Dataset Viewer
Auto-converted to Parquet
content
stringlengths
50
4.1k
language
stringclasses
8 values
/* This ANTLR4 grammar has been generated by Poirot */ grammar parenthesis; axiom : s EOF; a : '(' a ')' | '[' a ']' | 'a'; s : a | a 'b' s;
ANTLR
/* * Teragrep Data Processing Language Parser Library PTH-03 * Copyright (C) 2019, 2020, 2021, 2022 Suomen Kanuuna Oy * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>. * * * Additional permission under GNU Affero General Public License version 3 * section 7 * * If you modify this Program, or any covered work, by linking or combining it * with other code, such other code is not for that reason alone subject to any * of the requirements of the GNU Affero GPL version 3 as long as this Program * is the same Program as licensed from Suomen Kanuuna Oy without any additional * modifications. * * Supplemented terms under GNU Affero General Public License version 3 * section 7 * * Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified * versions must be marked as "Modified version of" The Program. * * Names of the licensors and authors may not be used for publicity purposes. * * No rights are granted for use of trade names, trademarks, or service marks * which are in The Program if any. * * Licensee must indemnify licensors and authors for any liability that these * contractual assumptions impose on licensors and authors. * * To the extent this program is licensed as part of the Commercial versions of * Teragrep, the applicable Commercial License may apply to this file if you as * a licensee so wish it. */ // -*- mode: conf; -*- lexer grammar COMMAND_STREAMSTATS_MODE; COMMAND_STREAMSTATS_MODE_ANTLR_BUG: 'command_streamstats_mode_antlr_bug' -> type(STRING_MATCH); // ++++++++++++++ COMMAND_STREAMSTATS_MODE ++++++++++++++ mode COMMAND_STREAMSTATS_MODE; // skip COMMAND_STREAMSTATS_MODE_SPACE: SPACE -> channel(HIDDEN); // exits COMMAND_STREAMSTATS_MODE_PIPE: '|' -> type(PIPE), popMode; COMMAND_STREAMSTATS_MODE_BRACKET_R: ']' -> type(BRACKET_R), popMode, popMode; // tokens COMMAND_STREAMSTATS_MODE_RESET_ON_CHANGE : 'reset_on_change=' -> pushMode(GET_BOOLEAN); COMMAND_STREAMSTATS_MODE_RESET_BEFORE : 'reset_before=(' -> pushMode(EVAL_LANGUAGE_MODE); COMMAND_STREAMSTATS_MODE_RESET_BEFORE_Q : 'reset_before="("' -> pushMode(EVAL_LANGUAGE_MODE); COMMAND_STREAMSTATS_MODE_TIME_WINDOW : 'time_window=' -> pushMode(GET_SPAN); COMMAND_STREAMSTATS_MODE_RESET_AFTER : 'reset_after=(' -> pushMode(EVAL_LANGUAGE_MODE) ; COMMAND_STREAMSTATS_MODE_RESET_AFTER_Q : 'reset_after="("' -> pushMode(EVAL_LANGUAGE_MODE) ; COMMAND_STREAMSTATS_MODE_CURRENT : 'current=' -> pushMode(GET_BOOLEAN); COMMAND_STREAMSTATS_MODE_WINDOW : 'window=' -> pushMode(GET_INTEGER); COMMAND_STREAMSTATS_MODE_GLOBAL : 'global=' -> pushMode(GET_BOOLEAN); COMMAND_STREAMSTATS_MODE_ALLNUM : 'allnum=' -> pushMode(GET_BOOLEAN); COMMAND_STREAMSTATS_MODE_COMMA : ',' -> type(COMMA); COMMAND_STREAMSTATS_MODE_BY : ('BY'|'by'|'By'); COMMAND_STREAMSTATS_MODE_SINGLE_QUOTE: '\'' ( '\\'. | ~('\''| '\\') )* '\'' -> type(GET_FIELD_SINGLE_QUOTED); COMMAND_STREAMSTATS_MODE_DQSTRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"' -> type(GET_FIELD_DOUBLE_QUOTED); COMMAND_STREAMSTATS_MODE_AS: ('AS'|'as'|'As'); COMMAND_STREAMSTATS_MODE_INT: DIGIT; fragment DIGIT: [0-9]+; // aggregateMethod COMMAND_STREAMSTATS_MODE_COUNT: 'count' -> type(METHOD_AGGREGATE_COUNT); COMMAND_STREAMSTATS_MODE_AVG_PARENTHESIS_R: 'avg(' -> type(METHOD_AGGREGATE_AVG), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_MEAN_PARENTHESIS_R: 'mean(' -> type(METHOD_AGGREGATE_MEAN), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_C_PARENTHESIS_
ANTLR
R: 'c(' -> type(METHOD_AGGREGATE_C), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_COUNT_PARENTHESIS_R: 'count(' -> type(METHOD_AGGREGATE_COUNT_B), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_DC_PARENTHESIS_R: 'dc(' -> type(METHOD_AGGREGATE_DC), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_DISTINCT_COUNT_PARENTHESIS_R: 'distinct_count(' -> type(METHOD_AGGREGATE_DISTINCT_COUNT), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_EARLIEST_PARENTHESIS_R: 'earliest(' -> type(METHOD_AGGREGATE_EARLIEST), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_EARLIEST_TIME_PARENTHESIS_R: 'earliest_time(' -> type(METHOD_AGGREGATE_EARLIEST_TIME), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_ESTDC_PARENTHESIS_R: 'estdc(' -> type(METHOD_AGGREGATE_ESTDC), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_ESTDC_ERROR_PARENTHESIS_R: 'estdc_error(' -> type(METHOD_AGGREGATE_ESTDC_ERROR), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_FIRST_PARENTHESIS_R: 'first(' -> type(METHOD_AGGREGATE_FIRST), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_LAST_PARENTHESIS_R: 'last(' -> type(METHOD_AGGREGATE_LAST), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_LATEST_PARENTHESIS_R: 'latest(' -> type(METHOD_AGGREGATE_LATEST), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_LATEST_TIME_PARENTHESIS_R: 'latest_time(' -> type(METHOD_AGGREGATE_LATEST_TIME), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_LIST_PARENTHESIS_R: 'list(' -> type(METHOD_AGGREGATE_LIST), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_MAX_PARENTHESIS_R: 'max(' -> type(METHOD_AGGREGATE_MAX), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_MEDIAN_PARENTHESIS_R: 'median(' -> type(METHOD_AGGREGATE_MEDIAN), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_MIN_PARENTHESIS_R: 'min(' -> type(METHOD_AGGREGATE_MIN), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_MODE_PARENTHESIS_R: 'mode(' -> type(METHOD_AGGREGATE_MODE), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_P_PARENTHESIS_R: 'p(' -> type(METHOD_AGGREGATE_P), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_PERC_PARENTHESIS_R: 'perc(' -> type(METHOD_AGGREGATE_PERC), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_EXACTPERC_PARENTHESIS_R: 'exactperc(' -> type(METHOD_AGGREGATE_EXACTPERC), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_UPPERPERC_PARENTHESIS_R: 'upperperc(' -> type(METHOD_AGGREGATE_UPPERPERC), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_PERCINT_PARENTHESIS_R: 'percint(' -> type(METHOD_AGGREGATE_PERCINT), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_RANGE_PARENTHESIS_R: 'range(' -> type(METHOD_AGGREGATE_RANGE), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_RATE_PARENTHESIS_R: 'rate(' -> type(METHOD_AGGREGATE_RATE), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_STDEV_PARENTHESIS_R: 'stdev(' -> type(METHOD_AGGREGATE_STDEV), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_STDEVP_PARENTHESIS_R: 'stdevp(' -> type(METHOD_AGGREGATE_STDEVP), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_SUM_PARENTHESIS_R: 'sum(' -> type(METHOD_AGGREGATE_SUM), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_SUMSQ_PARENTHESIS_R: 'sumsq(' -> type(METHOD_AGGREGATE_SUMSQ), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_VALUES_PARENTHESIS_R: 'values(' -> type(METHOD_AGGREGATE_VALUES), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_VAR_PARENTHESIS_R: 'var(' -> type(METHOD_AGGREGATE_VAR), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_VARP_PARENTHESIS_R: 'varp(' -> type(METHOD_AGGREGATE_VARP), pushMode(AGGREGATION_MODE); //special percX() COMMAND_STREAMSTATS_MODE_P_VARIABLE: 'p'COMMAND_STREAMSTATS_MODE_INT -> type(METHOD_AGGREGATE_P_VARIABLE), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_PERC_VARIABLE: 'perc'COMMAND_STREAMSTATS_MODE_INT -> type(METHOD_AGGREGATE_PERC_VARIABLE), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTATS_MODE_EXACTPERC_VARIABLE: 'exactperc'COMMAND_STREAMSTATS_MODE_INT -> type(METHOD_AGGREGATE_EXACTPERC_VARIABLE), pushMode(AGGREGATION_MODE); COMMAND_STREAMSTAT
ANTLR
S_MODE_UPPERPERC_VARIABLE: 'upperperc'COMMAND_STREAMSTATS_MODE_INT -> type(METHOD_AGGREGATE_UPPERPERC_VARIABLE), pushMode(AGGREGATION_MODE); // characters for string fragment COMMAND_STREAMSTATS_MODE_CHAR :'\u0023' // # |'\u0024' // $ |'\u0025' // % |'\u0026' // & // |'\u0027' // ' // |'\u0028' // ( // |'\u0029' // ) |'\u002A' // * |'\u002B' // + // |'\u002C' // , |'\u002D' // - |'\u002E' // . |'\u002F' // / |'\u0030' // 0 |'\u0031' // 1 |'\u0032' // 2 |'\u0033' // 3 |'\u0034' // 4 |'\u0035' // 5 |'\u0036' // 6 |'\u0037' // 7 |'\u0038' // 8 |'\u0039' // 9 |'\u003A' // : |'\u003B' // ; |'\u003C' // < |'\u003D' {false}? // = |'\u003E' // > |'\u003F' // ? |'\u0040' // STREAMSTATS |'\u0041' // A |'\u0042' // B |'\u0043' // C |'\u0044' // D |'\u0045' // E |'\u0046' // F |'\u0047' // G |'\u0048' // H |'\u0049' // I |'\u004A' // J |'\u004B' // K |'\u004C' // L |'\u004D' // M |'\u004E' // N |'\u004F' // O |'\u0050' // P |'\u0051' // Q |'\u0052' // R |'\u0053' // S |'\u0054' // T |'\u0055' // U |'\u0056' // V |'\u0057' // W |'\u0058' // X |'\u0059' // Y |'\u005A' // Z |'\u005B' {false}? // [ |'\u005C' // \ |'\u005D' {false}? // ] |'\u005E' // ^ |'\u005F' // _ |'\u0060' // ` |'\u0061' // a |'\u0062' // b |'\u0063' // c |'\u0064' // d |'\u0065' // e |'\u0066' // f |'\u0067' // g |'\u0068' // h |'\u0069' // u |'\u006A' // j |'\u006B' // k |'\u006C' // l |'\u006D' // m |'\u006E' // n |'\u006F' // o |'\u0070' // p |'\u0071' // q |'\u0072' // r |'\u0073' // s |'\u0074' // t |'\u0075' // u |'\u0076' // v |'\u0077' // w |'\u0078' // x |'\u0079' // y |'\u007A' // z |'\u007B' // { // |'\u007C' // | |'\u007D' // } |'\u007E' // ~ |'\u007F'..'\uFFFF' // DEL .. inf ; COMMAND_STREAMSTATS_MODE_STRING // one or more characters : (COMMAND_STREAMSTATS_MODE_CHAR)+ -> type(GET_FIELD_STRING);
ANTLR
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false // $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging parser grammar abbParser; options { tokenVocab = abbLexer; } /* This grammar is still in development. In the current state, it is only able to parse .sys-files and read the given declarations. */ /* This file is the grammar for the ABB RAPID Robot Language. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Antlr4 port by Tom Everett, 2016 Question mark stands for: zero or one Plus stands for: one or more Star stands for: zero or more */ module_ : moduleData EOF ; moduleData : MODULE moduleName NEWLINE dataList NEWLINE* ENDMODULE ; moduleName : IDENTIFIER | procCall ; dataList : (NEWLINE | declaration NEWLINE | procedure NEWLINE)* ; procedure : PROC procCall NEWLINE (functionCall NEWLINE)* ENDPROC ; procCall : procName procParameter? ; procName : IDENTIFIER ; procParameter : BRACKET_OPEN IDENTIFIER? BRACKET_CLOSE ; functionCall : IDENTIFIER (functionParameter COMMA)* functionParameter SEMICOLON ; functionParameter : ON_CALL | OFF_CALL | primitive | IDENTIFIER ; declaration : init_ type_ IDENTIFIER (EQUALS expression)? SEMICOLON ; type_ : TOOLDATA | WOBJDATA | SPEEDDATA | ZONEDATA | CLOCK | BOOL ; init_ : LOCAL? (CONST | PERS | VAR) ; expression : array_ | primitive ; array_ : SQUARE_OPEN (expression COMMA)* expression SQUARE_CLOSE ; primitive : BOOLLITERAL | CHARLITERAL | STRINGLITERAL | (PLUS | MINUS)? FLOATLITERAL | (PLUS | MINUS)? INTLITERAL ;
ANTLR
parser grammar TParser2; options { tokenVocab = TLexer2; } // These are all supported parser sections: // Parser file header. Appears at the top in all parser related files. Use e.g. for copyrights. @parser::header {/* parser/listener/visitor header section */} // Appears before any #include in h + cpp files. @parser::preinclude {/* parser precinclude section */} // Follows directly after the standard #includes in h + cpp files. @parser::postinclude { /* parser postinclude section */ #ifndef _WIN32 #pragma GCC diagnostic ignored "-Wunused-parameter" #endif } // Directly preceeds the parser class declaration in the h file (e.g. for additional types etc.). @parser::context {/* parser context section */} // Appears in the private part of the parser in the h file. // The function bodies could also appear in the definitions section, but I want to maximize // Java compatibility, so we can also create a Java parser from this grammar. // Still, some tweaking is necessary after the Java file generation (e.g. bool -> boolean). @parser::members { /* public parser declarations/members section */ bool myAction() { return true; } bool doesItBlend() { return true; } void cleanUp() {} void doInit() {} void doAfter() {} } // Appears in the public part of the parser in the h file. @parser::declarations {/* private parser declarations section */} // Appears in line with the other class member definitions in the cpp file. @parser::definitions {/* parser definitions section */} // Additionally there are similar sections for (base)listener and (base)visitor files. @parser::listenerpreinclude {/* listener preinclude section */} @parser::listenerpostinclude {/* listener postinclude section */} @parser::listenerdeclarations {/* listener public declarations/members section */} @parser::listenermembers {/* listener private declarations/members section */} @parser::listenerdefinitions {/* listener definitions section */} @parser::baselistenerpreinclude {/* base listener preinclude section */} @parser::baselistenerpostinclude {/* base listener postinclude section */} @parser::baselistenerdeclarations {/* base listener public declarations/members section */} @parser::baselistenermembers {/* base listener private declarations/members section */} @parser::baselistenerdefinitions {/* base listener definitions section */} @parser::visitorpreinclude {/* visitor preinclude section */} @parser::visitorpostinclude {/* visitor postinclude section */} @parser::visitordeclarations {/* visitor public declarations/members section */} @parser::visitormembers {/* visitor private declarations/members section */} @parser::visitordefinitions {/* visitor definitions section */} @parser::basevisitorpreinclude {/* base visitor preinclude section */} @parser::basevisitorpostinclude {/* base visitor postinclude section */} @parser::basevisitordeclarations {/* base visitor public declarations/members section */} @parser::basevisitormembers {/* base visitor private declarations/members section */} @parser::basevisitordefinitions {/* base visitor definitions section */} // Actual grammar start. main: stat+ EOF; divide : ID (and_ GreaterThan)? {doesItBlend()}?; and_ @init{ doInit(); } @after { doAfter(); } : And ; conquer: divide+ | {doesItBlend()}? and_ { myAction(); } | ID (LessThan* divide)?? { $ID.text; } ; // Unused rule to demonstrate some of the special features. unused[double input = 111] returns [double calculated] locals [int _a, double _b, int _c] @init{ doInit(); } @after { doAfter(); } : stat ; catch [...] { // Replaces the standard exception handling. } finally { cleanUp(); } unused2: (unused[1] .)+ (Colon | Semicolon | Plus)? ~Semicolon ; stat: expr Equal expr Semicolon | expr Semicolon ; expr: expr Star expr | expr Plus expr | OpenPar expr ClosePar | <assoc = right> expr QuestionMark expr Colon expr | <assoc = right> expr Equal expr | identifier = id | flowControl | INT | String ; flowControl: (Return expr | 'return') # Return | Continue # Continue ; id: ID; array : OpenCurly el += INT (Comma
ANTLR
el += INT)* CloseCurly; idarray : OpenCurly element += id (Comma element += id)* CloseCurly; any: t = .;
ANTLR
/* * 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. */ lexer grammar SqlBaseLexer; @members { /** * When true, parser should throw ParseException for unclosed bracketed comment. */ public boolean has_unclosed_bracketed_comment = 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; } } /** * This method will be called when we see '/*' and try to match it as a bracketed comment. * If the next character is '+', it should be parsed as hint later, and we cannot match * it as a bracketed comment. * * Returns true if the next character is '+'. */ public boolean isHint() { int nextChar = _input.LA(1); if (nextChar == '+') { return true; } else { return false; } } /** * This method will be called when the character stream ends and try to find out the * unclosed bracketed comment. * If the method be called, it means the end of the entire character stream match, * and we set the flag and fail later. */ public void markUnclosedComment() { has_unclosed_bracketed_comment = true; } /** * When greater than zero, it's in the middle of parsing ARRAY/MAP/STRUCT type. */ public int complex_type_level_counter = 0; /** * Increase the counter by one when hits KEYWORD 'ARRAY', 'MAP', 'STRUCT'. */ public void incComplexTypeLevelCounter() { complex_type_level_counter++; } /** * Decrease the counter by one when hits close tag '>' && the counter greater than zero * which means we are in the middle of complex type parsing. Otherwise, it's a dangling * GT token and we do nothing. */ public void decComplexTypeLevelCounter() { if (complex_type_level_counter > 0) complex_type_level_counter--; } /** * If the counter is zero, it's a shift right operator. It can be closing tags of an complex * type definition, such as MAP<INT, ARRAY<INT>>. */ public boolean isShiftRightOperator() { return complex_type_level_counter == 0 ? true : false; } } SEMICOLON: ';'; LEFT_PAREN: '('; RIGHT_PAREN: ')'; COMMA: ','; DOT: '.'; LEFT_BRACKET: '['; RIGHT_BRACKET: ']'; BANG: '!'; // 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`, and // modify `ParserUtils.toExprAlias()` which assumes all keywords are between `ADD` and `ZONE`. //============================ // Start of the keywords list //============================ //--SPARK-KEYWORD-LIST-START ADD: 'ADD'; AFTER: 'AFTER';
ANTLR
AGGREGATE: 'AGGREGATE'; ALL: 'ALL'; ALTER: 'ALTER'; ALWAYS: 'ALWAYS'; ANALYZE: 'ANALYZE'; AND: 'AND'; ANTI: 'ANTI'; ANY: 'ANY'; ANY_VALUE: 'ANY_VALUE'; ARCHIVE: 'ARCHIVE'; ARRAY: 'ARRAY' {incComplexTypeLevelCounter();}; AS: 'AS'; ASC: 'ASC'; AT: 'AT'; ATOMIC: 'ATOMIC'; AUTHORIZATION: 'AUTHORIZATION'; BEGIN: 'BEGIN'; BETWEEN: 'BETWEEN'; BIGINT: 'BIGINT'; BINARY: 'BINARY'; BINDING: 'BINDING'; BOOLEAN: 'BOOLEAN'; BOTH: 'BOTH'; BUCKET: 'BUCKET'; BUCKETS: 'BUCKETS'; BY: 'BY'; BYTE: 'BYTE'; CACHE: 'CACHE'; CALL: 'CALL'; CALLED: 'CALLED'; CASCADE: 'CASCADE'; CASE: 'CASE'; CAST: 'CAST'; CATALOG: 'CATALOG'; CATALOGS: 'CATALOGS'; CHANGE: 'CHANGE'; CHAR: 'CHAR'; CHARACTER: 'CHARACTER'; CHECK: 'CHECK'; CLEAR: 'CLEAR'; CLUSTER: 'CLUSTER'; CLUSTERED: 'CLUSTERED'; CODEGEN: 'CODEGEN'; COLLATE: 'COLLATE'; COLLATION: 'COLLATION'; COLLECTION: 'COLLECTION'; COLUMN: 'COLUMN'; COLUMNS: 'COLUMNS'; COMMENT: 'COMMENT'; COMMIT: 'COMMIT'; COMPACT: 'COMPACT'; COMPACTIONS: 'COMPACTIONS'; COMPENSATION: 'COMPENSATION'; COMPUTE: 'COMPUTE'; CONCATENATE: 'CONCATENATE'; CONDITION: 'CONDITION'; CONSTRAINT: 'CONSTRAINT'; CONTAINS: 'CONTAINS'; CONTINUE: 'CONTINUE'; 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'; DAY: 'DAY'; DAYS: 'DAYS'; DAYOFYEAR: 'DAYOFYEAR'; DATA: 'DATA'; DATE: 'DATE'; DATABASE: 'DATABASE'; DATABASES: 'DATABASES'; DATEADD: 'DATEADD'; DATE_ADD: 'DATE_ADD'; DATEDIFF: 'DATEDIFF'; DATE_DIFF: 'DATE_DIFF'; DBPROPERTIES: 'DBPROPERTIES'; DEC: 'DEC'; DECIMAL: 'DECIMAL'; DECLARE: 'DECLARE'; DEFAULT: 'DEFAULT'; DEFINED: 'DEFINED'; DEFINER: 'DEFINER'; DELETE: 'DELETE'; DELIMITED: 'DELIMITED'; DESC: 'DESC'; DESCRIBE: 'DESCRIBE'; DETERMINISTIC: 'DETERMINISTIC'; DFS: 'DFS'; DIRECTORIES: 'DIRECTORIES'; DIRECTORY: 'DIRECTORY'; DISTINCT: 'DISTINCT'; DISTRIBUTE: 'DISTRIBUTE'; DIV: 'DIV'; DO: 'DO'; DOUBLE: 'DOUBLE'; DROP: 'DROP'; ELSE: 'ELSE'; ELSEIF: 'ELSEIF'; END: 'END'; ENFORCED: 'ENFORCED'; ESCAPE: 'ESCAPE'; ESCAPED: 'ESCAPED'; EVOLUTION: 'EVOLUTION'; EXCEPT: 'EXCEPT'; EXCHANGE: 'EXCHANGE'; EXCLUDE: 'EXCLUDE'; EXISTS: 'EXISTS'; EXIT: 'EXIT'; EXPLAIN: 'EXPLAIN'; EXPORT: 'EXPORT'; EXTEND: 'EXTEND'; EXTENDED: 'EXTENDED'; EXTERNAL: 'EXTERNAL'; EXTRACT: 'EXTRACT'; FALSE: 'FALSE'; FETCH: 'FETCH'; FIELDS: 'FIELDS'; FILTER: 'FILTER'; FILEFORMAT: 'FILEFORMAT'; FIRST: 'FIRST'; FLOAT: 'FLOAT'; FLOW: 'FLOW'; FOLLOWING: 'FOLLOWING'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FORMAT: 'FORMAT'; FORMATTED: 'FORMATTED'; FOUND: 'FOUND'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; FUNCTIONS: 'FUNCTIONS'; GENERATED: 'GENERATED'; GLOBAL: 'GLOBAL'; GRANT: 'GRANT'; GROUP: 'GROUP'; GROUPING: 'GROUPING'; HANDLER: 'HANDLER'; HAVING: 'HAVING'; BINARY_HEX: 'X'; HOUR: 'HOUR'; HOURS: 'HOURS'; IDENTIFIER_KW: 'IDENTIFIER'; IDENTITY: 'IDENTITY'; IF: 'IF'; IGNORE: 'IGNORE'; IMMEDIATE: 'IMMEDIATE'; IMPORT: 'IMPORT'; IN: 'IN'; INCLUDE: 'INCLUDE'; INCREMENT: 'INCREMENT'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; INNER: 'INNER'; INPATH: 'INPATH'; INPUT: 'INPUT'; INPUTFORMAT: 'INPUTFORMAT'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTERVAL: 'INTERVAL'; INT: 'INT'; INTEGER: 'INTEGER'; INTO: 'INTO'; INVOKER: 'INVOKER'; IS: 'IS'; ITEMS: 'ITEMS'; ITERATE: 'ITERATE'; JOIN: 'JOIN'; JSON: 'JSON'; KEY: 'KEY'; KEYS: 'KEYS'; LANGUAGE: 'LANGUAGE'; LAST: 'LAST'; LATERAL: 'LATERAL'; LAZY: 'LAZY'; LEADING: 'LEADING'; LEAVE: 'LEAVE'; LEFT: 'LEFT'; LEVEL: 'LEVEL'; LIKE: 'LIKE'; ILIKE: 'ILIKE'; LIMIT: 'LIMIT'; LINES: 'LINES'; LIST: 'LIST'; LOAD: 'LOAD'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCKS: 'LOCKS'; LOGICAL: 'LOGICAL'; LONG: 'LONG'; LOOP: 'LOOP'; MACRO: 'MACRO'; MAP: 'MAP' {incComplexTypeLevelCounter();}; MATCHED: 'MATCHED'; MATERIALIZED: 'MATERIALIZED'; MAX: 'MAX'; MERGE: 'MERGE'; MICROSECOND: 'MICROSECOND'; MICROSECONDS: 'MICROSECONDS'; MILLISECOND: 'MILLISECOND'; MILLISECONDS: 'MILLISECONDS'; MINUTE: 'MINUTE'; MINUTES: 'MINUTES'; MODIFIES: 'MODIFIES'; MONTH: 'MONTH'; MONTHS: 'MONTHS'; MSCK: 'MSCK'; NAME: 'NAME'; NAMESPACE: 'NAMESPACE'
ANTLR
; NAMESPACES: 'NAMESPACES'; NANOSECOND: 'NANOSECOND'; NANOSECONDS: 'NANOSECONDS'; NATURAL: 'NATURAL'; NO: 'NO'; NONE: 'NONE'; NOT: 'NOT'; NULL: 'NULL'; NULLS: 'NULLS'; NUMERIC: 'NUMERIC'; NORELY: 'NORELY'; OF: 'OF'; OFFSET: 'OFFSET'; 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'; PROCEDURE: 'PROCEDURE'; PROCEDURES: 'PROCEDURES'; PROPERTIES: 'PROPERTIES'; PURGE: 'PURGE'; QUARTER: 'QUARTER'; QUERY: 'QUERY'; RANGE: 'RANGE'; READS: 'READS'; REAL: 'REAL'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; RECOVER: 'RECOVER'; RECURSION: 'RECURSION'; RECURSIVE: 'RECURSIVE'; REDUCE: 'REDUCE'; REFERENCES: 'REFERENCES'; REFRESH: 'REFRESH'; RELY: 'RELY'; RENAME: 'RENAME'; REPAIR: 'REPAIR'; REPEAT: 'REPEAT'; REPEATABLE: 'REPEATABLE'; REPLACE: 'REPLACE'; RESET: 'RESET'; RESPECT: 'RESPECT'; RESTRICT: 'RESTRICT'; RETURN: 'RETURN'; RETURNS: 'RETURNS'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; RLIKE: 'RLIKE' | 'REGEXP'; ROLE: 'ROLE'; ROLES: 'ROLES'; ROLLBACK: 'ROLLBACK'; ROLLUP: 'ROLLUP'; ROW: 'ROW'; ROWS: 'ROWS'; SECOND: 'SECOND'; SECONDS: 'SECONDS'; SCHEMA: 'SCHEMA'; SCHEMAS: 'SCHEMAS'; SECURITY: 'SECURITY'; SELECT: 'SELECT'; SEMI: 'SEMI'; SEPARATED: 'SEPARATED'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETMINUS: 'MINUS'; SETS: 'SETS'; SHORT: 'SHORT'; SHOW: 'SHOW'; SINGLE: 'SINGLE'; SKEWED: 'SKEWED'; SMALLINT: 'SMALLINT'; SOME: 'SOME'; SORT: 'SORT'; SORTED: 'SORTED'; SOURCE: 'SOURCE'; SPECIFIC: 'SPECIFIC'; SQL: 'SQL'; SQLEXCEPTION: 'SQLEXCEPTION'; SQLSTATE: 'SQLSTATE'; START: 'START'; STATISTICS: 'STATISTICS'; STORED: 'STORED'; STRATIFY: 'STRATIFY'; STREAM: 'STREAM'; STREAMING: 'STREAMING'; STRING: 'STRING'; STRUCT: 'STRUCT' {incComplexTypeLevelCounter();}; SUBSTR: 'SUBSTR'; SUBSTRING: 'SUBSTRING'; SYNC: 'SYNC'; SYSTEM_TIME: 'SYSTEM_TIME'; SYSTEM_VERSION: 'SYSTEM_VERSION'; TABLE: 'TABLE'; TABLES: 'TABLES'; TABLESAMPLE: 'TABLESAMPLE'; TARGET: 'TARGET'; TBLPROPERTIES: 'TBLPROPERTIES'; TEMPORARY: 'TEMPORARY' | 'TEMP'; TERMINATED: 'TERMINATED'; THEN: 'THEN'; TIME: 'TIME'; TIMEDIFF: 'TIMEDIFF'; TIMESTAMP: 'TIMESTAMP'; TIMESTAMP_LTZ: 'TIMESTAMP_LTZ'; TIMESTAMP_NTZ: 'TIMESTAMP_NTZ'; TIMESTAMPADD: 'TIMESTAMPADD'; TIMESTAMPDIFF: 'TIMESTAMPDIFF'; TINYINT: 'TINYINT'; TO: 'TO'; EXECUTE: 'EXECUTE'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; TRANSACTIONS: 'TRANSACTIONS'; TRANSFORM: 'TRANSFORM'; TRIM: 'TRIM'; TRUE: 'TRUE'; TRUNCATE: 'TRUNCATE'; TRY_CAST: 'TRY_CAST'; TYPE: 'TYPE'; UNARCHIVE: 'UNARCHIVE'; UNBOUNDED: 'UNBOUNDED'; UNCACHE: 'UNCACHE'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNKNOWN: 'UNKNOWN'; UNLOCK: 'UNLOCK'; UNPIVOT: 'UNPIVOT'; UNSET: 'UNSET'; UNTIL: 'UNTIL'; UPDATE: 'UPDATE'; USE: 'USE'; USER: 'USER'; USING: 'USING'; VALUE: 'VALUE'; VALUES: 'VALUES'; VARCHAR: 'VARCHAR'; VAR: 'VAR'; VARIABLE: 'VARIABLE'; VARIANT: 'VARIANT'; VERSION: 'VERSION'; VIEW: 'VIEW'; VIEWS: 'VIEWS'; VOID: 'VOID'; WEEK: 'WEEK'; WEEKS: 'WEEKS'; WHEN: 'WHEN'; WHERE: 'WHERE'; WHILE: 'WHILE'; WINDOW: 'WINDOW'; WITH: 'WITH'; WITHIN: 'WITHIN'; WITHOUT: 'WITHOUT'; YEAR: 'YEAR'; YEARS: 'YEARS'; ZONE: 'ZONE'; //--SPARK-KEYWORD-LIST-END //============================ // End of the keywords list //============================ EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>' {decComplexTypeLevelCounter();}; GTE : '>=' | '!<'; SHIFT_LEFT: '<<'; SHIFT_RIGHT: '>>' {isShiftRightOperator()}?; SHIFT_RIGHT_UNSIGNED: '>>>' {isShiftRightOperator()}?; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; OPERATOR_PIPE: '|>'; HAT: '^'; COLON: ':'; DOUBLE_COLON: '::'; ARROW: '->'; FAT_ARROW : '=>'; HENT
ANTLR
_START: '/*+'; HENT_END: '*/'; QUESTION: '?'; STRING_LITERAL : '\'' ( ~('\''|'\\') | ('\\' .) | ('\'' '\'') )* '\'' | 'R\'' (~'\'')* '\'' | 'R"'(~'"')* '"' ; DOUBLEQUOTED_STRING :'"' ( ~('"'|'\\') | '""' | ('\\' .) )* '"' ; // NOTE: If you move a numeric literal, you should modify `ParserUtils.toExprAlias()` // which assumes all numeric literals are between `BIGINT_LITERAL` and `BIGDECIMAL_LITERAL`. 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()}? ; FLOAT_LITERAL : DIGIT+ EXPONENT? 'F' | DECIMAL_DIGITS EXPONENT? 'F' {isValidDecimal()}? ; DOUBLE_LITERAL : DIGIT+ EXPONENT? 'D' | DECIMAL_DIGITS EXPONENT? 'D' {isValidDecimal()}? ; BIGDECIMAL_LITERAL : DIGIT+ EXPONENT? 'BD' | DECIMAL_DIGITS EXPONENT? 'BD' {isValidDecimal()}? ; // Generalize the identifier to give a sensible INVALID_IDENTIFIER error message: // * Unicode letters rather than a-z and A-Z only // * URI paths for table references using paths // We then narrow down to ANSI rules in exitUnquotedIdentifier() in the parser. IDENTIFIER : (UNICODE_LETTER | DIGIT | '_')+ | UNICODE_LETTER+ '://' (UNICODE_LETTER | DIGIT | '_' | '/' | '-' | '.' | '?' | '=' | '&' | '#' | '%')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DECIMAL_DIGITS : DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment EXPONENT : 'E' [+-]? DIGIT+ ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Z] ; fragment UNICODE_LETTER : [\p{L}] ; SIMPLE_COMMENT : '--' ('\\\n' | ~[\r\n])* '\r'? '\n'? -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' {!isHint()}? ( BRACKETED_COMMENT | . )*? ('*/' | {markUnclosedComment();} EOF) -> channel(HIDDEN) ; WS : [ \t\n\f\r\u000B\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u202F\u205F\u3000]+ -> 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 : . ;
ANTLR
/* MIT License Copyright (c) 2022 Mustafa Said AÄŸca Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ lexer grammar svlogLexer; channels { COMMENTS, DIRECTIVES } EM : '!' ; EMEQ : '!=' ; EMEQEQ : '!==' ; EMEQQM : '!=?' ; DQ : '"' ; DQDPIDQ : '"DPI"' ; DQDPIMICDQ : '"DPI-C"' ; HA : '#' ; HAHA : '##' ; HAMIHA : '#-#' ; HAEQHA : '#=#' ; DL : '$' ; DLERROR : '$error' ; DLFATAL : '$fatal' ; DLFULLSKEW : '$fullskew' ; DLHOLD : '$hold' ; DLINFO : '$info' ; DLNOCHANGE : '$nochange' ; DLPERIOD : '$period' ; DLRECOVERY : '$recovery' ; DLRECREM : '$recrem' ; DLREMOVAL : '$removal' ; DLROOTDT : '$root.' ; DLSETUP : '$setup' ; DLSETUPHOLD : '$setuphold' ; DLSKEW : '$skew' ; DLTIMESKEW : '$timeskew' ; DLUNIT : '$unit' ; DLWARNING : '$warning' ; DLWIDTH : '$width' ; MO : '%' ; MOEQ : '%=' ; AM : '&' ; AMAM : '&&' ; AMAMAM : '&&&' ; AMEQ : '&=' ; AP : '\'' ; LP : '(' ; RP : ')' ; AS : '*' ; ASAS : '**' ; ASSL : '*/' ; ASCLCLAS : '*::*' ; ASEQ : '*=' ; ASGT : '*>' ; PL : '+' ; PLPL : '++' ; PLCL : '+:' ; PLEQ : '+=' ; CO : ',' ; MI : '-' ; MIMI : '--' ; MICL : '-:' ; MIEQ : '-=' ; MIGT : '->' ; MIGTGT : '->>' ; DT : '.' ; DTAS : '.*' ; SL : '/' ; SLAS : '/*' ; SLSL : '//' ; SLEQ : '/=' ; ONESTEP : '1step' ; CL : ':' ; CLSL : ':/' ; CLCL : '::' ; CLEQ : ':=' ; SC : ';' ; LT : '<' ; LTMIGT : '<->' ; LTLT : '<<' ; LTLTLT : '<<<' ; LTLTLTEQ : '<<<=' ; LTLTEQ : '<<=' ; LTEQ : '<=' ; EQ : '=' ; EQEQ : '==' ; EQEQEQ : '===' ; EQEQQM : '==?' ; EQGT : '=>' ; GT : '>' ; GTEQ : '>=' ; GTGT : '>>' ; GTGTEQ : '>>=' ; GTGTGT : '>>>' ; GTGTGTEQ : '>>>=' ; QM : '?' ; AT : '@' ; ATAT : '@@' ; PATHPULSEDL : 'PATHPULSE$' ; LB : '[' ; RB : ']' ; CA : '^' ; CAEQ : '^=' ; CATI : '^~' ; GA : '`' -> channel(DIRECTIVES), pushMode(DIRECTIVE_MODE) ; ACCEPT_ON : 'accept_on' ; ALIAS : 'alias' ; ALWAYS : 'always' ; ALWAYS_COMB : 'always_comb' ; ALWAYS_FF : 'always_ff' ; ALWAYS_LATCH : 'always_latch' ; AND : 'and' ; ASSERT : 'assert' ; ASSIGN : 'assign' ; ASSUME : 'assume' ; AUTOMATIC : 'automatic' ; BEFORE : 'before' ; BEGIN : 'begin' ; BIND : 'bind' ; BINS : 'bins' ; BINSOF : 'binsof' ; BIT : 'bit' ; BREAK : 'break' ; BUF : 'buf' ; BUFIFZERO : 'bufif0' ; BUFIFONE : 'bufif1' ; BYTE : 'byte' ; CASE : 'case' ; CASEX : 'casex' ; CASEZ : 'casez' ; CELL : 'cell' ; CHANDLE : 'chandle' ; CHECKER : 'checker' ; CLASS : 'class' ; CLOCKING : 'clocking' ; CMOS : 'cmos' ; CONFIG : 'config' ; CONST : 'const' ; CONSTRAINT : 'constraint' ; CONTEXT : 'context' ; CONTINUE : 'continue' ; COVER : 'cover' ; COVERGROUP : 'covergroup' ; COVERPOINT : 'coverpoint' ; CROSS : 'cross' ; DEASSIGN : 'deassign' ; DEFAULT : 'default' ; DEFPARAM : 'defparam' ; DESIGN : 'design' ; DISABLE : 'disable' ; DIST : 'dist' ; DO : 'do' ; EDGE : 'edge' ; ELSE : 'else' ; END : 'end' ; ENDCASE : 'endcase' ; ENDCHECKER : 'endchecker' ; ENDCLASS : 'endclass' ; ENDCLOCKING : 'endclocking' ; ENDCONFIG : 'endconfig' ; ENDFUNCTION : 'endfunction' ; ENDGENERATE : 'endgenerate' ; ENDGROUP : 'endgroup' ; ENDINTERFACE : 'endinterface' ; ENDMODULE : 'endmodule' ; ENDPACKAGE : 'endpackage' ; ENDPRIMITIVE : 'endprimitive' ; ENDPROGRAM : 'endprogram' ; ENDPROP
ANTLR
ERTY : 'endproperty' ; ENDSEQUENCE : 'endsequence' ; ENDSPECIFY : 'endspecify' ; ENDTABLE : 'endtable' ; ENDTASK : 'endtask' ; ENUM : 'enum' ; EVENT : 'event' ; EXPECT : 'expect' ; EXPORT : 'export' ; EXTENDS : 'extends' ; EXTERN : 'extern' ; FINAL : 'final' ; FIRST_MATCH : 'first_match' ; FOR : 'for' ; FORCE : 'force' ; FOREACH : 'foreach' ; FOREVER : 'forever' ; FORK : 'fork' ; FORKJOIN : 'forkjoin' ; FUNCTION : 'function' ; GENERATE : 'generate' ; GENVAR : 'genvar' ; GLOBAL : 'global' ; HIGHZZERO : 'highz0' ; HIGHZONE : 'highz1' ; IF : 'if' ; IFF : 'iff' ; IFNONE : 'ifnone' ; IGNORE_BINS : 'ignore_bins' ; ILLEGAL_BINS : 'illegal_bins' ; IMPLEMENTS : 'implements' ; IMPLIES : 'implies' ; IMPORT : 'import' ; INCLUDE : 'include' -> mode(LIBRARY_MODE) ; INITIAL : 'initial' ; INOUT : 'inout' ; INPUT : 'input' ; INSIDE : 'inside' ; INSTANCE : 'instance' ; INT : 'int' ; INTEGER : 'integer' ; INTERCONNECT : 'interconnect' ; INTERFACE : 'interface' ; INTERSECT : 'intersect' ; JOIN : 'join' ; JOIN_ANY : 'join_any' ; JOIN_NONE : 'join_none' ; LARGE : 'large' ; LET : 'let' ; LIBLIST : 'liblist' ; LIBRARY : 'library' -> mode(LIBRARY_MODE) ; LOCAL : 'local' ; LOCALPARAM : 'localparam' ; LOGIC : 'logic' ; LONGINT : 'longint' ; MACROMODULE : 'macromodule' ; MATCHES : 'matches' ; MEDIUM : 'medium' ; MODPORT : 'modport' ; MODULE : 'module' ; NAND : 'nand' ; NEGEDGE : 'negedge' ; NETTYPE : 'nettype' ; NEW : 'new' ; NEXTTIME : 'nexttime' ; NMOS : 'nmos' ; NOR : 'nor' ; NOSHOWCANCELLED : 'noshowcancelled' ; NOT : 'not' ; NOTIFZERO : 'notif0' ; NOTIFONE : 'notif1' ; NULL : 'null' ; OPTIONDT : 'option.' ; OR : 'or' ; OUTPUT : 'output' ; PACKAGE : 'package' ; PACKED : 'packed' ; PARAMETER : 'parameter' ; PMOS : 'pmos' ; POSEDGE : 'posedge' ; PRIMITIVE : 'primitive' ; PRIORITY : 'priority' ; PROGRAM : 'program' ; PROPERTY : 'property' ; PROTECTED : 'protected' ; PULLZERO : 'pull0' ; PULLONE : 'pull1' ; PULLDOWN : 'pulldown' ; PULLUP : 'pullup' ; PULSESTYLE_ONDETECT : 'pulsestyle_ondetect' ; PULSESTYLE_ONEVENT : 'pulsestyle_onevent' ; PURE : 'pure' ; RAND : 'rand' ; RANDC : 'randc' ; RANDCASE : 'randcase' ; RANDOMIZE : 'randomize' ; RANDSEQUENCE : 'randsequence' ; RCMOS : 'rcmos' ; REAL : 'real' ; REALTIME : 'realtime' ; REF : 'ref' ; REG : 'reg' ; REJECT_ON : 'reject_on' ; RELEASE : 'release' ; REPEAT : 'repeat' ; RESTRICT : 'restrict' ; RETURN : 'return' ; RNMOS : 'rnmos' ; RPMOS : 'rpmos' ; RTRAN : 'rtran' ; RTRANIFZERO : 'rtranif0' ; RTRANIFONE : 'rtranif1' ; S_ALWAYS : 's_always' ; S_EVENTUALLY : 's_eventually' ; S_NEXTTIME : 's_nexttime' ; S_UNTIL : 's_until' ; S_UNTIL_WITH : 's_until_with' ; SAMPLE : 'sample' ; SCALARED : 'scalared' ; SEQUENCE : 'sequence' ; SHORTINT : 'shortint' ; SHORTREAL : 'shortreal' ; SHOWCANCELLED : 'showcancelled' ; SIGNED : 'signed' ; SMALL : 'small' ; SOFT : 'soft' ; SOLVE : 'solve' ; SPECIFY : 'specify' ; SPECPARAM : 'specparam' ; STATIC : 'static' ; STD : 'std' ; STRING : 'string' ; STRONG : 'strong' ; STRONGZERO : 'strong0' ; STRONGONE : 'strong1' ; STRUCT : 'struct' ; SUPER : 'super' ; SUPPLYZERO : 'supply0' ; SUPPLYONE : 'supply1' ; SYNC_ACCEPT_ON : 'sync_accept_on' ; SYNC_REJECT_ON : 'sync_reject_on' ; TABLE : 'table' -> mode(UDP_MODE) ; TAGGED : 'tagged' ; TASK : 'task' ; THIS : 'this' ; THROUGHOUT : 'throughout' ; TIME : 'time' ; TIMEPRECISION : 'timeprecision' ; TIMEUNIT : 'timeunit' ; TRAN : 'tran' ; TRANIFZERO : 'tranif0' ; TRANIFONE : 'tranif1' ; TRI : 'tri' ; TRIZERO : 'tri0' ; TRIONE : 'tri1' ; TRIAND : 'triand' ; TRIOR : 'trior' ; TRIREG : 'trireg' ; TYPE : 'type' ; TYPE_OPTIONDT : 'type_option.' ; TYPEDEF : 'typedef' ; UNION : 'union' ; UNIQUE : 'unique' ; UNIQUEZERO : 'unique0' ; UNSIGNED : 'unsigned' ; UNTIL : 'until' ; UNTIL_WITH : 'until_with' ; UNTYPED : 'untyped' ; USE : 'use' ; UWIRE : 'uwire' ; VAR : 'var' ; VECTORED : 'vectored' ; VIRTUAL : 'virtual' ; VOID : 'void' ; WAIT : 'wait' ; WAIT_ORDER : 'wait_order' ; WAND : 'wand' ; WEAK : 'weak' ; WEAKZERO : 'weak0' ; WEAKONE : 'weak1' ; WHILE : 'while' ; WILDCARD : 'wildcard' ; WIRE : 'wire' ; WITH : 'with' ; WITHIN : 'within' ; WOR : 'wor'
ANTLR
; XNOR : 'xnor' ; XOR : 'xor' ; LC : '{' ; VL : '|' ; VLMIGT : '|->' ; VLEQ : '|=' ; VLEQGT : '|=>' ; VLVL : '||' ; RC : '}' ; TI : '~' ; TIAM : '~&' ; TICA : '~^' ; TIVL : '~|' ; TIME_LITERAL : ( UNSIGNED_NUMBER | FIXED_POINT_NUMBER ) TIME_UNIT ; fragment TIME_UNIT : [munpf]? 's' ; DECIMAL_NUMBER : ( SIZE? DECIMAL_BASE )? UNSIGNED_NUMBER | SIZE? DECIMAL_BASE ( X_DIGIT | Z_DIGIT ) '_'* ; BINARY_NUMBER : SIZE? BINARY_BASE BINARY_VALUE ; OCTAL_NUMBER : SIZE? OCTAL_BASE OCTAL_VALUE ; HEX_NUMBER : SIZE? HEX_BASE HEX_VALUE ; fragment SIGN : [+\-] ; fragment SIZE : NON_ZERO_UNSIGNED_NUMBER ; fragment NON_ZERO_UNSIGNED_NUMBER : NON_ZERO_DECIMAL_DIGIT ( '_' | DECIMAL_DIGIT )* ; REAL_NUMBER : FIXED_POINT_NUMBER | UNSIGNED_NUMBER ( '.' UNSIGNED_NUMBER )? EXP SIGN? UNSIGNED_NUMBER ; fragment FIXED_POINT_NUMBER : UNSIGNED_NUMBER '.' UNSIGNED_NUMBER ; fragment EXP : [eE] ; fragment UNSIGNED_NUMBER : DECIMAL_DIGIT ( '_' | DECIMAL_DIGIT )* ; fragment BINARY_VALUE : BINARY_DIGIT ( '_' | BINARY_DIGIT )* ; fragment OCTAL_VALUE : OCTAL_DIGIT ( '_' | OCTAL_DIGIT )* ; fragment HEX_VALUE : HEX_DIGIT ( '_' | HEX_DIGIT )* ; fragment DECIMAL_BASE : '\'' [sS]? [dD] ; fragment BINARY_BASE : '\'' [sS]? [bB] ; fragment OCTAL_BASE : '\'' [sS]? [oO] ; fragment HEX_BASE : '\'' [sS]? [hH] ; fragment NON_ZERO_DECIMAL_DIGIT : [1-9] ; fragment DECIMAL_DIGIT : [0-9] ; fragment BINARY_DIGIT : [01] | X_DIGIT | Z_DIGIT ; fragment OCTAL_DIGIT : [0-7] | X_DIGIT | Z_DIGIT ; fragment HEX_DIGIT : [0-9a-fA-F] | X_DIGIT | Z_DIGIT ; fragment X_DIGIT : [xX] ; fragment Z_DIGIT : [zZ?] ; UNBASED_UNSIZED_LITERAL : '\'0' | '\'1' | '\'' [xXzZ] ; STRING_LITERAL : '"' ( ~["\\] | ESC_SEQ )*? '"' ; fragment ESC_SEQ : '\\' . ; COMMENT : ( ONE_LINE_COMMENT | BLOCK_COMMENT ) -> channel(COMMENTS) ; fragment ONE_LINE_COMMENT : '//' COMMENT_TEXT NEWLINE ; fragment BLOCK_COMMENT : '/*' COMMENT_TEXT '*/' ; fragment COMMENT_TEXT : ASCII_ANY*? ; fragment NEWLINE : '\r'? '\n' ; ESCAPED_IDENTIFIER : '\\' ASCII_PRINTABLE_EXCEPT_SPACE* WHITE_SPACE ; SIMPLE_IDENTIFIER : [a-zA-Z_] [a-zA-Z0-9_$]* ; SYSTEM_TF_IDENTIFIER : '$' [a-zA-Z0-9_$][a-zA-Z0-9_$]* ; WHITE_SPACE : [ \t\r\n]+ -> channel(HIDDEN) ; fragment ASCII_ANY : [\u0000-\u007f] ; fragment ASCII_PRINTABLE : [\u0020-\u007e] ; fragment ASCII_PRINTABLE_EXCEPT_SPACE : [\u0021-\u007e] ; ZERO_OR_ONE_Z_OR_X : [01][zZxX] ; mode LIBRARY_MODE; LMCO : CO -> type(CO) ; LMSC : SC -> type(SC), mode(DEFAULT_MODE) ; LMGA : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; MIINCDIR : '-incdir' ; LIBRARY_ESCAPED_IDENTIFIER : ESCAPED_IDENTIFIER -> type(ESCAPED_IDENTIFIER) ; LIBRARY_SIMPLE_IDENTIFIER : SIMPLE_IDENTIFIER -> type(SIMPLE_IDENTIFIER) ; LIBRARY_COMMENT : COMMENT -> channel(COMMENTS), type(COMMENT) ; FILE_PATH_SPEC : ~[",; \t\r\n\\]+ | PATH_STRING ; fragment PATH_STRING : STRING_LITERAL ; LIBRARY_WHITE_SPACE : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; mode UDP_MODE; UMLP : LP -> type(LP) ; UMRP : RP -> type(RP) ; UMMI : MI -> type(MI) ; UMCL : CL -> type(CL) ; UMSC : SC -> type(SC) ; UMGA : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; //OUTPUT_SYMBOL : [01xX] ; //LEVEL_SYMBOL : [01xX?bB] ; OUTPUT_OR_LEVEL_SYMBOL : [01xX] ; LEVEL_ONLY_SYMBOL : [?bB] ; EDGE_SYMBOL : [rRfFpPnN*] ; UDP_ENDTABLE : 'endtable' -> type(ENDTABLE), mode(DEFAULT_MODE) ; UDP_COMMENT : COMMENT -> channel(COMMENTS), type(COMMENT) ; UDP_WHITE_SPACE : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; mode DIRECTIVE_MODE; FILE_DIRECTIVE : '__FILE__' -> channel(DIRECTIVES), popMode ; LINE_DIRECTIVE_ : '__LINE__' -> channel(DIRECTIVES), popMode ; BEGIN_KEYWORDS_DIRECTIVE : 'begin_keywords' -> channel(DIRECTIVES), mode(DIRECTIVE_TEXT_MODE) ; CELLDEFINE_DIRECTIVE : 'celldefine' -> channel(DIRECTIVES), popMode ; DEFAULT_NETTYPE_DIRECTIVE : 'default_nettype' -> channel(DIRECTIVES), mode(DIRECTIVE_TEXT_MODE) ; DEFINE_DIRECTIVE : 'define' -> channel(DIRECTIVES), mode(DEFINE_DIRECTIVE_MODE) ; ELSE_DIRECTIVE : 'else' -> channel(DIRECTIVES), popMode, mode(SOURCE_TEXT_MODE) ; ELSIF_DIRECTIVE : 'elsif' -> channel(DIRECTIVES), popMode, mode(ELSI
ANTLR
F_DIRECTIVE_MODE) ; END_KEYWORDS_DIRECTIVE : 'end_keywords' -> channel(DIRECTIVES), popMode ; ENDCELLDEFINE_DIRECTIVE : 'endcelldefine' -> channel(DIRECTIVES), popMode ; ENDIF_DIRECTIVE : 'endif' -> channel(DIRECTIVES), popMode, popMode, popMode ; IFDEF_DIRECTIVE : 'ifdef' -> channel(DIRECTIVES), mode(IFDEF_DIRECTIVE_MODE) ; IFNDEF_DIRECTIVE : 'ifndef' -> channel(DIRECTIVES), mode(IFDEF_DIRECTIVE_MODE) ; INCLUDE_DIRECTIVE : 'include' -> channel(DIRECTIVES), mode(DIRECTIVE_TEXT_MODE) ; LINE_DIRECTIVE : 'line' -> channel(DIRECTIVES), mode(DIRECTIVE_TEXT_MODE) ; NOUNCONNECTED_DRIVE_DIRECTIVE : 'nounconnected_drive' -> channel(DIRECTIVES), popMode ; PRAGMA_DIRECTIVE : 'pragma' -> channel(DIRECTIVES), mode(DIRECTIVE_TEXT_MODE) ; RESETALL_DIRECTIVE : 'resetall' -> channel(DIRECTIVES), popMode ; TIMESCALE_DIRECTIVE : 'timescale' -> channel(DIRECTIVES), mode(DIRECTIVE_TEXT_MODE) ; UNCONNECTED_DRIVE_DIRECTIVE : 'unconnected_drive' -> channel(DIRECTIVES), mode(DIRECTIVE_TEXT_MODE) ; UNDEF_DIRECTIVE : 'undef' -> channel(DIRECTIVES), mode(UNDEF_DIRECTIVE_MODE) ; UNDEFINEALL_DIRECTIVE : 'undefineall' -> channel(DIRECTIVES), popMode ; MACRO_USAGE : DIRECTIVE_ID [ \t\r\n]*? MACRO_ARGS? -> channel(DIRECTIVES), popMode ; fragment DIRECTIVE_ID : DIRECTIVE_ESCAPED_ID | DIRECTIVE_SIMPLE_ID ; fragment DIRECTIVE_ESCAPED_ID : '\\' ASCII_PRINTABLE_EXCEPT_SPACE* WHITE_SPACE ; fragment DIRECTIVE_SIMPLE_ID : [a-zA-Z_] [a-zA-Z0-9_$]* ; fragment MACRO_ARGS : '(' ( MACRO_ARGS | ~[()] )* ')' ; mode DIRECTIVE_TEXT_MODE; DIRECTIVE_TEXT : COMMENT_TEXT NEWLINE -> channel(DIRECTIVES), popMode ; mode DEFINE_DIRECTIVE_MODE; DIRECTIVE_IDENTIFIER : DIRECTIVE_ID -> channel(DIRECTIVES), mode(MACRO_TEXT_MODE) ; DIRECTIVE_COMMENT : COMMENT -> channel(COMMENTS) ; DIRECTIVE_WHITE_SPACE : SPACE_TAB -> channel(HIDDEN) ; DIRECTIVE_NEWLINE : NEWLINE -> channel(HIDDEN) ; fragment SPACE_TAB : [ \t]+ ; mode MACRO_TEXT_MODE; MACRO_TEXT : ~[\r\n\\]+ -> channel(DIRECTIVES) ; MACRO_ESC_NEWLINE : '\\' NEWLINE -> channel(DIRECTIVES) ; MACRO_ESC_SEQ : ESC_SEQ -> channel(DIRECTIVES), type(MACRO_TEXT) ; MACRO_NEWLINE : NEWLINE -> channel(HIDDEN), type(DIRECTIVE_NEWLINE), popMode ; mode UNDEF_DIRECTIVE_MODE; UNDEF_IDENTIFIER : DIRECTIVE_ID -> channel(DIRECTIVES), type(DIRECTIVE_IDENTIFIER), popMode ; UNDEF_COMMENT : COMMENT -> channel(COMMENTS), type(DIRECTIVE_COMMENT) ; UNDEF_WHITE_SPACE : SPACE_TAB -> channel(HIDDEN), type(DIRECTIVE_WHITE_SPACE) ; UNDEF_NEWLINE : NEWLINE -> channel(HIDDEN), type(DIRECTIVE_NEWLINE) ; mode IFDEF_DIRECTIVE_MODE; IFDEF_IDENTIFIER : DIRECTIVE_ID -> channel(DIRECTIVES), type(DIRECTIVE_IDENTIFIER), pushMode(SOURCE_TEXT_MODE) ; IFDEF_COMMENT : COMMENT -> channel(COMMENTS), type(DIRECTIVE_COMMENT) ; IFDEF_WHITE_SPACE : SPACE_TAB -> channel(HIDDEN), type(DIRECTIVE_WHITE_SPACE) ; IFDEF_NEWLINE : NEWLINE -> channel(HIDDEN), type(DIRECTIVE_NEWLINE) ; mode ELSIF_DIRECTIVE_MODE; ELSIF_IDENTIFIER : DIRECTIVE_ID -> channel(DIRECTIVES), type(DIRECTIVE_IDENTIFIER), mode(SOURCE_TEXT_MODE) ; ELSIF_COMMENT : COMMENT -> channel(COMMENTS), type(DIRECTIVE_COMMENT) ; ELSIF_WHITE_SPACE : SPACE_TAB -> channel(HIDDEN), type(DIRECTIVE_WHITE_SPACE) ; ELSIF_NEWLINE : NEWLINE -> channel(HIDDEN), type(DIRECTIVE_NEWLINE) ; mode SOURCE_TEXT_MODE; SOURCE_TEXT : ~'`'+ -> channel(DIRECTIVES) ; STGA : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ;
ANTLR
lexer grammar TypeScriptLexer; channels { ERROR } options { superClass=TypeScriptBaseLexer; } MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN); SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); RegularExpressionLiteral: '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart*; OpenBracket: '['; CloseBracket: ']'; OpenParen: '('; CloseParen: ')'; OpenBrace: '{' {this.ProcessOpenBrace();}; CloseBrace: '}' {this.ProcessCloseBrace();}; SemiColon: ';'; Comma: ','; Assign: '='; QuestionMark: '?'; Colon: ':'; Ellipsis: '...'; Dot: '.'; PlusPlus: '++'; MinusMinus: '--'; Plus: '+'; Minus: '-'; BitNot: '~'; Not: '!'; Multiply: '*'; Divide: '/'; Modulus: '%'; RightShiftArithmetic: '>>'; LeftShiftArithmetic: '<<'; RightShiftLogical: '>>>'; LessThan: '<'; MoreThan: '>'; LessThanEquals: '<='; GreaterThanEquals: '>='; Equals_: '=='; NotEquals: '!='; IdentityEquals: '==='; IdentityNotEquals: '!=='; BitAnd: '&'; BitXOr: '^'; BitOr: '|'; And: '&&'; Or: '||'; MultiplyAssign: '*='; DivideAssign: '/='; ModulusAssign: '%='; PlusAssign: '+='; MinusAssign: '-='; LeftShiftArithmeticAssign: '<<='; RightShiftArithmeticAssign: '>>='; RightShiftLogicalAssign: '>>>='; BitAndAssign: '&='; BitXorAssign: '^='; BitOrAssign: '|='; ARROW: '=>'; /// Null Literals NullLiteral: 'null'; /// Boolean Literals BooleanLiteral: 'true' | 'false'; /// Numeric Literals DecimalLiteral: DecimalIntegerLiteral '.' [0-9]* ExponentPart? | '.' [0-9]+ ExponentPart? | DecimalIntegerLiteral ExponentPart? ; /// Numeric Literals HexIntegerLiteral: '0' [xX] HexDigit+; OctalIntegerLiteral: '0' [0-7]+ {!this.IsStrictMode()}?; OctalIntegerLiteral2: '0' [oO] [0-7]+; BinaryIntegerLiteral: '0' [bB] [01]+; /// Keywords Break: 'break'; Do: 'do'; Instanceof: 'instanceof'; Typeof: 'typeof'; Case: 'case'; Else: 'else'; New: 'new'; Var: 'var'; Catch: 'catch'; Finally: 'finally'; Return: 'return'; Void: 'void'; Continue: 'continue'; For: 'for'; Switch: 'switch'; While: 'while'; Debugger: 'debugger'; Function: 'function'; This: 'this'; With: 'with'; Default: 'default'; If: 'if'; Throw: 'throw'; Delete: 'delete'; In: 'in'; Try: 'try'; As: 'as';
ANTLR
From: 'from'; ReadOnly: 'readonly'; Async: 'async'; /// Future Reserved Words Class: 'class'; Enum: 'enum'; Extends: 'extends'; Super: 'super'; Const: 'const'; Export: 'export'; Import: 'import'; /// The following tokens are also considered to be FutureReservedWords /// when parsing strict mode Implements: 'implements' ; Let: 'let' ; Private: 'private' ; Public: 'public' ; Interface: 'interface' ; Package: 'package' ; Protected: 'protected' ; Static: 'static' ; Yield: 'yield' ; //keywords: Any : 'any'; Number: 'number'; Boolean: 'boolean'; String: 'string'; Symbol: 'symbol'; Type: 'type'; Get: 'get '; Set: 'set '; Constructor: 'constructor'; Namespace: 'namespace'; Require: 'require'; Module: 'module'; Declare: 'declare'; Abstract: 'abstract'; Is: 'is'; // // Ext.2 Additions to 1.8: Decorators // At: '@'; /// Identifier Names and Identifiers Identifier: IdentifierStart IdentifierPart*; /// String Literals StringLiteral: ('"' DoubleStringCharacter* '"' | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();} ; TemplateStringLiteral: '`' ('\\`' | ~'`')* '`'; WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); /// Comments HtmlComment: '<!--' .*? '-->' -> channel(HIDDEN); CDataComment: '<![CDATA[' .*? ']]>' -> channel(HIDDEN); UnexpectedCharacter: . -> channel(ERROR); // Fragment rules fragment DoubleStringCharacter : ~["\\\r\n] | '\\' EscapeSequence | LineContinuation ; fragment SingleStringCharacter : ~['\\\r\n] | '\\' EscapeSequence | LineContinuation ; fragment EscapeSequence : CharacterEscapeSequence | '0' // no digit ahead! TODO | HexEscapeSequence | UnicodeEscapeSequence | ExtendedUnicodeEscapeSequence ; fragment CharacterEscapeSequence : SingleEscapeCharacter | NonEscapeCharacter ; fragment HexEscapeSequence : 'x' HexDigit HexDigit ; fragment UnicodeEscapeSequence : 'u' HexDigit HexDigit HexDigit HexDigit ; fragment ExtendedUnicodeEscapeSequence : 'u' '{' HexDigit+ '}' ; fragment SingleEscapeCharacter : ['"\\bfnrtv] ; fragment NonEscapeCharacter : ~['"\\bfnrtv0-9xu\r\n] ; fragment EscapeCharacter : SingleEscapeCharacter | [0-9] | [xu] ; fragment LineContinuation : '\\' [\r\n\u2028\u2029] ; fragment HexDigit : [0-9a-fA-F] ; fragment DecimalIntegerLiteral : '0' | [1-9] [0-9]* ; fragment ExponentPart : [eE] [+-]? [0-9]+ ; fragment IdentifierPart : IdentifierStart | UnicodeCombiningMark | UnicodeDigit | UnicodeConnectorPunctuation | '\u200C' | '\u200D' ; fragment IdentifierStart : UnicodeLetter | [$_] | '\\' UnicodeEscapeSequence ; fragment UnicodeLetter : [\u0041-\u005A] | [\u0061-\u007A] | [\u00AA] | [\u00B5] | [\u00BA] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u021F] | [\u0222-\u0233] | [\u0250-\u02AD] | [\u02B0-\u02B8] | [\u02BB-\u02C1] | [\u02D0-\u02D1] | [\u02E0-\u02E4] | [\u02EE] | [\u037A] | [\u0386] | [\u0388-\u038A] | [\u038C] | [\u038E-\u03A1] | [\u03A3-\u03CE] | [\u03D0-\u03D7] | [\u03DA-\u03F3] | [\u0400-\u0481] | [\u048C-\u04C4] | [\u04C7-\u04C8] | [\u04CB-\u04CC] | [\u04D0-\u04F5] | [\u04F8-\u04F9] | [\u0531-\u0556] | [\u0559] | [\u0561-\u0587]
ANTLR
| [\u05D0-\u05EA] | [\u05F0-\u05F2] | [\u0621-\u063A] | [\u0640-\u064A] | [\u0671-\u06D3] | [\u06D5] | [\u06E5-\u06E6] | [\u06FA-\u06FC] | [\u0710] | [\u0712-\u072C] | [\u0780-\u07A5] | [\u0905-\u0939] | [\u093D] | [\u0950] | [\u0958-\u0961] | [\u0985-\u098C] | [\u098F-\u0990] | [\u0993-\u09A8] | [\u09AA-\u09B0] | [\u09B2] | [\u09B6-\u09B9] | [\u09DC-\u09DD] | [\u09DF-\u09E1] | [\u09F0-\u09F1] | [\u0A05-\u0A0A] | [\u0A0F-\u0A10] | [\u0A13-\u0A28] | [\u0A2A-\u0A30] | [\u0A32-\u0A33] | [\u0A35-\u0A36] | [\u0A38-\u0A39] | [\u0A59-\u0A5C] | [\u0A5E] | [\u0A72-\u0A74] | [\u0A85-\u0A8B] | [\u0A8D] | [\u0A8F-\u0A91] | [\u0A93-\u0AA8] | [\u0AAA-\u0AB0] | [\u0AB2-\u0AB3] | [\u0AB5-\u0AB9] | [\u0ABD] | [\u0AD0] | [\u0AE0] | [\u0B05-\u0B0C] | [\u0B0F-\u0B10] | [\u0B13-\u0B28] | [\u0B2A-\u0B30] | [\u0B32-\u0B33] | [\u0B36-\u0B39] | [\u0B3D] | [\u0B5C-\u0B5D] | [\u0B5F-\u0B61] | [\u0B85-\u0B8A] | [\u0B8E-\u0B90] | [\u0B92-\u0B95] | [\u0B99-\u0B9A] | [\u0B9C] | [\u0B9E-\u0B9F] | [\u0BA3-\u0BA4] | [\u0BA8-\u0BAA] | [\u0BAE-\u0BB5] | [\u0BB7-\u0BB9] | [\u0C05-\u0C0C] | [\u0C0E-\u0C10] | [\u0C12-\u0C28] | [\u0C2A-\u0C33] | [\u0C35-\u0C39] | [\u0C60-\u0C61] | [\u0C85-\u0C8C] | [\u0C8E-\u0C90] | [\u0C92-\u0CA8] | [\u0CAA-\u0CB3] | [\u0CB5-\u0CB9] | [\u0CDE] | [\u0CE0-\u0CE1] | [\u0D05-\u0D0C] | [\u0D0E-\u0D10] | [\u0D12-\u0D28] | [\u0D2A-\u0D39] | [\u0D60-\u0D61] | [\u0D85-\u0D96] | [\u0D9A-\u0DB1] | [\u0DB3-\u0DBB] | [\u0DBD] | [\u0DC0-\u0DC6] | [\u0E01-\u0E30] | [\u0E32-\u0E33] | [\u0E40-\u0E46] | [\u0E81-\u0E82] | [\u0E84] | [\u0E87-\u0E88] | [\u0E8A] | [\u0E8D] | [\u0E94-\u0E97] | [\u0E99-\u0E9F] | [\u0EA1-\u0EA3] | [\u0EA5] | [\u0EA7] | [\u0EAA-\u0EAB] | [\u0EAD-\u0EB0] | [\u0EB2-\u0EB3] | [\u0EBD-\u0EC4] | [\u0EC6] | [\u0EDC-\u0EDD] | [\u0F00] | [\u0F40-\u0F6A] | [\u0F88-\u0F8B] | [\u1000-\u1021] | [\u1023-\u1027] | [\u1029-\u102A] | [\u1050-\u1055] | [\u10A0-\u10C5] | [\u10D0-\u10F6] | [\u1100-\u1159] | [\u115F-\u11A2] | [\u11A8-\u11F9] | [\u1200-\u1206] | [\u1208-\u1246] | [\u1248] | [\u124A-\u124D] | [\u1250-\u1256] | [\u1258] | [\u125A-\u125D] | [\u1260-\u1286] | [\u1288] | [\u128A-\u128D] | [\u1290-\u12AE] | [\u12B0] | [\u12B2-\u12B5] | [\u12B8-\u12BE] | [\u12C0] | [\u12C2-\u12C5] | [\u12C8-\u12CE] | [\u12D0-\u12D6] | [\u12D8-\u12EE] | [\u12F0-\u130E] | [\u1310] | [\u1312-\u1315] | [\u1318-\u131E] | [\u1320-\u1346] | [\u1348-\u135A] | [\u13A0-\u13B0] | [\u13B1-\u13F4] | [\u1401-\u1676] | [\u1681-\u169A] | [\u16A0-\u16EA] | [\u1780-\u17B3] | [\u1820-\u1877] | [\u1880-\u18A8] | [\u1E00-\u1E9B] | [\u1EA0-\u1EE0] | [\u1EE1-\u1EF9] | [\u1F00-\u1F15] | [\u1F18-\u1F1D] | [\u1F20-\u1F39] | [\u1F3A-\u1F45] | [\u1F48-\u1F4D] | [\u1F50-\u1F57] | [\u1F59] | [\u1F5B] | [\u1F5D] | [\u1F5F-\u1F7D] | [\u1F80-\u1FB4] | [\u1FB6-\u1FBC] | [\u1FBE] | [\u1FC2-\u1FC4] | [\u1FC6-\u1FCC] | [\u1FD0-\u1FD3] | [\u1FD6-\u1FDB] | [\u1FE0-\u1FEC] | [\u1FF2-\u1FF4] | [\u1FF6-\u1FFC] | [\u207F] | [\u2102] | [\u2107] | [\u210A-\u2113] | [\u2115] | [\u2119-\u211D] | [\u2124] | [\u2126] | [\u2128] | [\u212A-\u212D] | [\u212F-\u2131] | [\u2133-\u2139] | [\u2160-\u2183] | [\u3005-\u3007] | [\u3021-\u3029] | [\u3031-\u3035] | [\u3038-\u303A] | [\u3041-\u3094] | [\u309D-\u309E] | [\u30A1-\u30FA] | [\u30FC-\u30FE] | [\u3105-\u312C] | [\u3131-\u318E] | [\u31A0-\u31B7] | [\u3400-\u4DBF] | [\u4
ANTLR
E00-\u9FFF] | [\uA000-\uA48C] | [\uAC00] | [\uD7A3] | [\uF900-\uFA2D] | [\uFB00-\uFB06] | [\uFB13-\uFB17] | [\uFB1D] | [\uFB1F-\uFB28] | [\uFB2A-\uFB36] | [\uFB38-\uFB3C] | [\uFB3E] | [\uFB40-\uFB41] | [\uFB43-\uFB44] | [\uFB46-\uFBB1] | [\uFBD3-\uFD3D] | [\uFD50-\uFD8F] | [\uFD92-\uFDC7] | [\uFDF0-\uFDFB] | [\uFE70-\uFE72] | [\uFE74] | [\uFE76-\uFEFC] | [\uFF21-\uFF3A] | [\uFF41-\uFF5A] | [\uFF66-\uFFBE] | [\uFFC2-\uFFC7] | [\uFFCA-\uFFCF] | [\uFFD2-\uFFD7] | [\uFFDA-\uFFDC] ; fragment UnicodeCombiningMark : [\u0300-\u034E] | [\u0360-\u0362] | [\u0483-\u0486] | [\u0591-\u05A1] | [\u05A3-\u05B9] | [\u05BB-\u05BD] | [\u05BF] | [\u05C1-\u05C2] | [\u05C4] | [\u064B-\u0655] | [\u0670] | [\u06D6-\u06DC] | [\u06DF-\u06E4] | [\u06E7-\u06E8] | [\u06EA-\u06ED] | [\u0711] | [\u0730-\u074A] | [\u07A6-\u07B0] | [\u0901-\u0903] | [\u093C] | [\u093E-\u094D] | [\u0951-\u0954] | [\u0962-\u0963] | [\u0981-\u0983] | [\u09BC-\u09C4] | [\u09C7-\u09C8] | [\u09CB-\u09CD] | [\u09D7] | [\u09E2-\u09E3] | [\u0A02] | [\u0A3C] | [\u0A3E-\u0A42] | [\u0A47-\u0A48] | [\u0A4B-\u0A4D] | [\u0A70-\u0A71] | [\u0A81-\u0A83] | [\u0ABC] | [\u0ABE-\u0AC5] | [\u0AC7-\u0AC9] | [\u0ACB-\u0ACD] | [\u0B01-\u0B03] | [\u0B3C] | [\u0B3E-\u0B43] | [\u0B47-\u0B48] | [\u0B4B-\u0B4D] | [\u0B56-\u0B57] | [\u0B82-\u0B83] | [\u0BBE-\u0BC2] | [\u0BC6-\u0BC8] | [\u0BCA-\u0BCD] | [\u0BD7] | [\u0C01-\u0C03] | [\u0C3E-\u0C44] | [\u0C46-\u0C48] | [\u0C4A-\u0C4D] | [\u0C55-\u0C56] | [\u0C82-\u0C83] | [\u0CBE-\u0CC4] | [\u0CC6-\u0CC8] | [\u0CCA-\u0CCD] | [\u0CD5-\u0CD6] | [\u0D02-\u0D03] | [\u0D3E-\u0D43] | [\u0D46-\u0D48] | [\u0D4A-\u0D4D] | [\u0D57] | [\u0D82-\u0D83] | [\u0DCA] | [\u0DCF-\u0DD4] | [\u0DD6] | [\u0DD8-\u0DDF] | [\u0DF2-\u0DF3] | [\u0E31] | [\u0E34-\u0E3A] | [\u0E47-\u0E4E] | [\u0EB1] | [\u0EB4-\u0EB9] | [\u0EBB-\u0EBC] | [\u0EC8-\u0ECD] | [\u0F18-\u0F19] | [\u0F35] | [\u0F37] | [\u0F39] | [\u0F3E-\u0F3F] | [\u0F71-\u0F84] | [\u0F86-\u0F87] | [\u0F90-\u0F97] | [\u0F99-\u0FBC] | [\u0FC6] | [\u102C-\u1032] | [\u1036-\u1039] | [\u1056-\u1059] | [\u17B4-\u17D3] | [\u18A9] | [\u20D0-\u20DC] | [\u20E1] | [\u302A-\u302F] | [\u3099-\u309A] | [\uFB1E] | [\uFE20-\uFE23] ; fragment UnicodeDigit : [\u0030-\u0039] | [\u0660-\u0669] | [\u06F0-\u06F9] | [\u0966-\u096F] | [\u09E6-\u09EF] | [\u0A66-\u0A6F] | [\u0AE6-\u0AEF] | [\u0B66-\u0B6F] | [\u0BE7-\u0BEF] | [\u0C66-\u0C6F] | [\u0CE6-\u0CEF] | [\u0D66-\u0D6F] | [\u0E50-\u0E59] | [\u0ED0-\u0ED9] | [\u0F20-\u0F29] | [\u1040-\u1049] | [\u1369-\u1371] | [\u17E0-\u17E9] | [\u1810-\u1819] | [\uFF10-\uFF19] ; fragment UnicodeConnectorPunctuation : [\u005F] | [\u203F-\u2040] | [\u30FB] | [\uFE33-\uFE34] | [\uFE4D-\uFE4F] | [\uFF3F] | [\uFF65] ; fragment RegularExpressionFirstChar : ~[*\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' ; fragment RegularExpressionChar : ~[\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' ; fragment RegularExpressionClassChar : ~[\r\n\u2028\u2029\]\\] | RegularExpressionBackslashSequence ; fragment RegularExpressionBackslashSequence : '\\' ~[\r\n\u2028\u2029] ;
ANTLR
/* * 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; } } } singleStatement : statement EOF ; singleExpression : namedExpression EOF ; singleTableIdentifier : tableIdentifier EOF ; singleFunctionIdentifier : functionIdentifier EOF ; singleDataType : dataType EOF ; singleTableSchema : colTypeList EOF ; statement : query #statementDefault | USE db=identifier #use | CREATE DATABASE (IF NOT EXISTS)? identifier (COMMENT comment=STRING)? locationSpec? (WITH DBPROPERTIES tablePropertyList)? #createDatabase | ALTER DATABASE identifier SET DBPROPERTIES tablePropertyList #setDatabaseProperties | DROP DATABASE (IF EXISTS)? identifier (RESTRICT | CASCADE)? #dropDatabase | createTableHeader ('(' colTypeList ')')? tableProvider ((OPTIONS options=tablePropertyList) | (PARTITIONED BY partitionColumnNames=identifierList) | bucketSpec | locationSpec | (COMMENT comment=STRING) | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createTable | createTableHeader ('(' columns=colTypeList ')')? ((COMMENT comment=STRING) | (PARTITIONED BY '(' partitionColumns=colTypeList ')') | bucketSpec | skewSpec | rowFormat | createFileFormat | locationSpec | (TBLPROPERTIES tableProps=tablePropertyList))* (AS? query)? #createHiveTable | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier LIKE source=tableIdentifier locationSpec? #createTableLike | ANALYZE TABLE tableIdentifier partitionSpec? COMPUTE STATISTICS (identifier | FOR COLUMNS identifierSeq)? #analyze | ALTER TABLE tableIdentifier ADD COLUMNS '(' columns=colTypeList ')' #addTableColumns | ALTER (TABLE | VIEW) from=tableIdentifier RENAME TO to=tableIdentifier #renameTab
ANTLR
le | ALTER (TABLE | VIEW) tableIdentifier SET TBLPROPERTIES tablePropertyList #setTableProperties | ALTER (TABLE | VIEW) tableIdentifier UNSET TBLPROPERTIES (IF EXISTS)? tablePropertyList #unsetTableProperties | ALTER TABLE tableIdentifier partitionSpec? CHANGE COLUMN? identifier 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 tableIdentifier from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition | ALTER TABLE tableIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions | ALTER VIEW tableIdentifier DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* #dropTablePartitions | ALTER TABLE tableIdentifier partitionSpec? SET locationSpec #setTableLocation | ALTER TABLE tableIdentifier RECOVER PARTITIONS #recoverPartitions | DROP TABLE (IF EXISTS)? tableIdentifier PURGE? #dropTable | DROP VIEW (IF EXISTS)? tableIdentifier #dropTable | 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) db=identifier)? (LIKE? pattern=STRING)? #showTables | SHOW TABLE EXTENDED ((FROM | IN) db=identifier)? LIKE pattern=STRING partitionSpec? #showTable | SHOW DATABASES (LIKE? pattern=STRING)? #showDatabases | SHOW TBLPROPERTIES table=tableIdentifier ('(' key=tablePropertyKey ')')? #showTblProperties | SHOW COLUMNS (FROM | IN) tableIdentifier ((FROM | IN) db=identifier)? #showColumns | SHOW PARTITIONS tableIdentifier partitionSpec? #showPartitions | SHOW identifier? FUNCTIONS (LIKE? (qualifiedName | pattern=STRING))? #showFunctions | SHOW CREATE TABLE tableIdentifier #showCreateTable | (DESC | DESCRIBE) FUNCTION EXTENDED? describeFuncName #describeFunction | (DESC | DESCRIBE) DATABASE EXTENDED? identifier #describeDatabase | (DESC | DESCRIBE) TABLE? option=(EXTENDED | FORMATTED)? tableIdentifier partitionSpec? describeColName? #describeTable | REFRESH TABLE tableIdentifier #refreshTable | REFRESH (STRING | .*?) #refreshResource | CACHE
ANTLR
LAZY? TABLE tableIdentifier (AS? query)? #cacheTable | UNCACHE TABLE (IF EXISTS)? tableIdentifier #uncacheTable | CLEAR CACHE #clearCache | LOAD DATA LOCAL? INPATH path=STRING OVERWRITE? INTO TABLE tableIdentifier partitionSpec? #loadData | TRUNCATE TABLE tableIdentifier partitionSpec? #truncateTable | MSCK REPAIR TABLE tableIdentifier #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)? tableIdentifier ; 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? queryNoWith ; insertInto : INSERT OVERWRITE TABLE tableIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable | INSERT INTO TABLE? tableIdentifier partitionSpec? #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)? ; describeFuncName : qualifiedN
ANTLR
ame | STRING | comparisonOperator | arithmeticOperator | predicateOperator ; describeColName : nameParts+=identifier ('.' nameParts+=identifier)* ; ctes : WITH namedQuery (',' namedQuery)* ; namedQuery : name=identifier 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 ; queryNoWith : 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)*)? windows? (LIMIT (ALL | limit=expression))? (OFFSET (ALL | offset=expression))? ; multiInsertQueryBody : insertInto? querySpecification queryOrganization ; 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 | TABLE tableIdentifier #table | inlineTable #inlineTableDefault1 | '(' queryNoWith ')' #subquery ; sortItem : expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))? ; querySpecification : (((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)? fromClause? (WHERE where=booleanExpression)?) | ((kind=SELECT (hints+=hint)* setQuantifier? namedExpressionSeq fromClause? | fromClause (kind=SELECT setQuantifier? namedExpressionSeq)?) lateralView* (WHERE where=booleanExpression)? aggregation? (HAVING having=booleanExpression)? windows?) ; hint : '/*+' hintStatements+=hintStatement (','? hintStatements+=hintStatement)* '*/' ; hintStatement : hintName=identifier | hintName=identifier '(' parameters+=primaryExpression (',' parameters+=primaryExpression)* ')' ; fromClause : FROM relation (',' relation)* lateralView* pivotClause? ; aggregation : GROUP BY groupingExp
ANTLR
ressions+=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 '(' identifier (',' identifier)* ')' ; 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 : identifier (',' identifier)* ; orderedIdentifierList : '(' orderedIdentifier (',' orderedIdentifier)* ')' ; orderedIdentifier : identifier ordering=(ASC | DESC)? ; identifierCommentList : '(' identifierComment (',' identifierComment)* ')' ; identifierComment : identifier (COMMENT STRING)? ; relationPrimary : tableIdentifier sample? tableAlias #tableName | '(' queryNoWith ')' sample? tableAlias #aliasedQuery | '(' relation ')' sample? tableAlias #aliasedRelation | inlineTable #inlineTableDefault2 | functionTable #tableValuedFunction ; inlineTable : VALUES expression (',' expression)* tableAlias ; functionTable : identifier '(' (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 ; tableIdentifier : (db=identifier '.')? table=identifier ; functionIdentifier : (db=identifier '.')? function=identifier ; namedExpression : expression (AS? (identifier | identifierList))? ; namedExpressionSeq : namedExpression (',' namedExpression)* ; 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=BETWE
ANTLR
EN lower=valueExpression AND upper=valueExpression | NOT? kind=IN '(' expression (',' expression)* ')' | NOT? kind=IN '(' query ')' | NOT? kind=(RLIKE | LIKE) pattern=valueExpression | NOT? kind=(MATCH | MATCH_PHRASE) right=valueExpression | IS NOT? kind=NULL | 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 : 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 | qualifiedName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')' (OVER windowSpec)? #functionCall | qualifiedName '(' trimOption=(BOTH | LEADING | TRAILING) argument+=expression FROM argument+=expression ')' #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 ; constant : NULL #nullLiteral | interval #intervalLiteral | identifier STRING #typeConstructor | number
ANTLR
#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 intervalField* ; intervalField : value=intervalValue unit=identifier (TO to=identifier)? ; intervalValue : (PLUS | MINUS)? (INTEGER_VALUE | DECIMAL_VALUE) | STRING ; colPosition : FIRST | AFTER identifier ; dataType : complex=ARRAY '<' dataType '>' #complexDataType | complex=MAP '<' dataType ',' dataType '>' #complexDataType | complex=STRUCT ('<' complexColTypeList? '>' | NEQ) #complexDataType | identifier ('(' INTEGER_VALUE (',' INTEGER_VALUE)* ')')? #primitiveDataType ; colTypeList : colType (',' colType)* ; colType : identifier dataType (COMMENT STRING)? ; complexColTypeList : complexColType (',' complexColType)* ; complexColType : identifier ':' dataType (COMMENT STRING)? ; whenClause : WHEN condition=expression THEN result=expression ; windows : WINDOW namedWindow (',' namedWindow)* ; namedWindow : identifier AS windowSpec ; windowSpec : name=identifier #windowRef | '('name=identifier')' #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) ; qualifiedName : identifier ('.' identifier)* ; identifier : strictIdentifier | ANTI | FULL | INNER | LEFT | SEMI | RIGHT | NATURAL | JOIN | CROSS | ON | UNION | INTERSECT | EXCEPT | SETMINUS ; strictIdentifier : IDENTIFIER #unquotedIdentifier | quotedIdentifier #quotedIdentifierAlternative | 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 ; nonReserved : SHOW | TABLES | COLUMNS | COLUMN | PARTITIONS | FUNCTIONS | DATABASES | ADD | OVER | PARTITION | RANGE | ROWS | PRECEDING | FOLLOWING | CURRENT | ROW | LAST | FIRST | AFTER | MAP | ARRAY | STRUCT | PIVOT | LATERAL | WINDOW | REDUCE | TRANSFORM | SERDE | SERDEPROPERTIES | RECORDREADER | DELIMITED | FIELDS | TERMINATED | COLLECTION | ITEMS | KEYS | ESCAPED | LINES | SEPARATED | EXTENDED | REFRESH | CLEAR | CACHE | UNCACHE | LAZY | GLOBAL | TEMPORARY | OPTIONS | GROUPING | CUBE | ROLLUP | EXPLAIN | FORMAT | LOGICAL | FORMATTED | CODEGEN | COST | TABLESAMPLE | USE | TO | BUCKET | PERCENTLIT | OUT | OF | SET | RESET | VIEW | REPLACE | IF | POSITION | EXTRACT | NO | DATA | START | TRANSACTION | COMMIT | ROLLBACK | IGNORE | SORT | CLUSTER | DISTRIBUTE | UNSET | TBLPROPERTIES | SKEWED | STORED | DIRECTORI
ANTLR
ES | LOCATION | EXCHANGE | ARCHIVE | UNARCHIVE | FILEFORMAT | TOUCH | COMPACT | CONCATENATE | CHANGE | CASCADE | RESTRICT | BUCKETS | CLUSTERED | SORTED | PURGE | INPUTFORMAT | OUTPUTFORMAT | DBPROPERTIES | DFS | TRUNCATE | COMPUTE | LIST | STATISTICS | ANALYZE | PARTITIONED | EXTERNAL | DEFINED | RECORDWRITER | REVOKE | GRANT | LOCK | UNLOCK | MSCK | REPAIR | RECOVER | EXPORT | IMPORT | LOAD | VALUES | COMMENT | ROLE | ROLES | COMPACTIONS | PRINCIPALS | TRANSACTIONS | INDEX | INDEXES | LOCKS | OPTION | LOCAL | INPATH | ASC | DESC | LIMIT | RENAME | SETS | OFFSET | AT | NULLS | OVERWRITE | ALL | ANY | ALTER | AS | BETWEEN | BY | CREATE | DELETE | DESCRIBE | DROP | EXISTS | FALSE | FOR | GROUP | IN | INSERT | INTO | IS |LIKE | NULL | ORDER | OUTER | TABLE | TRUE | WITH | RLIKE | MATCH | MATCH_PHRASE | AND | CASE | CAST | DISTINCT | DIV | ELSE | END | FUNCTION | INTERVAL | MACRO | OR | STRATIFY | THEN | UNBOUNDED | WHEN | DATABASE | SELECT | FROM | WHERE | HAVING | TO | TABLE | WITH | NOT | DIRECTORY | BOTH | LEADING | TRAILING ; SELECT: 'SELECT'; FROM: 'FROM'; ADD: 'ADD'; AS: 'AS'; ALL: 'ALL'; ANY: 'ANY'; DISTINCT: 'DISTINCT'; WHERE: 'WHERE'; GROUP: 'GROUP'; BY: 'BY'; GROUPING: 'GROUPING'; SETS: 'SETS'; CUBE: 'CUBE'; ROLLUP: 'ROLLUP'; ORDER: 'ORDER'; HAVING: 'HAVING'; LIMIT: 'LIMIT'; OFFSET: 'OFFSET'; AT: 'AT'; OR: 'OR'; AND: 'AND'; IN: 'IN'; NOT: 'NOT' | '!'; NO: 'NO'; EXISTS: 'EXISTS'; BETWEEN: 'BETWEEN'; LIKE: 'LIKE'; RLIKE: 'RLIKE' | 'REGEXP'; MATCH: 'MATCH'; MATCH_PHRASE: 'MATCH_PHRASE'; IS: 'IS'; NULL: 'NULL'; TRUE: 'TRUE'; FALSE: 'FALSE'; NULLS: 'NULLS'; ASC: 'ASC'; DESC: 'DESC'; FOR: 'FOR'; INTERVAL: 'INTERVAL'; CASE: 'CASE'; WHEN: 'WHEN'; THEN: 'THEN'; ELSE: 'ELSE'; END: 'END'; JOIN: 'JOIN'; CROSS: 'CROSS'; OUTER: 'OUTER'; INNER: 'INNER'; LEFT: 'LEFT'; SEMI: 'SEMI'; RIGHT: 'RIGHT'; FULL: 'FULL'; NATURAL: 'NATURAL'; ON: 'ON'; PIVOT: 'PIVOT'; LATERAL: 'LATERAL'; WINDOW: 'WINDOW'; OVER: 'OVER'; PARTITION: 'PARTITION'; RANGE: 'RANGE'; ROWS: 'ROWS'; UNBOUNDED: 'UNBOUNDED'; PRECEDING: 'PRECEDING'; FOLLOWING: 'FOLLOWING'; CURRENT: 'CURRENT'; FIRST: 'FIRST'; AFTER: 'AFTER'; LAST: 'LAST'; ROW: 'ROW'; WITH: 'WITH'; VALUES: 'VALUES'; CREATE: 'CREATE'; TABLE: 'TABLE'; DIRECTORY: 'DIRECTORY'; VIEW: 'VIEW'; REPLACE: 'REPLACE'; INSERT: 'INSERT'; DELETE: 'DELETE'; INTO: 'INTO'; DESCRIBE: 'DESCRIBE'; EXPLAIN: 'EXPLAIN'; FORMAT: 'FORMAT'; LOGICAL: 'LOGICAL'; CODEGEN: 'CODEGEN'; COST: 'COST'; CAST: 'CAST'; SHOW: 'SHOW'; TABLES: 'TABLES'; COLUMNS: 'COLUMNS'; COLUMN: 'COLUMN'; USE: 'USE'; PARTITIONS: 'PARTITIONS'; FUNCTIONS: 'FUNCTIONS'; DROP: 'DROP'; UNION: 'UNION'; EXCEPT: 'EXCEPT'; SETMINUS: 'MINUS'; INTERSECT: 'INTERSECT'; TO: 'TO'; TABLESAMPLE: 'TABLESAMPLE'; STRATIFY: 'STRATIFY'; ALTER: 'ALTER'; RENAME: 'RENAME'; ARRAY: 'ARRAY'; MAP: 'MAP'; STRUCT: 'STRUCT'; COMMENT: 'COMMENT'; SET: 'SET'; RESET: 'RESET'; DATA: 'DATA'; START: 'START'; TRANSACTION: 'TRANSACTION'; COMMIT: 'COMMIT'; ROLLBACK: 'ROLLBACK'; MACRO: 'MACRO'; IGNORE: 'IGNORE'; BOTH: 'BOTH'; LEADING: 'LEADING'; TRAILING: 'TRAILING'; IF: 'IF'; POSITION: 'POSITION'; EXTRACT: 'EXTRACT'; EQ : '=' | '=='; NSEQ: '<=>'; NEQ : '<>'; NEQJ: '!='; LT : '<'; LTE : '<=' | '!>'; GT : '>'; GTE : '>=' | '!<'; PLUS: '+'; MINUS: '-'; ASTERISK: '*'; SLASH: '/'; PERCENT: '%'; DIV: 'DIV'; TILDE: '~'; AMPERSAND: '&'; PIPE: '|'; CONCAT_PIPE: '||'; HAT: '^'; PERCENTLIT: 'PERCENT'; BUCKET: 'BUCKET'; OUT: 'OUT'; OF: 'OF'; SORT: 'SORT'; CLUSTER: 'CLUSTER'; DISTRIBUTE: 'DISTRIBUTE'; OVERWRITE: 'OVERWRITE'; TRANSFORM: 'TRANSFORM'; REDUCE: 'REDUCE'; USING: 'USING'; SERDE: 'SERDE'; SERDEPROPERTIES: 'SERDEPROPERTIES'; RECORDREADER: 'RECORDREADER'; RECORDWRITER: 'RECORDWRITER'; DELIMITED: 'DELIMITED'; FIELDS: 'FIELDS'; TERMINATED: 'TERMINATED'; COLLECTION: 'COLLECTION'; ITEMS: 'ITEMS'; KEYS: 'KEYS'; ESCAPED: 'ESCAPED'; LINES: 'LINES'; SEPARATED: 'SEPARATED'; FUNCTION: 'FUNCTION'; EXTENDED: 'EXTENDED'; REFRESH: 'REFRESH'; CLEAR: 'CLEAR'; CACHE: 'CACHE'; UNCACHE: 'UNCACHE'; LAZY: 'LAZY'; FORMATTED: 'FORMATTED'; GLOBAL: 'GLOBAL'; TEMP
ANTLR
ORARY: 'TEMPORARY' | 'TEMP'; OPTIONS: 'OPTIONS'; UNSET: 'UNSET'; TBLPROPERTIES: 'TBLPROPERTIES'; DBPROPERTIES: 'DBPROPERTIES'; BUCKETS: 'BUCKETS'; SKEWED: 'SKEWED'; STORED: 'STORED'; DIRECTORIES: 'DIRECTORIES'; LOCATION: 'LOCATION'; EXCHANGE: 'EXCHANGE'; ARCHIVE: 'ARCHIVE'; UNARCHIVE: 'UNARCHIVE'; FILEFORMAT: 'FILEFORMAT'; TOUCH: 'TOUCH'; COMPACT: 'COMPACT'; CONCATENATE: 'CONCATENATE'; CHANGE: 'CHANGE'; CASCADE: 'CASCADE'; RESTRICT: 'RESTRICT'; CLUSTERED: 'CLUSTERED'; SORTED: 'SORTED'; PURGE: 'PURGE'; INPUTFORMAT: 'INPUTFORMAT'; OUTPUTFORMAT: 'OUTPUTFORMAT'; DATABASE: 'DATABASE' | 'SCHEMA'; DATABASES: 'DATABASES' | 'SCHEMAS'; DFS: 'DFS'; TRUNCATE: 'TRUNCATE'; ANALYZE: 'ANALYZE'; COMPUTE: 'COMPUTE'; LIST: 'LIST'; STATISTICS: 'STATISTICS'; PARTITIONED: 'PARTITIONED'; EXTERNAL: 'EXTERNAL'; DEFINED: 'DEFINED'; REVOKE: 'REVOKE'; GRANT: 'GRANT'; LOCK: 'LOCK'; UNLOCK: 'UNLOCK'; MSCK: 'MSCK'; REPAIR: 'REPAIR'; RECOVER: 'RECOVER'; EXPORT: 'EXPORT'; IMPORT: 'IMPORT'; LOAD: 'LOAD'; ROLE: 'ROLE'; ROLES: 'ROLES'; COMPACTIONS: 'COMPACTIONS'; PRINCIPALS: 'PRINCIPALS'; TRANSACTIONS: 'TRANSACTIONS'; INDEX: 'INDEX'; INDEXES: 'INDEXES'; LOCKS: 'LOCKS'; OPTION: 'OPTION'; ANTI: 'ANTI'; LOCAL: 'LOCAL'; INPATH: 'INPATH'; 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 : . ;
ANTLR
/* Python grammar The MIT License (MIT) Copyright (c) 2021 Robert Einhorn Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* * Project : an ANTLR4 parser grammar by the official PEG grammar * https://github.com/RobEin/ANTLR4-parser-for-Python-3.13 * Developed by : Robert Einhorn * */ /* * Contributors : [Willie Shen](https://github.com/Willie169) */ // Python 3.13.2 https://docs.python.org/3.13/reference/grammar.html#full-grammar-specification parser grammar PythonParser; options { tokenVocab=PythonLexer; } // STARTING RULES // ============== file_input: statements? EOF; interactive: statement_newline; eval: expressions NEWLINE* EOF; func_type: '(' type_expressions? ')' '->' expression NEWLINE* EOF; // GENERAL STATEMENTS // ================== statements: statement+; statement: compound_stmt | simple_stmts; statement_newline : compound_stmt NEWLINE | simple_stmts | NEWLINE | EOF; simple_stmts : simple_stmt (';' simple_stmt)* ';'? NEWLINE ; // NOTE: assignment MUST precede expression, else parsing a simple assignment // will throw a SyntaxError. simple_stmt : assignment | type_alias | star_expressions | return_stmt | import_stmt | raise_stmt | 'pass' | del_stmt | yield_stmt | assert_stmt | 'break' | 'continue' | global_stmt | nonlocal_stmt; compound_stmt : function_def | if_stmt | class_def | with_stmt | for_stmt | try_stmt | while_stmt | match_stmt; // SIMPLE STATEMENTS // ================= // NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield' assignment : name ':' expression ('=' annotated_rhs )? | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ('=' annotated_rhs )? | (star_targets '=' )+ (yield_expr | star_expressions) TYPE_COMMENT? | single_target augassign (yield_expr | star_expressions); annotated_rhs: yield_expr | star_expressions; augassign : '+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//='; return_stmt : 'return' star_expressions?; raise_stmt : 'raise' (expression ('from' expression )?)? ; global_stmt: 'global' name (',' name)*; nonlocal_stmt: 'nonlocal' name (',' name)*; del_stmt : 'del' del_targets; yield_stmt: yield_expr; assert_stmt: 'assert' expression (',' expression )?; import_stmt : import_name | import_from; // Import statements // ----------------- import_name: 'import' dotted_as_names; // note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS import_from : 'from' ('.' | '...')* dotted_name 'import' import_from_targets | 'from' ('.' | '...')+ 'import' import_from_targets; import_from_targets : '(' import_from_as_names ','? ')' | import_from_as_names | '*'; import_from_as_names : import_from_as_name (',' import_from_as_name)*; import_from_as_name : name ('as' name )?; dotted_as_names : dotted_as_name (',' dotted_as_n
ANTLR
ame)*; dotted_as_name : dotted_name ('as' name )?; dotted_name : dotted_name '.' name | name; // COMPOUND STATEMENTS // =================== // Common elements // --------------- block : NEWLINE INDENT statements DEDENT | simple_stmts; decorators: ('@' named_expression NEWLINE )+; // Class definitions // ----------------- class_def : decorators class_def_raw | class_def_raw; class_def_raw : 'class' name type_params? ('(' arguments? ')' )? ':' block; // Function definitions // -------------------- function_def : decorators function_def_raw | function_def_raw; function_def_raw : 'def' name type_params? '(' params? ')' ('->' expression )? ':' func_type_comment? block | 'async' 'def' name type_params? '(' params? ')' ('->' expression )? ':' func_type_comment? block; // Function parameters // ------------------- params : parameters; parameters : slash_no_default param_no_default* param_with_default* star_etc? | slash_with_default param_with_default* star_etc? | param_no_default+ param_with_default* star_etc? | param_with_default+ star_etc? | star_etc; // Some duplication here because we can't write (',' | {isCurrentTokenType(RPAR)}?), // which is because we don't support empty alternatives (yet). slash_no_default : param_no_default+ '/' ','? ; slash_with_default : param_no_default* param_with_default+ '/' ','? ; star_etc : '*' param_no_default param_maybe_default* kwds? | '*' param_no_default_star_annotation param_maybe_default* kwds? | '*' ',' param_maybe_default+ kwds? | kwds; kwds : '**' param_no_default; // One parameter. This *includes* a following comma and type comment. // // There are three styles: // - No default_assignment // - With default_assignment // - Maybe with default_assignment // // There are two alternative forms of each, to deal with type comments: // - Ends in a comma followed by an optional type comment // - No comma, optional type comment, must be followed by close paren // The latter form is for a final parameter without trailing comma. // param_no_default : param ','? TYPE_COMMENT? ; param_no_default_star_annotation : param_star_annotation ','? TYPE_COMMENT? ; param_with_default : param default_assignment ','? TYPE_COMMENT? ; param_maybe_default : param default_assignment? ','? TYPE_COMMENT? ; param: name annotation?; param_star_annotation: name star_annotation; annotation: ':' expression; star_annotation: ':' star_expression; default_assignment: '=' expression; // If statement // ------------ if_stmt : 'if' named_expression ':' block (elif_stmt | else_block?) ; elif_stmt : 'elif' named_expression ':' block (elif_stmt | else_block?) ; else_block : 'else' ':' block; // While statement // --------------- while_stmt : 'while' named_expression ':' block else_block?; // For statement // ------------- for_stmt : 'async'? 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? ; // With statement // -------------- with_stmt : 'with' '(' with_item (',' with_item)* ','? ')' ':' TYPE_COMMENT? block | 'async' 'with' '(' with_item (',' with_item)* ','? ')' ':' block | 'async'? 'with' with_item (',' with_item)* ':' TYPE_COMMENT? block ; with_item : expression ('as' star_target)? ; // Try statement // ------------- try_stmt : 'try' ':' block finally_block | 'try' ':' block except_block+ else_block? finally_block? | 'try' ':' block except_star_block+ else_block? finally_block?; // Except statement // ---------------- except_block : 'except' (expression ('as' name )?)? ':' block ; except_star_block : 'except' '*' expression ('as' name )? ':' block; finally_block : 'finally' ':' block; // Match statement // --------------- match_stmt : 'match' subject_expr ':' NEWLINE INDENT case_block+ DEDENT; subject_expr : star_named_expression ',' star_named_expressions? | named_expression; case_block : 'case' patterns guard? ':' block;
ANTLR
guard: 'if' named_expression; patterns : open_sequence_pattern | pattern; pattern : as_pattern | or_pattern; as_pattern : or_pattern 'as' pattern_capture_target; or_pattern : closed_pattern ('|' closed_pattern)*; closed_pattern : literal_pattern | capture_pattern | wildcard_pattern | value_pattern | group_pattern | sequence_pattern | mapping_pattern | class_pattern; // Literal patterns are used for equality and identity constraints literal_pattern : signed_number | complex_number | strings | 'None' | 'True' | 'False'; // Literal expressions are used to restrict permitted mapping pattern keys literal_expr : signed_number | complex_number | strings | 'None' | 'True' | 'False'; complex_number : signed_real_number ('+' | '-') imaginary_number ; signed_number : '-'? NUMBER ; signed_real_number : '-'? real_number ; real_number : NUMBER; imaginary_number : NUMBER; capture_pattern : pattern_capture_target; pattern_capture_target : name_except_underscore; wildcard_pattern : '_'; value_pattern : attr; attr : name ('.' name)+ ; name_or_attr : name ('.' name)* ; group_pattern : '(' pattern ')'; sequence_pattern : '[' maybe_sequence_pattern? ']' | '(' open_sequence_pattern? ')'; open_sequence_pattern : maybe_star_pattern ',' maybe_sequence_pattern?; maybe_sequence_pattern : maybe_star_pattern (',' maybe_star_pattern)* ','?; maybe_star_pattern : star_pattern | pattern; star_pattern : '*' name ; mapping_pattern : LBRACE RBRACE | LBRACE double_star_pattern ','? RBRACE | LBRACE items_pattern (',' double_star_pattern)? ','? RBRACE ; items_pattern : key_value_pattern (',' key_value_pattern)*; key_value_pattern : (literal_expr | attr) ':' pattern; double_star_pattern : '**' pattern_capture_target; class_pattern : name_or_attr '(' ((positional_patterns (',' keyword_patterns)? | keyword_patterns) ','?)? ')' ; positional_patterns : pattern (',' pattern)*; keyword_patterns : keyword_pattern (',' keyword_pattern)*; keyword_pattern : name '=' pattern; // Type statement // --------------- type_alias : 'type' name type_params? '=' expression; // Type parameter declaration // -------------------------- type_params: '[' type_param_seq ']'; type_param_seq: type_param (',' type_param)* ','?; type_param : name type_param_bound? type_param_default? | '*' name type_param_starred_default? | '**' name type_param_default? ; type_param_bound: ':' expression; type_param_default: '=' expression; type_param_starred_default: '=' star_expression; // EXPRESSIONS // ----------- expressions : expression (',' expression )* ','? ; expression : disjunction ('if' disjunction 'else' expression)? | lambdef ; yield_expr : 'yield' ('from' expression | star_expressions?) ; star_expressions : star_expression (',' star_expression )* ','? ; star_expression : '*' bitwise_or | expression; star_named_expressions: star_named_expression (',' star_named_expression)* ','?; star_named_expression : '*' bitwise_or | named_expression; assignment_expression : name ':=' expression; named_expression : assignment_expression | expression; disjunction : conjunction ('or' conjunction )* ; conjunction : inversion ('and' inversion )* ; inversion : 'not' inversion | comparison; // Comparison operators // -------------------- comparison : bitwise_or compare_op_bitwise_or_pair* ; compare_op_bitwise_or_pair : eq_bitwise_or | noteq_bitwise_or | lte_bitwise_or | lt_bitwise_or | gte_bitwise_or | gt_bitwise_or | notin_bitwise_or | in_bitwise_or | isnot_bitwise_or | is_bitwise_or; eq_bitwise_or: '==' bitwise_or; noteq_bitwise_or : ('!=' ) bitwise_or; lte_bitwise_or: '<=' bitwise_or; lt_bitwise_or: '<' bitwise_or; gte_bitwise_or: '>=' bitwise
ANTLR
_or; gt_bitwise_or: '>' bitwise_or; notin_bitwise_or: 'not' 'in' bitwise_or; in_bitwise_or: 'in' bitwise_or; isnot_bitwise_or: 'is' 'not' bitwise_or; is_bitwise_or: 'is' bitwise_or; // Bitwise operators // ----------------- bitwise_or : bitwise_or '|' bitwise_xor | bitwise_xor; bitwise_xor : bitwise_xor '^' bitwise_and | bitwise_and; bitwise_and : bitwise_and '&' shift_expr | shift_expr; shift_expr : shift_expr ('<<' | '>>') sum | sum ; // Arithmetic operators // -------------------- sum : sum ('+' | '-') term | term ; term : term ('*' | '/' | '//' | '%' | '@') factor | factor ; factor : '+' factor | '-' factor | '~' factor | power; power : await_primary ('**' factor)? ; // Primary elements // ---------------- // Primary elements are things like "obj.something.something", "obj[something]", "obj(something)", "obj" ... await_primary : 'await' primary | primary; primary : primary ('.' name | genexp | '(' arguments? ')' | '[' slices ']') | atom ; slices : slice | (slice | starred_expression) (',' (slice | starred_expression))* ','?; slice : expression? ':' expression? (':' expression? )? | named_expression; atom : name | 'True' | 'False' | 'None' | strings | NUMBER | (tuple | group | genexp) | (list | listcomp) | (dict | set | dictcomp | setcomp) | '...'; group : '(' (yield_expr | named_expression) ')'; // Lambda functions // ---------------- lambdef : 'lambda' lambda_params? ':' expression; lambda_params : lambda_parameters; // lambda_parameters etc. duplicates parameters but without annotations // or type comments, and if there's no comma after a parameter, we expect // a colon, not a close parenthesis. (For more, see parameters above.) // lambda_parameters : lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? | lambda_param_with_default+ lambda_star_etc? | lambda_star_etc; lambda_slash_no_default : lambda_param_no_default+ '/' ','? ; lambda_slash_with_default : lambda_param_no_default* lambda_param_with_default+ '/' ','? ; lambda_star_etc : '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? | '*' ',' lambda_param_maybe_default+ lambda_kwds? | lambda_kwds; lambda_kwds : '**' lambda_param_no_default; lambda_param_no_default : lambda_param ','? ; lambda_param_with_default : lambda_param default_assignment ','? ; lambda_param_maybe_default : lambda_param default_assignment? ','? ; lambda_param: name; // LITERALS // ======== fstring_middle : fstring_replacement_field | FSTRING_MIDDLE; fstring_replacement_field : LBRACE annotated_rhs '='? fstring_conversion? fstring_full_format_spec? RBRACE; fstring_conversion : '!' name; fstring_full_format_spec : ':' fstring_format_spec*; fstring_format_spec : FSTRING_MIDDLE | fstring_replacement_field; fstring : FSTRING_START fstring_middle* FSTRING_END; string: STRING; strings: (fstring|string)+; list : '[' star_named_expressions? ']'; tuple : '(' (star_named_expression ',' star_named_expressions? )? ')'; set: LBRACE star_named_expressions RBRACE; // Dicts // ----- dict : LBRACE double_starred_kvpairs? RBRACE; double_starred_kvpairs: double_starred_kvpair (',' double_starred_kvpair)* ','?; double_starred_kvpair : '**' bitwise_or | kvpair; kvpair: expression ':' expression; // Comprehensions & Generators // --------------------------- for_if_clauses : for_if_clause+; for_if_clause : 'async'? 'for' star_targets 'in' disjunction ('if' disjunction )* ; listcomp : '[' named_expression for_if_clauses ']'; setcomp : LBRACE named_expression for_if_clauses RBRACE; genexp : '(' ( assignment_expression | expression) for_if_clauses ')';
ANTLR
dictcomp : LBRACE kvpair for_if_clauses RBRACE; // FUNCTION CALL ARGUMENTS // ======================= arguments : args ','?; args : (starred_expression | ( assignment_expression | expression)) (',' (starred_expression | ( assignment_expression | expression)))* (',' kwargs )? | kwargs; kwargs : kwarg_or_starred (',' kwarg_or_starred)* (',' kwarg_or_double_starred (',' kwarg_or_double_starred)*)? | kwarg_or_double_starred (',' kwarg_or_double_starred)* ; starred_expression : '*' expression; kwarg_or_starred : name '=' expression | starred_expression; kwarg_or_double_starred : name '=' expression | '**' expression; // ASSIGNMENT TARGETS // ================== // Generic targets // --------------- // NOTE: star_targets may contain *bitwise_or, targets may not. star_targets : star_target (',' star_target )* ','? ; star_targets_list_seq: star_target (',' star_target)* ','?; star_targets_tuple_seq : star_target (',' | (',' star_target )+ ','?) ; star_target : '*' (star_target) | target_with_star_atom; target_with_star_atom : t_primary ('.' name | '[' slices ']') | star_atom ; star_atom : name | '(' target_with_star_atom ')' | '(' star_targets_tuple_seq? ')' | '[' star_targets_list_seq? ']'; single_target : single_subscript_attribute_target | name | '(' single_target ')'; single_subscript_attribute_target : t_primary ('.' name | '[' slices ']') ; t_primary : t_primary ('.' name | '[' slices ']' | genexp | '(' arguments? ')') | atom ; // Targets for del statements // -------------------------- del_targets: del_target (',' del_target)* ','?; del_target : t_primary ('.' name | '[' slices ']') | del_t_atom ; del_t_atom : name | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']'; // TYPING ELEMENTS // --------------- // type_expressions allow */** but ignore them type_expressions : expression (',' expression)* (',' ('*' expression (',' '**' expression)? | '**' expression))? | '*' expression (',' '**' expression)? | '**' expression ; func_type_comment : NEWLINE TYPE_COMMENT // Must be followed by indented block | TYPE_COMMENT; // *** related to soft keywords: https://docs.python.org/3.13/reference/lexical_analysis.html#soft-keywords name_except_underscore : NAME // ***** The NAME token can be used only in this rule ***** | NAME_OR_TYPE | NAME_OR_MATCH | NAME_OR_CASE ; // ***** Always use name rule instead of NAME token in this grammar ***** name: NAME_OR_WILDCARD | name_except_underscore; // ========================= END OF THE GRAMMAR ===========================
ANTLR
/* * The MIT License (MIT) * * Copyright (c) 2014 by Bart Kiers * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Project : python3-parser; an ANTLR4 grammar for Python 3 * https://github.com/bkiers/python3-parser * Developed by : Bart Kiers, [email protected] */ grammar Python3; // All comments that start with "///" are copy-pasted from // The Python Language Reference: https://docs.python.org/3.3/reference/grammar.html tokens { INDENT, DEDENT } @lexer::members { // A queue where extra tokens are pushed on (see the NEWLINE lexer rule). private java.util.LinkedList<Token> tokens = new java.util.LinkedList<>(); // The stack that keeps track of the indentation level. private java.util.Stack<Integer> indents = new java.util.Stack<>(); // The amount of opened braces, brackets and parenthesis. private int opened = 0; // The most recently produced token. private Token lastToken = null; @Override public void emit(Token t) { super.setToken(t); tokens.offer(t); } @Override public Token nextToken() { // Check if the end-of-file is ahead and there are still some DEDENTS expected. if (_input.LA(1) == EOF && !this.indents.isEmpty()) { // Remove any trailing EOF tokens from our buffer. for (int i = tokens.size() - 1; i >= 0; i--) { if (tokens.get(i).getType() == EOF) { tokens.remove(i); } } // First emit an extra line break that serves as the end of the statement. this.emit(commonToken(Python3Parser.NEWLINE, "\n")); // Now emit as much DEDENT tokens as needed. while (!indents.isEmpty()) { this.emit(createDedent()); indents.pop(); } // Put the EOF back on the token stream. this.emit(commonToken(Python3Parser.EOF, "<EOF>")); } Token next = super.nextToken(); if (next.getChannel() == Token.DEFAULT_CHANNEL) { // Keep track of the last token on the default channel. this.lastToken = next; } return tokens.isEmpty() ? next : tokens.poll(); } private Token createDedent() { CommonToken dedent = commonToken(Python3Parser.DEDENT, ""); dedent.setLine(this.lastToken.getLine()); return dedent; } private CommonToken commonToken(int type, String text) { int stop = this.getCharIndex() - 1; int start = text.isEmpty() ? stop : stop - text.length() + 1; return new CommonToken(this._tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, start, stop); } // Calculates the indentation of the provided spaces, taking the // following rules into account: // // "Tabs are replaced (from left to right) by one to eight spaces // such that the total number of characters up to and including // the replacement is a multiple of eight [...]" // // -- https://docs.python.org/3.1/reference/lexical_analysis.html#indentation static int getIndentationCount(String spaces) { int count = 0; for (char ch : spaces.toCharArray()) { switch (ch) { case '\t': count
ANTLR
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
374