text,length,is_long_context,metric_val,label_metric "<%@ Page Title="""" Language=""C#"" MasterPageFile=""~/Views/Shared/Site.MVC.Master"" Inherits=""System.Web.Mvc.ViewPage"" %>
Ctrl + S
Save and Continue
Alt + M
Template/Profile Tab
Alt + O
Constraints Tab
Alt + P
Preview Tab
Alt + L
Validation Tab
Alt + A
Analyst View Mode
Alt + I
Editor View Mode
Alt + G
Engineer View Mode

*

This template/profile is locked. Unlock the template/profile to edit.
Extensions
Identifier Type Value  
Move the template/profile to change the Implementation Guide, Type, or Applies To fields.
 
Value

CONF Message

CONF Message
Modifying this template/profile may impact one or more of the following templates which contain/imply this template/profile.

Implied By

Contained By

View Mode
Edit Note
Applies to...
The selection is not valid.
",16269,True,3083.2037713696645,median " HTML Tutorial
w3schools.com
THE WORLD'S LARGEST WEB DEVELOPER SITE
HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP HOW TO JQUERY W3.CSS PYTHON XML MORE FORUM EXAMPLES REFERENCES
×

×

×

×

HTML5 Tutorial

HTML HOME HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Styles HTML Formatting HTML Quotations HTML Comments HTML Colors HTML CSS HTML Links HTML Images HTML Tables HTML Lists HTML Blocks HTML Classes HTML Id HTML Iframes HTML JavaScript HTML File Paths HTML Head HTML Layout HTML Responsive HTML Computercode HTML Entities HTML Symbols HTML Charset HTML URL Encode HTML XHTML

HTML Forms

HTML Forms HTML Form Elements HTML Input Types HTML Input Attributes

HTML5

HTML5 Intro HTML5 Support HTML5 New Elements HTML5 Semantics HTML5 Migration HTML5 Style Guide

HTML Graphics

HTML Canvas HTML SVG HTML Google Maps

HTML Media

HTML Media HTML Video HTML Audio HTML Plug-ins HTML YouTube

HTML APIs

HTML Geolocation HTML Drag/Drop HTML Web Storage HTML Web Workers HTML SSE

HTML Examples

HTML Examples HTML Quiz HTML Exercises HTML Certificate HTML Summary HTML Accessibility

HTML References

HTML Tag List HTML Attributes HTML Events HTML Colors HTML Canvas HTML Audio/Video HTML Doctypes HTML Character Sets HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods PX to EM Converter Keyboard Shortcuts

HTML5 Tutorial

❮ Home Next ❯

With HTML you can create your own Website.

This tutorial teaches you everything about HTML.

HTML is easy to learn - You will enjoy it.


Examples in Every Chapter

This HTML tutorial contains hundreds of HTML examples.

With our online HTML editor, you can edit the HTML, and click on a button to view the result.

Example

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>This is a Heading</h1>
<p>This is a paragraph.</p>

</body>
</html>
Try it Yourself »

Click on the "Try it Yourself" button to see how it works.

Start learning HTML now!


HTML Examples

At the end of the HTML tutorial, you can find more than 200 examples.

With our online editor, you can edit and test each example yourself.

Go to HTML Examples!



HTML Exercises and Quiz Test

Test your HTML skills at W3Schools!

Start HTML Exercises!

Start HTML Quiz!


HTML References

At W3Schools you will find complete references about tags, attributes, events, color names, entities, character-sets, URL encoding, language codes, HTTP messages, and more.

HTML Tag Reference


HTML Exam - Get Your Diploma!

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The Bootstrap Certificate documents your knowledge of the Bootstrap framework.


❮ Home Next ❯

COLOR PICKER

SHARE



CERTIFICATES

HTML, CSS, JavaScript, PHP, jQuery, Bootstrap and XML.

Read More »


REPORT ERROR
PRINT PAGE
FORUM
ABOUT

×

Your Suggestion:


×

Thank You For Helping Us!

Your message has been sent to W3Schools.


W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 1999-2018 by Refsnes Data. All Rights Reserved.
Powered by W3.CSS.



",16162,False,2437.9808329849516,median "<%@ Page Title="""" Language=""C#"" MasterPageFile=""~/Views/Shared/Site.MVC.Master"" Inherits=""System.Web.Mvc.ViewPage"" %>
Ctrl + S
Save and Continue
Alt + M
Template/Profile Tab
Alt + O
Constraints Tab
Alt + P
Preview Tab
Alt + L
Validation Tab
Alt + A
Analyst View Mode
Alt + I
Editor View Mode
Alt + G
Engineer View Mode

*

This template/profile is locked. Unlock the template/profile to edit.
Extensions
Identifier Type Value  
Move the template/profile to change the Implementation Guide, Type, or Applies To fields.
 
Value

CONF Message

CONF Message
Modifying this template/profile may impact one or more of the following templates which contain/imply this template/profile.

Implied By

Contained By

View Mode
Edit Note
Applies to...
The selection is not valid.
",16308,True,3090.73801392759,median "<%@ Control Language=""C#"" AutoEventWireup=""true"" CodeFile=""updateWebWalletForm.ascx.cs"" Inherits=""web_WebUserControl"" %>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using com.payline.www;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs)
    {
        try
        {
            WebPaymentAPI ws =new WebPaymentAPI();
            payment payment =new payment();
            order order =new order();
            buyer buyer =new buyer();
            address address =new address();
            recurring recurring =new recurring();
            orderDetail orderDetail1 =new orderDetail1();
            orderDetail orderDetail2 =new orderDetail1();
            privateData privateData1 =new privateData();
            privateData privateData2 =new privateData();
            privateData privateData3 =new privateData();
            privateData[] privateDataList =null;
            
            string[] selectedCrontractList = new string[100];
            string token;
            string redirectURL;
            string contractNumber;
            string walletId;
            string updatePersonalDetails;
            string updatePaymentDetails;
                        
            contractNumber = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""paymentContractNumber""))).Text;
            if (contractNumber.Contains("";""))
            {
                string[] split = contractNumber.Split( new char {';'});
                selectedCrontractList = split;
                payment.contractNumber = Resources.Resource.CONTRACT_NUMBER;
            }
            else
            {
                payment.contractNumber = contractNumber;
                selectedCrontractList.SetValue(contractNumber, 0);
            }

            walletId = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""walletId""))).Text;
            updatePersonalDetails = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""updatePersonalDetails""))).Text;
            updatePaymentDetails = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""updatePaymentDetails""))).Text;
                                                                   
            // PRIVATE DATA (optional) 
            privateData1.key = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""privateDataKey1""))).Text;
            privateData1.value = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""privateDataValue1""))).Text;
            privateData2.key = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""privateDataKey2""))).Text;
            privateData2.value = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""privateDataValue2""))).Text;
            privateData3.key = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""privateDataKey3""))).Text;
            privateData3.value = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""privateDataValue3""))).Text;
                                                                           
            privateDataList.SetValue(privateData1,0);
            privateDataList.SetValue(privateData2,1);
            privateDataList.SetValue(privateData3,2);
            
            // TRANSACTION OPTIONS 
            string securityMode = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""securityMode""))).Text;
            if (securityMode == """")
                securityMode = Resources.Resource.SECURITY_MODE;
                
            string notificationURL = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""notificationURL""))).Text;
            if (notificationURL == """")
                notificationURL = Resources.Resource.NOTIFICATION_URL;
                        
            string returnURL = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""returnURL""))).Text;
            if (returnURL == """")
                returnURL = Resources.Resource.RETURN_URL;
            
            string cancelURL = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""cancelURL""))).Text;
            if (cancelURL == """")
                cancelURL = Resources.Resource.CANCEL_URL;
            
            string customPaymentPageCode = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""customPaymentPageCode""))).Text;
            if (customPaymentPageCode == """")
                customPaymentPageCode = Resources.Resource.CUSTOM_PAYMENT_PAGE_CODE;
                
            string customPaymentTemplateURL = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""customPaymentTemplateURL""))).Text;
            if (customPaymentTemplateURL == """")
                customPaymentTemplateURL = Resources.Resource.CUSTOM_PAYMENT_TEMPLATE_URL;
                
            string languageCode = ((TextBox)(Page.PreviousPage.FindControl(""updateWebWallet"".FindControl(""languageCode""))).Text;
            if (languageCode == """")
                languageCode = Resources.Resource.LANGUAGE_CODE;
                        
            
            if (Resources.Resource.PROXY_HOST != """" && Resources.Resource.PROXY_PORT != """")
                ws.Proxy = new System.Net.WebProxy(Resources.Resource.PROXY_HOST, Convert.ToInt32(Resources.Resource.PROXY_PORT));
            
            if (Resources.Resource.PROD == ""true"")
                ws.Url = Resources.Resource.ENDPOINT_WEB;

            ws.Credentials = new System.Net.NetworkCredential(Resources.Resource.MERCHANT_ID, Resources.Resource.ACCESS_KEY);
            
            result resultat = ws.updateWebWallet(contractNumber, walletId, updatePersonalDetails, updatePaymentDetails, languageCode, customPaymentPageCode, 
                                                                Resources.Resource.SECURITY_MODE, returnURL, cancelURL, notificationURL, privateDataList, customPaymentTemplateURL, 
                                                                out token, out redirectURL);
                           
            if (resultat.code == ""00000"")
            {
                Response.Redirect(redirectURL);
            }
            else
                Response.Write(""resultat message error : "" + resultat.longMessage);
        }
        catch (Exception exc)
        {
            Response.Write(exc.ToString());
        }            
    }
}
<form method="post" runat="server" class="payline-form">

	<fieldset>
        
        <div class="row">

            <label for="paymentContractNumber">Contract numbers</label>
            <asp:TextBox runat="server" id="paymentContractNumber" Text="001">

       		<span class="help">(separator if severals numbers : ";")</span>
        </div>
        <div class="row">

            <label for="walletId">Wallet Id</label>
            <asp:TextBox runat="server" id="walletId" Text="">
      		
        </div>      
        <div class="row">

            <label for="updatePersonalDetails">Update personal details</label>
            <asp:TextBox runat="server" id="updatePersonalDetails" Text="">
      		
        </div>                  
        <div class="row">

            <label for="updatePaymentDetails">Update payment details</label>
            <asp:TextBox runat="server" id="updatePaymentDetails" Text="">
      		
        </div>        
	</fieldset>
	<fieldset>

        <h4>Private datas</h4>
        <div class="row">
            <label for="privateDataKey1">Private data key 1</label>

            <asp:TextBox runat="server" id="privateDataKey1" Text="key 1" />

        </div>
        <div class="row">
            <label for="privateDataValue1">Private data value 1</label>

            <asp:TextBox runat="server" id="privateDataValue1" Text="value 1" />

        </div>  
        <hr/>
        <div class="row">
            <label for="privateDataKey2">Private data key 2</label>

            <asp:TextBox runat="server" id="privateDataKey2" Text="key 2" />

        </div>   
        <div class="row">
            <label for="privateDataValue2">Private data value 2</label>

            <asp:TextBox runat="server" id="privateDataValue2" Text="value 2" />

        </div>
        <hr/>
        <div class="row">
            <label for="privateDataKey3">Private data key 3</label>

            <asp:TextBox runat="server" id="privateDataKey3" Text="key 3" />

        </div>   
        <div class="row">
            <label for="privateDataValue3">Private data value 2</label>

            <asp:TextBox runat="server" id="privateDataValue3" Text="value 3" />

        </div>     
	</fieldset>
    <fieldset>
    	<h4>Transaction options</h4>
		<div class="row">

            <label for="securityMode">Security Mode</label>
            <asp:TextBox runat="server" id="securityMode" Text="" />

        		</div> 
 
		
		<div class="row">

            <label for="notificationURL">Notification url</label>
            <asp:TextBox runat="server" id="notificationURL" Text="" />

            <span class="help">(valid url like http:// or https://)</span>
		</div> 
        <div class="row">

            <label for="returnURL">Return url</label>
            <asp:TextBox runat="server" id="returnURL" Text="" />

            <span class="help">(valid url like http:// or https://)</span>
		</div>  
        <div class="row">

            <label for="cancelURL">Cancel url</label>
            <asp:TextBox runat="server" id="cancelURL" Text="" />

            <span class="help">(valid url like http:// or https://)</span>
		</div> 
        <div class="row">

            <label for="customPaymentPageCode">Custom payment page code</label>
            <asp:TextBox runat="server" id="customPaymentPageCode" Text="" />

		</div>
		<div class="row">

            <label for="customPaymentTemplateURL">Custom payment template URL</label>
            <asp:TextBox runat="server" id="customPaymentTemplateURL" Text="" />

		</div>
        <div class="row">
            <label for="languageCode">Language Code</label>   
            <asp:DropDownList runat="server" id="languageCode">

                <asp:ListItem value="fre/fra">FR</asp:ListItem>
                <asp:ListItem value="ger/deu">DE</asp:ListItem>

                <asp:ListItem value="eng">UK</asp:ListItem>
                <asp:ListItem value="ita">IT</asp:ListItem>

                <asp:ListItem value="spa">SP</asp:ListItem>
            </asp:DropDownList>
		</div>
    </fieldset>   
 
    <fieldset>
		<div class="row">

            <label for="debug">MODE DEBUG</label>
            <asp:Checkbox runat="server" id="debug" />

		</div>  
    </fieldset>       
    <asp:Button PostBackUrl="~/wallet/updateWebWallet.aspx" runat="server" CssClass="submit" Text="Start payment process" />
</form>
 
(separator if severals numbers : "";"")

Private datas



Transaction options

(valid url like http:// or https://)
(valid url like http:// or https://)
(valid url like http:// or https://)
FR DE UK IT SP
",16328,True,4497.911275932103,median "/* * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar SqlBase; @members { /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ public boolean legacy_setops_precedence_enbled = false; /** * Verify whether current token is a valid decimal token (which contains dot). * Returns true if the character that follows the token is not a digit or letter or underscore. * * For example: * For char stream ""2.3"", ""2."" is not a valid decimal token, because it is followed by digit '3'. * For char stream ""2.3_"", ""2.3"" is not a valid decimal token, because it is followed by '_'. * For char stream ""2.3W"", ""2.3"" is not a valid decimal token, because it is followed by 'W'. * For char stream ""12.0D 34.E2+0.12 "" 12.0D is a valid decimal token because it is followed * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+' * which is not a digit or letter or underscore. */ public boolean isValidDecimal() { int nextChar = _input.LA(1); if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' || nextChar == '_') { return false; } else { return true; } } /** * When true, ANSI SQL parsing mode is enabled. */ public boolean ansi = false; } singleStatement : statement EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleMultipartIdentifier : multipartIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; singleInterval : INTERVAL? multiUnitsInterval EOF ; statement : query #statementDefault | ctes? dmlStatementNoWith #dmlStatement | USE NAMESPACE? multipartIdentifier #use | CREATE (database | NAMESPACE) (IF NOT EXISTS)? multipartIdentifier ((COMMENT comment=STRING) | locationSpec | (WITH (DBPROPERTIES | PROPERTIES) tablePropertyList))* #createNamespace | ALTER (database | NAMESPACE) multipartIdentifier SET (DBPROPERTIES | PROPERTIES) tablePropertyList #setNamespaceProperties | ALTER database db=errorCapturingIdentifier SET locationSpec #setDatabaseLocation | DROP (database | NAMESPACE) (IF EXISTS)? multipartIdentifier (RESTRICT | CASCADE)? #dropNamespace | SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showNamespaces | createTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? ((COMMENT comment=STRING) | (PARTITIONED BY '(' partitionColumns=colTypeList ')' | PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier tableProvider? locationSpec? #createTableLike | replaceTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #replaceTable | ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) columns=qualifiedColTypeWithPositionList #addTableColumns | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) '(' columns=qualifiedColTypeWithPositionList ')' #addTableColumns | ALTER TABLE table=multipartIdentifier RENAME COLUMN from=multipartIdentifier TO to=errorCapturingIdentifier #renameTableColumn | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) '(' columns=multipartIdentifierList ')' #dropTableColumns | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) columns=multipartIdentifierList #dropTableColumns | ALTER (TABLE | VIEW) from=tableIdentifier RENAME TO to=tableIdentifier #renameTable | ALTER (TABLE | VIEW) multipartIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) multipartIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ALTER TABLE table=multipartIdentifier (ALTER | CHANGE) COLUMN? column=multipartIdentifier (TYPE dataType)? (COMMENT comment=STRING)? colPosition? #alterTableColumn | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDEPROPERTIES tablePropertyList #setTableSerDe | ALTER (TABLE | VIEW) multipartIdentifier ADD (IF NOT EXISTS)? partitionSpecLocation+ #addTablePartition | ALTER TABLE multipartIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER (TABLE | VIEW) multipartIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER TABLE multipartIdentifier (partitionSpec)? SET locationSpec #setTableLocation | ALTER TABLE multipartIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? multipartIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? multipartIdentifier #dropView | CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)? VIEW (IF NOT EXISTS)? tableIdentifier identifierCommentList? ((COMMENT STRING) | (PARTITIONED ON identifierList) | (TBLPROPERTIES tablePropertyList))* AS query #createView | CREATE (OR REPLACE)? GLOBAL? TEMPORARY VIEW tableIdentifier ('(' colTypeList ')')? tableProvider (OPTIONS tablePropertyList)? #createTempViewUsing | ALTER VIEW multipartIdentifier AS? query #alterViewQuery | CREATE (OR REPLACE)? TEMPORARY? FUNCTION (IF NOT EXISTS)? multipartIdentifier AS className=STRING (USING resource (',' resource)*)? #createFunction | DROP TEMPORARY? FUNCTION (IF EXISTS)? multipartIdentifier #dropFunction | EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)? statement #explain | SHOW TABLES ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) namespace=multipartIdentifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW TBLPROPERTIES table=multipartIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) table=multipartIdentifier ((FROM | IN) namespace=multipartIdentifier)? #showColumns | SHOW PARTITIONS multipartIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (multipartIdentifier | pattern=STRING))? #showFunctions | SHOW CREATE TABLE multipartIdentifier #showCreateTable | SHOW CURRENT NAMESPACE #showCurrentNamespace | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) (database | NAMESPACE) EXTENDED? multipartIdentifier #describeNamespace | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? multipartIdentifier partitionSpec? describeColName? #describeTable | (DESC | DESCRIBE) QUERY? query #describeQuery | REFRESH TABLE multipartIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE LAZY? TABLE multipartIdentifier (OPTIONS options=tablePropertyList)? (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? multipartIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE multipartIdentifier partitionSpec? #loadData | TRUNCATE TABLE multipartIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE multipartIdentifier #repairTable | op=(ADD | LIST) identifier .*? #manageResource | SET ROLE .*? #failNativeCommand | SET .*? #setConfiguration | RESET #resetConfiguration | DELETE FROM multipartIdentifier tableAlias whereClause? #deleteFromTable | UPDATE multipartIdentifier tableAlias setClause whereClause? #updateTable | MERGE INTO target=multipartIdentifier targetAlias=tableAlias USING (source=multipartIdentifier | '(' sourceQuery=query')') sourceAlias=tableAlias ON mergeCondition=booleanExpression matchedClause* notMatchedClause* #mergeIntoTable | unsupportedHiveNativeCommands .*? #failNativeCommand ; unsupportedHiveNativeCommands : kw1=CREATE kw2=ROLE | kw1=DROP kw2=ROLE | kw1=GRANT kw2=ROLE? | kw1=REVOKE kw2=ROLE? | kw1=SHOW kw2=GRANT | kw1=SHOW kw2=ROLE kw3=GRANT? | kw1=SHOW kw2=PRINCIPALS | kw1=SHOW kw2=ROLES | kw1=SHOW kw2=CURRENT kw3=ROLES | kw1=EXPORT kw2=TABLE | kw1=IMPORT kw2=TABLE | kw1=SHOW kw2=COMPACTIONS | kw1=SHOW kw2=CREATE kw3=TABLE | kw1=SHOW kw2=TRANSACTIONS | kw1=SHOW kw2=INDEXES | kw1=SHOW kw2=LOCKS | kw1=CREATE kw2=INDEX | kw1=DROP kw2=INDEX | kw1=ALTER kw2=INDEX | kw1=LOCK kw2=TABLE | kw1=LOCK kw2=DATABASE | kw1=UNLOCK kw2=TABLE | kw1=UNLOCK kw2=DATABASE | kw1=CREATE kw2=TEMPORARY kw3=MACRO | kw1=DROP kw2=TEMPORARY kw3=MACRO | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=CLUSTERED | kw1=ALTER kw2=TABLE tableIdentifier kw3=CLUSTERED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SORTED | kw1=ALTER kw2=TABLE tableIdentifier kw3=SKEWED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SKEWED | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=STORED kw5=AS kw6=DIRECTORIES | kw1=ALTER kw2=TABLE tableIdentifier kw3=SET kw4=SKEWED kw5=LOCATION | kw1=ALTER kw2=TABLE tableIdentifier kw3=EXCHANGE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=ARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=UNARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=SET kw4=FILEFORMAT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=REPLACE kw4=COLUMNS | kw1=START kw2=TRANSACTION | kw1=COMMIT | kw1=ROLLBACK | kw1=DFS | kw1=DELETE kw2=FROM ; createTableHeader : CREATE TEMPORARY? EXTERNAL? TABLE (IF NOT EXISTS)? multipartIdentifier ; replaceTableHeader : (CREATE OR)? REPLACE TABLE multipartIdentifier ; bucketSpec : CLUSTERED BY identifierList (SORTED BY orderedIdentifierList)? INTO INTEGER_VALUE BUCKETS ; skewSpec : SKEWED BY identifierList ON (constantList | nestedConstantList) (STORED AS DIRECTORIES)? ; locationSpec : LOCATION STRING ; query : ctes? queryTerm queryOrganization ; insertInto : INSERT OVERWRITE TABLE? multipartIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? multipartIdentifier partitionSpec? (IF NOT EXISTS)? #insertIntoTable | INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat? #insertOverwriteHiveDir | INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)? tableProvider (OPTIONS options=tablePropertyList)? #insertOverwriteDir ; partitionSpecLocation : partitionSpec locationSpec? ; partitionSpec : PARTITION '(' partitionVal (',' partitionVal)* ')' ; partitionVal : identifier (EQ constant)? ; database : DATABASE | SCHEMA ; describeFuncName : qualifiedName | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=errorCapturingIdentifier (columnAliases=identifierList)? AS? '(' query ')' ; tableProvider : USING multipartIdentifier ; tablePropertyList : '(' tableProperty (',' tableProperty)* ')' ; tableProperty : key=tablePropertyKey (EQ? value=tablePropertyValue)? ; tablePropertyKey : identifier ('.' identifier)* | STRING ; tablePropertyValue : INTEGER_VALUE | DECIMAL_VALUE | booleanValue | STRING ; constantList : '(' constant (',' constant)* ')' ; nestedConstantList : '(' constantList (',' constantList)* ')' ; createFileFormat : STORED AS fileFormat | STORED BY storageHandler ; fileFormat : INPUTFORMAT inFmt=STRING OUTPUTFORMAT outFmt=STRING #tableFileFormat | identifier #genericFileFormat ; storageHandler : STRING (WITH SERDEPROPERTIES tablePropertyList)? ; resource : identifier STRING ; dmlStatementNoWith : insertInto queryTerm queryOrganization #singleInsertQuery | fromClause multiInsertQueryBody+ #multiInsertQuery ; queryOrganization : (ORDER BY order+=sortItem (',' order+=sortItem)*)? (CLUSTER BY clusterBy+=expression (',' clusterBy+=expression)*)? (DISTRIBUTE BY distributeBy+=expression (',' distributeBy+=expression)*)? (SORT BY sort+=sortItem (',' sort+=sortItem)*)? windowClause? (LIMIT (ALL | limit=expression))? ; multiInsertQueryBody : insertInto fromStatementBody ; queryTerm : queryPrimary #queryTermDefault | left=queryTerm {legacy_setops_precedence_enbled}? operator=(INTERSECT | UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=INTERSECT setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=(UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation ; queryPrimary : querySpecification #queryPrimaryDefault | fromStatement #fromStmt | TABLE multipartIdentifier #table | inlineTable #inlineTableDefault1 | '(' query ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; fromStatement : fromClause fromStatementBody+ ; fromStatementBody : transformClause whereClause? queryOrganization | selectClause lateralView* whereClause? aggregationClause? havingClause? windowClause? queryOrganization ; querySpecification : transformClause fromClause? whereClause? #transformQuerySpecification | selectClause fromClause? lateralView* whereClause? aggregationClause? havingClause? windowClause? #regularQuerySpecification ; transformClause : (SELECT kind=TRANSFORM '(' namedExpressionSeq ')' | kind=MAP namedExpressionSeq | kind=REDUCE namedExpressionSeq) inRowFormat=rowFormat? (RECORDWRITER recordWriter=STRING)? USING script=STRING (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList) ')')))? outRowFormat=rowFormat? (RECORDREADER recordReader=STRING)? ; selectClause : SELECT (hints+=hint)* setQuantifier? namedExpressionSeq ; setClause : SET assignmentList ; matchedClause : WHEN MATCHED (AND matchedCond=booleanExpression)? THEN matchedAction ; notMatchedClause : WHEN NOT MATCHED (AND notMatchedCond=booleanExpression)? THEN notMatchedAction ; matchedAction : DELETE | UPDATE SET ASTERISK | UPDATE SET assignmentList ; notMatchedAction : INSERT ASTERISK | INSERT '(' columns=multipartIdentifierList ')' VALUES '(' expression (',' expression)* ')' ; assignmentList : assignment (',' assignment)* ; assignment : key=multipartIdentifier EQ value=expression ; whereClause : WHERE booleanExpression ; havingClause : HAVING booleanExpression ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregationClause : GROUP BY groupingExpressions+=expression (',' groupingExpressions+=expression)* ( WITH kind=ROLLUP | WITH kind=CUBE | kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')')? | GROUP BY kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')' ; groupingSet : '(' (expression (',' expression)*)? ')' | expression ; pivotClause : PIVOT '(' aggregates=namedExpressionSeq FOR pivotColumn IN '(' pivotValues+=pivotValue (',' pivotValues+=pivotValue)* ')' ')' ; pivotColumn : identifiers+=identifier | '(' identifiers+=identifier (',' identifiers+=identifier)* ')' ; pivotValue : expression (AS? identifier)? ; lateralView : LATERAL VIEW (OUTER)? qualifiedName '(' (expression (',' expression)*)? ')' tblName=identifier (AS? colName+=identifier (',' colName+=identifier)*)? ; setQuantifier : DISTINCT | ALL ; relation : relationPrimary joinRelation* ; joinRelation : (joinType) JOIN right=relationPrimary joinCriteria? | NATURAL joinType JOIN right=relationPrimary ; joinType : INNER? | CROSS | LEFT OUTER? | LEFT? SEMI | RIGHT OUTER? | FULL OUTER? | LEFT? ANTI ; joinCriteria : ON booleanExpression | USING identifierList ; sample : TABLESAMPLE '(' sampleMethod? ')' ; sampleMethod : negativeSign=MINUS? percentage=(INTEGER_VALUE | DECIMAL_VALUE) PERCENTLIT #sampleByPercentile | expression ROWS #sampleByRows | sampleType=BUCKET numerator=INTEGER_VALUE OUT OF denominator=INTEGER_VALUE (ON (identifier | qualifiedName '(' ')'))? #sampleByBucket | bytes=expression #sampleByBytes ; identifierList : '(' identifierSeq ')' ; identifierSeq : ident+=errorCapturingIdentifier (',' ident+=errorCapturingIdentifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : ident=errorCapturingIdentifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier (COMMENT STRING)? ; relationPrimary : multipartIdentifier sample? tableAlias #tableName | '(' query ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : funcName=errorCapturingIdentifier '(' (expression (',' expression)*)? ')' tableAlias ; tableAlias : (AS? strictIdentifier identifierList?)? ; rowFormat : ROW FORMAT SERDE name=STRING (WITH SERDEPROPERTIES props=tablePropertyList)? #rowFormatSerde | ROW FORMAT DELIMITED (FIELDS TERMINATED BY fieldsTerminatedBy=STRING (ESCAPED BY escapedBy=STRING)?)? (COLLECTION ITEMS TERMINATED BY collectionItemsTerminatedBy=STRING)? (MAP KEYS TERMINATED BY keysTerminatedBy=STRING)? (LINES TERMINATED BY linesSeparatedBy=STRING)? (NULL DEFINED AS nullDefinedAs=STRING)? #rowFormatDelimited ; multipartIdentifierList : multipartIdentifier (',' multipartIdentifier)* ; multipartIdentifier : parts+=errorCapturingIdentifier ('.' parts+=errorCapturingIdentifier)* ; tableIdentifier : (db=errorCapturingIdentifier '.')? table=errorCapturingIdentifier ; functionIdentifier : (db=errorCapturingIdentifier '.')? function=errorCapturingIdentifier ; namedExpression : expression (AS? (name=errorCapturingIdentifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; transformList : '(' transforms+=transform (',' transforms+=transform)* ')' ; transform : qualifiedName #identityTransform | transformName=identifier '(' argument+=transformArgument (',' argument+=transformArgument)* ')' #applyTransform ; transformArgument : qualifiedName | constant ; expression : booleanExpression ; booleanExpression : NOT booleanExpression #logicalNot | EXISTS '(' query ')' #exists | valueExpression predicate? #predicated | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary ; predicate : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=(RLIKE | LIKE) pattern=valueExpression | IS NOT? kind=NULL | IS NOT? kind=(TRUE | FALSE | UNKNOWN) | IS NOT? kind=DISTINCT FROM right=valueExpression ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS | TILDE) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS | CONCAT_PIPE) right=valueExpression #arithmeticBinary | left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary | left=valueExpression operator=HAT right=valueExpression #arithmeticBinary | left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary | left=valueExpression comparisonOperator right=valueExpression #comparison ; primaryExpression : name=(CURRENT_DATE | CURRENT_TIMESTAMP) #currentDatetime | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase | CAST '(' expression AS dataType ')' #cast | STRUCT '(' (argument+=namedExpression (',' argument+=namedExpression)*)? ')' #struct | (FIRST | FIRST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #first | (LAST | LAST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #last | POSITION '(' substr=valueExpression IN str=valueExpression ')' #position | constant #constantDefault | ASTERISK #star | qualifiedName '.' ASTERISK #star | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor | '(' query ')' #subqueryExpression | qualifiedName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (OVER windowSpec)? #functionCall | identifier '->' expression #lambda | '(' identifier (',' identifier)+ ')' '->' expression #lambda | value=primaryExpression '[' index=valueExpression ']' #subscript | identifier #columnReference | base=primaryExpression '.' fieldName=identifier #dereference | '(' expression ')' #parenthesizedExpression | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract | (SUBSTR | SUBSTRING) '(' str=valueExpression (FROM | ',') pos=valueExpression ((FOR | ',') len=valueExpression)? ')' #substring | TRIM '(' trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)? FROM srcStr=valueExpression ')' #trim | OVERLAY '(' input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? ')' #overlay ; constant : NULL #nullLiteral | interval #intervalLiteral | negativeSign=MINUS? identifier STRING #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral | STRING+ #stringLiteral ; comparisonOperator : EQ | NEQ | NEQJ | LT | LTE | GT | GTE | NSEQ ; arithmeticOperator : PLUS | MINUS | ASTERISK | SLASH | PERCENT | DIV | TILDE | AMPERSAND | PIPE | CONCAT_PIPE | HAT ; predicateOperator : OR | AND | IN | NOT ; booleanValue : TRUE | FALSE ; interval : negativeSign=MINUS? INTERVAL (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval)? | {ansi}? (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval) ; errorCapturingMultiUnitsInterval : multiUnitsInterval unitToUnitInterval? ; multiUnitsInterval : (intervalValue intervalUnit)+ ; errorCapturingUnitToUnitInterval : body=unitToUnitInterval (error1=multiUnitsInterval | error2=unitToUnitInterval)? ; unitToUnitInterval : value=intervalValue from=intervalUnit TO to=intervalUnit ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; intervalUnit : DAY | DAYS | HOUR | HOURS | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | SECOND | SECONDS | WEEK | WEEKS | YEAR | YEARS ; colPosition : FIRST | AFTER multipartIdentifier ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; qualifiedColTypeWithPositionList : qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)* ; qualifiedColTypeWithPosition : name=multipartIdentifier dataType (COMMENT comment=STRING)? colPosition? ; colTypeList : colType (',' colType)* ; colType : colName=errorCapturingIdentifier dataType (COMMENT STRING)? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (COMMENT STRING)? ; whenClause : WHEN condition=expression THEN result=expression ; windowClause : WINDOW namedWindow (',' namedWindow)* ; namedWindow : name=errorCapturingIdentifier AS windowSpec ; windowSpec : name=errorCapturingIdentifier #windowRef | '('name=errorCapturingIdentifier')' #windowRef | '(' ( CLUSTER BY partition+=expression (',' partition+=expression)* | ((PARTITION | DISTRIBUTE) BY partition+=expression (',' partition+=expression)*)? ((ORDER | SORT) BY sortItem (',' sortItem)*)?) windowFrame? ')' #windowDef ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=(PRECEDING | FOLLOWING) | boundType=CURRENT ROW | expression boundType=(PRECEDING | FOLLOWING) ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; qualifiedName : identifier ('.' identifier)* ; // this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table` // replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise // valid expressions such as ""a-b"" can be recognized as an identifier errorCapturingIdentifier : identifier errorCapturingIdentifierExtra ; // extra left-factoring grammar errorCapturingIdentifierExtra : (MINUS identifier)+ #errorIdent | #realIdent ; identifier : strictIdentifier | {!ansi}? strictNonReserved ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | {ansi}? ansiNonReserved #unquotedIdentifier | {!ansi}? nonReserved #unquotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; number : MINUS? DECIMAL_VALUE #decimalLiteral | MINUS? INTEGER_VALUE #integerLiteral | MINUS? BIGINT_LITERAL #bigIntLiteral | MINUS? SMALLINT_LITERAL #smallIntLiteral | MINUS? TINYINT_LITERAL #tinyIntLiteral | MINUS? DOUBLE_LITERAL #doubleLiteral | MINUS? BIGDECIMAL_LITERAL #bigDecimalLiteral ; // When `spark.sql.dialect.spark.ansi.enabled=true`, there are 2 kinds of keywords in Spark SQL. // - Reserved keywords: // Keywords that are reserved and can't be used as identifiers for table, view, column, // function, alias, etc. // - Non-reserved keywords: // Keywords that have a special meaning only in particular contexts and can be used as // identifiers in other contexts. For example, `SELECT 1 WEEK` is an interval literal, but WEEK // can be used as identifiers in other places. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The non-reserved keywords are listed below. Keywords not in this list are reserved keywords. ansiNonReserved : ADD | AFTER | ALTER | ANALYZE | ARCHIVE | ARRAY | ASC | AT | BETWEEN | BUCKET | BUCKETS | BY | CACHE | CASCADE | CHANGE | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLECTION | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | COST | CUBE | CURRENT | DATA | DATABASE | DATABASES | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTRIBUTE | DIV | DROP | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FORMAT | FORMATTED | FUNCTION | FUNCTIONS | GLOBAL | GROUPING | HOURS | IF | IGNORE | IMPORT | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | ITEMS | KEYS | LAST | LATERAL | LAZY | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTES | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NULLS | OF | OPTION | OPTIONS | OUT | OUTPUTFORMAT | OVER | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECONDS | SEPARATED | SERDE | SERDEPROPERTIES | SET | SETS | SHOW | SKEWED | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | TOUCH | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | UNARCHIVE | UNBOUNDED | UNCACHE | UNLOCK | UNSET | UPDATE | USE | VALUES | VIEW | WEEK | WEEKS | WINDOW | YEARS ; // When `spark.sql.dialect.spark.ansi.enabled=false`, there are 2 kinds of keywords in Spark SQL. // - Non-reserved keywords: // Same definition as the one when `spark.sql.dialect.spark.ansi.enabled=true`. // - Strict-non-reserved keywords: // A strict version of non-reserved keywords, which can not be used as table alias. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The strict-non-reserved keywords are listed in `strictNonReserved`. // The non-reserved keywords are listed in `nonReserved`. // These 2 together contain all the keywords. strictNonReserved : ANTI | CROSS | EXCEPT | FULL | INNER | INTERSECT | JOIN | LEFT | NATURAL | ON | RIGHT | SEMI | SETMINUS | UNION | USING ; nonReserved : ADD | AFTER | ALL | ALTER | ANALYZE | AND | ANY | ARCHIVE | ARRAY | AS | ASC | AT | AUTHORIZATION | BETWEEN | BOTH | BUCKET | BUCKETS | BY | CACHE | CASCADE | CASE | CAST | CHANGE | CHECK | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLATE | COLLECTION | COLUMN | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | CONSTRAINT | COST | CREATE | CUBE | CURRENT | CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATABASES | DAY | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTINCT | DISTRIBUTE | DIV | DROP | ELSE | END | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FALSE | FETCH | FIELDS | FILEFORMAT | FIRST | FIRST_VALUE | FOLLOWING | FOR | FOREIGN | FORMAT | FORMATTED | FROM | FUNCTION | FUNCTIONS | GLOBAL | GRANT | GROUP | GROUPING | HAVING | HOUR | HOURS | IF | IGNORE | IMPORT | IN | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | INTO | IS | ITEMS | KEYS | LAST | LAST_VALUE | LATERAL | LAZY | LEADING | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NOT | NULL | NULLS | OF | ONLY | OPTION | OPTIONS | OR | ORDER | OUT | OUTER | OUTPUTFORMAT | OVER | OVERLAPS | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRIMARY | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFERENCES | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECOND | SECONDS | SELECT | SEPARATED | SERDE | SERDEPROPERTIES | SESSION_USER | SET | SETS | SHOW | SKEWED | SOME | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLE | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | THEN | TO | TOUCH | TRAILING | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNIQUE | UNKNOWN | UNLOCK | UNSET | UPDATE | USE | USER | VALUES | VIEW | WEEK | WEEKS | WHEN | WHERE | WINDOW | WITH | YEAR | YEARS ; // NOTE: If you add a new token in the list below, you should update the list of keywords // in `docs/sql-keywords.md`. If the token is a non-reserved keyword, // please update `ansiNonReserved` and `nonReserved` as well. //============================ // Start of the keywords list //============================ ADD: 'ADD'; AFTER: 'AFTER'; ALL: 'ALL'; ALTER: 'ALTER'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY'; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; AUTHORIZATION: 'AUTHORIZATION'; BETWEEN: 'BETWEEN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; CACHE: 'CACHE'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CHANGE: 'CHANGE'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONSTRAINT: 'CONSTRAINT'; COST: 'COST'; CREATE: 'CREATE'; CROSS: 'CROSS'; CUBE: 'CUBE'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; DATA: 'DATA'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES' | 'SCHEMAS'; DAY: 'DAY'; DAYS: 'DAYS'; DBPROPERTIES: 'DBPROPERTIES'; DEFINED: 'DEFINED'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DROP: 'DROP'; ELSE: 'ELSE'; END: 'END'; ESCAPED: 'ESCAPED'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXISTS: 'EXISTS'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FIRST_VALUE: 'FIRST_VALUE'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HAVING: 'HAVING'; HOUR: 'HOUR'; HOURS: 'HOURS'; IF: 'IF'; IGNORE: 'IGNORE'; IMPORT: 'IMPORT'; IN: 'IN'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INTO: 'INTO'; IS: 'IS'; ITEMS: 'ITEMS'; JOIN: 'JOIN'; KEYS: 'KEYS'; LAST: 'LAST'; LAST_VALUE: 'LAST_VALUE'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEFT: 'LEFT'; LIKE: 'LIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; MACRO: 'MACRO'; MAP: 'MAP'; MATCHED: 'MATCHED'; MERGE: 'MERGE'; MICROSECOND: 'MICROSECOND'; MICROSECONDS: 'MICROSECONDS'; MILLISECOND: 'MILLISECOND'; MILLISECONDS: 'MILLISECONDS'; MINUTE: 'MINUTE'; MINUTES: 'MINUTES'; MONTH: 'MONTH'; MONTHS: 'MONTHS'; MSCK: 'MSCK'; NAMESPACE: 'NAMESPACE'; NAMESPACES: 'NAMESPACES'; NATURAL: 'NATURAL'; NO: 'NO'; NOT: 'NOT' | '!'; NULL: 'NULL'; NULLS: 'NULLS'; OF: 'OF'; ON: 'ON'; ONLY: 'ONLY'; OPTION: 'OPTION'; OPTIONS: 'OPTIONS'; OR: 'OR'; ORDER: 'ORDER'; OUT: 'OUT'; OUTER: 'OUTER'; OUTPUTFORMAT: 'OUTPUTFORMAT'; OVER: 'OVER'; OVERLAPS: 'OVERLAPS'; OVERLAY: 'OVERLAY'; OVERWRITE: 'OVERWRITE'; PARTITION: 'PARTITION'; PARTITIONED: 'PARTITIONED'; PARTITIONS: 'PARTITIONS'; PERCENTLIT: 'PERCENT'; PIVOT: 'PIVOT'; PLACING: 'PLACING'; POSITION: 'POSITION'; PRECEDING: 'PRECEDING'; PRIMARY: 'PRIMARY'; PRINCIPALS: 'PRINCIPALS'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUERY: 'QUERY'; RANGE: 'RANGE'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESPECT: 'RESPECT'; RESTRICT: 'RESTRICT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SCHEMA: 'SCHEMA'; SECOND: 'SECOND'; SECONDS: 'SECONDS'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHOW: 'SHOW'; SKEWED: 'SKEWED'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STRUCT: 'STRUCT'; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TO: 'TO'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNSET: 'UNSET'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUES: 'VALUES'; VIEW: 'VIEW'; WEEK: 'WEEK'; WEEKS: 'WEEKS'; WHEN: 'WHEN'; WHERE: 'WHERE'; WINDOW: 'WINDOW'; WITH: 'WITH'; YEAR: 'YEAR'; YEARS: 'YEARS'; //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; DIV: 'DIV'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; STRING : '\\'' ( ~('\\''|'\\\\') | ('\\\\' .) )* '\\'' | '""' ( ~('""'|'\\\\') | ('\\\\' .) )* '""' ; BIGINT_LITERAL : DIGIT+ 'L' ; SMALLINT_LITERAL : DIGIT+ 'S' ; TINYINT_LITERAL : DIGIT+ 'Y' ; INTEGER_VALUE : DIGIT+ ; DECIMAL_VALUE : DIGIT+ EXPONENT | DECIMAL_DIGITS EXPONENT? {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; SIMPLE_COMMENT : '--' ~[\\r\\n]* '\\r'? '\\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ; ",12367,False,2316.691918797024,median "/* * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar SqlBase; @members { /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ public boolean legacy_setops_precedence_enbled = false; /** * Verify whether current token is a valid decimal token (which contains dot). * Returns true if the character that follows the token is not a digit or letter or underscore. * * For example: * For char stream ""2.3"", ""2."" is not a valid decimal token, because it is followed by digit '3'. * For char stream ""2.3_"", ""2.3"" is not a valid decimal token, because it is followed by '_'. * For char stream ""2.3W"", ""2.3"" is not a valid decimal token, because it is followed by 'W'. * For char stream ""12.0D 34.E2+0.12 "" 12.0D is a valid decimal token because it is followed * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+' * which is not a digit or letter or underscore. */ public boolean isValidDecimal() { int nextChar = _input.LA(1); if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' || nextChar == '_') { return false; } else { return true; } } /** * When true, ANSI SQL parsing mode is enabled. */ public boolean ansi = false; } singleStatement : statement EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleMultipartIdentifier : multipartIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; singleInterval : INTERVAL? (intervalValue intervalUnit)+ EOF ; statement : query #statementDefault | ctes? dmlStatementNoWith #dmlStatement | USE NAMESPACE? multipartIdentifier #use | CREATE (database | NAMESPACE) (IF NOT EXISTS)? multipartIdentifier ((COMMENT comment=STRING) | locationSpec | (WITH (DBPROPERTIES | PROPERTIES) tablePropertyList))* #createNamespace | ALTER database db=errorCapturingIdentifier SET DBPROPERTIES tablePropertyList #setDatabaseProperties | ALTER database db=errorCapturingIdentifier SET locationSpec #setDatabaseLocation | DROP (database | NAMESPACE) (IF EXISTS)? multipartIdentifier (RESTRICT | CASCADE)? #dropNamespace | SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showNamespaces | createTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? ((COMMENT comment=STRING) | (PARTITIONED BY '(' partitionColumns=colTypeList ')' | PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier locationSpec? #createTableLike | replaceTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #replaceTable | ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) columns=qualifiedColTypeWithPositionList #addTableColumns | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) '(' columns=qualifiedColTypeWithPositionList ')' #addTableColumns | ALTER TABLE multipartIdentifier RENAME COLUMN from=qualifiedName TO to=identifier #renameTableColumn | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) '(' columns=qualifiedNameList ')' #dropTableColumns | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) columns=qualifiedNameList #dropTableColumns | ALTER (TABLE | VIEW) from=tableIdentifier RENAME TO to=tableIdentifier #renameTable | ALTER (TABLE | VIEW) multipartIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) multipartIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ALTER TABLE multipartIdentifier (ALTER | CHANGE) COLUMN? qualifiedName (TYPE dataType)? (COMMENT comment=STRING)? colPosition? #alterTableColumn | ALTER TABLE tableIdentifier partitionSpec? CHANGE COLUMN? colName=errorCapturingIdentifier colType colPosition? #changeColumn | ALTER TABLE tableIdentifier (partitionSpec)? SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ALTER TABLE tableIdentifier (partitionSpec)? SET SERDEPROPERTIES tablePropertyList #setTableSerDe | ALTER TABLE tableIdentifier ADD (IF NOT EXISTS)? partitionSpecLocation+ #addTablePartition | ALTER VIEW tableIdentifier ADD (IF NOT EXISTS)? partitionSpec+ #addTablePartition | ALTER TABLE multipartIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER (TABLE | VIEW) multipartIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER TABLE multipartIdentifier (partitionSpec)? SET locationSpec #setTableLocation | ALTER TABLE multipartIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? multipartIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? multipartIdentifier #dropView | CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)? VIEW (IF NOT EXISTS)? tableIdentifier identifierCommentList? ((COMMENT STRING) | (PARTITIONED ON identifierList) | (TBLPROPERTIES tablePropertyList))* AS query #createView | CREATE (OR REPLACE)? GLOBAL? TEMPORARY VIEW tableIdentifier ('(' colTypeList ')')? tableProvider (OPTIONS tablePropertyList)? #createTempViewUsing | ALTER VIEW tableIdentifier AS? query #alterViewQuery | CREATE (OR REPLACE)? TEMPORARY? FUNCTION (IF NOT EXISTS)? qualifiedName AS className=STRING (USING resource (',' resource)*)? #createFunction | DROP TEMPORARY? FUNCTION (IF EXISTS)? qualifiedName #dropFunction | EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)? statement #explain | SHOW TABLES ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) db=errorCapturingIdentifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW TBLPROPERTIES table=tableIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) table=multipartIdentifier ((FROM | IN) namespace=multipartIdentifier)? #showColumns | SHOW PARTITIONS multipartIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (qualifiedName | pattern=STRING))? #showFunctions | SHOW CREATE TABLE multipartIdentifier #showCreateTable | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) database EXTENDED? db=errorCapturingIdentifier #describeDatabase | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? multipartIdentifier partitionSpec? describeColName? #describeTable | (DESC | DESCRIBE) QUERY? query #describeQuery | REFRESH TABLE multipartIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE LAZY? TABLE multipartIdentifier (OPTIONS options=tablePropertyList)? (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? multipartIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE multipartIdentifier partitionSpec? #loadData | TRUNCATE TABLE multipartIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE multipartIdentifier #repairTable | op=(ADD | LIST) identifier .*? #manageResource | SET ROLE .*? #failNativeCommand | SET .*? #setConfiguration | RESET #resetConfiguration | DELETE FROM multipartIdentifier tableAlias whereClause? #deleteFromTable | UPDATE multipartIdentifier tableAlias setClause whereClause? #updateTable | unsupportedHiveNativeCommands .*? #failNativeCommand ; unsupportedHiveNativeCommands : kw1=CREATE kw2=ROLE | kw1=DROP kw2=ROLE | kw1=GRANT kw2=ROLE? | kw1=REVOKE kw2=ROLE? | kw1=SHOW kw2=GRANT | kw1=SHOW kw2=ROLE kw3=GRANT? | kw1=SHOW kw2=PRINCIPALS | kw1=SHOW kw2=ROLES | kw1=SHOW kw2=CURRENT kw3=ROLES | kw1=EXPORT kw2=TABLE | kw1=IMPORT kw2=TABLE | kw1=SHOW kw2=COMPACTIONS | kw1=SHOW kw2=CREATE kw3=TABLE | kw1=SHOW kw2=TRANSACTIONS | kw1=SHOW kw2=INDEXES | kw1=SHOW kw2=LOCKS | kw1=CREATE kw2=INDEX | kw1=DROP kw2=INDEX | kw1=ALTER kw2=INDEX | kw1=LOCK kw2=TABLE | kw1=LOCK kw2=DATABASE | kw1=UNLOCK kw2=TABLE | kw1=UNLOCK kw2=DATABASE | kw1=CREATE kw2=TEMPORARY kw3=MACRO | kw1=DROP kw2=TEMPORARY kw3=MACRO | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=CLUSTERED | kw1=ALTER kw2=TABLE tableIdentifier kw3=CLUSTERED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SORTED | kw1=ALTER kw2=TABLE tableIdentifier kw3=SKEWED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SKEWED | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=STORED kw5=AS kw6=DIRECTORIES | kw1=ALTER kw2=TABLE tableIdentifier kw3=SET kw4=SKEWED kw5=LOCATION | kw1=ALTER kw2=TABLE tableIdentifier kw3=EXCHANGE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=ARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=UNARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=SET kw4=FILEFORMAT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=REPLACE kw4=COLUMNS | kw1=START kw2=TRANSACTION | kw1=COMMIT | kw1=ROLLBACK | kw1=DFS | kw1=DELETE kw2=FROM ; createTableHeader : CREATE TEMPORARY? EXTERNAL? TABLE (IF NOT EXISTS)? multipartIdentifier ; replaceTableHeader : (CREATE OR)? REPLACE TABLE multipartIdentifier ; bucketSpec : CLUSTERED BY identifierList (SORTED BY orderedIdentifierList)? INTO INTEGER_VALUE BUCKETS ; skewSpec : SKEWED BY identifierList ON (constantList | nestedConstantList) (STORED AS DIRECTORIES)? ; locationSpec : LOCATION STRING ; query : ctes? queryTerm queryOrganization ; insertInto : INSERT OVERWRITE TABLE? multipartIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? multipartIdentifier partitionSpec? (IF NOT EXISTS)? #insertIntoTable | INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat? #insertOverwriteHiveDir | INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)? tableProvider (OPTIONS options=tablePropertyList)? #insertOverwriteDir ; partitionSpecLocation : partitionSpec locationSpec? ; partitionSpec : PARTITION '(' partitionVal (',' partitionVal)* ')' ; partitionVal : identifier (EQ constant)? ; database : DATABASE | SCHEMA ; describeFuncName : qualifiedName | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=errorCapturingIdentifier (columnAliases=identifierList)? AS? '(' query ')' ; tableProvider : USING qualifiedName ; tablePropertyList : '(' tableProperty (',' tableProperty)* ')' ; tableProperty : key=tablePropertyKey (EQ? value=tablePropertyValue)? ; tablePropertyKey : identifier ('.' identifier)* | STRING ; tablePropertyValue : INTEGER_VALUE | DECIMAL_VALUE | booleanValue | STRING ; constantList : '(' constant (',' constant)* ')' ; nestedConstantList : '(' constantList (',' constantList)* ')' ; createFileFormat : STORED AS fileFormat | STORED BY storageHandler ; fileFormat : INPUTFORMAT inFmt=STRING OUTPUTFORMAT outFmt=STRING #tableFileFormat | identifier #genericFileFormat ; storageHandler : STRING (WITH SERDEPROPERTIES tablePropertyList)? ; resource : identifier STRING ; dmlStatementNoWith : insertInto queryTerm queryOrganization #singleInsertQuery | fromClause multiInsertQueryBody+ #multiInsertQuery ; queryOrganization : (ORDER BY order+=sortItem (',' order+=sortItem)*)? (CLUSTER BY clusterBy+=expression (',' clusterBy+=expression)*)? (DISTRIBUTE BY distributeBy+=expression (',' distributeBy+=expression)*)? (SORT BY sort+=sortItem (',' sort+=sortItem)*)? windowClause? (LIMIT (ALL | limit=expression))? ; multiInsertQueryBody : insertInto fromStatementBody ; queryTerm : queryPrimary #queryTermDefault | left=queryTerm {legacy_setops_precedence_enbled}? operator=(INTERSECT | UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=INTERSECT setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=(UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation ; queryPrimary : querySpecification #queryPrimaryDefault | fromStatement #fromStmt | TABLE multipartIdentifier #table | inlineTable #inlineTableDefault1 | '(' query ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; fromStatement : fromClause fromStatementBody+ ; fromStatementBody : transformClause whereClause? queryOrganization | selectClause lateralView* whereClause? aggregationClause? havingClause? windowClause? queryOrganization ; querySpecification : transformClause fromClause? whereClause? #transformQuerySpecification | selectClause fromClause? lateralView* whereClause? aggregationClause? havingClause? windowClause? #regularQuerySpecification ; transformClause : (SELECT kind=TRANSFORM '(' namedExpressionSeq ')' | kind=MAP namedExpressionSeq | kind=REDUCE namedExpressionSeq) inRowFormat=rowFormat? (RECORDWRITER recordWriter=STRING)? USING script=STRING (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList) ')')))? outRowFormat=rowFormat? (RECORDREADER recordReader=STRING)? ; selectClause : SELECT (hints+=hint)* setQuantifier? namedExpressionSeq ; setClause : SET assign (',' assign)* ; assign : key=multipartIdentifier EQ value=expression ; whereClause : WHERE booleanExpression ; havingClause : HAVING booleanExpression ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregationClause : GROUP BY groupingExpressions+=expression (',' groupingExpressions+=expression)* ( WITH kind=ROLLUP | WITH kind=CUBE | kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')')? | GROUP BY kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')' ; groupingSet : '(' (expression (',' expression)*)? ')' | expression ; pivotClause : PIVOT '(' aggregates=namedExpressionSeq FOR pivotColumn IN '(' pivotValues+=pivotValue (',' pivotValues+=pivotValue)* ')' ')' ; pivotColumn : identifiers+=identifier | '(' identifiers+=identifier (',' identifiers+=identifier)* ')' ; pivotValue : expression (AS? identifier)? ; lateralView : LATERAL VIEW (OUTER)? qualifiedName '(' (expression (',' expression)*)? ')' tblName=identifier (AS? colName+=identifier (',' colName+=identifier)*)? ; setQuantifier : DISTINCT | ALL ; relation : relationPrimary joinRelation* ; joinRelation : (joinType) JOIN right=relationPrimary joinCriteria? | NATURAL joinType JOIN right=relationPrimary ; joinType : INNER? | CROSS | LEFT OUTER? | LEFT? SEMI | RIGHT OUTER? | FULL OUTER? | LEFT? ANTI ; joinCriteria : ON booleanExpression | USING identifierList ; sample : TABLESAMPLE '(' sampleMethod? ')' ; sampleMethod : negativeSign=MINUS? percentage=(INTEGER_VALUE | DECIMAL_VALUE) PERCENTLIT #sampleByPercentile | expression ROWS #sampleByRows | sampleType=BUCKET numerator=INTEGER_VALUE OUT OF denominator=INTEGER_VALUE (ON (identifier | qualifiedName '(' ')'))? #sampleByBucket | bytes=expression #sampleByBytes ; identifierList : '(' identifierSeq ')' ; identifierSeq : ident+=errorCapturingIdentifier (',' ident+=errorCapturingIdentifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : ident=errorCapturingIdentifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier (COMMENT STRING)? ; relationPrimary : multipartIdentifier sample? tableAlias #tableName | '(' query ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : funcName=errorCapturingIdentifier '(' (expression (',' expression)*)? ')' tableAlias ; tableAlias : (AS? strictIdentifier identifierList?)? ; rowFormat : ROW FORMAT SERDE name=STRING (WITH SERDEPROPERTIES props=tablePropertyList)? #rowFormatSerde | ROW FORMAT DELIMITED (FIELDS TERMINATED BY fieldsTerminatedBy=STRING (ESCAPED BY escapedBy=STRING)?)? (COLLECTION ITEMS TERMINATED BY collectionItemsTerminatedBy=STRING)? (MAP KEYS TERMINATED BY keysTerminatedBy=STRING)? (LINES TERMINATED BY linesSeparatedBy=STRING)? (NULL DEFINED AS nullDefinedAs=STRING)? #rowFormatDelimited ; multipartIdentifier : parts+=errorCapturingIdentifier ('.' parts+=errorCapturingIdentifier)* ; tableIdentifier : (db=errorCapturingIdentifier '.')? table=errorCapturingIdentifier ; functionIdentifier : (db=errorCapturingIdentifier '.')? function=errorCapturingIdentifier ; namedExpression : expression (AS? (name=errorCapturingIdentifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; transformList : '(' transforms+=transform (',' transforms+=transform)* ')' ; transform : qualifiedName #identityTransform | transformName=identifier '(' argument+=transformArgument (',' argument+=transformArgument)* ')' #applyTransform ; transformArgument : qualifiedName | constant ; expression : booleanExpression ; booleanExpression : NOT booleanExpression #logicalNot | EXISTS '(' query ')' #exists | valueExpression predicate? #predicated | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary ; predicate : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=(RLIKE | LIKE) pattern=valueExpression | IS NOT? kind=NULL | IS NOT? kind=(TRUE | FALSE | UNKNOWN) | IS NOT? kind=DISTINCT FROM right=valueExpression ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS | TILDE) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS | CONCAT_PIPE) right=valueExpression #arithmeticBinary | left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary | left=valueExpression operator=HAT right=valueExpression #arithmeticBinary | left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary | left=valueExpression comparisonOperator right=valueExpression #comparison ; primaryExpression : name=(CURRENT_DATE | CURRENT_TIMESTAMP) #currentDatetime | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase | CAST '(' expression AS dataType ')' #cast | STRUCT '(' (argument+=namedExpression (',' argument+=namedExpression)*)? ')' #struct | (FIRST | FIRST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #first | (LAST | LAST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #last | POSITION '(' substr=valueExpression IN str=valueExpression ')' #position | constant #constantDefault | ASTERISK #star | qualifiedName '.' ASTERISK #star | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor | '(' query ')' #subqueryExpression | qualifiedName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (OVER windowSpec)? #functionCall | IDENTIFIER '->' expression #lambda | '(' IDENTIFIER (',' IDENTIFIER)+ ')' '->' expression #lambda | value=primaryExpression '[' index=valueExpression ']' #subscript | identifier #columnReference | base=primaryExpression '.' fieldName=identifier #dereference | '(' expression ')' #parenthesizedExpression | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract | (SUBSTR | SUBSTRING) '(' str=valueExpression (FROM | ',') pos=valueExpression ((FOR | ',') len=valueExpression)? ')' #substring | TRIM '(' trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)? FROM srcStr=valueExpression ')' #trim | OVERLAY '(' input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? ')' #overlay ; constant : NULL #nullLiteral | interval #intervalLiteral | identifier STRING #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral | STRING+ #stringLiteral ; comparisonOperator : EQ | NEQ | NEQJ | LT | LTE | GT | GTE | NSEQ ; arithmeticOperator : PLUS | MINUS | ASTERISK | SLASH | PERCENT | DIV | TILDE | AMPERSAND | PIPE | CONCAT_PIPE | HAT ; predicateOperator : OR | AND | IN | NOT ; booleanValue : TRUE | FALSE ; interval : {ansi}? INTERVAL? intervalField+ | {!ansi}? INTERVAL intervalField* ; intervalField : value=intervalValue unit=intervalUnit (TO to=intervalUnit)? ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; intervalUnit : DAY | DAYS | HOUR | HOURS | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | SECOND | SECONDS | WEEK | WEEKS | YEAR | YEARS ; colPosition : FIRST | AFTER qualifiedName ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; qualifiedColTypeWithPositionList : qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)* ; qualifiedColTypeWithPosition : name=qualifiedName dataType (COMMENT comment=STRING)? colPosition? ; colTypeList : colType (',' colType)* ; colType : colName=errorCapturingIdentifier dataType (COMMENT STRING)? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (COMMENT STRING)? ; whenClause : WHEN condition=expression THEN result=expression ; windowClause : WINDOW namedWindow (',' namedWindow)* ; namedWindow : name=errorCapturingIdentifier AS windowSpec ; windowSpec : name=errorCapturingIdentifier #windowRef | '('name=errorCapturingIdentifier')' #windowRef | '(' ( CLUSTER BY partition+=expression (',' partition+=expression)* | ((PARTITION | DISTRIBUTE) BY partition+=expression (',' partition+=expression)*)? ((ORDER | SORT) BY sortItem (',' sortItem)*)?) windowFrame? ')' #windowDef ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=(PRECEDING | FOLLOWING) | boundType=CURRENT ROW | expression boundType=(PRECEDING | FOLLOWING) ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; qualifiedName : identifier ('.' identifier)* ; // this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table` // replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise // valid expressions such as ""a-b"" can be recognized as an identifier errorCapturingIdentifier : identifier errorCapturingIdentifierExtra ; // extra left-factoring grammar errorCapturingIdentifierExtra : (MINUS identifier)+ #errorIdent | #realIdent ; identifier : strictIdentifier | {!ansi}? strictNonReserved ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | {ansi}? ansiNonReserved #unquotedIdentifier | {!ansi}? nonReserved #unquotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; number : MINUS? DECIMAL_VALUE #decimalLiteral | MINUS? INTEGER_VALUE #integerLiteral | MINUS? BIGINT_LITERAL #bigIntLiteral | MINUS? SMALLINT_LITERAL #smallIntLiteral | MINUS? TINYINT_LITERAL #tinyIntLiteral | MINUS? DOUBLE_LITERAL #doubleLiteral | MINUS? BIGDECIMAL_LITERAL #bigDecimalLiteral ; // When `spark.sql.ansi.enabled=true`, there are 2 kinds of keywords in Spark SQL. // - Reserved keywords: // Keywords that are reserved and can't be used as identifiers for table, view, column, // function, alias, etc. // - Non-reserved keywords: // Keywords that have a special meaning only in particular contexts and can be used as // identifiers in other contexts. For example, `SELECT 1 WEEK` is an interval literal, but WEEK // can be used as identifiers in other places. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The non-reserved keywords are listed below. Keywords not in this list are reserved keywords. ansiNonReserved : ADD | AFTER | ALTER | ANALYZE | ARCHIVE | ARRAY | ASC | AT | BETWEEN | BUCKET | BUCKETS | BY | CACHE | CASCADE | CHANGE | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLECTION | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | COST | CUBE | CURRENT | DATA | DATABASE | DATABASES | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTRIBUTE | DIV | DROP | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FORMAT | FORMATTED | FUNCTION | FUNCTIONS | GLOBAL | GROUPING | HOURS | IF | IGNORE | IMPORT | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | ITEMS | KEYS | LAST | LATERAL | LAZY | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTES | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NULLS | OF | OPTION | OPTIONS | OUT | OUTPUTFORMAT | OVER | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECONDS | SEPARATED | SERDE | SERDEPROPERTIES | SET | SETS | SHOW | SKEWED | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | TOUCH | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | UNARCHIVE | UNBOUNDED | UNCACHE | UNLOCK | UNSET | UPDATE | USE | VALUES | VIEW | WEEK | WEEKS | WINDOW | YEARS ; // When `spark.sql.ansi.enabled=false`, there are 2 kinds of keywords in Spark SQL. // - Non-reserved keywords: // Same definition as the one when `spark.sql.ansi.enabled=true`. // - Strict-non-reserved keywords: // A strict version of non-reserved keywords, which can not be used as table alias. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The strict-non-reserved keywords are listed in `strictNonReserved`. // The non-reserved keywords are listed in `nonReserved`. // These 2 together contain all the keywords. strictNonReserved : ANTI | CROSS | EXCEPT | FULL | INNER | INTERSECT | JOIN | LEFT | NATURAL | ON | RIGHT | SEMI | SETMINUS | UNION | USING ; nonReserved : ADD | AFTER | ALL | ALTER | ANALYZE | AND | ANY | ARCHIVE | ARRAY | AS | ASC | AT | AUTHORIZATION | BETWEEN | BOTH | BUCKET | BUCKETS | BY | CACHE | CASCADE | CASE | CAST | CHANGE | CHECK | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLATE | COLLECTION | COLUMN | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | CONSTRAINT | COST | CREATE | CUBE | CURRENT | CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATABASES | DAY | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTINCT | DISTRIBUTE | DIV | DROP | ELSE | END | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FALSE | FETCH | FIELDS | FILEFORMAT | FIRST | FIRST_VALUE | FOLLOWING | FOR | FOREIGN | FORMAT | FORMATTED | FROM | FUNCTION | FUNCTIONS | GLOBAL | GRANT | GROUP | GROUPING | HAVING | HOUR | HOURS | IF | IGNORE | IMPORT | IN | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | INTO | IS | ITEMS | KEYS | LAST | LAST_VALUE | LATERAL | LAZY | LEADING | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NOT | NULL | NULLS | OF | ONLY | OPTION | OPTIONS | OR | ORDER | OUT | OUTER | OUTPUTFORMAT | OVER | OVERLAPS | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRIMARY | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFERENCES | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECOND | SECONDS | SELECT | SEPARATED | SERDE | SERDEPROPERTIES | SESSION_USER | SET | SETS | SHOW | SKEWED | SOME | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLE | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | THEN | TO | TOUCH | TRAILING | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNIQUE | UNKNOWN | UNLOCK | UNSET | UPDATE | USE | USER | VALUES | VIEW | WEEK | WEEKS | WHEN | WHERE | WINDOW | WITH | YEAR | YEARS ; // NOTE: If you add a new token in the list below, you should update the list of keywords // in `docs/sql-keywords.md`. If the token is a non-reserved keyword, // please update `ansiNonReserved` and `nonReserved` as well. //============================ // Start of the keywords list //============================ ADD: 'ADD'; AFTER: 'AFTER'; ALL: 'ALL'; ALTER: 'ALTER'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY'; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; AUTHORIZATION: 'AUTHORIZATION'; BETWEEN: 'BETWEEN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; CACHE: 'CACHE'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CHANGE: 'CHANGE'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONSTRAINT: 'CONSTRAINT'; COST: 'COST'; CREATE: 'CREATE'; CROSS: 'CROSS'; CUBE: 'CUBE'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; DATA: 'DATA'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES' | 'SCHEMAS'; DAY: 'DAY'; DAYS: 'DAYS'; DBPROPERTIES: 'DBPROPERTIES'; DEFINED: 'DEFINED'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DROP: 'DROP'; ELSE: 'ELSE'; END: 'END'; ESCAPED: 'ESCAPED'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXISTS: 'EXISTS'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FIRST_VALUE: 'FIRST_VALUE'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HAVING: 'HAVING'; HOUR: 'HOUR'; HOURS: 'HOURS'; IF: 'IF'; IGNORE: 'IGNORE'; IMPORT: 'IMPORT'; IN: 'IN'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INTO: 'INTO'; IS: 'IS'; ITEMS: 'ITEMS'; JOIN: 'JOIN'; KEYS: 'KEYS'; LAST: 'LAST'; LAST_VALUE: 'LAST_VALUE'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEFT: 'LEFT'; LIKE: 'LIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; MACRO: 'MACRO'; MAP: 'MAP'; MICROSECOND: 'MICROSECOND'; MICROSECONDS: 'MICROSECONDS'; MILLISECOND: 'MILLISECOND'; MILLISECONDS: 'MILLISECONDS'; MINUTE: 'MINUTE'; MINUTES: 'MINUTES'; MONTH: 'MONTH'; MONTHS: 'MONTHS'; MSCK: 'MSCK'; NAMESPACE: 'NAMESPACE'; NAMESPACES: 'NAMESPACES'; NATURAL: 'NATURAL'; NO: 'NO'; NOT: 'NOT' | '!'; NULL: 'NULL'; NULLS: 'NULLS'; OF: 'OF'; ON: 'ON'; ONLY: 'ONLY'; OPTION: 'OPTION'; OPTIONS: 'OPTIONS'; OR: 'OR'; ORDER: 'ORDER'; OUT: 'OUT'; OUTER: 'OUTER'; OUTPUTFORMAT: 'OUTPUTFORMAT'; OVER: 'OVER'; OVERLAPS: 'OVERLAPS'; OVERLAY: 'OVERLAY'; OVERWRITE: 'OVERWRITE'; PARTITION: 'PARTITION'; PARTITIONED: 'PARTITIONED'; PARTITIONS: 'PARTITIONS'; PERCENTLIT: 'PERCENT'; PIVOT: 'PIVOT'; PLACING: 'PLACING'; POSITION: 'POSITION'; PRECEDING: 'PRECEDING'; PRIMARY: 'PRIMARY'; PRINCIPALS: 'PRINCIPALS'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUERY: 'QUERY'; RANGE: 'RANGE'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESPECT: 'RESPECT'; RESTRICT: 'RESTRICT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SCHEMA: 'SCHEMA'; SECOND: 'SECOND'; SECONDS: 'SECONDS'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHOW: 'SHOW'; SKEWED: 'SKEWED'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STRUCT: 'STRUCT'; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TO: 'TO'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNSET: 'UNSET'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUES: 'VALUES'; VIEW: 'VIEW'; WEEK: 'WEEK'; WEEKS: 'WEEKS'; WHEN: 'WHEN'; WHERE: 'WHERE'; WINDOW: 'WINDOW'; WITH: 'WITH'; YEAR: 'YEAR'; YEARS: 'YEARS'; //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; DIV: 'DIV'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; STRING : '\\'' ( ~('\\''|'\\\\') | ('\\\\' .) )* '\\'' | '""' ( ~('""'|'\\\\') | ('\\\\' .) )* '""' ; BIGINT_LITERAL : DIGIT+ 'L' ; SMALLINT_LITERAL : DIGIT+ 'S' ; TINYINT_LITERAL : DIGIT+ 'Y' ; INTEGER_VALUE : DIGIT+ ; DECIMAL_VALUE : DIGIT+ EXPONENT | DECIMAL_DIGITS EXPONENT? {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; SIMPLE_COMMENT : '--' ~[\\r\\n]* '\\r'? '\\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ; ",12048,False,2253.0807957572565,median "/* * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar SqlBase; @members { /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ public boolean legacy_setops_precedence_enbled = false; /** * Verify whether current token is a valid decimal token (which contains dot). * Returns true if the character that follows the token is not a digit or letter or underscore. * * For example: * For char stream ""2.3"", ""2."" is not a valid decimal token, because it is followed by digit '3'. * For char stream ""2.3_"", ""2.3"" is not a valid decimal token, because it is followed by '_'. * For char stream ""2.3W"", ""2.3"" is not a valid decimal token, because it is followed by 'W'. * For char stream ""12.0D 34.E2+0.12 "" 12.0D is a valid decimal token because it is followed * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+' * which is not a digit or letter or underscore. */ public boolean isValidDecimal() { int nextChar = _input.LA(1); if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' || nextChar == '_') { return false; } else { return true; } } /** * When true, the behavior of keywords follows ANSI SQL standard. */ public boolean SQL_standard_keyword_behavior = false; } singleStatement : statement EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleMultipartIdentifier : multipartIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; statement : query #statementDefault | ctes? dmlStatementNoWith #dmlStatement | USE NAMESPACE? multipartIdentifier #use | CREATE (database | NAMESPACE) (IF NOT EXISTS)? multipartIdentifier ((COMMENT comment=STRING) | locationSpec | (WITH (DBPROPERTIES | PROPERTIES) tablePropertyList))* #createNamespace | ALTER (database | NAMESPACE) multipartIdentifier SET (DBPROPERTIES | PROPERTIES) tablePropertyList #setNamespaceProperties | ALTER (database | NAMESPACE) multipartIdentifier SET locationSpec #setNamespaceLocation | DROP (database | NAMESPACE) (IF EXISTS)? multipartIdentifier (RESTRICT | CASCADE)? #dropNamespace | SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showNamespaces | createTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? ((COMMENT comment=STRING) | (PARTITIONED BY '(' partitionColumns=colTypeList ')' | PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier tableProvider? locationSpec? #createTableLike | replaceTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #replaceTable | ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) columns=qualifiedColTypeWithPositionList #addTableColumns | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) '(' columns=qualifiedColTypeWithPositionList ')' #addTableColumns | ALTER TABLE table=multipartIdentifier RENAME COLUMN from=multipartIdentifier TO to=errorCapturingIdentifier #renameTableColumn | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) '(' columns=multipartIdentifierList ')' #dropTableColumns | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) columns=multipartIdentifierList #dropTableColumns | ALTER (TABLE | VIEW) from=multipartIdentifier RENAME TO to=multipartIdentifier #renameTable | ALTER (TABLE | VIEW) multipartIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) multipartIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ALTER TABLE table=multipartIdentifier (ALTER | CHANGE) COLUMN? column=multipartIdentifier (TYPE dataType)? (COMMENT comment=STRING)? colPosition? #alterTableColumn | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDEPROPERTIES tablePropertyList #setTableSerDe | ALTER (TABLE | VIEW) multipartIdentifier ADD (IF NOT EXISTS)? partitionSpecLocation+ #addTablePartition | ALTER TABLE multipartIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER (TABLE | VIEW) multipartIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER TABLE multipartIdentifier (partitionSpec)? SET locationSpec #setTableLocation | ALTER TABLE multipartIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? multipartIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? multipartIdentifier #dropView | CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)? VIEW (IF NOT EXISTS)? multipartIdentifier identifierCommentList? ((COMMENT STRING) | (PARTITIONED ON identifierList) | (TBLPROPERTIES tablePropertyList))* AS query #createView | CREATE (OR REPLACE)? GLOBAL? TEMPORARY VIEW tableIdentifier ('(' colTypeList ')')? tableProvider (OPTIONS tablePropertyList)? #createTempViewUsing | ALTER VIEW multipartIdentifier AS? query #alterViewQuery | CREATE (OR REPLACE)? TEMPORARY? FUNCTION (IF NOT EXISTS)? multipartIdentifier AS className=STRING (USING resource (',' resource)*)? #createFunction | DROP TEMPORARY? FUNCTION (IF EXISTS)? multipartIdentifier #dropFunction | EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)? statement #explain | SHOW TABLES ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) namespace=multipartIdentifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW TBLPROPERTIES table=multipartIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) table=multipartIdentifier ((FROM | IN) namespace=multipartIdentifier)? #showColumns | SHOW PARTITIONS multipartIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (multipartIdentifier | pattern=STRING))? #showFunctions | SHOW CREATE TABLE multipartIdentifier #showCreateTable | SHOW CURRENT NAMESPACE #showCurrentNamespace | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) (database | NAMESPACE) EXTENDED? multipartIdentifier #describeNamespace | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? multipartIdentifier partitionSpec? describeColName? #describeTable | (DESC | DESCRIBE) QUERY? query #describeQuery | REFRESH TABLE multipartIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE LAZY? TABLE multipartIdentifier (OPTIONS options=tablePropertyList)? (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? multipartIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE multipartIdentifier partitionSpec? #loadData | TRUNCATE TABLE multipartIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE multipartIdentifier #repairTable | op=(ADD | LIST) identifier .*? #manageResource | SET ROLE .*? #failNativeCommand | SET .*? #setConfiguration | RESET #resetConfiguration | unsupportedHiveNativeCommands .*? #failNativeCommand ; unsupportedHiveNativeCommands : kw1=CREATE kw2=ROLE | kw1=DROP kw2=ROLE | kw1=GRANT kw2=ROLE? | kw1=REVOKE kw2=ROLE? | kw1=SHOW kw2=GRANT | kw1=SHOW kw2=ROLE kw3=GRANT? | kw1=SHOW kw2=PRINCIPALS | kw1=SHOW kw2=ROLES | kw1=SHOW kw2=CURRENT kw3=ROLES | kw1=EXPORT kw2=TABLE | kw1=IMPORT kw2=TABLE | kw1=SHOW kw2=COMPACTIONS | kw1=SHOW kw2=CREATE kw3=TABLE | kw1=SHOW kw2=TRANSACTIONS | kw1=SHOW kw2=INDEXES | kw1=SHOW kw2=LOCKS | kw1=CREATE kw2=INDEX | kw1=DROP kw2=INDEX | kw1=ALTER kw2=INDEX | kw1=LOCK kw2=TABLE | kw1=LOCK kw2=DATABASE | kw1=UNLOCK kw2=TABLE | kw1=UNLOCK kw2=DATABASE | kw1=CREATE kw2=TEMPORARY kw3=MACRO | kw1=DROP kw2=TEMPORARY kw3=MACRO | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=CLUSTERED | kw1=ALTER kw2=TABLE tableIdentifier kw3=CLUSTERED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SORTED | kw1=ALTER kw2=TABLE tableIdentifier kw3=SKEWED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SKEWED | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=STORED kw5=AS kw6=DIRECTORIES | kw1=ALTER kw2=TABLE tableIdentifier kw3=SET kw4=SKEWED kw5=LOCATION | kw1=ALTER kw2=TABLE tableIdentifier kw3=EXCHANGE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=ARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=UNARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=SET kw4=FILEFORMAT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=REPLACE kw4=COLUMNS | kw1=START kw2=TRANSACTION | kw1=COMMIT | kw1=ROLLBACK | kw1=DFS | kw1=DELETE kw2=FROM ; createTableHeader : CREATE TEMPORARY? EXTERNAL? TABLE (IF NOT EXISTS)? multipartIdentifier ; replaceTableHeader : (CREATE OR)? REPLACE TABLE multipartIdentifier ; bucketSpec : CLUSTERED BY identifierList (SORTED BY orderedIdentifierList)? INTO INTEGER_VALUE BUCKETS ; skewSpec : SKEWED BY identifierList ON (constantList | nestedConstantList) (STORED AS DIRECTORIES)? ; locationSpec : LOCATION STRING ; query : ctes? queryTerm queryOrganization ; insertInto : INSERT OVERWRITE TABLE? multipartIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? multipartIdentifier partitionSpec? (IF NOT EXISTS)? #insertIntoTable | INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat? #insertOverwriteHiveDir | INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)? tableProvider (OPTIONS options=tablePropertyList)? #insertOverwriteDir ; partitionSpecLocation : partitionSpec locationSpec? ; partitionSpec : PARTITION '(' partitionVal (',' partitionVal)* ')' ; partitionVal : identifier (EQ constant)? ; database : DATABASE | SCHEMA ; describeFuncName : qualifiedName | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=errorCapturingIdentifier (columnAliases=identifierList)? AS? '(' query ')' ; tableProvider : USING multipartIdentifier ; tablePropertyList : '(' tableProperty (',' tableProperty)* ')' ; tableProperty : key=tablePropertyKey (EQ? value=tablePropertyValue)? ; tablePropertyKey : identifier ('.' identifier)* | STRING ; tablePropertyValue : INTEGER_VALUE | DECIMAL_VALUE | booleanValue | STRING ; constantList : '(' constant (',' constant)* ')' ; nestedConstantList : '(' constantList (',' constantList)* ')' ; createFileFormat : STORED AS fileFormat | STORED BY storageHandler ; fileFormat : INPUTFORMAT inFmt=STRING OUTPUTFORMAT outFmt=STRING #tableFileFormat | identifier #genericFileFormat ; storageHandler : STRING (WITH SERDEPROPERTIES tablePropertyList)? ; resource : identifier STRING ; dmlStatementNoWith : insertInto queryTerm queryOrganization #singleInsertQuery | fromClause multiInsertQueryBody+ #multiInsertQuery | DELETE FROM multipartIdentifier tableAlias whereClause? #deleteFromTable | UPDATE multipartIdentifier tableAlias setClause whereClause? #updateTable | MERGE INTO target=multipartIdentifier targetAlias=tableAlias USING (source=multipartIdentifier | '(' sourceQuery=query')') sourceAlias=tableAlias ON mergeCondition=booleanExpression matchedClause* notMatchedClause* #mergeIntoTable ; queryOrganization : (ORDER BY order+=sortItem (',' order+=sortItem)*)? (CLUSTER BY clusterBy+=expression (',' clusterBy+=expression)*)? (DISTRIBUTE BY distributeBy+=expression (',' distributeBy+=expression)*)? (SORT BY sort+=sortItem (',' sort+=sortItem)*)? windowClause? (LIMIT (ALL | limit=expression))? ; multiInsertQueryBody : insertInto fromStatementBody ; queryTerm : queryPrimary #queryTermDefault | left=queryTerm {legacy_setops_precedence_enbled}? operator=(INTERSECT | UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=INTERSECT setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=(UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation ; queryPrimary : querySpecification #queryPrimaryDefault | fromStatement #fromStmt | TABLE multipartIdentifier #table | inlineTable #inlineTableDefault1 | '(' query ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; fromStatement : fromClause fromStatementBody+ ; fromStatementBody : transformClause whereClause? queryOrganization | selectClause lateralView* whereClause? aggregationClause? havingClause? windowClause? queryOrganization ; querySpecification : transformClause fromClause? whereClause? #transformQuerySpecification | selectClause fromClause? lateralView* whereClause? aggregationClause? havingClause? windowClause? #regularQuerySpecification ; transformClause : (SELECT kind=TRANSFORM '(' namedExpressionSeq ')' | kind=MAP namedExpressionSeq | kind=REDUCE namedExpressionSeq) inRowFormat=rowFormat? (RECORDWRITER recordWriter=STRING)? USING script=STRING (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList) ')')))? outRowFormat=rowFormat? (RECORDREADER recordReader=STRING)? ; selectClause : SELECT (hints+=hint)* setQuantifier? namedExpressionSeq ; setClause : SET assignmentList ; matchedClause : WHEN MATCHED (AND matchedCond=booleanExpression)? THEN matchedAction ; notMatchedClause : WHEN NOT MATCHED (AND notMatchedCond=booleanExpression)? THEN notMatchedAction ; matchedAction : DELETE | UPDATE SET ASTERISK | UPDATE SET assignmentList ; notMatchedAction : INSERT ASTERISK | INSERT '(' columns=multipartIdentifierList ')' VALUES '(' expression (',' expression)* ')' ; assignmentList : assignment (',' assignment)* ; assignment : key=multipartIdentifier EQ value=expression ; whereClause : WHERE booleanExpression ; havingClause : HAVING booleanExpression ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregationClause : GROUP BY groupingExpressions+=expression (',' groupingExpressions+=expression)* ( WITH kind=ROLLUP | WITH kind=CUBE | kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')')? | GROUP BY kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')' ; groupingSet : '(' (expression (',' expression)*)? ')' | expression ; pivotClause : PIVOT '(' aggregates=namedExpressionSeq FOR pivotColumn IN '(' pivotValues+=pivotValue (',' pivotValues+=pivotValue)* ')' ')' ; pivotColumn : identifiers+=identifier | '(' identifiers+=identifier (',' identifiers+=identifier)* ')' ; pivotValue : expression (AS? identifier)? ; lateralView : LATERAL VIEW (OUTER)? qualifiedName '(' (expression (',' expression)*)? ')' tblName=identifier (AS? colName+=identifier (',' colName+=identifier)*)? ; setQuantifier : DISTINCT | ALL ; relation : relationPrimary joinRelation* ; joinRelation : (joinType) JOIN right=relationPrimary joinCriteria? | NATURAL joinType JOIN right=relationPrimary ; joinType : INNER? | CROSS | LEFT OUTER? | LEFT? SEMI | RIGHT OUTER? | FULL OUTER? | LEFT? ANTI ; joinCriteria : ON booleanExpression | USING identifierList ; sample : TABLESAMPLE '(' sampleMethod? ')' ; sampleMethod : negativeSign=MINUS? percentage=(INTEGER_VALUE | DECIMAL_VALUE) PERCENTLIT #sampleByPercentile | expression ROWS #sampleByRows | sampleType=BUCKET numerator=INTEGER_VALUE OUT OF denominator=INTEGER_VALUE (ON (identifier | qualifiedName '(' ')'))? #sampleByBucket | bytes=expression #sampleByBytes ; identifierList : '(' identifierSeq ')' ; identifierSeq : ident+=errorCapturingIdentifier (',' ident+=errorCapturingIdentifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : ident=errorCapturingIdentifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier (COMMENT STRING)? ; relationPrimary : multipartIdentifier sample? tableAlias #tableName | '(' query ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : funcName=errorCapturingIdentifier '(' (expression (',' expression)*)? ')' tableAlias ; tableAlias : (AS? strictIdentifier identifierList?)? ; rowFormat : ROW FORMAT SERDE name=STRING (WITH SERDEPROPERTIES props=tablePropertyList)? #rowFormatSerde | ROW FORMAT DELIMITED (FIELDS TERMINATED BY fieldsTerminatedBy=STRING (ESCAPED BY escapedBy=STRING)?)? (COLLECTION ITEMS TERMINATED BY collectionItemsTerminatedBy=STRING)? (MAP KEYS TERMINATED BY keysTerminatedBy=STRING)? (LINES TERMINATED BY linesSeparatedBy=STRING)? (NULL DEFINED AS nullDefinedAs=STRING)? #rowFormatDelimited ; multipartIdentifierList : multipartIdentifier (',' multipartIdentifier)* ; multipartIdentifier : parts+=errorCapturingIdentifier ('.' parts+=errorCapturingIdentifier)* ; tableIdentifier : (db=errorCapturingIdentifier '.')? table=errorCapturingIdentifier ; functionIdentifier : (db=errorCapturingIdentifier '.')? function=errorCapturingIdentifier ; namedExpression : expression (AS? (name=errorCapturingIdentifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; transformList : '(' transforms+=transform (',' transforms+=transform)* ')' ; transform : qualifiedName #identityTransform | transformName=identifier '(' argument+=transformArgument (',' argument+=transformArgument)* ')' #applyTransform ; transformArgument : qualifiedName | constant ; expression : booleanExpression ; booleanExpression : NOT booleanExpression #logicalNot | EXISTS '(' query ')' #exists | valueExpression predicate? #predicated | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary ; predicate : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=(RLIKE | LIKE) pattern=valueExpression | IS NOT? kind=NULL | IS NOT? kind=(TRUE | FALSE | UNKNOWN) | IS NOT? kind=DISTINCT FROM right=valueExpression ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS | TILDE) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS | CONCAT_PIPE) right=valueExpression #arithmeticBinary | left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary | left=valueExpression operator=HAT right=valueExpression #arithmeticBinary | left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary | left=valueExpression comparisonOperator right=valueExpression #comparison ; primaryExpression : name=(CURRENT_DATE | CURRENT_TIMESTAMP) #currentDatetime | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase | CAST '(' expression AS dataType ')' #cast | STRUCT '(' (argument+=namedExpression (',' argument+=namedExpression)*)? ')' #struct | (FIRST | FIRST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #first | (LAST | LAST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #last | POSITION '(' substr=valueExpression IN str=valueExpression ')' #position | constant #constantDefault | ASTERISK #star | qualifiedName '.' ASTERISK #star | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor | '(' query ')' #subqueryExpression | functionName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (OVER windowSpec)? #functionCall | identifier '->' expression #lambda | '(' identifier (',' identifier)+ ')' '->' expression #lambda | value=primaryExpression '[' index=valueExpression ']' #subscript | identifier #columnReference | base=primaryExpression '.' fieldName=identifier #dereference | '(' expression ')' #parenthesizedExpression | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract | (SUBSTR | SUBSTRING) '(' str=valueExpression (FROM | ',') pos=valueExpression ((FOR | ',') len=valueExpression)? ')' #substring | TRIM '(' trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)? FROM srcStr=valueExpression ')' #trim | OVERLAY '(' input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? ')' #overlay ; constant : NULL #nullLiteral | interval #intervalLiteral | identifier STRING #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral | STRING+ #stringLiteral ; comparisonOperator : EQ | NEQ | NEQJ | LT | LTE | GT | GTE | NSEQ ; arithmeticOperator : PLUS | MINUS | ASTERISK | SLASH | PERCENT | DIV | TILDE | AMPERSAND | PIPE | CONCAT_PIPE | HAT ; predicateOperator : OR | AND | IN | NOT ; booleanValue : TRUE | FALSE ; interval : INTERVAL (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval)? | {SQL_standard_keyword_behavior}? (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval) ; errorCapturingMultiUnitsInterval : multiUnitsInterval unitToUnitInterval? ; multiUnitsInterval : (intervalValue intervalUnit)+ ; errorCapturingUnitToUnitInterval : body=unitToUnitInterval (error1=multiUnitsInterval | error2=unitToUnitInterval)? ; unitToUnitInterval : value=intervalValue from=intervalUnit TO to=intervalUnit ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; intervalUnit : DAY | DAYS | HOUR | HOURS | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | SECOND | SECONDS | WEEK | WEEKS | YEAR | YEARS ; colPosition : FIRST | AFTER multipartIdentifier ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; qualifiedColTypeWithPositionList : qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)* ; qualifiedColTypeWithPosition : name=multipartIdentifier dataType (COMMENT comment=STRING)? colPosition? ; colTypeList : colType (',' colType)* ; colType : colName=errorCapturingIdentifier dataType (COMMENT STRING)? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (COMMENT STRING)? ; whenClause : WHEN condition=expression THEN result=expression ; windowClause : WINDOW namedWindow (',' namedWindow)* ; namedWindow : name=errorCapturingIdentifier AS windowSpec ; windowSpec : name=errorCapturingIdentifier #windowRef | '('name=errorCapturingIdentifier')' #windowRef | '(' ( CLUSTER BY partition+=expression (',' partition+=expression)* | ((PARTITION | DISTRIBUTE) BY partition+=expression (',' partition+=expression)*)? ((ORDER | SORT) BY sortItem (',' sortItem)*)?) windowFrame? ')' #windowDef ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=(PRECEDING | FOLLOWING) | boundType=CURRENT ROW | expression boundType=(PRECEDING | FOLLOWING) ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; functionName : qualifiedName | LEFT | RIGHT ; qualifiedName : identifier ('.' identifier)* ; // this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table` // replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise // valid expressions such as ""a-b"" can be recognized as an identifier errorCapturingIdentifier : identifier errorCapturingIdentifierExtra ; // extra left-factoring grammar errorCapturingIdentifierExtra : (MINUS identifier)+ #errorIdent | #realIdent ; identifier : strictIdentifier | {!SQL_standard_keyword_behavior}? strictNonReserved ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | {SQL_standard_keyword_behavior}? ansiNonReserved #unquotedIdentifier | {!SQL_standard_keyword_behavior}? nonReserved #unquotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; number : MINUS? DECIMAL_VALUE #decimalLiteral | MINUS? INTEGER_VALUE #integerLiteral | MINUS? BIGINT_LITERAL #bigIntLiteral | MINUS? SMALLINT_LITERAL #smallIntLiteral | MINUS? TINYINT_LITERAL #tinyIntLiteral | MINUS? DOUBLE_LITERAL #doubleLiteral | MINUS? BIGDECIMAL_LITERAL #bigDecimalLiteral ; // When `SQL_standard_keyword_behavior=true`, there are 2 kinds of keywords in Spark SQL. // - Reserved keywords: // Keywords that are reserved and can't be used as identifiers for table, view, column, // function, alias, etc. // - Non-reserved keywords: // Keywords that have a special meaning only in particular contexts and can be used as // identifiers in other contexts. For example, `SELECT 1 WEEK` is an interval literal, but WEEK // can be used as identifiers in other places. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The non-reserved keywords are listed below. Keywords not in this list are reserved keywords. ansiNonReserved : ADD | AFTER | ALTER | ANALYZE | ARCHIVE | ARRAY | ASC | AT | BETWEEN | BUCKET | BUCKETS | BY | CACHE | CASCADE | CHANGE | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLECTION | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | COST | CUBE | CURRENT | DATA | DATABASE | DATABASES | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTRIBUTE | DIV | DROP | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FORMAT | FORMATTED | FUNCTION | FUNCTIONS | GLOBAL | GROUPING | HOURS | IF | IGNORE | IMPORT | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | ITEMS | KEYS | LAST | LATERAL | LAZY | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTES | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NULLS | OF | OPTION | OPTIONS | OUT | OUTPUTFORMAT | OVER | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECONDS | SEPARATED | SERDE | SERDEPROPERTIES | SET | SETS | SHOW | SKEWED | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | TOUCH | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | UNARCHIVE | UNBOUNDED | UNCACHE | UNLOCK | UNSET | UPDATE | USE | VALUES | VIEW | WEEK | WEEKS | WINDOW | YEARS ; // When `SQL_standard_keyword_behavior=false`, there are 2 kinds of keywords in Spark SQL. // - Non-reserved keywords: // Same definition as the one when `SQL_standard_keyword_behavior=true`. // - Strict-non-reserved keywords: // A strict version of non-reserved keywords, which can not be used as table alias. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The strict-non-reserved keywords are listed in `strictNonReserved`. // The non-reserved keywords are listed in `nonReserved`. // These 2 together contain all the keywords. strictNonReserved : ANTI | CROSS | EXCEPT | FULL | INNER | INTERSECT | JOIN | LEFT | NATURAL | ON | RIGHT | SEMI | SETMINUS | UNION | USING ; nonReserved : ADD | AFTER | ALL | ALTER | ANALYZE | AND | ANY | ARCHIVE | ARRAY | AS | ASC | AT | AUTHORIZATION | BETWEEN | BOTH | BUCKET | BUCKETS | BY | CACHE | CASCADE | CASE | CAST | CHANGE | CHECK | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLATE | COLLECTION | COLUMN | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | CONSTRAINT | COST | CREATE | CUBE | CURRENT | CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATABASES | DAY | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTINCT | DISTRIBUTE | DIV | DROP | ELSE | END | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FALSE | FETCH | FIELDS | FILEFORMAT | FIRST | FIRST_VALUE | FOLLOWING | FOR | FOREIGN | FORMAT | FORMATTED | FROM | FUNCTION | FUNCTIONS | GLOBAL | GRANT | GROUP | GROUPING | HAVING | HOUR | HOURS | IF | IGNORE | IMPORT | IN | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | INTO | IS | ITEMS | KEYS | LAST | LAST_VALUE | LATERAL | LAZY | LEADING | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NOT | NULL | NULLS | OF | ONLY | OPTION | OPTIONS | OR | ORDER | OUT | OUTER | OUTPUTFORMAT | OVER | OVERLAPS | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRIMARY | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFERENCES | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECOND | SECONDS | SELECT | SEPARATED | SERDE | SERDEPROPERTIES | SESSION_USER | SET | SETS | SHOW | SKEWED | SOME | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLE | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | THEN | TO | TOUCH | TRAILING | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNIQUE | UNKNOWN | UNLOCK | UNSET | UPDATE | USE | USER | VALUES | VIEW | WEEK | WEEKS | WHEN | WHERE | WINDOW | WITH | YEAR | YEARS ; // NOTE: If you add a new token in the list below, you should update the list of keywords // in `docs/sql-keywords.md`. If the token is a non-reserved keyword, // please update `ansiNonReserved` and `nonReserved` as well. //============================ // Start of the keywords list //============================ ADD: 'ADD'; AFTER: 'AFTER'; ALL: 'ALL'; ALTER: 'ALTER'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY'; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; AUTHORIZATION: 'AUTHORIZATION'; BETWEEN: 'BETWEEN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; CACHE: 'CACHE'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CHANGE: 'CHANGE'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONSTRAINT: 'CONSTRAINT'; COST: 'COST'; CREATE: 'CREATE'; CROSS: 'CROSS'; CUBE: 'CUBE'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; DATA: 'DATA'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES' | 'SCHEMAS'; DAY: 'DAY'; DAYS: 'DAYS'; DBPROPERTIES: 'DBPROPERTIES'; DEFINED: 'DEFINED'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DROP: 'DROP'; ELSE: 'ELSE'; END: 'END'; ESCAPED: 'ESCAPED'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXISTS: 'EXISTS'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FIRST_VALUE: 'FIRST_VALUE'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HAVING: 'HAVING'; HOUR: 'HOUR'; HOURS: 'HOURS'; IF: 'IF'; IGNORE: 'IGNORE'; IMPORT: 'IMPORT'; IN: 'IN'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INTO: 'INTO'; IS: 'IS'; ITEMS: 'ITEMS'; JOIN: 'JOIN'; KEYS: 'KEYS'; LAST: 'LAST'; LAST_VALUE: 'LAST_VALUE'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEFT: 'LEFT'; LIKE: 'LIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; MACRO: 'MACRO'; MAP: 'MAP'; MATCHED: 'MATCHED'; MERGE: 'MERGE'; MICROSECOND: 'MICROSECOND'; MICROSECONDS: 'MICROSECONDS'; MILLISECOND: 'MILLISECOND'; MILLISECONDS: 'MILLISECONDS'; MINUTE: 'MINUTE'; MINUTES: 'MINUTES'; MONTH: 'MONTH'; MONTHS: 'MONTHS'; MSCK: 'MSCK'; NAMESPACE: 'NAMESPACE'; NAMESPACES: 'NAMESPACES'; NATURAL: 'NATURAL'; NO: 'NO'; NOT: 'NOT' | '!'; NULL: 'NULL'; NULLS: 'NULLS'; OF: 'OF'; ON: 'ON'; ONLY: 'ONLY'; OPTION: 'OPTION'; OPTIONS: 'OPTIONS'; OR: 'OR'; ORDER: 'ORDER'; OUT: 'OUT'; OUTER: 'OUTER'; OUTPUTFORMAT: 'OUTPUTFORMAT'; OVER: 'OVER'; OVERLAPS: 'OVERLAPS'; OVERLAY: 'OVERLAY'; OVERWRITE: 'OVERWRITE'; PARTITION: 'PARTITION'; PARTITIONED: 'PARTITIONED'; PARTITIONS: 'PARTITIONS'; PERCENTLIT: 'PERCENT'; PIVOT: 'PIVOT'; PLACING: 'PLACING'; POSITION: 'POSITION'; PRECEDING: 'PRECEDING'; PRIMARY: 'PRIMARY'; PRINCIPALS: 'PRINCIPALS'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUERY: 'QUERY'; RANGE: 'RANGE'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESPECT: 'RESPECT'; RESTRICT: 'RESTRICT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SCHEMA: 'SCHEMA'; SECOND: 'SECOND'; SECONDS: 'SECONDS'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHOW: 'SHOW'; SKEWED: 'SKEWED'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STRUCT: 'STRUCT'; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TO: 'TO'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNSET: 'UNSET'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUES: 'VALUES'; VIEW: 'VIEW'; WEEK: 'WEEK'; WEEKS: 'WEEKS'; WHEN: 'WHEN'; WHERE: 'WHERE'; WINDOW: 'WINDOW'; WITH: 'WITH'; YEAR: 'YEAR'; YEARS: 'YEARS'; //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; DIV: 'DIV'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; STRING : '\\'' ( ~('\\''|'\\\\') | ('\\\\' .) )* '\\'' | '""' ( ~('""'|'\\\\') | ('\\\\' .) )* '""' ; BIGINT_LITERAL : DIGIT+ 'L' ; SMALLINT_LITERAL : DIGIT+ 'S' ; TINYINT_LITERAL : DIGIT+ 'Y' ; INTEGER_VALUE : DIGIT+ ; DECIMAL_VALUE : DIGIT+ EXPONENT | DECIMAL_DIGITS EXPONENT? {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; SIMPLE_COMMENT : '--' ~[\\r\\n]* '\\r'? '\\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ; ",12363,False,2312.503230663706,median "/* * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar SqlBase; @members { /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ public boolean legacy_setops_precedence_enbled = false; /** * When false, a literal with an exponent would be converted into * double type rather than decimal type. */ public boolean legacy_exponent_literal_as_decimal_enabled = false; /** * When false, CREATE TABLE syntax without a provider will use * the value of spark.sql.sources.default as its provider. */ public boolean legacy_create_hive_table_by_default_enabled = false; /** * Verify whether current token is a valid decimal token (which contains dot). * Returns true if the character that follows the token is not a digit or letter or underscore. * * For example: * For char stream ""2.3"", ""2."" is not a valid decimal token, because it is followed by digit '3'. * For char stream ""2.3_"", ""2.3"" is not a valid decimal token, because it is followed by '_'. * For char stream ""2.3W"", ""2.3"" is not a valid decimal token, because it is followed by 'W'. * For char stream ""12.0D 34.E2+0.12 "" 12.0D is a valid decimal token because it is followed * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+' * which is not a digit or letter or underscore. */ public boolean isValidDecimal() { int nextChar = _input.LA(1); if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' || nextChar == '_') { return false; } else { return true; } } /** * When true, the behavior of keywords follows ANSI SQL standard. */ public boolean SQL_standard_keyword_behavior = false; } singleStatement : statement EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleMultipartIdentifier : multipartIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; statement : query #statementDefault | ctes? dmlStatementNoWith #dmlStatement | USE NAMESPACE? multipartIdentifier #use | CREATE namespace (IF NOT EXISTS)? multipartIdentifier (commentSpec | locationSpec | (WITH (DBPROPERTIES | PROPERTIES) tablePropertyList))* #createNamespace | ALTER namespace multipartIdentifier SET (DBPROPERTIES | PROPERTIES) tablePropertyList #setNamespaceProperties | ALTER namespace multipartIdentifier SET locationSpec #setNamespaceLocation | DROP namespace (IF EXISTS)? multipartIdentifier (RESTRICT | CASCADE)? #dropNamespace | SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showNamespaces | {!legacy_create_hive_table_by_default_enabled}? createTableHeader ('(' colTypeList ')')? tableProvider? createTableClauses (AS? query)? #createTable | {legacy_create_hive_table_by_default_enabled}? createTableHeader ('(' colTypeList ')')? tableProvider createTableClauses (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? (commentSpec | (PARTITIONED BY '(' partitionColumns=colTypeList ')' | PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier (tableProvider | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* #createTableLike | replaceTableHeader ('(' colTypeList ')')? tableProvider createTableClauses (AS? query)? #replaceTable | ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) columns=qualifiedColTypeWithPositionList #addTableColumns | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) '(' columns=qualifiedColTypeWithPositionList ')' #addTableColumns | ALTER TABLE table=multipartIdentifier RENAME COLUMN from=multipartIdentifier TO to=errorCapturingIdentifier #renameTableColumn | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) '(' columns=multipartIdentifierList ')' #dropTableColumns | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) columns=multipartIdentifierList #dropTableColumns | ALTER (TABLE | VIEW) from=multipartIdentifier RENAME TO to=multipartIdentifier #renameTable | ALTER (TABLE | VIEW) multipartIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) multipartIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties |ALTER TABLE table=multipartIdentifier (ALTER | CHANGE) COLUMN? column=multipartIdentifier alterColumnAction? #alterTableAlterColumn | ALTER TABLE table=multipartIdentifier partitionSpec? CHANGE COLUMN? colName=multipartIdentifier colType colPosition? #hiveChangeColumn | ALTER TABLE table=multipartIdentifier partitionSpec? REPLACE COLUMNS '(' columns=qualifiedColTypeWithPositionList ')' #hiveReplaceColumns | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDEPROPERTIES tablePropertyList #setTableSerDe | ALTER (TABLE | VIEW) multipartIdentifier ADD (IF NOT EXISTS)? partitionSpecLocation+ #addTablePartition | ALTER TABLE multipartIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER (TABLE | VIEW) multipartIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER TABLE multipartIdentifier (partitionSpec)? SET locationSpec #setTableLocation | ALTER TABLE multipartIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? multipartIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? multipartIdentifier #dropView | CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)? VIEW (IF NOT EXISTS)? multipartIdentifier identifierCommentList? (commentSpec | (PARTITIONED ON identifierList) | (TBLPROPERTIES tablePropertyList))* AS query #createView | CREATE (OR REPLACE)? GLOBAL? TEMPORARY VIEW tableIdentifier ('(' colTypeList ')')? tableProvider (OPTIONS tablePropertyList)? #createTempViewUsing | ALTER VIEW multipartIdentifier AS? query #alterViewQuery | CREATE (OR REPLACE)? TEMPORARY? FUNCTION (IF NOT EXISTS)? multipartIdentifier AS className=STRING (USING resource (',' resource)*)? #createFunction | DROP TEMPORARY? FUNCTION (IF EXISTS)? multipartIdentifier #dropFunction | EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)? statement #explain | SHOW TABLES ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) ns=multipartIdentifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW TBLPROPERTIES table=multipartIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) table=multipartIdentifier ((FROM | IN) ns=multipartIdentifier)? #showColumns | SHOW PARTITIONS multipartIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (multipartIdentifier | pattern=STRING))? #showFunctions | SHOW CREATE TABLE multipartIdentifier (AS SERDE)? #showCreateTable | SHOW CURRENT NAMESPACE #showCurrentNamespace | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) namespace EXTENDED? multipartIdentifier #describeNamespace | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? multipartIdentifier partitionSpec? describeColName? #describeRelation | (DESC | DESCRIBE) QUERY? query #describeQuery | COMMENT ON namespace multipartIdentifier IS comment=(STRING | NULL) #commentNamespace | COMMENT ON TABLE multipartIdentifier IS comment=(STRING | NULL) #commentTable | REFRESH TABLE multipartIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE LAZY? TABLE multipartIdentifier (OPTIONS options=tablePropertyList)? (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? multipartIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE multipartIdentifier partitionSpec? #loadData | TRUNCATE TABLE multipartIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE multipartIdentifier #repairTable | op=(ADD | LIST) identifier (STRING | .*?) #manageResource | SET ROLE .*? #failNativeCommand | SET .*? #setConfiguration | RESET #resetConfiguration | unsupportedHiveNativeCommands .*? #failNativeCommand ; unsupportedHiveNativeCommands : kw1=CREATE kw2=ROLE | kw1=DROP kw2=ROLE | kw1=GRANT kw2=ROLE? | kw1=REVOKE kw2=ROLE? | kw1=SHOW kw2=GRANT | kw1=SHOW kw2=ROLE kw3=GRANT? | kw1=SHOW kw2=PRINCIPALS | kw1=SHOW kw2=ROLES | kw1=SHOW kw2=CURRENT kw3=ROLES | kw1=EXPORT kw2=TABLE | kw1=IMPORT kw2=TABLE | kw1=SHOW kw2=COMPACTIONS | kw1=SHOW kw2=CREATE kw3=TABLE | kw1=SHOW kw2=TRANSACTIONS | kw1=SHOW kw2=INDEXES | kw1=SHOW kw2=LOCKS | kw1=CREATE kw2=INDEX | kw1=DROP kw2=INDEX | kw1=ALTER kw2=INDEX | kw1=LOCK kw2=TABLE | kw1=LOCK kw2=DATABASE | kw1=UNLOCK kw2=TABLE | kw1=UNLOCK kw2=DATABASE | kw1=CREATE kw2=TEMPORARY kw3=MACRO | kw1=DROP kw2=TEMPORARY kw3=MACRO | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=CLUSTERED | kw1=ALTER kw2=TABLE tableIdentifier kw3=CLUSTERED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SORTED | kw1=ALTER kw2=TABLE tableIdentifier kw3=SKEWED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SKEWED | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=STORED kw5=AS kw6=DIRECTORIES | kw1=ALTER kw2=TABLE tableIdentifier kw3=SET kw4=SKEWED kw5=LOCATION | kw1=ALTER kw2=TABLE tableIdentifier kw3=EXCHANGE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=ARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=UNARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=SET kw4=FILEFORMAT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=REPLACE kw4=COLUMNS | kw1=START kw2=TRANSACTION | kw1=COMMIT | kw1=ROLLBACK | kw1=DFS ; createTableHeader : CREATE TEMPORARY? EXTERNAL? TABLE (IF NOT EXISTS)? multipartIdentifier ; replaceTableHeader : (CREATE OR)? REPLACE TABLE multipartIdentifier ; bucketSpec : CLUSTERED BY identifierList (SORTED BY orderedIdentifierList)? INTO INTEGER_VALUE BUCKETS ; skewSpec : SKEWED BY identifierList ON (constantList | nestedConstantList) (STORED AS DIRECTORIES)? ; locationSpec : LOCATION STRING ; commentSpec : COMMENT STRING ; query : ctes? queryTerm queryOrganization ; insertInto : INSERT OVERWRITE TABLE? multipartIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? multipartIdentifier partitionSpec? (IF NOT EXISTS)? #insertIntoTable | INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat? #insertOverwriteHiveDir | INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)? tableProvider (OPTIONS options=tablePropertyList)? #insertOverwriteDir ; partitionSpecLocation : partitionSpec locationSpec? ; partitionSpec : PARTITION '(' partitionVal (',' partitionVal)* ')' ; partitionVal : identifier (EQ constant)? ; namespace : NAMESPACE | DATABASE | SCHEMA ; describeFuncName : qualifiedName | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=errorCapturingIdentifier (columnAliases=identifierList)? AS? '(' query ')' ; tableProvider : USING multipartIdentifier ; createTableClauses :((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | commentSpec | (TBLPROPERTIES tableProps=tablePropertyList))* ; tablePropertyList : '(' tableProperty (',' tableProperty)* ')' ; tableProperty : key=tablePropertyKey (EQ? value=tablePropertyValue)? ; tablePropertyKey : identifier ('.' identifier)* | STRING ; tablePropertyValue : INTEGER_VALUE | DECIMAL_VALUE | booleanValue | STRING ; constantList : '(' constant (',' constant)* ')' ; nestedConstantList : '(' constantList (',' constantList)* ')' ; createFileFormat : STORED AS fileFormat | STORED BY storageHandler ; fileFormat : INPUTFORMAT inFmt=STRING OUTPUTFORMAT outFmt=STRING #tableFileFormat | identifier #genericFileFormat ; storageHandler : STRING (WITH SERDEPROPERTIES tablePropertyList)? ; resource : identifier STRING ; dmlStatementNoWith : insertInto queryTerm queryOrganization #singleInsertQuery | fromClause multiInsertQueryBody+ #multiInsertQuery | DELETE FROM multipartIdentifier tableAlias whereClause? #deleteFromTable | UPDATE multipartIdentifier tableAlias setClause whereClause? #updateTable | MERGE INTO target=multipartIdentifier targetAlias=tableAlias USING (source=multipartIdentifier | '(' sourceQuery=query')') sourceAlias=tableAlias ON mergeCondition=booleanExpression matchedClause* notMatchedClause* #mergeIntoTable ; queryOrganization : (ORDER BY order+=sortItem (',' order+=sortItem)*)? (CLUSTER BY clusterBy+=expression (',' clusterBy+=expression)*)? (DISTRIBUTE BY distributeBy+=expression (',' distributeBy+=expression)*)? (SORT BY sort+=sortItem (',' sort+=sortItem)*)? windowClause? (LIMIT (ALL | limit=expression))? ; multiInsertQueryBody : insertInto fromStatementBody ; queryTerm : queryPrimary #queryTermDefault | left=queryTerm {legacy_setops_precedence_enbled}? operator=(INTERSECT | UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=INTERSECT setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=(UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation ; queryPrimary : querySpecification #queryPrimaryDefault | fromStatement #fromStmt | TABLE multipartIdentifier #table | inlineTable #inlineTableDefault1 | '(' query ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; fromStatement : fromClause fromStatementBody+ ; fromStatementBody : transformClause whereClause? queryOrganization | selectClause lateralView* whereClause? aggregationClause? havingClause? windowClause? queryOrganization ; querySpecification : transformClause fromClause? whereClause? #transformQuerySpecification | selectClause fromClause? lateralView* whereClause? aggregationClause? havingClause? windowClause? #regularQuerySpecification ; transformClause : (SELECT kind=TRANSFORM '(' namedExpressionSeq ')' | kind=MAP namedExpressionSeq | kind=REDUCE namedExpressionSeq) inRowFormat=rowFormat? (RECORDWRITER recordWriter=STRING)? USING script=STRING (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList) ')')))? outRowFormat=rowFormat? (RECORDREADER recordReader=STRING)? ; selectClause : SELECT (hints+=hint)* setQuantifier? namedExpressionSeq ; setClause : SET assignmentList ; matchedClause : WHEN MATCHED (AND matchedCond=booleanExpression)? THEN matchedAction ; notMatchedClause : WHEN NOT MATCHED (AND notMatchedCond=booleanExpression)? THEN notMatchedAction ; matchedAction : DELETE | UPDATE SET ASTERISK | UPDATE SET assignmentList ; notMatchedAction : INSERT ASTERISK | INSERT '(' columns=multipartIdentifierList ')' VALUES '(' expression (',' expression)* ')' ; assignmentList : assignment (',' assignment)* ; assignment : key=multipartIdentifier EQ value=expression ; whereClause : WHERE booleanExpression ; havingClause : HAVING booleanExpression ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregationClause : GROUP BY groupingExpressions+=expression (',' groupingExpressions+=expression)* ( WITH kind=ROLLUP | WITH kind=CUBE | kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')')? | GROUP BY kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')' ; groupingSet : '(' (expression (',' expression)*)? ')' | expression ; pivotClause : PIVOT '(' aggregates=namedExpressionSeq FOR pivotColumn IN '(' pivotValues+=pivotValue (',' pivotValues+=pivotValue)* ')' ')' ; pivotColumn : identifiers+=identifier | '(' identifiers+=identifier (',' identifiers+=identifier)* ')' ; pivotValue : expression (AS? identifier)? ; lateralView : LATERAL VIEW (OUTER)? qualifiedName '(' (expression (',' expression)*)? ')' tblName=identifier (AS? colName+=identifier (',' colName+=identifier)*)? ; setQuantifier : DISTINCT | ALL ; relation : relationPrimary joinRelation* ; joinRelation : (joinType) JOIN right=relationPrimary joinCriteria? | NATURAL joinType JOIN right=relationPrimary ; joinType : INNER? | CROSS | LEFT OUTER? | LEFT? SEMI | RIGHT OUTER? | FULL OUTER? | LEFT? ANTI ; joinCriteria : ON booleanExpression | USING identifierList ; sample : TABLESAMPLE '(' sampleMethod? ')' ; sampleMethod : negativeSign=MINUS? percentage=(INTEGER_VALUE | DECIMAL_VALUE) PERCENTLIT #sampleByPercentile | expression ROWS #sampleByRows | sampleType=BUCKET numerator=INTEGER_VALUE OUT OF denominator=INTEGER_VALUE (ON (identifier | qualifiedName '(' ')'))? #sampleByBucket | bytes=expression #sampleByBytes ; identifierList : '(' identifierSeq ')' ; identifierSeq : ident+=errorCapturingIdentifier (',' ident+=errorCapturingIdentifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : ident=errorCapturingIdentifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier commentSpec? ; relationPrimary : multipartIdentifier sample? tableAlias #tableName | '(' query ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : funcName=errorCapturingIdentifier '(' (expression (',' expression)*)? ')' tableAlias ; tableAlias : (AS? strictIdentifier identifierList?)? ; rowFormat : ROW FORMAT SERDE name=STRING (WITH SERDEPROPERTIES props=tablePropertyList)? #rowFormatSerde | ROW FORMAT DELIMITED (FIELDS TERMINATED BY fieldsTerminatedBy=STRING (ESCAPED BY escapedBy=STRING)?)? (COLLECTION ITEMS TERMINATED BY collectionItemsTerminatedBy=STRING)? (MAP KEYS TERMINATED BY keysTerminatedBy=STRING)? (LINES TERMINATED BY linesSeparatedBy=STRING)? (NULL DEFINED AS nullDefinedAs=STRING)? #rowFormatDelimited ; multipartIdentifierList : multipartIdentifier (',' multipartIdentifier)* ; multipartIdentifier : parts+=errorCapturingIdentifier ('.' parts+=errorCapturingIdentifier)* ; tableIdentifier : (db=errorCapturingIdentifier '.')? table=errorCapturingIdentifier ; functionIdentifier : (db=errorCapturingIdentifier '.')? function=errorCapturingIdentifier ; namedExpression : expression (AS? (name=errorCapturingIdentifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; transformList : '(' transforms+=transform (',' transforms+=transform)* ')' ; transform : qualifiedName #identityTransform | transformName=identifier '(' argument+=transformArgument (',' argument+=transformArgument)* ')' #applyTransform ; transformArgument : qualifiedName | constant ; expression : booleanExpression ; booleanExpression : NOT booleanExpression #logicalNot | EXISTS '(' query ')' #exists | valueExpression predicate? #predicated | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary ; predicate : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=RLIKE pattern=valueExpression | NOT? kind=LIKE pattern=valueExpression (ESCAPE escapeChar=STRING)? | IS NOT? kind=NULL | IS NOT? kind=(TRUE | FALSE | UNKNOWN) | IS NOT? kind=DISTINCT FROM right=valueExpression ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS | TILDE) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS | CONCAT_PIPE) right=valueExpression #arithmeticBinary | left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary | left=valueExpression operator=HAT right=valueExpression #arithmeticBinary | left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary | left=valueExpression comparisonOperator right=valueExpression #comparison ; primaryExpression : name=(CURRENT_DATE | CURRENT_TIMESTAMP) #currentDatetime | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase | CAST '(' expression AS dataType ')' #cast | STRUCT '(' (argument+=namedExpression (',' argument+=namedExpression)*)? ')' #struct | FIRST '(' expression (IGNORE NULLS)? ')' #first | LAST '(' expression (IGNORE NULLS)? ')' #last | POSITION '(' substr=valueExpression IN str=valueExpression ')' #position | constant #constantDefault | ASTERISK #star | qualifiedName '.' ASTERISK #star | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor | '(' query ')' #subqueryExpression | functionName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (FILTER '(' WHERE where=booleanExpression ')')? (OVER windowSpec)? #functionCall | identifier '->' expression #lambda | '(' identifier (',' identifier)+ ')' '->' expression #lambda | value=primaryExpression '[' index=valueExpression ']' #subscript | identifier #columnReference | base=primaryExpression '.' fieldName=identifier #dereference | '(' expression ')' #parenthesizedExpression | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract | (SUBSTR | SUBSTRING) '(' str=valueExpression (FROM | ',') pos=valueExpression ((FOR | ',') len=valueExpression)? ')' #substring | TRIM '(' trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)? FROM srcStr=valueExpression ')' #trim | OVERLAY '(' input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? ')' #overlay ; constant : NULL #nullLiteral | interval #intervalLiteral | identifier STRING #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral | STRING+ #stringLiteral ; comparisonOperator : EQ | NEQ | NEQJ | LT | LTE | GT | GTE | NSEQ ; arithmeticOperator : PLUS | MINUS | ASTERISK | SLASH | PERCENT | DIV | TILDE | AMPERSAND | PIPE | CONCAT_PIPE | HAT ; predicateOperator : OR | AND | IN | NOT ; booleanValue : TRUE | FALSE ; interval : INTERVAL (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval)? ; errorCapturingMultiUnitsInterval : multiUnitsInterval unitToUnitInterval? ; multiUnitsInterval : (intervalValue intervalUnit)+ ; errorCapturingUnitToUnitInterval : body=unitToUnitInterval (error1=multiUnitsInterval | error2=unitToUnitInterval)? ; unitToUnitInterval : value=intervalValue from=intervalUnit TO to=intervalUnit ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; intervalUnit : DAY | HOUR | MINUTE | MONTH | SECOND | YEAR | identifier ; colPosition : position=FIRST | position=AFTER afterCol=errorCapturingIdentifier ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; qualifiedColTypeWithPositionList : qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)* ; qualifiedColTypeWithPosition : name=multipartIdentifier dataType (NOT NULL)? commentSpec? colPosition? ; colTypeList : colType (',' colType)* ; colType : colName=errorCapturingIdentifier dataType (NOT NULL)? commentSpec? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (NOT NULL)? commentSpec? ; whenClause : WHEN condition=expression THEN result=expression ; windowClause : WINDOW namedWindow (',' namedWindow)* ; namedWindow : name=errorCapturingIdentifier AS windowSpec ; windowSpec : name=errorCapturingIdentifier #windowRef | '('name=errorCapturingIdentifier')' #windowRef | '(' ( CLUSTER BY partition+=expression (',' partition+=expression)* | ((PARTITION | DISTRIBUTE) BY partition+=expression (',' partition+=expression)*)? ((ORDER | SORT) BY sortItem (',' sortItem)*)?) windowFrame? ')' #windowDef ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=(PRECEDING | FOLLOWING) | boundType=CURRENT ROW | expression boundType=(PRECEDING | FOLLOWING) ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; functionName : qualifiedName | FILTER | LEFT | RIGHT ; qualifiedName : identifier ('.' identifier)* ; // this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table` // replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise // valid expressions such as ""a-b"" can be recognized as an identifier errorCapturingIdentifier : identifier errorCapturingIdentifierExtra ; // extra left-factoring grammar errorCapturingIdentifierExtra : (MINUS identifier)+ #errorIdent | #realIdent ; identifier : strictIdentifier | {!SQL_standard_keyword_behavior}? strictNonReserved ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | {SQL_standard_keyword_behavior}? ansiNonReserved #unquotedIdentifier | {!SQL_standard_keyword_behavior}? nonReserved #unquotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; number : {!legacy_exponent_literal_as_decimal_enabled}? MINUS? EXPONENT_VALUE #exponentLiteral | {!legacy_exponent_literal_as_decimal_enabled}? MINUS? DECIMAL_VALUE #decimalLiteral | {legacy_exponent_literal_as_decimal_enabled}? MINUS? (EXPONENT_VALUE | DECIMAL_VALUE) #legacyDecimalLiteral | MINUS? INTEGER_VALUE #integerLiteral | MINUS? BIGINT_LITERAL #bigIntLiteral | MINUS? SMALLINT_LITERAL #smallIntLiteral | MINUS? TINYINT_LITERAL #tinyIntLiteral | MINUS? DOUBLE_LITERAL #doubleLiteral | MINUS? BIGDECIMAL_LITERAL #bigDecimalLiteral ; alterColumnAction : TYPE dataType | commentSpec | colPosition | setOrDrop=(SET | DROP) NOT NULL ; // When `SQL_standard_keyword_behavior=true`, there are 2 kinds of keywords in Spark SQL. // - Reserved keywords: // Keywords that are reserved and can't be used as identifiers for table, view, column, // function, alias, etc. // - Non-reserved keywords: // Keywords that have a special meaning only in particular contexts and can be used as // identifiers in other contexts. For example, `EXPLAIN SELECT ...` is a command, but EXPLAIN // can be used as identifiers in other places. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The non-reserved keywords are listed below. Keywords not in this list are reserved keywords. ansiNonReserved : ADD | AFTER | ALTER | ANALYZE | ARCHIVE | ARRAY | ASC | AT | BETWEEN | BUCKET | BUCKETS | BY | CACHE | CASCADE | CHANGE | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLECTION | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | COST | CUBE | CURRENT | DATA | DATABASE | DATABASES | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTRIBUTE | DIV | DROP | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FORMAT | FORMATTED | FUNCTION | FUNCTIONS | GLOBAL | GROUPING | IF | IGNORE | IMPORT | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | ITEMS | KEYS | LAST | LATERAL | LAZY | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MSCK | NAMESPACE | NAMESPACES | NO | NULLS | OF | OPTION | OPTIONS | OUT | OUTPUTFORMAT | OVER | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SEPARATED | SERDE | SERDEPROPERTIES | SET | SETS | SHOW | SKEWED | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | TOUCH | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | UNARCHIVE | UNBOUNDED | UNCACHE | UNLOCK | UNSET | UPDATE | USE | VALUES | VIEW | WINDOW ; // When `SQL_standard_keyword_behavior=false`, there are 2 kinds of keywords in Spark SQL. // - Non-reserved keywords: // Same definition as the one when `SQL_standard_keyword_behavior=true`. // - Strict-non-reserved keywords: // A strict version of non-reserved keywords, which can not be used as table alias. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The strict-non-reserved keywords are listed in `strictNonReserved`. // The non-reserved keywords are listed in `nonReserved`. // These 2 together contain all the keywords. strictNonReserved : ANTI | CROSS | EXCEPT | FULL | INNER | INTERSECT | JOIN | LEFT | NATURAL | ON | RIGHT | SEMI | SETMINUS | UNION | USING ; nonReserved : ADD | AFTER | ALL | ALTER | ANALYZE | AND | ANY | ARCHIVE | ARRAY | AS | ASC | AT | AUTHORIZATION | BETWEEN | BOTH | BUCKET | BUCKETS | BY | CACHE | CASCADE | CASE | CAST | CHANGE | CHECK | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLATE | COLLECTION | COLUMN | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | CONSTRAINT | COST | CREATE | CUBE | CURRENT | CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATABASES | DAY | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTINCT | DISTRIBUTE | DIV | DROP | ELSE | END | ESCAPE | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FALSE | FETCH | FILTER | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FOR | FOREIGN | FORMAT | FORMATTED | FROM | FUNCTION | FUNCTIONS | GLOBAL | GRANT | GROUP | GROUPING | HAVING | HOUR | IF | IGNORE | IMPORT | IN | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | INTO | IS | ITEMS | KEYS | LAST | LATERAL | LAZY | LEADING | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MINUTE | MONTH | MSCK | NAMESPACE | NAMESPACES | NO | NOT | NULL | NULLS | OF | ONLY | OPTION | OPTIONS | OR | ORDER | OUT | OUTER | OUTPUTFORMAT | OVER | OVERLAPS | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRIMARY | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFERENCES | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECOND | SELECT | SEPARATED | SERDE | SERDEPROPERTIES | SESSION_USER | SET | SETS | SHOW | SKEWED | SOME | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLE | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | THEN | TO | TOUCH | TRAILING | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNIQUE | UNKNOWN | UNLOCK | UNSET | UPDATE | USE | USER | VALUES | VIEW | WHEN | WHERE | WINDOW | WITH | YEAR ; // NOTE: If you add a new token in the list below, you should update the list of keywords // in `docs/sql-keywords.md`. If the token is a non-reserved keyword, // please update `ansiNonReserved` and `nonReserved` as well. //============================ // Start of the keywords list //============================ ADD: 'ADD'; AFTER: 'AFTER'; ALL: 'ALL'; ALTER: 'ALTER'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY'; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; AUTHORIZATION: 'AUTHORIZATION'; BETWEEN: 'BETWEEN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; CACHE: 'CACHE'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CHANGE: 'CHANGE'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONSTRAINT: 'CONSTRAINT'; COST: 'COST'; CREATE: 'CREATE'; CROSS: 'CROSS'; CUBE: 'CUBE'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; DATA: 'DATA'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES' | 'SCHEMAS'; DAY: 'DAY'; DBPROPERTIES: 'DBPROPERTIES'; DEFINED: 'DEFINED'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DROP: 'DROP'; ELSE: 'ELSE'; END: 'END'; ESCAPE: 'ESCAPE'; ESCAPED: 'ESCAPED'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXISTS: 'EXISTS'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILTER: 'FILTER'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HAVING: 'HAVING'; HOUR: 'HOUR'; IF: 'IF'; IGNORE: 'IGNORE'; IMPORT: 'IMPORT'; IN: 'IN'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INTO: 'INTO'; IS: 'IS'; ITEMS: 'ITEMS'; JOIN: 'JOIN'; KEYS: 'KEYS'; LAST: 'LAST'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEFT: 'LEFT'; LIKE: 'LIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; MACRO: 'MACRO'; MAP: 'MAP'; MATCHED: 'MATCHED'; MERGE: 'MERGE'; MINUTE: 'MINUTE'; MONTH: 'MONTH'; MSCK: 'MSCK'; NAMESPACE: 'NAMESPACE'; NAMESPACES: 'NAMESPACES'; NATURAL: 'NATURAL'; NO: 'NO'; NOT: 'NOT' | '!'; NULL: 'NULL'; NULLS: 'NULLS'; OF: 'OF'; ON: 'ON'; ONLY: 'ONLY'; OPTION: 'OPTION'; OPTIONS: 'OPTIONS'; OR: 'OR'; ORDER: 'ORDER'; OUT: 'OUT'; OUTER: 'OUTER'; OUTPUTFORMAT: 'OUTPUTFORMAT'; OVER: 'OVER'; OVERLAPS: 'OVERLAPS'; OVERLAY: 'OVERLAY'; OVERWRITE: 'OVERWRITE'; PARTITION: 'PARTITION'; PARTITIONED: 'PARTITIONED'; PARTITIONS: 'PARTITIONS'; PERCENTLIT: 'PERCENT'; PIVOT: 'PIVOT'; PLACING: 'PLACING'; POSITION: 'POSITION'; PRECEDING: 'PRECEDING'; PRIMARY: 'PRIMARY'; PRINCIPALS: 'PRINCIPALS'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUERY: 'QUERY'; RANGE: 'RANGE'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESTRICT: 'RESTRICT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SCHEMA: 'SCHEMA'; SECOND: 'SECOND'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHOW: 'SHOW'; SKEWED: 'SKEWED'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STRUCT: 'STRUCT'; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TO: 'TO'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNSET: 'UNSET'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUES: 'VALUES'; VIEW: 'VIEW'; WHEN: 'WHEN'; WHERE: 'WHERE'; WINDOW: 'WINDOW'; WITH: 'WITH'; YEAR: 'YEAR'; //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; DIV: 'DIV'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; STRING : '\\'' ( ~('\\''|'\\\\') | ('\\\\' .) )* '\\'' | '""' ( ~('""'|'\\\\') | ('\\\\' .) )* '""' ; BIGINT_LITERAL : DIGIT+ 'L' ; SMALLINT_LITERAL : DIGIT+ 'S' ; TINYINT_LITERAL : DIGIT+ 'Y' ; INTEGER_VALUE : DIGIT+ ; EXPONENT_VALUE : DIGIT+ EXPONENT | DECIMAL_DIGITS EXPONENT {isValidDecimal()}? ; DECIMAL_VALUE : DECIMAL_DIGITS {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; SIMPLE_COMMENT : '--' ~[\\r\\n]* '\\r'? '\\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ; ",12397,False,2321.895285730198,median "/* * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar SqlBase; @members { /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ public boolean legacy_setops_precedence_enbled = false; /** * When false, a literal with an exponent would be converted into * double type rather than decimal type. */ public boolean legacy_exponent_literal_as_decimal_enabled = false; /** * Verify whether current token is a valid decimal token (which contains dot). * Returns true if the character that follows the token is not a digit or letter or underscore. * * For example: * For char stream ""2.3"", ""2."" is not a valid decimal token, because it is followed by digit '3'. * For char stream ""2.3_"", ""2.3"" is not a valid decimal token, because it is followed by '_'. * For char stream ""2.3W"", ""2.3"" is not a valid decimal token, because it is followed by 'W'. * For char stream ""12.0D 34.E2+0.12 "" 12.0D is a valid decimal token because it is followed * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+' * which is not a digit or letter or underscore. */ public boolean isValidDecimal() { int nextChar = _input.LA(1); if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' || nextChar == '_') { return false; } else { return true; } } /** * When true, the behavior of keywords follows ANSI SQL standard. */ public boolean SQL_standard_keyword_behavior = false; } singleStatement : statement ';'* EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleMultipartIdentifier : multipartIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; statement : query #statementDefault | ctes? dmlStatementNoWith #dmlStatement | USE NAMESPACE? multipartIdentifier #use | CREATE namespace (IF NOT EXISTS)? multipartIdentifier (commentSpec | locationSpec | (WITH (DBPROPERTIES | PROPERTIES) tablePropertyList))* #createNamespace | ALTER namespace multipartIdentifier SET (DBPROPERTIES | PROPERTIES) tablePropertyList #setNamespaceProperties | ALTER namespace multipartIdentifier SET locationSpec #setNamespaceLocation | DROP namespace (IF EXISTS)? multipartIdentifier (RESTRICT | CASCADE)? #dropNamespace | SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showNamespaces | createTableHeader ('(' colTypeList ')')? tableProvider createTableClauses (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? (commentSpec | (PARTITIONED BY '(' partitionColumns=colTypeList ')' | PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier (tableProvider | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* #createTableLike | replaceTableHeader ('(' colTypeList ')')? tableProvider createTableClauses (AS? query)? #replaceTable | ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) columns=qualifiedColTypeWithPositionList #addTableColumns | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) '(' columns=qualifiedColTypeWithPositionList ')' #addTableColumns | ALTER TABLE table=multipartIdentifier RENAME COLUMN from=multipartIdentifier TO to=errorCapturingIdentifier #renameTableColumn | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) '(' columns=multipartIdentifierList ')' #dropTableColumns | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) columns=multipartIdentifierList #dropTableColumns | ALTER (TABLE | VIEW) from=multipartIdentifier RENAME TO to=multipartIdentifier #renameTable | ALTER (TABLE | VIEW) multipartIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) multipartIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ALTER TABLE table=multipartIdentifier (ALTER | CHANGE) COLUMN? column=multipartIdentifier alterColumnAction? #alterTableAlterColumn | ALTER TABLE table=multipartIdentifier partitionSpec? CHANGE COLUMN? colName=multipartIdentifier colType colPosition? #hiveChangeColumn | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDEPROPERTIES tablePropertyList #setTableSerDe | ALTER (TABLE | VIEW) multipartIdentifier ADD (IF NOT EXISTS)? partitionSpecLocation+ #addTablePartition | ALTER TABLE multipartIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER (TABLE | VIEW) multipartIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER TABLE multipartIdentifier (partitionSpec)? SET locationSpec #setTableLocation | ALTER TABLE multipartIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? multipartIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? multipartIdentifier #dropView | CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)? VIEW (IF NOT EXISTS)? multipartIdentifier identifierCommentList? (commentSpec | (PARTITIONED ON identifierList) | (TBLPROPERTIES tablePropertyList))* AS query #createView | CREATE (OR REPLACE)? GLOBAL? TEMPORARY VIEW tableIdentifier ('(' colTypeList ')')? tableProvider (OPTIONS tablePropertyList)? #createTempViewUsing | ALTER VIEW multipartIdentifier AS? query #alterViewQuery | CREATE (OR REPLACE)? TEMPORARY? FUNCTION (IF NOT EXISTS)? multipartIdentifier AS className=STRING (USING resource (',' resource)*)? #createFunction | DROP TEMPORARY? FUNCTION (IF EXISTS)? multipartIdentifier #dropFunction | EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)? statement #explain | SHOW TABLES ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) ns=multipartIdentifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW TBLPROPERTIES table=multipartIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) table=multipartIdentifier ((FROM | IN) ns=multipartIdentifier)? #showColumns | SHOW VIEWS ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showViews | SHOW PARTITIONS multipartIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (multipartIdentifier | pattern=STRING))? #showFunctions | SHOW CREATE TABLE multipartIdentifier (AS SERDE)? #showCreateTable | SHOW CURRENT NAMESPACE #showCurrentNamespace | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) namespace EXTENDED? multipartIdentifier #describeNamespace | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? multipartIdentifier partitionSpec? describeColName? #describeRelation | (DESC | DESCRIBE) QUERY? query #describeQuery | COMMENT ON namespace multipartIdentifier IS comment=(STRING | NULL) #commentNamespace | COMMENT ON TABLE multipartIdentifier IS comment=(STRING | NULL) #commentTable | REFRESH TABLE multipartIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE LAZY? TABLE multipartIdentifier (OPTIONS options=tablePropertyList)? (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? multipartIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE multipartIdentifier partitionSpec? #loadData | TRUNCATE TABLE multipartIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE multipartIdentifier #repairTable | op=(ADD | LIST) identifier (STRING | .*?) #manageResource | SET ROLE .*? #failNativeCommand | SET .*? #setConfiguration | RESET #resetConfiguration | unsupportedHiveNativeCommands .*? #failNativeCommand ; unsupportedHiveNativeCommands : kw1=CREATE kw2=ROLE | kw1=DROP kw2=ROLE | kw1=GRANT kw2=ROLE? | kw1=REVOKE kw2=ROLE? | kw1=SHOW kw2=GRANT | kw1=SHOW kw2=ROLE kw3=GRANT? | kw1=SHOW kw2=PRINCIPALS | kw1=SHOW kw2=ROLES | kw1=SHOW kw2=CURRENT kw3=ROLES | kw1=EXPORT kw2=TABLE | kw1=IMPORT kw2=TABLE | kw1=SHOW kw2=COMPACTIONS | kw1=SHOW kw2=CREATE kw3=TABLE | kw1=SHOW kw2=TRANSACTIONS | kw1=SHOW kw2=INDEXES | kw1=SHOW kw2=LOCKS | kw1=CREATE kw2=INDEX | kw1=DROP kw2=INDEX | kw1=ALTER kw2=INDEX | kw1=LOCK kw2=TABLE | kw1=LOCK kw2=DATABASE | kw1=UNLOCK kw2=TABLE | kw1=UNLOCK kw2=DATABASE | kw1=CREATE kw2=TEMPORARY kw3=MACRO | kw1=DROP kw2=TEMPORARY kw3=MACRO | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=CLUSTERED | kw1=ALTER kw2=TABLE tableIdentifier kw3=CLUSTERED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SORTED | kw1=ALTER kw2=TABLE tableIdentifier kw3=SKEWED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SKEWED | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=STORED kw5=AS kw6=DIRECTORIES | kw1=ALTER kw2=TABLE tableIdentifier kw3=SET kw4=SKEWED kw5=LOCATION | kw1=ALTER kw2=TABLE tableIdentifier kw3=EXCHANGE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=ARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=UNARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=SET kw4=FILEFORMAT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=REPLACE kw4=COLUMNS | kw1=START kw2=TRANSACTION | kw1=COMMIT | kw1=ROLLBACK | kw1=DFS ; createTableHeader : CREATE TEMPORARY? EXTERNAL? TABLE (IF NOT EXISTS)? multipartIdentifier ; replaceTableHeader : (CREATE OR)? REPLACE TABLE multipartIdentifier ; bucketSpec : CLUSTERED BY identifierList (SORTED BY orderedIdentifierList)? INTO INTEGER_VALUE BUCKETS ; skewSpec : SKEWED BY identifierList ON (constantList | nestedConstantList) (STORED AS DIRECTORIES)? ; locationSpec : LOCATION STRING ; commentSpec : COMMENT STRING ; query : ctes? queryTerm queryOrganization ; insertInto : INSERT OVERWRITE TABLE? multipartIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? multipartIdentifier partitionSpec? (IF NOT EXISTS)? #insertIntoTable | INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat? #insertOverwriteHiveDir | INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)? tableProvider (OPTIONS options=tablePropertyList)? #insertOverwriteDir ; partitionSpecLocation : partitionSpec locationSpec? ; partitionSpec : PARTITION '(' partitionVal (',' partitionVal)* ')' ; partitionVal : identifier (EQ constant)? ; namespace : NAMESPACE | DATABASE | SCHEMA ; describeFuncName : qualifiedName | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=errorCapturingIdentifier (columnAliases=identifierList)? AS? '(' query ')' ; tableProvider : USING multipartIdentifier ; createTableClauses :((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | commentSpec | (TBLPROPERTIES tableProps=tablePropertyList))* ; tablePropertyList : '(' tableProperty (',' tableProperty)* ')' ; tableProperty : key=tablePropertyKey (EQ? value=tablePropertyValue)? ; tablePropertyKey : identifier ('.' identifier)* | STRING ; tablePropertyValue : INTEGER_VALUE | DECIMAL_VALUE | booleanValue | STRING ; constantList : '(' constant (',' constant)* ')' ; nestedConstantList : '(' constantList (',' constantList)* ')' ; createFileFormat : STORED AS fileFormat | STORED BY storageHandler ; fileFormat : INPUTFORMAT inFmt=STRING OUTPUTFORMAT outFmt=STRING #tableFileFormat | identifier #genericFileFormat ; storageHandler : STRING (WITH SERDEPROPERTIES tablePropertyList)? ; resource : identifier STRING ; dmlStatementNoWith : insertInto queryTerm queryOrganization #singleInsertQuery | fromClause multiInsertQueryBody+ #multiInsertQuery | DELETE FROM multipartIdentifier tableAlias whereClause? #deleteFromTable | UPDATE multipartIdentifier tableAlias setClause whereClause? #updateTable | MERGE INTO target=multipartIdentifier targetAlias=tableAlias USING (source=multipartIdentifier | '(' sourceQuery=query')') sourceAlias=tableAlias ON mergeCondition=booleanExpression matchedClause* notMatchedClause* #mergeIntoTable ; queryOrganization : (ORDER BY order+=sortItem (',' order+=sortItem)*)? (CLUSTER BY clusterBy+=expression (',' clusterBy+=expression)*)? (DISTRIBUTE BY distributeBy+=expression (',' distributeBy+=expression)*)? (SORT BY sort+=sortItem (',' sort+=sortItem)*)? windowClause? (LIMIT (ALL | limit=expression))? ; multiInsertQueryBody : insertInto fromStatementBody ; queryTerm : queryPrimary #queryTermDefault | left=queryTerm {legacy_setops_precedence_enbled}? operator=(INTERSECT | UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=INTERSECT setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=(UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation ; queryPrimary : querySpecification #queryPrimaryDefault | fromStatement #fromStmt | TABLE multipartIdentifier #table | inlineTable #inlineTableDefault1 | '(' query ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; fromStatement : fromClause fromStatementBody+ ; fromStatementBody : transformClause whereClause? queryOrganization | selectClause lateralView* whereClause? aggregationClause? havingClause? windowClause? queryOrganization ; querySpecification : transformClause fromClause? whereClause? #transformQuerySpecification | selectClause fromClause? lateralView* whereClause? aggregationClause? havingClause? windowClause? #regularQuerySpecification ; transformClause : (SELECT kind=TRANSFORM '(' namedExpressionSeq ')' | kind=MAP namedExpressionSeq | kind=REDUCE namedExpressionSeq) inRowFormat=rowFormat? (RECORDWRITER recordWriter=STRING)? USING script=STRING (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList) ')')))? outRowFormat=rowFormat? (RECORDREADER recordReader=STRING)? ; selectClause : SELECT (hints+=hint)* setQuantifier? namedExpressionSeq ; setClause : SET assignmentList ; matchedClause : WHEN MATCHED (AND matchedCond=booleanExpression)? THEN matchedAction ; notMatchedClause : WHEN NOT MATCHED (AND notMatchedCond=booleanExpression)? THEN notMatchedAction ; matchedAction : DELETE | UPDATE SET ASTERISK | UPDATE SET assignmentList ; notMatchedAction : INSERT ASTERISK | INSERT '(' columns=multipartIdentifierList ')' VALUES '(' expression (',' expression)* ')' ; assignmentList : assignment (',' assignment)* ; assignment : key=multipartIdentifier EQ value=expression ; whereClause : WHERE booleanExpression ; havingClause : HAVING booleanExpression ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregationClause : GROUP BY groupingExpressions+=expression (',' groupingExpressions+=expression)* ( WITH kind=ROLLUP | WITH kind=CUBE | kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')')? | GROUP BY kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')' ; groupingSet : '(' (expression (',' expression)*)? ')' | expression ; pivotClause : PIVOT '(' aggregates=namedExpressionSeq FOR pivotColumn IN '(' pivotValues+=pivotValue (',' pivotValues+=pivotValue)* ')' ')' ; pivotColumn : identifiers+=identifier | '(' identifiers+=identifier (',' identifiers+=identifier)* ')' ; pivotValue : expression (AS? identifier)? ; lateralView : LATERAL VIEW (OUTER)? qualifiedName '(' (expression (',' expression)*)? ')' tblName=identifier (AS? colName+=identifier (',' colName+=identifier)*)? ; setQuantifier : DISTINCT | ALL ; relation : relationPrimary joinRelation* ; joinRelation : (joinType) JOIN right=relationPrimary joinCriteria? | NATURAL joinType JOIN right=relationPrimary ; joinType : INNER? | CROSS | LEFT OUTER? | LEFT? SEMI | RIGHT OUTER? | FULL OUTER? | LEFT? ANTI ; joinCriteria : ON booleanExpression | USING identifierList ; sample : TABLESAMPLE '(' sampleMethod? ')' ; sampleMethod : negativeSign=MINUS? percentage=(INTEGER_VALUE | DECIMAL_VALUE) PERCENTLIT #sampleByPercentile | expression ROWS #sampleByRows | sampleType=BUCKET numerator=INTEGER_VALUE OUT OF denominator=INTEGER_VALUE (ON (identifier | qualifiedName '(' ')'))? #sampleByBucket | bytes=expression #sampleByBytes ; identifierList : '(' identifierSeq ')' ; identifierSeq : ident+=errorCapturingIdentifier (',' ident+=errorCapturingIdentifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : ident=errorCapturingIdentifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier commentSpec? ; relationPrimary : multipartIdentifier sample? tableAlias #tableName | '(' query ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : funcName=errorCapturingIdentifier '(' (expression (',' expression)*)? ')' tableAlias ; tableAlias : (AS? strictIdentifier identifierList?)? ; rowFormat : ROW FORMAT SERDE name=STRING (WITH SERDEPROPERTIES props=tablePropertyList)? #rowFormatSerde | ROW FORMAT DELIMITED (FIELDS TERMINATED BY fieldsTerminatedBy=STRING (ESCAPED BY escapedBy=STRING)?)? (COLLECTION ITEMS TERMINATED BY collectionItemsTerminatedBy=STRING)? (MAP KEYS TERMINATED BY keysTerminatedBy=STRING)? (LINES TERMINATED BY linesSeparatedBy=STRING)? (NULL DEFINED AS nullDefinedAs=STRING)? #rowFormatDelimited ; multipartIdentifierList : multipartIdentifier (',' multipartIdentifier)* ; multipartIdentifier : parts+=errorCapturingIdentifier ('.' parts+=errorCapturingIdentifier)* ; tableIdentifier : (db=errorCapturingIdentifier '.')? table=errorCapturingIdentifier ; functionIdentifier : (db=errorCapturingIdentifier '.')? function=errorCapturingIdentifier ; namedExpression : expression (AS? (name=errorCapturingIdentifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; transformList : '(' transforms+=transform (',' transforms+=transform)* ')' ; transform : qualifiedName #identityTransform | transformName=identifier '(' argument+=transformArgument (',' argument+=transformArgument)* ')' #applyTransform ; transformArgument : qualifiedName | constant ; expression : booleanExpression ; booleanExpression : NOT booleanExpression #logicalNot | EXISTS '(' query ')' #exists | valueExpression predicate? #predicated | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary ; predicate : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=RLIKE pattern=valueExpression | NOT? kind=LIKE pattern=valueExpression (ESCAPE escapeChar=STRING)? | IS NOT? kind=NULL | IS NOT? kind=(TRUE | FALSE | UNKNOWN) | IS NOT? kind=DISTINCT FROM right=valueExpression ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS | TILDE) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS | CONCAT_PIPE) right=valueExpression #arithmeticBinary | left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary | left=valueExpression operator=HAT right=valueExpression #arithmeticBinary | left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary | left=valueExpression comparisonOperator right=valueExpression #comparison ; primaryExpression : name=(CURRENT_DATE | CURRENT_TIMESTAMP) #currentDatetime | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase | CAST '(' expression AS dataType ')' #cast | STRUCT '(' (argument+=namedExpression (',' argument+=namedExpression)*)? ')' #struct | FIRST '(' expression (IGNORE NULLS)? ')' #first | LAST '(' expression (IGNORE NULLS)? ')' #last | POSITION '(' substr=valueExpression IN str=valueExpression ')' #position | constant #constantDefault | ASTERISK #star | qualifiedName '.' ASTERISK #star | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor | '(' query ')' #subqueryExpression | functionName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (FILTER '(' WHERE where=booleanExpression ')')? (OVER windowSpec)? #functionCall | identifier '->' expression #lambda | '(' identifier (',' identifier)+ ')' '->' expression #lambda | value=primaryExpression '[' index=valueExpression ']' #subscript | identifier #columnReference | base=primaryExpression '.' fieldName=identifier #dereference | '(' expression ')' #parenthesizedExpression | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract | (SUBSTR | SUBSTRING) '(' str=valueExpression (FROM | ',') pos=valueExpression ((FOR | ',') len=valueExpression)? ')' #substring | TRIM '(' trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)? FROM srcStr=valueExpression ')' #trim | OVERLAY '(' input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? ')' #overlay ; constant : NULL #nullLiteral | interval #intervalLiteral | identifier STRING #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral | STRING+ #stringLiteral ; comparisonOperator : EQ | NEQ | NEQJ | LT | LTE | GT | GTE | NSEQ ; arithmeticOperator : PLUS | MINUS | ASTERISK | SLASH | PERCENT | DIV | TILDE | AMPERSAND | PIPE | CONCAT_PIPE | HAT ; predicateOperator : OR | AND | IN | NOT ; booleanValue : TRUE | FALSE ; interval : INTERVAL (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval)? ; errorCapturingMultiUnitsInterval : multiUnitsInterval unitToUnitInterval? ; multiUnitsInterval : (intervalValue unit+=identifier)+ ; errorCapturingUnitToUnitInterval : body=unitToUnitInterval (error1=multiUnitsInterval | error2=unitToUnitInterval)? ; unitToUnitInterval : value=intervalValue from=identifier TO to=identifier ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; colPosition : position=FIRST | position=AFTER afterCol=errorCapturingIdentifier ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; qualifiedColTypeWithPositionList : qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)* ; qualifiedColTypeWithPosition : name=multipartIdentifier dataType (NOT NULL)? commentSpec? colPosition? ; colTypeList : colType (',' colType)* ; colType : colName=errorCapturingIdentifier dataType (NOT NULL)? commentSpec? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (NOT NULL)? commentSpec? ; whenClause : WHEN condition=expression THEN result=expression ; windowClause : WINDOW namedWindow (',' namedWindow)* ; namedWindow : name=errorCapturingIdentifier AS windowSpec ; windowSpec : name=errorCapturingIdentifier #windowRef | '('name=errorCapturingIdentifier')' #windowRef | '(' ( CLUSTER BY partition+=expression (',' partition+=expression)* | ((PARTITION | DISTRIBUTE) BY partition+=expression (',' partition+=expression)*)? ((ORDER | SORT) BY sortItem (',' sortItem)*)?) windowFrame? ')' #windowDef ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=(PRECEDING | FOLLOWING) | boundType=CURRENT ROW | expression boundType=(PRECEDING | FOLLOWING) ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; functionName : qualifiedName | FILTER | LEFT | RIGHT ; qualifiedName : identifier ('.' identifier)* ; // this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table` // replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise // valid expressions such as ""a-b"" can be recognized as an identifier errorCapturingIdentifier : identifier errorCapturingIdentifierExtra ; // extra left-factoring grammar errorCapturingIdentifierExtra : (MINUS identifier)+ #errorIdent | #realIdent ; identifier : strictIdentifier | {!SQL_standard_keyword_behavior}? strictNonReserved ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | {SQL_standard_keyword_behavior}? ansiNonReserved #unquotedIdentifier | {!SQL_standard_keyword_behavior}? nonReserved #unquotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; number : {!legacy_exponent_literal_as_decimal_enabled}? MINUS? EXPONENT_VALUE #exponentLiteral | {!legacy_exponent_literal_as_decimal_enabled}? MINUS? DECIMAL_VALUE #decimalLiteral | {legacy_exponent_literal_as_decimal_enabled}? MINUS? (EXPONENT_VALUE | DECIMAL_VALUE) #legacyDecimalLiteral | MINUS? INTEGER_VALUE #integerLiteral | MINUS? BIGINT_LITERAL #bigIntLiteral | MINUS? SMALLINT_LITERAL #smallIntLiteral | MINUS? TINYINT_LITERAL #tinyIntLiteral | MINUS? DOUBLE_LITERAL #doubleLiteral | MINUS? BIGDECIMAL_LITERAL #bigDecimalLiteral ; alterColumnAction : TYPE dataType | commentSpec | colPosition | setOrDrop=(SET | DROP) NOT NULL ; // When `SQL_standard_keyword_behavior=true`, there are 2 kinds of keywords in Spark SQL. // - Reserved keywords: // Keywords that are reserved and can't be used as identifiers for table, view, column, // function, alias, etc. // - Non-reserved keywords: // Keywords that have a special meaning only in particular contexts and can be used as // identifiers in other contexts. For example, `EXPLAIN SELECT ...` is a command, but EXPLAIN // can be used as identifiers in other places. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The non-reserved keywords are listed below. Keywords not in this list are reserved keywords. ansiNonReserved //--ANSI-NON-RESERVED-START : ADD | AFTER | ALTER | ANALYZE | ANTI | ARCHIVE | ARRAY | ASC | AT | BETWEEN | BUCKET | BUCKETS | BY | CACHE | CASCADE | CHANGE | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLECTION | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | COST | CUBE | CURRENT | DATA | DATABASE | DATABASES | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTRIBUTE | DIV | DROP | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FORMAT | FORMATTED | FUNCTION | FUNCTIONS | GLOBAL | GROUPING | IF | IGNORE | IMPORT | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | ITEMS | KEYS | LAST | LATERAL | LAZY | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MSCK | NAMESPACE | NAMESPACES | NO | NULLS | OF | OPTION | OPTIONS | OUT | OUTPUTFORMAT | OVER | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SEMI | SEPARATED | SERDE | SERDEPROPERTIES | SET | SETMINUS | SETS | SHOW | SKEWED | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | TOUCH | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNLOCK | UNSET | UPDATE | USE | VALUES | VIEW | VIEWS | WINDOW //--ANSI-NON-RESERVED-END ; // When `SQL_standard_keyword_behavior=false`, there are 2 kinds of keywords in Spark SQL. // - Non-reserved keywords: // Same definition as the one when `SQL_standard_keyword_behavior=true`. // - Strict-non-reserved keywords: // A strict version of non-reserved keywords, which can not be used as table alias. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The strict-non-reserved keywords are listed in `strictNonReserved`. // The non-reserved keywords are listed in `nonReserved`. // These 2 together contain all the keywords. strictNonReserved : ANTI | CROSS | EXCEPT | FULL | INNER | INTERSECT | JOIN | LEFT | NATURAL | ON | RIGHT | SEMI | SETMINUS | UNION | USING ; nonReserved //--DEFAULT-NON-RESERVED-START : ADD | AFTER | ALL | ALTER | ANALYZE | AND | ANY | ARCHIVE | ARRAY | AS | ASC | AT | AUTHORIZATION | BETWEEN | BOTH | BUCKET | BUCKETS | BY | CACHE | CASCADE | CASE | CAST | CHANGE | CHECK | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLATE | COLLECTION | COLUMN | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | CONSTRAINT | COST | CREATE | CUBE | CURRENT | CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATABASES | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTINCT | DISTRIBUTE | DIV | DROP | ELSE | END | ESCAPE | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FALSE | FETCH | FILTER | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FOR | FOREIGN | FORMAT | FORMATTED | FROM | FUNCTION | FUNCTIONS | GLOBAL | GRANT | GROUP | GROUPING | HAVING | IF | IGNORE | IMPORT | IN | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | INTO | IS | ITEMS | KEYS | LAST | LATERAL | LAZY | LEADING | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MSCK | NAMESPACE | NAMESPACES | NO | NOT | NULL | NULLS | OF | ONLY | OPTION | OPTIONS | OR | ORDER | OUT | OUTER | OUTPUTFORMAT | OVER | OVERLAPS | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRIMARY | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFERENCES | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SELECT | SEPARATED | SERDE | SERDEPROPERTIES | SESSION_USER | SET | SETS | SHOW | SKEWED | SOME | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLE | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | THEN | TO | TOUCH | TRAILING | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNIQUE | UNKNOWN | UNLOCK | UNSET | UPDATE | USE | USER | VALUES | VIEW | VIEWS | WHEN | WHERE | WINDOW | WITH //--DEFAULT-NON-RESERVED-END ; // NOTE: If you add a new token in the list below, you should update the list of keywords // and reserved tag in `docs/sql-ref-ansi-compliance.md#sql-keywords`. //============================ // Start of the keywords list //============================ //--SPARK-KEYWORD-LIST-START ADD: 'ADD'; AFTER: 'AFTER'; ALL: 'ALL'; ALTER: 'ALTER'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY'; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; AUTHORIZATION: 'AUTHORIZATION'; BETWEEN: 'BETWEEN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; CACHE: 'CACHE'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CHANGE: 'CHANGE'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONSTRAINT: 'CONSTRAINT'; COST: 'COST'; CREATE: 'CREATE'; CROSS: 'CROSS'; CUBE: 'CUBE'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; DATA: 'DATA'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES' | 'SCHEMAS'; DBPROPERTIES: 'DBPROPERTIES'; DEFINED: 'DEFINED'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DIV: 'DIV'; DROP: 'DROP'; ELSE: 'ELSE'; END: 'END'; ESCAPE: 'ESCAPE'; ESCAPED: 'ESCAPED'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXISTS: 'EXISTS'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILTER: 'FILTER'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HAVING: 'HAVING'; IF: 'IF'; IGNORE: 'IGNORE'; IMPORT: 'IMPORT'; IN: 'IN'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INTO: 'INTO'; IS: 'IS'; ITEMS: 'ITEMS'; JOIN: 'JOIN'; KEYS: 'KEYS'; LAST: 'LAST'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEFT: 'LEFT'; LIKE: 'LIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; MACRO: 'MACRO'; MAP: 'MAP'; MATCHED: 'MATCHED'; MERGE: 'MERGE'; MSCK: 'MSCK'; NAMESPACE: 'NAMESPACE'; NAMESPACES: 'NAMESPACES'; NATURAL: 'NATURAL'; NO: 'NO'; NOT: 'NOT' | '!'; NULL: 'NULL'; NULLS: 'NULLS'; OF: 'OF'; ON: 'ON'; ONLY: 'ONLY'; OPTION: 'OPTION'; OPTIONS: 'OPTIONS'; OR: 'OR'; ORDER: 'ORDER'; OUT: 'OUT'; OUTER: 'OUTER'; OUTPUTFORMAT: 'OUTPUTFORMAT'; OVER: 'OVER'; OVERLAPS: 'OVERLAPS'; OVERLAY: 'OVERLAY'; OVERWRITE: 'OVERWRITE'; PARTITION: 'PARTITION'; PARTITIONED: 'PARTITIONED'; PARTITIONS: 'PARTITIONS'; PERCENTLIT: 'PERCENT'; PIVOT: 'PIVOT'; PLACING: 'PLACING'; POSITION: 'POSITION'; PRECEDING: 'PRECEDING'; PRIMARY: 'PRIMARY'; PRINCIPALS: 'PRINCIPALS'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUERY: 'QUERY'; RANGE: 'RANGE'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESTRICT: 'RESTRICT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SCHEMA: 'SCHEMA'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHOW: 'SHOW'; SKEWED: 'SKEWED'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STRUCT: 'STRUCT'; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TO: 'TO'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNSET: 'UNSET'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUES: 'VALUES'; VIEW: 'VIEW'; VIEWS: 'VIEWS'; WHEN: 'WHEN'; WHERE: 'WHERE'; WINDOW: 'WINDOW'; WITH: 'WITH'; //--SPARK-KEYWORD-LIST-END //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; STRING : '\\'' ( ~('\\''|'\\\\') | ('\\\\' .) )* '\\'' | '""' ( ~('""'|'\\\\') | ('\\\\' .) )* '""' ; BIGINT_LITERAL : DIGIT+ 'L' ; SMALLINT_LITERAL : DIGIT+ 'S' ; TINYINT_LITERAL : DIGIT+ 'Y' ; INTEGER_VALUE : DIGIT+ ; EXPONENT_VALUE : DIGIT+ EXPONENT | DECIMAL_DIGITS EXPONENT {isValidDecimal()}? ; DECIMAL_VALUE : DECIMAL_DIGITS {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; SIMPLE_COMMENT : '--' ('\\\\\\n' | ~[\\r\\n])* '\\r'? '\\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ; ",12283,False,2282.4202960426546,median "############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 4, 0x90 POLY: .quad 0x1, 0xC200000000000000 TWOONE: .quad 0x1, 0x100000000 SHUF_CONST: .quad 0x8090a0b0c0d0e0f, 0x1020304050607 MASK1: .quad 0xffffffffffffffff, 0x0 MASK2: .quad 0x0, 0xffffffffffffffff INC_1: .quad 1,0 .p2align 4, 0x90 .globl _y8_AesGcmPrecompute_avx _y8_AesGcmPrecompute_avx: movdqu (%rsi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 psrlq $(63), %xmm4 movdqa %xmm4, %xmm3 pslldq $(8), %xmm4 psrldq $(8), %xmm3 por %xmm4, %xmm0 pshufd $(36), %xmm3, %xmm4 pcmpeqd TWOONE(%rip), %xmm4 pand POLY(%rip), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm1 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm0, %xmm3 pxor %xmm1, %xmm5 pxor %xmm0, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm0, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm3 movdqa %xmm1, %xmm5 movdqa %xmm1, %xmm15 psllq $(63), %xmm3 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm3 pxor %xmm15, %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm1 pxor %xmm3, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm1, %xmm3 pxor %xmm2, %xmm5 pxor %xmm1, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm1, %xmm2 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm1, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm3 movdqa %xmm2, %xmm5 movdqa %xmm2, %xmm15 psllq $(63), %xmm3 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm3 pxor %xmm15, %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 movdqu %xmm0, (%rdi) movdqu %xmm1, (16)(%rdi) movdqu %xmm2, (32)(%rdi) ret .p2align 4, 0x90 .globl _y8_AesGcmMulGcm_avx _y8_AesGcmMulGcm_avx: movdqa (%rdi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa (%rsi), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, (%rdi) ret .p2align 4, 0x90 .globl _y8_AesGcmAuth_avx _y8_AesGcmAuth_avx: movdqa (%rdi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa (%rcx), %xmm1 movslq %edx, %rdx .p2align 4, 0x90 .Lauth_loopgas_3: movdqu (%rsi), %xmm2 pshufb SHUF_CONST(%rip), %xmm2 add $(16), %rsi pxor %xmm2, %xmm0 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 sub $(16), %rdx jnz .Lauth_loopgas_3 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, (%rdi) ret .p2align 4, 0x90 .globl _y8_AesGcmEnc_avx _y8_AesGcmEnc_avx: push %rbx sub $(128), %rsp mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx movdqa SHUF_CONST(%rip), %xmm4 movdqu (%rax), %xmm0 movdqu (%rbx), %xmm1 movdqu (%rcx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%rsp) movdqa %xmm1, (16)(%rsp) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm1, (64)(%rsp) movdqa %xmm1, (80)(%rsp) mov (168)(%rsp), %rbx movdqa (32)(%rbx), %xmm10 pshufd $(78), %xmm10, %xmm9 pxor %xmm10, %xmm9 movdqa %xmm9, (96)(%rsp) movslq %edx, %rdx mov %r9, %rcx mov %rdx, %rax and $(63), %rax and $(-64), %rdx jz .Lsingle_block_procgas_4 .p2align 4, 0x90 .Lblks4_loopgas_4: movdqa INC_1(%rip), %xmm6 movdqa SHUF_CONST(%rip), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm6, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm6, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm6, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm6, %xmm4 movdqa %xmm4, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher4_loopgas_4: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher4_loopgas_4 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%rsp), %xmm0 movdqa %xmm4, (16)(%rsp) movdqu (%rsi), %xmm4 movdqu (16)(%rsi), %xmm5 movdqu (32)(%rsi), %xmm6 movdqu (48)(%rsi), %xmm7 add $(64), %rsi pxor %xmm4, %xmm0 movdqu %xmm0, (%rdi) pshufb SHUF_CONST(%rip), %xmm0 pxor (32)(%rsp), %xmm0 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%rdi) pshufb SHUF_CONST(%rip), %xmm1 pxor (48)(%rsp), %xmm1 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%rdi) pshufb SHUF_CONST(%rip), %xmm2 pxor (64)(%rsp), %xmm2 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%rdi) pshufb SHUF_CONST(%rip), %xmm3 pxor (80)(%rsp), %xmm3 add $(64), %rdi cmp $(64), %rdx je .Lcombine_hashgas_4 movdqa MASK1(%rip), %xmm14 pshufd $(78), %xmm0, %xmm6 movdqa %xmm0, %xmm5 pxor %xmm0, %xmm6 pclmulqdq $(0), %xmm10, %xmm0 pshufd $(78), %xmm1, %xmm13 movdqa %xmm1, %xmm12 pxor %xmm1, %xmm13 pclmulqdq $(17), %xmm10, %xmm5 pclmulqdq $(0), %xmm9, %xmm6 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 pshufd $(78), %xmm6, %xmm4 movdqa %xmm4, %xmm6 pand MASK2(%rip), %xmm4 pand %xmm14, %xmm6 pxor %xmm4, %xmm0 pxor %xmm6, %xmm5 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 pclmulqdq $(0), %xmm10, %xmm1 pxor %xmm4, %xmm0 psllq $(5), %xmm0 pxor %xmm4, %xmm0 psllq $(57), %xmm0 pshufd $(78), %xmm0, %xmm6 movdqa %xmm6, %xmm0 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm6 pand MASK2(%rip), %xmm0 pxor %xmm4, %xmm0 pxor %xmm6, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm0 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm6, %xmm0 psrlq $(1), %xmm0 pxor %xmm6, %xmm0 psrlq $(1), %xmm0 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 pxor %xmm1, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm1 pxor %xmm13, %xmm12 movdqa %xmm1, %xmm11 movdqa %xmm1, %xmm13 movdqa %xmm1, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm1 pxor %xmm11, %xmm12 movdqa %xmm1, %xmm13 psrlq $(5), %xmm13 pxor %xmm1, %xmm13 psrlq $(1), %xmm13 pxor %xmm1, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm1 pxor %xmm12, %xmm1 pshufd $(78), %xmm2, %xmm6 movdqa %xmm2, %xmm5 pxor %xmm2, %xmm6 pclmulqdq $(0), %xmm10, %xmm2 pshufd $(78), %xmm3, %xmm13 movdqa %xmm3, %xmm12 pxor %xmm3, %xmm13 pclmulqdq $(17), %xmm10, %xmm5 pclmulqdq $(0), %xmm9, %xmm6 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 pshufd $(78), %xmm6, %xmm4 movdqa %xmm4, %xmm6 pand MASK2(%rip), %xmm4 pand %xmm14, %xmm6 pxor %xmm4, %xmm2 pxor %xmm6, %xmm5 movdqa %xmm2, %xmm4 psllq $(1), %xmm2 pclmulqdq $(0), %xmm10, %xmm3 pxor %xmm4, %xmm2 psllq $(5), %xmm2 pxor %xmm4, %xmm2 psllq $(57), %xmm2 pshufd $(78), %xmm2, %xmm6 movdqa %xmm6, %xmm2 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm6 pand MASK2(%rip), %xmm2 pxor %xmm4, %xmm2 pxor %xmm6, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm2 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pxor %xmm3, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm3 pxor %xmm13, %xmm12 movdqa %xmm3, %xmm11 movdqa %xmm3, %xmm13 movdqa %xmm3, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm3 pxor %xmm11, %xmm12 movdqa %xmm3, %xmm13 psrlq $(5), %xmm13 pxor %xmm3, %xmm13 psrlq $(1), %xmm13 pxor %xmm3, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm3 pxor %xmm12, %xmm3 movdqa %xmm0, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm2, (64)(%rsp) movdqa %xmm3, (80)(%rsp) sub $(64), %rdx movdqa (%rsp), %xmm0 cmp $(64), %rdx jge .Lblks4_loopgas_4 .Lcombine_hashgas_4: movdqa (%rbx), %xmm8 movdqa (16)(%rbx), %xmm9 pshufd $(78), %xmm0, %xmm5 pshufd $(78), %xmm10, %xmm6 pxor %xmm0, %xmm5 pxor %xmm10, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm0, %xmm4 pclmulqdq $(0), %xmm10, %xmm0 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm10, %xmm4 pxor %xmm0, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm0 movdqa %xmm0, %xmm6 movdqa %xmm0, %xmm5 movdqa %xmm0, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm0 pxor %xmm6, %xmm4 movdqa %xmm0, %xmm5 psrlq $(5), %xmm5 pxor %xmm0, %xmm5 psrlq $(1), %xmm5 pxor %xmm0, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm0 pxor %xmm4, %xmm0 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm9, %xmm6 pxor %xmm1, %xmm5 pxor %xmm9, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm9, %xmm1 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm9, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm6 movdqa %xmm1, %xmm5 movdqa %xmm1, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm1 pxor %xmm6, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm8, %xmm6 pxor %xmm2, %xmm5 pxor %xmm8, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm8, %xmm2 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm8, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm6 movdqa %xmm2, %xmm5 movdqa %xmm2, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm2 pxor %xmm6, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 pxor %xmm1, %xmm3 pxor %xmm2, %xmm3 pshufd $(78), %xmm3, %xmm5 pshufd $(78), %xmm8, %xmm6 pxor %xmm3, %xmm5 pxor %xmm8, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm3, %xmm4 pclmulqdq $(0), %xmm8, %xmm3 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm8, %xmm4 pxor %xmm3, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm3 movdqa %xmm3, %xmm6 movdqa %xmm3, %xmm5 movdqa %xmm3, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm3 pxor %xmm6, %xmm4 movdqa %xmm3, %xmm5 psrlq $(5), %xmm5 pxor %xmm3, %xmm5 psrlq $(1), %xmm5 pxor %xmm3, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm3 pxor %xmm4, %xmm3 pxor %xmm0, %xmm3 movdqa %xmm3, (32)(%rsp) .Lsingle_block_procgas_4: test %rax, %rax jz .Lquitgas_4 .p2align 4, 0x90 .Lblk_loopgas_4: movdqa (%rsp), %xmm0 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb SHUF_CONST(%rip), %xmm1 pxor %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher_loopgas_4: aesenc %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher_loopgas_4 aesenclast %xmm0, %xmm1 movdqa (16)(%rsp), %xmm0 movdqa %xmm1, (16)(%rsp) movdqu (%rsi), %xmm1 add $(16), %rsi pxor %xmm1, %xmm0 movdqu %xmm0, (%rdi) add $(16), %rdi pshufb SHUF_CONST(%rip), %xmm0 pxor (32)(%rsp), %xmm0 movdqa (%rbx), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 movdqa %xmm0, (32)(%rsp) sub $(16), %rax jg .Lblk_loopgas_4 .Lquitgas_4: movdqa (%rsp), %xmm0 movdqa (16)(%rsp), %xmm1 movdqa (32)(%rsp), %xmm2 mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx pshufb SHUF_CONST(%rip), %xmm0 movdqu %xmm0, (%rax) movdqu %xmm1, (%rbx) pshufb SHUF_CONST(%rip), %xmm2 movdqu %xmm2, (%rcx) add $(128), %rsp pop %rbx ret .p2align 4, 0x90 .globl _y8_AesGcmDec_avx _y8_AesGcmDec_avx: push %rbx sub $(128), %rsp mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx movdqa SHUF_CONST(%rip), %xmm4 movdqu (%rax), %xmm0 movdqu (%rbx), %xmm1 movdqu (%rcx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%rsp) movdqa %xmm1, (16)(%rsp) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm1, (64)(%rsp) movdqa %xmm1, (80)(%rsp) mov (168)(%rsp), %rbx movdqa (32)(%rbx), %xmm10 pshufd $(78), %xmm10, %xmm9 pxor %xmm10, %xmm9 movdqa %xmm9, (96)(%rsp) movslq %edx, %rdx mov %r9, %rcx mov %rdx, %rax and $(63), %rax and $(-64), %rdx jz .Lsingle_block_procgas_5 .p2align 4, 0x90 .Lblks4_loopgas_5: movdqa INC_1(%rip), %xmm6 movdqa SHUF_CONST(%rip), %xmm5 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, %xmm2 paddd INC_1(%rip), %xmm2 movdqa %xmm2, %xmm3 paddd INC_1(%rip), %xmm3 movdqa %xmm3, %xmm4 paddd INC_1(%rip), %xmm4 movdqa %xmm4, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher4_loopgas_5: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher4_loopgas_5 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%rsp), %xmm0 movdqa %xmm4, (16)(%rsp) movdqu (%rsi), %xmm4 movdqu (16)(%rsi), %xmm5 movdqu (32)(%rsi), %xmm6 movdqu (48)(%rsi), %xmm7 add $(64), %rsi pxor %xmm4, %xmm0 movdqu %xmm0, (%rdi) pshufb SHUF_CONST(%rip), %xmm4 pxor (32)(%rsp), %xmm4 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%rdi) pshufb SHUF_CONST(%rip), %xmm5 pxor (48)(%rsp), %xmm5 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%rdi) pshufb SHUF_CONST(%rip), %xmm6 pxor (64)(%rsp), %xmm6 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%rdi) pshufb SHUF_CONST(%rip), %xmm7 pxor (80)(%rsp), %xmm7 add $(64), %rdi cmp $(64), %rdx je .Lcombine_hashgas_5 movdqa MASK1(%rip), %xmm14 pshufd $(78), %xmm4, %xmm2 movdqa %xmm4, %xmm1 pxor %xmm4, %xmm2 pclmulqdq $(0), %xmm10, %xmm4 pshufd $(78), %xmm5, %xmm13 movdqa %xmm5, %xmm12 pxor %xmm5, %xmm13 pclmulqdq $(17), %xmm10, %xmm1 pclmulqdq $(0), %xmm9, %xmm2 pxor %xmm4, %xmm2 pxor %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm0 movdqa %xmm0, %xmm2 pand MASK2(%rip), %xmm0 pand %xmm14, %xmm2 pxor %xmm0, %xmm4 pxor %xmm2, %xmm1 movdqa %xmm4, %xmm0 psllq $(1), %xmm4 pclmulqdq $(0), %xmm10, %xmm5 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 pshufd $(78), %xmm4, %xmm2 movdqa %xmm2, %xmm4 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm2 pand MASK2(%rip), %xmm4 pxor %xmm0, %xmm4 pxor %xmm2, %xmm1 movdqa %xmm4, %xmm2 psrlq $(5), %xmm4 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm2, %xmm4 psrlq $(1), %xmm4 pxor %xmm2, %xmm4 psrlq $(1), %xmm4 pxor %xmm2, %xmm4 pxor %xmm1, %xmm4 pxor %xmm5, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm5 pxor %xmm13, %xmm12 movdqa %xmm5, %xmm11 movdqa %xmm5, %xmm13 movdqa %xmm5, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm5 pxor %xmm11, %xmm12 movdqa %xmm5, %xmm13 psrlq $(5), %xmm13 pxor %xmm5, %xmm13 psrlq $(1), %xmm13 pxor %xmm5, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm5 pxor %xmm12, %xmm5 pshufd $(78), %xmm6, %xmm2 movdqa %xmm6, %xmm1 pxor %xmm6, %xmm2 pclmulqdq $(0), %xmm10, %xmm6 pshufd $(78), %xmm7, %xmm13 movdqa %xmm7, %xmm12 pxor %xmm7, %xmm13 pclmulqdq $(17), %xmm10, %xmm1 pclmulqdq $(0), %xmm9, %xmm2 pxor %xmm6, %xmm2 pxor %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm0 movdqa %xmm0, %xmm2 pand MASK2(%rip), %xmm0 pand %xmm14, %xmm2 pxor %xmm0, %xmm6 pxor %xmm2, %xmm1 movdqa %xmm6, %xmm0 psllq $(1), %xmm6 pclmulqdq $(0), %xmm10, %xmm7 pxor %xmm0, %xmm6 psllq $(5), %xmm6 pxor %xmm0, %xmm6 psllq $(57), %xmm6 pshufd $(78), %xmm6, %xmm2 movdqa %xmm2, %xmm6 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm2 pand MASK2(%rip), %xmm6 pxor %xmm0, %xmm6 pxor %xmm2, %xmm1 movdqa %xmm6, %xmm2 psrlq $(5), %xmm6 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 pxor %xmm1, %xmm6 pxor %xmm7, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm7 pxor %xmm13, %xmm12 movdqa %xmm7, %xmm11 movdqa %xmm7, %xmm13 movdqa %xmm7, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm7 pxor %xmm11, %xmm12 movdqa %xmm7, %xmm13 psrlq $(5), %xmm13 pxor %xmm7, %xmm13 psrlq $(1), %xmm13 pxor %xmm7, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm7 pxor %xmm12, %xmm7 movdqa %xmm4, (32)(%rsp) movdqa %xmm5, (48)(%rsp) movdqa %xmm6, (64)(%rsp) movdqa %xmm7, (80)(%rsp) sub $(64), %rdx movdqa (%rsp), %xmm0 cmp $(64), %rdx jge .Lblks4_loopgas_5 .Lcombine_hashgas_5: movdqa (%rbx), %xmm8 movdqa (16)(%rbx), %xmm9 pshufd $(78), %xmm4, %xmm2 pshufd $(78), %xmm10, %xmm0 pxor %xmm4, %xmm2 pxor %xmm10, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm4, %xmm1 pclmulqdq $(0), %xmm10, %xmm4 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm10, %xmm1 pxor %xmm4, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm4 movdqa %xmm4, %xmm0 movdqa %xmm4, %xmm2 movdqa %xmm4, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm4 pxor %xmm0, %xmm1 movdqa %xmm4, %xmm2 psrlq $(5), %xmm2 pxor %xmm4, %xmm2 psrlq $(1), %xmm2 pxor %xmm4, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm4 pxor %xmm1, %xmm4 pshufd $(78), %xmm5, %xmm2 pshufd $(78), %xmm9, %xmm0 pxor %xmm5, %xmm2 pxor %xmm9, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm5, %xmm1 pclmulqdq $(0), %xmm9, %xmm5 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm9, %xmm1 pxor %xmm5, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm5 movdqa %xmm5, %xmm0 movdqa %xmm5, %xmm2 movdqa %xmm5, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm5 pxor %xmm0, %xmm1 movdqa %xmm5, %xmm2 psrlq $(5), %xmm2 pxor %xmm5, %xmm2 psrlq $(1), %xmm2 pxor %xmm5, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm5 pxor %xmm1, %xmm5 pshufd $(78), %xmm6, %xmm2 pshufd $(78), %xmm8, %xmm0 pxor %xmm6, %xmm2 pxor %xmm8, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm6, %xmm1 pclmulqdq $(0), %xmm8, %xmm6 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm8, %xmm1 pxor %xmm6, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm6 movdqa %xmm6, %xmm0 movdqa %xmm6, %xmm2 movdqa %xmm6, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm6 pxor %xmm0, %xmm1 movdqa %xmm6, %xmm2 psrlq $(5), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm6 pxor %xmm1, %xmm6 pxor %xmm5, %xmm7 pxor %xmm6, %xmm7 pshufd $(78), %xmm7, %xmm2 pshufd $(78), %xmm8, %xmm0 pxor %xmm7, %xmm2 pxor %xmm8, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm7, %xmm1 pclmulqdq $(0), %xmm8, %xmm7 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm8, %xmm1 pxor %xmm7, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm7 movdqa %xmm7, %xmm0 movdqa %xmm7, %xmm2 movdqa %xmm7, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm7 pxor %xmm0, %xmm1 movdqa %xmm7, %xmm2 psrlq $(5), %xmm2 pxor %xmm7, %xmm2 psrlq $(1), %xmm2 pxor %xmm7, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm7 pxor %xmm1, %xmm7 pxor %xmm4, %xmm7 movdqa %xmm7, (32)(%rsp) .Lsingle_block_procgas_5: test %rax, %rax jz .Lquitgas_5 .p2align 4, 0x90 .Lblk_loopgas_5: movdqa (%rsp), %xmm0 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb SHUF_CONST(%rip), %xmm1 pxor %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher_loopgas_5: aesenc %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher_loopgas_5 aesenclast %xmm0, %xmm1 movdqa (16)(%rsp), %xmm0 movdqa %xmm1, (16)(%rsp) movdqu (%rsi), %xmm1 add $(16), %rsi pxor %xmm1, %xmm0 movdqu %xmm0, (%rdi) add $(16), %rdi pshufb SHUF_CONST(%rip), %xmm1 pxor (32)(%rsp), %xmm1 movdqa (%rbx), %xmm0 pshufd $(78), %xmm1, %xmm4 pshufd $(78), %xmm0, %xmm2 pxor %xmm1, %xmm4 pxor %xmm0, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm1, %xmm3 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm0, %xmm3 pxor %xmm1, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 movdqa %xmm1, %xmm4 movdqa %xmm1, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm1 pxor %xmm2, %xmm3 movdqa %xmm1, %xmm4 psrlq $(5), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm1 pxor %xmm3, %xmm1 movdqa %xmm1, (32)(%rsp) sub $(16), %rax jg .Lblk_loopgas_5 .Lquitgas_5: movdqa (%rsp), %xmm0 movdqa (16)(%rsp), %xmm1 movdqa (32)(%rsp), %xmm2 mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx pshufb SHUF_CONST(%rip), %xmm0 movdqu %xmm0, (%rax) movdqu %xmm1, (%rbx) pshufb SHUF_CONST(%rip), %xmm2 movdqu %xmm2, (%rcx) add $(128), %rsp pop %rbx ret ",16236,True,4894.856107583023,median "/* * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar SqlBase; @members { /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ public boolean legacy_setops_precedence_enbled = false; /** * Verify whether current token is a valid decimal token (which contains dot). * Returns true if the character that follows the token is not a digit or letter or underscore. * * For example: * For char stream ""2.3"", ""2."" is not a valid decimal token, because it is followed by digit '3'. * For char stream ""2.3_"", ""2.3"" is not a valid decimal token, because it is followed by '_'. * For char stream ""2.3W"", ""2.3"" is not a valid decimal token, because it is followed by 'W'. * For char stream ""12.0D 34.E2+0.12 "" 12.0D is a valid decimal token because it is followed * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+' * which is not a digit or letter or underscore. */ public boolean isValidDecimal() { int nextChar = _input.LA(1); if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' || nextChar == '_') { return false; } else { return true; } } /** * When true, ANSI SQL parsing mode is enabled. */ public boolean ansi = false; } singleStatement : statement EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleMultipartIdentifier : multipartIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; statement : query #statementDefault | ctes? dmlStatementNoWith #dmlStatement | USE NAMESPACE? multipartIdentifier #use | CREATE (database | NAMESPACE) (IF NOT EXISTS)? multipartIdentifier ((COMMENT comment=STRING) | locationSpec | (WITH (DBPROPERTIES | PROPERTIES) tablePropertyList))* #createNamespace | ALTER (database | NAMESPACE) multipartIdentifier SET (DBPROPERTIES | PROPERTIES) tablePropertyList #setNamespaceProperties | ALTER (database | NAMESPACE) multipartIdentifier SET locationSpec #setNamespaceLocation | DROP (database | NAMESPACE) (IF EXISTS)? multipartIdentifier (RESTRICT | CASCADE)? #dropNamespace | SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showNamespaces | createTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? ((COMMENT comment=STRING) | (PARTITIONED BY '(' partitionColumns=colTypeList ')' | PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier tableProvider? locationSpec? #createTableLike | replaceTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #replaceTable | ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) columns=qualifiedColTypeWithPositionList #addTableColumns | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) '(' columns=qualifiedColTypeWithPositionList ')' #addTableColumns | ALTER TABLE table=multipartIdentifier RENAME COLUMN from=multipartIdentifier TO to=errorCapturingIdentifier #renameTableColumn | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) '(' columns=multipartIdentifierList ')' #dropTableColumns | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) columns=multipartIdentifierList #dropTableColumns | ALTER (TABLE | VIEW) from=tableIdentifier RENAME TO to=tableIdentifier #renameTable | ALTER (TABLE | VIEW) multipartIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) multipartIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ALTER TABLE table=multipartIdentifier (ALTER | CHANGE) COLUMN? column=multipartIdentifier (TYPE dataType)? (COMMENT comment=STRING)? colPosition? #alterTableColumn | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDEPROPERTIES tablePropertyList #setTableSerDe | ALTER (TABLE | VIEW) multipartIdentifier ADD (IF NOT EXISTS)? partitionSpecLocation+ #addTablePartition | ALTER TABLE multipartIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER (TABLE | VIEW) multipartIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER TABLE multipartIdentifier (partitionSpec)? SET locationSpec #setTableLocation | ALTER TABLE multipartIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? multipartIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? multipartIdentifier #dropView | CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)? VIEW (IF NOT EXISTS)? tableIdentifier identifierCommentList? ((COMMENT STRING) | (PARTITIONED ON identifierList) | (TBLPROPERTIES tablePropertyList))* AS query #createView | CREATE (OR REPLACE)? GLOBAL? TEMPORARY VIEW tableIdentifier ('(' colTypeList ')')? tableProvider (OPTIONS tablePropertyList)? #createTempViewUsing | ALTER VIEW multipartIdentifier AS? query #alterViewQuery | CREATE (OR REPLACE)? TEMPORARY? FUNCTION (IF NOT EXISTS)? multipartIdentifier AS className=STRING (USING resource (',' resource)*)? #createFunction | DROP TEMPORARY? FUNCTION (IF EXISTS)? multipartIdentifier #dropFunction | EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)? statement #explain | SHOW TABLES ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) namespace=multipartIdentifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW TBLPROPERTIES table=multipartIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) table=multipartIdentifier ((FROM | IN) namespace=multipartIdentifier)? #showColumns | SHOW PARTITIONS multipartIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (multipartIdentifier | pattern=STRING))? #showFunctions | SHOW CREATE TABLE multipartIdentifier #showCreateTable | SHOW CURRENT NAMESPACE #showCurrentNamespace | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) (database | NAMESPACE) EXTENDED? multipartIdentifier #describeNamespace | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? multipartIdentifier partitionSpec? describeColName? #describeTable | (DESC | DESCRIBE) QUERY? query #describeQuery | REFRESH TABLE multipartIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE LAZY? TABLE multipartIdentifier (OPTIONS options=tablePropertyList)? (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? multipartIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE multipartIdentifier partitionSpec? #loadData | TRUNCATE TABLE multipartIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE multipartIdentifier #repairTable | op=(ADD | LIST) identifier .*? #manageResource | SET ROLE .*? #failNativeCommand | SET .*? #setConfiguration | RESET #resetConfiguration | unsupportedHiveNativeCommands .*? #failNativeCommand ; unsupportedHiveNativeCommands : kw1=CREATE kw2=ROLE | kw1=DROP kw2=ROLE | kw1=GRANT kw2=ROLE? | kw1=REVOKE kw2=ROLE? | kw1=SHOW kw2=GRANT | kw1=SHOW kw2=ROLE kw3=GRANT? | kw1=SHOW kw2=PRINCIPALS | kw1=SHOW kw2=ROLES | kw1=SHOW kw2=CURRENT kw3=ROLES | kw1=EXPORT kw2=TABLE | kw1=IMPORT kw2=TABLE | kw1=SHOW kw2=COMPACTIONS | kw1=SHOW kw2=CREATE kw3=TABLE | kw1=SHOW kw2=TRANSACTIONS | kw1=SHOW kw2=INDEXES | kw1=SHOW kw2=LOCKS | kw1=CREATE kw2=INDEX | kw1=DROP kw2=INDEX | kw1=ALTER kw2=INDEX | kw1=LOCK kw2=TABLE | kw1=LOCK kw2=DATABASE | kw1=UNLOCK kw2=TABLE | kw1=UNLOCK kw2=DATABASE | kw1=CREATE kw2=TEMPORARY kw3=MACRO | kw1=DROP kw2=TEMPORARY kw3=MACRO | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=CLUSTERED | kw1=ALTER kw2=TABLE tableIdentifier kw3=CLUSTERED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SORTED | kw1=ALTER kw2=TABLE tableIdentifier kw3=SKEWED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SKEWED | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=STORED kw5=AS kw6=DIRECTORIES | kw1=ALTER kw2=TABLE tableIdentifier kw3=SET kw4=SKEWED kw5=LOCATION | kw1=ALTER kw2=TABLE tableIdentifier kw3=EXCHANGE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=ARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=UNARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=SET kw4=FILEFORMAT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=REPLACE kw4=COLUMNS | kw1=START kw2=TRANSACTION | kw1=COMMIT | kw1=ROLLBACK | kw1=DFS | kw1=DELETE kw2=FROM ; createTableHeader : CREATE TEMPORARY? EXTERNAL? TABLE (IF NOT EXISTS)? multipartIdentifier ; replaceTableHeader : (CREATE OR)? REPLACE TABLE multipartIdentifier ; bucketSpec : CLUSTERED BY identifierList (SORTED BY orderedIdentifierList)? INTO INTEGER_VALUE BUCKETS ; skewSpec : SKEWED BY identifierList ON (constantList | nestedConstantList) (STORED AS DIRECTORIES)? ; locationSpec : LOCATION STRING ; query : ctes? queryTerm queryOrganization ; insertInto : INSERT OVERWRITE TABLE? multipartIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? multipartIdentifier partitionSpec? (IF NOT EXISTS)? #insertIntoTable | INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat? #insertOverwriteHiveDir | INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)? tableProvider (OPTIONS options=tablePropertyList)? #insertOverwriteDir ; partitionSpecLocation : partitionSpec locationSpec? ; partitionSpec : PARTITION '(' partitionVal (',' partitionVal)* ')' ; partitionVal : identifier (EQ constant)? ; database : DATABASE | SCHEMA ; describeFuncName : qualifiedName | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=errorCapturingIdentifier (columnAliases=identifierList)? AS? '(' query ')' ; tableProvider : USING multipartIdentifier ; tablePropertyList : '(' tableProperty (',' tableProperty)* ')' ; tableProperty : key=tablePropertyKey (EQ? value=tablePropertyValue)? ; tablePropertyKey : identifier ('.' identifier)* | STRING ; tablePropertyValue : INTEGER_VALUE | DECIMAL_VALUE | booleanValue | STRING ; constantList : '(' constant (',' constant)* ')' ; nestedConstantList : '(' constantList (',' constantList)* ')' ; createFileFormat : STORED AS fileFormat | STORED BY storageHandler ; fileFormat : INPUTFORMAT inFmt=STRING OUTPUTFORMAT outFmt=STRING #tableFileFormat | identifier #genericFileFormat ; storageHandler : STRING (WITH SERDEPROPERTIES tablePropertyList)? ; resource : identifier STRING ; dmlStatementNoWith : insertInto queryTerm queryOrganization #singleInsertQuery | fromClause multiInsertQueryBody+ #multiInsertQuery | DELETE FROM multipartIdentifier tableAlias whereClause? #deleteFromTable | UPDATE multipartIdentifier tableAlias setClause whereClause? #updateTable | MERGE INTO target=multipartIdentifier targetAlias=tableAlias USING (source=multipartIdentifier | '(' sourceQuery=query')') sourceAlias=tableAlias ON mergeCondition=booleanExpression matchedClause* notMatchedClause* #mergeIntoTable ; queryOrganization : (ORDER BY order+=sortItem (',' order+=sortItem)*)? (CLUSTER BY clusterBy+=expression (',' clusterBy+=expression)*)? (DISTRIBUTE BY distributeBy+=expression (',' distributeBy+=expression)*)? (SORT BY sort+=sortItem (',' sort+=sortItem)*)? windowClause? (LIMIT (ALL | limit=expression))? ; multiInsertQueryBody : insertInto fromStatementBody ; queryTerm : queryPrimary #queryTermDefault | left=queryTerm {legacy_setops_precedence_enbled}? operator=(INTERSECT | UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=INTERSECT setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=(UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation ; queryPrimary : querySpecification #queryPrimaryDefault | fromStatement #fromStmt | TABLE multipartIdentifier #table | inlineTable #inlineTableDefault1 | '(' query ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; fromStatement : fromClause fromStatementBody+ ; fromStatementBody : transformClause whereClause? queryOrganization | selectClause lateralView* whereClause? aggregationClause? havingClause? windowClause? queryOrganization ; querySpecification : transformClause fromClause? whereClause? #transformQuerySpecification | selectClause fromClause? lateralView* whereClause? aggregationClause? havingClause? windowClause? #regularQuerySpecification ; transformClause : (SELECT kind=TRANSFORM '(' namedExpressionSeq ')' | kind=MAP namedExpressionSeq | kind=REDUCE namedExpressionSeq) inRowFormat=rowFormat? (RECORDWRITER recordWriter=STRING)? USING script=STRING (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList) ')')))? outRowFormat=rowFormat? (RECORDREADER recordReader=STRING)? ; selectClause : SELECT (hints+=hint)* setQuantifier? namedExpressionSeq ; setClause : SET assignmentList ; matchedClause : WHEN MATCHED (AND matchedCond=booleanExpression)? THEN matchedAction ; notMatchedClause : WHEN NOT MATCHED (AND notMatchedCond=booleanExpression)? THEN notMatchedAction ; matchedAction : DELETE | UPDATE SET ASTERISK | UPDATE SET assignmentList ; notMatchedAction : INSERT ASTERISK | INSERT '(' columns=multipartIdentifierList ')' VALUES '(' expression (',' expression)* ')' ; assignmentList : assignment (',' assignment)* ; assignment : key=multipartIdentifier EQ value=expression ; whereClause : WHERE booleanExpression ; havingClause : HAVING booleanExpression ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregationClause : GROUP BY groupingExpressions+=expression (',' groupingExpressions+=expression)* ( WITH kind=ROLLUP | WITH kind=CUBE | kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')')? | GROUP BY kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')' ; groupingSet : '(' (expression (',' expression)*)? ')' | expression ; pivotClause : PIVOT '(' aggregates=namedExpressionSeq FOR pivotColumn IN '(' pivotValues+=pivotValue (',' pivotValues+=pivotValue)* ')' ')' ; pivotColumn : identifiers+=identifier | '(' identifiers+=identifier (',' identifiers+=identifier)* ')' ; pivotValue : expression (AS? identifier)? ; lateralView : LATERAL VIEW (OUTER)? qualifiedName '(' (expression (',' expression)*)? ')' tblName=identifier (AS? colName+=identifier (',' colName+=identifier)*)? ; setQuantifier : DISTINCT | ALL ; relation : relationPrimary joinRelation* ; joinRelation : (joinType) JOIN right=relationPrimary joinCriteria? | NATURAL joinType JOIN right=relationPrimary ; joinType : INNER? | CROSS | LEFT OUTER? | LEFT? SEMI | RIGHT OUTER? | FULL OUTER? | LEFT? ANTI ; joinCriteria : ON booleanExpression | USING identifierList ; sample : TABLESAMPLE '(' sampleMethod? ')' ; sampleMethod : negativeSign=MINUS? percentage=(INTEGER_VALUE | DECIMAL_VALUE) PERCENTLIT #sampleByPercentile | expression ROWS #sampleByRows | sampleType=BUCKET numerator=INTEGER_VALUE OUT OF denominator=INTEGER_VALUE (ON (identifier | qualifiedName '(' ')'))? #sampleByBucket | bytes=expression #sampleByBytes ; identifierList : '(' identifierSeq ')' ; identifierSeq : ident+=errorCapturingIdentifier (',' ident+=errorCapturingIdentifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : ident=errorCapturingIdentifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier (COMMENT STRING)? ; relationPrimary : multipartIdentifier sample? tableAlias #tableName | '(' query ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : funcName=errorCapturingIdentifier '(' (expression (',' expression)*)? ')' tableAlias ; tableAlias : (AS? strictIdentifier identifierList?)? ; rowFormat : ROW FORMAT SERDE name=STRING (WITH SERDEPROPERTIES props=tablePropertyList)? #rowFormatSerde | ROW FORMAT DELIMITED (FIELDS TERMINATED BY fieldsTerminatedBy=STRING (ESCAPED BY escapedBy=STRING)?)? (COLLECTION ITEMS TERMINATED BY collectionItemsTerminatedBy=STRING)? (MAP KEYS TERMINATED BY keysTerminatedBy=STRING)? (LINES TERMINATED BY linesSeparatedBy=STRING)? (NULL DEFINED AS nullDefinedAs=STRING)? #rowFormatDelimited ; multipartIdentifierList : multipartIdentifier (',' multipartIdentifier)* ; multipartIdentifier : parts+=errorCapturingIdentifier ('.' parts+=errorCapturingIdentifier)* ; tableIdentifier : (db=errorCapturingIdentifier '.')? table=errorCapturingIdentifier ; functionIdentifier : (db=errorCapturingIdentifier '.')? function=errorCapturingIdentifier ; namedExpression : expression (AS? (name=errorCapturingIdentifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; transformList : '(' transforms+=transform (',' transforms+=transform)* ')' ; transform : qualifiedName #identityTransform | transformName=identifier '(' argument+=transformArgument (',' argument+=transformArgument)* ')' #applyTransform ; transformArgument : qualifiedName | constant ; expression : booleanExpression ; booleanExpression : NOT booleanExpression #logicalNot | EXISTS '(' query ')' #exists | valueExpression predicate? #predicated | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary ; predicate : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=(RLIKE | LIKE) pattern=valueExpression | IS NOT? kind=NULL | IS NOT? kind=(TRUE | FALSE | UNKNOWN) | IS NOT? kind=DISTINCT FROM right=valueExpression ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS | TILDE) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS | CONCAT_PIPE) right=valueExpression #arithmeticBinary | left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary | left=valueExpression operator=HAT right=valueExpression #arithmeticBinary | left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary | left=valueExpression comparisonOperator right=valueExpression #comparison ; primaryExpression : name=(CURRENT_DATE | CURRENT_TIMESTAMP) #currentDatetime | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase | CAST '(' expression AS dataType ')' #cast | STRUCT '(' (argument+=namedExpression (',' argument+=namedExpression)*)? ')' #struct | (FIRST | FIRST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #first | (LAST | LAST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #last | POSITION '(' substr=valueExpression IN str=valueExpression ')' #position | constant #constantDefault | ASTERISK #star | qualifiedName '.' ASTERISK #star | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor | '(' query ')' #subqueryExpression | qualifiedName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (OVER windowSpec)? #functionCall | identifier '->' expression #lambda | '(' identifier (',' identifier)+ ')' '->' expression #lambda | value=primaryExpression '[' index=valueExpression ']' #subscript | identifier #columnReference | base=primaryExpression '.' fieldName=identifier #dereference | '(' expression ')' #parenthesizedExpression | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract | (SUBSTR | SUBSTRING) '(' str=valueExpression (FROM | ',') pos=valueExpression ((FOR | ',') len=valueExpression)? ')' #substring | TRIM '(' trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)? FROM srcStr=valueExpression ')' #trim | OVERLAY '(' input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? ')' #overlay ; constant : NULL #nullLiteral | interval #intervalLiteral | negativeSign=MINUS? identifier STRING #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral | STRING+ #stringLiteral ; comparisonOperator : EQ | NEQ | NEQJ | LT | LTE | GT | GTE | NSEQ ; arithmeticOperator : PLUS | MINUS | ASTERISK | SLASH | PERCENT | DIV | TILDE | AMPERSAND | PIPE | CONCAT_PIPE | HAT ; predicateOperator : OR | AND | IN | NOT ; booleanValue : TRUE | FALSE ; interval : negativeSign=MINUS? INTERVAL (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval)? | {ansi}? (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval) ; errorCapturingMultiUnitsInterval : multiUnitsInterval unitToUnitInterval? ; multiUnitsInterval : (intervalValue intervalUnit)+ ; errorCapturingUnitToUnitInterval : body=unitToUnitInterval (error1=multiUnitsInterval | error2=unitToUnitInterval)? ; unitToUnitInterval : value=intervalValue from=intervalUnit TO to=intervalUnit ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; intervalUnit : DAY | DAYS | HOUR | HOURS | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | SECOND | SECONDS | WEEK | WEEKS | YEAR | YEARS ; colPosition : FIRST | AFTER multipartIdentifier ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; qualifiedColTypeWithPositionList : qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)* ; qualifiedColTypeWithPosition : name=multipartIdentifier dataType (COMMENT comment=STRING)? colPosition? ; colTypeList : colType (',' colType)* ; colType : colName=errorCapturingIdentifier dataType (COMMENT STRING)? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (COMMENT STRING)? ; whenClause : WHEN condition=expression THEN result=expression ; windowClause : WINDOW namedWindow (',' namedWindow)* ; namedWindow : name=errorCapturingIdentifier AS windowSpec ; windowSpec : name=errorCapturingIdentifier #windowRef | '('name=errorCapturingIdentifier')' #windowRef | '(' ( CLUSTER BY partition+=expression (',' partition+=expression)* | ((PARTITION | DISTRIBUTE) BY partition+=expression (',' partition+=expression)*)? ((ORDER | SORT) BY sortItem (',' sortItem)*)?) windowFrame? ')' #windowDef ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=(PRECEDING | FOLLOWING) | boundType=CURRENT ROW | expression boundType=(PRECEDING | FOLLOWING) ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; qualifiedName : identifier ('.' identifier)* ; // this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table` // replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise // valid expressions such as ""a-b"" can be recognized as an identifier errorCapturingIdentifier : identifier errorCapturingIdentifierExtra ; // extra left-factoring grammar errorCapturingIdentifierExtra : (MINUS identifier)+ #errorIdent | #realIdent ; identifier : strictIdentifier | {!ansi}? strictNonReserved ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | {ansi}? ansiNonReserved #unquotedIdentifier | {!ansi}? nonReserved #unquotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; number : MINUS? DECIMAL_VALUE #decimalLiteral | MINUS? INTEGER_VALUE #integerLiteral | MINUS? BIGINT_LITERAL #bigIntLiteral | MINUS? SMALLINT_LITERAL #smallIntLiteral | MINUS? TINYINT_LITERAL #tinyIntLiteral | MINUS? DOUBLE_LITERAL #doubleLiteral | MINUS? BIGDECIMAL_LITERAL #bigDecimalLiteral ; // When `spark.sql.dialect.spark.ansi.enabled=true`, there are 2 kinds of keywords in Spark SQL. // - Reserved keywords: // Keywords that are reserved and can't be used as identifiers for table, view, column, // function, alias, etc. // - Non-reserved keywords: // Keywords that have a special meaning only in particular contexts and can be used as // identifiers in other contexts. For example, `SELECT 1 WEEK` is an interval literal, but WEEK // can be used as identifiers in other places. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The non-reserved keywords are listed below. Keywords not in this list are reserved keywords. ansiNonReserved : ADD | AFTER | ALTER | ANALYZE | ARCHIVE | ARRAY | ASC | AT | BETWEEN | BUCKET | BUCKETS | BY | CACHE | CASCADE | CHANGE | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLECTION | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | COST | CUBE | CURRENT | DATA | DATABASE | DATABASES | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTRIBUTE | DIV | DROP | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FORMAT | FORMATTED | FUNCTION | FUNCTIONS | GLOBAL | GROUPING | HOURS | IF | IGNORE | IMPORT | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | ITEMS | KEYS | LAST | LATERAL | LAZY | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTES | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NULLS | OF | OPTION | OPTIONS | OUT | OUTPUTFORMAT | OVER | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECONDS | SEPARATED | SERDE | SERDEPROPERTIES | SET | SETS | SHOW | SKEWED | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | TOUCH | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | UNARCHIVE | UNBOUNDED | UNCACHE | UNLOCK | UNSET | UPDATE | USE | VALUES | VIEW | WEEK | WEEKS | WINDOW | YEARS ; // When `spark.sql.dialect.spark.ansi.enabled=false`, there are 2 kinds of keywords in Spark SQL. // - Non-reserved keywords: // Same definition as the one when `spark.sql.dialect.spark.ansi.enabled=true`. // - Strict-non-reserved keywords: // A strict version of non-reserved keywords, which can not be used as table alias. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The strict-non-reserved keywords are listed in `strictNonReserved`. // The non-reserved keywords are listed in `nonReserved`. // These 2 together contain all the keywords. strictNonReserved : ANTI | CROSS | EXCEPT | FULL | INNER | INTERSECT | JOIN | LEFT | NATURAL | ON | RIGHT | SEMI | SETMINUS | UNION | USING ; nonReserved : ADD | AFTER | ALL | ALTER | ANALYZE | AND | ANY | ARCHIVE | ARRAY | AS | ASC | AT | AUTHORIZATION | BETWEEN | BOTH | BUCKET | BUCKETS | BY | CACHE | CASCADE | CASE | CAST | CHANGE | CHECK | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLATE | COLLECTION | COLUMN | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | CONSTRAINT | COST | CREATE | CUBE | CURRENT | CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATABASES | DAY | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTINCT | DISTRIBUTE | DIV | DROP | ELSE | END | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FALSE | FETCH | FIELDS | FILEFORMAT | FIRST | FIRST_VALUE | FOLLOWING | FOR | FOREIGN | FORMAT | FORMATTED | FROM | FUNCTION | FUNCTIONS | GLOBAL | GRANT | GROUP | GROUPING | HAVING | HOUR | HOURS | IF | IGNORE | IMPORT | IN | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | INTO | IS | ITEMS | KEYS | LAST | LAST_VALUE | LATERAL | LAZY | LEADING | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MATCHED | MERGE | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NOT | NULL | NULLS | OF | ONLY | OPTION | OPTIONS | OR | ORDER | OUT | OUTER | OUTPUTFORMAT | OVER | OVERLAPS | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRIMARY | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFERENCES | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECOND | SECONDS | SELECT | SEPARATED | SERDE | SERDEPROPERTIES | SESSION_USER | SET | SETS | SHOW | SKEWED | SOME | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLE | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | THEN | TO | TOUCH | TRAILING | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNIQUE | UNKNOWN | UNLOCK | UNSET | UPDATE | USE | USER | VALUES | VIEW | WEEK | WEEKS | WHEN | WHERE | WINDOW | WITH | YEAR | YEARS ; // NOTE: If you add a new token in the list below, you should update the list of keywords // in `docs/sql-keywords.md`. If the token is a non-reserved keyword, // please update `ansiNonReserved` and `nonReserved` as well. //============================ // Start of the keywords list //============================ ADD: 'ADD'; AFTER: 'AFTER'; ALL: 'ALL'; ALTER: 'ALTER'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY'; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; AUTHORIZATION: 'AUTHORIZATION'; BETWEEN: 'BETWEEN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; CACHE: 'CACHE'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CHANGE: 'CHANGE'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONSTRAINT: 'CONSTRAINT'; COST: 'COST'; CREATE: 'CREATE'; CROSS: 'CROSS'; CUBE: 'CUBE'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; DATA: 'DATA'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES' | 'SCHEMAS'; DAY: 'DAY'; DAYS: 'DAYS'; DBPROPERTIES: 'DBPROPERTIES'; DEFINED: 'DEFINED'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DROP: 'DROP'; ELSE: 'ELSE'; END: 'END'; ESCAPED: 'ESCAPED'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXISTS: 'EXISTS'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FIRST_VALUE: 'FIRST_VALUE'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HAVING: 'HAVING'; HOUR: 'HOUR'; HOURS: 'HOURS'; IF: 'IF'; IGNORE: 'IGNORE'; IMPORT: 'IMPORT'; IN: 'IN'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INTO: 'INTO'; IS: 'IS'; ITEMS: 'ITEMS'; JOIN: 'JOIN'; KEYS: 'KEYS'; LAST: 'LAST'; LAST_VALUE: 'LAST_VALUE'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEFT: 'LEFT'; LIKE: 'LIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; MACRO: 'MACRO'; MAP: 'MAP'; MATCHED: 'MATCHED'; MERGE: 'MERGE'; MICROSECOND: 'MICROSECOND'; MICROSECONDS: 'MICROSECONDS'; MILLISECOND: 'MILLISECOND'; MILLISECONDS: 'MILLISECONDS'; MINUTE: 'MINUTE'; MINUTES: 'MINUTES'; MONTH: 'MONTH'; MONTHS: 'MONTHS'; MSCK: 'MSCK'; NAMESPACE: 'NAMESPACE'; NAMESPACES: 'NAMESPACES'; NATURAL: 'NATURAL'; NO: 'NO'; NOT: 'NOT' | '!'; NULL: 'NULL'; NULLS: 'NULLS'; OF: 'OF'; ON: 'ON'; ONLY: 'ONLY'; OPTION: 'OPTION'; OPTIONS: 'OPTIONS'; OR: 'OR'; ORDER: 'ORDER'; OUT: 'OUT'; OUTER: 'OUTER'; OUTPUTFORMAT: 'OUTPUTFORMAT'; OVER: 'OVER'; OVERLAPS: 'OVERLAPS'; OVERLAY: 'OVERLAY'; OVERWRITE: 'OVERWRITE'; PARTITION: 'PARTITION'; PARTITIONED: 'PARTITIONED'; PARTITIONS: 'PARTITIONS'; PERCENTLIT: 'PERCENT'; PIVOT: 'PIVOT'; PLACING: 'PLACING'; POSITION: 'POSITION'; PRECEDING: 'PRECEDING'; PRIMARY: 'PRIMARY'; PRINCIPALS: 'PRINCIPALS'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUERY: 'QUERY'; RANGE: 'RANGE'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESPECT: 'RESPECT'; RESTRICT: 'RESTRICT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SCHEMA: 'SCHEMA'; SECOND: 'SECOND'; SECONDS: 'SECONDS'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHOW: 'SHOW'; SKEWED: 'SKEWED'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STRUCT: 'STRUCT'; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TO: 'TO'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNSET: 'UNSET'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUES: 'VALUES'; VIEW: 'VIEW'; WEEK: 'WEEK'; WEEKS: 'WEEKS'; WHEN: 'WHEN'; WHERE: 'WHERE'; WINDOW: 'WINDOW'; WITH: 'WITH'; YEAR: 'YEAR'; YEARS: 'YEARS'; //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; DIV: 'DIV'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; STRING : '\\'' ( ~('\\''|'\\\\') | ('\\\\' .) )* '\\'' | '""' ( ~('""'|'\\\\') | ('\\\\' .) )* '""' ; BIGINT_LITERAL : DIGIT+ 'L' ; SMALLINT_LITERAL : DIGIT+ 'S' ; TINYINT_LITERAL : DIGIT+ 'Y' ; INTEGER_VALUE : DIGIT+ ; DECIMAL_VALUE : DIGIT+ EXPONENT | DECIMAL_DIGITS EXPONENT? {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; SIMPLE_COMMENT : '--' ~[\\r\\n]* '\\r'? '\\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ; ",12354,False,2305.115486624634,median "; ; jidctint.asm - accurate integer IDCT (64-bit SSE2) ; ; Copyright 2009 Pierre Ossman for Cendio AB ; Copyright (C) 2009, 2016, D. R. Commander. ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; This file contains a slow-but-accurate integer implementation of the ; inverse DCT (Discrete Cosine Transform). The following code is based ; directly on the IJG's original jidctint.c; see the jidctint.c for ; more details. %include ""jsimdext.inc"" %include ""jdct.inc"" ; -------------------------------------------------------------------------- %define CONST_BITS 13 %define PASS1_BITS 2 %define DESCALE_P1 (CONST_BITS - PASS1_BITS) %define DESCALE_P2 (CONST_BITS + PASS1_BITS + 3) %if CONST_BITS == 13 F_0_298 equ 2446 ; FIX(0.298631336) F_0_390 equ 3196 ; FIX(0.390180644) F_0_541 equ 4433 ; FIX(0.541196100) F_0_765 equ 6270 ; FIX(0.765366865) F_0_899 equ 7373 ; FIX(0.899976223) F_1_175 equ 9633 ; FIX(1.175875602) F_1_501 equ 12299 ; FIX(1.501321110) F_1_847 equ 15137 ; FIX(1.847759065) F_1_961 equ 16069 ; FIX(1.961570560) F_2_053 equ 16819 ; FIX(2.053119869) F_2_562 equ 20995 ; FIX(2.562915447) F_3_072 equ 25172 ; FIX(3.072711026) %else ; NASM cannot do compile-time arithmetic on floating-point constants. %define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n)) F_0_298 equ DESCALE( 320652955, 30 - CONST_BITS) ; FIX(0.298631336) F_0_390 equ DESCALE( 418953276, 30 - CONST_BITS) ; FIX(0.390180644) F_0_541 equ DESCALE( 581104887, 30 - CONST_BITS) ; FIX(0.541196100) F_0_765 equ DESCALE( 821806413, 30 - CONST_BITS) ; FIX(0.765366865) F_0_899 equ DESCALE( 966342111, 30 - CONST_BITS) ; FIX(0.899976223) F_1_175 equ DESCALE(1262586813, 30 - CONST_BITS) ; FIX(1.175875602) F_1_501 equ DESCALE(1612031267, 30 - CONST_BITS) ; FIX(1.501321110) F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065) F_1_961 equ DESCALE(2106220350, 30 - CONST_BITS) ; FIX(1.961570560) F_2_053 equ DESCALE(2204520673, 30 - CONST_BITS) ; FIX(2.053119869) F_2_562 equ DESCALE(2751909506, 30 - CONST_BITS) ; FIX(2.562915447) F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026) %endif ; -------------------------------------------------------------------------- SECTION SEG_CONST alignz 32 GLOBAL_DATA(jconst_idct_islow_sse2) EXTN(jconst_idct_islow_sse2): PW_F130_F054 times 4 dw (F_0_541 + F_0_765), F_0_541 PW_F054_MF130 times 4 dw F_0_541, (F_0_541 - F_1_847) PW_MF078_F117 times 4 dw (F_1_175 - F_1_961), F_1_175 PW_F117_F078 times 4 dw F_1_175, (F_1_175 - F_0_390) PW_MF060_MF089 times 4 dw (F_0_298 - F_0_899), -F_0_899 PW_MF089_F060 times 4 dw -F_0_899, (F_1_501 - F_0_899) PW_MF050_MF256 times 4 dw (F_2_053 - F_2_562), -F_2_562 PW_MF256_F050 times 4 dw -F_2_562, (F_3_072 - F_2_562) PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1) PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1) PB_CENTERJSAMP times 16 db CENTERJSAMPLE alignz 32 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 64 ; ; Perform dequantization and inverse DCT on one block of coefficients. ; ; GLOBAL(void) ; jsimd_idct_islow_sse2(void *dct_table, JCOEFPTR coef_block, ; JSAMPARRAY output_buf, JDIMENSION output_col) ; ; r10 = jpeg_component_info *compptr ; r11 = JCOEFPTR coef_block ; r12 = JSAMPARRAY output_buf ; r13d = JDIMENSION output_col %define original_rbp rbp + 0 %define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM] %define WK_NUM 12 align 32 GLOBAL_FUNCTION(jsimd_idct_islow_sse2) EXTN(jsimd_idct_islow_sse2): push rbp mov rax, rsp ; rax = original rbp sub rsp, byte 4 and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits mov [rsp], rax mov rbp, rsp ; rbp = aligned rbp lea rsp, [wk(0)] collect_args 4 ; ---- Pass 1: process columns from input. mov rdx, r10 ; quantptr mov rsi, r11 ; inptr %ifndef NO_ZERO_COLUMN_TEST_ISLOW_SSE2 mov eax, dword [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)] or eax, dword [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)] jnz near .columnDCT movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] por xmm1, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] por xmm0, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] por xmm1, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] por xmm0, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] por xmm1, xmm0 packsswb xmm1, xmm1 packsswb xmm1, xmm1 movd eax, xmm1 test rax, rax jnz short .columnDCT ; -- AC terms all zero movdqa xmm5, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] pmullw xmm5, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] psllw xmm5, PASS1_BITS movdqa xmm4, xmm5 ; xmm5=in0=(00 01 02 03 04 05 06 07) punpcklwd xmm5, xmm5 ; xmm5=(00 00 01 01 02 02 03 03) punpckhwd xmm4, xmm4 ; xmm4=(04 04 05 05 06 06 07 07) pshufd xmm7, xmm5, 0x00 ; xmm7=col0=(00 00 00 00 00 00 00 00) pshufd xmm6, xmm5, 0x55 ; xmm6=col1=(01 01 01 01 01 01 01 01) pshufd xmm1, xmm5, 0xAA ; xmm1=col2=(02 02 02 02 02 02 02 02) pshufd xmm5, xmm5, 0xFF ; xmm5=col3=(03 03 03 03 03 03 03 03) pshufd xmm0, xmm4, 0x00 ; xmm0=col4=(04 04 04 04 04 04 04 04) pshufd xmm3, xmm4, 0x55 ; xmm3=col5=(05 05 05 05 05 05 05 05) pshufd xmm2, xmm4, 0xAA ; xmm2=col6=(06 06 06 06 06 06 06 06) pshufd xmm4, xmm4, 0xFF ; xmm4=col7=(07 07 07 07 07 07 07 07) movdqa XMMWORD [wk(8)], xmm6 ; wk(8)=col1 movdqa XMMWORD [wk(9)], xmm5 ; wk(9)=col3 movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5 movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7 jmp near .column_end %endif .columnDCT: ; -- Even part movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] pmullw xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] movdqa xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] movdqa xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] pmullw xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] pmullw xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] ; (Original) ; z1 = (z2 + z3) * 0.541196100; ; tmp2 = z1 + z3 * -1.847759065; ; tmp3 = z1 + z2 * 0.765366865; ; ; (This implementation) ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; movdqa xmm4, xmm1 ; xmm1=in2=z2 movdqa xmm5, xmm1 punpcklwd xmm4, xmm3 ; xmm3=in6=z3 punpckhwd xmm5, xmm3 movdqa xmm1, xmm4 movdqa xmm3, xmm5 pmaddwd xmm4, [rel PW_F130_F054] ; xmm4=tmp3L pmaddwd xmm5, [rel PW_F130_F054] ; xmm5=tmp3H pmaddwd xmm1, [rel PW_F054_MF130] ; xmm1=tmp2L pmaddwd xmm3, [rel PW_F054_MF130] ; xmm3=tmp2H movdqa xmm6, xmm0 paddw xmm0, xmm2 ; xmm0=in0+in4 psubw xmm6, xmm2 ; xmm6=in0-in4 pxor xmm7, xmm7 pxor xmm2, xmm2 punpcklwd xmm7, xmm0 ; xmm7=tmp0L punpckhwd xmm2, xmm0 ; xmm2=tmp0H psrad xmm7, (16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS psrad xmm2, (16-CONST_BITS) ; psrad xmm2,16 & pslld xmm2,CONST_BITS movdqa xmm0, xmm7 paddd xmm7, xmm4 ; xmm7=tmp10L psubd xmm0, xmm4 ; xmm0=tmp13L movdqa xmm4, xmm2 paddd xmm2, xmm5 ; xmm2=tmp10H psubd xmm4, xmm5 ; xmm4=tmp13H movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=tmp10L movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=tmp10H movdqa XMMWORD [wk(2)], xmm0 ; wk(2)=tmp13L movdqa XMMWORD [wk(3)], xmm4 ; wk(3)=tmp13H pxor xmm5, xmm5 pxor xmm7, xmm7 punpcklwd xmm5, xmm6 ; xmm5=tmp1L punpckhwd xmm7, xmm6 ; xmm7=tmp1H psrad xmm5, (16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS psrad xmm7, (16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS movdqa xmm2, xmm5 paddd xmm5, xmm1 ; xmm5=tmp11L psubd xmm2, xmm1 ; xmm2=tmp12L movdqa xmm0, xmm7 paddd xmm7, xmm3 ; xmm7=tmp11H psubd xmm0, xmm3 ; xmm0=tmp12H movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L movdqa XMMWORD [wk(5)], xmm7 ; wk(5)=tmp11H movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=tmp12L movdqa XMMWORD [wk(7)], xmm0 ; wk(7)=tmp12H ; -- Odd part movdqa xmm4, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] movdqa xmm6, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] pmullw xmm4, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] pmullw xmm6, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] movdqa xmm1, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] pmullw xmm1, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] pmullw xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] movdqa xmm5, xmm6 movdqa xmm7, xmm4 paddw xmm5, xmm3 ; xmm5=z3 paddw xmm7, xmm1 ; xmm7=z4 ; (Original) ; z5 = (z3 + z4) * 1.175875602; ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; ; z3 += z5; z4 += z5; ; ; (This implementation) ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); movdqa xmm2, xmm5 movdqa xmm0, xmm5 punpcklwd xmm2, xmm7 punpckhwd xmm0, xmm7 movdqa xmm5, xmm2 movdqa xmm7, xmm0 pmaddwd xmm2, [rel PW_MF078_F117] ; xmm2=z3L pmaddwd xmm0, [rel PW_MF078_F117] ; xmm0=z3H pmaddwd xmm5, [rel PW_F117_F078] ; xmm5=z4L pmaddwd xmm7, [rel PW_F117_F078] ; xmm7=z4H movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=z3L movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=z3H ; (Original) ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; ; tmp0 += z1 + z3; tmp1 += z2 + z4; ; tmp2 += z2 + z3; tmp3 += z1 + z4; ; ; (This implementation) ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); ; tmp0 += z3; tmp1 += z4; ; tmp2 += z3; tmp3 += z4; movdqa xmm2, xmm3 movdqa xmm0, xmm3 punpcklwd xmm2, xmm4 punpckhwd xmm0, xmm4 movdqa xmm3, xmm2 movdqa xmm4, xmm0 pmaddwd xmm2, [rel PW_MF060_MF089] ; xmm2=tmp0L pmaddwd xmm0, [rel PW_MF060_MF089] ; xmm0=tmp0H pmaddwd xmm3, [rel PW_MF089_F060] ; xmm3=tmp3L pmaddwd xmm4, [rel PW_MF089_F060] ; xmm4=tmp3H paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp0L paddd xmm0, XMMWORD [wk(11)] ; xmm0=tmp0H paddd xmm3, xmm5 ; xmm3=tmp3L paddd xmm4, xmm7 ; xmm4=tmp3H movdqa XMMWORD [wk(8)], xmm2 ; wk(8)=tmp0L movdqa XMMWORD [wk(9)], xmm0 ; wk(9)=tmp0H movdqa xmm2, xmm1 movdqa xmm0, xmm1 punpcklwd xmm2, xmm6 punpckhwd xmm0, xmm6 movdqa xmm1, xmm2 movdqa xmm6, xmm0 pmaddwd xmm2, [rel PW_MF050_MF256] ; xmm2=tmp1L pmaddwd xmm0, [rel PW_MF050_MF256] ; xmm0=tmp1H pmaddwd xmm1, [rel PW_MF256_F050] ; xmm1=tmp2L pmaddwd xmm6, [rel PW_MF256_F050] ; xmm6=tmp2H paddd xmm2, xmm5 ; xmm2=tmp1L paddd xmm0, xmm7 ; xmm0=tmp1H paddd xmm1, XMMWORD [wk(10)] ; xmm1=tmp2L paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=tmp1L movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=tmp1H ; -- Final output stage movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L movdqa xmm7, XMMWORD [wk(1)] ; xmm7=tmp10H movdqa xmm2, xmm5 movdqa xmm0, xmm7 paddd xmm5, xmm3 ; xmm5=data0L paddd xmm7, xmm4 ; xmm7=data0H psubd xmm2, xmm3 ; xmm2=data7L psubd xmm0, xmm4 ; xmm0=data7H movdqa xmm3, [rel PD_DESCALE_P1] ; xmm3=[rel PD_DESCALE_P1] paddd xmm5, xmm3 paddd xmm7, xmm3 psrad xmm5, DESCALE_P1 psrad xmm7, DESCALE_P1 paddd xmm2, xmm3 paddd xmm0, xmm3 psrad xmm2, DESCALE_P1 psrad xmm0, DESCALE_P1 packssdw xmm5, xmm7 ; xmm5=data0=(00 01 02 03 04 05 06 07) packssdw xmm2, xmm0 ; xmm2=data7=(70 71 72 73 74 75 76 77) movdqa xmm4, XMMWORD [wk(4)] ; xmm4=tmp11L movdqa xmm3, XMMWORD [wk(5)] ; xmm3=tmp11H movdqa xmm7, xmm4 movdqa xmm0, xmm3 paddd xmm4, xmm1 ; xmm4=data1L paddd xmm3, xmm6 ; xmm3=data1H psubd xmm7, xmm1 ; xmm7=data6L psubd xmm0, xmm6 ; xmm0=data6H movdqa xmm1, [rel PD_DESCALE_P1] ; xmm1=[rel PD_DESCALE_P1] paddd xmm4, xmm1 paddd xmm3, xmm1 psrad xmm4, DESCALE_P1 psrad xmm3, DESCALE_P1 paddd xmm7, xmm1 paddd xmm0, xmm1 psrad xmm7, DESCALE_P1 psrad xmm0, DESCALE_P1 packssdw xmm4, xmm3 ; xmm4=data1=(10 11 12 13 14 15 16 17) packssdw xmm7, xmm0 ; xmm7=data6=(60 61 62 63 64 65 66 67) movdqa xmm6, xmm5 ; transpose coefficients(phase 1) punpcklwd xmm5, xmm4 ; xmm5=(00 10 01 11 02 12 03 13) punpckhwd xmm6, xmm4 ; xmm6=(04 14 05 15 06 16 07 17) movdqa xmm1, xmm7 ; transpose coefficients(phase 1) punpcklwd xmm7, xmm2 ; xmm7=(60 70 61 71 62 72 63 73) punpckhwd xmm1, xmm2 ; xmm1=(64 74 65 75 66 76 67 77) movdqa xmm3, XMMWORD [wk(6)] ; xmm3=tmp12L movdqa xmm0, XMMWORD [wk(7)] ; xmm0=tmp12H movdqa xmm4, XMMWORD [wk(10)] ; xmm4=tmp1L movdqa xmm2, XMMWORD [wk(11)] ; xmm2=tmp1H movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 01 11 02 12 03 13) movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=(04 14 05 15 06 16 07 17) movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=(60 70 61 71 62 72 63 73) movdqa XMMWORD [wk(5)], xmm1 ; wk(5)=(64 74 65 75 66 76 67 77) movdqa xmm5, xmm3 movdqa xmm6, xmm0 paddd xmm3, xmm4 ; xmm3=data2L paddd xmm0, xmm2 ; xmm0=data2H psubd xmm5, xmm4 ; xmm5=data5L psubd xmm6, xmm2 ; xmm6=data5H movdqa xmm7, [rel PD_DESCALE_P1] ; xmm7=[rel PD_DESCALE_P1] paddd xmm3, xmm7 paddd xmm0, xmm7 psrad xmm3, DESCALE_P1 psrad xmm0, DESCALE_P1 paddd xmm5, xmm7 paddd xmm6, xmm7 psrad xmm5, DESCALE_P1 psrad xmm6, DESCALE_P1 packssdw xmm3, xmm0 ; xmm3=data2=(20 21 22 23 24 25 26 27) packssdw xmm5, xmm6 ; xmm5=data5=(50 51 52 53 54 55 56 57) movdqa xmm1, XMMWORD [wk(2)] ; xmm1=tmp13L movdqa xmm4, XMMWORD [wk(3)] ; xmm4=tmp13H movdqa xmm2, XMMWORD [wk(8)] ; xmm2=tmp0L movdqa xmm7, XMMWORD [wk(9)] ; xmm7=tmp0H movdqa xmm0, xmm1 movdqa xmm6, xmm4 paddd xmm1, xmm2 ; xmm1=data3L paddd xmm4, xmm7 ; xmm4=data3H psubd xmm0, xmm2 ; xmm0=data4L psubd xmm6, xmm7 ; xmm6=data4H movdqa xmm2, [rel PD_DESCALE_P1] ; xmm2=[rel PD_DESCALE_P1] paddd xmm1, xmm2 paddd xmm4, xmm2 psrad xmm1, DESCALE_P1 psrad xmm4, DESCALE_P1 paddd xmm0, xmm2 paddd xmm6, xmm2 psrad xmm0, DESCALE_P1 psrad xmm6, DESCALE_P1 packssdw xmm1, xmm4 ; xmm1=data3=(30 31 32 33 34 35 36 37) packssdw xmm0, xmm6 ; xmm0=data4=(40 41 42 43 44 45 46 47) movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 01 11 02 12 03 13) movdqa xmm2, XMMWORD [wk(1)] ; xmm2=(04 14 05 15 06 16 07 17) movdqa xmm4, xmm3 ; transpose coefficients(phase 1) punpcklwd xmm3, xmm1 ; xmm3=(20 30 21 31 22 32 23 33) punpckhwd xmm4, xmm1 ; xmm4=(24 34 25 35 26 36 27 37) movdqa xmm6, xmm0 ; transpose coefficients(phase 1) punpcklwd xmm0, xmm5 ; xmm0=(40 50 41 51 42 52 43 53) punpckhwd xmm6, xmm5 ; xmm6=(44 54 45 55 46 56 47 57) movdqa xmm1, xmm7 ; transpose coefficients(phase 2) punpckldq xmm7, xmm3 ; xmm7=(00 10 20 30 01 11 21 31) punpckhdq xmm1, xmm3 ; xmm1=(02 12 22 32 03 13 23 33) movdqa xmm5, xmm2 ; transpose coefficients(phase 2) punpckldq xmm2, xmm4 ; xmm2=(04 14 24 34 05 15 25 35) punpckhdq xmm5, xmm4 ; xmm5=(06 16 26 36 07 17 27 37) movdqa xmm3, XMMWORD [wk(4)] ; xmm3=(60 70 61 71 62 72 63 73) movdqa xmm4, XMMWORD [wk(5)] ; xmm4=(64 74 65 75 66 76 67 77) movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=(04 14 24 34 05 15 25 35) movdqa XMMWORD [wk(7)], xmm5 ; wk(7)=(06 16 26 36 07 17 27 37) movdqa xmm2, xmm0 ; transpose coefficients(phase 2) punpckldq xmm0, xmm3 ; xmm0=(40 50 60 70 41 51 61 71) punpckhdq xmm2, xmm3 ; xmm2=(42 52 62 72 43 53 63 73) movdqa xmm5, xmm6 ; transpose coefficients(phase 2) punpckldq xmm6, xmm4 ; xmm6=(44 54 64 74 45 55 65 75) punpckhdq xmm5, xmm4 ; xmm5=(46 56 66 76 47 57 67 77) movdqa xmm3, xmm7 ; transpose coefficients(phase 3) punpcklqdq xmm7, xmm0 ; xmm7=col0=(00 10 20 30 40 50 60 70) punpckhqdq xmm3, xmm0 ; xmm3=col1=(01 11 21 31 41 51 61 71) movdqa xmm4, xmm1 ; transpose coefficients(phase 3) punpcklqdq xmm1, xmm2 ; xmm1=col2=(02 12 22 32 42 52 62 72) punpckhqdq xmm4, xmm2 ; xmm4=col3=(03 13 23 33 43 53 63 73) movdqa xmm0, XMMWORD [wk(6)] ; xmm0=(04 14 24 34 05 15 25 35) movdqa xmm2, XMMWORD [wk(7)] ; xmm2=(06 16 26 36 07 17 27 37) movdqa XMMWORD [wk(8)], xmm3 ; wk(8)=col1 movdqa XMMWORD [wk(9)], xmm4 ; wk(9)=col3 movdqa xmm3, xmm0 ; transpose coefficients(phase 3) punpcklqdq xmm0, xmm6 ; xmm0=col4=(04 14 24 34 44 54 64 74) punpckhqdq xmm3, xmm6 ; xmm3=col5=(05 15 25 35 45 55 65 75) movdqa xmm4, xmm2 ; transpose coefficients(phase 3) punpcklqdq xmm2, xmm5 ; xmm2=col6=(06 16 26 36 46 56 66 76) punpckhqdq xmm4, xmm5 ; xmm4=col7=(07 17 27 37 47 57 67 77) movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5 movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7 .column_end: ; -- Prefetch the next coefficient block prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32] prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32] prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32] prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32] ; ---- Pass 2: process rows from work array, store into output array. mov rax, [original_rbp] mov rdi, r12 ; (JSAMPROW *) mov eax, r13d ; -- Even part ; xmm7=col0, xmm1=col2, xmm0=col4, xmm2=col6 ; (Original) ; z1 = (z2 + z3) * 0.541196100; ; tmp2 = z1 + z3 * -1.847759065; ; tmp3 = z1 + z2 * 0.765366865; ; ; (This implementation) ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; movdqa xmm6, xmm1 ; xmm1=in2=z2 movdqa xmm5, xmm1 punpcklwd xmm6, xmm2 ; xmm2=in6=z3 punpckhwd xmm5, xmm2 movdqa xmm1, xmm6 movdqa xmm2, xmm5 pmaddwd xmm6, [rel PW_F130_F054] ; xmm6=tmp3L pmaddwd xmm5, [rel PW_F130_F054] ; xmm5=tmp3H pmaddwd xmm1, [rel PW_F054_MF130] ; xmm1=tmp2L pmaddwd xmm2, [rel PW_F054_MF130] ; xmm2=tmp2H movdqa xmm3, xmm7 paddw xmm7, xmm0 ; xmm7=in0+in4 psubw xmm3, xmm0 ; xmm3=in0-in4 pxor xmm4, xmm4 pxor xmm0, xmm0 punpcklwd xmm4, xmm7 ; xmm4=tmp0L punpckhwd xmm0, xmm7 ; xmm0=tmp0H psrad xmm4, (16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS psrad xmm0, (16-CONST_BITS) ; psrad xmm0,16 & pslld xmm0,CONST_BITS movdqa xmm7, xmm4 paddd xmm4, xmm6 ; xmm4=tmp10L psubd xmm7, xmm6 ; xmm7=tmp13L movdqa xmm6, xmm0 paddd xmm0, xmm5 ; xmm0=tmp10H psubd xmm6, xmm5 ; xmm6=tmp13H movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=tmp10L movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp10H movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=tmp13L movdqa XMMWORD [wk(3)], xmm6 ; wk(3)=tmp13H pxor xmm5, xmm5 pxor xmm4, xmm4 punpcklwd xmm5, xmm3 ; xmm5=tmp1L punpckhwd xmm4, xmm3 ; xmm4=tmp1H psrad xmm5, (16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS psrad xmm4, (16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS movdqa xmm0, xmm5 paddd xmm5, xmm1 ; xmm5=tmp11L psubd xmm0, xmm1 ; xmm0=tmp12L movdqa xmm7, xmm4 paddd xmm4, xmm2 ; xmm4=tmp11H psubd xmm7, xmm2 ; xmm7=tmp12H movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=tmp11H movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=tmp12L movdqa XMMWORD [wk(7)], xmm7 ; wk(7)=tmp12H ; -- Odd part movdqa xmm6, XMMWORD [wk(9)] ; xmm6=col3 movdqa xmm3, XMMWORD [wk(8)] ; xmm3=col1 movdqa xmm1, XMMWORD [wk(11)] ; xmm1=col7 movdqa xmm2, XMMWORD [wk(10)] ; xmm2=col5 movdqa xmm5, xmm6 movdqa xmm4, xmm3 paddw xmm5, xmm1 ; xmm5=z3 paddw xmm4, xmm2 ; xmm4=z4 ; (Original) ; z5 = (z3 + z4) * 1.175875602; ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; ; z3 += z5; z4 += z5; ; ; (This implementation) ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); movdqa xmm0, xmm5 movdqa xmm7, xmm5 punpcklwd xmm0, xmm4 punpckhwd xmm7, xmm4 movdqa xmm5, xmm0 movdqa xmm4, xmm7 pmaddwd xmm0, [rel PW_MF078_F117] ; xmm0=z3L pmaddwd xmm7, [rel PW_MF078_F117] ; xmm7=z3H pmaddwd xmm5, [rel PW_F117_F078] ; xmm5=z4L pmaddwd xmm4, [rel PW_F117_F078] ; xmm4=z4H movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=z3L movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=z3H ; (Original) ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; ; tmp0 += z1 + z3; tmp1 += z2 + z4; ; tmp2 += z2 + z3; tmp3 += z1 + z4; ; ; (This implementation) ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); ; tmp0 += z3; tmp1 += z4; ; tmp2 += z3; tmp3 += z4; movdqa xmm0, xmm1 movdqa xmm7, xmm1 punpcklwd xmm0, xmm3 punpckhwd xmm7, xmm3 movdqa xmm1, xmm0 movdqa xmm3, xmm7 pmaddwd xmm0, [rel PW_MF060_MF089] ; xmm0=tmp0L pmaddwd xmm7, [rel PW_MF060_MF089] ; xmm7=tmp0H pmaddwd xmm1, [rel PW_MF089_F060] ; xmm1=tmp3L pmaddwd xmm3, [rel PW_MF089_F060] ; xmm3=tmp3H paddd xmm0, XMMWORD [wk(10)] ; xmm0=tmp0L paddd xmm7, XMMWORD [wk(11)] ; xmm7=tmp0H paddd xmm1, xmm5 ; xmm1=tmp3L paddd xmm3, xmm4 ; xmm3=tmp3H movdqa XMMWORD [wk(8)], xmm0 ; wk(8)=tmp0L movdqa XMMWORD [wk(9)], xmm7 ; wk(9)=tmp0H movdqa xmm0, xmm2 movdqa xmm7, xmm2 punpcklwd xmm0, xmm6 punpckhwd xmm7, xmm6 movdqa xmm2, xmm0 movdqa xmm6, xmm7 pmaddwd xmm0, [rel PW_MF050_MF256] ; xmm0=tmp1L pmaddwd xmm7, [rel PW_MF050_MF256] ; xmm7=tmp1H pmaddwd xmm2, [rel PW_MF256_F050] ; xmm2=tmp2L pmaddwd xmm6, [rel PW_MF256_F050] ; xmm6=tmp2H paddd xmm0, xmm5 ; xmm0=tmp1L paddd xmm7, xmm4 ; xmm7=tmp1H paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp2L paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=tmp1L movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=tmp1H ; -- Final output stage movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L movdqa xmm4, XMMWORD [wk(1)] ; xmm4=tmp10H movdqa xmm0, xmm5 movdqa xmm7, xmm4 paddd xmm5, xmm1 ; xmm5=data0L paddd xmm4, xmm3 ; xmm4=data0H psubd xmm0, xmm1 ; xmm0=data7L psubd xmm7, xmm3 ; xmm7=data7H movdqa xmm1, [rel PD_DESCALE_P2] ; xmm1=[rel PD_DESCALE_P2] paddd xmm5, xmm1 paddd xmm4, xmm1 psrad xmm5, DESCALE_P2 psrad xmm4, DESCALE_P2 paddd xmm0, xmm1 paddd xmm7, xmm1 psrad xmm0, DESCALE_P2 psrad xmm7, DESCALE_P2 packssdw xmm5, xmm4 ; xmm5=data0=(00 10 20 30 40 50 60 70) packssdw xmm0, xmm7 ; xmm0=data7=(07 17 27 37 47 57 67 77) movdqa xmm3, XMMWORD [wk(4)] ; xmm3=tmp11L movdqa xmm1, XMMWORD [wk(5)] ; xmm1=tmp11H movdqa xmm4, xmm3 movdqa xmm7, xmm1 paddd xmm3, xmm2 ; xmm3=data1L paddd xmm1, xmm6 ; xmm1=data1H psubd xmm4, xmm2 ; xmm4=data6L psubd xmm7, xmm6 ; xmm7=data6H movdqa xmm2, [rel PD_DESCALE_P2] ; xmm2=[rel PD_DESCALE_P2] paddd xmm3, xmm2 paddd xmm1, xmm2 psrad xmm3, DESCALE_P2 psrad xmm1, DESCALE_P2 paddd xmm4, xmm2 paddd xmm7, xmm2 psrad xmm4, DESCALE_P2 psrad xmm7, DESCALE_P2 packssdw xmm3, xmm1 ; xmm3=data1=(01 11 21 31 41 51 61 71) packssdw xmm4, xmm7 ; xmm4=data6=(06 16 26 36 46 56 66 76) packsswb xmm5, xmm4 ; xmm5=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) packsswb xmm3, xmm0 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) movdqa xmm6, XMMWORD [wk(6)] ; xmm6=tmp12L movdqa xmm2, XMMWORD [wk(7)] ; xmm2=tmp12H movdqa xmm1, XMMWORD [wk(10)] ; xmm1=tmp1L movdqa xmm7, XMMWORD [wk(11)] ; xmm7=tmp1H movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) movdqa xmm4, xmm6 movdqa xmm0, xmm2 paddd xmm6, xmm1 ; xmm6=data2L paddd xmm2, xmm7 ; xmm2=data2H psubd xmm4, xmm1 ; xmm4=data5L psubd xmm0, xmm7 ; xmm0=data5H movdqa xmm5, [rel PD_DESCALE_P2] ; xmm5=[rel PD_DESCALE_P2] paddd xmm6, xmm5 paddd xmm2, xmm5 psrad xmm6, DESCALE_P2 psrad xmm2, DESCALE_P2 paddd xmm4, xmm5 paddd xmm0, xmm5 psrad xmm4, DESCALE_P2 psrad xmm0, DESCALE_P2 packssdw xmm6, xmm2 ; xmm6=data2=(02 12 22 32 42 52 62 72) packssdw xmm4, xmm0 ; xmm4=data5=(05 15 25 35 45 55 65 75) movdqa xmm3, XMMWORD [wk(2)] ; xmm3=tmp13L movdqa xmm1, XMMWORD [wk(3)] ; xmm1=tmp13H movdqa xmm7, XMMWORD [wk(8)] ; xmm7=tmp0L movdqa xmm5, XMMWORD [wk(9)] ; xmm5=tmp0H movdqa xmm2, xmm3 movdqa xmm0, xmm1 paddd xmm3, xmm7 ; xmm3=data3L paddd xmm1, xmm5 ; xmm1=data3H psubd xmm2, xmm7 ; xmm2=data4L psubd xmm0, xmm5 ; xmm0=data4H movdqa xmm7, [rel PD_DESCALE_P2] ; xmm7=[rel PD_DESCALE_P2] paddd xmm3, xmm7 paddd xmm1, xmm7 psrad xmm3, DESCALE_P2 psrad xmm1, DESCALE_P2 paddd xmm2, xmm7 paddd xmm0, xmm7 psrad xmm2, DESCALE_P2 psrad xmm0, DESCALE_P2 movdqa xmm5, [rel PB_CENTERJSAMP] ; xmm5=[rel PB_CENTERJSAMP] packssdw xmm3, xmm1 ; xmm3=data3=(03 13 23 33 43 53 63 73) packssdw xmm2, xmm0 ; xmm2=data4=(04 14 24 34 44 54 64 74) movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) movdqa xmm1, XMMWORD [wk(1)] ; xmm1=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) packsswb xmm6, xmm2 ; xmm6=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74) packsswb xmm3, xmm4 ; xmm3=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75) paddb xmm7, xmm5 paddb xmm1, xmm5 paddb xmm6, xmm5 paddb xmm3, xmm5 movdqa xmm0, xmm7 ; transpose coefficients(phase 1) punpcklbw xmm7, xmm1 ; xmm7=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71) punpckhbw xmm0, xmm1 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77) movdqa xmm2, xmm6 ; transpose coefficients(phase 1) punpcklbw xmm6, xmm3 ; xmm6=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73) punpckhbw xmm2, xmm3 ; xmm2=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75) movdqa xmm4, xmm7 ; transpose coefficients(phase 2) punpcklwd xmm7, xmm6 ; xmm7=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) punpckhwd xmm4, xmm6 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73) movdqa xmm5, xmm2 ; transpose coefficients(phase 2) punpcklwd xmm2, xmm0 ; xmm2=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) punpckhwd xmm5, xmm0 ; xmm5=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77) movdqa xmm1, xmm7 ; transpose coefficients(phase 3) punpckldq xmm7, xmm2 ; xmm7=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) punpckhdq xmm1, xmm2 ; xmm1=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) movdqa xmm3, xmm4 ; transpose coefficients(phase 3) punpckldq xmm4, xmm5 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57) punpckhdq xmm3, xmm5 ; xmm3=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77) pshufd xmm6, xmm7, 0x4E ; xmm6=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) pshufd xmm0, xmm1, 0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) pshufd xmm2, xmm4, 0x4E ; xmm2=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47) pshufd xmm5, xmm3, 0x4E ; xmm5=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67) mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+2*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm7 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm1 mov rdx, JSAMPROW [rdi+4*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+6*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3 mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+3*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm0 mov rdx, JSAMPROW [rdi+5*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+7*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm2 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm5 uncollect_args 4 mov rsp, rbp ; rsp <- aligned rbp pop rsp ; rsp <- original rbp pop rbp ret ; For some reason, the OS X linker does not honor the request to align the ; segment unless we do this. align 32 ",16195,True,4073.4459924431817,median "COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1995 -- All Rights Reserved GEOWORKS CONFIDENTIAL PROJECT: socket MODULE: access point database FILE: accpntApi.asm AUTHOR: Eric Weber, Apr 24, 1995 ROUTINES: Name Description ---- ----------- GLB AccessPointCreateEntry Create an access point GLB AccessPointDestroyEntry Destroy an access point GLB AccessPointDestroyEntryNoNotify GLB AccessPointMultiDestroyDone GLB AccessPointGetType Get the access point type GLB AccessPointSetStringProperty Set a string property on an access point GLB AccessPointSetIntegerProperty Set a integer property on an access point GLB AccessPointGetStringProperty Get a string property on an access point GLB AccessPointGetIntegerProperty Get a integer property on an access point GLB AccessPointDestroyProperty Destroy one property of an access point GLB AccessPointGetEntries Get a chunk array of entry IDs of a given type INT GetEntriesCallback Possibly copy an access point from one array to another GLB AccessPointCompareStandardProperty Compare a string to a standard property name GLB AccessPointCommit Forces changes to disk GLB AccessPointIsEntryValid Test whether an access point exists GLB AccessPointLock Lock an access point to prevent changes GLB AccessPointUnlock Unlock an access point INT AccessPointCheckLock Check if an access point is locked REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/24/95 Initial revision jwu 10/25/96 Added locking access points DESCRIPTION: $Id: accpntApi.asm,v 1.17 97/10/22 13:19:16 brianc Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ Strings segment lmem LMEM_TYPE_GENERAL accpntCategory chunk.char ""accpnt"",0 localize not activeKey chunk.char ""active0"",0 localize not Strings ends ApiCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointCreateEntry %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Create an access point CALLED BY: GLOBAL PASS: bx - ID of entry before which to insert new entry (0 to place at end) ax - AccessPointType RETURN: ax - new ID carry set if old entry not found DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/24/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointCreateEntry proc far uses bx,cx,dx,si,di,bp,ds .enter push bx, ax EnterDatabase bx Assert etype ax, AccessPointType ; ; read the last assigned key value from the database ; segmov ds, cs mov si, offset initCategory mov cx, cs mov dx, offset initIDKey call InitFileReadInteger ; ax=value, carry on err jnc nextValue clr ax ; ; increment the value ; if we reach 65536, wrap around, but skip over zero ; nextValue: inc ax jnz noZ inc ax ; don't use zero noZ: call CheckIfEntryExists ; carry if does not exist jnc nextValue ; ; this is the value we want to use ; valueOK:: pop bx, dx ; position, type call AllocateEntry ; carry on err jc done call GenerateCreationNotice ; ; note that we've used this ID ; mov bp, ax mov dx, offset initIDKey call InitFileWriteInteger ; carry on err EC < ERROR_C UNABLE_TO_ALLOCATE_ENTRY_POINT > ; ; commit the changes ; AccpntCommit clc done: ExitDatabase bx .leave ret AccessPointCreateEntry endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointDestroyEntry %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Destroy an access point CALLED BY: GLOBAL PASS: ax - id of access point to destroy RETURN: carry - set if access point does not exist or is locked DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/25/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointDestroyEntry proc far uses ax,dx .enter call GetTypeLow call AccessPointGetActivePoint call AccessPointDestroyEntryDirect .leave ret AccessPointDestroyEntry endp AccessPointDestroyEntryDirect proc far uses ax,bx,cx,dx,si,ds,es .enter EnterDatabase bx ; ; make sure changes are allowed ; call AccessPointCheckLock jc done ; locked! ; ; remove access point from table of contents ; call FreeEntryFile ; remove from init file jc done call FreeEntryMem ; dx = entry type call BuildEntryCategory ; get category name ; ; remove it's category, and hence all of its properties ; call InitFileDeleteCategory call GenerateDeletionNotice AccpntCommit clc done: ExitDatabase bx .leave ret AccessPointDestroyEntryDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointDestroyEntryNoNotify %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Destroy an access point, but don't send out notifications. CALLED BY: AccessPointSelectorDeleteMulti PASS: ax = id of access point to destroy RETURN: carry set if access point does not exist or is locked dx = entry type DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 1/ 1/97 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointDestroyEntryNoNotify proc far uses ax, bx, cx, si, ds, es .enter EnterDatabase bx ; ; make sure changes are allowed ; call AccessPointCheckLock jc done ; locked! ; ; remove access point from table of contents ; call FreeEntryFile ; remove from init file jc done call FreeEntryMem ; dx = entry type call BuildEntryCategory ; get category name ; ; remove it's category, and hence all of its properties ; call InitFileDeleteCategory AccpntCommit clc done: ExitDatabase bx .leave ret AccessPointDestroyEntryNoNotify endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointMultiDestroyDone %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send batched notification for group of deleted access points. CALLED BY: AccessPointSelectorDeleteMulti PASS: bx = block of IDs dx = entry type RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 1/ 1/97 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointMultiDestroyDone proc far uses ax .enter mov ax, bx call GenerateMultiDeletionNotice .leave ret AccessPointMultiDestroyDone endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointGetType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the access point type CALLED BY: GLOBAL PASS: ax - access point ID RETURN: bx - AccessPointType (0 if not found) carry set if not found DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/ 2/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointGetType proc far uses ax,cx,dx,si,di,bp,ds .enter EnterDatabase bx call GetTypeLow ; dx = AccessPointType ExitDatabase bx mov bx, dx ; ; set carry if bx=0 ; tst bx lahf rcl ah rcl ah .leave ret AccessPointGetType endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointGetActivePoint %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the active point CALLED BY: GLOBAL PASS: ax - access point ID dx - type RETURN: ax - the active accesspoint for the same type carry set if not found DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- mzhu 2/ 2/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointGetActivePoint proc far uses bx,cx,dx,si,di,bp,ds,es .enter add dx, 48 ; '0' = 48 push ax segmov es, ds, bx mov bx, handle Strings call MemLock mov ds, ax mov cx, ax assume ds:Strings mov bp, ds:[activeKey] mov ds:[bp+6], dx mov dx, ds:[activeKey] ; cx:dx = key mov si, ds:[accpntCategory] ; ds:si = category assume ds:nothing pop ax call InitFileReadInteger ; ax = accpnt pushf mov bx, handle Strings call MemUnlock popf .leave ret AccessPointGetActivePoint endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointSetActivePoint %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the active point for the type CALLED BY: GLOBAL PASS: ax - access point dx - type RETURN: carry set if error DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- mzhu 2/ 2/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointSetActivePoint proc far uses ax, bx,cx,dx,si,di,bp,ds,es .enter add dx, 48 ; '0' = 48 push ax segmov es, ds, bx mov bx, handle Strings call MemLock mov ds, ax mov cx, ax assume ds:Strings mov bp, ds:[activeKey] mov ds:[bp+6], dx mov dx, ds:[activeKey] ; cx:dx = key mov si, ds:[accpntCategory] ; ds:si = category assume ds:nothing pop bp call InitFileWriteInteger pushf mov bx, handle Strings call MemUnlock popf .leave ret AccessPointSetActivePoint endp ifdef SCRAMBLED_INI_STRINGS COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% APCheckScrambledProperty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Check if this property is to be scrambled CALLED BY: INTERNAL PASS: cx:dx - pointer to property name if cx = 0, dx = APSP_ RETURN: carry set if scrambled DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 10/30/98 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ APCheckScrambledProperty proc near jcxz checkScrambled notScrambled: clc ; only APSPs supported ret checkScrambled: cmp dx, APSP_SECRET jne notScrambled ; not scrambled stc ; APSP_SECRET, scramble ret APCheckScrambledProperty endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% APScramble, APUnscramble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Scramble and unscramble .ini string CALLED BY: INTERNAL PASS: es:di - ASCIIZ string cx - num chars, 0 for null-terminated RETURN: cx - length if 0 passed in, otherwise unchanged DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 10/30/98 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ APScramble proc near uses ax, ds, si, di .enter tst cx jnz haveLength call LocalStringLength ; cx = length haveLength: jcxz done push cx segmov ds, es, si mov si, di scrambleLoop: LocalGetChar ax, dssi SBCS < xor al, 0xbc > DBCS < xor ax, 0xbcbc > LocalPutChar esdi, ax loop scrambleLoop pop cx done: .leave ret APScramble endp APUnscramble equ APScramble COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% APScrambleAndInitFileWrite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Scramble and write .ini string CALLED BY: INTERNAL PASS: ds:si - category ASCIIZ string cx:dx - key ASCIIZ string es:di - body ASCIIZ string RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 10/30/98 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ APScrambleAndInitFileWrite proc near uses bp .enter ; ; scramble data ; push cx clr cx ; null-terminated call APScramble mov bp, cx ; bp = size for write data DBCS < shl bp, 1 > pop cx ; ; write scrambled string to .ini file ; call InitFileWriteData ; ; unscramble so user buffer is not altered ; push cx clr cx ; null-terminated call APScramble pop cx .leave ret APScrambleAndInitFileWrite endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% APInitFileReadAndUnscramble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Read .ini string and unscramble CALLED BY: INTERNAL PASS: ds:si - category ASCIIZ string cx:dx - key ASCIIZ string bp - size If size = 0 Buffer will be allocated for string Else es:di - buffer to fill RETURN: carry - clear if successful cx - number of chars retrieved (excluding null terminator) cx = 0 if category / key not found bx - mem handle to block containing entry (IFRF_SIZE = 0) - or - es:di - buffer filled (IFRF_SIZE != 0) DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 10/30/98 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ APInitFileReadAndUnscramble proc near ; ; read scrambled string from .ini file ; call InitFileReadData ; ; unscramble ; jc done ; error, return it tst bp ; have buffer? jnz haveBuffer push ax, es, di call MemLock mov es, ax clr di haveBuffer: DBCS < shr cx, 1 ; bytes to chars > call APUnscramble ; pass cx = num chars tst bp jnz done call MemUnlock pop ax, es, di clc ; indicate success done: ret APInitFileReadAndUnscramble endp endif ; SCRAMBLED_INI_STRINGS COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointSetStringProperty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set a string property on an access point CALLED BY: GLOBAL PASS: ax - access point id cx:dx - null terminated property name es:di - null terminated property value RETURN: carry set if access point does not exist or is locked DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/25/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointSetStringProperty proc far uses ax,dx .enter mov bx, dx call GetTypeLow call AccessPointGetActivePoint mov dx, bx call AccessPointSetStringPropertyDirect .leave ret AccessPointSetStringProperty endp AccessPointSetStringPropertyDirect proc far uses bx,cx,dx,ds,si .enter Assert fptrXIP, esdi EnterDatabase bx call ValidateEntry jc done ; ; Only allow change if accpnt not locked or if property is ; automatic. ; test dx, APSP_AUTOMATIC jz checkLock jcxz continue checkLock: call AccessPointCheckLock jc done continue: ; ; Set string property. ; ifdef SCRAMBLED_INI_STRINGS call APCheckScrambledProperty pushf ; save result endif call ParseStandardProperty ; cx:dx=key, bx=APSP call BuildEntryCategory ; ds:si = category ifdef SCRAMBLED_INI_STRINGS popf ; C set if scrambled jnc notScrambled call APScrambleAndInitFileWrite jmp afterWrite notScrambled: call InitFileWriteString afterWrite: else call InitFileWriteString endif AccpntCommit call GenerateChangeNotice clc ; indicate success done: ExitDatabase bx .leave ret AccessPointSetStringPropertyDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointSetIntegerProperty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set a integer property on an access point CALLED BY: GLOBAL PASS: ax - access point id cx:dx - null terminated property name bp - value to store RETURN: carry set if access point does not exist or is locked DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/25/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointSetIntegerProperty proc far uses ax,dx .enter mov bx, dx call GetTypeLow call AccessPointGetActivePoint mov dx, bx call AccessPointSetIntegerPropertyDirect .leave ret AccessPointSetIntegerProperty endp AccessPointSetIntegerPropertyDirect proc far uses bx,cx,dx,ds,si .enter EnterDatabase bx call ValidateEntry jc done ; ; Only allow change if accpnt not locked or if property is ; automatic. ; test dx, APSP_AUTOMATIC jz checkLock jcxz continue checkLock: call AccessPointCheckLock jc done continue: ; ; Set integer property. ; call ParseStandardProperty ; cx:dx = key, ; bx = APSP call BuildEntryCategory ; ds:si = category call InitFileWriteInteger AccpntCommit call GenerateChangeNotice clc ; indicate success done: ExitDatabase bx .leave ret AccessPointSetIntegerPropertyDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointGetStringProperty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get a string property on an access point CALLED BY: GLOBAL PASS: ax - access point id cx:dx - null terminated property name bp - size of buffer (0 to allocate block) es:di - buffer for property value (if bp != 0) RETURN: carry set on error cx - number of chars retrieved (excluding null terminator) cx = 0 if property not found bx - mem handle to block containing entry - or - es:di - buffer filled DESTROYED: bx (if not returned) SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/25/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointGetStringProperty proc far uses ax,dx .enter mov bx, dx call GetTypeLow call AccessPointGetActivePoint mov dx, bx call AccessPointGetStringPropertyDirect .leave ret AccessPointGetStringProperty endp AccessPointGetStringPropertyDirect proc far uses dx,bp,si,ds .enter EnterDatabase bx EC < call ValidateEntry > EC < jc done > ifdef SCRAMBLED_INI_STRINGS call APCheckScrambledProperty pushf ; save result endif call ParseStandardProperty ; cx:dx = key and bp, mask IFRF_SIZE ; get low 12 bits EC < jz ptrOK > EC < Assert fptrXIP, esdi > ptrOK:: call BuildEntryCategory ; ds:si = category ifdef SCRAMBLED_INI_STRINGS popf ; C set if scrambled jnc notScrambled call APInitFileReadAndUnscramble jmp afterRead notScrambled: call InitFileReadString afterRead: else call InitFileReadString endif done:: ExitDatabase .leave ret AccessPointGetStringPropertyDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointGetIntegerProperty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get a integer property on an access point CALLED BY: GLOBAL PASS: ax - access point id cx:dx - null terminated property name RETURN: carry set if error ax - value of property (unchanged if error) DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/25/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointGetIntegerProperty proc far uses bx, dx .enter mov bx, dx call GetTypeLow call AccessPointGetActivePoint mov dx, bx call AccessPointGetIntegerPropertyDirect .leave ret AccessPointGetIntegerProperty endp AccessPointGetIntegerPropertyDirect proc far uses bx,cx,dx,ds,si .enter EnterDatabase bx EC < call ValidateEntry > EC < jc done > call ParseStandardProperty ; cx:dx = key call BuildEntryCategory ; ds:si = category call InitFileReadInteger done:: ExitDatabase bx .leave ret AccessPointGetIntegerPropertyDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointDestroyProperty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Destroy one property of an access point CALLED BY: GLOBAL PASS: ax - access point id cx:dx - null terminated property name RETURN: carry set if error (accpnt locked) DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/25/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointDestroyProperty proc far uses ax,dx .enter mov bx, dx call GetTypeLow call AccessPointGetActivePoint mov dx, bx call AccessPointDestroyPropertyDirect .leave ret AccessPointDestroyProperty endp AccessPointDestroyPropertyDirect proc far uses bx,cx,dx,si,ds .enter EnterDatabase bx EC < call ValidateEntry > EC < jc done > ; ; Only allow change if accpnt not locked or if property is ; automatic. ; test dx, APSP_AUTOMATIC jz checkLock jcxz change checkLock: call AccessPointCheckLock jc done change: ; ; Delete the property. ; call ParseStandardProperty ; cx:dx = key call BuildEntryCategory ; ds:si = category call InitFileDeleteEntry AccpntCommit call GenerateChangeNotice clc ; indicate success done:: ExitDatabase bx .leave ret AccessPointDestroyPropertyDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointGetEntries %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get a chunk array of entry IDs of a given type CALLED BY: GLOBAL PASS: ds - segment in which to return data si - chunk in which to return data (0 to create one) ax - type of entries to list (APT_ALL for all types) RETURN: ds:si - chunk array of entry ID words (ds may have moved) DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 4/25/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointGetEntries proc far uses ax,bx,cx,dx,di,bp,es .enter EnterDatabase bx, SAVE_DS EC < cmp ax, APT_ALL > EC < je aptOK > EC < Assert etype ax, AccessPointType > aptOK:: EC < Assert segment, ds > EC < tst si > EC < jz chunkOK > EC < Assert chunk si,ds > chunkOK:: mov bp, ax ; remember type ; ; create a chunk array in target block ; mov bx, size word ; element size clr cx ; default header size clr al ; no obj flags call ChunkArrayCreate ; si = chunk push si ; save chunk handle mov cx, ds mov dx, si ; *cx:dx = target array ; ; lock down the source block ; mov bx, handle AccessTypeArray call MemLock mov ds, ax mov si, offset AccessTypeArray ; ; copy the chunk array ; mov bx, cs mov di, offset GetEntriesCallback call ChunkArrayEnum ; ; clean up and exit ; mov bx, handle AccessTypeArray call MemUnlock ; release source block ExitDatabase bx mov ds, cx pop si ; *ds:si = target array .leave ret AccessPointGetEntries endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetEntriesCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Possibly copy an access point from one array to another CALLED BY: AccessPointGetEntries (via ChunkArrayEnum) PASS: *ds:si - AccessTypeArray ds:di - current entry in AccessTypeArray *cx:dx - target array bp - desired type RETURN: *cx:dx - target array (possibly moved) carry clear DESTROYED: ax, bx, si, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/ 2/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetEntriesCallback proc far uses ds .enter ; ; if type matches, copy it ; cmp bp, ds:[di] je typeOK ; ; if bp is APT_ALL, copy it ; cmp bp, APT_ALL jne done ; ; switch to AccessPointArray and read ID from same offset ; we are at in AccessTypeArray ; typeOK: sub di, ds:[si] mov si, offset AccessPointArray add di, ds:[si] mov ax, ds:[di] ; ; store it in target array ; mov ds, cx mov si, dx call ChunkArrayAppend ; ds:di = new slot mov ds:[di], ax mov cx, ds ; save new segment value done: clc .leave ret GetEntriesCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointCompareStandardProperty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compare a string to a standard property name CALLED BY: GLOBAL PASS: es:di - null terminated string to match dx - AccessPointStandardProperty RETURN: zero flag - set if equal DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/17/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointCompareStandardProperty proc far uses bx,cx,dx,si,di,ds .enter EnterDatabase bx Assert fptrXIP, esdi ; ; get the standard property name ; clr cx call ParseStandardProperty ; cx:dx = property movdw dssi, cxdx ; ; compare it to the passed value ; clr cx ; null terminated call LocalCmpStringsNoCase ; z flag if equal ExitDatabase bx .leave ret AccessPointCompareStandardProperty endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointCommit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Force changes to disk CALLED BY: GLOBAL PASS: nothing RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/23/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointCommit proc far call InitFileCommit ret AccessPointCommit endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointIsEntryValid %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Test whether an access point exists CALLED BY: GLOBAL PASS: ax - access point ID RETURN: carry set if invalid DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 11/21/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointIsEntryValid proc far uses ax,dx .enter call GetTypeLow call AccessPointGetActivePoint call AccessPointIsEntryValidDirect .leave ret AccessPointIsEntryValid endp AccessPointIsEntryValidDirect proc far uses bx, ds .enter EnterDatabase bx call ValidateEntry ExitDatabase .leave ret AccessPointIsEntryValidDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointLock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock an access point. Once an access point is locked, only the automatic settings for it may be modified. CALLED BY: GLOBAL PASS: ax = access point ID RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Writes lock entry to ini for this accpnt. REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 10/25/96 Initial version jwu 01/18/97 lock stored in memory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointLock proc far uses ax,dx .enter call GetTypeLow call AccessPointGetActivePoint call AccessPointLockDirect .leave ret AccessPointLock endp AccessPointLockDirect proc far uses bx, cx, dx, di, si, ds, es .enter ; ; If access point is already locked, don't lock it again. ; EnterDatabase bx EC < call ValidateEntry > EC < jc exit > mov_tr cx, ax ; cx = accpnt id mov bx, handle AccessPointLockArray call MemLock mov ds, ax mov es, ax mov si, offset AccessPointLockArray ; *ds:si = array mov di, ds:[si] mov ax, es:[di].CAH_count add di, es:[di].CAH_offset xchg cx, ax ; ax = id, cx = count repne scasw je done ; already locked ; ; Add new lock to array and send a notification for it ; call ChunkArrayAppend mov ds:[di], ax mov dx, APT_INTERNET call GenerateLockNotice done: call MemUnlock exit: ExitDatabase bx .leave ret AccessPointLockDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointUnlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Unlock an access point. CALLED BY: GLOBAL PASS: ax = access point ID RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Removes lock entry for this accpnt. REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 10/25/96 Initial version jwu 01/18/97 lock stored in memory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointUnlock proc far uses ax,dx .enter call GetTypeLow call AccessPointGetActivePoint call AccessPointUnlockDirect .leave ret AccessPointUnlock endp AccessPointUnlockDirect proc far uses bx, cx, dx, di, si, ds, es .enter ; ; Find access point in lock array. ; EnterDatabase bx EC < call ValidateEntry > EC < jc exit > mov_tr cx, ax ; cx = accpnt id mov bx, handle AccessPointLockArray call MemLock mov ds, ax mov es, ax mov si, offset AccessPointLockArray ; *ds:si = array mov di, ds:[si] mov ax, es:[di].CAH_count add di, es:[di].CAH_offset xchg cx, ax ; ax = id, cx = count repne scasw jne done ; ; Delete entry from lock array and send a notification for it ; dec di dec di call ChunkArrayDelete mov dx, APT_INTERNET call GenerateLockNotice done: call MemUnlock exit: ExitDatabase bx .leave ret AccessPointUnlockDirect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointCheckLock/AccessPointInUse %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Check if an access point is locked. If an access point is locked, only the automatic settings may be modified. Applications use AccessPointInUse which hides the concept of locked access points. CALLED BY: EXTERNAL (AccessPointInUse) INTERNAL (AccessPointCheckLock) AccessPointDestroyEntry AccessPointSetStringProperty AccessPointSetIntegerProperty AccessPointDestroyProperty PASS: ax = access point ID RETURN: carry set if locked or in use DESTROYED: nothing PSEUDO CODE/STRATEGY: NOTE: Do not call EnterDatabase here. Caller already got exclusive access and calling it here will cause deadlock. REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 10/25/96 Initial version jwu 01/18/97 locks stored in memory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointInUse proc far uses ax,dx .enter call GetTypeLow call AccessPointGetActivePoint call AccessPointInUseDirect .leave ret AccessPointInUse endp AccessPointInUseDirect proc far uses bx .enter EnterDatabase bx, SAVE_DS EC < call ValidateEntry > EC < jc exit > call AccessPointCheckLock exit: ExitDatabase bx, SAVE_DS .leave ret AccessPointInUseDirect endp AccessPointCheckLock proc near uses bx, cx, di, si, es .enter ; ; Check if access point is in lock array. ; mov_tr cx, ax mov bx, handle AccessPointLockArray call MemLock mov es, ax mov di, offset AccessPointLockArray mov di, es:[di] mov ax, es:[di].CAH_count add di, es:[di].CAH_offset xchg cx, ax ; ax = id, cx = count repne scasw call MemUnlock clc ; assume not locked jne exit stc ; it's locked exit: .leave ret AccessPointCheckLock endp dialingAreaCodeKey char ""areaCode"",0 dialingCallWaitingKey char ""callWaiting"",0 dialingOutsideLineKey char ""outsideLine"",0 dialingDialMethodKey char ""dialMethod"",0 dialTenDigitKey char ""tenDigit"",0 dialtoneKey char ""dialtone"",0 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointGetDialingOptions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Returns dialing options from INI file. If a key is not present in the INI file, NULL or a default value will be used. CALLED BY: EXTERNAL/GLOBAL PASS: cx:dx = fptr to AccessPointDialingOptions structure to be filled RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 9/03/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointGetDialingOptions proc far uses ax,bx,cx,dx,si,di,bp,ds,es .enter ; Use es:[di] to point to current member of structure. ; di will be moved from element to element at each step. ; mov es, cx mov di, dx add di, offset APDO_areaCode ; Set up ds:si to point to category key. Should stay the whole ; routine. ; segmov ds, cs, cx mov si, offset initCategory ; Read the area code key. ; mov dx, offset dialingAreaCodeKey mov {byte}es:[di], 0 ; default value mov bp, (size APDO_areaCode) and mask IFRF_SIZE call InitFileReadString jc checkCallWaiting ; unsuccessful cmp cx, APDO_AREA_CODE_LEN ; must be 3 digits! je checkCallWaiting mov {TCHAR}es:[di], 0 ; if not, null it! checkCallWaiting: ; Read the call waiting key. ; add di, offset APDO_callWaiting - offset APDO_areaCode mov cx, cs mov dx, offset dialingCallWaitingKey mov bp, (size APDO_callWaiting) and mask IFRF_SIZE mov {TCHAR}es:[di], 0 ; default value call InitFileReadString ; Read the outside line key. ; add di, offset APDO_outsideLine - offset APDO_callWaiting mov cx, cs mov dx, offset dialingOutsideLineKey mov bp, (size APDO_outsideLine) and mask IFRF_SIZE mov {TCHAR}es:[di], 0 ; default value call InitFileReadString ; Read the dialing method key. Here we read the string key ; onto the stack since the value in the struct is only a one ; byte enumeration. Happily, the value of the enum is either ; 'T' or 'P', the value stored in the ini file. ; pushdw esdi sub sp, 2*(size TCHAR) mov di, sp segmov es, ss, cx mov cx, cs mov dx, offset dialingDialMethodKey mov bp, 2 mov al, APDM_TONE ; default value call InitFileReadString jc useDefaultMethod ; not in INI file mov ah, es:[di] cmp ah, APDM_PULSE je gotMethod cmp ah, APDM_TONE jne useDefaultMethod ; if not valid, use al gotMethod: mov al, ah useDefaultMethod: add sp, 2*(size TCHAR) popdw esdi add di, offset APDO_dialMethod - offset APDO_outsideLine mov es:[di], al ; Read boolean ten digit key. ; add di, offset APDO_tenDigit - offset APDO_dialMethod mov cx, cs mov dx, offset dialTenDigitKey mov {byte}es:[di], FALSE ; default value call InitFileReadBoolean jc gotTenDigit ; no value, use def. mov es:[di], al gotTenDigit: ; Read boolean dialtone key. ; add di, offset APDO_waitForDialtone - offset APDO_tenDigit mov cx, cs mov dx, offset dialtoneKey mov {byte}es:[di], TRUE ; default value call InitFileReadBoolean jc gotDialtone ; no value, use def. mov es:[di], al gotDialtone: ; Whew! .leave ret AccessPointGetDialingOptions endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointSetDialingOptions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets dialing options in INI file. CALLED BY: EXTERNAL/GLOBAL PASS: cx:dx = fptr to AccessPointDialingOptions structure to be written to INI file. All string values must be null terminated. RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 9/03/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AccessPointSetDialingOptions proc far uses ax,bx,cx,dx,si,di,bp,ds,es .enter ; Use es:[di] to point to current member of structure. ; di will be moved from element to element at each step. ; mov es, cx mov di, dx add di, offset APDO_areaCode ; Set up ds:si to point to category key. Should stay the whole ; routine. ; segmov ds, cs, cx mov si, offset initCategory ; Write the area code key. ; mov dx, offset dialingAreaCodeKey call InitFileWriteString ; Write the call waiting key. ; add di, offset APDO_callWaiting - offset APDO_areaCode mov cx, cs mov dx, offset dialingCallWaitingKey call InitFileWriteString ; Write the outside line key. ; add di, offset APDO_outsideLine - offset APDO_callWaiting mov cx, cs mov dx, offset dialingOutsideLineKey call InitFileWriteString ; Write the dialing method key. We just write out a string to ; the file whose value is the enumeration value. Those values should ; be printable ascii characters. To do this, we need to make a string ; on the stack so that we have a zero byte. ; add di, offset APDO_dialMethod - offset APDO_outsideLine sub sp, 2*(size TCHAR) mov bp, sp mov cl, es:[di] mov ss:[bp], cl mov {byte}ss:[bp+1], 0 DBCS < mov {word}ss:[bp+2], 0 > pushdw esdi mov di, bp segmov es, ss, cx mov cx, cs mov dx, offset dialingDialMethodKey call InitFileWriteString popdw esdi add sp, 2*(size TCHAR) ; Write ten digit boolean key. ; add di, offset APDO_tenDigit - offset APDO_dialMethod clr ax mov al, es:[di] ; ax != 0 ==> TRUE mov cx, cs mov dx, offset dialTenDigitKey call InitFileWriteBoolean ; Write dialtone boolean key. ; add di, offset APDO_waitForDialtone - offset APDO_tenDigit clr ax mov al, es:[di] ; ax != 0 ==> TRUE mov cx, cs mov dx, offset dialtoneKey call InitFileWriteBoolean ; Write these suckers to the disk. ; call InitFileCommit .leave ret AccessPointSetDialingOptions endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AccessPointGetPhoneStringWithOptions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the phone string (stored in APSP_PHONE) with dialing options applied for the currently set access point. Options will only be applied if (1) they are set (may be in INI file) and (2) if APSP_USE_DIALING_OPTIONS is set non-zero for access point. If APSP_USE_DIALING_OPTIONS is not present, the routine will behave normally but no options will be applied (i.e., output will be equal to APSP_PHONE string). CALLED BY: EXTERNAL/GLOBAL PASS: ax = access point id bx = handle to block to receive string or 0 to have block allocated. RETURN: carry: set if APSP_PHONE is defined clear if no PHONE is specified for access point. cx = length of phone string (excluding zero-byte) DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: Oh, string parsing and concatenation in ASM is SO MUCH FUN! This was much shorter in C, really. REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 9/03/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PREAMBLE_LEN equ 32 AccessPointGetPhoneStringWithOptions proc far uses ax,dx,si,di,ds,es accPntID local word push ax returnHan local hptr push bx origCX local word push cx phonePropHan local hptr preamble local PREAMBLE_LEN dup (TCHAR) areaCode local 3 dup (TCHAR) DBCS < areaCodeLen local byte > prefix local 3 dup (TCHAR) extension local 4 dup (TCHAR) dialOptions local AccessPointDialingOptions localDialOptions local AccessPointLocalDialingOptions .enter ; Get the phone number from the access point. (AX was passed in ; to be the access point ID.) ; push bp ; save locals clr cx, bp mov dx, APSP_PHONE call AccessPointGetStringProperty ; bx = block, cx = len pop bp ; restore locals cmc ; carry set = failure LONG jnc done ; no phone, E.T., clc mov ss:[phonePropHan], bx tst ss:[returnHan] jnz returnBlockAlloc mov ax, 112*(size TCHAR) ; big enuf! mov cx, ALLOC_DYNAMIC call MemAlloc LONG jc errorFreePropHan mov ss:[returnHan], bx returnBlockAlloc: mov bx, ss:[phonePropHan] call MemLock LONG jc errorFreePropHan ; may leak memory mov ds, ax clr si mov bx, ss:[returnHan] call MemLock LONG jc errorUnlockPropHan ; may leak memory mov es, ax clr di ; ds:si = original phone number ; es:di = return phone number ; ; At this point, check is APSP_USE_DIALING_OPTIONS is present for ; this access point. ; mov ax, ss:[accPntID] ; can trash ax,cx,dx clr cx mov dx, APSP_USE_DIALING_OPTIONS call AccessPointGetIntegerProperty jc skipOptions tst ax jnz useOptions skipOptions: ; OK.. we are bailing but we need to copy the phone number to the ; output string an proceed like a normal call. To do that, we simply ; need to advance ds:si to the end of the source string and pretend ; we have ""garbage"". ; LocalGetChar ax, dssi ; rep scasb uses es:di. LocalIsNull ax ; use lodsb loop instead jnz skipOptions jmp stuffIt useOptions: ; bl = numDigits ; bh = garbageInString ; cl = firstDigitIs1 ; ch = preambleLen clr bx, cx ; First time through, figure out how many actual digits we have ; and some things about it. Store a preamble, valid dial chars ; before the first digits, just in case. loop1: LocalGetChar ax, dssi LocalIsNull ax jz doneLoop1 inc bh ; assume garbage, but digit LocalCmpChar ax, '#' ; (which means # or *) je haveDigit1 LocalCmpChar ax, '*' je haveDigit1 dec bh ; unassume garbage LocalCmpChar ax, '0' jb noDigit1 LocalCmpChar ax, '9' ja noDigit1 haveDigit1: tst bl ; numDigits == 0 jnz alreadyHaveOneDigit1 LocalCmpChar ax, '1' ; first digit == 1 jne alreadyHaveOneDigit1 inc cl ; first digit is a 1.. note it alreadyHaveOneDigit1: inc bl ; inc count of digits jmp loop1 noDigit1: LocalCmpChar ax, '-' ; check for useless (,),- chars je loop1 ; they aren't garbage, fluff LocalCmpChar ax, '(' je loop1 LocalCmpChar ax, ')' je loop1 tst bl ; numDigits ==0 ? jnz garbageLoop1 ; nope - no preamble, garbage cmp ch, PREAMBLE_LEN ; preambleLen < PREAMBLE_LEN jae garbageLoop1 ; nope - garbage push bx ; stuff in preamble lea bx, ss:[preamble] add bl, ch DBCS < adc bh, 0 > DBCS < add bl, ch ; size TCHAR > adc bh, 0 LocalPutChar ssbx, ax, noAdvance pop bx inc ch ; preambleLen++ jmp loop1 ; no garbage garbageLoop1: inc bh ; yup, garbage jmp loop1 doneLoop1: ; Get the dialing options (in local variable).. we need to, no matter ; what, stuff the 'T' or 'P' in the output string. (We may bail below ; by stuffing the input string to the output string; however, we still ; would like the T or P present.) ; push cx mov cx, ss lea dx, ss:[dialOptions] ; dx unused so far call AccessPointGetDialingOptions pop cx ; Also get the local dialing options for this access point. ; push ax, cx, dx clr ss:[localDialOptions] ; by default, options are off mov ax, ss:[accPntID] ; can trash ax,cx,dx clr cx mov dx, APSP_LOCAL_DIALING_OPTIONS call AccessPointGetIntegerProperty jc skipLocalOptions mov ss:[localDialOptions], ax skipLocalOptions: pop ax, cx, dx ; Write dial method ('T' or 'P') out first. ; mov al, ss:[dialOptions].APDO_dialMethod DBCS < clr ah > LocalPutChar esdi, ax ; At this point, we can figure out if we are going to just stuff the ; string out as it came in because we have garbage or unparse-able ; stuff. tst bh ; garbageInString jnz stuffIt tst cl ; first digit is 1 ? jnz stuffItFDI1 cmp bl, 7 ; first dig not 1.. 7 or 10 digs je pressOn ; get to pass GO. cmp bl, 10 je pressOn stuffIt: mov cx, si ; cx=si = num chars in string clr si ; since ds:0 is byte 0 LocalCopyNString ; includes null terminator> jmp doneSuccess stuffItFDI1: cmp bl, 11 ; first dig is 1.. do we have jne stuffIt ; 11 digits? If not, garbage! pressOn: ; ds:si = original phone number ; es:di = return phone number ; bl = numDigits ; bh = numDigits2 (for second loop) (was garbage counter.. must be 0) ; cl = firstDigitIs1 ; ch = preambleLen ; ah = areaCodeLen ; dl = prefixLen ; dh = extLen EC < tst bh > EC < ERROR_NZ -1 > clr dx, si SBCS < clr ah > DBCS < clr ss:[areaCodeLen] > ; This time through, we parse out area code, prefix, and extension. ; Oh, this is fun in ASM! loop2: LocalGetChar ax, dssi LocalIsNull ax jz doneLoop2 LocalCmpChar ax, '0' ; isdigit? jb loop2 LocalCmpChar ax, '9' ja loop2 tst bh ; first digit this loop? jnz notFirst2 tst cl ; first digit should be 1? jz notFirst2 EC < LocalCmpChar ax, '1' > EC < ERROR_NE -1 > clr cl ; clear firstDigit and ; don't count this digit jmp loop2 notFirst2: cmp bl, 10 ; do we have 10 digits? jb tryPrefix2 SBCS < cmp ah, 2 ; are seeing the first 3 still?> DBCS < cmp ss:[areaCodeLen], 2 ; are seeing the first 3 still?> ja tryPrefix2 push bx ; yes.. write area code. lea bx, ss:[areaCode] SBCS < add bl, ah > DBCS < add bl, ss:[areaCodeLen] > DBCS < adc bh, 0 > DBCS < add bl, ss:[areaCodeLen] ; TCHAR size > adc bh, 0 LocalPutChar ssbx, ax, noAdvance pop bx SBCS < inc ah ; ++areaCodeLen > DBCS < inc ss:[areaCodeLen] ; ++areaCodeLen > incloop2: inc bh ; ++numDigits2 jmp loop2 tryPrefix2: cmp dl, 2 ; do we have 3 prefix yet? ja tryExt2 push bx ; no.. write in prefix. lea bx, ss:[prefix] add bl, dl DBCS < adc bh, 0 > DBCS < add bl, dl ; TCHAR size > adc bh, 0 LocalPutChar ssbx, ax, noAdvance pop bx inc dl ; ++prefixLen jmp incloop2 tryExt2: cmp dh, 3 ; have we filled ext yet? EC < ERROR_A -1 ; BAD BAD > NEC < ja doneLoop2 ; don't count anymore! > push bx ; no.. write in extension. lea bx, ss:[extension] add bl, dh DBCS < adc bh, 0 > DBCS < add bl, dh ; TCHAR size > adc bh, 0 LocalPutChar ssbx, ax, noAdvance pop bx inc dh ; ++extensionLen jmp incloop2 doneLoop2: if ERROR_CHECK cmp di, 1*(size TCHAR) ; di should be 1 ('T' or 'P') ERROR_NZ -1 cmp dl, 3 ; prefixLen == 3 ERROR_NE -1 cmp dh, 4 ; && extensionLen == 4 ERROR_NE -1 cmp bh, 7 ; numDigits2 == 7 je ecOK ; cool cmp bh, 10 ; numDigits == 10 ERROR_NE -1 ; MUST BE! SBCS < cmp ah, 3 ; areaCodeLen == 3 > DBCS < cmp ss:[areaCodeLen], 3 ; areaCodeLen == 3 > ERROR_NE -1 ecOK: endif ; Let's build the return value now! ; ; es:di = return phone number ; bl = ; bh = numDigits2 (for second loop) (was garbage counter.. must be 0) ; cl = ; ch = preambleLen ; ah = areaCodeLen ; dl = prefixLen ; ; All our source data comes from the stack now, daddy-o. ; segmov ds, ss ; Copy out the preamble, if any. ; tst ch ; preamble? jz noPreamble lea si, ss:[preamble] push ax clr cl xchg ch, cl LocalCopyNString pop ax ; cx = ; Check the outside line action. ; noPreamble: tst ss:[dialOptions].APDO_outsideLine jz noOutsideLine lea si, ss:[dialOptions].APDO_outsideLine clr bl ; pause counter olCopy: LocalGetChar ax, dssi ; 0-terminated LocalIsNull ax jz olCopyDone LocalPutChar esdi, ax LocalCmpChar ax, ',' jne olCopy inc bl jmp olCopy olCopyDone: ; Append pause ',' if none already. LocalLoadChar ax, ',' tst bl jnz noOutsideLine LocalPutChar esdi, ax ; Check the call waiting action. ; noOutsideLine: tst ss:[dialOptions].APDO_callWaiting jz noCallWaiting lea si, ss:[dialOptions].APDO_callWaiting clr bl ; pause counter cwCopy: LocalGetChar ax, dssi ; 0-terminated LocalIsNull ax jz cwCopyDone LocalPutChar esdi, ax LocalCmpChar ax, ',' jne cwCopy inc bl jmp cwCopy cwCopyDone: ; Append pause ',' if none already. LocalLoadChar ax, ',' tst bl jnz noCallWaiting LocalPutChar esdi, ax ; Do we stick out an area code? ; cx = offset to which area code to use noCallWaiting: clr cx ; no area code at first test ss:[localDialOptions], mask APLDO_ALWAYS_ADD_AREA_CODE jnz forced tst ss:[dialOptions].APDO_tenDigit jz notForced forced: cmp bh, 10 ; numDigits2 jne forcedNot10 useSupplied: lea cx, ss:[areaCode] jmp haveArea forcedNot10: ; Need 10 digits, don't have 10.. use default area code tst ss:[dialOptions].APDO_areaCode jz noAreaCode ; no default.. oh well lea cx, ss:[dialOptions].APDO_areaCode jmp haveArea notForced: ; Not forced to. Do we have 10 digits? If not, no need for ; an area code. cmp bh, 10 ; numDigits2 jne noAreaCode ; nope! done. tst ss:[dialOptions].APDO_areaCode ; no default to cmp? jz useSupplied ; use one supplied ; We have 10 digits and we have a default area code. We need ; to compare them to see if we have to dial it. push es,ds,si,di,cx segmov ds, ss, si mov es, si lea si, ss:[dialOptions].APDO_areaCode lea di, ss:[areaCode] mov cx, 3 SBCS < repe cmpsb > DBCS < repe cmpsw > pop es,ds,si,di,cx je noAreaCode ; EQUAL.. no area code needed jmp useSupplied ; otherwise, use supplied code haveArea: ; Area code required.. Write out a ""1--"" ; If APLDO_OMIT_ONE_FOR_LONG_DISTANCE, skip the ""1-"". test ss:[localDialOptions], mask APLDO_OMIT_ONE_FOR_LONG_DISTANCE jnz skipOne LocalLoadChar ax, '1' LocalPutChar esdi, ax LocalLoadChar ax, '-' LocalPutChar esdi, ax skipOne: mov si, cx ; copy 3 byte area code. mov cx, 3 LocalCopyNString LocalLoadChar ax, '-' LocalPutChar esdi, ax noAreaCode: ; Finally, the rest of the damn thing. lea si, ss:[prefix] mov cx, 3 LocalCopyNString LocalLoadChar ax, '-' LocalPutChar esdi, ax lea si, ss:[extension] mov cx, 4 LocalCopyNString LocalClrChar ax LocalPutChar esdi, ax ; 0 terminate it doneSuccess: SBCS < stc ; success > mov cx, di ; return length in cx DBCS < shr cx, 1 ; size to length > dec cx ; don't count zero byte DBCS < stc ; success > mov bx, ss:[returnHan] call MemUnlock ; flags preserved unlockPropHan: mov bx, ss:[phonePropHan] call MemUnlock ; flags preserved freePropHan: mov bx, ss:[phonePropHan] ; may jump here pushf call MemFree popf ; Return the return handle in BX. If there was a failure, this should ; still be 0 if the handle was to be allocated. ; mov bx, ss:[returnHan] done: ; If unsuccessful, restore CX to passed CX. jc reallyDone mov cx, ss:[origCX] reallyDone: .leave ret errorUnlockPropHan: clc jmp unlockPropHan errorFreePropHan: clc jmp freePropHan AccessPointGetPhoneStringWithOptions endp ApiCode ends ",16284,True,3132.482366683781,median ";; ;; Copyright (c) 2012-2018, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; ;; code to compute octal MD5 using SSE ;; Stack must be aligned to 16 bytes before call ;; Windows clobbers: rax rbx rdx rsi rdi r8 r9 r10 r11 r12 r13 r14 r15 ;; Windows preserves: rcx rbp ;; ;; Linux clobbers: rax rbx rcx rdx rsi r8 r9 r10 r11 r12 r13 r14 r15 ;; Linux preserves: rdi rbp ;; ;; clobbers xmm0-15 %include ""include/os.asm"" %include ""mb_mgr_datastruct.asm"" section .data align=64 default rel align 64 MKGLOBAL(MD5_TABLE,data,internal) MD5_TABLE: dd 0xd76aa478, 0xd76aa478, 0xd76aa478, 0xd76aa478 dd 0xe8c7b756, 0xe8c7b756, 0xe8c7b756, 0xe8c7b756 dd 0x242070db, 0x242070db, 0x242070db, 0x242070db dd 0xc1bdceee, 0xc1bdceee, 0xc1bdceee, 0xc1bdceee dd 0xf57c0faf, 0xf57c0faf, 0xf57c0faf, 0xf57c0faf dd 0x4787c62a, 0x4787c62a, 0x4787c62a, 0x4787c62a dd 0xa8304613, 0xa8304613, 0xa8304613, 0xa8304613 dd 0xfd469501, 0xfd469501, 0xfd469501, 0xfd469501 dd 0x698098d8, 0x698098d8, 0x698098d8, 0x698098d8 dd 0x8b44f7af, 0x8b44f7af, 0x8b44f7af, 0x8b44f7af dd 0xffff5bb1, 0xffff5bb1, 0xffff5bb1, 0xffff5bb1 dd 0x895cd7be, 0x895cd7be, 0x895cd7be, 0x895cd7be dd 0x6b901122, 0x6b901122, 0x6b901122, 0x6b901122 dd 0xfd987193, 0xfd987193, 0xfd987193, 0xfd987193 dd 0xa679438e, 0xa679438e, 0xa679438e, 0xa679438e dd 0x49b40821, 0x49b40821, 0x49b40821, 0x49b40821 dd 0xf61e2562, 0xf61e2562, 0xf61e2562, 0xf61e2562 dd 0xc040b340, 0xc040b340, 0xc040b340, 0xc040b340 dd 0x265e5a51, 0x265e5a51, 0x265e5a51, 0x265e5a51 dd 0xe9b6c7aa, 0xe9b6c7aa, 0xe9b6c7aa, 0xe9b6c7aa dd 0xd62f105d, 0xd62f105d, 0xd62f105d, 0xd62f105d dd 0x02441453, 0x02441453, 0x02441453, 0x02441453 dd 0xd8a1e681, 0xd8a1e681, 0xd8a1e681, 0xd8a1e681 dd 0xe7d3fbc8, 0xe7d3fbc8, 0xe7d3fbc8, 0xe7d3fbc8 dd 0x21e1cde6, 0x21e1cde6, 0x21e1cde6, 0x21e1cde6 dd 0xc33707d6, 0xc33707d6, 0xc33707d6, 0xc33707d6 dd 0xf4d50d87, 0xf4d50d87, 0xf4d50d87, 0xf4d50d87 dd 0x455a14ed, 0x455a14ed, 0x455a14ed, 0x455a14ed dd 0xa9e3e905, 0xa9e3e905, 0xa9e3e905, 0xa9e3e905 dd 0xfcefa3f8, 0xfcefa3f8, 0xfcefa3f8, 0xfcefa3f8 dd 0x676f02d9, 0x676f02d9, 0x676f02d9, 0x676f02d9 dd 0x8d2a4c8a, 0x8d2a4c8a, 0x8d2a4c8a, 0x8d2a4c8a dd 0xfffa3942, 0xfffa3942, 0xfffa3942, 0xfffa3942 dd 0x8771f681, 0x8771f681, 0x8771f681, 0x8771f681 dd 0x6d9d6122, 0x6d9d6122, 0x6d9d6122, 0x6d9d6122 dd 0xfde5380c, 0xfde5380c, 0xfde5380c, 0xfde5380c dd 0xa4beea44, 0xa4beea44, 0xa4beea44, 0xa4beea44 dd 0x4bdecfa9, 0x4bdecfa9, 0x4bdecfa9, 0x4bdecfa9 dd 0xf6bb4b60, 0xf6bb4b60, 0xf6bb4b60, 0xf6bb4b60 dd 0xbebfbc70, 0xbebfbc70, 0xbebfbc70, 0xbebfbc70 dd 0x289b7ec6, 0x289b7ec6, 0x289b7ec6, 0x289b7ec6 dd 0xeaa127fa, 0xeaa127fa, 0xeaa127fa, 0xeaa127fa dd 0xd4ef3085, 0xd4ef3085, 0xd4ef3085, 0xd4ef3085 dd 0x04881d05, 0x04881d05, 0x04881d05, 0x04881d05 dd 0xd9d4d039, 0xd9d4d039, 0xd9d4d039, 0xd9d4d039 dd 0xe6db99e5, 0xe6db99e5, 0xe6db99e5, 0xe6db99e5 dd 0x1fa27cf8, 0x1fa27cf8, 0x1fa27cf8, 0x1fa27cf8 dd 0xc4ac5665, 0xc4ac5665, 0xc4ac5665, 0xc4ac5665 dd 0xf4292244, 0xf4292244, 0xf4292244, 0xf4292244 dd 0x432aff97, 0x432aff97, 0x432aff97, 0x432aff97 dd 0xab9423a7, 0xab9423a7, 0xab9423a7, 0xab9423a7 dd 0xfc93a039, 0xfc93a039, 0xfc93a039, 0xfc93a039 dd 0x655b59c3, 0x655b59c3, 0x655b59c3, 0x655b59c3 dd 0x8f0ccc92, 0x8f0ccc92, 0x8f0ccc92, 0x8f0ccc92 dd 0xffeff47d, 0xffeff47d, 0xffeff47d, 0xffeff47d dd 0x85845dd1, 0x85845dd1, 0x85845dd1, 0x85845dd1 dd 0x6fa87e4f, 0x6fa87e4f, 0x6fa87e4f, 0x6fa87e4f dd 0xfe2ce6e0, 0xfe2ce6e0, 0xfe2ce6e0, 0xfe2ce6e0 dd 0xa3014314, 0xa3014314, 0xa3014314, 0xa3014314 dd 0x4e0811a1, 0x4e0811a1, 0x4e0811a1, 0x4e0811a1 dd 0xf7537e82, 0xf7537e82, 0xf7537e82, 0xf7537e82 dd 0xbd3af235, 0xbd3af235, 0xbd3af235, 0xbd3af235 dd 0x2ad7d2bb, 0x2ad7d2bb, 0x2ad7d2bb, 0x2ad7d2bb dd 0xeb86d391, 0xeb86d391, 0xeb86d391, 0xeb86d391 ONES: dd 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff section .text %ifdef LINUX ;; Linux Registers %define arg1 rdi %define arg2 rsi %define mem1 rcx %define mem2 rdx %else %define arg1 rcx %define arg2 rdx %define mem1 rdi %define mem2 rsi %endif ;; rbp is not clobbered %define inp0 r8 %define inp1 r9 %define inp2 r10 %define inp3 r11 %define inp4 r12 %define inp5 r13 %define inp6 r14 %define inp7 r15 %define TBL rax %define IDX rbx %define A xmm0 %define B xmm1 %define C xmm2 %define D xmm3 %define E xmm4 ; tmp %define F xmm5 ; tmp %define A2 xmm6 %define B2 xmm7 %define C2 xmm8 %define D2 xmm9 %define FUN E %define TMP F %define FUN2 xmm10 %define TMP2 xmm11 %define T0 xmm10 %define T1 xmm11 %define T2 xmm12 %define T3 xmm13 %define T4 xmm14 %define T5 xmm15 ; Stack Layout ; ; 470 DD2 ; 460 CC2 ; 450 BB2 ; 440 AA2 ; 430 DD ; 420 CC ; 410 BB ; 400 AA ; ; 3F0 data2[15] for lanes 7...4 \\ ; ... \\ ; 300 data2[0] for lanes 7...4 \\ ; 2F0 data2[15] for lanes 3...0 > mem block 2 ; ... / ; 210 data2[1] for lanes 3...0 / ; 200 data2[0] for lanes 3...0 / ; ; 1F0 data1[15] for lanes 7...4 \\ ; ... \\ ; 100 data1[0] for lanes 7...4 \\ ; F0 data1[15] for lanes 3...0 > mem block 1 ; ... / ; 10 data1[1] for lanes 3...0 / ; 0 data1[0] for lanes 3...0 / ; stack size must be an odd multiple of 8 bytes in size struc STACK _DATA: reso 2*2*16 ; 2 blocks * 2 sets of lanes * 16 regs _DIGEST: reso 8 ; stores AA-DD, AA2-DD2 resb 8 ; for alignment endstruc %define STACK_SIZE STACK_size %define AA rsp + _DIGEST + 16*0 %define BB rsp + _DIGEST + 16*1 %define CC rsp + _DIGEST + 16*2 %define DD rsp + _DIGEST + 16*3 %define AA2 rsp + _DIGEST + 16*4 %define BB2 rsp + _DIGEST + 16*5 %define CC2 rsp + _DIGEST + 16*6 %define DD2 rsp + _DIGEST + 16*7 ;; ;; MD5 left rotations (number of bits) ;; rot11 equ 7 rot12 equ 12 rot13 equ 17 rot14 equ 22 rot21 equ 5 rot22 equ 9 rot23 equ 14 rot24 equ 20 rot31 equ 4 rot32 equ 11 rot33 equ 16 rot34 equ 23 rot41 equ 6 rot42 equ 10 rot43 equ 15 rot44 equ 21 ; transpose r0, r1, r2, r3, t0, t1 ; ""transpose"" data in {r0..r3} using temps {t0..t3} ; Input looks like: {r0 r1 r2 r3} ; r0 = {a3 a2 a1 a0} ; r1 = {b3 b2 b1 b0} ; r2 = {c3 c2 c1 c0} ; r3 = {d3 d2 d1 d0} ; ; output looks like: {t0 r1 r0 r3} ; t0 = {d0 c0 b0 a0} ; r1 = {d1 c1 b1 a1} ; r0 = {d2 c2 b2 a2} ; r3 = {d3 c3 b3 a3} ; %macro TRANSPOSE 6 %define %%r0 %1 %define %%r1 %2 %define %%r2 %3 %define %%r3 %4 %define %%t0 %5 %define %%t1 %6 movdqa %%t0, %%r0 shufps %%t0, %%r1, 0x44 ; t0 = {b1 b0 a1 a0} shufps %%r0, %%r1, 0xEE ; r0 = {b3 b2 a3 a2} movdqa %%t1, %%r2 shufps %%t1, %%r3, 0x44 ; t1 = {d1 d0 c1 c0} shufps %%r2, %%r3, 0xEE ; r2 = {d3 d2 c3 c2} movdqa %%r1, %%t0 shufps %%r1, %%t1, 0xDD ; r1 = {d1 c1 b1 a1} movdqa %%r3, %%r0 shufps %%r3, %%r2, 0xDD ; r3 = {d3 c3 b3 a3} shufps %%r0, %%r2, 0x88 ; r0 = {d2 c2 b2 a2} shufps %%t0, %%t1, 0x88 ; t0 = {d0 c0 b0 a0} %endmacro ;; ;; Magic functions defined in RFC 1321 ;; ; macro MAGIC_F F,X,Y,Z ;; F = ((Z) ^ ((X) & ((Y) ^ (Z)))) %macro MAGIC_F 4 %define %%F %1 %define %%X %2 %define %%Y %3 %define %%Z %4 movdqa %%F,%%Z pxor %%F,%%Y pand %%F,%%X pxor %%F,%%Z %endmacro ; macro MAGIC_G F,X,Y,Z ;; F = F((Z),(X),(Y)) %macro MAGIC_G 4 %define %%F %1 %define %%X %2 %define %%Y %3 %define %%Z %4 MAGIC_F %%F,%%Z,%%X,%%Y %endmacro ; macro MAGIC_H F,X,Y,Z ;; F = ((X) ^ (Y) ^ (Z)) %macro MAGIC_H 4 %define %%F %1 %define %%X %2 %define %%Y %3 %define %%Z %4 movdqa %%F,%%Z pxor %%F,%%Y pxor %%F,%%X %endmacro ; macro MAGIC_I F,X,Y,Z ;; F = ((Y) ^ ((X) | ~(Z))) %macro MAGIC_I 4 %define %%F %1 %define %%X %2 %define %%Y %3 %define %%Z %4 movdqa %%F,%%Z pxor %%F,[rel ONES] ; pnot %%F por %%F,%%X pxor %%F,%%Y %endmacro ; PROLD reg, imm, tmp %macro PROLD 3 %define %%reg %1 %define %%imm %2 %define %%tmp %3 movdqa %%tmp, %%reg psrld %%tmp, (32-%%imm) pslld %%reg, %%imm por %%reg, %%tmp %endmacro ;; ;; single MD5 step ;; ;; A = B +ROL32((A +MAGIC(B,C,D) +data +const), nrot) ;; ; macro MD5_STEP1 MAGIC_FUN, A,B,C,D, A2,B2,C3,D2, FUN, TMP, data, MD5const, nrot %macro MD5_STEP1 14 %define %%MAGIC_FUN %1 %define %%A %2 %define %%B %3 %define %%C %4 %define %%D %5 %define %%A2 %6 %define %%B2 %7 %define %%C2 %8 %define %%D2 %9 %define %%FUN %10 %define %%TMP %11 %define %%data %12 %define %%MD5const %13 %define %%nrot %14 paddd %%A, %%MD5const paddd %%A2, %%MD5const paddd %%A, [%%data] paddd %%A2, [%%data + 16*16] %%MAGIC_FUN %%FUN, %%B,%%C,%%D paddd %%A, %%FUN %%MAGIC_FUN %%FUN, %%B2,%%C2,%%D2 paddd %%A2, %%FUN PROLD %%A,%%nrot, %%TMP PROLD %%A2,%%nrot, %%TMP paddd %%A, %%B paddd %%A2, %%B2 %endmacro ;; ;; single MD5 step ;; ;; A = B +ROL32((A +MAGIC(B,C,D) +data +const), nrot) ;; ; macro MD5_STEP MAGIC_FUN, A,B,C,D, A2,B2,C3,D2, FUN, TMP, FUN2, TMP2, data, ; MD5const, nrot %macro MD5_STEP 16 %define %%MAGIC_FUN %1 %define %%A %2 %define %%B %3 %define %%C %4 %define %%D %5 %define %%A2 %6 %define %%B2 %7 %define %%C2 %8 %define %%D2 %9 %define %%FUN %10 %define %%TMP %11 %define %%FUN2 %12 %define %%TMP2 %13 %define %%data %14 %define %%MD5const %15 %define %%nrot %16 paddd %%A, %%MD5const paddd %%A2, %%MD5const paddd %%A, [%%data] paddd %%A2, [%%data + 16*16] %%MAGIC_FUN %%FUN, %%B,%%C,%%D %%MAGIC_FUN %%FUN2, %%B2,%%C2,%%D2 paddd %%A, %%FUN paddd %%A2, %%FUN2 PROLD %%A,%%nrot, %%TMP PROLD %%A2,%%nrot, %%TMP2 paddd %%A, %%B paddd %%A2, %%B2 %endmacro ; void md5_x4x2_sse(MD5_ARGS *args, UINT64 num_blks) ; arg 1 : pointer to MD5_ARGS structure ; arg 2 : number of blocks (>=1) ; align 32 MKGLOBAL(md5_x4x2_sse,function,internal) md5_x4x2_sse: sub rsp, STACK_SIZE ;; each row of transposed digests is split into 2 parts, the right half stored in A, and left half in A2 ;; Initialize digests movdqa A,[arg1 + 0*16 + 0*MD5_DIGEST_ROW_SIZE] movdqa B,[arg1 + 0*16 + 1*MD5_DIGEST_ROW_SIZE] movdqa C,[arg1 + 0*16 + 2*MD5_DIGEST_ROW_SIZE] movdqa D,[arg1 + 0*16 + 3*MD5_DIGEST_ROW_SIZE] ;; Initialize digests movdqa A2,[arg1 + 1*16 + 0*MD5_DIGEST_ROW_SIZE] movdqa B2,[arg1 + 1*16 + 1*MD5_DIGEST_ROW_SIZE] movdqa C2,[arg1 + 1*16 + 2*MD5_DIGEST_ROW_SIZE] movdqa D2,[arg1 + 1*16 + 3*MD5_DIGEST_ROW_SIZE] lea TBL, [rel MD5_TABLE] ;; load input pointers mov inp0,[arg1+_data_ptr_md5 +0*PTR_SZ] mov inp1,[arg1+_data_ptr_md5 +1*PTR_SZ] mov inp2,[arg1+_data_ptr_md5 +2*PTR_SZ] mov inp3,[arg1+_data_ptr_md5 +3*PTR_SZ] mov inp4,[arg1+_data_ptr_md5 +4*PTR_SZ] mov inp5,[arg1+_data_ptr_md5 +5*PTR_SZ] mov inp6,[arg1+_data_ptr_md5 +6*PTR_SZ] mov inp7,[arg1+_data_ptr_md5 +7*PTR_SZ] xor IDX, IDX ; Make ping-pong pointers to the two memory blocks mov mem1, rsp lea mem2, [rsp + 16*16*2] ;; Load first block of data and save back to stack %assign I 0 %rep 4 movdqu T2,[inp0+IDX+I*16] movdqu T1,[inp1+IDX+I*16] movdqu T4,[inp2+IDX+I*16] movdqu T3,[inp3+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem1+(I*4+0)*16],T0 movdqa [mem1+(I*4+1)*16],T1 movdqa [mem1+(I*4+2)*16],T2 movdqa [mem1+(I*4+3)*16],T3 movdqu T2,[inp4+IDX+I*16] movdqu T1,[inp5+IDX+I*16] movdqu T4,[inp6+IDX+I*16] movdqu T3,[inp7+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem1+(I*4+0)*16 + 16*16],T0 movdqa [mem1+(I*4+1)*16 + 16*16],T1 movdqa [mem1+(I*4+2)*16 + 16*16],T2 movdqa [mem1+(I*4+3)*16 + 16*16],T3 %assign I (I+1) %endrep lloop: ; save old digests movdqa [AA], A movdqa [BB], B movdqa [CC], C movdqa [DD], D ; save old digests movdqa [AA2], A2 movdqa [BB2], B2 movdqa [CC2], C2 movdqa [DD2], D2 add IDX, 4*16 sub arg2, 1 je lastblock MD5_STEP1 MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 0*16, [TBL+ 0*16], rot11 MD5_STEP1 MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 1*16, [TBL+ 1*16], rot12 MD5_STEP1 MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 2*16, [TBL+ 2*16], rot13 MD5_STEP1 MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 3*16, [TBL+ 3*16], rot14 MD5_STEP1 MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 4*16, [TBL+ 4*16], rot11 MD5_STEP1 MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 5*16, [TBL+ 5*16], rot12 MD5_STEP1 MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 6*16, [TBL+ 6*16], rot13 MD5_STEP1 MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 7*16, [TBL+ 7*16], rot14 %assign I 0 movdqu T2,[inp0+IDX+I*16] movdqu T1,[inp1+IDX+I*16] movdqu T4,[inp2+IDX+I*16] movdqu T3,[inp3+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16],T0 movdqa [mem2+(I*4+1)*16],T1 movdqa [mem2+(I*4+2)*16],T2 movdqa [mem2+(I*4+3)*16],T3 MD5_STEP1 MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 8*16, [TBL+ 8*16], rot11 MD5_STEP1 MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 9*16, [TBL+ 9*16], rot12 MD5_STEP1 MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +10*16, [TBL+10*16], rot13 MD5_STEP1 MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 +11*16, [TBL+11*16], rot14 MD5_STEP1 MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 +12*16, [TBL+12*16], rot11 MD5_STEP1 MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 +13*16, [TBL+13*16], rot12 MD5_STEP1 MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +14*16, [TBL+14*16], rot13 MD5_STEP1 MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 +15*16, [TBL+15*16], rot14 movdqu T2,[inp4+IDX+I*16] movdqu T1,[inp5+IDX+I*16] movdqu T4,[inp6+IDX+I*16] movdqu T3,[inp7+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16 + 16*16],T0 movdqa [mem2+(I*4+1)*16 + 16*16],T1 movdqa [mem2+(I*4+2)*16 + 16*16],T2 movdqa [mem2+(I*4+3)*16 + 16*16],T3 %assign I (I+1) MD5_STEP1 MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 1*16, [TBL+16*16], rot21 MD5_STEP1 MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 6*16, [TBL+17*16], rot22 MD5_STEP1 MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +11*16, [TBL+18*16], rot23 MD5_STEP1 MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 0*16, [TBL+19*16], rot24 MD5_STEP1 MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 5*16, [TBL+20*16], rot21 MD5_STEP1 MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 +10*16, [TBL+21*16], rot22 MD5_STEP1 MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +15*16, [TBL+22*16], rot23 MD5_STEP1 MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 4*16, [TBL+23*16], rot24 movdqu T2,[inp0+IDX+I*16] movdqu T1,[inp1+IDX+I*16] movdqu T4,[inp2+IDX+I*16] movdqu T3,[inp3+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16],T0 movdqa [mem2+(I*4+1)*16],T1 movdqa [mem2+(I*4+2)*16],T2 movdqa [mem2+(I*4+3)*16],T3 MD5_STEP1 MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 9*16, [TBL+24*16], rot21 MD5_STEP1 MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 +14*16, [TBL+25*16], rot22 MD5_STEP1 MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 3*16, [TBL+26*16], rot23 MD5_STEP1 MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 8*16, [TBL+27*16], rot24 MD5_STEP1 MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 +13*16, [TBL+28*16], rot21 MD5_STEP1 MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 2*16, [TBL+29*16], rot22 MD5_STEP1 MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 7*16, [TBL+30*16], rot23 MD5_STEP1 MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 +12*16, [TBL+31*16], rot24 movdqu T2,[inp4+IDX+I*16] movdqu T1,[inp5+IDX+I*16] movdqu T4,[inp6+IDX+I*16] movdqu T3,[inp7+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16 + 16*16],T0 movdqa [mem2+(I*4+1)*16 + 16*16],T1 movdqa [mem2+(I*4+2)*16 + 16*16],T2 movdqa [mem2+(I*4+3)*16 + 16*16],T3 %assign I (I+1) MD5_STEP1 MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 5*16, [TBL+32*16], rot31 MD5_STEP1 MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 8*16, [TBL+33*16], rot32 MD5_STEP1 MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +11*16, [TBL+34*16], rot33 MD5_STEP1 MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 +14*16, [TBL+35*16], rot34 MD5_STEP1 MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 1*16, [TBL+36*16], rot31 MD5_STEP1 MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 4*16, [TBL+37*16], rot32 MD5_STEP1 MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 7*16, [TBL+38*16], rot33 MD5_STEP1 MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 +10*16, [TBL+39*16], rot34 movdqu T2,[inp0+IDX+I*16] movdqu T1,[inp1+IDX+I*16] movdqu T4,[inp2+IDX+I*16] movdqu T3,[inp3+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16],T0 movdqa [mem2+(I*4+1)*16],T1 movdqa [mem2+(I*4+2)*16],T2 movdqa [mem2+(I*4+3)*16],T3 MD5_STEP1 MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 +13*16, [TBL+40*16], rot31 MD5_STEP1 MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 0*16, [TBL+41*16], rot32 MD5_STEP1 MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 3*16, [TBL+42*16], rot33 MD5_STEP1 MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 6*16, [TBL+43*16], rot34 MD5_STEP1 MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 9*16, [TBL+44*16], rot31 MD5_STEP1 MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 +12*16, [TBL+45*16], rot32 MD5_STEP1 MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +15*16, [TBL+46*16], rot33 MD5_STEP1 MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 2*16, [TBL+47*16], rot34 movdqu T2,[inp4+IDX+I*16] movdqu T1,[inp5+IDX+I*16] movdqu T4,[inp6+IDX+I*16] movdqu T3,[inp7+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16 + 16*16],T0 movdqa [mem2+(I*4+1)*16 + 16*16],T1 movdqa [mem2+(I*4+2)*16 + 16*16],T2 movdqa [mem2+(I*4+3)*16 + 16*16],T3 %assign I (I+1) MD5_STEP1 MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 0*16, [TBL+48*16], rot41 MD5_STEP1 MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 7*16, [TBL+49*16], rot42 MD5_STEP1 MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +14*16, [TBL+50*16], rot43 MD5_STEP1 MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 5*16, [TBL+51*16], rot44 MD5_STEP1 MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 +12*16, [TBL+52*16], rot41 MD5_STEP1 MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 + 3*16, [TBL+53*16], rot42 MD5_STEP1 MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 +10*16, [TBL+54*16], rot43 MD5_STEP1 MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 1*16, [TBL+55*16], rot44 movdqu T2,[inp0+IDX+I*16] movdqu T1,[inp1+IDX+I*16] movdqu T4,[inp2+IDX+I*16] movdqu T3,[inp3+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16],T0 movdqa [mem2+(I*4+1)*16],T1 movdqa [mem2+(I*4+2)*16],T2 movdqa [mem2+(I*4+3)*16],T3 MD5_STEP1 MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 8*16, [TBL+56*16], rot41 MD5_STEP1 MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 +15*16, [TBL+57*16], rot42 MD5_STEP1 MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 6*16, [TBL+58*16], rot43 MD5_STEP1 MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 +13*16, [TBL+59*16], rot44 MD5_STEP1 MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, mem1 + 4*16, [TBL+60*16], rot41 MD5_STEP1 MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, mem1 +11*16, [TBL+61*16], rot42 MD5_STEP1 MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, mem1 + 2*16, [TBL+62*16], rot43 MD5_STEP1 MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, mem1 + 9*16, [TBL+63*16], rot44 movdqu T2,[inp4+IDX+I*16] movdqu T1,[inp5+IDX+I*16] movdqu T4,[inp6+IDX+I*16] movdqu T3,[inp7+IDX+I*16] TRANSPOSE T2, T1, T4, T3, T0, T5 movdqa [mem2+(I*4+0)*16 + 16*16],T0 movdqa [mem2+(I*4+1)*16 + 16*16],T1 movdqa [mem2+(I*4+2)*16 + 16*16],T2 movdqa [mem2+(I*4+3)*16 + 16*16],T3 %assign I (I+1) paddd A,[AA] paddd B,[BB] paddd C,[CC] paddd D,[DD] paddd A2,[AA2] paddd B2,[BB2] paddd C2,[CC2] paddd D2,[DD2] ; swap mem1 and mem2 xchg mem1, mem2 jmp lloop lastblock: MD5_STEP MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 0*16, [TBL+ 0*16], rot11 MD5_STEP MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 1*16, [TBL+ 1*16], rot12 MD5_STEP MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 2*16, [TBL+ 2*16], rot13 MD5_STEP MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 3*16, [TBL+ 3*16], rot14 MD5_STEP MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 4*16, [TBL+ 4*16], rot11 MD5_STEP MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 5*16, [TBL+ 5*16], rot12 MD5_STEP MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 6*16, [TBL+ 6*16], rot13 MD5_STEP MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 7*16, [TBL+ 7*16], rot14 MD5_STEP MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 8*16, [TBL+ 8*16], rot11 MD5_STEP MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 9*16, [TBL+ 9*16], rot12 MD5_STEP MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +10*16, [TBL+10*16], rot13 MD5_STEP MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 +11*16, [TBL+11*16], rot14 MD5_STEP MAGIC_F, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 +12*16, [TBL+12*16], rot11 MD5_STEP MAGIC_F, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 +13*16, [TBL+13*16], rot12 MD5_STEP MAGIC_F, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +14*16, [TBL+14*16], rot13 MD5_STEP MAGIC_F, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 +15*16, [TBL+15*16], rot14 MD5_STEP MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 1*16, [TBL+16*16], rot21 MD5_STEP MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 6*16, [TBL+17*16], rot22 MD5_STEP MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +11*16, [TBL+18*16], rot23 MD5_STEP MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 0*16, [TBL+19*16], rot24 MD5_STEP MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 5*16, [TBL+20*16], rot21 MD5_STEP MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 +10*16, [TBL+21*16], rot22 MD5_STEP MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +15*16, [TBL+22*16], rot23 MD5_STEP MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 4*16, [TBL+23*16], rot24 MD5_STEP MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 9*16, [TBL+24*16], rot21 MD5_STEP MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 +14*16, [TBL+25*16], rot22 MD5_STEP MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 3*16, [TBL+26*16], rot23 MD5_STEP MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 8*16, [TBL+27*16], rot24 MD5_STEP MAGIC_G, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 +13*16, [TBL+28*16], rot21 MD5_STEP MAGIC_G, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 2*16, [TBL+29*16], rot22 MD5_STEP MAGIC_G, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 7*16, [TBL+30*16], rot23 MD5_STEP MAGIC_G, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 +12*16, [TBL+31*16], rot24 MD5_STEP MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 5*16, [TBL+32*16], rot31 MD5_STEP MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 8*16, [TBL+33*16], rot32 MD5_STEP MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +11*16, [TBL+34*16], rot33 MD5_STEP MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 +14*16, [TBL+35*16], rot34 MD5_STEP MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 1*16, [TBL+36*16], rot31 MD5_STEP MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 4*16, [TBL+37*16], rot32 MD5_STEP MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 7*16, [TBL+38*16], rot33 MD5_STEP MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 +10*16, [TBL+39*16], rot34 MD5_STEP MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 +13*16, [TBL+40*16], rot31 MD5_STEP MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 0*16, [TBL+41*16], rot32 MD5_STEP MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 3*16, [TBL+42*16], rot33 MD5_STEP MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 6*16, [TBL+43*16], rot34 MD5_STEP MAGIC_H, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 9*16, [TBL+44*16], rot31 MD5_STEP MAGIC_H, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 +12*16, [TBL+45*16], rot32 MD5_STEP MAGIC_H, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +15*16, [TBL+46*16], rot33 MD5_STEP MAGIC_H, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 2*16, [TBL+47*16], rot34 MD5_STEP MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 0*16, [TBL+48*16], rot41 MD5_STEP MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 7*16, [TBL+49*16], rot42 MD5_STEP MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +14*16, [TBL+50*16], rot43 MD5_STEP MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 5*16, [TBL+51*16], rot44 MD5_STEP MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 +12*16, [TBL+52*16], rot41 MD5_STEP MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 + 3*16, [TBL+53*16], rot42 MD5_STEP MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 +10*16, [TBL+54*16], rot43 MD5_STEP MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 1*16, [TBL+55*16], rot44 MD5_STEP MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 8*16, [TBL+56*16], rot41 MD5_STEP MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 +15*16, [TBL+57*16], rot42 MD5_STEP MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 6*16, [TBL+58*16], rot43 MD5_STEP MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 +13*16, [TBL+59*16], rot44 MD5_STEP MAGIC_I, A,B,C,D, A2,B2,C2,D2, FUN,TMP, FUN2,TMP2, mem1 + 4*16, [TBL+60*16], rot41 MD5_STEP MAGIC_I, D,A,B,C, D2,A2,B2,C2, FUN,TMP, FUN2,TMP2, mem1 +11*16, [TBL+61*16], rot42 MD5_STEP MAGIC_I, C,D,A,B, C2,D2,A2,B2, FUN,TMP, FUN2,TMP2, mem1 + 2*16, [TBL+62*16], rot43 MD5_STEP MAGIC_I, B,C,D,A, B2,C2,D2,A2, FUN,TMP, FUN2,TMP2, mem1 + 9*16, [TBL+63*16], rot44 paddd A,[AA] paddd B,[BB] paddd C,[CC] paddd D,[DD] paddd A2,[AA2] paddd B2,[BB2] paddd C2,[CC2] paddd D2,[DD2] ; write out digests movdqu [arg1 + 0*16 + 0*MD5_DIGEST_ROW_SIZE], A movdqu [arg1 + 0*16 + 1*MD5_DIGEST_ROW_SIZE], B movdqu [arg1 + 0*16 + 2*MD5_DIGEST_ROW_SIZE], C movdqu [arg1 + 0*16 + 3*MD5_DIGEST_ROW_SIZE], D movdqu [arg1 + 1*16 + 0*MD5_DIGEST_ROW_SIZE], A2 movdqu [arg1 + 1*16 + 1*MD5_DIGEST_ROW_SIZE], B2 movdqu [arg1 + 1*16 + 2*MD5_DIGEST_ROW_SIZE], C2 movdqu [arg1 + 1*16 + 3*MD5_DIGEST_ROW_SIZE], D2 ;; update input pointers add inp0, IDX add inp1, IDX add inp2, IDX add inp3, IDX add inp4, IDX add inp5, IDX add inp6, IDX add inp7, IDX mov [arg1 +_data_ptr_md5 + 0*PTR_SZ], inp0 mov [arg1 +_data_ptr_md5 + 1*PTR_SZ], inp1 mov [arg1 +_data_ptr_md5 + 2*PTR_SZ], inp2 mov [arg1 +_data_ptr_md5 + 3*PTR_SZ], inp3 mov [arg1 +_data_ptr_md5 + 4*PTR_SZ], inp4 mov [arg1 +_data_ptr_md5 + 5*PTR_SZ], inp5 mov [arg1 +_data_ptr_md5 + 6*PTR_SZ], inp6 mov [arg1 +_data_ptr_md5 + 7*PTR_SZ], inp7 ;;;;;;;;;;;;;;;; ;; Postamble add rsp, STACK_SIZE ret %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif ",16148,True,3321.020723620208,median "/* * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar. */ grammar SqlBase; @members { /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ public boolean legacy_setops_precedence_enbled = false; /** * Verify whether current token is a valid decimal token (which contains dot). * Returns true if the character that follows the token is not a digit or letter or underscore. * * For example: * For char stream ""2.3"", ""2."" is not a valid decimal token, because it is followed by digit '3'. * For char stream ""2.3_"", ""2.3"" is not a valid decimal token, because it is followed by '_'. * For char stream ""2.3W"", ""2.3"" is not a valid decimal token, because it is followed by 'W'. * For char stream ""12.0D 34.E2+0.12 "" 12.0D is a valid decimal token because it is followed * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+' * which is not a digit or letter or underscore. */ public boolean isValidDecimal() { int nextChar = _input.LA(1); if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' || nextChar == '_') { return false; } else { return true; } } /** * When true, ANSI SQL parsing mode is enabled. */ public boolean ansi = false; } singleStatement : statement EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleMultipartIdentifier : multipartIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; singleInterval : INTERVAL? multiUnitsInterval EOF ; statement : query #statementDefault | ctes? dmlStatementNoWith #dmlStatement | USE NAMESPACE? multipartIdentifier #use | CREATE (database | NAMESPACE) (IF NOT EXISTS)? multipartIdentifier ((COMMENT comment=STRING) | locationSpec | (WITH (DBPROPERTIES | PROPERTIES) tablePropertyList))* #createNamespace | ALTER database db=errorCapturingIdentifier SET DBPROPERTIES tablePropertyList #setDatabaseProperties | ALTER database db=errorCapturingIdentifier SET locationSpec #setDatabaseLocation | DROP (database | NAMESPACE) (IF EXISTS)? multipartIdentifier (RESTRICT | CASCADE)? #dropNamespace | SHOW (DATABASES | NAMESPACES) ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showNamespaces | createTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? ((COMMENT comment=STRING) | (PARTITIONED BY '(' partitionColumns=colTypeList ')' | PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier locationSpec? #createTableLike | replaceTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitioning=transformList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #replaceTable | ANALYZE TABLE multipartIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq | FOR ALL COLUMNS)? #analyze | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) columns=qualifiedColTypeWithPositionList #addTableColumns | ALTER TABLE multipartIdentifier ADD (COLUMN | COLUMNS) '(' columns=qualifiedColTypeWithPositionList ')' #addTableColumns | ALTER TABLE multipartIdentifier RENAME COLUMN from=qualifiedName TO to=identifier #renameTableColumn | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) '(' columns=qualifiedNameList ')' #dropTableColumns | ALTER TABLE multipartIdentifier DROP (COLUMN | COLUMNS) columns=qualifiedNameList #dropTableColumns | ALTER (TABLE | VIEW) from=tableIdentifier RENAME TO to=tableIdentifier #renameTable | ALTER (TABLE | VIEW) multipartIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) multipartIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ALTER TABLE multipartIdentifier (ALTER | CHANGE) COLUMN? multipartIdentifier (TYPE dataType)? (COMMENT comment=STRING)? colPosition? #alterTableColumn | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDE STRING (WITH SERDEPROPERTIES tablePropertyList)? #setTableSerDe | ALTER TABLE multipartIdentifier (partitionSpec)? SET SERDEPROPERTIES tablePropertyList #setTableSerDe | ALTER (TABLE | VIEW) multipartIdentifier ADD (IF NOT EXISTS)? partitionSpecLocation+ #addTablePartition | ALTER TABLE multipartIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER (TABLE | VIEW) multipartIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER TABLE multipartIdentifier (partitionSpec)? SET locationSpec #setTableLocation | ALTER TABLE multipartIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? multipartIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? multipartIdentifier #dropView | CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)? VIEW (IF NOT EXISTS)? tableIdentifier identifierCommentList? ((COMMENT STRING) | (PARTITIONED ON identifierList) | (TBLPROPERTIES tablePropertyList))* AS query #createView | CREATE (OR REPLACE)? GLOBAL? TEMPORARY VIEW tableIdentifier ('(' colTypeList ')')? tableProvider (OPTIONS tablePropertyList)? #createTempViewUsing | ALTER VIEW tableIdentifier AS? query #alterViewQuery | CREATE (OR REPLACE)? TEMPORARY? FUNCTION (IF NOT EXISTS)? qualifiedName AS className=STRING (USING resource (',' resource)*)? #createFunction | DROP TEMPORARY? FUNCTION (IF EXISTS)? qualifiedName #dropFunction | EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)? statement #explain | SHOW TABLES ((FROM | IN) multipartIdentifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) db=errorCapturingIdentifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW TBLPROPERTIES table=tableIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) table=multipartIdentifier ((FROM | IN) namespace=multipartIdentifier)? #showColumns | SHOW PARTITIONS multipartIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (qualifiedName | pattern=STRING))? #showFunctions | SHOW CREATE TABLE multipartIdentifier #showCreateTable | SHOW CURRENT NAMESPACE #showCurrentNamespace | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) database EXTENDED? db=errorCapturingIdentifier #describeDatabase | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? multipartIdentifier partitionSpec? describeColName? #describeTable | (DESC | DESCRIBE) QUERY? query #describeQuery | REFRESH TABLE multipartIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE LAZY? TABLE multipartIdentifier (OPTIONS options=tablePropertyList)? (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? multipartIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE multipartIdentifier partitionSpec? #loadData | TRUNCATE TABLE multipartIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE multipartIdentifier #repairTable | op=(ADD | LIST) identifier .*? #manageResource | SET ROLE .*? #failNativeCommand | SET .*? #setConfiguration | RESET #resetConfiguration | DELETE FROM multipartIdentifier tableAlias whereClause? #deleteFromTable | UPDATE multipartIdentifier tableAlias setClause whereClause? #updateTable | unsupportedHiveNativeCommands .*? #failNativeCommand ; unsupportedHiveNativeCommands : kw1=CREATE kw2=ROLE | kw1=DROP kw2=ROLE | kw1=GRANT kw2=ROLE? | kw1=REVOKE kw2=ROLE? | kw1=SHOW kw2=GRANT | kw1=SHOW kw2=ROLE kw3=GRANT? | kw1=SHOW kw2=PRINCIPALS | kw1=SHOW kw2=ROLES | kw1=SHOW kw2=CURRENT kw3=ROLES | kw1=EXPORT kw2=TABLE | kw1=IMPORT kw2=TABLE | kw1=SHOW kw2=COMPACTIONS | kw1=SHOW kw2=CREATE kw3=TABLE | kw1=SHOW kw2=TRANSACTIONS | kw1=SHOW kw2=INDEXES | kw1=SHOW kw2=LOCKS | kw1=CREATE kw2=INDEX | kw1=DROP kw2=INDEX | kw1=ALTER kw2=INDEX | kw1=LOCK kw2=TABLE | kw1=LOCK kw2=DATABASE | kw1=UNLOCK kw2=TABLE | kw1=UNLOCK kw2=DATABASE | kw1=CREATE kw2=TEMPORARY kw3=MACRO | kw1=DROP kw2=TEMPORARY kw3=MACRO | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=CLUSTERED | kw1=ALTER kw2=TABLE tableIdentifier kw3=CLUSTERED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SORTED | kw1=ALTER kw2=TABLE tableIdentifier kw3=SKEWED kw4=BY | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=SKEWED | kw1=ALTER kw2=TABLE tableIdentifier kw3=NOT kw4=STORED kw5=AS kw6=DIRECTORIES | kw1=ALTER kw2=TABLE tableIdentifier kw3=SET kw4=SKEWED kw5=LOCATION | kw1=ALTER kw2=TABLE tableIdentifier kw3=EXCHANGE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=ARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=UNARCHIVE kw4=PARTITION | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=SET kw4=FILEFORMAT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=REPLACE kw4=COLUMNS | kw1=START kw2=TRANSACTION | kw1=COMMIT | kw1=ROLLBACK | kw1=DFS | kw1=DELETE kw2=FROM ; createTableHeader : CREATE TEMPORARY? EXTERNAL? TABLE (IF NOT EXISTS)? multipartIdentifier ; replaceTableHeader : (CREATE OR)? REPLACE TABLE multipartIdentifier ; bucketSpec : CLUSTERED BY identifierList (SORTED BY orderedIdentifierList)? INTO INTEGER_VALUE BUCKETS ; skewSpec : SKEWED BY identifierList ON (constantList | nestedConstantList) (STORED AS DIRECTORIES)? ; locationSpec : LOCATION STRING ; query : ctes? queryTerm queryOrganization ; insertInto : INSERT OVERWRITE TABLE? multipartIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? multipartIdentifier partitionSpec? (IF NOT EXISTS)? #insertIntoTable | INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat? #insertOverwriteHiveDir | INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)? tableProvider (OPTIONS options=tablePropertyList)? #insertOverwriteDir ; partitionSpecLocation : partitionSpec locationSpec? ; partitionSpec : PARTITION '(' partitionVal (',' partitionVal)* ')' ; partitionVal : identifier (EQ constant)? ; database : DATABASE | SCHEMA ; describeFuncName : qualifiedName | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=errorCapturingIdentifier (columnAliases=identifierList)? AS? '(' query ')' ; tableProvider : USING qualifiedName ; tablePropertyList : '(' tableProperty (',' tableProperty)* ')' ; tableProperty : key=tablePropertyKey (EQ? value=tablePropertyValue)? ; tablePropertyKey : identifier ('.' identifier)* | STRING ; tablePropertyValue : INTEGER_VALUE | DECIMAL_VALUE | booleanValue | STRING ; constantList : '(' constant (',' constant)* ')' ; nestedConstantList : '(' constantList (',' constantList)* ')' ; createFileFormat : STORED AS fileFormat | STORED BY storageHandler ; fileFormat : INPUTFORMAT inFmt=STRING OUTPUTFORMAT outFmt=STRING #tableFileFormat | identifier #genericFileFormat ; storageHandler : STRING (WITH SERDEPROPERTIES tablePropertyList)? ; resource : identifier STRING ; dmlStatementNoWith : insertInto queryTerm queryOrganization #singleInsertQuery | fromClause multiInsertQueryBody+ #multiInsertQuery ; queryOrganization : (ORDER BY order+=sortItem (',' order+=sortItem)*)? (CLUSTER BY clusterBy+=expression (',' clusterBy+=expression)*)? (DISTRIBUTE BY distributeBy+=expression (',' distributeBy+=expression)*)? (SORT BY sort+=sortItem (',' sort+=sortItem)*)? windowClause? (LIMIT (ALL | limit=expression))? ; multiInsertQueryBody : insertInto fromStatementBody ; queryTerm : queryPrimary #queryTermDefault | left=queryTerm {legacy_setops_precedence_enbled}? operator=(INTERSECT | UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=INTERSECT setQuantifier? right=queryTerm #setOperation | left=queryTerm {!legacy_setops_precedence_enbled}? operator=(UNION | EXCEPT | SETMINUS) setQuantifier? right=queryTerm #setOperation ; queryPrimary : querySpecification #queryPrimaryDefault | fromStatement #fromStmt | TABLE multipartIdentifier #table | inlineTable #inlineTableDefault1 | '(' query ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; fromStatement : fromClause fromStatementBody+ ; fromStatementBody : transformClause whereClause? queryOrganization | selectClause lateralView* whereClause? aggregationClause? havingClause? windowClause? queryOrganization ; querySpecification : transformClause fromClause? whereClause? #transformQuerySpecification | selectClause fromClause? lateralView* whereClause? aggregationClause? havingClause? windowClause? #regularQuerySpecification ; transformClause : (SELECT kind=TRANSFORM '(' namedExpressionSeq ')' | kind=MAP namedExpressionSeq | kind=REDUCE namedExpressionSeq) inRowFormat=rowFormat? (RECORDWRITER recordWriter=STRING)? USING script=STRING (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList) ')')))? outRowFormat=rowFormat? (RECORDREADER recordReader=STRING)? ; selectClause : SELECT (hints+=hint)* setQuantifier? namedExpressionSeq ; setClause : SET assign (',' assign)* ; assign : key=multipartIdentifier EQ value=expression ; whereClause : WHERE booleanExpression ; havingClause : HAVING booleanExpression ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregationClause : GROUP BY groupingExpressions+=expression (',' groupingExpressions+=expression)* ( WITH kind=ROLLUP | WITH kind=CUBE | kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')')? | GROUP BY kind=GROUPING SETS '(' groupingSet (',' groupingSet)* ')' ; groupingSet : '(' (expression (',' expression)*)? ')' | expression ; pivotClause : PIVOT '(' aggregates=namedExpressionSeq FOR pivotColumn IN '(' pivotValues+=pivotValue (',' pivotValues+=pivotValue)* ')' ')' ; pivotColumn : identifiers+=identifier | '(' identifiers+=identifier (',' identifiers+=identifier)* ')' ; pivotValue : expression (AS? identifier)? ; lateralView : LATERAL VIEW (OUTER)? qualifiedName '(' (expression (',' expression)*)? ')' tblName=identifier (AS? colName+=identifier (',' colName+=identifier)*)? ; setQuantifier : DISTINCT | ALL ; relation : relationPrimary joinRelation* ; joinRelation : (joinType) JOIN right=relationPrimary joinCriteria? | NATURAL joinType JOIN right=relationPrimary ; joinType : INNER? | CROSS | LEFT OUTER? | LEFT? SEMI | RIGHT OUTER? | FULL OUTER? | LEFT? ANTI ; joinCriteria : ON booleanExpression | USING identifierList ; sample : TABLESAMPLE '(' sampleMethod? ')' ; sampleMethod : negativeSign=MINUS? percentage=(INTEGER_VALUE | DECIMAL_VALUE) PERCENTLIT #sampleByPercentile | expression ROWS #sampleByRows | sampleType=BUCKET numerator=INTEGER_VALUE OUT OF denominator=INTEGER_VALUE (ON (identifier | qualifiedName '(' ')'))? #sampleByBucket | bytes=expression #sampleByBytes ; identifierList : '(' identifierSeq ')' ; identifierSeq : ident+=errorCapturingIdentifier (',' ident+=errorCapturingIdentifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : ident=errorCapturingIdentifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier (COMMENT STRING)? ; relationPrimary : multipartIdentifier sample? tableAlias #tableName | '(' query ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : funcName=errorCapturingIdentifier '(' (expression (',' expression)*)? ')' tableAlias ; tableAlias : (AS? strictIdentifier identifierList?)? ; rowFormat : ROW FORMAT SERDE name=STRING (WITH SERDEPROPERTIES props=tablePropertyList)? #rowFormatSerde | ROW FORMAT DELIMITED (FIELDS TERMINATED BY fieldsTerminatedBy=STRING (ESCAPED BY escapedBy=STRING)?)? (COLLECTION ITEMS TERMINATED BY collectionItemsTerminatedBy=STRING)? (MAP KEYS TERMINATED BY keysTerminatedBy=STRING)? (LINES TERMINATED BY linesSeparatedBy=STRING)? (NULL DEFINED AS nullDefinedAs=STRING)? #rowFormatDelimited ; multipartIdentifier : parts+=errorCapturingIdentifier ('.' parts+=errorCapturingIdentifier)* ; tableIdentifier : (db=errorCapturingIdentifier '.')? table=errorCapturingIdentifier ; functionIdentifier : (db=errorCapturingIdentifier '.')? function=errorCapturingIdentifier ; namedExpression : expression (AS? (name=errorCapturingIdentifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; transformList : '(' transforms+=transform (',' transforms+=transform)* ')' ; transform : qualifiedName #identityTransform | transformName=identifier '(' argument+=transformArgument (',' argument+=transformArgument)* ')' #applyTransform ; transformArgument : qualifiedName | constant ; expression : booleanExpression ; booleanExpression : NOT booleanExpression #logicalNot | EXISTS '(' query ')' #exists | valueExpression predicate? #predicated | left=booleanExpression operator=AND right=booleanExpression #logicalBinary | left=booleanExpression operator=OR right=booleanExpression #logicalBinary ; predicate : NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=(RLIKE | LIKE) pattern=valueExpression | IS NOT? kind=NULL | IS NOT? kind=(TRUE | FALSE | UNKNOWN) | IS NOT? kind=DISTINCT FROM right=valueExpression ; valueExpression : primaryExpression #valueExpressionDefault | operator=(MINUS | PLUS | TILDE) valueExpression #arithmeticUnary | left=valueExpression operator=(ASTERISK | SLASH | PERCENT | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=(PLUS | MINUS | CONCAT_PIPE) right=valueExpression #arithmeticBinary | left=valueExpression operator=AMPERSAND right=valueExpression #arithmeticBinary | left=valueExpression operator=HAT right=valueExpression #arithmeticBinary | left=valueExpression operator=PIPE right=valueExpression #arithmeticBinary | left=valueExpression comparisonOperator right=valueExpression #comparison ; primaryExpression : name=(CURRENT_DATE | CURRENT_TIMESTAMP) #currentDatetime | CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase | CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase | CAST '(' expression AS dataType ')' #cast | STRUCT '(' (argument+=namedExpression (',' argument+=namedExpression)*)? ')' #struct | (FIRST | FIRST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #first | (LAST | LAST_VALUE) '(' expression ((IGNORE | RESPECT) NULLS)? ')' #last | POSITION '(' substr=valueExpression IN str=valueExpression ')' #position | constant #constantDefault | ASTERISK #star | qualifiedName '.' ASTERISK #star | '(' namedExpression (',' namedExpression)+ ')' #rowConstructor | '(' query ')' #subqueryExpression | qualifiedName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (OVER windowSpec)? #functionCall | identifier '->' expression #lambda | '(' identifier (',' identifier)+ ')' '->' expression #lambda | value=primaryExpression '[' index=valueExpression ']' #subscript | identifier #columnReference | base=primaryExpression '.' fieldName=identifier #dereference | '(' expression ')' #parenthesizedExpression | EXTRACT '(' field=identifier FROM source=valueExpression ')' #extract | (SUBSTR | SUBSTRING) '(' str=valueExpression (FROM | ',') pos=valueExpression ((FOR | ',') len=valueExpression)? ')' #substring | TRIM '(' trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)? FROM srcStr=valueExpression ')' #trim | OVERLAY '(' input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? ')' #overlay ; constant : NULL #nullLiteral | interval #intervalLiteral | identifier STRING #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral | STRING+ #stringLiteral ; comparisonOperator : EQ | NEQ | NEQJ | LT | LTE | GT | GTE | NSEQ ; arithmeticOperator : PLUS | MINUS | ASTERISK | SLASH | PERCENT | DIV | TILDE | AMPERSAND | PIPE | CONCAT_PIPE | HAT ; predicateOperator : OR | AND | IN | NOT ; booleanValue : TRUE | FALSE ; interval : INTERVAL (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval)? | {ansi}? (errorCapturingMultiUnitsInterval | errorCapturingUnitToUnitInterval) ; errorCapturingMultiUnitsInterval : multiUnitsInterval unitToUnitInterval? ; multiUnitsInterval : (intervalValue intervalUnit)+ ; errorCapturingUnitToUnitInterval : body=unitToUnitInterval (error1=multiUnitsInterval | error2=unitToUnitInterval)? ; unitToUnitInterval : value=intervalValue from=intervalUnit TO to=intervalUnit ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; intervalUnit : DAY | DAYS | HOUR | HOURS | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | SECOND | SECONDS | WEEK | WEEKS | YEAR | YEARS ; colPosition : FIRST | AFTER qualifiedName ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; qualifiedColTypeWithPositionList : qualifiedColTypeWithPosition (',' qualifiedColTypeWithPosition)* ; qualifiedColTypeWithPosition : name=qualifiedName dataType (COMMENT comment=STRING)? colPosition? ; colTypeList : colType (',' colType)* ; colType : colName=errorCapturingIdentifier dataType (COMMENT STRING)? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (COMMENT STRING)? ; whenClause : WHEN condition=expression THEN result=expression ; windowClause : WINDOW namedWindow (',' namedWindow)* ; namedWindow : name=errorCapturingIdentifier AS windowSpec ; windowSpec : name=errorCapturingIdentifier #windowRef | '('name=errorCapturingIdentifier')' #windowRef | '(' ( CLUSTER BY partition+=expression (',' partition+=expression)* | ((PARTITION | DISTRIBUTE) BY partition+=expression (',' partition+=expression)*)? ((ORDER | SORT) BY sortItem (',' sortItem)*)?) windowFrame? ')' #windowDef ; windowFrame : frameType=RANGE start=frameBound | frameType=ROWS start=frameBound | frameType=RANGE BETWEEN start=frameBound AND end=frameBound | frameType=ROWS BETWEEN start=frameBound AND end=frameBound ; frameBound : UNBOUNDED boundType=(PRECEDING | FOLLOWING) | boundType=CURRENT ROW | expression boundType=(PRECEDING | FOLLOWING) ; qualifiedNameList : qualifiedName (',' qualifiedName)* ; qualifiedName : identifier ('.' identifier)* ; // this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table` // replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise // valid expressions such as ""a-b"" can be recognized as an identifier errorCapturingIdentifier : identifier errorCapturingIdentifierExtra ; // extra left-factoring grammar errorCapturingIdentifierExtra : (MINUS identifier)+ #errorIdent | #realIdent ; identifier : strictIdentifier | {!ansi}? strictNonReserved ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | {ansi}? ansiNonReserved #unquotedIdentifier | {!ansi}? nonReserved #unquotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; number : MINUS? DECIMAL_VALUE #decimalLiteral | MINUS? INTEGER_VALUE #integerLiteral | MINUS? BIGINT_LITERAL #bigIntLiteral | MINUS? SMALLINT_LITERAL #smallIntLiteral | MINUS? TINYINT_LITERAL #tinyIntLiteral | MINUS? DOUBLE_LITERAL #doubleLiteral | MINUS? BIGDECIMAL_LITERAL #bigDecimalLiteral ; // When `spark.sql.ansi.enabled=true`, there are 2 kinds of keywords in Spark SQL. // - Reserved keywords: // Keywords that are reserved and can't be used as identifiers for table, view, column, // function, alias, etc. // - Non-reserved keywords: // Keywords that have a special meaning only in particular contexts and can be used as // identifiers in other contexts. For example, `SELECT 1 WEEK` is an interval literal, but WEEK // can be used as identifiers in other places. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The non-reserved keywords are listed below. Keywords not in this list are reserved keywords. ansiNonReserved : ADD | AFTER | ALTER | ANALYZE | ARCHIVE | ARRAY | ASC | AT | BETWEEN | BUCKET | BUCKETS | BY | CACHE | CASCADE | CHANGE | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLECTION | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | COST | CUBE | CURRENT | DATA | DATABASE | DATABASES | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTRIBUTE | DIV | DROP | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FIELDS | FILEFORMAT | FIRST | FOLLOWING | FORMAT | FORMATTED | FUNCTION | FUNCTIONS | GLOBAL | GROUPING | HOURS | IF | IGNORE | IMPORT | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | ITEMS | KEYS | LAST | LATERAL | LAZY | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTES | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NULLS | OF | OPTION | OPTIONS | OUT | OUTPUTFORMAT | OVER | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECONDS | SEPARATED | SERDE | SERDEPROPERTIES | SET | SETS | SHOW | SKEWED | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | TOUCH | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | UNARCHIVE | UNBOUNDED | UNCACHE | UNLOCK | UNSET | UPDATE | USE | VALUES | VIEW | WEEK | WEEKS | WINDOW | YEARS ; // When `spark.sql.ansi.enabled=false`, there are 2 kinds of keywords in Spark SQL. // - Non-reserved keywords: // Same definition as the one when `spark.sql.ansi.enabled=true`. // - Strict-non-reserved keywords: // A strict version of non-reserved keywords, which can not be used as table alias. // You can find the full keywords list by searching ""Start of the keywords list"" in this file. // The strict-non-reserved keywords are listed in `strictNonReserved`. // The non-reserved keywords are listed in `nonReserved`. // These 2 together contain all the keywords. strictNonReserved : ANTI | CROSS | EXCEPT | FULL | INNER | INTERSECT | JOIN | LEFT | NATURAL | ON | RIGHT | SEMI | SETMINUS | UNION | USING ; nonReserved : ADD | AFTER | ALL | ALTER | ANALYZE | AND | ANY | ARCHIVE | ARRAY | AS | ASC | AT | AUTHORIZATION | BETWEEN | BOTH | BUCKET | BUCKETS | BY | CACHE | CASCADE | CASE | CAST | CHANGE | CHECK | CLEAR | CLUSTER | CLUSTERED | CODEGEN | COLLATE | COLLECTION | COLUMN | COLUMNS | COMMENT | COMMIT | COMPACT | COMPACTIONS | COMPUTE | CONCATENATE | CONSTRAINT | COST | CREATE | CUBE | CURRENT | CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATABASES | DAY | DAYS | DBPROPERTIES | DEFINED | DELETE | DELIMITED | DESC | DESCRIBE | DFS | DIRECTORIES | DIRECTORY | DISTINCT | DISTRIBUTE | DIV | DROP | ELSE | END | ESCAPED | EXCHANGE | EXISTS | EXPLAIN | EXPORT | EXTENDED | EXTERNAL | EXTRACT | FALSE | FETCH | FIELDS | FILEFORMAT | FIRST | FIRST_VALUE | FOLLOWING | FOR | FOREIGN | FORMAT | FORMATTED | FROM | FUNCTION | FUNCTIONS | GLOBAL | GRANT | GROUP | GROUPING | HAVING | HOUR | HOURS | IF | IGNORE | IMPORT | IN | INDEX | INDEXES | INPATH | INPUTFORMAT | INSERT | INTERVAL | INTO | IS | ITEMS | KEYS | LAST | LAST_VALUE | LATERAL | LAZY | LEADING | LIKE | LIMIT | LINES | LIST | LOAD | LOCAL | LOCATION | LOCK | LOCKS | LOGICAL | MACRO | MAP | MICROSECOND | MICROSECONDS | MILLISECOND | MILLISECONDS | MINUTE | MINUTES | MONTH | MONTHS | MSCK | NAMESPACE | NAMESPACES | NO | NOT | NULL | NULLS | OF | ONLY | OPTION | OPTIONS | OR | ORDER | OUT | OUTER | OUTPUTFORMAT | OVER | OVERLAPS | OVERLAY | OVERWRITE | PARTITION | PARTITIONED | PARTITIONS | PERCENTLIT | PIVOT | PLACING | POSITION | PRECEDING | PRIMARY | PRINCIPALS | PROPERTIES | PURGE | QUERY | RANGE | RECORDREADER | RECORDWRITER | RECOVER | REDUCE | REFERENCES | REFRESH | RENAME | REPAIR | REPLACE | RESET | RESPECT | RESTRICT | REVOKE | RLIKE | ROLE | ROLES | ROLLBACK | ROLLUP | ROW | ROWS | SCHEMA | SECOND | SECONDS | SELECT | SEPARATED | SERDE | SERDEPROPERTIES | SESSION_USER | SET | SETS | SHOW | SKEWED | SOME | SORT | SORTED | START | STATISTICS | STORED | STRATIFY | STRUCT | SUBSTR | SUBSTRING | TABLE | TABLES | TABLESAMPLE | TBLPROPERTIES | TEMPORARY | TERMINATED | THEN | TO | TOUCH | TRAILING | TRANSACTION | TRANSACTIONS | TRANSFORM | TRIM | TRUE | TRUNCATE | TYPE | UNARCHIVE | UNBOUNDED | UNCACHE | UNIQUE | UNKNOWN | UNLOCK | UNSET | UPDATE | USE | USER | VALUES | VIEW | WEEK | WEEKS | WHEN | WHERE | WINDOW | WITH | YEAR | YEARS ; // NOTE: If you add a new token in the list below, you should update the list of keywords // in `docs/sql-keywords.md`. If the token is a non-reserved keyword, // please update `ansiNonReserved` and `nonReserved` as well. //============================ // Start of the keywords list //============================ ADD: 'ADD'; AFTER: 'AFTER'; ALL: 'ALL'; ALTER: 'ALTER'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY'; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; AUTHORIZATION: 'AUTHORIZATION'; BETWEEN: 'BETWEEN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; CACHE: 'CACHE'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CHANGE: 'CHANGE'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONSTRAINT: 'CONSTRAINT'; COST: 'COST'; CREATE: 'CREATE'; CROSS: 'CROSS'; CUBE: 'CUBE'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; DATA: 'DATA'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES' | 'SCHEMAS'; DAY: 'DAY'; DAYS: 'DAYS'; DBPROPERTIES: 'DBPROPERTIES'; DEFINED: 'DEFINED'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DROP: 'DROP'; ELSE: 'ELSE'; END: 'END'; ESCAPED: 'ESCAPED'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXISTS: 'EXISTS'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FIRST_VALUE: 'FIRST_VALUE'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HAVING: 'HAVING'; HOUR: 'HOUR'; HOURS: 'HOURS'; IF: 'IF'; IGNORE: 'IGNORE'; IMPORT: 'IMPORT'; IN: 'IN'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INTO: 'INTO'; IS: 'IS'; ITEMS: 'ITEMS'; JOIN: 'JOIN'; KEYS: 'KEYS'; LAST: 'LAST'; LAST_VALUE: 'LAST_VALUE'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEFT: 'LEFT'; LIKE: 'LIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; MACRO: 'MACRO'; MAP: 'MAP'; MICROSECOND: 'MICROSECOND'; MICROSECONDS: 'MICROSECONDS'; MILLISECOND: 'MILLISECOND'; MILLISECONDS: 'MILLISECONDS'; MINUTE: 'MINUTE'; MINUTES: 'MINUTES'; MONTH: 'MONTH'; MONTHS: 'MONTHS'; MSCK: 'MSCK'; NAMESPACE: 'NAMESPACE'; NAMESPACES: 'NAMESPACES'; NATURAL: 'NATURAL'; NO: 'NO'; NOT: 'NOT' | '!'; NULL: 'NULL'; NULLS: 'NULLS'; OF: 'OF'; ON: 'ON'; ONLY: 'ONLY'; OPTION: 'OPTION'; OPTIONS: 'OPTIONS'; OR: 'OR'; ORDER: 'ORDER'; OUT: 'OUT'; OUTER: 'OUTER'; OUTPUTFORMAT: 'OUTPUTFORMAT'; OVER: 'OVER'; OVERLAPS: 'OVERLAPS'; OVERLAY: 'OVERLAY'; OVERWRITE: 'OVERWRITE'; PARTITION: 'PARTITION'; PARTITIONED: 'PARTITIONED'; PARTITIONS: 'PARTITIONS'; PERCENTLIT: 'PERCENT'; PIVOT: 'PIVOT'; PLACING: 'PLACING'; POSITION: 'POSITION'; PRECEDING: 'PRECEDING'; PRIMARY: 'PRIMARY'; PRINCIPALS: 'PRINCIPALS'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUERY: 'QUERY'; RANGE: 'RANGE'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESPECT: 'RESPECT'; RESTRICT: 'RESTRICT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SCHEMA: 'SCHEMA'; SECOND: 'SECOND'; SECONDS: 'SECONDS'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHOW: 'SHOW'; SKEWED: 'SKEWED'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STRUCT: 'STRUCT'; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TO: 'TO'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNSET: 'UNSET'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUES: 'VALUES'; VIEW: 'VIEW'; WEEK: 'WEEK'; WEEKS: 'WEEKS'; WHEN: 'WHEN'; WHERE: 'WHERE'; WINDOW: 'WINDOW'; WITH: 'WITH'; YEAR: 'YEAR'; YEARS: 'YEARS'; //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; DIV: 'DIV'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; STRING : '\\'' ( ~('\\''|'\\\\') | ('\\\\' .) )* '\\'' | '""' ( ~('""'|'\\\\') | ('\\\\' .) )* '""' ; BIGINT_LITERAL : DIGIT+ 'L' ; SMALLINT_LITERAL : DIGIT+ 'S' ; TINYINT_LITERAL : DIGIT+ 'Y' ; INTEGER_VALUE : DIGIT+ ; DECIMAL_VALUE : DIGIT+ EXPONENT | DECIMAL_DIGITS EXPONENT? {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; SIMPLE_COMMENT : '--' ~[\\r\\n]* '\\r'? '\\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ; ",12094,False,2269.1495015328255,median "; Dn-FamiTracker exported music data: yakra.0cc ; ; Module header .word ft_song_list .word ft_instrument_list .word ft_sample_list .word ft_samples .word ft_groove_list .byte 0 ; flags .word 3600 ; NTSC speed .word 3000 ; PAL speed ; Instrument pointer list ft_instrument_list: .word ft_inst_0 .word ft_inst_1 .word ft_inst_2 .word ft_inst_3 .word ft_inst_4 .word ft_inst_5 .word ft_inst_6 .word ft_inst_7 .word ft_inst_8 .word ft_inst_9 .word ft_inst_10 .word ft_inst_11 .word ft_inst_12 .word ft_inst_13 .word ft_inst_14 .word ft_inst_15 .word ft_inst_16 .word ft_inst_17 .word ft_inst_18 .word ft_inst_19 ; Instruments ft_inst_0: .byte 0 .byte $11 .word ft_seq_2a03_0 .word ft_seq_2a03_4 ft_inst_1: .byte 0 .byte $15 .word ft_seq_2a03_5 .word ft_seq_2a03_2 .word ft_seq_2a03_9 ft_inst_2: .byte 0 .byte $11 .word ft_seq_2a03_10 .word ft_seq_2a03_14 ft_inst_3: .byte 0 .byte $00 ft_inst_4: .byte 0 .byte $07 .word ft_seq_2a03_15 .word ft_seq_2a03_11 .word ft_seq_2a03_7 ft_inst_5: .byte 0 .byte $03 .word ft_seq_2a03_20 .word ft_seq_2a03_16 ft_inst_6: .byte 0 .byte $03 .word ft_seq_2a03_25 .word ft_seq_2a03_21 ft_inst_7: .byte 0 .byte $13 .word ft_seq_2a03_30 .word ft_seq_2a03_26 .word ft_seq_2a03_19 ft_inst_8: .byte 0 .byte $03 .word ft_seq_2a03_35 .word ft_seq_2a03_21 ft_inst_9: .byte 0 .byte $17 .word ft_seq_2a03_5 .word ft_seq_2a03_31 .word ft_seq_2a03_2 .word ft_seq_2a03_4 ft_inst_10: .byte 0 .byte $11 .word ft_seq_2a03_40 .word ft_seq_2a03_4 ft_inst_11: .byte 0 .byte $13 .word ft_seq_2a03_0 .word ft_seq_2a03_31 .word ft_seq_2a03_4 ft_inst_12: .byte 0 .byte $15 .word ft_seq_2a03_0 .word ft_seq_2a03_12 .word ft_seq_2a03_29 ft_inst_13: .byte 0 .byte $03 .word ft_seq_2a03_45 .word ft_seq_2a03_36 ft_inst_14: .byte 0 .byte $03 .word ft_seq_2a03_50 .word ft_seq_2a03_41 ft_inst_15: .byte 0 .byte $07 .word ft_seq_2a03_35 .word ft_seq_2a03_11 .word ft_seq_2a03_7 ft_inst_16: .byte 0 .byte $13 .word ft_seq_2a03_60 .word ft_seq_2a03_51 .word ft_seq_2a03_24 ft_inst_17: .byte 0 .byte $13 .word ft_seq_2a03_70 .word ft_seq_2a03_61 .word ft_seq_2a03_19 ft_inst_18: .byte 0 .byte $15 .word ft_seq_2a03_75 .word ft_seq_2a03_2 .word ft_seq_2a03_9 ft_inst_19: .byte 0 .byte $15 .word ft_seq_2a03_80 .word ft_seq_2a03_12 .word ft_seq_2a03_29 ; Sequences ft_seq_2a03_0: .byte $03, $FF, $00, $00, $0F, $0D, $0E ft_seq_2a03_2: .byte $17, $0B, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $01, $01, $FF, $FF .byte $FD, $FD, $FF, $FF, $01, $01, $03 ft_seq_2a03_4: .byte $01, $FF, $00, $00, $01 ft_seq_2a03_5: .byte $0E, $FF, $00, $00, $06, $0A, $09, $0D, $0B, $0C, $0B, $0B, $0C, $0D, $0D, $0D, $0D, $0D ft_seq_2a03_7: .byte $10, $08, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $FF, $FF, $FF, $FF, $01, $01 ft_seq_2a03_9: .byte $04, $FF, $00, $00, $01, $00, $00, $00 ft_seq_2a03_10: .byte $01, $FF, $00, $00, $04 ft_seq_2a03_11: .byte $02, $FF, $00, $01, $26, $23 ft_seq_2a03_12: .byte $0C, $02, $00, $00, $00, $00, $FF, $FE, $00, $02, $01, $01, $02, $00, $FE, $FF ft_seq_2a03_14: .byte $01, $FF, $00, $00, $00 ft_seq_2a03_15: .byte $01, $FF, $00, $00, $0F ft_seq_2a03_16: .byte $0C, $FF, $00, $01, $0C, $09, $0A, $0A, $0A, $0B, $0B, $0B, $0C, $0C, $0D, $0D ft_seq_2a03_19: .byte $02, $FF, $00, $00, $01, $00 ft_seq_2a03_20: .byte $02, $FF, $00, $00, $0D, $00 ft_seq_2a03_21: .byte $02, $FF, $00, $01, $31, $2C ft_seq_2a03_24: .byte $02, $FF, $00, $00, $01, $00 ft_seq_2a03_25: .byte $01, $FF, $00, $00, $0F ft_seq_2a03_26: .byte $02, $01, $00, $01, $05, $0C ft_seq_2a03_29: .byte $03, $FF, $00, $00, $02, $00, $01 ft_seq_2a03_30: .byte $0A, $FF, $00, $00, $0D, $0D, $0A, $08, $07, $05, $04, $03, $01, $00 ft_seq_2a03_31: .byte $03, $01, $00, $02, $00, $07, $F9 ft_seq_2a03_35: .byte $03, $FF, $00, $00, $0F, $0F, $00 ft_seq_2a03_36: .byte $04, $FF, $00, $02, $00, $FD, $FE, $FF ft_seq_2a03_40: .byte $03, $FF, $00, $00, $0D, $0E, $06 ft_seq_2a03_41: .byte $03, $02, $00, $01, $09, $0B, $0C ft_seq_2a03_45: .byte $05, $FF, $00, $00, $0F, $0F, $0F, $0F, $00 ft_seq_2a03_50: .byte $39, $FF, $00, $00, $0E, $0C, $0B, $0A, $0A, $09, $08, $08, $07, $07, $06, $06, $05, $05, $05, $05 .byte $04, $04, $04, $03, $03, $03, $02, $02, $02, $02, $01, $01, $01, $01, $01, $00, $00, $00, $00, $00 .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .byte $00 ft_seq_2a03_51: .byte $02, $01, $00, $01, $0B, $0D ft_seq_2a03_60: .byte $09, $FF, $00, $00, $0C, $09, $08, $07, $05, $04, $03, $03, $00 ft_seq_2a03_61: .byte $02, $01, $00, $01, $05, $0C ft_seq_2a03_70: .byte $0E, $FF, $00, $00, $0D, $0D, $0A, $0D, $07, $05, $08, $03, $01, $00, $00, $00, $00, $00 ft_seq_2a03_75: .byte $09, $FF, $00, $00, $0C, $0B, $0B, $0C, $0D, $0D, $0D, $0D, $0D ft_seq_2a03_80: .byte $0F, $FF, $00, $00, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0E ; DPCM instrument list (pitch, sample index) ft_sample_list: ; DPCM samples list (location, size, bank) ft_samples: ; Groove list ft_groove_list: .byte $00 ; Grooves (size, terms) ; Song pointer list ft_song_list: .word ft_song_0 ; Song info ft_song_0: .word ft_s0_frames .byte 14 ; frame count .byte 48 ; pattern length .byte 4 ; speed .byte 180 ; tempo .byte 0 ; groove position .byte 0 ; initial bank ; ; Pattern and frame data for all songs below ; ; Bank 0 ft_s0_frames: .word ft_s0f0 .word ft_s0f1 .word ft_s0f2 .word ft_s0f3 .word ft_s0f4 .word ft_s0f5 .word ft_s0f6 .word ft_s0f7 .word ft_s0f8 .word ft_s0f9 .word ft_s0f10 .word ft_s0f11 .word ft_s0f12 .word ft_s0f13 ft_s0f0: .word ft_s0p6c0, ft_s0p10c1, ft_s0p10c2, ft_s0p3c3, ft_s0p0c4 ft_s0f1: .word ft_s0p7c0, ft_s0p11c1, ft_s0p11c2, ft_s0p8c3, ft_s0p0c4 ft_s0f2: .word ft_s0p0c0, ft_s0p0c1, ft_s0p0c2, ft_s0p0c3, ft_s0p0c4 ft_s0f3: .word ft_s0p0c0, ft_s0p1c1, ft_s0p2c2, ft_s0p1c3, ft_s0p0c4 ft_s0f4: .word ft_s0p0c0, ft_s0p0c1, ft_s0p0c2, ft_s0p0c3, ft_s0p0c4 ft_s0f5: .word ft_s0p0c0, ft_s0p2c1, ft_s0p8c2, ft_s0p2c3, ft_s0p0c4 ft_s0f6: .word ft_s0p1c0, ft_s0p3c1, ft_s0p1c2, ft_s0p0c3, ft_s0p0c4 ft_s0f7: .word ft_s0p1c0, ft_s0p4c1, ft_s0p3c2, ft_s0p1c3, ft_s0p0c4 ft_s0f8: .word ft_s0p1c0, ft_s0p3c1, ft_s0p1c2, ft_s0p0c3, ft_s0p0c4 ft_s0f9: .word ft_s0p1c0, ft_s0p5c1, ft_s0p9c2, ft_s0p2c3, ft_s0p0c4 ft_s0f10: .word ft_s0p2c0, ft_s0p6c1, ft_s0p4c2, ft_s0p4c3, ft_s0p0c4 ft_s0f11: .word ft_s0p3c0, ft_s0p7c1, ft_s0p5c2, ft_s0p5c3, ft_s0p0c4 ft_s0f12: .word ft_s0p4c0, ft_s0p8c1, ft_s0p6c2, ft_s0p6c3, ft_s0p0c4 ft_s0f13: .word ft_s0p5c0, ft_s0p9c1, ft_s0p7c2, ft_s0p7c3, ft_s0p0c4 ; Bank 0 ft_s0p0c0: .byte $82, $00, $E0, $F8, $2C, $E2, $FF, $1B, $E0, $F6, $27, $F1, $2C, $F6, $25, $E2, $FF, $1B, $E0, $F7 .byte $23, $F1, $25, $F6, $25, $F1, $23, $F5, $27, $E2, $FF, $1B, $E0, $F8, $2D, $E2, $FF, $1E, $E0, $F6 .byte $28, $E2, $FF, $1E, $E0, $F6, $24, $E2, $FF, $1E, $E0, $F8, $2D, $E2, $FF, $1E, $E0, $F6, $28, $F1 .byte $2D, $F6, $24, $E2, $FF, $1B, $E0, $F8, $2C, $E2, $FF, $1B, $E0, $F6, $27, $F1, $2C, $F6, $25, $E2 .byte $FF, $1B, $E0, $F7, $23, $F1, $25, $F6, $25, $F1, $23, $F5, $27, $E2, $FF, $1B, $E0, $F8, $2F, $E2 .byte $FF, $1C, $E0, $F6, $2A, $E2, $FF, $1C, $E0, $F6, $25, $E2, $FF, $1C, $E0, $F8, $2D, $E2, $FF, $19 .byte $E0, $F6, $28, $E2, $FF, $19, $E0, $F6, $23, $83, $E2, $FF, $19, $00 ; Bank 0 ft_s0p0c1: .byte $E2, $FF, $1B, $00, $7F, $02, $E1, $FA, $20, $00, $F1, $00, $00, $FC, $20, $01, $F1, $00, $01, $FA .byte $20, $00, $F1, $00, $00, $FC, $27, $04, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01 .byte $FA, $20, $00, $F1, $00, $00, $FC, $27, $01, $F1, $00, $01, $FA, $20, $00, $F1, $00, $00, $FC, $27 .byte $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01, $82, $00, $80, $24, $FA, $27, $F1 .byte $00, $FB, $28, $83, $F1, $00, $00 ; Bank 0 ft_s0p0c2: .byte $E4, $14, $00, $E3, $14, $01, $7F, $00, $E4, $14, $01, $E6, $20, $02, $7F, $00, $E4, $14, $00, $7F .byte $00, $12, $01, $7F, $01, $12, $01, $E8, $25, $03, $E4, $14, $01, $14, $00, $E3, $14, $01, $7F, $00 .byte $E4, $14, $01, $E6, $20, $02, $82, $00, $7F, $E4, $14, $7F, $15, $83, $E3, $15, $02, $E4, $15, $00 .byte $7F, $00, $E6, $12, $03, $E5, $12, $00, $7F, $00 ; Bank 0 ft_s0p0c3: .byte $E5, $FF, $1D, $03, $1D, $01, $80, $22, $1D, $03, $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D .byte $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5, $1D, $01, $1D, $03, $1D, $01, $80, $22, $1D, $03 .byte $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D, $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5 .byte $1D, $01 ; Bank 0 ft_s0p0c4: .byte $00, $2F ; Bank 0 ft_s0p1c0: .byte $82, $00, $E0, $F8, $2F, $E2, $FF, $1E, $E0, $F6, $2A, $F1, $2F, $F6, $28, $E2, $FF, $1E, $E0, $F7 .byte $27, $F1, $28, $F6, $28, $F1, $26, $F5, $2A, $E2, $FF, $1E, $E0, $F8, $30, $E2, $FF, $21, $E0, $F6 .byte $2B, $E2, $FF, $21, $E0, $F6, $26, $E2, $FF, $21, $E0, $F8, $30, $E2, $FF, $21, $E0, $F6, $2B, $F1 .byte $30, $F6, $26, $E2, $FF, $1E, $E0, $F8, $2F, $E2, $FF, $1E, $E0, $F6, $2A, $F1, $2F, $F6, $28, $E2 .byte $FF, $1E, $E0, $F7, $27, $F1, $28, $F6, $28, $F1, $26, $F5, $2A, $E2, $FF, $1E, $E0, $F8, $32, $E2 .byte $FF, $1F, $E0, $F6, $2D, $E2, $FF, $1F, $E0, $F6, $28, $E2, $FF, $1F, $E0, $F8, $30, $E2, $FF, $1C .byte $E0, $F6, $2B, $E2, $FF, $1C, $E0, $F6, $26, $83, $E2, $FF, $1C, $00 ; Bank 0 ft_s0p1c1: .byte $E1, $FC, $2A, $04, $F1, $00, $00, $FB, $25, $04, $F1, $00, $00, $FB, $28, $02, $F1, $00, $00, $FA .byte $27, $02, $F1, $00, $00, $FA, $25, $02, $82, $00, $F1, $00, $80, $24, $FA, $23, $F1, $00, $FA, $23 .byte $F1, $00, $FB, $25, $F8, $00, $83, $E1, $FC, $27, $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00 .byte $F1, $00, $05 ; Bank 0 ft_s0p1c2: .byte $E4, $17, $00, $E3, $17, $01, $7F, $00, $E4, $17, $01, $E6, $23, $02, $7F, $00, $E4, $17, $00, $7F .byte $00, $15, $01, $7F, $01, $15, $01, $E8, $28, $03, $E4, $17, $01, $17, $00, $E3, $17, $01, $7F, $00 .byte $E4, $17, $01, $E6, $23, $02, $82, $00, $7F, $E4, $17, $7F, $18, $83, $E3, $18, $02, $E4, $18, $00 .byte $7F, $00, $E6, $15, $03, $E5, $15, $00, $7F, $00 ; Bank 0 ft_s0p1c3: .byte $E5, $FF, $1D, $03, $1D, $01, $80, $22, $1D, $03, $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D .byte $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5, $1D, $01, $1D, $03, $1D, $01, $80, $22, $1D, $03 .byte $E5, $1D, $01, $1D, $03, $82, $01, $1D, $E7, $1D, $1D, $83, $1D, $01 ; Bank 0 ft_s0p2c0: .byte $82, $00, $E0, $F9, $33, $F1, $26, $F7, $2E, $F1, $33, $F7, $29, $F1, $2E, $F9, $33, $F1, $29, $F7 .byte $2E, $F1, $33, $F7, $29, $F1, $2E, $FA, $32, $FA, $00, $F9, $00, $F8, $00, $F7, $00, $F1, $00, $F9 .byte $33, $F1, $32, $F7, $2E, $F1, $33, $F7, $29, $F1, $2E, $F9, $32, $F6, $00, $F7, $00, $F8, $00, $F9 .byte $00, $F1, $00, $F9, $35, $F9, $00, $F8, $00, $F7, $00, $F6, $00, $F1, $00, $F9, $33, $F1, $35, $F8 .byte $35, $F1, $33, $F8, $33, $F1, $35, $F9, $2E, $F1, $33, $F8, $29, $F1, $2E, $F8, $24, $83, $F1, $29 .byte $00 ; Bank 0 ft_s0p2c1: .byte $E1, $FC, $2A, $04, $F1, $00, $00, $FB, $25, $04, $F1, $00, $00, $FB, $28, $02, $F1, $00, $00, $FA .byte $27, $02, $F1, $00, $00, $FA, $25, $02, $82, $00, $F1, $00, $80, $24, $FA, $24, $F1, $00, $FA, $24 .byte $F1, $00, $FB, $25, $F8, $00, $83, $E1, $FC, $27, $07, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00 .byte $F1, $00, $06 ; Bank 0 ft_s0p2c2: .byte $E4, $14, $00, $E3, $14, $01, $7F, $00, $E4, $14, $01, $E6, $20, $02, $7F, $00, $E4, $14, $00, $7F .byte $00, $12, $01, $7F, $01, $12, $01, $E8, $25, $03, $E4, $14, $01, $14, $00, $E3, $14, $01, $7F, $00 .byte $E4, $14, $01, $E6, $20, $02, $82, $00, $7F, $E4, $14, $7F, $15, $83, $E3, $15, $02, $E4, $15, $00 .byte $7F, $00, $E6, $12, $01, $12, $01, $E5, $12, $00, $7F, $00 ; Bank 0 ft_s0p2c3: .byte $E5, $FF, $1D, $03, $1D, $01, $80, $22, $1D, $03, $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D .byte $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5, $1D, $01, $F9, $1D, $03, $82, $01, $F7, $1D, $F9 .byte $1D, $F7, $1D, $F7, $1D, $83, $F9, $1D, $03, $F7, $1D, $01, $EE, $FF, $1D, $05 ; Bank 0 ft_s0p3c0: .byte $82, $00, $E0, $F9, $32, $F1, $25, $F7, $2D, $F1, $32, $F7, $28, $F1, $2D, $F9, $32, $F1, $28, $F7 .byte $2D, $F1, $32, $F7, $28, $F1, $2D, $FA, $31, $FA, $00, $F9, $00, $F8, $00, $F7, $00, $F1, $00, $F9 .byte $32, $F1, $31, $F7, $2D, $F1, $32, $F7, $28, $F1, $2D, $F9, $31, $F6, $00, $F7, $00, $F8, $00, $F9 .byte $00, $F1, $00, $F9, $34, $F9, $00, $F8, $00, $F7, $00, $F6, $00, $F1, $00, $F9, $32, $F1, $34, $F8 .byte $34, $F1, $32, $F8, $32, $F1, $34, $F9, $2D, $F1, $32, $F8, $28, $F1, $2D, $F8, $23, $83, $F1, $28 .byte $00 ; Bank 0 ft_s0p3c1: .byte $E1, $FF, $1E, $00, $7F, $02, $FA, $23, $00, $F1, $00, $00, $FC, $23, $01, $F1, $00, $01, $FA, $23 .byte $00, $F1, $00, $00, $FC, $2A, $04, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01, $FA .byte $23, $00, $F1, $00, $00, $FC, $2A, $01, $F1, $00, $01, $FA, $23, $00, $F1, $00, $00, $FC, $2A, $08 .byte $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01, $82, $00, $80, $24, $FA, $2A, $F1, $00 .byte $FB, $2B, $83, $F1, $00, $00 ; Bank 0 ft_s0p3c2: .byte $E4, $17, $00, $E3, $17, $01, $7F, $00, $E4, $17, $01, $E6, $23, $02, $7F, $00, $E4, $17, $00, $7F .byte $00, $15, $01, $7F, $01, $15, $01, $E8, $28, $03, $E4, $17, $01, $17, $00, $E3, $17, $01, $7F, $00 .byte $E4, $17, $01, $E6, $23, $02, $82, $00, $7F, $E4, $17, $7F, $18, $83, $E3, $18, $02, $E4, $18, $00 .byte $7F, $00, $E6, $15, $01, $15, $01, $E5, $15, $00, $7F, $00 ; Bank 0 ft_s0p3c3: .byte $EE, $FF, $1D, $05, $82, $01, $E5, $F8, $1D, $FA, $1D, $FC, $1D, $FF, $1D, $FF, $1D, $FF, $1D, $83 .byte $E7, $FF, $1D, $03, $E5, $1D, $19 ; Bank 0 ft_s0p4c0: .byte $82, $00, $E0, $F9, $25, $F1, $23, $F7, $23, $F1, $25, $F7, $25, $F1, $23, $F9, $27, $F1, $25, $F7 .byte $25, $F1, $27, $F7, $27, $F1, $25, $FA, $28, $F1, $27, $F8, $27, $F1, $28, $F8, $28, $F1, $27, $FA .byte $2A, $F1, $28, $F8, $28, $F1, $2A, $F8, $2A, $F1, $28, $FA, $2C, $F1, $2A, $F8, $2A, $F1, $2C, $F8 .byte $2C, $F1, $2A, $EC, $F9, $2E, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $E0, $FB .byte $2F, $F1, $2E, $F9, $2E, $F1, $2F, $F9, $2F, $F1, $2E, $EC, $FB, $31, $FB, $00, $FA, $00, $F9, $00 .byte $83, $F0, $00, $01 ; Bank 0 ft_s0p4c1: .byte $E1, $FC, $2D, $04, $F1, $00, $00, $FB, $28, $04, $F1, $00, $00, $FB, $2B, $02, $F1, $00, $00, $FA .byte $2A, $02, $F1, $00, $00, $FA, $28, $02, $82, $00, $F1, $00, $80, $24, $FA, $26, $F1, $00, $FA, $26 .byte $F1, $00, $FB, $28, $F8, $00, $83, $E1, $FC, $2A, $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00 .byte $F1, $00, $05 ; Bank 0 ft_s0p4c2: .byte $E6, $21, $01, $7F, $01, $82, $00, $E4, $21, $7F, $25, $7F, $27, $7F, $2C, $7F, $83, $E6, $2B, $04 .byte $82, $00, $7F, $E4, $22, $7F, $EF, $22, $7F, $E3, $22, $7F, $83, $E6, $2B, $04, $7F, $00, $2E, $04 .byte $7F, $00, $E3, $2B, $00, $22, $00, $E4, $22, $01, $EF, $22, $01, $ED, $26, $00, $E3, $20, $00, $E4 .byte $20, $01, $EF, $20, $01 ; Bank 0 ft_s0p4c3: .byte $EE, $FF, $1D, $03, $82, $01, $F8, $1D, $E5, $FD, $1D, $FE, $1D, $FF, $1D, $83, $EE, $1D, $05, $E7 .byte $1D, $01, $1D, $01, $1D, $01, $EE, $FF, $1D, $05, $FC, $1D, $05, $82, $01, $E5, $FA, $1D, $F6, $1D .byte $F6, $1D, $F9, $1D, $F8, $1D, $83, $F8, $1D, $01 ; Bank 0 ft_s0p5c0: .byte $82, $00, $80, $26, $FD, $33, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $FC, $33 .byte $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $EA, $F6, $29, $F7, $2A, $F8, $2C, $F9 .byte $2E, $FA, $2F, $FB, $31, $80, $26, $FD, $33, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82 .byte $00, $FC, $33, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $EA, $F6, $29, $F7, $2A .byte $F8, $2C, $F9, $2E, $FA, $2F, $FB, $31, $80, $26, $F8, $33, $F0, $00, $F9, $33, $F0, $00, $FA, $33 .byte $F0, $00, $FD, $33, $F9, $00, $F8, $00, $F7, $00, $F0, $00, $83, $86, $03, $00, $00 ; Bank 0 ft_s0p5c1: .byte $E1, $FC, $2D, $04, $F1, $00, $00, $FB, $28, $04, $F1, $00, $00, $FB, $2B, $02, $F1, $00, $00, $FA .byte $2A, $02, $F1, $00, $00, $FA, $28, $02, $82, $00, $F1, $00, $80, $24, $FA, $27, $F1, $00, $FA, $27 .byte $F1, $00, $FB, $28, $F8, $00, $83, $FC, $2A, $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1 .byte $00, $05 ; Bank 0 ft_s0p5c2: .byte $E6, $20, $01, $7F, $01, $82, $00, $E4, $20, $7F, $24, $7F, $26, $7F, $2B, $7F, $83, $E6, $2A, $04 .byte $82, $00, $7F, $E4, $21, $7F, $EF, $21, $7F, $E3, $21, $7F, $83, $E6, $2A, $04, $7F, $00, $2D, $04 .byte $7F, $00, $E3, $2B, $00, $21, $00, $E4, $21, $01, $EF, $21, $01, $ED, $26, $00, $E3, $1F, $00, $E4 .byte $1F, $01, $EF, $1F, $01 ; Bank 0 ft_s0p5c3: .byte $E7, $FF, $1D, $03, $82, $01, $E5, $FC, $1D, $FC, $1D, $FD, $1D, $FD, $1D, $83, $EE, $FF, $1D, $05 .byte $E7, $1D, $01, $1D, $01, $1D, $01, $EE, $FF, $1D, $05, $FC, $1D, $05, $82, $01, $E5, $FA, $1D, $F6 .byte $1D, $F6, $1D, $F9, $1D, $F6, $1D, $83, $F6, $1D, $01 ; Bank 0 ft_s0p6c0: .byte $82, $00, $E0, $FD, $37, $F1, $00, $FA, $32, $F1, $37, $FB, $2D, $F1, $32, $FB, $2C, $F1, $2D, $FC .byte $31, $F1, $2C, $FD, $36, $F1, $31, $FD, $35, $F1, $36, $FA, $30, $F1, $35, $FB, $2B, $F1, $30, $FB .byte $2A, $F1, $2B, $FC, $2F, $F1, $2A, $FD, $34, $86, $02, $F1, $2F, $83, $FB, $33, $17 ; Bank 0 ft_s0p6c1: .byte $80, $24, $F8, $20, $01, $7F, $01, $82, $00, $20, $7F, $20, $7F, $20, $7F, $20, $7F, $E0, $F8, $2D .byte $F8, $00, $F7, $00, $F6, $00, $F5, $00, $7F, $80, $24, $F8, $20, $7F, $20, $7F, $20, $7F, $E0, $F7 .byte $2D, $F4, $00, $F5, $00, $F6, $00, $F7, $00, $7F, $F7, $30, $F7, $00, $F6, $00, $F5, $00, $F4, $00 .byte $7F, $83, $80, $24, $F8, $1D, $03, $7F, $01, $F8, $20, $03, $7F, $01 ; Bank 0 ft_s0p6c2: .byte $E4, $1E, $03, $EF, $1E, $01, $E4, $22, $03, $EF, $22, $01, $E4, $21, $03, $EF, $21, $01, $E4, $20 .byte $03, $EF, $20, $01, $82, $00, $E6, $1B, $9B, $02, $00, $1B, $9B, $02, $00, $1B, $9B, $02, $00, $83 .byte $20, $03, $7F, $01, $82, $00, $1D, $9B, $02, $00, $1D, $9B, $02, $00, $1D, $9B, $02, $00, $83, $23 .byte $01, $23, $01, $E8, $23, $01 ; Bank 0 ft_s0p6c3: .byte $E5, $FF, $1D, $03, $1D, $01, $80, $20, $FC, $1D, $03, $E5, $FF, $1D, $01, $1D, $03, $1D, $01, $80 .byte $20, $FC, $1D, $03, $82, $01, $E5, $FF, $1D, $E7, $FC, $1D, $FC, $1D, $FC, $1D, $83, $EE, $FF, $1D .byte $05, $82, $01, $E7, $FC, $1D, $FC, $1D, $FC, $1D, $FF, $1D, $FF, $1D, $83, $FA, $1D, $01 ; Bank 0 ft_s0p7c0: .byte $E0, $FC, $33, $01, $F8, $00, $02, $F9, $00, $02, $FA, $00, $03, $82, $05, $EC, $F9, $33, $F8, $00 .byte $F7, $00, $F6, $00, $83, $F5, $00, $03, $82, $01, $F4, $00, $F3, $00, $F2, $00, $83, $F1, $00, $01 ; Bank 0 ft_s0p7c1: .byte $80, $24, $F8, $1F, $01, $7F, $01, $82, $00, $1F, $7F, $1F, $7F, $1F, $7F, $1F, $7F, $E0, $F8, $2C .byte $F8, $00, $F7, $00, $F6, $00, $F5, $00, $7F, $80, $24, $F8, $1F, $7F, $1F, $7F, $1F, $7F, $E0, $F7 .byte $2C, $F4, $00, $F5, $00, $F6, $00, $F7, $00, $7F, $F7, $2F, $F7, $00, $F6, $00, $F5, $00, $F4, $00 .byte $7F, $83, $80, $24, $F8, $1C, $03, $7F, $01, $F8, $1F, $03, $7F, $01 ; Bank 0 ft_s0p7c2: .byte $82, $00, $ED, $2B, $E3, $9B, $02, $25, $ED, $26, $E3, $9B, $02, $25, $ED, $1F, $7F, $2B, $E3, $9B .byte $02, $25, $ED, $26, $E3, $9B, $02, $25, $ED, $1F, $7F, $83, $E8, $25, $03, $EF, $25, $01, $E6, $25 .byte $03, $7F, $01, $25, $03, $EF, $25, $01, $E8, $25, $05, $82, $00, $E6, $25, $9B, $02, $00, $25, $9B .byte $02, $00, $25, $9B, $02, $00, $83, $25, $01, $25, $01, $E8, $25, $01 ; Bank 0 ft_s0p7c3: .byte $82, $01, $E5, $FF, $1D, $1D, $1D, $1D, $1D, $1D, $83, $EE, $1D, $03, $F7, $1D, $01, $E7, $FF, $1D .byte $05, $1D, $03, $E5, $1D, $01, $EE, $1D, $05, $82, $01, $E7, $FD, $1D, $FD, $1D, $FD, $1D, $FE, $1D .byte $FF, $1D, $83, $FF, $1D, $01 ; Bank 0 ft_s0p8c1: .byte $82, $00, $EB, $F8, $1B, $F6, $00, $F4, $00, $F2, $00, $83, $F1, $00, $01, $82, $00, $F9, $1D, $F7 .byte $00, $F5, $00, $F3, $00, $83, $F1, $00, $01, $82, $00, $FA, $1E, $F8, $00, $F6, $00, $F4, $00, $83 .byte $F1, $00, $01, $82, $00, $FB, $20, $F9, $00, $F7, $00, $F5, $00, $83, $F1, $00, $01, $82, $00, $E0 .byte $F8, $25, $F1, $00, $F8, $25, $F1, $00, $F8, $25, $F1, $00, $EC, $F9, $29, $F9, $00, $F8, $00, $F7 .byte $00, $83, $F0, $00, $01, $82, $00, $E0, $F9, $28, $F1, $00, $F9, $28, $F1, $00, $F9, $28, $F1, $00 .byte $EC, $FA, $2C, $FA, $00, $F9, $00, $F8, $00, $83, $F0, $00, $01 ; Bank 0 ft_s0p8c2: .byte $E4, $14, $00, $E3, $14, $01, $7F, $00, $E4, $14, $01, $E6, $20, $02, $7F, $00, $E4, $14, $00, $7F .byte $00, $12, $01, $7F, $01, $12, $01, $E8, $25, $03, $E4, $14, $01, $82, $00, $ED, $2B, $E3, $14, $E4 .byte $14, $7F, $83, $14, $01, $82, $00, $ED, $26, $E3, $20, $E4, $20, $7F, $20, $7F, $ED, $2B, $E3, $15 .byte $83, $E4, $15, $01, $15, $00, $7F, $00, $12, $04, $7F, $00 ; Bank 0 ft_s0p8c3: .byte $E5, $FF, $1D, $03, $FF, $1D, $01, $80, $20, $FF, $1D, $03, $E5, $FF, $1D, $01, $FF, $1D, $03, $FF .byte $1D, $01, $80, $20, $FF, $1D, $03, $E5, $FF, $1D, $01, $FF, $1D, $03, $FF, $1D, $01, $80, $20, $FF .byte $1D, $03, $E5, $FF, $1D, $01, $FF, $1D, $03, $FF, $1D, $01, $80, $20, $FF, $1D, $03, $E5, $FF, $1D .byte $01 ; Bank 0 ft_s0p9c1: .byte $82, $00, $E9, $FF, $22, $FC, $00, $F9, $00, $F6, $00, $83, $F1, $00, $01, $82, $00, $FE, $22, $FB .byte $00, $F8, $00, $F5, $00, $83, $F1, $00, $01, $7F, $05, $82, $00, $FF, $22, $FC, $00, $F9, $00, $F6 .byte $00, $83, $F1, $00, $01, $82, $00, $FE, $22, $FB, $00, $F8, $00, $F5, $00, $83, $F1, $00, $01, $7F .byte $05, $82, $00, $FC, $22, $F1, $00, $FC, $22, $F1, $00, $FC, $22, $F1, $00, $FF, $22, $FC, $00, $F9 .byte $00, $F6, $00, $83, $F0, $00, $01 ; Bank 0 ft_s0p9c2: .byte $E4, $17, $00, $E3, $17, $01, $7F, $00, $E4, $17, $01, $E6, $23, $02, $7F, $00, $E4, $17, $00, $7F .byte $00, $15, $01, $7F, $01, $15, $01, $E8, $28, $03, $E4, $17, $01, $82, $00, $ED, $2B, $E3, $17, $E4 .byte $17, $7F, $83, $17, $01, $ED, $26, $01, $82, $00, $E4, $17, $7F, $17, $7F, $ED, $2B, $E3, $18, $83 .byte $E4, $18, $01, $18, $00, $7F, $00, $15, $00, $E3, $15, $02, $E5, $15, $00, $7F, $00 ; Bank 0 ft_s0p10c1: .byte $82, $00, $80, $24, $FF, $23, $F1, $00, $FE, $28, $F1, $00, $FD, $2B, $F1, $00, $FD, $2A, $F1, $00 .byte $FE, $26, $F1, $00, $FF, $22, $F1, $00, $FF, $21, $F1, $00, $FE, $26, $F1, $00, $FD, $29, $F1, $00 .byte $FD, $28, $F1, $00, $FE, $24, $F1, $00, $FF, $21, $F1, $00, $83, $E1, $F9, $20, $17 ; Bank 0 ft_s0p10c2: .byte $82, $00, $ED, $2B, $7F, $26, $7F, $1F, $7F, $2B, $7F, $26, $7F, $1F, $7F, $2B, $7F, $26, $7F, $1F .byte $7F, $83, $E8, $0D, $03, $EF, $0D, $19 ; Bank 0 ft_s0p11c1: .byte $E1, $FC, $20, $01, $F9, $00, $05, $FA, $00, $03, $82, $05, $F9, $00, $F8, $00, $F7, $00, $F6, $00 .byte $83, $F5, $00, $03, $82, $01, $F4, $00, $F3, $00, $F2, $00, $83, $F1, $00, $01 ; Bank 0 ft_s0p11c2: .byte $E4, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F .byte $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F .byte $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F .byte $00, $20, $00, $7F, $00 ; DPCM samples (located at DPCM segment) ",16331,True,4197.84537442008,median "############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 5, 0x90 POLY: .quad 0x1, 0xC200000000000000 TWOONE: .quad 0x1, 0x100000000 SHUF_CONST: .quad 0x8090a0b0c0d0e0f, 0x1020304050607 MASK1: .quad 0xffffffffffffffff, 0x0 MASK2: .quad 0x0, 0xffffffffffffffff INC_1: .quad 1,0 .p2align 5, 0x90 .globl _l9_AesGcmPrecompute_avx _l9_AesGcmPrecompute_avx: movdqu (%rsi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 psrlq $(63), %xmm4 movdqa %xmm4, %xmm3 pslldq $(8), %xmm4 psrldq $(8), %xmm3 por %xmm4, %xmm0 pshufd $(36), %xmm3, %xmm4 pcmpeqd TWOONE(%rip), %xmm4 pand POLY(%rip), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm1 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm0, %xmm3 pxor %xmm1, %xmm5 pxor %xmm0, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm0, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm3 movdqa %xmm1, %xmm5 movdqa %xmm1, %xmm15 psllq $(63), %xmm3 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm3 pxor %xmm15, %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm1 pxor %xmm3, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm1, %xmm3 pxor %xmm2, %xmm5 pxor %xmm1, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm1, %xmm2 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm1, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm3 movdqa %xmm2, %xmm5 movdqa %xmm2, %xmm15 psllq $(63), %xmm3 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm3 pxor %xmm15, %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 movdqu %xmm0, (%rdi) movdqu %xmm1, (16)(%rdi) movdqu %xmm2, (32)(%rdi) vzeroupper ret .p2align 5, 0x90 .globl _l9_AesGcmMulGcm_avx _l9_AesGcmMulGcm_avx: movdqa (%rdi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa (%rsi), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, (%rdi) vzeroupper ret .p2align 5, 0x90 .globl _l9_AesGcmAuth_avx _l9_AesGcmAuth_avx: movdqa (%rdi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa (%rcx), %xmm1 movslq %edx, %rdx .p2align 5, 0x90 .Lauth_loopgas_3: movdqu (%rsi), %xmm2 pshufb SHUF_CONST(%rip), %xmm2 add $(16), %rsi pxor %xmm2, %xmm0 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 sub $(16), %rdx jnz .Lauth_loopgas_3 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, (%rdi) vzeroupper ret .p2align 5, 0x90 .globl _l9_AesGcmEnc_avx _l9_AesGcmEnc_avx: push %rbx sub $(128), %rsp mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx movdqa SHUF_CONST(%rip), %xmm4 movdqu (%rax), %xmm0 movdqu (%rbx), %xmm1 movdqu (%rcx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%rsp) movdqa %xmm1, (16)(%rsp) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm1, (64)(%rsp) movdqa %xmm1, (80)(%rsp) mov (168)(%rsp), %rbx movdqa (32)(%rbx), %xmm10 pshufd $(78), %xmm10, %xmm9 pxor %xmm10, %xmm9 movdqa %xmm9, (96)(%rsp) movslq %edx, %rdx mov %r9, %rcx mov %rdx, %rax and $(63), %rax and $(-64), %rdx jz .Lsingle_block_procgas_4 .p2align 5, 0x90 .Lblks4_loopgas_4: movdqa INC_1(%rip), %xmm6 movdqa SHUF_CONST(%rip), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm6, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm6, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm6, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm6, %xmm4 movdqa %xmm4, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 5, 0x90 .Lcipher4_loopgas_4: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher4_loopgas_4 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%rsp), %xmm0 movdqa %xmm4, (16)(%rsp) movdqu (%rsi), %xmm4 movdqu (16)(%rsi), %xmm5 movdqu (32)(%rsi), %xmm6 movdqu (48)(%rsi), %xmm7 add $(64), %rsi pxor %xmm4, %xmm0 movdqu %xmm0, (%rdi) pshufb SHUF_CONST(%rip), %xmm0 pxor (32)(%rsp), %xmm0 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%rdi) pshufb SHUF_CONST(%rip), %xmm1 pxor (48)(%rsp), %xmm1 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%rdi) pshufb SHUF_CONST(%rip), %xmm2 pxor (64)(%rsp), %xmm2 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%rdi) pshufb SHUF_CONST(%rip), %xmm3 pxor (80)(%rsp), %xmm3 add $(64), %rdi cmp $(64), %rdx je .Lcombine_hashgas_4 movdqa MASK1(%rip), %xmm14 pshufd $(78), %xmm0, %xmm6 movdqa %xmm0, %xmm5 pxor %xmm0, %xmm6 pclmulqdq $(0), %xmm10, %xmm0 pshufd $(78), %xmm1, %xmm13 movdqa %xmm1, %xmm12 pxor %xmm1, %xmm13 pclmulqdq $(17), %xmm10, %xmm5 pclmulqdq $(0), %xmm9, %xmm6 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 pshufd $(78), %xmm6, %xmm4 movdqa %xmm4, %xmm6 pand MASK2(%rip), %xmm4 pand %xmm14, %xmm6 pxor %xmm4, %xmm0 pxor %xmm6, %xmm5 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 pclmulqdq $(0), %xmm10, %xmm1 pxor %xmm4, %xmm0 psllq $(5), %xmm0 pxor %xmm4, %xmm0 psllq $(57), %xmm0 pshufd $(78), %xmm0, %xmm6 movdqa %xmm6, %xmm0 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm6 pand MASK2(%rip), %xmm0 pxor %xmm4, %xmm0 pxor %xmm6, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm0 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm6, %xmm0 psrlq $(1), %xmm0 pxor %xmm6, %xmm0 psrlq $(1), %xmm0 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 pxor %xmm1, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm1 pxor %xmm13, %xmm12 movdqa %xmm1, %xmm11 movdqa %xmm1, %xmm13 movdqa %xmm1, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm1 pxor %xmm11, %xmm12 movdqa %xmm1, %xmm13 psrlq $(5), %xmm13 pxor %xmm1, %xmm13 psrlq $(1), %xmm13 pxor %xmm1, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm1 pxor %xmm12, %xmm1 pshufd $(78), %xmm2, %xmm6 movdqa %xmm2, %xmm5 pxor %xmm2, %xmm6 pclmulqdq $(0), %xmm10, %xmm2 pshufd $(78), %xmm3, %xmm13 movdqa %xmm3, %xmm12 pxor %xmm3, %xmm13 pclmulqdq $(17), %xmm10, %xmm5 pclmulqdq $(0), %xmm9, %xmm6 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 pshufd $(78), %xmm6, %xmm4 movdqa %xmm4, %xmm6 pand MASK2(%rip), %xmm4 pand %xmm14, %xmm6 pxor %xmm4, %xmm2 pxor %xmm6, %xmm5 movdqa %xmm2, %xmm4 psllq $(1), %xmm2 pclmulqdq $(0), %xmm10, %xmm3 pxor %xmm4, %xmm2 psllq $(5), %xmm2 pxor %xmm4, %xmm2 psllq $(57), %xmm2 pshufd $(78), %xmm2, %xmm6 movdqa %xmm6, %xmm2 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm6 pand MASK2(%rip), %xmm2 pxor %xmm4, %xmm2 pxor %xmm6, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm2 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pxor %xmm3, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm3 pxor %xmm13, %xmm12 movdqa %xmm3, %xmm11 movdqa %xmm3, %xmm13 movdqa %xmm3, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm3 pxor %xmm11, %xmm12 movdqa %xmm3, %xmm13 psrlq $(5), %xmm13 pxor %xmm3, %xmm13 psrlq $(1), %xmm13 pxor %xmm3, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm3 pxor %xmm12, %xmm3 movdqa %xmm0, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm2, (64)(%rsp) movdqa %xmm3, (80)(%rsp) sub $(64), %rdx movdqa (%rsp), %xmm0 cmp $(64), %rdx jge .Lblks4_loopgas_4 .Lcombine_hashgas_4: movdqa (%rbx), %xmm8 movdqa (16)(%rbx), %xmm9 pshufd $(78), %xmm0, %xmm5 pshufd $(78), %xmm10, %xmm6 pxor %xmm0, %xmm5 pxor %xmm10, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm0, %xmm4 pclmulqdq $(0), %xmm10, %xmm0 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm10, %xmm4 pxor %xmm0, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm0 movdqa %xmm0, %xmm6 movdqa %xmm0, %xmm5 movdqa %xmm0, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm0 pxor %xmm6, %xmm4 movdqa %xmm0, %xmm5 psrlq $(5), %xmm5 pxor %xmm0, %xmm5 psrlq $(1), %xmm5 pxor %xmm0, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm0 pxor %xmm4, %xmm0 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm9, %xmm6 pxor %xmm1, %xmm5 pxor %xmm9, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm9, %xmm1 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm9, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm6 movdqa %xmm1, %xmm5 movdqa %xmm1, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm1 pxor %xmm6, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm8, %xmm6 pxor %xmm2, %xmm5 pxor %xmm8, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm8, %xmm2 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm8, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm6 movdqa %xmm2, %xmm5 movdqa %xmm2, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm2 pxor %xmm6, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 pxor %xmm1, %xmm3 pxor %xmm2, %xmm3 pshufd $(78), %xmm3, %xmm5 pshufd $(78), %xmm8, %xmm6 pxor %xmm3, %xmm5 pxor %xmm8, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm3, %xmm4 pclmulqdq $(0), %xmm8, %xmm3 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm8, %xmm4 pxor %xmm3, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm3 movdqa %xmm3, %xmm6 movdqa %xmm3, %xmm5 movdqa %xmm3, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm3 pxor %xmm6, %xmm4 movdqa %xmm3, %xmm5 psrlq $(5), %xmm5 pxor %xmm3, %xmm5 psrlq $(1), %xmm5 pxor %xmm3, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm3 pxor %xmm4, %xmm3 pxor %xmm0, %xmm3 movdqa %xmm3, (32)(%rsp) .Lsingle_block_procgas_4: test %rax, %rax jz .Lquitgas_4 .p2align 5, 0x90 .Lblk_loopgas_4: movdqa (%rsp), %xmm0 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb SHUF_CONST(%rip), %xmm1 pxor %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 5, 0x90 .Lcipher_loopgas_4: aesenc %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher_loopgas_4 aesenclast %xmm0, %xmm1 movdqa (16)(%rsp), %xmm0 movdqa %xmm1, (16)(%rsp) movdqu (%rsi), %xmm1 add $(16), %rsi pxor %xmm1, %xmm0 movdqu %xmm0, (%rdi) add $(16), %rdi pshufb SHUF_CONST(%rip), %xmm0 pxor (32)(%rsp), %xmm0 movdqa (%rbx), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 movdqa %xmm0, (32)(%rsp) sub $(16), %rax jg .Lblk_loopgas_4 .Lquitgas_4: movdqa (%rsp), %xmm0 movdqa (16)(%rsp), %xmm1 movdqa (32)(%rsp), %xmm2 mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx pshufb SHUF_CONST(%rip), %xmm0 movdqu %xmm0, (%rax) movdqu %xmm1, (%rbx) pshufb SHUF_CONST(%rip), %xmm2 movdqu %xmm2, (%rcx) add $(128), %rsp vzeroupper pop %rbx ret .p2align 5, 0x90 .globl _l9_AesGcmDec_avx _l9_AesGcmDec_avx: push %rbx sub $(128), %rsp mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx movdqa SHUF_CONST(%rip), %xmm4 movdqu (%rax), %xmm0 movdqu (%rbx), %xmm1 movdqu (%rcx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%rsp) movdqa %xmm1, (16)(%rsp) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm1, (64)(%rsp) movdqa %xmm1, (80)(%rsp) mov (168)(%rsp), %rbx movdqa (32)(%rbx), %xmm10 pshufd $(78), %xmm10, %xmm9 pxor %xmm10, %xmm9 movdqa %xmm9, (96)(%rsp) movslq %edx, %rdx mov %r9, %rcx mov %rdx, %rax and $(63), %rax and $(-64), %rdx jz .Lsingle_block_procgas_5 .p2align 5, 0x90 .Lblks4_loopgas_5: movdqa INC_1(%rip), %xmm6 movdqa SHUF_CONST(%rip), %xmm5 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, %xmm2 paddd INC_1(%rip), %xmm2 movdqa %xmm2, %xmm3 paddd INC_1(%rip), %xmm3 movdqa %xmm3, %xmm4 paddd INC_1(%rip), %xmm4 movdqa %xmm4, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 5, 0x90 .Lcipher4_loopgas_5: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher4_loopgas_5 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%rsp), %xmm0 movdqa %xmm4, (16)(%rsp) movdqu (%rsi), %xmm4 movdqu (16)(%rsi), %xmm5 movdqu (32)(%rsi), %xmm6 movdqu (48)(%rsi), %xmm7 add $(64), %rsi pxor %xmm4, %xmm0 movdqu %xmm0, (%rdi) pshufb SHUF_CONST(%rip), %xmm4 pxor (32)(%rsp), %xmm4 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%rdi) pshufb SHUF_CONST(%rip), %xmm5 pxor (48)(%rsp), %xmm5 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%rdi) pshufb SHUF_CONST(%rip), %xmm6 pxor (64)(%rsp), %xmm6 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%rdi) pshufb SHUF_CONST(%rip), %xmm7 pxor (80)(%rsp), %xmm7 add $(64), %rdi cmp $(64), %rdx je .Lcombine_hashgas_5 movdqa MASK1(%rip), %xmm14 pshufd $(78), %xmm4, %xmm2 movdqa %xmm4, %xmm1 pxor %xmm4, %xmm2 pclmulqdq $(0), %xmm10, %xmm4 pshufd $(78), %xmm5, %xmm13 movdqa %xmm5, %xmm12 pxor %xmm5, %xmm13 pclmulqdq $(17), %xmm10, %xmm1 pclmulqdq $(0), %xmm9, %xmm2 pxor %xmm4, %xmm2 pxor %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm0 movdqa %xmm0, %xmm2 pand MASK2(%rip), %xmm0 pand %xmm14, %xmm2 pxor %xmm0, %xmm4 pxor %xmm2, %xmm1 movdqa %xmm4, %xmm0 psllq $(1), %xmm4 pclmulqdq $(0), %xmm10, %xmm5 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 pshufd $(78), %xmm4, %xmm2 movdqa %xmm2, %xmm4 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm2 pand MASK2(%rip), %xmm4 pxor %xmm0, %xmm4 pxor %xmm2, %xmm1 movdqa %xmm4, %xmm2 psrlq $(5), %xmm4 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm2, %xmm4 psrlq $(1), %xmm4 pxor %xmm2, %xmm4 psrlq $(1), %xmm4 pxor %xmm2, %xmm4 pxor %xmm1, %xmm4 pxor %xmm5, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm5 pxor %xmm13, %xmm12 movdqa %xmm5, %xmm11 movdqa %xmm5, %xmm13 movdqa %xmm5, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm5 pxor %xmm11, %xmm12 movdqa %xmm5, %xmm13 psrlq $(5), %xmm13 pxor %xmm5, %xmm13 psrlq $(1), %xmm13 pxor %xmm5, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm5 pxor %xmm12, %xmm5 pshufd $(78), %xmm6, %xmm2 movdqa %xmm6, %xmm1 pxor %xmm6, %xmm2 pclmulqdq $(0), %xmm10, %xmm6 pshufd $(78), %xmm7, %xmm13 movdqa %xmm7, %xmm12 pxor %xmm7, %xmm13 pclmulqdq $(17), %xmm10, %xmm1 pclmulqdq $(0), %xmm9, %xmm2 pxor %xmm6, %xmm2 pxor %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm0 movdqa %xmm0, %xmm2 pand MASK2(%rip), %xmm0 pand %xmm14, %xmm2 pxor %xmm0, %xmm6 pxor %xmm2, %xmm1 movdqa %xmm6, %xmm0 psllq $(1), %xmm6 pclmulqdq $(0), %xmm10, %xmm7 pxor %xmm0, %xmm6 psllq $(5), %xmm6 pxor %xmm0, %xmm6 psllq $(57), %xmm6 pshufd $(78), %xmm6, %xmm2 movdqa %xmm2, %xmm6 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm2 pand MASK2(%rip), %xmm6 pxor %xmm0, %xmm6 pxor %xmm2, %xmm1 movdqa %xmm6, %xmm2 psrlq $(5), %xmm6 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 pxor %xmm1, %xmm6 pxor %xmm7, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm7 pxor %xmm13, %xmm12 movdqa %xmm7, %xmm11 movdqa %xmm7, %xmm13 movdqa %xmm7, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm7 pxor %xmm11, %xmm12 movdqa %xmm7, %xmm13 psrlq $(5), %xmm13 pxor %xmm7, %xmm13 psrlq $(1), %xmm13 pxor %xmm7, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm7 pxor %xmm12, %xmm7 movdqa %xmm4, (32)(%rsp) movdqa %xmm5, (48)(%rsp) movdqa %xmm6, (64)(%rsp) movdqa %xmm7, (80)(%rsp) sub $(64), %rdx movdqa (%rsp), %xmm0 cmp $(64), %rdx jge .Lblks4_loopgas_5 .Lcombine_hashgas_5: movdqa (%rbx), %xmm8 movdqa (16)(%rbx), %xmm9 pshufd $(78), %xmm4, %xmm2 pshufd $(78), %xmm10, %xmm0 pxor %xmm4, %xmm2 pxor %xmm10, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm4, %xmm1 pclmulqdq $(0), %xmm10, %xmm4 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm10, %xmm1 pxor %xmm4, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm4 movdqa %xmm4, %xmm0 movdqa %xmm4, %xmm2 movdqa %xmm4, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm4 pxor %xmm0, %xmm1 movdqa %xmm4, %xmm2 psrlq $(5), %xmm2 pxor %xmm4, %xmm2 psrlq $(1), %xmm2 pxor %xmm4, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm4 pxor %xmm1, %xmm4 pshufd $(78), %xmm5, %xmm2 pshufd $(78), %xmm9, %xmm0 pxor %xmm5, %xmm2 pxor %xmm9, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm5, %xmm1 pclmulqdq $(0), %xmm9, %xmm5 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm9, %xmm1 pxor %xmm5, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm5 movdqa %xmm5, %xmm0 movdqa %xmm5, %xmm2 movdqa %xmm5, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm5 pxor %xmm0, %xmm1 movdqa %xmm5, %xmm2 psrlq $(5), %xmm2 pxor %xmm5, %xmm2 psrlq $(1), %xmm2 pxor %xmm5, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm5 pxor %xmm1, %xmm5 pshufd $(78), %xmm6, %xmm2 pshufd $(78), %xmm8, %xmm0 pxor %xmm6, %xmm2 pxor %xmm8, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm6, %xmm1 pclmulqdq $(0), %xmm8, %xmm6 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm8, %xmm1 pxor %xmm6, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm6 movdqa %xmm6, %xmm0 movdqa %xmm6, %xmm2 movdqa %xmm6, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm6 pxor %xmm0, %xmm1 movdqa %xmm6, %xmm2 psrlq $(5), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm6 pxor %xmm1, %xmm6 pxor %xmm5, %xmm7 pxor %xmm6, %xmm7 pshufd $(78), %xmm7, %xmm2 pshufd $(78), %xmm8, %xmm0 pxor %xmm7, %xmm2 pxor %xmm8, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm7, %xmm1 pclmulqdq $(0), %xmm8, %xmm7 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm8, %xmm1 pxor %xmm7, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm7 movdqa %xmm7, %xmm0 movdqa %xmm7, %xmm2 movdqa %xmm7, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm7 pxor %xmm0, %xmm1 movdqa %xmm7, %xmm2 psrlq $(5), %xmm2 pxor %xmm7, %xmm2 psrlq $(1), %xmm2 pxor %xmm7, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm7 pxor %xmm1, %xmm7 pxor %xmm4, %xmm7 movdqa %xmm7, (32)(%rsp) .Lsingle_block_procgas_5: test %rax, %rax jz .Lquitgas_5 .p2align 5, 0x90 .Lblk_loopgas_5: movdqa (%rsp), %xmm0 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb SHUF_CONST(%rip), %xmm1 pxor %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 5, 0x90 .Lcipher_loopgas_5: aesenc %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher_loopgas_5 aesenclast %xmm0, %xmm1 movdqa (16)(%rsp), %xmm0 movdqa %xmm1, (16)(%rsp) movdqu (%rsi), %xmm1 add $(16), %rsi pxor %xmm1, %xmm0 movdqu %xmm0, (%rdi) add $(16), %rdi pshufb SHUF_CONST(%rip), %xmm1 pxor (32)(%rsp), %xmm1 movdqa (%rbx), %xmm0 pshufd $(78), %xmm1, %xmm4 pshufd $(78), %xmm0, %xmm2 pxor %xmm1, %xmm4 pxor %xmm0, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm1, %xmm3 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm0, %xmm3 pxor %xmm1, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 movdqa %xmm1, %xmm4 movdqa %xmm1, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm1 pxor %xmm2, %xmm3 movdqa %xmm1, %xmm4 psrlq $(5), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm1 pxor %xmm3, %xmm1 movdqa %xmm1, (32)(%rsp) sub $(16), %rax jg .Lblk_loopgas_5 .Lquitgas_5: movdqa (%rsp), %xmm0 movdqa (16)(%rsp), %xmm1 movdqa (32)(%rsp), %xmm2 mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx pshufb SHUF_CONST(%rip), %xmm0 movdqu %xmm0, (%rax) movdqu %xmm1, (%rbx) pshufb SHUF_CONST(%rip), %xmm2 movdqu %xmm2, (%rcx) add $(128), %rsp vzeroupper pop %rbx ret ",16253,True,4899.803047429573,median "lexer grammar UbigiaLexer; @header { #pragma warning disable CS0115 // CS0115: no suitable method found to override #pragma warning disable CS3021 // CS3021: The CLSCompliant attribute is not needed because the assembly does not have a CLSCompliant attribute // ReSharper disable InvalidXmlDocComment // ReSharper disable all } // Comments fragment COMMENT_PREFIX : '--'; COMMENT : COMMENT_PREFIX NO_NEWLINE*; // String fragment STRING_QUOTED_NON_EMPTY_DOUBLE : DOUBLEQUOTE (~[""\\r\\n\\u0085\\u2028\\u2029])+ DOUBLEQUOTE; fragment STRING_QUOTED_NON_EMPTY_SINGLE : SINGLEQUOTE (~['\\r\\n\\u0085\\u2028\\u2029])+ SINGLEQUOTE; STRING_QUOTED_NON_EMPTY : STRING_QUOTED_NON_EMPTY_DOUBLE | STRING_QUOTED_NON_EMPTY_SINGLE ; fragment STRING_QUOTED_DOUBLE : DOUBLEQUOTE (~[""\\r\\n\\u0085\\u2028\\u2029])* DOUBLEQUOTE; fragment STRING_QUOTED_SINGLE : SINGLEQUOTE (~['\\r\\n\\u0085\\u2028\\u2029])* SINGLEQUOTE; STRING_QUOTED : STRING_QUOTED_DOUBLE | STRING_QUOTED_SINGLE ; // ============================================================================ // Literals // Guids. GUID : GUID_BLOCK_8 MINUS? GUID_BLOCK_4 MINUS? GUID_BLOCK_4 MINUS? GUID_BLOCK_4 MINUS? GUID_BLOCK_8 GUID_BLOCK_4 ; fragment GUID_BLOCK_4 : HEX HEX HEX HEX ; fragment GUID_BLOCK_8 : HEX HEX HEX HEX HEX HEX HEX HEX ; // Bools BOOLEAN_LITERAL : TRUE | FALSE ; UBIGIA_IDENTIFIER : AMPERSAND GUID '.' GUID '.' GUID '.' DIGIT+ '.' DIGIT+ '.' DIGIT+ ; // Specials ======================================================================= NEWLINE : '\\r\\n' | '\\r' | '\\n' | '\\u0085' // ' | '\\u2028' //'' | '\\u2029' //'' ; WHITESPACE : UNICODE_CLASS_ZS //'' | '\\u0009' //'' | '\\u000B' //'' | '\\u000C' //'
' ; // ===================================================================================================================== // New implementation BYTE_ORDER_MARK: '\\u00EF\\u00BB\\u00BF'; // Characters. LETTER : LETTER_CHARACTER ; DIGIT : [0-9] ; HEX : [A-Fa-f] | DIGIT ; LPAREN : '('; RPAREN : ')'; LBRACE : '{'; RBRACE : '}'; LBRACK : '['; RBRACK : ']'; LCHEVR : '<'; RCHEVR : '>'; SEMI : ';'; COLON : ':'; COMMA : ','; DOT : '.'; MINUS : '-'; PLUS : '+'; FSLASH : '/'; BSLASH : '\\\\'; EQUALS : '='; AMPERSAND : '&'; ASTERIKS : '*'; DOLLAR : '$'; SINGLEQUOTE : '\\''; DOUBLEQUOTE : '""' ; HASHTAG : '#' ; QUESTION : '?' ; EXCLAMATION : '!' ; ATSIGN : '@' ; ROOT_SUBJECT_PREFIX : ('ROOT' | 'root' | 'Root'); TRUE : ('TRUE' | 'true' | 'True'); FALSE : ('FALSE' | 'false' | 'False'); ANNOTATION_NODE_ADD : 'node-add'; ANNOTATION_NODES_ADD : 'nodes-add'; ANNOTATION_NODE_LINK : 'node-link'; ANNOTATION_NODES_LINK : 'nodes-link'; ANNOTATION_NODE_REMOVE : 'node-remove'; ANNOTATION_NODES_REMOVE : 'nodes-remove'; ANNOTATION_NODE : 'node'; ANNOTATION_NODES : 'nodes'; ANNOTATION_NODE_UNLINK : 'node-unlink'; ANNOTATION_NODES_UNLINK : 'nodes-unlink'; ANNOTATION_NODE_SET : 'node-set'; ANNOTATION_NODE_CLEAR : 'node-clear'; HEADER_OPTION_NAMESPACE : ('namespace' | 'Namespace' | 'NAMESPACE'); HEADER_OPTION_CONTEXT : ('context' | 'Context' | 'CONTEXT'); VALUE_TYPE_OBJECT : 'object'; VALUE_TYPE_STRING : 'string'; VALUE_TYPE_BOOL : 'bool'; VALUE_TYPE_FLOAT : 'float'; VALUE_TYPE_INT : 'int'; VALUE_TYPE_DATETIME : 'datetime'; IDENTIFIER : IDENTIFIER_START_CHARACTER IDENTIFIER_PART_CHARACTER* ; fragment IDENTIFIER_START_CHARACTER : LETTER_CHARACTER | '_' ; fragment IDENTIFIER_PART_CHARACTER : LETTER_CHARACTER | DECIMAL_DIGIT_CHARACTER | CONNECTING_CHARACTER | COMBINING_CHARACTER | FORMATTING_CHARACTER ; // ===================================================================================================================== // Escape sequences. ESCAPED_SINGLEQUOTE : '\\\\\\''; ESCAPED_DOUBLEQUOTE : '\\\\""'; fragment SIMPLE_ESCAPE_SEQUENCE : '\\\\\\'' | '\\\\""' | '\\\\\\\\' | '\\\\0' | '\\\\a' | '\\\\b' | '\\\\f' | '\\\\n' | '\\\\r' | '\\\\t' | '\\\\v' ; fragment HEX_ESCAPE_SEQUENCE : '\\\\x' HEXDIGIT | '\\\\x' HEXDIGIT HEXDIGIT | '\\\\x' HEXDIGIT HEXDIGIT HEXDIGIT | '\\\\x' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT ; //B.1.5 Unicode Character Escape Sequences fragment UNICODE_ESCAPE_SEQUENCE : '\\\\u' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT | '\\\\U' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT ; // ===================================================================================================================== // Characters fragment COMMON_CHARACTER : SIMPLE_ESCAPE_SEQUENCE | HEX_ESCAPE_SEQUENCE | UNICODE_ESCAPE_SEQUENCE ; //'' // WARNING: ignores UNICODE_ESCAPE_SEQUENCE fragment LETTER_CHARACTER : UNICODE_CLASS_LU | UNICODE_CLASS_LL | UNICODE_CLASS_LT | UNICODE_CLASS_LM | UNICODE_CLASS_LO | UNICODE_CLASS_NL | UNICODE_ESCAPE_SEQUENCE ; //'' // WARNING: ignores UNICODE_ESCAPE_SEQUENCE fragment DECIMAL_DIGIT_CHARACTER : UNICODE_CLASS_ND | UNICODE_ESCAPE_SEQUENCE ; //'' // WARNING: ignores UNICODE_ESCAPE_SEQUENCE fragment CONNECTING_CHARACTER : UNICODE_CLASS_PC | UNICODE_ESCAPE_SEQUENCE ; //'' // WARNING: ignores UNICODE_ESCAPE_SEQUENCE fragment COMBINING_CHARACTER : UNICODE_CLASS_MN | UNICODE_CLASS_MC | UNICODE_ESCAPE_SEQUENCE ; //'' // WARNING: ignores UNICODE_ESCAPE_SEQUENCE fragment FORMATTING_CHARACTER : UNICODE_CLASS_CF | UNICODE_ESCAPE_SEQUENCE ; fragment HEXDIGIT : [0-9] | [A-F] | [a-f]; // ===================================================================================================================== // Unicode character classes: fragment UNICODE_CLASS_LU : '\\u0041'..'\\u005a' | '\\u00c0'..'\\u00d6' | '\\u00d8'..'\\u00de' | '\\u0100'..'\\u0136' | '\\u0139'..'\\u0147' | '\\u014a'..'\\u0178' | '\\u0179'..'\\u017d' | '\\u0181'..'\\u0182' | '\\u0184'..'\\u0186' | '\\u0187'..'\\u0189' | '\\u018a'..'\\u018b' | '\\u018e'..'\\u0191' | '\\u0193'..'\\u0194' | '\\u0196'..'\\u0198' | '\\u019c'..'\\u019d' | '\\u019f'..'\\u01a0' | '\\u01a2'..'\\u01a6' | '\\u01a7'..'\\u01a9' | '\\u01ac'..'\\u01ae' | '\\u01af'..'\\u01b1' | '\\u01b2'..'\\u01b3' | '\\u01b5'..'\\u01b7' | '\\u01b8'..'\\u01bc' | '\\u01c4'..'\\u01cd' | '\\u01cf'..'\\u01db' | '\\u01de'..'\\u01ee' | '\\u01f1'..'\\u01f4' | '\\u01f6'..'\\u01f8' | '\\u01fa'..'\\u0232' | '\\u023a'..'\\u023b' | '\\u023d'..'\\u023e' | '\\u0241'..'\\u0243' | '\\u0244'..'\\u0246' | '\\u0248'..'\\u024e' | '\\u0370'..'\\u0372' | '\\u0376'..'\\u037f' | '\\u0386'..'\\u0388' | '\\u0389'..'\\u038a' | '\\u038c'..'\\u038e' | '\\u038f'..'\\u0391' | '\\u0392'..'\\u03a1' | '\\u03a3'..'\\u03ab' | '\\u03cf'..'\\u03d2' | '\\u03d3'..'\\u03d4' | '\\u03d8'..'\\u03ee' | '\\u03f4'..'\\u03f7' | '\\u03f9'..'\\u03fa' | '\\u03fd'..'\\u042f' | '\\u0460'..'\\u0480' | '\\u048a'..'\\u04c0' | '\\u04c1'..'\\u04cd' | '\\u04d0'..'\\u052e' | '\\u0531'..'\\u0556' | '\\u10a0'..'\\u10c5' | '\\u10c7'..'\\u10cd' | '\\u1e00'..'\\u1e94' | '\\u1e9e'..'\\u1efe' | '\\u1f08'..'\\u1f0f' | '\\u1f18'..'\\u1f1d' | '\\u1f28'..'\\u1f2f' | '\\u1f38'..'\\u1f3f' | '\\u1f48'..'\\u1f4d' | '\\u1f59'..'\\u1f5f' | '\\u1f68'..'\\u1f6f' | '\\u1fb8'..'\\u1fbb' | '\\u1fc8'..'\\u1fcb' | '\\u1fd8'..'\\u1fdb' | '\\u1fe8'..'\\u1fec' | '\\u1ff8'..'\\u1ffb' | '\\u2102'..'\\u2107' | '\\u210b'..'\\u210d' | '\\u2110'..'\\u2112' | '\\u2115'..'\\u2119' | '\\u211a'..'\\u211d' | '\\u2124'..'\\u212a' | '\\u212b'..'\\u212d' | '\\u2130'..'\\u2133' | '\\u213e'..'\\u213f' | '\\u2145'..'\\u2183' | '\\u2c00'..'\\u2c2e' | '\\u2c60'..'\\u2c62' | '\\u2c63'..'\\u2c64' | '\\u2c67'..'\\u2c6d' | '\\u2c6e'..'\\u2c70' | '\\u2c72'..'\\u2c75' | '\\u2c7e'..'\\u2c80' | '\\u2c82'..'\\u2ce2' | '\\u2ceb'..'\\u2ced' | '\\u2cf2'..'\\ua640' | '\\ua642'..'\\ua66c' | '\\ua680'..'\\ua69a' | '\\ua722'..'\\ua72e' | '\\ua732'..'\\ua76e' | '\\ua779'..'\\ua77d' | '\\ua77e'..'\\ua786' | '\\ua78b'..'\\ua78d' | '\\ua790'..'\\ua792' | '\\ua796'..'\\ua7aa' | '\\ua7ab'..'\\ua7ad' | '\\ua7b0'..'\\ua7b1' | '\\uff21'..'\\uff3a' ; fragment UNICODE_CLASS_LL : '\\u0061'..'\\u007A' | '\\u00b5'..'\\u00df' | '\\u00e0'..'\\u00f6' | '\\u00f8'..'\\u00ff' | '\\u0101'..'\\u0137' | '\\u0138'..'\\u0148' | '\\u0149'..'\\u0177' | '\\u017a'..'\\u017e' | '\\u017f'..'\\u0180' | '\\u0183'..'\\u0185' | '\\u0188'..'\\u018c' | '\\u018d'..'\\u0192' | '\\u0195'..'\\u0199' | '\\u019a'..'\\u019b' | '\\u019e'..'\\u01a1' | '\\u01a3'..'\\u01a5' | '\\u01a8'..'\\u01aa' | '\\u01ab'..'\\u01ad' | '\\u01b0'..'\\u01b4' | '\\u01b6'..'\\u01b9' | '\\u01ba'..'\\u01bd' | '\\u01be'..'\\u01bf' | '\\u01c6'..'\\u01cc' | '\\u01ce'..'\\u01dc' | '\\u01dd'..'\\u01ef' | '\\u01f0'..'\\u01f3' | '\\u01f5'..'\\u01f9' | '\\u01fb'..'\\u0233' | '\\u0234'..'\\u0239' | '\\u023c'..'\\u023f' | '\\u0240'..'\\u0242' | '\\u0247'..'\\u024f' | '\\u0250'..'\\u0293' | '\\u0295'..'\\u02af' | '\\u0371'..'\\u0373' | '\\u0377'..'\\u037b' | '\\u037c'..'\\u037d' | '\\u0390'..'\\u03ac' | '\\u03ad'..'\\u03ce' | '\\u03d0'..'\\u03d1' | '\\u03d5'..'\\u03d7' | '\\u03d9'..'\\u03ef' | '\\u03f0'..'\\u03f3' | '\\u03f5'..'\\u03fb' | '\\u03fc'..'\\u0430' | '\\u0431'..'\\u045f' | '\\u0461'..'\\u0481' | '\\u048b'..'\\u04bf' | '\\u04c2'..'\\u04ce' | '\\u04cf'..'\\u052f' | '\\u0561'..'\\u0587' | '\\u1d00'..'\\u1d2b' | '\\u1d6b'..'\\u1d77' | '\\u1d79'..'\\u1d9a' | '\\u1e01'..'\\u1e95' | '\\u1e96'..'\\u1e9d' | '\\u1e9f'..'\\u1eff' | '\\u1f00'..'\\u1f07' | '\\u1f10'..'\\u1f15' | '\\u1f20'..'\\u1f27' | '\\u1f30'..'\\u1f37' | '\\u1f40'..'\\u1f45' | '\\u1f50'..'\\u1f57' | '\\u1f60'..'\\u1f67' | '\\u1f70'..'\\u1f7d' | '\\u1f80'..'\\u1f87' | '\\u1f90'..'\\u1f97' | '\\u1fa0'..'\\u1fa7' | '\\u1fb0'..'\\u1fb4' | '\\u1fb6'..'\\u1fb7' | '\\u1fbe'..'\\u1fc2' | '\\u1fc3'..'\\u1fc4' | '\\u1fc6'..'\\u1fc7' | '\\u1fd0'..'\\u1fd3' | '\\u1fd6'..'\\u1fd7' | '\\u1fe0'..'\\u1fe7' | '\\u1ff2'..'\\u1ff4' | '\\u1ff6'..'\\u1ff7' | '\\u210a'..'\\u210e' | '\\u210f'..'\\u2113' | '\\u212f'..'\\u2139' | '\\u213c'..'\\u213d' | '\\u2146'..'\\u2149' | '\\u214e'..'\\u2184' | '\\u2c30'..'\\u2c5e' | '\\u2c61'..'\\u2c65' | '\\u2c66'..'\\u2c6c' | '\\u2c71'..'\\u2c73' | '\\u2c74'..'\\u2c76' | '\\u2c77'..'\\u2c7b' | '\\u2c81'..'\\u2ce3' | '\\u2ce4'..'\\u2cec' | '\\u2cee'..'\\u2cf3' | '\\u2d00'..'\\u2d25' | '\\u2d27'..'\\u2d2d' | '\\ua641'..'\\ua66d' | '\\ua681'..'\\ua69b' | '\\ua723'..'\\ua72f' | '\\ua730'..'\\ua731' | '\\ua733'..'\\ua771' | '\\ua772'..'\\ua778' | '\\ua77a'..'\\ua77c' | '\\ua77f'..'\\ua787' | '\\ua78c'..'\\ua78e' | '\\ua791'..'\\ua793' | '\\ua794'..'\\ua795' | '\\ua797'..'\\ua7a9' | '\\ua7fa'..'\\uab30' | '\\uab31'..'\\uab5a' | '\\uab64'..'\\uab65' | '\\ufb00'..'\\ufb06' | '\\ufb13'..'\\ufb17' | '\\uff41'..'\\uff5a' ; fragment UNICODE_CLASS_LT : '\\u01c5'..'\\u01cb' | '\\u01f2'..'\\u1f88' | '\\u1f89'..'\\u1f8f' | '\\u1f98'..'\\u1f9f' | '\\u1fa8'..'\\u1faf' | '\\u1fbc'..'\\u1fcc' | '\\u1ffc'..'\\u1ffc' ; fragment UNICODE_CLASS_LM : '\\u02b0'..'\\u02c1' | '\\u02c6'..'\\u02d1' | '\\u02e0'..'\\u02e4' | '\\u02ec'..'\\u02ee' | '\\u0374'..'\\u037a' | '\\u0559'..'\\u0640' | '\\u06e5'..'\\u06e6' | '\\u07f4'..'\\u07f5' | '\\u07fa'..'\\u081a' | '\\u0824'..'\\u0828' | '\\u0971'..'\\u0e46' | '\\u0ec6'..'\\u10fc' | '\\u17d7'..'\\u1843' | '\\u1aa7'..'\\u1c78' | '\\u1c79'..'\\u1c7d' | '\\u1d2c'..'\\u1d6a' | '\\u1d78'..'\\u1d9b' | '\\u1d9c'..'\\u1dbf' | '\\u2071'..'\\u207f' | '\\u2090'..'\\u209c' | '\\u2c7c'..'\\u2c7d' | '\\u2d6f'..'\\u2e2f' | '\\u3005'..'\\u3031' | '\\u3032'..'\\u3035' | '\\u303b'..'\\u309d' | '\\u309e'..'\\u30fc' | '\\u30fd'..'\\u30fe' | '\\ua015'..'\\ua4f8' | '\\ua4f9'..'\\ua4fd' | '\\ua60c'..'\\ua67f' | '\\ua69c'..'\\ua69d' | '\\ua717'..'\\ua71f' | '\\ua770'..'\\ua788' | '\\ua7f8'..'\\ua7f9' | '\\ua9cf'..'\\ua9e6' | '\\uaa70'..'\\uaadd' | '\\uaaf3'..'\\uaaf4' | '\\uab5c'..'\\uab5f' | '\\uff70'..'\\uff9e' | '\\uff9f'..'\\uff9f' ; fragment UNICODE_CLASS_LO : '\\u00aa'..'\\u00ba' | '\\u01bb'..'\\u01c0' | '\\u01c1'..'\\u01c3' | '\\u0294'..'\\u05d0' | '\\u05d1'..'\\u05ea' | '\\u05f0'..'\\u05f2' | '\\u0620'..'\\u063f' | '\\u0641'..'\\u064a' | '\\u066e'..'\\u066f' | '\\u0671'..'\\u06d3' | '\\u06d5'..'\\u06ee' | '\\u06ef'..'\\u06fa' | '\\u06fb'..'\\u06fc' | '\\u06ff'..'\\u0710' | '\\u0712'..'\\u072f' | '\\u074d'..'\\u07a5' | '\\u07b1'..'\\u07ca' | '\\u07cb'..'\\u07ea' | '\\u0800'..'\\u0815' | '\\u0840'..'\\u0858' | '\\u08a0'..'\\u08b2' | '\\u0904'..'\\u0939' | '\\u093d'..'\\u0950' | '\\u0958'..'\\u0961' | '\\u0972'..'\\u0980' | '\\u0985'..'\\u098c' | '\\u098f'..'\\u0990' | '\\u0993'..'\\u09a8' | '\\u09aa'..'\\u09b0' | '\\u09b2'..'\\u09b6' | '\\u09b7'..'\\u09b9' | '\\u09bd'..'\\u09ce' | '\\u09dc'..'\\u09dd' | '\\u09df'..'\\u09e1' | '\\u09f0'..'\\u09f1' | '\\u0a05'..'\\u0a0a' | '\\u0a0f'..'\\u0a10' | '\\u0a13'..'\\u0a28' | '\\u0a2a'..'\\u0a30' | '\\u0a32'..'\\u0a33' | '\\u0a35'..'\\u0a36' | '\\u0a38'..'\\u0a39' | '\\u0a59'..'\\u0a5c' | '\\u0a5e'..'\\u0a72' | '\\u0a73'..'\\u0a74' | '\\u0a85'..'\\u0a8d' | '\\u0a8f'..'\\u0a91' | '\\u0a93'..'\\u0aa8' | '\\u0aaa'..'\\u0ab0' | '\\u0ab2'..'\\u0ab3' | '\\u0ab5'..'\\u0ab9' | '\\u0abd'..'\\u0ad0' | '\\u0ae0'..'\\u0ae1' | '\\u0b05'..'\\u0b0c' | '\\u0b0f'..'\\u0b10' | '\\u0b13'..'\\u0b28' | '\\u0b2a'..'\\u0b30' | '\\u0b32'..'\\u0b33' | '\\u0b35'..'\\u0b39' | '\\u0b3d'..'\\u0b5c' | '\\u0b5d'..'\\u0b5f' | '\\u0b60'..'\\u0b61' | '\\u0b71'..'\\u0b83' | '\\u0b85'..'\\u0b8a' | '\\u0b8e'..'\\u0b90' | '\\u0b92'..'\\u0b95' | '\\u0b99'..'\\u0b9a' | '\\u0b9c'..'\\u0b9e' | '\\u0b9f'..'\\u0ba3' | '\\u0ba4'..'\\u0ba8' | '\\u0ba9'..'\\u0baa' | '\\u0bae'..'\\u0bb9' | '\\u0bd0'..'\\u0c05' | '\\u0c06'..'\\u0c0c' | '\\u0c0e'..'\\u0c10' | '\\u0c12'..'\\u0c28' | '\\u0c2a'..'\\u0c39' | '\\u0c3d'..'\\u0c58' | '\\u0c59'..'\\u0c60' | '\\u0c61'..'\\u0c85' | '\\u0c86'..'\\u0c8c' | '\\u0c8e'..'\\u0c90' | '\\u0c92'..'\\u0ca8' | '\\u0caa'..'\\u0cb3' | '\\u0cb5'..'\\u0cb9' | '\\u0cbd'..'\\u0cde' | '\\u0ce0'..'\\u0ce1' | '\\u0cf1'..'\\u0cf2' | '\\u0d05'..'\\u0d0c' | '\\u0d0e'..'\\u0d10' | '\\u0d12'..'\\u0d3a' | '\\u0d3d'..'\\u0d4e' | '\\u0d60'..'\\u0d61' | '\\u0d7a'..'\\u0d7f' | '\\u0d85'..'\\u0d96' | '\\u0d9a'..'\\u0db1' | '\\u0db3'..'\\u0dbb' | '\\u0dbd'..'\\u0dc0' | '\\u0dc1'..'\\u0dc6' | '\\u0e01'..'\\u0e30' | '\\u0e32'..'\\u0e33' | '\\u0e40'..'\\u0e45' | '\\u0e81'..'\\u0e82' | '\\u0e84'..'\\u0e87' | '\\u0e88'..'\\u0e8a' | '\\u0e8d'..'\\u0e94' | '\\u0e95'..'\\u0e97' | '\\u0e99'..'\\u0e9f' | '\\u0ea1'..'\\u0ea3' | '\\u0ea5'..'\\u0ea7' | '\\u0eaa'..'\\u0eab' | '\\u0ead'..'\\u0eb0' | '\\u0eb2'..'\\u0eb3' | '\\u0ebd'..'\\u0ec0' | '\\u0ec1'..'\\u0ec4' | '\\u0edc'..'\\u0edf' | '\\u0f00'..'\\u0f40' | '\\u0f41'..'\\u0f47' | '\\u0f49'..'\\u0f6c' | '\\u0f88'..'\\u0f8c' | '\\u1000'..'\\u102a' | '\\u103f'..'\\u1050' | '\\u1051'..'\\u1055' | '\\u105a'..'\\u105d' | '\\u1061'..'\\u1065' | '\\u1066'..'\\u106e' | '\\u106f'..'\\u1070' | '\\u1075'..'\\u1081' | '\\u108e'..'\\u10d0' | '\\u10d1'..'\\u10fa' | '\\u10fd'..'\\u1248' | '\\u124a'..'\\u124d' | '\\u1250'..'\\u1256' | '\\u1258'..'\\u125a' | '\\u125b'..'\\u125d' | '\\u1260'..'\\u1288' | '\\u128a'..'\\u128d' | '\\u1290'..'\\u12b0' | '\\u12b2'..'\\u12b5' | '\\u12b8'..'\\u12be' | '\\u12c0'..'\\u12c2' | '\\u12c3'..'\\u12c5' | '\\u12c8'..'\\u12d6' | '\\u12d8'..'\\u1310' | '\\u1312'..'\\u1315' | '\\u1318'..'\\u135a' | '\\u1380'..'\\u138f' | '\\u13a0'..'\\u13f4' | '\\u1401'..'\\u166c' | '\\u166f'..'\\u167f' | '\\u1681'..'\\u169a' | '\\u16a0'..'\\u16ea' | '\\u16f1'..'\\u16f8' | '\\u1700'..'\\u170c' | '\\u170e'..'\\u1711' | '\\u1720'..'\\u1731' | '\\u1740'..'\\u1751' | '\\u1760'..'\\u176c' | '\\u176e'..'\\u1770' | '\\u1780'..'\\u17b3' | '\\u17dc'..'\\u1820' | '\\u1821'..'\\u1842' | '\\u1844'..'\\u1877' | '\\u1880'..'\\u18a8' | '\\u18aa'..'\\u18b0' | '\\u18b1'..'\\u18f5' | '\\u1900'..'\\u191e' | '\\u1950'..'\\u196d' | '\\u1970'..'\\u1974' | '\\u1980'..'\\u19ab' | '\\u19c1'..'\\u19c7' | '\\u1a00'..'\\u1a16' | '\\u1a20'..'\\u1a54' | '\\u1b05'..'\\u1b33' | '\\u1b45'..'\\u1b4b' | '\\u1b83'..'\\u1ba0' | '\\u1bae'..'\\u1baf' | '\\u1bba'..'\\u1be5' | '\\u1c00'..'\\u1c23' | '\\u1c4d'..'\\u1c4f' | '\\u1c5a'..'\\u1c77' | '\\u1ce9'..'\\u1cec' | '\\u1cee'..'\\u1cf1' | '\\u1cf5'..'\\u1cf6' | '\\u2135'..'\\u2138' | '\\u2d30'..'\\u2d67' | '\\u2d80'..'\\u2d96' | '\\u2da0'..'\\u2da6' | '\\u2da8'..'\\u2dae' | '\\u2db0'..'\\u2db6' | '\\u2db8'..'\\u2dbe' | '\\u2dc0'..'\\u2dc6' | '\\u2dc8'..'\\u2dce' | '\\u2dd0'..'\\u2dd6' | '\\u2dd8'..'\\u2dde' | '\\u3006'..'\\u303c' | '\\u3041'..'\\u3096' | '\\u309f'..'\\u30a1' | '\\u30a2'..'\\u30fa' | '\\u30ff'..'\\u3105' | '\\u3106'..'\\u312d' | '\\u3131'..'\\u318e' | '\\u31a0'..'\\u31ba' | '\\u31f0'..'\\u31ff' | '\\u3400'..'\\u4db5' | '\\u4e00'..'\\u9fcc' | '\\ua000'..'\\ua014' | '\\ua016'..'\\ua48c' | '\\ua4d0'..'\\ua4f7' | '\\ua500'..'\\ua60b' | '\\ua610'..'\\ua61f' | '\\ua62a'..'\\ua62b' | '\\ua66e'..'\\ua6a0' | '\\ua6a1'..'\\ua6e5' | '\\ua7f7'..'\\ua7fb' | '\\ua7fc'..'\\ua801' | '\\ua803'..'\\ua805' | '\\ua807'..'\\ua80a' | '\\ua80c'..'\\ua822' | '\\ua840'..'\\ua873' | '\\ua882'..'\\ua8b3' | '\\ua8f2'..'\\ua8f7' | '\\ua8fb'..'\\ua90a' | '\\ua90b'..'\\ua925' | '\\ua930'..'\\ua946' | '\\ua960'..'\\ua97c' | '\\ua984'..'\\ua9b2' | '\\ua9e0'..'\\ua9e4' | '\\ua9e7'..'\\ua9ef' | '\\ua9fa'..'\\ua9fe' | '\\uaa00'..'\\uaa28' | '\\uaa40'..'\\uaa42' | '\\uaa44'..'\\uaa4b' | '\\uaa60'..'\\uaa6f' | '\\uaa71'..'\\uaa76' | '\\uaa7a'..'\\uaa7e' | '\\uaa7f'..'\\uaaaf' | '\\uaab1'..'\\uaab5' | '\\uaab6'..'\\uaab9' | '\\uaaba'..'\\uaabd' | '\\uaac0'..'\\uaac2' | '\\uaadb'..'\\uaadc' | '\\uaae0'..'\\uaaea' | '\\uaaf2'..'\\uab01' | '\\uab02'..'\\uab06' | '\\uab09'..'\\uab0e' | '\\uab11'..'\\uab16' | '\\uab20'..'\\uab26' | '\\uab28'..'\\uab2e' | '\\uabc0'..'\\uabe2' | '\\uac00'..'\\ud7a3' | '\\ud7b0'..'\\ud7c6' | '\\ud7cb'..'\\ud7fb' | '\\uf900'..'\\ufa6d' | '\\ufa70'..'\\ufad9' | '\\ufb1d'..'\\ufb1f' | '\\ufb20'..'\\ufb28' | '\\ufb2a'..'\\ufb36' | '\\ufb38'..'\\ufb3c' | '\\ufb3e'..'\\ufb40' | '\\ufb41'..'\\ufb43' | '\\ufb44'..'\\ufb46' | '\\ufb47'..'\\ufbb1' | '\\ufbd3'..'\\ufd3d' | '\\ufd50'..'\\ufd8f' | '\\ufd92'..'\\ufdc7' | '\\ufdf0'..'\\ufdfb' | '\\ufe70'..'\\ufe74' | '\\ufe76'..'\\ufefc' | '\\uff66'..'\\uff6f' | '\\uff71'..'\\uff9d' | '\\uffa0'..'\\uffbe' | '\\uffc2'..'\\uffc7' | '\\uffca'..'\\uffcf' | '\\uffd2'..'\\uffd7' | '\\uffda'..'\\uffdc' ; fragment UNICODE_CLASS_NL : '\\u16EE' // RUNIC ARLAUG SYMBOL | '\\u16EF' // RUNIC TVIMADUR SYMBOL | '\\u16F0' // RUNIC BELGTHOR SYMBOL | '\\u2160' // ROMAN NUMERAL ONE | '\\u2161' // ROMAN NUMERAL TWO | '\\u2162' // ROMAN NUMERAL THREE | '\\u2163' // ROMAN NUMERAL FOUR | '\\u2164' // ROMAN NUMERAL FIVE | '\\u2165' // ROMAN NUMERAL SIX | '\\u2166' // ROMAN NUMERAL SEVEN | '\\u2167' // ROMAN NUMERAL EIGHT | '\\u2168' // ROMAN NUMERAL NINE | '\\u2169' // ROMAN NUMERAL TEN | '\\u216A' // ROMAN NUMERAL ELEVEN | '\\u216B' // ROMAN NUMERAL TWELVE | '\\u216C' // ROMAN NUMERAL FIFTY | '\\u216D' // ROMAN NUMERAL ONE HUNDRED | '\\u216E' // ROMAN NUMERAL FIVE HUNDRED | '\\u216F' // ROMAN NUMERAL ONE THOUSAND ; fragment UNICODE_CLASS_MN : '\\u0300' // COMBINING GRAVE ACCENT | '\\u0301' // COMBINING ACUTE ACCENT | '\\u0302' // COMBINING CIRCUMFLEX ACCENT | '\\u0303' // COMBINING TILDE | '\\u0304' // COMBINING MACRON | '\\u0305' // COMBINING OVERLINE | '\\u0306' // COMBINING BREVE | '\\u0307' // COMBINING DOT ABOVE | '\\u0308' // COMBINING DIAERESIS | '\\u0309' // COMBINING HOOK ABOVE | '\\u030A' // COMBINING RING ABOVE | '\\u030B' // COMBINING DOUBLE ACUTE ACCENT | '\\u030C' // COMBINING CARON | '\\u030D' // COMBINING VERTICAL LINE ABOVE | '\\u030E' // COMBINING DOUBLE VERTICAL LINE ABOVE | '\\u030F' // COMBINING DOUBLE GRAVE ACCENT | '\\u0310' // COMBINING CANDRABINDU ; fragment UNICODE_CLASS_MC : '\\u0903' // DEVANAGARI SIGN VISARGA | '\\u093E' // DEVANAGARI VOWEL SIGN AA | '\\u093F' // DEVANAGARI VOWEL SIGN I | '\\u0940' // DEVANAGARI VOWEL SIGN II | '\\u0949' // DEVANAGARI VOWEL SIGN CANDRA O | '\\u094A' // DEVANAGARI VOWEL SIGN SHORT O | '\\u094B' // DEVANAGARI VOWEL SIGN O | '\\u094C' // DEVANAGARI VOWEL SIGN AU ; fragment UNICODE_CLASS_CF : '\\u00AD' // SOFT HYPHEN | '\\u0600' // ARABIC NUMBER SIGN | '\\u0601' // ARABIC SIGN SANAH | '\\u0602' // ARABIC FOOTNOTE MARKER | '\\u0603' // ARABIC SIGN SAFHA | '\\u06DD' // ARABIC END OF AYAH ; fragment UNICODE_CLASS_PC : '\\u005F' // LOW LINE | '\\u203F' // UNDERTIE | '\\u2040' // CHARACTER TIE | '\\u2054' // INVERTED UNDERTIE | '\\uFE33' // PRESENTATION FORM FOR VERTICAL LOW LINE | '\\uFE34' // PRESENTATION FORM FOR VERTICAL WAVY LOW LINE | '\\uFE4D' // DASHED LOW LINE | '\\uFE4E' // CENTRELINE LOW LINE | '\\uFE4F' // WAVY LOW LINE | '\\uFF3F' // FULLWIDTH LOW LINE ; fragment UNICODE_CLASS_ND : '\\u0030'..'\\u0039' | '\\u0660'..'\\u0669' | '\\u06f0'..'\\u06f9' | '\\u07c0'..'\\u07c9' | '\\u0966'..'\\u096f' | '\\u09e6'..'\\u09ef' | '\\u0a66'..'\\u0a6f' | '\\u0ae6'..'\\u0aef' | '\\u0b66'..'\\u0b6f' | '\\u0be6'..'\\u0bef' | '\\u0c66'..'\\u0c6f' | '\\u0ce6'..'\\u0cef' | '\\u0d66'..'\\u0d6f' | '\\u0de6'..'\\u0def' | '\\u0e50'..'\\u0e59' | '\\u0ed0'..'\\u0ed9' | '\\u0f20'..'\\u0f29' | '\\u1040'..'\\u1049' | '\\u1090'..'\\u1099' | '\\u17e0'..'\\u17e9' | '\\u1810'..'\\u1819' | '\\u1946'..'\\u194f' | '\\u19d0'..'\\u19d9' | '\\u1a80'..'\\u1a89' | '\\u1a90'..'\\u1a99' | '\\u1b50'..'\\u1b59' | '\\u1bb0'..'\\u1bb9' | '\\u1c40'..'\\u1c49' | '\\u1c50'..'\\u1c59' | '\\ua620'..'\\ua629' | '\\ua8d0'..'\\ua8d9' | '\\ua900'..'\\ua909' | '\\ua9d0'..'\\ua9d9' | '\\ua9f0'..'\\ua9f9' | '\\uaa50'..'\\uaa59' | '\\uabf0'..'\\uabf9' | '\\uff10'..'\\uff19' ; fragment UNICODE_CLASS_ZS : '\\u0020' // SPACE | '\\u00A0' // NO_BREAK SPACE | '\\u1680' // OGHAM SPACE MARK | '\\u180E' // MONGOLIAN VOWEL SEPARATOR | '\\u2000' // EN QUAD | '\\u2001' // EM QUAD | '\\u2002' // EN SPACE | '\\u2003' // EM SPACE | '\\u2004' // THREE_PER_EM SPACE | '\\u2005' // FOUR_PER_EM SPACE | '\\u2006' // SIX_PER_EM SPACE | '\\u2008' // PUNCTUATION SPACE | '\\u2009' // THIN SPACE | '\\u200A' // HAIR SPACE | '\\u202F' // NARROW NO_BREAK SPACE | '\\u3000' // IDEOGRAPHIC SPACE | '\\u205F' // MEDIUM MATHEMATICAL SPACE ; // ================================================================== NO_NEWLINE : ~[\\r\\n] ; NO_SINGLEQUOTE : ~['] ; NO_DOUBLEQUOTE : ~[""] ; NO_LBRACES : ~[{] ; ",12306,True,3362.189178104412,median " grammar XQuery; xpath : ( module )? EOF ; module : ( versionDecl )? ( libraryModule | mainModule ) ; versionDecl : 'xquery' 'version' STRING_LITERAL ('encoding' STRING_LITERAL)? separator ; mainModule : (xqdocComment)? prolog queryBody ; libraryModule : (xqdocComment)? moduleDecl prolog ; moduleDecl : 'module' 'namespace'ncnameOrKeyword EQstrippedStringLiteral separator ; /* * Note, the prolog production does not enforce the ordering requirements of the October * 2004 spec. This was the easiest way to handle some non-determinism problems, since we * are assuming for xqDoc that we are getting valid XQuery. */ prolog : ( ( boundarySpaceDecl | defaultCollationDecl | baseUriDecl | constructionDecl | orderingModeDecl | emptyOrderingDecl | copyNamespacesDecl | schemaImport | moduleImport | moduleImport | namespaceDecl | setterOld | varDecl | varDecl | functionDecl | functionDecl | optionDecl ) separator )* ; setter : ( ( boundarySpaceDecl | defaultCollationDecl | baseUriDecl | constructionDecl | orderingModeDecl | emptyOrderingDecl | copyNamespacesDecl ) separator ) ; setterOld : ( 'declare' 'default' ( ( 'element' 'namespace' STRING_LITERAL ) | ( 'function' 'namespace'strippedStringLiteral ) ) ) ; separator : SEMICOLON ; namespaceDecl : 'declare' 'namespace'ncnameOrKeyword EQstrippedStringLiteral ; boundarySpaceDecl : 'declare' 'boundary-space' ('preserve' | 'strip') ; optionDecl : 'declare' 'option' qName STRING_LITERAL ; orderingModeDecl : 'declare' 'ordering' ('ordered' | 'unordered') ; emptyOrderingDecl : 'declare' 'default' 'order' 'empty' ( 'greatest' | 'least' ) ; copyNamespacesDecl : 'declare' 'copy-namespaces' ('preserve' | 'no-preserve') COMMA ('inherit' | 'no-inherit' ) ; defaultCollationDecl : 'declare' 'default' 'collation' STRING_LITERAL ; baseUriDecl : 'declare' 'base-uri' STRING_LITERAL ; schemaImport : 'import' 'schema' ( schemaPrefix )? STRING_LITERAL ( 'at' STRING_LITERAL (COMMA STRING_LITERAL)*)? ; schemaPrefix : ('namespace'ncnameOrKeyword EQ) | ('default' 'element' 'namespace') ; moduleImport : (xqdocComment)? 'import' 'module' ( 'namespace'ncnameOrKeyword EQ )?strippedStringLiteral ('at'STRING_LITERAL (COMMA STRING_LITERAL)* )? ; varDecl : (xqdocComment)? 'declare' 'variable' DOLLARqName( typeDeclaration )? ( (COLON EQ exprSingle ) | 'external' ) ; constructionDecl : 'declare' 'construction' ('preserve' | 'strip') ; annotations : (annotation)* ; annotation : MODqName (LPAREN annotList RPAREN)? ; annotList : annotationParam ( COMMA annotationParam )* ; annotationParam :STRING_LITERAL ; functionDecl : (xqdocComment)? 'declare' (annotations)? 'function'qName LPAREN ( paramList )? RPAREN ( returnType )? ( functionBody | 'external' ) ; returnType : 'as' sequenceType ; functionBody : LCURLY expr RCURLY ; paramList : param ( COMMA param )* ; param : DOLLARqName ( typeDeclaration )? ; enclosedExpr : LCURLY expr RCURLY ; queryBody : expr ; expr : exprSingle ( ARROW exprSingle )* ( BANG exprSingle )* ( COMMA exprSingle ( ARROW exprSingle )* ( BANG exprSingle )* )* ; exprSingle : flworExpr | quantifiedExpr | switchExpr | typeswitchExpr | existUpdateExpr | ifExpr | tryCatchExpr | inlineFunctionExpr | orExpr ; inlineFunctionExpr : 'function' LPAREN ( paramList )? RPAREN ( returnType )? functionBody ; tryCatchExpr : 'try' LCURLY expr RCURLY 'catch' LPAREN DOLLARqName RPAREN LCURLY expr RCURLY ; existUpdateExpr : 'update' ( existReplaceExpr | existValueExpr | existInsertExpr | existDeleteExpr | existRenameExpr ) ; existReplaceExpr : 'replace' expr 'with' exprSingle ; existValueExpr : 'value' expr 'with' exprSingle ; existInsertExpr : 'insert' exprSingle ( 'into' | 'preceding' | 'following' ) exprSingle ; existDeleteExpr : 'delete' exprSingle ; existRenameExpr : 'rename' exprSingle 'as' exprSingle ; flworExpr : ( forClause | letClause )+ ( whereClause )? ( orderByClause )? 'return' exprSingle ; forClause : 'for' inVarBinding ( COMMA inVarBinding )* ; inVarBinding : DOLLARqName ( typeDeclaration )? ( positionalVar )? 'in' exprSingle ; positionalVar : 'at' DOLLARqName ; letClause : 'let' letVarBinding ( COMMA letVarBinding )* ; letVarBinding : DOLLARqName ( typeDeclaration )? COLON EQ exprSingle ( ARROW exprSingle )* ( BANG exprSingle )* ; whereClause : 'where' exprSingle ; orderByClause : ('stable')? 'order' 'by' orderSpecList ; orderSpecList : orderSpec ( COMMA orderSpec )* ; orderSpec : exprSingle orderModifier ; orderModifier : ( 'ascending' | 'descending' )? ( 'empty' ( 'greatest' | 'least' ) )? ( 'collation' STRING_LITERAL )? ; quantifiedExpr : ( 'some' | 'every' ) quantifiedInVarBinding ( COMMA quantifiedInVarBinding )* 'satisfies' exprSingle ; quantifiedInVarBinding : DOLLARqName ( typeDeclaration )? 'in' exprSingle ; switchExpr : 'switch' LPAREN expr RPAREN (switchCaseClause)+ 'default' 'return' exprSingle ; switchCaseClause : ( 'case' switchCaseOperand )+ 'return' exprSingle ; switchCaseOperand : exprSingle ; typeswitchExpr : 'typeswitch' LPAREN expr RPAREN (caseClause)+ 'default' (DOLLARqName)? 'return' exprSingle ; caseClause : 'case' (DOLLARqName 'as')? sequenceType 'return' exprSingle ; ifExpr : 'if' LPAREN expr RPAREN 'then' exprSingle ( ARROW exprSingle )* ( BANG exprSingle )* 'else' exprSingle ( ARROW exprSingle )* ( BANG exprSingle )* ; orExpr : andExpr ( 'or' andExpr )* ; andExpr : comparisonExpr ( 'and' comparisonExpr )* ; comparisonExpr : stringConcatExpr ( LT LT rangeExpr | GT GT rangeExpr | ( ( 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge' ) rangeExpr ) | ( ( EQ | NEQ | GT | GTEQ | LT | LTEQ ) rangeExpr ) | ( ( 'is' ) rangeExpr ) )? ; stringConcatExpr : rangeExpr ( CONCAT rangeExpr )* ; rangeExpr : additiveExpr ( 'to' additiveExpr )? ; additiveExpr : multiplicativeExpr ( ( PLUS | MINUS ) multiplicativeExpr )* ; multiplicativeExpr : unionExpr ( ( STAR | 'div' | 'idiv' | 'mod' ) unionExpr )* ; unionExpr : intersectExceptExpr ( ( 'union' | UNION ) intersectExceptExpr )* ; intersectExceptExpr : instanceofExpr ( ( 'intersect' | 'except' ) instanceofExpr )* ; instanceofExpr : treatExpr ( 'instance' 'of' sequenceType )? ; treatExpr : castableExpr ('treat' 'as' sequenceType)? ; castableExpr : castExpr ( 'castable' 'as' singleType )? ; castExpr : unaryExpr ( 'cast' 'as' singleType )? ; unaryExpr : (MINUS | PLUS)* valueExpr ; valueExpr : validateExpr | pathExpr | extensionExpr ; validateExpr : 'validate' (validationMode)? LCURLY expr RCURLY ; extensionExpr : (PRAGMA)+ LCURLY (expr)? RCURLY ; pathExpr : relativePathExpr | SLASH relativePathExpr | SLASH | DSLASH relativePathExpr ; relativePathExpr : stepExpr ( ( SLASH | DSLASH | BANG | ARROW ) stepExpr )* ; stepExpr : axisStep | filterExpr | filterExpr | filterExpr | axisStep ; axisStep : ( forwardOrReverseStep ) predicateList ; forwardOrReverseStep : forwardAxis nodeTest | reverseAxis nodeTest | abbrevStep ; abbrevStep : ( AT )? nodeTest | PARENT ; forwardAxis : forwardAxisSpecifier COLON COLON ; forwardAxisSpecifier : 'child' | 'self' | 'attribute' | 'descendant' | 'descendant-or-self' | 'following' | 'following-sibling' ; reverseAxis : reverseAxisSpecifier COLON COLON ; reverseAxisSpecifier : 'parent' | 'ancestor' | 'ancestor-or-self' | 'preceding' | 'preceding-sibling' ; nodeTest : kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | nameTest ; nameTest : wildcard |qName ; wildcard : STAR COLONncnameOrKeyword |ncnameOrKeyword COLON STAR | // * STAR ; filterExpr : primaryExpr predicateList ; predicateList : ( predicate )* ; predicate : LPPAREN expr RPPAREN ; primaryExpr : orderedExpr | unorderedExpr | computedConstructor | computedConstructor | constructor | functionCall | contextItemExpr | parenthesizedExpr | DOLLARqName | literal ; literal : STRING_LITERAL | numericLiteral ; numericLiteral : DOUBLE_LITERAL | DECIMAL_LITERAL | INTEGER_LITERAL ; parenthesizedExpr : LPAREN ( expr )? RPAREN ; contextItemExpr : SELF ; orderedExpr : 'ordered' LCURLY expr RCURLY ; unorderedExpr : 'unordered' LCURLY expr RCURLY ; functionCall :qName LPAREN ( functionParameters )? RPAREN ; functionParameters : exprSingle ( COMMA exprSingle )* ; constructor : directConstructor | computedConstructor ; directConstructor : dirElemConstructor | dirCommentConstructor | dirPIConstructor ; dirElemConstructor : elementWithAttributes | elementWithoutAttributes ; elementWithoutAttributes : LTqName ( ( SLASH GT ) | ( GT mixedElementContent END_TAG_STARTqName GT ) ) ; elementWithAttributes : LTqName attributeList ( ( SLASH GT ) | ( GT mixedElementContent END_TAG_STARTqName GT ) ) ; mixedElementContent : ( dirElemContent )* ; dirElemContent : directConstructor | ELEMENT_CONTENT | enclosedExpr | cdataSection ; attributeList : ( attributeDef )+ ; attributeDef :qName EQ attributeValue ; attributeValue : QUOT ( quotAttrValueContent )* QUOT | APOS ( aposAttrValueContent )* APOS ; quotAttrValueContent : QUOT_ATTRIBUTE_CONTENT | attrCommonContent ; aposAttrValueContent : APOS_ATTRIBUTE_CONTENT | attrCommonContent ; attrCommonContent : LCURLY LCURLY | RCURLY RCURLY | attributeEnclosedExpr ; attributeEnclosedExpr : LCURLY expr RCURLY ; xqdocComment :XQDOC_COMMENT ; dirCommentConstructor : XML_COMMENT XML_COMMENT_END ; dirPIConstructor : XML_PI XML_PI_END ; cdataSection : XML_CDATA XML_CDATA_END ; computedConstructor : compDocConstructor | compElemConstructor | compAttrConstructor | compTextConstructor | compCommentConstructor | compPIConstructor | compArrayNodeConstructor | compObjectNodeConstructor | compNumberNodeConstructor | compBooleanNodeConstructor | compNullNodeConstructor ; compObjectNodeConstructor : 'object-node' LCURLY compObjectDecl ( COMMA compObjectDecl )* RCURLY ; compObjectDecl : exprSingle COLON exprSingle ; compArrayNodeConstructor : 'array-node' LCURLY expr RCURLY ; compNumberNodeConstructor : 'number-node' LCURLY exprSingle RCURLY ; compBooleanNodeConstructor : 'boolean-node' LCURLY exprSingle RCURLY ; compNullNodeConstructor : 'null-node' LCURLY RCURLY ; compDocConstructor : 'document' LCURLY expr RCURLY ; compElemConstructor : 'element' LCURLY expr RCURLY LCURLY (contentExpr)? RCURLY | 'element'qName LCURLY (contentExpr)? RCURLY ; contentExpr : expr ; compAttrConstructor : 'attribute' LCURLY expr RCURLY LCURLY (expr)? RCURLY | 'attribute'qName LCURLY (expr)? RCURLY ; compTextConstructor : 'text' LCURLY expr RCURLY ; compCommentConstructor : 'comment' LCURLY expr RCURLY ; compPIConstructor : 'processing-instruction' LCURLY expr RCURLY LCURLY (expr)? RCURLY | 'processing-instruction'ncnameOrKeyword LCURLY (expr)? RCURLY ; singleType : atomicType ( QUESTION )? ; typeDeclaration : 'as' sequenceType ; sequenceType : 'empty-sequence' LPAREN RPAREN | itemType ( occurrenceIndicator )? ; occurrenceIndicator : QUESTION | STAR | PLUS ; itemType : 'item' LPAREN RPAREN | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | kindTest | atomicType ; atomicType :qName ; kindTest : documentTest | elementTest | attributeTest | schemaElementTest | schemaAttributeTest | piTest | commentTest | textTest | objectTest | arrayTest | anyKindTest ; anyKindTest : 'node' LPAREN RPAREN ; documentTest : 'document-node' LPAREN (elementTest | schemaElementTest)? RPAREN ; textTest : 'text' LPAREN RPAREN ; objectTest : 'object-node' LPAREN RPAREN ; arrayTest : 'array-node' LPAREN RPAREN ; commentTest : 'comment' LPAREN RPAREN ; piTest : 'processing-instruction' LPAREN (NCNAME | STRING_LITERAL)? RPAREN ; attributeTest : 'attribute' LPAREN ( attributeNameOrWildcard (COMMAqName)? ) ? RPAREN ; attributeNameOrWildcard : STAR |qName ; schemaAttributeTest : 'schema-attribute' LPARENqName RPAREN ; elementTest : 'element' LPAREN ( elementNameOrWildcard (COMMAqName (QUESTION)?)? )? RPAREN ; elementNameOrWildcard : STAR |qName ; schemaElementTest : 'schema-element' LPARENqName RPAREN ; validationMode : 'lax' | 'strict' ; qName :ncnameOrKeyword COLONncnameOrKeyword |ncnameOrKeyword ; /* All of the literals used in this grammar can also be * part of a valid QName. We thus have to test for each * of them below. */ ncnameOrKeyword :NCNAME |reservedKeywords ; strippedStringLiteral :STRING_LITERAL ; reservedKeywords : 'ancestor' | 'ancestor-or-self' | 'and' | 'as' | 'ascending' | 'at' | 'attribute' | 'base-uri' | 'boundary-space' | 'by' | 'case' | 'cast' | 'castable' | 'catch' | 'child' | 'collation' | 'comment' | 'construction' | 'copy-namespaces' | 'declare' | 'default' | 'delete' | 'descendant' | 'descendant-or-self' | 'descending' | 'div' | 'document' | 'document-node' | 'element' | 'else' | 'empty' | 'empty-sequence' | 'encoding' | 'eq' | 'every' | 'except' | 'external' | 'following' | 'following-sibling' | 'for' | 'function' | 'ge' | 'greatest' | 'gt' | 'idiv' | 'if' | 'import' | 'in' | 'inherit' | 'insert' | 'instance' | 'intersect' | 'into' | 'is' | 'item' | 'lax' | 'le' | 'least' | 'let' | 'lt' | 'mod' | 'module' | 'namespace' | 'ne' | 'node' | 'no-inherit' | 'no-preserve' | 'of' | 'option' | 'or' | 'order' | 'ordered' | 'ordering' | 'parent' | 'preceding' | 'preceding-sibling' | 'preserve' | 'processing-instruction' | 'rename' | 'replace' | 'return' | 'satisfies' | 'schema' | 'schema-attribute' | 'schema-element' | 'self' | 'some' | 'stable' | 'strict' | 'strip' | 'text' | 'then' | 'to' | 'treat' | 'try' | 'typeswitch' | 'xquery' | 'union' | 'unordered' | 'update' | 'validate' | 'value' | 'variable' | 'version' | 'where' | 'with' ; SLASH : '/' ; DSLASH : '/' '/' ; COLON : ':' ; COMMA : ',' ; SEMICOLON : ';' ; STAR : '*' ; QUESTION : '?' ; PLUS : '+' ; MINUS : '-' ; LPPAREN : '[' ; RPPAREN : ']' ; LPAREN : '(' ; RPAREN : ')' ; SELF : '.' ; PARENT : '..' ; UNION : '|' ; AT : '@' ; DOLLAR : '$' ; ANDEQ : '&=' ; OREQ : '|=' ; EQ : '=' ; NEQ : '!=' ; GT : '>' ; GTEQ : '>=' ; QUOT : '""' ; APOS : '\\''; LTEQ : '<=' ; BANG : '!'; ARROW : '=>'; MOD : '%' ; CONCAT : '||'; LT : '<' ; END_TAG_START : '' ; XML_CDATA_END : ']]>' ; XML_PI_START : '' ; LETTER : ( BASECHAR | IDEOGRAPHIC ) ; DIGITS : ( DIGIT )+ ; HEX_DIGITS : ( '0'..'9' | 'a'..'f' | 'A'..'F' )+ ; NMSTART : ( LETTER | '_' ) ; NMCHAR : ( LETTER | DIGIT | '.' | '-' | '_' | COMBINING_CHAR | EXTENDER ) ; NCNAME : NMSTART ( NMCHAR )* ; WS : ( ' ' | '\\t' | '\\n' | '\\r' )+ ; EXPR_COMMENT : '(:' ( CHAR | ':' | EXPR_COMMENT )* ':)' ; XQDOC_COMMENT : '(:~' ( CHAR | ':' )* ':)' ; PRAGMA: '(#' WS PRAGMA_QNAME WS ( PRAGMA_CONTENT )? '#' ')' ; PRAGMA_CONTENT : ( ~( ' ' | '\\t' | '\\n' | '\\r' ) ) ( CHAR | '#' )+ ; PRAGMA_QNAME : NCNAME ( ':' NCNAME )? ; INTEGER_LITERAL : { !(inElementContent || inAttributeContent) }? DIGITS ; DOUBLE_LITERAL : { !(inElementContent || inAttributeContent) }? ( ( '.' DIGITS ) | ( DIGITS ( '.' ( DIGIT )* )? ) ) ( 'e' | 'E' ) ( '+' | '-' )? DIGITS ; DECIMAL_LITERAL : { !(inElementContent || inAttributeContent) }? ( '.' DIGITS ) | ( DIGITS ( '.' ( DIGIT )* )? ) ; PREDEFINED_ENTITY_REF : '&' ( 'lt' | 'gt' | 'amp' | 'quot' | 'apos' ) ';' ; CHAR_REF : '&' '#' ( DIGITS | ( 'x' HEX_DIGITS ) ) ';' ; STRING_LITERAL : '""' ( PREDEFINED_ENTITY_REF | CHAR_REF | ( '""' '""' ) | ~ ( '""' | '&' ) )* '""' | '\\'' ( PREDEFINED_ENTITY_REF | CHAR_REF | ( '\\'' '\\'' ) | ~ ( '\\'' | '&' ) )* '\\'' ; QUOT_ATTRIBUTE_CONTENT : ( ~( '""' | '{' | '}' | '<' ) )+ ; APOS_ATTRIBUTE_CONTENT : ( ~( '\\'' | '{' | '}' | '<' ) )+ ; ELEMENT_CONTENT : ( '\\t' | '\\r' | '\\n' | '\\u0020'..'\\u003b' | '\\u003d'..'\\u007a' | '\\u007c' | '\\u007e'..'\\uFFFD' )+ ; XML_COMMENT : '