diff --git a/_scripts/templates/st.Arithmetic.g4 b/_scripts/templates/st.Arithmetic.g4 index 3caca859d9..477a9e6354 100644 --- a/_scripts/templates/st.Arithmetic.g4 +++ b/_scripts/templates/st.Arithmetic.g4 @@ -1,32 +1,119 @@ // Template generated code from trgen +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Arithmetic; -file_ : expression (SEMI expression)* EOF; -expression : expression POW expression | expression (TIMES | DIV) expression | expression (PLUS | MINUS) expression | LPAREN expression RPAREN | (PLUS | MINUS)* atom ; -atom : scientific | variable ; -scientific : SCIENTIFIC_NUMBER ; -variable : VARIABLE ; - -VARIABLE : VALID_ID_START VALID_ID_CHAR* ; -SCIENTIFIC_NUMBER : NUMBER (E SIGN? UNSIGNED_INTEGER)? ; -LPAREN : '(' ; -RPAREN : ')' ; -PLUS : '+' ; -MINUS : '-' ; -TIMES : '*' ; -DIV : '/' ; -GT : '>' ; -LT : '\<' ; -EQ : '=' ; -POINT : '.' ; -POW : '^' ; -SEMI : ';' ; -WS : [ \r\n\t] + -> channel(HIDDEN) ; - -fragment VALID_ID_START : ('a' .. 'z') | ('A' .. 'Z') | '_' ; -fragment VALID_ID_CHAR : VALID_ID_START | ('0' .. '9') ; -fragment NUMBER : ('0' .. '9') + ('.' ('0' .. '9') +)? ; -fragment UNSIGNED_INTEGER : ('0' .. '9')+ ; -fragment E : 'E' | 'e' ; -fragment SIGN : ('+' | '-') ; +file_ + : expression (SEMI expression)* EOF + ; + +expression + : expression POW expression + | expression (TIMES | DIV) expression + | expression (PLUS | MINUS) expression + | LPAREN expression RPAREN + | (PLUS | MINUS)* atom + ; + +atom + : scientific + | variable + ; + +scientific + : SCIENTIFIC_NUMBER + ; + +variable + : VARIABLE + ; + +VARIABLE + : VALID_ID_START VALID_ID_CHAR* + ; + +SCIENTIFIC_NUMBER + : NUMBER (E SIGN? UNSIGNED_INTEGER)? + ; + +LPAREN + : '(' + ; + +RPAREN + : ')' + ; + +PLUS + : '+' + ; + +MINUS + : '-' + ; + +TIMES + : '*' + ; + +DIV + : '/' + ; + +GT + : '>' + ; + +LT + : '\<' + ; + +EQ + : '=' + ; + +POINT + : '.' + ; + +POW + : '^' + ; + +SEMI + : ';' + ; + +WS + : [ \r\n\t]+ -> channel(HIDDEN) + ; + +fragment VALID_ID_START + : ('a' .. 'z') + | ('A' .. 'Z') + | '_' + ; + +fragment VALID_ID_CHAR + : VALID_ID_START + | ('0' .. '9') + ; + +fragment NUMBER + : ('0' .. '9')+ ('.' ('0' .. '9')+)? + ; + +fragment UNSIGNED_INTEGER + : ('0' .. '9')+ + ; + +fragment E + : 'E' + | 'e' + ; + +fragment SIGN + : ('+' | '-') + ; \ No newline at end of file diff --git a/abb/abbLexer.g4 b/abb/abbLexer.g4 index 8b31766c46..7885c064c2 100644 --- a/abb/abbLexer.g4 +++ b/abb/abbLexer.g4 @@ -1,122 +1,107 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar abbLexer; -options { caseInsensitive = true; } - -MODULE : 'module' ; -ENDMODULE : 'endmodule' ; -PROC: 'PROC'; -ENDPROC: 'ENDPROC'; -LOCAL: 'LOCAL'; -CONST: 'CONST'; -PERS: 'PERS'; -VAR: 'VAR'; -TOOLDATA: 'TOOLDATA'; -WOBJDATA: 'WOBJDATA'; -SPEEDDATA: 'SPEEDDATA'; -ZONEDATA: 'ZONEDATA'; -CLOCK: 'CLOCK'; -BOOL: 'BOOL'; -ON_CALL: '\\ON'; -OFF_CALL: '\\OFF'; - -SLASH : '/' ; -EQUALS : ':=' ; -COMMA : ','; -CURLY_OPEN : '{'; -CURLY_CLOSE : '}'; -COLON : ':'; -SEMICOLON : ';'; -BRACKET_OPEN : '('; -BRACKET_CLOSE : ')'; -SQUARE_OPEN : '['; -SQUARE_CLOSE : ']'; -DOT : '.'; -DOUBLEDOT : '..'; -REL_BIGGER : '>'; -REL_BIGGER_OR_EQUAL : '>='; -REL_SMALLER : '<'; -REL_SMALLER_OR_EQUAL: '<='; -REL_EQUAL : '=='; -REL_NOTEQUAL : '<>'; -PLUS : '+'; -MINUS : '-'; -MULTIPLY : '*'; -PERCENT : '%'; -HASH : '#'; - -WS - : (' ' | '\t' | '\u000C') -> skip - ; - -NEWLINE - : '\r'? '\n' - ; - -LINE_COMMENT - : '!' ~ ('\n' | '\r')* -> skip - ; - -BOOLLITERAL - : 'FALSE' - | 'TRUE' - ; - -CHARLITERAL - : '\'' (EscapeSequence | ~ ('\'' | '\\' | '\r' | '\n')) '\'' - ; - -STRINGLITERAL - : '"' (EscapeSequence | ~ ('\\' | '"' | '\r' | '\n'))* '"' - ; - -fragment EscapeSequence - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\' | '0' .. '3' '0' .. '7' '0' .. '7' | '0' .. '7' '0' .. '7' | '0' .. '7') - ; - -FLOATLITERAL - : ('0' .. '9') + '.' ('0' .. '9')* Exponent? | '.' ('0' .. '9') + Exponent? | ('0' .. '9') + Exponent - ; - -fragment Exponent - : 'E' ('+' | '-')? ('0' .. '9') + - ; - -INTLITERAL - : ('0' .. '9') + | HexPrefix HexDigit + HexSuffix | BinPrefix BinDigit + BinSuffix - ; - -fragment HexPrefix - : '\'' 'H' - ; - -fragment HexDigit - : '0' .. '9' | 'A' .. 'F' - ; - -fragment HexSuffix - : '\'' - ; - -fragment BinPrefix - : '\'' 'B' - ; - -fragment BinDigit - : '0' | '1' - ; - -fragment BinSuffix - : '\'' - ; - -IDENTIFIER - : IdentifierStart IdentifierPart* - ; - -fragment IdentifierStart - : 'A' .. 'Z' | '_' - ; - -fragment IdentifierPart - : IdentifierStart | '0' .. '9' - ; +options { + caseInsensitive = true; +} + +MODULE : 'module'; +ENDMODULE : 'endmodule'; +PROC : 'PROC'; +ENDPROC : 'ENDPROC'; +LOCAL : 'LOCAL'; +CONST : 'CONST'; +PERS : 'PERS'; +VAR : 'VAR'; +TOOLDATA : 'TOOLDATA'; +WOBJDATA : 'WOBJDATA'; +SPEEDDATA : 'SPEEDDATA'; +ZONEDATA : 'ZONEDATA'; +CLOCK : 'CLOCK'; +BOOL : 'BOOL'; +ON_CALL : '\\ON'; +OFF_CALL : '\\OFF'; + +SLASH : '/'; +EQUALS : ':='; +COMMA : ','; +CURLY_OPEN : '{'; +CURLY_CLOSE : '}'; +COLON : ':'; +SEMICOLON : ';'; +BRACKET_OPEN : '('; +BRACKET_CLOSE : ')'; +SQUARE_OPEN : '['; +SQUARE_CLOSE : ']'; +DOT : '.'; +DOUBLEDOT : '..'; +REL_BIGGER : '>'; +REL_BIGGER_OR_EQUAL : '>='; +REL_SMALLER : '<'; +REL_SMALLER_OR_EQUAL : '<='; +REL_EQUAL : '=='; +REL_NOTEQUAL : '<>'; +PLUS : '+'; +MINUS : '-'; +MULTIPLY : '*'; +PERCENT : '%'; +HASH : '#'; + +WS: (' ' | '\t' | '\u000C') -> skip; + +NEWLINE: '\r'? '\n'; + +LINE_COMMENT: '!' ~ ('\n' | '\r')* -> skip; + +BOOLLITERAL: 'FALSE' | 'TRUE'; + +CHARLITERAL: '\'' (EscapeSequence | ~ ('\'' | '\\' | '\r' | '\n')) '\''; + +STRINGLITERAL: '"' (EscapeSequence | ~ ('\\' | '"' | '\r' | '\n'))* '"'; + +fragment EscapeSequence: + '\\' ( + 'b' + | 't' + | 'n' + | 'f' + | 'r' + | '"' + | '\'' + | '\\' + | '0' .. '3' '0' .. '7' '0' .. '7' + | '0' .. '7' '0' .. '7' + | '0' .. '7' + ) +; + +FLOATLITERAL: + ('0' .. '9')+ '.' ('0' .. '9')* Exponent? + | '.' ('0' .. '9')+ Exponent? + | ('0' .. '9')+ Exponent +; + +fragment Exponent: 'E' ('+' | '-')? ('0' .. '9')+; + +INTLITERAL: ('0' .. '9')+ | HexPrefix HexDigit+ HexSuffix | BinPrefix BinDigit+ BinSuffix; + +fragment HexPrefix: '\'' 'H'; + +fragment HexDigit: '0' .. '9' | 'A' .. 'F'; + +fragment HexSuffix: '\''; + +fragment BinPrefix: '\'' 'B'; + +fragment BinDigit: '0' | '1'; + +fragment BinSuffix: '\''; + +IDENTIFIER: IdentifierStart IdentifierPart*; + +fragment IdentifierStart: 'A' .. 'Z' | '_'; + +fragment IdentifierPart: IdentifierStart | '0' .. '9'; \ No newline at end of file diff --git a/abb/abbParser.g4 b/abb/abbParser.g4 index 730781d869..35a14988d3 100644 --- a/abb/abbParser.g4 +++ b/abb/abbParser.g4 @@ -1,6 +1,11 @@ +// $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; } +options { + tokenVocab = abbLexer; +} /* This grammar is still in development. @@ -31,10 +36,7 @@ module_ ; moduleData - : MODULE moduleName NEWLINE - dataList - NEWLINE* - ENDMODULE + : MODULE moduleName NEWLINE dataList NEWLINE* ENDMODULE ; moduleName @@ -43,15 +45,11 @@ moduleName ; dataList - : (NEWLINE - | declaration NEWLINE - | procedure NEWLINE)* + : (NEWLINE | declaration NEWLINE | procedure NEWLINE)* ; procedure - : PROC procCall NEWLINE - (functionCall NEWLINE)* - ENDPROC + : PROC procCall NEWLINE (functionCall NEWLINE)* ENDPROC ; procCall @@ -82,15 +80,21 @@ declaration ; type_ - : TOOLDATA | WOBJDATA | SPEEDDATA | ZONEDATA | CLOCK | BOOL + : TOOLDATA + | WOBJDATA + | SPEEDDATA + | ZONEDATA + | CLOCK + | BOOL ; init_ - : LOCAL? ( CONST | PERS | VAR ) + : LOCAL? (CONST | PERS | VAR) ; expression - : array_ | primitive + : array_ + | primitive ; array_ @@ -103,4 +107,4 @@ primitive | STRINGLITERAL | (PLUS | MINUS)? FLOATLITERAL | (PLUS | MINUS)? INTLITERAL - ; + ; \ No newline at end of file diff --git a/abnf/Abnf.g4 b/abnf/Abnf.g4 index ba9d72908f..10def4be9e 100644 --- a/abnf/Abnf.g4 +++ b/abnf/Abnf.g4 @@ -43,111 +43,118 @@ ABNF grammar derived from: Terminal rules mainly created by ANTLRWorks 1.5 sample code. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Abnf; // Note: Whitespace handling not as strict as in the specification. rulelist - : rule_* EOF - ; + : rule_* EOF + ; rule_ - : ID '=' '/'? elements - ; + : ID '=' '/'? elements + ; elements - : alternation - ; + : alternation + ; alternation - : concatenation ( '/' concatenation )* - ; + : concatenation ('/' concatenation)* + ; concatenation - : repetition + - ; + : repetition+ + ; repetition - : repeat_? element - ; + : repeat_? element + ; repeat_ - : INT | INT? '*' INT? - ; + : INT + | INT? '*' INT? + ; element - : ID | group | option | STRING | NumberValue | ProseValue - ; + : ID + | group + | option + | STRING + | NumberValue + | ProseValue + ; group - : '(' alternation ')' - ; + : '(' alternation ')' + ; option - : '[' alternation ']' - ; - + : '[' alternation ']' + ; NumberValue - : '%' ( BinaryValue | DecimalValue | HexValue ) - ; - + : '%' (BinaryValue | DecimalValue | HexValue) + ; fragment BinaryValue - : 'b' BIT+ ( ( '.' BIT+ )+ | '-' BIT+ )? - ; - + : 'b' BIT+ (( '.' BIT+)+ | '-' BIT+)? + ; fragment DecimalValue - : 'd' DIGIT+ ( ( '.' DIGIT+ )+ | '-' DIGIT+ )? - ; - + : 'd' DIGIT+ (( '.' DIGIT+)+ | '-' DIGIT+)? + ; fragment HexValue - : 'x' HEX_DIGIT+ ( ( '.' HEX_DIGIT+ )+ | '-' HEX_DIGIT+ )? - ; - + : 'x' HEX_DIGIT+ (( '.' HEX_DIGIT+)+ | '-' HEX_DIGIT+)? + ; ProseValue - : '<' ~'>'* '>' - ; + : '<' ~'>'* '>' + ; ID - : LETTER ( LETTER | DIGIT | '-' )* - ; + : LETTER (LETTER | DIGIT | '-')* + ; INT - : '0' .. '9'+ - ; + : '0' .. '9'+ + ; COMMENT - : ';' ~ ( '\n' | '\r' )* '\r'? '\n' -> channel ( HIDDEN ) - ; + : ';' ~ ('\n' | '\r')* '\r'? '\n' -> channel ( HIDDEN ) + ; WS - : ( ' ' | '\t' | '\r' | '\n' ) -> channel ( HIDDEN ) - ; - + : (' ' | '\t' | '\r' | '\n') -> channel ( HIDDEN ) + ; STRING - : ( '%s' | '%i' )? '"' ~'"'* '"' - ; + : ('%s' | '%i')? '"' ~'"'* '"' + ; -fragment LETTER : 'a' .. 'z' | 'A' .. 'Z'; +fragment LETTER + : 'a' .. 'z' + | 'A' .. 'Z' + ; fragment BIT - : '0' .. '1' - ; - + : '0' .. '1' + ; fragment DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; // Note: from the RFC errata (http://www.rfc-editor.org/errata_search.php?rfc=5234&eid=4040): // > ABNF strings are case insensitive and the character set for these strings is US-ASCII. // > So the definition of HEXDIG already allows for both upper and lower case (or a mixture). fragment HEX_DIGIT - : '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' - ; + : '0' .. '9' + | 'a' .. 'f' + | 'A' .. 'F' + ; \ No newline at end of file diff --git a/ada/ada2005/Ada2005Lexer.g4 b/ada/ada2005/Ada2005Lexer.g4 index a316054027..a7a4025c51 100644 --- a/ada/ada2005/Ada2005Lexer.g4 +++ b/ada/ada2005/Ada2005Lexer.g4 @@ -21,152 +21,166 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Ada2005Lexer; -options { caseInsensitive = true; } - -ABORT : 'abort'; -ABS : 'abs'; -ABSTRACT : 'abstract'; -ACCEPT_ : 'accept'; -ACCESS : 'access'; -ALIASED : 'aliased'; -ALL : 'all'; -AND : 'and'; -ARRAY : 'array'; -AT : 'at'; - -BEGIN : 'begin'; -BODY_ : 'body'; - -CASE : 'case'; -CONSTANT : 'constant'; - -DECLARE : 'declare'; -DELAY : 'delay'; -DELTA : 'delta'; -DIGITS : 'digits'; -DO : 'do'; - -ELSE : 'else'; -ELSIF : 'elsif'; -END : 'end'; -ENTRY : 'entry'; -EXCEPTION : 'exception'; -EXIT : 'exit'; - -FOR : 'for'; -FUNCTION : 'function'; - -GENERIC : 'generic'; -GOTO : 'goto'; - -IF : 'if'; -IN : 'in'; -INTERFACE : 'interface'; -IS : 'is'; - -LIMITED : 'limited'; -LOOP : 'loop'; - -MOD : 'mod'; - -NEW : 'new'; -NOT : 'not'; -NULL_ : 'null'; - -OF : 'of'; -OR : 'or'; -OTHERS : 'others'; -OUT : 'out'; -OVERRIDING : 'overriding'; - -PACKAGE : 'package'; -PRAGMA : 'pragma'; -PRIVATE : 'private'; -PROCEDURE : 'procedure'; -PROTECTED : 'protected'; - -RAISE : 'raise'; -RANGE_ : 'range'; -RECORD : 'record'; -REM : 'rem'; -RENAMES : 'renames'; -REQUEUE : 'requeue'; -RETURN : 'return'; -REVERSE : 'reverse'; - -SELECT : 'select'; -SEPARATE : 'separate'; -SUBTYPE : 'subtype'; -SYNCHRONIZED : 'synchronized'; - -TAGGED : 'tagged'; -TASK : 'task'; -TERMINATE : 'terminate'; -THEN : 'then'; -TYPE : 'type'; - -UNTIL : 'until'; -USE : 'use'; - -WHEN : 'when'; -WHILE : 'while'; -WITH : 'with'; - -XOR : 'xor'; - -Range__ options { caseInsensitive = false; } : 'Range'; -Access__ options { caseInsensitive = false; } : 'Access'; -Delta__ options { caseInsensitive = false; } : 'Delta'; -Digits__ options { caseInsensitive = false; } : 'Digits'; - -WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); -LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); - -IDENTIFIER_ : LETTER+ [A-Z_0-9]*; -NUMERIC_LITERAL_ : DECIMAL_LITERAL | BASED_LITERAL; -DECIMAL_LITERAL : NUMERAL ('.' NUMERAL)? EXPONENT?; -NUMERAL : DIGIT+ ('_'? DIGIT)*; -EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; -BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; -BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; -EXTENDED_DIGIT : DIGIT | [A-F]; -BASE : NUMERAL; - -CHARACTER_LITERAL_: '\'' ~['\\\r\n] '\''; -STRING_LITERAL_ : '"' ('""' | ~'"' )* '"'; - -fragment LETTER : [A-Z]; -fragment DIGIT : [0-9]; - -HASH : '#'; -AMPERSAND : '&'; -LP : '('; -RP : ')'; -MULT : '*'; -PLUS : '+'; -COMMA : ','; -MINUS : '-'; -DOT : '.'; -COLON : ':'; -SEMI : ';'; -LT : '<'; -EQ : '='; -GT : '>'; -US : '_'; -VL : '|'; -DIV : '/'; -EP : '!'; -PS : '%'; -ARROW : '=>'; -DOTDOT : '..'; -EXPON : '**'; -ASSIGN : ':='; -NE : '/='; -GE : '>='; -LE : '<='; -LLB : '<<'; -RLB : '>>'; -BOX : '<>'; -SQ : '\''; +options { + caseInsensitive = true; +} + +ABORT : 'abort'; +ABS : 'abs'; +ABSTRACT : 'abstract'; +ACCEPT_ : 'accept'; +ACCESS : 'access'; +ALIASED : 'aliased'; +ALL : 'all'; +AND : 'and'; +ARRAY : 'array'; +AT : 'at'; + +BEGIN : 'begin'; +BODY_ : 'body'; + +CASE : 'case'; +CONSTANT : 'constant'; + +DECLARE : 'declare'; +DELAY : 'delay'; +DELTA : 'delta'; +DIGITS : 'digits'; +DO : 'do'; + +ELSE : 'else'; +ELSIF : 'elsif'; +END : 'end'; +ENTRY : 'entry'; +EXCEPTION : 'exception'; +EXIT : 'exit'; + +FOR : 'for'; +FUNCTION : 'function'; + +GENERIC : 'generic'; +GOTO : 'goto'; + +IF : 'if'; +IN : 'in'; +INTERFACE : 'interface'; +IS : 'is'; + +LIMITED : 'limited'; +LOOP : 'loop'; + +MOD: 'mod'; + +NEW : 'new'; +NOT : 'not'; +NULL_ : 'null'; + +OF : 'of'; +OR : 'or'; +OTHERS : 'others'; +OUT : 'out'; +OVERRIDING : 'overriding'; + +PACKAGE : 'package'; +PRAGMA : 'pragma'; +PRIVATE : 'private'; +PROCEDURE : 'procedure'; +PROTECTED : 'protected'; + +RAISE : 'raise'; +RANGE_ : 'range'; +RECORD : 'record'; +REM : 'rem'; +RENAMES : 'renames'; +REQUEUE : 'requeue'; +RETURN : 'return'; +REVERSE : 'reverse'; + +SELECT : 'select'; +SEPARATE : 'separate'; +SUBTYPE : 'subtype'; +SYNCHRONIZED : 'synchronized'; + +TAGGED : 'tagged'; +TASK : 'task'; +TERMINATE : 'terminate'; +THEN : 'then'; +TYPE : 'type'; + +UNTIL : 'until'; +USE : 'use'; + +WHEN : 'when'; +WHILE : 'while'; +WITH : 'with'; + +XOR: 'xor'; + +Range__ options { + caseInsensitive = false; +}: 'Range'; +Access__ options { + caseInsensitive = false; +}: 'Access'; +Delta__ options { + caseInsensitive = false; +}: 'Delta'; +Digits__ options { + caseInsensitive = false; +}: 'Digits'; + +WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); + +IDENTIFIER_ : LETTER+ [A-Z_0-9]*; +NUMERIC_LITERAL_ : DECIMAL_LITERAL | BASED_LITERAL; +DECIMAL_LITERAL : NUMERAL ('.' NUMERAL)? EXPONENT?; +NUMERAL : DIGIT+ ('_'? DIGIT)*; +EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; +BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; +BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; +EXTENDED_DIGIT : DIGIT | [A-F]; +BASE : NUMERAL; + +CHARACTER_LITERAL_ : '\'' ~['\\\r\n] '\''; +STRING_LITERAL_ : '"' ('""' | ~'"')* '"'; + +fragment LETTER : [A-Z]; +fragment DIGIT : [0-9]; + +HASH : '#'; +AMPERSAND : '&'; +LP : '('; +RP : ')'; +MULT : '*'; +PLUS : '+'; +COMMA : ','; +MINUS : '-'; +DOT : '.'; +COLON : ':'; +SEMI : ';'; +LT : '<'; +EQ : '='; +GT : '>'; +US : '_'; +VL : '|'; +DIV : '/'; +EP : '!'; +PS : '%'; +ARROW : '=>'; +DOTDOT : '..'; +EXPON : '**'; +ASSIGN : ':='; +NE : '/='; +GE : '>='; +LE : '<='; +LLB : '<<'; +RLB : '>>'; +BOX : '<>'; +SQ : '\''; \ No newline at end of file diff --git a/ada/ada2005/Ada2005Parser.g4 b/ada/ada2005/Ada2005Parser.g4 index 729b0854c3..81723d7848 100644 --- a/ada/ada2005/Ada2005Parser.g4 +++ b/ada/ada2005/Ada2005Parser.g4 @@ -20,1355 +20,1385 @@ 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. */ + +// $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 Ada2005Parser; +options { + tokenVocab = Ada2005Lexer; +} -options { tokenVocab = Ada2005Lexer; } /* 2 - */ - identifier - : IDENTIFIER_ - ; + : IDENTIFIER_ + ; string_literal - : STRING_LITERAL_ - ; + : STRING_LITERAL_ + ; numeric_literal - : NUMERIC_LITERAL_ - ; + : NUMERIC_LITERAL_ + ; character_literal - : CHARACTER_LITERAL_ - ; + : CHARACTER_LITERAL_ + ; + /* 3 - Declarations and Types */ - - + basic_declaration - : type_declaration - | subtype_declaration - | object_declaration - | number_declaration - | subprogram_declaration - | abstract_subprogram_declaration - | null_procedure_declaration - | package_declaration - | renaming_declaration - | exception_declaration - | generic_declaration - | generic_instantiation - ; + : type_declaration + | subtype_declaration + | object_declaration + | number_declaration + | subprogram_declaration + | abstract_subprogram_declaration + | null_procedure_declaration + | package_declaration + | renaming_declaration + | exception_declaration + | generic_declaration + | generic_instantiation + ; defining_identifier - : identifier - ; + : identifier + ; type_declaration - : full_type_declaration - | incomplete_type_declaration - | private_type_declaration - | private_extension_declaration - ; + : full_type_declaration + | incomplete_type_declaration + | private_type_declaration + | private_extension_declaration + ; full_type_declaration - : TYPE defining_identifier known_discriminant_part? IS type_definition ';' - | task_type_declaration - | protected_type_declaration - ; + : TYPE defining_identifier known_discriminant_part? IS type_definition ';' + | task_type_declaration + | protected_type_declaration + ; type_definition - : enumeration_type_definition - | integer_type_definition - | real_type_definition - | array_type_definition - | record_type_definition - | access_type_definition - | derived_type_definition - | interface_type_definition - ; + : enumeration_type_definition + | integer_type_definition + | real_type_definition + | array_type_definition + | record_type_definition + | access_type_definition + | derived_type_definition + | interface_type_definition + ; subtype_declaration - : SUBTYPE defining_identifier IS subtype_indication ';' - ; + : SUBTYPE defining_identifier IS subtype_indication ';' + ; subtype_indication - : null_exclusion? subtype_mark = name constraint? - ; + : null_exclusion? subtype_mark = name constraint? + ; constraint - : scalar_constraint - | composite_constraint - ; + : scalar_constraint + | composite_constraint + ; scalar_constraint - : range_constraint - | digits_constraint - | delta_constraint - ; + : range_constraint + | digits_constraint + | delta_constraint + ; composite_constraint - : index_constraint - | discriminant_constraint - ; + : index_constraint + | discriminant_constraint + ; object_declaration - : defining_identifier_list ':' ALIASED? CONSTANT? subtype_indication (':=' expression)? ';' - | defining_identifier_list ':' ALIASED? CONSTANT? access_definition (':=' expression)? ';' - | defining_identifier_list ':' ALIASED? CONSTANT? array_type_definition (':=' expression)? ';' - | single_task_declaration - | single_protected_declaration - ; + : defining_identifier_list ':' ALIASED? CONSTANT? subtype_indication (':=' expression)? ';' + | defining_identifier_list ':' ALIASED? CONSTANT? access_definition (':=' expression)? ';' + | defining_identifier_list ':' ALIASED? CONSTANT? array_type_definition (':=' expression)? ';' + | single_task_declaration + | single_protected_declaration + ; defining_identifier_list - : defining_identifier (',' defining_identifier)* - ; + : defining_identifier (',' defining_identifier)* + ; number_declaration - : defining_identifier_list ':' CONSTANT ':=' static_expression = expression ';' - ; + : defining_identifier_list ':' CONSTANT ':=' static_expression = expression ';' + ; derived_type_definition - : ABSTRACT? LIMITED? NEW parent_subtype_indication = subtype_indication ((AND interface_list)? record_extension_part)? - ; + : ABSTRACT? LIMITED? NEW parent_subtype_indication = subtype_indication ( + (AND interface_list)? record_extension_part + )? + ; range_constraint - : RANGE_ range - ; + : RANGE_ range + ; range - : range_attribute_reference - | simple_expression '..' simple_expression - ; + : range_attribute_reference + | simple_expression '..' simple_expression + ; enumeration_type_definition - : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' - ; + : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' + ; enumeration_literal_specification - : defining_identifier - | defining_character_literal - ; + : defining_identifier + | defining_character_literal + ; defining_character_literal - : character_literal - ; + : character_literal + ; integer_type_definition - : signed_integer_type_definition - | modular_type_definition - ; + : signed_integer_type_definition + | modular_type_definition + ; signed_integer_type_definition - : RANGE_ static_simple_expression = simple_expression '..' static_simple_expression = simple_expression - ; + : RANGE_ static_simple_expression = simple_expression '..' static_simple_expression = simple_expression + ; modular_type_definition - : MOD static_expression = expression - ; + : MOD static_expression = expression + ; real_type_definition - : floating_point_definition - | fixed_point_definition - ; + : floating_point_definition + | fixed_point_definition + ; floating_point_definition - : DIGITS static_expression = expression real_range_specification? - ; + : DIGITS static_expression = expression real_range_specification? + ; real_range_specification - : RANGE_ static_simple_expression = simple_expression '..' static_simple_expression = simple_expression - ; + : RANGE_ static_simple_expression = simple_expression '..' static_simple_expression = simple_expression + ; fixed_point_definition - : ordinary_fixed_point_definition - | decimal_fixed_point_definition - ; + : ordinary_fixed_point_definition + | decimal_fixed_point_definition + ; ordinary_fixed_point_definition - : DELTA static_expression = expression real_range_specification - ; + : DELTA static_expression = expression real_range_specification + ; decimal_fixed_point_definition - : DELTA static_expression = expression DIGITS static_expression = expression real_range_specification? - ; + : DELTA static_expression = expression DIGITS static_expression = expression real_range_specification? + ; digits_constraint - : DIGITS static_expression = expression range_constraint? - ; + : DIGITS static_expression = expression range_constraint? + ; array_type_definition - : unconstrained_array_definition - | constrained_array_definition - ; + : unconstrained_array_definition + | constrained_array_definition + ; unconstrained_array_definition - : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF component_definition - ; + : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF component_definition + ; index_subtype_definition - : subtype_mark = name RANGE_ '<>' - ; + : subtype_mark = name RANGE_ '<>' + ; constrained_array_definition - : ARRAY '(' discrete_subtype_definition (',' discrete_subtype_definition)* ')' OF component_definition - ; + : ARRAY '(' discrete_subtype_definition (',' discrete_subtype_definition)* ')' OF component_definition + ; discrete_subtype_definition - : discrete_subtype_indication = subtype_indication - | range - ; + : discrete_subtype_indication = subtype_indication + | range + ; component_definition - : ALIASED? subtype_indication - | ALIASED? access_definition - ; + : ALIASED? subtype_indication + | ALIASED? access_definition + ; index_constraint - : '(' discrete_range (',' discrete_range)* ')' - ; + : '(' discrete_range (',' discrete_range)* ')' + ; discrete_range - : discrete_subtype_indication = subtype_indication - | range - ; + : discrete_subtype_indication = subtype_indication + | range + ; discriminant_part - : unknown_discriminant_part - | known_discriminant_part - ; + : unknown_discriminant_part + | known_discriminant_part + ; unknown_discriminant_part - : '(' '<>' ')' - ; + : '(' '<>' ')' + ; known_discriminant_part - : '(' discriminant_specification (';' discriminant_specification)* ')' - ; + : '(' discriminant_specification (';' discriminant_specification)* ')' + ; discriminant_specification - : defining_identifier_list ':' null_exclusion? subtype_mark = name (':=' default_expression)? - | defining_identifier_list ':' access_definition (':=' default_expression)? - ; + : defining_identifier_list ':' null_exclusion? subtype_mark = name (':=' default_expression)? + | defining_identifier_list ':' access_definition (':=' default_expression)? + ; default_expression - : expression - ; + : expression + ; discriminant_constraint - : '(' discriminant_association (',' discriminant_association)* ')' - ; + : '(' discriminant_association (',' discriminant_association)* ')' + ; discriminant_association - : (discriminant_selector_name = selector_name ('|' discriminant_selector_name = selector_name)* '=>')? expression - ; + : ( + discriminant_selector_name = selector_name ('|' discriminant_selector_name = selector_name)* '=>' + )? expression + ; record_type_definition - : (ABSTRACT? TAGGED)? LIMITED? record_definition - ; + : (ABSTRACT? TAGGED)? LIMITED? record_definition + ; record_definition - : RECORD component_list END RECORD - | NULL_ RECORD - ; + : RECORD component_list END RECORD + | NULL_ RECORD + ; component_list - : component_item component_item* - | component_item* variant_part - | NULL_ ';' - ; + : component_item component_item* + | component_item* variant_part + | NULL_ ';' + ; component_item - : component_declaration - | aspect_clause - ; + : component_declaration + | aspect_clause + ; component_declaration - : defining_identifier_list ':' component_definition (':=' default_expression)? ';' - ; + : defining_identifier_list ':' component_definition (':=' default_expression)? ';' + ; variant_part - : CASE discriminant_direct_name = direct_name IS variant variant* END CASE ';' - ; + : CASE discriminant_direct_name = direct_name IS variant variant* END CASE ';' + ; variant - : WHEN discrete_choice_list '=>' component_list - ; + : WHEN discrete_choice_list '=>' component_list + ; discrete_choice_list - : discrete_choice ('|' discrete_choice)* - ; + : discrete_choice ('|' discrete_choice)* + ; discrete_choice - : expression - | discrete_range - | OTHERS - ; + : expression + | discrete_range + | OTHERS + ; record_extension_part - : WITH record_definition - ; + : WITH record_definition + ; abstract_subprogram_declaration - : overriding_indicator? subprogram_specification IS ABSTRACT ';' - ; + : overriding_indicator? subprogram_specification IS ABSTRACT ';' + ; interface_type_definition - : (LIMITED | TASK | PROTECTED | SYNCHRONIZED)? INTERFACE (AND interface_list)? - ; + : (LIMITED | TASK | PROTECTED | SYNCHRONIZED)? INTERFACE (AND interface_list)? + ; interface_list - : interface_subtype_mark = name (AND interface_subtype_mark = name)* - ; + : interface_subtype_mark = name (AND interface_subtype_mark = name)* + ; access_type_definition - : null_exclusion? access_to_object_definition - | null_exclusion? access_to_subprogram_definition - ; + : null_exclusion? access_to_object_definition + | null_exclusion? access_to_subprogram_definition + ; access_to_object_definition - : ACCESS general_access_modifier? subtype_indication - ; + : ACCESS general_access_modifier? subtype_indication + ; general_access_modifier - : ALL - | CONSTANT - ; + : ALL + | CONSTANT + ; access_to_subprogram_definition - : ACCESS PROTECTED? PROCEDURE parameter_profile - | ACCESS PROTECTED? FUNCTION parameter_and_result_profile - ; + : ACCESS PROTECTED? PROCEDURE parameter_profile + | ACCESS PROTECTED? FUNCTION parameter_and_result_profile + ; null_exclusion - : NOT NULL_ - ; + : NOT NULL_ + ; access_definition - : null_exclusion? ACCESS CONSTANT? subtype_mark = name - | null_exclusion? ACCESS PROTECTED? PROCEDURE parameter_profile - | null_exclusion? ACCESS PROTECTED? FUNCTION parameter_and_result_profile - ; + : null_exclusion? ACCESS CONSTANT? subtype_mark = name + | null_exclusion? ACCESS PROTECTED? PROCEDURE parameter_profile + | null_exclusion? ACCESS PROTECTED? FUNCTION parameter_and_result_profile + ; incomplete_type_declaration - : TYPE defining_identifier discriminant_part? (IS TAGGED)? ';' - ; + : TYPE defining_identifier discriminant_part? (IS TAGGED)? ';' + ; declarative_part - : declarative_item* - ; + : declarative_item* + ; declarative_item - : basic_declarative_item - | body - ; + : basic_declarative_item + | body + ; basic_declarative_item - : basic_declaration - | aspect_clause - | use_clause - ; + : basic_declaration + | aspect_clause + | use_clause + ; body - : proper_body - | body_stub - ; + : proper_body + | body_stub + ; proper_body - : subprogram_body - | package_body - | task_body - | protected_body - ; + : subprogram_body + | package_body + | task_body + | protected_body + ; + /* 4 - Names and Expressions */ - - + name - : direct_name - | name '.' ALL //explicit_dereference - | prefix = name '(' expression (',' expression)* ')' //indexed_component - | prefix = name '(' discrete_range ')' //slice - | prefix = name '.' selector_name //selected_component - | prefix = name SQ attribute_designator //attribute_reference - | subtype_mark = name '(' expression ')' - | subtype_mark = name '(' name ')' - //| function_name = name - | function_prefix = name actual_parameter_part - | character_literal - ; + : direct_name + | name '.' ALL //explicit_dereference + | prefix = name '(' expression (',' expression)* ')' //indexed_component + | prefix = name '(' discrete_range ')' //slice + | prefix = name '.' selector_name //selected_component + | prefix = name SQ attribute_designator //attribute_reference + | subtype_mark = name '(' expression ')' + | subtype_mark = name '(' name ')' + //| function_name = name + | function_prefix = name actual_parameter_part + | character_literal + ; direct_name - : identifier - | operator_symbol - ; + : identifier + | operator_symbol + ; selector_name - : identifier - | character_literal - | operator_symbol - ; + : identifier + | character_literal + | operator_symbol + ; attribute_designator - : identifier ('(' static_expression = expression ')')? - | Access__ - | Delta__ - | Digits__ // TODO - - ; + : identifier ('(' static_expression = expression ')')? + | Access__ + | Delta__ + | Digits__ // TODO + ; range_attribute_reference - : prefix = name SQ range_attribute_designator - ; + : prefix = name SQ range_attribute_designator + ; range_attribute_designator - : Range__ ('(' static_expression = expression ')')? //TODO - - ; + : Range__ ('(' static_expression = expression ')')? //TODO + ; aggregate - : record_aggregate - | extension_aggregate - | array_aggregate - ; + : record_aggregate + | extension_aggregate + | array_aggregate + ; record_aggregate - : '(' record_component_association_list ')' - ; + : '(' record_component_association_list ')' + ; record_component_association_list - : record_component_association (',' record_component_association)* - | NULL_ RECORD - ; + : record_component_association (',' record_component_association)* + | NULL_ RECORD + ; record_component_association - : (component_choice_list '=>')? expression - | component_choice_list '=>' '<>' - ; + : (component_choice_list '=>')? expression + | component_choice_list '=>' '<>' + ; component_choice_list - : component_selector_name = selector_name ('|' component_selector_name = selector_name)* - | OTHERS - ; + : component_selector_name = selector_name ('|' component_selector_name = selector_name)* + | OTHERS + ; extension_aggregate - : '(' ancestor_part WITH record_component_association_list ')' - ; + : '(' ancestor_part WITH record_component_association_list ')' + ; ancestor_part - : expression - | subtype_mark = name - ; + : expression + | subtype_mark = name + ; array_aggregate - : positional_array_aggregate - | named_array_aggregate - ; + : positional_array_aggregate + | named_array_aggregate + ; positional_array_aggregate - : '(' expression ',' expression (',' expression)* ')' - | '(' expression (',' expression)* ',' OTHERS '=>' expression ')' - | '(' expression (',' expression)* ',' OTHERS '=>' '<>' ')' - ; + : '(' expression ',' expression (',' expression)* ')' + | '(' expression (',' expression)* ',' OTHERS '=>' expression ')' + | '(' expression (',' expression)* ',' OTHERS '=>' '<>' ')' + ; named_array_aggregate - : '(' array_component_association (',' array_component_association)* ')' - ; + : '(' array_component_association (',' array_component_association)* ')' + ; array_component_association - : discrete_choice_list '=>' expression - | discrete_choice_list '=>' '<>' - ; + : discrete_choice_list '=>' expression + | discrete_choice_list '=>' '<>' + ; expression - : relation (AND relation)* - | relation (AND THEN relation)* - | relation (OR relation)* - | relation (OR ELSE relation)* - | relation (XOR relation)* - ; + : relation (AND relation)* + | relation (AND THEN relation)* + | relation (OR relation)* + | relation (OR ELSE relation)* + | relation (XOR relation)* + ; relation - : simple_expression (relational_operator simple_expression)? - | simple_expression NOT? IN range - | simple_expression NOT? IN subtype_mark = name - ; + : simple_expression (relational_operator simple_expression)? + | simple_expression NOT? IN range + | simple_expression NOT? IN subtype_mark = name + ; simple_expression - : unary_adding_operator? term (binary_adding_operator term)* - ; + : unary_adding_operator? term (binary_adding_operator term)* + ; term - : factor (multiplying_operator factor)* - ; + : factor (multiplying_operator factor)* + ; factor - : primary ('**' primary)? - | ABS primary - | NOT primary - ; + : primary ('**' primary)? + | ABS primary + | NOT primary + ; primary - : numeric_literal - | NULL_ - | string_literal - | aggregate - | name - | qualified_expression - | allocator - | '(' expression ')' - ; + : numeric_literal + | NULL_ + | string_literal + | aggregate + | name + | qualified_expression + | allocator + | '(' expression ')' + ; logical_operator - : AND - | OR - | XOR - ; + : AND + | OR + | XOR + ; relational_operator - : '=' - | '/=' - | '<' - | '<=' - | '>' - | '>=' - ; + : '=' + | '/=' + | '<' + | '<=' + | '>' + | '>=' + ; binary_adding_operator - : '+' - | MINUS - | '&' - ; + : '+' + | MINUS + | '&' + ; unary_adding_operator - : '+' - | MINUS - ; + : '+' + | MINUS + ; multiplying_operator - : '*' - | '/' - | MOD - | REM - ; + : '*' + | '/' + | MOD + | REM + ; highest_precedence_operator - : '**' - | ABS - | NOT - ; + : '**' + | ABS + | NOT + ; qualified_expression - : subtype_mark = name SQ '(' expression ')' - | subtype_mark = name SQ aggregate - ; + : subtype_mark = name SQ '(' expression ')' + | subtype_mark = name SQ aggregate + ; allocator - : NEW subtype_indication - | NEW qualified_expression - ; + : NEW subtype_indication + | NEW qualified_expression + ; + /* 5 - Statements */ - - + sequence_of_statements - : statement statement* - ; + : statement statement* + ; statement - : label* simple_statement - | label* compound_statement - ; + : label* simple_statement + | label* compound_statement + ; simple_statement - : null_statement - | assignment_statement - | exit_statement - | goto_statement - | procedure_call_statement - | simple_return_statement - | entry_call_statement - | requeue_statement - | delay_statement - | abort_statement - | raise_statement - | code_statement - ; + : null_statement + | assignment_statement + | exit_statement + | goto_statement + | procedure_call_statement + | simple_return_statement + | entry_call_statement + | requeue_statement + | delay_statement + | abort_statement + | raise_statement + | code_statement + ; compound_statement - : if_statement - | case_statement - | loop_statement - | block_statement - | extended_return_statement - | accept_statement - | select_statement - ; + : if_statement + | case_statement + | loop_statement + | block_statement + | extended_return_statement + | accept_statement + | select_statement + ; null_statement - : NULL_ ';' - ; + : NULL_ ';' + ; label - : '<<' label_statement_identifier = statement_identifier '>>' - ; + : '<<' label_statement_identifier = statement_identifier '>>' + ; statement_identifier - : direct_name - ; + : direct_name + ; assignment_statement - : variable_name = name ':=' expression ';' - ; + : variable_name = name ':=' expression ';' + ; if_statement - : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* (ELSE sequence_of_statements)? END IF ';' - ; + : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* ( + ELSE sequence_of_statements + )? END IF ';' + ; condition - : boolean_expression = expression - ; + : boolean_expression = expression + ; case_statement - : CASE expression IS case_statement_alternative case_statement_alternative* END CASE ';' - ; + : CASE expression IS case_statement_alternative case_statement_alternative* END CASE ';' + ; case_statement_alternative - : WHEN discrete_choice_list '=>' sequence_of_statements - ; + : WHEN discrete_choice_list '=>' sequence_of_statements + ; loop_statement - : (loop_statement_identifier = statement_identifier ':')? iteration_scheme? LOOP sequence_of_statements END LOOP loop_identifier = identifier? ';' - ; + : (loop_statement_identifier = statement_identifier ':')? iteration_scheme? LOOP sequence_of_statements END LOOP loop_identifier = identifier? ';' + ; iteration_scheme - : WHILE condition - | FOR loop_parameter_specification - ; + : WHILE condition + | FOR loop_parameter_specification + ; loop_parameter_specification - : defining_identifier IN REVERSE? discrete_subtype_definition - ; + : defining_identifier IN REVERSE? discrete_subtype_definition + ; block_statement - : (block_statement_identifier = statement_identifier ':')? (DECLARE declarative_part)? BEGIN handled_sequence_of_statements END block_identifier = identifier? ';' - ; + : (block_statement_identifier = statement_identifier ':')? (DECLARE declarative_part)? BEGIN handled_sequence_of_statements END block_identifier = + identifier? ';' + ; exit_statement - : EXIT loop_name = name? (WHEN condition)? ';' - ; + : EXIT loop_name = name? (WHEN condition)? ';' + ; goto_statement - : GOTO label_name = name ';' - ; + : GOTO label_name = name ';' + ; + /* 6 - Subprograms */ - - + subprogram_declaration - : overriding_indicator? subprogram_specification ';' - ; + : overriding_indicator? subprogram_specification ';' + ; subprogram_specification - : procedure_specification - | function_specification - ; + : procedure_specification + | function_specification + ; procedure_specification - : PROCEDURE defining_program_unit_name parameter_profile - ; + : PROCEDURE defining_program_unit_name parameter_profile + ; function_specification - : FUNCTION defining_designator parameter_and_result_profile - ; + : FUNCTION defining_designator parameter_and_result_profile + ; designator - : (parent_unit_name '.')? identifier - | operator_symbol - ; + : (parent_unit_name '.')? identifier + | operator_symbol + ; defining_designator - : defining_program_unit_name - | defining_operator_symbol - ; + : defining_program_unit_name + | defining_operator_symbol + ; defining_program_unit_name - : (parent_unit_name '.')? defining_identifier - ; + : (parent_unit_name '.')? defining_identifier + ; operator_symbol - : string_literal - ; + : string_literal + ; defining_operator_symbol - : operator_symbol - ; + : operator_symbol + ; parameter_profile - : formal_part? - ; + : formal_part? + ; parameter_and_result_profile - : formal_part? RETURN null_exclusion? subtype_mark = name - | formal_part? RETURN access_definition - ; + : formal_part? RETURN null_exclusion? subtype_mark = name + | formal_part? RETURN access_definition + ; formal_part - : '(' parameter_specification (';' parameter_specification)* ')' - ; + : '(' parameter_specification (';' parameter_specification)* ')' + ; parameter_specification - : defining_identifier_list ':' mode_ null_exclusion? subtype_mark = name (':=' default_expression)? - | defining_identifier_list ':' access_definition (':=' default_expression)? - ; + : defining_identifier_list ':' mode_ null_exclusion? subtype_mark = name ( + ':=' default_expression + )? + | defining_identifier_list ':' access_definition (':=' default_expression)? + ; mode_ - : IN? OUT? - ; + : IN? OUT? + ; subprogram_body - : overriding_indicator? subprogram_specification IS declarative_part BEGIN handled_sequence_of_statements END designator? ';' - ; + : overriding_indicator? subprogram_specification IS declarative_part BEGIN handled_sequence_of_statements END designator? ';' + ; procedure_call_statement - : procedure_name = name ';' - | procedure_prefix = name actual_parameter_part ';' - ; + : procedure_name = name ';' + | procedure_prefix = name actual_parameter_part ';' + ; actual_parameter_part - : '(' parameter_association (',' parameter_association)* ')' - ; + : '(' parameter_association (',' parameter_association)* ')' + ; parameter_association - : (formal_parameter_selector_name = selector_name '=>')? explicit_actual_parameter - ; + : (formal_parameter_selector_name = selector_name '=>')? explicit_actual_parameter + ; explicit_actual_parameter - : expression - | variable_name = name - ; + : expression + | variable_name = name + ; simple_return_statement - : RETURN expression? ';' - ; + : RETURN expression? ';' + ; extended_return_statement - : RETURN defining_identifier ':' ALIASED? return_subtype_indication (':=' expression)? (DO handled_sequence_of_statements END RETURN)? ';' - ; + : RETURN defining_identifier ':' ALIASED? return_subtype_indication (':=' expression)? ( + DO handled_sequence_of_statements END RETURN + )? ';' + ; return_subtype_indication - : subtype_indication - | access_definition - ; + : subtype_indication + | access_definition + ; null_procedure_declaration - : overriding_indicator? procedure_specification IS NULL_ ';' - ; + : overriding_indicator? procedure_specification IS NULL_ ';' + ; + /* 7 - Packages */ - - + package_declaration - : package_specification ';' - ; + : package_specification ';' + ; package_specification - : PACKAGE defining_program_unit_name IS basic_declarative_item* (PRIVATE basic_declarative_item*)? END ((parent_unit_name '.')? identifier)? - ; + : PACKAGE defining_program_unit_name IS basic_declarative_item* ( + PRIVATE basic_declarative_item* + )? END ((parent_unit_name '.')? identifier)? + ; package_body - : PACKAGE BODY_ defining_program_unit_name IS declarative_part (BEGIN handled_sequence_of_statements)? END ((parent_unit_name '.')? identifier)? ';' - ; + : PACKAGE BODY_ defining_program_unit_name IS declarative_part ( + BEGIN handled_sequence_of_statements + )? END ((parent_unit_name '.')? identifier)? ';' + ; private_type_declaration - : TYPE defining_identifier discriminant_part? IS (ABSTRACT? TAGGED)? LIMITED? PRIVATE ';' - ; + : TYPE defining_identifier discriminant_part? IS (ABSTRACT? TAGGED)? LIMITED? PRIVATE ';' + ; private_extension_declaration - : TYPE defining_identifier discriminant_part? IS ABSTRACT? (LIMITED | SYNCHRONIZED)? NEW ancestor_subtype_indication = subtype_indication (AND interface_list)? WITH PRIVATE ';' - ; + : TYPE defining_identifier discriminant_part? IS ABSTRACT? (LIMITED | SYNCHRONIZED)? NEW ancestor_subtype_indication = subtype_indication ( + AND interface_list + )? WITH PRIVATE ';' + ; + /* 8 - Visibility Rules */ - - + overriding_indicator - : NOT? OVERRIDING - ; + : NOT? OVERRIDING + ; use_clause - : use_package_clause - | use_type_clause - ; + : use_package_clause + | use_type_clause + ; use_package_clause - : USE package_name = name (',' package_name = name)* ';' - ; + : USE package_name = name (',' package_name = name)* ';' + ; use_type_clause - : USE TYPE subtype_mark = name (',' subtype_mark = name)* ';' - ; + : USE TYPE subtype_mark = name (',' subtype_mark = name)* ';' + ; renaming_declaration - : object_renaming_declaration - | exception_renaming_declaration - | package_renaming_declaration - | subprogram_renaming_declaration - | generic_renaming_declaration - ; + : object_renaming_declaration + | exception_renaming_declaration + | package_renaming_declaration + | subprogram_renaming_declaration + | generic_renaming_declaration + ; object_renaming_declaration - : defining_identifier ':' null_exclusion? subtype_mark = name RENAMES object_name = name ';' - | defining_identifier ':' access_definition RENAMES object_name = name ';' - ; + : defining_identifier ':' null_exclusion? subtype_mark = name RENAMES object_name = name ';' + | defining_identifier ':' access_definition RENAMES object_name = name ';' + ; exception_renaming_declaration - : defining_identifier ':' EXCEPTION RENAMES exception_name = name ';' - ; + : defining_identifier ':' EXCEPTION RENAMES exception_name = name ';' + ; package_renaming_declaration - : PACKAGE defining_program_unit_name RENAMES package_name = name ';' - ; + : PACKAGE defining_program_unit_name RENAMES package_name = name ';' + ; subprogram_renaming_declaration - : overriding_indicator? subprogram_specification RENAMES callable_entity_name = name ';' - ; + : overriding_indicator? subprogram_specification RENAMES callable_entity_name = name ';' + ; generic_renaming_declaration - : GENERIC PACKAGE defining_program_unit_name RENAMES generic_package_name = name ';' - | GENERIC PROCEDURE defining_program_unit_name RENAMES generic_procedure_name = name ';' - | GENERIC FUNCTION defining_program_unit_name RENAMES generic_function_name = name ';' - ; + : GENERIC PACKAGE defining_program_unit_name RENAMES generic_package_name = name ';' + | GENERIC PROCEDURE defining_program_unit_name RENAMES generic_procedure_name = name ';' + | GENERIC FUNCTION defining_program_unit_name RENAMES generic_function_name = name ';' + ; + /* 9 - Tasks and Synchronization */ - - + task_type_declaration - : TASK TYPE defining_identifier known_discriminant_part? (IS (NEW interface_list WITH)? task_definition)? ';' - ; + : TASK TYPE defining_identifier known_discriminant_part? ( + IS (NEW interface_list WITH)? task_definition + )? ';' + ; single_task_declaration - : TASK defining_identifier (IS (NEW interface_list WITH)? task_definition)? ';' - ; + : TASK defining_identifier (IS (NEW interface_list WITH)? task_definition)? ';' + ; task_definition - : task_item* (PRIVATE task_item*)? END task_identifier = identifier? - ; + : task_item* (PRIVATE task_item*)? END task_identifier = identifier? + ; task_item - : entry_declaration - | aspect_clause - ; + : entry_declaration + | aspect_clause + ; task_body - : TASK BODY_ defining_identifier IS declarative_part BEGIN handled_sequence_of_statements END task_identifier = identifier? ';' - ; + : TASK BODY_ defining_identifier IS declarative_part BEGIN handled_sequence_of_statements END task_identifier = identifier? ';' + ; protected_type_declaration - : PROTECTED TYPE defining_identifier known_discriminant_part? IS (NEW interface_list WITH)? protected_definition ';' - ; + : PROTECTED TYPE defining_identifier known_discriminant_part? IS (NEW interface_list WITH)? protected_definition ';' + ; single_protected_declaration - : PROTECTED defining_identifier IS (NEW interface_list WITH)? protected_definition ';' - ; + : PROTECTED defining_identifier IS (NEW interface_list WITH)? protected_definition ';' + ; protected_definition - : protected_operation_declaration* (PRIVATE protected_element_declaration*)? END protected_identifier = identifier? - ; + : protected_operation_declaration* (PRIVATE protected_element_declaration*)? END protected_identifier = identifier? + ; protected_operation_declaration - : subprogram_declaration - | entry_declaration - | aspect_clause - ; + : subprogram_declaration + | entry_declaration + | aspect_clause + ; protected_element_declaration - : protected_operation_declaration - | component_declaration - ; + : protected_operation_declaration + | component_declaration + ; protected_body - : PROTECTED BODY_ defining_identifier IS protected_operation_item* END protected_identifier = identifier? ';' - ; + : PROTECTED BODY_ defining_identifier IS protected_operation_item* END protected_identifier = identifier? ';' + ; protected_operation_item - : subprogram_declaration - | subprogram_body - | entry_body - | aspect_clause - ; + : subprogram_declaration + | subprogram_body + | entry_body + | aspect_clause + ; entry_declaration - : overriding_indicator? ENTRY defining_identifier ('(' discrete_subtype_definition ')')? parameter_profile ';' - ; + : overriding_indicator? ENTRY defining_identifier ('(' discrete_subtype_definition ')')? parameter_profile ';' + ; accept_statement - : ACCEPT_ entry_direct_name = direct_name ('(' entry_index ')')? parameter_profile (DO handled_sequence_of_statements END entry_identifier = identifier?)? ';' - ; + : ACCEPT_ entry_direct_name = direct_name ('(' entry_index ')')? parameter_profile ( + DO handled_sequence_of_statements END entry_identifier = identifier? + )? ';' + ; entry_index - : expression - ; + : expression + ; entry_body - : ENTRY defining_identifier entry_body_formal_part entry_barrier IS declarative_part BEGIN handled_sequence_of_statements END entry_identifier = identifier? ';' - ; + : ENTRY defining_identifier entry_body_formal_part entry_barrier IS declarative_part BEGIN handled_sequence_of_statements END entry_identifier = + identifier? ';' + ; entry_body_formal_part - : ('(' entry_index_specification ')')? parameter_profile - ; + : ('(' entry_index_specification ')')? parameter_profile + ; entry_barrier - : WHEN condition - ; + : WHEN condition + ; entry_index_specification - : FOR defining_identifier IN discrete_subtype_definition - ; + : FOR defining_identifier IN discrete_subtype_definition + ; entry_call_statement - : entry_name = name actual_parameter_part? ';' - ; + : entry_name = name actual_parameter_part? ';' + ; requeue_statement - : REQUEUE entry_name = name (WITH ABORT)? ';' - ; + : REQUEUE entry_name = name (WITH ABORT)? ';' + ; delay_statement - : delay_until_statement - | delay_relative_statement - ; + : delay_until_statement + | delay_relative_statement + ; delay_until_statement - : DELAY UNTIL delay_expression = expression ';' - ; + : DELAY UNTIL delay_expression = expression ';' + ; delay_relative_statement - : DELAY delay_expression = expression ';' - ; + : DELAY delay_expression = expression ';' + ; select_statement - : selective_accept - | timed_entry_call - | conditional_entry_call - | asynchronous_select - ; + : selective_accept + | timed_entry_call + | conditional_entry_call + | asynchronous_select + ; selective_accept - : SELECT guard? select_alternative (OR guard? select_alternative)* (ELSE sequence_of_statements)? END SELECT ';' - ; + : SELECT guard? select_alternative (OR guard? select_alternative)* ( + ELSE sequence_of_statements + )? END SELECT ';' + ; guard - : WHEN condition '=>' - ; + : WHEN condition '=>' + ; select_alternative - : accept_alternative - | delay_alternative - | terminate_alternative - ; + : accept_alternative + | delay_alternative + | terminate_alternative + ; accept_alternative - : accept_statement sequence_of_statements? - ; + : accept_statement sequence_of_statements? + ; delay_alternative - : delay_statement sequence_of_statements? - ; + : delay_statement sequence_of_statements? + ; terminate_alternative - : TERMINATE ';' - ; + : TERMINATE ';' + ; timed_entry_call - : SELECT entry_call_alternative OR delay_alternative END SELECT ';' - ; + : SELECT entry_call_alternative OR delay_alternative END SELECT ';' + ; entry_call_alternative - : procedure_or_entry_call sequence_of_statements? - ; + : procedure_or_entry_call sequence_of_statements? + ; procedure_or_entry_call - : procedure_call_statement - | entry_call_statement - ; + : procedure_call_statement + | entry_call_statement + ; conditional_entry_call - : SELECT entry_call_alternative ELSE sequence_of_statements END SELECT ';' - ; + : SELECT entry_call_alternative ELSE sequence_of_statements END SELECT ';' + ; asynchronous_select - : SELECT triggering_alternative THEN ABORT abortable_part END SELECT ';' - ; + : SELECT triggering_alternative THEN ABORT abortable_part END SELECT ';' + ; triggering_alternative - : triggering_statement sequence_of_statements? - ; + : triggering_statement sequence_of_statements? + ; triggering_statement - : procedure_or_entry_call - | delay_statement - ; + : procedure_or_entry_call + | delay_statement + ; abortable_part - : sequence_of_statements - ; + : sequence_of_statements + ; abort_statement - : ABORT task_name = name (',' task_name = name)* ';' - ; + : ABORT task_name = name (',' task_name = name)* ';' + ; + /* 10 - Program Structure and Compilation Issues */ - - + compilation - : compilation_unit* EOF - ; + : compilation_unit* EOF + ; compilation_unit - : context_clause library_item - | context_clause subunit - ; + : context_clause library_item + | context_clause subunit + ; library_item - : PRIVATE? library_unit_declaration - | library_unit_body - | PRIVATE? library_unit_renaming_declaration - ; + : PRIVATE? library_unit_declaration + | library_unit_body + | PRIVATE? library_unit_renaming_declaration + ; library_unit_declaration - : subprogram_declaration - | package_declaration - | generic_declaration - | generic_instantiation - ; + : subprogram_declaration + | package_declaration + | generic_declaration + | generic_instantiation + ; library_unit_renaming_declaration - : package_renaming_declaration - | generic_renaming_declaration - | subprogram_renaming_declaration - ; + : package_renaming_declaration + | generic_renaming_declaration + | subprogram_renaming_declaration + ; library_unit_body - : subprogram_body - | package_body - ; + : subprogram_body + | package_body + ; parent_unit_name - : name - ; + : name + ; context_clause - : context_item* - ; + : context_item* + ; context_item - : with_clause - | use_clause - ; + : with_clause + | use_clause + ; with_clause - : limited_with_clause - | nonlimited_with_clause - ; + : limited_with_clause + | nonlimited_with_clause + ; limited_with_clause - : LIMITED PRIVATE? WITH library_unit_name = name (',' library_unit_name = name)* ';' - ; + : LIMITED PRIVATE? WITH library_unit_name = name (',' library_unit_name = name)* ';' + ; nonlimited_with_clause - : PRIVATE? WITH library_unit_name = name (',' library_unit_name = name)* ';' - ; + : PRIVATE? WITH library_unit_name = name (',' library_unit_name = name)* ';' + ; body_stub - : subprogram_body_stub - | package_body_stub - | task_body_stub - | protected_body_stub - ; + : subprogram_body_stub + | package_body_stub + | task_body_stub + | protected_body_stub + ; subprogram_body_stub - : overriding_indicator? subprogram_specification IS SEPARATE ';' - ; + : overriding_indicator? subprogram_specification IS SEPARATE ';' + ; package_body_stub - : PACKAGE BODY_ defining_identifier IS SEPARATE ';' - ; + : PACKAGE BODY_ defining_identifier IS SEPARATE ';' + ; task_body_stub - : TASK BODY_ defining_identifier IS SEPARATE ';' - ; + : TASK BODY_ defining_identifier IS SEPARATE ';' + ; protected_body_stub - : PROTECTED BODY_ defining_identifier IS SEPARATE ';' - ; + : PROTECTED BODY_ defining_identifier IS SEPARATE ';' + ; subunit - : SEPARATE '(' parent_unit_name ')' proper_body - ; + : SEPARATE '(' parent_unit_name ')' proper_body + ; + /* 11 - Exceptions */ - - + exception_declaration - : defining_identifier_list ':' EXCEPTION ';' - ; + : defining_identifier_list ':' EXCEPTION ';' + ; handled_sequence_of_statements - : sequence_of_statements (EXCEPTION exception_handler exception_handler*)? - ; + : sequence_of_statements (EXCEPTION exception_handler exception_handler*)? + ; exception_handler - : WHEN (choice_parameter_specification ':')? exception_choice ('|' exception_choice)* '=>' sequence_of_statements - ; + : WHEN (choice_parameter_specification ':')? exception_choice ('|' exception_choice)* '=>' sequence_of_statements + ; choice_parameter_specification - : defining_identifier - ; + : defining_identifier + ; exception_choice - : exception_name = name - | OTHERS - ; + : exception_name = name + | OTHERS + ; raise_statement - : RAISE ';' - | RAISE exception_name = name (WITH string_expression = expression)? ';' - ; + : RAISE ';' + | RAISE exception_name = name (WITH string_expression = expression)? ';' + ; + /* 12 - Generic Units */ - - + generic_declaration - : generic_subprogram_declaration - | generic_package_declaration - ; + : generic_subprogram_declaration + | generic_package_declaration + ; generic_subprogram_declaration - : generic_formal_part subprogram_specification ';' - ; + : generic_formal_part subprogram_specification ';' + ; generic_package_declaration - : generic_formal_part package_specification ';' - ; + : generic_formal_part package_specification ';' + ; generic_formal_part - : GENERIC (generic_formal_parameter_declaration | use_clause)* - ; + : GENERIC (generic_formal_parameter_declaration | use_clause)* + ; generic_formal_parameter_declaration - : formal_object_declaration - | formal_type_declaration - | formal_subprogram_declaration - | formal_package_declaration - ; + : formal_object_declaration + | formal_type_declaration + | formal_subprogram_declaration + | formal_package_declaration + ; generic_instantiation - : PACKAGE defining_program_unit_name IS NEW generic_package_name = name generic_actual_part? ';' - | overriding_indicator? PROCEDURE defining_program_unit_name IS NEW generic_procedure_name = name generic_actual_part? ';' - | overriding_indicator? FUNCTION defining_designator IS NEW generic_function_name = name generic_actual_part? ';' - ; + : PACKAGE defining_program_unit_name IS NEW generic_package_name = name generic_actual_part? ';' + | overriding_indicator? PROCEDURE defining_program_unit_name IS NEW generic_procedure_name = name generic_actual_part? ';' + | overriding_indicator? FUNCTION defining_designator IS NEW generic_function_name = name generic_actual_part? ';' + ; generic_actual_part - : '(' generic_association (',' generic_association)* ')' - ; + : '(' generic_association (',' generic_association)* ')' + ; generic_association - : (generic_formal_parameter_selector_name = selector_name '=>')? explicit_generic_actual_parameter - ; + : (generic_formal_parameter_selector_name = selector_name '=>')? explicit_generic_actual_parameter + ; explicit_generic_actual_parameter - : expression - | variable_name = name - | subprogram_name = name - | entry_name = name - | subtype_mark = name - | package_instance_name = name - ; + : expression + | variable_name = name + | subprogram_name = name + | entry_name = name + | subtype_mark = name + | package_instance_name = name + ; formal_object_declaration - : defining_identifier_list ':' mode_ null_exclusion? subtype_mark = name (':=' default_expression)? ';' defining_identifier_list ':' mode_ access_definition (':=' default_expression)? ';' - ; + : defining_identifier_list ':' mode_ null_exclusion? subtype_mark = name ( + ':=' default_expression + )? ';' defining_identifier_list ':' mode_ access_definition (':=' default_expression)? ';' + ; formal_type_declaration - : TYPE defining_identifier discriminant_part? IS formal_type_definition ';' - ; + : TYPE defining_identifier discriminant_part? IS formal_type_definition ';' + ; formal_type_definition - : formal_private_type_definition - | formal_derived_type_definition - | formal_discrete_type_definition - | formal_signed_integer_type_definition - | formal_modular_type_definition - | formal_floating_point_definition - | formal_ordinary_fixed_point_definition - | formal_decimal_fixed_point_definition - | formal_array_type_definition - | formal_access_type_definition - | formal_interface_type_definition - ; + : formal_private_type_definition + | formal_derived_type_definition + | formal_discrete_type_definition + | formal_signed_integer_type_definition + | formal_modular_type_definition + | formal_floating_point_definition + | formal_ordinary_fixed_point_definition + | formal_decimal_fixed_point_definition + | formal_array_type_definition + | formal_access_type_definition + | formal_interface_type_definition + ; formal_private_type_definition - : (ABSTRACT? TAGGED)? LIMITED? PRIVATE - ; + : (ABSTRACT? TAGGED)? LIMITED? PRIVATE + ; formal_derived_type_definition - : ABSTRACT? (LIMITED | SYNCHRONIZED)? NEW subtype_mark = name ((AND interface_list)? WITH PRIVATE)? - ; + : ABSTRACT? (LIMITED | SYNCHRONIZED)? NEW subtype_mark = name ( + (AND interface_list)? WITH PRIVATE + )? + ; formal_discrete_type_definition - : '(' '<>' ')' - ; + : '(' '<>' ')' + ; formal_signed_integer_type_definition - : RANGE_ '<>' - ; + : RANGE_ '<>' + ; formal_modular_type_definition - : MOD '<>' - ; + : MOD '<>' + ; formal_floating_point_definition - : DIGITS '<>' - ; + : DIGITS '<>' + ; formal_ordinary_fixed_point_definition - : DELTA '<>' - ; + : DELTA '<>' + ; formal_decimal_fixed_point_definition - : DELTA '<>' DIGITS '<>' - ; + : DELTA '<>' DIGITS '<>' + ; formal_array_type_definition - : array_type_definition - ; + : array_type_definition + ; formal_access_type_definition - : access_type_definition - ; + : access_type_definition + ; formal_interface_type_definition - : interface_type_definition - ; + : interface_type_definition + ; formal_subprogram_declaration - : formal_concrete_subprogram_declaration - | formal_abstract_subprogram_declaration - ; + : formal_concrete_subprogram_declaration + | formal_abstract_subprogram_declaration + ; formal_concrete_subprogram_declaration - : WITH subprogram_specification (IS subprogram_default)? ';' - ; + : WITH subprogram_specification (IS subprogram_default)? ';' + ; formal_abstract_subprogram_declaration - : WITH subprogram_specification IS ABSTRACT subprogram_default? ';' - ; + : WITH subprogram_specification IS ABSTRACT subprogram_default? ';' + ; subprogram_default - : default_name - | '<>' - | NULL_ - ; + : default_name + | '<>' + | NULL_ + ; default_name - : name - ; + : name + ; formal_package_declaration - : WITH PACKAGE defining_identifier IS NEW generic_package_name = name formal_package_actual_part ';' - ; + : WITH PACKAGE defining_identifier IS NEW generic_package_name = name formal_package_actual_part ';' + ; formal_package_actual_part - : '(' (OTHERS '=>')? '<>' ')' - | generic_actual_part? - | '(' formal_package_association (',' formal_package_association)* (',' OTHERS '=>' '<>')? ')' - ; + : '(' (OTHERS '=>')? '<>' ')' + | generic_actual_part? + | '(' formal_package_association (',' formal_package_association)* (',' OTHERS '=>' '<>')? ')' + ; formal_package_association - : generic_association - | generic_formal_parameter_selector_name = selector_name '=>' '<>' - ; + : generic_association + | generic_formal_parameter_selector_name = selector_name '=>' '<>' + ; + /* 13 - Representation Issues */ - - + aspect_clause - : attribute_definition_clause - | enumeration_representation_clause - | record_representation_clause - | at_clause - ; + : attribute_definition_clause + | enumeration_representation_clause + | record_representation_clause + | at_clause + ; local_name - : direct_name - | direct_name SQ attribute_designator - | library_unit_name = name - ; + : direct_name + | direct_name SQ attribute_designator + | library_unit_name = name + ; attribute_definition_clause - : FOR local_name SQ attribute_designator USE expression ';' - | FOR local_name SQ attribute_designator USE name ';' - ; + : FOR local_name SQ attribute_designator USE expression ';' + | FOR local_name SQ attribute_designator USE name ';' + ; enumeration_representation_clause - : FOR first_subtype_local_name = local_name USE enumeration_aggregate ';' - ; + : FOR first_subtype_local_name = local_name USE enumeration_aggregate ';' + ; enumeration_aggregate - : array_aggregate - ; + : array_aggregate + ; record_representation_clause - : FOR first_subtype_local_name = local_name USE RECORD mod_clause? component_clause* END RECORD ';' - ; + : FOR first_subtype_local_name = local_name USE RECORD mod_clause? component_clause* END RECORD ';' + ; component_clause - : component_local_name = local_name AT position RANGE_ first_bit '..' last_bit ';' - ; + : component_local_name = local_name AT position RANGE_ first_bit '..' last_bit ';' + ; position - : static_expression = expression - ; + : static_expression = expression + ; first_bit - : static_simple_expression = simple_expression - ; + : static_simple_expression = simple_expression + ; last_bit - : static_simple_expression = simple_expression - ; + : static_simple_expression = simple_expression + ; code_statement - : qualified_expression ';' - ; + : qualified_expression ';' + ; + /* - */ - - + at_clause - : FOR direct_name USE AT expression ';' - ; + : FOR direct_name USE AT expression ';' + ; mod_clause - : AT MOD static_expression = expression ';' - ; + : AT MOD static_expression = expression ';' + ; delta_constraint - : DELTA static_expression = expression range_constraint? - ; - + : DELTA static_expression = expression range_constraint? + ; \ No newline at end of file diff --git a/ada/ada2012/AdaLexer.g4 b/ada/ada2012/AdaLexer.g4 index 1088a2fab9..7d7704e594 100644 --- a/ada/ada2012/AdaLexer.g4 +++ b/ada/ada2012/AdaLexer.g4 @@ -21,153 +21,169 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar AdaLexer; -options { caseInsensitive = true; } - -ABORT : 'abort'; -ABS : 'abs'; -ABSTRACT : 'abstract'; -ACCEPT_ : 'accept'; -ACCESS : 'access'; -ALIASED : 'aliased'; -ALL : 'all'; -AND : 'and'; -ARRAY : 'array'; -AT : 'at'; - -BEGIN : 'begin'; -BODY_ : 'body'; - -CASE : 'case'; -CONSTANT : 'constant'; - -DECLARE : 'declare'; -DELAY : 'delay'; -DELTA : 'delta'; -DIGITS : 'digits'; -DO : 'do'; - -ELSE : 'else'; -ELSIF : 'elsif'; -END : 'end'; -ENTRY : 'entry'; -EXCEPTION : 'exception'; -EXIT : 'exit'; - -FOR : 'for'; -FUNCTION : 'function'; - -GENERIC : 'generic'; -GOTO : 'goto'; - -IF : 'if'; -IN : 'in'; -INTERFACE : 'interface'; -IS : 'is'; - -LIMITED : 'limited'; -LOOP : 'loop'; - -MOD : 'mod'; - -NEW : 'new'; -NOT : 'not'; -NULL_ : 'null'; - -OF : 'of'; -OR : 'or'; -OTHERS : 'others'; -OUT : 'out'; -OVERRIDING : 'overriding'; -PACKAGE : 'package'; -PRAGMA : 'pragma'; -PRIVATE : 'private'; -PROCEDURE : 'procedure'; -PROTECTED : 'protected'; - -RAISE : 'raise'; -RANGE_ : 'range'; -RECORD : 'record'; -REM : 'rem'; -RENAMES : 'renames'; -REQUEUE : 'requeue'; -RETURN : 'return'; -REVERSE : 'reverse'; - -SELECT : 'select'; -SEPARATE : 'separate'; -SOME : 'some'; -SUBTYPE : 'subtype'; -SYNCHRONIZED : 'synchronized'; - -TAGGED : 'tagged'; -TASK : 'task'; -TERMINATE : 'terminate'; -THEN : 'then'; -TYPE : 'type'; - -UNTIL : 'until'; -USE : 'use'; - -WHEN : 'when'; -WHILE : 'while'; -WITH : 'with'; - -XOR : 'xor'; - -CLASS__ options { caseInsensitive = false; } : 'Class'; -ACCESS__ options { caseInsensitive = false; } : 'Access'; -DELTA__ options { caseInsensitive = false; } : 'Delta'; -DIGITS__ options { caseInsensitive = false; } : 'Digits'; -MOD__ options { caseInsensitive = false; } : 'Mod'; - -WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); -LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); - -IDENTIFIER_ : LETTER+ [A-Z_0-9]*; -NUMERIC_LITERAL_ : DECIMAL_LITERAL_ | BASED_LITERAL; -DECIMAL_LITERAL_ : NUMERAL ('.' NUMERAL)? EXPONENT?; -NUMERAL : DIGIT+ ('_'? DIGIT)*; -EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; -BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; -BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; -EXTENDED_DIGIT : DIGIT | [A-F]; -BASE : NUMERAL; - -CHARACTER_LITERAL_: '\'' ~['\\\r\n] '\''; -STRING_LITERAL_ : '"' ('""' | ~'"' )* '"'; - -fragment LETTER : [A-Z]; -fragment DIGIT : [0-9]; - -HASH : '#'; -AMPERSAND : '&'; -LP : '('; -RP : ')'; -MULT : '*'; -PLUS : '+'; -COMMA : ','; -MINUS : '-'; -DOT : '.'; -COLON : ':'; -SEMI : ';'; -LT : '<'; -EQ : '='; -GT : '>'; -US : '_'; -VL : '|'; -DIV : '/'; -EP : '!'; -PS : '%'; -ARROW : '=>'; -DOTDOT : '..'; -EXPON : '**'; -ASSIGN : ':='; -NE : '/='; -GE : '>='; -LE : '<='; -LLB : '<<'; -RLB : '>>'; -BOX : '<>'; -SQ : '\''; +options { + caseInsensitive = true; +} + +ABORT : 'abort'; +ABS : 'abs'; +ABSTRACT : 'abstract'; +ACCEPT_ : 'accept'; +ACCESS : 'access'; +ALIASED : 'aliased'; +ALL : 'all'; +AND : 'and'; +ARRAY : 'array'; +AT : 'at'; + +BEGIN : 'begin'; +BODY_ : 'body'; + +CASE : 'case'; +CONSTANT : 'constant'; + +DECLARE : 'declare'; +DELAY : 'delay'; +DELTA : 'delta'; +DIGITS : 'digits'; +DO : 'do'; + +ELSE : 'else'; +ELSIF : 'elsif'; +END : 'end'; +ENTRY : 'entry'; +EXCEPTION : 'exception'; +EXIT : 'exit'; + +FOR : 'for'; +FUNCTION : 'function'; + +GENERIC : 'generic'; +GOTO : 'goto'; + +IF : 'if'; +IN : 'in'; +INTERFACE : 'interface'; +IS : 'is'; + +LIMITED : 'limited'; +LOOP : 'loop'; + +MOD: 'mod'; + +NEW : 'new'; +NOT : 'not'; +NULL_ : 'null'; + +OF : 'of'; +OR : 'or'; +OTHERS : 'others'; +OUT : 'out'; +OVERRIDING : 'overriding'; +PACKAGE : 'package'; +PRAGMA : 'pragma'; +PRIVATE : 'private'; +PROCEDURE : 'procedure'; +PROTECTED : 'protected'; + +RAISE : 'raise'; +RANGE_ : 'range'; +RECORD : 'record'; +REM : 'rem'; +RENAMES : 'renames'; +REQUEUE : 'requeue'; +RETURN : 'return'; +REVERSE : 'reverse'; + +SELECT : 'select'; +SEPARATE : 'separate'; +SOME : 'some'; +SUBTYPE : 'subtype'; +SYNCHRONIZED : 'synchronized'; + +TAGGED : 'tagged'; +TASK : 'task'; +TERMINATE : 'terminate'; +THEN : 'then'; +TYPE : 'type'; + +UNTIL : 'until'; +USE : 'use'; + +WHEN : 'when'; +WHILE : 'while'; +WITH : 'with'; + +XOR: 'xor'; + +CLASS__ options { + caseInsensitive = false; +}: 'Class'; +ACCESS__ options { + caseInsensitive = false; +}: 'Access'; +DELTA__ options { + caseInsensitive = false; +}: 'Delta'; +DIGITS__ options { + caseInsensitive = false; +}: 'Digits'; +MOD__ options { + caseInsensitive = false; +}: 'Mod'; + +WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); + +IDENTIFIER_ : LETTER+ [A-Z_0-9]*; +NUMERIC_LITERAL_ : DECIMAL_LITERAL_ | BASED_LITERAL; +DECIMAL_LITERAL_ : NUMERAL ('.' NUMERAL)? EXPONENT?; +NUMERAL : DIGIT+ ('_'? DIGIT)*; +EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; +BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; +BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; +EXTENDED_DIGIT : DIGIT | [A-F]; +BASE : NUMERAL; + +CHARACTER_LITERAL_ : '\'' ~['\\\r\n] '\''; +STRING_LITERAL_ : '"' ('""' | ~'"')* '"'; + +fragment LETTER : [A-Z]; +fragment DIGIT : [0-9]; + +HASH : '#'; +AMPERSAND : '&'; +LP : '('; +RP : ')'; +MULT : '*'; +PLUS : '+'; +COMMA : ','; +MINUS : '-'; +DOT : '.'; +COLON : ':'; +SEMI : ';'; +LT : '<'; +EQ : '='; +GT : '>'; +US : '_'; +VL : '|'; +DIV : '/'; +EP : '!'; +PS : '%'; +ARROW : '=>'; +DOTDOT : '..'; +EXPON : '**'; +ASSIGN : ':='; +NE : '/='; +GE : '>='; +LE : '<='; +LLB : '<<'; +RLB : '>>'; +BOX : '<>'; +SQ : '\''; \ No newline at end of file diff --git a/ada/ada2012/AdaParser.g4 b/ada/ada2012/AdaParser.g4 index 825983b15f..40a765ec89 100644 --- a/ada/ada2012/AdaParser.g4 +++ b/ada/ada2012/AdaParser.g4 @@ -20,1458 +20,1478 @@ 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. */ + +// $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 AdaParser; +options { + tokenVocab = AdaLexer; +} -options { tokenVocab = AdaLexer; } /* 2 - Lexical Elements */ - identifier - : IDENTIFIER_ - ; + : IDENTIFIER_ + ; numeric_literal - : NUMERIC_LITERAL_ - ; + : NUMERIC_LITERAL_ + ; character_literal - : CHARACTER_LITERAL_ - ; + : CHARACTER_LITERAL_ + ; string_literal - : STRING_LITERAL_ - ; + : STRING_LITERAL_ + ; + /* 3 - Declarations and Types */ - basic_declaration - : type_declaration - | subtype_declaration - | object_declaration - | number_declaration - | subprogram_declaration - | abstract_subprogram_declaration - | null_procedure_declaration - | expression_function_declaration - | package_declaration - | renaming_declaration - | exception_declaration - | generic_declaration - | generic_instantiation - ; + : type_declaration + | subtype_declaration + | object_declaration + | number_declaration + | subprogram_declaration + | abstract_subprogram_declaration + | null_procedure_declaration + | expression_function_declaration + | package_declaration + | renaming_declaration + | exception_declaration + | generic_declaration + | generic_instantiation + ; defining_identifier - : identifier - ; + : identifier + ; type_declaration - : full_type_declaration - | incomplete_type_declaration - | private_type_declaration - | private_extension_declaration - ; + : full_type_declaration + | incomplete_type_declaration + | private_type_declaration + | private_extension_declaration + ; full_type_declaration - : TYPE defining_identifier known_discriminant_part? IS type_definition aspect_specification? SEMI - | task_type_declaration - | protected_type_declaration - ; + : TYPE defining_identifier known_discriminant_part? IS type_definition aspect_specification? SEMI + | task_type_declaration + | protected_type_declaration + ; type_definition - : enumeration_type_definition - | integer_type_definition - | real_type_definition - | array_type_definition - | record_type_definition - | access_type_definition - | derived_type_definition - | interface_type_definition - ; + : enumeration_type_definition + | integer_type_definition + | real_type_definition + | array_type_definition + | record_type_definition + | access_type_definition + | derived_type_definition + | interface_type_definition + ; subtype_declaration - : SUBTYPE defining_identifier IS subtype_indication aspect_specification? - ; + : SUBTYPE defining_identifier IS subtype_indication aspect_specification? + ; subtype_indication - : null_exclusion? subtype_mark constraint? - ; + : null_exclusion? subtype_mark constraint? + ; subtype_mark - : identifier - ; + : identifier + ; constraint - : scalar_constraint - | composite_constraint - ; + : scalar_constraint + | composite_constraint + ; scalar_constraint - : range_constraint - | digits_constraint - | delta_constraint - ; + : range_constraint + | digits_constraint + | delta_constraint + ; composite_constraint - : index_constraint - | discriminant_constraint - ; + : index_constraint + | discriminant_constraint + ; object_declaration - : defining_identifier_list COLON ALIASED? CONSTANT? subtype_indication (ASSIGN expression)? aspect_specification? SEMI - | defining_identifier_list COLON ALIASED? CONSTANT? access_definition (ASSIGN expression)? aspect_specification? SEMI - | defining_identifier_list COLON ALIASED? CONSTANT? array_type_definition (ASSIGN expression)? aspect_specification? SEMI - | single_task_declaration - | single_protected_declaration - ; + : defining_identifier_list COLON ALIASED? CONSTANT? subtype_indication (ASSIGN expression)? aspect_specification? SEMI + | defining_identifier_list COLON ALIASED? CONSTANT? access_definition (ASSIGN expression)? aspect_specification? SEMI + | defining_identifier_list COLON ALIASED? CONSTANT? array_type_definition (ASSIGN expression)? aspect_specification? SEMI + | single_task_declaration + | single_protected_declaration + ; defining_identifier_list - : defining_identifier (',' defining_identifier)* - ; + : defining_identifier (',' defining_identifier)* + ; number_declaration - : defining_identifier_list COLON CONSTANT ASSIGN expression - ; + : defining_identifier_list COLON CONSTANT ASSIGN expression + ; derived_type_definition - : ABSTRACT? LIMITED? NEW subtype_indication ((AND interface_list)? record_extension_part)? - ; + : ABSTRACT? LIMITED? NEW subtype_indication ((AND interface_list)? record_extension_part)? + ; range_constraint - : RANGE_ range - ; + : RANGE_ range + ; range - : range_attribute_reference - | simple_expression DOTDOT simple_expression - ; + : range_attribute_reference + | simple_expression DOTDOT simple_expression + ; enumeration_type_definition - : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' - ; + : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' + ; enumeration_literal_specification - : defining_identifier - | character_literal - ; + : defining_identifier + | character_literal + ; integer_type_definition - : signed_integer_type_definition - | modular_type_definition - ; + : signed_integer_type_definition + | modular_type_definition + ; signed_integer_type_definition - : RANGE_ expression '..' expression - ; + : RANGE_ expression '..' expression + ; modular_type_definition - : MOD expression - ; + : MOD expression + ; real_type_definition - : floating_point_definition - | fixed_point_definition - ; + : floating_point_definition + | fixed_point_definition + ; floating_point_definition - : DIGITS expression real_range_specification? - ; + : DIGITS expression real_range_specification? + ; real_range_specification - : RANGE_ expression DOTDOT expression - ; + : RANGE_ expression DOTDOT expression + ; fixed_point_definition - : ordinary_fixed_point_definition - | decimal_fixed_point_definition - ; + : ordinary_fixed_point_definition + | decimal_fixed_point_definition + ; ordinary_fixed_point_definition - : DELTA expression real_range_specification - ; + : DELTA expression real_range_specification + ; decimal_fixed_point_definition - : DELTA expression DIGITS expression real_range_specification? - ; + : DELTA expression DIGITS expression real_range_specification? + ; digits_constraint - : DIGITS expression range_constraint? - ; + : DIGITS expression range_constraint? + ; array_type_definition - : unconstrained_array_definition - | constrained_array_definition - ; + : unconstrained_array_definition + | constrained_array_definition + ; unconstrained_array_definition - : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF component_definition - ; + : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF component_definition + ; index_subtype_definition - : subtype_mark RANGE_ BOX - ; + : subtype_mark RANGE_ BOX + ; constrained_array_definition - : ARRAY '(' discrete_subtype_definition (',' discrete_subtype_definition)* ')' OF component_definition - ; + : ARRAY '(' discrete_subtype_definition (',' discrete_subtype_definition)* ')' OF component_definition + ; discrete_subtype_definition - : subtype_indication - | range - ; + : subtype_indication + | range + ; component_definition - : ALIASED? subtype_indication - | ALIASED? access_definition - ; + : ALIASED? subtype_indication + | ALIASED? access_definition + ; index_constraint - : '(' discrete_range (',' discrete_range)* ')' - ; + : '(' discrete_range (',' discrete_range)* ')' + ; discrete_range - : subtype_indication - | range - ; + : subtype_indication + | range + ; discriminant_part - : unknown_discriminant_part - | known_discriminant_part - ; + : unknown_discriminant_part + | known_discriminant_part + ; unknown_discriminant_part - : '(' BOX ')' - ; + : '(' BOX ')' + ; known_discriminant_part - : '(' discriminant_specification (SEMI discriminant_specification)* ')' - ; + : '(' discriminant_specification (SEMI discriminant_specification)* ')' + ; discriminant_specification - : defining_identifier_list COLON null_exclusion? subtype_mark (ASSIGN expression)? - | defining_identifier_list COLON access_definition (ASSIGN expression)? - ; + : defining_identifier_list COLON null_exclusion? subtype_mark (ASSIGN expression)? + | defining_identifier_list COLON access_definition (ASSIGN expression)? + ; default_expression - : expression - ; + : expression + ; discriminant_constraint - : '(' discriminant_association (',' discriminant_association)* ')' - ; + : '(' discriminant_association (',' discriminant_association)* ')' + ; discriminant_association - : (selector_name (VL selector_name)* ARROW)? expression - ; + : (selector_name (VL selector_name)* ARROW)? expression + ; record_type_definition - : (ABSTRACT? TAGGED)? LIMITED? record_definition - ; + : (ABSTRACT? TAGGED)? LIMITED? record_definition + ; record_definition - : RECORD component_list END RECORD - | NULL_ RECORD - ; + : RECORD component_list END RECORD + | NULL_ RECORD + ; component_list - : component_item+ - | component_item* variant_part - | NULL_ SEMI - ; + : component_item+ + | component_item* variant_part + | NULL_ SEMI + ; component_item - : component_declaration - | aspect_clause - ; + : component_declaration + | aspect_clause + ; component_declaration - : defining_identifier_list COLON component_definition (ASSIGN default_expression)? aspect_specification? SEMI - ; + : defining_identifier_list COLON component_definition (ASSIGN default_expression)? aspect_specification? SEMI + ; variant_part - : CASE direct_name IS variant+ END CASE SEMI - ; + : CASE direct_name IS variant+ END CASE SEMI + ; variant - : WHEN discrete_choice_list ARROW component_list - ; + : WHEN discrete_choice_list ARROW component_list + ; discrete_choice_list - : discrete_choice (VL discrete_choice)* - ; + : discrete_choice (VL discrete_choice)* + ; discrete_choice - : choice_expression - | subtype_indication - | range - | OTHERS - ; + : choice_expression + | subtype_indication + | range + | OTHERS + ; record_extension_part - : WITH record_definition - ; + : WITH record_definition + ; abstract_subprogram_declaration - : overriding_indicator? subprogram_specification IS ABSTRACT aspect_specification? - ; + : overriding_indicator? subprogram_specification IS ABSTRACT aspect_specification? + ; interface_type_definition - : (LIMITED | TASK | PROTECTED | SYNCHRONIZED)? INTERFACE (AND interface_list)? - ; + : (LIMITED | TASK | PROTECTED | SYNCHRONIZED)? INTERFACE (AND interface_list)? + ; interface_list - : subtype_mark (AND subtype_mark)* - ; + : subtype_mark (AND subtype_mark)* + ; access_type_definition - : null_exclusion? access_to_object_definition - | null_exclusion? access_to_subprogram_definition - ; + : null_exclusion? access_to_object_definition + | null_exclusion? access_to_subprogram_definition + ; access_to_object_definition - : ACCESS general_access_modifier? subtype_indication - ; + : ACCESS general_access_modifier? subtype_indication + ; general_access_modifier - : ALL - | CONSTANT - ; + : ALL + | CONSTANT + ; access_to_subprogram_definition - : ACCESS PROTECTED? PROCEDURE formal_part? //parameter_profile - | ACCESS PROTECTED? FUNCTION parameter_and_result_profile - ; + : ACCESS PROTECTED? PROCEDURE formal_part? //parameter_profile + | ACCESS PROTECTED? FUNCTION parameter_and_result_profile + ; null_exclusion - : NOT NULL_ - ; + : NOT NULL_ + ; access_definition - : null_exclusion? ACCESS CONSTANT? subtype_mark - | null_exclusion? ACCESS PROTECTED? PROCEDURE formal_part? //parameter_profile - | null_exclusion? ACCESS PROTECTED? FUNCTION parameter_and_result_profile - ; + : null_exclusion? ACCESS CONSTANT? subtype_mark + | null_exclusion? ACCESS PROTECTED? PROCEDURE formal_part? //parameter_profile + | null_exclusion? ACCESS PROTECTED? FUNCTION parameter_and_result_profile + ; incomplete_type_declaration - : TYPE defining_identifier discriminant_part? (IS TAGGED)? SEMI - ; + : TYPE defining_identifier discriminant_part? (IS TAGGED)? SEMI + ; declarative_part - : declarative_item* - ; + : declarative_item* + ; declarative_item - : basic_declarative_item - | body - ; + : basic_declarative_item + | body + ; basic_declarative_item - : basic_declaration - | aspect_clause - | use_clause - ; + : basic_declaration + | aspect_clause + | use_clause + ; body - : proper_body - | body_stub - ; + : proper_body + | body_stub + ; proper_body - : subprogram_body - | package_body - | task_body - | protected_body - ; + : subprogram_body + | package_body + | task_body + | protected_body + ; + /* 4 - Names and Expressions */ - name - : direct_name - //| explicit_dereference - | name DOT ALL - | name '(' expression (',' expression)* ')' //indexed_component - | name '(' discrete_range ')' //slice - | name DOT selector_name //selected_component - | name SQ attribute_designator //attribute_reference - | type_conversion - | name actual_parameter_part //function_call - | character_literal - | qualified_expression - //| name //generalized_reference - | name actual_parameter_part //generalized_indexing - - ; + : direct_name + //| explicit_dereference + | name DOT ALL + | name '(' expression (',' expression)* ')' //indexed_component + | name '(' discrete_range ')' //slice + | name DOT selector_name //selected_component + | name SQ attribute_designator //attribute_reference + | type_conversion + | name actual_parameter_part //function_call + | character_literal + | qualified_expression + //| name //generalized_reference + | name actual_parameter_part //generalized_indexing + ; direct_name - : identifier - | operator_symbol - ; + : identifier + | operator_symbol + ; selector_name - : identifier - | character_literal - | operator_symbol - ; + : identifier + | character_literal + | operator_symbol + ; attribute_designator - : identifier ('(' expression ')')? - | ACCESS__ - | DELTA__ - | DIGITS__ - | MOD__ - ; + : identifier ('(' expression ')')? + | ACCESS__ + | DELTA__ + | DIGITS__ + | MOD__ + ; range_attribute_reference - // : prefix '\'' range_attribute_designator - : name '\'' range_attribute_designator - ; +// : prefix '\'' range_attribute_designator + : name '\'' range_attribute_designator + ; range_attribute_designator - : RANGE_ ('(' expression ')')? - ; + : RANGE_ ('(' expression ')')? + ; aggregate - : record_aggregate - | extension_aggregate - | array_aggregate - ; + : record_aggregate + | extension_aggregate + | array_aggregate + ; record_aggregate - : '(' record_component_association_list ')' - ; + : '(' record_component_association_list ')' + ; record_component_association_list - : record_component_association (',' record_component_association)* - | NULL_ RECORD - ; + : record_component_association (',' record_component_association)* + | NULL_ RECORD + ; record_component_association - : (component_choice_list ARROW)? expression - | component_choice_list ARROW BOX - ; + : (component_choice_list ARROW)? expression + | component_choice_list ARROW BOX + ; component_choice_list - : selector_name (VL selector_name)* - | OTHERS - ; + : selector_name (VL selector_name)* + | OTHERS + ; extension_aggregate - : '(' ancestor_part WITH record_component_association_list ')' - ; + : '(' ancestor_part WITH record_component_association_list ')' + ; ancestor_part - : expression - | subtype_mark - ; + : expression + | subtype_mark + ; array_aggregate - : positional_array_aggregate - | named_array_aggregate - ; + : positional_array_aggregate + | named_array_aggregate + ; positional_array_aggregate - : '(' expression ',' expression (',' expression)* ')' - | '(' expression (',' expression)* ',' OTHERS ARROW expression ')' - | '(' expression (',' expression)* ',' OTHERS ARROW BOX ')' - ; + : '(' expression ',' expression (',' expression)* ')' + | '(' expression (',' expression)* ',' OTHERS ARROW expression ')' + | '(' expression (',' expression)* ',' OTHERS ARROW BOX ')' + ; named_array_aggregate - : '(' array_component_association (',' array_component_association)* ')' - ; + : '(' array_component_association (',' array_component_association)* ')' + ; array_component_association - : discrete_choice_list ARROW expression - | discrete_choice_list ARROW BOX - ; + : discrete_choice_list ARROW expression + | discrete_choice_list ARROW BOX + ; expression - : relation (AND relation)* - | relation (AND THEN relation)* - | relation (OR relation)* - | relation (OR ELSE relation)* - | relation (XOR relation)* - ; + : relation (AND relation)* + | relation (AND THEN relation)* + | relation (OR relation)* + | relation (OR ELSE relation)* + | relation (XOR relation)* + ; choice_expression - : choice_relation (AND choice_relation)* - | choice_relation (OR choice_relation)* - | choice_relation (XOR choice_relation)* - | choice_relation (AND THEN choice_relation)* - | choice_relation (OR ELSE choice_relation)* - ; + : choice_relation (AND choice_relation)* + | choice_relation (OR choice_relation)* + | choice_relation (XOR choice_relation)* + | choice_relation (AND THEN choice_relation)* + | choice_relation (OR ELSE choice_relation)* + ; choice_relation - : simple_expression (relational_operator simple_expression)? - ; + : simple_expression (relational_operator simple_expression)? + ; relation - : simple_expression (relational_operator simple_expression)? - | simple_expression NOT? IN membership_choice_list - ; + : simple_expression (relational_operator simple_expression)? + | simple_expression NOT? IN membership_choice_list + ; membership_choice_list - : membership_choice (VL membership_choice)* - ; + : membership_choice (VL membership_choice)* + ; membership_choice - : choice_expression - | range - | subtype_mark - ; + : choice_expression + | range + | subtype_mark + ; simple_expression - : unary_adding_operator? term (binary_adding_operator term)* - ; + : unary_adding_operator? term (binary_adding_operator term)* + ; term - : factor (multiplying_operator factor)* - ; + : factor (multiplying_operator factor)* + ; factor - : primary (EXPON primary)? - | ABS primary - | NOT primary - ; + : primary (EXPON primary)? + | ABS primary + | NOT primary + ; primary - : numeric_literal - | NULL_ - | string_literal - | aggregate - | name - | allocator - | '(' expression ')' - | '(' conditional_expression ')' - | '(' qualified_expression ')' - ; + : numeric_literal + | NULL_ + | string_literal + | aggregate + | name + | allocator + | '(' expression ')' + | '(' conditional_expression ')' + | '(' qualified_expression ')' + ; logical_operator - : AND - | OR - | XOR - ; + : AND + | OR + | XOR + ; relational_operator - : EQ - | NE - | LE - | GT - | LE - | GE - ; + : EQ + | NE + | LE + | GT + | LE + | GE + ; binary_adding_operator - : PLUS - | MINUS - | AMPERSAND - ; + : PLUS + | MINUS + | AMPERSAND + ; unary_adding_operator - : PLUS - | MINUS - ; + : PLUS + | MINUS + ; multiplying_operator - : MULT - | DIV - | MOD - | REM - ; + : MULT + | DIV + | MOD + | REM + ; highest_precedence_operator - : EXPON - | ABS - | NOT - ; + : EXPON + | ABS + | NOT + ; conditional_expression - : if_expression - | case_expression - ; + : if_expression + | case_expression + ; if_expression - : IF condition THEN expression (ELSIF condition THEN expression)* (ELSE expression)? - ; + : IF condition THEN expression (ELSIF condition THEN expression)* (ELSE expression)? + ; condition - : expression - ; + : expression + ; case_expression - : CASE expression IS case_expression_alternative (',' case_expression_alternative)* - ; + : CASE expression IS case_expression_alternative (',' case_expression_alternative)* + ; case_expression_alternative - : WHEN discrete_choice_list ARROW expression - ; + : WHEN discrete_choice_list ARROW expression + ; quantified_expression - : FOR quantifier loop_parameter_specification ARROW predicate - | FOR quantifier iterator_specification ARROW predicate - ; + : FOR quantifier loop_parameter_specification ARROW predicate + | FOR quantifier iterator_specification ARROW predicate + ; quantifier - : ALL - | SOME - ; + : ALL + | SOME + ; predicate - : expression - ; + : expression + ; type_conversion - : subtype_mark '(' expression ')' - | subtype_mark '(' name ')' - ; + : subtype_mark '(' expression ')' + | subtype_mark '(' name ')' + ; qualified_expression - : subtype_mark SQ '(' expression ')' - | subtype_mark SQ '(' aggregate ')' - ; + : subtype_mark SQ '(' expression ')' + | subtype_mark SQ '(' aggregate ')' + ; allocator - : NEW subpool_specification? subtype_indication - | NEW subpool_specification? qualified_expression - ; + : NEW subpool_specification? subtype_indication + | NEW subpool_specification? qualified_expression + ; subpool_specification - : '(' name ')' - ; + : '(' name ')' + ; + /* 5 - Statements */ - sequence_of_statements - : statement+ label* - ; + : statement+ label* + ; statement - : label* simple_statement - | label* compound_statement - ; + : label* simple_statement + | label* compound_statement + ; simple_statement - : null_statement - | assignment_statement - | exit_statement - | goto_statement - | procedure_call_statement - | simple_return_statement - | entry_call_statement - | requeue_statement - | delay_statement - | abort_statement - | raise_statement - | qualified_expression //code_statement - - ; + : null_statement + | assignment_statement + | exit_statement + | goto_statement + | procedure_call_statement + | simple_return_statement + | entry_call_statement + | requeue_statement + | delay_statement + | abort_statement + | raise_statement + | qualified_expression //code_statement + ; compound_statement - : if_statement - | case_statement - | loop_statement - | block_statement - | extended_return_statement - | accept_statement - | select_statement - ; + : if_statement + | case_statement + | loop_statement + | block_statement + | extended_return_statement + | accept_statement + | select_statement + ; null_statement - : NULL_ SEMI - ; + : NULL_ SEMI + ; label - : direct_name - ; + : direct_name + ; assignment_statement - : name ASSIGN expression SEMI - ; + : name ASSIGN expression SEMI + ; if_statement - : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* (ELSE sequence_of_statements)? END IF SEMI - ; + : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* ( + ELSE sequence_of_statements + )? END IF SEMI + ; case_statement - : CASE expression IS case_statement_alternative case_statement_alternative* END CASE SEMI - ; + : CASE expression IS case_statement_alternative case_statement_alternative* END CASE SEMI + ; case_statement_alternative - : WHEN discrete_choice_list ARROW sequence_of_statements - ; + : WHEN discrete_choice_list ARROW sequence_of_statements + ; loop_statement - : (direct_name COLON)? iteration_scheme? LOOP sequence_of_statements END LOOP identifier? SEMI - ; + : (direct_name COLON)? iteration_scheme? LOOP sequence_of_statements END LOOP identifier? SEMI + ; iteration_scheme - : WHILE condition - | FOR loop_parameter_specification - | FOR iterator_specification - ; + : WHILE condition + | FOR loop_parameter_specification + | FOR iterator_specification + ; loop_parameter_specification - : defining_identifier IN REVERSE? discrete_subtype_definition - ; + : defining_identifier IN REVERSE? discrete_subtype_definition + ; iterator_specification - : defining_identifier IN REVERSE? name - | defining_identifier COLON subtype_indication OF REVERSE? name - ; + : defining_identifier IN REVERSE? name + | defining_identifier COLON subtype_indication OF REVERSE? name + ; block_statement - : (direct_name COLON)? (DECLARE declarative_part)? BEGIN handled_sequence_of_statements END identifier? SEMI - ; + : (direct_name COLON)? (DECLARE declarative_part)? BEGIN handled_sequence_of_statements END identifier? SEMI + ; exit_statement - : EXIT name? (WHEN condition)? SEMI - ; + : EXIT name? (WHEN condition)? SEMI + ; goto_statement - : GOTO name - ; + : GOTO name + ; + /* 6 - Subprograms */ - subprogram_declaration - : overriding_indicator? subprogram_specification aspect_specification? SEMI - ; + : overriding_indicator? subprogram_specification aspect_specification? SEMI + ; subprogram_specification - : procedure_specification - | function_specification - ; + : procedure_specification + | function_specification + ; procedure_specification - : PROCEDURE defining_program_unit_name formal_part? //parameter_profile? - - ; + : PROCEDURE defining_program_unit_name formal_part? //parameter_profile? + ; function_specification - : FUNCTION defining_designator parameter_and_result_profile - ; + : FUNCTION defining_designator parameter_and_result_profile + ; designator - : (name DOT)? identifier - | operator_symbol - ; + : (name DOT)? identifier + | operator_symbol + ; defining_designator - : defining_program_unit_name - | defining_operator_symbol - ; + : defining_program_unit_name + | defining_operator_symbol + ; defining_program_unit_name - : (name DOT)? defining_identifier - ; + : (name DOT)? defining_identifier + ; operator_symbol - : string_literal - ; + : string_literal + ; defining_operator_symbol - : operator_symbol - ; + : operator_symbol + ; parameter_and_result_profile - : formal_part? RETURN null_exclusion? subtype_mark - | formal_part? RETURN access_definition - ; + : formal_part? RETURN null_exclusion? subtype_mark + | formal_part? RETURN access_definition + ; formal_part - : '(' parameter_specification (SEMI parameter_specification)* ')' - ; + : '(' parameter_specification (SEMI parameter_specification)* ')' + ; parameter_specification - : defining_identifier_list COLON ALIASED? mode_ null_exclusion? subtype_mark (ASSIGN default_expression)? - | defining_identifier_list COLON access_definition (ASSIGN default_expression)? - ; + : defining_identifier_list COLON ALIASED? mode_ null_exclusion? subtype_mark ( + ASSIGN default_expression + )? + | defining_identifier_list COLON access_definition (ASSIGN default_expression)? + ; mode_ - : IN? OUT? - ; + : IN? OUT? + ; subprogram_body - : overriding_indicator? subprogram_specification aspect_specification? IS declarative_part BEGIN handled_sequence_of_statements END designator? SEMI - ; + : overriding_indicator? subprogram_specification aspect_specification? IS declarative_part BEGIN handled_sequence_of_statements END designator? + SEMI + ; procedure_call_statement - : name - | name actual_parameter_part SEMI - ; + : name + | name actual_parameter_part SEMI + ; actual_parameter_part - : '(' parameter_association (',' parameter_association)* ')' - ; + : '(' parameter_association (',' parameter_association)* ')' + ; parameter_association - : (selector_name ARROW)? explicit_actual_parameter - ; + : (selector_name ARROW)? explicit_actual_parameter + ; explicit_actual_parameter - : expression - | name - ; + : expression + | name + ; simple_return_statement - : RETURN expression? SEMI - ; + : RETURN expression? SEMI + ; extended_return_object_declaration - : defining_identifier COLON ALIASED? CONSTANT? return_subtype_indication (ASSIGN expression)? - ; + : defining_identifier COLON ALIASED? CONSTANT? return_subtype_indication (ASSIGN expression)? + ; extended_return_statement - : RETURN extended_return_object_declaration (DO handled_sequence_of_statements END RETURN)? SEMI - ; + : RETURN extended_return_object_declaration (DO handled_sequence_of_statements END RETURN)? SEMI + ; return_subtype_indication - : subtype_indication - | access_definition - ; + : subtype_indication + | access_definition + ; null_procedure_declaration - : overriding_indicator? procedure_specification IS NULL_ aspect_specification? SEMI - ; + : overriding_indicator? procedure_specification IS NULL_ aspect_specification? SEMI + ; expression_function_declaration - : overriding_indicator? function_specification IS '(' expression ')' aspect_specification? SEMI - ; + : overriding_indicator? function_specification IS '(' expression ')' aspect_specification? SEMI + ; + /* 7 - Packages */ - package_declaration - : package_specification SEMI - ; + : package_specification SEMI + ; package_specification - : PACKAGE defining_program_unit_name aspect_specification? IS basic_declarative_item* (PRIVATE basic_declarative_item*)? END ((name DOT)? identifier)? - ; + : PACKAGE defining_program_unit_name aspect_specification? IS basic_declarative_item* ( + PRIVATE basic_declarative_item* + )? END ((name DOT)? identifier)? + ; package_body - : PACKAGE BODY_ defining_program_unit_name aspect_specification? IS declarative_part (BEGIN handled_sequence_of_statements)? END ((name DOT)? identifier)? SEMI - ; + : PACKAGE BODY_ defining_program_unit_name aspect_specification? IS declarative_part ( + BEGIN handled_sequence_of_statements + )? END ((name DOT)? identifier)? SEMI + ; private_type_declaration - : TYPE defining_identifier discriminant_part? IS (ABSTRACT? TAGGED)? LIMITED? PRIVATE aspect_specification? SEMI - ; + : TYPE defining_identifier discriminant_part? IS (ABSTRACT? TAGGED)? LIMITED? PRIVATE aspect_specification? SEMI + ; private_extension_declaration - : TYPE defining_identifier discriminant_part? IS ABSTRACT? (LIMITED | SYNCHRONIZED) NEW subtype_indication (AND interface_list)? WITH PRIVATE aspect_specification? SEMI - ; + : TYPE defining_identifier discriminant_part? IS ABSTRACT? (LIMITED | SYNCHRONIZED) NEW subtype_indication ( + AND interface_list + )? WITH PRIVATE aspect_specification? SEMI + ; + /* 8 - Visibility Rules */ - overriding_indicator - : NOT? OVERRIDING - ; + : NOT? OVERRIDING + ; use_clause - : use_package_clause - | use_type_clause - ; + : use_package_clause + | use_type_clause + ; use_package_clause - : USE name (',' name)* SEMI - ; + : USE name (',' name)* SEMI + ; use_type_clause - : USE ALL? TYPE subtype_mark (',' subtype_mark)* SEMI - ; + : USE ALL? TYPE subtype_mark (',' subtype_mark)* SEMI + ; renaming_declaration - : object_renaming_declaration - | exception_renaming_declaration - | package_renaming_declaration - | subprogram_renaming_declaration - | generic_renaming_declaration - ; + : object_renaming_declaration + | exception_renaming_declaration + | package_renaming_declaration + | subprogram_renaming_declaration + | generic_renaming_declaration + ; object_renaming_declaration - : defining_identifier COLON null_exclusion? subtype_mark RENAMES name aspect_specification? SEMI - | defining_identifier COLON access_definition RENAMES name aspect_specification? SEMI - ; + : defining_identifier COLON null_exclusion? subtype_mark RENAMES name aspect_specification? SEMI + | defining_identifier COLON access_definition RENAMES name aspect_specification? SEMI + ; exception_renaming_declaration - : defining_identifier COLON EXCEPTION RENAMES name aspect_specification? SEMI - ; + : defining_identifier COLON EXCEPTION RENAMES name aspect_specification? SEMI + ; package_renaming_declaration - : PACKAGE defining_program_unit_name RENAMES name aspect_specification? SEMI - ; + : PACKAGE defining_program_unit_name RENAMES name aspect_specification? SEMI + ; subprogram_renaming_declaration - : overriding_indicator? subprogram_specification RENAMES name aspect_specification? SEMI - ; + : overriding_indicator? subprogram_specification RENAMES name aspect_specification? SEMI + ; generic_renaming_declaration - : GENERIC PACKAGE defining_program_unit_name RENAMES name aspect_specification? SEMI - | GENERIC PROCEDURE defining_program_unit_name RENAMES name aspect_specification? SEMI - | GENERIC FUNCTION defining_program_unit_name RENAMES name aspect_specification? SEMI - ; + : GENERIC PACKAGE defining_program_unit_name RENAMES name aspect_specification? SEMI + | GENERIC PROCEDURE defining_program_unit_name RENAMES name aspect_specification? SEMI + | GENERIC FUNCTION defining_program_unit_name RENAMES name aspect_specification? SEMI + ; + /* 9 - Tasks and Synchronization */ - task_type_declaration - : TASK TYPE defining_identifier known_discriminant_part? aspect_specification? (IS (NEW interface_list WITH)? task_definition)? SEMI - ; + : TASK TYPE defining_identifier known_discriminant_part? aspect_specification? ( + IS (NEW interface_list WITH)? task_definition + )? SEMI + ; single_task_declaration - : TASK defining_identifier aspect_specification? (IS (NEW interface_list WITH)? task_definition)? SEMI - ; + : TASK defining_identifier aspect_specification? ( + IS (NEW interface_list WITH)? task_definition + )? SEMI + ; task_definition - : task_item* (PRIVATE task_item*)? END identifier? - ; + : task_item* (PRIVATE task_item*)? END identifier? + ; task_item - : entry_declaration - | aspect_clause - ; + : entry_declaration + | aspect_clause + ; task_body - : TASK BODY_ defining_identifier aspect_specification? IS declarative_part BEGIN handled_sequence_of_statements END identifier? SEMI - ; + : TASK BODY_ defining_identifier aspect_specification? IS declarative_part BEGIN handled_sequence_of_statements END identifier? SEMI + ; protected_type_declaration - : PROTECTED TYPE defining_identifier known_discriminant_part? aspect_specification? IS (NEW interface_list WITH)? protected_definition SEMI - ; + : PROTECTED TYPE defining_identifier known_discriminant_part? aspect_specification? IS ( + NEW interface_list WITH + )? protected_definition SEMI + ; single_protected_declaration - : PROTECTED defining_identifier aspect_specification? IS (NEW interface_list WITH)? protected_definition SEMI - ; + : PROTECTED defining_identifier aspect_specification? IS (NEW interface_list WITH)? protected_definition SEMI + ; protected_definition - : protected_operation_declaration* (PRIVATE protected_element_declaration*)? END identifier? - ; + : protected_operation_declaration* (PRIVATE protected_element_declaration*)? END identifier? + ; protected_operation_declaration - : subprogram_declaration - | entry_declaration - | aspect_clause - ; + : subprogram_declaration + | entry_declaration + | aspect_clause + ; protected_element_declaration - : protected_operation_declaration - | component_declaration - ; + : protected_operation_declaration + | component_declaration + ; protected_body - : PROTECTED BODY_ defining_identifier aspect_specification? IS protected_operation_item* END identifier? SEMI - ; + : PROTECTED BODY_ defining_identifier aspect_specification? IS protected_operation_item* END identifier? SEMI + ; protected_operation_item - : subprogram_declaration - | subprogram_body - | entry_body - | aspect_clause - ; + : subprogram_declaration + | subprogram_body + | entry_body + | aspect_clause + ; entry_declaration - : overriding_indicator? ENTRY defining_identifier ('(' discrete_subtype_definition ')')? formal_part? //parameter_profile - aspect_specification? SEMI - ; + : overriding_indicator? ENTRY defining_identifier ('(' discrete_subtype_definition ')')? formal_part? //parameter_profile + aspect_specification? SEMI + ; accept_statement - : ACCEPT_ entry_direct_name ('(' entry_index ')')? formal_part? /*parameter_profile*/ - - (DO handled_sequence_of_statements END entry_identifier?)? SEMI - ; + : ACCEPT_ entry_direct_name ('(' entry_index ')')? formal_part? /*parameter_profile*/ ( + DO handled_sequence_of_statements END entry_identifier? + )? SEMI + ; entry_direct_name - : direct_name - ; + : direct_name + ; entry_index - : expression - ; + : expression + ; entry_body - : ENTRY defining_identifier entry_body_formal_part entry_barrier IS declarative_part BEGIN handled_sequence_of_statements END entry_identifier? SEMI - ; + : ENTRY defining_identifier entry_body_formal_part entry_barrier IS declarative_part BEGIN handled_sequence_of_statements END entry_identifier? + SEMI + ; entry_identifier - : identifier - ; + : identifier + ; entry_body_formal_part - : ('(' entry_index_specification ')')? formal_part? //parameter_profile - - ; + : ('(' entry_index_specification ')')? formal_part? //parameter_profile + ; entry_barrier - : WHEN condition - ; + : WHEN condition + ; entry_index_specification - : FOR defining_identifier IN discrete_subtype_definition - ; + : FOR defining_identifier IN discrete_subtype_definition + ; entry_call_statement - : name actual_parameter_part? SEMI - ; + : name actual_parameter_part? SEMI + ; requeue_statement - : REQUEUE name (WITH ABORT)? SEMI - ; + : REQUEUE name (WITH ABORT)? SEMI + ; delay_statement - : delay_until_statement - | delay_relative_statement - ; + : delay_until_statement + | delay_relative_statement + ; delay_until_statement - : DELAY UNTIL delay_expression - ; + : DELAY UNTIL delay_expression + ; delay_relative_statement - : DELAY delay_expression - ; + : DELAY delay_expression + ; delay_expression - : expression - ; + : expression + ; select_statement - : selective_accept - | timed_entry_call - | conditional_entry_call - | asynchronous_select - ; + : selective_accept + | timed_entry_call + | conditional_entry_call + | asynchronous_select + ; selective_accept - : SELECT guard? select_alternative (OR guard? select_alternative)* (ELSE sequence_of_statements)? END SELECT SEMI - ; + : SELECT guard? select_alternative (OR guard? select_alternative)* ( + ELSE sequence_of_statements + )? END SELECT SEMI + ; guard - : WHEN condition ARROW - ; + : WHEN condition ARROW + ; select_alternative - : accept_alternative - | delay_alternative - | terminate_alternative - ; + : accept_alternative + | delay_alternative + | terminate_alternative + ; accept_alternative - : accept_statement sequence_of_statements? - ; + : accept_statement sequence_of_statements? + ; delay_alternative - : delay_statement sequence_of_statements? - ; + : delay_statement sequence_of_statements? + ; terminate_alternative - : TERMINATE SEMI - ; + : TERMINATE SEMI + ; timed_entry_call - : SELECT entry_call_alternative OR delay_alternative END SELECT SEMI - ; + : SELECT entry_call_alternative OR delay_alternative END SELECT SEMI + ; entry_call_alternative - : procedure_or_entry_call sequence_of_statements? - ; + : procedure_or_entry_call sequence_of_statements? + ; procedure_or_entry_call - : procedure_call_statement - | entry_call_statement - ; + : procedure_call_statement + | entry_call_statement + ; conditional_entry_call - : SELECT entry_call_alternative ELSE sequence_of_statements END SELECT SEMI - ; + : SELECT entry_call_alternative ELSE sequence_of_statements END SELECT SEMI + ; asynchronous_select - : SELECT triggering_alternative THEN ABORT abortable_part END SELECT SEMI - ; + : SELECT triggering_alternative THEN ABORT abortable_part END SELECT SEMI + ; triggering_alternative - : triggering_statement sequence_of_statements? - ; + : triggering_statement sequence_of_statements? + ; triggering_statement - : procedure_or_entry_call - | delay_statement - ; + : procedure_or_entry_call + | delay_statement + ; abortable_part - : sequence_of_statements - ; + : sequence_of_statements + ; abort_statement - : ABORT name (',' name)* - ; + : ABORT name (',' name)* + ; + /* 10 - Program Structure and Compilation Issues */ - compilation - : compilation_unit* EOF - ; + : compilation_unit* EOF + ; compilation_unit - : context_item* (library_item | subunit) - ; + : context_item* (library_item | subunit) + ; library_item - : PRIVATE? library_unit_declaration - | library_unit_body - | PRIVATE? library_unit_renaming_declaration - ; + : PRIVATE? library_unit_declaration + | library_unit_body + | PRIVATE? library_unit_renaming_declaration + ; library_unit_declaration - : subprogram_declaration - | package_declaration - | generic_declaration - | generic_instantiation - ; + : subprogram_declaration + | package_declaration + | generic_declaration + | generic_instantiation + ; library_unit_renaming_declaration - : package_renaming_declaration - | generic_renaming_declaration - | subprogram_renaming_declaration - ; + : package_renaming_declaration + | generic_renaming_declaration + | subprogram_renaming_declaration + ; library_unit_body - : subprogram_body - | package_body - ; + : subprogram_body + | package_body + ; context_item - : with_clause - | use_clause - ; + : with_clause + | use_clause + ; with_clause - : limited_with_clause - | nonlimited_with_clause - ; + : limited_with_clause + | nonlimited_with_clause + ; limited_with_clause - : LIMITED PRIVATE? WITH name (',' name)* SEMI - ; + : LIMITED PRIVATE? WITH name (',' name)* SEMI + ; nonlimited_with_clause - : PRIVATE? WITH name (',' name)* SEMI - ; + : PRIVATE? WITH name (',' name)* SEMI + ; body_stub - : subprogram_body_stub - | package_body_stub - | task_body_stub - | protected_body_stub - ; + : subprogram_body_stub + | package_body_stub + | task_body_stub + | protected_body_stub + ; subprogram_body_stub - : overriding_indicator? subprogram_specification IS SEPARATE aspect_specification? SEMI - ; + : overriding_indicator? subprogram_specification IS SEPARATE aspect_specification? SEMI + ; package_body_stub - : PACKAGE BODY_ defining_identifier IS SEPARATE aspect_specification? SEMI - ; + : PACKAGE BODY_ defining_identifier IS SEPARATE aspect_specification? SEMI + ; task_body_stub - : TASK BODY_ defining_identifier IS SEPARATE aspect_specification? SEMI - ; + : TASK BODY_ defining_identifier IS SEPARATE aspect_specification? SEMI + ; protected_body_stub - : PROTECTED BODY_ defining_identifier IS SEPARATE aspect_specification? SEMI - ; + : PROTECTED BODY_ defining_identifier IS SEPARATE aspect_specification? SEMI + ; subunit - : SEPARATE '(' name ')' proper_body - ; + : SEPARATE '(' name ')' proper_body + ; + /* 11 - Exceptions */ - exception_declaration - : defining_identifier_list COLON EXCEPTION aspect_specification? SEMI - ; + : defining_identifier_list COLON EXCEPTION aspect_specification? SEMI + ; handled_sequence_of_statements - : sequence_of_statements (EXCEPTION exception_handler+)? - ; + : sequence_of_statements (EXCEPTION exception_handler+)? + ; exception_handler - : WHEN (choice_parameter_specification COLON)? exception_choice (VL exception_choice)* ARROW sequence_of_statements - ; + : WHEN (choice_parameter_specification COLON)? exception_choice (VL exception_choice)* ARROW sequence_of_statements + ; choice_parameter_specification - : defining_identifier - ; + : defining_identifier + ; exception_choice - : name - | OTHERS - ; + : name + | OTHERS + ; raise_statement - : RAISE SEMI - | RAISE name (WITH expression)? SEMI - ; + : RAISE SEMI + | RAISE name (WITH expression)? SEMI + ; + /* 12 - Generic Units */ - generic_declaration - : generic_subprogram_declaration - | generic_package_declaration - ; + : generic_subprogram_declaration + | generic_package_declaration + ; generic_subprogram_declaration - : generic_formal_part subprogram_specification aspect_specification? SEMI - ; + : generic_formal_part subprogram_specification aspect_specification? SEMI + ; generic_package_declaration - : generic_formal_part package_specification SEMI - ; + : generic_formal_part package_specification SEMI + ; generic_formal_part - : GENERIC (generic_formal_parameter_declaration | use_clause)* - ; + : GENERIC (generic_formal_parameter_declaration | use_clause)* + ; generic_formal_parameter_declaration - : formal_object_declaration - | formal_type_declaration - | formal_subprogram_declaration - | formal_package_declaration - ; + : formal_object_declaration + | formal_type_declaration + | formal_subprogram_declaration + | formal_package_declaration + ; generic_instantiation - : PACKAGE defining_program_unit_name IS NEW name generic_actual_part? aspect_specification? - | overriding_indicator? PROCEDURE defining_program_unit_name IS NEW name generic_actual_part? aspect_specification? - | overriding_indicator? FUNCTION defining_designator IS NEW name generic_actual_part? aspect_specification? - ; + : PACKAGE defining_program_unit_name IS NEW name generic_actual_part? aspect_specification? + | overriding_indicator? PROCEDURE defining_program_unit_name IS NEW name generic_actual_part? aspect_specification? + | overriding_indicator? FUNCTION defining_designator IS NEW name generic_actual_part? aspect_specification? + ; generic_actual_part - : '(' generic_association (',' generic_association)* ')' - ; + : '(' generic_association (',' generic_association)* ')' + ; generic_association - : (selector_name ARROW)? explicit_generic_actual_parameter - ; + : (selector_name ARROW)? explicit_generic_actual_parameter + ; explicit_generic_actual_parameter - : expression - | name - | subtype_mark - ; + : expression + | name + | subtype_mark + ; formal_object_declaration - : defining_identifier_list COLON mode_ null_exclusion? subtype_mark (ASSIGN default_expression)? aspect_specification? SEMI - | defining_identifier_list COLON mode_ access_definition (ASSIGN default_expression)? aspect_specification? - ; + : defining_identifier_list COLON mode_ null_exclusion? subtype_mark (ASSIGN default_expression)? aspect_specification? SEMI + | defining_identifier_list COLON mode_ access_definition (ASSIGN default_expression)? aspect_specification? + ; formal_type_declaration - : formal_complete_type_declaration - | formal_incomplete_type_declaration - ; + : formal_complete_type_declaration + | formal_incomplete_type_declaration + ; formal_complete_type_declaration - : TYPE defining_identifier discriminant_part? IS formal_type_definition aspect_specification? SEMI - ; + : TYPE defining_identifier discriminant_part? IS formal_type_definition aspect_specification? SEMI + ; formal_incomplete_type_declaration - : TYPE defining_identifier discriminant_part? (IS TAGGED)? SEMI - ; + : TYPE defining_identifier discriminant_part? (IS TAGGED)? SEMI + ; formal_type_definition - : formal_private_type_definition - | formal_derived_type_definition - | formal_discrete_type_definition - | formal_signed_integer_type_definition - | formal_modular_type_definition - | formal_floating_point_type_definition - | formal_ordinary_fixed_point_type_definition - | formal_decimal_fixed_point_type_definition - | formal_array_type_definition - | formal_access_type_definition - | formal_interface_type_definition - ; + : formal_private_type_definition + | formal_derived_type_definition + | formal_discrete_type_definition + | formal_signed_integer_type_definition + | formal_modular_type_definition + | formal_floating_point_type_definition + | formal_ordinary_fixed_point_type_definition + | formal_decimal_fixed_point_type_definition + | formal_array_type_definition + | formal_access_type_definition + | formal_interface_type_definition + ; formal_private_type_definition - : (ABSTRACT? TAGGED)? LIMITED? PRIVATE - ; + : (ABSTRACT? TAGGED)? LIMITED? PRIVATE + ; formal_derived_type_definition - : ABSTRACT? LIMITED? SYNCHRONIZED NEW subtype_mark ((AND interface_list)? WITH PRIVATE)? - ; + : ABSTRACT? LIMITED? SYNCHRONIZED NEW subtype_mark ((AND interface_list)? WITH PRIVATE)? + ; formal_discrete_type_definition - : '(' BOX ')' - ; + : '(' BOX ')' + ; formal_signed_integer_type_definition - : range BOX - ; + : range BOX + ; formal_modular_type_definition - : MOD BOX - ; + : MOD BOX + ; formal_floating_point_type_definition - : DIGITS BOX - ; + : DIGITS BOX + ; formal_ordinary_fixed_point_type_definition - : DELTA BOX - ; + : DELTA BOX + ; formal_decimal_fixed_point_type_definition - : DELTA BOX DIGITS BOX - ; + : DELTA BOX DIGITS BOX + ; formal_array_type_definition - : array_type_definition - ; + : array_type_definition + ; formal_access_type_definition - : access_type_definition - ; + : access_type_definition + ; formal_interface_type_definition - : interface_type_definition - ; + : interface_type_definition + ; formal_subprogram_declaration - : formal_concrete_subprogram_declaration - | formal_abstract_subprogram_declaration - ; + : formal_concrete_subprogram_declaration + | formal_abstract_subprogram_declaration + ; formal_concrete_subprogram_declaration - : WITH subprogram_specification (IS subprogram_default)? aspect_specification? SEMI - ; + : WITH subprogram_specification (IS subprogram_default)? aspect_specification? SEMI + ; formal_abstract_subprogram_declaration - : WITH subprogram_specification IS ABSTRACT subprogram_default? aspect_specification? SEMI - ; + : WITH subprogram_specification IS ABSTRACT subprogram_default? aspect_specification? SEMI + ; subprogram_default - : name - | BOX - | NULL_ - ; + : name + | BOX + | NULL_ + ; formal_package_declaration - : WITH PACKAGE defining_identifier IS NEW name formal_package_actual_part aspect_specification? SEMI - ; + : WITH PACKAGE defining_identifier IS NEW name formal_package_actual_part aspect_specification? SEMI + ; formal_package_actual_part - : '(' (OTHERS ARROW)? BOX ')' - | generic_actual_part? - | '(' formal_package_association (',' formal_package_association)* (',' OTHERS ARROW BOX)? ')' - ; + : '(' (OTHERS ARROW)? BOX ')' + | generic_actual_part? + | '(' formal_package_association (',' formal_package_association)* (',' OTHERS ARROW BOX)? ')' + ; formal_package_association - : generic_association - | selector_name ARROW BOX - ; + : generic_association + | selector_name ARROW BOX + ; + /* 13 - Representation Issues */ - aspect_clause - : attribute_definition_clause - | enumeration_representation_clause - | record_representation_clause - | at_clause - ; + : attribute_definition_clause + | enumeration_representation_clause + | record_representation_clause + | at_clause + ; local_name - : direct_name - | direct_name SQ attribute_designator - | name - ; + : direct_name + | direct_name SQ attribute_designator + | name + ; aspect_specification - : WITH aspect_mark (ARROW aspect_definition)? (',' aspect_mark (ARROW aspect_definition)?)* - ; + : WITH aspect_mark (ARROW aspect_definition)? (',' aspect_mark (ARROW aspect_definition)?)* + ; aspect_mark - : aspect_identifier (SQ CLASS__)? //TODO Class or id_ - - ; + : aspect_identifier (SQ CLASS__)? //TODO Class or id_ + ; aspect_identifier - : identifier - ; + : identifier + ; aspect_definition - : name - | expression - | identifier - ; + : name + | expression + | identifier + ; attribute_definition_clause - : FOR local_name SQ attribute_designator USE expression SEMI - | FOR local_name SQ attribute_designator USE name SEMI - ; + : FOR local_name SQ attribute_designator USE expression SEMI + | FOR local_name SQ attribute_designator USE name SEMI + ; enumeration_representation_clause - : FOR local_name USE enumeration_aggregate SEMI - ; + : FOR local_name USE enumeration_aggregate SEMI + ; enumeration_aggregate - : array_aggregate - ; + : array_aggregate + ; record_representation_clause - : FOR local_name USE RECORD mod_clause? component_clause* END RECORD? - ; + : FOR local_name USE RECORD mod_clause? component_clause* END RECORD? + ; component_clause - : component_local_name AT position RANGE_ first_bit DOTDOT last_bit SEMI - ; + : component_local_name AT position RANGE_ first_bit DOTDOT last_bit SEMI + ; component_local_name - : local_name - ; + : local_name + ; position - : expression - ; + : expression + ; first_bit - : expression - ; + : expression + ; last_bit - : expression - ; + : expression + ; + /* J.* */ - delta_constraint - : DELTA expression range_constraint? - ; + : DELTA expression range_constraint? + ; at_clause - : FOR direct_name USE AT expression SEMI - ; + : FOR direct_name USE AT expression SEMI + ; mod_clause - : AT MOD expression SEMI - ; + : AT MOD expression SEMI + ; \ No newline at end of file diff --git a/ada/ada83/Ada83Lexer.g4 b/ada/ada83/Ada83Lexer.g4 index 44c31d5638..d750bd0661 100644 --- a/ada/ada83/Ada83Lexer.g4 +++ b/ada/ada83/Ada83Lexer.g4 @@ -21,138 +21,144 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Ada83Lexer; -options { caseInsensitive = true; } - -ABORT : 'abort'; -ABS : 'abs'; -ACCEPT_ : 'accept'; -ACCESS : 'access'; -ALL : 'all'; -AND : 'and'; -ARRAY : 'array'; -AT : 'at'; - -BEGIN : 'begin'; -BODY_ : 'body'; - -CASE : 'case'; -CONSTANT : 'constant'; - -DECLARE : 'declare'; -DELAY : 'delay'; -DELTA : 'delta'; -DIGITS : 'digits'; -DO : 'do'; - -ELSE : 'else'; -ELSIF : 'elsif'; -END : 'end'; -ENTRY : 'entry'; -EXCEPTION_ : 'exception'; -EXIT : 'exit'; - -FOR : 'for'; -FUNCTION : 'function'; - -GENERIC : 'generic'; -GOTO : 'goto'; - -IF : 'if'; -IN : 'in'; -IS : 'is'; - -LIMITED : 'limited'; -LOOP : 'loop'; - -MOD : 'mod'; - -NEW : 'new'; -NOT : 'not'; -NULL_ : 'null'; - -OF : 'of'; -OR : 'or'; -OTHERS : 'others'; -OUT : 'out'; - -PACKAGE : 'package'; -PRAGMA : 'pragma'; -PRIVATE : 'private'; -PROCEDURE : 'procedure'; - -RAISE : 'raise'; -RANGE_ : 'range'; -RECORD : 'record'; -REM : 'rem'; -RENAMES : 'renames'; -RETURN : 'return'; -REVERSE : 'reverse'; - -SELECT : 'select'; -SEPARATE : 'separate'; -SUBTYPE : 'subtype'; - -TASK : 'task'; -TERMINATE : 'terminate'; -THEN : 'then'; -TYPE : 'type'; - -USE : 'use'; - -WHEN : 'when'; -WHILE : 'while'; -WITH : 'with'; - -XOR : 'xor'; - -WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); -LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); - -IDENTIFIER_ : LETTER+ [A-Z_0-9]*; -NUMERIC_LITERAL_ : DECIMAL_LITERAL | BASED_LITERAL; -DECIMAL_LITERAL : NUMERAL ('.' NUMERAL)? EXPONENT?; -NUMERAL : DIGIT+ ('_'? DIGIT)*; -EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; -BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; -BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; -EXTENDED_DIGIT : DIGIT | [A-F]; -BASE : NUMERAL; - -CHARACTER_LITERAL_: '\'' ~['\\\r\n] '\''; -STRING_LITERAL_ : '"' ('""' | ~'"')* '"'; - -fragment LETTER : [A-Z]; -fragment DIGIT : [0-9]; - -HASH : '#'; -AMPERSAND : '&'; -LP : '('; -RP : ')'; -MULT : '*'; -PLUS : '+'; -COMMA : ','; -MINUS : '-'; -DOT : '.'; -COLON : ':'; -SEMI : ';'; -LT : '<'; -EQ : '='; -GT : '>'; -US : '_'; -VL : '|'; -DIV : '/'; -EP : '!'; -PS : '%'; -ARROW : '=>'; -DOTDOT : '..'; -EXPON : '**'; -ASSIGN : ':='; -NE : '/='; -GE : '>='; -LE : '<='; -LLB : '<<'; -RLB : '>>'; -BOX : '<>'; -SQ : '\''; +options { + caseInsensitive = true; +} + +ABORT : 'abort'; +ABS : 'abs'; +ACCEPT_ : 'accept'; +ACCESS : 'access'; +ALL : 'all'; +AND : 'and'; +ARRAY : 'array'; +AT : 'at'; + +BEGIN : 'begin'; +BODY_ : 'body'; + +CASE : 'case'; +CONSTANT : 'constant'; + +DECLARE : 'declare'; +DELAY : 'delay'; +DELTA : 'delta'; +DIGITS : 'digits'; +DO : 'do'; + +ELSE : 'else'; +ELSIF : 'elsif'; +END : 'end'; +ENTRY : 'entry'; +EXCEPTION_ : 'exception'; +EXIT : 'exit'; + +FOR : 'for'; +FUNCTION : 'function'; + +GENERIC : 'generic'; +GOTO : 'goto'; + +IF : 'if'; +IN : 'in'; +IS : 'is'; + +LIMITED : 'limited'; +LOOP : 'loop'; + +MOD: 'mod'; + +NEW : 'new'; +NOT : 'not'; +NULL_ : 'null'; + +OF : 'of'; +OR : 'or'; +OTHERS : 'others'; +OUT : 'out'; + +PACKAGE : 'package'; +PRAGMA : 'pragma'; +PRIVATE : 'private'; +PROCEDURE : 'procedure'; + +RAISE : 'raise'; +RANGE_ : 'range'; +RECORD : 'record'; +REM : 'rem'; +RENAMES : 'renames'; +RETURN : 'return'; +REVERSE : 'reverse'; + +SELECT : 'select'; +SEPARATE : 'separate'; +SUBTYPE : 'subtype'; + +TASK : 'task'; +TERMINATE : 'terminate'; +THEN : 'then'; +TYPE : 'type'; + +USE: 'use'; + +WHEN : 'when'; +WHILE : 'while'; +WITH : 'with'; + +XOR: 'xor'; + +WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); + +IDENTIFIER_ : LETTER+ [A-Z_0-9]*; +NUMERIC_LITERAL_ : DECIMAL_LITERAL | BASED_LITERAL; +DECIMAL_LITERAL : NUMERAL ('.' NUMERAL)? EXPONENT?; +NUMERAL : DIGIT+ ('_'? DIGIT)*; +EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; +BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; +BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; +EXTENDED_DIGIT : DIGIT | [A-F]; +BASE : NUMERAL; + +CHARACTER_LITERAL_ : '\'' ~['\\\r\n] '\''; +STRING_LITERAL_ : '"' ('""' | ~'"')* '"'; + +fragment LETTER : [A-Z]; +fragment DIGIT : [0-9]; + +HASH : '#'; +AMPERSAND : '&'; +LP : '('; +RP : ')'; +MULT : '*'; +PLUS : '+'; +COMMA : ','; +MINUS : '-'; +DOT : '.'; +COLON : ':'; +SEMI : ';'; +LT : '<'; +EQ : '='; +GT : '>'; +US : '_'; +VL : '|'; +DIV : '/'; +EP : '!'; +PS : '%'; +ARROW : '=>'; +DOTDOT : '..'; +EXPON : '**'; +ASSIGN : ':='; +NE : '/='; +GE : '>='; +LE : '<='; +LLB : '<<'; +RLB : '>>'; +BOX : '<>'; +SQ : '\''; \ No newline at end of file diff --git a/ada/ada83/Ada83Parser.g4 b/ada/ada83/Ada83Parser.g4 index 8cc43f10ec..de13078bdb 100644 --- a/ada/ada83/Ada83Parser.g4 +++ b/ada/ada83/Ada83Parser.g4 @@ -20,842 +20,855 @@ 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. */ + +// $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 Ada83Parser; +options { + tokenVocab = Ada83Lexer; +} -options { tokenVocab = Ada83Lexer; } /* 2 - Lexical Elements */ - identifier - : IDENTIFIER_ - ; + : IDENTIFIER_ + ; numeric_literal - : NUMERIC_LITERAL_ - ; + : NUMERIC_LITERAL_ + ; character_literal - : CHARACTER_LITERAL_ - ; + : CHARACTER_LITERAL_ + ; string_literal - : STRING_LITERAL_ - ; + : STRING_LITERAL_ + ; + /* 3 - Declarations and Types */ - - + basic_declaration - : object_declaration - | number_declaration - | type_declaration - | subtype_declaration - | subprogram_declaration - | package_declaration - | task_declaration - | generic_declaration - | exception_declaration - | generic_instantiation - | renaming_declaration - | deferred_constant_declaration - ; + : object_declaration + | number_declaration + | type_declaration + | subtype_declaration + | subprogram_declaration + | package_declaration + | task_declaration + | generic_declaration + | exception_declaration + | generic_instantiation + | renaming_declaration + | deferred_constant_declaration + ; object_declaration - : identifier_list ':' CONSTANT? subtype_indication (':=' expression)? ';' - | identifier_list ':' CONSTANT? constrained_array_definition (':=' expression)? ';' - ; + : identifier_list ':' CONSTANT? subtype_indication (':=' expression)? ';' + | identifier_list ':' CONSTANT? constrained_array_definition (':=' expression)? ';' + ; number_declaration - : identifier_list ':' CONSTANT ':=' universal_static = expression ';' - ; + : identifier_list ':' CONSTANT ':=' universal_static = expression ';' + ; type_declaration - : full_type_declaration - | incomplete_type_declaration - | private_type_declaration - ; + : full_type_declaration + | incomplete_type_declaration + | private_type_declaration + ; full_type_declaration - : TYPE identifier discriminant_part? IS type_definition ';' - ; + : TYPE identifier discriminant_part? IS type_definition ';' + ; type_definition - : enumeration_type_definition - | integer_type_definition - | real_type_definition - | array_type_definition - | record_type_definition - | access_type_definition - | derived_type_definition - ; + : enumeration_type_definition + | integer_type_definition + | real_type_definition + | array_type_definition + | record_type_definition + | access_type_definition + | derived_type_definition + ; subtype_declaration - : SUBTYPE identifier IS subtype_indication ';' - ; + : SUBTYPE identifier IS subtype_indication ';' + ; subtype_indication - : type_mark = name constraint? - ; + : type_mark = name constraint? + ; constraint - : range_constraint - | floating_point_constraint - | fixed_point_constraint - | index_constraint - | discriminant_constraint - ; + : range_constraint + | floating_point_constraint + | fixed_point_constraint + | index_constraint + | discriminant_constraint + ; derived_type_definition - : NEW subtype_indication - ; + : NEW subtype_indication + ; identifier_list - : identifier (',' identifier)* - ; + : identifier (',' identifier)* + ; range_constraint - : range range - ; + : range range + ; range - : prefix = name SQ attribute_designator // range_attribute - | simple_expression '..' simple_expression - ; + : prefix = name SQ attribute_designator // range_attribute + | simple_expression '..' simple_expression + ; enumeration_type_definition - : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' - ; + : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' + ; enumeration_literal_specification - : enumeration_literal - ; + : enumeration_literal + ; enumeration_literal - : identifier - | character_literal - ; + : identifier + | character_literal + ; integer_type_definition - : range_constraint - ; + : range_constraint + ; real_type_definition - : floating_point_constraint - | fixed_point_constraint - ; + : floating_point_constraint + | fixed_point_constraint + ; floating_point_constraint - : floating_accuracy_definition range_constraint? - ; + : floating_accuracy_definition range_constraint? + ; floating_accuracy_definition - : DIGITS static_simple = expression - ; + : DIGITS static_simple = expression + ; fixed_point_constraint - : fixed_accuracy_definition range_constraint? - ; + : fixed_accuracy_definition range_constraint? + ; fixed_accuracy_definition - : DELTA static_simple = expression - ; + : DELTA static_simple = expression + ; array_type_definition - : unconstrained_array_definition - | constrained_array_definition - ; + : unconstrained_array_definition + | constrained_array_definition + ; unconstrained_array_definition - : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF subtype_indication - ; + : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF subtype_indication + ; constrained_array_definition - : ARRAY index_constraint OF subtype_indication - ; + : ARRAY index_constraint OF subtype_indication + ; index_subtype_definition - : type_mark = name range '<>' - ; + : type_mark = name range '<>' + ; index_constraint - : '(' discrete_range (',' discrete_range)* ')' - ; + : '(' discrete_range (',' discrete_range)* ')' + ; discrete_range - : subtype_indication - | range - ; + : subtype_indication + | range + ; record_type_definition - : RECORD component_list END RECORD - ; + : RECORD component_list END RECORD + ; component_list - : component_declaration component_declaration* - | component_declaration* variant_part - | NULL_ ';' - ; + : component_declaration component_declaration* + | component_declaration* variant_part + | NULL_ ';' + ; component_declaration - : identifier_list ':' component_subtype_definition (':=' expression)? ';' - ; + : identifier_list ':' component_subtype_definition (':=' expression)? ';' + ; component_subtype_definition - : subtype_indication - ; + : subtype_indication + ; discriminant_part - : '(' discriminant_specification (';' discriminant_specification)* ')' - ; + : '(' discriminant_specification (';' discriminant_specification)* ')' + ; discriminant_specification - : identifier_list ':' type_mark = name (':=' expression)? - ; + : identifier_list ':' type_mark = name (':=' expression)? + ; discriminant_constraint - : '(' discriminant_association (',' discriminant_association)* ')' - ; + : '(' discriminant_association (',' discriminant_association)* ')' + ; discriminant_association - : (discriminant = simple_name ('|' discriminant = simple_name)* '=>')? expression - ; + : (discriminant = simple_name ('|' discriminant = simple_name)* '=>')? expression + ; variant_part - : CASE discriminant = simple_name IS variant variant* END CASE ';' - ; + : CASE discriminant = simple_name IS variant variant* END CASE ';' + ; variant - : WHEN choice ('|' choice)* '=>' component_list - ; + : WHEN choice ('|' choice)* '=>' component_list + ; choice - : simple_expression - | discrete_range - | OTHERS - | component = simple_name - ; + : simple_expression + | discrete_range + | OTHERS + | component = simple_name + ; access_type_definition - : ACCESS subtype_indication - ; + : ACCESS subtype_indication + ; incomplete_type_declaration - : TYPE identifier discriminant_part? ';' - ; + : TYPE identifier discriminant_part? ';' + ; basic_declarative_item - : basic_declaration - | representation_clause - | use_clause - ; + : basic_declaration + | representation_clause + | use_clause + ; later_declarative_item - : body - | subprogram_declaration - | package_declaration - | task_declaration - | generic_declaration - | use_clause - | generic_instantiation - ; + : body + | subprogram_declaration + | package_declaration + | task_declaration + | generic_declaration + | use_clause + | generic_instantiation + ; body - : proper_body - | body_stub - ; + : proper_body + | body_stub + ; proper_body - : subprogram_body - | package_body - | task_body - ; + : subprogram_body + | package_body + | task_body + ; + /* 4 - Names */ - - + name - : simple_name - | character_literal - | operator_symbol - | prefix = name '(' expression (',' expression)* ')' //indexed_component - | prefix = name '(' discrete_range ')' //slice - | prefix = name '.' selector //selected_component - | prefix = name SQ attribute_designator //attribute - | name actual_parameter_part //fn call - - ; + : simple_name + | character_literal + | operator_symbol + | prefix = name '(' expression (',' expression)* ')' //indexed_component + | prefix = name '(' discrete_range ')' //slice + | prefix = name '.' selector //selected_component + | prefix = name SQ attribute_designator //attribute + | name actual_parameter_part //fn call + ; simple_name - : identifier - ; + : identifier + ; selector - : simple_name - | character_literal - | operator_symbol - | ALL - ; + : simple_name + | character_literal + | operator_symbol + | ALL + ; attribute_designator - : simple_name ('(' universal_static = expression ')')? - ; + : simple_name ('(' universal_static = expression ')')? + ; aggregate - : '(' component_association (',' component_association)* ')' - ; + : '(' component_association (',' component_association)* ')' + ; component_association - : (choice ('|' choice)* '=>')? expression - ; + : (choice ('|' choice)* '=>')? expression + ; expression - : relation (AND relation)* - | relation (AND THEN relation)* - | relation (OR relation)* - | relation (OR ELSE relation)* - | relation (XOR relation)* - ; + : relation (AND relation)* + | relation (AND THEN relation)* + | relation (OR relation)* + | relation (OR ELSE relation)* + | relation (XOR relation)* + ; relation - : simple_expression (relational_operator simple_expression)? - | simple_expression NOT? IN range - | simple_expression NOT? IN type_mark = name - ; + : simple_expression (relational_operator simple_expression)? + | simple_expression NOT? IN range + | simple_expression NOT? IN type_mark = name + ; simple_expression - : unary_adding_operator? term (binary_adding_operator term)* - ; + : unary_adding_operator? term (binary_adding_operator term)* + ; term - : factor (multiplying_operator factor)* - ; + : factor (multiplying_operator factor)* + ; factor - : primary ('**' primary)? - | ABS primary - | NOT primary - ; + : primary ('**' primary)? + | ABS primary + | NOT primary + ; primary - : numeric_literal - | NULL_ - | aggregate - | string_literal - | name - | allocator - | function = name actual_parameter_part? //function_call - | type_conversion - | qualified_expression - | '(' expression ')' - ; + : numeric_literal + | NULL_ + | aggregate + | string_literal + | name + | allocator + | function = name actual_parameter_part? //function_call + | type_conversion + | qualified_expression + | '(' expression ')' + ; logical_operator - : AND - | OR - | XOR - ; + : AND + | OR + | XOR + ; relational_operator - : '=' - | '/=' - | '<' - | '<=' - | '>' - | '>=' - ; + : '=' + | '/=' + | '<' + | '<=' + | '>' + | '>=' + ; binary_adding_operator - : '+' - | '-' - | '&' - ; + : '+' + | '-' + | '&' + ; unary_adding_operator - : '+' - | '-' - ; + : '+' + | '-' + ; multiplying_operator - : '*' - | '/' - | MOD - | REM - ; + : '*' + | '/' + | MOD + | REM + ; highest_precedence_operator - : '**' - | ABS - | NOT - ; + : '**' + | ABS + | NOT + ; type_conversion - : type_mark = name '(' expression ')' - ; + : type_mark = name '(' expression ')' + ; qualified_expression - : type_mark = name SQ '(' expression ')' - | type_mark = name SQ aggregate - ; + : type_mark = name SQ '(' expression ')' + | type_mark = name SQ aggregate + ; allocator - : NEW subtype_indication - | NEW qualified_expression - ; + : NEW subtype_indication + | NEW qualified_expression + ; + /* 5 - Statements */ - - + sequence_of_statements - : statement statement* - ; + : statement statement* + ; statement - : label* simple_statement - | label* compound_statement - ; + : label* simple_statement + | label* compound_statement + ; simple_statement - : null_statement - | assignment_statement - | procedure_call_statement - | exit_statement - | return_statement - | goto_statement - | entry_call_statement - | delay_statement - | abort_statement - | raise_statement - | code_statement - ; + : null_statement + | assignment_statement + | procedure_call_statement + | exit_statement + | return_statement + | goto_statement + | entry_call_statement + | delay_statement + | abort_statement + | raise_statement + | code_statement + ; compound_statement - : if_statement - | case_statement - | loop_statement - | block_statement - | accept_statement - | select_statement - ; + : if_statement + | case_statement + | loop_statement + | block_statement + | accept_statement + | select_statement + ; label - : '<<' simple_name '>>' // label_simple_name - - ; + : '<<' simple_name '>>' // label_simple_name + ; null_statement - : NULL_ ';' - ; + : NULL_ ';' + ; assignment_statement - : variable = name ':=' expression ';' - ; + : variable = name ':=' expression ';' + ; if_statement - : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* (ELSE sequence_of_statements)? END IF ';' - ; + : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* ( + ELSE sequence_of_statements + )? END IF ';' + ; condition - : boolean = expression - ; + : boolean = expression + ; case_statement - : CASE expression IS case_statement_alternative case_statement_alternative* END CASE ';' - ; + : CASE expression IS case_statement_alternative case_statement_alternative* END CASE ';' + ; case_statement_alternative - : WHEN choice ('|' choice)* '=>' sequence_of_statements - ; + : WHEN choice ('|' choice)* '=>' sequence_of_statements + ; loop_statement - : (loop = simple_name ':')? iteration_scheme? LOOP sequence_of_statements END LOOP loop = simple_name? ';' - ; + : (loop = simple_name ':')? iteration_scheme? LOOP sequence_of_statements END LOOP loop = simple_name? ';' + ; iteration_scheme - : WHILE condition - | FOR loop_parameter_specification - ; + : WHILE condition + | FOR loop_parameter_specification + ; loop_parameter_specification - : identifier IN REVERSE? discrete_range - ; + : identifier IN REVERSE? discrete_range + ; block_statement - : (block = simple_name ':')? (DECLARE basic_declarative_item* later_declarative_item*)? BEGIN sequence_of_statements (EXCEPTION_ exception_handler exception_handler*)? END block = simple_name? ';' - ; + : (block = simple_name ':')? (DECLARE basic_declarative_item* later_declarative_item*)? BEGIN sequence_of_statements ( + EXCEPTION_ exception_handler exception_handler* + )? END block = simple_name? ';' + ; exit_statement - : EXIT loop = name? (WHEN condition)? ';' - ; + : EXIT loop = name? (WHEN condition)? ';' + ; return_statement - : RETURN expression? ';' - ; + : RETURN expression? ';' + ; goto_statement - : GOTO name ';' // label_name - - ; + : GOTO name ';' // label_name + ; + /* 6 - Subprograms */ - - + subprogram_declaration - : subprogram_specification ';' - ; + : subprogram_specification ';' + ; subprogram_specification - : PROCEDURE identifier formal_part? - | FUNCTION designator formal_part? RETURN type_mark = name - ; + : PROCEDURE identifier formal_part? + | FUNCTION designator formal_part? RETURN type_mark = name + ; designator - : identifier - | operator_symbol - ; + : identifier + | operator_symbol + ; operator_symbol - : string_literal - ; + : string_literal + ; formal_part - : '(' parameter_specification (';' parameter_specification)? ')' - ; + : '(' parameter_specification (';' parameter_specification)? ')' + ; parameter_specification - : identifier_list ':' mode_ type_mark = name (':=' expression)? - ; + : identifier_list ':' mode_ type_mark = name (':=' expression)? + ; mode_ - : IN? OUT? - ; + : IN? OUT? + ; subprogram_body - : subprogram_specification IS basic_declarative_item* later_declarative_item* BEGIN sequence_of_statements (EXCEPTION_ exception_handler exception_handler*)? END designator? ';' - ; + : subprogram_specification IS basic_declarative_item* later_declarative_item* BEGIN sequence_of_statements ( + EXCEPTION_ exception_handler exception_handler* + )? END designator? ';' + ; procedure_call_statement - : name actual_parameter_part? ';' - ; + : name actual_parameter_part? ';' + ; actual_parameter_part - : '(' parameter_association (',' parameter_association)* ')' - ; + : '(' parameter_association (',' parameter_association)* ')' + ; parameter_association - : (formal_parameter '=>')? actual_parameter - ; + : (formal_parameter '=>')? actual_parameter + ; formal_parameter - : parameter = simple_name - ; + : parameter = simple_name + ; actual_parameter - : expression - | name - | name '(' name ')' - ; + : expression + | name + | name '(' name ')' + ; + /* 7 - Packages */ - - + package_declaration - : package_specification ';' - ; + : package_specification ';' + ; package_specification - : PACKAGE identifier IS basic_declarative_item* (PRIVATE basic_declarative_item*)? END package = simple_name? - ; + : PACKAGE identifier IS basic_declarative_item* (PRIVATE basic_declarative_item*)? END package = simple_name? + ; package_body - : PACKAGE BODY_ package = simple_name IS basic_declarative_item* later_declarative_item* (BEGIN sequence_of_statements (EXCEPTION_ exception_handler exception_handler*)?)? END package = simple_name? ';' - ; + : PACKAGE BODY_ package = simple_name IS basic_declarative_item* later_declarative_item* ( + BEGIN sequence_of_statements (EXCEPTION_ exception_handler exception_handler*)? + )? END package = simple_name? ';' + ; private_type_declaration - : TYPE identifier discriminant_part? IS LIMITED? PRIVATE ';' - ; + : TYPE identifier discriminant_part? IS LIMITED? PRIVATE ';' + ; deferred_constant_declaration - : identifier_list ':' CONSTANT type_mark = name ';' - ; + : identifier_list ':' CONSTANT type_mark = name ';' + ; + /* 8 - Visibility Rules */ - - + use_clause - : USE package = name (',' package = name)* ';' - ; + : USE package = name (',' package = name)* ';' + ; renaming_declaration - : identifier ':' name RENAMES name ';' - | identifier ':' EXCEPTION_ RENAMES name ';' - | PACKAGE identifier RENAMES name ';' - | subprogram_specification RENAMES name ';' - ; + : identifier ':' name RENAMES name ';' + | identifier ':' EXCEPTION_ RENAMES name ';' + | PACKAGE identifier RENAMES name ';' + | subprogram_specification RENAMES name ';' + ; + /* 9 - Tasks */ - - + task_declaration - : task_specification ';' - ; + : task_specification ';' + ; task_specification - : TASK TYPE? identifier (IS entry_declaration* representation_clause* END task = simple_name?)? - ; + : TASK TYPE? identifier (IS entry_declaration* representation_clause* END task = simple_name?)? + ; task_body - : TASK BODY_ task = simple_name IS basic_declarative_item* later_declarative_item* BEGIN sequence_of_statements (EXCEPTION_ exception_handler exception_handler*)? END task = simple_name? ';' - ; + : TASK BODY_ task = simple_name IS basic_declarative_item* later_declarative_item* BEGIN sequence_of_statements ( + EXCEPTION_ exception_handler exception_handler* + )? END task = simple_name? ';' + ; entry_declaration - : ENTRY identifier ('(' discrete_range ')')? formal_part? ';' - ; + : ENTRY identifier ('(' discrete_range ')')? formal_part? ';' + ; entry_call_statement - : entry = name actual_parameter_part? ';' - ; + : entry = name actual_parameter_part? ';' + ; accept_statement - : ACCEPT_ entry = simple_name ('(' entry_index ')')? formal_part? (DO sequence_of_statements END entry = simple_name?)? ';' - ; + : ACCEPT_ entry = simple_name ('(' entry_index ')')? formal_part? ( + DO sequence_of_statements END entry = simple_name? + )? ';' + ; entry_index - : expression - ; + : expression + ; delay_statement - : DELAY simple_expression ';' - ; + : DELAY simple_expression ';' + ; select_statement - : selective_wait - | conditional_entry_call - | timed_entry_call - ; + : selective_wait + | conditional_entry_call + | timed_entry_call + ; selective_wait - : SELECT select_alternative (OR select_alternative)* (ELSE sequence_of_statements)? END SELECT ';' - ; + : SELECT select_alternative (OR select_alternative)* (ELSE sequence_of_statements)? END SELECT ';' + ; select_alternative - : (WHEN condition '=>')? selective_wait_alternative - ; + : (WHEN condition '=>')? selective_wait_alternative + ; selective_wait_alternative - : accept_alternative - | delay_alternative - | terminate_alternative - ; + : accept_alternative + | delay_alternative + | terminate_alternative + ; accept_alternative - : accept_statement sequence_of_statements? - ; + : accept_statement sequence_of_statements? + ; delay_alternative - : delay_statement sequence_of_statements? - ; + : delay_statement sequence_of_statements? + ; terminate_alternative - : TERMINATE ';' - ; + : TERMINATE ';' + ; conditional_entry_call - : SELECT entry_call_statement sequence_of_statements? ELSE sequence_of_statements END SELECT ';' - ; + : SELECT entry_call_statement sequence_of_statements? ELSE sequence_of_statements END SELECT ';' + ; timed_entry_call - : SELECT entry_call_statement sequence_of_statements? OR delay_alternative END SELECT ';' - ; + : SELECT entry_call_statement sequence_of_statements? OR delay_alternative END SELECT ';' + ; abort_statement - : ABORT task = name (',' task = name)* ';' - ; + : ABORT task = name (',' task = name)* ';' + ; + /* 10 - Program Structure and Compilation Issues */ - - + compilation - : compilation_unit* EOF - ; + : compilation_unit* EOF + ; compilation_unit - : context_clause library_unit - | context_clause secondary_unit - ; + : context_clause library_unit + | context_clause secondary_unit + ; library_unit - : subprogram_declaration - | package_declaration - | generic_declaration - | generic_instantiation - | subprogram_body - ; + : subprogram_declaration + | package_declaration + | generic_declaration + | generic_instantiation + | subprogram_body + ; secondary_unit - : library_unit_body - | subunit - ; + : library_unit_body + | subunit + ; library_unit_body - : subprogram_body - | package_body - ; + : subprogram_body + | package_body + ; context_clause - : (with_clause use_clause*)* - ; + : (with_clause use_clause*)* + ; with_clause - : WITH unit = simple_name (',' unit = simple_name)* ';' - ; + : WITH unit = simple_name (',' unit = simple_name)* ';' + ; body_stub - : subprogram_specification IS SEPARATE ';' - | PACKAGE BODY_ package = simple_name IS SEPARATE ';' - | TASK BODY_ task = simple_name IS SEPARATE ';' - ; + : subprogram_specification IS SEPARATE ';' + | PACKAGE BODY_ package = simple_name IS SEPARATE ';' + | TASK BODY_ task = simple_name IS SEPARATE ';' + ; subunit - : SEPARATE '(' parent_unit = name ')' proper_body - ; + : SEPARATE '(' parent_unit = name ')' proper_body + ; + /* 11 - Exceptions */ - - + exception_declaration - : identifier_list ':' EXCEPTION_ ';' - ; + : identifier_list ':' EXCEPTION_ ';' + ; exception_handler - : WHEN exception_choice ('|' exception_choice)* '=>' sequence_of_statements - ; + : WHEN exception_choice ('|' exception_choice)* '=>' sequence_of_statements + ; exception_choice - : name - | OTHERS - ; + : name + | OTHERS + ; raise_statement - : RAISE name? ';' - ; + : RAISE name? ';' + ; + /* 12 - Generic Units */ - - + generic_declaration - : generic_specification ';' - ; + : generic_specification ';' + ; generic_specification - : generic_formal_part subprogram_specification - | generic_formal_part package_specification - ; + : generic_formal_part subprogram_specification + | generic_formal_part package_specification + ; generic_formal_part - : GENERIC generic_parameter_declaration* - ; + : GENERIC generic_parameter_declaration* + ; generic_parameter_declaration - : identifier_list ':' (IN OUT?)? type_mark = name (':=' expression)? ';' - | TYPE identifier IS generic_type_definition ';' - | private_type_declaration - | WITH subprogram_specification (IS name)? ';' - | WITH subprogram_specification (IS '<>')? ';' - ; + : identifier_list ':' (IN OUT?)? type_mark = name (':=' expression)? ';' + | TYPE identifier IS generic_type_definition ';' + | private_type_declaration + | WITH subprogram_specification (IS name)? ';' + | WITH subprogram_specification (IS '<>')? ';' + ; generic_type_definition - : '(' '<>' ')' - | RANGE_ '<>' - | DIGITS '<>' - | DELTA '<>' - | array_type_definition - | access_type_definition - ; + : '(' '<>' ')' + | RANGE_ '<>' + | DIGITS '<>' + | DELTA '<>' + | array_type_definition + | access_type_definition + ; generic_instantiation - : PACKAGE identifier IS NEW generic_package = name generic_actual_part? ';' - | PROCEDURE identifier IS NEW generic_procedure = name generic_actual_part? ';' - | FUNCTION designator IS NEW generic_function = name generic_actual_part? ';' - ; + : PACKAGE identifier IS NEW generic_package = name generic_actual_part? ';' + | PROCEDURE identifier IS NEW generic_procedure = name generic_actual_part? ';' + | FUNCTION designator IS NEW generic_function = name generic_actual_part? ';' + ; generic_actual_part - : '(' generic_association (',' generic_association)* ')' - ; + : '(' generic_association (',' generic_association)* ')' + ; generic_association - : (generic_formal_parameter '=>')? generic_actual_parameter - ; + : (generic_formal_parameter '=>')? generic_actual_parameter + ; generic_formal_parameter - : parameter = simple_name - | operator_symbol - ; + : parameter = simple_name + | operator_symbol + ; generic_actual_parameter - : expression - | variable = name - | subprogram = name - | entry = name - | type_mark = name - ; + : expression + | variable = name + | subprogram = name + | entry = name + | type_mark = name + ; + /* 13 - Representation Clauses and Implementation-Dependent Features */ - - + representation_clause - : type_representation_clause - | address_clause - ; + : type_representation_clause + | address_clause + ; type_representation_clause - : length_clause - | enumeration_representation_clause - | record_representation_clause - ; + : length_clause + | enumeration_representation_clause + | record_representation_clause + ; length_clause - : FOR prefix = name SQ attribute_designator USE simple_expression ';' - ; + : FOR prefix = name SQ attribute_designator USE simple_expression ';' + ; enumeration_representation_clause - : FOR type = simple_name USE aggregate ';' - ; + : FOR type = simple_name USE aggregate ';' + ; record_representation_clause - : FOR type = simple_name USE RECORD alignment_clause? component_clause* END RECORD ';' - ; + : FOR type = simple_name USE RECORD alignment_clause? component_clause* END RECORD ';' + ; alignment_clause - : AT MOD static_simple = expression ';' - ; + : AT MOD static_simple = expression ';' + ; component_clause - : component = name AT static_simple = expression RANGE_ static = range ';' - ; + : component = name AT static_simple = expression RANGE_ static = range ';' + ; address_clause - : FOR simple_name USE AT simple_expression ';' - ; + : FOR simple_name USE AT simple_expression ';' + ; code_statement - : type_mark = name SQ record = aggregate ';' - ; + : type_mark = name SQ record = aggregate ';' + ; + /* -*/ - - +*/ \ No newline at end of file diff --git a/ada/ada95/Ada95Lexer.g4 b/ada/ada95/Ada95Lexer.g4 index 24a7e638e2..87e4dc1009 100644 --- a/ada/ada95/Ada95Lexer.g4 +++ b/ada/ada95/Ada95Lexer.g4 @@ -21,144 +21,150 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Ada95Lexer; -options { caseInsensitive = true; } - -ABORT : 'abort'; -ABS : 'abs'; -ABSTRACT : 'abstract'; -ACCEPT_ : 'accept'; -ACCESS : 'access'; -ALIASED : 'aliased'; -ALL : 'all'; -AND : 'and'; -ARRAY : 'array'; -AT : 'at'; - -BEGIN : 'begin'; -BODY_ : 'body'; - -CASE : 'case'; -CONSTANT : 'constant'; - -DECLARE : 'declare'; -DELAY : 'delay'; -DELTA : 'delta'; -DIGITS : 'digits'; -DO : 'do'; - -ELSE : 'else'; -ELSIF : 'elsif'; -END : 'end'; -ENTRY : 'entry'; -EXCEPTION : 'exception'; -EXIT : 'exit'; - -FOR : 'for'; -FUNCTION : 'function'; - -GENERIC : 'generic'; -GOTO : 'goto'; - -IF : 'if'; -IN : 'in'; -IS : 'is'; - -LIMITED : 'limited'; -LOOP : 'loop'; - -MOD : 'mod'; - -NEW : 'new'; -NOT : 'not'; -NULL_ : 'null'; - -OF : 'of'; -OR : 'or'; -OTHERS : 'others'; -OUT : 'out'; - -PACKAGE : 'package'; -PRAGMA : 'pragma'; -PRIVATE : 'private'; -PROCEDURE : 'procedure'; -PROTECTED : 'protected'; - -RAISE : 'raise'; -RANGE_ : 'range'; -RECORD : 'record'; -REM : 'rem'; -RENAMES : 'renames'; -REQUEUE : 'requeue'; -RETURN : 'return'; -REVERSE : 'reverse'; - -SELECT : 'select'; -SEPARATE : 'separate'; -SUBTYPE : 'subtype'; - -TAGGED : 'tagged'; -TASK : 'task'; -TERMINATE : 'terminate'; -THEN : 'then'; -TYPE : 'type'; - -UNTIL : 'until'; -USE : 'use'; - -WHEN : 'when'; -WHILE : 'while'; -WITH : 'with'; - -XOR : 'xor'; - -WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); -LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); - -IDENTIFIER_ : LETTER+ [A-Z_0-9]*; -NUMERIC_LITERAL_ : DECIMAL_LITERAL_ | BASED_LITERAL; -DECIMAL_LITERAL_ : NUMERAL ('.' NUMERAL)? EXPONENT?; -NUMERAL : DIGIT+ ('_'? DIGIT)*; -EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; -BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; -BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; -EXTENDED_DIGIT : DIGIT | [A-F]; -BASE : NUMERAL; +options { + caseInsensitive = true; +} + +ABORT : 'abort'; +ABS : 'abs'; +ABSTRACT : 'abstract'; +ACCEPT_ : 'accept'; +ACCESS : 'access'; +ALIASED : 'aliased'; +ALL : 'all'; +AND : 'and'; +ARRAY : 'array'; +AT : 'at'; + +BEGIN : 'begin'; +BODY_ : 'body'; + +CASE : 'case'; +CONSTANT : 'constant'; + +DECLARE : 'declare'; +DELAY : 'delay'; +DELTA : 'delta'; +DIGITS : 'digits'; +DO : 'do'; + +ELSE : 'else'; +ELSIF : 'elsif'; +END : 'end'; +ENTRY : 'entry'; +EXCEPTION : 'exception'; +EXIT : 'exit'; + +FOR : 'for'; +FUNCTION : 'function'; + +GENERIC : 'generic'; +GOTO : 'goto'; + +IF : 'if'; +IN : 'in'; +IS : 'is'; + +LIMITED : 'limited'; +LOOP : 'loop'; + +MOD: 'mod'; + +NEW : 'new'; +NOT : 'not'; +NULL_ : 'null'; + +OF : 'of'; +OR : 'or'; +OTHERS : 'others'; +OUT : 'out'; + +PACKAGE : 'package'; +PRAGMA : 'pragma'; +PRIVATE : 'private'; +PROCEDURE : 'procedure'; +PROTECTED : 'protected'; + +RAISE : 'raise'; +RANGE_ : 'range'; +RECORD : 'record'; +REM : 'rem'; +RENAMES : 'renames'; +REQUEUE : 'requeue'; +RETURN : 'return'; +REVERSE : 'reverse'; + +SELECT : 'select'; +SEPARATE : 'separate'; +SUBTYPE : 'subtype'; + +TAGGED : 'tagged'; +TASK : 'task'; +TERMINATE : 'terminate'; +THEN : 'then'; +TYPE : 'type'; + +UNTIL : 'until'; +USE : 'use'; + +WHEN : 'when'; +WHILE : 'while'; +WITH : 'with'; + +XOR: 'xor'; + +WHITESPACE : [ \t\r\n]+ -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); + +IDENTIFIER_ : LETTER+ [A-Z_0-9]*; +NUMERIC_LITERAL_ : DECIMAL_LITERAL_ | BASED_LITERAL; +DECIMAL_LITERAL_ : NUMERAL ('.' NUMERAL)? EXPONENT?; +NUMERAL : DIGIT+ ('_'? DIGIT)*; +EXPONENT : 'E' '+'? NUMERAL | 'E' '-' NUMERAL; +BASED_LITERAL : BASE '#' BASED_NUMERAL ('.' BASED_NUMERAL)? '#' EXPONENT?; +BASED_NUMERAL : EXTENDED_DIGIT ('_'? EXTENDED_DIGIT)*; +EXTENDED_DIGIT : DIGIT | [A-F]; +BASE : NUMERAL; CHARACTER_LITERAL : '\'' ~['\\\r\n] '\''; -STRING_LITERAL_ : '"' ('""' | ~'"' )* '"'; - -fragment LETTER : [A-Z]; -fragment DIGIT : [0-9]; - -HASH : '#'; -AMPERSAND : '&'; -LP : '('; -RP : ')'; -MULT : '*'; -PLUS : '+'; -COMMA : ','; -MINUS : '-'; -DOT : '.'; -COLON : ':'; -SEMI : ';'; -LT : '<'; -EQ : '='; -GT : '>'; -US : '_'; -VL : '|'; -DIV : '/'; -EP : '!'; -PS : '%'; -ARROW : '=>'; -DOTDOT : '..'; -EXPON : '**'; -ASSIGN : ':='; -NE : '/='; -GE : '>='; -LE : '<='; -LLB : '<<'; -RLB : '>>'; -BOX : '<>'; -SQ : '\''; +STRING_LITERAL_ : '"' ('""' | ~'"')* '"'; + +fragment LETTER : [A-Z]; +fragment DIGIT : [0-9]; + +HASH : '#'; +AMPERSAND : '&'; +LP : '('; +RP : ')'; +MULT : '*'; +PLUS : '+'; +COMMA : ','; +MINUS : '-'; +DOT : '.'; +COLON : ':'; +SEMI : ';'; +LT : '<'; +EQ : '='; +GT : '>'; +US : '_'; +VL : '|'; +DIV : '/'; +EP : '!'; +PS : '%'; +ARROW : '=>'; +DOTDOT : '..'; +EXPON : '**'; +ASSIGN : ':='; +NE : '/='; +GE : '>='; +LE : '<='; +LLB : '<<'; +RLB : '>>'; +BOX : '<>'; +SQ : '\''; \ No newline at end of file diff --git a/ada/ada95/Ada95Parser.g4 b/ada/ada95/Ada95Parser.g4 index c639f57404..1b24df69e5 100644 --- a/ada/ada95/Ada95Parser.g4 +++ b/ada/ada95/Ada95Parser.g4 @@ -20,1274 +20,1294 @@ 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. */ + +// $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 Ada95Parser; -options { tokenVocab = Ada95Lexer; } +options { + tokenVocab = Ada95Lexer; +} /* 2 - Lexical Elements */ identifier - : IDENTIFIER_ - ; + : IDENTIFIER_ + ; numeric_literal - : NUMERIC_LITERAL_ - ; + : NUMERIC_LITERAL_ + ; character_literal - : CHARACTER_LITERAL - ; + : CHARACTER_LITERAL + ; string_literal - : STRING_LITERAL_ - ; + : STRING_LITERAL_ + ; + /* 3 - Declarations and Types */ - - + basic_declaration - : type_declaration - | subtype_declaration - | object_declaration - | number_declaration - | subprogram_declaration - | abstract_subprogram_declaration - | package_declaration - | renaming_declaration - | exception_declaration - | generic_declaration - | generic_instantiation - ; + : type_declaration + | subtype_declaration + | object_declaration + | number_declaration + | subprogram_declaration + | abstract_subprogram_declaration + | package_declaration + | renaming_declaration + | exception_declaration + | generic_declaration + | generic_instantiation + ; defining_identifier - : identifier - ; + : identifier + ; type_declaration - : full_type_declaration - | incomplete_type_declaration - | private_type_declaration - | private_extension_declaration - ; + : full_type_declaration + | incomplete_type_declaration + | private_type_declaration + | private_extension_declaration + ; full_type_declaration - : TYPE defining_identifier known_discriminant_part? IS type_definition ';' - | task_type_declaration - | protected_type_declaration - ; + : TYPE defining_identifier known_discriminant_part? IS type_definition ';' + | task_type_declaration + | protected_type_declaration + ; type_definition - : enumeration_type_definition - | integer_type_definition - | real_type_definition - | array_type_definition - | record_type_definition - | access_type_definition - | derived_type_definition - ; + : enumeration_type_definition + | integer_type_definition + | real_type_definition + | array_type_definition + | record_type_definition + | access_type_definition + | derived_type_definition + ; subtype_declaration - : SUBTYPE defining_identifier IS subtype_indication ';' - ; + : SUBTYPE defining_identifier IS subtype_indication ';' + ; subtype_indication - : subtype_mark = name constraint? - ; + : subtype_mark = name constraint? + ; constraint - : scalar_constraint - | composite_constraint - ; + : scalar_constraint + | composite_constraint + ; scalar_constraint - : range_constraint - | digits_constraint - | delta_constraint - ; + : range_constraint + | digits_constraint + | delta_constraint + ; composite_constraint - : index_constraint - | discriminant_constraint - ; + : index_constraint + | discriminant_constraint + ; object_declaration - : defining_identifier_list ':' ALIASED? CONSTANT? subtype_indication (':=' expression)? ';' - | defining_identifier_list ':' ALIASED? CONSTANT? array_type_definition (':=' expression)? ';' - | single_task_declaration - | single_protected_declaration - ; + : defining_identifier_list ':' ALIASED? CONSTANT? subtype_indication (':=' expression)? ';' + | defining_identifier_list ':' ALIASED? CONSTANT? array_type_definition (':=' expression)? ';' + | single_task_declaration + | single_protected_declaration + ; defining_identifier_list - : defining_identifier (',' defining_identifier)* - ; + : defining_identifier (',' defining_identifier)* + ; number_declaration - : defining_identifier_list ':' CONSTANT ':=' static_expression = expression ';' - ; + : defining_identifier_list ':' CONSTANT ':=' static_expression = expression ';' + ; derived_type_definition - : ABSTRACT? NEW parent_subtype_indication = subtype_indication record_extension_part? - ; + : ABSTRACT? NEW parent_subtype_indication = subtype_indication record_extension_part? + ; range_constraint - : RANGE_ range - ; + : RANGE_ range + ; range - : range_attribute_reference - | simple_expression '..' simple_expression - ; + : range_attribute_reference + | simple_expression '..' simple_expression + ; enumeration_type_definition - : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' - ; + : '(' enumeration_literal_specification (',' enumeration_literal_specification)* ')' + ; enumeration_literal_specification - : defining_identifier - | defining_character_literal - ; + : defining_identifier + | defining_character_literal + ; defining_character_literal - : character_literal - ; + : character_literal + ; integer_type_definition - : signed_integer_type_definition - | modular_type_definition - ; + : signed_integer_type_definition + | modular_type_definition + ; signed_integer_type_definition - : RANGE_ static_simple_expression = simple_expression '..' static_simple_expression = simple_expression - ; + : RANGE_ static_simple_expression = simple_expression '..' static_simple_expression = simple_expression + ; modular_type_definition - : MOD static_expression = expression - ; + : MOD static_expression = expression + ; real_type_definition - : floating_point_definition - | fixed_point_definition - ; + : floating_point_definition + | fixed_point_definition + ; floating_point_definition - : DIGITS static_expression = expression real_range_specification? - ; + : DIGITS static_expression = expression real_range_specification? + ; real_range_specification - : range static_simple_expression = simple_expression '..' static_simple_expression = simple_expression - ; + : range static_simple_expression = simple_expression '..' static_simple_expression = simple_expression + ; fixed_point_definition - : ordinary_fixed_point_definition - | decimal_fixed_point_definition - ; + : ordinary_fixed_point_definition + | decimal_fixed_point_definition + ; ordinary_fixed_point_definition - : DELTA static_expression = expression real_range_specification - ; + : DELTA static_expression = expression real_range_specification + ; decimal_fixed_point_definition - : DELTA static_expression = expression DIGITS static_expression = expression real_range_specification? - ; + : DELTA static_expression = expression DIGITS static_expression = expression real_range_specification? + ; digits_constraint - : DIGITS static_expression = expression range_constraint? - ; + : DIGITS static_expression = expression range_constraint? + ; array_type_definition - : unconstrained_array_definition - | constrained_array_definition - ; + : unconstrained_array_definition + | constrained_array_definition + ; unconstrained_array_definition - : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF component_definition - ; + : ARRAY '(' index_subtype_definition (',' index_subtype_definition)* ')' OF component_definition + ; index_subtype_definition - : subtype_mark = name range '<>' - ; + : subtype_mark = name range '<>' + ; constrained_array_definition - : ARRAY '(' discrete_subtype_definition (',' discrete_subtype_definition)* ')' OF component_definition - ; + : ARRAY '(' discrete_subtype_definition (',' discrete_subtype_definition)* ')' OF component_definition + ; discrete_subtype_definition - : discrete_subtype_indication = subtype_indication - | range - ; + : discrete_subtype_indication = subtype_indication + | range + ; component_definition - : ALIASED? subtype_indication - ; + : ALIASED? subtype_indication + ; index_constraint - : '(' discrete_range (',' discrete_range)* ')' - ; + : '(' discrete_range (',' discrete_range)* ')' + ; discrete_range - : discrete_subtype_indication = subtype_indication - | range - ; + : discrete_subtype_indication = subtype_indication + | range + ; discriminant_part - : unknown_discriminant_part - | known_discriminant_part - ; + : unknown_discriminant_part + | known_discriminant_part + ; unknown_discriminant_part - : '(' '<>' ')' - ; + : '(' '<>' ')' + ; known_discriminant_part - : '(' discriminant_specification (';' discriminant_specification)* ')' - ; + : '(' discriminant_specification (';' discriminant_specification)* ')' + ; discriminant_specification - : defining_identifier_list ':' subtype_mark = name (':=' default_expression)? - | defining_identifier_list ':' access_definition (':=' default_expression)? - ; + : defining_identifier_list ':' subtype_mark = name (':=' default_expression)? + | defining_identifier_list ':' access_definition (':=' default_expression)? + ; default_expression - : expression - ; + : expression + ; discriminant_constraint - : '(' discriminant_association (',' discriminant_association)* ')' - ; + : '(' discriminant_association (',' discriminant_association)* ')' + ; discriminant_association - : (discriminant_selector_name = selector_name ('|' discriminant_selector_name = selector_name)* '=>')? expression - ; + : ( + discriminant_selector_name = selector_name ('|' discriminant_selector_name = selector_name)* '=>' + )? expression + ; record_type_definition - : (ABSTRACT? TAGGED)? LIMITED? record_definition - ; + : (ABSTRACT? TAGGED)? LIMITED? record_definition + ; record_definition - : RECORD component_list END RECORD - | NULL_ RECORD - ; + : RECORD component_list END RECORD + | NULL_ RECORD + ; component_list - : component_item component_item* - | component_item* variant_part - | NULL_ ';' - ; + : component_item component_item* + | component_item* variant_part + | NULL_ ';' + ; component_item - : component_declaration - | aspect_clause - ; + : component_declaration + | aspect_clause + ; component_declaration - : defining_identifier_list ':' component_definition (':=' default_expression)? ';' - ; + : defining_identifier_list ':' component_definition (':=' default_expression)? ';' + ; variant_part - : CASE discriminant_direct_name = direct_name IS variant variant* END CASE ';' - ; + : CASE discriminant_direct_name = direct_name IS variant variant* END CASE ';' + ; variant - : WHEN discrete_choice_list '=>' component_list - ; + : WHEN discrete_choice_list '=>' component_list + ; discrete_choice_list - : discrete_choice ('|' discrete_choice)* - ; + : discrete_choice ('|' discrete_choice)* + ; discrete_choice - : expression - | discrete_range - | OTHERS - ; + : expression + | discrete_range + | OTHERS + ; record_extension_part - : WITH record_definition - ; + : WITH record_definition + ; access_type_definition - : access_to_object_definition - | access_to_subprogram_definition - ; + : access_to_object_definition + | access_to_subprogram_definition + ; access_to_object_definition - : ACCESS general_access_modifier? subtype_indication - ; + : ACCESS general_access_modifier? subtype_indication + ; general_access_modifier - : ALL - | CONSTANT - ; + : ALL + | CONSTANT + ; access_to_subprogram_definition - : ACCESS PROTECTED? PROCEDURE parameter_profile - | ACCESS PROTECTED? FUNCTION parameter_and_result_profile - ; + : ACCESS PROTECTED? PROCEDURE parameter_profile + | ACCESS PROTECTED? FUNCTION parameter_and_result_profile + ; access_definition - : ACCESS subtype_mark = name - ; + : ACCESS subtype_mark = name + ; incomplete_type_declaration - : TYPE defining_identifier discriminant_part? ';' - ; + : TYPE defining_identifier discriminant_part? ';' + ; declarative_part - : declarative_item* - ; + : declarative_item* + ; declarative_item - : basic_declarative_item - | body - ; + : basic_declarative_item + | body + ; basic_declarative_item - : basic_declaration - | aspect_clause - | use_clause - ; + : basic_declaration + | aspect_clause + | use_clause + ; body - : proper_body - | body_stub - ; + : proper_body + | body_stub + ; proper_body - : subprogram_body - | package_body - | task_body - | protected_body - ; + : subprogram_body + | package_body + | task_body + | protected_body + ; + /* 4 - Names and Expressions */ - - + name - : direct_name - | name '.' ALL - | prefix = name '(' expression (',' expression)* ')' //indexed_component - | prefix = name '(' discrete_range ')' //slice - | prefix = name '.' selector_name //selected_component - | prefix = name SQ attribute_designator //attribute_reference - | subtype_mark = name '(' expression ')' - | subtype_mark = name '(' name ')' - | function_prefix = name actual_parameter_part - | character_literal - ; + : direct_name + | name '.' ALL + | prefix = name '(' expression (',' expression)* ')' //indexed_component + | prefix = name '(' discrete_range ')' //slice + | prefix = name '.' selector_name //selected_component + | prefix = name SQ attribute_designator //attribute_reference + | subtype_mark = name '(' expression ')' + | subtype_mark = name '(' name ')' + | function_prefix = name actual_parameter_part + | character_literal + ; direct_name - : identifier - | operator_symbol - ; + : identifier + | operator_symbol + ; selector_name - : identifier - | character_literal - | operator_symbol - ; + : identifier + | character_literal + | operator_symbol + ; attribute_designator - : identifier ('(' static_expression = expression ')')? - | ACCESS - | DELTA - | DIGITS - ; + : identifier ('(' static_expression = expression ')')? + | ACCESS + | DELTA + | DIGITS + ; range_attribute_reference - : prefix = name SQ range_attribute_designator - ; + : prefix = name SQ range_attribute_designator + ; range_attribute_designator - : RANGE_ ('(' static_expression = expression ')')? - ; + : RANGE_ ('(' static_expression = expression ')')? + ; aggregate - : record_aggregate - | extension_aggregate - | array_aggregate - ; + : record_aggregate + | extension_aggregate + | array_aggregate + ; record_aggregate - : '(' record_component_association_list ')' - ; + : '(' record_component_association_list ')' + ; record_component_association_list - : record_component_association (',' record_component_association)* - | NULL_ RECORD - ; + : record_component_association (',' record_component_association)* + | NULL_ RECORD + ; record_component_association - : (component_choice_list '=>')? expression - ; + : (component_choice_list '=>')? expression + ; component_choice_list - : component_selector_name = selector_name ('|' component_selector_name = selector_name)* - | OTHERS - ; + : component_selector_name = selector_name ('|' component_selector_name = selector_name)* + | OTHERS + ; extension_aggregate - : '(' ancestor_part WITH record_component_association_list ')' - ; + : '(' ancestor_part WITH record_component_association_list ')' + ; ancestor_part - : expression - | subtype_mark = name - ; + : expression + | subtype_mark = name + ; array_aggregate - : positional_array_aggregate - | named_array_aggregate - ; + : positional_array_aggregate + | named_array_aggregate + ; positional_array_aggregate - : '(' expression ',' expression (',' expression)* ')' - | '(' expression (',' expression)* ',' OTHERS '=>' expression ')' - ; + : '(' expression ',' expression (',' expression)* ')' + | '(' expression (',' expression)* ',' OTHERS '=>' expression ')' + ; named_array_aggregate - : '(' array_component_association (',' array_component_association)* ')' - ; + : '(' array_component_association (',' array_component_association)* ')' + ; array_component_association - : discrete_choice_list '=>' expression - ; + : discrete_choice_list '=>' expression + ; expression - : relation (AND relation)* - | relation (AND THEN relation)* - | relation (OR relation)* - | relation (OR ELSE relation)* - | relation (XOR relation)* - ; + : relation (AND relation)* + | relation (AND THEN relation)* + | relation (OR relation)* + | relation (OR ELSE relation)* + | relation (XOR relation)* + ; relation - : simple_expression (relational_operator simple_expression)? - | simple_expression NOT? IN range - | simple_expression NOT? IN subtype_mark = name - ; + : simple_expression (relational_operator simple_expression)? + | simple_expression NOT? IN range + | simple_expression NOT? IN subtype_mark = name + ; simple_expression - : unary_adding_operator? term (binary_adding_operator term)* - ; + : unary_adding_operator? term (binary_adding_operator term)* + ; term - : factor (multiplying_operator factor)* - ; + : factor (multiplying_operator factor)* + ; factor - : primary ('**' primary)? - | ABS primary - | NOT primary - ; + : primary ('**' primary)? + | ABS primary + | NOT primary + ; primary - : numeric_literal - | NULL_ - | string_literal - | aggregate - | name - | qualified_expression - | allocator - | '(' expression ')' - ; + : numeric_literal + | NULL_ + | string_literal + | aggregate + | name + | qualified_expression + | allocator + | '(' expression ')' + ; logical_operator - : AND - | OR - | XOR - ; + : AND + | OR + | XOR + ; relational_operator - : '=' - | '/=' - | '<' - | '<=' - | '>' - | '>=' - ; + : '=' + | '/=' + | '<' + | '<=' + | '>' + | '>=' + ; binary_adding_operator - : '+' - | '-' - | '&' - ; + : '+' + | '-' + | '&' + ; unary_adding_operator - : '+' - | '-' - ; + : '+' + | '-' + ; multiplying_operator - : '*' - | '/' - | MOD - | REM - ; + : '*' + | '/' + | MOD + | REM + ; highest_precedence_operator - : '**' - | ABS - | NOT - ; + : '**' + | ABS + | NOT + ; qualified_expression - : subtype_mark = name SQ '(' expression ')' - | subtype_mark = name SQ aggregate - ; + : subtype_mark = name SQ '(' expression ')' + | subtype_mark = name SQ aggregate + ; allocator - : NEW subtype_indication - | NEW qualified_expression - ; + : NEW subtype_indication + | NEW qualified_expression + ; + /* 5 - Statements */ - - + sequence_of_statements - : statement statement* - ; + : statement statement* + ; statement - : label* simple_statement - | label* compound_statement - ; + : label* simple_statement + | label* compound_statement + ; simple_statement - : null_statement - | assignment_statement - | exit_statement - | goto_statement - | procedure_call_statement - | return_statement - | entry_call_statement - | requeue_statement - | delay_statement - | abort_statement - | raise_statement - | code_statement - ; + : null_statement + | assignment_statement + | exit_statement + | goto_statement + | procedure_call_statement + | return_statement + | entry_call_statement + | requeue_statement + | delay_statement + | abort_statement + | raise_statement + | code_statement + ; compound_statement - : if_statement - | case_statement - | loop_statement - | block_statement - | accept_statement - | select_statement - ; + : if_statement + | case_statement + | loop_statement + | block_statement + | accept_statement + | select_statement + ; null_statement - : NULL_ ';' - ; + : NULL_ ';' + ; label - : '<<' label_statement_identifier = statement_identifier '>>' - ; + : '<<' label_statement_identifier = statement_identifier '>>' + ; statement_identifier - : direct_name - ; + : direct_name + ; assignment_statement - : variable_name = name ':=' expression ';' - ; + : variable_name = name ':=' expression ';' + ; if_statement - : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* (ELSE sequence_of_statements)? END IF ';' - ; + : IF condition THEN sequence_of_statements (ELSIF condition THEN sequence_of_statements)* ( + ELSE sequence_of_statements + )? END IF ';' + ; condition - : boolean_expression - ; + : boolean_expression + ; case_statement - : CASE expression IS case_statement_alternative case_statement_alternative* END CASE ';' - ; + : CASE expression IS case_statement_alternative case_statement_alternative* END CASE ';' + ; case_statement_alternative - : WHEN discrete_choice_list '=>' sequence_of_statements - ; + : WHEN discrete_choice_list '=>' sequence_of_statements + ; loop_statement - : (loop_statement_identifier = statement_identifier ':')? iteration_scheme? LOOP sequence_of_statements END LOOP loop_identifier = identifier? ';' - ; + : (loop_statement_identifier = statement_identifier ':')? iteration_scheme? LOOP sequence_of_statements END LOOP loop_identifier = identifier? ';' + ; iteration_scheme - : WHILE condition - | FOR loop_parameter_specification - ; + : WHILE condition + | FOR loop_parameter_specification + ; loop_parameter_specification - : defining_identifier IN REVERSE? discrete_subtype_definition - ; + : defining_identifier IN REVERSE? discrete_subtype_definition + ; block_statement - : (block_statement_identifier = statement_identifier ':')? (DECLARE declarative_part)? BEGIN handled_sequence_of_statements END block_identifier = identifier? ';' - ; + : (block_statement_identifier = statement_identifier ':')? (DECLARE declarative_part)? BEGIN handled_sequence_of_statements END block_identifier = + identifier? ';' + ; exit_statement - : EXIT loop_name = name? (WHEN condition)? ';' - ; + : EXIT loop_name = name? (WHEN condition)? ';' + ; goto_statement - : GOTO label_name = name ';' - ; + : GOTO label_name = name ';' + ; + /* 6 - Subprograms */ - - + subprogram_declaration - : subprogram_specification ';' - ; + : subprogram_specification ';' + ; abstract_subprogram_declaration - : subprogram_specification IS ABSTRACT ';' - ; + : subprogram_specification IS ABSTRACT ';' + ; subprogram_specification - : PROCEDURE defining_program_unit_name parameter_profile - | FUNCTION defining_designator parameter_and_result_profile - ; + : PROCEDURE defining_program_unit_name parameter_profile + | FUNCTION defining_designator parameter_and_result_profile + ; designator - : (parent_unit_name '.')? identifier - | operator_symbol - ; + : (parent_unit_name '.')? identifier + | operator_symbol + ; defining_designator - : defining_program_unit_name - | defining_operator_symbol - ; + : defining_program_unit_name + | defining_operator_symbol + ; defining_program_unit_name - : (parent_unit_name '.')? defining_identifier - ; + : (parent_unit_name '.')? defining_identifier + ; operator_symbol - : string_literal - ; + : string_literal + ; defining_operator_symbol - : operator_symbol - ; + : operator_symbol + ; parameter_profile - : formal_part? - ; + : formal_part? + ; parameter_and_result_profile - : formal_part? RETURN subtype_mark = name - ; + : formal_part? RETURN subtype_mark = name + ; formal_part - : '(' parameter_specification (';' parameter_specification)* ')' - ; + : '(' parameter_specification (';' parameter_specification)* ')' + ; parameter_specification - : defining_identifier_list ':' mode_ subtype_mark = name (':=' default_expression)? - | defining_identifier_list ':' access_definition (':=' default_expression)? - ; + : defining_identifier_list ':' mode_ subtype_mark = name (':=' default_expression)? + | defining_identifier_list ':' access_definition (':=' default_expression)? + ; mode_ - : IN? OUT? - ; + : IN? OUT? + ; subprogram_body - : subprogram_specification IS declarative_part BEGIN handled_sequence_of_statements END designator? ';' - ; + : subprogram_specification IS declarative_part BEGIN handled_sequence_of_statements END designator? ';' + ; procedure_call_statement - : procedure_name = name ';' - | procedure_prefix = name actual_parameter_part ';' - ; + : procedure_name = name ';' + | procedure_prefix = name actual_parameter_part ';' + ; actual_parameter_part - : '(' parameter_association (',' parameter_association)* ')' - ; + : '(' parameter_association (',' parameter_association)* ')' + ; parameter_association - : (formal_parameter_selector_name = selector_name '=>')? explicit_actual_parameter - ; + : (formal_parameter_selector_name = selector_name '=>')? explicit_actual_parameter + ; explicit_actual_parameter - : expression - | variable_name = name - ; + : expression + | variable_name = name + ; return_statement - : RETURN expression? ';' - ; + : RETURN expression? ';' + ; + /* 7 - Packages */ - - + package_declaration - : package_specification ';' - ; + : package_specification ';' + ; package_specification - : PACKAGE defining_program_unit_name IS basic_declarative_item* (PRIVATE basic_declarative_item*)? END ((parent_unit_name '.')? identifier)? - ; + : PACKAGE defining_program_unit_name IS basic_declarative_item* ( + PRIVATE basic_declarative_item* + )? END ((parent_unit_name '.')? identifier)? + ; package_body - : PACKAGE BODY_ defining_program_unit_name IS declarative_part (BEGIN handled_sequence_of_statements)? END ((parent_unit_name '.')? identifier)? ';' - ; + : PACKAGE BODY_ defining_program_unit_name IS declarative_part ( + BEGIN handled_sequence_of_statements + )? END ((parent_unit_name '.')? identifier)? ';' + ; private_type_declaration - : TYPE defining_identifier discriminant_part? IS (ABSTRACT? TAGGED)? LIMITED? PRIVATE ';' - ; + : TYPE defining_identifier discriminant_part? IS (ABSTRACT? TAGGED)? LIMITED? PRIVATE ';' + ; private_extension_declaration - : TYPE defining_identifier discriminant_part? IS ABSTRACT? NEW ancestor_subtype_indication = subtype_indication WITH PRIVATE ';' - ; + : TYPE defining_identifier discriminant_part? IS ABSTRACT? NEW ancestor_subtype_indication = subtype_indication WITH PRIVATE ';' + ; + /* 8 - Visibility Rules */ - - + use_clause - : use_package_clause - | use_type_clause - ; + : use_package_clause + | use_type_clause + ; use_package_clause - : USE package_name = name (',' package_nam = name)* ';' - ; + : USE package_name = name (',' package_nam = name)* ';' + ; use_type_clause - : USE TYPE subtype_mark = name (',' subtype_mark = name)* ';' - ; + : USE TYPE subtype_mark = name (',' subtype_mark = name)* ';' + ; renaming_declaration - : object_renaming_declaration - | exception_renaming_declaration - | package_renaming_declaration - | subprogram_renaming_declaration - | generic_renaming_declaration - ; + : object_renaming_declaration + | exception_renaming_declaration + | package_renaming_declaration + | subprogram_renaming_declaration + | generic_renaming_declaration + ; object_renaming_declaration - : defining_identifier ':' subtype_mark = name RENAMES object_name = name ';' - ; + : defining_identifier ':' subtype_mark = name RENAMES object_name = name ';' + ; exception_renaming_declaration - : defining_identifier ':' EXCEPTION RENAMES exception_name = name ';' - ; + : defining_identifier ':' EXCEPTION RENAMES exception_name = name ';' + ; package_renaming_declaration - : PACKAGE defining_program_unit_name RENAMES package_name = name ';' - ; + : PACKAGE defining_program_unit_name RENAMES package_name = name ';' + ; subprogram_renaming_declaration - : subprogram_specification RENAMES callable_entity_name = name ';' - ; + : subprogram_specification RENAMES callable_entity_name = name ';' + ; generic_renaming_declaration - : GENERIC PACKAGE defining_program_unit_name RENAMES generic_package_name = name ';' - | GENERIC PROCEDURE defining_program_unit_name RENAMES generic_procedure_name = name ';' - | GENERIC FUNCTION defining_program_unit_name RENAMES generic_function_name = name ';' - ; + : GENERIC PACKAGE defining_program_unit_name RENAMES generic_package_name = name ';' + | GENERIC PROCEDURE defining_program_unit_name RENAMES generic_procedure_name = name ';' + | GENERIC FUNCTION defining_program_unit_name RENAMES generic_function_name = name ';' + ; + /* 9 - Tasks and Synchronization */ - - + task_type_declaration - : TASK TYPE defining_identifier known_discriminant_part? (IS task_definition)? ';' - ; + : TASK TYPE defining_identifier known_discriminant_part? (IS task_definition)? ';' + ; single_task_declaration - : TASK defining_identifier (IS task_definition)? ';' - ; + : TASK defining_identifier (IS task_definition)? ';' + ; task_definition - : task_item* (PRIVATE task_item*)? END task_identifier = identifier? - ; + : task_item* (PRIVATE task_item*)? END task_identifier = identifier? + ; task_item - : entry_declaration - | aspect_clause - ; + : entry_declaration + | aspect_clause + ; task_body - : TASK BODY_ defining_identifier IS declarative_part BEGIN handled_sequence_of_statements END task_identifier = identifier? ';' - ; + : TASK BODY_ defining_identifier IS declarative_part BEGIN handled_sequence_of_statements END task_identifier = identifier? ';' + ; protected_type_declaration - : PROTECTED TYPE defining_identifier known_discriminant_part? IS protected_definition ';' - ; + : PROTECTED TYPE defining_identifier known_discriminant_part? IS protected_definition ';' + ; single_protected_declaration - : PROTECTED defining_identifier IS protected_definition ';' - ; + : PROTECTED defining_identifier IS protected_definition ';' + ; protected_definition - : protected_operation_declaration* (PRIVATE protected_element_declaration*)? END protected_identifier = identifier? - ; + : protected_operation_declaration* (PRIVATE protected_element_declaration*)? END protected_identifier = identifier? + ; protected_operation_declaration - : subprogram_declaration - | entry_declaration - | aspect_clause - ; + : subprogram_declaration + | entry_declaration + | aspect_clause + ; protected_element_declaration - : protected_operation_declaration - | component_declaration - ; + : protected_operation_declaration + | component_declaration + ; protected_body - : PROTECTED BODY_ defining_identifier IS protected_operation_item* END protected_identifier = identifier? ';' - ; + : PROTECTED BODY_ defining_identifier IS protected_operation_item* END protected_identifier = identifier? ';' + ; protected_operation_item - : subprogram_declaration - | subprogram_body - | entry_body - | aspect_clause - ; + : subprogram_declaration + | subprogram_body + | entry_body + | aspect_clause + ; entry_declaration - : ENTRY defining_identifier ('(' discrete_subtype_definition ')')? parameter_profile ';' - ; + : ENTRY defining_identifier ('(' discrete_subtype_definition ')')? parameter_profile ';' + ; accept_statement - : ACCEPT_ entry_direct_name = direct_name ('(' entry_index ')')? parameter_profile (DO handled_sequence_of_statements END entry_identifier = identifier?)? ';' - ; + : ACCEPT_ entry_direct_name = direct_name ('(' entry_index ')')? parameter_profile ( + DO handled_sequence_of_statements END entry_identifier = identifier? + )? ';' + ; entry_index - : expression - ; + : expression + ; entry_body - : ENTRY defining_identifier entry_body_formal_part entry_barrier IS declarative_part BEGIN handled_sequence_of_statements END entry_identifier = identifier? ';' - ; + : ENTRY defining_identifier entry_body_formal_part entry_barrier IS declarative_part BEGIN handled_sequence_of_statements END entry_identifier = + identifier? ';' + ; entry_body_formal_part - : ('(' entry_index_specification ')')? parameter_profile - ; + : ('(' entry_index_specification ')')? parameter_profile + ; entry_barrier - : WHEN condition - ; + : WHEN condition + ; entry_index_specification - : FOR defining_identifier IN discrete_subtype_definition - ; + : FOR defining_identifier IN discrete_subtype_definition + ; entry_call_statement - : entry_name = name actual_parameter_part? ';' - ; + : entry_name = name actual_parameter_part? ';' + ; requeue_statement - : REQUEUE entry_name = name (WITH ABORT)? ';' - ; + : REQUEUE entry_name = name (WITH ABORT)? ';' + ; delay_statement - : delay_until_statement - | delay_relative_statement - ; + : delay_until_statement + | delay_relative_statement + ; delay_until_statement - : DELAY UNTIL delay_expression = expression ';' - ; + : DELAY UNTIL delay_expression = expression ';' + ; delay_relative_statement - : DELAY delay_expression = expression ';' - ; + : DELAY delay_expression = expression ';' + ; select_statement - : selective_accept - | timed_entry_call - | conditional_entry_call - | asynchronous_select - ; + : selective_accept + | timed_entry_call + | conditional_entry_call + | asynchronous_select + ; selective_accept - : SELECT guard? select_alternative (OR guard? select_alternative)* (ELSE sequence_of_statements)? END SELECT ';' - ; + : SELECT guard? select_alternative (OR guard? select_alternative)* ( + ELSE sequence_of_statements + )? END SELECT ';' + ; guard - : WHEN condition '=>' - ; + : WHEN condition '=>' + ; select_alternative - : accept_alternative - | delay_alternative - | terminate_alternative - ; + : accept_alternative + | delay_alternative + | terminate_alternative + ; accept_alternative - : accept_statement sequence_of_statements? - ; + : accept_statement sequence_of_statements? + ; delay_alternative - : delay_statement sequence_of_statements? - ; + : delay_statement sequence_of_statements? + ; terminate_alternative - : TERMINATE ';' - ; + : TERMINATE ';' + ; timed_entry_call - : SELECT entry_call_alternative OR delay_alternative END SELECT ';' - ; + : SELECT entry_call_alternative OR delay_alternative END SELECT ';' + ; entry_call_alternative - : entry_call_statement sequence_of_statements? - ; + : entry_call_statement sequence_of_statements? + ; conditional_entry_call - : SELECT entry_call_alternative ELSE sequence_of_statements END SELECT ';' - ; + : SELECT entry_call_alternative ELSE sequence_of_statements END SELECT ';' + ; asynchronous_select - : SELECT triggering_alternative THEN ABORT abortable_part END SELECT ';' - ; + : SELECT triggering_alternative THEN ABORT abortable_part END SELECT ';' + ; triggering_alternative - : triggering_statement sequence_of_statements? - ; + : triggering_statement sequence_of_statements? + ; triggering_statement - : entry_call_statement - | delay_statement - ; + : entry_call_statement + | delay_statement + ; abortable_part - : sequence_of_statements - ; + : sequence_of_statements + ; abort_statement - : ABORT task_name = name (',' task_name = name)* ';' - ; + : ABORT task_name = name (',' task_name = name)* ';' + ; + /* 10 - Program Structure and Compilation Issues */ - - + compilation - : compilation_unit* EOF - ; + : compilation_unit* EOF + ; compilation_unit - : context_clause library_item - | context_clause subunit - ; + : context_clause library_item + | context_clause subunit + ; library_item - : PRIVATE? library_unit_declaration - | library_unit_body - | PRIVATE? library_unit_renaming_declaration - ; + : PRIVATE? library_unit_declaration + | library_unit_body + | PRIVATE? library_unit_renaming_declaration + ; library_unit_declaration - : subprogram_declaration - | package_declaration - | generic_declaration - | generic_instantiation - ; + : subprogram_declaration + | package_declaration + | generic_declaration + | generic_instantiation + ; library_unit_renaming_declaration - : package_renaming_declaration - | generic_renaming_declaration - | subprogram_renaming_declaration - ; + : package_renaming_declaration + | generic_renaming_declaration + | subprogram_renaming_declaration + ; library_unit_body - : subprogram_body - | package_body - ; + : subprogram_body + | package_body + ; parent_unit_name - : name - ; + : name + ; context_clause - : context_item* - ; + : context_item* + ; context_item - : with_clause - | use_clause - ; + : with_clause + | use_clause + ; with_clause - : WITH library_unit_name = name (',' library_unit_name = name)* ';' - ; + : WITH library_unit_name = name (',' library_unit_name = name)* ';' + ; body_stub - : subprogram_body_stub - | package_body_stub - | task_body_stub - | protected_body_stub - ; + : subprogram_body_stub + | package_body_stub + | task_body_stub + | protected_body_stub + ; subprogram_body_stub - : subprogram_specification IS SEPARATE ';' - ; + : subprogram_specification IS SEPARATE ';' + ; package_body_stub - : PACKAGE BODY_ defining_identifier IS SEPARATE ';' - ; + : PACKAGE BODY_ defining_identifier IS SEPARATE ';' + ; task_body_stub - : TASK BODY_ defining_identifier IS SEPARATE ';' - ; + : TASK BODY_ defining_identifier IS SEPARATE ';' + ; protected_body_stub - : PROTECTED BODY_ defining_identifier IS SEPARATE ';' - ; + : PROTECTED BODY_ defining_identifier IS SEPARATE ';' + ; subunit - : SEPARATE '(' parent_unit_name ')' proper_body - ; + : SEPARATE '(' parent_unit_name ')' proper_body + ; + /* 11 - Exceptions */ - - + exception_declaration - : defining_identifier_list ':' EXCEPTION ';' - ; + : defining_identifier_list ':' EXCEPTION ';' + ; handled_sequence_of_statements - : sequence_of_statements (EXCEPTION exception_handler exception_handler*)? - ; + : sequence_of_statements (EXCEPTION exception_handler exception_handler*)? + ; exception_handler - : WHEN (choice_parameter_specification ':')? exception_choice ('|' exception_choice)* '=>' sequence_of_statements - ; + : WHEN (choice_parameter_specification ':')? exception_choice ('|' exception_choice)* '=>' sequence_of_statements + ; choice_parameter_specification - : defining_identifier - ; + : defining_identifier + ; exception_choice - : exception_name = name - | OTHERS - ; + : exception_name = name + | OTHERS + ; raise_statement - : RAISE exception_name = name? ';' - ; + : RAISE exception_name = name? ';' + ; + /* 12 - Generic Units */ - - + generic_declaration - : generic_subprogram_declaration - | generic_package_declaration - ; + : generic_subprogram_declaration + | generic_package_declaration + ; generic_subprogram_declaration - : generic_formal_part subprogram_specification ';' - ; + : generic_formal_part subprogram_specification ';' + ; generic_package_declaration - : generic_formal_part package_specification ';' - ; + : generic_formal_part package_specification ';' + ; generic_formal_part - : GENERIC (generic_formal_parameter_declaration | use_clause)* - ; + : GENERIC (generic_formal_parameter_declaration | use_clause)* + ; generic_formal_parameter_declaration - : formal_object_declaration - | formal_type_declaration - | formal_subprogram_declaration - | formal_package_declaration - ; + : formal_object_declaration + | formal_type_declaration + | formal_subprogram_declaration + | formal_package_declaration + ; generic_instantiation - : PACKAGE defining_program_unit_name IS NEW generic_package_name = name generic_actual_part? ';' - | PROCEDURE defining_program_unit_name IS NEW generic_procedure_name = name generic_actual_part? ';' - | FUNCTION defining_designator IS NEW generic_function_name = name generic_actual_part? ';' - ; + : PACKAGE defining_program_unit_name IS NEW generic_package_name = name generic_actual_part? ';' + | PROCEDURE defining_program_unit_name IS NEW generic_procedure_name = name generic_actual_part? ';' + | FUNCTION defining_designator IS NEW generic_function_name = name generic_actual_part? ';' + ; generic_actual_part - : '(' generic_association (',' generic_association)* ')' - ; + : '(' generic_association (',' generic_association)* ')' + ; generic_association - : (generic_formal_parameter_selector_name = selector_name '=>')? explicit_generic_actual_parameter - ; + : (generic_formal_parameter_selector_name = selector_name '=>')? explicit_generic_actual_parameter + ; explicit_generic_actual_parameter - : expression - | variable_name = name - | subprogram_name = name - | entry_name = name - | subtype_mark = name - | package_instance_name = name - ; + : expression + | variable_name = name + | subprogram_name = name + | entry_name = name + | subtype_mark = name + | package_instance_name = name + ; formal_object_declaration - : defining_identifier_list ':' mode_ subtype_mark = name (':=' default_expression)? ';' - ; + : defining_identifier_list ':' mode_ subtype_mark = name (':=' default_expression)? ';' + ; formal_type_declaration - : TYPE defining_identifier discriminant_part? IS formal_type_definition ';' - ; + : TYPE defining_identifier discriminant_part? IS formal_type_definition ';' + ; formal_type_definition - : formal_private_type_definition - | formal_derived_type_definition - | formal_discrete_type_definition - | formal_signed_integer_type_definition - | formal_modular_type_definition - | formal_floating_point_definition - | formal_ordinary_fixed_point_definition - | formal_decimal_fixed_point_definition - | formal_array_type_definition - | formal_access_type_definition - ; + : formal_private_type_definition + | formal_derived_type_definition + | formal_discrete_type_definition + | formal_signed_integer_type_definition + | formal_modular_type_definition + | formal_floating_point_definition + | formal_ordinary_fixed_point_definition + | formal_decimal_fixed_point_definition + | formal_array_type_definition + | formal_access_type_definition + ; formal_private_type_definition - : (ABSTRACT? TAGGED)? LIMITED? PRIVATE - ; + : (ABSTRACT? TAGGED)? LIMITED? PRIVATE + ; formal_derived_type_definition - : ABSTRACT? NEW subtype_mark = name (WITH PRIVATE)? - ; + : ABSTRACT? NEW subtype_mark = name (WITH PRIVATE)? + ; formal_discrete_type_definition - : '(' '<>' ')' - ; + : '(' '<>' ')' + ; formal_signed_integer_type_definition - : RANGE_ '<>' - ; + : RANGE_ '<>' + ; formal_modular_type_definition - : MOD '<>' - ; + : MOD '<>' + ; formal_floating_point_definition - : DIGITS '<>' - ; + : DIGITS '<>' + ; formal_ordinary_fixed_point_definition - : DELTA '<>' - ; + : DELTA '<>' + ; formal_decimal_fixed_point_definition - : DELTA '<>' DIGITS '<>' - ; + : DELTA '<>' DIGITS '<>' + ; formal_array_type_definition - : array_type_definition - ; + : array_type_definition + ; formal_access_type_definition - : access_type_definition - ; + : access_type_definition + ; formal_subprogram_declaration - : WITH subprogram_specification (IS subprogram_default)? ';' - ; + : WITH subprogram_specification (IS subprogram_default)? ';' + ; subprogram_default - : default_name - | '<>' - ; + : default_name + | '<>' + ; default_name - : name - ; + : name + ; formal_package_declaration - : WITH PACKAGE defining_identifier IS NEW generic_package_name = name formal_package_actual_part ';' - ; + : WITH PACKAGE defining_identifier IS NEW generic_package_name = name formal_package_actual_part ';' + ; formal_package_actual_part - : '(' '<>' ')' - | generic_actual_part? - ; + : '(' '<>' ')' + | generic_actual_part? + ; + /* 13 - Representation Issues */ - - + aspect_clause - : attribute_definition_clause - | enumeration_representation_clause - | record_representation_clause - | at_clause - ; + : attribute_definition_clause + | enumeration_representation_clause + | record_representation_clause + | at_clause + ; local_name - : direct_name - | direct_name SQ attribute_designator - | library_unit_name = name - ; + : direct_name + | direct_name SQ attribute_designator + | library_unit_name = name + ; attribute_definition_clause - : FOR local_name SQ attribute_designator USE expression ';' - | FOR local_name SQ attribute_designator USE name ';' - ; + : FOR local_name SQ attribute_designator USE expression ';' + | FOR local_name SQ attribute_designator USE name ';' + ; enumeration_representation_clause - : FOR first_subtype_local_name = name USE enumeration_aggregate ';' - ; + : FOR first_subtype_local_name = name USE enumeration_aggregate ';' + ; enumeration_aggregate - : array_aggregate - ; + : array_aggregate + ; record_representation_clause - : FOR first_subtype_local_name = name USE RECORD mod_clause? component_clause* END RECORD ';' - ; + : FOR first_subtype_local_name = name USE RECORD mod_clause? component_clause* END RECORD ';' + ; component_clause - : component_local_name = name AT position RANGE_ first_bit '..' last_bit ';' - ; + : component_local_name = name AT position RANGE_ first_bit '..' last_bit ';' + ; position - : static_expression = expression - ; + : static_expression = expression + ; first_bit - : static_simple_expression = simple_expression - ; + : static_simple_expression = simple_expression + ; last_bit - : static_simple_expression = simple_expression - ; + : static_simple_expression = simple_expression + ; code_statement - : qualified_expression ';' - ; + : qualified_expression ';' + ; restriction - : restriction_identifier = identifier - | restriction_parameter_identifier = identifier '=>' expression - ; + : restriction_identifier = identifier + | restriction_parameter_identifier = identifier '=>' expression + ; + /* J */ - - + at_clause - : FOR direct_name USE AT expression ';' - ; + : FOR direct_name USE AT expression ';' + ; delta_constraint - : DELTA static_expression = expression range_constraint? - ; + : DELTA static_expression = expression range_constraint? + ; mod_clause - : AT MOD static_expression = expression ';' - ; + : AT MOD static_expression = expression ';' + ; boolean_expression - : expression - ; + : expression + ; \ No newline at end of file diff --git a/agc/agc.g4 b/agc/agc.g4 index 7884d601c4..9a14a13499 100644 --- a/agc/agc.g4 +++ b/agc/agc.g4 @@ -41,320 +41,326 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* http://www.ibiblio.org/apollo/assembly_language_manual.html */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar agc; prog - : line+ EOF - ; + : line+ EOF + ; line - : comment_line - | blank_line - | instruction_line - | erase_line - | assignment_line - ; + : comment_line + | blank_line + | instruction_line + | erase_line + | assignment_line + ; blank_line - : label? eol - ; + : label? eol + ; comment_line - : ws? comment eol - ; - // an instruction "line" can span many lines in the file, and can have comment lines in the middle of it + : ws? comment eol + ; + +// an instruction "line" can span many lines in the file, and can have comment lines in the middle of it instruction_line - : label? ws opcodes (eol comment_line)? argument (eol argument)* eol - ; + : label? ws opcodes (eol comment_line)? argument (eol argument)* eol + ; // erase can be specified with no variable erase_line - : variable? ws ERASE (ws? expression)* (ws comment)? eol - ; + : variable? ws ERASE (ws? expression)* (ws comment)? eol + ; // assignment with no RHS is legal assignment_line - : variable ws? (EQUAL | EQUALS) (ws? expression)* (ws comment)? eol - ; + : variable ws? (EQUAL | EQUALS) (ws? expression)* (ws comment)? eol + ; opcodes - : opcode (ws opcode)? - ; + : opcode (ws opcode)? + ; argument - : (ws expression)* (ws comment)? - ; + : (ws expression)* (ws comment)? + ; ws - : WS - ; + : WS + ; eol - : WS? EOL - ; + : WS? EOL + ; comment - : COMMENT - ; + : COMMENT + ; label - : LABEL - | register_ - | standard_opcode - | pseudo_opcode - ; + : LABEL + | register_ + | standard_opcode + | pseudo_opcode + ; variable - : LABEL - | register_ - | standard_opcode - | pseudo_opcode - | LPAREN LABEL RPAREN - | variable LPAREN LABEL RPAREN - ; + : LABEL + | register_ + | standard_opcode + | pseudo_opcode + | LPAREN LABEL RPAREN + | variable LPAREN LABEL RPAREN + ; expression - : multiplyingExpression (ws? (PLUS | MINUS) ws? multiplyingExpression)* - ; + : multiplyingExpression (ws? (PLUS | MINUS) ws? multiplyingExpression)* + ; multiplyingExpression - : atom (ws? (TIMES | DIV) ws? atom)* - ; + : atom (ws? (TIMES | DIV) ws? atom)* + ; atom - : inte - | decimal - | variable - | label - | register_ - ; + : inte + | decimal + | variable + | label + | register_ + ; inte - : INTE - ; + : INTE + ; decimal - : (PLUS | MINUS)? DECIMAL - ; + : (PLUS | MINUS)? DECIMAL + ; register_ - : A - | L - | Q - | EB - | FB - | Z - | BB - | ARUPT - | LRUPT - | QRUPT - | QRUPT - | BBRUPT - | BRUPT - | CYR - | SR - | CYL - | EDOP - | TIME2 - | TIME1 - | TIME3 - | TIME4 - | TIME5 - | TIME6 - | CDUX - | CDUY - | CDUZ - | OPTY - | OPTX - | PIPAX - | PIPAY - | PIPAZ - | QMRHCCTR - | RHCP - | PMRHCCTR - | RHCY - | RMRHCCTR - | RHCR - | INLINK - | RNRAD - | GYROCTR - | GYROCMD - | CDUXCMD - | CDUYCMD - | CDUZCMD - | OPTYCMD - | OPTXCMD - | THRUST - | LEMONM - | OUTLINK - | ALTM - ; + : A + | L + | Q + | EB + | FB + | Z + | BB + | ARUPT + | LRUPT + | QRUPT + | QRUPT + | BBRUPT + | BRUPT + | CYR + | SR + | CYL + | EDOP + | TIME2 + | TIME1 + | TIME3 + | TIME4 + | TIME5 + | TIME6 + | CDUX + | CDUY + | CDUZ + | OPTY + | OPTX + | PIPAX + | PIPAY + | PIPAZ + | QMRHCCTR + | RHCP + | PMRHCCTR + | RHCY + | RMRHCCTR + | RHCR + | INLINK + | RNRAD + | GYROCTR + | GYROCMD + | CDUXCMD + | CDUYCMD + | CDUZCMD + | OPTYCMD + | OPTXCMD + | THRUST + | LEMONM + | OUTLINK + | ALTM + ; opcode - : standard_opcode - | pseudo_opcode - | axt_opcode - ; - // Address to Index + : standard_opcode + | pseudo_opcode + | axt_opcode + ; + +// Address to Index axt_opcode - : AXTC1 - | AXTC2 - ; + : AXTC1 + | AXTC2 + ; pseudo_opcode - : K1DNADR - | K2DNADR - | K3DNADR - | K4DNADR - | K5DNADR - | K6DNADR - | DNCHAN - | DNPTR - | M1DNADR - | M2DNADR - | M3DNADR - | M4DNADR - | M5DNADR - | M6DNADR - | MDNCHAN - | MDNPTR - | K2DEC - | K2DECS - | K2DNADR - | M2DNADR - | K2FCADR // embed a double-word constant - | K3DNADR - | M3DNADR - | K4DNADR - | M4DNADR - | K5DNADR - | M5DNADR - | K6DNADR - | M6DNADR - | BANK - | BLOCK - | BNKSUM - | COUNT - | COUNTS - | DEC // embed a single-precision (SP) constant - | K2DEC // embed a double precision constant - | K2FCADR // embed a double-word constant, to be used later by the DTCF instruction - | OCT // embed an octal constant - | SETLOC - | SUBRO - ; + : K1DNADR + | K2DNADR + | K3DNADR + | K4DNADR + | K5DNADR + | K6DNADR + | DNCHAN + | DNPTR + | M1DNADR + | M2DNADR + | M3DNADR + | M4DNADR + | M5DNADR + | M6DNADR + | MDNCHAN + | MDNPTR + | K2DEC + | K2DECS + | K2DNADR + | M2DNADR + | K2FCADR // embed a double-word constant + | K3DNADR + | M3DNADR + | K4DNADR + | M4DNADR + | K5DNADR + | M5DNADR + | K6DNADR + | M6DNADR + | BANK + | BLOCK + | BNKSUM + | COUNT + | COUNTS + | DEC // embed a single-precision (SP) constant + | K2DEC // embed a double precision constant + | K2FCADR // embed a double-word constant, to be used later by the DTCF instruction + | OCT // embed an octal constant + | SETLOC + | SUBRO + ; standard_opcode - : TC // transfer control - | TCR // transfer control - | CCS // Count, Compare, and Skip - | TCF // Transfer Control to Fixed - | DAS // Double Add to Storage - | LXCH // Exchange L and K - | INCR // Increment - | AD // add to accumulator - | ADS // Add to Storage - | CA // Clear and Add - | CS // Clear and Subtract - | INDEX // Index - | DXCH // double exchange - | TS // Transfer to Storage - | XCH // Exchange A and K - | AD // AD - | MASK // Mask A by K - | MSK // Mask A by K - | READ // Read Channel KC - | WRITE // Write Channel KC - | RAND // Read and Mask - | WAND // Write and Mask - | ROR // Read and Superimpose - | WOR // Write and Superimpose - | RXOR // Read and Invert - | EDRUPT // for machine checkout only - | BZF // Branch Zero to Fixed - | MSU // Modular Subtract - | QXCH // Exchange Q and K - | AUG // augment - | DIM // diminish - | DCA // Double Clear and Add - | DCS // Double Clear and Subtract - | SU // subtract - | BZMF // Branch Zero or Minus to Fixed - | MP // Multiply - | XXALQ // Execute Extracode Using A, L, and Q - | XLQ // Execute Using L and Q - | RETURN // Return from Subroutine - | RELINT // Enable Interrupts - | INHINT // Disable Interrupts - | EXTEND // extend - | NOOP // No-operation - | DDOUBL // Double Precision Double - | DTCF // Double Transfer Control, Switching F Bank - | COM // Complement the Contents of A - | ZL // Zero L - | RESUME // Resume Interrupted Program - | DTCB // Double Transfer Control, Switching Both Banks - | OVSK // Overflow Skip - | TCAA // Transfer Control to Address in A - | DOUBLE // Double the Contents of A - | ZQ // Zero Q - | DCOM // Double Complement - | SQUARE // Square the Contents of A - | PINC // Add +1 in 1's-complement fashion to a counter - | PCDU // Add +1 in 2's-complement fashion to a counter. - | MINC // Add -1 in 1's-complement fashion to a counter. - | MCDU // Add -1 in 2's-complement fashion to a counter. - | DINC // look at the docs - | SHINC // look at the docs - | SHANC // look at the docs - | INOTRD // look at the docs - | INOTLD // look at the docs - | FETCH // look at the docs - | STORE // look at the docs - | GOJ // Jump to location 04000 octal. - | TCSAJ // look at the docs - | CAF // Clear and Add Fixed - | CAE // Clear and Add Erasable - | CADR - | DMOVE - | VMOVE - | SMOVE - | DSU - | RTB - | ITC - | NOLOD - | EXIT - | BPL - | SIN - | COS - | CAD - | TEST - | VXSC - | ITC - | DAD - | VXV - | VAD - | DAD - | BPL - | DMP - | BOV - | VXV - | VAD - | UNIT - | OCTAL - | ADRES - | ABVAL - | COMP - | DV // Divide - | NDX // INDEX (alternative syntax) - | POUT // look at the docs - | MOUT // look at the docs - | ZOUT // look at the docs - | LODON // this is used in a couple places in a "2-opcodes on a line" format - | TSLT // this is used in a couple places in a "2-opcodes on a line" format - ; + : TC // transfer control + | TCR // transfer control + | CCS // Count, Compare, and Skip + | TCF // Transfer Control to Fixed + | DAS // Double Add to Storage + | LXCH // Exchange L and K + | INCR // Increment + | AD // add to accumulator + | ADS // Add to Storage + | CA // Clear and Add + | CS // Clear and Subtract + | INDEX // Index + | DXCH // double exchange + | TS // Transfer to Storage + | XCH // Exchange A and K + | AD // AD + | MASK // Mask A by K + | MSK // Mask A by K + | READ // Read Channel KC + | WRITE // Write Channel KC + | RAND // Read and Mask + | WAND // Write and Mask + | ROR // Read and Superimpose + | WOR // Write and Superimpose + | RXOR // Read and Invert + | EDRUPT // for machine checkout only + | BZF // Branch Zero to Fixed + | MSU // Modular Subtract + | QXCH // Exchange Q and K + | AUG // augment + | DIM // diminish + | DCA // Double Clear and Add + | DCS // Double Clear and Subtract + | SU // subtract + | BZMF // Branch Zero or Minus to Fixed + | MP // Multiply + | XXALQ // Execute Extracode Using A, L, and Q + | XLQ // Execute Using L and Q + | RETURN // Return from Subroutine + | RELINT // Enable Interrupts + | INHINT // Disable Interrupts + | EXTEND // extend + | NOOP // No-operation + | DDOUBL // Double Precision Double + | DTCF // Double Transfer Control, Switching F Bank + | COM // Complement the Contents of A + | ZL // Zero L + | RESUME // Resume Interrupted Program + | DTCB // Double Transfer Control, Switching Both Banks + | OVSK // Overflow Skip + | TCAA // Transfer Control to Address in A + | DOUBLE // Double the Contents of A + | ZQ // Zero Q + | DCOM // Double Complement + | SQUARE // Square the Contents of A + | PINC // Add +1 in 1's-complement fashion to a counter + | PCDU // Add +1 in 2's-complement fashion to a counter. + | MINC // Add -1 in 1's-complement fashion to a counter. + | MCDU // Add -1 in 2's-complement fashion to a counter. + | DINC // look at the docs + | SHINC // look at the docs + | SHANC // look at the docs + | INOTRD // look at the docs + | INOTLD // look at the docs + | FETCH // look at the docs + | STORE // look at the docs + | GOJ // Jump to location 04000 octal. + | TCSAJ // look at the docs + | CAF // Clear and Add Fixed + | CAE // Clear and Add Erasable + | CADR + | DMOVE + | VMOVE + | SMOVE + | DSU + | RTB + | ITC + | NOLOD + | EXIT + | BPL + | SIN + | COS + | CAD + | TEST + | VXSC + | ITC + | DAD + | VXV + | VAD + | DAD + | BPL + | DMP + | BOV + | VXV + | VAD + | UNIT + | OCTAL + | ADRES + | ABVAL + | COMP + | DV // Divide + | NDX // INDEX (alternative syntax) + | POUT // look at the docs + | MOUT // look at the docs + | ZOUT // look at the docs + | LODON // this is used in a couple places in a "2-opcodes on a line" format + | TSLT // this is used in a couple places in a "2-opcodes on a line" format + ; // // labels can begin with + or -, letters or digits @@ -362,243 +368,787 @@ standard_opcode // labels can contain "&" as well as math symbols "+-*/" and "." // -A : 'A'; -ABVAL : 'ABVAL'; -AD : 'AD'; -ADRES : 'ADRES'; -ADS : 'ADS'; -ALTM : 'ALTM'; -ARUPT : 'ARUPT'; -AUG : 'AUG'; -AXTC1 : 'AXT,1'; -AXTC2 : 'AXT,2'; -BANK : 'BANK'; -BB : 'BB'; -BBRUPT : 'BBRUPT'; -BLOCK : 'BLOCK'; -BNKSUM : 'BNKSUM'; -BOV : 'BOV'; -BPL : 'BPL'; -BRUPT : 'BRUPT'; -BZF : 'BZF'; -BZMF : 'BZMF'; -CA : 'CA'; -CAD : 'CAD'; -CADR : 'CADR'; -CAE : 'CAE'; -CAF : 'CAF'; -CCS : 'CCS'; -CDUX : 'CDUX'; -CDUXCMD : 'CDUXCMD'; -CDUY : 'CDUY'; -CDUYCMD : 'CDUYCMD'; -CDUZ : 'CDUZ'; -CDUZCMD : 'CDUZCMD'; -COM : 'COM'; -COMP : 'COMP'; -COS : 'COS'; -COUNT : 'COUNT'; -COUNTS : 'COUNT*'; -CS : 'CS'; -CYL : 'CYL'; -CYR : 'CYR'; -DAD : 'DAD'; -DAS : 'DAS'; -DCA : 'DCA'; -DCOM : 'DCOM'; -DCS : 'DCS'; -DDOUBL : 'DDOUBL'; -DEC : 'DEC'; -DIM : 'DIM'; -DINC : 'DINC'; -DMOVE : 'DMOVE'; -DMP : 'DMP'; -DNCHAN : 'DNCHAN'; -DNPTR : 'DNPTR'; -DOUBLE : 'DOUBLE'; -DSU : 'DSU'; -DTCB : 'DTCB'; -DTCF : 'DTCF'; -DV : 'DV'; -DXCH : 'DXCH'; -EB : 'EB'; -EDOP : 'EDOP'; -EDRUPT : 'EDRUPT'; -EQUALS : 'EQUALS'; -ERASE : 'ERASE'; -EXIT : 'EXIT'; -EXTEND : 'EXTEND'; -FB : 'FB'; -FETCH : 'FETCH'; -GOJ : 'GOJ'; -GYROCMD : 'GYROCMD'; -GYROCTR : 'GYROCTR'; -INCR : 'INCR'; -INDEX : 'INDEX'; -INHINT : 'INHINT'; -INLINK : 'INLINK'; -INOTLD : 'INOTLD'; -INOTRD : 'INOTRD'; -ITC : 'ITC'; -K1DNADR : '1DNADR'; -K2DEC : '2DEC'; -K2DECS : '2DEC*'; -K2DNADR : '2DNADR'; -K2FCADR : '2FCADR'; -K3DNADR : '3DNADR'; -K4DNADR : '4DNADR'; -K5DNADR : '5DNADR'; -K6DNADR : '6DNADR'; -L : 'L'; -LEMONM : 'LEMONM'; -LODON : 'LODON'; -LRUPT : 'LRUPT'; -LXCH : 'LXCH'; -M1DNADR : '-1DNADR'; -M2DNADR : '-2DNADR'; -M3DNADR : '-3DNADR'; -M4DNADR : '-4DNADR'; -M5DNADR : '-5DNADR'; -M6DNADR : '-6DNADR'; -MASK : 'MASK'; -MCDU : 'MCDU'; -MDNCHAN : '-DNCHAN'; -MDNPTR : '-DNPTR'; -MINC : 'MINC'; -MOUT : 'MOUT'; -MP : 'MP'; -MSK : 'MSK'; -MSU : 'MSU'; -NDX : 'NDX'; -NOLOD : 'NOLOD'; -NOOP : 'NOOP'; -OCT : 'OCT'; -OCTAL : 'OCTAL'; -OPTX : 'OPTX'; -OPTXCMD : 'OPTXCMD'; -OPTY : 'OPTY'; -OPTYCMD : 'OPTYCMD'; -OUTLINK : 'OUTLINK'; -OVSK : 'OVSK'; -PCDU : 'PCDU'; -PINC : 'PINC'; -PIPAX : 'PIPAX'; -PIPAY : 'PIPAY'; -PIPAZ : 'PIPAZ'; -PMRHCCTR : 'P-RHCCTR'; -POUT : 'POUT'; -Q : 'Q'; -QMRHCCTR : 'Q-RHCCTR'; -QRUPT : 'QRUPT'; -QXCH : 'QXCH'; -RMRHCCTR : 'R-RHCCTR'; -RAND : 'RAND'; -READ : 'READ'; -RELINT : 'RELINT'; -RESUME : 'RESUME'; -RETURN : 'RETURN'; -RHCP : 'RHCP'; -RHCR : 'RHCR'; -RHCY : 'RHCY'; -RNRAD : 'RNRAD'; -ROR : 'ROR'; -RTB : 'RTB'; -RXOR : 'RXOR'; -SETLOC : 'SETLOC'; -SHANC : 'SHANC'; -SHINC : 'SHINC'; -SIN : 'SIN'; -SMOVE : 'SMOVE'; -SQUARE : 'SQUARE'; -SR : 'SR'; -STORE : 'STORE'; -SU : 'SU'; -SUBRO : 'SUBRO'; -TC : 'TC'; -TCAA : 'TCAA'; -TCF : 'TCF'; -TCR : 'TCR'; -TCSAJ : 'TCSAJ'; -TEST : 'TEST'; -THRUST : 'THRUST'; -TIME1 : 'TIME1'; -TIME2 : 'TIME2'; -TIME3 : 'TIME3'; -TIME4 : 'TIME4'; -TIME5 : 'TIME5'; -TIME6 : 'TIME6'; -TS : 'TS'; -TSLT : 'TSLT'; -UNIT : 'UNIT'; -VAD : 'VAD'; -VMOVE : 'VMOVE'; -VXSC : 'VXSC'; -VXV : 'VXV'; -WAND : 'WAND'; -WOR : 'WOR'; -WRITE : 'WRITE'; -XCH : 'XCH'; -XLQ : 'XLQ'; -XXALQ : 'XXALQ'; -Z : 'Z'; -ZL : 'ZL'; -ZOUT : 'ZOUT'; -ZQ : 'ZQ'; +A + : 'A' + ; + +ABVAL + : 'ABVAL' + ; + +AD + : 'AD' + ; + +ADRES + : 'ADRES' + ; + +ADS + : 'ADS' + ; + +ALTM + : 'ALTM' + ; + +ARUPT + : 'ARUPT' + ; + +AUG + : 'AUG' + ; + +AXTC1 + : 'AXT,1' + ; + +AXTC2 + : 'AXT,2' + ; + +BANK + : 'BANK' + ; + +BB + : 'BB' + ; + +BBRUPT + : 'BBRUPT' + ; + +BLOCK + : 'BLOCK' + ; + +BNKSUM + : 'BNKSUM' + ; + +BOV + : 'BOV' + ; + +BPL + : 'BPL' + ; + +BRUPT + : 'BRUPT' + ; + +BZF + : 'BZF' + ; + +BZMF + : 'BZMF' + ; + +CA + : 'CA' + ; + +CAD + : 'CAD' + ; + +CADR + : 'CADR' + ; + +CAE + : 'CAE' + ; + +CAF + : 'CAF' + ; + +CCS + : 'CCS' + ; + +CDUX + : 'CDUX' + ; + +CDUXCMD + : 'CDUXCMD' + ; + +CDUY + : 'CDUY' + ; + +CDUYCMD + : 'CDUYCMD' + ; + +CDUZ + : 'CDUZ' + ; + +CDUZCMD + : 'CDUZCMD' + ; + +COM + : 'COM' + ; + +COMP + : 'COMP' + ; + +COS + : 'COS' + ; + +COUNT + : 'COUNT' + ; + +COUNTS + : 'COUNT*' + ; + +CS + : 'CS' + ; + +CYL + : 'CYL' + ; + +CYR + : 'CYR' + ; + +DAD + : 'DAD' + ; + +DAS + : 'DAS' + ; + +DCA + : 'DCA' + ; + +DCOM + : 'DCOM' + ; + +DCS + : 'DCS' + ; + +DDOUBL + : 'DDOUBL' + ; + +DEC + : 'DEC' + ; + +DIM + : 'DIM' + ; + +DINC + : 'DINC' + ; + +DMOVE + : 'DMOVE' + ; + +DMP + : 'DMP' + ; + +DNCHAN + : 'DNCHAN' + ; + +DNPTR + : 'DNPTR' + ; + +DOUBLE + : 'DOUBLE' + ; + +DSU + : 'DSU' + ; + +DTCB + : 'DTCB' + ; + +DTCF + : 'DTCF' + ; + +DV + : 'DV' + ; + +DXCH + : 'DXCH' + ; + +EB + : 'EB' + ; + +EDOP + : 'EDOP' + ; + +EDRUPT + : 'EDRUPT' + ; + +EQUALS + : 'EQUALS' + ; + +ERASE + : 'ERASE' + ; + +EXIT + : 'EXIT' + ; + +EXTEND + : 'EXTEND' + ; + +FB + : 'FB' + ; + +FETCH + : 'FETCH' + ; + +GOJ + : 'GOJ' + ; + +GYROCMD + : 'GYROCMD' + ; + +GYROCTR + : 'GYROCTR' + ; + +INCR + : 'INCR' + ; + +INDEX + : 'INDEX' + ; + +INHINT + : 'INHINT' + ; + +INLINK + : 'INLINK' + ; + +INOTLD + : 'INOTLD' + ; + +INOTRD + : 'INOTRD' + ; + +ITC + : 'ITC' + ; + +K1DNADR + : '1DNADR' + ; + +K2DEC + : '2DEC' + ; + +K2DECS + : '2DEC*' + ; + +K2DNADR + : '2DNADR' + ; + +K2FCADR + : '2FCADR' + ; + +K3DNADR + : '3DNADR' + ; + +K4DNADR + : '4DNADR' + ; + +K5DNADR + : '5DNADR' + ; + +K6DNADR + : '6DNADR' + ; + +L + : 'L' + ; + +LEMONM + : 'LEMONM' + ; + +LODON + : 'LODON' + ; + +LRUPT + : 'LRUPT' + ; + +LXCH + : 'LXCH' + ; + +M1DNADR + : '-1DNADR' + ; + +M2DNADR + : '-2DNADR' + ; + +M3DNADR + : '-3DNADR' + ; + +M4DNADR + : '-4DNADR' + ; + +M5DNADR + : '-5DNADR' + ; + +M6DNADR + : '-6DNADR' + ; + +MASK + : 'MASK' + ; + +MCDU + : 'MCDU' + ; + +MDNCHAN + : '-DNCHAN' + ; + +MDNPTR + : '-DNPTR' + ; + +MINC + : 'MINC' + ; + +MOUT + : 'MOUT' + ; + +MP + : 'MP' + ; + +MSK + : 'MSK' + ; + +MSU + : 'MSU' + ; + +NDX + : 'NDX' + ; + +NOLOD + : 'NOLOD' + ; + +NOOP + : 'NOOP' + ; + +OCT + : 'OCT' + ; + +OCTAL + : 'OCTAL' + ; + +OPTX + : 'OPTX' + ; + +OPTXCMD + : 'OPTXCMD' + ; + +OPTY + : 'OPTY' + ; + +OPTYCMD + : 'OPTYCMD' + ; + +OUTLINK + : 'OUTLINK' + ; + +OVSK + : 'OVSK' + ; + +PCDU + : 'PCDU' + ; + +PINC + : 'PINC' + ; + +PIPAX + : 'PIPAX' + ; + +PIPAY + : 'PIPAY' + ; + +PIPAZ + : 'PIPAZ' + ; + +PMRHCCTR + : 'P-RHCCTR' + ; + +POUT + : 'POUT' + ; + +Q + : 'Q' + ; + +QMRHCCTR + : 'Q-RHCCTR' + ; + +QRUPT + : 'QRUPT' + ; + +QXCH + : 'QXCH' + ; + +RMRHCCTR + : 'R-RHCCTR' + ; + +RAND + : 'RAND' + ; + +READ + : 'READ' + ; + +RELINT + : 'RELINT' + ; + +RESUME + : 'RESUME' + ; + +RETURN + : 'RETURN' + ; + +RHCP + : 'RHCP' + ; + +RHCR + : 'RHCR' + ; + +RHCY + : 'RHCY' + ; + +RNRAD + : 'RNRAD' + ; + +ROR + : 'ROR' + ; + +RTB + : 'RTB' + ; + +RXOR + : 'RXOR' + ; + +SETLOC + : 'SETLOC' + ; + +SHANC + : 'SHANC' + ; + +SHINC + : 'SHINC' + ; + +SIN + : 'SIN' + ; + +SMOVE + : 'SMOVE' + ; + +SQUARE + : 'SQUARE' + ; + +SR + : 'SR' + ; + +STORE + : 'STORE' + ; + +SU + : 'SU' + ; + +SUBRO + : 'SUBRO' + ; + +TC + : 'TC' + ; + +TCAA + : 'TCAA' + ; + +TCF + : 'TCF' + ; + +TCR + : 'TCR' + ; + +TCSAJ + : 'TCSAJ' + ; + +TEST + : 'TEST' + ; + +THRUST + : 'THRUST' + ; + +TIME1 + : 'TIME1' + ; + +TIME2 + : 'TIME2' + ; + +TIME3 + : 'TIME3' + ; + +TIME4 + : 'TIME4' + ; + +TIME5 + : 'TIME5' + ; + +TIME6 + : 'TIME6' + ; + +TS + : 'TS' + ; + +TSLT + : 'TSLT' + ; + +UNIT + : 'UNIT' + ; + +VAD + : 'VAD' + ; + +VMOVE + : 'VMOVE' + ; + +VXSC + : 'VXSC' + ; + +VXV + : 'VXV' + ; + +WAND + : 'WAND' + ; + +WOR + : 'WOR' + ; + +WRITE + : 'WRITE' + ; + +XCH + : 'XCH' + ; + +XLQ + : 'XLQ' + ; + +XXALQ + : 'XXALQ' + ; + +Z + : 'Z' + ; + +ZL + : 'ZL' + ; + +ZOUT + : 'ZOUT' + ; + +ZQ + : 'ZQ' + ; COMMENT - : '#' ~ [\r\n]* - ; + : '#' ~ [\r\n]* + ; EQUAL - : '=' - ; + : '=' + ; PLUS - : '+' - ; + : '+' + ; MINUS - : '-' - ; + : '-' + ; TIMES - : '*' - ; + : '*' + ; DIV - : '/' - ; + : '/' + ; COMMA - : ',' - ; + : ',' + ; LPAREN - : '(' - ; + : '(' + ; RPAREN - : ')' - ; + : ')' + ; EOL - : [\r\n]+ - ; + : [\r\n]+ + ; LABEL - : [a-zA-Z0-9_.+\\\-/*=&]+ - ; + : [a-zA-Z0-9_.+\\\-/*=&]+ + ; INTE - : [0-9]+ ('DEC' | 'D') - ; + : [0-9]+ ('DEC' | 'D') + ; DECIMAL - : [0-9]+ ('.' [0-9]+)? - | '.' [0-9]+ - ; + : [0-9]+ ('.' [0-9]+)? + | '.' [0-9]+ + ; WS - : [ \t]+ - ; - + : [ \t]+ + ; \ No newline at end of file diff --git a/alef/alef.g4 b/alef/alef.g4 index 4b70720913..7ccaed17c4 100644 --- a/alef/alef.g4 +++ b/alef/alef.g4 @@ -32,602 +32,604 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // http://doc.cat-v.org/plan_9/2nd_edition/papers/alef/ref +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar alef; program - : decllist? EOF - ; + : decllist? EOF + ; decllist - : decl+ - ; + : decl+ + ; decl - : tname vardecllist? ';' - | tname vardecl '(' arglist? ')' block - | tname adtfunc '(' arglist? ')' block - | tname vardecl '(' arglist? ')' ';' - | typespec ';' - | TYPEDEF ztname vardecl zargs? ';' - | TYPEDEF IDENTIFIER ';' - ; + : tname vardecllist? ';' + | tname vardecl '(' arglist? ')' block + | tname adtfunc '(' arglist? ')' block + | tname vardecl '(' arglist? ')' ';' + | typespec ';' + | TYPEDEF ztname vardecl zargs? ';' + | TYPEDEF IDENTIFIER ';' + ; zargs - : '(' arglist? ')' - ; + : '(' arglist? ')' + ; ztname - : tname - | AGGR - | ADT - | UNION - ; + : tname + | AGGR + | ADT + | UNION + ; adtfunc - : typename '.' name - | indsp typename '.' name - ; + : typename '.' name + | indsp typename '.' name + ; typespec - : AGGR ztag? '{' memberlist '}' ztag? - | UNION ztag? '{' memberlist '}' ztag? - | ADT ztag? zpolytype? '{' memberlist '}' ztag? - | ENUM ztag? '{' setlist '}' - ; + : AGGR ztag? '{' memberlist '}' ztag? + | UNION ztag? '{' memberlist '}' ztag? + | ADT ztag? zpolytype? '{' memberlist '}' ztag? + | ENUM ztag? '{' setlist '}' + ; ztag - : name - | typename - ; + : name + | typename + ; zpolytype - : '[' polytype ']' - ; + : '[' polytype ']' + ; polytype - : name - | name ',' polytype - ; + : name + | name ',' polytype + ; setlist - : sname? - | setlist ',' setlist - ; + : sname? + | setlist ',' setlist + ; sname - : name ('=' expr_)? - ; + : name ('=' expr_)? + ; name - : IDENTIFIER - ; + : IDENTIFIER + ; memberlist - : decl - | memberlist decl - ; + : decl + | memberlist decl + ; vardecllist - : ivardecl (',' ivardecl)* - ; + : ivardecl (',' ivardecl)* + ; ivardecl - : vardecl zinit? - ; + : vardecl zinit? + ; zinit - : '=' zelist - ; + : '=' zelist + ; zelist - : zexpr? - | '[' expr_ ']' expr_ - | '.' stag expr_ - | '{' zelist '}' - | '[' expr_ ']' '{' zelist '}' - | zelist ',' zelist - ; + : zexpr? + | '[' expr_ ']' expr_ + | '.' stag expr_ + | '{' zelist '}' + | '[' expr_ ']' '{' zelist '}' + | zelist ',' zelist + ; vardecl - : IDENTIFIER arrayspec? - | indsp IDENTIFIER arrayspec? - | '(' indsp IDENTIFIER arrayspec? ')' '(' arglist? ')' - | indsp '(' indsp IDENTIFIER arrayspec? ')' '(' arglist? ')' - ; + : IDENTIFIER arrayspec? + | indsp IDENTIFIER arrayspec? + | '(' indsp IDENTIFIER arrayspec? ')' '(' arglist? ')' + | indsp '(' indsp IDENTIFIER arrayspec? ')' '(' arglist? ')' + ; arrayspec - : ('[' zexpr? ']')+ - ; + : ('[' zexpr? ']')+ + ; indsp - : '*'+ - ; + : '*'+ + ; arglist - : arglistp* ',' arg - ; + : arglistp* ',' arg + ; arglistp - : arg - | '*' xtname - | '.' xtname - ; + : arg + | '*' xtname + | '.' xtname + ; arg - : xtname - | xtname indsp arrayspec? - | xtname '(' indsp ')' '(' arglist? ')' - | xtname indsp '(' indsp ')' '(' arglist? ')' - | TUPLE tuplearg - | xtname vardecl - | '.' '.' '.' - ; + : xtname + | xtname indsp arrayspec? + | xtname '(' indsp ')' '(' arglist? ')' + | xtname indsp '(' indsp ')' '(' arglist? ')' + | TUPLE tuplearg + | xtname vardecl + | '.' '.' '.' + ; tuplearg - : tname - | tname '(' indsp ')' '(' arglist? ')' - | tname vardecl - ; + : tname + | tname '(' indsp ')' '(' arglist? ')' + | tname vardecl + ; autolist - : autodecl+ - ; + : autodecl+ + ; autodecl - : xtname vardecllist? ';' - | TUPLE tname vardecllist? ';' - ; + : xtname vardecllist? ';' + | TUPLE tname vardecllist? ';' + ; block - : '{' autolist? slist? '}' - | '!' '{' autolist? slist? '}' - ; + : '{' autolist? slist? '}' + | '!' '{' autolist? slist? '}' + ; slist - : stmnt+ - ; + : stmnt+ + ; tbody - : '{' ctlist? '}' - | '!' '{' clist? '}' - ; + : '{' ctlist? '}' + | '!' '{' clist? '}' + ; ctlist - : tcase+ - ; + : tcase+ + ; tcase - : CASE typecast ':' slist? - | DEFAULT ':' slist? - ; + : CASE typecast ':' slist? + | DEFAULT ':' slist? + ; cbody - : '{' clist? '}' - | '!' '{' clist? '}' - ; + : '{' clist? '}' + | '!' '{' clist? '}' + ; clist - : case_+ - ; + : case_+ + ; case_ - : CASE expr_ ':' slist? - | DEFAULT ':' slist? - ; + : CASE expr_ ':' slist? + | DEFAULT ':' slist? + ; rbody - : stmnt - | IDENTIFIER block - ; + : stmnt + | IDENTIFIER block + ; zlab - : IDENTIFIER - ; + : IDENTIFIER + ; stmnt - : nlstmnt - | IDENTIFIER ':' stmnt - ; + : nlstmnt + | IDENTIFIER ':' stmnt + ; info - : ',' STRING_CONST - ; + : ',' STRING_CONST + ; nlstmnt - : zexpr? ';' - | block - | CHECK expr_ info? ';' - | ALLOC elist ';' - | UNALLOC elist ';' - | RESCUE rbody - | RAISE zlab? ';' - | GOTO IDENTIFIER ';' - | PROC elist ';' - | TASK elist ';' - | BECOME expr_ ';' - | ALT cbody - | RETURN zexpr? ';' - | FOR '(' zexpr? ';' zexpr? ';' zexpr? ')' stmnt - | WHILE '(' expr_ ')' stmnt - | DO stmnt WHILE '(' expr_ ')' - | IF '(' expr_ ')' stmnt - | IF '(' expr_ ')' stmnt ELSE stmnt - | PAR block - | SWITCH expr_ cbody - | TYPEOF expr_ tbody - | CONTINUE zconst? ';' - | BREAK zconst? ';' - ; + : zexpr? ';' + | block + | CHECK expr_ info? ';' + | ALLOC elist ';' + | UNALLOC elist ';' + | RESCUE rbody + | RAISE zlab? ';' + | GOTO IDENTIFIER ';' + | PROC elist ';' + | TASK elist ';' + | BECOME expr_ ';' + | ALT cbody + | RETURN zexpr? ';' + | FOR '(' zexpr? ';' zexpr? ';' zexpr? ')' stmnt + | WHILE '(' expr_ ')' stmnt + | DO stmnt WHILE '(' expr_ ')' + | IF '(' expr_ ')' stmnt + | IF '(' expr_ ')' stmnt ELSE stmnt + | PAR block + | SWITCH expr_ cbody + | TYPEOF expr_ tbody + | CONTINUE zconst? ';' + | BREAK zconst? ';' + ; zconst - : CONSTANT - ; + : CONSTANT + ; zexpr - : expr_ - ; + : expr_ + ; expr_ - : castexpr - | expr_ '*' expr_ - | expr_ '/' expr_ - | expr_ '%' expr_ - | expr_ '+' expr_ - | expr_ '-' expr_ - | expr_ '>>' expr_ - | expr_ '<<' expr_ - | expr_ '<' expr_ - | expr_ '>' expr_ - | expr_ '<=' expr_ - | expr_ '>=' expr_ - | expr_ '==' expr_ - | expr_ '!=' expr_ - | expr_ '&' expr_ - | expr_ '^' expr_ - | expr_ '|' expr_ - | expr_ '&&' expr_ - | expr_ '||' expr_ - | expr_ '=' expr_ - | expr_ ':=' expr_ - | expr_ '<-' '=' expr_ - | expr_ '+=' expr_ - | expr_ '-=' expr_ - | expr_ '*=' expr_ - | expr_ '/=' expr_ - | expr_ '%=' expr_ - | expr_ '>>=' expr_ - | expr_ '<<=' expr_ - | expr_ '&=' expr_ - | expr_ '|=' expr_ - | expr_ '^=' expr_ - | expr_ '::' expr_ - ; + : castexpr + | expr_ '*' expr_ + | expr_ '/' expr_ + | expr_ '%' expr_ + | expr_ '+' expr_ + | expr_ '-' expr_ + | expr_ '>>' expr_ + | expr_ '<<' expr_ + | expr_ '<' expr_ + | expr_ '>' expr_ + | expr_ '<=' expr_ + | expr_ '>=' expr_ + | expr_ '==' expr_ + | expr_ '!=' expr_ + | expr_ '&' expr_ + | expr_ '^' expr_ + | expr_ '|' expr_ + | expr_ '&&' expr_ + | expr_ '||' expr_ + | expr_ '=' expr_ + | expr_ ':=' expr_ + | expr_ '<-' '=' expr_ + | expr_ '+=' expr_ + | expr_ '-=' expr_ + | expr_ '*=' expr_ + | expr_ '/=' expr_ + | expr_ '%=' expr_ + | expr_ '>>=' expr_ + | expr_ '<<=' expr_ + | expr_ '&=' expr_ + | expr_ '|=' expr_ + | expr_ '^=' expr_ + | expr_ '::' expr_ + ; castexpr - : monexpr - | '(' typecast ')' castexpr - | '(' ALLOC typecast ')' castexpr - ; + : monexpr + | '(' typecast ')' castexpr + | '(' ALLOC typecast ')' castexpr + ; typecast - : xtname - | xtname indsp - | xtname '(' indsp ')' '(' arglist? ')' - | TUPLE tname - ; + : xtname + | xtname indsp + | xtname '(' indsp ')' '(' arglist? ')' + | TUPLE tname + ; monexpr - : term_ - | '*' castexpr - | '&' castexpr - | '+' castexpr - | '-' castexpr - | '--' castexpr - | ZEROX castexpr - | '++' castexpr - | '!' castexpr - | '~' castexpr - | SIZEOF monexpr - | '<-' castexpr - | '?' castexpr - ; + : term_ + | '*' castexpr + | '&' castexpr + | '+' castexpr + | '-' castexpr + | '--' castexpr + | ZEROX castexpr + | '++' castexpr + | '!' castexpr + | '~' castexpr + | SIZEOF monexpr + | '<-' castexpr + | '?' castexpr + ; ztelist - : telist - ; + : telist + ; telist - : tcomp (',' tcomp)* - ; + : tcomp (',' tcomp)* + ; tcomp - : expr_ - | '{' ztelist? '}' - ; + : expr_ + | '{' ztelist? '}' + ; term_ - : '(' telist ')' - | SIZEOF '(' typecast ')' - | term_ '(' zarlist? ')' - | term_ '[' expr_ ']' - | term_ '.' stag - | '.' typename '.' stag - | term_ '->' stag - | term_ '--' - | term_ '++' - | term_ '?' - | name - | '.' '.' '.' - | ARITHMETIC_CONST - | NIL - | CONSTANT - | enum_member - | STRING_CONST - | '$' STRING_CONST - ; + : '(' telist ')' + | SIZEOF '(' typecast ')' + | term_ '(' zarlist? ')' + | term_ '[' expr_ ']' + | term_ '.' stag + | '.' typename '.' stag + | term_ '->' stag + | term_ '--' + | term_ '++' + | term_ '?' + | name + | '.' '.' '.' + | ARITHMETIC_CONST + | NIL + | CONSTANT + | enum_member + | STRING_CONST + | '$' STRING_CONST + ; stag - : IDENTIFIER - | typename - ; + : IDENTIFIER + | typename + ; zarlist - : elist - ; + : elist + ; elist - : expr_ - | elist ',' expr_ - ; + : expr_ + | elist ',' expr_ + ; tlist - : typecast - | typecast ',' tlist - ; + : typecast + | typecast ',' tlist + ; tname - : sclass? xtname - | sclass? TUPLE '(' tlist ')' - | sclass? '(' tlist ')' - ; + : sclass? xtname + | sclass? TUPLE '(' tlist ')' + | sclass? '(' tlist ')' + ; variant - : typecast - | typecast ',' variant - ; + : typecast + | typecast ',' variant + ; xtname - : INT - | UINT - | SINT - | USINT - | BYTE - | FLOAT - | VOID - | typename - | typename '[' variant ']' - | CHAN '(' variant ')' bufdim? - ; + : INT + | UINT + | SINT + | USINT + | BYTE + | FLOAT + | VOID + | typename + | typename '[' variant ']' + | CHAN '(' variant ')' bufdim? + ; bufdim - : '[' expr_ ']' - ; + : '[' expr_ ']' + ; sclass - : EXTERN - | INTERN - | PRIVATE - ; + : EXTERN + | INTERN + | PRIVATE + ; typename - : IDENTIFIER - ; + : IDENTIFIER + ; enum_member - : IDENTIFIER - ; + : IDENTIFIER + ; ADT - : 'adt' - ; + : 'adt' + ; AGGR - : 'aggr' - ; + : 'aggr' + ; ALLOC - : 'alloc' - ; + : 'alloc' + ; ALT - : 'alt' - ; + : 'alt' + ; BECOME - : 'become' - ; + : 'become' + ; BREAK - : 'break' - ; + : 'break' + ; BYTE - : 'byte' - ; + : 'byte' + ; CASE - : 'case' - ; + : 'case' + ; CHAN - : 'chan' - ; + : 'chan' + ; CHECK - : 'check' - ; + : 'check' + ; CONTINUE - : 'continue' - ; + : 'continue' + ; DEFAULT - : 'default' - ; + : 'default' + ; DO - : 'do' - ; + : 'do' + ; ELSE - : 'else' - ; + : 'else' + ; ENUM - : 'enum' - ; + : 'enum' + ; EXTERN - : 'extern' - ; + : 'extern' + ; FLOAT - : 'float' - ; + : 'float' + ; FOR - : 'for' - ; + : 'for' + ; GOTO - : 'goto' - ; + : 'goto' + ; IF - : 'if' - ; + : 'if' + ; INT - : 'int' - ; + : 'int' + ; INTERN - : 'intern' - ; + : 'intern' + ; LINT - : 'lint' - ; + : 'lint' + ; NIL - : 'nil' - ; + : 'nil' + ; PAR - : 'par' - ; + : 'par' + ; PROC - : 'proc' - ; + : 'proc' + ; RAISE - : 'raise' - ; + : 'raise' + ; RESCUE - : 'rescue' - ; + : 'rescue' + ; RETURN - : 'return' - ; + : 'return' + ; SINT - : 'sint' - ; + : 'sint' + ; SIZEOF - : 'sizeof' - ; + : 'sizeof' + ; SWITCH - : 'switch' - ; + : 'switch' + ; TASK - : 'task' - ; + : 'task' + ; TUPLE - : 'tuple' - ; + : 'tuple' + ; TYPEDEF - : 'typedef' - ; + : 'typedef' + ; TYPEOF - : 'typeof' - ; + : 'typeof' + ; UINT - : 'uint' - ; + : 'uint' + ; ULINT - : 'ulint' - ; + : 'ulint' + ; UNALLOC - : 'unalloc' - ; + : 'unalloc' + ; UNION - : 'union' - ; + : 'union' + ; USINT - : 'usint' - ; + : 'usint' + ; VOID - : 'void' - ; + : 'void' + ; WHILE - : 'while' - ; + : 'while' + ; ZEROX - : 'zerox' - ; + : 'zerox' + ; PRIVATE - : 'private' - ; + : 'private' + ; IDENTIFIER - : [a-zA-Z_] [a-zA-Z_0-9]* - ; + : [a-zA-Z_] [a-zA-Z_0-9]* + ; STRING_CONST - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; CONSTANT - : '\'' ~ '\''* '\'' - ; + : '\'' ~ '\''* '\'' + ; ARITHMETIC_CONST - : DIGIT+ ('.' DIGIT*)? ('e' DIGIT+)? - ; + : DIGIT+ ('.' DIGIT*)? ('e' DIGIT+)? + ; fragment DIGIT - : [0-9] - ; + : [0-9] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/algol60/algol60.g4 b/algol60/algol60.g4 index dc5ce861c2..99d8df6f41 100644 --- a/algol60/algol60.g4 +++ b/algol60/algol60.g4 @@ -1,6 +1,11 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar algol60; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} // Derived from the authoratitive source ISO 1538 // You can download a free copy at: @@ -12,254 +17,910 @@ options { caseInsensitive = true; } // TBD // 1.1 -empty_ : ; -fragment Basic_symbol : Letter | Digit | Logical_value_f | Delimiter ; +empty_ + : + ; + +fragment Basic_symbol + : Letter + | Digit + | Logical_value_f + | Delimiter + ; // The alphabet can be extended in any way. // If memory serves me, I recall no case sensitivity. -Array_ : 'array'; -Begin_ : 'begin'; -Boolean_ : 'boolean'; -Comment_ : 'comment'; -Do_ : 'do'; -Else_ : 'else'; -End_ : 'end'; -False_ : 'false'; -For_ : 'for'; -Goto_ : 'go' Ws* 'to'; -If_ : 'if'; -Integer_ : 'integer'; -Label_ : 'label'; -Own_ : 'own'; -Procedure_ : 'procedure'; -Real_ : 'real'; -Step_ : 'step'; -String_ : 'string'; -Switch_ : 'switch'; -Then_ : 'then'; -True_ : 'true'; -Until_ : 'until'; -Value_ : 'value'; -While_ : 'while'; - -And_ : '⋀' | '&' ; // '⊃' | ∧ | '⋀' -Assign_ : ':=' ; -Colon_ : ':' ; -Comma_ : ',' ; -Dot_ : '.' ; -Divide_ : '/' | '÷' ; -Eor_ : '^=' ; -Eq_ : '=' ; -Equiv_ : '≡' ; -Exp_ : '↑' | '^' ; -Gt_ : '>' ; -Ge_ : '≥' | '>=' ; -Includes_ : '⊃' ; -Lb_ : '[' ; -Le_ : '<=' | '≤' ; -LP_ : '(' ; -Lt_ : '<' ; -Minus_ : '-' | '–'; -Mult_ : '×' | '*' ; -Ne_ : '≠' | '!=' ; -Not_ : '¬' | '!' ; -Or_ : '⋁' | '|' ; -Plus_ : '+' ; -Rb_ : ']' ; -Rp_ : ')' ; -Semi_ : ';' ; -Underscore_ : '_' ; +Array_ + : 'array' + ; + +Begin_ + : 'begin' + ; + +Boolean_ + : 'boolean' + ; + +Comment_ + : 'comment' + ; + +Do_ + : 'do' + ; + +Else_ + : 'else' + ; + +End_ + : 'end' + ; + +False_ + : 'false' + ; + +For_ + : 'for' + ; + +Goto_ + : 'go' Ws* 'to' + ; + +If_ + : 'if' + ; + +Integer_ + : 'integer' + ; + +Label_ + : 'label' + ; + +Own_ + : 'own' + ; + +Procedure_ + : 'procedure' + ; + +Real_ + : 'real' + ; + +Step_ + : 'step' + ; + +String_ + : 'string' + ; + +Switch_ + : 'switch' + ; + +Then_ + : 'then' + ; + +True_ + : 'true' + ; + +Until_ + : 'until' + ; + +Value_ + : 'value' + ; + +While_ + : 'while' + ; + +And_ + : '⋀' + | '&' + ; // '⊃' | ∧ | '⋀' + +Assign_ + : ':=' + ; + +Colon_ + : ':' + ; + +Comma_ + : ',' + ; + +Dot_ + : '.' + ; + +Divide_ + : '/' + | '÷' + ; + +Eor_ + : '^=' + ; + +Eq_ + : '=' + ; + +Equiv_ + : '≡' + ; + +Exp_ + : '↑' + | '^' + ; + +Gt_ + : '>' + ; + +Ge_ + : '≥' + | '>=' + ; + +Includes_ + : '⊃' + ; + +Lb_ + : '[' + ; + +Le_ + : '<=' + | '≤' + ; + +LP_ + : '(' + ; + +Lt_ + : '<' + ; + +Minus_ + : '-' + | '–' + ; + +Mult_ + : '×' + | '*' + ; + +Ne_ + : '≠' + | '!=' + ; + +Not_ + : '¬' + | '!' + ; + +Or_ + : '⋁' + | '|' + ; + +Plus_ + : '+' + ; + +Rb_ + : ']' + ; + +Rp_ + : ')' + ; + +Semi_ + : ';' + ; + +Underscore_ + : '_' + ; // 2.1 -fragment Letter : [a-z] - | '_' // an extension. - ; +fragment Letter + : [a-z] + | '_' // an extension. + ; // 2.2.1 -fragment Digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ; -fragment ULCorner_f options { caseInsensitive=false; } : '\u231C' ; -ULCorner : ULCorner_f ; -fragment URCorner_f options { caseInsensitive=false; } : '\u231D' ; -URCorner : URCorner_f ; +fragment Digit + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + | '8' + | '9' + ; + +fragment ULCorner_f options { + caseInsensitive = false; +} + : '\u231C'; + +ULCorner + : ULCorner_f + ; + +fragment URCorner_f options { + caseInsensitive = false; +} + : '\u231D'; + +URCorner + : URCorner_f + ; // 2.2.2 -fragment Logical_value_f : True_ | False_ ; -Logical_value : Logical_value_f ; +fragment Logical_value_f + : True_ + | False_ + ; + +Logical_value + : Logical_value_f + ; // 2.3 -fragment Delimiter : Operator | Separator | Bracket | Declarator | Specificator ; -fragment Operator : Arithmetic_operator | Relational_operator_f | Logical_operator | Sequential_operator ; -fragment Arithmetic_operator : Plus_ | Minus_ | Mult_ | Divide_ | Exp_ ; -fragment Relational_operator_f : Lt_ | Le_ | Eq_ | Ne_ | Gt_ | Ge_ ; -Relational_operator : Relational_operator_f ; -fragment Logical_operator : Equiv_ | Includes_ | Or_ | And_ | Not_ ; -fragment Sequential_operator : Goto_ | If_ | Then_ | Else_ | For_ | Do_ ; -fragment Separator : Comma_ | Dot_ | '10' | Colon_ | Semi_ | Assign_ | Underscore_ | Step_ | Until_ | While_ | Comment_ ; -fragment Bracket : LP_ | Rp_ | Lb_ | Rb_ | '⌈' | '⌝' | Begin_ | End_ ; -fragment Declarator : Own_ | Boolean_ | Integer_ | Real_ | Array_ | Switch_ | Procedure_ ; -fragment Specificator : String_ | Label_ | Value_ ; +fragment Delimiter + : Operator + | Separator + | Bracket + | Declarator + | Specificator + ; + +fragment Operator + : Arithmetic_operator + | Relational_operator_f + | Logical_operator + | Sequential_operator + ; + +fragment Arithmetic_operator + : Plus_ + | Minus_ + | Mult_ + | Divide_ + | Exp_ + ; + +fragment Relational_operator_f + : Lt_ + | Le_ + | Eq_ + | Ne_ + | Gt_ + | Ge_ + ; + +Relational_operator + : Relational_operator_f + ; + +fragment Logical_operator + : Equiv_ + | Includes_ + | Or_ + | And_ + | Not_ + ; + +fragment Sequential_operator + : Goto_ + | If_ + | Then_ + | Else_ + | For_ + | Do_ + ; + +fragment Separator + : Comma_ + | Dot_ + | '10' + | Colon_ + | Semi_ + | Assign_ + | Underscore_ + | Step_ + | Until_ + | While_ + | Comment_ + ; + +fragment Bracket + : LP_ + | Rp_ + | Lb_ + | Rb_ + | '⌈' + | '⌝' + | Begin_ + | End_ + ; + +fragment Declarator + : Own_ + | Boolean_ + | Integer_ + | Real_ + | Array_ + | Switch_ + | Procedure_ + ; + +fragment Specificator + : String_ + | Label_ + | Value_ + ; + // Antlr restriction cannot use ~Semi_. -Comment : Comment_ ~';'+ Semi_ -> channel(HIDDEN) ; +Comment + : Comment_ ~';'+ Semi_ -> channel(HIDDEN) + ; // 2.4.1 // rewritten to avoid MLR. -Identifier : (Letter | Digit)+ ; +Identifier + : (Letter | Digit)+ + ; // 2.5.1 // rewritten to avoid MLR. -Unsigned_integer : Digit+ ; -integer : Unsigned_integer | Plus_ Unsigned_integer | Minus_ Unsigned_integer ; -Decimal_fraction : Dot_ Unsigned_integer ; +Unsigned_integer + : Digit+ + ; + +integer + : Unsigned_integer + | Plus_ Unsigned_integer + | Minus_ Unsigned_integer + ; + +Decimal_fraction + : Dot_ Unsigned_integer + ; + // unfold -Exponential_part : '10' (Unsigned_integer | Plus_ Unsigned_integer | Minus_ Unsigned_integer) ; -Decimal_number : Unsigned_integer | Decimal_fraction | Unsigned_integer Decimal_fraction ; -Unsigned_number : Decimal_number | Exponential_part | Decimal_number Exponential_part ; -number : Unsigned_number | Plus_ Unsigned_number | Minus_ Unsigned_number ; +Exponential_part + : '10' (Unsigned_integer | Plus_ Unsigned_integer | Minus_ Unsigned_integer) + ; + +Decimal_number + : Unsigned_integer + | Decimal_fraction + | Unsigned_integer Decimal_fraction + ; + +Unsigned_number + : Decimal_number + | Exponential_part + | Decimal_number Exponential_part + ; + +number + : Unsigned_number + | Plus_ Unsigned_number + | Minus_ Unsigned_number + ; // 2.6.1 -fragment Proper_string options { caseInsensitive=false; } : ~('\u231C' | '\u231D')* ; -fragment Open_string : Proper_string | Proper_string Closed_string Open_string ; -fragment Closed_string : ULCorner Open_string URCorner ; -fragment StdString : Closed_string | Closed_string StdString ; -String : StdString // String according to spec. - | '"' ~'"'* '"' | '`' ~'\''* '\'' ; // Additional non-standard strings used in examples. +fragment Proper_string options { + caseInsensitive = false; +} + : ~('\u231C' | '\u231D')*; + +fragment Open_string + : Proper_string + | Proper_string Closed_string Open_string + ; + +fragment Closed_string + : ULCorner Open_string URCorner + ; + +fragment StdString + : Closed_string + | Closed_string StdString + ; + +String + : StdString // String according to spec. + | '"' ~'"'* '"' + | '`' ~'\''* '\'' + ; // Additional non-standard strings used in examples. // 3 -expression : arithmetic_expression | boolean_expression | designational_expression ; +expression + : arithmetic_expression + | boolean_expression + | designational_expression + ; // 3.1 -variable_identifier : Identifier ; -simple_variable : variable_identifier ; -subscript_expression : arithmetic_expression ; -subscript_list : subscript_expression | subscript_list Comma_ subscript_expression ; -array_identifier : Identifier ; -subscripted_variable : array_identifier Lb_ subscript_list Rb_ ; -variable : simple_variable | subscripted_variable ; +variable_identifier + : Identifier + ; + +simple_variable + : variable_identifier + ; + +subscript_expression + : arithmetic_expression + ; + +subscript_list + : subscript_expression + | subscript_list Comma_ subscript_expression + ; + +array_identifier + : Identifier + ; + +subscripted_variable + : array_identifier Lb_ subscript_list Rb_ + ; + +variable + : simple_variable + | subscripted_variable + ; // 3.2.1 -procedure_identifier : Identifier ; +procedure_identifier + : Identifier + ; + // The following rules replaced because there is no context sensitive lexing. //letter_string : letter | letter_string letter ; //parameter_delimiter : Comma_ | Rp_ letter_string Colon_ LP_ ; -parameter_delimiter : Comma_ | Rp_ Identifier Colon_ LP_ ; -actual_parameter : String | expression | array_identifier | switch_identifier | procedure_identifier ; -actual_parameter_list : actual_parameter | actual_parameter_list parameter_delimiter actual_parameter ; -function_designator : procedure_identifier actual_parameter_part ; +parameter_delimiter + : Comma_ + | Rp_ Identifier Colon_ LP_ + ; + +actual_parameter + : String + | expression + | array_identifier + | switch_identifier + | procedure_identifier + ; + +actual_parameter_list + : actual_parameter + | actual_parameter_list parameter_delimiter actual_parameter + ; + +function_designator + : procedure_identifier actual_parameter_part + ; // 3.3.1 -adding_operator : Plus_ | Minus_ ; -multiplying_operator : Mult_ | Divide_ ; -primary : Unsigned_number | variable | function_designator | LP_ arithmetic_expression Rp_ ; -factor : primary | factor Exp_ primary ; -term : factor | term multiplying_operator factor ; -simple_arithmetic_expression : term - | adding_operator term - | simple_arithmetic_expression adding_operator term ; -if_clause : If_ boolean_expression Then_ ; -arithmetic_expression : simple_arithmetic_expression | if_clause simple_arithmetic_expression Else_ arithmetic_expression ; +adding_operator + : Plus_ + | Minus_ + ; + +multiplying_operator + : Mult_ + | Divide_ + ; + +primary + : Unsigned_number + | variable + | function_designator + | LP_ arithmetic_expression Rp_ + ; + +factor + : primary + | factor Exp_ primary + ; + +term + : factor + | term multiplying_operator factor + ; + +simple_arithmetic_expression + : term + | adding_operator term + | simple_arithmetic_expression adding_operator term + ; + +if_clause + : If_ boolean_expression Then_ + ; + +arithmetic_expression + : simple_arithmetic_expression + | if_clause simple_arithmetic_expression Else_ arithmetic_expression + ; // 3.4.1 // dup relational_operator. -relation : simple_arithmetic_expression Relational_operator simple_arithmetic_expression ; -boolean_primary : Logical_value | variable | function_designator | relation | LP_ boolean_expression Rp_ ; -boolean_secondary : boolean_primary | Not_ boolean_primary ; -boolean_factor : boolean_secondary | boolean_factor And_ boolean_secondary ; -boolean_term : boolean_factor | boolean_term Or_ boolean_factor ; -implication : boolean_term | implication Includes_ boolean_term ; -simple_boolean : implication | simple_boolean Equiv_ implication ; -boolean_expression : simple_boolean | if_clause simple_boolean Else_ boolean_expression ; +relation + : simple_arithmetic_expression Relational_operator simple_arithmetic_expression + ; + +boolean_primary + : Logical_value + | variable + | function_designator + | relation + | LP_ boolean_expression Rp_ + ; + +boolean_secondary + : boolean_primary + | Not_ boolean_primary + ; + +boolean_factor + : boolean_secondary + | boolean_factor And_ boolean_secondary + ; + +boolean_term + : boolean_factor + | boolean_term Or_ boolean_factor + ; + +implication + : boolean_term + | implication Includes_ boolean_term + ; + +simple_boolean + : implication + | simple_boolean Equiv_ implication + ; + +boolean_expression + : simple_boolean + | if_clause simple_boolean Else_ boolean_expression + ; // 3.5.1 -label : Identifier | Unsigned_integer ; -switch_identifier : Identifier ; -switch_designator : switch_identifier Lb_ subscript_expression Rb_ ; -simple_designational_expression : label | switch_designator | LP_ designational_expression Rp_ ; -designational_expression : simple_designational_expression | if_clause simple_designational_expression Else_ designational_expression ; +label + : Identifier + | Unsigned_integer + ; + +switch_identifier + : Identifier + ; + +switch_designator + : switch_identifier Lb_ subscript_expression Rb_ + ; + +simple_designational_expression + : label + | switch_designator + | LP_ designational_expression Rp_ + ; + +designational_expression + : simple_designational_expression + | if_clause simple_designational_expression Else_ designational_expression + ; // 4.1.1 -unlabelled_basic_statement : assignment_statement | go_to_statement | dummy_statement | procedure_statement ; -basic_statement : unlabelled_basic_statement | label Colon_ basic_statement ; -unconditional_statement : basic_statement | compound_statement | block ; -statement : unconditional_statement | conditional_statement | for_statement ; -compound_tail : statement End_ | statement Semi_ compound_tail ; -block_head : Begin_ declaration | block_head Semi_ declaration ; -unlabelled_compound : Begin_ compound_tail ; -unlabelled_block : block_head Semi_ compound_tail ; -compound_statement : unlabelled_compound | label Colon_ compound_statement ; -block : unlabelled_block | label Colon_ block ; -program : (block | compound_statement) EOF ; +unlabelled_basic_statement + : assignment_statement + | go_to_statement + | dummy_statement + | procedure_statement + ; + +basic_statement + : unlabelled_basic_statement + | label Colon_ basic_statement + ; + +unconditional_statement + : basic_statement + | compound_statement + | block + ; + +statement + : unconditional_statement + | conditional_statement + | for_statement + ; + +compound_tail + : statement End_ + | statement Semi_ compound_tail + ; + +block_head + : Begin_ declaration + | block_head Semi_ declaration + ; + +unlabelled_compound + : Begin_ compound_tail + ; + +unlabelled_block + : block_head Semi_ compound_tail + ; + +compound_statement + : unlabelled_compound + | label Colon_ compound_statement + ; + +block + : unlabelled_block + | label Colon_ block + ; + +program + : (block | compound_statement) EOF + ; // 4.2.1 -destination : variable | procedure_identifier ; -left_part : variable Assign_ | procedure_identifier Assign_ ; -left_part_list : left_part | left_part_list left_part ; -assignment_statement : left_part_list arithmetic_expression | left_part_list boolean_expression ; +destination + : variable + | procedure_identifier + ; + +left_part + : variable Assign_ + | procedure_identifier Assign_ + ; + +left_part_list + : left_part + | left_part_list left_part + ; + +assignment_statement + : left_part_list arithmetic_expression + | left_part_list boolean_expression + ; // 4.3.1 -go_to_statement : Goto_ designational_expression ; +go_to_statement + : Goto_ designational_expression + ; // 4.4.1 -dummy_statement : empty_ ; +dummy_statement + : empty_ + ; // 4.5.1 // dup if_clause // dup unconditional statement -if_statement : if_clause unconditional_statement ; -conditional_statement : if_statement | if_statement Else_ statement | if_clause for_statement | label Colon_ conditional_statement ; +if_statement + : if_clause unconditional_statement + ; + +conditional_statement + : if_statement + | if_statement Else_ statement + | if_clause for_statement + | label Colon_ conditional_statement + ; // 4.6.1 -for_list_element : arithmetic_expression - | arithmetic_expression Step_ arithmetic_expression Until_ arithmetic_expression - | arithmetic_expression While_ boolean_expression ; -for_list : for_list_element | for_list Comma_ for_list_element ; -for_clause : For_ variable Assign_ for_list Do_ ; -for_statement : for_clause statement | label Colon_ for_statement ; +for_list_element + : arithmetic_expression + | arithmetic_expression Step_ arithmetic_expression Until_ arithmetic_expression + | arithmetic_expression While_ boolean_expression + ; + +for_list + : for_list_element + | for_list Comma_ for_list_element + ; + +for_clause + : For_ variable Assign_ for_list Do_ + ; + +for_statement + : for_clause statement + | label Colon_ for_statement + ; // 4.7.1 // dup actual_parameter // dup letter_string // dup parameter_delimiter // dup actual_parameter_list -actual_parameter_part : empty_ | LP_ actual_parameter_list Rp_ ; -procedure_statement : procedure_identifier actual_parameter_part ; +actual_parameter_part + : empty_ + | LP_ actual_parameter_list Rp_ + ; + +procedure_statement + : procedure_identifier actual_parameter_part + ; // 4.7.8 -code : .* ; // match anything. +code + : .* + ; // match anything. // 5 -declaration : type_declaration | array_declaration | switch_declaration | procedure_declaration ; +declaration + : type_declaration + | array_declaration + | switch_declaration + | procedure_declaration + ; // 5.1.1 -type_list : simple_variable | simple_variable Comma_ type_list ; -type_ : Real_ | Integer_ | Boolean_ ; -local_or_own : empty_ | Own_ ; -type_declaration : local_or_own type_ type_list ; +type_list + : simple_variable + | simple_variable Comma_ type_list + ; + +type_ + : Real_ + | Integer_ + | Boolean_ + ; + +local_or_own + : empty_ + | Own_ + ; + +type_declaration + : local_or_own type_ type_list + ; // 5.2.1 -lower_bound : arithmetic_expression ; -upper_bound : arithmetic_expression ; -bound_pair : lower_bound Colon_ upper_bound ; -bound_pair_list : bound_pair | bound_pair_list Comma_ bound_pair ; -array_segment : array_identifier Lb_ bound_pair_list Rb_ | array_identifier Comma_ array_segment ; -array_list : array_segment | array_list Comma_ array_segment ; -array_declarer : type_ Array_ | Array_ ; -array_declaration : local_or_own array_declarer array_list ; +lower_bound + : arithmetic_expression + ; + +upper_bound + : arithmetic_expression + ; + +bound_pair + : lower_bound Colon_ upper_bound + ; + +bound_pair_list + : bound_pair + | bound_pair_list Comma_ bound_pair + ; + +array_segment + : array_identifier Lb_ bound_pair_list Rb_ + | array_identifier Comma_ array_segment + ; + +array_list + : array_segment + | array_list Comma_ array_segment + ; + +array_declarer + : type_ Array_ + | Array_ + ; + +array_declaration + : local_or_own array_declarer array_list + ; // 5.3.1 -switch_list : designational_expression | switch_list Comma_ designational_expression ; -switch_declaration : Switch_ switch_identifier Assign_ switch_list ; +switch_list + : designational_expression + | switch_list Comma_ designational_expression + ; + +switch_declaration + : Switch_ switch_identifier Assign_ switch_list + ; // 5.4.1 -formal_parameter : Identifier ; -formal_parameter_list : formal_parameter | formal_parameter_list parameter_delimiter formal_parameter ; -formal_parameter_part : empty_ | LP_ formal_parameter_list Rp_ ; -identifier_list : Identifier | identifier_list Comma_ Identifier ; -value_part : Value_ identifier_list Semi_ | empty_ ; -specifier : String_ | type_ | Array_ | type_ Array_ | Label_ | Switch_ | Procedure_ | type_ Procedure_ ; -specification_part : empty_ | specifier identifier_list Semi_ | specification_part specifier identifier_list ; -procedure_heading : procedure_identifier formal_parameter_part Semi_ value_part specification_part ; -procedure_body : statement | code ; -procedure_declaration : Procedure_ procedure_heading procedure_body | type_ Procedure_ procedure_heading procedure_body ; - -WS : Ws -> channel(HIDDEN) ; -fragment Ws : [ \r\n\t]+ ; +formal_parameter + : Identifier + ; + +formal_parameter_list + : formal_parameter + | formal_parameter_list parameter_delimiter formal_parameter + ; + +formal_parameter_part + : empty_ + | LP_ formal_parameter_list Rp_ + ; + +identifier_list + : Identifier + | identifier_list Comma_ Identifier + ; + +value_part + : Value_ identifier_list Semi_ + | empty_ + ; + +specifier + : String_ + | type_ + | Array_ + | type_ Array_ + | Label_ + | Switch_ + | Procedure_ + | type_ Procedure_ + ; + +specification_part + : empty_ + | specifier identifier_list Semi_ + | specification_part specifier identifier_list + ; + +procedure_heading + : procedure_identifier formal_parameter_part Semi_ value_part specification_part + ; + +procedure_body + : statement + | code + ; + +procedure_declaration + : Procedure_ procedure_heading procedure_body + | type_ Procedure_ procedure_heading procedure_body + ; + +WS + : Ws -> channel(HIDDEN) + ; + +fragment Ws + : [ \r\n\t]+ + ; \ No newline at end of file diff --git a/alloy/alloy.g4 b/alloy/alloy.g4 index 9d7c89bce9..e4b602d821 100644 --- a/alloy/alloy.g4 +++ b/alloy/alloy.g4 @@ -25,199 +25,202 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar alloy; alloyModule - : moduleDecl? import_* paragraph+ EOF - ; + : moduleDecl? import_* paragraph+ EOF + ; moduleDecl - : 'module' qualName name (',' name)* - ; + : 'module' qualName name (',' name)* + ; import_ - : 'open' qualName (',' qualName)* ('as' name)? - ; + : 'open' qualName (',' qualName)* ('as' name)? + ; paragraph - : sigDecl - | factDecl - | predDecl - | funDecl - | assertDecl - | cmdDecl - ; + : sigDecl + | factDecl + | predDecl + | funDecl + | assertDecl + | cmdDecl + ; sigDecl - : 'abstract'? mult? 'sig' name (',' name)* sigExt? '{' (decl (',' decl)*)? '}' block? - ; + : 'abstract'? mult? 'sig' name (',' name)* sigExt? '{' (decl (',' decl)*)? '}' block? + ; sigExt - : 'extends' qualName - | 'in' qualName ('+' qualName)* - ; + : 'extends' qualName + | 'in' qualName ('+' qualName)* + ; mult - : 'lone' - | 'some' - | 'one' - ; + : 'lone' + | 'some' + | 'one' + ; decl - : 'disj'? name (',' name)* ':' 'disj'? expr - ; + : 'disj'? name (',' name)* ':' 'disj'? expr + ; factDecl - : 'fact' name? block - ; + : 'fact' name? block + ; predDecl - : 'pred' (qualName '.')? name paraDecls? block - ; + : 'pred' (qualName '.')? name paraDecls? block + ; funDecl - : 'fun' (qualName '.')? name paraDecls? ':' expr '{' expr '}' - ; + : 'fun' (qualName '.')? name paraDecls? ':' expr '{' expr '}' + ; paraDecls - : '(' decl (',' decl)* ')' - | '[' decl (',' decl)* ']' - ; + : '(' decl (',' decl)* ')' + | '[' decl (',' decl)* ']' + ; assertDecl - : 'assert' name? block - ; + : 'assert' name? block + ; cmdDecl - : (name ':')? ('run' | 'check')? (qualName | block) scope? - ; + : (name ':')? ('run' | 'check')? (qualName | block) scope? + ; scope - : 'for' number ('but' typescope (',' typescope)*)? - | 'for' typescope (',' typescope)* - ; + : 'for' number ('but' typescope (',' typescope)*)? + | 'for' typescope (',' typescope)* + ; typescope - : 'exactly'? number qualName - ; + : 'exactly'? number qualName + ; expr - : const_ - | qualName - | '@' name - | 'this' - | unOp expr - | expr binOp expr - | expr arrowOp expr - | expr '[' (',' expr)+ ']' - | expr ('!' | 'not')? compareOp expr - | expr ('=>' | 'implies')? expr 'else' expr - | 'let' letDecl (',' letDecl)* blockOrBar - | quant decl (',' decl)* blockOrBar - | '{' decl (',' decl)* blockOrBar '}' - | '(' expr ')' - | block - ; + : const_ + | qualName + | '@' name + | 'this' + | unOp expr + | expr binOp expr + | expr arrowOp expr + | expr '[' (',' expr)+ ']' + | expr ('!' | 'not')? compareOp expr + | expr ('=>' | 'implies')? expr 'else' expr + | 'let' letDecl (',' letDecl)* blockOrBar + | quant decl (',' decl)* blockOrBar + | '{' decl (',' decl)* blockOrBar '}' + | '(' expr ')' + | block + ; const_ - : '-'? number - | 'none' - | 'univ' - | 'iden' - ; + : '-'? number + | 'none' + | 'univ' + | 'iden' + ; unOp - : '!' - | 'not' - | 'no' - | mult - | 'set' - | '#' - | '~' - | '*' - | '^' - ; + : '!' + | 'not' + | 'no' + | mult + | 'set' + | '#' + | '~' + | '*' + | '^' + ; binOp - : '||' - | 'or' - | '&&' - | 'and' - | '<=>' - | 'iff' - | '=>' - | 'implies' - | '&' - | '+' - | '-' - | '++' - | '<:' - | ':>' - | '.' - ; + : '||' + | 'or' + | '&&' + | 'and' + | '<=>' + | 'iff' + | '=>' + | 'implies' + | '&' + | '+' + | '-' + | '++' + | '<:' + | ':>' + | '.' + ; arrowOp - : (mult | 'set')? '->' (mult | 'set')? - ; + : (mult | 'set')? '->' (mult | 'set')? + ; compareOp - : 'in' - | '=' - | '<' - | '>' - | '=<' - | '>=' - ; + : 'in' + | '=' + | '<' + | '>' + | '=<' + | '>=' + ; letDecl - : name '=' expr - ; + : name '=' expr + ; block - : '{' expr* '}' - ; + : '{' expr* '}' + ; blockOrBar - : block - | BAR expr - ; + : block + | BAR expr + ; quant - : 'all' - | 'no' - | 'sum' - | mult - ; + : 'all' + | 'no' + | 'sum' + | mult + ; qualName - : 'this/'? (name '/')* name - ; + : 'this/'? (name '/')* name + ; name - : IDENTIFIER - ; + : IDENTIFIER + ; number - : DIGIT+ - ; + : DIGIT+ + ; BAR - : '|' - ; + : '|' + ; DIGIT - : '0' .. '9' - ; + : '0' .. '9' + ; IDENTIFIER - : ('a' .. 'z' | 'A' .. 'Z') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_')* - ; + : ('a' .. 'z' | 'A' .. 'Z') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_')* + ; COMMENT - : '//' ~ [\r\n]* -> skip - ; + : '//' ~ [\r\n]* -> skip + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/alpaca/alpaca.g4 b/alpaca/alpaca.g4 index 8d951886a6..4319ca49d9 100644 --- a/alpaca/alpaca.g4 +++ b/alpaca/alpaca.g4 @@ -29,135 +29,138 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar alpaca; prog - : defns ('.' | 'begin') EOF - ; + : defns ('.' | 'begin') EOF + ; defns - : defn (';' defn)* - ; + : defn (';' defn)* + ; defn - : stateDefn - | classDefn - | nbhdDefn - ; + : stateDefn + | classDefn + | nbhdDefn + ; stateDefn - : 'state' stateID QUOTEDCHAR? membershipDecl* rules? - ; + : 'state' stateID QUOTEDCHAR? membershipDecl* rules? + ; classDefn - : 'class' classID membershipDecl* rules? - ; + : 'class' classID membershipDecl* rules? + ; nbhdDefn - : 'neighbourhood' nbhdID neigbourhood - ; + : 'neighbourhood' nbhdID neigbourhood + ; classID - : identifier - ; + : identifier + ; stateID - : identifier - ; + : identifier + ; nbhdID - : identifier - ; + : identifier + ; membershipDecl - : classRef - ; + : classRef + ; classRef - : 'is' classID - ; + : 'is' classID + ; rules - : rule_ (',' rule_)* - ; + : rule_ (',' rule_)* + ; rule_ - : 'to' stateRef ('when' expression)? - ; + : 'to' stateRef ('when' expression)? + ; stateRef - : stateID - | arrowchain - | 'me' - ; + : stateID + | arrowchain + | 'me' + ; expression - : term (('and' | 'or' | 'xor') term)* - ; + : term (('and' | 'or' | 'xor') term)* + ; term - : adjacencyPred - | '(' expression ')' - | 'not' term - | boolPrimitive - | relationalPred - ; + : adjacencyPred + | '(' expression ')' + | 'not' term + | boolPrimitive + | relationalPred + ; relationalPred - : stateRef ('='? stateRef | classRef) - ; + : stateRef ('='? stateRef | classRef) + ; adjacencyPred - : naturalnumber ('in' (neigbourhood | nbhdID))? (stateRef | classRef) - ; + : naturalnumber ('in' (neigbourhood | nbhdID))? (stateRef | classRef) + ; boolPrimitive - : 'true' - | 'false' - | 'guess' - ; + : 'true' + | 'false' + | 'guess' + ; neigbourhood - : '(' arrowchain* ')' - ; + : '(' arrowchain* ')' + ; identifier - : ALPHA (ALPHA | DIGIT)* - ; + : ALPHA (ALPHA | DIGIT)* + ; naturalnumber - : DIGIT+ - ; + : DIGIT+ + ; arrowchain - : ARROW+ - ; + : ARROW+ + ; QUOTEDCHAR - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; QUOTE - : '"' - ; + : '"' + ; ALPHA - : [a-zA-Z] - ; + : [a-zA-Z] + ; DIGIT - : [0-9] - ; + : [0-9] + ; ARROW - : [^v<>] - ; + : [^v<>] + ; COMMENT - : '/*' .*? '*/' -> skip - ; + : '/*' .*? '*/' -> skip + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/angelscript/angelscript.g4 b/angelscript/angelscript.g4 index 011fb73337..f9f3270724 100644 --- a/angelscript/angelscript.g4 +++ b/angelscript/angelscript.g4 @@ -29,330 +29,382 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar angelscript; script - : (import_ | enum_ | typdef | class_ | mixin_ | interface_ | funcdef | virtprop | var_ | func_ | namespace | ';')+ EOF - ; + : ( + import_ + | enum_ + | typdef + | class_ + | mixin_ + | interface_ + | funcdef + | virtprop + | var_ + | func_ + | namespace + | ';' + )+ EOF + ; class_ - : ('shared' | 'abstract' | 'final' | 'external')* 'class' IDENTIFIER (';' | (':' IDENTIFIER (',' IDENTIFIER)*)? '{' (virtprop | func_ | var_ | funcdef)* '}' ) - ; + : ('shared' | 'abstract' | 'final' | 'external')* 'class' IDENTIFIER ( + ';' + | (':' IDENTIFIER (',' IDENTIFIER)*)? '{' (virtprop | func_ | var_ | funcdef)* '}' + ) + ; typdef - : 'typedef' PRIMTYPE IDENTIFIER ';' - ; + : 'typedef' PRIMTYPE IDENTIFIER ';' + ; namespace - : 'namespace' IDENTIFIER '{' script '}' - ; + : 'namespace' IDENTIFIER '{' script '}' + ; func_ - : ('shared' | 'external')* ('private' | 'protected')? (type_ '&'? | '~')? IDENTIFIER paramlist 'const'? FUNCATTR? (';' | statblock) - ; + : ('shared' | 'external')* ('private' | 'protected')? (type_ '&'? | '~')? IDENTIFIER paramlist 'const'? FUNCATTR? ( + ';' + | statblock + ) + ; interface_ - : ('external' | 'shared')* 'interface' IDENTIFIER (';' | (':' IDENTIFIER (',' IDENTIFIER)*)? '{' (virtprop | intfmthd)* '}' ) - ; + : ('external' | 'shared')* 'interface' IDENTIFIER ( + ';' + | (':' IDENTIFIER (',' IDENTIFIER)*)? '{' (virtprop | intfmthd)* '}' + ) + ; var_ - : ('private' | 'protected')? type_ IDENTIFIER ('=' (initlist | expr) | arglist)? (',' IDENTIFIER ('=' (initlist | expr) | arglist)?)* ';' - ; + : ('private' | 'protected')? type_ IDENTIFIER ('=' (initlist | expr) | arglist)? ( + ',' IDENTIFIER ('=' (initlist | expr) | arglist)? + )* ';' + ; import_ - : 'import' type_ '&'? IDENTIFIER paramlist FUNCATTR 'from' STRING ';' - ; + : 'import' type_ '&'? IDENTIFIER paramlist FUNCATTR 'from' STRING ';' + ; enum_ - : ('shared' | 'external')* 'enum' IDENTIFIER (';' | '{' IDENTIFIER ('=' expr)? (',' IDENTIFIER ('=' expr)?)* '}') - ; + : ('shared' | 'external')* 'enum' IDENTIFIER ( + ';' + | '{' IDENTIFIER ('=' expr)? (',' IDENTIFIER ('=' expr)?)* '}' + ) + ; funcdef - : ('external' | 'shared')* 'funcdef' type_ '&'? IDENTIFIER paramlist ';' - ; + : ('external' | 'shared')* 'funcdef' type_ '&'? IDENTIFIER paramlist ';' + ; virtprop - : ('private' | 'protected')? type_ '&'? IDENTIFIER '{' (('get' | 'set') 'const'? FUNCATTR (statblock | ';'))* '}' - ; + : ('private' | 'protected')? type_ '&'? IDENTIFIER '{' ( + ('get' | 'set') 'const'? FUNCATTR (statblock | ';') + )* '}' + ; mixin_ - : 'mixin' class_ - ; + : 'mixin' class_ + ; intfmthd - : type_ '&'? IDENTIFIER paramlist 'const'? ';' - ; + : type_ '&'? IDENTIFIER paramlist 'const'? ';' + ; statblock - : '{' (var_ | statement)* '}' - ; + : '{' (var_ | statement)* '}' + ; paramlist - : '(' (VOID | type_ typemod IDENTIFIER? ('=' expr)? (',' type_ typemod IDENTIFIER? ('=' expr)?)* )? ')' - ; + : '(' ( + VOID + | type_ typemod IDENTIFIER? ('=' expr)? (',' type_ typemod IDENTIFIER? ('=' expr)?)* + )? ')' + ; typemod - : ('&' ('in' | 'out' | 'inout')?)? - ; + : ('&' ('in' | 'out' | 'inout')?)? + ; type_ - : 'const'? scope datatype ('<' type_ (',' type_)* '>')* ('[' ']' | '@' 'const'?)* - ; + : 'const'? scope datatype ('<' type_ (',' type_)* '>')* ('[' ']' | '@' 'const'?)* + ; initlist - : '{' (assign | initlist)? (',' (assign | initlist)?)* '}' - ; + : '{' (assign | initlist)? (',' (assign | initlist)?)* '}' + ; scope - : '::'? (IDENTIFIER '::')* (IDENTIFIER ('<' type_ (',' type_)* '>')? '::')? - ; + : '::'? (IDENTIFIER '::')* (IDENTIFIER ('<' type_ (',' type_)* '>')? '::')? + ; datatype - : IDENTIFIER | PRIMTYPE | '?' | 'auto' - ; + : IDENTIFIER + | PRIMTYPE + | '?' + | 'auto' + ; statement - : if_ | for_ | while_ | return_ | statblock | break_ | continue_ | dowhile | switch_ | exprstat | try_ - ; + : if_ + | for_ + | while_ + | return_ + | statblock + | break_ + | continue_ + | dowhile + | switch_ + | exprstat + | try_ + ; switch_ - : 'switch' '(' assign ')' '{' case_* '}' - ; + : 'switch' '(' assign ')' '{' case_* '}' + ; break_ - : 'break' ';' - ; + : 'break' ';' + ; for_ - : 'for' '(' (var_ | exprstat) exprstat (assign (',' assign)*)? ')' statement - ; + : 'for' '(' (var_ | exprstat) exprstat (assign (',' assign)*)? ')' statement + ; while_ - : 'while' '(' assign ')' statement - ; + : 'while' '(' assign ')' statement + ; dowhile - : 'do' statement 'while' '(' assign ')' ';' - ; + : 'do' statement 'while' '(' assign ')' ';' + ; if_ - : 'if' '(' assign ')' statement ('else' statement)? - ; + : 'if' '(' assign ')' statement ('else' statement)? + ; continue_ - : 'continue' ';' - ; + : 'continue' ';' + ; exprstat - : assign? ';' - ; + : assign? ';' + ; try_ - : 'try' statblock 'catch' statblock - ; + : 'try' statblock 'catch' statblock + ; return_ - : 'return' assign? ';' - ; + : 'return' assign? ';' + ; case_ - : ('case' expr | 'default') ':' statement* - ; + : ('case' expr | 'default') ':' statement* + ; expr - : exprterm (exprop exprterm)* - ; + : exprterm (exprop exprterm)* + ; exprterm - : (type_ '=')? initlist - | EXPRPREOP* exprvalue exprpostop* - ; + : (type_ '=')? initlist + | EXPRPREOP* exprvalue exprpostop* + ; exprvalue - : VOID - | constructcall - | funccall - | varaccess - | cast - | LITERAL - | '(' assign ')' - | lambda_ - ; + : VOID + | constructcall + | funccall + | varaccess + | cast + | LITERAL + | '(' assign ')' + | lambda_ + ; constructcall - : type_ arglist - ; + : type_ arglist + ; exprpostop - : '.' (funccall | IDENTIFIER) - | '[' (IDENTIFIER ':')? assign (',' IDENTIFIER? ':' assign)* ']' - | arglist - | '++' - | '--' - ; + : '.' (funccall | IDENTIFIER) + | '[' (IDENTIFIER ':')? assign (',' IDENTIFIER? ':' assign)* ']' + | arglist + | '++' + | '--' + ; cast - : 'cast' '<' type_ '>' '(' assign ')' - ; + : 'cast' '<' type_ '>' '(' assign ')' + ; lambda_ - : 'function' '(' ((type_ typemod)? IDENTIFIER (',' (type_ typemod)? IDENTIFIER)*)? ')' statblock - ; + : 'function' '(' ((type_ typemod)? IDENTIFIER (',' (type_ typemod)? IDENTIFIER)*)? ')' statblock + ; funccall - : scope IDENTIFIER arglist - ; + : scope IDENTIFIER arglist + ; varaccess - : scope IDENTIFIER - ; + : scope IDENTIFIER + ; arglist - : '(' (IDENTIFIER ':')? assign (',' (IDENTIFIER ':')? assign)* ')' - ; + : '(' (IDENTIFIER ':')? assign (',' (IDENTIFIER ':')? assign)* ')' + ; assign - : condition (ASSIGNOP assign)? - ; + : condition (ASSIGNOP assign)? + ; condition - : expr ('?' assign ':' assign)? - ; + : expr ('?' assign ':' assign)? + ; exprop - : MATHOP - | COMPOP - | LOGICOP - | BITOP - ; + : MATHOP + | COMPOP + | LOGICOP + | BITOP + ; BITOP - : '&' - | '|' - | '^' - | '<<' - | '>>' - | '>>>' - ; + : '&' + | '|' + | '^' + | '<<' + | '>>' + | '>>>' + ; MATHOP - : PLUS - | MINUS - | '*' - | '/' - | '\'' - | '**' - ; + : PLUS + | MINUS + | '*' + | '/' + | '\'' + | '**' + ; COMPOP - : '==' - | '!=' - | '<' - | '<=' - | '>' - | '>=' - | 'is' - | '!is' - ; + : '==' + | '!=' + | '<' + | '<=' + | '>' + | '>=' + | 'is' + | '!is' + ; LOGICOP - : '&&' - | '||' - | '^^' - | 'and' - | 'or' - | 'xor' - ; + : '&&' + | '||' + | '^^' + | 'and' + | 'or' + | 'xor' + ; ASSIGNOP - : '=' - | '+=' - | '-=' - | '*=' - | '/=' - | '|=' - | '&=' - | '^=' - | '%=' - | '**=' - | '<<=' - | '>>=' - | '>>>=' - ; + : '=' + | '+=' + | '-=' + | '*=' + | '/=' + | '|=' + | '&=' + | '^=' + | '%=' + | '**=' + | '<<=' + | '>>=' + | '>>>=' + ; PRIMTYPE - : VOID - | 'int' - | 'int8' - | 'int16' - | 'int32' - | 'int64' - | 'uint' - | 'uint8' - | 'uint16' - | 'uint32' - | 'uint64' - | 'float' - | 'double' - | 'bool' - ; + : VOID + | 'int' + | 'int8' + | 'int16' + | 'int32' + | 'int64' + | 'uint' + | 'uint8' + | 'uint16' + | 'uint32' + | 'uint64' + | 'float' + | 'double' + | 'bool' + ; FUNCATTR - : 'override' | 'final' | 'explicit' | 'property' - ; + : 'override' + | 'final' + | 'explicit' + | 'property' + ; EXPRPREOP - : MINUS - | PLUS - | '!' - | '++' - | '--' - | '~' - | '@' - ; + : MINUS + | PLUS + | '!' + | '++' + | '--' + | '~' + | '@' + ; VOID - : 'void' - ; + : 'void' + ; fragment PLUS - : '+' - ; + : '+' + ; fragment MINUS - : '-' - ; + : '-' + ; LITERAL - : NUMBER - | STRING - | BITS - | 'true' - | 'false' - | 'null' - ; + : NUMBER + | STRING + | BITS + | 'true' + | 'false' + | 'null' + ; IDENTIFIER - : [a-zA-Z_] [a-zA-Z0-9_]* - ; + : [a-zA-Z_] [a-zA-Z0-9_]* + ; NUMBER - : [0-9] '.' [0-9]+ - ; + : [0-9] '.' [0-9]+ + ; STRING - : '"' ~ '"'* '"' - | '\'' ~ '\''* '\'' - ; + : '"' ~ '"'* '"' + | '\'' ~ '\''* '\'' + ; BITS - : ('0b' | '0o' | '0d' | '0x' | '0B' | '0O' | '0D' | '0X') [0-9a-z] - ; + : ('0b' | '0o' | '0d' | '0x' | '0B' | '0O' | '0D' | '0X') [0-9a-z] + ; COMMENT - : '//' ~ [\r\n]* -> skip - ; + : '//' ~ [\r\n]* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/antlr/antlr2/ANTLRv2Lexer.g4 b/antlr/antlr2/ANTLRv2Lexer.g4 index 5bcbf2ef9e..1f63cd1099 100644 --- a/antlr/antlr2/ANTLRv2Lexer.g4 +++ b/antlr/antlr2/ANTLRv2Lexer.g4 @@ -25,15 +25,24 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ANTLRv2Lexer; -options { superClass = LexerAdaptor; } +options { + superClass = LexerAdaptor; +} -channels { OFF_CHANNEL } +channels { + OFF_CHANNEL +} tokens { DOC_COMMENT, - PARSER, + PARSER, LEXER, RULE, BLOCK, @@ -61,8 +70,8 @@ tokens { TEMPLATE, SCOPE, SEMPRED, - GATED_SEMPRED, // {p}? => - SYN_SEMPRED, // (...) => it's a manually-specified synpred converted to sempred + GATED_SEMPRED, // {p}? => + SYN_SEMPRED, // (...) => it's a manually-specified synpred converted to sempred BACKTRACK_SEMPRED, // auto backtracking mode syn pred converted to sempred FRAGMENT, TREE_BEGIN, @@ -73,127 +82,103 @@ tokens { ACTION_CONTENT } -DOC_COMMENT - : '/**' .*? ('*/' | EOF) -> channel(OFF_CHANNEL) - ; - -SL_COMMENT - : '//' ~ [\r\n]* -> channel(OFF_CHANNEL) - ; - -ML_COMMENT - : '/*' .*? '*/' -> channel(OFF_CHANNEL) - ; - -INT - : '0' .. '9'+ - ; - -CHAR_LITERAL - : '\'' LITERAL_CHAR '\'' - ; - -fragment LITERAL_CHAR - : ESC - | ~ ('\'' | '\\') - ; - -STRING_LITERAL - : '"' LIT_STR* '"' - ; - -fragment LIT_STR - : ESC - | ~ ('\\' | '"') - ; - -fragment ESC - : '\\' ('n' | 'r' | 't' | 'b' | 'f' | '"' | '\'' | '\\' | '>' | 'u' XDIGIT XDIGIT XDIGIT XDIGIT | OctDigit (OctDigit OctDigit?)? | .) - ; - -fragment XDIGIT - : '0' .. '9' - | 'a' .. 'f' - | 'A' .. 'F' - ; - -BEGIN_ARGUMENT - : LBrack - { this.handleBeginArgument(); } - ; - -BEGIN_ACTION - : LBrace -> pushMode (Actionx) - ; - -OPTIONS - : 'options' -> pushMode (Options) - ; - -TOKENS - : 'tokens' -> pushMode (Tokens) - ; - -HEADER : 'header' ; -CLASS : 'class' ; -EXTENDS : 'extends' ; -LEXCLASS : 'lexclass' ; -TREEPARSER : 'treeparser' ; -EXCEPTION : 'exception' ; -CATCH : 'catch' ; -FINALLY : 'finally' ; -FRAGMENT : 'fragment' ; -GRAMMAR : 'grammar' ; -LEXER : 'Lexer' ; -PARSER : 'Parser' ; -PRIVATE : 'private' ; -PROTECTED : 'protected' ; -PUBLIC : 'public' ; -RETURNS : 'returns' ; -SCOPE : 'scope' ; -THROWS : 'throws' ; -TREE : 'tree' ; -fragment WS_LOOP : (WS | SL_COMMENT | ML_COMMENT)* ; -OPEN_ELEMENT_OPTION : Lt ; -CLOSE_ELEMENT_OPTION : Gt ; -AT : At ; -BANG : '!' ; -COLON : Colon ; -COLONCOLON : DColon ; -COMMA : Comma ; -DOT : Dot ; -EQUAL : Equal ; -LBRACE : LBrace ; -LBRACK : LBrack ; -LPAREN : LParen ; -OR : Pipe ; -PLUS : Plus ; -QM : Question ; -RANGE : Range ; -RBRACE : RBrace ; -RBRACK : RBrack ; -REWRITE : RArrow ; -ROOT : '^' ; -RPAREN : RParen ; -SEMI : Semi ; -SEMPREDOP : '=>' ; -STAR : Star ; -TREE_BEGIN : '^(' ; -DOLLAR : Dollar ; -PEQ : PlusAssign ; -NOT : Tilde ; - -WS - : (' ' | '\t' | '\r'? '\n')+ -> channel(OFF_CHANNEL) - ; - -TOKEN_REF - : 'A' .. 'Z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')* - ; - -RULE_REF - : 'a' .. 'z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')* - ; +DOC_COMMENT: '/**' .*? ('*/' | EOF) -> channel(OFF_CHANNEL); + +SL_COMMENT: '//' ~ [\r\n]* -> channel(OFF_CHANNEL); + +ML_COMMENT: '/*' .*? '*/' -> channel(OFF_CHANNEL); + +INT: '0' .. '9'+; + +CHAR_LITERAL: '\'' LITERAL_CHAR '\''; + +fragment LITERAL_CHAR: ESC | ~ ('\'' | '\\'); + +STRING_LITERAL: '"' LIT_STR* '"'; + +fragment LIT_STR: ESC | ~ ('\\' | '"'); + +fragment ESC: + '\\' ( + 'n' + | 'r' + | 't' + | 'b' + | 'f' + | '"' + | '\'' + | '\\' + | '>' + | 'u' XDIGIT XDIGIT XDIGIT XDIGIT + | OctDigit (OctDigit OctDigit?)? + | . + ) +; + +fragment XDIGIT: '0' .. '9' | 'a' .. 'f' | 'A' .. 'F'; + +BEGIN_ARGUMENT: LBrack { this.handleBeginArgument(); }; + +BEGIN_ACTION: LBrace -> pushMode (Actionx); + +OPTIONS: 'options' -> pushMode (Options); + +TOKENS: 'tokens' -> pushMode (Tokens); + +HEADER : 'header'; +CLASS : 'class'; +EXTENDS : 'extends'; +LEXCLASS : 'lexclass'; +TREEPARSER : 'treeparser'; +EXCEPTION : 'exception'; +CATCH : 'catch'; +FINALLY : 'finally'; +FRAGMENT : 'fragment'; +GRAMMAR : 'grammar'; +LEXER : 'Lexer'; +PARSER : 'Parser'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PUBLIC : 'public'; +RETURNS : 'returns'; +SCOPE : 'scope'; +THROWS : 'throws'; +TREE : 'tree'; +fragment WS_LOOP : (WS | SL_COMMENT | ML_COMMENT)*; +OPEN_ELEMENT_OPTION : Lt; +CLOSE_ELEMENT_OPTION : Gt; +AT : At; +BANG : '!'; +COLON : Colon; +COLONCOLON : DColon; +COMMA : Comma; +DOT : Dot; +EQUAL : Equal; +LBRACE : LBrace; +LBRACK : LBrack; +LPAREN : LParen; +OR : Pipe; +PLUS : Plus; +QM : Question; +RANGE : Range; +RBRACE : RBrace; +RBRACK : RBrack; +REWRITE : RArrow; +ROOT : '^'; +RPAREN : RParen; +SEMI : Semi; +SEMPREDOP : '=>'; +STAR : Star; +TREE_BEGIN : '^('; +DOLLAR : Dollar; +PEQ : PlusAssign; +NOT : Tilde; + +WS: (' ' | '\t' | '\r'? '\n')+ -> channel(OFF_CHANNEL); + +TOKEN_REF: 'A' .. 'Z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')*; + +RULE_REF: 'a' .. 'z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')*; // ====================================================== // Lexer fragments @@ -201,163 +186,122 @@ RULE_REF // ----------------------------------- // Whitespace & Comments -fragment Ws - : Hws - | Vws - ; +fragment Ws: Hws | Vws; -fragment Hws - : [ \t] - ; +fragment Hws: [ \t]; -fragment Vws - : [\r\n\f] - ; +fragment Vws: [\r\n\f]; -fragment BlockComment - : '/*' .*? ('*/' | EOF) - ; +fragment BlockComment: '/*' .*? ('*/' | EOF); -fragment DocComment - : '/**' .*? ('*/' | EOF) - ; +fragment DocComment: '/**' .*? ('*/' | EOF); -fragment LineComment - : '//' ~ [\r\n]* - ; +fragment LineComment: '//' ~ [\r\n]*; // ----------------------------------- // Escapes // Any kind of escaped character that we can embed within ANTLR literal strings. -fragment EscSeq - : Esc ([btnfr"'\\] | UnicodeEsc | OctEsc | . | EOF) - ; +fragment EscSeq: Esc ([btnfr"'\\] | UnicodeEsc | OctEsc | . | EOF); -fragment EscAny - : Esc . - ; +fragment EscAny: Esc .; -fragment UnicodeEsc - : 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)? - ; +fragment UnicodeEsc: 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)?; -fragment OctEsc - : OctDigit (OctDigit OctDigit?)? - ; +fragment OctEsc: OctDigit (OctDigit OctDigit?)?; // ----------------------------------- // Numerals -fragment DecimalNumeral - : '0' - | [1-9] DecDigit* - ; - // ----------------------------------- - // Digits +fragment DecimalNumeral: '0' | [1-9] DecDigit*; +// ----------------------------------- +// Digits -fragment HexDigit - : [0-9a-fA-F] - ; +fragment HexDigit: [0-9a-fA-F]; -fragment DecDigit - : [0-9] - ; +fragment DecDigit: [0-9]; -fragment OctDigit - : [0-7] - ; +fragment OctDigit: [0-7]; // ----------------------------------- // Literals -fragment BoolLiteral - : 'true' - | 'false' - ; - -fragment CharLiteral - : SQuote (EscSeq | ~ ['\r\n\\]) SQuote - ; - -fragment SQuoteLiteral - : SQuote (EscSeq | ~ ['\r\n\\])* SQuote - ; - -fragment DQuoteLiteral - : DQuote (EscSeq | ~ ["\r\n\\])* DQuote - ; - -fragment USQuoteLiteral - : SQuote (EscSeq | ~ ['\r\n\\])* - ; - // ----------------------------------- - // Character ranges - -fragment NameChar - : NameStartChar - | '0' .. '9' - | Underscore - | '\u00B7' - | '\u0300' .. '\u036F' - | '\u203F' .. '\u2040' - ; - -fragment NameStartChar - : 'A' .. 'Z' - | 'a' .. 'z' - | '\u00C0' .. '\u00D6' - | '\u00D8' .. '\u00F6' - | '\u00F8' .. '\u02FF' - | '\u0370' .. '\u037D' - | '\u037F' .. '\u1FFF' - | '\u200C' .. '\u200D' - | '\u2070' .. '\u218F' - | '\u2C00' .. '\u2FEF' - | '\u3001' .. '\uD7FF' - | '\uF900' .. '\uFDCF' - | '\uFDF0' .. '\uFFFD' - ; +fragment BoolLiteral: 'true' | 'false'; + +fragment CharLiteral: SQuote (EscSeq | ~ ['\r\n\\]) SQuote; + +fragment SQuoteLiteral: SQuote (EscSeq | ~ ['\r\n\\])* SQuote; + +fragment DQuoteLiteral: DQuote (EscSeq | ~ ["\r\n\\])* DQuote; + +fragment USQuoteLiteral: SQuote (EscSeq | ~ ['\r\n\\])*; +// ----------------------------------- +// Character ranges + +fragment NameChar: + NameStartChar + | '0' .. '9' + | Underscore + | '\u00B7' + | '\u0300' .. '\u036F' + | '\u203F' .. '\u2040' +; + +fragment NameStartChar: + 'A' .. 'Z' + | 'a' .. 'z' + | '\u00C0' .. '\u00D6' + | '\u00D8' .. '\u00F6' + | '\u00F8' .. '\u02FF' + | '\u0370' .. '\u037D' + | '\u037F' .. '\u1FFF' + | '\u200C' .. '\u200D' + | '\u2070' .. '\u218F' + | '\u2C00' .. '\u2FEF' + | '\u3001' .. '\uD7FF' + | '\uF900' .. '\uFDCF' + | '\uFDF0' .. '\uFFFD' +; // ignores | ['\u10000-'\uEFFFF] ; // ----------------------------------- // Types -fragment Int : 'int' ; +fragment Int: 'int'; // ----------------------------------- // Symbols -fragment Esc : '\\' ; -fragment Colon : ':' ; -fragment DColon : '::' ; -fragment SQuote : '\'' ; -fragment DQuote : '"' ; -fragment LParen : '(' ; -fragment RParen : ')' ; -fragment LBrace : '{' ; -fragment RBrace : '}' ; -fragment LBrack : '[' ; -fragment RBrack : ']' ; -fragment RArrow : '->' ; -fragment Lt : '<' ; -fragment Gt : '>' ; -fragment Equal : '=' ; -fragment Question : '?' ; -fragment Star : '*' ; -fragment Plus : '+' ; -fragment PlusAssign : '+=' ; -fragment Underscore : '_' ; -fragment Pipe : '|' ; -fragment Dollar : '$' ; -fragment Comma : ',' ; -fragment Semi : ';' ; -fragment Dot : '.' ; -fragment Range : '..' ; -fragment At : '@' ; -fragment Pound : '#' ; -fragment Tilde : '~' ; +fragment Esc : '\\'; +fragment Colon : ':'; +fragment DColon : '::'; +fragment SQuote : '\''; +fragment DQuote : '"'; +fragment LParen : '('; +fragment RParen : ')'; +fragment LBrace : '{'; +fragment RBrace : '}'; +fragment LBrack : '['; +fragment RBrack : ']'; +fragment RArrow : '->'; +fragment Lt : '<'; +fragment Gt : '>'; +fragment Equal : '='; +fragment Question : '?'; +fragment Star : '*'; +fragment Plus : '+'; +fragment PlusAssign : '+='; +fragment Underscore : '_'; +fragment Pipe : '|'; +fragment Dollar : '$'; +fragment Comma : ','; +fragment Semi : ';'; +fragment Dot : '.'; +fragment Range : '..'; +fragment At : '@'; +fragment Pound : '#'; +fragment Tilde : '~'; // ====================================================== // Lexer modes @@ -366,35 +310,20 @@ fragment Tilde : '~' ; mode Argument; // E.g., [int x, List a[]] -NESTED_ARGUMENT - : LBrack -> type (ARGUMENT_CONTENT) , pushMode (Argument) - ; +NESTED_ARGUMENT: LBrack -> type (ARGUMENT_CONTENT), pushMode (Argument); -ARGUMENT_ESCAPE - : EscAny -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_ESCAPE: EscAny -> type (ARGUMENT_CONTENT); -ARGUMENT_STRING_LITERAL - : DQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_STRING_LITERAL: DQuoteLiteral -> type (ARGUMENT_CONTENT); -ARGUMENT_CHAR_LITERAL - : SQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_CHAR_LITERAL: SQuoteLiteral -> type (ARGUMENT_CONTENT); -END_ARGUMENT - : RBrack - { this.handleEndArgument(); } - ; - // added this to return non-EOF token type here. EOF does something weird +END_ARGUMENT: RBrack { this.handleEndArgument(); }; +// added this to return non-EOF token type here. EOF does something weird -UNTERMINATED_ARGUMENT - : EOF -> popMode - ; +UNTERMINATED_ARGUMENT: EOF -> popMode; -ARGUMENT_CONTENT - : . - ; +ARGUMENT_CONTENT: .; // ------------------------- // Actions @@ -407,182 +336,96 @@ ARGUMENT_CONTENT // in their own alts so as not to inadvertantly match {}. mode Actionx; -NESTED_ACTION - : LBrace -> type (ACTION_CONTENT) , pushMode (Actionx) - ; +NESTED_ACTION: LBrace -> type (ACTION_CONTENT), pushMode (Actionx); -ACTION_ESCAPE - : EscAny -> type (ACTION_CONTENT) - ; +ACTION_ESCAPE: EscAny -> type (ACTION_CONTENT); -ACTION_STRING_LITERAL - : DQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_STRING_LITERAL: DQuoteLiteral -> type (ACTION_CONTENT); -ACTION_CHAR_LITERAL - : SQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_CHAR_LITERAL: SQuoteLiteral -> type (ACTION_CONTENT); -ACTION_DOC_COMMENT - : DocComment -> type (ACTION_CONTENT) - ; +ACTION_DOC_COMMENT: DocComment -> type (ACTION_CONTENT); -ACTION_BLOCK_COMMENT - : BlockComment -> type (ACTION_CONTENT) - ; +ACTION_BLOCK_COMMENT: BlockComment -> type (ACTION_CONTENT); -ACTION_LINE_COMMENT - : LineComment -> type (ACTION_CONTENT) - ; +ACTION_LINE_COMMENT: LineComment -> type (ACTION_CONTENT); -END_ACTION - : RBrace - { this.handleEndAction(); } - ; +END_ACTION: RBrace { this.handleEndAction(); }; -UNTERMINATED_ACTION - : EOF -> popMode - ; +UNTERMINATED_ACTION: EOF -> popMode; -ACTION_CONTENT - : . - ; +ACTION_CONTENT: .; // ------------------------- mode Options; -OPT_DOC_COMMENT - : DocComment -> type (DOC_COMMENT) , channel (OFF_CHANNEL) - ; +OPT_DOC_COMMENT: DocComment -> type (DOC_COMMENT), channel (OFF_CHANNEL); -OPT_BLOCK_COMMENT - : BlockComment -> type (ML_COMMENT) , channel (OFF_CHANNEL) - ; +OPT_BLOCK_COMMENT: BlockComment -> type (ML_COMMENT), channel (OFF_CHANNEL); -OPT_LINE_COMMENT - : LineComment -> type (SL_COMMENT) , channel (OFF_CHANNEL) - ; +OPT_LINE_COMMENT: LineComment -> type (SL_COMMENT), channel (OFF_CHANNEL); -OPT_LBRACE - : LBrace - { this.handleOptionsLBrace(); } - ; +OPT_LBRACE: LBrace { this.handleOptionsLBrace(); }; -OPT_RBRACE - : RBrace -> type (RBRACE) , popMode - ; +OPT_RBRACE: RBrace -> type (RBRACE), popMode; -OPT_ID - : Id -> type (ID) - ; +OPT_ID: Id -> type (ID); -OPT_DOT - : Dot -> type (DOT) - ; +OPT_DOT: Dot -> type (DOT); -OPT_ASSIGN - : Equal -> type (EQUAL) - ; +OPT_ASSIGN: Equal -> type (EQUAL); -OPT_STRING_LITERAL - : SQuoteLiteral -> type (CHAR_LITERAL) - ; +OPT_STRING_LITERAL: SQuoteLiteral -> type (CHAR_LITERAL); -OPT_STRING_LITERAL2 - : DQuoteLiteral -> type (STRING_LITERAL) - ; +OPT_STRING_LITERAL2: DQuoteLiteral -> type (STRING_LITERAL); -OPT_RANGE - : Range -> type(RANGE) - ; +OPT_RANGE: Range -> type(RANGE); -OPT_INT - : DecimalNumeral -> type (INT) - ; +OPT_INT: DecimalNumeral -> type (INT); -OPT_STAR - : Star -> type (STAR) - ; +OPT_STAR: Star -> type (STAR); -OPT_SEMI - : Semi -> type (SEMI) - ; +OPT_SEMI: Semi -> type (SEMI); -OPT_WS - : Ws+ -> type (WS) , channel (OFF_CHANNEL) - ; +OPT_WS: Ws+ -> type (WS), channel (OFF_CHANNEL); // ------------------------- mode Tokens; -TOK_DOC_COMMENT - : DocComment -> type (DOC_COMMENT) , channel (OFF_CHANNEL) - ; - -TOK_BLOCK_COMMENT - : BlockComment -> type (ML_COMMENT) , channel (OFF_CHANNEL) - ; +TOK_DOC_COMMENT: DocComment -> type (DOC_COMMENT), channel (OFF_CHANNEL); -TOK_LINE_COMMENT - : LineComment -> type (SL_COMMENT) , channel (OFF_CHANNEL) - ; +TOK_BLOCK_COMMENT: BlockComment -> type (ML_COMMENT), channel (OFF_CHANNEL); -TOK_LBRACE - : LBrace -> type (LBRACE) - ; +TOK_LINE_COMMENT: LineComment -> type (SL_COMMENT), channel (OFF_CHANNEL); -TOK_RBRACE - : RBrace -> type (RBRACE) , popMode - ; +TOK_LBRACE: LBrace -> type (LBRACE); -TOK_ID - : Id -> type (TOKEN_REF) - ; +TOK_RBRACE: RBrace -> type (RBRACE), popMode; -TOK_EQ - : Equal -> type (EQUAL) - ; +TOK_ID: Id -> type (TOKEN_REF); -TOK_CL - : '\'' LITERAL_CHAR '\'' -> type(CHAR_LITERAL) - ; +TOK_EQ: Equal -> type (EQUAL); -TOK_SL - : '"' LIT_STR* '"' -> type(STRING_LITERAL) - ; +TOK_CL: '\'' LITERAL_CHAR '\'' -> type(CHAR_LITERAL); -TOK_SEMI - : Semi -> type (SEMI) - ; +TOK_SL: '"' LIT_STR* '"' -> type(STRING_LITERAL); -TOK_RANGE - : Range -> type(RANGE) - ; +TOK_SEMI: Semi -> type (SEMI); -TOK_WS - : Ws+ -> type (WS) , channel (OFF_CHANNEL) - ; +TOK_RANGE: Range -> type(RANGE); +TOK_WS: Ws+ -> type (WS), channel (OFF_CHANNEL); // ------------------------- mode LexerCharSet; -LEXER_CHAR_SET_BODY - : (~ [\]\\] | EscAny)+ -> more - ; +LEXER_CHAR_SET_BODY: (~ [\]\\] | EscAny)+ -> more; -LEXER_CHAR_SET - : RBrack -> popMode - ; +LEXER_CHAR_SET: RBrack -> popMode; -UNTERMINATED_CHAR_SET - : EOF -> popMode - ; +UNTERMINATED_CHAR_SET: EOF -> popMode; // ------------------------------------------------------------------------------ // Grammar specific Keywords, Punctuation, etc. -fragment Id - : NameStartChar NameChar* - ; - +fragment Id: NameStartChar NameChar*; \ No newline at end of file diff --git a/antlr/antlr2/ANTLRv2Parser.g4 b/antlr/antlr2/ANTLRv2Parser.g4 index ada6d0a1a5..268b3dece2 100644 --- a/antlr/antlr2/ANTLRv2Parser.g4 +++ b/antlr/antlr2/ANTLRv2Parser.g4 @@ -25,6 +25,10 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $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 ANTLRv2Parser; options @@ -33,239 +37,234 @@ options } grammar_ - : header_* fileOptionsSpec? classDef* EOF - ; + : header_* fileOptionsSpec? classDef* EOF + ; header_ - : HEADER STRING_LITERAL? actionBlock - ; + : HEADER STRING_LITERAL? actionBlock + ; classDef - : actionBlock? DOC_COMMENT? ( lexerSpec | treeParserSpec | parserSpec ) rules - ; - + : actionBlock? DOC_COMMENT? (lexerSpec | treeParserSpec | parserSpec) rules + ; + fileOptionsSpec - : OPTIONS LBRACE option* RBRACE - ; + : OPTIONS LBRACE option* RBRACE + ; parserOptionsSpec - : OPTIONS LBRACE option* RBRACE - ; + : OPTIONS LBRACE option* RBRACE + ; treeParserOptionsSpec - : OPTIONS LBRACE option* RBRACE - ; + : OPTIONS LBRACE option* RBRACE + ; lexerOptionsSpec - : OPTIONS LBRACE lexerOption* RBRACE - ; + : OPTIONS LBRACE lexerOption* RBRACE + ; subruleOptionsSpec - : OPTIONS LBRACE option* RBRACE - ; + : OPTIONS LBRACE option* RBRACE + ; option - : id_ EQUAL optionValue SEMI - ; + : id_ EQUAL optionValue SEMI + ; optionValue - : qualifiedID - | STRING_LITERAL - | CHAR_LITERAL - | INT - ; + : qualifiedID + | STRING_LITERAL + | CHAR_LITERAL + | INT + ; lexerOption - : id_ EQUAL lexerOptionValue SEMI - ; + : id_ EQUAL lexerOptionValue SEMI + ; lexerOptionValue - : charSet - | optionValue - ; + : charSet + | optionValue + ; charSet - : setBlockElement ( OR setBlockElement)* - ; + : setBlockElement (OR setBlockElement)* + ; setBlockElement - : CHAR_LITERAL (RANGE CHAR_LITERAL)? - ; + : CHAR_LITERAL (RANGE CHAR_LITERAL)? + ; tokensSpec - : TOKENS LBRACE tokenEntry+ RBRACE - ; + : TOKENS LBRACE tokenEntry+ RBRACE + ; tokenEntry - : ( - TOKEN_REF - ( EQUAL STRING_LITERAL )? - tokensSpecOptions? - | STRING_LITERAL - tokensSpecOptions? - ) - SEMI - ; + : (TOKEN_REF ( EQUAL STRING_LITERAL)? tokensSpecOptions? | STRING_LITERAL tokensSpecOptions?) SEMI + ; tokensSpecOptions - : OPEN_ELEMENT_OPTION id_ EQUAL optionValue ( SEMI id_ EQUAL optionValue )* CLOSE_ELEMENT_OPTION - ; + : OPEN_ELEMENT_OPTION id_ EQUAL optionValue (SEMI id_ EQUAL optionValue)* CLOSE_ELEMENT_OPTION + ; superClass - : LPAREN STRING_LITERAL RPAREN - ; + : LPAREN STRING_LITERAL RPAREN + ; parserSpec - : CLASS id_ (EXTENDS PARSER superClass? | ) SEMI parserOptionsSpec? tokensSpec? actionBlock? - ; + : CLASS id_ (EXTENDS PARSER superClass? |) SEMI parserOptionsSpec? tokensSpec? actionBlock? + ; lexerSpec - : (LEXCLASS id_ | CLASS id_ EXTENDS LEXER superClass?) - SEMI lexerOptionsSpec? tokensSpec? actionBlock? - ; + : (LEXCLASS id_ | CLASS id_ EXTENDS LEXER superClass?) SEMI lexerOptionsSpec? tokensSpec? actionBlock? + ; treeParserSpec - : CLASS id_ EXTENDS TREEPARSER superClass? SEMI treeParserOptionsSpec? tokensSpec? actionBlock? - ; + : CLASS id_ EXTENDS TREEPARSER superClass? SEMI treeParserOptionsSpec? tokensSpec? actionBlock? + ; rules - : rule_+ - ; + : rule_+ + ; rule_ - : DOC_COMMENT? (PROTECTED | PUBLIC | PRIVATE)? id_ BANG? argActionBlock? (RETURNS argActionBlock)? throwsSpec? ruleOptionsSpec? ruleAction* COLON altList SEMI exceptionGroup? - ; + : DOC_COMMENT? (PROTECTED | PUBLIC | PRIVATE)? id_ BANG? argActionBlock? ( + RETURNS argActionBlock + )? throwsSpec? ruleOptionsSpec? ruleAction* COLON altList SEMI exceptionGroup? + ; ruleOptionsSpec - : OPTIONS LBRACE option* RBRACE - ; + : OPTIONS LBRACE option* RBRACE + ; throwsSpec - : THROWS id_ (COMMA id_)* - ; + : THROWS id_ (COMMA id_)* + ; block - : alternative (OR alternative )* - ; + : alternative (OR alternative)* + ; alternative - : BANG? element* - ; + : BANG? element* + ; exceptionGroup - : exceptionSpec+ - ; + : exceptionSpec+ + ; exceptionSpec - : EXCEPTION - argActionBlock? - exceptionHandler* - ; + : EXCEPTION argActionBlock? exceptionHandler* + ; exceptionSpecNoLabel - : EXCEPTION - exceptionHandler* - ; + : EXCEPTION exceptionHandler* + ; exceptionHandler - : CATCH argActionBlock actionBlock - ; + : CATCH argActionBlock actionBlock + ; element - : elementNoOptionSpec elementOptionSpec? - ; + : elementNoOptionSpec elementOptionSpec? + ; elementOptionSpec - : OPEN_ELEMENT_OPTION - id_ EQUAL optionValue - ( SEMI id_ EQUAL optionValue )* - CLOSE_ELEMENT_OPTION - ; + : OPEN_ELEMENT_OPTION id_ EQUAL optionValue (SEMI id_ EQUAL optionValue)* CLOSE_ELEMENT_OPTION + ; elementNoOptionSpec - : id_ EQUAL (id_ COLON)? (rule_ref_or_keyword_as argActionBlock? BANG? | TOKEN_REF argActionBlock?) - | (id_ COLON)? (rule_ref_or_keyword_as argActionBlock? BANG? | range_ | terminal_ | NOT ( notTerminal | ebnf) | ebnf) - | actionBlock QM? - | tree_ - ; + : id_ EQUAL (id_ COLON)? ( + rule_ref_or_keyword_as argActionBlock? BANG? + | TOKEN_REF argActionBlock? + ) + | (id_ COLON)? ( + rule_ref_or_keyword_as argActionBlock? BANG? + | range_ + | terminal_ + | NOT ( notTerminal | ebnf) + | ebnf + ) + | actionBlock QM? + | tree_ + ; rule_ref_or_keyword_as - : RULE_REF - | GRAMMAR - | TREE - ; + : RULE_REF + | GRAMMAR + | TREE + ; tree_ - : TREE_BEGIN rootNode element+ RPAREN - ; + : TREE_BEGIN rootNode element+ RPAREN + ; rootNode - : (id_ COLON)? terminal_ - ; + : (id_ COLON)? terminal_ + ; ebnf - : LPAREN ( subruleOptionsSpec actionBlock? COLON | actionBlock COLON)? block RPAREN - ( (QM | STAR | PLUS)? BANG? | SEMPREDOP) - ; + : LPAREN (subruleOptionsSpec actionBlock? COLON | actionBlock COLON)? block RPAREN ( + (QM | STAR | PLUS)? BANG? + | SEMPREDOP + ) + ; ast_type_spec - : (ROOT | BANG)? - ; + : (ROOT | BANG)? + ; range_ - : CHAR_LITERAL RANGE CHAR_LITERAL BANG? - | (TOKEN_REF | STRING_LITERAL) RANGE ast_type_spec - ; + : CHAR_LITERAL RANGE CHAR_LITERAL BANG? + | (TOKEN_REF | STRING_LITERAL) RANGE ast_type_spec + ; terminal_ - : CHAR_LITERAL BANG? - | TOKEN_REF ast_type_spec argActionBlock? - | STRING_LITERAL ast_type_spec - | DOT ast_type_spec - ; + : CHAR_LITERAL BANG? + | TOKEN_REF ast_type_spec argActionBlock? + | STRING_LITERAL ast_type_spec + | DOT ast_type_spec + ; notTerminal - : CHAR_LITERAL BANG? - | TOKEN_REF ast_type_spec - ; + : CHAR_LITERAL BANG? + | TOKEN_REF ast_type_spec + ; qualifiedID - : id_ ( DOT id_)* - ; + : id_ (DOT id_)* + ; id_ - : TOKEN_REF - | RULE_REF - | GRAMMAR - | TREE - ; - + : TOKEN_REF + | RULE_REF + | GRAMMAR + | TREE + ; action - : AT (actionScopeName COLONCOLON)? id_ actionBlock - ; + : AT (actionScopeName COLONCOLON)? id_ actionBlock + ; actionScopeName - : id_ - | LEXER - | PARSER - ; + : id_ + | LEXER + | PARSER + ; - ruleAction - : actionBlock - ; + : actionBlock + ; altList - : alternative (OR alternative )* - ; + : alternative (OR alternative)* + ; actionBlock - : BEGIN_ACTION ACTION_CONTENT* END_ACTION - ; + : BEGIN_ACTION ACTION_CONTENT* END_ACTION + ; argActionBlock - : BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT - ; - - + : BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT + ; \ No newline at end of file diff --git a/antlr/antlr3/ANTLRv3Lexer.g4 b/antlr/antlr3/ANTLRv3Lexer.g4 index 850321c7cf..5571c2e0dd 100644 --- a/antlr/antlr3/ANTLRv3Lexer.g4 +++ b/antlr/antlr3/ANTLRv3Lexer.g4 @@ -25,15 +25,24 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ANTLRv3Lexer; -options { superClass = LexerAdaptor; } +options { + superClass = LexerAdaptor; +} -channels { OFF_CHANNEL } +channels { + OFF_CHANNEL +} tokens { DOC_COMMENT, - PARSER, + PARSER, LEXER, RULE, BLOCK, @@ -61,8 +70,8 @@ tokens { TEMPLATE, SCOPE, SEMPRED, - GATED_SEMPRED, // {p}? => - SYN_SEMPRED, // (...) => it's a manually-specified synpred converted to sempred + GATED_SEMPRED, // {p}? => + SYN_SEMPRED, // (...) => it's a manually-specified synpred converted to sempred BACKTRACK_SEMPRED, // auto backtracking mode syn pred converted to sempred FRAGMENT, TREE_BEGIN, @@ -73,57 +82,45 @@ tokens { ACTION_CONTENT } -DOC_COMMENT - : '/**' .*? ('*/' | EOF) -> channel(OFF_CHANNEL) - ; +DOC_COMMENT: '/**' .*? ('*/' | EOF) -> channel(OFF_CHANNEL); -SL_COMMENT - : '//' ~ [\r\n]* -> channel(OFF_CHANNEL) - ; +SL_COMMENT: '//' ~ [\r\n]* -> channel(OFF_CHANNEL); -ML_COMMENT - : '/*' .*? '*/' -> channel(OFF_CHANNEL) - ; +ML_COMMENT: '/*' .*? '*/' -> channel(OFF_CHANNEL); -INT - : '0' .. '9'+ - ; +INT: '0' .. '9'+; -CHAR_LITERAL - : '\'' LITERAL_CHAR '\'' - ; +CHAR_LITERAL: '\'' LITERAL_CHAR '\''; -STRING_LITERAL - : '\'' LITERAL_CHAR LITERAL_CHAR* '\'' - ; +STRING_LITERAL: '\'' LITERAL_CHAR LITERAL_CHAR* '\''; -fragment LITERAL_CHAR - : ESC - | ~ ('\'' | '\\') - ; +fragment LITERAL_CHAR: ESC | ~ ('\'' | '\\'); // This seems to be available in Antlr3. -DOUBLE_QUOTE_STRING_LITERAL - : '"' (ESC | ~ ('\\' | '"'))* '"' - ; +DOUBLE_QUOTE_STRING_LITERAL: '"' (ESC | ~ ('\\' | '"'))* '"'; // This seems to be available in Antlr3. -DOUBLE_ANGLE_STRING_LITERAL - : '<<' .*? '>>' - ; - -fragment ESC - : '\\' ('n' | 'r' | 't' | 'b' | 'f' | '"' | '\'' | '\\' | '>' | 'u' XDIGIT XDIGIT XDIGIT XDIGIT | .) - ; - -fragment XDIGIT - : '0' .. '9' - | 'a' .. 'f' - | 'A' .. 'F' - ; - +DOUBLE_ANGLE_STRING_LITERAL: '<<' .*? '>>'; + +fragment ESC: + '\\' ( + 'n' + | 'r' + | 't' + | 'b' + | 'f' + | '"' + | '\'' + | '\\' + | '>' + | 'u' XDIGIT XDIGIT XDIGIT XDIGIT + | . + ) +; + +fragment XDIGIT: '0' .. '9' | 'a' .. 'f' | 'A' .. 'F'; // ------------------------- // Arguments @@ -132,17 +129,12 @@ fragment XDIGIT // to a rule invocation, or input parameters to a rule specification // are contained within square brackets. -BEGIN_ARGUMENT - : LBrack - { this.handleBeginArgument(); } - ; +BEGIN_ARGUMENT: LBrack { this.handleBeginArgument(); }; // ------------------------- // Actions -BEGIN_ACTION - : LBrace -> pushMode (Actionx) - ; +BEGIN_ACTION: LBrace -> pushMode (Actionx); // ------------------------- // Keywords @@ -151,71 +143,60 @@ BEGIN_ACTION // they would be ambiguous with the keyword vs some other identifier. OPTIONS, // TOKENS, & CHANNELS blocks are handled idiomatically in dedicated lexical modes. -OPTIONS - : 'options' -> pushMode (Options) - ; - -TOKENS - : 'tokens' -> pushMode (Tokens) - ; +OPTIONS: 'options' -> pushMode (Options); -CATCH : 'catch' ; -FINALLY : 'finally' ; -FRAGMENT : 'fragment' ; -GRAMMAR : 'grammar' ; -LEXER : 'lexer' ; -PARSER : 'parser' ; -PRIVATE : 'private' ; -PROTECTED : 'protected' ; -PUBLIC : 'public' ; -RETURNS : 'returns' ; -SCOPE : 'scope' ; -THROWS : 'throws' ; -TREE : 'tree' ; +TOKENS: 'tokens' -> pushMode (Tokens); +CATCH : 'catch'; +FINALLY : 'finally'; +FRAGMENT : 'fragment'; +GRAMMAR : 'grammar'; +LEXER : 'lexer'; +PARSER : 'parser'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PUBLIC : 'public'; +RETURNS : 'returns'; +SCOPE : 'scope'; +THROWS : 'throws'; +TREE : 'tree'; -fragment WS_LOOP : (WS | SL_COMMENT | ML_COMMENT)* ; +fragment WS_LOOP: (WS | SL_COMMENT | ML_COMMENT)*; //// ================================= - -AT : At ; -BANG : '!' ; -COLON : Colon ; -COLONCOLON : DColon ; -COMMA : Comma ; -DOT : Dot ; -EQUAL : Equal ; -LBRACE : LBrace ; -LBRACK : LBrack ; -LPAREN : LParen ; -OR : Pipe ; -PLUS : Plus ; -QM : Question ; -RANGE : '..' ; -RBRACE : RBrace ; -RBRACK : RBrack ; -REWRITE : RArrow ; -ROOT : '^' ; -RPAREN : RParen ; -SEMI : Semi ; -SEMPREDOP : '=>' ; -STAR : Star ; -TREE_BEGIN : '^(' ; -DOLLAR : Dollar ; -PEQ : PlusAssign ; -NOT : Tilde ; - -WS - : (' ' | '\t' | '\r'? '\n')+ -> channel(OFF_CHANNEL) - ; - -TOKEN_REF - : 'A' .. 'Z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')* - ; - -RULE_REF - : 'a' .. 'z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')* - ; + +AT : At; +BANG : '!'; +COLON : Colon; +COLONCOLON : DColon; +COMMA : Comma; +DOT : Dot; +EQUAL : Equal; +LBRACE : LBrace; +LBRACK : LBrack; +LPAREN : LParen; +OR : Pipe; +PLUS : Plus; +QM : Question; +RANGE : '..'; +RBRACE : RBrace; +RBRACK : RBrack; +REWRITE : RArrow; +ROOT : '^'; +RPAREN : RParen; +SEMI : Semi; +SEMPREDOP : '=>'; +STAR : Star; +TREE_BEGIN : '^('; +DOLLAR : Dollar; +PEQ : PlusAssign; +NOT : Tilde; + +WS: (' ' | '\t' | '\r'? '\n')+ -> channel(OFF_CHANNEL); + +TOKEN_REF: 'A' .. 'Z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')*; + +RULE_REF: 'a' .. 'z' ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9')*; // ====================================================== // Lexer fragments @@ -223,172 +204,123 @@ RULE_REF // ----------------------------------- // Whitespace & Comments -fragment Ws - : Hws - | Vws - ; - -fragment Hws - : [ \t] - ; - -fragment Vws - : [\r\n\f] - ; - -fragment BlockComment - : '/*' .*? ('*/' | EOF) - ; - -fragment DocComment - : '/**' .*? ('*/' | EOF) - ; - -fragment LineComment - : '//' ~ [\r\n]* - ; - // ----------------------------------- - // Escapes - // Any kind of escaped character that we can embed within ANTLR literal strings. - -fragment EscSeq - : Esc ([btnfr"'\\] | UnicodeEsc | . | EOF) - ; - -fragment EscAny - : Esc . - ; - -fragment UnicodeEsc - : 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)? - ; - // ----------------------------------- - // Numerals - -fragment DecimalNumeral - : '0' - | [1-9] DecDigit* - ; - // ----------------------------------- - // Digits - -fragment HexDigit - : [0-9a-fA-F] - ; - -fragment DecDigit - : [0-9] - ; - // ----------------------------------- - // Literals - -fragment BoolLiteral - : 'true' - | 'false' - ; - -fragment CharLiteral - : SQuote (EscSeq | ~ ['\r\n\\]) SQuote - ; - -fragment SQuoteLiteral - : SQuote (EscSeq | ~ ['\r\n\\])* SQuote - ; - -fragment DQuoteLiteral - : DQuote (EscSeq | ~ ["\r\n\\])* DQuote - ; - -fragment USQuoteLiteral - : SQuote (EscSeq | ~ ['\r\n\\])* - ; - // ----------------------------------- - // Character ranges - -fragment NameChar - : NameStartChar - | '0' .. '9' - | Underscore - | '\u00B7' - | '\u0300' .. '\u036F' - | '\u203F' .. '\u2040' - ; - -fragment NameStartChar - : 'A' .. 'Z' - | 'a' .. 'z' - | '\u00C0' .. '\u00D6' - | '\u00D8' .. '\u00F6' - | '\u00F8' .. '\u02FF' - | '\u0370' .. '\u037D' - | '\u037F' .. '\u1FFF' - | '\u200C' .. '\u200D' - | '\u2070' .. '\u218F' - | '\u2C00' .. '\u2FEF' - | '\u3001' .. '\uD7FF' - | '\uF900' .. '\uFDCF' - | '\uFDF0' .. '\uFFFD' - ; +fragment Ws: Hws | Vws; + +fragment Hws: [ \t]; + +fragment Vws: [\r\n\f]; + +fragment BlockComment: '/*' .*? ('*/' | EOF); + +fragment DocComment: '/**' .*? ('*/' | EOF); + +fragment LineComment: '//' ~ [\r\n]*; +// ----------------------------------- +// Escapes +// Any kind of escaped character that we can embed within ANTLR literal strings. + +fragment EscSeq: Esc ([btnfr"'\\] | UnicodeEsc | . | EOF); + +fragment EscAny: Esc .; + +fragment UnicodeEsc: 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)?; +// ----------------------------------- +// Numerals + +fragment DecimalNumeral: '0' | [1-9] DecDigit*; +// ----------------------------------- +// Digits + +fragment HexDigit: [0-9a-fA-F]; + +fragment DecDigit: [0-9]; +// ----------------------------------- +// Literals + +fragment BoolLiteral: 'true' | 'false'; + +fragment CharLiteral: SQuote (EscSeq | ~ ['\r\n\\]) SQuote; + +fragment SQuoteLiteral: SQuote (EscSeq | ~ ['\r\n\\])* SQuote; + +fragment DQuoteLiteral: DQuote (EscSeq | ~ ["\r\n\\])* DQuote; + +fragment USQuoteLiteral: SQuote (EscSeq | ~ ['\r\n\\])*; +// ----------------------------------- +// Character ranges + +fragment NameChar: + NameStartChar + | '0' .. '9' + | Underscore + | '\u00B7' + | '\u0300' .. '\u036F' + | '\u203F' .. '\u2040' +; + +fragment NameStartChar: + 'A' .. 'Z' + | 'a' .. 'z' + | '\u00C0' .. '\u00D6' + | '\u00D8' .. '\u00F6' + | '\u00F8' .. '\u02FF' + | '\u0370' .. '\u037D' + | '\u037F' .. '\u1FFF' + | '\u200C' .. '\u200D' + | '\u2070' .. '\u218F' + | '\u2C00' .. '\u2FEF' + | '\u3001' .. '\uD7FF' + | '\uF900' .. '\uFDCF' + | '\uFDF0' .. '\uFFFD' +; // ignores | ['\u10000-'\uEFFFF] ; // ----------------------------------- // Types -fragment Int : 'int' ; +fragment Int: 'int'; // ----------------------------------- // Symbols -fragment Esc : '\\' ; -fragment Colon : ':' ; -fragment DColon : '::' ; - -fragment SQuote - : '\'' - ; - -fragment DQuote - : '"' - ; - -fragment LParen : '(' ; -fragment RParen : ')' ; -fragment LBrace : '{' ; -fragment RBrace : '}' ; -fragment LBrack : '[' ; -fragment RBrack : ']' ; -fragment RArrow : '->' ; - -fragment Lt - : '<' - ; - -fragment Gt - : '>' - ; - -fragment Equal : '=' ; -fragment Question : '?' ; -fragment Star : '*' ; -fragment Plus : '+' ; -fragment PlusAssign : '+=' ; -fragment Underscore : '_' ; -fragment Pipe : '|' ; -fragment Dollar : '$' ; -fragment Comma : ',' ; -fragment Semi : ';' ; -fragment Dot : '.' ; -fragment Range : '..' ; -fragment At : '@' ; - -fragment Pound - : '#' - ; - -fragment Tilde - : '~' - ; +fragment Esc : '\\'; +fragment Colon : ':'; +fragment DColon : '::'; + +fragment SQuote: '\''; + +fragment DQuote: '"'; + +fragment LParen : '('; +fragment RParen : ')'; +fragment LBrace : '{'; +fragment RBrace : '}'; +fragment LBrack : '['; +fragment RBrack : ']'; +fragment RArrow : '->'; + +fragment Lt: '<'; + +fragment Gt: '>'; + +fragment Equal : '='; +fragment Question : '?'; +fragment Star : '*'; +fragment Plus : '+'; +fragment PlusAssign : '+='; +fragment Underscore : '_'; +fragment Pipe : '|'; +fragment Dollar : '$'; +fragment Comma : ','; +fragment Semi : ';'; +fragment Dot : '.'; +fragment Range : '..'; +fragment At : '@'; + +fragment Pound: '#'; + +fragment Tilde: '~'; // ====================================================== // Lexer modes @@ -397,35 +329,20 @@ fragment Tilde mode Argument; // E.g., [int x, List a[]] -NESTED_ARGUMENT - : LBrack -> type (ARGUMENT_CONTENT) , pushMode (Argument) - ; +NESTED_ARGUMENT: LBrack -> type (ARGUMENT_CONTENT), pushMode (Argument); -ARGUMENT_ESCAPE - : EscAny -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_ESCAPE: EscAny -> type (ARGUMENT_CONTENT); -ARGUMENT_STRING_LITERAL - : DQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_STRING_LITERAL: DQuoteLiteral -> type (ARGUMENT_CONTENT); -ARGUMENT_CHAR_LITERAL - : SQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_CHAR_LITERAL: SQuoteLiteral -> type (ARGUMENT_CONTENT); -END_ARGUMENT - : RBrack - { this.handleEndArgument(); } - ; - // added this to return non-EOF token type here. EOF does something weird +END_ARGUMENT: RBrack { this.handleEndArgument(); }; +// added this to return non-EOF token type here. EOF does something weird -UNTERMINATED_ARGUMENT - : EOF -> popMode - ; +UNTERMINATED_ARGUMENT: EOF -> popMode; -ARGUMENT_CONTENT - : . - ; +ARGUMENT_CONTENT: .; // ------------------------- // Actions @@ -438,170 +355,90 @@ ARGUMENT_CONTENT // in their own alts so as not to inadvertantly match {}. mode Actionx; -NESTED_ACTION - : LBrace -> type (ACTION_CONTENT) , pushMode (Actionx) - ; +NESTED_ACTION: LBrace -> type (ACTION_CONTENT), pushMode (Actionx); -ACTION_ESCAPE - : EscAny -> type (ACTION_CONTENT) - ; +ACTION_ESCAPE: EscAny -> type (ACTION_CONTENT); -ACTION_STRING_LITERAL - : DQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_STRING_LITERAL: DQuoteLiteral -> type (ACTION_CONTENT); -ACTION_CHAR_LITERAL - : SQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_CHAR_LITERAL: SQuoteLiteral -> type (ACTION_CONTENT); -ACTION_DOC_COMMENT - : DocComment -> type (ACTION_CONTENT) - ; +ACTION_DOC_COMMENT: DocComment -> type (ACTION_CONTENT); -ACTION_BLOCK_COMMENT - : BlockComment -> type (ACTION_CONTENT) - ; +ACTION_BLOCK_COMMENT: BlockComment -> type (ACTION_CONTENT); -ACTION_LINE_COMMENT - : LineComment -> type (ACTION_CONTENT) - ; +ACTION_LINE_COMMENT: LineComment -> type (ACTION_CONTENT); -END_ACTION - : RBrace - { this.handleEndAction(); } - ; +END_ACTION: RBrace { this.handleEndAction(); }; -UNTERMINATED_ACTION - : EOF -> popMode - ; +UNTERMINATED_ACTION: EOF -> popMode; -ACTION_CONTENT - : . - ; +ACTION_CONTENT: .; // ------------------------- mode Options; -OPT_DOC_COMMENT - : DocComment -> type (DOC_COMMENT) , channel (OFF_CHANNEL) - ; +OPT_DOC_COMMENT: DocComment -> type (DOC_COMMENT), channel (OFF_CHANNEL); -OPT_BLOCK_COMMENT - : BlockComment -> type (ML_COMMENT) , channel (OFF_CHANNEL) - ; +OPT_BLOCK_COMMENT: BlockComment -> type (ML_COMMENT), channel (OFF_CHANNEL); -OPT_LINE_COMMENT - : LineComment -> type (SL_COMMENT) , channel (OFF_CHANNEL) - ; +OPT_LINE_COMMENT: LineComment -> type (SL_COMMENT), channel (OFF_CHANNEL); -OPT_LBRACE - : LBrace - { this.handleOptionsLBrace(); } - ; +OPT_LBRACE: LBrace { this.handleOptionsLBrace(); }; -OPT_RBRACE - : RBrace -> type (RBRACE) , popMode - ; +OPT_RBRACE: RBrace -> type (RBRACE), popMode; -OPT_ID - : Id -> type (ID) - ; +OPT_ID: Id -> type (ID); -OPT_DOT - : Dot -> type (DOT) - ; +OPT_DOT: Dot -> type (DOT); -OPT_ASSIGN - : Equal -> type (EQUAL) - ; +OPT_ASSIGN: Equal -> type (EQUAL); -OPT_STRING_LITERAL - : SQuoteLiteral -> type (STRING_LITERAL) - ; +OPT_STRING_LITERAL: SQuoteLiteral -> type (STRING_LITERAL); -OPT_INT - : DecimalNumeral -> type (INT) - ; +OPT_INT: DecimalNumeral -> type (INT); -OPT_STAR - : Star -> type (STAR) - ; +OPT_STAR: Star -> type (STAR); -OPT_SEMI - : Semi -> type (SEMI) - ; +OPT_SEMI: Semi -> type (SEMI); -OPT_WS - : Ws+ -> type (WS) , channel (OFF_CHANNEL) - ; +OPT_WS: Ws+ -> type (WS), channel (OFF_CHANNEL); // ------------------------- mode Tokens; -TOK_DOC_COMMENT - : DocComment -> type (DOC_COMMENT) , channel (OFF_CHANNEL) - ; +TOK_DOC_COMMENT: DocComment -> type (DOC_COMMENT), channel (OFF_CHANNEL); -TOK_BLOCK_COMMENT - : BlockComment -> type (ML_COMMENT) , channel (OFF_CHANNEL) - ; +TOK_BLOCK_COMMENT: BlockComment -> type (ML_COMMENT), channel (OFF_CHANNEL); -TOK_LINE_COMMENT - : LineComment -> type (SL_COMMENT) , channel (OFF_CHANNEL) - ; +TOK_LINE_COMMENT: LineComment -> type (SL_COMMENT), channel (OFF_CHANNEL); -TOK_LBRACE - : LBrace -> type (LBRACE) - ; +TOK_LBRACE: LBrace -> type (LBRACE); -TOK_RBRACE - : RBrace -> type (RBRACE) , popMode - ; +TOK_RBRACE: RBrace -> type (RBRACE), popMode; -TOK_ID - : Id -> type (TOKEN_REF) - ; +TOK_ID: Id -> type (TOKEN_REF); -TOK_EQ - : Equal -> type (EQUAL) - ; +TOK_EQ: Equal -> type (EQUAL); -TOK_CL - : '\'' LITERAL_CHAR '\'' -> type(CHAR_LITERAL) - ; +TOK_CL: '\'' LITERAL_CHAR '\'' -> type(CHAR_LITERAL); -TOK_SL - : '\'' LITERAL_CHAR LITERAL_CHAR* '\'' -> type(STRING_LITERAL) - ; +TOK_SL: '\'' LITERAL_CHAR LITERAL_CHAR* '\'' -> type(STRING_LITERAL); -TOK_SEMI - : Semi -> type (SEMI) - ; - -TOK_WS - : Ws+ -> type (WS) , channel (OFF_CHANNEL) - ; +TOK_SEMI: Semi -> type (SEMI); +TOK_WS: Ws+ -> type (WS), channel (OFF_CHANNEL); // ------------------------- mode LexerCharSet; -LEXER_CHAR_SET_BODY - : (~ [\]\\] | EscAny)+ -> more - ; +LEXER_CHAR_SET_BODY: (~ [\]\\] | EscAny)+ -> more; -LEXER_CHAR_SET - : RBrack -> popMode - ; +LEXER_CHAR_SET: RBrack -> popMode; -UNTERMINATED_CHAR_SET - : EOF -> popMode - ; +UNTERMINATED_CHAR_SET: EOF -> popMode; // ------------------------------------------------------------------------------ // Grammar specific Keywords, Punctuation, etc. -fragment Id - : NameStartChar NameChar* - ; - +fragment Id: NameStartChar NameChar*; \ No newline at end of file diff --git a/antlr/antlr3/ANTLRv3Parser.g4 b/antlr/antlr3/ANTLRv3Parser.g4 index 5ff9296293..a3317883ae 100644 --- a/antlr/antlr3/ANTLRv3Parser.g4 +++ b/antlr/antlr3/ANTLRv3Parser.g4 @@ -25,234 +25,236 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $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 ANTLRv3Parser; -options { tokenVocab = ANTLRv3Lexer; } +options { + tokenVocab = ANTLRv3Lexer; +} grammarDef - : DOC_COMMENT? (LEXER | PARSER | TREE| ) GRAMMAR id_ SEMI optionsSpec? tokensSpec? attrScope* action* rule_+ - EOF - ; + : DOC_COMMENT? (LEXER | PARSER | TREE |) GRAMMAR id_ SEMI optionsSpec? tokensSpec? attrScope* action* rule_+ EOF + ; tokensSpec - : TOKENS LBRACE tokenSpec+ RBRACE - ; + : TOKENS LBRACE tokenSpec+ RBRACE + ; tokenSpec - : TOKEN_REF ( EQUAL (STRING_LITERAL | CHAR_LITERAL) | ) SEMI - ; + : TOKEN_REF (EQUAL (STRING_LITERAL | CHAR_LITERAL) |) SEMI + ; attrScope - : SCOPE id_ actionBlock - ; + : SCOPE id_ actionBlock + ; action - : AT (actionScopeName COLONCOLON)? id_ actionBlock - ; + : AT (actionScopeName COLONCOLON)? id_ actionBlock + ; actionScopeName - : id_ - | LEXER - | PARSER - ; + : id_ + | LEXER + | PARSER + ; optionsSpec - : OPTIONS LBRACE option* RBRACE - ; + : OPTIONS LBRACE option* RBRACE + ; option - : id_ EQUAL optionValue SEMI - ; + : id_ EQUAL optionValue SEMI + ; optionValue - : id_ - | STRING_LITERAL - | CHAR_LITERAL - | INT - | STAR - ; + : id_ + | STRING_LITERAL + | CHAR_LITERAL + | INT + | STAR + ; rule_ - : DOC_COMMENT? (PROTECTED | PUBLIC | PRIVATE | FRAGMENT)? id_ BANG? argActionBlock? (RETURNS argActionBlock)? throwsSpec? optionsSpec? ruleScopeSpec? ruleAction* COLON altList SEMI exceptionGroup? - ; - + : DOC_COMMENT? (PROTECTED | PUBLIC | PRIVATE | FRAGMENT)? id_ BANG? argActionBlock? ( + RETURNS argActionBlock + )? throwsSpec? optionsSpec? ruleScopeSpec? ruleAction* COLON altList SEMI exceptionGroup? + ; + ruleAction - : AT id_ actionBlock - ; + : AT id_ actionBlock + ; throwsSpec - : THROWS id_ (COMMA id_)* - ; + : THROWS id_ (COMMA id_)* + ; ruleScopeSpec - : SCOPE actionBlock - | SCOPE id_ (COMMA id_)* SEMI - | SCOPE actionBlock SCOPE id_ (COMMA id_)* SEMI - ; + : SCOPE actionBlock + | SCOPE id_ (COMMA id_)* SEMI + | SCOPE actionBlock SCOPE id_ (COMMA id_)* SEMI + ; block - : LPAREN (optionsSpec? COLON)? - alternative rewrite (OR alternative rewrite )* - RPAREN - ; + : LPAREN (optionsSpec? COLON)? alternative rewrite (OR alternative rewrite)* RPAREN + ; altList - : alternative rewrite (OR alternative rewrite )* - ; + : alternative rewrite (OR alternative rewrite)* + ; alternative - : element+ - | - ; + : element+ + | + ; exceptionGroup - : exceptionHandler+ finallyClause? - | finallyClause - ; + : exceptionHandler+ finallyClause? + | finallyClause + ; exceptionHandler - : CATCH argActionBlock actionBlock - ; + : CATCH argActionBlock actionBlock + ; finallyClause - : FINALLY actionBlock - ; + : FINALLY actionBlock + ; element - : elementNoOptionSpec - ; + : elementNoOptionSpec + ; elementNoOptionSpec - : id_ (EQUAL | PEQ) atom (ebnfSuffix | ) - | id_ (EQUAL | PEQ) block (ebnfSuffix | ) - | atom (ebnfSuffix | ) - | ebnf - | actionBlock - | actionBlock QM ( SEMPREDOP | ) - | treeSpec (ebnfSuffix | ) - ; + : id_ (EQUAL | PEQ) atom (ebnfSuffix |) + | id_ (EQUAL | PEQ) block (ebnfSuffix |) + | atom (ebnfSuffix |) + | ebnf + | actionBlock + | actionBlock QM ( SEMPREDOP |) + | treeSpec (ebnfSuffix |) + ; actionBlock - : BEGIN_ACTION ACTION_CONTENT* END_ACTION - ; + : BEGIN_ACTION ACTION_CONTENT* END_ACTION + ; argActionBlock - : BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT - ; + : BEGIN_ARGUMENT ARGUMENT_CONTENT* END_ARGUMENT + ; atom - : range_ ( ROOT | BANG | ) - | terminal_ - | notSet ( ROOT | BANG | ) - | RULE_REF argActionBlock? ( ROOT | BANG )? - ; + : range_ (ROOT | BANG |) + | terminal_ + | notSet ( ROOT | BANG |) + | RULE_REF argActionBlock? ( ROOT | BANG)? + ; notSet - : NOT (notTerminal | block) - ; + : NOT (notTerminal | block) + ; treeSpec - : TREE_BEGIN element element+ RPAREN - ; + : TREE_BEGIN element element+ RPAREN + ; ebnf - : block (QM | STAR | PLUS | SEMPREDOP | ) - ; + : block (QM | STAR | PLUS | SEMPREDOP |) + ; range_ - : CHAR_LITERAL RANGE CHAR_LITERAL - ; + : CHAR_LITERAL RANGE CHAR_LITERAL + ; terminal_ - : (CHAR_LITERAL - | TOKEN_REF (argActionBlock | ) - | STRING_LITERAL - | DOT - ) (ROOT | BANG)? - ; + : (CHAR_LITERAL | TOKEN_REF (argActionBlock |) | STRING_LITERAL | DOT) (ROOT | BANG)? + ; notTerminal - : CHAR_LITERAL - | TOKEN_REF - | STRING_LITERAL - ; + : CHAR_LITERAL + | TOKEN_REF + | STRING_LITERAL + ; ebnfSuffix - : QM - | STAR - | PLUS - ; + : QM + | STAR + | PLUS + ; rewrite - : (REWRITE actionBlock QM rewrite_alternative)* REWRITE rewrite_alternative - | - ; + : (REWRITE actionBlock QM rewrite_alternative)* REWRITE rewrite_alternative + | + ; rewrite_alternative - : rewrite_template - | rewrite_tree_alternative - | - ; + : rewrite_template + | rewrite_tree_alternative + | + ; rewrite_tree_block - : LPAREN rewrite_tree_alternative RPAREN - ; + : LPAREN rewrite_tree_alternative RPAREN + ; rewrite_tree_alternative - : rewrite_tree_element+ - ; + : rewrite_tree_element+ + ; rewrite_tree_element - : rewrite_tree_atom - | rewrite_tree_atom ebnfSuffix - | rewrite_tree (ebnfSuffix | ) - | rewrite_tree_ebnf - ; + : rewrite_tree_atom + | rewrite_tree_atom ebnfSuffix + | rewrite_tree (ebnfSuffix |) + | rewrite_tree_ebnf + ; rewrite_tree_atom - : CHAR_LITERAL - | TOKEN_REF argActionBlock? - | RULE_REF - | STRING_LITERAL - | DOLLAR id_ - | actionBlock - ; + : CHAR_LITERAL + | TOKEN_REF argActionBlock? + | RULE_REF + | STRING_LITERAL + | DOLLAR id_ + | actionBlock + ; rewrite_tree_ebnf - : rewrite_tree_block ebnfSuffix - ; + : rewrite_tree_block ebnfSuffix + ; rewrite_tree - : TREE_BEGIN rewrite_tree_atom rewrite_tree_element* RPAREN - ; + : TREE_BEGIN rewrite_tree_atom rewrite_tree_element* RPAREN + ; rewrite_template - : id_ LPAREN rewrite_template_args RPAREN - ( DOUBLE_QUOTE_STRING_LITERAL | DOUBLE_ANGLE_STRING_LITERAL ) - | rewrite_template_ref - | rewrite_indirect_template_head - | actionBlock - ; + : id_ LPAREN rewrite_template_args RPAREN ( + DOUBLE_QUOTE_STRING_LITERAL + | DOUBLE_ANGLE_STRING_LITERAL + ) + | rewrite_template_ref + | rewrite_indirect_template_head + | actionBlock + ; rewrite_template_ref - : id_ LPAREN rewrite_template_args RPAREN - ; + : id_ LPAREN rewrite_template_args RPAREN + ; rewrite_indirect_template_head - : LPAREN actionBlock RPAREN LPAREN rewrite_template_args RPAREN - ; + : LPAREN actionBlock RPAREN LPAREN rewrite_template_args RPAREN + ; rewrite_template_args - : rewrite_template_arg (COMMA rewrite_template_arg)* - | - ; + : rewrite_template_arg (COMMA rewrite_template_arg)* + | + ; rewrite_template_arg - : id_ EQUAL actionBlock - ; + : id_ EQUAL actionBlock + ; id_ - : TOKEN_REF - | RULE_REF - ; - + : TOKEN_REF + | RULE_REF + ; \ No newline at end of file diff --git a/antlr/antlr4/ANTLRv4Lexer.g4 b/antlr/antlr4/ANTLRv4Lexer.g4 index cfe41d4790..bf389d0915 100644 --- a/antlr/antlr4/ANTLRv4Lexer.g4 +++ b/antlr/antlr4/ANTLRv4Lexer.g4 @@ -434,4 +434,4 @@ UNTERMINATED_CHAR_SET // Grammar specific Keywords, Punctuation, etc. fragment Id : NameStartChar NameChar* - ; + ; \ No newline at end of file diff --git a/antlr/antlr4/ANTLRv4Parser.g4 b/antlr/antlr4/ANTLRv4Parser.g4 index c5da2095fb..a4ff765988 100644 --- a/antlr/antlr4/ANTLRv4Parser.g4 +++ b/antlr/antlr4/ANTLRv4Parser.g4 @@ -405,4 +405,4 @@ elementOption identifier : RULE_REF | TOKEN_REF - ; + ; \ No newline at end of file diff --git a/antlr/antlr4/Cpp/ANTLRv4Lexer.g4 b/antlr/antlr4/Cpp/ANTLRv4Lexer.g4 index c96864c5a2..493d554744 100644 --- a/antlr/antlr4/Cpp/ANTLRv4Lexer.g4 +++ b/antlr/antlr4/Cpp/ANTLRv4Lexer.g4 @@ -39,41 +39,44 @@ // Lexer specification // ====================================================== +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ANTLRv4Lexer; -options { superClass = LexerAdaptor; } +options { + superClass = LexerAdaptor; +} import LexBasic; -@header -{ +@header { #include "LexerAdaptor.h" } - // Standard set of fragments -tokens { TOKEN_REF , RULE_REF , LEXER_CHAR_SET } -channels { OFF_CHANNEL , COMMENT } +tokens { + TOKEN_REF, + RULE_REF, + LEXER_CHAR_SET +} +channels { + OFF_CHANNEL, + COMMENT +} // ------------------------- // Comments -DOC_COMMENT - : DocComment -> channel (COMMENT) - ; +DOC_COMMENT: DocComment -> channel (COMMENT); -BLOCK_COMMENT - : BlockComment -> channel (COMMENT) - ; +BLOCK_COMMENT: BlockComment -> channel (COMMENT); -LINE_COMMENT - : LineComment -> channel (COMMENT) - ; +LINE_COMMENT: LineComment -> channel (COMMENT); // ------------------------- // Integer -INT - : DecimalNumeral - ; +INT: DecimalNumeral; // ------------------------- // Literal string @@ -82,13 +85,9 @@ INT // multi-character string. All literals are single quote delimited and // may contain unicode escape sequences of the form \uxxxx, where x // is a valid hexadecimal number (per Unicode standard). -STRING_LITERAL - : SQuoteLiteral - ; +STRING_LITERAL: SQuoteLiteral; -UNTERMINATED_STRING_LITERAL - : USQuoteLiteral - ; +UNTERMINATED_STRING_LITERAL: USQuoteLiteral; // ------------------------- // Arguments @@ -96,16 +95,11 @@ UNTERMINATED_STRING_LITERAL // Certain argument lists, such as those specifying call parameters // to a rule invocation, or input parameters to a rule specification // are contained within square brackets. -BEGIN_ARGUMENT - : LBrack - { this->handleBeginArgument(); } - ; +BEGIN_ARGUMENT: LBrack { this->handleBeginArgument(); }; // ------------------------- // Target Language Actions -BEGIN_ACTION - : LBrace -> pushMode (TargetLanguageAction) - ; +BEGIN_ACTION: LBrace -> pushMode (TargetLanguageAction); // ------------------------- // Keywords @@ -114,173 +108,95 @@ BEGIN_ACTION // but only when followed by '{', and considered as a single token. // Otherwise, the symbols are tokenized as RULE_REF and allowed as // an identifier in a labeledElement. -OPTIONS : 'options' WSNLCHARS* '{' ; -TOKENS : 'tokens' WSNLCHARS* '{' ; -CHANNELS : 'channels' WSNLCHARS* '{' ; +OPTIONS : 'options' WSNLCHARS* '{'; +TOKENS : 'tokens' WSNLCHARS* '{'; +CHANNELS : 'channels' WSNLCHARS* '{'; + +fragment WSNLCHARS: ' ' | '\t' | '\f' | '\n' | '\r'; + +IMPORT: 'import'; + +FRAGMENT: 'fragment'; + +LEXER: 'lexer'; + +PARSER: 'parser'; + +GRAMMAR: 'grammar'; + +PROTECTED: 'protected'; + +PUBLIC: 'public'; + +PRIVATE: 'private'; + +RETURNS: 'returns'; -fragment WSNLCHARS : ' ' | '\t' | '\f' | '\n' | '\r' ; +LOCALS: 'locals'; -IMPORT - : 'import' - ; +THROWS: 'throws'; -FRAGMENT - : 'fragment' - ; +CATCH: 'catch'; -LEXER - : 'lexer' - ; +FINALLY: 'finally'; -PARSER - : 'parser' - ; +MODE: 'mode'; +// ------------------------- +// Punctuation + +COLON: Colon; + +COLONCOLON: DColon; + +COMMA: Comma; + +SEMI: Semi; + +LPAREN: LParen; + +RPAREN: RParen; + +LBRACE: LBrace; -GRAMMAR - : 'grammar' - ; +RBRACE: RBrace; -PROTECTED - : 'protected' - ; +RARROW: RArrow; -PUBLIC - : 'public' - ; +LT: Lt; -PRIVATE - : 'private' - ; +GT: Gt; -RETURNS - : 'returns' - ; +ASSIGN: Equal; -LOCALS - : 'locals' - ; +QUESTION: Question; -THROWS - : 'throws' - ; +STAR: Star; -CATCH - : 'catch' - ; +PLUS_ASSIGN: PlusAssign; -FINALLY - : 'finally' - ; +PLUS: Plus; -MODE - : 'mode' - ; - // ------------------------- - // Punctuation - -COLON - : Colon - ; - -COLONCOLON - : DColon - ; - -COMMA - : Comma - ; - -SEMI - : Semi - ; - -LPAREN - : LParen - ; - -RPAREN - : RParen - ; - -LBRACE - : LBrace - ; - -RBRACE - : RBrace - ; - -RARROW - : RArrow - ; - -LT - : Lt - ; +OR: Pipe; -GT - : Gt - ; - -ASSIGN - : Equal - ; - -QUESTION - : Question - ; - -STAR - : Star - ; - -PLUS_ASSIGN - : PlusAssign - ; - -PLUS - : Plus - ; - -OR - : Pipe - ; - -DOLLAR - : Dollar - ; - -RANGE - : Range - ; - -DOT - : Dot - ; - -AT - : At - ; - -POUND - : Pound - ; - -NOT - : Tilde - ; - // ------------------------- - // Identifiers - allows unicode rule/token names +DOLLAR: Dollar; -ID - : Id - ; - // ------------------------- - // Whitespace +RANGE: Range; + +DOT: Dot; + +AT: At; + +POUND: Pound; + +NOT: Tilde; +// ------------------------- +// Identifiers - allows unicode rule/token names + +ID: Id; +// ------------------------- +// Whitespace -WS - : Ws+ -> channel (OFF_CHANNEL) - ; +WS: Ws+ -> channel (OFF_CHANNEL); // ------------------------- // Illegal Characters @@ -294,9 +210,7 @@ WS // errors. // Comment this rule out to allow the error to be propagated to the parser -ERRCHAR - : . -> channel (HIDDEN) - ; +ERRCHAR: . -> channel (HIDDEN); // ====================================================== // Lexer modes @@ -304,35 +218,20 @@ ERRCHAR // Arguments mode Argument; // E.g., [int x, List a[]] -NESTED_ARGUMENT - : LBrack -> type (ARGUMENT_CONTENT) , pushMode (Argument) - ; +NESTED_ARGUMENT: LBrack -> type (ARGUMENT_CONTENT), pushMode (Argument); -ARGUMENT_ESCAPE - : EscAny -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_ESCAPE: EscAny -> type (ARGUMENT_CONTENT); -ARGUMENT_STRING_LITERAL - : DQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_STRING_LITERAL: DQuoteLiteral -> type (ARGUMENT_CONTENT); -ARGUMENT_CHAR_LITERAL - : SQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_CHAR_LITERAL: SQuoteLiteral -> type (ARGUMENT_CONTENT); -END_ARGUMENT - : RBrack - { this->handleEndArgument(); } - ; +END_ARGUMENT: RBrack { this->handleEndArgument(); }; // added this to return non-EOF token type here. EOF does something weird -UNTERMINATED_ARGUMENT - : EOF -> popMode - ; +UNTERMINATED_ARGUMENT: EOF -> popMode; -ARGUMENT_CONTENT - : . - ; +ARGUMENT_CONTENT: .; // ------------------------- // Target Language Actions @@ -344,64 +243,34 @@ ARGUMENT_CONTENT // that they are delimited by ' or " and so consume these // in their own alts so as not to inadvertantly match {}. mode TargetLanguageAction; -NESTED_ACTION - : LBrace -> type (ACTION_CONTENT) , pushMode (TargetLanguageAction) - ; +NESTED_ACTION: LBrace -> type (ACTION_CONTENT), pushMode (TargetLanguageAction); -ACTION_ESCAPE - : EscAny -> type (ACTION_CONTENT) - ; +ACTION_ESCAPE: EscAny -> type (ACTION_CONTENT); -ACTION_STRING_LITERAL - : DQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_STRING_LITERAL: DQuoteLiteral -> type (ACTION_CONTENT); -ACTION_CHAR_LITERAL - : SQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_CHAR_LITERAL: SQuoteLiteral -> type (ACTION_CONTENT); -ACTION_DOC_COMMENT - : DocComment -> type (ACTION_CONTENT) - ; +ACTION_DOC_COMMENT: DocComment -> type (ACTION_CONTENT); -ACTION_BLOCK_COMMENT - : BlockComment -> type (ACTION_CONTENT) - ; +ACTION_BLOCK_COMMENT: BlockComment -> type (ACTION_CONTENT); -ACTION_LINE_COMMENT - : LineComment -> type (ACTION_CONTENT) - ; +ACTION_LINE_COMMENT: LineComment -> type (ACTION_CONTENT); -END_ACTION - : RBrace - { this->handleEndAction(); } - ; +END_ACTION: RBrace { this->handleEndAction(); }; -UNTERMINATED_ACTION - : EOF -> popMode - ; +UNTERMINATED_ACTION: EOF -> popMode; -ACTION_CONTENT - : . - ; +ACTION_CONTENT: .; // ------------------------- mode LexerCharSet; -LEXER_CHAR_SET_BODY - : (~ [\]\\] | EscAny)+ -> more - ; +LEXER_CHAR_SET_BODY: (~ [\]\\] | EscAny)+ -> more; -LEXER_CHAR_SET - : RBrack -> popMode - ; +LEXER_CHAR_SET: RBrack -> popMode; -UNTERMINATED_CHAR_SET - : EOF -> popMode - ; +UNTERMINATED_CHAR_SET: EOF -> popMode; // ------------------------------------------------------------------------------ // Grammar specific Keywords, Punctuation, etc. -fragment Id - : NameStartChar NameChar* - ; - +fragment Id: NameStartChar NameChar*; \ No newline at end of file diff --git a/antlr/antlr4/LexBasic.g4 b/antlr/antlr4/LexBasic.g4 index 1939630ece..761e3db2e4 100644 --- a/antlr/antlr4/LexBasic.g4 +++ b/antlr/antlr4/LexBasic.g4 @@ -283,4 +283,4 @@ fragment Pound fragment Tilde : '~' - ; + ; \ No newline at end of file diff --git a/antlr/antlr4/Python3/ANTLRv4Lexer.g4 b/antlr/antlr4/Python3/ANTLRv4Lexer.g4 index 05a14fd53b..5af4832505 100644 --- a/antlr/antlr4/Python3/ANTLRv4Lexer.g4 +++ b/antlr/antlr4/Python3/ANTLRv4Lexer.g4 @@ -39,35 +39,40 @@ // Lexer specification // ====================================================== +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ANTLRv4Lexer; -options { superClass = LexerAdaptor; } +options { + superClass = LexerAdaptor; +} import LexBasic; // Standard set of fragments -tokens { TOKEN_REF , RULE_REF , LEXER_CHAR_SET } -channels { OFF_CHANNEL , COMMENT } +tokens { + TOKEN_REF, + RULE_REF, + LEXER_CHAR_SET +} +channels { + OFF_CHANNEL, + COMMENT +} // ------------------------- // Comments -DOC_COMMENT - : DocComment -> channel (COMMENT) - ; +DOC_COMMENT: DocComment -> channel (COMMENT); -BLOCK_COMMENT - : BlockComment -> channel (COMMENT) - ; +BLOCK_COMMENT: BlockComment -> channel (COMMENT); -LINE_COMMENT - : LineComment -> channel (COMMENT) - ; +LINE_COMMENT: LineComment -> channel (COMMENT); // ------------------------- // Integer -INT - : DecimalNumeral - ; +INT: DecimalNumeral; // ------------------------- // Literal string @@ -76,13 +81,9 @@ INT // multi-character string. All literals are single quote delimited and // may contain unicode escape sequences of the form \uxxxx, where x // is a valid hexadecimal number (per Unicode standard). -STRING_LITERAL - : SQuoteLiteral - ; +STRING_LITERAL: SQuoteLiteral; -UNTERMINATED_STRING_LITERAL - : USQuoteLiteral - ; +UNTERMINATED_STRING_LITERAL: USQuoteLiteral; // ------------------------- // Arguments @@ -90,16 +91,11 @@ UNTERMINATED_STRING_LITERAL // Certain argument lists, such as those specifying call parameters // to a rule invocation, or input parameters to a rule specification // are contained within square brackets. -BEGIN_ARGUMENT - : LBrack - { self.handleBeginArgument() } - ; +BEGIN_ARGUMENT: LBrack { self.handleBeginArgument() }; // ------------------------- // Target Language Actions -BEGIN_ACTION - : LBrace -> pushMode (TargetLanguageAction) - ; +BEGIN_ACTION: LBrace -> pushMode (TargetLanguageAction); // ------------------------- // Keywords @@ -108,173 +104,95 @@ BEGIN_ACTION // but only when followed by '{', and considered as a single token. // Otherwise, the symbols are tokenized as RULE_REF and allowed as // an identifier in a labeledElement. -OPTIONS : 'options' WSNLCHARS* '{' ; -TOKENS : 'tokens' WSNLCHARS* '{' ; -CHANNELS : 'channels' WSNLCHARS* '{' ; +OPTIONS : 'options' WSNLCHARS* '{'; +TOKENS : 'tokens' WSNLCHARS* '{'; +CHANNELS : 'channels' WSNLCHARS* '{'; + +fragment WSNLCHARS: ' ' | '\t' | '\f' | '\n' | '\r'; + +IMPORT: 'import'; + +FRAGMENT: 'fragment'; + +LEXER: 'lexer'; + +PARSER: 'parser'; + +GRAMMAR: 'grammar'; + +PROTECTED: 'protected'; + +PUBLIC: 'public'; + +PRIVATE: 'private'; + +RETURNS: 'returns'; + +LOCALS: 'locals'; + +THROWS: 'throws'; -fragment WSNLCHARS : ' ' | '\t' | '\f' | '\n' | '\r' ; +CATCH: 'catch'; -IMPORT - : 'import' - ; +FINALLY: 'finally'; -FRAGMENT - : 'fragment' - ; +MODE: 'mode'; +// ------------------------- +// Punctuation + +COLON: Colon; + +COLONCOLON: DColon; + +COMMA: Comma; + +SEMI: Semi; + +LPAREN: LParen; + +RPAREN: RParen; -LEXER - : 'lexer' - ; +LBRACE: LBrace; -PARSER - : 'parser' - ; +RBRACE: RBrace; -GRAMMAR - : 'grammar' - ; +RARROW: RArrow; -PROTECTED - : 'protected' - ; +LT: Lt; -PUBLIC - : 'public' - ; +GT: Gt; -PRIVATE - : 'private' - ; +ASSIGN: Equal; -RETURNS - : 'returns' - ; +QUESTION: Question; -LOCALS - : 'locals' - ; +STAR: Star; -THROWS - : 'throws' - ; +PLUS_ASSIGN: PlusAssign; -CATCH - : 'catch' - ; +PLUS: Plus; -FINALLY - : 'finally' - ; +OR: Pipe; -MODE - : 'mode' - ; - // ------------------------- - // Punctuation - -COLON - : Colon - ; - -COLONCOLON - : DColon - ; - -COMMA - : Comma - ; - -SEMI - : Semi - ; - -LPAREN - : LParen - ; - -RPAREN - : RParen - ; - -LBRACE - : LBrace - ; - -RBRACE - : RBrace - ; - -RARROW - : RArrow - ; - -LT - : Lt - ; +DOLLAR: Dollar; -GT - : Gt - ; - -ASSIGN - : Equal - ; - -QUESTION - : Question - ; - -STAR - : Star - ; - -PLUS_ASSIGN - : PlusAssign - ; - -PLUS - : Plus - ; - -OR - : Pipe - ; - -DOLLAR - : Dollar - ; - -RANGE - : Range - ; - -DOT - : Dot - ; - -AT - : At - ; - -POUND - : Pound - ; - -NOT - : Tilde - ; - // ------------------------- - // Identifiers - allows unicode rule/token names +RANGE: Range; -ID - : Id - ; - // ------------------------- - // Whitespace +DOT: Dot; + +AT: At; + +POUND: Pound; + +NOT: Tilde; +// ------------------------- +// Identifiers - allows unicode rule/token names + +ID: Id; +// ------------------------- +// Whitespace -WS - : Ws+ -> channel (OFF_CHANNEL) - ; +WS: Ws+ -> channel (OFF_CHANNEL); // ------------------------- // Illegal Characters @@ -288,9 +206,7 @@ WS // errors. // Comment this rule out to allow the error to be propagated to the parser -ERRCHAR - : . -> channel (HIDDEN) - ; +ERRCHAR: . -> channel (HIDDEN); // ====================================================== // Lexer modes @@ -298,35 +214,20 @@ ERRCHAR // Arguments mode Argument; // E.g., [int x, List a[]] -NESTED_ARGUMENT - : LBrack -> type (ARGUMENT_CONTENT) , pushMode (Argument) - ; +NESTED_ARGUMENT: LBrack -> type (ARGUMENT_CONTENT), pushMode (Argument); -ARGUMENT_ESCAPE - : EscAny -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_ESCAPE: EscAny -> type (ARGUMENT_CONTENT); -ARGUMENT_STRING_LITERAL - : DQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_STRING_LITERAL: DQuoteLiteral -> type (ARGUMENT_CONTENT); -ARGUMENT_CHAR_LITERAL - : SQuoteLiteral -> type (ARGUMENT_CONTENT) - ; +ARGUMENT_CHAR_LITERAL: SQuoteLiteral -> type (ARGUMENT_CONTENT); -END_ARGUMENT - : RBrack - { self.handleEndArgument() } - ; +END_ARGUMENT: RBrack { self.handleEndArgument() }; // added this to return non-EOF token type here. EOF does something weird -UNTERMINATED_ARGUMENT - : EOF -> popMode - ; +UNTERMINATED_ARGUMENT: EOF -> popMode; -ARGUMENT_CONTENT - : . - ; +ARGUMENT_CONTENT: .; // ------------------------- // Target Language Actions @@ -338,64 +239,34 @@ ARGUMENT_CONTENT // that they are delimited by ' or " and so consume these // in their own alts so as not to inadvertantly match {}. mode TargetLanguageAction; -NESTED_ACTION - : LBrace -> type (ACTION_CONTENT) , pushMode (TargetLanguageAction) - ; +NESTED_ACTION: LBrace -> type (ACTION_CONTENT), pushMode (TargetLanguageAction); -ACTION_ESCAPE - : EscAny -> type (ACTION_CONTENT) - ; +ACTION_ESCAPE: EscAny -> type (ACTION_CONTENT); -ACTION_STRING_LITERAL - : DQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_STRING_LITERAL: DQuoteLiteral -> type (ACTION_CONTENT); -ACTION_CHAR_LITERAL - : SQuoteLiteral -> type (ACTION_CONTENT) - ; +ACTION_CHAR_LITERAL: SQuoteLiteral -> type (ACTION_CONTENT); -ACTION_DOC_COMMENT - : DocComment -> type (ACTION_CONTENT) - ; +ACTION_DOC_COMMENT: DocComment -> type (ACTION_CONTENT); -ACTION_BLOCK_COMMENT - : BlockComment -> type (ACTION_CONTENT) - ; +ACTION_BLOCK_COMMENT: BlockComment -> type (ACTION_CONTENT); -ACTION_LINE_COMMENT - : LineComment -> type (ACTION_CONTENT) - ; +ACTION_LINE_COMMENT: LineComment -> type (ACTION_CONTENT); -END_ACTION - : RBrace - { self.handleEndAction() } - ; +END_ACTION: RBrace { self.handleEndAction() }; -UNTERMINATED_ACTION - : EOF -> popMode - ; +UNTERMINATED_ACTION: EOF -> popMode; -ACTION_CONTENT - : . - ; +ACTION_CONTENT: .; // ------------------------- mode LexerCharSet; -LEXER_CHAR_SET_BODY - : (~ [\]\\] | EscAny)+ -> more - ; +LEXER_CHAR_SET_BODY: (~ [\]\\] | EscAny)+ -> more; -LEXER_CHAR_SET - : RBrack -> popMode - ; +LEXER_CHAR_SET: RBrack -> popMode; -UNTERMINATED_CHAR_SET - : EOF -> popMode - ; +UNTERMINATED_CHAR_SET: EOF -> popMode; // ------------------------------------------------------------------------------ // Grammar specific Keywords, Punctuation, etc. -fragment Id - : NameStartChar NameChar* - ; - +fragment Id: NameStartChar NameChar*; \ No newline at end of file diff --git a/apex/apex.g4 b/apex/apex.g4 index b06491d1b7..2cb613eb3e 100644 --- a/apex/apex.g4 +++ b/apex/apex.g4 @@ -40,127 +40,127 @@ * * How to run example: https://mohan-chinnappan-n5.github.io/sfbooks/sfdevnotes/language-design/apex-grammar.html */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar apex; // starting point for parsing a apexcode file compilationUnit - : packageDeclaration? importDeclaration* typeDeclaration* EOF + : packageDeclaration? importDeclaration* typeDeclaration* EOF ; packageDeclaration - : annotation* PACKAGE qualifiedName ';' + : annotation* PACKAGE qualifiedName ';' ; importDeclaration - : IMPORT STATIC? qualifiedName ('.' '*')? ';' + : IMPORT STATIC? qualifiedName ('.' '*')? ';' ; typeDeclaration - : classOrInterfaceModifier* classDeclaration - | classOrInterfaceModifier* enumDeclaration - | classOrInterfaceModifier* interfaceDeclaration - | classOrInterfaceModifier* annotationTypeDeclaration - | ';' + : classOrInterfaceModifier* classDeclaration + | classOrInterfaceModifier* enumDeclaration + | classOrInterfaceModifier* interfaceDeclaration + | classOrInterfaceModifier* annotationTypeDeclaration + | ';' ; modifier - : classOrInterfaceModifier - | NATIVE - | SYNCHRONIZED - | TRANSIENT + : classOrInterfaceModifier + | NATIVE + | SYNCHRONIZED + | TRANSIENT ; classOrInterfaceModifier - : annotation // class or interface - | PUBLIC // class or interface - | PROTECTED // class or interface - | PRIVATE // class or interface - | STATIC // class or interface - | ABSTRACT // class or interface - | FINAL // class only -- does not apply to interfaces - | GLOBAL // class or interface - | WEBSERVICE // class only -- does not apply to interfaces - | OVERRIDE // method only - | VIRTUAL // method only - | TESTMETHOD // method only - | APEX_WITH_SHARING // class only - | APEX_WITHOUT_SHARING //class only + : annotation // class or interface + | PUBLIC // class or interface + | PROTECTED // class or interface + | PRIVATE // class or interface + | STATIC // class or interface + | ABSTRACT // class or interface + | FINAL // class only -- does not apply to interfaces + | GLOBAL // class or interface + | WEBSERVICE // class only -- does not apply to interfaces + | OVERRIDE // method only + | VIRTUAL // method only + | TESTMETHOD // method only + | APEX_WITH_SHARING // class only + | APEX_WITHOUT_SHARING //class only ; variableModifier - : FINAL - | annotation + : FINAL + | annotation ; classDeclaration - : CLASS Identifier typeParameters? - (EXTENDS type_)? - (IMPLEMENTS typeList)? - classBody + : CLASS Identifier typeParameters? (EXTENDS type_)? (IMPLEMENTS typeList)? classBody ; typeParameters - : '<' typeParameter (',' typeParameter)* '>' + : '<' typeParameter (',' typeParameter)* '>' ; typeParameter - : Identifier (EXTENDS typeBound)? + : Identifier (EXTENDS typeBound)? ; typeBound - : type_ ('&' type_)* + : type_ ('&' type_)* ; enumDeclaration - : ENUM Identifier (IMPLEMENTS typeList)? - '{' enumConstants? ','? enumBodyDeclarations? '}' + : ENUM Identifier (IMPLEMENTS typeList)? '{' enumConstants? ','? enumBodyDeclarations? '}' ; enumConstants - : enumConstant (',' enumConstant)* + : enumConstant (',' enumConstant)* ; enumConstant - : annotation* Identifier arguments? classBody? + : annotation* Identifier arguments? classBody? ; enumBodyDeclarations - : ';' classBodyDeclaration* + : ';' classBodyDeclaration* ; interfaceDeclaration - : INTERFACE Identifier typeParameters? (EXTENDS typeList)? interfaceBody + : INTERFACE Identifier typeParameters? (EXTENDS typeList)? interfaceBody ; typeList - : type_ (',' type_)* + : type_ (',' type_)* ; classBody - : '{' classBodyDeclaration* '}' + : '{' classBodyDeclaration* '}' ; interfaceBody - : '{' interfaceBodyDeclaration* '}' + : '{' interfaceBodyDeclaration* '}' ; classBodyDeclaration - : ';' - | STATIC? block - | modifier* memberDeclaration + : ';' + | STATIC? block + | modifier* memberDeclaration ; memberDeclaration - : methodDeclaration - | genericMethodDeclaration - | fieldDeclaration - | constructorDeclaration - | genericConstructorDeclaration - | interfaceDeclaration - | annotationTypeDeclaration - | classDeclaration - | enumDeclaration - | propertyDeclaration + : methodDeclaration + | genericMethodDeclaration + | fieldDeclaration + | constructorDeclaration + | genericConstructorDeclaration + | interfaceDeclaration + | annotationTypeDeclaration + | classDeclaration + | enumDeclaration + | propertyDeclaration ; /* We use rule this even for void methods which cannot have [] after parameters. @@ -169,973 +169,1304 @@ memberDeclaration for invalid return type after parsing. */ methodDeclaration - : OVERRIDE? (type_|VOID) Identifier formalParameters ('[' ']')* - (THROWS qualifiedNameList)? - ( methodBody - | ';' - ) + : OVERRIDE? (type_ | VOID) Identifier formalParameters ('[' ']')* (THROWS qualifiedNameList)? ( + methodBody + | ';' + ) ; genericMethodDeclaration - : typeParameters methodDeclaration + : typeParameters methodDeclaration ; constructorDeclaration - : Identifier formalParameters (THROWS qualifiedNameList)? - constructorBody + : Identifier formalParameters (THROWS qualifiedNameList)? constructorBody ; genericConstructorDeclaration - : typeParameters constructorDeclaration + : typeParameters constructorDeclaration ; fieldDeclaration - : type_ variableDeclarators ';' + : type_ variableDeclarators ';' ; propertyDeclaration - : type_ variableDeclarators propertyBodyDeclaration + : type_ variableDeclarators propertyBodyDeclaration ; propertyBodyDeclaration - : '{' propertyBlock propertyBlock? '}' + : '{' propertyBlock propertyBlock? '}' ; interfaceBodyDeclaration - : modifier* interfaceMemberDeclaration - | ';' + : modifier* interfaceMemberDeclaration + | ';' ; interfaceMemberDeclaration - : constDeclaration - | interfaceMethodDeclaration - | genericInterfaceMethodDeclaration - | interfaceDeclaration - | annotationTypeDeclaration - | classDeclaration - | enumDeclaration + : constDeclaration + | interfaceMethodDeclaration + | genericInterfaceMethodDeclaration + | interfaceDeclaration + | annotationTypeDeclaration + | classDeclaration + | enumDeclaration ; constDeclaration - : type_ constantDeclarator (',' constantDeclarator)* ';' + : type_ constantDeclarator (',' constantDeclarator)* ';' ; constantDeclarator - : Identifier ('[' ']')* '=' variableInitializer + : Identifier ('[' ']')* '=' variableInitializer ; // see matching of [] comment in methodDeclaratorRest interfaceMethodDeclaration - : (type_|VOID) Identifier formalParameters ('[' ']')* - (THROWS qualifiedNameList)? - ';' + : (type_ | VOID) Identifier formalParameters ('[' ']')* (THROWS qualifiedNameList)? ';' ; genericInterfaceMethodDeclaration - : typeParameters interfaceMethodDeclaration + : typeParameters interfaceMethodDeclaration ; variableDeclarators - : variableDeclarator (',' variableDeclarator)* + : variableDeclarator (',' variableDeclarator)* ; variableDeclarator - : variableDeclaratorId ('=' variableInitializer)? + : variableDeclaratorId ('=' variableInitializer)? ; variableDeclaratorId - : Identifier ('[' ']')* + : Identifier ('[' ']')* ; variableInitializer - : arrayInitializer - | expression + : arrayInitializer + | expression ; arrayInitializer - : '{' (variableInitializer (',' variableInitializer)* ','? )? '}' + : '{' (variableInitializer (',' variableInitializer)* ','?)? '}' ; enumConstantName - : Identifier + : Identifier ; type_ - : classOrInterfaceType ('[' ']')* - | primitiveType ('[' ']')* + : classOrInterfaceType ('[' ']')* + | primitiveType ('[' ']')* ; classOrInterfaceType - : Identifier typeArguments? ('.' Identifier typeArguments? )* - | SET typeArguments // 'set <' has to be defined explisitly, otherwise it clashes with SET of property setter + : Identifier typeArguments? ('.' Identifier typeArguments?)* + | SET typeArguments // 'set <' has to be defined explisitly, otherwise it clashes with SET of property setter ; primitiveType - : CHAR - | BYTE - | SHORT - | INT - | FLOAT + : CHAR + | BYTE + | SHORT + | INT + | FLOAT ; typeArguments - : '<' typeArgument (',' typeArgument)* '>' + : '<' typeArgument (',' typeArgument)* '>' ; typeArgument - : type_ - | '?' ((EXTENDS | SUPER) type_)? + : type_ + | '?' ((EXTENDS | SUPER) type_)? ; qualifiedNameList - : qualifiedName (',' qualifiedName)* + : qualifiedName (',' qualifiedName)* ; formalParameters - : '(' formalParameterList? ')' + : '(' formalParameterList? ')' ; formalParameterList - : formalParameter (',' formalParameter)* (',' lastFormalParameter)? - | lastFormalParameter + : formalParameter (',' formalParameter)* (',' lastFormalParameter)? + | lastFormalParameter ; formalParameter - : variableModifier* type_ variableDeclaratorId + : variableModifier* type_ variableDeclaratorId ; lastFormalParameter - : variableModifier* type_ '...' variableDeclaratorId + : variableModifier* type_ '...' variableDeclaratorId ; methodBody - : block + : block ; constructorBody - : block + : block ; qualifiedName - : Identifier ('.' Identifier)* + : Identifier ('.' Identifier)* ; literal - : IntegerLiteral - | FloatingPointLiteral - | CharacterLiteral - | StringLiteral - | BooleanLiteral - | NullLiteral + : IntegerLiteral + | FloatingPointLiteral + | CharacterLiteral + | StringLiteral + | BooleanLiteral + | NullLiteral ; // ANNOTATIONS annotation - : '@' annotationName ( '(' ( elementValuePairs | elementValue )? ')' )? + : '@' annotationName ('(' ( elementValuePairs | elementValue)? ')')? ; -annotationName : qualifiedName ; +annotationName + : qualifiedName + ; elementValuePairs - : elementValuePair (','? elementValuePair)* + : elementValuePair (','? elementValuePair)* ; elementValuePair - : Identifier '=' elementValue + : Identifier '=' elementValue ; elementValue - : expression - | annotation - | elementValueArrayInitializer + : expression + | annotation + | elementValueArrayInitializer ; elementValueArrayInitializer - : '{' (elementValue (',' elementValue)*)? ','? '}' + : '{' (elementValue (',' elementValue)*)? ','? '}' ; annotationTypeDeclaration - : '@' INTERFACE Identifier annotationTypeBody + : '@' INTERFACE Identifier annotationTypeBody ; annotationTypeBody - : '{' annotationTypeElementDeclaration* '}' + : '{' annotationTypeElementDeclaration* '}' ; annotationTypeElementDeclaration - : modifier* annotationTypeElementRest - | ';' // this is not allowed by the grammar, but apparently allowed by the actual compiler + : modifier* annotationTypeElementRest + | ';' // this is not allowed by the grammar, but apparently allowed by the actual compiler ; annotationTypeElementRest - : type_ annotationMethodOrConstantRest ';' - | classDeclaration ';'? - | interfaceDeclaration ';'? - | enumDeclaration ';'? - | annotationTypeDeclaration ';'? + : type_ annotationMethodOrConstantRest ';' + | classDeclaration ';'? + | interfaceDeclaration ';'? + | enumDeclaration ';'? + | annotationTypeDeclaration ';'? ; annotationMethodOrConstantRest - : annotationMethodRest - | annotationConstantRest + : annotationMethodRest + | annotationConstantRest ; annotationMethodRest - : Identifier '(' ')' defaultValue? + : Identifier '(' ')' defaultValue? ; annotationConstantRest - : variableDeclarators + : variableDeclarators ; defaultValue - : DEFAULT elementValue + : DEFAULT elementValue ; // STATEMENTS / BLOCKS block - : '{' blockStatement* '}' + : '{' blockStatement* '}' ; blockStatement - : localVariableDeclarationStatement - | statement - | typeDeclaration + : localVariableDeclarationStatement + | statement + | typeDeclaration ; localVariableDeclarationStatement - : localVariableDeclaration ';' + : localVariableDeclaration ';' ; localVariableDeclaration - : variableModifier* type_ variableDeclarators + : variableModifier* type_ variableDeclarators ; statement - : block - | IF parExpression statement (ELSE statement)? - | FOR '(' forControl ')' statement - | WHILE parExpression statement - | DO statement WHILE parExpression ';' - | RUNAS '(' expression ')' statement - | TRY block (catchClause+ finallyBlock? | finallyBlock) - | TRY resourceSpecification block catchClause* finallyBlock? - | RETURN expression? ';' - | THROW expression ';' - | BREAK Identifier? ';' - | CONTINUE Identifier? ';' - | ';' - | statementExpression ';' - | Identifier ':' statement - | apexDbExpression ';' + : block + | IF parExpression statement (ELSE statement)? + | FOR '(' forControl ')' statement + | WHILE parExpression statement + | DO statement WHILE parExpression ';' + | RUNAS '(' expression ')' statement + | TRY block (catchClause+ finallyBlock? | finallyBlock) + | TRY resourceSpecification block catchClause* finallyBlock? + | RETURN expression? ';' + | THROW expression ';' + | BREAK Identifier? ';' + | CONTINUE Identifier? ';' + | ';' + | statementExpression ';' + | Identifier ':' statement + | apexDbExpression ';' ; propertyBlock - : modifier* (getter | setter) - ; + : modifier* (getter | setter) + ; getter - : GET (';' | methodBody) - ; + : GET (';' | methodBody) + ; setter - : SET (';' | methodBody) - ; - + : SET (';' | methodBody) + ; catchClause - : CATCH '(' variableModifier* catchType Identifier ')' block + : CATCH '(' variableModifier* catchType Identifier ')' block ; catchType - : qualifiedName ('|' qualifiedName)* + : qualifiedName ('|' qualifiedName)* ; finallyBlock - : FINALLY block + : FINALLY block ; resourceSpecification - : '(' resources ';'? ')' + : '(' resources ';'? ')' ; resources - : resource (';' resource)* + : resource (';' resource)* ; resource - : variableModifier* classOrInterfaceType variableDeclaratorId '=' expression + : variableModifier* classOrInterfaceType variableDeclaratorId '=' expression ; forControl - : enhancedForControl - | forInit? ';' expression? ';' forUpdate? + : enhancedForControl + | forInit? ';' expression? ';' forUpdate? ; forInit - : localVariableDeclaration - | expressionList + : localVariableDeclaration + | expressionList ; enhancedForControl - : variableModifier* type_ variableDeclaratorId ':' expression + : variableModifier* type_ variableDeclaratorId ':' expression ; forUpdate - : expressionList + : expressionList ; // EXPRESSIONS parExpression - : '(' expression ')' + : '(' expression ')' ; expressionList - : expression (',' expression)* + : expression (',' expression)* ; statementExpression - : expression + : expression ; constantExpression - : expression + : expression ; apexDbUpsertExpression - : DB_UPSERT expression expression* + : DB_UPSERT expression expression* ; apexDbExpression - : (DB_INSERT | DB_UPDATE | DB_DELETE | DB_UNDELETE) expression - | apexDbUpsertExpression - ; + : (DB_INSERT | DB_UPDATE | DB_DELETE | DB_UNDELETE) expression + | apexDbUpsertExpression + ; expression - : primary - | expression '.' GET '(' expressionList? ')' - | expression '.' SET '(' expressionList? ')' - | expression '?'? '.' Identifier - | expression '.' THIS - | expression '.' NEW - | expression '.' - ( DB_INSERT - | DB_UPSERT - | DB_UPDATE - | DB_DELETE - | DB_UNDELETE - ) - | expression '.' SUPER superSuffix - | expression '.' explicitGenericInvocation - | expression '[' expression ']' - | expression '(' expressionList? ')' - | NEW creator - | '(' type_ ')' expression - | expression ('++' | '--') - | ('+'|'-'|'++'|'--') expression - | ('~'|'!') expression - | expression ('*'|'/'|'%') expression - | expression ('+'|'-') expression - | expression ('<' '<' | '>' '>' '>' | '>' '>') expression - | expression ('<=' | '>=' | '>' | '<') expression - | expression INSTANCEOF type_ - | expression ('==' | '!=' | '<>') expression - | expression '&' expression - | expression '^' expression - | expression '|' expression - | expression '&&' expression - | expression '||' expression - | expression '?' expression ':' expression - | expression - ( '=' - | '+=' - | '-=' - | '*=' - | '/=' - | '&=' - | '|=' - | '^=' - | '>>=' - | '>>>=' - | '<<=' - | '%=' - ) - expression + : primary + | expression '.' GET '(' expressionList? ')' + | expression '.' SET '(' expressionList? ')' + | expression '?'? '.' Identifier + | expression '.' THIS + | expression '.' NEW + | expression '.' (DB_INSERT | DB_UPSERT | DB_UPDATE | DB_DELETE | DB_UNDELETE) + | expression '.' SUPER superSuffix + | expression '.' explicitGenericInvocation + | expression '[' expression ']' + | expression '(' expressionList? ')' + | NEW creator + | '(' type_ ')' expression + | expression ('++' | '--') + | ('+' | '-' | '++' | '--') expression + | ('~' | '!') expression + | expression ('*' | '/' | '%') expression + | expression ('+' | '-') expression + | expression ('<' '<' | '>' '>' '>' | '>' '>') expression + | expression ('<=' | '>=' | '>' | '<') expression + | expression INSTANCEOF type_ + | expression ('==' | '!=' | '<>') expression + | expression '&' expression + | expression '^' expression + | expression '|' expression + | expression '&&' expression + | expression '||' expression + | expression '?' expression ':' expression + | expression ( + '=' + | '+=' + | '-=' + | '*=' + | '/=' + | '&=' + | '|=' + | '^=' + | '>>=' + | '>>>=' + | '<<=' + | '%=' + ) expression ; primary - : '(' expression ')' - | THIS - | SUPER - | literal - | Identifier - | type_ '.' CLASS - | VOID '.' CLASS - | nonWildcardTypeArguments (explicitGenericInvocationSuffix | THIS arguments) - | SoqlLiteral + : '(' expression ')' + | THIS + | SUPER + | literal + | Identifier + | type_ '.' CLASS + | VOID '.' CLASS + | nonWildcardTypeArguments (explicitGenericInvocationSuffix | THIS arguments) + | SoqlLiteral ; creator - : nonWildcardTypeArguments createdName classCreatorRest - | createdName (arrayCreatorRest | classCreatorRest | mapCreatorRest | setCreatorRest) + : nonWildcardTypeArguments createdName classCreatorRest + | createdName (arrayCreatorRest | classCreatorRest | mapCreatorRest | setCreatorRest) ; createdName - : Identifier typeArgumentsOrDiamond? ('.' Identifier typeArgumentsOrDiamond?)* - | primitiveType - | SET typeArgumentsOrDiamond // 'set <' has to be defined explisitly, otherwise it clashes with SET of property setter + : Identifier typeArgumentsOrDiamond? ('.' Identifier typeArgumentsOrDiamond?)* + | primitiveType + | SET typeArgumentsOrDiamond // 'set <' has to be defined explisitly, otherwise it clashes with SET of property setter ; innerCreator - : Identifier nonWildcardTypeArgumentsOrDiamond? classCreatorRest + : Identifier nonWildcardTypeArgumentsOrDiamond? classCreatorRest ; arrayCreatorRest - : '[' - ( ']' ('[' ']')* arrayInitializer - | expression ']' ('[' expression ']')* ('[' ']')* - ) + : '[' (']' ('[' ']')* arrayInitializer | expression ']' ('[' expression ']')* ('[' ']')*) ; mapCreatorRest - : '{' - ( '}' - | ( Identifier | expression ) '=>' ( literal | expression ) (',' (Identifier | expression) '=>' ( literal | expression ) )* '}' - ) + : '{' ( + '}' + | (Identifier | expression) '=>' (literal | expression) ( + ',' (Identifier | expression) '=>' ( literal | expression) + )* '}' + ) ; setCreatorRest - : '{' - ( '}' - | ( literal | expression ) (',' ( literal | expression ))* '}' - ) - ; + : '{' ('}' | ( literal | expression) (',' ( literal | expression))* '}') + ; classCreatorRest - : arguments classBody? + : arguments classBody? ; explicitGenericInvocation - : nonWildcardTypeArguments explicitGenericInvocationSuffix + : nonWildcardTypeArguments explicitGenericInvocationSuffix ; nonWildcardTypeArguments - : '<' typeList '>' + : '<' typeList '>' ; typeArgumentsOrDiamond - : '<' '>' - | typeArguments + : '<' '>' + | typeArguments ; nonWildcardTypeArgumentsOrDiamond - : '<' '>' - | nonWildcardTypeArguments + : '<' '>' + | nonWildcardTypeArguments ; superSuffix - : arguments - | '.' Identifier arguments? + : arguments + | '.' Identifier arguments? ; explicitGenericInvocationSuffix - : SUPER superSuffix - | Identifier arguments + : SUPER superSuffix + | Identifier arguments ; arguments - : '(' expressionList? ')' + : '(' expressionList? ')' ; // Apex - SOQL literal SoqlLiteral : '[' WS* SELECT (SelectRestNoInnerBrackets | SelectRestAllowingInnerBrackets)*? ']' - ; + ; fragment SelectRestAllowingInnerBrackets - : '[' ~']' .*? ']' - | ~'[' .*? - ; + : '[' ~']' .*? ']' + | ~'[' .*? + ; fragment SelectRestNoInnerBrackets - : ~'[' - ; + : ~'[' + ; + // LEXER // ?3.9 Keywords -OVERRIDE : O V E R R I D E; -VIRTUAL : V I R T U A L; -SET : S E T; -GET : G E T; -ABSTRACT : A B S T R A C T; -BREAK : B R E A K; -BYTE : B Y T E; -CATCH : C A T C H; -CHAR : C H A R; -CLASS : C L A S S; -CONST : C O N S T; -CONTINUE : C O N T I N U E; -DEFAULT : D E F A U L T; -DO : D O; -ELSE : E L S E; -ENUM : E N U M; -EXTENDS : E X T E N D S; -FINAL : F I N A L; -FINALLY : F I N A L L Y; -FLOAT : F L O A T; -FOR : F O R; -IF : I F; -GOTO : G O T O; -IMPLEMENTS : I M P L E M E N T S; -IMPORT : I M P O R T; -INSTANCEOF : I N S T A N C E O F; -INT : I N T; -INTERFACE : I N T E R F A C E; -NATIVE : N A T I V E; -NEW : N E W; -PACKAGE : P A C K A G E; -PRIVATE : P R I V A T E; -PROTECTED : P R O T E C T E D; -PUBLIC : P U B L I C; -RETURN : R E T U R N; -SHORT : S H O R T; -STATIC : S T A T I C; - -SUPER : S U P E R; -SYNCHRONIZED : S Y N C H R O N I Z E D; -THIS : T H I S; -THROW : T H R O W; -THROWS : T H R O W S; -TRANSIENT : T R A N S I E N T; -TRY : T R Y; -VOID : V O I D; -VOLATILE : V O L A T I L E; -WHILE : W H I L E; +OVERRIDE + : O V E R R I D E + ; + +VIRTUAL + : V I R T U A L + ; + +SET + : S E T + ; + +GET + : G E T + ; + +ABSTRACT + : A B S T R A C T + ; + +BREAK + : B R E A K + ; + +BYTE + : B Y T E + ; + +CATCH + : C A T C H + ; + +CHAR + : C H A R + ; + +CLASS + : C L A S S + ; + +CONST + : C O N S T + ; + +CONTINUE + : C O N T I N U E + ; + +DEFAULT + : D E F A U L T + ; + +DO + : D O + ; + +ELSE + : E L S E + ; + +ENUM + : E N U M + ; + +EXTENDS + : E X T E N D S + ; + +FINAL + : F I N A L + ; + +FINALLY + : F I N A L L Y + ; + +FLOAT + : F L O A T + ; + +FOR + : F O R + ; + +IF + : I F + ; + +GOTO + : G O T O + ; + +IMPLEMENTS + : I M P L E M E N T S + ; + +IMPORT + : I M P O R T + ; + +INSTANCEOF + : I N S T A N C E O F + ; + +INT + : I N T + ; + +INTERFACE + : I N T E R F A C E + ; + +NATIVE + : N A T I V E + ; + +NEW + : N E W + ; + +PACKAGE + : P A C K A G E + ; + +PRIVATE + : P R I V A T E + ; + +PROTECTED + : P R O T E C T E D + ; + +PUBLIC + : P U B L I C + ; + +RETURN + : R E T U R N + ; + +SHORT + : S H O R T + ; + +STATIC + : S T A T I C + ; + +SUPER + : S U P E R + ; + +SYNCHRONIZED + : S Y N C H R O N I Z E D + ; + +THIS + : T H I S + ; + +THROW + : T H R O W + ; + +THROWS + : T H R O W S + ; + +TRANSIENT + : T R A N S I E N T + ; + +TRY + : T R Y + ; + +VOID + : V O I D + ; + +VOLATILE + : V O L A T I L E + ; + +WHILE + : W H I L E + ; // Apexcode specific -GLOBAL : G L O B A L; -WEBSERVICE : W E B S E R V I C E; -APEX_WITH_SHARING : W I T H SPACE S H A R I N G; -APEX_WITHOUT_SHARING : W I T H O U T SPACE S H A R I N G; -SELECT : S E L E C T; -DB_INSERT : I N S E R T; -DB_UPSERT : U P S E R T; -DB_UPDATE : U P D A T E; -DB_DELETE : D E L E T E; -DB_UNDELETE : U N D E L E T E; -TESTMETHOD : T E S T M E T H O D; -RUNAS : S Y S T E M DOT R U N A S; +GLOBAL + : G L O B A L + ; + +WEBSERVICE + : W E B S E R V I C E + ; + +APEX_WITH_SHARING + : W I T H SPACE S H A R I N G + ; + +APEX_WITHOUT_SHARING + : W I T H O U T SPACE S H A R I N G + ; + +SELECT + : S E L E C T + ; + +DB_INSERT + : I N S E R T + ; + +DB_UPSERT + : U P S E R T + ; +DB_UPDATE + : U P D A T E + ; + +DB_DELETE + : D E L E T E + ; + +DB_UNDELETE + : U N D E L E T E + ; + +TESTMETHOD + : T E S T M E T H O D + ; + +RUNAS + : S Y S T E M DOT R U N A S + ; // ?3.10.1 Integer Literals IntegerLiteral - : DecimalIntegerLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - | BinaryIntegerLiteral + : DecimalIntegerLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + | BinaryIntegerLiteral ; -fragment -DecimalIntegerLiteral - : DecimalNumeral IntegerTypeSuffix? +fragment DecimalIntegerLiteral + : DecimalNumeral IntegerTypeSuffix? ; -fragment -HexIntegerLiteral - : HexNumeral IntegerTypeSuffix? +fragment HexIntegerLiteral + : HexNumeral IntegerTypeSuffix? ; -fragment -OctalIntegerLiteral - : OctalNumeral IntegerTypeSuffix? +fragment OctalIntegerLiteral + : OctalNumeral IntegerTypeSuffix? ; -fragment -BinaryIntegerLiteral - : BinaryNumeral IntegerTypeSuffix? +fragment BinaryIntegerLiteral + : BinaryNumeral IntegerTypeSuffix? ; -fragment -IntegerTypeSuffix - : [lL] +fragment IntegerTypeSuffix + : [lL] ; -fragment -DecimalNumeral - : '0' Digit? - | NonZeroDigit (Digits? | Underscores Digits) +fragment DecimalNumeral + : '0' Digit? + | NonZeroDigit (Digits? | Underscores Digits) ; -fragment -Digits - : Digit (DigitOrUnderscore* Digit)? +fragment Digits + : Digit (DigitOrUnderscore* Digit)? ; -fragment -Digit - : '0' - | NonZeroDigit +fragment Digit + : '0' + | NonZeroDigit ; -fragment -NonZeroDigit - : [1-9] +fragment NonZeroDigit + : [1-9] ; -fragment -DigitOrUnderscore - : Digit - | '_' +fragment DigitOrUnderscore + : Digit + | '_' ; -fragment -Underscores - : '_'+ +fragment Underscores + : '_'+ ; -fragment -HexNumeral - : '0' [xX] HexDigits +fragment HexNumeral + : '0' [xX] HexDigits ; -fragment -HexDigits - : HexDigit (HexDigitOrUnderscore* HexDigit)? +fragment HexDigits + : HexDigit (HexDigitOrUnderscore* HexDigit)? ; -fragment -HexDigit - : [0-9a-fA-F] +fragment HexDigit + : [0-9a-fA-F] ; -fragment -HexDigitOrUnderscore - : HexDigit - | '_' +fragment HexDigitOrUnderscore + : HexDigit + | '_' ; -fragment -OctalNumeral - : '0' Underscores? OctalDigits +fragment OctalNumeral + : '0' Underscores? OctalDigits ; -fragment -OctalDigits - : OctalDigit (OctalDigitOrUnderscore* OctalDigit)? +fragment OctalDigits + : OctalDigit (OctalDigitOrUnderscore* OctalDigit)? ; -fragment -OctalDigit - : [0-7] +fragment OctalDigit + : [0-7] ; -fragment -OctalDigitOrUnderscore - : OctalDigit - | '_' +fragment OctalDigitOrUnderscore + : OctalDigit + | '_' ; -fragment -BinaryNumeral - : '0' [bB] BinaryDigits +fragment BinaryNumeral + : '0' [bB] BinaryDigits ; -fragment -BinaryDigits - : BinaryDigit (BinaryDigitOrUnderscore* BinaryDigit)? +fragment BinaryDigits + : BinaryDigit (BinaryDigitOrUnderscore* BinaryDigit)? ; -fragment -BinaryDigit - : [01] +fragment BinaryDigit + : [01] ; -fragment -BinaryDigitOrUnderscore - : BinaryDigit - | '_' +fragment BinaryDigitOrUnderscore + : BinaryDigit + | '_' ; // ?3.10.2 Floating-Point Literals FloatingPointLiteral - : DecimalFloatingPointLiteral - | HexadecimalFloatingPointLiteral + : DecimalFloatingPointLiteral + | HexadecimalFloatingPointLiteral ; -fragment -DecimalFloatingPointLiteral - : Digits '.' Digits? ExponentPart? FloatTypeSuffix? - | '.' Digits ExponentPart? FloatTypeSuffix? - | Digits ExponentPart FloatTypeSuffix? - | Digits FloatTypeSuffix +fragment DecimalFloatingPointLiteral + : Digits '.' Digits? ExponentPart? FloatTypeSuffix? + | '.' Digits ExponentPart? FloatTypeSuffix? + | Digits ExponentPart FloatTypeSuffix? + | Digits FloatTypeSuffix ; -fragment -ExponentPart - : ExponentIndicator SignedInteger +fragment ExponentPart + : ExponentIndicator SignedInteger ; -fragment -ExponentIndicator - : [eE] +fragment ExponentIndicator + : [eE] ; -fragment -SignedInteger - : Sign? Digits +fragment SignedInteger + : Sign? Digits ; -fragment -Sign - : [+-] +fragment Sign + : [+-] ; -fragment -FloatTypeSuffix - : [fFdD] +fragment FloatTypeSuffix + : [fFdD] ; -fragment -HexadecimalFloatingPointLiteral - : HexSignificand BinaryExponent FloatTypeSuffix? +fragment HexadecimalFloatingPointLiteral + : HexSignificand BinaryExponent FloatTypeSuffix? ; -fragment -HexSignificand - : HexNumeral '.'? - | '0' [xX] HexDigits? '.' HexDigits +fragment HexSignificand + : HexNumeral '.'? + | '0' [xX] HexDigits? '.' HexDigits ; -fragment -BinaryExponent - : BinaryExponentIndicator SignedInteger +fragment BinaryExponent + : BinaryExponentIndicator SignedInteger ; -fragment -BinaryExponentIndicator - : [pP] +fragment BinaryExponentIndicator + : [pP] ; // ?3.10.3 Boolean Literals BooleanLiteral - : 'true' - | 'false' + : 'true' + | 'false' ; // ?3.10.4 Character Literals CharacterLiteral - : QUOTE SingleCharacter QUOTE - | QUOTE EscapeSequence QUOTE + : QUOTE SingleCharacter QUOTE + | QUOTE EscapeSequence QUOTE ; -fragment -SingleCharacter - : ~['\\] +fragment SingleCharacter + : ~['\\] ; // ?3.10.5 String Literals StringLiteral - : QUOTE StringCharacters? QUOTE + : QUOTE StringCharacters? QUOTE ; -fragment -StringCharacters - : StringCharacter+ +fragment StringCharacters + : StringCharacter+ ; -fragment -StringCharacter - : ~['\\] - | EscapeSequence +fragment StringCharacter + : ~['\\] + | EscapeSequence ; // ?3.10.6 Escape Sequences for Character and String Literals -fragment -EscapeSequence - : '\\' [btnfr"'\\] - | OctalEscape - | UnicodeEscape +fragment EscapeSequence + : '\\' [btnfr"'\\] + | OctalEscape + | UnicodeEscape ; -fragment -OctalEscape - : '\\' OctalDigit - | '\\' OctalDigit OctalDigit - | '\\' ZeroToThree OctalDigit OctalDigit +fragment OctalEscape + : '\\' OctalDigit + | '\\' OctalDigit OctalDigit + | '\\' ZeroToThree OctalDigit OctalDigit ; -fragment -UnicodeEscape - : '\\' 'u' HexDigit HexDigit HexDigit HexDigit +fragment UnicodeEscape + : '\\' 'u' HexDigit HexDigit HexDigit HexDigit ; -fragment -ZeroToThree - : [0-3] +fragment ZeroToThree + : [0-3] ; // ?3.10.7 The Null Literal -NullLiteral : N U L L; - +NullLiteral + : N U L L + ; // ?3.11 Separators -LPAREN : '('; -RPAREN : ')'; -LBRACE : '{'; -RBRACE : '}'; -LBRACK : '['; -RBRACK : ']'; -SEMI : ';'; -COMMA : ','; -DOT : '.'; +LPAREN + : '(' + ; + +RPAREN + : ')' + ; + +LBRACE + : '{' + ; + +RBRACE + : '}' + ; + +LBRACK + : '[' + ; + +RBRACK + : ']' + ; + +SEMI + : ';' + ; + +COMMA + : ',' + ; + +DOT + : '.' + ; // ?3.12 Operators -ASSIGN : '='; -GT : '>'; -LT : '<'; -BANG : '!'; -TILDE : '~'; -QUESTION : '?'; -COLON : ':'; -EQUAL : '=='; -LE : '<='; -GE : '>='; -NOTEQUAL : '!='; -AND : '&&'; -OR : '||'; -INC : '++'; -DEC : '--'; -ADD : '+'; -SUB : '-'; -MUL : '*'; -DIV : '/'; -BITAND : '&'; -BITOR : '|'; -CARET : '^'; -MOD : '%'; - -ADD_ASSIGN : '+='; -SUB_ASSIGN : '-='; -MUL_ASSIGN : '*='; -DIV_ASSIGN : '/='; -AND_ASSIGN : '&='; -OR_ASSIGN : '|='; -XOR_ASSIGN : '^='; -MOD_ASSIGN : '%='; -LSHIFT_ASSIGN : '<<='; -RSHIFT_ASSIGN : '>>='; -URSHIFT_ASSIGN : '>>>='; -LAMBDA_LIKE : '=>'; +ASSIGN + : '=' + ; + +GT + : '>' + ; + +LT + : '<' + ; + +BANG + : '!' + ; + +TILDE + : '~' + ; + +QUESTION + : '?' + ; + +COLON + : ':' + ; + +EQUAL + : '==' + ; + +LE + : '<=' + ; + +GE + : '>=' + ; + +NOTEQUAL + : '!=' + ; + +AND + : '&&' + ; + +OR + : '||' + ; + +INC + : '++' + ; + +DEC + : '--' + ; + +ADD + : '+' + ; + +SUB + : '-' + ; + +MUL + : '*' + ; + +DIV + : '/' + ; + +BITAND + : '&' + ; + +BITOR + : '|' + ; +CARET + : '^' + ; + +MOD + : '%' + ; + +ADD_ASSIGN + : '+=' + ; + +SUB_ASSIGN + : '-=' + ; + +MUL_ASSIGN + : '*=' + ; + +DIV_ASSIGN + : '/=' + ; + +AND_ASSIGN + : '&=' + ; + +OR_ASSIGN + : '|=' + ; + +XOR_ASSIGN + : '^=' + ; + +MOD_ASSIGN + : '%=' + ; + +LSHIFT_ASSIGN + : '<<=' + ; + +RSHIFT_ASSIGN + : '>>=' + ; + +URSHIFT_ASSIGN + : '>>>=' + ; + +LAMBDA_LIKE + : '=>' + ; // ?3.8 Identifiers (must appear after all keywords in the grammar) Identifier - : JavaLetter JavaLetterOrDigit* + : JavaLetter JavaLetterOrDigit* ; -fragment -JavaLetter - : [a-zA-Z$_] // these are the "java letters" below 0xFF - | // covers all characters above 0xFF which are not a surrogate - ~[\u0000-\u00FF\uD800-\uDBFF] - {Character.isJavaIdentifierStart(_input.LA(-1))}? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - {Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? +fragment JavaLetter + : [a-zA-Z$_] // these are the "java letters" below 0xFF + | // covers all characters above 0xFF which are not a surrogate + ~[\u0000-\u00FF\uD800-\uDBFF] {Character.isJavaIdentifierStart(_input.LA(-1))}? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] {Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? ; -fragment -JavaLetterOrDigit - : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0xFF - | // covers all characters above 0xFF which are not a surrogate - ~[\u0000-\u00FF\uD800-\uDBFF] - {Character.isJavaIdentifierPart(_input.LA(-1))}? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - {Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? +fragment JavaLetterOrDigit + : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0xFF + | // covers all characters above 0xFF which are not a surrogate + ~[\u0000-\u00FF\uD800-\uDBFF] {Character.isJavaIdentifierPart(_input.LA(-1))}? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] {Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? ; // // Additional symbols not defined in the lexical specification // -AT : '@'; -ELLIPSIS : '...'; +AT + : '@' + ; + +ELLIPSIS + : '...' + ; // // Whitespace and comments // -WS : [ \t\r\n\u000C]+ -> skip +WS + : [ \t\r\n\u000C]+ -> skip ; APEXDOC_COMMENT - : '/**' [\r\n] .*? '*/' -> skip + : '/**' [\r\n] .*? '*/' -> skip ; APEXDOC_COMMENT_START - : '/**' -> skip + : '/**' -> skip ; COMMENT - : '/*' .*? '*/' -> skip + : '/*' .*? '*/' -> skip ; COMMENT_START - : '/*' -> skip + : '/*' -> skip ; LINE_COMMENT - : '//' ~[\r\n]* -> skip + : '//' ~[\r\n]* -> skip ; // // Unexpected token for non recognized elements // -QUOTE : '\'' -> skip; +QUOTE + : '\'' -> skip + ; // characters -fragment A : [aA]; -fragment B : [bB]; -fragment C : [cC]; -fragment D : [dD]; -fragment E : [eE]; -fragment F : [fF]; -fragment G : [gG]; -fragment H : [hH]; -fragment I : [iI]; -fragment J : [jJ]; -fragment K : [kK]; -fragment L : [lL]; -fragment M : [mM]; -fragment N : [nN]; -fragment O : [oO]; -fragment P : [pP]; -fragment Q : [qQ]; -fragment R : [rR]; -fragment S : [sS]; -fragment T : [tT]; -fragment U : [uU]; -fragment V : [vV]; -fragment W : [wW]; -fragment X : [xX]; -fragment Y : [yY]; -fragment Z : [zZ]; -fragment SPACE : ' '; +fragment A + : [aA] + ; + +fragment B + : [bB] + ; + +fragment C + : [cC] + ; + +fragment D + : [dD] + ; + +fragment E + : [eE] + ; + +fragment F + : [fF] + ; + +fragment G + : [gG] + ; + +fragment H + : [hH] + ; + +fragment I + : [iI] + ; + +fragment J + : [jJ] + ; + +fragment K + : [kK] + ; + +fragment L + : [lL] + ; + +fragment M + : [mM] + ; + +fragment N + : [nN] + ; + +fragment O + : [oO] + ; + +fragment P + : [pP] + ; + +fragment Q + : [qQ] + ; + +fragment R + : [rR] + ; + +fragment S + : [sS] + ; + +fragment T + : [tT] + ; + +fragment U + : [uU] + ; + +fragment V + : [vV] + ; + +fragment W + : [wW] + ; + +fragment X + : [xX] + ; + +fragment Y + : [yY] + ; + +fragment Z + : [zZ] + ; + +fragment SPACE + : ' ' + ; \ No newline at end of file diff --git a/apt/apt.g4 b/apt/apt.g4 index f87b2fd157..a20a7eb753 100644 --- a/apt/apt.g4 +++ b/apt/apt.g4 @@ -1,67 +1,224 @@ // Generated with UniGrammar (https://gitlab.com/KOLANICH/UniGrammar.py) // for antlr4 (https://github.com/antlr/antlr4) backend + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar apt; // productions -record: commented=commenterR? rType=TypeR WSS options_ = optionsR? uri=uriR WSS distribution=wordWithDash components=componentsR WSS? EOF; -wordWithDashSegment: Word | Dash; -wordWithDash: wordWithDashSegment+; -component: WSS cId=wordWithDash; -componentsR: component+; +record + : commented = commenterR? rType = TypeR WSS options_ = optionsR? uri = uriR WSS distribution = wordWithDash components = componentsR WSS? EOF + ; + +wordWithDashSegment + : Word + | Dash + ; + +wordWithDash + : wordWithDashSegment+ + ; + +component + : WSS cId = wordWithDash + ; + +componentsR + : component+ + ; + +optionsR + : openingBrace = OptionsStart pairs = optionsList closingBrace = OptionsEnd WSS + ; + +optionsList + : firstOption = optionR restOptions = additionalOptions + ; + +additionalOptions + : additionalOption* + ; + +additionalOption + : separator = OptionsSeparator option = optionR + ; + +optionR + : key = OptionName OptionNameValueSeparator value = optionValue + ; + +wordWithPlus + : Plus word = Word + ; + +uriSchema + : word = Word restWords = restSchemaWords + ; + +restSchemaWords + : wordWithPlus* + ; + +genericURI + : schema = uriSchema Colon restOfURI = nonSpaceString + ; + +uriR + : cdromURI + | genericURI + ; + +commenterR + : CommentMarker WSS + ; -optionsR: openingBrace=OptionsStart pairs=optionsList closingBrace=OptionsEnd WSS; -optionsList: firstOption=optionR restOptions=additionalOptions; -additionalOptions: additionalOption*; -additionalOption: separator=OptionsSeparator option=optionR; -optionR: key=OptionName OptionNameValueSeparator value=optionValue; +optionValueSegment + : Word + | PunctuationAllowedInOptionValue + | Dash + | OptionName + | CdromSchema + | TypeR + | Plus + | Colon + ; -wordWithPlus: Plus word=Word; -uriSchema: word=Word restWords=restSchemaWords; -restSchemaWords: wordWithPlus*; -genericURI: schema=uriSchema Colon restOfURI=nonSpaceString; +optionValue + : optionValueSegment+ + ; -uriR: cdromURI | genericURI; +nonSquareBracketStringSegment + : NonWhitespaceNonOptionValueNonSquareRightBracketNonEq + | optionValueSegment + | OptionNameValueSeparator + ; -commenterR: CommentMarker WSS; +nonSquareBracketString + : nonSquareBracketStringSegment+ + ; -optionValueSegment: Word | PunctuationAllowedInOptionValue | Dash | OptionName | CdromSchema | TypeR | Plus | Colon; -optionValue: optionValueSegment+; -nonSquareBracketStringSegment: NonWhitespaceNonOptionValueNonSquareRightBracketNonEq | optionValueSegment | OptionNameValueSeparator; -nonSquareBracketString: nonSquareBracketStringSegment+; -nonSpaceStringSegment: nonSquareBracketStringSegment | OptionsEnd; -nonSpaceString: nonSpaceStringSegment+; +nonSpaceStringSegment + : nonSquareBracketStringSegment + | OptionsEnd + ; -singleTickEnclosedString: SingleTick nonSquareBracketString SingleTick; -doubleTickEnclosedString: DoubleTick nonSquareBracketString DoubleTick; -tickEnclosedString: singleTickEnclosedString | doubleTickEnclosedString; -enclosedString: OptionsStart tickEnclosedString OptionsEnd; -cdromURI: CdromSchema Colon enclosedString nonSpaceString; +nonSpaceString + : nonSpaceStringSegment+ + ; +singleTickEnclosedString + : SingleTick nonSquareBracketString SingleTick + ; + +doubleTickEnclosedString + : DoubleTick nonSquareBracketString DoubleTick + ; + +tickEnclosedString + : singleTickEnclosedString + | doubleTickEnclosedString + ; + +enclosedString + : OptionsStart tickEnclosedString OptionsEnd + ; + +cdromURI + : CdromSchema Colon enclosedString nonSpaceString + ; // keywords -TypeR: 'deb' | 'deb-src'; -OptionName: 'arch' | 'lang' | 'target' | 'pdiffs' | 'by-hash' | 'valid-until-max' | 'allow-downgrade-to-insecure' | 'allow-weak' | 'allow-insecure' | 'trusted' | 'signed-by' | 'check-valid-until' | 'valid-until-min' | 'check-date' | 'inrelease-path' | 'date-max-future'; -CdromSchema: 'cdrom:'; +TypeR + : 'deb' + | 'deb-src' + ; + +OptionName + : 'arch' + | 'lang' + | 'target' + | 'pdiffs' + | 'by-hash' + | 'valid-until-max' + | 'allow-downgrade-to-insecure' + | 'allow-weak' + | 'allow-insecure' + | 'trusted' + | 'signed-by' + | 'check-valid-until' + | 'valid-until-min' + | 'check-date' + | 'inrelease-path' + | 'date-max-future' + ; +CdromSchema + : 'cdrom:' + ; // tokens -Word: WordChar+; -WSS: WS+; +Word + : WordChar+ + ; + +WSS + : WS+ + ; // characters -WS: [ \t\n\r\u{000b}\u{000c}]; -PunctuationAllowedInOptionValue: [/.]; -OptionsStart: '['; -OptionsEnd: ']'; -OptionNameValueSeparator: '='; -CommentMarker: '#'; -Plus: '+'; -Colon: ':'; -OptionsSeparator: ','; -Dash: '-'; -SingleTick: '\''; -DoubleTick: '"'; -WordChar: [0-9A-Z_a-z]; -NonWhitespaceNonOptionValueNonSquareRightBracketNonEq: ~[\t-\r "#'+-:=A-\]_a-z]; +WS + : [ \t\n\r\u{000b}\u{000c}] + ; + +PunctuationAllowedInOptionValue + : [/.] + ; + +OptionsStart + : '[' + ; + +OptionsEnd + : ']' + ; + +OptionNameValueSeparator + : '=' + ; + +CommentMarker + : '#' + ; + +Plus + : '+' + ; + +Colon + : ':' + ; + +OptionsSeparator + : ',' + ; + +Dash + : '-' + ; + +SingleTick + : '\'' + ; + +DoubleTick + : '"' + ; +WordChar + : [0-9A-Z_a-z] + ; +NonWhitespaceNonOptionValueNonSquareRightBracketNonEq + : ~[\t-\r "#'+-:=A-\]_a-z] + ; \ No newline at end of file diff --git a/aql/ArangoDbLexer.g4 b/aql/ArangoDbLexer.g4 index 874522d3c3..5b7b65f4bd 100644 --- a/aql/ArangoDbLexer.g4 +++ b/aql/ArangoDbLexer.g4 @@ -21,123 +21,133 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ArangoDbLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} //keywrods -COLLECT: 'COLLECT'; -FILTER: 'FILTER'; -FOR: 'FOR'; -INSERT: 'INSERT'; -LET: 'LET'; -LIMIT: 'LIMIT'; -REMOVE: 'REMOVE'; -REPLACE: 'REPLACE'; -RETURN: 'RETURN'; -SEARCH: 'SEARCH'; -SORT: 'SORT'; -UPDATE: 'UPDATE'; -UPSERT: 'UPSERT'; -WINDOW: 'WINDOW'; -WITH: 'WITH'; - -AGGREGATE: 'AGGREGATE'; -ALL: 'ALL'; -AND: 'AND'; -ANY: 'ANY'; -ASC: 'ASC'; -DESC: 'DESC'; -DISTINCT: 'DISTINCT'; -FALSE: 'FALSE'; -GRAPH: 'GRAPH'; -IN: 'IN'; -INBOUND: 'INBOUND'; -INTO: 'INTO'; -K_PATHS: 'K_PATHS'; -K_SHORTEST_PATHS: 'K_SHORTEST_PATHS'; -LIKE: 'LIKE'; -NONE: 'NONE'; -NOT: 'NOT'; -NULL_: 'NULL'; -OR: 'OR'; -OUTBOUND: 'OUTBOUND'; -SHORTEST_PATH: 'SHORTEST_PATH'; -TRUE: 'TRUE'; - -KEEP: 'KEEP'; -COUNT: 'COUNT'; -OPTIONS: 'OPTIONS'; -PRUNE: 'PRUNE'; -TO: 'TO'; +COLLECT : 'COLLECT'; +FILTER : 'FILTER'; +FOR : 'FOR'; +INSERT : 'INSERT'; +LET : 'LET'; +LIMIT : 'LIMIT'; +REMOVE : 'REMOVE'; +REPLACE : 'REPLACE'; +RETURN : 'RETURN'; +SEARCH : 'SEARCH'; +SORT : 'SORT'; +UPDATE : 'UPDATE'; +UPSERT : 'UPSERT'; +WINDOW : 'WINDOW'; +WITH : 'WITH'; + +AGGREGATE : 'AGGREGATE'; +ALL : 'ALL'; +AND : 'AND'; +ANY : 'ANY'; +ASC : 'ASC'; +DESC : 'DESC'; +DISTINCT : 'DISTINCT'; +FALSE : 'FALSE'; +GRAPH : 'GRAPH'; +IN : 'IN'; +INBOUND : 'INBOUND'; +INTO : 'INTO'; +K_PATHS : 'K_PATHS'; +K_SHORTEST_PATHS : 'K_SHORTEST_PATHS'; +LIKE : 'LIKE'; +NONE : 'NONE'; +NOT : 'NOT'; +NULL_ : 'NULL'; +OR : 'OR'; +OUTBOUND : 'OUTBOUND'; +SHORTEST_PATH : 'SHORTEST_PATH'; +TRUE : 'TRUE'; + +KEEP : 'KEEP'; +COUNT : 'COUNT'; +OPTIONS : 'OPTIONS'; +PRUNE : 'PRUNE'; +TO : 'TO'; //case-sensitive: //CURRENT – available in array inline expressions //NEW – available after INSERT / UPDATE / REPLACE / UPSERT operation //OLD – available after UPDATE / REPLACE / UPSERT / REMOVE operation -CURRENT options { caseInsensitive = false; }: 'CURRENT'; -NEW options { caseInsensitive = false; }: 'NEW'; -OLD options { caseInsensitive = false; }: 'OLD'; +CURRENT options { + caseInsensitive = false; +}: 'CURRENT'; +NEW options { + caseInsensitive = false; +}: 'NEW'; +OLD options { + caseInsensitive = false; +}: 'OLD'; DOCUMENT: 'DOCUMENT'; - -SEMI: ';'; -L_AND: '&&'; -L_OR: '||'; -L_NOT: '!'; - -EQ: '=='; -NE: '!='; -LT: '<'; -LE: '<='; -GT: '>'; -GE: '>='; - -PLUS: '+'; -MINUS: '-'; -STAR: '*'; -DIV: '/'; -MOD: '%'; - -QM: '?'; -COLON: ':'; -RANGE: '..'; - -ASSIGN: '='; -COMMA: ','; -SCOPE: '::'; -ACCESS: '.'; - -REGEX_MATCH: '=~'; -REGEX_NON_MATCH: '!~'; - -LRB: '('; -RRB: ')'; -LSB: '['; -RSB: ']'; -LCB: '{'; -RCB: '}'; - -WHITE_SPACE : [ \t\r\n]+ -> channel(HIDDEN); - -SQL_COMMENT : '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); -LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); - -ID : [A-Z_] [A-Z0-9_]*; -BIND_PARAMETER : '@' [A-Z0-9][A-Z0-9_]*; -BIND_PARAMETER_COLL : '@@' [A-Z0-9][A-Z0-9_]*; - -STRING_LITERAL : '\'' (~'\'' | '\'\'')* '\''; -DOUBLE_QUOTED_STRING_LITERAL : '"' ~'"'+ '"'; -BACKSTICK_STRING_LITERAL : '`' ~'`'+ '`'; - -DECIMAL_LITERAL : DEC_DIGIT+; -FLOAT_LITERAL : DEC_DOT_DEC; -REAL_LITERAL : (DECIMAL_LITERAL | DEC_DOT_DEC) 'E' [+-]? DEC_DIGIT+; - - -fragment HexDigit : [0-9a-f]; -fragment LETTER : [A-Z_]; -fragment DEC_DOT_DEC : DEC_DIGIT+ '.' DEC_DIGIT+ | '.' DEC_DIGIT+; -fragment DEC_DIGIT : [0-9]; +SEMI : ';'; +L_AND : '&&'; +L_OR : '||'; +L_NOT : '!'; + +EQ : '=='; +NE : '!='; +LT : '<'; +LE : '<='; +GT : '>'; +GE : '>='; + +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +DIV : '/'; +MOD : '%'; + +QM : '?'; +COLON : ':'; +RANGE : '..'; + +ASSIGN : '='; +COMMA : ','; +SCOPE : '::'; +ACCESS : '.'; + +REGEX_MATCH : '=~'; +REGEX_NON_MATCH : '!~'; + +LRB : '('; +RRB : ')'; +LSB : '['; +RSB : ']'; +LCB : '{'; +RCB : '}'; + +WHITE_SPACE: [ \t\r\n]+ -> channel(HIDDEN); + +SQL_COMMENT : '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); + +ID : [A-Z_] [A-Z0-9_]*; +BIND_PARAMETER : '@' [A-Z0-9][A-Z0-9_]*; +BIND_PARAMETER_COLL : '@@' [A-Z0-9][A-Z0-9_]*; + +STRING_LITERAL : '\'' (~'\'' | '\'\'')* '\''; +DOUBLE_QUOTED_STRING_LITERAL : '"' ~'"'+ '"'; +BACKSTICK_STRING_LITERAL : '`' ~'`'+ '`'; + +DECIMAL_LITERAL : DEC_DIGIT+; +FLOAT_LITERAL : DEC_DOT_DEC; +REAL_LITERAL : (DECIMAL_LITERAL | DEC_DOT_DEC) 'E' [+-]? DEC_DIGIT+; + +fragment HexDigit : [0-9a-f]; +fragment LETTER : [A-Z_]; +fragment DEC_DOT_DEC : DEC_DIGIT+ '.' DEC_DIGIT+ | '.' DEC_DIGIT+; +fragment DEC_DIGIT : [0-9]; \ No newline at end of file diff --git a/aql/ArangoDbParser.g4 b/aql/ArangoDbParser.g4 index df682e8c03..bc7657c4c6 100644 --- a/aql/ArangoDbParser.g4 +++ b/aql/ArangoDbParser.g4 @@ -21,9 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 ArangoDbParser; -options { tokenVocab=ArangoDbLexer; } +options { + tokenVocab = ArangoDbLexer; +} arangodb_query : data_query EOF @@ -35,35 +40,29 @@ data_query ; data_access_query - : with_collection_list? ( for_op* return_expr - | FOR v=id_ (',' e=id_ (',' p=id_)? )? - IN (numeric_literal ('..' numeric_literal)? )? - (OUTBOUND | INBOUND | ANY) expr - (GRAPH expr | collection_list) // collections support direction: ANY - (PRUNE expr)? - filter* - options_? - return_expr? ) + : with_collection_list? ( + for_op* return_expr + | FOR v = id_ (',' e = id_ (',' p = id_)?)? IN (numeric_literal ('..' numeric_literal)?)? ( + OUTBOUND + | INBOUND + | ANY + ) expr (GRAPH expr | collection_list) // collections support direction: ANY + (PRUNE expr)? filter* options_? return_expr? + ) ; for_op - : for_in - collect* - filter* - sort* - limit* - window* + : for_in collect* filter* sort* limit* window* ; data_modification_query - : with_collection_list? for_op* - ( INSERT object_literal in_into collection options_? + : with_collection_list? for_op* ( + INSERT object_literal in_into collection options_? | UPDATE (expr WITH)? object_literal IN collection options_? | REPLACE (expr WITH)? object_literal IN collection options_? | (REMOVE expr IN collection options_?)+ | UPSERT expr INSERT expr (UPDATE | REPLACE) expr IN collection options_? - ) - return_expr? + ) return_expr? ; options_ @@ -118,13 +117,13 @@ collection ; collect - : COLLECT ( expr (INTO expr)? - | expr (INTO id_ KEEP id_)? - | expr WITH COUNT INTO id_ - | expr? aggregate_assign (INTO id_)? - | WITH COUNT INTO id_ - ) - options_? + : COLLECT ( + expr (INTO expr)? + | expr (INTO id_ KEEP id_)? + | expr WITH COUNT INTO id_ + | expr? aggregate_assign (INTO id_)? + | WITH COUNT INTO id_ + ) options_? ; window @@ -153,7 +152,7 @@ expr | '(' (expr | data_access_query) ')' | expr '[' (expr | '*') ']' | expr ACCESS expr - | ('+'|'-') expr + | ('+' | '-') expr | id_ LRB expr RRB | expr ('*' | '/' | '%') expr | expr ('+' | '-') expr @@ -208,4 +207,4 @@ numeric_literal : DECIMAL_LITERAL | FLOAT_LITERAL | REAL_LITERAL - ; + ; \ No newline at end of file diff --git a/arden/ArdenLexer.g4 b/arden/ArdenLexer.g4 index e12fdaf3e0..c60b0a820c 100644 --- a/arden/ArdenLexer.g4 +++ b/arden/ArdenLexer.g4 @@ -1,340 +1,336 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ArdenLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} // Keywords -ABS: 'abs'; -ACTION: 'action:'; -ADD: 'add'; -AFTER: 'after'; -AGGREGATE: 'aggregate'; -AGO: 'ago'; -ALL: 'all'; -AND: 'and'; -ANY: 'any'; -APPLICABILITY: 'applicability'; -ARCCOS: 'arccos'; -ARCSIN: 'arcsin'; -ARCTAN: 'arctan'; -ARDEN: 'arden:'; -ARDEN_VERSION: 'version ' ('2' ('.' ( '1' | '2' | '5' | '6' | '7' | '8' | '9' | '10'))? | '3'); -ARETRUE: 'aretrue'; -ARGUMENT: 'argument'; -AS: 'as'; -AT: 'at'; -ATTIME: 'attime'; -ATTRIBUTE: 'attribute'; -AUTHOR: 'author:' -> mode(TextMode); -AVERAGE: 'average' | 'avg'; -BE: 'be'; -BEFORE: 'before'; -BOOLEAN: 'boolean'; -BREAKLOOP: 'breakloop'; -BY: 'by'; -CALL: 'call'; -CASE: 'case'; -CEILING: 'ceiling'; -CHARACTERS: 'characters'; -CITATIONS: 'citations:'; -CLONE: 'clone'; -CONCLUDE: 'conclude'; -COSINE: 'cos' 'ine'?; -COUNT: 'count'; -CRISP: 'crisp'; -CURRENTTIME: 'currenttime'; -DATA: 'data:'; -DATAWC: 'data'; -DATE: 'date:'; -DAY: 'day' 's'?; -DECREASE: 'decrease'; -DEFAULT: 'default'; -DEFAULTCO: 'default:' -> mode(TwoCharMode); -DEFUZZIFIED: 'defuzzified'; -DELAY: 'delay'; -DESTINATION: 'destination'; -DO: 'do'; -DURATION: 'duration'; -EARLIEST: 'earliest'; -ELEMENTS: 'elements'; -ELSE: 'else'; -ELSEIF: 'elseif'; -END: 'end:'; -ENDDO: 'enddo'; -ENDIF: 'endif'; -ENDSWITCH: 'endswitch'; -EQUAL: 'equal'; -EVENT: 'event'; -EVENTTIME: 'eventtime'; -EVERY: 'every'; -EVOKE: 'evoke:'; -EXIST: 'exist' 's'?; -EXP: 'exp'; -EXPLANATION: 'explanation:' -> mode(TextMode); -EXTRACT: 'extract'; -FALSE: 'false'; -FILENAME: 'filename:' -> mode(MlmName); -FIND: 'find'; -FIRST: 'first'; -FLOOR: 'floor'; -FOLLOWING: 'following'; -FOR: 'for'; -FORMATTED: 'formatted'; -FROM: 'from'; -FUZZIFIED: 'fuzzified'; -FUZZY: 'fuzzy'; -GREATER: 'greater'; -HOUR: 'hour' 's'?; -IF: 'if'; -IN: 'in'; -INCLUDE: 'include'; -INCREASE: 'increase'; -INDEX: 'index'; -INSTITUTION: 'institution:' -> mode(TextMode); -INSTITUTIONWC: 'institution'; -INT: 'int'; -INTERFACE: 'interface'; -INTERVAL: 'interval'; -IS: 'is' | 'are' | 'was' | 'were'; -ISTRUE: 'istrue'; -IT: 'it' | 'they'; -KEYWORDS: 'keywords' -> mode(TextMode); -KNOWLEDGE: 'knowledge:'; -LANGUAGE: 'language:' -> mode(TwoCharMode); -LAST: 'last'; -LATEST: 'latest'; -LEAST: 'least'; -LEFT: 'left'; -LENGTH: 'length'; -LESS: 'less'; -LET: 'let'; -LIBRARY: 'library:'; -LINGUISTIC: 'linguistic'; -LINKS: 'links:'; -LINK_TYPE: 'url_link' | 'mesh_link' | 'other_link' | 'exe_link'; -LIST: 'list'; -LOCALIZED: 'localized'; -LOG10: 'log10'; -LOG: 'log'; -LOGIC: 'logic:'; -LOWERCASE: 'lowercase'; -MAINTENANCE: 'maintenance:'; -MATCHES: 'matches'; -MAXIMUM: 'max' 'imum'?; -MEDIAN: 'median'; -MERGE: 'merge'; -MESSAGE: 'message'; -MINIMUM: 'min' 'imum'?; -MINUTE: 'minute' 's'?; -MLM: 'mlm'; -MLMNAME: 'mlmname:' -> mode(MlmName); -MLM_SELF: 'mlm'[_-]'self'; -MONTH: 'month' 's'?; -MOST: 'most'; -NAMES: 'names'; -NEAREST: 'nearest'; -NEW: 'new'; -NO: 'no'; -NOT: 'not'; -NOW: 'now'; -NULL: 'null'; -NUMBEROP: 'number'; -OBJECT: 'object'; -OCCUR: 'occur' ('s' | 'red')?; -OF: 'of'; -OR: 'or'; -PAST: 'past'; -PATTERN: 'pattern'; -PERCENT: 'percent' | '%'; -PRECEDING: 'preceding'; -PRESENT: 'present'; -PRIORITY: 'priority:'; -PURPOSE: 'purpose:' -> mode(TextMode); -READ: 'read'; -REMOVE: 'remove'; -REPLACE: 'replace'; -RESOURCES: 'resources:'; -RETURN: 'return'; -REVERSE: 'reverse'; -RIGHT: 'right'; -ROUND: 'round'; -SAME: 'same'; -SECOND: 'second' 's'?; -SEQTO: 'seqto'; -SET: 'set'; -SINE: 'sin' 'e'?; -SLOPE: 'slope'; -SORT: 'sort'; -SPECIALIST: 'specialist:' -> mode(TextMode); -SQRT: 'sqrt'; -STARTING: 'starting'; -STDDEV: 'stddev'; -STRINGOP: 'string'; -SUBLIST: 'sublist'; -SUBSTRING: 'substring'; -SUM: 'sum'; -SURROUNDING: 'surrounding'; -SWITCH: 'switch'; -TANGENT: 'tan' 'gent'?; -THAN: 'than'; -THE: 'the' -> channel(HIDDEN); -THEN: 'then'; -TIME: 'time'; -TITLE: 'title:' -> mode(TextMode); -TO: 'to'; -TODAY: 'today'; -TOMORROW: 'tomorrow'; -TRIGGERTIME: 'triggertime'; -TRIM: 'trim'; -TRUE: 'true'; -TRUNCATE: 'truncate'; -TRUTHVALUE: 'truth value'; -TYPE: 'type:'; -TYPE_CODE: 'data'[_-]'driven'; -UNTIL: 'until'; -UPPERCASE: 'uppercase'; -URGENCY: 'urgency:'; -USING: 'using'; -VALIDATION: 'validation:'; -VALIDATION_CODE:'production' | 'research' | 'testing' | 'expired'; -VARIABLE: 'variable'; -VARIANCE: 'variance'; -VERSION: 'version:' -> mode(TextMode); -WEEK: 'week' 's'?; -WEEKDAYLITERAL: 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday'; -WHERE: 'where'; -WHILE: 'while'; -WITH: 'with'; -WITHIN: 'within'; -WRITE: 'write'; -YEAR: 'year' 's'?; +ABS : 'abs'; +ACTION : 'action:'; +ADD : 'add'; +AFTER : 'after'; +AGGREGATE : 'aggregate'; +AGO : 'ago'; +ALL : 'all'; +AND : 'and'; +ANY : 'any'; +APPLICABILITY : 'applicability'; +ARCCOS : 'arccos'; +ARCSIN : 'arcsin'; +ARCTAN : 'arctan'; +ARDEN : 'arden:'; +ARDEN_VERSION : 'version ' ('2' ('.' ( '1' | '2' | '5' | '6' | '7' | '8' | '9' | '10'))? | '3'); +ARETRUE : 'aretrue'; +ARGUMENT : 'argument'; +AS : 'as'; +AT : 'at'; +ATTIME : 'attime'; +ATTRIBUTE : 'attribute'; +AUTHOR : 'author:' -> mode(TextMode); +AVERAGE : 'average' | 'avg'; +BE : 'be'; +BEFORE : 'before'; +BOOLEAN : 'boolean'; +BREAKLOOP : 'breakloop'; +BY : 'by'; +CALL : 'call'; +CASE : 'case'; +CEILING : 'ceiling'; +CHARACTERS : 'characters'; +CITATIONS : 'citations:'; +CLONE : 'clone'; +CONCLUDE : 'conclude'; +COSINE : 'cos' 'ine'?; +COUNT : 'count'; +CRISP : 'crisp'; +CURRENTTIME : 'currenttime'; +DATA : 'data:'; +DATAWC : 'data'; +DATE : 'date:'; +DAY : 'day' 's'?; +DECREASE : 'decrease'; +DEFAULT : 'default'; +DEFAULTCO : 'default:' -> mode(TwoCharMode); +DEFUZZIFIED : 'defuzzified'; +DELAY : 'delay'; +DESTINATION : 'destination'; +DO : 'do'; +DURATION : 'duration'; +EARLIEST : 'earliest'; +ELEMENTS : 'elements'; +ELSE : 'else'; +ELSEIF : 'elseif'; +END : 'end:'; +ENDDO : 'enddo'; +ENDIF : 'endif'; +ENDSWITCH : 'endswitch'; +EQUAL : 'equal'; +EVENT : 'event'; +EVENTTIME : 'eventtime'; +EVERY : 'every'; +EVOKE : 'evoke:'; +EXIST : 'exist' 's'?; +EXP : 'exp'; +EXPLANATION : 'explanation:' -> mode(TextMode); +EXTRACT : 'extract'; +FALSE : 'false'; +FILENAME : 'filename:' -> mode(MlmName); +FIND : 'find'; +FIRST : 'first'; +FLOOR : 'floor'; +FOLLOWING : 'following'; +FOR : 'for'; +FORMATTED : 'formatted'; +FROM : 'from'; +FUZZIFIED : 'fuzzified'; +FUZZY : 'fuzzy'; +GREATER : 'greater'; +HOUR : 'hour' 's'?; +IF : 'if'; +IN : 'in'; +INCLUDE : 'include'; +INCREASE : 'increase'; +INDEX : 'index'; +INSTITUTION : 'institution:' -> mode(TextMode); +INSTITUTIONWC : 'institution'; +INT : 'int'; +INTERFACE : 'interface'; +INTERVAL : 'interval'; +IS : 'is' | 'are' | 'was' | 'were'; +ISTRUE : 'istrue'; +IT : 'it' | 'they'; +KEYWORDS : 'keywords' -> mode(TextMode); +KNOWLEDGE : 'knowledge:'; +LANGUAGE : 'language:' -> mode(TwoCharMode); +LAST : 'last'; +LATEST : 'latest'; +LEAST : 'least'; +LEFT : 'left'; +LENGTH : 'length'; +LESS : 'less'; +LET : 'let'; +LIBRARY : 'library:'; +LINGUISTIC : 'linguistic'; +LINKS : 'links:'; +LINK_TYPE : 'url_link' | 'mesh_link' | 'other_link' | 'exe_link'; +LIST : 'list'; +LOCALIZED : 'localized'; +LOG10 : 'log10'; +LOG : 'log'; +LOGIC : 'logic:'; +LOWERCASE : 'lowercase'; +MAINTENANCE : 'maintenance:'; +MATCHES : 'matches'; +MAXIMUM : 'max' 'imum'?; +MEDIAN : 'median'; +MERGE : 'merge'; +MESSAGE : 'message'; +MINIMUM : 'min' 'imum'?; +MINUTE : 'minute' 's'?; +MLM : 'mlm'; +MLMNAME : 'mlmname:' -> mode(MlmName); +MLM_SELF : 'mlm' [_-]'self'; +MONTH : 'month' 's'?; +MOST : 'most'; +NAMES : 'names'; +NEAREST : 'nearest'; +NEW : 'new'; +NO : 'no'; +NOT : 'not'; +NOW : 'now'; +NULL : 'null'; +NUMBEROP : 'number'; +OBJECT : 'object'; +OCCUR : 'occur' ('s' | 'red')?; +OF : 'of'; +OR : 'or'; +PAST : 'past'; +PATTERN : 'pattern'; +PERCENT : 'percent' | '%'; +PRECEDING : 'preceding'; +PRESENT : 'present'; +PRIORITY : 'priority:'; +PURPOSE : 'purpose:' -> mode(TextMode); +READ : 'read'; +REMOVE : 'remove'; +REPLACE : 'replace'; +RESOURCES : 'resources:'; +RETURN : 'return'; +REVERSE : 'reverse'; +RIGHT : 'right'; +ROUND : 'round'; +SAME : 'same'; +SECOND : 'second' 's'?; +SEQTO : 'seqto'; +SET : 'set'; +SINE : 'sin' 'e'?; +SLOPE : 'slope'; +SORT : 'sort'; +SPECIALIST : 'specialist:' -> mode(TextMode); +SQRT : 'sqrt'; +STARTING : 'starting'; +STDDEV : 'stddev'; +STRINGOP : 'string'; +SUBLIST : 'sublist'; +SUBSTRING : 'substring'; +SUM : 'sum'; +SURROUNDING : 'surrounding'; +SWITCH : 'switch'; +TANGENT : 'tan' 'gent'?; +THAN : 'than'; +THE : 'the' -> channel(HIDDEN); +THEN : 'then'; +TIME : 'time'; +TITLE : 'title:' -> mode(TextMode); +TO : 'to'; +TODAY : 'today'; +TOMORROW : 'tomorrow'; +TRIGGERTIME : 'triggertime'; +TRIM : 'trim'; +TRUE : 'true'; +TRUNCATE : 'truncate'; +TRUTHVALUE : 'truth value'; +TYPE : 'type:'; +TYPE_CODE : 'data' [_-]'driven'; +UNTIL : 'until'; +UPPERCASE : 'uppercase'; +URGENCY : 'urgency:'; +USING : 'using'; +VALIDATION : 'validation:'; +VALIDATION_CODE : 'production' | 'research' | 'testing' | 'expired'; +VARIABLE : 'variable'; +VARIANCE : 'variance'; +VERSION : 'version:' -> mode(TextMode); +WEEK : 'week' 's'?; +WEEKDAYLITERAL: + 'sunday' + | 'monday' + | 'tuesday' + | 'wednesday' + | 'thursday' + | 'friday' + | 'saturday' +; +WHERE : 'where'; +WHILE : 'while'; +WITH : 'with'; +WITHIN : 'within'; +WRITE : 'write'; +YEAR : 'year' 's'?; // Seperators -LPAREN: '('; -RPAREN: ')'; -LBRACE: '{' -> mode(DataMapping); -RBRACE: '}'; -LBRACK: '['; -RBRACK: ']'; -SC: ';'; -DSC: ';;'; -COLON: ':'; -DOT: '.'; -COMMA: ','; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{' -> mode(DataMapping); +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SC : ';'; +DSC : ';;'; +COLON : ':'; +DOT : '.'; +COMMA : ','; // Operators -ASSIGN: ':='; -PLUS: '+'; -MINUS: '-'; -MUL: '*'; -DIV: '/'; -POWER: '**'; -EQ: '=' | 'eq'; -LT: '<' | 'lt'; -GT: '>' | 'gt'; -LE: '<=' | 'le'; -GE: '>=' | 'ge'; -NE: '<>' | 'ne'; -DOR: '||'; +ASSIGN : ':='; +PLUS : '+'; +MINUS : '-'; +MUL : '*'; +DIV : '/'; +POWER : '**'; +EQ : '=' | 'eq'; +LT : '<' | 'lt'; +GT : '>' | 'gt'; +LE : '<=' | 'le'; +GE : '>=' | 'ge'; +NE : '<>' | 'ne'; +DOR : '||'; // Digit constructs -NUMBER - : Digit+ DOT? Digit* Exponent - | DOT Digit+ Exponent - ; +NUMBER: Digit+ DOT? Digit* Exponent | DOT Digit+ Exponent; // Date constructs -TIMEOFDAY: Digit Digit COLON Digit Digit Seconds TimeZone; +TIMEOFDAY: Digit Digit COLON Digit Digit Seconds TimeZone; -ISO_DATE: Digit Digit Digit Digit MINUS Digit Digit MINUS Digit Digit; +ISO_DATE: Digit Digit Digit Digit MINUS Digit Digit MINUS Digit Digit; -ISO_DATE_TIME: Digit Digit Digit Digit MINUS Digit Digit MINUS Digit Digit 't' Digit Digit COLON Digit Digit COLON Digit Digit FractionalDigit TimeZone; +ISO_DATE_TIME: + Digit Digit Digit Digit MINUS Digit Digit MINUS Digit Digit 't' Digit Digit COLON Digit Digit COLON Digit Digit FractionalDigit TimeZone +; // String constructs -CITATION: Digit+ DOT ' ' ('support' | 'refute')?; +CITATION: Digit+ DOT ' ' ('support' | 'refute')?; -TERM: '\'' .*? '\''; +TERM: '\'' .*? '\''; -STRING: '"' ( '""' | ~'"' )* '"'; +STRING: '"' ( '""' | ~'"')* '"'; // Creates an identifier with max of 80 chars -IDENTIFIER - : StartIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier - ; +IDENTIFIER: + StartIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier RestIdentifier +; // Comment -COMMENT: '/*' .*? '*/' -> channel(HIDDEN); +COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); +LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); // Whitespace -WS: [ \t\r\n]+ -> channel(HIDDEN); +WS: [ \t\r\n]+ -> channel(HIDDEN); // Fragment rules // Digit fragments -fragment Digit - : [0-9] - ; +fragment Digit: [0-9]; -fragment FractionalDigit - : (DOT Digit+)? - ; +fragment FractionalDigit: (DOT Digit+)?; -fragment Exponent - : ('e' [+-]? Digit+)? - ; +fragment Exponent: ('e' [+-]? Digit+)?; // Date fragments -fragment Seconds - : (COLON Digit Digit FractionalDigit)? - ; +fragment Seconds: (COLON Digit Digit FractionalDigit)?; -fragment TimeZone - : 'z'? - | (PLUS | MINUS) Digit Digit COLON Digit Digit - ; +fragment TimeZone: 'z'? | (PLUS | MINUS) Digit Digit COLON Digit Digit; // String fragments -fragment Letter - : [a-z] - ; +fragment Letter: [a-z]; // Start of the identifier 10 chars, starting with a letter -fragment StartIdentifier - : Letter (ID (ID (ID (ID (ID (ID (ID (ID (ID?)?)?)?)?)?)?)?)?)? - ; +fragment StartIdentifier: Letter (ID (ID (ID (ID (ID (ID (ID (ID (ID?)?)?)?)?)?)?)?)?)?; // Rest of the identifier 10 chars -fragment RestIdentifier - : (ID (ID (ID (ID (ID (ID (ID (ID(ID (ID?)?)?)?)?)?)?)?)?)?)? - ; +fragment RestIdentifier: (ID (ID (ID (ID (ID (ID (ID (ID (ID (ID?)?)?)?)?)?)?)?)?)?)?; -fragment ID - : Letter | [0-9] | '_' - ; +fragment ID: Letter | [0-9] | '_'; -fragment MlmID - : ID | DOT | MINUS - ; +fragment MlmID: ID | DOT | MINUS; // Lexer modes mode TextMode; -TEXT: .+? ';;' -> mode(DEFAULT_MODE); +TEXT: .+? ';;' -> mode(DEFAULT_MODE); mode DataMapping; -DATA_MAPPING: (~'}' | '\\' .)+ -> mode(DEFAULT_MODE); +DATA_MAPPING: (~'}' | '\\' .)+ -> mode(DEFAULT_MODE); mode MlmName; -MLMID: MlmIDStart MlmIDRest MlmIDRest MlmIDRest MlmIDRest MlmIDRest MlmIDRest MlmIDRest -> mode(DEFAULT_MODE); +MLMID: + MlmIDStart MlmIDRest MlmIDRest MlmIDRest MlmIDRest MlmIDRest MlmIDRest MlmIDRest -> mode(DEFAULT_MODE) +; -WS_ID: [ \t\r\n]+ -> channel(HIDDEN); +WS_ID: [ \t\r\n]+ -> channel(HIDDEN); -fragment MlmIDStart - : Letter (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID?)?)?)?)?)?)?)?)?)? - ; -fragment MlmIDRest - : (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID?)?)?)?)?)?)?)?)?)?)? - ; +fragment MlmIDStart: + Letter (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID?)?)?)?)?)?)?)?)?)? +; +fragment MlmIDRest: + (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID (MlmID?)?)?)?)?)?)?)?)?)?)? +; mode TwoCharMode; -TWOCHARCODE options {caseInsensitive = false; }: Letter Letter ('_' [A-Z] [A-Z])? -> mode(DEFAULT_MODE); +TWOCHARCODE options { + caseInsensitive = false; +}: Letter Letter ('_' [A-Z] [A-Z])? -> mode(DEFAULT_MODE); -WS_TCM: WS -> channel(HIDDEN); \ No newline at end of file +WS_TCM: WS -> channel(HIDDEN); \ No newline at end of file diff --git a/arden/ArdenParser.g4 b/arden/ArdenParser.g4 index 26a572bf5d..b5ee4fb53f 100644 --- a/arden/ArdenParser.g4 +++ b/arden/ArdenParser.g4 @@ -29,833 +29,841 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $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 ArdenParser; +options { + tokenVocab = ArdenLexer; +} -options { tokenVocab = ArdenLexer; } // A mlm always consists of three parts and ends with the statement END: // These parts are maintenace_category, library_category, knowledge_category Ref: 5.1 file_ - : mlms EOF - ; + : mlms EOF + ; mlms - : mlm* - ; + : mlm* + ; mlm - : maintenanceCategory libraryCategory knowledgeCategory resourcesCategory END - ; + : maintenanceCategory libraryCategory knowledgeCategory resourcesCategory END + ; // Maintenace category Ref: 6.1 maintenanceCategory - : MAINTENANCE titleSlot mlmNameSlot ardenVersionSlot versionSlot institutionSlot authorSlot specialistSlot dateSlot validationSlot - ; + : MAINTENANCE titleSlot mlmNameSlot ardenVersionSlot versionSlot institutionSlot authorSlot specialistSlot dateSlot validationSlot + ; // Library category Ref: 6.2 libraryCategory - : LIBRARY purposeSlot explanationSlot keywordsSlot citationsSlot linksSlot - ; + : LIBRARY purposeSlot explanationSlot keywordsSlot citationsSlot linksSlot + ; // Knowledge category Ref 6.3 knowledgeCategory - : KNOWLEDGE typeSlot dataSlot prioritySlot evokeSlot logicSlot actionSlot urgencySlot - ; + : KNOWLEDGE typeSlot dataSlot prioritySlot evokeSlot logicSlot actionSlot urgencySlot + ; // Resource category Ref: 6.4 resourcesCategory - : (RESOURCES defaultSlot languageSlot)? - ; + : (RESOURCES defaultSlot languageSlot)? + ; // Slots // Maintenance slots titleSlot - : TITLE TEXT - ; + : TITLE TEXT + ; mlmNameSlot - : (MLMNAME | FILENAME) MLMID DSC - ; + : (MLMNAME | FILENAME) MLMID DSC + ; ardenVersionSlot - : (ARDEN ARDEN_VERSION DSC)? - ; + : (ARDEN ARDEN_VERSION DSC)? + ; versionSlot - : VERSION TEXT - ; + : VERSION TEXT + ; institutionSlot - : INSTITUTION TEXT - ; + : INSTITUTION TEXT + ; authorSlot - : AUTHOR TEXT - ; + : AUTHOR TEXT + ; specialistSlot - : SPECIALIST TEXT - ; + : SPECIALIST TEXT + ; dateSlot - : DATE (ISO_DATE | ISO_DATE_TIME) DSC - ; + : DATE (ISO_DATE | ISO_DATE_TIME) DSC + ; validationSlot - : VALIDATION VALIDATION_CODE DSC - ; + : VALIDATION VALIDATION_CODE DSC + ; // Library slots purposeSlot - : PURPOSE TEXT - ; + : PURPOSE TEXT + ; explanationSlot - : EXPLANATION TEXT - ; + : EXPLANATION TEXT + ; keywordsSlot - : KEYWORDS TEXT - ; + : KEYWORDS TEXT + ; citationsSlot - : (CITATIONS citationList DSC)? - ; + : (CITATIONS citationList DSC)? + ; citationList - : singleCitation? - | singleCitation SC citationList - ; + : singleCitation? + | singleCitation SC citationList + ; singleCitation - : CITATION? STRING - ; + : CITATION? STRING + ; linksSlot - : (LINKS linkList DSC)? - ; + : (LINKS linkList DSC)? + ; linkList - : singleLink? - | linkList SC singleLink - ; + : singleLink? + | linkList SC singleLink + ; singleLink - : (LINK_TYPE TERM)? STRING - ; + : (LINK_TYPE TERM)? STRING + ; // Knowledge slots typeSlot - : TYPE TYPE_CODE DSC - ; + : TYPE TYPE_CODE DSC + ; dataSlot - : DATA dataBlock DSC - ; + : DATA dataBlock DSC + ; prioritySlot - : (PRIORITY NUMBER DSC)? - ; + : (PRIORITY NUMBER DSC)? + ; evokeSlot - : EVOKE evokeBlock DSC - ; + : EVOKE evokeBlock DSC + ; logicSlot - : LOGIC logicBlock DSC - ; + : LOGIC logicBlock DSC + ; actionSlot - : ACTION actionBlock DSC - ; + : ACTION actionBlock DSC + ; urgencySlot - : (URGENCY (NUMBER | IDENTIFIER) DSC)? - ; + : (URGENCY (NUMBER | IDENTIFIER) DSC)? + ; // Resource slots defaultSlot - : DEFAULTCO TWOCHARCODE DSC - ; + : DEFAULTCO TWOCHARCODE DSC + ; languageSlot - : languageSlot singleLanguageCode - | singleLanguageCode - ; + : languageSlot singleLanguageCode + | singleLanguageCode + ; singleLanguageCode - : LANGUAGE TWOCHARCODE resourceTerms DSC - ; + : LANGUAGE TWOCHARCODE resourceTerms DSC + ; resourceTerms - : resourceTerms SC TERM COLON STRING - | (TERM COLON STRING)? - ; + : resourceTerms SC TERM COLON STRING + | (TERM COLON STRING)? + ; // Logic block logicBlock - : logicBlock SC logicStatement - | logicStatement - ; + : logicBlock SC logicStatement + | logicStatement + ; logicStatement - : logicAssignment? - | IF logicIfThenElse - | FOR IDENTIFIER IN expr DO logicBlock SC ENDDO - | WHILE expr DO logicBlock SC ENDDO - | logicSwitch - | BREAKLOOP - | CONCLUDE expr - ; + : logicAssignment? + | IF logicIfThenElse + | FOR IDENTIFIER IN expr DO logicBlock SC ENDDO + | WHILE expr DO logicBlock SC ENDDO + | logicSwitch + | BREAKLOOP + | CONCLUDE expr + ; logicIfThenElse - : expr THEN logicBlock SC logicElseIf - ; + : expr THEN logicBlock SC logicElseIf + ; logicElseIf - : ENDIF AGGREGATE? - | ELSE logicBlock SC ENDIF AGGREGATE? - | ELSEIF logicIfThenElse - ; + : ENDIF AGGREGATE? + | ELSE logicBlock SC ENDIF AGGREGATE? + | ELSEIF logicIfThenElse + ; logicAssignment - : identifierBecomes expr - | timeBecomes expr - | applicabilityBecomes expr - | identifierBecomes callPhrase - | (LPAREN dataVarList RPAREN ASSIGN | LET LPAREN dataVarList RPAREN BE) callPhrase - | identifierBecomes (newObjectPhrase | fuzzySetPhrase) - ; + : identifierBecomes expr + | timeBecomes expr + | applicabilityBecomes expr + | identifierBecomes callPhrase + | (LPAREN dataVarList RPAREN ASSIGN | LET LPAREN dataVarList RPAREN BE) callPhrase + | identifierBecomes (newObjectPhrase | fuzzySetPhrase) + ; exprFuzzySet - : fuzzySetPhrase - | expr - ; + : fuzzySetPhrase + | expr + ; identifierBecomes - : identifierOrObjectRef ASSIGN - | LET identifierOrObjectRef BE - | NOW ASSIGN - ; + : identifierOrObjectRef ASSIGN + | LET identifierOrObjectRef BE + | NOW ASSIGN + ; logicSwitch - : SWITCH IDENTIFIER COLON logicSwitchCases ENDSWITCH AGGREGATE? - ; + : SWITCH IDENTIFIER COLON logicSwitchCases ENDSWITCH AGGREGATE? + ; logicSwitchCases - : (CASE exprFactor logicBlock logicSwitchCases)? - | DEFAULT logicBlock - ; + : (CASE exprFactor logicBlock logicSwitchCases)? + | DEFAULT logicBlock + ; identifierOrObjectRef - : IDENTIFIER - | identifierOrObjectRef (LBRACK expr RBRACK | DOT identifierOrObjectRef) - ; + : IDENTIFIER + | identifierOrObjectRef (LBRACK expr RBRACK | DOT identifierOrObjectRef) + ; timeBecomes - : TIME OF? identifierOrObjectRef ASSIGN - | LET TIME OF? identifierOrObjectRef BE - ; + : TIME OF? identifierOrObjectRef ASSIGN + | LET TIME OF? identifierOrObjectRef BE + ; applicabilityBecomes - : APPLICABILITY OF? identifierOrObjectRef ASSIGN - | LET APPLICABILITY OF? identifierOrObjectRef BE - ; + : APPLICABILITY OF? identifierOrObjectRef ASSIGN + | LET APPLICABILITY OF? identifierOrObjectRef BE + ; callPhrase - : CALL IDENTIFIER (WITH expr)? - ; + : CALL IDENTIFIER (WITH expr)? + ; // Expressions expr - : exprSort - | expr COMMA exprSort - | COMMA exprSort - ; + : exprSort + | expr COMMA exprSort + | COMMA exprSort + ; exprSort - : exprAddList (MERGE exprSort)? - | SORT sortOption exprSort (USING exprFunction)? - | exprAddList MERGE exprSort USING exprFunction - ; + : exprAddList (MERGE exprSort)? + | SORT sortOption exprSort (USING exprFunction)? + | exprAddList MERGE exprSort USING exprFunction + ; sortOption - : DATAWC? - | TIME - | APPLICABILITY - ; + : DATAWC? + | TIME + | APPLICABILITY + ; exprAddList - : exprRemoveList - | ADD exprWhere TO exprWhere (AT exprWhere)? - ; + : exprRemoveList + | ADD exprWhere TO exprWhere (AT exprWhere)? + ; exprRemoveList - : exprWhere - | REMOVE exprWhere FROM exprWhere - ; + : exprWhere + | REMOVE exprWhere FROM exprWhere + ; exprWhere - : exprRange (WHERE exprRange)? - ; + : exprRange (WHERE exprRange)? + ; exprRange - : exprOr (SEQTO exprOr)? - ; + : exprOr (SEQTO exprOr)? + ; exprOr - : exprOr OR exprAnd - | exprAnd - ; + : exprOr OR exprAnd + | exprAnd + ; exprAnd - : exprAnd AND exprNot - | exprNot - ; + : exprAnd AND exprNot + | exprNot + ; exprNot - : NOT? exprComparison - ; + : NOT? exprComparison + ; exprComparison - : exprString - | exprFindString - | exprString singleCompOp exprString - | exprString IS? NOT? (mainCompOp | inCompOp) - | exprString OCCUR NOT? (temporalCompOp | rangeCompOp) - | exprString MATCHES PATTERN exprString - ; + : exprString + | exprFindString + | exprString singleCompOp exprString + | exprString IS? NOT? (mainCompOp | inCompOp) + | exprString OCCUR NOT? (temporalCompOp | rangeCompOp) + | exprString MATCHES PATTERN exprString + ; exprFindString - : FIND exprString IN? STRINGOP exprString stringSearchStart - ; + : FIND exprString IN? STRINGOP exprString stringSearchStart + ; exprString - : exprPlus - | exprString ('||' | FORMATTED WITH) exprPlus - | TRIM trimOption exprString - | caseOption exprString - | SUBSTRING exprPlus CHARACTERS stringSearchStart FROM exprString - ; + : exprPlus + | exprString ('||' | FORMATTED WITH) exprPlus + | TRIM trimOption exprString + | caseOption exprString + | SUBSTRING exprPlus CHARACTERS stringSearchStart FROM exprString + ; trimOption - : LEFT? - | RIGHT - ; + : LEFT? + | RIGHT + ; caseOption - : UPPERCASE - | LOWERCASE - ; + : UPPERCASE + | LOWERCASE + ; stringSearchStart - : (STARTING AT exprPlus)? - ; + : (STARTING AT exprPlus)? + ; exprPlus - : exprTimes - | exprPlus (PLUS | MINUS) exprTimes - | (PLUS | MINUS) exprTimes - ; + : exprTimes + | exprPlus (PLUS | MINUS) exprTimes + | (PLUS | MINUS) exprTimes + ; exprTimes - : exprPower - | exprTimes (MUL | DIV) exprPower - ; + : exprPower + | exprTimes (MUL | DIV) exprPower + ; exprPower - : exprAtTime - | exprFunction POWER exprFunction - ; + : exprAtTime + | exprFunction POWER exprFunction + ; exprAtTime - : exprBefore (ATTIME exprAtTime)? - ; + : exprBefore (ATTIME exprAtTime)? + ; exprBefore - : exprAgo - | exprDuration (BEFORE | AFTER | FROM) exprAgo - ; + : exprAgo + | exprDuration (BEFORE | AFTER | FROM) exprAgo + ; exprAgo - : exprDuration AGO? - ; + : exprDuration AGO? + ; exprDuration - : exprFunction durationOp? - ; + : exprFunction durationOp? + ; exprFunction - : exprFactor - | ofFuncOp OF? exprFunction - | fromOfFuncOp OF? exprFunction - | fromOfFuncOp exprFactor FROM exprFunction - | REPLACE timePart OF? exprFunction WITH exprFactor - | fromOfFuncOp OF? exprFunction USING exprFunction - | fromOfFuncOp exprFactor FROM exprFunction USING exprFunction - | fromFuncOp exprFactor FROM exprFunction - | indexFromOfFuncOp OF? exprFunction - | indexFromOfFuncOp exprFactor FROM exprFunction - | atLeastMostOp exprFactor (ISTRUE | ARETRUE)? FROM exprFunction - | (INDEX OF | indexFromFuncOp) exprFactor FROM exprFunction - | exprFactor AS asFuncOp - | exprAttributeFrom - | exprSubListFrom - ; + : exprFactor + | ofFuncOp OF? exprFunction + | fromOfFuncOp OF? exprFunction + | fromOfFuncOp exprFactor FROM exprFunction + | REPLACE timePart OF? exprFunction WITH exprFactor + | fromOfFuncOp OF? exprFunction USING exprFunction + | fromOfFuncOp exprFactor FROM exprFunction USING exprFunction + | fromFuncOp exprFactor FROM exprFunction + | indexFromOfFuncOp OF? exprFunction + | indexFromOfFuncOp exprFactor FROM exprFunction + | atLeastMostOp exprFactor (ISTRUE | ARETRUE)? FROM exprFunction + | (INDEX OF | indexFromFuncOp) exprFactor FROM exprFunction + | exprFactor AS asFuncOp + | exprAttributeFrom + | exprSubListFrom + ; exprAttributeFrom - : ATTRIBUTE exprFactor FROM exprFactor - ; + : ATTRIBUTE exprFactor FROM exprFactor + ; exprSubListFrom - : SUBLIST exprFactor ELEMENTS (STARTING AT exprFactor)? FROM exprFactor - ; + : SUBLIST exprFactor ELEMENTS (STARTING AT exprFactor)? FROM exprFactor + ; exprFactor - : exprFactorAtom (LBRACK expr RBRACK)? - | exprFactor DOT IDENTIFIER - ; + : exprFactorAtom (LBRACK expr RBRACK)? + | exprFactor DOT IDENTIFIER + ; exprFactorAtom - : IDENTIFIER - | NUMBER - | string - | timeValue - | booleanValue - | WEEKDAYLITERAL - | TODAY - | TOMORROW - | NULL - | CONCLUDE - | IT - | LPAREN (expr | exprFuzzySet)? RPAREN - ; + : IDENTIFIER + | NUMBER + | string + | timeValue + | booleanValue + | WEEKDAYLITERAL + | TODAY + | TOMORROW + | NULL + | CONCLUDE + | IT + | LPAREN (expr | exprFuzzySet)? RPAREN + ; singleCompOp - : EQ - | LT - | GT - | LE - | GE - | NE - ; + : EQ + | LT + | GT + | LE + | GE + | NE + ; mainCompOp - : temporalCompOp - | rangeCompOp - | unaryCompOp - | binaryCompOp exprString - ; + : temporalCompOp + | rangeCompOp + | unaryCompOp + | binaryCompOp exprString + ; rangeCompOp - : WITHIN exprString TO exprString - ; + : WITHIN exprString TO exprString + ; temporalCompOp - : WITHIN exprString (PRECEDING | FOLLOWING | SURROUNDING) exprString - | WITHIN (PAST | SAME DAY AS) exprString - | (BEFORE | AFTER | EQUAL) exprString - | AT exprString - ; + : WITHIN exprString (PRECEDING | FOLLOWING | SURROUNDING) exprString + | WITHIN (PAST | SAME DAY AS) exprString + | (BEFORE | AFTER | EQUAL) exprString + | AT exprString + ; unaryCompOp - : PRESENT - | NULL - | BOOLEAN - | TRUTHVALUE - | CRISP - | FUZZY - | NUMBEROP - | TIME - | DURATION - | STRINGOP - | LIST - | OBJECT - | LINGUISTIC VARIABLE - | IDENTIFIER - | TIME OF DAY - ; + : PRESENT + | NULL + | BOOLEAN + | TRUTHVALUE + | CRISP + | FUZZY + | NUMBEROP + | TIME + | DURATION + | STRINGOP + | LIST + | OBJECT + | LINGUISTIC VARIABLE + | IDENTIFIER + | TIME OF DAY + ; binaryCompOp - : (LESS | GREATER) THAN (OR EQUAL)? - | IN - ; + : (LESS | GREATER) THAN (OR EQUAL)? + | IN + ; ofFuncOp - : ofReadFuncOp - | ofNoreadFuncOp - ; + : ofReadFuncOp + | ofNoreadFuncOp + ; inCompOp - : IN exprString - ; + : IN exprString + ; ofReadFuncOp - : AVERAGE - | COUNT - | EXIST - | SUM - | MEDIAN - ; + : AVERAGE + | COUNT + | EXIST + | SUM + | MEDIAN + ; ofNoreadFuncOp - : ANY ISTRUE? - | ALL ARETRUE? - | NO ISTRUE? - | SLOPE - | STDDEV - | VARIANCE - | INCREASE - | PERCENT? (INCREASE | DECREASE) - | INTERVAL - | TIME (OF DAY)? - | DAY OF WEEK - | ARCCOS - | ARCSIN - | ARCTAN - | COSINE - | SINE - | TANGENT - | EXP - | FLOOR - | INT - | ROUND - | CEILING - | TRUNCATE - | LOG - | LOG10 - | ABS - | SQRT - | EXTRACT (YEAR | MONTH | DAY | HOUR | MINUTE | SECOND | TIME OF DAY) - | STRINGOP - | EXTRACT CHARACTERS - | REVERSE - | LENGTH - | CLONE - | EXTRACT ATTRIBUTE NAMES - | APPLICABILITY - | DEFUZZIFIED - ; + : ANY ISTRUE? + | ALL ARETRUE? + | NO ISTRUE? + | SLOPE + | STDDEV + | VARIANCE + | INCREASE + | PERCENT? (INCREASE | DECREASE) + | INTERVAL + | TIME (OF DAY)? + | DAY OF WEEK + | ARCCOS + | ARCSIN + | ARCTAN + | COSINE + | SINE + | TANGENT + | EXP + | FLOOR + | INT + | ROUND + | CEILING + | TRUNCATE + | LOG + | LOG10 + | ABS + | SQRT + | EXTRACT (YEAR | MONTH | DAY | HOUR | MINUTE | SECOND | TIME OF DAY) + | STRINGOP + | EXTRACT CHARACTERS + | REVERSE + | LENGTH + | CLONE + | EXTRACT ATTRIBUTE NAMES + | APPLICABILITY + | DEFUZZIFIED + ; fromFuncOp - : NEAREST - ; + : NEAREST + ; indexFromFuncOp - : INDEX NEAREST - ; + : INDEX NEAREST + ; fromOfFuncOp - : MINIMUM - | MAXIMUM - | LAST - | FIRST - | EARLIEST - | LATEST - ; + : MINIMUM + | MAXIMUM + | LAST + | FIRST + | EARLIEST + | LATEST + ; indexFromOfFuncOp - : INDEX (MINIMUM | MAXIMUM | EARLIEST | LATEST) - ; + : INDEX (MINIMUM | MAXIMUM | EARLIEST | LATEST) + ; asFuncOp - : NUMBEROP - | TIME - | STRINGOP - | TRUTHVALUE - ; + : NUMBEROP + | TIME + | STRINGOP + | TRUTHVALUE + ; atLeastMostOp - : AT (LEAST | MOST) - ; + : AT (LEAST | MOST) + ; durationOp - : YEAR - | MONTH - | WEEK - | DAY - | HOUR - | MINUTE - | SECOND - ; + : YEAR + | MONTH + | WEEK + | DAY + | HOUR + | MINUTE + | SECOND + ; timePart - : YEAR - | MONTH - | DAY - | HOUR - | MINUTE - | SECOND - ; + : YEAR + | MONTH + | DAY + | HOUR + | MINUTE + | SECOND + ; // Factors string - : STRING - | LOCALIZED TERM localizeOption - ; + : STRING + | LOCALIZED TERM localizeOption + ; localizeOption - : (BY STRING)? - | BY IDENTIFIER - ; + : (BY STRING)? + | BY IDENTIFIER + ; booleanValue - : TRUTHVALUE? (TRUE | FALSE) - | TRUTHVALUE NUMBER - ; + : TRUTHVALUE? (TRUE | FALSE) + | TRUTHVALUE NUMBER + ; timeValue - : NOW - | ISO_DATE_TIME - | ISO_DATE - | EVENTTIME - | TRIGGERTIME - | CURRENTTIME - | TIMEOFDAY - ; + : NOW + | ISO_DATE_TIME + | ISO_DATE + | EVENTTIME + | TRIGGERTIME + | CURRENTTIME + | TIMEOFDAY + ; // Data block dataBlock - : dataBlock SC dataStatement - | dataStatement - ; + : dataBlock SC dataStatement + | dataStatement + ; dataStatement - : dataAssignment? - | IF dataIfThenElse - | FOR IDENTIFIER IN expr DO dataBlock SC ENDDO - | WHILE expr DO dataBlock SC ENDDO - | dataSwitch - | BREAKLOOP - | INCLUDE IDENTIFIER - ; + : dataAssignment? + | IF dataIfThenElse + | FOR IDENTIFIER IN expr DO dataBlock SC ENDDO + | WHILE expr DO dataBlock SC ENDDO + | dataSwitch + | BREAKLOOP + | INCLUDE IDENTIFIER + ; dataIfThenElse - : expr THEN dataBlock SC dataElseIf - ; + : expr THEN dataBlock SC dataElseIf + ; dataElseIf - : ENDIF AGGREGATE? - | ELSE dataBlock SC ENDIF AGGREGATE? - | ELSEIF dataIfThenElse - ; + : ENDIF AGGREGATE? + | ELSE dataBlock SC ENDIF AGGREGATE? + | ELSEIF dataIfThenElse + ; dataSwitch - : SWITCH IDENTIFIER COLON dataSwitchCases ENDSWITCH AGGREGATE? - ; + : SWITCH IDENTIFIER COLON dataSwitchCases ENDSWITCH AGGREGATE? + ; dataSwitchCases - : (CASE exprFactor dataBlock dataSwitchCases)? - | DEFAULT dataBlock - ; + : (CASE exprFactor dataBlock dataSwitchCases)? + | DEFAULT dataBlock + ; dataAssignment - : identifierBecomes dataAssignPhrase - | timeBecomes expr - | applicabilityBecomes expr - | (LPAREN dataVarList RPAREN ASSIGN | LET LPAREN dataVarList RPAREN BE) (READ (AS IDENTIFIER)? readPhrase | ARGUMENT) - ; + : identifierBecomes dataAssignPhrase + | timeBecomes expr + | applicabilityBecomes expr + | (LPAREN dataVarList RPAREN ASSIGN | LET LPAREN dataVarList RPAREN BE) ( + READ (AS IDENTIFIER)? readPhrase + | ARGUMENT + ) + ; dataVarList - : identifierOrObjectRef (COMMA dataVarList)? - ; + : identifierOrObjectRef (COMMA dataVarList)? + ; dataAssignPhrase - : READ (AS IDENTIFIER)? readPhrase - | MLM (TERM (FROM INSTITUTIONWC string)? | MLM_SELF) - | (INTERFACE | EVENT | MESSAGE) mappingFactor - | MESSAGE AS IDENTIFIER mappingFactor? - | DESTINATION (mappingFactor AS IDENTIFIER mappingFactor?) - | ARGUMENT - | OBJECT objectDefinition - | LINGUISTIC VARIABLE objectDefinition - | callPhrase - | newObjectPhrase - | fuzzySetPhrase - | expr - ; + : READ (AS IDENTIFIER)? readPhrase + | MLM (TERM (FROM INSTITUTIONWC string)? | MLM_SELF) + | (INTERFACE | EVENT | MESSAGE) mappingFactor + | MESSAGE AS IDENTIFIER mappingFactor? + | DESTINATION (mappingFactor AS IDENTIFIER mappingFactor?) + | ARGUMENT + | OBJECT objectDefinition + | LINGUISTIC VARIABLE objectDefinition + | callPhrase + | newObjectPhrase + | fuzzySetPhrase + | expr + ; fuzzySetPhrase - : FUZZY SET fuzzySetInitList - | exprDuration FUZZIFIED BY exprDuration - | exprFactor FUZZIFIED BY exprFactor - ; + : FUZZY SET fuzzySetInitList + | exprDuration FUZZIFIED BY exprDuration + | exprFactor FUZZIFIED BY exprFactor + ; fuzzySetInitList - : fuzzySetInitElement - | fuzzySetInitList COMMA fuzzySetInitElement - ; + : fuzzySetInitElement + | fuzzySetInitList COMMA fuzzySetInitElement + ; fuzzySetInitElement - : LPAREN fuzzySetInitFactor COMMA exprFactor RPAREN - ; + : LPAREN fuzzySetInitFactor COMMA exprFactor RPAREN + ; fuzzySetInitFactor - : exprFactor - | NUMBER durationOp - ; + : exprFactor + | NUMBER durationOp + ; readPhrase - : readWhere - | ofReadFuncOp OF? readWhere - | fromOfFuncOp OF? readWhere - | fromOfFuncOp exprFactor FROM readWhere - ; + : readWhere + | ofReadFuncOp OF? readWhere + | fromOfFuncOp OF? readWhere + | fromOfFuncOp exprFactor FROM readWhere + ; readWhere - : mappingFactor (WHERE IT OCCUR NOT? (temporalCompOp | rangeCompOp))? - | LPAREN readWhere RPAREN - ; + : mappingFactor (WHERE IT OCCUR NOT? (temporalCompOp | rangeCompOp))? + | LPAREN readWhere RPAREN + ; mappingFactor - : LBRACE DATA_MAPPING RBRACE - ; + : LBRACE DATA_MAPPING RBRACE + ; objectDefinition - : LBRACK objectAttributeList RBRACK - ; + : LBRACK objectAttributeList RBRACK + ; objectAttributeList - : IDENTIFIER (COMMA objectAttributeList)? - ; + : IDENTIFIER (COMMA objectAttributeList)? + ; newObjectPhrase - : NEW IDENTIFIER (WITH (expr | (expr WITH)? LBRACK objectInitList RBRACK))? - ; + : NEW IDENTIFIER (WITH (expr | (expr WITH)? LBRACK objectInitList RBRACK))? + ; objectInitList - : objectInitElement - | objectInitList COMMA objectInitElement - ; + : objectInitElement + | objectInitList COMMA objectInitElement + ; objectInitElement - : IDENTIFIER ASSIGN expr - ; + : IDENTIFIER ASSIGN expr + ; // Evoke block evokeBlock - : evokeStatement - | evokeBlock SC evokeStatement - ; + : evokeStatement + | evokeBlock SC evokeStatement + ; evokeStatement - : eventOr? - | evokeTime - | delayedEvoke - | qualifiedEvokeCycle - | CALL - ; + : eventOr? + | evokeTime + | delayedEvoke + | qualifiedEvokeCycle + | CALL + ; eventList - : eventOr - | eventList COMMA eventOr - ; + : eventOr + | eventList COMMA eventOr + ; eventOr - : eventOr OR eventAny - | eventAny - ; + : eventOr OR eventAny + | eventAny + ; eventAny - : ANY OF? (LPAREN eventList RPAREN | IDENTIFIER) - | eventFactor - ; + : ANY OF? (LPAREN eventList RPAREN | IDENTIFIER) + | eventFactor + ; eventFactor - : LPAREN eventOr RPAREN - | IDENTIFIER - ; + : LPAREN eventOr RPAREN + | IDENTIFIER + ; delayedEvoke - : evokeTimeExprOr (AFTER eventTime)? - | evokeDuration AFTER evokeTimeOr - ; + : evokeTimeExprOr (AFTER eventTime)? + | evokeDuration AFTER evokeTimeOr + ; eventTime - : TIME OF? eventAny - ; + : TIME OF? eventAny + ; evokeTimeOr - : evokeTime - | evokeTime OR evokeTimeOr - ; + : evokeTime + | evokeTime OR evokeTimeOr + ; evokeTimeExprOr - : evokeTimeExpr - | evokeTimeExpr OR evokeTimeExprOr - ; + : evokeTimeExpr + | evokeTimeExpr OR evokeTimeExprOr + ; evokeTimeExpr - : evokeDuration - | evokeTime - ; + : evokeDuration + | evokeTime + ; evokeTime - : ISO_DATE_TIME - | ISO_DATE - | relativeEvokeTimeExpr - ; + : ISO_DATE_TIME + | ISO_DATE + | relativeEvokeTimeExpr + ; evokeDuration - : NUMBER durationOp - ; + : NUMBER durationOp + ; relativeEvokeTimeExpr - : (TODAY | TOMORROW | WEEKDAYLITERAL) ATTIME TIMEOFDAY - ; + : (TODAY | TOMORROW | WEEKDAYLITERAL) ATTIME TIMEOFDAY + ; qualifiedEvokeCycle - : simpleEvokeCycle (UNTIL expr)? - ; + : simpleEvokeCycle (UNTIL expr)? + ; simpleEvokeCycle - : EVERY evokeDuration FOR evokeDuration STARTING startingDelay - ; + : EVERY evokeDuration FOR evokeDuration STARTING startingDelay + ; startingDelay - : eventTime - | delayedEvoke - ; + : eventTime + | delayedEvoke + ; // Action block actionBlock - : actionStatement - | actionBlock SC actionStatement - ; + : actionStatement + | actionBlock SC actionStatement + ; actionStatement - : (IF actionIfThenElse)? - | FOR IDENTIFIER IN expr DO actionBlock SC ENDDO - | WHILE expr DO actionBlock SC ENDDO - | actionSwitch - | BREAKLOOP - | callPhrase (DELAY expr)? - | WRITE expr (AT IDENTIFIER)? - | RETURN expr - | identifierBecomes expr - | timeBecomes expr - | applicabilityBecomes expr - | identifierBecomes newObjectPhrase - ; + : (IF actionIfThenElse)? + | FOR IDENTIFIER IN expr DO actionBlock SC ENDDO + | WHILE expr DO actionBlock SC ENDDO + | actionSwitch + | BREAKLOOP + | callPhrase (DELAY expr)? + | WRITE expr (AT IDENTIFIER)? + | RETURN expr + | identifierBecomes expr + | timeBecomes expr + | applicabilityBecomes expr + | identifierBecomes newObjectPhrase + ; actionIfThenElse - : expr THEN actionBlock SC actionElseIf - ; + : expr THEN actionBlock SC actionElseIf + ; actionElseIf - : ENDIF AGGREGATE? - | ELSE actionBlock SC ENDIF AGGREGATE? - | ELSEIF actionIfThenElse - ; + : ENDIF AGGREGATE? + | ELSE actionBlock SC ENDIF AGGREGATE? + | ELSEIF actionIfThenElse + ; actionSwitch - : SWITCH IDENTIFIER COLON actionSwitchCases ENDSWITCH AGGREGATE? - ; + : SWITCH IDENTIFIER COLON actionSwitchCases ENDSWITCH AGGREGATE? + ; actionSwitchCases - : (CASE exprFactor actionBlock actionSwitchCases)? - | DEFAULT actionBlock - ; - + : (CASE exprFactor actionBlock actionSwitchCases)? + | DEFAULT actionBlock + ; \ No newline at end of file diff --git a/argus/argus.g4 b/argus/argus.g4 index 85379a5f20..7bd176700e 100644 --- a/argus/argus.g4 +++ b/argus/argus.g4 @@ -29,400 +29,405 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar argus; file_ - : module EOF - ; + : module EOF + ; module - : equate* equates_ - | equate* guardian - | equate* procedure - | equate* iterator - | equate* cluster - ; + : equate* equates_ + | equate* guardian + | equate* procedure + | equate* iterator + | equate* cluster + ; equates_ - : idn '=' 'equates' (parms where?)? equate* 'end' idn - ; + : idn '=' 'equates' (parms where?)? equate* 'end' idn + ; guardian - : idn '=' 'guardian' parms? 'is' idn (',' idn)* ('handles' idn (',' idn)*)? where? equate* state_decl* ('recover' body 'end')? ('background' body 'end')? operation* creator operation* 'end' idn - ; + : idn '=' 'guardian' parms? 'is' idn (',' idn)* ('handles' idn (',' idn)*)? where? equate* state_decl* ( + 'recover' body 'end' + )? ('background' body 'end')? operation* creator operation* 'end' idn + ; cluster - : idn '=' 'cluster' parms? 'is' opidn (',' opidn)*? where? equate* 'rep' '=' type_spec equate* own_var* routine routine* 'end' idn - ; + : idn '=' 'cluster' parms? 'is' opidn (',' opidn)*? where? equate* 'rep' '=' type_spec equate* own_var* routine routine* 'end' idn + ; operation - : creator - | handler - | routine - ; + : creator + | handler + | routine + ; routine - : procedure - | iterator - ; + : procedure + | iterator + ; procedure - : idn '=' 'proc' parms? args returnz? signals? where? routine_body 'end' idn - ; + : idn '=' 'proc' parms? args returnz? signals? where? routine_body 'end' idn + ; iterator - : idn '=' 'iter' parms? args yields? signals? where? routine_body 'end' idn - ; + : idn '=' 'iter' parms? args yields? signals? where? routine_body 'end' idn + ; creator - : idn '=' 'creator' args returnz? signals? routine_body 'end' idn - ; + : idn '=' 'creator' args returnz? signals? routine_body 'end' idn + ; handler - : idn '=' 'handler' args returnz? signals? routine_body 'end' idn - ; + : idn '=' 'handler' args returnz? signals? routine_body 'end' idn + ; routine_body - : equate* own_var* statement* - ; + : equate* own_var* statement* + ; parms - : parm (',' parm)* - ; + : parm (',' parm)* + ; parm - : idn (',' idn)* ':' 'type' - | idn (',' idn)* ':' type_spec - ; + : idn (',' idn)* ':' 'type' + | idn (',' idn)* ':' type_spec + ; args - : '(' (decl (',' decl)*)* ')' - ; + : '(' (decl (',' decl)*)* ')' + ; decl - : idn (',' idn)* ':' type_spec - ; + : idn (',' idn)* ':' type_spec + ; returnz - : 'returns' '(' type_spec (',' type_spec)* ')' - ; + : 'returns' '(' type_spec (',' type_spec)* ')' + ; yields - : 'yields' '(' type_spec (',' type_spec)* ')' - ; + : 'yields' '(' type_spec (',' type_spec)* ')' + ; signals - : 'signals' '(' exception_ (',' exception_)* ')' - ; + : 'signals' '(' exception_ (',' exception_)* ')' + ; exception_ - : name (type_spec (',' type_spec)*)? - ; + : name (type_spec (',' type_spec)*)? + ; opidn - : idn - | 'transmit' - ; + : idn + | 'transmit' + ; where - : 'where' restriction (',' restriction)* - ; + : 'where' restriction (',' restriction)* + ; restriction - : idn 'has' oper_decl (',' oper_decl)* - | idn 'in' type_set - ; + : idn 'has' oper_decl (',' oper_decl)* + | idn 'in' type_set + ; type_set - : (idn | idn 'has' oper_decl (',' oper_decl)* equate*)* - | idn - | reference '$' name - ; + : (idn | idn 'has' oper_decl (',' oper_decl)* equate*)* + | idn + | reference '$' name + ; oper_decl - : name (',' name)* ':' type_spec - | 'transmit' - ; + : name (',' name)* ':' type_spec + | 'transmit' + ; constant - : expression - | type_spec - ; + : expression + | type_spec + ; state_decl - : 'stable'? decl - | 'stable'? idn ':' type_spec ':=' expression - | 'stable'? decl (',' decl)* ':=' call - ; + : 'stable'? decl + | 'stable'? idn ':' type_spec ':=' expression + | 'stable'? decl (',' decl)* ':=' call + ; equate - : idn '=' constant - | idn '=' type_set - | idn '=' reference - ; + : idn '=' constant + | idn '=' type_set + | idn '=' reference + ; own_var - : 'own' decl - | 'own' idn ':' type_spec ':=' expression - | 'own' decl (',' decl)* ':=' call ('@' primaries)? - ; + : 'own' decl + | 'own' idn ':' type_spec ':=' expression + | 'own' decl (',' decl)* ':=' call ('@' primaries)? + ; statement - : decl - | idn ':' type_spec ':=' expression - | decl (',' decl)* ':=' call ('@' primaries)? - | idn (',' idn)* ':=' call ('@' primaries)? - | idn (',' idn)* ':=' expression (',' expression)* - | primaries '.' name ':=' expression - | primaries expression? ':=' expression - | call ('@' primaries)? - | 'fork' call - | 'seize' expression 'do' body 'end' - | 'pause' - | 'terminate' - | enter_stmt - | 'coenter' coarm coarm* 'end' - | 'abort'? 'leave' - | 'while' expression 'do' body 'end' - | for_stmt - | if_stmt - | tagcase_stmt - | tagtest_stmt - | tagwait_stmt - | 'abort'? 'return' (expression (',' expression)*)? - | 'yield' (expression (',' expression)*)? - | 'abort'? 'signal' name (expression (',' expression)*)? - | 'abort'? 'exit' name (expression (',' expression)*)? - | 'abort'? 'break' - | 'abort'? 'continue' - | 'begin' body 'end' - | statement 'abort'? 'resignal' name (',' name)* - | statement 'except' when_handler* others_handler? 'end' - ; + : decl + | idn ':' type_spec ':=' expression + | decl (',' decl)* ':=' call ('@' primaries)? + | idn (',' idn)* ':=' call ('@' primaries)? + | idn (',' idn)* ':=' expression (',' expression)* + | primaries '.' name ':=' expression + | primaries expression? ':=' expression + | call ('@' primaries)? + | 'fork' call + | 'seize' expression 'do' body 'end' + | 'pause' + | 'terminate' + | enter_stmt + | 'coenter' coarm coarm* 'end' + | 'abort'? 'leave' + | 'while' expression 'do' body 'end' + | for_stmt + | if_stmt + | tagcase_stmt + | tagtest_stmt + | tagwait_stmt + | 'abort'? 'return' (expression (',' expression)*)? + | 'yield' (expression (',' expression)*)? + | 'abort'? 'signal' name (expression (',' expression)*)? + | 'abort'? 'exit' name (expression (',' expression)*)? + | 'abort'? 'break' + | 'abort'? 'continue' + | 'begin' body 'end' + | statement 'abort'? 'resignal' name (',' name)* + | statement 'except' when_handler* others_handler? 'end' + ; enter_stmt - : 'enter' 'topaction' body 'end' - | 'enter' 'action' body 'end' - ; + : 'enter' 'topaction' body 'end' + | 'enter' 'action' body 'end' + ; coarm - : armtag ('foreach' decl (',' decl)* 'in' call)* body - ; + : armtag ('foreach' decl (',' decl)* 'in' call)* body + ; armtag - : 'action' - | 'topaction' - | 'process' - ; + : 'action' + | 'topaction' + | 'process' + ; for_stmt - : 'for' decl (',' decl)* 'in' call 'do' body 'end' - | 'for' idn (',' idn)* 'in' call 'do' body 'end' - ; + : 'for' decl (',' decl)* 'in' call 'do' body 'end' + | 'for' idn (',' idn)* 'in' call 'do' body 'end' + ; if_stmt - : 'if' expression 'then' body ('elseif' expression 'then' body)* ('else' body)? 'end' - ; + : 'if' expression 'then' body ('elseif' expression 'then' body)* ('else' body)? 'end' + ; tagcase_stmt - : 'tagcase' expression tag_arm tag_arm* ('others' ':' body)? 'end' - ; + : 'tagcase' expression tag_arm tag_arm* ('others' ':' body)? 'end' + ; tagtest_stmt - : 'tagtest' expression atag_arm atag_arm* ('others' ':' body)? 'end' - ; + : 'tagtest' expression atag_arm atag_arm* ('others' ':' body)? 'end' + ; tagwait_stmt - : 'tagwait' expression atag_arm atag_arm* 'end' - ; + : 'tagwait' expression atag_arm atag_arm* 'end' + ; tag_arm - : 'tag' name (',' name)* (idn ':' type_spec)? ':' body - ; + : 'tag' name (',' name)* (idn ':' type_spec)? ':' body + ; atag_arm - : tag_kind name (',' name)* (idn ':' type_spec)* ':' body - ; + : tag_kind name (',' name)* (idn ':' type_spec)* ':' body + ; tag_kind - : 'tag' - | 'wtag' - ; + : 'tag' + | 'wtag' + ; when_handler - : 'when' name (',' name)* (decl (',' decl)*)* ':' body - | 'when' name (',' name)* '(' '*' ')' ':' body - ; + : 'when' name (',' name)* (decl (',' decl)*)* ':' body + | 'when' name (',' name)* '(' '*' ')' ':' body + ; others_handler - : 'others' (idn ':' type_spec)* ':' body - ; + : 'others' (idn ':' type_spec)* ':' body + ; body - : equate* statement* - ; + : equate* statement* + ; type_spec - : 'null' - | 'node' - | 'bool' - | 'int' - | 'real' - | 'char' - | 'string' - | 'any' - | 'image' - | 'rep' - | 'cvt' - | 'sequence' '[' type_actual ']' - | 'array' '[' type_actual ']' - | 'atomic_array' '[' type_actual ']' - | 'struct' '[' field_spec (',' field_spec)* ']' - | 'record' '[' field_spec (',' field_spec)* ']' - | 'atomic_record' '[' field_spec (',' field_spec)* ']' - | 'oneof' '[' field_spec (',' field_spec)* ']' - | 'variant' '[' field_spec (',' field_spec)* ']' - | 'atomic_variant' '[' field_spec (',' field_spec)* ']' - | 'proctype' (type_spec (',' type_spec)*)? returnz? signals? - | 'itertype' (type_spec (',' type_spec)*)? yields? signals? - | 'creatortype' (type_spec (',' type_spec)*)? returnz? signals? - | 'handlertype' (type_spec (',' type_spec)*)? returnz? signals? - | 'mutex' '[' type_actual ']' - | reference - ; + : 'null' + | 'node' + | 'bool' + | 'int' + | 'real' + | 'char' + | 'string' + | 'any' + | 'image' + | 'rep' + | 'cvt' + | 'sequence' '[' type_actual ']' + | 'array' '[' type_actual ']' + | 'atomic_array' '[' type_actual ']' + | 'struct' '[' field_spec (',' field_spec)* ']' + | 'record' '[' field_spec (',' field_spec)* ']' + | 'atomic_record' '[' field_spec (',' field_spec)* ']' + | 'oneof' '[' field_spec (',' field_spec)* ']' + | 'variant' '[' field_spec (',' field_spec)* ']' + | 'atomic_variant' '[' field_spec (',' field_spec)* ']' + | 'proctype' (type_spec (',' type_spec)*)? returnz? signals? + | 'itertype' (type_spec (',' type_spec)*)? yields? signals? + | 'creatortype' (type_spec (',' type_spec)*)? returnz? signals? + | 'handlertype' (type_spec (',' type_spec)*)? returnz? signals? + | 'mutex' '[' type_actual ']' + | reference + ; field_spec - : name (',' name)* ':' type_actual - ; + : name (',' name)* ':' type_actual + ; reference - : idn - | idn (actual_parm (',' actual_parm)*)? - | reference '$' name - ; + : idn + | idn (actual_parm (',' actual_parm)*)? + | reference '$' name + ; actual_parm - : constant - | type_actual - ; + : constant + | type_actual + ; type_actual - : type_spec ('with' (opbinding (',' opbinding)*)?)? - ; + : type_spec ('with' (opbinding (',' opbinding)*)?)? + ; opbinding - : name (',' name)* ':' primaries - ; + : name (',' name)* ':' primaries + ; expression - : primaries - | call '@' primaries - | '(' expression ')' - | '~' expression - | '−' expression - | expression '**' expression - | expression '//' expression - | expression '/' expression - | expression '*' expression - | expression '||' expression - | expression '+' expression - | expression '−' expression - | expression '<' expression - | expression '<=' expression - | expression '=' expression - | expression '>=' expression - | expression '>' expression - | expression '~<' expression - | expression '~<=' expression - | expression '~=' expression - | expression '~>=' expression - | expression '~>' expression - | expression '&' expression - | expression 'cand' expression - | expression '|' expression - | expression 'cor' expression - ; + : primaries + | call '@' primaries + | '(' expression ')' + | '~' expression + | '−' expression + | expression '**' expression + | expression '//' expression + | expression '/' expression + | expression '*' expression + | expression '||' expression + | expression '+' expression + | expression '−' expression + | expression '<' expression + | expression '<=' expression + | expression '=' expression + | expression '>=' expression + | expression '>' expression + | expression '~<' expression + | expression '~<=' expression + | expression '~=' expression + | expression '~>=' expression + | expression '~>' expression + | expression '&' expression + | expression 'cand' expression + | expression '|' expression + | expression 'cor' expression + ; primaries - : primary ('.' name | expression (',' expression)*)* - ; + : primary ('.' name | expression (',' expression)*)* + ; primary - : entities - ; + : entities + ; call - : primaries '(' (expression (',' expression)*)? ')' - ; + : primaries '(' (expression (',' expression)*)? ')' + ; entities - : entity ('.' name | expression)* - ; + : entity ('.' name | expression)* + ; entity - : 'nil' - | 'true' - | 'false' - | INT_LITERAL - | REAL_LITERAL - | CHAR_LITERAL - | STRING_LITERAL - | 'self' - | reference - | 'bind' entities (bind_arg (',' bind_arg)*)? - | type_spec '$' (field (',' field)*)* - | type_spec '$' (expression ':')? (expression (',' expression)*)? - | type_spec '$' name (actual_parm (',' actual_parm)*)? - | 'up' '(' expression ')' - | 'down' '(' expression ')' - ; + : 'nil' + | 'true' + | 'false' + | INT_LITERAL + | REAL_LITERAL + | CHAR_LITERAL + | STRING_LITERAL + | 'self' + | reference + | 'bind' entities (bind_arg (',' bind_arg)*)? + | type_spec '$' (field (',' field)*)* + | type_spec '$' (expression ':')? (expression (',' expression)*)? + | type_spec '$' name (actual_parm (',' actual_parm)*)? + | 'up' '(' expression ')' + | 'down' '(' expression ')' + ; field - : name (',' name)* ':' expression - ; + : name (',' name)* ':' expression + ; bind_arg - : '*' - | expression - ; + : '*' + | expression + ; name - : IDENTIFIER - ; + : IDENTIFIER + ; idn - : IDENTIFIER - ; + : IDENTIFIER + ; INT_LITERAL - : DIGIT+ - ; + : DIGIT+ + ; REAL_LITERAL - : DIGIT+ '.' DIGIT+ - ; + : DIGIT+ '.' DIGIT+ + ; CHAR_LITERAL - : '\'' .*? '\'' - ; + : '\'' .*? '\'' + ; STRING_LITERAL - : '"' .*? '"' - ; + : '"' .*? '"' + ; IDENTIFIER - : [a-zA-Z] [a-zA-Z0-9]* - ; + : [a-zA-Z] [a-zA-Z0-9]* + ; fragment DIGIT - : [0-9] - ; + : [0-9] + ; COMMENT - : '%' ~ [\r\n]* -> skip - ; + : '%' ~ [\r\n]* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/arithmetic/arithmetic.g4 b/arithmetic/arithmetic.g4 index 6fc45adcb5..00adcafd9a 100644 --- a/arithmetic/arithmetic.g4 +++ b/arithmetic/arithmetic.g4 @@ -30,135 +30,128 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar arithmetic; -file_ : equation* EOF; +file_ + : equation* EOF + ; equation - : expression relop expression - ; + : expression relop expression + ; expression - : expression POW expression - | expression (TIMES | DIV) expression - | expression (PLUS | MINUS) expression - | LPAREN expression RPAREN - | (PLUS | MINUS)* atom - ; + : expression POW expression + | expression (TIMES | DIV) expression + | expression (PLUS | MINUS) expression + | LPAREN expression RPAREN + | (PLUS | MINUS)* atom + ; atom - : scientific - | variable - ; + : scientific + | variable + ; scientific - : SCIENTIFIC_NUMBER - ; + : SCIENTIFIC_NUMBER + ; variable - : VARIABLE - ; + : VARIABLE + ; relop - : EQ - | GT - | LT - ; - + : EQ + | GT + | LT + ; VARIABLE - : VALID_ID_START VALID_ID_CHAR* - ; - + : VALID_ID_START VALID_ID_CHAR* + ; fragment VALID_ID_START - : 'a' .. 'z' | 'A' .. 'Z' | '_' - ; - + : 'a' .. 'z' + | 'A' .. 'Z' + | '_' + ; fragment VALID_ID_CHAR - : VALID_ID_START | '0' .. '9' - ; + : VALID_ID_START + | '0' .. '9' + ; //The NUMBER part gets its potential sign from "(PLUS | MINUS)* atom" in the expression rule SCIENTIFIC_NUMBER - : NUMBER (E SIGN? UNSIGNED_INTEGER)? - ; + : NUMBER (E SIGN? UNSIGNED_INTEGER)? + ; fragment NUMBER - : ('0' .. '9') + ('.' ('0' .. '9') +)? - ; + : ('0' .. '9')+ ('.' ('0' .. '9')+)? + ; fragment UNSIGNED_INTEGER - : ('0' .. '9')+ - ; - + : ('0' .. '9')+ + ; fragment E - : 'E' | 'e' - ; - + : 'E' + | 'e' + ; fragment SIGN - : '+' | '-' - ; - + : '+' + | '-' + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; TIMES - : '*' - ; - + : '*' + ; DIV - : '/' - ; - + : '/' + ; GT - : '>' - ; - + : '>' + ; LT - : '<' - ; - + : '<' + ; EQ - : '=' - ; - + : '=' + ; POINT - : '.' - ; - + : '.' + ; POW - : '^' - ; - + : '^' + ; WS - : [ \r\n\t] + -> skip - ; + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/asl/ASL.g4 b/asl/ASL.g4 index e8b4fc6d45..1e4da827ef 100644 --- a/asl/ASL.g4 +++ b/asl/ASL.g4 @@ -4,315 +4,1068 @@ Copyright 2021 Ultra Electronics Limited, trading as Precision Control Systems ( SPDX-License-Identifier: GPL-3.0-or-later */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ASL; /* * Parser Rules */ -asl : statement+ EOF ; -statement : (simple_statement | sequential_logic_statement | native_language_section) NEWLINE+ ; -simple_statement : assignment_statement - | create_statement - | delete_statement - | find_statement - | relationship_navigation - | associative_relationship_navigation - | relationship_link - | relationship_unlink - | event_generation - | operation_invocation - | timer_operation - | set_operation - | struct_statement ; -sequential_logic_statement : switch_statement - | if_statement - | for_loop - | loop_statement ; - -assignment_statement : constant_assignment | date_time_assignment | variable_assignment | object_attribute_assignment - | arithmetic_assignment ; -constant_assignment : (variable | object_attribute) '=' (constant | UNDEFINED) ; -date_time_assignment : (variable | object_attribute) '=' (CURRENT_DATE | CURRENT_TIME) ; -variable_assignment : (variable | object_attribute) '=' (variable | THIS) ; -object_attribute_assignment : (variable | object_attribute) '=' object_attribute ; -arithmetic_assignment : (variable | object_attribute) '=' arithmetic_expression ; -arithmetic_expression : arithmetic_component ARITHMETIC_OPERATOR (arithmetic_component | arithmetic_expression) - | '(' arithmetic_component ARITHMETIC_OPERATOR (arithmetic_component | arithmetic_expression) ')' - | countof_function ; -arithmetic_component : variable | object_attribute | constant | countof_function ; -countof_function : COUNTOF (set_variable | (variable | THIS) '->' relationship_spec) ; - -create_statement : (variable | THIS) '=' CREATE UNIQUE? object_name (WITH attribute_assignments)? ; -attribute_assignments : attribute_assignment ('&' attribute_assignment)* ; -attribute_assignment : attribute '=' (constant | variable | object_attribute | arithmetic_expression | CURRENT_DATE | CURRENT_TIME | UNDEFINED); -delete_statement : DELETE (variable | THIS) ; - -find_statement : find_instance_statement | find_set_statement ; -find_instance_statement : variable '=' (FIND_ONE | FIND_ONLY) (object_name | set_variable) (WHERE object_condition)? ; -find_set_statement : set_variable '=' - ((FIND object_name | FIND? set_variable) WHERE object_condition - | FIND_ALL object_name) - ((ORDERED_BY | REVERSE_ORDERED_BY) attribute)? ; -object_condition : attribute logical_operator (variable | object_attribute | constant | UNDEFINED) (('&' | '|') object_condition)* - | '(' attribute logical_operator (variable | constant | UNDEFINED) ')' (('&' | '|') object_condition)* ; -equality_operator : EQ | NEQ | EQUALS | NOT_EQUALS ; -logical_operator : equality_operator | LT | GT | LTE | GTE | LESS_THAN | GREATER_THAN ; -relationship_navigation : (variable | set_variable) '=' (variable | set_variable | THIS) ('->' relationship_spec)+ (WHERE object_condition)? - ((ORDERED_BY | REVERSE_ORDERED_BY) attribute)? ; -associative_relationship_navigation : variable '=' (variable | THIS) AND (variable | THIS) '->' (qualified_relationship | relationship_role) ; -relationship_link : LINK (variable | THIS) relationship_spec variable (USING variable)? - | LINK variable relationship_spec THIS (USING variable)? ; -relationship_unlink : UNLINK (variable | THIS) relationship_spec variable - | UNLINK variable relationship_spec THIS ; -relationship_spec : R_NUMBER | qualified_relationship | relationship_role ; -qualified_relationship : R_NUMBER DOT object_name ; -relationship_role : R_NUMBER DOT LOWERCASE_TEXT ; - -event_generation : internal_event_generation | external_event_generation ; -internal_event_generation : GENERATE event_specification '(' event_parameters? ')' ';' (TO (variable | THIS))? ; -external_event_generation : GENERATE external_event_specification '(' event_parameters? ')' ';' ; -event_specification : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID ; -external_event_specification : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID ; -event_parameters : event_parameter (',' event_parameter)* ; -event_parameter : variable | constant | THIS | object_attribute | structure_field | UNDEFINED ; - -operation_invocation : object_operation | domain_operation | bridge_operation ; -object_operation : '[' output_parameter_list? ']' '=' oo_specification '[' input_parameter_list? ']' ; -domain_operation : '[' output_parameter_list? ']' '=' do_specification '[' input_parameter_list? ']' ; -bridge_operation : '[' output_parameter_list? ']' '=' bo_specification '[' input_parameter_list? ']' ; -oo_specification : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID ; -do_specification : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID ; -bo_specification : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID ; -output_parameter_list : output_parameter (',' output_parameter)* ; -output_parameter : variable | set_variable | object_attribute ; -input_parameter_list : input_parameter (',' input_parameter)* ; -input_parameter : variable | set_variable | constant | object_attribute ; - -timer_operation : timer_creation | timer_deletion | set_relative_timer | set_absolute_timer | set_recurring_timer | timer_reset ; -timer_creation : '[' timer_id ']' '=' CREATE_TIMER '[' ']' ; -timer_deletion : '[' ']' '=' DELETE_TIMER '[' timer_id ']' ; -set_relative_timer : GENERATE TIM1 '(' time_to_fire ',' return_event ',' target_instance ')' ';' TO timer_id ; -set_absolute_timer : GENERATE TIM10 '(' fire_year ',' fire_month ',' fire_date ',' fire_hour ',' fire_minute ',' fire_second - ',' return_event ',' target_instance ')' ';' TO timer_id ; -set_recurring_timer : GENERATE TIM3 '(' start_time ',' period ',' return_event ',' target_instance ')' ';' TO timer_id ; -timer_reset : GENERATE TIM2 '(' ')' ';' TO timer_id ; -timer_id : variable | object_attribute ; -time_to_fire : variable | object_attribute | INTEGER_VALUE ; -return_event : UPPERCASE_NUMBER_ID ; -target_instance : variable | THIS ; -fire_year : variable | object_attribute | INTEGER_VALUE ; -fire_month : variable | object_attribute | INTEGER_VALUE ; -fire_date : variable | object_attribute | INTEGER_VALUE ; -fire_hour : variable | object_attribute | INTEGER_VALUE ; -fire_minute : variable | object_attribute | INTEGER_VALUE ; -fire_second : variable | object_attribute | INTEGER_VALUE ; -start_time : variable | object_attribute | INTEGER_VALUE ; -period : variable | object_attribute | INTEGER_VALUE ; - -set_operation : unique_set | set_combination | set_difference ; -unique_set : set_variable '=' UNIQUE set_variable ; -set_combination : set_variable '=' (UNION_OF | DISUNION_OF | INTERSECTION_OF) set_variable AND set_variable ; -set_difference : set_variable '=' set_variable NOT_IN set_variable ; - -struct_statement : struct_definition | struct_instantiation | struct_assembly | struct_for_loop - | order_struct | struct_subset ; -struct_definition : DEFINE STRUCTURE struct_type NEWLINE - (member_name member_type NEWLINE)+ - ENDDEFINE ; -member_name : LOWERCASE_ID | LOWERCASE_NUMBER_ID ; -member_type : INTEGER | REAL | BOOLEAN | TEXT | DATE | TIME | struct_type | user_defined_type ; -struct_instantiation : struct_ IS struct_type ; -struct_assembly : APPEND '[' value_list ']' TO struct_ ((ORDERED_BY | REVERSE_ORDERED_BY) member_name)? ; -struct_for_loop : FOR '[' variable_list ']' IN struct_ DO NEWLINE - statement* - (break_statement statement*)? - ENDFOR ; -order_struct : struct_ '=' struct_ (ORDERED_BY | REVERSE_ORDERED_BY) member_name ; -struct_subset : struct_ '=' struct_ WHERE struct_condition ; -struct_condition : member_name logical_operator component ( (AND | OR | '&' | '|') struct_condition)* ; - -struct_ : '{' (LOWERCASE_ID | LOWERCASE_NUMBER_ID) '}' ; -struct_type : LOWERCASE_ID | LOWERCASE_NUMBER_ID | LEADING_FIRST_UPPERCASE_ID '.' LOWERCASE_ID ; -value_list : struct_value (',' struct_value)* ; -struct_value : variable | set_variable | constant | object_attribute | struct_ ; -variable_list : (variable | struct_) (',' (variable | struct_))* ; - -switch_statement : SWITCH (variable | object_attribute) NEWLINE - (CASE constant NEWLINE - statement*)+ - (DEFAULT NEWLINE - statement+)? - ENDSWITCH ; - -if_statement : IF (logical_condition | L_PAREN logical_condition R_PAREN) THEN NEWLINE - statement+ - (ELSE NEWLINE - statement+)? - ENDIF ; -logical_condition : ( '!' | NOT )? compound_logical_condition ( (AND | OR | '&' | '|') ( '!' | NOT )? compound_logical_condition)* ; -compound_logical_condition : ( '!' | NOT )? simple_logical_condition ( (AND | OR | '&' | '|') ( '!' | NOT )? simple_logical_condition)* - | L_PAREN ( '!' | NOT )? simple_logical_condition ( (AND | OR | '&' | '|') ( '!' | NOT )? simple_logical_condition)* R_PAREN ; -simple_logical_condition : L_PAREN? (variable - | component logical_operator component - | component equality_operator UNDEFINED) R_PAREN? ; -component : variable | object_attribute | constant | COUNTOF set_variable | arithmetic_expression | THIS ; - -for_loop : FOR variable IN set_variable DO NEWLINE - statement* - (break_statement statement*)? - ENDFOR ; - -break_statement : (BREAK | BREAKIF logical_condition) NEWLINE ; - -loop_statement : LOOP NEWLINE - statement* - break_statement - (break_statement | statement)* - ENDLOOP ; - -native_language_section : INLINE NEWLINE .*? END_INLINE ; - -set_variable : '{' variable '}' ; -variable : LOWERCASE_ID | LOWERCASE_NUMBER_ID ; -object_name : UPPERCASE_ID ; +asl + : statement+ EOF + ; + +statement + : (simple_statement | sequential_logic_statement | native_language_section) NEWLINE+ + ; + +simple_statement + : assignment_statement + | create_statement + | delete_statement + | find_statement + | relationship_navigation + | associative_relationship_navigation + | relationship_link + | relationship_unlink + | event_generation + | operation_invocation + | timer_operation + | set_operation + | struct_statement + ; + +sequential_logic_statement + : switch_statement + | if_statement + | for_loop + | loop_statement + ; + +assignment_statement + : constant_assignment + | date_time_assignment + | variable_assignment + | object_attribute_assignment + | arithmetic_assignment + ; + +constant_assignment + : (variable | object_attribute) '=' (constant | UNDEFINED) + ; + +date_time_assignment + : (variable | object_attribute) '=' (CURRENT_DATE | CURRENT_TIME) + ; + +variable_assignment + : (variable | object_attribute) '=' (variable | THIS) + ; + +object_attribute_assignment + : (variable | object_attribute) '=' object_attribute + ; + +arithmetic_assignment + : (variable | object_attribute) '=' arithmetic_expression + ; + +arithmetic_expression + : arithmetic_component ARITHMETIC_OPERATOR (arithmetic_component | arithmetic_expression) + | '(' arithmetic_component ARITHMETIC_OPERATOR (arithmetic_component | arithmetic_expression) ')' + | countof_function + ; + +arithmetic_component + : variable + | object_attribute + | constant + | countof_function + ; + +countof_function + : COUNTOF (set_variable | (variable | THIS) '->' relationship_spec) + ; + +create_statement + : (variable | THIS) '=' CREATE UNIQUE? object_name (WITH attribute_assignments)? + ; + +attribute_assignments + : attribute_assignment ('&' attribute_assignment)* + ; + +attribute_assignment + : attribute '=' ( + constant + | variable + | object_attribute + | arithmetic_expression + | CURRENT_DATE + | CURRENT_TIME + | UNDEFINED + ) + ; + +delete_statement + : DELETE (variable | THIS) + ; + +find_statement + : find_instance_statement + | find_set_statement + ; + +find_instance_statement + : variable '=' (FIND_ONE | FIND_ONLY) (object_name | set_variable) (WHERE object_condition)? + ; + +find_set_statement + : set_variable '=' ( + (FIND object_name | FIND? set_variable) WHERE object_condition + | FIND_ALL object_name + ) ((ORDERED_BY | REVERSE_ORDERED_BY) attribute)? + ; + +object_condition + : attribute logical_operator (variable | object_attribute | constant | UNDEFINED) ( + ('&' | '|') object_condition + )* + | '(' attribute logical_operator (variable | constant | UNDEFINED) ')' ( + ('&' | '|') object_condition + )* + ; + +equality_operator + : EQ + | NEQ + | EQUALS + | NOT_EQUALS + ; + +logical_operator + : equality_operator + | LT + | GT + | LTE + | GTE + | LESS_THAN + | GREATER_THAN + ; + +relationship_navigation + : (variable | set_variable) '=' (variable | set_variable | THIS) ('->' relationship_spec)+ ( + WHERE object_condition + )? ((ORDERED_BY | REVERSE_ORDERED_BY) attribute)? + ; + +associative_relationship_navigation + : variable '=' (variable | THIS) AND (variable | THIS) '->' ( + qualified_relationship + | relationship_role + ) + ; + +relationship_link + : LINK (variable | THIS) relationship_spec variable (USING variable)? + | LINK variable relationship_spec THIS (USING variable)? + ; + +relationship_unlink + : UNLINK (variable | THIS) relationship_spec variable + | UNLINK variable relationship_spec THIS + ; + +relationship_spec + : R_NUMBER + | qualified_relationship + | relationship_role + ; + +qualified_relationship + : R_NUMBER DOT object_name + ; + +relationship_role + : R_NUMBER DOT LOWERCASE_TEXT + ; + +event_generation + : internal_event_generation + | external_event_generation + ; + +internal_event_generation + : GENERATE event_specification '(' event_parameters? ')' ';' (TO (variable | THIS))? + ; + +external_event_generation + : GENERATE external_event_specification '(' event_parameters? ')' ';' + ; + +event_specification + : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID + ; + +external_event_specification + : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID + ; + +event_parameters + : event_parameter (',' event_parameter)* + ; + +event_parameter + : variable + | constant + | THIS + | object_attribute + | structure_field + | UNDEFINED + ; + +operation_invocation + : object_operation + | domain_operation + | bridge_operation + ; + +object_operation + : '[' output_parameter_list? ']' '=' oo_specification '[' input_parameter_list? ']' + ; + +domain_operation + : '[' output_parameter_list? ']' '=' do_specification '[' input_parameter_list? ']' + ; + +bridge_operation + : '[' output_parameter_list? ']' '=' bo_specification '[' input_parameter_list? ']' + ; + +oo_specification + : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID + ; + +do_specification + : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID + ; + +bo_specification + : UPPERCASE_NUMBER_ID ':' LEADING_UPPERCASE_ID + ; + +output_parameter_list + : output_parameter (',' output_parameter)* + ; + +output_parameter + : variable + | set_variable + | object_attribute + ; + +input_parameter_list + : input_parameter (',' input_parameter)* + ; + +input_parameter + : variable + | set_variable + | constant + | object_attribute + ; + +timer_operation + : timer_creation + | timer_deletion + | set_relative_timer + | set_absolute_timer + | set_recurring_timer + | timer_reset + ; + +timer_creation + : '[' timer_id ']' '=' CREATE_TIMER '[' ']' + ; + +timer_deletion + : '[' ']' '=' DELETE_TIMER '[' timer_id ']' + ; + +set_relative_timer + : GENERATE TIM1 '(' time_to_fire ',' return_event ',' target_instance ')' ';' TO timer_id + ; + +set_absolute_timer + : GENERATE TIM10 '(' fire_year ',' fire_month ',' fire_date ',' fire_hour ',' fire_minute ',' fire_second ',' return_event ',' target_instance ')' + ';' TO timer_id + ; + +set_recurring_timer + : GENERATE TIM3 '(' start_time ',' period ',' return_event ',' target_instance ')' ';' TO timer_id + ; + +timer_reset + : GENERATE TIM2 '(' ')' ';' TO timer_id + ; + +timer_id + : variable + | object_attribute + ; + +time_to_fire + : variable + | object_attribute + | INTEGER_VALUE + ; + +return_event + : UPPERCASE_NUMBER_ID + ; + +target_instance + : variable + | THIS + ; + +fire_year + : variable + | object_attribute + | INTEGER_VALUE + ; + +fire_month + : variable + | object_attribute + | INTEGER_VALUE + ; + +fire_date + : variable + | object_attribute + | INTEGER_VALUE + ; + +fire_hour + : variable + | object_attribute + | INTEGER_VALUE + ; + +fire_minute + : variable + | object_attribute + | INTEGER_VALUE + ; + +fire_second + : variable + | object_attribute + | INTEGER_VALUE + ; + +start_time + : variable + | object_attribute + | INTEGER_VALUE + ; + +period + : variable + | object_attribute + | INTEGER_VALUE + ; + +set_operation + : unique_set + | set_combination + | set_difference + ; + +unique_set + : set_variable '=' UNIQUE set_variable + ; + +set_combination + : set_variable '=' (UNION_OF | DISUNION_OF | INTERSECTION_OF) set_variable AND set_variable + ; + +set_difference + : set_variable '=' set_variable NOT_IN set_variable + ; + +struct_statement + : struct_definition + | struct_instantiation + | struct_assembly + | struct_for_loop + | order_struct + | struct_subset + ; + +struct_definition + : DEFINE STRUCTURE struct_type NEWLINE (member_name member_type NEWLINE)+ ENDDEFINE + ; + +member_name + : LOWERCASE_ID + | LOWERCASE_NUMBER_ID + ; + +member_type + : INTEGER + | REAL + | BOOLEAN + | TEXT + | DATE + | TIME + | struct_type + | user_defined_type + ; + +struct_instantiation + : struct_ IS struct_type + ; + +struct_assembly + : APPEND '[' value_list ']' TO struct_ ((ORDERED_BY | REVERSE_ORDERED_BY) member_name)? + ; + +struct_for_loop + : FOR '[' variable_list ']' IN struct_ DO NEWLINE statement* (break_statement statement*)? ENDFOR + ; + +order_struct + : struct_ '=' struct_ (ORDERED_BY | REVERSE_ORDERED_BY) member_name + ; + +struct_subset + : struct_ '=' struct_ WHERE struct_condition + ; + +struct_condition + : member_name logical_operator component ((AND | OR | '&' | '|') struct_condition)* + ; + +struct_ + : '{' (LOWERCASE_ID | LOWERCASE_NUMBER_ID) '}' + ; + +struct_type + : LOWERCASE_ID + | LOWERCASE_NUMBER_ID + | LEADING_FIRST_UPPERCASE_ID '.' LOWERCASE_ID + ; + +value_list + : struct_value (',' struct_value)* + ; + +struct_value + : variable + | set_variable + | constant + | object_attribute + | struct_ + ; + +variable_list + : (variable | struct_) (',' (variable | struct_))* + ; + +switch_statement + : SWITCH (variable | object_attribute) NEWLINE (CASE constant NEWLINE statement*)+ ( + DEFAULT NEWLINE statement+ + )? ENDSWITCH + ; + +if_statement + : IF (logical_condition | L_PAREN logical_condition R_PAREN) THEN NEWLINE statement+ ( + ELSE NEWLINE statement+ + )? ENDIF + ; + +logical_condition + : ('!' | NOT)? compound_logical_condition ( + (AND | OR | '&' | '|') ( '!' | NOT)? compound_logical_condition + )* + ; + +compound_logical_condition + : ('!' | NOT)? simple_logical_condition ( + (AND | OR | '&' | '|') ( '!' | NOT)? simple_logical_condition + )* + | L_PAREN ('!' | NOT)? simple_logical_condition ( + (AND | OR | '&' | '|') ( '!' | NOT)? simple_logical_condition + )* R_PAREN + ; + +simple_logical_condition + : L_PAREN? ( + variable + | component logical_operator component + | component equality_operator UNDEFINED + ) R_PAREN? + ; + +component + : variable + | object_attribute + | constant + | COUNTOF set_variable + | arithmetic_expression + | THIS + ; + +for_loop + : FOR variable IN set_variable DO NEWLINE statement* (break_statement statement*)? ENDFOR + ; + +break_statement + : (BREAK | BREAKIF logical_condition) NEWLINE + ; + +loop_statement + : LOOP NEWLINE statement* break_statement (break_statement | statement)* ENDLOOP + ; + +native_language_section + : INLINE NEWLINE .*? END_INLINE + ; + +set_variable + : '{' variable '}' + ; + +variable + : LOWERCASE_ID + | LOWERCASE_NUMBER_ID + ; + +object_name + : UPPERCASE_ID + ; /* Attribute names with a leading uppercase letter for the first word only are allowed but for consistency with event names and operation names, this should be changed to enforce a leading uppercase letter for all words in the future. */ -attribute : LEADING_FIRST_UPPERCASE_ID | LEADING_UPPERCASE_ID | UPPERCASE_ID | INSTANCE_ID ; -object_attribute : (variable | THIS) '.' attribute ; -constant : INTEGER_VALUE | REAL_VALUE | BOOLEAN_VALUE | text_string | enum_value | DATE_VALUE | TIME_VALUE ; -text_string : LOWERCASE_TEXT | OTHER_TEXT | QUOTE QUOTE ; -enum_value : UPPERCASE_ID | UPPERCASE_OR_NUMBER_ID; -structure_field : variable '.' LOWERCASE_ID ; -user_defined_type : UPPERCASE_ID '.' LEADING_FIRST_UPPERCASE_ID ; +attribute + : LEADING_FIRST_UPPERCASE_ID + | LEADING_UPPERCASE_ID + | UPPERCASE_ID + | INSTANCE_ID + ; + +object_attribute + : (variable | THIS) '.' attribute + ; + +constant + : INTEGER_VALUE + | REAL_VALUE + | BOOLEAN_VALUE + | text_string + | enum_value + | DATE_VALUE + | TIME_VALUE + ; + +text_string + : LOWERCASE_TEXT + | OTHER_TEXT + | QUOTE QUOTE + ; + +enum_value + : UPPERCASE_ID + | UPPERCASE_OR_NUMBER_ID + ; + +structure_field + : variable '.' LOWERCASE_ID + ; + +user_defined_type + : UPPERCASE_ID '.' LEADING_FIRST_UPPERCASE_ID + ; /* * Lexer Rules */ -fragment LOWERCASE : [a-z] ; -fragment UPPERCASE : [A-Z] ; -fragment DIGIT : [0-9] ; - -THIS : 'this' ; -CREATE : 'create' ; -UNIQUE : 'unique' ; -WITH : 'with' ; -DELETE : 'delete' ; -UNDEFINED : 'UNDEFINED' ; -FIND_ONLY : 'find-only' ; -FIND_ONE : 'find-one' ; -FIND_ALL : 'find-all' ; -FIND : 'find' ; -WHERE : 'where' ; -EQUALS : 'equals' ; -NOT_EQUALS : 'not-equals' ; -LESS_THAN : 'less-than' ; -GREATER_THAN : 'greater-than' ; -REVERSE_ORDERED_BY : 'reverse ordered by' ; -ORDERED_BY : 'ordered by' ; -COUNTOF : 'countof' ; -AND : 'and' ; -OR : 'or' ; -NOT : 'not' ; -LINK : 'link' ; -USING : 'using' ; -UNLINK : 'unlink' ; -RELATIONSHIP_TRAVERSAL : '->' ; -GENERATE : '%generate' ; -TO : 'to' ; -CREATE_TIMER : 'Create_Timer' ; -DELETE_TIMER : 'Delete_Timer' ; -TIM10 : 'TIM10:Set_Absolute_Timer' ; -TIM1 : 'TIM1:Set_Timer' ; -TIM2 : 'TIM2:Reset_Timer' ; -TIM3 : 'TIM3:Set_Chimer' ; -CURRENT_DATE : 'current-date' ; -CURRENT_TIME : 'current-time' ; -SWITCH : 'switch' ; -CASE : 'case' ; -DEFAULT : 'default' ; -ENDSWITCH : 'endswitch' ; -IF : 'if' ; -THEN : 'then' ; -ELSE : 'else' ; -ENDIF : 'endif' ; -FOR : 'for' ; -IN : 'in' ; -DO : 'do' ; -ENDFOR : 'endfor' ; -BREAK : 'break' ; -BREAKIF : 'breakif' ; -LOOP : 'loop' ; -ENDLOOP : 'endloop' ; -INLINE : '$INLINE' ; -END_INLINE : '$ENDINLINE' ; -DEFINE : 'define' ; -STRUCTURE : 'structure' ; -ENDDEFINE : 'enddefine' ; -IS : 'is' ; -APPEND : 'append' ; -INTEGER : 'Integer' ; -REAL : 'Real' ; -BOOLEAN : 'Boolean' ; -TEXT : 'Text' ; -DATE : 'Date' ; -TIME : 'Time_of_Day' ; - -NEQ : '!=' ; -EQ : '=' ; -LTE : '<=' ; -GTE : '>=' ; -LT : '<' ; -GT : '>' ; -LOGICAL_AND : '&' ; -LOGICAL_OR : '|' ; -LOGICAL_NOT : '!' ; -L_PAREN : '(' ; -R_PAREN : ')' ; -L_CURLY : '{' ; -R_CURLY : '}' ; -L_SQUARE : '[' ; -R_SQUARE : ']' ; -UNDERSCORE : '_' ; -DOT : '.' ; -SEMI_COLON : ';' ; -COLON : ':' ; -COMMA : ',' ; -HASH : '#' ; -BACKSLASH : '\\' ; -UNION_OF : 'union-of' ; -DISUNION_OF : 'disunion-of' ; -INTERSECTION_OF : 'intersection-of' ; -NOT_IN : 'not-in' ; - -DATE_VALUE : DIGIT DIGIT DIGIT DIGIT '.' DIGIT DIGIT '.' DIGIT DIGIT ; -TIME_VALUE : DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT ; -INTEGER_VALUE : '-'? DIGIT+ ; -REAL_VALUE : '-'? DIGIT+ '.' DIGIT+ ; -ARITHMETIC_OPERATOR : '+' | '-' | '/' | '*' ; -BOOLEAN_VALUE : 'TRUE' | 'FALSE' ; - -LOWERCASE_TEXT : '"' LOWERCASE+ (' ' LOWERCASE+)* '"' ; -OTHER_TEXT : '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('\\' | '"' | 'r' | 'n' | 't'))* '"' ; -QUOTE : '"' ; -R_NUMBER : 'R' DIGIT+ ; -INSTANCE_ID : 'instance_id' ; -UPPERCASE_ID : UPPERCASE+ ('_' UPPERCASE+)* ; -LOWERCASE_ID : LOWERCASE+ ('_' LOWERCASE+)* ; -LEADING_UPPERCASE_ID : UPPERCASE (UPPERCASE | LOWERCASE)* ('_' UPPERCASE (UPPERCASE | LOWERCASE)+)* ; -LEADING_FIRST_UPPERCASE_ID : UPPERCASE (UPPERCASE | LOWERCASE)* ('_' (UPPERCASE | LOWERCASE)+)* ; -UPPERCASE_NUMBER_ID : UPPERCASE+ ('_' UPPERCASE+)* DIGIT+; -LOWERCASE_NUMBER_ID : LOWERCASE (LOWERCASE | DIGIT)* ('_' (LOWERCASE | DIGIT)+)* ; -UPPERCASE_OR_NUMBER_ID : UPPERCASE (UPPERCASE | DIGIT)* ('_' (UPPERCASE | DIGIT)+)* ; - -NATIVE_LANGUAGE : INLINE NEWLINE .*? END_INLINE NEWLINE+ -> skip ; -CONTINUATION : BACKSLASH NEWLINE -> skip ; -WHITESPACE : [ \t]+ -> skip ; -COMMENT : HASH .*? NEWLINE+ -> skip ; -NEWLINE : ('\r'? '\n' | '\r')+ ; -OTHER : . ; +fragment LOWERCASE + : [a-z] + ; + +fragment UPPERCASE + : [A-Z] + ; + +fragment DIGIT + : [0-9] + ; + +THIS + : 'this' + ; + +CREATE + : 'create' + ; + +UNIQUE + : 'unique' + ; + +WITH + : 'with' + ; + +DELETE + : 'delete' + ; + +UNDEFINED + : 'UNDEFINED' + ; + +FIND_ONLY + : 'find-only' + ; + +FIND_ONE + : 'find-one' + ; + +FIND_ALL + : 'find-all' + ; + +FIND + : 'find' + ; + +WHERE + : 'where' + ; + +EQUALS + : 'equals' + ; + +NOT_EQUALS + : 'not-equals' + ; + +LESS_THAN + : 'less-than' + ; + +GREATER_THAN + : 'greater-than' + ; + +REVERSE_ORDERED_BY + : 'reverse ordered by' + ; + +ORDERED_BY + : 'ordered by' + ; + +COUNTOF + : 'countof' + ; + +AND + : 'and' + ; + +OR + : 'or' + ; + +NOT + : 'not' + ; + +LINK + : 'link' + ; + +USING + : 'using' + ; + +UNLINK + : 'unlink' + ; + +RELATIONSHIP_TRAVERSAL + : '->' + ; + +GENERATE + : '%generate' + ; + +TO + : 'to' + ; + +CREATE_TIMER + : 'Create_Timer' + ; + +DELETE_TIMER + : 'Delete_Timer' + ; + +TIM10 + : 'TIM10:Set_Absolute_Timer' + ; + +TIM1 + : 'TIM1:Set_Timer' + ; + +TIM2 + : 'TIM2:Reset_Timer' + ; + +TIM3 + : 'TIM3:Set_Chimer' + ; + +CURRENT_DATE + : 'current-date' + ; + +CURRENT_TIME + : 'current-time' + ; + +SWITCH + : 'switch' + ; + +CASE + : 'case' + ; + +DEFAULT + : 'default' + ; + +ENDSWITCH + : 'endswitch' + ; + +IF + : 'if' + ; + +THEN + : 'then' + ; + +ELSE + : 'else' + ; + +ENDIF + : 'endif' + ; + +FOR + : 'for' + ; + +IN + : 'in' + ; + +DO + : 'do' + ; + +ENDFOR + : 'endfor' + ; + +BREAK + : 'break' + ; + +BREAKIF + : 'breakif' + ; + +LOOP + : 'loop' + ; + +ENDLOOP + : 'endloop' + ; + +INLINE + : '$INLINE' + ; + +END_INLINE + : '$ENDINLINE' + ; + +DEFINE + : 'define' + ; + +STRUCTURE + : 'structure' + ; + +ENDDEFINE + : 'enddefine' + ; + +IS + : 'is' + ; + +APPEND + : 'append' + ; + +INTEGER + : 'Integer' + ; + +REAL + : 'Real' + ; + +BOOLEAN + : 'Boolean' + ; + +TEXT + : 'Text' + ; + +DATE + : 'Date' + ; + +TIME + : 'Time_of_Day' + ; + +NEQ + : '!=' + ; + +EQ + : '=' + ; + +LTE + : '<=' + ; + +GTE + : '>=' + ; + +LT + : '<' + ; + +GT + : '>' + ; + +LOGICAL_AND + : '&' + ; + +LOGICAL_OR + : '|' + ; + +LOGICAL_NOT + : '!' + ; + +L_PAREN + : '(' + ; + +R_PAREN + : ')' + ; + +L_CURLY + : '{' + ; + +R_CURLY + : '}' + ; + +L_SQUARE + : '[' + ; + +R_SQUARE + : ']' + ; + +UNDERSCORE + : '_' + ; + +DOT + : '.' + ; + +SEMI_COLON + : ';' + ; + +COLON + : ':' + ; + +COMMA + : ',' + ; + +HASH + : '#' + ; + +BACKSLASH + : '\\' + ; + +UNION_OF + : 'union-of' + ; + +DISUNION_OF + : 'disunion-of' + ; + +INTERSECTION_OF + : 'intersection-of' + ; + +NOT_IN + : 'not-in' + ; + +DATE_VALUE + : DIGIT DIGIT DIGIT DIGIT '.' DIGIT DIGIT '.' DIGIT DIGIT + ; + +TIME_VALUE + : DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT + ; + +INTEGER_VALUE + : '-'? DIGIT+ + ; + +REAL_VALUE + : '-'? DIGIT+ '.' DIGIT+ + ; + +ARITHMETIC_OPERATOR + : '+' + | '-' + | '/' + | '*' + ; + +BOOLEAN_VALUE + : 'TRUE' + | 'FALSE' + ; + +LOWERCASE_TEXT + : '"' LOWERCASE+ (' ' LOWERCASE+)* '"' + ; + +OTHER_TEXT + : '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('\\' | '"' | 'r' | 'n' | 't'))* '"' + ; + +QUOTE + : '"' + ; + +R_NUMBER + : 'R' DIGIT+ + ; + +INSTANCE_ID + : 'instance_id' + ; + +UPPERCASE_ID + : UPPERCASE+ ('_' UPPERCASE+)* + ; + +LOWERCASE_ID + : LOWERCASE+ ('_' LOWERCASE+)* + ; + +LEADING_UPPERCASE_ID + : UPPERCASE (UPPERCASE | LOWERCASE)* ('_' UPPERCASE (UPPERCASE | LOWERCASE)+)* + ; + +LEADING_FIRST_UPPERCASE_ID + : UPPERCASE (UPPERCASE | LOWERCASE)* ('_' (UPPERCASE | LOWERCASE)+)* + ; + +UPPERCASE_NUMBER_ID + : UPPERCASE+ ('_' UPPERCASE+)* DIGIT+ + ; + +LOWERCASE_NUMBER_ID + : LOWERCASE (LOWERCASE | DIGIT)* ('_' (LOWERCASE | DIGIT)+)* + ; + +UPPERCASE_OR_NUMBER_ID + : UPPERCASE (UPPERCASE | DIGIT)* ('_' (UPPERCASE | DIGIT)+)* + ; + +NATIVE_LANGUAGE + : INLINE NEWLINE .*? END_INLINE NEWLINE+ -> skip + ; + +CONTINUATION + : BACKSLASH NEWLINE -> skip + ; + +WHITESPACE + : [ \t]+ -> skip + ; + +COMMENT + : HASH .*? NEWLINE+ -> skip + ; + +NEWLINE + : ('\r'? '\n' | '\r')+ + ; + +OTHER + : . + ; \ No newline at end of file diff --git a/asm/asm6502/asm6502.g4 b/asm/asm6502/asm6502.g4 index 30c3f3fcac..f78a44e71c 100644 --- a/asm/asm6502/asm6502.g4 +++ b/asm/asm6502/asm6502.g4 @@ -30,224 +30,409 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar asm6502; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} prog - : line* EOF - ; + : line* EOF + ; line - : (instruction | assemblerinstruction | lbl)? EOL - ; + : (instruction | assemblerinstruction | lbl)? EOL + ; instruction - : label? opcode argumentlist? - ; + : label? opcode argumentlist? + ; assemblerinstruction - : argument? assembleropcode argumentlist? - ; + : argument? assembleropcode argumentlist? + ; assembleropcode - : ASSEMBLER_INSTRUCTION - ; + : ASSEMBLER_INSTRUCTION + ; lbl - : label ':' - ; + : label ':' + ; argumentlist - : argument (',' argumentlist)? - ; + : argument (',' argumentlist)? + ; label - : name - ; + : name + ; argument - : prefix_? (number | name | string_ | '*') (('+' | '-') number)? - | '(' argument ')' - ; + : prefix_? (number | name | string_ | '*') (('+' | '-') number)? + | '(' argument ')' + ; prefix_ - : '#' - ; + : '#' + ; string_ - : STRING - ; + : STRING + ; name - : NAME - ; + : NAME + ; number - : NUMBER - ; + : NUMBER + ; opcode - : ADC - | AND - | ASL - | BCC - | BCS - | BEQ - | BIT - | BMI - | BNE - | BPL - | BRA - | BRK - | BVC - | BVS - | CLC - | CLD - | CLI - | CLV - | CMP - | CPX - | CPY - | DEC - | DEX - | DEY - | EOR - | INC - | INX - | INY - | JMP - | JSR - | LDA - | LDY - | LDX - | LSR - | NOP - | ORA - | PHA - | PHX - | PHY - | PHP - | PLA - | PLP - | PLY - | ROL - | ROR - | RTI - | RTS - | SBC - | SEC - | SED - | SEI - | STA - | STX - | STY - | STZ - | TAX - | TAY - | TSX - | TXA - | TXS - | TYA - ; - + : ADC + | AND + | ASL + | BCC + | BCS + | BEQ + | BIT + | BMI + | BNE + | BPL + | BRA + | BRK + | BVC + | BVS + | CLC + | CLD + | CLI + | CLV + | CMP + | CPX + | CPY + | DEC + | DEX + | DEY + | EOR + | INC + | INX + | INY + | JMP + | JSR + | LDA + | LDY + | LDX + | LSR + | NOP + | ORA + | PHA + | PHX + | PHY + | PHP + | PLA + | PLP + | PLY + | ROL + | ROR + | RTI + | RTS + | SBC + | SEC + | SED + | SEI + | STA + | STX + | STY + | STZ + | TAX + | TAY + | TSX + | TXA + | TXS + | TYA + ; ASSEMBLER_INSTRUCTION - : 'ORG' | 'EQU' | 'ASC' | 'DS' | 'DFC' | '=' - ; + : 'ORG' + | 'EQU' + | 'ASC' + | 'DS' + | 'DFC' + | '=' + ; /* * opcodes */ -ADC: 'ADC'; -AND: 'AND'; -ASL: 'ASL'; -BCC: 'BCC'; -BCS: 'BCS'; -BEQ: 'BEQ'; -BIT: 'BIT'; -BMI: 'BMI'; -BNE: 'BNE'; -BPL: 'BPL'; -BRA: 'BRA'; -BRK: 'BRK'; -BVC: 'BVC'; -BVS: 'BVS'; -CLC: 'CLC'; -CLD: 'CLD'; -CLI: 'CLI'; -CLV: 'CLV'; -CMP: 'CMP'; -CPX: 'CPX'; -CPY: 'CPY'; -DEC: 'DEC'; -DEX: 'DEX'; -DEY: 'DEY'; -EOR: 'EOR'; -INC: 'INC'; -INX: 'INX'; -INY: 'INY'; -JMP: 'JMP'; -JSR: 'JSR'; -LDA: 'LDA'; -LDY: 'LDY'; -LDX: 'LDX'; -LSR: 'LSR'; -NOP: 'NOP'; -ORA: 'ORA'; -PHA: 'PHA'; -PHX: 'PHX'; -PHY: 'PHY'; -PHP: 'PHP'; -PLA: 'PLA'; -PLP: 'PLP'; -PLY: 'PLY'; -ROL: 'ROL'; -ROR: 'ROR'; -RTI: 'RTI'; -RTS: 'RTS'; -SBC: 'SBC'; -SEC: 'SEC'; -SED: 'SED'; -SEI: 'SEI'; -STA: 'STA'; -STX: 'STX'; -STY: 'STY'; -STZ: 'STZ'; -TAX: 'TAX'; -TAY: 'TAY'; -TSX: 'TSX'; -TXA: 'TXA'; -TXS: 'TXS'; -TYA: 'TYA'; +ADC + : 'ADC' + ; +AND + : 'AND' + ; -NAME - : [A-Z] [A-Z0-9."]* - ; +ASL + : 'ASL' + ; +BCC + : 'BCC' + ; -NUMBER - : '$'? [0-9A-F] + - ; +BCS + : 'BCS' + ; +BEQ + : 'BEQ' + ; -COMMENT - : ';' ~ [\r\n]* -> skip - ; +BIT + : 'BIT' + ; +BMI + : 'BMI' + ; -STRING - : '"' ~ ["]* '"' - ; +BNE + : 'BNE' + ; +BPL + : 'BPL' + ; -EOL - : [\r\n] + - ; +BRA + : 'BRA' + ; + +BRK + : 'BRK' + ; + +BVC + : 'BVC' + ; + +BVS + : 'BVS' + ; + +CLC + : 'CLC' + ; + +CLD + : 'CLD' + ; + +CLI + : 'CLI' + ; + +CLV + : 'CLV' + ; + +CMP + : 'CMP' + ; + +CPX + : 'CPX' + ; + +CPY + : 'CPY' + ; + +DEC + : 'DEC' + ; + +DEX + : 'DEX' + ; + +DEY + : 'DEY' + ; + +EOR + : 'EOR' + ; + +INC + : 'INC' + ; + +INX + : 'INX' + ; + +INY + : 'INY' + ; + +JMP + : 'JMP' + ; + +JSR + : 'JSR' + ; + +LDA + : 'LDA' + ; + +LDY + : 'LDY' + ; + +LDX + : 'LDX' + ; + +LSR + : 'LSR' + ; + +NOP + : 'NOP' + ; + +ORA + : 'ORA' + ; + +PHA + : 'PHA' + ; +PHX + : 'PHX' + ; + +PHY + : 'PHY' + ; + +PHP + : 'PHP' + ; + +PLA + : 'PLA' + ; + +PLP + : 'PLP' + ; + +PLY + : 'PLY' + ; + +ROL + : 'ROL' + ; + +ROR + : 'ROR' + ; + +RTI + : 'RTI' + ; + +RTS + : 'RTS' + ; + +SBC + : 'SBC' + ; + +SEC + : 'SEC' + ; + +SED + : 'SED' + ; + +SEI + : 'SEI' + ; + +STA + : 'STA' + ; + +STX + : 'STX' + ; + +STY + : 'STY' + ; + +STZ + : 'STZ' + ; + +TAX + : 'TAX' + ; + +TAY + : 'TAY' + ; + +TSX + : 'TSX' + ; + +TXA + : 'TXA' + ; + +TXS + : 'TXS' + ; + +TYA + : 'TYA' + ; + +NAME + : [A-Z] [A-Z0-9."]* + ; + +NUMBER + : '$'? [0-9A-F]+ + ; + +COMMENT + : ';' ~ [\r\n]* -> skip + ; + +STRING + : '"' ~ ["]* '"' + ; + +EOL + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/asm/asm8080/asm8080.g4 b/asm/asm8080/asm8080.g4 index 43e200ff8c..6fef6d2e80 100644 --- a/asm/asm8080/asm8080.g4 +++ b/asm/asm8080/asm8080.g4 @@ -33,206 +33,219 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * http://fms.komkon.org/comp/CPUs/8080.txt */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar asm8080; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} prog - : EOL* ((line EOL)* line EOL*)? EOF - ; + : EOL* ((line EOL)* line EOL*)? EOF + ; line - : lbl? (instruction | directive) comment? - | lbl comment? - | comment - ; + : lbl? (instruction | directive) comment? + | lbl comment? + | comment + ; instruction - : opcode expressionlist? - ; + : opcode expressionlist? + ; opcode - : OPCODE - ; + : OPCODE + ; register_ - : REGISTER - ; + : REGISTER + ; directive - : argument? assemblerdirective expressionlist - ; + : argument? assemblerdirective expressionlist + ; assemblerdirective - : ASSEMBLER_DIRECTIVE - ; + : ASSEMBLER_DIRECTIVE + ; lbl - : label ':'? - ; + : label ':'? + ; expressionlist - : expression (',' expression)* - ; + : expression (',' expression)* + ; label - : name - ; + : name + ; expression - : multiplyingExpression (('+' | '-') multiplyingExpression)* - ; + : multiplyingExpression (('+' | '-') multiplyingExpression)* + ; multiplyingExpression - : argument (('*' | '/') argument)* - ; + : argument (('*' | '/') argument)* + ; argument - : number - | register_ - | dollar - | name - | string_ - | '(' expression ')' - ; + : number + | register_ + | dollar + | name + | string_ + | '(' expression ')' + ; dollar - : '$' - ; + : '$' + ; string_ - : STRING - ; + : STRING + ; name - : NAME - ; + : NAME + ; number - : NUMBER - ; + : NUMBER + ; comment - : COMMENT - ; + : COMMENT + ; ASSEMBLER_DIRECTIVE - : 'ORG' - | 'END' - | 'EQU' - | 'DB' - | 'DW' - | 'DS' - | 'IF' - | 'ENDIF' - | 'SET' - ; + : 'ORG' + | 'END' + | 'EQU' + | 'DB' + | 'DW' + | 'DS' + | 'IF' + | 'ENDIF' + | 'SET' + ; REGISTER - : 'A' | 'B' | 'C' | 'D' | 'E' | 'H' | 'L' | 'PC' | 'SP' - ; + : 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'H' + | 'L' + | 'PC' + | 'SP' + ; OPCODE - : 'MOV' - | 'MVI' - | 'LDA' - | 'STA' - | 'LDAX' - | 'STAX' - | 'LHLD' - | 'SHLD' - | 'LXI' - | 'PUSH' - | 'POP' - | 'XTHL' - | 'SPHL' - | 'PCHL' - | 'XCHG' - | 'ADD' - | 'SUB' - | 'INR' - | 'DCR' - | 'CMP' - | 'ANA' - | 'ORA' - | 'XRA' - | 'ADI' - | 'SUI' - | 'CPI' - | 'ANI' - | 'ORI' - | 'XRI' - | 'DAA' - | 'ADC' - | 'ACI' - | 'SBB' - | 'SBI' - | 'DAD' - | 'INX' - | 'DCX' - | 'JMP' - | 'CALL' - | 'RET' - | 'RAL' - | 'RAR' - | 'RLC' - | 'RRC' - | 'IN' - | 'OUT' - | 'CMC' - | 'STC' - | 'CMA' - | 'HLT' - | 'NOP' - | 'DI' - | 'EI' - | 'RST' - | 'JNZ' - | 'JZ' - | 'JNC' - | 'JC' - | 'JPO' - | 'JPE' - | 'JP' - | 'JM' - | 'CNZ' - | 'CZ' - | 'CNC' - | 'CC' - | 'CPO' - | 'CPE' - | 'CP' - | 'CM' - | 'RNZ' - | 'RZ' - | 'RNC' - | 'RC' - | 'RPO' - | 'RPE' - | 'RP' - | 'RM' - ; + : 'MOV' + | 'MVI' + | 'LDA' + | 'STA' + | 'LDAX' + | 'STAX' + | 'LHLD' + | 'SHLD' + | 'LXI' + | 'PUSH' + | 'POP' + | 'XTHL' + | 'SPHL' + | 'PCHL' + | 'XCHG' + | 'ADD' + | 'SUB' + | 'INR' + | 'DCR' + | 'CMP' + | 'ANA' + | 'ORA' + | 'XRA' + | 'ADI' + | 'SUI' + | 'CPI' + | 'ANI' + | 'ORI' + | 'XRI' + | 'DAA' + | 'ADC' + | 'ACI' + | 'SBB' + | 'SBI' + | 'DAD' + | 'INX' + | 'DCX' + | 'JMP' + | 'CALL' + | 'RET' + | 'RAL' + | 'RAR' + | 'RLC' + | 'RRC' + | 'IN' + | 'OUT' + | 'CMC' + | 'STC' + | 'CMA' + | 'HLT' + | 'NOP' + | 'DI' + | 'EI' + | 'RST' + | 'JNZ' + | 'JZ' + | 'JNC' + | 'JC' + | 'JPO' + | 'JPE' + | 'JP' + | 'JM' + | 'CNZ' + | 'CZ' + | 'CNC' + | 'CC' + | 'CPO' + | 'CPE' + | 'CP' + | 'CM' + | 'RNZ' + | 'RZ' + | 'RNC' + | 'RC' + | 'RPO' + | 'RPE' + | 'RP' + | 'RM' + ; NAME - : [A-Z] [A-Z0-9."]* - ; + : [A-Z] [A-Z0-9."]* + ; NUMBER - : '$'? [0-9A-F] + 'H'? - ; + : '$'? [0-9A-F]+ 'H'? + ; COMMENT - : ';' ~ [\r\n]* - ; + : ';' ~ [\r\n]* + ; STRING - : '\u0027' ~'\u0027'* '\u0027' - ; + : '\u0027' ~'\u0027'* '\u0027' + ; EOL - : [\r\n] + - ; + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/asm/asm8086/asm8086.g4 b/asm/asm8086/asm8086.g4 index f368b7b5cc..233527a164 100644 --- a/asm/asm8086/asm8086.g4 +++ b/asm/asm8086/asm8086.g4 @@ -30,536 +30,1083 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar asm8086; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} prog - : line* EOF - ; + : line* EOF + ; line - : lbl? (assemblerdirective | instruction)? ('!' instruction)* EOL - ; + : lbl? (assemblerdirective | instruction)? ('!' instruction)* EOL + ; instruction - : rep? opcode expressionlist? - ; + : rep? opcode expressionlist? + ; lbl - : label COLON? - ; + : label COLON? + ; assemblerdirective - : org - | end - | if_ - | endif_ - | equ - | db - | dw - | cseg - | dd - | dseg - | title - | include_ - | rw - | rb - | rs - | DOT - ; + : org + | end + | if_ + | endif_ + | equ + | db + | dw + | cseg + | dd + | dseg + | title + | include_ + | rw + | rb + | rs + | DOT + ; rw - : name? RW expression - ; + : name? RW expression + ; rb - : name? RB expression - ; + : name? RB expression + ; rs - : name? RS expression - ; + : name? RS expression + ; cseg - : CSEG expression? - ; + : CSEG expression? + ; dseg - : DSEG expression? - ; + : DSEG expression? + ; dw - : DW expressionlist - ; + : DW expressionlist + ; db - : DB expressionlist - ; + : DB expressionlist + ; dd - : DD expressionlist - ; + : DD expressionlist + ; equ - : name EQU expression - ; + : name EQU expression + ; if_ - : IF assemblerexpression - ; + : IF assemblerexpression + ; assemblerexpression - : assemblerterm (assemblerlogical assemblerterm)* - | RP assemblerexpression LP - ; + : assemblerterm (assemblerlogical assemblerterm)* + | RP assemblerexpression LP + ; assemblerlogical - : EQ - | NE - ; + : EQ + | NE + ; assemblerterm - : name - | number - | NOT assemblerterm - ; + : name + | number + | NOT assemblerterm + ; endif_ - : ENDIF - ; + : ENDIF + ; end - : END - ; + : END + ; org - : ORG expression - ; + : ORG expression + ; title - : TITLE string_ - ; + : TITLE string_ + ; include_ - : INCLUDE name - ; + : INCLUDE name + ; expressionlist - : expression (COMMA expression)* - ; + : expression (COMMA expression)* + ; label - : name - ; + : name + ; expression - : multiplyingExpression (sign multiplyingExpression)* - ; + : multiplyingExpression (sign multiplyingExpression)* + ; multiplyingExpression - : argument ((STAR | SLASH | MOD | AND) argument)* - ; + : argument ((STAR | SLASH | MOD | AND) argument)* + ; argument - : number - | dollar - | register_ - | name - | string_ - | RP expression LP - | (number | name)? LB expression RB_ - | ptr expression - | NOT expression - | OFFSET expression - | LENGTH expression - | register_ COLON expression - ; + : number + | dollar + | register_ + | name + | string_ + | RP expression LP + | (number | name)? LB expression RB_ + | ptr expression + | NOT expression + | OFFSET expression + | LENGTH expression + | register_ COLON expression + ; ptr - : (BYTE | WORD | DWORD)? PTR - ; + : (BYTE | WORD | DWORD)? PTR + ; dollar - : DOLLAR - ; + : DOLLAR + ; register_ - : AH - | AL - | BH - | BL - | CH - | CL - | DH - | DL - | AX - | BX - | CX - | DX - | CI - | DI - | BP - | SP - | IP - | CS - | DS - | ES - | SS - ; + : AH + | AL + | BH + | BL + | CH + | CL + | DH + | DL + | AX + | BX + | CX + | DX + | CI + | DI + | BP + | SP + | IP + | CS + | DS + | ES + | SS + ; string_ - : STRING - ; + : STRING + ; name - : NAME - ; + : NAME + ; number - : sign? NUMBER - ; + : sign? NUMBER + ; opcode - : AAA - | AAD - | AAM - | AAS - | ADC - | ADD - | AND - | CALL - | CBW - | CLC - | CLD - | CLI - | CMC - | CMP - | CMPSB - | CMPSW - | CWD - | DAA - | DAS - | DEC - | DIV - | ESC - | HLT - | IDIV - | IMUL - | IN - | INC - | INT - | INTO - | IRET - | JA - | JAE - | JB - | JBE - | JC - | JE - | JG - | JGE - | JL - | JLE - | JNA - | JNAE - | JNB - | JNBE - | JNC - | JNE - | JNG - | JNGE - | JNL - | JNLE - | JNO - | JNP - | JNS - | JNZ - | JO - | JP - | JPE - | JPO - | JS - | JZ - | JCXZ - | JMP - | JMPS - | JMPF - | LAHF - | LDS - | LEA - | LES - | LOCK - | LODS - | LODSB - | LODSW - | LOOP - | LOOPE - | LOOPNE - | LOOPNZ - | LOOPZ - | MOV - | MOVS - | MOVSB - | MOVSW - | MUL - | NEG - | NOP - | NOT - | OR - | OUT - | POP - | POPF - | PUSH - | PUSHF - | RCL - | RCR - | RET - | RETN - | RETF - | ROL - | ROR - | SAHF - | SAL - | SAR - | SALC - | SBB - | SCASB - | SCASW - | SHL - | SHR - | STC - | STD - | STI - | STOSB - | STOSW - | SUB - | TEST - | WAIT - | XCHG - | XLAT - | XOR - ; + : AAA + | AAD + | AAM + | AAS + | ADC + | ADD + | AND + | CALL + | CBW + | CLC + | CLD + | CLI + | CMC + | CMP + | CMPSB + | CMPSW + | CWD + | DAA + | DAS + | DEC + | DIV + | ESC + | HLT + | IDIV + | IMUL + | IN + | INC + | INT + | INTO + | IRET + | JA + | JAE + | JB + | JBE + | JC + | JE + | JG + | JGE + | JL + | JLE + | JNA + | JNAE + | JNB + | JNBE + | JNC + | JNE + | JNG + | JNGE + | JNL + | JNLE + | JNO + | JNP + | JNS + | JNZ + | JO + | JP + | JPE + | JPO + | JS + | JZ + | JCXZ + | JMP + | JMPS + | JMPF + | LAHF + | LDS + | LEA + | LES + | LOCK + | LODS + | LODSB + | LODSW + | LOOP + | LOOPE + | LOOPNE + | LOOPNZ + | LOOPZ + | MOV + | MOVS + | MOVSB + | MOVSW + | MUL + | NEG + | NOP + | NOT + | OR + | OUT + | POP + | POPF + | PUSH + | PUSHF + | RCL + | RCR + | RET + | RETN + | RETF + | ROL + | ROR + | SAHF + | SAL + | SAR + | SALC + | SBB + | SCASB + | SCASW + | SHL + | SHR + | STC + | STD + | STI + | STOSB + | STOSW + | SUB + | TEST + | WAIT + | XCHG + | XLAT + | XOR + ; rep - : REP - | REPE - | REPNE - | REPNZ - | REPZ - ; - -sign : PLUS | MINUS ; - -BYTE: 'BYTE'; -WORD: 'WORD'; -DWORD: 'DWORD'; -DSEG: 'DSEG'; -CSEG: 'CSEG'; -INCLUDE: 'INCLUDE'; -TITLE: 'TITLE'; -END: 'END'; -ORG: 'ORG'; -ENDIF: 'ENDIF'; -IF: 'IF'; -EQU: 'EQU'; -DW: 'DW'; -DB: 'DB'; -DD: 'DD'; -PTR: 'PTR'; -OFFSET: 'OFFSET'; -RW: 'RW'; -RB: 'RB'; -RS: 'RS'; -LENGTH: 'LENGTH'; -EQ: 'EQ'; -NE: 'NE'; -MOD: 'MOD'; + : REP + | REPE + | REPNE + | REPNZ + | REPZ + ; + +sign + : PLUS + | MINUS + ; + +BYTE + : 'BYTE' + ; + +WORD + : 'WORD' + ; + +DWORD + : 'DWORD' + ; + +DSEG + : 'DSEG' + ; + +CSEG + : 'CSEG' + ; + +INCLUDE + : 'INCLUDE' + ; + +TITLE + : 'TITLE' + ; + +END + : 'END' + ; + +ORG + : 'ORG' + ; + +ENDIF + : 'ENDIF' + ; + +IF + : 'IF' + ; + +EQU + : 'EQU' + ; + +DW + : 'DW' + ; + +DB + : 'DB' + ; + +DD + : 'DD' + ; + +PTR + : 'PTR' + ; + +OFFSET + : 'OFFSET' + ; + +RW + : 'RW' + ; + +RB + : 'RB' + ; + +RS + : 'RS' + ; + +LENGTH + : 'LENGTH' + ; + +EQ + : 'EQ' + ; + +NE + : 'NE' + ; + +MOD + : 'MOD' + ; COMMENT - : ';' ~ [\r\n]* -> skip - ; - -AH: 'AH'; -AL: 'AL'; -BH: 'BH'; -BL: 'BL'; -CH: 'CH'; -CL: 'CL'; -DH: 'DH'; -DL: 'DL'; -AX: 'AX'; -BX: 'BX'; -CX: 'CX'; -DX: 'DX'; -CI: 'CI'; -DI: 'DI'; -BP: 'BP'; -SP: 'SP'; -IP: 'IP'; -CS: 'CS'; -DS: 'DS'; -ES: 'ES'; -SS: 'SS'; - -AAA: 'AAA'; -AAD: 'AAD'; -AAM: 'AAM'; -AAS: 'AAS'; -ADC: 'ADC'; -ADD: 'ADD'; -AND: 'AND'; -CALL: 'CALL'; -CBW: 'CBW'; -CLC: 'CLC'; -CLD: 'CLD'; -CLI: 'CLI'; -CMC: 'CMC'; -CMP: 'CMP'; -CMPSB: 'CMPSB'; -CMPSW: 'CMPSW'; -CWD: 'CWD'; -DAA: 'DAA'; -DAS: 'DAS'; -DEC: 'DEC'; -DIV: 'DIV'; -ESC: 'ESC'; -HLT: 'HLT'; -IDIV: 'IDIV'; -IMUL: 'IMUL'; -IN: 'IN'; -INC: 'INC'; -INT: 'INT'; -INTO: 'INTO'; -IRET: 'IRET'; -JA: 'JA'; -JAE: 'JAE'; -JB: 'JB'; -JBE: 'JBE'; -JC: 'JC'; -JE: 'JE'; -JG: 'JG'; -JGE: 'JGE'; -JL: 'JL'; -JLE: 'JLE'; -JNA: 'JNA'; -JNAE: 'JNAE'; -JNB: 'JNB'; -JNBE: 'JNBE'; -JNC: 'JNC'; -JNE: 'JNE'; -JNG: 'JNG'; -JNGE: 'JNGE'; -JNL: 'JNL'; -JNLE: 'JNLE'; -JNO: 'JNO'; -JNP: 'JNP'; -JNS: 'JNS'; -JNZ: 'JNZ'; -JO: 'JO'; -JP: 'JP'; -JPE: 'JPE'; -JPO: 'JPO'; -JS: 'JS'; -JZ: 'JZ'; -JCXZ: 'JCXZ'; -JMP: 'JMP'; -JMPS: 'JMPS'; -JMPF: 'JMPF'; -LAHF: 'LAHF'; -LDS: 'LDS'; -LEA: 'LEA'; -LES: 'LES'; -LOCK: 'LOCK'; -LODS: 'LODS'; -LODSB: 'LODSB'; -LODSW: 'LODSW'; -LOOP: 'LOOP'; -LOOPE: 'LOOPE'; -LOOPNE: 'LOOPNE'; -LOOPNZ: 'LOOPNZ'; -LOOPZ: 'LOOPZ'; -MOV: 'MOV'; -MOVS: 'MOVS'; -MOVSB: 'MOVSB'; -MOVSW: 'MOVSW'; -MUL: 'MUL'; -NEG: 'NEG'; -NOP: 'NOP'; -NOT: 'NOT'; -OR: 'OR'; -OUT: 'OUT'; -POP: 'POP'; -POPF: 'POPF'; -PUSH: 'PUSH'; -PUSHF: 'PUSHF'; -RCL: 'RCL'; -RCR: 'RCR'; -RET: 'RET'; -RETN: 'RETN'; -RETF: 'RETF'; -ROL: 'ROL'; -ROR: 'ROR'; -SAHF: 'SAHF'; -SAL: 'SAL'; -SAR: 'SAR'; -SALC: 'SALC'; -SBB: 'SBB'; -SCASB: 'SCASB'; -SCASW: 'SCASW'; -SHL: 'SHL'; -SHR: 'SHR'; -STC: 'STC'; -STD: 'STD'; -STI: 'STI'; -STOSB: 'STOSB'; -STOSW: 'STOSW'; -SUB: 'SUB'; -TEST: 'TEST'; -WAIT: 'WAIT'; -XCHG: 'XCHG'; -XLAT: 'XLAT'; -XOR: 'XOR'; - -REP: 'REP'; -REPE: 'REPE'; -REPNE: 'REPNE'; -REPNZ: 'REPNZ'; -REPZ: 'REPZ'; - - -STAR : '*' ; -SLASH : '/' ; -DOLLAR : '$' ; -PLUS : '+' ; -MINUS : '-' ; -NOT_ : '!' ; -COLON : ':' ; -DOT : '.' ; -RP : '(' ; -LP : ')' ; -COMMA : ',' ; -SEMI : ';' ; -LB : '[' ; -RB_ : ']' ; + : ';' ~ [\r\n]* -> skip + ; + +AH + : 'AH' + ; + +AL + : 'AL' + ; + +BH + : 'BH' + ; + +BL + : 'BL' + ; + +CH + : 'CH' + ; + +CL + : 'CL' + ; + +DH + : 'DH' + ; + +DL + : 'DL' + ; + +AX + : 'AX' + ; + +BX + : 'BX' + ; + +CX + : 'CX' + ; + +DX + : 'DX' + ; + +CI + : 'CI' + ; + +DI + : 'DI' + ; + +BP + : 'BP' + ; + +SP + : 'SP' + ; + +IP + : 'IP' + ; + +CS + : 'CS' + ; + +DS + : 'DS' + ; + +ES + : 'ES' + ; + +SS + : 'SS' + ; + +AAA + : 'AAA' + ; + +AAD + : 'AAD' + ; + +AAM + : 'AAM' + ; + +AAS + : 'AAS' + ; + +ADC + : 'ADC' + ; + +ADD + : 'ADD' + ; + +AND + : 'AND' + ; + +CALL + : 'CALL' + ; + +CBW + : 'CBW' + ; + +CLC + : 'CLC' + ; + +CLD + : 'CLD' + ; + +CLI + : 'CLI' + ; + +CMC + : 'CMC' + ; + +CMP + : 'CMP' + ; + +CMPSB + : 'CMPSB' + ; + +CMPSW + : 'CMPSW' + ; + +CWD + : 'CWD' + ; + +DAA + : 'DAA' + ; + +DAS + : 'DAS' + ; + +DEC + : 'DEC' + ; + +DIV + : 'DIV' + ; + +ESC + : 'ESC' + ; + +HLT + : 'HLT' + ; + +IDIV + : 'IDIV' + ; + +IMUL + : 'IMUL' + ; + +IN + : 'IN' + ; + +INC + : 'INC' + ; + +INT + : 'INT' + ; + +INTO + : 'INTO' + ; + +IRET + : 'IRET' + ; + +JA + : 'JA' + ; + +JAE + : 'JAE' + ; + +JB + : 'JB' + ; + +JBE + : 'JBE' + ; + +JC + : 'JC' + ; + +JE + : 'JE' + ; + +JG + : 'JG' + ; + +JGE + : 'JGE' + ; + +JL + : 'JL' + ; + +JLE + : 'JLE' + ; + +JNA + : 'JNA' + ; + +JNAE + : 'JNAE' + ; + +JNB + : 'JNB' + ; + +JNBE + : 'JNBE' + ; + +JNC + : 'JNC' + ; + +JNE + : 'JNE' + ; + +JNG + : 'JNG' + ; + +JNGE + : 'JNGE' + ; + +JNL + : 'JNL' + ; + +JNLE + : 'JNLE' + ; + +JNO + : 'JNO' + ; + +JNP + : 'JNP' + ; + +JNS + : 'JNS' + ; + +JNZ + : 'JNZ' + ; + +JO + : 'JO' + ; + +JP + : 'JP' + ; + +JPE + : 'JPE' + ; + +JPO + : 'JPO' + ; + +JS + : 'JS' + ; + +JZ + : 'JZ' + ; + +JCXZ + : 'JCXZ' + ; + +JMP + : 'JMP' + ; + +JMPS + : 'JMPS' + ; + +JMPF + : 'JMPF' + ; + +LAHF + : 'LAHF' + ; + +LDS + : 'LDS' + ; + +LEA + : 'LEA' + ; + +LES + : 'LES' + ; + +LOCK + : 'LOCK' + ; + +LODS + : 'LODS' + ; + +LODSB + : 'LODSB' + ; + +LODSW + : 'LODSW' + ; + +LOOP + : 'LOOP' + ; + +LOOPE + : 'LOOPE' + ; + +LOOPNE + : 'LOOPNE' + ; + +LOOPNZ + : 'LOOPNZ' + ; + +LOOPZ + : 'LOOPZ' + ; + +MOV + : 'MOV' + ; + +MOVS + : 'MOVS' + ; + +MOVSB + : 'MOVSB' + ; + +MOVSW + : 'MOVSW' + ; + +MUL + : 'MUL' + ; + +NEG + : 'NEG' + ; + +NOP + : 'NOP' + ; + +NOT + : 'NOT' + ; + +OR + : 'OR' + ; + +OUT + : 'OUT' + ; + +POP + : 'POP' + ; + +POPF + : 'POPF' + ; + +PUSH + : 'PUSH' + ; + +PUSHF + : 'PUSHF' + ; + +RCL + : 'RCL' + ; + +RCR + : 'RCR' + ; + +RET + : 'RET' + ; + +RETN + : 'RETN' + ; + +RETF + : 'RETF' + ; + +ROL + : 'ROL' + ; + +ROR + : 'ROR' + ; + +SAHF + : 'SAHF' + ; + +SAL + : 'SAL' + ; + +SAR + : 'SAR' + ; + +SALC + : 'SALC' + ; + +SBB + : 'SBB' + ; + +SCASB + : 'SCASB' + ; + +SCASW + : 'SCASW' + ; + +SHL + : 'SHL' + ; + +SHR + : 'SHR' + ; + +STC + : 'STC' + ; + +STD + : 'STD' + ; + +STI + : 'STI' + ; + +STOSB + : 'STOSB' + ; + +STOSW + : 'STOSW' + ; + +SUB + : 'SUB' + ; + +TEST + : 'TEST' + ; + +WAIT + : 'WAIT' + ; + +XCHG + : 'XCHG' + ; + +XLAT + : 'XLAT' + ; + +XOR + : 'XOR' + ; + +REP + : 'REP' + ; + +REPE + : 'REPE' + ; + +REPNE + : 'REPNE' + ; + +REPNZ + : 'REPNZ' + ; + +REPZ + : 'REPZ' + ; + +STAR + : '*' + ; + +SLASH + : '/' + ; + +DOLLAR + : '$' + ; + +PLUS + : '+' + ; + +MINUS + : '-' + ; + +NOT_ + : '!' + ; + +COLON + : ':' + ; + +DOT + : '.' + ; + +RP + : '(' + ; + +LP + : ')' + ; + +COMMA + : ',' + ; + +SEMI + : ';' + ; + +LB + : '[' + ; +RB_ + : ']' + ; NAME - : [.A-Z] [A-Z0-9."_]* - ; + : [.A-Z] [A-Z0-9."_]* + ; NUMBER - : [0-9A-F] + 'H'? - ; + : [0-9A-F]+ 'H'? + ; STRING - : '\u0027' ~'\u0027'* '\u0027' - ; + : '\u0027' ~'\u0027'* '\u0027' + ; EOL - : [\r\n] + - ; + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/asm/asmMASM/asmMASM.g4 b/asm/asmMASM/asmMASM.g4 index c9b21190d2..c9fb07533f 100644 --- a/asm/asmMASM/asmMASM.g4 +++ b/asm/asmMASM/asmMASM.g4 @@ -30,259 +30,313 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar asmMASM; -options { caseInsensitive=true; } +options { + caseInsensitive = true; +} prog - : line* EOF - ; + : line* EOF + ; line - : (lbl | endlbl)? (assemblerdirective | masmdirectives | instruction)? EOL - ; + : (lbl | endlbl)? (assemblerdirective | masmdirectives | instruction)? EOL + ; instruction - : rep? opcode expressionlist? - ; + : rep? opcode expressionlist? + ; lbl - : label ':'? - ; + : label ':'? + ; endlbl - : END name? - ; + : END name? + ; assemblerdirective - : org - | if_ - | endif_ - | equ - | db - | dw - | dm - | ds - | include - | includelib - | invoke - | option - | put - | assign - | segment - | endsegment - | group - | label_ - | assume - | extern_ - | public_ - | type_ expressionlist+ - ; + : org + | if_ + | endif_ + | equ + | db + | dw + | dm + | ds + | include + | includelib + | invoke + | option + | put + | assign + | segment + | endsegment + | group + | label_ + | assume + | extern_ + | public_ + | type_ expressionlist+ + ; masmdirectives - : masmdirective+ - ; + : masmdirective+ + ; masmdirective - : MASMDIRECTIVE expressionlist? - ; + : MASMDIRECTIVE expressionlist? + ; assume - : ASSUME register_ ':' name (',' register_ ':' name)* - ; + : ASSUME register_ ':' name (',' register_ ':' name)* + ; label_ - : name LABEL type_ - ; + : name LABEL type_ + ; type_ - : BYTE - | SBYTE - | WORD - | DWORD - ; + : BYTE + | SBYTE + | WORD + | DWORD + ; group - : name GROUP name (',' name)* - ; + : name GROUP name (',' name)* + ; segment - : name SEGMENT align? - ; + : name SEGMENT align? + ; endsegment - : name SEGMENTEND - ; + : name SEGMENTEND + ; align - : BYTE | WORD | DWORD | PARA | PAGE - | ALIGN '(' number ')' - ; + : BYTE + | WORD + | DWORD + | PARA + | PAGE + | ALIGN '(' number ')' + ; assign - : name ASSIGN expression - ; + : name ASSIGN expression + ; put - : PUT expressionlist - ; + : PUT expressionlist + ; include - : INCLUDE expressionlist - ; + : INCLUDE expressionlist + ; includelib - : INCLUDELIB expressionlist - ; + : INCLUDELIB expressionlist + ; invoke - : INVOKE expressionlist - ; + : INVOKE expressionlist + ; option - : OPTION expressionlist - ; + : OPTION expressionlist + ; ds - : DS expressionlist - ; + : DS expressionlist + ; dw - : DW expressionlist - ; + : DW expressionlist + ; db - : DB expressionlist - ; + : DB expressionlist + ; dm - : DM expressionlist - ; + : DM expressionlist + ; dup - : number DUP expression - ; + : number DUP expression + ; equ - : EQU expression - ; + : EQU expression + ; extern_ - : EXTERN expression - ; + : EXTERN expression + ; public_ - : PUBLIC expression - ; + : PUBLIC expression + ; if_ - : IF expression - ; + : IF expression + ; endif_ - : ENDIF - ; + : ENDIF + ; org - : ORG expression - ; + : ORG expression + ; expressionlist - : expression (',' expression)* - ; + : expression (',' expression)* + ; label - : name - | gross - ; + : name + | gross + ; expression - : multiplyingExpression (SIGN multiplyingExpression)* - ; + : multiplyingExpression (SIGN multiplyingExpression)* + ; multiplyingExpression - : argument (('*' | '/') argument)* - ; + : argument (('*' | '/') argument)* + ; argument - : number - | dollar - | ques - | register_ - | (name ':')? name - | string - | '(' expression ')' - | '[' expression ']' - | NOT expression - | OFFSET expression - | gross - | dup - ; + : number + | dollar + | ques + | register_ + | (name ':')? name + | string + | '(' expression ')' + | '[' expression ']' + | NOT expression + | OFFSET expression + | gross + | dup + ; /* MASM allows opcode names such as "RET" to be label names and also allows assemlber directives such as "PUT" as names */ gross - : opcode - | grossrawassemblerdirective - ; + : opcode + | grossrawassemblerdirective + ; grossrawassemblerdirective - : PUT - | IF - | ENDIF - | ORG - | EQU - ; + : PUT + | IF + | ENDIF + | ORG + | EQU + ; dollar - : DOLLAR - ; + : DOLLAR + ; ques - : QUES - ; + : QUES + ; register_ - : REGISTER - ; + : REGISTER + ; string - : STRING1 - | STRING2 - ; + : STRING1 + | STRING2 + ; name - : NAME - ; + : NAME + ; number - : SIGN? NUMBER - ; + : SIGN? NUMBER + ; opcode - : OPCODE - ; + : OPCODE + ; rep - : REP - ; - -ORG: 'ORG'; -END: 'END'; -ENDIF: 'ENDIF'; -IF: 'IF'; -EQU: 'EQU'; -DW: 'DW'; -DB: 'DB'; -DM: 'DM'; -DS: 'DS'; -INCLUDE: 'INCLUDE'; -INCLUDELIB: 'INCLUDELIB'; -INVOKE: 'INVOKE'; -OPTION: 'OPTION'; -PUT: 'PUT'; -NOT: 'NOT'; + : REP + ; + +ORG + : 'ORG' + ; + +END + : 'END' + ; + +ENDIF + : 'ENDIF' + ; + +IF + : 'IF' + ; + +EQU + : 'EQU' + ; + +DW + : 'DW' + ; + +DB + : 'DB' + ; + +DM + : 'DM' + ; + +DS + : 'DS' + ; + +INCLUDE + : 'INCLUDE' + ; + +INCLUDELIB + : 'INCLUDELIB' + ; + +INVOKE + : 'INVOKE' + ; + +OPTION + : 'OPTION' + ; + +PUT + : 'PUT' + ; + +NOT + : 'NOT' + ; + REGISTER : 'AH' | 'AL' @@ -426,74 +480,123 @@ OPCODE | 'XOR' ; -REP : 'REP' +REP + : 'REP' | 'REPE' | 'REPNE' | 'REPNZ' | 'REPZ' ; -OFFSET: 'OFFSET'; -SEGMENT: 'SEGMENT'; -SEGMENTEND: 'ENDS'; -GROUP: 'GROUP'; -BYTE: 'BYTE'; -SBYTE: 'SBYTE'; -WORD: 'WORD'; -DWORD: 'DWORD'; -PARA: 'PARA'; -PAGE: 'PAGE'; -ALIGN: 'ALIGN'; -LABEL: 'LABEL'; -DUP: 'DUP'; -ASSUME: 'ASSUME'; -EXTERN: 'EXTERN'; -PUBLIC: 'PUBLIC'; - -ASSIGN: '='; -DOLLAR: '$'; -QUES: '?'; +OFFSET + : 'OFFSET' + ; +SEGMENT + : 'SEGMENT' + ; -SIGN - : '+' | '-' - ; +SEGMENTEND + : 'ENDS' + ; +GROUP + : 'GROUP' + ; -MASMDIRECTIVE - : '.' [A-Z0-9] + - ; +BYTE + : 'BYTE' + ; +SBYTE + : 'SBYTE' + ; -NAME - : [_A-Z] [A-Z0-9._@]* - ; +WORD + : 'WORD' + ; +DWORD + : 'DWORD' + ; -NUMBER - : [0-9A-F] + 'H'? - ; +PARA + : 'PARA' + ; +PAGE + : 'PAGE' + ; -STRING1 - : '"' ~'"'* '"' - ; +ALIGN + : 'ALIGN' + ; +LABEL + : 'LABEL' + ; -STRING2 - : '\u0027' ~'\u0027'* '\u0027' - ; +DUP + : 'DUP' + ; +ASSUME + : 'ASSUME' + ; + +EXTERN + : 'EXTERN' + ; + +PUBLIC + : 'PUBLIC' + ; + +ASSIGN + : '=' + ; + +DOLLAR + : '$' + ; + +QUES + : '?' + ; + +SIGN + : '+' + | '-' + ; + +MASMDIRECTIVE + : '.' [A-Z0-9]+ + ; + +NAME + : [_A-Z] [A-Z0-9._@]* + ; + +NUMBER + : [0-9A-F]+ 'H'? + ; + +STRING1 + : '"' ~'"'* '"' + ; + +STRING2 + : '\u0027' ~'\u0027'* '\u0027' + ; COMMENT - : ';' ~ [\r\n]* -> skip - ; + : ';' ~ [\r\n]* -> skip + ; EOL - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/asm/asmZ80/asmZ80.g4 b/asm/asmZ80/asmZ80.g4 index 35f50b0b96..934a2e880c 100644 --- a/asm/asmZ80/asmZ80.g4 +++ b/asm/asmZ80/asmZ80.g4 @@ -33,92 +33,118 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * http://fms.komkon.org/comp/CPUs/z80.txt */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar asmZ80; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} prog - : EOL* ((line EOL)* line EOL*)? EOF - ; + : EOL* ((line EOL)* line EOL*)? EOF + ; line - : lbl? (instruction | directive) comment? - | lbl comment? - | comment - ; + : lbl? (instruction | directive) comment? + | lbl comment? + | comment + ; instruction - : opcode expressionlist? - ; + : opcode expressionlist? + ; opcode - : OPCODE - ; + : OPCODE + ; register_ - : REGISTER - ; + : REGISTER + ; directive - : argument? assemblerdirective expressionlist - ; + : argument? assemblerdirective expressionlist + ; assemblerdirective - : ASSEMBLER_DIRECTIVE - ; + : ASSEMBLER_DIRECTIVE + ; lbl - : label ':'? - ; + : label ':'? + ; expressionlist - : expression (',' expression)* - ; + : expression (',' expression)* + ; label - : name - ; + : name + ; expression - : multiplyingExpression (('+' | '-') multiplyingExpression)* - ; + : multiplyingExpression (('+' | '-') multiplyingExpression)* + ; multiplyingExpression - : argument (('*' | '/') argument)* - ; + : argument (('*' | '/') argument)* + ; argument - : number - | register_ - | dollar - | name - | string_ - | '(' expression ')' - ; + : number + | register_ + | dollar + | name + | string_ + | '(' expression ')' + ; dollar - : '$' - ; + : '$' + ; string_ - : STRING - ; + : STRING + ; name - : NAME - ; + : NAME + ; number - : NUMBER - ; + : NUMBER + ; comment - : COMMENT - ; + : COMMENT + ; REGISTER - : 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'H' | 'L' | 'I' | 'R' | 'IXH' | 'IXL' | 'IYH' | 'IYL' | 'AF' | 'BC' | 'DE' | 'HL' | 'PC' | 'SP' | 'IX' | 'IY' - ; + : 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + | 'H' + | 'L' + | 'I' + | 'R' + | 'IXH' + | 'IXL' + | 'IYH' + | 'IYL' + | 'AF' + | 'BC' + | 'DE' + | 'HL' + | 'PC' + | 'SP' + | 'IX' + | 'IY' + ; ASSEMBLER_DIRECTIVE : 'ORG' @@ -200,28 +226,28 @@ OPCODE | 'SRL' | 'SUB' | 'XOR' - ; + ; NAME - : [A-Z] [A-Z0-9."]* - ; + : [A-Z] [A-Z0-9."]* + ; NUMBER - : '$'? [0-9A-F]+ 'H'? - ; + : '$'? [0-9A-F]+ 'H'? + ; COMMENT - : ';' ~ [\r\n]* - ; + : ';' ~ [\r\n]* + ; STRING - : '\u0027' ~'\u0027'* '\u0027' - ; + : '\u0027' ~'\u0027'* '\u0027' + ; EOL - : [\r\n] + - ; + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/asm/masm/MASM.g4 b/asm/masm/MASM.g4 index 9b4af997a8..d94d63690a 100644 --- a/asm/masm/MASM.g4 +++ b/asm/masm/MASM.g4 @@ -1,4 +1,3 @@ - /** This grammar is generated with antlrworks in order to parse an asm source code.First of all the lexical rules established here do not replace the ones @@ -9,1798 +8,1540 @@ to provide the necessary tokens for the parser. /* Ported to Antlr4 by Tom Everett */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar MASM; compilationUnit - : (segments | directive_exp1)* 'end' Identifier EOF - ; + : (segments | directive_exp1)* 'end' Identifier EOF + ; segments - : Identifier 'segments' 'para' 'public' (code | proc)* Identifier 'ends' - ; + : Identifier 'segments' 'para' 'public' (code | proc)* Identifier 'ends' + ; proc - : Identifier 'proc' code* 'ret' Identifier 'endp' - ; + : Identifier 'proc' code* 'ret' Identifier 'endp' + ; code - : binary_exp1 - | binary_exp10 - | binary_exp11 - | binary_exp12 - | binary_exp2 - | binary_exp3 - | binary_exp4 - | binary_exp5 - | binary_exp6 - | binary_exp7 - | binary_exp8 - | binary_exp9 - | unuary_exp1 - | unuary_exp2 - | unuary_exp3 - | unuary_exp4 - | unuary_exp5 - | notarguments - | variabledeclaration - | directive_exp1 - ; + : binary_exp1 + | binary_exp10 + | binary_exp11 + | binary_exp12 + | binary_exp2 + | binary_exp3 + | binary_exp4 + | binary_exp5 + | binary_exp6 + | binary_exp7 + | binary_exp8 + | binary_exp9 + | unuary_exp1 + | unuary_exp2 + | unuary_exp3 + | unuary_exp4 + | unuary_exp5 + | notarguments + | variabledeclaration + | directive_exp1 + ; binary_exp1 - : o register_ Separator (register_ | Integer | memory) - | o memory Separator (register_ | Integer) - ; + : o register_ Separator (register_ | Integer | memory) + | o memory Separator (register_ | Integer) + ; unuary_exp1 - : op (Integer | register_ | memory) - ; + : op (Integer | register_ | memory) + ; unuary_exp2 - : ope (register_ | memory) - ; + : ope (register_ | memory) + ; binary_exp2 - : oper register_ Separator (register_ | memory) - | oper memory Separator register_ - ; + : oper register_ Separator (register_ | memory) + | oper memory Separator register_ + ; notarguments - : opera - ; + : opera + ; binary_exp3 - : operat (register_ | memory) Separator (register_ | Integer | memory) - ; + : operat (register_ | memory) Separator (register_ | Integer | memory) + ; unuary_exp3 - : operato Identifier - ; + : operato Identifier + ; binary_exp4 - : operator_ register_ Separator (register_ | memory) - ; + : operator_ register_ Separator (register_ | memory) + ; binary_exp5 - : l register_ Separator memory - ; + : l register_ Separator memory + ; binary_exp6 - : x (register_ | memory) Separator register_ - ; + : x (register_ | memory) Separator register_ + ; binary_exp7 - : s (register_ | memory) Separator (Integer | register_) - ; + : s (register_ | memory) Separator (Integer | register_) + ; binary_exp8 - : sh (register_ | memory) Separator register_ Separator (register_ | Integer) - ; + : sh (register_ | memory) Separator register_ Separator (register_ | Integer) + ; binary_exp9 - : b (register_ | memory) Separator (register_ | memory) - ; + : b (register_ | memory) Separator (register_ | memory) + ; unuary_exp4 - : call (register_ | memory | Integer) - ; + : call (register_ | memory | Integer) + ; unuary_exp5 - : interruption Integer - ; + : interruption Integer + ; binary_exp10 - : in_ register_ Separator (register_ | Integer) - ; + : in_ register_ Separator (register_ | Integer) + ; binary_exp11 - : out (register_ | Integer) Separator register_ - ; + : out (register_ | Integer) Separator register_ + ; binary_exp12 - : re opera - ; + : re opera + ; directive_exp1 - : directives Identifier - | directives - ; + : directives Identifier + | directives + ; variabledeclaration - : Identifier ty (question | String_ | Integer) - ; + : Identifier ty (question | String_ | Integer) + ; memory - : '[' (register_ | Identifier) ('+' (register_ ('+' (Integer | Hexnum | Octalnum))? | Integer | Hexnum | Octalnum))? ']' - ; + : '[' (register_ | Identifier) ( + '+' (register_ ('+' (Integer | Hexnum | Octalnum))? | Integer | Hexnum | Octalnum) + )? ']' + ; segmentos - : DS - | ES - | CS - | SS - | GS - | FS - ; + : DS + | ES + | CS + | SS + | GS + | FS + ; register_ - : AH - | AL - | AX - | BH - | BL - | BX - | CH - | CL - | CX - | DH - | DL - | DX - | SI - | DI - | SP - | BP - | EAX - | EBX - | ECX - | EDX - | ESI - | EDI - | ESP - | EBP - ; + : AH + | AL + | AX + | BH + | BL + | BX + | CH + | CL + | CX + | DH + | DL + | DX + | SI + | DI + | SP + | BP + | EAX + | EBX + | ECX + | EDX + | ESI + | EDI + | ESP + | EBP + ; o - : MOV - | CMP - | TEST - ; + : MOV + | CMP + | TEST + ; op - : PUSH - ; + : PUSH + ; ope - : POP - | IDIV - | INC - | DEC - | NEG - | MUL - | DIV - | IMUL - | NOT - | SETPO - | SETAE - | SETNLE - | SETC - | SETNO - | SETNB - | SETP - | SETNGE - | SETL - | SETGE - | SETPE - | SETNL - | SETNZ - | SETNE - | SETNC - | SETBE - | SETNP - | SETNS - | SETO - | SETNA - | SETNAE - | SETZ - | SETLE - | SETNBE - | SETS - | SETE - | SETB - | SETA - | SETG - | SETNG - ; + : POP + | IDIV + | INC + | DEC + | NEG + | MUL + | DIV + | IMUL + | NOT + | SETPO + | SETAE + | SETNLE + | SETC + | SETNO + | SETNB + | SETP + | SETNGE + | SETL + | SETGE + | SETPE + | SETNL + | SETNZ + | SETNE + | SETNC + | SETBE + | SETNP + | SETNS + | SETO + | SETNA + | SETNAE + | SETZ + | SETLE + | SETNBE + | SETS + | SETE + | SETB + | SETA + | SETG + | SETNG + ; oper - : XCHG - ; + : XCHG + ; opera - : POPAD - | AAA - | POPA - | POPFD - | CWD - | LAHF - | PUSHAD - | PUSHF - | AAS - | BSWAP - | PUSHFD - | CBW - | CWDE - | XLAT - | AAM - | AAD - | CDQ - | DAA - | SAHF - | DAS - | INTO - | IRET - | CLC - | STC - | CMC - | CLD - | STD - | CLI - | STI - | MOVSB - | MOVSW - | MOVSD - | LODS - | LODSB - | LODSW - | LODSD - | STOS - | STOSB - | STOSW - | SOTSD - | SCAS - | SCASB - | SCASW - | SCASD - | CMPS - | CMPSB - | CMPSW - | CMPSD - | INSB - | INSW - | INSD - | OUTSB - | OUTSW - | OUTSD - ; + : POPAD + | AAA + | POPA + | POPFD + | CWD + | LAHF + | PUSHAD + | PUSHF + | AAS + | BSWAP + | PUSHFD + | CBW + | CWDE + | XLAT + | AAM + | AAD + | CDQ + | DAA + | SAHF + | DAS + | INTO + | IRET + | CLC + | STC + | CMC + | CLD + | STD + | CLI + | STI + | MOVSB + | MOVSW + | MOVSD + | LODS + | LODSB + | LODSW + | LODSD + | STOS + | STOSB + | STOSW + | SOTSD + | SCAS + | SCASB + | SCASW + | SCASD + | CMPS + | CMPSB + | CMPSW + | CMPSD + | INSB + | INSW + | INSD + | OUTSB + | OUTSW + | OUTSD + ; operat - : ADC - | ADD - | SUB - | CBB - | XOR - | OR - ; + : ADC + | ADD + | SUB + | CBB + | XOR + | OR + ; operato - : JNBE - | JNZ - | JPO - | JZ - | JS - | LOOPNZ - | JGE - | JB - | JNB - | JO - | JP - | JNO - | JNL - | JNAE - | LOOPZ - | JMP - | JNP - | LOOP - | JL - | JCXZ - | JAE - | JNGE - | JA - | LOOPNE - | LOOPE - | JG - | JNLE - | JE - | JNC - | JC - | JNA - | JBE - | JLE - | JPE - | JNS - | JECXZ - | JNG - ; + : JNBE + | JNZ + | JPO + | JZ + | JS + | LOOPNZ + | JGE + | JB + | JNB + | JO + | JP + | JNO + | JNL + | JNAE + | LOOPZ + | JMP + | JNP + | LOOP + | JL + | JCXZ + | JAE + | JNGE + | JA + | LOOPNE + | LOOPE + | JG + | JNLE + | JE + | JNC + | JC + | JNA + | JBE + | JLE + | JPE + | JNS + | JECXZ + | JNG + ; operator_ - : MOVZX - | BSF - | BSR - ; + : MOVZX + | BSF + | BSR + ; l - : LES - | LEA - | LDS - | INS - | OUTS - ; + : LES + | LEA + | LDS + | INS + | OUTS + ; x - : XADD - | CMPXCHG - ; + : XADD + | CMPXCHG + ; s - : SHL - | SHR - | ROR - | ROL - | RCL - | SAL - | RCR - | SAR - ; + : SHL + | SHR + | ROR + | ROL + | RCL + | SAL + | RCR + | SAR + ; sh - : SHRD - | SHLD - ; + : SHRD + | SHLD + ; b - : BTR - | BT - | BTC - ; + : BTR + | BT + | BTC + ; call - : CALL - ; + : CALL + ; interruption - : INT - | RETN - | RET - | RETF - ; + : INT + | RETN + | RET + | RETF + ; in_ - : IN - ; + : IN + ; out - : OUT - ; + : OUT + ; re - : REP - | REPE - | REPZ - | REPNE - | REPNZ - ; + : REP + | REPE + | REPZ + | REPNE + | REPNZ + ; directives - : ALPHA - | CONST - | CREF - | XCREF - | DATA - | DATA2 - | DOSSEG - | ERR - | ERR1 - | ERR2 - | ERRE - | ERRNZ - | ERRDEF - | ERRNDEF - | ERRB - | ERRNB - | ERRIDN - | ERRDIF - | EVEN - | LIST - | WIDTH - | MASK - | SEQ - | XLIST - | EXIT - | MODEL - ; + : ALPHA + | CONST + | CREF + | XCREF + | DATA + | DATA2 + | DOSSEG + | ERR + | ERR1 + | ERR2 + | ERRE + | ERRNZ + | ERRDEF + | ERRNDEF + | ERRB + | ERRNB + | ERRIDN + | ERRDIF + | EVEN + | LIST + | WIDTH + | MASK + | SEQ + | XLIST + | EXIT + | MODEL + ; ty - : BYTE - | SBYTE - | DB - | WORD - | SWORD - | DW - | DWORD - | SDWORD - | DD - | FWORD - | DF - | QWORD - | DQ - | TBYTE - | DT - | REAL4 - | REAL8 - | REAL - | FAR - | NEAR - | PROC - ; + : BYTE + | SBYTE + | DB + | WORD + | SWORD + | DW + | DWORD + | SDWORD + | DD + | FWORD + | DF + | QWORD + | DQ + | TBYTE + | DT + | REAL4 + | REAL8 + | REAL + | FAR + | NEAR + | PROC + ; question - : QUESTION - ; + : QUESTION + ; time - : TIMES - ; - + : TIMES + ; Identifier - : Letter ('_' | Letter | Digit)* - ; - + : Letter ('_' | Letter | Digit)* + ; DS - : 'ds' - ; - + : 'ds' + ; ES - : 'es' - ; - + : 'es' + ; CS - : 'cs' - ; - + : 'cs' + ; SS - : 'ss' - ; - + : 'ss' + ; GS - : 'gs' - ; - + : 'gs' + ; FS - : 'fs' - ; - + : 'fs' + ; AH - : 'ah' - ; - + : 'ah' + ; AL - : 'al' - ; - + : 'al' + ; AX - : 'ax' - ; - + : 'ax' + ; BH - : 'bh' - ; - + : 'bh' + ; BL - : 'bl' - ; - + : 'bl' + ; BX - : 'bx' - ; - + : 'bx' + ; CH - : 'ch' - ; - + : 'ch' + ; CL - : 'cl' - ; - + : 'cl' + ; CX - : 'cx' - ; - + : 'cx' + ; DH - : 'dh' - ; - + : 'dh' + ; DL - : 'dl' - ; - + : 'dl' + ; DX - : 'dx' - ; - + : 'dx' + ; SI - : 'si' - ; - + : 'si' + ; DI - : 'di' - ; - + : 'di' + ; SP - : 'sp' - ; - + : 'sp' + ; BP - : 'bp' - ; - + : 'bp' + ; EAX - : 'eax' - ; - + : 'eax' + ; EBX - : 'ebx' - ; - + : 'ebx' + ; ECX - : 'ecx' - ; - + : 'ecx' + ; EDX - : 'edx' - ; - + : 'edx' + ; ESI - : 'esi' - ; - + : 'esi' + ; EDI - : 'edi' - ; - + : 'edi' + ; ESP - : 'esp' - ; - + : 'esp' + ; EBP - : 'ebp' - ; - + : 'ebp' + ; MOV - : 'mov' - ; - + : 'mov' + ; CMP - : 'cmp' - ; - + : 'cmp' + ; TEST - : 'test' - ; - + : 'test' + ; PUSH - : 'push' - ; - + : 'push' + ; POP - : 'pop' - ; - + : 'pop' + ; IDIV - : 'idiv' - ; - + : 'idiv' + ; INC - : 'inc' - ; - + : 'inc' + ; DEC - : 'dec' - ; - + : 'dec' + ; NEG - : 'neg' - ; - + : 'neg' + ; MUL - : 'mul' - ; - + : 'mul' + ; DIV - : 'div' - ; - + : 'div' + ; IMUL - : 'imul' - ; - + : 'imul' + ; NOT - : 'not' - ; - + : 'not' + ; SETPO - : 'setpo' - ; - + : 'setpo' + ; SETAE - : 'setae' - ; - + : 'setae' + ; SETNLE - : 'setnle' - ; - + : 'setnle' + ; SETC - : 'setc' - ; - + : 'setc' + ; SETNO - : 'setno' - ; - + : 'setno' + ; SETNB - : 'setnb' - ; - + : 'setnb' + ; SETP - : 'setp' - ; - + : 'setp' + ; SETNGE - : 'setnge' - ; - + : 'setnge' + ; SETL - : 'setl' - ; - + : 'setl' + ; SETGE - : 'setge' - ; - + : 'setge' + ; SETPE - : 'setpe' - ; - + : 'setpe' + ; SETNL - : 'setnl' - ; - + : 'setnl' + ; SETNZ - : 'setnz' - ; - + : 'setnz' + ; SETNE - : 'setne' - ; - + : 'setne' + ; SETNC - : 'setnc' - ; - + : 'setnc' + ; SETBE - : 'setbe' - ; - + : 'setbe' + ; SETNP - : 'setnp' - ; - + : 'setnp' + ; SETNS - : 'setns' - ; - + : 'setns' + ; SETO - : 'seto' - ; - + : 'seto' + ; SETNA - : 'setna' - ; - + : 'setna' + ; SETNAE - : 'setnae' - ; - + : 'setnae' + ; SETZ - : 'setz' - ; - + : 'setz' + ; SETLE - : 'setle' - ; - + : 'setle' + ; SETNBE - : 'setnbe' - ; - + : 'setnbe' + ; SETS - : 'sets' - ; - + : 'sets' + ; SETE - : 'sete' - ; - + : 'sete' + ; SETB - : 'setb' - ; - + : 'setb' + ; SETA - : 'seta' - ; - + : 'seta' + ; SETG - : 'setg' - ; - + : 'setg' + ; SETNG - : 'setng' - ; - + : 'setng' + ; XCHG - : 'xchg' - ; - + : 'xchg' + ; POPAD - : 'popad' - ; - + : 'popad' + ; AAA - : 'aaa' - ; - + : 'aaa' + ; POPA - : 'popa' - ; - + : 'popa' + ; POPFD - : 'popfd' - ; - + : 'popfd' + ; CWD - : 'cwd' - ; - + : 'cwd' + ; LAHF - : 'lahf' - ; - + : 'lahf' + ; PUSHAD - : 'pushad' - ; - + : 'pushad' + ; PUSHF - : 'pushf' - ; - + : 'pushf' + ; AAS - : 'aas' - ; - + : 'aas' + ; BSWAP - : 'bswap' - ; - + : 'bswap' + ; PUSHFD - : 'pushfd' - ; - + : 'pushfd' + ; CBW - : 'cbw' - ; - + : 'cbw' + ; CWDE - : 'cwde' - ; - + : 'cwde' + ; XLAT - : 'xlat' - ; - + : 'xlat' + ; AAM - : 'aam' - ; - + : 'aam' + ; AAD - : 'aad' - ; - + : 'aad' + ; CDQ - : 'cdq' - ; - + : 'cdq' + ; DAA - : 'daa' - ; - + : 'daa' + ; SAHF - : 'sahf' - ; - + : 'sahf' + ; DAS - : 'das' - ; - + : 'das' + ; INTO - : 'into' - ; - + : 'into' + ; IRET - : 'iret' - ; - + : 'iret' + ; CLC - : 'clc' - ; - + : 'clc' + ; STC - : 'stc' - ; - + : 'stc' + ; CMC - : 'cmc' - ; - + : 'cmc' + ; CLD - : 'cld' - ; - + : 'cld' + ; STD - : 'std' - ; - + : 'std' + ; CLI - : 'cli' - ; - + : 'cli' + ; STI - : 'sti' - ; - + : 'sti' + ; MOVSB - : 'movsb' - ; - + : 'movsb' + ; MOVSW - : 'movsw' - ; - + : 'movsw' + ; MOVSD - : 'movsd' - ; - + : 'movsd' + ; LODS - : 'lods' - ; - + : 'lods' + ; LODSB - : 'lodsb' - ; - + : 'lodsb' + ; LODSW - : 'lodsw' - ; - + : 'lodsw' + ; LODSD - : 'lodsd' - ; - + : 'lodsd' + ; STOS - : 'stos' - ; - + : 'stos' + ; STOSB - : 'stosb' - ; - + : 'stosb' + ; STOSW - : 'stosw' - ; - + : 'stosw' + ; SOTSD - : 'sotsd' - ; - + : 'sotsd' + ; SCAS - : 'scas' - ; - + : 'scas' + ; SCASB - : 'scasb' - ; - + : 'scasb' + ; SCASW - : 'scasw' - ; - + : 'scasw' + ; SCASD - : 'scasd' - ; - + : 'scasd' + ; CMPS - : 'cmps' - ; - + : 'cmps' + ; CMPSB - : 'cmpsb' - ; - + : 'cmpsb' + ; CMPSW - : 'cmpsw' - ; - + : 'cmpsw' + ; CMPSD - : 'cmpsd' - ; - + : 'cmpsd' + ; INSB - : 'insb' - ; - + : 'insb' + ; INSW - : 'insw' - ; - + : 'insw' + ; INSD - : 'insd' - ; - + : 'insd' + ; OUTSB - : 'outsb' - ; - + : 'outsb' + ; OUTSW - : 'outsw' - ; - + : 'outsw' + ; OUTSD - : 'outsd' - ; - + : 'outsd' + ; ADC - : 'adc' - ; - + : 'adc' + ; ADD - : 'add' - ; - + : 'add' + ; SUB - : 'sub' - ; - + : 'sub' + ; CBB - : 'cbb' - ; - + : 'cbb' + ; XOR - : 'xor' - ; - + : 'xor' + ; OR - : 'or' - ; - + : 'or' + ; JNBE - : 'jnbe' - ; - + : 'jnbe' + ; JNZ - : 'jnz' - ; - + : 'jnz' + ; JPO - : 'jpo' - ; - + : 'jpo' + ; JZ - : 'jz' - ; - + : 'jz' + ; JS - : 'js' - ; - + : 'js' + ; LOOPNZ - : 'loopnz' - ; - + : 'loopnz' + ; JGE - : 'jge' - ; - + : 'jge' + ; JB - : 'jb' - ; - + : 'jb' + ; JNB - : 'jnb' - ; - + : 'jnb' + ; JO - : 'jo' - ; - + : 'jo' + ; JP - : 'jp' - ; - + : 'jp' + ; JNO - : 'jno' - ; - + : 'jno' + ; JNL - : 'jnl' - ; - + : 'jnl' + ; JNAE - : 'jnae' - ; - + : 'jnae' + ; LOOPZ - : 'loopz' - ; - + : 'loopz' + ; JMP - : 'jmp' - ; - + : 'jmp' + ; JNP - : 'jnp' - ; - + : 'jnp' + ; LOOP - : 'loop' - ; - + : 'loop' + ; JL - : 'jl' - ; - + : 'jl' + ; JCXZ - : 'jcxz' - ; - + : 'jcxz' + ; JAE - : 'jae' - ; - + : 'jae' + ; JNGE - : 'jnge' - ; - + : 'jnge' + ; JA - : 'ja' - ; - + : 'ja' + ; LOOPNE - : 'loopne' - ; - + : 'loopne' + ; LOOPE - : 'loope' - ; - + : 'loope' + ; JG - : 'jg' - ; - + : 'jg' + ; JNLE - : 'jnle' - ; - + : 'jnle' + ; JE - : 'je' - ; - + : 'je' + ; JNC - : 'jnc' - ; - + : 'jnc' + ; JC - : 'jc' - ; - + : 'jc' + ; JNA - : 'jna' - ; - + : 'jna' + ; JBE - : 'jbe' - ; - + : 'jbe' + ; JLE - : 'jle' - ; - + : 'jle' + ; JPE - : 'jpe' - ; - + : 'jpe' + ; JNS - : 'jns' - ; - + : 'jns' + ; JECXZ - : 'jecxz' - ; - + : 'jecxz' + ; JNG - : 'jng' - ; - + : 'jng' + ; MOVZX - : 'movzx' - ; - + : 'movzx' + ; BSF - : 'bsf' - ; - + : 'bsf' + ; BSR - : 'bsr' - ; - + : 'bsr' + ; LES - : 'les' - ; - + : 'les' + ; LEA - : 'lea' - ; - + : 'lea' + ; LDS - : 'lds' - ; - + : 'lds' + ; INS - : 'ins' - ; - + : 'ins' + ; OUTS - : 'outs' - ; - + : 'outs' + ; XADD - : 'xadd' - ; - + : 'xadd' + ; CMPXCHG - : 'cmpxchg' - ; - + : 'cmpxchg' + ; SHL - : 'shl' - ; - + : 'shl' + ; SHR - : 'shr' - ; - + : 'shr' + ; ROR - : 'ror' - ; - + : 'ror' + ; ROL - : 'rol' - ; - + : 'rol' + ; RCL - : 'rcl' - ; - + : 'rcl' + ; SAL - : 'sal' - ; - + : 'sal' + ; RCR - : 'rcr' - ; - + : 'rcr' + ; SAR - : 'sar' - ; - + : 'sar' + ; SHRD - : 'shrd' - ; - + : 'shrd' + ; SHLD - : 'shld' - ; - + : 'shld' + ; BTR - : 'btr' - ; - + : 'btr' + ; BT - : 'bt' - ; - + : 'bt' + ; BTC - : 'btc' - ; - + : 'btc' + ; CALL - : 'call' - ; - + : 'call' + ; INT - : 'int' - ; - + : 'int' + ; RETN - : 'retn' - ; - + : 'retn' + ; RET - : 'ret' - ; - + : 'ret' + ; RETF - : 'retf' - ; - + : 'retf' + ; IN - : 'in' - ; - + : 'in' + ; OUT - : 'out' - ; - + : 'out' + ; REP - : 'rep' - ; - + : 'rep' + ; REPE - : 'repe' - ; - + : 'repe' + ; REPZ - : 'repz' - ; - + : 'repz' + ; REPNE - : 'repne' - ; - + : 'repne' + ; REPNZ - : 'repnz' - ; - + : 'repnz' + ; ALPHA - : '.alpha' - ; - + : '.alpha' + ; CONST - : '.const' - ; - + : '.const' + ; CREF - : '.cref' - ; - + : '.cref' + ; XCREF - : '.xcref' - ; - + : '.xcref' + ; DATA - : 'data' - ; - + : 'data' + ; DATA2 - : 'data?' - ; - + : 'data?' + ; DOSSEG - : 'dosseg' - ; - + : 'dosseg' + ; ERR - : '.err' - ; - + : '.err' + ; ERR1 - : '.err1' - ; - + : '.err1' + ; ERR2 - : '.err2' - ; - + : '.err2' + ; ERRE - : '.erre' - ; - + : '.erre' + ; ERRNZ - : '.errnz' - ; - + : '.errnz' + ; ERRDEF - : '.errdef' - ; - + : '.errdef' + ; ERRNDEF - : '.errndef' - ; - + : '.errndef' + ; ERRB - : '.errb' - ; - + : '.errb' + ; ERRNB - : '.errnb' - ; - + : '.errnb' + ; ERRIDN - : '.erridn[i]' - ; - + : '.erridn[i]' + ; ERRDIF - : '.errdif[i]' - ; - + : '.errdif[i]' + ; EVEN - : 'even' - ; - + : 'even' + ; LIST - : '.list' - ; - + : '.list' + ; WIDTH - : 'width' - ; - + : 'width' + ; MASK - : 'mask' - ; - + : 'mask' + ; SEQ - : '.seq' - ; - + : '.seq' + ; XLIST - : '.xlist' - ; - + : '.xlist' + ; EXIT - : '.exit' - ; - + : '.exit' + ; MODEL - : '.model' - ; - + : '.model' + ; BYTE - : 'byte' - ; - + : 'byte' + ; SBYTE - : 'sbyte' - ; - + : 'sbyte' + ; DB - : 'db' - ; - + : 'db' + ; WORD - : 'word' - ; - + : 'word' + ; SWORD - : 'sword' - ; - + : 'sword' + ; DW - : 'dw' - ; - + : 'dw' + ; DWORD - : 'dword' - ; - + : 'dword' + ; SDWORD - : 'sdword' - ; - + : 'sdword' + ; DD - : 'dd' - ; - + : 'dd' + ; FWORD - : 'fword' - ; - + : 'fword' + ; DF - : 'df' - ; - + : 'df' + ; QWORD - : 'qword' - ; - + : 'qword' + ; DQ - : 'dq' - ; - + : 'dq' + ; TBYTE - : 'tbyte' - ; - + : 'tbyte' + ; DT - : 'dt' - ; - + : 'dt' + ; REAL4 - : 'real4' - ; - + : 'real4' + ; REAL8 - : 'real8' - ; - + : 'real8' + ; REAL - : 'real' - ; - + : 'real' + ; FAR - : 'far' - ; - + : 'far' + ; NEAR - : 'near' - ; - + : 'near' + ; PROC - : 'proc' - ; - + : 'proc' + ; QUESTION - : '?' - ; - + : '?' + ; TIMES - : 'times' - ; - + : 'times' + ; Hexnum - : HexDigit + ('h' | 'H') - ; - + : HexDigit+ ('h' | 'H') + ; Integer - : Digit+ - ; - + : Digit+ + ; Octalnum - : ('0' .. '7') + ('o' | 'O') - ; - + : ('0' .. '7')+ ('o' | 'O') + ; fragment HexDigit - : '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' - ; - + : '0' .. '9' + | 'a' .. 'f' + | 'A' .. 'F' + ; FloatingPointLiteral - : ('0' .. '9') + '.' ('0' .. '9')* Exponent? | '.' ('0' .. '9') + Exponent? | ('0' .. '9') + Exponent - ; - + : ('0' .. '9')+ '.' ('0' .. '9')* Exponent? + | '.' ('0' .. '9')+ Exponent? + | ('0' .. '9')+ Exponent + ; fragment Exponent - : ('e' | 'E') ('+' | '-')? ('0' .. '9') + - ; - + : ('e' | 'E') ('+' | '-')? ('0' .. '9')+ + ; String_ - : ' \'' ('\\' . | ~ ('\\' | '\''))* '\'' - ; - + : ' \'' ('\\' . | ~ ('\\' | '\''))* '\'' + ; fragment Letter - : 'a' .. 'z' | 'A' .. 'Z' - ; - + : 'a' .. 'z' + | 'A' .. 'Z' + ; fragment Digit - : '0' .. '9' - ; - + : '0' .. '9' + ; Etiqueta - : Identifier ':' - ; - + : Identifier ':' + ; Separator - : ',' - ; - + : ',' + ; WS - : (' ' | '\t' | '\n' | '\r') -> skip - ; - + : (' ' | '\t' | '\n' | '\r') -> skip + ; LINE_COMMENT - : ';' ~ ('\n' | '\r')* '\r'? '\n' -> skip - ; + : ';' ~ ('\n' | '\r')* '\r'? '\n' -> skip + ; \ No newline at end of file diff --git a/asm/nasm/nasm_x86_64_Lexer.g4 b/asm/nasm/nasm_x86_64_Lexer.g4 index 616b52c03d..e9e4981830 100644 --- a/asm/nasm/nasm_x86_64_Lexer.g4 +++ b/asm/nasm/nasm_x86_64_Lexer.g4 @@ -1,2702 +1,2681 @@ -lexer grammar nasm_x86_64_Lexer; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -options { caseInsensitive=true; } +lexer grammar nasm_x86_64_Lexer; +options { + caseInsensitive = true; +} -DB: 'db'; -DW: 'dw'; -DD: 'dd'; -DQ: 'dq'; -DT: 'dt'; -DO: 'do'; -DY: 'dy'; -DZ: 'dz'; -RESB: 'resb'; -RESW: 'resw'; -RESD: 'resd'; -RESQ: 'resq'; -REST: 'rest'; -RESO: 'reso'; -RESY: 'resy'; -RESZ: 'resz'; -INCBIN: 'incbin'; +DB : 'db'; +DW : 'dw'; +DD : 'dd'; +DQ : 'dq'; +DT : 'dt'; +DO : 'do'; +DY : 'dy'; +DZ : 'dz'; +RESB : 'resb'; +RESW : 'resw'; +RESD : 'resd'; +RESQ : 'resq'; +REST : 'rest'; +RESO : 'reso'; +RESY : 'resy'; +RESZ : 'resz'; +INCBIN : 'incbin'; -BYTE: 'byte'; -WORD: 'word'; -DWORD: 'dword'; -QWORD: 'qword'; -TWORD: 'tword'; -OWORD: 'oword'; -YWORD: 'yword'; -ZWORD: 'zword'; +BYTE : 'byte'; +WORD : 'word'; +DWORD : 'dword'; +QWORD : 'qword'; +TWORD : 'tword'; +OWORD : 'oword'; +YWORD : 'yword'; +ZWORD : 'zword'; DUP: 'dup'; -COMMA: ','; -QUESTION: '?'; -LEFT_PARENTHESIS: '('; -RIGHT_PARENTHESIS: ')'; -LEFT_BRACKET: '['; -RIGHT_BRACKET: ']'; -COLON: ':'; -BOOLEAN_OR: '||'; -BOOLEAN_XOR: '^^'; -BOOLEAN_AND: '&&'; -EQUAL_1: '='; -EQUAL_2: '=='; -NOT_EQUAL_1: '!='; -NOT_EQUAL_2: '<>'; -LESS_THAN: '<'; -LESS_THAN_EQUAL: '<='; -GREATER_THAN: '>'; -GREATER_THAN_EQUAL: '>='; -SIGNED_COMPARISON: '<=>'; -BITWISE_OR: '|'; -BITWISE_XOR: '^'; -BITWISE_AND: '&'; -LEFT_SHIFT: '<<'; -RIGHT_SHIFT: '>>'; -LEFT_SHIFT_COMPLETENESS: '<<<'; -RIGHT_SHIFT_COMPLETENESS: '>>>'; -PLUS: '+'; -MINUS: '-'; -MULTIPLICATION: '*'; -UNSIGNED_DIVISION: '/'; -SIGNED_DIVISION: '//'; -PERCENT: '%'; //Also is the signed module operator -SIGNED_MODULE: '%%'; -BITWISE_NOT: '~'; -BOOLEAN_NOT: '!'; -DOLLAR: '$'; -DOUBLE_DOLLAR: '$$'; - -AAA: 'aaa'; -AAD: 'aad'; -AAM: 'aam'; -AAS: 'aas'; -ADC: 'adc'; -ADD: 'add'; -AND: 'and'; -ARPL: 'arpl'; -BB0_RESET: 'bb0_reset'; -BB1_RESET: 'bb1_reset'; -BOUND: 'bound'; -BSF: 'bsf'; -BSR: 'bsr'; -BSWAP: 'bswap'; -BT: 'bt'; -BTC: 'btc'; -BTR: 'btr'; -BTS: 'bts'; -CALL: 'call'; -CBW: 'cbw'; -CDQ: 'cdq'; -CDQE: 'cdqe'; -CLC: 'clc'; -CLD: 'cld'; -CLI: 'cli'; -CLTS: 'clts'; -CMC: 'cmc'; -CMOVA: 'cmova'; -CMOVAE: 'cmovae'; -CMOVB: 'cmovb'; -CMOVBE: 'cmovbe'; -CMOVC: 'cmovc'; -CMOVE: 'cmove'; -CMOVGE: 'cmovge'; -CMOVL: 'cmovl'; -CMOVLE: 'cmovle'; -CMOVNA: 'cmovna'; -CMOVNAE: 'cmovnae'; -CMOVNB: 'cmovnb'; -CMOVNBE: 'cmovnbe'; -CMOVNC: 'cmovnc'; -CMOVNE: 'cmovne'; -CMOVNG: 'cmovng'; -CMOVNGE: 'cmovnge'; -CMOVNL: 'cmovnl'; -CMOVNO: 'cmovno'; -CMOVNP: 'cmovnp'; -CMOVNS: 'cmovns'; -CMOVNZ: 'cmovnz'; -CMOVO: 'cmovo'; -CMOVP: 'cmovp'; -CMOVPE: 'cmovpe'; -CMOVPO: 'cmovpo'; -CMOVS: 'cmovs'; -CMOVZ: 'cmovz'; -CMP: 'cmp'; -CMPSB: 'cmpsb'; -CMPSD: 'cmpsd'; -CMPSQ: 'cmpsq'; -CMPSW: 'cmpsw'; -CMPXCHG: 'cmpxchg'; -CMPXCHG16B: 'cmpxchg16b'; -CMPXCHG486: 'cmpxchg486'; -CMPXCHG8B: 'cmpxchg8b'; -CPU_READ: 'cpu_read'; -CPU_WRITE: 'cpu_write'; -CPUID: 'cpuid'; -CQO: 'cqo'; -CWD: 'cwd'; -CWDE: 'cwde'; -DAA: 'daa'; -DAS: 'das'; -DEC: 'dec'; -DIV: 'div'; -DMINT: 'dmint'; -EMMS: 'emms'; -ENTER: 'enter'; -EQU: 'equ'; -F2XM1: 'f2xm1'; -FABS: 'fabs'; -FADD: 'fadd'; -FADDP: 'faddp'; -FBLD: 'fbld'; -FBSTP: 'fbstp'; -FCHS: 'fchs'; -FCLEX: 'fclex'; -FCMOVB: 'fcmovb'; -FCMOVBE: 'fcmovbe'; -FCMOVE: 'fcmove'; -FCMOVNB: 'fcmovnb'; -FCMOVNBE: 'fcmovnbe'; -FCMOVNE: 'fcmovne'; -FCMOVNU: 'fcmovnu'; -FCMOVU: 'fcmovu'; -FCOM: 'fcom'; -FCOMI: 'fcomi'; -FCOMIP: 'fcomip'; -FCOMP: 'fcomp'; -FCOMPP: 'fcompp'; -FCOS: 'fcos'; -FDECSTP: 'fdecstp'; -FDISI: 'fdisi'; -FDIV: 'fdiv'; -FDIVP: 'fdivp'; -FDIVR: 'fdivr'; -FDIVRP: 'fdivrp'; -FEMMS: 'femms'; -FENI: 'feni'; -FFREE: 'ffree'; -FFREEP: 'ffreep'; -FIADD: 'fiadd'; -FICOM: 'ficom'; -FICOMP: 'ficomp'; -FIDIV: 'fidiv'; -FIDIVR: 'fidivr'; -FILD: 'fild'; -FIMUL: 'fimul'; -FINCSTP: 'fincstp'; -FINIT: 'finit'; -FIST: 'fist'; -FISTP: 'fistp'; -FISTTP: 'fisttp'; -FISUB: 'fisub'; -FISUBR: 'fisubr'; -FLD: 'fld'; -FLD1: 'fld1'; -FLDCW: 'fldcw'; -FLDENV: 'fldenv'; -FLDL2E: 'fldl2e'; -FLDL2T: 'fldl2t'; -FLDLG2: 'fldlg2'; -FLDLN2: 'fldln2'; -FLDPI: 'fldpi'; -FLDZ: 'fldz'; -FMUL: 'fmul'; -FMULP: 'fmulp'; -FNCLEX: 'fnclex'; -FNDISI: 'fndisi'; -FNENI: 'fneni'; -FNINIT: 'fninit'; -FNOP: 'fnop'; -FNSAVE: 'fnsave'; -FNSTCW: 'fnstcw'; -FNSTENV: 'fnstenv'; -FNSTSW: 'fnstsw'; -FPATAN: 'fpatan'; -FPREM: 'fprem'; -FPREM1: 'fprem1'; -FPTAN: 'fptan'; -FRNDINT: 'frndint'; -FRSTOR: 'frstor'; -FSAVE: 'fsave'; -FSCALE: 'fscale'; -FSETPM: 'fsetpm'; -FSIN: 'fsin'; -FSINCOS: 'fsincos'; -FSQRT: 'fsqrt'; -FST: 'fst'; -FSTCW: 'fstcw'; -FSTENV: 'fstenv'; -FSTP: 'fstp'; -FSTSW: 'fstsw'; -FSUB: 'fsub'; -FSUBP: 'fsubp'; -FSUBR: 'fsubr'; -FSUBRP: 'fsubrp'; -FTST: 'ftst'; -FUCOM: 'fucom'; -FUCOMI: 'fucomi'; -FUCOMIP: 'fucomip'; -FUCOMP: 'fucomp'; -FUCOMPP: 'fucompp'; -FWAIT: 'fwait'; -FXAM: 'fxam'; -FXCH: 'fxch'; -FXTRACT: 'fxtract'; -FYL2X: 'fyl2x'; -FYL2XP1: 'fyl2xp1'; -HLT: 'hlt'; -IBTS: 'ibts'; -ICEBP: 'icebp'; -IDIV: 'idiv'; -IMUL: 'imul'; -IN: 'in'; -INC: 'inc'; -INSB: 'insb'; -INSD: 'insd'; -INSW: 'insw'; -INT: 'int'; -INT01: 'int01'; -INT03: 'int03'; -INT1: 'int1'; -INT3: 'int3'; -INTO: 'into'; -INVD: 'invd'; -INVLPG: 'invlpg'; -INVLPGA: 'invlpga'; -INVPCID: 'invpcid'; -IRET: 'iret'; -IRETD: 'iretd'; -IRETQ: 'iretq'; -IRETW: 'iretw'; -JA: 'ja'; -JAE: 'jae'; -JB: 'jb'; -JBE: 'jbe'; -JC: 'jc'; -JCXZ: 'jcxz'; -JE: 'je'; -JECXZ: 'jecxz'; -JG: 'jg'; -JGE: 'jge'; -JL: 'jl'; -JLE: 'jle'; -JMP: 'jmp'; -JMPE: 'jmpe'; -JNA: 'jna'; -JNAE: 'jnae'; -JNB: 'jnb'; -JNBE: 'jnbe'; -JNC: 'jnc'; -JNE: 'jne'; -JNG: 'jng'; -JNGE: 'jnge'; -JNL: 'jnl'; -JNLE: 'jnle'; -JNO: 'jno'; -JNP: 'jnp'; -JNS: 'jns'; -JNZ: 'jnz'; -JO: 'jo'; -JP: 'jp'; -JPE: 'jpe'; -JPO: 'jpo'; -JRCXZ: 'jrcxz'; -JS: 'js'; -JZ: 'jz'; -LAHF: 'lahf'; -LAR: 'lar'; -LDS: 'lds'; -LEA: 'lea'; -LEAVE: 'leave'; -LES: 'les'; -LFENCE: 'lfence'; -LFS: 'lfs'; -LGDT: 'lgdt'; -LGS: 'lgs'; -LIDT: 'lidt'; -LLDT: 'lldt'; -LMSW: 'lmsw'; -LOADALL: 'loadall'; -LOADALL286: 'loadall286'; -LODSB: 'lodsb'; -LODSD: 'lodsd'; -LODSQ: 'lodsq'; -LODSW: 'lodsw'; -LOOP: 'loop'; -LOOPE: 'loope'; -LOOPNE: 'loopne'; -LOOPNZ: 'loopnz'; -LOOPZ: 'loopz'; -LSL: 'lsl'; -LSS: 'lss'; -LTR: 'ltr'; -MFENCE: 'mfence'; -MONITOR: 'monitor'; -MONITORX: 'monitorx'; -MOV: 'mov'; -MOVD: 'movd'; -MOVQ: 'movq'; -MOVSB: 'movsb'; -MOVSD: 'movsd'; -MOVSQ: 'movsq'; -MOVSW: 'movsw'; -MOVSX: 'movsx'; -MOVSXD: 'movsxd'; -MOVZX: 'movzx'; -MUL: 'mul'; -MWAIT: 'mwait'; -MWAITX: 'mwaitx'; -NEG: 'neg'; -NOP: 'nop'; -NOT: 'not'; -OR: 'or'; -OUT: 'out'; -OUTSB: 'outsb'; -OUTSD: 'outsd'; -OUTSW: 'outsw'; -PACKSSDW: 'packssdw'; -PACKSSWB: 'packsswb'; -PACKUSWB: 'packuswb'; -PADDB: 'paddb'; -PADDD: 'paddd'; -PADDSB: 'paddsb'; -PADDSIW: 'paddsiw'; -PADDSW: 'paddsw'; -PADDUSB: 'paddusb'; -PADDUSW: 'paddusw'; -PADDW: 'paddw'; -PAND: 'pand'; -PANDN: 'pandn'; -PAUSE: 'pause'; -PAVEB: 'paveb'; -PAVGUSB: 'pavgusb'; -PCMPEQB: 'pcmpeqb'; -PCMPEQD: 'pcmpeqd'; -PCMPEQW: 'pcmpeqw'; -PCMPGTB: 'pcmpgtb'; -PCMPGTD: 'pcmpgtd'; -PCMPGTW: 'pcmpgtw'; -PDISTIB: 'pdistib'; -PF2ID: 'pf2id'; -PFACC: 'pfacc'; -PFADD: 'pfadd'; -PFCMPEQ: 'pfcmpeq'; -PFCMPGE: 'pfcmpge'; -PFCMPGT: 'pfcmpgt'; -PFMAX: 'pfmax'; -PFMIN: 'pfmin'; -PFMUL: 'pfmul'; -PFRCP: 'pfrcp'; -PFRCPIT1: 'pfrcpit1'; -PFRCPIT2: 'pfrcpit2'; -PFRSQIT1: 'pfrsqit1'; -PFRSQRT: 'pfrsqrt'; -PFSUB: 'pfsub'; -PFSUBR: 'pfsubr'; -PI2FD: 'pi2fd'; -PMACHRIW: 'pmachriw'; -PMADDWD: 'pmaddwd'; -PMAGW: 'pmagw'; -PMULHRIW: 'pmulhriw'; -PMULHRWA: 'pmulhrwa'; -PMULHRWC: 'pmulhrwc'; -PMULHW: 'pmulhw'; -PMULLW: 'pmullw'; -PMVGEZB: 'pmvgezb'; -PMVLZB: 'pmvlzb'; -PMVNZB: 'pmvnzb'; -PMVZB: 'pmvzb'; -POP: 'pop'; -POPA: 'popa'; -POPAD: 'popad'; -POPAW: 'popaw'; -POPF: 'popf'; -POPFD: 'popfd'; -POPFQ: 'popfq'; -POPFW: 'popfw'; -POR: 'por'; -PREFETCH: 'prefetch'; -PREFETCHW: 'prefetchw'; -PSLLD: 'pslld'; -PSLLQ: 'psllq'; -PSLLW: 'psllw'; -PSRAD: 'psrad'; -PSRAW: 'psraw'; -PSRLD: 'psrld'; -PSRLQ: 'psrlq'; -PSRLW: 'psrlw'; -PSUBB: 'psubb'; -PSUBD: 'psubd'; -PSUBSB: 'psubsb'; -PSUBSIW: 'psubsiw'; -PSUBSW: 'psubsw'; -PSUBUSB: 'psubusb'; -PSUBUSW: 'psubusw'; -PSUBW: 'psubw'; -PUNPCKHBW: 'punpckhbw'; -PUNPCKHDQ: 'punpckhdq'; -PUNPCKHWD: 'punpckhwd'; -PUNPCKLBW: 'punpcklbw'; -PUNPCKLDQ: 'punpckldq'; -PUNPCKLWD: 'punpcklwd'; -PUSH: 'push'; -PUSHA: 'pusha'; -PUSHAD: 'pushad'; -PUSHAW: 'pushaw'; -PUSHF: 'pushf'; -PUSHFD: 'pushfd'; -PUSHFQ: 'pushfq'; -PUSHFW: 'pushfw'; -PXOR: 'pxor'; -RCL: 'rcl'; -RCR: 'rcr'; -RDM: 'rdm'; -RDMSR: 'rdmsr'; -RDPMC: 'rdpmc'; -RDSHR: 'rdshr'; -RDTSC: 'rdtsc'; -RDTSCP: 'rdtscp'; -RET: 'ret'; -RETD: 'retd'; -RETF: 'retf'; -RETFD: 'retfd'; -RETFQ: 'retfq'; -RETFW: 'retfw'; -RETN: 'retn'; -RETND: 'retnd'; -RETNQ: 'retnq'; -RETNW: 'retnw'; -RETQ: 'retq'; -RETW: 'retw'; -ROL: 'rol'; -ROR: 'ror'; -RSDC: 'rsdc'; -RSLDT: 'rsldt'; -RSM: 'rsm'; -RSTS: 'rsts'; -SAHF: 'sahf'; -SAL: 'sal'; -SALC: 'salc'; -SAR: 'sar'; -SBB: 'sbb'; -SCASB: 'scasb'; -SCASD: 'scasd'; -SCASQ: 'scasq'; -SCASW: 'scasw'; -SETA: 'seta'; -SETAE: 'setae'; -SETB: 'setb'; -SETBE: 'setbe'; -SETC: 'setc'; -SETE: 'sete'; -SETG: 'setg'; -SETGE: 'setge'; -SETL: 'setl'; -SETLE: 'setle'; -SETNA: 'setna'; -SETNAE: 'setnae'; -SETNB: 'setnb'; -SETNBE: 'setnbe'; -SETNC: 'setnc'; -SETNE: 'setne'; -SETNG: 'setng'; -SETNGE: 'setnge'; -SETNL: 'setnl'; -SETNLE: 'setnle'; -SETNO: 'setno'; -SETNP: 'setnp'; -SETNS: 'setns'; -SETNZ: 'setnz'; -SETO: 'seto'; -SETP: 'setp'; -SETPE: 'setpe'; -SETPO: 'setpo'; -SETS: 'sets'; -SETZ: 'setz'; -SFENCE: 'sfence'; -SGDT: 'sgdt'; -SHL: 'shl'; -SHLD: 'shld'; -SHR: 'shr'; -SHRD: 'shrd'; -SIDT: 'sidt'; -SKINIT: 'skinit'; -SLDT: 'sldt'; -SMI: 'smi'; -SMINT: 'smint'; -SMINTOLD: 'smintold'; -SMSW: 'smsw'; -STC: 'stc'; -STD: 'std'; -STI: 'sti'; -STOSB: 'stosb'; -STOSD: 'stosd'; -STOSQ: 'stosq'; -STOSW: 'stosw'; -STR: 'str'; -SUB: 'sub'; -SVDC: 'svdc'; -SVLDT: 'svldt'; -SVTS: 'svts'; -SWAPGS: 'swapgs'; -SYSCALL: 'syscall'; -SYSENTER: 'sysenter'; -SYSEXIT: 'sysexit'; -SYSRET: 'sysret'; -TEST: 'test'; -UD0: 'ud0'; -UD1: 'ud1'; -UD2: 'ud2'; -UD2A: 'ud2a'; -UD2B: 'ud2b'; -UMOV: 'umov'; -VERR: 'verr'; -VERW: 'verw'; -WBINVD: 'wbinvd'; -WRMSR: 'wrmsr'; -WRSHR: 'wrshr'; -XADD: 'xadd'; -XBTS: 'xbts'; -XCHG: 'xchg'; -XLAT: 'xlat'; -XLATB: 'xlatb'; -XOR: 'xor'; - - -AL: 'al'; -AH: 'ah'; -AX: 'ax'; -EAX: 'eax'; -RAX: 'rax'; -BL: 'bl'; -BH: 'bh'; -BX: 'bx'; -EBX: 'ebx'; -RBX: 'rbx'; -CL: 'cl'; -CH: 'ch'; -CX: 'cx'; -ECX: 'ecx'; -RCX: 'rcx'; -DL: 'dl'; -DH: 'dh'; -DX: 'dx'; -EDX: 'edx'; -RDX: 'rdx'; -SPL: 'spl'; -SP: 'sp'; -ESP: 'esp'; -RSP: 'rsp'; -BPL: 'bpl'; -BP: 'bp'; -EBP: 'ebp'; -RBP: 'rbp'; -SIL: 'sil'; -SI: 'si'; -ESI: 'esi'; -RSI: 'rsi'; -DIL: 'dil'; -DI: 'di'; -EDI: 'edi'; -RDI: 'rdi'; -R8B: 'r8b'; -R9B: 'r9b'; -R10B: 'r10b'; -R11B: 'r11b'; -R12B: 'r12b'; -R13B: 'r13b'; -R14B: 'r14b'; -R15B: 'r15b'; -R8W: 'r8w'; -R9W: 'r9w'; -R10W: 'r10w'; -R11W: 'r11w'; -R12W: 'r12w'; -R13W: 'r13w'; -R14W: 'r14w'; -R15W: 'r15w'; -R8D: 'r8d'; -R9D: 'r9d'; -R10D: 'r10d'; -R11D: 'r11d'; -R12D: 'r12d'; -R13D: 'r13d'; -R14D: 'r14d'; -R15D: 'r15d'; -R8: 'r8'; -R9: 'r9'; -R10: 'r10'; -R11: 'r11'; -R12: 'r12'; -R13: 'r13'; -R14: 'r14'; -R15: 'r15'; -IP: 'ip'; -EIP: 'eip'; -RIP: 'rip'; -ES: 'es'; -CS: 'cs'; -SS: 'ss'; -DS: 'ds'; -FS: 'fs'; -GS: 'gs'; -SEGR6: 'segr6'; -SEGR7: 'segr7'; -CR0: 'cr0'; -CR1: 'cr1'; -CR2: 'cr2'; -CR3: 'cr3'; -CR4: 'cr4'; -CR5: 'cr5'; -CR6: 'cr6'; -CR7: 'cr7'; -CR8: 'cr8'; -CR9: 'cr9'; -CR10: 'cr10'; -CR11: 'cr11'; -CR12: 'cr12'; -CR13: 'cr13'; -CR14: 'cr14'; -CR15: 'cr15'; -DR0: 'dr0'; -DR1: 'dr1'; -DR2: 'dr2'; -DR3: 'dr3'; -DR4: 'dr4'; -DR5: 'dr5'; -DR6: 'dr6'; -DR7: 'dr7'; -DR8: 'dr8'; -DR9: 'dr9'; -DR10: 'dr10'; -DR11: 'dr11'; -DR12: 'dr12'; -DR13: 'dr13'; -DR14: 'dr14'; -DR15: 'dr15'; -TR0: 'tr0'; -TR1: 'tr1'; -TR2: 'tr2'; -TR3: 'tr3'; -TR4: 'tr4'; -TR5: 'tr5'; -TR6: 'tr6'; -TR7: 'tr7'; -ST0: 'st0'; -ST1: 'st1'; -ST2: 'st2'; -ST3: 'st3'; -ST4: 'st4'; -ST5: 'st5'; -ST6: 'st6'; -ST7: 'st7'; -MM0: 'mm0'; -MM1: 'mm1'; -MM2: 'mm2'; -MM3: 'mm3'; -MM4: 'mm4'; -MM5: 'mm5'; -MM6: 'mm6'; -MM7: 'mm7'; -XMM0: 'xmm0'; -XMM1: 'xmm1'; -XMM2: 'xmm2'; -XMM3: 'xmm3'; -XMM4: 'xmm4'; -XMM5: 'xmm5'; -XMM6: 'xmm6'; -XMM7: 'xmm7'; -XMM8: 'xmm8'; -XMM9: 'xmm9'; -XMM10: 'xmm10'; -XMM11: 'xmm11'; -XMM12: 'xmm12'; -XMM13: 'xmm13'; -XMM14: 'xmm14'; -XMM15: 'xmm15'; -XMM16: 'xmm16'; -XMM17: 'xmm17'; -XMM18: 'xmm18'; -XMM19: 'xmm19'; -XMM20: 'xmm20'; -XMM21: 'xmm21'; -XMM22: 'xmm22'; -XMM23: 'xmm23'; -XMM24: 'xmm24'; -XMM25: 'xmm25'; -XMM26: 'xmm26'; -XMM27: 'xmm27'; -XMM28: 'xmm28'; -XMM29: 'xmm29'; -XMM30: 'xmm30'; -XMM31: 'xmm31'; -YMM0: 'ymm0'; -YMM1: 'ymm1'; -YMM2: 'ymm2'; -YMM3: 'ymm3'; -YMM4: 'ymm4'; -YMM5: 'ymm5'; -YMM6: 'ymm6'; -YMM7: 'ymm7'; -YMM8: 'ymm8'; -YMM9: 'ymm9'; -YMM10: 'ymm10'; -YMM11: 'ymm11'; -YMM12: 'ymm12'; -YMM13: 'ymm13'; -YMM14: 'ymm14'; -YMM15: 'ymm15'; -YMM16: 'ymm16'; -YMM17: 'ymm17'; -YMM18: 'ymm18'; -YMM19: 'ymm19'; -YMM20: 'ymm20'; -YMM21: 'ymm21'; -YMM22: 'ymm22'; -YMM23: 'ymm23'; -YMM24: 'ymm24'; -YMM25: 'ymm25'; -YMM26: 'ymm26'; -YMM27: 'ymm27'; -YMM28: 'ymm28'; -YMM29: 'ymm29'; -YMM30: 'ymm30'; -YMM31: 'ymm31'; -ZMM0: 'zmm0'; -ZMM1: 'zmm1'; -ZMM2: 'zmm2'; -ZMM3: 'zmm3'; -ZMM4: 'zmm4'; -ZMM5: 'zmm5'; -ZMM6: 'zmm6'; -ZMM7: 'zmm7'; -ZMM8: 'zmm8'; -ZMM9: 'zmm9'; -ZMM10: 'zmm10'; -ZMM11: 'zmm11'; -ZMM12: 'zmm12'; -ZMM13: 'zmm13'; -ZMM14: 'zmm14'; -ZMM15: 'zmm15'; -ZMM16: 'zmm16'; -ZMM17: 'zmm17'; -ZMM18: 'zmm18'; -ZMM19: 'zmm19'; -ZMM20: 'zmm20'; -ZMM21: 'zmm21'; -ZMM22: 'zmm22'; -ZMM23: 'zmm23'; -ZMM24: 'zmm24'; -ZMM25: 'zmm25'; -ZMM26: 'zmm26'; -ZMM27: 'zmm27'; -ZMM28: 'zmm28'; -ZMM29: 'zmm29'; -ZMM30: 'zmm30'; -ZMM31: 'zmm31'; -TMM0: 'tmm0'; -TMM1: 'tmm1'; -TMM2: 'tmm2'; -TMM3: 'tmm3'; -TMM4: 'tmm4'; -TMM5: 'tmm5'; -TMM6: 'tmm6'; -TMM7: 'tmm7'; -K0: 'k0'; -K1: 'k1'; -K2: 'k2'; -K3: 'k3'; -K4: 'k4'; -K5: 'k5'; -K6: 'k6'; -K7: 'k7'; -BND0: 'bnd0'; -BND1: 'bnd1'; -BND2: 'bnd2'; -BND3: 'bnd3'; - - -AADD: 'aadd'; -AAND: 'aand'; -ADCX: 'adcx'; -ADDPD: 'addpd'; -ADDPS: 'addps'; -ADDSD: 'addsd'; -ADDSS: 'addss'; -ADDSUBPD: 'addsubpd'; -ADDSUBPS: 'addsubps'; -ADOX: 'adox'; -AESDEC: 'aesdec'; -AESDECLAST: 'aesdeclast'; -AESENC: 'aesenc'; -AESENCLAST: 'aesenclast'; -AESIMC: 'aesimc'; -AESKEYGENASSIST: 'aeskeygenassist'; -ANDN: 'andn'; -ANDNPD: 'andnpd'; -ANDNPS: 'andnps'; -ANDPD: 'andpd'; -ANDPS: 'andps'; -AXOR: 'axor'; -BEXTR: 'bextr'; -BLCFILL: 'blcfill'; -BLCI: 'blci'; -BLCIC: 'blcic'; -BLCMSK: 'blcmsk'; -BLCS: 'blcs'; -BLENDPD: 'blendpd'; -BLENDPS: 'blendps'; -BLENDVPD: 'blendvpd'; -BLENDVPS: 'blendvps'; -BLSFILL: 'blsfill'; -BLSI: 'blsi'; -BLSIC: 'blsic'; -BLSMSK: 'blsmsk'; -BLSR: 'blsr'; -BNDCL: 'bndcl'; -BNDCN: 'bndcn'; -BNDCU: 'bndcu'; -BNDLDX: 'bndldx'; -BNDMK: 'bndmk'; -BNDMOV: 'bndmov'; -BNDSTX: 'bndstx'; -BZHI: 'bzhi'; -CLAC: 'clac'; -CLDEMOTE: 'cldemote'; -CLFLUSH: 'clflush'; -CLFLUSHOPT: 'clflushopt'; -CLGI: 'clgi'; -CLRSSBSY: 'clrssbsy'; -CLUI: 'clui'; -CLWB: 'clwb'; -CLZERO: 'clzero'; -CMPEQPD: 'cmpeqpd'; -CMPEQPS: 'cmpeqps'; -CMPEQSD: 'cmpeqsd'; -CMPEQSS: 'cmpeqss'; -CMPLEPD: 'cmplepd'; -CMPLEPS: 'cmpleps'; -CMPLESD: 'cmplesd'; -CMPLESS: 'cmpless'; -CMPLTPD: 'cmpltpd'; -CMPLTPS: 'cmpltps'; -CMPLTSD: 'cmpltsd'; -CMPLTSS: 'cmpltss'; -CMPNEQPD: 'cmpneqpd'; -CMPNEQPS: 'cmpneqps'; -CMPNEQSD: 'cmpneqsd'; -CMPNEQSS: 'cmpneqss'; -CMPNLEPD: 'cmpnlepd'; -CMPNLEPS: 'cmpnleps'; -CMPNLESD: 'cmpnlesd'; -CMPNLESS: 'cmpnless'; -CMPNLTPD: 'cmpnltpd'; -CMPNLTPS: 'cmpnltps'; -CMPNLTSD: 'cmpnltsd'; -CMPNLTSS: 'cmpnltss'; -CMPNPXADD: 'cmpnpxadd'; -CMPNSXADD: 'cmpnsxadd'; -CMPNZXADD: 'cmpnzxadd'; -CMPORDPD: 'cmpordpd'; -CMPORDPS: 'cmpordps'; -CMPORDSD: 'cmpordsd'; -CMPORDSS: 'cmpordss'; -CMPOXADD: 'cmpoxadd'; -CMPPD: 'cmppd'; -CMPPS: 'cmpps'; -CMPPXADD: 'cmppxadd'; -CMPSS: 'cmpss'; -CMPSXADD: 'cmpsxadd'; -CMPUNORDPD: 'cmpunordpd'; -CMPUNORDPS: 'cmpunordps'; -CMPUNORDSD: 'cmpunordsd'; -CMPUNORDSS: 'cmpunordss'; -CMPZXADD: 'cmpzxadd'; -COMISD: 'comisd'; -COMISS: 'comiss'; -CRC32: 'crc32'; -CVTDQ2PD: 'cvtdq2pd'; -CVTDQ2PS: 'cvtdq2ps'; -CVTPD2DQ: 'cvtpd2dq'; -CVTPD2PI: 'cvtpd2pi'; -CVTPD2PS: 'cvtpd2ps'; -CVTPI2PD: 'cvtpi2pd'; -CVTPI2PS: 'cvtpi2ps'; -CVTPS2DQ: 'cvtps2dq'; -CVTPS2PD: 'cvtps2pd'; -CVTPS2PI: 'cvtps2pi'; -CVTSD2SI: 'cvtsd2si'; -CVTSD2SS: 'cvtsd2ss'; -CVTSI2SD: 'cvtsi2sd'; -CVTSI2SS: 'cvtsi2ss'; -CVTSS2SD: 'cvtss2sd'; -CVTSS2SI: 'cvtss2si'; -CVTTPD2DQ: 'cvttpd2dq'; -CVTTPD2PI: 'cvttpd2pi'; -CVTTPS2DQ: 'cvttps2dq'; -CVTTPS2PI: 'cvttps2pi'; -CVTTSD2SI: 'cvttsd2si'; -CVTTSS2SI: 'cvttss2si'; -DIVPD: 'divpd'; -DIVPS: 'divps'; -DIVSD: 'divsd'; -DIVSS: 'divss'; -DPPD: 'dppd'; -DPPS: 'dpps'; -ENCLS: 'encls'; -ENCLU: 'enclu'; -ENCLV: 'enclv'; -ENDBR32: 'endbr32'; -ENDBR64: 'endbr64'; -ENQCMD: 'enqcmd'; -ENQCMDS: 'enqcmds'; -EXTRACTPS: 'extractps'; -EXTRQ: 'extrq'; -FXRSTOR: 'fxrstor'; -FXRSTOR64: 'fxrstor64'; -FXSAVE: 'fxsave'; -FXSAVE64: 'fxsave64'; -GETSEC: 'getsec'; -GF2P8AFFINEINVQB: 'gf2p8affineinvqb'; -GF2P8AFFINEQB: 'gf2p8affineqb'; -GF2P8MULB: 'gf2p8mulb'; -HADDPD: 'haddpd'; -HADDPS: 'haddps'; -HINT_NOP0: 'hint_nop0'; -HINT_NOP1: 'hint_nop1'; -HINT_NOP10: 'hint_nop10'; -HINT_NOP11: 'hint_nop11'; -HINT_NOP12: 'hint_nop12'; -HINT_NOP13: 'hint_nop13'; -HINT_NOP14: 'hint_nop14'; -HINT_NOP15: 'hint_nop15'; -HINT_NOP16: 'hint_nop16'; -HINT_NOP17: 'hint_nop17'; -HINT_NOP18: 'hint_nop18'; -HINT_NOP19: 'hint_nop19'; -HINT_NOP2: 'hint_nop2'; -HINT_NOP20: 'hint_nop20'; -HINT_NOP21: 'hint_nop21'; -HINT_NOP22: 'hint_nop22'; -HINT_NOP23: 'hint_nop23'; -HINT_NOP24: 'hint_nop24'; -HINT_NOP25: 'hint_nop25'; -HINT_NOP26: 'hint_nop26'; -HINT_NOP27: 'hint_nop27'; -HINT_NOP28: 'hint_nop28'; -HINT_NOP29: 'hint_nop29'; -HINT_NOP3: 'hint_nop3'; -HINT_NOP30: 'hint_nop30'; -HINT_NOP31: 'hint_nop31'; -HINT_NOP32: 'hint_nop32'; -HINT_NOP33: 'hint_nop33'; -HINT_NOP34: 'hint_nop34'; -HINT_NOP35: 'hint_nop35'; -HINT_NOP36: 'hint_nop36'; -HINT_NOP37: 'hint_nop37'; -HINT_NOP38: 'hint_nop38'; -HINT_NOP39: 'hint_nop39'; -HINT_NOP4: 'hint_nop4'; -HINT_NOP40: 'hint_nop40'; -HINT_NOP41: 'hint_nop41'; -HINT_NOP42: 'hint_nop42'; -HINT_NOP43: 'hint_nop43'; -HINT_NOP44: 'hint_nop44'; -HINT_NOP45: 'hint_nop45'; -HINT_NOP46: 'hint_nop46'; -HINT_NOP47: 'hint_nop47'; -HINT_NOP48: 'hint_nop48'; -HINT_NOP49: 'hint_nop49'; -HINT_NOP5: 'hint_nop5'; -HINT_NOP50: 'hint_nop50'; -HINT_NOP51: 'hint_nop51'; -HINT_NOP52: 'hint_nop52'; -HINT_NOP53: 'hint_nop53'; -HINT_NOP54: 'hint_nop54'; -HINT_NOP55: 'hint_nop55'; -HINT_NOP56: 'hint_nop56'; -HINT_NOP57: 'hint_nop57'; -HINT_NOP58: 'hint_nop58'; -HINT_NOP59: 'hint_nop59'; -HINT_NOP6: 'hint_nop6'; -HINT_NOP60: 'hint_nop60'; -HINT_NOP61: 'hint_nop61'; -HINT_NOP62: 'hint_nop62'; -HINT_NOP63: 'hint_nop63'; -HINT_NOP7: 'hint_nop7'; -HINT_NOP8: 'hint_nop8'; -HINT_NOP9: 'hint_nop9'; -HRESET: 'hreset'; -HSUBPD: 'hsubpd'; -HSUBPS: 'hsubps'; -INCSSPD: 'incsspd'; -INCSSPQ: 'incsspq'; -INSERTPS: 'insertps'; -INSERTQ: 'insertq'; -INVEPT: 'invept'; -INVVPID: 'invvpid'; -KADD: 'kadd'; -KADDB: 'kaddb'; -KADDD: 'kaddd'; -KADDQ: 'kaddq'; -KADDW: 'kaddw'; -KAND: 'kand'; -KANDB: 'kandb'; -KANDD: 'kandd'; -KANDN: 'kandn'; -KANDNB: 'kandnb'; -KANDND: 'kandnd'; -KANDNQ: 'kandnq'; -KANDNW: 'kandnw'; -KANDQ: 'kandq'; -KANDW: 'kandw'; -KMOV: 'kmov'; -KMOVB: 'kmovb'; -KMOVD: 'kmovd'; -KMOVQ: 'kmovq'; -KMOVW: 'kmovw'; -KNOT: 'knot'; -KNOTB: 'knotb'; -KNOTD: 'knotd'; -KNOTQ: 'knotq'; -KNOTW: 'knotw'; -KOR: 'kor'; -KORB: 'korb'; -KORD: 'kord'; -KORQ: 'korq'; -KORTEST: 'kortest'; -KORTESTB: 'kortestb'; -KORTESTD: 'kortestd'; -KORTESTQ: 'kortestq'; -KORTESTW: 'kortestw'; -KORW: 'korw'; -KSHIFTL: 'kshiftl'; -KSHIFTLB: 'kshiftlb'; -KSHIFTLD: 'kshiftld'; -KSHIFTLQ: 'kshiftlq'; -KSHIFTLW: 'kshiftlw'; -KSHIFTR: 'kshiftr'; -KSHIFTRB: 'kshiftrb'; -KSHIFTRD: 'kshiftrd'; -KSHIFTRQ: 'kshiftrq'; -KSHIFTRW: 'kshiftrw'; -KTEST: 'ktest'; -KTESTB: 'ktestb'; -KTESTD: 'ktestd'; -KTESTQ: 'ktestq'; -KTESTW: 'ktestw'; -KUNPCK: 'kunpck'; -KUNPCKBW: 'kunpckbw'; -KUNPCKDQ: 'kunpckdq'; -KUNPCKWD: 'kunpckwd'; -KXNOR: 'kxnor'; -KXNORB: 'kxnorb'; -KXNORD: 'kxnord'; -KXNORQ: 'kxnorq'; -KXNORW: 'kxnorw'; -KXOR: 'kxor'; -KXORB: 'kxorb'; -KXORD: 'kxord'; -KXORQ: 'kxorq'; -KXORW: 'kxorw'; -LDDQU: 'lddqu'; -LDMXCSR: 'ldmxcsr'; -LDTILECFG: 'ldtilecfg'; -LLWPCB: 'llwpcb'; -LWPINS: 'lwpins'; -LWPVAL: 'lwpval'; -LZCNT: 'lzcnt'; -MASKMOVDQU: 'maskmovdqu'; -MASKMOVQ: 'maskmovq'; -MAXPD: 'maxpd'; -MAXPS: 'maxps'; -MAXSD: 'maxsd'; -MAXSS: 'maxss'; -MINPD: 'minpd'; -MINPS: 'minps'; -MINSD: 'minsd'; -MINSS: 'minss'; -MONTMUL: 'montmul'; -MOVAPD: 'movapd'; -MOVAPS: 'movaps'; -MOVBE: 'movbe'; -MOVDDUP: 'movddup'; -MOVDIR64B: 'movdir64b'; -MOVDIRI: 'movdiri'; -MOVDQ2Q: 'movdq2q'; -MOVDQA: 'movdqa'; -MOVDQU: 'movdqu'; -MOVHLPS: 'movhlps'; -MOVHPD: 'movhpd'; -MOVHPS: 'movhps'; -MOVLHPS: 'movlhps'; -MOVLPD: 'movlpd'; -MOVLPS: 'movlps'; -MOVMSKPD: 'movmskpd'; -MOVMSKPS: 'movmskps'; -MOVNTDQ: 'movntdq'; -MOVNTDQA: 'movntdqa'; -MOVNTI: 'movnti'; -MOVNTPD: 'movntpd'; -MOVNTPS: 'movntps'; -MOVNTQ: 'movntq'; -MOVNTSD: 'movntsd'; -MOVNTSS: 'movntss'; -MOVQ2DQ: 'movq2dq'; -MOVSHDUP: 'movshdup'; -MOVSLDUP: 'movsldup'; -MOVSS: 'movss'; -MOVUPD: 'movupd'; -MOVUPS: 'movups'; -MPSADBW: 'mpsadbw'; -MULPD: 'mulpd'; -MULPS: 'mulps'; -MULSD: 'mulsd'; -MULSS: 'mulss'; -MULX: 'mulx'; -ORPD: 'orpd'; -ORPS: 'orps'; -PABSB: 'pabsb'; -PABSD: 'pabsd'; -PABSW: 'pabsw'; -PACKUSDW: 'packusdw'; -PADDQ: 'paddq'; -PALIGNR: 'palignr'; -PAVGB: 'pavgb'; -PAVGW: 'pavgw'; -PBLENDVB: 'pblendvb'; -PBLENDW: 'pblendw'; -PCLMULHQHQDQ: 'pclmulhqhqdq'; -PCLMULHQLQDQ: 'pclmulhqlqdq'; -PCLMULLQHQDQ: 'pclmullqhqdq'; -PCLMULLQLQDQ: 'pclmullqlqdq'; -PCLMULQDQ: 'pclmulqdq'; -PCMPEQQ: 'pcmpeqq'; -PCMPESTRI: 'pcmpestri'; -PCMPESTRM: 'pcmpestrm'; -PCMPGTQ: 'pcmpgtq'; -PCMPISTRI: 'pcmpistri'; -PCMPISTRM: 'pcmpistrm'; -PCOMMIT: 'pcommit'; -PCONFIG: 'pconfig'; -PDEP: 'pdep'; -PEXT: 'pext'; -PEXTRB: 'pextrb'; -PEXTRD: 'pextrd'; -PEXTRQ: 'pextrq'; -PEXTRW: 'pextrw'; -PF2IW: 'pf2iw'; -PFNACC: 'pfnacc'; -PFPNACC: 'pfpnacc'; -PFRCPV: 'pfrcpv'; -PFRSQRTV: 'pfrsqrtv'; -PHADDD: 'phaddd'; -PHADDSW: 'phaddsw'; -PHADDW: 'phaddw'; -PHMINPOSUW: 'phminposuw'; -PHSUBD: 'phsubd'; -PHSUBSW: 'phsubsw'; -PHSUBW: 'phsubw'; -PI2FW: 'pi2fw'; -PINSRB: 'pinsrb'; -PINSRD: 'pinsrd'; -PINSRQ: 'pinsrq'; -PINSRW: 'pinsrw'; -PMADDUBSW: 'pmaddubsw'; -PMAXSB: 'pmaxsb'; -PMAXSD: 'pmaxsd'; -PMAXSW: 'pmaxsw'; -PMAXUB: 'pmaxub'; -PMAXUD: 'pmaxud'; -PMAXUW: 'pmaxuw'; -PMINSB: 'pminsb'; -PMINSD: 'pminsd'; -PMINSW: 'pminsw'; -PMINUB: 'pminub'; -PMINUD: 'pminud'; -PMINUW: 'pminuw'; -PMOVMSKB: 'pmovmskb'; -PMOVSXBD: 'pmovsxbd'; -PMOVSXBQ: 'pmovsxbq'; -PMOVSXBW: 'pmovsxbw'; -PMOVSXDQ: 'pmovsxdq'; -PMOVSXWD: 'pmovsxwd'; -PMOVSXWQ: 'pmovsxwq'; -PMOVZXBD: 'pmovzxbd'; -PMOVZXBQ: 'pmovzxbq'; -PMOVZXBW: 'pmovzxbw'; -PMOVZXDQ: 'pmovzxdq'; -PMOVZXWD: 'pmovzxwd'; -PMOVZXWQ: 'pmovzxwq'; -PMULDQ: 'pmuldq'; -PMULHRSW: 'pmulhrsw'; -PMULHUW: 'pmulhuw'; -PMULLD: 'pmulld'; -PMULUDQ: 'pmuludq'; -POPCNT: 'popcnt'; -PREFETCHIT0: 'prefetchit0'; -PREFETCHIT1: 'prefetchit1'; -PREFETCHNTA: 'prefetchnta'; -PREFETCHT0: 'prefetcht0'; -PREFETCHT1: 'prefetcht1'; -PREFETCHT2: 'prefetcht2'; -PREFETCHWT1: 'prefetchwt1'; -PSADBW: 'psadbw'; -PSHUFB: 'pshufb'; -PSHUFD: 'pshufd'; -PSHUFHW: 'pshufhw'; -PSHUFLW: 'pshuflw'; -PSHUFW: 'pshufw'; -PSIGNB: 'psignb'; -PSIGND: 'psignd'; -PSIGNW: 'psignw'; -PSLLDQ: 'pslldq'; -PSRLDQ: 'psrldq'; -PSUBQ: 'psubq'; -PSWAPD: 'pswapd'; -PTEST: 'ptest'; -PTWRITE: 'ptwrite'; -PUNPCKHQDQ: 'punpckhqdq'; -PUNPCKLQDQ: 'punpcklqdq'; -PVALIDATE: 'pvalidate'; -RCPPS: 'rcpps'; -RCPSS: 'rcpss'; -RDFSBASE: 'rdfsbase'; -RDGSBASE: 'rdgsbase'; -RDMSRLIST: 'rdmsrlist'; -RDPID: 'rdpid'; -RDPKRU: 'rdpkru'; -RDRAND: 'rdrand'; -RDSEED: 'rdseed'; -RDSSPD: 'rdsspd'; -RDSSPQ: 'rdsspq'; -RMPADJUST: 'rmpadjust'; -RORX: 'rorx'; -ROUNDPD: 'roundpd'; -ROUNDPS: 'roundps'; -ROUNDSD: 'roundsd'; -ROUNDSS: 'roundss'; -RSQRTPS: 'rsqrtps'; -RSQRTSS: 'rsqrtss'; -RSTORSSP: 'rstorssp'; -SARX: 'sarx'; -SAVEPREVSSP: 'saveprevssp'; -SENDUIPI: 'senduipi'; -SERIALIZE: 'serialize'; -SETSSBSY: 'setssbsy'; -SHA1MSG1: 'sha1msg1'; -SHA1MSG2: 'sha1msg2'; -SHA1NEXTE: 'sha1nexte'; -SHA1RNDS4: 'sha1rnds4'; -SHA256MSG1: 'sha256msg1'; -SHA256MSG2: 'sha256msg2'; -SHA256RNDS2: 'sha256rnds2'; -SHLX: 'shlx'; -SHRX: 'shrx'; -SHUFPD: 'shufpd'; -SHUFPS: 'shufps'; -SLWPCB: 'slwpcb'; -SQRTPD: 'sqrtpd'; -SQRTPS: 'sqrtps'; -SQRTSD: 'sqrtsd'; -SQRTSS: 'sqrtss'; -STAC: 'stac'; -STGI: 'stgi'; -STMXCSR: 'stmxcsr'; -STTILECFG: 'sttilecfg'; -STUI: 'stui'; -SUBPD: 'subpd'; -SUBPS: 'subps'; -SUBSD: 'subsd'; -SUBSS: 'subss'; -T1MSKC: 't1mskc'; -TDPBF16PS: 'tdpbf16ps'; -TDPBSSD: 'tdpbssd'; -TDPBSUD: 'tdpbsud'; -TDPBUSD: 'tdpbusd'; -TDPBUUD: 'tdpbuud'; -TESTUI: 'testui'; -TILELOADD: 'tileloadd'; -TILELOADDT1: 'tileloaddt1'; -TILERELEASE: 'tilerelease'; -TILESTORED: 'tilestored'; -TILEZERO: 'tilezero'; -TPAUSE: 'tpause'; -TZCNT: 'tzcnt'; -TZMSK: 'tzmsk'; -UCOMISD: 'ucomisd'; -UCOMISS: 'ucomiss'; -UIRET: 'uiret'; -UMONITOR: 'umonitor'; -UMWAIT: 'umwait'; -UNPCKHPD: 'unpckhpd'; -UNPCKHPS: 'unpckhps'; -UNPCKLPD: 'unpcklpd'; -UNPCKLPS: 'unpcklps'; -V4DPWSSD: 'v4dpwssd'; -V4DPWSSDS: 'v4dpwssds'; -V4FMADDPS: 'v4fmaddps'; -V4FMADDSS: 'v4fmaddss'; -V4FNMADDPS: 'v4fnmaddps'; -V4FNMADDSS: 'v4fnmaddss'; -VADDPD: 'vaddpd'; -VADDPH: 'vaddph'; -VADDPS: 'vaddps'; -VADDSD: 'vaddsd'; -VADDSH: 'vaddsh'; -VADDSS: 'vaddss'; -VADDSUBPD: 'vaddsubpd'; -VADDSUBPS: 'vaddsubps'; -VAESDEC: 'vaesdec'; -VAESDECLAST: 'vaesdeclast'; -VAESENC: 'vaesenc'; -VAESENCLAST: 'vaesenclast'; -VAESIMC: 'vaesimc'; -VAESKEYGENASSIST: 'vaeskeygenassist'; -VALIGND: 'valignd'; -VALIGNQ: 'valignq'; -VANDNPD: 'vandnpd'; -VANDNPS: 'vandnps'; -VANDPD: 'vandpd'; -VANDPS: 'vandps'; -VBCSTNEBF16PS: 'vbcstnebf16ps'; -VBCSTNESH2PS: 'vbcstnesh2ps'; -VBLENDMPD: 'vblendmpd'; -VBLENDMPS: 'vblendmps'; -VBLENDPD: 'vblendpd'; -VBLENDPS: 'vblendps'; -VBLENDVPD: 'vblendvpd'; -VBLENDVPS: 'vblendvps'; -VBROADCASTF128: 'vbroadcastf128'; -VBROADCASTF32X2: 'vbroadcastf32x2'; -VBROADCASTF32X4: 'vbroadcastf32x4'; -VBROADCASTF32X8: 'vbroadcastf32x8'; -VBROADCASTF64X2: 'vbroadcastf64x2'; -VBROADCASTF64X4: 'vbroadcastf64x4'; -VBROADCASTI128: 'vbroadcasti128'; -VBROADCASTI32X2: 'vbroadcasti32x2'; -VBROADCASTI32X4: 'vbroadcasti32x4'; -VBROADCASTI32X8: 'vbroadcasti32x8'; -VBROADCASTI64X2: 'vbroadcasti64x2'; -VBROADCASTI64X4: 'vbroadcasti64x4'; -VBROADCASTSD: 'vbroadcastsd'; -VBROADCASTSS: 'vbroadcastss'; -VCMPEQ_OQPD: 'vcmpeq_oqpd'; -VCMPEQ_OQPS: 'vcmpeq_oqps'; -VCMPEQ_OQSD: 'vcmpeq_oqsd'; -VCMPEQ_OQSS: 'vcmpeq_oqss'; -VCMPEQ_OSPD: 'vcmpeq_ospd'; -VCMPEQ_OSPS: 'vcmpeq_osps'; -VCMPEQ_OSSD: 'vcmpeq_ossd'; -VCMPEQ_OSSS: 'vcmpeq_osss'; -VCMPEQ_UQPD: 'vcmpeq_uqpd'; -VCMPEQ_UQPS: 'vcmpeq_uqps'; -VCMPEQ_UQSD: 'vcmpeq_uqsd'; -VCMPEQ_UQSS: 'vcmpeq_uqss'; -VCMPEQ_USPD: 'vcmpeq_uspd'; -VCMPEQ_USPS: 'vcmpeq_usps'; -VCMPEQ_USSD: 'vcmpeq_ussd'; -VCMPEQ_USSS: 'vcmpeq_usss'; -VCMPEQPD: 'vcmpeqpd'; -VCMPEQPS: 'vcmpeqps'; -VCMPEQSD: 'vcmpeqsd'; -VCMPEQSS: 'vcmpeqss'; -VCMPFALSE_OQPD: 'vcmpfalse_oqpd'; -VCMPFALSE_OQPS: 'vcmpfalse_oqps'; -VCMPFALSE_OQSD: 'vcmpfalse_oqsd'; -VCMPFALSE_OQSS: 'vcmpfalse_oqss'; -VCMPFALSE_OSPD: 'vcmpfalse_ospd'; -VCMPFALSE_OSPS: 'vcmpfalse_osps'; -VCMPFALSE_OSSD: 'vcmpfalse_ossd'; -VCMPFALSE_OSSS: 'vcmpfalse_osss'; -VCMPFALSEPD: 'vcmpfalsepd'; -VCMPFALSEPS: 'vcmpfalseps'; -VCMPFALSESD: 'vcmpfalsesd'; -VCMPFALSESS: 'vcmpfalsess'; -VCMPGE_OQPD: 'vcmpge_oqpd'; -VCMPGE_OQPS: 'vcmpge_oqps'; -VCMPGE_OQSD: 'vcmpge_oqsd'; -VCMPGE_OQSS: 'vcmpge_oqss'; -VCMPGE_OSPD: 'vcmpge_ospd'; -VCMPGE_OSPS: 'vcmpge_osps'; -VCMPGE_OSSD: 'vcmpge_ossd'; -VCMPGE_OSSS: 'vcmpge_osss'; -VCMPGEPD: 'vcmpgepd'; -VCMPGEPS: 'vcmpgeps'; -VCMPGESD: 'vcmpgesd'; -VCMPGESS: 'vcmpgess'; -VCMPGT_OQPD: 'vcmpgt_oqpd'; -VCMPGT_OQPS: 'vcmpgt_oqps'; -VCMPGT_OQSD: 'vcmpgt_oqsd'; -VCMPGT_OQSS: 'vcmpgt_oqss'; -VCMPGT_OSPD: 'vcmpgt_ospd'; -VCMPGT_OSPS: 'vcmpgt_osps'; -VCMPGT_OSSD: 'vcmpgt_ossd'; -VCMPGT_OSSS: 'vcmpgt_osss'; -VCMPGTPD: 'vcmpgtpd'; -VCMPGTPS: 'vcmpgtps'; -VCMPGTSD: 'vcmpgtsd'; -VCMPGTSS: 'vcmpgtss'; -VCMPLE_OQPD: 'vcmple_oqpd'; -VCMPLE_OQPS: 'vcmple_oqps'; -VCMPLE_OQSD: 'vcmple_oqsd'; -VCMPLE_OQSS: 'vcmple_oqss'; -VCMPLE_OSPD: 'vcmple_ospd'; -VCMPLE_OSPS: 'vcmple_osps'; -VCMPLE_OSSD: 'vcmple_ossd'; -VCMPLE_OSSS: 'vcmple_osss'; -VCMPLEPD: 'vcmplepd'; -VCMPLEPS: 'vcmpleps'; -VCMPLESD: 'vcmplesd'; -VCMPLESS: 'vcmpless'; -VCMPLT_OQPD: 'vcmplt_oqpd'; -VCMPLT_OQPS: 'vcmplt_oqps'; -VCMPLT_OQSD: 'vcmplt_oqsd'; -VCMPLT_OQSS: 'vcmplt_oqss'; -VCMPLT_OSPD: 'vcmplt_ospd'; -VCMPLT_OSPS: 'vcmplt_osps'; -VCMPLT_OSSD: 'vcmplt_ossd'; -VCMPLT_OSSS: 'vcmplt_osss'; -VCMPLTPD: 'vcmpltpd'; -VCMPLTPS: 'vcmpltps'; -VCMPLTSD: 'vcmpltsd'; -VCMPLTSS: 'vcmpltss'; -VCMPNEQ_OQPD: 'vcmpneq_oqpd'; -VCMPNEQ_OQPS: 'vcmpneq_oqps'; -VCMPNEQ_OQSD: 'vcmpneq_oqsd'; -VCMPNEQ_OQSS: 'vcmpneq_oqss'; -VCMPNEQ_OSPD: 'vcmpneq_ospd'; -VCMPNEQ_OSPS: 'vcmpneq_osps'; -VCMPNEQ_OSSD: 'vcmpneq_ossd'; -VCMPNEQ_OSSS: 'vcmpneq_osss'; -VCMPNEQ_UQPD: 'vcmpneq_uqpd'; -VCMPNEQ_UQPS: 'vcmpneq_uqps'; -VCMPNEQ_UQSD: 'vcmpneq_uqsd'; -VCMPNEQ_UQSS: 'vcmpneq_uqss'; -VCMPNEQ_USPD: 'vcmpneq_uspd'; -VCMPNEQ_USPS: 'vcmpneq_usps'; -VCMPNEQ_USSD: 'vcmpneq_ussd'; -VCMPNEQ_USSS: 'vcmpneq_usss'; -VCMPNEQPD: 'vcmpneqpd'; -VCMPNEQPS: 'vcmpneqps'; -VCMPNEQSD: 'vcmpneqsd'; -VCMPNEQSS: 'vcmpneqss'; -VCMPNGE_UQPD: 'vcmpnge_uqpd'; -VCMPNGE_UQPS: 'vcmpnge_uqps'; -VCMPNGE_UQSD: 'vcmpnge_uqsd'; -VCMPNGE_UQSS: 'vcmpnge_uqss'; -VCMPNGE_USPD: 'vcmpnge_uspd'; -VCMPNGE_USPS: 'vcmpnge_usps'; -VCMPNGE_USSD: 'vcmpnge_ussd'; -VCMPNGE_USSS: 'vcmpnge_usss'; -VCMPNGEPD: 'vcmpngepd'; -VCMPNGEPS: 'vcmpngeps'; -VCMPNGESD: 'vcmpngesd'; -VCMPNGESS: 'vcmpngess'; -VCMPNGT_UQPD: 'vcmpngt_uqpd'; -VCMPNGT_UQPS: 'vcmpngt_uqps'; -VCMPNGT_UQSD: 'vcmpngt_uqsd'; -VCMPNGT_UQSS: 'vcmpngt_uqss'; -VCMPNGT_USPD: 'vcmpngt_uspd'; -VCMPNGT_USPS: 'vcmpngt_usps'; -VCMPNGT_USSD: 'vcmpngt_ussd'; -VCMPNGT_USSS: 'vcmpngt_usss'; -VCMPNGTPD: 'vcmpngtpd'; -VCMPNGTPS: 'vcmpngtps'; -VCMPNGTSD: 'vcmpngtsd'; -VCMPNGTSS: 'vcmpngtss'; -VCMPNLE_UQPD: 'vcmpnle_uqpd'; -VCMPNLE_UQPS: 'vcmpnle_uqps'; -VCMPNLE_UQSD: 'vcmpnle_uqsd'; -VCMPNLE_UQSS: 'vcmpnle_uqss'; -VCMPNLE_USPD: 'vcmpnle_uspd'; -VCMPNLE_USPS: 'vcmpnle_usps'; -VCMPNLE_USSD: 'vcmpnle_ussd'; -VCMPNLE_USSS: 'vcmpnle_usss'; -VCMPNLEPD: 'vcmpnlepd'; -VCMPNLEPS: 'vcmpnleps'; -VCMPNLESD: 'vcmpnlesd'; -VCMPNLESS: 'vcmpnless'; -VCMPNLT_UQPD: 'vcmpnlt_uqpd'; -VCMPNLT_UQPS: 'vcmpnlt_uqps'; -VCMPNLT_UQSD: 'vcmpnlt_uqsd'; -VCMPNLT_UQSS: 'vcmpnlt_uqss'; -VCMPNLT_USPD: 'vcmpnlt_uspd'; -VCMPNLT_USPS: 'vcmpnlt_usps'; -VCMPNLT_USSD: 'vcmpnlt_ussd'; -VCMPNLT_USSS: 'vcmpnlt_usss'; -VCMPNLTPD: 'vcmpnltpd'; -VCMPNLTPS: 'vcmpnltps'; -VCMPNLTSD: 'vcmpnltsd'; -VCMPNLTSS: 'vcmpnltss'; -VCMPORD_QPD: 'vcmpord_qpd'; -VCMPORD_QPS: 'vcmpord_qps'; -VCMPORD_QSD: 'vcmpord_qsd'; -VCMPORD_QSS: 'vcmpord_qss'; -VCMPORD_SPD: 'vcmpord_spd'; -VCMPORD_SPS: 'vcmpord_sps'; -VCMPORD_SSD: 'vcmpord_ssd'; -VCMPORD_SSS: 'vcmpord_sss'; -VCMPORDPD: 'vcmpordpd'; -VCMPORDPS: 'vcmpordps'; -VCMPORDSD: 'vcmpordsd'; -VCMPORDSS: 'vcmpordss'; -VCMPPD: 'vcmppd'; -VCMPPH: 'vcmpph'; -VCMPPS: 'vcmpps'; -VCMPSD: 'vcmpsd'; -VCMPSH: 'vcmpsh'; -VCMPSS: 'vcmpss'; -VCMPTRUE_UQPD: 'vcmptrue_uqpd'; -VCMPTRUE_UQPS: 'vcmptrue_uqps'; -VCMPTRUE_UQSD: 'vcmptrue_uqsd'; -VCMPTRUE_UQSS: 'vcmptrue_uqss'; -VCMPTRUE_USPD: 'vcmptrue_uspd'; -VCMPTRUE_USPS: 'vcmptrue_usps'; -VCMPTRUE_USSD: 'vcmptrue_ussd'; -VCMPTRUE_USSS: 'vcmptrue_usss'; -VCMPTRUEPD: 'vcmptruepd'; -VCMPTRUEPS: 'vcmptrueps'; -VCMPTRUESD: 'vcmptruesd'; -VCMPTRUESS: 'vcmptruess'; -VCMPUNORD_QPD: 'vcmpunord_qpd'; -VCMPUNORD_QPS: 'vcmpunord_qps'; -VCMPUNORD_QSD: 'vcmpunord_qsd'; -VCMPUNORD_QSS: 'vcmpunord_qss'; -VCMPUNORD_SPD: 'vcmpunord_spd'; -VCMPUNORD_SPS: 'vcmpunord_sps'; -VCMPUNORD_SSD: 'vcmpunord_ssd'; -VCMPUNORD_SSS: 'vcmpunord_sss'; -VCMPUNORDPD: 'vcmpunordpd'; -VCMPUNORDPS: 'vcmpunordps'; -VCMPUNORDSD: 'vcmpunordsd'; -VCMPUNORDSS: 'vcmpunordss'; -VCOMISD: 'vcomisd'; -VCOMISH: 'vcomish'; -VCOMISS: 'vcomiss'; -VCOMPRESSPD: 'vcompresspd'; -VCOMPRESSPS: 'vcompressps'; -VCVTDQ2PD: 'vcvtdq2pd'; -VCVTDQ2PH: 'vcvtdq2ph'; -VCVTDQ2PS: 'vcvtdq2ps'; -VCVTNE2PS2BF16: 'vcvtne2ps2bf16'; -VCVTNEEBF162PS: 'vcvtneebf162ps'; -VCVTNEEPH2PS: 'vcvtneeph2ps'; -VCVTNEOBF162PS: 'vcvtneobf162ps'; -VCVTNEOPH2PS: 'vcvtneoph2ps'; -VCVTNEPS2BF16: 'vcvtneps2bf16'; -VCVTPD2DQ: 'vcvtpd2dq'; -VCVTPD2PH: 'vcvtpd2ph'; -VCVTPD2PS: 'vcvtpd2ps'; -VCVTPD2QQ: 'vcvtpd2qq'; -VCVTPD2UDQ: 'vcvtpd2udq'; -VCVTPD2UQQ: 'vcvtpd2uqq'; -VCVTPH2DQ: 'vcvtph2dq'; -VCVTPH2PD: 'vcvtph2pd'; -VCVTPH2PS: 'vcvtph2ps'; -VCVTPH2PSX: 'vcvtph2psx'; -VCVTPH2QQ: 'vcvtph2qq'; -VCVTPH2UDQ: 'vcvtph2udq'; -VCVTPH2UQQ: 'vcvtph2uqq'; -VCVTPH2UW: 'vcvtph2uw'; -VCVTPH2W: 'vcvtph2w'; -VCVTPS2DQ: 'vcvtps2dq'; -VCVTPS2PD: 'vcvtps2pd'; -VCVTPS2PH: 'vcvtps2ph'; -VCVTPS2QQ: 'vcvtps2qq'; -VCVTPS2UDQ: 'vcvtps2udq'; -VCVTPS2UQQ: 'vcvtps2uqq'; -VCVTQQ2PD: 'vcvtqq2pd'; -VCVTQQ2PH: 'vcvtqq2ph'; -VCVTQQ2PS: 'vcvtqq2ps'; -VCVTSD2SH: 'vcvtsd2sh'; -VCVTSD2SI: 'vcvtsd2si'; -VCVTSD2SS: 'vcvtsd2ss'; -VCVTSD2USI: 'vcvtsd2usi'; -VCVTSH2SD: 'vcvtsh2sd'; -VCVTSH2SI: 'vcvtsh2si'; -VCVTSH2SS: 'vcvtsh2ss'; -VCVTSH2USI: 'vcvtsh2usi'; -VCVTSI2SD: 'vcvtsi2sd'; -VCVTSI2SH: 'vcvtsi2sh'; -VCVTSI2SS: 'vcvtsi2ss'; -VCVTSS2SD: 'vcvtss2sd'; -VCVTSS2SH: 'vcvtss2sh'; -VCVTSS2SI: 'vcvtss2si'; -VCVTSS2USI: 'vcvtss2usi'; -VCVTTPD2DQ: 'vcvttpd2dq'; -VCVTTPD2QQ: 'vcvttpd2qq'; -VCVTTPD2UDQ: 'vcvttpd2udq'; -VCVTTPD2UQQ: 'vcvttpd2uqq'; -VCVTTPH2DQ: 'vcvttph2dq'; -VCVTTPH2QQ: 'vcvttph2qq'; -VCVTTPH2UDQ: 'vcvttph2udq'; -VCVTTPH2UQQ: 'vcvttph2uqq'; -VCVTTPH2UW: 'vcvttph2uw'; -VCVTTPH2W: 'vcvttph2w'; -VCVTTPS2DQ: 'vcvttps2dq'; -VCVTTPS2QQ: 'vcvttps2qq'; -VCVTTPS2UDQ: 'vcvttps2udq'; -VCVTTPS2UQQ: 'vcvttps2uqq'; -VCVTTSD2SI: 'vcvttsd2si'; -VCVTTSD2USI: 'vcvttsd2usi'; -VCVTTSH2SI: 'vcvttsh2si'; -VCVTTSH2USI: 'vcvttsh2usi'; -VCVTTSS2SI: 'vcvttss2si'; -VCVTTSS2USI: 'vcvttss2usi'; -VCVTUDQ2PD: 'vcvtudq2pd'; -VCVTUDQ2PH: 'vcvtudq2ph'; -VCVTUDQ2PS: 'vcvtudq2ps'; -VCVTUQQ2PD: 'vcvtuqq2pd'; -VCVTUQQ2PH: 'vcvtuqq2ph'; -VCVTUQQ2PS: 'vcvtuqq2ps'; -VCVTUSI2SD: 'vcvtusi2sd'; -VCVTUSI2SH: 'vcvtusi2sh'; -VCVTUSI2SS: 'vcvtusi2ss'; -VCVTUW2PH: 'vcvtuw2ph'; -VCVTW2PH: 'vcvtw2ph'; -VDBPSADBW: 'vdbpsadbw'; -VDIVPD: 'vdivpd'; -VDIVPH: 'vdivph'; -VDIVPS: 'vdivps'; -VDIVSD: 'vdivsd'; -VDIVSH: 'vdivsh'; -VDIVSS: 'vdivss'; -VDPBF16PS: 'vdpbf16ps'; -VDPPD: 'vdppd'; -VDPPS: 'vdpps'; -VENDSCALEPH: 'vendscaleph'; -VENDSCALESH: 'vendscalesh'; -VEXP2PD: 'vexp2pd'; -VEXP2PS: 'vexp2ps'; -VEXPANDPD: 'vexpandpd'; -VEXPANDPS: 'vexpandps'; -VEXTRACTF128: 'vextractf128'; -VEXTRACTF32X4: 'vextractf32x4'; -VEXTRACTF32X8: 'vextractf32x8'; -VEXTRACTF64X2: 'vextractf64x2'; -VEXTRACTF64X4: 'vextractf64x4'; -VEXTRACTI128: 'vextracti128'; -VEXTRACTI32X4: 'vextracti32x4'; -VEXTRACTI32X8: 'vextracti32x8'; -VEXTRACTI64X2: 'vextracti64x2'; -VEXTRACTI64X4: 'vextracti64x4'; -VEXTRACTPS: 'vextractps'; -VFCMADDCPH: 'vfcmaddcph'; -VFCMADDCSH: 'vfcmaddcsh'; -VFCMULCPCH: 'vfcmulcpch'; -VFCMULCSH: 'vfcmulcsh'; -VFIXUPIMMPD: 'vfixupimmpd'; -VFIXUPIMMPS: 'vfixupimmps'; -VFIXUPIMMSD: 'vfixupimmsd'; -VFIXUPIMMSS: 'vfixupimmss'; -VFMADD123PD: 'vfmadd123pd'; -VFMADD123PS: 'vfmadd123ps'; -VFMADD123SD: 'vfmadd123sd'; -VFMADD123SS: 'vfmadd123ss'; -VFMADD132PD: 'vfmadd132pd'; -VFMADD132PH: 'vfmadd132ph'; -VFMADD132PS: 'vfmadd132ps'; -VFMADD132SD: 'vfmadd132sd'; -VFMADD132SS: 'vfmadd132ss'; -VFMADD213PD: 'vfmadd213pd'; -VFMADD213PH: 'vfmadd213ph'; -VFMADD213PS: 'vfmadd213ps'; -VFMADD213SD: 'vfmadd213sd'; -VFMADD213SS: 'vfmadd213ss'; -VFMADD231PD: 'vfmadd231pd'; -VFMADD231PH: 'vfmadd231ph'; -VFMADD231PS: 'vfmadd231ps'; -VFMADD231SD: 'vfmadd231sd'; -VFMADD231SS: 'vfmadd231ss'; -VFMADD312PD: 'vfmadd312pd'; -VFMADD312PS: 'vfmadd312ps'; -VFMADD312SD: 'vfmadd312sd'; -VFMADD312SS: 'vfmadd312ss'; -VFMADD321PD: 'vfmadd321pd'; -VFMADD321PS: 'vfmadd321ps'; -VFMADD321SD: 'vfmadd321sd'; -VFMADD321SS: 'vfmadd321ss'; -VFMADDCPH: 'vfmaddcph'; -VFMADDCSH: 'vfmaddcsh'; -VFMADDPD: 'vfmaddpd'; -VFMADDPS: 'vfmaddps'; -VFMADDSD: 'vfmaddsd'; -VFMADDSS: 'vfmaddss'; -VFMADDSUB123PD: 'vfmaddsub123pd'; -VFMADDSUB123PS: 'vfmaddsub123ps'; -VFMADDSUB132PD: 'vfmaddsub132pd'; -VFMADDSUB132PH: 'vfmaddsub132ph'; -VFMADDSUB132PS: 'vfmaddsub132ps'; -VFMADDSUB213PD: 'vfmaddsub213pd'; -VFMADDSUB213PH: 'vfmaddsub213ph'; -VFMADDSUB213PS: 'vfmaddsub213ps'; -VFMADDSUB231PD: 'vfmaddsub231pd'; -VFMADDSUB231PH: 'vfmaddsub231ph'; -VFMADDSUB231PS: 'vfmaddsub231ps'; -VFMADDSUB312PD: 'vfmaddsub312pd'; -VFMADDSUB312PS: 'vfmaddsub312ps'; -VFMADDSUB321PD: 'vfmaddsub321pd'; -VFMADDSUB321PS: 'vfmaddsub321ps'; -VFMADDSUBPD: 'vfmaddsubpd'; -VFMADDSUBPS: 'vfmaddsubps'; -VFMSUB123PD: 'vfmsub123pd'; -VFMSUB123PS: 'vfmsub123ps'; -VFMSUB123SD: 'vfmsub123sd'; -VFMSUB123SS: 'vfmsub123ss'; -VFMSUB132PD: 'vfmsub132pd'; -VFMSUB132PH: 'vfmsub132ph'; -VFMSUB132PS: 'vfmsub132ps'; -VFMSUB132SD: 'vfmsub132sd'; -VFMSUB132SS: 'vfmsub132ss'; -VFMSUB213PD: 'vfmsub213pd'; -VFMSUB213PH: 'vfmsub213ph'; -VFMSUB213PS: 'vfmsub213ps'; -VFMSUB213SD: 'vfmsub213sd'; -VFMSUB213SS: 'vfmsub213ss'; -VFMSUB231PD: 'vfmsub231pd'; -VFMSUB231PH: 'vfmsub231ph'; -VFMSUB231PS: 'vfmsub231ps'; -VFMSUB231SD: 'vfmsub231sd'; -VFMSUB231SS: 'vfmsub231ss'; -VFMSUB312PD: 'vfmsub312pd'; -VFMSUB312PS: 'vfmsub312ps'; -VFMSUB312SD: 'vfmsub312sd'; -VFMSUB312SS: 'vfmsub312ss'; -VFMSUB321PD: 'vfmsub321pd'; -VFMSUB321PS: 'vfmsub321ps'; -VFMSUB321SD: 'vfmsub321sd'; -VFMSUB321SS: 'vfmsub321ss'; -VFMSUBADD123PD: 'vfmsubadd123pd'; -VFMSUBADD123PS: 'vfmsubadd123ps'; -VFMSUBADD132PD: 'vfmsubadd132pd'; -VFMSUBADD132PH: 'vfmsubadd132ph'; -VFMSUBADD132PS: 'vfmsubadd132ps'; -VFMSUBADD213PD: 'vfmsubadd213pd'; -VFMSUBADD213PH: 'vfmsubadd213ph'; -VFMSUBADD213PS: 'vfmsubadd213ps'; -VFMSUBADD231PD: 'vfmsubadd231pd'; -VFMSUBADD231PH: 'vfmsubadd231ph'; -VFMSUBADD231PS: 'vfmsubadd231ps'; -VFMSUBADD312PD: 'vfmsubadd312pd'; -VFMSUBADD312PS: 'vfmsubadd312ps'; -VFMSUBADD321PD: 'vfmsubadd321pd'; -VFMSUBADD321PS: 'vfmsubadd321ps'; -VFMSUBADDPD: 'vfmsubaddpd'; -VFMSUBADDPS: 'vfmsubaddps'; -VFMSUBPD: 'vfmsubpd'; -VFMSUBPS: 'vfmsubps'; -VFMSUBSD: 'vfmsubsd'; -VFMSUBSS: 'vfmsubss'; -VFMULCPCH: 'vfmulcpch'; -VFMULCSH: 'vfmulcsh'; -VFNMADD123PD: 'vfnmadd123pd'; -VFNMADD123PS: 'vfnmadd123ps'; -VFNMADD123SD: 'vfnmadd123sd'; -VFNMADD123SS: 'vfnmadd123ss'; -VFNMADD132PD: 'vfnmadd132pd'; -VFNMADD132PS: 'vfnmadd132ps'; -VFNMADD132SD: 'vfnmadd132sd'; -VFNMADD132SS: 'vfnmadd132ss'; -VFNMADD213PD: 'vfnmadd213pd'; -VFNMADD213PS: 'vfnmadd213ps'; -VFNMADD213SD: 'vfnmadd213sd'; -VFNMADD213SS: 'vfnmadd213ss'; -VFNMADD231PD: 'vfnmadd231pd'; -VFNMADD231PS: 'vfnmadd231ps'; -VFNMADD231SD: 'vfnmadd231sd'; -VFNMADD231SS: 'vfnmadd231ss'; -VFNMADD312PD: 'vfnmadd312pd'; -VFNMADD312PS: 'vfnmadd312ps'; -VFNMADD312SD: 'vfnmadd312sd'; -VFNMADD312SS: 'vfnmadd312ss'; -VFNMADD321PD: 'vfnmadd321pd'; -VFNMADD321PS: 'vfnmadd321ps'; -VFNMADD321SD: 'vfnmadd321sd'; -VFNMADD321SS: 'vfnmadd321ss'; -VFNMADDPD: 'vfnmaddpd'; -VFNMADDPS: 'vfnmaddps'; -VFNMADDSD: 'vfnmaddsd'; -VFNMADDSS: 'vfnmaddss'; -VFNMSUB123PD: 'vfnmsub123pd'; -VFNMSUB123PS: 'vfnmsub123ps'; -VFNMSUB123SD: 'vfnmsub123sd'; -VFNMSUB123SS: 'vfnmsub123ss'; -VFNMSUB132PD: 'vfnmsub132pd'; -VFNMSUB132PS: 'vfnmsub132ps'; -VFNMSUB132SD: 'vfnmsub132sd'; -VFNMSUB132SS: 'vfnmsub132ss'; -VFNMSUB213PD: 'vfnmsub213pd'; -VFNMSUB213PS: 'vfnmsub213ps'; -VFNMSUB213SD: 'vfnmsub213sd'; -VFNMSUB213SS: 'vfnmsub213ss'; -VFNMSUB231PD: 'vfnmsub231pd'; -VFNMSUB231PS: 'vfnmsub231ps'; -VFNMSUB231SD: 'vfnmsub231sd'; -VFNMSUB231SS: 'vfnmsub231ss'; -VFNMSUB312PD: 'vfnmsub312pd'; -VFNMSUB312PS: 'vfnmsub312ps'; -VFNMSUB312SD: 'vfnmsub312sd'; -VFNMSUB312SS: 'vfnmsub312ss'; -VFNMSUB321PD: 'vfnmsub321pd'; -VFNMSUB321PS: 'vfnmsub321ps'; -VFNMSUB321SD: 'vfnmsub321sd'; -VFNMSUB321SS: 'vfnmsub321ss'; -VFNMSUBPD: 'vfnmsubpd'; -VFNMSUBPS: 'vfnmsubps'; -VFNMSUBSD: 'vfnmsubsd'; -VFNMSUBSS: 'vfnmsubss'; -VFPCLASSPD: 'vfpclasspd'; -VFPCLASSPH: 'vfpclassph'; -VFPCLASSPS: 'vfpclassps'; -VFPCLASSSD: 'vfpclasssd'; -VFPCLASSSH: 'vfpclasssh'; -VFPCLASSSS: 'vfpclassss'; -VFRCZPD: 'vfrczpd'; -VFRCZPS: 'vfrczps'; -VFRCZSD: 'vfrczsd'; -VFRCZSS: 'vfrczss'; -VGATHERDPD: 'vgatherdpd'; -VGATHERDPS: 'vgatherdps'; -VGATHERPF0DPD: 'vgatherpf0dpd'; -VGATHERPF0DPS: 'vgatherpf0dps'; -VGATHERPF0QPD: 'vgatherpf0qpd'; -VGATHERPF0QPS: 'vgatherpf0qps'; -VGATHERPF1DPD: 'vgatherpf1dpd'; -VGATHERPF1DPS: 'vgatherpf1dps'; -VGATHERPF1QPD: 'vgatherpf1qpd'; -VGATHERPF1QPS: 'vgatherpf1qps'; -VGATHERQPD: 'vgatherqpd'; -VGATHERQPS: 'vgatherqps'; -VGETEXPPD: 'vgetexppd'; -VGETEXPPH: 'vgetexpph'; -VGETEXPPS: 'vgetexpps'; -VGETEXPSD: 'vgetexpsd'; -VGETEXPSH: 'vgetexpsh'; -VGETEXPSS: 'vgetexpss'; -VGETMANTPD: 'vgetmantpd'; -VGETMANTPH: 'vgetmantph'; -VGETMANTPS: 'vgetmantps'; -VGETMANTSD: 'vgetmantsd'; -VGETMANTSH: 'vgetmantsh'; -VGETMANTSS: 'vgetmantss'; -VGETMAXPH: 'vgetmaxph'; -VGETMAXSH: 'vgetmaxsh'; -VGETMINPH: 'vgetminph'; -VGETMINSH: 'vgetminsh'; -VGF2P8AFFINEINVQB: 'vgf2p8affineinvqb'; -VGF2P8AFFINEQB: 'vgf2p8affineqb'; -VGF2P8MULB: 'vgf2p8mulb'; -VHADDPD: 'vhaddpd'; -VHADDPS: 'vhaddps'; -VHSUBPD: 'vhsubpd'; -VHSUBPS: 'vhsubps'; -VINSERTF128: 'vinsertf128'; -VINSERTF32X4: 'vinsertf32x4'; -VINSERTF32X8: 'vinsertf32x8'; -VINSERTF64X2: 'vinsertf64x2'; -VINSERTF64X4: 'vinsertf64x4'; -VINSERTI128: 'vinserti128'; -VINSERTI32X4: 'vinserti32x4'; -VINSERTI32X8: 'vinserti32x8'; -VINSERTI64X2: 'vinserti64x2'; -VINSERTI64X4: 'vinserti64x4'; -VINSERTPS: 'vinsertps'; -VLDDQU: 'vlddqu'; -VLDMXCSR: 'vldmxcsr'; -VLDQQU: 'vldqqu'; -VMASKMOVDQU: 'vmaskmovdqu'; -VMASKMOVPD: 'vmaskmovpd'; -VMASKMOVPS: 'vmaskmovps'; -VMAXPD: 'vmaxpd'; -VMAXPS: 'vmaxps'; -VMAXSD: 'vmaxsd'; -VMAXSS: 'vmaxss'; -VMCALL: 'vmcall'; -VMCLEAR: 'vmclear'; -VMFUNC: 'vmfunc'; -VMGEXIT: 'vmgexit'; -VMINPD: 'vminpd'; -VMINPS: 'vminps'; -VMINSD: 'vminsd'; -VMINSS: 'vminss'; -VMLAUNCH: 'vmlaunch'; -VMLOAD: 'vmload'; -VMMCALL: 'vmmcall'; -VMOVAPD: 'vmovapd'; -VMOVAPS: 'vmovaps'; -VMOVD: 'vmovd'; -VMOVDDUP: 'vmovddup'; -VMOVDQA: 'vmovdqa'; -VMOVDQA32: 'vmovdqa32'; -VMOVDQA64: 'vmovdqa64'; -VMOVDQU: 'vmovdqu'; -VMOVDQU16: 'vmovdqu16'; -VMOVDQU32: 'vmovdqu32'; -VMOVDQU64: 'vmovdqu64'; -VMOVDQU8: 'vmovdqu8'; -VMOVHLPS: 'vmovhlps'; -VMOVHPD: 'vmovhpd'; -VMOVHPS: 'vmovhps'; -VMOVLHPS: 'vmovlhps'; -VMOVLPD: 'vmovlpd'; -VMOVLPS: 'vmovlps'; -VMOVMSKPD: 'vmovmskpd'; -VMOVMSKPS: 'vmovmskps'; -VMOVNTDQ: 'vmovntdq'; -VMOVNTDQA: 'vmovntdqa'; -VMOVNTPD: 'vmovntpd'; -VMOVNTPS: 'vmovntps'; -VMOVNTQQ: 'vmovntqq'; -VMOVQ: 'vmovq'; -VMOVQQA: 'vmovqqa'; -VMOVQQU: 'vmovqqu'; -VMOVSD: 'vmovsd'; -VMOVSH: 'vmovsh'; -VMOVSHDUP: 'vmovshdup'; -VMOVSLDUP: 'vmovsldup'; -VMOVSS: 'vmovss'; -VMOVUPD: 'vmovupd'; -VMOVUPS: 'vmovups'; -VMOVW: 'vmovw'; -VMPSADBW: 'vmpsadbw'; -VMPTRLD: 'vmptrld'; -VMPTRST: 'vmptrst'; -VMREAD: 'vmread'; -VMRESUME: 'vmresume'; -VMRUN: 'vmrun'; -VMSAVE: 'vmsave'; -VMULPD: 'vmulpd'; -VMULPH: 'vmulph'; -VMULPS: 'vmulps'; -VMULSD: 'vmulsd'; -VMULSH: 'vmulsh'; -VMULSS: 'vmulss'; -VMWRITE: 'vmwrite'; -VMXOFF: 'vmxoff'; -VMXON: 'vmxon'; -VORPD: 'vorpd'; -VORPS: 'vorps'; -VP2INTERSECTD: 'vp2intersectd'; -VPABSB: 'vpabsb'; -VPABSD: 'vpabsd'; -VPABSQ: 'vpabsq'; -VPABSW: 'vpabsw'; -VPACKSSDW: 'vpackssdw'; -VPACKSSWB: 'vpacksswb'; -VPACKUSDW: 'vpackusdw'; -VPACKUSWB: 'vpackuswb'; -VPADDB: 'vpaddb'; -VPADDD: 'vpaddd'; -VPADDQ: 'vpaddq'; -VPADDSB: 'vpaddsb'; -VPADDSW: 'vpaddsw'; -VPADDUSB: 'vpaddusb'; -VPADDUSW: 'vpaddusw'; -VPADDW: 'vpaddw'; -VPALIGNR: 'vpalignr'; -VPAND: 'vpand'; -VPANDD: 'vpandd'; -VPANDN: 'vpandn'; -VPANDND: 'vpandnd'; -VPANDNQ: 'vpandnq'; -VPANDQ: 'vpandq'; -VPAVGB: 'vpavgb'; -VPAVGW: 'vpavgw'; -VPBLENDD: 'vpblendd'; -VPBLENDMB: 'vpblendmb'; -VPBLENDMD: 'vpblendmd'; -VPBLENDMQ: 'vpblendmq'; -VPBLENDMW: 'vpblendmw'; -VPBLENDVB: 'vpblendvb'; -VPBLENDW: 'vpblendw'; -VPBROADCASTB: 'vpbroadcastb'; -VPBROADCASTD: 'vpbroadcastd'; -VPBROADCASTMB2Q: 'vpbroadcastmb2q'; -VPBROADCASTMW2D: 'vpbroadcastmw2d'; -VPBROADCASTQ: 'vpbroadcastq'; -VPBROADCASTW: 'vpbroadcastw'; -VPCLMULHQHQDQ: 'vpclmulhqhqdq'; -VPCLMULHQLQDQ: 'vpclmulhqlqdq'; -VPCLMULLQHQDQ: 'vpclmullqhqdq'; -VPCLMULLQLQDQ: 'vpclmullqlqdq'; -VPCLMULQDQ: 'vpclmulqdq'; -VPCMOV: 'vpcmov'; -VPCMPB: 'vpcmpb'; -VPCMPD: 'vpcmpd'; -VPCMPEQB: 'vpcmpeqb'; -VPCMPEQD: 'vpcmpeqd'; -VPCMPEQQ: 'vpcmpeqq'; -VPCMPEQUB: 'vpcmpequb'; -VPCMPEQUD: 'vpcmpequd'; -VPCMPEQUQ: 'vpcmpequq'; -VPCMPEQUW: 'vpcmpequw'; -VPCMPEQW: 'vpcmpeqw'; -VPCMPESTRI: 'vpcmpestri'; -VPCMPESTRM: 'vpcmpestrm'; -VPCMPGEB: 'vpcmpgeb'; -VPCMPGED: 'vpcmpged'; -VPCMPGEQ: 'vpcmpgeq'; -VPCMPGEUB: 'vpcmpgeub'; -VPCMPGEUD: 'vpcmpgeud'; -VPCMPGEUQ: 'vpcmpgeuq'; -VPCMPGEUW: 'vpcmpgeuw'; -VPCMPGEW: 'vpcmpgew'; -VPCMPGTB: 'vpcmpgtb'; -VPCMPGTD: 'vpcmpgtd'; -VPCMPGTQ: 'vpcmpgtq'; -VPCMPGTUB: 'vpcmpgtub'; -VPCMPGTUD: 'vpcmpgtud'; -VPCMPGTUQ: 'vpcmpgtuq'; -VPCMPGTUW: 'vpcmpgtuw'; -VPCMPGTW: 'vpcmpgtw'; -VPCMPISTRI: 'vpcmpistri'; -VPCMPISTRM: 'vpcmpistrm'; -VPCMPLEB: 'vpcmpleb'; -VPCMPLED: 'vpcmpled'; -VPCMPLEQ: 'vpcmpleq'; -VPCMPLEUB: 'vpcmpleub'; -VPCMPLEUD: 'vpcmpleud'; -VPCMPLEUQ: 'vpcmpleuq'; -VPCMPLEUW: 'vpcmpleuw'; -VPCMPLEW: 'vpcmplew'; -VPCMPLTB: 'vpcmpltb'; -VPCMPLTD: 'vpcmpltd'; -VPCMPLTQ: 'vpcmpltq'; -VPCMPLTUB: 'vpcmpltub'; -VPCMPLTUD: 'vpcmpltud'; -VPCMPLTUQ: 'vpcmpltuq'; -VPCMPLTUW: 'vpcmpltuw'; -VPCMPLTW: 'vpcmpltw'; -VPCMPNEQB: 'vpcmpneqb'; -VPCMPNEQD: 'vpcmpneqd'; -VPCMPNEQQ: 'vpcmpneqq'; -VPCMPNEQUB: 'vpcmpnequb'; -VPCMPNEQUD: 'vpcmpnequd'; -VPCMPNEQUQ: 'vpcmpnequq'; -VPCMPNEQUW: 'vpcmpnequw'; -VPCMPNEQW: 'vpcmpneqw'; -VPCMPNGTB: 'vpcmpngtb'; -VPCMPNGTD: 'vpcmpngtd'; -VPCMPNGTQ: 'vpcmpngtq'; -VPCMPNGTUB: 'vpcmpngtub'; -VPCMPNGTUD: 'vpcmpngtud'; -VPCMPNGTUQ: 'vpcmpngtuq'; -VPCMPNGTUW: 'vpcmpngtuw'; -VPCMPNGTW: 'vpcmpngtw'; -VPCMPNLEB: 'vpcmpnleb'; -VPCMPNLED: 'vpcmpnled'; -VPCMPNLEQ: 'vpcmpnleq'; -VPCMPNLEUB: 'vpcmpnleub'; -VPCMPNLEUD: 'vpcmpnleud'; -VPCMPNLEUQ: 'vpcmpnleuq'; -VPCMPNLEUW: 'vpcmpnleuw'; -VPCMPNLEW: 'vpcmpnlew'; -VPCMPNLTB: 'vpcmpnltb'; -VPCMPNLTD: 'vpcmpnltd'; -VPCMPNLTQ: 'vpcmpnltq'; -VPCMPNLTUB: 'vpcmpnltub'; -VPCMPNLTUD: 'vpcmpnltud'; -VPCMPNLTUQ: 'vpcmpnltuq'; -VPCMPNLTUW: 'vpcmpnltuw'; -VPCMPNLTW: 'vpcmpnltw'; -VPCMPQ: 'vpcmpq'; -VPCMPUB: 'vpcmpub'; -VPCMPUD: 'vpcmpud'; -VPCMPUQ: 'vpcmpuq'; -VPCMPUW: 'vpcmpuw'; -VPCMPW: 'vpcmpw'; -VPCOMB: 'vpcomb'; -VPCOMD: 'vpcomd'; -VPCOMPRESSB: 'vpcompressb'; -VPCOMPRESSD: 'vpcompressd'; -VPCOMPRESSQ: 'vpcompressq'; -VPCOMPRESSW: 'vpcompressw'; -VPCOMQ: 'vpcomq'; -VPCOMUB: 'vpcomub'; -VPCOMUD: 'vpcomud'; -VPCOMUQ: 'vpcomuq'; -VPCOMUW: 'vpcomuw'; -VPCOMW: 'vpcomw'; -VPCONFLICTD: 'vpconflictd'; -VPCONFLICTQ: 'vpconflictq'; -VPDPBSSD: 'vpdpbssd'; -VPDPBSSDS: 'vpdpbssds'; -VPDPBSUD: 'vpdpbsud'; -VPDPBSUDS: 'vpdpbsuds'; -VPDPBUSD: 'vpdpbusd'; -VPDPBUSDS: 'vpdpbusds'; -VPDPBUUD: 'vpdpbuud'; -VPDPBUUDS: 'vpdpbuuds'; -VPDPWSSD: 'vpdpwssd'; -VPDPWSSDS: 'vpdpwssds'; -VPERM2F128: 'vperm2f128'; -VPERM2I128: 'vperm2i128'; -VPERMB: 'vpermb'; -VPERMD: 'vpermd'; -VPERMI2B: 'vpermi2b'; -VPERMI2D: 'vpermi2d'; -VPERMI2PD: 'vpermi2pd'; -VPERMI2PS: 'vpermi2ps'; -VPERMI2Q: 'vpermi2q'; -VPERMI2W: 'vpermi2w'; -VPERMILPD: 'vpermilpd'; -VPERMILPS: 'vpermilps'; -VPERMPD: 'vpermpd'; -VPERMPS: 'vpermps'; -VPERMQ: 'vpermq'; -VPERMT2B: 'vpermt2b'; -VPERMT2D: 'vpermt2d'; -VPERMT2PD: 'vpermt2pd'; -VPERMT2PS: 'vpermt2ps'; -VPERMT2Q: 'vpermt2q'; -VPERMT2W: 'vpermt2w'; -VPERMW: 'vpermw'; -VPEXPANDB: 'vpexpandb'; -VPEXPANDD: 'vpexpandd'; -VPEXPANDQ: 'vpexpandq'; -VPEXPANDW: 'vpexpandw'; -VPEXTRB: 'vpextrb'; -VPEXTRD: 'vpextrd'; -VPEXTRQ: 'vpextrq'; -VPEXTRW: 'vpextrw'; -VPGATHERDD: 'vpgatherdd'; -VPGATHERDQ: 'vpgatherdq'; -VPGATHERQD: 'vpgatherqd'; -VPGATHERQQ: 'vpgatherqq'; -VPHADDBD: 'vphaddbd'; -VPHADDBQ: 'vphaddbq'; -VPHADDBW: 'vphaddbw'; -VPHADDD: 'vphaddd'; -VPHADDDQ: 'vphadddq'; -VPHADDSW: 'vphaddsw'; -VPHADDUBD: 'vphaddubd'; -VPHADDUBQ: 'vphaddubq'; -VPHADDUBW: 'vphaddubw'; -VPHADDUDQ: 'vphaddudq'; -VPHADDUWD: 'vphadduwd'; -VPHADDUWQ: 'vphadduwq'; -VPHADDW: 'vphaddw'; -VPHADDWD: 'vphaddwd'; -VPHADDWQ: 'vphaddwq'; -VPHMINPOSUW: 'vphminposuw'; -VPHSUBBW: 'vphsubbw'; -VPHSUBD: 'vphsubd'; -VPHSUBDQ: 'vphsubdq'; -VPHSUBSW: 'vphsubsw'; -VPHSUBW: 'vphsubw'; -VPHSUBWD: 'vphsubwd'; -VPINSRB: 'vpinsrb'; -VPINSRD: 'vpinsrd'; -VPINSRQ: 'vpinsrq'; -VPINSRW: 'vpinsrw'; -VPLZCNTD: 'vplzcntd'; -VPLZCNTQ: 'vplzcntq'; -VPMACSDD: 'vpmacsdd'; -VPMACSDQH: 'vpmacsdqh'; -VPMACSDQL: 'vpmacsdql'; -VPMACSSDD: 'vpmacssdd'; -VPMACSSDQH: 'vpmacssdqh'; -VPMACSSDQL: 'vpmacssdql'; -VPMACSSWD: 'vpmacsswd'; -VPMACSSWW: 'vpmacssww'; -VPMACSWD: 'vpmacswd'; -VPMACSWW: 'vpmacsww'; -VPMADCSSWD: 'vpmadcsswd'; -VPMADCSWD: 'vpmadcswd'; -VPMADD132PH: 'vpmadd132ph'; -VPMADD132SH: 'vpmadd132sh'; -VPMADD213PH: 'vpmadd213ph'; -VPMADD213SH: 'vpmadd213sh'; -VPMADD231PH: 'vpmadd231ph'; -VPMADD231SH: 'vpmadd231sh'; -VPMADD52HUQ: 'vpmadd52huq'; -VPMADD52LUQ: 'vpmadd52luq'; -VPMADDUBSW: 'vpmaddubsw'; -VPMADDWD: 'vpmaddwd'; -VPMASKMOVD: 'vpmaskmovd'; -VPMASKMOVQ: 'vpmaskmovq'; -VPMAXSB: 'vpmaxsb'; -VPMAXSD: 'vpmaxsd'; -VPMAXSQ: 'vpmaxsq'; -VPMAXSW: 'vpmaxsw'; -VPMAXUB: 'vpmaxub'; -VPMAXUD: 'vpmaxud'; -VPMAXUQ: 'vpmaxuq'; -VPMAXUW: 'vpmaxuw'; -VPMINSB: 'vpminsb'; -VPMINSD: 'vpminsd'; -VPMINSQ: 'vpminsq'; -VPMINSW: 'vpminsw'; -VPMINUB: 'vpminub'; -VPMINUD: 'vpminud'; -VPMINUQ: 'vpminuq'; -VPMINUW: 'vpminuw'; -VPMOVB2M: 'vpmovb2m'; -VPMOVD2M: 'vpmovd2m'; -VPMOVDB: 'vpmovdb'; -VPMOVDW: 'vpmovdw'; -VPMOVM2B: 'vpmovm2b'; -VPMOVM2D: 'vpmovm2d'; -VPMOVM2Q: 'vpmovm2q'; -VPMOVM2W: 'vpmovm2w'; -VPMOVMSKB: 'vpmovmskb'; -VPMOVQ2M: 'vpmovq2m'; -VPMOVQB: 'vpmovqb'; -VPMOVQD: 'vpmovqd'; -VPMOVQW: 'vpmovqw'; -VPMOVSDB: 'vpmovsdb'; -VPMOVSDW: 'vpmovsdw'; -VPMOVSQB: 'vpmovsqb'; -VPMOVSQD: 'vpmovsqd'; -VPMOVSQW: 'vpmovsqw'; -VPMOVSWB: 'vpmovswb'; -VPMOVSXBD: 'vpmovsxbd'; -VPMOVSXBQ: 'vpmovsxbq'; -VPMOVSXBW: 'vpmovsxbw'; -VPMOVSXDQ: 'vpmovsxdq'; -VPMOVSXWD: 'vpmovsxwd'; -VPMOVSXWQ: 'vpmovsxwq'; -VPMOVUSDB: 'vpmovusdb'; -VPMOVUSDW: 'vpmovusdw'; -VPMOVUSQB: 'vpmovusqb'; -VPMOVUSQD: 'vpmovusqd'; -VPMOVUSQW: 'vpmovusqw'; -VPMOVUSWB: 'vpmovuswb'; -VPMOVW2M: 'vpmovw2m'; -VPMOVWB: 'vpmovwb'; -VPMOVZXBD: 'vpmovzxbd'; -VPMOVZXBQ: 'vpmovzxbq'; -VPMOVZXBW: 'vpmovzxbw'; -VPMOVZXDQ: 'vpmovzxdq'; -VPMOVZXWD: 'vpmovzxwd'; -VPMOVZXWQ: 'vpmovzxwq'; -VPMSUB132PH: 'vpmsub132ph'; -VPMSUB132SH: 'vpmsub132sh'; -VPMSUB213PH: 'vpmsub213ph'; -VPMSUB213SH: 'vpmsub213sh'; -VPMSUB231PH: 'vpmsub231ph'; -VPMSUB231SH: 'vpmsub231sh'; -VPMULDQ: 'vpmuldq'; -VPMULHRSW: 'vpmulhrsw'; -VPMULHUW: 'vpmulhuw'; -VPMULHW: 'vpmulhw'; -VPMULLD: 'vpmulld'; -VPMULLQ: 'vpmullq'; -VPMULLW: 'vpmullw'; -VPMULTISHIFTQB: 'vpmultishiftqb'; -VPMULUDQ: 'vpmuludq'; -VPNMADD132SH: 'vpnmadd132sh'; -VPNMADD213SH: 'vpnmadd213sh'; -VPNMADD231SH: 'vpnmadd231sh'; -VPNMSUB132SH: 'vpnmsub132sh'; -VPNMSUB213SH: 'vpnmsub213sh'; -VPNMSUB231SH: 'vpnmsub231sh'; -VPOPCNTB: 'vpopcntb'; -VPOPCNTD: 'vpopcntd'; -VPOPCNTQ: 'vpopcntq'; -VPOPCNTW: 'vpopcntw'; -VPOR: 'vpor'; -VPORD: 'vpord'; -VPORQ: 'vporq'; -VPPERM: 'vpperm'; -VPROLD: 'vprold'; -VPROLQ: 'vprolq'; -VPROLVD: 'vprolvd'; -VPROLVQ: 'vprolvq'; -VPRORD: 'vprord'; -VPRORQ: 'vprorq'; -VPRORVD: 'vprorvd'; -VPRORVQ: 'vprorvq'; -VPROTB: 'vprotb'; -VPROTD: 'vprotd'; -VPROTQ: 'vprotq'; -VPROTW: 'vprotw'; -VPSADBW: 'vpsadbw'; -VPSCATTERDD: 'vpscatterdd'; -VPSCATTERDQ: 'vpscatterdq'; -VPSCATTERQD: 'vpscatterqd'; -VPSCATTERQQ: 'vpscatterqq'; -VPSHAB: 'vpshab'; -VPSHAD: 'vpshad'; -VPSHAQ: 'vpshaq'; -VPSHAW: 'vpshaw'; -VPSHLB: 'vpshlb'; -VPSHLD: 'vpshld'; -VPSHLDD: 'vpshldd'; -VPSHLDQ: 'vpshldq'; -VPSHLDVD: 'vpshldvd'; -VPSHLDVQ: 'vpshldvq'; -VPSHLDVW: 'vpshldvw'; -VPSHLDW: 'vpshldw'; -VPSHLQ: 'vpshlq'; -VPSHLW: 'vpshlw'; -VPSHRDD: 'vpshrdd'; -VPSHRDQ: 'vpshrdq'; -VPSHRDVD: 'vpshrdvd'; -VPSHRDVQ: 'vpshrdvq'; -VPSHRDVW: 'vpshrdvw'; -VPSHRDW: 'vpshrdw'; -VPSHUFB: 'vpshufb'; -VPSHUFBITQMB: 'vpshufbitqmb'; -VPSHUFD: 'vpshufd'; -VPSHUFHW: 'vpshufhw'; -VPSHUFLW: 'vpshuflw'; -VPSIGNB: 'vpsignb'; -VPSIGND: 'vpsignd'; -VPSIGNW: 'vpsignw'; -VPSLLD: 'vpslld'; -VPSLLDQ: 'vpslldq'; -VPSLLQ: 'vpsllq'; -VPSLLVD: 'vpsllvd'; -VPSLLVQ: 'vpsllvq'; -VPSLLVW: 'vpsllvw'; -VPSLLW: 'vpsllw'; -VPSRAD: 'vpsrad'; -VPSRAQ: 'vpsraq'; -VPSRAVD: 'vpsravd'; -VPSRAVQ: 'vpsravq'; -VPSRAVW: 'vpsravw'; -VPSRAW: 'vpsraw'; -VPSRLD: 'vpsrld'; -VPSRLDQ: 'vpsrldq'; -VPSRLQ: 'vpsrlq'; -VPSRLVD: 'vpsrlvd'; -VPSRLVQ: 'vpsrlvq'; -VPSRLVW: 'vpsrlvw'; -VPSRLW: 'vpsrlw'; -VPSUBB: 'vpsubb'; -VPSUBD: 'vpsubd'; -VPSUBQ: 'vpsubq'; -VPSUBSB: 'vpsubsb'; -VPSUBSW: 'vpsubsw'; -VPSUBUSB: 'vpsubusb'; -VPSUBUSW: 'vpsubusw'; -VPSUBW: 'vpsubw'; -VPTERNLOGD: 'vpternlogd'; -VPTERNLOGQ: 'vpternlogq'; -VPTEST: 'vptest'; -VPTESTMB: 'vptestmb'; -VPTESTMD: 'vptestmd'; -VPTESTMQ: 'vptestmq'; -VPTESTMW: 'vptestmw'; -VPTESTNMB: 'vptestnmb'; -VPTESTNMD: 'vptestnmd'; -VPTESTNMQ: 'vptestnmq'; -VPTESTNMW: 'vptestnmw'; -VPUNPCKHBW: 'vpunpckhbw'; -VPUNPCKHDQ: 'vpunpckhdq'; -VPUNPCKHQDQ: 'vpunpckhqdq'; -VPUNPCKHWD: 'vpunpckhwd'; -VPUNPCKLBW: 'vpunpcklbw'; -VPUNPCKLDQ: 'vpunpckldq'; -VPUNPCKLQDQ: 'vpunpcklqdq'; -VPUNPCKLWD: 'vpunpcklwd'; -VPXOR: 'vpxor'; -VPXORD: 'vpxord'; -VPXORQ: 'vpxorq'; -VRANGEPD: 'vrangepd'; -VRANGEPS: 'vrangeps'; -VRANGESD: 'vrangesd'; -VRANGESS: 'vrangess'; -VRCP14PD: 'vrcp14pd'; -VRCP14PS: 'vrcp14ps'; -VRCP14SD: 'vrcp14sd'; -VRCP14SS: 'vrcp14ss'; -VRCP28PD: 'vrcp28pd'; -VRCP28PS: 'vrcp28ps'; -VRCP28SD: 'vrcp28sd'; -VRCP28SS: 'vrcp28ss'; -VRCPPH: 'vrcpph'; -VRCPPS: 'vrcpps'; -VRCPSH: 'vrcpsh'; -VRCPSS: 'vrcpss'; -VREDUCEPD: 'vreducepd'; -VREDUCEPH: 'vreduceph'; -VREDUCEPS: 'vreduceps'; -VREDUCESD: 'vreducesd'; -VREDUCESH: 'vreducesh'; -VREDUCESS: 'vreducess'; -VRNDSCALEPD: 'vrndscalepd'; -VRNDSCALEPS: 'vrndscaleps'; -VRNDSCALESD: 'vrndscalesd'; -VRNDSCALESS: 'vrndscaless'; -VROUNDPD: 'vroundpd'; -VROUNDPS: 'vroundps'; -VROUNDSD: 'vroundsd'; -VROUNDSS: 'vroundss'; -VRSQRT14PD: 'vrsqrt14pd'; -VRSQRT14PS: 'vrsqrt14ps'; -VRSQRT14SD: 'vrsqrt14sd'; -VRSQRT14SS: 'vrsqrt14ss'; -VRSQRT28PD: 'vrsqrt28pd'; -VRSQRT28PS: 'vrsqrt28ps'; -VRSQRT28SD: 'vrsqrt28sd'; -VRSQRT28SS: 'vrsqrt28ss'; -VRSQRTPH: 'vrsqrtph'; -VRSQRTPS: 'vrsqrtps'; -VRSQRTSH: 'vrsqrtsh'; -VRSQRTSS: 'vrsqrtss'; -VSCALEFPD: 'vscalefpd'; -VSCALEFPH: 'vscalefph'; -VSCALEFPS: 'vscalefps'; -VSCALEFSD: 'vscalefsd'; -VSCALEFSH: 'vscalefsh'; -VSCALEFSS: 'vscalefss'; -VSCATTERDPD: 'vscatterdpd'; -VSCATTERDPS: 'vscatterdps'; -VSCATTERPF0DPD: 'vscatterpf0dpd'; -VSCATTERPF0DPS: 'vscatterpf0dps'; -VSCATTERPF0QPD: 'vscatterpf0qpd'; -VSCATTERPF0QPS: 'vscatterpf0qps'; -VSCATTERPF1DPD: 'vscatterpf1dpd'; -VSCATTERPF1DPS: 'vscatterpf1dps'; -VSCATTERPF1QPD: 'vscatterpf1qpd'; -VSCATTERPF1QPS: 'vscatterpf1qps'; -VSCATTERQPD: 'vscatterqpd'; -VSCATTERQPS: 'vscatterqps'; -VSHUFF32X4: 'vshuff32x4'; -VSHUFF64X2: 'vshuff64x2'; -VSHUFI32X4: 'vshufi32x4'; -VSHUFI64X2: 'vshufi64x2'; -VSHUFPD: 'vshufpd'; -VSHUFPS: 'vshufps'; -VSQRTPD: 'vsqrtpd'; -VSQRTPH: 'vsqrtph'; -VSQRTPS: 'vsqrtps'; -VSQRTSD: 'vsqrtsd'; -VSQRTSH: 'vsqrtsh'; -VSQRTSS: 'vsqrtss'; -VSTMXCSR: 'vstmxcsr'; -VSUBPD: 'vsubpd'; -VSUBPH: 'vsubph'; -VSUBPS: 'vsubps'; -VSUBSD: 'vsubsd'; -VSUBSH: 'vsubsh'; -VSUBSS: 'vsubss'; -VTESTPD: 'vtestpd'; -VTESTPS: 'vtestps'; -VUCOMISD: 'vucomisd'; -VUCOMISH: 'vucomish'; -VUCOMISS: 'vucomiss'; -VUNPCKHPD: 'vunpckhpd'; -VUNPCKHPS: 'vunpckhps'; -VUNPCKLPD: 'vunpcklpd'; -VUNPCKLPS: 'vunpcklps'; -VXORPD: 'vxorpd'; -VXORPS: 'vxorps'; -VZEROALL: 'vzeroall'; -VZEROUPPER: 'vzeroupper'; -WBNOINVD: 'wbnoinvd'; -WRFSBASE: 'wrfsbase'; -WRGSBASE: 'wrgsbase'; -WRMSRLIST: 'wrmsrlist'; -WRMSRNS: 'wrmsrns'; -WRPKRU: 'wrpkru'; -WRSSD: 'wrssd'; -WRSSQ: 'wrssq'; -WRUSSD: 'wrussd'; -WRUSSQ: 'wrussq'; -XABORT: 'xabort'; -XBEGIN: 'xbegin'; -XCRYPTCBC: 'xcryptcbc'; -XCRYPTCFB: 'xcryptcfb'; -XCRYPTCTR: 'xcryptctr'; -XCRYPTECB: 'xcryptecb'; -XCRYPTOFB: 'xcryptofb'; -XEND: 'xend'; -XGETBV: 'xgetbv'; -XORPD: 'xorpd'; -XORPS: 'xorps'; -XRESLDTRK: 'xresldtrk'; -XRSTOR: 'xrstor'; -XRSTOR64: 'xrstor64'; -XRSTORS: 'xrstors'; -XRSTORS64: 'xrstors64'; -XSAVE: 'xsave'; -XSAVE64: 'xsave64'; -XSAVEC: 'xsavec'; -XSAVEC64: 'xsavec64'; -XSAVEOPT: 'xsaveopt'; -XSAVEOPT64: 'xsaveopt64'; -XSAVES: 'xsaves'; -XSAVES64: 'xsaves64'; -XSETBV: 'xsetbv'; -XSHA1: 'xsha1'; -XSHA256: 'xsha256'; -XSTORE: 'xstore'; -XSUSLDTRK: 'xsusldtrk'; -XTEST: 'xtest'; +COMMA : ','; +QUESTION : '?'; +LEFT_PARENTHESIS : '('; +RIGHT_PARENTHESIS : ')'; +LEFT_BRACKET : '['; +RIGHT_BRACKET : ']'; +COLON : ':'; +BOOLEAN_OR : '||'; +BOOLEAN_XOR : '^^'; +BOOLEAN_AND : '&&'; +EQUAL_1 : '='; +EQUAL_2 : '=='; +NOT_EQUAL_1 : '!='; +NOT_EQUAL_2 : '<>'; +LESS_THAN : '<'; +LESS_THAN_EQUAL : '<='; +GREATER_THAN : '>'; +GREATER_THAN_EQUAL : '>='; +SIGNED_COMPARISON : '<=>'; +BITWISE_OR : '|'; +BITWISE_XOR : '^'; +BITWISE_AND : '&'; +LEFT_SHIFT : '<<'; +RIGHT_SHIFT : '>>'; +LEFT_SHIFT_COMPLETENESS : '<<<'; +RIGHT_SHIFT_COMPLETENESS : '>>>'; +PLUS : '+'; +MINUS : '-'; +MULTIPLICATION : '*'; +UNSIGNED_DIVISION : '/'; +SIGNED_DIVISION : '//'; +PERCENT : '%'; //Also is the signed module operator +SIGNED_MODULE : '%%'; +BITWISE_NOT : '~'; +BOOLEAN_NOT : '!'; +DOLLAR : '$'; +DOUBLE_DOLLAR : '$$'; +AAA : 'aaa'; +AAD : 'aad'; +AAM : 'aam'; +AAS : 'aas'; +ADC : 'adc'; +ADD : 'add'; +AND : 'and'; +ARPL : 'arpl'; +BB0_RESET : 'bb0_reset'; +BB1_RESET : 'bb1_reset'; +BOUND : 'bound'; +BSF : 'bsf'; +BSR : 'bsr'; +BSWAP : 'bswap'; +BT : 'bt'; +BTC : 'btc'; +BTR : 'btr'; +BTS : 'bts'; +CALL : 'call'; +CBW : 'cbw'; +CDQ : 'cdq'; +CDQE : 'cdqe'; +CLC : 'clc'; +CLD : 'cld'; +CLI : 'cli'; +CLTS : 'clts'; +CMC : 'cmc'; +CMOVA : 'cmova'; +CMOVAE : 'cmovae'; +CMOVB : 'cmovb'; +CMOVBE : 'cmovbe'; +CMOVC : 'cmovc'; +CMOVE : 'cmove'; +CMOVGE : 'cmovge'; +CMOVL : 'cmovl'; +CMOVLE : 'cmovle'; +CMOVNA : 'cmovna'; +CMOVNAE : 'cmovnae'; +CMOVNB : 'cmovnb'; +CMOVNBE : 'cmovnbe'; +CMOVNC : 'cmovnc'; +CMOVNE : 'cmovne'; +CMOVNG : 'cmovng'; +CMOVNGE : 'cmovnge'; +CMOVNL : 'cmovnl'; +CMOVNO : 'cmovno'; +CMOVNP : 'cmovnp'; +CMOVNS : 'cmovns'; +CMOVNZ : 'cmovnz'; +CMOVO : 'cmovo'; +CMOVP : 'cmovp'; +CMOVPE : 'cmovpe'; +CMOVPO : 'cmovpo'; +CMOVS : 'cmovs'; +CMOVZ : 'cmovz'; +CMP : 'cmp'; +CMPSB : 'cmpsb'; +CMPSD : 'cmpsd'; +CMPSQ : 'cmpsq'; +CMPSW : 'cmpsw'; +CMPXCHG : 'cmpxchg'; +CMPXCHG16B : 'cmpxchg16b'; +CMPXCHG486 : 'cmpxchg486'; +CMPXCHG8B : 'cmpxchg8b'; +CPU_READ : 'cpu_read'; +CPU_WRITE : 'cpu_write'; +CPUID : 'cpuid'; +CQO : 'cqo'; +CWD : 'cwd'; +CWDE : 'cwde'; +DAA : 'daa'; +DAS : 'das'; +DEC : 'dec'; +DIV : 'div'; +DMINT : 'dmint'; +EMMS : 'emms'; +ENTER : 'enter'; +EQU : 'equ'; +F2XM1 : 'f2xm1'; +FABS : 'fabs'; +FADD : 'fadd'; +FADDP : 'faddp'; +FBLD : 'fbld'; +FBSTP : 'fbstp'; +FCHS : 'fchs'; +FCLEX : 'fclex'; +FCMOVB : 'fcmovb'; +FCMOVBE : 'fcmovbe'; +FCMOVE : 'fcmove'; +FCMOVNB : 'fcmovnb'; +FCMOVNBE : 'fcmovnbe'; +FCMOVNE : 'fcmovne'; +FCMOVNU : 'fcmovnu'; +FCMOVU : 'fcmovu'; +FCOM : 'fcom'; +FCOMI : 'fcomi'; +FCOMIP : 'fcomip'; +FCOMP : 'fcomp'; +FCOMPP : 'fcompp'; +FCOS : 'fcos'; +FDECSTP : 'fdecstp'; +FDISI : 'fdisi'; +FDIV : 'fdiv'; +FDIVP : 'fdivp'; +FDIVR : 'fdivr'; +FDIVRP : 'fdivrp'; +FEMMS : 'femms'; +FENI : 'feni'; +FFREE : 'ffree'; +FFREEP : 'ffreep'; +FIADD : 'fiadd'; +FICOM : 'ficom'; +FICOMP : 'ficomp'; +FIDIV : 'fidiv'; +FIDIVR : 'fidivr'; +FILD : 'fild'; +FIMUL : 'fimul'; +FINCSTP : 'fincstp'; +FINIT : 'finit'; +FIST : 'fist'; +FISTP : 'fistp'; +FISTTP : 'fisttp'; +FISUB : 'fisub'; +FISUBR : 'fisubr'; +FLD : 'fld'; +FLD1 : 'fld1'; +FLDCW : 'fldcw'; +FLDENV : 'fldenv'; +FLDL2E : 'fldl2e'; +FLDL2T : 'fldl2t'; +FLDLG2 : 'fldlg2'; +FLDLN2 : 'fldln2'; +FLDPI : 'fldpi'; +FLDZ : 'fldz'; +FMUL : 'fmul'; +FMULP : 'fmulp'; +FNCLEX : 'fnclex'; +FNDISI : 'fndisi'; +FNENI : 'fneni'; +FNINIT : 'fninit'; +FNOP : 'fnop'; +FNSAVE : 'fnsave'; +FNSTCW : 'fnstcw'; +FNSTENV : 'fnstenv'; +FNSTSW : 'fnstsw'; +FPATAN : 'fpatan'; +FPREM : 'fprem'; +FPREM1 : 'fprem1'; +FPTAN : 'fptan'; +FRNDINT : 'frndint'; +FRSTOR : 'frstor'; +FSAVE : 'fsave'; +FSCALE : 'fscale'; +FSETPM : 'fsetpm'; +FSIN : 'fsin'; +FSINCOS : 'fsincos'; +FSQRT : 'fsqrt'; +FST : 'fst'; +FSTCW : 'fstcw'; +FSTENV : 'fstenv'; +FSTP : 'fstp'; +FSTSW : 'fstsw'; +FSUB : 'fsub'; +FSUBP : 'fsubp'; +FSUBR : 'fsubr'; +FSUBRP : 'fsubrp'; +FTST : 'ftst'; +FUCOM : 'fucom'; +FUCOMI : 'fucomi'; +FUCOMIP : 'fucomip'; +FUCOMP : 'fucomp'; +FUCOMPP : 'fucompp'; +FWAIT : 'fwait'; +FXAM : 'fxam'; +FXCH : 'fxch'; +FXTRACT : 'fxtract'; +FYL2X : 'fyl2x'; +FYL2XP1 : 'fyl2xp1'; +HLT : 'hlt'; +IBTS : 'ibts'; +ICEBP : 'icebp'; +IDIV : 'idiv'; +IMUL : 'imul'; +IN : 'in'; +INC : 'inc'; +INSB : 'insb'; +INSD : 'insd'; +INSW : 'insw'; +INT : 'int'; +INT01 : 'int01'; +INT03 : 'int03'; +INT1 : 'int1'; +INT3 : 'int3'; +INTO : 'into'; +INVD : 'invd'; +INVLPG : 'invlpg'; +INVLPGA : 'invlpga'; +INVPCID : 'invpcid'; +IRET : 'iret'; +IRETD : 'iretd'; +IRETQ : 'iretq'; +IRETW : 'iretw'; +JA : 'ja'; +JAE : 'jae'; +JB : 'jb'; +JBE : 'jbe'; +JC : 'jc'; +JCXZ : 'jcxz'; +JE : 'je'; +JECXZ : 'jecxz'; +JG : 'jg'; +JGE : 'jge'; +JL : 'jl'; +JLE : 'jle'; +JMP : 'jmp'; +JMPE : 'jmpe'; +JNA : 'jna'; +JNAE : 'jnae'; +JNB : 'jnb'; +JNBE : 'jnbe'; +JNC : 'jnc'; +JNE : 'jne'; +JNG : 'jng'; +JNGE : 'jnge'; +JNL : 'jnl'; +JNLE : 'jnle'; +JNO : 'jno'; +JNP : 'jnp'; +JNS : 'jns'; +JNZ : 'jnz'; +JO : 'jo'; +JP : 'jp'; +JPE : 'jpe'; +JPO : 'jpo'; +JRCXZ : 'jrcxz'; +JS : 'js'; +JZ : 'jz'; +LAHF : 'lahf'; +LAR : 'lar'; +LDS : 'lds'; +LEA : 'lea'; +LEAVE : 'leave'; +LES : 'les'; +LFENCE : 'lfence'; +LFS : 'lfs'; +LGDT : 'lgdt'; +LGS : 'lgs'; +LIDT : 'lidt'; +LLDT : 'lldt'; +LMSW : 'lmsw'; +LOADALL : 'loadall'; +LOADALL286 : 'loadall286'; +LODSB : 'lodsb'; +LODSD : 'lodsd'; +LODSQ : 'lodsq'; +LODSW : 'lodsw'; +LOOP : 'loop'; +LOOPE : 'loope'; +LOOPNE : 'loopne'; +LOOPNZ : 'loopnz'; +LOOPZ : 'loopz'; +LSL : 'lsl'; +LSS : 'lss'; +LTR : 'ltr'; +MFENCE : 'mfence'; +MONITOR : 'monitor'; +MONITORX : 'monitorx'; +MOV : 'mov'; +MOVD : 'movd'; +MOVQ : 'movq'; +MOVSB : 'movsb'; +MOVSD : 'movsd'; +MOVSQ : 'movsq'; +MOVSW : 'movsw'; +MOVSX : 'movsx'; +MOVSXD : 'movsxd'; +MOVZX : 'movzx'; +MUL : 'mul'; +MWAIT : 'mwait'; +MWAITX : 'mwaitx'; +NEG : 'neg'; +NOP : 'nop'; +NOT : 'not'; +OR : 'or'; +OUT : 'out'; +OUTSB : 'outsb'; +OUTSD : 'outsd'; +OUTSW : 'outsw'; +PACKSSDW : 'packssdw'; +PACKSSWB : 'packsswb'; +PACKUSWB : 'packuswb'; +PADDB : 'paddb'; +PADDD : 'paddd'; +PADDSB : 'paddsb'; +PADDSIW : 'paddsiw'; +PADDSW : 'paddsw'; +PADDUSB : 'paddusb'; +PADDUSW : 'paddusw'; +PADDW : 'paddw'; +PAND : 'pand'; +PANDN : 'pandn'; +PAUSE : 'pause'; +PAVEB : 'paveb'; +PAVGUSB : 'pavgusb'; +PCMPEQB : 'pcmpeqb'; +PCMPEQD : 'pcmpeqd'; +PCMPEQW : 'pcmpeqw'; +PCMPGTB : 'pcmpgtb'; +PCMPGTD : 'pcmpgtd'; +PCMPGTW : 'pcmpgtw'; +PDISTIB : 'pdistib'; +PF2ID : 'pf2id'; +PFACC : 'pfacc'; +PFADD : 'pfadd'; +PFCMPEQ : 'pfcmpeq'; +PFCMPGE : 'pfcmpge'; +PFCMPGT : 'pfcmpgt'; +PFMAX : 'pfmax'; +PFMIN : 'pfmin'; +PFMUL : 'pfmul'; +PFRCP : 'pfrcp'; +PFRCPIT1 : 'pfrcpit1'; +PFRCPIT2 : 'pfrcpit2'; +PFRSQIT1 : 'pfrsqit1'; +PFRSQRT : 'pfrsqrt'; +PFSUB : 'pfsub'; +PFSUBR : 'pfsubr'; +PI2FD : 'pi2fd'; +PMACHRIW : 'pmachriw'; +PMADDWD : 'pmaddwd'; +PMAGW : 'pmagw'; +PMULHRIW : 'pmulhriw'; +PMULHRWA : 'pmulhrwa'; +PMULHRWC : 'pmulhrwc'; +PMULHW : 'pmulhw'; +PMULLW : 'pmullw'; +PMVGEZB : 'pmvgezb'; +PMVLZB : 'pmvlzb'; +PMVNZB : 'pmvnzb'; +PMVZB : 'pmvzb'; +POP : 'pop'; +POPA : 'popa'; +POPAD : 'popad'; +POPAW : 'popaw'; +POPF : 'popf'; +POPFD : 'popfd'; +POPFQ : 'popfq'; +POPFW : 'popfw'; +POR : 'por'; +PREFETCH : 'prefetch'; +PREFETCHW : 'prefetchw'; +PSLLD : 'pslld'; +PSLLQ : 'psllq'; +PSLLW : 'psllw'; +PSRAD : 'psrad'; +PSRAW : 'psraw'; +PSRLD : 'psrld'; +PSRLQ : 'psrlq'; +PSRLW : 'psrlw'; +PSUBB : 'psubb'; +PSUBD : 'psubd'; +PSUBSB : 'psubsb'; +PSUBSIW : 'psubsiw'; +PSUBSW : 'psubsw'; +PSUBUSB : 'psubusb'; +PSUBUSW : 'psubusw'; +PSUBW : 'psubw'; +PUNPCKHBW : 'punpckhbw'; +PUNPCKHDQ : 'punpckhdq'; +PUNPCKHWD : 'punpckhwd'; +PUNPCKLBW : 'punpcklbw'; +PUNPCKLDQ : 'punpckldq'; +PUNPCKLWD : 'punpcklwd'; +PUSH : 'push'; +PUSHA : 'pusha'; +PUSHAD : 'pushad'; +PUSHAW : 'pushaw'; +PUSHF : 'pushf'; +PUSHFD : 'pushfd'; +PUSHFQ : 'pushfq'; +PUSHFW : 'pushfw'; +PXOR : 'pxor'; +RCL : 'rcl'; +RCR : 'rcr'; +RDM : 'rdm'; +RDMSR : 'rdmsr'; +RDPMC : 'rdpmc'; +RDSHR : 'rdshr'; +RDTSC : 'rdtsc'; +RDTSCP : 'rdtscp'; +RET : 'ret'; +RETD : 'retd'; +RETF : 'retf'; +RETFD : 'retfd'; +RETFQ : 'retfq'; +RETFW : 'retfw'; +RETN : 'retn'; +RETND : 'retnd'; +RETNQ : 'retnq'; +RETNW : 'retnw'; +RETQ : 'retq'; +RETW : 'retw'; +ROL : 'rol'; +ROR : 'ror'; +RSDC : 'rsdc'; +RSLDT : 'rsldt'; +RSM : 'rsm'; +RSTS : 'rsts'; +SAHF : 'sahf'; +SAL : 'sal'; +SALC : 'salc'; +SAR : 'sar'; +SBB : 'sbb'; +SCASB : 'scasb'; +SCASD : 'scasd'; +SCASQ : 'scasq'; +SCASW : 'scasw'; +SETA : 'seta'; +SETAE : 'setae'; +SETB : 'setb'; +SETBE : 'setbe'; +SETC : 'setc'; +SETE : 'sete'; +SETG : 'setg'; +SETGE : 'setge'; +SETL : 'setl'; +SETLE : 'setle'; +SETNA : 'setna'; +SETNAE : 'setnae'; +SETNB : 'setnb'; +SETNBE : 'setnbe'; +SETNC : 'setnc'; +SETNE : 'setne'; +SETNG : 'setng'; +SETNGE : 'setnge'; +SETNL : 'setnl'; +SETNLE : 'setnle'; +SETNO : 'setno'; +SETNP : 'setnp'; +SETNS : 'setns'; +SETNZ : 'setnz'; +SETO : 'seto'; +SETP : 'setp'; +SETPE : 'setpe'; +SETPO : 'setpo'; +SETS : 'sets'; +SETZ : 'setz'; +SFENCE : 'sfence'; +SGDT : 'sgdt'; +SHL : 'shl'; +SHLD : 'shld'; +SHR : 'shr'; +SHRD : 'shrd'; +SIDT : 'sidt'; +SKINIT : 'skinit'; +SLDT : 'sldt'; +SMI : 'smi'; +SMINT : 'smint'; +SMINTOLD : 'smintold'; +SMSW : 'smsw'; +STC : 'stc'; +STD : 'std'; +STI : 'sti'; +STOSB : 'stosb'; +STOSD : 'stosd'; +STOSQ : 'stosq'; +STOSW : 'stosw'; +STR : 'str'; +SUB : 'sub'; +SVDC : 'svdc'; +SVLDT : 'svldt'; +SVTS : 'svts'; +SWAPGS : 'swapgs'; +SYSCALL : 'syscall'; +SYSENTER : 'sysenter'; +SYSEXIT : 'sysexit'; +SYSRET : 'sysret'; +TEST : 'test'; +UD0 : 'ud0'; +UD1 : 'ud1'; +UD2 : 'ud2'; +UD2A : 'ud2a'; +UD2B : 'ud2b'; +UMOV : 'umov'; +VERR : 'verr'; +VERW : 'verw'; +WBINVD : 'wbinvd'; +WRMSR : 'wrmsr'; +WRSHR : 'wrshr'; +XADD : 'xadd'; +XBTS : 'xbts'; +XCHG : 'xchg'; +XLAT : 'xlat'; +XLATB : 'xlatb'; +XOR : 'xor'; -BITS: 'bits'; -USE16: 'use16'; -USE32: 'use32'; -DEFAULT: 'default'; -REL: 'rel'; -ABS: 'abs'; -BND: 'bnd'; -NOBND: 'nobnd'; -SECTIONS: 'sections'; -SECTION: 'section'; -SEGMENTS: 'segments'; -SEGMENT: 'segment'; -ABSOLUTE: 'absolute'; -EXTERN: 'extern'; -REQUIRED: 'required'; -GLOBAL: 'global'; -COMMON: 'common'; -NEAR: 'near'; -FAR: 'far'; -STATIC: 'static'; -CPU: 'cpu'; -FLOAT_NAME: 'float'; -DAZ: 'daz'; -NODAZ: 'nodaz'; -UP: 'up'; -DOWN: 'down'; -ZERO: 'zero'; -WARNING: 'warning'; -ORG: 'org'; -ALIGN: 'align'; -VSTART: 'vstart'; -START: 'start'; -PROGBITS: 'progbits'; -NOBITS: 'nobits'; -VFOLLOWS: 'vfollows'; -FOLLOWS: 'follows'; -MAP: 'map'; -ALL: 'all'; -BRIEF: 'brief'; -SYMBOLS: 'symbols'; -PRIVATE: 'private'; -PUBLIC: 'public'; -STACK: 'stack'; -CLASS_: 'class'; -OVERLAY: 'overlay'; -FLAT: 'flat'; -GROUP: 'group'; -UPPERCASE: 'uppercase'; -IMPORT: 'import'; -EXPORT: 'export'; -RESIDENT: 'resident'; -NODATA: 'nodata'; -PARM: 'parm'; -CODE: 'code'; -TEXT: 'text'; -RDATA: 'rdata'; -DATA: 'data'; -BSS: 'bss'; -INFO: 'info'; -COMDAT: 'comdat'; -SAFESEH: 'safeseh'; -MIXED: 'mixed'; -ZEROFILL: 'zerofill'; -NO_DEAD_STRIP: 'no_dead_strip'; -LIVE_SUPPORT: 'live_support'; -STRIP_STATIC_SYMS: 'strip_static_syms'; -DEBUG: 'debug'; -OSABI: 'osabi'; -NOTE: 'note'; -PREINIT_ARRAY: 'preinit_array'; -INIT_ARRAY: 'init_array'; -FINI_ARRAY: 'fini_array'; -TLS: 'tls'; -POINTER: 'pointer'; -NOALLOC: 'noalloc'; -ALLOC: 'alloc'; -NOEXEC: 'noexec'; -EXEC: 'exec'; -NOWRITE: 'nowrite'; -WRITE: 'write'; -WRT: 'wrt'; -FUNCTION: 'function'; -OBJECT: 'object'; -WEAK: 'weak'; -STRONG: 'strong'; -INTERNAL: 'internal'; -HIDDEN_: 'hidden'; -PROTECTED: 'protected'; -STRICT: 'strict'; -TIMES: 'times'; +AL : 'al'; +AH : 'ah'; +AX : 'ax'; +EAX : 'eax'; +RAX : 'rax'; +BL : 'bl'; +BH : 'bh'; +BX : 'bx'; +EBX : 'ebx'; +RBX : 'rbx'; +CL : 'cl'; +CH : 'ch'; +CX : 'cx'; +ECX : 'ecx'; +RCX : 'rcx'; +DL : 'dl'; +DH : 'dh'; +DX : 'dx'; +EDX : 'edx'; +RDX : 'rdx'; +SPL : 'spl'; +SP : 'sp'; +ESP : 'esp'; +RSP : 'rsp'; +BPL : 'bpl'; +BP : 'bp'; +EBP : 'ebp'; +RBP : 'rbp'; +SIL : 'sil'; +SI : 'si'; +ESI : 'esi'; +RSI : 'rsi'; +DIL : 'dil'; +DI : 'di'; +EDI : 'edi'; +RDI : 'rdi'; +R8B : 'r8b'; +R9B : 'r9b'; +R10B : 'r10b'; +R11B : 'r11b'; +R12B : 'r12b'; +R13B : 'r13b'; +R14B : 'r14b'; +R15B : 'r15b'; +R8W : 'r8w'; +R9W : 'r9w'; +R10W : 'r10w'; +R11W : 'r11w'; +R12W : 'r12w'; +R13W : 'r13w'; +R14W : 'r14w'; +R15W : 'r15w'; +R8D : 'r8d'; +R9D : 'r9d'; +R10D : 'r10d'; +R11D : 'r11d'; +R12D : 'r12d'; +R13D : 'r13d'; +R14D : 'r14d'; +R15D : 'r15d'; +R8 : 'r8'; +R9 : 'r9'; +R10 : 'r10'; +R11 : 'r11'; +R12 : 'r12'; +R13 : 'r13'; +R14 : 'r14'; +R15 : 'r15'; +IP : 'ip'; +EIP : 'eip'; +RIP : 'rip'; +ES : 'es'; +CS : 'cs'; +SS : 'ss'; +DS : 'ds'; +FS : 'fs'; +GS : 'gs'; +SEGR6 : 'segr6'; +SEGR7 : 'segr7'; +CR0 : 'cr0'; +CR1 : 'cr1'; +CR2 : 'cr2'; +CR3 : 'cr3'; +CR4 : 'cr4'; +CR5 : 'cr5'; +CR6 : 'cr6'; +CR7 : 'cr7'; +CR8 : 'cr8'; +CR9 : 'cr9'; +CR10 : 'cr10'; +CR11 : 'cr11'; +CR12 : 'cr12'; +CR13 : 'cr13'; +CR14 : 'cr14'; +CR15 : 'cr15'; +DR0 : 'dr0'; +DR1 : 'dr1'; +DR2 : 'dr2'; +DR3 : 'dr3'; +DR4 : 'dr4'; +DR5 : 'dr5'; +DR6 : 'dr6'; +DR7 : 'dr7'; +DR8 : 'dr8'; +DR9 : 'dr9'; +DR10 : 'dr10'; +DR11 : 'dr11'; +DR12 : 'dr12'; +DR13 : 'dr13'; +DR14 : 'dr14'; +DR15 : 'dr15'; +TR0 : 'tr0'; +TR1 : 'tr1'; +TR2 : 'tr2'; +TR3 : 'tr3'; +TR4 : 'tr4'; +TR5 : 'tr5'; +TR6 : 'tr6'; +TR7 : 'tr7'; +ST0 : 'st0'; +ST1 : 'st1'; +ST2 : 'st2'; +ST3 : 'st3'; +ST4 : 'st4'; +ST5 : 'st5'; +ST6 : 'st6'; +ST7 : 'st7'; +MM0 : 'mm0'; +MM1 : 'mm1'; +MM2 : 'mm2'; +MM3 : 'mm3'; +MM4 : 'mm4'; +MM5 : 'mm5'; +MM6 : 'mm6'; +MM7 : 'mm7'; +XMM0 : 'xmm0'; +XMM1 : 'xmm1'; +XMM2 : 'xmm2'; +XMM3 : 'xmm3'; +XMM4 : 'xmm4'; +XMM5 : 'xmm5'; +XMM6 : 'xmm6'; +XMM7 : 'xmm7'; +XMM8 : 'xmm8'; +XMM9 : 'xmm9'; +XMM10 : 'xmm10'; +XMM11 : 'xmm11'; +XMM12 : 'xmm12'; +XMM13 : 'xmm13'; +XMM14 : 'xmm14'; +XMM15 : 'xmm15'; +XMM16 : 'xmm16'; +XMM17 : 'xmm17'; +XMM18 : 'xmm18'; +XMM19 : 'xmm19'; +XMM20 : 'xmm20'; +XMM21 : 'xmm21'; +XMM22 : 'xmm22'; +XMM23 : 'xmm23'; +XMM24 : 'xmm24'; +XMM25 : 'xmm25'; +XMM26 : 'xmm26'; +XMM27 : 'xmm27'; +XMM28 : 'xmm28'; +XMM29 : 'xmm29'; +XMM30 : 'xmm30'; +XMM31 : 'xmm31'; +YMM0 : 'ymm0'; +YMM1 : 'ymm1'; +YMM2 : 'ymm2'; +YMM3 : 'ymm3'; +YMM4 : 'ymm4'; +YMM5 : 'ymm5'; +YMM6 : 'ymm6'; +YMM7 : 'ymm7'; +YMM8 : 'ymm8'; +YMM9 : 'ymm9'; +YMM10 : 'ymm10'; +YMM11 : 'ymm11'; +YMM12 : 'ymm12'; +YMM13 : 'ymm13'; +YMM14 : 'ymm14'; +YMM15 : 'ymm15'; +YMM16 : 'ymm16'; +YMM17 : 'ymm17'; +YMM18 : 'ymm18'; +YMM19 : 'ymm19'; +YMM20 : 'ymm20'; +YMM21 : 'ymm21'; +YMM22 : 'ymm22'; +YMM23 : 'ymm23'; +YMM24 : 'ymm24'; +YMM25 : 'ymm25'; +YMM26 : 'ymm26'; +YMM27 : 'ymm27'; +YMM28 : 'ymm28'; +YMM29 : 'ymm29'; +YMM30 : 'ymm30'; +YMM31 : 'ymm31'; +ZMM0 : 'zmm0'; +ZMM1 : 'zmm1'; +ZMM2 : 'zmm2'; +ZMM3 : 'zmm3'; +ZMM4 : 'zmm4'; +ZMM5 : 'zmm5'; +ZMM6 : 'zmm6'; +ZMM7 : 'zmm7'; +ZMM8 : 'zmm8'; +ZMM9 : 'zmm9'; +ZMM10 : 'zmm10'; +ZMM11 : 'zmm11'; +ZMM12 : 'zmm12'; +ZMM13 : 'zmm13'; +ZMM14 : 'zmm14'; +ZMM15 : 'zmm15'; +ZMM16 : 'zmm16'; +ZMM17 : 'zmm17'; +ZMM18 : 'zmm18'; +ZMM19 : 'zmm19'; +ZMM20 : 'zmm20'; +ZMM21 : 'zmm21'; +ZMM22 : 'zmm22'; +ZMM23 : 'zmm23'; +ZMM24 : 'zmm24'; +ZMM25 : 'zmm25'; +ZMM26 : 'zmm26'; +ZMM27 : 'zmm27'; +ZMM28 : 'zmm28'; +ZMM29 : 'zmm29'; +ZMM30 : 'zmm30'; +ZMM31 : 'zmm31'; +TMM0 : 'tmm0'; +TMM1 : 'tmm1'; +TMM2 : 'tmm2'; +TMM3 : 'tmm3'; +TMM4 : 'tmm4'; +TMM5 : 'tmm5'; +TMM6 : 'tmm6'; +TMM7 : 'tmm7'; +K0 : 'k0'; +K1 : 'k1'; +K2 : 'k2'; +K3 : 'k3'; +K4 : 'k4'; +K5 : 'k5'; +K6 : 'k6'; +K7 : 'k7'; +BND0 : 'bnd0'; +BND1 : 'bnd1'; +BND2 : 'bnd2'; +BND3 : 'bnd3'; +AADD : 'aadd'; +AAND : 'aand'; +ADCX : 'adcx'; +ADDPD : 'addpd'; +ADDPS : 'addps'; +ADDSD : 'addsd'; +ADDSS : 'addss'; +ADDSUBPD : 'addsubpd'; +ADDSUBPS : 'addsubps'; +ADOX : 'adox'; +AESDEC : 'aesdec'; +AESDECLAST : 'aesdeclast'; +AESENC : 'aesenc'; +AESENCLAST : 'aesenclast'; +AESIMC : 'aesimc'; +AESKEYGENASSIST : 'aeskeygenassist'; +ANDN : 'andn'; +ANDNPD : 'andnpd'; +ANDNPS : 'andnps'; +ANDPD : 'andpd'; +ANDPS : 'andps'; +AXOR : 'axor'; +BEXTR : 'bextr'; +BLCFILL : 'blcfill'; +BLCI : 'blci'; +BLCIC : 'blcic'; +BLCMSK : 'blcmsk'; +BLCS : 'blcs'; +BLENDPD : 'blendpd'; +BLENDPS : 'blendps'; +BLENDVPD : 'blendvpd'; +BLENDVPS : 'blendvps'; +BLSFILL : 'blsfill'; +BLSI : 'blsi'; +BLSIC : 'blsic'; +BLSMSK : 'blsmsk'; +BLSR : 'blsr'; +BNDCL : 'bndcl'; +BNDCN : 'bndcn'; +BNDCU : 'bndcu'; +BNDLDX : 'bndldx'; +BNDMK : 'bndmk'; +BNDMOV : 'bndmov'; +BNDSTX : 'bndstx'; +BZHI : 'bzhi'; +CLAC : 'clac'; +CLDEMOTE : 'cldemote'; +CLFLUSH : 'clflush'; +CLFLUSHOPT : 'clflushopt'; +CLGI : 'clgi'; +CLRSSBSY : 'clrssbsy'; +CLUI : 'clui'; +CLWB : 'clwb'; +CLZERO : 'clzero'; +CMPEQPD : 'cmpeqpd'; +CMPEQPS : 'cmpeqps'; +CMPEQSD : 'cmpeqsd'; +CMPEQSS : 'cmpeqss'; +CMPLEPD : 'cmplepd'; +CMPLEPS : 'cmpleps'; +CMPLESD : 'cmplesd'; +CMPLESS : 'cmpless'; +CMPLTPD : 'cmpltpd'; +CMPLTPS : 'cmpltps'; +CMPLTSD : 'cmpltsd'; +CMPLTSS : 'cmpltss'; +CMPNEQPD : 'cmpneqpd'; +CMPNEQPS : 'cmpneqps'; +CMPNEQSD : 'cmpneqsd'; +CMPNEQSS : 'cmpneqss'; +CMPNLEPD : 'cmpnlepd'; +CMPNLEPS : 'cmpnleps'; +CMPNLESD : 'cmpnlesd'; +CMPNLESS : 'cmpnless'; +CMPNLTPD : 'cmpnltpd'; +CMPNLTPS : 'cmpnltps'; +CMPNLTSD : 'cmpnltsd'; +CMPNLTSS : 'cmpnltss'; +CMPNPXADD : 'cmpnpxadd'; +CMPNSXADD : 'cmpnsxadd'; +CMPNZXADD : 'cmpnzxadd'; +CMPORDPD : 'cmpordpd'; +CMPORDPS : 'cmpordps'; +CMPORDSD : 'cmpordsd'; +CMPORDSS : 'cmpordss'; +CMPOXADD : 'cmpoxadd'; +CMPPD : 'cmppd'; +CMPPS : 'cmpps'; +CMPPXADD : 'cmppxadd'; +CMPSS : 'cmpss'; +CMPSXADD : 'cmpsxadd'; +CMPUNORDPD : 'cmpunordpd'; +CMPUNORDPS : 'cmpunordps'; +CMPUNORDSD : 'cmpunordsd'; +CMPUNORDSS : 'cmpunordss'; +CMPZXADD : 'cmpzxadd'; +COMISD : 'comisd'; +COMISS : 'comiss'; +CRC32 : 'crc32'; +CVTDQ2PD : 'cvtdq2pd'; +CVTDQ2PS : 'cvtdq2ps'; +CVTPD2DQ : 'cvtpd2dq'; +CVTPD2PI : 'cvtpd2pi'; +CVTPD2PS : 'cvtpd2ps'; +CVTPI2PD : 'cvtpi2pd'; +CVTPI2PS : 'cvtpi2ps'; +CVTPS2DQ : 'cvtps2dq'; +CVTPS2PD : 'cvtps2pd'; +CVTPS2PI : 'cvtps2pi'; +CVTSD2SI : 'cvtsd2si'; +CVTSD2SS : 'cvtsd2ss'; +CVTSI2SD : 'cvtsi2sd'; +CVTSI2SS : 'cvtsi2ss'; +CVTSS2SD : 'cvtss2sd'; +CVTSS2SI : 'cvtss2si'; +CVTTPD2DQ : 'cvttpd2dq'; +CVTTPD2PI : 'cvttpd2pi'; +CVTTPS2DQ : 'cvttps2dq'; +CVTTPS2PI : 'cvttps2pi'; +CVTTSD2SI : 'cvttsd2si'; +CVTTSS2SI : 'cvttss2si'; +DIVPD : 'divpd'; +DIVPS : 'divps'; +DIVSD : 'divsd'; +DIVSS : 'divss'; +DPPD : 'dppd'; +DPPS : 'dpps'; +ENCLS : 'encls'; +ENCLU : 'enclu'; +ENCLV : 'enclv'; +ENDBR32 : 'endbr32'; +ENDBR64 : 'endbr64'; +ENQCMD : 'enqcmd'; +ENQCMDS : 'enqcmds'; +EXTRACTPS : 'extractps'; +EXTRQ : 'extrq'; +FXRSTOR : 'fxrstor'; +FXRSTOR64 : 'fxrstor64'; +FXSAVE : 'fxsave'; +FXSAVE64 : 'fxsave64'; +GETSEC : 'getsec'; +GF2P8AFFINEINVQB : 'gf2p8affineinvqb'; +GF2P8AFFINEQB : 'gf2p8affineqb'; +GF2P8MULB : 'gf2p8mulb'; +HADDPD : 'haddpd'; +HADDPS : 'haddps'; +HINT_NOP0 : 'hint_nop0'; +HINT_NOP1 : 'hint_nop1'; +HINT_NOP10 : 'hint_nop10'; +HINT_NOP11 : 'hint_nop11'; +HINT_NOP12 : 'hint_nop12'; +HINT_NOP13 : 'hint_nop13'; +HINT_NOP14 : 'hint_nop14'; +HINT_NOP15 : 'hint_nop15'; +HINT_NOP16 : 'hint_nop16'; +HINT_NOP17 : 'hint_nop17'; +HINT_NOP18 : 'hint_nop18'; +HINT_NOP19 : 'hint_nop19'; +HINT_NOP2 : 'hint_nop2'; +HINT_NOP20 : 'hint_nop20'; +HINT_NOP21 : 'hint_nop21'; +HINT_NOP22 : 'hint_nop22'; +HINT_NOP23 : 'hint_nop23'; +HINT_NOP24 : 'hint_nop24'; +HINT_NOP25 : 'hint_nop25'; +HINT_NOP26 : 'hint_nop26'; +HINT_NOP27 : 'hint_nop27'; +HINT_NOP28 : 'hint_nop28'; +HINT_NOP29 : 'hint_nop29'; +HINT_NOP3 : 'hint_nop3'; +HINT_NOP30 : 'hint_nop30'; +HINT_NOP31 : 'hint_nop31'; +HINT_NOP32 : 'hint_nop32'; +HINT_NOP33 : 'hint_nop33'; +HINT_NOP34 : 'hint_nop34'; +HINT_NOP35 : 'hint_nop35'; +HINT_NOP36 : 'hint_nop36'; +HINT_NOP37 : 'hint_nop37'; +HINT_NOP38 : 'hint_nop38'; +HINT_NOP39 : 'hint_nop39'; +HINT_NOP4 : 'hint_nop4'; +HINT_NOP40 : 'hint_nop40'; +HINT_NOP41 : 'hint_nop41'; +HINT_NOP42 : 'hint_nop42'; +HINT_NOP43 : 'hint_nop43'; +HINT_NOP44 : 'hint_nop44'; +HINT_NOP45 : 'hint_nop45'; +HINT_NOP46 : 'hint_nop46'; +HINT_NOP47 : 'hint_nop47'; +HINT_NOP48 : 'hint_nop48'; +HINT_NOP49 : 'hint_nop49'; +HINT_NOP5 : 'hint_nop5'; +HINT_NOP50 : 'hint_nop50'; +HINT_NOP51 : 'hint_nop51'; +HINT_NOP52 : 'hint_nop52'; +HINT_NOP53 : 'hint_nop53'; +HINT_NOP54 : 'hint_nop54'; +HINT_NOP55 : 'hint_nop55'; +HINT_NOP56 : 'hint_nop56'; +HINT_NOP57 : 'hint_nop57'; +HINT_NOP58 : 'hint_nop58'; +HINT_NOP59 : 'hint_nop59'; +HINT_NOP6 : 'hint_nop6'; +HINT_NOP60 : 'hint_nop60'; +HINT_NOP61 : 'hint_nop61'; +HINT_NOP62 : 'hint_nop62'; +HINT_NOP63 : 'hint_nop63'; +HINT_NOP7 : 'hint_nop7'; +HINT_NOP8 : 'hint_nop8'; +HINT_NOP9 : 'hint_nop9'; +HRESET : 'hreset'; +HSUBPD : 'hsubpd'; +HSUBPS : 'hsubps'; +INCSSPD : 'incsspd'; +INCSSPQ : 'incsspq'; +INSERTPS : 'insertps'; +INSERTQ : 'insertq'; +INVEPT : 'invept'; +INVVPID : 'invvpid'; +KADD : 'kadd'; +KADDB : 'kaddb'; +KADDD : 'kaddd'; +KADDQ : 'kaddq'; +KADDW : 'kaddw'; +KAND : 'kand'; +KANDB : 'kandb'; +KANDD : 'kandd'; +KANDN : 'kandn'; +KANDNB : 'kandnb'; +KANDND : 'kandnd'; +KANDNQ : 'kandnq'; +KANDNW : 'kandnw'; +KANDQ : 'kandq'; +KANDW : 'kandw'; +KMOV : 'kmov'; +KMOVB : 'kmovb'; +KMOVD : 'kmovd'; +KMOVQ : 'kmovq'; +KMOVW : 'kmovw'; +KNOT : 'knot'; +KNOTB : 'knotb'; +KNOTD : 'knotd'; +KNOTQ : 'knotq'; +KNOTW : 'knotw'; +KOR : 'kor'; +KORB : 'korb'; +KORD : 'kord'; +KORQ : 'korq'; +KORTEST : 'kortest'; +KORTESTB : 'kortestb'; +KORTESTD : 'kortestd'; +KORTESTQ : 'kortestq'; +KORTESTW : 'kortestw'; +KORW : 'korw'; +KSHIFTL : 'kshiftl'; +KSHIFTLB : 'kshiftlb'; +KSHIFTLD : 'kshiftld'; +KSHIFTLQ : 'kshiftlq'; +KSHIFTLW : 'kshiftlw'; +KSHIFTR : 'kshiftr'; +KSHIFTRB : 'kshiftrb'; +KSHIFTRD : 'kshiftrd'; +KSHIFTRQ : 'kshiftrq'; +KSHIFTRW : 'kshiftrw'; +KTEST : 'ktest'; +KTESTB : 'ktestb'; +KTESTD : 'ktestd'; +KTESTQ : 'ktestq'; +KTESTW : 'ktestw'; +KUNPCK : 'kunpck'; +KUNPCKBW : 'kunpckbw'; +KUNPCKDQ : 'kunpckdq'; +KUNPCKWD : 'kunpckwd'; +KXNOR : 'kxnor'; +KXNORB : 'kxnorb'; +KXNORD : 'kxnord'; +KXNORQ : 'kxnorq'; +KXNORW : 'kxnorw'; +KXOR : 'kxor'; +KXORB : 'kxorb'; +KXORD : 'kxord'; +KXORQ : 'kxorq'; +KXORW : 'kxorw'; +LDDQU : 'lddqu'; +LDMXCSR : 'ldmxcsr'; +LDTILECFG : 'ldtilecfg'; +LLWPCB : 'llwpcb'; +LWPINS : 'lwpins'; +LWPVAL : 'lwpval'; +LZCNT : 'lzcnt'; +MASKMOVDQU : 'maskmovdqu'; +MASKMOVQ : 'maskmovq'; +MAXPD : 'maxpd'; +MAXPS : 'maxps'; +MAXSD : 'maxsd'; +MAXSS : 'maxss'; +MINPD : 'minpd'; +MINPS : 'minps'; +MINSD : 'minsd'; +MINSS : 'minss'; +MONTMUL : 'montmul'; +MOVAPD : 'movapd'; +MOVAPS : 'movaps'; +MOVBE : 'movbe'; +MOVDDUP : 'movddup'; +MOVDIR64B : 'movdir64b'; +MOVDIRI : 'movdiri'; +MOVDQ2Q : 'movdq2q'; +MOVDQA : 'movdqa'; +MOVDQU : 'movdqu'; +MOVHLPS : 'movhlps'; +MOVHPD : 'movhpd'; +MOVHPS : 'movhps'; +MOVLHPS : 'movlhps'; +MOVLPD : 'movlpd'; +MOVLPS : 'movlps'; +MOVMSKPD : 'movmskpd'; +MOVMSKPS : 'movmskps'; +MOVNTDQ : 'movntdq'; +MOVNTDQA : 'movntdqa'; +MOVNTI : 'movnti'; +MOVNTPD : 'movntpd'; +MOVNTPS : 'movntps'; +MOVNTQ : 'movntq'; +MOVNTSD : 'movntsd'; +MOVNTSS : 'movntss'; +MOVQ2DQ : 'movq2dq'; +MOVSHDUP : 'movshdup'; +MOVSLDUP : 'movsldup'; +MOVSS : 'movss'; +MOVUPD : 'movupd'; +MOVUPS : 'movups'; +MPSADBW : 'mpsadbw'; +MULPD : 'mulpd'; +MULPS : 'mulps'; +MULSD : 'mulsd'; +MULSS : 'mulss'; +MULX : 'mulx'; +ORPD : 'orpd'; +ORPS : 'orps'; +PABSB : 'pabsb'; +PABSD : 'pabsd'; +PABSW : 'pabsw'; +PACKUSDW : 'packusdw'; +PADDQ : 'paddq'; +PALIGNR : 'palignr'; +PAVGB : 'pavgb'; +PAVGW : 'pavgw'; +PBLENDVB : 'pblendvb'; +PBLENDW : 'pblendw'; +PCLMULHQHQDQ : 'pclmulhqhqdq'; +PCLMULHQLQDQ : 'pclmulhqlqdq'; +PCLMULLQHQDQ : 'pclmullqhqdq'; +PCLMULLQLQDQ : 'pclmullqlqdq'; +PCLMULQDQ : 'pclmulqdq'; +PCMPEQQ : 'pcmpeqq'; +PCMPESTRI : 'pcmpestri'; +PCMPESTRM : 'pcmpestrm'; +PCMPGTQ : 'pcmpgtq'; +PCMPISTRI : 'pcmpistri'; +PCMPISTRM : 'pcmpistrm'; +PCOMMIT : 'pcommit'; +PCONFIG : 'pconfig'; +PDEP : 'pdep'; +PEXT : 'pext'; +PEXTRB : 'pextrb'; +PEXTRD : 'pextrd'; +PEXTRQ : 'pextrq'; +PEXTRW : 'pextrw'; +PF2IW : 'pf2iw'; +PFNACC : 'pfnacc'; +PFPNACC : 'pfpnacc'; +PFRCPV : 'pfrcpv'; +PFRSQRTV : 'pfrsqrtv'; +PHADDD : 'phaddd'; +PHADDSW : 'phaddsw'; +PHADDW : 'phaddw'; +PHMINPOSUW : 'phminposuw'; +PHSUBD : 'phsubd'; +PHSUBSW : 'phsubsw'; +PHSUBW : 'phsubw'; +PI2FW : 'pi2fw'; +PINSRB : 'pinsrb'; +PINSRD : 'pinsrd'; +PINSRQ : 'pinsrq'; +PINSRW : 'pinsrw'; +PMADDUBSW : 'pmaddubsw'; +PMAXSB : 'pmaxsb'; +PMAXSD : 'pmaxsd'; +PMAXSW : 'pmaxsw'; +PMAXUB : 'pmaxub'; +PMAXUD : 'pmaxud'; +PMAXUW : 'pmaxuw'; +PMINSB : 'pminsb'; +PMINSD : 'pminsd'; +PMINSW : 'pminsw'; +PMINUB : 'pminub'; +PMINUD : 'pminud'; +PMINUW : 'pminuw'; +PMOVMSKB : 'pmovmskb'; +PMOVSXBD : 'pmovsxbd'; +PMOVSXBQ : 'pmovsxbq'; +PMOVSXBW : 'pmovsxbw'; +PMOVSXDQ : 'pmovsxdq'; +PMOVSXWD : 'pmovsxwd'; +PMOVSXWQ : 'pmovsxwq'; +PMOVZXBD : 'pmovzxbd'; +PMOVZXBQ : 'pmovzxbq'; +PMOVZXBW : 'pmovzxbw'; +PMOVZXDQ : 'pmovzxdq'; +PMOVZXWD : 'pmovzxwd'; +PMOVZXWQ : 'pmovzxwq'; +PMULDQ : 'pmuldq'; +PMULHRSW : 'pmulhrsw'; +PMULHUW : 'pmulhuw'; +PMULLD : 'pmulld'; +PMULUDQ : 'pmuludq'; +POPCNT : 'popcnt'; +PREFETCHIT0 : 'prefetchit0'; +PREFETCHIT1 : 'prefetchit1'; +PREFETCHNTA : 'prefetchnta'; +PREFETCHT0 : 'prefetcht0'; +PREFETCHT1 : 'prefetcht1'; +PREFETCHT2 : 'prefetcht2'; +PREFETCHWT1 : 'prefetchwt1'; +PSADBW : 'psadbw'; +PSHUFB : 'pshufb'; +PSHUFD : 'pshufd'; +PSHUFHW : 'pshufhw'; +PSHUFLW : 'pshuflw'; +PSHUFW : 'pshufw'; +PSIGNB : 'psignb'; +PSIGND : 'psignd'; +PSIGNW : 'psignw'; +PSLLDQ : 'pslldq'; +PSRLDQ : 'psrldq'; +PSUBQ : 'psubq'; +PSWAPD : 'pswapd'; +PTEST : 'ptest'; +PTWRITE : 'ptwrite'; +PUNPCKHQDQ : 'punpckhqdq'; +PUNPCKLQDQ : 'punpcklqdq'; +PVALIDATE : 'pvalidate'; +RCPPS : 'rcpps'; +RCPSS : 'rcpss'; +RDFSBASE : 'rdfsbase'; +RDGSBASE : 'rdgsbase'; +RDMSRLIST : 'rdmsrlist'; +RDPID : 'rdpid'; +RDPKRU : 'rdpkru'; +RDRAND : 'rdrand'; +RDSEED : 'rdseed'; +RDSSPD : 'rdsspd'; +RDSSPQ : 'rdsspq'; +RMPADJUST : 'rmpadjust'; +RORX : 'rorx'; +ROUNDPD : 'roundpd'; +ROUNDPS : 'roundps'; +ROUNDSD : 'roundsd'; +ROUNDSS : 'roundss'; +RSQRTPS : 'rsqrtps'; +RSQRTSS : 'rsqrtss'; +RSTORSSP : 'rstorssp'; +SARX : 'sarx'; +SAVEPREVSSP : 'saveprevssp'; +SENDUIPI : 'senduipi'; +SERIALIZE : 'serialize'; +SETSSBSY : 'setssbsy'; +SHA1MSG1 : 'sha1msg1'; +SHA1MSG2 : 'sha1msg2'; +SHA1NEXTE : 'sha1nexte'; +SHA1RNDS4 : 'sha1rnds4'; +SHA256MSG1 : 'sha256msg1'; +SHA256MSG2 : 'sha256msg2'; +SHA256RNDS2 : 'sha256rnds2'; +SHLX : 'shlx'; +SHRX : 'shrx'; +SHUFPD : 'shufpd'; +SHUFPS : 'shufps'; +SLWPCB : 'slwpcb'; +SQRTPD : 'sqrtpd'; +SQRTPS : 'sqrtps'; +SQRTSD : 'sqrtsd'; +SQRTSS : 'sqrtss'; +STAC : 'stac'; +STGI : 'stgi'; +STMXCSR : 'stmxcsr'; +STTILECFG : 'sttilecfg'; +STUI : 'stui'; +SUBPD : 'subpd'; +SUBPS : 'subps'; +SUBSD : 'subsd'; +SUBSS : 'subss'; +T1MSKC : 't1mskc'; +TDPBF16PS : 'tdpbf16ps'; +TDPBSSD : 'tdpbssd'; +TDPBSUD : 'tdpbsud'; +TDPBUSD : 'tdpbusd'; +TDPBUUD : 'tdpbuud'; +TESTUI : 'testui'; +TILELOADD : 'tileloadd'; +TILELOADDT1 : 'tileloaddt1'; +TILERELEASE : 'tilerelease'; +TILESTORED : 'tilestored'; +TILEZERO : 'tilezero'; +TPAUSE : 'tpause'; +TZCNT : 'tzcnt'; +TZMSK : 'tzmsk'; +UCOMISD : 'ucomisd'; +UCOMISS : 'ucomiss'; +UIRET : 'uiret'; +UMONITOR : 'umonitor'; +UMWAIT : 'umwait'; +UNPCKHPD : 'unpckhpd'; +UNPCKHPS : 'unpckhps'; +UNPCKLPD : 'unpcklpd'; +UNPCKLPS : 'unpcklps'; +V4DPWSSD : 'v4dpwssd'; +V4DPWSSDS : 'v4dpwssds'; +V4FMADDPS : 'v4fmaddps'; +V4FMADDSS : 'v4fmaddss'; +V4FNMADDPS : 'v4fnmaddps'; +V4FNMADDSS : 'v4fnmaddss'; +VADDPD : 'vaddpd'; +VADDPH : 'vaddph'; +VADDPS : 'vaddps'; +VADDSD : 'vaddsd'; +VADDSH : 'vaddsh'; +VADDSS : 'vaddss'; +VADDSUBPD : 'vaddsubpd'; +VADDSUBPS : 'vaddsubps'; +VAESDEC : 'vaesdec'; +VAESDECLAST : 'vaesdeclast'; +VAESENC : 'vaesenc'; +VAESENCLAST : 'vaesenclast'; +VAESIMC : 'vaesimc'; +VAESKEYGENASSIST : 'vaeskeygenassist'; +VALIGND : 'valignd'; +VALIGNQ : 'valignq'; +VANDNPD : 'vandnpd'; +VANDNPS : 'vandnps'; +VANDPD : 'vandpd'; +VANDPS : 'vandps'; +VBCSTNEBF16PS : 'vbcstnebf16ps'; +VBCSTNESH2PS : 'vbcstnesh2ps'; +VBLENDMPD : 'vblendmpd'; +VBLENDMPS : 'vblendmps'; +VBLENDPD : 'vblendpd'; +VBLENDPS : 'vblendps'; +VBLENDVPD : 'vblendvpd'; +VBLENDVPS : 'vblendvps'; +VBROADCASTF128 : 'vbroadcastf128'; +VBROADCASTF32X2 : 'vbroadcastf32x2'; +VBROADCASTF32X4 : 'vbroadcastf32x4'; +VBROADCASTF32X8 : 'vbroadcastf32x8'; +VBROADCASTF64X2 : 'vbroadcastf64x2'; +VBROADCASTF64X4 : 'vbroadcastf64x4'; +VBROADCASTI128 : 'vbroadcasti128'; +VBROADCASTI32X2 : 'vbroadcasti32x2'; +VBROADCASTI32X4 : 'vbroadcasti32x4'; +VBROADCASTI32X8 : 'vbroadcasti32x8'; +VBROADCASTI64X2 : 'vbroadcasti64x2'; +VBROADCASTI64X4 : 'vbroadcasti64x4'; +VBROADCASTSD : 'vbroadcastsd'; +VBROADCASTSS : 'vbroadcastss'; +VCMPEQ_OQPD : 'vcmpeq_oqpd'; +VCMPEQ_OQPS : 'vcmpeq_oqps'; +VCMPEQ_OQSD : 'vcmpeq_oqsd'; +VCMPEQ_OQSS : 'vcmpeq_oqss'; +VCMPEQ_OSPD : 'vcmpeq_ospd'; +VCMPEQ_OSPS : 'vcmpeq_osps'; +VCMPEQ_OSSD : 'vcmpeq_ossd'; +VCMPEQ_OSSS : 'vcmpeq_osss'; +VCMPEQ_UQPD : 'vcmpeq_uqpd'; +VCMPEQ_UQPS : 'vcmpeq_uqps'; +VCMPEQ_UQSD : 'vcmpeq_uqsd'; +VCMPEQ_UQSS : 'vcmpeq_uqss'; +VCMPEQ_USPD : 'vcmpeq_uspd'; +VCMPEQ_USPS : 'vcmpeq_usps'; +VCMPEQ_USSD : 'vcmpeq_ussd'; +VCMPEQ_USSS : 'vcmpeq_usss'; +VCMPEQPD : 'vcmpeqpd'; +VCMPEQPS : 'vcmpeqps'; +VCMPEQSD : 'vcmpeqsd'; +VCMPEQSS : 'vcmpeqss'; +VCMPFALSE_OQPD : 'vcmpfalse_oqpd'; +VCMPFALSE_OQPS : 'vcmpfalse_oqps'; +VCMPFALSE_OQSD : 'vcmpfalse_oqsd'; +VCMPFALSE_OQSS : 'vcmpfalse_oqss'; +VCMPFALSE_OSPD : 'vcmpfalse_ospd'; +VCMPFALSE_OSPS : 'vcmpfalse_osps'; +VCMPFALSE_OSSD : 'vcmpfalse_ossd'; +VCMPFALSE_OSSS : 'vcmpfalse_osss'; +VCMPFALSEPD : 'vcmpfalsepd'; +VCMPFALSEPS : 'vcmpfalseps'; +VCMPFALSESD : 'vcmpfalsesd'; +VCMPFALSESS : 'vcmpfalsess'; +VCMPGE_OQPD : 'vcmpge_oqpd'; +VCMPGE_OQPS : 'vcmpge_oqps'; +VCMPGE_OQSD : 'vcmpge_oqsd'; +VCMPGE_OQSS : 'vcmpge_oqss'; +VCMPGE_OSPD : 'vcmpge_ospd'; +VCMPGE_OSPS : 'vcmpge_osps'; +VCMPGE_OSSD : 'vcmpge_ossd'; +VCMPGE_OSSS : 'vcmpge_osss'; +VCMPGEPD : 'vcmpgepd'; +VCMPGEPS : 'vcmpgeps'; +VCMPGESD : 'vcmpgesd'; +VCMPGESS : 'vcmpgess'; +VCMPGT_OQPD : 'vcmpgt_oqpd'; +VCMPGT_OQPS : 'vcmpgt_oqps'; +VCMPGT_OQSD : 'vcmpgt_oqsd'; +VCMPGT_OQSS : 'vcmpgt_oqss'; +VCMPGT_OSPD : 'vcmpgt_ospd'; +VCMPGT_OSPS : 'vcmpgt_osps'; +VCMPGT_OSSD : 'vcmpgt_ossd'; +VCMPGT_OSSS : 'vcmpgt_osss'; +VCMPGTPD : 'vcmpgtpd'; +VCMPGTPS : 'vcmpgtps'; +VCMPGTSD : 'vcmpgtsd'; +VCMPGTSS : 'vcmpgtss'; +VCMPLE_OQPD : 'vcmple_oqpd'; +VCMPLE_OQPS : 'vcmple_oqps'; +VCMPLE_OQSD : 'vcmple_oqsd'; +VCMPLE_OQSS : 'vcmple_oqss'; +VCMPLE_OSPD : 'vcmple_ospd'; +VCMPLE_OSPS : 'vcmple_osps'; +VCMPLE_OSSD : 'vcmple_ossd'; +VCMPLE_OSSS : 'vcmple_osss'; +VCMPLEPD : 'vcmplepd'; +VCMPLEPS : 'vcmpleps'; +VCMPLESD : 'vcmplesd'; +VCMPLESS : 'vcmpless'; +VCMPLT_OQPD : 'vcmplt_oqpd'; +VCMPLT_OQPS : 'vcmplt_oqps'; +VCMPLT_OQSD : 'vcmplt_oqsd'; +VCMPLT_OQSS : 'vcmplt_oqss'; +VCMPLT_OSPD : 'vcmplt_ospd'; +VCMPLT_OSPS : 'vcmplt_osps'; +VCMPLT_OSSD : 'vcmplt_ossd'; +VCMPLT_OSSS : 'vcmplt_osss'; +VCMPLTPD : 'vcmpltpd'; +VCMPLTPS : 'vcmpltps'; +VCMPLTSD : 'vcmpltsd'; +VCMPLTSS : 'vcmpltss'; +VCMPNEQ_OQPD : 'vcmpneq_oqpd'; +VCMPNEQ_OQPS : 'vcmpneq_oqps'; +VCMPNEQ_OQSD : 'vcmpneq_oqsd'; +VCMPNEQ_OQSS : 'vcmpneq_oqss'; +VCMPNEQ_OSPD : 'vcmpneq_ospd'; +VCMPNEQ_OSPS : 'vcmpneq_osps'; +VCMPNEQ_OSSD : 'vcmpneq_ossd'; +VCMPNEQ_OSSS : 'vcmpneq_osss'; +VCMPNEQ_UQPD : 'vcmpneq_uqpd'; +VCMPNEQ_UQPS : 'vcmpneq_uqps'; +VCMPNEQ_UQSD : 'vcmpneq_uqsd'; +VCMPNEQ_UQSS : 'vcmpneq_uqss'; +VCMPNEQ_USPD : 'vcmpneq_uspd'; +VCMPNEQ_USPS : 'vcmpneq_usps'; +VCMPNEQ_USSD : 'vcmpneq_ussd'; +VCMPNEQ_USSS : 'vcmpneq_usss'; +VCMPNEQPD : 'vcmpneqpd'; +VCMPNEQPS : 'vcmpneqps'; +VCMPNEQSD : 'vcmpneqsd'; +VCMPNEQSS : 'vcmpneqss'; +VCMPNGE_UQPD : 'vcmpnge_uqpd'; +VCMPNGE_UQPS : 'vcmpnge_uqps'; +VCMPNGE_UQSD : 'vcmpnge_uqsd'; +VCMPNGE_UQSS : 'vcmpnge_uqss'; +VCMPNGE_USPD : 'vcmpnge_uspd'; +VCMPNGE_USPS : 'vcmpnge_usps'; +VCMPNGE_USSD : 'vcmpnge_ussd'; +VCMPNGE_USSS : 'vcmpnge_usss'; +VCMPNGEPD : 'vcmpngepd'; +VCMPNGEPS : 'vcmpngeps'; +VCMPNGESD : 'vcmpngesd'; +VCMPNGESS : 'vcmpngess'; +VCMPNGT_UQPD : 'vcmpngt_uqpd'; +VCMPNGT_UQPS : 'vcmpngt_uqps'; +VCMPNGT_UQSD : 'vcmpngt_uqsd'; +VCMPNGT_UQSS : 'vcmpngt_uqss'; +VCMPNGT_USPD : 'vcmpngt_uspd'; +VCMPNGT_USPS : 'vcmpngt_usps'; +VCMPNGT_USSD : 'vcmpngt_ussd'; +VCMPNGT_USSS : 'vcmpngt_usss'; +VCMPNGTPD : 'vcmpngtpd'; +VCMPNGTPS : 'vcmpngtps'; +VCMPNGTSD : 'vcmpngtsd'; +VCMPNGTSS : 'vcmpngtss'; +VCMPNLE_UQPD : 'vcmpnle_uqpd'; +VCMPNLE_UQPS : 'vcmpnle_uqps'; +VCMPNLE_UQSD : 'vcmpnle_uqsd'; +VCMPNLE_UQSS : 'vcmpnle_uqss'; +VCMPNLE_USPD : 'vcmpnle_uspd'; +VCMPNLE_USPS : 'vcmpnle_usps'; +VCMPNLE_USSD : 'vcmpnle_ussd'; +VCMPNLE_USSS : 'vcmpnle_usss'; +VCMPNLEPD : 'vcmpnlepd'; +VCMPNLEPS : 'vcmpnleps'; +VCMPNLESD : 'vcmpnlesd'; +VCMPNLESS : 'vcmpnless'; +VCMPNLT_UQPD : 'vcmpnlt_uqpd'; +VCMPNLT_UQPS : 'vcmpnlt_uqps'; +VCMPNLT_UQSD : 'vcmpnlt_uqsd'; +VCMPNLT_UQSS : 'vcmpnlt_uqss'; +VCMPNLT_USPD : 'vcmpnlt_uspd'; +VCMPNLT_USPS : 'vcmpnlt_usps'; +VCMPNLT_USSD : 'vcmpnlt_ussd'; +VCMPNLT_USSS : 'vcmpnlt_usss'; +VCMPNLTPD : 'vcmpnltpd'; +VCMPNLTPS : 'vcmpnltps'; +VCMPNLTSD : 'vcmpnltsd'; +VCMPNLTSS : 'vcmpnltss'; +VCMPORD_QPD : 'vcmpord_qpd'; +VCMPORD_QPS : 'vcmpord_qps'; +VCMPORD_QSD : 'vcmpord_qsd'; +VCMPORD_QSS : 'vcmpord_qss'; +VCMPORD_SPD : 'vcmpord_spd'; +VCMPORD_SPS : 'vcmpord_sps'; +VCMPORD_SSD : 'vcmpord_ssd'; +VCMPORD_SSS : 'vcmpord_sss'; +VCMPORDPD : 'vcmpordpd'; +VCMPORDPS : 'vcmpordps'; +VCMPORDSD : 'vcmpordsd'; +VCMPORDSS : 'vcmpordss'; +VCMPPD : 'vcmppd'; +VCMPPH : 'vcmpph'; +VCMPPS : 'vcmpps'; +VCMPSD : 'vcmpsd'; +VCMPSH : 'vcmpsh'; +VCMPSS : 'vcmpss'; +VCMPTRUE_UQPD : 'vcmptrue_uqpd'; +VCMPTRUE_UQPS : 'vcmptrue_uqps'; +VCMPTRUE_UQSD : 'vcmptrue_uqsd'; +VCMPTRUE_UQSS : 'vcmptrue_uqss'; +VCMPTRUE_USPD : 'vcmptrue_uspd'; +VCMPTRUE_USPS : 'vcmptrue_usps'; +VCMPTRUE_USSD : 'vcmptrue_ussd'; +VCMPTRUE_USSS : 'vcmptrue_usss'; +VCMPTRUEPD : 'vcmptruepd'; +VCMPTRUEPS : 'vcmptrueps'; +VCMPTRUESD : 'vcmptruesd'; +VCMPTRUESS : 'vcmptruess'; +VCMPUNORD_QPD : 'vcmpunord_qpd'; +VCMPUNORD_QPS : 'vcmpunord_qps'; +VCMPUNORD_QSD : 'vcmpunord_qsd'; +VCMPUNORD_QSS : 'vcmpunord_qss'; +VCMPUNORD_SPD : 'vcmpunord_spd'; +VCMPUNORD_SPS : 'vcmpunord_sps'; +VCMPUNORD_SSD : 'vcmpunord_ssd'; +VCMPUNORD_SSS : 'vcmpunord_sss'; +VCMPUNORDPD : 'vcmpunordpd'; +VCMPUNORDPS : 'vcmpunordps'; +VCMPUNORDSD : 'vcmpunordsd'; +VCMPUNORDSS : 'vcmpunordss'; +VCOMISD : 'vcomisd'; +VCOMISH : 'vcomish'; +VCOMISS : 'vcomiss'; +VCOMPRESSPD : 'vcompresspd'; +VCOMPRESSPS : 'vcompressps'; +VCVTDQ2PD : 'vcvtdq2pd'; +VCVTDQ2PH : 'vcvtdq2ph'; +VCVTDQ2PS : 'vcvtdq2ps'; +VCVTNE2PS2BF16 : 'vcvtne2ps2bf16'; +VCVTNEEBF162PS : 'vcvtneebf162ps'; +VCVTNEEPH2PS : 'vcvtneeph2ps'; +VCVTNEOBF162PS : 'vcvtneobf162ps'; +VCVTNEOPH2PS : 'vcvtneoph2ps'; +VCVTNEPS2BF16 : 'vcvtneps2bf16'; +VCVTPD2DQ : 'vcvtpd2dq'; +VCVTPD2PH : 'vcvtpd2ph'; +VCVTPD2PS : 'vcvtpd2ps'; +VCVTPD2QQ : 'vcvtpd2qq'; +VCVTPD2UDQ : 'vcvtpd2udq'; +VCVTPD2UQQ : 'vcvtpd2uqq'; +VCVTPH2DQ : 'vcvtph2dq'; +VCVTPH2PD : 'vcvtph2pd'; +VCVTPH2PS : 'vcvtph2ps'; +VCVTPH2PSX : 'vcvtph2psx'; +VCVTPH2QQ : 'vcvtph2qq'; +VCVTPH2UDQ : 'vcvtph2udq'; +VCVTPH2UQQ : 'vcvtph2uqq'; +VCVTPH2UW : 'vcvtph2uw'; +VCVTPH2W : 'vcvtph2w'; +VCVTPS2DQ : 'vcvtps2dq'; +VCVTPS2PD : 'vcvtps2pd'; +VCVTPS2PH : 'vcvtps2ph'; +VCVTPS2QQ : 'vcvtps2qq'; +VCVTPS2UDQ : 'vcvtps2udq'; +VCVTPS2UQQ : 'vcvtps2uqq'; +VCVTQQ2PD : 'vcvtqq2pd'; +VCVTQQ2PH : 'vcvtqq2ph'; +VCVTQQ2PS : 'vcvtqq2ps'; +VCVTSD2SH : 'vcvtsd2sh'; +VCVTSD2SI : 'vcvtsd2si'; +VCVTSD2SS : 'vcvtsd2ss'; +VCVTSD2USI : 'vcvtsd2usi'; +VCVTSH2SD : 'vcvtsh2sd'; +VCVTSH2SI : 'vcvtsh2si'; +VCVTSH2SS : 'vcvtsh2ss'; +VCVTSH2USI : 'vcvtsh2usi'; +VCVTSI2SD : 'vcvtsi2sd'; +VCVTSI2SH : 'vcvtsi2sh'; +VCVTSI2SS : 'vcvtsi2ss'; +VCVTSS2SD : 'vcvtss2sd'; +VCVTSS2SH : 'vcvtss2sh'; +VCVTSS2SI : 'vcvtss2si'; +VCVTSS2USI : 'vcvtss2usi'; +VCVTTPD2DQ : 'vcvttpd2dq'; +VCVTTPD2QQ : 'vcvttpd2qq'; +VCVTTPD2UDQ : 'vcvttpd2udq'; +VCVTTPD2UQQ : 'vcvttpd2uqq'; +VCVTTPH2DQ : 'vcvttph2dq'; +VCVTTPH2QQ : 'vcvttph2qq'; +VCVTTPH2UDQ : 'vcvttph2udq'; +VCVTTPH2UQQ : 'vcvttph2uqq'; +VCVTTPH2UW : 'vcvttph2uw'; +VCVTTPH2W : 'vcvttph2w'; +VCVTTPS2DQ : 'vcvttps2dq'; +VCVTTPS2QQ : 'vcvttps2qq'; +VCVTTPS2UDQ : 'vcvttps2udq'; +VCVTTPS2UQQ : 'vcvttps2uqq'; +VCVTTSD2SI : 'vcvttsd2si'; +VCVTTSD2USI : 'vcvttsd2usi'; +VCVTTSH2SI : 'vcvttsh2si'; +VCVTTSH2USI : 'vcvttsh2usi'; +VCVTTSS2SI : 'vcvttss2si'; +VCVTTSS2USI : 'vcvttss2usi'; +VCVTUDQ2PD : 'vcvtudq2pd'; +VCVTUDQ2PH : 'vcvtudq2ph'; +VCVTUDQ2PS : 'vcvtudq2ps'; +VCVTUQQ2PD : 'vcvtuqq2pd'; +VCVTUQQ2PH : 'vcvtuqq2ph'; +VCVTUQQ2PS : 'vcvtuqq2ps'; +VCVTUSI2SD : 'vcvtusi2sd'; +VCVTUSI2SH : 'vcvtusi2sh'; +VCVTUSI2SS : 'vcvtusi2ss'; +VCVTUW2PH : 'vcvtuw2ph'; +VCVTW2PH : 'vcvtw2ph'; +VDBPSADBW : 'vdbpsadbw'; +VDIVPD : 'vdivpd'; +VDIVPH : 'vdivph'; +VDIVPS : 'vdivps'; +VDIVSD : 'vdivsd'; +VDIVSH : 'vdivsh'; +VDIVSS : 'vdivss'; +VDPBF16PS : 'vdpbf16ps'; +VDPPD : 'vdppd'; +VDPPS : 'vdpps'; +VENDSCALEPH : 'vendscaleph'; +VENDSCALESH : 'vendscalesh'; +VEXP2PD : 'vexp2pd'; +VEXP2PS : 'vexp2ps'; +VEXPANDPD : 'vexpandpd'; +VEXPANDPS : 'vexpandps'; +VEXTRACTF128 : 'vextractf128'; +VEXTRACTF32X4 : 'vextractf32x4'; +VEXTRACTF32X8 : 'vextractf32x8'; +VEXTRACTF64X2 : 'vextractf64x2'; +VEXTRACTF64X4 : 'vextractf64x4'; +VEXTRACTI128 : 'vextracti128'; +VEXTRACTI32X4 : 'vextracti32x4'; +VEXTRACTI32X8 : 'vextracti32x8'; +VEXTRACTI64X2 : 'vextracti64x2'; +VEXTRACTI64X4 : 'vextracti64x4'; +VEXTRACTPS : 'vextractps'; +VFCMADDCPH : 'vfcmaddcph'; +VFCMADDCSH : 'vfcmaddcsh'; +VFCMULCPCH : 'vfcmulcpch'; +VFCMULCSH : 'vfcmulcsh'; +VFIXUPIMMPD : 'vfixupimmpd'; +VFIXUPIMMPS : 'vfixupimmps'; +VFIXUPIMMSD : 'vfixupimmsd'; +VFIXUPIMMSS : 'vfixupimmss'; +VFMADD123PD : 'vfmadd123pd'; +VFMADD123PS : 'vfmadd123ps'; +VFMADD123SD : 'vfmadd123sd'; +VFMADD123SS : 'vfmadd123ss'; +VFMADD132PD : 'vfmadd132pd'; +VFMADD132PH : 'vfmadd132ph'; +VFMADD132PS : 'vfmadd132ps'; +VFMADD132SD : 'vfmadd132sd'; +VFMADD132SS : 'vfmadd132ss'; +VFMADD213PD : 'vfmadd213pd'; +VFMADD213PH : 'vfmadd213ph'; +VFMADD213PS : 'vfmadd213ps'; +VFMADD213SD : 'vfmadd213sd'; +VFMADD213SS : 'vfmadd213ss'; +VFMADD231PD : 'vfmadd231pd'; +VFMADD231PH : 'vfmadd231ph'; +VFMADD231PS : 'vfmadd231ps'; +VFMADD231SD : 'vfmadd231sd'; +VFMADD231SS : 'vfmadd231ss'; +VFMADD312PD : 'vfmadd312pd'; +VFMADD312PS : 'vfmadd312ps'; +VFMADD312SD : 'vfmadd312sd'; +VFMADD312SS : 'vfmadd312ss'; +VFMADD321PD : 'vfmadd321pd'; +VFMADD321PS : 'vfmadd321ps'; +VFMADD321SD : 'vfmadd321sd'; +VFMADD321SS : 'vfmadd321ss'; +VFMADDCPH : 'vfmaddcph'; +VFMADDCSH : 'vfmaddcsh'; +VFMADDPD : 'vfmaddpd'; +VFMADDPS : 'vfmaddps'; +VFMADDSD : 'vfmaddsd'; +VFMADDSS : 'vfmaddss'; +VFMADDSUB123PD : 'vfmaddsub123pd'; +VFMADDSUB123PS : 'vfmaddsub123ps'; +VFMADDSUB132PD : 'vfmaddsub132pd'; +VFMADDSUB132PH : 'vfmaddsub132ph'; +VFMADDSUB132PS : 'vfmaddsub132ps'; +VFMADDSUB213PD : 'vfmaddsub213pd'; +VFMADDSUB213PH : 'vfmaddsub213ph'; +VFMADDSUB213PS : 'vfmaddsub213ps'; +VFMADDSUB231PD : 'vfmaddsub231pd'; +VFMADDSUB231PH : 'vfmaddsub231ph'; +VFMADDSUB231PS : 'vfmaddsub231ps'; +VFMADDSUB312PD : 'vfmaddsub312pd'; +VFMADDSUB312PS : 'vfmaddsub312ps'; +VFMADDSUB321PD : 'vfmaddsub321pd'; +VFMADDSUB321PS : 'vfmaddsub321ps'; +VFMADDSUBPD : 'vfmaddsubpd'; +VFMADDSUBPS : 'vfmaddsubps'; +VFMSUB123PD : 'vfmsub123pd'; +VFMSUB123PS : 'vfmsub123ps'; +VFMSUB123SD : 'vfmsub123sd'; +VFMSUB123SS : 'vfmsub123ss'; +VFMSUB132PD : 'vfmsub132pd'; +VFMSUB132PH : 'vfmsub132ph'; +VFMSUB132PS : 'vfmsub132ps'; +VFMSUB132SD : 'vfmsub132sd'; +VFMSUB132SS : 'vfmsub132ss'; +VFMSUB213PD : 'vfmsub213pd'; +VFMSUB213PH : 'vfmsub213ph'; +VFMSUB213PS : 'vfmsub213ps'; +VFMSUB213SD : 'vfmsub213sd'; +VFMSUB213SS : 'vfmsub213ss'; +VFMSUB231PD : 'vfmsub231pd'; +VFMSUB231PH : 'vfmsub231ph'; +VFMSUB231PS : 'vfmsub231ps'; +VFMSUB231SD : 'vfmsub231sd'; +VFMSUB231SS : 'vfmsub231ss'; +VFMSUB312PD : 'vfmsub312pd'; +VFMSUB312PS : 'vfmsub312ps'; +VFMSUB312SD : 'vfmsub312sd'; +VFMSUB312SS : 'vfmsub312ss'; +VFMSUB321PD : 'vfmsub321pd'; +VFMSUB321PS : 'vfmsub321ps'; +VFMSUB321SD : 'vfmsub321sd'; +VFMSUB321SS : 'vfmsub321ss'; +VFMSUBADD123PD : 'vfmsubadd123pd'; +VFMSUBADD123PS : 'vfmsubadd123ps'; +VFMSUBADD132PD : 'vfmsubadd132pd'; +VFMSUBADD132PH : 'vfmsubadd132ph'; +VFMSUBADD132PS : 'vfmsubadd132ps'; +VFMSUBADD213PD : 'vfmsubadd213pd'; +VFMSUBADD213PH : 'vfmsubadd213ph'; +VFMSUBADD213PS : 'vfmsubadd213ps'; +VFMSUBADD231PD : 'vfmsubadd231pd'; +VFMSUBADD231PH : 'vfmsubadd231ph'; +VFMSUBADD231PS : 'vfmsubadd231ps'; +VFMSUBADD312PD : 'vfmsubadd312pd'; +VFMSUBADD312PS : 'vfmsubadd312ps'; +VFMSUBADD321PD : 'vfmsubadd321pd'; +VFMSUBADD321PS : 'vfmsubadd321ps'; +VFMSUBADDPD : 'vfmsubaddpd'; +VFMSUBADDPS : 'vfmsubaddps'; +VFMSUBPD : 'vfmsubpd'; +VFMSUBPS : 'vfmsubps'; +VFMSUBSD : 'vfmsubsd'; +VFMSUBSS : 'vfmsubss'; +VFMULCPCH : 'vfmulcpch'; +VFMULCSH : 'vfmulcsh'; +VFNMADD123PD : 'vfnmadd123pd'; +VFNMADD123PS : 'vfnmadd123ps'; +VFNMADD123SD : 'vfnmadd123sd'; +VFNMADD123SS : 'vfnmadd123ss'; +VFNMADD132PD : 'vfnmadd132pd'; +VFNMADD132PS : 'vfnmadd132ps'; +VFNMADD132SD : 'vfnmadd132sd'; +VFNMADD132SS : 'vfnmadd132ss'; +VFNMADD213PD : 'vfnmadd213pd'; +VFNMADD213PS : 'vfnmadd213ps'; +VFNMADD213SD : 'vfnmadd213sd'; +VFNMADD213SS : 'vfnmadd213ss'; +VFNMADD231PD : 'vfnmadd231pd'; +VFNMADD231PS : 'vfnmadd231ps'; +VFNMADD231SD : 'vfnmadd231sd'; +VFNMADD231SS : 'vfnmadd231ss'; +VFNMADD312PD : 'vfnmadd312pd'; +VFNMADD312PS : 'vfnmadd312ps'; +VFNMADD312SD : 'vfnmadd312sd'; +VFNMADD312SS : 'vfnmadd312ss'; +VFNMADD321PD : 'vfnmadd321pd'; +VFNMADD321PS : 'vfnmadd321ps'; +VFNMADD321SD : 'vfnmadd321sd'; +VFNMADD321SS : 'vfnmadd321ss'; +VFNMADDPD : 'vfnmaddpd'; +VFNMADDPS : 'vfnmaddps'; +VFNMADDSD : 'vfnmaddsd'; +VFNMADDSS : 'vfnmaddss'; +VFNMSUB123PD : 'vfnmsub123pd'; +VFNMSUB123PS : 'vfnmsub123ps'; +VFNMSUB123SD : 'vfnmsub123sd'; +VFNMSUB123SS : 'vfnmsub123ss'; +VFNMSUB132PD : 'vfnmsub132pd'; +VFNMSUB132PS : 'vfnmsub132ps'; +VFNMSUB132SD : 'vfnmsub132sd'; +VFNMSUB132SS : 'vfnmsub132ss'; +VFNMSUB213PD : 'vfnmsub213pd'; +VFNMSUB213PS : 'vfnmsub213ps'; +VFNMSUB213SD : 'vfnmsub213sd'; +VFNMSUB213SS : 'vfnmsub213ss'; +VFNMSUB231PD : 'vfnmsub231pd'; +VFNMSUB231PS : 'vfnmsub231ps'; +VFNMSUB231SD : 'vfnmsub231sd'; +VFNMSUB231SS : 'vfnmsub231ss'; +VFNMSUB312PD : 'vfnmsub312pd'; +VFNMSUB312PS : 'vfnmsub312ps'; +VFNMSUB312SD : 'vfnmsub312sd'; +VFNMSUB312SS : 'vfnmsub312ss'; +VFNMSUB321PD : 'vfnmsub321pd'; +VFNMSUB321PS : 'vfnmsub321ps'; +VFNMSUB321SD : 'vfnmsub321sd'; +VFNMSUB321SS : 'vfnmsub321ss'; +VFNMSUBPD : 'vfnmsubpd'; +VFNMSUBPS : 'vfnmsubps'; +VFNMSUBSD : 'vfnmsubsd'; +VFNMSUBSS : 'vfnmsubss'; +VFPCLASSPD : 'vfpclasspd'; +VFPCLASSPH : 'vfpclassph'; +VFPCLASSPS : 'vfpclassps'; +VFPCLASSSD : 'vfpclasssd'; +VFPCLASSSH : 'vfpclasssh'; +VFPCLASSSS : 'vfpclassss'; +VFRCZPD : 'vfrczpd'; +VFRCZPS : 'vfrczps'; +VFRCZSD : 'vfrczsd'; +VFRCZSS : 'vfrczss'; +VGATHERDPD : 'vgatherdpd'; +VGATHERDPS : 'vgatherdps'; +VGATHERPF0DPD : 'vgatherpf0dpd'; +VGATHERPF0DPS : 'vgatherpf0dps'; +VGATHERPF0QPD : 'vgatherpf0qpd'; +VGATHERPF0QPS : 'vgatherpf0qps'; +VGATHERPF1DPD : 'vgatherpf1dpd'; +VGATHERPF1DPS : 'vgatherpf1dps'; +VGATHERPF1QPD : 'vgatherpf1qpd'; +VGATHERPF1QPS : 'vgatherpf1qps'; +VGATHERQPD : 'vgatherqpd'; +VGATHERQPS : 'vgatherqps'; +VGETEXPPD : 'vgetexppd'; +VGETEXPPH : 'vgetexpph'; +VGETEXPPS : 'vgetexpps'; +VGETEXPSD : 'vgetexpsd'; +VGETEXPSH : 'vgetexpsh'; +VGETEXPSS : 'vgetexpss'; +VGETMANTPD : 'vgetmantpd'; +VGETMANTPH : 'vgetmantph'; +VGETMANTPS : 'vgetmantps'; +VGETMANTSD : 'vgetmantsd'; +VGETMANTSH : 'vgetmantsh'; +VGETMANTSS : 'vgetmantss'; +VGETMAXPH : 'vgetmaxph'; +VGETMAXSH : 'vgetmaxsh'; +VGETMINPH : 'vgetminph'; +VGETMINSH : 'vgetminsh'; +VGF2P8AFFINEINVQB : 'vgf2p8affineinvqb'; +VGF2P8AFFINEQB : 'vgf2p8affineqb'; +VGF2P8MULB : 'vgf2p8mulb'; +VHADDPD : 'vhaddpd'; +VHADDPS : 'vhaddps'; +VHSUBPD : 'vhsubpd'; +VHSUBPS : 'vhsubps'; +VINSERTF128 : 'vinsertf128'; +VINSERTF32X4 : 'vinsertf32x4'; +VINSERTF32X8 : 'vinsertf32x8'; +VINSERTF64X2 : 'vinsertf64x2'; +VINSERTF64X4 : 'vinsertf64x4'; +VINSERTI128 : 'vinserti128'; +VINSERTI32X4 : 'vinserti32x4'; +VINSERTI32X8 : 'vinserti32x8'; +VINSERTI64X2 : 'vinserti64x2'; +VINSERTI64X4 : 'vinserti64x4'; +VINSERTPS : 'vinsertps'; +VLDDQU : 'vlddqu'; +VLDMXCSR : 'vldmxcsr'; +VLDQQU : 'vldqqu'; +VMASKMOVDQU : 'vmaskmovdqu'; +VMASKMOVPD : 'vmaskmovpd'; +VMASKMOVPS : 'vmaskmovps'; +VMAXPD : 'vmaxpd'; +VMAXPS : 'vmaxps'; +VMAXSD : 'vmaxsd'; +VMAXSS : 'vmaxss'; +VMCALL : 'vmcall'; +VMCLEAR : 'vmclear'; +VMFUNC : 'vmfunc'; +VMGEXIT : 'vmgexit'; +VMINPD : 'vminpd'; +VMINPS : 'vminps'; +VMINSD : 'vminsd'; +VMINSS : 'vminss'; +VMLAUNCH : 'vmlaunch'; +VMLOAD : 'vmload'; +VMMCALL : 'vmmcall'; +VMOVAPD : 'vmovapd'; +VMOVAPS : 'vmovaps'; +VMOVD : 'vmovd'; +VMOVDDUP : 'vmovddup'; +VMOVDQA : 'vmovdqa'; +VMOVDQA32 : 'vmovdqa32'; +VMOVDQA64 : 'vmovdqa64'; +VMOVDQU : 'vmovdqu'; +VMOVDQU16 : 'vmovdqu16'; +VMOVDQU32 : 'vmovdqu32'; +VMOVDQU64 : 'vmovdqu64'; +VMOVDQU8 : 'vmovdqu8'; +VMOVHLPS : 'vmovhlps'; +VMOVHPD : 'vmovhpd'; +VMOVHPS : 'vmovhps'; +VMOVLHPS : 'vmovlhps'; +VMOVLPD : 'vmovlpd'; +VMOVLPS : 'vmovlps'; +VMOVMSKPD : 'vmovmskpd'; +VMOVMSKPS : 'vmovmskps'; +VMOVNTDQ : 'vmovntdq'; +VMOVNTDQA : 'vmovntdqa'; +VMOVNTPD : 'vmovntpd'; +VMOVNTPS : 'vmovntps'; +VMOVNTQQ : 'vmovntqq'; +VMOVQ : 'vmovq'; +VMOVQQA : 'vmovqqa'; +VMOVQQU : 'vmovqqu'; +VMOVSD : 'vmovsd'; +VMOVSH : 'vmovsh'; +VMOVSHDUP : 'vmovshdup'; +VMOVSLDUP : 'vmovsldup'; +VMOVSS : 'vmovss'; +VMOVUPD : 'vmovupd'; +VMOVUPS : 'vmovups'; +VMOVW : 'vmovw'; +VMPSADBW : 'vmpsadbw'; +VMPTRLD : 'vmptrld'; +VMPTRST : 'vmptrst'; +VMREAD : 'vmread'; +VMRESUME : 'vmresume'; +VMRUN : 'vmrun'; +VMSAVE : 'vmsave'; +VMULPD : 'vmulpd'; +VMULPH : 'vmulph'; +VMULPS : 'vmulps'; +VMULSD : 'vmulsd'; +VMULSH : 'vmulsh'; +VMULSS : 'vmulss'; +VMWRITE : 'vmwrite'; +VMXOFF : 'vmxoff'; +VMXON : 'vmxon'; +VORPD : 'vorpd'; +VORPS : 'vorps'; +VP2INTERSECTD : 'vp2intersectd'; +VPABSB : 'vpabsb'; +VPABSD : 'vpabsd'; +VPABSQ : 'vpabsq'; +VPABSW : 'vpabsw'; +VPACKSSDW : 'vpackssdw'; +VPACKSSWB : 'vpacksswb'; +VPACKUSDW : 'vpackusdw'; +VPACKUSWB : 'vpackuswb'; +VPADDB : 'vpaddb'; +VPADDD : 'vpaddd'; +VPADDQ : 'vpaddq'; +VPADDSB : 'vpaddsb'; +VPADDSW : 'vpaddsw'; +VPADDUSB : 'vpaddusb'; +VPADDUSW : 'vpaddusw'; +VPADDW : 'vpaddw'; +VPALIGNR : 'vpalignr'; +VPAND : 'vpand'; +VPANDD : 'vpandd'; +VPANDN : 'vpandn'; +VPANDND : 'vpandnd'; +VPANDNQ : 'vpandnq'; +VPANDQ : 'vpandq'; +VPAVGB : 'vpavgb'; +VPAVGW : 'vpavgw'; +VPBLENDD : 'vpblendd'; +VPBLENDMB : 'vpblendmb'; +VPBLENDMD : 'vpblendmd'; +VPBLENDMQ : 'vpblendmq'; +VPBLENDMW : 'vpblendmw'; +VPBLENDVB : 'vpblendvb'; +VPBLENDW : 'vpblendw'; +VPBROADCASTB : 'vpbroadcastb'; +VPBROADCASTD : 'vpbroadcastd'; +VPBROADCASTMB2Q : 'vpbroadcastmb2q'; +VPBROADCASTMW2D : 'vpbroadcastmw2d'; +VPBROADCASTQ : 'vpbroadcastq'; +VPBROADCASTW : 'vpbroadcastw'; +VPCLMULHQHQDQ : 'vpclmulhqhqdq'; +VPCLMULHQLQDQ : 'vpclmulhqlqdq'; +VPCLMULLQHQDQ : 'vpclmullqhqdq'; +VPCLMULLQLQDQ : 'vpclmullqlqdq'; +VPCLMULQDQ : 'vpclmulqdq'; +VPCMOV : 'vpcmov'; +VPCMPB : 'vpcmpb'; +VPCMPD : 'vpcmpd'; +VPCMPEQB : 'vpcmpeqb'; +VPCMPEQD : 'vpcmpeqd'; +VPCMPEQQ : 'vpcmpeqq'; +VPCMPEQUB : 'vpcmpequb'; +VPCMPEQUD : 'vpcmpequd'; +VPCMPEQUQ : 'vpcmpequq'; +VPCMPEQUW : 'vpcmpequw'; +VPCMPEQW : 'vpcmpeqw'; +VPCMPESTRI : 'vpcmpestri'; +VPCMPESTRM : 'vpcmpestrm'; +VPCMPGEB : 'vpcmpgeb'; +VPCMPGED : 'vpcmpged'; +VPCMPGEQ : 'vpcmpgeq'; +VPCMPGEUB : 'vpcmpgeub'; +VPCMPGEUD : 'vpcmpgeud'; +VPCMPGEUQ : 'vpcmpgeuq'; +VPCMPGEUW : 'vpcmpgeuw'; +VPCMPGEW : 'vpcmpgew'; +VPCMPGTB : 'vpcmpgtb'; +VPCMPGTD : 'vpcmpgtd'; +VPCMPGTQ : 'vpcmpgtq'; +VPCMPGTUB : 'vpcmpgtub'; +VPCMPGTUD : 'vpcmpgtud'; +VPCMPGTUQ : 'vpcmpgtuq'; +VPCMPGTUW : 'vpcmpgtuw'; +VPCMPGTW : 'vpcmpgtw'; +VPCMPISTRI : 'vpcmpistri'; +VPCMPISTRM : 'vpcmpistrm'; +VPCMPLEB : 'vpcmpleb'; +VPCMPLED : 'vpcmpled'; +VPCMPLEQ : 'vpcmpleq'; +VPCMPLEUB : 'vpcmpleub'; +VPCMPLEUD : 'vpcmpleud'; +VPCMPLEUQ : 'vpcmpleuq'; +VPCMPLEUW : 'vpcmpleuw'; +VPCMPLEW : 'vpcmplew'; +VPCMPLTB : 'vpcmpltb'; +VPCMPLTD : 'vpcmpltd'; +VPCMPLTQ : 'vpcmpltq'; +VPCMPLTUB : 'vpcmpltub'; +VPCMPLTUD : 'vpcmpltud'; +VPCMPLTUQ : 'vpcmpltuq'; +VPCMPLTUW : 'vpcmpltuw'; +VPCMPLTW : 'vpcmpltw'; +VPCMPNEQB : 'vpcmpneqb'; +VPCMPNEQD : 'vpcmpneqd'; +VPCMPNEQQ : 'vpcmpneqq'; +VPCMPNEQUB : 'vpcmpnequb'; +VPCMPNEQUD : 'vpcmpnequd'; +VPCMPNEQUQ : 'vpcmpnequq'; +VPCMPNEQUW : 'vpcmpnequw'; +VPCMPNEQW : 'vpcmpneqw'; +VPCMPNGTB : 'vpcmpngtb'; +VPCMPNGTD : 'vpcmpngtd'; +VPCMPNGTQ : 'vpcmpngtq'; +VPCMPNGTUB : 'vpcmpngtub'; +VPCMPNGTUD : 'vpcmpngtud'; +VPCMPNGTUQ : 'vpcmpngtuq'; +VPCMPNGTUW : 'vpcmpngtuw'; +VPCMPNGTW : 'vpcmpngtw'; +VPCMPNLEB : 'vpcmpnleb'; +VPCMPNLED : 'vpcmpnled'; +VPCMPNLEQ : 'vpcmpnleq'; +VPCMPNLEUB : 'vpcmpnleub'; +VPCMPNLEUD : 'vpcmpnleud'; +VPCMPNLEUQ : 'vpcmpnleuq'; +VPCMPNLEUW : 'vpcmpnleuw'; +VPCMPNLEW : 'vpcmpnlew'; +VPCMPNLTB : 'vpcmpnltb'; +VPCMPNLTD : 'vpcmpnltd'; +VPCMPNLTQ : 'vpcmpnltq'; +VPCMPNLTUB : 'vpcmpnltub'; +VPCMPNLTUD : 'vpcmpnltud'; +VPCMPNLTUQ : 'vpcmpnltuq'; +VPCMPNLTUW : 'vpcmpnltuw'; +VPCMPNLTW : 'vpcmpnltw'; +VPCMPQ : 'vpcmpq'; +VPCMPUB : 'vpcmpub'; +VPCMPUD : 'vpcmpud'; +VPCMPUQ : 'vpcmpuq'; +VPCMPUW : 'vpcmpuw'; +VPCMPW : 'vpcmpw'; +VPCOMB : 'vpcomb'; +VPCOMD : 'vpcomd'; +VPCOMPRESSB : 'vpcompressb'; +VPCOMPRESSD : 'vpcompressd'; +VPCOMPRESSQ : 'vpcompressq'; +VPCOMPRESSW : 'vpcompressw'; +VPCOMQ : 'vpcomq'; +VPCOMUB : 'vpcomub'; +VPCOMUD : 'vpcomud'; +VPCOMUQ : 'vpcomuq'; +VPCOMUW : 'vpcomuw'; +VPCOMW : 'vpcomw'; +VPCONFLICTD : 'vpconflictd'; +VPCONFLICTQ : 'vpconflictq'; +VPDPBSSD : 'vpdpbssd'; +VPDPBSSDS : 'vpdpbssds'; +VPDPBSUD : 'vpdpbsud'; +VPDPBSUDS : 'vpdpbsuds'; +VPDPBUSD : 'vpdpbusd'; +VPDPBUSDS : 'vpdpbusds'; +VPDPBUUD : 'vpdpbuud'; +VPDPBUUDS : 'vpdpbuuds'; +VPDPWSSD : 'vpdpwssd'; +VPDPWSSDS : 'vpdpwssds'; +VPERM2F128 : 'vperm2f128'; +VPERM2I128 : 'vperm2i128'; +VPERMB : 'vpermb'; +VPERMD : 'vpermd'; +VPERMI2B : 'vpermi2b'; +VPERMI2D : 'vpermi2d'; +VPERMI2PD : 'vpermi2pd'; +VPERMI2PS : 'vpermi2ps'; +VPERMI2Q : 'vpermi2q'; +VPERMI2W : 'vpermi2w'; +VPERMILPD : 'vpermilpd'; +VPERMILPS : 'vpermilps'; +VPERMPD : 'vpermpd'; +VPERMPS : 'vpermps'; +VPERMQ : 'vpermq'; +VPERMT2B : 'vpermt2b'; +VPERMT2D : 'vpermt2d'; +VPERMT2PD : 'vpermt2pd'; +VPERMT2PS : 'vpermt2ps'; +VPERMT2Q : 'vpermt2q'; +VPERMT2W : 'vpermt2w'; +VPERMW : 'vpermw'; +VPEXPANDB : 'vpexpandb'; +VPEXPANDD : 'vpexpandd'; +VPEXPANDQ : 'vpexpandq'; +VPEXPANDW : 'vpexpandw'; +VPEXTRB : 'vpextrb'; +VPEXTRD : 'vpextrd'; +VPEXTRQ : 'vpextrq'; +VPEXTRW : 'vpextrw'; +VPGATHERDD : 'vpgatherdd'; +VPGATHERDQ : 'vpgatherdq'; +VPGATHERQD : 'vpgatherqd'; +VPGATHERQQ : 'vpgatherqq'; +VPHADDBD : 'vphaddbd'; +VPHADDBQ : 'vphaddbq'; +VPHADDBW : 'vphaddbw'; +VPHADDD : 'vphaddd'; +VPHADDDQ : 'vphadddq'; +VPHADDSW : 'vphaddsw'; +VPHADDUBD : 'vphaddubd'; +VPHADDUBQ : 'vphaddubq'; +VPHADDUBW : 'vphaddubw'; +VPHADDUDQ : 'vphaddudq'; +VPHADDUWD : 'vphadduwd'; +VPHADDUWQ : 'vphadduwq'; +VPHADDW : 'vphaddw'; +VPHADDWD : 'vphaddwd'; +VPHADDWQ : 'vphaddwq'; +VPHMINPOSUW : 'vphminposuw'; +VPHSUBBW : 'vphsubbw'; +VPHSUBD : 'vphsubd'; +VPHSUBDQ : 'vphsubdq'; +VPHSUBSW : 'vphsubsw'; +VPHSUBW : 'vphsubw'; +VPHSUBWD : 'vphsubwd'; +VPINSRB : 'vpinsrb'; +VPINSRD : 'vpinsrd'; +VPINSRQ : 'vpinsrq'; +VPINSRW : 'vpinsrw'; +VPLZCNTD : 'vplzcntd'; +VPLZCNTQ : 'vplzcntq'; +VPMACSDD : 'vpmacsdd'; +VPMACSDQH : 'vpmacsdqh'; +VPMACSDQL : 'vpmacsdql'; +VPMACSSDD : 'vpmacssdd'; +VPMACSSDQH : 'vpmacssdqh'; +VPMACSSDQL : 'vpmacssdql'; +VPMACSSWD : 'vpmacsswd'; +VPMACSSWW : 'vpmacssww'; +VPMACSWD : 'vpmacswd'; +VPMACSWW : 'vpmacsww'; +VPMADCSSWD : 'vpmadcsswd'; +VPMADCSWD : 'vpmadcswd'; +VPMADD132PH : 'vpmadd132ph'; +VPMADD132SH : 'vpmadd132sh'; +VPMADD213PH : 'vpmadd213ph'; +VPMADD213SH : 'vpmadd213sh'; +VPMADD231PH : 'vpmadd231ph'; +VPMADD231SH : 'vpmadd231sh'; +VPMADD52HUQ : 'vpmadd52huq'; +VPMADD52LUQ : 'vpmadd52luq'; +VPMADDUBSW : 'vpmaddubsw'; +VPMADDWD : 'vpmaddwd'; +VPMASKMOVD : 'vpmaskmovd'; +VPMASKMOVQ : 'vpmaskmovq'; +VPMAXSB : 'vpmaxsb'; +VPMAXSD : 'vpmaxsd'; +VPMAXSQ : 'vpmaxsq'; +VPMAXSW : 'vpmaxsw'; +VPMAXUB : 'vpmaxub'; +VPMAXUD : 'vpmaxud'; +VPMAXUQ : 'vpmaxuq'; +VPMAXUW : 'vpmaxuw'; +VPMINSB : 'vpminsb'; +VPMINSD : 'vpminsd'; +VPMINSQ : 'vpminsq'; +VPMINSW : 'vpminsw'; +VPMINUB : 'vpminub'; +VPMINUD : 'vpminud'; +VPMINUQ : 'vpminuq'; +VPMINUW : 'vpminuw'; +VPMOVB2M : 'vpmovb2m'; +VPMOVD2M : 'vpmovd2m'; +VPMOVDB : 'vpmovdb'; +VPMOVDW : 'vpmovdw'; +VPMOVM2B : 'vpmovm2b'; +VPMOVM2D : 'vpmovm2d'; +VPMOVM2Q : 'vpmovm2q'; +VPMOVM2W : 'vpmovm2w'; +VPMOVMSKB : 'vpmovmskb'; +VPMOVQ2M : 'vpmovq2m'; +VPMOVQB : 'vpmovqb'; +VPMOVQD : 'vpmovqd'; +VPMOVQW : 'vpmovqw'; +VPMOVSDB : 'vpmovsdb'; +VPMOVSDW : 'vpmovsdw'; +VPMOVSQB : 'vpmovsqb'; +VPMOVSQD : 'vpmovsqd'; +VPMOVSQW : 'vpmovsqw'; +VPMOVSWB : 'vpmovswb'; +VPMOVSXBD : 'vpmovsxbd'; +VPMOVSXBQ : 'vpmovsxbq'; +VPMOVSXBW : 'vpmovsxbw'; +VPMOVSXDQ : 'vpmovsxdq'; +VPMOVSXWD : 'vpmovsxwd'; +VPMOVSXWQ : 'vpmovsxwq'; +VPMOVUSDB : 'vpmovusdb'; +VPMOVUSDW : 'vpmovusdw'; +VPMOVUSQB : 'vpmovusqb'; +VPMOVUSQD : 'vpmovusqd'; +VPMOVUSQW : 'vpmovusqw'; +VPMOVUSWB : 'vpmovuswb'; +VPMOVW2M : 'vpmovw2m'; +VPMOVWB : 'vpmovwb'; +VPMOVZXBD : 'vpmovzxbd'; +VPMOVZXBQ : 'vpmovzxbq'; +VPMOVZXBW : 'vpmovzxbw'; +VPMOVZXDQ : 'vpmovzxdq'; +VPMOVZXWD : 'vpmovzxwd'; +VPMOVZXWQ : 'vpmovzxwq'; +VPMSUB132PH : 'vpmsub132ph'; +VPMSUB132SH : 'vpmsub132sh'; +VPMSUB213PH : 'vpmsub213ph'; +VPMSUB213SH : 'vpmsub213sh'; +VPMSUB231PH : 'vpmsub231ph'; +VPMSUB231SH : 'vpmsub231sh'; +VPMULDQ : 'vpmuldq'; +VPMULHRSW : 'vpmulhrsw'; +VPMULHUW : 'vpmulhuw'; +VPMULHW : 'vpmulhw'; +VPMULLD : 'vpmulld'; +VPMULLQ : 'vpmullq'; +VPMULLW : 'vpmullw'; +VPMULTISHIFTQB : 'vpmultishiftqb'; +VPMULUDQ : 'vpmuludq'; +VPNMADD132SH : 'vpnmadd132sh'; +VPNMADD213SH : 'vpnmadd213sh'; +VPNMADD231SH : 'vpnmadd231sh'; +VPNMSUB132SH : 'vpnmsub132sh'; +VPNMSUB213SH : 'vpnmsub213sh'; +VPNMSUB231SH : 'vpnmsub231sh'; +VPOPCNTB : 'vpopcntb'; +VPOPCNTD : 'vpopcntd'; +VPOPCNTQ : 'vpopcntq'; +VPOPCNTW : 'vpopcntw'; +VPOR : 'vpor'; +VPORD : 'vpord'; +VPORQ : 'vporq'; +VPPERM : 'vpperm'; +VPROLD : 'vprold'; +VPROLQ : 'vprolq'; +VPROLVD : 'vprolvd'; +VPROLVQ : 'vprolvq'; +VPRORD : 'vprord'; +VPRORQ : 'vprorq'; +VPRORVD : 'vprorvd'; +VPRORVQ : 'vprorvq'; +VPROTB : 'vprotb'; +VPROTD : 'vprotd'; +VPROTQ : 'vprotq'; +VPROTW : 'vprotw'; +VPSADBW : 'vpsadbw'; +VPSCATTERDD : 'vpscatterdd'; +VPSCATTERDQ : 'vpscatterdq'; +VPSCATTERQD : 'vpscatterqd'; +VPSCATTERQQ : 'vpscatterqq'; +VPSHAB : 'vpshab'; +VPSHAD : 'vpshad'; +VPSHAQ : 'vpshaq'; +VPSHAW : 'vpshaw'; +VPSHLB : 'vpshlb'; +VPSHLD : 'vpshld'; +VPSHLDD : 'vpshldd'; +VPSHLDQ : 'vpshldq'; +VPSHLDVD : 'vpshldvd'; +VPSHLDVQ : 'vpshldvq'; +VPSHLDVW : 'vpshldvw'; +VPSHLDW : 'vpshldw'; +VPSHLQ : 'vpshlq'; +VPSHLW : 'vpshlw'; +VPSHRDD : 'vpshrdd'; +VPSHRDQ : 'vpshrdq'; +VPSHRDVD : 'vpshrdvd'; +VPSHRDVQ : 'vpshrdvq'; +VPSHRDVW : 'vpshrdvw'; +VPSHRDW : 'vpshrdw'; +VPSHUFB : 'vpshufb'; +VPSHUFBITQMB : 'vpshufbitqmb'; +VPSHUFD : 'vpshufd'; +VPSHUFHW : 'vpshufhw'; +VPSHUFLW : 'vpshuflw'; +VPSIGNB : 'vpsignb'; +VPSIGND : 'vpsignd'; +VPSIGNW : 'vpsignw'; +VPSLLD : 'vpslld'; +VPSLLDQ : 'vpslldq'; +VPSLLQ : 'vpsllq'; +VPSLLVD : 'vpsllvd'; +VPSLLVQ : 'vpsllvq'; +VPSLLVW : 'vpsllvw'; +VPSLLW : 'vpsllw'; +VPSRAD : 'vpsrad'; +VPSRAQ : 'vpsraq'; +VPSRAVD : 'vpsravd'; +VPSRAVQ : 'vpsravq'; +VPSRAVW : 'vpsravw'; +VPSRAW : 'vpsraw'; +VPSRLD : 'vpsrld'; +VPSRLDQ : 'vpsrldq'; +VPSRLQ : 'vpsrlq'; +VPSRLVD : 'vpsrlvd'; +VPSRLVQ : 'vpsrlvq'; +VPSRLVW : 'vpsrlvw'; +VPSRLW : 'vpsrlw'; +VPSUBB : 'vpsubb'; +VPSUBD : 'vpsubd'; +VPSUBQ : 'vpsubq'; +VPSUBSB : 'vpsubsb'; +VPSUBSW : 'vpsubsw'; +VPSUBUSB : 'vpsubusb'; +VPSUBUSW : 'vpsubusw'; +VPSUBW : 'vpsubw'; +VPTERNLOGD : 'vpternlogd'; +VPTERNLOGQ : 'vpternlogq'; +VPTEST : 'vptest'; +VPTESTMB : 'vptestmb'; +VPTESTMD : 'vptestmd'; +VPTESTMQ : 'vptestmq'; +VPTESTMW : 'vptestmw'; +VPTESTNMB : 'vptestnmb'; +VPTESTNMD : 'vptestnmd'; +VPTESTNMQ : 'vptestnmq'; +VPTESTNMW : 'vptestnmw'; +VPUNPCKHBW : 'vpunpckhbw'; +VPUNPCKHDQ : 'vpunpckhdq'; +VPUNPCKHQDQ : 'vpunpckhqdq'; +VPUNPCKHWD : 'vpunpckhwd'; +VPUNPCKLBW : 'vpunpcklbw'; +VPUNPCKLDQ : 'vpunpckldq'; +VPUNPCKLQDQ : 'vpunpcklqdq'; +VPUNPCKLWD : 'vpunpcklwd'; +VPXOR : 'vpxor'; +VPXORD : 'vpxord'; +VPXORQ : 'vpxorq'; +VRANGEPD : 'vrangepd'; +VRANGEPS : 'vrangeps'; +VRANGESD : 'vrangesd'; +VRANGESS : 'vrangess'; +VRCP14PD : 'vrcp14pd'; +VRCP14PS : 'vrcp14ps'; +VRCP14SD : 'vrcp14sd'; +VRCP14SS : 'vrcp14ss'; +VRCP28PD : 'vrcp28pd'; +VRCP28PS : 'vrcp28ps'; +VRCP28SD : 'vrcp28sd'; +VRCP28SS : 'vrcp28ss'; +VRCPPH : 'vrcpph'; +VRCPPS : 'vrcpps'; +VRCPSH : 'vrcpsh'; +VRCPSS : 'vrcpss'; +VREDUCEPD : 'vreducepd'; +VREDUCEPH : 'vreduceph'; +VREDUCEPS : 'vreduceps'; +VREDUCESD : 'vreducesd'; +VREDUCESH : 'vreducesh'; +VREDUCESS : 'vreducess'; +VRNDSCALEPD : 'vrndscalepd'; +VRNDSCALEPS : 'vrndscaleps'; +VRNDSCALESD : 'vrndscalesd'; +VRNDSCALESS : 'vrndscaless'; +VROUNDPD : 'vroundpd'; +VROUNDPS : 'vroundps'; +VROUNDSD : 'vroundsd'; +VROUNDSS : 'vroundss'; +VRSQRT14PD : 'vrsqrt14pd'; +VRSQRT14PS : 'vrsqrt14ps'; +VRSQRT14SD : 'vrsqrt14sd'; +VRSQRT14SS : 'vrsqrt14ss'; +VRSQRT28PD : 'vrsqrt28pd'; +VRSQRT28PS : 'vrsqrt28ps'; +VRSQRT28SD : 'vrsqrt28sd'; +VRSQRT28SS : 'vrsqrt28ss'; +VRSQRTPH : 'vrsqrtph'; +VRSQRTPS : 'vrsqrtps'; +VRSQRTSH : 'vrsqrtsh'; +VRSQRTSS : 'vrsqrtss'; +VSCALEFPD : 'vscalefpd'; +VSCALEFPH : 'vscalefph'; +VSCALEFPS : 'vscalefps'; +VSCALEFSD : 'vscalefsd'; +VSCALEFSH : 'vscalefsh'; +VSCALEFSS : 'vscalefss'; +VSCATTERDPD : 'vscatterdpd'; +VSCATTERDPS : 'vscatterdps'; +VSCATTERPF0DPD : 'vscatterpf0dpd'; +VSCATTERPF0DPS : 'vscatterpf0dps'; +VSCATTERPF0QPD : 'vscatterpf0qpd'; +VSCATTERPF0QPS : 'vscatterpf0qps'; +VSCATTERPF1DPD : 'vscatterpf1dpd'; +VSCATTERPF1DPS : 'vscatterpf1dps'; +VSCATTERPF1QPD : 'vscatterpf1qpd'; +VSCATTERPF1QPS : 'vscatterpf1qps'; +VSCATTERQPD : 'vscatterqpd'; +VSCATTERQPS : 'vscatterqps'; +VSHUFF32X4 : 'vshuff32x4'; +VSHUFF64X2 : 'vshuff64x2'; +VSHUFI32X4 : 'vshufi32x4'; +VSHUFI64X2 : 'vshufi64x2'; +VSHUFPD : 'vshufpd'; +VSHUFPS : 'vshufps'; +VSQRTPD : 'vsqrtpd'; +VSQRTPH : 'vsqrtph'; +VSQRTPS : 'vsqrtps'; +VSQRTSD : 'vsqrtsd'; +VSQRTSH : 'vsqrtsh'; +VSQRTSS : 'vsqrtss'; +VSTMXCSR : 'vstmxcsr'; +VSUBPD : 'vsubpd'; +VSUBPH : 'vsubph'; +VSUBPS : 'vsubps'; +VSUBSD : 'vsubsd'; +VSUBSH : 'vsubsh'; +VSUBSS : 'vsubss'; +VTESTPD : 'vtestpd'; +VTESTPS : 'vtestps'; +VUCOMISD : 'vucomisd'; +VUCOMISH : 'vucomish'; +VUCOMISS : 'vucomiss'; +VUNPCKHPD : 'vunpckhpd'; +VUNPCKHPS : 'vunpckhps'; +VUNPCKLPD : 'vunpcklpd'; +VUNPCKLPS : 'vunpcklps'; +VXORPD : 'vxorpd'; +VXORPS : 'vxorps'; +VZEROALL : 'vzeroall'; +VZEROUPPER : 'vzeroupper'; +WBNOINVD : 'wbnoinvd'; +WRFSBASE : 'wrfsbase'; +WRGSBASE : 'wrgsbase'; +WRMSRLIST : 'wrmsrlist'; +WRMSRNS : 'wrmsrns'; +WRPKRU : 'wrpkru'; +WRSSD : 'wrssd'; +WRSSQ : 'wrssq'; +WRUSSD : 'wrussd'; +WRUSSQ : 'wrussq'; +XABORT : 'xabort'; +XBEGIN : 'xbegin'; +XCRYPTCBC : 'xcryptcbc'; +XCRYPTCFB : 'xcryptcfb'; +XCRYPTCTR : 'xcryptctr'; +XCRYPTECB : 'xcryptecb'; +XCRYPTOFB : 'xcryptofb'; +XEND : 'xend'; +XGETBV : 'xgetbv'; +XORPD : 'xorpd'; +XORPS : 'xorps'; +XRESLDTRK : 'xresldtrk'; +XRSTOR : 'xrstor'; +XRSTOR64 : 'xrstor64'; +XRSTORS : 'xrstors'; +XRSTORS64 : 'xrstors64'; +XSAVE : 'xsave'; +XSAVE64 : 'xsave64'; +XSAVEC : 'xsavec'; +XSAVEC64 : 'xsavec64'; +XSAVEOPT : 'xsaveopt'; +XSAVEOPT64 : 'xsaveopt64'; +XSAVES : 'xsaves'; +XSAVES64 : 'xsaves64'; +XSETBV : 'xsetbv'; +XSHA1 : 'xsha1'; +XSHA256 : 'xsha256'; +XSTORE : 'xstore'; +XSUSLDTRK : 'xsusldtrk'; +XTEST : 'xtest'; -FLOAT_NUMBER - : [0-9][0-9_]* '.' [0-9_]* 'e'? SIGN? [0-9_]+ - | '0x1p+' [0-9]+ - ; +BITS : 'bits'; +USE16 : 'use16'; +USE32 : 'use32'; +DEFAULT : 'default'; +REL : 'rel'; +ABS : 'abs'; +BND : 'bnd'; +NOBND : 'nobnd'; +SECTIONS : 'sections'; +SECTION : 'section'; +SEGMENTS : 'segments'; +SEGMENT : 'segment'; +ABSOLUTE : 'absolute'; +EXTERN : 'extern'; +REQUIRED : 'required'; +GLOBAL : 'global'; +COMMON : 'common'; +NEAR : 'near'; +FAR : 'far'; +STATIC : 'static'; +CPU : 'cpu'; +FLOAT_NAME : 'float'; +DAZ : 'daz'; +NODAZ : 'nodaz'; +UP : 'up'; +DOWN : 'down'; +ZERO : 'zero'; +WARNING : 'warning'; +ORG : 'org'; +ALIGN : 'align'; +VSTART : 'vstart'; +START : 'start'; +PROGBITS : 'progbits'; +NOBITS : 'nobits'; +VFOLLOWS : 'vfollows'; +FOLLOWS : 'follows'; +MAP : 'map'; +ALL : 'all'; +BRIEF : 'brief'; +SYMBOLS : 'symbols'; +PRIVATE : 'private'; +PUBLIC : 'public'; +STACK : 'stack'; +CLASS_ : 'class'; +OVERLAY : 'overlay'; +FLAT : 'flat'; +GROUP : 'group'; +UPPERCASE : 'uppercase'; +IMPORT : 'import'; +EXPORT : 'export'; +RESIDENT : 'resident'; +NODATA : 'nodata'; +PARM : 'parm'; +CODE : 'code'; +TEXT : 'text'; +RDATA : 'rdata'; +DATA : 'data'; +BSS : 'bss'; +INFO : 'info'; +COMDAT : 'comdat'; +SAFESEH : 'safeseh'; +MIXED : 'mixed'; +ZEROFILL : 'zerofill'; +NO_DEAD_STRIP : 'no_dead_strip'; +LIVE_SUPPORT : 'live_support'; +STRIP_STATIC_SYMS : 'strip_static_syms'; +DEBUG : 'debug'; +OSABI : 'osabi'; +NOTE : 'note'; +PREINIT_ARRAY : 'preinit_array'; +INIT_ARRAY : 'init_array'; +FINI_ARRAY : 'fini_array'; +TLS : 'tls'; +POINTER : 'pointer'; +NOALLOC : 'noalloc'; +ALLOC : 'alloc'; +NOEXEC : 'noexec'; +EXEC : 'exec'; +NOWRITE : 'nowrite'; +WRITE : 'write'; +WRT : 'wrt'; +FUNCTION : 'function'; +OBJECT : 'object'; +WEAK : 'weak'; +STRONG : 'strong'; +INTERNAL : 'internal'; +HIDDEN_ : 'hidden'; +PROTECTED : 'protected'; +STRICT : 'strict'; +TIMES : 'times'; -DECIMAL_INTEGER - : [0-9][0-9_]* 'd'? - | '0d' [0-9][0-9_]* - ; +FLOAT_NUMBER: [0-9][0-9_]* '.' [0-9_]* 'e'? SIGN? [0-9_]+ | '0x1p+' [0-9]+; -SIGN - : PLUS | MINUS - ; +DECIMAL_INTEGER: [0-9][0-9_]* 'd'? | '0d' [0-9][0-9_]*; -OCT_INTEGER - : [0-7][0-7_]* ('q' | 'o') - | '0' [qo][0-7][0-7_]* - ; +SIGN: PLUS | MINUS; -HEX_INTEGER - : [0-9A-F][0-9A-F_]+ 'h' - | '$' [0-9A-F][0-9A-F_]* - | '0' [xh][0-9A-F][0-9A-F_]* - ; +OCT_INTEGER: [0-7][0-7_]* ('q' | 'o') | '0' [qo][0-7][0-7_]*; -BIN_INTEGER - : [01][01_]+ ('b' | 'y') - | '0' [by][01][01_]* - ; +HEX_INTEGER: [0-9A-F][0-9A-F_]+ 'h' | '$' [0-9A-F][0-9A-F_]* | '0' [xh][0-9A-F][0-9A-F_]*; -STRING - : STRING1 - | STRING2 - ; +BIN_INTEGER: [01][01_]+ ('b' | 'y') | '0' [by][01][01_]*; -STRING1 - : '"' ~'"'* '"' - ; +STRING: STRING1 | STRING2; -STRING2 - : '\u0027' ~'\u0027'* '\u0027' - ; +STRING1: '"' ~'"'* '"'; -WARNING_NAME - : NAME (MINUS NAME)+ - ; +STRING2: '\u0027' ~'\u0027'* '\u0027'; -NAME - : [a-z._?][a-z0-9_$#@~.?]* - ; +WARNING_NAME: NAME (MINUS NAME)+; -PREPROCESSOR_DIRECTIVES - : '%' ('define' | 'xdefine' | 'ixdefine' | 'undef' | 'assign' | 'iassign' | 'defstr' | 'deftok' | 'defalias' | 'undefalias' | 'strcat' | 'strlen' | 'substr' | 'include' | 'pathsearch' | 'depend' | 'use' | 'line' | 'clear') ~[\r\n]* - -> channel(HIDDEN) - ; +NAME: [a-z._?][a-z0-9_$#@~.?]*; -MULTILINE_MACRO - : '%macro' .*? '%endmacro' - -> channel(HIDDEN) - ; +PREPROCESSOR_DIRECTIVES: + '%' ( + 'define' + | 'xdefine' + | 'ixdefine' + | 'undef' + | 'assign' + | 'iassign' + | 'defstr' + | 'deftok' + | 'defalias' + | 'undefalias' + | 'strcat' + | 'strlen' + | 'substr' + | 'include' + | 'pathsearch' + | 'depend' + | 'use' + | 'line' + | 'clear' + ) ~[\r\n]* -> channel(HIDDEN) +; -COMMENT - : ';' ~[\r\n]* - -> channel(HIDDEN) - ; +MULTILINE_MACRO: '%macro' .*? '%endmacro' -> channel(HIDDEN); -EOL - : [\r\n] + - ; +COMMENT: ';' ~[\r\n]* -> channel(HIDDEN); -WHITESPACE - : [ \t] - -> channel(HIDDEN) - ; +EOL: [\r\n]+; +WHITESPACE: [ \t] -> channel(HIDDEN); \ No newline at end of file diff --git a/asm/nasm/nasm_x86_64_Parser.g4 b/asm/nasm/nasm_x86_64_Parser.g4 index 22bf50d9c4..f39f9ff10e 100644 --- a/asm/nasm/nasm_x86_64_Parser.g4 +++ b/asm/nasm/nasm_x86_64_Parser.g4 @@ -1,8 +1,11 @@ +// $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 nasm_x86_64_Parser; options { - caseInsensitive=true; - tokenVocab=nasm_x86_64_Lexer; + caseInsensitive = true; + tokenVocab = nasm_x86_64_Lexer; } program @@ -72,7 +75,10 @@ section ; section_params - : name attribute? section_type? class? overlay? designation? allocation? execution? writing? starting_possition? follow? (use16 | use32)? flat? (absolute_seg | alingment)? comdat? tls? + : name attribute? section_type? class? overlay? designation? allocation? execution? writing? starting_possition? follow? ( + use16 + | use32 + )? flat? (absolute_seg | alingment)? comdat? tls? ; name @@ -350,13 +356,13 @@ times : TIMES ; - pseudoinstruction - : name? ( dx value (COMMA value)* - | resx integer - | incbin atom (COMMA atom)* - | equ (integer | expression) - ) + : name? ( + dx value (COMMA value)* + | resx integer + | incbin atom (COMMA atom)* + | equ (integer | expression) + ) ; dx @@ -444,7 +450,10 @@ unaryExpression ; unaryOperator - : PLUS | MINUS | BITWISE_NOT | BOOLEAN_NOT + : PLUS + | MINUS + | BITWISE_NOT + | BOOLEAN_NOT ; castExpression @@ -459,7 +468,9 @@ castExpression ; multiplicativeExpression - : castExpression ((MULTIPLICATION | UNSIGNED_DIVISION | SIGNED_DIVISION | PERCENT | SIGNED_MODULE) castExpression)* + : castExpression ( + (MULTIPLICATION | UNSIGNED_DIVISION | SIGNED_DIVISION | PERCENT | SIGNED_MODULE) castExpression + )* ; additiveExpression @@ -467,11 +478,15 @@ additiveExpression ; shiftExpression - : additiveExpression ((LEFT_SHIFT | RIGHT_SHIFT | LEFT_SHIFT_COMPLETENESS | RIGHT_SHIFT_COMPLETENESS) additiveExpression)* + : additiveExpression ( + (LEFT_SHIFT | RIGHT_SHIFT | LEFT_SHIFT_COMPLETENESS | RIGHT_SHIFT_COMPLETENESS) additiveExpression + )* ; relationalExpression - : shiftExpression ((LESS_THAN | LESS_THAN_EQUAL | GREATER_THAN | GREATER_THAN | SIGNED_COMPARISON) shiftExpression)* + : shiftExpression ( + (LESS_THAN | LESS_THAN_EQUAL | GREATER_THAN | GREATER_THAN | SIGNED_COMPARISON) shiftExpression + )* ; equalityExpression @@ -510,30 +525,2494 @@ equ : EQU ; - instruction - : opcode operand? (COMMA operand)* + : opcode operand? (COMMA operand)* | macro_call ; -opcode: AAA | AAD | AAM | AAS | ADC | ADD | AND | ARPL | BB0_RESET | BB1_RESET | BOUND | BSF | BSR | BSWAP | BT | BTC | BTR | BTS | CALL | CBW | CDQ | CDQE | CLC | CLD | CLI | CLTS | CMC | CMOVA | CMOVAE | CMOVB | CMOVBE | CMOVC | CMOVE | CMOVGE | CMOVL | CMOVLE | CMOVNA | CMOVNAE | CMOVNB | CMOVNBE | CMOVNC | CMOVNE | CMOVNG | CMOVNGE | CMOVNL | CMOVNO | CMOVNP | CMOVNS | CMOVNZ | CMOVO | CMOVP | CMOVPE | CMOVPO | CMOVS | CMOVZ | CMP | CMPSB | CMPSD | CMPSQ | CMPSW | CMPXCHG | CMPXCHG16B | CMPXCHG486 | CMPXCHG8B | CPU_READ | CPU_WRITE | CPUID | CQO | CWD | CWDE | DAA | DAS | DEC | DIV | DMINT | EMMS | ENTER | EQU | F2XM1 | FABS | FADD | FADDP | FBLD | FBSTP | FCHS | FCLEX | FCMOVB | FCMOVBE | FCMOVE | FCMOVNB | FCMOVNBE | FCMOVNE | FCMOVNU | FCMOVU | FCOM | FCOMI | FCOMIP | FCOMP | FCOMPP | FCOS | FDECSTP | FDISI | FDIV | FDIVP | FDIVR | FDIVRP | FEMMS | FENI | FFREE | FFREEP | FIADD | FICOM | FICOMP | FIDIV | FIDIVR | FILD | FIMUL | FINCSTP | FINIT | FIST | FISTP | FISTTP | FISUB | FISUBR | FLD | FLD1 | FLDCW | FLDENV | FLDL2E | FLDL2T | FLDLG2 | FLDLN2 | FLDPI | FLDZ | FMUL | FMULP | FNCLEX | FNDISI | FNENI | FNINIT | FNOP | FNSAVE | FNSTCW | FNSTENV | FNSTSW | FPATAN | FPREM | FPREM1 | FPTAN | FRNDINT | FRSTOR | FSAVE | FSCALE | FSETPM | FSIN | FSINCOS | FSQRT | FST | FSTCW | FSTENV | FSTP | FSTSW | FSUB | FSUBP | FSUBR | FSUBRP | FTST | FUCOM | FUCOMI | FUCOMIP | FUCOMP | FUCOMPP | FWAIT | FXAM | FXCH | FXTRACT | FYL2X | FYL2XP1 | HLT | IBTS | ICEBP | IDIV | IMUL | IN | INC | INSB | INSD | INSW | INT | INT01 | INT03 | INT1 | INT3 | INTO | INVD | INVLPG | INVLPGA | INVPCID | IRET | IRETD | IRETQ | IRETW | JA | JAE | JB | JBE | JC | JCXZ | JE | JECXZ | JG | JGE | JL | JLE | JMP | JMPE | JNA | JNAE | JNB | JNBE | JNC | JNE | JNG | JNGE | JNL | JNLE | JNO | JNP | JNS | JNZ | JO | JP | JPE | JPO | JRCXZ | JS | JZ | LAHF | LAR | LDS | LEA | LEAVE | LES | LFENCE | LFS | LGDT | LGS | LIDT | LLDT | LMSW | LOADALL | LOADALL286 | LODSB | LODSD | LODSQ | LODSW | LOOP | LOOPE | LOOPNE | LOOPNZ | LOOPZ | LSL | LSS | LTR | MFENCE | MONITOR | MONITORX | MOV | MOVD | MOVQ | MOVSB | MOVSD | MOVSQ | MOVSW | MOVSX | MOVSXD | MOVZX | MUL | MWAIT | MWAITX | NEG | NOP | NOT | OR | OUT | OUTSB | OUTSD | OUTSW | PACKSSDW | PACKSSWB | PACKUSWB | PADDB | PADDD | PADDSB | PADDSIW | PADDSW | PADDUSB | PADDUSW | PADDW | PAND | PANDN | PAUSE | PAVEB | PAVGUSB | PCMPEQB | PCMPEQD | PCMPEQW | PCMPGTB | PCMPGTD | PCMPGTW | PDISTIB | PF2ID | PFACC | PFADD | PFCMPEQ | PFCMPGE | PFCMPGT | PFMAX | PFMIN | PFMUL | PFRCP | PFRCPIT1 | PFRCPIT2 | PFRSQIT1 | PFRSQRT | PFSUB | PFSUBR | PI2FD | PMACHRIW | PMADDWD | PMAGW | PMULHRIW | PMULHRWA | PMULHRWC | PMULHW | PMULLW | PMVGEZB | PMVLZB | PMVNZB | PMVZB | POP | POPA | POPAD | POPAW | POPF | POPFD | POPFQ | POPFW | POR | PREFETCH | PREFETCHW | PSLLD | PSLLQ | PSLLW | PSRAD | PSRAW | PSRLD | PSRLQ | PSRLW | PSUBB | PSUBD | PSUBSB | PSUBSIW | PSUBSW | PSUBUSB | PSUBUSW | PSUBW | PUNPCKHBW | PUNPCKHDQ | PUNPCKHWD | PUNPCKLBW | PUNPCKLDQ | PUNPCKLWD | PUSH | PUSHA | PUSHAD | PUSHAW | PUSHF | PUSHFD | PUSHFQ | PUSHFW | PXOR | RCL | RCR | RDM | RDMSR | RDPMC | RDSHR | RDTSC | RDTSCP | RET | RETD | RETF | RETFD | RETFQ | RETFW | RETN | RETND | RETNQ | RETNW | RETQ | RETW | ROL | ROR | RSDC | RSLDT | RSM | RSTS | SAHF | SAL | SALC | SAR | SBB | SCASB | SCASD | SCASQ | SCASW | SETA | SETAE | SETB | SETBE | SETC | SETE | SETG | SETGE | SETL | SETLE | SETNA | SETNAE | SETNB | SETNBE | SETNC | SETNE | SETNG | SETNGE | SETNL | SETNLE | SETNO | SETNP | SETNS | SETNZ | SETO | SETP | SETPE | SETPO | SETS | SETZ | SFENCE | SGDT | SHL | SHLD | SHR | SHRD | SIDT | SKINIT | SLDT | SMI | SMINT | SMINTOLD | SMSW | STC | STD | STI | STOSB | STOSD | STOSQ | STOSW | STR | SUB | SVDC | SVLDT | SVTS | SWAPGS | SYSCALL | SYSENTER | SYSEXIT | SYSRET | TEST | UD0 | UD1 | UD2 | UD2A | UD2B | UMOV | VERR | VERW | WBINVD | WRMSR | WRSHR | XADD | XBTS | XCHG | XLAT | XLATB | XOR | AADD | AAND | ADCX | ADDPD | ADDPS | ADDSD | ADDSS | ADDSUBPD | ADDSUBPS | ADOX | AESDEC | AESDECLAST | AESENC | AESENCLAST | AESIMC | AESKEYGENASSIST | ANDN | ANDNPD | ANDNPS | ANDPD | ANDPS | AXOR | BEXTR | BLCFILL | BLCI | BLCIC | BLCMSK | BLCS | BLENDPD | BLENDPS | BLENDVPD | BLENDVPS | BLSFILL | BLSI | BLSIC | BLSMSK | BLSR | BNDCL | BNDCN | BNDCU | BNDLDX | BNDMK | BNDMOV | BNDSTX | BZHI | CLAC | CLDEMOTE | CLFLUSH | CLFLUSHOPT | CLGI | CLRSSBSY | CLUI | CLWB | CLZERO | CMPEQPD | CMPEQPS | CMPEQSD | CMPEQSS | CMPLEPD | CMPLEPS | CMPLESD | CMPLESS | CMPLTPD | CMPLTPS | CMPLTSD | CMPLTSS | CMPNEQPD | CMPNEQPS | CMPNEQSD | CMPNEQSS | CMPNLEPD | CMPNLEPS | CMPNLESD | CMPNLESS | CMPNLTPD | CMPNLTPS | CMPNLTSD | CMPNLTSS | CMPNPXADD | CMPNSXADD | CMPNZXADD | CMPORDPD | CMPORDPS | CMPORDSD | CMPORDSS | CMPOXADD | CMPPD | CMPPS | CMPPXADD | CMPSS | CMPSXADD | CMPUNORDPD | CMPUNORDPS | CMPUNORDSD | CMPUNORDSS | CMPZXADD | COMISD | COMISS | CRC32 | CVTDQ2PD | CVTDQ2PS | CVTPD2DQ | CVTPD2PI | CVTPD2PS | CVTPI2PD | CVTPI2PS | CVTPS2DQ | CVTPS2PD | CVTPS2PI | CVTSD2SI | CVTSD2SS | CVTSI2SD | CVTSI2SS | CVTSS2SD | CVTSS2SI | CVTTPD2DQ | CVTTPD2PI | CVTTPS2DQ | CVTTPS2PI | CVTTSD2SI | CVTTSS2SI | DIVPD | DIVPS | DIVSD | DIVSS | DPPD | DPPS | ENCLS | ENCLU | ENCLV | ENDBR32 | ENDBR64 | ENQCMD | ENQCMDS | EXTRACTPS | EXTRQ | FXRSTOR | FXRSTOR64 | FXSAVE | FXSAVE64 | GETSEC | GF2P8AFFINEINVQB | GF2P8AFFINEQB | GF2P8MULB | HADDPD | HADDPS | HINT_NOP0 | HINT_NOP1 | HINT_NOP10 | HINT_NOP11 | HINT_NOP12 | HINT_NOP13 | HINT_NOP14 | HINT_NOP15 | HINT_NOP16 | HINT_NOP17 | HINT_NOP18 | HINT_NOP19 | HINT_NOP2 | HINT_NOP20 | HINT_NOP21 | HINT_NOP22 | HINT_NOP23 | HINT_NOP24 | HINT_NOP25 | HINT_NOP26 | HINT_NOP27 | HINT_NOP28 | HINT_NOP29 | HINT_NOP3 | HINT_NOP30 | HINT_NOP31 | HINT_NOP32 | HINT_NOP33 | HINT_NOP34 | HINT_NOP35 | HINT_NOP36 | HINT_NOP37 | HINT_NOP38 | HINT_NOP39 | HINT_NOP4 | HINT_NOP40 | HINT_NOP41 | HINT_NOP42 | HINT_NOP43 | HINT_NOP44 | HINT_NOP45 | HINT_NOP46 | HINT_NOP47 | HINT_NOP48 | HINT_NOP49 | HINT_NOP5 | HINT_NOP50 | HINT_NOP51 | HINT_NOP52 | HINT_NOP53 | HINT_NOP54 | HINT_NOP55 | HINT_NOP56 | HINT_NOP57 | HINT_NOP58 | HINT_NOP59 | HINT_NOP6 | HINT_NOP60 | HINT_NOP61 | HINT_NOP62 | HINT_NOP63 | HINT_NOP7 | HINT_NOP8 | HINT_NOP9 | HRESET | HSUBPD | HSUBPS | INCSSPD | INCSSPQ | INSERTPS | INSERTQ | INVEPT | INVVPID | KADD | KADDB | KADDD | KADDQ | KADDW | KAND | KANDB | KANDD | KANDN | KANDNB | KANDND | KANDNQ | KANDNW | KANDQ | KANDW | KMOV | KMOVB | KMOVD | KMOVQ | KMOVW | KNOT | KNOTB | KNOTD | KNOTQ | KNOTW | KOR | KORB | KORD | KORQ | KORTEST | KORTESTB | KORTESTD | KORTESTQ | KORTESTW | KORW | KSHIFTL | KSHIFTLB | KSHIFTLD | KSHIFTLQ | KSHIFTLW | KSHIFTR | KSHIFTRB | KSHIFTRD | KSHIFTRQ | KSHIFTRW | KTEST | KTESTB | KTESTD | KTESTQ | KTESTW | KUNPCK | KUNPCKBW | KUNPCKDQ | KUNPCKWD | KXNOR | KXNORB | KXNORD | KXNORQ | KXNORW | KXOR | KXORB | KXORD | KXORQ | KXORW | LDDQU | LDMXCSR | LDTILECFG | LLWPCB | LWPINS | LWPVAL | LZCNT | MASKMOVDQU | MASKMOVQ | MAXPD | MAXPS | MAXSD | MAXSS | MINPD | MINPS | MINSD | MINSS | MONTMUL | MOVAPD | MOVAPS | MOVBE | MOVDDUP | MOVDIR64B | MOVDIRI | MOVDQ2Q | MOVDQA | MOVDQU | MOVHLPS | MOVHPD | MOVHPS | MOVLHPS | MOVLPD | MOVLPS | MOVMSKPD | MOVMSKPS | MOVNTDQ | MOVNTDQA | MOVNTI | MOVNTPD | MOVNTPS | MOVNTQ | MOVNTSD | MOVNTSS | MOVQ2DQ | MOVSHDUP | MOVSLDUP | MOVSS | MOVUPD | MOVUPS | MPSADBW | MULPD | MULPS | MULSD | MULSS | MULX | ORPD | ORPS | PABSB | PABSD | PABSW | PACKUSDW | PADDQ | PALIGNR | PAVGB | PAVGW | PBLENDVB | PBLENDW | PCLMULHQHQDQ | PCLMULHQLQDQ | PCLMULLQHQDQ | PCLMULLQLQDQ | PCLMULQDQ | PCMPEQQ | PCMPESTRI | PCMPESTRM | PCMPGTQ | PCMPISTRI | PCMPISTRM | PCOMMIT | PCONFIG | PDEP | PEXT | PEXTRB | PEXTRD | PEXTRQ | PEXTRW | PF2IW | PFNACC | PFPNACC | PFRCPV | PFRSQRTV | PHADDD | PHADDSW | PHADDW | PHMINPOSUW | PHSUBD | PHSUBSW | PHSUBW | PI2FW | PINSRB | PINSRD | PINSRQ | PINSRW | PMADDUBSW | PMAXSB | PMAXSD | PMAXSW | PMAXUB | PMAXUD | PMAXUW | PMINSB | PMINSD | PMINSW | PMINUB | PMINUD | PMINUW | PMOVMSKB | PMOVSXBD | PMOVSXBQ | PMOVSXBW | PMOVSXDQ | PMOVSXWD | PMOVSXWQ | PMOVZXBD | PMOVZXBQ | PMOVZXBW | PMOVZXDQ | PMOVZXWD | PMOVZXWQ | PMULDQ | PMULHRSW | PMULHUW | PMULLD | PMULUDQ | POPCNT | PREFETCHIT0 | PREFETCHIT1 | PREFETCHNTA | PREFETCHT0 | PREFETCHT1 | PREFETCHT2 | PREFETCHWT1 | PSADBW | PSHUFB | PSHUFD | PSHUFHW | PSHUFLW | PSHUFW | PSIGNB | PSIGND | PSIGNW | PSLLDQ | PSRLDQ | PSUBQ | PSWAPD | PTEST | PTWRITE | PUNPCKHQDQ | PUNPCKLQDQ | PVALIDATE | RCPPS | RCPSS | RDFSBASE | RDGSBASE | RDMSRLIST | RDPID | RDPKRU | RDRAND | RDSEED | RDSSPD | RDSSPQ | RMPADJUST | RORX | ROUNDPD | ROUNDPS | ROUNDSD | ROUNDSS | RSQRTPS | RSQRTSS | RSTORSSP | SARX | SAVEPREVSSP | SENDUIPI | SERIALIZE | SETSSBSY | SHA1MSG1 | SHA1MSG2 | SHA1NEXTE | SHA1RNDS4 | SHA256MSG1 | SHA256MSG2 | SHA256RNDS2 | SHLX | SHRX | SHUFPD | SHUFPS | SLWPCB | SQRTPD | SQRTPS | SQRTSD | SQRTSS | STAC | STGI | STMXCSR | STTILECFG | STUI | SUBPD | SUBPS | SUBSD | SUBSS | T1MSKC | TDPBF16PS | TDPBSSD | TDPBSUD | TDPBUSD | TDPBUUD | TESTUI | TILELOADD | TILELOADDT1 | TILERELEASE | TILESTORED | TILEZERO | TPAUSE | TZCNT | TZMSK | UCOMISD | UCOMISS | UIRET | UMONITOR | UMWAIT | UNPCKHPD | UNPCKHPS | UNPCKLPD | UNPCKLPS | V4DPWSSD | V4DPWSSDS | V4FMADDPS | V4FMADDSS | V4FNMADDPS | V4FNMADDSS | VADDPD | VADDPH | VADDPS | VADDSD | VADDSH | VADDSS | VADDSUBPD | VADDSUBPS | VAESDEC | VAESDECLAST | VAESENC | VAESENCLAST | VAESIMC | VAESKEYGENASSIST | VALIGND | VALIGNQ | VANDNPD | VANDNPS | VANDPD | VANDPS | VBCSTNEBF16PS | VBCSTNESH2PS | VBLENDMPD | VBLENDMPS | VBLENDPD | VBLENDPS | VBLENDVPD | VBLENDVPS | VBROADCASTF128 | VBROADCASTF32X2 | VBROADCASTF32X4 | VBROADCASTF32X8 | VBROADCASTF64X2 | VBROADCASTF64X4 | VBROADCASTI128 | VBROADCASTI32X2 | VBROADCASTI32X4 | VBROADCASTI32X8 | VBROADCASTI64X2 | VBROADCASTI64X4 | VBROADCASTSD | VBROADCASTSS | VCMPEQ_OQPD | VCMPEQ_OQPS | VCMPEQ_OQSD | VCMPEQ_OQSS | VCMPEQ_OSPD | VCMPEQ_OSPS | VCMPEQ_OSSD | VCMPEQ_OSSS | VCMPEQ_UQPD | VCMPEQ_UQPS | VCMPEQ_UQSD | VCMPEQ_UQSS | VCMPEQ_USPD | VCMPEQ_USPS | VCMPEQ_USSD | VCMPEQ_USSS | VCMPEQPD | VCMPEQPS | VCMPEQSD | VCMPEQSS | VCMPFALSE_OQPD | VCMPFALSE_OQPS | VCMPFALSE_OQSD | VCMPFALSE_OQSS | VCMPFALSE_OSPD | VCMPFALSE_OSPS | VCMPFALSE_OSSD | VCMPFALSE_OSSS | VCMPFALSEPD | VCMPFALSEPS | VCMPFALSESD | VCMPFALSESS | VCMPGE_OQPD | VCMPGE_OQPS | VCMPGE_OQSD | VCMPGE_OQSS | VCMPGE_OSPD | VCMPGE_OSPS | VCMPGE_OSSD | VCMPGE_OSSS | VCMPGEPD | VCMPGEPS | VCMPGESD | VCMPGESS | VCMPGT_OQPD | VCMPGT_OQPS | VCMPGT_OQSD | VCMPGT_OQSS | VCMPGT_OSPD | VCMPGT_OSPS | VCMPGT_OSSD | VCMPGT_OSSS | VCMPGTPD | VCMPGTPS | VCMPGTSD | VCMPGTSS | VCMPLE_OQPD | VCMPLE_OQPS | VCMPLE_OQSD | VCMPLE_OQSS | VCMPLE_OSPD | VCMPLE_OSPS | VCMPLE_OSSD | VCMPLE_OSSS | VCMPLEPD | VCMPLEPS | VCMPLESD | VCMPLESS | VCMPLT_OQPD | VCMPLT_OQPS | VCMPLT_OQSD | VCMPLT_OQSS | VCMPLT_OSPD | VCMPLT_OSPS | VCMPLT_OSSD | VCMPLT_OSSS | VCMPLTPD | VCMPLTPS | VCMPLTSD | VCMPLTSS | VCMPNEQ_OQPD | VCMPNEQ_OQPS | VCMPNEQ_OQSD | VCMPNEQ_OQSS | VCMPNEQ_OSPD | VCMPNEQ_OSPS | VCMPNEQ_OSSD | VCMPNEQ_OSSS | VCMPNEQ_UQPD | VCMPNEQ_UQPS | VCMPNEQ_UQSD | VCMPNEQ_UQSS | VCMPNEQ_USPD | VCMPNEQ_USPS | VCMPNEQ_USSD | VCMPNEQ_USSS | VCMPNEQPD | VCMPNEQPS | VCMPNEQSD | VCMPNEQSS | VCMPNGE_UQPD | VCMPNGE_UQPS | VCMPNGE_UQSD | VCMPNGE_UQSS | VCMPNGE_USPD | VCMPNGE_USPS | VCMPNGE_USSD | VCMPNGE_USSS | VCMPNGEPD | VCMPNGEPS | VCMPNGESD | VCMPNGESS | VCMPNGT_UQPD | VCMPNGT_UQPS | VCMPNGT_UQSD | VCMPNGT_UQSS | VCMPNGT_USPD | VCMPNGT_USPS | VCMPNGT_USSD | VCMPNGT_USSS | VCMPNGTPD | VCMPNGTPS | VCMPNGTSD | VCMPNGTSS | VCMPNLE_UQPD | VCMPNLE_UQPS | VCMPNLE_UQSD | VCMPNLE_UQSS | VCMPNLE_USPD | VCMPNLE_USPS | VCMPNLE_USSD | VCMPNLE_USSS | VCMPNLEPD | VCMPNLEPS | VCMPNLESD | VCMPNLESS | VCMPNLT_UQPD | VCMPNLT_UQPS | VCMPNLT_UQSD | VCMPNLT_UQSS | VCMPNLT_USPD | VCMPNLT_USPS | VCMPNLT_USSD | VCMPNLT_USSS | VCMPNLTPD | VCMPNLTPS | VCMPNLTSD | VCMPNLTSS | VCMPORD_QPD | VCMPORD_QPS | VCMPORD_QSD | VCMPORD_QSS | VCMPORD_SPD | VCMPORD_SPS | VCMPORD_SSD | VCMPORD_SSS | VCMPORDPD | VCMPORDPS | VCMPORDSD | VCMPORDSS | VCMPPD | VCMPPH | VCMPPS | VCMPSD | VCMPSH | VCMPSS | VCMPTRUE_UQPD | VCMPTRUE_UQPS | VCMPTRUE_UQSD | VCMPTRUE_UQSS | VCMPTRUE_USPD | VCMPTRUE_USPS | VCMPTRUE_USSD | VCMPTRUE_USSS | VCMPTRUEPD | VCMPTRUEPS | VCMPTRUESD | VCMPTRUESS | VCMPUNORD_QPD | VCMPUNORD_QPS | VCMPUNORD_QSD | VCMPUNORD_QSS | VCMPUNORD_SPD | VCMPUNORD_SPS | VCMPUNORD_SSD | VCMPUNORD_SSS | VCMPUNORDPD | VCMPUNORDPS | VCMPUNORDSD | VCMPUNORDSS | VCOMISD | VCOMISH | VCOMISS | VCOMPRESSPD | VCOMPRESSPS | VCVTDQ2PD | VCVTDQ2PH | VCVTDQ2PS | VCVTNE2PS2BF16 | VCVTNEEBF162PS | VCVTNEEPH2PS | VCVTNEOBF162PS | VCVTNEOPH2PS | VCVTNEPS2BF16 | VCVTPD2DQ | VCVTPD2PH | VCVTPD2PS | VCVTPD2QQ | VCVTPD2UDQ | VCVTPD2UQQ | VCVTPH2DQ | VCVTPH2PD | VCVTPH2PS | VCVTPH2PSX | VCVTPH2QQ | VCVTPH2UDQ | VCVTPH2UQQ | VCVTPH2UW | VCVTPH2W | VCVTPS2DQ | VCVTPS2PD | VCVTPS2PH | VCVTPS2QQ | VCVTPS2UDQ | VCVTPS2UQQ | VCVTQQ2PD | VCVTQQ2PH | VCVTQQ2PS | VCVTSD2SH | VCVTSD2SI | VCVTSD2SS | VCVTSD2USI | VCVTSH2SD | VCVTSH2SI | VCVTSH2SS | VCVTSH2USI | VCVTSI2SD | VCVTSI2SH | VCVTSI2SS | VCVTSS2SD | VCVTSS2SH | VCVTSS2SI | VCVTSS2USI | VCVTTPD2DQ | VCVTTPD2QQ | VCVTTPD2UDQ | VCVTTPD2UQQ | VCVTTPH2DQ | VCVTTPH2QQ | VCVTTPH2UDQ | VCVTTPH2UQQ | VCVTTPH2UW | VCVTTPH2W | VCVTTPS2DQ | VCVTTPS2QQ | VCVTTPS2UDQ | VCVTTPS2UQQ | VCVTTSD2SI | VCVTTSD2USI | VCVTTSH2SI | VCVTTSH2USI | VCVTTSS2SI | VCVTTSS2USI | VCVTUDQ2PD | VCVTUDQ2PH | VCVTUDQ2PS | VCVTUQQ2PD | VCVTUQQ2PH | VCVTUQQ2PS | VCVTUSI2SD | VCVTUSI2SH | VCVTUSI2SS | VCVTUW2PH | VCVTW2PH | VDBPSADBW | VDIVPD | VDIVPH | VDIVPS | VDIVSD | VDIVSH | VDIVSS | VDPBF16PS | VDPPD | VDPPS | VENDSCALEPH | VENDSCALESH | VEXP2PD | VEXP2PS | VEXPANDPD | VEXPANDPS | VEXTRACTF128 | VEXTRACTF32X4 | VEXTRACTF32X8 | VEXTRACTF64X2 | VEXTRACTF64X4 | VEXTRACTI128 | VEXTRACTI32X4 | VEXTRACTI32X8 | VEXTRACTI64X2 | VEXTRACTI64X4 | VEXTRACTPS | VFCMADDCPH | VFCMADDCSH | VFCMULCPCH | VFCMULCSH | VFIXUPIMMPD | VFIXUPIMMPS | VFIXUPIMMSD | VFIXUPIMMSS | VFMADD123PD | VFMADD123PS | VFMADD123SD | VFMADD123SS | VFMADD132PD | VFMADD132PH | VFMADD132PS | VFMADD132SD | VFMADD132SS | VFMADD213PD | VFMADD213PH | VFMADD213PS | VFMADD213SD | VFMADD213SS | VFMADD231PD | VFMADD231PH | VFMADD231PS | VFMADD231SD | VFMADD231SS | VFMADD312PD | VFMADD312PS | VFMADD312SD | VFMADD312SS | VFMADD321PD | VFMADD321PS | VFMADD321SD | VFMADD321SS | VFMADDCPH | VFMADDCSH | VFMADDPD | VFMADDPS | VFMADDSD | VFMADDSS | VFMADDSUB123PD | VFMADDSUB123PS | VFMADDSUB132PD | VFMADDSUB132PH | VFMADDSUB132PS | VFMADDSUB213PD | VFMADDSUB213PH | VFMADDSUB213PS | VFMADDSUB231PD | VFMADDSUB231PH | VFMADDSUB231PS | VFMADDSUB312PD | VFMADDSUB312PS | VFMADDSUB321PD | VFMADDSUB321PS | VFMADDSUBPD | VFMADDSUBPS | VFMSUB123PD | VFMSUB123PS | VFMSUB123SD | VFMSUB123SS | VFMSUB132PD | VFMSUB132PH | VFMSUB132PS | VFMSUB132SD | VFMSUB132SS | VFMSUB213PD | VFMSUB213PH | VFMSUB213PS | VFMSUB213SD | VFMSUB213SS | VFMSUB231PD | VFMSUB231PH | VFMSUB231PS | VFMSUB231SD | VFMSUB231SS | VFMSUB312PD | VFMSUB312PS | VFMSUB312SD | VFMSUB312SS | VFMSUB321PD | VFMSUB321PS | VFMSUB321SD | VFMSUB321SS | VFMSUBADD123PD | VFMSUBADD123PS | VFMSUBADD132PD | VFMSUBADD132PH | VFMSUBADD132PS | VFMSUBADD213PD | VFMSUBADD213PH | VFMSUBADD213PS | VFMSUBADD231PD | VFMSUBADD231PH | VFMSUBADD231PS | VFMSUBADD312PD | VFMSUBADD312PS | VFMSUBADD321PD | VFMSUBADD321PS | VFMSUBADDPD | VFMSUBADDPS | VFMSUBPD | VFMSUBPS | VFMSUBSD | VFMSUBSS | VFMULCPCH | VFMULCSH | VFNMADD123PD | VFNMADD123PS | VFNMADD123SD | VFNMADD123SS | VFNMADD132PD | VFNMADD132PS | VFNMADD132SD | VFNMADD132SS | VFNMADD213PD | VFNMADD213PS | VFNMADD213SD | VFNMADD213SS | VFNMADD231PD | VFNMADD231PS | VFNMADD231SD | VFNMADD231SS | VFNMADD312PD | VFNMADD312PS | VFNMADD312SD | VFNMADD312SS | VFNMADD321PD | VFNMADD321PS | VFNMADD321SD | VFNMADD321SS | VFNMADDPD | VFNMADDPS | VFNMADDSD | VFNMADDSS | VFNMSUB123PD | VFNMSUB123PS | VFNMSUB123SD | VFNMSUB123SS | VFNMSUB132PD | VFNMSUB132PS | VFNMSUB132SD | VFNMSUB132SS | VFNMSUB213PD | VFNMSUB213PS | VFNMSUB213SD | VFNMSUB213SS | VFNMSUB231PD | VFNMSUB231PS | VFNMSUB231SD | VFNMSUB231SS | VFNMSUB312PD | VFNMSUB312PS | VFNMSUB312SD | VFNMSUB312SS | VFNMSUB321PD | VFNMSUB321PS | VFNMSUB321SD | VFNMSUB321SS | VFNMSUBPD | VFNMSUBPS | VFNMSUBSD | VFNMSUBSS | VFPCLASSPD | VFPCLASSPH | VFPCLASSPS | VFPCLASSSD | VFPCLASSSH | VFPCLASSSS | VFRCZPD | VFRCZPS | VFRCZSD | VFRCZSS | VGATHERDPD | VGATHERDPS | VGATHERPF0DPD | VGATHERPF0DPS | VGATHERPF0QPD | VGATHERPF0QPS | VGATHERPF1DPD | VGATHERPF1DPS | VGATHERPF1QPD | VGATHERPF1QPS | VGATHERQPD | VGATHERQPS | VGETEXPPD | VGETEXPPH | VGETEXPPS | VGETEXPSD | VGETEXPSH | VGETEXPSS | VGETMANTPD | VGETMANTPH | VGETMANTPS | VGETMANTSD | VGETMANTSH | VGETMANTSS | VGETMAXPH | VGETMAXSH | VGETMINPH | VGETMINSH | VGF2P8AFFINEINVQB | VGF2P8AFFINEQB | VGF2P8MULB | VHADDPD | VHADDPS | VHSUBPD | VHSUBPS | VINSERTF128 | VINSERTF32X4 | VINSERTF32X8 | VINSERTF64X2 | VINSERTF64X4 | VINSERTI128 | VINSERTI32X4 | VINSERTI32X8 | VINSERTI64X2 | VINSERTI64X4 | VINSERTPS | VLDDQU | VLDMXCSR | VLDQQU | VMASKMOVDQU | VMASKMOVPD | VMASKMOVPS | VMAXPD | VMAXPS | VMAXSD | VMAXSS | VMCALL | VMCLEAR | VMFUNC | VMGEXIT | VMINPD | VMINPS | VMINSD | VMINSS | VMLAUNCH | VMLOAD | VMMCALL | VMOVAPD | VMOVAPS | VMOVD | VMOVDDUP | VMOVDQA | VMOVDQA32 | VMOVDQA64 | VMOVDQU | VMOVDQU16 | VMOVDQU32 | VMOVDQU64 | VMOVDQU8 | VMOVHLPS | VMOVHPD | VMOVHPS | VMOVLHPS | VMOVLPD | VMOVLPS | VMOVMSKPD | VMOVMSKPS | VMOVNTDQ | VMOVNTDQA | VMOVNTPD | VMOVNTPS | VMOVNTQQ | VMOVQ | VMOVQQA | VMOVQQU | VMOVSD | VMOVSH | VMOVSHDUP | VMOVSLDUP | VMOVSS | VMOVUPD | VMOVUPS | VMOVW | VMPSADBW | VMPTRLD | VMPTRST | VMREAD | VMRESUME | VMRUN | VMSAVE | VMULPD | VMULPH | VMULPS | VMULSD | VMULSH | VMULSS | VMWRITE | VMXOFF | VMXON | VORPD | VORPS | VP2INTERSECTD | VPABSB | VPABSD | VPABSQ | VPABSW | VPACKSSDW | VPACKSSWB | VPACKUSDW | VPACKUSWB | VPADDB | VPADDD | VPADDQ | VPADDSB | VPADDSW | VPADDUSB | VPADDUSW | VPADDW | VPALIGNR | VPAND | VPANDD | VPANDN | VPANDND | VPANDNQ | VPANDQ | VPAVGB | VPAVGW | VPBLENDD | VPBLENDMB | VPBLENDMD | VPBLENDMQ | VPBLENDMW | VPBLENDVB | VPBLENDW | VPBROADCASTB | VPBROADCASTD | VPBROADCASTMB2Q | VPBROADCASTMW2D | VPBROADCASTQ | VPBROADCASTW | VPCLMULHQHQDQ | VPCLMULHQLQDQ | VPCLMULLQHQDQ | VPCLMULLQLQDQ | VPCLMULQDQ | VPCMOV | VPCMPB | VPCMPD | VPCMPEQB | VPCMPEQD | VPCMPEQQ | VPCMPEQUB | VPCMPEQUD | VPCMPEQUQ | VPCMPEQUW | VPCMPEQW | VPCMPESTRI | VPCMPESTRM | VPCMPGEB | VPCMPGED | VPCMPGEQ | VPCMPGEUB | VPCMPGEUD | VPCMPGEUQ | VPCMPGEUW | VPCMPGEW | VPCMPGTB | VPCMPGTD | VPCMPGTQ | VPCMPGTUB | VPCMPGTUD | VPCMPGTUQ | VPCMPGTUW | VPCMPGTW | VPCMPISTRI | VPCMPISTRM | VPCMPLEB | VPCMPLED | VPCMPLEQ | VPCMPLEUB | VPCMPLEUD | VPCMPLEUQ | VPCMPLEUW | VPCMPLEW | VPCMPLTB | VPCMPLTD | VPCMPLTQ | VPCMPLTUB | VPCMPLTUD | VPCMPLTUQ | VPCMPLTUW | VPCMPLTW | VPCMPNEQB | VPCMPNEQD | VPCMPNEQQ | VPCMPNEQUB | VPCMPNEQUD | VPCMPNEQUQ | VPCMPNEQUW | VPCMPNEQW | VPCMPNGTB | VPCMPNGTD | VPCMPNGTQ | VPCMPNGTUB | VPCMPNGTUD | VPCMPNGTUQ | VPCMPNGTUW | VPCMPNGTW | VPCMPNLEB | VPCMPNLED | VPCMPNLEQ | VPCMPNLEUB | VPCMPNLEUD | VPCMPNLEUQ | VPCMPNLEUW | VPCMPNLEW | VPCMPNLTB | VPCMPNLTD | VPCMPNLTQ | VPCMPNLTUB | VPCMPNLTUD | VPCMPNLTUQ | VPCMPNLTUW | VPCMPNLTW | VPCMPQ | VPCMPUB | VPCMPUD | VPCMPUQ | VPCMPUW | VPCMPW | VPCOMB | VPCOMD | VPCOMPRESSB | VPCOMPRESSD | VPCOMPRESSQ | VPCOMPRESSW | VPCOMQ | VPCOMUB | VPCOMUD | VPCOMUQ | VPCOMUW | VPCOMW | VPCONFLICTD | VPCONFLICTQ | VPDPBSSD | VPDPBSSDS | VPDPBSUD | VPDPBSUDS | VPDPBUSD | VPDPBUSDS | VPDPBUUD | VPDPBUUDS | VPDPWSSD | VPDPWSSDS | VPERM2F128 | VPERM2I128 | VPERMB | VPERMD | VPERMI2B | VPERMI2D | VPERMI2PD | VPERMI2PS | VPERMI2Q | VPERMI2W | VPERMILPD | VPERMILPS | VPERMPD | VPERMPS | VPERMQ | VPERMT2B | VPERMT2D | VPERMT2PD | VPERMT2PS | VPERMT2Q | VPERMT2W | VPERMW | VPEXPANDB | VPEXPANDD | VPEXPANDQ | VPEXPANDW | VPEXTRB | VPEXTRD | VPEXTRQ | VPEXTRW | VPGATHERDD | VPGATHERDQ | VPGATHERQD | VPGATHERQQ | VPHADDBD | VPHADDBQ | VPHADDBW | VPHADDD | VPHADDDQ | VPHADDSW | VPHADDUBD | VPHADDUBQ | VPHADDUBW | VPHADDUDQ | VPHADDUWD | VPHADDUWQ | VPHADDW | VPHADDWD | VPHADDWQ | VPHMINPOSUW | VPHSUBBW | VPHSUBD | VPHSUBDQ | VPHSUBSW | VPHSUBW | VPHSUBWD | VPINSRB | VPINSRD | VPINSRQ | VPINSRW | VPLZCNTD | VPLZCNTQ | VPMACSDD | VPMACSDQH | VPMACSDQL | VPMACSSDD | VPMACSSDQH | VPMACSSDQL | VPMACSSWD | VPMACSSWW | VPMACSWD | VPMACSWW | VPMADCSSWD | VPMADCSWD | VPMADD132PH | VPMADD132SH | VPMADD213PH | VPMADD213SH | VPMADD231PH | VPMADD231SH | VPMADD52HUQ | VPMADD52LUQ | VPMADDUBSW | VPMADDWD | VPMASKMOVD | VPMASKMOVQ | VPMAXSB | VPMAXSD | VPMAXSQ | VPMAXSW | VPMAXUB | VPMAXUD | VPMAXUQ | VPMAXUW | VPMINSB | VPMINSD | VPMINSQ | VPMINSW | VPMINUB | VPMINUD | VPMINUQ | VPMINUW | VPMOVB2M | VPMOVD2M | VPMOVDB | VPMOVDW | VPMOVM2B | VPMOVM2D | VPMOVM2Q | VPMOVM2W | VPMOVMSKB | VPMOVQ2M | VPMOVQB | VPMOVQD | VPMOVQW | VPMOVSDB | VPMOVSDW | VPMOVSQB | VPMOVSQD | VPMOVSQW | VPMOVSWB | VPMOVSXBD | VPMOVSXBQ | VPMOVSXBW | VPMOVSXDQ | VPMOVSXWD | VPMOVSXWQ | VPMOVUSDB | VPMOVUSDW | VPMOVUSQB | VPMOVUSQD | VPMOVUSQW | VPMOVUSWB | VPMOVW2M | VPMOVWB | VPMOVZXBD | VPMOVZXBQ | VPMOVZXBW | VPMOVZXDQ | VPMOVZXWD | VPMOVZXWQ | VPMSUB132PH | VPMSUB132SH | VPMSUB213PH | VPMSUB213SH | VPMSUB231PH | VPMSUB231SH | VPMULDQ | VPMULHRSW | VPMULHUW | VPMULHW | VPMULLD | VPMULLQ | VPMULLW | VPMULTISHIFTQB | VPMULUDQ | VPNMADD132SH | VPNMADD213SH | VPNMADD231SH | VPNMSUB132SH | VPNMSUB213SH | VPNMSUB231SH | VPOPCNTB | VPOPCNTD | VPOPCNTQ | VPOPCNTW | VPOR | VPORD | VPORQ | VPPERM | VPROLD | VPROLQ | VPROLVD | VPROLVQ | VPRORD | VPRORQ | VPRORVD | VPRORVQ | VPROTB | VPROTD | VPROTQ | VPROTW | VPSADBW | VPSCATTERDD | VPSCATTERDQ | VPSCATTERQD | VPSCATTERQQ | VPSHAB | VPSHAD | VPSHAQ | VPSHAW | VPSHLB | VPSHLD | VPSHLDD | VPSHLDQ | VPSHLDVD | VPSHLDVQ | VPSHLDVW | VPSHLDW | VPSHLQ | VPSHLW | VPSHRDD | VPSHRDQ | VPSHRDVD | VPSHRDVQ | VPSHRDVW | VPSHRDW | VPSHUFB | VPSHUFBITQMB | VPSHUFD | VPSHUFHW | VPSHUFLW | VPSIGNB | VPSIGND | VPSIGNW | VPSLLD | VPSLLDQ | VPSLLQ | VPSLLVD | VPSLLVQ | VPSLLVW | VPSLLW | VPSRAD | VPSRAQ | VPSRAVD | VPSRAVQ | VPSRAVW | VPSRAW | VPSRLD | VPSRLDQ | VPSRLQ | VPSRLVD | VPSRLVQ | VPSRLVW | VPSRLW | VPSUBB | VPSUBD | VPSUBQ | VPSUBSB | VPSUBSW | VPSUBUSB | VPSUBUSW | VPSUBW | VPTERNLOGD | VPTERNLOGQ | VPTEST | VPTESTMB | VPTESTMD | VPTESTMQ | VPTESTMW | VPTESTNMB | VPTESTNMD | VPTESTNMQ | VPTESTNMW | VPUNPCKHBW | VPUNPCKHDQ | VPUNPCKHQDQ | VPUNPCKHWD | VPUNPCKLBW | VPUNPCKLDQ | VPUNPCKLQDQ | VPUNPCKLWD | VPXOR | VPXORD | VPXORQ | VRANGEPD | VRANGEPS | VRANGESD | VRANGESS | VRCP14PD | VRCP14PS | VRCP14SD | VRCP14SS | VRCP28PD | VRCP28PS | VRCP28SD | VRCP28SS | VRCPPH | VRCPPS | VRCPSH | VRCPSS | VREDUCEPD | VREDUCEPH | VREDUCEPS | VREDUCESD | VREDUCESH | VREDUCESS | VRNDSCALEPD | VRNDSCALEPS | VRNDSCALESD | VRNDSCALESS | VROUNDPD | VROUNDPS | VROUNDSD | VROUNDSS | VRSQRT14PD | VRSQRT14PS | VRSQRT14SD | VRSQRT14SS | VRSQRT28PD | VRSQRT28PS | VRSQRT28SD | VRSQRT28SS | VRSQRTPH | VRSQRTPS | VRSQRTSH | VRSQRTSS | VSCALEFPD | VSCALEFPH | VSCALEFPS | VSCALEFSD | VSCALEFSH | VSCALEFSS | VSCATTERDPD | VSCATTERDPS | VSCATTERPF0DPD | VSCATTERPF0DPS | VSCATTERPF0QPD | VSCATTERPF0QPS | VSCATTERPF1DPD | VSCATTERPF1DPS | VSCATTERPF1QPD | VSCATTERPF1QPS | VSCATTERQPD | VSCATTERQPS | VSHUFF32X4 | VSHUFF64X2 | VSHUFI32X4 | VSHUFI64X2 | VSHUFPD | VSHUFPS | VSQRTPD | VSQRTPH | VSQRTPS | VSQRTSD | VSQRTSH | VSQRTSS | VSTMXCSR | VSUBPD | VSUBPH | VSUBPS | VSUBSD | VSUBSH | VSUBSS | VTESTPD | VTESTPS | VUCOMISD | VUCOMISH | VUCOMISS | VUNPCKHPD | VUNPCKHPS | VUNPCKLPD | VUNPCKLPS | VXORPD | VXORPS | VZEROALL | VZEROUPPER | WBNOINVD | WRFSBASE | WRGSBASE | WRMSRLIST | WRMSRNS | WRPKRU | WRSSD | WRSSQ | WRUSSD | WRUSSQ | XABORT | XBEGIN | XCRYPTCBC | XCRYPTCFB | XCRYPTCTR | XCRYPTECB | XCRYPTOFB | XEND | XGETBV | XORPD | XORPS | XRESLDTRK | XRSTOR | XRSTOR64 | XRSTORS | XRSTORS64 | XSAVE | XSAVE64 | XSAVEC | XSAVEC64 | XSAVEOPT | XSAVEOPT64 | XSAVES | XSAVES64 | XSETBV | XSHA1 | XSHA256 | XSTORE | XSUSLDTRK | XTEST; +opcode + : AAA + | AAD + | AAM + | AAS + | ADC + | ADD + | AND + | ARPL + | BB0_RESET + | BB1_RESET + | BOUND + | BSF + | BSR + | BSWAP + | BT + | BTC + | BTR + | BTS + | CALL + | CBW + | CDQ + | CDQE + | CLC + | CLD + | CLI + | CLTS + | CMC + | CMOVA + | CMOVAE + | CMOVB + | CMOVBE + | CMOVC + | CMOVE + | CMOVGE + | CMOVL + | CMOVLE + | CMOVNA + | CMOVNAE + | CMOVNB + | CMOVNBE + | CMOVNC + | CMOVNE + | CMOVNG + | CMOVNGE + | CMOVNL + | CMOVNO + | CMOVNP + | CMOVNS + | CMOVNZ + | CMOVO + | CMOVP + | CMOVPE + | CMOVPO + | CMOVS + | CMOVZ + | CMP + | CMPSB + | CMPSD + | CMPSQ + | CMPSW + | CMPXCHG + | CMPXCHG16B + | CMPXCHG486 + | CMPXCHG8B + | CPU_READ + | CPU_WRITE + | CPUID + | CQO + | CWD + | CWDE + | DAA + | DAS + | DEC + | DIV + | DMINT + | EMMS + | ENTER + | EQU + | F2XM1 + | FABS + | FADD + | FADDP + | FBLD + | FBSTP + | FCHS + | FCLEX + | FCMOVB + | FCMOVBE + | FCMOVE + | FCMOVNB + | FCMOVNBE + | FCMOVNE + | FCMOVNU + | FCMOVU + | FCOM + | FCOMI + | FCOMIP + | FCOMP + | FCOMPP + | FCOS + | FDECSTP + | FDISI + | FDIV + | FDIVP + | FDIVR + | FDIVRP + | FEMMS + | FENI + | FFREE + | FFREEP + | FIADD + | FICOM + | FICOMP + | FIDIV + | FIDIVR + | FILD + | FIMUL + | FINCSTP + | FINIT + | FIST + | FISTP + | FISTTP + | FISUB + | FISUBR + | FLD + | FLD1 + | FLDCW + | FLDENV + | FLDL2E + | FLDL2T + | FLDLG2 + | FLDLN2 + | FLDPI + | FLDZ + | FMUL + | FMULP + | FNCLEX + | FNDISI + | FNENI + | FNINIT + | FNOP + | FNSAVE + | FNSTCW + | FNSTENV + | FNSTSW + | FPATAN + | FPREM + | FPREM1 + | FPTAN + | FRNDINT + | FRSTOR + | FSAVE + | FSCALE + | FSETPM + | FSIN + | FSINCOS + | FSQRT + | FST + | FSTCW + | FSTENV + | FSTP + | FSTSW + | FSUB + | FSUBP + | FSUBR + | FSUBRP + | FTST + | FUCOM + | FUCOMI + | FUCOMIP + | FUCOMP + | FUCOMPP + | FWAIT + | FXAM + | FXCH + | FXTRACT + | FYL2X + | FYL2XP1 + | HLT + | IBTS + | ICEBP + | IDIV + | IMUL + | IN + | INC + | INSB + | INSD + | INSW + | INT + | INT01 + | INT03 + | INT1 + | INT3 + | INTO + | INVD + | INVLPG + | INVLPGA + | INVPCID + | IRET + | IRETD + | IRETQ + | IRETW + | JA + | JAE + | JB + | JBE + | JC + | JCXZ + | JE + | JECXZ + | JG + | JGE + | JL + | JLE + | JMP + | JMPE + | JNA + | JNAE + | JNB + | JNBE + | JNC + | JNE + | JNG + | JNGE + | JNL + | JNLE + | JNO + | JNP + | JNS + | JNZ + | JO + | JP + | JPE + | JPO + | JRCXZ + | JS + | JZ + | LAHF + | LAR + | LDS + | LEA + | LEAVE + | LES + | LFENCE + | LFS + | LGDT + | LGS + | LIDT + | LLDT + | LMSW + | LOADALL + | LOADALL286 + | LODSB + | LODSD + | LODSQ + | LODSW + | LOOP + | LOOPE + | LOOPNE + | LOOPNZ + | LOOPZ + | LSL + | LSS + | LTR + | MFENCE + | MONITOR + | MONITORX + | MOV + | MOVD + | MOVQ + | MOVSB + | MOVSD + | MOVSQ + | MOVSW + | MOVSX + | MOVSXD + | MOVZX + | MUL + | MWAIT + | MWAITX + | NEG + | NOP + | NOT + | OR + | OUT + | OUTSB + | OUTSD + | OUTSW + | PACKSSDW + | PACKSSWB + | PACKUSWB + | PADDB + | PADDD + | PADDSB + | PADDSIW + | PADDSW + | PADDUSB + | PADDUSW + | PADDW + | PAND + | PANDN + | PAUSE + | PAVEB + | PAVGUSB + | PCMPEQB + | PCMPEQD + | PCMPEQW + | PCMPGTB + | PCMPGTD + | PCMPGTW + | PDISTIB + | PF2ID + | PFACC + | PFADD + | PFCMPEQ + | PFCMPGE + | PFCMPGT + | PFMAX + | PFMIN + | PFMUL + | PFRCP + | PFRCPIT1 + | PFRCPIT2 + | PFRSQIT1 + | PFRSQRT + | PFSUB + | PFSUBR + | PI2FD + | PMACHRIW + | PMADDWD + | PMAGW + | PMULHRIW + | PMULHRWA + | PMULHRWC + | PMULHW + | PMULLW + | PMVGEZB + | PMVLZB + | PMVNZB + | PMVZB + | POP + | POPA + | POPAD + | POPAW + | POPF + | POPFD + | POPFQ + | POPFW + | POR + | PREFETCH + | PREFETCHW + | PSLLD + | PSLLQ + | PSLLW + | PSRAD + | PSRAW + | PSRLD + | PSRLQ + | PSRLW + | PSUBB + | PSUBD + | PSUBSB + | PSUBSIW + | PSUBSW + | PSUBUSB + | PSUBUSW + | PSUBW + | PUNPCKHBW + | PUNPCKHDQ + | PUNPCKHWD + | PUNPCKLBW + | PUNPCKLDQ + | PUNPCKLWD + | PUSH + | PUSHA + | PUSHAD + | PUSHAW + | PUSHF + | PUSHFD + | PUSHFQ + | PUSHFW + | PXOR + | RCL + | RCR + | RDM + | RDMSR + | RDPMC + | RDSHR + | RDTSC + | RDTSCP + | RET + | RETD + | RETF + | RETFD + | RETFQ + | RETFW + | RETN + | RETND + | RETNQ + | RETNW + | RETQ + | RETW + | ROL + | ROR + | RSDC + | RSLDT + | RSM + | RSTS + | SAHF + | SAL + | SALC + | SAR + | SBB + | SCASB + | SCASD + | SCASQ + | SCASW + | SETA + | SETAE + | SETB + | SETBE + | SETC + | SETE + | SETG + | SETGE + | SETL + | SETLE + | SETNA + | SETNAE + | SETNB + | SETNBE + | SETNC + | SETNE + | SETNG + | SETNGE + | SETNL + | SETNLE + | SETNO + | SETNP + | SETNS + | SETNZ + | SETO + | SETP + | SETPE + | SETPO + | SETS + | SETZ + | SFENCE + | SGDT + | SHL + | SHLD + | SHR + | SHRD + | SIDT + | SKINIT + | SLDT + | SMI + | SMINT + | SMINTOLD + | SMSW + | STC + | STD + | STI + | STOSB + | STOSD + | STOSQ + | STOSW + | STR + | SUB + | SVDC + | SVLDT + | SVTS + | SWAPGS + | SYSCALL + | SYSENTER + | SYSEXIT + | SYSRET + | TEST + | UD0 + | UD1 + | UD2 + | UD2A + | UD2B + | UMOV + | VERR + | VERW + | WBINVD + | WRMSR + | WRSHR + | XADD + | XBTS + | XCHG + | XLAT + | XLATB + | XOR + | AADD + | AAND + | ADCX + | ADDPD + | ADDPS + | ADDSD + | ADDSS + | ADDSUBPD + | ADDSUBPS + | ADOX + | AESDEC + | AESDECLAST + | AESENC + | AESENCLAST + | AESIMC + | AESKEYGENASSIST + | ANDN + | ANDNPD + | ANDNPS + | ANDPD + | ANDPS + | AXOR + | BEXTR + | BLCFILL + | BLCI + | BLCIC + | BLCMSK + | BLCS + | BLENDPD + | BLENDPS + | BLENDVPD + | BLENDVPS + | BLSFILL + | BLSI + | BLSIC + | BLSMSK + | BLSR + | BNDCL + | BNDCN + | BNDCU + | BNDLDX + | BNDMK + | BNDMOV + | BNDSTX + | BZHI + | CLAC + | CLDEMOTE + | CLFLUSH + | CLFLUSHOPT + | CLGI + | CLRSSBSY + | CLUI + | CLWB + | CLZERO + | CMPEQPD + | CMPEQPS + | CMPEQSD + | CMPEQSS + | CMPLEPD + | CMPLEPS + | CMPLESD + | CMPLESS + | CMPLTPD + | CMPLTPS + | CMPLTSD + | CMPLTSS + | CMPNEQPD + | CMPNEQPS + | CMPNEQSD + | CMPNEQSS + | CMPNLEPD + | CMPNLEPS + | CMPNLESD + | CMPNLESS + | CMPNLTPD + | CMPNLTPS + | CMPNLTSD + | CMPNLTSS + | CMPNPXADD + | CMPNSXADD + | CMPNZXADD + | CMPORDPD + | CMPORDPS + | CMPORDSD + | CMPORDSS + | CMPOXADD + | CMPPD + | CMPPS + | CMPPXADD + | CMPSS + | CMPSXADD + | CMPUNORDPD + | CMPUNORDPS + | CMPUNORDSD + | CMPUNORDSS + | CMPZXADD + | COMISD + | COMISS + | CRC32 + | CVTDQ2PD + | CVTDQ2PS + | CVTPD2DQ + | CVTPD2PI + | CVTPD2PS + | CVTPI2PD + | CVTPI2PS + | CVTPS2DQ + | CVTPS2PD + | CVTPS2PI + | CVTSD2SI + | CVTSD2SS + | CVTSI2SD + | CVTSI2SS + | CVTSS2SD + | CVTSS2SI + | CVTTPD2DQ + | CVTTPD2PI + | CVTTPS2DQ + | CVTTPS2PI + | CVTTSD2SI + | CVTTSS2SI + | DIVPD + | DIVPS + | DIVSD + | DIVSS + | DPPD + | DPPS + | ENCLS + | ENCLU + | ENCLV + | ENDBR32 + | ENDBR64 + | ENQCMD + | ENQCMDS + | EXTRACTPS + | EXTRQ + | FXRSTOR + | FXRSTOR64 + | FXSAVE + | FXSAVE64 + | GETSEC + | GF2P8AFFINEINVQB + | GF2P8AFFINEQB + | GF2P8MULB + | HADDPD + | HADDPS + | HINT_NOP0 + | HINT_NOP1 + | HINT_NOP10 + | HINT_NOP11 + | HINT_NOP12 + | HINT_NOP13 + | HINT_NOP14 + | HINT_NOP15 + | HINT_NOP16 + | HINT_NOP17 + | HINT_NOP18 + | HINT_NOP19 + | HINT_NOP2 + | HINT_NOP20 + | HINT_NOP21 + | HINT_NOP22 + | HINT_NOP23 + | HINT_NOP24 + | HINT_NOP25 + | HINT_NOP26 + | HINT_NOP27 + | HINT_NOP28 + | HINT_NOP29 + | HINT_NOP3 + | HINT_NOP30 + | HINT_NOP31 + | HINT_NOP32 + | HINT_NOP33 + | HINT_NOP34 + | HINT_NOP35 + | HINT_NOP36 + | HINT_NOP37 + | HINT_NOP38 + | HINT_NOP39 + | HINT_NOP4 + | HINT_NOP40 + | HINT_NOP41 + | HINT_NOP42 + | HINT_NOP43 + | HINT_NOP44 + | HINT_NOP45 + | HINT_NOP46 + | HINT_NOP47 + | HINT_NOP48 + | HINT_NOP49 + | HINT_NOP5 + | HINT_NOP50 + | HINT_NOP51 + | HINT_NOP52 + | HINT_NOP53 + | HINT_NOP54 + | HINT_NOP55 + | HINT_NOP56 + | HINT_NOP57 + | HINT_NOP58 + | HINT_NOP59 + | HINT_NOP6 + | HINT_NOP60 + | HINT_NOP61 + | HINT_NOP62 + | HINT_NOP63 + | HINT_NOP7 + | HINT_NOP8 + | HINT_NOP9 + | HRESET + | HSUBPD + | HSUBPS + | INCSSPD + | INCSSPQ + | INSERTPS + | INSERTQ + | INVEPT + | INVVPID + | KADD + | KADDB + | KADDD + | KADDQ + | KADDW + | KAND + | KANDB + | KANDD + | KANDN + | KANDNB + | KANDND + | KANDNQ + | KANDNW + | KANDQ + | KANDW + | KMOV + | KMOVB + | KMOVD + | KMOVQ + | KMOVW + | KNOT + | KNOTB + | KNOTD + | KNOTQ + | KNOTW + | KOR + | KORB + | KORD + | KORQ + | KORTEST + | KORTESTB + | KORTESTD + | KORTESTQ + | KORTESTW + | KORW + | KSHIFTL + | KSHIFTLB + | KSHIFTLD + | KSHIFTLQ + | KSHIFTLW + | KSHIFTR + | KSHIFTRB + | KSHIFTRD + | KSHIFTRQ + | KSHIFTRW + | KTEST + | KTESTB + | KTESTD + | KTESTQ + | KTESTW + | KUNPCK + | KUNPCKBW + | KUNPCKDQ + | KUNPCKWD + | KXNOR + | KXNORB + | KXNORD + | KXNORQ + | KXNORW + | KXOR + | KXORB + | KXORD + | KXORQ + | KXORW + | LDDQU + | LDMXCSR + | LDTILECFG + | LLWPCB + | LWPINS + | LWPVAL + | LZCNT + | MASKMOVDQU + | MASKMOVQ + | MAXPD + | MAXPS + | MAXSD + | MAXSS + | MINPD + | MINPS + | MINSD + | MINSS + | MONTMUL + | MOVAPD + | MOVAPS + | MOVBE + | MOVDDUP + | MOVDIR64B + | MOVDIRI + | MOVDQ2Q + | MOVDQA + | MOVDQU + | MOVHLPS + | MOVHPD + | MOVHPS + | MOVLHPS + | MOVLPD + | MOVLPS + | MOVMSKPD + | MOVMSKPS + | MOVNTDQ + | MOVNTDQA + | MOVNTI + | MOVNTPD + | MOVNTPS + | MOVNTQ + | MOVNTSD + | MOVNTSS + | MOVQ2DQ + | MOVSHDUP + | MOVSLDUP + | MOVSS + | MOVUPD + | MOVUPS + | MPSADBW + | MULPD + | MULPS + | MULSD + | MULSS + | MULX + | ORPD + | ORPS + | PABSB + | PABSD + | PABSW + | PACKUSDW + | PADDQ + | PALIGNR + | PAVGB + | PAVGW + | PBLENDVB + | PBLENDW + | PCLMULHQHQDQ + | PCLMULHQLQDQ + | PCLMULLQHQDQ + | PCLMULLQLQDQ + | PCLMULQDQ + | PCMPEQQ + | PCMPESTRI + | PCMPESTRM + | PCMPGTQ + | PCMPISTRI + | PCMPISTRM + | PCOMMIT + | PCONFIG + | PDEP + | PEXT + | PEXTRB + | PEXTRD + | PEXTRQ + | PEXTRW + | PF2IW + | PFNACC + | PFPNACC + | PFRCPV + | PFRSQRTV + | PHADDD + | PHADDSW + | PHADDW + | PHMINPOSUW + | PHSUBD + | PHSUBSW + | PHSUBW + | PI2FW + | PINSRB + | PINSRD + | PINSRQ + | PINSRW + | PMADDUBSW + | PMAXSB + | PMAXSD + | PMAXSW + | PMAXUB + | PMAXUD + | PMAXUW + | PMINSB + | PMINSD + | PMINSW + | PMINUB + | PMINUD + | PMINUW + | PMOVMSKB + | PMOVSXBD + | PMOVSXBQ + | PMOVSXBW + | PMOVSXDQ + | PMOVSXWD + | PMOVSXWQ + | PMOVZXBD + | PMOVZXBQ + | PMOVZXBW + | PMOVZXDQ + | PMOVZXWD + | PMOVZXWQ + | PMULDQ + | PMULHRSW + | PMULHUW + | PMULLD + | PMULUDQ + | POPCNT + | PREFETCHIT0 + | PREFETCHIT1 + | PREFETCHNTA + | PREFETCHT0 + | PREFETCHT1 + | PREFETCHT2 + | PREFETCHWT1 + | PSADBW + | PSHUFB + | PSHUFD + | PSHUFHW + | PSHUFLW + | PSHUFW + | PSIGNB + | PSIGND + | PSIGNW + | PSLLDQ + | PSRLDQ + | PSUBQ + | PSWAPD + | PTEST + | PTWRITE + | PUNPCKHQDQ + | PUNPCKLQDQ + | PVALIDATE + | RCPPS + | RCPSS + | RDFSBASE + | RDGSBASE + | RDMSRLIST + | RDPID + | RDPKRU + | RDRAND + | RDSEED + | RDSSPD + | RDSSPQ + | RMPADJUST + | RORX + | ROUNDPD + | ROUNDPS + | ROUNDSD + | ROUNDSS + | RSQRTPS + | RSQRTSS + | RSTORSSP + | SARX + | SAVEPREVSSP + | SENDUIPI + | SERIALIZE + | SETSSBSY + | SHA1MSG1 + | SHA1MSG2 + | SHA1NEXTE + | SHA1RNDS4 + | SHA256MSG1 + | SHA256MSG2 + | SHA256RNDS2 + | SHLX + | SHRX + | SHUFPD + | SHUFPS + | SLWPCB + | SQRTPD + | SQRTPS + | SQRTSD + | SQRTSS + | STAC + | STGI + | STMXCSR + | STTILECFG + | STUI + | SUBPD + | SUBPS + | SUBSD + | SUBSS + | T1MSKC + | TDPBF16PS + | TDPBSSD + | TDPBSUD + | TDPBUSD + | TDPBUUD + | TESTUI + | TILELOADD + | TILELOADDT1 + | TILERELEASE + | TILESTORED + | TILEZERO + | TPAUSE + | TZCNT + | TZMSK + | UCOMISD + | UCOMISS + | UIRET + | UMONITOR + | UMWAIT + | UNPCKHPD + | UNPCKHPS + | UNPCKLPD + | UNPCKLPS + | V4DPWSSD + | V4DPWSSDS + | V4FMADDPS + | V4FMADDSS + | V4FNMADDPS + | V4FNMADDSS + | VADDPD + | VADDPH + | VADDPS + | VADDSD + | VADDSH + | VADDSS + | VADDSUBPD + | VADDSUBPS + | VAESDEC + | VAESDECLAST + | VAESENC + | VAESENCLAST + | VAESIMC + | VAESKEYGENASSIST + | VALIGND + | VALIGNQ + | VANDNPD + | VANDNPS + | VANDPD + | VANDPS + | VBCSTNEBF16PS + | VBCSTNESH2PS + | VBLENDMPD + | VBLENDMPS + | VBLENDPD + | VBLENDPS + | VBLENDVPD + | VBLENDVPS + | VBROADCASTF128 + | VBROADCASTF32X2 + | VBROADCASTF32X4 + | VBROADCASTF32X8 + | VBROADCASTF64X2 + | VBROADCASTF64X4 + | VBROADCASTI128 + | VBROADCASTI32X2 + | VBROADCASTI32X4 + | VBROADCASTI32X8 + | VBROADCASTI64X2 + | VBROADCASTI64X4 + | VBROADCASTSD + | VBROADCASTSS + | VCMPEQ_OQPD + | VCMPEQ_OQPS + | VCMPEQ_OQSD + | VCMPEQ_OQSS + | VCMPEQ_OSPD + | VCMPEQ_OSPS + | VCMPEQ_OSSD + | VCMPEQ_OSSS + | VCMPEQ_UQPD + | VCMPEQ_UQPS + | VCMPEQ_UQSD + | VCMPEQ_UQSS + | VCMPEQ_USPD + | VCMPEQ_USPS + | VCMPEQ_USSD + | VCMPEQ_USSS + | VCMPEQPD + | VCMPEQPS + | VCMPEQSD + | VCMPEQSS + | VCMPFALSE_OQPD + | VCMPFALSE_OQPS + | VCMPFALSE_OQSD + | VCMPFALSE_OQSS + | VCMPFALSE_OSPD + | VCMPFALSE_OSPS + | VCMPFALSE_OSSD + | VCMPFALSE_OSSS + | VCMPFALSEPD + | VCMPFALSEPS + | VCMPFALSESD + | VCMPFALSESS + | VCMPGE_OQPD + | VCMPGE_OQPS + | VCMPGE_OQSD + | VCMPGE_OQSS + | VCMPGE_OSPD + | VCMPGE_OSPS + | VCMPGE_OSSD + | VCMPGE_OSSS + | VCMPGEPD + | VCMPGEPS + | VCMPGESD + | VCMPGESS + | VCMPGT_OQPD + | VCMPGT_OQPS + | VCMPGT_OQSD + | VCMPGT_OQSS + | VCMPGT_OSPD + | VCMPGT_OSPS + | VCMPGT_OSSD + | VCMPGT_OSSS + | VCMPGTPD + | VCMPGTPS + | VCMPGTSD + | VCMPGTSS + | VCMPLE_OQPD + | VCMPLE_OQPS + | VCMPLE_OQSD + | VCMPLE_OQSS + | VCMPLE_OSPD + | VCMPLE_OSPS + | VCMPLE_OSSD + | VCMPLE_OSSS + | VCMPLEPD + | VCMPLEPS + | VCMPLESD + | VCMPLESS + | VCMPLT_OQPD + | VCMPLT_OQPS + | VCMPLT_OQSD + | VCMPLT_OQSS + | VCMPLT_OSPD + | VCMPLT_OSPS + | VCMPLT_OSSD + | VCMPLT_OSSS + | VCMPLTPD + | VCMPLTPS + | VCMPLTSD + | VCMPLTSS + | VCMPNEQ_OQPD + | VCMPNEQ_OQPS + | VCMPNEQ_OQSD + | VCMPNEQ_OQSS + | VCMPNEQ_OSPD + | VCMPNEQ_OSPS + | VCMPNEQ_OSSD + | VCMPNEQ_OSSS + | VCMPNEQ_UQPD + | VCMPNEQ_UQPS + | VCMPNEQ_UQSD + | VCMPNEQ_UQSS + | VCMPNEQ_USPD + | VCMPNEQ_USPS + | VCMPNEQ_USSD + | VCMPNEQ_USSS + | VCMPNEQPD + | VCMPNEQPS + | VCMPNEQSD + | VCMPNEQSS + | VCMPNGE_UQPD + | VCMPNGE_UQPS + | VCMPNGE_UQSD + | VCMPNGE_UQSS + | VCMPNGE_USPD + | VCMPNGE_USPS + | VCMPNGE_USSD + | VCMPNGE_USSS + | VCMPNGEPD + | VCMPNGEPS + | VCMPNGESD + | VCMPNGESS + | VCMPNGT_UQPD + | VCMPNGT_UQPS + | VCMPNGT_UQSD + | VCMPNGT_UQSS + | VCMPNGT_USPD + | VCMPNGT_USPS + | VCMPNGT_USSD + | VCMPNGT_USSS + | VCMPNGTPD + | VCMPNGTPS + | VCMPNGTSD + | VCMPNGTSS + | VCMPNLE_UQPD + | VCMPNLE_UQPS + | VCMPNLE_UQSD + | VCMPNLE_UQSS + | VCMPNLE_USPD + | VCMPNLE_USPS + | VCMPNLE_USSD + | VCMPNLE_USSS + | VCMPNLEPD + | VCMPNLEPS + | VCMPNLESD + | VCMPNLESS + | VCMPNLT_UQPD + | VCMPNLT_UQPS + | VCMPNLT_UQSD + | VCMPNLT_UQSS + | VCMPNLT_USPD + | VCMPNLT_USPS + | VCMPNLT_USSD + | VCMPNLT_USSS + | VCMPNLTPD + | VCMPNLTPS + | VCMPNLTSD + | VCMPNLTSS + | VCMPORD_QPD + | VCMPORD_QPS + | VCMPORD_QSD + | VCMPORD_QSS + | VCMPORD_SPD + | VCMPORD_SPS + | VCMPORD_SSD + | VCMPORD_SSS + | VCMPORDPD + | VCMPORDPS + | VCMPORDSD + | VCMPORDSS + | VCMPPD + | VCMPPH + | VCMPPS + | VCMPSD + | VCMPSH + | VCMPSS + | VCMPTRUE_UQPD + | VCMPTRUE_UQPS + | VCMPTRUE_UQSD + | VCMPTRUE_UQSS + | VCMPTRUE_USPD + | VCMPTRUE_USPS + | VCMPTRUE_USSD + | VCMPTRUE_USSS + | VCMPTRUEPD + | VCMPTRUEPS + | VCMPTRUESD + | VCMPTRUESS + | VCMPUNORD_QPD + | VCMPUNORD_QPS + | VCMPUNORD_QSD + | VCMPUNORD_QSS + | VCMPUNORD_SPD + | VCMPUNORD_SPS + | VCMPUNORD_SSD + | VCMPUNORD_SSS + | VCMPUNORDPD + | VCMPUNORDPS + | VCMPUNORDSD + | VCMPUNORDSS + | VCOMISD + | VCOMISH + | VCOMISS + | VCOMPRESSPD + | VCOMPRESSPS + | VCVTDQ2PD + | VCVTDQ2PH + | VCVTDQ2PS + | VCVTNE2PS2BF16 + | VCVTNEEBF162PS + | VCVTNEEPH2PS + | VCVTNEOBF162PS + | VCVTNEOPH2PS + | VCVTNEPS2BF16 + | VCVTPD2DQ + | VCVTPD2PH + | VCVTPD2PS + | VCVTPD2QQ + | VCVTPD2UDQ + | VCVTPD2UQQ + | VCVTPH2DQ + | VCVTPH2PD + | VCVTPH2PS + | VCVTPH2PSX + | VCVTPH2QQ + | VCVTPH2UDQ + | VCVTPH2UQQ + | VCVTPH2UW + | VCVTPH2W + | VCVTPS2DQ + | VCVTPS2PD + | VCVTPS2PH + | VCVTPS2QQ + | VCVTPS2UDQ + | VCVTPS2UQQ + | VCVTQQ2PD + | VCVTQQ2PH + | VCVTQQ2PS + | VCVTSD2SH + | VCVTSD2SI + | VCVTSD2SS + | VCVTSD2USI + | VCVTSH2SD + | VCVTSH2SI + | VCVTSH2SS + | VCVTSH2USI + | VCVTSI2SD + | VCVTSI2SH + | VCVTSI2SS + | VCVTSS2SD + | VCVTSS2SH + | VCVTSS2SI + | VCVTSS2USI + | VCVTTPD2DQ + | VCVTTPD2QQ + | VCVTTPD2UDQ + | VCVTTPD2UQQ + | VCVTTPH2DQ + | VCVTTPH2QQ + | VCVTTPH2UDQ + | VCVTTPH2UQQ + | VCVTTPH2UW + | VCVTTPH2W + | VCVTTPS2DQ + | VCVTTPS2QQ + | VCVTTPS2UDQ + | VCVTTPS2UQQ + | VCVTTSD2SI + | VCVTTSD2USI + | VCVTTSH2SI + | VCVTTSH2USI + | VCVTTSS2SI + | VCVTTSS2USI + | VCVTUDQ2PD + | VCVTUDQ2PH + | VCVTUDQ2PS + | VCVTUQQ2PD + | VCVTUQQ2PH + | VCVTUQQ2PS + | VCVTUSI2SD + | VCVTUSI2SH + | VCVTUSI2SS + | VCVTUW2PH + | VCVTW2PH + | VDBPSADBW + | VDIVPD + | VDIVPH + | VDIVPS + | VDIVSD + | VDIVSH + | VDIVSS + | VDPBF16PS + | VDPPD + | VDPPS + | VENDSCALEPH + | VENDSCALESH + | VEXP2PD + | VEXP2PS + | VEXPANDPD + | VEXPANDPS + | VEXTRACTF128 + | VEXTRACTF32X4 + | VEXTRACTF32X8 + | VEXTRACTF64X2 + | VEXTRACTF64X4 + | VEXTRACTI128 + | VEXTRACTI32X4 + | VEXTRACTI32X8 + | VEXTRACTI64X2 + | VEXTRACTI64X4 + | VEXTRACTPS + | VFCMADDCPH + | VFCMADDCSH + | VFCMULCPCH + | VFCMULCSH + | VFIXUPIMMPD + | VFIXUPIMMPS + | VFIXUPIMMSD + | VFIXUPIMMSS + | VFMADD123PD + | VFMADD123PS + | VFMADD123SD + | VFMADD123SS + | VFMADD132PD + | VFMADD132PH + | VFMADD132PS + | VFMADD132SD + | VFMADD132SS + | VFMADD213PD + | VFMADD213PH + | VFMADD213PS + | VFMADD213SD + | VFMADD213SS + | VFMADD231PD + | VFMADD231PH + | VFMADD231PS + | VFMADD231SD + | VFMADD231SS + | VFMADD312PD + | VFMADD312PS + | VFMADD312SD + | VFMADD312SS + | VFMADD321PD + | VFMADD321PS + | VFMADD321SD + | VFMADD321SS + | VFMADDCPH + | VFMADDCSH + | VFMADDPD + | VFMADDPS + | VFMADDSD + | VFMADDSS + | VFMADDSUB123PD + | VFMADDSUB123PS + | VFMADDSUB132PD + | VFMADDSUB132PH + | VFMADDSUB132PS + | VFMADDSUB213PD + | VFMADDSUB213PH + | VFMADDSUB213PS + | VFMADDSUB231PD + | VFMADDSUB231PH + | VFMADDSUB231PS + | VFMADDSUB312PD + | VFMADDSUB312PS + | VFMADDSUB321PD + | VFMADDSUB321PS + | VFMADDSUBPD + | VFMADDSUBPS + | VFMSUB123PD + | VFMSUB123PS + | VFMSUB123SD + | VFMSUB123SS + | VFMSUB132PD + | VFMSUB132PH + | VFMSUB132PS + | VFMSUB132SD + | VFMSUB132SS + | VFMSUB213PD + | VFMSUB213PH + | VFMSUB213PS + | VFMSUB213SD + | VFMSUB213SS + | VFMSUB231PD + | VFMSUB231PH + | VFMSUB231PS + | VFMSUB231SD + | VFMSUB231SS + | VFMSUB312PD + | VFMSUB312PS + | VFMSUB312SD + | VFMSUB312SS + | VFMSUB321PD + | VFMSUB321PS + | VFMSUB321SD + | VFMSUB321SS + | VFMSUBADD123PD + | VFMSUBADD123PS + | VFMSUBADD132PD + | VFMSUBADD132PH + | VFMSUBADD132PS + | VFMSUBADD213PD + | VFMSUBADD213PH + | VFMSUBADD213PS + | VFMSUBADD231PD + | VFMSUBADD231PH + | VFMSUBADD231PS + | VFMSUBADD312PD + | VFMSUBADD312PS + | VFMSUBADD321PD + | VFMSUBADD321PS + | VFMSUBADDPD + | VFMSUBADDPS + | VFMSUBPD + | VFMSUBPS + | VFMSUBSD + | VFMSUBSS + | VFMULCPCH + | VFMULCSH + | VFNMADD123PD + | VFNMADD123PS + | VFNMADD123SD + | VFNMADD123SS + | VFNMADD132PD + | VFNMADD132PS + | VFNMADD132SD + | VFNMADD132SS + | VFNMADD213PD + | VFNMADD213PS + | VFNMADD213SD + | VFNMADD213SS + | VFNMADD231PD + | VFNMADD231PS + | VFNMADD231SD + | VFNMADD231SS + | VFNMADD312PD + | VFNMADD312PS + | VFNMADD312SD + | VFNMADD312SS + | VFNMADD321PD + | VFNMADD321PS + | VFNMADD321SD + | VFNMADD321SS + | VFNMADDPD + | VFNMADDPS + | VFNMADDSD + | VFNMADDSS + | VFNMSUB123PD + | VFNMSUB123PS + | VFNMSUB123SD + | VFNMSUB123SS + | VFNMSUB132PD + | VFNMSUB132PS + | VFNMSUB132SD + | VFNMSUB132SS + | VFNMSUB213PD + | VFNMSUB213PS + | VFNMSUB213SD + | VFNMSUB213SS + | VFNMSUB231PD + | VFNMSUB231PS + | VFNMSUB231SD + | VFNMSUB231SS + | VFNMSUB312PD + | VFNMSUB312PS + | VFNMSUB312SD + | VFNMSUB312SS + | VFNMSUB321PD + | VFNMSUB321PS + | VFNMSUB321SD + | VFNMSUB321SS + | VFNMSUBPD + | VFNMSUBPS + | VFNMSUBSD + | VFNMSUBSS + | VFPCLASSPD + | VFPCLASSPH + | VFPCLASSPS + | VFPCLASSSD + | VFPCLASSSH + | VFPCLASSSS + | VFRCZPD + | VFRCZPS + | VFRCZSD + | VFRCZSS + | VGATHERDPD + | VGATHERDPS + | VGATHERPF0DPD + | VGATHERPF0DPS + | VGATHERPF0QPD + | VGATHERPF0QPS + | VGATHERPF1DPD + | VGATHERPF1DPS + | VGATHERPF1QPD + | VGATHERPF1QPS + | VGATHERQPD + | VGATHERQPS + | VGETEXPPD + | VGETEXPPH + | VGETEXPPS + | VGETEXPSD + | VGETEXPSH + | VGETEXPSS + | VGETMANTPD + | VGETMANTPH + | VGETMANTPS + | VGETMANTSD + | VGETMANTSH + | VGETMANTSS + | VGETMAXPH + | VGETMAXSH + | VGETMINPH + | VGETMINSH + | VGF2P8AFFINEINVQB + | VGF2P8AFFINEQB + | VGF2P8MULB + | VHADDPD + | VHADDPS + | VHSUBPD + | VHSUBPS + | VINSERTF128 + | VINSERTF32X4 + | VINSERTF32X8 + | VINSERTF64X2 + | VINSERTF64X4 + | VINSERTI128 + | VINSERTI32X4 + | VINSERTI32X8 + | VINSERTI64X2 + | VINSERTI64X4 + | VINSERTPS + | VLDDQU + | VLDMXCSR + | VLDQQU + | VMASKMOVDQU + | VMASKMOVPD + | VMASKMOVPS + | VMAXPD + | VMAXPS + | VMAXSD + | VMAXSS + | VMCALL + | VMCLEAR + | VMFUNC + | VMGEXIT + | VMINPD + | VMINPS + | VMINSD + | VMINSS + | VMLAUNCH + | VMLOAD + | VMMCALL + | VMOVAPD + | VMOVAPS + | VMOVD + | VMOVDDUP + | VMOVDQA + | VMOVDQA32 + | VMOVDQA64 + | VMOVDQU + | VMOVDQU16 + | VMOVDQU32 + | VMOVDQU64 + | VMOVDQU8 + | VMOVHLPS + | VMOVHPD + | VMOVHPS + | VMOVLHPS + | VMOVLPD + | VMOVLPS + | VMOVMSKPD + | VMOVMSKPS + | VMOVNTDQ + | VMOVNTDQA + | VMOVNTPD + | VMOVNTPS + | VMOVNTQQ + | VMOVQ + | VMOVQQA + | VMOVQQU + | VMOVSD + | VMOVSH + | VMOVSHDUP + | VMOVSLDUP + | VMOVSS + | VMOVUPD + | VMOVUPS + | VMOVW + | VMPSADBW + | VMPTRLD + | VMPTRST + | VMREAD + | VMRESUME + | VMRUN + | VMSAVE + | VMULPD + | VMULPH + | VMULPS + | VMULSD + | VMULSH + | VMULSS + | VMWRITE + | VMXOFF + | VMXON + | VORPD + | VORPS + | VP2INTERSECTD + | VPABSB + | VPABSD + | VPABSQ + | VPABSW + | VPACKSSDW + | VPACKSSWB + | VPACKUSDW + | VPACKUSWB + | VPADDB + | VPADDD + | VPADDQ + | VPADDSB + | VPADDSW + | VPADDUSB + | VPADDUSW + | VPADDW + | VPALIGNR + | VPAND + | VPANDD + | VPANDN + | VPANDND + | VPANDNQ + | VPANDQ + | VPAVGB + | VPAVGW + | VPBLENDD + | VPBLENDMB + | VPBLENDMD + | VPBLENDMQ + | VPBLENDMW + | VPBLENDVB + | VPBLENDW + | VPBROADCASTB + | VPBROADCASTD + | VPBROADCASTMB2Q + | VPBROADCASTMW2D + | VPBROADCASTQ + | VPBROADCASTW + | VPCLMULHQHQDQ + | VPCLMULHQLQDQ + | VPCLMULLQHQDQ + | VPCLMULLQLQDQ + | VPCLMULQDQ + | VPCMOV + | VPCMPB + | VPCMPD + | VPCMPEQB + | VPCMPEQD + | VPCMPEQQ + | VPCMPEQUB + | VPCMPEQUD + | VPCMPEQUQ + | VPCMPEQUW + | VPCMPEQW + | VPCMPESTRI + | VPCMPESTRM + | VPCMPGEB + | VPCMPGED + | VPCMPGEQ + | VPCMPGEUB + | VPCMPGEUD + | VPCMPGEUQ + | VPCMPGEUW + | VPCMPGEW + | VPCMPGTB + | VPCMPGTD + | VPCMPGTQ + | VPCMPGTUB + | VPCMPGTUD + | VPCMPGTUQ + | VPCMPGTUW + | VPCMPGTW + | VPCMPISTRI + | VPCMPISTRM + | VPCMPLEB + | VPCMPLED + | VPCMPLEQ + | VPCMPLEUB + | VPCMPLEUD + | VPCMPLEUQ + | VPCMPLEUW + | VPCMPLEW + | VPCMPLTB + | VPCMPLTD + | VPCMPLTQ + | VPCMPLTUB + | VPCMPLTUD + | VPCMPLTUQ + | VPCMPLTUW + | VPCMPLTW + | VPCMPNEQB + | VPCMPNEQD + | VPCMPNEQQ + | VPCMPNEQUB + | VPCMPNEQUD + | VPCMPNEQUQ + | VPCMPNEQUW + | VPCMPNEQW + | VPCMPNGTB + | VPCMPNGTD + | VPCMPNGTQ + | VPCMPNGTUB + | VPCMPNGTUD + | VPCMPNGTUQ + | VPCMPNGTUW + | VPCMPNGTW + | VPCMPNLEB + | VPCMPNLED + | VPCMPNLEQ + | VPCMPNLEUB + | VPCMPNLEUD + | VPCMPNLEUQ + | VPCMPNLEUW + | VPCMPNLEW + | VPCMPNLTB + | VPCMPNLTD + | VPCMPNLTQ + | VPCMPNLTUB + | VPCMPNLTUD + | VPCMPNLTUQ + | VPCMPNLTUW + | VPCMPNLTW + | VPCMPQ + | VPCMPUB + | VPCMPUD + | VPCMPUQ + | VPCMPUW + | VPCMPW + | VPCOMB + | VPCOMD + | VPCOMPRESSB + | VPCOMPRESSD + | VPCOMPRESSQ + | VPCOMPRESSW + | VPCOMQ + | VPCOMUB + | VPCOMUD + | VPCOMUQ + | VPCOMUW + | VPCOMW + | VPCONFLICTD + | VPCONFLICTQ + | VPDPBSSD + | VPDPBSSDS + | VPDPBSUD + | VPDPBSUDS + | VPDPBUSD + | VPDPBUSDS + | VPDPBUUD + | VPDPBUUDS + | VPDPWSSD + | VPDPWSSDS + | VPERM2F128 + | VPERM2I128 + | VPERMB + | VPERMD + | VPERMI2B + | VPERMI2D + | VPERMI2PD + | VPERMI2PS + | VPERMI2Q + | VPERMI2W + | VPERMILPD + | VPERMILPS + | VPERMPD + | VPERMPS + | VPERMQ + | VPERMT2B + | VPERMT2D + | VPERMT2PD + | VPERMT2PS + | VPERMT2Q + | VPERMT2W + | VPERMW + | VPEXPANDB + | VPEXPANDD + | VPEXPANDQ + | VPEXPANDW + | VPEXTRB + | VPEXTRD + | VPEXTRQ + | VPEXTRW + | VPGATHERDD + | VPGATHERDQ + | VPGATHERQD + | VPGATHERQQ + | VPHADDBD + | VPHADDBQ + | VPHADDBW + | VPHADDD + | VPHADDDQ + | VPHADDSW + | VPHADDUBD + | VPHADDUBQ + | VPHADDUBW + | VPHADDUDQ + | VPHADDUWD + | VPHADDUWQ + | VPHADDW + | VPHADDWD + | VPHADDWQ + | VPHMINPOSUW + | VPHSUBBW + | VPHSUBD + | VPHSUBDQ + | VPHSUBSW + | VPHSUBW + | VPHSUBWD + | VPINSRB + | VPINSRD + | VPINSRQ + | VPINSRW + | VPLZCNTD + | VPLZCNTQ + | VPMACSDD + | VPMACSDQH + | VPMACSDQL + | VPMACSSDD + | VPMACSSDQH + | VPMACSSDQL + | VPMACSSWD + | VPMACSSWW + | VPMACSWD + | VPMACSWW + | VPMADCSSWD + | VPMADCSWD + | VPMADD132PH + | VPMADD132SH + | VPMADD213PH + | VPMADD213SH + | VPMADD231PH + | VPMADD231SH + | VPMADD52HUQ + | VPMADD52LUQ + | VPMADDUBSW + | VPMADDWD + | VPMASKMOVD + | VPMASKMOVQ + | VPMAXSB + | VPMAXSD + | VPMAXSQ + | VPMAXSW + | VPMAXUB + | VPMAXUD + | VPMAXUQ + | VPMAXUW + | VPMINSB + | VPMINSD + | VPMINSQ + | VPMINSW + | VPMINUB + | VPMINUD + | VPMINUQ + | VPMINUW + | VPMOVB2M + | VPMOVD2M + | VPMOVDB + | VPMOVDW + | VPMOVM2B + | VPMOVM2D + | VPMOVM2Q + | VPMOVM2W + | VPMOVMSKB + | VPMOVQ2M + | VPMOVQB + | VPMOVQD + | VPMOVQW + | VPMOVSDB + | VPMOVSDW + | VPMOVSQB + | VPMOVSQD + | VPMOVSQW + | VPMOVSWB + | VPMOVSXBD + | VPMOVSXBQ + | VPMOVSXBW + | VPMOVSXDQ + | VPMOVSXWD + | VPMOVSXWQ + | VPMOVUSDB + | VPMOVUSDW + | VPMOVUSQB + | VPMOVUSQD + | VPMOVUSQW + | VPMOVUSWB + | VPMOVW2M + | VPMOVWB + | VPMOVZXBD + | VPMOVZXBQ + | VPMOVZXBW + | VPMOVZXDQ + | VPMOVZXWD + | VPMOVZXWQ + | VPMSUB132PH + | VPMSUB132SH + | VPMSUB213PH + | VPMSUB213SH + | VPMSUB231PH + | VPMSUB231SH + | VPMULDQ + | VPMULHRSW + | VPMULHUW + | VPMULHW + | VPMULLD + | VPMULLQ + | VPMULLW + | VPMULTISHIFTQB + | VPMULUDQ + | VPNMADD132SH + | VPNMADD213SH + | VPNMADD231SH + | VPNMSUB132SH + | VPNMSUB213SH + | VPNMSUB231SH + | VPOPCNTB + | VPOPCNTD + | VPOPCNTQ + | VPOPCNTW + | VPOR + | VPORD + | VPORQ + | VPPERM + | VPROLD + | VPROLQ + | VPROLVD + | VPROLVQ + | VPRORD + | VPRORQ + | VPRORVD + | VPRORVQ + | VPROTB + | VPROTD + | VPROTQ + | VPROTW + | VPSADBW + | VPSCATTERDD + | VPSCATTERDQ + | VPSCATTERQD + | VPSCATTERQQ + | VPSHAB + | VPSHAD + | VPSHAQ + | VPSHAW + | VPSHLB + | VPSHLD + | VPSHLDD + | VPSHLDQ + | VPSHLDVD + | VPSHLDVQ + | VPSHLDVW + | VPSHLDW + | VPSHLQ + | VPSHLW + | VPSHRDD + | VPSHRDQ + | VPSHRDVD + | VPSHRDVQ + | VPSHRDVW + | VPSHRDW + | VPSHUFB + | VPSHUFBITQMB + | VPSHUFD + | VPSHUFHW + | VPSHUFLW + | VPSIGNB + | VPSIGND + | VPSIGNW + | VPSLLD + | VPSLLDQ + | VPSLLQ + | VPSLLVD + | VPSLLVQ + | VPSLLVW + | VPSLLW + | VPSRAD + | VPSRAQ + | VPSRAVD + | VPSRAVQ + | VPSRAVW + | VPSRAW + | VPSRLD + | VPSRLDQ + | VPSRLQ + | VPSRLVD + | VPSRLVQ + | VPSRLVW + | VPSRLW + | VPSUBB + | VPSUBD + | VPSUBQ + | VPSUBSB + | VPSUBSW + | VPSUBUSB + | VPSUBUSW + | VPSUBW + | VPTERNLOGD + | VPTERNLOGQ + | VPTEST + | VPTESTMB + | VPTESTMD + | VPTESTMQ + | VPTESTMW + | VPTESTNMB + | VPTESTNMD + | VPTESTNMQ + | VPTESTNMW + | VPUNPCKHBW + | VPUNPCKHDQ + | VPUNPCKHQDQ + | VPUNPCKHWD + | VPUNPCKLBW + | VPUNPCKLDQ + | VPUNPCKLQDQ + | VPUNPCKLWD + | VPXOR + | VPXORD + | VPXORQ + | VRANGEPD + | VRANGEPS + | VRANGESD + | VRANGESS + | VRCP14PD + | VRCP14PS + | VRCP14SD + | VRCP14SS + | VRCP28PD + | VRCP28PS + | VRCP28SD + | VRCP28SS + | VRCPPH + | VRCPPS + | VRCPSH + | VRCPSS + | VREDUCEPD + | VREDUCEPH + | VREDUCEPS + | VREDUCESD + | VREDUCESH + | VREDUCESS + | VRNDSCALEPD + | VRNDSCALEPS + | VRNDSCALESD + | VRNDSCALESS + | VROUNDPD + | VROUNDPS + | VROUNDSD + | VROUNDSS + | VRSQRT14PD + | VRSQRT14PS + | VRSQRT14SD + | VRSQRT14SS + | VRSQRT28PD + | VRSQRT28PS + | VRSQRT28SD + | VRSQRT28SS + | VRSQRTPH + | VRSQRTPS + | VRSQRTSH + | VRSQRTSS + | VSCALEFPD + | VSCALEFPH + | VSCALEFPS + | VSCALEFSD + | VSCALEFSH + | VSCALEFSS + | VSCATTERDPD + | VSCATTERDPS + | VSCATTERPF0DPD + | VSCATTERPF0DPS + | VSCATTERPF0QPD + | VSCATTERPF0QPS + | VSCATTERPF1DPD + | VSCATTERPF1DPS + | VSCATTERPF1QPD + | VSCATTERPF1QPS + | VSCATTERQPD + | VSCATTERQPS + | VSHUFF32X4 + | VSHUFF64X2 + | VSHUFI32X4 + | VSHUFI64X2 + | VSHUFPD + | VSHUFPS + | VSQRTPD + | VSQRTPH + | VSQRTPS + | VSQRTSD + | VSQRTSH + | VSQRTSS + | VSTMXCSR + | VSUBPD + | VSUBPH + | VSUBPS + | VSUBSD + | VSUBSH + | VSUBSS + | VTESTPD + | VTESTPS + | VUCOMISD + | VUCOMISH + | VUCOMISS + | VUNPCKHPD + | VUNPCKHPS + | VUNPCKLPD + | VUNPCKLPS + | VXORPD + | VXORPS + | VZEROALL + | VZEROUPPER + | WBNOINVD + | WRFSBASE + | WRGSBASE + | WRMSRLIST + | WRMSRNS + | WRPKRU + | WRSSD + | WRSSQ + | WRUSSD + | WRUSSQ + | XABORT + | XBEGIN + | XCRYPTCBC + | XCRYPTCFB + | XCRYPTCTR + | XCRYPTECB + | XCRYPTOFB + | XEND + | XGETBV + | XORPD + | XORPS + | XRESLDTRK + | XRSTOR + | XRSTOR64 + | XRSTORS + | XRSTORS64 + | XSAVE + | XSAVE64 + | XSAVEC + | XSAVEC64 + | XSAVEOPT + | XSAVEOPT64 + | XSAVES + | XSAVES64 + | XSETBV + | XSHA1 + | XSHA256 + | XSTORE + | XSUSLDTRK + | XTEST + ; operand : (register COLON)? (register | name) - | (strict? size)? (string | float_number | integer | LEFT_BRACKET expression (COMMA expression)* RIGHT_BRACKET) + | (strict? size)? ( + string + | float_number + | integer + | LEFT_BRACKET expression (COMMA expression)* RIGHT_BRACKET + ) | expression ; -register: AL | AH | AX | EAX | RAX | BL | BH | BX | EBX | RBX | CL | CH | CX | ECX | RCX | DL | DH | DX | EDX | RDX | SPL | SP | ESP | RSP | BPL | BP | EBP | RBP | SIL | SI | ESI | RSI | DIL | DI | EDI | RDI | R8B | R9B | R10B | R11B | R12B | R13B | R14B | R15B | R8W | R9W | R10W | R11W | R12W | R13W | R14W | R15W | R8D | R9D | R10D | R11D | R12D | R13D | R14D | R15D | R8 | R9 | R10 | R11 | R12 | R13 | R14 | R15 | IP | EIP | RIP | ES | CS | SS | DS | FS | GS | SEGR6 | SEGR7 | CR0 | CR1 | CR2 | CR3 | CR4 | CR5 | CR6 | CR7 | CR8 | CR9 | CR10 | CR11 | CR12 | CR13 | CR14 | CR15 | DR0 | DR1 | DR2 | DR3 | DR4 | DR5 | DR6 | DR7 | DR8 | DR9 | DR10 | DR11 | DR12 | DR13 | DR14 | DR15 | TR0 | TR1 | TR2 | TR3 | TR4 | TR5 | TR6 | TR7 | ST0 | ST1 | ST2 | ST3 | ST4 | ST5 | ST6 | ST7 | MM0 | MM1 | MM2 | MM3 | MM4 | MM5 | MM6 | MM7 | XMM0 | XMM1 | XMM2 | XMM3 | XMM4 | XMM5 | XMM6 | XMM7 | XMM8 | XMM9 | XMM10 | XMM11 | XMM12 | XMM13 | XMM14 | XMM15 | XMM16 | XMM17 | XMM18 | XMM19 | XMM20 | XMM21 | XMM22 | XMM23 | XMM24 | XMM25 | XMM26 | XMM27 | XMM28 | XMM29 | XMM30 | XMM31 | YMM0 | YMM1 | YMM2 | YMM3 | YMM4 | YMM5 | YMM6 | YMM7 | YMM8 | YMM9 | YMM10 | YMM11 | YMM12 | YMM13 | YMM14 | YMM15 | YMM16 | YMM17 | YMM18 | YMM19 | YMM20 | YMM21 | YMM22 | YMM23 | YMM24 | YMM25 | YMM26 | YMM27 | YMM28 | YMM29 | YMM30 | YMM31 | ZMM0 | ZMM1 | ZMM2 | ZMM3 | ZMM4 | ZMM5 | ZMM6 | ZMM7 | ZMM8 | ZMM9 | ZMM10 | ZMM11 | ZMM12 | ZMM13 | ZMM14 | ZMM15 | ZMM16 | ZMM17 | ZMM18 | ZMM19 | ZMM20 | ZMM21 | ZMM22 | ZMM23 | ZMM24 | ZMM25 | ZMM26 | ZMM27 | ZMM28 | ZMM29 | ZMM30 | ZMM31 | TMM0 | TMM1 | TMM2 | TMM3 | TMM4 | TMM5 | TMM6 | TMM7 | K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7 | BND0 | BND1 | BND2 | BND3 ; +register + : AL + | AH + | AX + | EAX + | RAX + | BL + | BH + | BX + | EBX + | RBX + | CL + | CH + | CX + | ECX + | RCX + | DL + | DH + | DX + | EDX + | RDX + | SPL + | SP + | ESP + | RSP + | BPL + | BP + | EBP + | RBP + | SIL + | SI + | ESI + | RSI + | DIL + | DI + | EDI + | RDI + | R8B + | R9B + | R10B + | R11B + | R12B + | R13B + | R14B + | R15B + | R8W + | R9W + | R10W + | R11W + | R12W + | R13W + | R14W + | R15W + | R8D + | R9D + | R10D + | R11D + | R12D + | R13D + | R14D + | R15D + | R8 + | R9 + | R10 + | R11 + | R12 + | R13 + | R14 + | R15 + | IP + | EIP + | RIP + | ES + | CS + | SS + | DS + | FS + | GS + | SEGR6 + | SEGR7 + | CR0 + | CR1 + | CR2 + | CR3 + | CR4 + | CR5 + | CR6 + | CR7 + | CR8 + | CR9 + | CR10 + | CR11 + | CR12 + | CR13 + | CR14 + | CR15 + | DR0 + | DR1 + | DR2 + | DR3 + | DR4 + | DR5 + | DR6 + | DR7 + | DR8 + | DR9 + | DR10 + | DR11 + | DR12 + | DR13 + | DR14 + | DR15 + | TR0 + | TR1 + | TR2 + | TR3 + | TR4 + | TR5 + | TR6 + | TR7 + | ST0 + | ST1 + | ST2 + | ST3 + | ST4 + | ST5 + | ST6 + | ST7 + | MM0 + | MM1 + | MM2 + | MM3 + | MM4 + | MM5 + | MM6 + | MM7 + | XMM0 + | XMM1 + | XMM2 + | XMM3 + | XMM4 + | XMM5 + | XMM6 + | XMM7 + | XMM8 + | XMM9 + | XMM10 + | XMM11 + | XMM12 + | XMM13 + | XMM14 + | XMM15 + | XMM16 + | XMM17 + | XMM18 + | XMM19 + | XMM20 + | XMM21 + | XMM22 + | XMM23 + | XMM24 + | XMM25 + | XMM26 + | XMM27 + | XMM28 + | XMM29 + | XMM30 + | XMM31 + | YMM0 + | YMM1 + | YMM2 + | YMM3 + | YMM4 + | YMM5 + | YMM6 + | YMM7 + | YMM8 + | YMM9 + | YMM10 + | YMM11 + | YMM12 + | YMM13 + | YMM14 + | YMM15 + | YMM16 + | YMM17 + | YMM18 + | YMM19 + | YMM20 + | YMM21 + | YMM22 + | YMM23 + | YMM24 + | YMM25 + | YMM26 + | YMM27 + | YMM28 + | YMM29 + | YMM30 + | YMM31 + | ZMM0 + | ZMM1 + | ZMM2 + | ZMM3 + | ZMM4 + | ZMM5 + | ZMM6 + | ZMM7 + | ZMM8 + | ZMM9 + | ZMM10 + | ZMM11 + | ZMM12 + | ZMM13 + | ZMM14 + | ZMM15 + | ZMM16 + | ZMM17 + | ZMM18 + | ZMM19 + | ZMM20 + | ZMM21 + | ZMM22 + | ZMM23 + | ZMM24 + | ZMM25 + | ZMM26 + | ZMM27 + | ZMM28 + | ZMM29 + | ZMM30 + | ZMM31 + | TMM0 + | TMM1 + | TMM2 + | TMM3 + | TMM4 + | TMM5 + | TMM6 + | TMM7 + | K0 + | K1 + | K2 + | K3 + | K4 + | K5 + | K6 + | K7 + | BND0 + | BND1 + | BND2 + | BND3 + ; strict : STRICT ; macro_call - : name ( macro_param? (COMMA macro_param)* - | LEFT_PARENTHESIS macro_param? (COMMA macro_param)* RIGHT_PARENTHESIS - ) + : name ( + macro_param? (COMMA macro_param)* + | LEFT_PARENTHESIS macro_param? (COMMA macro_param)* RIGHT_PARENTHESIS + ) ; macro_param @@ -541,6 +3020,4 @@ macro_param | name | integer | float_number - ; - - + ; \ No newline at end of file diff --git a/asm/pdp7/pdp7.g4 b/asm/pdp7/pdp7.g4 index 31d2a2c681..465e8f52af 100644 --- a/asm/pdp7/pdp7.g4 +++ b/asm/pdp7/pdp7.g4 @@ -30,67 +30,77 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar pdp7; prog - : (line? eol)+ line? EOF - ; + : (line? eol)+ line? EOF + ; line - : declarations comment? | comment - ; + : declarations comment? + | comment + ; declarations - : declaration (';' declaration?)* - ; + : declaration (';' declaration?)* + ; // multiple labels can occur on the same line declaration - : label+ declarationRight* | declarationRight+ - ; + : label+ declarationRight* + | declarationRight+ + ; declarationRight - : instruction | assignment | expression - ; + : instruction + | assignment + | expression + ; instruction - : opcode argument* - ; + : opcode argument* + ; argument - : expression - ; + : expression + ; assignment - : symbol '=' expression - ; + : symbol '=' expression + ; // note that opcodes can be symbols. This is because it is legal to have a // variable name that is an opcode symbol - : opcode | variable | LOC | RELOC + : opcode + | variable + | LOC + | RELOC ; expression - : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* - ; + : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* + ; multiplyingExpression - : atom ((TIMES | DIV) atom)* - ; + : atom ((TIMES | DIV) atom)* + ; atom - : variable - | LOC - | CHAR - | RELOC - | string - | DECIMAL - | DECIMAL_MINUS - | OCTAL - | NUMERIC_LITERAL - | '-' atom - ; + : variable + | LOC + | CHAR + | RELOC + | string + | DECIMAL + | DECIMAL_MINUS + | OCTAL + | NUMERIC_LITERAL + | '-' atom + ; // string chars, then potentially more than 1 octal constant, then potentially '>' string @@ -98,192 +108,182 @@ string ; eol - : EOL - ; + : EOL + ; comment - : COMMENT - ; + : COMMENT + ; label - : LABEL - ; + : LABEL + ; variable - : IDENTIFIER - ; + : IDENTIFIER + ; opcode - : 'dac' - | 'jms' - | 'dzm' - | 'lac' - | 'xor' - | 'add' - | 'tad' - | 'xct' - | 'isz' - | 'and' - | 'sad' - | 'jmp' - | 'nop' -// | 'i' - | 'law' - | 'cma' - | 'las' - | 'ral' - | 'rar' - | 'hlt' - | 'sma' - | 'sza' - | 'snl' - | 'skp' - | 'sna' - | 'szl' - | 'rtl' - | 'rtr' - | 'cil' - | 'rcl' - | 'rcr' - | 'cia' - | 'lrs' - | 'lrss' - | 'lls' - | 'llss' - | 'als' - | 'alss' - | 'mul' - | 'idiv' - | 'lacq' - | 'clq' - | 'omq' - | 'cmq' - | 'lmq' - | 'dscs' - | 'dslw' - | 'dslm' - | 'dsld' - | 'dsls' - | 'dssf' - | 'dsrs' - | 'iof' - | 'ion' - | 'caf' - | 'clon' - | 'clsf' - | 'clof' - | 'ksf' - | 'krb' - | 'tsf' - | 'tcf' - | 'tls' - | 'sck' - | 'cck' - | 'lck' - | 'rsf' - | 'rsa' - | 'rrb' - | 'psf' - | 'pcf' - | 'psa' - | 'cdf' - | 'rlpd' - | 'lda' - | 'wcga' - | 'raef' - | 'rlpd' - | 'beg' - | 'spb' - | 'cpb' - | 'lpb' - | 'wbl' - | 'dprs' - | 'dpsf' - | 'dpcf' - | 'dprc' - | 'crsf' - | 'crrb' - | 'sys' - | 'czm' - | 'irss' - | 'dsm' - ; + : 'dac' + | 'jms' + | 'dzm' + | 'lac' + | 'xor' + | 'add' + | 'tad' + | 'xct' + | 'isz' + | 'and' + | 'sad' + | 'jmp' + | 'nop' + // | 'i' + | 'law' + | 'cma' + | 'las' + | 'ral' + | 'rar' + | 'hlt' + | 'sma' + | 'sza' + | 'snl' + | 'skp' + | 'sna' + | 'szl' + | 'rtl' + | 'rtr' + | 'cil' + | 'rcl' + | 'rcr' + | 'cia' + | 'lrs' + | 'lrss' + | 'lls' + | 'llss' + | 'als' + | 'alss' + | 'mul' + | 'idiv' + | 'lacq' + | 'clq' + | 'omq' + | 'cmq' + | 'lmq' + | 'dscs' + | 'dslw' + | 'dslm' + | 'dsld' + | 'dsls' + | 'dssf' + | 'dsrs' + | 'iof' + | 'ion' + | 'caf' + | 'clon' + | 'clsf' + | 'clof' + | 'ksf' + | 'krb' + | 'tsf' + | 'tcf' + | 'tls' + | 'sck' + | 'cck' + | 'lck' + | 'rsf' + | 'rsa' + | 'rrb' + | 'psf' + | 'pcf' + | 'psa' + | 'cdf' + | 'rlpd' + | 'lda' + | 'wcga' + | 'raef' + | 'rlpd' + | 'beg' + | 'spb' + | 'cpb' + | 'lpb' + | 'wbl' + | 'dprs' + | 'dpsf' + | 'dpcf' + | 'dprc' + | 'crsf' + | 'crrb' + | 'sys' + | 'czm' + | 'irss' + | 'dsm' + ; LOC - : '.' - ; - + : '.' + ; RELOC - : '..' - ; - + : '..' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; TIMES - : '*' - ; - + : '*' + ; DIV - : '/' - ; - + : '/' + ; LABEL - : [a-zA-Z0-9.] + ':' - ; - + : [a-zA-Z0-9.]+ ':' + ; // the period is considered a letter IDENTIFIER - : [a-zA-Z] [a-zA-Z0-9.]* - ; - + : [a-zA-Z] [a-zA-Z0-9.]* + ; NUMERIC_LITERAL - : [0-9][0-9a-f]* - ; + : [0-9][0-9a-f]* + ; DECIMAL - : 'd' [0-9] + - ; + : 'd' [0-9]+ + ; OCTAL - : 'o' [0-7] + - ; + : 'o' [0-7]+ + ; DECIMAL_MINUS - : 'dm' [0-9] + - ; + : 'dm' [0-9]+ + ; STRING - : '<' [a-zA-Z0-9$*,%/:?#@.]* - ; + : '<' [a-zA-Z0-9$*,%/:?#@.]* + ; CHAR - : [a-zA-Z0-9>.] '>' + : [a-zA-Z0-9>.] '>' ; - -COMMENT - : '"' ~ [\r\n]* - ; +COMMENT + : '"' ~ [\r\n]* + ; EOL - : [\r\n]+ - ; - + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/asm/ptx/ptx-isa-1.0/PTXLexer.g4 b/asm/ptx/ptx-isa-1.0/PTXLexer.g4 index ed93f5bb76..b23215e9b0 100644 --- a/asm/ptx/ptx-isa-1.0/PTXLexer.g4 +++ b/asm/ptx/ptx-isa-1.0/PTXLexer.g4 @@ -30,280 +30,253 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PTXLexer; //------------------ -ALIGN : '.align'; -BYTE : '.byte'; -CONST : '.const'; -ENTRY : '.entry'; -EXTERN : '.extern'; -FILE : '.file'; -FUNC : '.func'; -GLOBAL : '.global'; -LOCAL : '.local'; -LOC : '.loc'; -PARAM : '.param'; -REG : '.reg'; -SECTION : '.section'; -SHARED : '.shared'; -SREG : '.sreg'; -STRUCT : '.struct'; -SURF : '.surf'; -TARGET : '.target'; -DOT_TEX : '.tex'; -UNION : '.union'; -VERSION : '.version' -> mode(V); -VISIBLE : '.visible'; +ALIGN : '.align'; +BYTE : '.byte'; +CONST : '.const'; +ENTRY : '.entry'; +EXTERN : '.extern'; +FILE : '.file'; +FUNC : '.func'; +GLOBAL : '.global'; +LOCAL : '.local'; +LOC : '.loc'; +PARAM : '.param'; +REG : '.reg'; +SECTION : '.section'; +SHARED : '.shared'; +SREG : '.sreg'; +STRUCT : '.struct'; +SURF : '.surf'; +TARGET : '.target'; +DOT_TEX : '.tex'; +UNION : '.union'; +VERSION : '.version' -> mode(V); +VISIBLE : '.visible'; //--------------------- -S8 : '.s8'; -S16 : '.s16'; -S32 : '.s32'; -S64 : '.s64'; -U8 : '.u8'; -U16 : '.u16'; -U32 : '.u32'; -U64 : '.u64'; -F16 : '.f16'; -F32 : '.f32'; -F64 : '.f64'; -B8 : '.b8'; -B16 : '.b16'; -B32 : '.b32'; -B64 : '.b64'; -PRED : '.pred'; -V2 : '.v2'; -V3 : '.v3'; -V4 : '.v4'; - -SM_10 : 'sm_10'; -SM_11 : 'sm_11'; -SM_12 : 'sm_12'; -SM_13 : 'sm_13'; -COMPUTE_10 : 'compute_10'; -COMPUTE_11 : 'compute_11'; +S8 : '.s8'; +S16 : '.s16'; +S32 : '.s32'; +S64 : '.s64'; +U8 : '.u8'; +U16 : '.u16'; +U32 : '.u32'; +U64 : '.u64'; +F16 : '.f16'; +F32 : '.f32'; +F64 : '.f64'; +B8 : '.b8'; +B16 : '.b16'; +B32 : '.b32'; +B64 : '.b64'; +PRED : '.pred'; +V2 : '.v2'; +V3 : '.v3'; +V4 : '.v4'; + +SM_10 : 'sm_10'; +SM_11 : 'sm_11'; +SM_12 : 'sm_12'; +SM_13 : 'sm_13'; +COMPUTE_10 : 'compute_10'; +COMPUTE_11 : 'compute_11'; // platform option DEBUG : 'debug'; MAP_F64_TO_F32 : 'map_f64_to_f32'; // instruction keyword -ABS : 'abs'; -ADD : 'add'; -ADDC : 'addc'; -AND : 'and'; -ATOM : 'atom'; -BAR : 'bar'; -BRA : 'bra'; -BRKPT : 'brkpt'; -CALL : 'call'; -CNOT : 'cnot'; -COS : 'cos'; -CROSS : 'cross'; -CVT : 'cvt'; -DIV : 'div'; -DOT : 'dot'; -EX2 : 'ex2'; -EXIT : 'exit'; -EXTRACT : 'extract'; -FMA : 'fma'; -FRC : 'frc'; -INSERT : 'insert'; -LD : 'ld'; -LG2 : 'lg2'; -MAD : 'mad'; -MAD24 : 'mad24'; -MAX : 'max'; -MEMBAR : 'membar'; -MIN : 'min'; -MOV : 'mov'; -MUL : 'mul'; -MUL24 : 'mul24'; -NEG : 'neg'; -NOP : 'nop'; -NOT : 'not'; -OR : 'or'; -RCP : 'rcp'; -REM : 'rem'; -RET : 'ret'; -RSQRT : 'rsqrt'; -SAD : 'sad'; -SELP : 'selp'; -SET : 'set'; -SETP : 'setp'; -SHL : 'shl'; -SHR : 'shr'; -SIN : 'sin'; -SLCT : 'slct'; -SQRT : 'sqrt'; -ST : 'st'; -SUB : 'sub'; -SUBC : 'subc'; -TEX : 'tex'; -TRAP : 'trap'; -VOTE : 'vote'; -VRED : 'vred'; -XOR : 'xor'; +ABS : 'abs'; +ADD : 'add'; +ADDC : 'addc'; +AND : 'and'; +ATOM : 'atom'; +BAR : 'bar'; +BRA : 'bra'; +BRKPT : 'brkpt'; +CALL : 'call'; +CNOT : 'cnot'; +COS : 'cos'; +CROSS : 'cross'; +CVT : 'cvt'; +DIV : 'div'; +DOT : 'dot'; +EX2 : 'ex2'; +EXIT : 'exit'; +EXTRACT : 'extract'; +FMA : 'fma'; +FRC : 'frc'; +INSERT : 'insert'; +LD : 'ld'; +LG2 : 'lg2'; +MAD : 'mad'; +MAD24 : 'mad24'; +MAX : 'max'; +MEMBAR : 'membar'; +MIN : 'min'; +MOV : 'mov'; +MUL : 'mul'; +MUL24 : 'mul24'; +NEG : 'neg'; +NOP : 'nop'; +NOT : 'not'; +OR : 'or'; +RCP : 'rcp'; +REM : 'rem'; +RET : 'ret'; +RSQRT : 'rsqrt'; +SAD : 'sad'; +SELP : 'selp'; +SET : 'set'; +SETP : 'setp'; +SHL : 'shl'; +SHR : 'shr'; +SIN : 'sin'; +SLCT : 'slct'; +SQRT : 'sqrt'; +ST : 'st'; +SUB : 'sub'; +SUBC : 'subc'; +TEX : 'tex'; +TRAP : 'trap'; +VOTE : 'vote'; +VRED : 'vred'; +XOR : 'xor'; // predefined identifiers -CLOCK : '%clock'; -LANEID : '%laneid'; -PM : '%pm'[0-3]; -NCTAID : '%nctaid.' [012]; -SMID : '%smid'; -CTAID : '%ctaid.' [012]; -NTID : '%ntid.' [012]; -TID : '%tid.' [012]; -NSMID : '%nsmid'; -WARPID : '%warpid'; -GRIDID : '%gridid'; -WARP_SZ : 'WARP_SZ'; - -RN : '.rn'; -RZ : '.rz'; -RM : '.rm'; -RP : '.rp'; - -RNI : '.rni'; -RZI : '.rzi'; -RMI : '.rmi'; -RPI : '.rpi'; - -SAT : '.sat'; -UNI : '.uni'; - -LT : '.lt'; -GT : '.gt'; -LE : '.le'; -GE : '.ge'; -NE : '.ne'; -EQ : '.eq'; -LS : '.ls'; -HS : '.hs'; -EQU : '.equ'; -NEU : '.neu'; -LTU : '.ltu'; -LEU : '.leu'; -GTU : '.gtu'; -GEU : '.geu'; -NUM : '.num'; -NAN_ : '.nan'; -HI : '.hi'; -LO : '.lo'; -WIDE : '.wide'; - -G1D : '.1d'; -G2D : '.2d'; -G3D : '.3d'; - -SYNC : '.sync'; -INC : '.inc'; -DEC : '.dec'; -CAS : '.cas'; -EXCH : '.exch'; - -DOT_AND : '.and'; -DOT_OR : '.or'; -DOT_XOR : '.xor'; +CLOCK : '%clock'; +LANEID : '%laneid'; +PM : '%pm' [0-3]; +NCTAID : '%nctaid.' [012]; +SMID : '%smid'; +CTAID : '%ctaid.' [012]; +NTID : '%ntid.' [012]; +TID : '%tid.' [012]; +NSMID : '%nsmid'; +WARPID : '%warpid'; +GRIDID : '%gridid'; +WARP_SZ : 'WARP_SZ'; + +RN : '.rn'; +RZ : '.rz'; +RM : '.rm'; +RP : '.rp'; + +RNI : '.rni'; +RZI : '.rzi'; +RMI : '.rmi'; +RPI : '.rpi'; + +SAT : '.sat'; +UNI : '.uni'; + +LT : '.lt'; +GT : '.gt'; +LE : '.le'; +GE : '.ge'; +NE : '.ne'; +EQ : '.eq'; +LS : '.ls'; +HS : '.hs'; +EQU : '.equ'; +NEU : '.neu'; +LTU : '.ltu'; +LEU : '.leu'; +GTU : '.gtu'; +GEU : '.geu'; +NUM : '.num'; +NAN_ : '.nan'; +HI : '.hi'; +LO : '.lo'; +WIDE : '.wide'; + +G1D : '.1d'; +G2D : '.2d'; +G3D : '.3d'; + +SYNC : '.sync'; +INC : '.inc'; +DEC : '.dec'; +CAS : '.cas'; +EXCH : '.exch'; + +DOT_AND : '.and'; +DOT_OR : '.or'; +DOT_XOR : '.xor'; //#include, #define, #if, #ifdef, #else, #endif, #line, #file -LABEL - : [a-zA-Z0-9$_] + ':' - ; - -IDENTIFIER - : [a-zA-Z] [a-zA-Z0-9_$]* - | [_$%] [a-zA-Z0-9_$]+ - ; - -PARAM_VAR_NAME - : '%' IDENTIFIER '<' DECIMAL_LITERAL '>' - ; - -fragment DIGIT - : [0-9] - ; - -fragment BIT - : [01] - ; - -fragment HEX_DIGIT - : [0-9a-fA-F] - ; - -HEXADECIMAL_LITERAL - : '0' [xX] HEX_DIGIT+ 'U'? - ; - -DECIMAL_LITERAL - : ([1-9] DIGIT* | '0') 'U'? - ; - -BINARY_LITERAL - : '0' [bB] BIT+ 'U'? - ; - -OCTAL_LITERAL - : '0' [0-7]+ 'U'? - ; - -REAL_LITERAL - : ([1-9] DIGIT* | '0') '.' DIGIT* - | '.' DIGIT+ - ; - -SINGLE_PRECISION_FLOATING_POINT_LITERAL - : '0' [fF] HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - ; - -DOUBLE_PRECISION_FLOATING_POINT_LITERAL - : '0' [dD] HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - ; - -LCB : '{'; -RCB : '}'; -LRP : '('; -RRP : ')'; -LSB : '['; -RSB : ']'; -PLUS : '+'; -MINUS : '-'; -NEG_OP : '~'; -SEMI : ';'; -AT_OP : '@'; -EM_OP : '!'; -MOD_OP : '%'; -STAR : '*'; -DIV_OP : '/'; -AND_OP : '&'; -OR_OP : '|'; -XOR_OP : '^'; -QM_OP : '?'; -COLON : ':'; -ASSIGN : '='; -BIT_BUCKET : '_'; -COMMA : ','; -DOT_OP : '.'; - -WS : [ \n\r\t] -> channel(HIDDEN); -SINGLE_LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); -MULTI_LINE_COMMENT : '/*' .*? '*/' -> channel(HIDDEN); +LABEL: [a-zA-Z0-9$_]+ ':'; + +IDENTIFIER: [a-zA-Z] [a-zA-Z0-9_$]* | [_$%] [a-zA-Z0-9_$]+; + +PARAM_VAR_NAME: '%' IDENTIFIER '<' DECIMAL_LITERAL '>'; + +fragment DIGIT: [0-9]; + +fragment BIT: [01]; + +fragment HEX_DIGIT: [0-9a-fA-F]; + +HEXADECIMAL_LITERAL: '0' [xX] HEX_DIGIT+ 'U'?; + +DECIMAL_LITERAL: ([1-9] DIGIT* | '0') 'U'?; + +BINARY_LITERAL: '0' [bB] BIT+ 'U'?; + +OCTAL_LITERAL: '0' [0-7]+ 'U'?; + +REAL_LITERAL: ([1-9] DIGIT* | '0') '.' DIGIT* | '.' DIGIT+; + +SINGLE_PRECISION_FLOATING_POINT_LITERAL: + '0' [fF] HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT +; + +DOUBLE_PRECISION_FLOATING_POINT_LITERAL: + '0' [dD] HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT + HEX_DIGIT HEX_DIGIT HEX_DIGIT +; + +LCB : '{'; +RCB : '}'; +LRP : '('; +RRP : ')'; +LSB : '['; +RSB : ']'; +PLUS : '+'; +MINUS : '-'; +NEG_OP : '~'; +SEMI : ';'; +AT_OP : '@'; +EM_OP : '!'; +MOD_OP : '%'; +STAR : '*'; +DIV_OP : '/'; +AND_OP : '&'; +OR_OP : '|'; +XOR_OP : '^'; +QM_OP : '?'; +COLON : ':'; +ASSIGN : '='; +BIT_BUCKET : '_'; +COMMA : ','; +DOT_OP : '.'; + +WS : [ \n\r\t] -> channel(HIDDEN); +SINGLE_LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); +MULTI_LINE_COMMENT : '/*' .*? '*/' -> channel(HIDDEN); mode V; -DECIMAL_LITERAL_V - : ([1-9] DIGIT* | '0') 'U'? -> type(DECIMAL_LITERAL) - ; +DECIMAL_LITERAL_V: ([1-9] DIGIT* | '0') 'U'? -> type(DECIMAL_LITERAL); -VER - : DECIMAL_LITERAL '.' DECIMAL_LITERAL -> mode(DEFAULT_MODE) - ; +VER: DECIMAL_LITERAL '.' DECIMAL_LITERAL -> mode(DEFAULT_MODE); -V_WS : [ \n\r\t] -> type(WS), channel(HIDDEN); +V_WS: [ \n\r\t] -> type(WS), channel(HIDDEN); \ No newline at end of file diff --git a/asm/ptx/ptx-isa-1.0/PTXParser.g4 b/asm/ptx/ptx-isa-1.0/PTXParser.g4 index 5c639e821e..140447ad9f 100644 --- a/asm/ptx/ptx-isa-1.0/PTXParser.g4 +++ b/asm/ptx/ptx-isa-1.0/PTXParser.g4 @@ -30,14 +30,17 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 PTXParser; -options { tokenVocab=PTXLexer; } +options { + tokenVocab = PTXLexer; +} prog - : version_directive - target_directive+ - line* EOF + : version_directive target_directive+ line* EOF ; version_directive @@ -71,10 +74,7 @@ line ; directive - : ( CONST - | GLOBAL - | LOCAL - | SHARED) var_decl + : (CONST | GLOBAL | LOCAL | SHARED) var_decl | REG vector_type? built_in_type id_list initializer? | SREG vector_type? built_in_type? special_register | state_space? STRUCT alignment? id_ ('{' struct_field_list '}' | id_) @@ -104,8 +104,8 @@ special_register debugging_directive : SECTION /*section_type, section_name*/ - | FILE filename=IDENTIFIER - | LOC line_number=DECIMAL_LITERAL + | FILE filename = IDENTIFIER + | LOC line_number = DECIMAL_LITERAL | BYTE data_list ; @@ -184,64 +184,66 @@ data_type ; instruction - : ABS data_type d=operand ',' a=operand - | ADD rounding_mode? SAT? data_type d=operand ',' a=operand ',' b=operand - | AND data_type d=operand ',' a=operand ',' b=operand - | ATOM space '.' op=operation data_type d=operand ',' a=operand ',' b=operand (',' c=operand)? - | BAR SYNC? d=operand - | BRA UNI? tgt=id_ + : ABS data_type d = operand ',' a = operand + | ADD rounding_mode? SAT? data_type d = operand ',' a = operand ',' b = operand + | AND data_type d = operand ',' a = operand ',' b = operand + | ATOM space '.' op = operation data_type d = operand ',' a = operand ',' b = operand ( + ',' c = operand + )? + | BAR SYNC? d = operand + | BRA UNI? tgt = id_ | BRKPT - | CALL UNI? ('(' r=operand ')' ',')? fn=id_ (',' '(' operand (',' operand)* ')')? - | CNOT data_type d=operand ',' a=operand - | COS data_type d=operand ',' a=operand + | CALL UNI? ('(' r = operand ')' ',')? fn = id_ (',' '(' operand (',' operand)* ')')? + | CNOT data_type d = operand ',' a = operand + | COS data_type d = operand ',' a = operand | CROSS - | CVT rounding_mode? SAT? dt=data_type at=data_type d=operand ',' a=operand - | DIV WIDE? rounding_mode? SAT? data_type d=operand ',' a=operand ',' b=operand + | CVT rounding_mode? SAT? dt = data_type at = data_type d = operand ',' a = operand + | DIV WIDE? rounding_mode? SAT? data_type d = operand ',' a = operand ',' b = operand | DOT - | EX2 data_type d=operand ',' a=operand + | EX2 data_type d = operand ',' a = operand | EXIT | EXTRACT - | FRC data_type d=operand ',' a=operand + | FRC data_type d = operand ',' a = operand | INSERT - | LD space t=data_type d=operand ',' a=operand - | LD space vec t=data_type d=operand ',' a=operand - | LG2 data_type d=operand ',' a=operand - | MAD (HI | LO | WIDE)? rounding_mode? SAT? data_type d=operand ',' a=operand ',' b=operand ',' c=operand - | MAD24 (HI | LO)? SAT? data_type d=operand ',' a=operand ',' b=operand ',' c=operand - | MAX data_type d=operand ',' a=operand ',' b=operand + | LD space t = data_type d = operand ',' a = operand + | LD space vec t = data_type d = operand ',' a = operand + | LG2 data_type d = operand ',' a = operand + | MAD (HI | LO | WIDE)? rounding_mode? SAT? data_type d = operand ',' a = operand ',' b = operand ',' c = operand + | MAD24 (HI | LO)? SAT? data_type d = operand ',' a = operand ',' b = operand ',' c = operand + | MAX data_type d = operand ',' a = operand ',' b = operand | MEMBAR - | MIN data_type d=operand ',' a=operand ',' b=operand - | MOV data_type d=operand ',' a=operand - | MUL (HI | LO | WIDE)? rounding_mode? SAT? data_type d=operand ',' a=operand ',' b=operand - | MUL24 (HI | LO)? data_type d=operand ',' a=operand ',' b=operand - | NEG data_type d=operand ',' a=operand + | MIN data_type d = operand ',' a = operand ',' b = operand + | MOV data_type d = operand ',' a = operand + | MUL (HI | LO | WIDE)? rounding_mode? SAT? data_type d = operand ',' a = operand ',' b = operand + | MUL24 (HI | LO)? data_type d = operand ',' a = operand ',' b = operand + | NEG data_type d = operand ',' a = operand | NOP - | NOT data_type d=operand ',' a=operand - | OR data_type d=operand ',' a=operand ',' b=operand - | RCP data_type d=operand ',' a=operand - | REM WIDE? data_type d=operand ',' a=operand ',' b=operand + | NOT data_type d = operand ',' a = operand + | OR data_type d = operand ',' a = operand ',' b = operand + | RCP data_type d = operand ',' a = operand + | REM WIDE? data_type d = operand ',' a = operand ',' b = operand | RET UNI? - | RSQRT data_type d=operand ',' a=operand - | SAD rounding_mode? data_type d=operand ',' a=operand ',' b=operand ',' c=operand - | SELP data_type d=operand ',' a=operand ',' b=operand ',' c=operand - | SET cmp_op dt=data_type st=data_type d=operand ',' a=operand ',' b=operand - | SET cmp_op bool_op dt=data_type st=data_type d=operand ',' a=operand ',' b=operand ',' '!'? c=operand - | SETP cmp_op data_type p=operand ('|' q=operand)? ',' a=operand ',' b=operand - | SETP cmp_op bool_op data_type p=operand ('|' q=operand)? ',' a=operand ',' b=operand ',' '!'? c=operand - | SHL data_type d=operand ',' a=operand ',' b=operand - | SHR data_type d=operand ',' a=operand ',' b=operand - | SIN data_type d=operand ',' a=operand - | SLCT dt=data_type ct=data_type d=operand ',' a=operand ',' b=operand ',' c=operand - | SQRT data_type d=operand ',' a=operand - | ST space t=data_type d=operand ',' a=operand - | ST space vec t=data_type d=operand ',' a=operand - | SUB rounding_mode? SAT? data_type d=operand ',' a=operand ',' b=operand - | TEX geom dt=data_type bt=data_type d=operand ',' a=operand ',' b=operand + | RSQRT data_type d = operand ',' a = operand + | SAD rounding_mode? data_type d = operand ',' a = operand ',' b = operand ',' c = operand + | SELP data_type d = operand ',' a = operand ',' b = operand ',' c = operand + | SET cmp_op dt = data_type st = data_type d = operand ',' a = operand ',' b = operand + | SET cmp_op bool_op dt = data_type st = data_type d = operand ',' a = operand ',' b = operand ',' '!'? c = operand + | SETP cmp_op data_type p = operand ('|' q = operand)? ',' a = operand ',' b = operand + | SETP cmp_op bool_op data_type p = operand ('|' q = operand)? ',' a = operand ',' b = operand ',' '!'? c = operand + | SHL data_type d = operand ',' a = operand ',' b = operand + | SHR data_type d = operand ',' a = operand ',' b = operand + | SIN data_type d = operand ',' a = operand + | SLCT dt = data_type ct = data_type d = operand ',' a = operand ',' b = operand ',' c = operand + | SQRT data_type d = operand ',' a = operand + | ST space t = data_type d = operand ',' a = operand + | ST space vec t = data_type d = operand ',' a = operand + | SUB rounding_mode? SAT? data_type d = operand ',' a = operand ',' b = operand + | TEX geom dt = data_type bt = data_type d = operand ',' a = operand ',' b = operand | TRAP | VOTE | VRED - | XOR data_type d=operand ',' a=operand ',' b=operand - | '{' instruction_list? '}' + | XOR data_type d = operand ',' a = operand ',' b = operand + | '{' instruction_list? '}' ; instruction_list @@ -257,7 +259,7 @@ operation | ADD | MIN | MAX - | CAS //compare and swap + | CAS //compare and swap | EXCH //exchange ; @@ -410,4 +412,4 @@ floating_point_constant : SINGLE_PRECISION_FLOATING_POINT_LITERAL | DOUBLE_PRECISION_FLOATING_POINT_LITERAL | REAL_LITERAL - ; + ; \ No newline at end of file diff --git a/asm/ptx/ptx-isa-2.1/Ptx.g4 b/asm/ptx/ptx-isa-2.1/Ptx.g4 index a28a02103e..6f3434218c 100644 --- a/asm/ptx/ptx-isa-2.1/Ptx.g4 +++ b/asm/ptx/ptx-isa-2.1/Ptx.g4 @@ -22,6 +22,9 @@ */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Ptx; prog @@ -57,9 +60,7 @@ statement ; label_decl - : - i=T_WORD - T_COLON + : i = T_WORD T_COLON ; /************************************************************************************** @@ -70,12 +71,7 @@ label_decl ***************************************************************************************/ semicolon_terminated_statement - : ( - semicolon_terminated_directive - | instruction - | linking_directive - ) - T_SEMICOLON + : (semicolon_terminated_directive | instruction | linking_directive) T_SEMICOLON | pragma ; @@ -96,14 +92,11 @@ unterminated_directive ; entry - : - a=entry_aux + : a = entry_aux ; entry_aux - : - (K_VISIBLE | K_EXTERN )? - K_ENTRY kernel_name ( T_OP entry_param_list? T_CP )? performance_tuning_directives? entry_body + : (K_VISIBLE | K_EXTERN)? K_ENTRY kernel_name (T_OP entry_param_list? T_CP)? performance_tuning_directives? entry_body ; kernel_name @@ -123,7 +116,7 @@ entry_space ; align - : K_ALIGN b=byte_count + : K_ALIGN b = byte_count ; texref @@ -131,7 +124,9 @@ texref ; byte_count - : base_10_integer | base_8_integer | base_16_integer + : base_10_integer + | base_8_integer + | base_16_integer ; entry_param_type @@ -140,13 +135,11 @@ entry_param_type ; entry_body - : - T_OC statement* T_CC + : T_OC statement* T_CC ; fundamental_type - : - a=fundamental_type_aux + : a = fundamental_type_aux ; fundamental_type_aux @@ -169,20 +162,16 @@ fundamental_type_aux ; vector_type - : - v=vector_type_aux - f=fundamental_type + : v = vector_type_aux f = fundamental_type ; vector_type_aux - : - K_V4 + : K_V4 | K_V2 ; opaque_type - : - a=opaque_type_aux + : a = opaque_type_aux ; opaque_type_aux @@ -192,17 +181,13 @@ opaque_type_aux ; func - : a=func_aux + : a = func_aux ; func_aux - : - (K_VISIBLE | K_EXTERN )? - K_FUNC - ( T_OP func_ret_list? T_CP )? - func_name - ( T_OP func_param_list? T_CP )? - func_body? + : (K_VISIBLE | K_EXTERN)? K_FUNC (T_OP func_ret_list? T_CP)? func_name ( + T_OP func_param_list? T_CP + )? func_body? ; func_name @@ -210,7 +195,7 @@ func_name ; func_ret_list - : func_ret ( T_COMMA func_ret )* + : func_ret (T_COMMA func_ret)* ; func_ret @@ -227,7 +212,7 @@ func_ret_type ; func_param_list - : func_param ( T_COMMA func_param )* ( T_ELLIPSIS )? + : func_param (T_COMMA func_param)* (T_ELLIPSIS)? ; func_param @@ -258,7 +243,7 @@ branch_targets ; list_of_labels - : opr ( T_COMMA opr )* + : opr (T_COMMA opr)* ; call_targets @@ -266,11 +251,13 @@ call_targets ; call_prototype - : label_decl K_CALLPROTOTYPE ( T_OP call_param_list? T_CP)? T_UNDERSCORE ( T_OP call_param_list? T_CP )? + : label_decl K_CALLPROTOTYPE (T_OP call_param_list? T_CP)? T_UNDERSCORE ( + T_OP call_param_list? T_CP + )? ; call_param_list - : call_param ( T_COMMA call_param )* + : call_param (T_COMMA call_param)* ; call_param @@ -287,7 +274,7 @@ call_param_type ; performance_tuning_directives - : ( performance_tuning_directive )+ + : (performance_tuning_directive)+ ; performance_tuning_directive @@ -304,11 +291,11 @@ maxnreg ; maxntid - : K_MAXNTID integer ( T_COMMA integer ( T_COMMA integer )? )? + : K_MAXNTID integer (T_COMMA integer ( T_COMMA integer)?)? ; reqntid - : K_REQNTID integer ( T_COMMA integer ( T_COMMA integer )? )? + : K_REQNTID integer (T_COMMA integer ( T_COMMA integer)?)? ; minnctapersm @@ -335,32 +322,42 @@ debugging_directive ; dwarf - : a=K_DWARF + : a = K_DWARF ; file - : a=K_FILE b=integer c=T_STRING (T_COMMA integer)* + : a = K_FILE b = integer c = T_STRING (T_COMMA integer)* ; section - : a=K_SECTION - section_name - T_OC - data_declarator_list* - T_CC + : a = K_SECTION section_name T_OC data_declarator_list* T_CC ; section_name - : T_WORD | U_DEBUG_ABBREV | U_DEBUG_INFO | U_DEBUG_LINE | (U_DEBUG_LOC (T_PLUS integer)?) | U_DEBUG_PUBNAMES | U_DEBUG_RANGES + : T_WORD + | U_DEBUG_ABBREV + | U_DEBUG_INFO + | U_DEBUG_LINE + | (U_DEBUG_LOC (T_PLUS integer)?) + | U_DEBUG_PUBNAMES + | U_DEBUG_RANGES ; data_declarator_list - : type - (integer | T_WORD | U_DEBUG_ABBREV | U_DEBUG_INFO | U_DEBUG_LINE | (U_DEBUG_LOC (T_PLUS integer)?) | U_DEBUG_PUBNAMES | U_DEBUG_RANGES) + : type ( + integer + | T_WORD + | U_DEBUG_ABBREV + | U_DEBUG_INFO + | U_DEBUG_LINE + | (U_DEBUG_LOC (T_PLUS integer)?) + | U_DEBUG_PUBNAMES + | U_DEBUG_RANGES + ) ; loc - : a=K_LOC b=integer c=integer d=integer + : a = K_LOC b = integer c = integer d = integer ; linking_directive @@ -369,9 +366,7 @@ linking_directive ; extern_ - : - K_EXTERN - i=identifier_decl + : K_EXTERN i = identifier_decl ; visible @@ -379,36 +374,32 @@ visible ; identifier_decl - : - a=identifier_decl_aux + : a = identifier_decl_aux ; identifier_decl_aux - : (state_space_specifier | global_space_specifier | const_space_specifier) - align? type? texref? - (variable_declarator_list_ | variable_declarator+) T_SEMICOLON? + : (state_space_specifier | global_space_specifier | const_space_specifier) align? type? texref? ( + variable_declarator_list_ + | variable_declarator+ + ) T_SEMICOLON? ; variable_declarator_list_ - : type (variable_declarator | variable_declarator_with_initializer) ( T_COMMA (variable_declarator | variable_declarator_with_initializer) )* + : type (variable_declarator | variable_declarator_with_initializer) ( + T_COMMA (variable_declarator | variable_declarator_with_initializer) + )* ; variable_declarator - : id_or_opcode - ( - array_spec - | parameterized_register_spec - )? + : id_or_opcode (array_spec | parameterized_register_spec)? ; array_spec - : - i=array_spec_aux + : i = array_spec_aux ; array_spec_aux - : - ( T_OB integer? T_CB )+ + : (T_OB integer? T_CB)+ ; parameterized_register_spec @@ -509,21 +500,15 @@ variable_declarator_with_initializer ; equal_initializer - : - T_EQ variable_initializer - ; + : T_EQ variable_initializer + ; variable_initializer - : ( aggregate_initializer | constant_expression | id_or_opcode ) + : (aggregate_initializer | constant_expression | id_or_opcode) ; aggregate_initializer - : T_OC - (variable_initializer - (T_COMMA variable_initializer - )* - )? - T_CC + : T_OC (variable_initializer (T_COMMA variable_initializer)*)? T_CC ; type @@ -538,8 +523,7 @@ id ; state_space_specifier - : - a=state_space_specifier_aux + : a = state_space_specifier_aux ; state_space_specifier_aux @@ -553,11 +537,11 @@ state_space_specifier_aux ; global_space_specifier - : a=global + : a = global ; const_space_specifier - : a=const_ + : a = const_ ; const_ @@ -623,13 +607,11 @@ tex //////////////////////////////////////////////////////////////////////////////////////////////////// instruction - : - a=instruction_aux + : a = instruction_aux ; instruction_aux - : predicate? - ( + : predicate? ( i_abs | i_add | i_addc @@ -717,124 +699,85 @@ predicate ; i_abs - : - i=KI_ABS - t=i_abs_type - o=i_abs_opr + : i = KI_ABS t = i_abs_type o = i_abs_opr ; i_abs_type - : - ( - ( - K_S16 | K_S32 | K_S64 - ) | - ( - K_FTZ? K_F32 - ) | - ( - K_F64 - ) - ) + : (( K_S16 | K_S32 | K_S64) | ( K_FTZ? K_F32) | ( K_F64)) ; i_abs_opr - : - ( - opr_register - T_COMMA - opr_register_or_constant - ) + : (opr_register T_COMMA opr_register_or_constant) ; i_add - : - i=KI_ADD - t=i_add_type - o=i_add_opr + : i = KI_ADD t = i_add_type o = i_add_opr ; -i_add_type: - ( - ( - ( ( K_SAT K_S32 ) | ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) ) | - ( K_CC ( K_S32 | K_U32 ) ) - ) | +i_add_type + : ( ( - ( K_RN | K_RZ | K_RM | K_RP )? K_FTZ? K_SAT? K_F32 - ) | - ( ( K_RN | K_RZ | K_RM | K_RP )? K_F64 ) + (( K_SAT K_S32) | ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64)) + | ( K_CC ( K_S32 | K_U32)) + ) + | ( ( K_RN | K_RZ | K_RM | K_RP)? K_FTZ? K_SAT? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP)? K_F64) ) ; i_add_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_addc - : - i=KI_ADDC - t=i_addc_type - o=i_addc_opr + : i = KI_ADDC t = i_addc_type o = i_addc_opr ; -i_addc_type: - ( - ( - K_CC? ( K_S32 | K_U32 | K_S16 | K_U16 | K_U64 ) - ) - ) +i_addc_type + : (( K_CC? ( K_S32 | K_U32 | K_S16 | K_U16 | K_U64))) ; i_addc_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_and - : - i=KI_AND - t=i_and_type - o=i_and_opr + : i = KI_AND t = i_and_type o = i_and_opr ; -i_and_type: - ( - K_PRED | K_B16 | K_B32 | K_B64 - ) +i_and_type + : (K_PRED | K_B16 | K_B32 | K_B64) ; i_and_opr - : - opr3 + : opr3 ; i_atom - : - i=KI_ATOM - t=i_atom_type - o=i_atom_opr + : i = KI_ATOM t = i_atom_type o = i_atom_opr ; i_atom_type - : - ( + : ( ( - ( K_GLOBAL | K_SHARED )? - ( K_AND | K_OR | K_XOR | K_CAS | K_EXCH | K_ADD | K_INC | K_DEC | K_MIN | K_MAX ) - ( K_B32 | K_B64 | K_U32 | K_U64 | K_S32 | K_F32 ) + (K_GLOBAL | K_SHARED)? ( + K_AND + | K_OR + | K_XOR + | K_CAS + | K_EXCH + | K_ADD + | K_INC + | K_DEC + | K_MIN + | K_MAX + ) (K_B32 | K_B64 | K_U32 | K_U64 | K_S32 | K_F32) ) ) ; i_atom_opr - : - opr T_COMMA T_OB opr T_CB T_COMMA opr ( T_COMMA opr )? + : opr T_COMMA T_OB opr T_CB T_COMMA opr (T_COMMA opr)? ; i_bar @@ -845,201 +788,126 @@ i_bar ; i_bar1 - : - i=KI_BAR - t=i_bar1_type - o=i_bar1_opr + : i = KI_BAR t = i_bar1_type o = i_bar1_opr ; i_bar1_type - : - K_SYNC + : K_SYNC ; i_bar1_opr - : - opr ( T_COMMA opr )? + : opr (T_COMMA opr)? ; - i_bar2 - : - i=KI_BAR - t=i_bar2_type - o=i_bar2_opr + : i = KI_BAR t = i_bar2_type o = i_bar2_opr ; i_bar2_type - : - K_ARRIVE + : K_ARRIVE ; i_bar2_opr - : - opr2 + : opr2 ; i_bar3 - : - i=KI_BAR - t=i_bar3_type - o=i_bar3_opr + : i = KI_BAR t = i_bar3_type o = i_bar3_opr ; i_bar3_type - : - ( - K_RED - K_POPC - K_U32 - ) + : (K_RED K_POPC K_U32) ; i_bar3_opr - : - opr T_COMMA opr - ( T_COMMA opr )? - T_COMMA T_NOT? opr + : opr T_COMMA opr (T_COMMA opr)? T_COMMA T_NOT? opr ; i_bar4 - : - i=KI_BAR - t=i_bar4_type - o=i_bar4_opr + : i = KI_BAR t = i_bar4_type o = i_bar4_opr ; i_bar4_type - : - ( - K_RED - ( K_AND | K_OR ) - K_PRED - ) + : (K_RED ( K_AND | K_OR) K_PRED) ; i_bar4_opr - : - opr T_COMMA opr - ( T_COMMA opr )? - T_COMMA T_NOT? opr + : opr T_COMMA opr (T_COMMA opr)? T_COMMA T_NOT? opr ; i_bfe - : - i=KI_BFE - t=i_bfe_type - o=i_bfe_opr + : i = KI_BFE t = i_bfe_type o = i_bfe_opr ; i_bfe_type - : - ( K_S32 | K_U32 | K_S64 | K_U64 ) + : (K_S32 | K_U32 | K_S64 | K_U64) ; i_bfe_opr - : - opr_register - T_COMMA - opr_register_or_constant3 + : opr_register T_COMMA opr_register_or_constant3 ; i_bfi - : - i=KI_BFI - t=i_bfi_type - o=i_bfi_opr + : i = KI_BFI t = i_bfi_type o = i_bfi_opr ; i_bfi_type - : - ( K_B32 | K_B64 ) + : (K_B32 | K_B64) ; i_bfi_opr - : - opr_register - T_COMMA - opr_register_or_constant4 + : opr_register T_COMMA opr_register_or_constant4 ; i_bfind - : - i=KI_BFIND - t=i_bfind_type - o=i_bfind_opr + : i = KI_BFIND t = i_bfind_type o = i_bfind_opr ; i_bfind_type - : - ( K_SHIFTAMT )? ( K_S32 | K_U32 | K_S64 | K_U64 ) + : (K_SHIFTAMT)? (K_S32 | K_U32 | K_S64 | K_U64) ; i_bfind_opr - : - opr_register - T_COMMA - opr_register_or_constant + : opr_register T_COMMA opr_register_or_constant ; i_bra - : - KI_BRA - i_bra_type - i_bra_opr + : KI_BRA i_bra_type i_bra_opr ; i_bra_type - : - K_UNI + : K_UNI | ; i_bra_opr - : - ( - opr_label - | opr_register T_COMMA opr_label - ) + : (opr_label | opr_register T_COMMA opr_label) ; i_brev - : - i=KI_BREV - t=i_brev_type - o=i_brev_opr + : i = KI_BREV t = i_brev_type o = i_brev_opr ; i_brev_type - : - ( K_B32 | K_B64 ) + : (K_B32 | K_B64) ; i_brev_opr - : - opr_register - T_COMMA - opr_register_or_constant + : opr_register T_COMMA opr_register_or_constant ; i_brkpt - : - i=KI_BRKPT + : i = KI_BRKPT ; i_call - : - KI_CALL - i_call_type - ( T_OP opr ( T_COMMA opr )* T_CP T_COMMA )? - func_name - ( T_COMMA T_OP opr ( T_COMMA opr )* T_CP )? - ( T_COMMA flist | T_COMMA fproto )? + : KI_CALL i_call_type (T_OP opr ( T_COMMA opr)* T_CP T_COMMA)? func_name ( + T_COMMA T_OP opr ( T_COMMA opr)* T_CP + )? (T_COMMA flist | T_COMMA fproto)? ; i_call_type - : - t=K_UNI + : t = K_UNI | ; @@ -1052,276 +920,252 @@ fproto ; i_clz - : - i=KI_CLZ - t=i_clz_type - o=i_clz_opr + : i = KI_CLZ t = i_clz_type o = i_clz_opr ; i_clz_type - : - ( K_B32 | K_B64 ) + : (K_B32 | K_B64) ; i_clz_opr - : - opr_register - T_COMMA - opr_register_or_constant + : opr_register T_COMMA opr_register_or_constant ; i_cnot - : - i=KI_CNOT - t=i_cnot_type - o=i_cnot_opr + : i = KI_CNOT t = i_cnot_type o = i_cnot_opr ; i_cnot_type - : - ( - K_B16 | K_B32 | K_B64 - ) + : (K_B16 | K_B32 | K_B64) ; i_cnot_opr - : - opr2 + : opr2 ; i_copysign - : - i=KI_COPYSIGN - t=i_copysign_type - o=i_copysign_opr + : i = KI_COPYSIGN t = i_copysign_type o = i_copysign_opr ; i_copysign_type - : - ( K_F32 | K_F64 ) + : (K_F32 | K_F64) ; i_copysign_opr - : - opr_register - T_COMMA - opr_register - T_COMMA - opr_register + : opr_register T_COMMA opr_register T_COMMA opr_register ; i_cos - : - i=KI_COS - t=i_cos_type - o=i_cos_opr + : i = KI_COS t = i_cos_type o = i_cos_opr ; i_cos_type - : - K_APPROX K_FTZ? K_F32 + : K_APPROX K_FTZ? K_F32 ; i_cos_opr - : - opr2 + : opr2 ; i_cvt - : - i=KI_CVT - t=i_cvt_type - o=i_cvt_opr + : i = KI_CVT t = i_cvt_type o = i_cvt_opr ; i_cvt_type - : - ( + : ( ( - ( i_cvt_irnd | i_cvt_frnd ) - K_FTZ? - K_SAT? - ( K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F16 | K_F32 | K_F64 ) - ( K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F16 | K_F32 | K_F64 ) - ( i_cvt_irnd | i_cvt_frnd ) - K_FTZ? - K_SAT? + (i_cvt_irnd | i_cvt_frnd) K_FTZ? K_SAT? ( + K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F16 + | K_F32 + | K_F64 + ) (K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F16 | K_F32 | K_F64) ( + i_cvt_irnd + | i_cvt_frnd + ) K_FTZ? K_SAT? ) ) ; - i_cvt_irnd - : - i=i_cvt_irnd_aux + : i = i_cvt_irnd_aux | ; i_cvt_irnd_aux - : - ( K_RNI | K_RZI | K_RMI | K_RPI ) + : (K_RNI | K_RZI | K_RMI | K_RPI) ; i_cvt_frnd - : - i=i_cvt_frnd_aux + : i = i_cvt_frnd_aux | ; i_cvt_frnd_aux - : - ( K_RN | K_RZ | K_RM | K_RP ) + : (K_RN | K_RZ | K_RM | K_RP) ; i_cvt_opr - : - opr2 + : opr2 ; i_cvta - : - i=KI_CVTA - t=i_cvta_type - o=i_cvta_opr + : i = KI_CVTA t = i_cvta_type o = i_cvta_opr ; i_cvta_type - : - K_TO? - ( K_GLOBAL | K_LOCAL | K_SHARED | K_CONST ) - ( K_U32 | K_U64 ) + : K_TO? (K_GLOBAL | K_LOCAL | K_SHARED | K_CONST) (K_U32 | K_U64) ; i_cvta_opr - : - opr T_COMMA opr ( T_PLUS integer )? + : opr T_COMMA opr (T_PLUS integer)? ; i_div - : - i=KI_DIV - t=i_div_type - o=i_div_opr + : i = KI_DIV t = i_div_type o = i_div_opr ; i_div_type - : - ( - ( - K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 - ) | - ( - K_APPROX K_FTZ? K_F32 - ) | - ( - K_FULL K_FTZ? K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP ) K_FTZ? K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP ) K_F64 - ) + : ( + ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) + | ( K_APPROX K_FTZ? K_F32) + | ( K_FULL K_FTZ? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_FTZ? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_F64) ) ; i_div_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_ex2 - : - i=KI_EX2 - t=i_ex2_type - o=i_ex2_opr + : i = KI_EX2 t = i_ex2_type o = i_ex2_opr ; i_ex2_type - : - K_APPROX K_FTZ? K_F32 + : K_APPROX K_FTZ? K_F32 ; i_ex2_opr - : - opr2 + : opr2 ; i_exit - : - i=KI_EXIT + : i = KI_EXIT ; i_fma - : - i=KI_FMA - t=i_fma_type - o=i_fma_opr + : i = KI_FMA t = i_fma_type o = i_fma_opr ; i_fma_type - : - ( K_RN | K_RZ | K_RM | K_RP ) - K_FTZ? - K_SAT? - K_F32 + : (K_RN | K_RZ | K_RM | K_RP) K_FTZ? K_SAT? K_F32 ; i_fma_opr - : - opr4 + : opr4 ; i_isspacep - : - i=KI_ISSPACEP - t=i_isspacep_type - o=i_isspacep_opr + : i = KI_ISSPACEP t = i_isspacep_type o = i_isspacep_opr ; i_isspacep_type - : - ( K_GLOBAL | K_LOCAL | K_SHARED ) + : (K_GLOBAL | K_LOCAL | K_SHARED) ; i_isspacep_opr - : - opr2 + : opr2 ; i_ld - : - i=KI_LD - t=i_ld_type - o=i_ld_opr + : i = KI_LD t = i_ld_type o = i_ld_opr ; i_ld_type - : - ( - ( - ( K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED )? - ( K_CA | K_CG | K_CS | K_LU | K_CV )? - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - ) | - ( - ( K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED )? - ( K_CA | K_CG | K_CS | K_LU | K_CV )? - ( K_V2 | K_V4 ) - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - ) | - ( - K_VOLATILE - ( K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED )? - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - ) | + : ( ( - K_VOLATILE - ( K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED )? - ( K_V2 | K_V4 ) - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + (K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED)? (K_CA | K_CG | K_CS | K_LU | K_CV)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) + ) + | ( + (K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED)? (K_CA | K_CG | K_CS | K_LU | K_CV)? ( + K_V2 + | K_V4 + ) ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) + ) + | ( + K_VOLATILE (K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) + ) + | ( + K_VOLATILE (K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED)? (K_V2 | K_V4) ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) ) ) ; @@ -1331,487 +1175,323 @@ i_ld_opr ; i_ldu - : - i=KI_LDU - t=i_ldu_type - o=i_ldu_opr + : i = KI_LDU t = i_ldu_type o = i_ldu_opr ; i_ldu_type - : - ( - ( - ( K_GLOBAL )? - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - ) | + : ( ( - ( K_GLOBAL )? - ( K_V2 | K_V4 ) - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + (K_GLOBAL)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) + ) + | ( + (K_GLOBAL)? (K_V2 | K_V4) ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) ) ) ; i_ldu_opr - : - opr T_COMMA T_OB opr T_CB + : opr T_COMMA T_OB opr T_CB ; i_lg2 - : - i=KI_LG2 - t=i_lg2_type - o=i_lg2_opr + : i = KI_LG2 t = i_lg2_type o = i_lg2_opr ; i_lg2_type - : - K_APPROX K_FTZ? K_F32 + : K_APPROX K_FTZ? K_F32 ; i_lg2_opr - : - opr2 + : opr2 ; i_mad - : - i=KI_MAD - t=i_mad_type - o=i_mad_opr + : i = KI_MAD t = i_mad_type o = i_mad_opr ; i_mad_type - : - ( - ( - ( K_HI | K_LO | K_WIDE ) - ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 ) - ) | - ( K_HI K_SAT K_S32 ) | - ( - K_FTZ? - K_SAT? - K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP) - K_FTZ? - K_SAT? - K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP) - K_F64 - ) + : ( + (( K_HI | K_LO | K_WIDE) ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64)) + | ( K_HI K_SAT K_S32) + | ( K_FTZ? K_SAT? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_FTZ? K_SAT? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_F64) ) ; i_mad_opr - : - opr_register - T_COMMA - opr_register_or_constant3 + : opr_register T_COMMA opr_register_or_constant3 ; i_mad24 - : - i=KI_MAD24 - t=i_mad24_type - o=i_mad24_opr + : i = KI_MAD24 t = i_mad24_type o = i_mad24_opr ; i_mad24_type - : - ( - ( - ( K_HI | K_LO ) - ( K_U32 | K_S32 ) - ) | - ( - K_HI K_SAT K_S32 - ) - ) + : (( ( K_HI | K_LO) ( K_U32 | K_S32)) | ( K_HI K_SAT K_S32)) ; i_mad24_opr - : - opr_register - T_COMMA - opr_register_or_constant3 + : opr_register T_COMMA opr_register_or_constant3 ; i_max - : - i=KI_MAX - t=i_max_type - o=i_max_opr + : i = KI_MAX t = i_max_type o = i_max_opr ; i_max_type - : - ( - ( - K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 - ) | - ( - K_FTZ? K_F32 - ) | - ( - K_F64 - ) - ) + : (( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) | ( K_FTZ? K_F32) | ( K_F64)) ; i_max_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_membar - : - i=KI_MEMBAR - t=i_membar_type + : i = KI_MEMBAR t = i_membar_type ; i_membar_type - : - ( K_CTA | K_GL | K_SYS ) + : (K_CTA | K_GL | K_SYS) ; i_min - : - i=KI_MIN - t=i_min_type - o=i_min_opr + : i = KI_MIN t = i_min_type o = i_min_opr ; i_min_type - : - ( - ( - K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 - ) | - ( - K_FTZ? K_F32 - ) | - ( - K_F64 - ) - ) + : (( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) | ( K_FTZ? K_F32) | ( K_F64)) ; i_min_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_mov - : - i=KI_MOV - t=i_mov_type - o=i_mov_opr + : i = KI_MOV t = i_mov_type o = i_mov_opr ; i_mov_type - : - ( - K_PRED | K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 + : ( + K_PRED + | K_B16 + | K_B32 + | K_B64 + | K_U16 + | K_U32 + | K_U64 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 ) ; i_mov_opr - : - opr2 + : opr2 ; i_mul - : - i=KI_MUL - t=i_mul_type - o=i_mul_opr + : i = KI_MUL t = i_mul_type o = i_mul_opr ; i_mul_type - : - ( - ( - ( K_HI | K_LO | K_WIDE )? ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 ) - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP )? K_FTZ? K_SAT? K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP )? K_F64 - ) + : ( + (( K_HI | K_LO | K_WIDE)? ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64)) + | ( ( K_RN | K_RZ | K_RM | K_RP)? K_FTZ? K_SAT? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP)? K_F64) ) ; i_mul_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_mul24 - : - i=KI_MUL24 - t=i_mul24_type - o=i_mul24_opr + : i = KI_MUL24 t = i_mul24_type o = i_mul24_opr ; i_mul24_type - : - ( ( K_HI | K_LO ) ( K_U32 | K_S32 ) ) + : (( K_HI | K_LO) ( K_U32 | K_S32)) ; i_mul24_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_neg - : - i=KI_NEG - t=i_neg_type - o=i_neg_opr + : i = KI_NEG t = i_neg_type o = i_neg_opr ; i_neg_type - : - ( - ( - K_S16 | K_S32 | K_S64 - ) | - ( - K_FTZ? K_F32 - ) | - ( - K_F64 - ) - ) + : (( K_S16 | K_S32 | K_S64) | ( K_FTZ? K_F32) | ( K_F64)) ; i_neg_opr - : - opr_register - T_COMMA - opr_register_or_constant + : opr_register T_COMMA opr_register_or_constant ; i_not - : - i=KI_NOT - t=i_not_type - o=i_not_opr + : i = KI_NOT t = i_not_type o = i_not_opr ; i_not_type - : - ( - K_PRED | K_B16 | K_B32 | K_B64 - ) + : (K_PRED | K_B16 | K_B32 | K_B64) ; i_not_opr - : - opr2 + : opr2 ; i_or - : - i=KI_OR - t=i_or_type - o=i_or_opr + : i = KI_OR t = i_or_type o = i_or_opr ; i_or_type - : - ( - K_PRED | K_B16 | K_B32 | K_B64 - ) + : (K_PRED | K_B16 | K_B32 | K_B64) ; i_or_opr - : - opr3 + : opr3 ; i_pmevent - : - i=KI_PMEVENT - o=i_pmevent_opr + : i = KI_PMEVENT o = i_pmevent_opr ; i_pmevent_opr - : - opr + : opr ; i_popc - : - i=KI_POPC - t=i_popc_type - o=i_popc_opr + : i = KI_POPC t = i_popc_type o = i_popc_opr ; i_popc_type - : - ( K_B32 | K_B64 ) + : (K_B32 | K_B64) ; i_popc_opr - : - opr_register - T_COMMA - opr_register_or_constant + : opr_register T_COMMA opr_register_or_constant ; i_prefetch - : - i=KI_PREFETCH - t=i_prefetch_type - o=i_prefetch_opr + : i = KI_PREFETCH t = i_prefetch_type o = i_prefetch_opr ; i_prefetch_type - : - ( - ( - ( K_GLOBAL | K_LOCAL )? - ( K_L1 | K_L2 ) - ) - ) + : (( ( K_GLOBAL | K_LOCAL)? ( K_L1 | K_L2))) ; i_prefetch_opr - : - T_OB opr T_CB + : T_OB opr T_CB ; i_prefetchu - : - i=KI_PREFETCHU - t=i_prefetchu_type - o=i_prefetchu_opr + : i = KI_PREFETCHU t = i_prefetchu_type o = i_prefetchu_opr ; i_prefetchu_type - : - K_L1 + : K_L1 ; i_prefetchu_opr - : - T_OB opr T_CB + : T_OB opr T_CB ; i_prmt - : - i=KI_PRMT - t=i_prmt_type - o=i_prmt_opr + : i = KI_PRMT t = i_prmt_type o = i_prmt_opr ; i_prmt_type - : - K_B32 - ( K_F4E | K_B4E | K_RC8 | K_ECL | K_ECR | K_RC16 )? + : K_B32 (K_F4E | K_B4E | K_RC8 | K_ECL | K_ECR | K_RC16)? ; i_prmt_opr - : - opr_register - T_COMMA - opr_register - T_COMMA - opr_register - T_COMMA - opr_register + : opr_register T_COMMA opr_register T_COMMA opr_register T_COMMA opr_register ; i_rcp - : - i=KI_RCP - t=i_rcp_type - o=i_rcp_opr + : i = KI_RCP t = i_rcp_type o = i_rcp_opr ; i_rcp_type - : - ( - ( - K_APPROX K_FTZ? K_F32 K_FTZ? - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP ) - K_FTZ? - K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP ) - K_F64 - ) | - ( - K_APPROX K_FTZ K_F64 - ) + : ( + ( K_APPROX K_FTZ? K_F32 K_FTZ?) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_FTZ? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_F64) + | ( K_APPROX K_FTZ K_F64) ) ; i_rcp_opr - : - opr2 + : opr2 ; i_red - : - i=KI_RED - t=i_red_type - o=i_red_opr + : i = KI_RED t = i_red_type o = i_red_opr ; i_red_type - : - ( K_GLOBAL | K_SHARED )? - ( K_AND | K_OR | K_XOR | K_ADD | K_INC | K_DEC | K_MIN | K_MAX ) - ( K_B32 | K_B64 | K_U32 | K_U64 | K_S32 | K_F32 ) + : (K_GLOBAL | K_SHARED)? (K_AND | K_OR | K_XOR | K_ADD | K_INC | K_DEC | K_MIN | K_MAX) ( + K_B32 + | K_B64 + | K_U32 + | K_U64 + | K_S32 + | K_F32 + ) ; i_red_opr - : - T_OB opr T_CB T_COMMA opr + : T_OB opr T_CB T_COMMA opr ; i_rem - : - i=KI_REM - t=i_rem_type - o=i_rem_opr + : i = KI_REM t = i_rem_type o = i_rem_opr ; i_rem_type - : - ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 ) + : (K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) ; i_rem_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_ret - : - i=KI_RET - t=i_ret_type + : i = KI_RET t = i_ret_type ; i_ret_type @@ -1820,63 +1500,39 @@ i_ret_type ; i_rsqrt - : - i=KI_RSQRT - t=i_rsqrt_type - o=i_rsqrt_opr + : i = KI_RSQRT t = i_rsqrt_type o = i_rsqrt_opr ; i_rsqrt_type - : - ( - ( - K_APPROX K_FTZ? K_F32 - ) | - ( - K_APPROX K_F64 - ) - ) + : (( K_APPROX K_FTZ? K_F32) | ( K_APPROX K_F64)) ; i_rsqrt_opr - : - opr2 + : opr2 ; i_sad - : - i=KI_SAD - t=i_sad_type - o=i_sad_opr + : i = KI_SAD t = i_sad_type o = i_sad_opr ; i_sad_type - : - ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 ) + : (K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) ; i_sad_opr - : - opr_register - T_COMMA - opr_register_or_constant3 + : opr_register T_COMMA opr_register_or_constant3 ; i_selp - : - i=KI_SELP - t=i_selp_type - o=i_selp_opr + : i = KI_SELP t = i_selp_type o = i_selp_opr ; i_selp_type - : - ( K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + : (K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64) ; i_selp_opr - : - opr4 + : opr4 ; i_set @@ -1885,54 +1541,97 @@ i_set ; i_set1 - : - i=KI_SET - t=i_set1_type - o=i_set1_opr + : i = KI_SET t = i_set1_type o = i_set1_opr ; i_set1_type - : - ( + : ( ( - ( K_EQ | K_NE | K_LT | K_LE | K_GT | K_GE | K_LO | K_LS | K_HI | K_HS - | K_EQU | K_NEU | K_LTU | K_LEU | K_GTU | K_GEU | K_NUM | K_NAN ) - K_FTZ? - ( K_U32 | K_S32 | K_F32 ) - ( K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + ( + K_EQ + | K_NE + | K_LT + | K_LE + | K_GT + | K_GE + | K_LO + | K_LS + | K_HI + | K_HS + | K_EQU + | K_NEU + | K_LTU + | K_LEU + | K_GTU + | K_GEU + | K_NUM + | K_NAN + ) K_FTZ? (K_U32 | K_S32 | K_F32) ( + K_B16 + | K_B32 + | K_B64 + | K_U16 + | K_U32 + | K_U64 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) ) ) ; i_set1_opr - : - opr3 + : opr3 ; i_set2 - : - i=KI_SET - t=i_set2_type - o=i_set2_opr + : i = KI_SET t = i_set2_type o = i_set2_opr ; i_set2_type - : - ( + : ( ( - ( K_EQ | K_NE | K_LT | K_LE | K_GT | K_GE | K_LO | K_LS | K_HI | K_HS - | K_EQU | K_NEU | K_LTU | K_LEU | K_GTU | K_GEU | K_NUM | K_NAN ) - ( K_AND | K_OR | K_XOR ) - K_FTZ? - ( K_U32 | K_S32 | K_F32 ) - ( K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + ( + K_EQ + | K_NE + | K_LT + | K_LE + | K_GT + | K_GE + | K_LO + | K_LS + | K_HI + | K_HS + | K_EQU + | K_NEU + | K_LTU + | K_LEU + | K_GTU + | K_GEU + | K_NUM + | K_NAN + ) (K_AND | K_OR | K_XOR) K_FTZ? (K_U32 | K_S32 | K_F32) ( + K_B16 + | K_B32 + | K_B64 + | K_U16 + | K_U32 + | K_U64 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) ) ) ; i_set2_opr - : - opr T_COMMA opr T_COMMA opr T_COMMA T_NOT? opr + : opr T_COMMA opr T_COMMA opr T_COMMA T_NOT? opr ; i_setp @@ -1941,535 +1640,489 @@ i_setp ; i_setp1 - : - i=KI_SETP - t=i_setp1_type - o=i_setp1_opr + : i = KI_SETP t = i_setp1_type o = i_setp1_opr ; i_setp1_type - : - ( + : ( ( - ( K_EQ | K_NE | K_LT | K_LE | K_GT | K_GE | K_LO | K_LS | K_HI | K_HS - | K_EQU | K_NEU | K_LTU | K_LEU | K_GTU | K_GEU | K_NUM | K_NAN ) - K_FTZ? - ( K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + ( + K_EQ + | K_NE + | K_LT + | K_LE + | K_GT + | K_GE + | K_LO + | K_LS + | K_HI + | K_HS + | K_EQU + | K_NEU + | K_LTU + | K_LEU + | K_GTU + | K_GEU + | K_NUM + | K_NAN + ) K_FTZ? ( + K_B16 + | K_B32 + | K_B64 + | K_U16 + | K_U32 + | K_U64 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) ) ) ; i_setp1_opr - : - opr3 + : opr3 ; i_setp2 - : - i=KI_SETP - t=i_setp2_type - o=i_setp2_opr + : i = KI_SETP t = i_setp2_type o = i_setp2_opr ; i_setp2_type - : - ( + : ( ( - ( K_EQ | K_NE | K_LT | K_LE | K_GT | K_GE | K_LO | K_LS | K_HI | K_HS - | K_EQU | K_NEU | K_LTU | K_LEU | K_GTU | K_GEU | K_NUM | K_NAN ) - ( K_AND | K_OR | K_XOR ) - K_FTZ? - ( K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + ( + K_EQ + | K_NE + | K_LT + | K_LE + | K_GT + | K_GE + | K_LO + | K_LS + | K_HI + | K_HS + | K_EQU + | K_NEU + | K_LTU + | K_LEU + | K_GTU + | K_GEU + | K_NUM + | K_NAN + ) (K_AND | K_OR | K_XOR) K_FTZ? ( + K_B16 + | K_B32 + | K_B64 + | K_U16 + | K_U32 + | K_U64 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) ) ) ; i_setp2_opr - : - opr T_COMMA opr T_COMMA opr T_COMMA T_NOT? opr + : opr T_COMMA opr T_COMMA opr T_COMMA T_NOT? opr ; i_shl - : - i=KI_SHL - t=i_shl_type - o=i_shl_opr + : i = KI_SHL t = i_shl_type o = i_shl_opr ; i_shl_type - : - ( - K_B16 | K_B32 | K_B64 - ) + : (K_B16 | K_B32 | K_B64) ; i_shl_opr - : - opr3 + : opr3 ; i_shr - : - i=KI_SHR - t=i_shr_type - o=i_shr_opr + : i = KI_SHR t = i_shr_type o = i_shr_opr ; i_shr_type - : - ( - K_B16 | K_B32 | K_B64 | - K_U16 | K_U32 | K_U64 | - K_S16 | K_S32 | K_S64 - ) + : (K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) ; i_shr_opr - : - opr3 + : opr3 ; i_sin - : - i=KI_SIN - t=i_sin_type - o=i_sin_opr + : i = KI_SIN t = i_sin_type o = i_sin_opr ; i_sin_type - : - K_APPROX K_FTZ? K_F32 + : K_APPROX K_FTZ? K_F32 ; i_sin_opr - : - opr2 + : opr2 ; i_slct - : - i=KI_SLCT - t=i_slct_type - o=i_slct_opr + : i = KI_SLCT t = i_slct_type o = i_slct_opr ; i_slct_type - : - ( - ( - ( K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - K_S32 - ) | + : ( ( - K_FTZ? - ( K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - K_F32 + (K_B16 | K_B32 | K_B64 | K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64) K_S32 + ) + | ( + K_FTZ? ( + K_B16 + | K_B32 + | K_B64 + | K_U16 + | K_U32 + | K_U64 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) K_F32 ) ) ; i_slct_opr - : - opr4 + : opr4 ; i_sqrt - : - i=KI_SQRT - t=i_sqrt_type - o=i_sqrt_opr + : i = KI_SQRT t = i_sqrt_type o = i_sqrt_opr ; i_sqrt_type - : - ( - ( - K_APPROX K_FTZ? K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP ) - K_FTZ? - K_F32 - ) | - ( - ( K_RN | K_RZ | K_RM | K_RP ) - K_F64 - ) + : ( + ( K_APPROX K_FTZ? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_FTZ? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP) K_F64) ) ; i_sqrt_opr - : - opr2 + : opr2 ; i_st - : - i=KI_ST - t=i_st_type - o=i_st_opr + : i = KI_ST t = i_st_type o = i_st_opr ; i_st_type - : - ( - ( - ( K_GLOBAL | K_LOCAL | K_SHARED | K_PARAM )? - ( K_WB | K_CG | K_CS | K_WT )? - ( K_V2 | K_V4 )? - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - ) | - ( - K_VOLATILE - ( K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED )? - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) - ) | + : ( ( - K_VOLATILE - ( K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED )? - ( K_V2 | K_V4 ) - ( K_B8 | K_B16 | K_B32 | K_B64 | K_U8 | K_U16 | K_U32 | K_U64 | K_S8 | K_S16 | K_S32 | K_S64 | K_F32 | K_F64 ) + (K_GLOBAL | K_LOCAL | K_SHARED | K_PARAM)? (K_WB | K_CG | K_CS | K_WT)? (K_V2 | K_V4)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) + ) + | ( + K_VOLATILE (K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) + ) + | ( + K_VOLATILE (K_CONST | K_GLOBAL | K_LOCAL | K_PARAM | K_SHARED)? (K_V2 | K_V4) ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + | K_U8 + | K_U16 + | K_U32 + | K_U64 + | K_S8 + | K_S16 + | K_S32 + | K_S64 + | K_F32 + | K_F64 + ) ) ) ; i_st_opr - : - T_OB opr T_CB T_COMMA opr + : T_OB opr T_CB T_COMMA opr ; i_sub - : - i=KI_SUB - t=i_sub_type - o=i_sub_opr + : i = KI_SUB t = i_sub_type o = i_sub_opr ; i_sub_type - : - ( - ( - ( ( K_SAT K_S32 ) | ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) ) | - ( K_CC ( K_S32 | K_U32 ) ) - ) | + : ( ( - ( K_RN | K_RZ | K_RM | K_RP )? K_FTZ? K_SAT? K_F32 - ) | - ( ( K_RN | K_RZ | K_RM | K_RP )? K_F64 ) + (( K_SAT K_S32) | ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64)) + | ( K_CC ( K_S32 | K_U32)) + ) + | ( ( K_RN | K_RZ | K_RM | K_RP)? K_FTZ? K_SAT? K_F32) + | ( ( K_RN | K_RZ | K_RM | K_RP)? K_F64) ) ; i_sub_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_subc - : - i=KI_SUBC - t=i_subc_type - o=i_subc_opr + : i = KI_SUBC t = i_subc_type o = i_subc_opr ; i_subc_type - : - ( - ( ( K_SAT K_S32 ) | ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64) ) | - ( K_CC ( K_S32 | K_U32 ) ) - ) + : (( ( K_SAT K_S32) | ( K_U16 | K_U32 | K_U64 | K_S16 | K_S32 | K_S64)) | ( K_CC ( K_S32 | K_U32))) ; i_subc_opr - : - opr_register - T_COMMA - opr_register_or_constant2 + : opr_register T_COMMA opr_register_or_constant2 ; i_suld - : - i=KI_SULD - t=i_suld_type - o=i_suld_opr + : i = KI_SULD t = i_suld_type o = i_suld_opr ; i_suld_type - : - ( - ( - K_B - ( K_1D | K_2D | K_3D ) - ( K_CA | K_CG | K_CS | K_CV )? - ( K_V2 | K_V4 )? - ( K_B8 | K_B16 | K_B32 | K_B64 ) - ( K_TRAP | K_CLAMP | K_ZERO ) - ) | + : ( ( - K_P - ( K_1D | K_2D | K_3D ) - ( K_CA | K_CG | K_CS | K_CV )? - ( K_V2 | K_V4 )? - ( K_B32 | K_U32 | K_S32 | K_F32 ) - ( K_TRAP | K_CLAMP | K_ZERO ) + K_B (K_1D | K_2D | K_3D) (K_CA | K_CG | K_CS | K_CV)? (K_V2 | K_V4)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + ) (K_TRAP | K_CLAMP | K_ZERO) + ) + | ( + K_P (K_1D | K_2D | K_3D) (K_CA | K_CG | K_CS | K_CV)? (K_V2 | K_V4)? ( + K_B32 + | K_U32 + | K_S32 + | K_F32 + ) (K_TRAP | K_CLAMP | K_ZERO) ) ) ; i_suld_opr - : - opr T_COMMA T_OB opr T_COMMA opr T_CB + : opr T_COMMA T_OB opr T_COMMA opr T_CB ; i_sured - : - i=KI_SURED - t=i_sured_type - o=i_sured_opr + : i = KI_SURED t = i_sured_type o = i_sured_opr ; i_sured_type - : - ( - ( - K_B - ( K_1D | K_2D | K_3D ) - ( K_CA | K_CG | K_CS | K_CV )? - ( K_V2 | K_V4 )? - ( K_B8 | K_B16 | K_B32 | K_B64 ) - ( K_TRAP | K_CLAMP | K_ZERO ) - ) | + : ( ( - K_P - ( K_1D | K_2D | K_3D ) - ( K_CA | K_CG | K_CS | K_CV )? - ( K_V2 | K_V4 )? - ( K_B32 | K_U32 | K_S32 | K_F32 ) - ( K_TRAP | K_CLAMP | K_ZERO ) + K_B (K_1D | K_2D | K_3D) (K_CA | K_CG | K_CS | K_CV)? (K_V2 | K_V4)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + ) (K_TRAP | K_CLAMP | K_ZERO) + ) + | ( + K_P (K_1D | K_2D | K_3D) (K_CA | K_CG | K_CS | K_CV)? (K_V2 | K_V4)? ( + K_B32 + | K_U32 + | K_S32 + | K_F32 + ) (K_TRAP | K_CLAMP | K_ZERO) ) ) ; i_sured_opr - : - T_OB opr T_COMMA opr T_CB T_COMMA opr + : T_OB opr T_COMMA opr T_CB T_COMMA opr ; i_sust - : - i=KI_SUST - t=i_sust_type - o=i_sust_opr + : i = KI_SUST t = i_sust_type o = i_sust_opr ; i_sust_type - : - ( - ( - K_B - ( K_1D | K_2D | K_3D ) - ( K_CA | K_CG | K_CS | K_CV )? - ( K_V2 | K_V4 )? - ( K_B8 | K_B16 | K_B32 | K_B64 ) - ( K_TRAP | K_CLAMP | K_ZERO ) - ) | + : ( ( - K_P - ( K_1D | K_2D | K_3D ) - ( K_CA | K_CG | K_CS | K_CV )? - ( K_V2 | K_V4 )? - ( K_B32 | K_U32 | K_S32 | K_F32 ) - ( K_TRAP | K_CLAMP | K_ZERO ) + K_B (K_1D | K_2D | K_3D) (K_CA | K_CG | K_CS | K_CV)? (K_V2 | K_V4)? ( + K_B8 + | K_B16 + | K_B32 + | K_B64 + ) (K_TRAP | K_CLAMP | K_ZERO) + ) + | ( + K_P (K_1D | K_2D | K_3D) (K_CA | K_CG | K_CS | K_CV)? (K_V2 | K_V4)? ( + K_B32 + | K_U32 + | K_S32 + | K_F32 + ) (K_TRAP | K_CLAMP | K_ZERO) ) ) ; i_sust_opr - : - T_OB opr T_COMMA opr T_CB T_COMMA opr + : T_OB opr T_COMMA opr T_CB T_COMMA opr ; i_suq - : - i=KI_SUQ - t=i_suq_type - o=i_suq_opr + : i = KI_SUQ t = i_suq_type o = i_suq_opr ; i_suq_type - : - ( K_WIDTH | K_HEIGHT | K_DEPTH ) - K_B32 + : (K_WIDTH | K_HEIGHT | K_DEPTH) K_B32 ; i_suq_opr - : - opr T_COMMA T_OB opr T_CB + : opr T_COMMA T_OB opr T_CB ; i_testp - : - i=KI_TESTP - t=i_testp_type - o=i_testp_opr + : i = KI_TESTP t = i_testp_type o = i_testp_opr ; i_testp_type - : - ( K_FINITE | K_INFINITE | K_NUMBER | K_NOTANUMBER | K_NORMAL | K_SUBNORMAL ) - ( K_F32 | K_F64 ) + : (K_FINITE | K_INFINITE | K_NUMBER | K_NOTANUMBER | K_NORMAL | K_SUBNORMAL) (K_F32 | K_F64) ; i_testp_opr - : - opr_register - T_COMMA - opr_register + : opr_register T_COMMA opr_register ; i_tex - : - i=KI_TEX - t=i_tex_type - o=i_tex_opr + : i = KI_TEX t = i_tex_type o = i_tex_opr ; i_tex_type - : - ( - ( - ( K_1D | K_2D | K_3D ) - K_V4 - ( K_U32 | K_S32 | K_F32 ) - ( K_S32 | K_F32 ) - ) - ) + : (( ( K_1D | K_2D | K_3D) K_V4 ( K_U32 | K_S32 | K_F32) ( K_S32 | K_F32))) ; i_tex_opr - : - opr T_COMMA T_OB opr T_COMMA opr ( T_COMMA opr )? T_CB + : opr T_COMMA T_OB opr T_COMMA opr (T_COMMA opr)? T_CB ; i_txq - : - i=KI_TXQ - t=i_txq_type - o=i_txq_opr + : i = KI_TXQ t = i_txq_type o = i_txq_opr ; i_txq_type - : - ( - ( - ( K_WIDTH | K_HEIGHT | K_DEPTH | K_CHANNEL_DATA_TYPE | K_CHANNEL_ORDER | K_NORMALIZED_COORDS ) - ) | + : ( ( - ( K_FILTER_MODE | K_ADDR_MODE_0 | K_ADDR_MODE_1 | K_ADDR_MODE_2 ) + ( + K_WIDTH + | K_HEIGHT + | K_DEPTH + | K_CHANNEL_DATA_TYPE + | K_CHANNEL_ORDER + | K_NORMALIZED_COORDS + ) ) - ) - K_B32 + | ( ( K_FILTER_MODE | K_ADDR_MODE_0 | K_ADDR_MODE_1 | K_ADDR_MODE_2)) + ) K_B32 ; i_txq_opr - : - opr T_COMMA T_OB opr T_CB + : opr T_COMMA T_OB opr T_CB ; i_trap - : - i=KI_TRAP + : i = KI_TRAP ; i_vabsdiff - : - i=KI_VABSDIFF + : i = KI_VABSDIFF ; i_vadd - : - i=KI_VADD + : i = KI_VADD ; i_vmad - : - i=KI_VMAD + : i = KI_VMAD ; i_vmax - : - i=KI_VMAX + : i = KI_VMAX ; i_vmin - : - i=KI_VMIN + : i = KI_VMIN ; i_vset - : - i=KI_VSET + : i = KI_VSET ; i_vshl - : - i=KI_VSHL + : i = KI_VSHL ; i_vshr - : - i=KI_VSHR + : i = KI_VSHR ; i_vsub - : - i=KI_VSUB + : i = KI_VSUB ; i_vote - : - i=KI_VOTE - t=i_vote_type - o=i_vote_opr + : i = KI_VOTE t = i_vote_type o = i_vote_opr ; i_vote_type - : - ( - ( - ( K_ALL | K_ANY | K_UNI ) - K_PRED - ) | - ( - K_BALLOT - K_B32 - ) - ) + : (( ( K_ALL | K_ANY | K_UNI) K_PRED) | ( K_BALLOT K_B32)) ; i_vote_opr - : - opr T_COMMA T_NOT? opr + : opr T_COMMA T_NOT? opr ; i_xor - : - i=KI_XOR - t=i_xor_type - o=i_xor_opr + : i = KI_XOR t = i_xor_type o = i_xor_opr ; i_xor_type - : - ( - K_PRED | K_B16 | K_B32 | K_B64 - ) + : (K_PRED | K_B16 | K_B32 | K_B64) ; i_xor_opr - : - opr3 + : opr3 ; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2479,12 +2132,12 @@ i_xor_opr //////////////////////////////////////////////////////////////////////////////////////////////////// opr_register - : a=id_or_opcode + : a = id_or_opcode ; opr_register_or_constant - : a=id_or_opcode - | b=constant_expression + : a = id_or_opcode + | b = constant_expression ; opr_register_or_constant2 @@ -2500,11 +2153,12 @@ opr_register_or_constant4 ; opr_register_or_constant5 - : opr_register_or_constant T_COMMA opr_register_or_constant T_COMMA opr_register_or_constant T_COMMA opr_register_or_constant T_COMMA opr_register_or_constant + : opr_register_or_constant T_COMMA opr_register_or_constant T_COMMA opr_register_or_constant T_COMMA opr_register_or_constant T_COMMA + opr_register_or_constant ; opr_label - : a=T_WORD + : a = T_WORD ; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2514,26 +2168,22 @@ opr_label //////////////////////////////////////////////////////////////////////////////////////////////////// opr - : - a=opr_aux + : a = opr_aux ; // This probably needs a lot of work... opr_aux : ( ( - ( id_or_opcode ( K_X | K_Y | K_Z | K_W | K_A | K_R | K_G | K_B )? - | constant_expression ) - ( T_PLUS constant_expression )? - ( T_LT opr T_GT )? - ) | - ( // aggregate - T_OC - (id_or_opcode | T_UNDERSCORE) - ( T_COMMA (id_or_opcode | T_UNDERSCORE))* - T_CC - ) | - T_UNDERSCORE + (id_or_opcode ( K_X | K_Y | K_Z | K_W | K_A | K_R | K_G | K_B)? | constant_expression) ( + T_PLUS constant_expression + )? (T_LT opr T_GT)? + ) + | ( + // aggregate + T_OC (id_or_opcode | T_UNDERSCORE) (T_COMMA (id_or_opcode | T_UNDERSCORE))* T_CC + ) + | T_UNDERSCORE ) ; @@ -2553,7 +2203,6 @@ opr5 : opr T_COMMA opr T_COMMA opr T_COMMA opr T_COMMA opr ; - //////////////////////////////////////////////////////////////////////////////////////////////////// // // Constant literal expressions. @@ -2561,138 +2210,98 @@ opr5 //////////////////////////////////////////////////////////////////////////////////////////////////// constant_expression - : - e=constant_expression_aux + : e = constant_expression_aux ; constant_expression_aux - : - conditional_expression + : conditional_expression ; conditional_expression - : conditional_or_expression - ( T_QUESTION constant_expression_aux T_COLON conditional_expression - )? + : conditional_or_expression (T_QUESTION constant_expression_aux T_COLON conditional_expression)? ; conditional_or_expression - : conditional_and_expression - ( T_OROR conditional_and_expression - )* + : conditional_and_expression (T_OROR conditional_and_expression)* ; conditional_and_expression - : inclusive_or_expression - ( T_ANDAND inclusive_or_expression - )* + : inclusive_or_expression (T_ANDAND inclusive_or_expression)* ; inclusive_or_expression - : exclusive_or_expression - ( T_OR exclusive_or_expression - )* + : exclusive_or_expression (T_OR exclusive_or_expression)* ; exclusive_or_expression - : and_expression - ( T_XOR and_expression - )* + : and_expression (T_XOR and_expression)* ; and_expression - : equality_expression - ( T_AND equality_expression - )* + : equality_expression (T_AND equality_expression)* ; equality_expression - : relational_expression - ( - ( T_EQEQ - | T_NOTEQ - ) - relational_expression - )* + : relational_expression (( T_EQEQ | T_NOTEQ) relational_expression)* ; relational_expression - : shift_expression - (relational_op shift_expression - )* + : shift_expression (relational_op shift_expression)* ; relational_op - : T_LE - | T_GE - | T_LT - | T_GT + : T_LE + | T_GE + | T_LT + | T_GT ; shift_expression - : additive_expression - (shift_op additive_expression - )* + : additive_expression (shift_op additive_expression)* ; shift_op - : T_LTLT - | T_GTGT + : T_LTLT + | T_GTGT ; additive_expression - : multiplicative_expression - ( - ( T_PLUS - | T_MINUS - ) - multiplicative_expression - )* + : multiplicative_expression (( T_PLUS | T_MINUS) multiplicative_expression)* ; -multiplicative_expression - : - unary_expression - ( - ( T_STAR - | T_SLASH - | T_PERCENT - ) - unary_expression - )* +multiplicative_expression + : unary_expression (( T_STAR | T_SLASH | T_PERCENT) unary_expression)* ; unary_expression - : T_PLUS unary_expression - | T_MINUS unary_expression - | unary_expression_not_plus_minus + : T_PLUS unary_expression + | T_MINUS unary_expression + | unary_expression_not_plus_minus ; unary_expression_not_plus_minus - : T_TILDE unary_expression - | T_NOT unary_expression - | cast_expression - | primary + : T_TILDE unary_expression + | T_NOT unary_expression + | cast_expression + | primary ; cast_expression - : - e=cast_expression_aux + : e = cast_expression_aux ; cast_expression_aux - : - T_OP (K_S64 | K_U64) T_CP unary_expression + : T_OP (K_S64 | K_U64) T_CP unary_expression ; primary - : par_expression - | integer - | float_ + : par_expression + | integer + | float_ ; par_expression - : T_OP constant_expression_aux T_CP + : T_OP constant_expression_aux T_CP ; integer @@ -2717,314 +2326,1180 @@ base_16_integer : T_HEX_LITERAL ; -KI_ABS: 'abs'; -KI_ADD: 'add'; -KI_ADDC: 'addc'; -KI_AND: 'and'; -KI_ATOM: 'atom'; -KI_BAR: 'bar'; -KI_BFE: 'bfe'; -KI_BFI: 'bfi'; -KI_BFIND: 'bfind'; -KI_BRA: 'bra'; -KI_BREV: 'brev'; -KI_BRKPT: 'brkpt'; -KI_CALL: 'call'; -KI_CLZ: 'clz'; -KI_CNOT: 'cnot'; -KI_COPYSIGN: 'copysign'; -KI_COS: 'cos'; -KI_CVT: 'cvt'; -KI_CVTA: 'cvta'; -KI_DIV: 'div'; -KI_EX2: 'ex2'; -KI_EXIT: 'exit'; -KI_FMA: 'fma'; -KI_ISSPACEP: 'isspacep'; -KI_LD: 'ld'; -KI_LDU: 'ldu'; -KI_LG2: 'lg2'; -KI_MAD24: 'mad24'; -KI_MAD: 'mad'; -KI_MAX: 'max'; -KI_MEMBAR: 'membar'; -KI_MIN: 'min'; -KI_MOV: 'mov'; -KI_MUL24: 'mul24'; -KI_MUL: 'mul'; -KI_NEG: 'neg'; -KI_NOT: 'not'; -KI_OR: 'or'; -KI_PMEVENT: 'pmevent'; -KI_POPC: 'popc'; -KI_PREFETCH: 'prefetch'; -KI_PREFETCHU: 'prefetchu'; -KI_PRMT: 'prmt'; -KI_RCP: 'rcp'; -KI_RED: 'red'; -KI_REM: 'rem'; -KI_RET: 'ret'; -KI_RSQRT: 'rsqrt'; -KI_SAD: 'sad'; -KI_SELP: 'selp'; -KI_SETP: 'setp'; -// Note order after SETP -KI_SET: 'set'; -KI_SHL: 'shl'; -KI_SHR: 'shr'; -KI_SIN: 'sin'; -KI_SLCT: 'slct'; -KI_SQRT: 'sqrt'; -KI_ST: 'st'; -KI_SUB: 'sub'; -KI_SUBC: 'subc'; -KI_SULD: 'suld'; -KI_SUQ: 'suq'; -KI_SURED: 'sured'; -KI_SUST: 'sust'; -KI_TESTP: 'testp'; -KI_TEX: 'tex'; -KI_TRAP: 'trap'; -KI_TXQ: 'txq'; -KI_VABSDIFF: 'vabsdiff'; -KI_VADD: 'vadd'; -KI_VMAD: 'vmad'; -KI_VMAX: 'vmax'; -KI_VMIN: 'vmin'; -KI_VOTE: 'vote'; -KI_VSET: 'vset'; -KI_VSHL: 'vshl'; -KI_VSHR: 'vshr'; -KI_VSUB: 'vsub'; -KI_XOR: 'xor'; - -T_QUESTION: '?'; -T_OROR: '||'; -T_ANDAND: '&&'; -T_OR: '|'; -T_XOR: '^'; -T_AND: '&'; -T_EQEQ: '=='; -T_LE: '<='; -T_GE: '>='; -T_LTLT: '<<'; -T_GTGT: '>>'; -T_STAR: '*'; -T_TILDE: '~'; -T_FLT_LITERAL: ( '0' ('f' | 'F' | 'd' | 'D') ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ | '.' ('0' .. '9')+ | ('0' .. '9')+ '.' | ('0' .. '9')+ '.' ('0' .. '9')+ ); -T_HEX_LITERAL: '0' ('x' | 'X') ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ 'U'?; -T_OCT_LITERAL: '0' ('0' .. '7' )+ 'U'?; -T_DEC_LITERAL: ('0' .. '9') ( '0' .. '9')* 'U'?; -K_3D: '.3d'; -K_2D: '.2d'; -K_1D: '.1d'; - -U_DEBUG_ABBREV: '.debug_abbrev'; -U_DEBUG_INFO: '.debug_info'; -U_DEBUG_LINE: '.debug_line'; -U_DEBUG_LOC: '.debug_loc'; -U_DEBUG_PUBNAMES: '.debug_pubnames'; -U_DEBUG_RANGES: '.debug_ranges'; -U_BYTE: '.byte'; -U_4BYTE: '.4byte'; -T_EQ: '='; -T_SEMICOLON: ';'; -T_PLUS: '+'; -T_OP: '('; -T_OC: '{'; -T_OB: '['; -T_NOTEQ: '!='; -T_NOT: '!'; -T_MINUS: '-'; -T_GT: '>'; -T_LT: '<'; -T_ELLIPSIS: '...'; -T_CP: ')'; -T_COMMA:','; -T_COLON: ':'; -T_CC: '}'; -T_CB: ']'; -LINE_COMMENT: '//' .*? ('\n' | '\r') -> channel(HIDDEN); -K_ZERO: '.zero'; -K_XOR: '.xor'; -K_WT: '.wt'; -K_WIDTH: '.width'; -K_WIDE: '.wide'; -K_WB: '.wb'; -K_VOLATILE: '.volatile'; -K_VISIBLE: '.visible'; -K_VERSION: '.version'; -K_VB: '.vb'; -K_V4: '.v4'; -K_V2: '.v2'; -K_UNI: '.uni'; -K_U8: '.u8'; -K_U64: '.u64'; -K_U32: '.u32'; -K_U16: '.u16'; -K_TRAP: '.trap'; -K_TO: '.to'; -K_TEXREF: '.texref'; -K_TEX: '.tex'; -K_TARGET: '.target'; -K_SYS: '.sys'; -K_SYNC: '.sync'; -K_SURFREF: '.surfref'; -K_SUBNORMAL: '.subnormal'; -K_SREG: '.sreg'; -K_SHIFTAMT: '.shiftamt'; -K_SHARED: '.shared'; -K_SECTION: '.section'; -K_SAT: '.sat'; -K_SAMPLERREF: '.samplerref'; -K_S8: '.s8'; -K_S64: '.s64'; -K_S32: '.s32'; -K_S16: '.s16'; -K_RZI: '.rzi'; -K_RZ: '.rz'; -K_RPI: '.rpi'; -K_RP: '.rp'; -K_RNI: '.rni'; -K_RN: '.rn'; -K_RMI: '.rmi'; -K_RM: '.rm'; -K_REQNTID: '.reqntid'; -K_REG: '.reg'; -K_RED: '.red'; -K_RCP: '.rcp'; -K_RC8: '.rc8'; -K_RC16: '.rc16'; -K_PRED: '.pred'; -K_PRAGMA: '.pragma'; -K_POPC: '.popc'; -K_PARAM: '.param'; -K_P: '.p'; -K_OR: '.or'; -K_OC: '.oc'; -K_NUMBER: '.number'; -K_NUM: '.num'; -K_NS: '.ns'; -K_NOUNROLL: '"nounroll"'; -T_STRING: '"' ( ~('"') )* '"'; -K_NOTANUMBER: '.notanumber'; -K_NORMALIZED_COORDS: '.normalized_coords'; -K_NORMAL: '.normal'; -K_NEU: '.neu'; -K_NE: '.ne'; -K_NAN: '.nan'; -K_MINNCTAPERSM: '.minnctapersm'; -K_MIN: '.min'; -K_MAXNTID: '.maxntid'; -K_MAXNREG: '.maxnreg'; -K_MAXNCTAPERSM: '.maxnctapersm'; -K_MAX: '.max'; -K_LU: '.lu'; -K_LTU: '.ltu'; -K_LT: '.lt'; -K_LS: '.ls'; -K_LOCAL: '.local'; -K_LOC: '.loc'; -K_LO: '.lo'; -K_LEU: '.leu'; -K_LE: '.le'; -K_L2: '.L2'; -K_L1: '.L1'; -K_INFINITE: '.infinite'; -K_INC: '.inc'; -K_HS: '.hs'; -K_HI: '.hi'; -K_HEIGHT: '.height'; -K_GTU: '.gtu'; -K_GT: '.gt'; -K_GLOBAL: '.global'; -K_GL: '.gl'; -K_GEU: '.geu'; -K_GE: '.ge'; -K_FUNC: '.func'; -K_FULL: '.full'; -K_FTZ: '.ftz'; -K_FINITE: '.finite'; -K_FILTER_MODE: '.filter_mode'; -K_FILE: '.file'; -K_F64: '.f64'; -K_F4E: '.f4e'; -K_F32: '.f32'; -K_F16: '.f16'; -K_EXTERN: '.extern'; -K_EXCH: '.exch'; -K_EQU: '.equ'; -K_EQ: '.eq'; -K_ENTRY: '.entry'; -K_ECR: '.ecr'; -K_ECL: '.ecl'; -K_DWARF: '@@DWARF' .*? ('\n' | '\r'); -K_DEPTH: '.depth'; -K_DEC: '.dec'; -K_CV: '.cv'; -K_CTA: '.cta'; -K_CS: '.cs'; -K_CONST: '.const'; -K_CLAMP: '.clamp'; -K_CHANNEL_ORDER: '.channel_order'; -K_CHANNEL_DATA_TYPE: '.channel_data_type'; -K_CHANNEL_DATA: '.channel_data'; -K_CG: '.cg'; -K_CC: '.cc'; -K_CAS: '.cas'; -K_CALLTARGETS: '.calltargets'; -K_CALLPROTOTYPE: '.callprototype'; -K_CA: '.ca'; -K_BRANCHTARGETS: '.branchtargets'; -K_BALLOT: '.ballot'; -K_B8: '.b8'; -K_B64: '.b64'; -K_B4E: '.b4e'; -K_B32: '.b32'; -K_B16: '.b16'; -K_ARRIVE: '.arrive'; -K_APPROX: '.approx'; -K_ANY: '.any'; -K_AND: '.and'; -K_ALL: '.all'; -K_ALIGN: '.align'; -K_ADDR_MODE_2: '.addr_mode_2'; -K_ADDR_MODE_1: '.addr_mode_1'; -K_ADDR_MODE_0: '.addr_mode_0'; -K_ADDRESS_SIZE: '.address_size'; -K_ADD: '.add'; -K_X: '.x'; -K_Y: '.y'; -K_Z: '.z'; -K_W: '.w'; -K_A: '.a'; -K_R: '.r'; -K_G: '.g'; -K_B: '.b'; -COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -WS: (' '| '\t' | '\r' | '\n')+ -> channel(HIDDEN); -T_WORD: (('a'..'z' | 'A'..'Z' ) FollowSym*) | (('_' | '%' | '$' ) FollowSym+ ); -T_UNDERSCORE: '_'; -T_AT: '@'; -T_PERCENT: '%'; -T_SLASH: '/'; -T_DOT: '.'; - -fragment -EscapeSequence - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') - | OctalEscape - ; - -fragment -OctalEscape - : '\\' ('0'..'3') ('0'..'7') ('0'..'7') - | '\\' ('0'..'7') ('0'..'7') - | '\\' ('0'..'7') - ; - -fragment -FollowSym - : ( 'a'..'z' | 'A'..'Z' | '0'..'9' | '_' | '$' ) +KI_ABS + : 'abs' + ; + +KI_ADD + : 'add' + ; + +KI_ADDC + : 'addc' + ; + +KI_AND + : 'and' + ; + +KI_ATOM + : 'atom' + ; + +KI_BAR + : 'bar' + ; + +KI_BFE + : 'bfe' + ; + +KI_BFI + : 'bfi' + ; + +KI_BFIND + : 'bfind' + ; + +KI_BRA + : 'bra' + ; + +KI_BREV + : 'brev' + ; + +KI_BRKPT + : 'brkpt' + ; + +KI_CALL + : 'call' + ; + +KI_CLZ + : 'clz' + ; + +KI_CNOT + : 'cnot' + ; + +KI_COPYSIGN + : 'copysign' + ; + +KI_COS + : 'cos' + ; + +KI_CVT + : 'cvt' + ; + +KI_CVTA + : 'cvta' + ; + +KI_DIV + : 'div' + ; + +KI_EX2 + : 'ex2' + ; + +KI_EXIT + : 'exit' + ; + +KI_FMA + : 'fma' + ; + +KI_ISSPACEP + : 'isspacep' + ; + +KI_LD + : 'ld' + ; + +KI_LDU + : 'ldu' + ; + +KI_LG2 + : 'lg2' + ; + +KI_MAD24 + : 'mad24' + ; + +KI_MAD + : 'mad' + ; + +KI_MAX + : 'max' + ; + +KI_MEMBAR + : 'membar' + ; + +KI_MIN + : 'min' + ; + +KI_MOV + : 'mov' + ; + +KI_MUL24 + : 'mul24' + ; + +KI_MUL + : 'mul' + ; + +KI_NEG + : 'neg' + ; + +KI_NOT + : 'not' + ; + +KI_OR + : 'or' + ; + +KI_PMEVENT + : 'pmevent' + ; + +KI_POPC + : 'popc' + ; + +KI_PREFETCH + : 'prefetch' + ; + +KI_PREFETCHU + : 'prefetchu' + ; + +KI_PRMT + : 'prmt' + ; + +KI_RCP + : 'rcp' + ; + +KI_RED + : 'red' + ; + +KI_REM + : 'rem' + ; + +KI_RET + : 'ret' + ; + +KI_RSQRT + : 'rsqrt' + ; + +KI_SAD + : 'sad' + ; + +KI_SELP + : 'selp' + ; + +KI_SETP + : 'setp' + ; + +// Note order after SETP +KI_SET + : 'set' + ; + +KI_SHL + : 'shl' + ; + +KI_SHR + : 'shr' + ; + +KI_SIN + : 'sin' + ; + +KI_SLCT + : 'slct' + ; + +KI_SQRT + : 'sqrt' + ; + +KI_ST + : 'st' + ; + +KI_SUB + : 'sub' + ; + +KI_SUBC + : 'subc' + ; + +KI_SULD + : 'suld' + ; + +KI_SUQ + : 'suq' + ; + +KI_SURED + : 'sured' + ; + +KI_SUST + : 'sust' + ; + +KI_TESTP + : 'testp' + ; + +KI_TEX + : 'tex' + ; + +KI_TRAP + : 'trap' + ; + +KI_TXQ + : 'txq' + ; + +KI_VABSDIFF + : 'vabsdiff' + ; + +KI_VADD + : 'vadd' + ; + +KI_VMAD + : 'vmad' + ; + +KI_VMAX + : 'vmax' + ; + +KI_VMIN + : 'vmin' + ; + +KI_VOTE + : 'vote' + ; + +KI_VSET + : 'vset' + ; + +KI_VSHL + : 'vshl' + ; + +KI_VSHR + : 'vshr' + ; + +KI_VSUB + : 'vsub' + ; + +KI_XOR + : 'xor' + ; + +T_QUESTION + : '?' + ; + +T_OROR + : '||' + ; + +T_ANDAND + : '&&' + ; + +T_OR + : '|' + ; + +T_XOR + : '^' + ; + +T_AND + : '&' + ; + +T_EQEQ + : '==' + ; + +T_LE + : '<=' + ; + +T_GE + : '>=' + ; + +T_LTLT + : '<<' + ; + +T_GTGT + : '>>' + ; + +T_STAR + : '*' + ; + +T_TILDE + : '~' + ; + +T_FLT_LITERAL + : ( + '0' ('f' | 'F' | 'd' | 'D') ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F')+ + | '.' ('0' .. '9')+ + | ('0' .. '9')+ '.' + | ('0' .. '9')+ '.' ('0' .. '9')+ + ) + ; + +T_HEX_LITERAL + : '0' ('x' | 'X') ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F')+ 'U'? + ; + +T_OCT_LITERAL + : '0' ('0' .. '7')+ 'U'? + ; + +T_DEC_LITERAL + : ('0' .. '9') ('0' .. '9')* 'U'? + ; + +K_3D + : '.3d' + ; + +K_2D + : '.2d' + ; + +K_1D + : '.1d' + ; + +U_DEBUG_ABBREV + : '.debug_abbrev' + ; + +U_DEBUG_INFO + : '.debug_info' + ; + +U_DEBUG_LINE + : '.debug_line' + ; + +U_DEBUG_LOC + : '.debug_loc' + ; + +U_DEBUG_PUBNAMES + : '.debug_pubnames' + ; + +U_DEBUG_RANGES + : '.debug_ranges' + ; + +U_BYTE + : '.byte' + ; + +U_4BYTE + : '.4byte' + ; + +T_EQ + : '=' + ; + +T_SEMICOLON + : ';' + ; + +T_PLUS + : '+' + ; + +T_OP + : '(' + ; + +T_OC + : '{' + ; + +T_OB + : '[' + ; + +T_NOTEQ + : '!=' + ; + +T_NOT + : '!' + ; + +T_MINUS + : '-' + ; + +T_GT + : '>' + ; + +T_LT + : '<' + ; + +T_ELLIPSIS + : '...' + ; + +T_CP + : ')' + ; + +T_COMMA + : ',' + ; + +T_COLON + : ':' + ; + +T_CC + : '}' + ; + +T_CB + : ']' + ; + +LINE_COMMENT + : '//' .*? ('\n' | '\r') -> channel(HIDDEN) + ; + +K_ZERO + : '.zero' + ; + +K_XOR + : '.xor' + ; + +K_WT + : '.wt' + ; + +K_WIDTH + : '.width' + ; + +K_WIDE + : '.wide' + ; + +K_WB + : '.wb' + ; + +K_VOLATILE + : '.volatile' + ; + +K_VISIBLE + : '.visible' + ; + +K_VERSION + : '.version' + ; + +K_VB + : '.vb' + ; + +K_V4 + : '.v4' + ; + +K_V2 + : '.v2' + ; + +K_UNI + : '.uni' + ; + +K_U8 + : '.u8' + ; + +K_U64 + : '.u64' + ; + +K_U32 + : '.u32' + ; + +K_U16 + : '.u16' + ; + +K_TRAP + : '.trap' + ; + +K_TO + : '.to' + ; + +K_TEXREF + : '.texref' + ; + +K_TEX + : '.tex' + ; + +K_TARGET + : '.target' + ; + +K_SYS + : '.sys' + ; + +K_SYNC + : '.sync' + ; + +K_SURFREF + : '.surfref' + ; + +K_SUBNORMAL + : '.subnormal' + ; + +K_SREG + : '.sreg' + ; + +K_SHIFTAMT + : '.shiftamt' + ; + +K_SHARED + : '.shared' + ; + +K_SECTION + : '.section' + ; + +K_SAT + : '.sat' + ; + +K_SAMPLERREF + : '.samplerref' + ; + +K_S8 + : '.s8' + ; + +K_S64 + : '.s64' + ; + +K_S32 + : '.s32' + ; + +K_S16 + : '.s16' + ; + +K_RZI + : '.rzi' + ; + +K_RZ + : '.rz' + ; + +K_RPI + : '.rpi' + ; + +K_RP + : '.rp' + ; + +K_RNI + : '.rni' + ; + +K_RN + : '.rn' + ; + +K_RMI + : '.rmi' + ; + +K_RM + : '.rm' + ; + +K_REQNTID + : '.reqntid' + ; + +K_REG + : '.reg' + ; + +K_RED + : '.red' + ; + +K_RCP + : '.rcp' + ; + +K_RC8 + : '.rc8' + ; + +K_RC16 + : '.rc16' + ; + +K_PRED + : '.pred' + ; + +K_PRAGMA + : '.pragma' + ; + +K_POPC + : '.popc' + ; + +K_PARAM + : '.param' + ; + +K_P + : '.p' + ; + +K_OR + : '.or' + ; + +K_OC + : '.oc' + ; + +K_NUMBER + : '.number' + ; + +K_NUM + : '.num' + ; + +K_NS + : '.ns' + ; + +K_NOUNROLL + : '"nounroll"' + ; + +T_STRING + : '"' (~('"'))* '"' + ; + +K_NOTANUMBER + : '.notanumber' + ; + +K_NORMALIZED_COORDS + : '.normalized_coords' + ; + +K_NORMAL + : '.normal' + ; + +K_NEU + : '.neu' + ; + +K_NE + : '.ne' + ; + +K_NAN + : '.nan' + ; + +K_MINNCTAPERSM + : '.minnctapersm' + ; + +K_MIN + : '.min' + ; + +K_MAXNTID + : '.maxntid' + ; + +K_MAXNREG + : '.maxnreg' + ; + +K_MAXNCTAPERSM + : '.maxnctapersm' + ; + +K_MAX + : '.max' + ; + +K_LU + : '.lu' + ; + +K_LTU + : '.ltu' + ; + +K_LT + : '.lt' + ; + +K_LS + : '.ls' + ; + +K_LOCAL + : '.local' + ; + +K_LOC + : '.loc' + ; + +K_LO + : '.lo' + ; + +K_LEU + : '.leu' + ; + +K_LE + : '.le' + ; + +K_L2 + : '.L2' + ; + +K_L1 + : '.L1' + ; + +K_INFINITE + : '.infinite' + ; + +K_INC + : '.inc' + ; + +K_HS + : '.hs' + ; + +K_HI + : '.hi' + ; + +K_HEIGHT + : '.height' + ; + +K_GTU + : '.gtu' + ; + +K_GT + : '.gt' + ; + +K_GLOBAL + : '.global' + ; + +K_GL + : '.gl' + ; + +K_GEU + : '.geu' + ; + +K_GE + : '.ge' + ; + +K_FUNC + : '.func' + ; + +K_FULL + : '.full' + ; + +K_FTZ + : '.ftz' + ; + +K_FINITE + : '.finite' + ; + +K_FILTER_MODE + : '.filter_mode' + ; + +K_FILE + : '.file' + ; + +K_F64 + : '.f64' + ; + +K_F4E + : '.f4e' + ; + +K_F32 + : '.f32' + ; + +K_F16 + : '.f16' + ; + +K_EXTERN + : '.extern' + ; + +K_EXCH + : '.exch' + ; + +K_EQU + : '.equ' + ; + +K_EQ + : '.eq' + ; + +K_ENTRY + : '.entry' + ; + +K_ECR + : '.ecr' + ; + +K_ECL + : '.ecl' + ; + +K_DWARF + : '@@DWARF' .*? ('\n' | '\r') + ; + +K_DEPTH + : '.depth' + ; + +K_DEC + : '.dec' + ; + +K_CV + : '.cv' + ; + +K_CTA + : '.cta' + ; + +K_CS + : '.cs' + ; + +K_CONST + : '.const' + ; + +K_CLAMP + : '.clamp' + ; + +K_CHANNEL_ORDER + : '.channel_order' + ; + +K_CHANNEL_DATA_TYPE + : '.channel_data_type' + ; + +K_CHANNEL_DATA + : '.channel_data' + ; + +K_CG + : '.cg' + ; + +K_CC + : '.cc' + ; + +K_CAS + : '.cas' + ; + +K_CALLTARGETS + : '.calltargets' + ; + +K_CALLPROTOTYPE + : '.callprototype' + ; + +K_CA + : '.ca' + ; + +K_BRANCHTARGETS + : '.branchtargets' + ; + +K_BALLOT + : '.ballot' + ; + +K_B8 + : '.b8' + ; + +K_B64 + : '.b64' + ; + +K_B4E + : '.b4e' + ; + +K_B32 + : '.b32' + ; + +K_B16 + : '.b16' + ; + +K_ARRIVE + : '.arrive' + ; + +K_APPROX + : '.approx' + ; + +K_ANY + : '.any' + ; + +K_AND + : '.and' + ; + +K_ALL + : '.all' + ; + +K_ALIGN + : '.align' + ; + +K_ADDR_MODE_2 + : '.addr_mode_2' + ; + +K_ADDR_MODE_1 + : '.addr_mode_1' + ; + +K_ADDR_MODE_0 + : '.addr_mode_0' + ; + +K_ADDRESS_SIZE + : '.address_size' + ; + +K_ADD + : '.add' + ; + +K_X + : '.x' + ; + +K_Y + : '.y' + ; + +K_Z + : '.z' + ; + +K_W + : '.w' + ; + +K_A + : '.a' + ; + +K_R + : '.r' + ; + +K_G + : '.g' + ; + +K_B + : '.b' + ; + +COMMENT + : '/*' .*? '*/' -> channel(HIDDEN) + ; + +WS + : (' ' | '\t' | '\r' | '\n')+ -> channel(HIDDEN) + ; + +T_WORD + : (('a' ..'z' | 'A' ..'Z') FollowSym*) + | (('_' | '%' | '$') FollowSym+) + ; + +T_UNDERSCORE + : '_' + ; + +T_AT + : '@' + ; + +T_PERCENT + : '%' + ; + +T_SLASH + : '/' + ; + +T_DOT + : '.' + ; + +fragment EscapeSequence + : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') + | OctalEscape + ; + +fragment OctalEscape + : '\\' ('0' ..'3') ('0' ..'7') ('0' ..'7') + | '\\' ('0' ..'7') ('0' ..'7') + | '\\' ('0' ..'7') ; +fragment FollowSym + : ('a' ..'z' | 'A' ..'Z' | '0' ..'9' | '_' | '$') + ; \ No newline at end of file diff --git a/asn/asn/ASN.g4 b/asn/asn/ASN.g4 index cedf31b9ed..84eabec36e 100644 --- a/asn/asn/ASN.g4 +++ b/asn/asn/ASN.g4 @@ -1,4 +1,4 @@ - /* +/* [The "BSD licence"] Copyright (c) 2007-2008 Terence Parr All rights reserved. @@ -42,63 +42,71 @@ of the predicates since it was too much ambiguity. If you have some comments/improvements, send me an e-mail. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging grammar ASN; -modules: moduleDefinition+ EOF; - -moduleDefinition : IDENTIFIER (L_BRACE (IDENTIFIER L_PARAN NUMBER R_PARAN)* R_BRACE)? - DEFINITIONS_LITERAL - tagDefault - extensionDefault - ASSIGN_OP - BEGIN_LITERAL - moduleBody - END_LITERAL - ; +modules + : moduleDefinition+ EOF + ; +moduleDefinition + : IDENTIFIER (L_BRACE (IDENTIFIER L_PARAN NUMBER R_PARAN)* R_BRACE)? DEFINITIONS_LITERAL tagDefault extensionDefault ASSIGN_OP BEGIN_LITERAL + moduleBody END_LITERAL + ; +tagDefault + : ((EXPLICIT_LITERAL | IMPLICIT_LITERAL | AUTOMATIC_LITERAL) TAGS_LITERAL)? + ; -tagDefault : ( (EXPLICIT_LITERAL|IMPLICIT_LITERAL|AUTOMATIC_LITERAL) TAGS_LITERAL )? -; +extensionDefault + : (EXTENSIBILITY_LITERAL IMPLIED_LITERAL)? + ; -extensionDefault : - (EXTENSIBILITY_LITERAL IMPLIED_LITERAL)? -; +moduleBody + : (exports imports assignmentList)? + ; -moduleBody : (exports imports assignmentList) ? -; -exports : (EXPORTS_LITERAL symbolsExported SEMI_COLON - | EXPORTS_LITERAL ALL_LITERAL SEMI_COLON )? -; +exports + : (EXPORTS_LITERAL symbolsExported SEMI_COLON | EXPORTS_LITERAL ALL_LITERAL SEMI_COLON)? + ; -symbolsExported : symbolList? -; +symbolsExported + : symbolList? + ; -imports : (IMPORTS_LITERAL symbolsImported SEMI_COLON )? -; +imports + : (IMPORTS_LITERAL symbolsImported SEMI_COLON)? + ; -symbolsImported : symbolsFromModuleList? -; +symbolsImported + : symbolsFromModuleList? + ; -symbolsFromModuleList : - symbolsFromModule symbolsFromModule* -; +symbolsFromModuleList + : symbolsFromModule symbolsFromModule* + ; -symbolsFromModule : symbolList FROM_LITERAL globalModuleReference -; +symbolsFromModule + : symbolList FROM_LITERAL globalModuleReference + ; -globalModuleReference : IDENTIFIER assignedIdentifier -; +globalModuleReference + : IDENTIFIER assignedIdentifier + ; -assignedIdentifier : -; +assignedIdentifier + : + ; -symbolList : symbol (COMMA symbol)* -; +symbolList + : symbol (COMMA symbol)* + ; -symbol : IDENTIFIER (L_BRACE R_BRACE)? -; +symbol + : IDENTIFIER (L_BRACE R_BRACE)? + ; //parameterizedReference : // reference (L_BRACE R_BRACE)? @@ -109,834 +117,1034 @@ symbol : IDENTIFIER (L_BRACE R_BRACE)? // identifier //; -assignmentList : assignment+ -; - - -assignment : - IDENTIFIER - ( valueAssignment - | typeAssignment - | parameterizedAssignment - | objectClassAssignment - ) - ; - -sequenceType :SEQUENCE_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists )? R_BRACE - ; -extensionAndException : ELLIPSIS exceptionSpec? -; -optionalExtensionMarker : ( COMMA ELLIPSIS )? -; - -componentTypeLists : - rootComponentTypeList (COMMA extensionAndException extensionAdditions (optionalExtensionMarker|EXTENSTIONENDMARKER COMMA rootComponentTypeList))? -// | rootComponentTypeList COMMA extensionAndException extensionAdditions optionalExtensionMarker -// | rootComponentTypeList COMMA extensionAndException extensionAdditions EXTENSTIONENDMARKER COMMA rootComponentTypeList - | extensionAndException extensionAdditions (optionalExtensionMarker | EXTENSTIONENDMARKER COMMA rootComponentTypeList) -// | extensionAndException extensionAdditions optionalExtensionMarker -; -rootComponentTypeList : componentTypeList -; -componentTypeList : componentType (COMMA componentType)* -; -componentType : - namedType (OPTIONAL_LITERAL | DEFAULT_LITERAL value )? - | COMPONENTS_LITERAL OF_LITERAL asnType -; - -extensionAdditions : (COMMA extensionAdditionList)? -; -extensionAdditionList : extensionAddition (COMMA extensionAddition)* -; -extensionAddition : componentType | extensionAdditionGroup -; -extensionAdditionGroup : DOUBLE_L_BRACKET versionNumber componentTypeList DOUBLE_R_BRACKET -; -versionNumber : (NUMBER COLON )? -; - -sequenceOfType : SEQUENCE_LITERAL (L_PARAN (constraint | sizeConstraint) R_PARAN)? OF_LITERAL (asnType | namedType ) -; -sizeConstraint : SIZE_LITERAL constraint - ; - -parameterizedAssignment : - parameterList - ASSIGN_OP - (asnType - | value - | valueSet - ) - -| definedObjectClass ASSIGN_OP - ( object_ - | objectClass - | objectSet - ) - - -// parameterizedTypeAssignment -//| parameterizedValueAssignment -//| parameterizedValueSetTypeAssignment -//| parameterizedObjectClassAssignment -//| parameterizedObjectAssignment -//| parameterizedObjectSetAssignment -; -parameterList : L_BRACE parameter (COMMA parameter)* R_BRACE -; -parameter : (paramGovernor COLON)? IDENTIFIER -; -paramGovernor : governor | IDENTIFIER -; +assignmentList + : assignment+ + ; + +assignment + : IDENTIFIER ( + valueAssignment + | typeAssignment + | parameterizedAssignment + | objectClassAssignment + ) + ; + +sequenceType + : SEQUENCE_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists)? R_BRACE + ; + +extensionAndException + : ELLIPSIS exceptionSpec? + ; + +optionalExtensionMarker + : (COMMA ELLIPSIS)? + ; + +componentTypeLists + : rootComponentTypeList ( + COMMA extensionAndException extensionAdditions ( + optionalExtensionMarker + | EXTENSTIONENDMARKER COMMA rootComponentTypeList + ) + )? + // | rootComponentTypeList COMMA extensionAndException extensionAdditions optionalExtensionMarker + // | rootComponentTypeList COMMA extensionAndException extensionAdditions EXTENSTIONENDMARKER COMMA rootComponentTypeList + | extensionAndException extensionAdditions ( + optionalExtensionMarker + | EXTENSTIONENDMARKER COMMA rootComponentTypeList + ) + // | extensionAndException extensionAdditions optionalExtensionMarker + ; + +rootComponentTypeList + : componentTypeList + ; + +componentTypeList + : componentType (COMMA componentType)* + ; + +componentType + : namedType (OPTIONAL_LITERAL | DEFAULT_LITERAL value)? + | COMPONENTS_LITERAL OF_LITERAL asnType + ; + +extensionAdditions + : (COMMA extensionAdditionList)? + ; + +extensionAdditionList + : extensionAddition (COMMA extensionAddition)* + ; + +extensionAddition + : componentType + | extensionAdditionGroup + ; + +extensionAdditionGroup + : DOUBLE_L_BRACKET versionNumber componentTypeList DOUBLE_R_BRACKET + ; + +versionNumber + : (NUMBER COLON)? + ; + +sequenceOfType + : SEQUENCE_LITERAL (L_PARAN (constraint | sizeConstraint) R_PARAN)? OF_LITERAL ( + asnType + | namedType + ) + ; + +sizeConstraint + : SIZE_LITERAL constraint + ; + +parameterizedAssignment + : parameterList ASSIGN_OP (asnType | value | valueSet) + | definedObjectClass ASSIGN_OP (object_ | objectClass | objectSet) + + // parameterizedTypeAssignment + //| parameterizedValueAssignment + //| parameterizedValueSetTypeAssignment + //| parameterizedObjectClassAssignment + //| parameterizedObjectAssignment + //| parameterizedObjectSetAssignment + ; + +parameterList + : L_BRACE parameter (COMMA parameter)* R_BRACE + ; + +parameter + : (paramGovernor COLON)? IDENTIFIER + ; + +paramGovernor + : governor + | IDENTIFIER + ; + //dummyGovernor : dummyReference //; -governor : asnType | definedObjectClass -; - - -objectClassAssignment : /*IDENTIFIER*/ ASSIGN_OP objectClass -; - -objectClass : definedObjectClass | objectClassDefn /*| parameterizedObjectClass */ -; -definedObjectClass : - (IDENTIFIER DOT)? IDENTIFIER - | TYPE_IDENTIFIER_LITERAL - | ABSTRACT_SYNTAX_LITERAL -; -usefulObjectClassReference : - TYPE_IDENTIFIER_LITERAL - | ABSTRACT_SYNTAX_LITERAL -; - -externalObjectClassReference : IDENTIFIER DOT IDENTIFIER -; - -objectClassDefn : CLASS_LITERAL L_BRACE fieldSpec (COMMA fieldSpec )* R_BRACE withSyntaxSpec? -; -withSyntaxSpec : WITH_LITERAL SYNTAX_LITERAL syntaxList -; -syntaxList : L_BRACE tokenOrGroupSpec+ R_BRACE -; - -tokenOrGroupSpec : requiredToken | optionalGroup -; - -optionalGroup : L_BRACKET tokenOrGroupSpec+ R_BRACKET -; - -requiredToken : literal | primitiveFieldName -; -literal : IDENTIFIER | COMMA -; -primitiveFieldName : - AMPERSAND IDENTIFIER; - - -fieldSpec : - AMPERSAND IDENTIFIER - ( - typeOptionalitySpec? - | asnType (valueSetOptionalitySpec? | UNIQUE_LITERAL? valueOptionalitySpec? ) - | fieldName (OPTIONAL_LITERAL | DEFAULT_LITERAL (valueSet | value))? - | definedObjectClass (OPTIONAL_LITERAL | DEFAULT_LITERAL (objectSet | object_))? - - ) - -// typeFieldSpec -// | fixedTypeValueFieldSpec -// | variableTypeValueFieldSpec -// | fixedTypeValueSetFieldSpec -// | variableTypeValueSetFieldSpec -// | objectFieldSpec -// | objectSetFieldSpec -; - -typeFieldSpec : AMPERSAND IDENTIFIER typeOptionalitySpec? -; -typeOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL asnType -; -fixedTypeValueFieldSpec : AMPERSAND IDENTIFIER asnType UNIQUE_LITERAL? valueOptionalitySpec ? -; -valueOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL value -; - -variableTypeValueFieldSpec : AMPERSAND IDENTIFIER fieldName valueOptionalitySpec ? -; - -fixedTypeValueSetFieldSpec : AMPERSAND IDENTIFIER asnType valueSetOptionalitySpec ? -; - -valueSetOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL valueSet -; - -object_ : definedObject /*| objectDefn | objectFromObject */| parameterizedObject -; -parameterizedObject : definedObject actualParameterList -; +governor + : asnType + | definedObjectClass + ; + +objectClassAssignment + : /*IDENTIFIER*/ ASSIGN_OP objectClass + ; + +objectClass + : definedObjectClass + | objectClassDefn /*| parameterizedObjectClass */ + ; + +definedObjectClass + : (IDENTIFIER DOT)? IDENTIFIER + | TYPE_IDENTIFIER_LITERAL + | ABSTRACT_SYNTAX_LITERAL + ; + +usefulObjectClassReference + : TYPE_IDENTIFIER_LITERAL + | ABSTRACT_SYNTAX_LITERAL + ; + +externalObjectClassReference + : IDENTIFIER DOT IDENTIFIER + ; + +objectClassDefn + : CLASS_LITERAL L_BRACE fieldSpec (COMMA fieldSpec)* R_BRACE withSyntaxSpec? + ; + +withSyntaxSpec + : WITH_LITERAL SYNTAX_LITERAL syntaxList + ; + +syntaxList + : L_BRACE tokenOrGroupSpec+ R_BRACE + ; + +tokenOrGroupSpec + : requiredToken + | optionalGroup + ; + +optionalGroup + : L_BRACKET tokenOrGroupSpec+ R_BRACKET + ; + +requiredToken + : literal + | primitiveFieldName + ; + +literal + : IDENTIFIER + | COMMA + ; + +primitiveFieldName + : AMPERSAND IDENTIFIER + ; + +fieldSpec + : AMPERSAND IDENTIFIER ( + typeOptionalitySpec? + | asnType (valueSetOptionalitySpec? | UNIQUE_LITERAL? valueOptionalitySpec?) + | fieldName (OPTIONAL_LITERAL | DEFAULT_LITERAL (valueSet | value))? + | definedObjectClass (OPTIONAL_LITERAL | DEFAULT_LITERAL (objectSet | object_))? + ) + + // typeFieldSpec + // | fixedTypeValueFieldSpec + // | variableTypeValueFieldSpec + // | fixedTypeValueSetFieldSpec + // | variableTypeValueSetFieldSpec + // | objectFieldSpec + // | objectSetFieldSpec + ; + +typeFieldSpec + : AMPERSAND IDENTIFIER typeOptionalitySpec? + ; + +typeOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL asnType + ; + +fixedTypeValueFieldSpec + : AMPERSAND IDENTIFIER asnType UNIQUE_LITERAL? valueOptionalitySpec? + ; + +valueOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL value + ; +variableTypeValueFieldSpec + : AMPERSAND IDENTIFIER fieldName valueOptionalitySpec? + ; + +fixedTypeValueSetFieldSpec + : AMPERSAND IDENTIFIER asnType valueSetOptionalitySpec? + ; + +valueSetOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL valueSet + ; + +object_ + : definedObject /*| objectDefn | objectFromObject */ + | parameterizedObject + ; + +parameterizedObject + : definedObject actualParameterList + ; definedObject - : IDENTIFIER DOT? - ; -objectSet : L_BRACE objectSetSpec R_BRACE -; -objectSetSpec : - rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec )?)? - | ELLIPSIS (COMMA additionalElementSetSpec )? -; - - -fieldName : AMPERSAND IDENTIFIER(AMPERSAND IDENTIFIER DOT)* -; -valueSet : L_BRACE elementSetSpecs R_BRACE -; -elementSetSpecs : - rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec)?)? - ; -rootElementSetSpec : elementSetSpec -; -additionalElementSetSpec : elementSetSpec -; -elementSetSpec : unions | ALL_LITERAL exclusions -; -unions : intersections (unionMark intersections)* -; -exclusions : EXCEPT_LITERAL elements -; -intersections : intersectionElements (intersectionMark intersectionElements)* -; -unionMark : PIPE | UNION_LITERAL -; - -intersectionMark : POWER | INTERSECTION_LITERAL -; - -elements : subtypeElements -// | objectSetElements -// | L_PARAN elementSetSpec R_PARAN -; -objectSetElements : - object_ | definedObject /*| objectSetFromObjects | parameterizedObjectSet */ -; - - -intersectionElements : elements exclusions? -; -subtypeElements : - (value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) - |sizeConstraint - | PATTERN_LITERAL value - | value -; - - -variableTypeValueSetFieldSpec : AMPERSAND IDENTIFIER fieldName valueSetOptionalitySpec? -; -objectFieldSpec : AMPERSAND IDENTIFIER definedObjectClass objectOptionalitySpec? -; -objectOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL object_ -; -objectSetFieldSpec : AMPERSAND IDENTIFIER definedObjectClass objectSetOptionalitySpec ? -; -objectSetOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL objectSet -; - -typeAssignment : - ASSIGN_OP - asnType -; - -valueAssignment : - asnType - ASSIGN_OP - value -; -asnType : (builtinType | referencedType) constraint* -; -builtinType : - octetStringType - | bitStringType - | choiceType - | enumeratedType - | integerType - | sequenceType - | sequenceOfType - | setType - | setOfType - | objectidentifiertype - | objectClassFieldType - | BOOLEAN_LITERAL - | NULL_LITERAL - - ; - -objectClassFieldType : definedObjectClass DOT fieldName -; - - -setType : SET_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists)? R_BRACE - ; - -setOfType : SET_LITERAL (constraint | sizeConstraint)? OF_LITERAL (asnType | namedType) -; - -referencedType : - definedType -// | selectionType -// | typeFromObject -// | valueSetFromObjects -; -definedType : -IDENTIFIER (DOT IDENTIFIER)? actualParameterList? -; - - -constraint :L_PARAN constraintSpec exceptionSpec? R_PARAN -//L_PARAN value DOT_DOT value R_PARAN -; - -constraintSpec : generalConstraint | subtypeConstraint -; -userDefinedConstraint : CONSTRAINED_LITERAL BY_LITERAL L_BRACE userDefinedConstraintParameter (COMMA userDefinedConstraintParameter)* R_BRACE -; - -generalConstraint : userDefinedConstraint | tableConstraint | contentsConstraint -; -userDefinedConstraintParameter : - governor (COLON - value - | valueSet - | object_ - | objectSet - )? -; - -tableConstraint : /*simpleTableConstraint |*/ componentRelationConstraint -; -simpleTableConstraint : objectSet -; - - -contentsConstraint : - CONTAINING_LITERAL asnType - | ENCODED_LITERAL BY_LITERAL value - | CONTAINING_LITERAL asnType ENCODED_LITERAL BY_LITERAL value - | WITH_LITERAL COMPONENTS_LITERAL L_BRACE componentPresenceLists R_BRACE -; - -componentPresenceLists: - componentPresenceList? (COMMA ELLIPSIS (COMMA componentPresenceList)?)? - | ELLIPSIS (COMMA componentPresenceList)? -; - -componentPresenceList: componentPresence (COMMA componentPresence)* -; - -componentPresence: IDENTIFIER (ABSENT_LITERAL | PRESENT_LITERAL) -; - - -subtypeConstraint : + : IDENTIFIER DOT? + ; + +objectSet + : L_BRACE objectSetSpec R_BRACE + ; + +objectSetSpec + : rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec)?)? + | ELLIPSIS (COMMA additionalElementSetSpec)? + ; + +fieldName + : AMPERSAND IDENTIFIER (AMPERSAND IDENTIFIER DOT)* + ; + +valueSet + : L_BRACE elementSetSpecs R_BRACE + ; + elementSetSpecs -//((value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) ) -// | sizeConstraint -// | value - ; -value : builtinValue -; -builtinValue : - enumeratedValue - | integerValue - | choiceValue - | objectIdentifierValue - | booleanValue - | CSTRING - | BSTRING - ; - -objectIdentifierValue : L_BRACE /*(definedValue)?*/ objIdComponentsList R_BRACE -; + : rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec)?)? + ; + +rootElementSetSpec + : elementSetSpec + ; + +additionalElementSetSpec + : elementSetSpec + ; + +elementSetSpec + : unions + | ALL_LITERAL exclusions + ; + +unions + : intersections (unionMark intersections)* + ; + +exclusions + : EXCEPT_LITERAL elements + ; + +intersections + : intersectionElements (intersectionMark intersectionElements)* + ; + +unionMark + : PIPE + | UNION_LITERAL + ; + +intersectionMark + : POWER + | INTERSECTION_LITERAL + ; + +elements + : subtypeElements + // | objectSetElements + // | L_PARAN elementSetSpec R_PARAN + ; + +objectSetElements + : object_ + | definedObject /*| objectSetFromObjects | parameterizedObjectSet */ + ; + +intersectionElements + : elements exclusions? + ; + +subtypeElements + : (value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) + | sizeConstraint + | PATTERN_LITERAL value + | value + ; + +variableTypeValueSetFieldSpec + : AMPERSAND IDENTIFIER fieldName valueSetOptionalitySpec? + ; + +objectFieldSpec + : AMPERSAND IDENTIFIER definedObjectClass objectOptionalitySpec? + ; + +objectOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL object_ + ; + +objectSetFieldSpec + : AMPERSAND IDENTIFIER definedObjectClass objectSetOptionalitySpec? + ; + +objectSetOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL objectSet + ; + +typeAssignment + : ASSIGN_OP asnType + ; + +valueAssignment + : asnType ASSIGN_OP value + ; + +asnType + : (builtinType | referencedType) constraint* + ; + +builtinType + : octetStringType + | bitStringType + | choiceType + | enumeratedType + | integerType + | sequenceType + | sequenceOfType + | setType + | setOfType + | objectidentifiertype + | objectClassFieldType + | BOOLEAN_LITERAL + | NULL_LITERAL + ; + +objectClassFieldType + : definedObjectClass DOT fieldName + ; + +setType + : SET_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists)? R_BRACE + ; + +setOfType + : SET_LITERAL (constraint | sizeConstraint)? OF_LITERAL (asnType | namedType) + ; + +referencedType + : definedType + // | selectionType + // | typeFromObject + // | valueSetFromObjects + ; + +definedType + : IDENTIFIER (DOT IDENTIFIER)? actualParameterList? + ; + +constraint + : L_PARAN constraintSpec exceptionSpec? R_PARAN + //L_PARAN value DOT_DOT value R_PARAN + ; + +constraintSpec + : generalConstraint + | subtypeConstraint + ; + +userDefinedConstraint + : CONSTRAINED_LITERAL BY_LITERAL L_BRACE userDefinedConstraintParameter ( + COMMA userDefinedConstraintParameter + )* R_BRACE + ; + +generalConstraint + : userDefinedConstraint + | tableConstraint + | contentsConstraint + ; + +userDefinedConstraintParameter + : governor (COLON value | valueSet | object_ | objectSet)? + ; + +tableConstraint + : /*simpleTableConstraint |*/ componentRelationConstraint + ; + +simpleTableConstraint + : objectSet + ; + +contentsConstraint + : CONTAINING_LITERAL asnType + | ENCODED_LITERAL BY_LITERAL value + | CONTAINING_LITERAL asnType ENCODED_LITERAL BY_LITERAL value + | WITH_LITERAL COMPONENTS_LITERAL L_BRACE componentPresenceLists R_BRACE + ; + +componentPresenceLists + : componentPresenceList? (COMMA ELLIPSIS (COMMA componentPresenceList)?)? + | ELLIPSIS (COMMA componentPresenceList)? + ; + +componentPresenceList + : componentPresence (COMMA componentPresence)* + ; + +componentPresence + : IDENTIFIER (ABSENT_LITERAL | PRESENT_LITERAL) + ; + +subtypeConstraint + : elementSetSpecs + //((value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) ) + // | sizeConstraint + // | value + ; + +value + : builtinValue + ; + +builtinValue + : enumeratedValue + | integerValue + | choiceValue + | objectIdentifierValue + | booleanValue + | CSTRING + | BSTRING + ; + +objectIdentifierValue + : L_BRACE /*(definedValue)?*/ objIdComponentsList R_BRACE + ; + objIdComponentsList - : objIdComponents objIdComponents* -; -objIdComponents : - NUMBER - | IDENTIFIER (L_PARAN (NUMBER | definedValue ) R_PARAN)? - | definedValue -; - - -integerValue : signedNumber | IDENTIFIER -; - -choiceValue : IDENTIFIER COLON value -; -enumeratedValue : IDENTIFIER -; - -signedNumber : MINUS? NUMBER -; -choiceType : CHOICE_LITERAL L_BRACE alternativeTypeLists R_BRACE -; -alternativeTypeLists : rootAlternativeTypeList (COMMA - extensionAndException extensionAdditionAlternatives optionalExtensionMarker )? - ; -extensionAdditionAlternatives : (COMMA extensionAdditionAlternativesList )? -; -extensionAdditionAlternativesList : extensionAdditionAlternative (COMMA extensionAdditionAlternative)* -; -extensionAdditionAlternative : extensionAdditionAlternativesGroup | namedType -; -extensionAdditionAlternativesGroup : DOUBLE_L_BRACKET versionNumber alternativeTypeList DOUBLE_R_BRACKET -; - -rootAlternativeTypeList : alternativeTypeList -; -alternativeTypeList : namedType (COMMA namedType)* -; -namedType : IDENTIFIER asnType -; -enumeratedType : ENUMERATED_LITERAL L_BRACE enumerations R_BRACE -; -enumerations :rootEnumeration (COMMA ELLIPSIS exceptionSpec? (COMMA additionalEnumeration )?)? - ; -rootEnumeration : enumeration -; -enumeration : enumerationItem ( COMMA enumerationItem)* -; -enumerationItem : IDENTIFIER | namedNumber | value -; -namedNumber : IDENTIFIER L_PARAN (signedNumber | definedValue) R_PARAN -; -definedValue : - // externalValueReference - //| valuereference - parameterizedValue -; -parameterizedValue : simpleDefinedValue actualParameterList? -; -simpleDefinedValue : IDENTIFIER (DOT IDENTIFIER)? -; - -actualParameterList : L_BRACE actualParameter (COMMA actualParameter)* R_BRACE -; -actualParameter : asnType | value /*| valueSet | definedObjectClass | object_ | objectSet*/ -; -exceptionSpec : EXCLAM exceptionIdentification -; -exceptionIdentification : signedNumber - | definedValue - | asnType COLON value -; -additionalEnumeration : enumeration -; -integerType:INTEGER_LITERAL (L_BRACE namedNumberList R_BRACE)? -; -namedNumberList : namedNumber (COMMA namedNumber)* -; -objectidentifiertype : OBJECT_LITERAL IDENTIFIER_LITERAL -; -componentRelationConstraint : L_BRACE IDENTIFIER (DOT IDENTIFIER)? R_BRACE - (L_BRACE atNotation (COMMA atNotation)* R_BRACE)? -; -atNotation : (A_ROND | A_ROND_DOT level) componentIdList -; -level : (DOT level)? -; - -componentIdList : IDENTIFIER (DOT IDENTIFIER)* //????? -; -octetStringType : OCTET_LITERAL STRING_LITERAL -; -bitStringType : BIT_LITERAL STRING_LITERAL (L_BRACE namedBitList R_BRACE)? -; -namedBitList: namedBit (COMMA namedBit)* -; -namedBit : IDENTIFIER L_PARAN (NUMBER | definedValue) R_PARAN - ; - -booleanValue: TRUE_LITERAL | FALSE_LITERAL | TRUE_SMALL_LITERAL | FALSE_SMALL_LITERAL -; + : objIdComponents objIdComponents* + ; + +objIdComponents + : NUMBER + | IDENTIFIER (L_PARAN (NUMBER | definedValue) R_PARAN)? + | definedValue + ; + +integerValue + : signedNumber + | IDENTIFIER + ; + +choiceValue + : IDENTIFIER COLON value + ; + +enumeratedValue + : IDENTIFIER + ; + +signedNumber + : MINUS? NUMBER + ; + +choiceType + : CHOICE_LITERAL L_BRACE alternativeTypeLists R_BRACE + ; + +alternativeTypeLists + : rootAlternativeTypeList ( + COMMA extensionAndException extensionAdditionAlternatives optionalExtensionMarker + )? + ; + +extensionAdditionAlternatives + : (COMMA extensionAdditionAlternativesList)? + ; + +extensionAdditionAlternativesList + : extensionAdditionAlternative (COMMA extensionAdditionAlternative)* + ; + +extensionAdditionAlternative + : extensionAdditionAlternativesGroup + | namedType + ; + +extensionAdditionAlternativesGroup + : DOUBLE_L_BRACKET versionNumber alternativeTypeList DOUBLE_R_BRACKET + ; + +rootAlternativeTypeList + : alternativeTypeList + ; + +alternativeTypeList + : namedType (COMMA namedType)* + ; + +namedType + : IDENTIFIER asnType + ; + +enumeratedType + : ENUMERATED_LITERAL L_BRACE enumerations R_BRACE + ; + +enumerations + : rootEnumeration (COMMA ELLIPSIS exceptionSpec? (COMMA additionalEnumeration)?)? + ; + +rootEnumeration + : enumeration + ; + +enumeration + : enumerationItem (COMMA enumerationItem)* + ; + +enumerationItem + : IDENTIFIER + | namedNumber + | value + ; + +namedNumber + : IDENTIFIER L_PARAN (signedNumber | definedValue) R_PARAN + ; + +definedValue + : + // externalValueReference + //| valuereference + parameterizedValue + ; + +parameterizedValue + : simpleDefinedValue actualParameterList? + ; + +simpleDefinedValue + : IDENTIFIER (DOT IDENTIFIER)? + ; + +actualParameterList + : L_BRACE actualParameter (COMMA actualParameter)* R_BRACE + ; + +actualParameter + : asnType + | value /*| valueSet | definedObjectClass | object_ | objectSet*/ + ; + +exceptionSpec + : EXCLAM exceptionIdentification + ; + +exceptionIdentification + : signedNumber + | definedValue + | asnType COLON value + ; + +additionalEnumeration + : enumeration + ; + +integerType + : INTEGER_LITERAL (L_BRACE namedNumberList R_BRACE)? + ; + +namedNumberList + : namedNumber (COMMA namedNumber)* + ; + +objectidentifiertype + : OBJECT_LITERAL IDENTIFIER_LITERAL + ; + +componentRelationConstraint + : L_BRACE IDENTIFIER (DOT IDENTIFIER)? R_BRACE (L_BRACE atNotation (COMMA atNotation)* R_BRACE)? + ; + +atNotation + : (A_ROND | A_ROND_DOT level) componentIdList + ; + +level + : (DOT level)? + ; + +componentIdList + : IDENTIFIER (DOT IDENTIFIER)* //????? + ; + +octetStringType + : OCTET_LITERAL STRING_LITERAL + ; + +bitStringType + : BIT_LITERAL STRING_LITERAL (L_BRACE namedBitList R_BRACE)? + ; + +namedBitList + : namedBit (COMMA namedBit)* + ; + +namedBit + : IDENTIFIER L_PARAN (NUMBER | definedValue) R_PARAN + ; + +booleanValue + : TRUE_LITERAL + | FALSE_LITERAL + | TRUE_SMALL_LITERAL + | FALSE_SMALL_LITERAL + ; A_ROND - : '@' - ; + : '@' + ; STAR - : '*' - ; + : '*' + ; ASSIGN_OP - : '::=' - ; + : '::=' + ; BOOLEAN_LITERAL - : 'BOOLEAN' - ; + : 'BOOLEAN' + ; TRUE_LITERAL - : 'TRUE' - ; + : 'TRUE' + ; FALSE_LITERAL - : 'FALSE' - ; + : 'FALSE' + ; DOT - : '.' - ; + : '.' + ; DOUBLE_DOT - : '..' - ; + : '..' + ; + ELLIPSIS - : '...' - ; + : '...' + ; APOSTROPHE - : '\'' - ; + : '\'' + ; AMPERSAND - : '&' - ; + : '&' + ; LESS_THAN - : '<' - ; + : '<' + ; GREATER_THAN - : '>' - ; + : '>' + ; LESS_THAN_SLASH - : '' - ; + : '/>' + ; TRUE_SMALL_LITERAL - : 'true' - ; + : 'true' + ; FALSE_SMALL_LITERAL - : 'false' - ; + : 'false' + ; INTEGER_LITERAL - : 'INTEGER' - ; + : 'INTEGER' + ; L_BRACE - : '{' - ; + : '{' + ; R_BRACE - : '}' - ; + : '}' + ; COMMA - : ',' - ; + : ',' + ; L_PARAN - : '(' - ; + : '(' + ; R_PARAN - : ')' - ; + : ')' + ; MINUS - : '-' - ; + : '-' + ; ENUMERATED_LITERAL - : 'ENUMERATED' - ; - + : 'ENUMERATED' + ; REAL_LITERAL - : 'REAL' - ; + : 'REAL' + ; PLUS_INFINITY_LITERAL - : 'PLUS-INFINITY' - ; + : 'PLUS-INFINITY' + ; MINUS_INFINITY_LITERAL - : 'MINUS-INFINITY' - ; + : 'MINUS-INFINITY' + ; BIT_LITERAL - : 'BIT' - ; + : 'BIT' + ; STRING_LITERAL - : 'STRING' - ; + : 'STRING' + ; CONTAINING_LITERAL - : 'CONTAINING' - ; + : 'CONTAINING' + ; OCTET_LITERAL - : 'OCTET' - ; + : 'OCTET' + ; NULL_LITERAL - : 'NULL' - ; + : 'NULL' + ; SEQUENCE_LITERAL - : 'SEQUENCE' - ; + : 'SEQUENCE' + ; OPTIONAL_LITERAL - : 'OPTIONAL' - ; + : 'OPTIONAL' + ; DEFAULT_LITERAL - : 'DEFAULT' - ; + : 'DEFAULT' + ; COMPONENTS_LITERAL - : 'COMPONENTS' - ; + : 'COMPONENTS' + ; OF_LITERAL - : 'OF' - ; + : 'OF' + ; SET_LITERAL - : 'SET' - ; + : 'SET' + ; EXCLAM - : '!' - ; + : '!' + ; ALL_LITERAL - : 'ALL' - ; + : 'ALL' + ; EXCEPT_LITERAL - : 'EXCEPT' - ; + : 'EXCEPT' + ; POWER - : '^' - ; + : '^' + ; PIPE - : '|' - ; + : '|' + ; UNION_LITERAL - : 'UNION' - ; + : 'UNION' + ; INTERSECTION_LITERAL - : 'INTERSECTION' - ; + : 'INTERSECTION' + ; INCLUDES_LITERAL - : 'INCLUDES' - ; + : 'INCLUDES' + ; MIN_LITERAL - : 'MIN' - ; + : 'MIN' + ; MAX_LITERAL - : 'MAX' - ; + : 'MAX' + ; SIZE_LITERAL - : 'SIZE' - ; + : 'SIZE' + ; FROM_LITERAL - : 'FROM' - ; + : 'FROM' + ; WITH_LITERAL - : 'WITH' - ; + : 'WITH' + ; COMPONENT_LITERAL - : 'COMPONENT' - ; + : 'COMPONENT' + ; PRESENT_LITERAL - : 'PRESENT' - ; + : 'PRESENT' + ; ABSENT_LITERAL - : 'ABSENT' - ; + : 'ABSENT' + ; PATTERN_LITERAL - : 'PATTERN' - ; + : 'PATTERN' + ; TYPE_IDENTIFIER_LITERAL - : 'TYPE-Identifier' - ; + : 'TYPE-Identifier' + ; ABSTRACT_SYNTAX_LITERAL - : 'ABSTRACT-SYNTAX' - ; + : 'ABSTRACT-SYNTAX' + ; CLASS_LITERAL - : 'CLASS' - ; + : 'CLASS' + ; UNIQUE_LITERAL - : 'UNIQUE' - ; + : 'UNIQUE' + ; SYNTAX_LITERAL - : 'SYNTAX' - ; + : 'SYNTAX' + ; L_BRACKET - : '[' - ; + : '[' + ; R_BRACKET - : ']' - ; + : ']' + ; INSTANCE_LITERAL - : 'INSTANCE' - ; + : 'INSTANCE' + ; SEMI_COLON - : ';' - ; + : ';' + ; IMPORTS_LITERAL - : 'IMPORTS' - ; + : 'IMPORTS' + ; EXPORTS_LITERAL - : 'EXPORTS' - ; + : 'EXPORTS' + ; EXTENSIBILITY_LITERAL - : 'EXTENSIBILITY' - ; + : 'EXTENSIBILITY' + ; IMPLIED_LITERAL - : 'IMPLIED' - ; + : 'IMPLIED' + ; EXPLICIT_LITERAL - : 'EXPLICIT' - ; + : 'EXPLICIT' + ; TAGS_LITERAL - : 'TAGS' - ; + : 'TAGS' + ; IMPLICIT_LITERAL - : 'IMPLICIT' - ; + : 'IMPLICIT' + ; AUTOMATIC_LITERAL - : 'AUTOMATIC' - ; + : 'AUTOMATIC' + ; DEFINITIONS_LITERAL - : 'DEFINITIONS' - ; + : 'DEFINITIONS' + ; BEGIN_LITERAL - : 'BEGIN' - ; + : 'BEGIN' + ; END_LITERAL - : 'END' - ; + : 'END' + ; DOUBLE_L_BRACKET - : '[[' - ; + : '[[' + ; DOUBLE_R_BRACKET - : ']]' - ; + : ']]' + ; COLON - : ':' - ; + : ':' + ; CHOICE_LITERAL - : 'CHOICE' - ; + : 'CHOICE' + ; UNIVERSAL_LITERAL - : 'UNIVERSAL' - ; + : 'UNIVERSAL' + ; APPLICATION_LITERAL - : 'APPLICATION' - ; + : 'APPLICATION' + ; PRIVATE_LITERAL - : 'PRIVATE' - ; + : 'PRIVATE' + ; EMBEDDED_LITERAL - : 'EMBEDDED' - ; + : 'EMBEDDED' + ; PDV_LITERAL - : 'PDV' - ; + : 'PDV' + ; EXTERNAL_LITERAL - : 'EXTERNAL' - ; + : 'EXTERNAL' + ; OBJECT_LITERAL - : 'OBJECT' - ; + : 'OBJECT' + ; + IDENTIFIER_LITERAL - : 'IDENTIFIER' - ; + : 'IDENTIFIER' + ; + RELATIVE_OID_LITERAL - : 'RELATIVE-OID' - ; + : 'RELATIVE-OID' + ; CHARACTER_LITERAL - : 'CHARACTER' - ; + : 'CHARACTER' + ; CONSTRAINED_LITERAL - : 'CONSTRAINED' - ; + : 'CONSTRAINED' + ; BY_LITERAL - : 'BY' - ; + : 'BY' + ; A_ROND_DOT - : '@.' - ; + : '@.' + ; ENCODED_LITERAL - : 'ENCODED' - ; + : 'ENCODED' + ; COMMENT - : '--' + : '--' ; UNRESTRICTEDCHARACTERSTRINGTYPE @@ -944,19 +1152,19 @@ UNRESTRICTEDCHARACTERSTRINGTYPE ; EXTENSTIONENDMARKER - : COMMA ELLIPSIS + : COMMA ELLIPSIS ; fragment DIGIT - : '0'..'9' + : '0' ..'9' ; fragment UPPER - : 'A'..'Z' + : 'A' ..'Z' ; fragment LOWER - : 'a'..'z' + : 'a' ..'z' ; NUMBER @@ -964,89 +1172,83 @@ NUMBER ; WS - : (' '|'\r'|'\t'|'\u000C'|'\n') -> skip + : (' ' | '\r' | '\t' | '\u000C' | '\n') -> skip ; fragment Exponent - : ('e'|'E') ('+'|'-')? NUMBER + : ('e' | 'E') ('+' | '-')? NUMBER ; LINE_COMMENT - : '--' ~('\n'|'\r')* '\r'? '\n' ->skip + : '--' ~('\n' | '\r')* '\r'? '\n' -> skip ; BSTRING - : APOSTROPHE ('0'..'1')* '\'B' + : APOSTROPHE ('0' ..'1')* '\'B' ; fragment HEXDIGIT - : DIGIT | 'a'..'f' | 'A'..'F' + : DIGIT + | 'a' ..'f' + | 'A' ..'F' ; HSTRING : APOSTROPHE HEXDIGIT* '\'H' ; - - - //IDENTIFIER : ('a'..'z'|'A'..'Z') ('0'..'9'|'a'..'z'|'A'..'Z')* ; CSTRING - : '"' ( EscapeSequence | ~('\\'|'"') )* '"' + : '"' (EscapeSequence | ~('\\' | '"'))* '"' ; -fragment -EscapeSequence - : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|APOSTROPHE|'\\') +fragment EscapeSequence + : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | APOSTROPHE | '\\') ; - - //fragment /**I found this char range in JavaCC's grammar, but Letter and Digit overlap. Still works, but... */ -fragment -LETTER - : '\u0024' | - '\u002d' | - '\u0041'..'\u005a' | - '\u005f' | - '\u0061'..'\u007a' | - '\u00c0'..'\u00d6' | - '\u00d8'..'\u00f6' | - '\u00f8'..'\u00ff' | - '\u0100'..'\u1fff' | - '\u3040'..'\u318f' | - '\u3300'..'\u337f' | - '\u3400'..'\u3d2d' | - '\u4e00'..'\u9fff' | - '\uf900'..'\ufaff' - ; - -fragment -JavaIDDigit - : '\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' | - '\u1040'..'\u1049' - ; +fragment LETTER + : '\u0024' + | '\u002d' + | '\u0041' ..'\u005a' + | '\u005f' + | '\u0061' ..'\u007a' + | '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0100' ..'\u1fff' + | '\u3040' ..'\u318f' + | '\u3300' ..'\u337f' + | '\u3400' ..'\u3d2d' + | '\u4e00' ..'\u9fff' + | '\uf900' ..'\ufaff' + ; + +fragment JavaIDDigit + : '\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' + | '\u1040' ..'\u1049' + ; //OBJECTCLASSREFERENCE // : UPPER (UPPER | LOWER | '-') // ; IDENTIFIER - : LETTER (LETTER|JavaIDDigit)* - ; + : LETTER (LETTER | JavaIDDigit)* + ; \ No newline at end of file diff --git a/asn/asn_3gpp/ASN_3gpp.g4 b/asn/asn_3gpp/ASN_3gpp.g4 index 571170d15f..7ac2426fd2 100644 --- a/asn/asn_3gpp/ASN_3gpp.g4 +++ b/asn/asn_3gpp/ASN_3gpp.g4 @@ -1,4 +1,4 @@ - /* +/* [The "BSD licence"] Copyright (c) 2007-2008 Terence Parr All rights reserved. @@ -42,64 +42,71 @@ of the predicates since it was too much ambiguity. If you have some comments/improvements, send me an e-mail. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging grammar ASN_3gpp; -modules: moduleDefinition+ EOF; - -moduleDefinition : IDENTIFIER (L_BRACE (IDENTIFIER L_PARAN NUMBER R_PARAN)* R_BRACE)? - DEFINITIONS_LITERAL - tagDefault - extensionDefault - ASSIGN_OP - BEGIN_LITERAL - moduleBody - END_LITERAL - EOF - ; +modules + : moduleDefinition+ EOF + ; +moduleDefinition + : IDENTIFIER (L_BRACE (IDENTIFIER L_PARAN NUMBER R_PARAN)* R_BRACE)? DEFINITIONS_LITERAL tagDefault extensionDefault ASSIGN_OP BEGIN_LITERAL + moduleBody END_LITERAL EOF + ; +tagDefault + : ((EXPLICIT_LITERAL | IMPLICIT_LITERAL | AUTOMATIC_LITERAL) TAGS_LITERAL)? + ; -tagDefault : ( (EXPLICIT_LITERAL|IMPLICIT_LITERAL|AUTOMATIC_LITERAL) TAGS_LITERAL )? -; +extensionDefault + : (EXTENSIBILITY_LITERAL IMPLIED_LITERAL)? + ; -extensionDefault : - (EXTENSIBILITY_LITERAL IMPLIED_LITERAL)? -; +moduleBody + : (exports imports assignmentList)? + ; -moduleBody : (exports imports assignmentList) ? -; -exports : (EXPORTS_LITERAL symbolsExported SEMI_COLON - | EXPORTS_LITERAL ALL_LITERAL SEMI_COLON )? -; +exports + : (EXPORTS_LITERAL symbolsExported SEMI_COLON | EXPORTS_LITERAL ALL_LITERAL SEMI_COLON)? + ; -symbolsExported : symbolList? -; +symbolsExported + : symbolList? + ; -imports : (IMPORTS_LITERAL symbolsImported SEMI_COLON )? -; +imports + : (IMPORTS_LITERAL symbolsImported SEMI_COLON)? + ; -symbolsImported : symbolsFromModuleList? -; +symbolsImported + : symbolsFromModuleList? + ; -symbolsFromModuleList : - symbolsFromModule symbolsFromModule* -; +symbolsFromModuleList + : symbolsFromModule symbolsFromModule* + ; -symbolsFromModule : symbolList FROM_LITERAL globalModuleReference -; +symbolsFromModule + : symbolList FROM_LITERAL globalModuleReference + ; -globalModuleReference : IDENTIFIER assignedIdentifier -; +globalModuleReference + : IDENTIFIER assignedIdentifier + ; -assignedIdentifier : -; +assignedIdentifier + : + ; -symbolList : symbol (COMMA symbol)* -; +symbolList + : symbol (COMMA symbol)* + ; -symbol : IDENTIFIER (L_BRACE R_BRACE)? -; +symbol + : IDENTIFIER (L_BRACE R_BRACE)? + ; //parameterizedReference : // reference (L_BRACE R_BRACE)? @@ -110,859 +117,1061 @@ symbol : IDENTIFIER (L_BRACE R_BRACE)? // identifier //; -assignmentList : assignment assignment* -; - - -assignment : - IDENTIFIER - ( valueAssignment - | typeAssignment - | parameterizedAssignment - | objectClassAssignment - ) - ; - -sequenceType :SEQUENCE_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists )? R_BRACE - ; -extensionAndException : ELLIPSIS exceptionSpec? -; -optionalExtensionMarker : ( COMMA ELLIPSIS )? -; - -componentTypeLists : - rootComponentTypeList (tag | COMMA tag? extensionAndException extensionAdditions (optionalExtensionMarker| EXTENSTIONENDMARKER COMMA rootComponentTypeList tag?))? -// | rootComponentTypeList COMMA extensionAndException extensionAdditions optionalExtensionMarker -// | rootComponentTypeList COMMA extensionAndException extensionAdditions EXTENSTIONENDMARKER COMMA rootComponentTypeList - | extensionAndException extensionAdditions (optionalExtensionMarker | EXTENSTIONENDMARKER COMMA rootComponentTypeList tag?) -// | extensionAndException extensionAdditions optionalExtensionMarker -; -rootComponentTypeList : componentTypeList -; -componentTypeList : componentType (COMMA tag? componentType)* -; -componentType : - namedType (OPTIONAL_LITERAL | DEFAULT_LITERAL value )? - | COMPONENTS_LITERAL OF_LITERAL asnType -; +assignmentList + : assignment assignment* + ; + +assignment + : IDENTIFIER ( + valueAssignment + | typeAssignment + | parameterizedAssignment + | objectClassAssignment + ) + ; + +sequenceType + : SEQUENCE_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists)? R_BRACE + ; + +extensionAndException + : ELLIPSIS exceptionSpec? + ; + +optionalExtensionMarker + : (COMMA ELLIPSIS)? + ; + +componentTypeLists + : rootComponentTypeList ( + tag + | COMMA tag? extensionAndException extensionAdditions ( + optionalExtensionMarker + | EXTENSTIONENDMARKER COMMA rootComponentTypeList tag? + ) + )? + // | rootComponentTypeList COMMA extensionAndException extensionAdditions optionalExtensionMarker + // | rootComponentTypeList COMMA extensionAndException extensionAdditions EXTENSTIONENDMARKER COMMA rootComponentTypeList + | extensionAndException extensionAdditions ( + optionalExtensionMarker + | EXTENSTIONENDMARKER COMMA rootComponentTypeList tag? + ) + // | extensionAndException extensionAdditions optionalExtensionMarker + ; + +rootComponentTypeList + : componentTypeList + ; + +componentTypeList + : componentType (COMMA tag? componentType)* + ; + +componentType + : namedType (OPTIONAL_LITERAL | DEFAULT_LITERAL value)? + | COMPONENTS_LITERAL OF_LITERAL asnType + ; tag - : needTag - | condTag - | INVALID_TAG - ; + : needTag + | condTag + | INVALID_TAG + ; needTag - : NEED_LITERAL IDENTIFIER - ; + : NEED_LITERAL IDENTIFIER + ; NEED_LITERAL - : '--' (' ' | '\t')*? 'Need' - ; + : '--' (' ' | '\t')*? 'Need' + ; condTag - : COND_LITERAL IDENTIFIER - ; + : COND_LITERAL IDENTIFIER + ; COND_LITERAL - : '--' (' ' | '\t')*? 'Cond' - ; + : '--' (' ' | '\t')*? 'Cond' + ; INVALID_TAG - : '--' ~('\n'|'\r')* - ; - -extensionAdditions : (COMMA extensionAdditionList)? -; -extensionAdditionList : extensionAddition (COMMA extensionAddition)* -; -extensionAddition : componentType | extensionAdditionGroup -; -extensionAdditionGroup : DOUBLE_L_BRACKET versionNumber componentTypeList tag? DOUBLE_R_BRACKET -; -versionNumber : (NUMBER COLON )? -; - -sequenceOfType : SEQUENCE_LITERAL (L_PARAN (constraint | sizeConstraint) R_PARAN)? OF_LITERAL (asnType | namedType ) -; -sizeConstraint : SIZE_LITERAL constraint - ; - -parameterizedAssignment : - parameterList - ASSIGN_OP - (asnType - | value - | valueSet - ) - -| definedObjectClass ASSIGN_OP - ( object_ - | objectClass - | objectSet - ) - -// parameterizedTypeAssignment -//| parameterizedValueAssignment -//| parameterizedValueSetTypeAssignment -//| parameterizedObjectClassAssignment -//| parameterizedObjectAssignment -//| parameterizedObjectSetAssignment -; -parameterList : L_BRACE parameter (COMMA parameter)* R_BRACE -; -parameter : (paramGovernor COLON)? IDENTIFIER -; -paramGovernor : governor | IDENTIFIER -; + : '--' ~('\n' | '\r')* + ; + +extensionAdditions + : (COMMA extensionAdditionList)? + ; + +extensionAdditionList + : extensionAddition (COMMA extensionAddition)* + ; + +extensionAddition + : componentType + | extensionAdditionGroup + ; + +extensionAdditionGroup + : DOUBLE_L_BRACKET versionNumber componentTypeList tag? DOUBLE_R_BRACKET + ; + +versionNumber + : (NUMBER COLON)? + ; + +sequenceOfType + : SEQUENCE_LITERAL (L_PARAN (constraint | sizeConstraint) R_PARAN)? OF_LITERAL ( + asnType + | namedType + ) + ; + +sizeConstraint + : SIZE_LITERAL constraint + ; + +parameterizedAssignment + : parameterList ASSIGN_OP (asnType | value | valueSet) + | definedObjectClass ASSIGN_OP (object_ | objectClass | objectSet) + + // parameterizedTypeAssignment + //| parameterizedValueAssignment + //| parameterizedValueSetTypeAssignment + //| parameterizedObjectClassAssignment + //| parameterizedObjectAssignment + //| parameterizedObjectSetAssignment + ; + +parameterList + : L_BRACE parameter (COMMA parameter)* R_BRACE + ; + +parameter + : (paramGovernor COLON)? IDENTIFIER + ; + +paramGovernor + : governor + | IDENTIFIER + ; + //dummyGovernor : dummyReference //; -governor : asnType | definedObjectClass -; - - -objectClassAssignment : /*IDENTIFIER*/ ASSIGN_OP objectClass -; - -objectClass : definedObjectClass | objectClassDefn /*| parameterizedObjectClass */ -; -definedObjectClass : - (IDENTIFIER DOT)? IDENTIFIER - | TYPE_IDENTIFIER_LITERAL - | ABSTRACT_SYNTAX_LITERAL -; -usefulObjectClassReference : - TYPE_IDENTIFIER_LITERAL - | ABSTRACT_SYNTAX_LITERAL -; - -externalObjectClassReference : IDENTIFIER DOT IDENTIFIER -; - -objectClassDefn : CLASS_LITERAL L_BRACE fieldSpec (COMMA fieldSpec )* R_BRACE withSyntaxSpec? -; -withSyntaxSpec : WITH_LITERAL SYNTAX_LITERAL syntaxList -; -syntaxList : L_BRACE tokenOrGroupSpec+ R_BRACE -; - -tokenOrGroupSpec : requiredToken | optionalGroup -; - -optionalGroup : L_BRACKET tokenOrGroupSpec+ R_BRACKET -; - -requiredToken : literal | primitiveFieldName -; -literal : IDENTIFIER | COMMA -; -primitiveFieldName : - AMPERSAND IDENTIFIER; - - -fieldSpec : - AMPERSAND IDENTIFIER - ( - typeOptionalitySpec? - | asnType (valueSetOptionalitySpec? | UNIQUE_LITERAL? valueOptionalitySpec? ) - | fieldName (OPTIONAL_LITERAL | DEFAULT_LITERAL (valueSet | value))? - | definedObjectClass (OPTIONAL_LITERAL | DEFAULT_LITERAL (objectSet | object_))? - - ) - -// typeFieldSpec -// | fixedTypeValueFieldSpec -// | variableTypeValueFieldSpec -// | fixedTypeValueSetFieldSpec -// | variableTypeValueSetFieldSpec -// | objectFieldSpec -// | objectSetFieldSpec -; - -typeFieldSpec : AMPERSAND IDENTIFIER typeOptionalitySpec? -; -typeOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL asnType -; -fixedTypeValueFieldSpec : AMPERSAND IDENTIFIER asnType UNIQUE_LITERAL? valueOptionalitySpec ? -; -valueOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL value -; - -variableTypeValueFieldSpec : AMPERSAND IDENTIFIER fieldName valueOptionalitySpec ? -; - -fixedTypeValueSetFieldSpec : AMPERSAND IDENTIFIER asnType valueSetOptionalitySpec ? -; - -valueSetOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL valueSet -; - -object_ : definedObject /*| objectDefn | objectFromObject */| parameterizedObject -; -parameterizedObject : definedObject actualParameterList -; +governor + : asnType + | definedObjectClass + ; + +objectClassAssignment + : /*IDENTIFIER*/ ASSIGN_OP objectClass + ; + +objectClass + : definedObjectClass + | objectClassDefn /*| parameterizedObjectClass */ + ; + +definedObjectClass + : (IDENTIFIER DOT)? IDENTIFIER + | TYPE_IDENTIFIER_LITERAL + | ABSTRACT_SYNTAX_LITERAL + ; + +usefulObjectClassReference + : TYPE_IDENTIFIER_LITERAL + | ABSTRACT_SYNTAX_LITERAL + ; + +externalObjectClassReference + : IDENTIFIER DOT IDENTIFIER + ; + +objectClassDefn + : CLASS_LITERAL L_BRACE fieldSpec (COMMA fieldSpec)* R_BRACE withSyntaxSpec? + ; + +withSyntaxSpec + : WITH_LITERAL SYNTAX_LITERAL syntaxList + ; + +syntaxList + : L_BRACE tokenOrGroupSpec+ R_BRACE + ; + +tokenOrGroupSpec + : requiredToken + | optionalGroup + ; + +optionalGroup + : L_BRACKET tokenOrGroupSpec+ R_BRACKET + ; + +requiredToken + : literal + | primitiveFieldName + ; + +literal + : IDENTIFIER + | COMMA + ; + +primitiveFieldName + : AMPERSAND IDENTIFIER + ; + +fieldSpec + : AMPERSAND IDENTIFIER ( + typeOptionalitySpec? + | asnType (valueSetOptionalitySpec? | UNIQUE_LITERAL? valueOptionalitySpec?) + | fieldName (OPTIONAL_LITERAL | DEFAULT_LITERAL (valueSet | value))? + | definedObjectClass (OPTIONAL_LITERAL | DEFAULT_LITERAL (objectSet | object_))? + ) + + // typeFieldSpec + // | fixedTypeValueFieldSpec + // | variableTypeValueFieldSpec + // | fixedTypeValueSetFieldSpec + // | variableTypeValueSetFieldSpec + // | objectFieldSpec + // | objectSetFieldSpec + ; + +typeFieldSpec + : AMPERSAND IDENTIFIER typeOptionalitySpec? + ; + +typeOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL asnType + ; + +fixedTypeValueFieldSpec + : AMPERSAND IDENTIFIER asnType UNIQUE_LITERAL? valueOptionalitySpec? + ; + +valueOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL value + ; +variableTypeValueFieldSpec + : AMPERSAND IDENTIFIER fieldName valueOptionalitySpec? + ; + +fixedTypeValueSetFieldSpec + : AMPERSAND IDENTIFIER asnType valueSetOptionalitySpec? + ; + +valueSetOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL valueSet + ; + +object_ + : definedObject /*| objectDefn | objectFromObject */ + | parameterizedObject + ; + +parameterizedObject + : definedObject actualParameterList + ; definedObject - : IDENTIFIER DOT? - ; -objectSet : L_BRACE objectSetSpec R_BRACE -; -objectSetSpec : - rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec )?)? - | ELLIPSIS (COMMA additionalElementSetSpec )? -; - - -fieldName : AMPERSAND IDENTIFIER (AMPERSAND IDENTIFIER DOT)* -; -valueSet : L_BRACE elementSetSpecs R_BRACE -; -elementSetSpecs : - rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec)?)? - ; -rootElementSetSpec : elementSetSpec -; -additionalElementSetSpec : elementSetSpec -; -elementSetSpec : unions | ALL_LITERAL exclusions -; -unions : intersections (unionMark intersections)* -; -exclusions : EXCEPT_LITERAL elements -; -intersections : intersectionElements (intersectionMark intersectionElements)* -; -unionMark : PIPE | UNION_LITERAL -; - -intersectionMark : POWER | INTERSECTION_LITERAL -; - -elements : subtypeElements -// | objectSetElements -// | L_PARAN elementSetSpec R_PARAN -; -objectSetElements : - object_ | definedObject /*| objectSetFromObjects | parameterizedObjectSet */ -; - - -intersectionElements : elements exclusions? -; -subtypeElements : - (value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) - |sizeConstraint - | PATTERN_LITERAL value - | value -; - - -variableTypeValueSetFieldSpec : AMPERSAND IDENTIFIER fieldName valueSetOptionalitySpec? -; -objectFieldSpec : AMPERSAND IDENTIFIER definedObjectClass objectOptionalitySpec? -; -objectOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL object_ -; -objectSetFieldSpec : AMPERSAND IDENTIFIER definedObjectClass objectSetOptionalitySpec ? -; -objectSetOptionalitySpec : OPTIONAL_LITERAL | DEFAULT_LITERAL objectSet -; - -typeAssignment : - ASSIGN_OP - asnType -; - -valueAssignment : - asnType - ASSIGN_OP - value -; -asnType : (builtinType | referencedType) constraint* -; -builtinType : - octetStringType - | bitStringType - | choiceType - | enumeratedType - | integerType - | sequenceType - | sequenceOfType - | setType - | setOfType - | objectidentifiertype - | objectClassFieldType - | BOOLEAN_LITERAL - | NULL_LITERAL - - ; - -objectClassFieldType : definedObjectClass DOT fieldName -; - - -setType : SET_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists)? R_BRACE - ; - -setOfType : SET_LITERAL (constraint | sizeConstraint)? OF_LITERAL (asnType | namedType) -; - -referencedType : - definedType -// | selectionType -// | typeFromObject -// | valueSetFromObjects -; -definedType : -IDENTIFIER (DOT IDENTIFIER)? actualParameterList? -; - - -constraint :L_PARAN constraintSpec exceptionSpec? R_PARAN -//L_PARAN value DOT_DOT value R_PARAN -; - -constraintSpec : generalConstraint | subtypeConstraint -; -userDefinedConstraint : CONSTRAINED_LITERAL BY_LITERAL L_BRACE userDefinedConstraintParameter (COMMA userDefinedConstraintParameter)* R_BRACE -; - -generalConstraint : userDefinedConstraint | tableConstraint | contentsConstraint -; -userDefinedConstraintParameter : - governor (COLON - value - | valueSet - | object_ - | objectSet - )? -; - -tableConstraint : /*simpleTableConstraint |*/ componentRelationConstraint -; -simpleTableConstraint : objectSet -; - - -contentsConstraint : - CONTAINING_LITERAL asnType - | ENCODED_LITERAL BY_LITERAL value - | CONTAINING_LITERAL asnType ENCODED_LITERAL BY_LITERAL value - | WITH_LITERAL COMPONENTS_LITERAL L_BRACE componentPresenceLists R_BRACE -; - -componentPresenceLists: - componentPresenceList? (COMMA ELLIPSIS (COMMA componentPresenceList)?)? - | ELLIPSIS (COMMA componentPresenceList)? -; - -componentPresenceList: componentPresence (COMMA componentPresence)* -; - -componentPresence: IDENTIFIER (ABSENT_LITERAL | PRESENT_LITERAL) -; - - -subtypeConstraint : + : IDENTIFIER DOT? + ; + +objectSet + : L_BRACE objectSetSpec R_BRACE + ; + +objectSetSpec + : rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec)?)? + | ELLIPSIS (COMMA additionalElementSetSpec)? + ; + +fieldName + : AMPERSAND IDENTIFIER (AMPERSAND IDENTIFIER DOT)* + ; + +valueSet + : L_BRACE elementSetSpecs R_BRACE + ; + elementSetSpecs -//((value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) ) -// | sizeConstraint -// | value - ; -value : builtinValue -; -builtinValue : - enumeratedValue - | integerValue - | choiceValue - | objectIdentifierValue - | booleanValue - | CSTRING - | BSTRING - ; - -objectIdentifierValue : L_BRACE /*(definedValue)?*/ objIdComponentsList R_BRACE -; + : rootElementSetSpec (COMMA ELLIPSIS (COMMA additionalElementSetSpec)?)? + ; + +rootElementSetSpec + : elementSetSpec + ; + +additionalElementSetSpec + : elementSetSpec + ; + +elementSetSpec + : unions + | ALL_LITERAL exclusions + ; + +unions + : intersections (unionMark intersections)* + ; + +exclusions + : EXCEPT_LITERAL elements + ; + +intersections + : intersectionElements (intersectionMark intersectionElements)* + ; + +unionMark + : PIPE + | UNION_LITERAL + ; + +intersectionMark + : POWER + | INTERSECTION_LITERAL + ; + +elements + : subtypeElements + // | objectSetElements + // | L_PARAN elementSetSpec R_PARAN + ; + +objectSetElements + : object_ + | definedObject /*| objectSetFromObjects | parameterizedObjectSet */ + ; + +intersectionElements + : elements exclusions? + ; + +subtypeElements + : (value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) + | sizeConstraint + | PATTERN_LITERAL value + | value + ; + +variableTypeValueSetFieldSpec + : AMPERSAND IDENTIFIER fieldName valueSetOptionalitySpec? + ; + +objectFieldSpec + : AMPERSAND IDENTIFIER definedObjectClass objectOptionalitySpec? + ; + +objectOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL object_ + ; + +objectSetFieldSpec + : AMPERSAND IDENTIFIER definedObjectClass objectSetOptionalitySpec? + ; + +objectSetOptionalitySpec + : OPTIONAL_LITERAL + | DEFAULT_LITERAL objectSet + ; + +typeAssignment + : ASSIGN_OP asnType + ; + +valueAssignment + : asnType ASSIGN_OP value + ; + +asnType + : (builtinType | referencedType) constraint* + ; + +builtinType + : octetStringType + | bitStringType + | choiceType + | enumeratedType + | integerType + | sequenceType + | sequenceOfType + | setType + | setOfType + | objectidentifiertype + | objectClassFieldType + | BOOLEAN_LITERAL + | NULL_LITERAL + ; + +objectClassFieldType + : definedObjectClass DOT fieldName + ; + +setType + : SET_LITERAL L_BRACE (extensionAndException optionalExtensionMarker | componentTypeLists)? R_BRACE + ; + +setOfType + : SET_LITERAL (constraint | sizeConstraint)? OF_LITERAL (asnType | namedType) + ; + +referencedType + : definedType + // | selectionType + // | typeFromObject + // | valueSetFromObjects + ; + +definedType + : IDENTIFIER (DOT IDENTIFIER)? actualParameterList? + ; + +constraint + : L_PARAN constraintSpec exceptionSpec? R_PARAN + //L_PARAN value DOT_DOT value R_PARAN + ; + +constraintSpec + : generalConstraint + | subtypeConstraint + ; + +userDefinedConstraint + : CONSTRAINED_LITERAL BY_LITERAL L_BRACE userDefinedConstraintParameter ( + COMMA userDefinedConstraintParameter + )* R_BRACE + ; + +generalConstraint + : userDefinedConstraint + | tableConstraint + | contentsConstraint + ; + +userDefinedConstraintParameter + : governor (COLON value | valueSet | object_ | objectSet)? + ; + +tableConstraint + : /*simpleTableConstraint |*/ componentRelationConstraint + ; + +simpleTableConstraint + : objectSet + ; + +contentsConstraint + : CONTAINING_LITERAL asnType + | ENCODED_LITERAL BY_LITERAL value + | CONTAINING_LITERAL asnType ENCODED_LITERAL BY_LITERAL value + | WITH_LITERAL COMPONENTS_LITERAL L_BRACE componentPresenceLists R_BRACE + ; + +componentPresenceLists + : componentPresenceList? (COMMA ELLIPSIS (COMMA componentPresenceList)?)? + | ELLIPSIS (COMMA componentPresenceList)? + ; + +componentPresenceList + : componentPresence (COMMA componentPresence)* + ; + +componentPresence + : IDENTIFIER (ABSENT_LITERAL | PRESENT_LITERAL) + ; + +subtypeConstraint + : elementSetSpecs + //((value | MIN_LITERAL) LESS_THAN? DOUBLE_DOT LESS_THAN? (value | MAX_LITERAL) ) + // | sizeConstraint + // | value + ; + +value + : builtinValue + ; + +builtinValue + : enumeratedValue + | integerValue + | choiceValue + | objectIdentifierValue + | booleanValue + | CSTRING + | BSTRING + ; + +objectIdentifierValue + : L_BRACE /*(definedValue)?*/ objIdComponentsList R_BRACE + ; + objIdComponentsList - : objIdComponents objIdComponents* -; -objIdComponents : - NUMBER - | IDENTIFIER (L_PARAN (NUMBER | definedValue ) R_PARAN)? - | definedValue -; - - -integerValue : signedNumber | IDENTIFIER -; - -choiceValue : IDENTIFIER COLON value -; -enumeratedValue : IDENTIFIER -; - -signedNumber : MINUS? NUMBER -; -choiceType : CHOICE_LITERAL L_BRACE alternativeTypeLists R_BRACE -; -alternativeTypeLists : rootAlternativeTypeList (COMMA - extensionAndException extensionAdditionAlternatives optionalExtensionMarker )? - ; -extensionAdditionAlternatives : (COMMA extensionAdditionAlternativesList )? -; -extensionAdditionAlternativesList : extensionAdditionAlternative (COMMA extensionAdditionAlternative)* -; -extensionAdditionAlternative : extensionAdditionAlternativesGroup | namedType -; -extensionAdditionAlternativesGroup : DOUBLE_L_BRACKET versionNumber alternativeTypeList DOUBLE_R_BRACKET -; - -rootAlternativeTypeList : alternativeTypeList -; -alternativeTypeList : namedType (COMMA namedType)* -; -namedType : IDENTIFIER asnType -; -enumeratedType : ENUMERATED_LITERAL L_BRACE enumerations R_BRACE -; -enumerations :rootEnumeration (COMMA ELLIPSIS exceptionSpec? (COMMA additionalEnumeration )?)? - ; -rootEnumeration : enumeration -; -enumeration : enumerationItem ( COMMA enumerationItem)* -; -enumerationItem : IDENTIFIER | namedNumber | value -; -namedNumber : IDENTIFIER L_PARAN (signedNumber | definedValue) R_PARAN -; -definedValue : - // externalValueReference - //| valuereference - parameterizedValue -; -parameterizedValue : simpleDefinedValue actualParameterList? -; -simpleDefinedValue : IDENTIFIER (DOT IDENTIFIER)? -; - -actualParameterList : L_BRACE actualParameter (COMMA actualParameter)* R_BRACE -; -actualParameter : asnType | value /*| valueSet | definedObjectClass | object | objectSet*/ -; -exceptionSpec : EXCLAM exceptionIdentification -; -exceptionIdentification : signedNumber - | definedValue - | asnType COLON value -; -additionalEnumeration : enumeration -; -integerType:INTEGER_LITERAL (L_BRACE namedNumberList R_BRACE)? -; -namedNumberList : namedNumber (COMMA namedNumber)* -; -objectidentifiertype : OBJECT_LITERAL IDENTIFIER_LITERAL -; -componentRelationConstraint : L_BRACE IDENTIFIER (DOT IDENTIFIER)? R_BRACE - (L_BRACE atNotation (COMMA atNotation)* R_BRACE)? -; -atNotation : (A_ROND | A_ROND_DOT level) componentIdList -; -level : (DOT level)? -; - -componentIdList : IDENTIFIER (DOT IDENTIFIER)* //????? -; -octetStringType : OCTET_LITERAL STRING_LITERAL -; -bitStringType : BIT_LITERAL STRING_LITERAL (L_BRACE namedBitList R_BRACE)? -; -namedBitList: namedBit (COMMA namedBit)* -; -namedBit : IDENTIFIER L_PARAN (NUMBER | definedValue) R_PARAN - ; - -booleanValue: TRUE_LITERAL | FALSE_LITERAL | TRUE_SMALL_LITERAL | FALSE_SMALL_LITERAL -; + : objIdComponents objIdComponents* + ; + +objIdComponents + : NUMBER + | IDENTIFIER (L_PARAN (NUMBER | definedValue) R_PARAN)? + | definedValue + ; + +integerValue + : signedNumber + | IDENTIFIER + ; + +choiceValue + : IDENTIFIER COLON value + ; + +enumeratedValue + : IDENTIFIER + ; + +signedNumber + : MINUS? NUMBER + ; + +choiceType + : CHOICE_LITERAL L_BRACE alternativeTypeLists R_BRACE + ; + +alternativeTypeLists + : rootAlternativeTypeList ( + COMMA extensionAndException extensionAdditionAlternatives optionalExtensionMarker + )? + ; + +extensionAdditionAlternatives + : (COMMA extensionAdditionAlternativesList)? + ; + +extensionAdditionAlternativesList + : extensionAdditionAlternative (COMMA extensionAdditionAlternative)* + ; + +extensionAdditionAlternative + : extensionAdditionAlternativesGroup + | namedType + ; + +extensionAdditionAlternativesGroup + : DOUBLE_L_BRACKET versionNumber alternativeTypeList DOUBLE_R_BRACKET + ; + +rootAlternativeTypeList + : alternativeTypeList + ; + +alternativeTypeList + : namedType (COMMA namedType)* + ; + +namedType + : IDENTIFIER asnType + ; + +enumeratedType + : ENUMERATED_LITERAL L_BRACE enumerations R_BRACE + ; + +enumerations + : rootEnumeration (COMMA ELLIPSIS exceptionSpec? (COMMA additionalEnumeration)?)? + ; + +rootEnumeration + : enumeration + ; + +enumeration + : enumerationItem (COMMA enumerationItem)* + ; + +enumerationItem + : IDENTIFIER + | namedNumber + | value + ; + +namedNumber + : IDENTIFIER L_PARAN (signedNumber | definedValue) R_PARAN + ; + +definedValue + : + // externalValueReference + //| valuereference + parameterizedValue + ; + +parameterizedValue + : simpleDefinedValue actualParameterList? + ; + +simpleDefinedValue + : IDENTIFIER (DOT IDENTIFIER)? + ; + +actualParameterList + : L_BRACE actualParameter (COMMA actualParameter)* R_BRACE + ; + +actualParameter + : asnType + | value /*| valueSet | definedObjectClass | object | objectSet*/ + ; + +exceptionSpec + : EXCLAM exceptionIdentification + ; + +exceptionIdentification + : signedNumber + | definedValue + | asnType COLON value + ; + +additionalEnumeration + : enumeration + ; + +integerType + : INTEGER_LITERAL (L_BRACE namedNumberList R_BRACE)? + ; + +namedNumberList + : namedNumber (COMMA namedNumber)* + ; + +objectidentifiertype + : OBJECT_LITERAL IDENTIFIER_LITERAL + ; + +componentRelationConstraint + : L_BRACE IDENTIFIER (DOT IDENTIFIER)? R_BRACE (L_BRACE atNotation (COMMA atNotation)* R_BRACE)? + ; + +atNotation + : (A_ROND | A_ROND_DOT level) componentIdList + ; + +level + : (DOT level)? + ; + +componentIdList + : IDENTIFIER (DOT IDENTIFIER)* //????? + ; + +octetStringType + : OCTET_LITERAL STRING_LITERAL + ; + +bitStringType + : BIT_LITERAL STRING_LITERAL (L_BRACE namedBitList R_BRACE)? + ; + +namedBitList + : namedBit (COMMA namedBit)* + ; + +namedBit + : IDENTIFIER L_PARAN (NUMBER | definedValue) R_PARAN + ; + +booleanValue + : TRUE_LITERAL + | FALSE_LITERAL + | TRUE_SMALL_LITERAL + | FALSE_SMALL_LITERAL + ; A_ROND - : '@' - ; + : '@' + ; STAR - : '*' - ; + : '*' + ; ASSIGN_OP - : '::=' - ; + : '::=' + ; BOOLEAN_LITERAL - : 'BOOLEAN' - ; + : 'BOOLEAN' + ; TRUE_LITERAL - : 'TRUE' - ; + : 'TRUE' + ; FALSE_LITERAL - : 'FALSE' - ; + : 'FALSE' + ; DOT - : '.' - ; + : '.' + ; DOUBLE_DOT - : '..' - ; + : '..' + ; + ELLIPSIS - : '...' - ; + : '...' + ; APOSTROPHE - : '\'' - ; + : '\'' + ; AMPERSAND - : '&' - ; + : '&' + ; LESS_THAN - : '<' - ; + : '<' + ; GREATER_THAN - : '>' - ; + : '>' + ; LESS_THAN_SLASH - : '' - ; + : '/>' + ; TRUE_SMALL_LITERAL - : 'true' - ; + : 'true' + ; FALSE_SMALL_LITERAL - : 'false' - ; + : 'false' + ; INTEGER_LITERAL - : 'INTEGER' - ; + : 'INTEGER' + ; L_BRACE - : '{' - ; + : '{' + ; R_BRACE - : '}' - ; + : '}' + ; COMMA - : ',' - ; + : ',' + ; L_PARAN - : '(' - ; + : '(' + ; R_PARAN - : ')' - ; + : ')' + ; MINUS - : '-' - ; + : '-' + ; ENUMERATED_LITERAL - : 'ENUMERATED' - ; - + : 'ENUMERATED' + ; REAL_LITERAL - : 'REAL' - ; + : 'REAL' + ; PLUS_INFINITY_LITERAL - : 'PLUS-INFINITY' - ; + : 'PLUS-INFINITY' + ; MINUS_INFINITY_LITERAL - : 'MINUS-INFINITY' - ; + : 'MINUS-INFINITY' + ; BIT_LITERAL - : 'BIT' - ; + : 'BIT' + ; STRING_LITERAL - : 'STRING' - ; + : 'STRING' + ; CONTAINING_LITERAL - : 'CONTAINING' - ; + : 'CONTAINING' + ; OCTET_LITERAL - : 'OCTET' - ; + : 'OCTET' + ; NULL_LITERAL - : 'NULL' - ; + : 'NULL' + ; SEQUENCE_LITERAL - : 'SEQUENCE' - ; + : 'SEQUENCE' + ; OPTIONAL_LITERAL - : 'OPTIONAL' - ; + : 'OPTIONAL' + ; DEFAULT_LITERAL - : 'DEFAULT' - ; + : 'DEFAULT' + ; COMPONENTS_LITERAL - : 'COMPONENTS' - ; + : 'COMPONENTS' + ; OF_LITERAL - : 'OF' - ; + : 'OF' + ; SET_LITERAL - : 'SET' - ; + : 'SET' + ; EXCLAM - : '!' - ; + : '!' + ; ALL_LITERAL - : 'ALL' - ; + : 'ALL' + ; EXCEPT_LITERAL - : 'EXCEPT' - ; + : 'EXCEPT' + ; POWER - : '^' - ; + : '^' + ; PIPE - : '|' - ; + : '|' + ; UNION_LITERAL - : 'UNION' - ; + : 'UNION' + ; INTERSECTION_LITERAL - : 'INTERSECTION' - ; + : 'INTERSECTION' + ; INCLUDES_LITERAL - : 'INCLUDES' - ; + : 'INCLUDES' + ; MIN_LITERAL - : 'MIN' - ; + : 'MIN' + ; MAX_LITERAL - : 'MAX' - ; + : 'MAX' + ; SIZE_LITERAL - : 'SIZE' - ; + : 'SIZE' + ; FROM_LITERAL - : 'FROM' - ; + : 'FROM' + ; WITH_LITERAL - : 'WITH' - ; + : 'WITH' + ; COMPONENT_LITERAL - : 'COMPONENT' - ; + : 'COMPONENT' + ; PRESENT_LITERAL - : 'PRESENT' - ; + : 'PRESENT' + ; ABSENT_LITERAL - : 'ABSENT' - ; + : 'ABSENT' + ; PATTERN_LITERAL - : 'PATTERN' - ; + : 'PATTERN' + ; TYPE_IDENTIFIER_LITERAL - : 'TYPE-Identifier' - ; + : 'TYPE-Identifier' + ; ABSTRACT_SYNTAX_LITERAL - : 'ABSTRACT-SYNTAX' - ; + : 'ABSTRACT-SYNTAX' + ; CLASS_LITERAL - : 'CLASS' - ; + : 'CLASS' + ; UNIQUE_LITERAL - : 'UNIQUE' - ; + : 'UNIQUE' + ; SYNTAX_LITERAL - : 'SYNTAX' - ; + : 'SYNTAX' + ; L_BRACKET - : '[' - ; + : '[' + ; R_BRACKET - : ']' - ; + : ']' + ; INSTANCE_LITERAL - : 'INSTANCE' - ; + : 'INSTANCE' + ; SEMI_COLON - : ';' - ; + : ';' + ; IMPORTS_LITERAL - : 'IMPORTS' - ; + : 'IMPORTS' + ; EXPORTS_LITERAL - : 'EXPORTS' - ; + : 'EXPORTS' + ; EXTENSIBILITY_LITERAL - : 'EXTENSIBILITY' - ; + : 'EXTENSIBILITY' + ; IMPLIED_LITERAL - : 'IMPLIED' - ; + : 'IMPLIED' + ; EXPLICIT_LITERAL - : 'EXPLICIT' - ; + : 'EXPLICIT' + ; TAGS_LITERAL - : 'TAGS' - ; + : 'TAGS' + ; IMPLICIT_LITERAL - : 'IMPLICIT' - ; + : 'IMPLICIT' + ; AUTOMATIC_LITERAL - : 'AUTOMATIC' - ; + : 'AUTOMATIC' + ; DEFINITIONS_LITERAL - : 'DEFINITIONS' - ; + : 'DEFINITIONS' + ; BEGIN_LITERAL - : 'BEGIN' - ; + : 'BEGIN' + ; END_LITERAL - : 'END' - ; + : 'END' + ; DOUBLE_L_BRACKET - : '[[' - ; + : '[[' + ; DOUBLE_R_BRACKET - : ']]' - ; + : ']]' + ; COLON - : ':' - ; + : ':' + ; CHOICE_LITERAL - : 'CHOICE' - ; + : 'CHOICE' + ; UNIVERSAL_LITERAL - : 'UNIVERSAL' - ; + : 'UNIVERSAL' + ; APPLICATION_LITERAL - : 'APPLICATION' - ; + : 'APPLICATION' + ; PRIVATE_LITERAL - : 'PRIVATE' - ; + : 'PRIVATE' + ; EMBEDDED_LITERAL - : 'EMBEDDED' - ; + : 'EMBEDDED' + ; PDV_LITERAL - : 'PDV' - ; + : 'PDV' + ; EXTERNAL_LITERAL - : 'EXTERNAL' - ; + : 'EXTERNAL' + ; OBJECT_LITERAL - : 'OBJECT' - ; + : 'OBJECT' + ; + IDENTIFIER_LITERAL - : 'IDENTIFIER' - ; + : 'IDENTIFIER' + ; + RELATIVE_OID_LITERAL - : 'RELATIVE-OID' - ; + : 'RELATIVE-OID' + ; CHARACTER_LITERAL - : 'CHARACTER' - ; + : 'CHARACTER' + ; CONSTRAINED_LITERAL - : 'CONSTRAINED' - ; + : 'CONSTRAINED' + ; BY_LITERAL - : 'BY' - ; + : 'BY' + ; A_ROND_DOT - : '@.' - ; + : '@.' + ; ENCODED_LITERAL - : 'ENCODED' - ; + : 'ENCODED' + ; COMMENT - : '--' + : '--' ; UNRESTRICTEDCHARACTERSTRINGTYPE @@ -970,19 +1179,19 @@ UNRESTRICTEDCHARACTERSTRINGTYPE ; EXTENSTIONENDMARKER - : COMMA ELLIPSIS + : COMMA ELLIPSIS ; fragment DIGIT - : '0'..'9' + : '0' ..'9' ; fragment UPPER - : 'A'..'Z' + : 'A' ..'Z' ; fragment LOWER - : 'a'..'z' + : 'a' ..'z' ; NUMBER @@ -990,89 +1199,83 @@ NUMBER ; WS - : (' '|'\r'|'\t'|'\u000C'|'\n') -> skip + : (' ' | '\r' | '\t' | '\u000C' | '\n') -> skip ; fragment Exponent - : ('e'|'E') ('+'|'-')? NUMBER + : ('e' | 'E') ('+' | '-')? NUMBER ; LINE_COMMENT - : {getCharPositionInLine() == 0}? (' ' | '\t')*? '--' ~('\n'|'\r')* '\r'? '\n' ->skip + : {getCharPositionInLine() == 0}? (' ' | '\t')*? '--' ~('\n' | '\r')* '\r'? '\n' -> skip ; BSTRING - : APOSTROPHE ('0'..'1')* '\'B' + : APOSTROPHE ('0' ..'1')* '\'B' ; fragment HEXDIGIT - : DIGIT | 'a'..'f' | 'A'..'F' + : DIGIT + | 'a' ..'f' + | 'A' ..'F' ; HSTRING : APOSTROPHE HEXDIGIT* '\'H' ; - - - //IDENTIFIER : ('a'..'z'|'A'..'Z') ('0'..'9'|'a'..'z'|'A'..'Z')* ; CSTRING - : '"' ( EscapeSequence | ~('\\'|'"') )* '"' + : '"' (EscapeSequence | ~('\\' | '"'))* '"' ; -fragment -EscapeSequence - : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|APOSTROPHE|'\\') +fragment EscapeSequence + : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | APOSTROPHE | '\\') ; - - //fragment /**I found this char range in JavaCC's grammar, but Letter and Digit overlap. Still works, but... */ -fragment -LETTER - : '\u0024' | - '\u002d' | - '\u0041'..'\u005a' | - '\u005f' | - '\u0061'..'\u007a' | - '\u00c0'..'\u00d6' | - '\u00d8'..'\u00f6' | - '\u00f8'..'\u00ff' | - '\u0100'..'\u1fff' | - '\u3040'..'\u318f' | - '\u3300'..'\u337f' | - '\u3400'..'\u3d2d' | - '\u4e00'..'\u9fff' | - '\uf900'..'\ufaff' - ; - -fragment -JavaIDDigit - : '\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' | - '\u1040'..'\u1049' - ; +fragment LETTER + : '\u0024' + | '\u002d' + | '\u0041' ..'\u005a' + | '\u005f' + | '\u0061' ..'\u007a' + | '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0100' ..'\u1fff' + | '\u3040' ..'\u318f' + | '\u3300' ..'\u337f' + | '\u3400' ..'\u3d2d' + | '\u4e00' ..'\u9fff' + | '\uf900' ..'\ufaff' + ; + +fragment JavaIDDigit + : '\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' + | '\u1040' ..'\u1049' + ; //OBJECTCLASSREFERENCE // : UPPER (UPPER | LOWER | '-') // ; IDENTIFIER - : LETTER (LETTER|JavaIDDigit)* - ; + : LETTER (LETTER | JavaIDDigit)* + ; \ No newline at end of file diff --git a/aspectj/AspectJLexer.g4 b/aspectj/AspectJLexer.g4 index 91bcd5b45c..ff8499c776 100644 --- a/aspectj/AspectJLexer.g4 +++ b/aspectj/AspectJLexer.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2015 Adam Taylor @@ -33,355 +32,374 @@ https://eclipse.org/aspectj/doc/next/progguide/starting.html https://eclipse.org/aspectj/doc/next/adk15notebook/grammar.html */ - - /* + +/* This grammar builds on top of the ANTLR4 Java grammar, but it uses lexical modes to lex the annotation form of AspectJ; hence in order to use it you need to break Java.g4 into Separate Lexer (JavaLexer.g4) and Parser (JavaParser.g4) grammars. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar AspectJLexer; import JavaLexer; -DOTDOT : '..'; -DQUOTE : '"'; - -ADVICEEXECUTION : 'adviceexecution'; -ANNOTATION : 'annotation'; -ARGS : 'args'; -AFTER : 'after'; -AROUND : 'around'; -ASPECT : 'aspect'; -BEFORE : 'before'; -CALL : 'call'; -CFLOW : 'cflow'; -CFLOWBELOW : 'cflowbelow'; -DECLARE : 'declare'; -ERROR : 'error'; -EXECUTION : 'execution'; -GET : 'get'; -HANDLER : 'handler'; -INITIALIZATION : 'initialization'; -ISSINGLETON : 'issingleton'; -PARENTS : 'parents'; -PERCFLOW : 'percflow'; -PERCFLOWBELOW : 'percflowbelow'; -PERTARGET : 'pertarget'; -PERTHIS : 'perthis'; -PERTYPEWITHIN : 'pertypewithin'; -POINTCUT : 'pointcut'; -PRECEDENCE : 'precedence'; -PREINITIALIZATION : 'preinitialization'; -PRIVILEGED : 'privileged'; -RETURNING : 'returning'; -SET : 'set'; -SOFT : 'soft'; -STATICINITIALIZATION : 'staticinitialization'; -TARGET : 'target'; -THROWING : 'throwing'; -WARNING : 'warning'; -WITHIN : 'within'; -WITHINCODE : 'withincode'; - -ANNOTATION_AFTER : 'After'; -ANNOTATION_AFTERRETURNING : 'AfterReturning'; -ANNOTATION_AFTERTHROWING : 'AfterThrowing'; -ANNOTATION_AROUND : 'Around'; -ANNOTATION_ASPECT : 'Aspect'; -ANNOTATION_BEFORE : 'Before'; -ANNOTATION_DECLAREPARENTS : 'DeclareParents'; -ANNOTATION_DECLAREMIXIN : 'DeclareMixin'; -ANNOTATION_DECLAREWARNING : 'DeclareWarning'; -ANNOTATION_DECLAREERROR : 'DeclareError'; -ANNOTATION_DECLAREPRECEDENCE : 'DeclarePrecedence'; -ANNOTATION_POINTCUT : 'Pointcut'; -ANNOTATION_CONSTRUCTOR : 'constructor'; -ANNOTATION_DEFAULTIMPL : 'defaultImpl'; -ANNOTATION_FIELD : 'field'; -ANNOTATION_INTERFACES : 'interfaces'; -ANNOTATION_TYPE : 'type'; -ANNOTATION_METHOD : 'method'; -ANNOTATION_VALUE : 'value'; - -AT : '@' -> pushMode(Annotation); +DOTDOT : '..'; +DQUOTE : '"'; + +ADVICEEXECUTION : 'adviceexecution'; +ANNOTATION : 'annotation'; +ARGS : 'args'; +AFTER : 'after'; +AROUND : 'around'; +ASPECT : 'aspect'; +BEFORE : 'before'; +CALL : 'call'; +CFLOW : 'cflow'; +CFLOWBELOW : 'cflowbelow'; +DECLARE : 'declare'; +ERROR : 'error'; +EXECUTION : 'execution'; +GET : 'get'; +HANDLER : 'handler'; +INITIALIZATION : 'initialization'; +ISSINGLETON : 'issingleton'; +PARENTS : 'parents'; +PERCFLOW : 'percflow'; +PERCFLOWBELOW : 'percflowbelow'; +PERTARGET : 'pertarget'; +PERTHIS : 'perthis'; +PERTYPEWITHIN : 'pertypewithin'; +POINTCUT : 'pointcut'; +PRECEDENCE : 'precedence'; +PREINITIALIZATION : 'preinitialization'; +PRIVILEGED : 'privileged'; +RETURNING : 'returning'; +SET : 'set'; +SOFT : 'soft'; +STATICINITIALIZATION : 'staticinitialization'; +TARGET : 'target'; +THROWING : 'throwing'; +WARNING : 'warning'; +WITHIN : 'within'; +WITHINCODE : 'withincode'; + +ANNOTATION_AFTER : 'After'; +ANNOTATION_AFTERRETURNING : 'AfterReturning'; +ANNOTATION_AFTERTHROWING : 'AfterThrowing'; +ANNOTATION_AROUND : 'Around'; +ANNOTATION_ASPECT : 'Aspect'; +ANNOTATION_BEFORE : 'Before'; +ANNOTATION_DECLAREPARENTS : 'DeclareParents'; +ANNOTATION_DECLAREMIXIN : 'DeclareMixin'; +ANNOTATION_DECLAREWARNING : 'DeclareWarning'; +ANNOTATION_DECLAREERROR : 'DeclareError'; +ANNOTATION_DECLAREPRECEDENCE : 'DeclarePrecedence'; +ANNOTATION_POINTCUT : 'Pointcut'; +ANNOTATION_CONSTRUCTOR : 'constructor'; +ANNOTATION_DEFAULTIMPL : 'defaultImpl'; +ANNOTATION_FIELD : 'field'; +ANNOTATION_INTERFACES : 'interfaces'; +ANNOTATION_TYPE : 'type'; +ANNOTATION_METHOD : 'method'; +ANNOTATION_VALUE : 'value'; +AT: '@' -> pushMode(Annotation); mode Annotation; -ANNOTATION_AFTER1 : ANNOTATION_AFTER -> type(ANNOTATION_AFTER), mode(AspectJAnnotationMode); -ANNOTATION_AFTERRETURNING1 : ANNOTATION_AFTERRETURNING -> type(ANNOTATION_AFTERRETURNING), mode(AspectJAnnotationMode); -ANNOTATION_AFTERTHROWING1 : ANNOTATION_AFTERTHROWING -> type(ANNOTATION_AFTERTHROWING), mode(AspectJAnnotationMode); -ANNOTATION_AROUND1 : ANNOTATION_AROUND -> type(ANNOTATION_AROUND), mode(AspectJAnnotationMode); -ANNOTATION_ASPECT1 : ANNOTATION_ASPECT -> type(ANNOTATION_ASPECT), mode(AspectJAnnotationMode); -ANNOTATION_BEFORE1 : ANNOTATION_BEFORE -> type(ANNOTATION_BEFORE), mode(AspectJAnnotationMode); -ANNOTATION_DECLAREPARENTS1 : ANNOTATION_DECLAREPARENTS -> type(ANNOTATION_DECLAREPARENTS), mode(AspectJAnnotationMode); -ANNOTATION_DECLAREMIXIN1 : ANNOTATION_DECLAREMIXIN -> type(ANNOTATION_DECLAREMIXIN), mode(AspectJAnnotationMode); -ANNOTATION_DECLAREWARNING1 : ANNOTATION_DECLAREWARNING -> type(ANNOTATION_DECLAREWARNING), mode(AspectJAnnotationMode); -ANNOTATION_DECLAREERROR1 : ANNOTATION_DECLAREERROR -> type(ANNOTATION_DECLAREERROR), mode(AspectJAnnotationMode); -ANNOTATION_DECLAREPRECEDENCE1 : ANNOTATION_DECLAREPRECEDENCE -> type(ANNOTATION_DECLAREPRECEDENCE), mode(AspectJAnnotationMode); -ANNOTATION_POINTCUT1 : ANNOTATION_POINTCUT -> type(ANNOTATION_POINTCUT), mode(AspectJAnnotationMode); - -ARGS1 : ARGS -> type(ARGS), mode(DEFAULT_MODE); -TARGET1 : TARGET -> type(TARGET), mode(DEFAULT_MODE); -THIS1 : THIS -> type(THIS), mode(DEFAULT_MODE); - -Identifier1 : Identifier -> type(Identifier), mode(DEFAULT_MODE); -WS1 : [ \t\r\n\u000C]+ -> skip; -COMMENT1 : '/*' .*? '*/' -> skip; -LINE_COMMENT1 : '//' ~[\r\n]* -> skip; -INVALID1 : . -> mode(DEFAULT_MODE); - +ANNOTATION_AFTER1: ANNOTATION_AFTER -> type(ANNOTATION_AFTER), mode(AspectJAnnotationMode); +ANNOTATION_AFTERRETURNING1: + ANNOTATION_AFTERRETURNING -> type(ANNOTATION_AFTERRETURNING), mode(AspectJAnnotationMode) +; +ANNOTATION_AFTERTHROWING1: + ANNOTATION_AFTERTHROWING -> type(ANNOTATION_AFTERTHROWING), mode(AspectJAnnotationMode) +; +ANNOTATION_AROUND1 : ANNOTATION_AROUND -> type(ANNOTATION_AROUND), mode(AspectJAnnotationMode); +ANNOTATION_ASPECT1 : ANNOTATION_ASPECT -> type(ANNOTATION_ASPECT), mode(AspectJAnnotationMode); +ANNOTATION_BEFORE1 : ANNOTATION_BEFORE -> type(ANNOTATION_BEFORE), mode(AspectJAnnotationMode); +ANNOTATION_DECLAREPARENTS1: + ANNOTATION_DECLAREPARENTS -> type(ANNOTATION_DECLAREPARENTS), mode(AspectJAnnotationMode) +; +ANNOTATION_DECLAREMIXIN1: + ANNOTATION_DECLAREMIXIN -> type(ANNOTATION_DECLAREMIXIN), mode(AspectJAnnotationMode) +; +ANNOTATION_DECLAREWARNING1: + ANNOTATION_DECLAREWARNING -> type(ANNOTATION_DECLAREWARNING), mode(AspectJAnnotationMode) +; +ANNOTATION_DECLAREERROR1: + ANNOTATION_DECLAREERROR -> type(ANNOTATION_DECLAREERROR), mode(AspectJAnnotationMode) +; +ANNOTATION_DECLAREPRECEDENCE1: + ANNOTATION_DECLAREPRECEDENCE -> type(ANNOTATION_DECLAREPRECEDENCE), mode(AspectJAnnotationMode) +; +ANNOTATION_POINTCUT1: + ANNOTATION_POINTCUT -> type(ANNOTATION_POINTCUT), mode(AspectJAnnotationMode) +; + +ARGS1 : ARGS -> type(ARGS), mode(DEFAULT_MODE); +TARGET1 : TARGET -> type(TARGET), mode(DEFAULT_MODE); +THIS1 : THIS -> type(THIS), mode(DEFAULT_MODE); + +Identifier1 : Identifier -> type(Identifier), mode(DEFAULT_MODE); +WS1 : [ \t\r\n\u000C]+ -> skip; +COMMENT1 : '/*' .*? '*/' -> skip; +LINE_COMMENT1 : '//' ~[\r\n]* -> skip; +INVALID1 : . -> mode(DEFAULT_MODE); mode AspectJAnnotationMode; - -ABSTRACT2 : ABSTRACT -> type(ABSTRACT), mode(DEFAULT_MODE); -ASSERT2 : ASSERT -> type(ASSERT), mode(DEFAULT_MODE); -BOOLEAN2 : BOOLEAN -> type(BOOLEAN), mode(DEFAULT_MODE); -BREAK2 : BREAK -> type(BREAK), mode(DEFAULT_MODE); -BYTE2 : BYTE -> type(BYTE), mode(DEFAULT_MODE); -CASE2 : CASE -> type(CASE), mode(DEFAULT_MODE); -CATCH2 : CATCH -> type(CATCH), mode(DEFAULT_MODE); -CHAR2 : CHAR -> type(CHAR), mode(DEFAULT_MODE); -CLASS2 : CLASS -> type(CLASS), mode(DEFAULT_MODE); -CONST2 : CONST -> type(CONST), mode(DEFAULT_MODE); -CONTINUE2 : CONTINUE -> type(CONTINUE), mode(DEFAULT_MODE); -DEFAULT2 : DEFAULT -> type(DEFAULT), mode(DEFAULT_MODE); -DO2 : DO -> type(DO), mode(DEFAULT_MODE); -DOUBLE2 : DOUBLE -> type(DOUBLE), mode(DEFAULT_MODE); -ELSE2 : ELSE -> type(ELSE), mode(DEFAULT_MODE); -ENUM2 : ENUM -> type(ENUM), mode(DEFAULT_MODE); -EXTENDS2 : EXTENDS -> type(EXTENDS), mode(DEFAULT_MODE); -FINAL2 : FINAL -> type(FINAL), mode(DEFAULT_MODE); -FINALLY2 : FINALLY -> type(FINALLY), mode(DEFAULT_MODE); -FLOAT2 : FLOAT -> type(FLOAT), mode(DEFAULT_MODE); -FOR2 : FOR -> type(FOR), mode(DEFAULT_MODE); -IF2 : IF -> type(IF), mode(DEFAULT_MODE); -GOTO2 : GOTO -> type(GOTO), mode(DEFAULT_MODE); -IMPLEMENTS2 : IMPLEMENTS -> type(IMPLEMENTS), mode(DEFAULT_MODE); -IMPORT2 : IMPORT -> type(IMPORT), mode(DEFAULT_MODE); -INSTANCEOF2 : INSTANCEOF -> type(INSTANCEOF), mode(DEFAULT_MODE); -INT2 : INT -> type(INT), mode(DEFAULT_MODE); -INTERFACE2 : INTERFACE -> type(INTERFACE), mode(DEFAULT_MODE); -LONG2 : LONG -> type(LONG), mode(DEFAULT_MODE); -NATIVE2 : NATIVE -> type(NATIVE), mode(DEFAULT_MODE); -NEW2 : NEW -> type(NEW), mode(DEFAULT_MODE); -PACKAGE2 : PACKAGE -> type(PACKAGE), mode(DEFAULT_MODE); -PRIVATE2 : PRIVATE -> type(PRIVATE), mode(DEFAULT_MODE); -PROTECTED2 : PROTECTED -> type(PROTECTED), mode(DEFAULT_MODE); -PUBLIC2 : PUBLIC -> type(PUBLIC), mode(DEFAULT_MODE); -RETURN2 : RETURN -> type(RETURN), mode(DEFAULT_MODE); -SHORT2 : SHORT -> type(SHORT), mode(DEFAULT_MODE); -STATIC2 : STATIC -> type(STATIC), mode(DEFAULT_MODE); -STRICTFP2 : STRICTFP -> type(STRICTFP), mode(DEFAULT_MODE); -SUPER2 : SUPER -> type(SUPER), mode(DEFAULT_MODE); -SWITCH2 : SWITCH -> type(SWITCH), mode(DEFAULT_MODE); -SYNCHRONIZED2 : SYNCHRONIZED -> type(SYNCHRONIZED), mode(DEFAULT_MODE); -THIS2 : THIS -> type(THIS), mode(DEFAULT_MODE); -THROW2 : THROW -> type(THROW), mode(DEFAULT_MODE); -THROWS2 : THROWS -> type(THROWS), mode(DEFAULT_MODE); -TRANSIENT2 : TRANSIENT -> type(TRANSIENT), mode(DEFAULT_MODE); -TRY2 : TRY -> type(TRY), mode(DEFAULT_MODE); -VOID2 : VOID -> type(VOID), mode(DEFAULT_MODE); -VOLATILE2 : VOLATILE -> type(VOLATILE), mode(DEFAULT_MODE); -WHILE2 : WHILE -> type(WHILE), mode(DEFAULT_MODE); - -ADVICEEXECUTION2 : ADVICEEXECUTION -> type(ADVICEEXECUTION), mode(DEFAULT_MODE); -ANNOTATION2 : ANNOTATION -> type(ANNOTATION), mode(DEFAULT_MODE); -ARGS2 : ARGS -> type(ARGS), mode(DEFAULT_MODE); -AFTER2 : AFTER -> type(AFTER), mode(DEFAULT_MODE); -AROUND2 : AROUND -> type(AROUND), mode(DEFAULT_MODE); -ASPECT2 : ASPECT -> type(ASPECT), mode(DEFAULT_MODE); -BEFORE2 : BEFORE -> type(BEFORE), mode(DEFAULT_MODE); -CALL2 : CALL -> type(CALL), mode(DEFAULT_MODE); -CFLOW2 : CFLOW -> type(CFLOW), mode(DEFAULT_MODE); -CFLOWBELOW2 : CFLOWBELOW -> type(CFLOWBELOW), mode(DEFAULT_MODE); -DECLARE2 : DECLARE -> type(DECLARE), mode(DEFAULT_MODE); -ERROR2 : ERROR -> type(ERROR), mode(DEFAULT_MODE); -EXECUTION2 : EXECUTION -> type(EXECUTION), mode(DEFAULT_MODE); -GET2 : GET -> type(GET), mode(DEFAULT_MODE); -HANDLER2 : HANDLER -> type(HANDLER), mode(DEFAULT_MODE); -INITIALIZATION2 : INITIALIZATION -> type(INITIALIZATION), mode(DEFAULT_MODE); -ISSINGLETON2 : ISSINGLETON -> type(ISSINGLETON), mode(DEFAULT_MODE); -PARENTS2 : PARENTS -> type(PARENTS), mode(DEFAULT_MODE); -PERCFLOW2 : PERCFLOW -> type(PERCFLOW), mode(DEFAULT_MODE); -PERCFLOWBELOW2 : PERCFLOWBELOW -> type(PERCFLOWBELOW), mode(DEFAULT_MODE); -PERTARGET2 : PERTARGET -> type(PERTARGET), mode(DEFAULT_MODE); -PERTHIS2 : PERTHIS -> type(PERTHIS), mode(DEFAULT_MODE); -PERTYPEWITHIN2 : PERTYPEWITHIN -> type(PERTYPEWITHIN), mode(DEFAULT_MODE); -POINTCUT2 : POINTCUT -> type(POINTCUT), mode(DEFAULT_MODE); -PRECEDENCE2 : PRECEDENCE -> type(PRECEDENCE), mode(DEFAULT_MODE); -PREINITIALIZATION2 : PREINITIALIZATION -> type(PREINITIALIZATION), mode(DEFAULT_MODE); -PRIVILEGED2 : PRIVILEGED -> type(PRIVILEGED), mode(DEFAULT_MODE); -RETURNING2 : RETURNING -> type(RETURNING), mode(DEFAULT_MODE); -SET2 : SET -> type(SET), mode(DEFAULT_MODE); -SOFT2 : SOFT -> type(SOFT), mode(DEFAULT_MODE); -STATICINITIALIZATION2 : STATICINITIALIZATION -> type(STATICINITIALIZATION), mode(DEFAULT_MODE); -TARGET2 : TARGET -> type(TARGET), mode(DEFAULT_MODE); -THROWING2 : THROWING -> type(THROWING), mode(DEFAULT_MODE); -WARNING2 : WARNING -> type(WARNING), mode(DEFAULT_MODE); -WITHIN2 : WITHIN -> type(WITHIN), mode(DEFAULT_MODE); -WITHINCODE2 : WITHINCODE -> type(WITHINCODE), mode(DEFAULT_MODE); - -IntegerLiteral2 : IntegerLiteral -> type(IntegerLiteral), pushMode(AspectJAnnotationScope); -FloatingPointLiteral2 : FloatingPointLiteral -> type(FloatingPointLiteral), pushMode(AspectJAnnotationScope); -BooleanLiteral2 : BooleanLiteral -> type(BooleanLiteral), pushMode(AspectJAnnotationScope); -CharacterLiteral2 : CharacterLiteral -> type(CharacterLiteral), pushMode(AspectJAnnotationScope); -StringLiteral2 : StringLiteral -> type(StringLiteral), pushMode(AspectJAnnotationScope); -NullLiteral2 : NullLiteral -> type(NullLiteral), pushMode(AspectJAnnotationScope); -LPAREN2 : LPAREN -> type(LPAREN), pushMode(AspectJAnnotationScope); -RPAREN2 : RPAREN -> type(RPAREN), mode(DEFAULT_MODE); -LBRACE2 : LBRACE -> type(LBRACE), mode(DEFAULT_MODE); -RBRACE2 : RBRACE -> type(RBRACE), mode(DEFAULT_MODE); -LBRACK2 : LBRACK -> type(LBRACK), mode(DEFAULT_MODE); -RBRACK2 : RBRACK -> type(RBRACK), mode(DEFAULT_MODE); -SEMI2 : SEMI -> type(SEMI), mode(DEFAULT_MODE); -COMMA2 : COMMA -> type(COMMA), mode(DEFAULT_MODE); -DOT2 : DOT -> type(DOT), mode(DEFAULT_MODE); -DOTDOT2 : DOTDOT -> type(DOTDOT), mode(DEFAULT_MODE); -DQUOTE2 : DQUOTE -> type(DQUOTE), mode(DEFAULT_MODE); -ASSIGN2 : ASSIGN -> type(ASSIGN), mode(DEFAULT_MODE); -GT2 : GT -> type(GT), mode(DEFAULT_MODE); -LT2 : LT -> type(LT), mode(DEFAULT_MODE); -BANG2 : BANG -> type(BANG), mode(DEFAULT_MODE); -TILDE2 : TILDE -> type(TILDE), mode(DEFAULT_MODE); -QUESTION2 : QUESTION -> type(QUESTION), mode(DEFAULT_MODE); -COLON2 : COLON -> type(COLON), mode(DEFAULT_MODE); -EQUAL2 : EQUAL -> type(EQUAL), mode(DEFAULT_MODE); -LE2 : LE -> type(LE), mode(DEFAULT_MODE); -GE2 : GE -> type(GE), mode(DEFAULT_MODE); -NOTEQUAL2 : NOTEQUAL -> type(NOTEQUAL), mode(DEFAULT_MODE); -AND2 : AND -> type(ADD), mode(DEFAULT_MODE); -OR2 : OR -> type(OR), mode(DEFAULT_MODE); -INC2 : INC -> type(INC), mode(DEFAULT_MODE); -DEC2 : DEC -> type(DEC), mode(DEFAULT_MODE); -ADD2 : ADD -> type(ADD), mode(DEFAULT_MODE); -SUB2 : SUB -> type(SUB), mode(DEFAULT_MODE); -MUL2 : MUL -> type(MUL), mode(DEFAULT_MODE); -DIV2 : DIV -> type(DIV), mode(DEFAULT_MODE); -BITAND2 : BITAND -> type(BITAND), mode(DEFAULT_MODE); -BITOR2 : BITOR -> type(BITOR), mode(DEFAULT_MODE); -CARET2 : CARET -> type(CARET), mode(DEFAULT_MODE); -MOD2 : MOD -> type(MOD), mode(DEFAULT_MODE); -ADD_ASSIGN2 : ADD_ASSIGN -> type(ADD_ASSIGN), mode(DEFAULT_MODE); -SUB_ASSIGN2 : SUB_ASSIGN -> type(SUB_ASSIGN), mode(DEFAULT_MODE); -MUL_ASSIGN2 : MUL_ASSIGN -> type(MUL_ASSIGN), mode(DEFAULT_MODE); -DIV_ASSIGN2 : DIV_ASSIGN -> type(DIV_ASSIGN), mode(DEFAULT_MODE); -AND_ASSIGN2 : AND_ASSIGN -> type(AND_ASSIGN), mode(DEFAULT_MODE); -OR_ASSIGN2 : OR_ASSIGN -> type(OR_ASSIGN), mode(DEFAULT_MODE); -XOR_ASSIGN2 : XOR_ASSIGN -> type(XOR_ASSIGN), mode(DEFAULT_MODE); -MOD_ASSIGN2 : MOD_ASSIGN -> type(MOD_ASSIGN), mode(DEFAULT_MODE); -LSHIFT_ASSIGN2 : LSHIFT_ASSIGN -> type(LSHIFT_ASSIGN), mode(DEFAULT_MODE); -RSHIFT_ASSIGN2 : RSHIFT_ASSIGN -> type(RSHIFT_ASSIGN), mode(DEFAULT_MODE); -URSHIFT_ASSIGN2 : URSHIFT_ASSIGN -> type(URSHIFT_ASSIGN), mode(DEFAULT_MODE); -Identifier2 : Identifier -> type(Identifier), mode(DEFAULT_MODE); - -AT2 : AT -> type(AT), mode(Annotation); - -ELLIPSIS2 : ELLIPSIS -> type(ELLIPSIS), mode(DEFAULT_MODE); -WS2 : WS -> skip; -COMMENT2 : COMMENT -> skip; -LINE_COMMENT2 : LINE_COMMENT -> skip; - - -mode AspectJAnnotationScope; -RPAREN3 : RPAREN -> type(RPAREN), mode(DEFAULT_MODE); +ABSTRACT2 : ABSTRACT -> type(ABSTRACT), mode(DEFAULT_MODE); +ASSERT2 : ASSERT -> type(ASSERT), mode(DEFAULT_MODE); +BOOLEAN2 : BOOLEAN -> type(BOOLEAN), mode(DEFAULT_MODE); +BREAK2 : BREAK -> type(BREAK), mode(DEFAULT_MODE); +BYTE2 : BYTE -> type(BYTE), mode(DEFAULT_MODE); +CASE2 : CASE -> type(CASE), mode(DEFAULT_MODE); +CATCH2 : CATCH -> type(CATCH), mode(DEFAULT_MODE); +CHAR2 : CHAR -> type(CHAR), mode(DEFAULT_MODE); +CLASS2 : CLASS -> type(CLASS), mode(DEFAULT_MODE); +CONST2 : CONST -> type(CONST), mode(DEFAULT_MODE); +CONTINUE2 : CONTINUE -> type(CONTINUE), mode(DEFAULT_MODE); +DEFAULT2 : DEFAULT -> type(DEFAULT), mode(DEFAULT_MODE); +DO2 : DO -> type(DO), mode(DEFAULT_MODE); +DOUBLE2 : DOUBLE -> type(DOUBLE), mode(DEFAULT_MODE); +ELSE2 : ELSE -> type(ELSE), mode(DEFAULT_MODE); +ENUM2 : ENUM -> type(ENUM), mode(DEFAULT_MODE); +EXTENDS2 : EXTENDS -> type(EXTENDS), mode(DEFAULT_MODE); +FINAL2 : FINAL -> type(FINAL), mode(DEFAULT_MODE); +FINALLY2 : FINALLY -> type(FINALLY), mode(DEFAULT_MODE); +FLOAT2 : FLOAT -> type(FLOAT), mode(DEFAULT_MODE); +FOR2 : FOR -> type(FOR), mode(DEFAULT_MODE); +IF2 : IF -> type(IF), mode(DEFAULT_MODE); +GOTO2 : GOTO -> type(GOTO), mode(DEFAULT_MODE); +IMPLEMENTS2 : IMPLEMENTS -> type(IMPLEMENTS), mode(DEFAULT_MODE); +IMPORT2 : IMPORT -> type(IMPORT), mode(DEFAULT_MODE); +INSTANCEOF2 : INSTANCEOF -> type(INSTANCEOF), mode(DEFAULT_MODE); +INT2 : INT -> type(INT), mode(DEFAULT_MODE); +INTERFACE2 : INTERFACE -> type(INTERFACE), mode(DEFAULT_MODE); +LONG2 : LONG -> type(LONG), mode(DEFAULT_MODE); +NATIVE2 : NATIVE -> type(NATIVE), mode(DEFAULT_MODE); +NEW2 : NEW -> type(NEW), mode(DEFAULT_MODE); +PACKAGE2 : PACKAGE -> type(PACKAGE), mode(DEFAULT_MODE); +PRIVATE2 : PRIVATE -> type(PRIVATE), mode(DEFAULT_MODE); +PROTECTED2 : PROTECTED -> type(PROTECTED), mode(DEFAULT_MODE); +PUBLIC2 : PUBLIC -> type(PUBLIC), mode(DEFAULT_MODE); +RETURN2 : RETURN -> type(RETURN), mode(DEFAULT_MODE); +SHORT2 : SHORT -> type(SHORT), mode(DEFAULT_MODE); +STATIC2 : STATIC -> type(STATIC), mode(DEFAULT_MODE); +STRICTFP2 : STRICTFP -> type(STRICTFP), mode(DEFAULT_MODE); +SUPER2 : SUPER -> type(SUPER), mode(DEFAULT_MODE); +SWITCH2 : SWITCH -> type(SWITCH), mode(DEFAULT_MODE); +SYNCHRONIZED2 : SYNCHRONIZED -> type(SYNCHRONIZED), mode(DEFAULT_MODE); +THIS2 : THIS -> type(THIS), mode(DEFAULT_MODE); +THROW2 : THROW -> type(THROW), mode(DEFAULT_MODE); +THROWS2 : THROWS -> type(THROWS), mode(DEFAULT_MODE); +TRANSIENT2 : TRANSIENT -> type(TRANSIENT), mode(DEFAULT_MODE); +TRY2 : TRY -> type(TRY), mode(DEFAULT_MODE); +VOID2 : VOID -> type(VOID), mode(DEFAULT_MODE); +VOLATILE2 : VOLATILE -> type(VOLATILE), mode(DEFAULT_MODE); +WHILE2 : WHILE -> type(WHILE), mode(DEFAULT_MODE); -DQUOTE3 : DQUOTE -> type(DQUOTE), pushMode(AspectJAnnotationString); +ADVICEEXECUTION2 : ADVICEEXECUTION -> type(ADVICEEXECUTION), mode(DEFAULT_MODE); +ANNOTATION2 : ANNOTATION -> type(ANNOTATION), mode(DEFAULT_MODE); +ARGS2 : ARGS -> type(ARGS), mode(DEFAULT_MODE); +AFTER2 : AFTER -> type(AFTER), mode(DEFAULT_MODE); +AROUND2 : AROUND -> type(AROUND), mode(DEFAULT_MODE); +ASPECT2 : ASPECT -> type(ASPECT), mode(DEFAULT_MODE); +BEFORE2 : BEFORE -> type(BEFORE), mode(DEFAULT_MODE); +CALL2 : CALL -> type(CALL), mode(DEFAULT_MODE); +CFLOW2 : CFLOW -> type(CFLOW), mode(DEFAULT_MODE); +CFLOWBELOW2 : CFLOWBELOW -> type(CFLOWBELOW), mode(DEFAULT_MODE); +DECLARE2 : DECLARE -> type(DECLARE), mode(DEFAULT_MODE); +ERROR2 : ERROR -> type(ERROR), mode(DEFAULT_MODE); +EXECUTION2 : EXECUTION -> type(EXECUTION), mode(DEFAULT_MODE); +GET2 : GET -> type(GET), mode(DEFAULT_MODE); +HANDLER2 : HANDLER -> type(HANDLER), mode(DEFAULT_MODE); +INITIALIZATION2 : INITIALIZATION -> type(INITIALIZATION), mode(DEFAULT_MODE); +ISSINGLETON2 : ISSINGLETON -> type(ISSINGLETON), mode(DEFAULT_MODE); +PARENTS2 : PARENTS -> type(PARENTS), mode(DEFAULT_MODE); +PERCFLOW2 : PERCFLOW -> type(PERCFLOW), mode(DEFAULT_MODE); +PERCFLOWBELOW2 : PERCFLOWBELOW -> type(PERCFLOWBELOW), mode(DEFAULT_MODE); +PERTARGET2 : PERTARGET -> type(PERTARGET), mode(DEFAULT_MODE); +PERTHIS2 : PERTHIS -> type(PERTHIS), mode(DEFAULT_MODE); +PERTYPEWITHIN2 : PERTYPEWITHIN -> type(PERTYPEWITHIN), mode(DEFAULT_MODE); +POINTCUT2 : POINTCUT -> type(POINTCUT), mode(DEFAULT_MODE); +PRECEDENCE2 : PRECEDENCE -> type(PRECEDENCE), mode(DEFAULT_MODE); +PREINITIALIZATION2 : PREINITIALIZATION -> type(PREINITIALIZATION), mode(DEFAULT_MODE); +PRIVILEGED2 : PRIVILEGED -> type(PRIVILEGED), mode(DEFAULT_MODE); +RETURNING2 : RETURNING -> type(RETURNING), mode(DEFAULT_MODE); +SET2 : SET -> type(SET), mode(DEFAULT_MODE); +SOFT2 : SOFT -> type(SOFT), mode(DEFAULT_MODE); +STATICINITIALIZATION2 : STATICINITIALIZATION -> type(STATICINITIALIZATION), mode(DEFAULT_MODE); +TARGET2 : TARGET -> type(TARGET), mode(DEFAULT_MODE); +THROWING2 : THROWING -> type(THROWING), mode(DEFAULT_MODE); +WARNING2 : WARNING -> type(WARNING), mode(DEFAULT_MODE); +WITHIN2 : WITHIN -> type(WITHIN), mode(DEFAULT_MODE); +WITHINCODE2 : WITHINCODE -> type(WITHINCODE), mode(DEFAULT_MODE); -AT3 : AT -> type(AT), pushMode(Annotation); +IntegerLiteral2: IntegerLiteral -> type(IntegerLiteral), pushMode(AspectJAnnotationScope); +FloatingPointLiteral2: + FloatingPointLiteral -> type(FloatingPointLiteral), pushMode(AspectJAnnotationScope) +; +BooleanLiteral2: BooleanLiteral -> type(BooleanLiteral), pushMode(AspectJAnnotationScope); +CharacterLiteral2: + CharacterLiteral -> type(CharacterLiteral), pushMode(AspectJAnnotationScope) +; +StringLiteral2 : StringLiteral -> type(StringLiteral), pushMode(AspectJAnnotationScope); +NullLiteral2 : NullLiteral -> type(NullLiteral), pushMode(AspectJAnnotationScope); +LPAREN2 : LPAREN -> type(LPAREN), pushMode(AspectJAnnotationScope); +RPAREN2 : RPAREN -> type(RPAREN), mode(DEFAULT_MODE); +LBRACE2 : LBRACE -> type(LBRACE), mode(DEFAULT_MODE); +RBRACE2 : RBRACE -> type(RBRACE), mode(DEFAULT_MODE); +LBRACK2 : LBRACK -> type(LBRACK), mode(DEFAULT_MODE); +RBRACK2 : RBRACK -> type(RBRACK), mode(DEFAULT_MODE); +SEMI2 : SEMI -> type(SEMI), mode(DEFAULT_MODE); +COMMA2 : COMMA -> type(COMMA), mode(DEFAULT_MODE); +DOT2 : DOT -> type(DOT), mode(DEFAULT_MODE); +DOTDOT2 : DOTDOT -> type(DOTDOT), mode(DEFAULT_MODE); +DQUOTE2 : DQUOTE -> type(DQUOTE), mode(DEFAULT_MODE); +ASSIGN2 : ASSIGN -> type(ASSIGN), mode(DEFAULT_MODE); +GT2 : GT -> type(GT), mode(DEFAULT_MODE); +LT2 : LT -> type(LT), mode(DEFAULT_MODE); +BANG2 : BANG -> type(BANG), mode(DEFAULT_MODE); +TILDE2 : TILDE -> type(TILDE), mode(DEFAULT_MODE); +QUESTION2 : QUESTION -> type(QUESTION), mode(DEFAULT_MODE); +COLON2 : COLON -> type(COLON), mode(DEFAULT_MODE); +EQUAL2 : EQUAL -> type(EQUAL), mode(DEFAULT_MODE); +LE2 : LE -> type(LE), mode(DEFAULT_MODE); +GE2 : GE -> type(GE), mode(DEFAULT_MODE); +NOTEQUAL2 : NOTEQUAL -> type(NOTEQUAL), mode(DEFAULT_MODE); +AND2 : AND -> type(ADD), mode(DEFAULT_MODE); +OR2 : OR -> type(OR), mode(DEFAULT_MODE); +INC2 : INC -> type(INC), mode(DEFAULT_MODE); +DEC2 : DEC -> type(DEC), mode(DEFAULT_MODE); +ADD2 : ADD -> type(ADD), mode(DEFAULT_MODE); +SUB2 : SUB -> type(SUB), mode(DEFAULT_MODE); +MUL2 : MUL -> type(MUL), mode(DEFAULT_MODE); +DIV2 : DIV -> type(DIV), mode(DEFAULT_MODE); +BITAND2 : BITAND -> type(BITAND), mode(DEFAULT_MODE); +BITOR2 : BITOR -> type(BITOR), mode(DEFAULT_MODE); +CARET2 : CARET -> type(CARET), mode(DEFAULT_MODE); +MOD2 : MOD -> type(MOD), mode(DEFAULT_MODE); +ADD_ASSIGN2 : ADD_ASSIGN -> type(ADD_ASSIGN), mode(DEFAULT_MODE); +SUB_ASSIGN2 : SUB_ASSIGN -> type(SUB_ASSIGN), mode(DEFAULT_MODE); +MUL_ASSIGN2 : MUL_ASSIGN -> type(MUL_ASSIGN), mode(DEFAULT_MODE); +DIV_ASSIGN2 : DIV_ASSIGN -> type(DIV_ASSIGN), mode(DEFAULT_MODE); +AND_ASSIGN2 : AND_ASSIGN -> type(AND_ASSIGN), mode(DEFAULT_MODE); +OR_ASSIGN2 : OR_ASSIGN -> type(OR_ASSIGN), mode(DEFAULT_MODE); +XOR_ASSIGN2 : XOR_ASSIGN -> type(XOR_ASSIGN), mode(DEFAULT_MODE); +MOD_ASSIGN2 : MOD_ASSIGN -> type(MOD_ASSIGN), mode(DEFAULT_MODE); +LSHIFT_ASSIGN2 : LSHIFT_ASSIGN -> type(LSHIFT_ASSIGN), mode(DEFAULT_MODE); +RSHIFT_ASSIGN2 : RSHIFT_ASSIGN -> type(RSHIFT_ASSIGN), mode(DEFAULT_MODE); +URSHIFT_ASSIGN2 : URSHIFT_ASSIGN -> type(URSHIFT_ASSIGN), mode(DEFAULT_MODE); +Identifier2 : Identifier -> type(Identifier), mode(DEFAULT_MODE); -ASSIGN3 : ASSIGN -> type(ASSIGN); -LBRACE3 : LBRACE -> type(LBRACE); -RBRACE3 : RBRACE -> type(RBRACE); -COMMA3 : COMMA -> type(COMMA); -DOT3 : DOT -> type(DOT); -CLASS3 : CLASS -> type(CLASS); +AT2: AT -> type(AT), mode(Annotation); -DEFAULTIMPL3 : ANNOTATION_DEFAULTIMPL -> type(ANNOTATION_DEFAULTIMPL); -ANNOTATION_INTERFACES3 : ANNOTATION_INTERFACES -> type(ANNOTATION_INTERFACES); -POINTCUT3 : POINTCUT -> type(POINTCUT); -RETURNING3 : RETURNING -> type(RETURNING); -VALUE3 : ANNOTATION_VALUE -> type(ANNOTATION_VALUE); +ELLIPSIS2 : ELLIPSIS -> type(ELLIPSIS), mode(DEFAULT_MODE); +WS2 : WS -> skip; +COMMENT2 : COMMENT -> skip; +LINE_COMMENT2 : LINE_COMMENT -> skip; -Identifier3 : Identifier -> type(Identifier); -WS3 : [ \t\r\n\u000C]+ -> skip; -COMMENT3 : '/*' .*? '*/' -> skip; -LINE_COMMENT3 : '//' ~[\r\n]* -> skip; -INVALID3 : . -> mode(DEFAULT_MODE); +mode AspectJAnnotationScope; +RPAREN3: RPAREN -> type(RPAREN), mode(DEFAULT_MODE); + +DQUOTE3: DQUOTE -> type(DQUOTE), pushMode(AspectJAnnotationString); + +AT3: AT -> type(AT), pushMode(Annotation); + +ASSIGN3 : ASSIGN -> type(ASSIGN); +LBRACE3 : LBRACE -> type(LBRACE); +RBRACE3 : RBRACE -> type(RBRACE); +COMMA3 : COMMA -> type(COMMA); +DOT3 : DOT -> type(DOT); +CLASS3 : CLASS -> type(CLASS); + +DEFAULTIMPL3 : ANNOTATION_DEFAULTIMPL -> type(ANNOTATION_DEFAULTIMPL); +ANNOTATION_INTERFACES3 : ANNOTATION_INTERFACES -> type(ANNOTATION_INTERFACES); +POINTCUT3 : POINTCUT -> type(POINTCUT); +RETURNING3 : RETURNING -> type(RETURNING); +VALUE3 : ANNOTATION_VALUE -> type(ANNOTATION_VALUE); + +Identifier3 : Identifier -> type(Identifier); +WS3 : [ \t\r\n\u000C]+ -> skip; +COMMENT3 : '/*' .*? '*/' -> skip; +LINE_COMMENT3 : '//' ~[\r\n]* -> skip; +INVALID3 : . -> mode(DEFAULT_MODE); mode AspectJAnnotationString; -DQUOTE4 : DQUOTE -> type(DQUOTE), popMode; - -LPAREN4 : LPAREN -> type(LPAREN); -RPAREN4 : RPAREN -> type(RPAREN); -COLON4 : COLON -> type(COLON); -AND4 : AND -> type(AND); -OR4 : OR -> type(OR); -COMMA4 : COMMA -> type(COMMA); -DOT4 : DOT -> type(DOT); -DOTDOT4 : DOTDOT -> type(DOTDOT); -EQUAL4 : EQUAL -> type(EQUAL); -ADD4 : ADD -> type(ADD); -LBRACE4 : LBRACE -> type(LBRACE); -RBRACE4 : RBRACE -> type(RBRACE); -BANG4 : BANG -> type(BANG); -MUL4 : MUL -> type(MUL); -ASSIGN4 : ASSIGN -> type(ASSIGN); -BOOLEAN4 : BOOLEAN -> type(BOOLEAN); -BYTE4 : BYTE -> type(BYTE); -CHAR4 : CHAR -> type(CHAR); -IF4 : IF -> type(IF); -INT4 : INT -> type(INT); -LONG4 : LONG -> type(LONG); -NEW4 : NEW -> type(NEW); -SHORT4 : SHORT -> type(SHORT); -THIS4 : THIS -> type(THIS); -VOID4 : VOID -> type(VOID); - -ADVICEEXECUTION4 : ADVICEEXECUTION -> type(ADVICEEXECUTION); -ANNOTATION4 : ANNOTATION -> type(ANNOTATION); -ARGS4 : ARGS -> type(ARGS); -AFTER4 : AFTER -> type(AFTER); -AROUND4 : AROUND -> type(AROUND); -ASPECT4 : ASPECT -> type(ASPECT); -BEFORE4 : BEFORE -> type(BEFORE); -CALL4 : CALL -> type(CALL); -CFLOW4 : CFLOW -> type(CFLOW); -CFLOWBELOW4 : CFLOWBELOW -> type(CFLOWBELOW); -DECLARE4 : DECLARE -> type(DECLARE); -ERROR4 : ERROR -> type(ERROR); -EXECUTION4 : EXECUTION -> type(EXECUTION); -GET4 : GET -> type(GET); -HANDLER4 : HANDLER -> type(HANDLER); -INITIALIZATION4 : INITIALIZATION -> type(INITIALIZATION); -ISSINGLETON4 : ISSINGLETON -> type(ISSINGLETON); -PARENTS4 : PARENTS -> type(PARENTS); -PERCFLOW4 : PERCFLOW -> type(PERCFLOW); -PERCFLOWBELOW4 : PERCFLOWBELOW -> type(PERCFLOWBELOW); -PERTARGET4 : PERTARGET -> type(PERTARGET); -PERTHIS4 : PERTHIS -> type(PERTHIS); -PERTYPEWITHIN4 : PERTYPEWITHIN -> type(PERTYPEWITHIN); -POINTCUT4 : POINTCUT -> type(POINTCUT); -PRECEDENCE4 : PRECEDENCE -> type(PRECEDENCE); -PREINITIALIZATION4 : PREINITIALIZATION -> type(PREINITIALIZATION ); -PRIVILEGED4 : PRIVILEGED -> type(PRIVILEGED); -RETURNING4 : RETURNING -> type(RETURNING); -SET4 : SET -> type(SET ); -SOFT4 : SOFT -> type(SOFT ); -STATICINITIALIZATION4 : STATICINITIALIZATION -> type(STATICINITIALIZATION); -TARGET4 : TARGET -> type(TARGET ); -THROWING4 : THROWING -> type(THROWING); -WARNING4 : WARNING -> type(WARNING); -WITHIN4 : WITHIN -> type(WITHIN ); -WITHINCODE4 : WITHINCODE -> type(WITHINCODE); - -Identifier4 : Identifier -> type(Identifier); -WS4 : [ \t\r\n\u000C]+ -> skip; -COMMENT4 : '/*' .*? '*/' -> skip; -LINE_COMMENT4 : '//' ~[\r\n]* -> skip; -INVALID4 : . -> popMode, mode(DEFAULT_MODE); - \ No newline at end of file +DQUOTE4: DQUOTE -> type(DQUOTE), popMode; + +LPAREN4 : LPAREN -> type(LPAREN); +RPAREN4 : RPAREN -> type(RPAREN); +COLON4 : COLON -> type(COLON); +AND4 : AND -> type(AND); +OR4 : OR -> type(OR); +COMMA4 : COMMA -> type(COMMA); +DOT4 : DOT -> type(DOT); +DOTDOT4 : DOTDOT -> type(DOTDOT); +EQUAL4 : EQUAL -> type(EQUAL); +ADD4 : ADD -> type(ADD); +LBRACE4 : LBRACE -> type(LBRACE); +RBRACE4 : RBRACE -> type(RBRACE); +BANG4 : BANG -> type(BANG); +MUL4 : MUL -> type(MUL); +ASSIGN4 : ASSIGN -> type(ASSIGN); +BOOLEAN4 : BOOLEAN -> type(BOOLEAN); +BYTE4 : BYTE -> type(BYTE); +CHAR4 : CHAR -> type(CHAR); +IF4 : IF -> type(IF); +INT4 : INT -> type(INT); +LONG4 : LONG -> type(LONG); +NEW4 : NEW -> type(NEW); +SHORT4 : SHORT -> type(SHORT); +THIS4 : THIS -> type(THIS); +VOID4 : VOID -> type(VOID); + +ADVICEEXECUTION4 : ADVICEEXECUTION -> type(ADVICEEXECUTION); +ANNOTATION4 : ANNOTATION -> type(ANNOTATION); +ARGS4 : ARGS -> type(ARGS); +AFTER4 : AFTER -> type(AFTER); +AROUND4 : AROUND -> type(AROUND); +ASPECT4 : ASPECT -> type(ASPECT); +BEFORE4 : BEFORE -> type(BEFORE); +CALL4 : CALL -> type(CALL); +CFLOW4 : CFLOW -> type(CFLOW); +CFLOWBELOW4 : CFLOWBELOW -> type(CFLOWBELOW); +DECLARE4 : DECLARE -> type(DECLARE); +ERROR4 : ERROR -> type(ERROR); +EXECUTION4 : EXECUTION -> type(EXECUTION); +GET4 : GET -> type(GET); +HANDLER4 : HANDLER -> type(HANDLER); +INITIALIZATION4 : INITIALIZATION -> type(INITIALIZATION); +ISSINGLETON4 : ISSINGLETON -> type(ISSINGLETON); +PARENTS4 : PARENTS -> type(PARENTS); +PERCFLOW4 : PERCFLOW -> type(PERCFLOW); +PERCFLOWBELOW4 : PERCFLOWBELOW -> type(PERCFLOWBELOW); +PERTARGET4 : PERTARGET -> type(PERTARGET); +PERTHIS4 : PERTHIS -> type(PERTHIS); +PERTYPEWITHIN4 : PERTYPEWITHIN -> type(PERTYPEWITHIN); +POINTCUT4 : POINTCUT -> type(POINTCUT); +PRECEDENCE4 : PRECEDENCE -> type(PRECEDENCE); +PREINITIALIZATION4 : PREINITIALIZATION -> type(PREINITIALIZATION ); +PRIVILEGED4 : PRIVILEGED -> type(PRIVILEGED); +RETURNING4 : RETURNING -> type(RETURNING); +SET4 : SET -> type(SET ); +SOFT4 : SOFT -> type(SOFT ); +STATICINITIALIZATION4 : STATICINITIALIZATION -> type(STATICINITIALIZATION); +TARGET4 : TARGET -> type(TARGET ); +THROWING4 : THROWING -> type(THROWING); +WARNING4 : WARNING -> type(WARNING); +WITHIN4 : WITHIN -> type(WITHIN ); +WITHINCODE4 : WITHINCODE -> type(WITHINCODE); + +Identifier4 : Identifier -> type(Identifier); +WS4 : [ \t\r\n\u000C]+ -> skip; +COMMENT4 : '/*' .*? '*/' -> skip; +LINE_COMMENT4 : '//' ~[\r\n]* -> skip; +INVALID4 : . -> popMode, mode(DEFAULT_MODE); \ No newline at end of file diff --git a/aspectj/AspectJParser.g4 b/aspectj/AspectJParser.g4 index d6f49c743f..0546ad1f23 100644 --- a/aspectj/AspectJParser.g4 +++ b/aspectj/AspectJParser.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2015 Adam Taylor @@ -33,543 +32,518 @@ https://eclipse.org/aspectj/doc/next/progguide/starting.html https://eclipse.org/aspectj/doc/next/adk15notebook/grammar.html */ - - /* + +/* This grammar builds on top of the ANTLR4 Java grammar, but it uses lexical modes to lex the annotation form of AspectJ; hence in order to use it you need to break Java.g4 into Separate Lexer (JavaLexer.g4) and Parser (JavaParser.g4) grammars. */ +// $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 AspectJParser; -options { tokenVocab=AspectJLexer; } +options { + tokenVocab = AspectJLexer; +} import JavaParser; typeDeclaration - : classOrInterfaceModifier* classDeclaration - | classOrInterfaceModifier* enumDeclaration - | classOrInterfaceModifier* interfaceDeclaration - | classOrInterfaceModifier* annotationTypeDeclaration - | classOrInterfaceModifier* aspectDeclaration - | ';' - ; - + : classOrInterfaceModifier* classDeclaration + | classOrInterfaceModifier* enumDeclaration + | classOrInterfaceModifier* interfaceDeclaration + | classOrInterfaceModifier* annotationTypeDeclaration + | classOrInterfaceModifier* aspectDeclaration + | ';' + ; + aspectBody - : '{' aspectBodyDeclaration* '}' - ; + : '{' aspectBodyDeclaration* '}' + ; classBodyDeclaration - : ';' - | 'static'? block - | modifier* memberDeclaration - | 'static' aspectDeclaration + : ';' + | 'static'? block + | modifier* memberDeclaration + | 'static' aspectDeclaration ; - + aspectBodyDeclaration - : classBodyDeclaration - | advice - | interTypeMemberDeclaration - | interTypeDeclaration - ; + : classBodyDeclaration + | advice + | interTypeMemberDeclaration + | interTypeDeclaration + ; memberDeclaration - : methodDeclaration - | genericMethodDeclaration - | fieldDeclaration - | constructorDeclaration - | genericConstructorDeclaration - | interfaceDeclaration - | annotationTypeDeclaration - | classDeclaration - | enumDeclaration - | pointcutDeclaration - ; - + : methodDeclaration + | genericMethodDeclaration + | fieldDeclaration + | constructorDeclaration + | genericConstructorDeclaration + | interfaceDeclaration + | annotationTypeDeclaration + | classDeclaration + | enumDeclaration + | pointcutDeclaration + ; + // ANNOTATIONS annotation - : '@' annotationName ( '(' ( elementValuePairs | elementValue )? ')' )? - | '@' 'After' '(' '"' pointcutExpression '"' ')' - | '@' 'AfterReturning' '(' '"' pointcutExpression '"' ')' - | '@' 'AfterReturning' '(' 'pointcut' '=' '"' pointcutExpression '"' ',' 'returning' '=' '"' id '"' ')' - | '@' 'AfterThrowing' '(' '"' pointcutExpression '"' ')' - | '@' 'Around' '(' '"' pointcutExpression '"' ')' - | '@' 'Aspect' ( '(' '"' perClause '"' ')' )? - | '@' 'Before' '(' '"' pointcutExpression '"' ')' - | '@' 'DeclareError' '(' '"' pointcutExpression '"' ')' - | '@' 'DeclareMixin' '(' 'value' '=' '"' typePattern '"' ',' 'interfaces' '=' '{' classPatternList '}' ')' - | '@' 'DeclareParents' '(' '"' typePattern '"' ')' - | '@' 'DeclareParents' '(' 'value' '=' '"' typePattern '"' ',' 'defaultImpl' '=' classPattern ')' - | '@' 'DeclarePrecedence' '(' '"' typePatternList '"' ')' - | '@' 'DeclareWarning' '(' '"' pointcutExpression '"' ')' - | '@' 'Pointcut' '(' '"' pointcutExpression? '"' ')' - ; - + : '@' annotationName ('(' ( elementValuePairs | elementValue)? ')')? + | '@' 'After' '(' '"' pointcutExpression '"' ')' + | '@' 'AfterReturning' '(' '"' pointcutExpression '"' ')' + | '@' 'AfterReturning' '(' 'pointcut' '=' '"' pointcutExpression '"' ',' 'returning' '=' '"' id '"' ')' + | '@' 'AfterThrowing' '(' '"' pointcutExpression '"' ')' + | '@' 'Around' '(' '"' pointcutExpression '"' ')' + | '@' 'Aspect' ( '(' '"' perClause '"' ')')? + | '@' 'Before' '(' '"' pointcutExpression '"' ')' + | '@' 'DeclareError' '(' '"' pointcutExpression '"' ')' + | '@' 'DeclareMixin' '(' 'value' '=' '"' typePattern '"' ',' 'interfaces' '=' '{' classPatternList '}' ')' + | '@' 'DeclareParents' '(' '"' typePattern '"' ')' + | '@' 'DeclareParents' '(' 'value' '=' '"' typePattern '"' ',' 'defaultImpl' '=' classPattern ')' + | '@' 'DeclarePrecedence' '(' '"' typePatternList '"' ')' + | '@' 'DeclareWarning' '(' '"' pointcutExpression '"' ')' + | '@' 'Pointcut' '(' '"' pointcutExpression? '"' ')' + ; + classPattern - : id ('.' id)* '.' 'class' - ; + : id ('.' id)* '.' 'class' + ; classPatternList - : classPattern (',' classPattern)* - ; - - + : classPattern (',' classPattern)* + ; + aspectDeclaration - : 'privileged'? modifier* 'aspect' id - ('extends' type)? - ('implements' typeList)? - perClause? - aspectBody - ; - + : 'privileged'? modifier* 'aspect' id ('extends' type)? ('implements' typeList)? perClause? aspectBody + ; + advice - : 'strictfp'? adviceSpec ('throws' typeList)? ':' pointcutExpression methodBody - ; + : 'strictfp'? adviceSpec ('throws' typeList)? ':' pointcutExpression methodBody + ; adviceSpec - : 'before' formalParameters - | 'after' formalParameters - | 'after' formalParameters 'returning' ('(' formalParameter? ')')? - | 'after' formalParameters 'throwing' ('(' formalParameter? ')')? - | (type | 'void') 'around' formalParameters - ; + : 'before' formalParameters + | 'after' formalParameters + | 'after' formalParameters 'returning' ('(' formalParameter? ')')? + | 'after' formalParameters 'throwing' ('(' formalParameter? ')')? + | (type | 'void') 'around' formalParameters + ; perClause - : 'pertarget' '(' pointcutExpression ')' - | 'perthis' '(' pointcutExpression ')' - | 'percflow' '(' pointcutExpression ')' - | 'percflowbelow' '(' pointcutExpression ')' - | 'pertypewithin' '(' typePattern ')' - | 'issingleton' '(' ')' - ; - + : 'pertarget' '(' pointcutExpression ')' + | 'perthis' '(' pointcutExpression ')' + | 'percflow' '(' pointcutExpression ')' + | 'percflowbelow' '(' pointcutExpression ')' + | 'pertypewithin' '(' typePattern ')' + | 'issingleton' '(' ')' + ; + pointcutDeclaration - : 'abstract' modifier* 'pointcut' id formalParameters ';' - | modifier* 'pointcut' id formalParameters ':' pointcutExpression ';' - ; - + : 'abstract' modifier* 'pointcut' id formalParameters ';' + | modifier* 'pointcut' id formalParameters ':' pointcutExpression ';' + ; + pointcutExpression - : (pointcutPrimitive | referencePointcut) - | '!' pointcutExpression - | '(' pointcutExpression ')' - | pointcutExpression '&&' pointcutExpression - | pointcutExpression '||' pointcutExpression - ; - + : (pointcutPrimitive | referencePointcut) + | '!' pointcutExpression + | '(' pointcutExpression ')' + | pointcutExpression '&&' pointcutExpression + | pointcutExpression '||' pointcutExpression + ; + pointcutPrimitive - : 'call' '(' methodOrConstructorPattern ')' #CallPointcut - | 'execution' '(' methodOrConstructorPattern ')' #ExecutionPointcut - | 'initialization' '(' constructorPattern ')' #InitializationPointcut - | 'preinitialization' '(' constructorPattern ')' #PreInitializationPointcut - | 'staticinitialization' '(' optionalParensTypePattern ')' #StaticInitializationPointcut - | 'get' '(' fieldPattern ')' #GetPointcut - | 'set' '(' fieldPattern ')' #SetPointcut - | 'handler' '(' optionalParensTypePattern ')' #HandlerPointcut - | 'adviceexecution' '(' ')' #AdviceExecutionPointcut - | 'within' '(' optionalParensTypePattern ')' #WithinPointcut - | 'withincode' '(' methodOrConstructorPattern ')' #WithinCodePointcut - | 'cflow' '(' pointcutExpression ')' #CFlowPointcut - | 'cflowbelow' '(' pointcutExpression ')' #CFlowBelowPointcut - | 'if' '(' expression? ')' #IfPointcut - | 'this' '(' typeOrIdentifier ')' #ThisPointcutPointcut - | 'target' '(' typeOrIdentifier ')' #TargetPointcut - | 'args' '(' argsPatternList ')' #ArgsPointcut - | '@' 'this' '(' annotationOrIdentifer ')' #AnnotationThisPointcut - | '@' 'target' '(' annotationOrIdentifer ')' #AnnotationTargetPointcut - | '@' 'args' '(' annotationsOrIdentifiersPattern ')' #AnnotationArgsPointcut - | '@' 'within' '(' annotationOrIdentifer ')' #AnnotationWithinPointcut - | '@' 'withincode' '(' annotationOrIdentifer ')' #AnnotationWithinCodePointcut - | '@' 'annotation' '(' annotationOrIdentifer ')' #AnnotationPointcut - ; + : 'call' '(' methodOrConstructorPattern ')' # CallPointcut + | 'execution' '(' methodOrConstructorPattern ')' # ExecutionPointcut + | 'initialization' '(' constructorPattern ')' # InitializationPointcut + | 'preinitialization' '(' constructorPattern ')' # PreInitializationPointcut + | 'staticinitialization' '(' optionalParensTypePattern ')' # StaticInitializationPointcut + | 'get' '(' fieldPattern ')' # GetPointcut + | 'set' '(' fieldPattern ')' # SetPointcut + | 'handler' '(' optionalParensTypePattern ')' # HandlerPointcut + | 'adviceexecution' '(' ')' # AdviceExecutionPointcut + | 'within' '(' optionalParensTypePattern ')' # WithinPointcut + | 'withincode' '(' methodOrConstructorPattern ')' # WithinCodePointcut + | 'cflow' '(' pointcutExpression ')' # CFlowPointcut + | 'cflowbelow' '(' pointcutExpression ')' # CFlowBelowPointcut + | 'if' '(' expression? ')' # IfPointcut + | 'this' '(' typeOrIdentifier ')' # ThisPointcutPointcut + | 'target' '(' typeOrIdentifier ')' # TargetPointcut + | 'args' '(' argsPatternList ')' # ArgsPointcut + | '@' 'this' '(' annotationOrIdentifer ')' # AnnotationThisPointcut + | '@' 'target' '(' annotationOrIdentifer ')' # AnnotationTargetPointcut + | '@' 'args' '(' annotationsOrIdentifiersPattern ')' # AnnotationArgsPointcut + | '@' 'within' '(' annotationOrIdentifer ')' # AnnotationWithinPointcut + | '@' 'withincode' '(' annotationOrIdentifer ')' # AnnotationWithinCodePointcut + | '@' 'annotation' '(' annotationOrIdentifer ')' # AnnotationPointcut + ; referencePointcut - : (typePattern '.')? id formalParametersPattern - ; - + : (typePattern '.')? id formalParametersPattern + ; + interTypeMemberDeclaration - : modifier* (type|'void') type '.' id formalParameters ('throws' typeList)? methodBody - | modifier* 'abstract' modifier* (type|'void') type '.' id formalParameters ('throws' typeList)? ';' - | modifier* type '.' 'new' formalParameters ('throws' typeList)? methodBody - | modifier* (type|'void') type '.' id ('=' expression)? ';' - ; + : modifier* (type | 'void') type '.' id formalParameters ('throws' typeList)? methodBody + | modifier* 'abstract' modifier* (type | 'void') type '.' id formalParameters ( + 'throws' typeList + )? ';' + | modifier* type '.' 'new' formalParameters ('throws' typeList)? methodBody + | modifier* (type | 'void') type '.' id ('=' expression)? ';' + ; interTypeDeclaration - : 'declare' 'parents' ':' typePattern 'extends' type ';' - | 'declare' 'parents' ':' typePattern 'implements' typeList ';' - | 'declare' 'warning' ':' pointcutExpression ':' StringLiteral ';' - | 'declare' 'error' ':' pointcutExpression ':' StringLiteral ';' - | 'declare' 'soft' ':' type ':' pointcutExpression ';' - | 'declare' 'precedence' ':' typePatternList ';' - | 'declare' '@' 'type' ':' typePattern ':' annotation ';' - | 'declare' '@' 'method' ':' methodPattern ':' annotation ';' - | 'declare' '@' 'constructor' ':' constructorPattern ':' annotation ';' - | 'declare' '@' 'field' ':' fieldPattern ':' annotation ';' - ; + : 'declare' 'parents' ':' typePattern 'extends' type ';' + | 'declare' 'parents' ':' typePattern 'implements' typeList ';' + | 'declare' 'warning' ':' pointcutExpression ':' StringLiteral ';' + | 'declare' 'error' ':' pointcutExpression ':' StringLiteral ';' + | 'declare' 'soft' ':' type ':' pointcutExpression ';' + | 'declare' 'precedence' ':' typePatternList ';' + | 'declare' '@' 'type' ':' typePattern ':' annotation ';' + | 'declare' '@' 'method' ':' methodPattern ':' annotation ';' + | 'declare' '@' 'constructor' ':' constructorPattern ':' annotation ';' + | 'declare' '@' 'field' ':' fieldPattern ':' annotation ';' + ; typePattern - : simpleTypePattern - | '!' typePattern - | '(' annotationPattern? typePattern ')' - | typePattern '&&' typePattern - | typePattern '||' typePattern - ; - + : simpleTypePattern + | '!' typePattern + | '(' annotationPattern? typePattern ')' + | typePattern '&&' typePattern + | typePattern '||' typePattern + ; + simpleTypePattern - : dottedNamePattern '+'? ('[' ']')* - ; - + : dottedNamePattern '+'? ('[' ']')* + ; + dottedNamePattern - : (type | id | '*' | '.' | '..')+ - | 'void' - ; + : (type | id | '*' | '.' | '..')+ + | 'void' + ; optionalParensTypePattern - : '(' annotationPattern? typePattern ')' - | annotationPattern? typePattern - ; - - + : '(' annotationPattern? typePattern ')' + | annotationPattern? typePattern + ; + fieldPattern - : annotationPattern? fieldModifiersPattern? typePattern (typePattern dotOrDotDot)? simpleNamePattern - ; - + : annotationPattern? fieldModifiersPattern? typePattern (typePattern dotOrDotDot)? simpleNamePattern + ; + fieldModifiersPattern - : '!'? fieldModifier fieldModifiersPattern* - ; - + : '!'? fieldModifier fieldModifiersPattern* + ; + fieldModifier - : ( 'public' - | 'private' - | 'protected' - | 'static' - | 'transient' - | 'final' - ) - ; - + : ('public' | 'private' | 'protected' | 'static' | 'transient' | 'final') + ; + dotOrDotDot - : '.' - | '..' - ; - + : '.' + | '..' + ; + simpleNamePattern - : id ('*' id)* '*'? - | '*' (id '*')* id? - ; - + : id ('*' id)* '*'? + | '*' (id '*')* id? + ; + methodOrConstructorPattern - : methodPattern - | constructorPattern - ; - + : methodPattern + | constructorPattern + ; + methodPattern - : annotationPattern? methodModifiersPattern? typePattern (typePattern dotOrDotDot)? simpleNamePattern formalParametersPattern throwsPattern? - ; - - + : annotationPattern? methodModifiersPattern? typePattern (typePattern dotOrDotDot)? simpleNamePattern formalParametersPattern throwsPattern? + ; + methodModifiersPattern - : '!'? methodModifier methodModifiersPattern* - ; - + : '!'? methodModifier methodModifiersPattern* + ; + methodModifier - : ( 'public' - | 'private' - | 'protected' - | 'static' - | 'synchronized' - | 'final' - ) - ; - + : ('public' | 'private' | 'protected' | 'static' | 'synchronized' | 'final') + ; + formalsPattern - : '..' (',' formalsPatternAfterDotDot)* - | optionalParensTypePattern (',' formalsPattern)* - | typePattern '...' - ; - + : '..' (',' formalsPatternAfterDotDot)* + | optionalParensTypePattern (',' formalsPattern)* + | typePattern '...' + ; + formalsPatternAfterDotDot - : optionalParensTypePattern (',' formalsPatternAfterDotDot)* - | typePattern '...' - ; - + : optionalParensTypePattern (',' formalsPatternAfterDotDot)* + | typePattern '...' + ; + throwsPattern - : 'throws' typePatternList - ; - + : 'throws' typePatternList + ; + typePatternList - : typePattern (',' typePattern)* - ; + : typePattern (',' typePattern)* + ; - constructorPattern - : annotationPattern? constructorModifiersPattern? (typePattern dotOrDotDot)? 'new' formalParametersPattern throwsPattern? - ; - + : annotationPattern? constructorModifiersPattern? (typePattern dotOrDotDot)? 'new' formalParametersPattern throwsPattern? + ; + constructorModifiersPattern - : '!'? constructorModifier constructorModifiersPattern* - ; - + : '!'? constructorModifier constructorModifiersPattern* + ; + constructorModifier - : ('public' | 'private' | 'protected') - ; + : ('public' | 'private' | 'protected') + ; - annotationPattern - : '!'? '@' annotationTypePattern annotationPattern* - ; + : '!'? '@' annotationTypePattern annotationPattern* + ; annotationTypePattern - : qualifiedName - | '(' typePattern ')' - ; - + : qualifiedName + | '(' typePattern ')' + ; + formalParametersPattern - : '(' formalsPattern? ')' - ; + : '(' formalsPattern? ')' + ; typeOrIdentifier - : type - | variableDeclaratorId - ; - + : type + | variableDeclaratorId + ; + annotationOrIdentifer - : qualifiedName | id - ; + : qualifiedName + | id + ; annotationsOrIdentifiersPattern - : '..' (',' annotationsOrIdentifiersPatternAfterDotDot)? - | annotationOrIdentifer (',' annotationsOrIdentifiersPattern)* - | '*' (',' annotationsOrIdentifiersPattern)* - ; - + : '..' (',' annotationsOrIdentifiersPatternAfterDotDot)? + | annotationOrIdentifer (',' annotationsOrIdentifiersPattern)* + | '*' (',' annotationsOrIdentifiersPattern)* + ; + annotationsOrIdentifiersPatternAfterDotDot - : annotationOrIdentifer (',' annotationsOrIdentifiersPatternAfterDotDot)* - | '*' (',' annotationsOrIdentifiersPatternAfterDotDot)* - ; - + : annotationOrIdentifer (',' annotationsOrIdentifiersPatternAfterDotDot)* + | '*' (',' annotationsOrIdentifiersPatternAfterDotDot)* + ; + argsPattern - : typeOrIdentifier - | ('*' | '..') - ; - -argsPatternList - : argsPattern (',' argsPattern)* - ; + : typeOrIdentifier + | ('*' | '..') + ; +argsPatternList + : argsPattern (',' argsPattern)* + ; // all of the following rules are only necessary to change rules in the original Java grammar from 'Identifier' to 'id' id - : ( ARGS - | AFTER - | AROUND - | ASPECT - | BEFORE - | CALL - | CFLOW - | CFLOWBELOW - | DECLARE - | ERROR - | EXECUTION - | GET - | HANDLER - | INITIALIZATION - | ISSINGLETON - | PARENTS - | PERCFLOW - | PERCFLOWBELOW - | PERTARGET - | PERTHIS - | PERTYPEWITHIN - | POINTCUT - | PRECEDENCE - | PREINITIALIZATION - | PRIVILEGED - | RETURNING - | SET - | SOFT - | STATICINITIALIZATION - | TARGET - | THROWING - | WARNING - | WITHIN - | WITHINCODE - ) - | Identifier - ; - - + : ( + ARGS + | AFTER + | AROUND + | ASPECT + | BEFORE + | CALL + | CFLOW + | CFLOWBELOW + | DECLARE + | ERROR + | EXECUTION + | GET + | HANDLER + | INITIALIZATION + | ISSINGLETON + | PARENTS + | PERCFLOW + | PERCFLOWBELOW + | PERTARGET + | PERTHIS + | PERTYPEWITHIN + | POINTCUT + | PRECEDENCE + | PREINITIALIZATION + | PRIVILEGED + | RETURNING + | SET + | SOFT + | STATICINITIALIZATION + | TARGET + | THROWING + | WARNING + | WITHIN + | WITHINCODE + ) + | Identifier + ; + classDeclaration - : 'class' id typeParameters? - ('extends' type)? - ('implements' typeList)? - classBody + : 'class' id typeParameters? ('extends' type)? ('implements' typeList)? classBody ; - + typeParameter - : id ('extends' typeBound)? + : id ('extends' typeBound)? ; - + enumDeclaration - : ENUM id ('implements' typeList)? - '{' enumConstants? ','? enumBodyDeclarations? '}' + : ENUM id ('implements' typeList)? '{' enumConstants? ','? enumBodyDeclarations? '}' ; enumConstant - : annotation* id arguments? classBody? + : annotation* id arguments? classBody? ; - + interfaceDeclaration - : 'interface' id typeParameters? ('extends' typeList)? interfaceBody + : 'interface' id typeParameters? ('extends' typeList)? interfaceBody ; - + methodDeclaration - : (type|'void') id formalParameters ('[' ']')* - ('throws' qualifiedNameList)? - ( methodBody - | ';' - ) + : (type | 'void') id formalParameters ('[' ']')* ('throws' qualifiedNameList)? ( + methodBody + | ';' + ) ; constructorDeclaration - : id formalParameters ('throws' qualifiedNameList)? - constructorBody + : id formalParameters ('throws' qualifiedNameList)? constructorBody ; - + constantDeclarator - : id ('[' ']')* '=' variableInitializer + : id ('[' ']')* '=' variableInitializer ; - + interfaceMethodDeclaration - : (type|'void') id formalParameters ('[' ']')* - ('throws' qualifiedNameList)? - ';' + : (type | 'void') id formalParameters ('[' ']')* ('throws' qualifiedNameList)? ';' ; - + variableDeclaratorId - : id ('[' ']')* + : id ('[' ']')* ; - + enumConstantName - : id + : id ; - + classOrInterfaceType - : id typeArguments? ('.' id typeArguments? )* + : id typeArguments? ('.' id typeArguments?)* ; qualifiedName - : id ('.' id)* + : id ('.' id)* ; - + elementValuePair - : id '=' elementValue + : id '=' elementValue ; - + annotationTypeDeclaration - : '@' 'interface' id annotationTypeBody + : '@' 'interface' id annotationTypeBody ; - + annotationMethodRest - : id '(' ')' defaultValue? + : id '(' ')' defaultValue? ; - + statement - : block - | ASSERT expression (':' expression)? ';' - | 'if' parExpression statement ('else' statement)? - | 'for' '(' forControl ')' statement - | 'while' parExpression statement - | 'do' statement 'while' parExpression ';' - | 'try' block (catchClause+ finallyBlock? | finallyBlock) - | 'try' resourceSpecification block catchClause* finallyBlock? - | 'switch' parExpression '{' switchBlockStatementGroup* switchLabel* '}' - | 'synchronized' parExpression block - | 'return' expression? ';' - | 'throw' expression ';' - | 'break' id? ';' - | 'continue' id? ';' - | ';' - | statementExpression ';' - | id ':' statement - ; - + : block + | ASSERT expression (':' expression)? ';' + | 'if' parExpression statement ('else' statement)? + | 'for' '(' forControl ')' statement + | 'while' parExpression statement + | 'do' statement 'while' parExpression ';' + | 'try' block (catchClause+ finallyBlock? | finallyBlock) + | 'try' resourceSpecification block catchClause* finallyBlock? + | 'switch' parExpression '{' switchBlockStatementGroup* switchLabel* '}' + | 'synchronized' parExpression block + | 'return' expression? ';' + | 'throw' expression ';' + | 'break' id? ';' + | 'continue' id? ';' + | ';' + | statementExpression ';' + | id ':' statement + ; + catchClause - : 'catch' '(' variableModifier* catchType id ')' block + : 'catch' '(' variableModifier* catchType id ')' block ; - + expression - : primary - | expression '.' id - | expression '.' 'this' - | expression '.' 'new' nonWildcardTypeArguments? innerCreator - | expression '.' 'super' superSuffix - | expression '.' explicitGenericInvocation - | expression '[' expression ']' - | expression '(' expressionList? ')' - | 'new' creator - | '(' type ')' expression - | expression ('++' | '--') - | ('+'|'-'|'++'|'--') expression - | ('~'|'!') expression - | expression ('*'|'/'|'%') expression - | expression ('+'|'-') expression - | expression ('<' '<' | '>' '>' '>' | '>' '>') expression - | expression ('<=' | '>=' | '>' | '<') expression - | expression 'instanceof' type - | expression ('==' | '!=') expression - | expression '&' expression - | expression '^' expression - | expression '|' expression - | expression '&&' expression - | expression '||' expression - | expression '?' expression ':' expression - | /**/ expression - ( '=' - | '+=' - | '-=' - | '*=' - | '/=' - | '&=' - | '|=' - | '^=' - | '>>=' - | '>>>=' - | '<<=' - | '%=' - ) - expression + : primary + | expression '.' id + | expression '.' 'this' + | expression '.' 'new' nonWildcardTypeArguments? innerCreator + | expression '.' 'super' superSuffix + | expression '.' explicitGenericInvocation + | expression '[' expression ']' + | expression '(' expressionList? ')' + | 'new' creator + | '(' type ')' expression + | expression ('++' | '--') + | ('+' | '-' | '++' | '--') expression + | ('~' | '!') expression + | expression ('*' | '/' | '%') expression + | expression ('+' | '-') expression + | expression ('<' '<' | '>' '>' '>' | '>' '>') expression + | expression ('<=' | '>=' | '>' | '<') expression + | expression 'instanceof' type + | expression ('==' | '!=') expression + | expression '&' expression + | expression '^' expression + | expression '|' expression + | expression '&&' expression + | expression '||' expression + | expression '?' expression ':' expression + | /**/ expression ( + '=' + | '+=' + | '-=' + | '*=' + | '/=' + | '&=' + | '|=' + | '^=' + | '>>=' + | '>>>=' + | '<<=' + | '%=' + ) expression ; primary - : '(' expression ')' - | 'this' - | 'super' - | literal - | id - | type '.' 'class' - | 'void' '.' 'class' - | nonWildcardTypeArguments (explicitGenericInvocationSuffix | 'this' arguments) - ; - + : '(' expression ')' + | 'this' + | 'super' + | literal + | id + | type '.' 'class' + | 'void' '.' 'class' + | nonWildcardTypeArguments (explicitGenericInvocationSuffix | 'this' arguments) + ; + createdName - : id typeArgumentsOrDiamond? ('.' id typeArgumentsOrDiamond?)* - | primitiveType + : id typeArgumentsOrDiamond? ('.' id typeArgumentsOrDiamond?)* + | primitiveType ; innerCreator - : id nonWildcardTypeArgumentsOrDiamond? classCreatorRest + : id nonWildcardTypeArgumentsOrDiamond? classCreatorRest ; - + superSuffix - : arguments - | '.' id arguments? + : arguments + | '.' id arguments? ; - + explicitGenericInvocationSuffix - : 'super' superSuffix - | id arguments - ; - + : 'super' superSuffix + | id arguments + ; \ No newline at end of file diff --git a/atl/ATL.g4 b/atl/ATL.g4 index 24e10db0e5..cdece352c1 100644 --- a/atl/ATL.g4 +++ b/atl/ATL.g4 @@ -16,546 +16,557 @@ limitations under the License. Initially developed in the context of ARTIST EU project www.artist-project.eu */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ATL; /* * Parser Rules */ unit - : ( module | library_ | query ) EOF - ; + : (module | library_ | query) EOF + ; module - : 'module' (STRING | IDENTIFIER) ';' 'create' targetModelPattern transformationMode sourceModelPattern ';' libraryRef* moduleElement* - ; + : 'module' (STRING | IDENTIFIER) ';' 'create' targetModelPattern transformationMode sourceModelPattern ';' libraryRef* moduleElement* + ; // Small change introducing targetModelPattern, sourceModelPattern, transformationMode to facilitate fetching the information via the parser targetModelPattern - : oclModel (',' oclModel)* - ; + : oclModel (',' oclModel)* + ; sourceModelPattern - : oclModel (',' oclModel)* - ; + : oclModel (',' oclModel)* + ; transformationMode - : 'refining' - | 'from' - ; + : 'refining' + | 'from' + ; library_ - : 'library' (STRING | IDENTIFIER) ';' libraryRef* helper* - ; + : 'library' (STRING | IDENTIFIER) ';' libraryRef* helper* + ; query - : 'query' (STRING | IDENTIFIER) '=' oclExpression ';' libraryRef* helper* - ; + : 'query' (STRING | IDENTIFIER) '=' oclExpression ';' libraryRef* helper* + ; libraryRef - : 'uses' STRING ';' - ; + : 'uses' STRING ';' + ; moduleElement - : helper - | arule - ; + : helper + | arule + ; helper - : 'helper' oclFeatureDefinition ';' - ; + : 'helper' oclFeatureDefinition ';' + ; oclFeatureDefinition - : oclContextDefinition? 'def' ':' oclFeature - ; + : oclContextDefinition? 'def' ':' oclFeature + ; oclContextDefinition - : 'context' oclType - ; + : 'context' oclType + ; oclFeature - : operation - | attribute - ; + : operation + | attribute + ; operation - : IDENTIFIER '(' (parameter (',' parameter)*)? ')' ':' oclType '=' oclExpression - ; + : IDENTIFIER '(' (parameter (',' parameter)*)? ')' ':' oclType '=' oclExpression + ; parameter - : IDENTIFIER ':' oclType - ; + : IDENTIFIER ':' oclType + ; attribute - : IDENTIFIER ':' oclType '=' oclExpression - ; + : IDENTIFIER ':' oclType '=' oclExpression + ; arule - : calledRule - | matchedRule - ; + : calledRule + | matchedRule + ; matchedRule - : lazyMatchedRule - | matchedRule_abstractContents - ; + : lazyMatchedRule + | matchedRule_abstractContents + ; lazyMatchedRule - : 'unique'? 'lazy' 'abstract'? 'refining'? 'rule' IDENTIFIER ('extends' IDENTIFIER)? '{' inPattern ('using' '{' ruleVariableDeclaration* '}')? outPattern? actionBlock? '}' - ; + : 'unique'? 'lazy' 'abstract'? 'refining'? 'rule' IDENTIFIER ('extends' IDENTIFIER)? '{' inPattern ( + 'using' '{' ruleVariableDeclaration* '}' + )? outPattern? actionBlock? '}' + ; ruleVariableDeclaration - : IDENTIFIER ':' oclType '=' oclExpression ';' - ; + : IDENTIFIER ':' oclType '=' oclExpression ';' + ; calledRule - : 'entrypoint'? 'endpoint'? 'rule' IDENTIFIER '(' (parameter (',' parameter)*)? ')' '{' ('using' '{' ruleVariableDeclaration* '}')? outPattern? actionBlock? '}' - ; + : 'entrypoint'? 'endpoint'? 'rule' IDENTIFIER '(' (parameter (',' parameter)*)? ')' '{' ( + 'using' '{' ruleVariableDeclaration* '}' + )? outPattern? actionBlock? '}' + ; inPattern - : 'from' inPatternElement (',' inPatternElement)* ('(' oclExpression ')')? - ; + : 'from' inPatternElement (',' inPatternElement)* ('(' oclExpression ')')? + ; inPatternElement - : simpleInPatternElement - ; + : simpleInPatternElement + ; simpleInPatternElement - : IDENTIFIER ':' oclType ('in' IDENTIFIER (',' IDENTIFIER)*)? - ; + : IDENTIFIER ':' oclType ('in' IDENTIFIER (',' IDENTIFIER)*)? + ; outPattern - : 'to' outPatternElement (',' outPatternElement)* - ; + : 'to' outPatternElement (',' outPatternElement)* + ; outPatternElement - : simpleOutPatternElement - | forEachOutPatternElement - ; + : simpleOutPatternElement + | forEachOutPatternElement + ; simpleOutPatternElement - : IDENTIFIER ':' oclType ('in' IDENTIFIER)? ('mapsTo' IDENTIFIER)? ('(' (binding (',' binding)*)? ')')? - ; + : IDENTIFIER ':' oclType ('in' IDENTIFIER)? ('mapsTo' IDENTIFIER)? ( + '(' (binding (',' binding)*)? ')' + )? + ; forEachOutPatternElement - : IDENTIFIER ':' 'distinct' oclType 'foreach' '(' iterator 'in' oclExpression ')' ('mapsTo' IDENTIFIER)? ('(' (binding (',' binding)*)? ')')? - ; + : IDENTIFIER ':' 'distinct' oclType 'foreach' '(' iterator 'in' oclExpression ')' ( + 'mapsTo' IDENTIFIER + )? ('(' (binding (',' binding)*)? ')')? + ; binding - : IDENTIFIER '<-' oclExpression - ; + : IDENTIFIER '<-' oclExpression + ; actionBlock - : 'do' '{' statement* '}' - ; + : 'do' '{' statement* '}' + ; statement - : ifStat - | expressionStat - | bindingStat - | forStat - ; + : ifStat + | expressionStat + | bindingStat + | forStat + ; bindingStat - : oclExpression '<-' oclExpression ';' - ; + : oclExpression '<-' oclExpression ';' + ; expressionStat - : oclExpression ';' - ; + : oclExpression ';' + ; ifStat - : 'if' '(' oclExpression ')' (statement | '{' statement* '}') ('else' (statement | '{' statement* '}'))? - ; + : 'if' '(' oclExpression ')' (statement | '{' statement* '}') ( + 'else' (statement | '{' statement* '}') + )? + ; forStat - : 'for' '(' iterator 'in' oclExpression ')' '{' statement* '}' - ; + : 'for' '(' iterator 'in' oclExpression ')' '{' statement* '}' + ; oclModel - : IDENTIFIER ':' IDENTIFIER - ; + : IDENTIFIER ':' IDENTIFIER + ; oclModelElement - : IDENTIFIER '!' (STRING | IDENTIFIER) - ; + : IDENTIFIER '!' (STRING | IDENTIFIER) + ; oclExpression - : priority_5 - | letExp - ; + : priority_5 + | letExp + ; iteratorExp - : IDENTIFIER '(' iterator (',' iterator)* '|' oclExpression ')' - ; + : IDENTIFIER '(' iterator (',' iterator)* '|' oclExpression ')' + ; iterateExp - : 'iterate' '(' iterator (',' iterator)* ';' variableDeclaration '|' oclExpression ')' - ; + : 'iterate' '(' iterator (',' iterator)* ';' variableDeclaration '|' oclExpression ')' + ; collectionOperationCallExp - : IDENTIFIER '(' (oclExpression (',' oclExpression)*)? ')' - ; + : IDENTIFIER '(' (oclExpression (',' oclExpression)*)? ')' + ; operationCallExp - : IDENTIFIER '(' (oclExpression (',' oclExpression)*)? ')' - ; + : IDENTIFIER '(' (oclExpression (',' oclExpression)*)? ')' + ; navigationOrAttributeCallExp - : IDENTIFIER - ; + : IDENTIFIER + ; iterator - : IDENTIFIER - ; + : IDENTIFIER + ; oclUndefinedExp - : 'OclUndefined' - ; + : 'OclUndefined' + ; primitiveExp - : numericExp - | booleanExp - | stringExp - ; + : numericExp + | booleanExp + | stringExp + ; numericExp - : integerExp - | realExp - ; + : integerExp + | realExp + ; booleanExp - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; integerExp - : INTEGER - ; + : INTEGER + ; realExp - : FLOAT - ; + : FLOAT + ; stringExp - : STRING - ; + : STRING + ; ifExp - : 'if' oclExpression 'then' oclExpression 'else' oclExpression 'endif' - ; + : 'if' oclExpression 'then' oclExpression 'else' oclExpression 'endif' + ; variableExp - : IDENTIFIER - ; + : IDENTIFIER + ; superExp - : 'super' - ; + : 'super' + ; letExp - : 'let' variableDeclaration 'in' oclExpression - ; + : 'let' variableDeclaration 'in' oclExpression + ; variableDeclaration - : IDENTIFIER ':' oclType '=' oclExpression - ; + : IDENTIFIER ':' oclType '=' oclExpression + ; enumLiteralExp - : '#' IDENTIFIER - ; + : '#' IDENTIFIER + ; collectionExp - : bagExp - | setExp - | orderedSetExp - | sequenceExp - ; + : bagExp + | setExp + | orderedSetExp + | sequenceExp + ; bagExp - : 'Bag' '{' (oclExpression (',' oclExpression)*)? '}' - ; + : 'Bag' '{' (oclExpression (',' oclExpression)*)? '}' + ; setExp - : 'Set' '{' (oclExpression (',' oclExpression)*)? '}' - ; + : 'Set' '{' (oclExpression (',' oclExpression)*)? '}' + ; orderedSetExp - : 'OrderedSet' '{' (oclExpression (',' oclExpression)*)? '}' - ; + : 'OrderedSet' '{' (oclExpression (',' oclExpression)*)? '}' + ; sequenceExp - : 'Sequence' '{' (oclExpression (',' oclExpression)*)? '}' - ; + : 'Sequence' '{' (oclExpression (',' oclExpression)*)? '}' + ; mapExp - : 'Map' '{' (mapElement (',' mapElement)*)? '}' - ; + : 'Map' '{' (mapElement (',' mapElement)*)? '}' + ; mapElement - : '(' oclExpression ',' oclExpression ')' - ; + : '(' oclExpression ',' oclExpression ')' + ; tupleExp - : 'Tuple' '{' (tuplePart (',' tuplePart)*)? '}' - ; + : 'Tuple' '{' (tuplePart (',' tuplePart)*)? '}' + ; tuplePart - : IDENTIFIER (':' oclType)? '=' oclExpression - ; + : IDENTIFIER (':' oclType)? '=' oclExpression + ; oclType - : oclModelElement - | oclAnyType - | tupleType - | mapType - | primitive - | collectionType - | oclType_abstractContents - ; + : oclModelElement + | oclAnyType + | tupleType + | mapType + | primitive + | collectionType + | oclType_abstractContents + ; oclAnyType - : oclAnyType_abstractContents - ; + : oclAnyType_abstractContents + ; tupleType - : 'TupleType' '(' (tupleTypeAttribute (',' tupleTypeAttribute)*)? ')' - ; + : 'TupleType' '(' (tupleTypeAttribute (',' tupleTypeAttribute)*)? ')' + ; tupleTypeAttribute - : IDENTIFIER ':' oclType - ; + : IDENTIFIER ':' oclType + ; mapType - : 'Map' '(' oclType ',' oclType ')' - ; + : 'Map' '(' oclType ',' oclType ')' + ; primitive - : numericType - | booleanType - | stringType - ; + : numericType + | booleanType + | stringType + ; numericType - : integerType - | realType - ; + : integerType + | realType + ; integerType - : 'Integer' - ; + : 'Integer' + ; realType - : 'Real' - ; + : 'Real' + ; booleanType - : 'Boolean' - ; + : 'Boolean' + ; stringType - : 'String' - ; + : 'String' + ; collectionType - : bagType - | setType - | orderedSetType - | sequenceType - | collectionType_abstractContents - ; + : bagType + | setType + | orderedSetType + | sequenceType + | collectionType_abstractContents + ; bagType - : 'Bag' '(' oclType ')' - ; + : 'Bag' '(' oclType ')' + ; setType - : 'Set' '(' oclType ')' - ; + : 'Set' '(' oclType ')' + ; orderedSetType - : 'OrderedSet' '(' oclType ')' - ; + : 'OrderedSet' '(' oclType ')' + ; sequenceType - : 'Sequence' '(' oclType ')' - ; + : 'Sequence' '(' oclType ')' + ; priority_0 - : primary_oclExpression ('.' (operationCallExp | navigationOrAttributeCallExp) | '->' (iteratorExp | iterateExp | collectionOperationCallExp))* - ; + : primary_oclExpression ( + '.' (operationCallExp | navigationOrAttributeCallExp) + | '->' (iteratorExp | iterateExp | collectionOperationCallExp) + )* + ; priority_1 - : 'not' priority_0 - | '-' priority_0 - | priority_0 - ; + : 'not' priority_0 + | '-' priority_0 + | priority_0 + ; priority_2 - : priority_1 ('*' priority_1 | '/' priority_1 | 'div' priority_1 | 'mod' priority_1)* - ; + : priority_1 ('*' priority_1 | '/' priority_1 | 'div' priority_1 | 'mod' priority_1)* + ; priority_3 - : priority_2 ('+' priority_2 | '-' priority_2)* - ; + : priority_2 ('+' priority_2 | '-' priority_2)* + ; priority_4 - : priority_3 ('=' priority_3 | '>' priority_3 | '<' priority_3 | '>=' priority_3 | '<=' priority_3 | '<>' priority_3)* - ; + : priority_3 ( + '=' priority_3 + | '>' priority_3 + | '<' priority_3 + | '>=' priority_3 + | '<=' priority_3 + | '<>' priority_3 + )* + ; priority_5 - : priority_4 ('and' priority_4 | 'or' priority_4 | 'xor' priority_4 | 'implies' priority_4)* - ; + : priority_4 ('and' priority_4 | 'or' priority_4 | 'xor' priority_4 | 'implies' priority_4)* + ; matchedRule_abstractContents - : 'nodefault'? 'abstract'? 'refining'? 'rule' IDENTIFIER ('extends' IDENTIFIER)? '{' inPattern ('using' '{' ruleVariableDeclaration* '}')? outPattern? actionBlock? '}' - ; + : 'nodefault'? 'abstract'? 'refining'? 'rule' IDENTIFIER ('extends' IDENTIFIER)? '{' inPattern ( + 'using' '{' ruleVariableDeclaration* '}' + )? outPattern? actionBlock? '}' + ; oclType_abstractContents - : 'OclType' - ; + : 'OclType' + ; oclAnyType_abstractContents - : 'OclAny' - ; + : 'OclAny' + ; collectionType_abstractContents - : 'Collection' '(' oclType ')' - ; + : 'Collection' '(' oclType ')' + ; primary_oclExpression - : variableExp - | oclUndefinedExp - | primitiveExp - | ifExp - | superExp - | enumLiteralExp - | collectionExp - | mapExp - | tupleExp - | oclType - | '(' oclExpression ')' - ; - + : variableExp + | oclUndefinedExp + | primitiveExp + | ifExp + | superExp + | enumLiteralExp + | collectionExp + | mapExp + | tupleExp + | oclType + | '(' oclExpression ')' + ; STRING - : '"' DoubleStringCharacters? '"' | '\'' SingleStringCharacters? '\'' - ; - + : '"' DoubleStringCharacters? '"' + | '\'' SingleStringCharacters? '\'' + ; fragment DoubleStringCharacters - : DoubleStringCharacter + - ; - + : DoubleStringCharacter+ + ; fragment DoubleStringCharacter - : ~ ["\\] | '\\' [btnfr"'\\] - ; - + : ~ ["\\] + | '\\' [btnfr"'\\] + ; fragment SingleStringCharacters - : SingleStringCharacter + - ; - + : SingleStringCharacter+ + ; fragment SingleStringCharacter - : ~ ['\\] | '\\' [btnfr"'\\] - ; + : ~ ['\\] + | '\\' [btnfr"'\\] + ; // Integer Literals INTEGER - : DecimalIntegerLiteral - ; - + : DecimalIntegerLiteral + ; fragment DecimalIntegerLiteral - : DecimalNumeral - ; - + : DecimalNumeral + ; fragment DecimalNumeral - : '0' | NonZeroDigit Digits? - ; - + : '0' + | NonZeroDigit Digits? + ; fragment Digits - : Digit Digit* - ; - + : Digit Digit* + ; fragment Digit - : '0' | NonZeroDigit - ; - + : '0' + | NonZeroDigit + ; fragment NonZeroDigit - : [1-9] - ; - + : [1-9] + ; FLOAT - : DecimalFloatingPointLiteral - ; - + : DecimalFloatingPointLiteral + ; fragment DecimalFloatingPointLiteral - : Digits '.' Digits? ExponentPart? FloatTypeSuffix? | '.' Digits ExponentPart? FloatTypeSuffix? | Digits ExponentPart FloatTypeSuffix? | Digits FloatTypeSuffix - ; - + : Digits '.' Digits? ExponentPart? FloatTypeSuffix? + | '.' Digits ExponentPart? FloatTypeSuffix? + | Digits ExponentPart FloatTypeSuffix? + | Digits FloatTypeSuffix + ; fragment ExponentPart - : ExponentIndicator SignedInteger - ; - + : ExponentIndicator SignedInteger + ; fragment ExponentIndicator - : [eE] - ; - + : [eE] + ; fragment SignedInteger - : Sign? Digits - ; - + : Sign? Digits + ; fragment Sign - : [+-] - ; - + : [+-] + ; fragment FloatTypeSuffix - : [fFdD] - ; - + : [fFdD] + ; IDENTIFIER - : LetterOrDigit LetterOrDigit* - ; - + : LetterOrDigit LetterOrDigit* + ; fragment Letter - : [a-zA-Z$_] - ; - + : [a-zA-Z$_] + ; fragment LetterOrDigit - : [a-zA-Z0-9$_] - ; + : [a-zA-Z0-9$_] + ; // // Whitespace and comments // WS - : [ \t\r\n\u000C] + -> skip - ; - + : [ \t\r\n\u000C]+ -> skip + ; COMMENT - : '/*' .*? '*/' -> skip - ; - + : '/*' .*? '*/' -> skip + ; LINE_COMMENT - : '--' ~ [\r\n]* -> skip - ; + : '--' ~ [\r\n]* -> skip + ; \ No newline at end of file diff --git a/awk/awk.g4 b/awk/awk.g4 index 06c0b79d00..806b590a09 100644 --- a/awk/awk.g4 +++ b/awk/awk.g4 @@ -19,301 +19,514 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar awk; program - : item_list item? EOF - ; + : item_list item? EOF + ; + item_list - : (item terminator)* - ; + : (item terminator)* + ; + item - : action_ - | pattern action_ - | normal_pattern - | FUNCTION func_name '(' param_list_opt ')' newline_opt action_ - ; + : action_ + | pattern action_ + | normal_pattern + | FUNCTION func_name '(' param_list_opt ')' newline_opt action_ + ; + param_list_opt - : param_list? - ; + : param_list? + ; + param_list - : name (',' name)* - ; + : name (',' name)* + ; + pattern - : normal_pattern - | special_pattern - ; + : normal_pattern + | special_pattern + ; + normal_pattern - : expr (',' newline_opt expr)? - ; + : expr (',' newline_opt expr)? + ; + special_pattern - : BEGIN - | END - ; + : BEGIN + | END + ; + action_ - : '{' newline_opt (terminated_statement_list | unterminated_statement_list)? '}' - ; + : '{' newline_opt (terminated_statement_list | unterminated_statement_list)? '}' + ; + terminator - : terminator NEWLINE - | ';' - | NEWLINE - ; + : terminator NEWLINE + | ';' + | NEWLINE + ; + terminated_statement_list - : terminated_statement+ - ; + : terminated_statement+ + ; + unterminated_statement_list - : terminated_statement* unterminated_statement - ; + : terminated_statement* unterminated_statement + ; + terminated_statement - : action_ newline_opt - | IF '(' expr ')' newline_opt terminated_statement (ELSE newline_opt terminated_statement)? - | WHILE '(' expr ')' newline_opt terminated_statement - | FOR '(' simple_statement_opt ';' expr_opt ';' simple_statement_opt ')' newline_opt terminated_statement - | FOR '(' name IN name ')' newline_opt terminated_statement - | ';' newline_opt - | terminatable_statement (NEWLINE | ';') newline_opt - ; + : action_ newline_opt + | IF '(' expr ')' newline_opt terminated_statement (ELSE newline_opt terminated_statement)? + | WHILE '(' expr ')' newline_opt terminated_statement + | FOR '(' simple_statement_opt ';' expr_opt ';' simple_statement_opt ')' newline_opt terminated_statement + | FOR '(' name IN name ')' newline_opt terminated_statement + | ';' newline_opt + | terminatable_statement (NEWLINE | ';') newline_opt + ; + unterminated_statement - : terminatable_statement - | IF '(' expr ')' newline_opt unterminated_statement - | IF '(' expr ')' newline_opt terminated_statement ELSE newline_opt unterminated_statement - | WHILE '(' expr ')' newline_opt unterminated_statement - | FOR '(' simple_statement_opt ';' expr_opt ';' simple_statement_opt ')' newline_opt unterminated_statement - | FOR '(' name IN name ')' newline_opt unterminated_statement - ; + : terminatable_statement + | IF '(' expr ')' newline_opt unterminated_statement + | IF '(' expr ')' newline_opt terminated_statement ELSE newline_opt unterminated_statement + | WHILE '(' expr ')' newline_opt unterminated_statement + | FOR '(' simple_statement_opt ';' expr_opt ';' simple_statement_opt ')' newline_opt unterminated_statement + | FOR '(' name IN name ')' newline_opt unterminated_statement + ; + terminatable_statement - : simple_statement - | BREAK - | CONTINUE - | NEXT - | EXIT expr_opt - | RETURN expr_opt - | DO newline_opt terminated_statement WHILE '(' expr ')' - ; + : simple_statement + | BREAK + | CONTINUE + | NEXT + | EXIT expr_opt + | RETURN expr_opt + | DO newline_opt terminated_statement WHILE '(' expr ')' + ; + simple_statement_opt - : simple_statement? - ; + : simple_statement? + ; + simple_statement - : DELETE name '[' expr_list ']' - | expr - | print_statement - ; + : DELETE name '[' expr_list ']' + | expr + | print_statement + ; + print_statement - : simple_print_statement output_redirection? - ; + : simple_print_statement output_redirection? + ; + simple_print_statement - : PRINT print_expr_list_opt - | PRINT '(' multiple_expr_list ')' - | PRINTF print_expr_list - | PRINTF '(' multiple_expr_list ')' - ; + : PRINT print_expr_list_opt + | PRINT '(' multiple_expr_list ')' + | PRINTF print_expr_list + | PRINTF '(' multiple_expr_list ')' + ; + output_redirection - : '>' expr - | APPEND expr - | '|' expr - ; + : '>' expr + | APPEND expr + | '|' expr + ; + expr_list_opt - : expr_list? - ; + : expr_list? + ; + expr_list - : expr (',' newline_opt expr)* - ; + : expr (',' newline_opt expr)* + ; + multiple_expr_list - : expr (',' newline_opt expr)+ - ; + : expr (',' newline_opt expr)+ + ; + expr_opt - : expr? - ; + : expr? + ; + expr - : unary_expr - | non_unary_expr - ; + : unary_expr + | non_unary_expr + ; + unary_expr - : ('+' | '-') expr - | unary_expr '^' expr - | unary_expr ('*' | '/' | '%') expr - | unary_expr ('+' | '-') expr - | unary_expr non_unary_expr - | unary_expr ('<' | '>' | LE | NE | EQ | GE) expr - | unary_expr ('~' | NO_MATCH) expr - | unary_expr IN name - | unary_expr AND newline_opt expr - | unary_expr OR newline_opt expr - | unary_expr '?' expr ':' expr - | unary_expr '|' simple_get - ; + : ('+' | '-') expr + | unary_expr '^' expr + | unary_expr ('*' | '/' | '%') expr + | unary_expr ('+' | '-') expr + | unary_expr non_unary_expr + | unary_expr ('<' | '>' | LE | NE | EQ | GE) expr + | unary_expr ('~' | NO_MATCH) expr + | unary_expr IN name + | unary_expr AND newline_opt expr + | unary_expr OR newline_opt expr + | unary_expr '?' expr ':' expr + | unary_expr '|' simple_get + ; + non_unary_expr - : '(' expr ')' - | '!' expr - | non_unary_expr '^' expr - | non_unary_expr ('*' | '/' | '%') expr - | non_unary_expr ('+' | '-') expr - | non_unary_expr non_unary_expr - | non_unary_expr ('<' | '>' | LE | NE | EQ | GE) expr - | non_unary_expr ('~' | NO_MATCH) expr - | non_unary_expr IN name - | '(' multiple_expr_list ')' IN name - | non_unary_expr AND newline_opt expr - | non_unary_expr OR newline_opt expr - | non_unary_expr '?' expr ':' expr - | number - | string - | ere - | lvalue (INCR | DECR)? - | (INCR | DECR) lvalue - | lvalue (POW_ASSIGN | MOD_ASSIGN | MUL_ASSIGN | DIV_ASSIGN | ADD_ASSIGN | SUB_ASSIGN | '=') expr - | func_name '(' expr_list_opt ')' - | builtin_func_name ('(' expr_list_opt ')')? - | simple_get ('<' expr)? - | non_unary_expr '|' simple_get - ; + : '(' expr ')' + | '!' expr + | non_unary_expr '^' expr + | non_unary_expr ('*' | '/' | '%') expr + | non_unary_expr ('+' | '-') expr + | non_unary_expr non_unary_expr + | non_unary_expr ('<' | '>' | LE | NE | EQ | GE) expr + | non_unary_expr ('~' | NO_MATCH) expr + | non_unary_expr IN name + | '(' multiple_expr_list ')' IN name + | non_unary_expr AND newline_opt expr + | non_unary_expr OR newline_opt expr + | non_unary_expr '?' expr ':' expr + | number + | string + | ere + | lvalue (INCR | DECR)? + | (INCR | DECR) lvalue + | lvalue ( + POW_ASSIGN + | MOD_ASSIGN + | MUL_ASSIGN + | DIV_ASSIGN + | ADD_ASSIGN + | SUB_ASSIGN + | '=' + ) expr + | func_name '(' expr_list_opt ')' + | builtin_func_name ('(' expr_list_opt ')')? + | simple_get ('<' expr)? + | non_unary_expr '|' simple_get + ; + print_expr_list_opt - : print_expr_list? - ; + : print_expr_list? + ; + print_expr_list - : print_expr (',' newline_opt print_expr)* - ; + : print_expr (',' newline_opt print_expr)* + ; + print_expr - : unary_print_expr - | non_unary_print_expr - ; + : unary_print_expr + | non_unary_print_expr + ; + unary_print_expr - : ('+' | '-') print_expr - | unary_print_expr '^' print_expr - | unary_print_expr ('*' | '/' | '%') print_expr - | unary_print_expr ('+' | '-') print_expr - | unary_print_expr non_unary_print_expr - | unary_print_expr ('~' | NO_MATCH) print_expr - | unary_print_expr IN name - | unary_print_expr AND newline_opt print_expr - | unary_print_expr OR newline_opt print_expr - | unary_print_expr '?' print_expr ':' print_expr - ; + : ('+' | '-') print_expr + | unary_print_expr '^' print_expr + | unary_print_expr ('*' | '/' | '%') print_expr + | unary_print_expr ('+' | '-') print_expr + | unary_print_expr non_unary_print_expr + | unary_print_expr ('~' | NO_MATCH) print_expr + | unary_print_expr IN name + | unary_print_expr AND newline_opt print_expr + | unary_print_expr OR newline_opt print_expr + | unary_print_expr '?' print_expr ':' print_expr + ; + non_unary_print_expr - : '(' expr ')' - | '!' print_expr - | non_unary_print_expr '^' print_expr - | non_unary_print_expr ('*' | '/' | '%') print_expr - | non_unary_print_expr ('+' | '-') print_expr - | non_unary_print_expr non_unary_print_expr - | non_unary_print_expr ('~' | NO_MATCH) print_expr - | non_unary_print_expr IN name - | '(' multiple_expr_list ')' IN name - | non_unary_print_expr AND newline_opt print_expr - | non_unary_print_expr OR newline_opt print_expr - | non_unary_print_expr '?' print_expr ':' print_expr - | number - | string - | ere - | lvalue (INCR | DECR)? - | (INCR | DECR) lvalue - | lvalue (POW_ASSIGN | MOD_ASSIGN | MUL_ASSIGN | DIV_ASSIGN | ADD_ASSIGN | SUB_ASSIGN | '=') print_expr - | func_name '(' expr_list_opt ')' - | builtin_func_name ('(' expr_list_opt ')')? - ; + : '(' expr ')' + | '!' print_expr + | non_unary_print_expr '^' print_expr + | non_unary_print_expr ('*' | '/' | '%') print_expr + | non_unary_print_expr ('+' | '-') print_expr + | non_unary_print_expr non_unary_print_expr + | non_unary_print_expr ('~' | NO_MATCH) print_expr + | non_unary_print_expr IN name + | '(' multiple_expr_list ')' IN name + | non_unary_print_expr AND newline_opt print_expr + | non_unary_print_expr OR newline_opt print_expr + | non_unary_print_expr '?' print_expr ':' print_expr + | number + | string + | ere + | lvalue (INCR | DECR)? + | (INCR | DECR) lvalue + | lvalue ( + POW_ASSIGN + | MOD_ASSIGN + | MUL_ASSIGN + | DIV_ASSIGN + | ADD_ASSIGN + | SUB_ASSIGN + | '=' + ) print_expr + | func_name '(' expr_list_opt ')' + | builtin_func_name ('(' expr_list_opt ')')? + ; + lvalue - : name ('[' expr_list ']')? - | '$' expr - ; + : name ('[' expr_list ']')? + | '$' expr + ; + simple_get - : GETLINE lvalue? - ; + : GETLINE lvalue? + ; + newline_opt - : NEWLINE* - ; + : NEWLINE* + ; + number - : NUMBER - ; + : NUMBER + ; + string - : STRING - ; + : STRING + ; + ere - : ERE - ; + : ERE + ; + builtin_func_name - : BUILTIN_FUNC_NAME - ; + : BUILTIN_FUNC_NAME + ; + func_name - : WORD - ; + : WORD + ; + name - : WORD - ; - -BEGIN : 'BEGIN' ; -BREAK : 'break' ; -CONTINUE : 'continue' ; -DELETE : 'delete' ; -DO : 'do' ; -ELSE : 'else' ; -END : 'END' ; -EXIT : 'exit' ; -FOR : 'for' ; -FUNCTION : 'function' ; -GETLINE : 'getline' ; -IF : 'if' ; -IN : 'in' ; -NEXT : 'next' ; -PRINT : 'print' ; -PRINTF : 'printf' ; -RETURN : 'return' ; -WHILE : 'while' ; + : WORD + ; + +BEGIN + : 'BEGIN' + ; + +BREAK + : 'break' + ; + +CONTINUE + : 'continue' + ; + +DELETE + : 'delete' + ; + +DO + : 'do' + ; + +ELSE + : 'else' + ; + +END + : 'END' + ; + +EXIT + : 'exit' + ; + +FOR + : 'for' + ; + +FUNCTION + : 'function' + ; + +GETLINE + : 'getline' + ; + +IF + : 'if' + ; + +IN + : 'in' + ; + +NEXT + : 'next' + ; + +PRINT + : 'print' + ; + +PRINTF + : 'printf' + ; + +RETURN + : 'return' + ; + +WHILE + : 'while' + ; + BUILTIN_FUNC_NAME - : 'atan2' - | 'close' - | 'cos' - | 'exp' - | 'gsub' - | 'index' - | 'int' - | 'length' - | 'log' - | 'match' - | 'rand' - | 'sin' - | 'split' - | 'sprintf' - | 'sqrt' - | 'srand' - | 'sub' - | 'substr' - | 'system' - | 'tolower' - | 'toupper' - ; - -ADD_ASSIGN : '+=' ; -AND : '&&' ; -APPEND : '>>' ; -DECR : '--' ; -DIV_ASSIGN : '/=' ; -EQ : '==' ; -GE : '>=' ; -INCR : '++' ; -LE : '<=' ; -MOD_ASSIGN : '%=' ; -MUL_ASSIGN : '*=' ; -NE : '!=' ; -NO_MATCH : '!~' ; -OR : '||' ; -POW_ASSIGN : '^=' ; -SUB_ASSIGN : '-=' ; - -COMMENT : '#' .*? NEWLINE -> channel(HIDDEN) ; -ERE : '/' (~[/\\\r\n] | ESCAPE_SEQUENCE)* '/' ; -ESC_NEWLINE : '\\' NEWLINE -> skip ; -NEWLINE : '\r'? '\n' ; -NUMBER : DECIMAL_CONSTANT | FLOAT_CONSTANT | HEX_CONSTANT | OCTAL_CONSTANT ; -SPACE : [ \t]+ -> skip ; -STRING : '"' (~["\\\r\n] | ESCAPE_SEQUENCE)* '"' ; -WORD : [A-Za-z_] [A-Za-z_0-9]* ; - -fragment DECIMAL_CONSTANT : [1-9] [0-9]* ; -fragment DIGIT_SEQUENCE : [0-9]+ ; -fragment ESCAPE_SEQUENCE : '\\' (HEX_NUMBER | OCTAL_NUMBER | .) ; -fragment EXPONENT_PART : [eE] [+\-]? DIGIT_SEQUENCE ; -fragment FLOAT_CONSTANT : DIGIT_SEQUENCE '.' DIGIT_SEQUENCE EXPONENT_PART? | DIGIT_SEQUENCE EXPONENT_PART ; -fragment HEX_CONSTANT : '0' [xX] [0-9A-Fa-f]+ ; -fragment HEX_NUMBER : [xX] [0-9A-Fa-f] [0-9A-Fa-f]? ; -fragment OCTAL_CONSTANT : '0' [0-7]* ; -fragment OCTAL_NUMBER : [0-7] [0-7]? [0-7]? ; + : 'atan2' + | 'close' + | 'cos' + | 'exp' + | 'gsub' + | 'index' + | 'int' + | 'length' + | 'log' + | 'match' + | 'rand' + | 'sin' + | 'split' + | 'sprintf' + | 'sqrt' + | 'srand' + | 'sub' + | 'substr' + | 'system' + | 'tolower' + | 'toupper' + ; + +ADD_ASSIGN + : '+=' + ; + +AND + : '&&' + ; + +APPEND + : '>>' + ; + +DECR + : '--' + ; + +DIV_ASSIGN + : '/=' + ; + +EQ + : '==' + ; + +GE + : '>=' + ; + +INCR + : '++' + ; + +LE + : '<=' + ; + +MOD_ASSIGN + : '%=' + ; + +MUL_ASSIGN + : '*=' + ; + +NE + : '!=' + ; + +NO_MATCH + : '!~' + ; + +OR + : '||' + ; + +POW_ASSIGN + : '^=' + ; + +SUB_ASSIGN + : '-=' + ; + +COMMENT + : '#' .*? NEWLINE -> channel(HIDDEN) + ; + +ERE + : '/' (~[/\\\r\n] | ESCAPE_SEQUENCE)* '/' + ; + +ESC_NEWLINE + : '\\' NEWLINE -> skip + ; + +NEWLINE + : '\r'? '\n' + ; + +NUMBER + : DECIMAL_CONSTANT + | FLOAT_CONSTANT + | HEX_CONSTANT + | OCTAL_CONSTANT + ; + +SPACE + : [ \t]+ -> skip + ; + +STRING + : '"' (~["\\\r\n] | ESCAPE_SEQUENCE)* '"' + ; + +WORD + : [A-Za-z_] [A-Za-z_0-9]* + ; + +fragment DECIMAL_CONSTANT + : [1-9] [0-9]* + ; + +fragment DIGIT_SEQUENCE + : [0-9]+ + ; + +fragment ESCAPE_SEQUENCE + : '\\' (HEX_NUMBER | OCTAL_NUMBER | .) + ; + +fragment EXPONENT_PART + : [eE] [+\-]? DIGIT_SEQUENCE + ; + +fragment FLOAT_CONSTANT + : DIGIT_SEQUENCE '.' DIGIT_SEQUENCE EXPONENT_PART? + | DIGIT_SEQUENCE EXPONENT_PART + ; + +fragment HEX_CONSTANT + : '0' [xX] [0-9A-Fa-f]+ + ; + +fragment HEX_NUMBER + : [xX] [0-9A-Fa-f] [0-9A-Fa-f]? + ; + +fragment OCTAL_CONSTANT + : '0' [0-7]* + ; + +fragment OCTAL_NUMBER + : [0-7] [0-7]? [0-7]? + ; \ No newline at end of file diff --git a/b/b.g4 b/b/b.g4 index f33850e522..0ea5e77aa0 100644 --- a/b/b.g4 +++ b/b/b.g4 @@ -30,193 +30,190 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar b; program - : definition* EOF - ; + : definition* EOF + ; definition - : name constant? (ival (',' ival)*)* ';' - | name '(' (name (',' name)*)? ')' statement - ; + : name constant? (ival (',' ival)*)* ';' + | name '(' (name (',' name)*)? ')' statement + ; ival - : constant - | name - ; + : constant + | name + ; statement - : externsmt - | autosmt - | name ':' statement - | casestmt - | blockstmt - | ifstmt - | whilestmt - | switchstmt - | gotostmt - | returnstmt - | expressionstmt - | nullstmt - ; + : externsmt + | autosmt + | name ':' statement + | casestmt + | blockstmt + | ifstmt + | whilestmt + | switchstmt + | gotostmt + | returnstmt + | expressionstmt + | nullstmt + ; nullstmt - : ';' - ; + : ';' + ; expressionstmt - : rvalue ';' - ; + : rvalue ';' + ; blockstmt - : '{' statement* '}' - ; + : '{' statement* '}' + ; returnstmt - : 'return' ('(' rvalue ')')? ';' - ; + : 'return' ('(' rvalue ')')? ';' + ; gotostmt - : 'goto' rvalue ';' - ; + : 'goto' rvalue ';' + ; switchstmt - : 'switch' rvalue statement - ; + : 'switch' rvalue statement + ; whilestmt - : 'while' '(' rvalue ')' statement - ; + : 'while' '(' rvalue ')' statement + ; ifstmt - : 'if' '(' rvalue ')' statement ('else' statement)? - ; + : 'if' '(' rvalue ')' statement ('else' statement)? + ; casestmt - : 'case' constant ':' statement - ; + : 'case' constant ':' statement + ; externsmt - : 'extrn' name (',' name)* ';' - ; + : 'extrn' name (',' name)* ';' + ; autosmt - : 'auto' name constant? (',' name constant?)* ';' - ; + : 'auto' name constant? (',' name constant?)* ';' + ; rvalue - : expression - | comparison - | ternary - | assignment - ; + : expression + | comparison + | ternary + | assignment + ; ternary - : expression '?' rvalue ':' rvalue - ; + : expression '?' rvalue ':' rvalue + ; comparison - : expression binary rvalue - ; + : expression binary rvalue + ; assignment - : name assign rvalue - ; + : name assign rvalue + ; expression - : '(' rvalue ')' - | name - | constant - | incdec name - | name incdec - | unary rvalue - | '&' name - | functioninvocation - ; + : '(' rvalue ')' + | name + | constant + | incdec name + | name incdec + | unary rvalue + | '&' name + | functioninvocation + ; functioninvocation - : name '(' functionparameters? ')' - ; + : name '(' functionparameters? ')' + ; functionparameters - : rvalue (',' rvalue)* - ; + : rvalue (',' rvalue)* + ; assign - : '=' binary? - ; + : '=' binary? + ; incdec - : '++' - | '--' - ; + : '++' + | '--' + ; unary - : '-' - | '!' - ; + : '-' + | '!' + ; binary - : '|' - | '&' - | '==' - | '!=' - | '<' - | '<=' - | '>' - | '>=' - | '<<' - | '>>' - | '-' - | '+' - | '%' - | '*' - | '/' - ; + : '|' + | '&' + | '==' + | '!=' + | '<' + | '<=' + | '>' + | '>=' + | '<<' + | '>>' + | '-' + | '+' + | '%' + | '*' + | '/' + ; lvalue - : name - | '*' rvalue - | rvalue '[' rvalue ']' - ; + : name + | '*' rvalue + | rvalue '[' rvalue ']' + ; constant - : INT - | STRING1 - | STRING2 - ; + : INT + | STRING1 + | STRING2 + ; name - : NAME - ; - + : NAME + ; NAME - : [a-zA-Z] [a-zA-Z0-9_]* - ; - + : [a-zA-Z] [a-zA-Z0-9_]* + ; INT - : [0-9] + - ; - + : [0-9]+ + ; STRING1 - : '"' ~ ["\r\n]* '"' - ; - + : '"' ~ ["\r\n]* '"' + ; STRING2 - : '\'' ~ ['\r\n]* '\'' - ; - + : '\'' ~ ['\r\n]* '\'' + ; BLOCKCOMMENT - : '/*' .*? '*/' -> skip - ; - + : '/*' .*? '*/' -> skip + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/basic/jvmBasic.g4 b/basic/jvmBasic.g4 index f7adb80a52..0332002eff 100644 --- a/basic/jvmBasic.g4 +++ b/basic/jvmBasic.g4 @@ -1,6 +1,11 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar jvmBasic; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} /* [The "BSD licence"] @@ -28,1115 +33,1010 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/// a program is a collection of lines +*/ // a program is a collection of lines prog - : line + EOF - ; + : line+ EOF + ; // a line starts with an INT line - : linenumber (amprstmt (COLON amprstmt?)* | COMMENT | REM) - ; + : linenumber (amprstmt (COLON amprstmt?)* | COMMENT | REM) + ; amperoper - : AMPERSAND - ; + : AMPERSAND + ; linenumber - : NUMBER - ; + : NUMBER + ; amprstmt - : amperoper? statement - | COMMENT - | REM - ; + : amperoper? statement + | COMMENT + | REM + ; statement - : CLS | LOAD | SAVE | TRACE | NOTRACE | FLASH | INVERSE | GR | NORMAL | SHLOAD | CLEAR | RUN | STOP | TEXT | HOME | HGR | HGR2 - | endstmt - | returnstmt - | restorestmt - | amptstmt - | popstmt - | liststmt - | storestmt - | getstmt - | recallstmt - | nextstmt - | instmt - | prstmt - | onerrstmt - | hlinstmt - | vlinstmt - | colorstmt - | speedstmt - | scalestmt - | rotstmt - | hcolorstmt - | himemstmt - | lomemstmt - | printstmt1 - | pokestmt - | plotstmt - | ongotostmt - | ongosubstmt - | ifstmt - | forstmt1 - | forstmt2 - | inputstmt - | tabstmt - | dimstmt - | gotostmt - | gosubstmt - | callstmt - | readstmt - | hplotstmt - | vplotstmt - | vtabstmnt - | htabstmnt - | waitstmt - | datastmt - | xdrawstmt - | drawstmt - | defstmt - | letstmt - | includestmt - ; + : CLS + | LOAD + | SAVE + | TRACE + | NOTRACE + | FLASH + | INVERSE + | GR + | NORMAL + | SHLOAD + | CLEAR + | RUN + | STOP + | TEXT + | HOME + | HGR + | HGR2 + | endstmt + | returnstmt + | restorestmt + | amptstmt + | popstmt + | liststmt + | storestmt + | getstmt + | recallstmt + | nextstmt + | instmt + | prstmt + | onerrstmt + | hlinstmt + | vlinstmt + | colorstmt + | speedstmt + | scalestmt + | rotstmt + | hcolorstmt + | himemstmt + | lomemstmt + | printstmt1 + | pokestmt + | plotstmt + | ongotostmt + | ongosubstmt + | ifstmt + | forstmt1 + | forstmt2 + | inputstmt + | tabstmt + | dimstmt + | gotostmt + | gosubstmt + | callstmt + | readstmt + | hplotstmt + | vplotstmt + | vtabstmnt + | htabstmnt + | waitstmt + | datastmt + | xdrawstmt + | drawstmt + | defstmt + | letstmt + | includestmt + ; vardecl - : var_ (LPAREN exprlist RPAREN)* - ; + : var_ (LPAREN exprlist RPAREN)* + ; printstmt1 - : (PRINT | QUESTION) printlist? - ; + : (PRINT | QUESTION) printlist? + ; printlist - : expression ((COMMA | SEMICOLON) expression?)* - ; + : expression ((COMMA | SEMICOLON) expression?)* + ; getstmt - : GET exprlist - ; + : GET exprlist + ; letstmt - : LET? variableassignment - ; + : LET? variableassignment + ; variableassignment - : vardecl EQ exprlist - ; + : vardecl EQ exprlist + ; relop - : GTE - | GT EQ - | EQ GT - | LTE - | LT EQ - | EQ LT - | neq - | EQ - | GT - | LT - ; + : GTE + | GT EQ + | EQ GT + | LTE + | LT EQ + | EQ LT + | neq + | EQ + | GT + | LT + ; neq - : LT GT - ; + : LT GT + ; ifstmt - : IF expression THEN? (statement | linenumber) - ; + : IF expression THEN? (statement | linenumber) + ; // for stmt 1 puts the for-next on one line forstmt1 - : FOR vardecl EQ expression TO expression (STEP expression)? (statement NEXT vardecl?)? - ; + : FOR vardecl EQ expression TO expression (STEP expression)? (statement NEXT vardecl?)? + ; // for stmt 2 puts the for, the statment, and the next on 3 lines. It needs "nextstmt" forstmt2 - : FOR vardecl EQ expression TO expression (STEP expression)? - ; + : FOR vardecl EQ expression TO expression (STEP expression)? + ; nextstmt - : NEXT (vardecl (',' vardecl)*)? - ; + : NEXT (vardecl (',' vardecl)*)? + ; inputstmt - : INPUT (STRINGLITERAL (COMMA | SEMICOLON))? varlist - ; + : INPUT (STRINGLITERAL (COMMA | SEMICOLON))? varlist + ; readstmt - : READ varlist - ; + : READ varlist + ; dimstmt - : DIM varlist - ; + : DIM varlist + ; gotostmt - : GOTO linenumber - ; + : GOTO linenumber + ; gosubstmt - : GOSUB expression - ; + : GOSUB expression + ; pokestmt - : POKE expression COMMA expression - ; + : POKE expression COMMA expression + ; callstmt - : CALL exprlist - ; + : CALL exprlist + ; hplotstmt - : HPLOT (expression COMMA expression)? (TO expression COMMA expression)* - ; + : HPLOT (expression COMMA expression)? (TO expression COMMA expression)* + ; vplotstmt - : VPLOT (expression COMMA expression)? (TO expression COMMA expression)* - ; + : VPLOT (expression COMMA expression)? (TO expression COMMA expression)* + ; plotstmt - : PLOT expression COMMA expression - ; + : PLOT expression COMMA expression + ; ongotostmt - : ON expression GOTO linenumber (COMMA linenumber)* - ; + : ON expression GOTO linenumber (COMMA linenumber)* + ; ongosubstmt - : ON expression GOSUB linenumber (COMMA linenumber)* - ; + : ON expression GOSUB linenumber (COMMA linenumber)* + ; vtabstmnt - : VTAB expression - ; + : VTAB expression + ; htabstmnt - : HTAB expression - ; + : HTAB expression + ; himemstmt - : HIMEM COLON expression - ; + : HIMEM COLON expression + ; lomemstmt - : LOMEM COLON expression - ; + : LOMEM COLON expression + ; datastmt - : DATA datum (COMMA datum?)* - ; + : DATA datum (COMMA datum?)* + ; datum - : number - | STRINGLITERAL - ; + : number + | STRINGLITERAL + ; waitstmt - : WAIT expression COMMA expression (COMMA expression)? - ; + : WAIT expression COMMA expression (COMMA expression)? + ; xdrawstmt - : XDRAW expression (AT expression COMMA expression)? - ; + : XDRAW expression (AT expression COMMA expression)? + ; drawstmt - : DRAW expression (AT expression COMMA expression)? - ; + : DRAW expression (AT expression COMMA expression)? + ; defstmt - : DEF FN? var_ LPAREN var_ RPAREN EQ expression - ; + : DEF FN? var_ LPAREN var_ RPAREN EQ expression + ; tabstmt - : TAB LPAREN expression RPAREN - ; + : TAB LPAREN expression RPAREN + ; speedstmt - : SPEED EQ expression - ; + : SPEED EQ expression + ; rotstmt - : ROT EQ expression - ; + : ROT EQ expression + ; scalestmt - : SCALE EQ expression - ; + : SCALE EQ expression + ; colorstmt - : COLOR EQ expression - ; + : COLOR EQ expression + ; hcolorstmt - : HCOLOR EQ expression - ; + : HCOLOR EQ expression + ; hlinstmt - : HLIN expression COMMA expression AT expression - ; + : HLIN expression COMMA expression AT expression + ; vlinstmt - : VLIN expression COMMA expression AT expression - ; + : VLIN expression COMMA expression AT expression + ; onerrstmt - : ONERR GOTO linenumber - ; + : ONERR GOTO linenumber + ; prstmt - : PRNUMBER NUMBER - ; + : PRNUMBER NUMBER + ; instmt - : INNUMBER NUMBER - ; + : INNUMBER NUMBER + ; storestmt - : STORE vardecl - ; + : STORE vardecl + ; recallstmt - : RECALL vardecl - ; + : RECALL vardecl + ; liststmt - : LIST expression? - ; + : LIST expression? + ; popstmt - : POP (expression COMMA expression)? - ; + : POP (expression COMMA expression)? + ; amptstmt - : AMPERSAND expression - ; + : AMPERSAND expression + ; includestmt - : INCLUDE expression - ; + : INCLUDE expression + ; endstmt - : END - ; + : END + ; returnstmt - : RETURN - ; + : RETURN + ; restorestmt - : RESTORE - ; + : RESTORE + ; // expressions and such number - : ('+' | '-')? (NUMBER | FLOAT) - ; + : ('+' | '-')? (NUMBER | FLOAT) + ; func_ - : STRINGLITERAL - | number - | tabfunc - | vardecl - | chrfunc - | sqrfunc - | lenfunc - | strfunc - | ascfunc - | scrnfunc - | midfunc - | pdlfunc - | peekfunc - | intfunc - | spcfunc - | frefunc - | posfunc - | usrfunc - | leftfunc - | valfunc - | rightfunc - | fnfunc - | sinfunc - | cosfunc - | tanfunc - | atnfunc - | rndfunc - | sgnfunc - | expfunc - | logfunc - | absfunc - | LPAREN expression RPAREN - ; + : STRINGLITERAL + | number + | tabfunc + | vardecl + | chrfunc + | sqrfunc + | lenfunc + | strfunc + | ascfunc + | scrnfunc + | midfunc + | pdlfunc + | peekfunc + | intfunc + | spcfunc + | frefunc + | posfunc + | usrfunc + | leftfunc + | valfunc + | rightfunc + | fnfunc + | sinfunc + | cosfunc + | tanfunc + | atnfunc + | rndfunc + | sgnfunc + | expfunc + | logfunc + | absfunc + | LPAREN expression RPAREN + ; signExpression - : NOT? (PLUS | MINUS)? func_ - ; + : NOT? (PLUS | MINUS)? func_ + ; exponentExpression - : signExpression (EXPONENT signExpression)* - ; + : signExpression (EXPONENT signExpression)* + ; multiplyingExpression - : exponentExpression ((TIMES | DIV) exponentExpression)* - ; + : exponentExpression ((TIMES | DIV) exponentExpression)* + ; addingExpression - : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* - ; + : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* + ; relationalExpression - : addingExpression (relop addingExpression)? - ; + : addingExpression (relop addingExpression)? + ; expression - : func_ - | relationalExpression ((AND | OR) relationalExpression)* - ; + : func_ + | relationalExpression ((AND | OR) relationalExpression)* + ; // lists var_ - : varname varsuffix? - ; + : varname varsuffix? + ; varname - : LETTERS (LETTERS | NUMBER)* - ; + : LETTERS (LETTERS | NUMBER)* + ; varsuffix - : DOLLAR | PERCENT - ; + : DOLLAR + | PERCENT + ; varlist - : vardecl (COMMA vardecl)* - ; + : vardecl (COMMA vardecl)* + ; exprlist - : expression (COMMA expression)* - ; + : expression (COMMA expression)* + ; // functions sqrfunc - : SQR LPAREN expression RPAREN - ; + : SQR LPAREN expression RPAREN + ; chrfunc - : CHR LPAREN expression RPAREN - ; + : CHR LPAREN expression RPAREN + ; lenfunc - : LEN LPAREN expression RPAREN - ; + : LEN LPAREN expression RPAREN + ; ascfunc - : ASC LPAREN expression RPAREN - ; + : ASC LPAREN expression RPAREN + ; midfunc - : MID LPAREN expression COMMA expression COMMA expression RPAREN - ; + : MID LPAREN expression COMMA expression COMMA expression RPAREN + ; pdlfunc - : PDL LPAREN expression RPAREN - ; + : PDL LPAREN expression RPAREN + ; peekfunc - : PEEK LPAREN expression RPAREN - ; + : PEEK LPAREN expression RPAREN + ; intfunc - : INTF LPAREN expression RPAREN - ; + : INTF LPAREN expression RPAREN + ; spcfunc - : SPC LPAREN expression RPAREN - ; + : SPC LPAREN expression RPAREN + ; frefunc - : FRE LPAREN expression RPAREN - ; + : FRE LPAREN expression RPAREN + ; posfunc - : POS LPAREN expression RPAREN - ; + : POS LPAREN expression RPAREN + ; usrfunc - : USR LPAREN expression RPAREN - ; + : USR LPAREN expression RPAREN + ; leftfunc - : LEFT LPAREN expression COMMA expression RPAREN - ; + : LEFT LPAREN expression COMMA expression RPAREN + ; rightfunc - : RIGHT LPAREN expression COMMA expression RPAREN - ; + : RIGHT LPAREN expression COMMA expression RPAREN + ; strfunc - : STR LPAREN expression RPAREN - ; + : STR LPAREN expression RPAREN + ; fnfunc - : FN var_ LPAREN expression RPAREN - ; + : FN var_ LPAREN expression RPAREN + ; valfunc - : VAL LPAREN expression RPAREN - ; + : VAL LPAREN expression RPAREN + ; scrnfunc - : SCRN LPAREN expression COMMA expression RPAREN - ; + : SCRN LPAREN expression COMMA expression RPAREN + ; sinfunc - : SIN LPAREN expression RPAREN - ; + : SIN LPAREN expression RPAREN + ; cosfunc - : COS LPAREN expression RPAREN - ; + : COS LPAREN expression RPAREN + ; tanfunc - : TAN LPAREN expression RPAREN - ; + : TAN LPAREN expression RPAREN + ; atnfunc - : ATN LPAREN expression RPAREN - ; + : ATN LPAREN expression RPAREN + ; rndfunc - : RND LPAREN expression RPAREN - ; + : RND LPAREN expression RPAREN + ; sgnfunc - : SGN LPAREN expression RPAREN - ; + : SGN LPAREN expression RPAREN + ; expfunc - : EXP LPAREN expression RPAREN - ; + : EXP LPAREN expression RPAREN + ; logfunc - : LOG LPAREN expression RPAREN - ; + : LOG LPAREN expression RPAREN + ; absfunc - : ABS LPAREN expression RPAREN - ; + : ABS LPAREN expression RPAREN + ; tabfunc - : TAB LPAREN expression RPAREN - ; - + : TAB LPAREN expression RPAREN + ; DOLLAR - : '$' - ; - + : '$' + ; PERCENT - : '%' - ; - + : '%' + ; RETURN - : 'RETURN' - ; - + : 'RETURN' + ; PRINT - : 'PRINT' - ; - + : 'PRINT' + ; GOTO - : 'GOTO' - ; - + : 'GOTO' + ; GOSUB - : 'GOSUB' - ; - + : 'GOSUB' + ; IF - : 'IF' - ; - + : 'IF' + ; NEXT - : 'NEXT' - ; - + : 'NEXT' + ; THEN - : 'THEN' - ; - + : 'THEN' + ; REM - : 'REM' - ; - + : 'REM' + ; CHR - : 'CHR$' - ; - + : 'CHR$' + ; MID - : 'MID$' - ; - + : 'MID$' + ; LEFT - : 'LEFT$' - ; - + : 'LEFT$' + ; RIGHT - : 'RIGHT$' - ; - + : 'RIGHT$' + ; STR - : 'STR$' - ; - + : 'STR$' + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; TIMES - : '*' - ; - + : '*' + ; DIV - : '/' - ; - + : '/' + ; CLEAR - : 'CLEAR' - ; - + : 'CLEAR' + ; GTE - : '>: ' - ; - + : '>: ' + ; LTE - : '<: ' - ; - + : '<: ' + ; GT - : '>' - ; - + : '>' + ; LT - : '<' - ; - + : '<' + ; COMMA - : ',' - ; - + : ',' + ; LIST - : 'LIST' - ; - + : 'LIST' + ; RUN - : 'RUN' - ; - + : 'RUN' + ; END - : 'END' - ; - + : 'END' + ; LET - : 'LET' - ; - + : 'LET' + ; EQ - : '=' - ; - + : '=' + ; FOR - : 'FOR' - ; - + : 'FOR' + ; TO - : 'TO' - ; - + : 'TO' + ; STEP - : 'STEP' - ; - + : 'STEP' + ; INPUT - : 'INPUT' - ; - + : 'INPUT' + ; SEMICOLON - : ';' - ; - + : ';' + ; DIM - : 'DIM' - ; - + : 'DIM' + ; SQR - : 'SQR' - ; - + : 'SQR' + ; COLON - : ':' - ; - + : ':' + ; TEXT - : 'TEXT' - ; - + : 'TEXT' + ; HGR - : 'HGR' - ; - + : 'HGR' + ; HGR2 - : 'HGR2' - ; - + : 'HGR2' + ; LEN - : 'LEN' - ; - + : 'LEN' + ; CALL - : 'CALL' - ; - + : 'CALL' + ; ASC - : 'ASC' - ; - + : 'ASC' + ; HPLOT - : 'HPLOT' - ; - + : 'HPLOT' + ; VPLOT - : 'VPLOT' - ; - + : 'VPLOT' + ; PRNUMBER - : 'PR#' - ; - + : 'PR#' + ; INNUMBER - : 'IN#' - ; - + : 'IN#' + ; VTAB - : 'VTAB' - ; - + : 'VTAB' + ; HTAB - : 'HTAB' - ; - + : 'HTAB' + ; HOME - : 'HOME' - ; - + : 'HOME' + ; ON - : 'ON' - ; - + : 'ON' + ; PDL - : 'PDL' - ; - + : 'PDL' + ; PLOT - : 'PLOT' - ; - + : 'PLOT' + ; PEEK - : 'PEEK' - ; - + : 'PEEK' + ; POKE - : 'POKE' - ; - + : 'POKE' + ; INTF - : 'INT' - ; - + : 'INT' + ; STOP - : 'STOP' - ; - + : 'STOP' + ; HIMEM - : 'HIMEM' - ; - + : 'HIMEM' + ; LOMEM - : 'LOMEM' - ; - + : 'LOMEM' + ; FLASH - : 'FLASH' - ; - + : 'FLASH' + ; INVERSE - : 'INVERSE' - ; - + : 'INVERSE' + ; NORMAL - : 'NORMAL' - ; - + : 'NORMAL' + ; ONERR - : 'ONERR' - ; - + : 'ONERR' + ; SPC - : 'SPC' - ; - + : 'SPC' + ; FRE - : 'FRE' - ; - + : 'FRE' + ; POS - : 'POS' - ; - + : 'POS' + ; USR - : 'USR' - ; - + : 'USR' + ; TRACE - : 'TRACE' - ; - + : 'TRACE' + ; NOTRACE - : 'NOTRACE' - ; - + : 'NOTRACE' + ; AND - : 'AND' - ; - + : 'AND' + ; OR - : 'OR' - ; - + : 'OR' + ; DATA - : 'DATA' - ; - + : 'DATA' + ; WAIT - : 'WAIT' - ; - + : 'WAIT' + ; READ - : 'READ' - ; - + : 'READ' + ; XDRAW - : 'XDRAW' - ; - + : 'XDRAW' + ; DRAW - : 'DRAW' - ; - + : 'DRAW' + ; AT - : 'AT' - ; - + : 'AT' + ; DEF - : 'DEF' - ; - + : 'DEF' + ; FN - : 'FN' - ; - + : 'FN' + ; VAL - : 'VAL' - ; - + : 'VAL' + ; TAB - : 'TAB' - ; - + : 'TAB' + ; SPEED - : 'SPEED' - ; - + : 'SPEED' + ; ROT - : 'ROT' - ; - + : 'ROT' + ; SCALE - : 'SCALE' - ; - + : 'SCALE' + ; COLOR - : 'COLOR' - ; - + : 'COLOR' + ; HCOLOR - : 'HCOLOR' - ; - + : 'HCOLOR' + ; HLIN - : 'HLIN' - ; - + : 'HLIN' + ; VLIN - : 'VLIN' - ; - + : 'VLIN' + ; SCRN - : 'SCRN' - ; - + : 'SCRN' + ; POP - : 'POP' - ; - + : 'POP' + ; SHLOAD - : 'SHLOAD' - ; - + : 'SHLOAD' + ; SIN - : 'SIN' - ; - + : 'SIN' + ; COS - : 'COS' - ; - + : 'COS' + ; TAN - : 'TAN' - ; - + : 'TAN' + ; ATN - : 'ATN' - ; - + : 'ATN' + ; RND - : 'RND' - ; - + : 'RND' + ; SGN - : 'SGN' - ; - + : 'SGN' + ; EXP - : 'EXP' - ; - + : 'EXP' + ; LOG - : 'LOG' - ; - + : 'LOG' + ; ABS - : 'ABS' - ; - + : 'ABS' + ; STORE - : 'STORE' - ; - + : 'STORE' + ; RECALL - : 'RECALL' - ; - + : 'RECALL' + ; GET - : 'GET' - ; - + : 'GET' + ; EXPONENT - : '^' - ; - + : '^' + ; AMPERSAND - : '&' - ; - + : '&' + ; GR - : 'GR' - ; - + : 'GR' + ; NOT - : 'NOT' - ; - + : 'NOT' + ; RESTORE - : 'RESTORE' - ; - + : 'RESTORE' + ; SAVE - : 'SAVE' - ; - + : 'SAVE' + ; LOAD - : 'LOAD' - ; - + : 'LOAD' + ; QUESTION - : '?' - ; - + : '?' + ; INCLUDE - : 'INCLUDE' - ; - + : 'INCLUDE' + ; CLS - : 'CLS' - ; - + : 'CLS' + ; COMMENT - : REM ~ [\r\n]* - ; - + : REM ~ [\r\n]* + ; STRINGLITERAL - : '"' ~ ["\r\n]* '"' - ; - + : '"' ~ ["\r\n]* '"' + ; LETTERS - : ('A' .. 'Z') + - ; - + : ('A' .. 'Z')+ + ; NUMBER - : ('0' .. '9') + ('E' NUMBER)* - ; - + : ('0' .. '9')+ ('E' NUMBER)* + ; FLOAT - : ('0' .. '9')* '.' ('0' .. '9') + ('E' ('0' .. '9') +)* - ; - + : ('0' .. '9')* '.' ('0' .. '9')+ ('E' ('0' .. '9')+)* + ; WS - : [ \r\n\t] + -> channel (HIDDEN) - ; + : [ \r\n\t]+ -> channel (HIDDEN) + ; \ No newline at end of file diff --git a/bcl/bcl.g4 b/bcl/bcl.g4 index 330d75450e..115a43639b 100644 --- a/bcl/bcl.g4 +++ b/bcl/bcl.g4 @@ -29,19 +29,22 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar bcl; bcl - : term* EOF - ; + : term* EOF + ; term - : '00' - | '01' - | '1' term term - ; + : '00' + | '01' + | '1' term term + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/bcpl/bcplLexer.g4 b/bcpl/bcplLexer.g4 index 562862ce0f..b18edd7353 100644 --- a/bcpl/bcplLexer.g4 +++ b/bcpl/bcplLexer.g4 @@ -1,142 +1,146 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar bcplLexer; -ACEQ : '&:=' ; -AND : '&' ; -ARROW : '->' ; -AT : '@' ; -BANG : '!' ; -CB : '$)' | '}'; -CC : '::' ; -CEQ : ':=' ; -COLON : ':' ; -COMMA : ',' ; -DASH: '-' ; -DD : '..' ; -DOT : '.' ; -EQ : '=' ; -Eqv : 'EQV' ; -EQVCEQ : 'EQV:=' ; -GE : '>=' ; -GG : '>>' ; -GT : '>' ; -KABS : 'ABS' ; -KAND : 'AND' ; -KBE : 'BE' ; -KBREAK : 'BREAK' ; -KBY : 'BY' ; -KCASE : 'CASE' ; -KDEFAULT : 'DEFAULT' ; -KDO : 'DO' ; -KELSE : 'ELSE' ; -KENDCASE : 'ENDCASE' ; -KEQ : 'EQ' ; -KEVERY : 'EVERY' ; -KEXIT : 'EXIT' ; -KFALSE : 'FALSE' ; -KFINISH : 'FINISH' ; -KFIX : 'FIX' ; -KFLOAT : 'FLOAT' ; -KFLT : 'FLT' ; -KFOR : 'FOR' ; -KGET : 'GET' ; -KGLOBAL : 'GLOBAL' ; -KGOTO : 'GOTO' ; -KIF : 'IF' ; -KINTO : 'INTO' ; -KLET : 'LET' ; -KLOOP : 'LOOP' ; -KMANIFEST : 'MANIFEST' ; -KMATCH : 'MATCH' ; -KMOD : 'MOD' ; -KNE : 'NE' ; -KNEXT : 'NEXT' ; -KNOT : 'NOT' ; -KOF : 'OF' ; -KOR : 'OR' ; -KREPEAT : 'REPEAT' ; -KREPEATUNTIL : 'REPEATUNTIL' ; -KREPEATWHILE : 'REPEATWHILE' ; -KRESULTS : 'RESULTIS' ; -KRETURN : 'RETURN' ; -KSECTION : 'SECTION' ; -KSLCT : 'SLCT' ; -KSTATIC : 'STATIC' ; -KSWITCHON : 'SWITCHON' ; -KTEST : 'TEST' ; -KTHEN : 'THEN' ; -KTO : 'TO' ; -KTRUE : 'TRUE' ; -KUNLESS : 'UNLESS' ; -KUNTIL : 'UNTIL' ; -KVALOF : 'VALOF' ; -KVEC : 'VEC' ; -KWHILE : 'WHILE' ; -KXOR : 'XOR' ; -LBR : '[' ; -LE : '<=' ; -LL : '<<' ; -LLCEQ : '<<:=' ; -LP : '(' ; -LT : '<' ; -MODCEQ : 'MOD:=' ; -NCEQ : '~:=' ; -NE : '~=' ; -Neqv : 'NEQV' ; -NEQVCEQ : 'NEQV:=' ; -OB : '$(' | '{'; -PABS : '#ABS' ; -PARROW : '#->' ; -PCEQ : '#:=' ; -PDD : '#..' ; -PE : '#=' ; -PERCENT : '%' ; -PGE : '#>=' ; -PGT : '#>' ; -PLCEQ : '+:=' ; -PLE : '#<=' ; -PLT : '#<' ; -PLUS : '+' ; -PMINUS : '#-' ; -PMOD : '#MOD' ; -PMODCEQ : '#MOD:=' ; -PNCEQ : '#~:=' ; -PNE : '#~=' ; -POP : '#(' ; -PPCEQ : '#+:=' ; -PPLUS : '#+' ; -PREM : '#REM' ; -PSCEQ : '#*:=' ; -PSLCEQ : '#/:=' ; -PSTAR : '#*' ; -QM : '?' ; -RBR : ']' ; -REM : 'REM' ; -RP : ')' ; -RRCEQ : '>>:=' ; -SCEQ : '*:=' ; -SEMI : ';' ; -SLASH: '/' ; -SLCEQ : '/:=' ; -STAR: '*' ; -Table : 'TABLE' ; -TILDE : '~' ; -VBAR : '|' ; -VCEQ : '|:=' ; -XORCEQ : 'XOR:=' ; +ACEQ : '&:='; +AND : '&'; +ARROW : '->'; +AT : '@'; +BANG : '!'; +CB : '$)' | '}'; +CC : '::'; +CEQ : ':='; +COLON : ':'; +COMMA : ','; +DASH : '-'; +DD : '..'; +DOT : '.'; +EQ : '='; +Eqv : 'EQV'; +EQVCEQ : 'EQV:='; +GE : '>='; +GG : '>>'; +GT : '>'; +KABS : 'ABS'; +KAND : 'AND'; +KBE : 'BE'; +KBREAK : 'BREAK'; +KBY : 'BY'; +KCASE : 'CASE'; +KDEFAULT : 'DEFAULT'; +KDO : 'DO'; +KELSE : 'ELSE'; +KENDCASE : 'ENDCASE'; +KEQ : 'EQ'; +KEVERY : 'EVERY'; +KEXIT : 'EXIT'; +KFALSE : 'FALSE'; +KFINISH : 'FINISH'; +KFIX : 'FIX'; +KFLOAT : 'FLOAT'; +KFLT : 'FLT'; +KFOR : 'FOR'; +KGET : 'GET'; +KGLOBAL : 'GLOBAL'; +KGOTO : 'GOTO'; +KIF : 'IF'; +KINTO : 'INTO'; +KLET : 'LET'; +KLOOP : 'LOOP'; +KMANIFEST : 'MANIFEST'; +KMATCH : 'MATCH'; +KMOD : 'MOD'; +KNE : 'NE'; +KNEXT : 'NEXT'; +KNOT : 'NOT'; +KOF : 'OF'; +KOR : 'OR'; +KREPEAT : 'REPEAT'; +KREPEATUNTIL : 'REPEATUNTIL'; +KREPEATWHILE : 'REPEATWHILE'; +KRESULTS : 'RESULTIS'; +KRETURN : 'RETURN'; +KSECTION : 'SECTION'; +KSLCT : 'SLCT'; +KSTATIC : 'STATIC'; +KSWITCHON : 'SWITCHON'; +KTEST : 'TEST'; +KTHEN : 'THEN'; +KTO : 'TO'; +KTRUE : 'TRUE'; +KUNLESS : 'UNLESS'; +KUNTIL : 'UNTIL'; +KVALOF : 'VALOF'; +KVEC : 'VEC'; +KWHILE : 'WHILE'; +KXOR : 'XOR'; +LBR : '['; +LE : '<='; +LL : '<<'; +LLCEQ : '<<:='; +LP : '('; +LT : '<'; +MODCEQ : 'MOD:='; +NCEQ : '~:='; +NE : '~='; +Neqv : 'NEQV'; +NEQVCEQ : 'NEQV:='; +OB : '$(' | '{'; +PABS : '#ABS'; +PARROW : '#->'; +PCEQ : '#:='; +PDD : '#..'; +PE : '#='; +PERCENT : '%'; +PGE : '#>='; +PGT : '#>'; +PLCEQ : '+:='; +PLE : '#<='; +PLT : '#<'; +PLUS : '+'; +PMINUS : '#-'; +PMOD : '#MOD'; +PMODCEQ : '#MOD:='; +PNCEQ : '#~:='; +PNE : '#~='; +POP : '#('; +PPCEQ : '#+:='; +PPLUS : '#+'; +PREM : '#REM'; +PSCEQ : '#*:='; +PSLCEQ : '#/:='; +PSTAR : '#*'; +QM : '?'; +RBR : ']'; +REM : 'REM'; +RP : ')'; +RRCEQ : '>>:='; +SCEQ : '*:='; +SEMI : ';'; +SLASH : '/'; +SLCEQ : '/:='; +STAR : '*'; +Table : 'TABLE'; +TILDE : '~'; +VBAR : '|'; +VCEQ : '|:='; +XORCEQ : 'XOR:='; -Identifier : Letter (Letter | Digit | '.' | '_')* ; +Identifier: Letter (Letter | Digit | '.' | '_')*; -Binary_number : ('#B'|'#b') [01]+ ; -Character_constant : '\'' '*'? . '\'' ; -Comment : ('/*' .*? '*/' | '//' ~('\n' | '\r')*) -> channel(HIDDEN) ; -Digits : Digit+; -Hex_number : ('#X'|'#x') Hex_digit Hex_digit* ; -Octal_number : '#' Octal_digit Octal_digit* ; -String_constant : '"' ~'"'* /* 255 or fewer characters */ '"' ; -WS : [ \t]+ -> channel(HIDDEN) ; -NL : [\n\r]+ -> channel(2) ; +Binary_number : ('#B' | '#b') [01]+; +Character_constant : '\'' '*'? . '\''; +Comment : ('/*' .*? '*/' | '//' ~('\n' | '\r')*) -> channel(HIDDEN); +Digits : Digit+; +Hex_number : ('#X' | '#x') Hex_digit Hex_digit*; +Octal_number : '#' Octal_digit Octal_digit*; +String_constant : '"' ~'"'* /* 255 or fewer characters */ '"'; +WS : [ \t]+ -> channel(HIDDEN); +NL : [\n\r]+ -> channel(2); -fragment Letter : [a-zA-Z] ; -fragment Octal_digit : [0-7] ; -fragment Hex_digit : [0-9A-Fa-f] ; -fragment Digit : [0-9] ; +fragment Letter : [a-zA-Z]; +fragment Octal_digit : [0-7]; +fragment Hex_digit : [0-9A-Fa-f]; +fragment Digit : [0-9]; \ No newline at end of file diff --git a/bcpl/bcplParser.g4 b/bcpl/bcplParser.g4 index 615131033c..db58a9ebeb 100644 --- a/bcpl/bcplParser.g4 +++ b/bcpl/bcplParser.g4 @@ -1,150 +1,558 @@ +// $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 bcplParser; -options { tokenVocab=bcplLexer; superClass=bcplParserBase; } +options { + tokenVocab = bcplLexer; + superClass = bcplParserBase; +} + +program + : directive* declaration_part EOF + ; + +number + : Octal_number + | Hex_number + | Digits + | Binary_number + ; -program : directive* declaration_part EOF ; +identifier + : Identifier + ; -number : Octal_number | Hex_number | Digits | Binary_number ; -identifier : Identifier; -name : identifier ; +name + : identifier + ; // 8.8.2 Operators -mult_op : '*' | '/' | 'REM' ; -add_op : '+' | '-' ; -shift_op : '<<' | '>>' ; -and_op : '&' ; -or_op : '|' ; +mult_op + : '*' + | '/' + | 'REM' + ; + +add_op + : '+' + | '-' + ; + +shift_op + : '<<' + | '>>' + ; + +and_op + : '&' + ; + +or_op + : '|' + ; // 8.8.3 Expressions -expression : e0 ; +expression + : e0 + ; // 8.8.4 Constant-expressions -c_element : Character_constant | number | identifier | 'TRUE' | 'FALSE' | '(' constant_expression ')' | '?' ; -c_mult_E : c_mult_E mult_op c_element | c_element ; -c_add_E : c_add_E add_op c_mult_E | add_op c_mult_E | c_mult_E ; -c_shift_E : c_shift_E shift_op c_add_E | c_add_E ; -c_and_E : c_and_E and_op c_shift_E | c_shift_E ; -constant_expression : constant_expression or_op c_and_E | c_and_E ; +c_element + : Character_constant + | number + | identifier + | 'TRUE' + | 'FALSE' + | '(' constant_expression ')' + | '?' + ; + +c_mult_E + : c_mult_E mult_op c_element + | c_element + ; + +c_add_E + : c_add_E add_op c_mult_E + | add_op c_mult_E + | c_mult_E + ; + +c_shift_E + : c_shift_E shift_op c_add_E + | c_add_E + ; + +c_and_E + : c_and_E and_op c_shift_E + | c_shift_E + ; + +constant_expression + : constant_expression or_op c_and_E + | c_and_E + ; // 8.8.5 List of expressions and identifiers -expression_list : expression (',' expression)* ; -name_list : name (',' name)* ; +expression_list + : expression (',' expression)* + ; + +name_list + : name (',' name)* + ; // 8.8.6 Declarations -manifest_item : identifier (('='|'EQ') constant_expression)? ; -manifest_list : manifest_item (semi manifest_item)* ; -manifest_declaration : 'MANIFEST' OB manifest_list CB ; -static_declaration : 'STATIC' OB manifest_list CB ; -global_item : identifier (':' constant_expression)? ; -global_list : global_item (semi global_item)* ; -global_declaration : 'GLOBAL' OB global_list CB ; -simple_definition : name_list ('='|'EQ') expression_list ; -vector_definition : identifier ('='|'EQ') 'VEC' constant_expression ; -function_definition : identifier '(' name_list ')' ('='|'EQ') expression | identifier '(' ')' ('='|'EQ') expression ; -routine_definition : identifier '(' name_list ')' 'BE' command | identifier '(' ')' 'BE' command ; -definition : simple_definition | vector_definition | function_definition | routine_definition ; -simultaneous_declaration : 'LET' definition ('AND' definition)* ; -declaration : simultaneous_declaration | manifest_declaration | static_declaration | global_declaration ; +manifest_item + : identifier (('=' | 'EQ') constant_expression)? + ; + +manifest_list + : manifest_item (semi manifest_item)* + ; + +manifest_declaration + : 'MANIFEST' OB manifest_list CB + ; + +static_declaration + : 'STATIC' OB manifest_list CB + ; + +global_item + : identifier (':' constant_expression)? + ; + +global_list + : global_item (semi global_item)* + ; + +global_declaration + : 'GLOBAL' OB global_list CB + ; + +simple_definition + : name_list ('=' | 'EQ') expression_list + ; + +vector_definition + : identifier ('=' | 'EQ') 'VEC' constant_expression + ; + +function_definition + : identifier '(' name_list ')' ('=' | 'EQ') expression + | identifier '(' ')' ('=' | 'EQ') expression + ; + +routine_definition + : identifier '(' name_list ')' 'BE' command + | identifier '(' ')' 'BE' command + ; + +definition + : simple_definition + | vector_definition + | function_definition + | routine_definition + ; + +simultaneous_declaration + : 'LET' definition ('AND' definition)* + ; + +declaration + : simultaneous_declaration + | manifest_declaration + | static_declaration + | global_declaration + ; // 8.8.7 Left-hand side expressions -lhse : e0 ; -left_hand_side_list : lhse (',' lhse)* ; +lhse + : e0 + ; + +left_hand_side_list + : lhse (',' lhse)* + ; // 8.8.8 Unlabeled commands -assignment : left_hand_side_list assop expression_list ; -simple_command : 'BREAK' | 'LOOP' | 'ENDCASE' | 'RETURN' | 'FINISH' ; -goto_command : 'GOTO' expression ; -routine_command : bexp '(' expression_list ')' | bexp '(' ')' ; -resultis_command : 'RESULTIS' expression ; -switchon_command : 'SWITCHON' expression 'INTO' compound_command ; -repeatable_command : assignment | simple_command | goto_command | routine_command | resultis_command | repeatable_command 'REPEAT' | repeatable_command 'REPEATUNTIL' expression | repeatable_command 'REPEATWHILE' expression | switchon_command | compound_command | block ; -repeated_command : repeatable_command 'REPEAT' | repeatable_command 'REPEATUNTIL' expression | repeatable_command 'REPEATWHILE' expression ; -until_command : 'UNTIL' expression 'DO' command ; -while_command : 'WHILE' expression 'DO' command ; -for_command : 'FOR' identifier ('='|'EQ') expression 'TO' expression ('BY' constant_expression)? 'DO'? command ; -repetitive_command : repeated_command | until_command | while_command | for_command | unless_command ; -test_command : 'TEST' expression ('THEN'|'DO')? command ('ELSE'|'OR') command ; -if_command : 'IF' expression ('THEN'|'DO')? command ; -unless_command : 'UNLESS' expression ('THEN'|'DO')? command ; -unlabelled_command : repeatable_command | repetitive_command | test_command | if_command ; +assignment + : left_hand_side_list assop expression_list + ; + +simple_command + : 'BREAK' + | 'LOOP' + | 'ENDCASE' + | 'RETURN' + | 'FINISH' + ; + +goto_command + : 'GOTO' expression + ; + +routine_command + : bexp '(' expression_list ')' + | bexp '(' ')' + ; + +resultis_command + : 'RESULTIS' expression + ; + +switchon_command + : 'SWITCHON' expression 'INTO' compound_command + ; + +repeatable_command + : assignment + | simple_command + | goto_command + | routine_command + | resultis_command + | repeatable_command 'REPEAT' + | repeatable_command 'REPEATUNTIL' expression + | repeatable_command 'REPEATWHILE' expression + | switchon_command + | compound_command + | block + ; + +repeated_command + : repeatable_command 'REPEAT' + | repeatable_command 'REPEATUNTIL' expression + | repeatable_command 'REPEATWHILE' expression + ; + +until_command + : 'UNTIL' expression 'DO' command + ; + +while_command + : 'WHILE' expression 'DO' command + ; + +for_command + : 'FOR' identifier ('=' | 'EQ') expression 'TO' expression ('BY' constant_expression)? 'DO'? command + ; + +repetitive_command + : repeated_command + | until_command + | while_command + | for_command + | unless_command + ; + +test_command + : 'TEST' expression ('THEN' | 'DO')? command ('ELSE' | 'OR') command + ; + +if_command + : 'IF' expression ('THEN' | 'DO')? command + ; + +unless_command + : 'UNLESS' expression ('THEN' | 'DO')? command + ; + +unlabelled_command + : repeatable_command + | repetitive_command + | test_command + | if_command + ; // 8.8.9 Labeled commands -label_prefix : identifier ':' ; -case_prefix : 'CASE' constant_expression ':' ; -default_prefix : 'DEFAULT' ':' ; -prefix_ : label_prefix | case_prefix | default_prefix ; -command : prefix_* unlabelled_command | prefix_ prefix_* ; +label_prefix + : identifier ':' + ; + +case_prefix + : 'CASE' constant_expression ':' + ; + +default_prefix + : 'DEFAULT' ':' + ; + +prefix_ + : label_prefix + | case_prefix + | default_prefix + ; + +command + : prefix_* unlabelled_command + | prefix_ prefix_* + ; // 8.8.10 Blocks and compound commands -command_list : command (semi command)* ; -declaration_part : declaration (semi declaration)* ; -semi : ';'+ | nl; +command_list + : command (semi command)* + ; + +declaration_part + : declaration (semi declaration)* + ; + +semi + : ';'+ + | nl + ; + +block + : OB declaration_part semi command_list? CB + ; -block : OB declaration_part semi command_list? CB ; -compound_command : OB command_list? CB ; +compound_command + : OB command_list? CB + ; // Extended -directive : 'GET' String_constant | 'SECTION' String_constant ; - -fname : 'FLT' identifier ; -const : number | Character_constant | 'TRUE' | 'FALSE' | '?' ; -bpat : '+' number | '-' number | 'TRUE' | 'FALSE' | '?' | Character_constant ; -string : String_constant ; -relop : '=' | 'EQ' | '~=' | 'NE' | '<' | '<=' | '>' | '>=' | '#=' | '#~=' | '#<' | '#<=' | '#>' | '#>=' ; -fcond : '->' | '#->' ; -range : '..' | '#..' ; -jcom : 'NEXT' | 'EXIT' | 'BREAK' | 'LOOP' | 'ENDCASE' ; -assop : ':=' | '*:=' | '/:=' | 'MOD:=' | '+:=' | '~:=' | '#:=' | '#*:=' | '#/:=' | '#MOD:=' | '#+:=' | '#~:=' | '<<:=' | '>>:=' | '&:=' | '|:=' | 'EQV:=' | 'NEQV:=' | 'XOR:=' ; -nonl : { IsNotNl() }? ; -mlist : (':' p0? ('->' e0 | 'BE' command))+ '.'? ; -p0 : sp (sp0 | sp1 | p3)* ; -p1 : sp (sp1 | p3)* ; -p2 : sp p3* ; -p3 : p2 ; -sp0 : ',' p1 ; -sp1 : sp0 | '|' p2 ; +directive + : 'GET' String_constant + | 'SECTION' String_constant + ; + +fname + : 'FLT' identifier + ; + +const + : number + | Character_constant + | 'TRUE' + | 'FALSE' + | '?' + ; + +bpat + : '+' number + | '-' number + | 'TRUE' + | 'FALSE' + | '?' + | Character_constant + ; + +string + : String_constant + ; + +relop + : '=' + | 'EQ' + | '~=' + | 'NE' + | '<' + | '<=' + | '>' + | '>=' + | '#=' + | '#~=' + | '#<' + | '#<=' + | '#>' + | '#>=' + ; + +fcond + : '->' + | '#->' + ; + +range + : '..' + | '#..' + ; + +jcom + : 'NEXT' + | 'EXIT' + | 'BREAK' + | 'LOOP' + | 'ENDCASE' + ; + +assop + : ':=' + | '*:=' + | '/:=' + | 'MOD:=' + | '+:=' + | '~:=' + | '#:=' + | '#*:=' + | '#/:=' + | '#MOD:=' + | '#+:=' + | '#~:=' + | '<<:=' + | '>>:=' + | '&:=' + | '|:=' + | 'EQV:=' + | 'NEQV:=' + | 'XOR:=' + ; + +nonl + : { IsNotNl() }? + ; + +mlist + : (':' p0? ('->' e0 | 'BE' command))+ '.'? + ; + +p0 + : sp (sp0 | sp1 | p3)* + ; + +p1 + : sp (sp1 | p3)* + ; + +p2 + : sp p3* + ; + +p3 + : p2 + ; + +sp0 + : ',' p1 + ; + +sp1 + : sp0 + | '|' p2 + ; + sp - : relop (bpat | '(' e0 ')') - | jcom - | '(' p0 ')' - | '[' p0 ']' - | bpat (range bpat)? - | fname - ; + : relop (bpat | '(' e0 ')') + | jcom + | '(' p0 ')' + | '[' p0 ']' + | bpat (range bpat)? + | fname + ; + bexp - : name - | const - | string - | 'SLCT' e9 (':' e9 (':' e9)? )? - | 'NEXT' | 'EXIT' | 'BREAK' | 'LOOP' | 'ENDCASE' - | '(' e0 ')' - | ('FLOAT' | 'FIX' | '!' | '@') e7 - | ('+' | '-' | 'ABS' | '#+' | '#-' | '#ABS') e5 - | ('NOT'|'~') e3 - | 'TABLE' e0 (',' e0)* - | ('MATCH' | 'EVERY') '(' e0 (',' e0)* ')' mlist - | 'VALOF' command - ; -se9 :'(' (e0 (',' e0)*)? ')' | '#(' e0 (',' e0)* ')' | '[' e0 ']' ; -se8 : ('OF' | '::' | '!' | '%') e8 ; -se6 : ('*' | '/' | 'MOD' | '#*' | '#MOD' | 'REM' | '#REM') e6 ; -se5 : ('=' | 'EQ' | '~=' | 'NE' | '<' | '<=' | '>' | '>=' | '#=' | '#~=' | '#<' | '#<=' | '#>' | '#>=') e4 (relop e4)* | ('+' | '-' | '#+' | '#-') e5 ; -se4 : ('<<' | '>>') e4 ; -se3 : '&' e3 ; -se2 : '|' e2 ; -se1: ('EQV' | 'XOR' | 'NEQV') e1 | fcond e0 ',' e0 ; - -e9 : bexp ; -e8 : bexp (nonl se9 )* ; -e7 : bexp (nonl ( se9 | se8 ))* ; -e6 : bexp (nonl ( se9 | se8 ))* ; -e5 : bexp (nonl ( se9 | se8 | se6 ))* ; -e4 : bexp (nonl ( se9 | se8 | se6 | se5 ))* ; -e3 : bexp (nonl ( se9 | se8 | se6 | se5 | se4 ))* ; -e2 : bexp (nonl ( se9 | se8 | se6 | se5 | se4 | se3 ))* ; -e1 : bexp (nonl ( se9 | se8 | se6 | se5 | se4 | se3 | se2 ))* ; -e0 : bexp (nonl ( se9 | se8 | se6 | se5 | se4 | se3 | se2 | se1 ))* ; - -nl : { IsNl() }? ; + : name + | const + | string + | 'SLCT' e9 (':' e9 (':' e9)?)? + | 'NEXT' + | 'EXIT' + | 'BREAK' + | 'LOOP' + | 'ENDCASE' + | '(' e0 ')' + | ('FLOAT' | 'FIX' | '!' | '@') e7 + | ('+' | '-' | 'ABS' | '#+' | '#-' | '#ABS') e5 + | ('NOT' | '~') e3 + | 'TABLE' e0 (',' e0)* + | ('MATCH' | 'EVERY') '(' e0 (',' e0)* ')' mlist + | 'VALOF' command + ; + +se9 + : '(' (e0 (',' e0)*)? ')' + | '#(' e0 (',' e0)* ')' + | '[' e0 ']' + ; + +se8 + : ('OF' | '::' | '!' | '%') e8 + ; + +se6 + : ('*' | '/' | 'MOD' | '#*' | '#MOD' | 'REM' | '#REM') e6 + ; + +se5 + : ( + '=' + | 'EQ' + | '~=' + | 'NE' + | '<' + | '<=' + | '>' + | '>=' + | '#=' + | '#~=' + | '#<' + | '#<=' + | '#>' + | '#>=' + ) e4 (relop e4)* + | ('+' | '-' | '#+' | '#-') e5 + ; + +se4 + : ('<<' | '>>') e4 + ; + +se3 + : '&' e3 + ; + +se2 + : '|' e2 + ; + +se1 + : ('EQV' | 'XOR' | 'NEQV') e1 + | fcond e0 ',' e0 + ; + +e9 + : bexp + ; + +e8 + : bexp (nonl se9)* + ; + +e7 + : bexp (nonl ( se9 | se8))* + ; + +e6 + : bexp (nonl ( se9 | se8))* + ; + +e5 + : bexp (nonl ( se9 | se8 | se6))* + ; + +e4 + : bexp (nonl ( se9 | se8 | se6 | se5))* + ; + +e3 + : bexp (nonl ( se9 | se8 | se6 | se5 | se4))* + ; + +e2 + : bexp (nonl ( se9 | se8 | se6 | se5 | se4 | se3))* + ; + +e1 + : bexp (nonl ( se9 | se8 | se6 | se5 | se4 | se3 | se2))* + ; + +e0 + : bexp (nonl ( se9 | se8 | se6 | se5 | se4 | se3 | se2 | se1))* + ; +nl + : { IsNl() }? + ; \ No newline at end of file diff --git a/bcpl/ignore/bcpl.g4 b/bcpl/ignore/bcpl.g4 index 32bb059558..4294b05218 100644 --- a/bcpl/ignore/bcpl.g4 +++ b/bcpl/ignore/bcpl.g4 @@ -29,484 +29,488 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* http://java.lykkenborg.no/2012/02/bcpl-grammar.html */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar bcpl; element - : CHARACTERCONSTANT - | STRINGCONSTANT - | NUMBER - | IDENTIFIER - | 'TRUE' - | 'FALSE' - ; + : CHARACTERCONSTANT + | STRINGCONSTANT + | NUMBER + | IDENTIFIER + | 'TRUE' + | 'FALSE' + ; primaryE - : primaryE '(' expression_list ')' - | primaryE '(' ')' - | '(' expression ')' - | element - ; + : primaryE '(' expression_list ')' + | primaryE '(' ')' + | '(' expression ')' + | element + ; vectorE - : (vectorE '!' primaryE) - | primaryE - ; + : (vectorE '!' primaryE) + | primaryE + ; addressE - : ADDRESSOP addressE - | vectorE - ; + : ADDRESSOP addressE + | vectorE + ; multE - : (multE MULTOP addressE) - | addressE - ; + : (multE MULTOP addressE) + | addressE + ; addE - : addE ADDOP multE - | ADDOP multE - | multE - ; + : addE ADDOP multE + | ADDOP multE + | multE + ; relE - : addE (RELOP addE)* - ; + : addE (RELOP addE)* + ; shiftE - : shiftE SHIFTOP addE - | relE - ; + : shiftE SHIFTOP addE + | relE + ; notE - : NOTOP shiftE - | shiftE - ; + : NOTOP shiftE + | shiftE + ; andE - : notE (ADDOP notE)* - ; + : notE (ADDOP notE)* + ; orE - : andE (OROP andE)* - ; + : andE (OROP andE)* + ; eqvE - : orE (EQVOP orE)* - ; - // ugh + : orE (EQVOP orE)* + ; + +// ugh name - : IDENTIFIER - ; + : IDENTIFIER + ; conditionalE - : eqvE '->' conditionalE ',' conditionalE - | eqvE - ; + : eqvE '->' conditionalE ',' conditionalE + | eqvE + ; expression - : conditionalE - | 'TABLE' constant_expression (',' constant_expression)* - | 'VALOF' command - ; + : conditionalE + | 'TABLE' constant_expression (',' constant_expression)* + | 'VALOF' command + ; c_element - : CHARACTERCONSTANT - | NUMBER - | IDENTIFIER - | 'TRUE' - | 'FALSE' - | '(' constant_expression ')' - ; + : CHARACTERCONSTANT + | NUMBER + | IDENTIFIER + | 'TRUE' + | 'FALSE' + | '(' constant_expression ')' + ; c_multE - : c_multE MULTOP c_element - | c_element - ; + : c_multE MULTOP c_element + | c_element + ; c_addE - : c_addE ADDOP c_multE - | ADDOP c_multE - | c_multE - ; + : c_addE ADDOP c_multE + | ADDOP c_multE + | c_multE + ; c_shiftE - : c_shiftE SHIFTOP c_addE - | c_addE - ; + : c_shiftE SHIFTOP c_addE + | c_addE + ; c_andE - : c_andE ANDOP c_shiftE - | c_shiftE - ; + : c_andE ANDOP c_shiftE + | c_shiftE + ; constant_expression - : constant_expression OROP c_andE - | c_andE - ; + : constant_expression OROP c_andE + | c_andE + ; expression_list - : expression (',' expression)* - ; + : expression (',' expression)* + ; name_list - : name (',' name)* - ; + : name (',' name)* + ; manifest_item - : IDENTIFIER '=' constant_expression - ; + : IDENTIFIER '=' constant_expression + ; manifest_list - : manifest_item (';' manifest_item)* - ; + : manifest_item (';' manifest_item)* + ; manifest_declaration - : 'MANIFEST' '$(' manifest_list '$)' - ; + : 'MANIFEST' '$(' manifest_list '$)' + ; static_declaration - : 'STATIC' '$(' manifest_list '$)' - ; + : 'STATIC' '$(' manifest_list '$)' + ; global_item - : IDENTIFIER ':' constant_expression - ; + : IDENTIFIER ':' constant_expression + ; global_list - : global_item (';' global_item)* - ; + : global_item (';' global_item)* + ; global_declaration - : 'GLOBAL' '$(' global_list '$)' - ; + : 'GLOBAL' '$(' global_list '$)' + ; simple_definition - : name_list '=' expression_list - ; + : name_list '=' expression_list + ; vector_definition - : IDENTIFIER '=' 'VEC' constant_expression - ; + : IDENTIFIER '=' 'VEC' constant_expression + ; function_definition - : IDENTIFIER '(' name_list ')' '=' expression - | IDENTIFIER '(' ')' '=' expression - ; + : IDENTIFIER '(' name_list ')' '=' expression + | IDENTIFIER '(' ')' '=' expression + ; routine_definition - : IDENTIFIER '(' name_list ')' 'BE' command - | IDENTIFIER '(' ')' 'BE' command - ; + : IDENTIFIER '(' name_list ')' 'BE' command + | IDENTIFIER '(' ')' 'BE' command + ; definition - : simple_definition - | vector_definition - | function_definition - | routine_definition - ; + : simple_definition + | vector_definition + | function_definition + | routine_definition + ; simultaneous_declaration - : 'LET' definition ('AND' definition)* - ; + : 'LET' definition ('AND' definition)* + ; declaration - : simultaneous_declaration - | manifest_declaration - | static_declaration - | global_declaration - ; + : simultaneous_declaration + | manifest_declaration + | static_declaration + | global_declaration + ; lhse - : IDENTIFIER - | vectorE '!' primaryE - | '!' primaryE - ; + : IDENTIFIER + | vectorE '!' primaryE + | '!' primaryE + ; left_hand_side_list - : lhse (',' lhse)* - ; + : lhse (',' lhse)* + ; assignment - : left_hand_side_list ':=' expression_list - ; + : left_hand_side_list ':=' expression_list + ; simple_command - : 'BREAK' - | 'LOOP' - | 'ENDCASE' - | 'RETURN' - | 'FINISH' - ; + : 'BREAK' + | 'LOOP' + | 'ENDCASE' + | 'RETURN' + | 'FINISH' + ; goto_command - : 'GOTO' expression - ; + : 'GOTO' expression + ; routine_command - : primaryE '(' expression_list ')' - | primaryE '(' ')' - ; + : primaryE '(' expression_list ')' + | primaryE '(' ')' + ; resultis_command - : 'RESULTIS' expression - ; + : 'RESULTIS' expression + ; switchon_command - : 'SWITCHON' expression 'INTO' compound_command - ; + : 'SWITCHON' expression 'INTO' compound_command + ; repeatable_command - : assignment - | simple_command - | goto_command - | routine_command - | resultis_command - | repeated_command - | switchon_command - | compound_command - | block - ; + : assignment + | simple_command + | goto_command + | routine_command + | resultis_command + | repeated_command + | switchon_command + | compound_command + | block + ; repeated_command - : repeatable_command 'REPEAT' - | repeatable_command 'REPEATUNTIL' expression - | repeatable_command 'REPEATWHILE' expression - ; + : repeatable_command 'REPEAT' + | repeatable_command 'REPEATUNTIL' expression + | repeatable_command 'REPEATWHILE' expression + ; until_command - : 'UNTIL' expression 'DO' command - ; + : 'UNTIL' expression 'DO' command + ; while_command - : 'WHILE' expression 'DO' command - ; + : 'WHILE' expression 'DO' command + ; for_command - : 'FOR' IDENTIFIER '=' expression 'TO' expression 'BY' constant_expression 'DO' command - | 'FOR' IDENTIFIER ':' expression 'TO' expression 'DO' command - ; + : 'FOR' IDENTIFIER '=' expression 'TO' expression 'BY' constant_expression 'DO' command + | 'FOR' IDENTIFIER ':' expression 'TO' expression 'DO' command + ; repetitive_command - : repeated_command - | until_command - | while_command - | for_command - ; + : repeated_command + | until_command + | while_command + | for_command + ; test_command - : 'TEST' expression 'THEN' command 'ELSE' command - ; + : 'TEST' expression 'THEN' command 'ELSE' command + ; if_command - : 'IF' expression 'THEN' command - ; + : 'IF' expression 'THEN' command + ; unless_command - : 'UNLESS' expression 'THEN' command - ; + : 'UNLESS' expression 'THEN' command + ; unlabelled_command - : repeatable_command - | repetitive_command - | test_command - | if_command - ; + : repeatable_command + | repetitive_command + | test_command + | if_command + ; label_prefix - : IDENTIFIER ':' - ; + : IDENTIFIER ':' + ; case_prefix - : 'CASE' constant_expression ':' - ; + : 'CASE' constant_expression ':' + ; default_prefix - : 'DEFAULT' ':' - ; + : 'DEFAULT' ':' + ; prefix - : label_prefix - | case_prefix - | default_prefix - ; + : label_prefix + | case_prefix + | default_prefix + ; command - : unlabelled_command - | prefix command - | prefix - ; + : unlabelled_command + | prefix command + | prefix + ; command_list - : command (';' command)* - ; + : command (';' command)* + ; declaration_part - : declaration (';' declaration)* - ; + : declaration (';' declaration)* + ; block - : '$(' declaration_part ';' command_list '$)' - ; + : '$(' declaration_part ';' command_list '$)' + ; compound_command - : '$(' command_list '$)' - ; + : '$(' command_list '$)' + ; program - : declaration_part - ; + : declaration_part + ; LETTER - : 'A' - | 'B' - | 'C' - | 'D' - | 'E' - | 'F' - | 'G' - | 'H' - | 'I' - | 'J' - | 'K' - | 'L' - | 'M' - | 'N' - | 'O' - | 'P' - | 'Q' - | 'R' - | 'S' - | 'T' - | 'U' - | 'V' - | 'W' - | 'X' - | 'Y' - | 'Z' - ; + : 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + | 'G' + | 'H' + | 'I' + | 'J' + | 'K' + | 'L' + | 'M' + | 'N' + | 'O' + | 'P' + | 'Q' + | 'R' + | 'S' + | 'T' + | 'U' + | 'V' + | 'W' + | 'X' + | 'Y' + | 'Z' + ; OCTALDIGIT - : '0' - | '1' - | '2' - | '3' - | '4' - | '5' - | '6' - | '7' - ; + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + ; HEXDIGIT - : '0' - | '1' - | '2' - | '3' - | '4' - | '5' - | '6' - | '7' - | '8' - | '9' - | 'A' - | 'B' - | 'C' - | 'D' - | 'E' - | 'F' - ; + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + | '8' + | '9' + | 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + ; DIGIT - : '0' - | '1' - | '2' - | '3' - | '4' - | '5' - | '6' - | '7' - | '8' - | '9' - ; + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + | '8' + | '9' + ; STRINGCONSTANT - : '"' ('\'"' | ~ '"')* '"' - ; + : '"' ('\'"' | ~ '"')* '"' + ; CHARACTERCONSTANT - : '\'' (DIGIT | LETTER) '\'' - ; + : '\'' (DIGIT | LETTER) '\'' + ; OCTALNUMBER - : '#' OCTALDIGIT+ - ; + : '#' OCTALDIGIT+ + ; HEXNUMBER - : '#X' HEXDIGIT+ - ; + : '#X' HEXDIGIT+ + ; NUMBER - : OCTALNUMBER - | HEXNUMBER - | DIGIT+ - ; + : OCTALNUMBER + | HEXNUMBER + | DIGIT+ + ; IDENTIFIER - : LETTER (LETTER | DIGIT | '.')* - ; + : LETTER (LETTER | DIGIT | '.')* + ; ADDRESSOP - : '@' - | '!' - ; + : '@' + | '!' + ; MULTOP - : '*' - | '/' - | 'REM' - ; + : '*' + | '/' + | 'REM' + ; ADDOP - : '+' - | '-' - ; + : '+' + | '-' + ; RELOP - : '=' - | '¬=' - | '<=' - | '>=' - | '<' - | '>' - ; + : '=' + | '¬=' + | '<=' + | '>=' + | '<' + | '>' + ; SHIFTOP - : '<<' - | '>>' - ; + : '<<' + | '>>' + ; ANDOP - : '&' - ; + : '&' + ; OROP - : '|' - ; + : '|' + ; EQVOP - : 'EQV' - | 'NEQV' - ; + : 'EQV' + | 'NEQV' + ; NOTOP - : '¬' - ; + : '¬' + ; STRING - : - ; + : + ; WS - : [ \r\n] -> skip - ; - + : [ \r\n] -> skip + ; \ No newline at end of file diff --git a/bcpl/ignore/origbcpl.g4 b/bcpl/ignore/origbcpl.g4 index 91e8b92a5c..b668294e53 100644 --- a/bcpl/ignore/origbcpl.g4 +++ b/bcpl/ignore/origbcpl.g4 @@ -1,131 +1,564 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar bcpl; // 8.8.1 Identifier, Strings, Numbers. -letter : 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' -// extended - | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' - ; -octal_digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' ; -hex_digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' ; -digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ; +letter + : 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + | 'G' + | 'H' + | 'I' + | 'J' + | 'K' + | 'L' + | 'M' + | 'N' + | 'O' + | 'P' + | 'Q' + | 'R' + | 'S' + | 'T' + | 'U' + | 'V' + | 'W' + | 'X' + | 'Y' + | 'Z' + // extended + | 'a' + | 'b' + | 'c' + | 'd' + | 'e' + | 'f' + | 'g' + | 'h' + | 'i' + | 'j' + | 'k' + | 'l' + | 'm' + | 'n' + | 'o' + | 'p' + | 'q' + | 'r' + | 's' + | 't' + | 'u' + | 'v' + | 'w' + | 'x' + | 'y' + | 'z' + ; + +octal_digit + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + ; + +hex_digit + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + | '8' + | '9' + | 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + ; + +digit + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + | '8' + | '9' + ; + // extended -string_constant : '"' ~'"'* /* 255 or fewer characters */ '"' ; -character_constant : '\'' one_character '\'' ; -octal_number : '#' octal_digit octal_digit* ; -hex_number : '#X' hex_digit hex_digit* ; -number : octal_number | hex_number | digit digit* ; -identifier : letter (letter | digit | '.')* ; +string_constant + : '"' ~'"'* /* 255 or fewer characters */ '"' + ; + +character_constant + : '\'' one_character '\'' + ; + +octal_number + : '#' octal_digit octal_digit* + ; + +hex_number + : '#X' hex_digit hex_digit* + ; + +number + : octal_number + | hex_number + | digit digit* + ; + +identifier + : letter (letter | digit | '.')* + ; // missing -one_character : letter | digit ; -name : identifier ; +one_character + : letter + | digit + ; + +name + : identifier + ; // 8.8.2 Operators -address_op : '@' | '!' ; -mult_op : '*' | '/' | 'REM' ; -add_op : '+' | '-' ; -rel_op : '=' | '=' | '<=' | '>=' | '<' | '>' ; -shift_op : '<<' | '>>' ; -and_op : '&' ; -or_op : '|' ; -eqv_op : 'EQV' | 'NEQV' ; -not_op : '' ; +address_op + : '@' + | '!' + ; + +mult_op + : '*' + | '/' + | 'REM' + ; + +add_op + : '+' + | '-' + ; + +rel_op + : '=' + | '�=' + | '<=' + | '>=' + | '<' + | '>' + ; + +shift_op + : '<<' + | '>>' + ; + +and_op + : '&' + ; + +or_op + : '|' + ; + +eqv_op + : 'EQV' + | 'NEQV' + ; + +not_op + : '�' + ; // 8.8.3 Expressions -element : character_constant | string_constant | number | identifier | 'TRUE' | 'FALSE' ; -primary_E : primary_E '(' expression_list ')' | primary_E '(' ')' | '(' expression ')' | element ; -vector_E : vector_E '!' primary_E | primary_E ; -address_E : address_op address_E | vector_E ; -mult_E : mult_E mult_op address_E | address_E ; -add_E : add_E add_op mult_E | add_op mult_E | mult_E ; -rel_E : add_E (rel_op add_E)* ; -shift_E : shift_E shift_op add_E | rel_E ; -not_E : not_op shift_E | shift_E ; -and_E : not_E (and_op not_E)* ; -or_E : and_E (or_op and_E)* ; -eqv_E : or_E (eqv_op or_E)* ; -conditional_E : eqv_E '->' conditional_E ',' conditional_E | eqv_E ; -expression : conditional_E | 'TABLE' constant_expression (',' constant_expression)* | 'VALOF' command ; +element + : character_constant + | string_constant + | number + | identifier + | 'TRUE' + | 'FALSE' + ; + +primary_E + : primary_E '(' expression_list ')' + | primary_E '(' ')' + | '(' expression ')' + | element + ; + +vector_E + : vector_E '!' primary_E + | primary_E + ; + +address_E + : address_op address_E + | vector_E + ; + +mult_E + : mult_E mult_op address_E + | address_E + ; + +add_E + : add_E add_op mult_E + | add_op mult_E + | mult_E + ; + +rel_E + : add_E (rel_op add_E)* + ; + +shift_E + : shift_E shift_op add_E + | rel_E + ; + +not_E + : not_op shift_E + | shift_E + ; + +and_E + : not_E (and_op not_E)* + ; + +or_E + : and_E (or_op and_E)* + ; + +eqv_E + : or_E (eqv_op or_E)* + ; + +conditional_E + : eqv_E '->' conditional_E ',' conditional_E + | eqv_E + ; + +expression + : conditional_E + | 'TABLE' constant_expression (',' constant_expression)* + | 'VALOF' command + ; // 8.8.4 Constant-expressions -c_element : character_constant | number | identifier | 'TRUE' | 'FALSE' | '(' constant_expression ')' ; -c_mult_E : c_mult_E mult_op c_element | c_element ; -c_add_E : c_add_E add_op c_mult_E | add_op c_mult_E | c_mult_E ; -c_shift_E : c_shift_E shift_op c_add_E | c_add_E ; -c_and_E : c_and_E and_op c_shift_E | c_shift_E ; -constant_expression : constant_expression or_op c_and_E | c_and_E ; +c_element + : character_constant + | number + | identifier + | 'TRUE' + | 'FALSE' + | '(' constant_expression ')' + ; + +c_mult_E + : c_mult_E mult_op c_element + | c_element + ; + +c_add_E + : c_add_E add_op c_mult_E + | add_op c_mult_E + | c_mult_E + ; + +c_shift_E + : c_shift_E shift_op c_add_E + | c_add_E + ; + +c_and_E + : c_and_E and_op c_shift_E + | c_shift_E + ; + +constant_expression + : constant_expression or_op c_and_E + | c_and_E + ; // 8.8.5 List of expressions and identifiers -expression_list : expression (',' expression)* ; -name_list : name (',' name)* ; +expression_list + : expression (',' expression)* + ; + +name_list + : name (',' name)* + ; // 8.8.6 Declarations -manifest_item : identifier '=' constant_expression ; -manifest_list : manifest_item (';' manifest_item)* ; -manifest_declaration : 'MANIFEST' '$(' manifest_list '$)' ; -static_declaration : 'STATIC' '$(' manifest_list '$)' ; -global_item : identifier ':' constant_expression ; -global_list : global_item (';' global_item)* ; -global_declaration : 'GLOBAL' '$(' global_list '$)' ; -simple_definition : name_list '=' expression_list ; -vector_definition : identifier '=' 'VEC' constant_expression ; -function_definition : identifier '(' name_list ')' '=' expression | identifier '(' ')' '=' expression ; -routine_definition : identifier '(' name_list ')' 'BE' command | identifier '(' ')' 'BE' command ; -definition : simple_definition | vector_definition | function_definition | routine_definition ; -simultaneous_declaration : 'LET' definition ('AND' definition)* ; -declaration : simultaneous_declaration | manifest_declaration | static_declaration | global_declaration ; +manifest_item + : identifier '=' constant_expression + ; + +manifest_list + : manifest_item (';' manifest_item)* + ; + +manifest_declaration + : 'MANIFEST' '$(' manifest_list '$)' + ; + +static_declaration + : 'STATIC' '$(' manifest_list '$)' + ; + +global_item + : identifier ':' constant_expression + ; + +global_list + : global_item (';' global_item)* + ; + +global_declaration + : 'GLOBAL' '$(' global_list '$)' + ; + +simple_definition + : name_list '=' expression_list + ; + +vector_definition + : identifier '=' 'VEC' constant_expression + ; + +function_definition + : identifier '(' name_list ')' '=' expression + | identifier '(' ')' '=' expression + ; + +routine_definition + : identifier '(' name_list ')' 'BE' command + | identifier '(' ')' 'BE' command + ; + +definition + : simple_definition + | vector_definition + | function_definition + | routine_definition + ; + +simultaneous_declaration + : 'LET' definition ('AND' definition)* + ; + +declaration + : simultaneous_declaration + | manifest_declaration + | static_declaration + | global_declaration + ; // 8.8.7 Left-hand side expressions -lhse : identifier | vector_E '!' primary_E | '!' primary_E ; -left_hand_side_list : lhse (',' lhse)* ; +lhse + : identifier + | vector_E '!' primary_E + | '!' primary_E + ; + +left_hand_side_list + : lhse (',' lhse)* + ; // 8.8.8 Unlabeled commands -assignment : left_hand_side_list ':=' expression_list ; -simple_command : 'BREAK' | 'LOOP' | 'ENDCASE' | 'RETURN' | 'FINISH' ; -goto_command : 'GOTO' expression ; -routine_command : primary_E '(' expression_list ')' | primary_E '(' ')' ; -resultis_command : 'RESULTIS' expression ; -switchon_command : 'SWITCHON' expression 'INTO' compound_command ; -repeatable_command : assignment | simple_command | goto_command | routine_command | resultis_command | repeated_command | switchon_command | compound_command | block ; -repeated_command : repeatable_command 'REPEAT' | repeatable_command 'REPEATUNTIL' expression | repeatable_command 'REPEATWHILE' expression ; -until_command : 'UNTIL' expression 'DO' command ; -while_command : 'WHILE' expression 'DO' command ; -for_command : 'FOR' identifier '=' expression 'TO' expression 'BY' constant_expression 'DO' command | 'FOR' identifier '=' expression 'TO' expression 'DO' command ; -repetitive_command : repeated_command | until_command | while_command | for_command ; -test_command : 'TEST' expression 'THEN' command 'ELSE' command ; -if_command : 'IF' expression 'THEN' command ; -unless_command : 'UNLESS' expression 'THEN' command ; -unlabelled_command : repeatable_command | repetitive_command | test_command | if_command ; +assignment + : left_hand_side_list ':=' expression_list + ; + +simple_command + : 'BREAK' + | 'LOOP' + | 'ENDCASE' + | 'RETURN' + | 'FINISH' + ; + +goto_command + : 'GOTO' expression + ; + +routine_command + : primary_E '(' expression_list ')' + | primary_E '(' ')' + ; + +resultis_command + : 'RESULTIS' expression + ; + +switchon_command + : 'SWITCHON' expression 'INTO' compound_command + ; + +repeatable_command + : assignment + | simple_command + | goto_command + | routine_command + | resultis_command + | repeated_command + | switchon_command + | compound_command + | block + ; + +repeated_command + : repeatable_command 'REPEAT' + | repeatable_command 'REPEATUNTIL' expression + | repeatable_command 'REPEATWHILE' expression + ; + +until_command + : 'UNTIL' expression 'DO' command + ; + +while_command + : 'WHILE' expression 'DO' command + ; + +for_command + : 'FOR' identifier '=' expression 'TO' expression 'BY' constant_expression 'DO' command + | 'FOR' identifier '=' expression 'TO' expression 'DO' command + ; + +repetitive_command + : repeated_command + | until_command + | while_command + | for_command + ; + +test_command + : 'TEST' expression 'THEN' command 'ELSE' command + ; + +if_command + : 'IF' expression 'THEN' command + ; + +unless_command + : 'UNLESS' expression 'THEN' command + ; + +unlabelled_command + : repeatable_command + | repetitive_command + | test_command + | if_command + ; // 8.8.9 Labeled commands -label_prefix : identifier ':' ; -case_prefix : 'CASE' constant_expression ':' ; -default_prefix : 'DEFAULT' ':' ; -prefix : label_prefix | case_prefix | default_prefix ; -command : unlabelled_command | prefix command | prefix ; +label_prefix + : identifier ':' + ; + +case_prefix + : 'CASE' constant_expression ':' + ; + +default_prefix + : 'DEFAULT' ':' + ; + +prefix + : label_prefix + | case_prefix + | default_prefix + ; + +command + : unlabelled_command + | prefix command + | prefix + ; // 8.8.10 Blocks and compound commands -command_list : command (';' command)* ; -declaration_part : declaration (';' declaration)* ; -block : '$(' declaration_part ';' command_list '$)' ; -compound_command : '$(' command_list '$)' ; +command_list + : command (';' command)* + ; + +declaration_part + : declaration (';' declaration)* + ; + +block + : '$(' declaration_part ';' command_list '$)' + ; + +compound_command + : '$(' command_list '$)' + ; + // Extended // program : declaration_part ; -program : (declaration_part | directive) ; +program + : (declaration_part | directive) + ; // Extended -directive : 'GET' string_constant | 'SECTION' string_constant ; +directive + : 'GET' string_constant + | 'SECTION' string_constant + ; // Extended -Comment : ('/*' .*? '*/' | '//' ~('\n' | '\r')*) -> channel(HIDDEN) ; -WS : [ \r\n] -> channel(HIDDEN) ; +Comment + : ('/*' .*? '*/' | '//' ~('\n' | '\r')*) -> channel(HIDDEN) + ; + +WS + : [ \r\n] -> channel(HIDDEN) + ; + +Rem + : 'REM' + ; + +Eqv + : 'EQV' + ; + +Neqv + : 'NEQV' + ; + +True + : 'TRUE' + ; + +False + : 'FALSE' + ; -Rem : 'REM' ; -Eqv : 'EQV' ; -Neqv : 'NEQV' ; -True : 'TRUE' ; -False : 'FALSE' ; -Table : 'TABLE' ; +Table + : 'TABLE' + ; -Left_dollar_open : '$(' ; +Left_dollar_open + : '$(' + ; \ No newline at end of file diff --git a/bdf/bdf.g4 b/bdf/bdf.g4 index 82aaa2f73f..eabbe5b37f 100644 --- a/bdf/bdf.g4 +++ b/bdf/bdf.g4 @@ -22,156 +22,250 @@ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -grammar bdf; - -font: startfont EOF; - -startfont: - 'STARTFONT' ARG ( - fontdecl - | sizedecl - | fontboundingboxdecl - | propertiesdecl - | charsdecl - | chardecl - )+ 'ENDFONT'; - -fontdecl: 'FONT' ARG; - -sizedecl: 'SIZE' ARG ARG ARG; - -fontboundingboxdecl: 'FONTBOUNDINGBOX' ARG ARG ARG ARG; - -propertiesdecl: - 'STARTPROPERTIES' ARG ( - fontascentdecl - | fontdecentdecl - | foundrydecl - | familynanmedecl - | weightnamedecl - | slantdecl - | setwidthnamedecl - | addstylenamedecl - | pixelsizedecl - | pointsizedecl - | resolutionxdecl - | resolutionydecl - | spacingdecl - | averagewidthdecl - | charsetregistrydecl - | charsetencoding - | fontnameregistry - | charsetcollectionsdecl - | fontnamedecl - | facenamedecl - | copyrightdecl - | fontversiondecl - | underlinepositiondecl - | underlinethicknessdecl - | xheightdecl - | capheighdecl - | rawascentdecl - | rawdescentdecl - | normspacedecl - | relativeweightdecl - | relaticesetwidthdecl - | figurewidthdecl - | avglowercasewidthdecl - | avguppercasewidthdecl - )* 'ENDPROPERTIES'; - -foundrydecl: 'FOUNDRY' QUOTEDSTRING; - -familynanmedecl: 'FAMILY_NAME' QUOTEDSTRING; - -weightnamedecl: 'WEIGHT_NAME' QUOTEDSTRING; - -slantdecl: 'SLANT' QUOTEDSTRING; - -setwidthnamedecl: 'SETWIDTH_NAME' QUOTEDSTRING; - -addstylenamedecl: 'ADD_STYLE_NAME' QUOTEDSTRING; - -pixelsizedecl: 'PIXEL_SIZE' ARG; - -pointsizedecl: 'POINT_SIZE' ARG; - -resolutionxdecl: 'RESOLUTION_X' ARG; -resolutionydecl: 'RESOLUTION_Y' ARG; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -spacingdecl: 'SPACING' QUOTEDSTRING; - -averagewidthdecl: 'AVERAGE_WIDTH' ARG; - -charsetregistrydecl: 'CHARSET_REGISTRY' QUOTEDSTRING; - -charsetencoding: 'CHARSET_ENCODING' QUOTEDSTRING; - -fontnameregistry: 'FONTNAME_REGISTRY' QUOTEDSTRING; - -fontascentdecl: 'FONT_ASCENT' ARG; - -charsetcollectionsdecl: 'CHARSET_COLLECTIONS' QUOTEDSTRING; - -fontnamedecl: 'FONT_NAME' QUOTEDSTRING; - -facenamedecl: 'FACE_NAME' QUOTEDSTRING; - -copyrightdecl: 'COPYRIGHT' QUOTEDSTRING; - -fontdecentdecl: 'FONT_DESCENT' ARG; - -fontversiondecl: 'FONT_VERSION' QUOTEDSTRING; - -underlinepositiondecl: 'UNDERLINE_POSITION' ARG; - -underlinethicknessdecl: 'UNDERLINE_THICKNESS' ARG; - -xheightdecl: 'X_HEIGHT' ARG; +grammar bdf; -capheighdecl: 'CAP_HEIGHT' ARG; +font + : startfont EOF + ; + +startfont + : 'STARTFONT' ARG ( + fontdecl + | sizedecl + | fontboundingboxdecl + | propertiesdecl + | charsdecl + | chardecl + )+ 'ENDFONT' + ; + +fontdecl + : 'FONT' ARG + ; + +sizedecl + : 'SIZE' ARG ARG ARG + ; + +fontboundingboxdecl + : 'FONTBOUNDINGBOX' ARG ARG ARG ARG + ; + +propertiesdecl + : 'STARTPROPERTIES' ARG ( + fontascentdecl + | fontdecentdecl + | foundrydecl + | familynanmedecl + | weightnamedecl + | slantdecl + | setwidthnamedecl + | addstylenamedecl + | pixelsizedecl + | pointsizedecl + | resolutionxdecl + | resolutionydecl + | spacingdecl + | averagewidthdecl + | charsetregistrydecl + | charsetencoding + | fontnameregistry + | charsetcollectionsdecl + | fontnamedecl + | facenamedecl + | copyrightdecl + | fontversiondecl + | underlinepositiondecl + | underlinethicknessdecl + | xheightdecl + | capheighdecl + | rawascentdecl + | rawdescentdecl + | normspacedecl + | relativeweightdecl + | relaticesetwidthdecl + | figurewidthdecl + | avglowercasewidthdecl + | avguppercasewidthdecl + )* 'ENDPROPERTIES' + ; + +foundrydecl + : 'FOUNDRY' QUOTEDSTRING + ; + +familynanmedecl + : 'FAMILY_NAME' QUOTEDSTRING + ; + +weightnamedecl + : 'WEIGHT_NAME' QUOTEDSTRING + ; + +slantdecl + : 'SLANT' QUOTEDSTRING + ; + +setwidthnamedecl + : 'SETWIDTH_NAME' QUOTEDSTRING + ; + +addstylenamedecl + : 'ADD_STYLE_NAME' QUOTEDSTRING + ; + +pixelsizedecl + : 'PIXEL_SIZE' ARG + ; + +pointsizedecl + : 'POINT_SIZE' ARG + ; + +resolutionxdecl + : 'RESOLUTION_X' ARG + ; + +resolutionydecl + : 'RESOLUTION_Y' ARG + ; + +spacingdecl + : 'SPACING' QUOTEDSTRING + ; + +averagewidthdecl + : 'AVERAGE_WIDTH' ARG + ; + +charsetregistrydecl + : 'CHARSET_REGISTRY' QUOTEDSTRING + ; + +charsetencoding + : 'CHARSET_ENCODING' QUOTEDSTRING + ; + +fontnameregistry + : 'FONTNAME_REGISTRY' QUOTEDSTRING + ; + +fontascentdecl + : 'FONT_ASCENT' ARG + ; + +charsetcollectionsdecl + : 'CHARSET_COLLECTIONS' QUOTEDSTRING + ; + +fontnamedecl + : 'FONT_NAME' QUOTEDSTRING + ; + +facenamedecl + : 'FACE_NAME' QUOTEDSTRING + ; + +copyrightdecl + : 'COPYRIGHT' QUOTEDSTRING + ; + +fontdecentdecl + : 'FONT_DESCENT' ARG + ; + +fontversiondecl + : 'FONT_VERSION' QUOTEDSTRING + ; + +underlinepositiondecl + : 'UNDERLINE_POSITION' ARG + ; + +underlinethicknessdecl + : 'UNDERLINE_THICKNESS' ARG + ; + +xheightdecl + : 'X_HEIGHT' ARG + ; -rawascentdecl: 'RAW_ASCENT' ARG; +capheighdecl + : 'CAP_HEIGHT' ARG + ; -rawdescentdecl: 'RAW_DESCENT' ARG; +rawascentdecl + : 'RAW_ASCENT' ARG + ; -normspacedecl: 'NORM_SPACE' ARG; +rawdescentdecl + : 'RAW_DESCENT' ARG + ; -relativeweightdecl: 'RELATIVE_WEIGHT' ARG; +normspacedecl + : 'NORM_SPACE' ARG + ; -relaticesetwidthdecl: 'RELATIVE_SETWIDTH' ARG; +relativeweightdecl + : 'RELATIVE_WEIGHT' ARG + ; -figurewidthdecl: 'FIGURE_WIDTH' ARG; +relaticesetwidthdecl + : 'RELATIVE_SETWIDTH' ARG + ; -avglowercasewidthdecl: 'AVG_LOWERCASE_WIDTH' ARG; +figurewidthdecl + : 'FIGURE_WIDTH' ARG + ; -avguppercasewidthdecl: 'AVG_UPPERCASE_WIDTH' ARG; +avglowercasewidthdecl + : 'AVG_LOWERCASE_WIDTH' ARG + ; -charsdecl: 'CHARS' ARG; +avguppercasewidthdecl + : 'AVG_UPPERCASE_WIDTH' ARG + ; -chardecl: - 'STARTCHAR' ARG ( - encodingdecl - | swidthdecl - | dwidthdecl - | bbxdecl - | bitmapdecl - )* 'ENDCHAR'; +charsdecl + : 'CHARS' ARG + ; -encodingdecl: 'ENCODING' ARG; +chardecl + : 'STARTCHAR' ARG (encodingdecl | swidthdecl | dwidthdecl | bbxdecl | bitmapdecl)* 'ENDCHAR' + ; -swidthdecl: 'SWIDTH' ARG ARG; +encodingdecl + : 'ENCODING' ARG + ; -dwidthdecl: 'DWIDTH' ARG ARG; +swidthdecl + : 'SWIDTH' ARG ARG + ; -bbxdecl: 'BBX' ARG ARG ARG ARG; +dwidthdecl + : 'DWIDTH' ARG ARG + ; -bitmapdecl: 'BITMAP' ARG*; +bbxdecl + : 'BBX' ARG ARG ARG ARG + ; -ARG: ('U' '+')? '-'? [a-zA-Z0-9-.]+ ('.' [0-9A-Fa-f]+)?; +bitmapdecl + : 'BITMAP' ARG* + ; -QUOTEDSTRING: '"' .*? '"'; +ARG + : ('U' '+')? '-'? [a-zA-Z0-9-.]+ ('.' [0-9A-Fa-f]+)? + ; -WS: [ \r\n\t]+ -> skip; +QUOTEDSTRING + : '"' .*? '"' + ; +WS + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/bencoding/BencodingLexer.g4 b/bencoding/BencodingLexer.g4 index db29b7993f..6252016e21 100644 --- a/bencoding/BencodingLexer.g4 +++ b/bencoding/BencodingLexer.g4 @@ -1,35 +1,27 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar BencodingLexer; -options { superClass=BencodingLexerBase; } +options { + superClass = BencodingLexerBase; +} -INT_START - : 'i' - ; +INT_START: 'i'; -INTEGER - : '-'? [0-9]+ - ; +INTEGER: '-'? [0-9]+; -STRING_START - : [0-9]+ ':' {setStringLength();} -> skip, pushMode(StringMode) - ; +STRING_START: [0-9]+ ':' {setStringLength();} -> skip, pushMode(StringMode); -LIST_START - : 'l' - ; +LIST_START: 'l'; -DICT_START - : 'd' - ; +DICT_START: 'd'; -END - : 'e' - ; +END: 'e'; -OTHER - : . - ; +OTHER: .; mode StringMode; - STRING : ( {consumeStringChars()}? . )+ -> popMode; \ No newline at end of file +STRING: ({consumeStringChars()}? .)+ -> popMode; \ No newline at end of file diff --git a/bencoding/BencodingParser.g4 b/bencoding/BencodingParser.g4 index 4c19e1bee2..ee770c767b 100644 --- a/bencoding/BencodingParser.g4 +++ b/bencoding/BencodingParser.g4 @@ -1,37 +1,40 @@ +// $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 BencodingParser; options { - tokenVocab=BencodingLexer; + tokenVocab = BencodingLexer; } // https://wiki.theory.org/BitTorrentSpecification#Bencoding data - : values EOF - ; + : values EOF + ; values - : value* - ; + : value* + ; value - : integer - | STRING - | list - | dict - ; + : integer + | STRING + | list + | dict + ; integer - : INT_START INTEGER END - ; + : INT_START INTEGER END + ; list - : LIST_START values END - ; + : LIST_START values END + ; dict - : DICT_START key_value* END - ; + : DICT_START key_value* END + ; key_value - : STRING value - ; \ No newline at end of file + : STRING value + ; \ No newline at end of file diff --git a/bibcode/bibcode.g4 b/bibcode/bibcode.g4 index 197df42564..98dc87205d 100644 --- a/bibcode/bibcode.g4 +++ b/bibcode/bibcode.g4 @@ -32,66 +32,72 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://web.archive.org/web/20110607153038/http://cdsweb.u-strasbg.fr/simbad/refcode/refcode-paper.html +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar bibcode; bibcode - : year publish volume pagesection author EOF - ; + : year publish volume pagesection author EOF + ; year - : DIGIT DIGIT DIGIT DIGIT - ; + : DIGIT DIGIT DIGIT DIGIT + ; publish - : (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) - ; + : (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) ( + letter + | digit + | DOT + ) + ; volume - : (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) - ; + : (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) (letter | digit | DOT) + ; pagesection - : section? page - ; + : section? page + ; section - : letter - ; + : letter + ; page - : (digit | DOT)+ - ; + : (digit | DOT)+ + ; author - : letter - ; + : letter + ; DOT - : '.' - ; + : '.' + ; letter - : UPPERLETTER - | LOWERLETTER - ; + : UPPERLETTER + | LOWERLETTER + ; digit - : DIGIT - ; + : DIGIT + ; UPPERLETTER - : [A-Z] - ; + : [A-Z] + ; LOWERLETTER - : [a-z] - ; + : [a-z] + ; DIGIT - : [0-9] - ; + : [0-9] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/bibtex/BibTeXLexer.g4 b/bibtex/BibTeXLexer.g4 index 32e0049161..95c503a045 100644 --- a/bibtex/BibTeXLexer.g4 +++ b/bibtex/BibTeXLexer.g4 @@ -21,151 +21,93 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar BibTeXLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} // Keywords -ARTICLE: - AT 'article' - ; - -BOOK: - AT 'book' - ; +ARTICLE: AT 'article'; -BOOKLET: - AT 'booklet' - ; +BOOK: AT 'book'; -INBOOK: - AT 'inbook' - ; +BOOKLET: AT 'booklet'; -INCOLLECTION: - AT 'incollection' - ; +INBOOK: AT 'inbook'; -INPROCEEDINGS: - AT 'inproceedings' - ; +INCOLLECTION: AT 'incollection'; -PROCEEDINGS: - AT 'proceedings' - ; +INPROCEEDINGS: AT 'inproceedings'; -MANUAL: - AT 'manual' - ; +PROCEEDINGS: AT 'proceedings'; -MASTERTHESIS: - AT 'masterthesis' - ; +MANUAL: AT 'manual'; -PHDTHESIS: - AT 'phdthesis' - ; +MASTERTHESIS: AT 'masterthesis'; -MISC: - AT 'misc' - ; +PHDTHESIS: AT 'phdthesis'; -TECHREPORT: - AT 'techreport' - ; +MISC: AT 'misc'; -UNPUBLISHED: - AT 'unpublished' - ; +TECHREPORT: AT 'techreport'; +UNPUBLISHED: AT 'unpublished'; // Identifiers -IDENTIFIER - : [a-zA-Z_] [a-zA-Z_0-9-]* - ; +IDENTIFIER: [a-zA-Z_] [a-zA-Z_0-9-]*; // Operators -EQ - : '=' - ; - +EQ: '='; // Punctuation -COMMA - : ',' - ; +COMMA: ','; -DQUOTE - : '"' - ; +DQUOTE: '"'; // Delimiters -LPAREN - : '(' - ; -RPAREN - : ')' - ; -LBRACE - : '{' - ; -RBRACE - : '}' - ; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; // Symbols -AT - : '@' - ; - +AT: '@'; // Literals -STRING_LITERAL - : LBRACE (ESC | BRACE_ENCLOSED_SAFECODEPOINT)* RBRACE +STRING_LITERAL: + LBRACE (ESC | BRACE_ENCLOSED_SAFECODEPOINT)* RBRACE | DQUOTE (ESC | QUOTE_ENCLOSED_SAFECODEPOINT)* DQUOTE - ; +; -INTEGER_LITERAL - : (LBRACE | DQUOTE)? INTEGER (RBRACE | DQUOTE)? - ; +INTEGER_LITERAL: (LBRACE | DQUOTE)? INTEGER (RBRACE | DQUOTE)?; // Fragments -fragment ESC - : '\\' (["\\/bfnrt] | UNICODE) - ; +fragment ESC: '\\' (["\\/bfnrt] | UNICODE); -fragment UNICODE - : 'u' HEX HEX HEX HEX - ; +fragment UNICODE: 'u' HEX HEX HEX HEX; -fragment INTEGER - : '0' | [1-9] [0-9]* - ; +fragment INTEGER: '0' | [1-9] [0-9]*; -fragment HEX - : [0-9a-fA-F] - ; +fragment HEX: [0-9a-fA-F]; -fragment QUOTE_ENCLOSED_SAFECODEPOINT - : ~ ["\\\u0000-\u001F] - ; +fragment QUOTE_ENCLOSED_SAFECODEPOINT: ~ ["\\\u0000-\u001F]; -fragment BRACE_ENCLOSED_SAFECODEPOINT - : ~ [\\\u0000-\u001F] - ; +fragment BRACE_ENCLOSED_SAFECODEPOINT: ~ [\\\u0000-\u001F]; // Whitespace and Comment -WS: - [ \t\r\n\u000C]+ -> skip - ; +WS: [ \t\r\n\u000C]+ -> skip; -LINE_COMMENT - : '%' ~[\r\n]* -> skip - ; \ No newline at end of file +LINE_COMMENT: '%' ~[\r\n]* -> skip; \ No newline at end of file diff --git a/bibtex/BibTeXParser.g4 b/bibtex/BibTeXParser.g4 index 6f5f45da18..775334f0d4 100644 --- a/bibtex/BibTeXParser.g4 +++ b/bibtex/BibTeXParser.g4 @@ -21,9 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + +// $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 BibTeXParser; -options { tokenVocab=BibTeXLexer; } +options { + tokenVocab = BibTeXLexer; +} bibTex : entry* EOF diff --git a/bicep/Bicep.g4 b/bicep/Bicep.g4 index 304aae9464..c7cfcc9396 100644 --- a/bicep/Bicep.g4 +++ b/bicep/Bicep.g4 @@ -1,9 +1,12 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Bicep; // program -> statement* EOF program - : statement* EOF - ; + : statement* EOF + ; // statement -> // targetScopeDecl | @@ -17,99 +20,104 @@ program // outputDecl | // NL statement - : targetScopeDecl - | importDecl - | metadataDecl - | parameterDecl - | typeDecl - | variableDecl - | resourceDecl - | moduleDecl - | outputDecl - | NL - ; + : targetScopeDecl + | importDecl + | metadataDecl + | parameterDecl + | typeDecl + | variableDecl + | resourceDecl + | moduleDecl + | outputDecl + | NL + ; // targetScopeDecl -> "targetScope" "=" expression targetScopeDecl - : TARGET_SCOPE ASSIGN expression - ; + : TARGET_SCOPE ASSIGN expression + ; // importDecl -> decorator* "import" interpString(specification) importWithClause? importAsClause? NL importDecl - : decorator* IMPORT specification=interpString importWithClause? importAsClause? NL - ; + : decorator* IMPORT specification = interpString importWithClause? importAsClause? NL + ; // importWithClause -> "with" object importWithClause - : WITH object - ; + : WITH object + ; // importAsClause -> "as" IDENTIFIER(alias) importAsClause - : AS alias=identifier - ; + : AS alias = identifier + ; // metadataDecl -> "metadata" IDENTIFIER(name) "=" expression NL metadataDecl - : METADATA name=identifier ASSIGN expression NL - ; + : METADATA name = identifier ASSIGN expression NL + ; // parameterDecl -> // decorator* "parameter" IDENTIFIER(name) typeExpression parameterDefaultValue? NL | // decorator* "parameter" IDENTIFIER(name) "resource" interpString(type) parameterDefaultValue? NL | parameterDecl - : decorator* PARAM name=identifier ( typeExpression parameterDefaultValue? - | RESOURCE type=interpString parameterDefaultValue? - ) - NL - ; + : decorator* PARAM name = identifier ( + typeExpression parameterDefaultValue? + | RESOURCE type = interpString parameterDefaultValue? + ) NL + ; // parameterDefaultValue -> "=" expression parameterDefaultValue - : ASSIGN expression - ; + : ASSIGN expression + ; // typeDecl -> decorator* "type" IDENTIFIER(name) "=" typeExpression NL typeDecl - : decorator* TYPE name=identifier ASSIGN typeExpression NL - ; + : decorator* TYPE name = identifier ASSIGN typeExpression NL + ; // variableDecl -> decorator* "variable" IDENTIFIER(name) "=" expression NL variableDecl - : decorator* VAR name=identifier ASSIGN expression NL - ; + : decorator* VAR name = identifier ASSIGN expression NL + ; // resourceDecl -> decorator* "resource" IDENTIFIER(name) interpString(type) "existing"? "=" (ifCondition | object | forExpression) NL resourceDecl - : decorator* RESOURCE name=identifier type=interpString EXISTING? ASSIGN ( ifCondition | object | forExpression ) NL - ; + : decorator* RESOURCE name = identifier type = interpString EXISTING? ASSIGN ( + ifCondition + | object + | forExpression + ) NL + ; // moduleDecl -> decorator* "module" IDENTIFIER(name) interpString(type) "=" (ifCondition | object | forExpression) NL moduleDecl - : decorator* MODULE name=identifier type=interpString ASSIGN ( ifCondition | object | forExpression ) NL - ; + : decorator* MODULE name = identifier type = interpString ASSIGN ( + ifCondition + | object + | forExpression + ) NL + ; // outputDecl -> // decorator* "output" IDENTIFIER(name) IDENTIFIER(type) "=" expression NL // decorator* "output" IDENTIFIER(name) "resource" interpString(type) "=" expression NL outputDecl - : decorator* OUTPUT name=identifier ( type1=identifier - | RESOURCE type2=interpString - ) - ASSIGN expression NL - ; + : decorator* OUTPUT name = identifier (type1 = identifier | RESOURCE type2 = interpString) ASSIGN expression NL + ; // decorator -> "@" decoratorExpression NL decorator - : AT decoratorExpression NL - ; + : AT decoratorExpression NL + ; // expression -> // binaryExpression | // binaryExpression "?" expression ":" expression expression - : binaryExpression ( QMARK expression COL expression )? - ; + : binaryExpression (QMARK expression COL expression)? + ; // binaryExpression -> // equalityExpression | @@ -117,18 +125,18 @@ expression // binaryExpression "||" equalityExpression | // binaryExpression "??" equalityExpression binaryExpression - : binaryExpression ( AND | OR | COALESCE ) equalityExpression - | equalityExpression - ; + : binaryExpression (AND | OR | COALESCE) equalityExpression + | equalityExpression + ; // equalityExpression -> // relationalExpression | // equalityExpression "==" relationalExpression | // equalityExpression "!=" relationalExpression equalityExpression - : equalityExpression ( EQ | NEQ ) relationalExpression - | relationalExpression - ; + : equalityExpression (EQ | NEQ) relationalExpression + | relationalExpression + ; // relationalExpression -> // additiveExpression | @@ -137,18 +145,18 @@ equalityExpression // relationalExpression "<" additiveExpression | // relationalExpression "<=" additiveExpression relationalExpression - : relationalExpression ( GT | GTE | LT | LTE ) additiveExpression - | additiveExpression - ; + : relationalExpression (GT | GTE | LT | LTE) additiveExpression + | additiveExpression + ; // additiveExpression -> // multiplicativeExpression | // additiveExpression "+" multiplicativeExpression | // additiveExpression "-" multiplicativeExpression additiveExpression - : additiveExpression ( ADD | MIN ) multiplicativeExpression - | multiplicativeExpression - ; + : additiveExpression (ADD | MIN) multiplicativeExpression + | multiplicativeExpression + ; // multiplicativeExpression -> // unaryExpression | @@ -156,24 +164,24 @@ additiveExpression // multiplicativeExpression "/" unaryExpression | // multiplicativeExpression "%" unaryExpression multiplicativeExpression - : multiplicativeExpression ( MUL | DIV | MOD ) unaryExpression - | unaryExpression - ; + : multiplicativeExpression (MUL | DIV | MOD) unaryExpression + | unaryExpression + ; // unaryExpression -> // memberExpression | // unaryOperator unaryExpression unaryExpression - : memberExpression - | unaryOperator unaryExpression - ; + : memberExpression + | unaryOperator unaryExpression + ; // unaryOperator -> "!" | "-" | "+" unaryOperator - : NOT - | MIN - | ADD - ; + : NOT + | MIN + | ADD + ; // // memberExpression -> @@ -183,12 +191,12 @@ unaryOperator // memberExpression "." functionCall // memberExpression ":" IDENTIFIER(name) memberExpression - : memberExpression OBRACK expression CBRACK - | memberExpression DOT property=identifier - | memberExpression DOT functionCall - | memberExpression COL name=identifier - | primaryExpression - ; + : memberExpression OBRACK expression CBRACK + | memberExpression DOT property = identifier + | memberExpression DOT functionCall + | memberExpression COL name = identifier + | primaryExpression + ; // primaryExpression -> // functionCall | @@ -201,113 +209,113 @@ memberExpression // parenthesizedExpression | // lambdaExpression primaryExpression - : functionCall - | literalValue - | interpString - | MULTILINE_STRING - | array - | forExpression - | object - | parenthesizedExpression - | lambdaExpression - ; + : functionCall + | literalValue + | interpString + | MULTILINE_STRING + | array + | forExpression + | object + | parenthesizedExpression + | lambdaExpression + ; // decoratorExpression -> functionCall | memberExpression "." functionCall decoratorExpression - : functionCall - | memberExpression DOT functionCall - ; + : functionCall + | memberExpression DOT functionCall + ; // functionCall -> IDENTIFIER "(" argumentList? ")" functionCall - : identifier OPAR argumentList? CPAR - ; + : identifier OPAR argumentList? CPAR + ; // argumentList -> expression ("," expression)* argumentList - : expression ( COMMA expression )* - ; + : expression (COMMA expression)* + ; // parenthesizedExpression -> "(" expression ")" parenthesizedExpression - : OPAR expression CPAR - ; + : OPAR expression CPAR + ; // lambdaExpression -> ( "(" argumentList? ")" | IDENTIFIER ) "=>" expression lambdaExpression - : ( OPAR argumentList? CPAR | identifier ) ARROW expression - ; + : (OPAR argumentList? CPAR | identifier) ARROW expression + ; // ifCondition -> "if" parenthesizedExpression object ifCondition - : IF parenthesizedExpression object - ; + : IF parenthesizedExpression object + ; // forExpression -> "[" "for" (IDENTIFIER(item) | forVariableBlock) "in" expression ":" forBody "]" forExpression - : OBRACK FOR ( item=identifier | forVariableBlock ) IN expression COL forBody CBRACK - ; + : OBRACK FOR (item = identifier | forVariableBlock) IN expression COL forBody CBRACK + ; // forVariableBlock -> "(" IDENTIFIER(item) "," IDENTIFIER(index) ")" forVariableBlock - : OPAR item=identifier COMMA index=identifier CPAR - ; + : OPAR item = identifier COMMA index = identifier CPAR + ; // forBody -> expression(body) | ifCondition forBody - : body=expression - | ifCondition - ; + : body = expression + | ifCondition + ; // interpString -> stringLeftPiece ( expression stringMiddlePiece )* expression stringRightPiece | stringComplete interpString - : STRING_LEFT_PIECE ( expression STRING_MIDDLE_PIECE )* expression STRING_RIGHT_PIECE - | STRING_COMPLETE - ; + : STRING_LEFT_PIECE (expression STRING_MIDDLE_PIECE)* expression STRING_RIGHT_PIECE + | STRING_COMPLETE + ; // literalValue -> NUMBER | "true" | "false" | "null" literalValue - : NUMBER - | TRUE - | FALSE - | NULL - | identifier - ; + : NUMBER + | TRUE + | FALSE + | NULL + | identifier + ; // object -> "{" ( NL+ ( objectProperty NL+ )* )? "}" object - : OBRACE ( NL+ ( objectProperty NL+ )* )? CBRACE - ; + : OBRACE (NL+ ( objectProperty NL+)*)? CBRACE + ; // objectProperty -> ( IDENTIFIER(name) | interpString ) ":" expression objectProperty - : ( name=identifier | interpString ) COL expression - ; + : (name = identifier | interpString) COL expression + ; // array -> "[" ( NL+ arrayItem* )? "]" array - : OBRACK ( NL+ arrayItem* )? CBRACK - ; + : OBRACK (NL+ arrayItem*)? CBRACK + ; // arrayItem -> expression NL+ arrayItem - : expression NL+ - ; + : expression NL+ + ; // typeExpression -> singularTypeExpression ("|" singularTypeExpression)* typeExpression - : singularTypeExpression ( PIPE singularTypeExpression )* - ; + : singularTypeExpression (PIPE singularTypeExpression)* + ; // singularTypeExpression -> // primaryTypeExpression | // singularTypeExpression "[]" | // parenthesizedTypeExpression singularTypeExpression - : primaryTypeExpression - | singularTypeExpression OBRACK CBRACK - | parenthesizedTypeExpression - ; + : primaryTypeExpression + | singularTypeExpression OBRACK CBRACK + | parenthesizedTypeExpression + ; // primaryTypeExpression -> // ambientTypeReference | @@ -319,195 +327,362 @@ singularTypeExpression // objectType | // tupleType primaryTypeExpression - : ambientTypeReference - | type=identifier - | unaryOperator? literalValue - | STRING_COMPLETE - | MULTILINE_STRING - | objectType - | tupleType - ; + : ambientTypeReference + | type = identifier + | unaryOperator? literalValue + | STRING_COMPLETE + | MULTILINE_STRING + | objectType + | tupleType + ; // ambientTypeReference -> "string" | "int" | "bool" | "array" | "object" ambientTypeReference - : STRING - | INT - | INT - | ARRAY - | OBJECT - ; + : STRING + | INT + | INT + | ARRAY + | OBJECT + ; // objectType -> "{" (NL+ ((objectTypeProperty | objectTypeAdditionalPropertiesMatcher) NL+ )* )? "}" objectType - : OBRACE (NL+ ( ( objectTypeProperty | objectTypeAdditionalPropertiesMatcher ) NL+ )* )? CBRACE - ; + : OBRACE (NL+ ( ( objectTypeProperty | objectTypeAdditionalPropertiesMatcher) NL+)*)? CBRACE + ; // objectTypeProperty -> decorator* ( IDENTIFIER(name) | stringComplete | multilineString ) ":" typeExpression objectTypeProperty - : decorator* ( name=identifier | STRING_COMPLETE | MULTILINE_STRING ) COL typeExpression - ; + : decorator* (name = identifier | STRING_COMPLETE | MULTILINE_STRING) COL typeExpression + ; // objectTypeAdditionalPropertiesMatcher -> decorator* "*:" typeExpression objectTypeAdditionalPropertiesMatcher - : decorator* STAR_COL typeExpression - ; + : decorator* STAR_COL typeExpression + ; // tupleType -> "[" (NL+ tupleItem* )? "]" tupleType - : OBRACK ( NL+ tupleItem* )? CBRACK - ; + : OBRACK (NL+ tupleItem*)? CBRACK + ; // tupleItem -> decorator* typeExpression NL+ tupleItem - : decorator* typeExpression NL+ - ; + : decorator* typeExpression NL+ + ; // parenthesizedTypeExpression -> "(" typeExpression ")" parenthesizedTypeExpression - : OPAR typeExpression CPAR - ; + : OPAR typeExpression CPAR + ; identifier - : IDENTIFIER - | IMPORT - | WITH - | AS - | METADATA - | PARAM - | RESOURCE - | MODULE - | OUTPUT - | EXISTING - | TYPE - | VAR - | IF - | FOR - | IN - | TRUE - | FALSE - | NULL - | TARGET_SCOPE - | STRING - | INT - | BOOL - | ARRAY - | OBJECT - ; + : IDENTIFIER + | IMPORT + | WITH + | AS + | METADATA + | PARAM + | RESOURCE + | MODULE + | OUTPUT + | EXISTING + | TYPE + | VAR + | IF + | FOR + | IN + | TRUE + | FALSE + | NULL + | TARGET_SCOPE + | STRING + | INT + | BOOL + | ARRAY + | OBJECT + ; // disableNextLineDiagnosticsDirective-> #disable-next-line diagnosticCode1 diagnosticCode2 diagnosticCode3 NL DISABLE_NEXT_LINE_DIAGNOSTIC_DIRECTIVE - : '#disable-next-line' ~[\r\n]+ NL -> skip - ; + : '#disable-next-line' ~[\r\n]+ NL -> skip + ; SINGLE_LINE_COMMENT - : '//' ~[\r\n]* -> skip - ; + : '//' ~[\r\n]* -> skip + ; MULTI_LINE_COMMENT - : '/*' .*? '*/' -> skip - ; + : '/*' .*? '*/' -> skip + ; // multilineString -> "'''" + MULTILINESTRINGCHAR+ + "'''" MULTILINE_STRING - : '\'\'\'' .*? '\'\'\'' - ; + : '\'\'\'' .*? '\'\'\'' + ; // stringLeftPiece -> "'" STRINGCHAR* "${" STRING_LEFT_PIECE - : '\'' STRINGCHAR* '${' - ; + : '\'' STRINGCHAR* '${' + ; // stringMiddlePiece -> "}" STRINGCHAR* "${" STRING_MIDDLE_PIECE - : '}' STRINGCHAR* '${' - ; + : '}' STRINGCHAR* '${' + ; // stringRightPiece -> "}" STRINGCHAR* "'" STRING_RIGHT_PIECE - : '}' STRINGCHAR* '\'' - ; + : '}' STRINGCHAR* '\'' + ; // stringComplete -> "'" STRINGCHAR* "'" STRING_COMPLETE - : '\'' STRINGCHAR* '\'' - ; - -ARROW : '=>'; -AT : '@'; -COMMA : ','; -PIPE : '|'; -STAR_COL : '*:'; -OBRACK : '['; -CBRACK : ']'; -OPAR : '('; -CPAR : ')'; -DOT : '.'; -NOT : '!'; -MUL : '*'; -DIV : '/'; -MOD : '%'; -ADD : '+'; -MIN : '-'; -GT : '>'; -GTE : '>='; -LT : '<'; -LTE : '<='; -EQ : '=='; -NEQ : '!='; -AND : '&&'; -OR : 'OR'; -COALESCE : '??'; -QMARK : '?'; -COL : ':'; -ASSIGN : '='; -OBRACE : '{'; -CBRACE : '}'; - -IMPORT : 'import'; -WITH : 'with'; -AS : 'as'; -METADATA : 'metadata'; -PARAM : 'param'; -RESOURCE : 'resource'; -MODULE : 'module'; -OUTPUT : 'output'; -EXISTING : 'existing'; -TYPE : 'type'; -VAR : 'var'; -IF : 'if'; -FOR : 'for'; -IN : 'in'; -TRUE : 'true'; -FALSE : 'false'; -NULL : 'null'; -TARGET_SCOPE : 'targetScope'; -STRING : 'string'; -INT : 'int'; -BOOL : 'bool'; -ARRAY : 'array'; -OBJECT : 'object'; - -IDENTIFIER : [a-zA-Z_] [a-zA-Z_0-9]*; - -NUMBER : [0-9]+ ( '.' [0-9]+ )?; + : '\'' STRINGCHAR* '\'' + ; + +ARROW + : '=>' + ; + +AT + : '@' + ; + +COMMA + : ',' + ; + +PIPE + : '|' + ; + +STAR_COL + : '*:' + ; + +OBRACK + : '[' + ; + +CBRACK + : ']' + ; + +OPAR + : '(' + ; + +CPAR + : ')' + ; + +DOT + : '.' + ; + +NOT + : '!' + ; + +MUL + : '*' + ; + +DIV + : '/' + ; + +MOD + : '%' + ; + +ADD + : '+' + ; + +MIN + : '-' + ; + +GT + : '>' + ; + +GTE + : '>=' + ; + +LT + : '<' + ; + +LTE + : '<=' + ; + +EQ + : '==' + ; + +NEQ + : '!=' + ; + +AND + : '&&' + ; + +OR + : 'OR' + ; + +COALESCE + : '??' + ; + +QMARK + : '?' + ; + +COL + : ':' + ; + +ASSIGN + : '=' + ; + +OBRACE + : '{' + ; + +CBRACE + : '}' + ; + +IMPORT + : 'import' + ; + +WITH + : 'with' + ; + +AS + : 'as' + ; + +METADATA + : 'metadata' + ; + +PARAM + : 'param' + ; + +RESOURCE + : 'resource' + ; + +MODULE + : 'module' + ; + +OUTPUT + : 'output' + ; + +EXISTING + : 'existing' + ; + +TYPE + : 'type' + ; + +VAR + : 'var' + ; + +IF + : 'if' + ; + +FOR + : 'for' + ; + +IN + : 'in' + ; + +TRUE + : 'true' + ; + +FALSE + : 'false' + ; + +NULL + : 'null' + ; + +TARGET_SCOPE + : 'targetScope' + ; + +STRING + : 'string' + ; + +INT + : 'int' + ; + +BOOL + : 'bool' + ; + +ARRAY + : 'array' + ; + +OBJECT + : 'object' + ; + +IDENTIFIER + : [a-zA-Z_] [a-zA-Z_0-9]* + ; + +NUMBER + : [0-9]+ ('.' [0-9]+)? + ; // NL -> ("\n" | "\r")+ -NL : [\r\n]+; +NL + : [\r\n]+ + ; -SPACES : [ \t]+ -> skip; +SPACES + : [ \t]+ -> skip + ; -UNKNOWN : .; +UNKNOWN + : . + ; // https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/data-types#strings fragment STRINGCHAR - : ~[\\'\n\r\t$] - | ESCAPE - ; + : ~[\\'\n\r\t$] + | ESCAPE + ; fragment ESCAPE - : '\\' ( [\\'nrt$] | 'u{' HEX+ '}' ) - ; + : '\\' ([\\'nrt$] | 'u{' HEX+ '}') + ; fragment HEX - : [0-9a-fA-F] - ; \ No newline at end of file + : [0-9a-fA-F] + ; \ No newline at end of file diff --git a/bison/BisonLexer.g4 b/bison/BisonLexer.g4 index 43d1a8247d..8ff9a49ece 100644 --- a/bison/BisonLexer.g4 +++ b/bison/BisonLexer.g4 @@ -2,9 +2,15 @@ // Copyright 2020-2022 // MIT License +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar BisonLexer; -options { superClass = BisonLexerBase; } +options { + superClass = BisonLexerBase; +} // Insert here @header for C++ lexer. @@ -14,110 +20,73 @@ tokens { // ======================= Common fragments ========================= -fragment Underscore - : '_' - ; +fragment Underscore: '_'; -fragment NameStartChar - : 'A'..'Z' - | 'a'..'z' +fragment NameStartChar: + 'A' ..'Z' + | 'a' ..'z' | '_' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00F6' + | '\u00F8' ..'\u02FF' + | '\u0370' ..'\u037D' + | '\u037F' ..'\u1FFF' + | '\u200C' ..'\u200D' + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' | '$' // For PHP - ; // ignores | ['\u10000-'\uEFFFF] ; - -fragment DQuoteLiteral - : DQuote ( EscSeq | ~["\r\n\\] | '\\' [\n\r]* )* DQuote - ; - -fragment DQuote - : '"' - ; - -fragment SQuote - : '\'' - ; - -fragment CharLiteral - : SQuote ( EscSeq | ~['\r\n\\] ) SQuote - ; - -fragment SQuoteLiteral - : SQuote ( EscSeq | ~['\r\n\\] )* SQuote - ; - -fragment Esc - : '\\' - ; - -fragment EscSeq - : Esc - ([abefnrtv?"'\\] // The standard escaped character set such as tab, newline, etc. - | [xuU]?[0-9]+) // C-style - ; - -fragment EscAny - : Esc . - ; - -fragment Id - : NameStartChar NameChar* - ; - -fragment Type - : ([\t\r\n\f a-zA-Z0-9] | '[' | ']' | '{' | '}' | '.' | '_' | '(' | ')' | ',')+ - ; - -fragment NameChar - : NameStartChar - | '0'..'9' - | Underscore - | '\u00B7' - | '\u0300'..'\u036F' - | '\u203F'..'\u2040' +; // ignores | ['\u10000-'\uEFFFF] ; + +fragment DQuoteLiteral: DQuote ( EscSeq | ~["\r\n\\] | '\\' [\n\r]*)* DQuote; + +fragment DQuote: '"'; + +fragment SQuote: '\''; + +fragment CharLiteral: SQuote ( EscSeq | ~['\r\n\\]) SQuote; + +fragment SQuoteLiteral: SQuote ( EscSeq | ~['\r\n\\])* SQuote; + +fragment Esc: '\\'; + +fragment EscSeq: + Esc ( + [abefnrtv?"'\\] // The standard escaped character set such as tab, newline, etc. + | [xuU]? [0-9]+ + ) // C-style +; + +fragment EscAny: Esc .; + +fragment Id: NameStartChar NameChar*; + +fragment Type: ([\t\r\n\f a-zA-Z0-9] | '[' | ']' | '{' | '}' | '.' | '_' | '(' | ')' | ',')+; + +fragment NameChar: + NameStartChar + | '0' ..'9' + | Underscore + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' | '.' | '-' - ; - -fragment BlockComment - : '/*' - ( - '/' ~'*' - | ~'/' - )* - '*/' - ; - -fragment LineComment - : '//' ~[\r\n]* - ; - -fragment LineCommentExt - : '//' ~'\n'* ( '\n' Hws* '//' ~'\n'* )* - ; - -fragment Ws - : Hws - | Vws - ; - -fragment Hws - : [ \t] - ; - -fragment Vws - : [\r\n\f] - ; +; + +fragment BlockComment: '/*' ( '/' ~'*' | ~'/')* '*/'; + +fragment LineComment: '//' ~[\r\n]*; + +fragment LineCommentExt: '//' ~'\n'* ( '\n' Hws* '//' ~'\n'*)*; + +fragment Ws: Hws | Vws; + +fragment Hws: [ \t]; + +fragment Vws: [\r\n\f]; /* Four types of user code: - prologue (code between '%{' '%}' in the first section, before %%); @@ -128,318 +97,183 @@ fragment Vws // ------------------------- // Actions -fragment LBrace - : '{' - ; +fragment LBrace: '{'; -fragment RBrace - : '}' - ; +fragment RBrace: '}'; -fragment PercentLBrace - : '%{' - ; +fragment PercentLBrace: '%{'; -fragment PercentRBrace - : '%}' - ; +fragment PercentRBrace: '%}'; -fragment PercentQuestion - : '%?{' - ; +fragment PercentQuestion: '%?{'; -fragment ActionCode - : Stuff* - ; +fragment ActionCode: Stuff*; -fragment Stuff - : EscAny +fragment Stuff: + EscAny | DQuoteLiteral | SQuoteLiteral | BlockComment | LineComment | NestedAction | ~('{' | '}' | '\'' | '"') - ; +; -fragment NestedPrologue - : PercentLBrace ActionCode PercentRBrace - ; +fragment NestedPrologue: PercentLBrace ActionCode PercentRBrace; -fragment NestedAction - : LBrace ActionCode RBrace - ; +fragment NestedAction: LBrace ActionCode RBrace; -fragment NestedPredicate - : PercentQuestion ActionCode RBrace - ; +fragment NestedPredicate: PercentQuestion ActionCode RBrace; -fragment Sp - : Ws* - ; +fragment Sp: Ws*; -fragment Eqopt - : (Sp [=])? - ; +fragment Eqopt: (Sp [=])?; -PercentPercent: '%%' { this.NextMode(); } - ; +PercentPercent: '%%' { this.NextMode(); }; - /*----------------------------. +/*----------------------------. | Scanning Bison directives. | `----------------------------*/ - /* For directives that are also command line options, the regex must be +/* For directives that are also command line options, the regex must be "%..." after "[-_]"s are removed, and the directive must match the --long option name, with a single string argument. Otherwise, add exceptions to ../build-aux/cross-options.pl. */ -NONASSOC - : '%binary' - ; +NONASSOC: '%binary'; -CODE - : '%code' - ; +CODE: '%code'; -PERCENT_DEBUG - : '%debug' - ; +PERCENT_DEBUG: '%debug'; -DEFAULT_PREC - : '%default-prec' - ; +DEFAULT_PREC: '%default-prec'; -DEFINE - : '%define' - ; +DEFINE: '%define'; -DEFINES - : '%defines' - ; +DEFINES: '%defines'; -DESTRUCTOR - : '%destructor' - ; +DESTRUCTOR: '%destructor'; -DPREC - : '%dprec' - ; +DPREC: '%dprec'; -EMPTY_RULE - : '%empty' - ; +EMPTY_RULE: '%empty'; -EXPECT - : '%expect' - ; +EXPECT: '%expect'; -EXPECT_RR - : '%expect-rr' - ; +EXPECT_RR: '%expect-rr'; -PERCENT_FILE_PREFIX - : '%file-prefix' - ; +PERCENT_FILE_PREFIX: '%file-prefix'; -INITIAL_ACTION - : '%initial-action' - ; +INITIAL_ACTION: '%initial-action'; -GLR_PARSER - : '%glr-parser' - ; +GLR_PARSER: '%glr-parser'; -LANGUAGE - : '%language' - ; +LANGUAGE: '%language'; -PERCENT_LEFT - : '%left' - ; +PERCENT_LEFT: '%left'; -LEX - : '%lex-param' - ; +LEX: '%lex-param'; -LOCATIONS - : '%locations' - ; +LOCATIONS: '%locations'; -MERGE - : '%merge' - ; +MERGE: '%merge'; -NO_DEFAULT_PREC - : '%no-default-prec' - ; +NO_DEFAULT_PREC: '%no-default-prec'; -NO_LINES - : '%no-lines' - ; +NO_LINES: '%no-lines'; -PERCENT_NONASSOC - : '%nonassoc' - ; +PERCENT_NONASSOC: '%nonassoc'; -NONDETERMINISTIC_PARSER - : '%nondeterministic-parser' - ; +NONDETERMINISTIC_PARSER: '%nondeterministic-parser'; -NTERM - : '%nterm' - ; +NTERM: '%nterm'; -PARAM - : '%param' - ; +PARAM: '%param'; -PARSE - : '%parse-param' - ; +PARSE: '%parse-param'; -PERCENT_PREC - : '%prec' - ; +PERCENT_PREC: '%prec'; -PRECEDENCE - : '%precedence' - ; +PRECEDENCE: '%precedence'; -PRINTER - : '%printer' - ; +PRINTER: '%printer'; -REQUIRE - : '%require' - ; +REQUIRE: '%require'; -PERCENT_RIGHT - : '%right' - ; +PERCENT_RIGHT: '%right'; -SKELETON - : '%skeleton' - ; +SKELETON: '%skeleton'; -PERCENT_START - : '%start' - ; +PERCENT_START: '%start'; -TOKEN - : '%term' - ; +TOKEN: '%term'; -PERCENT_TOKEN - : '%token' - ; +PERCENT_TOKEN: '%token'; -TOKEN_TABLE - : '%token' [-_] 'table' - ; +TOKEN_TABLE: '%token' [-_] 'table'; -PERCENT_TYPE - : '%type' - ; +PERCENT_TYPE: '%type'; -PERCENT_UNION - : '%union' - ; +PERCENT_UNION: '%union'; -VERBOSE - : '%verbose' - ; +VERBOSE: '%verbose'; -PERCENT_YACC - : '%yacc' - ; +PERCENT_YACC: '%yacc'; - /* Deprecated since Bison 2.3b (2008-05-27), but the warning is +/* Deprecated since Bison 2.3b (2008-05-27), but the warning is issued only since Bison 3.4. */ -PERCENT_PURE_PARSER - : '%pure' [-_] 'parser' - ; +PERCENT_PURE_PARSER: '%pure' [-_] 'parser'; - /* Deprecated since Bison 2.6 (2012-07-19), but the warning is +/* Deprecated since Bison 2.6 (2012-07-19), but the warning is issued only since Bison 3.3. */ -PERCENT_NAME_PREFIX - : '%name' [-_] 'prefix' Eqopt? Sp - ; +PERCENT_NAME_PREFIX: '%name' [-_] 'prefix' Eqopt? Sp; - /* Deprecated since Bison 2.7.90, 2012. */ -OBS_DEFAULT_PREC - : '%default' [-_] 'prec' - ; +/* Deprecated since Bison 2.7.90, 2012. */ +OBS_DEFAULT_PREC: '%default' [-_] 'prec'; -OBS_PERCENT_ERROR_VERBOSE - : '%error' [-_] 'verbose' - ; +OBS_PERCENT_ERROR_VERBOSE: '%error' [-_] 'verbose'; -OBS_EXPECT_RR - : '%expect' [-_] 'rr' - ; +OBS_EXPECT_RR: '%expect' [-_] 'rr'; -OBS_PERCENT_FILE_PREFIX - : '%file-prefix' Eqopt - ; +OBS_PERCENT_FILE_PREFIX: '%file-prefix' Eqopt; -OBS_FIXED_OUTPUT - : '%fixed' [-_] 'output' [-_] 'files' - ; +OBS_FIXED_OUTPUT: '%fixed' [-_] 'output' [-_] 'files'; -OBS_NO_DEFAULT_PREC - : '%no' [-_] 'default' [-_] 'prec' - ; +OBS_NO_DEFAULT_PREC: '%no' [-_] 'default' [-_] 'prec'; -OBS_NO_LINES - : '%no' [-_] 'lines' - ; +OBS_NO_LINES: '%no' [-_] 'lines'; -OBS_OUTPUT - : '%output' Eqopt - ; +OBS_OUTPUT: '%output' Eqopt; -OBS_TOKEN_TABLE - : '%token' [-_] 'table' - ; +OBS_TOKEN_TABLE: '%token' [-_] 'table'; - -BRACED_CODE: NestedAction; -BRACED_PREDICATE: NestedPredicate; -BRACKETED_ID: '[' Id ']'; -CHAR: CharLiteral; -COLON: ':'; +BRACED_CODE : NestedAction; +BRACED_PREDICATE : NestedPredicate; +BRACKETED_ID : '[' Id ']'; +CHAR : CharLiteral; +COLON : ':'; //EPILOGUE: 'epilogue'; -EQUAL: '='; +EQUAL: '='; //ID_COLON: Id ':'; -ID: Id; -PIPE: '|'; -SEMICOLON: ';'; -TAG: '<' Type '>'; -TAG_ANY: '<*>'; -TAG_NONE: '<>'; -STRING: DQuoteLiteral; -INT: [0-9]+; -LPAREN: '('; -RPAREN: ')'; - -BLOCK_COMMENT - : BlockComment -> channel(HIDDEN) - ; - -LINE_COMMENT - : LineComment -> channel(HIDDEN) - ; - -WS - : ( Hws | Vws )+ -> channel(HIDDEN) - ; - - -PROLOGUE - : NestedPrologue - ; +ID : Id; +PIPE : '|'; +SEMICOLON : ';'; +TAG : '<' Type '>'; +TAG_ANY : '<*>'; +TAG_NONE : '<>'; +STRING : DQuoteLiteral; +INT : [0-9]+; +LPAREN : '('; +RPAREN : ')'; + +BLOCK_COMMENT: BlockComment -> channel(HIDDEN); + +LINE_COMMENT: LineComment -> channel(HIDDEN); + +WS: ( Hws | Vws)+ -> channel(HIDDEN); + +PROLOGUE: NestedPrologue; // ============================================================== // Note, all prologue rules can be used in grammar declarations. @@ -449,5 +283,4 @@ PROLOGUE mode EpilogueMode; // Expected: Warning AC0131 greedy block ()+ contains wildcard; the non-greedy syntax ()+? may be preferred LanguageServer // Changing from .* to .*? to avoid the warning. It may or may not work. - EPILOGUE: .+ ; - +EPILOGUE: .+; \ No newline at end of file diff --git a/bison/BisonParser.g4 b/bison/BisonParser.g4 index 2c3ab4e7d5..63e56f3a47 100644 --- a/bison/BisonParser.g4 +++ b/bison/BisonParser.g4 @@ -17,15 +17,18 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - /*==========\ | Grammar. | \==========*/ +// $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 BisonParser; -options { tokenVocab=BisonLexer; } +options { + tokenVocab = BisonLexer; +} input_ : prologue_declarations '%%' bison_grammar epilogue_opt EOF @@ -75,7 +78,6 @@ params | actionBlock ; - /*----------------------. | grammar_declaration. | `----------------------*/ @@ -159,13 +161,15 @@ nterm_decls // A non empty list of possibly tagged symbols for %token or %nterm. -token_decls : ( | TAG ) token_decl+ ( TAG token_decl+ )* ; +token_decls + : ( | TAG) token_decl+ (TAG token_decl+)* + ; // One symbol declaration for %token or %nterm. token_decl : id int_opt alias - | id id LPAREN id RPAREN alias // Not in Bison, but used in https://github.com/ruby/ruby/parse.y + | id id LPAREN id RPAREN alias // Not in Bison, but used in https://github.com/ruby/ruby/parse.y ; int_opt @@ -176,10 +180,9 @@ int_opt alias : | string_as_id -//| TSTRING + //| TSTRING ; - /*-------------------------------------. | token_decls_for_prec (%left, etc.). | `-------------------------------------*/ @@ -202,7 +205,6 @@ token_decl_for_prec | string_as_id ; - /*-----------------------------------. | symbol_decls (argument of %type). | `-----------------------------------*/ @@ -241,7 +243,8 @@ rhses_1 ; rhs - : ( symbol named_ref_opt + : ( + symbol named_ref_opt | tag_opt actionBlock named_ref_opt | BRACED_PREDICATE | EMPTY_RULE @@ -249,7 +252,8 @@ rhs | DPREC INT | MERGE TAG | EXPECT INT - | EXPECT_RR INT)* + | EXPECT_RR INT + )* ; named_ref_opt @@ -257,7 +261,6 @@ named_ref_opt | BRACKETED_ID ; - /*---------------------. | variable and value. | `---------------------*/ @@ -273,7 +276,6 @@ value | actionBlock ; - /*--------------. | Identifiers. | `--------------*/ @@ -304,4 +306,4 @@ epilogue_opt actionBlock : BRACED_CODE - ; + ; \ No newline at end of file diff --git a/bnf/bnf.g4 b/bnf/bnf.g4 index 3077918393..4c3bdbda79 100644 --- a/bnf/bnf.g4 +++ b/bnf/bnf.g4 @@ -26,11 +26,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar bnf; rulelist : rule_* EOF -; + ; rule_ : lhs ASSIGN rhs @@ -125,9 +128,9 @@ Less_Than_Sign ; ID - : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'-'|' ')+ + : ('a' ..'z' | 'A' ..'Z') ('a' ..'z' | 'A' ..'Z' | '0' ..'9' | '-' | ' ')+ ; WS : [ \r\n\t] -> skip - ; + ; \ No newline at end of file diff --git a/c/C.g4 b/c/C.g4 index 6f79735980..8b63b9588e 100644 --- a/c/C.g4 +++ b/c/C.g4 @@ -27,830 +27,1066 @@ */ /** C 2011 grammar built from the C11 Spec */ -grammar C; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar C; primaryExpression - : Identifier - | Constant - | StringLiteral+ - | '(' expression ')' - | genericSelection - | '__extension__'? '(' compoundStatement ')' // Blocks (GCC extension) - | '__builtin_va_arg' '(' unaryExpression ',' typeName ')' - | '__builtin_offsetof' '(' typeName ',' unaryExpression ')' + : Identifier + | Constant + | StringLiteral+ + | '(' expression ')' + | genericSelection + | '__extension__'? '(' compoundStatement ')' // Blocks (GCC extension) + | '__builtin_va_arg' '(' unaryExpression ',' typeName ')' + | '__builtin_offsetof' '(' typeName ',' unaryExpression ')' ; genericSelection - : '_Generic' '(' assignmentExpression ',' genericAssocList ')' + : '_Generic' '(' assignmentExpression ',' genericAssocList ')' ; genericAssocList - : genericAssociation (',' genericAssociation)* + : genericAssociation (',' genericAssociation)* ; genericAssociation - : (typeName | 'default') ':' assignmentExpression + : (typeName | 'default') ':' assignmentExpression ; postfixExpression - : - ( primaryExpression - | '__extension__'? '(' typeName ')' '{' initializerList ','? '}' - ) - ('[' expression ']' - | '(' argumentExpressionList? ')' - | ('.' | '->') Identifier - | '++' - | '--' + : (primaryExpression | '__extension__'? '(' typeName ')' '{' initializerList ','? '}') ( + '[' expression ']' + | '(' argumentExpressionList? ')' + | ('.' | '->') Identifier + | '++' + | '--' )* ; argumentExpressionList - : assignmentExpression (',' assignmentExpression)* + : assignmentExpression (',' assignmentExpression)* ; unaryExpression - : - ('++' | '--' | 'sizeof')* - (postfixExpression - | unaryOperator castExpression - | ('sizeof' | '_Alignof') '(' typeName ')' - | '&&' Identifier // GCC extension address of label + : ('++' | '--' | 'sizeof')* ( + postfixExpression + | unaryOperator castExpression + | ('sizeof' | '_Alignof') '(' typeName ')' + | '&&' Identifier // GCC extension address of label ) ; unaryOperator - : '&' | '*' | '+' | '-' | '~' | '!' + : '&' + | '*' + | '+' + | '-' + | '~' + | '!' ; castExpression - : '__extension__'? '(' typeName ')' castExpression - | unaryExpression - | DigitSequence // for + : '__extension__'? '(' typeName ')' castExpression + | unaryExpression + | DigitSequence // for ; multiplicativeExpression - : castExpression (('*'|'/'|'%') castExpression)* + : castExpression (('*' | '/' | '%') castExpression)* ; additiveExpression - : multiplicativeExpression (('+'|'-') multiplicativeExpression)* + : multiplicativeExpression (('+' | '-') multiplicativeExpression)* ; shiftExpression - : additiveExpression (('<<'|'>>') additiveExpression)* + : additiveExpression (('<<' | '>>') additiveExpression)* ; relationalExpression - : shiftExpression (('<'|'>'|'<='|'>=') shiftExpression)* + : shiftExpression (('<' | '>' | '<=' | '>=') shiftExpression)* ; equalityExpression - : relationalExpression (('=='| '!=') relationalExpression)* + : relationalExpression (('==' | '!=') relationalExpression)* ; andExpression - : equalityExpression ( '&' equalityExpression)* + : equalityExpression ('&' equalityExpression)* ; exclusiveOrExpression - : andExpression ('^' andExpression)* + : andExpression ('^' andExpression)* ; inclusiveOrExpression - : exclusiveOrExpression ('|' exclusiveOrExpression)* + : exclusiveOrExpression ('|' exclusiveOrExpression)* ; logicalAndExpression - : inclusiveOrExpression ('&&' inclusiveOrExpression)* + : inclusiveOrExpression ('&&' inclusiveOrExpression)* ; logicalOrExpression - : logicalAndExpression ( '||' logicalAndExpression)* + : logicalAndExpression ('||' logicalAndExpression)* ; conditionalExpression - : logicalOrExpression ('?' expression ':' conditionalExpression)? + : logicalOrExpression ('?' expression ':' conditionalExpression)? ; assignmentExpression - : conditionalExpression - | unaryExpression assignmentOperator assignmentExpression - | DigitSequence // for + : conditionalExpression + | unaryExpression assignmentOperator assignmentExpression + | DigitSequence // for ; assignmentOperator - : '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|=' + : '=' + | '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '&=' + | '^=' + | '|=' ; expression - : assignmentExpression (',' assignmentExpression)* + : assignmentExpression (',' assignmentExpression)* ; constantExpression - : conditionalExpression + : conditionalExpression ; declaration - : declarationSpecifiers initDeclaratorList? ';' - | staticAssertDeclaration + : declarationSpecifiers initDeclaratorList? ';' + | staticAssertDeclaration ; declarationSpecifiers - : declarationSpecifier+ + : declarationSpecifier+ ; declarationSpecifiers2 - : declarationSpecifier+ + : declarationSpecifier+ ; declarationSpecifier - : storageClassSpecifier - | typeSpecifier - | typeQualifier - | functionSpecifier - | alignmentSpecifier + : storageClassSpecifier + | typeSpecifier + | typeQualifier + | functionSpecifier + | alignmentSpecifier ; initDeclaratorList - : initDeclarator (',' initDeclarator)* + : initDeclarator (',' initDeclarator)* ; initDeclarator - : declarator ('=' initializer)? + : declarator ('=' initializer)? ; storageClassSpecifier - : 'typedef' - | 'extern' - | 'static' - | '_Thread_local' - | 'auto' - | 'register' + : 'typedef' + | 'extern' + | 'static' + | '_Thread_local' + | 'auto' + | 'register' ; typeSpecifier - : 'void' - | 'char' - | 'short' - | 'int' - | 'long' - | 'float' - | 'double' - | 'signed' - | 'unsigned' - | '_Bool' - | '_Complex' - | '__m128' - | '__m128d' - | '__m128i' - | '__extension__' '(' ('__m128' | '__m128d' | '__m128i') ')' - | atomicTypeSpecifier - | structOrUnionSpecifier - | enumSpecifier - | typedefName - | '__typeof__' '(' constantExpression ')' // GCC extension + : 'void' + | 'char' + | 'short' + | 'int' + | 'long' + | 'float' + | 'double' + | 'signed' + | 'unsigned' + | '_Bool' + | '_Complex' + | '__m128' + | '__m128d' + | '__m128i' + | '__extension__' '(' ('__m128' | '__m128d' | '__m128i') ')' + | atomicTypeSpecifier + | structOrUnionSpecifier + | enumSpecifier + | typedefName + | '__typeof__' '(' constantExpression ')' // GCC extension ; structOrUnionSpecifier - : structOrUnion Identifier? '{' structDeclarationList '}' - | structOrUnion Identifier + : structOrUnion Identifier? '{' structDeclarationList '}' + | structOrUnion Identifier ; structOrUnion - : 'struct' - | 'union' + : 'struct' + | 'union' ; structDeclarationList - : structDeclaration+ + : structDeclaration+ ; structDeclaration // The first two rules have priority order and cannot be simplified to one expression. - : specifierQualifierList structDeclaratorList ';' - | specifierQualifierList ';' - | staticAssertDeclaration + : specifierQualifierList structDeclaratorList ';' + | specifierQualifierList ';' + | staticAssertDeclaration ; specifierQualifierList - : (typeSpecifier| typeQualifier) specifierQualifierList? + : (typeSpecifier | typeQualifier) specifierQualifierList? ; structDeclaratorList - : structDeclarator (',' structDeclarator)* + : structDeclarator (',' structDeclarator)* ; structDeclarator - : declarator - | declarator? ':' constantExpression + : declarator + | declarator? ':' constantExpression ; enumSpecifier - : 'enum' Identifier? '{' enumeratorList ','? '}' - | 'enum' Identifier + : 'enum' Identifier? '{' enumeratorList ','? '}' + | 'enum' Identifier ; enumeratorList - : enumerator (',' enumerator)* + : enumerator (',' enumerator)* ; enumerator - : enumerationConstant ('=' constantExpression)? + : enumerationConstant ('=' constantExpression)? ; enumerationConstant - : Identifier + : Identifier ; atomicTypeSpecifier - : '_Atomic' '(' typeName ')' + : '_Atomic' '(' typeName ')' ; typeQualifier - : 'const' - | 'restrict' - | 'volatile' - | '_Atomic' + : 'const' + | 'restrict' + | 'volatile' + | '_Atomic' ; functionSpecifier - : 'inline' - | '_Noreturn' - | '__inline__' // GCC extension - | '__stdcall' - | gccAttributeSpecifier - | '__declspec' '(' Identifier ')' + : 'inline' + | '_Noreturn' + | '__inline__' // GCC extension + | '__stdcall' + | gccAttributeSpecifier + | '__declspec' '(' Identifier ')' ; alignmentSpecifier - : '_Alignas' '(' (typeName | constantExpression) ')' + : '_Alignas' '(' (typeName | constantExpression) ')' ; declarator - : pointer? directDeclarator gccDeclaratorExtension* + : pointer? directDeclarator gccDeclaratorExtension* ; directDeclarator - : Identifier - | '(' declarator ')' - | directDeclarator '[' typeQualifierList? assignmentExpression? ']' - | directDeclarator '[' 'static' typeQualifierList? assignmentExpression ']' - | directDeclarator '[' typeQualifierList 'static' assignmentExpression ']' - | directDeclarator '[' typeQualifierList? '*' ']' - | directDeclarator '(' parameterTypeList ')' - | directDeclarator '(' identifierList? ')' - | Identifier ':' DigitSequence // bit field - | vcSpecificModifer Identifier // Visual C Extension - | '(' vcSpecificModifer declarator ')' // Visual C Extension + : Identifier + | '(' declarator ')' + | directDeclarator '[' typeQualifierList? assignmentExpression? ']' + | directDeclarator '[' 'static' typeQualifierList? assignmentExpression ']' + | directDeclarator '[' typeQualifierList 'static' assignmentExpression ']' + | directDeclarator '[' typeQualifierList? '*' ']' + | directDeclarator '(' parameterTypeList ')' + | directDeclarator '(' identifierList? ')' + | Identifier ':' DigitSequence // bit field + | vcSpecificModifer Identifier // Visual C Extension + | '(' vcSpecificModifer declarator ')' // Visual C Extension ; vcSpecificModifer - : '__cdecl' - | '__clrcall' - | '__stdcall' - | '__fastcall' - | '__thiscall' - | '__vectorcall' + : '__cdecl' + | '__clrcall' + | '__stdcall' + | '__fastcall' + | '__thiscall' + | '__vectorcall' ; - gccDeclaratorExtension - : '__asm' '(' StringLiteral+ ')' - | gccAttributeSpecifier + : '__asm' '(' StringLiteral+ ')' + | gccAttributeSpecifier ; gccAttributeSpecifier - : '__attribute__' '(' '(' gccAttributeList ')' ')' + : '__attribute__' '(' '(' gccAttributeList ')' ')' ; gccAttributeList - : gccAttribute? (',' gccAttribute?)* + : gccAttribute? (',' gccAttribute?)* ; gccAttribute - : ~(',' | '(' | ')') // relaxed def for "identifier or reserved word" - ('(' argumentExpressionList? ')')? + : ~(',' | '(' | ')') // relaxed def for "identifier or reserved word" + ('(' argumentExpressionList? ')')? ; nestedParenthesesBlock - : ( ~('(' | ')') - | '(' nestedParenthesesBlock ')' - )* + : (~('(' | ')') | '(' nestedParenthesesBlock ')')* ; pointer - : (('*'|'^') typeQualifierList?)+ // ^ - Blocks language extension + : (('*' | '^') typeQualifierList?)+ // ^ - Blocks language extension ; typeQualifierList - : typeQualifier+ + : typeQualifier+ ; parameterTypeList - : parameterList (',' '...')? + : parameterList (',' '...')? ; parameterList - : parameterDeclaration (',' parameterDeclaration)* + : parameterDeclaration (',' parameterDeclaration)* ; parameterDeclaration - : declarationSpecifiers declarator - | declarationSpecifiers2 abstractDeclarator? + : declarationSpecifiers declarator + | declarationSpecifiers2 abstractDeclarator? ; identifierList - : Identifier (',' Identifier)* + : Identifier (',' Identifier)* ; typeName - : specifierQualifierList abstractDeclarator? + : specifierQualifierList abstractDeclarator? ; abstractDeclarator - : pointer - | pointer? directAbstractDeclarator gccDeclaratorExtension* + : pointer + | pointer? directAbstractDeclarator gccDeclaratorExtension* ; directAbstractDeclarator - : '(' abstractDeclarator ')' gccDeclaratorExtension* - | '[' typeQualifierList? assignmentExpression? ']' - | '[' 'static' typeQualifierList? assignmentExpression ']' - | '[' typeQualifierList 'static' assignmentExpression ']' - | '[' '*' ']' - | '(' parameterTypeList? ')' gccDeclaratorExtension* - | directAbstractDeclarator '[' typeQualifierList? assignmentExpression? ']' - | directAbstractDeclarator '[' 'static' typeQualifierList? assignmentExpression ']' - | directAbstractDeclarator '[' typeQualifierList 'static' assignmentExpression ']' - | directAbstractDeclarator '[' '*' ']' - | directAbstractDeclarator '(' parameterTypeList? ')' gccDeclaratorExtension* + : '(' abstractDeclarator ')' gccDeclaratorExtension* + | '[' typeQualifierList? assignmentExpression? ']' + | '[' 'static' typeQualifierList? assignmentExpression ']' + | '[' typeQualifierList 'static' assignmentExpression ']' + | '[' '*' ']' + | '(' parameterTypeList? ')' gccDeclaratorExtension* + | directAbstractDeclarator '[' typeQualifierList? assignmentExpression? ']' + | directAbstractDeclarator '[' 'static' typeQualifierList? assignmentExpression ']' + | directAbstractDeclarator '[' typeQualifierList 'static' assignmentExpression ']' + | directAbstractDeclarator '[' '*' ']' + | directAbstractDeclarator '(' parameterTypeList? ')' gccDeclaratorExtension* ; typedefName - : Identifier + : Identifier ; initializer - : assignmentExpression - | '{' initializerList ','? '}' + : assignmentExpression + | '{' initializerList ','? '}' ; initializerList - : designation? initializer (',' designation? initializer)* + : designation? initializer (',' designation? initializer)* ; designation - : designatorList '=' + : designatorList '=' ; designatorList - : designator+ + : designator+ ; designator - : '[' constantExpression ']' - | '.' Identifier + : '[' constantExpression ']' + | '.' Identifier ; staticAssertDeclaration - : '_Static_assert' '(' constantExpression ',' StringLiteral+ ')' ';' + : '_Static_assert' '(' constantExpression ',' StringLiteral+ ')' ';' ; statement - : labeledStatement - | compoundStatement - | expressionStatement - | selectionStatement - | iterationStatement - | jumpStatement - | ('__asm' | '__asm__') ('volatile' | '__volatile__') '(' (logicalOrExpression (',' logicalOrExpression)*)? (':' (logicalOrExpression (',' logicalOrExpression)*)?)* ')' ';' + : labeledStatement + | compoundStatement + | expressionStatement + | selectionStatement + | iterationStatement + | jumpStatement + | ('__asm' | '__asm__') ('volatile' | '__volatile__') '(' ( + logicalOrExpression (',' logicalOrExpression)* + )? (':' (logicalOrExpression (',' logicalOrExpression)*)?)* ')' ';' ; labeledStatement - : Identifier ':' statement? - | 'case' constantExpression ':' statement - | 'default' ':' statement + : Identifier ':' statement? + | 'case' constantExpression ':' statement + | 'default' ':' statement ; compoundStatement - : '{' blockItemList? '}' + : '{' blockItemList? '}' ; blockItemList - : blockItem+ + : blockItem+ ; blockItem - : statement - | declaration + : statement + | declaration ; expressionStatement - : expression? ';' + : expression? ';' ; selectionStatement - : 'if' '(' expression ')' statement ('else' statement)? - | 'switch' '(' expression ')' statement + : 'if' '(' expression ')' statement ('else' statement)? + | 'switch' '(' expression ')' statement ; iterationStatement - : While '(' expression ')' statement - | Do statement While '(' expression ')' ';' - | For '(' forCondition ')' statement + : While '(' expression ')' statement + | Do statement While '(' expression ')' ';' + | For '(' forCondition ')' statement ; // | 'for' '(' expression? ';' expression? ';' forUpdate? ')' statement // | For '(' declaration expression? ';' expression? ')' statement forCondition - : (forDeclaration | expression?) ';' forExpression? ';' forExpression? - ; + : (forDeclaration | expression?) ';' forExpression? ';' forExpression? + ; forDeclaration - : declarationSpecifiers initDeclaratorList? + : declarationSpecifiers initDeclaratorList? ; forExpression - : assignmentExpression (',' assignmentExpression)* + : assignmentExpression (',' assignmentExpression)* ; jumpStatement - : ('goto' Identifier - | 'continue' - | 'break' - | 'return' expression? - | 'goto' unaryExpression // GCC extension - ) - ';' + : ( + 'goto' Identifier + | 'continue' + | 'break' + | 'return' expression? + | 'goto' unaryExpression // GCC extension + ) ';' ; compilationUnit - : translationUnit? EOF + : translationUnit? EOF ; translationUnit - : externalDeclaration+ + : externalDeclaration+ ; externalDeclaration - : functionDefinition - | declaration - | ';' // stray ; + : functionDefinition + | declaration + | ';' // stray ; ; functionDefinition - : declarationSpecifiers? declarator declarationList? compoundStatement + : declarationSpecifiers? declarator declarationList? compoundStatement ; declarationList - : declaration+ - ; - -Auto : 'auto'; -Break : 'break'; -Case : 'case'; -Char : 'char'; -Const : 'const'; -Continue : 'continue'; -Default : 'default'; -Do : 'do'; -Double : 'double'; -Else : 'else'; -Enum : 'enum'; -Extern : 'extern'; -Float : 'float'; -For : 'for'; -Goto : 'goto'; -If : 'if'; -Inline : 'inline'; -Int : 'int'; -Long : 'long'; -Register : 'register'; -Restrict : 'restrict'; -Return : 'return'; -Short : 'short'; -Signed : 'signed'; -Sizeof : 'sizeof'; -Static : 'static'; -Struct : 'struct'; -Switch : 'switch'; -Typedef : 'typedef'; -Union : 'union'; -Unsigned : 'unsigned'; -Void : 'void'; -Volatile : 'volatile'; -While : 'while'; - -Alignas : '_Alignas'; -Alignof : '_Alignof'; -Atomic : '_Atomic'; -Bool : '_Bool'; -Complex : '_Complex'; -Generic : '_Generic'; -Imaginary : '_Imaginary'; -Noreturn : '_Noreturn'; -StaticAssert : '_Static_assert'; -ThreadLocal : '_Thread_local'; - -LeftParen : '('; -RightParen : ')'; -LeftBracket : '['; -RightBracket : ']'; -LeftBrace : '{'; -RightBrace : '}'; - -Less : '<'; -LessEqual : '<='; -Greater : '>'; -GreaterEqual : '>='; -LeftShift : '<<'; -RightShift : '>>'; - -Plus : '+'; -PlusPlus : '++'; -Minus : '-'; -MinusMinus : '--'; -Star : '*'; -Div : '/'; -Mod : '%'; - -And : '&'; -Or : '|'; -AndAnd : '&&'; -OrOr : '||'; -Caret : '^'; -Not : '!'; -Tilde : '~'; - -Question : '?'; -Colon : ':'; -Semi : ';'; -Comma : ','; - -Assign : '='; + : declaration+ + ; + +Auto + : 'auto' + ; + +Break + : 'break' + ; + +Case + : 'case' + ; + +Char + : 'char' + ; + +Const + : 'const' + ; + +Continue + : 'continue' + ; + +Default + : 'default' + ; + +Do + : 'do' + ; + +Double + : 'double' + ; + +Else + : 'else' + ; + +Enum + : 'enum' + ; + +Extern + : 'extern' + ; + +Float + : 'float' + ; + +For + : 'for' + ; + +Goto + : 'goto' + ; + +If + : 'if' + ; + +Inline + : 'inline' + ; + +Int + : 'int' + ; + +Long + : 'long' + ; + +Register + : 'register' + ; + +Restrict + : 'restrict' + ; + +Return + : 'return' + ; + +Short + : 'short' + ; + +Signed + : 'signed' + ; + +Sizeof + : 'sizeof' + ; + +Static + : 'static' + ; + +Struct + : 'struct' + ; + +Switch + : 'switch' + ; + +Typedef + : 'typedef' + ; + +Union + : 'union' + ; + +Unsigned + : 'unsigned' + ; + +Void + : 'void' + ; + +Volatile + : 'volatile' + ; + +While + : 'while' + ; + +Alignas + : '_Alignas' + ; + +Alignof + : '_Alignof' + ; + +Atomic + : '_Atomic' + ; + +Bool + : '_Bool' + ; + +Complex + : '_Complex' + ; + +Generic + : '_Generic' + ; + +Imaginary + : '_Imaginary' + ; + +Noreturn + : '_Noreturn' + ; + +StaticAssert + : '_Static_assert' + ; + +ThreadLocal + : '_Thread_local' + ; + +LeftParen + : '(' + ; + +RightParen + : ')' + ; + +LeftBracket + : '[' + ; + +RightBracket + : ']' + ; + +LeftBrace + : '{' + ; + +RightBrace + : '}' + ; + +Less + : '<' + ; + +LessEqual + : '<=' + ; + +Greater + : '>' + ; + +GreaterEqual + : '>=' + ; + +LeftShift + : '<<' + ; + +RightShift + : '>>' + ; + +Plus + : '+' + ; + +PlusPlus + : '++' + ; + +Minus + : '-' + ; + +MinusMinus + : '--' + ; + +Star + : '*' + ; + +Div + : '/' + ; + +Mod + : '%' + ; + +And + : '&' + ; + +Or + : '|' + ; + +AndAnd + : '&&' + ; + +OrOr + : '||' + ; + +Caret + : '^' + ; + +Not + : '!' + ; + +Tilde + : '~' + ; + +Question + : '?' + ; + +Colon + : ':' + ; + +Semi + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + // '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|=' -StarAssign : '*='; -DivAssign : '/='; -ModAssign : '%='; -PlusAssign : '+='; -MinusAssign : '-='; -LeftShiftAssign : '<<='; -RightShiftAssign : '>>='; -AndAssign : '&='; -XorAssign : '^='; -OrAssign : '|='; - -Equal : '=='; -NotEqual : '!='; - -Arrow : '->'; -Dot : '.'; -Ellipsis : '...'; +StarAssign + : '*=' + ; + +DivAssign + : '/=' + ; + +ModAssign + : '%=' + ; + +PlusAssign + : '+=' + ; + +MinusAssign + : '-=' + ; + +LeftShiftAssign + : '<<=' + ; + +RightShiftAssign + : '>>=' + ; + +AndAssign + : '&=' + ; + +XorAssign + : '^=' + ; + +OrAssign + : '|=' + ; + +Equal + : '==' + ; + +NotEqual + : '!=' + ; + +Arrow + : '->' + ; + +Dot + : '.' + ; + +Ellipsis + : '...' + ; Identifier - : IdentifierNondigit - ( IdentifierNondigit - | Digit - )* + : IdentifierNondigit (IdentifierNondigit | Digit)* ; -fragment -IdentifierNondigit - : Nondigit - | UniversalCharacterName +fragment IdentifierNondigit + : Nondigit + | UniversalCharacterName //| // other implementation-defined characters... ; -fragment -Nondigit - : [a-zA-Z_] +fragment Nondigit + : [a-zA-Z_] ; -fragment -Digit - : [0-9] +fragment Digit + : [0-9] ; -fragment -UniversalCharacterName - : '\\u' HexQuad - | '\\U' HexQuad HexQuad +fragment UniversalCharacterName + : '\\u' HexQuad + | '\\U' HexQuad HexQuad ; -fragment -HexQuad - : HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit +fragment HexQuad + : HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit ; Constant - : IntegerConstant - | FloatingConstant + : IntegerConstant + | FloatingConstant //| EnumerationConstant - | CharacterConstant + | CharacterConstant ; -fragment -IntegerConstant - : DecimalConstant IntegerSuffix? - | OctalConstant IntegerSuffix? - | HexadecimalConstant IntegerSuffix? - | BinaryConstant +fragment IntegerConstant + : DecimalConstant IntegerSuffix? + | OctalConstant IntegerSuffix? + | HexadecimalConstant IntegerSuffix? + | BinaryConstant ; -fragment -BinaryConstant - : '0' [bB] [0-1]+ - ; +fragment BinaryConstant + : '0' [bB] [0-1]+ + ; -fragment -DecimalConstant - : NonzeroDigit Digit* +fragment DecimalConstant + : NonzeroDigit Digit* ; -fragment -OctalConstant - : '0' OctalDigit* +fragment OctalConstant + : '0' OctalDigit* ; -fragment -HexadecimalConstant - : HexadecimalPrefix HexadecimalDigit+ +fragment HexadecimalConstant + : HexadecimalPrefix HexadecimalDigit+ ; -fragment -HexadecimalPrefix - : '0' [xX] +fragment HexadecimalPrefix + : '0' [xX] ; -fragment -NonzeroDigit - : [1-9] +fragment NonzeroDigit + : [1-9] ; -fragment -OctalDigit - : [0-7] +fragment OctalDigit + : [0-7] ; -fragment -HexadecimalDigit - : [0-9a-fA-F] +fragment HexadecimalDigit + : [0-9a-fA-F] ; -fragment -IntegerSuffix - : UnsignedSuffix LongSuffix? - | UnsignedSuffix LongLongSuffix - | LongSuffix UnsignedSuffix? - | LongLongSuffix UnsignedSuffix? +fragment IntegerSuffix + : UnsignedSuffix LongSuffix? + | UnsignedSuffix LongLongSuffix + | LongSuffix UnsignedSuffix? + | LongLongSuffix UnsignedSuffix? ; -fragment -UnsignedSuffix - : [uU] +fragment UnsignedSuffix + : [uU] ; -fragment -LongSuffix - : [lL] +fragment LongSuffix + : [lL] ; -fragment -LongLongSuffix - : 'll' | 'LL' +fragment LongLongSuffix + : 'll' + | 'LL' ; -fragment -FloatingConstant - : DecimalFloatingConstant - | HexadecimalFloatingConstant +fragment FloatingConstant + : DecimalFloatingConstant + | HexadecimalFloatingConstant ; -fragment -DecimalFloatingConstant - : FractionalConstant ExponentPart? FloatingSuffix? - | DigitSequence ExponentPart FloatingSuffix? +fragment DecimalFloatingConstant + : FractionalConstant ExponentPart? FloatingSuffix? + | DigitSequence ExponentPart FloatingSuffix? ; -fragment -HexadecimalFloatingConstant - : HexadecimalPrefix (HexadecimalFractionalConstant | HexadecimalDigitSequence) BinaryExponentPart FloatingSuffix? +fragment HexadecimalFloatingConstant + : HexadecimalPrefix (HexadecimalFractionalConstant | HexadecimalDigitSequence) BinaryExponentPart FloatingSuffix? ; -fragment -FractionalConstant - : DigitSequence? '.' DigitSequence - | DigitSequence '.' +fragment FractionalConstant + : DigitSequence? '.' DigitSequence + | DigitSequence '.' ; -fragment -ExponentPart - : [eE] Sign? DigitSequence +fragment ExponentPart + : [eE] Sign? DigitSequence ; -fragment -Sign - : [+-] +fragment Sign + : [+-] ; DigitSequence - : Digit+ + : Digit+ ; -fragment -HexadecimalFractionalConstant - : HexadecimalDigitSequence? '.' HexadecimalDigitSequence - | HexadecimalDigitSequence '.' +fragment HexadecimalFractionalConstant + : HexadecimalDigitSequence? '.' HexadecimalDigitSequence + | HexadecimalDigitSequence '.' ; -fragment -BinaryExponentPart - : [pP] Sign? DigitSequence +fragment BinaryExponentPart + : [pP] Sign? DigitSequence ; -fragment -HexadecimalDigitSequence - : HexadecimalDigit+ +fragment HexadecimalDigitSequence + : HexadecimalDigit+ ; -fragment -FloatingSuffix - : [flFL] +fragment FloatingSuffix + : [flFL] ; -fragment -CharacterConstant - : '\'' CCharSequence '\'' - | 'L\'' CCharSequence '\'' - | 'u\'' CCharSequence '\'' - | 'U\'' CCharSequence '\'' +fragment CharacterConstant + : '\'' CCharSequence '\'' + | 'L\'' CCharSequence '\'' + | 'u\'' CCharSequence '\'' + | 'U\'' CCharSequence '\'' ; -fragment -CCharSequence - : CChar+ +fragment CCharSequence + : CChar+ ; -fragment -CChar - : ~['\\\r\n] - | EscapeSequence +fragment CChar + : ~['\\\r\n] + | EscapeSequence ; -fragment -EscapeSequence - : SimpleEscapeSequence - | OctalEscapeSequence - | HexadecimalEscapeSequence - | UniversalCharacterName +fragment EscapeSequence + : SimpleEscapeSequence + | OctalEscapeSequence + | HexadecimalEscapeSequence + | UniversalCharacterName ; -fragment -SimpleEscapeSequence - : '\\' ['"?abfnrtv\\] +fragment SimpleEscapeSequence + : '\\' ['"?abfnrtv\\] ; -fragment -OctalEscapeSequence - : '\\' OctalDigit OctalDigit? OctalDigit? +fragment OctalEscapeSequence + : '\\' OctalDigit OctalDigit? OctalDigit? ; -fragment -HexadecimalEscapeSequence - : '\\x' HexadecimalDigit+ +fragment HexadecimalEscapeSequence + : '\\x' HexadecimalDigit+ ; StringLiteral - : EncodingPrefix? '"' SCharSequence? '"' + : EncodingPrefix? '"' SCharSequence? '"' ; -fragment -EncodingPrefix - : 'u8' - | 'u' - | 'U' - | 'L' +fragment EncodingPrefix + : 'u8' + | 'u' + | 'U' + | 'L' ; -fragment -SCharSequence - : SChar+ +fragment SCharSequence + : SChar+ ; -fragment -SChar - : ~["\\\r\n] - | EscapeSequence - | '\\\n' // Added line - | '\\\r\n' // Added line +fragment SChar + : ~["\\\r\n] + | EscapeSequence + | '\\\n' // Added line + | '\\\r\n' // Added line ; -MultiLineMacro: - '#' (~[\n]*? '\\' '\r'? '\n')+ ~ [\n]+ -> channel (HIDDEN); +MultiLineMacro + : '#' (~[\n]*? '\\' '\r'? '\n')+ ~ [\n]+ -> channel (HIDDEN) + ; -Directive: '#' ~ [\n]* -> channel (HIDDEN); +Directive + : '#' ~ [\n]* -> channel (HIDDEN) + ; // ignore the following asm blocks: /* @@ -860,27 +1096,21 @@ Directive: '#' ~ [\n]* -> channel (HIDDEN); } */ AsmBlock - : 'asm' ~'{'* '{' ~'}'* '}' - -> channel(HIDDEN) + : 'asm' ~'{'* '{' ~'}'* '}' -> channel(HIDDEN) ; Whitespace - : [ \t]+ -> channel(HIDDEN) + : [ \t]+ -> channel(HIDDEN) ; Newline - : ( '\r' '\n'? - | '\n' - ) - -> channel(HIDDEN) + : ('\r' '\n'? | '\n') -> channel(HIDDEN) ; BlockComment - : '/*' .*? '*/' - -> channel(HIDDEN) + : '/*' .*? '*/' -> channel(HIDDEN) ; LineComment - : '//' ~[\r\n]* - -> channel(HIDDEN) - ; + : '//' ~[\r\n]* -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/calculator/calculator.g4 b/calculator/calculator.g4 index ba0a76f1ba..40276c5e13 100644 --- a/calculator/calculator.g4 +++ b/calculator/calculator.g4 @@ -30,236 +30,209 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar calculator; equation - : expression relop expression EOF - ; + : expression relop expression EOF + ; expression - : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* - ; + : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* + ; multiplyingExpression - : powExpression ((TIMES | DIV) powExpression)* - ; + : powExpression ((TIMES | DIV) powExpression)* + ; powExpression - : signedAtom (POW signedAtom)* - ; + : signedAtom (POW signedAtom)* + ; signedAtom - : PLUS signedAtom - | MINUS signedAtom - | func_ - | atom - ; + : PLUS signedAtom + | MINUS signedAtom + | func_ + | atom + ; atom - : scientific - | variable - | constant - | LPAREN expression RPAREN - ; + : scientific + | variable + | constant + | LPAREN expression RPAREN + ; scientific - : SCIENTIFIC_NUMBER - ; + : SCIENTIFIC_NUMBER + ; constant - : PI - | EULER - | I - ; + : PI + | EULER + | I + ; variable - : VARIABLE - ; + : VARIABLE + ; func_ - : funcname LPAREN expression (COMMA expression)* RPAREN - ; + : funcname LPAREN expression (COMMA expression)* RPAREN + ; funcname - : COS - | TAN - | SIN - | ACOS - | ATAN - | ASIN - | LOG - | LN - | SQRT - ; + : COS + | TAN + | SIN + | ACOS + | ATAN + | ASIN + | LOG + | LN + | SQRT + ; relop - : EQ - | GT - | LT - ; - + : EQ + | GT + | LT + ; COS - : 'cos' - ; - + : 'cos' + ; SIN - : 'sin' - ; - + : 'sin' + ; TAN - : 'tan' - ; - + : 'tan' + ; ACOS - : 'acos' - ; - + : 'acos' + ; ASIN - : 'asin' - ; - + : 'asin' + ; ATAN - : 'atan' - ; - + : 'atan' + ; LN - : 'ln' - ; - + : 'ln' + ; LOG - : 'log' - ; - + : 'log' + ; SQRT - : 'sqrt' - ; - + : 'sqrt' + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; TIMES - : '*' - ; - + : '*' + ; DIV - : '/' - ; - + : '/' + ; GT - : '>' - ; - + : '>' + ; LT - : '<' - ; - + : '<' + ; EQ - : '=' - ; - + : '=' + ; COMMA - : ',' - ; - + : ',' + ; POINT - : '.' - ; - + : '.' + ; POW - : '^' - ; - + : '^' + ; PI - : 'pi' - ; - + : 'pi' + ; EULER - : E2 - ; - + : E2 + ; I - : 'i' - ; - + : 'i' + ; VARIABLE - : VALID_ID_START VALID_ID_CHAR* - ; - + : VALID_ID_START VALID_ID_CHAR* + ; fragment VALID_ID_START - : 'a' .. 'z' | 'A' .. 'Z' | '_' - ; - + : 'a' .. 'z' + | 'A' .. 'Z' + | '_' + ; fragment VALID_ID_CHAR - : VALID_ID_START - | '0' .. '9' - ; - + : VALID_ID_START + | '0' .. '9' + ; SCIENTIFIC_NUMBER - : NUMBER ((E1 | E2) SIGN? NUMBER)? - ; - + : NUMBER ((E1 | E2) SIGN? NUMBER)? + ; fragment NUMBER - : '0'..'9'+ ('.' '0'..'9'+ )? - ; - + : '0' ..'9'+ ('.' '0' ..'9'+)? + ; fragment E1 - : 'E' - ; - + : 'E' + ; fragment E2 - : 'e' - ; - + : 'e' + ; fragment SIGN - : '+' | '-' - ; - + : '+' + | '-' + ; WS - : [ \r\n\t] + -> skip - ; + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/callable/callable_.g4 b/callable/callable_.g4 index e8f4978946..17a4b8b763 100644 --- a/callable/callable_.g4 +++ b/callable/callable_.g4 @@ -29,46 +29,49 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar callable_; program - : line (EOL+ line)* EOF - ; + : line (EOL+ line)* EOF + ; line - : ID '(' f_inner? ')' - ; + : ID '(' f_inner? ')' + ; f_inner - : f_arg (',' f_arg)* - ; + : f_arg (',' f_arg)* + ; f_arg - : line - | STRING - ; + : line + | STRING + ; ID - : (LETTER_UPPER | LETTER_LOWER | '-')+ - ; + : (LETTER_UPPER | LETTER_LOWER | '-')+ + ; STRING - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; LETTER_UPPER - : [A-Z] - ; + : [A-Z] + ; LETTER_LOWER - : [a-z] - ; + : [a-z] + ; EOL - : [\r\n] - ; + : [\r\n] + ; WS - : [ \t]+ -> skip - ; - + : [ \t]+ -> skip + ; \ No newline at end of file diff --git a/capnproto/CapnProto.g4 b/capnproto/CapnProto.g4 index 4ea5f32ac2..0100abca37 100644 --- a/capnproto/CapnProto.g4 +++ b/capnproto/CapnProto.g4 @@ -1,147 +1,228 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging grammar CapnProto; // parser rules -document : - file_identifier using_import* namespace_? document_content* EOF ; - -file_identifier : - FILE_ID ';' ; - -using_import : - 'using' ( NAME '=' )? 'import' TEXT ( '.' NAME )? ';' ; - -namespace_ : - '$' NAME '.namespace' '(' TEXT ')' ';' ; - -document_content : - struct_def | interface_def | function_def | annotation_def | const_def | enum_def ; - -struct_def : - 'struct' type_ annotation_reference? '{' struct_content* '}' ; - -struct_content : - field_def | enum_def | named_union_def - | unnamed_union_def | interface_def | annotation_def - | struct_def | group_def | const_def | inner_using ; - -interface_def : - 'interface' type_ ( 'extends' '(' type_ ')' )? '{' interface_content* '}' ; - -interface_content : - field_def | enum_def | named_union_def - | unnamed_union_def | interface_def - | struct_def | function_def ; - -field_def : - NAME LOCATOR ':' type_ ( '=' const_value )? ';' ; - -type_ : - NAME - inner_type? - ( '.' type_ )? ; - -inner_type : - '(' type_ inner_type? ( ',' type_ inner_type? )* ')' ; - -enum_def : - 'enum' NAME annotation_reference? '{' enum_content* '}' ; - -annotation_reference : - '$' type_ '.ann'? '(' TEXT ')' ; - -enum_content : - NAME LOCATOR annotation_reference? ';' ; - -named_union_def : - NAME LOCATOR? ':union' '{' union_content* '}' ; - -unnamed_union_def : - 'union' '{' union_content* '}' ; - -union_content : - field_def | group_def | unnamed_union_def | named_union_def ; - -group_def : - NAME ':group' '{' group_content* '}' ; - -group_content : - field_def | unnamed_union_def | named_union_def ; - -function_def : - NAME LOCATOR? generic_type_parameters? ( function_parameters | type_ ) - ( '->' ( function_parameters | type_ ) )? - ';' ; - -generic_type_parameters : - '[' - NAME ( ',' NAME )* - ']' ; - -function_parameters : - '(' - ( NAME ':' type_ ( '=' const_value )? - ( ',' NAME ':' type_ ( '=' const_value )? )* - )? - ')' ; - -annotation_def : - 'annotation' type_ annotation_parameters? ':' type_ ';' ; - -annotation_parameters : - '(' 'struct' ')' ; - -const_def : - 'const' NAME ':' type_ '=' const_value ';' ; - -const_value : - '-'? '.'? NAME ( '.' NAME )? | INTEGER | FLOAT - | TEXT | BOOLEAN | HEXADECIMAL | VOID - | literal_list | literal_union | literal_bytes ; - -literal_union : - '(' NAME '=' union_mapping ( ',' NAME '=' union_mapping )* ')' ; - -literal_list : - '[' const_value ( ',' const_value )* ']' ; - -literal_bytes : - '0x' TEXT ; - -union_mapping : - '(' NAME '=' const_value ')' | const_value ; - -inner_using : - 'using' NAME ( '.' NAME )* - ( '=' type_ )? - ';' ; - - +document + : file_identifier using_import* namespace_? document_content* EOF + ; + +file_identifier + : FILE_ID ';' + ; + +using_import + : 'using' (NAME '=')? 'import' TEXT ('.' NAME)? ';' + ; + +namespace_ + : '$' NAME '.namespace' '(' TEXT ')' ';' + ; + +document_content + : struct_def + | interface_def + | function_def + | annotation_def + | const_def + | enum_def + ; + +struct_def + : 'struct' type_ annotation_reference? '{' struct_content* '}' + ; + +struct_content + : field_def + | enum_def + | named_union_def + | unnamed_union_def + | interface_def + | annotation_def + | struct_def + | group_def + | const_def + | inner_using + ; + +interface_def + : 'interface' type_ ('extends' '(' type_ ')')? '{' interface_content* '}' + ; + +interface_content + : field_def + | enum_def + | named_union_def + | unnamed_union_def + | interface_def + | struct_def + | function_def + ; + +field_def + : NAME LOCATOR ':' type_ ('=' const_value)? ';' + ; + +type_ + : NAME inner_type? ('.' type_)? + ; + +inner_type + : '(' type_ inner_type? (',' type_ inner_type?)* ')' + ; + +enum_def + : 'enum' NAME annotation_reference? '{' enum_content* '}' + ; + +annotation_reference + : '$' type_ '.ann'? '(' TEXT ')' + ; + +enum_content + : NAME LOCATOR annotation_reference? ';' + ; + +named_union_def + : NAME LOCATOR? ':union' '{' union_content* '}' + ; + +unnamed_union_def + : 'union' '{' union_content* '}' + ; + +union_content + : field_def + | group_def + | unnamed_union_def + | named_union_def + ; + +group_def + : NAME ':group' '{' group_content* '}' + ; + +group_content + : field_def + | unnamed_union_def + | named_union_def + ; + +function_def + : NAME LOCATOR? generic_type_parameters? (function_parameters | type_) ( + '->' ( function_parameters | type_) + )? ';' + ; + +generic_type_parameters + : '[' NAME (',' NAME)* ']' + ; + +function_parameters + : '(' (NAME ':' type_ ( '=' const_value)? ( ',' NAME ':' type_ ( '=' const_value)?)*)? ')' + ; + +annotation_def + : 'annotation' type_ annotation_parameters? ':' type_ ';' + ; + +annotation_parameters + : '(' 'struct' ')' + ; + +const_def + : 'const' NAME ':' type_ '=' const_value ';' + ; + +const_value + : '-'? '.'? NAME ('.' NAME)? + | INTEGER + | FLOAT + | TEXT + | BOOLEAN + | HEXADECIMAL + | VOID + | literal_list + | literal_union + | literal_bytes + ; + +literal_union + : '(' NAME '=' union_mapping (',' NAME '=' union_mapping)* ')' + ; + +literal_list + : '[' const_value (',' const_value)* ']' + ; + +literal_bytes + : '0x' TEXT + ; + +union_mapping + : '(' NAME '=' const_value ')' + | const_value + ; + +inner_using + : 'using' NAME ('.' NAME)* ('=' type_)? ';' + ; + // lexer rules -fragment DIGIT : [0-9] ; +fragment DIGIT + : [0-9] + ; -fragment HEX_DIGIT : DIGIT | 'A'..'F' | 'a'..'f' ; +fragment HEX_DIGIT + : DIGIT + | 'A' ..'F' + | 'a' ..'f' + ; -LOCATOR : '@' DIGIT+ '!'? ; +LOCATOR + : '@' DIGIT+ '!'? + ; -TEXT : '"' ~["]*? '"' ; +TEXT + : '"' ~["]*? '"' + ; -INTEGER : '-'? DIGIT+ ; +INTEGER + : '-'? DIGIT+ + ; -FLOAT : '-'? DIGIT+ ( '.' DIGIT+ )? ( 'e' '-'? DIGIT+ )? ; +FLOAT + : '-'? DIGIT+ ('.' DIGIT+)? ('e' '-'? DIGIT+)? + ; -HEXADECIMAL : '-'? '0x' HEX_DIGIT+ ; +HEXADECIMAL + : '-'? '0x' HEX_DIGIT+ + ; -FILE_ID : '@' HEXADECIMAL ; +FILE_ID + : '@' HEXADECIMAL + ; -BOOLEAN : 'true' | 'false' ; +BOOLEAN + : 'true' + | 'false' + ; -VOID : 'void' ; +VOID + : 'void' + ; -NAME : [a-zA-Z] [a-zA-Z0-9]* ; +NAME + : [a-zA-Z] [a-zA-Z0-9]* + ; -COMMENT : '#' ~[\n]* -> channel(HIDDEN) ; +COMMENT + : '#' ~[\n]* -> channel(HIDDEN) + ; -WHITESPACE : [ \t\r\n] -> skip ; +WHITESPACE + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/caql/CaQL.g4 b/caql/CaQL.g4 index 932f071d78..5e499b9e16 100644 --- a/caql/CaQL.g4 +++ b/caql/CaQL.g4 @@ -1,11 +1,18 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar CaQL; -start_: expression EOF; +start_ + : expression EOF + ; -expression: vectorOperation; +expression + : vectorOperation + ; vectorOperation - : vectorOperation (powOp vectorOperation | subqueryOp) + : vectorOperation (powOp vectorOperation | subqueryOp) | unaryOp vectorOperation | vectorOperation multOp vectorOperation | vectorOperation addOp vectorOperation @@ -13,9 +20,9 @@ vectorOperation | vectorOperation andUnlessOp vectorOperation | vectorOperation orOp vectorOperation | vectorOperation vectorMatchOp vectorOperation - | name LEFT_BRACE vectorOperation (COMMA vectorOperation)* RIGHT_BRACE + | name LEFT_BRACE vectorOperation (COMMA vectorOperation)* RIGHT_BRACE | LEFT_PAREN vectorOperation RIGHT_PAREN - | name LEFT_PAREN (STRING|NUMBER|UUID) (COMMA LIMIT? (STRING|NUMBER|UUID))* RIGHT_PAREN metricsAggregation* + | name LEFT_PAREN (STRING | NUMBER | UUID) (COMMA LIMIT? (STRING | NUMBER | UUID))* RIGHT_PAREN metricsAggregation* | vectorOperation metricsAggregation | NUMBER | STRING @@ -24,40 +31,106 @@ vectorOperation // Operators +unaryOp + : ADD + | SUB + ; + +powOp + : POW grouping? + ; + +multOp + : (MULT | DIV | MOD) grouping? + ; + +addOp + : (ADD | SUB) grouping? + ; + +compareOp + : (DEQ | NE | GT | LT | GE | LE) BOOL? grouping? + ; + +andUnlessOp + : (AND | UNLESS) grouping? + ; + +orOp + : OR grouping? + ; + +vectorMatchOp + : (ON | UNLESS) grouping? + ; + +subqueryOp + : SUBQUERY_RANGE offsetOp? + ; -unaryOp: ADD | SUB; -powOp: POW grouping?; -multOp: (MULT | DIV | MOD) grouping?; -addOp: (ADD | SUB) grouping?; -compareOp: (DEQ | NE | GT | LT | GE | LE) BOOL? grouping?; -andUnlessOp: (AND | UNLESS) grouping?; -orOp: OR grouping?; -vectorMatchOp: (ON | UNLESS) grouping?; -subqueryOp: SUBQUERY_RANGE offsetOp?; -offsetOp: OFFSET DURATION; +offsetOp + : OFFSET DURATION + ; // Functions -parameter: literal | vectorOperation; -parameterList: LEFT_PAREN (parameter (COMMA parameter)*)? RIGHT_PAREN; -metricsAggregation: LINE_ name parameterList; -multMetrics: COMMA vectorOperation; -by: BY labelNameList; -without: WITHOUT labelNameList; +parameter + : literal + | vectorOperation + ; + +parameterList + : LEFT_PAREN (parameter (COMMA parameter)*)? RIGHT_PAREN + ; + +metricsAggregation + : LINE_ name parameterList + ; + +multMetrics + : COMMA vectorOperation + ; + +by + : BY labelNameList + ; + +without + : WITHOUT labelNameList + ; // Vector one-to-one/one-to-many joins -grouping: (on_ | ignoring) (groupLeft | groupRight)?; -on_: ON labelNameList; -ignoring: IGNORING labelNameList; -groupLeft: GROUP_LEFT labelNameList?; -groupRight: GROUP_RIGHT labelNameList?; +grouping + : (on_ | ignoring) (groupLeft | groupRight)? + ; + +on_ + : ON labelNameList + ; + +ignoring + : IGNORING labelNameList + ; + +groupLeft + : GROUP_LEFT labelNameList? + ; + +groupRight + : GROUP_RIGHT labelNameList? + ; // Label names -name: keyword | NAME; +name + : keyword + | NAME + ; -labelNameList: LEFT_PAREN (name (COMMA name)*)? RIGHT_PAREN; +labelNameList + : LEFT_PAREN (name (COMMA name)*)? RIGHT_PAREN + ; keyword : AND @@ -73,15 +146,24 @@ keyword | BOOL ; -literal: NUMBER | STRING; +literal + : NUMBER + | STRING + ; -fragment NUMERAL: [0-9]+ ('.' [0-9]+)?; +fragment NUMERAL + : [0-9]+ ('.' [0-9]+)? + ; fragment SCIENTIFIC_NUMBER - : NUMERAL ('e' ('-' | '+')? NUMERAL)? - ; + : NUMERAL ('e' ('-' | '+')? NUMERAL)? + ; + +NUMBER + : NUMERAL + | SCIENTIFIC_NUMBER + ; -NUMBER: NUMERAL | SCIENTIFIC_NUMBER; STRING : '\'' (~('\'' | '\\') | '\\' .)* '\'' | '"' (~('"' | '\\') | '\\' .)* '"' @@ -89,70 +171,220 @@ STRING // Binary operators -ADD: '+'; -SUB: '-'; -MULT: '*'; -DIV: '/'; -MOD: '%'; -POW: '^'; +ADD + : '+' + ; -AND: 'and'; -OR: 'or'; -UNLESS: 'unless'; +SUB + : '-' + ; + +MULT + : '*' + ; + +DIV + : '/' + ; + +MOD + : '%' + ; + +POW + : '^' + ; + +AND + : 'and' + ; + +OR + : 'or' + ; + +UNLESS + : 'unless' + ; // Comparison operators -EQ: '='; -DEQ: '=='; -NE: '!='; -GT: '>'; -LT: '<'; -GE: '>='; -LE: '<='; -RE: '=~'; -NRE: '!~'; +EQ + : '=' + ; + +DEQ + : '==' + ; + +NE + : '!=' + ; + +GT + : '>' + ; + +LT + : '<' + ; + +GE + : '>=' + ; + +LE + : '<=' + ; + +RE + : '=~' + ; + +NRE + : '!~' + ; // Aggregation modifiers -BY: 'by'; -WITHOUT: 'without'; +BY + : 'by' + ; + +WITHOUT + : 'without' + ; // Join modifiers -ON: 'on'; -IGNORING: 'ignoring'; -GROUP_LEFT: 'group_left'; -GROUP_RIGHT: 'group_right'; -OFFSET: 'offset'; - -BOOL: 'bool'; - -LEFT_BRACE: '{'; -RIGHT_BRACE: '}'; -LEFT_PAREN: '('; -RIGHT_PAREN: ')'; -LEFT_BRACKET: '['; -RIGHT_BRACKET: ']'; -COMMA: ','; -LINE_: '|'; -COLON: ':'; - -SUBQUERY_RANGE : LEFT_BRACKET DURATION ':' DURATION? RIGHT_BRACKET; -TIME_RANGE : LEFT_BRACKET DURATION RIGHT_BRACKET; -DURATION: [0-9]+ ('s' | 'm' | 'h' | 'd' | 'w' | 'y'); -NAME: [a-z_:] [a-z0-9_:]*; -LIMIT: 'limit='; -UUID: Time_low '-' Time_mid '-' Time_high_and_version '-' Clock_seq_and_reserved Clock_seq_low '-' Node ; -fragment Time_low: FourHexOctet; -fragment Time_mid: TwoHexOctet; -fragment Time_high_and_version: TwoHexOctet; -fragment Clock_seq_and_reserved: HexOctet; -fragment Clock_seq_low: HexOctet; -fragment Node: SixHexOctet; -fragment HexOctet: HexDigit HexDigit; -fragment HexDigit: [0-9a-fA-F]; -fragment SixHexOctet: HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit; -fragment FourHexOctet: HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit; -fragment TwoHexOctet: HexDigit HexDigit HexDigit HexDigit ; - -WS: [\r\t\n ]+ -> channel(HIDDEN); +ON + : 'on' + ; + +IGNORING + : 'ignoring' + ; + +GROUP_LEFT + : 'group_left' + ; + +GROUP_RIGHT + : 'group_right' + ; + +OFFSET + : 'offset' + ; + +BOOL + : 'bool' + ; + +LEFT_BRACE + : '{' + ; + +RIGHT_BRACE + : '}' + ; + +LEFT_PAREN + : '(' + ; + +RIGHT_PAREN + : ')' + ; + +LEFT_BRACKET + : '[' + ; + +RIGHT_BRACKET + : ']' + ; + +COMMA + : ',' + ; + +LINE_ + : '|' + ; + +COLON + : ':' + ; + +SUBQUERY_RANGE + : LEFT_BRACKET DURATION ':' DURATION? RIGHT_BRACKET + ; + +TIME_RANGE + : LEFT_BRACKET DURATION RIGHT_BRACKET + ; + +DURATION + : [0-9]+ ('s' | 'm' | 'h' | 'd' | 'w' | 'y') + ; + +NAME + : [a-z_:] [a-z0-9_:]* + ; + +LIMIT + : 'limit=' + ; + +UUID + : Time_low '-' Time_mid '-' Time_high_and_version '-' Clock_seq_and_reserved Clock_seq_low '-' Node + ; + +fragment Time_low + : FourHexOctet + ; + +fragment Time_mid + : TwoHexOctet + ; + +fragment Time_high_and_version + : TwoHexOctet + ; + +fragment Clock_seq_and_reserved + : HexOctet + ; + +fragment Clock_seq_low + : HexOctet + ; + +fragment Node + : SixHexOctet + ; + +fragment HexOctet + : HexDigit HexDigit + ; + +fragment HexDigit + : [0-9a-fA-F] + ; + +fragment SixHexOctet + : HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit + ; + +fragment FourHexOctet + : HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit + ; + +fragment TwoHexOctet + : HexDigit HexDigit HexDigit HexDigit + ; + +WS + : [\r\t\n ]+ -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/caql/Metrics.g4 b/caql/Metrics.g4 index 16aa276767..375afd102b 100644 --- a/caql/Metrics.g4 +++ b/caql/Metrics.g4 @@ -1,18 +1,52 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Metrics; -start: expr EOF; +start + : expr EOF + ; + +expr + : op = (AND | OR) LEFT_PAREN metricsName = STRING COLON metricsValue = STRING metricsMult* RIGHT_PAREN + ; + +metricsMult + : COMMA metricsName = STRING COLON metricsValue = STRING + ; + +LEFT_PAREN + : '(' + ; + +RIGHT_PAREN + : ')' + ; + +AND + : 'and' + ; + +OR + : 'or' + ; + +COMMA + : ',' + ; + +STRING + : [a-zA-Z0-9_*=/"]+ [a-zA-Z0-9_*=/ "]+ [a-zA-Z0-9_*=/"]+ + ; + +COLON + : ':' + ; -expr: - op=(AND|OR) LEFT_PAREN metricsName=STRING COLON metricsValue=STRING metricsMult* RIGHT_PAREN +WS + : [ \t\n\r\u000C]+ -> skip ; -metricsMult: COMMA metricsName=STRING COLON metricsValue=STRING; -LEFT_PAREN: '('; -RIGHT_PAREN: ')'; -AND: 'and'; -OR: 'or'; -COMMA: ','; -STRING: [a-zA-Z0-9_*=/"]+[a-zA-Z0-9_*=/ "]+[a-zA-Z0-9_*=/"]+; -COLON: ':'; -WS: [ \t\n\r\u000C]+ -> skip; -SHEBANG : '#' '!' ~('\n'|'\r')* -> channel(HIDDEN); +SHEBANG + : '#' '!' ~('\n' | '\r')* -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/cayenne/cayenne.g4 b/cayenne/cayenne.g4 index 79e408645c..cf944d936a 100644 --- a/cayenne/cayenne.g4 +++ b/cayenne/cayenne.g4 @@ -25,44 +25,77 @@ // http://citeseer.ist.psu.edu/viewdoc/download;jsessionid=F54E0B46B27FC0AEF07271B358CE34E3?doi=10.1.1.47.155&rep=rep1&type=pdf -grammar cayenne; - -file_: expr EOF ; - -expr: - '(' varid '::' type_ ')' '->' expr - | '\\' '(' varid '::' type_ ')' '->' expr - | expr expr - | 'data' (conid type_* '|')* - | conid '@' type_ - | 'case' varid 'of' arm* '::' type_ - | 'sig' sign* - | 'struct' defn* - | expr '.' lblid - | id_ - | '#'; - -arm: '(' conid varid* ')' '->' expr ';' | varid '->' expr ';'; - -sign: lblid '::' type_ ';' | lblid '::' type_ '=' expr ';'; - -defn: vis lblid '::' type_ '=' expr ';'; - -vis: 'private' | 'public' abs_; - -abs_: 'abstract' | 'concrete'; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -type_: expr; - -varid: id_; - -conid: id_; - -lblid: id_; - -id_: ID; - -ID: [a-zA-Z] [a-zA-Z0-9]*; - -WS: [ \r\n\t]+ -> skip; +grammar cayenne; +file_ + : expr EOF + ; + +expr + : '(' varid '::' type_ ')' '->' expr + | '\\' '(' varid '::' type_ ')' '->' expr + | expr expr + | 'data' (conid type_* '|')* + | conid '@' type_ + | 'case' varid 'of' arm* '::' type_ + | 'sig' sign* + | 'struct' defn* + | expr '.' lblid + | id_ + | '#' + ; + +arm + : '(' conid varid* ')' '->' expr ';' + | varid '->' expr ';' + ; + +sign + : lblid '::' type_ ';' + | lblid '::' type_ '=' expr ';' + ; + +defn + : vis lblid '::' type_ '=' expr ';' + ; + +vis + : 'private' + | 'public' abs_ + ; + +abs_ + : 'abstract' + | 'concrete' + ; + +type_ + : expr + ; + +varid + : id_ + ; + +conid + : id_ + ; + +lblid + : id_ + ; + +id_ + : ID + ; + +ID + : [a-zA-Z] [a-zA-Z0-9]* + ; + +WS + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/chip8/chip8.g4 b/chip8/chip8.g4 index 5c2f2a42eb..d720395fa8 100644 --- a/chip8/chip8.g4 +++ b/chip8/chip8.g4 @@ -29,207 +29,210 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar chip8; file_ - : instruction_* EOF - ; + : instruction_* EOF + ; instruction_ - : cls - | ret - | sys - | jp - | call - | se - | sne - | se1 - | ld - | add - | ld2 - | or - | and - | xor - | add2 - | sub - | shr - | subn - | shl - | sne2 - | ld3 - | jp2 - | rnd - | drw - | skp - | sknp - | ld4 - | ld5 - | ld6 - | ld7 - | add3 - | ld8 - | ld9 - | ld10 - | ld11 - ; + : cls + | ret + | sys + | jp + | call + | se + | sne + | se1 + | ld + | add + | ld2 + | or + | and + | xor + | add2 + | sub + | shr + | subn + | shl + | sne2 + | ld3 + | jp2 + | rnd + | drw + | skp + | sknp + | ld4 + | ld5 + | ld6 + | ld7 + | add3 + | ld8 + | ld9 + | ld10 + | ld11 + ; cls - : 'CLS' - ; + : 'CLS' + ; ret - : 'RET' - ; + : 'RET' + ; sys - : 'SYS' ADDR - ; + : 'SYS' ADDR + ; jp - : 'JP' ADDR - ; + : 'JP' ADDR + ; call - : 'CALL' ADDR - ; + : 'CALL' ADDR + ; se - : 'SE' REGISTER ',' BYTE - ; + : 'SE' REGISTER ',' BYTE + ; sne - : 'SNE' REGISTER ',' BYTE - ; + : 'SNE' REGISTER ',' BYTE + ; se1 - : 'SE' REGISTER ',' REGISTER - ; + : 'SE' REGISTER ',' REGISTER + ; ld - : 'LD' REGISTER ',' BYTE - ; + : 'LD' REGISTER ',' BYTE + ; add - : 'ADD' REGISTER ',' BYTE - ; + : 'ADD' REGISTER ',' BYTE + ; ld2 - : 'LD' REGISTER ',' REGISTER - ; + : 'LD' REGISTER ',' REGISTER + ; or - : 'OR' REGISTER ',' REGISTER - ; + : 'OR' REGISTER ',' REGISTER + ; and - : 'AND' REGISTER ',' REGISTER - ; + : 'AND' REGISTER ',' REGISTER + ; xor - : 'XOR' REGISTER ',' REGISTER - ; + : 'XOR' REGISTER ',' REGISTER + ; add2 - : 'ADD' REGISTER ',' REGISTER - ; + : 'ADD' REGISTER ',' REGISTER + ; sub - : 'SUB' REGISTER ',' REGISTER - ; + : 'SUB' REGISTER ',' REGISTER + ; shr - : 'SHR' REGISTER '{' ',' REGISTER '}' - ; + : 'SHR' REGISTER '{' ',' REGISTER '}' + ; subn - : 'SUBN' REGISTER ',' REGISTER - ; + : 'SUBN' REGISTER ',' REGISTER + ; shl - : 'SHL' REGISTER '{' ',' REGISTER '}' - ; + : 'SHL' REGISTER '{' ',' REGISTER '}' + ; sne2 - : REGISTER ',' REGISTER - ; + : REGISTER ',' REGISTER + ; ld3 - : 'LD' 'I' ',' ADDR - ; + : 'LD' 'I' ',' ADDR + ; jp2 - : 'JP' 'V' '0' ',' ADDR - ; + : 'JP' 'V' '0' ',' ADDR + ; rnd - : 'RND' REGISTER ',' BYTE - ; + : 'RND' REGISTER ',' BYTE + ; drw - : 'DRW' REGISTER ',' REGISTER ',' DIGIT - ; + : 'DRW' REGISTER ',' REGISTER ',' DIGIT + ; skp - : 'SKP' REGISTER - ; + : 'SKP' REGISTER + ; sknp - : 'SKNP' REGISTER - ; + : 'SKNP' REGISTER + ; ld4 - : 'LD' REGISTER ',' 'DT' - ; + : 'LD' REGISTER ',' 'DT' + ; ld5 - : 'LD' REGISTER ',' 'K' - ; + : 'LD' REGISTER ',' 'K' + ; ld6 - : 'LD' 'DT' ',' REGISTER - ; + : 'LD' 'DT' ',' REGISTER + ; ld7 - : 'LD' 'ST' ',' REGISTER - ; + : 'LD' 'ST' ',' REGISTER + ; add3 - : 'ADD' 'I' ',' REGISTER - ; + : 'ADD' 'I' ',' REGISTER + ; ld8 - : 'LD' 'F' ',' REGISTER - ; + : 'LD' 'F' ',' REGISTER + ; ld9 - : 'LD' 'B' ',' REGISTER - ; + : 'LD' 'B' ',' REGISTER + ; ld10 - : '[' 'I' ']' ',' REGISTER - ; + : '[' 'I' ']' ',' REGISTER + ; ld11 - : 'LD' REGISTER ',' '[' 'I' ']' - ; + : 'LD' REGISTER ',' '[' 'I' ']' + ; REGISTER - : 'V' DIGIT - ; + : 'V' DIGIT + ; ADDR - : DIGIT DIGIT DIGIT - ; + : DIGIT DIGIT DIGIT + ; BYTE - : DIGIT DIGIT - ; + : DIGIT DIGIT + ; DIGIT - : [0-9A-F] - ; + : [0-9A-F] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/clf/clf.g4 b/clf/clf.g4 index 39e1d10526..8617a33994 100644 --- a/clf/clf.g4 +++ b/clf/clf.g4 @@ -30,90 +30,85 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar clf; log - : (line? EOL) + line? EOF - ; + : (line? EOL)+ line? EOF + ; // combined log format has the referer and useragent fields line - : host logname username datetimetz request statuscode bytes (referer useragent)? - ; + : host logname username datetimetz request statuscode bytes (referer useragent)? + ; host - : STRING - | IP - ; + : STRING + | IP + ; logname - : STRING - ; + : STRING + ; username - : STRING - ; + : STRING + ; datetimetz - : '[' DATE ':' TIME TZ ']' - ; - + : '[' DATE ':' TIME TZ ']' + ; DATE - : [0-9] + '/' STRING '/' [0-9] + - ; - + : [0-9]+ '/' STRING '/' [0-9]+ + ; TIME - : [0-9] + ':' [0-9] + ':' [0-9] + - ; - + : [0-9]+ ':' [0-9]+ ':' [0-9]+ + ; TZ - : '-' [0-9] + - ; + : '-' [0-9]+ + ; referer - : LITERAL - ; + : LITERAL + ; request - : LITERAL - ; + : LITERAL + ; useragent - : LITERAL - ; + : LITERAL + ; statuscode - : STRING - ; + : STRING + ; bytes - : STRING - ; - + : STRING + ; LITERAL - : '"' ~ '"'* '"' - ; - + : '"' ~ '"'* '"' + ; IP - : [0-9] + '.' [0-9] + '.' [0-9] + '.' [0-9] + - ; - + : [0-9]+ '.' [0-9]+ '.' [0-9]+ '.' [0-9]+ + ; STRING - : [a-zA-Z0-9();._-] + - ; - + : [a-zA-Z0-9();._-]+ + ; EOL - : '\r'? '\n' - ; - + : '\r'? '\n' + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/clif/CLIF.g4 b/clif/CLIF.g4 index ca860b8d01..3af4adc7d2 100644 --- a/clif/CLIF.g4 +++ b/clif/CLIF.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2015 Adam Taylor @@ -38,208 +37,272 @@ http://stl.mie.utoronto.ca/colore/ */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar CLIF; //A.2.3.1 Term sequence termseq - : (term | SEQMARK)* - ; + : (term | SEQMARK)* + ; //A.2.3.2 Name interpretedname - : NUMERAL - | QUOTEDSTRING - ; - + : NUMERAL + | QUOTEDSTRING + ; + interpretablename - : NAMECHARSEQUENCE - | ENCLOSEDNAME - ; - + : NAMECHARSEQUENCE + | ENCLOSEDNAME + ; + name - : interpretedname - | interpretablename - ; - - + : interpretedname + | interpretablename + ; + //A.2.3.3 Term term - : name - | OPEN operator_ termseq CLOSE - | OPEN 'cl-comment' QUOTEDSTRING term CLOSE - ; - + : name + | OPEN operator_ termseq CLOSE + | OPEN 'cl-comment' QUOTEDSTRING term CLOSE + ; + operator_ - : term - ; - + : term + ; //A.2.3.4 Equation equation - : OPEN '=' term term CLOSE - ; - - + : OPEN '=' term term CLOSE + ; + //A.2.3.5 Sentence sentence - : atomsent - | boolsent - | quantsent - | commentsent - ; - + : atomsent + | boolsent + | quantsent + | commentsent + ; //A.2.3.6 Atomic sentence atomsent - : equation - | atom - ; - + : equation + | atom + ; + atom - : OPEN predicate termseq CLOSE - | OPEN term OPEN 'cl-roleset' OPEN name term CLOSE CLOSE CLOSE - ; - -predicate - : term - ; + : OPEN predicate termseq CLOSE + | OPEN term OPEN 'cl-roleset' OPEN name term CLOSE CLOSE CLOSE + ; +predicate + : term + ; //A.2.3.7 Boolean sentence boolsent - : OPEN ('and' | 'or') sentence* CLOSE - | OPEN ('if' | 'iff') sentence sentence CLOSE - | OPEN 'not' sentence CLOSE - ; - + : OPEN ('and' | 'or') sentence* CLOSE + | OPEN ('if' | 'iff') sentence sentence CLOSE + | OPEN 'not' sentence CLOSE + ; //A.2.3.8 Quantified sentence quantsent - : OPEN ('forall' | 'exists') interpretablename? boundlist sentence CLOSE - ; - + : OPEN ('forall' | 'exists') interpretablename? boundlist sentence CLOSE + ; + boundlist - : OPEN - ( interpretablename - | SEQMARK - | OPEN (interpretablename | SEQMARK) term CLOSE - )* - CLOSE - ; + : OPEN (interpretablename | SEQMARK | OPEN (interpretablename | SEQMARK) term CLOSE)* CLOSE + ; //A.2.3.9 Commented sentence commentsent - : OPEN 'cl-comment' ENCLOSEDNAME sentence CLOSE - ; - + : OPEN 'cl-comment' ENCLOSEDNAME sentence CLOSE + ; //A.2.3.10 Module module - : OPEN 'cl-module' interpretablename (OPEN 'cl-excludes' name* CLOSE)? cltext? CLOSE - ; - + : OPEN 'cl-module' interpretablename (OPEN 'cl-excludes' name* CLOSE)? cltext? CLOSE + ; //A.2.3.11 Phrase phrase - : sentence - | module - | OPEN 'cl-imports' interpretablename CLOSE - | OPEN 'cl-comment' ENCLOSEDNAME cltext? CLOSE - ; + : sentence + | module + | OPEN 'cl-imports' interpretablename CLOSE + | OPEN 'cl-comment' ENCLOSEDNAME cltext? CLOSE + ; text - : phrase+ - ; - + : phrase+ + ; + cltext - : module - | namedtext - | text - ; - -namedtext - : OPEN 'cl-text' interpretablename text? CLOSE ; + : module + | namedtext + | text + ; +namedtext + : OPEN 'cl-text' interpretablename text? CLOSE + ; //A.2.2.2 Delimiters -OPEN : '('; -CLOSE : ')'; -STRINGQUOTE : '\''; -NAMEQUOTE : '"'; -BACKSLASH : '\\'; +OPEN + : '(' + ; +CLOSE + : ')' + ; -//A.2.2.3 Characters -fragment -CHAR : [0-9~!#$%^&*_+{}|:<>?`\-=[\];,./A-Za-z]; +STRINGQUOTE + : '\'' + ; -fragment -DIGIT : [0-9]; +NAMEQUOTE + : '"' + ; -fragment -HEXA : [0-9A-Fa-f]; +BACKSLASH + : '\\' + ; + +//A.2.2.3 Characters +fragment CHAR + : [0-9~!#$%^&*_+{}|:<>?`\-=[\];,./A-Za-z] + ; +fragment DIGIT + : [0-9] + ; + +fragment HEXA + : [0-9A-Fa-f] + ; //A.2.2.4 Quoting within strings -fragment -NONASCII - : '\\' 'u' HEXA HEXA HEXA HEXA - | '\\' 'U' HEXA HEXA HEXA HEXA HEXA HEXA - ; - -fragment -INNERSTRINGQUOTE : '\'' ; +fragment NONASCII + : '\\' 'u' HEXA HEXA HEXA HEXA + | '\\' 'U' HEXA HEXA HEXA HEXA HEXA HEXA + ; -fragment -INNERNAMEQUOTE : '"' ; +fragment INNERSTRINGQUOTE + : '\'' + ; -fragment -INNERBACKSLASH : '\\'; +fragment INNERNAMEQUOTE + : '"' + ; -NUMERAL : DIGIT+; -SEQMARK : '...' CHAR*; +fragment INNERBACKSLASH + : '\\' + ; +NUMERAL + : DIGIT+ + ; -//A.2.2.5 Quoted strings -QUOTEDSTRING : STRINGQUOTE (WHITE | OPEN | CLOSE | CHAR | NONASCII | NAMEQUOTE | INNERSTRINGQUOTE | INNERBACKSLASH )* STRINGQUOTE ; -ENCLOSEDNAME : NAMEQUOTE (WHITE | OPEN | CLOSE | CHAR | NONASCII | STRINGQUOTE | INNERNAMEQUOTE )* NAMEQUOTE ; +SEQMARK + : '...' CHAR* + ; +//A.2.2.5 Quoted strings +QUOTEDSTRING + : STRINGQUOTE ( + WHITE + | OPEN + | CLOSE + | CHAR + | NONASCII + | NAMEQUOTE + | INNERSTRINGQUOTE + | INNERBACKSLASH + )* STRINGQUOTE + ; + +ENCLOSEDNAME + : NAMEQUOTE (WHITE | OPEN | CLOSE | CHAR | NONASCII | STRINGQUOTE | INNERNAMEQUOTE)* NAMEQUOTE + ; //A.2.2.6 Reserved tokens -EQUAL : '='; -AND : 'and'; -OR : 'or'; -IFF : 'iff'; -IF : 'if'; -FORALL : 'forall'; -EXISTS : 'exists'; -NOT : 'not'; -CL_ROLESET : 'cl-roleset'; -CL_TEXT : 'cl-text'; -CL_IMPORTS : 'cl-imports'; -CL_EXCLUDES : 'cl-excludes'; -CL_MODULE : 'cl-module'; -CL_COMMENT : 'cl-comment'; -CL_PREFIX : 'cl-prefix'; +EQUAL + : '=' + ; + +AND + : 'and' + ; + +OR + : 'or' + ; + +IFF + : 'iff' + ; + +IF + : 'if' + ; + +FORALL + : 'forall' + ; + +EXISTS + : 'exists' + ; + +NOT + : 'not' + ; +CL_ROLESET + : 'cl-roleset' + ; + +CL_TEXT + : 'cl-text' + ; + +CL_IMPORTS + : 'cl-imports' + ; + +CL_EXCLUDES + : 'cl-excludes' + ; + +CL_MODULE + : 'cl-module' + ; + +CL_COMMENT + : 'cl-comment' + ; + +CL_PREFIX + : 'cl-prefix' + ; //A.2.2.7 Name character sequence NAMECHARSEQUENCE - : CHAR (CHAR | STRINGQUOTE | NAMEQUOTE | BACKSLASH)* - ; - + : CHAR (CHAR | STRINGQUOTE | NAMEQUOTE | BACKSLASH)* + ; // A.2.2.1 White space WHITE - : [ \t\n\r\u000B] -> skip - ; - -BLOCKCOMMENT - : '/*' (BLOCKCOMMENT | .)*? '*/' -> skip // nesting allowed (but should it be?) - ; - -LineComment - : '//' ~[\u000A\u000D]* -> skip - ; + : [ \t\n\r\u000B] -> skip + ; +BLOCKCOMMENT + : '/*' (BLOCKCOMMENT | .)*? '*/' -> skip // nesting allowed (but should it be?) + ; +LineComment + : '//' ~[\u000A\u000D]* -> skip + ; \ No newline at end of file diff --git a/clojure/Clojure.g4 b/clojure/Clojure.g4 index 8675ff3daa..f313cad5e0 100644 --- a/clojure/Clojure.g4 +++ b/clojure/Clojure.g4 @@ -23,26 +23,42 @@ crap in parens" but I guess that is LISP for you ;) */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Clojure; -file_: form * EOF; +file_ + : form* EOF + ; -form: literal +form + : literal | list_ | vector | map_ | reader_macro ; -forms: form* ; +forms + : form* + ; -list_: '(' forms ')' ; +list_ + : '(' forms ')' + ; -vector: '[' forms ']' ; +vector + : '[' forms ']' + ; -map_: '{' (form form)* '}' ; +map_ + : '{' (form form)* '}' + ; -set_: '#{' forms '}' ; +set_ + : '#{' forms '}' + ; reader_macro : lambda_ @@ -130,10 +146,22 @@ literal | param_name ; -string_: STRING; -hex_: HEX; -bin_: BIN; -bign: BIGN; +string_ + : STRING + ; + +hex_ + : HEX + ; + +bin_ + : BIN + ; + +bign + : BIGN + ; + number : FLOAT | hex_ @@ -147,26 +175,59 @@ character | u_hex_quad | any_char ; -named_char: CHAR_NAMED ; -any_char: CHAR_ANY ; -u_hex_quad: CHAR_U ; -nil_: NIL; +named_char + : CHAR_NAMED + ; + +any_char + : CHAR_ANY + ; + +u_hex_quad + : CHAR_U + ; + +nil_ + : NIL + ; + +keyword + : macro_keyword + | simple_keyword + ; + +simple_keyword + : ':' symbol + ; + +macro_keyword + : ':' ':' symbol + ; + +symbol + : ns_symbol + | simple_sym + ; -keyword: macro_keyword | simple_keyword; -simple_keyword: ':' symbol; -macro_keyword: ':' ':' symbol; +simple_sym + : SYMBOL + ; -symbol: ns_symbol | simple_sym; -simple_sym: SYMBOL; -ns_symbol: NS_SYMBOL; +ns_symbol + : NS_SYMBOL + ; -param_name: PARAM_NAME; +param_name + : PARAM_NAME + ; // Lexers //-------------------------------------------------------------------- -STRING : '"' ( ~'"' | '\\' '"' )* '"' ; +STRING + : '"' (~'"' | '\\' '"')* '"' + ; // FIXME: Doesn't deal with arbitrary read radixes, BigNums FLOAT @@ -175,44 +236,60 @@ FLOAT | '-'? 'NaN' ; -fragment -FLOAT_TAIL +fragment FLOAT_TAIL : FLOAT_DECIMAL FLOAT_EXP | FLOAT_DECIMAL | FLOAT_EXP ; -fragment -FLOAT_DECIMAL +fragment FLOAT_DECIMAL : '.' [0-9]+ ; -fragment -FLOAT_EXP +fragment FLOAT_EXP : [eE] '-'? [0-9]+ ; -fragment -HEXD: [0-9a-fA-F] ; -HEX: '0' [xX] HEXD+ ; -BIN: '0' [bB] [10]+ ; -LONG: '-'? [0-9]+[lL]?; -BIGN: '-'? [0-9]+[nN]; + +fragment HEXD + : [0-9a-fA-F] + ; + +HEX + : '0' [xX] HEXD+ + ; + +BIN + : '0' [bB] [10]+ + ; + +LONG + : '-'? [0-9]+ [lL]? + ; + +BIGN + : '-'? [0-9]+ [nN] + ; CHAR_U - : '\\' 'u'[0-9D-Fd-f] HEXD HEXD HEXD ; + : '\\' 'u' [0-9D-Fd-f] HEXD HEXD HEXD + ; + CHAR_NAMED - : '\\' ( 'newline' - | 'return' - | 'space' - | 'tab' - | 'formfeed' - | 'backspace' ) ; + : '\\' ('newline' | 'return' | 'space' | 'tab' | 'formfeed' | 'backspace') + ; + CHAR_ANY - : '\\' . ; + : '\\' . + ; -NIL : 'nil'; +NIL + : 'nil' + ; -BOOLEAN : 'true' | 'false' ; +BOOLEAN + : 'true' + | 'false' + ; SYMBOL : '.' @@ -224,38 +301,57 @@ NS_SYMBOL : NAME '/' SYMBOL ; -PARAM_NAME: '%' ('1'..'9' '0'..'9'* | '&')? ; +PARAM_NAME + : '%' ('1' ..'9' '0' ..'9'* | '&')? + ; // Fragments //-------------------------------------------------------------------- -fragment -NAME: SYMBOL_HEAD SYMBOL_REST* (':' SYMBOL_REST+)* ; +fragment NAME + : SYMBOL_HEAD SYMBOL_REST* (':' SYMBOL_REST+)* + ; -fragment -SYMBOL_HEAD - : ~('0' .. '9' - | '^' | '`' | '\'' | '"' | '#' | '~' | '@' | ':' | '/' | '%' | '(' | ')' | '[' | ']' | '{' | '}' // FIXME: could be one group +fragment SYMBOL_HEAD + : ~( + '0' .. '9' + | '^' + | '`' + | '\'' + | '"' + | '#' + | '~' + | '@' + | ':' + | '/' + | '%' + | '(' + | ')' + | '[' + | ']' + | '{' + | '}' // FIXME: could be one group | [ \n\r\t,] // FIXME: could be WS - ) + ) ; -fragment -SYMBOL_REST +fragment SYMBOL_REST : SYMBOL_HEAD - | '0'..'9' + | '0' ..'9' | '.' ; // Discard //-------------------------------------------------------------------- -fragment -WS : [ \n\r\t,] ; +fragment WS + : [ \n\r\t,] + ; -fragment -COMMENT: ';' ~[\r\n]* ; +fragment COMMENT + : ';' ~[\r\n]* + ; TRASH - : ( WS | COMMENT ) -> channel(HIDDEN) - ; + : (WS | COMMENT) -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/clu/clu.g4 b/clu/clu.g4 index c954bbf57f..40e21944e8 100644 --- a/clu/clu.g4 +++ b/clu/clu.g4 @@ -23,274 +23,276 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar clu; module - : equate* (procedure | iterator | cluster) EOF - ; + : equate* (procedure | iterator | cluster) EOF + ; procedure - : idn '=' 'proc' parms? args returnz? signals? where_? routine_body 'end' idn - ; + : idn '=' 'proc' parms? args returnz? signals? where_? routine_body 'end' idn + ; iterator - : idn '=' 'iter' parms? args yields? signals? where_? routine_body 'end' idn - ; + : idn '=' 'iter' parms? args yields? signals? where_? routine_body 'end' idn + ; cluster - : idn '=' 'cluster' parms? 'is' idn_list where_? cluster_body 'end' idn - ; + : idn '=' 'cluster' parms? 'is' idn_list where_? cluster_body 'end' idn + ; parms - : param (',' param)* - ; + : param (',' param)* + ; param - : idn_list ':' ('type' | type_spec) - ; + : idn_list ':' ('type' | type_spec) + ; args - : '(' decl_list? ')' - ; + : '(' decl_list? ')' + ; decl_list - : decl (',' decl)* - ; + : decl (',' decl)* + ; decl - : idn_list ':' type_spec - ; + : idn_list ':' type_spec + ; returnz - : 'returns' '(' type_spec_list ')' - ; + : 'returns' '(' type_spec_list ')' + ; yields - : 'yields' '(' type_spec_list ')' - ; + : 'yields' '(' type_spec_list ')' + ; signals - : 'signals' '(' exception_ (',' exception_)* ')' - ; + : 'signals' '(' exception_ (',' exception_)* ')' + ; exception_ - : name type_spec_list? - ; + : name type_spec_list? + ; type_spec_list - : type_spec (',' type_spec)* - ; + : type_spec (',' type_spec)* + ; where_ - : 'where' restriction (',' restriction)* - ; + : 'where' restriction (',' restriction)* + ; restriction - : idn ('has' oper_decl_list | 'in' type_set) - ; + : idn ('has' oper_decl_list | 'in' type_set) + ; type_set - : (idn | idn 'has' oper_decl_list equate*)* - | idn - ; + : (idn | idn 'has' oper_decl_list equate*)* + | idn + ; oper_decl_list - : oper_decl (',' oper_decl)* - ; + : oper_decl (',' oper_decl)* + ; oper_decl - : op_name_list ':' type_spec - ; + : op_name_list ':' type_spec + ; op_name_list - : op_name (',' op_name)* - ; + : op_name (',' op_name)* + ; op_name - : name '[' constant_list? ']' - ; + : name '[' constant_list? ']' + ; constant_list - : constant (',' constant)* - ; + : constant (',' constant)* + ; constant - : expression - | type_spec - ; + : expression + | type_spec + ; routine_body - : equate* own_var* statement* - ; + : equate* own_var* statement* + ; cluster_body - : equate* 'rep' '=' type_spec equate* own_var* 'routine' routine* - ; + : equate* 'rep' '=' type_spec equate* own_var* 'routine' routine* + ; routine - : procedure - | iterator - ; + : procedure + | iterator + ; equate - : idn '=' (constant | type_set) - ; + : idn '=' (constant | type_set) + ; own_var - : 'own' (decl | idn ':' type_spec ':=' expression | decl_list ':=' invocation) - ; + : 'own' (decl | idn ':' type_spec ':=' expression | decl_list ':=' invocation) + ; type_spec - : 'null' - | 'bool' - | 'int' - | 'real' - | 'char' - | 'string' - | 'any' - | 'rep' - | 'cvt' - | 'array' - | 'sequence' type_spec? - | ('record' | 'struct' | 'oneof' | 'variant') field_spec_list? - | ('proctype' | 'itertype') field_spec_list? returnz? signals? - | idn constant_list? - ; + : 'null' + | 'bool' + | 'int' + | 'real' + | 'char' + | 'string' + | 'any' + | 'rep' + | 'cvt' + | 'array' + | 'sequence' type_spec? + | ('record' | 'struct' | 'oneof' | 'variant') field_spec_list? + | ('proctype' | 'itertype') field_spec_list? returnz? signals? + | idn constant_list? + ; field_spec_list - : field_spec (',' field_spec)* - ; + : field_spec (',' field_spec)* + ; field_spec - : name_list ':' type_spec - ; + : name_list ':' type_spec + ; statement - : decl - | idn ':' type_spec ':=' expression - | decl_list ':=' invocation - | idn_list ':=' (invocation | expression_list) - | primary '.' name ':=' expression - | invocation - | 'while' expression 'do' body 'end' - | 'for' (decl_list | idn_list)? 'in' invocation 'do' body 'end' - | 'if' expression 'then' body ('elseif' expression 'then' body)* ('else' body)? 'end' - | 'tagcase' expression tag_arm* ('others' ':' body)? 'end' - | ('return' | 'yield') expression_list? - | 'signal' name expression_list? - | 'exit' name expression_list? - | 'break' - | 'begin' body 'end' - | statement ('resignal' name_list | 'except' when_handler* others_handler? 'end') - ; + : decl + | idn ':' type_spec ':=' expression + | decl_list ':=' invocation + | idn_list ':=' (invocation | expression_list) + | primary '.' name ':=' expression + | invocation + | 'while' expression 'do' body 'end' + | 'for' (decl_list | idn_list)? 'in' invocation 'do' body 'end' + | 'if' expression 'then' body ('elseif' expression 'then' body)* ('else' body)? 'end' + | 'tagcase' expression tag_arm* ('others' ':' body)? 'end' + | ('return' | 'yield') expression_list? + | 'signal' name expression_list? + | 'exit' name expression_list? + | 'break' + | 'begin' body 'end' + | statement ('resignal' name_list | 'except' when_handler* others_handler? 'end') + ; tag_arm - : 'tag' name_list ('(' idn ':' type_spec ')')? ':' body - ; + : 'tag' name_list ('(' idn ':' type_spec ')')? ':' body + ; when_handler - : 'when' name_list ('(' '*' ')' | decl_list?) ':' body - ; + : 'when' name_list ('(' '*' ')' | decl_list?) ':' body + ; others_handler - : 'others' ('(' idn ':' type_spec ')')? ':' body - ; + : 'others' ('(' idn ':' type_spec ')')? ':' body + ; body - : equate* statement* - ; + : equate* statement* + ; expression_list - : expression (',' expression)* - ; + : expression (',' expression)* + ; expression - : primary - | '(' expression ')' - | ('~' | '-') expression - | expression '**' expression - | expression ('//' | '/' | '*') expression - | expression ('||' | '+' | '-') expression - | expression ('<' | '<=' | '=' | '>=' | '>' | '~<' | '~<=' | '~=' | '~>=' | '~>') expression - | expression ('&' | 'cand') expression - | expression ('|' | 'cor') expression - ; + : primary + | '(' expression ')' + | ('~' | '-') expression + | expression '**' expression + | expression ('//' | '/' | '*') expression + | expression ('||' | '+' | '-') expression + | expression ('<' | '<=' | '=' | '>=' | '>' | '~<' | '~<=' | '~=' | '~>=' | '~>') expression + | expression ('&' | 'cand') expression + | expression ('|' | 'cor') expression + ; primary - : 'nil' - | 'true' - | 'false' - | int_literal - | real_literal - | string_literal - | idn constant_list? - | primary ('.' name | expression | '(' expression_list? ')') - | type_spec '$' (field_list | '[' (expression ':')? expression_list ']' | name constant_list?) - | 'force' type_spec? - | ('up' | 'down') '(' expression ')' - ; + : 'nil' + | 'true' + | 'false' + | int_literal + | real_literal + | string_literal + | idn constant_list? + | primary ('.' name | expression | '(' expression_list? ')') + | type_spec '$' (field_list | '[' (expression ':')? expression_list ']' | name constant_list?) + | 'force' type_spec? + | ('up' | 'down') '(' expression ')' + ; invocation - : primary '(' expression_list ')' - ; + : primary '(' expression_list ')' + ; field_list - : field (',' field)* - ; + : field (',' field)* + ; field - : name_list ':' expression - ; + : name_list ':' expression + ; idn_list - : idn (',' idn)* - ; + : idn (',' idn)* + ; idn - : STRING - ; + : STRING + ; name_list - : name (',' name)* - ; + : name (',' name)* + ; name - : STRING - ; + : STRING + ; int_literal - : INT - ; + : INT + ; real_literal - : FLOAT - ; + : FLOAT + ; string_literal - : STRINGLITERAL - ; + : STRINGLITERAL + ; STRINGLITERAL - : '"' ~'"'* '"' - ; + : '"' ~'"'* '"' + ; STRING - : [a-zA-Z] [a-zA-Z0-9_]* - ; + : [a-zA-Z] [a-zA-Z0-9_]* + ; INT - : [0-9]+ - ; + : [0-9]+ + ; FLOAT - : [0-9]+ '.' [0-9]* - ; + : [0-9]+ '.' [0-9]* + ; COMMENT - : '%' ~[\r\n]* -> channel(HIDDEN) - ; + : '%' ~[\r\n]* -> channel(HIDDEN) + ; WS - : [ \t\r\n]+ -> channel(HIDDEN) - ; - + : [ \t\r\n]+ -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/cmake/CMake.g4 b/cmake/CMake.g4 index af5cebac92..48f1ff1fbc 100644 --- a/cmake/CMake.g4 +++ b/cmake/CMake.g4 @@ -8,90 +8,92 @@ https://cmake.org/cmake/help/v3.12/manual/cmake-language.7.html */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar CMake; file_ - : command_invocation* EOF - ; + : command_invocation* EOF + ; command_invocation - : Identifier '(' (single_argument|compound_argument)* ')' - ; + : Identifier '(' (single_argument | compound_argument)* ')' + ; single_argument - : Identifier | Unquoted_argument | Bracket_argument | Quoted_argument - ; + : Identifier + | Unquoted_argument + | Bracket_argument + | Quoted_argument + ; compound_argument - : '(' (single_argument|compound_argument)* ')' - ; + : '(' (single_argument | compound_argument)* ')' + ; Identifier - : [A-Za-z_][A-Za-z0-9_]* - ; + : [A-Za-z_][A-Za-z0-9_]* + ; Unquoted_argument - : (~[ \t\r\n()#"\\] | Escape_sequence)+ - ; + : (~[ \t\r\n()#"\\] | Escape_sequence)+ + ; Escape_sequence - : Escape_identity | Escape_encoded | Escape_semicolon - ; + : Escape_identity + | Escape_encoded + | Escape_semicolon + ; -fragment -Escape_identity - : '\\' ~[A-Za-z0-9;] - ; +fragment Escape_identity + : '\\' ~[A-Za-z0-9;] + ; -fragment -Escape_encoded - : '\\t' | '\\r' | '\\n' - ; +fragment Escape_encoded + : '\\t' + | '\\r' + | '\\n' + ; -fragment -Escape_semicolon - : '\\;' - ; +fragment Escape_semicolon + : '\\;' + ; Quoted_argument - : '"' (~[\\"] | Escape_sequence | Quoted_cont)* '"' - ; + : '"' (~[\\"] | Escape_sequence | Quoted_cont)* '"' + ; -fragment -Quoted_cont - : '\\' ('\r' '\n'? | '\n') - ; +fragment Quoted_cont + : '\\' ('\r' '\n'? | '\n') + ; Bracket_argument - : '[' Bracket_arg_nested ']' - ; + : '[' Bracket_arg_nested ']' + ; -fragment -Bracket_arg_nested - : '=' Bracket_arg_nested '=' - | '[' .*? ']' - ; +fragment Bracket_arg_nested + : '=' Bracket_arg_nested '=' + | '[' .*? ']' + ; Bracket_comment - : '#[' Bracket_arg_nested ']' - -> skip - ; + : '#[' Bracket_arg_nested ']' -> skip + ; Line_comment - : '#' ( // # - | '[' '='* // #[== - | '[' '='* ~('=' | '[' | '\r' | '\n') ~('\r' | '\n')* // #[==xx - | ~('[' | '\r' | '\n') ~('\r' | '\n')* // #xx - ) ('\r' '\n'? | '\n' | EOF) - -> skip - ; + : '#' ( + // # + | '[' '='* // #[== + | '[' '='* ~('=' | '[' | '\r' | '\n') ~('\r' | '\n')* // #[==xx + | ~('[' | '\r' | '\n') ~('\r' | '\n')* // #xx + ) ('\r' '\n'? | '\n' | EOF) -> skip + ; Newline - : ('\r' '\n'? | '\n')+ - -> skip - ; + : ('\r' '\n'? | '\n')+ -> skip + ; Space - : [ \t]+ - -> skip - ; + : [ \t]+ -> skip + ; \ No newline at end of file diff --git a/cobol85/Cobol85.g4 b/cobol85/Cobol85.g4 index b5c0ac2c6c..2924a7127a 100644 --- a/cobol85/Cobol85.g4 +++ b/cobol85/Cobol85.g4 @@ -17,3230 +17,5639 @@ * with the provided preprocessor, which executes COPY and REPLACE statements. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Cobol85; -startRule : compilationUnit EOF; +startRule + : compilationUnit EOF + ; compilationUnit - : programUnit+ - ; + : programUnit+ + ; programUnit - : identificationDivision environmentDivision? dataDivision? procedureDivision? programUnit* endProgramStatement? - ; + : identificationDivision environmentDivision? dataDivision? procedureDivision? programUnit* endProgramStatement? + ; endProgramStatement - : END PROGRAM programName DOT_FS - ; + : END PROGRAM programName DOT_FS + ; // --- identification division -------------------------------------------------------------------- identificationDivision - : (IDENTIFICATION | ID) DIVISION DOT_FS programIdParagraph identificationDivisionBody* - ; + : (IDENTIFICATION | ID) DIVISION DOT_FS programIdParagraph identificationDivisionBody* + ; identificationDivisionBody - : authorParagraph | installationParagraph | dateWrittenParagraph | dateCompiledParagraph | securityParagraph | remarksParagraph - ; + : authorParagraph + | installationParagraph + | dateWrittenParagraph + | dateCompiledParagraph + | securityParagraph + | remarksParagraph + ; // - program id paragraph ---------------------------------- programIdParagraph - : PROGRAM_ID DOT_FS programName (IS? (COMMON | INITIAL | LIBRARY | DEFINITION | RECURSIVE) PROGRAM?)? DOT_FS? commentEntry? - ; + : PROGRAM_ID DOT_FS programName ( + IS? (COMMON | INITIAL | LIBRARY | DEFINITION | RECURSIVE) PROGRAM? + )? DOT_FS? commentEntry? + ; // - author paragraph ---------------------------------- authorParagraph - : AUTHOR DOT_FS commentEntry? - ; + : AUTHOR DOT_FS commentEntry? + ; // - installation paragraph ---------------------------------- installationParagraph - : INSTALLATION DOT_FS commentEntry? - ; + : INSTALLATION DOT_FS commentEntry? + ; // - date written paragraph ---------------------------------- dateWrittenParagraph - : DATE_WRITTEN DOT_FS commentEntry? - ; + : DATE_WRITTEN DOT_FS commentEntry? + ; // - date compiled paragraph ---------------------------------- dateCompiledParagraph - : DATE_COMPILED DOT_FS commentEntry? - ; + : DATE_COMPILED DOT_FS commentEntry? + ; // - security paragraph ---------------------------------- securityParagraph - : SECURITY DOT_FS commentEntry? - ; + : SECURITY DOT_FS commentEntry? + ; // - remarks paragraph ---------------------------------- remarksParagraph - : REMARKS DOT_FS commentEntry? - ; + : REMARKS DOT_FS commentEntry? + ; // --- environment division -------------------------------------------------------------------- environmentDivision - : ENVIRONMENT DIVISION DOT_FS environmentDivisionBody* - ; + : ENVIRONMENT DIVISION DOT_FS environmentDivisionBody* + ; environmentDivisionBody - : configurationSection | specialNamesParagraph | inputOutputSection - ; + : configurationSection + | specialNamesParagraph + | inputOutputSection + ; // -- configuration section ---------------------------------- configurationSection - : CONFIGURATION SECTION DOT_FS configurationSectionParagraph* - ; + : CONFIGURATION SECTION DOT_FS configurationSectionParagraph* + ; // - configuration section paragraph ---------------------------------- configurationSectionParagraph - : sourceComputerParagraph | objectComputerParagraph | specialNamesParagraph - // strictly, specialNamesParagraph does not belong into configurationSectionParagraph, but ibm-cobol allows this - ; + : sourceComputerParagraph + | objectComputerParagraph + | specialNamesParagraph + // strictly, specialNamesParagraph does not belong into configurationSectionParagraph, but ibm-cobol allows this + ; // - source computer paragraph ---------------------------------- sourceComputerParagraph - : SOURCE_COMPUTER DOT_FS computerName (WITH? DEBUGGING MODE)? DOT_FS - ; + : SOURCE_COMPUTER DOT_FS computerName (WITH? DEBUGGING MODE)? DOT_FS + ; // - object computer paragraph ---------------------------------- objectComputerParagraph - : OBJECT_COMPUTER DOT_FS computerName objectComputerClause* DOT_FS - ; + : OBJECT_COMPUTER DOT_FS computerName objectComputerClause* DOT_FS + ; objectComputerClause - : memorySizeClause | diskSizeClause | collatingSequenceClause | segmentLimitClause | characterSetClause - ; + : memorySizeClause + | diskSizeClause + | collatingSequenceClause + | segmentLimitClause + | characterSetClause + ; memorySizeClause - : MEMORY SIZE? (integerLiteral | cobolWord) (WORDS | CHARACTERS | MODULES)? - ; + : MEMORY SIZE? (integerLiteral | cobolWord) (WORDS | CHARACTERS | MODULES)? + ; diskSizeClause - : DISK SIZE? IS? (integerLiteral | cobolWord) (WORDS | MODULES)? - ; + : DISK SIZE? IS? (integerLiteral | cobolWord) (WORDS | MODULES)? + ; collatingSequenceClause - : PROGRAM? COLLATING? SEQUENCE (IS? alphabetName+) collatingSequenceClauseAlphanumeric? collatingSequenceClauseNational? - ; + : PROGRAM? COLLATING? SEQUENCE (IS? alphabetName+) collatingSequenceClauseAlphanumeric? collatingSequenceClauseNational? + ; collatingSequenceClauseAlphanumeric - : FOR? ALPHANUMERIC IS? alphabetName - ; + : FOR? ALPHANUMERIC IS? alphabetName + ; collatingSequenceClauseNational - : FOR? NATIONAL IS? alphabetName - ; + : FOR? NATIONAL IS? alphabetName + ; segmentLimitClause - : SEGMENT_LIMIT IS? integerLiteral - ; + : SEGMENT_LIMIT IS? integerLiteral + ; characterSetClause - : CHARACTER SET DOT_FS - ; + : CHARACTER SET DOT_FS + ; // - special names paragraph ---------------------------------- specialNamesParagraph - : SPECIAL_NAMES DOT_FS (specialNameClause+ DOT_FS)? - ; + : SPECIAL_NAMES DOT_FS (specialNameClause+ DOT_FS)? + ; specialNameClause - : channelClause | odtClause | alphabetClause | classClause | currencySignClause | decimalPointClause | symbolicCharactersClause | environmentSwitchNameClause | defaultDisplaySignClause | defaultComputationalSignClause | reserveNetworkClause - ; + : channelClause + | odtClause + | alphabetClause + | classClause + | currencySignClause + | decimalPointClause + | symbolicCharactersClause + | environmentSwitchNameClause + | defaultDisplaySignClause + | defaultComputationalSignClause + | reserveNetworkClause + ; alphabetClause - : alphabetClauseFormat1 | alphabetClauseFormat2 - ; + : alphabetClauseFormat1 + | alphabetClauseFormat2 + ; alphabetClauseFormat1 - : ALPHABET alphabetName (FOR ALPHANUMERIC)? IS? (EBCDIC | ASCII | STANDARD_1 | STANDARD_2 | NATIVE | cobolWord | alphabetLiterals+) - ; + : ALPHABET alphabetName (FOR ALPHANUMERIC)? IS? ( + EBCDIC + | ASCII + | STANDARD_1 + | STANDARD_2 + | NATIVE + | cobolWord + | alphabetLiterals+ + ) + ; alphabetLiterals - : literal (alphabetThrough | alphabetAlso+)? - ; + : literal (alphabetThrough | alphabetAlso+)? + ; alphabetThrough - : (THROUGH | THRU) literal - ; + : (THROUGH | THRU) literal + ; alphabetAlso - : ALSO literal+ - ; + : ALSO literal+ + ; alphabetClauseFormat2 - : ALPHABET alphabetName FOR? NATIONAL IS? (NATIVE | CCSVERSION literal) - ; + : ALPHABET alphabetName FOR? NATIONAL IS? (NATIVE | CCSVERSION literal) + ; channelClause - : CHANNEL integerLiteral IS? mnemonicName - ; + : CHANNEL integerLiteral IS? mnemonicName + ; classClause - : CLASS className (FOR? (ALPHANUMERIC | NATIONAL))? IS? classClauseThrough+ - ; + : CLASS className (FOR? (ALPHANUMERIC | NATIONAL))? IS? classClauseThrough+ + ; classClauseThrough - : classClauseFrom ((THROUGH | THRU) classClauseTo)? - ; + : classClauseFrom ((THROUGH | THRU) classClauseTo)? + ; classClauseFrom - : identifier | literal - ; + : identifier + | literal + ; classClauseTo - : identifier | literal - ; + : identifier + | literal + ; currencySignClause - : CURRENCY SIGN? IS? literal (WITH? PICTURE SYMBOL literal)? - ; + : CURRENCY SIGN? IS? literal (WITH? PICTURE SYMBOL literal)? + ; decimalPointClause - : DECIMAL_POINT IS? COMMA - ; + : DECIMAL_POINT IS? COMMA + ; defaultComputationalSignClause - : DEFAULT (COMPUTATIONAL | COMP)? (SIGN IS?)? (LEADING | TRAILING)? (SEPARATE CHARACTER?) - ; + : DEFAULT (COMPUTATIONAL | COMP)? (SIGN IS?)? (LEADING | TRAILING)? (SEPARATE CHARACTER?) + ; defaultDisplaySignClause - : DEFAULT_DISPLAY (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? - ; + : DEFAULT_DISPLAY (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? + ; environmentSwitchNameClause - : environmentName IS? mnemonicName environmentSwitchNameSpecialNamesStatusPhrase? | environmentSwitchNameSpecialNamesStatusPhrase - ; + : environmentName IS? mnemonicName environmentSwitchNameSpecialNamesStatusPhrase? + | environmentSwitchNameSpecialNamesStatusPhrase + ; environmentSwitchNameSpecialNamesStatusPhrase - : ON STATUS? IS? condition (OFF STATUS? IS? condition)? | OFF STATUS? IS? condition (ON STATUS? IS? condition)? - ; + : ON STATUS? IS? condition (OFF STATUS? IS? condition)? + | OFF STATUS? IS? condition (ON STATUS? IS? condition)? + ; odtClause - : ODT IS? mnemonicName - ; + : ODT IS? mnemonicName + ; reserveNetworkClause - : RESERVE WORDS? LIST? IS? NETWORK CAPABLE? - ; + : RESERVE WORDS? LIST? IS? NETWORK CAPABLE? + ; symbolicCharactersClause - : SYMBOLIC CHARACTERS? (FOR? (ALPHANUMERIC | NATIONAL))? symbolicCharacters+ (IN alphabetName)? - ; + : SYMBOLIC CHARACTERS? (FOR? (ALPHANUMERIC | NATIONAL))? symbolicCharacters+ (IN alphabetName)? + ; symbolicCharacters - : symbolicCharacter+ (IS | ARE)? integerLiteral+ - ; + : symbolicCharacter+ (IS | ARE)? integerLiteral+ + ; // -- input output section ---------------------------------- inputOutputSection - : INPUT_OUTPUT SECTION DOT_FS inputOutputSectionParagraph* - ; + : INPUT_OUTPUT SECTION DOT_FS inputOutputSectionParagraph* + ; // - input output section paragraph ---------------------------------- inputOutputSectionParagraph - : fileControlParagraph | ioControlParagraph - ; + : fileControlParagraph + | ioControlParagraph + ; // - file control paragraph ---------------------------------- fileControlParagraph - : FILE_CONTROL (DOT_FS? fileControlEntry)* DOT_FS - ; + : FILE_CONTROL (DOT_FS? fileControlEntry)* DOT_FS + ; fileControlEntry - : selectClause fileControlClause* - ; + : selectClause fileControlClause* + ; selectClause - : SELECT OPTIONAL? fileName - ; + : SELECT OPTIONAL? fileName + ; fileControlClause - : assignClause | reserveClause | organizationClause | paddingCharacterClause | recordDelimiterClause | accessModeClause | recordKeyClause | alternateRecordKeyClause | fileStatusClause | passwordClause | relativeKeyClause - ; + : assignClause + | reserveClause + | organizationClause + | paddingCharacterClause + | recordDelimiterClause + | accessModeClause + | recordKeyClause + | alternateRecordKeyClause + | fileStatusClause + | passwordClause + | relativeKeyClause + ; assignClause - : ASSIGN TO? (DISK | DISPLAY | KEYBOARD | PORT | PRINTER | READER | REMOTE | TAPE | VIRTUAL | assignmentName | literal) - ; + : ASSIGN TO? ( + DISK + | DISPLAY + | KEYBOARD + | PORT + | PRINTER + | READER + | REMOTE + | TAPE + | VIRTUAL + | assignmentName + | literal + ) + ; reserveClause - : RESERVE (NO | integerLiteral) ALTERNATE? (AREA | AREAS)? - ; + : RESERVE (NO | integerLiteral) ALTERNATE? (AREA | AREAS)? + ; organizationClause - : (ORGANIZATION IS?)? (LINE | RECORD BINARY | RECORD | BINARY)? (SEQUENTIAL | RELATIVE | INDEXED) - ; + : (ORGANIZATION IS?)? (LINE | RECORD BINARY | RECORD | BINARY)? ( + SEQUENTIAL + | RELATIVE + | INDEXED + ) + ; paddingCharacterClause - : PADDING CHARACTER? IS? (qualifiedDataName | literal) - ; + : PADDING CHARACTER? IS? (qualifiedDataName | literal) + ; recordDelimiterClause - : RECORD DELIMITER IS? (STANDARD_1 | IMPLICIT | assignmentName) - ; + : RECORD DELIMITER IS? (STANDARD_1 | IMPLICIT | assignmentName) + ; accessModeClause - : ACCESS MODE? IS? (SEQUENTIAL | RANDOM | DYNAMIC | EXCLUSIVE) - ; + : ACCESS MODE? IS? (SEQUENTIAL | RANDOM | DYNAMIC | EXCLUSIVE) + ; recordKeyClause - : RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)? - ; + : RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)? + ; alternateRecordKeyClause - : ALTERNATE RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)? - ; + : ALTERNATE RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)? + ; passwordClause - : PASSWORD IS? dataName - ; + : PASSWORD IS? dataName + ; fileStatusClause - : FILE? STATUS IS? qualifiedDataName qualifiedDataName? - ; + : FILE? STATUS IS? qualifiedDataName qualifiedDataName? + ; relativeKeyClause - : RELATIVE KEY? IS? qualifiedDataName - ; + : RELATIVE KEY? IS? qualifiedDataName + ; // - io control paragraph ---------------------------------- ioControlParagraph - : I_O_CONTROL DOT_FS (fileName DOT_FS)? (ioControlClause* DOT_FS)? - ; + : I_O_CONTROL DOT_FS (fileName DOT_FS)? (ioControlClause* DOT_FS)? + ; ioControlClause - : rerunClause | sameClause | multipleFileClause | commitmentControlClause - ; + : rerunClause + | sameClause + | multipleFileClause + | commitmentControlClause + ; rerunClause - : RERUN (ON (assignmentName | fileName))? EVERY (rerunEveryRecords | rerunEveryOf | rerunEveryClock) - ; + : RERUN (ON (assignmentName | fileName))? EVERY ( + rerunEveryRecords + | rerunEveryOf + | rerunEveryClock + ) + ; rerunEveryRecords - : integerLiteral RECORDS - ; + : integerLiteral RECORDS + ; rerunEveryOf - : END? OF? (REEL | UNIT) OF fileName - ; + : END? OF? (REEL | UNIT) OF fileName + ; rerunEveryClock - : integerLiteral CLOCK_UNITS? - ; + : integerLiteral CLOCK_UNITS? + ; sameClause - : SAME (RECORD | SORT | SORT_MERGE)? AREA? FOR? fileName+ - ; + : SAME (RECORD | SORT | SORT_MERGE)? AREA? FOR? fileName+ + ; multipleFileClause - : MULTIPLE FILE TAPE? CONTAINS? multipleFilePosition+ - ; + : MULTIPLE FILE TAPE? CONTAINS? multipleFilePosition+ + ; multipleFilePosition - : fileName (POSITION integerLiteral)? - ; + : fileName (POSITION integerLiteral)? + ; commitmentControlClause - : COMMITMENT CONTROL FOR? fileName - ; + : COMMITMENT CONTROL FOR? fileName + ; // --- data division -------------------------------------------------------------------- dataDivision - : DATA DIVISION DOT_FS dataDivisionSection* - ; + : DATA DIVISION DOT_FS dataDivisionSection* + ; dataDivisionSection - : fileSection | dataBaseSection | workingStorageSection | linkageSection | communicationSection | localStorageSection | screenSection | reportSection | programLibrarySection - ; + : fileSection + | dataBaseSection + | workingStorageSection + | linkageSection + | communicationSection + | localStorageSection + | screenSection + | reportSection + | programLibrarySection + ; // -- file section ---------------------------------- fileSection - : FILE SECTION DOT_FS fileDescriptionEntry* - ; + : FILE SECTION DOT_FS fileDescriptionEntry* + ; fileDescriptionEntry - : (FD | SD) fileName (DOT_FS? fileDescriptionEntryClause)* DOT_FS dataDescriptionEntry* - ; + : (FD | SD) fileName (DOT_FS? fileDescriptionEntryClause)* DOT_FS dataDescriptionEntry* + ; fileDescriptionEntryClause - : externalClause | globalClause | blockContainsClause | recordContainsClause | labelRecordsClause | valueOfClause | dataRecordsClause | linageClause | codeSetClause | reportClause | recordingModeClause - ; + : externalClause + | globalClause + | blockContainsClause + | recordContainsClause + | labelRecordsClause + | valueOfClause + | dataRecordsClause + | linageClause + | codeSetClause + | reportClause + | recordingModeClause + ; externalClause - : IS? EXTERNAL - ; + : IS? EXTERNAL + ; globalClause - : IS? GLOBAL - ; + : IS? GLOBAL + ; blockContainsClause - : BLOCK CONTAINS? integerLiteral blockContainsTo? (RECORDS | CHARACTERS)? - ; + : BLOCK CONTAINS? integerLiteral blockContainsTo? (RECORDS | CHARACTERS)? + ; blockContainsTo - : TO integerLiteral - ; + : TO integerLiteral + ; recordContainsClause - : RECORD (recordContainsClauseFormat1 | recordContainsClauseFormat2 | recordContainsClauseFormat3) - ; + : RECORD ( + recordContainsClauseFormat1 + | recordContainsClauseFormat2 + | recordContainsClauseFormat3 + ) + ; recordContainsClauseFormat1 - : CONTAINS? integerLiteral CHARACTERS? - ; + : CONTAINS? integerLiteral CHARACTERS? + ; recordContainsClauseFormat2 - : IS? VARYING IN? SIZE? (FROM? integerLiteral recordContainsTo? CHARACTERS?)? (DEPENDING ON? qualifiedDataName)? - ; + : IS? VARYING IN? SIZE? (FROM? integerLiteral recordContainsTo? CHARACTERS?)? ( + DEPENDING ON? qualifiedDataName + )? + ; recordContainsClauseFormat3 - : CONTAINS? integerLiteral recordContainsTo CHARACTERS? - ; + : CONTAINS? integerLiteral recordContainsTo CHARACTERS? + ; recordContainsTo - : TO integerLiteral - ; + : TO integerLiteral + ; labelRecordsClause - : LABEL (RECORD IS? | RECORDS ARE?) (OMITTED | STANDARD | dataName+) - ; + : LABEL (RECORD IS? | RECORDS ARE?) (OMITTED | STANDARD | dataName+) + ; valueOfClause - : VALUE OF valuePair+ - ; + : VALUE OF valuePair+ + ; valuePair - : systemName IS? (qualifiedDataName | literal) - ; + : systemName IS? (qualifiedDataName | literal) + ; dataRecordsClause - : DATA (RECORD IS? | RECORDS ARE?) dataName+ - ; + : DATA (RECORD IS? | RECORDS ARE?) dataName+ + ; linageClause - : LINAGE IS? (dataName | integerLiteral) LINES? linageAt* - ; + : LINAGE IS? (dataName | integerLiteral) LINES? linageAt* + ; linageAt - : linageFootingAt | linageLinesAtTop | linageLinesAtBottom - ; + : linageFootingAt + | linageLinesAtTop + | linageLinesAtBottom + ; linageFootingAt - : WITH? FOOTING AT? (dataName | integerLiteral) - ; + : WITH? FOOTING AT? (dataName | integerLiteral) + ; linageLinesAtTop - : LINES? AT? TOP (dataName | integerLiteral) - ; + : LINES? AT? TOP (dataName | integerLiteral) + ; linageLinesAtBottom - : LINES? AT? BOTTOM (dataName | integerLiteral) - ; + : LINES? AT? BOTTOM (dataName | integerLiteral) + ; recordingModeClause - : RECORDING MODE? IS? modeStatement - ; + : RECORDING MODE? IS? modeStatement + ; modeStatement - : cobolWord - ; + : cobolWord + ; codeSetClause - : CODE_SET IS? alphabetName - ; + : CODE_SET IS? alphabetName + ; reportClause - : (REPORT IS? | REPORTS ARE?) reportName+ - ; + : (REPORT IS? | REPORTS ARE?) reportName+ + ; // -- data base section ---------------------------------- dataBaseSection - : DATA_BASE SECTION DOT_FS dataBaseSectionEntry* - ; + : DATA_BASE SECTION DOT_FS dataBaseSectionEntry* + ; dataBaseSectionEntry - : integerLiteral literal INVOKE literal - ; + : integerLiteral literal INVOKE literal + ; // -- working storage section ---------------------------------- workingStorageSection - : WORKING_STORAGE SECTION DOT_FS dataDescriptionEntry* - ; + : WORKING_STORAGE SECTION DOT_FS dataDescriptionEntry* + ; // -- linkage section ---------------------------------- linkageSection - : LINKAGE SECTION DOT_FS dataDescriptionEntry* - ; + : LINKAGE SECTION DOT_FS dataDescriptionEntry* + ; // -- communication section ---------------------------------- communicationSection - : COMMUNICATION SECTION DOT_FS (communicationDescriptionEntry | dataDescriptionEntry)* - ; + : COMMUNICATION SECTION DOT_FS (communicationDescriptionEntry | dataDescriptionEntry)* + ; communicationDescriptionEntry - : communicationDescriptionEntryFormat1 | communicationDescriptionEntryFormat2 | communicationDescriptionEntryFormat3 - ; + : communicationDescriptionEntryFormat1 + | communicationDescriptionEntryFormat2 + | communicationDescriptionEntryFormat3 + ; communicationDescriptionEntryFormat1 - : CD cdName FOR? INITIAL? INPUT ((symbolicQueueClause | symbolicSubQueueClause | messageDateClause | messageTimeClause | symbolicSourceClause | textLengthClause | endKeyClause | statusKeyClause | messageCountClause) | dataDescName)* DOT_FS - ; + : CD cdName FOR? INITIAL? INPUT ( + ( + symbolicQueueClause + | symbolicSubQueueClause + | messageDateClause + | messageTimeClause + | symbolicSourceClause + | textLengthClause + | endKeyClause + | statusKeyClause + | messageCountClause + ) + | dataDescName + )* DOT_FS + ; communicationDescriptionEntryFormat2 - : CD cdName FOR? OUTPUT (destinationCountClause | textLengthClause | statusKeyClause | destinationTableClause | errorKeyClause | symbolicDestinationClause)* DOT_FS - ; + : CD cdName FOR? OUTPUT ( + destinationCountClause + | textLengthClause + | statusKeyClause + | destinationTableClause + | errorKeyClause + | symbolicDestinationClause + )* DOT_FS + ; communicationDescriptionEntryFormat3 - : CD cdName FOR? INITIAL I_O ((messageDateClause | messageTimeClause | symbolicTerminalClause | textLengthClause | endKeyClause | statusKeyClause) | dataDescName)* DOT_FS - ; + : CD cdName FOR? INITIAL I_O ( + ( + messageDateClause + | messageTimeClause + | symbolicTerminalClause + | textLengthClause + | endKeyClause + | statusKeyClause + ) + | dataDescName + )* DOT_FS + ; destinationCountClause - : DESTINATION COUNT IS? dataDescName - ; + : DESTINATION COUNT IS? dataDescName + ; destinationTableClause - : DESTINATION TABLE OCCURS integerLiteral TIMES (INDEXED BY indexName+)? - ; + : DESTINATION TABLE OCCURS integerLiteral TIMES (INDEXED BY indexName+)? + ; endKeyClause - : END KEY IS? dataDescName - ; + : END KEY IS? dataDescName + ; errorKeyClause - : ERROR KEY IS? dataDescName - ; + : ERROR KEY IS? dataDescName + ; messageCountClause - : MESSAGE? COUNT IS? dataDescName - ; + : MESSAGE? COUNT IS? dataDescName + ; messageDateClause - : MESSAGE DATE IS? dataDescName - ; + : MESSAGE DATE IS? dataDescName + ; messageTimeClause - : MESSAGE TIME IS? dataDescName - ; + : MESSAGE TIME IS? dataDescName + ; statusKeyClause - : STATUS KEY IS? dataDescName - ; + : STATUS KEY IS? dataDescName + ; symbolicDestinationClause - : SYMBOLIC? DESTINATION IS? dataDescName - ; + : SYMBOLIC? DESTINATION IS? dataDescName + ; symbolicQueueClause - : SYMBOLIC? QUEUE IS? dataDescName - ; + : SYMBOLIC? QUEUE IS? dataDescName + ; symbolicSourceClause - : SYMBOLIC? SOURCE IS? dataDescName - ; + : SYMBOLIC? SOURCE IS? dataDescName + ; symbolicTerminalClause - : SYMBOLIC? TERMINAL IS? dataDescName - ; + : SYMBOLIC? TERMINAL IS? dataDescName + ; symbolicSubQueueClause - : SYMBOLIC? (SUB_QUEUE_1 | SUB_QUEUE_2 | SUB_QUEUE_3) IS? dataDescName - ; + : SYMBOLIC? (SUB_QUEUE_1 | SUB_QUEUE_2 | SUB_QUEUE_3) IS? dataDescName + ; textLengthClause - : TEXT LENGTH IS? dataDescName - ; + : TEXT LENGTH IS? dataDescName + ; // -- local storage section ---------------------------------- localStorageSection - : LOCAL_STORAGE SECTION DOT_FS (LD localName DOT_FS)? dataDescriptionEntry* - ; + : LOCAL_STORAGE SECTION DOT_FS (LD localName DOT_FS)? dataDescriptionEntry* + ; // -- screen section ---------------------------------- screenSection - : SCREEN SECTION DOT_FS screenDescriptionEntry* - ; + : SCREEN SECTION DOT_FS screenDescriptionEntry* + ; screenDescriptionEntry - : INTEGERLITERAL (FILLER | screenName)? (screenDescriptionBlankClause | screenDescriptionBellClause | screenDescriptionBlinkClause | screenDescriptionEraseClause | screenDescriptionLightClause | screenDescriptionGridClause | screenDescriptionReverseVideoClause | screenDescriptionUnderlineClause | screenDescriptionSizeClause | screenDescriptionLineClause | screenDescriptionColumnClause | screenDescriptionForegroundColorClause | screenDescriptionBackgroundColorClause | screenDescriptionControlClause | screenDescriptionValueClause | screenDescriptionPictureClause | (screenDescriptionFromClause | screenDescriptionUsingClause) | screenDescriptionUsageClause | screenDescriptionBlankWhenZeroClause | screenDescriptionJustifiedClause | screenDescriptionSignClause | screenDescriptionAutoClause | screenDescriptionSecureClause | screenDescriptionRequiredClause | screenDescriptionPromptClause | screenDescriptionFullClause | screenDescriptionZeroFillClause)* DOT_FS - ; + : INTEGERLITERAL (FILLER | screenName)? ( + screenDescriptionBlankClause + | screenDescriptionBellClause + | screenDescriptionBlinkClause + | screenDescriptionEraseClause + | screenDescriptionLightClause + | screenDescriptionGridClause + | screenDescriptionReverseVideoClause + | screenDescriptionUnderlineClause + | screenDescriptionSizeClause + | screenDescriptionLineClause + | screenDescriptionColumnClause + | screenDescriptionForegroundColorClause + | screenDescriptionBackgroundColorClause + | screenDescriptionControlClause + | screenDescriptionValueClause + | screenDescriptionPictureClause + | (screenDescriptionFromClause | screenDescriptionUsingClause) + | screenDescriptionUsageClause + | screenDescriptionBlankWhenZeroClause + | screenDescriptionJustifiedClause + | screenDescriptionSignClause + | screenDescriptionAutoClause + | screenDescriptionSecureClause + | screenDescriptionRequiredClause + | screenDescriptionPromptClause + | screenDescriptionFullClause + | screenDescriptionZeroFillClause + )* DOT_FS + ; screenDescriptionBlankClause - : BLANK (SCREEN | LINE) - ; + : BLANK (SCREEN | LINE) + ; screenDescriptionBellClause - : BELL | BEEP - ; + : BELL + | BEEP + ; screenDescriptionBlinkClause - : BLINK - ; + : BLINK + ; screenDescriptionEraseClause - : ERASE (EOL | EOS) - ; + : ERASE (EOL | EOS) + ; screenDescriptionLightClause - : HIGHLIGHT | LOWLIGHT - ; + : HIGHLIGHT + | LOWLIGHT + ; screenDescriptionGridClause - : GRID | LEFTLINE | OVERLINE - ; + : GRID + | LEFTLINE + | OVERLINE + ; screenDescriptionReverseVideoClause - : REVERSE_VIDEO - ; + : REVERSE_VIDEO + ; screenDescriptionUnderlineClause - : UNDERLINE - ; + : UNDERLINE + ; screenDescriptionSizeClause - : SIZE IS? (identifier | integerLiteral) - ; + : SIZE IS? (identifier | integerLiteral) + ; screenDescriptionLineClause - : LINE (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral) - ; + : LINE (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral) + ; screenDescriptionColumnClause - : (COLUMN | COL) (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral) - ; + : (COLUMN | COL) (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral) + ; screenDescriptionForegroundColorClause - : (FOREGROUND_COLOR | FOREGROUND_COLOUR) IS? (identifier | integerLiteral) - ; + : (FOREGROUND_COLOR | FOREGROUND_COLOUR) IS? (identifier | integerLiteral) + ; screenDescriptionBackgroundColorClause - : (BACKGROUND_COLOR | BACKGROUND_COLOUR) IS? (identifier | integerLiteral) - ; + : (BACKGROUND_COLOR | BACKGROUND_COLOUR) IS? (identifier | integerLiteral) + ; screenDescriptionControlClause - : CONTROL IS? identifier - ; + : CONTROL IS? identifier + ; screenDescriptionValueClause - : (VALUE IS?) literal - ; + : (VALUE IS?) literal + ; screenDescriptionPictureClause - : (PICTURE | PIC) IS? pictureString - ; + : (PICTURE | PIC) IS? pictureString + ; screenDescriptionFromClause - : FROM (identifier | literal) screenDescriptionToClause? - ; + : FROM (identifier | literal) screenDescriptionToClause? + ; screenDescriptionToClause - : TO identifier - ; + : TO identifier + ; screenDescriptionUsingClause - : USING identifier - ; + : USING identifier + ; screenDescriptionUsageClause - : (USAGE IS?) (DISPLAY | DISPLAY_1) - ; + : (USAGE IS?) (DISPLAY | DISPLAY_1) + ; screenDescriptionBlankWhenZeroClause - : BLANK WHEN? ZERO - ; + : BLANK WHEN? ZERO + ; screenDescriptionJustifiedClause - : (JUSTIFIED | JUST) RIGHT? - ; + : (JUSTIFIED | JUST) RIGHT? + ; screenDescriptionSignClause - : (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? - ; + : (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? + ; screenDescriptionAutoClause - : AUTO | AUTO_SKIP - ; + : AUTO + | AUTO_SKIP + ; screenDescriptionSecureClause - : SECURE | NO_ECHO - ; + : SECURE + | NO_ECHO + ; screenDescriptionRequiredClause - : REQUIRED | EMPTY_CHECK - ; + : REQUIRED + | EMPTY_CHECK + ; screenDescriptionPromptClause - : PROMPT CHARACTER? IS? (identifier | literal) screenDescriptionPromptOccursClause? - ; + : PROMPT CHARACTER? IS? (identifier | literal) screenDescriptionPromptOccursClause? + ; screenDescriptionPromptOccursClause - : OCCURS integerLiteral TIMES? - ; + : OCCURS integerLiteral TIMES? + ; screenDescriptionFullClause - : FULL | LENGTH_CHECK - ; + : FULL + | LENGTH_CHECK + ; screenDescriptionZeroFillClause - : ZERO_FILL - ; + : ZERO_FILL + ; // -- report section ---------------------------------- reportSection - : REPORT SECTION DOT_FS reportDescription* - ; + : REPORT SECTION DOT_FS reportDescription* + ; reportDescription - : reportDescriptionEntry reportGroupDescriptionEntry+ - ; + : reportDescriptionEntry reportGroupDescriptionEntry+ + ; reportDescriptionEntry - : RD reportName reportDescriptionGlobalClause? (reportDescriptionPageLimitClause reportDescriptionHeadingClause? reportDescriptionFirstDetailClause? reportDescriptionLastDetailClause? reportDescriptionFootingClause?)? DOT_FS - ; + : RD reportName reportDescriptionGlobalClause? ( + reportDescriptionPageLimitClause reportDescriptionHeadingClause? reportDescriptionFirstDetailClause? reportDescriptionLastDetailClause? + reportDescriptionFootingClause? + )? DOT_FS + ; reportDescriptionGlobalClause - : IS? GLOBAL - ; + : IS? GLOBAL + ; reportDescriptionPageLimitClause - : PAGE (LIMIT IS? | LIMITS ARE?)? integerLiteral (LINE | LINES)? - ; + : PAGE (LIMIT IS? | LIMITS ARE?)? integerLiteral (LINE | LINES)? + ; reportDescriptionHeadingClause - : HEADING integerLiteral - ; + : HEADING integerLiteral + ; reportDescriptionFirstDetailClause - : FIRST DETAIL integerLiteral - ; + : FIRST DETAIL integerLiteral + ; reportDescriptionLastDetailClause - : LAST DETAIL integerLiteral - ; + : LAST DETAIL integerLiteral + ; reportDescriptionFootingClause - : FOOTING integerLiteral - ; + : FOOTING integerLiteral + ; reportGroupDescriptionEntry - : reportGroupDescriptionEntryFormat1 | reportGroupDescriptionEntryFormat2 | reportGroupDescriptionEntryFormat3 - ; + : reportGroupDescriptionEntryFormat1 + | reportGroupDescriptionEntryFormat2 + | reportGroupDescriptionEntryFormat3 + ; reportGroupDescriptionEntryFormat1 - : integerLiteral dataName reportGroupLineNumberClause? reportGroupNextGroupClause? reportGroupTypeClause reportGroupUsageClause? DOT_FS - ; + : integerLiteral dataName reportGroupLineNumberClause? reportGroupNextGroupClause? reportGroupTypeClause reportGroupUsageClause? DOT_FS + ; reportGroupDescriptionEntryFormat2 - : integerLiteral dataName? reportGroupLineNumberClause? reportGroupUsageClause DOT_FS - ; + : integerLiteral dataName? reportGroupLineNumberClause? reportGroupUsageClause DOT_FS + ; reportGroupDescriptionEntryFormat3 - : integerLiteral dataName? (reportGroupPictureClause | reportGroupUsageClause | reportGroupSignClause | reportGroupJustifiedClause | reportGroupBlankWhenZeroClause | reportGroupLineNumberClause | reportGroupColumnNumberClause | (reportGroupSourceClause | reportGroupValueClause | reportGroupSumClause | reportGroupResetClause) | reportGroupIndicateClause)* DOT_FS - ; + : integerLiteral dataName? ( + reportGroupPictureClause + | reportGroupUsageClause + | reportGroupSignClause + | reportGroupJustifiedClause + | reportGroupBlankWhenZeroClause + | reportGroupLineNumberClause + | reportGroupColumnNumberClause + | ( + reportGroupSourceClause + | reportGroupValueClause + | reportGroupSumClause + | reportGroupResetClause + ) + | reportGroupIndicateClause + )* DOT_FS + ; reportGroupBlankWhenZeroClause - : BLANK WHEN? ZERO - ; + : BLANK WHEN? ZERO + ; reportGroupColumnNumberClause - : COLUMN NUMBER? IS? integerLiteral - ; + : COLUMN NUMBER? IS? integerLiteral + ; reportGroupIndicateClause - : GROUP INDICATE? - ; + : GROUP INDICATE? + ; reportGroupJustifiedClause - : (JUSTIFIED | JUST) RIGHT? - ; + : (JUSTIFIED | JUST) RIGHT? + ; reportGroupLineNumberClause - : LINE? NUMBER? IS? (reportGroupLineNumberNextPage | reportGroupLineNumberPlus) - ; + : LINE? NUMBER? IS? (reportGroupLineNumberNextPage | reportGroupLineNumberPlus) + ; reportGroupLineNumberNextPage - : integerLiteral (ON? NEXT PAGE)? - ; + : integerLiteral (ON? NEXT PAGE)? + ; reportGroupLineNumberPlus - : PLUS integerLiteral - ; + : PLUS integerLiteral + ; reportGroupNextGroupClause - : NEXT GROUP IS? (integerLiteral | reportGroupNextGroupNextPage | reportGroupNextGroupPlus) - ; + : NEXT GROUP IS? (integerLiteral | reportGroupNextGroupNextPage | reportGroupNextGroupPlus) + ; reportGroupNextGroupPlus - : PLUS integerLiteral - ; + : PLUS integerLiteral + ; reportGroupNextGroupNextPage - : NEXT PAGE - ; + : NEXT PAGE + ; reportGroupPictureClause - : (PICTURE | PIC) IS? pictureString - ; + : (PICTURE | PIC) IS? pictureString + ; reportGroupResetClause - : RESET ON? (FINAL | dataName) - ; + : RESET ON? (FINAL | dataName) + ; reportGroupSignClause - : SIGN IS? (LEADING | TRAILING) SEPARATE CHARACTER? - ; + : SIGN IS? (LEADING | TRAILING) SEPARATE CHARACTER? + ; reportGroupSourceClause - : SOURCE IS? identifier - ; + : SOURCE IS? identifier + ; reportGroupSumClause - : SUM identifier (COMMACHAR? identifier)* (UPON dataName (COMMACHAR? dataName)*)? - ; + : SUM identifier (COMMACHAR? identifier)* (UPON dataName (COMMACHAR? dataName)*)? + ; reportGroupTypeClause - : TYPE IS? (reportGroupTypeReportHeading | reportGroupTypePageHeading | reportGroupTypeControlHeading | reportGroupTypeDetail | reportGroupTypeControlFooting | reportGroupTypePageFooting | reportGroupTypeReportFooting) - ; + : TYPE IS? ( + reportGroupTypeReportHeading + | reportGroupTypePageHeading + | reportGroupTypeControlHeading + | reportGroupTypeDetail + | reportGroupTypeControlFooting + | reportGroupTypePageFooting + | reportGroupTypeReportFooting + ) + ; reportGroupTypeReportHeading - : REPORT HEADING | RH - ; + : REPORT HEADING + | RH + ; reportGroupTypePageHeading - : PAGE HEADING | PH - ; + : PAGE HEADING + | PH + ; reportGroupTypeControlHeading - : (CONTROL HEADING | CH) (FINAL | dataName) - ; + : (CONTROL HEADING | CH) (FINAL | dataName) + ; reportGroupTypeDetail - : DETAIL | DE - ; + : DETAIL + | DE + ; reportGroupTypeControlFooting - : (CONTROL FOOTING | CF) (FINAL | dataName) - ; + : (CONTROL FOOTING | CF) (FINAL | dataName) + ; reportGroupUsageClause - : (USAGE IS?)? (DISPLAY | DISPLAY_1) - ; + : (USAGE IS?)? (DISPLAY | DISPLAY_1) + ; reportGroupTypePageFooting - : PAGE FOOTING | PF - ; + : PAGE FOOTING + | PF + ; reportGroupTypeReportFooting - : REPORT FOOTING | RF - ; + : REPORT FOOTING + | RF + ; reportGroupValueClause - : VALUE IS? literal - ; + : VALUE IS? literal + ; // -- program library section ---------------------------------- programLibrarySection - : PROGRAM_LIBRARY SECTION DOT_FS libraryDescriptionEntry* - ; + : PROGRAM_LIBRARY SECTION DOT_FS libraryDescriptionEntry* + ; libraryDescriptionEntry - : libraryDescriptionEntryFormat1 | libraryDescriptionEntryFormat2 - ; + : libraryDescriptionEntryFormat1 + | libraryDescriptionEntryFormat2 + ; libraryDescriptionEntryFormat1 - : LD libraryName EXPORT libraryAttributeClauseFormat1? libraryEntryProcedureClauseFormat1? - ; + : LD libraryName EXPORT libraryAttributeClauseFormat1? libraryEntryProcedureClauseFormat1? + ; libraryDescriptionEntryFormat2 - : LB libraryName IMPORT libraryIsGlobalClause? libraryIsCommonClause? (libraryAttributeClauseFormat2 | libraryEntryProcedureClauseFormat2)* - ; + : LB libraryName IMPORT libraryIsGlobalClause? libraryIsCommonClause? ( + libraryAttributeClauseFormat2 + | libraryEntryProcedureClauseFormat2 + )* + ; libraryAttributeClauseFormat1 - : ATTRIBUTE (SHARING IS? (DONTCARE | PRIVATE | SHAREDBYRUNUNIT | SHAREDBYALL))? - ; + : ATTRIBUTE (SHARING IS? (DONTCARE | PRIVATE | SHAREDBYRUNUNIT | SHAREDBYALL))? + ; libraryAttributeClauseFormat2 - : ATTRIBUTE libraryAttributeFunction? (LIBACCESS IS? (BYFUNCTION | BYTITLE))? libraryAttributeParameter? libraryAttributeTitle? - ; + : ATTRIBUTE libraryAttributeFunction? (LIBACCESS IS? (BYFUNCTION | BYTITLE))? libraryAttributeParameter? libraryAttributeTitle? + ; libraryAttributeFunction - : FUNCTIONNAME IS literal - ; + : FUNCTIONNAME IS literal + ; libraryAttributeParameter - : LIBPARAMETER IS? literal - ; + : LIBPARAMETER IS? literal + ; libraryAttributeTitle - : TITLE IS? literal - ; + : TITLE IS? literal + ; libraryEntryProcedureClauseFormat1 - : ENTRY_PROCEDURE programName libraryEntryProcedureForClause? - ; + : ENTRY_PROCEDURE programName libraryEntryProcedureForClause? + ; libraryEntryProcedureClauseFormat2 - : ENTRY_PROCEDURE programName libraryEntryProcedureForClause? libraryEntryProcedureWithClause? libraryEntryProcedureUsingClause? libraryEntryProcedureGivingClause? - ; + : ENTRY_PROCEDURE programName libraryEntryProcedureForClause? libraryEntryProcedureWithClause? libraryEntryProcedureUsingClause? + libraryEntryProcedureGivingClause? + ; libraryEntryProcedureForClause - : FOR literal - ; + : FOR literal + ; libraryEntryProcedureGivingClause - : GIVING dataName - ; + : GIVING dataName + ; libraryEntryProcedureUsingClause - : USING libraryEntryProcedureUsingName+ - ; + : USING libraryEntryProcedureUsingName+ + ; libraryEntryProcedureUsingName - : dataName | fileName - ; + : dataName + | fileName + ; libraryEntryProcedureWithClause - : WITH libraryEntryProcedureWithName+ - ; + : WITH libraryEntryProcedureWithName+ + ; libraryEntryProcedureWithName - : localName | fileName - ; + : localName + | fileName + ; libraryIsCommonClause - : IS? COMMON - ; + : IS? COMMON + ; libraryIsGlobalClause - : IS? GLOBAL - ; + : IS? GLOBAL + ; // data description entry ---------------------------------- dataDescriptionEntry - : dataDescriptionEntryFormat1 | dataDescriptionEntryFormat2 | dataDescriptionEntryFormat3 | dataDescriptionEntryExecSql - ; + : dataDescriptionEntryFormat1 + | dataDescriptionEntryFormat2 + | dataDescriptionEntryFormat3 + | dataDescriptionEntryExecSql + ; dataDescriptionEntryFormat1 - : (INTEGERLITERAL | LEVEL_NUMBER_77) (FILLER | dataName)? (dataRedefinesClause | dataIntegerStringClause | dataExternalClause | dataGlobalClause | dataTypeDefClause | dataThreadLocalClause | dataPictureClause | dataCommonOwnLocalClause | dataTypeClause | dataUsingClause | dataUsageClause | dataValueClause | dataReceivedByClause | dataOccursClause | dataSignClause | dataSynchronizedClause | dataJustifiedClause | dataBlankWhenZeroClause | dataWithLowerBoundsClause | dataAlignedClause | dataRecordAreaClause)* DOT_FS - ; + : (INTEGERLITERAL | LEVEL_NUMBER_77) (FILLER | dataName)? ( + dataRedefinesClause + | dataIntegerStringClause + | dataExternalClause + | dataGlobalClause + | dataTypeDefClause + | dataThreadLocalClause + | dataPictureClause + | dataCommonOwnLocalClause + | dataTypeClause + | dataUsingClause + | dataUsageClause + | dataValueClause + | dataReceivedByClause + | dataOccursClause + | dataSignClause + | dataSynchronizedClause + | dataJustifiedClause + | dataBlankWhenZeroClause + | dataWithLowerBoundsClause + | dataAlignedClause + | dataRecordAreaClause + )* DOT_FS + ; dataDescriptionEntryFormat2 - : LEVEL_NUMBER_66 dataName dataRenamesClause DOT_FS - ; + : LEVEL_NUMBER_66 dataName dataRenamesClause DOT_FS + ; dataDescriptionEntryFormat3 - : LEVEL_NUMBER_88 conditionName dataValueClause DOT_FS - ; + : LEVEL_NUMBER_88 conditionName dataValueClause DOT_FS + ; dataDescriptionEntryExecSql - : EXECSQLLINE+ DOT_FS? - ; + : EXECSQLLINE+ DOT_FS? + ; dataAlignedClause - : ALIGNED - ; + : ALIGNED + ; dataBlankWhenZeroClause - : BLANK WHEN? (ZERO | ZEROS | ZEROES) - ; + : BLANK WHEN? (ZERO | ZEROS | ZEROES) + ; dataCommonOwnLocalClause - : COMMON | OWN | LOCAL - ; + : COMMON + | OWN + | LOCAL + ; dataExternalClause - : IS? EXTERNAL (BY literal)? - ; + : IS? EXTERNAL (BY literal)? + ; dataGlobalClause - : IS? GLOBAL - ; + : IS? GLOBAL + ; dataIntegerStringClause - : INTEGER | STRING - ; + : INTEGER + | STRING + ; dataJustifiedClause - : (JUSTIFIED | JUST) RIGHT? - ; + : (JUSTIFIED | JUST) RIGHT? + ; dataOccursClause - : OCCURS integerLiteral dataOccursTo? TIMES? (DEPENDING ON? qualifiedDataName)? dataOccursSort* (INDEXED BY? LOCAL? indexName+)? - ; + : OCCURS integerLiteral dataOccursTo? TIMES? (DEPENDING ON? qualifiedDataName)? dataOccursSort* ( + INDEXED BY? LOCAL? indexName+ + )? + ; dataOccursTo - : TO integerLiteral - ; + : TO integerLiteral + ; dataOccursSort - : (ASCENDING | DESCENDING) KEY? IS? qualifiedDataName+ - ; + : (ASCENDING | DESCENDING) KEY? IS? qualifiedDataName+ + ; dataPictureClause - : (PICTURE | PIC) IS? pictureString - ; + : (PICTURE | PIC) IS? pictureString + ; pictureString - : (pictureChars+ pictureCardinality?)+ - ; + : (pictureChars+ pictureCardinality?)+ + ; pictureChars - : DOLLARCHAR | IDENTIFIER | NUMERICLITERAL | SLASHCHAR | COMMACHAR | DOT | COLONCHAR | ASTERISKCHAR | DOUBLEASTERISKCHAR | LPARENCHAR | RPARENCHAR | PLUSCHAR | MINUSCHAR | LESSTHANCHAR | MORETHANCHAR | integerLiteral - ; + : DOLLARCHAR + | IDENTIFIER + | NUMERICLITERAL + | SLASHCHAR + | COMMACHAR + | DOT + | COLONCHAR + | ASTERISKCHAR + | DOUBLEASTERISKCHAR + | LPARENCHAR + | RPARENCHAR + | PLUSCHAR + | MINUSCHAR + | LESSTHANCHAR + | MORETHANCHAR + | integerLiteral + ; pictureCardinality - : LPARENCHAR integerLiteral RPARENCHAR - ; + : LPARENCHAR integerLiteral RPARENCHAR + ; dataReceivedByClause - : RECEIVED? BY? (CONTENT | REFERENCE | REF) - ; + : RECEIVED? BY? (CONTENT | REFERENCE | REF) + ; dataRecordAreaClause - : RECORD AREA - ; + : RECORD AREA + ; dataRedefinesClause - : REDEFINES dataName - ; + : REDEFINES dataName + ; dataRenamesClause - : RENAMES qualifiedDataName ((THROUGH | THRU) qualifiedDataName)? - ; + : RENAMES qualifiedDataName ((THROUGH | THRU) qualifiedDataName)? + ; dataSignClause - : (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? - ; + : (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? + ; dataSynchronizedClause - : (SYNCHRONIZED | SYNC) (LEFT | RIGHT)? - ; + : (SYNCHRONIZED | SYNC) (LEFT | RIGHT)? + ; dataThreadLocalClause - : IS? THREAD_LOCAL - ; + : IS? THREAD_LOCAL + ; dataTypeClause - : TYPE IS? (SHORT_DATE | LONG_DATE | NUMERIC_DATE | NUMERIC_TIME | LONG_TIME) - ; + : TYPE IS? (SHORT_DATE | LONG_DATE | NUMERIC_DATE | NUMERIC_TIME | LONG_TIME) + ; dataTypeDefClause - : IS? TYPEDEF - ; + : IS? TYPEDEF + ; dataUsageClause - : (USAGE IS?)? (BINARY (TRUNCATED | EXTENDED)? | BIT | COMP | COMP_1 | COMP_2 | COMP_3 | COMP_4 | COMP_5 | COMPUTATIONAL | COMPUTATIONAL_1 | COMPUTATIONAL_2 | COMPUTATIONAL_3 | COMPUTATIONAL_4 | COMPUTATIONAL_5 | CONTROL_POINT | DATE | DISPLAY | DISPLAY_1 | DOUBLE | EVENT | FUNCTION_POINTER | INDEX | KANJI | LOCK | NATIONAL | PACKED_DECIMAL | POINTER | PROCEDURE_POINTER | REAL | TASK) - ; + : (USAGE IS?)? ( + BINARY (TRUNCATED | EXTENDED)? + | BIT + | COMP + | COMP_1 + | COMP_2 + | COMP_3 + | COMP_4 + | COMP_5 + | COMPUTATIONAL + | COMPUTATIONAL_1 + | COMPUTATIONAL_2 + | COMPUTATIONAL_3 + | COMPUTATIONAL_4 + | COMPUTATIONAL_5 + | CONTROL_POINT + | DATE + | DISPLAY + | DISPLAY_1 + | DOUBLE + | EVENT + | FUNCTION_POINTER + | INDEX + | KANJI + | LOCK + | NATIONAL + | PACKED_DECIMAL + | POINTER + | PROCEDURE_POINTER + | REAL + | TASK + ) + ; dataUsingClause - : USING (LANGUAGE | CONVENTION) OF? (cobolWord | dataName) - ; + : USING (LANGUAGE | CONVENTION) OF? (cobolWord | dataName) + ; dataValueClause - : (VALUE IS? | VALUES ARE?)? dataValueInterval (COMMACHAR? dataValueInterval)* - ; + : (VALUE IS? | VALUES ARE?)? dataValueInterval (COMMACHAR? dataValueInterval)* + ; dataValueInterval - : dataValueIntervalFrom dataValueIntervalTo? - ; + : dataValueIntervalFrom dataValueIntervalTo? + ; dataValueIntervalFrom - : literal | cobolWord - ; + : literal + | cobolWord + ; dataValueIntervalTo - : (THROUGH | THRU) literal - ; + : (THROUGH | THRU) literal + ; dataWithLowerBoundsClause - : WITH? LOWER BOUNDS - ; + : WITH? LOWER BOUNDS + ; // --- procedure division -------------------------------------------------------------------- procedureDivision - : PROCEDURE DIVISION procedureDivisionUsingClause? procedureDivisionGivingClause? DOT_FS procedureDeclaratives? procedureDivisionBody - ; + : PROCEDURE DIVISION procedureDivisionUsingClause? procedureDivisionGivingClause? DOT_FS procedureDeclaratives? procedureDivisionBody + ; procedureDivisionUsingClause - : (USING | CHAINING) procedureDivisionUsingParameter+ - ; + : (USING | CHAINING) procedureDivisionUsingParameter+ + ; procedureDivisionGivingClause - : (GIVING | RETURNING) dataName - ; + : (GIVING | RETURNING) dataName + ; procedureDivisionUsingParameter - : procedureDivisionByReferencePhrase | procedureDivisionByValuePhrase - ; + : procedureDivisionByReferencePhrase + | procedureDivisionByValuePhrase + ; procedureDivisionByReferencePhrase - : (BY? REFERENCE)? procedureDivisionByReference+ - ; + : (BY? REFERENCE)? procedureDivisionByReference+ + ; procedureDivisionByReference - : (OPTIONAL? (identifier | fileName)) | ANY - ; + : (OPTIONAL? (identifier | fileName)) + | ANY + ; procedureDivisionByValuePhrase - : BY? VALUE procedureDivisionByValue+ - ; + : BY? VALUE procedureDivisionByValue+ + ; procedureDivisionByValue - : identifier | literal | ANY - ; + : identifier + | literal + | ANY + ; procedureDeclaratives - : DECLARATIVES DOT_FS procedureDeclarative+ END DECLARATIVES DOT_FS - ; + : DECLARATIVES DOT_FS procedureDeclarative+ END DECLARATIVES DOT_FS + ; procedureDeclarative - : procedureSectionHeader DOT_FS useStatement DOT_FS paragraphs - ; + : procedureSectionHeader DOT_FS useStatement DOT_FS paragraphs + ; procedureSectionHeader - : sectionName SECTION integerLiteral? - ; + : sectionName SECTION integerLiteral? + ; procedureDivisionBody - : paragraphs procedureSection* - ; + : paragraphs procedureSection* + ; // -- procedure section ---------------------------------- procedureSection - : procedureSectionHeader DOT_FS paragraphs - ; + : procedureSectionHeader DOT_FS paragraphs + ; paragraphs - : sentence* paragraph* - ; + : sentence* paragraph* + ; paragraph - : paragraphName DOT_FS (alteredGoTo | sentence*) - ; + : paragraphName DOT_FS (alteredGoTo | sentence*) + ; sentence - : statement* DOT_FS - ; + : statement* DOT_FS + ; statement - : acceptStatement | addStatement | alterStatement | callStatement | cancelStatement | closeStatement | computeStatement | continueStatement | deleteStatement | disableStatement | displayStatement | divideStatement | enableStatement | entryStatement | evaluateStatement | exhibitStatement | execCicsStatement | execSqlStatement | execSqlImsStatement | exitStatement | generateStatement | gobackStatement | goToStatement | ifStatement | initializeStatement | initiateStatement | inspectStatement | mergeStatement | moveStatement | multiplyStatement | openStatement | performStatement | purgeStatement | readStatement | receiveStatement | releaseStatement | returnStatement | rewriteStatement | searchStatement | sendStatement | setStatement | sortStatement | startStatement | stopStatement | stringStatement | subtractStatement | terminateStatement | unstringStatement | writeStatement - ; + : acceptStatement + | addStatement + | alterStatement + | callStatement + | cancelStatement + | closeStatement + | computeStatement + | continueStatement + | deleteStatement + | disableStatement + | displayStatement + | divideStatement + | enableStatement + | entryStatement + | evaluateStatement + | exhibitStatement + | execCicsStatement + | execSqlStatement + | execSqlImsStatement + | exitStatement + | generateStatement + | gobackStatement + | goToStatement + | ifStatement + | initializeStatement + | initiateStatement + | inspectStatement + | mergeStatement + | moveStatement + | multiplyStatement + | openStatement + | performStatement + | purgeStatement + | readStatement + | receiveStatement + | releaseStatement + | returnStatement + | rewriteStatement + | searchStatement + | sendStatement + | setStatement + | sortStatement + | startStatement + | stopStatement + | stringStatement + | subtractStatement + | terminateStatement + | unstringStatement + | writeStatement + ; // accept statement acceptStatement - : ACCEPT identifier (acceptFromDateStatement | acceptFromEscapeKeyStatement | acceptFromMnemonicStatement | acceptMessageCountStatement)? onExceptionClause? notOnExceptionClause? END_ACCEPT? - ; + : ACCEPT identifier ( + acceptFromDateStatement + | acceptFromEscapeKeyStatement + | acceptFromMnemonicStatement + | acceptMessageCountStatement + )? onExceptionClause? notOnExceptionClause? END_ACCEPT? + ; acceptFromDateStatement - : FROM (DATE YYYYMMDD? | DAY YYYYDDD? | DAY_OF_WEEK | TIME | TIMER | TODAYS_DATE MMDDYYYY? | TODAYS_NAME | YEAR | YYYYMMDD | YYYYDDD) - ; + : FROM ( + DATE YYYYMMDD? + | DAY YYYYDDD? + | DAY_OF_WEEK + | TIME + | TIMER + | TODAYS_DATE MMDDYYYY? + | TODAYS_NAME + | YEAR + | YYYYMMDD + | YYYYDDD + ) + ; acceptFromMnemonicStatement - : FROM mnemonicName - ; + : FROM mnemonicName + ; acceptFromEscapeKeyStatement - : FROM ESCAPE KEY - ; + : FROM ESCAPE KEY + ; acceptMessageCountStatement - : MESSAGE? COUNT - ; + : MESSAGE? COUNT + ; // add statement addStatement - : ADD (addToStatement | addToGivingStatement | addCorrespondingStatement) onSizeErrorPhrase? notOnSizeErrorPhrase? END_ADD? - ; + : ADD (addToStatement | addToGivingStatement | addCorrespondingStatement) onSizeErrorPhrase? notOnSizeErrorPhrase? END_ADD? + ; addToStatement - : addFrom+ TO addTo+ - ; + : addFrom+ TO addTo+ + ; addToGivingStatement - : addFrom+ (TO addToGiving+)? GIVING addGiving+ - ; + : addFrom+ (TO addToGiving+)? GIVING addGiving+ + ; addCorrespondingStatement - : (CORRESPONDING | CORR) identifier TO addTo - ; + : (CORRESPONDING | CORR) identifier TO addTo + ; addFrom - : identifier | literal - ; + : identifier + | literal + ; addTo - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; addToGiving - : identifier | literal - ; + : identifier + | literal + ; addGiving - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; // altered go to statement alteredGoTo - : GO TO? DOT_FS - ; + : GO TO? DOT_FS + ; // alter statement alterStatement - : ALTER alterProceedTo+ - ; + : ALTER alterProceedTo+ + ; alterProceedTo - : procedureName TO (PROCEED TO)? procedureName - ; + : procedureName TO (PROCEED TO)? procedureName + ; // call statement callStatement - : CALL (identifier | literal) callUsingPhrase? callGivingPhrase? onOverflowPhrase? onExceptionClause? notOnExceptionClause? END_CALL? - ; + : CALL (identifier | literal) callUsingPhrase? callGivingPhrase? onOverflowPhrase? onExceptionClause? notOnExceptionClause? END_CALL? + ; callUsingPhrase - : USING callUsingParameter+ - ; + : USING callUsingParameter+ + ; callUsingParameter - : callByReferencePhrase | callByValuePhrase | callByContentPhrase - ; + : callByReferencePhrase + | callByValuePhrase + | callByContentPhrase + ; callByReferencePhrase - : (BY? REFERENCE)? callByReference+ - ; + : (BY? REFERENCE)? callByReference+ + ; callByReference - : ((ADDRESS OF | INTEGER | STRING)? identifier | literal | fileName) | OMITTED - ; + : ((ADDRESS OF | INTEGER | STRING)? identifier | literal | fileName) + | OMITTED + ; callByValuePhrase - : BY? VALUE callByValue+ - ; + : BY? VALUE callByValue+ + ; callByValue - : (ADDRESS OF | LENGTH OF?)? (identifier | literal) - ; + : (ADDRESS OF | LENGTH OF?)? (identifier | literal) + ; callByContentPhrase - : BY? CONTENT callByContent+ - ; + : BY? CONTENT callByContent+ + ; callByContent - : (ADDRESS OF | LENGTH OF?)? identifier | literal | OMITTED - ; + : (ADDRESS OF | LENGTH OF?)? identifier + | literal + | OMITTED + ; callGivingPhrase - : (GIVING | RETURNING) identifier - ; + : (GIVING | RETURNING) identifier + ; // cancel statement cancelStatement - : CANCEL cancelCall+ - ; + : CANCEL cancelCall+ + ; cancelCall - : libraryName (BYTITLE | BYFUNCTION) | identifier | literal - ; + : libraryName (BYTITLE | BYFUNCTION) + | identifier + | literal + ; // close statement closeStatement - : CLOSE closeFile+ - ; + : CLOSE closeFile+ + ; closeFile - : fileName (closeReelUnitStatement | closeRelativeStatement | closePortFileIOStatement)? - ; + : fileName (closeReelUnitStatement | closeRelativeStatement | closePortFileIOStatement)? + ; closeReelUnitStatement - : (REEL | UNIT) (FOR? REMOVAL)? (WITH? (NO REWIND | LOCK))? - ; + : (REEL | UNIT) (FOR? REMOVAL)? (WITH? (NO REWIND | LOCK))? + ; closeRelativeStatement - : WITH? (NO REWIND | LOCK) - ; + : WITH? (NO REWIND | LOCK) + ; closePortFileIOStatement - : (WITH? NO WAIT | WITH WAIT) (USING closePortFileIOUsing+)? - ; + : (WITH? NO WAIT | WITH WAIT) (USING closePortFileIOUsing+)? + ; closePortFileIOUsing - : closePortFileIOUsingCloseDisposition | closePortFileIOUsingAssociatedData | closePortFileIOUsingAssociatedDataLength - ; + : closePortFileIOUsingCloseDisposition + | closePortFileIOUsingAssociatedData + | closePortFileIOUsingAssociatedDataLength + ; closePortFileIOUsingCloseDisposition - : CLOSE_DISPOSITION OF? (ABORT | ORDERLY) - ; + : CLOSE_DISPOSITION OF? (ABORT | ORDERLY) + ; closePortFileIOUsingAssociatedData - : ASSOCIATED_DATA (identifier | integerLiteral) - ; + : ASSOCIATED_DATA (identifier | integerLiteral) + ; closePortFileIOUsingAssociatedDataLength - : ASSOCIATED_DATA_LENGTH OF? (identifier | integerLiteral) - ; + : ASSOCIATED_DATA_LENGTH OF? (identifier | integerLiteral) + ; // compute statement computeStatement - : COMPUTE computeStore+ (EQUALCHAR | EQUAL) arithmeticExpression onSizeErrorPhrase? notOnSizeErrorPhrase? END_COMPUTE? - ; + : COMPUTE computeStore+ (EQUALCHAR | EQUAL) arithmeticExpression onSizeErrorPhrase? notOnSizeErrorPhrase? END_COMPUTE? + ; computeStore - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; // continue statement continueStatement - : CONTINUE - ; + : CONTINUE + ; // delete statement deleteStatement - : DELETE fileName RECORD? invalidKeyPhrase? notInvalidKeyPhrase? END_DELETE? - ; + : DELETE fileName RECORD? invalidKeyPhrase? notInvalidKeyPhrase? END_DELETE? + ; // disable statement disableStatement - : DISABLE (INPUT TERMINAL? | I_O TERMINAL | OUTPUT) cdName WITH? KEY (identifier | literal) - ; + : DISABLE (INPUT TERMINAL? | I_O TERMINAL | OUTPUT) cdName WITH? KEY (identifier | literal) + ; // display statement displayStatement - : DISPLAY displayOperand+ displayAt? displayUpon? displayWith? - ; + : DISPLAY displayOperand+ displayAt? displayUpon? displayWith? + ; displayOperand - : identifier | literal - ; + : identifier + | literal + ; displayAt - : AT (identifier | literal) - ; + : AT (identifier | literal) + ; displayUpon - : UPON (mnemonicName | environmentName) - ; + : UPON (mnemonicName | environmentName) + ; displayWith - : WITH? NO ADVANCING - ; + : WITH? NO ADVANCING + ; // divide statement divideStatement - : DIVIDE (identifier | literal) (divideIntoStatement | divideIntoGivingStatement | divideByGivingStatement) divideRemainder? onSizeErrorPhrase? notOnSizeErrorPhrase? END_DIVIDE? - ; + : DIVIDE (identifier | literal) ( + divideIntoStatement + | divideIntoGivingStatement + | divideByGivingStatement + ) divideRemainder? onSizeErrorPhrase? notOnSizeErrorPhrase? END_DIVIDE? + ; divideIntoStatement - : INTO divideInto+ - ; + : INTO divideInto+ + ; divideIntoGivingStatement - : INTO (identifier | literal) divideGivingPhrase? - ; + : INTO (identifier | literal) divideGivingPhrase? + ; divideByGivingStatement - : BY (identifier | literal) divideGivingPhrase? - ; + : BY (identifier | literal) divideGivingPhrase? + ; divideGivingPhrase - : GIVING divideGiving+ - ; + : GIVING divideGiving+ + ; divideInto - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; divideGiving - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; divideRemainder - : REMAINDER identifier - ; + : REMAINDER identifier + ; // enable statement enableStatement - : ENABLE (INPUT TERMINAL? | I_O TERMINAL | OUTPUT) cdName WITH? KEY (literal | identifier) - ; + : ENABLE (INPUT TERMINAL? | I_O TERMINAL | OUTPUT) cdName WITH? KEY (literal | identifier) + ; // entry statement entryStatement - : ENTRY literal (USING identifier+)? - ; + : ENTRY literal (USING identifier+)? + ; // evaluate statement evaluateStatement - : EVALUATE evaluateSelect evaluateAlsoSelect* evaluateWhenPhrase+ evaluateWhenOther? END_EVALUATE? - ; + : EVALUATE evaluateSelect evaluateAlsoSelect* evaluateWhenPhrase+ evaluateWhenOther? END_EVALUATE? + ; evaluateSelect - : identifier | literal | arithmeticExpression | condition - ; + : identifier + | literal + | arithmeticExpression + | condition + ; evaluateAlsoSelect - : ALSO evaluateSelect - ; + : ALSO evaluateSelect + ; evaluateWhenPhrase - : evaluateWhen+ statement* - ; + : evaluateWhen+ statement* + ; evaluateWhen - : WHEN evaluateCondition evaluateAlsoCondition* - ; + : WHEN evaluateCondition evaluateAlsoCondition* + ; evaluateCondition - : ANY | NOT? evaluateValue evaluateThrough? | condition | booleanLiteral - ; + : ANY + | NOT? evaluateValue evaluateThrough? + | condition + | booleanLiteral + ; evaluateThrough - : (THROUGH | THRU) evaluateValue - ; + : (THROUGH | THRU) evaluateValue + ; evaluateAlsoCondition - : ALSO evaluateCondition - ; + : ALSO evaluateCondition + ; evaluateWhenOther - : WHEN OTHER statement* - ; + : WHEN OTHER statement* + ; evaluateValue - : identifier | literal | arithmeticExpression - ; + : identifier + | literal + | arithmeticExpression + ; // exec cics statement execCicsStatement - : EXECCICSLINE+ - ; + : EXECCICSLINE+ + ; // exec sql statement execSqlStatement - : EXECSQLLINE+ - ; + : EXECSQLLINE+ + ; // exec sql ims statement execSqlImsStatement - : EXECSQLIMSLINE+ - ; + : EXECSQLIMSLINE+ + ; // exhibit statement exhibitStatement - : EXHIBIT NAMED? CHANGED? exhibitOperand+ - ; + : EXHIBIT NAMED? CHANGED? exhibitOperand+ + ; exhibitOperand - : identifier | literal - ; + : identifier + | literal + ; // exit statement exitStatement - : EXIT PROGRAM? - ; + : EXIT PROGRAM? + ; // generate statement generateStatement - : GENERATE reportName - ; + : GENERATE reportName + ; // goback statement gobackStatement - : GOBACK - ; + : GOBACK + ; // goto statement goToStatement - : GO TO? (goToStatementSimple | goToDependingOnStatement) - ; + : GO TO? (goToStatementSimple | goToDependingOnStatement) + ; goToStatementSimple - : procedureName - ; + : procedureName + ; goToDependingOnStatement - : MORE_LABELS | procedureName+ (DEPENDING ON? identifier)? - ; + : MORE_LABELS + | procedureName+ (DEPENDING ON? identifier)? + ; // if statement ifStatement - : IF condition ifThen ifElse? END_IF? - ; + : IF condition ifThen ifElse? END_IF? + ; ifThen - : THEN? (NEXT SENTENCE | statement*) - ; + : THEN? (NEXT SENTENCE | statement*) + ; ifElse - : ELSE (NEXT SENTENCE | statement*) - ; + : ELSE (NEXT SENTENCE | statement*) + ; // initialize statement initializeStatement - : INITIALIZE identifier+ initializeReplacingPhrase? - ; + : INITIALIZE identifier+ initializeReplacingPhrase? + ; initializeReplacingPhrase - : REPLACING initializeReplacingBy+ - ; + : REPLACING initializeReplacingBy+ + ; initializeReplacingBy - : (ALPHABETIC | ALPHANUMERIC | ALPHANUMERIC_EDITED | NATIONAL | NATIONAL_EDITED | NUMERIC | NUMERIC_EDITED | DBCS | EGCS) DATA? BY (identifier | literal) - ; + : ( + ALPHABETIC + | ALPHANUMERIC + | ALPHANUMERIC_EDITED + | NATIONAL + | NATIONAL_EDITED + | NUMERIC + | NUMERIC_EDITED + | DBCS + | EGCS + ) DATA? BY (identifier | literal) + ; // initiate statement initiateStatement - : INITIATE reportName+ - ; + : INITIATE reportName+ + ; // inspect statement inspectStatement - : INSPECT identifier (inspectTallyingPhrase | inspectReplacingPhrase | inspectTallyingReplacingPhrase | inspectConvertingPhrase) - ; + : INSPECT identifier ( + inspectTallyingPhrase + | inspectReplacingPhrase + | inspectTallyingReplacingPhrase + | inspectConvertingPhrase + ) + ; inspectTallyingPhrase - : TALLYING inspectFor+ - ; + : TALLYING inspectFor+ + ; inspectReplacingPhrase - : REPLACING (inspectReplacingCharacters | inspectReplacingAllLeadings)+ - ; + : REPLACING (inspectReplacingCharacters | inspectReplacingAllLeadings)+ + ; inspectTallyingReplacingPhrase - : TALLYING inspectFor+ inspectReplacingPhrase+ - ; + : TALLYING inspectFor+ inspectReplacingPhrase+ + ; inspectConvertingPhrase - : CONVERTING (identifier | literal) inspectTo inspectBeforeAfter* - ; + : CONVERTING (identifier | literal) inspectTo inspectBeforeAfter* + ; inspectFor - : identifier FOR (inspectCharacters | inspectAllLeadings)+ - ; + : identifier FOR (inspectCharacters | inspectAllLeadings)+ + ; inspectCharacters - : CHARACTERS inspectBeforeAfter* - ; + : CHARACTERS inspectBeforeAfter* + ; inspectReplacingCharacters - : CHARACTERS inspectBy inspectBeforeAfter* - ; + : CHARACTERS inspectBy inspectBeforeAfter* + ; inspectAllLeadings - : (ALL | LEADING) inspectAllLeading+ - ; + : (ALL | LEADING) inspectAllLeading+ + ; inspectReplacingAllLeadings - : (ALL | LEADING | FIRST) inspectReplacingAllLeading+ - ; + : (ALL | LEADING | FIRST) inspectReplacingAllLeading+ + ; inspectAllLeading - : (identifier | literal) inspectBeforeAfter* - ; + : (identifier | literal) inspectBeforeAfter* + ; inspectReplacingAllLeading - : (identifier | literal) inspectBy inspectBeforeAfter* - ; + : (identifier | literal) inspectBy inspectBeforeAfter* + ; inspectBy - : BY (identifier | literal) - ; + : BY (identifier | literal) + ; inspectTo - : TO (identifier | literal) - ; + : TO (identifier | literal) + ; inspectBeforeAfter - : (BEFORE | AFTER) INITIAL? (identifier | literal) - ; + : (BEFORE | AFTER) INITIAL? (identifier | literal) + ; // merge statement mergeStatement - : MERGE fileName mergeOnKeyClause+ mergeCollatingSequencePhrase? mergeUsing* mergeOutputProcedurePhrase? mergeGivingPhrase* - ; + : MERGE fileName mergeOnKeyClause+ mergeCollatingSequencePhrase? mergeUsing* mergeOutputProcedurePhrase? mergeGivingPhrase* + ; mergeOnKeyClause - : ON? (ASCENDING | DESCENDING) KEY? qualifiedDataName+ - ; + : ON? (ASCENDING | DESCENDING) KEY? qualifiedDataName+ + ; mergeCollatingSequencePhrase - : COLLATING? SEQUENCE IS? alphabetName+ mergeCollatingAlphanumeric? mergeCollatingNational? - ; + : COLLATING? SEQUENCE IS? alphabetName+ mergeCollatingAlphanumeric? mergeCollatingNational? + ; mergeCollatingAlphanumeric - : FOR? ALPHANUMERIC IS alphabetName - ; + : FOR? ALPHANUMERIC IS alphabetName + ; mergeCollatingNational - : FOR? NATIONAL IS? alphabetName - ; + : FOR? NATIONAL IS? alphabetName + ; mergeUsing - : USING fileName+ - ; + : USING fileName+ + ; mergeOutputProcedurePhrase - : OUTPUT PROCEDURE IS? procedureName mergeOutputThrough? - ; + : OUTPUT PROCEDURE IS? procedureName mergeOutputThrough? + ; mergeOutputThrough - : (THROUGH | THRU) procedureName - ; + : (THROUGH | THRU) procedureName + ; mergeGivingPhrase - : GIVING mergeGiving+ - ; + : GIVING mergeGiving+ + ; mergeGiving - : fileName (LOCK | SAVE | NO REWIND | CRUNCH | RELEASE | WITH REMOVE CRUNCH)? - ; + : fileName (LOCK | SAVE | NO REWIND | CRUNCH | RELEASE | WITH REMOVE CRUNCH)? + ; // move statement moveStatement - : MOVE ALL? (moveToStatement | moveCorrespondingToStatement) - ; + : MOVE ALL? (moveToStatement | moveCorrespondingToStatement) + ; moveToStatement - : moveToSendingArea TO identifier+ - ; + : moveToSendingArea TO identifier+ + ; moveToSendingArea - : identifier | literal - ; + : identifier + | literal + ; moveCorrespondingToStatement - : (CORRESPONDING | CORR) moveCorrespondingToSendingArea TO identifier+ - ; + : (CORRESPONDING | CORR) moveCorrespondingToSendingArea TO identifier+ + ; moveCorrespondingToSendingArea - : identifier - ; + : identifier + ; // multiply statement multiplyStatement - : MULTIPLY (identifier | literal) BY (multiplyRegular | multiplyGiving) onSizeErrorPhrase? notOnSizeErrorPhrase? END_MULTIPLY? - ; + : MULTIPLY (identifier | literal) BY (multiplyRegular | multiplyGiving) onSizeErrorPhrase? notOnSizeErrorPhrase? END_MULTIPLY? + ; multiplyRegular - : multiplyRegularOperand+ - ; + : multiplyRegularOperand+ + ; multiplyRegularOperand - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; multiplyGiving - : multiplyGivingOperand GIVING multiplyGivingResult+ - ; + : multiplyGivingOperand GIVING multiplyGivingResult+ + ; multiplyGivingOperand - : identifier | literal - ; + : identifier + | literal + ; multiplyGivingResult - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; // open statement openStatement - : OPEN (openInputStatement | openOutputStatement | openIOStatement | openExtendStatement)+ - ; + : OPEN (openInputStatement | openOutputStatement | openIOStatement | openExtendStatement)+ + ; openInputStatement - : INPUT openInput+ - ; + : INPUT openInput+ + ; openInput - : fileName (REVERSED | WITH? NO REWIND)? - ; + : fileName (REVERSED | WITH? NO REWIND)? + ; openOutputStatement - : OUTPUT openOutput+ - ; + : OUTPUT openOutput+ + ; openOutput - : fileName (WITH? NO REWIND)? - ; + : fileName (WITH? NO REWIND)? + ; openIOStatement - : I_O fileName+ - ; + : I_O fileName+ + ; openExtendStatement - : EXTEND fileName+ - ; + : EXTEND fileName+ + ; // perform statement performStatement - : PERFORM (performInlineStatement | performProcedureStatement) - ; + : PERFORM (performInlineStatement | performProcedureStatement) + ; performInlineStatement - : performType? statement* END_PERFORM - ; + : performType? statement* END_PERFORM + ; performProcedureStatement - : procedureName ((THROUGH | THRU) procedureName)? performType? - ; + : procedureName ((THROUGH | THRU) procedureName)? performType? + ; performType - : performTimes | performUntil | performVarying - ; + : performTimes + | performUntil + | performVarying + ; performTimes - : (identifier | integerLiteral) TIMES - ; + : (identifier | integerLiteral) TIMES + ; performUntil - : performTestClause? UNTIL condition - ; + : performTestClause? UNTIL condition + ; performVarying - : performTestClause performVaryingClause | performVaryingClause performTestClause? - ; + : performTestClause performVaryingClause + | performVaryingClause performTestClause? + ; performVaryingClause - : VARYING performVaryingPhrase performAfter* - ; + : VARYING performVaryingPhrase performAfter* + ; performVaryingPhrase - : (identifier | literal) performFrom performBy performUntil - ; + : (identifier | literal) performFrom performBy performUntil + ; performAfter - : AFTER performVaryingPhrase - ; + : AFTER performVaryingPhrase + ; performFrom - : FROM (identifier | literal | arithmeticExpression) - ; + : FROM (identifier | literal | arithmeticExpression) + ; performBy - : BY (identifier | literal | arithmeticExpression) - ; + : BY (identifier | literal | arithmeticExpression) + ; performTestClause - : WITH? TEST (BEFORE | AFTER) - ; + : WITH? TEST (BEFORE | AFTER) + ; // purge statement purgeStatement - : PURGE cdName+ - ; + : PURGE cdName+ + ; // read statement readStatement - : READ fileName NEXT? RECORD? readInto? readWith? readKey? invalidKeyPhrase? notInvalidKeyPhrase? atEndPhrase? notAtEndPhrase? END_READ? - ; + : READ fileName NEXT? RECORD? readInto? readWith? readKey? invalidKeyPhrase? notInvalidKeyPhrase? atEndPhrase? notAtEndPhrase? END_READ? + ; readInto - : INTO identifier - ; + : INTO identifier + ; readWith - : WITH? ((KEPT | NO) LOCK | WAIT) - ; + : WITH? ((KEPT | NO) LOCK | WAIT) + ; readKey - : KEY IS? qualifiedDataName - ; + : KEY IS? qualifiedDataName + ; // receive statement receiveStatement - : RECEIVE (receiveFromStatement | receiveIntoStatement) onExceptionClause? notOnExceptionClause? END_RECEIVE? - ; + : RECEIVE (receiveFromStatement | receiveIntoStatement) onExceptionClause? notOnExceptionClause? END_RECEIVE? + ; receiveFromStatement - : dataName FROM receiveFrom (receiveBefore | receiveWith | receiveThread | receiveSize | receiveStatus)* - ; + : dataName FROM receiveFrom ( + receiveBefore + | receiveWith + | receiveThread + | receiveSize + | receiveStatus + )* + ; receiveFrom - : THREAD dataName | LAST THREAD | ANY THREAD - ; + : THREAD dataName + | LAST THREAD + | ANY THREAD + ; receiveIntoStatement - : cdName (MESSAGE | SEGMENT) INTO? identifier receiveNoData? receiveWithData? - ; + : cdName (MESSAGE | SEGMENT) INTO? identifier receiveNoData? receiveWithData? + ; receiveNoData - : NO DATA statement* - ; + : NO DATA statement* + ; receiveWithData - : WITH DATA statement* - ; + : WITH DATA statement* + ; receiveBefore - : BEFORE TIME? (numericLiteral | identifier) - ; + : BEFORE TIME? (numericLiteral | identifier) + ; receiveWith - : WITH? NO WAIT - ; + : WITH? NO WAIT + ; receiveThread - : THREAD IN? dataName - ; + : THREAD IN? dataName + ; receiveSize - : SIZE IN? (numericLiteral | identifier) - ; + : SIZE IN? (numericLiteral | identifier) + ; receiveStatus - : STATUS IN? (identifier) - ; + : STATUS IN? (identifier) + ; // release statement releaseStatement - : RELEASE recordName (FROM qualifiedDataName)? - ; + : RELEASE recordName (FROM qualifiedDataName)? + ; // return statement returnStatement - : RETURN fileName RECORD? returnInto? atEndPhrase notAtEndPhrase? END_RETURN? - ; + : RETURN fileName RECORD? returnInto? atEndPhrase notAtEndPhrase? END_RETURN? + ; returnInto - : INTO qualifiedDataName - ; + : INTO qualifiedDataName + ; // rewrite statement rewriteStatement - : REWRITE recordName rewriteFrom? invalidKeyPhrase? notInvalidKeyPhrase? END_REWRITE? - ; + : REWRITE recordName rewriteFrom? invalidKeyPhrase? notInvalidKeyPhrase? END_REWRITE? + ; rewriteFrom - : FROM identifier - ; + : FROM identifier + ; // search statement searchStatement - : SEARCH ALL? qualifiedDataName searchVarying? atEndPhrase? searchWhen+ END_SEARCH? - ; + : SEARCH ALL? qualifiedDataName searchVarying? atEndPhrase? searchWhen+ END_SEARCH? + ; searchVarying - : VARYING qualifiedDataName - ; + : VARYING qualifiedDataName + ; searchWhen - : WHEN condition (NEXT SENTENCE | statement*) - ; + : WHEN condition (NEXT SENTENCE | statement*) + ; // send statement sendStatement - : SEND (sendStatementSync | sendStatementAsync) onExceptionClause? notOnExceptionClause? - ; + : SEND (sendStatementSync | sendStatementAsync) onExceptionClause? notOnExceptionClause? + ; sendStatementSync - : (identifier | literal) sendFromPhrase? sendWithPhrase? sendReplacingPhrase? sendAdvancingPhrase? - ; + : (identifier | literal) sendFromPhrase? sendWithPhrase? sendReplacingPhrase? sendAdvancingPhrase? + ; sendStatementAsync - : TO (TOP | BOTTOM) identifier - ; + : TO (TOP | BOTTOM) identifier + ; sendFromPhrase - : FROM identifier - ; + : FROM identifier + ; sendWithPhrase - : WITH (EGI | EMI | ESI | identifier) - ; + : WITH (EGI | EMI | ESI | identifier) + ; sendReplacingPhrase - : REPLACING LINE? - ; + : REPLACING LINE? + ; sendAdvancingPhrase - : (BEFORE | AFTER) ADVANCING? (sendAdvancingPage | sendAdvancingLines | sendAdvancingMnemonic) - ; + : (BEFORE | AFTER) ADVANCING? (sendAdvancingPage | sendAdvancingLines | sendAdvancingMnemonic) + ; sendAdvancingPage - : PAGE - ; + : PAGE + ; sendAdvancingLines - : (identifier | literal) (LINE | LINES)? - ; + : (identifier | literal) (LINE | LINES)? + ; sendAdvancingMnemonic - : mnemonicName - ; + : mnemonicName + ; // set statement setStatement - : SET (setToStatement+ | setUpDownByStatement) - ; + : SET (setToStatement+ | setUpDownByStatement) + ; setToStatement - : setTo+ TO setToValue+ - ; + : setTo+ TO setToValue+ + ; setUpDownByStatement - : setTo+ (UP BY | DOWN BY) setByValue - ; + : setTo+ (UP BY | DOWN BY) setByValue + ; setTo - : identifier - ; + : identifier + ; setToValue - : ON | OFF | ENTRY (identifier | literal) | identifier | literal - ; + : ON + | OFF + | ENTRY (identifier | literal) + | identifier + | literal + ; setByValue - : identifier | literal - ; + : identifier + | literal + ; // sort statement sortStatement - : SORT fileName sortOnKeyClause+ sortDuplicatesPhrase? sortCollatingSequencePhrase? sortInputProcedurePhrase? sortUsing* sortOutputProcedurePhrase? sortGivingPhrase* - ; + : SORT fileName sortOnKeyClause+ sortDuplicatesPhrase? sortCollatingSequencePhrase? sortInputProcedurePhrase? sortUsing* sortOutputProcedurePhrase + ? sortGivingPhrase* + ; sortOnKeyClause - : ON? (ASCENDING | DESCENDING) KEY? qualifiedDataName+ - ; + : ON? (ASCENDING | DESCENDING) KEY? qualifiedDataName+ + ; sortDuplicatesPhrase - : WITH? DUPLICATES IN? ORDER? - ; + : WITH? DUPLICATES IN? ORDER? + ; sortCollatingSequencePhrase - : COLLATING? SEQUENCE IS? alphabetName+ sortCollatingAlphanumeric? sortCollatingNational? - ; + : COLLATING? SEQUENCE IS? alphabetName+ sortCollatingAlphanumeric? sortCollatingNational? + ; sortCollatingAlphanumeric - : FOR? ALPHANUMERIC IS alphabetName - ; + : FOR? ALPHANUMERIC IS alphabetName + ; sortCollatingNational - : FOR? NATIONAL IS? alphabetName - ; + : FOR? NATIONAL IS? alphabetName + ; sortInputProcedurePhrase - : INPUT PROCEDURE IS? procedureName sortInputThrough? - ; + : INPUT PROCEDURE IS? procedureName sortInputThrough? + ; sortInputThrough - : (THROUGH | THRU) procedureName - ; + : (THROUGH | THRU) procedureName + ; sortUsing - : USING fileName+ - ; + : USING fileName+ + ; sortOutputProcedurePhrase - : OUTPUT PROCEDURE IS? procedureName sortOutputThrough? - ; + : OUTPUT PROCEDURE IS? procedureName sortOutputThrough? + ; sortOutputThrough - : (THROUGH | THRU) procedureName - ; + : (THROUGH | THRU) procedureName + ; sortGivingPhrase - : GIVING sortGiving+ - ; + : GIVING sortGiving+ + ; sortGiving - : fileName (LOCK | SAVE | NO REWIND | CRUNCH | RELEASE | WITH REMOVE CRUNCH)? - ; + : fileName (LOCK | SAVE | NO REWIND | CRUNCH | RELEASE | WITH REMOVE CRUNCH)? + ; // start statement startStatement - : START fileName startKey? invalidKeyPhrase? notInvalidKeyPhrase? END_START? - ; + : START fileName startKey? invalidKeyPhrase? notInvalidKeyPhrase? END_START? + ; startKey - : KEY IS? (EQUAL TO? | EQUALCHAR | GREATER THAN? | MORETHANCHAR | NOT LESS THAN? | NOT LESSTHANCHAR | GREATER THAN? OR EQUAL TO? | MORETHANOREQUAL) qualifiedDataName - ; + : KEY IS? ( + EQUAL TO? + | EQUALCHAR + | GREATER THAN? + | MORETHANCHAR + | NOT LESS THAN? + | NOT LESSTHANCHAR + | GREATER THAN? OR EQUAL TO? + | MORETHANOREQUAL + ) qualifiedDataName + ; // stop statement stopStatement - : STOP (RUN | literal) - ; + : STOP (RUN | literal) + ; // string statement stringStatement - : STRING stringSendingPhrase+ stringIntoPhrase stringWithPointerPhrase? onOverflowPhrase? notOnOverflowPhrase? END_STRING? - ; + : STRING stringSendingPhrase+ stringIntoPhrase stringWithPointerPhrase? onOverflowPhrase? notOnOverflowPhrase? END_STRING? + ; stringSendingPhrase - : stringSending+ (stringDelimitedByPhrase | stringForPhrase) - ; + : stringSending+ (stringDelimitedByPhrase | stringForPhrase) + ; stringSending - : identifier | literal - ; + : identifier + | literal + ; stringDelimitedByPhrase - : DELIMITED BY? (SIZE | identifier | literal) - ; + : DELIMITED BY? (SIZE | identifier | literal) + ; stringForPhrase - : FOR (identifier | literal) - ; + : FOR (identifier | literal) + ; stringIntoPhrase - : INTO identifier - ; + : INTO identifier + ; stringWithPointerPhrase - : WITH? POINTER qualifiedDataName - ; + : WITH? POINTER qualifiedDataName + ; // subtract statement subtractStatement - : SUBTRACT (subtractFromStatement | subtractFromGivingStatement | subtractCorrespondingStatement) onSizeErrorPhrase? notOnSizeErrorPhrase? END_SUBTRACT? - ; + : SUBTRACT ( + subtractFromStatement + | subtractFromGivingStatement + | subtractCorrespondingStatement + ) onSizeErrorPhrase? notOnSizeErrorPhrase? END_SUBTRACT? + ; subtractFromStatement - : subtractSubtrahend+ FROM subtractMinuend+ - ; + : subtractSubtrahend+ FROM subtractMinuend+ + ; subtractFromGivingStatement - : subtractSubtrahend+ FROM subtractMinuendGiving GIVING subtractGiving+ - ; + : subtractSubtrahend+ FROM subtractMinuendGiving GIVING subtractGiving+ + ; subtractCorrespondingStatement - : (CORRESPONDING | CORR) qualifiedDataName FROM subtractMinuendCorresponding - ; + : (CORRESPONDING | CORR) qualifiedDataName FROM subtractMinuendCorresponding + ; subtractSubtrahend - : identifier | literal - ; + : identifier + | literal + ; subtractMinuend - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; subtractMinuendGiving - : identifier | literal - ; + : identifier + | literal + ; subtractGiving - : identifier ROUNDED? - ; + : identifier ROUNDED? + ; subtractMinuendCorresponding - : qualifiedDataName ROUNDED? - ; + : qualifiedDataName ROUNDED? + ; // terminate statement terminateStatement - : TERMINATE reportName - ; + : TERMINATE reportName + ; // unstring statement unstringStatement - : UNSTRING unstringSendingPhrase unstringIntoPhrase unstringWithPointerPhrase? unstringTallyingPhrase? onOverflowPhrase? notOnOverflowPhrase? END_UNSTRING? - ; + : UNSTRING unstringSendingPhrase unstringIntoPhrase unstringWithPointerPhrase? unstringTallyingPhrase? onOverflowPhrase? notOnOverflowPhrase? + END_UNSTRING? + ; unstringSendingPhrase - : identifier (unstringDelimitedByPhrase unstringOrAllPhrase*)? - ; + : identifier (unstringDelimitedByPhrase unstringOrAllPhrase*)? + ; unstringDelimitedByPhrase - : DELIMITED BY? ALL? (identifier | literal) - ; + : DELIMITED BY? ALL? (identifier | literal) + ; unstringOrAllPhrase - : OR ALL? (identifier | literal) - ; + : OR ALL? (identifier | literal) + ; unstringIntoPhrase - : INTO unstringInto+ - ; + : INTO unstringInto+ + ; unstringInto - : identifier unstringDelimiterIn? unstringCountIn? - ; + : identifier unstringDelimiterIn? unstringCountIn? + ; unstringDelimiterIn - : DELIMITER IN? identifier - ; + : DELIMITER IN? identifier + ; unstringCountIn - : COUNT IN? identifier - ; + : COUNT IN? identifier + ; unstringWithPointerPhrase - : WITH? POINTER qualifiedDataName - ; + : WITH? POINTER qualifiedDataName + ; unstringTallyingPhrase - : TALLYING IN? qualifiedDataName - ; + : TALLYING IN? qualifiedDataName + ; // use statement useStatement - : USE (useAfterClause | useDebugClause) - ; + : USE (useAfterClause | useDebugClause) + ; useAfterClause - : GLOBAL? AFTER STANDARD? (EXCEPTION | ERROR) PROCEDURE ON? useAfterOn - ; + : GLOBAL? AFTER STANDARD? (EXCEPTION | ERROR) PROCEDURE ON? useAfterOn + ; useAfterOn - : INPUT | OUTPUT | I_O | EXTEND | fileName+ - ; + : INPUT + | OUTPUT + | I_O + | EXTEND + | fileName+ + ; useDebugClause - : FOR? DEBUGGING ON? useDebugOn+ - ; + : FOR? DEBUGGING ON? useDebugOn+ + ; useDebugOn - : ALL PROCEDURES | ALL REFERENCES? OF? identifier | procedureName | fileName - ; + : ALL PROCEDURES + | ALL REFERENCES? OF? identifier + | procedureName + | fileName + ; // write statement writeStatement - : WRITE recordName writeFromPhrase? writeAdvancingPhrase? writeAtEndOfPagePhrase? writeNotAtEndOfPagePhrase? invalidKeyPhrase? notInvalidKeyPhrase? END_WRITE? - ; + : WRITE recordName writeFromPhrase? writeAdvancingPhrase? writeAtEndOfPagePhrase? writeNotAtEndOfPagePhrase? invalidKeyPhrase? notInvalidKeyPhrase + ? END_WRITE? + ; writeFromPhrase - : FROM (identifier | literal) - ; + : FROM (identifier | literal) + ; writeAdvancingPhrase - : (BEFORE | AFTER) ADVANCING? (writeAdvancingPage | writeAdvancingLines | writeAdvancingMnemonic) - ; + : (BEFORE | AFTER) ADVANCING? ( + writeAdvancingPage + | writeAdvancingLines + | writeAdvancingMnemonic + ) + ; writeAdvancingPage - : PAGE - ; + : PAGE + ; writeAdvancingLines - : (identifier | literal) (LINE | LINES)? - ; + : (identifier | literal) (LINE | LINES)? + ; writeAdvancingMnemonic - : mnemonicName - ; + : mnemonicName + ; writeAtEndOfPagePhrase - : AT? (END_OF_PAGE | EOP) statement* - ; + : AT? (END_OF_PAGE | EOP) statement* + ; writeNotAtEndOfPagePhrase - : NOT AT? (END_OF_PAGE | EOP) statement* - ; + : NOT AT? (END_OF_PAGE | EOP) statement* + ; // statement phrases ---------------------------------- atEndPhrase - : AT? END statement* - ; + : AT? END statement* + ; notAtEndPhrase - : NOT AT? END statement* - ; + : NOT AT? END statement* + ; invalidKeyPhrase - : INVALID KEY? statement* - ; + : INVALID KEY? statement* + ; notInvalidKeyPhrase - : NOT INVALID KEY? statement* - ; + : NOT INVALID KEY? statement* + ; onOverflowPhrase - : ON? OVERFLOW statement* - ; + : ON? OVERFLOW statement* + ; notOnOverflowPhrase - : NOT ON? OVERFLOW statement* - ; + : NOT ON? OVERFLOW statement* + ; onSizeErrorPhrase - : ON? SIZE ERROR statement* - ; + : ON? SIZE ERROR statement* + ; notOnSizeErrorPhrase - : NOT ON? SIZE ERROR statement* - ; + : NOT ON? SIZE ERROR statement* + ; // statement clauses ---------------------------------- onExceptionClause - : ON? EXCEPTION statement* - ; + : ON? EXCEPTION statement* + ; notOnExceptionClause - : NOT ON? EXCEPTION statement* - ; + : NOT ON? EXCEPTION statement* + ; // arithmetic expression ---------------------------------- arithmeticExpression - : multDivs plusMinus* - ; + : multDivs plusMinus* + ; plusMinus - : (PLUSCHAR | MINUSCHAR) multDivs - ; + : (PLUSCHAR | MINUSCHAR) multDivs + ; multDivs - : powers multDiv* - ; + : powers multDiv* + ; multDiv - : (ASTERISKCHAR | SLASHCHAR) powers - ; + : (ASTERISKCHAR | SLASHCHAR) powers + ; powers - : (PLUSCHAR | MINUSCHAR)? basis power* - ; + : (PLUSCHAR | MINUSCHAR)? basis power* + ; power - : DOUBLEASTERISKCHAR basis - ; + : DOUBLEASTERISKCHAR basis + ; basis - : LPARENCHAR arithmeticExpression RPARENCHAR | identifier | literal - ; + : LPARENCHAR arithmeticExpression RPARENCHAR + | identifier + | literal + ; // condition ---------------------------------- condition - : combinableCondition andOrCondition* - ; + : combinableCondition andOrCondition* + ; andOrCondition - : (AND | OR) (combinableCondition | abbreviation+) - ; + : (AND | OR) (combinableCondition | abbreviation+) + ; combinableCondition - : NOT? simpleCondition - ; + : NOT? simpleCondition + ; simpleCondition - : LPARENCHAR condition RPARENCHAR | relationCondition | classCondition | conditionNameReference - ; + : LPARENCHAR condition RPARENCHAR + | relationCondition + | classCondition + | conditionNameReference + ; classCondition - : identifier IS? NOT? (NUMERIC | ALPHABETIC | ALPHABETIC_LOWER | ALPHABETIC_UPPER | DBCS | KANJI | className) - ; + : identifier IS? NOT? ( + NUMERIC + | ALPHABETIC + | ALPHABETIC_LOWER + | ALPHABETIC_UPPER + | DBCS + | KANJI + | className + ) + ; conditionNameReference - : conditionName (inData* inFile? conditionNameSubscriptReference* | inMnemonic*) - ; + : conditionName (inData* inFile? conditionNameSubscriptReference* | inMnemonic*) + ; conditionNameSubscriptReference - : LPARENCHAR subscript_ (COMMACHAR? subscript_)* RPARENCHAR - ; + : LPARENCHAR subscript_ (COMMACHAR? subscript_)* RPARENCHAR + ; // relation ---------------------------------- relationCondition - : relationSignCondition | relationArithmeticComparison | relationCombinedComparison - ; + : relationSignCondition + | relationArithmeticComparison + | relationCombinedComparison + ; relationSignCondition - : arithmeticExpression IS? NOT? (POSITIVE | NEGATIVE | ZERO) - ; + : arithmeticExpression IS? NOT? (POSITIVE | NEGATIVE | ZERO) + ; relationArithmeticComparison - : arithmeticExpression relationalOperator arithmeticExpression - ; + : arithmeticExpression relationalOperator arithmeticExpression + ; relationCombinedComparison - : arithmeticExpression relationalOperator LPARENCHAR relationCombinedCondition RPARENCHAR - ; + : arithmeticExpression relationalOperator LPARENCHAR relationCombinedCondition RPARENCHAR + ; relationCombinedCondition - : arithmeticExpression ((AND | OR) arithmeticExpression)+ - ; + : arithmeticExpression ((AND | OR) arithmeticExpression)+ + ; relationalOperator - : (IS | ARE)? (NOT? (GREATER THAN? | MORETHANCHAR | LESS THAN? | LESSTHANCHAR | EQUAL TO? | EQUALCHAR) | NOTEQUALCHAR | GREATER THAN? OR EQUAL TO? | MORETHANOREQUAL | LESS THAN? OR EQUAL TO? | LESSTHANOREQUAL) - ; + : (IS | ARE)? ( + NOT? (GREATER THAN? | MORETHANCHAR | LESS THAN? | LESSTHANCHAR | EQUAL TO? | EQUALCHAR) + | NOTEQUALCHAR + | GREATER THAN? OR EQUAL TO? + | MORETHANOREQUAL + | LESS THAN? OR EQUAL TO? + | LESSTHANOREQUAL + ) + ; abbreviation - : NOT? relationalOperator? (arithmeticExpression | LPARENCHAR arithmeticExpression abbreviation RPARENCHAR) - ; + : NOT? relationalOperator? ( + arithmeticExpression + | LPARENCHAR arithmeticExpression abbreviation RPARENCHAR + ) + ; // identifier ---------------------------------- identifier - : qualifiedDataName | tableCall | functionCall | specialRegister - ; + : qualifiedDataName + | tableCall + | functionCall + | specialRegister + ; tableCall - : qualifiedDataName (LPARENCHAR subscript_ (COMMACHAR? subscript_)* RPARENCHAR)* referenceModifier? - ; + : qualifiedDataName (LPARENCHAR subscript_ (COMMACHAR? subscript_)* RPARENCHAR)* referenceModifier? + ; functionCall - : FUNCTION functionName (LPARENCHAR argument (COMMACHAR? argument)* RPARENCHAR)* referenceModifier? - ; + : FUNCTION functionName (LPARENCHAR argument (COMMACHAR? argument)* RPARENCHAR)* referenceModifier? + ; referenceModifier - : LPARENCHAR characterPosition COLONCHAR length? RPARENCHAR - ; + : LPARENCHAR characterPosition COLONCHAR length? RPARENCHAR + ; characterPosition - : arithmeticExpression - ; + : arithmeticExpression + ; length - : arithmeticExpression - ; + : arithmeticExpression + ; subscript_ - : ALL | integerLiteral | qualifiedDataName integerLiteral? | indexName integerLiteral? | arithmeticExpression - ; + : ALL + | integerLiteral + | qualifiedDataName integerLiteral? + | indexName integerLiteral? + | arithmeticExpression + ; argument - : literal | identifier | qualifiedDataName integerLiteral? | indexName integerLiteral? | arithmeticExpression - ; + : literal + | identifier + | qualifiedDataName integerLiteral? + | indexName integerLiteral? + | arithmeticExpression + ; // qualified data name ---------------------------------- qualifiedDataName - : qualifiedDataNameFormat1 | qualifiedDataNameFormat2 | qualifiedDataNameFormat3 | qualifiedDataNameFormat4 - ; + : qualifiedDataNameFormat1 + | qualifiedDataNameFormat2 + | qualifiedDataNameFormat3 + | qualifiedDataNameFormat4 + ; qualifiedDataNameFormat1 - : (dataName | conditionName) (qualifiedInData+ inFile? | inFile)? - ; + : (dataName | conditionName) (qualifiedInData+ inFile? | inFile)? + ; qualifiedDataNameFormat2 - : paragraphName inSection - ; + : paragraphName inSection + ; qualifiedDataNameFormat3 - : textName inLibrary - ; + : textName inLibrary + ; qualifiedDataNameFormat4 - : LINAGE_COUNTER inFile - ; + : LINAGE_COUNTER inFile + ; qualifiedInData - : inData | inTable - ; + : inData + | inTable + ; // in ---------------------------------- inData - : (IN | OF) dataName - ; + : (IN | OF) dataName + ; inFile - : (IN | OF) fileName - ; + : (IN | OF) fileName + ; inMnemonic - : (IN | OF) mnemonicName - ; + : (IN | OF) mnemonicName + ; inSection - : (IN | OF) sectionName - ; + : (IN | OF) sectionName + ; inLibrary - : (IN | OF) libraryName - ; + : (IN | OF) libraryName + ; inTable - : (IN | OF) tableCall - ; + : (IN | OF) tableCall + ; // names ---------------------------------- alphabetName - : cobolWord - ; + : cobolWord + ; assignmentName - : systemName - ; + : systemName + ; basisName - : programName - ; + : programName + ; cdName - : cobolWord - ; + : cobolWord + ; className - : cobolWord - ; + : cobolWord + ; computerName - : systemName - ; + : systemName + ; conditionName - : cobolWord - ; + : cobolWord + ; dataName - : cobolWord - ; + : cobolWord + ; dataDescName - : FILLER | CURSOR | dataName - ; + : FILLER + | CURSOR + | dataName + ; environmentName - : systemName - ; + : systemName + ; fileName - : cobolWord - ; + : cobolWord + ; functionName - : INTEGER | LENGTH | RANDOM | SUM | WHEN_COMPILED | cobolWord - ; + : INTEGER + | LENGTH + | RANDOM + | SUM + | WHEN_COMPILED + | cobolWord + ; indexName - : cobolWord - ; + : cobolWord + ; languageName - : systemName - ; + : systemName + ; libraryName - : cobolWord - ; + : cobolWord + ; localName - : cobolWord - ; + : cobolWord + ; mnemonicName - : cobolWord - ; + : cobolWord + ; paragraphName - : cobolWord | integerLiteral - ; + : cobolWord + | integerLiteral + ; procedureName - : paragraphName inSection? | sectionName - ; + : paragraphName inSection? + | sectionName + ; programName - : NONNUMERICLITERAL | cobolWord - ; + : NONNUMERICLITERAL + | cobolWord + ; recordName - : qualifiedDataName - ; + : qualifiedDataName + ; reportName - : qualifiedDataName - ; + : qualifiedDataName + ; routineName - : cobolWord - ; + : cobolWord + ; screenName - : cobolWord - ; + : cobolWord + ; sectionName - : cobolWord | integerLiteral - ; + : cobolWord + | integerLiteral + ; systemName - : cobolWord - ; + : cobolWord + ; symbolicCharacter - : cobolWord - ; + : cobolWord + ; textName - : cobolWord - ; + : cobolWord + ; // literal ---------------------------------- cobolWord - : IDENTIFIER - | COBOL | PROGRAM - | ABORT | AS | ASCII | ASSOCIATED_DATA | ASSOCIATED_DATA_LENGTH | ATTRIBUTE | AUTO | AUTO_SKIP - | BACKGROUND_COLOR | BACKGROUND_COLOUR | BEEP | BELL | BINARY | BIT | BLINK | BOUNDS - | CAPABLE | CCSVERSION | CHANGED | CHANNEL | CLOSE_DISPOSITION | COMMITMENT | CONTROL_POINT | CONVENTION | CRUNCH | CURSOR - | DEFAULT | DEFAULT_DISPLAY | DEFINITION | DFHRESP | DFHVALUE | DISK | DONTCARE | DOUBLE - | EBCDIC | EMPTY_CHECK | ENTER | ENTRY_PROCEDURE | EOL | EOS | ERASE | ESCAPE | EVENT | EXCLUSIVE | EXPORT | EXTENDED - | FOREGROUND_COLOR | FOREGROUND_COLOUR | FULL | FUNCTIONNAME | FUNCTION_POINTER - | GRID - | HIGHLIGHT - | IMPLICIT | IMPORT | INTEGER - | KEPT | KEYBOARD - | LANGUAGE | LB | LD | LEFTLINE | LENGTH_CHECK | LIBACCESS | LIBPARAMETER | LIBRARY | LIST | LOCAL | LONG_DATE | LONG_TIME | LOWER | LOWLIGHT - | MMDDYYYY - | NAMED | NATIONAL | NATIONAL_EDITED | NETWORK | NO_ECHO | NUMERIC_DATE | NUMERIC_TIME - | ODT | ORDERLY | OVERLINE | OWN - | PASSWORD | PORT | PRINTER | PRIVATE | PROCESS | PROMPT - | READER | REAL | RECEIVED | RECURSIVE | REF | REMOTE | REMOVE | REQUIRED | REVERSE_VIDEO - | SAVE | SECURE | SHARED | SHAREDBYALL | SHAREDBYRUNUNIT | SHARING | SHORT_DATE | SYMBOL - | TASK | THREAD | THREAD_LOCAL | TIMER | TODAYS_DATE | TODAYS_NAME | TRUNCATED | TYPEDEF - | UNDERLINE - | VIRTUAL - | WAIT - | YEAR | YYYYMMDD | YYYYDDD - | ZERO_FILL - ; + : IDENTIFIER + | COBOL + | PROGRAM + | ABORT + | AS + | ASCII + | ASSOCIATED_DATA + | ASSOCIATED_DATA_LENGTH + | ATTRIBUTE + | AUTO + | AUTO_SKIP + | BACKGROUND_COLOR + | BACKGROUND_COLOUR + | BEEP + | BELL + | BINARY + | BIT + | BLINK + | BOUNDS + | CAPABLE + | CCSVERSION + | CHANGED + | CHANNEL + | CLOSE_DISPOSITION + | COMMITMENT + | CONTROL_POINT + | CONVENTION + | CRUNCH + | CURSOR + | DEFAULT + | DEFAULT_DISPLAY + | DEFINITION + | DFHRESP + | DFHVALUE + | DISK + | DONTCARE + | DOUBLE + | EBCDIC + | EMPTY_CHECK + | ENTER + | ENTRY_PROCEDURE + | EOL + | EOS + | ERASE + | ESCAPE + | EVENT + | EXCLUSIVE + | EXPORT + | EXTENDED + | FOREGROUND_COLOR + | FOREGROUND_COLOUR + | FULL + | FUNCTIONNAME + | FUNCTION_POINTER + | GRID + | HIGHLIGHT + | IMPLICIT + | IMPORT + | INTEGER + | KEPT + | KEYBOARD + | LANGUAGE + | LB + | LD + | LEFTLINE + | LENGTH_CHECK + | LIBACCESS + | LIBPARAMETER + | LIBRARY + | LIST + | LOCAL + | LONG_DATE + | LONG_TIME + | LOWER + | LOWLIGHT + | MMDDYYYY + | NAMED + | NATIONAL + | NATIONAL_EDITED + | NETWORK + | NO_ECHO + | NUMERIC_DATE + | NUMERIC_TIME + | ODT + | ORDERLY + | OVERLINE + | OWN + | PASSWORD + | PORT + | PRINTER + | PRIVATE + | PROCESS + | PROMPT + | READER + | REAL + | RECEIVED + | RECURSIVE + | REF + | REMOTE + | REMOVE + | REQUIRED + | REVERSE_VIDEO + | SAVE + | SECURE + | SHARED + | SHAREDBYALL + | SHAREDBYRUNUNIT + | SHARING + | SHORT_DATE + | SYMBOL + | TASK + | THREAD + | THREAD_LOCAL + | TIMER + | TODAYS_DATE + | TODAYS_NAME + | TRUNCATED + | TYPEDEF + | UNDERLINE + | VIRTUAL + | WAIT + | YEAR + | YYYYMMDD + | YYYYDDD + | ZERO_FILL + ; literal - : NONNUMERICLITERAL | figurativeConstant | numericLiteral | booleanLiteral | cicsDfhRespLiteral | cicsDfhValueLiteral - ; + : NONNUMERICLITERAL + | figurativeConstant + | numericLiteral + | booleanLiteral + | cicsDfhRespLiteral + | cicsDfhValueLiteral + ; booleanLiteral - : TRUE | FALSE - ; + : TRUE + | FALSE + ; numericLiteral - : NUMERICLITERAL | ZERO | integerLiteral - ; + : NUMERICLITERAL + | ZERO + | integerLiteral + ; integerLiteral - : INTEGERLITERAL | LEVEL_NUMBER_66 | LEVEL_NUMBER_77 | LEVEL_NUMBER_88 - ; + : INTEGERLITERAL + | LEVEL_NUMBER_66 + | LEVEL_NUMBER_77 + | LEVEL_NUMBER_88 + ; cicsDfhRespLiteral - : DFHRESP LPARENCHAR (cobolWord | literal) RPARENCHAR - ; + : DFHRESP LPARENCHAR (cobolWord | literal) RPARENCHAR + ; cicsDfhValueLiteral - : DFHVALUE LPARENCHAR (cobolWord | literal) RPARENCHAR - ; + : DFHVALUE LPARENCHAR (cobolWord | literal) RPARENCHAR + ; // keywords ---------------------------------- figurativeConstant - : ALL literal | HIGH_VALUE | HIGH_VALUES | LOW_VALUE | LOW_VALUES | NULL_ | NULLS | QUOTE | QUOTES | SPACE | SPACES | ZERO | ZEROS | ZEROES - ; + : ALL literal + | HIGH_VALUE + | HIGH_VALUES + | LOW_VALUE + | LOW_VALUES + | NULL_ + | NULLS + | QUOTE + | QUOTES + | SPACE + | SPACES + | ZERO + | ZEROS + | ZEROES + ; specialRegister - : ADDRESS OF identifier - | DATE | DAY | DAY_OF_WEEK | DEBUG_CONTENTS | DEBUG_ITEM | DEBUG_LINE | DEBUG_NAME | DEBUG_SUB_1 | DEBUG_SUB_2 | DEBUG_SUB_3 - | LENGTH OF? identifier | LINAGE_COUNTER | LINE_COUNTER - | PAGE_COUNTER - | RETURN_CODE - | SHIFT_IN | SHIFT_OUT | SORT_CONTROL | SORT_CORE_SIZE | SORT_FILE_SIZE | SORT_MESSAGE | SORT_MODE_SIZE | SORT_RETURN - | TALLY | TIME - | WHEN_COMPILED - ; + : ADDRESS OF identifier + | DATE + | DAY + | DAY_OF_WEEK + | DEBUG_CONTENTS + | DEBUG_ITEM + | DEBUG_LINE + | DEBUG_NAME + | DEBUG_SUB_1 + | DEBUG_SUB_2 + | DEBUG_SUB_3 + | LENGTH OF? identifier + | LINAGE_COUNTER + | LINE_COUNTER + | PAGE_COUNTER + | RETURN_CODE + | SHIFT_IN + | SHIFT_OUT + | SORT_CONTROL + | SORT_CORE_SIZE + | SORT_FILE_SIZE + | SORT_MESSAGE + | SORT_MODE_SIZE + | SORT_RETURN + | TALLY + | TIME + | WHEN_COMPILED + ; // comment entry commentEntry - : COMMENTENTRYLINE+ - ; + : COMMENTENTRYLINE+ + ; // lexer rules -------------------------------------------------------------------------------- // keywords -ABORT : A B O R T; -ACCEPT : A C C E P T; -ACCESS : A C C E S S; -ADD : A D D; -ADDRESS : A D D R E S S; -ADVANCING : A D V A N C I N G; -AFTER : A F T E R; -ALIGNED : A L I G N E D; -ALL : A L L; -ALPHABET : A L P H A B E T; -ALPHABETIC : A L P H A B E T I C; -ALPHABETIC_LOWER : A L P H A B E T I C MINUSCHAR L O W E R; -ALPHABETIC_UPPER : A L P H A B E T I C MINUSCHAR U P P E R; -ALPHANUMERIC : A L P H A N U M E R I C; -ALPHANUMERIC_EDITED : A L P H A N U M E R I C MINUSCHAR E D I T E D; -ALSO : A L S O; -ALTER : A L T E R; -ALTERNATE : A L T E R N A T E; -AND : A N D; -ANY : A N Y; -ARE : A R E; -AREA : A R E A; -AREAS : A R E A S; -AS : A S; -ASCENDING : A S C E N D I N G; -ASCII : A S C I I; -ASSIGN : A S S I G N; -ASSOCIATED_DATA : A S S O C I A T E D MINUSCHAR D A T A; -ASSOCIATED_DATA_LENGTH : A S S O C I A T E D MINUSCHAR D A T A MINUSCHAR L E N G T H; -AT : A T; -ATTRIBUTE : A T T R I B U T E; -AUTHOR : A U T H O R; -AUTO : A U T O; -AUTO_SKIP : A U T O MINUSCHAR S K I P; -BACKGROUND_COLOR : B A C K G R O U N D MINUSCHAR C O L O R; -BACKGROUND_COLOUR : B A C K G R O U N D MINUSCHAR C O L O U R; -BASIS : B A S I S; -BEEP : B E E P; -BEFORE : B E F O R E; -BEGINNING : B E G I N N I N G; -BELL : B E L L; -BINARY : B I N A R Y; -BIT : B I T; -BLANK : B L A N K; -BLINK : B L I N K; -BLOCK : B L O C K; -BOUNDS : B O U N D S; -BOTTOM : B O T T O M; -BY : B Y; -BYFUNCTION : B Y F U N C T I O N; -BYTITLE : B Y T I T L E; -CALL : C A L L; -CANCEL : C A N C E L; -CAPABLE : C A P A B L E; -CCSVERSION : C C S V E R S I O N; -CD : C D; -CF : C F; -CH : C H; -CHAINING : C H A I N I N G; -CHANGED : C H A N G E D; -CHANNEL : C H A N N E L; -CHARACTER : C H A R A C T E R; -CHARACTERS : C H A R A C T E R S; -CLASS : C L A S S; -CLASS_ID : C L A S S MINUSCHAR I D; -CLOCK_UNITS : C L O C K MINUSCHAR U N I T S; -CLOSE : C L O S E; -CLOSE_DISPOSITION : C L O S E MINUSCHAR D I S P O S I T I O N; -COBOL : C O B O L; -CODE : C O D E; -CODE_SET : C O D E MINUSCHAR S E T; -COLLATING : C O L L A T I N G; -COL : C O L; -COLUMN : C O L U M N; -COM_REG : C O M MINUSCHAR R E G; -COMMA : C O M M A; -COMMITMENT : C O M M I T M E N T; -COMMON : C O M M O N; -COMMUNICATION : C O M M U N I C A T I O N; -COMP : C O M P; -COMP_1 : C O M P MINUSCHAR '1'; -COMP_2 : C O M P MINUSCHAR '2'; -COMP_3 : C O M P MINUSCHAR '3'; -COMP_4 : C O M P MINUSCHAR '4'; -COMP_5 : C O M P MINUSCHAR '5'; -COMPUTATIONAL : C O M P U T A T I O N A L; -COMPUTATIONAL_1 : C O M P U T A T I O N A L MINUSCHAR '1'; -COMPUTATIONAL_2 : C O M P U T A T I O N A L MINUSCHAR '2'; -COMPUTATIONAL_3 : C O M P U T A T I O N A L MINUSCHAR '3'; -COMPUTATIONAL_4 : C O M P U T A T I O N A L MINUSCHAR '4'; -COMPUTATIONAL_5 : C O M P U T A T I O N A L MINUSCHAR '5'; -COMPUTE : C O M P U T E; -CONFIGURATION : C O N F I G U R A T I O N; -CONTAINS : C O N T A I N S; -CONTENT : C O N T E N T; -CONTINUE : C O N T I N U E; -CONTROL : C O N T R O L; -CONTROL_POINT : C O N T R O L MINUSCHAR P O I N T; -CONTROLS : C O N T R O L S; -CONVENTION : C O N V E N T I O N; -CONVERTING : C O N V E R T I N G; -COPY : C O P Y; -CORR : C O R R; -CORRESPONDING : C O R R E S P O N D I N G; -COUNT : C O U N T; -CRUNCH : C R U N C H; -CURRENCY : C U R R E N C Y; -CURSOR : C U R S O R; -DATA : D A T A; -DATA_BASE : D A T A MINUSCHAR B A S E; -DATE : D A T E; -DATE_COMPILED : D A T E MINUSCHAR C O M P I L E D; -DATE_WRITTEN : D A T E MINUSCHAR W R I T T E N; -DAY : D A Y; -DAY_OF_WEEK : D A Y MINUSCHAR O F MINUSCHAR W E E K; -DBCS : D B C S; -DE : D E; -DEBUG_CONTENTS : D E B U G MINUSCHAR C O N T E N T S; -DEBUG_ITEM : D E B U G MINUSCHAR I T E M; -DEBUG_LINE : D E B U G MINUSCHAR L I N E; -DEBUG_NAME : D E B U G MINUSCHAR N A M E; -DEBUG_SUB_1 : D E B U G MINUSCHAR S U B MINUSCHAR '1'; -DEBUG_SUB_2 : D E B U G MINUSCHAR S U B MINUSCHAR '2'; -DEBUG_SUB_3 : D E B U G MINUSCHAR S U B MINUSCHAR '3'; -DEBUGGING : D E B U G G I N G; -DECIMAL_POINT : D E C I M A L MINUSCHAR P O I N T; -DECLARATIVES : D E C L A R A T I V E S; -DEFAULT : D E F A U L T; -DEFAULT_DISPLAY : D E F A U L T MINUSCHAR D I S P L A Y; -DEFINITION : D E F I N I T I O N; -DELETE : D E L E T E; -DELIMITED : D E L I M I T E D; -DELIMITER : D E L I M I T E R; -DEPENDING : D E P E N D I N G; -DESCENDING : D E S C E N D I N G; -DESTINATION : D E S T I N A T I O N; -DETAIL : D E T A I L; -DFHRESP : D F H R E S P; -DFHVALUE : D F H V A L U E; -DISABLE : D I S A B L E; -DISK : D I S K; -DISPLAY : D I S P L A Y; -DISPLAY_1 : D I S P L A Y MINUSCHAR '1'; -DIVIDE : D I V I D E; -DIVISION : D I V I S I O N; -DONTCARE : D O N T C A R E; -DOUBLE : D O U B L E; -DOWN : D O W N; -DUPLICATES : D U P L I C A T E S; -DYNAMIC : D Y N A M I C; -EBCDIC : E B C D I C; -EGCS : E G C S; // E X T E N S I O N -EGI : E G I; -ELSE : E L S E; -EMI : E M I; -EMPTY_CHECK : E M P T Y MINUSCHAR C H E C K; -ENABLE : E N A B L E; -END : E N D; -END_ACCEPT : E N D MINUSCHAR A C C E P T; -END_ADD : E N D MINUSCHAR A D D; -END_CALL : E N D MINUSCHAR C A L L; -END_COMPUTE : E N D MINUSCHAR C O M P U T E; -END_DELETE : E N D MINUSCHAR D E L E T E; -END_DIVIDE : E N D MINUSCHAR D I V I D E; -END_EVALUATE : E N D MINUSCHAR E V A L U A T E; -END_IF : E N D MINUSCHAR I F; -END_MULTIPLY : E N D MINUSCHAR M U L T I P L Y; -END_OF_PAGE : E N D MINUSCHAR O F MINUSCHAR P A G E; -END_PERFORM : E N D MINUSCHAR P E R F O R M; -END_READ : E N D MINUSCHAR R E A D; -END_RECEIVE : E N D MINUSCHAR R E C E I V E; -END_RETURN : E N D MINUSCHAR R E T U R N; -END_REWRITE : E N D MINUSCHAR R E W R I T E; -END_SEARCH : E N D MINUSCHAR S E A R C H; -END_START : E N D MINUSCHAR S T A R T; -END_STRING : E N D MINUSCHAR S T R I N G; -END_SUBTRACT : E N D MINUSCHAR S U B T R A C T; -END_UNSTRING : E N D MINUSCHAR U N S T R I N G; -END_WRITE : E N D MINUSCHAR W R I T E; -ENDING : E N D I N F; -ENTER : E N T E R; -ENTRY : E N T R Y; -ENTRY_PROCEDURE : E N T R Y MINUSCHAR P R O C E D U R E; -ENVIRONMENT : E N V I R O N M E N T; -EOP : E O P; -EQUAL : E Q U A L; -ERASE : E R A S E; -ERROR : E R R O R; -EOL : E O L; -EOS : E O S; -ESCAPE : E S C A P E; -ESI : E S I; -EVALUATE : E V A L U A T E; -EVENT : E V E N T; -EVERY : E V E R Y; -EXCEPTION : E X C E P T I O N; -EXCLUSIVE : E X C L U S I V E; -EXHIBIT : E X H I B I T; -EXIT : E X I T; -EXPORT : E X P O R T; -EXTEND : E X T E N D; -EXTENDED : E X T E N D E D; -EXTERNAL : E X T E R N A L; -FALSE : F A L S E; -FD : F D; -FILE : F I L E; -FILE_CONTROL : F I L E MINUSCHAR C O N T R O L; -FILLER : F I L L E R; -FINAL : F I N A L; -FIRST : F I R S T; -FOOTING : F O O T I N G; -FOR : F O R; -FOREGROUND_COLOR : F O R E G R O U N D MINUSCHAR C O L O R; -FOREGROUND_COLOUR : F O R E G R O U N D MINUSCHAR C O L O U R; -FROM : F R O M; -FULL : F U L L; -FUNCTION : F U N C T I O N; -FUNCTIONNAME : F U N C T I O N N A M E; -FUNCTION_POINTER : F U N C T I O N MINUSCHAR P O I N T E R; -GENERATE : G E N E R A T E; -GOBACK : G O B A C K; -GIVING : G I V I N G; -GLOBAL : G L O B A L; -GO : G O; -GREATER : G R E A T E R; -GRID : G R I D; -GROUP : G R O U P; -HEADING : H E A D I N G; -HIGHLIGHT : H I G H L I G H T; -HIGH_VALUE : H I G H MINUSCHAR V A L U E; -HIGH_VALUES : H I G H MINUSCHAR V A L U E S; -I_O : I MINUSCHAR O; -I_O_CONTROL : I MINUSCHAR O MINUSCHAR C O N T R O L; -ID : I D; -IDENTIFICATION : I D E N T I F I C A T I O N; -IF : I F; -IMPLICIT : I M P L I C I T; -IMPORT : I M P O R T; -IN : I N; -INDEX : I N D E X; -INDEXED : I N D E X E D; -INDICATE : I N D I C A T E; -INITIAL : I N I T I A L; -INITIALIZE : I N I T I A L I Z E; -INITIATE : I N I T I A T E; -INPUT : I N P U T; -INPUT_OUTPUT : I N P U T MINUSCHAR O U T P U T; -INSPECT : I N S P E C T; -INSTALLATION : I N S T A L L A T I O N; -INTEGER : I N T E G E R; -INTO : I N T O; -INVALID : I N V A L I D; -INVOKE : I N V O K E; -IS : I S; -JUST : J U S T; -JUSTIFIED : J U S T I F I E D; -KANJI : K A N J I; -KEPT : K E P T; -KEY : K E Y; -KEYBOARD : K E Y B O A R D; -LABEL : L A B E L; -LANGUAGE : L A N G U A G E; -LAST : L A S T; -LB : L B; -LD : L D; -LEADING : L E A D I N G; -LEFT : L E F T; -LEFTLINE : L E F T L I N E; -LENGTH : L E N G T H; -LENGTH_CHECK : L E N G T H MINUSCHAR C H E C K; -LESS : L E S S; -LIBACCESS : L I B A C C E S S; -LIBPARAMETER : L I B P A R A M E T E R; -LIBRARY : L I B R A R Y; -LIMIT : L I M I T; -LIMITS : L I M I T S; -LINAGE : L I N A G E; -LINAGE_COUNTER : L I N A G E MINUSCHAR C O U N T E R; -LINE : L I N E; -LINES : L I N E S; -LINE_COUNTER : L I N E MINUSCHAR C O U N T E R; -LINKAGE : L I N K A G E; -LIST : L I S T; -LOCAL : L O C A L; -LOCAL_STORAGE : L O C A L MINUSCHAR S T O R A G E; -LOCK : L O C K; -LONG_DATE : L O N G MINUSCHAR D A T E; -LONG_TIME : L O N G MINUSCHAR T I M E; -LOWER : L O W E R; -LOWLIGHT : L O W L I G H T; -LOW_VALUE : L O W MINUSCHAR V A L U E; -LOW_VALUES : L O W MINUSCHAR V A L U E S; -MEMORY : M E M O R Y; -MERGE : M E R G E; -MESSAGE : M E S S A G E; -MMDDYYYY : M M D D Y Y Y Y; -MODE : M O D E; -MODULES : M O D U L E S; -MORE_LABELS : M O R E MINUSCHAR L A B E L S; -MOVE : M O V E; -MULTIPLE : M U L T I P L E; -MULTIPLY : M U L T I P L Y; -NAMED : N A M E D; -NATIONAL : N A T I O N A L; -NATIONAL_EDITED : N A T I O N A L MINUSCHAR E D I T E D; -NATIVE : N A T I V E; -NEGATIVE : N E G A T I V E; -NETWORK : N E T W O R K; -NEXT : N E X T; -NO : N O; -NO_ECHO : N O MINUSCHAR E C H O; -NOT : N O T; -NULL_ : N U L L; -NULLS : N U L L S; -NUMBER : N U M B E R; -NUMERIC : N U M E R I C; -NUMERIC_DATE : N U M E R I C MINUSCHAR D A T E; -NUMERIC_EDITED : N U M E R I C MINUSCHAR E D I T E D; -NUMERIC_TIME : N U M E R I C MINUSCHAR T I M E; -OBJECT_COMPUTER : O B J E C T MINUSCHAR C O M P U T E R; -OCCURS : O C C U R S; -ODT : O D T; -OF : O F; -OFF : O F F; -OMITTED : O M I T T E D; -ON : O N; -OPEN : O P E N; -OPTIONAL : O P T I O N A L; -OR : O R; -ORDER : O R D E R; -ORDERLY : O R D E R L Y; -ORGANIZATION : O R G A N I Z A T I O N; -OTHER : O T H E R; -OUTPUT : O U T P U T; -OVERFLOW : O V E R F L O W; -OVERLINE : O V E R L I N E; -OWN : O W N; -PACKED_DECIMAL : P A C K E D MINUSCHAR D E C I M A L; -PADDING : P A D D I N G; -PAGE : P A G E; -PAGE_COUNTER : P A G E MINUSCHAR C O U N T E R; -PASSWORD : P A S S W O R D; -PERFORM : P E R F O R M; -PF : P F; -PH : P H; -PIC : P I C; -PICTURE : P I C T U R E; -PLUS : P L U S; -POINTER : P O I N T E R; -POSITION : P O S I T I O N; -POSITIVE : P O S I T I V E; -PORT : P O R T; -PRINTER : P R I N T E R; -PRINTING : P R I N T I N G; -PRIVATE : P R I V A T E; -PROCEDURE : P R O C E D U R E; -PROCEDURE_POINTER : P R O C E D U R E MINUSCHAR P O I N T E R; -PROCEDURES : P R O C E D U R E S; -PROCEED : P R O C E E D; -PROCESS : P R O C E S S; -PROGRAM : P R O G R A M; -PROGRAM_ID : P R O G R A M MINUSCHAR I D; -PROGRAM_LIBRARY : P R O G R A M MINUSCHAR L I B R A R Y; -PROMPT : P R O M P T; -PURGE : P U R G E; -QUEUE : Q U E U E; -QUOTE : Q U O T E; -QUOTES : Q U O T E S; -RANDOM : R A N D O M; -READER : R E A D E R; -REMOTE : R E M O T E; -RD : R D; -REAL : R E A L; -READ : R E A D; -RECEIVE : R E C E I V E; -RECEIVED : R E C E I V E D; -RECORD : R E C O R D; -RECORDING : R E C O R D I N G; -RECORDS : R E C O R D S; -RECURSIVE : R E C U R S I V E; -REDEFINES : R E D E F I N E S; -REEL : R E E L; -REF : R E F; -REFERENCE : R E F E R E N C E; -REFERENCES : R E F E R E N C E S; -RELATIVE : R E L A T I V E; -RELEASE : R E L E A S E; -REMAINDER : R E M A I N D E R; -REMARKS : R E M A R K S; -REMOVAL : R E M O V A L; -REMOVE : R E M O V E; -RENAMES : R E N A M E S; -REPLACE : R E P L A C E; -REPLACING : R E P L A C I N G; -REPORT : R E P O R T; -REPORTING : R E P O R T I N G; -REPORTS : R E P O R T S; -REQUIRED : R E Q U I R E D; -RERUN : R E R U N; -RESERVE : R E S E R V E; -REVERSE_VIDEO : R E S E R V E MINUSCHAR V I D E O; -RESET : R E S E T; -RETURN : R E T U R N; -RETURN_CODE : R E T U R N MINUSCHAR C O D E; -RETURNING: R E T U R N I N G; -REVERSED : R E V E R S E D; -REWIND : R E W I N D; -REWRITE : R E W R I T E; -RF : R F; -RH : R H; -RIGHT : R I G H T; -ROUNDED : R O U N D E D; -RUN : R U N; -SAME : S A M E; -SAVE : S A V E; -SCREEN : S C R E E N; -SD : S D; -SEARCH : S E A R C H; -SECTION : S E C T I O N; -SECURE : S E C U R E; -SECURITY : S E C U R I T Y; -SEGMENT : S E G M E N T; -SEGMENT_LIMIT : S E G M E N T MINUSCHAR L I M I T; -SELECT : S E L E C T; -SEND : S E N D; -SENTENCE : S E N T E N C E; -SEPARATE : S E P A R A T E; -SEQUENCE : S E Q U E N C E; -SEQUENTIAL : S E Q U E N T I A L; -SET : S E T; -SHARED : S H A R E D; -SHAREDBYALL : S H A R E D B Y A L L; -SHAREDBYRUNUNIT : S H A R E D B Y R U N U N I T; -SHARING : S H A R I N G; -SHIFT_IN : S H I F T MINUSCHAR I N; -SHIFT_OUT : S H I F T MINUSCHAR O U T; -SHORT_DATE : S H O R T MINUSCHAR D A T E; -SIGN : S I G N; -SIZE : S I Z E; -SORT : S O R T; -SORT_CONTROL : S O R T MINUSCHAR C O N T R O L; -SORT_CORE_SIZE : S O R T MINUSCHAR C O R E MINUSCHAR S I Z E; -SORT_FILE_SIZE : S O R T MINUSCHAR F I L E MINUSCHAR S I Z E; -SORT_MERGE : S O R T MINUSCHAR M E R G E; -SORT_MESSAGE : S O R T MINUSCHAR M E S S A G E; -SORT_MODE_SIZE : S O R T MINUSCHAR M O D E MINUSCHAR S I Z E; -SORT_RETURN : S O R T MINUSCHAR R E T U R N; -SOURCE : S O U R C E; -SOURCE_COMPUTER : S O U R C E MINUSCHAR C O M P U T E R; -SPACE : S P A C E; -SPACES : S P A C E S; -SPECIAL_NAMES : S P E C I A L MINUSCHAR N A M E S; -STANDARD : S T A N D A R D; -STANDARD_1 : S T A N D A R D MINUSCHAR '1'; -STANDARD_2 : S T A N D A R D MINUSCHAR '2'; -START : S T A R T; -STATUS : S T A T U S; -STOP : S T O P; -STRING : S T R I N G; -SUB_QUEUE_1 : S U B MINUSCHAR Q U E U E MINUSCHAR '1'; -SUB_QUEUE_2 : S U B MINUSCHAR Q U E U E MINUSCHAR '2'; -SUB_QUEUE_3 : S U B MINUSCHAR Q U E U E MINUSCHAR '3'; -SUBTRACT : S U B T R A C T; -SUM : S U M; -SUPPRESS : S U P P R E S S; -SYMBOL : S Y M B O L; -SYMBOLIC : S Y M B O L I C; -SYNC : S Y N C; -SYNCHRONIZED : S Y N C H R O N I Z E D; -TABLE : T A B L E; -TALLY : T A L L Y; -TALLYING : T A L L Y I N G; -TASK : T A S K; -TAPE : T A P E; -TERMINAL : T E R M I N A L; -TERMINATE : T E R M I N A T E; -TEST : T E S T; -TEXT : T E X T; -THAN : T H A N; -THEN : T H E N; -THREAD : T H R E A D; -THREAD_LOCAL : T H R E A D MINUSCHAR L O C A L; -THROUGH : T H R O U G H; -THRU : T H R U; -TIME : T I M E; -TIMER : T I M E R; -TIMES : T I M E S; -TITLE : T I T L E; -TO : T O; -TODAYS_DATE : T O D A Y S MINUSCHAR D A T E; -TODAYS_NAME : T O D A Y S MINUSCHAR N A M E; -TOP : T O P; -TRAILING : T R A I L I N G; -TRUE : T R U E; -TRUNCATED : T R U N C A T E D; -TYPE : T Y P E; -TYPEDEF : T Y P E D E F; -UNDERLINE : U N D E R L I N E; -UNIT : U N I T; -UNSTRING : U N S T R I N G; -UNTIL : U N T I L; -UP : U P; -UPON : U P O N; -USAGE : U S A G E; -USE : U S E; -USING : U S I N G; -VALUE : V A L U E; -VALUES : V A L U E S; -VARYING : V A R Y I N G; -VIRTUAL : V I R T U A L; -WAIT : W A I T; -WHEN : W H E N; -WHEN_COMPILED : W H E N MINUSCHAR C O M P I L E D; -WITH : W I T H; -WORDS : W O R D S; -WORKING_STORAGE : W O R K I N G MINUSCHAR S T O R A G E; -WRITE : W R I T E; -YEAR : Y E A R; -YYYYMMDD : Y Y Y Y M M D D; -YYYYDDD : Y Y Y Y D D D; -ZERO : Z E R O; -ZERO_FILL : Z E R O MINUSCHAR F I L L; -ZEROS : Z E R O S; -ZEROES : Z E R O E S; +ABORT + : A B O R T + ; -// symbols -AMPCHAR : '&'; -ASTERISKCHAR : '*'; -DOUBLEASTERISKCHAR : '**'; -COLONCHAR : ':'; -COMMACHAR : ','; -COMMENTENTRYTAG : '*>CE'; -COMMENTTAG : '*>'; -DOLLARCHAR : '$'; -DOUBLEQUOTE : '"'; -// period full stop -DOT_FS : '.' ('\r' | '\n' | '\f' | '\t' | ' ')+ | '.' EOF; -DOT : '.'; -EQUALCHAR : '='; -EXECCICSTAG : '*>EXECCICS'; -EXECSQLTAG : '*>EXECSQL'; -EXECSQLIMSTAG : '*>EXECSQLIMS'; -LESSTHANCHAR : '<'; -LESSTHANOREQUAL : '<='; -LPARENCHAR : '('; -MINUSCHAR : '-'; -MORETHANCHAR : '>'; -MORETHANOREQUAL : '>='; -NOTEQUALCHAR : '<>'; -PLUSCHAR : '+'; -SINGLEQUOTE : '\''; -RPARENCHAR : ')'; -SLASHCHAR : '/'; +ACCEPT + : A C C E P T + ; -// literals -NONNUMERICLITERAL : STRINGLITERAL | DBCSLITERAL | HEXNUMBER | NULLTERMINATED; +ACCESS + : A C C E S S + ; -fragment HEXNUMBER : - X '"' [0-9A-F]+ '"' - | X '\'' [0-9A-F]+ '\'' -; +ADD + : A D D + ; -fragment NULLTERMINATED : - Z '"' (~["\n\r] | '""' | '\'')* '"' - | Z '\'' (~['\n\r] | '\'\'' | '"')* '\'' -; +ADDRESS + : A D D R E S S + ; -fragment STRINGLITERAL : - '"' (~["\n\r] | '""' | '\'')* '"' - | '\'' (~['\n\r] | '\'\'' | '"')* '\'' -; +ADVANCING + : A D V A N C I N G + ; -fragment DBCSLITERAL : - [GN] '"' (~["\n\r] | '""' | '\'')* '"' - | [GN] '\'' (~['\n\r] | '\'\'' | '"')* '\'' -; +AFTER + : A F T E R + ; -LEVEL_NUMBER_66 : '66'; -LEVEL_NUMBER_77 : '77'; -LEVEL_NUMBER_88 : '88'; +ALIGNED + : A L I G N E D + ; -INTEGERLITERAL : (PLUSCHAR | MINUSCHAR)? [0-9]+; +ALL + : A L L + ; -NUMERICLITERAL : (PLUSCHAR | MINUSCHAR)? [0-9]* (DOT | COMMACHAR) [0-9]+ (('e' | 'E') (PLUSCHAR | MINUSCHAR)? [0-9]+)?; +ALPHABET + : A L P H A B E T + ; -IDENTIFIER : [a-zA-Z0-9]+ ([-_]+ [a-zA-Z0-9]+)*; +ALPHABETIC + : A L P H A B E T I C + ; -// whitespace, line breaks, comments, ... -NEWLINE : '\r'? '\n' -> channel(HIDDEN); -EXECCICSLINE : EXECCICSTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}'); -EXECSQLIMSLINE : EXECSQLIMSTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}'); -EXECSQLLINE : EXECSQLTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}'); -COMMENTENTRYLINE : COMMENTENTRYTAG WS ~('\n' | '\r')*; -COMMENTLINE : COMMENTTAG WS ~('\n' | '\r')* -> channel(HIDDEN); -WS : [ \t\f;]+ -> channel(HIDDEN); -SEPARATOR : ', ' -> channel(HIDDEN); +ALPHABETIC_LOWER + : A L P H A B E T I C MINUSCHAR L O W E R + ; -// case insensitive chars -fragment A:('a'|'A'); -fragment B:('b'|'B'); -fragment C:('c'|'C'); -fragment D:('d'|'D'); -fragment E:('e'|'E'); -fragment F:('f'|'F'); -fragment G:('g'|'G'); -fragment H:('h'|'H'); -fragment I:('i'|'I'); -fragment J:('j'|'J'); -fragment K:('k'|'K'); -fragment L:('l'|'L'); -fragment M:('m'|'M'); -fragment N:('n'|'N'); -fragment O:('o'|'O'); -fragment P:('p'|'P'); -fragment Q:('q'|'Q'); -fragment R:('r'|'R'); -fragment S:('s'|'S'); -fragment T:('t'|'T'); -fragment U:('u'|'U'); -fragment V:('v'|'V'); -fragment W:('w'|'W'); -fragment X:('x'|'X'); -fragment Y:('y'|'Y'); -fragment Z:('z'|'Z'); +ALPHABETIC_UPPER + : A L P H A B E T I C MINUSCHAR U P P E R + ; + +ALPHANUMERIC + : A L P H A N U M E R I C + ; + +ALPHANUMERIC_EDITED + : A L P H A N U M E R I C MINUSCHAR E D I T E D + ; + +ALSO + : A L S O + ; + +ALTER + : A L T E R + ; + +ALTERNATE + : A L T E R N A T E + ; + +AND + : A N D + ; + +ANY + : A N Y + ; + +ARE + : A R E + ; + +AREA + : A R E A + ; + +AREAS + : A R E A S + ; + +AS + : A S + ; + +ASCENDING + : A S C E N D I N G + ; + +ASCII + : A S C I I + ; + +ASSIGN + : A S S I G N + ; + +ASSOCIATED_DATA + : A S S O C I A T E D MINUSCHAR D A T A + ; + +ASSOCIATED_DATA_LENGTH + : A S S O C I A T E D MINUSCHAR D A T A MINUSCHAR L E N G T H + ; + +AT + : A T + ; + +ATTRIBUTE + : A T T R I B U T E + ; + +AUTHOR + : A U T H O R + ; + +AUTO + : A U T O + ; + +AUTO_SKIP + : A U T O MINUSCHAR S K I P + ; + +BACKGROUND_COLOR + : B A C K G R O U N D MINUSCHAR C O L O R + ; + +BACKGROUND_COLOUR + : B A C K G R O U N D MINUSCHAR C O L O U R + ; + +BASIS + : B A S I S + ; + +BEEP + : B E E P + ; + +BEFORE + : B E F O R E + ; + +BEGINNING + : B E G I N N I N G + ; + +BELL + : B E L L + ; + +BINARY + : B I N A R Y + ; + +BIT + : B I T + ; + +BLANK + : B L A N K + ; + +BLINK + : B L I N K + ; + +BLOCK + : B L O C K + ; + +BOUNDS + : B O U N D S + ; + +BOTTOM + : B O T T O M + ; + +BY + : B Y + ; + +BYFUNCTION + : B Y F U N C T I O N + ; + +BYTITLE + : B Y T I T L E + ; + +CALL + : C A L L + ; + +CANCEL + : C A N C E L + ; + +CAPABLE + : C A P A B L E + ; + +CCSVERSION + : C C S V E R S I O N + ; + +CD + : C D + ; + +CF + : C F + ; + +CH + : C H + ; + +CHAINING + : C H A I N I N G + ; + +CHANGED + : C H A N G E D + ; + +CHANNEL + : C H A N N E L + ; + +CHARACTER + : C H A R A C T E R + ; + +CHARACTERS + : C H A R A C T E R S + ; + +CLASS + : C L A S S + ; + +CLASS_ID + : C L A S S MINUSCHAR I D + ; + +CLOCK_UNITS + : C L O C K MINUSCHAR U N I T S + ; + +CLOSE + : C L O S E + ; + +CLOSE_DISPOSITION + : C L O S E MINUSCHAR D I S P O S I T I O N + ; + +COBOL + : C O B O L + ; + +CODE + : C O D E + ; + +CODE_SET + : C O D E MINUSCHAR S E T + ; + +COLLATING + : C O L L A T I N G + ; + +COL + : C O L + ; + +COLUMN + : C O L U M N + ; + +COM_REG + : C O M MINUSCHAR R E G + ; + +COMMA + : C O M M A + ; + +COMMITMENT + : C O M M I T M E N T + ; + +COMMON + : C O M M O N + ; + +COMMUNICATION + : C O M M U N I C A T I O N + ; + +COMP + : C O M P + ; + +COMP_1 + : C O M P MINUSCHAR '1' + ; + +COMP_2 + : C O M P MINUSCHAR '2' + ; + +COMP_3 + : C O M P MINUSCHAR '3' + ; + +COMP_4 + : C O M P MINUSCHAR '4' + ; + +COMP_5 + : C O M P MINUSCHAR '5' + ; + +COMPUTATIONAL + : C O M P U T A T I O N A L + ; + +COMPUTATIONAL_1 + : C O M P U T A T I O N A L MINUSCHAR '1' + ; + +COMPUTATIONAL_2 + : C O M P U T A T I O N A L MINUSCHAR '2' + ; + +COMPUTATIONAL_3 + : C O M P U T A T I O N A L MINUSCHAR '3' + ; + +COMPUTATIONAL_4 + : C O M P U T A T I O N A L MINUSCHAR '4' + ; + +COMPUTATIONAL_5 + : C O M P U T A T I O N A L MINUSCHAR '5' + ; + +COMPUTE + : C O M P U T E + ; + +CONFIGURATION + : C O N F I G U R A T I O N + ; + +CONTAINS + : C O N T A I N S + ; + +CONTENT + : C O N T E N T + ; + +CONTINUE + : C O N T I N U E + ; + +CONTROL + : C O N T R O L + ; + +CONTROL_POINT + : C O N T R O L MINUSCHAR P O I N T + ; + +CONTROLS + : C O N T R O L S + ; + +CONVENTION + : C O N V E N T I O N + ; + +CONVERTING + : C O N V E R T I N G + ; + +COPY + : C O P Y + ; + +CORR + : C O R R + ; + +CORRESPONDING + : C O R R E S P O N D I N G + ; + +COUNT + : C O U N T + ; + +CRUNCH + : C R U N C H + ; + +CURRENCY + : C U R R E N C Y + ; + +CURSOR + : C U R S O R + ; + +DATA + : D A T A + ; + +DATA_BASE + : D A T A MINUSCHAR B A S E + ; + +DATE + : D A T E + ; + +DATE_COMPILED + : D A T E MINUSCHAR C O M P I L E D + ; + +DATE_WRITTEN + : D A T E MINUSCHAR W R I T T E N + ; + +DAY + : D A Y + ; + +DAY_OF_WEEK + : D A Y MINUSCHAR O F MINUSCHAR W E E K + ; + +DBCS + : D B C S + ; + +DE + : D E + ; + +DEBUG_CONTENTS + : D E B U G MINUSCHAR C O N T E N T S + ; + +DEBUG_ITEM + : D E B U G MINUSCHAR I T E M + ; + +DEBUG_LINE + : D E B U G MINUSCHAR L I N E + ; + +DEBUG_NAME + : D E B U G MINUSCHAR N A M E + ; + +DEBUG_SUB_1 + : D E B U G MINUSCHAR S U B MINUSCHAR '1' + ; + +DEBUG_SUB_2 + : D E B U G MINUSCHAR S U B MINUSCHAR '2' + ; + +DEBUG_SUB_3 + : D E B U G MINUSCHAR S U B MINUSCHAR '3' + ; + +DEBUGGING + : D E B U G G I N G + ; + +DECIMAL_POINT + : D E C I M A L MINUSCHAR P O I N T + ; + +DECLARATIVES + : D E C L A R A T I V E S + ; + +DEFAULT + : D E F A U L T + ; + +DEFAULT_DISPLAY + : D E F A U L T MINUSCHAR D I S P L A Y + ; + +DEFINITION + : D E F I N I T I O N + ; + +DELETE + : D E L E T E + ; + +DELIMITED + : D E L I M I T E D + ; + +DELIMITER + : D E L I M I T E R + ; + +DEPENDING + : D E P E N D I N G + ; + +DESCENDING + : D E S C E N D I N G + ; + +DESTINATION + : D E S T I N A T I O N + ; + +DETAIL + : D E T A I L + ; + +DFHRESP + : D F H R E S P + ; + +DFHVALUE + : D F H V A L U E + ; + +DISABLE + : D I S A B L E + ; + +DISK + : D I S K + ; + +DISPLAY + : D I S P L A Y + ; + +DISPLAY_1 + : D I S P L A Y MINUSCHAR '1' + ; + +DIVIDE + : D I V I D E + ; + +DIVISION + : D I V I S I O N + ; + +DONTCARE + : D O N T C A R E + ; + +DOUBLE + : D O U B L E + ; + +DOWN + : D O W N + ; + +DUPLICATES + : D U P L I C A T E S + ; + +DYNAMIC + : D Y N A M I C + ; + +EBCDIC + : E B C D I C + ; + +EGCS + : E G C S + ; // E X T E N S I O N + +EGI + : E G I + ; + +ELSE + : E L S E + ; + +EMI + : E M I + ; + +EMPTY_CHECK + : E M P T Y MINUSCHAR C H E C K + ; + +ENABLE + : E N A B L E + ; + +END + : E N D + ; + +END_ACCEPT + : E N D MINUSCHAR A C C E P T + ; + +END_ADD + : E N D MINUSCHAR A D D + ; + +END_CALL + : E N D MINUSCHAR C A L L + ; + +END_COMPUTE + : E N D MINUSCHAR C O M P U T E + ; + +END_DELETE + : E N D MINUSCHAR D E L E T E + ; + +END_DIVIDE + : E N D MINUSCHAR D I V I D E + ; + +END_EVALUATE + : E N D MINUSCHAR E V A L U A T E + ; + +END_IF + : E N D MINUSCHAR I F + ; + +END_MULTIPLY + : E N D MINUSCHAR M U L T I P L Y + ; + +END_OF_PAGE + : E N D MINUSCHAR O F MINUSCHAR P A G E + ; + +END_PERFORM + : E N D MINUSCHAR P E R F O R M + ; + +END_READ + : E N D MINUSCHAR R E A D + ; + +END_RECEIVE + : E N D MINUSCHAR R E C E I V E + ; + +END_RETURN + : E N D MINUSCHAR R E T U R N + ; + +END_REWRITE + : E N D MINUSCHAR R E W R I T E + ; + +END_SEARCH + : E N D MINUSCHAR S E A R C H + ; + +END_START + : E N D MINUSCHAR S T A R T + ; + +END_STRING + : E N D MINUSCHAR S T R I N G + ; + +END_SUBTRACT + : E N D MINUSCHAR S U B T R A C T + ; + +END_UNSTRING + : E N D MINUSCHAR U N S T R I N G + ; + +END_WRITE + : E N D MINUSCHAR W R I T E + ; + +ENDING + : E N D I N F + ; + +ENTER + : E N T E R + ; + +ENTRY + : E N T R Y + ; + +ENTRY_PROCEDURE + : E N T R Y MINUSCHAR P R O C E D U R E + ; + +ENVIRONMENT + : E N V I R O N M E N T + ; + +EOP + : E O P + ; + +EQUAL + : E Q U A L + ; + +ERASE + : E R A S E + ; + +ERROR + : E R R O R + ; + +EOL + : E O L + ; + +EOS + : E O S + ; + +ESCAPE + : E S C A P E + ; + +ESI + : E S I + ; + +EVALUATE + : E V A L U A T E + ; + +EVENT + : E V E N T + ; + +EVERY + : E V E R Y + ; + +EXCEPTION + : E X C E P T I O N + ; + +EXCLUSIVE + : E X C L U S I V E + ; + +EXHIBIT + : E X H I B I T + ; + +EXIT + : E X I T + ; + +EXPORT + : E X P O R T + ; + +EXTEND + : E X T E N D + ; + +EXTENDED + : E X T E N D E D + ; + +EXTERNAL + : E X T E R N A L + ; + +FALSE + : F A L S E + ; + +FD + : F D + ; + +FILE + : F I L E + ; + +FILE_CONTROL + : F I L E MINUSCHAR C O N T R O L + ; + +FILLER + : F I L L E R + ; + +FINAL + : F I N A L + ; + +FIRST + : F I R S T + ; + +FOOTING + : F O O T I N G + ; + +FOR + : F O R + ; + +FOREGROUND_COLOR + : F O R E G R O U N D MINUSCHAR C O L O R + ; + +FOREGROUND_COLOUR + : F O R E G R O U N D MINUSCHAR C O L O U R + ; + +FROM + : F R O M + ; + +FULL + : F U L L + ; + +FUNCTION + : F U N C T I O N + ; + +FUNCTIONNAME + : F U N C T I O N N A M E + ; + +FUNCTION_POINTER + : F U N C T I O N MINUSCHAR P O I N T E R + ; + +GENERATE + : G E N E R A T E + ; + +GOBACK + : G O B A C K + ; + +GIVING + : G I V I N G + ; + +GLOBAL + : G L O B A L + ; + +GO + : G O + ; + +GREATER + : G R E A T E R + ; + +GRID + : G R I D + ; + +GROUP + : G R O U P + ; + +HEADING + : H E A D I N G + ; + +HIGHLIGHT + : H I G H L I G H T + ; + +HIGH_VALUE + : H I G H MINUSCHAR V A L U E + ; + +HIGH_VALUES + : H I G H MINUSCHAR V A L U E S + ; + +I_O + : I MINUSCHAR O + ; + +I_O_CONTROL + : I MINUSCHAR O MINUSCHAR C O N T R O L + ; + +ID + : I D + ; + +IDENTIFICATION + : I D E N T I F I C A T I O N + ; + +IF + : I F + ; + +IMPLICIT + : I M P L I C I T + ; + +IMPORT + : I M P O R T + ; + +IN + : I N + ; + +INDEX + : I N D E X + ; + +INDEXED + : I N D E X E D + ; + +INDICATE + : I N D I C A T E + ; + +INITIAL + : I N I T I A L + ; + +INITIALIZE + : I N I T I A L I Z E + ; + +INITIATE + : I N I T I A T E + ; + +INPUT + : I N P U T + ; + +INPUT_OUTPUT + : I N P U T MINUSCHAR O U T P U T + ; + +INSPECT + : I N S P E C T + ; + +INSTALLATION + : I N S T A L L A T I O N + ; + +INTEGER + : I N T E G E R + ; + +INTO + : I N T O + ; + +INVALID + : I N V A L I D + ; + +INVOKE + : I N V O K E + ; + +IS + : I S + ; + +JUST + : J U S T + ; + +JUSTIFIED + : J U S T I F I E D + ; + +KANJI + : K A N J I + ; + +KEPT + : K E P T + ; + +KEY + : K E Y + ; + +KEYBOARD + : K E Y B O A R D + ; + +LABEL + : L A B E L + ; + +LANGUAGE + : L A N G U A G E + ; + +LAST + : L A S T + ; + +LB + : L B + ; + +LD + : L D + ; + +LEADING + : L E A D I N G + ; + +LEFT + : L E F T + ; + +LEFTLINE + : L E F T L I N E + ; + +LENGTH + : L E N G T H + ; + +LENGTH_CHECK + : L E N G T H MINUSCHAR C H E C K + ; + +LESS + : L E S S + ; + +LIBACCESS + : L I B A C C E S S + ; + +LIBPARAMETER + : L I B P A R A M E T E R + ; + +LIBRARY + : L I B R A R Y + ; + +LIMIT + : L I M I T + ; + +LIMITS + : L I M I T S + ; + +LINAGE + : L I N A G E + ; + +LINAGE_COUNTER + : L I N A G E MINUSCHAR C O U N T E R + ; + +LINE + : L I N E + ; + +LINES + : L I N E S + ; + +LINE_COUNTER + : L I N E MINUSCHAR C O U N T E R + ; + +LINKAGE + : L I N K A G E + ; + +LIST + : L I S T + ; + +LOCAL + : L O C A L + ; + +LOCAL_STORAGE + : L O C A L MINUSCHAR S T O R A G E + ; + +LOCK + : L O C K + ; + +LONG_DATE + : L O N G MINUSCHAR D A T E + ; + +LONG_TIME + : L O N G MINUSCHAR T I M E + ; + +LOWER + : L O W E R + ; + +LOWLIGHT + : L O W L I G H T + ; + +LOW_VALUE + : L O W MINUSCHAR V A L U E + ; + +LOW_VALUES + : L O W MINUSCHAR V A L U E S + ; + +MEMORY + : M E M O R Y + ; + +MERGE + : M E R G E + ; + +MESSAGE + : M E S S A G E + ; + +MMDDYYYY + : M M D D Y Y Y Y + ; + +MODE + : M O D E + ; + +MODULES + : M O D U L E S + ; + +MORE_LABELS + : M O R E MINUSCHAR L A B E L S + ; + +MOVE + : M O V E + ; + +MULTIPLE + : M U L T I P L E + ; + +MULTIPLY + : M U L T I P L Y + ; + +NAMED + : N A M E D + ; + +NATIONAL + : N A T I O N A L + ; + +NATIONAL_EDITED + : N A T I O N A L MINUSCHAR E D I T E D + ; + +NATIVE + : N A T I V E + ; + +NEGATIVE + : N E G A T I V E + ; + +NETWORK + : N E T W O R K + ; + +NEXT + : N E X T + ; + +NO + : N O + ; + +NO_ECHO + : N O MINUSCHAR E C H O + ; + +NOT + : N O T + ; + +NULL_ + : N U L L + ; + +NULLS + : N U L L S + ; + +NUMBER + : N U M B E R + ; + +NUMERIC + : N U M E R I C + ; + +NUMERIC_DATE + : N U M E R I C MINUSCHAR D A T E + ; + +NUMERIC_EDITED + : N U M E R I C MINUSCHAR E D I T E D + ; + +NUMERIC_TIME + : N U M E R I C MINUSCHAR T I M E + ; + +OBJECT_COMPUTER + : O B J E C T MINUSCHAR C O M P U T E R + ; + +OCCURS + : O C C U R S + ; + +ODT + : O D T + ; + +OF + : O F + ; + +OFF + : O F F + ; + +OMITTED + : O M I T T E D + ; + +ON + : O N + ; + +OPEN + : O P E N + ; + +OPTIONAL + : O P T I O N A L + ; + +OR + : O R + ; + +ORDER + : O R D E R + ; + +ORDERLY + : O R D E R L Y + ; + +ORGANIZATION + : O R G A N I Z A T I O N + ; + +OTHER + : O T H E R + ; + +OUTPUT + : O U T P U T + ; + +OVERFLOW + : O V E R F L O W + ; + +OVERLINE + : O V E R L I N E + ; + +OWN + : O W N + ; + +PACKED_DECIMAL + : P A C K E D MINUSCHAR D E C I M A L + ; + +PADDING + : P A D D I N G + ; + +PAGE + : P A G E + ; + +PAGE_COUNTER + : P A G E MINUSCHAR C O U N T E R + ; + +PASSWORD + : P A S S W O R D + ; + +PERFORM + : P E R F O R M + ; + +PF + : P F + ; + +PH + : P H + ; + +PIC + : P I C + ; + +PICTURE + : P I C T U R E + ; + +PLUS + : P L U S + ; + +POINTER + : P O I N T E R + ; + +POSITION + : P O S I T I O N + ; + +POSITIVE + : P O S I T I V E + ; + +PORT + : P O R T + ; + +PRINTER + : P R I N T E R + ; + +PRINTING + : P R I N T I N G + ; + +PRIVATE + : P R I V A T E + ; + +PROCEDURE + : P R O C E D U R E + ; + +PROCEDURE_POINTER + : P R O C E D U R E MINUSCHAR P O I N T E R + ; + +PROCEDURES + : P R O C E D U R E S + ; + +PROCEED + : P R O C E E D + ; + +PROCESS + : P R O C E S S + ; + +PROGRAM + : P R O G R A M + ; + +PROGRAM_ID + : P R O G R A M MINUSCHAR I D + ; + +PROGRAM_LIBRARY + : P R O G R A M MINUSCHAR L I B R A R Y + ; + +PROMPT + : P R O M P T + ; + +PURGE + : P U R G E + ; + +QUEUE + : Q U E U E + ; + +QUOTE + : Q U O T E + ; + +QUOTES + : Q U O T E S + ; + +RANDOM + : R A N D O M + ; + +READER + : R E A D E R + ; + +REMOTE + : R E M O T E + ; + +RD + : R D + ; + +REAL + : R E A L + ; + +READ + : R E A D + ; + +RECEIVE + : R E C E I V E + ; + +RECEIVED + : R E C E I V E D + ; + +RECORD + : R E C O R D + ; + +RECORDING + : R E C O R D I N G + ; + +RECORDS + : R E C O R D S + ; + +RECURSIVE + : R E C U R S I V E + ; + +REDEFINES + : R E D E F I N E S + ; + +REEL + : R E E L + ; + +REF + : R E F + ; + +REFERENCE + : R E F E R E N C E + ; + +REFERENCES + : R E F E R E N C E S + ; + +RELATIVE + : R E L A T I V E + ; + +RELEASE + : R E L E A S E + ; + +REMAINDER + : R E M A I N D E R + ; + +REMARKS + : R E M A R K S + ; + +REMOVAL + : R E M O V A L + ; + +REMOVE + : R E M O V E + ; + +RENAMES + : R E N A M E S + ; + +REPLACE + : R E P L A C E + ; + +REPLACING + : R E P L A C I N G + ; + +REPORT + : R E P O R T + ; + +REPORTING + : R E P O R T I N G + ; + +REPORTS + : R E P O R T S + ; + +REQUIRED + : R E Q U I R E D + ; + +RERUN + : R E R U N + ; + +RESERVE + : R E S E R V E + ; + +REVERSE_VIDEO + : R E S E R V E MINUSCHAR V I D E O + ; + +RESET + : R E S E T + ; + +RETURN + : R E T U R N + ; + +RETURN_CODE + : R E T U R N MINUSCHAR C O D E + ; + +RETURNING + : R E T U R N I N G + ; + +REVERSED + : R E V E R S E D + ; + +REWIND + : R E W I N D + ; + +REWRITE + : R E W R I T E + ; + +RF + : R F + ; + +RH + : R H + ; + +RIGHT + : R I G H T + ; + +ROUNDED + : R O U N D E D + ; + +RUN + : R U N + ; + +SAME + : S A M E + ; + +SAVE + : S A V E + ; + +SCREEN + : S C R E E N + ; + +SD + : S D + ; + +SEARCH + : S E A R C H + ; + +SECTION + : S E C T I O N + ; + +SECURE + : S E C U R E + ; + +SECURITY + : S E C U R I T Y + ; + +SEGMENT + : S E G M E N T + ; + +SEGMENT_LIMIT + : S E G M E N T MINUSCHAR L I M I T + ; + +SELECT + : S E L E C T + ; + +SEND + : S E N D + ; + +SENTENCE + : S E N T E N C E + ; + +SEPARATE + : S E P A R A T E + ; + +SEQUENCE + : S E Q U E N C E + ; + +SEQUENTIAL + : S E Q U E N T I A L + ; + +SET + : S E T + ; + +SHARED + : S H A R E D + ; + +SHAREDBYALL + : S H A R E D B Y A L L + ; + +SHAREDBYRUNUNIT + : S H A R E D B Y R U N U N I T + ; + +SHARING + : S H A R I N G + ; + +SHIFT_IN + : S H I F T MINUSCHAR I N + ; + +SHIFT_OUT + : S H I F T MINUSCHAR O U T + ; + +SHORT_DATE + : S H O R T MINUSCHAR D A T E + ; + +SIGN + : S I G N + ; + +SIZE + : S I Z E + ; + +SORT + : S O R T + ; + +SORT_CONTROL + : S O R T MINUSCHAR C O N T R O L + ; + +SORT_CORE_SIZE + : S O R T MINUSCHAR C O R E MINUSCHAR S I Z E + ; + +SORT_FILE_SIZE + : S O R T MINUSCHAR F I L E MINUSCHAR S I Z E + ; + +SORT_MERGE + : S O R T MINUSCHAR M E R G E + ; + +SORT_MESSAGE + : S O R T MINUSCHAR M E S S A G E + ; + +SORT_MODE_SIZE + : S O R T MINUSCHAR M O D E MINUSCHAR S I Z E + ; + +SORT_RETURN + : S O R T MINUSCHAR R E T U R N + ; + +SOURCE + : S O U R C E + ; + +SOURCE_COMPUTER + : S O U R C E MINUSCHAR C O M P U T E R + ; + +SPACE + : S P A C E + ; + +SPACES + : S P A C E S + ; + +SPECIAL_NAMES + : S P E C I A L MINUSCHAR N A M E S + ; + +STANDARD + : S T A N D A R D + ; + +STANDARD_1 + : S T A N D A R D MINUSCHAR '1' + ; + +STANDARD_2 + : S T A N D A R D MINUSCHAR '2' + ; + +START + : S T A R T + ; + +STATUS + : S T A T U S + ; + +STOP + : S T O P + ; + +STRING + : S T R I N G + ; + +SUB_QUEUE_1 + : S U B MINUSCHAR Q U E U E MINUSCHAR '1' + ; + +SUB_QUEUE_2 + : S U B MINUSCHAR Q U E U E MINUSCHAR '2' + ; + +SUB_QUEUE_3 + : S U B MINUSCHAR Q U E U E MINUSCHAR '3' + ; + +SUBTRACT + : S U B T R A C T + ; + +SUM + : S U M + ; + +SUPPRESS + : S U P P R E S S + ; + +SYMBOL + : S Y M B O L + ; + +SYMBOLIC + : S Y M B O L I C + ; + +SYNC + : S Y N C + ; + +SYNCHRONIZED + : S Y N C H R O N I Z E D + ; + +TABLE + : T A B L E + ; + +TALLY + : T A L L Y + ; + +TALLYING + : T A L L Y I N G + ; + +TASK + : T A S K + ; + +TAPE + : T A P E + ; + +TERMINAL + : T E R M I N A L + ; + +TERMINATE + : T E R M I N A T E + ; + +TEST + : T E S T + ; + +TEXT + : T E X T + ; + +THAN + : T H A N + ; + +THEN + : T H E N + ; + +THREAD + : T H R E A D + ; + +THREAD_LOCAL + : T H R E A D MINUSCHAR L O C A L + ; + +THROUGH + : T H R O U G H + ; + +THRU + : T H R U + ; + +TIME + : T I M E + ; + +TIMER + : T I M E R + ; + +TIMES + : T I M E S + ; + +TITLE + : T I T L E + ; + +TO + : T O + ; + +TODAYS_DATE + : T O D A Y S MINUSCHAR D A T E + ; + +TODAYS_NAME + : T O D A Y S MINUSCHAR N A M E + ; + +TOP + : T O P + ; + +TRAILING + : T R A I L I N G + ; + +TRUE + : T R U E + ; + +TRUNCATED + : T R U N C A T E D + ; + +TYPE + : T Y P E + ; + +TYPEDEF + : T Y P E D E F + ; + +UNDERLINE + : U N D E R L I N E + ; + +UNIT + : U N I T + ; + +UNSTRING + : U N S T R I N G + ; + +UNTIL + : U N T I L + ; + +UP + : U P + ; + +UPON + : U P O N + ; + +USAGE + : U S A G E + ; + +USE + : U S E + ; + +USING + : U S I N G + ; + +VALUE + : V A L U E + ; + +VALUES + : V A L U E S + ; + +VARYING + : V A R Y I N G + ; + +VIRTUAL + : V I R T U A L + ; + +WAIT + : W A I T + ; + +WHEN + : W H E N + ; + +WHEN_COMPILED + : W H E N MINUSCHAR C O M P I L E D + ; + +WITH + : W I T H + ; + +WORDS + : W O R D S + ; + +WORKING_STORAGE + : W O R K I N G MINUSCHAR S T O R A G E + ; + +WRITE + : W R I T E + ; + +YEAR + : Y E A R + ; + +YYYYMMDD + : Y Y Y Y M M D D + ; + +YYYYDDD + : Y Y Y Y D D D + ; + +ZERO + : Z E R O + ; + +ZERO_FILL + : Z E R O MINUSCHAR F I L L + ; + +ZEROS + : Z E R O S + ; + +ZEROES + : Z E R O E S + ; + +// symbols +AMPCHAR + : '&' + ; + +ASTERISKCHAR + : '*' + ; + +DOUBLEASTERISKCHAR + : '**' + ; + +COLONCHAR + : ':' + ; + +COMMACHAR + : ',' + ; + +COMMENTENTRYTAG + : '*>CE' + ; + +COMMENTTAG + : '*>' + ; + +DOLLARCHAR + : '$' + ; + +DOUBLEQUOTE + : '"' + ; + +// period full stop +DOT_FS + : '.' ('\r' | '\n' | '\f' | '\t' | ' ')+ + | '.' EOF + ; + +DOT + : '.' + ; + +EQUALCHAR + : '=' + ; + +EXECCICSTAG + : '*>EXECCICS' + ; + +EXECSQLTAG + : '*>EXECSQL' + ; + +EXECSQLIMSTAG + : '*>EXECSQLIMS' + ; + +LESSTHANCHAR + : '<' + ; + +LESSTHANOREQUAL + : '<=' + ; + +LPARENCHAR + : '(' + ; + +MINUSCHAR + : '-' + ; + +MORETHANCHAR + : '>' + ; + +MORETHANOREQUAL + : '>=' + ; + +NOTEQUALCHAR + : '<>' + ; + +PLUSCHAR + : '+' + ; + +SINGLEQUOTE + : '\'' + ; + +RPARENCHAR + : ')' + ; + +SLASHCHAR + : '/' + ; + +// literals +NONNUMERICLITERAL + : STRINGLITERAL + | DBCSLITERAL + | HEXNUMBER + | NULLTERMINATED + ; + +fragment HEXNUMBER + : X '"' [0-9A-F]+ '"' + | X '\'' [0-9A-F]+ '\'' + ; + +fragment NULLTERMINATED + : Z '"' (~["\n\r] | '""' | '\'')* '"' + | Z '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; + +fragment STRINGLITERAL + : '"' (~["\n\r] | '""' | '\'')* '"' + | '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; + +fragment DBCSLITERAL + : [GN] '"' (~["\n\r] | '""' | '\'')* '"' + | [GN] '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; + +LEVEL_NUMBER_66 + : '66' + ; + +LEVEL_NUMBER_77 + : '77' + ; + +LEVEL_NUMBER_88 + : '88' + ; + +INTEGERLITERAL + : (PLUSCHAR | MINUSCHAR)? [0-9]+ + ; + +NUMERICLITERAL + : (PLUSCHAR | MINUSCHAR)? [0-9]* (DOT | COMMACHAR) [0-9]+ ( + ('e' | 'E') (PLUSCHAR | MINUSCHAR)? [0-9]+ + )? + ; + +IDENTIFIER + : [a-zA-Z0-9]+ ([-_]+ [a-zA-Z0-9]+)* + ; + +// whitespace, line breaks, comments, ... +NEWLINE + : '\r'? '\n' -> channel(HIDDEN) + ; + +EXECCICSLINE + : EXECCICSTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}') + ; + +EXECSQLIMSLINE + : EXECSQLIMSTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}') + ; + +EXECSQLLINE + : EXECSQLTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}') + ; + +COMMENTENTRYLINE + : COMMENTENTRYTAG WS ~('\n' | '\r')* + ; + +COMMENTLINE + : COMMENTTAG WS ~('\n' | '\r')* -> channel(HIDDEN) + ; + +WS + : [ \t\f;]+ -> channel(HIDDEN) + ; + +SEPARATOR + : ', ' -> channel(HIDDEN) + ; + +// case insensitive chars +fragment A + : ('a' | 'A') + ; + +fragment B + : ('b' | 'B') + ; + +fragment C + : ('c' | 'C') + ; + +fragment D + : ('d' | 'D') + ; + +fragment E + : ('e' | 'E') + ; + +fragment F + : ('f' | 'F') + ; + +fragment G + : ('g' | 'G') + ; + +fragment H + : ('h' | 'H') + ; + +fragment I + : ('i' | 'I') + ; + +fragment J + : ('j' | 'J') + ; + +fragment K + : ('k' | 'K') + ; + +fragment L + : ('l' | 'L') + ; + +fragment M + : ('m' | 'M') + ; + +fragment N + : ('n' | 'N') + ; + +fragment O + : ('o' | 'O') + ; + +fragment P + : ('p' | 'P') + ; + +fragment Q + : ('q' | 'Q') + ; + +fragment R + : ('r' | 'R') + ; + +fragment S + : ('s' | 'S') + ; + +fragment T + : ('t' | 'T') + ; + +fragment U + : ('u' | 'U') + ; + +fragment V + : ('v' | 'V') + ; + +fragment W + : ('w' | 'W') + ; + +fragment X + : ('x' | 'X') + ; + +fragment Y + : ('y' | 'Y') + ; + +fragment Z + : ('z' | 'Z') + ; \ No newline at end of file diff --git a/cobol85/Cobol85Preprocessor.g4 b/cobol85/Cobol85Preprocessor.g4 index 7c16327c86..6425486dab 100644 --- a/cobol85/Cobol85Preprocessor.g4 +++ b/cobol85/Cobol85Preprocessor.g4 @@ -12,659 +12,1892 @@ * This is a preprocessor grammar for Cobol 85. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Cobol85Preprocessor; startRule - : (compilerOptions | copyStatement | execCicsStatement | execSqlStatement | execSqlImsStatement | replaceOffStatement | replaceArea | ejectStatement | skipStatement | titleStatement | charDataLine | NEWLINE)* EOF - ; + : ( + compilerOptions + | copyStatement + | execCicsStatement + | execSqlStatement + | execSqlImsStatement + | replaceOffStatement + | replaceArea + | ejectStatement + | skipStatement + | titleStatement + | charDataLine + | NEWLINE + )* EOF + ; // compiler options compilerOptions - : (PROCESS | CBL) (COMMACHAR? compilerOption | compilerXOpts)+ - ; + : (PROCESS | CBL) (COMMACHAR? compilerOption | compilerXOpts)+ + ; compilerXOpts - : XOPTS LPARENCHAR compilerOption (COMMACHAR? compilerOption)* RPARENCHAR - ; + : XOPTS LPARENCHAR compilerOption (COMMACHAR? compilerOption)* RPARENCHAR + ; compilerOption - : ADATA | ADV | APOST - | (ARITH | AR) LPARENCHAR (EXTEND | E_CHAR | COMPAT | C_CHAR) RPARENCHAR - | AWO - | BLOCK0 - | (BUFSIZE | BUF) LPARENCHAR literal RPARENCHAR - | CBLCARD - | CICS (LPARENCHAR literal RPARENCHAR)? - | COBOL2 | COBOL3 - | (CODEPAGE | CP) LPARENCHAR literal RPARENCHAR - | (COMPILE | C_CHAR) - | CPP | CPSM - | (CURRENCY | CURR) LPARENCHAR literal RPARENCHAR - | DATA LPARENCHAR literal RPARENCHAR - | (DATEPROC | DP) (LPARENCHAR (FLAG | NOFLAG)? COMMACHAR? (TRIG | NOTRIG)? RPARENCHAR)? - | DBCS - | (DECK | D_CHAR) - | DEBUG - | (DIAGTRUNC | DTR) - | DLL - | (DUMP | DU) - | (DYNAM | DYN) - | EDF | EPILOG - | EXIT - | (EXPORTALL | EXP) - | (FASTSRT | FSRT) - | FEPI - | (FLAG | F_CHAR) LPARENCHAR (E_CHAR | I_CHAR | S_CHAR | U_CHAR | W_CHAR) (COMMACHAR (E_CHAR | I_CHAR | S_CHAR | U_CHAR | W_CHAR))? RPARENCHAR - | FLAGSTD LPARENCHAR (M_CHAR | I_CHAR | H_CHAR) (COMMACHAR (D_CHAR | DD | N_CHAR | NN | S_CHAR | SS))? RPARENCHAR - | GDS | GRAPHIC - | INTDATE LPARENCHAR (ANSI | LILIAN) RPARENCHAR - | (LANGUAGE | LANG) LPARENCHAR (ENGLISH | CS | EN | JA | JP | KA | UE) RPARENCHAR - | LEASM | LENGTH | LIB | LIN - | (LINECOUNT | LC) LPARENCHAR literal RPARENCHAR - | LINKAGE | LIST - | MAP - | MARGINS LPARENCHAR literal COMMACHAR literal (COMMACHAR literal)? RPARENCHAR - | (MDECK | MD) (LPARENCHAR (C_CHAR | COMPILE | NOC | NOCOMPILE) RPARENCHAR)? - | NAME (LPARENCHAR (ALIAS | NOALIAS) RPARENCHAR)? - | NATLANG LPARENCHAR (CS | EN | KA) RPARENCHAR - | NOADATA | NOADV | NOAWO - | NOBLOCK0 - | NOCBLCARD | NOCICS | NOCMPR2 - | (NOCOMPILE | NOC) (LPARENCHAR (S_CHAR | E_CHAR | W_CHAR) RPARENCHAR)? - | NOCPSM - | (NOCURRENCY | NOCURR) - | (NODATEPROC | NODP) - | NODBCS | NODEBUG - | (NODECK | NOD) - | NODLL | NODE - | (NODUMP | NODU) - | (NODIAGTRUNC | NODTR) - | (NODYNAM | NODYN) - | NOEDF | NOEPILOG | NOEXIT - | (NOEXPORTALL | NOEXP) - | (NOFASTSRT | NOFSRT) - | NOFEPI - | (NOFLAG | NOF) - | NOFLAGMIG | NOFLAGSTD - | NOGRAPHIC - | NOLENGTH | NOLIB | NOLINKAGE | NOLIST - | NOMAP - | (NOMDECK | NOMD) - | NONAME - | (NONUMBER | NONUM) - | (NOOBJECT | NOOBJ) - | (NOOFFSET | NOOFF) - | NOOPSEQUENCE - | (NOOPTIMIZE | NOOPT) - | NOOPTIONS - | NOP | NOPROLOG - | NORENT - | (NOSEQUENCE | NOSEQ) - | (NOSOURCE | NOS) - | NOSPIE | NOSQL - | (NOSQLCCSID | NOSQLC) - | (NOSSRANGE | NOSSR) - | NOSTDTRUNC - | (NOTERMINAL | NOTERM) | NOTEST | NOTHREAD - | NOVBREF - | (NOWORD | NOWD) - | NSEQ - | (NSYMBOL | NS) LPARENCHAR (NATIONAL | NAT | DBCS) RPARENCHAR - | NOVBREF - | (NOXREF | NOX) - | NOZWB - | (NUMBER | NUM) - | NUMPROC LPARENCHAR (MIG | NOPFD | PFD) RPARENCHAR - | (OBJECT | OBJ) - | (OFFSET | OFF) - | OPMARGINS LPARENCHAR literal COMMACHAR literal (COMMACHAR literal)? RPARENCHAR - | OPSEQUENCE LPARENCHAR literal COMMACHAR literal RPARENCHAR - | (OPTIMIZE | OPT) (LPARENCHAR (FULL | STD) RPARENCHAR)? - | OPTFILE | OPTIONS | OP - | (OUTDD | OUT) LPARENCHAR cobolWord RPARENCHAR - | (PGMNAME | PGMN) LPARENCHAR (CO | COMPAT | LM | LONGMIXED | LONGUPPER | LU | M_CHAR | MIXED | U_CHAR | UPPER) RPARENCHAR - | PROLOG - | (QUOTE | Q_CHAR) - | RENT - | RMODE LPARENCHAR (ANY | AUTO | literal) RPARENCHAR - | (SEQUENCE | SEQ) (LPARENCHAR literal COMMACHAR literal RPARENCHAR)? - | (SIZE | SZ) LPARENCHAR (MAX | literal) RPARENCHAR - | (SOURCE | S_CHAR) - | SP - | SPACE LPARENCHAR literal RPARENCHAR - | SPIE - | SQL (LPARENCHAR literal RPARENCHAR)? - | (SQLCCSID | SQLC) - | (SSRANGE | SSR) - | SYSEIB - | (TERMINAL | TERM) - | TEST (LPARENCHAR (HOOK | NOHOOK)? COMMACHAR? (SEP | SEPARATE | NOSEP | NOSEPARATE)? COMMACHAR? (EJPD | NOEJPD)? RPARENCHAR)? - | THREAD - | TRUNC LPARENCHAR (BIN | OPT | STD) RPARENCHAR - | VBREF - | (WORD | WD) LPARENCHAR cobolWord RPARENCHAR - | (XMLPARSE | XP) LPARENCHAR (COMPAT | C_CHAR | XMLSS | X_CHAR) RPARENCHAR - | (XREF | X_CHAR) (LPARENCHAR (FULL | SHORT)? RPARENCHAR)? - | (YEARWINDOW | YW) LPARENCHAR literal RPARENCHAR - | ZWB - ; + : ADATA + | ADV + | APOST + | (ARITH | AR) LPARENCHAR (EXTEND | E_CHAR | COMPAT | C_CHAR) RPARENCHAR + | AWO + | BLOCK0 + | (BUFSIZE | BUF) LPARENCHAR literal RPARENCHAR + | CBLCARD + | CICS (LPARENCHAR literal RPARENCHAR)? + | COBOL2 + | COBOL3 + | (CODEPAGE | CP) LPARENCHAR literal RPARENCHAR + | (COMPILE | C_CHAR) + | CPP + | CPSM + | (CURRENCY | CURR) LPARENCHAR literal RPARENCHAR + | DATA LPARENCHAR literal RPARENCHAR + | (DATEPROC | DP) (LPARENCHAR (FLAG | NOFLAG)? COMMACHAR? (TRIG | NOTRIG)? RPARENCHAR)? + | DBCS + | (DECK | D_CHAR) + | DEBUG + | (DIAGTRUNC | DTR) + | DLL + | (DUMP | DU) + | (DYNAM | DYN) + | EDF + | EPILOG + | EXIT + | (EXPORTALL | EXP) + | (FASTSRT | FSRT) + | FEPI + | (FLAG | F_CHAR) LPARENCHAR (E_CHAR | I_CHAR | S_CHAR | U_CHAR | W_CHAR) ( + COMMACHAR (E_CHAR | I_CHAR | S_CHAR | U_CHAR | W_CHAR) + )? RPARENCHAR + | FLAGSTD LPARENCHAR (M_CHAR | I_CHAR | H_CHAR) ( + COMMACHAR (D_CHAR | DD | N_CHAR | NN | S_CHAR | SS) + )? RPARENCHAR + | GDS + | GRAPHIC + | INTDATE LPARENCHAR (ANSI | LILIAN) RPARENCHAR + | (LANGUAGE | LANG) LPARENCHAR (ENGLISH | CS | EN | JA | JP | KA | UE) RPARENCHAR + | LEASM + | LENGTH + | LIB + | LIN + | (LINECOUNT | LC) LPARENCHAR literal RPARENCHAR + | LINKAGE + | LIST + | MAP + | MARGINS LPARENCHAR literal COMMACHAR literal (COMMACHAR literal)? RPARENCHAR + | (MDECK | MD) (LPARENCHAR (C_CHAR | COMPILE | NOC | NOCOMPILE) RPARENCHAR)? + | NAME (LPARENCHAR (ALIAS | NOALIAS) RPARENCHAR)? + | NATLANG LPARENCHAR (CS | EN | KA) RPARENCHAR + | NOADATA + | NOADV + | NOAWO + | NOBLOCK0 + | NOCBLCARD + | NOCICS + | NOCMPR2 + | (NOCOMPILE | NOC) (LPARENCHAR (S_CHAR | E_CHAR | W_CHAR) RPARENCHAR)? + | NOCPSM + | (NOCURRENCY | NOCURR) + | (NODATEPROC | NODP) + | NODBCS + | NODEBUG + | (NODECK | NOD) + | NODLL + | NODE + | (NODUMP | NODU) + | (NODIAGTRUNC | NODTR) + | (NODYNAM | NODYN) + | NOEDF + | NOEPILOG + | NOEXIT + | (NOEXPORTALL | NOEXP) + | (NOFASTSRT | NOFSRT) + | NOFEPI + | (NOFLAG | NOF) + | NOFLAGMIG + | NOFLAGSTD + | NOGRAPHIC + | NOLENGTH + | NOLIB + | NOLINKAGE + | NOLIST + | NOMAP + | (NOMDECK | NOMD) + | NONAME + | (NONUMBER | NONUM) + | (NOOBJECT | NOOBJ) + | (NOOFFSET | NOOFF) + | NOOPSEQUENCE + | (NOOPTIMIZE | NOOPT) + | NOOPTIONS + | NOP + | NOPROLOG + | NORENT + | (NOSEQUENCE | NOSEQ) + | (NOSOURCE | NOS) + | NOSPIE + | NOSQL + | (NOSQLCCSID | NOSQLC) + | (NOSSRANGE | NOSSR) + | NOSTDTRUNC + | (NOTERMINAL | NOTERM) + | NOTEST + | NOTHREAD + | NOVBREF + | (NOWORD | NOWD) + | NSEQ + | (NSYMBOL | NS) LPARENCHAR (NATIONAL | NAT | DBCS) RPARENCHAR + | NOVBREF + | (NOXREF | NOX) + | NOZWB + | (NUMBER | NUM) + | NUMPROC LPARENCHAR (MIG | NOPFD | PFD) RPARENCHAR + | (OBJECT | OBJ) + | (OFFSET | OFF) + | OPMARGINS LPARENCHAR literal COMMACHAR literal (COMMACHAR literal)? RPARENCHAR + | OPSEQUENCE LPARENCHAR literal COMMACHAR literal RPARENCHAR + | (OPTIMIZE | OPT) (LPARENCHAR (FULL | STD) RPARENCHAR)? + | OPTFILE + | OPTIONS + | OP + | (OUTDD | OUT) LPARENCHAR cobolWord RPARENCHAR + | (PGMNAME | PGMN) LPARENCHAR ( + CO + | COMPAT + | LM + | LONGMIXED + | LONGUPPER + | LU + | M_CHAR + | MIXED + | U_CHAR + | UPPER + ) RPARENCHAR + | PROLOG + | (QUOTE | Q_CHAR) + | RENT + | RMODE LPARENCHAR (ANY | AUTO | literal) RPARENCHAR + | (SEQUENCE | SEQ) (LPARENCHAR literal COMMACHAR literal RPARENCHAR)? + | (SIZE | SZ) LPARENCHAR (MAX | literal) RPARENCHAR + | (SOURCE | S_CHAR) + | SP + | SPACE LPARENCHAR literal RPARENCHAR + | SPIE + | SQL (LPARENCHAR literal RPARENCHAR)? + | (SQLCCSID | SQLC) + | (SSRANGE | SSR) + | SYSEIB + | (TERMINAL | TERM) + | TEST ( + LPARENCHAR (HOOK | NOHOOK)? COMMACHAR? (SEP | SEPARATE | NOSEP | NOSEPARATE)? COMMACHAR? ( + EJPD + | NOEJPD + )? RPARENCHAR + )? + | THREAD + | TRUNC LPARENCHAR (BIN | OPT | STD) RPARENCHAR + | VBREF + | (WORD | WD) LPARENCHAR cobolWord RPARENCHAR + | (XMLPARSE | XP) LPARENCHAR (COMPAT | C_CHAR | XMLSS | X_CHAR) RPARENCHAR + | (XREF | X_CHAR) (LPARENCHAR (FULL | SHORT)? RPARENCHAR)? + | (YEARWINDOW | YW) LPARENCHAR literal RPARENCHAR + | ZWB + ; // exec cics statement execCicsStatement - : EXEC CICS charData END_EXEC DOT? - ; + : EXEC CICS charData END_EXEC DOT? + ; // exec sql statement execSqlStatement - : EXEC SQL charDataSql END_EXEC DOT? - ; + : EXEC SQL charDataSql END_EXEC DOT? + ; // exec sql ims statement execSqlImsStatement - : EXEC SQLIMS charData END_EXEC DOT? - ; + : EXEC SQLIMS charData END_EXEC DOT? + ; // copy statement copyStatement - : COPY copySource (NEWLINE* (directoryPhrase | familyPhrase | replacingPhrase | SUPPRESS))* NEWLINE* DOT - ; + : COPY copySource (NEWLINE* (directoryPhrase | familyPhrase | replacingPhrase | SUPPRESS))* NEWLINE* DOT + ; copySource - : (literal | cobolWord | filename) ((OF | IN) copyLibrary)? - ; + : (literal | cobolWord | filename) ((OF | IN) copyLibrary)? + ; copyLibrary - : literal | cobolWord - ; + : literal + | cobolWord + ; replacingPhrase - : REPLACING NEWLINE* replaceClause (NEWLINE+ replaceClause)* - ; + : REPLACING NEWLINE* replaceClause (NEWLINE+ replaceClause)* + ; // replace statement replaceArea - : replaceByStatement (copyStatement | charData)* replaceOffStatement? - ; + : replaceByStatement (copyStatement | charData)* replaceOffStatement? + ; replaceByStatement - : REPLACE (NEWLINE* replaceClause)+ DOT - ; + : REPLACE (NEWLINE* replaceClause)+ DOT + ; replaceOffStatement - : REPLACE OFF DOT - ; + : REPLACE OFF DOT + ; replaceClause - : replaceable NEWLINE* BY NEWLINE* replacement (NEWLINE* directoryPhrase)? (NEWLINE* familyPhrase)? - ; + : replaceable NEWLINE* BY NEWLINE* replacement (NEWLINE* directoryPhrase)? ( + NEWLINE* familyPhrase + )? + ; directoryPhrase - : (OF | IN) NEWLINE* (literal | cobolWord) - ; + : (OF | IN) NEWLINE* (literal | cobolWord) + ; familyPhrase - : ON NEWLINE* (literal | cobolWord) - ; + : ON NEWLINE* (literal | cobolWord) + ; replaceable - : literal | cobolWord | pseudoText | charDataLine - ; + : literal + | cobolWord + | pseudoText + | charDataLine + ; replacement - : literal | cobolWord | pseudoText | charDataLine - ; + : literal + | cobolWord + | pseudoText + | charDataLine + ; // eject statement ejectStatement - : EJECT DOT? - ; + : EJECT DOT? + ; // skip statement skipStatement - : (SKIP1 | SKIP2 | SKIP3) DOT? - ; + : (SKIP1 | SKIP2 | SKIP3) DOT? + ; // title statement titleStatement - : TITLE literal DOT? - ; + : TITLE literal DOT? + ; // literal ---------------------------------- pseudoText - : DOUBLEEQUALCHAR charData? DOUBLEEQUALCHAR - ; + : DOUBLEEQUALCHAR charData? DOUBLEEQUALCHAR + ; charData - : (charDataLine | NEWLINE)+ - ; + : (charDataLine | NEWLINE)+ + ; charDataSql - : (charDataLine | COPY | REPLACE | NEWLINE)+ - ; + : (charDataLine | COPY | REPLACE | NEWLINE)+ + ; charDataLine - : (cobolWord | literal | filename | TEXT | DOT | LPARENCHAR | RPARENCHAR)+ - ; + : (cobolWord | literal | filename | TEXT | DOT | LPARENCHAR | RPARENCHAR)+ + ; cobolWord - : IDENTIFIER | charDataKeyword - ; + : IDENTIFIER + | charDataKeyword + ; literal - : NONNUMERICLITERAL | NUMERICLITERAL - ; + : NONNUMERICLITERAL + | NUMERICLITERAL + ; filename - : FILENAME - ; + : FILENAME + ; // keywords ---------------------------------- charDataKeyword - : ADATA | ADV | ALIAS | ANSI | ANY | APOST | AR | ARITH | AUTO | AWO - | BIN | BLOCK0 | BUF | BUFSIZE | BY - | CBL | CBLCARD | CO | COBOL2 | COBOL3 | CODEPAGE | COMMACHAR | COMPAT | COMPILE | CP | CPP | CPSM | CS | CURR | CURRENCY - | DATA | DATEPROC | DBCS | DD | DEBUG | DECK | DIAGTRUNC | DLI | DLL | DP | DTR | DU | DUMP | DYN | DYNAM - | EDF | EJECT | EJPD | EN | ENGLISH | EPILOG | EXCI | EXIT | EXP | EXPORTALL | EXTEND - | FASTSRT | FLAG | FLAGSTD | FULL | FSRT - | GDS | GRAPHIC - | HOOK - | IN | INTDATE - | JA | JP - | KA - | LANG | LANGUAGE | LC | LENGTH | LIB | LILIAN | LIN | LINECOUNT | LINKAGE | LIST | LM | LONGMIXED | LONGUPPER | LU - | MAP | MARGINS | MAX | MD | MDECK | MIG | MIXED - | NAME | NAT | NATIONAL | NATLANG - | NN - | NO - | NOADATA | NOADV | NOALIAS | NOAWO - | NOBLOCK0 - | NOC | NOCBLCARD | NOCICS | NOCMPR2 | NOCOMPILE | NOCPSM | NOCURR | NOCURRENCY - | NOD | NODATEPROC | NODBCS | NODE | NODEBUG | NODECK | NODIAGTRUNC | NODLL | NODU | NODUMP | NODP | NODTR | NODYN | NODYNAM - | NOEDF | NOEJPD | NOEPILOG | NOEXIT | NOEXP | NOEXPORTALL - | NOF | NOFASTSRT | NOFEPI | NOFLAG | NOFLAGMIG | NOFLAGSTD | NOFSRT - | NOGRAPHIC - | NOHOOK - | NOLENGTH | NOLIB | NOLINKAGE | NOLIST - | NOMAP | NOMD | NOMDECK - | NONAME | NONUM | NONUMBER - | NOOBJ | NOOBJECT | NOOFF | NOOFFSET | NOOPSEQUENCE | NOOPT | NOOPTIMIZE | NOOPTIONS - | NOP | NOPFD | NOPROLOG - | NORENT - | NOS | NOSEP | NOSEPARATE | NOSEQ | NOSEQUENCE | NOSOURCE | NOSPIE | NOSQL | NOSQLC | NOSQLCCSID | NOSSR | NOSSRANGE | NOSTDTRUNC - | NOTERM | NOTERMINAL | NOTEST | NOTHREAD | NOTRIG - | NOVBREF - | NOWORD - | NOX | NOXREF - | NOZWB - | NSEQ | NSYMBOL | NS - | NUM | NUMBER | NUMPROC - | OBJ | OBJECT | ON | OF | OFF | OFFSET | OPMARGINS | OPSEQUENCE | OPTIMIZE | OP | OPT | OPTFILE | OPTIONS | OUT | OUTDD - | PFD | PGMN | PGMNAME | PPTDBG | PROCESS | PROLOG - | QUOTE - | RENT | REPLACING | RMODE - | SEQ | SEQUENCE | SEP | SEPARATE | SHORT | SIZE | SOURCE | SP | SPACE | SPIE | SQL | SQLC | SQLCCSID | SS | SSR | SSRANGE | STD | SYSEIB | SZ - | TERM | TERMINAL | TEST | THREAD | TITLE | TRIG | TRUNC - | UE | UPPER - | VBREF - | WD - | XMLPARSE | XMLSS | XOPTS | XREF - | YEARWINDOW | YW - | ZWB - | C_CHAR | D_CHAR | E_CHAR | F_CHAR | H_CHAR | I_CHAR | M_CHAR | N_CHAR | Q_CHAR | S_CHAR | U_CHAR | W_CHAR | X_CHAR - ; + : ADATA + | ADV + | ALIAS + | ANSI + | ANY + | APOST + | AR + | ARITH + | AUTO + | AWO + | BIN + | BLOCK0 + | BUF + | BUFSIZE + | BY + | CBL + | CBLCARD + | CO + | COBOL2 + | COBOL3 + | CODEPAGE + | COMMACHAR + | COMPAT + | COMPILE + | CP + | CPP + | CPSM + | CS + | CURR + | CURRENCY + | DATA + | DATEPROC + | DBCS + | DD + | DEBUG + | DECK + | DIAGTRUNC + | DLI + | DLL + | DP + | DTR + | DU + | DUMP + | DYN + | DYNAM + | EDF + | EJECT + | EJPD + | EN + | ENGLISH + | EPILOG + | EXCI + | EXIT + | EXP + | EXPORTALL + | EXTEND + | FASTSRT + | FLAG + | FLAGSTD + | FULL + | FSRT + | GDS + | GRAPHIC + | HOOK + | IN + | INTDATE + | JA + | JP + | KA + | LANG + | LANGUAGE + | LC + | LENGTH + | LIB + | LILIAN + | LIN + | LINECOUNT + | LINKAGE + | LIST + | LM + | LONGMIXED + | LONGUPPER + | LU + | MAP + | MARGINS + | MAX + | MD + | MDECK + | MIG + | MIXED + | NAME + | NAT + | NATIONAL + | NATLANG + | NN + | NO + | NOADATA + | NOADV + | NOALIAS + | NOAWO + | NOBLOCK0 + | NOC + | NOCBLCARD + | NOCICS + | NOCMPR2 + | NOCOMPILE + | NOCPSM + | NOCURR + | NOCURRENCY + | NOD + | NODATEPROC + | NODBCS + | NODE + | NODEBUG + | NODECK + | NODIAGTRUNC + | NODLL + | NODU + | NODUMP + | NODP + | NODTR + | NODYN + | NODYNAM + | NOEDF + | NOEJPD + | NOEPILOG + | NOEXIT + | NOEXP + | NOEXPORTALL + | NOF + | NOFASTSRT + | NOFEPI + | NOFLAG + | NOFLAGMIG + | NOFLAGSTD + | NOFSRT + | NOGRAPHIC + | NOHOOK + | NOLENGTH + | NOLIB + | NOLINKAGE + | NOLIST + | NOMAP + | NOMD + | NOMDECK + | NONAME + | NONUM + | NONUMBER + | NOOBJ + | NOOBJECT + | NOOFF + | NOOFFSET + | NOOPSEQUENCE + | NOOPT + | NOOPTIMIZE + | NOOPTIONS + | NOP + | NOPFD + | NOPROLOG + | NORENT + | NOS + | NOSEP + | NOSEPARATE + | NOSEQ + | NOSEQUENCE + | NOSOURCE + | NOSPIE + | NOSQL + | NOSQLC + | NOSQLCCSID + | NOSSR + | NOSSRANGE + | NOSTDTRUNC + | NOTERM + | NOTERMINAL + | NOTEST + | NOTHREAD + | NOTRIG + | NOVBREF + | NOWORD + | NOX + | NOXREF + | NOZWB + | NSEQ + | NSYMBOL + | NS + | NUM + | NUMBER + | NUMPROC + | OBJ + | OBJECT + | ON + | OF + | OFF + | OFFSET + | OPMARGINS + | OPSEQUENCE + | OPTIMIZE + | OP + | OPT + | OPTFILE + | OPTIONS + | OUT + | OUTDD + | PFD + | PGMN + | PGMNAME + | PPTDBG + | PROCESS + | PROLOG + | QUOTE + | RENT + | REPLACING + | RMODE + | SEQ + | SEQUENCE + | SEP + | SEPARATE + | SHORT + | SIZE + | SOURCE + | SP + | SPACE + | SPIE + | SQL + | SQLC + | SQLCCSID + | SS + | SSR + | SSRANGE + | STD + | SYSEIB + | SZ + | TERM + | TERMINAL + | TEST + | THREAD + | TITLE + | TRIG + | TRUNC + | UE + | UPPER + | VBREF + | WD + | XMLPARSE + | XMLSS + | XOPTS + | XREF + | YEARWINDOW + | YW + | ZWB + | C_CHAR + | D_CHAR + | E_CHAR + | F_CHAR + | H_CHAR + | I_CHAR + | M_CHAR + | N_CHAR + | Q_CHAR + | S_CHAR + | U_CHAR + | W_CHAR + | X_CHAR + ; // lexer rules -------------------------------------------------------------------------------- // keywords -ADATA : A D A T A; -ADV : A D V; -ALIAS : A L I A S; -ANSI : A N S I; -ANY : A N Y; -APOST : A P O S T; -AR : A R; -ARITH : A R I T H; -AUTO : A U T O; -AWO : A W O; -BIN : B I N; -BLOCK0 : B L O C K '0'; -BUF : B U F; -BUFSIZE : B U F S I Z E; -BY : B Y; -CBL : C B L; -CBLCARD : C B L C A R D; -CICS : C I C S; -CO : C O; -COBOL2 : C O B O L '2'; -COBOL3 : C O B O L '3'; -CODEPAGE : C O D E P A G E; -COMPAT : C O M P A T; -COMPILE : C O M P I L E; -COPY : C O P Y; -CP : C P; -CPP : C P P; -CPSM : C P S M; -CS : C S; -CURR : C U R R; -CURRENCY : C U R R E N C Y; -DATA : D A T A; -DATEPROC : D A T E P R O C; -DBCS : D B C S; -DD : D D; -DEBUG : D E B U G; -DECK : D E C K; -DIAGTRUNC : D I A G T R U N C; -DLI : D L I; -DLL : D L L; -DP : D P; -DTR : D T R; -DU : D U; -DUMP : D U M P; -DYN : D Y N; -DYNAM : D Y N A M; -EDF : E D F; -EJECT : E J E C T; -EJPD : E J P D; -EN : E N; -ENGLISH : E N G L I S H; -END_EXEC : E N D '-' E X E C; -EPILOG : E P I L O G; -EXCI : E X C I; -EXEC : E X E C; -EXIT : E X I T; -EXP : E X P; -EXPORTALL : E X P O R T A L L; -EXTEND : E X T E N D; -FASTSRT : F A S T S R T; -FEPI : F E P I; -FLAG : F L A G; -FLAGSTD : F L A G S T D; -FSRT : F S R T; -FULL : F U L L; -GDS : G D S; -GRAPHIC : G R A P H I C; -HOOK : H O O K; -IN : I N; -INTDATE : I N T D A T E; -JA : J A; -JP : J P; -KA : K A; -LANG : L A N G; -LANGUAGE : L A N G U A G E; -LC : L C; -LEASM : L E A S M; -LENGTH : L E N G T H; -LIB : L I B; -LILIAN : L I L I A N; -LIN : L I N; -LINECOUNT : L I N E C O U N T; -LINKAGE : L I N K A G E; -LIST : L I S T; -LM : L M; -LONGMIXED : L O N G M I X E D; -LONGUPPER : L O N G U P P E R; -LPARENCHAR : '('; -LU : L U; -MAP : M A P; -MARGINS : M A R G I N S; -MAX : M A X; -MD : M D; -MDECK : M D E C K; -MIG : M I G; -MIXED : M I X E D; -NAME : N A M E; -NAT : N A T; -NATIONAL : N A T I O N A L; -NATLANG : N A T L A N G; -NN : N N; -NO : N O; -NOADATA : N O A D A T A; -NOADV : N O A D V; -NOALIAS : N O A L I A S; -NOAWO : N O A W O; -NOBLOCK0 : N O B L O C K '0'; -NOC : N O C; -NOCBLCARD : N O C B L C A R D; -NOCICS : N O C I C S; -NOCMPR2 : N O C M P R '2'; -NOCOMPILE : N O C O M P I L E; -NOCPSM : N O C P S M; -NOCURR : N O C U R R; -NOCURRENCY : N O C U R R E N C Y; -NOD : N O D; -NODATEPROC : N O D A T E P R O C; -NODBCS : N O D B C S; -NODE : N O D E; -NODEBUG : N O D E B U G; -NODECK : N O D E C K; -NODIAGTRUNC : N O D I A G T R U N C; -NODLL : N O D L L; -NODU : N O D U; -NODUMP : N O D U M P; -NODP : N O D P; -NODTR : N O D T R; -NODYN : N O D Y N; -NODYNAM : N O D Y N A M; -NOEDF : N O E D F; -NOEJPD : N O E J P D; -NOEPILOG : N O E P I L O G; -NOEXIT : N O E X I T; -NOEXP : N O E X P; -NOEXPORTALL : N O E X P O R T A L L; -NOF : N O F; -NOFASTSRT : N O F A S T S R T; -NOFEPI : N O F E P I; -NOFLAG : N O F L A G; -NOFLAGMIG : N O F L A G M I G; -NOFLAGSTD : N O F L A G S T D; -NOFSRT : N O F S R T; -NOGRAPHIC : N O G R A P H I C; -NOHOOK : N O H O O K; -NOLENGTH : N O L E N G T H; -NOLIB : N O L I B; -NOLINKAGE : N O L I N K A G E; -NOLIST : N O L I S T; -NOMAP : N O M A P; -NOMD : N O M D; -NOMDECK : N O M D E C K; -NONAME : N O N A M E; -NONUM : N O N U M; -NONUMBER : N O N U M B E R; -NOOBJ : N O O B J; -NOOBJECT : N O O B J E C T; -NOOFF : N O O F F; -NOOFFSET : N O O F F S E T; -NOOPSEQUENCE : N O O P S E Q U E N C E; -NOOPT : N O O P T; -NOOPTIMIZE : N O O P T I M I Z E; -NOOPTIONS : N O O P T I O N S; -NOP : N O P; -NOPFD : N O P F D; -NOPROLOG : N O P R O L O G; -NORENT : N O R E N T; -NOS : N O S; -NOSEP : N O S E P; -NOSEPARATE : N O S E P A R A T E; -NOSEQ : N O S E Q; -NOSOURCE : N O S O U R C E; -NOSPIE : N O S P I E; -NOSQL : N O S Q L; -NOSQLC : N O S Q L C; -NOSQLCCSID : N O S Q L C C S I D; -NOSSR : N O S S R; -NOSSRANGE : N O S S R A N G E; -NOSTDTRUNC : N O S T D T R U N C; -NOSEQUENCE : N O S E Q U E N C E; -NOTERM : N O T E R M; -NOTERMINAL : N O T E R M I N A L; -NOTEST : N O T E S T; -NOTHREAD : N O T H R E A D; -NOTRIG : N O T R I G; -NOVBREF : N O V B R E F; -NOWD : N O W D; -NOWORD : N O W O R D; -NOX : N O X; -NOXREF : N O X R E F; -NOZWB : N O Z W B; -NS : N S; -NSEQ : N S E Q; -NSYMBOL : N S Y M B O L; -NUM : N U M; -NUMBER : N U M B E R; -NUMPROC : N U M P R O C; -OBJ : O B J; -OBJECT : O B J E C T; -OF : O F; -OFF : O F F; -OFFSET : O F F S E T; -ON : O N; -OP : O P; -OPMARGINS : O P M A R G I N S; -OPSEQUENCE : O P S E Q U E N C E; -OPT : O P T; -OPTFILE : O P T F I L E; -OPTIMIZE : O P T I M I Z E; -OPTIONS : O P T I O N S; -OUT : O U T; -OUTDD : O U T D D; -PFD : P F D; -PPTDBG : P P T D B G; -PGMN : P G M N; -PGMNAME : P G M N A M E; -PROCESS : P R O C E S S; -PROLOG : P R O L O G; -QUOTE : Q U O T E; -RENT : R E N T; -REPLACE : R E P L A C E; -REPLACING : R E P L A C I N G; -RMODE : R M O D E; -RPARENCHAR : ')'; -SEP : S E P; -SEPARATE : S E P A R A T E; -SEQ : S E Q; -SEQUENCE : S E Q U E N C E; -SHORT : S H O R T; -SIZE : S I Z E; -SOURCE : S O U R C E; -SP : S P; -SPACE : S P A C E; -SPIE : S P I E; -SQL : S Q L; -SQLC : S Q L C; -SQLCCSID : S Q L C C S I D; -SQLIMS : S Q L I M S; -SKIP1 : S K I P '1'; -SKIP2 : S K I P '2'; -SKIP3 : S K I P '3'; -SS : S S; -SSR : S S R; -SSRANGE : S S R A N G E; -STD : S T D; -SUPPRESS : S U P P R E S S; -SYSEIB : S Y S E I B; -SZ : S Z; -TERM : T E R M; -TERMINAL : T E R M I N A L; -TEST : T E S T; -THREAD : T H R E A D; -TITLE : T I T L E; -TRIG : T R I G; -TRUNC : T R U N C; -UE : U E; -UPPER : U P P E R; -VBREF : V B R E F; -WD : W D; -WORD : W O R D; -XMLPARSE : X M L P A R S E; -XMLSS : X M L S S; -XOPTS: X O P T S; -XP : X P; -XREF : X R E F; -YEARWINDOW : Y E A R W I N D O W; -YW : Y W; -ZWB : Z W B; - -C_CHAR : C; -D_CHAR : D; -E_CHAR : E; -F_CHAR : F; -H_CHAR : H; -I_CHAR : I; -M_CHAR : M; -N_CHAR : N; -Q_CHAR : Q; -S_CHAR : S; -U_CHAR : U; -W_CHAR : W; -X_CHAR : X; +ADATA + : A D A T A + ; + +ADV + : A D V + ; + +ALIAS + : A L I A S + ; + +ANSI + : A N S I + ; + +ANY + : A N Y + ; + +APOST + : A P O S T + ; + +AR + : A R + ; + +ARITH + : A R I T H + ; + +AUTO + : A U T O + ; + +AWO + : A W O + ; + +BIN + : B I N + ; + +BLOCK0 + : B L O C K '0' + ; + +BUF + : B U F + ; + +BUFSIZE + : B U F S I Z E + ; + +BY + : B Y + ; + +CBL + : C B L + ; + +CBLCARD + : C B L C A R D + ; + +CICS + : C I C S + ; + +CO + : C O + ; + +COBOL2 + : C O B O L '2' + ; + +COBOL3 + : C O B O L '3' + ; + +CODEPAGE + : C O D E P A G E + ; + +COMPAT + : C O M P A T + ; + +COMPILE + : C O M P I L E + ; + +COPY + : C O P Y + ; + +CP + : C P + ; + +CPP + : C P P + ; + +CPSM + : C P S M + ; + +CS + : C S + ; + +CURR + : C U R R + ; + +CURRENCY + : C U R R E N C Y + ; + +DATA + : D A T A + ; + +DATEPROC + : D A T E P R O C + ; + +DBCS + : D B C S + ; + +DD + : D D + ; + +DEBUG + : D E B U G + ; + +DECK + : D E C K + ; + +DIAGTRUNC + : D I A G T R U N C + ; + +DLI + : D L I + ; + +DLL + : D L L + ; + +DP + : D P + ; + +DTR + : D T R + ; + +DU + : D U + ; + +DUMP + : D U M P + ; + +DYN + : D Y N + ; + +DYNAM + : D Y N A M + ; + +EDF + : E D F + ; + +EJECT + : E J E C T + ; + +EJPD + : E J P D + ; + +EN + : E N + ; + +ENGLISH + : E N G L I S H + ; + +END_EXEC + : E N D '-' E X E C + ; + +EPILOG + : E P I L O G + ; + +EXCI + : E X C I + ; + +EXEC + : E X E C + ; + +EXIT + : E X I T + ; + +EXP + : E X P + ; + +EXPORTALL + : E X P O R T A L L + ; + +EXTEND + : E X T E N D + ; + +FASTSRT + : F A S T S R T + ; + +FEPI + : F E P I + ; + +FLAG + : F L A G + ; + +FLAGSTD + : F L A G S T D + ; + +FSRT + : F S R T + ; + +FULL + : F U L L + ; + +GDS + : G D S + ; + +GRAPHIC + : G R A P H I C + ; + +HOOK + : H O O K + ; + +IN + : I N + ; + +INTDATE + : I N T D A T E + ; + +JA + : J A + ; + +JP + : J P + ; + +KA + : K A + ; + +LANG + : L A N G + ; + +LANGUAGE + : L A N G U A G E + ; + +LC + : L C + ; + +LEASM + : L E A S M + ; + +LENGTH + : L E N G T H + ; + +LIB + : L I B + ; + +LILIAN + : L I L I A N + ; + +LIN + : L I N + ; + +LINECOUNT + : L I N E C O U N T + ; + +LINKAGE + : L I N K A G E + ; + +LIST + : L I S T + ; + +LM + : L M + ; + +LONGMIXED + : L O N G M I X E D + ; + +LONGUPPER + : L O N G U P P E R + ; + +LPARENCHAR + : '(' + ; + +LU + : L U + ; + +MAP + : M A P + ; + +MARGINS + : M A R G I N S + ; + +MAX + : M A X + ; + +MD + : M D + ; + +MDECK + : M D E C K + ; + +MIG + : M I G + ; + +MIXED + : M I X E D + ; + +NAME + : N A M E + ; + +NAT + : N A T + ; + +NATIONAL + : N A T I O N A L + ; + +NATLANG + : N A T L A N G + ; + +NN + : N N + ; + +NO + : N O + ; + +NOADATA + : N O A D A T A + ; + +NOADV + : N O A D V + ; + +NOALIAS + : N O A L I A S + ; + +NOAWO + : N O A W O + ; + +NOBLOCK0 + : N O B L O C K '0' + ; + +NOC + : N O C + ; + +NOCBLCARD + : N O C B L C A R D + ; + +NOCICS + : N O C I C S + ; + +NOCMPR2 + : N O C M P R '2' + ; + +NOCOMPILE + : N O C O M P I L E + ; + +NOCPSM + : N O C P S M + ; + +NOCURR + : N O C U R R + ; + +NOCURRENCY + : N O C U R R E N C Y + ; + +NOD + : N O D + ; + +NODATEPROC + : N O D A T E P R O C + ; + +NODBCS + : N O D B C S + ; + +NODE + : N O D E + ; + +NODEBUG + : N O D E B U G + ; + +NODECK + : N O D E C K + ; + +NODIAGTRUNC + : N O D I A G T R U N C + ; + +NODLL + : N O D L L + ; + +NODU + : N O D U + ; + +NODUMP + : N O D U M P + ; + +NODP + : N O D P + ; + +NODTR + : N O D T R + ; + +NODYN + : N O D Y N + ; + +NODYNAM + : N O D Y N A M + ; + +NOEDF + : N O E D F + ; + +NOEJPD + : N O E J P D + ; + +NOEPILOG + : N O E P I L O G + ; + +NOEXIT + : N O E X I T + ; + +NOEXP + : N O E X P + ; + +NOEXPORTALL + : N O E X P O R T A L L + ; + +NOF + : N O F + ; + +NOFASTSRT + : N O F A S T S R T + ; + +NOFEPI + : N O F E P I + ; + +NOFLAG + : N O F L A G + ; + +NOFLAGMIG + : N O F L A G M I G + ; + +NOFLAGSTD + : N O F L A G S T D + ; + +NOFSRT + : N O F S R T + ; + +NOGRAPHIC + : N O G R A P H I C + ; + +NOHOOK + : N O H O O K + ; + +NOLENGTH + : N O L E N G T H + ; + +NOLIB + : N O L I B + ; + +NOLINKAGE + : N O L I N K A G E + ; + +NOLIST + : N O L I S T + ; + +NOMAP + : N O M A P + ; + +NOMD + : N O M D + ; + +NOMDECK + : N O M D E C K + ; + +NONAME + : N O N A M E + ; + +NONUM + : N O N U M + ; + +NONUMBER + : N O N U M B E R + ; + +NOOBJ + : N O O B J + ; +NOOBJECT + : N O O B J E C T + ; + +NOOFF + : N O O F F + ; + +NOOFFSET + : N O O F F S E T + ; + +NOOPSEQUENCE + : N O O P S E Q U E N C E + ; + +NOOPT + : N O O P T + ; + +NOOPTIMIZE + : N O O P T I M I Z E + ; + +NOOPTIONS + : N O O P T I O N S + ; + +NOP + : N O P + ; + +NOPFD + : N O P F D + ; + +NOPROLOG + : N O P R O L O G + ; + +NORENT + : N O R E N T + ; + +NOS + : N O S + ; + +NOSEP + : N O S E P + ; + +NOSEPARATE + : N O S E P A R A T E + ; + +NOSEQ + : N O S E Q + ; + +NOSOURCE + : N O S O U R C E + ; + +NOSPIE + : N O S P I E + ; + +NOSQL + : N O S Q L + ; + +NOSQLC + : N O S Q L C + ; + +NOSQLCCSID + : N O S Q L C C S I D + ; + +NOSSR + : N O S S R + ; + +NOSSRANGE + : N O S S R A N G E + ; + +NOSTDTRUNC + : N O S T D T R U N C + ; + +NOSEQUENCE + : N O S E Q U E N C E + ; + +NOTERM + : N O T E R M + ; + +NOTERMINAL + : N O T E R M I N A L + ; + +NOTEST + : N O T E S T + ; + +NOTHREAD + : N O T H R E A D + ; + +NOTRIG + : N O T R I G + ; + +NOVBREF + : N O V B R E F + ; + +NOWD + : N O W D + ; + +NOWORD + : N O W O R D + ; + +NOX + : N O X + ; + +NOXREF + : N O X R E F + ; + +NOZWB + : N O Z W B + ; + +NS + : N S + ; + +NSEQ + : N S E Q + ; + +NSYMBOL + : N S Y M B O L + ; + +NUM + : N U M + ; + +NUMBER + : N U M B E R + ; + +NUMPROC + : N U M P R O C + ; + +OBJ + : O B J + ; + +OBJECT + : O B J E C T + ; + +OF + : O F + ; + +OFF + : O F F + ; + +OFFSET + : O F F S E T + ; + +ON + : O N + ; + +OP + : O P + ; + +OPMARGINS + : O P M A R G I N S + ; + +OPSEQUENCE + : O P S E Q U E N C E + ; + +OPT + : O P T + ; + +OPTFILE + : O P T F I L E + ; + +OPTIMIZE + : O P T I M I Z E + ; + +OPTIONS + : O P T I O N S + ; + +OUT + : O U T + ; + +OUTDD + : O U T D D + ; + +PFD + : P F D + ; + +PPTDBG + : P P T D B G + ; + +PGMN + : P G M N + ; + +PGMNAME + : P G M N A M E + ; + +PROCESS + : P R O C E S S + ; + +PROLOG + : P R O L O G + ; + +QUOTE + : Q U O T E + ; + +RENT + : R E N T + ; + +REPLACE + : R E P L A C E + ; + +REPLACING + : R E P L A C I N G + ; + +RMODE + : R M O D E + ; + +RPARENCHAR + : ')' + ; + +SEP + : S E P + ; + +SEPARATE + : S E P A R A T E + ; + +SEQ + : S E Q + ; + +SEQUENCE + : S E Q U E N C E + ; + +SHORT + : S H O R T + ; + +SIZE + : S I Z E + ; + +SOURCE + : S O U R C E + ; + +SP + : S P + ; + +SPACE + : S P A C E + ; + +SPIE + : S P I E + ; + +SQL + : S Q L + ; + +SQLC + : S Q L C + ; + +SQLCCSID + : S Q L C C S I D + ; + +SQLIMS + : S Q L I M S + ; + +SKIP1 + : S K I P '1' + ; + +SKIP2 + : S K I P '2' + ; + +SKIP3 + : S K I P '3' + ; + +SS + : S S + ; + +SSR + : S S R + ; + +SSRANGE + : S S R A N G E + ; + +STD + : S T D + ; + +SUPPRESS + : S U P P R E S S + ; + +SYSEIB + : S Y S E I B + ; + +SZ + : S Z + ; + +TERM + : T E R M + ; + +TERMINAL + : T E R M I N A L + ; + +TEST + : T E S T + ; + +THREAD + : T H R E A D + ; + +TITLE + : T I T L E + ; + +TRIG + : T R I G + ; + +TRUNC + : T R U N C + ; + +UE + : U E + ; + +UPPER + : U P P E R + ; + +VBREF + : V B R E F + ; + +WD + : W D + ; + +WORD + : W O R D + ; + +XMLPARSE + : X M L P A R S E + ; + +XMLSS + : X M L S S + ; + +XOPTS + : X O P T S + ; + +XP + : X P + ; + +XREF + : X R E F + ; + +YEARWINDOW + : Y E A R W I N D O W + ; + +YW + : Y W + ; + +ZWB + : Z W B + ; + +C_CHAR + : C + ; + +D_CHAR + : D + ; + +E_CHAR + : E + ; + +F_CHAR + : F + ; + +H_CHAR + : H + ; + +I_CHAR + : I + ; + +M_CHAR + : M + ; + +N_CHAR + : N + ; + +Q_CHAR + : Q + ; + +S_CHAR + : S + ; + +U_CHAR + : U + ; + +W_CHAR + : W + ; + +X_CHAR + : X + ; // symbols -COMMENTTAG : '*>'; -COMMACHAR : ','; -DOT : '.'; -DOUBLEEQUALCHAR : '=='; +COMMENTTAG + : '*>' + ; + +COMMACHAR + : ',' + ; + +DOT + : '.' + ; + +DOUBLEEQUALCHAR + : '==' + ; // literals -NONNUMERICLITERAL : STRINGLITERAL | HEXNUMBER; -NUMERICLITERAL : [0-9]+; +NONNUMERICLITERAL + : STRINGLITERAL + | HEXNUMBER + ; -fragment HEXNUMBER : - X '"' [0-9A-F]+ '"' - | X '\'' [0-9A-F]+ '\'' -; +NUMERICLITERAL + : [0-9]+ + ; -fragment STRINGLITERAL : - '"' (~["\n\r] | '""' | '\'')* '"' - | '\'' (~['\n\r] | '\'\'' | '"')* '\'' -; +fragment HEXNUMBER + : X '"' [0-9A-F]+ '"' + | X '\'' [0-9A-F]+ '\'' + ; -IDENTIFIER : [a-zA-Z0-9]+ ([-_]+ [a-zA-Z0-9]+)*; -FILENAME : [a-zA-Z0-9]+ '.' [a-zA-Z0-9]+; +fragment STRINGLITERAL + : '"' (~["\n\r] | '""' | '\'')* '"' + | '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; +IDENTIFIER + : [a-zA-Z0-9]+ ([-_]+ [a-zA-Z0-9]+)* + ; + +FILENAME + : [a-zA-Z0-9]+ '.' [a-zA-Z0-9]+ + ; // whitespace, line breaks, comments, ... -NEWLINE : '\r'? '\n'; -COMMENTLINE : COMMENTTAG ~('\n' | '\r')* -> channel(HIDDEN); -WS : [ \t\f;]+ -> channel(HIDDEN); -TEXT : ~('\n' | '\r'); +NEWLINE + : '\r'? '\n' + ; + +COMMENTLINE + : COMMENTTAG ~('\n' | '\r')* -> channel(HIDDEN) + ; + +WS + : [ \t\f;]+ -> channel(HIDDEN) + ; +TEXT + : ~('\n' | '\r') + ; // case insensitive chars -fragment A:('a'|'A'); -fragment B:('b'|'B'); -fragment C:('c'|'C'); -fragment D:('d'|'D'); -fragment E:('e'|'E'); -fragment F:('f'|'F'); -fragment G:('g'|'G'); -fragment H:('h'|'H'); -fragment I:('i'|'I'); -fragment J:('j'|'J'); -fragment K:('k'|'K'); -fragment L:('l'|'L'); -fragment M:('m'|'M'); -fragment N:('n'|'N'); -fragment O:('o'|'O'); -fragment P:('p'|'P'); -fragment Q:('q'|'Q'); -fragment R:('r'|'R'); -fragment S:('s'|'S'); -fragment T:('t'|'T'); -fragment U:('u'|'U'); -fragment V:('v'|'V'); -fragment W:('w'|'W'); -fragment X:('x'|'X'); -fragment Y:('y'|'Y'); -fragment Z:('z'|'Z'); \ No newline at end of file +fragment A + : ('a' | 'A') + ; + +fragment B + : ('b' | 'B') + ; + +fragment C + : ('c' | 'C') + ; + +fragment D + : ('d' | 'D') + ; + +fragment E + : ('e' | 'E') + ; + +fragment F + : ('f' | 'F') + ; + +fragment G + : ('g' | 'G') + ; + +fragment H + : ('h' | 'H') + ; + +fragment I + : ('i' | 'I') + ; + +fragment J + : ('j' | 'J') + ; + +fragment K + : ('k' | 'K') + ; + +fragment L + : ('l' | 'L') + ; + +fragment M + : ('m' | 'M') + ; + +fragment N + : ('n' | 'N') + ; + +fragment O + : ('o' | 'O') + ; + +fragment P + : ('p' | 'P') + ; + +fragment Q + : ('q' | 'Q') + ; + +fragment R + : ('r' | 'R') + ; + +fragment S + : ('s' | 'S') + ; + +fragment T + : ('t' | 'T') + ; + +fragment U + : ('u' | 'U') + ; + +fragment V + : ('v' | 'V') + ; + +fragment W + : ('w' | 'W') + ; + +fragment X + : ('x' | 'X') + ; + +fragment Y + : ('y' | 'Y') + ; + +fragment Z + : ('z' | 'Z') + ; \ No newline at end of file diff --git a/cookie/cookie.g4 b/cookie/cookie.g4 index 7805f6c12c..9ae0173d7f 100644 --- a/cookie/cookie.g4 +++ b/cookie/cookie.g4 @@ -26,61 +26,60 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar cookie; cookie - : av_pairs* EOF - ; + : av_pairs* EOF + ; name - : attr - ; + : attr + ; av_pairs - : av_pair (';' av_pair)* - ; + : av_pair (';' av_pair)* + ; av_pair - : attr ('=' value)? - ; + : attr ('=' value)? + ; attr - : token - ; + : token + ; value - : word - ; + : word + ; word - : token - | quoted_string - ; + : token + | quoted_string + ; token - : TOKEN - ; + : TOKEN + ; quoted_string - : STRING - ; - + : STRING + ; STRING - : '"' (~ ('"' | '\n'))* '"' - ; - + : '"' (~ ('"' | '\n'))* '"' + ; TOKEN - : ('0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' | '-' | ' ' | '/' | '_' | ':' | ',')+ - ; - + : ('0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' | '-' | ' ' | '/' | '_' | ':' | ',')+ + ; DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; WS - : [\t\r\n] -> skip - ; + : [\t\r\n] -> skip + ; \ No newline at end of file diff --git a/cpp/CPP14Lexer.g4 b/cpp/CPP14Lexer.g4 index dfda5cad2f..897f6aec97 100644 --- a/cpp/CPP14Lexer.g4 +++ b/cpp/CPP14Lexer.g4 @@ -1,35 +1,37 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar CPP14Lexer; IntegerLiteral: - DecimalLiteral Integersuffix? - | OctalLiteral Integersuffix? - | HexadecimalLiteral Integersuffix? - | BinaryLiteral Integersuffix?; + DecimalLiteral Integersuffix? + | OctalLiteral Integersuffix? + | HexadecimalLiteral Integersuffix? + | BinaryLiteral Integersuffix? +; -CharacterLiteral: - ('u' | 'U' | 'L')? '\'' Cchar+ '\''; +CharacterLiteral: ('u' | 'U' | 'L')? '\'' Cchar+ '\''; FloatingLiteral: - Fractionalconstant Exponentpart? Floatingsuffix? - | Digitsequence Exponentpart Floatingsuffix?; + Fractionalconstant Exponentpart? Floatingsuffix? + | Digitsequence Exponentpart Floatingsuffix? +; -StringLiteral: - Encodingprefix? - (Rawstring - |'"' Schar* '"'); +StringLiteral: Encodingprefix? (Rawstring | '"' Schar* '"'); BooleanLiteral: False_ | True_; PointerLiteral: Nullptr; UserDefinedLiteral: - UserDefinedIntegerLiteral - | UserDefinedFloatingLiteral - | UserDefinedStringLiteral - | UserDefinedCharacterLiteral; + UserDefinedIntegerLiteral + | UserDefinedFloatingLiteral + | UserDefinedStringLiteral + | UserDefinedCharacterLiteral +; -MultiLineMacro: - '#' (~[\n]*? '\\' '\r'? '\n')+ ~ [\n]+ -> channel (HIDDEN); +MultiLineMacro: '#' (~[\n]*? '\\' '\r'? '\n')+ ~ [\n]+ -> channel (HIDDEN); Directive: '#' ~ [\n]* -> channel (HIDDEN); /*Keywords*/ @@ -281,18 +283,15 @@ DotStar: '.*'; Ellipsis: '...'; -fragment Hexquad: - HEXADECIMALDIGIT HEXADECIMALDIGIT HEXADECIMALDIGIT HEXADECIMALDIGIT; +fragment Hexquad: HEXADECIMALDIGIT HEXADECIMALDIGIT HEXADECIMALDIGIT HEXADECIMALDIGIT; -fragment Universalcharactername: - '\\u' Hexquad - | '\\U' Hexquad Hexquad; +fragment Universalcharactername: '\\u' Hexquad | '\\U' Hexquad Hexquad; Identifier: - /* + /* Identifiernondigit | Identifier Identifiernondigit | Identifier DIGIT - */ - Identifiernondigit (Identifiernondigit | DIGIT)*; + */ Identifiernondigit (Identifiernondigit | DIGIT)* +; fragment Identifiernondigit: NONDIGIT | Universalcharactername; @@ -304,9 +303,7 @@ DecimalLiteral: NONZERODIGIT ('\''? DIGIT)*; OctalLiteral: '0' ('\''? OCTALDIGIT)*; -HexadecimalLiteral: ('0x' | '0X') HEXADECIMALDIGIT ( - '\''? HEXADECIMALDIGIT - )*; +HexadecimalLiteral: ('0x' | '0X') HEXADECIMALDIGIT ( '\''? HEXADECIMALDIGIT)*; BinaryLiteral: ('0b' | '0B') BINARYDIGIT ('\''? BINARYDIGIT)*; @@ -319,10 +316,11 @@ fragment HEXADECIMALDIGIT: [0-9a-fA-F]; fragment BINARYDIGIT: [01]; Integersuffix: - Unsignedsuffix Longsuffix? - | Unsignedsuffix Longlongsuffix? - | Longsuffix Unsignedsuffix? - | Longlongsuffix Unsignedsuffix?; + Unsignedsuffix Longsuffix? + | Unsignedsuffix Longlongsuffix? + | Longsuffix Unsignedsuffix? + | Longlongsuffix Unsignedsuffix? +; fragment Unsignedsuffix: [uU]; @@ -330,44 +328,36 @@ fragment Longsuffix: [lL]; fragment Longlongsuffix: 'll' | 'LL'; -fragment Cchar: - ~ ['\\\r\n] - | Escapesequence - | Universalcharactername; +fragment Cchar: ~ ['\\\r\n] | Escapesequence | Universalcharactername; -fragment Escapesequence: - Simpleescapesequence - | Octalescapesequence - | Hexadecimalescapesequence; +fragment Escapesequence: Simpleescapesequence | Octalescapesequence | Hexadecimalescapesequence; fragment Simpleescapesequence: - '\\\'' - | '\\"' - | '\\?' - | '\\\\' - | '\\a' - | '\\b' - | '\\f' - | '\\n' - | '\\r' - | '\\' ('\r' '\n'? | '\n') - | '\\t' - | '\\v'; + '\\\'' + | '\\"' + | '\\?' + | '\\\\' + | '\\a' + | '\\b' + | '\\f' + | '\\n' + | '\\r' + | '\\' ('\r' '\n'? | '\n') + | '\\t' + | '\\v' +; fragment Octalescapesequence: - '\\' OCTALDIGIT - | '\\' OCTALDIGIT OCTALDIGIT - | '\\' OCTALDIGIT OCTALDIGIT OCTALDIGIT; + '\\' OCTALDIGIT + | '\\' OCTALDIGIT OCTALDIGIT + | '\\' OCTALDIGIT OCTALDIGIT OCTALDIGIT +; fragment Hexadecimalescapesequence: '\\x' HEXADECIMALDIGIT+; -fragment Fractionalconstant: - Digitsequence? '.' Digitsequence - | Digitsequence '.'; +fragment Fractionalconstant: Digitsequence? '.' Digitsequence | Digitsequence '.'; -fragment Exponentpart: - 'e' SIGN? Digitsequence - | 'E' SIGN? Digitsequence; +fragment Exponentpart: 'e' SIGN? Digitsequence | 'E' SIGN? Digitsequence; fragment SIGN: [+-]; @@ -377,22 +367,21 @@ fragment Floatingsuffix: [flFL]; fragment Encodingprefix: 'u8' | 'u' | 'U' | 'L'; -fragment Schar: - ~ ["\\\r\n] - | Escapesequence - | Universalcharactername; +fragment Schar: ~ ["\\\r\n] | Escapesequence | Universalcharactername; -fragment Rawstring: 'R"' ( '\\' ["()] |~[\r\n (])*? '(' ~[)]*? ')' ( '\\' ["()] | ~[\r\n "])*? '"'; +fragment Rawstring: 'R"' ( '\\' ["()] | ~[\r\n (])*? '(' ~[)]*? ')' ( '\\' ["()] | ~[\r\n "])*? '"'; UserDefinedIntegerLiteral: - DecimalLiteral Udsuffix - | OctalLiteral Udsuffix - | HexadecimalLiteral Udsuffix - | BinaryLiteral Udsuffix; + DecimalLiteral Udsuffix + | OctalLiteral Udsuffix + | HexadecimalLiteral Udsuffix + | BinaryLiteral Udsuffix +; UserDefinedFloatingLiteral: - Fractionalconstant Exponentpart? Udsuffix - | Digitsequence Exponentpart Udsuffix; + Fractionalconstant Exponentpart? Udsuffix + | Digitsequence Exponentpart Udsuffix +; UserDefinedStringLiteral: StringLiteral Udsuffix; @@ -406,4 +395,4 @@ Newline: ('\r' '\n'? | '\n') -> skip; BlockComment: '/*' .*? '*/' -> skip; -LineComment: '//' ~ [\r\n]* -> skip; +LineComment: '//' ~ [\r\n]* -> skip; \ No newline at end of file diff --git a/cpp/CPP14Parser.g4 b/cpp/CPP14Parser.g4 index 0eb8ddb1c1..b8ec3120e7 100644 --- a/cpp/CPP14Parser.g4 +++ b/cpp/CPP14Parser.g4 @@ -19,812 +19,1062 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************** */ + +// $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 CPP14Parser; options { - superClass = CPP14ParserBase; - tokenVocab = CPP14Lexer; + superClass = CPP14ParserBase; + tokenVocab = CPP14Lexer; } // Insert here @header for C++ parser. /*Basic concepts*/ -translationUnit: declarationseq? EOF; +translationUnit + : declarationseq? EOF + ; + /*Expressions*/ -primaryExpression: - literal+ - | This - | LeftParen expression RightParen - | idExpression - | lambdaExpression; - -idExpression: unqualifiedId | qualifiedId; - -unqualifiedId: - Identifier - | operatorFunctionId - | conversionFunctionId - | literalOperatorId - | Tilde (className | decltypeSpecifier) - | templateId; - -qualifiedId: nestedNameSpecifier Template? unqualifiedId; - -nestedNameSpecifier: - (theTypeName | namespaceName | decltypeSpecifier)? Doublecolon - | nestedNameSpecifier ( - Identifier - | Template? simpleTemplateId - ) Doublecolon; -lambdaExpression: - lambdaIntroducer lambdaDeclarator? compoundStatement; - -lambdaIntroducer: LeftBracket lambdaCapture? RightBracket; - -lambdaCapture: - captureList - | captureDefault (Comma captureList)?; - -captureDefault: And | Assign; - -captureList: capture (Comma capture)* Ellipsis?; - -capture: simpleCapture | initcapture; - -simpleCapture: And? Identifier | This; - -initcapture: And? Identifier initializer; - -lambdaDeclarator: - LeftParen parameterDeclarationClause? RightParen Mutable? exceptionSpecification? - attributeSpecifierSeq? trailingReturnType?; - -postfixExpression: - primaryExpression - | postfixExpression LeftBracket (expression | bracedInitList) RightBracket - | postfixExpression LeftParen expressionList? RightParen - | (simpleTypeSpecifier | typeNameSpecifier) ( - LeftParen expressionList? RightParen - | bracedInitList - ) - | postfixExpression (Dot | Arrow) ( - Template? idExpression - | pseudoDestructorName - ) - | postfixExpression (PlusPlus | MinusMinus) - | ( - Dynamic_cast - | Static_cast - | Reinterpret_cast - | Const_cast - ) Less theTypeId Greater LeftParen expression RightParen - | typeIdOfTheTypeId LeftParen (expression | theTypeId) RightParen; +primaryExpression + : literal+ + | This + | LeftParen expression RightParen + | idExpression + | lambdaExpression + ; + +idExpression + : unqualifiedId + | qualifiedId + ; + +unqualifiedId + : Identifier + | operatorFunctionId + | conversionFunctionId + | literalOperatorId + | Tilde (className | decltypeSpecifier) + | templateId + ; + +qualifiedId + : nestedNameSpecifier Template? unqualifiedId + ; + +nestedNameSpecifier + : (theTypeName | namespaceName | decltypeSpecifier)? Doublecolon + | nestedNameSpecifier ( Identifier | Template? simpleTemplateId) Doublecolon + ; + +lambdaExpression + : lambdaIntroducer lambdaDeclarator? compoundStatement + ; + +lambdaIntroducer + : LeftBracket lambdaCapture? RightBracket + ; + +lambdaCapture + : captureList + | captureDefault (Comma captureList)? + ; + +captureDefault + : And + | Assign + ; + +captureList + : capture (Comma capture)* Ellipsis? + ; + +capture + : simpleCapture + | initcapture + ; + +simpleCapture + : And? Identifier + | This + ; + +initcapture + : And? Identifier initializer + ; + +lambdaDeclarator + : LeftParen parameterDeclarationClause? RightParen Mutable? exceptionSpecification? attributeSpecifierSeq? trailingReturnType? + ; + +postfixExpression + : primaryExpression + | postfixExpression LeftBracket (expression | bracedInitList) RightBracket + | postfixExpression LeftParen expressionList? RightParen + | (simpleTypeSpecifier | typeNameSpecifier) ( + LeftParen expressionList? RightParen + | bracedInitList + ) + | postfixExpression (Dot | Arrow) (Template? idExpression | pseudoDestructorName) + | postfixExpression (PlusPlus | MinusMinus) + | (Dynamic_cast | Static_cast | Reinterpret_cast | Const_cast) Less theTypeId Greater LeftParen expression RightParen + | typeIdOfTheTypeId LeftParen (expression | theTypeId) RightParen + ; + /* add a middle layer to eliminate duplicated function declarations */ -typeIdOfTheTypeId: Typeid_; +typeIdOfTheTypeId + : Typeid_ + ; -expressionList: initializerList; +expressionList + : initializerList + ; -pseudoDestructorName: - nestedNameSpecifier? (theTypeName Doublecolon)? Tilde theTypeName - | nestedNameSpecifier Template simpleTemplateId Doublecolon Tilde theTypeName - | Tilde decltypeSpecifier; +pseudoDestructorName + : nestedNameSpecifier? (theTypeName Doublecolon)? Tilde theTypeName + | nestedNameSpecifier Template simpleTemplateId Doublecolon Tilde theTypeName + | Tilde decltypeSpecifier + ; -unaryExpression: - postfixExpression - | (PlusPlus | MinusMinus | unaryOperator | Sizeof) unaryExpression - | Sizeof ( - LeftParen theTypeId RightParen - | Ellipsis LeftParen Identifier RightParen - ) - | Alignof LeftParen theTypeId RightParen - | noExceptExpression - | newExpression_ - | deleteExpression; +unaryExpression + : postfixExpression + | (PlusPlus | MinusMinus | unaryOperator | Sizeof) unaryExpression + | Sizeof (LeftParen theTypeId RightParen | Ellipsis LeftParen Identifier RightParen) + | Alignof LeftParen theTypeId RightParen + | noExceptExpression + | newExpression_ + | deleteExpression + ; -unaryOperator: Or | Star | And | Plus | Tilde | Minus | Not; +unaryOperator + : Or + | Star + | And + | Plus + | Tilde + | Minus + | Not + ; -newExpression_: - Doublecolon? New newPlacement? ( - newTypeId - | LeftParen theTypeId RightParen - ) newInitializer_?; +newExpression_ + : Doublecolon? New newPlacement? (newTypeId | LeftParen theTypeId RightParen) newInitializer_? + ; -newPlacement: LeftParen expressionList RightParen; +newPlacement + : LeftParen expressionList RightParen + ; -newTypeId: typeSpecifierSeq newDeclarator_?; +newTypeId + : typeSpecifierSeq newDeclarator_? + ; -newDeclarator_: - pointerOperator newDeclarator_? - | noPointerNewDeclarator; +newDeclarator_ + : pointerOperator newDeclarator_? + | noPointerNewDeclarator + ; -noPointerNewDeclarator: - LeftBracket expression RightBracket attributeSpecifierSeq? - | noPointerNewDeclarator LeftBracket constantExpression RightBracket attributeSpecifierSeq?; +noPointerNewDeclarator + : LeftBracket expression RightBracket attributeSpecifierSeq? + | noPointerNewDeclarator LeftBracket constantExpression RightBracket attributeSpecifierSeq? + ; -newInitializer_: - LeftParen expressionList? RightParen - | bracedInitList; +newInitializer_ + : LeftParen expressionList? RightParen + | bracedInitList + ; -deleteExpression: - Doublecolon? Delete (LeftBracket RightBracket)? castExpression; +deleteExpression + : Doublecolon? Delete (LeftBracket RightBracket)? castExpression + ; -noExceptExpression: Noexcept LeftParen expression RightParen; +noExceptExpression + : Noexcept LeftParen expression RightParen + ; -castExpression: - unaryExpression - | LeftParen theTypeId RightParen castExpression; +castExpression + : unaryExpression + | LeftParen theTypeId RightParen castExpression + ; -pointerMemberExpression: - castExpression ((DotStar | ArrowStar) castExpression)*; +pointerMemberExpression + : castExpression ((DotStar | ArrowStar) castExpression)* + ; -multiplicativeExpression: - pointerMemberExpression ( - (Star | Div | Mod) pointerMemberExpression - )*; +multiplicativeExpression + : pointerMemberExpression ((Star | Div | Mod) pointerMemberExpression)* + ; -additiveExpression: - multiplicativeExpression ( - (Plus | Minus) multiplicativeExpression - )*; +additiveExpression + : multiplicativeExpression ((Plus | Minus) multiplicativeExpression)* + ; -shiftExpression: - additiveExpression (shiftOperator additiveExpression)*; +shiftExpression + : additiveExpression (shiftOperator additiveExpression)* + ; -shiftOperator: Greater Greater | Less Less; +shiftOperator + : Greater Greater + | Less Less + ; -relationalExpression: - shiftExpression ( - (Less | Greater | LessEqual | GreaterEqual) shiftExpression - )*; +relationalExpression + : shiftExpression ((Less | Greater | LessEqual | GreaterEqual) shiftExpression)* + ; -equalityExpression: - relationalExpression ( - (Equal | NotEqual) relationalExpression - )*; +equalityExpression + : relationalExpression ((Equal | NotEqual) relationalExpression)* + ; -andExpression: equalityExpression (And equalityExpression)*; +andExpression + : equalityExpression (And equalityExpression)* + ; -exclusiveOrExpression: andExpression (Caret andExpression)*; +exclusiveOrExpression + : andExpression (Caret andExpression)* + ; -inclusiveOrExpression: - exclusiveOrExpression (Or exclusiveOrExpression)*; +inclusiveOrExpression + : exclusiveOrExpression (Or exclusiveOrExpression)* + ; -logicalAndExpression: - inclusiveOrExpression (AndAnd inclusiveOrExpression)*; +logicalAndExpression + : inclusiveOrExpression (AndAnd inclusiveOrExpression)* + ; -logicalOrExpression: - logicalAndExpression (OrOr logicalAndExpression)*; +logicalOrExpression + : logicalAndExpression (OrOr logicalAndExpression)* + ; -conditionalExpression: - logicalOrExpression ( - Question expression Colon assignmentExpression - )?; +conditionalExpression + : logicalOrExpression (Question expression Colon assignmentExpression)? + ; -assignmentExpression: - conditionalExpression - | logicalOrExpression assignmentOperator initializerClause - | throwExpression; - -assignmentOperator: - Assign - | StarAssign - | DivAssign - | ModAssign - | PlusAssign - | MinusAssign - | RightShiftAssign - | LeftShiftAssign - | AndAssign - | XorAssign - | OrAssign; +assignmentExpression + : conditionalExpression + | logicalOrExpression assignmentOperator initializerClause + | throwExpression + ; -expression: assignmentExpression (Comma assignmentExpression)*; +assignmentOperator + : Assign + | StarAssign + | DivAssign + | ModAssign + | PlusAssign + | MinusAssign + | RightShiftAssign + | LeftShiftAssign + | AndAssign + | XorAssign + | OrAssign + ; + +expression + : assignmentExpression (Comma assignmentExpression)* + ; + +constantExpression + : conditionalExpression + ; -constantExpression: conditionalExpression; /*Statements*/ -statement: - labeledStatement - | declarationStatement - | attributeSpecifierSeq? ( - expressionStatement - | compoundStatement - | selectionStatement - | iterationStatement - | jumpStatement - | tryBlock - ); - -labeledStatement: - attributeSpecifierSeq? ( - Identifier - | Case constantExpression - | Default - ) Colon statement; - -expressionStatement: expression? Semi; - -compoundStatement: LeftBrace statementSeq? RightBrace; - -statementSeq: statement+; - -selectionStatement: - If LeftParen condition RightParen statement (Else statement)? - | Switch LeftParen condition RightParen statement; - -condition: - expression - | attributeSpecifierSeq? declSpecifierSeq declarator ( - Assign initializerClause - | bracedInitList - ); - -iterationStatement: - While LeftParen condition RightParen statement - | Do statement While LeftParen expression RightParen Semi - | For LeftParen ( - forInitStatement condition? Semi expression? - | forRangeDeclaration Colon forRangeInitializer - ) RightParen statement; - -forInitStatement: expressionStatement | simpleDeclaration; - -forRangeDeclaration: - attributeSpecifierSeq? declSpecifierSeq declarator; - -forRangeInitializer: expression | bracedInitList; - -jumpStatement: - ( - Break - | Continue - | Return (expression | bracedInitList)? - | Goto Identifier - ) Semi; - -declarationStatement: blockDeclaration; +statement + : labeledStatement + | declarationStatement + | attributeSpecifierSeq? ( + expressionStatement + | compoundStatement + | selectionStatement + | iterationStatement + | jumpStatement + | tryBlock + ) + ; + +labeledStatement + : attributeSpecifierSeq? (Identifier | Case constantExpression | Default) Colon statement + ; + +expressionStatement + : expression? Semi + ; + +compoundStatement + : LeftBrace statementSeq? RightBrace + ; + +statementSeq + : statement+ + ; + +selectionStatement + : If LeftParen condition RightParen statement (Else statement)? + | Switch LeftParen condition RightParen statement + ; + +condition + : expression + | attributeSpecifierSeq? declSpecifierSeq declarator ( + Assign initializerClause + | bracedInitList + ) + ; + +iterationStatement + : While LeftParen condition RightParen statement + | Do statement While LeftParen expression RightParen Semi + | For LeftParen ( + forInitStatement condition? Semi expression? + | forRangeDeclaration Colon forRangeInitializer + ) RightParen statement + ; + +forInitStatement + : expressionStatement + | simpleDeclaration + ; + +forRangeDeclaration + : attributeSpecifierSeq? declSpecifierSeq declarator + ; + +forRangeInitializer + : expression + | bracedInitList + ; + +jumpStatement + : (Break | Continue | Return (expression | bracedInitList)? | Goto Identifier) Semi + ; + +declarationStatement + : blockDeclaration + ; + /*Declarations*/ -declarationseq: declaration+; - -declaration: - blockDeclaration - | functionDefinition - | templateDeclaration - | explicitInstantiation - | explicitSpecialization - | linkageSpecification - | namespaceDefinition - | emptyDeclaration_ - | attributeDeclaration; - -blockDeclaration: - simpleDeclaration - | asmDefinition - | namespaceAliasDefinition - | usingDeclaration - | usingDirective - | staticAssertDeclaration - | aliasDeclaration - | opaqueEnumDeclaration; - -aliasDeclaration: - Using Identifier attributeSpecifierSeq? Assign theTypeId Semi; - -simpleDeclaration: - declSpecifierSeq? initDeclaratorList? Semi - | attributeSpecifierSeq declSpecifierSeq? initDeclaratorList Semi; - -staticAssertDeclaration: - Static_assert LeftParen constantExpression Comma StringLiteral RightParen Semi; - -emptyDeclaration_: Semi; - -attributeDeclaration: attributeSpecifierSeq Semi; - -declSpecifier: - storageClassSpecifier - | typeSpecifier - | functionSpecifier - | Friend - | Typedef - | Constexpr; - -declSpecifierSeq: declSpecifier+? attributeSpecifierSeq?; - -storageClassSpecifier: - Register - | Static - | Thread_local - | Extern - | Mutable; - -functionSpecifier: Inline | Virtual | Explicit; - -typedefName: Identifier; - -typeSpecifier: - trailingTypeSpecifier - | classSpecifier - | enumSpecifier; - -trailingTypeSpecifier: - simpleTypeSpecifier - | elaboratedTypeSpecifier - | typeNameSpecifier - | cvQualifier; - -typeSpecifierSeq: typeSpecifier+ attributeSpecifierSeq?; - -trailingTypeSpecifierSeq: - trailingTypeSpecifier+ attributeSpecifierSeq?; - -simpleTypeLengthModifier: - Short - | Long; - -simpleTypeSignednessModifier: - Unsigned - | Signed; - -simpleTypeSpecifier: - nestedNameSpecifier? theTypeName - | nestedNameSpecifier Template simpleTemplateId - | Char - | Char16 - | Char32 - | Wchar - | Bool - | Short - | Int - | Long - | Float - | Signed - | Unsigned - | Float - | Double - | Void - | Auto - | decltypeSpecifier - ; - -theTypeName: - className - | enumName - | typedefName - | simpleTemplateId; - -decltypeSpecifier: - Decltype LeftParen (expression | Auto) RightParen; - -elaboratedTypeSpecifier: - classKey ( - attributeSpecifierSeq? nestedNameSpecifier? Identifier - | simpleTemplateId - | nestedNameSpecifier Template? simpleTemplateId - ) - | Enum nestedNameSpecifier? Identifier; +declarationseq + : declaration+ + ; -enumName: Identifier; +declaration + : blockDeclaration + | functionDefinition + | templateDeclaration + | explicitInstantiation + | explicitSpecialization + | linkageSpecification + | namespaceDefinition + | emptyDeclaration_ + | attributeDeclaration + ; -enumSpecifier: - enumHead LeftBrace (enumeratorList Comma?)? RightBrace; +blockDeclaration + : simpleDeclaration + | asmDefinition + | namespaceAliasDefinition + | usingDeclaration + | usingDirective + | staticAssertDeclaration + | aliasDeclaration + | opaqueEnumDeclaration + ; -enumHead: - enumkey attributeSpecifierSeq? ( - nestedNameSpecifier? Identifier - )? enumbase?; +aliasDeclaration + : Using Identifier attributeSpecifierSeq? Assign theTypeId Semi + ; -opaqueEnumDeclaration: - enumkey attributeSpecifierSeq? Identifier enumbase? Semi; +simpleDeclaration + : declSpecifierSeq? initDeclaratorList? Semi + | attributeSpecifierSeq declSpecifierSeq? initDeclaratorList Semi + ; -enumkey: Enum (Class | Struct)?; +staticAssertDeclaration + : Static_assert LeftParen constantExpression Comma StringLiteral RightParen Semi + ; -enumbase: Colon typeSpecifierSeq; - -enumeratorList: - enumeratorDefinition (Comma enumeratorDefinition)*; - -enumeratorDefinition: enumerator (Assign constantExpression)?; +emptyDeclaration_ + : Semi + ; -enumerator: Identifier; +attributeDeclaration + : attributeSpecifierSeq Semi + ; -namespaceName: originalNamespaceName | namespaceAlias; +declSpecifier + : storageClassSpecifier + | typeSpecifier + | functionSpecifier + | Friend + | Typedef + | Constexpr + ; -originalNamespaceName: Identifier; +declSpecifierSeq + : declSpecifier+? attributeSpecifierSeq? + ; -namespaceDefinition: - Inline? Namespace (Identifier | originalNamespaceName)? LeftBrace namespaceBody = declarationseq - ? RightBrace; +storageClassSpecifier + : Register + | Static + | Thread_local + | Extern + | Mutable + ; -namespaceAlias: Identifier; +functionSpecifier + : Inline + | Virtual + | Explicit + ; -namespaceAliasDefinition: - Namespace Identifier Assign qualifiednamespacespecifier Semi; +typedefName + : Identifier + ; -qualifiednamespacespecifier: nestedNameSpecifier? namespaceName; +typeSpecifier + : trailingTypeSpecifier + | classSpecifier + | enumSpecifier + ; -usingDeclaration: - Using (Typename_? nestedNameSpecifier | Doublecolon) unqualifiedId Semi; +trailingTypeSpecifier + : simpleTypeSpecifier + | elaboratedTypeSpecifier + | typeNameSpecifier + | cvQualifier + ; -usingDirective: - attributeSpecifierSeq? Using Namespace nestedNameSpecifier? namespaceName Semi; +typeSpecifierSeq + : typeSpecifier+ attributeSpecifierSeq? + ; -asmDefinition: Asm LeftParen StringLiteral RightParen Semi; +trailingTypeSpecifierSeq + : trailingTypeSpecifier+ attributeSpecifierSeq? + ; -linkageSpecification: - Extern StringLiteral ( - LeftBrace declarationseq? RightBrace - | declaration - ); +simpleTypeLengthModifier + : Short + | Long + ; -attributeSpecifierSeq: attributeSpecifier+; +simpleTypeSignednessModifier + : Unsigned + | Signed + ; -attributeSpecifier: - LeftBracket LeftBracket attributeList? RightBracket RightBracket - | alignmentspecifier; +simpleTypeSpecifier + : nestedNameSpecifier? theTypeName + | nestedNameSpecifier Template simpleTemplateId + | Char + | Char16 + | Char32 + | Wchar + | Bool + | Short + | Int + | Long + | Float + | Signed + | Unsigned + | Float + | Double + | Void + | Auto + | decltypeSpecifier + ; + +theTypeName + : className + | enumName + | typedefName + | simpleTemplateId + ; -alignmentspecifier: - Alignas LeftParen (theTypeId | constantExpression) Ellipsis? RightParen; +decltypeSpecifier + : Decltype LeftParen (expression | Auto) RightParen + ; -attributeList: attribute (Comma attribute)* Ellipsis?; +elaboratedTypeSpecifier + : classKey ( + attributeSpecifierSeq? nestedNameSpecifier? Identifier + | simpleTemplateId + | nestedNameSpecifier Template? simpleTemplateId + ) + | Enum nestedNameSpecifier? Identifier + ; -attribute: (attributeNamespace Doublecolon)? Identifier attributeArgumentClause?; +enumName + : Identifier + ; -attributeNamespace: Identifier; +enumSpecifier + : enumHead LeftBrace (enumeratorList Comma?)? RightBrace + ; -attributeArgumentClause: LeftParen balancedTokenSeq? RightParen; +enumHead + : enumkey attributeSpecifierSeq? (nestedNameSpecifier? Identifier)? enumbase? + ; -balancedTokenSeq: balancedtoken+; +opaqueEnumDeclaration + : enumkey attributeSpecifierSeq? Identifier enumbase? Semi + ; + +enumkey + : Enum (Class | Struct)? + ; + +enumbase + : Colon typeSpecifierSeq + ; + +enumeratorList + : enumeratorDefinition (Comma enumeratorDefinition)* + ; + +enumeratorDefinition + : enumerator (Assign constantExpression)? + ; + +enumerator + : Identifier + ; + +namespaceName + : originalNamespaceName + | namespaceAlias + ; + +originalNamespaceName + : Identifier + ; + +namespaceDefinition + : Inline? Namespace (Identifier | originalNamespaceName)? LeftBrace namespaceBody = declarationseq? RightBrace + ; + +namespaceAlias + : Identifier + ; + +namespaceAliasDefinition + : Namespace Identifier Assign qualifiednamespacespecifier Semi + ; + +qualifiednamespacespecifier + : nestedNameSpecifier? namespaceName + ; + +usingDeclaration + : Using (Typename_? nestedNameSpecifier | Doublecolon) unqualifiedId Semi + ; + +usingDirective + : attributeSpecifierSeq? Using Namespace nestedNameSpecifier? namespaceName Semi + ; + +asmDefinition + : Asm LeftParen StringLiteral RightParen Semi + ; + +linkageSpecification + : Extern StringLiteral (LeftBrace declarationseq? RightBrace | declaration) + ; + +attributeSpecifierSeq + : attributeSpecifier+ + ; + +attributeSpecifier + : LeftBracket LeftBracket attributeList? RightBracket RightBracket + | alignmentspecifier + ; + +alignmentspecifier + : Alignas LeftParen (theTypeId | constantExpression) Ellipsis? RightParen + ; + +attributeList + : attribute (Comma attribute)* Ellipsis? + ; + +attribute + : (attributeNamespace Doublecolon)? Identifier attributeArgumentClause? + ; + +attributeNamespace + : Identifier + ; + +attributeArgumentClause + : LeftParen balancedTokenSeq? RightParen + ; + +balancedTokenSeq + : balancedtoken+ + ; + +balancedtoken + : LeftParen balancedTokenSeq RightParen + | LeftBracket balancedTokenSeq RightBracket + | LeftBrace balancedTokenSeq RightBrace + | ~(LeftParen | RightParen | LeftBrace | RightBrace | LeftBracket | RightBracket)+ + ; -balancedtoken: - LeftParen balancedTokenSeq RightParen - | LeftBracket balancedTokenSeq RightBracket - | LeftBrace balancedTokenSeq RightBrace - | ~( - LeftParen - | RightParen - | LeftBrace - | RightBrace - | LeftBracket - | RightBracket - )+; /*Declarators*/ -initDeclaratorList: initDeclarator (Comma initDeclarator)*; +initDeclaratorList + : initDeclarator (Comma initDeclarator)* + ; -initDeclarator: declarator initializer?; +initDeclarator + : declarator initializer? + ; -declarator: - pointerDeclarator - | noPointerDeclarator parametersAndQualifiers trailingReturnType; +declarator + : pointerDeclarator + | noPointerDeclarator parametersAndQualifiers trailingReturnType + ; -pointerDeclarator: (pointerOperator Const?)* noPointerDeclarator; +pointerDeclarator + : (pointerOperator Const?)* noPointerDeclarator + ; -noPointerDeclarator: - declaratorid attributeSpecifierSeq? - | noPointerDeclarator ( - parametersAndQualifiers - | LeftBracket constantExpression? RightBracket attributeSpecifierSeq? - ) - | LeftParen pointerDeclarator RightParen; +noPointerDeclarator + : declaratorid attributeSpecifierSeq? + | noPointerDeclarator ( + parametersAndQualifiers + | LeftBracket constantExpression? RightBracket attributeSpecifierSeq? + ) + | LeftParen pointerDeclarator RightParen + ; -parametersAndQualifiers: - LeftParen parameterDeclarationClause? RightParen cvqualifierseq? refqualifier? - exceptionSpecification? attributeSpecifierSeq?; +parametersAndQualifiers + : LeftParen parameterDeclarationClause? RightParen cvqualifierseq? refqualifier? exceptionSpecification? attributeSpecifierSeq? + ; -trailingReturnType: - Arrow trailingTypeSpecifierSeq abstractDeclarator?; +trailingReturnType + : Arrow trailingTypeSpecifierSeq abstractDeclarator? + ; -pointerOperator: - (And | AndAnd) attributeSpecifierSeq? - | nestedNameSpecifier? Star attributeSpecifierSeq? cvqualifierseq?; +pointerOperator + : (And | AndAnd) attributeSpecifierSeq? + | nestedNameSpecifier? Star attributeSpecifierSeq? cvqualifierseq? + ; -cvqualifierseq: cvQualifier+; +cvqualifierseq + : cvQualifier+ + ; -cvQualifier: Const | Volatile; +cvQualifier + : Const + | Volatile + ; -refqualifier: And | AndAnd; +refqualifier + : And + | AndAnd + ; -declaratorid: Ellipsis? idExpression; +declaratorid + : Ellipsis? idExpression + ; -theTypeId: typeSpecifierSeq abstractDeclarator?; +theTypeId + : typeSpecifierSeq abstractDeclarator? + ; -abstractDeclarator: - pointerAbstractDeclarator - | noPointerAbstractDeclarator? parametersAndQualifiers trailingReturnType - | abstractPackDeclarator; +abstractDeclarator + : pointerAbstractDeclarator + | noPointerAbstractDeclarator? parametersAndQualifiers trailingReturnType + | abstractPackDeclarator + ; -pointerAbstractDeclarator: - noPointerAbstractDeclarator - | pointerOperator+ noPointerAbstractDeclarator?; +pointerAbstractDeclarator + : noPointerAbstractDeclarator + | pointerOperator+ noPointerAbstractDeclarator? + ; -noPointerAbstractDeclarator: - noPointerAbstractDeclarator ( - parametersAndQualifiers - | noPointerAbstractDeclarator LeftBracket constantExpression? RightBracket - attributeSpecifierSeq? - ) - | parametersAndQualifiers - | LeftBracket constantExpression? RightBracket attributeSpecifierSeq? - | LeftParen pointerAbstractDeclarator RightParen; +noPointerAbstractDeclarator + : noPointerAbstractDeclarator ( + parametersAndQualifiers + | noPointerAbstractDeclarator LeftBracket constantExpression? RightBracket attributeSpecifierSeq? + ) + | parametersAndQualifiers + | LeftBracket constantExpression? RightBracket attributeSpecifierSeq? + | LeftParen pointerAbstractDeclarator RightParen + ; -abstractPackDeclarator: - pointerOperator* noPointerAbstractPackDeclarator; +abstractPackDeclarator + : pointerOperator* noPointerAbstractPackDeclarator + ; -noPointerAbstractPackDeclarator: - noPointerAbstractPackDeclarator ( - parametersAndQualifiers - | LeftBracket constantExpression? RightBracket attributeSpecifierSeq? - ) - | Ellipsis; +noPointerAbstractPackDeclarator + : noPointerAbstractPackDeclarator ( + parametersAndQualifiers + | LeftBracket constantExpression? RightBracket attributeSpecifierSeq? + ) + | Ellipsis + ; -parameterDeclarationClause: - parameterDeclarationList (Comma? Ellipsis)?; +parameterDeclarationClause + : parameterDeclarationList (Comma? Ellipsis)? + ; + +parameterDeclarationList + : parameterDeclaration (Comma parameterDeclaration)* + ; -parameterDeclarationList: - parameterDeclaration (Comma parameterDeclaration)*; +parameterDeclaration + : attributeSpecifierSeq? declSpecifierSeq (declarator | abstractDeclarator?) ( + Assign initializerClause + )? + ; -parameterDeclaration: - attributeSpecifierSeq? declSpecifierSeq (declarator | abstractDeclarator?) (Assign initializerClause)? - ; +functionDefinition + : attributeSpecifierSeq? declSpecifierSeq? declarator virtualSpecifierSeq? functionBody + ; -functionDefinition: - attributeSpecifierSeq? declSpecifierSeq? declarator virtualSpecifierSeq? functionBody; +functionBody + : constructorInitializer? compoundStatement + | functionTryBlock + | Assign (Default | Delete) Semi + ; -functionBody: - constructorInitializer? compoundStatement - | functionTryBlock - | Assign (Default | Delete) Semi; +initializer + : braceOrEqualInitializer + | LeftParen expressionList RightParen + ; -initializer: - braceOrEqualInitializer - | LeftParen expressionList RightParen; +braceOrEqualInitializer + : Assign initializerClause + | bracedInitList + ; -braceOrEqualInitializer: - Assign initializerClause - | bracedInitList; +initializerClause + : assignmentExpression + | bracedInitList + ; -initializerClause: assignmentExpression | bracedInitList; +initializerList + : initializerClause Ellipsis? (Comma initializerClause Ellipsis?)* + ; -initializerList: - initializerClause Ellipsis? ( - Comma initializerClause Ellipsis? - )*; +bracedInitList + : LeftBrace (initializerList Comma?)? RightBrace + ; -bracedInitList: LeftBrace (initializerList Comma?)? RightBrace; /*Classes*/ -className: Identifier | simpleTemplateId; +className + : Identifier + | simpleTemplateId + ; -classSpecifier: - classHead LeftBrace memberSpecification? RightBrace; +classSpecifier + : classHead LeftBrace memberSpecification? RightBrace + ; -classHead: - classKey attributeSpecifierSeq? ( - classHeadName classVirtSpecifier? - )? baseClause? - | Union attributeSpecifierSeq? ( - classHeadName classVirtSpecifier? - )?; +classHead + : classKey attributeSpecifierSeq? (classHeadName classVirtSpecifier?)? baseClause? + | Union attributeSpecifierSeq? ( classHeadName classVirtSpecifier?)? + ; -classHeadName: nestedNameSpecifier? className; +classHeadName + : nestedNameSpecifier? className + ; -classVirtSpecifier: Final; +classVirtSpecifier + : Final + ; -classKey: Class | Struct; +classKey + : Class + | Struct + ; -memberSpecification: - (memberdeclaration | accessSpecifier Colon)+; +memberSpecification + : (memberdeclaration | accessSpecifier Colon)+ + ; -memberdeclaration: - attributeSpecifierSeq? declSpecifierSeq? memberDeclaratorList? Semi - | functionDefinition - | usingDeclaration - | staticAssertDeclaration - | templateDeclaration - | aliasDeclaration - | emptyDeclaration_; +memberdeclaration + : attributeSpecifierSeq? declSpecifierSeq? memberDeclaratorList? Semi + | functionDefinition + | usingDeclaration + | staticAssertDeclaration + | templateDeclaration + | aliasDeclaration + | emptyDeclaration_ + ; -memberDeclaratorList: - memberDeclarator (Comma memberDeclarator)*; +memberDeclaratorList + : memberDeclarator (Comma memberDeclarator)* + ; -memberDeclarator: - declarator (virtualSpecifierSeq | { this.IsPureSpecifierAllowed() }? pureSpecifier | { this.IsPureSpecifierAllowed() }? virtualSpecifierSeq pureSpecifier | braceOrEqualInitializer) +memberDeclarator + : declarator ( + virtualSpecifierSeq + | { this.IsPureSpecifierAllowed() }? pureSpecifier + | { this.IsPureSpecifierAllowed() }? virtualSpecifierSeq pureSpecifier + | braceOrEqualInitializer + ) | declarator | Identifier? attributeSpecifierSeq? Colon constantExpression ; -virtualSpecifierSeq: virtualSpecifier+; +virtualSpecifierSeq + : virtualSpecifier+ + ; -virtualSpecifier: Override | Final; +virtualSpecifier + : Override + | Final + ; /* purespecifier: Assign '0'//Conflicts with the lexer ; */ -pureSpecifier: - Assign IntegerLiteral +pureSpecifier + : Assign IntegerLiteral ; /*Derived classes*/ -baseClause: Colon baseSpecifierList; +baseClause + : Colon baseSpecifierList + ; + +baseSpecifierList + : baseSpecifier Ellipsis? (Comma baseSpecifier Ellipsis?)* + ; -baseSpecifierList: - baseSpecifier Ellipsis? (Comma baseSpecifier Ellipsis?)*; +baseSpecifier + : attributeSpecifierSeq? ( + baseTypeSpecifier + | Virtual accessSpecifier? baseTypeSpecifier + | accessSpecifier Virtual? baseTypeSpecifier + ) + ; -baseSpecifier: - attributeSpecifierSeq? ( - baseTypeSpecifier - | Virtual accessSpecifier? baseTypeSpecifier - | accessSpecifier Virtual? baseTypeSpecifier - ); +classOrDeclType + : nestedNameSpecifier? className + | decltypeSpecifier + ; -classOrDeclType: - nestedNameSpecifier? className - | decltypeSpecifier; +baseTypeSpecifier + : classOrDeclType + ; -baseTypeSpecifier: classOrDeclType; +accessSpecifier + : Private + | Protected + | Public + ; -accessSpecifier: Private | Protected | Public; /*Special member functions*/ -conversionFunctionId: Operator conversionTypeId; +conversionFunctionId + : Operator conversionTypeId + ; -conversionTypeId: typeSpecifierSeq conversionDeclarator?; +conversionTypeId + : typeSpecifierSeq conversionDeclarator? + ; -conversionDeclarator: pointerOperator conversionDeclarator?; +conversionDeclarator + : pointerOperator conversionDeclarator? + ; -constructorInitializer: Colon memInitializerList; +constructorInitializer + : Colon memInitializerList + ; -memInitializerList: - memInitializer Ellipsis? (Comma memInitializer Ellipsis?)*; +memInitializerList + : memInitializer Ellipsis? (Comma memInitializer Ellipsis?)* + ; -memInitializer: - meminitializerid ( - LeftParen expressionList? RightParen - | bracedInitList - ); +memInitializer + : meminitializerid (LeftParen expressionList? RightParen | bracedInitList) + ; + +meminitializerid + : classOrDeclType + | Identifier + ; -meminitializerid: classOrDeclType | Identifier; /*Overloading*/ -operatorFunctionId: Operator theOperator; +operatorFunctionId + : Operator theOperator + ; + +literalOperatorId + : Operator (StringLiteral Identifier | UserDefinedStringLiteral) + ; -literalOperatorId: - Operator ( - StringLiteral Identifier - | UserDefinedStringLiteral - ); /*Templates*/ -templateDeclaration: - Template Less templateparameterList Greater declaration; +templateDeclaration + : Template Less templateparameterList Greater declaration + ; -templateparameterList: - templateParameter (Comma templateParameter)*; +templateparameterList + : templateParameter (Comma templateParameter)* + ; -templateParameter: typeParameter | parameterDeclaration; +templateParameter + : typeParameter + | parameterDeclaration + ; -typeParameter: - ( - (Template Less templateparameterList Greater)? Class - | Typename_ - ) (Ellipsis? Identifier? | Identifier? Assign theTypeId); +typeParameter + : ((Template Less templateparameterList Greater)? Class | Typename_) ( + Ellipsis? Identifier? + | Identifier? Assign theTypeId + ) + ; -simpleTemplateId: - templateName Less templateArgumentList? Greater; +simpleTemplateId + : templateName Less templateArgumentList? Greater + ; -templateId: - simpleTemplateId - | (operatorFunctionId | literalOperatorId) Less templateArgumentList? Greater; +templateId + : simpleTemplateId + | (operatorFunctionId | literalOperatorId) Less templateArgumentList? Greater + ; -templateName: Identifier; +templateName + : Identifier + ; -templateArgumentList: - templateArgument Ellipsis? (Comma templateArgument Ellipsis?)*; +templateArgumentList + : templateArgument Ellipsis? (Comma templateArgument Ellipsis?)* + ; -templateArgument: theTypeId | constantExpression | idExpression; +templateArgument + : theTypeId + | constantExpression + | idExpression + ; -typeNameSpecifier: - Typename_ nestedNameSpecifier ( - Identifier - | Template? simpleTemplateId - ); +typeNameSpecifier + : Typename_ nestedNameSpecifier (Identifier | Template? simpleTemplateId) + ; -explicitInstantiation: Extern? Template declaration; +explicitInstantiation + : Extern? Template declaration + ; + +explicitSpecialization + : Template Less Greater declaration + ; -explicitSpecialization: Template Less Greater declaration; /*Exception handling*/ -tryBlock: Try compoundStatement handlerSeq; +tryBlock + : Try compoundStatement handlerSeq + ; -functionTryBlock: - Try constructorInitializer? compoundStatement handlerSeq; +functionTryBlock + : Try constructorInitializer? compoundStatement handlerSeq + ; -handlerSeq: handler+; +handlerSeq + : handler+ + ; -handler: - Catch LeftParen exceptionDeclaration RightParen compoundStatement; +handler + : Catch LeftParen exceptionDeclaration RightParen compoundStatement + ; -exceptionDeclaration: - attributeSpecifierSeq? typeSpecifierSeq ( - declarator - | abstractDeclarator - )? - | Ellipsis; +exceptionDeclaration + : attributeSpecifierSeq? typeSpecifierSeq (declarator | abstractDeclarator)? + | Ellipsis + ; -throwExpression: Throw assignmentExpression?; +throwExpression + : Throw assignmentExpression? + ; -exceptionSpecification: - dynamicExceptionSpecification - | noeExceptSpecification; +exceptionSpecification + : dynamicExceptionSpecification + | noeExceptSpecification + ; -dynamicExceptionSpecification: - Throw LeftParen typeIdList? RightParen; +dynamicExceptionSpecification + : Throw LeftParen typeIdList? RightParen + ; -typeIdList: theTypeId Ellipsis? (Comma theTypeId Ellipsis?)*; +typeIdList + : theTypeId Ellipsis? (Comma theTypeId Ellipsis?)* + ; + +noeExceptSpecification + : Noexcept LeftParen constantExpression RightParen + | Noexcept + ; -noeExceptSpecification: - Noexcept LeftParen constantExpression RightParen - | Noexcept; /*Preprocessing directives*/ /*Lexer*/ -theOperator: - New (LeftBracket RightBracket)? - | Delete (LeftBracket RightBracket)? - | Plus - | Minus - | Star - | Div - | Mod - | Caret - | And - | Or - | Tilde - | Not - | Assign - | Greater - | Less - | GreaterEqual - | PlusAssign - | MinusAssign - | StarAssign - | ModAssign - | XorAssign - | AndAssign - | OrAssign - | Less Less - | Greater Greater - | RightShiftAssign - | LeftShiftAssign - | Equal - | NotEqual - | LessEqual - | AndAnd - | OrOr - | PlusPlus - | MinusMinus - | Comma - | ArrowStar - | Arrow - | LeftParen RightParen - | LeftBracket RightBracket; - -literal: - IntegerLiteral - | CharacterLiteral - | FloatingLiteral - | StringLiteral - | BooleanLiteral - | PointerLiteral - | UserDefinedLiteral; - +theOperator + : New (LeftBracket RightBracket)? + | Delete (LeftBracket RightBracket)? + | Plus + | Minus + | Star + | Div + | Mod + | Caret + | And + | Or + | Tilde + | Not + | Assign + | Greater + | Less + | GreaterEqual + | PlusAssign + | MinusAssign + | StarAssign + | ModAssign + | XorAssign + | AndAssign + | OrAssign + | Less Less + | Greater Greater + | RightShiftAssign + | LeftShiftAssign + | Equal + | NotEqual + | LessEqual + | AndAnd + | OrOr + | PlusPlus + | MinusMinus + | Comma + | ArrowStar + | Arrow + | LeftParen RightParen + | LeftBracket RightBracket + ; + +literal + : IntegerLiteral + | CharacterLiteral + | FloatingLiteral + | StringLiteral + | BooleanLiteral + | PointerLiteral + | UserDefinedLiteral + ; \ No newline at end of file diff --git a/cql/cql.g4 b/cql/cql.g4 index 27549745ed..a5fe05c70d 100644 --- a/cql/cql.g4 +++ b/cql/cql.g4 @@ -32,159 +32,163 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://www.loc.gov/standards/sru/cql/spec.html +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar cql; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} cql - : sortedQuery EOF - ; + : sortedQuery EOF + ; sortedQuery - : prefixAssignment sortedQuery - | scopedClause (SORTBY sortSpec)? - ; + : prefixAssignment sortedQuery + | scopedClause (SORTBY sortSpec)? + ; sortSpec - : sortSpec singleSpec - | singleSpec - ; + : sortSpec singleSpec + | singleSpec + ; singleSpec - : index modifierList? - ; + : index modifierList? + ; cqlQuery - : prefixAssignment cqlQuery - | scopedClause - ; + : prefixAssignment cqlQuery + | scopedClause + ; prefixAssignment - : '>' prefix_ '=' uri - | '>' uri - ; + : '>' prefix_ '=' uri + | '>' uri + ; scopedClause - : scopedClause booleanGroup searchClause - | searchClause - ; + : scopedClause booleanGroup searchClause + | searchClause + ; booleanGroup - : boolean_ modifierList? - ; + : boolean_ modifierList? + ; boolean_ - : AND - | OR - | NOT - | PROX - ; + : AND + | OR + | NOT + | PROX + ; searchClause - : '(' cqlQuery ')' - | index relation searchTerm - | searchTerm - ; + : '(' cqlQuery ')' + | index relation searchTerm + | searchTerm + ; relation - : comparitor modifierList? - ; + : comparitor modifierList? + ; comparitor - : comparitorSymbol - | namedComparitor - ; + : comparitorSymbol + | namedComparitor + ; comparitorSymbol - : '=' - | '>' - | '<' - | '>=' - | '<=' - | '<>' - | '==' - ; + : '=' + | '>' + | '<' + | '>=' + | '<=' + | '<>' + | '==' + ; namedComparitor - : identifier - ; + : identifier + ; modifierList - : modifierList modifier - | modifier - ; + : modifierList modifier + | modifier + ; modifier - : '/' modifierName (comparitorSymbol modifierValue)? - ; + : '/' modifierName (comparitorSymbol modifierValue)? + ; prefix_ - : term - ; + : term + ; uri - : term - ; + : term + ; modifierName - : term - ; + : term + ; modifierValue - : term - ; + : term + ; searchTerm - : term - ; + : term + ; index - : term - ; + : term + ; term - : identifier - | AND - | OR - | NOT - | PROX - | SORTBY - ; + : identifier + | AND + | OR + | NOT + | PROX + | SORTBY + ; identifier - : CHARSTRING1 - | CHARSTRING2 - ; + : CHARSTRING1 + | CHARSTRING2 + ; AND - : 'AND' - ; + : 'AND' + ; OR - : 'OR' - ; + : 'OR' + ; NOT - : 'NOT' - ; + : 'NOT' + ; PROX - : 'PROX' - ; + : 'PROX' + ; SORTBY - : 'SORTBY' - ; + : 'SORTBY' + ; CHARSTRING1 - : [A-Z.]+ - ; + : [A-Z.]+ + ; CHARSTRING2 - : '"' .*? '"' - ; + : '"' .*? '"' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/cql3/CqlLexer.g4 b/cql3/CqlLexer.g4 index f8e54dab7a..377fdbf220 100644 --- a/cql3/CqlLexer.g4 +++ b/cql3/CqlLexer.g4 @@ -1,177 +1,181 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar CqlLexer; options { - caseInsensitive = true; + caseInsensitive = true; } // Operators and Punctuators -LR_BRACKET: '('; -RR_BRACKET: ')'; -LC_BRACKET: '{'; -RC_BRACKET: '}'; -LS_BRACKET: '['; -RS_BRACKET: ']'; -COMMA: ','; -SEMI: ';'; -COLON: ':'; -DOT: '.'; -STAR: '*'; -DIVIDE: '/'; -MODULE: '%'; -PLUS: '+'; -MINUSMINUS: '--'; -MINUS: '-'; -DQUOTE: '"'; -SQUOTE: '\''; -OPERATOR_EQ: '='; -OPERATOR_LT: '<'; -OPERATOR_GT: '>'; -OPERATOR_LTE: '<='; -OPERATOR_GTE: '>='; +LR_BRACKET : '('; +RR_BRACKET : ')'; +LC_BRACKET : '{'; +RC_BRACKET : '}'; +LS_BRACKET : '['; +RS_BRACKET : ']'; +COMMA : ','; +SEMI : ';'; +COLON : ':'; +DOT : '.'; +STAR : '*'; +DIVIDE : '/'; +MODULE : '%'; +PLUS : '+'; +MINUSMINUS : '--'; +MINUS : '-'; +DQUOTE : '"'; +SQUOTE : '\''; +OPERATOR_EQ : '='; +OPERATOR_LT : '<'; +OPERATOR_GT : '>'; +OPERATOR_LTE : '<='; +OPERATOR_GTE : '>='; // Keywords -K_ADD: 'ADD'; -K_AGGREGATE: 'AGGREGATE'; -K_ALL: 'ALL'; -K_ALLOW: 'ALLOW'; -K_ALTER: 'ALTER'; -K_AND: 'AND'; -K_ANY: 'ANY'; -K_APPLY: 'APPLY'; -K_AS: 'AS'; -K_ASC: 'ASC'; -K_AUTHORIZE: 'AUTHORIZE'; -K_BATCH: 'BATCH'; -K_BEGIN: 'BEGIN'; -K_BY: 'BY'; -K_CALLED: 'CALLED'; -K_CLUSTERING: 'CLUSTERING'; -K_COLUMNFAMILY: 'COLUMNFAMILY'; -K_COMPACT: 'COMPACT'; -K_CONSISTENCY: 'CONSISTENCY'; -K_CONTAINS: 'CONTAINS'; -K_CREATE: 'CREATE'; -K_CUSTOM: 'CUSTOM'; -K_DELETE: 'DELETE'; -K_DESC: 'DESC'; -K_DESCRIBE: 'DESCRIBE'; -K_DISTINCT: 'DISTINCT'; -K_DROP: 'DROP'; -K_DURABLE_WRITES: 'DURABLE_WRITES'; -K_EACH_QUORUM: 'EACH_QUORUM'; -K_ENTRIES: 'ENTRIES'; -K_EXECUTE: 'EXECUTE'; -K_EXISTS: 'EXISTS'; -K_FALSE: 'FALSE'; -K_FILTERING: 'FILTERING'; -K_FINALFUNC: 'FINALFUNC'; -K_FROM: 'FROM'; -K_FULL: 'FULL'; -K_FUNCTION: 'FUNCTION'; -K_FUNCTIONS: 'FUNCTIONS'; -K_GRANT: 'GRANT'; -K_IF: 'IF'; -K_IN: 'IN'; -K_INDEX: 'INDEX'; -K_INFINITY: 'INFINITY'; -K_INITCOND: 'INITCOND'; -K_INPUT: 'INPUT'; -K_INSERT: 'INSERT'; -K_INTO: 'INTO'; -K_IS: 'IS'; -K_JSON: 'JSON'; -K_KEY: 'KEY'; -K_KEYS: 'KEYS'; -K_KEYSPACE: 'KEYSPACE'; -K_KEYSPACES: 'KEYSPACES'; -K_LANGUAGE: 'LANGUAGE'; -K_LEVEL: 'LEVEL'; -K_LIMIT: 'LIMIT'; -K_LOCAL_ONE: 'LOCAL_ONE'; -K_LOCAL_QUORUM: 'LOCAL_QUORUM'; -K_LOGGED: 'LOGGED'; -K_LOGIN: 'LOGIN'; -K_MATERIALIZED: 'MATERIALIZED'; -K_MODIFY: 'MODIFY'; -K_NAN: 'NAN'; -K_NORECURSIVE: 'NORECURSIVE'; -K_NOSUPERUSER: 'NOSUPERUSER'; -K_NOT: 'NOT'; -K_NULL: 'NULL'; -K_OF: 'OF'; -K_ON: 'ON'; -K_ONE: 'ONE'; -K_OPTIONS: 'OPTIONS'; -K_OR: 'OR'; -K_ORDER: 'ORDER'; -K_PARTITION: 'PARTITION'; -K_PASSWORD: 'PASSWORD'; -K_PER: 'PER'; -K_PERMISSION: 'PERMISSION'; -K_PERMISSIONS: 'PERMISSIONS'; -K_PRIMARY: 'PRIMARY'; -K_QUORUM: 'QUORUM'; -K_RENAME: 'RENAME'; -K_REPLACE: 'REPLACE'; -K_REPLICATION: 'REPLICATION'; -K_RETURNS: 'RETURNS'; -K_REVOKE: 'REVOKE'; -K_ROLE: 'ROLE'; -K_ROLES: 'ROLES'; -K_SCHEMA: 'SCHEMA'; -K_SELECT: 'SELECT'; -K_SET: 'SET'; -K_SFUNC: 'SFUNC'; -K_STATIC: 'STATIC'; -K_STORAGE: 'STORAGE'; -K_STYPE: 'STYPE'; -K_SUPERUSER: 'SUPERUSER'; -K_TABLE: 'TABLE'; -K_THREE: 'THREE'; -K_TIMESTAMP: 'TIMESTAMP'; -K_TO: 'TO'; -K_TOKEN: 'TOKEN'; -K_TRIGGER: 'TRIGGER'; -K_TRUE: 'TRUE'; -K_TRUNCATE: 'TRUNCATE'; -K_TTL: 'TTL'; -K_TWO: 'TWO'; -K_TYPE: 'TYPE'; -K_UNLOGGED: 'UNLOGGED'; -K_UPDATE: 'UPDATE'; -K_USE: 'USE'; -K_USER: 'USER'; -K_USING: 'USING'; -K_UUID: 'UUID'; -K_VALUES: 'VALUES'; -K_VIEW: 'VIEW'; -K_WHERE: 'WHERE'; -K_WITH: 'WITH'; -K_WRITETIME: 'WRITETIME'; -K_ASCII: 'ASCII'; -K_BIGINT: 'BIGINT'; -K_BLOB: 'BLOB'; -K_BOOLEAN: 'BOOLEAN'; -K_COUNTER: 'COUNTER'; -K_DATE: 'DATE'; -K_DECIMAL: 'DECIMAL'; -K_DOUBLE: 'DOUBLE'; -K_FLOAT: 'FLOAT'; -K_FROZEN: 'FROZEN'; -K_INET: 'INET'; -K_INT: 'INT'; -K_LIST: 'LIST'; -K_MAP: 'MAP'; -K_SMALLINT: 'SMALLINT'; -K_TEXT: 'TEXT'; -K_TIMEUUID: 'TIMEUUID'; -K_TIME: 'TIME'; -K_TINYINT: 'TINYINT'; -K_TUPLE: 'TUPLE'; -K_VARCHAR: 'VARCHAR'; -K_VARINT: 'VARINT'; +K_ADD : 'ADD'; +K_AGGREGATE : 'AGGREGATE'; +K_ALL : 'ALL'; +K_ALLOW : 'ALLOW'; +K_ALTER : 'ALTER'; +K_AND : 'AND'; +K_ANY : 'ANY'; +K_APPLY : 'APPLY'; +K_AS : 'AS'; +K_ASC : 'ASC'; +K_AUTHORIZE : 'AUTHORIZE'; +K_BATCH : 'BATCH'; +K_BEGIN : 'BEGIN'; +K_BY : 'BY'; +K_CALLED : 'CALLED'; +K_CLUSTERING : 'CLUSTERING'; +K_COLUMNFAMILY : 'COLUMNFAMILY'; +K_COMPACT : 'COMPACT'; +K_CONSISTENCY : 'CONSISTENCY'; +K_CONTAINS : 'CONTAINS'; +K_CREATE : 'CREATE'; +K_CUSTOM : 'CUSTOM'; +K_DELETE : 'DELETE'; +K_DESC : 'DESC'; +K_DESCRIBE : 'DESCRIBE'; +K_DISTINCT : 'DISTINCT'; +K_DROP : 'DROP'; +K_DURABLE_WRITES : 'DURABLE_WRITES'; +K_EACH_QUORUM : 'EACH_QUORUM'; +K_ENTRIES : 'ENTRIES'; +K_EXECUTE : 'EXECUTE'; +K_EXISTS : 'EXISTS'; +K_FALSE : 'FALSE'; +K_FILTERING : 'FILTERING'; +K_FINALFUNC : 'FINALFUNC'; +K_FROM : 'FROM'; +K_FULL : 'FULL'; +K_FUNCTION : 'FUNCTION'; +K_FUNCTIONS : 'FUNCTIONS'; +K_GRANT : 'GRANT'; +K_IF : 'IF'; +K_IN : 'IN'; +K_INDEX : 'INDEX'; +K_INFINITY : 'INFINITY'; +K_INITCOND : 'INITCOND'; +K_INPUT : 'INPUT'; +K_INSERT : 'INSERT'; +K_INTO : 'INTO'; +K_IS : 'IS'; +K_JSON : 'JSON'; +K_KEY : 'KEY'; +K_KEYS : 'KEYS'; +K_KEYSPACE : 'KEYSPACE'; +K_KEYSPACES : 'KEYSPACES'; +K_LANGUAGE : 'LANGUAGE'; +K_LEVEL : 'LEVEL'; +K_LIMIT : 'LIMIT'; +K_LOCAL_ONE : 'LOCAL_ONE'; +K_LOCAL_QUORUM : 'LOCAL_QUORUM'; +K_LOGGED : 'LOGGED'; +K_LOGIN : 'LOGIN'; +K_MATERIALIZED : 'MATERIALIZED'; +K_MODIFY : 'MODIFY'; +K_NAN : 'NAN'; +K_NORECURSIVE : 'NORECURSIVE'; +K_NOSUPERUSER : 'NOSUPERUSER'; +K_NOT : 'NOT'; +K_NULL : 'NULL'; +K_OF : 'OF'; +K_ON : 'ON'; +K_ONE : 'ONE'; +K_OPTIONS : 'OPTIONS'; +K_OR : 'OR'; +K_ORDER : 'ORDER'; +K_PARTITION : 'PARTITION'; +K_PASSWORD : 'PASSWORD'; +K_PER : 'PER'; +K_PERMISSION : 'PERMISSION'; +K_PERMISSIONS : 'PERMISSIONS'; +K_PRIMARY : 'PRIMARY'; +K_QUORUM : 'QUORUM'; +K_RENAME : 'RENAME'; +K_REPLACE : 'REPLACE'; +K_REPLICATION : 'REPLICATION'; +K_RETURNS : 'RETURNS'; +K_REVOKE : 'REVOKE'; +K_ROLE : 'ROLE'; +K_ROLES : 'ROLES'; +K_SCHEMA : 'SCHEMA'; +K_SELECT : 'SELECT'; +K_SET : 'SET'; +K_SFUNC : 'SFUNC'; +K_STATIC : 'STATIC'; +K_STORAGE : 'STORAGE'; +K_STYPE : 'STYPE'; +K_SUPERUSER : 'SUPERUSER'; +K_TABLE : 'TABLE'; +K_THREE : 'THREE'; +K_TIMESTAMP : 'TIMESTAMP'; +K_TO : 'TO'; +K_TOKEN : 'TOKEN'; +K_TRIGGER : 'TRIGGER'; +K_TRUE : 'TRUE'; +K_TRUNCATE : 'TRUNCATE'; +K_TTL : 'TTL'; +K_TWO : 'TWO'; +K_TYPE : 'TYPE'; +K_UNLOGGED : 'UNLOGGED'; +K_UPDATE : 'UPDATE'; +K_USE : 'USE'; +K_USER : 'USER'; +K_USING : 'USING'; +K_UUID : 'UUID'; +K_VALUES : 'VALUES'; +K_VIEW : 'VIEW'; +K_WHERE : 'WHERE'; +K_WITH : 'WITH'; +K_WRITETIME : 'WRITETIME'; +K_ASCII : 'ASCII'; +K_BIGINT : 'BIGINT'; +K_BLOB : 'BLOB'; +K_BOOLEAN : 'BOOLEAN'; +K_COUNTER : 'COUNTER'; +K_DATE : 'DATE'; +K_DECIMAL : 'DECIMAL'; +K_DOUBLE : 'DOUBLE'; +K_FLOAT : 'FLOAT'; +K_FROZEN : 'FROZEN'; +K_INET : 'INET'; +K_INT : 'INT'; +K_LIST : 'LIST'; +K_MAP : 'MAP'; +K_SMALLINT : 'SMALLINT'; +K_TEXT : 'TEXT'; +K_TIMEUUID : 'TIMEUUID'; +K_TIME : 'TIME'; +K_TINYINT : 'TINYINT'; +K_TUPLE : 'TUPLE'; +K_VARCHAR : 'VARCHAR'; +K_VARINT : 'VARINT'; // Literals @@ -183,32 +187,24 @@ DECIMAL_LITERAL: DEC_DIGIT+; FLOAT_LITERAL: MINUS? [0-9]+ (DOT [0-9]+)?; -HEXADECIMAL_LITERAL - : 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\'' - | '0X' HEX_DIGIT+ - ; +HEXADECIMAL_LITERAL: 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\'' | '0X' HEX_DIGIT+; -REAL_LITERAL - : DEC_DIGIT+ '.'? EXPONENT_NUM_PART - | DEC_DIGIT* '.' DEC_DIGIT+ EXPONENT_NUM_PART? - ; +REAL_LITERAL: DEC_DIGIT+ '.'? EXPONENT_NUM_PART | DEC_DIGIT* '.' DEC_DIGIT+ EXPONENT_NUM_PART?; -OBJECT_NAME - : [A-Z] [A-Z0-9_$]* - | '"' ~'"'+ '"' - ; +OBJECT_NAME: [A-Z] [A-Z0-9_$]* | '"' ~'"'+ '"'; -UUID: HEX_4DIGIT HEX_4DIGIT '-' HEX_4DIGIT '-' HEX_4DIGIT '-' HEX_4DIGIT '-' HEX_4DIGIT HEX_4DIGIT HEX_4DIGIT; +UUID: + HEX_4DIGIT HEX_4DIGIT '-' HEX_4DIGIT '-' HEX_4DIGIT '-' HEX_4DIGIT '-' HEX_4DIGIT HEX_4DIGIT HEX_4DIGIT +; // Hidden -SPACE: [ \t\r\n]+ -> channel (HIDDEN); -SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel (HIDDEN); -COMMENT_INPUT: '/*' .*? '*/' -> channel (HIDDEN); -LINE_COMMENT: ( - ('-- ' | '#' | '//') ~ [\r\n]* ('\r'? '\n' | EOF) - | '--' ('\r'? '\n' | EOF) - ) -> channel (HIDDEN); +SPACE : [ \t\r\n]+ -> channel (HIDDEN); +SPEC_MYSQL_COMMENT : '/*!' .+? '*/' -> channel (HIDDEN); +COMMENT_INPUT : '/*' .*? '*/' -> channel (HIDDEN); +LINE_COMMENT: + (('-- ' | '#' | '//') ~ [\r\n]* ('\r'? '\n' | EOF) | '--' ('\r'? '\n' | EOF)) -> channel (HIDDEN) +; // Fragments @@ -218,7 +214,4 @@ fragment HEX_DIGIT: [0-9A-F]; fragment DEC_DIGIT: [0-9]; -fragment EXPONENT_NUM_PART: 'E' '-'? DEC_DIGIT+; - - - +fragment EXPONENT_NUM_PART: 'E' '-'? DEC_DIGIT+; \ No newline at end of file diff --git a/cql3/CqlParser.g4 b/cql3/CqlParser.g4 index 866d86eee1..cee6521dee 100644 --- a/cql3/CqlParser.g4 +++ b/cql3/CqlParser.g4 @@ -21,147 +21,162 @@ * Project : cql-parser; an ANTLR4 grammar for Apache Cassandra CQL https://github.com/kdcro101cql-parser */ +// $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 CqlParser; options - { tokenVocab = CqlLexer; } + { + tokenVocab = CqlLexer; +} root - : cqls? MINUSMINUS? EOF - ; + : cqls? MINUSMINUS? EOF + ; cqls - : (cql MINUSMINUS? statementSeparator | empty_)* (cql (MINUSMINUS? statementSeparator)? | empty_) - ; + : (cql MINUSMINUS? statementSeparator | empty_)* ( + cql (MINUSMINUS? statementSeparator)? + | empty_ + ) + ; statementSeparator - : SEMI - ; + : SEMI + ; empty_ - : statementSeparator - ; + : statementSeparator + ; cql - : alterKeyspace - | alterMaterializedView - | alterRole - | alterTable - | alterType - | alterUser - | applyBatch - | createAggregate - | createFunction - | createIndex - | createKeyspace - | createMaterializedView - | createRole - | createTable - | createTrigger - | createType - | createUser - | delete_ - | dropAggregate - | dropFunction - | dropIndex - | dropKeyspace - | dropMaterializedView - | dropRole - | dropTable - | dropTrigger - | dropType - | dropUser - | grant - | insert - | listPermissions - | listRoles - | revoke - | select_ - | truncate - | update - | use_ - ; + : alterKeyspace + | alterMaterializedView + | alterRole + | alterTable + | alterType + | alterUser + | applyBatch + | createAggregate + | createFunction + | createIndex + | createKeyspace + | createMaterializedView + | createRole + | createTable + | createTrigger + | createType + | createUser + | delete_ + | dropAggregate + | dropFunction + | dropIndex + | dropKeyspace + | dropMaterializedView + | dropRole + | dropTable + | dropTrigger + | dropType + | dropUser + | grant + | insert + | listPermissions + | listRoles + | revoke + | select_ + | truncate + | update + | use_ + ; revoke - : kwRevoke priviledge kwOn resource kwFrom role - ; + : kwRevoke priviledge kwOn resource kwFrom role + ; listRoles - : kwList kwRoles (kwOf role)? kwNorecursive? - ; + : kwList kwRoles (kwOf role)? kwNorecursive? + ; listPermissions - : kwList priviledge (kwOn resource)? (kwOf role)? - ; + : kwList priviledge (kwOn resource)? (kwOf role)? + ; grant - : kwGrant priviledge kwOn resource kwTo role - ; + : kwGrant priviledge kwOn resource kwTo role + ; priviledge - : (kwAll | kwAllPermissions) - | kwAlter - | kwAuthorize - | kwDescibe - | kwExecute - | kwCreate - | kwDrop - | kwModify - | kwSelect - ; + : (kwAll | kwAllPermissions) + | kwAlter + | kwAuthorize + | kwDescibe + | kwExecute + | kwCreate + | kwDrop + | kwModify + | kwSelect + ; resource - : kwAll kwFunctions - | kwAll kwFunctions kwIn kwKeyspace keyspace - | kwFunction (keyspace DOT)? function_ - | kwAll kwKeyspaces - | kwKeyspace keyspace - | (kwTable)? (keyspace DOT)? table - | kwAll kwRoles - | kwRole role - ; + : kwAll kwFunctions + | kwAll kwFunctions kwIn kwKeyspace keyspace + | kwFunction (keyspace DOT)? function_ + | kwAll kwKeyspaces + | kwKeyspace keyspace + | (kwTable)? (keyspace DOT)? table + | kwAll kwRoles + | kwRole role + ; createUser - : kwCreate kwUser ifNotExist? user kwWith kwPassword stringLiteral (kwSuperuser | kwNosuperuser)? - ; + : kwCreate kwUser ifNotExist? user kwWith kwPassword stringLiteral ( + kwSuperuser + | kwNosuperuser + )? + ; createRole - : kwCreate kwRole ifNotExist? role roleWith? - ; + : kwCreate kwRole ifNotExist? role roleWith? + ; createType - : kwCreate kwType ifNotExist? (keyspace DOT)? type_ syntaxBracketLr typeMemberColumnList syntaxBracketRr - ; + : kwCreate kwType ifNotExist? (keyspace DOT)? type_ syntaxBracketLr typeMemberColumnList syntaxBracketRr + ; typeMemberColumnList - : column dataType (syntaxComma column dataType)* - ; + : column dataType (syntaxComma column dataType)* + ; createTrigger - : kwCreate kwTrigger ifNotExist? (keyspace DOT)? trigger kwUsing triggerClass - ; + : kwCreate kwTrigger ifNotExist? (keyspace DOT)? trigger kwUsing triggerClass + ; createMaterializedView - : kwCreate kwMaterialized kwView ifNotExist? (keyspace DOT)? materializedView kwAs kwSelect columnList kwFrom (keyspace DOT)? table materializedViewWhere kwPrimary kwKey syntaxBracketLr columnList syntaxBracketRr (kwWith materializedViewOptions)? - ; + : kwCreate kwMaterialized kwView ifNotExist? (keyspace DOT)? materializedView kwAs kwSelect columnList kwFrom ( + keyspace DOT + )? table materializedViewWhere kwPrimary kwKey syntaxBracketLr columnList syntaxBracketRr ( + kwWith materializedViewOptions + )? + ; materializedViewWhere - : kwWhere columnNotNullList (kwAnd relationElements)? - ; + : kwWhere columnNotNullList (kwAnd relationElements)? + ; columnNotNullList - : columnNotNull (kwAnd columnNotNull)* - ; + : columnNotNull (kwAnd columnNotNull)* + ; columnNotNull - : column kwIs kwNot kwNull - ; + : column kwIs kwNot kwNull + ; materializedViewOptions - : tableOptions - | tableOptions kwAnd clusteringOrder - | clusteringOrder - ; + : tableOptions + | tableOptions kwAnd clusteringOrder + | clusteringOrder + ; // CREATE MATERIALIZED VIEW [IF NOT EXISTS] [keyspace_name.] view_name // AS SELECT column_list @@ -172,1088 +187,1114 @@ materializedViewOptions // [WITH [table_properties] // [AND CLUSTERING ORDER BY (cluster_column_name order_option )]] createKeyspace - : kwCreate kwKeyspace ifNotExist? keyspace kwWith kwReplication OPERATOR_EQ syntaxBracketLc replicationList syntaxBracketRc (kwAnd durableWrites)? - ; + : kwCreate kwKeyspace ifNotExist? keyspace kwWith kwReplication OPERATOR_EQ syntaxBracketLc replicationList syntaxBracketRc ( + kwAnd durableWrites + )? + ; createFunction - : kwCreate orReplace? kwFunction ifNotExist? (keyspace DOT)? function_ syntaxBracketLr paramList? syntaxBracketRr returnMode kwReturns dataType kwLanguage language kwAs codeBlock - ; + : kwCreate orReplace? kwFunction ifNotExist? (keyspace DOT)? function_ syntaxBracketLr paramList? syntaxBracketRr returnMode kwReturns dataType + kwLanguage language kwAs codeBlock + ; codeBlock - : CODE_BLOCK - | STRING_LITERAL - ; + : CODE_BLOCK + | STRING_LITERAL + ; paramList - : param (syntaxComma param)* - ; + : param (syntaxComma param)* + ; returnMode - : (kwCalled | kwReturns kwNull) kwOn kwNull kwInput - ; + : (kwCalled | kwReturns kwNull) kwOn kwNull kwInput + ; createAggregate - : kwCreate orReplace? kwAggregate ifNotExist? (keyspace DOT)? aggregate syntaxBracketLr dataType syntaxBracketRr kwSfunc function_ kwStype dataType kwFinalfunc function_ kwInitcond initCondDefinition - ; + : kwCreate orReplace? kwAggregate ifNotExist? (keyspace DOT)? aggregate syntaxBracketLr dataType syntaxBracketRr kwSfunc function_ kwStype + dataType kwFinalfunc function_ kwInitcond initCondDefinition + ; // paramList // : initCondDefinition - : constant - | initCondList - | initCondListNested - | initCondHash - ; + : constant + | initCondList + | initCondListNested + | initCondHash + ; initCondHash - : syntaxBracketLc initCondHashItem (syntaxComma initCondHashItem)* syntaxBracketRc - ; + : syntaxBracketLc initCondHashItem (syntaxComma initCondHashItem)* syntaxBracketRc + ; initCondHashItem - : hashKey COLON initCondDefinition - ; + : hashKey COLON initCondDefinition + ; initCondListNested - : syntaxBracketLr initCondList (syntaxComma constant | initCondList)* syntaxBracketRr - ; + : syntaxBracketLr initCondList (syntaxComma constant | initCondList)* syntaxBracketRr + ; initCondList - : syntaxBracketLr constant (syntaxComma constant)* syntaxBracketRr - ; + : syntaxBracketLr constant (syntaxComma constant)* syntaxBracketRr + ; orReplace - : kwOr kwReplace - ; + : kwOr kwReplace + ; alterUser - : kwAlter kwUser user kwWith userPassword userSuperUser? - ; + : kwAlter kwUser user kwWith userPassword userSuperUser? + ; userPassword - : kwPassword stringLiteral - ; + : kwPassword stringLiteral + ; userSuperUser - : kwSuperuser - | kwNosuperuser - ; + : kwSuperuser + | kwNosuperuser + ; alterType - : kwAlter kwType (keyspace DOT)? type_ alterTypeOperation - ; + : kwAlter kwType (keyspace DOT)? type_ alterTypeOperation + ; alterTypeOperation - : alterTypeAlterType - | alterTypeAdd - | alterTypeRename - ; + : alterTypeAlterType + | alterTypeAdd + | alterTypeRename + ; alterTypeRename - : kwRename alterTypeRenameList - ; + : kwRename alterTypeRenameList + ; alterTypeRenameList - : alterTypeRenameItem (kwAnd alterTypeRenameItem)* - ; + : alterTypeRenameItem (kwAnd alterTypeRenameItem)* + ; alterTypeRenameItem - : column kwTo column - ; + : column kwTo column + ; alterTypeAdd - : kwAdd column dataType (syntaxComma column dataType)* - ; + : kwAdd column dataType (syntaxComma column dataType)* + ; alterTypeAlterType - : kwAlter column kwType dataType - ; + : kwAlter column kwType dataType + ; alterTable - : kwAlter kwTable (keyspace DOT)? table alterTableOperation - ; + : kwAlter kwTable (keyspace DOT)? table alterTableOperation + ; alterTableOperation - : alterTableAdd - | alterTableDropColumns - | alterTableDropCompactStorage - | alterTableRename - | alterTableWith - ; + : alterTableAdd + | alterTableDropColumns + | alterTableDropCompactStorage + | alterTableRename + | alterTableWith + ; alterTableWith - : kwWith tableOptions - ; + : kwWith tableOptions + ; alterTableRename - : kwRename column kwTo column - ; + : kwRename column kwTo column + ; alterTableDropCompactStorage - : kwDrop kwCompact kwStorage - ; + : kwDrop kwCompact kwStorage + ; alterTableDropColumns - : kwDrop alterTableDropColumnList - ; + : kwDrop alterTableDropColumnList + ; alterTableDropColumnList - : column (syntaxComma column)* - ; + : column (syntaxComma column)* + ; alterTableAdd - : kwAdd alterTableColumnDefinition - ; + : kwAdd alterTableColumnDefinition + ; alterTableColumnDefinition - : column dataType (syntaxComma column dataType)* - ; + : column dataType (syntaxComma column dataType)* + ; alterRole - : kwAlter kwRole role roleWith? - ; + : kwAlter kwRole role roleWith? + ; roleWith - : kwWith (roleWithOptions (kwAnd roleWithOptions)*) - ; + : kwWith (roleWithOptions (kwAnd roleWithOptions)*) + ; roleWithOptions - : kwPassword OPERATOR_EQ stringLiteral - | kwLogin OPERATOR_EQ booleanLiteral - | kwSuperuser OPERATOR_EQ booleanLiteral - | kwOptions OPERATOR_EQ optionHash - ; + : kwPassword OPERATOR_EQ stringLiteral + | kwLogin OPERATOR_EQ booleanLiteral + | kwSuperuser OPERATOR_EQ booleanLiteral + | kwOptions OPERATOR_EQ optionHash + ; alterMaterializedView - : kwAlter kwMaterialized kwView (keyspace DOT)? materializedView (kwWith tableOptions)? - ; + : kwAlter kwMaterialized kwView (keyspace DOT)? materializedView (kwWith tableOptions)? + ; dropUser - : kwDrop kwUser ifExist? user - ; + : kwDrop kwUser ifExist? user + ; dropType - : kwDrop kwType ifExist? (keyspace DOT)? type_ - ; + : kwDrop kwType ifExist? (keyspace DOT)? type_ + ; dropMaterializedView - : kwDrop kwMaterialized kwView ifExist? (keyspace DOT)? materializedView - ; + : kwDrop kwMaterialized kwView ifExist? (keyspace DOT)? materializedView + ; dropAggregate - : kwDrop kwAggregate ifExist? (keyspace DOT)? aggregate - ; + : kwDrop kwAggregate ifExist? (keyspace DOT)? aggregate + ; dropFunction - : kwDrop kwFunction ifExist? (keyspace DOT)? function_ - ; + : kwDrop kwFunction ifExist? (keyspace DOT)? function_ + ; dropTrigger - : kwDrop kwTrigger ifExist? trigger kwOn (keyspace DOT)? table - ; + : kwDrop kwTrigger ifExist? trigger kwOn (keyspace DOT)? table + ; dropRole - : kwDrop kwRole ifExist? role - ; + : kwDrop kwRole ifExist? role + ; dropTable - : kwDrop kwTable ifExist? (keyspace DOT)? table - ; + : kwDrop kwTable ifExist? (keyspace DOT)? table + ; dropKeyspace - : kwDrop kwKeyspace ifExist? keyspace - ; + : kwDrop kwKeyspace ifExist? keyspace + ; dropIndex - : kwDrop kwIndex ifExist? (keyspace DOT)? indexName - ; + : kwDrop kwIndex ifExist? (keyspace DOT)? indexName + ; createTable - : kwCreate kwTable ifNotExist? (keyspace DOT)? table syntaxBracketLr columnDefinitionList syntaxBracketRr withElement? - ; + : kwCreate kwTable ifNotExist? (keyspace DOT)? table syntaxBracketLr columnDefinitionList syntaxBracketRr withElement? + ; withElement - : kwWith tableOptions? clusteringOrder? - ; + : kwWith tableOptions? clusteringOrder? + ; clusteringOrder - : kwClustering kwOrder kwBy syntaxBracketLr column orderDirection? syntaxBracketRr - ; + : kwClustering kwOrder kwBy syntaxBracketLr column orderDirection? syntaxBracketRr + ; tableOptions - : tableOptionItem (kwAnd tableOptionItem)* - ; + : tableOptionItem (kwAnd tableOptionItem)* + ; tableOptionItem - : tableOptionName OPERATOR_EQ tableOptionValue - | tableOptionName OPERATOR_EQ optionHash - ; + : tableOptionName OPERATOR_EQ tableOptionValue + | tableOptionName OPERATOR_EQ optionHash + ; tableOptionName - : OBJECT_NAME - ; + : OBJECT_NAME + ; tableOptionValue - : stringLiteral - | floatLiteral - ; + : stringLiteral + | floatLiteral + ; optionHash - : syntaxBracketLc optionHashItem (syntaxComma optionHashItem)* syntaxBracketRc - ; + : syntaxBracketLc optionHashItem (syntaxComma optionHashItem)* syntaxBracketRc + ; optionHashItem - : optionHashKey COLON optionHashValue - ; + : optionHashKey COLON optionHashValue + ; optionHashKey - : stringLiteral - ; + : stringLiteral + ; optionHashValue - : stringLiteral - | floatLiteral - ; + : stringLiteral + | floatLiteral + ; columnDefinitionList - : (columnDefinition) (syntaxComma columnDefinition)* (syntaxComma primaryKeyElement)? - ; + : (columnDefinition) (syntaxComma columnDefinition)* (syntaxComma primaryKeyElement)? + ; // columnDefinition - : column dataType primaryKeyColumn? - ; + : column dataType primaryKeyColumn? + ; // primaryKeyColumn - : kwPrimary kwKey - ; + : kwPrimary kwKey + ; primaryKeyElement - : kwPrimary kwKey syntaxBracketLr primaryKeyDefinition syntaxBracketRr - ; + : kwPrimary kwKey syntaxBracketLr primaryKeyDefinition syntaxBracketRr + ; primaryKeyDefinition - : singlePrimaryKey - | compoundKey - | compositeKey - ; + : singlePrimaryKey + | compoundKey + | compositeKey + ; singlePrimaryKey - : column - ; + : column + ; compoundKey - : partitionKey (syntaxComma clusteringKeyList) - ; + : partitionKey (syntaxComma clusteringKeyList) + ; compositeKey - : syntaxBracketLr partitionKeyList syntaxBracketRr (syntaxComma clusteringKeyList) - ; + : syntaxBracketLr partitionKeyList syntaxBracketRr (syntaxComma clusteringKeyList) + ; partitionKeyList - : (partitionKey) (syntaxComma partitionKey)* - ; + : (partitionKey) (syntaxComma partitionKey)* + ; clusteringKeyList - : (clusteringKey) (syntaxComma clusteringKey)* - ; + : (clusteringKey) (syntaxComma clusteringKey)* + ; partitionKey - : column - ; + : column + ; clusteringKey - : column - ; + : column + ; applyBatch - : kwApply kwBatch - ; + : kwApply kwBatch + ; beginBatch - : kwBegin batchType? kwBatch usingTimestampSpec? - ; + : kwBegin batchType? kwBatch usingTimestampSpec? + ; batchType - : kwLogged - | kwUnlogged - ; + : kwLogged + | kwUnlogged + ; alterKeyspace - : kwAlter kwKeyspace keyspace kwWith kwReplication OPERATOR_EQ syntaxBracketLc replicationList syntaxBracketRc (kwAnd durableWrites)? - ; + : kwAlter kwKeyspace keyspace kwWith kwReplication OPERATOR_EQ syntaxBracketLc replicationList syntaxBracketRc ( + kwAnd durableWrites + )? + ; replicationList - : (replicationListItem) (syntaxComma replicationListItem)* - ; + : (replicationListItem) (syntaxComma replicationListItem)* + ; replicationListItem - : STRING_LITERAL COLON STRING_LITERAL - | STRING_LITERAL COLON DECIMAL_LITERAL - ; + : STRING_LITERAL COLON STRING_LITERAL + | STRING_LITERAL COLON DECIMAL_LITERAL + ; durableWrites - : kwDurableWrites OPERATOR_EQ booleanLiteral - ; + : kwDurableWrites OPERATOR_EQ booleanLiteral + ; use_ - : kwUse keyspace - ; + : kwUse keyspace + ; truncate - : kwTruncate (kwTable)? (keyspace DOT)? table - ; + : kwTruncate (kwTable)? (keyspace DOT)? table + ; createIndex - : kwCreate kwIndex ifNotExist? indexName? kwOn (keyspace DOT)? table syntaxBracketLr indexColumnSpec syntaxBracketRr - ; + : kwCreate kwIndex ifNotExist? indexName? kwOn (keyspace DOT)? table syntaxBracketLr indexColumnSpec syntaxBracketRr + ; indexName - : OBJECT_NAME - | stringLiteral - ; + : OBJECT_NAME + | stringLiteral + ; indexColumnSpec - : column - | indexKeysSpec - | indexEntriesSSpec - | indexFullSpec - ; + : column + | indexKeysSpec + | indexEntriesSSpec + | indexFullSpec + ; indexKeysSpec - : kwKeys syntaxBracketLr OBJECT_NAME syntaxBracketRr - ; + : kwKeys syntaxBracketLr OBJECT_NAME syntaxBracketRr + ; indexEntriesSSpec - : kwEntries syntaxBracketLr OBJECT_NAME syntaxBracketRr - ; + : kwEntries syntaxBracketLr OBJECT_NAME syntaxBracketRr + ; indexFullSpec - : kwFull syntaxBracketLr OBJECT_NAME syntaxBracketRr - ; + : kwFull syntaxBracketLr OBJECT_NAME syntaxBracketRr + ; delete_ - : beginBatch? kwDelete deleteColumnList? fromSpec usingTimestampSpec? whereSpec (ifExist | ifSpec)? - ; + : beginBatch? kwDelete deleteColumnList? fromSpec usingTimestampSpec? whereSpec ( + ifExist + | ifSpec + )? + ; deleteColumnList - : (deleteColumnItem) (syntaxComma deleteColumnItem)* - ; + : (deleteColumnItem) (syntaxComma deleteColumnItem)* + ; deleteColumnItem - : OBJECT_NAME - | OBJECT_NAME LS_BRACKET (stringLiteral | decimalLiteral) RS_BRACKET - ; + : OBJECT_NAME + | OBJECT_NAME LS_BRACKET (stringLiteral | decimalLiteral) RS_BRACKET + ; update - : beginBatch? kwUpdate (keyspace DOT)? table usingTtlTimestamp? kwSet assignments whereSpec (ifExist | ifSpec)? - ; + : beginBatch? kwUpdate (keyspace DOT)? table usingTtlTimestamp? kwSet assignments whereSpec ( + ifExist + | ifSpec + )? + ; ifSpec - : kwIf ifConditionList - ; + : kwIf ifConditionList + ; ifConditionList - : (ifCondition) (kwAnd ifCondition)* - ; + : (ifCondition) (kwAnd ifCondition)* + ; ifCondition - : OBJECT_NAME OPERATOR_EQ constant - ; + : OBJECT_NAME OPERATOR_EQ constant + ; assignments - : (assignmentElement) (syntaxComma assignmentElement)* - ; + : (assignmentElement) (syntaxComma assignmentElement)* + ; assignmentElement - : OBJECT_NAME OPERATOR_EQ (constant | assignmentMap | assignmentSet | assignmentList) - | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) decimalLiteral - | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) assignmentSet - | OBJECT_NAME OPERATOR_EQ assignmentSet (PLUS | MINUS) OBJECT_NAME - | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) assignmentMap - | OBJECT_NAME OPERATOR_EQ assignmentMap (PLUS | MINUS) OBJECT_NAME - | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) assignmentList - | OBJECT_NAME OPERATOR_EQ assignmentList (PLUS | MINUS) OBJECT_NAME - | OBJECT_NAME syntaxBracketLs decimalLiteral syntaxBracketRs OPERATOR_EQ constant - ; + : OBJECT_NAME OPERATOR_EQ (constant | assignmentMap | assignmentSet | assignmentList) + | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) decimalLiteral + | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) assignmentSet + | OBJECT_NAME OPERATOR_EQ assignmentSet (PLUS | MINUS) OBJECT_NAME + | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) assignmentMap + | OBJECT_NAME OPERATOR_EQ assignmentMap (PLUS | MINUS) OBJECT_NAME + | OBJECT_NAME OPERATOR_EQ OBJECT_NAME (PLUS | MINUS) assignmentList + | OBJECT_NAME OPERATOR_EQ assignmentList (PLUS | MINUS) OBJECT_NAME + | OBJECT_NAME syntaxBracketLs decimalLiteral syntaxBracketRs OPERATOR_EQ constant + ; assignmentSet - : syntaxBracketLc (constant (syntaxComma constant)*)? syntaxBracketRc - ; + : syntaxBracketLc (constant (syntaxComma constant)*)? syntaxBracketRc + ; assignmentMap - : syntaxBracketLc (constant syntaxColon constant) (syntaxComma constant syntaxColon constant)* syntaxBracketRc - ; + : syntaxBracketLc (constant syntaxColon constant) (syntaxComma constant syntaxColon constant)* syntaxBracketRc + ; assignmentList - : syntaxBracketLs constant (syntaxComma constant)* syntaxBracketRs - ; + : syntaxBracketLs constant (syntaxComma constant)* syntaxBracketRs + ; assignmentTuple - : syntaxBracketLr ( expression (syntaxComma expression)* ) syntaxBracketRr - ; + : syntaxBracketLr (expression (syntaxComma expression)*) syntaxBracketRr + ; insert - : beginBatch? kwInsert kwInto (keyspace DOT)? table insertColumnSpec? insertValuesSpec ifNotExist? usingTtlTimestamp? - ; + : beginBatch? kwInsert kwInto (keyspace DOT)? table insertColumnSpec? insertValuesSpec ifNotExist? usingTtlTimestamp? + ; usingTtlTimestamp - : kwUsing ttl - | kwUsing ttl kwAnd timestamp - | kwUsing timestamp - | kwUsing timestamp kwAnd ttl - ; + : kwUsing ttl + | kwUsing ttl kwAnd timestamp + | kwUsing timestamp + | kwUsing timestamp kwAnd ttl + ; timestamp - : kwTimestamp decimalLiteral - ; + : kwTimestamp decimalLiteral + ; ttl - : kwTtl decimalLiteral - ; + : kwTtl decimalLiteral + ; usingTimestampSpec - : kwUsing timestamp - ; + : kwUsing timestamp + ; ifNotExist - : kwIf kwNot kwExists - ; + : kwIf kwNot kwExists + ; ifExist - : kwIf kwExists - ; + : kwIf kwExists + ; insertValuesSpec - : kwValues '(' expressionList ')' - | kwJson constant - ; + : kwValues '(' expressionList ')' + | kwJson constant + ; insertColumnSpec - : '(' columnList ')' - ; + : '(' columnList ')' + ; columnList - : column (syntaxComma column)* - ; + : column (syntaxComma column)* + ; expressionList - : expression (syntaxComma expression)* - ; + : expression (syntaxComma expression)* + ; expression - : constant - | functionCall - | assignmentMap - | assignmentSet - | assignmentList - | assignmentTuple - ; + : constant + | functionCall + | assignmentMap + | assignmentSet + | assignmentList + | assignmentTuple + ; select_ - : kwSelect distinctSpec? kwJson? selectElements fromSpec whereSpec? orderSpec? limitSpec? allowFilteringSpec? - ; + : kwSelect distinctSpec? kwJson? selectElements fromSpec whereSpec? orderSpec? limitSpec? allowFilteringSpec? + ; allowFilteringSpec - : kwAllow kwFiltering - ; + : kwAllow kwFiltering + ; limitSpec - : kwLimit decimalLiteral - ; + : kwLimit decimalLiteral + ; fromSpec - : kwFrom fromSpecElement - ; + : kwFrom fromSpecElement + ; fromSpecElement - : OBJECT_NAME - | OBJECT_NAME '.' OBJECT_NAME - ; + : OBJECT_NAME + | OBJECT_NAME '.' OBJECT_NAME + ; orderSpec - : kwOrder kwBy orderSpecElement - ; + : kwOrder kwBy orderSpecElement + ; orderSpecElement - : OBJECT_NAME (kwAsc | kwDesc)? - ; + : OBJECT_NAME (kwAsc | kwDesc)? + ; whereSpec - : kwWhere relationElements - ; + : kwWhere relationElements + ; distinctSpec - : kwDistinct - ; + : kwDistinct + ; selectElements - : (star = '*' | selectElement) (syntaxComma selectElement)* - ; + : (star = '*' | selectElement) (syntaxComma selectElement)* + ; selectElement - : OBJECT_NAME '.' '*' - | OBJECT_NAME (kwAs OBJECT_NAME)? - | functionCall (kwAs OBJECT_NAME)? - ; + : OBJECT_NAME '.' '*' + | OBJECT_NAME (kwAs OBJECT_NAME)? + | functionCall (kwAs OBJECT_NAME)? + ; relationElements - : (relationElement) (kwAnd relationElement)* - ; + : (relationElement) (kwAnd relationElement)* + ; relationElement - : OBJECT_NAME (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) constant - | OBJECT_NAME '.' OBJECT_NAME (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) constant - | functionCall (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) constant - | functionCall (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) functionCall - | OBJECT_NAME kwIn '(' functionArgs? ')' - | '(' OBJECT_NAME (syntaxComma OBJECT_NAME)* ')' kwIn '(' assignmentTuple (syntaxComma assignmentTuple)* ')' - | '(' OBJECT_NAME (syntaxComma OBJECT_NAME)* ')' (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) ( assignmentTuple (syntaxComma assignmentTuple)* ) - | relalationContainsKey - | relalationContains - ; + : OBJECT_NAME (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) constant + | OBJECT_NAME '.' OBJECT_NAME ( + OPERATOR_EQ + | OPERATOR_LT + | OPERATOR_GT + | OPERATOR_LTE + | OPERATOR_GTE + ) constant + | functionCall (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) constant + | functionCall (OPERATOR_EQ | OPERATOR_LT | OPERATOR_GT | OPERATOR_LTE | OPERATOR_GTE) functionCall + | OBJECT_NAME kwIn '(' functionArgs? ')' + | '(' OBJECT_NAME (syntaxComma OBJECT_NAME)* ')' kwIn '(' assignmentTuple ( + syntaxComma assignmentTuple + )* ')' + | '(' OBJECT_NAME (syntaxComma OBJECT_NAME)* ')' ( + OPERATOR_EQ + | OPERATOR_LT + | OPERATOR_GT + | OPERATOR_LTE + | OPERATOR_GTE + ) (assignmentTuple (syntaxComma assignmentTuple)*) + | relalationContainsKey + | relalationContains + ; relalationContains - : OBJECT_NAME kwContains constant - ; + : OBJECT_NAME kwContains constant + ; relalationContainsKey - : OBJECT_NAME (kwContains kwKey) constant - ; + : OBJECT_NAME (kwContains kwKey) constant + ; functionCall - : OBJECT_NAME '(' STAR ')' - | OBJECT_NAME '(' functionArgs? ')' - | K_UUID '(' ')' - ; + : OBJECT_NAME '(' STAR ')' + | OBJECT_NAME '(' functionArgs? ')' + | K_UUID '(' ')' + ; functionArgs - : (constant | OBJECT_NAME | functionCall) (syntaxComma (constant | OBJECT_NAME | functionCall))* - ; + : (constant | OBJECT_NAME | functionCall) (syntaxComma (constant | OBJECT_NAME | functionCall))* + ; constant - : UUID - | stringLiteral - | decimalLiteral - | floatLiteral - | hexadecimalLiteral - | booleanLiteral - | codeBlock - | kwNull - ; + : UUID + | stringLiteral + | decimalLiteral + | floatLiteral + | hexadecimalLiteral + | booleanLiteral + | codeBlock + | kwNull + ; decimalLiteral - : DECIMAL_LITERAL - ; + : DECIMAL_LITERAL + ; floatLiteral - : DECIMAL_LITERAL - | FLOAT_LITERAL - ; + : DECIMAL_LITERAL + | FLOAT_LITERAL + ; stringLiteral - : STRING_LITERAL - ; + : STRING_LITERAL + ; booleanLiteral - : K_TRUE - | K_FALSE - ; + : K_TRUE + | K_FALSE + ; hexadecimalLiteral - : HEXADECIMAL_LITERAL - ; + : HEXADECIMAL_LITERAL + ; keyspace - : OBJECT_NAME - | DQUOTE OBJECT_NAME DQUOTE - ; + : OBJECT_NAME + | DQUOTE OBJECT_NAME DQUOTE + ; table - : OBJECT_NAME - | DQUOTE OBJECT_NAME DQUOTE - ; + : OBJECT_NAME + | DQUOTE OBJECT_NAME DQUOTE + ; column - : OBJECT_NAME - | DQUOTE OBJECT_NAME DQUOTE - ; + : OBJECT_NAME + | DQUOTE OBJECT_NAME DQUOTE + ; dataType - : dataTypeName dataTypeDefinition? - ; + : dataTypeName dataTypeDefinition? + ; dataTypeName - : OBJECT_NAME - | K_TIMESTAMP - | K_SET - | K_ASCII - | K_BIGINT - | K_BLOB - | K_BOOLEAN - | K_COUNTER - | K_DATE - | K_DECIMAL - | K_DOUBLE - | K_FLOAT - | K_FROZEN - | K_INET - | K_INT - | K_LIST - | K_MAP - | K_SMALLINT - | K_TEXT - | K_TIME - | K_TIMEUUID - | K_TINYINT - | K_TUPLE - | K_VARCHAR - | K_VARINT - | K_TIMESTAMP - | K_UUID - ; + : OBJECT_NAME + | K_TIMESTAMP + | K_SET + | K_ASCII + | K_BIGINT + | K_BLOB + | K_BOOLEAN + | K_COUNTER + | K_DATE + | K_DECIMAL + | K_DOUBLE + | K_FLOAT + | K_FROZEN + | K_INET + | K_INT + | K_LIST + | K_MAP + | K_SMALLINT + | K_TEXT + | K_TIME + | K_TIMEUUID + | K_TINYINT + | K_TUPLE + | K_VARCHAR + | K_VARINT + | K_TIMESTAMP + | K_UUID + ; dataTypeDefinition - : syntaxBracketLa dataTypeName (syntaxComma dataTypeName)* syntaxBracketRa - ; + : syntaxBracketLa dataTypeName (syntaxComma dataTypeName)* syntaxBracketRa + ; orderDirection - : kwAsc - | kwDesc - ; + : kwAsc + | kwDesc + ; role - : OBJECT_NAME - ; + : OBJECT_NAME + ; trigger - : OBJECT_NAME - ; + : OBJECT_NAME + ; triggerClass - : stringLiteral - ; + : stringLiteral + ; materializedView - : OBJECT_NAME - ; + : OBJECT_NAME + ; type_ - : OBJECT_NAME - ; + : OBJECT_NAME + ; aggregate - : OBJECT_NAME - ; + : OBJECT_NAME + ; function_ - : OBJECT_NAME - ; + : OBJECT_NAME + ; language - : OBJECT_NAME - ; + : OBJECT_NAME + ; user - : OBJECT_NAME - ; + : OBJECT_NAME + ; password - : stringLiteral - ; + : stringLiteral + ; hashKey - : OBJECT_NAME - ; + : OBJECT_NAME + ; param - : paramName dataType - ; + : paramName dataType + ; paramName - : OBJECT_NAME - | K_INPUT - ; + : OBJECT_NAME + | K_INPUT + ; kwAdd - : K_ADD - ; + : K_ADD + ; kwAggregate - : K_AGGREGATE - ; + : K_AGGREGATE + ; kwAll - : K_ALL - ; + : K_ALL + ; kwAllPermissions - : K_ALL K_PERMISSIONS - ; + : K_ALL K_PERMISSIONS + ; kwAllow - : K_ALLOW - ; + : K_ALLOW + ; kwAlter - : K_ALTER - ; + : K_ALTER + ; kwAnd - : K_AND - ; + : K_AND + ; kwApply - : K_APPLY - ; + : K_APPLY + ; kwAs - : K_AS - ; + : K_AS + ; kwAsc - : K_ASC - ; + : K_ASC + ; kwAuthorize - : K_AUTHORIZE - ; + : K_AUTHORIZE + ; kwBatch - : K_BATCH - ; + : K_BATCH + ; kwBegin - : K_BEGIN - ; + : K_BEGIN + ; kwBy - : K_BY - ; + : K_BY + ; kwCalled - : K_CALLED - ; + : K_CALLED + ; kwClustering - : K_CLUSTERING - ; + : K_CLUSTERING + ; kwCompact - : K_COMPACT - ; + : K_COMPACT + ; kwContains - : K_CONTAINS - ; + : K_CONTAINS + ; kwCreate - : K_CREATE - ; + : K_CREATE + ; kwDelete - : K_DELETE - ; + : K_DELETE + ; kwDesc - : K_DESC - ; + : K_DESC + ; kwDescibe - : K_DESCRIBE - ; + : K_DESCRIBE + ; kwDistinct - : K_DISTINCT - ; + : K_DISTINCT + ; kwDrop - : K_DROP - ; + : K_DROP + ; kwDurableWrites - : K_DURABLE_WRITES - ; + : K_DURABLE_WRITES + ; kwEntries - : K_ENTRIES - ; + : K_ENTRIES + ; kwExecute - : K_EXECUTE - ; + : K_EXECUTE + ; kwExists - : K_EXISTS - ; + : K_EXISTS + ; kwFiltering - : K_FILTERING - ; + : K_FILTERING + ; kwFinalfunc - : K_FINALFUNC - ; + : K_FINALFUNC + ; kwFrom - : K_FROM - ; + : K_FROM + ; kwFull - : K_FULL - ; + : K_FULL + ; kwFunction - : K_FUNCTION - ; + : K_FUNCTION + ; kwFunctions - : K_FUNCTIONS - ; + : K_FUNCTIONS + ; kwGrant - : K_GRANT - ; + : K_GRANT + ; kwIf - : K_IF - ; + : K_IF + ; kwIn - : K_IN - ; + : K_IN + ; kwIndex - : K_INDEX - ; + : K_INDEX + ; kwInitcond - : K_INITCOND - ; + : K_INITCOND + ; kwInput - : K_INPUT - ; + : K_INPUT + ; kwInsert - : K_INSERT - ; + : K_INSERT + ; kwInto - : K_INTO - ; + : K_INTO + ; kwIs - : K_IS - ; + : K_IS + ; kwJson - : K_JSON - ; + : K_JSON + ; kwKey - : K_KEY - ; + : K_KEY + ; kwKeys - : K_KEYS - ; + : K_KEYS + ; kwKeyspace - : K_KEYSPACE - ; + : K_KEYSPACE + ; kwKeyspaces - : K_KEYSPACES - ; + : K_KEYSPACES + ; kwLanguage - : K_LANGUAGE - ; + : K_LANGUAGE + ; kwLimit - : K_LIMIT - ; + : K_LIMIT + ; kwList - : K_LIST - ; + : K_LIST + ; kwLogged - : K_LOGGED - ; + : K_LOGGED + ; kwLogin - : K_LOGIN - ; + : K_LOGIN + ; kwMaterialized - : K_MATERIALIZED - ; + : K_MATERIALIZED + ; kwModify - : K_MODIFY - ; + : K_MODIFY + ; kwNosuperuser - : K_NOSUPERUSER - ; + : K_NOSUPERUSER + ; kwNorecursive - : K_NORECURSIVE - ; + : K_NORECURSIVE + ; kwNot - : K_NOT - ; + : K_NOT + ; kwNull - : K_NULL - ; + : K_NULL + ; kwOf - : K_OF - ; + : K_OF + ; kwOn - : K_ON - ; + : K_ON + ; kwOptions - : K_OPTIONS - ; + : K_OPTIONS + ; kwOr - : K_OR - ; + : K_OR + ; kwOrder - : K_ORDER - ; + : K_ORDER + ; kwPassword - : K_PASSWORD - ; + : K_PASSWORD + ; kwPrimary - : K_PRIMARY - ; + : K_PRIMARY + ; kwRename - : K_RENAME - ; + : K_RENAME + ; kwReplace - : K_REPLACE - ; + : K_REPLACE + ; kwReplication - : K_REPLICATION - ; + : K_REPLICATION + ; kwReturns - : K_RETURNS - ; + : K_RETURNS + ; kwRole - : K_ROLE - ; + : K_ROLE + ; kwRoles - : K_ROLES - ; + : K_ROLES + ; kwSelect - : K_SELECT - ; + : K_SELECT + ; kwSet - : K_SET - ; + : K_SET + ; kwSfunc - : K_SFUNC - ; + : K_SFUNC + ; kwStorage - : K_STORAGE - ; + : K_STORAGE + ; kwStype - : K_STYPE - ; + : K_STYPE + ; kwSuperuser - : K_SUPERUSER - ; + : K_SUPERUSER + ; kwTable - : K_TABLE - ; + : K_TABLE + ; kwTimestamp - : K_TIMESTAMP - ; + : K_TIMESTAMP + ; kwTo - : K_TO - ; + : K_TO + ; kwTrigger - : K_TRIGGER - ; + : K_TRIGGER + ; kwTruncate - : K_TRUNCATE - ; + : K_TRUNCATE + ; kwTtl - : K_TTL - ; + : K_TTL + ; kwType - : K_TYPE - ; + : K_TYPE + ; kwUnlogged - : K_UNLOGGED - ; + : K_UNLOGGED + ; kwUpdate - : K_UPDATE - ; + : K_UPDATE + ; kwUse - : K_USE - ; + : K_USE + ; kwUser - : K_USER - ; + : K_USER + ; kwUsing - : K_USING - ; + : K_USING + ; kwValues - : K_VALUES - ; + : K_VALUES + ; kwView - : K_VIEW - ; + : K_VIEW + ; kwWhere - : K_WHERE - ; + : K_WHERE + ; kwWith - : K_WITH - ; + : K_WITH + ; kwRevoke - : K_REVOKE - ; + : K_REVOKE + ; // BRACKETS // L - left @@ -1262,41 +1303,41 @@ kwRevoke // c - curly // r - rounded syntaxBracketLr - : LR_BRACKET - ; + : LR_BRACKET + ; syntaxBracketRr - : RR_BRACKET - ; + : RR_BRACKET + ; syntaxBracketLc - : LC_BRACKET - ; + : LC_BRACKET + ; syntaxBracketRc - : RC_BRACKET - ; + : RC_BRACKET + ; syntaxBracketLa - : OPERATOR_LT - ; + : OPERATOR_LT + ; syntaxBracketRa - : OPERATOR_GT - ; + : OPERATOR_GT + ; syntaxBracketLs - : LS_BRACKET - ; + : LS_BRACKET + ; syntaxBracketRs - : RS_BRACKET - ; + : RS_BRACKET + ; syntaxComma - : COMMA - ; + : COMMA + ; syntaxColon - : COLON - ; + : COLON + ; \ No newline at end of file diff --git a/creole/creole.g4 b/creole/creole.g4 index 28350d3101..4b26172a13 100644 --- a/creole/creole.g4 +++ b/creole/creole.g4 @@ -29,137 +29,139 @@ * examples here: http://svn.ez.no/svn/ezcomponents/trunk/Document/tests/files/wiki/creole/ */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar creole; document - : (line? CR)* EOF - ; + : (line? CR)* EOF + ; line - : markup + - ; + : markup+ + ; markup - : bold - | italics - | href - | title - | hline - | text_ - | listitem - | image - | tablerow - | tableheader - | nowiki - ; + : bold + | italics + | href + | title + | hline + | text_ + | listitem + | image + | tablerow + | tableheader + | nowiki + ; text_ - : (TEXT | RSLASH) + ('\\\\' text_)* - ; + : (TEXT | RSLASH)+ ('\\\\' text_)* + ; bold - : '**' markup + '**'? - ; + : '**' markup+ '**'? + ; italics - : RSLASH RSLASH markup + RSLASH RSLASH - ; + : RSLASH RSLASH markup+ RSLASH RSLASH + ; href - : LBRACKET text_ ('|' markup +)? RBRACKET - | LBRACE text_ '|' markup + RBRACE - ; + : LBRACKET text_ ('|' markup+)? RBRACKET + | LBRACE text_ '|' markup+ RBRACE + ; image - : LBRACE text_ RBRACE - ; + : LBRACE text_ RBRACE + ; hline - : '----' - ; + : '----' + ; listitem - : ('*' + markup) - | ('#' + markup) - ; + : ('*'+ markup) + | ('#'+ markup) + ; tableheader - : ('|=' markup +) + '|' WS* - ; + : ('|=' markup+)+ '|' WS* + ; tablerow - : ('|' markup +) + '|' WS* - ; + : ('|' markup+)+ '|' WS* + ; title - : '=' + markup '='* - ; + : '='+ markup '='* + ; nowiki - : NOWIKI - ; - + : NOWIKI + ; HASH - : '#' - ; - + : '#' + ; LBRACKET - : '[[' - ; - + : '[[' + ; RBRACKET - : ']]' - ; - + : ']]' + ; LBRACE - : '{{' - ; - + : '{{' + ; RBRACE - : '}}' - ; - + : '}}' + ; TEXT - : (LETTERS | DIGITS | SYMBOL | WS) + - ; - + : (LETTERS | DIGITS | SYMBOL | WS)+ + ; WS - : [ \t] - ; - + : [ \t] + ; CR - : '\r'? '\n' | EOF - ; - + : '\r'? '\n' + | EOF + ; NOWIKI - : '{{{' .*? '}}}' - ; - + : '{{{' .*? '}}}' + ; RSLASH - : '/' - ; - + : '/' + ; fragment LETTERS - : [a-zA-Z] - ; - + : [a-zA-Z] + ; fragment DIGITS - : [0-9] - ; - + : [0-9] + ; fragment SYMBOL - : '.' | ';' | ':' | ',' | '(' | ')' | '-' | '\\' | '\'' | '~' | '"' | '+' - ; + : '.' + | ';' + | ':' + | ',' + | '(' + | ')' + | '-' + | '\\' + | '\'' + | '~' + | '"' + | '+' + ; \ No newline at end of file diff --git a/csharp/CSharp/CSharpPreprocessorParser.g4 b/csharp/CSharp/CSharpPreprocessorParser.g4 index da779627bc..4339e71a55 100644 --- a/csharp/CSharp/CSharpPreprocessorParser.g4 +++ b/csharp/CSharp/CSharpPreprocessorParser.g4 @@ -2,39 +2,47 @@ // Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) // Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. +// $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 CSharpPreprocessorParser; -options { tokenVocab=CSharpLexer; superClass=CSharpPreprocessorParserBase; } +options { + tokenVocab = CSharpLexer; + superClass = CSharpPreprocessorParserBase; +} -preprocessor_directive returns [bool value] - : DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveDefine(); } #preprocessorDeclaration - | UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveUndef(); } #preprocessorDeclaration - | IF expr=preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveIf(); } #preprocessorConditional - | ELIF expr=preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveElif(); } #preprocessorConditional - | ELSE directive_new_line_or_sharp { this.OnPreprocessorDirectiveElse(); } #preprocessorConditional - | ENDIF directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndif(); } #preprocessorConditional - | LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.OnPreprocessorDirectiveLine(); } #preprocessorLine - | ERROR TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveError(); } #preprocessorDiagnostic - | WARNING TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveWarning(); } #preprocessorDiagnostic - | REGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveRegion(); } #preprocessorRegion - | ENDREGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndregion(); } #preprocessorRegion - | PRAGMA TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectivePragma(); } #preprocessorPragma - | NULLABLE TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveNullable(); } #preprocessorNullable - ; +preprocessor_directive + returns[bool value] + : DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveDefine(); } # preprocessorDeclaration + | UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveUndef(); } # preprocessorDeclaration + | IF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveIf(); } # preprocessorConditional + | ELIF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveElif(); } # preprocessorConditional + | ELSE directive_new_line_or_sharp { this.OnPreprocessorDirectiveElse(); } # preprocessorConditional + | ENDIF directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndif(); } # preprocessorConditional + | LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.OnPreprocessorDirectiveLine(); } # preprocessorLine + | ERROR TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveError(); } # preprocessorDiagnostic + | WARNING TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveWarning(); } # preprocessorDiagnostic + | REGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveRegion(); } # preprocessorRegion + | ENDREGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndregion(); } # preprocessorRegion + | PRAGMA TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectivePragma(); } # preprocessorPragma + | NULLABLE TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveNullable(); } # preprocessorNullable + ; directive_new_line_or_sharp : DIRECTIVE_NEW_LINE | EOF ; -preprocessor_expression returns [string value] - : TRUE { this.OnPreprocessorExpressionTrue(); } - | FALSE { this.OnPreprocessorExpressionFalse(); } - | CONDITIONAL_SYMBOL { this.OnPreprocessorExpressionConditionalSymbol(); } - | OPEN_PARENS expr=preprocessor_expression CLOSE_PARENS { this.OnPreprocessorExpressionConditionalOpenParens(); } - | BANG expr=preprocessor_expression { this.OnPreprocessorExpressionConditionalBang(); } - | expr1=preprocessor_expression OP_EQ expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalEq(); } - | expr1=preprocessor_expression OP_NE expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalNe(); } - | expr1=preprocessor_expression OP_AND expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalAnd(); } - | expr1=preprocessor_expression OP_OR expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalOr(); } - ; +preprocessor_expression + returns[string value] + : TRUE { this.OnPreprocessorExpressionTrue(); } + | FALSE { this.OnPreprocessorExpressionFalse(); } + | CONDITIONAL_SYMBOL { this.OnPreprocessorExpressionConditionalSymbol(); } + | OPEN_PARENS expr = preprocessor_expression CLOSE_PARENS { this.OnPreprocessorExpressionConditionalOpenParens(); } + | BANG expr = preprocessor_expression { this.OnPreprocessorExpressionConditionalBang(); } + | expr1 = preprocessor_expression OP_EQ expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalEq(); } + | expr1 = preprocessor_expression OP_NE expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalNe(); } + | expr1 = preprocessor_expression OP_AND expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalAnd(); } + | expr1 = preprocessor_expression OP_OR expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalOr(); } + ; \ No newline at end of file diff --git a/csharp/CSharpLexer.g4 b/csharp/CSharpLexer.g4 index 64c73ef023..10cdbc336c 100644 --- a/csharp/CSharpLexer.g4 +++ b/csharp/CSharpLexer.g4 @@ -2,1057 +2,1057 @@ // Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) // Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar CSharpLexer; -channels { COMMENTS_CHANNEL, DIRECTIVE } +channels { + COMMENTS_CHANNEL, + DIRECTIVE +} -options { superClass = CSharpLexerBase; } +options { + superClass = CSharpLexerBase; +} BYTE_ORDER_MARK: '\u00EF\u00BB\u00BF'; -SINGLE_LINE_DOC_COMMENT: '///' InputCharacter* -> channel(COMMENTS_CHANNEL); -EMPTY_DELIMITED_DOC_COMMENT: '/***/' -> channel(COMMENTS_CHANNEL); -DELIMITED_DOC_COMMENT: '/**' ~'/' .*? '*/' -> channel(COMMENTS_CHANNEL); -SINGLE_LINE_COMMENT: '//' InputCharacter* -> channel(COMMENTS_CHANNEL); -DELIMITED_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); -WHITESPACES: (Whitespace | NewLine)+ -> channel(HIDDEN); -SHARP: '#' -> mode(DIRECTIVE_MODE), skip; +SINGLE_LINE_DOC_COMMENT : '///' InputCharacter* -> channel(COMMENTS_CHANNEL); +EMPTY_DELIMITED_DOC_COMMENT : '/***/' -> channel(COMMENTS_CHANNEL); +DELIMITED_DOC_COMMENT : '/**' ~'/' .*? '*/' -> channel(COMMENTS_CHANNEL); +SINGLE_LINE_COMMENT : '//' InputCharacter* -> channel(COMMENTS_CHANNEL); +DELIMITED_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +WHITESPACES : (Whitespace | NewLine)+ -> channel(HIDDEN); +SHARP : '#' -> mode(DIRECTIVE_MODE), skip; -ABSTRACT: 'abstract'; -ADD: 'add'; -ALIAS: 'alias'; -ARGLIST: '__arglist'; -AS: 'as'; -ASCENDING: 'ascending'; -ASYNC: 'async'; -AWAIT: 'await'; -BASE: 'base'; -BOOL: 'bool'; -BREAK: 'break'; -BY: 'by'; -BYTE: 'byte'; -CASE: 'case'; -CATCH: 'catch'; -CHAR: 'char'; -CHECKED: 'checked'; -CLASS: 'class'; -CONST: 'const'; -CONTINUE: 'continue'; -DECIMAL: 'decimal'; -DEFAULT: 'default'; -DELEGATE: 'delegate'; -DESCENDING: 'descending'; -DO: 'do'; -DOUBLE: 'double'; -DYNAMIC: 'dynamic'; -ELSE: 'else'; -ENUM: 'enum'; -EQUALS: 'equals'; -EVENT: 'event'; -EXPLICIT: 'explicit'; -EXTERN: 'extern'; -FALSE: 'false'; -FINALLY: 'finally'; -FIXED: 'fixed'; -FLOAT: 'float'; -FOR: 'for'; -FOREACH: 'foreach'; -FROM: 'from'; -GET: 'get'; -GOTO: 'goto'; -GROUP: 'group'; -IF: 'if'; -IMPLICIT: 'implicit'; -IN: 'in'; -INT: 'int'; -INTERFACE: 'interface'; -INTERNAL: 'internal'; -INTO: 'into'; -IS: 'is'; -JOIN: 'join'; -LET: 'let'; -LOCK: 'lock'; -LONG: 'long'; -NAMEOF: 'nameof'; -NAMESPACE: 'namespace'; -NEW: 'new'; -NULL_: 'null'; -OBJECT: 'object'; -ON: 'on'; -OPERATOR: 'operator'; -ORDERBY: 'orderby'; -OUT: 'out'; -OVERRIDE: 'override'; -PARAMS: 'params'; -PARTIAL: 'partial'; -PRIVATE: 'private'; -PROTECTED: 'protected'; -PUBLIC: 'public'; -READONLY: 'readonly'; -REF: 'ref'; -REMOVE: 'remove'; -RETURN: 'return'; -SBYTE: 'sbyte'; -SEALED: 'sealed'; -SELECT: 'select'; -SET: 'set'; -SHORT: 'short'; -SIZEOF: 'sizeof'; -STACKALLOC: 'stackalloc'; -STATIC: 'static'; -STRING: 'string'; -STRUCT: 'struct'; -SWITCH: 'switch'; -THIS: 'this'; -THROW: 'throw'; -TRUE: 'true'; -TRY: 'try'; -TYPEOF: 'typeof'; -UINT: 'uint'; -ULONG: 'ulong'; -UNCHECKED: 'unchecked'; -UNMANAGED: 'unmanaged'; -UNSAFE: 'unsafe'; -USHORT: 'ushort'; -USING: 'using'; -VAR: 'var'; -VIRTUAL: 'virtual'; -VOID: 'void'; -VOLATILE: 'volatile'; -WHEN: 'when'; -WHERE: 'where'; -WHILE: 'while'; -YIELD: 'yield'; +ABSTRACT : 'abstract'; +ADD : 'add'; +ALIAS : 'alias'; +ARGLIST : '__arglist'; +AS : 'as'; +ASCENDING : 'ascending'; +ASYNC : 'async'; +AWAIT : 'await'; +BASE : 'base'; +BOOL : 'bool'; +BREAK : 'break'; +BY : 'by'; +BYTE : 'byte'; +CASE : 'case'; +CATCH : 'catch'; +CHAR : 'char'; +CHECKED : 'checked'; +CLASS : 'class'; +CONST : 'const'; +CONTINUE : 'continue'; +DECIMAL : 'decimal'; +DEFAULT : 'default'; +DELEGATE : 'delegate'; +DESCENDING : 'descending'; +DO : 'do'; +DOUBLE : 'double'; +DYNAMIC : 'dynamic'; +ELSE : 'else'; +ENUM : 'enum'; +EQUALS : 'equals'; +EVENT : 'event'; +EXPLICIT : 'explicit'; +EXTERN : 'extern'; +FALSE : 'false'; +FINALLY : 'finally'; +FIXED : 'fixed'; +FLOAT : 'float'; +FOR : 'for'; +FOREACH : 'foreach'; +FROM : 'from'; +GET : 'get'; +GOTO : 'goto'; +GROUP : 'group'; +IF : 'if'; +IMPLICIT : 'implicit'; +IN : 'in'; +INT : 'int'; +INTERFACE : 'interface'; +INTERNAL : 'internal'; +INTO : 'into'; +IS : 'is'; +JOIN : 'join'; +LET : 'let'; +LOCK : 'lock'; +LONG : 'long'; +NAMEOF : 'nameof'; +NAMESPACE : 'namespace'; +NEW : 'new'; +NULL_ : 'null'; +OBJECT : 'object'; +ON : 'on'; +OPERATOR : 'operator'; +ORDERBY : 'orderby'; +OUT : 'out'; +OVERRIDE : 'override'; +PARAMS : 'params'; +PARTIAL : 'partial'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PUBLIC : 'public'; +READONLY : 'readonly'; +REF : 'ref'; +REMOVE : 'remove'; +RETURN : 'return'; +SBYTE : 'sbyte'; +SEALED : 'sealed'; +SELECT : 'select'; +SET : 'set'; +SHORT : 'short'; +SIZEOF : 'sizeof'; +STACKALLOC : 'stackalloc'; +STATIC : 'static'; +STRING : 'string'; +STRUCT : 'struct'; +SWITCH : 'switch'; +THIS : 'this'; +THROW : 'throw'; +TRUE : 'true'; +TRY : 'try'; +TYPEOF : 'typeof'; +UINT : 'uint'; +ULONG : 'ulong'; +UNCHECKED : 'unchecked'; +UNMANAGED : 'unmanaged'; +UNSAFE : 'unsafe'; +USHORT : 'ushort'; +USING : 'using'; +VAR : 'var'; +VIRTUAL : 'virtual'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHEN : 'when'; +WHERE : 'where'; +WHILE : 'while'; +YIELD : 'yield'; //B.1.6 Identifiers // must be defined after all keywords so the first branch (Available_identifier) does not match keywords // https://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx -IDENTIFIER: '@'? IdentifierOrKeyword; +IDENTIFIER: '@'? IdentifierOrKeyword; //B.1.8 Literals // 0.Equals() would be parsed as an invalid real (1. branch) causing a lexer error -LITERAL_ACCESS: [0-9] ('_'* [0-9])* IntegerTypeSuffix? '.' '@'? IdentifierOrKeyword; -INTEGER_LITERAL: [0-9] ('_'* [0-9])* IntegerTypeSuffix?; -HEX_INTEGER_LITERAL: '0' [xX] ('_'* HexDigit)+ IntegerTypeSuffix?; -BIN_INTEGER_LITERAL: '0' [bB] ('_'* [01])+ IntegerTypeSuffix?; -REAL_LITERAL: ([0-9] ('_'* [0-9])*)? '.' [0-9] ('_'* [0-9])* ExponentPart? [FfDdMm]? | [0-9] ('_'* [0-9])* ([FfDdMm] | ExponentPart [FfDdMm]?); +LITERAL_ACCESS : [0-9] ('_'* [0-9])* IntegerTypeSuffix? '.' '@'? IdentifierOrKeyword; +INTEGER_LITERAL : [0-9] ('_'* [0-9])* IntegerTypeSuffix?; +HEX_INTEGER_LITERAL : '0' [xX] ('_'* HexDigit)+ IntegerTypeSuffix?; +BIN_INTEGER_LITERAL : '0' [bB] ('_'* [01])+ IntegerTypeSuffix?; +REAL_LITERAL: + ([0-9] ('_'* [0-9])*)? '.' [0-9] ('_'* [0-9])* ExponentPart? [FfDdMm]? + | [0-9] ('_'* [0-9])* ([FfDdMm] | ExponentPart [FfDdMm]?) +; -CHARACTER_LITERAL: '\'' (~['\\\r\n\u0085\u2028\u2029] | CommonCharacter) '\''; -REGULAR_STRING: '"' (~["\\\r\n\u0085\u2028\u2029] | CommonCharacter)* '"'; -VERBATIUM_STRING: '@"' (~'"' | '""')* '"'; -INTERPOLATED_REGULAR_STRING_START: '$"' { this.OnInterpolatedRegularStringStart(); } -> pushMode(INTERPOLATION_STRING); -INTERPOLATED_VERBATIUM_STRING_START: '$@"' { this.OnInterpolatedVerbatiumStringStart(); } -> pushMode(INTERPOLATION_STRING); +CHARACTER_LITERAL : '\'' (~['\\\r\n\u0085\u2028\u2029] | CommonCharacter) '\''; +REGULAR_STRING : '"' (~["\\\r\n\u0085\u2028\u2029] | CommonCharacter)* '"'; +VERBATIUM_STRING : '@"' (~'"' | '""')* '"'; +INTERPOLATED_REGULAR_STRING_START: + '$"' { this.OnInterpolatedRegularStringStart(); } -> pushMode(INTERPOLATION_STRING) +; +INTERPOLATED_VERBATIUM_STRING_START: + '$@"' { this.OnInterpolatedVerbatiumStringStart(); } -> pushMode(INTERPOLATION_STRING) +; //B.1.9 Operators And Punctuators -OPEN_BRACE: '{' { this.OnOpenBrace(); }; -CLOSE_BRACE: '}' { this.OnCloseBrace(); }; -OPEN_BRACKET: '['; -CLOSE_BRACKET: ']'; -OPEN_PARENS: '('; -CLOSE_PARENS: ')'; -DOT: '.'; -COMMA: ','; -COLON: ':' { this.OnColon(); }; -SEMICOLON: ';'; -PLUS: '+'; -MINUS: '-'; -STAR: '*'; -DIV: '/'; -PERCENT: '%'; -AMP: '&'; -BITWISE_OR: '|'; -CARET: '^'; -BANG: '!'; -TILDE: '~'; -ASSIGNMENT: '='; -LT: '<'; -GT: '>'; -INTERR: '?'; -DOUBLE_COLON: '::'; -OP_COALESCING: '??'; -OP_INC: '++'; -OP_DEC: '--'; -OP_AND: '&&'; -OP_OR: '||'; -OP_PTR: '->'; -OP_EQ: '=='; -OP_NE: '!='; -OP_LE: '<='; -OP_GE: '>='; -OP_ADD_ASSIGNMENT: '+='; -OP_SUB_ASSIGNMENT: '-='; -OP_MULT_ASSIGNMENT: '*='; -OP_DIV_ASSIGNMENT: '/='; -OP_MOD_ASSIGNMENT: '%='; -OP_AND_ASSIGNMENT: '&='; -OP_OR_ASSIGNMENT: '|='; -OP_XOR_ASSIGNMENT: '^='; -OP_LEFT_SHIFT: '<<'; -OP_LEFT_SHIFT_ASSIGNMENT: '<<='; -OP_COALESCING_ASSIGNMENT: '??='; -OP_RANGE: '..'; +OPEN_BRACE : '{' { this.OnOpenBrace(); }; +CLOSE_BRACE : '}' { this.OnCloseBrace(); }; +OPEN_BRACKET : '['; +CLOSE_BRACKET : ']'; +OPEN_PARENS : '('; +CLOSE_PARENS : ')'; +DOT : '.'; +COMMA : ','; +COLON : ':' { this.OnColon(); }; +SEMICOLON : ';'; +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +DIV : '/'; +PERCENT : '%'; +AMP : '&'; +BITWISE_OR : '|'; +CARET : '^'; +BANG : '!'; +TILDE : '~'; +ASSIGNMENT : '='; +LT : '<'; +GT : '>'; +INTERR : '?'; +DOUBLE_COLON : '::'; +OP_COALESCING : '??'; +OP_INC : '++'; +OP_DEC : '--'; +OP_AND : '&&'; +OP_OR : '||'; +OP_PTR : '->'; +OP_EQ : '=='; +OP_NE : '!='; +OP_LE : '<='; +OP_GE : '>='; +OP_ADD_ASSIGNMENT : '+='; +OP_SUB_ASSIGNMENT : '-='; +OP_MULT_ASSIGNMENT : '*='; +OP_DIV_ASSIGNMENT : '/='; +OP_MOD_ASSIGNMENT : '%='; +OP_AND_ASSIGNMENT : '&='; +OP_OR_ASSIGNMENT : '|='; +OP_XOR_ASSIGNMENT : '^='; +OP_LEFT_SHIFT : '<<'; +OP_LEFT_SHIFT_ASSIGNMENT : '<<='; +OP_COALESCING_ASSIGNMENT : '??='; +OP_RANGE : '..'; // https://msdn.microsoft.com/en-us/library/dn961160.aspx mode INTERPOLATION_STRING; -DOUBLE_CURLY_INSIDE: '{{'; -OPEN_BRACE_INSIDE: '{' { this.OpenBraceInside(); } -> skip, pushMode(DEFAULT_MODE); -REGULAR_CHAR_INSIDE: { this.IsRegularCharInside() }? SimpleEscapeSequence; -VERBATIUM_DOUBLE_QUOTE_INSIDE: { this.IsVerbatiumDoubleQuoteInside() }? '""'; -DOUBLE_QUOTE_INSIDE: '"' { this.OnDoubleQuoteInside(); } -> popMode; -REGULAR_STRING_INSIDE: { this.IsRegularCharInside() }? ~('{' | '\\' | '"')+; -VERBATIUM_INSIDE_STRING: { this.IsVerbatiumDoubleQuoteInside() }? ~('{' | '"')+; +DOUBLE_CURLY_INSIDE : '{{'; +OPEN_BRACE_INSIDE : '{' { this.OpenBraceInside(); } -> skip, pushMode(DEFAULT_MODE); +REGULAR_CHAR_INSIDE : { this.IsRegularCharInside() }? SimpleEscapeSequence; +VERBATIUM_DOUBLE_QUOTE_INSIDE : { this.IsVerbatiumDoubleQuoteInside() }? '""'; +DOUBLE_QUOTE_INSIDE : '"' { this.OnDoubleQuoteInside(); } -> popMode; +REGULAR_STRING_INSIDE : { this.IsRegularCharInside() }? ~('{' | '\\' | '"')+; +VERBATIUM_INSIDE_STRING : { this.IsVerbatiumDoubleQuoteInside() }? ~('{' | '"')+; mode INTERPOLATION_FORMAT; -DOUBLE_CURLY_CLOSE_INSIDE: '}}' -> type(FORMAT_STRING); -CLOSE_BRACE_INSIDE: '}' { this.OnCloseBraceInside(); } -> skip, popMode; -FORMAT_STRING: ~'}'+; +DOUBLE_CURLY_CLOSE_INSIDE : '}}' -> type(FORMAT_STRING); +CLOSE_BRACE_INSIDE : '}' { this.OnCloseBraceInside(); } -> skip, popMode; +FORMAT_STRING : ~'}'+; mode DIRECTIVE_MODE; -DIRECTIVE_WHITESPACES: Whitespace+ -> channel(HIDDEN); -DIGITS: [0-9]+ -> channel(DIRECTIVE); -DIRECTIVE_TRUE: 'true' -> channel(DIRECTIVE), type(TRUE); -DIRECTIVE_FALSE: 'false' -> channel(DIRECTIVE), type(FALSE); -DEFINE: 'define' -> channel(DIRECTIVE); -UNDEF: 'undef' -> channel(DIRECTIVE); -DIRECTIVE_IF: 'if' -> channel(DIRECTIVE), type(IF); -ELIF: 'elif' -> channel(DIRECTIVE); -DIRECTIVE_ELSE: 'else' -> channel(DIRECTIVE), type(ELSE); -ENDIF: 'endif' -> channel(DIRECTIVE); -LINE: 'line' -> channel(DIRECTIVE); -ERROR: 'error' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); -WARNING: 'warning' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); -REGION: 'region' Whitespace* -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); -ENDREGION: 'endregion' Whitespace* -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); -PRAGMA: 'pragma' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); -NULLABLE: 'nullable' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); -DIRECTIVE_DEFAULT: 'default' -> channel(DIRECTIVE), type(DEFAULT); -DIRECTIVE_HIDDEN: 'hidden' -> channel(DIRECTIVE); -DIRECTIVE_OPEN_PARENS: '(' -> channel(DIRECTIVE), type(OPEN_PARENS); -DIRECTIVE_CLOSE_PARENS: ')' -> channel(DIRECTIVE), type(CLOSE_PARENS); -DIRECTIVE_BANG: '!' -> channel(DIRECTIVE), type(BANG); -DIRECTIVE_OP_EQ: '==' -> channel(DIRECTIVE), type(OP_EQ); -DIRECTIVE_OP_NE: '!=' -> channel(DIRECTIVE), type(OP_NE); -DIRECTIVE_OP_AND: '&&' -> channel(DIRECTIVE), type(OP_AND); -DIRECTIVE_OP_OR: '||' -> channel(DIRECTIVE), type(OP_OR); -DIRECTIVE_STRING: '"' ~('"' | [\r\n\u0085\u2028\u2029])* '"' -> channel(DIRECTIVE), type(STRING); -CONDITIONAL_SYMBOL: IdentifierOrKeyword -> channel(DIRECTIVE); -DIRECTIVE_SINGLE_LINE_COMMENT: '//' ~[\r\n\u0085\u2028\u2029]* -> channel(COMMENTS_CHANNEL), type(SINGLE_LINE_COMMENT); -DIRECTIVE_NEW_LINE: NewLine -> channel(DIRECTIVE), mode(DEFAULT_MODE); +DIRECTIVE_WHITESPACES : Whitespace+ -> channel(HIDDEN); +DIGITS : [0-9]+ -> channel(DIRECTIVE); +DIRECTIVE_TRUE : 'true' -> channel(DIRECTIVE), type(TRUE); +DIRECTIVE_FALSE : 'false' -> channel(DIRECTIVE), type(FALSE); +DEFINE : 'define' -> channel(DIRECTIVE); +UNDEF : 'undef' -> channel(DIRECTIVE); +DIRECTIVE_IF : 'if' -> channel(DIRECTIVE), type(IF); +ELIF : 'elif' -> channel(DIRECTIVE); +DIRECTIVE_ELSE : 'else' -> channel(DIRECTIVE), type(ELSE); +ENDIF : 'endif' -> channel(DIRECTIVE); +LINE : 'line' -> channel(DIRECTIVE); +ERROR : 'error' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +WARNING : 'warning' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +REGION : 'region' Whitespace* -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +ENDREGION : 'endregion' Whitespace* -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +PRAGMA : 'pragma' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +NULLABLE : 'nullable' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +DIRECTIVE_DEFAULT : 'default' -> channel(DIRECTIVE), type(DEFAULT); +DIRECTIVE_HIDDEN : 'hidden' -> channel(DIRECTIVE); +DIRECTIVE_OPEN_PARENS : '(' -> channel(DIRECTIVE), type(OPEN_PARENS); +DIRECTIVE_CLOSE_PARENS : ')' -> channel(DIRECTIVE), type(CLOSE_PARENS); +DIRECTIVE_BANG : '!' -> channel(DIRECTIVE), type(BANG); +DIRECTIVE_OP_EQ : '==' -> channel(DIRECTIVE), type(OP_EQ); +DIRECTIVE_OP_NE : '!=' -> channel(DIRECTIVE), type(OP_NE); +DIRECTIVE_OP_AND : '&&' -> channel(DIRECTIVE), type(OP_AND); +DIRECTIVE_OP_OR : '||' -> channel(DIRECTIVE), type(OP_OR); +DIRECTIVE_STRING: + '"' ~('"' | [\r\n\u0085\u2028\u2029])* '"' -> channel(DIRECTIVE), type(STRING) +; +CONDITIONAL_SYMBOL: IdentifierOrKeyword -> channel(DIRECTIVE); +DIRECTIVE_SINGLE_LINE_COMMENT: + '//' ~[\r\n\u0085\u2028\u2029]* -> channel(COMMENTS_CHANNEL), type(SINGLE_LINE_COMMENT) +; +DIRECTIVE_NEW_LINE: NewLine -> channel(DIRECTIVE), mode(DEFAULT_MODE); mode DIRECTIVE_TEXT; -TEXT: ~[\r\n\u0085\u2028\u2029]+ -> channel(DIRECTIVE); -TEXT_NEW_LINE: NewLine -> channel(DIRECTIVE), type(DIRECTIVE_NEW_LINE), mode(DEFAULT_MODE); +TEXT : ~[\r\n\u0085\u2028\u2029]+ -> channel(DIRECTIVE); +TEXT_NEW_LINE : NewLine -> channel(DIRECTIVE), type(DIRECTIVE_NEW_LINE), mode(DEFAULT_MODE); // Fragments -fragment InputCharacter: ~[\r\n\u0085\u2028\u2029]; +fragment InputCharacter: ~[\r\n\u0085\u2028\u2029]; -fragment NewLineCharacter - : '\u000D' //'' - | '\u000A' //'' - | '\u0085' //'' - | '\u2028' //'' - | '\u2029' //'' - ; +fragment NewLineCharacter: + '\u000D' //'' + | '\u000A' //'' + | '\u0085' //'' + | '\u2028' //'' + | '\u2029' //'' +; -fragment IntegerTypeSuffix: [lL]? [uU] | [uU]? [lL]; -fragment ExponentPart: [eE] ('+' | '-')? [0-9] ('_'* [0-9])*; +fragment IntegerTypeSuffix : [lL]? [uU] | [uU]? [lL]; +fragment ExponentPart : [eE] ('+' | '-')? [0-9] ('_'* [0-9])*; -fragment CommonCharacter - : SimpleEscapeSequence - | HexEscapeSequence - | UnicodeEscapeSequence - ; +fragment CommonCharacter: SimpleEscapeSequence | HexEscapeSequence | UnicodeEscapeSequence; -fragment SimpleEscapeSequence - : '\\\'' - | '\\"' - | '\\\\' - | '\\0' - | '\\a' - | '\\b' - | '\\f' - | '\\n' - | '\\r' - | '\\t' - | '\\v' - ; +fragment SimpleEscapeSequence: + '\\\'' + | '\\"' + | '\\\\' + | '\\0' + | '\\a' + | '\\b' + | '\\f' + | '\\n' + | '\\r' + | '\\t' + | '\\v' +; -fragment HexEscapeSequence - : '\\x' HexDigit - | '\\x' HexDigit HexDigit - | '\\x' HexDigit HexDigit HexDigit - | '\\x' HexDigit HexDigit HexDigit HexDigit - ; +fragment HexEscapeSequence: + '\\x' HexDigit + | '\\x' HexDigit HexDigit + | '\\x' HexDigit HexDigit HexDigit + | '\\x' HexDigit HexDigit HexDigit HexDigit +; -fragment NewLine - : '\r\n' | '\r' | '\n' - | '\u0085' // ' - | '\u2028' //'' - | '\u2029' //'' - ; +fragment NewLine: + '\r\n' + | '\r' + | '\n' + | '\u0085' // ' + | '\u2028' //'' + | '\u2029' //'' +; -fragment Whitespace - : UnicodeClassZS //'' - | '\u0009' //'' - | '\u000B' //'' - | '\u000C' //'
' - ; +fragment Whitespace: + UnicodeClassZS //'' + | '\u0009' //'' + | '\u000B' //'' + | '\u000C' //'' +; -fragment UnicodeClassZS - : '\u0020' // SPACE - | '\u00A0' // NO_BREAK SPACE - | '\u1680' // OGHAM SPACE MARK - | '\u180E' // MONGOLIAN VOWEL SEPARATOR - | '\u2000' // EN QUAD - | '\u2001' // EM QUAD - | '\u2002' // EN SPACE - | '\u2003' // EM SPACE - | '\u2004' // THREE_PER_EM SPACE - | '\u2005' // FOUR_PER_EM SPACE - | '\u2006' // SIX_PER_EM SPACE - | '\u2008' // PUNCTUATION SPACE - | '\u2009' // THIN SPACE - | '\u200A' // HAIR SPACE - | '\u202F' // NARROW NO_BREAK SPACE - | '\u3000' // IDEOGRAPHIC SPACE - | '\u205F' // MEDIUM MATHEMATICAL SPACE - ; +fragment UnicodeClassZS: + '\u0020' // SPACE + | '\u00A0' // NO_BREAK SPACE + | '\u1680' // OGHAM SPACE MARK + | '\u180E' // MONGOLIAN VOWEL SEPARATOR + | '\u2000' // EN QUAD + | '\u2001' // EM QUAD + | '\u2002' // EN SPACE + | '\u2003' // EM SPACE + | '\u2004' // THREE_PER_EM SPACE + | '\u2005' // FOUR_PER_EM SPACE + | '\u2006' // SIX_PER_EM SPACE + | '\u2008' // PUNCTUATION SPACE + | '\u2009' // THIN SPACE + | '\u200A' // HAIR SPACE + | '\u202F' // NARROW NO_BREAK SPACE + | '\u3000' // IDEOGRAPHIC SPACE + | '\u205F' // MEDIUM MATHEMATICAL SPACE +; -fragment IdentifierOrKeyword - : IdentifierStartCharacter IdentifierPartCharacter* - ; +fragment IdentifierOrKeyword: IdentifierStartCharacter IdentifierPartCharacter*; -fragment IdentifierStartCharacter - : LetterCharacter - | '_' - ; +fragment IdentifierStartCharacter: LetterCharacter | '_'; -fragment IdentifierPartCharacter - : LetterCharacter - | DecimalDigitCharacter - | ConnectingCharacter - | CombiningCharacter - | FormattingCharacter - ; +fragment IdentifierPartCharacter: + LetterCharacter + | DecimalDigitCharacter + | ConnectingCharacter + | CombiningCharacter + | FormattingCharacter +; //'' // WARNING: ignores UnicodeEscapeSequence -fragment LetterCharacter - : UnicodeClassLU - | UnicodeClassLL - | UnicodeClassLT - | UnicodeClassLM - | UnicodeClassLO - | UnicodeClassNL - | UnicodeEscapeSequence - ; +fragment LetterCharacter: + UnicodeClassLU + | UnicodeClassLL + | UnicodeClassLT + | UnicodeClassLM + | UnicodeClassLO + | UnicodeClassNL + | UnicodeEscapeSequence +; //'' // WARNING: ignores UnicodeEscapeSequence -fragment DecimalDigitCharacter - : UnicodeClassND - | UnicodeEscapeSequence - ; +fragment DecimalDigitCharacter: UnicodeClassND | UnicodeEscapeSequence; //'' // WARNING: ignores UnicodeEscapeSequence -fragment ConnectingCharacter - : UnicodeClassPC - | UnicodeEscapeSequence - ; +fragment ConnectingCharacter: UnicodeClassPC | UnicodeEscapeSequence; //'' // WARNING: ignores UnicodeEscapeSequence -fragment CombiningCharacter - : UnicodeClassMN - | UnicodeClassMC - | UnicodeEscapeSequence - ; +fragment CombiningCharacter: UnicodeClassMN | UnicodeClassMC | UnicodeEscapeSequence; //'' // WARNING: ignores UnicodeEscapeSequence -fragment FormattingCharacter - : UnicodeClassCF - | UnicodeEscapeSequence - ; +fragment FormattingCharacter: UnicodeClassCF | UnicodeEscapeSequence; //B.1.5 Unicode Character Escape Sequences -fragment UnicodeEscapeSequence - : '\\u' HexDigit HexDigit HexDigit HexDigit - | '\\U' HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit - ; +fragment UnicodeEscapeSequence: + '\\u' HexDigit HexDigit HexDigit HexDigit + | '\\U' HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit +; -fragment HexDigit : [0-9] | [A-F] | [a-f]; +fragment HexDigit: [0-9] | [A-F] | [a-f]; // Unicode character classes -fragment UnicodeClassLU - : '\u0041'..'\u005a' - | '\u00c0'..'\u00d6' - | '\u00d8'..'\u00de' - | '\u0100'..'\u0136' - | '\u0139'..'\u0147' - | '\u014a'..'\u0178' - | '\u0179'..'\u017d' - | '\u0181'..'\u0182' - | '\u0184'..'\u0186' - | '\u0187'..'\u0189' - | '\u018a'..'\u018b' - | '\u018e'..'\u0191' - | '\u0193'..'\u0194' - | '\u0196'..'\u0198' - | '\u019c'..'\u019d' - | '\u019f'..'\u01a0' - | '\u01a2'..'\u01a6' - | '\u01a7'..'\u01a9' - | '\u01ac'..'\u01ae' - | '\u01af'..'\u01b1' - | '\u01b2'..'\u01b3' - | '\u01b5'..'\u01b7' - | '\u01b8'..'\u01bc' - | '\u01c4'..'\u01cd' - | '\u01cf'..'\u01db' - | '\u01de'..'\u01ee' - | '\u01f1'..'\u01f4' - | '\u01f6'..'\u01f8' - | '\u01fa'..'\u0232' - | '\u023a'..'\u023b' - | '\u023d'..'\u023e' - | '\u0241'..'\u0243' - | '\u0244'..'\u0246' - | '\u0248'..'\u024e' - | '\u0370'..'\u0372' - | '\u0376'..'\u037f' - | '\u0386'..'\u0388' - | '\u0389'..'\u038a' - | '\u038c'..'\u038e' - | '\u038f'..'\u0391' - | '\u0392'..'\u03a1' - | '\u03a3'..'\u03ab' - | '\u03cf'..'\u03d2' - | '\u03d3'..'\u03d4' - | '\u03d8'..'\u03ee' - | '\u03f4'..'\u03f7' - | '\u03f9'..'\u03fa' - | '\u03fd'..'\u042f' - | '\u0460'..'\u0480' - | '\u048a'..'\u04c0' - | '\u04c1'..'\u04cd' - | '\u04d0'..'\u052e' - | '\u0531'..'\u0556' - | '\u10a0'..'\u10c5' - | '\u10c7'..'\u10cd' - | '\u1e00'..'\u1e94' - | '\u1e9e'..'\u1efe' - | '\u1f08'..'\u1f0f' - | '\u1f18'..'\u1f1d' - | '\u1f28'..'\u1f2f' - | '\u1f38'..'\u1f3f' - | '\u1f48'..'\u1f4d' - | '\u1f59'..'\u1f5f' - | '\u1f68'..'\u1f6f' - | '\u1fb8'..'\u1fbb' - | '\u1fc8'..'\u1fcb' - | '\u1fd8'..'\u1fdb' - | '\u1fe8'..'\u1fec' - | '\u1ff8'..'\u1ffb' - | '\u2102'..'\u2107' - | '\u210b'..'\u210d' - | '\u2110'..'\u2112' - | '\u2115'..'\u2119' - | '\u211a'..'\u211d' - | '\u2124'..'\u212a' - | '\u212b'..'\u212d' - | '\u2130'..'\u2133' - | '\u213e'..'\u213f' - | '\u2145'..'\u2183' - | '\u2c00'..'\u2c2e' - | '\u2c60'..'\u2c62' - | '\u2c63'..'\u2c64' - | '\u2c67'..'\u2c6d' - | '\u2c6e'..'\u2c70' - | '\u2c72'..'\u2c75' - | '\u2c7e'..'\u2c80' - | '\u2c82'..'\u2ce2' - | '\u2ceb'..'\u2ced' - | '\u2cf2'..'\ua640' - | '\ua642'..'\ua66c' - | '\ua680'..'\ua69a' - | '\ua722'..'\ua72e' - | '\ua732'..'\ua76e' - | '\ua779'..'\ua77d' - | '\ua77e'..'\ua786' - | '\ua78b'..'\ua78d' - | '\ua790'..'\ua792' - | '\ua796'..'\ua7aa' - | '\ua7ab'..'\ua7ad' - | '\ua7b0'..'\ua7b1' - | '\uff21'..'\uff3a' - ; +fragment UnicodeClassLU: + '\u0041' ..'\u005a' + | '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00de' + | '\u0100' ..'\u0136' + | '\u0139' ..'\u0147' + | '\u014a' ..'\u0178' + | '\u0179' ..'\u017d' + | '\u0181' ..'\u0182' + | '\u0184' ..'\u0186' + | '\u0187' ..'\u0189' + | '\u018a' ..'\u018b' + | '\u018e' ..'\u0191' + | '\u0193' ..'\u0194' + | '\u0196' ..'\u0198' + | '\u019c' ..'\u019d' + | '\u019f' ..'\u01a0' + | '\u01a2' ..'\u01a6' + | '\u01a7' ..'\u01a9' + | '\u01ac' ..'\u01ae' + | '\u01af' ..'\u01b1' + | '\u01b2' ..'\u01b3' + | '\u01b5' ..'\u01b7' + | '\u01b8' ..'\u01bc' + | '\u01c4' ..'\u01cd' + | '\u01cf' ..'\u01db' + | '\u01de' ..'\u01ee' + | '\u01f1' ..'\u01f4' + | '\u01f6' ..'\u01f8' + | '\u01fa' ..'\u0232' + | '\u023a' ..'\u023b' + | '\u023d' ..'\u023e' + | '\u0241' ..'\u0243' + | '\u0244' ..'\u0246' + | '\u0248' ..'\u024e' + | '\u0370' ..'\u0372' + | '\u0376' ..'\u037f' + | '\u0386' ..'\u0388' + | '\u0389' ..'\u038a' + | '\u038c' ..'\u038e' + | '\u038f' ..'\u0391' + | '\u0392' ..'\u03a1' + | '\u03a3' ..'\u03ab' + | '\u03cf' ..'\u03d2' + | '\u03d3' ..'\u03d4' + | '\u03d8' ..'\u03ee' + | '\u03f4' ..'\u03f7' + | '\u03f9' ..'\u03fa' + | '\u03fd' ..'\u042f' + | '\u0460' ..'\u0480' + | '\u048a' ..'\u04c0' + | '\u04c1' ..'\u04cd' + | '\u04d0' ..'\u052e' + | '\u0531' ..'\u0556' + | '\u10a0' ..'\u10c5' + | '\u10c7' ..'\u10cd' + | '\u1e00' ..'\u1e94' + | '\u1e9e' ..'\u1efe' + | '\u1f08' ..'\u1f0f' + | '\u1f18' ..'\u1f1d' + | '\u1f28' ..'\u1f2f' + | '\u1f38' ..'\u1f3f' + | '\u1f48' ..'\u1f4d' + | '\u1f59' ..'\u1f5f' + | '\u1f68' ..'\u1f6f' + | '\u1fb8' ..'\u1fbb' + | '\u1fc8' ..'\u1fcb' + | '\u1fd8' ..'\u1fdb' + | '\u1fe8' ..'\u1fec' + | '\u1ff8' ..'\u1ffb' + | '\u2102' ..'\u2107' + | '\u210b' ..'\u210d' + | '\u2110' ..'\u2112' + | '\u2115' ..'\u2119' + | '\u211a' ..'\u211d' + | '\u2124' ..'\u212a' + | '\u212b' ..'\u212d' + | '\u2130' ..'\u2133' + | '\u213e' ..'\u213f' + | '\u2145' ..'\u2183' + | '\u2c00' ..'\u2c2e' + | '\u2c60' ..'\u2c62' + | '\u2c63' ..'\u2c64' + | '\u2c67' ..'\u2c6d' + | '\u2c6e' ..'\u2c70' + | '\u2c72' ..'\u2c75' + | '\u2c7e' ..'\u2c80' + | '\u2c82' ..'\u2ce2' + | '\u2ceb' ..'\u2ced' + | '\u2cf2' ..'\ua640' + | '\ua642' ..'\ua66c' + | '\ua680' ..'\ua69a' + | '\ua722' ..'\ua72e' + | '\ua732' ..'\ua76e' + | '\ua779' ..'\ua77d' + | '\ua77e' ..'\ua786' + | '\ua78b' ..'\ua78d' + | '\ua790' ..'\ua792' + | '\ua796' ..'\ua7aa' + | '\ua7ab' ..'\ua7ad' + | '\ua7b0' ..'\ua7b1' + | '\uff21' ..'\uff3a' +; -fragment UnicodeClassLL - : '\u0061'..'\u007A' - | '\u00b5'..'\u00df' - | '\u00e0'..'\u00f6' - | '\u00f8'..'\u00ff' - | '\u0101'..'\u0137' - | '\u0138'..'\u0148' - | '\u0149'..'\u0177' - | '\u017a'..'\u017e' - | '\u017f'..'\u0180' - | '\u0183'..'\u0185' - | '\u0188'..'\u018c' - | '\u018d'..'\u0192' - | '\u0195'..'\u0199' - | '\u019a'..'\u019b' - | '\u019e'..'\u01a1' - | '\u01a3'..'\u01a5' - | '\u01a8'..'\u01aa' - | '\u01ab'..'\u01ad' - | '\u01b0'..'\u01b4' - | '\u01b6'..'\u01b9' - | '\u01ba'..'\u01bd' - | '\u01be'..'\u01bf' - | '\u01c6'..'\u01cc' - | '\u01ce'..'\u01dc' - | '\u01dd'..'\u01ef' - | '\u01f0'..'\u01f3' - | '\u01f5'..'\u01f9' - | '\u01fb'..'\u0233' - | '\u0234'..'\u0239' - | '\u023c'..'\u023f' - | '\u0240'..'\u0242' - | '\u0247'..'\u024f' - | '\u0250'..'\u0293' - | '\u0295'..'\u02af' - | '\u0371'..'\u0373' - | '\u0377'..'\u037b' - | '\u037c'..'\u037d' - | '\u0390'..'\u03ac' - | '\u03ad'..'\u03ce' - | '\u03d0'..'\u03d1' - | '\u03d5'..'\u03d7' - | '\u03d9'..'\u03ef' - | '\u03f0'..'\u03f3' - | '\u03f5'..'\u03fb' - | '\u03fc'..'\u0430' - | '\u0431'..'\u045f' - | '\u0461'..'\u0481' - | '\u048b'..'\u04bf' - | '\u04c2'..'\u04ce' - | '\u04cf'..'\u052f' - | '\u0561'..'\u0587' - | '\u1d00'..'\u1d2b' - | '\u1d6b'..'\u1d77' - | '\u1d79'..'\u1d9a' - | '\u1e01'..'\u1e95' - | '\u1e96'..'\u1e9d' - | '\u1e9f'..'\u1eff' - | '\u1f00'..'\u1f07' - | '\u1f10'..'\u1f15' - | '\u1f20'..'\u1f27' - | '\u1f30'..'\u1f37' - | '\u1f40'..'\u1f45' - | '\u1f50'..'\u1f57' - | '\u1f60'..'\u1f67' - | '\u1f70'..'\u1f7d' - | '\u1f80'..'\u1f87' - | '\u1f90'..'\u1f97' - | '\u1fa0'..'\u1fa7' - | '\u1fb0'..'\u1fb4' - | '\u1fb6'..'\u1fb7' - | '\u1fbe'..'\u1fc2' - | '\u1fc3'..'\u1fc4' - | '\u1fc6'..'\u1fc7' - | '\u1fd0'..'\u1fd3' - | '\u1fd6'..'\u1fd7' - | '\u1fe0'..'\u1fe7' - | '\u1ff2'..'\u1ff4' - | '\u1ff6'..'\u1ff7' - | '\u210a'..'\u210e' - | '\u210f'..'\u2113' - | '\u212f'..'\u2139' - | '\u213c'..'\u213d' - | '\u2146'..'\u2149' - | '\u214e'..'\u2184' - | '\u2c30'..'\u2c5e' - | '\u2c61'..'\u2c65' - | '\u2c66'..'\u2c6c' - | '\u2c71'..'\u2c73' - | '\u2c74'..'\u2c76' - | '\u2c77'..'\u2c7b' - | '\u2c81'..'\u2ce3' - | '\u2ce4'..'\u2cec' - | '\u2cee'..'\u2cf3' - | '\u2d00'..'\u2d25' - | '\u2d27'..'\u2d2d' - | '\ua641'..'\ua66d' - | '\ua681'..'\ua69b' - | '\ua723'..'\ua72f' - | '\ua730'..'\ua731' - | '\ua733'..'\ua771' - | '\ua772'..'\ua778' - | '\ua77a'..'\ua77c' - | '\ua77f'..'\ua787' - | '\ua78c'..'\ua78e' - | '\ua791'..'\ua793' - | '\ua794'..'\ua795' - | '\ua797'..'\ua7a9' - | '\ua7fa'..'\uab30' - | '\uab31'..'\uab5a' - | '\uab64'..'\uab65' - | '\ufb00'..'\ufb06' - | '\ufb13'..'\ufb17' - | '\uff41'..'\uff5a' - ; +fragment UnicodeClassLL: + '\u0061' ..'\u007A' + | '\u00b5' ..'\u00df' + | '\u00e0' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0101' ..'\u0137' + | '\u0138' ..'\u0148' + | '\u0149' ..'\u0177' + | '\u017a' ..'\u017e' + | '\u017f' ..'\u0180' + | '\u0183' ..'\u0185' + | '\u0188' ..'\u018c' + | '\u018d' ..'\u0192' + | '\u0195' ..'\u0199' + | '\u019a' ..'\u019b' + | '\u019e' ..'\u01a1' + | '\u01a3' ..'\u01a5' + | '\u01a8' ..'\u01aa' + | '\u01ab' ..'\u01ad' + | '\u01b0' ..'\u01b4' + | '\u01b6' ..'\u01b9' + | '\u01ba' ..'\u01bd' + | '\u01be' ..'\u01bf' + | '\u01c6' ..'\u01cc' + | '\u01ce' ..'\u01dc' + | '\u01dd' ..'\u01ef' + | '\u01f0' ..'\u01f3' + | '\u01f5' ..'\u01f9' + | '\u01fb' ..'\u0233' + | '\u0234' ..'\u0239' + | '\u023c' ..'\u023f' + | '\u0240' ..'\u0242' + | '\u0247' ..'\u024f' + | '\u0250' ..'\u0293' + | '\u0295' ..'\u02af' + | '\u0371' ..'\u0373' + | '\u0377' ..'\u037b' + | '\u037c' ..'\u037d' + | '\u0390' ..'\u03ac' + | '\u03ad' ..'\u03ce' + | '\u03d0' ..'\u03d1' + | '\u03d5' ..'\u03d7' + | '\u03d9' ..'\u03ef' + | '\u03f0' ..'\u03f3' + | '\u03f5' ..'\u03fb' + | '\u03fc' ..'\u0430' + | '\u0431' ..'\u045f' + | '\u0461' ..'\u0481' + | '\u048b' ..'\u04bf' + | '\u04c2' ..'\u04ce' + | '\u04cf' ..'\u052f' + | '\u0561' ..'\u0587' + | '\u1d00' ..'\u1d2b' + | '\u1d6b' ..'\u1d77' + | '\u1d79' ..'\u1d9a' + | '\u1e01' ..'\u1e95' + | '\u1e96' ..'\u1e9d' + | '\u1e9f' ..'\u1eff' + | '\u1f00' ..'\u1f07' + | '\u1f10' ..'\u1f15' + | '\u1f20' ..'\u1f27' + | '\u1f30' ..'\u1f37' + | '\u1f40' ..'\u1f45' + | '\u1f50' ..'\u1f57' + | '\u1f60' ..'\u1f67' + | '\u1f70' ..'\u1f7d' + | '\u1f80' ..'\u1f87' + | '\u1f90' ..'\u1f97' + | '\u1fa0' ..'\u1fa7' + | '\u1fb0' ..'\u1fb4' + | '\u1fb6' ..'\u1fb7' + | '\u1fbe' ..'\u1fc2' + | '\u1fc3' ..'\u1fc4' + | '\u1fc6' ..'\u1fc7' + | '\u1fd0' ..'\u1fd3' + | '\u1fd6' ..'\u1fd7' + | '\u1fe0' ..'\u1fe7' + | '\u1ff2' ..'\u1ff4' + | '\u1ff6' ..'\u1ff7' + | '\u210a' ..'\u210e' + | '\u210f' ..'\u2113' + | '\u212f' ..'\u2139' + | '\u213c' ..'\u213d' + | '\u2146' ..'\u2149' + | '\u214e' ..'\u2184' + | '\u2c30' ..'\u2c5e' + | '\u2c61' ..'\u2c65' + | '\u2c66' ..'\u2c6c' + | '\u2c71' ..'\u2c73' + | '\u2c74' ..'\u2c76' + | '\u2c77' ..'\u2c7b' + | '\u2c81' ..'\u2ce3' + | '\u2ce4' ..'\u2cec' + | '\u2cee' ..'\u2cf3' + | '\u2d00' ..'\u2d25' + | '\u2d27' ..'\u2d2d' + | '\ua641' ..'\ua66d' + | '\ua681' ..'\ua69b' + | '\ua723' ..'\ua72f' + | '\ua730' ..'\ua731' + | '\ua733' ..'\ua771' + | '\ua772' ..'\ua778' + | '\ua77a' ..'\ua77c' + | '\ua77f' ..'\ua787' + | '\ua78c' ..'\ua78e' + | '\ua791' ..'\ua793' + | '\ua794' ..'\ua795' + | '\ua797' ..'\ua7a9' + | '\ua7fa' ..'\uab30' + | '\uab31' ..'\uab5a' + | '\uab64' ..'\uab65' + | '\ufb00' ..'\ufb06' + | '\ufb13' ..'\ufb17' + | '\uff41' ..'\uff5a' +; -fragment UnicodeClassLT - : '\u01c5'..'\u01cb' - | '\u01f2'..'\u1f88' - | '\u1f89'..'\u1f8f' - | '\u1f98'..'\u1f9f' - | '\u1fa8'..'\u1faf' - | '\u1fbc'..'\u1fcc' - | '\u1ffc'..'\u1ffc' - ; +fragment UnicodeClassLT: + '\u01c5' ..'\u01cb' + | '\u01f2' ..'\u1f88' + | '\u1f89' ..'\u1f8f' + | '\u1f98' ..'\u1f9f' + | '\u1fa8' ..'\u1faf' + | '\u1fbc' ..'\u1fcc' + | '\u1ffc' ..'\u1ffc' +; -fragment UnicodeClassLM - : '\u02b0'..'\u02c1' - | '\u02c6'..'\u02d1' - | '\u02e0'..'\u02e4' - | '\u02ec'..'\u02ee' - | '\u0374'..'\u037a' - | '\u0559'..'\u0640' - | '\u06e5'..'\u06e6' - | '\u07f4'..'\u07f5' - | '\u07fa'..'\u081a' - | '\u0824'..'\u0828' - | '\u0971'..'\u0e46' - | '\u0ec6'..'\u10fc' - | '\u17d7'..'\u1843' - | '\u1aa7'..'\u1c78' - | '\u1c79'..'\u1c7d' - | '\u1d2c'..'\u1d6a' - | '\u1d78'..'\u1d9b' - | '\u1d9c'..'\u1dbf' - | '\u2071'..'\u207f' - | '\u2090'..'\u209c' - | '\u2c7c'..'\u2c7d' - | '\u2d6f'..'\u2e2f' - | '\u3005'..'\u3031' - | '\u3032'..'\u3035' - | '\u303b'..'\u309d' - | '\u309e'..'\u30fc' - | '\u30fd'..'\u30fe' - | '\ua015'..'\ua4f8' - | '\ua4f9'..'\ua4fd' - | '\ua60c'..'\ua67f' - | '\ua69c'..'\ua69d' - | '\ua717'..'\ua71f' - | '\ua770'..'\ua788' - | '\ua7f8'..'\ua7f9' - | '\ua9cf'..'\ua9e6' - | '\uaa70'..'\uaadd' - | '\uaaf3'..'\uaaf4' - | '\uab5c'..'\uab5f' - | '\uff70'..'\uff9e' - | '\uff9f'..'\uff9f' - ; +fragment UnicodeClassLM: + '\u02b0' ..'\u02c1' + | '\u02c6' ..'\u02d1' + | '\u02e0' ..'\u02e4' + | '\u02ec' ..'\u02ee' + | '\u0374' ..'\u037a' + | '\u0559' ..'\u0640' + | '\u06e5' ..'\u06e6' + | '\u07f4' ..'\u07f5' + | '\u07fa' ..'\u081a' + | '\u0824' ..'\u0828' + | '\u0971' ..'\u0e46' + | '\u0ec6' ..'\u10fc' + | '\u17d7' ..'\u1843' + | '\u1aa7' ..'\u1c78' + | '\u1c79' ..'\u1c7d' + | '\u1d2c' ..'\u1d6a' + | '\u1d78' ..'\u1d9b' + | '\u1d9c' ..'\u1dbf' + | '\u2071' ..'\u207f' + | '\u2090' ..'\u209c' + | '\u2c7c' ..'\u2c7d' + | '\u2d6f' ..'\u2e2f' + | '\u3005' ..'\u3031' + | '\u3032' ..'\u3035' + | '\u303b' ..'\u309d' + | '\u309e' ..'\u30fc' + | '\u30fd' ..'\u30fe' + | '\ua015' ..'\ua4f8' + | '\ua4f9' ..'\ua4fd' + | '\ua60c' ..'\ua67f' + | '\ua69c' ..'\ua69d' + | '\ua717' ..'\ua71f' + | '\ua770' ..'\ua788' + | '\ua7f8' ..'\ua7f9' + | '\ua9cf' ..'\ua9e6' + | '\uaa70' ..'\uaadd' + | '\uaaf3' ..'\uaaf4' + | '\uab5c' ..'\uab5f' + | '\uff70' ..'\uff9e' + | '\uff9f' ..'\uff9f' +; -fragment UnicodeClassLO - : '\u00aa'..'\u00ba' - | '\u01bb'..'\u01c0' - | '\u01c1'..'\u01c3' - | '\u0294'..'\u05d0' - | '\u05d1'..'\u05ea' - | '\u05f0'..'\u05f2' - | '\u0620'..'\u063f' - | '\u0641'..'\u064a' - | '\u066e'..'\u066f' - | '\u0671'..'\u06d3' - | '\u06d5'..'\u06ee' - | '\u06ef'..'\u06fa' - | '\u06fb'..'\u06fc' - | '\u06ff'..'\u0710' - | '\u0712'..'\u072f' - | '\u074d'..'\u07a5' - | '\u07b1'..'\u07ca' - | '\u07cb'..'\u07ea' - | '\u0800'..'\u0815' - | '\u0840'..'\u0858' - | '\u08a0'..'\u08b2' - | '\u0904'..'\u0939' - | '\u093d'..'\u0950' - | '\u0958'..'\u0961' - | '\u0972'..'\u0980' - | '\u0985'..'\u098c' - | '\u098f'..'\u0990' - | '\u0993'..'\u09a8' - | '\u09aa'..'\u09b0' - | '\u09b2'..'\u09b6' - | '\u09b7'..'\u09b9' - | '\u09bd'..'\u09ce' - | '\u09dc'..'\u09dd' - | '\u09df'..'\u09e1' - | '\u09f0'..'\u09f1' - | '\u0a05'..'\u0a0a' - | '\u0a0f'..'\u0a10' - | '\u0a13'..'\u0a28' - | '\u0a2a'..'\u0a30' - | '\u0a32'..'\u0a33' - | '\u0a35'..'\u0a36' - | '\u0a38'..'\u0a39' - | '\u0a59'..'\u0a5c' - | '\u0a5e'..'\u0a72' - | '\u0a73'..'\u0a74' - | '\u0a85'..'\u0a8d' - | '\u0a8f'..'\u0a91' - | '\u0a93'..'\u0aa8' - | '\u0aaa'..'\u0ab0' - | '\u0ab2'..'\u0ab3' - | '\u0ab5'..'\u0ab9' - | '\u0abd'..'\u0ad0' - | '\u0ae0'..'\u0ae1' - | '\u0b05'..'\u0b0c' - | '\u0b0f'..'\u0b10' - | '\u0b13'..'\u0b28' - | '\u0b2a'..'\u0b30' - | '\u0b32'..'\u0b33' - | '\u0b35'..'\u0b39' - | '\u0b3d'..'\u0b5c' - | '\u0b5d'..'\u0b5f' - | '\u0b60'..'\u0b61' - | '\u0b71'..'\u0b83' - | '\u0b85'..'\u0b8a' - | '\u0b8e'..'\u0b90' - | '\u0b92'..'\u0b95' - | '\u0b99'..'\u0b9a' - | '\u0b9c'..'\u0b9e' - | '\u0b9f'..'\u0ba3' - | '\u0ba4'..'\u0ba8' - | '\u0ba9'..'\u0baa' - | '\u0bae'..'\u0bb9' - | '\u0bd0'..'\u0c05' - | '\u0c06'..'\u0c0c' - | '\u0c0e'..'\u0c10' - | '\u0c12'..'\u0c28' - | '\u0c2a'..'\u0c39' - | '\u0c3d'..'\u0c58' - | '\u0c59'..'\u0c60' - | '\u0c61'..'\u0c85' - | '\u0c86'..'\u0c8c' - | '\u0c8e'..'\u0c90' - | '\u0c92'..'\u0ca8' - | '\u0caa'..'\u0cb3' - | '\u0cb5'..'\u0cb9' - | '\u0cbd'..'\u0cde' - | '\u0ce0'..'\u0ce1' - | '\u0cf1'..'\u0cf2' - | '\u0d05'..'\u0d0c' - | '\u0d0e'..'\u0d10' - | '\u0d12'..'\u0d3a' - | '\u0d3d'..'\u0d4e' - | '\u0d60'..'\u0d61' - | '\u0d7a'..'\u0d7f' - | '\u0d85'..'\u0d96' - | '\u0d9a'..'\u0db1' - | '\u0db3'..'\u0dbb' - | '\u0dbd'..'\u0dc0' - | '\u0dc1'..'\u0dc6' - | '\u0e01'..'\u0e30' - | '\u0e32'..'\u0e33' - | '\u0e40'..'\u0e45' - | '\u0e81'..'\u0e82' - | '\u0e84'..'\u0e87' - | '\u0e88'..'\u0e8a' - | '\u0e8d'..'\u0e94' - | '\u0e95'..'\u0e97' - | '\u0e99'..'\u0e9f' - | '\u0ea1'..'\u0ea3' - | '\u0ea5'..'\u0ea7' - | '\u0eaa'..'\u0eab' - | '\u0ead'..'\u0eb0' - | '\u0eb2'..'\u0eb3' - | '\u0ebd'..'\u0ec0' - | '\u0ec1'..'\u0ec4' - | '\u0edc'..'\u0edf' - | '\u0f00'..'\u0f40' - | '\u0f41'..'\u0f47' - | '\u0f49'..'\u0f6c' - | '\u0f88'..'\u0f8c' - | '\u1000'..'\u102a' - | '\u103f'..'\u1050' - | '\u1051'..'\u1055' - | '\u105a'..'\u105d' - | '\u1061'..'\u1065' - | '\u1066'..'\u106e' - | '\u106f'..'\u1070' - | '\u1075'..'\u1081' - | '\u108e'..'\u10d0' - | '\u10d1'..'\u10fa' - | '\u10fd'..'\u1248' - | '\u124a'..'\u124d' - | '\u1250'..'\u1256' - | '\u1258'..'\u125a' - | '\u125b'..'\u125d' - | '\u1260'..'\u1288' - | '\u128a'..'\u128d' - | '\u1290'..'\u12b0' - | '\u12b2'..'\u12b5' - | '\u12b8'..'\u12be' - | '\u12c0'..'\u12c2' - | '\u12c3'..'\u12c5' - | '\u12c8'..'\u12d6' - | '\u12d8'..'\u1310' - | '\u1312'..'\u1315' - | '\u1318'..'\u135a' - | '\u1380'..'\u138f' - | '\u13a0'..'\u13f4' - | '\u1401'..'\u166c' - | '\u166f'..'\u167f' - | '\u1681'..'\u169a' - | '\u16a0'..'\u16ea' - | '\u16f1'..'\u16f8' - | '\u1700'..'\u170c' - | '\u170e'..'\u1711' - | '\u1720'..'\u1731' - | '\u1740'..'\u1751' - | '\u1760'..'\u176c' - | '\u176e'..'\u1770' - | '\u1780'..'\u17b3' - | '\u17dc'..'\u1820' - | '\u1821'..'\u1842' - | '\u1844'..'\u1877' - | '\u1880'..'\u18a8' - | '\u18aa'..'\u18b0' - | '\u18b1'..'\u18f5' - | '\u1900'..'\u191e' - | '\u1950'..'\u196d' - | '\u1970'..'\u1974' - | '\u1980'..'\u19ab' - | '\u19c1'..'\u19c7' - | '\u1a00'..'\u1a16' - | '\u1a20'..'\u1a54' - | '\u1b05'..'\u1b33' - | '\u1b45'..'\u1b4b' - | '\u1b83'..'\u1ba0' - | '\u1bae'..'\u1baf' - | '\u1bba'..'\u1be5' - | '\u1c00'..'\u1c23' - | '\u1c4d'..'\u1c4f' - | '\u1c5a'..'\u1c77' - | '\u1ce9'..'\u1cec' - | '\u1cee'..'\u1cf1' - | '\u1cf5'..'\u1cf6' - | '\u2135'..'\u2138' - | '\u2d30'..'\u2d67' - | '\u2d80'..'\u2d96' - | '\u2da0'..'\u2da6' - | '\u2da8'..'\u2dae' - | '\u2db0'..'\u2db6' - | '\u2db8'..'\u2dbe' - | '\u2dc0'..'\u2dc6' - | '\u2dc8'..'\u2dce' - | '\u2dd0'..'\u2dd6' - | '\u2dd8'..'\u2dde' - | '\u3006'..'\u303c' - | '\u3041'..'\u3096' - | '\u309f'..'\u30a1' - | '\u30a2'..'\u30fa' - | '\u30ff'..'\u3105' - | '\u3106'..'\u312d' - | '\u3131'..'\u318e' - | '\u31a0'..'\u31ba' - | '\u31f0'..'\u31ff' - | '\u3400'..'\u4db5' - | '\u4e00'..'\u9fcc' - | '\ua000'..'\ua014' - | '\ua016'..'\ua48c' - | '\ua4d0'..'\ua4f7' - | '\ua500'..'\ua60b' - | '\ua610'..'\ua61f' - | '\ua62a'..'\ua62b' - | '\ua66e'..'\ua6a0' - | '\ua6a1'..'\ua6e5' - | '\ua7f7'..'\ua7fb' - | '\ua7fc'..'\ua801' - | '\ua803'..'\ua805' - | '\ua807'..'\ua80a' - | '\ua80c'..'\ua822' - | '\ua840'..'\ua873' - | '\ua882'..'\ua8b3' - | '\ua8f2'..'\ua8f7' - | '\ua8fb'..'\ua90a' - | '\ua90b'..'\ua925' - | '\ua930'..'\ua946' - | '\ua960'..'\ua97c' - | '\ua984'..'\ua9b2' - | '\ua9e0'..'\ua9e4' - | '\ua9e7'..'\ua9ef' - | '\ua9fa'..'\ua9fe' - | '\uaa00'..'\uaa28' - | '\uaa40'..'\uaa42' - | '\uaa44'..'\uaa4b' - | '\uaa60'..'\uaa6f' - | '\uaa71'..'\uaa76' - | '\uaa7a'..'\uaa7e' - | '\uaa7f'..'\uaaaf' - | '\uaab1'..'\uaab5' - | '\uaab6'..'\uaab9' - | '\uaaba'..'\uaabd' - | '\uaac0'..'\uaac2' - | '\uaadb'..'\uaadc' - | '\uaae0'..'\uaaea' - | '\uaaf2'..'\uab01' - | '\uab02'..'\uab06' - | '\uab09'..'\uab0e' - | '\uab11'..'\uab16' - | '\uab20'..'\uab26' - | '\uab28'..'\uab2e' - | '\uabc0'..'\uabe2' - | '\uac00'..'\ud7a3' - | '\ud7b0'..'\ud7c6' - | '\ud7cb'..'\ud7fb' - | '\uf900'..'\ufa6d' - | '\ufa70'..'\ufad9' - | '\ufb1d'..'\ufb1f' - | '\ufb20'..'\ufb28' - | '\ufb2a'..'\ufb36' - | '\ufb38'..'\ufb3c' - | '\ufb3e'..'\ufb40' - | '\ufb41'..'\ufb43' - | '\ufb44'..'\ufb46' - | '\ufb47'..'\ufbb1' - | '\ufbd3'..'\ufd3d' - | '\ufd50'..'\ufd8f' - | '\ufd92'..'\ufdc7' - | '\ufdf0'..'\ufdfb' - | '\ufe70'..'\ufe74' - | '\ufe76'..'\ufefc' - | '\uff66'..'\uff6f' - | '\uff71'..'\uff9d' - | '\uffa0'..'\uffbe' - | '\uffc2'..'\uffc7' - | '\uffca'..'\uffcf' - | '\uffd2'..'\uffd7' - | '\uffda'..'\uffdc' - ; +fragment UnicodeClassLO: + '\u00aa' ..'\u00ba' + | '\u01bb' ..'\u01c0' + | '\u01c1' ..'\u01c3' + | '\u0294' ..'\u05d0' + | '\u05d1' ..'\u05ea' + | '\u05f0' ..'\u05f2' + | '\u0620' ..'\u063f' + | '\u0641' ..'\u064a' + | '\u066e' ..'\u066f' + | '\u0671' ..'\u06d3' + | '\u06d5' ..'\u06ee' + | '\u06ef' ..'\u06fa' + | '\u06fb' ..'\u06fc' + | '\u06ff' ..'\u0710' + | '\u0712' ..'\u072f' + | '\u074d' ..'\u07a5' + | '\u07b1' ..'\u07ca' + | '\u07cb' ..'\u07ea' + | '\u0800' ..'\u0815' + | '\u0840' ..'\u0858' + | '\u08a0' ..'\u08b2' + | '\u0904' ..'\u0939' + | '\u093d' ..'\u0950' + | '\u0958' ..'\u0961' + | '\u0972' ..'\u0980' + | '\u0985' ..'\u098c' + | '\u098f' ..'\u0990' + | '\u0993' ..'\u09a8' + | '\u09aa' ..'\u09b0' + | '\u09b2' ..'\u09b6' + | '\u09b7' ..'\u09b9' + | '\u09bd' ..'\u09ce' + | '\u09dc' ..'\u09dd' + | '\u09df' ..'\u09e1' + | '\u09f0' ..'\u09f1' + | '\u0a05' ..'\u0a0a' + | '\u0a0f' ..'\u0a10' + | '\u0a13' ..'\u0a28' + | '\u0a2a' ..'\u0a30' + | '\u0a32' ..'\u0a33' + | '\u0a35' ..'\u0a36' + | '\u0a38' ..'\u0a39' + | '\u0a59' ..'\u0a5c' + | '\u0a5e' ..'\u0a72' + | '\u0a73' ..'\u0a74' + | '\u0a85' ..'\u0a8d' + | '\u0a8f' ..'\u0a91' + | '\u0a93' ..'\u0aa8' + | '\u0aaa' ..'\u0ab0' + | '\u0ab2' ..'\u0ab3' + | '\u0ab5' ..'\u0ab9' + | '\u0abd' ..'\u0ad0' + | '\u0ae0' ..'\u0ae1' + | '\u0b05' ..'\u0b0c' + | '\u0b0f' ..'\u0b10' + | '\u0b13' ..'\u0b28' + | '\u0b2a' ..'\u0b30' + | '\u0b32' ..'\u0b33' + | '\u0b35' ..'\u0b39' + | '\u0b3d' ..'\u0b5c' + | '\u0b5d' ..'\u0b5f' + | '\u0b60' ..'\u0b61' + | '\u0b71' ..'\u0b83' + | '\u0b85' ..'\u0b8a' + | '\u0b8e' ..'\u0b90' + | '\u0b92' ..'\u0b95' + | '\u0b99' ..'\u0b9a' + | '\u0b9c' ..'\u0b9e' + | '\u0b9f' ..'\u0ba3' + | '\u0ba4' ..'\u0ba8' + | '\u0ba9' ..'\u0baa' + | '\u0bae' ..'\u0bb9' + | '\u0bd0' ..'\u0c05' + | '\u0c06' ..'\u0c0c' + | '\u0c0e' ..'\u0c10' + | '\u0c12' ..'\u0c28' + | '\u0c2a' ..'\u0c39' + | '\u0c3d' ..'\u0c58' + | '\u0c59' ..'\u0c60' + | '\u0c61' ..'\u0c85' + | '\u0c86' ..'\u0c8c' + | '\u0c8e' ..'\u0c90' + | '\u0c92' ..'\u0ca8' + | '\u0caa' ..'\u0cb3' + | '\u0cb5' ..'\u0cb9' + | '\u0cbd' ..'\u0cde' + | '\u0ce0' ..'\u0ce1' + | '\u0cf1' ..'\u0cf2' + | '\u0d05' ..'\u0d0c' + | '\u0d0e' ..'\u0d10' + | '\u0d12' ..'\u0d3a' + | '\u0d3d' ..'\u0d4e' + | '\u0d60' ..'\u0d61' + | '\u0d7a' ..'\u0d7f' + | '\u0d85' ..'\u0d96' + | '\u0d9a' ..'\u0db1' + | '\u0db3' ..'\u0dbb' + | '\u0dbd' ..'\u0dc0' + | '\u0dc1' ..'\u0dc6' + | '\u0e01' ..'\u0e30' + | '\u0e32' ..'\u0e33' + | '\u0e40' ..'\u0e45' + | '\u0e81' ..'\u0e82' + | '\u0e84' ..'\u0e87' + | '\u0e88' ..'\u0e8a' + | '\u0e8d' ..'\u0e94' + | '\u0e95' ..'\u0e97' + | '\u0e99' ..'\u0e9f' + | '\u0ea1' ..'\u0ea3' + | '\u0ea5' ..'\u0ea7' + | '\u0eaa' ..'\u0eab' + | '\u0ead' ..'\u0eb0' + | '\u0eb2' ..'\u0eb3' + | '\u0ebd' ..'\u0ec0' + | '\u0ec1' ..'\u0ec4' + | '\u0edc' ..'\u0edf' + | '\u0f00' ..'\u0f40' + | '\u0f41' ..'\u0f47' + | '\u0f49' ..'\u0f6c' + | '\u0f88' ..'\u0f8c' + | '\u1000' ..'\u102a' + | '\u103f' ..'\u1050' + | '\u1051' ..'\u1055' + | '\u105a' ..'\u105d' + | '\u1061' ..'\u1065' + | '\u1066' ..'\u106e' + | '\u106f' ..'\u1070' + | '\u1075' ..'\u1081' + | '\u108e' ..'\u10d0' + | '\u10d1' ..'\u10fa' + | '\u10fd' ..'\u1248' + | '\u124a' ..'\u124d' + | '\u1250' ..'\u1256' + | '\u1258' ..'\u125a' + | '\u125b' ..'\u125d' + | '\u1260' ..'\u1288' + | '\u128a' ..'\u128d' + | '\u1290' ..'\u12b0' + | '\u12b2' ..'\u12b5' + | '\u12b8' ..'\u12be' + | '\u12c0' ..'\u12c2' + | '\u12c3' ..'\u12c5' + | '\u12c8' ..'\u12d6' + | '\u12d8' ..'\u1310' + | '\u1312' ..'\u1315' + | '\u1318' ..'\u135a' + | '\u1380' ..'\u138f' + | '\u13a0' ..'\u13f4' + | '\u1401' ..'\u166c' + | '\u166f' ..'\u167f' + | '\u1681' ..'\u169a' + | '\u16a0' ..'\u16ea' + | '\u16f1' ..'\u16f8' + | '\u1700' ..'\u170c' + | '\u170e' ..'\u1711' + | '\u1720' ..'\u1731' + | '\u1740' ..'\u1751' + | '\u1760' ..'\u176c' + | '\u176e' ..'\u1770' + | '\u1780' ..'\u17b3' + | '\u17dc' ..'\u1820' + | '\u1821' ..'\u1842' + | '\u1844' ..'\u1877' + | '\u1880' ..'\u18a8' + | '\u18aa' ..'\u18b0' + | '\u18b1' ..'\u18f5' + | '\u1900' ..'\u191e' + | '\u1950' ..'\u196d' + | '\u1970' ..'\u1974' + | '\u1980' ..'\u19ab' + | '\u19c1' ..'\u19c7' + | '\u1a00' ..'\u1a16' + | '\u1a20' ..'\u1a54' + | '\u1b05' ..'\u1b33' + | '\u1b45' ..'\u1b4b' + | '\u1b83' ..'\u1ba0' + | '\u1bae' ..'\u1baf' + | '\u1bba' ..'\u1be5' + | '\u1c00' ..'\u1c23' + | '\u1c4d' ..'\u1c4f' + | '\u1c5a' ..'\u1c77' + | '\u1ce9' ..'\u1cec' + | '\u1cee' ..'\u1cf1' + | '\u1cf5' ..'\u1cf6' + | '\u2135' ..'\u2138' + | '\u2d30' ..'\u2d67' + | '\u2d80' ..'\u2d96' + | '\u2da0' ..'\u2da6' + | '\u2da8' ..'\u2dae' + | '\u2db0' ..'\u2db6' + | '\u2db8' ..'\u2dbe' + | '\u2dc0' ..'\u2dc6' + | '\u2dc8' ..'\u2dce' + | '\u2dd0' ..'\u2dd6' + | '\u2dd8' ..'\u2dde' + | '\u3006' ..'\u303c' + | '\u3041' ..'\u3096' + | '\u309f' ..'\u30a1' + | '\u30a2' ..'\u30fa' + | '\u30ff' ..'\u3105' + | '\u3106' ..'\u312d' + | '\u3131' ..'\u318e' + | '\u31a0' ..'\u31ba' + | '\u31f0' ..'\u31ff' + | '\u3400' ..'\u4db5' + | '\u4e00' ..'\u9fcc' + | '\ua000' ..'\ua014' + | '\ua016' ..'\ua48c' + | '\ua4d0' ..'\ua4f7' + | '\ua500' ..'\ua60b' + | '\ua610' ..'\ua61f' + | '\ua62a' ..'\ua62b' + | '\ua66e' ..'\ua6a0' + | '\ua6a1' ..'\ua6e5' + | '\ua7f7' ..'\ua7fb' + | '\ua7fc' ..'\ua801' + | '\ua803' ..'\ua805' + | '\ua807' ..'\ua80a' + | '\ua80c' ..'\ua822' + | '\ua840' ..'\ua873' + | '\ua882' ..'\ua8b3' + | '\ua8f2' ..'\ua8f7' + | '\ua8fb' ..'\ua90a' + | '\ua90b' ..'\ua925' + | '\ua930' ..'\ua946' + | '\ua960' ..'\ua97c' + | '\ua984' ..'\ua9b2' + | '\ua9e0' ..'\ua9e4' + | '\ua9e7' ..'\ua9ef' + | '\ua9fa' ..'\ua9fe' + | '\uaa00' ..'\uaa28' + | '\uaa40' ..'\uaa42' + | '\uaa44' ..'\uaa4b' + | '\uaa60' ..'\uaa6f' + | '\uaa71' ..'\uaa76' + | '\uaa7a' ..'\uaa7e' + | '\uaa7f' ..'\uaaaf' + | '\uaab1' ..'\uaab5' + | '\uaab6' ..'\uaab9' + | '\uaaba' ..'\uaabd' + | '\uaac0' ..'\uaac2' + | '\uaadb' ..'\uaadc' + | '\uaae0' ..'\uaaea' + | '\uaaf2' ..'\uab01' + | '\uab02' ..'\uab06' + | '\uab09' ..'\uab0e' + | '\uab11' ..'\uab16' + | '\uab20' ..'\uab26' + | '\uab28' ..'\uab2e' + | '\uabc0' ..'\uabe2' + | '\uac00' ..'\ud7a3' + | '\ud7b0' ..'\ud7c6' + | '\ud7cb' ..'\ud7fb' + | '\uf900' ..'\ufa6d' + | '\ufa70' ..'\ufad9' + | '\ufb1d' ..'\ufb1f' + | '\ufb20' ..'\ufb28' + | '\ufb2a' ..'\ufb36' + | '\ufb38' ..'\ufb3c' + | '\ufb3e' ..'\ufb40' + | '\ufb41' ..'\ufb43' + | '\ufb44' ..'\ufb46' + | '\ufb47' ..'\ufbb1' + | '\ufbd3' ..'\ufd3d' + | '\ufd50' ..'\ufd8f' + | '\ufd92' ..'\ufdc7' + | '\ufdf0' ..'\ufdfb' + | '\ufe70' ..'\ufe74' + | '\ufe76' ..'\ufefc' + | '\uff66' ..'\uff6f' + | '\uff71' ..'\uff9d' + | '\uffa0' ..'\uffbe' + | '\uffc2' ..'\uffc7' + | '\uffca' ..'\uffcf' + | '\uffd2' ..'\uffd7' + | '\uffda' ..'\uffdc' +; -fragment UnicodeClassNL - : '\u16EE' // RUNIC ARLAUG SYMBOL - | '\u16EF' // RUNIC TVIMADUR SYMBOL - | '\u16F0' // RUNIC BELGTHOR SYMBOL - | '\u2160' // ROMAN NUMERAL ONE - | '\u2161' // ROMAN NUMERAL TWO - | '\u2162' // ROMAN NUMERAL THREE - | '\u2163' // ROMAN NUMERAL FOUR - | '\u2164' // ROMAN NUMERAL FIVE - | '\u2165' // ROMAN NUMERAL SIX - | '\u2166' // ROMAN NUMERAL SEVEN - | '\u2167' // ROMAN NUMERAL EIGHT - | '\u2168' // ROMAN NUMERAL NINE - | '\u2169' // ROMAN NUMERAL TEN - | '\u216A' // ROMAN NUMERAL ELEVEN - | '\u216B' // ROMAN NUMERAL TWELVE - | '\u216C' // ROMAN NUMERAL FIFTY - | '\u216D' // ROMAN NUMERAL ONE HUNDRED - | '\u216E' // ROMAN NUMERAL FIVE HUNDRED - | '\u216F' // ROMAN NUMERAL ONE THOUSAND - ; +fragment UnicodeClassNL: + '\u16EE' // RUNIC ARLAUG SYMBOL + | '\u16EF' // RUNIC TVIMADUR SYMBOL + | '\u16F0' // RUNIC BELGTHOR SYMBOL + | '\u2160' // ROMAN NUMERAL ONE + | '\u2161' // ROMAN NUMERAL TWO + | '\u2162' // ROMAN NUMERAL THREE + | '\u2163' // ROMAN NUMERAL FOUR + | '\u2164' // ROMAN NUMERAL FIVE + | '\u2165' // ROMAN NUMERAL SIX + | '\u2166' // ROMAN NUMERAL SEVEN + | '\u2167' // ROMAN NUMERAL EIGHT + | '\u2168' // ROMAN NUMERAL NINE + | '\u2169' // ROMAN NUMERAL TEN + | '\u216A' // ROMAN NUMERAL ELEVEN + | '\u216B' // ROMAN NUMERAL TWELVE + | '\u216C' // ROMAN NUMERAL FIFTY + | '\u216D' // ROMAN NUMERAL ONE HUNDRED + | '\u216E' // ROMAN NUMERAL FIVE HUNDRED + | '\u216F' // ROMAN NUMERAL ONE THOUSAND +; -fragment UnicodeClassMN - : '\u0300' // COMBINING GRAVE ACCENT - | '\u0301' // COMBINING ACUTE ACCENT - | '\u0302' // COMBINING CIRCUMFLEX ACCENT - | '\u0303' // COMBINING TILDE - | '\u0304' // COMBINING MACRON - | '\u0305' // COMBINING OVERLINE - | '\u0306' // COMBINING BREVE - | '\u0307' // COMBINING DOT ABOVE - | '\u0308' // COMBINING DIAERESIS - | '\u0309' // COMBINING HOOK ABOVE - | '\u030A' // COMBINING RING ABOVE - | '\u030B' // COMBINING DOUBLE ACUTE ACCENT - | '\u030C' // COMBINING CARON - | '\u030D' // COMBINING VERTICAL LINE ABOVE - | '\u030E' // COMBINING DOUBLE VERTICAL LINE ABOVE - | '\u030F' // COMBINING DOUBLE GRAVE ACCENT - | '\u0310' // COMBINING CANDRABINDU - ; +fragment UnicodeClassMN: + '\u0300' // COMBINING GRAVE ACCENT + | '\u0301' // COMBINING ACUTE ACCENT + | '\u0302' // COMBINING CIRCUMFLEX ACCENT + | '\u0303' // COMBINING TILDE + | '\u0304' // COMBINING MACRON + | '\u0305' // COMBINING OVERLINE + | '\u0306' // COMBINING BREVE + | '\u0307' // COMBINING DOT ABOVE + | '\u0308' // COMBINING DIAERESIS + | '\u0309' // COMBINING HOOK ABOVE + | '\u030A' // COMBINING RING ABOVE + | '\u030B' // COMBINING DOUBLE ACUTE ACCENT + | '\u030C' // COMBINING CARON + | '\u030D' // COMBINING VERTICAL LINE ABOVE + | '\u030E' // COMBINING DOUBLE VERTICAL LINE ABOVE + | '\u030F' // COMBINING DOUBLE GRAVE ACCENT + | '\u0310' // COMBINING CANDRABINDU +; -fragment UnicodeClassMC - : '\u0903' // DEVANAGARI SIGN VISARGA - | '\u093E' // DEVANAGARI VOWEL SIGN AA - | '\u093F' // DEVANAGARI VOWEL SIGN I - | '\u0940' // DEVANAGARI VOWEL SIGN II - | '\u0949' // DEVANAGARI VOWEL SIGN CANDRA O - | '\u094A' // DEVANAGARI VOWEL SIGN SHORT O - | '\u094B' // DEVANAGARI VOWEL SIGN O - | '\u094C' // DEVANAGARI VOWEL SIGN AU - ; +fragment UnicodeClassMC: + '\u0903' // DEVANAGARI SIGN VISARGA + | '\u093E' // DEVANAGARI VOWEL SIGN AA + | '\u093F' // DEVANAGARI VOWEL SIGN I + | '\u0940' // DEVANAGARI VOWEL SIGN II + | '\u0949' // DEVANAGARI VOWEL SIGN CANDRA O + | '\u094A' // DEVANAGARI VOWEL SIGN SHORT O + | '\u094B' // DEVANAGARI VOWEL SIGN O + | '\u094C' // DEVANAGARI VOWEL SIGN AU +; -fragment UnicodeClassCF - : '\u00AD' // SOFT HYPHEN - | '\u0600' // ARABIC NUMBER SIGN - | '\u0601' // ARABIC SIGN SANAH - | '\u0602' // ARABIC FOOTNOTE MARKER - | '\u0603' // ARABIC SIGN SAFHA - | '\u06DD' // ARABIC END OF AYAH - ; +fragment UnicodeClassCF: + '\u00AD' // SOFT HYPHEN + | '\u0600' // ARABIC NUMBER SIGN + | '\u0601' // ARABIC SIGN SANAH + | '\u0602' // ARABIC FOOTNOTE MARKER + | '\u0603' // ARABIC SIGN SAFHA + | '\u06DD' // ARABIC END OF AYAH +; -fragment UnicodeClassPC - : '\u005F' // LOW LINE - | '\u203F' // UNDERTIE - | '\u2040' // CHARACTER TIE - | '\u2054' // INVERTED UNDERTIE - | '\uFE33' // PRESENTATION FORM FOR VERTICAL LOW LINE - | '\uFE34' // PRESENTATION FORM FOR VERTICAL WAVY LOW LINE - | '\uFE4D' // DASHED LOW LINE - | '\uFE4E' // CENTRELINE LOW LINE - | '\uFE4F' // WAVY LOW LINE - | '\uFF3F' // FULLWIDTH LOW LINE - ; +fragment UnicodeClassPC: + '\u005F' // LOW LINE + | '\u203F' // UNDERTIE + | '\u2040' // CHARACTER TIE + | '\u2054' // INVERTED UNDERTIE + | '\uFE33' // PRESENTATION FORM FOR VERTICAL LOW LINE + | '\uFE34' // PRESENTATION FORM FOR VERTICAL WAVY LOW LINE + | '\uFE4D' // DASHED LOW LINE + | '\uFE4E' // CENTRELINE LOW LINE + | '\uFE4F' // WAVY LOW LINE + | '\uFF3F' // FULLWIDTH LOW LINE +; -fragment UnicodeClassND - : '\u0030'..'\u0039' - | '\u0660'..'\u0669' - | '\u06f0'..'\u06f9' - | '\u07c0'..'\u07c9' - | '\u0966'..'\u096f' - | '\u09e6'..'\u09ef' - | '\u0a66'..'\u0a6f' - | '\u0ae6'..'\u0aef' - | '\u0b66'..'\u0b6f' - | '\u0be6'..'\u0bef' - | '\u0c66'..'\u0c6f' - | '\u0ce6'..'\u0cef' - | '\u0d66'..'\u0d6f' - | '\u0de6'..'\u0def' - | '\u0e50'..'\u0e59' - | '\u0ed0'..'\u0ed9' - | '\u0f20'..'\u0f29' - | '\u1040'..'\u1049' - | '\u1090'..'\u1099' - | '\u17e0'..'\u17e9' - | '\u1810'..'\u1819' - | '\u1946'..'\u194f' - | '\u19d0'..'\u19d9' - | '\u1a80'..'\u1a89' - | '\u1a90'..'\u1a99' - | '\u1b50'..'\u1b59' - | '\u1bb0'..'\u1bb9' - | '\u1c40'..'\u1c49' - | '\u1c50'..'\u1c59' - | '\ua620'..'\ua629' - | '\ua8d0'..'\ua8d9' - | '\ua900'..'\ua909' - | '\ua9d0'..'\ua9d9' - | '\ua9f0'..'\ua9f9' - | '\uaa50'..'\uaa59' - | '\uabf0'..'\uabf9' - | '\uff10'..'\uff19' - ; +fragment UnicodeClassND: + '\u0030' ..'\u0039' + | '\u0660' ..'\u0669' + | '\u06f0' ..'\u06f9' + | '\u07c0' ..'\u07c9' + | '\u0966' ..'\u096f' + | '\u09e6' ..'\u09ef' + | '\u0a66' ..'\u0a6f' + | '\u0ae6' ..'\u0aef' + | '\u0b66' ..'\u0b6f' + | '\u0be6' ..'\u0bef' + | '\u0c66' ..'\u0c6f' + | '\u0ce6' ..'\u0cef' + | '\u0d66' ..'\u0d6f' + | '\u0de6' ..'\u0def' + | '\u0e50' ..'\u0e59' + | '\u0ed0' ..'\u0ed9' + | '\u0f20' ..'\u0f29' + | '\u1040' ..'\u1049' + | '\u1090' ..'\u1099' + | '\u17e0' ..'\u17e9' + | '\u1810' ..'\u1819' + | '\u1946' ..'\u194f' + | '\u19d0' ..'\u19d9' + | '\u1a80' ..'\u1a89' + | '\u1a90' ..'\u1a99' + | '\u1b50' ..'\u1b59' + | '\u1bb0' ..'\u1bb9' + | '\u1c40' ..'\u1c49' + | '\u1c50' ..'\u1c59' + | '\ua620' ..'\ua629' + | '\ua8d0' ..'\ua8d9' + | '\ua900' ..'\ua909' + | '\ua9d0' ..'\ua9d9' + | '\ua9f0' ..'\ua9f9' + | '\uaa50' ..'\uaa59' + | '\uabf0' ..'\uabf9' + | '\uff10' ..'\uff19' +; \ No newline at end of file diff --git a/csharp/CSharpParser.g4 b/csharp/CSharpParser.g4 index ccf33c30b7..ec37fb2951 100644 --- a/csharp/CSharpParser.g4 +++ b/csharp/CSharpParser.g4 @@ -2,35 +2,42 @@ // Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) // Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. +// $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 CSharpParser; -options { tokenVocab=CSharpLexer; superClass = CSharpParserBase; } +options { + tokenVocab = CSharpLexer; + superClass = CSharpParserBase; +} // entry point compilation_unit - : BYTE_ORDER_MARK? extern_alias_directives? using_directives? - global_attribute_section* namespace_member_declarations? EOF - ; + : BYTE_ORDER_MARK? extern_alias_directives? using_directives? global_attribute_section* namespace_member_declarations? EOF + ; //B.2 Syntactic grammar //B.2.1 Basic concepts namespace_or_type_name - : (identifier type_argument_list? | qualified_alias_member) ('.' identifier type_argument_list?)* - ; + : (identifier type_argument_list? | qualified_alias_member) ( + '.' identifier type_argument_list? + )* + ; //B.2.2 Types type_ - : base_type ('?' | rank_specifier | '*')* - ; + : base_type ('?' | rank_specifier | '*')* + ; base_type - : simple_type - | class_type // represents types: enum, class, interface, delegate, type_parameter - | VOID '*' - | tuple_type - ; + : simple_type + | class_type // represents types: enum, class, interface, delegate, type_parameter + | VOID '*' + | tuple_type + ; tuple_type : '(' tuple_element (',' tuple_element)+ ')' @@ -41,125 +48,132 @@ tuple_element ; simple_type - : numeric_type - | BOOL - ; + : numeric_type + | BOOL + ; numeric_type - : integral_type - | floating_point_type - | DECIMAL - ; + : integral_type + | floating_point_type + | DECIMAL + ; integral_type - : SBYTE - | BYTE - | SHORT - | USHORT - | INT - | UINT - | LONG - | ULONG - | CHAR - ; + : SBYTE + | BYTE + | SHORT + | USHORT + | INT + | UINT + | LONG + | ULONG + | CHAR + ; floating_point_type - : FLOAT - | DOUBLE - ; + : FLOAT + | DOUBLE + ; /** namespace_or_type_name, OBJECT, STRING */ class_type - : namespace_or_type_name - | OBJECT - | DYNAMIC - | STRING - ; + : namespace_or_type_name + | OBJECT + | DYNAMIC + | STRING + ; type_argument_list - : '<' type_ ( ',' type_)* '>' - ; + : '<' type_ (',' type_)* '>' + ; //B.2.4 Expressions argument_list - : argument ( ',' argument)* - ; + : argument (',' argument)* + ; argument - : (identifier ':')? refout=(REF | OUT | IN)? - ( expression - | (VAR | type_) expression - ) - ; + : (identifier ':')? refout = (REF | OUT | IN)? (expression | (VAR | type_) expression) + ; expression - : assignment - | non_assignment_expression - | REF non_assignment_expression - ; + : assignment + | non_assignment_expression + | REF non_assignment_expression + ; non_assignment_expression - : lambda_expression - | query_expression - | conditional_expression - ; + : lambda_expression + | query_expression + | conditional_expression + ; assignment - : unary_expression assignment_operator expression - | unary_expression '??=' throwable_expression - ; + : unary_expression assignment_operator expression + | unary_expression '??=' throwable_expression + ; assignment_operator - : '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | right_shift_assignment - ; + : '=' + | '+=' + | '-=' + | '*=' + | '/=' + | '%=' + | '&=' + | '|=' + | '^=' + | '<<=' + | right_shift_assignment + ; conditional_expression - : null_coalescing_expression ('?' throwable_expression ':' throwable_expression)? - ; + : null_coalescing_expression ('?' throwable_expression ':' throwable_expression)? + ; null_coalescing_expression - : conditional_or_expression ('??' (null_coalescing_expression | throw_expression))? - ; + : conditional_or_expression ('??' (null_coalescing_expression | throw_expression))? + ; conditional_or_expression - : conditional_and_expression (OP_OR conditional_and_expression)* - ; + : conditional_and_expression (OP_OR conditional_and_expression)* + ; conditional_and_expression - : inclusive_or_expression (OP_AND inclusive_or_expression)* - ; + : inclusive_or_expression (OP_AND inclusive_or_expression)* + ; inclusive_or_expression - : exclusive_or_expression ('|' exclusive_or_expression)* - ; + : exclusive_or_expression ('|' exclusive_or_expression)* + ; exclusive_or_expression - : and_expression ('^' and_expression)* - ; + : and_expression ('^' and_expression)* + ; and_expression - : equality_expression ('&' equality_expression)* - ; + : equality_expression ('&' equality_expression)* + ; equality_expression - : relational_expression ((OP_EQ | OP_NE) relational_expression)* - ; + : relational_expression ((OP_EQ | OP_NE) relational_expression)* + ; relational_expression - : shift_expression (('<' | '>' | '<=' | '>=') shift_expression | IS isType | AS type_)* - ; + : shift_expression (('<' | '>' | '<=' | '>=') shift_expression | IS isType | AS type_)* + ; shift_expression - : additive_expression (('<<' | right_shift) additive_expression)* - ; + : additive_expression (('<<' | right_shift) additive_expression)* + ; additive_expression - : multiplicative_expression (('+' | '-') multiplicative_expression)* - ; + : multiplicative_expression (('+' | '-') multiplicative_expression)* + ; multiplicative_expression - : switch_expression (('*' | '/' | '%') switch_expression)* - ; + : switch_expression (('*' | '/' | '%') switch_expression)* + ; switch_expression : range_expression ('switch' '{' (switch_expression_arms ','?)? '}')? @@ -180,247 +194,266 @@ range_expression // https://msdn.microsoft.com/library/6a71f45d(v=vs.110).aspx unary_expression - : cast_expression - | primary_expression - | '+' unary_expression - | '-' unary_expression - | BANG unary_expression - | '~' unary_expression - | '++' unary_expression - | '--' unary_expression - | AWAIT unary_expression // C# 5 - | '&' unary_expression - | '*' unary_expression - | '^' unary_expression // C# 8 ranges - ; + : cast_expression + | primary_expression + | '+' unary_expression + | '-' unary_expression + | BANG unary_expression + | '~' unary_expression + | '++' unary_expression + | '--' unary_expression + | AWAIT unary_expression // C# 5 + | '&' unary_expression + | '*' unary_expression + | '^' unary_expression // C# 8 ranges + ; cast_expression : OPEN_PARENS type_ CLOSE_PARENS unary_expression ; -primary_expression // Null-conditional operators C# 6: https://msdn.microsoft.com/en-us/library/dn986595.aspx - : pe=primary_expression_start '!'? bracket_expression* '!'? - ((member_access | method_invocation | '++' | '--' | '->' identifier) '!'? bracket_expression* '!'?)* - ; +primary_expression // Null-conditional operators C# 6: https://msdn.microsoft.com/en-us/library/dn986595.aspx + : pe = primary_expression_start '!'? bracket_expression* '!'? ( + (member_access | method_invocation | '++' | '--' | '->' identifier) '!'? bracket_expression* '!'? + )* + ; primary_expression_start - : literal #literalExpression - | identifier type_argument_list? #simpleNameExpression - | OPEN_PARENS expression CLOSE_PARENS #parenthesisExpressions - | predefined_type #memberAccessExpression - | qualified_alias_member #memberAccessExpression - | LITERAL_ACCESS #literalAccessExpression - | THIS #thisReferenceExpression - | BASE ('.' identifier type_argument_list? | '[' expression_list ']') #baseAccessExpression - | NEW (type_ (object_creation_expression - | object_or_collection_initializer - | '[' expression_list ']' rank_specifier* array_initializer? - | rank_specifier+ array_initializer) - | anonymous_object_initializer - | rank_specifier array_initializer) #objectCreationExpression - | OPEN_PARENS argument ( ',' argument )+ CLOSE_PARENS #tupleExpression - | TYPEOF OPEN_PARENS (unbound_type_name | type_ | VOID) CLOSE_PARENS #typeofExpression - | CHECKED OPEN_PARENS expression CLOSE_PARENS #checkedExpression - | UNCHECKED OPEN_PARENS expression CLOSE_PARENS #uncheckedExpression - | DEFAULT (OPEN_PARENS type_ CLOSE_PARENS)? #defaultValueExpression - | ASYNC? DELEGATE (OPEN_PARENS explicit_anonymous_function_parameter_list? CLOSE_PARENS)? block #anonymousMethodExpression - | SIZEOF OPEN_PARENS type_ CLOSE_PARENS #sizeofExpression - // C# 6: https://msdn.microsoft.com/en-us/library/dn986596.aspx - | NAMEOF OPEN_PARENS (identifier '.')* identifier CLOSE_PARENS #nameofExpression - ; + : literal # literalExpression + | identifier type_argument_list? # simpleNameExpression + | OPEN_PARENS expression CLOSE_PARENS # parenthesisExpressions + | predefined_type # memberAccessExpression + | qualified_alias_member # memberAccessExpression + | LITERAL_ACCESS # literalAccessExpression + | THIS # thisReferenceExpression + | BASE ('.' identifier type_argument_list? | '[' expression_list ']') # baseAccessExpression + | NEW ( + type_ ( + object_creation_expression + | object_or_collection_initializer + | '[' expression_list ']' rank_specifier* array_initializer? + | rank_specifier+ array_initializer + ) + | anonymous_object_initializer + | rank_specifier array_initializer + ) # objectCreationExpression + | OPEN_PARENS argument ( ',' argument)+ CLOSE_PARENS # tupleExpression + | TYPEOF OPEN_PARENS (unbound_type_name | type_ | VOID) CLOSE_PARENS # typeofExpression + | CHECKED OPEN_PARENS expression CLOSE_PARENS # checkedExpression + | UNCHECKED OPEN_PARENS expression CLOSE_PARENS # uncheckedExpression + | DEFAULT (OPEN_PARENS type_ CLOSE_PARENS)? # defaultValueExpression + | ASYNC? DELEGATE (OPEN_PARENS explicit_anonymous_function_parameter_list? CLOSE_PARENS)? block # anonymousMethodExpression + | SIZEOF OPEN_PARENS type_ CLOSE_PARENS # sizeofExpression + // C# 6: https://msdn.microsoft.com/en-us/library/dn986596.aspx + | NAMEOF OPEN_PARENS (identifier '.')* identifier CLOSE_PARENS # nameofExpression + ; throwable_expression - : expression - | throw_expression - ; + : expression + | throw_expression + ; throw_expression - : THROW expression - ; + : THROW expression + ; member_access - : '?'? '.' identifier type_argument_list? - ; + : '?'? '.' identifier type_argument_list? + ; bracket_expression - : '?'? '[' indexer_argument ( ',' indexer_argument)* ']' - ; + : '?'? '[' indexer_argument (',' indexer_argument)* ']' + ; indexer_argument - : (identifier ':')? expression - ; + : (identifier ':')? expression + ; predefined_type - : BOOL | BYTE | CHAR | DECIMAL | DOUBLE | FLOAT | INT | LONG - | OBJECT | SBYTE | SHORT | STRING | UINT | ULONG | USHORT - ; + : BOOL + | BYTE + | CHAR + | DECIMAL + | DOUBLE + | FLOAT + | INT + | LONG + | OBJECT + | SBYTE + | SHORT + | STRING + | UINT + | ULONG + | USHORT + ; expression_list - : expression (',' expression)* - ; + : expression (',' expression)* + ; object_or_collection_initializer - : object_initializer - | collection_initializer - ; + : object_initializer + | collection_initializer + ; object_initializer - : OPEN_BRACE (member_initializer_list ','?)? CLOSE_BRACE - ; + : OPEN_BRACE (member_initializer_list ','?)? CLOSE_BRACE + ; member_initializer_list - : member_initializer (',' member_initializer)* - ; + : member_initializer (',' member_initializer)* + ; member_initializer - : (identifier | '[' expression ']') '=' initializer_value // C# 6 - ; + : (identifier | '[' expression ']') '=' initializer_value // C# 6 + ; initializer_value - : expression - | object_or_collection_initializer - ; + : expression + | object_or_collection_initializer + ; collection_initializer - : OPEN_BRACE element_initializer (',' element_initializer)* ','? CLOSE_BRACE - ; + : OPEN_BRACE element_initializer (',' element_initializer)* ','? CLOSE_BRACE + ; element_initializer - : non_assignment_expression - | OPEN_BRACE expression_list CLOSE_BRACE - ; + : non_assignment_expression + | OPEN_BRACE expression_list CLOSE_BRACE + ; anonymous_object_initializer - : OPEN_BRACE (member_declarator_list ','?)? CLOSE_BRACE - ; + : OPEN_BRACE (member_declarator_list ','?)? CLOSE_BRACE + ; member_declarator_list - : member_declarator ( ',' member_declarator)* - ; + : member_declarator (',' member_declarator)* + ; member_declarator - : primary_expression - | identifier '=' expression - ; + : primary_expression + | identifier '=' expression + ; unbound_type_name - : identifier ( generic_dimension_specifier? | '::' identifier generic_dimension_specifier?) - ('.' identifier generic_dimension_specifier?)* - ; + : identifier (generic_dimension_specifier? | '::' identifier generic_dimension_specifier?) ( + '.' identifier generic_dimension_specifier? + )* + ; generic_dimension_specifier - : '<' ','* '>' - ; + : '<' ','* '>' + ; isType - : base_type (rank_specifier | '*')* '?'? isTypePatternArms? identifier? - ; + : base_type (rank_specifier | '*')* '?'? isTypePatternArms? identifier? + ; isTypePatternArms - : '{' isTypePatternArm (',' isTypePatternArm)* '}' - ; + : '{' isTypePatternArm (',' isTypePatternArm)* '}' + ; isTypePatternArm - : identifier ':' expression - ; + : identifier ':' expression + ; lambda_expression - : ASYNC? anonymous_function_signature right_arrow anonymous_function_body - ; + : ASYNC? anonymous_function_signature right_arrow anonymous_function_body + ; anonymous_function_signature - : OPEN_PARENS CLOSE_PARENS - | OPEN_PARENS explicit_anonymous_function_parameter_list CLOSE_PARENS - | OPEN_PARENS implicit_anonymous_function_parameter_list CLOSE_PARENS - | identifier - ; + : OPEN_PARENS CLOSE_PARENS + | OPEN_PARENS explicit_anonymous_function_parameter_list CLOSE_PARENS + | OPEN_PARENS implicit_anonymous_function_parameter_list CLOSE_PARENS + | identifier + ; explicit_anonymous_function_parameter_list - : explicit_anonymous_function_parameter ( ',' explicit_anonymous_function_parameter)* - ; + : explicit_anonymous_function_parameter (',' explicit_anonymous_function_parameter)* + ; explicit_anonymous_function_parameter - : refout=(REF | OUT | IN)? type_ identifier - ; + : refout = (REF | OUT | IN)? type_ identifier + ; implicit_anonymous_function_parameter_list - : identifier (',' identifier)* - ; + : identifier (',' identifier)* + ; anonymous_function_body - : throwable_expression - | block - ; + : throwable_expression + | block + ; query_expression - : from_clause query_body - ; + : from_clause query_body + ; from_clause - : FROM type_? identifier IN expression - ; + : FROM type_? identifier IN expression + ; query_body - : query_body_clause* select_or_group_clause query_continuation? - ; + : query_body_clause* select_or_group_clause query_continuation? + ; query_body_clause - : from_clause - | let_clause - | where_clause - | combined_join_clause - | orderby_clause - ; + : from_clause + | let_clause + | where_clause + | combined_join_clause + | orderby_clause + ; let_clause - : LET identifier '=' expression - ; + : LET identifier '=' expression + ; where_clause - : WHERE expression - ; + : WHERE expression + ; combined_join_clause - : JOIN type_? identifier IN expression ON expression EQUALS expression (INTO identifier)? - ; + : JOIN type_? identifier IN expression ON expression EQUALS expression (INTO identifier)? + ; orderby_clause - : ORDERBY ordering (',' ordering)* - ; + : ORDERBY ordering (',' ordering)* + ; ordering - : expression dir=(ASCENDING | DESCENDING)? - ; + : expression dir = (ASCENDING | DESCENDING)? + ; select_or_group_clause - : SELECT expression - | GROUP expression BY expression - ; + : SELECT expression + | GROUP expression BY expression + ; query_continuation - : INTO identifier query_body - ; + : INTO identifier query_body + ; //B.2.5 Statements statement - : labeled_Statement - | declarationStatement - | embedded_statement - ; + : labeled_Statement + | declarationStatement + | embedded_statement + ; declarationStatement - : local_variable_declaration ';' - | local_constant_declaration ';' - | local_function_declaration - ; + : local_variable_declaration ';' + | local_constant_declaration ';' + | local_function_declaration + ; local_function_declaration : local_function_header local_function_body ; local_function_header - : local_function_modifiers? return_type identifier type_parameter_list? - OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? + : local_function_modifiers? return_type identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS + type_parameter_constraints_clauses? ; local_function_modifiers @@ -434,819 +467,843 @@ local_function_body ; labeled_Statement - : identifier ':' statement - ; + : identifier ':' statement + ; embedded_statement - : block - | simple_embedded_statement - ; + : block + | simple_embedded_statement + ; simple_embedded_statement - : ';' #theEmptyStatement - | expression ';' #expressionStatement + : ';' # theEmptyStatement + | expression ';' # expressionStatement - // selection statements - | IF OPEN_PARENS expression CLOSE_PARENS if_body (ELSE if_body)? #ifStatement - | SWITCH OPEN_PARENS expression CLOSE_PARENS OPEN_BRACE switch_section* CLOSE_BRACE #switchStatement + // selection statements + | IF OPEN_PARENS expression CLOSE_PARENS if_body (ELSE if_body)? # ifStatement + | SWITCH OPEN_PARENS expression CLOSE_PARENS OPEN_BRACE switch_section* CLOSE_BRACE # switchStatement // iteration statements - | WHILE OPEN_PARENS expression CLOSE_PARENS embedded_statement #whileStatement - | DO embedded_statement WHILE OPEN_PARENS expression CLOSE_PARENS ';' #doStatement - | FOR OPEN_PARENS for_initializer? ';' expression? ';' for_iterator? CLOSE_PARENS embedded_statement #forStatement - | AWAIT? FOREACH OPEN_PARENS local_variable_type identifier IN expression CLOSE_PARENS embedded_statement #foreachStatement + | WHILE OPEN_PARENS expression CLOSE_PARENS embedded_statement # whileStatement + | DO embedded_statement WHILE OPEN_PARENS expression CLOSE_PARENS ';' # doStatement + | FOR OPEN_PARENS for_initializer? ';' expression? ';' for_iterator? CLOSE_PARENS embedded_statement # forStatement + | AWAIT? FOREACH OPEN_PARENS local_variable_type identifier IN expression CLOSE_PARENS embedded_statement # foreachStatement // jump statements - | BREAK ';' #breakStatement - | CONTINUE ';' #continueStatement - | GOTO (identifier | CASE expression | DEFAULT) ';' #gotoStatement - | RETURN expression? ';' #returnStatement - | THROW expression? ';' #throwStatement - - | TRY block (catch_clauses finally_clause? | finally_clause) #tryStatement - | CHECKED block #checkedStatement - | UNCHECKED block #uncheckedStatement - | LOCK OPEN_PARENS expression CLOSE_PARENS embedded_statement #lockStatement - | USING OPEN_PARENS resource_acquisition CLOSE_PARENS embedded_statement #usingStatement - | YIELD (RETURN expression | BREAK) ';' #yieldStatement - - // unsafe statements - | UNSAFE block #unsafeStatement - | FIXED OPEN_PARENS pointer_type fixed_pointer_declarators CLOSE_PARENS embedded_statement #fixedStatement - ; + | BREAK ';' # breakStatement + | CONTINUE ';' # continueStatement + | GOTO (identifier | CASE expression | DEFAULT) ';' # gotoStatement + | RETURN expression? ';' # returnStatement + | THROW expression? ';' # throwStatement + | TRY block (catch_clauses finally_clause? | finally_clause) # tryStatement + | CHECKED block # checkedStatement + | UNCHECKED block # uncheckedStatement + | LOCK OPEN_PARENS expression CLOSE_PARENS embedded_statement # lockStatement + | USING OPEN_PARENS resource_acquisition CLOSE_PARENS embedded_statement # usingStatement + | YIELD (RETURN expression | BREAK) ';' # yieldStatement + + // unsafe statements + | UNSAFE block # unsafeStatement + | FIXED OPEN_PARENS pointer_type fixed_pointer_declarators CLOSE_PARENS embedded_statement # fixedStatement + ; block - : OPEN_BRACE statement_list? CLOSE_BRACE - ; + : OPEN_BRACE statement_list? CLOSE_BRACE + ; local_variable_declaration - : (USING | REF | REF READONLY)? local_variable_type local_variable_declarator ( ',' local_variable_declarator { this.IsLocalVariableDeclaration() }? )* - | FIXED pointer_type fixed_pointer_declarators - ; + : (USING | REF | REF READONLY)? local_variable_type local_variable_declarator ( + ',' local_variable_declarator { this.IsLocalVariableDeclaration() }? + )* + | FIXED pointer_type fixed_pointer_declarators + ; local_variable_type - : VAR - | type_ - ; + : VAR + | type_ + ; local_variable_declarator - : identifier ('=' REF? local_variable_initializer )? - ; + : identifier ('=' REF? local_variable_initializer)? + ; local_variable_initializer - : expression - | array_initializer - | stackalloc_initializer - ; + : expression + | array_initializer + | stackalloc_initializer + ; local_constant_declaration - : CONST type_ constant_declarators - ; + : CONST type_ constant_declarators + ; if_body - : block - | simple_embedded_statement - ; + : block + | simple_embedded_statement + ; switch_section - : switch_label+ statement_list - ; + : switch_label+ statement_list + ; switch_label - : CASE expression case_guard? ':' - | DEFAULT ':' - ; + : CASE expression case_guard? ':' + | DEFAULT ':' + ; case_guard - : WHEN expression - ; + : WHEN expression + ; statement_list - : statement+ - ; + : statement+ + ; for_initializer - : local_variable_declaration - | expression (',' expression)* - ; + : local_variable_declaration + | expression (',' expression)* + ; for_iterator - : expression (',' expression)* - ; + : expression (',' expression)* + ; catch_clauses - : specific_catch_clause specific_catch_clause* general_catch_clause? - | general_catch_clause - ; + : specific_catch_clause specific_catch_clause* general_catch_clause? + | general_catch_clause + ; specific_catch_clause - : CATCH OPEN_PARENS class_type identifier? CLOSE_PARENS exception_filter? block - ; + : CATCH OPEN_PARENS class_type identifier? CLOSE_PARENS exception_filter? block + ; general_catch_clause - : CATCH exception_filter? block - ; + : CATCH exception_filter? block + ; exception_filter // C# 6 - : WHEN OPEN_PARENS expression CLOSE_PARENS - ; + : WHEN OPEN_PARENS expression CLOSE_PARENS + ; finally_clause - : FINALLY block - ; + : FINALLY block + ; resource_acquisition - : local_variable_declaration - | expression - ; + : local_variable_declaration + | expression + ; //B.2.6 Namespaces; namespace_declaration - : NAMESPACE qi=qualified_identifier namespace_body ';'? - ; + : NAMESPACE qi = qualified_identifier namespace_body ';'? + ; qualified_identifier - : identifier ( '.' identifier )* - ; + : identifier ('.' identifier)* + ; namespace_body - : OPEN_BRACE extern_alias_directives? using_directives? namespace_member_declarations? CLOSE_BRACE - ; + : OPEN_BRACE extern_alias_directives? using_directives? namespace_member_declarations? CLOSE_BRACE + ; extern_alias_directives - : extern_alias_directive+ - ; + : extern_alias_directive+ + ; extern_alias_directive - : EXTERN ALIAS identifier ';' - ; + : EXTERN ALIAS identifier ';' + ; using_directives - : using_directive+ - ; + : using_directive+ + ; using_directive - : USING identifier '=' namespace_or_type_name ';' #usingAliasDirective - | USING namespace_or_type_name ';' #usingNamespaceDirective - // C# 6: https://msdn.microsoft.com/en-us/library/ms228593.aspx - | USING STATIC namespace_or_type_name ';' #usingStaticDirective - ; + : USING identifier '=' namespace_or_type_name ';' # usingAliasDirective + | USING namespace_or_type_name ';' # usingNamespaceDirective + // C# 6: https://msdn.microsoft.com/en-us/library/ms228593.aspx + | USING STATIC namespace_or_type_name ';' # usingStaticDirective + ; namespace_member_declarations - : namespace_member_declaration+ - ; + : namespace_member_declaration+ + ; namespace_member_declaration - : namespace_declaration - | type_declaration - ; + : namespace_declaration + | type_declaration + ; type_declaration - : attributes? all_member_modifiers? - (class_definition | struct_definition | interface_definition | enum_definition | delegate_definition) - ; + : attributes? all_member_modifiers? ( + class_definition + | struct_definition + | interface_definition + | enum_definition + | delegate_definition + ) + ; qualified_alias_member - : identifier '::' identifier type_argument_list? - ; + : identifier '::' identifier type_argument_list? + ; //B.2.7 Classes; type_parameter_list - : '<' type_parameter (',' type_parameter)* '>' - ; + : '<' type_parameter (',' type_parameter)* '>' + ; type_parameter - : attributes? identifier - ; + : attributes? identifier + ; class_base - : ':' class_type (',' namespace_or_type_name)* - ; + : ':' class_type (',' namespace_or_type_name)* + ; interface_type_list - : namespace_or_type_name (',' namespace_or_type_name)* - ; + : namespace_or_type_name (',' namespace_or_type_name)* + ; type_parameter_constraints_clauses - : type_parameter_constraints_clause+ - ; + : type_parameter_constraints_clause+ + ; type_parameter_constraints_clause - : WHERE identifier ':' type_parameter_constraints - ; + : WHERE identifier ':' type_parameter_constraints + ; type_parameter_constraints - : constructor_constraint - | primary_constraint (',' secondary_constraints)? (',' constructor_constraint)? - ; + : constructor_constraint + | primary_constraint (',' secondary_constraints)? (',' constructor_constraint)? + ; primary_constraint - : class_type - | CLASS '?'? - | STRUCT - | UNMANAGED - ; + : class_type + | CLASS '?'? + | STRUCT + | UNMANAGED + ; // namespace_or_type_name includes identifier secondary_constraints - : namespace_or_type_name (',' namespace_or_type_name)* - ; + : namespace_or_type_name (',' namespace_or_type_name)* + ; constructor_constraint - : NEW OPEN_PARENS CLOSE_PARENS - ; + : NEW OPEN_PARENS CLOSE_PARENS + ; class_body - : OPEN_BRACE class_member_declarations? CLOSE_BRACE - ; + : OPEN_BRACE class_member_declarations? CLOSE_BRACE + ; class_member_declarations - : class_member_declaration+ - ; + : class_member_declaration+ + ; class_member_declaration - : attributes? all_member_modifiers? (common_member_declaration | destructor_definition) - ; + : attributes? all_member_modifiers? (common_member_declaration | destructor_definition) + ; all_member_modifiers - : all_member_modifier+ - ; + : all_member_modifier+ + ; all_member_modifier - : NEW - | PUBLIC - | PROTECTED - | INTERNAL - | PRIVATE - | READONLY - | VOLATILE - | VIRTUAL - | SEALED - | OVERRIDE - | ABSTRACT - | STATIC - | UNSAFE - | EXTERN - | PARTIAL - | ASYNC // C# 5 - ; + : NEW + | PUBLIC + | PROTECTED + | INTERNAL + | PRIVATE + | READONLY + | VOLATILE + | VIRTUAL + | SEALED + | OVERRIDE + | ABSTRACT + | STATIC + | UNSAFE + | EXTERN + | PARTIAL + | ASYNC // C# 5 + ; // represents the intersection of struct_member_declaration and class_member_declaration common_member_declaration - : constant_declaration - | typed_member_declaration - | event_declaration - | conversion_operator_declarator (body | right_arrow throwable_expression ';') // C# 6 - | constructor_declaration - | VOID method_declaration - | class_definition - | struct_definition - | interface_definition - | enum_definition - | delegate_definition - ; + : constant_declaration + | typed_member_declaration + | event_declaration + | conversion_operator_declarator (body | right_arrow throwable_expression ';') // C# 6 + | constructor_declaration + | VOID method_declaration + | class_definition + | struct_definition + | interface_definition + | enum_definition + | delegate_definition + ; typed_member_declaration - : (REF | READONLY REF | REF READONLY)? type_ - ( namespace_or_type_name '.' indexer_declaration - | method_declaration - | property_declaration - | indexer_declaration - | operator_declaration - | field_declaration - ) - ; + : (REF | READONLY REF | REF READONLY)? type_ ( + namespace_or_type_name '.' indexer_declaration + | method_declaration + | property_declaration + | indexer_declaration + | operator_declaration + | field_declaration + ) + ; constant_declarators - : constant_declarator (',' constant_declarator)* - ; + : constant_declarator (',' constant_declarator)* + ; constant_declarator - : identifier '=' expression - ; + : identifier '=' expression + ; variable_declarators - : variable_declarator (',' variable_declarator)* - ; + : variable_declarator (',' variable_declarator)* + ; variable_declarator - : identifier ('=' variable_initializer)? - ; + : identifier ('=' variable_initializer)? + ; variable_initializer - : expression - | array_initializer - ; + : expression + | array_initializer + ; return_type - : type_ - | VOID - ; + : type_ + | VOID + ; member_name - : namespace_or_type_name - ; + : namespace_or_type_name + ; method_body - : block - | ';' - ; + : block + | ';' + ; formal_parameter_list - : parameter_array - | fixed_parameters (',' parameter_array)? - ; + : parameter_array + | fixed_parameters (',' parameter_array)? + ; fixed_parameters - : fixed_parameter ( ',' fixed_parameter )* - ; + : fixed_parameter (',' fixed_parameter)* + ; fixed_parameter - : attributes? parameter_modifier? arg_declaration - | ARGLIST - ; + : attributes? parameter_modifier? arg_declaration + | ARGLIST + ; parameter_modifier - : REF - | OUT - | IN - | REF THIS - | IN THIS - | THIS - ; + : REF + | OUT + | IN + | REF THIS + | IN THIS + | THIS + ; parameter_array - : attributes? PARAMS array_type identifier - ; + : attributes? PARAMS array_type identifier + ; accessor_declarations - : attrs=attributes? mods=accessor_modifier? - (GET accessor_body set_accessor_declaration? | SET accessor_body get_accessor_declaration?) - ; + : attrs = attributes? mods = accessor_modifier? ( + GET accessor_body set_accessor_declaration? + | SET accessor_body get_accessor_declaration? + ) + ; get_accessor_declaration - : attributes? accessor_modifier? GET accessor_body - ; + : attributes? accessor_modifier? GET accessor_body + ; set_accessor_declaration - : attributes? accessor_modifier? SET accessor_body - ; + : attributes? accessor_modifier? SET accessor_body + ; accessor_modifier - : PROTECTED - | INTERNAL - | PRIVATE - | PROTECTED INTERNAL - | INTERNAL PROTECTED - ; + : PROTECTED + | INTERNAL + | PRIVATE + | PROTECTED INTERNAL + | INTERNAL PROTECTED + ; accessor_body - : block - | ';' - ; + : block + | ';' + ; event_accessor_declarations - : attributes? (ADD block remove_accessor_declaration | REMOVE block add_accessor_declaration) - ; + : attributes? (ADD block remove_accessor_declaration | REMOVE block add_accessor_declaration) + ; add_accessor_declaration - : attributes? ADD block - ; + : attributes? ADD block + ; remove_accessor_declaration - : attributes? REMOVE block - ; + : attributes? REMOVE block + ; overloadable_operator - : '+' - | '-' - | BANG - | '~' - | '++' - | '--' - | TRUE - | FALSE - | '*' - | '/' - | '%' - | '&' - | '|' - | '^' - | '<<' - | right_shift - | OP_EQ - | OP_NE - | '>' - | '<' - | '>=' - | '<=' - ; + : '+' + | '-' + | BANG + | '~' + | '++' + | '--' + | TRUE + | FALSE + | '*' + | '/' + | '%' + | '&' + | '|' + | '^' + | '<<' + | right_shift + | OP_EQ + | OP_NE + | '>' + | '<' + | '>=' + | '<=' + ; conversion_operator_declarator - : (IMPLICIT | EXPLICIT) OPERATOR type_ OPEN_PARENS arg_declaration CLOSE_PARENS - ; + : (IMPLICIT | EXPLICIT) OPERATOR type_ OPEN_PARENS arg_declaration CLOSE_PARENS + ; constructor_initializer - : ':' (BASE | THIS) OPEN_PARENS argument_list? CLOSE_PARENS - ; + : ':' (BASE | THIS) OPEN_PARENS argument_list? CLOSE_PARENS + ; body - : block - | ';' - ; + : block + | ';' + ; //B.2.8 Structs struct_interfaces - : ':' interface_type_list - ; + : ':' interface_type_list + ; struct_body - : OPEN_BRACE struct_member_declaration* CLOSE_BRACE - ; + : OPEN_BRACE struct_member_declaration* CLOSE_BRACE + ; struct_member_declaration - : attributes? all_member_modifiers? - (common_member_declaration | FIXED type_ fixed_size_buffer_declarator+ ';') - ; + : attributes? all_member_modifiers? ( + common_member_declaration + | FIXED type_ fixed_size_buffer_declarator+ ';' + ) + ; //B.2.9 Arrays array_type - : base_type (('*' | '?')* rank_specifier)+ - ; + : base_type (('*' | '?')* rank_specifier)+ + ; rank_specifier - : '[' ','* ']' - ; + : '[' ','* ']' + ; array_initializer - : OPEN_BRACE (variable_initializer (',' variable_initializer)* ','?)? CLOSE_BRACE - ; + : OPEN_BRACE (variable_initializer (',' variable_initializer)* ','?)? CLOSE_BRACE + ; //B.2.10 Interfaces variant_type_parameter_list - : '<' variant_type_parameter (',' variant_type_parameter)* '>' - ; + : '<' variant_type_parameter (',' variant_type_parameter)* '>' + ; variant_type_parameter - : attributes? variance_annotation? identifier - ; + : attributes? variance_annotation? identifier + ; variance_annotation - : IN | OUT - ; + : IN + | OUT + ; interface_base - : ':' interface_type_list - ; + : ':' interface_type_list + ; interface_body // ignored in csharp 8 - : OPEN_BRACE interface_member_declaration* CLOSE_BRACE - ; + : OPEN_BRACE interface_member_declaration* CLOSE_BRACE + ; interface_member_declaration - : attributes? NEW? - (UNSAFE? (REF | REF READONLY | READONLY REF)? type_ - ( identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ';' - | identifier OPEN_BRACE interface_accessors CLOSE_BRACE - | THIS '[' formal_parameter_list ']' OPEN_BRACE interface_accessors CLOSE_BRACE) - | UNSAFE? VOID identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ';' - | EVENT type_ identifier ';') - ; + : attributes? NEW? ( + UNSAFE? (REF | REF READONLY | READONLY REF)? type_ ( + identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ';' + | identifier OPEN_BRACE interface_accessors CLOSE_BRACE + | THIS '[' formal_parameter_list ']' OPEN_BRACE interface_accessors CLOSE_BRACE + ) + | UNSAFE? VOID identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ';' + | EVENT type_ identifier ';' + ) + ; interface_accessors - : attributes? (GET ';' (attributes? SET ';')? | SET ';' (attributes? GET ';')?) - ; + : attributes? (GET ';' (attributes? SET ';')? | SET ';' (attributes? GET ';')?) + ; //B.2.11 Enums enum_base - : ':' type_ - ; + : ':' type_ + ; enum_body - : OPEN_BRACE (enum_member_declaration (',' enum_member_declaration)* ','?)? CLOSE_BRACE - ; + : OPEN_BRACE (enum_member_declaration (',' enum_member_declaration)* ','?)? CLOSE_BRACE + ; enum_member_declaration - : attributes? identifier ('=' expression)? - ; + : attributes? identifier ('=' expression)? + ; //B.2.12 Delegates //B.2.13 Attributes global_attribute_section - : '[' global_attribute_target ':' attribute_list ','? ']' - ; + : '[' global_attribute_target ':' attribute_list ','? ']' + ; global_attribute_target - : keyword - | identifier - ; + : keyword + | identifier + ; attributes - : attribute_section+ - ; + : attribute_section+ + ; attribute_section - : '[' (attribute_target ':')? attribute_list ','? ']' - ; + : '[' (attribute_target ':')? attribute_list ','? ']' + ; attribute_target - : keyword - | identifier - ; + : keyword + | identifier + ; attribute_list - : attribute (',' attribute)* - ; + : attribute (',' attribute)* + ; attribute - : namespace_or_type_name (OPEN_PARENS (attribute_argument (',' attribute_argument)*)? CLOSE_PARENS)? - ; + : namespace_or_type_name ( + OPEN_PARENS (attribute_argument (',' attribute_argument)*)? CLOSE_PARENS + )? + ; attribute_argument - : (identifier ':')? expression - ; + : (identifier ':')? expression + ; //B.3 Grammar extensions for unsafe code pointer_type - : (simple_type | class_type) (rank_specifier | '?')* '*' - | VOID '*' - ; + : (simple_type | class_type) (rank_specifier | '?')* '*' + | VOID '*' + ; fixed_pointer_declarators - : fixed_pointer_declarator (',' fixed_pointer_declarator)* - ; + : fixed_pointer_declarator (',' fixed_pointer_declarator)* + ; fixed_pointer_declarator - : identifier '=' fixed_pointer_initializer - ; + : identifier '=' fixed_pointer_initializer + ; fixed_pointer_initializer - : '&'? expression - | stackalloc_initializer - ; + : '&'? expression + | stackalloc_initializer + ; fixed_size_buffer_declarator - : identifier '[' expression ']' - ; + : identifier '[' expression ']' + ; stackalloc_initializer - : STACKALLOC type_ '[' expression ']' - | STACKALLOC type_? '[' expression? ']' OPEN_BRACE expression (',' expression)* ','? CLOSE_BRACE - ; + : STACKALLOC type_ '[' expression ']' + | STACKALLOC type_? '[' expression? ']' OPEN_BRACE expression (',' expression)* ','? CLOSE_BRACE + ; right_arrow - : first='=' second='>' {$first.index + 1 == $second.index}? // Nothing between the tokens? - ; + : first = '=' second = '>' {$first.index + 1 == $second.index}? // Nothing between the tokens? + ; right_shift - : first='>' second='>' {$first.index + 1 == $second.index}? // Nothing between the tokens? - ; + : first = '>' second = '>' {$first.index + 1 == $second.index}? // Nothing between the tokens? + ; right_shift_assignment - : first='>' second='>=' {$first.index + 1 == $second.index}? // Nothing between the tokens? - ; + : first = '>' second = '>=' {$first.index + 1 == $second.index}? // Nothing between the tokens? + ; literal - : boolean_literal - | string_literal - | INTEGER_LITERAL - | HEX_INTEGER_LITERAL - | BIN_INTEGER_LITERAL - | REAL_LITERAL - | CHARACTER_LITERAL - | NULL_ - ; + : boolean_literal + | string_literal + | INTEGER_LITERAL + | HEX_INTEGER_LITERAL + | BIN_INTEGER_LITERAL + | REAL_LITERAL + | CHARACTER_LITERAL + | NULL_ + ; boolean_literal - : TRUE - | FALSE - ; + : TRUE + | FALSE + ; string_literal - : interpolated_regular_string - | interpolated_verbatium_string - | REGULAR_STRING - | VERBATIUM_STRING - ; + : interpolated_regular_string + | interpolated_verbatium_string + | REGULAR_STRING + | VERBATIUM_STRING + ; interpolated_regular_string - : INTERPOLATED_REGULAR_STRING_START interpolated_regular_string_part* DOUBLE_QUOTE_INSIDE - ; - + : INTERPOLATED_REGULAR_STRING_START interpolated_regular_string_part* DOUBLE_QUOTE_INSIDE + ; interpolated_verbatium_string - : INTERPOLATED_VERBATIUM_STRING_START interpolated_verbatium_string_part* DOUBLE_QUOTE_INSIDE - ; + : INTERPOLATED_VERBATIUM_STRING_START interpolated_verbatium_string_part* DOUBLE_QUOTE_INSIDE + ; interpolated_regular_string_part - : interpolated_string_expression - | DOUBLE_CURLY_INSIDE - | REGULAR_CHAR_INSIDE - | REGULAR_STRING_INSIDE - ; + : interpolated_string_expression + | DOUBLE_CURLY_INSIDE + | REGULAR_CHAR_INSIDE + | REGULAR_STRING_INSIDE + ; interpolated_verbatium_string_part - : interpolated_string_expression - | DOUBLE_CURLY_INSIDE - | VERBATIUM_DOUBLE_QUOTE_INSIDE - | VERBATIUM_INSIDE_STRING - ; + : interpolated_string_expression + | DOUBLE_CURLY_INSIDE + | VERBATIUM_DOUBLE_QUOTE_INSIDE + | VERBATIUM_INSIDE_STRING + ; interpolated_string_expression - : expression (',' expression)* (':' FORMAT_STRING+)? - ; + : expression (',' expression)* (':' FORMAT_STRING+)? + ; //B.1.7 Keywords keyword - : ABSTRACT - | AS - | BASE - | BOOL - | BREAK - | BYTE - | CASE - | CATCH - | CHAR - | CHECKED - | CLASS - | CONST - | CONTINUE - | DECIMAL - | DEFAULT - | DELEGATE - | DO - | DOUBLE - | ELSE - | ENUM - | EVENT - | EXPLICIT - | EXTERN - | FALSE - | FINALLY - | FIXED - | FLOAT - | FOR - | FOREACH - | GOTO - | IF - | IMPLICIT - | IN - | INT - | INTERFACE - | INTERNAL - | IS - | LOCK - | LONG - | NAMESPACE - | NEW - | NULL_ - | OBJECT - | OPERATOR - | OUT - | OVERRIDE - | PARAMS - | PRIVATE - | PROTECTED - | PUBLIC - | READONLY - | REF - | RETURN - | SBYTE - | SEALED - | SHORT - | SIZEOF - | STACKALLOC - | STATIC - | STRING - | STRUCT - | SWITCH - | THIS - | THROW - | TRUE - | TRY - | TYPEOF - | UINT - | ULONG - | UNCHECKED - | UNMANAGED - | UNSAFE - | USHORT - | USING - | VIRTUAL - | VOID - | VOLATILE - | WHILE - ; + : ABSTRACT + | AS + | BASE + | BOOL + | BREAK + | BYTE + | CASE + | CATCH + | CHAR + | CHECKED + | CLASS + | CONST + | CONTINUE + | DECIMAL + | DEFAULT + | DELEGATE + | DO + | DOUBLE + | ELSE + | ENUM + | EVENT + | EXPLICIT + | EXTERN + | FALSE + | FINALLY + | FIXED + | FLOAT + | FOR + | FOREACH + | GOTO + | IF + | IMPLICIT + | IN + | INT + | INTERFACE + | INTERNAL + | IS + | LOCK + | LONG + | NAMESPACE + | NEW + | NULL_ + | OBJECT + | OPERATOR + | OUT + | OVERRIDE + | PARAMS + | PRIVATE + | PROTECTED + | PUBLIC + | READONLY + | REF + | RETURN + | SBYTE + | SEALED + | SHORT + | SIZEOF + | STACKALLOC + | STATIC + | STRING + | STRUCT + | SWITCH + | THIS + | THROW + | TRUE + | TRY + | TYPEOF + | UINT + | ULONG + | UNCHECKED + | UNMANAGED + | UNSAFE + | USHORT + | USING + | VIRTUAL + | VOID + | VOLATILE + | WHILE + ; // -------------------- extra rules for modularization -------------------------------- class_definition - : CLASS identifier type_parameter_list? class_base? type_parameter_constraints_clauses? - class_body ';'? - ; + : CLASS identifier type_parameter_list? class_base? type_parameter_constraints_clauses? class_body ';'? + ; struct_definition - : (READONLY | REF)? STRUCT identifier type_parameter_list? struct_interfaces? type_parameter_constraints_clauses? - struct_body ';'? - ; + : (READONLY | REF)? STRUCT identifier type_parameter_list? struct_interfaces? type_parameter_constraints_clauses? struct_body ';'? + ; interface_definition - : INTERFACE identifier variant_type_parameter_list? interface_base? - type_parameter_constraints_clauses? class_body ';'? - ; + : INTERFACE identifier variant_type_parameter_list? interface_base? type_parameter_constraints_clauses? class_body ';'? + ; enum_definition - : ENUM identifier enum_base? enum_body ';'? - ; + : ENUM identifier enum_base? enum_body ';'? + ; delegate_definition - : DELEGATE return_type identifier variant_type_parameter_list? - OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ';' - ; + : DELEGATE return_type identifier variant_type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? + ';' + ; event_declaration - : EVENT type_ (variable_declarators ';' | member_name OPEN_BRACE event_accessor_declarations CLOSE_BRACE) - ; + : EVENT type_ ( + variable_declarators ';' + | member_name OPEN_BRACE event_accessor_declarations CLOSE_BRACE + ) + ; field_declaration - : variable_declarators ';' - ; + : variable_declarators ';' + ; property_declaration // Property initializer & lambda in properties C# 6 - : member_name (OPEN_BRACE accessor_declarations CLOSE_BRACE ('=' variable_initializer ';')? | right_arrow throwable_expression ';') - ; + : member_name ( + OPEN_BRACE accessor_declarations CLOSE_BRACE ('=' variable_initializer ';')? + | right_arrow throwable_expression ';' + ) + ; constant_declaration - : CONST type_ constant_declarators ';' - ; + : CONST type_ constant_declarators ';' + ; indexer_declaration // lamdas from C# 6 - : THIS '[' formal_parameter_list ']' (OPEN_BRACE accessor_declarations CLOSE_BRACE | right_arrow throwable_expression ';') - ; + : THIS '[' formal_parameter_list ']' ( + OPEN_BRACE accessor_declarations CLOSE_BRACE + | right_arrow throwable_expression ';' + ) + ; destructor_definition - : '~' identifier OPEN_PARENS CLOSE_PARENS body - ; + : '~' identifier OPEN_PARENS CLOSE_PARENS body + ; constructor_declaration - : identifier OPEN_PARENS formal_parameter_list? CLOSE_PARENS constructor_initializer? body - ; + : identifier OPEN_PARENS formal_parameter_list? CLOSE_PARENS constructor_initializer? body + ; method_declaration // lamdas from C# 6 - : method_member_name type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS - type_parameter_constraints_clauses? (method_body | right_arrow throwable_expression ';') - ; + : method_member_name type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ( + method_body + | right_arrow throwable_expression ';' + ) + ; method_member_name - : (identifier | identifier '::' identifier) (type_argument_list? '.' identifier)* - ; + : (identifier | identifier '::' identifier) (type_argument_list? '.' identifier)* + ; operator_declaration // lamdas form C# 6 - : OPERATOR overloadable_operator OPEN_PARENS IN? arg_declaration - (',' IN? arg_declaration)? CLOSE_PARENS (body | right_arrow throwable_expression ';') - ; + : OPERATOR overloadable_operator OPEN_PARENS IN? arg_declaration (',' IN? arg_declaration)? CLOSE_PARENS ( + body + | right_arrow throwable_expression ';' + ) + ; arg_declaration - : type_ identifier ('=' expression)? - ; + : type_ identifier ('=' expression)? + ; method_invocation - : OPEN_PARENS argument_list? CLOSE_PARENS - ; + : OPEN_PARENS argument_list? CLOSE_PARENS + ; object_creation_expression - : OPEN_PARENS argument_list? CLOSE_PARENS object_or_collection_initializer? - ; + : OPEN_PARENS argument_list? CLOSE_PARENS object_or_collection_initializer? + ; identifier - : IDENTIFIER - | ADD - | ALIAS - | ARGLIST - | ASCENDING - | ASYNC - | AWAIT - | BY - | DESCENDING - | DYNAMIC - | EQUALS - | FROM - | GET - | GROUP - | INTO - | JOIN - | LET - | NAMEOF - | ON - | ORDERBY - | PARTIAL - | REMOVE - | SELECT - | SET - | UNMANAGED - | VAR - | WHEN - | WHERE - | YIELD - ; \ No newline at end of file + : IDENTIFIER + | ADD + | ALIAS + | ARGLIST + | ASCENDING + | ASYNC + | AWAIT + | BY + | DESCENDING + | DYNAMIC + | EQUALS + | FROM + | GET + | GROUP + | INTO + | JOIN + | LET + | NAMEOF + | ON + | ORDERBY + | PARTIAL + | REMOVE + | SELECT + | SET + | UNMANAGED + | VAR + | WHEN + | WHERE + | YIELD + ; \ No newline at end of file diff --git a/csharp/CSharpPreprocessorParser.g4 b/csharp/CSharpPreprocessorParser.g4 index 15ef60ace5..1127f2b11f 100644 --- a/csharp/CSharpPreprocessorParser.g4 +++ b/csharp/CSharpPreprocessorParser.g4 @@ -2,39 +2,47 @@ // Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) // Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. +// $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 CSharpPreprocessorParser; -options { tokenVocab=CSharpLexer; superClass=CSharpPreprocessorParserBase; } +options { + tokenVocab = CSharpLexer; + superClass = CSharpPreprocessorParserBase; +} -preprocessor_directive returns [Boolean value] - : DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveDefine(); } #preprocessorDeclaration - | UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveUndef(); } #preprocessorDeclaration - | IF expr=preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveIf(); } #preprocessorConditional - | ELIF expr=preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveElif(); } #preprocessorConditional - | ELSE directive_new_line_or_sharp { this.OnPreprocessorDirectiveElse(); } #preprocessorConditional - | ENDIF directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndif(); } #preprocessorConditional - | LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.OnPreprocessorDirectiveLine(); } #preprocessorLine - | ERROR TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveError(); } #preprocessorDiagnostic - | WARNING TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveWarning(); } #preprocessorDiagnostic - | REGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveRegion(); } #preprocessorRegion - | ENDREGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndregion(); } #preprocessorRegion - | PRAGMA TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectivePragma(); } #preprocessorPragma - | NULLABLE TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveNullable(); } #preprocessorNullable - ; +preprocessor_directive + returns[Boolean value] + : DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveDefine(); } # preprocessorDeclaration + | UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveUndef(); } # preprocessorDeclaration + | IF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveIf(); } # preprocessorConditional + | ELIF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveElif(); } # preprocessorConditional + | ELSE directive_new_line_or_sharp { this.OnPreprocessorDirectiveElse(); } # preprocessorConditional + | ENDIF directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndif(); } # preprocessorConditional + | LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.OnPreprocessorDirectiveLine(); } # preprocessorLine + | ERROR TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveError(); } # preprocessorDiagnostic + | WARNING TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveWarning(); } # preprocessorDiagnostic + | REGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveRegion(); } # preprocessorRegion + | ENDREGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndregion(); } # preprocessorRegion + | PRAGMA TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectivePragma(); } # preprocessorPragma + | NULLABLE TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveNullable(); } # preprocessorNullable + ; directive_new_line_or_sharp : DIRECTIVE_NEW_LINE | EOF ; -preprocessor_expression returns [String value] - : TRUE { this.OnPreprocessorExpressionTrue(); } - | FALSE { this.OnPreprocessorExpressionFalse(); } - | CONDITIONAL_SYMBOL { this.OnPreprocessorExpressionConditionalSymbol(); } - | OPEN_PARENS expr=preprocessor_expression CLOSE_PARENS { this.OnPreprocessorExpressionConditionalOpenParens(); } - | BANG expr=preprocessor_expression { this.OnPreprocessorExpressionConditionalBang(); } - | expr1=preprocessor_expression OP_EQ expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalEq(); } - | expr1=preprocessor_expression OP_NE expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalNe(); } - | expr1=preprocessor_expression OP_AND expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalAnd(); } - | expr1=preprocessor_expression OP_OR expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalOr(); } - ; +preprocessor_expression + returns[String value] + : TRUE { this.OnPreprocessorExpressionTrue(); } + | FALSE { this.OnPreprocessorExpressionFalse(); } + | CONDITIONAL_SYMBOL { this.OnPreprocessorExpressionConditionalSymbol(); } + | OPEN_PARENS expr = preprocessor_expression CLOSE_PARENS { this.OnPreprocessorExpressionConditionalOpenParens(); } + | BANG expr = preprocessor_expression { this.OnPreprocessorExpressionConditionalBang(); } + | expr1 = preprocessor_expression OP_EQ expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalEq(); } + | expr1 = preprocessor_expression OP_NE expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalNe(); } + | expr1 = preprocessor_expression OP_AND expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalAnd(); } + | expr1 = preprocessor_expression OP_OR expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalOr(); } + ; \ No newline at end of file diff --git a/css3/css3Lexer.g4 b/css3/css3Lexer.g4 index dcfea962d6..6813752641 100644 --- a/css3/css3Lexer.g4 +++ b/css3/css3Lexer.g4 @@ -1,56 +1,41 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar css3Lexer; -channels { ERROR } - -OpenBracket: '['; -CloseBracket: ']'; -OpenParen: '('; -CloseParen: ')'; -OpenBrace: '{'; -CloseBrace: '}'; -SemiColon: ';'; -Equal: '='; -Colon: ':'; -Dot: '.'; -Multiply: '*'; -Divide: '/'; -Pipe: '|'; -Underscore: '_'; - -fragment At - : '@' - ; - -fragment Hex - : [0-9a-fA-F] - ; - -fragment NewlineOrSpace - : '\r\n' - | [ \t\r\n\f] - | - ; - -fragment Unicode - : '\\' Hex Hex? Hex? Hex? Hex? Hex? NewlineOrSpace - ; - -fragment Escape - : Unicode - | '\\' ~[\r\n\f0-9a-fA-F] - ; - -fragment Nmstart - : [_a-zA-Z] - | Nonascii - | Escape - ; - -fragment Nmchar - : [_a-zA-Z0-9\-] - | Nonascii - | Escape - ; +channels { + ERROR +} + +OpenBracket : '['; +CloseBracket : ']'; +OpenParen : '('; +CloseParen : ')'; +OpenBrace : '{'; +CloseBrace : '}'; +SemiColon : ';'; +Equal : '='; +Colon : ':'; +Dot : '.'; +Multiply : '*'; +Divide : '/'; +Pipe : '|'; +Underscore : '_'; + +fragment At: '@'; + +fragment Hex: [0-9a-fA-F]; + +fragment NewlineOrSpace: '\r\n' | [ \t\r\n\f] |; + +fragment Unicode: '\\' Hex Hex? Hex? Hex? Hex? Hex? NewlineOrSpace; + +fragment Escape: Unicode | '\\' ~[\r\n\f0-9a-fA-F]; + +fragment Nmstart: [_a-zA-Z] | Nonascii | Escape; + +fragment Nmchar: [_a-zA-Z0-9\-] | Nonascii | Escape; // CSS2.2 Grammar defines the following, but I'm not sure how to add them to parser for error handling // BadString : @@ -58,501 +43,214 @@ fragment Nmchar // BadComment : // BadUri : -Comment - : '/*' ~'*'* '*'+ ( ~[/*] ~'*'* '*'+ )* '/' - ; - -fragment Name - : Nmchar+ - ; - -Url - : U R L '(' Whitespace ( [!#$%&*-~] | Nonascii | Escape )* Whitespace ')' - ; - -Space - : [ \t\r\n\f]+ - ; - -fragment Whitespace - : Space - | - ; - -fragment Newline - : '\n' - | '\r\n' - | '\r' - | '\f' - ; - -fragment ZeroToFourZeros - : '0'? '0'? '0'? '0'? - ; - -fragment A - : 'a' - | 'A' - | '\\' ZeroToFourZeros ('41'|'61') NewlineOrSpace - ; - -fragment B - : 'b' - | 'B' - | '\\' ZeroToFourZeros ('42'|'62') NewlineOrSpace - ; - -fragment C - : 'c' - | 'C' - | '\\' ZeroToFourZeros ('43'|'63') NewlineOrSpace - ; - -fragment D - : 'd' - | 'D' - | '\\' ZeroToFourZeros ('44'|'64') NewlineOrSpace - ; - -fragment E - : 'e' - | 'E' - | '\\' ZeroToFourZeros ('45'|'65') NewlineOrSpace - ; - -fragment F - : 'f' - | 'F' - | '\\' ZeroToFourZeros ('46'|'66') NewlineOrSpace - ; - -fragment G - : 'g' - | 'G' - | '\\' ZeroToFourZeros ('47'|'67') NewlineOrSpace - | '\\g' - | '\\G' - ; - -fragment H - : 'h' - | 'H' - | '\\' ZeroToFourZeros ('48'|'68') NewlineOrSpace - | '\\h' - | '\\H' - ; - -fragment I - : 'i' - | 'I' - | '\\' ZeroToFourZeros ('49'|'69') NewlineOrSpace - | '\\i' - | '\\I' - ; - -fragment K - : 'k' - | 'K' - | '\\' ZeroToFourZeros ('4b'|'6b') NewlineOrSpace - | '\\k' - | '\\K' - ; - -fragment L - : 'l' - | 'L' - | '\\' ZeroToFourZeros ('4c'|'6c') NewlineOrSpace - | '\\l' - | '\\L' - ; - -fragment M - : 'm' - | 'M' - | '\\' ZeroToFourZeros ('4d'|'6d') NewlineOrSpace - | '\\m' - | '\\M' - ; - -fragment N - : 'n' - | 'N' - | '\\' ZeroToFourZeros ('4e'|'6e') NewlineOrSpace - | '\\n' - | '\\N' - ; - -fragment O - : 'o' - | 'O' - | '\\' ZeroToFourZeros ('4f'|'6f') NewlineOrSpace - | '\\o' - | '\\O' - ; - -fragment P - : 'p' - | 'P' - | '\\' ZeroToFourZeros ('50'|'70') NewlineOrSpace - | '\\p' - | '\\P' - ; - -fragment Q - : 'q' - | 'Q' - | '\\' ZeroToFourZeros ('51'|'71') NewlineOrSpace - | '\\q' - | '\\Q' - ; - -fragment R - : 'r' - | 'R' - | '\\' ZeroToFourZeros ('52'|'72') NewlineOrSpace - | '\\r' - | '\\R' - ; - -fragment S - : 's' - | 'S' - | '\\' ZeroToFourZeros ('53'|'73') NewlineOrSpace - | '\\s' - | '\\S' - ; - -fragment T - : 't' - | 'T' - | '\\' ZeroToFourZeros ('54'|'74') NewlineOrSpace - | '\\t' - | '\\T' - ; - -fragment U - : 'u' - | 'U' - | '\\' ZeroToFourZeros ('55'|'75') NewlineOrSpace - | '\\u' - | '\\U' - ; - -fragment V - : 'v' - | 'V' - | '\\' ZeroToFourZeros ('56'|'76') NewlineOrSpace - | '\\v' - | '\\V' - ; - -fragment W - : 'w' - | 'W' - | '\\' ZeroToFourZeros ('57'|'77') NewlineOrSpace - | '\\w' - | '\\W' - ; - -fragment X - : 'x' - | 'X' - | '\\' ZeroToFourZeros ('58'|'78') NewlineOrSpace - | '\\x' - | '\\X' - ; - -fragment Y - : 'y' - | 'Y' - | '\\' ZeroToFourZeros ('59'|'79') NewlineOrSpace - | '\\y' - | '\\Y' - ; - -fragment Z - : 'z' - | 'Z' - | '\\' ZeroToFourZeros ('5a'|'7a') NewlineOrSpace - | '\\z' - | '\\Z' - ; - -fragment DashChar - : '-' - | '\\' ZeroToFourZeros '2d' NewlineOrSpace - ; - -Cdo - : '' - ; - -Includes - : '~=' - ; - -DashMatch - : '|=' - ; - -Hash - : '#' Name - ; - -Import - : At I M P O R T - ; - -Page - : At P A G E - ; - -Media - : At M E D I A - ; - -Namespace - : At N A M E S P A C E - ; - -Charset - : '@charset ' - ; - -Important - : '!' ( Space | Comment )* I M P O R T A N T - ; - -fragment FontRelative - : Number E M - | Number E X - | Number C H - | Number R E M - ; +Comment: '/*' ~'*'* '*'+ ( ~[/*] ~'*'* '*'+)* '/'; + +fragment Name: Nmchar+; + +Url: U R L '(' Whitespace ( [!#$%&*-~] | Nonascii | Escape)* Whitespace ')'; + +Space: [ \t\r\n\f]+; + +fragment Whitespace: Space |; + +fragment Newline: '\n' | '\r\n' | '\r' | '\f'; + +fragment ZeroToFourZeros: '0'? '0'? '0'? '0'?; + +fragment A: 'a' | 'A' | '\\' ZeroToFourZeros ('41' | '61') NewlineOrSpace; + +fragment B: 'b' | 'B' | '\\' ZeroToFourZeros ('42' | '62') NewlineOrSpace; + +fragment C: 'c' | 'C' | '\\' ZeroToFourZeros ('43' | '63') NewlineOrSpace; + +fragment D: 'd' | 'D' | '\\' ZeroToFourZeros ('44' | '64') NewlineOrSpace; + +fragment E: 'e' | 'E' | '\\' ZeroToFourZeros ('45' | '65') NewlineOrSpace; + +fragment F: 'f' | 'F' | '\\' ZeroToFourZeros ('46' | '66') NewlineOrSpace; + +fragment G: 'g' | 'G' | '\\' ZeroToFourZeros ('47' | '67') NewlineOrSpace | '\\g' | '\\G'; + +fragment H: 'h' | 'H' | '\\' ZeroToFourZeros ('48' | '68') NewlineOrSpace | '\\h' | '\\H'; + +fragment I: 'i' | 'I' | '\\' ZeroToFourZeros ('49' | '69') NewlineOrSpace | '\\i' | '\\I'; + +fragment K: 'k' | 'K' | '\\' ZeroToFourZeros ('4b' | '6b') NewlineOrSpace | '\\k' | '\\K'; + +fragment L: 'l' | 'L' | '\\' ZeroToFourZeros ('4c' | '6c') NewlineOrSpace | '\\l' | '\\L'; + +fragment M: 'm' | 'M' | '\\' ZeroToFourZeros ('4d' | '6d') NewlineOrSpace | '\\m' | '\\M'; + +fragment N: 'n' | 'N' | '\\' ZeroToFourZeros ('4e' | '6e') NewlineOrSpace | '\\n' | '\\N'; + +fragment O: 'o' | 'O' | '\\' ZeroToFourZeros ('4f' | '6f') NewlineOrSpace | '\\o' | '\\O'; + +fragment P: 'p' | 'P' | '\\' ZeroToFourZeros ('50' | '70') NewlineOrSpace | '\\p' | '\\P'; + +fragment Q: 'q' | 'Q' | '\\' ZeroToFourZeros ('51' | '71') NewlineOrSpace | '\\q' | '\\Q'; + +fragment R: 'r' | 'R' | '\\' ZeroToFourZeros ('52' | '72') NewlineOrSpace | '\\r' | '\\R'; + +fragment S: 's' | 'S' | '\\' ZeroToFourZeros ('53' | '73') NewlineOrSpace | '\\s' | '\\S'; + +fragment T: 't' | 'T' | '\\' ZeroToFourZeros ('54' | '74') NewlineOrSpace | '\\t' | '\\T'; + +fragment U: 'u' | 'U' | '\\' ZeroToFourZeros ('55' | '75') NewlineOrSpace | '\\u' | '\\U'; + +fragment V: 'v' | 'V' | '\\' ZeroToFourZeros ('56' | '76') NewlineOrSpace | '\\v' | '\\V'; + +fragment W: 'w' | 'W' | '\\' ZeroToFourZeros ('57' | '77') NewlineOrSpace | '\\w' | '\\W'; + +fragment X: 'x' | 'X' | '\\' ZeroToFourZeros ('58' | '78') NewlineOrSpace | '\\x' | '\\X'; + +fragment Y: 'y' | 'Y' | '\\' ZeroToFourZeros ('59' | '79') NewlineOrSpace | '\\y' | '\\Y'; + +fragment Z: 'z' | 'Z' | '\\' ZeroToFourZeros ('5a' | '7a') NewlineOrSpace | '\\z' | '\\Z'; + +fragment DashChar: '-' | '\\' ZeroToFourZeros '2d' NewlineOrSpace; + +Cdo: ''; + +Includes: '~='; + +DashMatch: '|='; + +Hash: '#' Name; + +Import: At I M P O R T; + +Page: At P A G E; + +Media: At M E D I A; + +Namespace: At N A M E S P A C E; + +Charset: '@charset '; + +Important: '!' ( Space | Comment)* I M P O R T A N T; + +fragment FontRelative: Number E M | Number E X | Number C H | Number R E M; // https://www.w3.org/TR/css3-values/#viewport-relative-lengths -fragment ViewportRelative - : Number V W - | Number V H - | Number V M I N - | Number V M A X - ; - -fragment AbsLength - : Number P X +fragment ViewportRelative: Number V W | Number V H | Number V M I N | Number V M A X; + +fragment AbsLength: + Number P X | Number C M | Number M M | Number I N | Number P T | Number P C | Number Q - ; - -fragment Angle - : Number D E G - | Number R A D - | Number G R A D - | Number T U R N - ; - -fragment Time - : Number M S - | Number S - ; - -fragment Freq - : Number H Z - | Number K H Z - ; - -Percentage - : Number '%' - ; - -Url_ - : 'url(' - ; - -UnicodeRange - : [u|U] '+?' '?'? '?'? '?'? '?'? '?'? +; + +fragment Angle: Number D E G | Number R A D | Number G R A D | Number T U R N; + +fragment Time: Number M S | Number S; + +fragment Freq: Number H Z | Number K H Z; + +Percentage: Number '%'; + +Url_: 'url('; + +UnicodeRange: + [u|U] '+?' '?'? '?'? '?'? '?'? '?'? | [u|U] '+' Hex '?'? '?'? '?'? '?'? '?'? | [u|U] '+' Hex Hex '?'? '?'? '?'? '?'? | [u|U] '+' Hex Hex Hex '?'? '?'? '?'? | [u|U] '+' Hex Hex Hex Hex '?'? '?'? | [u|U] '+' Hex Hex Hex Hex Hex '?'? - ; +; // https://www.w3.org/TR/css3-mediaqueries/ -MediaOnly - : O N L Y - ; - -Not - : N O T - ; - -And - : A N D - ; - -fragment Resolution - : Number D P I - | Number D P C M - | Number D P P X - ; - -fragment Length - : AbsLength - | FontRelative - | ViewportRelative - ; - -Dimension - : Length - | Time - | Freq - | Resolution - | Angle - ; - -UnknownDimension - : Number Ident - ; +MediaOnly: O N L Y; + +Not: N O T; + +And: A N D; + +fragment Resolution: Number D P I | Number D P C M | Number D P P X; + +fragment Length: AbsLength | FontRelative | ViewportRelative; + +Dimension: Length | Time | Freq | Resolution | Angle; + +UnknownDimension: Number Ident; // https://www.w3.org/TR/css3-selectors/ -fragment Nonascii - : ~[\u0000-\u007f] - ; +fragment Nonascii: ~[\u0000-\u007f]; -Plus - : '+' - ; +Plus: '+'; -Minus - : '-' - ; +Minus: '-'; -Greater - : '>' - ; +Greater: '>'; -Comma - : ',' - ; +Comma: ','; -Tilde - : '~' - ; +Tilde: '~'; -PseudoNot - : ':' N O T '(' - ; +PseudoNot: ':' N O T '('; -Number - : [0-9]+ - | [0-9]* '.' [0-9]+ - ; +Number: [0-9]+ | [0-9]* '.' [0-9]+; -String_ - : '"' ( ~[\n\r\f\\"] | '\\' Newline | Nonascii | Escape )* '"' - | '\'' ( ~[\n\r\f\\'] | '\\' Newline | Nonascii | Escape )* '\'' - ; +String_: + '"' (~[\n\r\f\\"] | '\\' Newline | Nonascii | Escape)* '"' + | '\'' ( ~[\n\r\f\\'] | '\\' Newline | Nonascii | Escape)* '\'' +; -PrefixMatch - : '^=' - ; +PrefixMatch: '^='; -SuffixMatch - : '$=' - ; +SuffixMatch: '$='; -SubstringMatch - : '*=' - ; +SubstringMatch: '*='; // https://www.w3.org/TR/css-fonts-3/#font-face-rule -FontFace - : At F O N T DashChar F A C E - ; +FontFace: At F O N T DashChar F A C E; // https://www.w3.org/TR/css3-conditional/ -Supports - : At S U P P O R T S - ; +Supports: At S U P P O R T S; -Or - : O R - ; +Or: O R; // https://www.w3.org/TR/css3-animations/ -fragment VendorPrefix - : '-' M O Z '-' - | '-' W E B K I T '-' - | '-' O '-' - ; +fragment VendorPrefix: '-' M O Z '-' | '-' W E B K I T '-' | '-' O '-'; -Keyframes - : At VendorPrefix? K E Y F R A M E S - ; +Keyframes: At VendorPrefix? K E Y F R A M E S; -From - : F R O M - ; +From: F R O M; -To - : T O - ; +To: T O; // https://www.w3.org/TR/css3-values/#calc-syntax -Calc - : 'calc(' - ; +Calc: 'calc('; // https://www.w3.org/TR/css-device-adapt-1/ -Viewport - : At V I E W P O R T - ; +Viewport: At V I E W P O R T; // https://www.w3.org/TR/css-counter-styles-3/ -CounterStyle - : At C O U N T E R DashChar S T Y L E - ; +CounterStyle: At C O U N T E R DashChar S T Y L E; // https://www.w3.org/TR/css-fonts-3/ -FontFeatureValues - : At F O N T DashChar F E A T U R E DashChar V A L U E S - ; +FontFeatureValues: At F O N T DashChar F E A T U R E DashChar V A L U E S; // https://msdn.microsoft.com/en-us/library/ms532847.aspx -DxImageTransform - : 'progid:DXImageTransform.Microsoft.' Function_ - ; +DxImageTransform: 'progid:DXImageTransform.Microsoft.' Function_; -AtKeyword - : At Ident - ; +AtKeyword: At Ident; // Variables // https://www.w3.org/TR/css-variables-1 -Variable - : '--' Nmstart Nmchar* - ; +Variable: '--' Nmstart Nmchar*; -Var - : 'var(' - ; +Var: 'var('; // Give Ident least priority so that more specific rules matches first -Ident - : '-'? Nmstart Nmchar* - ; +Ident: '-'? Nmstart Nmchar*; -Function_ - : Ident '(' - ; +Function_: Ident '('; -UnexpectedCharacter: . -> channel(ERROR); +UnexpectedCharacter: . -> channel(ERROR); \ No newline at end of file diff --git a/css3/css3Parser.g4 b/css3/css3Parser.g4 index efbc1735f7..b84af2f6be 100644 --- a/css3/css3Parser.g4 +++ b/css3/css3Parser.g4 @@ -1,30 +1,35 @@ +// $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 css3Parser; options { - tokenVocab=css3Lexer; + tokenVocab = css3Lexer; } stylesheet - : ws ( charset ( Comment | Space | Cdo | Cdc )* )* ( imports ( Comment | Space | Cdo | Cdc )* )* ( namespace_ ( Comment | Space | Cdo | Cdc )* )* ( nestedStatement ( Comment | Space | Cdo | Cdc )* )* EOF + : ws (charset ( Comment | Space | Cdo | Cdc)*)* (imports ( Comment | Space | Cdo | Cdc)*)* ( + namespace_ ( Comment | Space | Cdo | Cdc)* + )* (nestedStatement ( Comment | Space | Cdo | Cdc)*)* EOF ; charset - : Charset ws String_ ws ';' ws # goodCharset - | Charset ws String_ ws # badCharset + : Charset ws String_ ws ';' ws # goodCharset + | Charset ws String_ ws # badCharset ; imports - : Import ws ( String_ | url ) ws mediaQueryList ';' ws # goodImport - | Import ws ( String_ | url ) ws ';' ws # goodImport - | Import ws ( String_ | url ) ws mediaQueryList # badImport - | Import ws ( String_ | url ) ws # badImport + : Import ws (String_ | url) ws mediaQueryList ';' ws # goodImport + | Import ws ( String_ | url) ws ';' ws # goodImport + | Import ws ( String_ | url) ws mediaQueryList # badImport + | Import ws ( String_ | url) ws # badImport ; // Namespaces // https://www.w3.org/TR/css-namespaces-3/ namespace_ - : Namespace ws (namespacePrefix ws)? ( String_ | url ) ws ';' ws # goodNamespace - | Namespace ws (namespacePrefix ws)? ( String_ | url ) ws # badNamespace + : Namespace ws (namespacePrefix ws)? (String_ | url) ws ';' ws # goodNamespace + | Namespace ws (namespacePrefix ws)? ( String_ | url) ws # badNamespace ; namespacePrefix @@ -38,12 +43,12 @@ media ; mediaQueryList - : ( mediaQuery ( Comma ws mediaQuery )* )? ws + : (mediaQuery ( Comma ws mediaQuery)*)? ws ; mediaQuery - : ( MediaOnly | Not )? ws mediaType ws ( And ws mediaExpression )* - | mediaExpression ( And ws mediaExpression )* + : (MediaOnly | Not)? ws mediaType ws (And ws mediaExpression)* + | mediaExpression ( And ws mediaExpression)* ; mediaType @@ -51,7 +56,8 @@ mediaType ; mediaExpression - : '(' ws mediaFeature ( ':' ws expr )? ')' ws // Grammar allows for 'and(', which gets tokenized as Function. In practice, people always insert space before '(' to have it work on Chrome. + : '(' ws mediaFeature (':' ws expr)? ')' ws + // Grammar allows for 'and(', which gets tokenized as Function. In practice, people always insert space before '(' to have it work on Chrome. ; mediaFeature @@ -60,7 +66,7 @@ mediaFeature // Page page - : Page ws pseudoPage? '{' ws declaration? ( ';' ws declaration? )* '}' ws + : Page ws pseudoPage? '{' ws declaration? (';' ws declaration?)* '}' ws ; pseudoPage @@ -70,11 +76,11 @@ pseudoPage // Selectors // https://www.w3.org/TR/css3-selectors/ selectorGroup - : selector ( Comma ws selector )* + : selector (Comma ws selector)* ; selector - : simpleSelectorSequence ws ( combinator simpleSelectorSequence ws )* + : simpleSelectorSequence ws (combinator simpleSelectorSequence ws)* ; combinator @@ -85,8 +91,8 @@ combinator ; simpleSelectorSequence - : ( typeSelector | universal ) ( Hash | className | attrib | pseudo | negation )* - | ( Hash | className | attrib | pseudo | negation )+ + : (typeSelector | universal) (Hash | className | attrib | pseudo | negation)* + | ( Hash | className | attrib | pseudo | negation)+ ; typeSelector @@ -94,7 +100,7 @@ typeSelector ; typeNamespacePrefix - : ( ident | '*' )? '|' + : (ident | '*')? '|' ; elementName @@ -110,15 +116,20 @@ className ; attrib - : '[' ws typeNamespacePrefix? ident ws ( ( PrefixMatch | SuffixMatch | SubstringMatch | '=' | Includes | DashMatch ) ws ( ident | String_ ) ws )? ']' + : '[' ws typeNamespacePrefix? ident ws ( + (PrefixMatch | SuffixMatch | SubstringMatch | '=' | Includes | DashMatch) ws ( + ident + | String_ + ) ws + )? ']' ; pseudo - /* '::' starts a pseudo-element, ':' a pseudo-class */ - /* Exceptions: :first-line, :first-letter, :before And :after. */ - /* Note that pseudo-elements are restricted to one per selector And */ - /* occur MediaOnly in the last simple_selector_sequence. */ - : ':' ':'? ( ident | functionalPseudo ) +/* '::' starts a pseudo-element, ':' a pseudo-class */ +/* Exceptions: :first-line, :first-letter, :before And :after. */ +/* Note that pseudo-elements are restricted to one per selector And */ +/* occur MediaOnly in the last simple_selector_sequence. */ + : ':' ':'? (ident | functionalPseudo) ; functionalPseudo @@ -126,9 +137,9 @@ functionalPseudo ; expression - /* In CSS3, the expressions are identifiers, strings, */ - /* or of the form "an+b" */ - : ( ( Plus | Minus | Dimension | UnknownDimension | Number | String_ | ident ) ws )+ +/* In CSS3, the expressions are identifiers, strings, */ +/* or of the form "an+b" */ + : (( Plus | Minus | Dimension | UnknownDimension | Number | String_ | ident) ws)+ ; negation @@ -146,31 +157,31 @@ negationArg // Rules operator_ - : '/' ws # goodOperator - | Comma ws # goodOperator - | Space ws # goodOperator - | '=' ws # badOperator // IE filter and DXImageTransform function + : '/' ws # goodOperator + | Comma ws # goodOperator + | Space ws # goodOperator + | '=' ws # badOperator // IE filter and DXImageTransform function ; property_ - : ident ws # goodProperty - | Variable ws # goodProperty - | '*' ident # badProperty // IE hacks - | '_' ident # badProperty // IE hacks + : ident ws # goodProperty + | Variable ws # goodProperty + | '*' ident # badProperty // IE hacks + | '_' ident # badProperty // IE hacks ; ruleset - : selectorGroup '{' ws declarationList? '}' ws # knownRuleset - | any_* '{' ws declarationList? '}' ws # unknownRuleset + : selectorGroup '{' ws declarationList? '}' ws # knownRuleset + | any_* '{' ws declarationList? '}' ws # unknownRuleset ; declarationList - : ( ';' ws )* declaration ws ( ';' ws declaration? )* + : (';' ws)* declaration ws (';' ws declaration?)* ; declaration - : property_ ':' ws expr prio? # knownDeclaration - | property_ ':' ws value # unknownDeclaration + : property_ ':' ws expr prio? # knownDeclaration + | property_ ':' ws value # unknownDeclaration ; prio @@ -178,27 +189,27 @@ prio ; value - : ( any_ | block | AtKeyword ws )+ + : (any_ | block | AtKeyword ws)+ ; expr - : term ( operator_? term )* + : term (operator_? term)* ; term - : number ws # knownTerm - | percentage ws # knownTerm - | dimension ws # knownTerm - | String_ ws # knownTerm - | UnicodeRange ws # knownTerm - | ident ws # knownTerm - | var_ # knownTerm - | url ws # knownTerm - | hexcolor # knownTerm - | calc # knownTerm - | function_ # knownTerm - | unknownDimension ws # unknownTerm - | dxImageTransform # badTerm + : number ws # knownTerm + | percentage ws # knownTerm + | dimension ws # knownTerm + | String_ ws # knownTerm + | UnicodeRange ws # knownTerm + | ident ws # knownTerm + | var_ # knownTerm + | url ws # knownTerm + | hexcolor # knownTerm + | calc # knownTerm + | function_ # knownTerm + | unknownDimension ws # unknownTerm + | dxImageTransform # badTerm ; function_ @@ -206,7 +217,7 @@ function_ ; dxImageTransform - : DxImageTransform ws expr ')' ws // IE DXImageTransform function + : DxImageTransform ws expr ')' ws // IE DXImageTransform function ; hexcolor @@ -214,19 +225,19 @@ hexcolor ; number - : ( Plus | Minus )? Number + : (Plus | Minus)? Number ; percentage - : ( Plus | Minus )? Percentage + : (Plus | Minus)? Percentage ; dimension - : ( Plus | Minus )? Dimension + : (Plus | Minus)? Dimension ; unknownDimension - : ( Plus | Minus )? UnknownDimension + : (Plus | Minus)? UnknownDimension ; // Error handling @@ -244,13 +255,13 @@ any_ | Includes ws | DashMatch ws | ':' ws - | Function_ ws ( any_ | unused )* ')' ws - | '(' ws ( any_ | unused )* ')' ws - | '[' ws ( any_ | unused )* ']' ws + | Function_ ws ( any_ | unused)* ')' ws + | '(' ws ( any_ | unused)* ')' ws + | '[' ws ( any_ | unused)* ']' ws ; atRule - : AtKeyword ws any_* ( block | ';' ws ) # unknownAtRule + : AtKeyword ws any_* (block | ';' ws) # unknownAtRule ; unused @@ -262,7 +273,7 @@ unused ; block - : '{' ws ( declarationList | nestedStatement | any_ | block | AtKeyword ws | ';' ws )* '}' ws + : '{' ws (declarationList | nestedStatement | any_ | block | AtKeyword ws | ';' ws)* '}' ws ; // Conditional @@ -306,11 +317,11 @@ supportsNegation ; supportsConjunction - : supportsConditionInParens ( ws Space ws And ws Space ws supportsConditionInParens )+ + : supportsConditionInParens (ws Space ws And ws Space ws supportsConditionInParens)+ ; supportsDisjunction - : supportsConditionInParens ( ws Space ws Or ws Space ws supportsConditionInParens )+ + : supportsConditionInParens (ws Space ws Or ws Space ws supportsConditionInParens)+ ; supportsDeclarationCondition @@ -318,7 +329,7 @@ supportsDeclarationCondition ; generalEnclosed - : ( Function_ | '(' ) ( any_ | unused )* ')' + : (Function_ | '(') (any_ | unused)* ')' ; // Url @@ -341,11 +352,11 @@ calc ; calcSum - : calcProduct ( Space ws ( Plus | Minus ) ws Space ws calcProduct )* + : calcProduct (Space ws ( Plus | Minus) ws Space ws calcProduct)* ; calcProduct - : calcValue ( '*' ws calcValue | '/' ws number ws )* + : calcValue ('*' ws calcValue | '/' ws number ws)* ; calcValue @@ -359,12 +370,12 @@ calcValue // Font face // https://www.w3.org/TR/2013/CR-css-fonts-3-20131003/#font-face-rule fontFaceRule - : FontFace ws '{' ws fontFaceDeclaration? ( ';' ws fontFaceDeclaration? )* '}' ws + : FontFace ws '{' ws fontFaceDeclaration? (';' ws fontFaceDeclaration?)* '}' ws ; fontFaceDeclaration - : property_ ':' ws expr # knownFontFaceDeclaration - | property_ ':' ws value # unknownFontFaceDeclaration + : property_ ':' ws expr # knownFontFaceDeclaration + | property_ ':' ws value # unknownFontFaceDeclaration ; // Animations @@ -374,11 +385,11 @@ keyframesRule ; keyframeBlock - : ( keyframeSelector '{' ws declarationList? '}' ws ) + : (keyframeSelector '{' ws declarationList? '}' ws) ; keyframeSelector - : ( From | To | Percentage ) ws ( Comma ws ( From | To | Percentage ) ws )* + : (From | To | Percentage) ws (Comma ws ( From | To | Percentage) ws)* ; // Viewport @@ -400,16 +411,16 @@ fontFeatureValuesRule ; fontFamilyNameList - : fontFamilyName ( ws Comma ws fontFamilyName )* + : fontFamilyName (ws Comma ws fontFamilyName)* ; fontFamilyName : String_ - | ident ( ws ident )* + | ident ( ws ident)* ; featureValueBlock - : featureType ws '{' ws featureValueDefinition? ( ws ';' ws featureValueDefinition? )* '}' ws + : featureType ws '{' ws featureValueDefinition? (ws ';' ws featureValueDefinition?)* '}' ws ; featureType @@ -417,7 +428,7 @@ featureType ; featureValueDefinition - : ident ws ':' ws number ( ws number )* + : ident ws ':' ws number (ws number)* ; // The specific words can be identifiers too @@ -434,5 +445,5 @@ ident // Comments might be part of CSS hacks, thus pass them to visitor to decide whether to skip // Spaces are significant around '+' '-' '(', thus they should not be skipped ws - : ( Comment | Space )* - ; + : (Comment | Space)* + ; \ No newline at end of file diff --git a/csv/CSV.g4 b/csv/CSV.g4 index c610bf8b45..5d8893820b 100644 --- a/csv/CSV.g4 +++ b/csv/CSV.g4 @@ -26,13 +26,22 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar CSV; -csvFile: hdr row+ EOF ; +csvFile + : hdr row+ EOF + ; -hdr : row ; +hdr + : row + ; -row : field (',' field)* '\r'? '\n' ; +row + : field (',' field)* '\r'? '\n' + ; field : TEXT @@ -40,5 +49,10 @@ field | ; -TEXT : ~[,\n\r"]+ ; -STRING : '"' ('""'|~'"')* '"' ; // quote-quote is an escaped quote +TEXT + : ~[,\n\r"]+ + ; + +STRING + : '"' ('""' | ~'"')* '"' + ; // quote-quote is an escaped quote \ No newline at end of file diff --git a/ctl/ctl.g4 b/ctl/ctl.g4 index dcacb62efd..20937620e9 100644 --- a/ctl/ctl.g4 +++ b/ctl/ctl.g4 @@ -32,84 +32,88 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ctl; -file_ : proposition EOF ; +file_ + : proposition EOF + ; proposition - : CTL_DOWNTACK - | CTL_UPTACK - | ATOMIC - | CTL_INEVITABLE (CTL_NEXT | CTL_FINALLY | CTL_GLOBALLY) proposition - | CTL_EXISTS (CTL_NEXT | CTL_FINALLY | CTL_GLOBALLY) proposition - | CTL_INEVITABLE '[' proposition CTL_UNTIL proposition ']' - | CTL_EXISTS '[' proposition CTL_UNTIL proposition ']' - | '(' proposition ')' - | proposition (CTL_AND | CTL_OR | CTL_RIGHTWARDS_DOUBLE_ARROW | CTL_LEFT_RIGHT_DOUBLE_ARROW) proposition - | CTL_NOT proposition - ; + : CTL_DOWNTACK + | CTL_UPTACK + | ATOMIC + | CTL_INEVITABLE (CTL_NEXT | CTL_FINALLY | CTL_GLOBALLY) proposition + | CTL_EXISTS (CTL_NEXT | CTL_FINALLY | CTL_GLOBALLY) proposition + | CTL_INEVITABLE '[' proposition CTL_UNTIL proposition ']' + | CTL_EXISTS '[' proposition CTL_UNTIL proposition ']' + | '(' proposition ')' + | proposition (CTL_AND | CTL_OR | CTL_RIGHTWARDS_DOUBLE_ARROW | CTL_LEFT_RIGHT_DOUBLE_ARROW) proposition + | CTL_NOT proposition + ; ATOMIC - : [a-z]+ - ; + : [a-z]+ + ; CTL_UNTIL - : 'U' - ; + : 'U' + ; CTL_GLOBALLY - : 'G' - ; + : 'G' + ; CTL_FINALLY - : 'F' - ; + : 'F' + ; CTL_NEXT - : 'X' - ; + : 'X' + ; CTL_INEVITABLE - : 'A' - ; + : 'A' + ; CTL_EXISTS - : 'E' - ; + : 'E' + ; CTL_PROPOSITION - : '\u2205' - ; + : '\u2205' + ; CTL_LEFT_RIGHT_DOUBLE_ARROW - : '\u21d4' - ; + : '\u21d4' + ; CTL_RIGHTWARDS_DOUBLE_ARROW - : '\u21d2' - ; + : '\u21d2' + ; CTL_AND - : '\u2227' - ; + : '\u2227' + ; CTL_OR - : '\u2228' - ; + : '\u2228' + ; CTL_DOWNTACK - : '\u22a4' - ; + : '\u22a4' + ; CTL_UPTACK - : '\u22a5' - ; + : '\u22a5' + ; CTL_NOT - : '\u2310' - ; + : '\u2310' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/cto/CtoLexer.g4 b/cto/CtoLexer.g4 index bb60bda42a..05b9b7f536 100644 --- a/cto/CtoLexer.g4 +++ b/cto/CtoLexer.g4 @@ -31,130 +31,118 @@ https://hyperledger.github.io/composer/v0.19/reference/cto_language.html */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar CtoLexer; // Keywords -ABSTRACT: 'abstract'; -ASSET: 'asset'; -CONCEPT: 'concept'; -DEFAULT: 'default'; -ENUM: 'enum'; -EVENT: 'event'; -EXTENDS: 'extends'; -IDENTIFIED: 'identified by'; -IMPORT: 'import'; -NAMESPACE: 'namespace'; -OPTIONAL: 'optional'; -PARTICIPANT: 'participant'; -RANGE: 'range'; -REGEX: 'regex'; -TRANSACTION: 'transaction'; +ABSTRACT : 'abstract'; +ASSET : 'asset'; +CONCEPT : 'concept'; +DEFAULT : 'default'; +ENUM : 'enum'; +EVENT : 'event'; +EXTENDS : 'extends'; +IDENTIFIED : 'identified by'; +IMPORT : 'import'; +NAMESPACE : 'namespace'; +OPTIONAL : 'optional'; +PARTICIPANT : 'participant'; +RANGE : 'range'; +REGEX : 'regex'; +TRANSACTION : 'transaction'; //primitive types -BOOLEAN: 'Boolean'; -DATE_TIME: 'DateTime'; -DOUBLE: 'Double'; -INTEGER: 'Integer'; -LONG: 'Long'; -STRING: 'String'; +BOOLEAN : 'Boolean'; +DATE_TIME : 'DateTime'; +DOUBLE : 'Double'; +INTEGER : 'Integer'; +LONG : 'Long'; +STRING : 'String'; // Separators -LPAREN: '('; -RPAREN: ')'; -LBRACE: '{'; -RBRACE: '}'; -LBRACK: '['; -RBRACK: ']'; -SEMI: ';'; -COMMA: ','; -DOT: '.'; -COLON: ':'; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +COLON : ':'; // Operators -ASSIGN: '='; -MUL: '*'; +ASSIGN : '='; +MUL : '*'; // Additional symbols -AT: '@'; -ELLIPSIS: '...'; -REF: '--> '; -VAR: 'o '; +AT : '@'; +ELLIPSIS : '...'; +REF : '--> '; +VAR : 'o '; // Literals -DECIMAL_LITERAL: ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?; -OCT_LITERAL: '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?; -FLOAT_LITERAL: (Digits '.' Digits? | '.' Digits) ExponentPart? [fFdD]? - | Digits (ExponentPart [fFdD]? | [fFdD]) - ; -BOOL_LITERAL: 'true' - | 'false' - ; -DATE_TIME_LITERAL: Bound FullDate 'T' FullTime Bound; +DECIMAL_LITERAL : ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?; +OCT_LITERAL : '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?; +FLOAT_LITERAL: + (Digits '.' Digits? | '.' Digits) ExponentPart? [fFdD]? + | Digits (ExponentPart [fFdD]? | [fFdD]) +; +BOOL_LITERAL : 'true' | 'false'; +DATE_TIME_LITERAL : Bound FullDate 'T' FullTime Bound; // Whitespace and comments -WS: [ \t\r\n\u000C]+ -> skip; -LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); -COMMENT: '/*' .*? '*/' -> channel(HIDDEN); +WS : [ \t\r\n\u000C]+ -> skip; +LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); +COMMENT : '/*' .*? '*/' -> channel(HIDDEN); //REGEX Expr -REGEX_EXPR: '/'.*?'/'; - -fragment Bound: '"' | '\''; -fragment FullDate: Year '-' Month '-' Day; -fragment Year: Digit Digit Digit Digit; -fragment Month: [0][0-9]|[1][0-2]; -fragment Day: [0-2][0-9]|[0-3][01]; - -fragment FullTime - : PartialTime TimeOffset; -fragment TimeOffset - : 'Z' | TimeNumOffset; -fragment TimeNumOffset - : '-' [01][0-2] (':' HalfHour)? +REGEX_EXPR: '/' .*? '/'; + +fragment Bound : '"' | '\''; +fragment FullDate : Year '-' Month '-' Day; +fragment Year : Digit Digit Digit Digit; +fragment Month : [0][0-9]| [1][0-2]; +fragment Day : [0-2][0-9]| [0-3][01]; + +fragment FullTime : PartialTime TimeOffset; +fragment TimeOffset : 'Z' | TimeNumOffset; +fragment TimeNumOffset: + '-' [01][0-2] (':' HalfHour)? | '+' [01][0-5] (':' (HalfHour | [4][5]))? - ; -fragment HalfHour: [0][0] | [3][0]; -fragment PartialTime - : [0-2][0-3] ':' Sixty ':' Sixty ('.' [0-9]*)?; -fragment Sixty: [0-5] Digit; -fragment Digit: [0-9]; - +; +fragment HalfHour : [0][0] | [3][0]; +fragment PartialTime : [0-2][0-3] ':' Sixty ':' Sixty ('.' [0-9]*)?; +fragment Sixty : [0-5] Digit; +fragment Digit : [0-9]; -IDENTIFIER: LetterOrDigit+; +IDENTIFIER: LetterOrDigit+; -CHAR_LITERAL: '\'' (~["\\\r\n] | EscapeSequence)* '\''; -STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; +CHAR_LITERAL : '\'' (~["\\\r\n] | EscapeSequence)* '\''; +STRING_LITERAL : '"' (~["\\\r\n] | EscapeSequence)* '"'; // Fragment rules -fragment ExponentPart - : [eE] [+-]? Digits - ; +fragment ExponentPart: [eE] [+-]? Digits; -fragment EscapeSequence - : '\\' [btnfr"'\\] +fragment EscapeSequence: + '\\' [btnfr"'\\] | '\\' ([0-3]? [0-7])? [0-7] | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +; -fragment HexDigits - : HexDigit ((HexDigit | '_')* HexDigit)? - ; +fragment HexDigits: HexDigit ((HexDigit | '_')* HexDigit)?; -fragment HexDigit - : [0-9a-fA-F] - ; +fragment HexDigit: [0-9a-fA-F]; -fragment Digits - : [0-9] ([0-9_]* [0-9])? - ; +fragment Digits: [0-9] ([0-9_]* [0-9])?; -fragment LetterOrDigit - : Letter - | [0-9] - ; +fragment LetterOrDigit: Letter | [0-9]; -fragment Letter - : [a-zA-Z$_] // these are below 0x7F - | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate +fragment Letter: + [a-zA-Z$_] // these are below 0x7F + | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - ; +; \ No newline at end of file diff --git a/cto/CtoParser.g4 b/cto/CtoParser.g4 index a97b27fbaa..6a90715551 100644 --- a/cto/CtoParser.g4 +++ b/cto/CtoParser.g4 @@ -31,9 +31,14 @@ https://hyperledger.github.io/composer/v0.19/reference/cto_language.html */ +// $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 CtoParser; -options { tokenVocab=CtoLexer; } +options { + tokenVocab = CtoLexer; +} modelUnit : namespaceDeclaration importDeclaration* typeDeclaration* EOF @@ -49,7 +54,7 @@ importDeclaration typeDeclaration : assetDeclaration - | conceptDeclaration + | conceptDeclaration | enumDeclaration | participantDeclaration | transactionDeclaration @@ -62,49 +67,45 @@ classModifier ; assetDeclaration - : classModifier* - ASSET IDENTIFIER - extendsOrIdentified - classBody + : classModifier* ASSET IDENTIFIER extendsOrIdentified classBody ; conceptDeclaration - : classModifier* - CONCEPT IDENTIFIER - (EXTENDS IDENTIFIER)? - classBody + : classModifier* CONCEPT IDENTIFIER (EXTENDS IDENTIFIER)? classBody ; enumDeclaration - : ENUM IDENTIFIER '{' enumConstant* '}'; + : ENUM IDENTIFIER '{' enumConstant* '}' + ; enumConstant - : VAR IDENTIFIER; + : VAR IDENTIFIER + ; eventDeclaration - : EVENT IDENTIFIER - classBody + : EVENT IDENTIFIER classBody ; participantDeclaration - : classModifier* - PARTICIPANT IDENTIFIER - extendsOrIdentified - classBody + : classModifier* PARTICIPANT IDENTIFIER extendsOrIdentified classBody ; transactionDeclaration - : classModifier* - TRANSACTION IDENTIFIER - classBody + : classModifier* TRANSACTION IDENTIFIER classBody ; -extendsOrIdentified: EXTENDS IDENTIFIER | identified; +extendsOrIdentified + : EXTENDS IDENTIFIER + | identified + ; -identified: IDENTIFIED IDENTIFIER; +identified + : IDENTIFIED IDENTIFIER + ; classBody - : '{' classBodyDeclaration* '}'; + : '{' classBodyDeclaration* '}' + ; classBodyDeclaration : ';' @@ -117,13 +118,16 @@ fieldDeclaration | numericField identifier defaultNumber? rangeValidation? OPTIONAL? | dateField identifier defaultDate? OPTIONAL? | identifierField identifier - | reference identifier; + | reference identifier + ; identifierField - : VAR IDENTIFIER square*; + : VAR IDENTIFIER square* + ; numericField - : VAR numericPrimitive square*; + : VAR numericPrimitive square* + ; numericPrimitive : DOUBLE @@ -132,44 +136,60 @@ numericPrimitive ; booleanField - : VAR BOOLEAN square*; + : VAR BOOLEAN square* + ; dateField - : VAR DATE_TIME square*; + : VAR DATE_TIME square* + ; defaultDate - : DEFAULT ASSIGN DATE_TIME_LITERAL; + : DEFAULT ASSIGN DATE_TIME_LITERAL + ; regexDeclaration - : REGEX ASSIGN REGEX_EXPR; + : REGEX ASSIGN REGEX_EXPR + ; stringField - : VAR STRING square*; + : VAR STRING square* + ; reference - : REF IDENTIFIER square*; + : REF IDENTIFIER square* + ; qualifiedName - : IDENTIFIER ('.' IDENTIFIER)*; + : IDENTIFIER ('.' IDENTIFIER)* + ; rangeValidation - : RANGE ASSIGN rangeDeclaration; + : RANGE ASSIGN rangeDeclaration + ; rangeDeclaration : '[' numberLiteral ',' ']' | '[' ',' numberLiteral ']' - | '[' numberLiteral ',' numberLiteral ']'; + | '[' numberLiteral ',' numberLiteral ']' + ; defaultBoolean - : DEFAULT ASSIGN BOOL_LITERAL; + : DEFAULT ASSIGN BOOL_LITERAL + ; defaultString - : DEFAULT ASSIGN stringLiteral; + : DEFAULT ASSIGN stringLiteral + ; defaultNumber - : DEFAULT ASSIGN numberLiteral; + : DEFAULT ASSIGN numberLiteral + ; -identifier: IDENTIFIER | ASSET | PARTICIPANT; +identifier + : IDENTIFIER + | ASSET + | PARTICIPANT + ; literal : numberLiteral @@ -179,7 +199,8 @@ literal numberLiteral : integerLiteral - | floatLiteral; + | floatLiteral + ; stringLiteral : CHAR_LITERAL @@ -192,12 +213,17 @@ integerLiteral ; floatLiteral - : FLOAT_LITERAL; + : FLOAT_LITERAL + ; decorator - : AT qualifiedName ('(' elementValuePair ')')?; + : AT qualifiedName ('(' elementValuePair ')')? + ; elementValuePair - : literal (',' literal)*; + : literal (',' literal)* + ; -square: '[' ']'; \ No newline at end of file +square + : '[' ']' + ; \ No newline at end of file diff --git a/cypher/CypherLexer.g4 b/cypher/CypherLexer.g4 index 70e11017f4..c44c3e9d70 100644 --- a/cypher/CypherLexer.g4 +++ b/cypher/CypherLexer.g4 @@ -25,139 +25,140 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -lexer grammar CypherLexer; -channels { COMMENTS } -options { caseInsensitive=true; } - -ASSIGN : '='; -ADD_ASSIGN : '+='; -LE : '<='; -GE : '>='; -GT : '>'; -LT : '<'; -NOT_EQUAL : '<>'; -RANGE : '..'; -SEMI : ';'; -DOT : '.'; -COMMA : ','; -LPAREN : '('; -RPAREN : ')'; -LBRACE : '{'; -RBRACE : '}'; -LBRACK : '['; -RBRACK : ']'; -SUB : '-'; -PLUS : '+'; -DIV : '/'; -MOD : '%'; -CARET : '^'; -MULT : '*'; -ESC : '`'; -COLON : ':'; -STICK : '|'; -DOLLAR : '$'; - - - -CALL : 'CALL'; -YIELD : 'YIELD'; -FILTER : 'FILTER'; -EXTRACT : 'EXTRACT'; -COUNT : 'COUNT'; -ANY : 'ANY' ; -NONE : 'NONE'; -SINGLE : 'SINGLE'; -ALL : 'ALL'; -ASC : 'ASC'; -ASCENDING : 'ASCENDING'; -BY : 'BY' ; -CREATE : 'CREATE'; -DELETE : 'DELETE'; -DESC : 'DESC'; -DESCENDING : 'DESCENDING'; -DETACH : 'DETACH'; -EXISTS : 'EXISTS'; -LIMIT : 'LIMIT'; -MATCH : 'MATCH'; -MERGE : 'MERGE'; -ON : 'ON'; -OPTIONAL : 'OPTIONAL'; -ORDER : 'ORDER'; -REMOVE : 'REMOVE'; -RETURN : 'RETURN'; -SET : 'SET'; -SKIP_W : 'SKIP'; -WHERE : 'WHERE'; -WITH : 'WITH'; -UNION : 'UNION'; -UNWIND : 'UNWIND'; -AND : 'AND'; -AS : 'AS'; -CONTAINS : 'CONTAINS'; -DISTINCT : 'DISTINCT'; -ENDS : 'ENDS'; -IN : 'IN'; -IS : 'IS'; -NOT : 'NOT'; -OR : 'OR'; -STARTS : 'STARTS'; -XOR : 'XOR'; -FALSE : 'FALSE'; -TRUE : 'TRUE'; -NULL_W : 'NULL'; -CONSTRAINT : 'CONSTRAINT'; -DO : 'DO'; -FOR : 'FOR'; -REQUIRE : 'REQUIRE'; -UNIQUE : 'UNIQUE'; -CASE : 'CASE'; -WHEN : 'WHEN'; -THEN : 'THEN'; -ELSE : 'ELSE'; -END : 'END'; -MANDATORY : 'MANDATORY'; -SCALAR : 'SCALAR'; -OF : 'OF'; -ADD : 'ADD'; -DROP : 'DROP'; - -ID : LetterOrDigit+; - -ESC_LITERAL : '`' .*? '`'; -CHAR_LITERAL : '\'' (~['\\\r\n] | EscapeSequence)? '\''; -STRING_LITERAL : '"' (~["\\\r\n] | EscapeSequence)* '"'; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true - -DIGIT : SUB? (HexDigit | OctalDigit | Digits | FLOAT); -FLOAT - : (Digits '.' Digits | '.' Digits) ExponentPart? [fd]? - | Digits (ExponentPart [fd]? | [fd]) - ; - - -WS : [ \t\r\n\u000C]+ -> channel(HIDDEN); -COMMENT : '/*' .*? '*/' -> channel(COMMENTS); -LINE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS); -ERRCHAR : . -> channel(HIDDEN); - -fragment EscapeSequence - : '\\' [btnfr"'\\] +lexer grammar CypherLexer; +channels { + COMMENTS +} +options { + caseInsensitive = true; +} + +ASSIGN : '='; +ADD_ASSIGN : '+='; +LE : '<='; +GE : '>='; +GT : '>'; +LT : '<'; +NOT_EQUAL : '<>'; +RANGE : '..'; +SEMI : ';'; +DOT : '.'; +COMMA : ','; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SUB : '-'; +PLUS : '+'; +DIV : '/'; +MOD : '%'; +CARET : '^'; +MULT : '*'; +ESC : '`'; +COLON : ':'; +STICK : '|'; +DOLLAR : '$'; + +CALL : 'CALL'; +YIELD : 'YIELD'; +FILTER : 'FILTER'; +EXTRACT : 'EXTRACT'; +COUNT : 'COUNT'; +ANY : 'ANY'; +NONE : 'NONE'; +SINGLE : 'SINGLE'; +ALL : 'ALL'; +ASC : 'ASC'; +ASCENDING : 'ASCENDING'; +BY : 'BY'; +CREATE : 'CREATE'; +DELETE : 'DELETE'; +DESC : 'DESC'; +DESCENDING : 'DESCENDING'; +DETACH : 'DETACH'; +EXISTS : 'EXISTS'; +LIMIT : 'LIMIT'; +MATCH : 'MATCH'; +MERGE : 'MERGE'; +ON : 'ON'; +OPTIONAL : 'OPTIONAL'; +ORDER : 'ORDER'; +REMOVE : 'REMOVE'; +RETURN : 'RETURN'; +SET : 'SET'; +SKIP_W : 'SKIP'; +WHERE : 'WHERE'; +WITH : 'WITH'; +UNION : 'UNION'; +UNWIND : 'UNWIND'; +AND : 'AND'; +AS : 'AS'; +CONTAINS : 'CONTAINS'; +DISTINCT : 'DISTINCT'; +ENDS : 'ENDS'; +IN : 'IN'; +IS : 'IS'; +NOT : 'NOT'; +OR : 'OR'; +STARTS : 'STARTS'; +XOR : 'XOR'; +FALSE : 'FALSE'; +TRUE : 'TRUE'; +NULL_W : 'NULL'; +CONSTRAINT : 'CONSTRAINT'; +DO : 'DO'; +FOR : 'FOR'; +REQUIRE : 'REQUIRE'; +UNIQUE : 'UNIQUE'; +CASE : 'CASE'; +WHEN : 'WHEN'; +THEN : 'THEN'; +ELSE : 'ELSE'; +END : 'END'; +MANDATORY : 'MANDATORY'; +SCALAR : 'SCALAR'; +OF : 'OF'; +ADD : 'ADD'; +DROP : 'DROP'; + +ID: LetterOrDigit+; + +ESC_LITERAL : '`' .*? '`'; +CHAR_LITERAL : '\'' (~['\\\r\n] | EscapeSequence)? '\''; +STRING_LITERAL : '"' (~["\\\r\n] | EscapeSequence)* '"'; + +DIGIT : SUB? (HexDigit | OctalDigit | Digits | FLOAT); +FLOAT : (Digits '.' Digits | '.' Digits) ExponentPart? [fd]? | Digits (ExponentPart [fd]? | [fd]); + +WS : [ \t\r\n\u000C]+ -> channel(HIDDEN); +COMMENT : '/*' .*? '*/' -> channel(COMMENTS); +LINE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS); +ERRCHAR : . -> channel(HIDDEN); + +fragment EscapeSequence: + '\\' [btnfr"'\\] | '\\' ([0-3]? [0-7])? [0-7] | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; - +; -fragment ExponentPart : [e] [+-]? Digits; +fragment ExponentPart: [e] [+-]? Digits; -fragment HexDigits : '0x' HexDigit ((HexDigit | '_')* HexDigit)?; -fragment HexDigit : [0-9a-f] ; -fragment OctalDigit : '0' Digits; -fragment Digits : [1-9] ([0-9_]* [0-9])? ; +fragment HexDigits : '0x' HexDigit ((HexDigit | '_')* HexDigit)?; +fragment HexDigit : [0-9a-f]; +fragment OctalDigit : '0' Digits; +fragment Digits : [1-9] ([0-9_]* [0-9])?; -fragment LetterOrDigit : Letter | [0-9]; +fragment LetterOrDigit: Letter | [0-9]; -Letter : - [a-z_] - | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate - | [\uD800-\uDBFF] [\uDC00-\uDFFF]; // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF +Letter: + [a-z_] + | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate + | [\uD800-\uDBFF] [\uDC00-\uDFFF] +; // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF \ No newline at end of file diff --git a/cypher/CypherParser.g4 b/cypher/CypherParser.g4 index 3cd55ec87f..d6a6913e9d 100644 --- a/cypher/CypherParser.g4 +++ b/cypher/CypherParser.g4 @@ -25,9 +25,15 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $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 CypherParser; -options { tokenVocab=CypherLexer; } +options { + tokenVocab = CypherLexer; +} script : query SEMI? EOF @@ -49,7 +55,7 @@ singleQuery ; standaloneCall - : CALL invocationName parenExpressionChain? (YIELD (MULT | yieldItems ))? + : CALL invocationName parenExpressionChain? (YIELD (MULT | yieldItems))? ; returnSt @@ -96,7 +102,6 @@ multiPartQ : readingStatement* (updatingStatement* withSt)+ singlePartQ ; - matchSt : OPTIONAL? MATCH patternWhere ; @@ -123,7 +128,6 @@ deleteSt : DETACH? DELETE expressionChain ; - removeSt : REMOVE removeItem (COMMA removeItem)* ; @@ -144,6 +148,7 @@ parenExpressionChain yieldItems : yieldItem (COMMA yieldItem)* where? ; + yieldItem : (symbol AS)? symbol ; @@ -185,6 +190,7 @@ where pattern : patternPart (COMMA patternPart)* ; + expression : xorExpression (OR xorExpression)* ; @@ -202,7 +208,7 @@ notExpression ; comparisonExpression - : addSubExpression ( comparisonSigns addSubExpression)* + : addSubExpression (comparisonSigns addSubExpression)* ; comparisonSigns @@ -264,6 +270,7 @@ propertyExpression patternPart : (symbol ASSIGN)? patternElem ; + patternElem : nodePattern patternElemChain* | LPAREN patternElem RPAREN @@ -331,7 +338,7 @@ functionInvocation ; parenthesizedExpression - : LPAREN expression RPAREN + : LPAREN expression RPAREN ; filterWith @@ -358,7 +365,6 @@ countAll : COUNT LPAREN MULT RPAREN ; - expressionChain : expression (COMMA expression)* ; @@ -383,7 +389,7 @@ literal ; rangeLit - : MULT numLit? (RANGE numLit?)? + : MULT numLit? (RANGE numLit?)? ; boolLit @@ -394,12 +400,15 @@ boolLit numLit : DIGIT ; + stringLit : STRING_LITERAL ; + charLit : CHAR_LITERAL ; + listLit : LBRACK expressionChain? RBRACK ; @@ -429,7 +438,6 @@ symbol | SINGLE ; - reservedWord : ALL | ASC diff --git a/dart2/Dart2Lexer.g4 b/dart2/Dart2Lexer.g4 index 704ac85c4d..0d5d1f6be5 100644 --- a/dart2/Dart2Lexer.g4 +++ b/dart2/Dart2Lexer.g4 @@ -23,157 +23,220 @@ * https://github.com/dart-lang/sdk/tree/main/sdk/lib * A copy of the SDK is provided in the examples for regression testing. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Dart2Lexer; -options { superClass=Dart2LexerBase; } +options { + superClass = Dart2LexerBase; +} // Insert here @header for C++ lexer. -A: '&'; -AA: '&&'; -AE: '&='; -AT: '@'; -C: ','; -CB: ']'; -CBC: '}'; -CIR: '^'; -CIRE: '^='; -CO: ':'; -CP: ')'; -D: '.'; -DD: '..'; -DDD: '...'; -DDDQ: '...?'; -EE: '=='; -EG: '=>'; -EQ: '='; -GT: '>'; -LT: '<'; -LTE: '<='; -LTLT: '<<'; -LTLTE: '<<='; -ME: '-='; -MINUS: '-'; -MM: '--'; -NE: '!='; -NOT: '!'; -OB: '['; -OBC: '{'; -OP: '('; -P: '|'; -PC: '%'; -PE: '%='; -PL: '+'; -PLE: '+='; -PLPL: '++'; -PO: '#'; -POE: '|='; -PP: '||'; -QU: '?'; -QUD: '?.'; -QUDD: '?..'; -QUQU: '??'; -QUQUEQ: '??='; -SC: ';'; -SE: '/='; -SL: '/'; -SQS: '~/'; -SQSE: '~/='; -SQUIG: '~'; -ST: '*'; -STE: '*='; -ABSTRACT_:'abstract'; -AS_:'as'; -ASSERT_:'assert'; -ASYNC_:'async'; -AWAIT_:'await'; -BREAK_:'break'; -CASE_:'case'; -CATCH_:'catch'; -CLASS_:'class'; -CONST_:'const'; -CONTINUE_:'continue'; -COVARIANT_:'covariant'; -DEFAULT_:'default'; -DEFERRED_:'deferred'; -DO_:'do'; -DYNAMIC_:'dynamic'; -ELSE_:'else'; -ENUM_:'enum'; -EXPORT_:'export'; -EXTENDS_:'extends'; -EXTENSION_:'extension'; -EXTERNAL_:'external'; -FACTORY_:'factory'; -FALSE_:'false'; -FINAL_:'final'; -FINALLY_:'finally'; -FOR_:'for'; -FUNCTION_:'Function'; -GET_:'get'; -GTILDE_:'gtilde'; -HIDE_:'hide'; -IF_:'if'; -IMPLEMENTS_:'implements'; -IMPORT_:'import'; -IN_:'in'; -INTERFACE_:'interface'; -IS_:'is'; -LATE_:'late'; -LET_:'let'; -LIBRARY_:'library'; -MIXIN_:'mixin'; -NATIVE_:'native'; -NEW_:'new'; -NULL_:'null'; -OF_:'of'; -ON_:'on'; -OPERATOR_:'operator'; -PART_:'part'; -REQUIRED_:'required'; -RETHROW_:'rethrow'; -RETURN_:'return'; -SET_:'set'; -SHOW_:'show'; -STATIC_:'static'; -SUPER_:'super'; -SWITCH_:'switch'; -SYNC_:'sync'; -THIS_:'this'; -THROW_:'throw'; -TRUE_:'true'; -TRY_:'try'; -TYPEDEF_:'typedef'; -VAR_:'var'; -VOID_:'void'; -WHILE_:'while'; -WITH_:'with'; -YIELD_:'yield'; -NUMBER : DIGIT+ ( '.' DIGIT+ )? EXPONENT? | '.' DIGIT+ EXPONENT? ; -HEX_NUMBER : '0x' HEX_DIGIT+ | '0X' HEX_DIGIT+ ; -SingleLineString : StringDQ | StringSQ | 'r\'' ~('\'' | '\n' | '\r')* '\'' | 'r"' ~('"' | '\n' | '\r')* '"' ; -MultiLineString : '"""' StringContentTDQ*? '"""' | '\'\'\'' StringContentTSQ*? '\'\'\'' | 'r"""' (~'"' | '"' ~'"' | '""' ~'"')* '"""' | 'r\'\'\'' (~'\'' | '\'' ~'\'' | '\'\'' ~'\'')* '\'\'\'' ; -IDENTIFIER : IDENTIFIER_START IDENTIFIER_PART* ; -WHITESPACE : ( '\t' | ' ' | NEWLINE )+ -> skip; -SINGLE_LINE_COMMENT : '//' ~[\r\n]* -> skip ; -MULTI_LINE_COMMENT : '/*' ( MULTI_LINE_COMMENT | . )*? '*/' -> skip ; -fragment EXPONENT : ( 'e' | 'E' ) ( '+' | '-' )? DIGIT+ ; -fragment HEX_DIGIT : 'a' .. 'f' | 'A' .. 'F' | DIGIT ; -fragment StringDQ : '"' StringContentDQ*? '"' ; -fragment StringContentDQ : ~('\\' | '"' | '\n' | '\r' | '$') | '\\' ~('\n' | '\r') | StringDQ | '${' StringContentDQ*? '}' | '$' { this.CheckNotOpenBrace() }? ; -fragment StringSQ : '\'' StringContentSQ*? '\'' ; -fragment StringContentSQ : ~('\\' | '\'' | '\n' | '\r' | '$') | '\\' ~('\n' | '\r') | StringSQ | '${' StringContentSQ*? '}' | '$' { this.CheckNotOpenBrace() }? ; -fragment StringContentTDQ : ~('\\' | '"') | '"' ~'"' | '""' ~'"' ; -fragment StringContentTSQ : '\'' ~'\'' | '\'\'' ~'\'' | . ; -fragment ESCAPE_SEQUENCE : '\n' | '\r' | '\\f' | '\\b' | '\t' | '\\v' | '\\x' HEX_DIGIT HEX_DIGIT | '\\u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT | '\\u{' HEX_DIGIT_SEQUENCE '}' ; -fragment HEX_DIGIT_SEQUENCE : HEX_DIGIT HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? ; -fragment NEWLINE : '\n' | '\r' | '\r\n' ; -fragment BUILT_IN_IDENTIFIER : 'abstract' | 'as' | 'covariant' | 'deferred' | 'dynamic' | 'export' | 'external' | 'extension' | 'factory' | 'Function' | 'get' | 'implements' | 'import' | 'interface' | 'late' | 'library' | 'mixin' | 'operator' | 'part' | 'required' | 'set' | 'static' | 'typedef' ; -fragment OTHER_IDENTIFIER : 'async' | 'hide' | 'of' | 'on' | 'show' | 'sync' | 'await' | 'yield' ; -fragment IDENTIFIER_NO_DOLLAR : IDENTIFIER_START_NO_DOLLAR IDENTIFIER_PART_NO_DOLLAR* ; -fragment IDENTIFIER_START_NO_DOLLAR : LETTER | '_' ; -fragment IDENTIFIER_PART_NO_DOLLAR : IDENTIFIER_START_NO_DOLLAR | DIGIT ; -fragment IDENTIFIER_START : IDENTIFIER_START_NO_DOLLAR | '$' ; -fragment IDENTIFIER_PART : IDENTIFIER_START | DIGIT ; -fragment LETTER : 'a' .. 'z' | 'A' .. 'Z' ; -fragment DIGIT : '0' .. '9' ; +A : '&'; +AA : '&&'; +AE : '&='; +AT : '@'; +C : ','; +CB : ']'; +CBC : '}'; +CIR : '^'; +CIRE : '^='; +CO : ':'; +CP : ')'; +D : '.'; +DD : '..'; +DDD : '...'; +DDDQ : '...?'; +EE : '=='; +EG : '=>'; +EQ : '='; +GT : '>'; +LT : '<'; +LTE : '<='; +LTLT : '<<'; +LTLTE : '<<='; +ME : '-='; +MINUS : '-'; +MM : '--'; +NE : '!='; +NOT : '!'; +OB : '['; +OBC : '{'; +OP : '('; +P : '|'; +PC : '%'; +PE : '%='; +PL : '+'; +PLE : '+='; +PLPL : '++'; +PO : '#'; +POE : '|='; +PP : '||'; +QU : '?'; +QUD : '?.'; +QUDD : '?..'; +QUQU : '??'; +QUQUEQ : '??='; +SC : ';'; +SE : '/='; +SL : '/'; +SQS : '~/'; +SQSE : '~/='; +SQUIG : '~'; +ST : '*'; +STE : '*='; +ABSTRACT_ : 'abstract'; +AS_ : 'as'; +ASSERT_ : 'assert'; +ASYNC_ : 'async'; +AWAIT_ : 'await'; +BREAK_ : 'break'; +CASE_ : 'case'; +CATCH_ : 'catch'; +CLASS_ : 'class'; +CONST_ : 'const'; +CONTINUE_ : 'continue'; +COVARIANT_ : 'covariant'; +DEFAULT_ : 'default'; +DEFERRED_ : 'deferred'; +DO_ : 'do'; +DYNAMIC_ : 'dynamic'; +ELSE_ : 'else'; +ENUM_ : 'enum'; +EXPORT_ : 'export'; +EXTENDS_ : 'extends'; +EXTENSION_ : 'extension'; +EXTERNAL_ : 'external'; +FACTORY_ : 'factory'; +FALSE_ : 'false'; +FINAL_ : 'final'; +FINALLY_ : 'finally'; +FOR_ : 'for'; +FUNCTION_ : 'Function'; +GET_ : 'get'; +GTILDE_ : 'gtilde'; +HIDE_ : 'hide'; +IF_ : 'if'; +IMPLEMENTS_ : 'implements'; +IMPORT_ : 'import'; +IN_ : 'in'; +INTERFACE_ : 'interface'; +IS_ : 'is'; +LATE_ : 'late'; +LET_ : 'let'; +LIBRARY_ : 'library'; +MIXIN_ : 'mixin'; +NATIVE_ : 'native'; +NEW_ : 'new'; +NULL_ : 'null'; +OF_ : 'of'; +ON_ : 'on'; +OPERATOR_ : 'operator'; +PART_ : 'part'; +REQUIRED_ : 'required'; +RETHROW_ : 'rethrow'; +RETURN_ : 'return'; +SET_ : 'set'; +SHOW_ : 'show'; +STATIC_ : 'static'; +SUPER_ : 'super'; +SWITCH_ : 'switch'; +SYNC_ : 'sync'; +THIS_ : 'this'; +THROW_ : 'throw'; +TRUE_ : 'true'; +TRY_ : 'try'; +TYPEDEF_ : 'typedef'; +VAR_ : 'var'; +VOID_ : 'void'; +WHILE_ : 'while'; +WITH_ : 'with'; +YIELD_ : 'yield'; +NUMBER : DIGIT+ ( '.' DIGIT+)? EXPONENT? | '.' DIGIT+ EXPONENT?; +HEX_NUMBER : '0x' HEX_DIGIT+ | '0X' HEX_DIGIT+; +SingleLineString: + StringDQ + | StringSQ + | 'r\'' ~('\'' | '\n' | '\r')* '\'' + | 'r"' ~('"' | '\n' | '\r')* '"' +; +MultiLineString: + '"""' StringContentTDQ*? '"""' + | '\'\'\'' StringContentTSQ*? '\'\'\'' + | 'r"""' (~'"' | '"' ~'"' | '""' ~'"')* '"""' + | 'r\'\'\'' (~'\'' | '\'' ~'\'' | '\'\'' ~'\'')* '\'\'\'' +; +IDENTIFIER : IDENTIFIER_START IDENTIFIER_PART*; +WHITESPACE : ( '\t' | ' ' | NEWLINE)+ -> skip; +SINGLE_LINE_COMMENT : '//' ~[\r\n]* -> skip; +MULTI_LINE_COMMENT : '/*' ( MULTI_LINE_COMMENT | .)*? '*/' -> skip; +fragment EXPONENT : ( 'e' | 'E') ( '+' | '-')? DIGIT+; +fragment HEX_DIGIT : 'a' .. 'f' | 'A' .. 'F' | DIGIT; +fragment StringDQ : '"' StringContentDQ*? '"'; +fragment StringContentDQ: + ~('\\' | '"' | '\n' | '\r' | '$') + | '\\' ~('\n' | '\r') + | StringDQ + | '${' StringContentDQ*? '}' + | '$' { this.CheckNotOpenBrace() }? +; +fragment StringSQ: '\'' StringContentSQ*? '\''; +fragment StringContentSQ: + ~('\\' | '\'' | '\n' | '\r' | '$') + | '\\' ~('\n' | '\r') + | StringSQ + | '${' StringContentSQ*? '}' + | '$' { this.CheckNotOpenBrace() }? +; +fragment StringContentTDQ : ~('\\' | '"') | '"' ~'"' | '""' ~'"'; +fragment StringContentTSQ : '\'' ~'\'' | '\'\'' ~'\'' | .; +fragment ESCAPE_SEQUENCE: + '\n' + | '\r' + | '\\f' + | '\\b' + | '\t' + | '\\v' + | '\\x' HEX_DIGIT HEX_DIGIT + | '\\u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT + | '\\u{' HEX_DIGIT_SEQUENCE '}' +; +fragment HEX_DIGIT_SEQUENCE : HEX_DIGIT HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT?; +fragment NEWLINE : '\n' | '\r' | '\r\n'; +fragment BUILT_IN_IDENTIFIER: + 'abstract' + | 'as' + | 'covariant' + | 'deferred' + | 'dynamic' + | 'export' + | 'external' + | 'extension' + | 'factory' + | 'Function' + | 'get' + | 'implements' + | 'import' + | 'interface' + | 'late' + | 'library' + | 'mixin' + | 'operator' + | 'part' + | 'required' + | 'set' + | 'static' + | 'typedef' +; +fragment OTHER_IDENTIFIER : 'async' | 'hide' | 'of' | 'on' | 'show' | 'sync' | 'await' | 'yield'; +fragment IDENTIFIER_NO_DOLLAR : IDENTIFIER_START_NO_DOLLAR IDENTIFIER_PART_NO_DOLLAR*; +fragment IDENTIFIER_START_NO_DOLLAR : LETTER | '_'; +fragment IDENTIFIER_PART_NO_DOLLAR : IDENTIFIER_START_NO_DOLLAR | DIGIT; +fragment IDENTIFIER_START : IDENTIFIER_START_NO_DOLLAR | '$'; +fragment IDENTIFIER_PART : IDENTIFIER_START | DIGIT; +fragment LETTER : 'a' .. 'z' | 'A' .. 'Z'; +fragment DIGIT : '0' .. '9'; \ No newline at end of file diff --git a/dart2/Dart2Parser.g4 b/dart2/Dart2Parser.g4 index 2f6c3e2ef7..d90d5bc23b 100644 --- a/dart2/Dart2Parser.g4 +++ b/dart2/Dart2Parser.g4 @@ -23,215 +23,1103 @@ * https://github.com/dart-lang/sdk/tree/main/sdk/lib * A copy of the SDK is provided in the examples for regression testing. */ + +// $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 Dart2Parser; -options { tokenVocab=Dart2Lexer; } - -additiveExpression : multiplicativeExpression ( additiveOperator multiplicativeExpression )* | SUPER_ ( additiveOperator multiplicativeExpression )+ ; -additiveOperator : PL | MINUS ; -argumentList : namedArgument ( C namedArgument )* | expressionList ( C namedArgument )* ; -argumentPart : typeArguments? arguments ; -arguments : OP ( argumentList C? )? CP ; -asOperator : AS_ ; -assertion : ASSERT_ OP expr ( C expr )? C? CP ; -assertStatement : assertion SC ; -assignableExpression : primary assignableSelectorPart | SUPER_ unconditionalAssignableSelector | identifier ; -assignableSelector : unconditionalAssignableSelector | QUD identifier | QU OB expr CB ; -assignableSelectorPart : selector* assignableSelector ; -assignmentOperator : EQ | compoundAssignmentOperator ; -awaitExpression : AWAIT_ unaryExpression ; -binaryOperator : multiplicativeOperator | additiveOperator | shiftOperator | relationalOperator | EE | bitwiseOperator ; -bitwiseAndExpression : shiftExpression ( A shiftExpression )* | SUPER_ ( A shiftExpression )+ ; -bitwiseOperator : A | CIR | P ; -bitwiseOrExpression : bitwiseXorExpression ( P bitwiseXorExpression )* | SUPER_ ( P bitwiseXorExpression )+ ; -bitwiseXorExpression : bitwiseAndExpression ( CIR bitwiseAndExpression )* | SUPER_ ( CIR bitwiseAndExpression )+ ; -block : OBC statements CBC ; -booleanLiteral : TRUE_ | FALSE_ ; -breakStatement : BREAK_ identifier? SC ; -cascade : cascade DD cascadeSection | conditionalExpression ( QUDD | DD ) cascadeSection ; -cascadeAssignment : assignmentOperator expressionWithoutCascade ; -cascadeSection : cascadeSelector cascadeSectionTail ; -cascadeSectionTail : cascadeAssignment | selector* ( assignableSelector cascadeAssignment )? ; -cascadeSelector : OB expr CB | identifier ; -catchPart : CATCH_ OP identifier ( C identifier )? CP ; -classDeclaration : ABSTRACT_? CLASS_ typeIdentifier typeParameters? superclass? interfaces? OBC ( metadata classMemberDeclaration )* CBC | ABSTRACT_? CLASS_ mixinApplicationClass ; -classMemberDeclaration : declaration SC | methodSignature functionBody ; -combinator : SHOW_ identifierList | HIDE_ identifierList ; -compilationUnit: (libraryDeclaration | partDeclaration | expr | statement) EOF ; -compoundAssignmentOperator : STE | SE | SQSE | PE | PLE | ME | LTLTE | GT GT GT EQ | GT GT EQ | AE | CIRE | POE | QUQUEQ ; -conditionalExpression : ifNullExpression ( QU expressionWithoutCascade CO expressionWithoutCascade )? ; -configurableUri : uri configurationUri* ; -configurationUri : IF_ OP uriTest CP uri ; -constantConstructorSignature : CONST_ constructorName formalParameterList ; -constObjectExpression : CONST_ constructorDesignation arguments ; -constructorDesignation : typeIdentifier | qualifiedName | typeName typeArguments ( D identifier )? ; -constructorInvocation : typeName typeArguments D identifier arguments ; -constructorName : typeIdentifier ( D identifier )? ; -constructorSignature : constructorName formalParameterList ; -continueStatement : CONTINUE_ identifier? SC ; -declaration :ABSTRACT_? ( EXTERNAL_ factoryConstructorSignature | EXTERNAL_ constantConstructorSignature | EXTERNAL_ constructorSignature | ( EXTERNAL_ STATIC_? )? getterSignature | ( EXTERNAL_ STATIC_? )? setterSignature | ( EXTERNAL_ STATIC_? )? functionSignature | EXTERNAL_? operatorSignature | STATIC_ CONST_ type? staticFinalDeclarationList | STATIC_ FINAL_ type? staticFinalDeclarationList | STATIC_ LATE_ FINAL_ type? initializedIdentifierList | STATIC_ LATE_? varOrType initializedIdentifierList | COVARIANT_ LATE_ FINAL_ type? identifierList | COVARIANT_ LATE_? varOrType initializedIdentifierList | LATE_? FINAL_ type? initializedIdentifierList | LATE_? varOrType initializedIdentifierList | redirectingFactoryConstructorSignature | constantConstructorSignature ( redirection | initializers )? | constructorSignature ( redirection | initializers )? ); -declaredIdentifier : COVARIANT_? finalConstVarOrType identifier ; -defaultCase : label* DEFAULT_ CO statements ; -defaultFormalParameter : normalFormalParameter ( EQ expr )? ; -defaultNamedParameter : metadata REQUIRED_? normalFormalParameterNoMetadata ( ( EQ | CO ) expr )? ; -doStatement : DO_ statement WHILE_ OP expr CP SC ; -dottedIdentifierList : identifier ( D identifier )* ; -element : expressionElement | mapElement | spreadElement | ifElement | forElement ; -elements : element ( C element )* C? ; -enumEntry : metadata identifier ; -enumType : ENUM_ identifier OBC enumEntry ( C enumEntry )* C? CBC ; -equalityExpression : relationalExpression ( equalityOperator relationalExpression )? | SUPER_ equalityOperator relationalExpression ; -equalityOperator : EE | NE ; -expr : assignableExpression assignmentOperator expr | conditionalExpression | cascade | throwExpression ; -expressionElement : expr ; -expressionList : expr ( C expr )* ; -expressionStatement : expr? SC ; -expressionWithoutCascade : assignableExpression assignmentOperator expressionWithoutCascade | conditionalExpression | throwExpressionWithoutCascade ; -extensionDeclaration : EXTENSION_ identifier? typeParameters? ON_ type OBC ( metadata classMemberDeclaration )* CBC ; -factoryConstructorSignature : CONST_? FACTORY_ constructorName formalParameterList ; -fieldFormalParameter : finalConstVarOrType? THIS_ D identifier ( formalParameterPart QU? )? ; -fieldInitializer : ( THIS_ D )? identifier EQ initializerExpression ; -finalConstVarOrType : LATE_? FINAL_ type? | CONST_ type? | LATE_? varOrType ; -finallyPart : FINALLY_ block ; -forElement : AWAIT_? FOR_ OP forLoopParts CP element ; -forInitializerStatement : localVariableDeclaration | expr? SC ; -forLoopParts : forInitializerStatement expr? SC expressionList? | metadata declaredIdentifier IN_ expr | identifier IN_ expr ; -formalParameterList : OP CP | OP normalFormalParameters C? CP | OP normalFormalParameters C optionalOrNamedFormalParameters CP | OP optionalOrNamedFormalParameters CP ; -formalParameterPart : typeParameters? formalParameterList ; -forStatement : AWAIT_? FOR_ OP forLoopParts CP statement ; -functionBody :NATIVE_ stringLiteral? SC | ASYNC_? EG expr SC | ( ASYNC_ ST? | SYNC_ ST )? block ; -functionExpression : formalParameterPart functionExpressionBody ; -functionExpressionBody : ASYNC_? EG expr | ( ASYNC_ ST? | SYNC_ ST )? block ; -functionFormalParameter : COVARIANT_? type? identifier formalParameterPart QU? ; -functionPrefix : type? identifier ; -functionSignature : type? identifier formalParameterPart ; -functionType : functionTypeTails | typeNotFunction functionTypeTails ; -functionTypeAlias : functionPrefix formalParameterPart SC ; -functionTypeTail : FUNCTION_ typeParameters? parameterTypeList ; -functionTypeTails : functionTypeTail QU? functionTypeTails | functionTypeTail ; -getterSignature : type? GET_ identifier ; -identifier : IDENTIFIER | ABSTRACT_ | AS_ | COVARIANT_ | DEFERRED_ | DYNAMIC_ | EXPORT_ | EXTERNAL_ | EXTENSION_ | FACTORY_ | FUNCTION_ | GET_ | IMPLEMENTS_ | IMPORT_ | INTERFACE_ | LATE_ | LIBRARY_ | MIXIN_ | OPERATOR_ | PART_ | REQUIRED_ | SET_ | STATIC_ | TYPEDEF_ | FUNCTION_ | ASYNC_ | HIDE_ | OF_ | ON_ | SHOW_ | SYNC_ | AWAIT_ | YIELD_ | DYNAMIC_ | NATIVE_ ; -identifierList : identifier ( C identifier )* ; -ifElement : IF_ OP expr CP element ( ELSE_ element )? ; -ifNullExpression : logicalOrExpression ( QUQU logicalOrExpression )* ; -ifStatement : IF_ OP expr CP statement ( ELSE_ statement )? ; -importOrExport : libraryImport | libraryExport ; -importSpecification : IMPORT_ configurableUri ( DEFERRED_? AS_ identifier )? combinator* SC ; -incrementOperator : PLPL | MM ; -initializedIdentifier : identifier ( EQ expr )? ; -initializedIdentifierList : initializedIdentifier ( C initializedIdentifier )* ; -initializedVariableDeclaration : declaredIdentifier ( EQ expr )? ( C initializedIdentifier )* ; -initializerExpression : conditionalExpression | cascade ; -initializerListEntry : SUPER_ arguments | SUPER_ D identifier arguments | fieldInitializer | assertion ; -initializers : CO initializerListEntry ( C initializerListEntry )* ; -interfaces : IMPLEMENTS_ typeNotVoidList ; -isOperator : IS_ NOT? ; -label : identifier CO ; -letExpression : LET_ staticFinalDeclarationList IN_ expr ; -libraryDeclaration : libraryName? importOrExport* partDirective* ( metadata topLevelDeclaration )* ; - -libraryExport : metadata EXPORT_ configurableUri combinator* SC ; -libraryImport : metadata importSpecification ; -libraryName : metadata LIBRARY_ dottedIdentifierList SC ; -listLiteral : CONST_? typeArguments? OB elements? CB ; -literal : nullLiteral | booleanLiteral | numericLiteral | stringLiteral | symbolLiteral | listLiteral | setOrMapLiteral ; -localFunctionDeclaration : metadata functionSignature functionBody ; -localVariableDeclaration : metadata initializedVariableDeclaration SC ; -logicalAndExpression : equalityExpression ( AA equalityExpression )* ; -logicalOrExpression : logicalAndExpression ( PP logicalAndExpression )* ; -mapElement : expr CO expr ; -metadata : ( AT metadatum )* ; -metadatum : identifier | qualifiedName | constructorDesignation arguments ; -methodSignature : constructorSignature initializers? | factoryConstructorSignature | STATIC_? functionSignature | STATIC_? getterSignature | STATIC_? setterSignature | operatorSignature ; -minusOperator : MINUS ; -mixinApplication : typeNotVoid mixins interfaces? ; -mixinApplicationClass : identifier typeParameters? EQ mixinApplication SC ; -mixinDeclaration : MIXIN_ typeIdentifier typeParameters? ( ON_ typeNotVoidList )? interfaces? OBC ( metadata classMemberDeclaration )* CBC ; -mixins : WITH_ typeNotVoidList ; -multilineString : MultiLineString; -multiplicativeExpression : unaryExpression ( multiplicativeOperator unaryExpression )* | SUPER_ ( multiplicativeOperator unaryExpression )+ ; -multiplicativeOperator : ST | SL | PC | SQS ; -namedArgument : label expr ; -namedFormalParameters : OBC defaultNamedParameter ( C defaultNamedParameter )* C? CBC ; -namedParameterType : metadata REQUIRED_? typedIdentifier ; -namedParameterTypes : OBC namedParameterType ( C namedParameterType )* C? CBC ; -negationOperator : NOT ; -newExpression : NEW_ constructorDesignation arguments ; -nonLabelledStatement : block | localVariableDeclaration | forStatement | whileStatement | doStatement | switchStatement | ifStatement | rethrowStatement | tryStatement | breakStatement | continueStatement | returnStatement | yieldStatement | yieldEachStatement | expressionStatement | assertStatement | localFunctionDeclaration ; -normalFormalParameter : metadata normalFormalParameterNoMetadata ; -normalFormalParameterNoMetadata : functionFormalParameter | fieldFormalParameter | simpleFormalParameter ; -normalFormalParameters : normalFormalParameter ( C normalFormalParameter )* ; -normalParameterType : metadata typedIdentifier | metadata type ; -normalParameterTypes : normalParameterType ( C normalParameterType )* ; -nullLiteral : NULL_ ; -numericLiteral : NUMBER | HEX_NUMBER ; -onPart : catchPart block | ON_ typeNotVoid catchPart? block ; -operator : SQUIG | binaryOperator | OB CB | OB CB EQ ; -operatorSignature : type? OPERATOR_ operator formalParameterList ; -optionalOrNamedFormalParameters : optionalPositionalFormalParameters | namedFormalParameters ; -optionalParameterTypes : optionalPositionalParameterTypes | namedParameterTypes ; -optionalPositionalFormalParameters : OB defaultFormalParameter ( C defaultFormalParameter )* C? CB ; -optionalPositionalParameterTypes : OB normalParameterTypes C? CB ; -parameterTypeList : OP CP | OP normalParameterTypes C optionalParameterTypes CP | OP normalParameterTypes C? CP | OP optionalParameterTypes CP ; -partDeclaration : partHeader (metadata topLevelDeclaration)* ; -partDirective : metadata PART_ uri SC ; -partHeader : metadata PART_ OF_ ( dottedIdentifierList | uri ) SC ; -postfixExpression : assignableExpression postfixOperator | primary selector* ; -postfixOperator : incrementOperator ; -prefixOperator : minusOperator | negationOperator | tildeOperator ; -primary : thisExpression | SUPER_ unconditionalAssignableSelector | SUPER_ argumentPart | functionExpression | literal | identifier | newExpression | constObjectExpression | constructorInvocation | OP expr CP ; -qualifiedName : typeIdentifier D identifier | typeIdentifier D typeIdentifier D identifier ; -redirectingFactoryConstructorSignature : CONST_? FACTORY_ constructorName formalParameterList EQ constructorDesignation ; -redirection : CO THIS_ ( D identifier )? arguments ; -relationalExpression : bitwiseOrExpression ( typeTest | typeCast | relationalOperator bitwiseOrExpression )? | SUPER_ relationalOperator bitwiseOrExpression ; -relationalOperator : GT EQ | GT | LTE | LT ; -reserved_word : ASSERT_ | BREAK_ | CASE_ | CATCH_ | CLASS_ | CONST_ | CONTINUE_ | DEFAULT_ | DO_ | ELSE_ | ENUM_ | EXTENDS_ | FALSE_ | FINAL_ | FINALLY_ | FOR_ | IF_ | IN_ | IS_ | NEW_ | NULL_ | RETHROW_ | RETURN_ | SUPER_ | SWITCH_ | THIS_ | THROW_ | TRUE_ | TRY_ | VAR_ | VOID_ | WHILE_ | WITH_ ; -rethrowStatement : RETHROW_ SC ; -returnStatement : RETURN_ expr? SC ; -selector : NOT | assignableSelector | argumentPart ; -setOrMapLiteral : CONST_? typeArguments? OBC elements? CBC ; -setterSignature : type? SET_ identifier formalParameterList ; -shiftExpression : additiveExpression ( shiftOperator additiveExpression )* | SUPER_ ( shiftOperator additiveExpression )+ ; -shiftOperator : LTLT | GT GT GT | GT GT ; -simpleFormalParameter : declaredIdentifier | COVARIANT_? identifier ; -singleLineString : SingleLineString; -spreadElement : ( DDD | DDDQ ) expr ; -statement : label* nonLabelledStatement ; -statements : statement* ; -staticFinalDeclaration : identifier EQ expr ; -staticFinalDeclarationList : staticFinalDeclaration ( C staticFinalDeclaration )* ; -stringLiteral : ( multilineString | singleLineString )+ ; -superclass : EXTENDS_ typeNotVoid mixins? | mixins ; -switchCase : label* CASE_ expr CO statements ; -switchStatement : SWITCH_ OP expr CP OBC switchCase* defaultCase? CBC ; -symbolLiteral : PO ( identifier ( D identifier )* | operator | VOID_ ) ; -thisExpression : THIS_ ; -throwExpression : THROW_ expr ; -throwExpressionWithoutCascade : THROW_ expressionWithoutCascade ; -tildeOperator : SQUIG ; -topLevelDeclaration : classDeclaration | mixinDeclaration | extensionDeclaration | enumType | typeAlias | EXTERNAL_ functionSignature SC | EXTERNAL_ getterSignature SC | EXTERNAL_ setterSignature SC | functionSignature functionBody | getterSignature functionBody | setterSignature functionBody | ( FINAL_ | CONST_ ) type? staticFinalDeclarationList SC | LATE_ FINAL_ type? initializedIdentifierList SC | LATE_? varOrType initializedIdentifierList SC ; -tryStatement : TRY_ block ( onPart+ finallyPart? | finallyPart ) ; -type : functionType QU? | typeNotFunction ; -typeAlias : TYPEDEF_ typeIdentifier typeParameters? EQ type SC | TYPEDEF_ functionTypeAlias ; -typeArguments : LT typeList GT ; -typeCast : asOperator typeNotVoid ; -typedIdentifier : type identifier ; -typeIdentifier : IDENTIFIER | ASYNC_ | HIDE_ | OF_ | ON_ | SHOW_ | SYNC_ | AWAIT_ | YIELD_ | DYNAMIC_ | NATIVE_ | FUNCTION_; -typeList : type ( C type )* ; -typeName : typeIdentifier ( D typeIdentifier )? ; -typeNotFunction : VOID_ | typeNotVoidNotFunction ; -typeNotVoid : functionType QU? | typeNotVoidNotFunction ; -typeNotVoidList : typeNotVoid ( C typeNotVoid )* ; -typeNotVoidNotFunction : typeName typeArguments? QU? | FUNCTION_ QU? ; -typeNotVoidNotFunctionList : typeNotVoidNotFunction ( C typeNotVoidNotFunction )* ; -typeParameter : metadata identifier ( EXTENDS_ typeNotVoid )? ; -typeParameters : LT typeParameter ( C typeParameter )* GT ; -typeTest : isOperator typeNotVoid ; -unaryExpression : prefixOperator unaryExpression | awaitExpression | postfixExpression | ( minusOperator | tildeOperator ) SUPER_ | incrementOperator assignableExpression ; -unconditionalAssignableSelector : OB expr CB | D identifier ; -uri : stringLiteral ; -uriTest : dottedIdentifierList ( EE stringLiteral )? ; -varOrType : VAR_ | type ; -whileStatement : WHILE_ OP expr CP statement ; -yieldEachStatement : YIELD_ ST expr SC ; -yieldStatement : YIELD_ expr SC ; +options { + tokenVocab = Dart2Lexer; +} + +additiveExpression + : multiplicativeExpression (additiveOperator multiplicativeExpression)* + | SUPER_ ( additiveOperator multiplicativeExpression)+ + ; + +additiveOperator + : PL + | MINUS + ; + +argumentList + : namedArgument (C namedArgument)* + | expressionList ( C namedArgument)* + ; + +argumentPart + : typeArguments? arguments + ; + +arguments + : OP (argumentList C?)? CP + ; + +asOperator + : AS_ + ; + +assertion + : ASSERT_ OP expr (C expr)? C? CP + ; + +assertStatement + : assertion SC + ; + +assignableExpression + : primary assignableSelectorPart + | SUPER_ unconditionalAssignableSelector + | identifier + ; + +assignableSelector + : unconditionalAssignableSelector + | QUD identifier + | QU OB expr CB + ; + +assignableSelectorPart + : selector* assignableSelector + ; + +assignmentOperator + : EQ + | compoundAssignmentOperator + ; + +awaitExpression + : AWAIT_ unaryExpression + ; + +binaryOperator + : multiplicativeOperator + | additiveOperator + | shiftOperator + | relationalOperator + | EE + | bitwiseOperator + ; + +bitwiseAndExpression + : shiftExpression (A shiftExpression)* + | SUPER_ ( A shiftExpression)+ + ; + +bitwiseOperator + : A + | CIR + | P + ; + +bitwiseOrExpression + : bitwiseXorExpression (P bitwiseXorExpression)* + | SUPER_ ( P bitwiseXorExpression)+ + ; + +bitwiseXorExpression + : bitwiseAndExpression (CIR bitwiseAndExpression)* + | SUPER_ ( CIR bitwiseAndExpression)+ + ; + +block + : OBC statements CBC + ; + +booleanLiteral + : TRUE_ + | FALSE_ + ; + +breakStatement + : BREAK_ identifier? SC + ; + +cascade + : cascade DD cascadeSection + | conditionalExpression ( QUDD | DD) cascadeSection + ; + +cascadeAssignment + : assignmentOperator expressionWithoutCascade + ; + +cascadeSection + : cascadeSelector cascadeSectionTail + ; + +cascadeSectionTail + : cascadeAssignment + | selector* ( assignableSelector cascadeAssignment)? + ; + +cascadeSelector + : OB expr CB + | identifier + ; + +catchPart + : CATCH_ OP identifier (C identifier)? CP + ; + +classDeclaration + : ABSTRACT_? CLASS_ typeIdentifier typeParameters? superclass? interfaces? OBC ( + metadata classMemberDeclaration + )* CBC + | ABSTRACT_? CLASS_ mixinApplicationClass + ; + +classMemberDeclaration + : declaration SC + | methodSignature functionBody + ; + +combinator + : SHOW_ identifierList + | HIDE_ identifierList + ; + +compilationUnit + : (libraryDeclaration | partDeclaration | expr | statement) EOF + ; + +compoundAssignmentOperator + : STE + | SE + | SQSE + | PE + | PLE + | ME + | LTLTE + | GT GT GT EQ + | GT GT EQ + | AE + | CIRE + | POE + | QUQUEQ + ; + +conditionalExpression + : ifNullExpression (QU expressionWithoutCascade CO expressionWithoutCascade)? + ; + +configurableUri + : uri configurationUri* + ; + +configurationUri + : IF_ OP uriTest CP uri + ; + +constantConstructorSignature + : CONST_ constructorName formalParameterList + ; + +constObjectExpression + : CONST_ constructorDesignation arguments + ; + +constructorDesignation + : typeIdentifier + | qualifiedName + | typeName typeArguments ( D identifier)? + ; + +constructorInvocation + : typeName typeArguments D identifier arguments + ; + +constructorName + : typeIdentifier (D identifier)? + ; + +constructorSignature + : constructorName formalParameterList + ; + +continueStatement + : CONTINUE_ identifier? SC + ; + +declaration + : ABSTRACT_? ( + EXTERNAL_ factoryConstructorSignature + | EXTERNAL_ constantConstructorSignature + | EXTERNAL_ constructorSignature + | ( EXTERNAL_ STATIC_?)? getterSignature + | ( EXTERNAL_ STATIC_?)? setterSignature + | ( EXTERNAL_ STATIC_?)? functionSignature + | EXTERNAL_? operatorSignature + | STATIC_ CONST_ type? staticFinalDeclarationList + | STATIC_ FINAL_ type? staticFinalDeclarationList + | STATIC_ LATE_ FINAL_ type? initializedIdentifierList + | STATIC_ LATE_? varOrType initializedIdentifierList + | COVARIANT_ LATE_ FINAL_ type? identifierList + | COVARIANT_ LATE_? varOrType initializedIdentifierList + | LATE_? FINAL_ type? initializedIdentifierList + | LATE_? varOrType initializedIdentifierList + | redirectingFactoryConstructorSignature + | constantConstructorSignature ( redirection | initializers)? + | constructorSignature ( redirection | initializers)? + ) + ; + +declaredIdentifier + : COVARIANT_? finalConstVarOrType identifier + ; + +defaultCase + : label* DEFAULT_ CO statements + ; + +defaultFormalParameter + : normalFormalParameter (EQ expr)? + ; + +defaultNamedParameter + : metadata REQUIRED_? normalFormalParameterNoMetadata (( EQ | CO) expr)? + ; + +doStatement + : DO_ statement WHILE_ OP expr CP SC + ; + +dottedIdentifierList + : identifier (D identifier)* + ; + +element + : expressionElement + | mapElement + | spreadElement + | ifElement + | forElement + ; + +elements + : element (C element)* C? + ; + +enumEntry + : metadata identifier + ; + +enumType + : ENUM_ identifier OBC enumEntry (C enumEntry)* C? CBC + ; + +equalityExpression + : relationalExpression (equalityOperator relationalExpression)? + | SUPER_ equalityOperator relationalExpression + ; + +equalityOperator + : EE + | NE + ; + +expr + : assignableExpression assignmentOperator expr + | conditionalExpression + | cascade + | throwExpression + ; + +expressionElement + : expr + ; + +expressionList + : expr (C expr)* + ; + +expressionStatement + : expr? SC + ; + +expressionWithoutCascade + : assignableExpression assignmentOperator expressionWithoutCascade + | conditionalExpression + | throwExpressionWithoutCascade + ; + +extensionDeclaration + : EXTENSION_ identifier? typeParameters? ON_ type OBC (metadata classMemberDeclaration)* CBC + ; + +factoryConstructorSignature + : CONST_? FACTORY_ constructorName formalParameterList + ; + +fieldFormalParameter + : finalConstVarOrType? THIS_ D identifier (formalParameterPart QU?)? + ; + +fieldInitializer + : (THIS_ D)? identifier EQ initializerExpression + ; + +finalConstVarOrType + : LATE_? FINAL_ type? + | CONST_ type? + | LATE_? varOrType + ; + +finallyPart + : FINALLY_ block + ; + +forElement + : AWAIT_? FOR_ OP forLoopParts CP element + ; + +forInitializerStatement + : localVariableDeclaration + | expr? SC + ; + +forLoopParts + : forInitializerStatement expr? SC expressionList? + | metadata declaredIdentifier IN_ expr + | identifier IN_ expr + ; + +formalParameterList + : OP CP + | OP normalFormalParameters C? CP + | OP normalFormalParameters C optionalOrNamedFormalParameters CP + | OP optionalOrNamedFormalParameters CP + ; + +formalParameterPart + : typeParameters? formalParameterList + ; + +forStatement + : AWAIT_? FOR_ OP forLoopParts CP statement + ; + +functionBody + : NATIVE_ stringLiteral? SC + | ASYNC_? EG expr SC + | ( ASYNC_ ST? | SYNC_ ST)? block + ; + +functionExpression + : formalParameterPart functionExpressionBody + ; + +functionExpressionBody + : ASYNC_? EG expr + | ( ASYNC_ ST? | SYNC_ ST)? block + ; + +functionFormalParameter + : COVARIANT_? type? identifier formalParameterPart QU? + ; + +functionPrefix + : type? identifier + ; + +functionSignature + : type? identifier formalParameterPart + ; + +functionType + : functionTypeTails + | typeNotFunction functionTypeTails + ; + +functionTypeAlias + : functionPrefix formalParameterPart SC + ; + +functionTypeTail + : FUNCTION_ typeParameters? parameterTypeList + ; + +functionTypeTails + : functionTypeTail QU? functionTypeTails + | functionTypeTail + ; + +getterSignature + : type? GET_ identifier + ; + +identifier + : IDENTIFIER + | ABSTRACT_ + | AS_ + | COVARIANT_ + | DEFERRED_ + | DYNAMIC_ + | EXPORT_ + | EXTERNAL_ + | EXTENSION_ + | FACTORY_ + | FUNCTION_ + | GET_ + | IMPLEMENTS_ + | IMPORT_ + | INTERFACE_ + | LATE_ + | LIBRARY_ + | MIXIN_ + | OPERATOR_ + | PART_ + | REQUIRED_ + | SET_ + | STATIC_ + | TYPEDEF_ + | FUNCTION_ + | ASYNC_ + | HIDE_ + | OF_ + | ON_ + | SHOW_ + | SYNC_ + | AWAIT_ + | YIELD_ + | DYNAMIC_ + | NATIVE_ + ; + +identifierList + : identifier (C identifier)* + ; + +ifElement + : IF_ OP expr CP element (ELSE_ element)? + ; + +ifNullExpression + : logicalOrExpression (QUQU logicalOrExpression)* + ; + +ifStatement + : IF_ OP expr CP statement (ELSE_ statement)? + ; + +importOrExport + : libraryImport + | libraryExport + ; + +importSpecification + : IMPORT_ configurableUri (DEFERRED_? AS_ identifier)? combinator* SC + ; + +incrementOperator + : PLPL + | MM + ; + +initializedIdentifier + : identifier (EQ expr)? + ; + +initializedIdentifierList + : initializedIdentifier (C initializedIdentifier)* + ; + +initializedVariableDeclaration + : declaredIdentifier (EQ expr)? (C initializedIdentifier)* + ; + +initializerExpression + : conditionalExpression + | cascade + ; + +initializerListEntry + : SUPER_ arguments + | SUPER_ D identifier arguments + | fieldInitializer + | assertion + ; + +initializers + : CO initializerListEntry (C initializerListEntry)* + ; + +interfaces + : IMPLEMENTS_ typeNotVoidList + ; + +isOperator + : IS_ NOT? + ; + +label + : identifier CO + ; + +letExpression + : LET_ staticFinalDeclarationList IN_ expr + ; + +libraryDeclaration + : libraryName? importOrExport* partDirective* (metadata topLevelDeclaration)* + ; + +libraryExport + : metadata EXPORT_ configurableUri combinator* SC + ; + +libraryImport + : metadata importSpecification + ; + +libraryName + : metadata LIBRARY_ dottedIdentifierList SC + ; + +listLiteral + : CONST_? typeArguments? OB elements? CB + ; + +literal + : nullLiteral + | booleanLiteral + | numericLiteral + | stringLiteral + | symbolLiteral + | listLiteral + | setOrMapLiteral + ; + +localFunctionDeclaration + : metadata functionSignature functionBody + ; + +localVariableDeclaration + : metadata initializedVariableDeclaration SC + ; + +logicalAndExpression + : equalityExpression (AA equalityExpression)* + ; + +logicalOrExpression + : logicalAndExpression (PP logicalAndExpression)* + ; + +mapElement + : expr CO expr + ; + +metadata + : (AT metadatum)* + ; + +metadatum + : identifier + | qualifiedName + | constructorDesignation arguments + ; + +methodSignature + : constructorSignature initializers? + | factoryConstructorSignature + | STATIC_? functionSignature + | STATIC_? getterSignature + | STATIC_? setterSignature + | operatorSignature + ; + +minusOperator + : MINUS + ; + +mixinApplication + : typeNotVoid mixins interfaces? + ; + +mixinApplicationClass + : identifier typeParameters? EQ mixinApplication SC + ; + +mixinDeclaration + : MIXIN_ typeIdentifier typeParameters? (ON_ typeNotVoidList)? interfaces? OBC ( + metadata classMemberDeclaration + )* CBC + ; + +mixins + : WITH_ typeNotVoidList + ; + +multilineString + : MultiLineString + ; + +multiplicativeExpression + : unaryExpression (multiplicativeOperator unaryExpression)* + | SUPER_ ( multiplicativeOperator unaryExpression)+ + ; + +multiplicativeOperator + : ST + | SL + | PC + | SQS + ; + +namedArgument + : label expr + ; + +namedFormalParameters + : OBC defaultNamedParameter (C defaultNamedParameter)* C? CBC + ; + +namedParameterType + : metadata REQUIRED_? typedIdentifier + ; + +namedParameterTypes + : OBC namedParameterType (C namedParameterType)* C? CBC + ; + +negationOperator + : NOT + ; + +newExpression + : NEW_ constructorDesignation arguments + ; + +nonLabelledStatement + : block + | localVariableDeclaration + | forStatement + | whileStatement + | doStatement + | switchStatement + | ifStatement + | rethrowStatement + | tryStatement + | breakStatement + | continueStatement + | returnStatement + | yieldStatement + | yieldEachStatement + | expressionStatement + | assertStatement + | localFunctionDeclaration + ; + +normalFormalParameter + : metadata normalFormalParameterNoMetadata + ; + +normalFormalParameterNoMetadata + : functionFormalParameter + | fieldFormalParameter + | simpleFormalParameter + ; + +normalFormalParameters + : normalFormalParameter (C normalFormalParameter)* + ; + +normalParameterType + : metadata typedIdentifier + | metadata type + ; + +normalParameterTypes + : normalParameterType (C normalParameterType)* + ; + +nullLiteral + : NULL_ + ; + +numericLiteral + : NUMBER + | HEX_NUMBER + ; + +onPart + : catchPart block + | ON_ typeNotVoid catchPart? block + ; + +operator + : SQUIG + | binaryOperator + | OB CB + | OB CB EQ + ; + +operatorSignature + : type? OPERATOR_ operator formalParameterList + ; + +optionalOrNamedFormalParameters + : optionalPositionalFormalParameters + | namedFormalParameters + ; + +optionalParameterTypes + : optionalPositionalParameterTypes + | namedParameterTypes + ; + +optionalPositionalFormalParameters + : OB defaultFormalParameter (C defaultFormalParameter)* C? CB + ; + +optionalPositionalParameterTypes + : OB normalParameterTypes C? CB + ; + +parameterTypeList + : OP CP + | OP normalParameterTypes C optionalParameterTypes CP + | OP normalParameterTypes C? CP + | OP optionalParameterTypes CP + ; + +partDeclaration + : partHeader (metadata topLevelDeclaration)* + ; + +partDirective + : metadata PART_ uri SC + ; + +partHeader + : metadata PART_ OF_ (dottedIdentifierList | uri) SC + ; + +postfixExpression + : assignableExpression postfixOperator + | primary selector* + ; + +postfixOperator + : incrementOperator + ; + +prefixOperator + : minusOperator + | negationOperator + | tildeOperator + ; + +primary + : thisExpression + | SUPER_ unconditionalAssignableSelector + | SUPER_ argumentPart + | functionExpression + | literal + | identifier + | newExpression + | constObjectExpression + | constructorInvocation + | OP expr CP + ; + +qualifiedName + : typeIdentifier D identifier + | typeIdentifier D typeIdentifier D identifier + ; + +redirectingFactoryConstructorSignature + : CONST_? FACTORY_ constructorName formalParameterList EQ constructorDesignation + ; + +redirection + : CO THIS_ (D identifier)? arguments + ; + +relationalExpression + : bitwiseOrExpression (typeTest | typeCast | relationalOperator bitwiseOrExpression)? + | SUPER_ relationalOperator bitwiseOrExpression + ; + +relationalOperator + : GT EQ + | GT + | LTE + | LT + ; + +reserved_word + : ASSERT_ + | BREAK_ + | CASE_ + | CATCH_ + | CLASS_ + | CONST_ + | CONTINUE_ + | DEFAULT_ + | DO_ + | ELSE_ + | ENUM_ + | EXTENDS_ + | FALSE_ + | FINAL_ + | FINALLY_ + | FOR_ + | IF_ + | IN_ + | IS_ + | NEW_ + | NULL_ + | RETHROW_ + | RETURN_ + | SUPER_ + | SWITCH_ + | THIS_ + | THROW_ + | TRUE_ + | TRY_ + | VAR_ + | VOID_ + | WHILE_ + | WITH_ + ; + +rethrowStatement + : RETHROW_ SC + ; + +returnStatement + : RETURN_ expr? SC + ; + +selector + : NOT + | assignableSelector + | argumentPart + ; + +setOrMapLiteral + : CONST_? typeArguments? OBC elements? CBC + ; + +setterSignature + : type? SET_ identifier formalParameterList + ; + +shiftExpression + : additiveExpression (shiftOperator additiveExpression)* + | SUPER_ ( shiftOperator additiveExpression)+ + ; + +shiftOperator + : LTLT + | GT GT GT + | GT GT + ; + +simpleFormalParameter + : declaredIdentifier + | COVARIANT_? identifier + ; + +singleLineString + : SingleLineString + ; + +spreadElement + : (DDD | DDDQ) expr + ; + +statement + : label* nonLabelledStatement + ; + +statements + : statement* + ; + +staticFinalDeclaration + : identifier EQ expr + ; + +staticFinalDeclarationList + : staticFinalDeclaration (C staticFinalDeclaration)* + ; + +stringLiteral + : (multilineString | singleLineString)+ + ; + +superclass + : EXTENDS_ typeNotVoid mixins? + | mixins + ; + +switchCase + : label* CASE_ expr CO statements + ; + +switchStatement + : SWITCH_ OP expr CP OBC switchCase* defaultCase? CBC + ; + +symbolLiteral + : PO (identifier ( D identifier)* | operator | VOID_) + ; + +thisExpression + : THIS_ + ; + +throwExpression + : THROW_ expr + ; + +throwExpressionWithoutCascade + : THROW_ expressionWithoutCascade + ; + +tildeOperator + : SQUIG + ; + +topLevelDeclaration + : classDeclaration + | mixinDeclaration + | extensionDeclaration + | enumType + | typeAlias + | EXTERNAL_ functionSignature SC + | EXTERNAL_ getterSignature SC + | EXTERNAL_ setterSignature SC + | functionSignature functionBody + | getterSignature functionBody + | setterSignature functionBody + | ( FINAL_ | CONST_) type? staticFinalDeclarationList SC + | LATE_ FINAL_ type? initializedIdentifierList SC + | LATE_? varOrType initializedIdentifierList SC + ; + +tryStatement + : TRY_ block (onPart+ finallyPart? | finallyPart) + ; + +type + : functionType QU? + | typeNotFunction + ; + +typeAlias + : TYPEDEF_ typeIdentifier typeParameters? EQ type SC + | TYPEDEF_ functionTypeAlias + ; + +typeArguments + : LT typeList GT + ; + +typeCast + : asOperator typeNotVoid + ; + +typedIdentifier + : type identifier + ; + +typeIdentifier + : IDENTIFIER + | ASYNC_ + | HIDE_ + | OF_ + | ON_ + | SHOW_ + | SYNC_ + | AWAIT_ + | YIELD_ + | DYNAMIC_ + | NATIVE_ + | FUNCTION_ + ; + +typeList + : type (C type)* + ; + +typeName + : typeIdentifier (D typeIdentifier)? + ; + +typeNotFunction + : VOID_ + | typeNotVoidNotFunction + ; + +typeNotVoid + : functionType QU? + | typeNotVoidNotFunction + ; + +typeNotVoidList + : typeNotVoid (C typeNotVoid)* + ; + +typeNotVoidNotFunction + : typeName typeArguments? QU? + | FUNCTION_ QU? + ; + +typeNotVoidNotFunctionList + : typeNotVoidNotFunction (C typeNotVoidNotFunction)* + ; + +typeParameter + : metadata identifier (EXTENDS_ typeNotVoid)? + ; + +typeParameters + : LT typeParameter (C typeParameter)* GT + ; + +typeTest + : isOperator typeNotVoid + ; + +unaryExpression + : prefixOperator unaryExpression + | awaitExpression + | postfixExpression + | ( minusOperator | tildeOperator) SUPER_ + | incrementOperator assignableExpression + ; + +unconditionalAssignableSelector + : OB expr CB + | D identifier + ; + +uri + : stringLiteral + ; + +uriTest + : dottedIdentifierList (EE stringLiteral)? + ; + +varOrType + : VAR_ + | type + ; + +whileStatement + : WHILE_ OP expr CP statement + ; + +yieldEachStatement + : YIELD_ ST expr SC + ; + +yieldStatement + : YIELD_ expr SC + ; \ No newline at end of file diff --git a/databank/databank.g4 b/databank/databank.g4 index 1e2a079cc3..e10e5abc39 100644 --- a/databank/databank.g4 +++ b/databank/databank.g4 @@ -33,69 +33,68 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * http://archive.li/m3fki#selection-1331.0-1331.26 */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar databank; -options { superClass = DatabankParserBase; } +options { + superClass = DatabankParserBase; +} databank - : EOL* (datedseries | undatedseries) sample + EOL* EOF - ; + : EOL* (datedseries | undatedseries) sample+ EOL* EOF + ; datedseries - : datatype dateline dateline - ; + : datatype dateline dateline + ; undatedseries - : dateline dateline - ; + : dateline dateline + ; datatype - : FLOATINGPOINT { isdatatype() }? EOL - ; + : FLOATINGPOINT { isdatatype() }? EOL + ; dateline - : number EOL - ; + : number EOL + ; sample - : (number | 'NA') EOL? - ; + : (number | 'NA') EOL? + ; number - : FLOATINGPOINT - ; - + : FLOATINGPOINT + ; FLOATINGPOINT - : ('-'|'+')? NUMBER (E SIGN? NUMBER)? - ; - + : ('-' | '+')? NUMBER (E SIGN? NUMBER)? + ; fragment NUMBER - : ('0' .. '9') + ('.' ('0' .. '9')*)? - ; - + : ('0' .. '9')+ ('.' ('0' .. '9')*)? + ; fragment E - : 'E' | 'e' - ; - + : 'E' + | 'e' + ; fragment SIGN - : ('+' | '-') - ; - + : ('+' | '-') + ; COMMENT - : '"c' ~ ["]* '"' ' '* EOL -> skip - ; - + : '"c' ~ ["]* '"' ' '* EOL -> skip + ; EOL - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/datalog/datalog.g4 b/datalog/datalog.g4 index 5771c88e76..dc82f0fc62 100644 --- a/datalog/datalog.g4 +++ b/datalog/datalog.g4 @@ -29,102 +29,105 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar datalog; program - : statement* EOF - ; + : statement* EOF + ; statement - : assertion - | retraction - | query - | requirement - ; + : assertion + | retraction + | query + | requirement + ; assertion - : clause '.' - ; + : clause '.' + ; retraction - : clause '~' - ; + : clause '~' + ; query - : literal '?' - ; + : literal '?' + ; requirement - : '(' IDENTIFIER ')' '.' - ; + : '(' IDENTIFIER ')' '.' + ; clause - : literal ':-' body - | literal - ; + : literal ':-' body + | literal + ; body - : literal ',' body - | literal - ; + : literal ',' body + | literal + ; literal - : predicate_sym '(' ')' - | predicate_sym '(' terms_ ')' - | predicate_sym - | term_ '=' term_ - | term_ '!=' term_ - | VARIABLE ':-' external_sym '(' terms_ ')' - ; + : predicate_sym '(' ')' + | predicate_sym '(' terms_ ')' + | predicate_sym + | term_ '=' term_ + | term_ '!=' term_ + | VARIABLE ':-' external_sym '(' terms_ ')' + ; predicate_sym - : IDENTIFIER - | STRING - ; + : IDENTIFIER + | STRING + ; terms_ - : term_ - | term_ ',' terms_ - ; + : term_ + | term_ ',' terms_ + ; term_ - : VARIABLE - | constant - ; + : VARIABLE + | constant + ; constant - : IDENTIFIER - | STRING - | INTEGER - | 'true' - | 'false' - ; + : IDENTIFIER + | STRING + | INTEGER + | 'true' + | 'false' + ; external_sym - : IDENTIFIER - ; + : IDENTIFIER + ; VARIABLE - : [A-Z] [a-zA-Z_]* - ; + : [A-Z] [a-zA-Z_]* + ; IDENTIFIER - : [a-z] [a-zA-Z0-9_-]* - ; + : [a-z] [a-zA-Z0-9_-]* + ; STRING - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; INTEGER - : [0-9]+ - ; + : [0-9]+ + ; COMMENT - : '#' (~ [\n\r])* -> skip - ; + : '#' (~ [\n\r])* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/dcm/DCM_2_0_grammar.g4 b/dcm/DCM_2_0_grammar.g4 index 99110e5c83..beb119671a 100644 --- a/dcm/DCM_2_0_grammar.g4 +++ b/dcm/DCM_2_0_grammar.g4 @@ -1,225 +1,241 @@ - // Parser + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar DCM_2_0_grammar; konservierung - : ( '\n' )* 'KONSERVIERUNG_FORMAT 2.0' ( '\n' )+ kons_kopf kons_rumpf EOF - ; + : ('\n')* 'KONSERVIERUNG_FORMAT 2.0' ('\n')+ kons_kopf kons_rumpf EOF + ; kons_kopf - : ( modulkopf_info )? ( funktionsdef )? ( variantendef )? - ; + : (modulkopf_info)? (funktionsdef)? (variantendef)? + ; modulkopf_info - : ( mod_zeile )+ - ; + : (mod_zeile)+ + ; mod_zeile - : mod_anf_zeile ( mod_fort_zeile )* - ; + : mod_anf_zeile (mod_fort_zeile)* + ; mod_anf_zeile - : 'MODULKOPF' mod_ele_name mod_ele_wert - ; + : 'MODULKOPF' mod_ele_name mod_ele_wert + ; mod_fort_zeile - : 'MODULKOPF' mod_ele_wert - ; + : 'MODULKOPF' mod_ele_wert + ; mod_ele_name - : NAME - ; + : NAME + ; mod_ele_wert - : TEXT ( '\n' )+ - ; + : TEXT ('\n')+ + ; funktionsdef - : 'FUNKTIONEN' '\n' ( funktionszeile )+ 'END' ( '\n' )+ - ; + : 'FUNKTIONEN' '\n' (funktionszeile)+ 'END' ('\n')+ + ; funktionszeile - : 'FKT' NAME fkt_version fkt_langname - ; + : 'FKT' NAME fkt_version fkt_langname + ; fkt_version - : TEXT - ; + : TEXT + ; fkt_langname - : TEXT ( '\n' )+ - ; + : TEXT ('\n')+ + ; variantendef - : 'VARIANTENKODIERUNG' '\n' ( variantenkrit )+ 'END' ( '\n' )+ - ; + : 'VARIANTENKODIERUNG' '\n' (variantenkrit)+ 'END' ('\n')+ + ; variantenkrit - : 'KRITERIUM' krit_name ( krit_wert )* ( '\n' )+ - ; + : 'KRITERIUM' krit_name (krit_wert)* ('\n')+ + ; krit_name - : NAME - ; + : NAME + ; krit_wert - : NAME - ; + : NAME + ; kons_rumpf - : ( kenngroesse )* - ; + : (kenngroesse)* + ; kenngroesse - : ( kennwert | kennwerteblock | kennlinie | kennfeld | gruppenstuetzstellen | kenntext ) - ; + : (kennwert | kennwerteblock | kennlinie | kennfeld | gruppenstuetzstellen | kenntext) + ; kennwert - : 'FESTWERT' NAME '\n' kgr_info ( einheit_w )? 'WERT' realzahl '\n' 'END' ( '\n' )+ | 'FESTWERT' NAME '\n' kgr_info ( einheit_w )? 'TEXT' TEXT '\n' 'END' ( '\n' )+ - ; + : 'FESTWERT' NAME '\n' kgr_info (einheit_w)? 'WERT' realzahl '\n' 'END' ('\n')+ + | 'FESTWERT' NAME '\n' kgr_info ( einheit_w)? 'TEXT' TEXT '\n' 'END' ( '\n')+ + ; kennwerteblock - : 'FESTWERTEBLOCK' NAME anzahl_x '\n' kgr_info ( einheit_w )? ( werteliste_kwb )+ 'END' ( '\n' )+ - ; + : 'FESTWERTEBLOCK' NAME anzahl_x '\n' kgr_info (einheit_w)? (werteliste_kwb)+ 'END' ('\n')+ + ; kennlinie - : ( 'KENNLINIE' ) NAME anzahl_x '\n' kgr_info ( einheit_x )? ( einheit_w )? ( sst_liste_x )+ ( werteliste )+ 'END' ( '\n' )+ | ( 'FESTKENNLINIE' ) NAME anzahl_x '\n' kgr_info ( einheit_x )? ( einheit_w )? ( sst_liste_x )+ ( werteliste )+ 'END' ( '\n' )+ | ( 'GRUPPENKENNLINIE' ) NAME anzahl_x '\n' kgr_info ( einheit_x )? ( einheit_w )? ( sst_liste_x )+ ( werteliste )+ 'END' ( '\n' )+ - ; + : ('KENNLINIE') NAME anzahl_x '\n' kgr_info (einheit_x)? (einheit_w)? (sst_liste_x)+ ( + werteliste + )+ 'END' ('\n')+ + | ('FESTKENNLINIE') NAME anzahl_x '\n' kgr_info (einheit_x)? (einheit_w)? (sst_liste_x)+ ( + werteliste + )+ 'END' ('\n')+ + | ('GRUPPENKENNLINIE') NAME anzahl_x '\n' kgr_info (einheit_x)? (einheit_w)? (sst_liste_x)+ ( + werteliste + )+ 'END' ('\n')+ + ; kennfeld - : ( 'KENNFELD' ) NAME anzahl_x anzahl_y '\n' kgr_info ( einheit_x )? ( einheit_y )? ( einheit_w )? ( sst_liste_x )+ kf_zeile_liste 'END' ( '\n' )+ | ( 'FESTKENNFELD' ) NAME anzahl_x anzahl_y '\n' kgr_info ( einheit_x )? ( einheit_y )? ( einheit_w )? ( sst_liste_x )+ kf_zeile_liste 'END' ( '\n' )+ | ( 'GRUPPENKENNFELD' ) NAME anzahl_x anzahl_y '\n' kgr_info ( einheit_x )? ( einheit_y )? ( einheit_w )? ( sst_liste_x )+ kf_zeile_liste 'END' ( '\n' )+ - ; + : ('KENNFELD') NAME anzahl_x anzahl_y '\n' kgr_info (einheit_x)? (einheit_y)? (einheit_w)? ( + sst_liste_x + )+ kf_zeile_liste 'END' ('\n')+ + | ('FESTKENNFELD') NAME anzahl_x anzahl_y '\n' kgr_info (einheit_x)? (einheit_y)? (einheit_w)? ( + sst_liste_x + )+ kf_zeile_liste 'END' ('\n')+ + | ('GRUPPENKENNFELD') NAME anzahl_x anzahl_y '\n' kgr_info (einheit_x)? (einheit_y)? ( + einheit_w + )? (sst_liste_x)+ kf_zeile_liste 'END' ('\n')+ + ; gruppenstuetzstellen - : 'STUETZSTELLENVERTEILUNG' NAME anzahl_x '\n' kgr_info ( einheit_x )? ( sst_liste_x )+ 'END' ( '\n' )+ - ; + : 'STUETZSTELLENVERTEILUNG' NAME anzahl_x '\n' kgr_info (einheit_x)? (sst_liste_x)+ 'END' ( + '\n' + )+ + ; kenntext - : 'TEXTSTRING' NAME '\n' kgr_info 'TEXT' TEXT '\n' 'END' ( '\n' )+ - ; + : 'TEXTSTRING' NAME '\n' kgr_info 'TEXT' TEXT '\n' 'END' ('\n')+ + ; kgr_info - : ( langname )? ( displayname )? ( var_abhangigkeiten )? ( funktionszugehorigkeit )? - ; + : (langname)? (displayname)? (var_abhangigkeiten)? (funktionszugehorigkeit)? + ; einheit_x - : 'EINHEIT_X' TEXT '\n' - ; + : 'EINHEIT_X' TEXT '\n' + ; einheit_y - : 'EINHEIT_Y' TEXT '\n' - ; + : 'EINHEIT_Y' TEXT '\n' + ; einheit_w - : 'EINHEIT_W' TEXT '\n' - ; + : 'EINHEIT_W' TEXT '\n' + ; langname - : 'LANGNAME' TEXT '\n' - ; + : 'LANGNAME' TEXT '\n' + ; displayname - : 'DISPLAYNAME' ( NAME | TEXT ) '\n' - ; + : 'DISPLAYNAME' (NAME | TEXT) '\n' + ; var_abhangigkeiten - : 'VAR' var_abh ( ',' var_abh )* '\n' - ; + : 'VAR' var_abh (',' var_abh)* '\n' + ; var_abh - : NAME '=' NAME - ; + : NAME '=' NAME + ; funktionszugehorigkeit - : 'FUNKTION' ( NAME )+ '\n' - ; + : 'FUNKTION' (NAME)+ '\n' + ; anzahl_x - : INT - ; + : INT + ; anzahl_y - : INT - ; + : INT + ; werteliste - : 'WERT' ( realzahl )+ '\n' - ; + : 'WERT' (realzahl)+ '\n' + ; werteliste_kwb - : ( 'WERT' ( realzahl )+ '\n' | 'TEXT' ( TEXT )+ '\n' ) - ; + : ('WERT' ( realzahl)+ '\n' | 'TEXT' ( TEXT)+ '\n') + ; sst_liste_x - : ( 'ST/X' ( realzahl )+ '\n' | 'ST_TX/X' ( TEXT )+ '\n' ) - ; + : ('ST/X' ( realzahl)+ '\n' | 'ST_TX/X' ( TEXT)+ '\n') + ; kf_zeile_liste - : ( kf_zeile_liste_r+ | kf_zeile_liste_tx+ ) - ; + : (kf_zeile_liste_r+ | kf_zeile_liste_tx+) + ; kf_zeile_liste_r - : ( 'ST/Y' realzahl '\n' werteliste+ ) - ; + : ('ST/Y' realzahl '\n' werteliste+) + ; kf_zeile_liste_tx - : ( 'ST_TX/Y' TEXT '\n' werteliste+ ) - ; + : ('ST_TX/Y' TEXT '\n' werteliste+) + ; realzahl - : ( INT | FLOAT ) - ; + : (INT | FLOAT) + ; NAME - : LETTER ( LETTER | '0' .. '9' | '[' | ']' | '.' )* - ; - + : LETTER (LETTER | '0' .. '9' | '[' | ']' | '.')* + ; fragment LETTER - : 'A' .. 'Z' | 'a' .. 'z' | '_' - ; - + : 'A' .. 'Z' + | 'a' .. 'z' + | '_' + ; TEXT - : '"' ( EscapeSequence | ~ ( '\\' | '"' ) )* '"' - ; - + : '"' (EscapeSequence | ~ ( '\\' | '"'))* '"' + ; fragment EscapeSequence - : '\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\' ) - ; - + : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') + ; fragment QUOTE - : '"' - ; - + : '"' + ; INT - : MINUS? ( '0' | '1' .. '9' '0' .. '9'* ) - ; - + : MINUS? ('0' | '1' .. '9' '0' .. '9'*) + ; FLOAT - : MINUS? ( '0' .. '9' )+ '.' ( '0' .. '9' )* Exponent? | MINUS? '.' ( '0' .. '9' )+ Exponent? | MINUS? ( '0' .. '9' )+ Exponent - ; - + : MINUS? ('0' .. '9')+ '.' ('0' .. '9')* Exponent? + | MINUS? '.' ( '0' .. '9')+ Exponent? + | MINUS? ( '0' .. '9')+ Exponent + ; MINUS - : '-' - ; - + : '-' + ; fragment Exponent - : ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ - ; - + : ('e' | 'E') ('+' | '-')? ('0' .. '9')+ + ; WS - : ( ' ' | '\r' | '\t' | '\u000C' ) ->skip - ; - + : (' ' | '\r' | '\t' | '\u000C') -> skip + ; COMMENT - : ( '*' | '!' | '.' ) .*? '\n' ->skip - ; + : ('*' | '!' | '.') .*? '\n' -> skip + ; \ No newline at end of file diff --git a/dice/DiceNotationLexer.g4 b/dice/DiceNotationLexer.g4 index 4b767b3d95..9773925e0f 100644 --- a/dice/DiceNotationLexer.g4 +++ b/dice/DiceNotationLexer.g4 @@ -17,6 +17,11 @@ /** * Dice notation lexical rules. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar DiceNotationLexer; /** @@ -25,60 +30,28 @@ lexer grammar DiceNotationLexer; // Dice markers -DSEPARATOR -: - ( 'd' | 'D' ) -; +DSEPARATOR: ( 'd' | 'D'); -DIGIT -: - ('0'..'9')+ -; +DIGIT: ('0' ..'9')+; // Operation tokens -ADDOPERATOR -: - ( ADD | SUB ) -; - -MULTOPERATOR -: - ( MULT | DIV ) -; - -fragment ADD -: - '+' -; - -fragment SUB -: - '-' -; - -fragment MULT -: - '*' -; - -fragment DIV -: - '/' -; - -LPAREN -: - '(' -; - -RPAREN -: - ')' -; +ADDOPERATOR: ( ADD | SUB); + +MULTOPERATOR: ( MULT | DIV); + +fragment ADD: '+'; + +fragment SUB: '-'; + +fragment MULT: '*'; + +fragment DIV: '/'; + +LPAREN: '('; + +RPAREN: ')'; // Skippable tokens -WS: - [\t\r\n]+ -> skip -; +WS: [\t\r\n]+ -> skip; \ No newline at end of file diff --git a/dice/DiceNotationParser.g4 b/dice/DiceNotationParser.g4 index 2ec98df75d..09c06e2d00 100644 --- a/dice/DiceNotationParser.g4 +++ b/dice/DiceNotationParser.g4 @@ -19,46 +19,48 @@ * * This is the notation which RPGs and other tabletop games use to represent operations with dice. */ + +// $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 DiceNotationParser; -options { tokenVocab=DiceNotationLexer; } +options { + tokenVocab = DiceNotationLexer; +} /** * Rules. */ -file_ : notation EOF ; - +file_ + : notation EOF + ; + notation -: - dice - | number - | addOp -; + : dice + | number + | addOp + ; addOp -: - multOp (ADDOPERATOR multOp)* -; + : multOp (ADDOPERATOR multOp)* + ; multOp -: - operand (MULTOPERATOR operand)* -; + : operand (MULTOPERATOR operand)* + ; operand -: - dice - | number - | LPAREN notation RPAREN -; + : dice + | number + | LPAREN notation RPAREN + ; dice -: - ADDOPERATOR? DIGIT? DSEPARATOR DIGIT -; + : ADDOPERATOR? DIGIT? DSEPARATOR DIGIT + ; number -: - ADDOPERATOR? DIGIT -; + : ADDOPERATOR? DIGIT + ; \ No newline at end of file diff --git a/dif/dif.g4 b/dif/dif.g4 index 51db5944b8..a44ec08fd0 100644 --- a/dif/dif.g4 +++ b/dif/dif.g4 @@ -29,67 +29,70 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar dif; dif - : header data EOF - ; + : header data EOF + ; header - : tableheader vectorsheader tuplesheader dataheader - ; + : tableheader vectorsheader tuplesheader dataheader + ; tableheader - : 'TABLE' pair STRING - ; + : 'TABLE' pair STRING + ; vectorsheader - : 'VECTORS' pair STRING - ; + : 'VECTORS' pair STRING + ; tuplesheader - : 'TUPLES' pair STRING - ; + : 'TUPLES' pair STRING + ; dataheader - : 'DATA' pair STRING - ; + : 'DATA' pair STRING + ; data - : datum+ - ; + : datum+ + ; datum - : directive - | string_ - | numeric - ; + : directive + | string_ + | numeric + ; directive - : pair ('BOT' | 'EOD') - ; + : pair ('BOT' | 'EOD') + ; string_ - : pair STRING - ; + : pair STRING + ; numeric - : pair 'V' - ; + : pair 'V' + ; pair - : NUM ',' NUM - ; + : NUM ',' NUM + ; NUM - : ('-')? [0-9]+ - ; + : ('-')? [0-9]+ + ; STRING - : '"' .*? '"' - ; + : '"' .*? '"' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/doiurl/doiurl.g4 b/doiurl/doiurl.g4 index 98a4124c21..46872e994c 100644 --- a/doiurl/doiurl.g4 +++ b/doiurl/doiurl.g4 @@ -32,94 +32,98 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://www.doi.org - // https://tools.ietf.org/id/draft-paskin-doi-uri-04.txt +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar doiurl; doiuri - : scheme ':' encodeddoi ('?' query)? ('#' fragment_)? EOF? - ; + : scheme ':' encodeddoi ('?' query)? ('#' fragment_)? EOF? + ; scheme - : 'doi' - ; + : 'doi' + ; encodeddoi - : prefix_ '/' suffix - ; + : prefix_ '/' suffix + ; prefix_ - : segment - ; + : segment + ; suffix - : segment ('/' segment)* - ; + : segment ('/' segment)* + ; segment - : PCHAR+ - ; + : PCHAR+ + ; query - : (PCHAR | '/' | '?')* - ; + : (PCHAR | '/' | '?')* + ; fragment_ - : (PCHAR | '/' | '?')* - ; + : (PCHAR | '/' | '?')* + ; PCHAR - : UNRESERVED - | ESCAPED - | ';' - | ':' - | '@' - | '&' - | '=' - | '+' - | '$' - | ',' - ; + : UNRESERVED + | ESCAPED + | ';' + | ':' + | '@' + | '&' + | '=' + | '+' + | '$' + | ',' + ; fragment UNRESERVED - : ALPHA - | DIGIT - | MARK - ; + : ALPHA + | DIGIT + | MARK + ; fragment ESCAPED - : '%' HEXDIG HEXDIG - ; + : '%' HEXDIG HEXDIG + ; fragment MARK - : '-' - | '_' - | '.' - | '!' - | '~' - | '*' - | '\'' - | '(' - | ')' - ; - // https://tools.ietf.org/html/rfc2234 + : '-' + | '_' + | '.' + | '!' + | '~' + | '*' + | '\'' + | '(' + | ')' + ; + +// https://tools.ietf.org/html/rfc2234 fragment ALPHA - : [a-zA-Z] - ; - // https://tools.ietf.org/html/rfc2234 + : [a-zA-Z] + ; + +// https://tools.ietf.org/html/rfc2234 fragment DIGIT - : [0-9] - ; - // https:tools.ietf.org/html/rfc2234 + : [0-9] + ; + +// https:tools.ietf.org/html/rfc2234 fragment HEXDIG - : [0-9A-F] - ; + : [0-9A-F] + ; WS - : [ \t\r\n]+ -> skip - ; - + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/dot/DOT.g4 b/dot/DOT.g4 index 04409a01a1..f32d656655 100644 --- a/dot/DOT.g4 +++ b/dot/DOT.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2013 Terence Parr @@ -29,153 +28,149 @@ /** Derived from http://www.graphviz.org/doc/info/lang.html. Comments pulled from spec. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar DOT; graph - : STRICT? ( GRAPH | DIGRAPH ) id_? '{' stmt_list '}' EOF - ; + : STRICT? (GRAPH | DIGRAPH) id_? '{' stmt_list '}' EOF + ; stmt_list - : ( stmt ';'? )* - ; + : (stmt ';'?)* + ; stmt - : node_stmt | edge_stmt | attr_stmt | id_ '=' id_ | subgraph - ; + : node_stmt + | edge_stmt + | attr_stmt + | id_ '=' id_ + | subgraph + ; attr_stmt - : ( GRAPH | NODE | EDGE ) attr_list - ; + : (GRAPH | NODE | EDGE) attr_list + ; attr_list - : ( '[' a_list? ']' )+ - ; + : ('[' a_list? ']')+ + ; a_list - : ( id_ ( '=' id_ )? ','? )+ - ; + : (id_ ( '=' id_)? ','?)+ + ; edge_stmt - : ( node_id | subgraph ) edgeRHS attr_list? - ; + : (node_id | subgraph) edgeRHS attr_list? + ; edgeRHS - : ( edgeop ( node_id | subgraph ) )+ - ; + : (edgeop ( node_id | subgraph))+ + ; edgeop - : '->' | '--' - ; + : '->' + | '--' + ; node_stmt - : node_id attr_list? - ; + : node_id attr_list? + ; node_id - : id_ port? - ; + : id_ port? + ; port - : ':' id_ ( ':' id_ )? - ; + : ':' id_ (':' id_)? + ; subgraph - : ( SUBGRAPH id_? )? '{' stmt_list '}' - ; + : (SUBGRAPH id_?)? '{' stmt_list '}' + ; id_ - : ID | STRING | HTML_STRING | NUMBER - ; + : ID + | STRING + | HTML_STRING + | NUMBER + ; // "The keywords node, edge, graph, digraph, subgraph, and strict are // case-independent" STRICT - : [Ss] [Tt] [Rr] [Ii] [Cc] [Tt] - ; - + : [Ss] [Tt] [Rr] [Ii] [Cc] [Tt] + ; GRAPH - : [Gg] [Rr] [Aa] [Pp] [Hh] - ; - + : [Gg] [Rr] [Aa] [Pp] [Hh] + ; DIGRAPH - : [Dd] [Ii] [Gg] [Rr] [Aa] [Pp] [Hh] - ; - + : [Dd] [Ii] [Gg] [Rr] [Aa] [Pp] [Hh] + ; NODE - : [Nn] [Oo] [Dd] [Ee] - ; - + : [Nn] [Oo] [Dd] [Ee] + ; EDGE - : [Ee] [Dd] [Gg] [Ee] - ; - + : [Ee] [Dd] [Gg] [Ee] + ; SUBGRAPH - : [Ss] [Uu] [Bb] [Gg] [Rr] [Aa] [Pp] [Hh] - ; - + : [Ss] [Uu] [Bb] [Gg] [Rr] [Aa] [Pp] [Hh] + ; /** "a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )" */ NUMBER - : '-'? ( '.' DIGIT+ | DIGIT+ ( '.' DIGIT* )? ) - ; - + : '-'? ('.' DIGIT+ | DIGIT+ ( '.' DIGIT*)?) + ; fragment DIGIT - : [0-9] - ; - + : [0-9] + ; /** "any double-quoted string ("...") possibly containing escaped quotes" */ STRING - : '"' ( '\\"' | . )*? '"' - ; - + : '"' ('\\"' | .)*? '"' + ; /** "Any string of alphabetic ([a-zA-Z\200-\377]) characters, underscores * ('_') or digits ([0-9]), not beginning with a digit" */ ID - : LETTER ( LETTER | DIGIT )* - ; - + : LETTER (LETTER | DIGIT)* + ; fragment LETTER - : [a-zA-Z\u0080-\u00FF_] - ; - + : [a-zA-Z\u0080-\u00FF_] + ; /** "HTML strings, angle brackets must occur in matched pairs, and * unescaped newlines are allowed." */ HTML_STRING - : '<' ( TAG | ~ [<>] )* '>' - ; - + : '<' (TAG | ~ [<>])* '>' + ; fragment TAG - : '<' .*? '>' - ; - + : '<' .*? '>' + ; COMMENT - : '/*' .*? '*/' -> skip - ; - + : '/*' .*? '*/' -> skip + ; LINE_COMMENT - : '//' .*? '\r'? '\n' -> skip - ; - + : '//' .*? '\r'? '\n' -> skip + ; /** "a '#' character is considered a line output from a C preprocessor (e.g., * # 34 to indicate line 34 ) and discarded" */ PREPROC - : '#' ~[\r\n]* -> skip - ; - + : '#' ~[\r\n]* -> skip + ; WS - : [ \t\n\r]+ -> skip - ; + : [ \t\n\r]+ -> skip + ; \ No newline at end of file diff --git a/edif300/EDIF300.g4 b/edif300/EDIF300.g4 index b458fdf2fe..1b32fc82f4 100644 --- a/edif300/EDIF300.g4 +++ b/edif300/EDIF300.g4 @@ -26,3397 +26,4501 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -grammar EDIF300; - -goal : edif EOF ; - -absolute : '(absolute' - integerExpression - ')'; - -acLoad : '(acLoad' - capacitanceValue - ')'; - -acLoadDisplay : '(acLoadDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -acLoadFactorCapacitance : capacitanceValue; - -acLoadFactorTime : timeValue; - -addDisplay : '(addDisplay' - ( display )* - ')'; - -ampere : '(ampere' - unitExponent - ')'; - -and_ : '(and' - ( booleanExpression )* - ')'; - -angleValue : numberValue; - -annotate : '(annotate' - stringValue - ( display )* - ')'; - -approvedDate : '(approvedDate' - date - ')'; - -approvedDateDisplay : '(approvedDateDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -arc : '(arc' - startPoint - throughPoint - endPoint - ')'; - -ascii : '(ascii' - ')'; - -associatedInterconnectNameDisplay : '(associatedInterconnectNameDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -attachmentPoint : pointValue; - -author : '(author' - stringToken - ')'; - -backgroundColor : '(backgroundColor' - color - ')'; - -baselineJustify : '(baselineJustify' - ')'; - -becomes : '(becomes' - ( logicNameRef | logicList | logicOneOf ) - ')'; - -behaviorView : '(behaviorView' - viewNameDef - ( comment | nameInformation | userData - )* - ')'; - -bidirectional : '(bidirectional' - ')'; - -bidirectionalPort : '(bidirectionalPort' - ( bidirectionalPortAttributes )? - ')'; - -bidirectionalPortAttributes : '(bidirectionalPortAttributes' - ( dcFanInLoad | dcFanOutLoad | dcMaxFanIn | dcMaxFanOut )* - ')'; - -bitOrder : '(bitOrder' - ( lsbToMsb | msbToLsb ) - ')'; - -blue : scaledInteger; - -boldStyle : '(boldStyle' - ')'; - -eboolean : '(boolean' - booleanExpression - ')'; - -booleanConstant : '(booleanConstant' - constantNameDef - booleanToken - ')'; - -booleanConstantRef : '(booleanConstantRef' - constantNameRef - ')'; - -booleanExpression : ( and_ | booleanParameterRef | booleanToken | stringEqual | integerEqual | lessThan | lessThanOrEqual | not_ | or_ | xor_ | booleanConstantRef ) -; -booleanMap : '(booleanMap' - booleanValue - ')'; - -booleanParameter : '(booleanParameter' - parameterNameDef - ( eboolean | nameInformation )* - ')'; - -booleanParameterAssign : '(booleanParameterAssign' - parameterNameRef - booleanExpression - ')'; - -booleanParameterRef : '(booleanParameterRef' - parameterNameRef - ')'; - -booleanToken : ( efalse | etrue ); - -booleanValue : booleanToken; - -borderPattern : '(borderPattern' - pixelPattern - ')'; - -borderPatternVisible : '(borderPatternVisible' - booleanValue - ')'; - -borderWidth : '(borderWidth' - ( lengthValue | minimalWidth ) - ')'; - -bottomJustify : '(bottomJustify' - ')'; - -calculated : '(calculated' - ')'; - -candela : '(candela' - unitExponent - ')'; - -capacitanceValue : miNoMaxValue; - -caplineJustify : '(caplineJustify' - ')'; - -cell : '(cell' - libraryObjectNameDef - cellHeader - ( cluster | comment | userData | viewGroup )* - ')'; - -cellHeader : '(cellHeader' - ( documentation | nameInformation | property_ | status )* - - ')'; - -cellNameDisplay : '(cellNameDisplay' - ( display | displayNameOverride )* - ')'; - -cellPropertyDisplay : '(cellPropertyDisplay' - propertyNameRef - ( display | propertyNameDisplay )* - ')'; - -cellPropertyDisplayOverride : '(cellPropertyDisplayOverride' - propertyNameRef - ( addDisplay | replaceDisplay | removeDisplay ) - ( propertyNameDisplay )? - ')'; - -cellPropertyOverride : '(cellPropertyOverride' - propertyNameRef - ( typedValue | untyped ) - ( comment | fixed | propertyOverride )* - ')'; - -cellRef : '(cellRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -celsius : '(celsius' - unitExponent - ')'; - -centerJustify : '(centerJustify' - ')'; - -characterEncoding : '(characterEncoding' - ( ascii | iso8859 | jisx0201 | jisx0208 ) - ')'; - -checkDate : '(checkDate' - date - ')'; - -checkDateDisplay : '(checkDateDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -circle : '(circle' - pt1 - pt2 - ')'; - -cluster : '(cluster' - clusterNameDef - einterface - clusterHeader - ( schematicSymbol | schematicView | behaviorView | clusterConfiguration | comment | connectivityView | defaultClusterConfiguration | userData | logicModelView | maskLayoutView | pcbLayoutView | symbolicLayoutView )* - ')'; - -clusterConfiguration : '(clusterConfiguration' - clusterConfigurationNameDef - ( viewRef | leaf | unconfigured ) - ( comment | frameConfiguration | globalPortScope | nameInformation | instanceConfiguration | property_ | userData )* - ')'; - -clusterConfigurationNameCaseSensitive : '(clusterConfigurationNameCaseSensitive' - booleanToken - ')'; - -clusterConfigurationNameDef : nameDef; - -clusterConfigurationNameRef : nameRef; - -clusterConfigurationRef : '(clusterConfigurationRef' - clusterConfigurationNameRef - ')'; - -clusterHeader : '(clusterHeader' - ( documentation | nameInformation | property_ | status )* - ')'; - -clusterNameCaseSensitive : '(clusterNameCaseSensitive' - booleanToken - ')'; - -clusterNameDef : nameDef; - -clusterNameRef : nameRef; - -clusterPropertyDisplay : '(clusterPropertyDisplay' - propertyNameRef - ( display | propertyNameDisplay )* - ')'; - -clusterPropertyDisplayOverride : '(clusterPropertyDisplayOverride' - propertyNameRef - ( addDisplay | replaceDisplay | removeDisplay ) - ( propertyNameDisplay )? - ')'; - -clusterPropertyOverride : '(clusterPropertyOverride' - propertyNameRef - ( typedValue | untyped ) - ( comment | fixed | propertyOverride )* - ')'; - -clusterRef : '(clusterRef' - clusterNameRef - ( cellRef )? - ')'; - -color : '(color' - red - green - blue - ')'; - -comment : '(comment' - ( stringToken )* - ')'; - -commentGraphics : '(commentGraphics' - ( annotate | comment | figure | originalBoundingBox | propertyDisplay | userData )* - ')'; - -companyName : '(companyName' - stringToken - ')'; - -companyNameDisplay : '(companyNameDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -complementedName : '(complementedName' - ( complementedNamePart | nameDimension | namePartSeparator | simpleName )* - ')'; - -complementedNamePart : '(complementedNamePart' - ( complementedNamePart | namePartSeparator | simpleName )* - ')'; - -complexGeometry : '(complexGeometry' - geometryMacroRef - transform - ')'; - -complexName : '(complexName' - ( complementedNamePart | nameDimension | namePartSeparator | simpleName )* - ')'; - -compound : '(compound' - ( logicNameRef )* - ')'; - -condition : '(condition' - booleanExpression - ')'; - -conditionDisplay : '(conditionDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -connectedSignalIndexGenerator : '(connectedSignalIndexGenerator' - integerExpression - ')'; - -connectedSignalIndexGeneratorDisplay : '(connectedSignalIndexGeneratorDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -connectivityBus : '(connectivityBus' - interconnectNameDef - signalGroupRef - interconnectHeader - connectivityBusJoined - ( comment | connectivityBusSlice | connectivitySubBus | userData )* - ')'; - -connectivityBusJoined : '(connectivityBusJoined' - portJoined - ( connectivityRipperRef )* - ')'; - -connectivityBusSlice : '(connectivityBusSlice' - interconnectNameDef - signalGroupRef - interconnectHeader - connectivityBusJoined - ( comment | connectivityBusSlice | connectivitySubBus | userData )* - ')'; - -connectivityFrameStructure : '(connectivityFrameStructure' - connectivityFrameStructureNameDef - frameRef - ( comment | connectivityBus | connectivityFrameStructure | connectivityNet | connectivityRipper | timing | userData )* - ')'; - -connectivityFrameStructureNameDef : nameDef; - -connectivityNet : '(connectivityNet' - interconnectNameDef - signalRef - interconnectHeader - connectivityNetJoined - ( comment | connectivitySubNet | userData )* - ')'; - -connectivityNetJoined : '(connectivityNetJoined' - ( portJoined | joinedAsSignal ) - ( connectivityRipperRef )* - ')'; - -connectivityRipper : '(connectivityRipper' - connectivityRipperNameDef - ')'; - -connectivityRipperNameDef : nameDef; - -connectivityRipperNameRef : nameRef; - -connectivityRipperRef : '(connectivityRipperRef' - connectivityRipperNameRef - ')'; - -connectivityStructure : '(connectivityStructure' - ( comment | connectivityBus | connectivityFrameStructure | connectivityNet | connectivityRipper | localPortGroup | timing | userData )* - ')'; - -connectivitySubBus : '(connectivitySubBus' - interconnectNameDef - interconnectHeader - connectivityBusJoined - ( comment | connectivityBusSlice | connectivitySubBus | userData )* - ')'; - -connectivitySubNet : '(connectivitySubNet' - interconnectNameDef - interconnectHeader - connectivityNetJoined - ( comment | connectivitySubNet | userData )* - ')'; - -connectivityTagGenerator : '(connectivityTagGenerator' - stringExpression - ')'; - -connectivityTagGeneratorDisplay : '(connectivityTagGeneratorDisplay' - ( display )* - ')'; - -connectivityUnits : '(connectivityUnits' - ( setCapacitance | setTime )? - ')'; - -connectivityView : '(connectivityView' - viewNameDef - connectivityViewHeader - logicalConnectivity - connectivityStructure - ( comment | userData )* - ')'; - -connectivityViewHeader : '(connectivityViewHeader' - connectivityUnits - ( derivedFrom | documentation | nameInformation | previousVersion | property_ | status )* - ')'; - -constantNameDef : nameDef; - -constantNameRef : nameRef; - -constantValues : '(constantValues' - ( booleanConstant | integerConstant | stringConstant )* - ')'; - -contract : '(contract' - stringToken - ')'; - -contractDisplay : '(contractDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -copyright : '(copyright' - year - ( stringToken )* - ')'; - -copyrightDisplay : '(copyrightDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -cornerType : '(cornerType' - ( truncate | round_ | extend ) - ')'; - -coulomb : '(coulomb' - unitExponent - ')'; - -criticality : '(criticality' - integerValue - ')'; - -criticalityDisplay : '(criticalityDisplay' - ( display )* - ')'; - -currentMap : '(currentMap' - currentValue - ')'; - -currentValue : miNoMaxValue; - -curve : '(curve' - ( arc | pointValue )* - ')'; - -dataOrigin : '(dataOrigin' - stringToken - ( version )? - ')'; - -date : '(date' - yearNumber - monthNumber - dayNumber - ')'; - -dayNumber : integerToken; - -dcFanInLoad : '(dcFanInLoad' - numberValue - ')'; - -dcFanInLoadDisplay : '(dcFanInLoadDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -dcFanOutLoad : '(dcFanOutLoad' - numberValue - ')'; - -dcFanOutLoadDisplay : '(dcFanOutLoadDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -dcMaxFanIn : '(dcMaxFanIn' - numberValue - ')'; - -dcMaxFanInDisplay : '(dcMaxFanInDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -dcMaxFanOut : '(dcMaxFanOut' - numberValue - ')'; - -dcMaxFanOutDisplay : '(dcMaxFanOutDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -decimalToString : '(decimalToString' - integerExpression - ( minimumStringLength )? - ')'; - -defaultClusterConfiguration : '(defaultClusterConfiguration' - clusterConfigurationNameRef - ')'; - -defaultConnection : '(defaultConnection' - globalPortRef - ')'; - -degree : '(degree' - unitExponent - ')'; - -delay : '(delay' - timeDelay - ')'; - -denominator : integerValue; - -derivation : ( calculated | measured | required_ ); - -derivedFrom : '(derivedFrom' - viewRef - ( reason )? - ')'; - -design : '(design' - designNameDef - cellRef - designHeader - ( comment | designHierarchy | userData )* - ')'; - -designator : '(designator' - stringValue - ')'; - -designatorDisplay : '(designatorDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -designHeader : '(designHeader' - designUnits - ( documentation | nameInformation | property_ | status )* - ')'; - -designHierarchy : '(designHierarchy' - designHierarchyNameDef - clusterRef - clusterConfigurationRef - designHierarchyHeader - ( occurrenceHierarchyAnnotate )? - ')'; - -designHierarchyHeader : '(designHierarchyHeader' - ( booleanParameterAssign | integerParameterAssign | nameInformation | numberParameterAssign | property_ | stringParameterAssign )* - ')'; - -designHierarchyNameCaseSensitive : '(designHierarchyNameCaseSensitive' - booleanToken - ')'; - -designHierarchyNameDef : nameDef; - -designNameCaseSensitive : '(designNameCaseSensitive' - booleanToken - ')'; - -designNameDef : nameDef; - -designUnits : '(designUnits' - ( setCapacitance | setTime )* - ')'; - -diagram : '(diagram' - diagramNameDef - ( annotate | comment | figure | userData )* - ')'; - -diagramNameDef : nameDef; - -directionalPortAttributeOverride : '(directionalPortAttributeOverride' - ( inputPortAttributes | outputPortAttributes | bidirectionalPortAttributes ) - ')'; - -display : '(display' - ( figureGroupNameRef | figureGroupOverride )* - transform - ')'; - -displayAttributes : '(displayAttributes' - ( borderPattern | borderPatternVisible | borderWidth | color | fillPattern | fillPatternVisible | fontRef | horizontalJustification | textHeight | verticalJustification | visible )* - ')'; - -displayName : '(displayName' - stringToken - ')'; - -displayNameOverride : '(displayNameOverride' - stringToken - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -distanceValue : integerValue; - -dividend : integerExpression; - -divisor : integerExpression; - -documentation : '(documentation' - documentationNameDef - documentationHeader - ( section )* - ')'; - -documentationHeader : '(documentationHeader' - documentationUnits - ( backgroundColor | nameInformation | status )* - ')'; - -documentationNameCaseSensitive : '(documentationNameCaseSensitive' - booleanToken - ')'; - -documentationNameDef : nameDef; - -documentationUnits : '(documentationUnits' - ( setAngle | setDistance )* - ')'; - -dominates : '(dominates' - ( logicNameRef )* - ')'; - -dot : '(dot' - pointValue - ')'; - -drawingDescription : '(drawingDescription' - stringToken - ')'; - -drawingDescriptionDisplay : '(drawingDescriptionDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -drawingIdentification : '(drawingIdentification' - stringToken - ')'; - -drawingIdentificationDisplay : '(drawingIdentificationDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -drawingSize : '(drawingSize' - stringToken - ')'; - -drawingSizeDisplay : '(drawingSizeDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -duration : '(duration' - timeValue - ')'; - -e : '(e' - mantissa - exponent - ')'; - -edif : '(edif' - edifNameDef - edifVersion - edifHeader - ( library_ | design | comment | external_ | userData )* - ')'; - -edifHeader : '(edifHeader' - edifLevel - keywordMap - unitDefinitions - fontDefinitions - physicalDefaults - ( characterEncoding | constantValues | documentation | globalPortDefinitions | nameCaseSensitivity | nameInformation | physicalScaling | property_ | status )* - ')'; - -edifLevel : '(edifLevel' - edifLevelValue - ')'; - - -edifLevelValue : integerToken; - -edifNameDef : nameDef; - -edifVersion : '(edifVersion' - mark - issue - subIssue - ')'; - -endPoint : pointValue; - -endType : '(endType' - ( truncate | round_ | extend ) - ')'; - -engineeringDate : '(engineeringDate' - date - ')'; - -engineeringDateDisplay : '(engineeringDateDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -event : '(event' - ( portRef | portList | portSet | interconnectRef | interconnectSet ) - ( becomes | transition )* - ')'; - -exponent : integerToken; - -extend : '(extend' - ')'; - -extendForFrameMemberDef : forFrameMemberRef; - -extendFrameDef : frameNameRef; - -extendInstanceDef : instanceNameRef; - -extendInstanceMemberDef : instanceMemberRef; - -extendInterconnectDef : interconnectNameRef; - -extendPageDef : pageNameRef; - -extendPortDef : portNameRef; - -extendPortMemberDef : portMemberRef; - -extendSignalDef : signalNameRef; - -extendSignalGroupDef : signalGroupNameRef; - -extendSignalMemberDef : signalMemberRef; - -external_ : '(external' - libraryNameDef - libraryHeader - ( cell | comment | geometryMacro | pageBorderTemplate | pageTitleBlockTemplate | schematicFigureMacro | schematicForFrameBorderTemplate | schematicGlobalPortTemplate | schematicIfFrameBorderTemplate | schematicInterconnectTerminatorTemplate | schematicJunctionTemplate | schematicMasterPortTemplate | schematicOffPageConnectorTemplate | schematicOnPageConnectorTemplate | schematicOtherwiseFrameBorderTemplate | schematicRipperTemplate | schematicSymbolBorderTemplate | schematicSymbolPortTemplate | userData )* - ')'; - -fahrenheit : '(fahrenheit' - unitExponent - ')'; - -efalse : '(false' - ')'; - -farad : '(farad' - unitExponent - ')'; - -figure : '(figure' - ( figureGroupNameRef | figureGroupOverride ) - ( circle | comment | complexGeometry | dot | openShape | path | polygon | rectangle | shape | userData )* - ')'; - -figureGroup : '(figureGroup' - figureGroupNameDef - ( comment | cornerType | displayAttributes | endType | nameInformation | pathWidth | property_ | userData )* - ')'; - -figureGroupNameCaseSensitive : '(figureGroupNameCaseSensitive' - booleanToken - ')'; - -figureGroupNameDef : nameDef; - -figureGroupNameRef : nameRef; - -figureGroupOverride : '(figureGroupOverride' - figureGroupNameRef - ( comment | cornerType | displayAttributes | endType | pathWidth | propertyOverride )* - ')'; - -fillPattern : '(fillPattern' - pixelPattern - ')'; - -fillPatternVisible : '(fillPatternVisible' - booleanValue - ')'; - -firstIntegerExpression : integerExpression; - -firstStringExpression : stringExpression; - -fixed : '(fixed' - ')'; - -font : '(font' - fontNameDef - typeface - fontProportions - ( boldStyle | italicStyle | property_ | proportionalFont | userData )* - ')'; - -fontCapitalHeight : '(fontCapitalHeight' - lengthValue - ')'; - -fontDefinitions : '(fontDefinitions' - ( fonts )? - ')'; - -fontDescent : '(fontDescent' - lengthValue - ')'; - -fontFamily : stringToken; - -fontHeight : '(fontHeight' - lengthValue - ')'; - -fontNameDef : nameDef; - -fontNameRef : nameRef; - -fontProportions : '(fontProportions' - fontHeight - fontDescent - fontCapitalHeight - fontWidth - ')'; - -fontRef : '(fontRef' - fontNameRef - ')'; - -fonts : '(fonts' - setDistance - ( font )* - ')'; - -fontWidth : '(fontWidth' - lengthValue - ')'; - -forbiddenEvent : '(forbiddenEvent' - timeInterval - ( event )* - ')'; - -forFrame : '(forFrame' - frameNameDef - repetitionCount - forFrameIndex - logicalConnectivity - ( comment | documentation | nameInformation | property_ | userData )* - ')'; - -forFrameAnnotate : '(forFrameAnnotate' - extendForFrameMemberDef - ( comment | forFrameAnnotate | ifFrameAnnotate | interconnectAnnotate | leafOccurrenceAnnotate | occurrenceAnnotate | otherwiseFrameAnnotate )* - ')'; - -forFrameIndex : '(forFrameIndex' - indexNameDef - ( indexStart | indexStep | nameInformation )* - ')'; - -forFrameIndexDisplay : '(forFrameIndexDisplay' - ( indexEndDisplay | indexNameDisplay | indexStartDisplay | indexStepDisplay )* - ')'; - -forFrameIndexNameCaseSensitive : '(forFrameIndexNameCaseSensitive' - booleanToken - ')'; - -forFrameIndexRef : '(forFrameIndexRef' - indexNameRef - ')'; - -forFrameMemberRef : '(forFrameMemberRef' - frameNameRef - indexValue - ')'; - -forFrameRef : '(forFrameRef' - frameNameRef - ')'; - -frameConfiguration : '(frameConfiguration' - frameNameRef - ( frameConfiguration | instanceConfiguration )* - ')'; - -frameNameCaseSensitive : '(frameNameCaseSensitive' - booleanToken - ')'; - -frameNameDef : nameDef; - -frameNameRef : nameRef; - -frameRef : '(frameRef' - frameNameRef - ')'; - -frequencyValue : miNoMaxValue; - -fromBottom : '(fromBottom' - ')'; - -fromInteger : integerToken; - -fromLeft : '(fromLeft' - ')'; - -fromRight : '(fromRight' - ')'; - -fromTop : '(fromTop' - ')'; - -generated : '(generated' - ')'; - -geometryMacro : '(geometryMacro' - libraryObjectNameDef - geometryMacroHeader - ( circle | comment | complexGeometry | dot | openShape | path | polygon | rectangle | shape | userData )* - ')'; - -geometryMacroHeader : '(geometryMacroHeader' - geometryMacroUnits - ( backgroundColor | documentation | nameInformation | originalBoundingBox | property_ | status )* - ')'; - -geometryMacroRef : '(geometryMacroRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -geometryMacroUnits : '(geometryMacroUnits' - ( setAngle )? - ')'; - -globalPort : '(globalPort' - globalPortNameDef - ( comment | nameInformation | property_ | schematicGlobalPortAttributes | userData )* - ')'; - -globalPortBundle : '(globalPortBundle' - globalPortNameDef - globalPortList - ( comment | nameInformation | property_ | userData )* - ')'; - -globalPortDefinitions : '(globalPortDefinitions' - ( globalPort | globalPortBundle )* - ')'; - -globalPortList : '(globalPortList' - ( globalPortRef )* - ')'; - -globalPortNameCaseSensitive : '(globalPortNameCaseSensitive' - booleanToken - ')'; - -globalPortNameDef : nameDef; - -globalPortNameDisplay : '(globalPortNameDisplay' - ( display | displayNameOverride )* - ')'; - -globalPortNameRef : nameRef; - -globalPortPropertyDisplay : '(globalPortPropertyDisplay' - propertyNameRef - ( display | propertyNameDisplay )* - ')'; - -globalPortRef : '(globalPortRef' - globalPortNameRef - ')'; - -globalPortScope : '(globalPortScope' - globalPortNameRef - ')'; - -green : scaledInteger; - -henry : '(henry' - unitExponent - ')'; - -hertz : '(hertz' - unitExponent - ')'; - -horizontalJustification : '(horizontalJustification' - ( leftJustify | centerJustify | rightJustify ) - ')'; - -hotspot : '(hotspot' - pointValue - ( hotspotConnectDirection | hotspotNameDisplay | nameInformation | schematicWireAffinity )* - ')'; - -hotspotConnectDirection : '(hotspotConnectDirection' - ( fromBottom | fromLeft | fromRight | fromTop )* - ')'; - -hotspotGrid : '(hotspotGrid' - lengthValue - ')'; - -hotspotNameCaseSensitive : '(hotspotNameCaseSensitive' - booleanToken - ')'; - -hotspotNameDef : nameDef; - -hotspotNameDisplay : '(hotspotNameDisplay' - ( display | displayNameOverride )* - ')'; - -hotspotNameRef : nameRef; - -hourNumber : integerToken; - -ieeeDesignation : stringToken; - -ieeeSection : '(ieeeSection' - ( integerToken )* - ')'; - -ieeeStandard : '(ieeeStandard' - ieeeDesignation - year - ( comment |ieeeSection )* - ')'; - -ifFrame : '(ifFrame' - frameNameDef - condition - logicalConnectivity - ( comment | nameInformation | documentation | property_ | userData )* - ')'; - -ifFrameAnnotate : '(ifFrameAnnotate' - extendFrameDef - ( comment | forFrameAnnotate | ifFrameAnnotate | interconnectAnnotate | leafOccurrenceAnnotate | occurrenceAnnotate | otherwiseFrameAnnotate | propertyOverride )* - ')'; - -ifFrameRef : '(ifFrameRef' - frameNameRef - ')'; - -ifFrameSet : '(ifFrameSet' - ( ifFrameRef )* - ')'; - -ignore : '(ignore' - ')'; - -implementationNameCaseSensitive : '(implementationNameCaseSensitive' - booleanToken - ')'; - -implementationNameDef : nameDef; - -implementationNameDisplay : '(implementationNameDisplay' - ( display | displayNameOverride )* - ')'; - -implementationNameRef : nameRef; - -indexEndDisplay : '(indexEndDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -indexNameDef : nameDef; - -indexNameDisplay : '(indexNameDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -indexNameRef : nameRef; - -indexStart : '(indexStart' - integerExpression - ')'; - -indexStartDisplay : '(indexStartDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -indexStep : '(indexStep' - integerExpression - ')'; - -indexStepDisplay : '(indexStepDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -indexValue : '(indexValue' - integerToken - ')'; - -input_ : '(input' - ')'; - -inputPort : '(inputPort' - ( inputPortAttributes )? - ')'; - -inputPortAttributes : '(inputPortAttributes' - ( dcFanOutLoad | dcMaxFanIn )* - ')'; - -instance : '(instance' - instanceNameDef - clusterRef - ( booleanParameterAssign | cellPropertyOverride | clusterPropertyOverride | comment | designator | instanceNameGenerator | instancePortAttributes | instanceWidth | integerParameterAssign | nameInformation | numberParameterAssign | property_ | stringParameterAssign | timing | userData )* - ')'; - -instanceConfiguration : '(instanceConfiguration' - instanceNameRef - clusterConfigurationRef - ')'; - -instanceIndexValue : '(instanceIndexValue' - ')'; - -instanceMemberRef : '(instanceMemberRef' - instanceNameRef - indexValue - ')'; - -instanceNameCaseSensitive : '(instanceNameCaseSensitive' - booleanToken - ')'; - -instanceNameDef : nameDef; - -instanceNameDisplay : '(instanceNameDisplay' - ( display | displayNameOverride )* - ')'; - -instanceNameGenerator : '(instanceNameGenerator' - stringExpression - ')'; - -instanceNameGeneratorDisplay : '(instanceNameGeneratorDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -instanceNameRef : nameRef; - -instancePortAttributeDisplay : '(instancePortAttributeDisplay' - symbolPortImplementationNameRef - portRef - ( portPropertyDisplayOverride | portAttributeDisplay )* - ')'; - -instancePortAttributes : '(instancePortAttributes' - extendPortDef - ( acLoad | comment | connectedSignalIndexGenerator | designator | directionalPortAttributeOverride | portDelay | portDelayOverride | portLoadDelay | portLoadDelayOverride | portPropertyOverride | property_ | unused )* - ')'; - -instancePropertyDisplay : '(instancePropertyDisplay' - propertyNameRef - ( display )* - ( propertyNameDisplay )? - ( display )* - ')'; - -instancePropertyOverride : '(instancePropertyOverride' - propertyNameRef - ( typedValue | untyped ) - ( comment | fixed | propertyOverride )* - ')'; - -instanceRef : '(instanceRef' - instanceNameRef - ')'; - -instanceWidth : '(instanceWidth' - integerExpression - ')'; - -instanceWidthDisplay : '(instanceWidthDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -integer : '(integer' - integerExpression - ')'; - -integerConstant : '(integerConstant' - constantNameDef - integerToken - ')'; - -integerConstantRef : '(integerConstantRef' - constantNameRef - ')'; - -integerEqual : '(integerEqual' - firstIntegerExpression - secondIntegerExpression - ')'; - -integerExpression : ( integerParameterRef | integerToken | integerProduct | integerSubtract | integerSum | integerRemainder | integerQuotient | stringLength | integerConstantRef | forFrameIndexRef | portIndexValue | signalIndexValue | absolute | instanceIndexValue ) -; -integerParameter : '(integerParameter' - parameterNameDef - ( integer | nameInformation )* - ')'; - -integerParameterAssign : '(integerParameterAssign' - parameterNameRef - integerExpression - ')'; - -integerParameterRef : '(integerParameterRef' - parameterNameRef - ')'; - -integerProduct : '(integerProduct' - ( integerExpression )* - ')'; - -integerQuotient : '(integerQuotient' - dividend - divisor - ')'; - -integerRemainder : '(integerRemainder' - dividend - divisor - ')'; - -integerSubtract : '(integerSubtract' - minuend - subtrahend - ')'; - -integerSum : '(integerSum' - ( integerExpression )* - ')'; - -integerValue : integerToken; - -interconnectAnnotate : '(interconnectAnnotate' - extendInterconnectDef - ( comment | interconnectAnnotate | criticality | interconnectDelay | property_ | propertyOverride )* - ')'; - -interconnectAttachedText : '(interconnectAttachedText' - attachmentPoint - ( annotate | connectivityTagGeneratorDisplay | criticalityDisplay | interconnectDelayDisplay | interconnectNameDisplay | interconnectPropertyDisplay )* - ')'; - -interconnectDelay : '(interconnectDelay' - interconnectDelayNameDef - derivation - delay - ( becomes | transition )* - ')'; - -interconnectDelayDisplay : '(interconnectDelayDisplay' - interconnectDelayNameRef - ( display )* - ')'; - -interconnectDelayNameDef : nameDef; - -interconnectDelayNameRef : nameRef; - -interconnectHeader : '(interconnectHeader' - ( criticality | documentation | interconnectDelay | nameInformation | property_ )* - ')'; - -interconnectNameCaseSensitive : '(interconnectNameCaseSensitive' - booleanToken - ')'; - -interconnectNameDef : nameDef; - -interconnectNameDisplay : '(interconnectNameDisplay' - ( display | displayNameOverride )* - ')'; - -interconnectNameRef : nameRef; - -interconnectPropertyDisplay : '(interconnectPropertyDisplay' - propertyNameRef - ( display )* - ( propertyNameDisplay )? - ( display )* - ')'; - -interconnectRef : '(interconnectRef' - interconnectNameRef - ( pageRef )? - ')'; - -interconnectSet : '(interconnectSet' - ( interconnectRef )* - ')'; - -einterface : '(interface' - interfaceUnits - ( designator | booleanParameter | integerParameter | interfaceJoined | mustJoin | numberParameter | permutable | port | portBundle | stringParameter | timing | weakJoined )* - ')'; - -interfaceJoined : '(interfaceJoined' - ( portRef )* - ')'; - -interfaceUnits : '(interfaceUnits' - ( setCapacitance | setTime )* - ')'; - -iso8859 : '(iso8859' - iso8859Part - ')'; - -iso8859Part : integerToken; - -isolated : '(isolated' - ')'; - -issue : integerToken; - -italicStyle : '(italicStyle' - ')'; - -jisx0201 : '(jisx0201' - ')'; - -jisx0208 : '(jisx0208' - ')'; - -joinedAsSignal : '(joinedAsSignal' - ')'; - -joule : '(joule' - unitExponent - ')'; - -k0KeywordLevel : '(k0KeywordLevel' - ')'; - -k1KeywordAlias : '(k1KeywordAlias' - k1KeywordNameDef - k1KeywordNameRef - ')'; - -k1KeywordLevel : '(k1KeywordLevel' - ( k1KeywordAlias )* - ')'; - -k1KeywordNameDef : IDENTIFIER; - -k1KeywordNameRef : IDENTIFIER; - -k2Actual : '(k2Actual' - k2FormalNameRef - ')'; - -k2Build : '(k2Build' - k1KeywordNameRef - ( comment | k2Actual | k2Build | k2Literal )* - ')'; - -k2Formal : '(k2Formal' - k2FormalNameDef - ( k2Optional | k2Required ) - ')'; - -k2FormalNameDef : IDENTIFIER; - -k2FormalNameRef : IDENTIFIER; - -k2Generate : '(k2Generate' - ( comment | k2Actual | k2Build | k2Literal )* - ')'; - -k2KeywordDefine : '(k2KeywordDefine' - k1KeywordNameDef - k2KeywordParameters - k2Generate - ')'; - -k2KeywordLevel : '(k2KeywordLevel' - ( k1KeywordAlias | k2KeywordDefine )* - ')'; -k2KeywordParameters : '(k2KeywordParameters' - ( k2Formal )* - ')'; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -k2Literal : '(k2Literal' - ( IDENTIFIER | integerToken | stringToken )* - ')'; - -k2Optional : '(k2Optional' - ( k2Literal | k2Actual | k2Build ) - ')'; - -k2Required : '(k2Required' - ')'; - -k3Build : '(k3Build' - k1KeywordNameRef - ( comment | k2Actual | k2Literal | k3Build | k3ForEach )* - ')'; - -k3Collector : '(k3Collector' - ')'; - -k3ForEach : '(k3ForEach' - ( k2FormalNameRef | k3FormalList ) - ( comment | k2Actual | k2Literal | k3Build | k3ForEach )* - ')'; - -k3Formal : '(k3Formal' - k2FormalNameDef - ( k2Optional | k2Required | k3Collector ) - ')'; - -k3FormalList : '(k3FormalList' - ( k2FormalNameRef )* - ')'; - -k3Generate : '(k3Generate' - ( comment | k2Actual | k2Build | k2Literal | k3ForEach )* - ')'; - -k3KeywordDefine : '(k3KeywordDefine' - k1KeywordNameDef - k3KeywordParameters - k3Generate - ')'; - -k3KeywordLevel : '(k3KeywordLevel' - ( k1KeywordAlias | k3KeywordDefine )* - ')'; - -k3KeywordParameters : '(k3KeywordParameters' - ( k3Formal )* - ')'; - -kelvin : '(kelvin' - unitExponent - ')'; - -keywordMap : '(keywordMap' - ( k0KeywordLevel | k1KeywordLevel | k2KeywordLevel | k3KeywordLevel ) - ( comment )* - ')'; - -kilogram : '(kilogram' - unitExponent - ')'; - -leaf : '(leaf' - ')'; - -leafOccurrenceAnnotate : '(leafOccurrenceAnnotate' - ( extendInstanceDef | extendInstanceMemberDef ) - ( cellPropertyOverride | clusterPropertyOverride | comment | designator | instancePropertyOverride | portAnnotate | property_ )* - ')'; - -leftJustify : '(leftJustify' - ')'; - -lengthValue : distanceValue; - -lessThan : '(lessThan' - ( integerExpression )* - ')'; - -lessThanOrEqual : '(lessThanOrEqual' - ( integerExpression )* - ')'; - -library_ : '(library' - libraryNameDef - libraryHeader - ( cell | schematicInterconnectTerminatorTemplate | schematicJunctionTemplate | schematicGlobalPortTemplate | schematicMasterPortTemplate | schematicOffPageConnectorTemplate | schematicOnPageConnectorTemplate | schematicRipperTemplate | schematicSymbolBorderTemplate | schematicSymbolPortTemplate | pageBorderTemplate | pageTitleBlockTemplate | comment | geometryMacro | schematicFigureMacro | schematicForFrameBorderTemplate | schematicIfFrameBorderTemplate | schematicOtherwiseFrameBorderTemplate | userData )* - ')'; - -libraryHeader : '(libraryHeader' - edifLevel - nameCaseSensitivity - technology - ( backgroundColor | documentation | nameInformation | property_ | status )* - ')'; - -libraryNameCaseSensitive : '(libraryNameCaseSensitive' - booleanToken - ')'; - -libraryNameDef : nameDef; - -libraryNameRef : nameRef; - -libraryObjectNameCaseSensitive : '(libraryObjectNameCaseSensitive' - booleanToken - ')'; - -libraryObjectNameDef : nameDef; - -libraryObjectNameRef : nameRef; - -libraryRef : '(libraryRef' - libraryNameRef - ')'; - -loadDelay : '(loadDelay' - acLoadFactorTime - acLoadFactorCapacitance - ')'; - -localPortGroup : '(localPortGroup' - localPortGroupNameDef - portList - ( comment | nameInformation | property_ | userData )* - ')'; - -localPortGroupNameCaseSensitive : '(localPortGroupNameCaseSensitive' - booleanToken - ')'; - -localPortGroupNameDef : nameDef; - -localPortGroupNameRef : nameRef; - -localPortGroupRef : '(localPortGroupRef' - localPortGroupNameRef - ')'; - -logicalConnectivity : '(logicalConnectivity' - ( comment | forFrame | ifFrame | instance | otherwiseFrame | signal | signalGroup | userData )* - ')'; - -logicDefinitions : '(logicDefinitions' - setVoltage - setCurrent - ( comment | logicValue )* - ')'; - -logicList : '(logicList' - ( ignore | logicNameRef | logicOneOf )* - ')'; - -logicMapInput : '(logicMapInput' - ( logicRef )* - ')'; - -logicMapOutput : '(logicMapOutput' - ( logicRef )* - ')'; - -logicModelUnits : '(logicModelUnits' - ( setCapacitance | setTime )* - ')'; - -logicModelView : '(logicModelView' - viewNameDef - ( comment | nameInformation | userData )* - ')'; - -logicNameDef : nameDef; - -logicNameRef : nameRef; - -logicOneOf : '(logicOneOf' - ( logicList | logicNameRef )* - ')'; - -logicRef : '(logicRef' - logicNameRef - ( libraryRef )? - ')'; - -logicValue : '(logicValue' - logicNameDef - ( booleanMap | comment | compound | currentMap | dominates | isolated | logicMapInput | logicMapOutput | nameInformation | property_ | resolves | strong | voltageMap | weak_ )* - ')'; - -lsbToMsb : '(lsbToMsb' - ')'; - -mantissa : integerToken; - -mark : integerToken; - -maskLayoutUnits : '(maskLayoutUnits' - ( setAngle | setCapacitance | setDistance | setTime )* - ')'; - -maskLayoutView : '(maskLayoutView' - viewNameDef - ( comment | nameInformation | userData )* - ')'; - -measured : '(measured' - ')'; - -meter : '(meter' - unitExponent - ')'; - -middleJustify : '(middleJustify' - ')'; - -minimalWidth : '(minimalWidth' - ')'; - -minimumStringLength : '(minimumStringLength' - substringLength - ')'; - -miNoMax : '(miNoMax' - miNoMaxValue - ')'; - -miNoMaxValue : ( numberValue | mnm ); - -minuend : integerExpression; - -minuteNumber : integerToken; - -mixedDirection : '(mixedDirection' - ')'; - -mnm : '(mnm' - ( numberValue | undefined | unconstrained ) - ( numberValue | undefined | unconstrained ) - ( numberValue | undefined | unconstrained ) - ')'; - -mole : '(mole' - unitExponent - ')'; - -monthNumber : integerToken; - -msbToLsb : '(msbToLsb' - ')'; - -mustJoin : '(mustJoin' - ( interfaceJoined | portRef | weakJoined )* - ')'; - -nameAlias : '(nameAlias' - originalName - ( displayName | generated | nameStructure )* - ')'; - -nameCaseSensitivity : '(nameCaseSensitivity' - ( clusterConfigurationNameCaseSensitive | clusterNameCaseSensitive | designHierarchyNameCaseSensitive | designNameCaseSensitive | documentationNameCaseSensitive | figureGroupNameCaseSensitive | forFrameIndexNameCaseSensitive | frameNameCaseSensitive | globalPortNameCaseSensitive | hotspotNameCaseSensitive | implementationNameCaseSensitive | instanceNameCaseSensitive | interconnectNameCaseSensitive | libraryNameCaseSensitive | libraryObjectNameCaseSensitive | localPortGroupNameCaseSensitive | pageNameCaseSensitive | parameterNameCaseSensitive | portNameCaseSensitive | propertyNameCaseSensitive | signalGroupNameCaseSensitive | signalNameCaseSensitive | viewGroupNameCaseSensitive | viewNameCaseSensitive )* - ')'; - -nameDef : IDENTIFIER; - -nameDimension : '(nameDimension' - nameDimensionStructure - ( bitOrder )? - ')'; - -nameDimensionStructure : '(nameDimensionStructure' - ( complementedName | complexName | integerValue | sequence | simpleName )* - ')'; - -nameInformation : '(nameInformation' - primaryName - ( nameAlias )* - ')'; - -namePartSeparator : '(namePartSeparator' - stringToken - ')'; - -nameRef : IDENTIFIER; - -nameStructure : '(nameStructure' - ( simpleName | complexName | complementedName ) - ')'; - -narrowPort : '(narrowPort' - ')'; - -narrowWire : '(narrowWire' - ')'; - -noHotspotGrid : '(noHotspotGrid' - ')'; - -nominalHotspotGrid : '(nominalHotspotGrid' - lengthValue - ')'; - -nonPermutable : '(nonPermutable' - ( permutable | portRef )* - ')'; - -not_ : '(not' - booleanExpression - ')'; - -notInherited : '(notInherited' - ')'; - -number : '(number' - numberExpression - ')'; - -numberExpression : ( numberValue | numberParameterRef ); - -numberOfBasicUnits : scaledInteger; - -numberOfNewUnits : scaledInteger; - -numberParameter : '(numberParameter' - parameterNameDef - ( nameInformation | number )* - ')'; - -numberParameterAssign : '(numberParameterAssign' - parameterNameRef - numberExpression - ')'; - -numberParameterRef : '(numberParameterRef' - parameterNameRef - ')'; - -numberPoint : '(numberPoint' - xNumberValue - yNumberValue - ')'; - -numberValue : scaledInteger; - -numerator : integerValue; - -occurrenceAnnotate : '(occurrenceAnnotate' - ( extendInstanceDef | extendInstanceMemberDef ) - ( cellPropertyOverride | clusterPropertyOverride | comment | designator | forFrameAnnotate | ifFrameAnnotate | instancePropertyOverride | interconnectAnnotate | leafOccurrenceAnnotate | occurrenceAnnotate | otherwiseFrameAnnotate | pageAnnotate | portAnnotate | property_ | signalAnnotate | signalGroupAnnotate | timing | viewPropertyOverride )* - ')'; - -occurrenceHierarchyAnnotate : '(occurrenceHierarchyAnnotate' - ( cellPropertyOverride | clusterPropertyOverride | comment | forFrameAnnotate | ifFrameAnnotate | interconnectAnnotate | leafOccurrenceAnnotate | occurrenceAnnotate | otherwiseFrameAnnotate | pageAnnotate | portAnnotate | signalAnnotate | signalGroupAnnotate | timing | viewPropertyOverride )* - ')'; - -offsetEvent : '(offsetEvent' - event - numberValue - ')'; - -ohm : '(ohm' - unitExponent - ')'; - -openShape : '(openShape' - curve - ')'; - -or_ : '(or' - ( booleanExpression )* - ')'; - -origin : '(origin' - pointValue - ')'; - -originalBoundingBox : '(originalBoundingBox' - rectangle - ')'; - -originalDrawingDate : '(originalDrawingDate' - date - ')'; - -originalDrawingDateDisplay : '(originalDrawingDateDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -originalName : stringToken; - -otherwiseFrame : '(otherwiseFrame' - frameNameDef - ifFrameSet - logicalConnectivity - ( comment | documentation | nameInformation | property_ | userData )* - ')'; - -otherwiseFrameAnnotate : '(otherwiseFrameAnnotate' - extendFrameDef - ( comment | forFrameAnnotate | ifFrameAnnotate | interconnectAnnotate | leafOccurrenceAnnotate | occurrenceAnnotate | otherwiseFrameAnnotate | propertyOverride )* - ')'; - -otherwiseFrameRef : '(otherwiseFrameRef' - frameNameRef - ')'; - -output : '(output' - ')'; - -outputPort : '(outputPort' - ( outputPortAttributes )? - ')'; - -outputPortAttributes : '(outputPortAttributes' - ( dcFanInLoad | dcMaxFanOut )* - ')'; - -owner : '(owner' - stringValue - ')'; - -page : '(page' - pageNameDef - pageHeader - ( cellPropertyDisplay | clusterPropertyDisplay | comment | localPortGroup | pageCommentGraphics | pageTitleBlock | propertyDisplay | schematicBus | schematicForFrameImplementation | schematicGlobalPortImplementation | schematicIfFrameImplementation | schematicInstanceImplementation | schematicMasterPortImplementation | schematicNet | schematicOffPageConnectorImplementation | schematicOnPageConnectorImplementation | schematicOtherwiseFrameImplementation | schematicRipperImplementation | userData | viewPropertyDisplay )* - ')'; - -pageAnnotate : '(pageAnnotate' - extendPageDef - ( interconnectAnnotate )* - ')'; - -pageBorder : '(pageBorder' - pageBorderTemplateRef - transform - ( propertyDisplayOverride | propertyOverride )* - ')'; - -pageBorderTemplate : '(pageBorderTemplate' - libraryObjectNameDef - schematicTemplateHeader - usableArea - ( annotate | commentGraphics | figure | propertyDisplay | schematicComplexFigure )* - ')'; - -pageBorderTemplateRef : '(pageBorderTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -pageCommentGraphics : '(pageCommentGraphics' - ( annotate | comment | figure | schematicComplexFigure | userData )* - ')'; - -pageHeader : '(pageHeader' - ( backgroundColor | documentation | nameInformation | originalBoundingBox | pageBorder | pageSize | property_ | status )* - ')'; - -pageIdentification : '(pageIdentification' - stringToken - ')'; - -pageIdentificationDisplay : '(pageIdentificationDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -pageNameCaseSensitive : '(pageNameCaseSensitive' - booleanToken - ')'; - -pageNameDef : nameDef; - -pageNameRef : nameRef; - -pagePropertyDisplay : '(pagePropertyDisplay' - propertyNameRef - ( display | propertyNameDisplay)* - ')'; - -pageRef : '(pageRef' - pageNameRef - ')'; - -pageSize : '(pageSize' - rectangle - ')'; - -pageTitle : '(pageTitle' - stringToken - ')'; - -pageTitleBlock : '(pageTitleBlock' - implementationNameDef - pageTitleBlockTemplateRef - transform - ( nameInformation | pagePropertyDisplay | pageTitleBlockAttributeDisplay | pageTitleBlockAttributes | property_ | propertyDisplay | propertyDisplayOverride | propertyOverride )* - ')'; - -pageTitleBlockAttributeDisplay : '(pageTitleBlockAttributeDisplay' - ( approvedDateDisplay | checkDateDisplay | companyNameDisplay | contractDisplay | copyrightDisplay | drawingDescriptionDisplay | drawingIdentificationDisplay | drawingSizeDisplay | engineeringDateDisplay | originalDrawingDateDisplay | pageIdentificationDisplay | pageTitleDisplay | revisionDisplay | totalPagesDisplay )* - ')'; - -pageTitleBlockAttributes : '(pageTitleBlockAttributes' - ( approvedDate | checkDate | companyName | contract | drawingDescription | drawingIdentification | drawingSize | engineeringDate | originalDrawingDate | pageIdentification | pageTitle | revision )* - ')'; - -pageTitleBlockTemplate : '(pageTitleBlockTemplate' - libraryObjectNameDef - schematicTemplateHeader - ( annotate | commentGraphics | figure | pageTitleBlockAttributeDisplay | pageTitleBlockAttributes | propertyDisplay | schematicComplexFigure )* - ')'; - -pageTitleBlockTemplateRef : '(pageTitleBlockTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -pageTitleDisplay : '(pageTitleDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -parameterDisplay : '(parameterDisplay' - parameterNameRef - ( addDisplay | replaceDisplay | removeDisplay ) - ( parameterNameDisplay )? - ')'; - -parameterNameCaseSensitive : '(parameterNameCaseSensitive' - booleanToken - ')'; - -parameterNameDef : nameDef; - -parameterNameDisplay : '(parameterNameDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -parameterNameRef : nameRef; - -path : '(path' - pointList - ')'; - -pathDelay : '(pathDelay' - delay - ( event )* - ')'; - -pathWidth : '(pathWidth' - ( lengthValue | minimalWidth ) - ')'; - -pcbLayoutUnits : '(pcbLayoutUnits' - ( setAngle | setCapacitance | setDistance | setTime )* - ')'; - -pcbLayoutView : '(pcbLayoutView' - viewNameDef - ( comment | nameInformation | userData )* - ')'; - -permutable : '(permutable' - ( nonPermutable | permutable | portRef )* - ')'; - -physicalDefaults : '(physicalDefaults' - ( schematicRequiredDefaults )? - ')'; - -physicalScaling : '(physicalScaling' - ( comment | connectivityUnits | documentationUnits | geometryMacroUnits | interfaceUnits | logicModelUnits | maskLayoutUnits | pcbLayoutUnits | schematicUnits | symbolicLayoutUnits )* - ')'; - -pixelPattern : '(pixelPattern' - rowSize - ( pixelRow )* - ')'; - -pixelRow : '(pixelRow' - ( booleanToken )* - ')'; - -point : '(point' - pointValue - ')'; - -pointList : '(pointList' - ( pointValue )* - ')'; - -pointValue : pt; - -polygon : '(polygon' - pointList - ')'; - -port : '(port' - portNameDef? - portDirection? - ( acLoad | comment | defaultConnection | designator | nameInformation | portDelay | portLoadDelay | portNameGenerator | portWidth | property_ | schematicPortAttributes | unused | userData )* - ')'; - -portAnnotate : '(portAnnotate' - ( extendPortDef | extendPortMemberDef ) - ( acLoad | comment | designator | directionalPortAttributeOverride | portDelay | portDelayOverride | portLoadDelay | portLoadDelayOverride | portPropertyOverride | property_ )* - ')'; - -portAttributeDisplay : '(portAttributeDisplay' - ( acLoadDisplay | connectedSignalIndexGeneratorDisplay | dcFanInLoadDisplay | dcFanOutLoadDisplay | dcMaxFanInDisplay | dcMaxFanOutDisplay | designatorDisplay | portDelayDisplay | portLoadDelayDisplay | portNameDisplay | portNameGeneratorDisplay | portPropertyDisplay )* - ')'; - -portBundle : '(portBundle' - portNameDef - portList - ( comment | nameInformation | property_ | userData | designator)* - ')'; - -portDelay : '(portDelay' - portDelayNameDef - derivation - delay - ( becomes | transition )* - ')'; - -portDelayDisplay : '(portDelayDisplay' - portDelayNameRef - ( display )* - ')'; - -portDelayNameDef : nameDef; - -portDelayNameRef : nameRef; - -portDelayOverride : '(portDelayOverride' - portDelayNameRef - derivation - delay - ( becomes | transition )* - ')'; - -portDirection : ( inputPort | outputPort | bidirectionalPort | unspecifiedDirectionPort ); - -portDirectionIndicator : ( input_ | output | bidirectional | unspecified | unrestricted | mixedDirection ); - -portIndexValue : '(portIndexValue' - ')'; - -portInstanceRef : '(portInstanceRef' - ( portNameRef | portMemberRef ) - ( instanceRef | instanceMemberRef ) - ')'; - -portJoined : '(portJoined' - ( globalPortRef | localPortGroupRef | portInstanceRef | portRef )* - ')'; - -portList : '(portList' - ( portRef )* - ')'; - -portLoadDelay : '(portLoadDelay' - portLoadDelayNameDef - derivation - loadDelay - ( becomes | transition )* - ')'; - -portLoadDelayDisplay : '(portLoadDelayDisplay' - portLoadDelayNameRef - ( display )* - ')'; - -portLoadDelayNameDef : nameDef; - -portLoadDelayNameRef : nameRef; - -portLoadDelayOverride : '(portLoadDelayOverride' - portLoadDelayNameRef - derivation - loadDelay - ( becomes | transition )* - ')'; - -portMemberRef : '(portMemberRef' - portNameRef - indexValue - ')'; - -portNameCaseSensitive : '(portNameCaseSensitive' - booleanToken - ')'; - -portNameDef : nameDef; - -portNameDisplay : '(portNameDisplay' - ( display | displayNameOverride )* - ')'; - -portNameGenerator : '(portNameGenerator' - stringExpression - ')'; - -portNameGeneratorDisplay : '(portNameGeneratorDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -portNameRef : nameRef; - -portPropertyDisplay : '(portPropertyDisplay' - propertyNameRef - ( display | propertyNameDisplay )* - ')'; - -portPropertyDisplayOverride : '(portPropertyDisplayOverride' - propertyNameRef - ( addDisplay | replaceDisplay | removeDisplay ) - ( propertyNameDisplay )? - ')'; - -portPropertyOverride : '(portPropertyOverride' - propertyNameRef - ( typedValue | untyped ) - ( comment | fixed | propertyOverride )* - ')'; - -portRef : '(portRef' - portNameRef - ')'; - -portSet : '(portSet' - ( portRef )* - ')'; - -portWidth : '(portWidth' - integerExpression - ')'; - -presentLogicValue : ( logicNameRef | logicList | logicOneOf ); - -previousLogicValue : ( logicNameRef | logicList | logicOneOf ); - -previousVersion : '(previousVersion' - viewRef - ( reason )? - ')'; - -primaryName : '(primaryName' - originalName - ( displayName | generated | nameStructure )* - ')'; - -program : '(program' - stringValue - ( version )? - ')'; - -property_ : '(property' - propertyNameDef - ( typedValue | untyped ) - ( comment | nameInformation | owner | property_ | propertyInheritanceControl | unitRef )* - ')'; - -propertyDisplay : '(propertyDisplay' - propertyNameRef - ( display | propertyNameDisplay )* - ')'; - -propertyDisplayOverride : '(propertyDisplayOverride' - propertyNameRef - ( addDisplay | replaceDisplay | removeDisplay ) - ( propertyNameDisplay )? - ')'; - -propertyInheritanceControl : '(propertyInheritanceControl' - ( fixed | notInherited ) - ')'; - -propertyNameCaseSensitive : '(propertyNameCaseSensitive' - booleanToken - ')'; - -propertyNameDef : nameDef; - -propertyNameDisplay : '(propertyNameDisplay' - ( display | displayNameOverride )* - ')'; - -propertyNameRef : nameRef; - -propertyOverride : '(propertyOverride' - propertyNameRef - ( typedValue | untyped ) - ( comment | fixed | propertyOverride )* - ')'; - -proportionalFont : '(proportionalFont' - ')'; - -pt : '(pt' - xCoordinate - yCoordinate - ')'; - -pt1 : pointValue; - -pt2 : pointValue; - -radian : '(radian' - unitExponent - ')'; - -reason : '(reason' - stringToken - ')'; - -rectangle : '(rectangle' - pt1 - pt2 - ')'; - -red : scaledInteger; - -removeDisplay : '(removeDisplay' - ')'; - -repetitionCount : '(repetitionCount' - integerExpression - ')'; - -repetitionCountDisplay : '(repetitionCountDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -replaceDisplay : '(replaceDisplay' - ( display )* - ')'; - -required_ : '(required' - ')'; - -resolves : '(resolves' - ( logicNameRef )* - ')'; - -revision : '(revision' - stringToken - ')'; - -revisionDisplay : '(revisionDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -rightJustify : '(rightJustify' - ')'; - -ripperHotspot : '(ripperHotspot' - hotspotNameDef - hotspot - ')'; - -ripperHotspotRef : '(ripperHotspotRef' - hotspotNameRef - schematicRipperImplementationRef - ')'; - -rotation : '(rotation' - angleValue - ')'; - -round_ : '(round' - ')'; - -rowSize : integerToken; - -scaledInteger : ( integerToken | e ); - -scaleX : '(scaleX' - numerator - denominator - ')'; - -scaleY : '(scaleY' - numerator - denominator - ')'; - -schematicBus : '(schematicBus' - interconnectNameDef - signalGroupRef - schematicInterconnectHeader - schematicBusJoined - ( comment | schematicBusDetails | schematicBusSlice | schematicInterconnectAttributeDisplay | userData )* - ')'; - -schematicBusDetails : '(schematicBusDetails' - ( schematicBusGraphics | schematicSubBusSet ) - ')'; - -schematicBusGraphics : '(schematicBusGraphics' - ( comment | figure | schematicComplexFigure | userData )* - ')'; - -schematicBusJoined : '(schematicBusJoined' - (portJoined | ripperHotspotRef | schematicGlobalPortImplementationRef | schematicInterconnectTerminatorImplementationRef | schematicJunctionImplementationRef | schematicMasterPortImplementationRef | schematicOffPageConnectorImplementationRef | schematicOnPageConnectorImplementationRef | schematicSymbolPortImplementationRef )* - ')'; - -schematicBusSlice : '(schematicBusSlice' - interconnectNameDef - signalGroupRef - schematicInterconnectHeader - schematicBusJoined - ( comment | schematicBusDetails | schematicBusSlice | schematicInterconnectAttributeDisplay | userData )* - ')'; - -schematicComplexFigure : '(schematicComplexFigure' - schematicFigureMacroRef - transform - ( propertyDisplayOverride | propertyOverride )* - ')'; - -schematicFigureMacro : '(schematicFigureMacro' - libraryObjectNameDef - schematicTemplateHeader - ( annotate | comment | commentGraphics | figure | propertyDisplay | schematicComplexFigure | userData )* - ')'; - -schematicFigureMacroRef : '(schematicFigureMacroRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicForFrameBorder : '(schematicForFrameBorder' - schematicForFrameBorderTemplateRef - transform - ( forFrameIndexDisplay | propertyDisplayOverride | propertyOverride | repetitionCountDisplay )* - ')'; - -schematicForFrameBorderTemplate : '(schematicForFrameBorderTemplate' - libraryObjectNameDef - schematicTemplateHeader - usableArea - ( annotate | commentGraphics | figure | forFrameIndexDisplay | propertyDisplay | repetitionCountDisplay | schematicComplexFigure )* - ')'; - -schematicForFrameBorderTemplateRef : '(schematicForFrameBorderTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicForFrameImplementation : '(schematicForFrameImplementation' - implementationNameDef - forFrameRef - schematicForFrameImplementationHeader - schematicFrameImplementationDetails - ')'; - -schematicForFrameImplementationHeader : '(schematicForFrameImplementationHeader' - ( schematicForFrameBorder )? - ')'; - -schematicFrameImplementationDetails : '(schematicFrameImplementationDetails' - ( cellPropertyDisplay | clusterPropertyDisplay | comment | commentGraphics | propertyDisplay | schematicBus | schematicForFrameImplementation | schematicGlobalPortImplementation | schematicIfFrameImplementation | schematicInstanceImplementation | schematicMasterPortImplementation | schematicNet | schematicOffPageConnectorImplementation | schematicOnPageConnectorImplementation | schematicOtherwiseFrameImplementation | schematicRipperImplementation | userData | viewPropertyDisplay )* - ')'; - -schematicGlobalPortAttributes : '(schematicGlobalPortAttributes' - ( ieeeStandard | schematicPortAcPower | schematicPortAnalog | schematicPortChassisGround | schematicPortClock | schematicPortDcPower | schematicPortEarthGround | schematicPortGround | schematicPortNonLogical | schematicPortOpenCollector | schematicPortOpenEmitter | schematicPortPower | schematicPortThreeState )* - ')'; - -schematicGlobalPortImplementation : '(schematicGlobalPortImplementation' - implementationNameDef - schematicGlobalPortTemplateRef - globalPortRef - transform - ( globalPortNameDisplay | globalPortPropertyDisplay | implementationNameDisplay | nameInformation | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicGlobalPortImplementationRef : '(schematicGlobalPortImplementationRef' - implementationNameRef - ')'; - -schematicGlobalPortTemplate : '(schematicGlobalPortTemplate' - libraryObjectNameDef - schematicTemplateHeader - (hotspot)? - ( annotate | commentGraphics | figure | globalPortNameDisplay | implementationNameDisplay | propertyDisplay | schematicComplexFigure | schematicGlobalPortAttributes )* - (hotspot)? - ')'; - -schematicGlobalPortTemplateRef : '(schematicGlobalPortTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicIfFrameBorder : '(schematicIfFrameBorder' - schematicIfFrameBorderTemplateRef - transform - ( conditionDisplay | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicIfFrameBorderTemplate : '(schematicIfFrameBorderTemplate' - libraryObjectNameDef - schematicTemplateHeader - usableArea - ( annotate | commentGraphics | conditionDisplay | figure | propertyDisplay | schematicComplexFigure )* - ')'; - -schematicIfFrameBorderTemplateRef : '(schematicIfFrameBorderTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicIfFrameImplementation : '(schematicIfFrameImplementation' - implementationNameDef - ifFrameRef - schematicIfFrameImplementationHeader - schematicFrameImplementationDetails - ')'; - -schematicIfFrameImplementationHeader : '(schematicIfFrameImplementationHeader' - ( schematicIfFrameBorder )? - ')'; - -schematicImplementation : '(schematicImplementation' - ( page | totalPages )* - ')'; - -schematicInstanceImplementation : '(schematicInstanceImplementation' - implementationNameDef - instanceRef - schematicSymbolRef - transform - ( cellNameDisplay | cellPropertyDisplayOverride | clusterPropertyDisplayOverride | designatorDisplay | implementationNameDisplay | instanceNameDisplay | instanceNameGeneratorDisplay | instancePortAttributeDisplay | instancePropertyDisplay | instanceWidthDisplay | nameInformation | pageCommentGraphics | parameterDisplay | propertyDisplayOverride | propertyOverride | timingDisplay | viewNameDisplay )* - ')'; - -schematicInstanceImplementationRef : '(schematicInstanceImplementationRef' - implementationNameRef - ')'; - -schematicInterconnectAttributeDisplay : '(schematicInterconnectAttributeDisplay' - ( connectivityTagGeneratorDisplay | criticalityDisplay | interconnectAttachedText | interconnectDelayDisplay | interconnectNameDisplay | interconnectPropertyDisplay )* - ')'; - -schematicInterconnectHeader : '(schematicInterconnectHeader' - ( criticality | documentation | interconnectDelay | nameInformation | property_ | schematicInterconnectTerminatorImplementation | schematicJunctionImplementation | schematicWireStyle )* - ')'; - -schematicInterconnectTerminatorImplementation : '(schematicInterconnectTerminatorImplementation' - implementationNameDef - schematicInterconnectTerminatorTemplateRef - transform - ( implementationNameDisplay | nameInformation | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicInterconnectTerminatorImplementationRef : '(schematicInterconnectTerminatorImplementationRef' - implementationNameRef - ')'; - -schematicInterconnectTerminatorTemplate : '(schematicInterconnectTerminatorTemplate' - libraryObjectNameDef - schematicTemplateHeader - hotspot - ( commentGraphics | figure | implementationNameDisplay | propertyDisplay | schematicComplexFigure )* - ')'; - -schematicInterconnectTerminatorTemplateRef : '(schematicInterconnectTerminatorTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicJunctionImplementation : '(schematicJunctionImplementation' - implementationNameDef - schematicJunctionTemplateRef - transform - ( implementationNameDisplay | nameInformation | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicJunctionImplementationRef : '(schematicJunctionImplementationRef' - implementationNameRef - ')'; - -schematicJunctionTemplate : '(schematicJunctionTemplate' - libraryObjectNameDef - schematicTemplateHeader - hotspot - ( commentGraphics | figure | implementationNameDisplay | propertyDisplay | schematicComplexFigure )* - ')'; - -schematicJunctionTemplateRef : '(schematicJunctionTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicMasterPortImplementation : '(schematicMasterPortImplementation' - implementationNameDef - schematicMasterPortTemplateRef - ( portRef | localPortGroupRef ) - transform - ( implementationNameDisplay | nameInformation | portAttributeDisplay | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicMasterPortImplementationRef : '(schematicMasterPortImplementationRef' - implementationNameRef - ')'; - -schematicMasterPortTemplate : '(schematicMasterPortTemplate' - libraryObjectNameDef - schematicTemplateHeader - hotspot - portDirectionIndicator - ( annotate | commentGraphics | figure | implementationNameDisplay | portAttributeDisplay | propertyDisplay | schematicComplexFigure | schematicPortStyle )* - ')'; - -schematicMasterPortTemplateRef : '(schematicMasterPortTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicMetric : '(schematicMetric' - setDistance - ( hotspotGrid | noHotspotGrid ) - ( nominalHotspotGrid )? - ')'; - -schematicNet : '(schematicNet' - interconnectNameDef - signalRef - schematicInterconnectHeader - schematicNetJoined - ( comment | schematicInterconnectAttributeDisplay | schematicNetDetails | userData )* - ')'; - -schematicNetDetails : '(schematicNetDetails' - ( schematicNetGraphics | schematicSubNetSet ) - ')'; - -schematicNetGraphics : '(schematicNetGraphics' - ( comment | figure | schematicComplexFigure | userData )* - ')'; - -schematicNetJoined : '(schematicNetJoined' - ( portJoined | joinedAsSignal )? - ( ripperHotspotRef | schematicGlobalPortImplementationRef | schematicInterconnectTerminatorImplementationRef | schematicJunctionImplementationRef | schematicMasterPortImplementationRef | schematicOffPageConnectorImplementationRef | schematicOnPageConnectorImplementationRef | schematicSymbolPortImplementationRef )* - ( portJoined | joinedAsSignal )? - ( ripperHotspotRef | schematicGlobalPortImplementationRef | schematicInterconnectTerminatorImplementationRef | schematicJunctionImplementationRef | schematicMasterPortImplementationRef | schematicOffPageConnectorImplementationRef | schematicOnPageConnectorImplementationRef | schematicSymbolPortImplementationRef )* - ')'; - -schematicOffPageConnectorImplementation : '(schematicOffPageConnectorImplementation' - implementationNameDef - schematicOffPageConnectorTemplateRef - transform - ( associatedInterconnectNameDisplay | implementationNameDisplay | nameInformation | property_ | propertyDisplay | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicOffPageConnectorImplementationRef : '(schematicOffPageConnectorImplementationRef' - implementationNameRef - ')'; - -schematicOffPageConnectorTemplate : '(schematicOffPageConnectorTemplate' - libraryObjectNameDef - schematicTemplateHeader - hotspot - ( annotate | associatedInterconnectNameDisplay | commentGraphics | figure | implementationNameDisplay | propertyDisplay | schematicComplexFigure )* - ')'; - -schematicOffPageConnectorTemplateRef : '(schematicOffPageConnectorTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicOnPageConnectorImplementation : '(schematicOnPageConnectorImplementation' - implementationNameDef - schematicOnPageConnectorTemplateRef - transform - ( associatedInterconnectNameDisplay | implementationNameDisplay | nameInformation | property_ | propertyDisplay | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicOnPageConnectorImplementationRef : '(schematicOnPageConnectorImplementationRef' - implementationNameRef - ')'; - -schematicOnPageConnectorTemplate : '(schematicOnPageConnectorTemplate' - libraryObjectNameDef - schematicTemplateHeader - hotspot - ( annotate | associatedInterconnectNameDisplay | commentGraphics | figure | implementationNameDisplay | propertyDisplay | schematicComplexFigure )* - ')'; - -schematicOnPageConnectorTemplateRef : '(schematicOnPageConnectorTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicOtherwiseFrameBorder : '(schematicOtherwiseFrameBorder' - schematicOtherwiseFrameBorderTemplateRef - transform - ( propertyDisplayOverride | propertyOverride )* - ')'; - -schematicOtherwiseFrameBorderTemplate : '(schematicOtherwiseFrameBorderTemplate' - libraryObjectNameDef - schematicTemplateHeader - usableArea - ( annotate | commentGraphics | figure | propertyDisplay | schematicComplexFigure )* - ')'; - -schematicOtherwiseFrameBorderTemplateRef : '(schematicOtherwiseFrameBorderTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicOtherwiseFrameImplementation : '(schematicOtherwiseFrameImplementation' - implementationNameDef - otherwiseFrameRef - schematicOtherwiseFrameImplementationHeader - schematicFrameImplementationDetails - ')'; - -schematicOtherwiseFrameImplementationHeader : '(schematicOtherwiseFrameImplementationHeader' - ( schematicOtherwiseFrameBorder )? - ')'; - -schematicPortAcPower : '(schematicPortAcPower' - ( schematicPortAcPowerRecommendedFrequency | schematicPortAcPowerRecommendedVoltageRms )* - ')'; - -schematicPortAcPowerRecommendedFrequency : '(schematicPortAcPowerRecommendedFrequency' - frequencyValue - ')'; - -schematicPortAcPowerRecommendedVoltageRms : '(schematicPortAcPowerRecommendedVoltageRms' - voltageValue - ')'; - -schematicPortAnalog : '(schematicPortAnalog' - ')'; - -schematicPortAttributes : '(schematicPortAttributes' - ( ieeeStandard | schematicPortAcPower | schematicPortAnalog | schematicPortChassisGround | schematicPortClock | schematicPortDcPower | schematicPortEarthGround | schematicPortGround | schematicPortNonLogical | schematicPortOpenCollector | schematicPortOpenEmitter | schematicPortPower | schematicPortThreeState )* - ')'; - -schematicPortChassisGround : '(schematicPortChassisGround' - ( schematicPortAnalog )? - ')'; - -schematicPortClock : '(schematicPortClock' - ( ieeeStandard )? - ')'; - -schematicPortDcPower : '(schematicPortDcPower' - ( schematicPortAnalog | schematicPortDcPowerRecommendedVoltage )* - ')'; - -schematicPortDcPowerRecommendedVoltage : '(schematicPortDcPowerRecommendedVoltage' - voltageValue - ')'; - -schematicPortEarthGround : '(schematicPortEarthGround' - ( schematicPortAnalog )? - ')'; - -schematicPortGround : '(schematicPortGround' - ( schematicPortAnalog )? - ')'; - -schematicPortNonLogical : '(schematicPortNonLogical' - ')'; - -schematicPortOpenCollector : '(schematicPortOpenCollector' - ')'; - -schematicPortOpenEmitter : '(schematicPortOpenEmitter' - ')'; - -schematicPortPower : '(schematicPortPower' - ')'; - -schematicPortStyle : '(schematicPortStyle' - ( narrowPort | widePort ) - ')'; - -schematicPortThreeState : '(schematicPortThreeState' - ')'; - -schematicRequiredDefaults : '(schematicRequiredDefaults' - schematicMetric - fontRef - textHeight - ')'; - -schematicRipperImplementation : '(schematicRipperImplementation' - implementationNameDef - schematicRipperTemplateRef - transform - ( implementationNameDisplay | nameInformation | property_ | propertyDisplay | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicRipperImplementationRef : '(schematicRipperImplementationRef' - implementationNameRef - ')'; - -schematicRipperTemplate : '(schematicRipperTemplate' - libraryObjectNameDef - schematicTemplateHeader - ( annotate | commentGraphics | figure | implementationNameDisplay | propertyDisplay | ripperHotspot | schematicComplexFigure )* - ')'; - -schematicRipperTemplateRef : '(schematicRipperTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicSubBus : '(schematicSubBus' - interconnectNameDef - schematicSubInterconnectHeader - schematicBusJoined - ( comment | schematicBusDetails | schematicBusSlice | schematicInterconnectAttributeDisplay | userData )* - ')'; - -schematicSubBusSet : '(schematicSubBusSet' - ( schematicSubBus )* - ')'; - -schematicSubInterconnectHeader : '(schematicSubInterconnectHeader' - ( criticality | documentation | interconnectDelay | nameInformation | property_ )* - ')'; - -schematicSubNet : '(schematicSubNet' - interconnectNameDef - schematicSubInterconnectHeader - schematicNetJoined - ( comment | schematicInterconnectAttributeDisplay | schematicNetDetails | userData )* - ')'; - -schematicSubNetSet : '(schematicSubNetSet' - ( schematicSubNet )* - ')'; - -schematicSymbol : '(schematicSymbol' - viewNameDef - schematicSymbolHeader - ( annotate | cellNameDisplay | cellPropertyDisplay | clusterPropertyDisplay | comment | commentGraphics | designatorDisplay | figure | implementationNameDisplay | instanceNameDisplay | instanceNameGeneratorDisplay | instanceWidthDisplay | parameterDisplay | propertyDisplay | schematicComplexFigure | schematicSymbolPortImplementation | userData | viewNameDisplay )* - ')'; - -schematicSymbolBorder : '(schematicSymbolBorder' - schematicSymbolBorderTemplateRef - transform - ( propertyDisplayOverride | propertyOverride )* - ')'; - -schematicSymbolBorderTemplate : '(schematicSymbolBorderTemplate' - libraryObjectNameDef - schematicTemplateHeader - usableArea - ( annotate | commentGraphics | figure | propertyDisplay | schematicComplexFigure )* - ')'; - -schematicSymbolBorderTemplateRef : '(schematicSymbolBorderTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicSymbolHeader : '(schematicSymbolHeader' - schematicUnits - ( backgroundColor | derivedFrom | documentation | nameInformation | originalBoundingBox | pageSize | previousVersion | property_ | schematicSymbolBorder | status )* - ')'; - -schematicSymbolPortImplementation : '(schematicSymbolPortImplementation' - symbolPortImplementationNameDef - portRef - schematicSymbolPortTemplateRef - transform - ( portAttributeDisplay | propertyDisplayOverride | propertyOverride )* - ')'; - -schematicSymbolPortImplementationRef : '(schematicSymbolPortImplementationRef' - symbolPortImplementationNameRef - schematicInstanceImplementationRef - ')'; - -schematicSymbolPortTemplate : '(schematicSymbolPortTemplate' - libraryObjectNameDef - schematicTemplateHeader - hotspot - portDirectionIndicator - ( annotate | commentGraphics | figure | implementationNameDisplay | portAttributeDisplay | propertyDisplay | schematicComplexFigure | schematicPortAttributes | schematicPortStyle )* - ')'; - -schematicSymbolPortTemplateRef : '(schematicSymbolPortTemplateRef' - libraryObjectNameRef - ( libraryRef )? - ')'; - -schematicSymbolRef : '(schematicSymbolRef' - viewNameRef - ')'; - -schematicTemplateHeader : '(schematicTemplateHeader' - schematicUnits - ( backgroundColor | documentation | nameInformation | originalBoundingBox | property_ | status )* - ')'; - -schematicUnits : '(schematicUnits' - ( schematicMetric | setAngle | setCapacitance | setFrequency | setTime | setVoltage )* - ')'; - -schematicView : '(schematicView' - viewNameDef - schematicViewHeader - logicalConnectivity - schematicImplementation - ( comment | userData )* - ')'; - -schematicViewHeader : '(schematicViewHeader' - schematicUnits - ( derivedFrom | documentation | nameInformation | previousVersion | property_ | status )* - ')'; - -schematicWireAffinity : '(schematicWireAffinity' - ( narrowWire | wideWire | unrestricted ) - ')'; - -schematicWireStyle : '(schematicWireStyle' - ( narrowWire | wideWire ) - ')'; - -second : '(second' - unitExponent - ')'; - -secondIntegerExpression : integerExpression; - -secondNumber : integerToken; - -secondStringExpression : stringExpression; - -section : '(section' - sectionNameDef - sectionTitle - ( diagram | section | stringValue )* - ')'; - -sectionNameDef : nameDef; - -sectionTitle : '(sectionTitle' - stringToken - ')'; - -sequence : '(sequence' - fromInteger - toInteger - ( step )? - ')'; - -setAngle : '(setAngle' - unitRef - ')'; - -setCapacitance : '(setCapacitance' - unitRef - ')'; - -setCurrent : '(setCurrent' - unitRef - ')'; - -setDistance : '(setDistance' - unitRef - ')'; - -setFrequency : '(setFrequency' - unitRef - ')'; - -setTime : '(setTime' - unitRef - ')'; - -setVoltage : '(setVoltage' - unitRef - ')'; - -shape : '(shape' - curve - ')'; - -siemens : '(siemens' - unitExponent - ')'; - -signal : '(signal' - signalNameDef - signalJoined - ( connectivityTagGenerator | nameInformation | property_ | signalWidth )* - ')'; - -signalAnnotate : '(signalAnnotate' - ( extendSignalDef | extendSignalMemberDef ) - ( comment | property_ | propertyOverride )* - ')'; - -signalGroup : '(signalGroup' - signalGroupNameDef - signalList - ( property_ | nameInformation )* - ')'; - -signalGroupAnnotate : '(signalGroupAnnotate' - extendSignalGroupDef - ( comment | property_ | propertyOverride )* - ')'; - -signalGroupNameCaseSensitive : '(signalGroupNameCaseSensitive' - booleanToken - ')'; - -signalGroupNameDef : nameDef; - -signalGroupNameRef : nameRef; - -signalGroupRef : '(signalGroupRef' - signalGroupNameRef - ')'; - -signalIndexValue : '(signalIndexValue' - ')'; - -signalJoined : '(signalJoined' - ( globalPortRef | portInstanceRef | portMemberRef | portRef )* - ')'; - -signalList : '(signalList' - ( signalGroupRef | signalRef )* - ')'; - -signalMemberRef : '(signalMemberRef' - signalNameRef - indexValue - ')'; - -signalNameCaseSensitive : '(signalNameCaseSensitive' - booleanToken - ')'; - -signalNameDef : nameDef; - -signalNameRef : nameRef; - -signalRef : '(signalRef' - signalNameRef - ')'; - -signalWidth : '(signalWidth' - integerExpression - ')'; - -simpleName : stringToken; - -startPoint : pointValue; - -status : '(status' - ( comment | copyright | userData | written )* - ')'; - -step : '(step' - integerValue - ')'; - -string : '(string' - stringExpression - ')'; - -stringConcatenate : '(stringConcatenate' - ( stringExpression )* - ')'; - -stringConstant : '(stringConstant' - constantNameDef - stringToken - ')'; - -stringConstantRef : '(stringConstantRef' - constantNameRef - ')'; - -stringEqual : '(stringEqual' - firstStringExpression - secondStringExpression - ')'; - -stringExpression : ( stringParameterRef | stringToken | stringConstantRef | stringConcatenate | substring | decimalToString | stringPrefix | stringSuffix ) -; -stringLength : '(stringLength' - stringExpression - ')'; - -stringParameter : '(stringParameter' - parameterNameDef - ( nameInformation | string )* - ')'; - -stringParameterAssign : '(stringParameterAssign' - parameterNameRef - stringExpression - ')'; - -stringParameterRef : '(stringParameterRef' - parameterNameRef - ')'; - -stringPrefix : '(stringPrefix' - stringExpression - substringLength - ')'; - -stringSuffix : '(stringSuffix' - stringExpression - substringOffset - ')'; - -stringValue : stringToken; - -strong : '(strong' - logicNameRef - ')'; - -subIssue : integerToken; - -substring : '(substring' - stringExpression - substringLength - substringOffset - ')'; - -substringLength : integerExpression; - -substringOffset : integerExpression; - -subtrahend : integerExpression; - -symbolicLayoutUnits : '(symbolicLayoutUnits' - ( setAngle | setCapacitance | setDistance | setTime )* - ')'; - -symbolicLayoutView : '(symbolicLayoutView' - viewNameDef - ( comment | userData )* - ( nameInformation )? - ( comment | userData )* - ')'; - -symbolPortImplementationNameDef : nameDef; - -symbolPortImplementationNameRef : nameRef; - -technology : '(technology' - physicalScaling - ( comment | figureGroup | logicDefinitions | userData )* - ')'; - -textHeight : '(textHeight' - lengthValue - ')'; - -throughPoint : numberPoint; - -time : '(time' - hourNumber - minuteNumber - secondNumber - ')'; - -timeDelay : timeValue; - -timeInterval : '(timeInterval' - ( event | offsetEvent ) - ( event | offsetEvent | duration ) - ')'; - -timeStamp : '(timeStamp' - date - time - ')'; - -timeValue : miNoMaxValue; - -timing : '(timing' - timingNameDef - derivation - ( comment | forbiddenEvent | pathDelay | property_ | userData )* - ')'; - -timingDisplay : '(timingDisplay' - timingNameRef - ( display )* - ')'; - -timingNameDef : nameDef; - -timingNameRef : nameRef; - -toInteger : integerToken; - -topJustify : '(topJustify' - ')'; - -totalPages : '(totalPages' - integerToken - ')'; - -totalPagesDisplay : '(totalPagesDisplay' - ( addDisplay | replaceDisplay | removeDisplay ) - ')'; - -transform : '(transform' - ( origin | rotation | scaleX | scaleY )* - ')'; - -transition : '(transition' - previousLogicValue - presentLogicValue - ')'; - -etrue : '(true' - ')'; - -truncate : '(truncate' - ')'; - -typedValue : ( eboolean | integer | miNoMax | number | point | string ); - -typeface : '(typeface' - fontFamily - ( typefaceSuffix )? - ')'; - -typefaceSuffix : '(typefaceSuffix' - stringToken - ')'; - -unconfigured : '(unconfigured' - ')'; - -unconstrained : '(unconstrained' - ')'; - -undefined : '(undefined' - ')'; - -unit : '(unit' - unitNameDef - numberOfNewUnits - numberOfBasicUnits - ( ampere | candela | celsius | coulomb | degree | fahrenheit | farad | henry | hertz | joule | kelvin | kilogram | meter | mole | ohm | radian | second | siemens | volt | watt | weber )* - ')'; - -unitDefinitions : '(unitDefinitions' - ( unit )* - ')'; - -unitExponent : scaledInteger; - -unitNameDef : nameDef; - -unitNameRef : nameRef; - -unitRef : '(unitRef' - unitNameRef - ')'; - -unrestricted : '(unrestricted' - ')'; - -unspecified : '(unspecified' - ')'; - -unspecifiedDirectionPort : '(unspecifiedDirectionPort' - ')'; - -untyped : '(untyped' - ')'; - -unused : '(unused' - ')'; - -usableArea : '(usableArea' - ( rectangle )* - ')'; - -userData : '(userData' - userDataTag - ( IDENTIFIER | integerToken | stringToken | userData )* - ')'; - -userDataTag : IDENTIFIER; - -version : '(version' - stringValue - ')'; - -verticalJustification : '(verticalJustification' - ( bottomJustify | baselineJustify | middleJustify | caplineJustify | topJustify ) - ')'; - -viewGroup : '(viewGroup' - viewGroupNameDef - viewGroupHeader - ( comment | userData | viewGroupRef | viewRef )* - ')'; - -viewGroupHeader : '(viewGroupHeader' - ( documentation | nameInformation | property_ | reason )* - ')'; - -viewGroupNameCaseSensitive : '(viewGroupNameCaseSensitive' - booleanToken - ')'; - -viewGroupNameDef : nameDef; - -viewGroupNameRef : nameRef; - -viewGroupRef : '(viewGroupRef' - viewGroupNameRef - ')'; - -viewNameCaseSensitive : '(viewNameCaseSensitive' - booleanToken - ')'; - -viewNameDef : nameDef; - -viewNameDisplay : '(viewNameDisplay' - ( display | displayNameOverride )* - ')'; - -viewNameRef : nameRef; - -viewPropertyDisplay : '(viewPropertyDisplay' - propertyNameRef - ( display | propertyNameDisplay )* - ')'; - -viewPropertyOverride : '(viewPropertyOverride' - propertyNameRef - ( typedValue | untyped ) - ( comment | fixed | propertyOverride )* - ')'; - -viewRef : '(viewRef' - viewNameRef - ( clusterRef )? - ')'; - -visible : '(visible' - booleanValue - ')'; - -volt : '(volt' - unitExponent - ')'; - -voltageMap : '(voltageMap' - voltageValue - ')'; - -voltageValue : miNoMaxValue; - -watt : '(watt' - unitExponent - ')'; - -weak_ : '(weak' - logicNameRef - ')'; - -weakJoined : '(weakJoined' - ( interfaceJoined | portRef )* - ')'; - -weber : '(weber' - unitExponent - ')'; - -widePort : '(widePort' - ')'; - -wideWire : '(wideWire' - ')'; - -written : '(written' - timeStamp - ( author | comment | dataOrigin | program | userData )* - ')'; - -xCoordinate : integerValue; - -xNumberValue : numberValue; - -xor_ : '(xor' - ( booleanExpression )* - ')'; - -yCoordinate : integerValue; - -year : '(year' - ( yearNumber )* - ')'; +grammar EDIF300; -yearNumber : integerToken; +goal + : edif EOF + ; -yNumberValue : numberValue; +absolute + : '(absolute' integerExpression ')' + ; -integerToken :DECIMAL_LITERAL; -stringToken :STRING_LITERAL; +acLoad + : '(acLoad' capacitanceValue ')' + ; -IDENTIFIER : (SPECIAL)* (DIG)* (LETTER|'&'|UNDERLINE) ( LETTER | DIG | UNDERLINE |SPECIAL)* ; +acLoadDisplay + : '(acLoadDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; -STRING_LITERAL : '"' (~'"')* '"' ; +acLoadFactorCapacitance + : capacitanceValue + ; -DECIMAL_LITERAL : INTEGER ( '.' INTEGER* )? ; +acLoadFactorTime + : timeValue + ; -fragment -INTEGER : ('-'|'+')? DIG (DIG)* ; -fragment -LETTER : UPCASE |LOWCASE ; -fragment -UPCASE: [A-Z]; -fragment -LOWCASE: [a-z]; -fragment -DIG: [0-9]; -fragment -UNDERLINE : '_'; -fragment -SPECIAL: '!' | '#' | '$' | '&'| '*'| '+' | ',' | '-' | '.' | '/' | ':' | ';' | -'<' | '=' | '>' | '?' | '@' | '[' | ']'| '^' | '`' | '{' | '|' | '}' | '~'| '\\' ; +addDisplay + : '(addDisplay' (display)* ')' + ; -WS : [ \t\r\n]+ -> skip; +ampere + : '(ampere' unitExponent ')' + ; + +and_ + : '(and' (booleanExpression)* ')' + ; + +angleValue + : numberValue + ; + +annotate + : '(annotate' stringValue (display)* ')' + ; + +approvedDate + : '(approvedDate' date ')' + ; + +approvedDateDisplay + : '(approvedDateDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +arc + : '(arc' startPoint throughPoint endPoint ')' + ; + +ascii + : '(ascii' ')' + ; + +associatedInterconnectNameDisplay + : '(associatedInterconnectNameDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +attachmentPoint + : pointValue + ; + +author + : '(author' stringToken ')' + ; + +backgroundColor + : '(backgroundColor' color ')' + ; + +baselineJustify + : '(baselineJustify' ')' + ; + +becomes + : '(becomes' (logicNameRef | logicList | logicOneOf) ')' + ; + +behaviorView + : '(behaviorView' viewNameDef (comment | nameInformation | userData)* ')' + ; + +bidirectional + : '(bidirectional' ')' + ; + +bidirectionalPort + : '(bidirectionalPort' (bidirectionalPortAttributes)? ')' + ; + +bidirectionalPortAttributes + : '(bidirectionalPortAttributes' (dcFanInLoad | dcFanOutLoad | dcMaxFanIn | dcMaxFanOut)* ')' + ; + +bitOrder + : '(bitOrder' (lsbToMsb | msbToLsb) ')' + ; + +blue + : scaledInteger + ; + +boldStyle + : '(boldStyle' ')' + ; + +eboolean + : '(boolean' booleanExpression ')' + ; + +booleanConstant + : '(booleanConstant' constantNameDef booleanToken ')' + ; + +booleanConstantRef + : '(booleanConstantRef' constantNameRef ')' + ; + +booleanExpression + : ( + and_ + | booleanParameterRef + | booleanToken + | stringEqual + | integerEqual + | lessThan + | lessThanOrEqual + | not_ + | or_ + | xor_ + | booleanConstantRef + ) + ; + +booleanMap + : '(booleanMap' booleanValue ')' + ; + +booleanParameter + : '(booleanParameter' parameterNameDef (eboolean | nameInformation)* ')' + ; + +booleanParameterAssign + : '(booleanParameterAssign' parameterNameRef booleanExpression ')' + ; + +booleanParameterRef + : '(booleanParameterRef' parameterNameRef ')' + ; + +booleanToken + : (efalse | etrue) + ; + +booleanValue + : booleanToken + ; + +borderPattern + : '(borderPattern' pixelPattern ')' + ; + +borderPatternVisible + : '(borderPatternVisible' booleanValue ')' + ; + +borderWidth + : '(borderWidth' (lengthValue | minimalWidth) ')' + ; + +bottomJustify + : '(bottomJustify' ')' + ; + +calculated + : '(calculated' ')' + ; + +candela + : '(candela' unitExponent ')' + ; + +capacitanceValue + : miNoMaxValue + ; + +caplineJustify + : '(caplineJustify' ')' + ; + +cell + : '(cell' libraryObjectNameDef cellHeader (cluster | comment | userData | viewGroup)* ')' + ; + +cellHeader + : '(cellHeader' (documentation | nameInformation | property_ | status)* ')' + ; + +cellNameDisplay + : '(cellNameDisplay' (display | displayNameOverride)* ')' + ; + +cellPropertyDisplay + : '(cellPropertyDisplay' propertyNameRef (display | propertyNameDisplay)* ')' + ; + +cellPropertyDisplayOverride + : '(cellPropertyDisplayOverride' propertyNameRef (addDisplay | replaceDisplay | removeDisplay) ( + propertyNameDisplay + )? ')' + ; + +cellPropertyOverride + : '(cellPropertyOverride' propertyNameRef (typedValue | untyped) ( + comment + | fixed + | propertyOverride + )* ')' + ; + +cellRef + : '(cellRef' libraryObjectNameRef (libraryRef)? ')' + ; + +celsius + : '(celsius' unitExponent ')' + ; + +centerJustify + : '(centerJustify' ')' + ; + +characterEncoding + : '(characterEncoding' (ascii | iso8859 | jisx0201 | jisx0208) ')' + ; + +checkDate + : '(checkDate' date ')' + ; + +checkDateDisplay + : '(checkDateDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +circle + : '(circle' pt1 pt2 ')' + ; + +cluster + : '(cluster' clusterNameDef einterface clusterHeader ( + schematicSymbol + | schematicView + | behaviorView + | clusterConfiguration + | comment + | connectivityView + | defaultClusterConfiguration + | userData + | logicModelView + | maskLayoutView + | pcbLayoutView + | symbolicLayoutView + )* ')' + ; + +clusterConfiguration + : '(clusterConfiguration' clusterConfigurationNameDef (viewRef | leaf | unconfigured) ( + comment + | frameConfiguration + | globalPortScope + | nameInformation + | instanceConfiguration + | property_ + | userData + )* ')' + ; + +clusterConfigurationNameCaseSensitive + : '(clusterConfigurationNameCaseSensitive' booleanToken ')' + ; + +clusterConfigurationNameDef + : nameDef + ; + +clusterConfigurationNameRef + : nameRef + ; + +clusterConfigurationRef + : '(clusterConfigurationRef' clusterConfigurationNameRef ')' + ; + +clusterHeader + : '(clusterHeader' (documentation | nameInformation | property_ | status)* ')' + ; + +clusterNameCaseSensitive + : '(clusterNameCaseSensitive' booleanToken ')' + ; + +clusterNameDef + : nameDef + ; + +clusterNameRef + : nameRef + ; + +clusterPropertyDisplay + : '(clusterPropertyDisplay' propertyNameRef (display | propertyNameDisplay)* ')' + ; + +clusterPropertyDisplayOverride + : '(clusterPropertyDisplayOverride' propertyNameRef ( + addDisplay + | replaceDisplay + | removeDisplay + ) (propertyNameDisplay)? ')' + ; + +clusterPropertyOverride + : '(clusterPropertyOverride' propertyNameRef (typedValue | untyped) ( + comment + | fixed + | propertyOverride + )* ')' + ; + +clusterRef + : '(clusterRef' clusterNameRef (cellRef)? ')' + ; + +color + : '(color' red green blue ')' + ; + +comment + : '(comment' (stringToken)* ')' + ; + +commentGraphics + : '(commentGraphics' ( + annotate + | comment + | figure + | originalBoundingBox + | propertyDisplay + | userData + )* ')' + ; + +companyName + : '(companyName' stringToken ')' + ; + +companyNameDisplay + : '(companyNameDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +complementedName + : '(complementedName' (complementedNamePart | nameDimension | namePartSeparator | simpleName)* ')' + ; + +complementedNamePart + : '(complementedNamePart' (complementedNamePart | namePartSeparator | simpleName)* ')' + ; + +complexGeometry + : '(complexGeometry' geometryMacroRef transform ')' + ; + +complexName + : '(complexName' (complementedNamePart | nameDimension | namePartSeparator | simpleName)* ')' + ; + +compound + : '(compound' (logicNameRef)* ')' + ; + +condition + : '(condition' booleanExpression ')' + ; + +conditionDisplay + : '(conditionDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +connectedSignalIndexGenerator + : '(connectedSignalIndexGenerator' integerExpression ')' + ; + +connectedSignalIndexGeneratorDisplay + : '(connectedSignalIndexGeneratorDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +connectivityBus + : '(connectivityBus' interconnectNameDef signalGroupRef interconnectHeader connectivityBusJoined ( + comment + | connectivityBusSlice + | connectivitySubBus + | userData + )* ')' + ; + +connectivityBusJoined + : '(connectivityBusJoined' portJoined (connectivityRipperRef)* ')' + ; + +connectivityBusSlice + : '(connectivityBusSlice' interconnectNameDef signalGroupRef interconnectHeader connectivityBusJoined ( + comment + | connectivityBusSlice + | connectivitySubBus + | userData + )* ')' + ; + +connectivityFrameStructure + : '(connectivityFrameStructure' connectivityFrameStructureNameDef frameRef ( + comment + | connectivityBus + | connectivityFrameStructure + | connectivityNet + | connectivityRipper + | timing + | userData + )* ')' + ; + +connectivityFrameStructureNameDef + : nameDef + ; + +connectivityNet + : '(connectivityNet' interconnectNameDef signalRef interconnectHeader connectivityNetJoined ( + comment + | connectivitySubNet + | userData + )* ')' + ; + +connectivityNetJoined + : '(connectivityNetJoined' (portJoined | joinedAsSignal) (connectivityRipperRef)* ')' + ; + +connectivityRipper + : '(connectivityRipper' connectivityRipperNameDef ')' + ; + +connectivityRipperNameDef + : nameDef + ; + +connectivityRipperNameRef + : nameRef + ; + +connectivityRipperRef + : '(connectivityRipperRef' connectivityRipperNameRef ')' + ; + +connectivityStructure + : '(connectivityStructure' ( + comment + | connectivityBus + | connectivityFrameStructure + | connectivityNet + | connectivityRipper + | localPortGroup + | timing + | userData + )* ')' + ; + +connectivitySubBus + : '(connectivitySubBus' interconnectNameDef interconnectHeader connectivityBusJoined ( + comment + | connectivityBusSlice + | connectivitySubBus + | userData + )* ')' + ; + +connectivitySubNet + : '(connectivitySubNet' interconnectNameDef interconnectHeader connectivityNetJoined ( + comment + | connectivitySubNet + | userData + )* ')' + ; + +connectivityTagGenerator + : '(connectivityTagGenerator' stringExpression ')' + ; + +connectivityTagGeneratorDisplay + : '(connectivityTagGeneratorDisplay' (display)* ')' + ; + +connectivityUnits + : '(connectivityUnits' (setCapacitance | setTime)? ')' + ; + +connectivityView + : '(connectivityView' viewNameDef connectivityViewHeader logicalConnectivity connectivityStructure ( + comment + | userData + )* ')' + ; + +connectivityViewHeader + : '(connectivityViewHeader' connectivityUnits ( + derivedFrom + | documentation + | nameInformation + | previousVersion + | property_ + | status + )* ')' + ; + +constantNameDef + : nameDef + ; + +constantNameRef + : nameRef + ; + +constantValues + : '(constantValues' (booleanConstant | integerConstant | stringConstant)* ')' + ; + +contract + : '(contract' stringToken ')' + ; + +contractDisplay + : '(contractDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +copyright + : '(copyright' year (stringToken)* ')' + ; + +copyrightDisplay + : '(copyrightDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +cornerType + : '(cornerType' (truncate | round_ | extend) ')' + ; + +coulomb + : '(coulomb' unitExponent ')' + ; + +criticality + : '(criticality' integerValue ')' + ; + +criticalityDisplay + : '(criticalityDisplay' (display)* ')' + ; + +currentMap + : '(currentMap' currentValue ')' + ; + +currentValue + : miNoMaxValue + ; + +curve + : '(curve' (arc | pointValue)* ')' + ; + +dataOrigin + : '(dataOrigin' stringToken (version)? ')' + ; + +date + : '(date' yearNumber monthNumber dayNumber ')' + ; + +dayNumber + : integerToken + ; + +dcFanInLoad + : '(dcFanInLoad' numberValue ')' + ; + +dcFanInLoadDisplay + : '(dcFanInLoadDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +dcFanOutLoad + : '(dcFanOutLoad' numberValue ')' + ; + +dcFanOutLoadDisplay + : '(dcFanOutLoadDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +dcMaxFanIn + : '(dcMaxFanIn' numberValue ')' + ; + +dcMaxFanInDisplay + : '(dcMaxFanInDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +dcMaxFanOut + : '(dcMaxFanOut' numberValue ')' + ; + +dcMaxFanOutDisplay + : '(dcMaxFanOutDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +decimalToString + : '(decimalToString' integerExpression (minimumStringLength)? ')' + ; + +defaultClusterConfiguration + : '(defaultClusterConfiguration' clusterConfigurationNameRef ')' + ; + +defaultConnection + : '(defaultConnection' globalPortRef ')' + ; + +degree + : '(degree' unitExponent ')' + ; + +delay + : '(delay' timeDelay ')' + ; + +denominator + : integerValue + ; + +derivation + : (calculated | measured | required_) + ; + +derivedFrom + : '(derivedFrom' viewRef (reason)? ')' + ; + +design + : '(design' designNameDef cellRef designHeader (comment | designHierarchy | userData)* ')' + ; + +designator + : '(designator' stringValue ')' + ; + +designatorDisplay + : '(designatorDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +designHeader + : '(designHeader' designUnits (documentation | nameInformation | property_ | status)* ')' + ; + +designHierarchy + : '(designHierarchy' designHierarchyNameDef clusterRef clusterConfigurationRef designHierarchyHeader ( + occurrenceHierarchyAnnotate + )? ')' + ; + +designHierarchyHeader + : '(designHierarchyHeader' ( + booleanParameterAssign + | integerParameterAssign + | nameInformation + | numberParameterAssign + | property_ + | stringParameterAssign + )* ')' + ; + +designHierarchyNameCaseSensitive + : '(designHierarchyNameCaseSensitive' booleanToken ')' + ; + +designHierarchyNameDef + : nameDef + ; + +designNameCaseSensitive + : '(designNameCaseSensitive' booleanToken ')' + ; + +designNameDef + : nameDef + ; + +designUnits + : '(designUnits' (setCapacitance | setTime)* ')' + ; + +diagram + : '(diagram' diagramNameDef (annotate | comment | figure | userData)* ')' + ; + +diagramNameDef + : nameDef + ; + +directionalPortAttributeOverride + : '(directionalPortAttributeOverride' ( + inputPortAttributes + | outputPortAttributes + | bidirectionalPortAttributes + ) ')' + ; + +display + : '(display' (figureGroupNameRef | figureGroupOverride)* transform ')' + ; + +displayAttributes + : '(displayAttributes' ( + borderPattern + | borderPatternVisible + | borderWidth + | color + | fillPattern + | fillPatternVisible + | fontRef + | horizontalJustification + | textHeight + | verticalJustification + | visible + )* ')' + ; + +displayName + : '(displayName' stringToken ')' + ; + +displayNameOverride + : '(displayNameOverride' stringToken (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +distanceValue + : integerValue + ; + +dividend + : integerExpression + ; + +divisor + : integerExpression + ; + +documentation + : '(documentation' documentationNameDef documentationHeader (section)* ')' + ; + +documentationHeader + : '(documentationHeader' documentationUnits (backgroundColor | nameInformation | status)* ')' + ; + +documentationNameCaseSensitive + : '(documentationNameCaseSensitive' booleanToken ')' + ; + +documentationNameDef + : nameDef + ; + +documentationUnits + : '(documentationUnits' (setAngle | setDistance)* ')' + ; + +dominates + : '(dominates' (logicNameRef)* ')' + ; + +dot + : '(dot' pointValue ')' + ; + +drawingDescription + : '(drawingDescription' stringToken ')' + ; + +drawingDescriptionDisplay + : '(drawingDescriptionDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +drawingIdentification + : '(drawingIdentification' stringToken ')' + ; + +drawingIdentificationDisplay + : '(drawingIdentificationDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +drawingSize + : '(drawingSize' stringToken ')' + ; + +drawingSizeDisplay + : '(drawingSizeDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +duration + : '(duration' timeValue ')' + ; + +e + : '(e' mantissa exponent ')' + ; + +edif + : '(edif' edifNameDef edifVersion edifHeader ( + library_ + | design + | comment + | external_ + | userData + )* ')' + ; + +edifHeader + : '(edifHeader' edifLevel keywordMap unitDefinitions fontDefinitions physicalDefaults ( + characterEncoding + | constantValues + | documentation + | globalPortDefinitions + | nameCaseSensitivity + | nameInformation + | physicalScaling + | property_ + | status + )* ')' + ; + +edifLevel + : '(edifLevel' edifLevelValue ')' + ; + +edifLevelValue + : integerToken + ; + +edifNameDef + : nameDef + ; + +edifVersion + : '(edifVersion' mark issue subIssue ')' + ; + +endPoint + : pointValue + ; + +endType + : '(endType' (truncate | round_ | extend) ')' + ; + +engineeringDate + : '(engineeringDate' date ')' + ; + +engineeringDateDisplay + : '(engineeringDateDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +event + : '(event' (portRef | portList | portSet | interconnectRef | interconnectSet) ( + becomes + | transition + )* ')' + ; + +exponent + : integerToken + ; + +extend + : '(extend' ')' + ; + +extendForFrameMemberDef + : forFrameMemberRef + ; + +extendFrameDef + : frameNameRef + ; + +extendInstanceDef + : instanceNameRef + ; + +extendInstanceMemberDef + : instanceMemberRef + ; + +extendInterconnectDef + : interconnectNameRef + ; + +extendPageDef + : pageNameRef + ; + +extendPortDef + : portNameRef + ; + +extendPortMemberDef + : portMemberRef + ; + +extendSignalDef + : signalNameRef + ; + +extendSignalGroupDef + : signalGroupNameRef + ; + +extendSignalMemberDef + : signalMemberRef + ; + +external_ + : '(external' libraryNameDef libraryHeader ( + cell + | comment + | geometryMacro + | pageBorderTemplate + | pageTitleBlockTemplate + | schematicFigureMacro + | schematicForFrameBorderTemplate + | schematicGlobalPortTemplate + | schematicIfFrameBorderTemplate + | schematicInterconnectTerminatorTemplate + | schematicJunctionTemplate + | schematicMasterPortTemplate + | schematicOffPageConnectorTemplate + | schematicOnPageConnectorTemplate + | schematicOtherwiseFrameBorderTemplate + | schematicRipperTemplate + | schematicSymbolBorderTemplate + | schematicSymbolPortTemplate + | userData + )* ')' + ; + +fahrenheit + : '(fahrenheit' unitExponent ')' + ; + +efalse + : '(false' ')' + ; + +farad + : '(farad' unitExponent ')' + ; + +figure + : '(figure' (figureGroupNameRef | figureGroupOverride) ( + circle + | comment + | complexGeometry + | dot + | openShape + | path + | polygon + | rectangle + | shape + | userData + )* ')' + ; + +figureGroup + : '(figureGroup' figureGroupNameDef ( + comment + | cornerType + | displayAttributes + | endType + | nameInformation + | pathWidth + | property_ + | userData + )* ')' + ; + +figureGroupNameCaseSensitive + : '(figureGroupNameCaseSensitive' booleanToken ')' + ; + +figureGroupNameDef + : nameDef + ; + +figureGroupNameRef + : nameRef + ; + +figureGroupOverride + : '(figureGroupOverride' figureGroupNameRef ( + comment + | cornerType + | displayAttributes + | endType + | pathWidth + | propertyOverride + )* ')' + ; + +fillPattern + : '(fillPattern' pixelPattern ')' + ; + +fillPatternVisible + : '(fillPatternVisible' booleanValue ')' + ; + +firstIntegerExpression + : integerExpression + ; + +firstStringExpression + : stringExpression + ; + +fixed + : '(fixed' ')' + ; + +font + : '(font' fontNameDef typeface fontProportions ( + boldStyle + | italicStyle + | property_ + | proportionalFont + | userData + )* ')' + ; + +fontCapitalHeight + : '(fontCapitalHeight' lengthValue ')' + ; + +fontDefinitions + : '(fontDefinitions' (fonts)? ')' + ; + +fontDescent + : '(fontDescent' lengthValue ')' + ; + +fontFamily + : stringToken + ; + +fontHeight + : '(fontHeight' lengthValue ')' + ; + +fontNameDef + : nameDef + ; + +fontNameRef + : nameRef + ; + +fontProportions + : '(fontProportions' fontHeight fontDescent fontCapitalHeight fontWidth ')' + ; + +fontRef + : '(fontRef' fontNameRef ')' + ; + +fonts + : '(fonts' setDistance (font)* ')' + ; + +fontWidth + : '(fontWidth' lengthValue ')' + ; + +forbiddenEvent + : '(forbiddenEvent' timeInterval (event)* ')' + ; + +forFrame + : '(forFrame' frameNameDef repetitionCount forFrameIndex logicalConnectivity ( + comment + | documentation + | nameInformation + | property_ + | userData + )* ')' + ; + +forFrameAnnotate + : '(forFrameAnnotate' extendForFrameMemberDef ( + comment + | forFrameAnnotate + | ifFrameAnnotate + | interconnectAnnotate + | leafOccurrenceAnnotate + | occurrenceAnnotate + | otherwiseFrameAnnotate + )* ')' + ; + +forFrameIndex + : '(forFrameIndex' indexNameDef (indexStart | indexStep | nameInformation)* ')' + ; + +forFrameIndexDisplay + : '(forFrameIndexDisplay' ( + indexEndDisplay + | indexNameDisplay + | indexStartDisplay + | indexStepDisplay + )* ')' + ; + +forFrameIndexNameCaseSensitive + : '(forFrameIndexNameCaseSensitive' booleanToken ')' + ; + +forFrameIndexRef + : '(forFrameIndexRef' indexNameRef ')' + ; + +forFrameMemberRef + : '(forFrameMemberRef' frameNameRef indexValue ')' + ; + +forFrameRef + : '(forFrameRef' frameNameRef ')' + ; + +frameConfiguration + : '(frameConfiguration' frameNameRef (frameConfiguration | instanceConfiguration)* ')' + ; + +frameNameCaseSensitive + : '(frameNameCaseSensitive' booleanToken ')' + ; + +frameNameDef + : nameDef + ; + +frameNameRef + : nameRef + ; + +frameRef + : '(frameRef' frameNameRef ')' + ; + +frequencyValue + : miNoMaxValue + ; + +fromBottom + : '(fromBottom' ')' + ; + +fromInteger + : integerToken + ; + +fromLeft + : '(fromLeft' ')' + ; + +fromRight + : '(fromRight' ')' + ; + +fromTop + : '(fromTop' ')' + ; + +generated + : '(generated' ')' + ; + +geometryMacro + : '(geometryMacro' libraryObjectNameDef geometryMacroHeader ( + circle + | comment + | complexGeometry + | dot + | openShape + | path + | polygon + | rectangle + | shape + | userData + )* ')' + ; + +geometryMacroHeader + : '(geometryMacroHeader' geometryMacroUnits ( + backgroundColor + | documentation + | nameInformation + | originalBoundingBox + | property_ + | status + )* ')' + ; + +geometryMacroRef + : '(geometryMacroRef' libraryObjectNameRef (libraryRef)? ')' + ; + +geometryMacroUnits + : '(geometryMacroUnits' (setAngle)? ')' + ; + +globalPort + : '(globalPort' globalPortNameDef ( + comment + | nameInformation + | property_ + | schematicGlobalPortAttributes + | userData + )* ')' + ; + +globalPortBundle + : '(globalPortBundle' globalPortNameDef globalPortList ( + comment + | nameInformation + | property_ + | userData + )* ')' + ; + +globalPortDefinitions + : '(globalPortDefinitions' (globalPort | globalPortBundle)* ')' + ; + +globalPortList + : '(globalPortList' (globalPortRef)* ')' + ; + +globalPortNameCaseSensitive + : '(globalPortNameCaseSensitive' booleanToken ')' + ; + +globalPortNameDef + : nameDef + ; + +globalPortNameDisplay + : '(globalPortNameDisplay' (display | displayNameOverride)* ')' + ; + +globalPortNameRef + : nameRef + ; + +globalPortPropertyDisplay + : '(globalPortPropertyDisplay' propertyNameRef (display | propertyNameDisplay)* ')' + ; + +globalPortRef + : '(globalPortRef' globalPortNameRef ')' + ; + +globalPortScope + : '(globalPortScope' globalPortNameRef ')' + ; + +green + : scaledInteger + ; + +henry + : '(henry' unitExponent ')' + ; + +hertz + : '(hertz' unitExponent ')' + ; + +horizontalJustification + : '(horizontalJustification' (leftJustify | centerJustify | rightJustify) ')' + ; + +hotspot + : '(hotspot' pointValue ( + hotspotConnectDirection + | hotspotNameDisplay + | nameInformation + | schematicWireAffinity + )* ')' + ; + +hotspotConnectDirection + : '(hotspotConnectDirection' (fromBottom | fromLeft | fromRight | fromTop)* ')' + ; + +hotspotGrid + : '(hotspotGrid' lengthValue ')' + ; + +hotspotNameCaseSensitive + : '(hotspotNameCaseSensitive' booleanToken ')' + ; + +hotspotNameDef + : nameDef + ; + +hotspotNameDisplay + : '(hotspotNameDisplay' (display | displayNameOverride)* ')' + ; + +hotspotNameRef + : nameRef + ; + +hourNumber + : integerToken + ; + +ieeeDesignation + : stringToken + ; + +ieeeSection + : '(ieeeSection' (integerToken)* ')' + ; + +ieeeStandard + : '(ieeeStandard' ieeeDesignation year (comment | ieeeSection)* ')' + ; + +ifFrame + : '(ifFrame' frameNameDef condition logicalConnectivity ( + comment + | nameInformation + | documentation + | property_ + | userData + )* ')' + ; + +ifFrameAnnotate + : '(ifFrameAnnotate' extendFrameDef ( + comment + | forFrameAnnotate + | ifFrameAnnotate + | interconnectAnnotate + | leafOccurrenceAnnotate + | occurrenceAnnotate + | otherwiseFrameAnnotate + | propertyOverride + )* ')' + ; + +ifFrameRef + : '(ifFrameRef' frameNameRef ')' + ; + +ifFrameSet + : '(ifFrameSet' (ifFrameRef)* ')' + ; + +ignore + : '(ignore' ')' + ; + +implementationNameCaseSensitive + : '(implementationNameCaseSensitive' booleanToken ')' + ; + +implementationNameDef + : nameDef + ; + +implementationNameDisplay + : '(implementationNameDisplay' (display | displayNameOverride)* ')' + ; + +implementationNameRef + : nameRef + ; + +indexEndDisplay + : '(indexEndDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +indexNameDef + : nameDef + ; + +indexNameDisplay + : '(indexNameDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +indexNameRef + : nameRef + ; + +indexStart + : '(indexStart' integerExpression ')' + ; + +indexStartDisplay + : '(indexStartDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +indexStep + : '(indexStep' integerExpression ')' + ; + +indexStepDisplay + : '(indexStepDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +indexValue + : '(indexValue' integerToken ')' + ; + +input_ + : '(input' ')' + ; + +inputPort + : '(inputPort' (inputPortAttributes)? ')' + ; + +inputPortAttributes + : '(inputPortAttributes' (dcFanOutLoad | dcMaxFanIn)* ')' + ; + +instance + : '(instance' instanceNameDef clusterRef ( + booleanParameterAssign + | cellPropertyOverride + | clusterPropertyOverride + | comment + | designator + | instanceNameGenerator + | instancePortAttributes + | instanceWidth + | integerParameterAssign + | nameInformation + | numberParameterAssign + | property_ + | stringParameterAssign + | timing + | userData + )* ')' + ; + +instanceConfiguration + : '(instanceConfiguration' instanceNameRef clusterConfigurationRef ')' + ; + +instanceIndexValue + : '(instanceIndexValue' ')' + ; + +instanceMemberRef + : '(instanceMemberRef' instanceNameRef indexValue ')' + ; + +instanceNameCaseSensitive + : '(instanceNameCaseSensitive' booleanToken ')' + ; + +instanceNameDef + : nameDef + ; + +instanceNameDisplay + : '(instanceNameDisplay' (display | displayNameOverride)* ')' + ; + +instanceNameGenerator + : '(instanceNameGenerator' stringExpression ')' + ; + +instanceNameGeneratorDisplay + : '(instanceNameGeneratorDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +instanceNameRef + : nameRef + ; + +instancePortAttributeDisplay + : '(instancePortAttributeDisplay' symbolPortImplementationNameRef portRef ( + portPropertyDisplayOverride + | portAttributeDisplay + )* ')' + ; + +instancePortAttributes + : '(instancePortAttributes' extendPortDef ( + acLoad + | comment + | connectedSignalIndexGenerator + | designator + | directionalPortAttributeOverride + | portDelay + | portDelayOverride + | portLoadDelay + | portLoadDelayOverride + | portPropertyOverride + | property_ + | unused + )* ')' + ; + +instancePropertyDisplay + : '(instancePropertyDisplay' propertyNameRef (display)* (propertyNameDisplay)? (display)* ')' + ; + +instancePropertyOverride + : '(instancePropertyOverride' propertyNameRef (typedValue | untyped) ( + comment + | fixed + | propertyOverride + )* ')' + ; + +instanceRef + : '(instanceRef' instanceNameRef ')' + ; + +instanceWidth + : '(instanceWidth' integerExpression ')' + ; + +instanceWidthDisplay + : '(instanceWidthDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +integer + : '(integer' integerExpression ')' + ; + +integerConstant + : '(integerConstant' constantNameDef integerToken ')' + ; + +integerConstantRef + : '(integerConstantRef' constantNameRef ')' + ; + +integerEqual + : '(integerEqual' firstIntegerExpression secondIntegerExpression ')' + ; + +integerExpression + : ( + integerParameterRef + | integerToken + | integerProduct + | integerSubtract + | integerSum + | integerRemainder + | integerQuotient + | stringLength + | integerConstantRef + | forFrameIndexRef + | portIndexValue + | signalIndexValue + | absolute + | instanceIndexValue + ) + ; + +integerParameter + : '(integerParameter' parameterNameDef (integer | nameInformation)* ')' + ; + +integerParameterAssign + : '(integerParameterAssign' parameterNameRef integerExpression ')' + ; + +integerParameterRef + : '(integerParameterRef' parameterNameRef ')' + ; + +integerProduct + : '(integerProduct' (integerExpression)* ')' + ; + +integerQuotient + : '(integerQuotient' dividend divisor ')' + ; + +integerRemainder + : '(integerRemainder' dividend divisor ')' + ; + +integerSubtract + : '(integerSubtract' minuend subtrahend ')' + ; + +integerSum + : '(integerSum' (integerExpression)* ')' + ; + +integerValue + : integerToken + ; + +interconnectAnnotate + : '(interconnectAnnotate' extendInterconnectDef ( + comment + | interconnectAnnotate + | criticality + | interconnectDelay + | property_ + | propertyOverride + )* ')' + ; + +interconnectAttachedText + : '(interconnectAttachedText' attachmentPoint ( + annotate + | connectivityTagGeneratorDisplay + | criticalityDisplay + | interconnectDelayDisplay + | interconnectNameDisplay + | interconnectPropertyDisplay + )* ')' + ; + +interconnectDelay + : '(interconnectDelay' interconnectDelayNameDef derivation delay (becomes | transition)* ')' + ; + +interconnectDelayDisplay + : '(interconnectDelayDisplay' interconnectDelayNameRef (display)* ')' + ; + +interconnectDelayNameDef + : nameDef + ; + +interconnectDelayNameRef + : nameRef + ; + +interconnectHeader + : '(interconnectHeader' ( + criticality + | documentation + | interconnectDelay + | nameInformation + | property_ + )* ')' + ; + +interconnectNameCaseSensitive + : '(interconnectNameCaseSensitive' booleanToken ')' + ; + +interconnectNameDef + : nameDef + ; + +interconnectNameDisplay + : '(interconnectNameDisplay' (display | displayNameOverride)* ')' + ; + +interconnectNameRef + : nameRef + ; + +interconnectPropertyDisplay + : '(interconnectPropertyDisplay' propertyNameRef (display)* (propertyNameDisplay)? (display)* ')' + ; + +interconnectRef + : '(interconnectRef' interconnectNameRef (pageRef)? ')' + ; + +interconnectSet + : '(interconnectSet' (interconnectRef)* ')' + ; + +einterface + : '(interface' interfaceUnits ( + designator + | booleanParameter + | integerParameter + | interfaceJoined + | mustJoin + | numberParameter + | permutable + | port + | portBundle + | stringParameter + | timing + | weakJoined + )* ')' + ; + +interfaceJoined + : '(interfaceJoined' (portRef)* ')' + ; + +interfaceUnits + : '(interfaceUnits' (setCapacitance | setTime)* ')' + ; + +iso8859 + : '(iso8859' iso8859Part ')' + ; + +iso8859Part + : integerToken + ; + +isolated + : '(isolated' ')' + ; + +issue + : integerToken + ; + +italicStyle + : '(italicStyle' ')' + ; + +jisx0201 + : '(jisx0201' ')' + ; + +jisx0208 + : '(jisx0208' ')' + ; + +joinedAsSignal + : '(joinedAsSignal' ')' + ; + +joule + : '(joule' unitExponent ')' + ; + +k0KeywordLevel + : '(k0KeywordLevel' ')' + ; + +k1KeywordAlias + : '(k1KeywordAlias' k1KeywordNameDef k1KeywordNameRef ')' + ; + +k1KeywordLevel + : '(k1KeywordLevel' (k1KeywordAlias)* ')' + ; + +k1KeywordNameDef + : IDENTIFIER + ; + +k1KeywordNameRef + : IDENTIFIER + ; + +k2Actual + : '(k2Actual' k2FormalNameRef ')' + ; + +k2Build + : '(k2Build' k1KeywordNameRef (comment | k2Actual | k2Build | k2Literal)* ')' + ; + +k2Formal + : '(k2Formal' k2FormalNameDef (k2Optional | k2Required) ')' + ; + +k2FormalNameDef + : IDENTIFIER + ; + +k2FormalNameRef + : IDENTIFIER + ; + +k2Generate + : '(k2Generate' (comment | k2Actual | k2Build | k2Literal)* ')' + ; + +k2KeywordDefine + : '(k2KeywordDefine' k1KeywordNameDef k2KeywordParameters k2Generate ')' + ; + +k2KeywordLevel + : '(k2KeywordLevel' (k1KeywordAlias | k2KeywordDefine)* ')' + ; + +k2KeywordParameters + : '(k2KeywordParameters' (k2Formal)* ')' + ; + +k2Literal + : '(k2Literal' (IDENTIFIER | integerToken | stringToken)* ')' + ; + +k2Optional + : '(k2Optional' (k2Literal | k2Actual | k2Build) ')' + ; + +k2Required + : '(k2Required' ')' + ; + +k3Build + : '(k3Build' k1KeywordNameRef (comment | k2Actual | k2Literal | k3Build | k3ForEach)* ')' + ; + +k3Collector + : '(k3Collector' ')' + ; + +k3ForEach + : '(k3ForEach' (k2FormalNameRef | k3FormalList) ( + comment + | k2Actual + | k2Literal + | k3Build + | k3ForEach + )* ')' + ; + +k3Formal + : '(k3Formal' k2FormalNameDef (k2Optional | k2Required | k3Collector) ')' + ; + +k3FormalList + : '(k3FormalList' (k2FormalNameRef)* ')' + ; + +k3Generate + : '(k3Generate' (comment | k2Actual | k2Build | k2Literal | k3ForEach)* ')' + ; + +k3KeywordDefine + : '(k3KeywordDefine' k1KeywordNameDef k3KeywordParameters k3Generate ')' + ; + +k3KeywordLevel + : '(k3KeywordLevel' (k1KeywordAlias | k3KeywordDefine)* ')' + ; + +k3KeywordParameters + : '(k3KeywordParameters' (k3Formal)* ')' + ; + +kelvin + : '(kelvin' unitExponent ')' + ; + +keywordMap + : '(keywordMap' (k0KeywordLevel | k1KeywordLevel | k2KeywordLevel | k3KeywordLevel) (comment)* ')' + ; + +kilogram + : '(kilogram' unitExponent ')' + ; + +leaf + : '(leaf' ')' + ; + +leafOccurrenceAnnotate + : '(leafOccurrenceAnnotate' (extendInstanceDef | extendInstanceMemberDef) ( + cellPropertyOverride + | clusterPropertyOverride + | comment + | designator + | instancePropertyOverride + | portAnnotate + | property_ + )* ')' + ; + +leftJustify + : '(leftJustify' ')' + ; + +lengthValue + : distanceValue + ; + +lessThan + : '(lessThan' (integerExpression)* ')' + ; + +lessThanOrEqual + : '(lessThanOrEqual' (integerExpression)* ')' + ; + +library_ + : '(library' libraryNameDef libraryHeader ( + cell + | schematicInterconnectTerminatorTemplate + | schematicJunctionTemplate + | schematicGlobalPortTemplate + | schematicMasterPortTemplate + | schematicOffPageConnectorTemplate + | schematicOnPageConnectorTemplate + | schematicRipperTemplate + | schematicSymbolBorderTemplate + | schematicSymbolPortTemplate + | pageBorderTemplate + | pageTitleBlockTemplate + | comment + | geometryMacro + | schematicFigureMacro + | schematicForFrameBorderTemplate + | schematicIfFrameBorderTemplate + | schematicOtherwiseFrameBorderTemplate + | userData + )* ')' + ; + +libraryHeader + : '(libraryHeader' edifLevel nameCaseSensitivity technology ( + backgroundColor + | documentation + | nameInformation + | property_ + | status + )* ')' + ; + +libraryNameCaseSensitive + : '(libraryNameCaseSensitive' booleanToken ')' + ; + +libraryNameDef + : nameDef + ; + +libraryNameRef + : nameRef + ; + +libraryObjectNameCaseSensitive + : '(libraryObjectNameCaseSensitive' booleanToken ')' + ; + +libraryObjectNameDef + : nameDef + ; + +libraryObjectNameRef + : nameRef + ; + +libraryRef + : '(libraryRef' libraryNameRef ')' + ; + +loadDelay + : '(loadDelay' acLoadFactorTime acLoadFactorCapacitance ')' + ; + +localPortGroup + : '(localPortGroup' localPortGroupNameDef portList ( + comment + | nameInformation + | property_ + | userData + )* ')' + ; + +localPortGroupNameCaseSensitive + : '(localPortGroupNameCaseSensitive' booleanToken ')' + ; + +localPortGroupNameDef + : nameDef + ; + +localPortGroupNameRef + : nameRef + ; + +localPortGroupRef + : '(localPortGroupRef' localPortGroupNameRef ')' + ; + +logicalConnectivity + : '(logicalConnectivity' ( + comment + | forFrame + | ifFrame + | instance + | otherwiseFrame + | signal + | signalGroup + | userData + )* ')' + ; + +logicDefinitions + : '(logicDefinitions' setVoltage setCurrent (comment | logicValue)* ')' + ; + +logicList + : '(logicList' (ignore | logicNameRef | logicOneOf)* ')' + ; + +logicMapInput + : '(logicMapInput' (logicRef)* ')' + ; + +logicMapOutput + : '(logicMapOutput' (logicRef)* ')' + ; + +logicModelUnits + : '(logicModelUnits' (setCapacitance | setTime)* ')' + ; + +logicModelView + : '(logicModelView' viewNameDef (comment | nameInformation | userData)* ')' + ; + +logicNameDef + : nameDef + ; + +logicNameRef + : nameRef + ; + +logicOneOf + : '(logicOneOf' (logicList | logicNameRef)* ')' + ; + +logicRef + : '(logicRef' logicNameRef (libraryRef)? ')' + ; + +logicValue + : '(logicValue' logicNameDef ( + booleanMap + | comment + | compound + | currentMap + | dominates + | isolated + | logicMapInput + | logicMapOutput + | nameInformation + | property_ + | resolves + | strong + | voltageMap + | weak_ + )* ')' + ; + +lsbToMsb + : '(lsbToMsb' ')' + ; + +mantissa + : integerToken + ; + +mark + : integerToken + ; + +maskLayoutUnits + : '(maskLayoutUnits' (setAngle | setCapacitance | setDistance | setTime)* ')' + ; + +maskLayoutView + : '(maskLayoutView' viewNameDef (comment | nameInformation | userData)* ')' + ; + +measured + : '(measured' ')' + ; + +meter + : '(meter' unitExponent ')' + ; + +middleJustify + : '(middleJustify' ')' + ; + +minimalWidth + : '(minimalWidth' ')' + ; + +minimumStringLength + : '(minimumStringLength' substringLength ')' + ; + +miNoMax + : '(miNoMax' miNoMaxValue ')' + ; + +miNoMaxValue + : (numberValue | mnm) + ; + +minuend + : integerExpression + ; + +minuteNumber + : integerToken + ; + +mixedDirection + : '(mixedDirection' ')' + ; + +mnm + : '(mnm' (numberValue | undefined | unconstrained) (numberValue | undefined | unconstrained) ( + numberValue + | undefined + | unconstrained + ) ')' + ; + +mole + : '(mole' unitExponent ')' + ; + +monthNumber + : integerToken + ; + +msbToLsb + : '(msbToLsb' ')' + ; + +mustJoin + : '(mustJoin' (interfaceJoined | portRef | weakJoined)* ')' + ; + +nameAlias + : '(nameAlias' originalName (displayName | generated | nameStructure)* ')' + ; + +nameCaseSensitivity + : '(nameCaseSensitivity' ( + clusterConfigurationNameCaseSensitive + | clusterNameCaseSensitive + | designHierarchyNameCaseSensitive + | designNameCaseSensitive + | documentationNameCaseSensitive + | figureGroupNameCaseSensitive + | forFrameIndexNameCaseSensitive + | frameNameCaseSensitive + | globalPortNameCaseSensitive + | hotspotNameCaseSensitive + | implementationNameCaseSensitive + | instanceNameCaseSensitive + | interconnectNameCaseSensitive + | libraryNameCaseSensitive + | libraryObjectNameCaseSensitive + | localPortGroupNameCaseSensitive + | pageNameCaseSensitive + | parameterNameCaseSensitive + | portNameCaseSensitive + | propertyNameCaseSensitive + | signalGroupNameCaseSensitive + | signalNameCaseSensitive + | viewGroupNameCaseSensitive + | viewNameCaseSensitive + )* ')' + ; + +nameDef + : IDENTIFIER + ; + +nameDimension + : '(nameDimension' nameDimensionStructure (bitOrder)? ')' + ; + +nameDimensionStructure + : '(nameDimensionStructure' ( + complementedName + | complexName + | integerValue + | sequence + | simpleName + )* ')' + ; + +nameInformation + : '(nameInformation' primaryName (nameAlias)* ')' + ; + +namePartSeparator + : '(namePartSeparator' stringToken ')' + ; + +nameRef + : IDENTIFIER + ; + +nameStructure + : '(nameStructure' (simpleName | complexName | complementedName) ')' + ; + +narrowPort + : '(narrowPort' ')' + ; + +narrowWire + : '(narrowWire' ')' + ; + +noHotspotGrid + : '(noHotspotGrid' ')' + ; + +nominalHotspotGrid + : '(nominalHotspotGrid' lengthValue ')' + ; + +nonPermutable + : '(nonPermutable' (permutable | portRef)* ')' + ; + +not_ + : '(not' booleanExpression ')' + ; + +notInherited + : '(notInherited' ')' + ; + +number + : '(number' numberExpression ')' + ; + +numberExpression + : (numberValue | numberParameterRef) + ; + +numberOfBasicUnits + : scaledInteger + ; + +numberOfNewUnits + : scaledInteger + ; + +numberParameter + : '(numberParameter' parameterNameDef (nameInformation | number)* ')' + ; + +numberParameterAssign + : '(numberParameterAssign' parameterNameRef numberExpression ')' + ; + +numberParameterRef + : '(numberParameterRef' parameterNameRef ')' + ; + +numberPoint + : '(numberPoint' xNumberValue yNumberValue ')' + ; + +numberValue + : scaledInteger + ; + +numerator + : integerValue + ; + +occurrenceAnnotate + : '(occurrenceAnnotate' (extendInstanceDef | extendInstanceMemberDef) ( + cellPropertyOverride + | clusterPropertyOverride + | comment + | designator + | forFrameAnnotate + | ifFrameAnnotate + | instancePropertyOverride + | interconnectAnnotate + | leafOccurrenceAnnotate + | occurrenceAnnotate + | otherwiseFrameAnnotate + | pageAnnotate + | portAnnotate + | property_ + | signalAnnotate + | signalGroupAnnotate + | timing + | viewPropertyOverride + )* ')' + ; + +occurrenceHierarchyAnnotate + : '(occurrenceHierarchyAnnotate' ( + cellPropertyOverride + | clusterPropertyOverride + | comment + | forFrameAnnotate + | ifFrameAnnotate + | interconnectAnnotate + | leafOccurrenceAnnotate + | occurrenceAnnotate + | otherwiseFrameAnnotate + | pageAnnotate + | portAnnotate + | signalAnnotate + | signalGroupAnnotate + | timing + | viewPropertyOverride + )* ')' + ; + +offsetEvent + : '(offsetEvent' event numberValue ')' + ; + +ohm + : '(ohm' unitExponent ')' + ; + +openShape + : '(openShape' curve ')' + ; + +or_ + : '(or' (booleanExpression)* ')' + ; + +origin + : '(origin' pointValue ')' + ; + +originalBoundingBox + : '(originalBoundingBox' rectangle ')' + ; + +originalDrawingDate + : '(originalDrawingDate' date ')' + ; + +originalDrawingDateDisplay + : '(originalDrawingDateDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +originalName + : stringToken + ; + +otherwiseFrame + : '(otherwiseFrame' frameNameDef ifFrameSet logicalConnectivity ( + comment + | documentation + | nameInformation + | property_ + | userData + )* ')' + ; + +otherwiseFrameAnnotate + : '(otherwiseFrameAnnotate' extendFrameDef ( + comment + | forFrameAnnotate + | ifFrameAnnotate + | interconnectAnnotate + | leafOccurrenceAnnotate + | occurrenceAnnotate + | otherwiseFrameAnnotate + | propertyOverride + )* ')' + ; + +otherwiseFrameRef + : '(otherwiseFrameRef' frameNameRef ')' + ; + +output + : '(output' ')' + ; + +outputPort + : '(outputPort' (outputPortAttributes)? ')' + ; + +outputPortAttributes + : '(outputPortAttributes' (dcFanInLoad | dcMaxFanOut)* ')' + ; + +owner + : '(owner' stringValue ')' + ; + +page + : '(page' pageNameDef pageHeader ( + cellPropertyDisplay + | clusterPropertyDisplay + | comment + | localPortGroup + | pageCommentGraphics + | pageTitleBlock + | propertyDisplay + | schematicBus + | schematicForFrameImplementation + | schematicGlobalPortImplementation + | schematicIfFrameImplementation + | schematicInstanceImplementation + | schematicMasterPortImplementation + | schematicNet + | schematicOffPageConnectorImplementation + | schematicOnPageConnectorImplementation + | schematicOtherwiseFrameImplementation + | schematicRipperImplementation + | userData + | viewPropertyDisplay + )* ')' + ; + +pageAnnotate + : '(pageAnnotate' extendPageDef (interconnectAnnotate)* ')' + ; + +pageBorder + : '(pageBorder' pageBorderTemplateRef transform (propertyDisplayOverride | propertyOverride)* ')' + ; + +pageBorderTemplate + : '(pageBorderTemplate' libraryObjectNameDef schematicTemplateHeader usableArea ( + annotate + | commentGraphics + | figure + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +pageBorderTemplateRef + : '(pageBorderTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +pageCommentGraphics + : '(pageCommentGraphics' (annotate | comment | figure | schematicComplexFigure | userData)* ')' + ; + +pageHeader + : '(pageHeader' ( + backgroundColor + | documentation + | nameInformation + | originalBoundingBox + | pageBorder + | pageSize + | property_ + | status + )* ')' + ; + +pageIdentification + : '(pageIdentification' stringToken ')' + ; + +pageIdentificationDisplay + : '(pageIdentificationDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +pageNameCaseSensitive + : '(pageNameCaseSensitive' booleanToken ')' + ; + +pageNameDef + : nameDef + ; + +pageNameRef + : nameRef + ; + +pagePropertyDisplay + : '(pagePropertyDisplay' propertyNameRef (display | propertyNameDisplay)* ')' + ; + +pageRef + : '(pageRef' pageNameRef ')' + ; + +pageSize + : '(pageSize' rectangle ')' + ; + +pageTitle + : '(pageTitle' stringToken ')' + ; + +pageTitleBlock + : '(pageTitleBlock' implementationNameDef pageTitleBlockTemplateRef transform ( + nameInformation + | pagePropertyDisplay + | pageTitleBlockAttributeDisplay + | pageTitleBlockAttributes + | property_ + | propertyDisplay + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +pageTitleBlockAttributeDisplay + : '(pageTitleBlockAttributeDisplay' ( + approvedDateDisplay + | checkDateDisplay + | companyNameDisplay + | contractDisplay + | copyrightDisplay + | drawingDescriptionDisplay + | drawingIdentificationDisplay + | drawingSizeDisplay + | engineeringDateDisplay + | originalDrawingDateDisplay + | pageIdentificationDisplay + | pageTitleDisplay + | revisionDisplay + | totalPagesDisplay + )* ')' + ; + +pageTitleBlockAttributes + : '(pageTitleBlockAttributes' ( + approvedDate + | checkDate + | companyName + | contract + | drawingDescription + | drawingIdentification + | drawingSize + | engineeringDate + | originalDrawingDate + | pageIdentification + | pageTitle + | revision + )* ')' + ; + +pageTitleBlockTemplate + : '(pageTitleBlockTemplate' libraryObjectNameDef schematicTemplateHeader ( + annotate + | commentGraphics + | figure + | pageTitleBlockAttributeDisplay + | pageTitleBlockAttributes + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +pageTitleBlockTemplateRef + : '(pageTitleBlockTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +pageTitleDisplay + : '(pageTitleDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +parameterDisplay + : '(parameterDisplay' parameterNameRef (addDisplay | replaceDisplay | removeDisplay) ( + parameterNameDisplay + )? ')' + ; + +parameterNameCaseSensitive + : '(parameterNameCaseSensitive' booleanToken ')' + ; + +parameterNameDef + : nameDef + ; + +parameterNameDisplay + : '(parameterNameDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +parameterNameRef + : nameRef + ; + +path + : '(path' pointList ')' + ; + +pathDelay + : '(pathDelay' delay (event)* ')' + ; + +pathWidth + : '(pathWidth' (lengthValue | minimalWidth) ')' + ; + +pcbLayoutUnits + : '(pcbLayoutUnits' (setAngle | setCapacitance | setDistance | setTime)* ')' + ; + +pcbLayoutView + : '(pcbLayoutView' viewNameDef (comment | nameInformation | userData)* ')' + ; + +permutable + : '(permutable' (nonPermutable | permutable | portRef)* ')' + ; + +physicalDefaults + : '(physicalDefaults' (schematicRequiredDefaults)? ')' + ; + +physicalScaling + : '(physicalScaling' ( + comment + | connectivityUnits + | documentationUnits + | geometryMacroUnits + | interfaceUnits + | logicModelUnits + | maskLayoutUnits + | pcbLayoutUnits + | schematicUnits + | symbolicLayoutUnits + )* ')' + ; + +pixelPattern + : '(pixelPattern' rowSize (pixelRow)* ')' + ; + +pixelRow + : '(pixelRow' (booleanToken)* ')' + ; + +point + : '(point' pointValue ')' + ; + +pointList + : '(pointList' (pointValue)* ')' + ; + +pointValue + : pt + ; + +polygon + : '(polygon' pointList ')' + ; + +port + : '(port' portNameDef? portDirection? ( + acLoad + | comment + | defaultConnection + | designator + | nameInformation + | portDelay + | portLoadDelay + | portNameGenerator + | portWidth + | property_ + | schematicPortAttributes + | unused + | userData + )* ')' + ; + +portAnnotate + : '(portAnnotate' (extendPortDef | extendPortMemberDef) ( + acLoad + | comment + | designator + | directionalPortAttributeOverride + | portDelay + | portDelayOverride + | portLoadDelay + | portLoadDelayOverride + | portPropertyOverride + | property_ + )* ')' + ; + +portAttributeDisplay + : '(portAttributeDisplay' ( + acLoadDisplay + | connectedSignalIndexGeneratorDisplay + | dcFanInLoadDisplay + | dcFanOutLoadDisplay + | dcMaxFanInDisplay + | dcMaxFanOutDisplay + | designatorDisplay + | portDelayDisplay + | portLoadDelayDisplay + | portNameDisplay + | portNameGeneratorDisplay + | portPropertyDisplay + )* ')' + ; + +portBundle + : '(portBundle' portNameDef portList ( + comment + | nameInformation + | property_ + | userData + | designator + )* ')' + ; + +portDelay + : '(portDelay' portDelayNameDef derivation delay (becomes | transition)* ')' + ; + +portDelayDisplay + : '(portDelayDisplay' portDelayNameRef (display)* ')' + ; + +portDelayNameDef + : nameDef + ; + +portDelayNameRef + : nameRef + ; + +portDelayOverride + : '(portDelayOverride' portDelayNameRef derivation delay (becomes | transition)* ')' + ; + +portDirection + : (inputPort | outputPort | bidirectionalPort | unspecifiedDirectionPort) + ; + +portDirectionIndicator + : (input_ | output | bidirectional | unspecified | unrestricted | mixedDirection) + ; + +portIndexValue + : '(portIndexValue' ')' + ; + +portInstanceRef + : '(portInstanceRef' (portNameRef | portMemberRef) (instanceRef | instanceMemberRef) ')' + ; + +portJoined + : '(portJoined' (globalPortRef | localPortGroupRef | portInstanceRef | portRef)* ')' + ; + +portList + : '(portList' (portRef)* ')' + ; + +portLoadDelay + : '(portLoadDelay' portLoadDelayNameDef derivation loadDelay (becomes | transition)* ')' + ; + +portLoadDelayDisplay + : '(portLoadDelayDisplay' portLoadDelayNameRef (display)* ')' + ; + +portLoadDelayNameDef + : nameDef + ; + +portLoadDelayNameRef + : nameRef + ; + +portLoadDelayOverride + : '(portLoadDelayOverride' portLoadDelayNameRef derivation loadDelay (becomes | transition)* ')' + ; + +portMemberRef + : '(portMemberRef' portNameRef indexValue ')' + ; + +portNameCaseSensitive + : '(portNameCaseSensitive' booleanToken ')' + ; + +portNameDef + : nameDef + ; + +portNameDisplay + : '(portNameDisplay' (display | displayNameOverride)* ')' + ; + +portNameGenerator + : '(portNameGenerator' stringExpression ')' + ; + +portNameGeneratorDisplay + : '(portNameGeneratorDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +portNameRef + : nameRef + ; + +portPropertyDisplay + : '(portPropertyDisplay' propertyNameRef (display | propertyNameDisplay)* ')' + ; + +portPropertyDisplayOverride + : '(portPropertyDisplayOverride' propertyNameRef (addDisplay | replaceDisplay | removeDisplay) ( + propertyNameDisplay + )? ')' + ; + +portPropertyOverride + : '(portPropertyOverride' propertyNameRef (typedValue | untyped) ( + comment + | fixed + | propertyOverride + )* ')' + ; + +portRef + : '(portRef' portNameRef ')' + ; + +portSet + : '(portSet' (portRef)* ')' + ; + +portWidth + : '(portWidth' integerExpression ')' + ; + +presentLogicValue + : (logicNameRef | logicList | logicOneOf) + ; + +previousLogicValue + : (logicNameRef | logicList | logicOneOf) + ; + +previousVersion + : '(previousVersion' viewRef (reason)? ')' + ; + +primaryName + : '(primaryName' originalName (displayName | generated | nameStructure)* ')' + ; + +program + : '(program' stringValue (version)? ')' + ; + +property_ + : '(property' propertyNameDef (typedValue | untyped) ( + comment + | nameInformation + | owner + | property_ + | propertyInheritanceControl + | unitRef + )* ')' + ; + +propertyDisplay + : '(propertyDisplay' propertyNameRef (display | propertyNameDisplay)* ')' + ; + +propertyDisplayOverride + : '(propertyDisplayOverride' propertyNameRef (addDisplay | replaceDisplay | removeDisplay) ( + propertyNameDisplay + )? ')' + ; + +propertyInheritanceControl + : '(propertyInheritanceControl' (fixed | notInherited) ')' + ; + +propertyNameCaseSensitive + : '(propertyNameCaseSensitive' booleanToken ')' + ; + +propertyNameDef + : nameDef + ; + +propertyNameDisplay + : '(propertyNameDisplay' (display | displayNameOverride)* ')' + ; + +propertyNameRef + : nameRef + ; + +propertyOverride + : '(propertyOverride' propertyNameRef (typedValue | untyped) ( + comment + | fixed + | propertyOverride + )* ')' + ; + +proportionalFont + : '(proportionalFont' ')' + ; + +pt + : '(pt' xCoordinate yCoordinate ')' + ; + +pt1 + : pointValue + ; + +pt2 + : pointValue + ; + +radian + : '(radian' unitExponent ')' + ; + +reason + : '(reason' stringToken ')' + ; + +rectangle + : '(rectangle' pt1 pt2 ')' + ; + +red + : scaledInteger + ; + +removeDisplay + : '(removeDisplay' ')' + ; + +repetitionCount + : '(repetitionCount' integerExpression ')' + ; + +repetitionCountDisplay + : '(repetitionCountDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +replaceDisplay + : '(replaceDisplay' (display)* ')' + ; + +required_ + : '(required' ')' + ; + +resolves + : '(resolves' (logicNameRef)* ')' + ; + +revision + : '(revision' stringToken ')' + ; + +revisionDisplay + : '(revisionDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +rightJustify + : '(rightJustify' ')' + ; + +ripperHotspot + : '(ripperHotspot' hotspotNameDef hotspot ')' + ; + +ripperHotspotRef + : '(ripperHotspotRef' hotspotNameRef schematicRipperImplementationRef ')' + ; + +rotation + : '(rotation' angleValue ')' + ; + +round_ + : '(round' ')' + ; + +rowSize + : integerToken + ; + +scaledInteger + : (integerToken | e) + ; + +scaleX + : '(scaleX' numerator denominator ')' + ; + +scaleY + : '(scaleY' numerator denominator ')' + ; + +schematicBus + : '(schematicBus' interconnectNameDef signalGroupRef schematicInterconnectHeader schematicBusJoined ( + comment + | schematicBusDetails + | schematicBusSlice + | schematicInterconnectAttributeDisplay + | userData + )* ')' + ; + +schematicBusDetails + : '(schematicBusDetails' (schematicBusGraphics | schematicSubBusSet) ')' + ; + +schematicBusGraphics + : '(schematicBusGraphics' (comment | figure | schematicComplexFigure | userData)* ')' + ; + +schematicBusJoined + : '(schematicBusJoined' ( + portJoined + | ripperHotspotRef + | schematicGlobalPortImplementationRef + | schematicInterconnectTerminatorImplementationRef + | schematicJunctionImplementationRef + | schematicMasterPortImplementationRef + | schematicOffPageConnectorImplementationRef + | schematicOnPageConnectorImplementationRef + | schematicSymbolPortImplementationRef + )* ')' + ; + +schematicBusSlice + : '(schematicBusSlice' interconnectNameDef signalGroupRef schematicInterconnectHeader schematicBusJoined ( + comment + | schematicBusDetails + | schematicBusSlice + | schematicInterconnectAttributeDisplay + | userData + )* ')' + ; + +schematicComplexFigure + : '(schematicComplexFigure' schematicFigureMacroRef transform ( + propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicFigureMacro + : '(schematicFigureMacro' libraryObjectNameDef schematicTemplateHeader ( + annotate + | comment + | commentGraphics + | figure + | propertyDisplay + | schematicComplexFigure + | userData + )* ')' + ; + +schematicFigureMacroRef + : '(schematicFigureMacroRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicForFrameBorder + : '(schematicForFrameBorder' schematicForFrameBorderTemplateRef transform ( + forFrameIndexDisplay + | propertyDisplayOverride + | propertyOverride + | repetitionCountDisplay + )* ')' + ; + +schematicForFrameBorderTemplate + : '(schematicForFrameBorderTemplate' libraryObjectNameDef schematicTemplateHeader usableArea ( + annotate + | commentGraphics + | figure + | forFrameIndexDisplay + | propertyDisplay + | repetitionCountDisplay + | schematicComplexFigure + )* ')' + ; + +schematicForFrameBorderTemplateRef + : '(schematicForFrameBorderTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicForFrameImplementation + : '(schematicForFrameImplementation' implementationNameDef forFrameRef schematicForFrameImplementationHeader schematicFrameImplementationDetails + ')' + ; + +schematicForFrameImplementationHeader + : '(schematicForFrameImplementationHeader' (schematicForFrameBorder)? ')' + ; + +schematicFrameImplementationDetails + : '(schematicFrameImplementationDetails' ( + cellPropertyDisplay + | clusterPropertyDisplay + | comment + | commentGraphics + | propertyDisplay + | schematicBus + | schematicForFrameImplementation + | schematicGlobalPortImplementation + | schematicIfFrameImplementation + | schematicInstanceImplementation + | schematicMasterPortImplementation + | schematicNet + | schematicOffPageConnectorImplementation + | schematicOnPageConnectorImplementation + | schematicOtherwiseFrameImplementation + | schematicRipperImplementation + | userData + | viewPropertyDisplay + )* ')' + ; + +schematicGlobalPortAttributes + : '(schematicGlobalPortAttributes' ( + ieeeStandard + | schematicPortAcPower + | schematicPortAnalog + | schematicPortChassisGround + | schematicPortClock + | schematicPortDcPower + | schematicPortEarthGround + | schematicPortGround + | schematicPortNonLogical + | schematicPortOpenCollector + | schematicPortOpenEmitter + | schematicPortPower + | schematicPortThreeState + )* ')' + ; + +schematicGlobalPortImplementation + : '(schematicGlobalPortImplementation' implementationNameDef schematicGlobalPortTemplateRef globalPortRef transform ( + globalPortNameDisplay + | globalPortPropertyDisplay + | implementationNameDisplay + | nameInformation + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicGlobalPortImplementationRef + : '(schematicGlobalPortImplementationRef' implementationNameRef ')' + ; + +schematicGlobalPortTemplate + : '(schematicGlobalPortTemplate' libraryObjectNameDef schematicTemplateHeader (hotspot)? ( + annotate + | commentGraphics + | figure + | globalPortNameDisplay + | implementationNameDisplay + | propertyDisplay + | schematicComplexFigure + | schematicGlobalPortAttributes + )* (hotspot)? ')' + ; + +schematicGlobalPortTemplateRef + : '(schematicGlobalPortTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicIfFrameBorder + : '(schematicIfFrameBorder' schematicIfFrameBorderTemplateRef transform ( + conditionDisplay + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicIfFrameBorderTemplate + : '(schematicIfFrameBorderTemplate' libraryObjectNameDef schematicTemplateHeader usableArea ( + annotate + | commentGraphics + | conditionDisplay + | figure + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +schematicIfFrameBorderTemplateRef + : '(schematicIfFrameBorderTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicIfFrameImplementation + : '(schematicIfFrameImplementation' implementationNameDef ifFrameRef schematicIfFrameImplementationHeader schematicFrameImplementationDetails ')' + ; + +schematicIfFrameImplementationHeader + : '(schematicIfFrameImplementationHeader' (schematicIfFrameBorder)? ')' + ; + +schematicImplementation + : '(schematicImplementation' (page | totalPages)* ')' + ; + +schematicInstanceImplementation + : '(schematicInstanceImplementation' implementationNameDef instanceRef schematicSymbolRef transform ( + cellNameDisplay + | cellPropertyDisplayOverride + | clusterPropertyDisplayOverride + | designatorDisplay + | implementationNameDisplay + | instanceNameDisplay + | instanceNameGeneratorDisplay + | instancePortAttributeDisplay + | instancePropertyDisplay + | instanceWidthDisplay + | nameInformation + | pageCommentGraphics + | parameterDisplay + | propertyDisplayOverride + | propertyOverride + | timingDisplay + | viewNameDisplay + )* ')' + ; + +schematicInstanceImplementationRef + : '(schematicInstanceImplementationRef' implementationNameRef ')' + ; + +schematicInterconnectAttributeDisplay + : '(schematicInterconnectAttributeDisplay' ( + connectivityTagGeneratorDisplay + | criticalityDisplay + | interconnectAttachedText + | interconnectDelayDisplay + | interconnectNameDisplay + | interconnectPropertyDisplay + )* ')' + ; + +schematicInterconnectHeader + : '(schematicInterconnectHeader' ( + criticality + | documentation + | interconnectDelay + | nameInformation + | property_ + | schematicInterconnectTerminatorImplementation + | schematicJunctionImplementation + | schematicWireStyle + )* ')' + ; + +schematicInterconnectTerminatorImplementation + : '(schematicInterconnectTerminatorImplementation' implementationNameDef schematicInterconnectTerminatorTemplateRef transform ( + implementationNameDisplay + | nameInformation + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicInterconnectTerminatorImplementationRef + : '(schematicInterconnectTerminatorImplementationRef' implementationNameRef ')' + ; + +schematicInterconnectTerminatorTemplate + : '(schematicInterconnectTerminatorTemplate' libraryObjectNameDef schematicTemplateHeader hotspot ( + commentGraphics + | figure + | implementationNameDisplay + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +schematicInterconnectTerminatorTemplateRef + : '(schematicInterconnectTerminatorTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicJunctionImplementation + : '(schematicJunctionImplementation' implementationNameDef schematicJunctionTemplateRef transform ( + implementationNameDisplay + | nameInformation + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicJunctionImplementationRef + : '(schematicJunctionImplementationRef' implementationNameRef ')' + ; + +schematicJunctionTemplate + : '(schematicJunctionTemplate' libraryObjectNameDef schematicTemplateHeader hotspot ( + commentGraphics + | figure + | implementationNameDisplay + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +schematicJunctionTemplateRef + : '(schematicJunctionTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicMasterPortImplementation + : '(schematicMasterPortImplementation' implementationNameDef schematicMasterPortTemplateRef ( + portRef + | localPortGroupRef + ) transform ( + implementationNameDisplay + | nameInformation + | portAttributeDisplay + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicMasterPortImplementationRef + : '(schematicMasterPortImplementationRef' implementationNameRef ')' + ; + +schematicMasterPortTemplate + : '(schematicMasterPortTemplate' libraryObjectNameDef schematicTemplateHeader hotspot portDirectionIndicator ( + annotate + | commentGraphics + | figure + | implementationNameDisplay + | portAttributeDisplay + | propertyDisplay + | schematicComplexFigure + | schematicPortStyle + )* ')' + ; + +schematicMasterPortTemplateRef + : '(schematicMasterPortTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicMetric + : '(schematicMetric' setDistance (hotspotGrid | noHotspotGrid) (nominalHotspotGrid)? ')' + ; + +schematicNet + : '(schematicNet' interconnectNameDef signalRef schematicInterconnectHeader schematicNetJoined ( + comment + | schematicInterconnectAttributeDisplay + | schematicNetDetails + | userData + )* ')' + ; + +schematicNetDetails + : '(schematicNetDetails' (schematicNetGraphics | schematicSubNetSet) ')' + ; + +schematicNetGraphics + : '(schematicNetGraphics' (comment | figure | schematicComplexFigure | userData)* ')' + ; + +schematicNetJoined + : '(schematicNetJoined' (portJoined | joinedAsSignal)? ( + ripperHotspotRef + | schematicGlobalPortImplementationRef + | schematicInterconnectTerminatorImplementationRef + | schematicJunctionImplementationRef + | schematicMasterPortImplementationRef + | schematicOffPageConnectorImplementationRef + | schematicOnPageConnectorImplementationRef + | schematicSymbolPortImplementationRef + )* (portJoined | joinedAsSignal)? ( + ripperHotspotRef + | schematicGlobalPortImplementationRef + | schematicInterconnectTerminatorImplementationRef + | schematicJunctionImplementationRef + | schematicMasterPortImplementationRef + | schematicOffPageConnectorImplementationRef + | schematicOnPageConnectorImplementationRef + | schematicSymbolPortImplementationRef + )* ')' + ; + +schematicOffPageConnectorImplementation + : '(schematicOffPageConnectorImplementation' implementationNameDef schematicOffPageConnectorTemplateRef transform ( + associatedInterconnectNameDisplay + | implementationNameDisplay + | nameInformation + | property_ + | propertyDisplay + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicOffPageConnectorImplementationRef + : '(schematicOffPageConnectorImplementationRef' implementationNameRef ')' + ; + +schematicOffPageConnectorTemplate + : '(schematicOffPageConnectorTemplate' libraryObjectNameDef schematicTemplateHeader hotspot ( + annotate + | associatedInterconnectNameDisplay + | commentGraphics + | figure + | implementationNameDisplay + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +schematicOffPageConnectorTemplateRef + : '(schematicOffPageConnectorTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicOnPageConnectorImplementation + : '(schematicOnPageConnectorImplementation' implementationNameDef schematicOnPageConnectorTemplateRef transform ( + associatedInterconnectNameDisplay + | implementationNameDisplay + | nameInformation + | property_ + | propertyDisplay + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicOnPageConnectorImplementationRef + : '(schematicOnPageConnectorImplementationRef' implementationNameRef ')' + ; + +schematicOnPageConnectorTemplate + : '(schematicOnPageConnectorTemplate' libraryObjectNameDef schematicTemplateHeader hotspot ( + annotate + | associatedInterconnectNameDisplay + | commentGraphics + | figure + | implementationNameDisplay + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +schematicOnPageConnectorTemplateRef + : '(schematicOnPageConnectorTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicOtherwiseFrameBorder + : '(schematicOtherwiseFrameBorder' schematicOtherwiseFrameBorderTemplateRef transform ( + propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicOtherwiseFrameBorderTemplate + : '(schematicOtherwiseFrameBorderTemplate' libraryObjectNameDef schematicTemplateHeader usableArea ( + annotate + | commentGraphics + | figure + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +schematicOtherwiseFrameBorderTemplateRef + : '(schematicOtherwiseFrameBorderTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicOtherwiseFrameImplementation + : '(schematicOtherwiseFrameImplementation' implementationNameDef otherwiseFrameRef schematicOtherwiseFrameImplementationHeader + schematicFrameImplementationDetails ')' + ; + +schematicOtherwiseFrameImplementationHeader + : '(schematicOtherwiseFrameImplementationHeader' (schematicOtherwiseFrameBorder)? ')' + ; + +schematicPortAcPower + : '(schematicPortAcPower' ( + schematicPortAcPowerRecommendedFrequency + | schematicPortAcPowerRecommendedVoltageRms + )* ')' + ; + +schematicPortAcPowerRecommendedFrequency + : '(schematicPortAcPowerRecommendedFrequency' frequencyValue ')' + ; + +schematicPortAcPowerRecommendedVoltageRms + : '(schematicPortAcPowerRecommendedVoltageRms' voltageValue ')' + ; + +schematicPortAnalog + : '(schematicPortAnalog' ')' + ; + +schematicPortAttributes + : '(schematicPortAttributes' ( + ieeeStandard + | schematicPortAcPower + | schematicPortAnalog + | schematicPortChassisGround + | schematicPortClock + | schematicPortDcPower + | schematicPortEarthGround + | schematicPortGround + | schematicPortNonLogical + | schematicPortOpenCollector + | schematicPortOpenEmitter + | schematicPortPower + | schematicPortThreeState + )* ')' + ; + +schematicPortChassisGround + : '(schematicPortChassisGround' (schematicPortAnalog)? ')' + ; + +schematicPortClock + : '(schematicPortClock' (ieeeStandard)? ')' + ; + +schematicPortDcPower + : '(schematicPortDcPower' (schematicPortAnalog | schematicPortDcPowerRecommendedVoltage)* ')' + ; + +schematicPortDcPowerRecommendedVoltage + : '(schematicPortDcPowerRecommendedVoltage' voltageValue ')' + ; + +schematicPortEarthGround + : '(schematicPortEarthGround' (schematicPortAnalog)? ')' + ; + +schematicPortGround + : '(schematicPortGround' (schematicPortAnalog)? ')' + ; + +schematicPortNonLogical + : '(schematicPortNonLogical' ')' + ; + +schematicPortOpenCollector + : '(schematicPortOpenCollector' ')' + ; + +schematicPortOpenEmitter + : '(schematicPortOpenEmitter' ')' + ; + +schematicPortPower + : '(schematicPortPower' ')' + ; + +schematicPortStyle + : '(schematicPortStyle' (narrowPort | widePort) ')' + ; + +schematicPortThreeState + : '(schematicPortThreeState' ')' + ; + +schematicRequiredDefaults + : '(schematicRequiredDefaults' schematicMetric fontRef textHeight ')' + ; + +schematicRipperImplementation + : '(schematicRipperImplementation' implementationNameDef schematicRipperTemplateRef transform ( + implementationNameDisplay + | nameInformation + | property_ + | propertyDisplay + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicRipperImplementationRef + : '(schematicRipperImplementationRef' implementationNameRef ')' + ; + +schematicRipperTemplate + : '(schematicRipperTemplate' libraryObjectNameDef schematicTemplateHeader ( + annotate + | commentGraphics + | figure + | implementationNameDisplay + | propertyDisplay + | ripperHotspot + | schematicComplexFigure + )* ')' + ; + +schematicRipperTemplateRef + : '(schematicRipperTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicSubBus + : '(schematicSubBus' interconnectNameDef schematicSubInterconnectHeader schematicBusJoined ( + comment + | schematicBusDetails + | schematicBusSlice + | schematicInterconnectAttributeDisplay + | userData + )* ')' + ; + +schematicSubBusSet + : '(schematicSubBusSet' (schematicSubBus)* ')' + ; + +schematicSubInterconnectHeader + : '(schematicSubInterconnectHeader' ( + criticality + | documentation + | interconnectDelay + | nameInformation + | property_ + )* ')' + ; + +schematicSubNet + : '(schematicSubNet' interconnectNameDef schematicSubInterconnectHeader schematicNetJoined ( + comment + | schematicInterconnectAttributeDisplay + | schematicNetDetails + | userData + )* ')' + ; + +schematicSubNetSet + : '(schematicSubNetSet' (schematicSubNet)* ')' + ; + +schematicSymbol + : '(schematicSymbol' viewNameDef schematicSymbolHeader ( + annotate + | cellNameDisplay + | cellPropertyDisplay + | clusterPropertyDisplay + | comment + | commentGraphics + | designatorDisplay + | figure + | implementationNameDisplay + | instanceNameDisplay + | instanceNameGeneratorDisplay + | instanceWidthDisplay + | parameterDisplay + | propertyDisplay + | schematicComplexFigure + | schematicSymbolPortImplementation + | userData + | viewNameDisplay + )* ')' + ; + +schematicSymbolBorder + : '(schematicSymbolBorder' schematicSymbolBorderTemplateRef transform ( + propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicSymbolBorderTemplate + : '(schematicSymbolBorderTemplate' libraryObjectNameDef schematicTemplateHeader usableArea ( + annotate + | commentGraphics + | figure + | propertyDisplay + | schematicComplexFigure + )* ')' + ; + +schematicSymbolBorderTemplateRef + : '(schematicSymbolBorderTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicSymbolHeader + : '(schematicSymbolHeader' schematicUnits ( + backgroundColor + | derivedFrom + | documentation + | nameInformation + | originalBoundingBox + | pageSize + | previousVersion + | property_ + | schematicSymbolBorder + | status + )* ')' + ; + +schematicSymbolPortImplementation + : '(schematicSymbolPortImplementation' symbolPortImplementationNameDef portRef schematicSymbolPortTemplateRef transform ( + portAttributeDisplay + | propertyDisplayOverride + | propertyOverride + )* ')' + ; + +schematicSymbolPortImplementationRef + : '(schematicSymbolPortImplementationRef' symbolPortImplementationNameRef schematicInstanceImplementationRef ')' + ; + +schematicSymbolPortTemplate + : '(schematicSymbolPortTemplate' libraryObjectNameDef schematicTemplateHeader hotspot portDirectionIndicator ( + annotate + | commentGraphics + | figure + | implementationNameDisplay + | portAttributeDisplay + | propertyDisplay + | schematicComplexFigure + | schematicPortAttributes + | schematicPortStyle + )* ')' + ; + +schematicSymbolPortTemplateRef + : '(schematicSymbolPortTemplateRef' libraryObjectNameRef (libraryRef)? ')' + ; + +schematicSymbolRef + : '(schematicSymbolRef' viewNameRef ')' + ; + +schematicTemplateHeader + : '(schematicTemplateHeader' schematicUnits ( + backgroundColor + | documentation + | nameInformation + | originalBoundingBox + | property_ + | status + )* ')' + ; + +schematicUnits + : '(schematicUnits' ( + schematicMetric + | setAngle + | setCapacitance + | setFrequency + | setTime + | setVoltage + )* ')' + ; + +schematicView + : '(schematicView' viewNameDef schematicViewHeader logicalConnectivity schematicImplementation ( + comment + | userData + )* ')' + ; + +schematicViewHeader + : '(schematicViewHeader' schematicUnits ( + derivedFrom + | documentation + | nameInformation + | previousVersion + | property_ + | status + )* ')' + ; + +schematicWireAffinity + : '(schematicWireAffinity' (narrowWire | wideWire | unrestricted) ')' + ; + +schematicWireStyle + : '(schematicWireStyle' (narrowWire | wideWire) ')' + ; + +second + : '(second' unitExponent ')' + ; + +secondIntegerExpression + : integerExpression + ; + +secondNumber + : integerToken + ; + +secondStringExpression + : stringExpression + ; + +section + : '(section' sectionNameDef sectionTitle (diagram | section | stringValue)* ')' + ; + +sectionNameDef + : nameDef + ; + +sectionTitle + : '(sectionTitle' stringToken ')' + ; + +sequence + : '(sequence' fromInteger toInteger (step)? ')' + ; + +setAngle + : '(setAngle' unitRef ')' + ; + +setCapacitance + : '(setCapacitance' unitRef ')' + ; + +setCurrent + : '(setCurrent' unitRef ')' + ; + +setDistance + : '(setDistance' unitRef ')' + ; + +setFrequency + : '(setFrequency' unitRef ')' + ; + +setTime + : '(setTime' unitRef ')' + ; + +setVoltage + : '(setVoltage' unitRef ')' + ; + +shape + : '(shape' curve ')' + ; + +siemens + : '(siemens' unitExponent ')' + ; + +signal + : '(signal' signalNameDef signalJoined ( + connectivityTagGenerator + | nameInformation + | property_ + | signalWidth + )* ')' + ; + +signalAnnotate + : '(signalAnnotate' (extendSignalDef | extendSignalMemberDef) ( + comment + | property_ + | propertyOverride + )* ')' + ; + +signalGroup + : '(signalGroup' signalGroupNameDef signalList (property_ | nameInformation)* ')' + ; + +signalGroupAnnotate + : '(signalGroupAnnotate' extendSignalGroupDef (comment | property_ | propertyOverride)* ')' + ; + +signalGroupNameCaseSensitive + : '(signalGroupNameCaseSensitive' booleanToken ')' + ; + +signalGroupNameDef + : nameDef + ; + +signalGroupNameRef + : nameRef + ; + +signalGroupRef + : '(signalGroupRef' signalGroupNameRef ')' + ; + +signalIndexValue + : '(signalIndexValue' ')' + ; + +signalJoined + : '(signalJoined' (globalPortRef | portInstanceRef | portMemberRef | portRef)* ')' + ; + +signalList + : '(signalList' (signalGroupRef | signalRef)* ')' + ; + +signalMemberRef + : '(signalMemberRef' signalNameRef indexValue ')' + ; + +signalNameCaseSensitive + : '(signalNameCaseSensitive' booleanToken ')' + ; + +signalNameDef + : nameDef + ; + +signalNameRef + : nameRef + ; + +signalRef + : '(signalRef' signalNameRef ')' + ; + +signalWidth + : '(signalWidth' integerExpression ')' + ; + +simpleName + : stringToken + ; + +startPoint + : pointValue + ; + +status + : '(status' (comment | copyright | userData | written)* ')' + ; + +step + : '(step' integerValue ')' + ; + +string + : '(string' stringExpression ')' + ; + +stringConcatenate + : '(stringConcatenate' (stringExpression)* ')' + ; + +stringConstant + : '(stringConstant' constantNameDef stringToken ')' + ; + +stringConstantRef + : '(stringConstantRef' constantNameRef ')' + ; + +stringEqual + : '(stringEqual' firstStringExpression secondStringExpression ')' + ; + +stringExpression + : ( + stringParameterRef + | stringToken + | stringConstantRef + | stringConcatenate + | substring + | decimalToString + | stringPrefix + | stringSuffix + ) + ; + +stringLength + : '(stringLength' stringExpression ')' + ; + +stringParameter + : '(stringParameter' parameterNameDef (nameInformation | string)* ')' + ; + +stringParameterAssign + : '(stringParameterAssign' parameterNameRef stringExpression ')' + ; + +stringParameterRef + : '(stringParameterRef' parameterNameRef ')' + ; + +stringPrefix + : '(stringPrefix' stringExpression substringLength ')' + ; + +stringSuffix + : '(stringSuffix' stringExpression substringOffset ')' + ; + +stringValue + : stringToken + ; + +strong + : '(strong' logicNameRef ')' + ; + +subIssue + : integerToken + ; + +substring + : '(substring' stringExpression substringLength substringOffset ')' + ; + +substringLength + : integerExpression + ; + +substringOffset + : integerExpression + ; + +subtrahend + : integerExpression + ; + +symbolicLayoutUnits + : '(symbolicLayoutUnits' (setAngle | setCapacitance | setDistance | setTime)* ')' + ; + +symbolicLayoutView + : '(symbolicLayoutView' viewNameDef (comment | userData)* (nameInformation)? ( + comment + | userData + )* ')' + ; + +symbolPortImplementationNameDef + : nameDef + ; + +symbolPortImplementationNameRef + : nameRef + ; + +technology + : '(technology' physicalScaling (comment | figureGroup | logicDefinitions | userData)* ')' + ; + +textHeight + : '(textHeight' lengthValue ')' + ; + +throughPoint + : numberPoint + ; + +time + : '(time' hourNumber minuteNumber secondNumber ')' + ; + +timeDelay + : timeValue + ; + +timeInterval + : '(timeInterval' (event | offsetEvent) (event | offsetEvent | duration) ')' + ; + +timeStamp + : '(timeStamp' date time ')' + ; + +timeValue + : miNoMaxValue + ; + +timing + : '(timing' timingNameDef derivation ( + comment + | forbiddenEvent + | pathDelay + | property_ + | userData + )* ')' + ; + +timingDisplay + : '(timingDisplay' timingNameRef (display)* ')' + ; + +timingNameDef + : nameDef + ; + +timingNameRef + : nameRef + ; + +toInteger + : integerToken + ; + +topJustify + : '(topJustify' ')' + ; + +totalPages + : '(totalPages' integerToken ')' + ; + +totalPagesDisplay + : '(totalPagesDisplay' (addDisplay | replaceDisplay | removeDisplay) ')' + ; + +transform + : '(transform' (origin | rotation | scaleX | scaleY)* ')' + ; + +transition + : '(transition' previousLogicValue presentLogicValue ')' + ; + +etrue + : '(true' ')' + ; + +truncate + : '(truncate' ')' + ; + +typedValue + : (eboolean | integer | miNoMax | number | point | string) + ; + +typeface + : '(typeface' fontFamily (typefaceSuffix)? ')' + ; + +typefaceSuffix + : '(typefaceSuffix' stringToken ')' + ; + +unconfigured + : '(unconfigured' ')' + ; + +unconstrained + : '(unconstrained' ')' + ; + +undefined + : '(undefined' ')' + ; + +unit + : '(unit' unitNameDef numberOfNewUnits numberOfBasicUnits ( + ampere + | candela + | celsius + | coulomb + | degree + | fahrenheit + | farad + | henry + | hertz + | joule + | kelvin + | kilogram + | meter + | mole + | ohm + | radian + | second + | siemens + | volt + | watt + | weber + )* ')' + ; + +unitDefinitions + : '(unitDefinitions' (unit)* ')' + ; + +unitExponent + : scaledInteger + ; + +unitNameDef + : nameDef + ; + +unitNameRef + : nameRef + ; + +unitRef + : '(unitRef' unitNameRef ')' + ; + +unrestricted + : '(unrestricted' ')' + ; + +unspecified + : '(unspecified' ')' + ; + +unspecifiedDirectionPort + : '(unspecifiedDirectionPort' ')' + ; + +untyped + : '(untyped' ')' + ; + +unused + : '(unused' ')' + ; + +usableArea + : '(usableArea' (rectangle)* ')' + ; + +userData + : '(userData' userDataTag (IDENTIFIER | integerToken | stringToken | userData)* ')' + ; + +userDataTag + : IDENTIFIER + ; + +version + : '(version' stringValue ')' + ; + +verticalJustification + : '(verticalJustification' ( + bottomJustify + | baselineJustify + | middleJustify + | caplineJustify + | topJustify + ) ')' + ; + +viewGroup + : '(viewGroup' viewGroupNameDef viewGroupHeader (comment | userData | viewGroupRef | viewRef)* ')' + ; + +viewGroupHeader + : '(viewGroupHeader' (documentation | nameInformation | property_ | reason)* ')' + ; + +viewGroupNameCaseSensitive + : '(viewGroupNameCaseSensitive' booleanToken ')' + ; + +viewGroupNameDef + : nameDef + ; + +viewGroupNameRef + : nameRef + ; + +viewGroupRef + : '(viewGroupRef' viewGroupNameRef ')' + ; + +viewNameCaseSensitive + : '(viewNameCaseSensitive' booleanToken ')' + ; + +viewNameDef + : nameDef + ; + +viewNameDisplay + : '(viewNameDisplay' (display | displayNameOverride)* ')' + ; + +viewNameRef + : nameRef + ; + +viewPropertyDisplay + : '(viewPropertyDisplay' propertyNameRef (display | propertyNameDisplay)* ')' + ; + +viewPropertyOverride + : '(viewPropertyOverride' propertyNameRef (typedValue | untyped) ( + comment + | fixed + | propertyOverride + )* ')' + ; + +viewRef + : '(viewRef' viewNameRef (clusterRef)? ')' + ; + +visible + : '(visible' booleanValue ')' + ; + +volt + : '(volt' unitExponent ')' + ; + +voltageMap + : '(voltageMap' voltageValue ')' + ; + +voltageValue + : miNoMaxValue + ; + +watt + : '(watt' unitExponent ')' + ; + +weak_ + : '(weak' logicNameRef ')' + ; + +weakJoined + : '(weakJoined' (interfaceJoined | portRef)* ')' + ; + +weber + : '(weber' unitExponent ')' + ; + +widePort + : '(widePort' ')' + ; + +wideWire + : '(wideWire' ')' + ; + +written + : '(written' timeStamp (author | comment | dataOrigin | program | userData)* ')' + ; + +xCoordinate + : integerValue + ; + +xNumberValue + : numberValue + ; + +xor_ + : '(xor' (booleanExpression)* ')' + ; + +yCoordinate + : integerValue + ; + +year + : '(year' (yearNumber)* ')' + ; + +yearNumber + : integerToken + ; + +yNumberValue + : numberValue + ; + +integerToken + : DECIMAL_LITERAL + ; + +stringToken + : STRING_LITERAL + ; + +IDENTIFIER + : (SPECIAL)* (DIG)* (LETTER | '&' | UNDERLINE) (LETTER | DIG | UNDERLINE | SPECIAL)* + ; + +STRING_LITERAL + : '"' (~'"')* '"' + ; + +DECIMAL_LITERAL + : INTEGER ('.' INTEGER*)? + ; + +fragment INTEGER + : ('-' | '+')? DIG (DIG)* + ; + +fragment LETTER + : UPCASE + | LOWCASE + ; + +fragment UPCASE + : [A-Z] + ; + +fragment LOWCASE + : [a-z] + ; + +fragment DIG + : [0-9] + ; + +fragment UNDERLINE + : '_' + ; + +fragment SPECIAL + : '!' + | '#' + | '$' + | '&' + | '*' + | '+' + | ',' + | '-' + | '.' + | '/' + | ':' + | ';' + | '<' + | '=' + | '>' + | '?' + | '@' + | '[' + | ']' + | '^' + | '`' + | '{' + | '|' + | '}' + | '~' + | '\\' + ; + +WS + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/edn/edn.g4 b/edn/edn.g4 index 74d7f08dea..e13a45c6f1 100644 --- a/edn/edn.g4 +++ b/edn/edn.g4 @@ -23,101 +23,199 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar edn; -program: value* EOF; -value: - NilLiteral - | BooleanLiteral - | StringLiteral - | IntegerLiteral - | FloatingPointLiteral - | CharacterLiteral - | keyword - | Symbol - | tag - | list_ - | vector - | map_ - | set_; + +program + : value* EOF + ; + +value + : NilLiteral + | BooleanLiteral + | StringLiteral + | IntegerLiteral + | FloatingPointLiteral + | CharacterLiteral + | keyword + | Symbol + | tag + | list_ + | vector + | map_ + | set_ + ; //maybe add more tags here? did not get a lot of info from the spec -tag: Hash Symbol; -keyword: - Colon ( - Symbol - | IntegerLiteral - | FloatingPointLiteral - | NilLiteral - | BooleanLiteral - // maybe a character literal here? - ); -list_: LeftParenthesis value* RightParenthesis; -vector: LeftBracket value* RightBracket; -map_: LeftBrace (value value)* RightBrace; -set_: HashedLeftBrace value* RightBrace; - -NilLiteral: 'nil'; - -BooleanLiteral: 'true' | 'false'; - -StringLiteral: - '"' ( - ~["\\] - | ( - '\\' ( - [ctrn\\"] - | [bf] // - | UnicodeCharacter - ) - ) - )* '"'; - -IntegerLiteral: Int 'N'?; - -FloatingPointLiteral: Int ('M' | FractionalPart? Exponent?); - -CharacterLiteral: - '\\' ( - 'newline' - | 'return' - | 'space' - | 'tab' - | 'backspace' - | 'formfeed' - | UnicodeCharacter - | ~[ \r\n\t] - ); - -LeftParenthesis: '('; -RightParenthesis: ')'; -LeftBracket: '['; -RightBracket: ']'; -LeftBrace: '{'; -RightBrace: '}'; -HashedLeftBrace: '#{'; -Hash: '#'; -Colon: ':'; - -FractionalPart: '.' Digit+; -fragment Exponent: E Digit+; -fragment E: [eE] [+-]?; -Int: [+-]? ('0' | [1-9] Digit*); -fragment Digit: [0-9]; -fragment HexDigit: [a-fA-F0-9]; -fragment UnicodeCharacter: - 'u' HexDigit HexDigit HexDigit HexDigit; - -Symbol: '/' | Name ('/' Name)?; - -Name: (( [-+.] (Alpha | Extra | Special)) | (Alpha | Extra)) ( - Alpha - | Numeric - | Extra - | Special - )*; -fragment Alpha: [a-zA-Z\p{L}]; -fragment Numeric: [0-9]; -fragment Extra: [.*+!\-_?$%&=<>]; -fragment Special: [#:]; -Comment: ';' .*? '\r'? '\n' -> skip; -Whitespace: [ ,\r\n\t\u000C] -> skip; \ No newline at end of file +tag + : Hash Symbol + ; + +keyword + : Colon ( + Symbol + | IntegerLiteral + | FloatingPointLiteral + | NilLiteral + | BooleanLiteral + // maybe a character literal here? + ) + ; + +list_ + : LeftParenthesis value* RightParenthesis + ; + +vector + : LeftBracket value* RightBracket + ; + +map_ + : LeftBrace (value value)* RightBrace + ; + +set_ + : HashedLeftBrace value* RightBrace + ; + +NilLiteral + : 'nil' + ; + +BooleanLiteral + : 'true' + | 'false' + ; + +StringLiteral + : '"' ( + ~["\\] + | ( + '\\' ( + [ctrn\\"] + | [bf] // + | UnicodeCharacter + ) + ) + )* '"' + ; + +IntegerLiteral + : Int 'N'? + ; + +FloatingPointLiteral + : Int ('M' | FractionalPart? Exponent?) + ; + +CharacterLiteral + : '\\' ( + 'newline' + | 'return' + | 'space' + | 'tab' + | 'backspace' + | 'formfeed' + | UnicodeCharacter + | ~[ \r\n\t] + ) + ; + +LeftParenthesis + : '(' + ; + +RightParenthesis + : ')' + ; + +LeftBracket + : '[' + ; + +RightBracket + : ']' + ; + +LeftBrace + : '{' + ; + +RightBrace + : '}' + ; + +HashedLeftBrace + : '#{' + ; + +Hash + : '#' + ; + +Colon + : ':' + ; + +FractionalPart + : '.' Digit+ + ; + +fragment Exponent + : E Digit+ + ; + +fragment E + : [eE] [+-]? + ; + +Int + : [+-]? ('0' | [1-9] Digit*) + ; + +fragment Digit + : [0-9] + ; + +fragment HexDigit + : [a-fA-F0-9] + ; + +fragment UnicodeCharacter + : 'u' HexDigit HexDigit HexDigit HexDigit + ; + +Symbol + : '/' + | Name ('/' Name)? + ; + +Name + : (( [-+.] (Alpha | Extra | Special)) | (Alpha | Extra)) (Alpha | Numeric | Extra | Special)* + ; + +fragment Alpha + : [a-zA-Z\p{L}] + ; + +fragment Numeric + : [0-9] + ; + +fragment Extra + : [.*+!\-_?$%&=<>] + ; + +fragment Special + : [#:] + ; + +Comment + : ';' .*? '\r'? '\n' -> skip + ; + +Whitespace + : [ ,\r\n\t\u000C] -> skip + ; \ No newline at end of file diff --git a/elixir/ElixirLexer.g4 b/elixir/ElixirLexer.g4 index 78d25c1c96..dad50b5c2a 100644 --- a/elixir/ElixirLexer.g4 +++ b/elixir/ElixirLexer.g4 @@ -1,155 +1,186 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ElixirLexer; -COMMENT : '#' ~[\r\n]* -> skip; +COMMENT: '#' ~[\r\n]* -> skip; -NL : '\r'? '\n' | '\r'; +NL: '\r'? '\n' | '\r'; -SPACES : [ \t]+ -> channel(HIDDEN); +SPACES: [ \t]+ -> channel(HIDDEN); -ATOM - : ':' ( [\p{L}_] [\p{L}_0-9@]* [!?]? - | OPERATOR - | SINGLE_LINE_STRING - | SINGLE_LINE_CHARLIST - ) - ; +ATOM: ':' ( [\p{L}_] [\p{L}_0-9@]* [!?]? | OPERATOR | SINGLE_LINE_STRING | SINGLE_LINE_CHARLIST); // Keywords -TRUE : 'true'; +TRUE : 'true'; FALSE : 'false'; -NIL : 'nil'; -WHEN : 'when'; -AND : 'and'; -OR : 'or'; -NOT : 'not'; -IN : 'in'; -FN : 'fn'; -DO : 'do'; -END : 'end'; +NIL : 'nil'; +WHEN : 'when'; +AND : 'and'; +OR : 'or'; +NOT : 'not'; +IN : 'in'; +FN : 'fn'; +DO : 'do'; +END : 'end'; CATCH : 'catch'; RECUE : 'rescue'; AFTER : 'after'; -ELSE : 'else'; +ELSE : 'else'; // Non-keywords, which also need to be included in the `variable` parser rule -CASE : 'case'; -COND : 'cond'; -IF : 'if'; -UNLESS : 'unless'; +CASE : 'case'; +COND : 'cond'; +IF : 'if'; +UNLESS : 'unless'; DEFMODULE : 'defmodule'; -DEFMACRO : 'defmacro'; -DEF : 'def'; -DEFP : 'defp'; -FOR : 'for'; -WITH : 'with'; -TRY : 'try'; - -CODEPOINT : '?' ( '\\' . | ~[\\] ) ; - -SIGIL - : '~' [a-zA-Z] ( '/' ( ESCAPE | '\\/' | ~[/\\] )* '/' - | '|' ( ESCAPE | '\\|' | ~[|\\] )* '|' - | SINGLE_LINE_STRING - | MULTI_LINE_STRING - | SINGLE_LINE_CHARLIST - | MULTI_LINE_CHARLIST - | '\'' ( ESCAPE | '\\\'' | ~['\\] )* '\'' - | '(' ( ESCAPE | '\\)' | ~[)\\] )* ')' - | '[' ( ESCAPE | '\\]' | ~[\]\\] )* ']' - | '{' ( ESCAPE | '\\}' | ~[}\\] )* '}' - | '<' ( ESCAPE | '\\>' | ~[>\\] )* '>' - ) - [a-zA-Z]* - ; - -HEXADECIMAL : '0x' HEX+ ( '_' HEX+ )*; -OCTAL : '0o' [0-7]+ ( '_' [0-7]+ )*; -BINARY : '0b' [01]+ ( '_' [01]+ )*; -INTEGER : D+ ( '_' D+ )*; -FLOAT : D+ '.' D+ EXPONENT?; - -SINGLE_LINE_STRING : '"' ( ESCAPE | '\\"' | ~[\\"] )* '"'; -MULTI_LINE_STRING : '"""' .*? '"""'; -SINGLE_LINE_CHARLIST : '\'' ( ESCAPE | '\\\'' | ~[\\'] )* '\''; -MULTI_LINE_CHARLIST : '\'\'\'' .*? '\'\'\''; - -ALIAS : [A-Z] [a-zA-Z_0-9]*; - -VARIABLE : [\p{Ll}_] [\p{L}_0-9]* [!?]?; - -AT : '@'; -DOT : '.'; -EXCL : '!'; -CARET : '^'; -TILDE3 : '~~~'; -MUL : '*'; -DIV : '/'; -ADD : '+'; -SUB : '-'; -ADD2 : '++'; -SUB2 : '--'; -ADD3 : '+++'; -SUB3 : '---'; -DOT2 : '..'; -LTGT : '<>'; -PIPE_GT : '|>'; -LT3 : '<<<'; -GT3 : '>>>'; -GT2_TILDE: '<<~'; -TILDE_GT2: '~>>'; -LT_TILDE: '<~'; -TILDE_GT: '~>'; +DEFMACRO : 'defmacro'; +DEF : 'def'; +DEFP : 'defp'; +FOR : 'for'; +WITH : 'with'; +TRY : 'try'; + +CODEPOINT: '?' ( '\\' . | ~[\\]); + +SIGIL: + '~' [a-zA-Z] ( + '/' ( ESCAPE | '\\/' | ~[/\\])* '/' + | '|' ( ESCAPE | '\\|' | ~[|\\])* '|' + | SINGLE_LINE_STRING + | MULTI_LINE_STRING + | SINGLE_LINE_CHARLIST + | MULTI_LINE_CHARLIST + | '\'' ( ESCAPE | '\\\'' | ~['\\])* '\'' + | '(' ( ESCAPE | '\\)' | ~[)\\])* ')' + | '[' ( ESCAPE | '\\]' | ~[\]\\])* ']' + | '{' ( ESCAPE | '\\}' | ~[}\\])* '}' + | '<' ( ESCAPE | '\\>' | ~[>\\])* '>' + ) [a-zA-Z]* +; + +HEXADECIMAL : '0x' HEX+ ( '_' HEX+)*; +OCTAL : '0o' [0-7]+ ( '_' [0-7]+)*; +BINARY : '0b' [01]+ ( '_' [01]+)*; +INTEGER : D+ ( '_' D+)*; +FLOAT : D+ '.' D+ EXPONENT?; + +SINGLE_LINE_STRING : '"' ( ESCAPE | '\\"' | ~[\\"])* '"'; +MULTI_LINE_STRING : '"""' .*? '"""'; +SINGLE_LINE_CHARLIST : '\'' ( ESCAPE | '\\\'' | ~[\\'])* '\''; +MULTI_LINE_CHARLIST : '\'\'\'' .*? '\'\'\''; + +ALIAS: [A-Z] [a-zA-Z_0-9]*; + +VARIABLE: [\p{Ll}_] [\p{L}_0-9]* [!?]?; + +AT : '@'; +DOT : '.'; +EXCL : '!'; +CARET : '^'; +TILDE3 : '~~~'; +MUL : '*'; +DIV : '/'; +ADD : '+'; +SUB : '-'; +ADD2 : '++'; +SUB2 : '--'; +ADD3 : '+++'; +SUB3 : '---'; +DOT2 : '..'; +LTGT : '<>'; +PIPE_GT : '|>'; +LT3 : '<<<'; +GT3 : '>>>'; +GT2_TILDE : '<<~'; +TILDE_GT2 : '~>>'; +LT_TILDE : '<~'; +TILDE_GT : '~>'; LT_TILDE_GT : '<~>'; -LT_PIPE_GT : '<|>'; -LT : '<'; -GT : '>'; -LT_EQ : '<='; -GT_EQ : '>='; -EQ2 : '=='; -EXCL_EQ : '!='; -EQ_TILDE : '=~'; -EQ3 : '==='; -EXCL_EQ2 : '!=='; -AMP2 : '&&'; -AMP3 : '&&&'; -PIPE2 : '||'; -PIPE3 : '|||'; -EQ : '='; -AMP : '&'; -ARROW : '=>'; -PIPE : '|'; -COL2 : '::'; -LARROW : '<-'; -RARROW : '->'; -BSLASH2 : '\\\\'; - -OPAR : '('; -CPAR : ')'; +LT_PIPE_GT : '<|>'; +LT : '<'; +GT : '>'; +LT_EQ : '<='; +GT_EQ : '>='; +EQ2 : '=='; +EXCL_EQ : '!='; +EQ_TILDE : '=~'; +EQ3 : '==='; +EXCL_EQ2 : '!=='; +AMP2 : '&&'; +AMP3 : '&&&'; +PIPE2 : '||'; +PIPE3 : '|||'; +EQ : '='; +AMP : '&'; +ARROW : '=>'; +PIPE : '|'; +COL2 : '::'; +LARROW : '<-'; +RARROW : '->'; +BSLASH2 : '\\\\'; + +OPAR : '('; +CPAR : ')'; OBRACK : '['; CBRACK : ']'; OBRACE : '{'; CBRACE : '}'; -LT1 : '<<'; -GT2 : '>>'; -OMAP : '%' ( [a-zA-Z_.] [a-zA-Z_.0-9]* )? '{'; -COMMA : ','; -COL : ':'; -SCOL : ';'; - -fragment OPERATOR - : AT | DOT | EXCL | CARET | SUB3 | MUL | DIV | ADD | SUB | ADD2 | SUB2 | ADD3 | DOT2 | LTGT | PIPE_GT - | LT3 | GT3 | GT2_TILDE | TILDE_GT2 | LT_TILDE | TILDE_GT | LT_TILDE_GT | LT_PIPE_GT | LT | GT | LT_EQ - | GT_EQ | EQ2 | EXCL_EQ | EQ_TILDE | EQ3 | EXCL_EQ2 | AMP2 | AMP3 | PIPE2 | PIPE3 | EQ | AMP | PIPE - | COL2 | LARROW | RARROW | BSLASH2 - ; - -fragment D : [0-9]; -fragment HEX : [0-9a-fA-F]; +LT1 : '<<'; +GT2 : '>>'; +OMAP : '%' ( [a-zA-Z_.] [a-zA-Z_.0-9]*)? '{'; +COMMA : ','; +COL : ':'; +SCOL : ';'; + +fragment OPERATOR: + AT + | DOT + | EXCL + | CARET + | SUB3 + | MUL + | DIV + | ADD + | SUB + | ADD2 + | SUB2 + | ADD3 + | DOT2 + | LTGT + | PIPE_GT + | LT3 + | GT3 + | GT2_TILDE + | TILDE_GT2 + | LT_TILDE + | TILDE_GT + | LT_TILDE_GT + | LT_PIPE_GT + | LT + | GT + | LT_EQ + | GT_EQ + | EQ2 + | EXCL_EQ + | EQ_TILDE + | EQ3 + | EXCL_EQ2 + | AMP2 + | AMP3 + | PIPE2 + | PIPE3 + | EQ + | AMP + | PIPE + | COL2 + | LARROW + | RARROW + | BSLASH2 +; + +fragment D : [0-9]; +fragment HEX : [0-9a-fA-F]; fragment EXPONENT : [eE] [+-]? D+; -fragment ESCAPE - : '\\' ( [\\abdefnrstv0] - | 'x' HEX HEX - | 'u' HEX HEX HEX HEX - | 'u{' HEX+ '}' - ) - ; \ No newline at end of file +fragment ESCAPE: '\\' ( [\\abdefnrstv0] | 'x' HEX HEX | 'u' HEX HEX HEX HEX | 'u{' HEX+ '}'); \ No newline at end of file diff --git a/elixir/ElixirParser.g4 b/elixir/ElixirParser.g4 index db37cc21a6..4e1f369bc6 100644 --- a/elixir/ElixirParser.g4 +++ b/elixir/ElixirParser.g4 @@ -1,237 +1,314 @@ +// $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 ElixirParser; options { - tokenVocab=ElixirLexer; + tokenVocab = ElixirLexer; } parse - : block EOF - ; + : block EOF + ; block - : eoe? expression ( eoe expression )* eoe? - ; + : eoe? expression (eoe expression)* eoe? + ; eoe - : ( ';' | NL )+ - ; + : (';' | NL)+ + ; expression - : expression expression_tail #dotExpr - | expression '.'? '(' ( expressions_ ( ',' NL* options_ )? )? ')' #functionCallExpr - | expression '.'? '(' NL* options_ NL*')' #functionCallExpr - | module_def #moduleDefExpr - | function_def #functionDefExpr - | macro_def #macroDefExpr - | for #forExpr - | with #withExpr - | try #tryExpr - | expression expressions_ ( ',' NL* options_ )? #functionCallExpr - | expression options_? expressions_ #functionCallExpr - | expression options_ #functionCallExpr - | anonymous_function #anonymousFunctionExpr - | '(' expression ')' #nestedExpr - | '@' expression options_? #atExpr - | unaryOp expression #unaryExpr - | expression mulOp expression #mulExpr - | expression addOp expression #addExpr - | expression listOp expression #listExpr - | expression inOp expression #inExpr - | expression '|>' expression #pipeExpr - | expression otherOp expression #otherExpr - | expression bitOp expression #bitExpr - | expression relOp expression #relExpr - | expression eqOp expression #eqExpr - | expression andOp expression #andExpr - | expression orOp expression #orExpr - | expression '=' expression #patternExpr - | '&' expression #ampExpr - | expression '|' expression #prependExpr - | expression '::' expression #typeExpr - | expression WHEN expression #whenExpr - | expression '\\\\' expression #defaultValueExpr - | expression '->' NL* expression #rarrowExpr - | expression '<-' expression #larrowExpr - | list #listExpr - | tuple #tupleExpr - | map #mapExpr - | bool_ #boolExpr - | bitstring #bitstringExpr - | case #caseExpr - | cond #condExpr - | if #ifExpr - | unless #unlessExpr - | operator #operatorExpr - | do_block #doBlockExpr - | variables #variablesExpr - | ATOM #atomExpr - | INTEGER #integerExpr - | HEXADECIMAL #hexadecimalExpr - | OCTAL #octalExpr - | BINARY #binaryExpr - | FLOAT #floatExpr - | SIGIL #sigilExpr - | SINGLE_LINE_STRING #singleLineStringExpr - | MULTI_LINE_STRING #multiLineStringExpr - | SINGLE_LINE_CHARLIST #singleLineCharlistExpr - | MULTI_LINE_CHARLIST #multiLineCharlistExpr - | ALIAS #aliasExpr - | CODEPOINT #codepointExpr - | NIL #nilExpr - ; - -unaryOp : '+' | '-' | '!' | '^' | 'not' | '~~~'; -mulOp : '*' | '/'; -addOp : '+' | '-'; -listOp : '++' | '--' | '+++' | '---' | '..' | '<>'; -inOp : 'in' | 'not' 'in'; -relOp : '<' | '>' | '<=' | '>='; -eqOp : '==' | '!=' | '=~' | '===' | '!=='; -andOp : '&&' | '&&&' | 'and'; -orOp : '||' | '|||' | 'or'; -bitOp : '<<<' | '>>>'; -otherOp : '<<~' | '~>>' | '<~' | '~>' | '<~>' | '<|>'; + : expression expression_tail # dotExpr + | expression '.'? '(' (expressions_ ( ',' NL* options_)?)? ')' # functionCallExpr + | expression '.'? '(' NL* options_ NL* ')' # functionCallExpr + | module_def # moduleDefExpr + | function_def # functionDefExpr + | macro_def # macroDefExpr + | for # forExpr + | with # withExpr + | try # tryExpr + | expression expressions_ ( ',' NL* options_)? # functionCallExpr + | expression options_? expressions_ # functionCallExpr + | expression options_ # functionCallExpr + | anonymous_function # anonymousFunctionExpr + | '(' expression ')' # nestedExpr + | '@' expression options_? # atExpr + | unaryOp expression # unaryExpr + | expression mulOp expression # mulExpr + | expression addOp expression # addExpr + | expression listOp expression # listExpr + | expression inOp expression # inExpr + | expression '|>' expression # pipeExpr + | expression otherOp expression # otherExpr + | expression bitOp expression # bitExpr + | expression relOp expression # relExpr + | expression eqOp expression # eqExpr + | expression andOp expression # andExpr + | expression orOp expression # orExpr + | expression '=' expression # patternExpr + | '&' expression # ampExpr + | expression '|' expression # prependExpr + | expression '::' expression # typeExpr + | expression WHEN expression # whenExpr + | expression '\\\\' expression # defaultValueExpr + | expression '->' NL* expression # rarrowExpr + | expression '<-' expression # larrowExpr + | list # listExpr + | tuple # tupleExpr + | map # mapExpr + | bool_ # boolExpr + | bitstring # bitstringExpr + | case # caseExpr + | cond # condExpr + | if # ifExpr + | unless # unlessExpr + | operator # operatorExpr + | do_block # doBlockExpr + | variables # variablesExpr + | ATOM # atomExpr + | INTEGER # integerExpr + | HEXADECIMAL # hexadecimalExpr + | OCTAL # octalExpr + | BINARY # binaryExpr + | FLOAT # floatExpr + | SIGIL # sigilExpr + | SINGLE_LINE_STRING # singleLineStringExpr + | MULTI_LINE_STRING # multiLineStringExpr + | SINGLE_LINE_CHARLIST # singleLineCharlistExpr + | MULTI_LINE_CHARLIST # multiLineCharlistExpr + | ALIAS # aliasExpr + | CODEPOINT # codepointExpr + | NIL # nilExpr + ; + +unaryOp + : '+' + | '-' + | '!' + | '^' + | 'not' + | '~~~' + ; + +mulOp + : '*' + | '/' + ; + +addOp + : '+' + | '-' + ; + +listOp + : '++' + | '--' + | '+++' + | '---' + | '..' + | '<>' + ; + +inOp + : 'in' + | 'not' 'in' + ; + +relOp + : '<' + | '>' + | '<=' + | '>=' + ; + +eqOp + : '==' + | '!=' + | '=~' + | '===' + | '!==' + ; + +andOp + : '&&' + | '&&&' + | 'and' + ; + +orOp + : '||' + | '|||' + | 'or' + ; + +bitOp + : '<<<' + | '>>>' + ; + +otherOp + : '<<~' + | '~>>' + | '<~' + | '~>' + | '<~>' + | '<|>' + ; // TODO add literals -operator : unaryOp | mulOp | addOp | listOp | inOp | relOp | eqOp | andOp | orOp | bitOp | otherOp; +operator + : unaryOp + | mulOp + | addOp + | listOp + | inOp + | relOp + | eqOp + | andOp + | orOp + | bitOp + | otherOp + ; expression_tail - : '[' expression ']' - | '.' expression - ; + : '[' expression ']' + | '.' expression + ; do_block - : DO NL* block? NL* ( AFTER NL* block NL* )? END - ; + : DO NL* block? NL* (AFTER NL* block NL*)? END + ; bool_ - : TRUE - | FALSE - ; + : TRUE + | FALSE + ; list - : '[' NL* expressions_ ','? NL* ']' - | '[' NL* ( expressions_ ','? NL* )? ']' - | '[' NL* tuples ( ',' short_map_entries )? NL* ']' - | '[' NL* short_map_entries NL* ']' - ; + : '[' NL* expressions_ ','? NL* ']' + | '[' NL* ( expressions_ ','? NL*)? ']' + | '[' NL* tuples ( ',' short_map_entries)? NL* ']' + | '[' NL* short_map_entries NL* ']' + ; tuples - : tuple ( ',' tuple )* - ; + : tuple (',' tuple)* + ; tuple - : '{' ( expressions_ ','? )? '}' - ; + : '{' (expressions_ ','?)? '}' + ; map - : OMAP NL* '}' - | OMAP NL* ( expression '|' )? map_entries ','? NL* '}' - | OMAP NL* ( expression '|' )? short_map_entries ','? NL* '}' - | OMAP NL* ( expression '|' )? map_entries ( ',' short_map_entries )? ','? NL* '}' - ; + : OMAP NL* '}' + | OMAP NL* ( expression '|')? map_entries ','? NL* '}' + | OMAP NL* ( expression '|')? short_map_entries ','? NL* '}' + | OMAP NL* (expression '|')? map_entries (',' short_map_entries)? ','? NL* '}' + ; map_entries - : map_entry ( ',' map_entry )* - ; + : map_entry (',' map_entry)* + ; map_entry - : expression '=>' expression - ; + : expression '=>' expression + ; short_map_entries - : short_map_entry ( ',' NL* short_map_entry )* - ; + : short_map_entry (',' NL* short_map_entry)* + ; short_map_entry - : variable ':' expression - ; + : variable ':' expression + ; anonymous_function - : FN NL* expressions_? '->' NL* block? NL* END - | FN '(' expressions_? ')' '->' NL* block? NL* END - ; + : FN NL* expressions_? '->' NL* block? NL* END + | FN '(' expressions_? ')' '->' NL* block? NL* END + ; case - : CASE expression DO NL+ condition+ END - ; + : CASE expression DO NL+ condition+ END + ; condition - : expression '->' NL* expression NL+ - ; + : expression '->' NL* expression NL+ + ; cond - : COND DO NL+ condition+ END - ; + : COND DO NL+ condition+ END + ; if - : IF expression DO NL* block NL* ( ELSE NL* block NL* )? END - | IF expression ',' NL* DO ':' NL* expression ( ',' NL* ELSE ':' NL* expression )? - ; + : IF expression DO NL* block NL* (ELSE NL* block NL*)? END + | IF expression ',' NL* DO ':' NL* expression (',' NL* ELSE ':' NL* expression)? + ; unless - : UNLESS expression do_block - ; + : UNLESS expression do_block + ; bitstring - : '<<' ( expressions_ ','? )? '>>' - ; + : '<<' (expressions_ ','?)? '>>' + ; module_def - : DEFMODULE ALIAS do_block - ; + : DEFMODULE ALIAS do_block + ; function_def - : ( DEF | DEFP ) variable ( '(' expressions_? ')' )+ ( WHEN expression )? do_block - | ( DEF | DEFP ) variable ( '(' expressions_? ')' )+ ( WHEN expression )? ',' DO ':' expression - | ( DEF | DEFP ) variable ',' DO ':' expression - ; + : (DEF | DEFP) variable ('(' expressions_? ')')+ (WHEN expression)? do_block + | (DEF | DEFP) variable ('(' expressions_? ')')+ (WHEN expression)? ',' DO ':' expression + | ( DEF | DEFP) variable ',' DO ':' expression + ; macro_def - : DEFMACRO variable '(' expressions_? ')' ( WHEN expression )? do_block - | DEFMACRO variable '(' expressions_? ')' ( WHEN expression )? ',' DO ':' expression - ; + : DEFMACRO variable '(' expressions_? ')' (WHEN expression)? do_block + | DEFMACRO variable '(' expressions_? ')' (WHEN expression)? ',' DO ':' expression + ; for - : FOR expressions_ ( ',' NL* options_ )? do_block - | FOR expressions_ ( ',' NL* options_ )? ',' DO ':' NL* expression - ; + : FOR expressions_ (',' NL* options_)? do_block + | FOR expressions_ ( ',' NL* options_)? ',' DO ':' NL* expression + ; options_ - : option ( ',' NL* option )* - ; + : option (',' NL* option)* + ; option - : variable ':' expression - ; + : variable ':' expression + ; with - : WITH expressions_ do_block - ; + : WITH expressions_ do_block + ; try - : TRY DO NL* block ( RECUE | CATCH | AFTER ) NL* expressions_ ( NL* block )? ( NL* ELSE NL* block )? NL* END - ; + : TRY DO NL* block (RECUE | CATCH | AFTER) NL* expressions_ (NL* block)? (NL* ELSE NL* block)? NL* END + ; expressions_ - : expression ( ',' NL* expression )* - ; + : expression (',' NL* expression)* + ; variables - : variable ( ',' NL* variable )* - ; + : variable (',' NL* variable)* + ; variable - : VARIABLE - | CASE - | COND - | IF - | UNLESS - | DEFMODULE - | DEFMACRO - | DEF - | DEFP - | FOR - | WITH - | TRY - ; \ No newline at end of file + : VARIABLE + | CASE + | COND + | IF + | UNLESS + | DEFMODULE + | DEFMACRO + | DEF + | DEFP + | FOR + | WITH + | TRY + ; \ No newline at end of file diff --git a/erlang/Erlang.g4 b/erlang/Erlang.g4 index 0ee9d68eb6..05e6e8d364 100644 --- a/erlang/Erlang.g4 +++ b/erlang/Erlang.g4 @@ -23,434 +23,677 @@ // Update to Erlang/OTP 23.3 +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Erlang; -forms : form+ EOF ; +forms + : form+ EOF + ; -form : (attribute | function_) '.' ; +form + : (attribute | function_) '.' + ; /// Tokens -fragment DIGIT : [0-9] ; - -fragment LOWERCASE : [a-z] - | '\u00df'..'\u00f6' - | '\u00f8'..'\u00ff' ; - - -fragment UPPERCASE : [A-Z] - | '\u00c0'..'\u00d6' - | '\u00d8'..'\u00de' ; - -tokAtom : TokAtom ; -TokAtom : LOWERCASE (DIGIT | LOWERCASE | UPPERCASE | '_' | '@')* - | '\'' ( '\\' (~'\\'|'\\') | ~[\\'] )* '\'' ; - -tokVar : TokVar ; -TokVar : (UPPERCASE | '_') (DIGIT | LOWERCASE | UPPERCASE | '_' | '@')* ; - -tokFloat : TokFloat ; -TokFloat : '-'? DIGIT+ '.' DIGIT+ ([Ee] [+-]? DIGIT+)? ; - -tokInteger : TokInteger ; -TokInteger : '-'? DIGIT+ ('#' (DIGIT | [a-zA-Z])+)? ; +fragment DIGIT + : [0-9] + ; -tokChar : TokChar ; -TokChar : '$' ('\\'? ~[\r\n] | '\\' DIGIT DIGIT DIGIT) ; +fragment LOWERCASE + : [a-z] + | '\u00df' ..'\u00f6' + | '\u00f8' ..'\u00ff' + ; -tokString : TokString ; -TokString : '"' ( '\\' (~'\\'|'\\') | ~[\\"] )* '"' ; - -// antlr4 would not accept spec as an Atom otherwise. -AttrName : '-' ('spec' | 'callback') ; - -Comment : '%' ~[\r\n]* '\r'? '\n' -> skip ; - -WS : [\u0000-\u0020\u0080-\u00a0]+ -> skip ; +fragment UPPERCASE + : [A-Z] + | '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00de' + ; +tokAtom + : TokAtom + ; +TokAtom + : LOWERCASE (DIGIT | LOWERCASE | UPPERCASE | '_' | '@')* + | '\'' ( '\\' (~'\\' | '\\') | ~[\\'])* '\'' + ; -attribute : '-' tokAtom attrVal - | '-' tokAtom typedAttrVal - | '-' tokAtom '(' typedAttrVal ')' - | AttrName typeSpec - ; - - -/// Typing - -typeSpec : specFun typeSigs - | '(' specFun typeSigs ')' - ; +tokVar + : TokVar + ; -specFun : tokAtom - | tokAtom ':' tokAtom - ; +TokVar + : (UPPERCASE | '_') (DIGIT | LOWERCASE | UPPERCASE | '_' | '@')* + ; -typedAttrVal : expr ',' typedRecordFields - | expr '::' topType - ; +tokFloat + : TokFloat + ; -typedRecordFields : '{' typedExprs '}' ; +TokFloat + : '-'? DIGIT+ '.' DIGIT+ ([Ee] [+-]? DIGIT+)? + ; -typedExprs : typedExpr - | typedExpr ',' typedExprs - | expr ',' typedExprs - | typedExpr ',' exprs ; +tokInteger + : TokInteger + ; -typedExpr : expr '::' topType ; +TokInteger + : '-'? DIGIT+ ('#' (DIGIT | [a-zA-Z])+)? + ; -typeSigs : typeSig (';' typeSig)* ; +tokChar + : TokChar + ; -typeSig : funType ('when' typeGuards)? ; +TokChar + : '$' ('\\'? ~[\r\n] | '\\' DIGIT DIGIT DIGIT) + ; -typeGuards : typeGuard (',' typeGuard)* ; +tokString + : TokString + ; -typeGuard : tokAtom '(' topTypes ')' - | tokVar '::' topType ; +TokString + : '"' ('\\' (~'\\' | '\\') | ~[\\"])* '"' + ; -topTypes : topType (',' topType)* ; - -topType : (tokVar '::')? topType100 ; - -topType100 : type200 ('|' topType100)? ; - -type200 : type300 ('..' type300)? ; - -type300 : type300 addOp type400 - | type400 ; - -type400 : type400 multOp type500 - | type500 ; - -type500 : prefixOp? type_ ; - -type_ : '(' topType ')' - | tokVar - | tokAtom - | tokAtom '(' ')' - | tokAtom '(' topTypes ')' - | tokAtom ':' tokAtom '(' ')' - | tokAtom ':' tokAtom '(' topTypes ')' - | '[' ']' - | '[' topType ']' - | '[' topType ',' '...' ']' - | '#' '{' '}' - | '#' '{' mapPairTypes '}' - | '{' '}' - | '{' topTypes '}' - | '#' tokAtom '{' '}' - | '#' tokAtom '{' fieldTypes '}' - | binaryType - | tokInteger - | tokChar - | 'fun' '(' ')' - | 'fun' '(' funType100 ')' ; - -funType100 : '(' '...' ')' '->' topType - | funType ; - -funType : '(' (topTypes)? ')' '->' topType ; - -mapPairTypes : mapPairType (',' mapPairType)* ; - -mapPairType : topType ('=>' | ':=') topType ; - -fieldTypes : fieldType (',' fieldType)* ; - -fieldType : tokAtom '::' topType ; +// antlr4 would not accept spec as an Atom otherwise. +AttrName + : '-' ('spec' | 'callback') + ; -binaryType : '<<' '>>' - | '<<' binBaseType '>>' - | '<<' binUnitType '>>' - | '<<' binBaseType ',' binUnitType '>>' - ; +Comment + : '%' ~[\r\n]* '\r'? '\n' -> skip + ; -binBaseType : tokVar ':' type_ ; +WS + : [\u0000-\u0020\u0080-\u00a0]+ -> skip + ; -binUnitType : tokVar ':' tokVar '*' type_ ; +attribute + : '-' tokAtom attrVal + | '-' tokAtom typedAttrVal + | '-' tokAtom '(' typedAttrVal ')' + | AttrName typeSpec + ; +/// Typing +typeSpec + : specFun typeSigs + | '(' specFun typeSigs ')' + ; + +specFun + : tokAtom + | tokAtom ':' tokAtom + ; + +typedAttrVal + : expr ',' typedRecordFields + | expr '::' topType + ; + +typedRecordFields + : '{' typedExprs '}' + ; + +typedExprs + : typedExpr + | typedExpr ',' typedExprs + | expr ',' typedExprs + | typedExpr ',' exprs + ; + +typedExpr + : expr '::' topType + ; + +typeSigs + : typeSig (';' typeSig)* + ; + +typeSig + : funType ('when' typeGuards)? + ; + +typeGuards + : typeGuard (',' typeGuard)* + ; + +typeGuard + : tokAtom '(' topTypes ')' + | tokVar '::' topType + ; + +topTypes + : topType (',' topType)* + ; + +topType + : (tokVar '::')? topType100 + ; + +topType100 + : type200 ('|' topType100)? + ; + +type200 + : type300 ('..' type300)? + ; + +type300 + : type300 addOp type400 + | type400 + ; + +type400 + : type400 multOp type500 + | type500 + ; + +type500 + : prefixOp? type_ + ; + +type_ + : '(' topType ')' + | tokVar + | tokAtom + | tokAtom '(' ')' + | tokAtom '(' topTypes ')' + | tokAtom ':' tokAtom '(' ')' + | tokAtom ':' tokAtom '(' topTypes ')' + | '[' ']' + | '[' topType ']' + | '[' topType ',' '...' ']' + | '#' '{' '}' + | '#' '{' mapPairTypes '}' + | '{' '}' + | '{' topTypes '}' + | '#' tokAtom '{' '}' + | '#' tokAtom '{' fieldTypes '}' + | binaryType + | tokInteger + | tokChar + | 'fun' '(' ')' + | 'fun' '(' funType100 ')' + ; + +funType100 + : '(' '...' ')' '->' topType + | funType + ; + +funType + : '(' (topTypes)? ')' '->' topType + ; + +mapPairTypes + : mapPairType (',' mapPairType)* + ; + +mapPairType + : topType ('=>' | ':=') topType + ; + +fieldTypes + : fieldType (',' fieldType)* + ; + +fieldType + : tokAtom '::' topType + ; + +binaryType + : '<<' '>>' + | '<<' binBaseType '>>' + | '<<' binUnitType '>>' + | '<<' binBaseType ',' binUnitType '>>' + ; + +binBaseType + : tokVar ':' type_ + ; + +binUnitType + : tokVar ':' tokVar '*' type_ + ; /// Exprs -attrVal : expr - | '(' expr ')' - | expr ',' exprs - | '(' expr ',' exprs ')' ; - -function_ : functionClause (';' functionClause)* ; - -functionClause : tokAtom clauseArgs clauseGuard clauseBody ; - - -clauseArgs : patArgumentList ; - -clauseGuard : ('when' guard_)? ; - -clauseBody : '->' exprs ; - - -expr : 'catch' expr - | expr100 ; - -expr100 : expr150 (('=' | '!') expr150)* ; - -expr150 : expr160 ('orelse' expr160)* ; - -expr160 : expr200 ('andalso' expr200)* ; - -expr200 : expr300 (compOp expr300)? ; - -expr300 : expr400 (listOp expr400)* ; - -expr400 : expr500 (addOp expr500)* ; - -expr500 : expr600 (multOp expr600)* ; - -expr600 : prefixOp expr600 - | expr650 ; - -expr650 : mapExpr - | expr700 ; - -expr700 : functionCall - | recordExpr - | expr800 ; - -expr800 : exprMax (':' exprMax)? ; - -exprMax : tokVar - | atomic - | list_ - | binary - | listComprehension - | binaryComprehension - | tuple_ - | '(' expr ')' - | 'begin' exprs 'end' - | ifExpr - | caseExpr - | receiveExpr - | funExpr - | tryExpr - ; - -patExpr : patExpr200 ('=' patExpr)? ; - -patExpr200 : patExpr300 (compOp patExpr300)? ; - -patExpr300 : patExpr400 (listOp patExpr300)? ; - -patExpr400 : patExpr400 addOp patExpr500 - | patExpr500 ; - -patExpr500 : patExpr500 multOp patExpr600 - | patExpr600 ; - -patExpr600 : prefixOp patExpr600 - | patExpr650 ; - -patExpr650 : mapPatExpr - | patExpr700 ; - -patExpr700 : recordPatExpr - | patExpr800 ; - -patExpr800 : patExprMax ; - -patExprMax : tokVar - | atomic - | list_ - | binary - | tuple_ - | '(' patExpr ')' - ; - -mapPatExpr : patExprMax? '#' mapTuple - | mapPatExpr '#' mapTuple ; - -recordPatExpr : '#' tokAtom ('.' tokAtom | recordTuple) ; - -list_ : '[' ']' - | '[' expr tail - ; -tail : ']' - | '|' expr ']' - | ',' expr tail - ; - -binary : '<<' '>>' - | '<<' binElements '>>' ; - -binElements : binElement (',' binElement)* ; - -binElement : bitExpr optBitSizeExpr optBitTypeList ; - -bitExpr : prefixOp? exprMax ; - -optBitSizeExpr : (':' bitSizeExpr)? ; - -optBitTypeList : ('/' bitTypeList)? ; - -bitTypeList : bitType ('-' bitType)* ; - -bitType : tokAtom (':' tokInteger)? ; - -bitSizeExpr : exprMax ; - - -listComprehension : '[' expr '||' lcExprs ']' ; - -binaryComprehension : '<<' exprMax '||' lcExprs '>>' ; - -lcExprs : lcExpr (',' lcExpr)* ; - -lcExpr : expr - | expr '<-' expr - | binary '<=' expr - ; - -tuple_ : '{' exprs? '}' ; - -mapExpr : exprMax? '#' mapTuple - | mapExpr '#' mapTuple ; - -mapTuple : '{' (mapField (',' mapField)*)? '}' ; - -mapField : mapFieldAssoc - | mapFieldExact ; - -mapFieldAssoc : mapKey '=>' expr ; - -mapFieldExact : mapKey ':=' expr ; - -mapKey : expr ; +attrVal + : expr + | '(' expr ')' + | expr ',' exprs + | '(' expr ',' exprs ')' + ; + +function_ + : functionClause (';' functionClause)* + ; + +functionClause + : tokAtom clauseArgs clauseGuard clauseBody + ; + +clauseArgs + : patArgumentList + ; + +clauseGuard + : ('when' guard_)? + ; + +clauseBody + : '->' exprs + ; + +expr + : 'catch' expr + | expr100 + ; + +expr100 + : expr150 (('=' | '!') expr150)* + ; + +expr150 + : expr160 ('orelse' expr160)* + ; + +expr160 + : expr200 ('andalso' expr200)* + ; + +expr200 + : expr300 (compOp expr300)? + ; + +expr300 + : expr400 (listOp expr400)* + ; + +expr400 + : expr500 (addOp expr500)* + ; + +expr500 + : expr600 (multOp expr600)* + ; + +expr600 + : prefixOp expr600 + | expr650 + ; + +expr650 + : mapExpr + | expr700 + ; + +expr700 + : functionCall + | recordExpr + | expr800 + ; + +expr800 + : exprMax (':' exprMax)? + ; + +exprMax + : tokVar + | atomic + | list_ + | binary + | listComprehension + | binaryComprehension + | tuple_ + | '(' expr ')' + | 'begin' exprs 'end' + | ifExpr + | caseExpr + | receiveExpr + | funExpr + | tryExpr + ; + +patExpr + : patExpr200 ('=' patExpr)? + ; + +patExpr200 + : patExpr300 (compOp patExpr300)? + ; + +patExpr300 + : patExpr400 (listOp patExpr300)? + ; + +patExpr400 + : patExpr400 addOp patExpr500 + | patExpr500 + ; + +patExpr500 + : patExpr500 multOp patExpr600 + | patExpr600 + ; + +patExpr600 + : prefixOp patExpr600 + | patExpr650 + ; + +patExpr650 + : mapPatExpr + | patExpr700 + ; + +patExpr700 + : recordPatExpr + | patExpr800 + ; + +patExpr800 + : patExprMax + ; + +patExprMax + : tokVar + | atomic + | list_ + | binary + | tuple_ + | '(' patExpr ')' + ; + +mapPatExpr + : patExprMax? '#' mapTuple + | mapPatExpr '#' mapTuple + ; + +recordPatExpr + : '#' tokAtom ('.' tokAtom | recordTuple) + ; + +list_ + : '[' ']' + | '[' expr tail + ; + +tail + : ']' + | '|' expr ']' + | ',' expr tail + ; + +binary + : '<<' '>>' + | '<<' binElements '>>' + ; + +binElements + : binElement (',' binElement)* + ; + +binElement + : bitExpr optBitSizeExpr optBitTypeList + ; + +bitExpr + : prefixOp? exprMax + ; + +optBitSizeExpr + : (':' bitSizeExpr)? + ; + +optBitTypeList + : ('/' bitTypeList)? + ; + +bitTypeList + : bitType ('-' bitType)* + ; + +bitType + : tokAtom (':' tokInteger)? + ; + +bitSizeExpr + : exprMax + ; + +listComprehension + : '[' expr '||' lcExprs ']' + ; + +binaryComprehension + : '<<' exprMax '||' lcExprs '>>' + ; + +lcExprs + : lcExpr (',' lcExpr)* + ; + +lcExpr + : expr + | expr '<-' expr + | binary '<=' expr + ; + +tuple_ + : '{' exprs? '}' + ; + +mapExpr + : exprMax? '#' mapTuple + | mapExpr '#' mapTuple + ; + +mapTuple + : '{' (mapField (',' mapField)*)? '}' + ; + +mapField + : mapFieldAssoc + | mapFieldExact + ; + +mapFieldAssoc + : mapKey '=>' expr + ; + +mapFieldExact + : mapKey ':=' expr + ; + +mapKey + : expr + ; /* struct : tokAtom tuple ; */ - /* N.B. This is called from expr700. N.B. Field names are returned as the complete object, even if they are always atoms for the moment, this might change in the future. */ -recordExpr : exprMax? '#' tokAtom ('.' tokAtom | recordTuple) - | recordExpr '#' tokAtom ('.' tokAtom | recordTuple) - ; - -recordTuple : '{' recordFields? '}' ; +recordExpr + : exprMax? '#' tokAtom ('.' tokAtom | recordTuple) + | recordExpr '#' tokAtom ('.' tokAtom | recordTuple) + ; -recordFields : recordField (',' recordField)* ; +recordTuple + : '{' recordFields? '}' + ; -recordField : (tokVar | tokAtom) '=' expr ; +recordFields + : recordField (',' recordField)* + ; +recordField + : (tokVar | tokAtom) '=' expr + ; /* N.B. This is called from expr700. */ -functionCall : expr800 argumentList ; - - -ifExpr : 'if' ifClauses 'end' ; - -ifClauses : ifClause (';' ifClause)* ; - -ifClause : guard_ clauseBody ; - - -caseExpr : 'case' expr 'of' crClauses 'end' ; - -crClauses : crClause (';' crClause)* ; - -crClause : expr clauseGuard clauseBody ; - - -receiveExpr : 'receive' crClauses 'end' - | 'receive' 'after' expr clauseBody 'end' - | 'receive' crClauses 'after' expr clauseBody 'end' - ; - - -funExpr : 'fun' tokAtom '/' tokInteger - | 'fun' atomOrVar ':' atomOrVar '/' integerOrVar - | 'fun' funClauses 'end' - ; - -atomOrVar : tokAtom | tokVar ; - -integerOrVar : tokInteger | tokVar ; - - -funClauses : funClause (';' funClause)* ; - -funClause : patArgumentList clauseGuard clauseBody - | tokVar patArgumentList clauseGuard clauseBody ; - -tryExpr : 'try' exprs ('of' crClauses)? tryCatch ; - -tryCatch : 'catch' tryClauses 'end' - | 'catch' tryClauses 'after' exprs 'end' - | 'after' exprs 'end' ; - -tryClauses : tryClause (';' tryClause)* ; - -tryClause : expr clauseGuard clauseBody - | (atomOrVar ':')? patExpr tryOptStackTrace clauseGuard clauseBody ; - - -tryOptStackTrace : (':' tokVar)? ; - -argumentList : '(' exprs? ')' ; - -patArgumentList : '(' patExprs? ')' ; - -exprs : expr (',' expr)* ; - -patExprs : patExpr (',' patExpr)* ; - -guard_ : exprs (';' exprs)* ; - -atomic : tokChar - | tokInteger - | tokFloat - | tokAtom - | (tokString)+ - ; - -prefixOp : '+' - | '-' - | 'bnot' - | 'not' - ; - -multOp : '/' - | '*' - | 'div' - | 'rem' - | 'band' - | 'and' - ; - -addOp : '+' - | '-' - | 'bor' - | 'bxor' - | 'bsl' - | 'bsr' - | 'or' - | 'xor' - ; - -listOp : '++' - | '--' - ; - -compOp : '==' - | '/=' - | '=<' - | '<' - | '>=' - | '>' - | '=:=' - | '=/=' - ; - +functionCall + : expr800 argumentList + ; + +ifExpr + : 'if' ifClauses 'end' + ; + +ifClauses + : ifClause (';' ifClause)* + ; + +ifClause + : guard_ clauseBody + ; + +caseExpr + : 'case' expr 'of' crClauses 'end' + ; + +crClauses + : crClause (';' crClause)* + ; + +crClause + : expr clauseGuard clauseBody + ; + +receiveExpr + : 'receive' crClauses 'end' + | 'receive' 'after' expr clauseBody 'end' + | 'receive' crClauses 'after' expr clauseBody 'end' + ; + +funExpr + : 'fun' tokAtom '/' tokInteger + | 'fun' atomOrVar ':' atomOrVar '/' integerOrVar + | 'fun' funClauses 'end' + ; + +atomOrVar + : tokAtom + | tokVar + ; + +integerOrVar + : tokInteger + | tokVar + ; + +funClauses + : funClause (';' funClause)* + ; + +funClause + : patArgumentList clauseGuard clauseBody + | tokVar patArgumentList clauseGuard clauseBody + ; + +tryExpr + : 'try' exprs ('of' crClauses)? tryCatch + ; + +tryCatch + : 'catch' tryClauses 'end' + | 'catch' tryClauses 'after' exprs 'end' + | 'after' exprs 'end' + ; + +tryClauses + : tryClause (';' tryClause)* + ; + +tryClause + : expr clauseGuard clauseBody + | (atomOrVar ':')? patExpr tryOptStackTrace clauseGuard clauseBody + ; + +tryOptStackTrace + : (':' tokVar)? + ; + +argumentList + : '(' exprs? ')' + ; + +patArgumentList + : '(' patExprs? ')' + ; + +exprs + : expr (',' expr)* + ; + +patExprs + : patExpr (',' patExpr)* + ; + +guard_ + : exprs (';' exprs)* + ; + +atomic + : tokChar + | tokInteger + | tokFloat + | tokAtom + | (tokString)+ + ; + +prefixOp + : '+' + | '-' + | 'bnot' + | 'not' + ; + +multOp + : '/' + | '*' + | 'div' + | 'rem' + | 'band' + | 'and' + ; + +addOp + : '+' + | '-' + | 'bor' + | 'bxor' + | 'bsl' + | 'bsr' + | 'or' + | 'xor' + ; + +listOp + : '++' + | '--' + ; + +compOp + : '==' + | '/=' + | '=<' + | '<' + | '>=' + | '>' + | '=:=' + | '=/=' + ; \ No newline at end of file diff --git a/esolang/brainflak/brainflak.g4 b/esolang/brainflak/brainflak.g4 index 7e1240065a..ec42346dca 100644 --- a/esolang/brainflak/brainflak.g4 +++ b/esolang/brainflak/brainflak.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2020 Tom Everett @@ -26,68 +25,71 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar brainflak; file_ - : statement+ EOF - ; + : statement+ EOF + ; statement - : parenstmt - | bracestmt - | bracketstmt - | gtltstmt - ; + : parenstmt + | bracestmt + | bracketstmt + | gtltstmt + ; parenstmt - : LPAREN statement* RPAREN - ; + : LPAREN statement* RPAREN + ; bracestmt - : LBRACE statement* RBRACE - ; + : LBRACE statement* RBRACE + ; bracketstmt - : LBRACK statement* RBRACK - ; + : LBRACK statement* RBRACK + ; gtltstmt - : LT statement* GT - ; + : LT statement* GT + ; LPAREN - : '(' - ; + : '(' + ; RPAREN - : ')' - ; + : ')' + ; GT - : '>' - ; + : '>' + ; LT - : '<' - ; + : '<' + ; LBRACE - : '{' - ; + : '{' + ; RBRACE - : '}' - ; + : '}' + ; LBRACK - : '[' - ; + : '[' + ; RBRACK - : ']' - ; + : ']' + ; WS - : . -> skip - ; - + : . -> skip + ; \ No newline at end of file diff --git a/esolang/brainfuck/brainfuck.g4 b/esolang/brainfuck/brainfuck.g4 index cadc456eb2..69d2601981 100644 --- a/esolang/brainfuck/brainfuck.g4 +++ b/esolang/brainfuck/brainfuck.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2013 Tom Everett @@ -26,62 +25,62 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar brainfuck; file_ - : statement* EOF - ; + : statement* EOF + ; statement -: opcode -| LPAREN statement* RPAREN -; + : opcode + | LPAREN statement* RPAREN + ; opcode - : GT | LT | PLUS | MINUS | DOT | COMMA - ; - + : GT + | LT + | PLUS + | MINUS + | DOT + | COMMA + ; GT - : '>' - ; - + : '>' + ; LT - : '<' - ; - + : '<' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; DOT - : '.' - ; - + : '.' + ; COMMA - : ',' - ; - + : ',' + ; LPAREN - : '[' - ; - + : '[' + ; RPAREN - : ']' - ; - + : ']' + ; WS - : . -> skip - ; + : . -> skip + ; \ No newline at end of file diff --git a/esolang/cool/COOL.g4 b/esolang/cool/COOL.g4 index e179ec2a42..8dc7d0f48b 100644 --- a/esolang/cool/COOL.g4 +++ b/esolang/cool/COOL.g4 @@ -26,289 +26,297 @@ COOL grammar derived from: http://sist.shanghaitech.edu.cn/faculty/songfu/course/spring2017/cs131/COOL/COOLAid.pdf */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar COOL; program - : (classDefine ';')+ EOF - ; - + : (classDefine ';')+ EOF + ; classDefine - : CLASS TYPEID (INHERITS TYPEID)? '{' (feature ';')* '}' - ; + : CLASS TYPEID (INHERITS TYPEID)? '{' (feature ';')* '}' + ; feature - : OBJECTID '(' (formal (',' formal)*)? ')' ':' TYPEID '{' expression '}' # method - | OBJECTID ':' TYPEID (ASSIGNMENT expression)? # property - ; + : OBJECTID '(' (formal (',' formal)*)? ')' ':' TYPEID '{' expression '}' # method + | OBJECTID ':' TYPEID (ASSIGNMENT expression)? # property + ; formal - : OBJECTID ':' TYPEID - ; + : OBJECTID ':' TYPEID + ; + /* method argument */ - - + expression - : expression ('@' TYPEID)? '.' OBJECTID '(' (expression (',' expression)*)? ')' # methodCall - | OBJECTID '(' (expression (',' expression)*)? ')' # ownMethodCall - | IF expression THEN expression ELSE expression FI # if - | WHILE expression LOOP expression POOL # while - | '{' (expression ';')+ '}' # block - | LET OBJECTID ':' TYPEID (ASSIGNMENT expression)? (',' OBJECTID ':' TYPEID (ASSIGNMENT expression)?)* IN expression # letIn - | CASE expression OF (OBJECTID ':' TYPEID CASE_ARROW expression ';')+ ESAC # case - | NEW TYPEID # new - | INTEGER_NEGATIVE expression # negative - | ISVOID expression # isvoid - | expression MULTIPLY expression # multiply - | expression DIVISION expression # division - | expression ADD expression # add - | expression MINUS expression # minus - | expression LESS_THAN expression # lessThan - | expression LESS_EQUAL expression # lessEqual - | expression EQUAL expression # equal - | NOT expression # boolNot - | '(' expression ')' # parentheses - | OBJECTID # id - | INT # int - | STRING # string - | TRUE # true - | FALSE # false - | OBJECTID ASSIGNMENT expression # assignment - ; - // key words - + : expression ('@' TYPEID)? '.' OBJECTID '(' (expression (',' expression)*)? ')' # methodCall + | OBJECTID '(' (expression (',' expression)*)? ')' # ownMethodCall + | IF expression THEN expression ELSE expression FI # if + | WHILE expression LOOP expression POOL # while + | '{' (expression ';')+ '}' # block + | LET OBJECTID ':' TYPEID (ASSIGNMENT expression)? ( + ',' OBJECTID ':' TYPEID (ASSIGNMENT expression)? + )* IN expression # letIn + | CASE expression OF (OBJECTID ':' TYPEID CASE_ARROW expression ';')+ ESAC # case + | NEW TYPEID # new + | INTEGER_NEGATIVE expression # negative + | ISVOID expression # isvoid + | expression MULTIPLY expression # multiply + | expression DIVISION expression # division + | expression ADD expression # add + | expression MINUS expression # minus + | expression LESS_THAN expression # lessThan + | expression LESS_EQUAL expression # lessEqual + | expression EQUAL expression # equal + | NOT expression # boolNot + | '(' expression ')' # parentheses + | OBJECTID # id + | INT # int + | STRING # string + | TRUE # true + | FALSE # false + | OBJECTID ASSIGNMENT expression # assignment + ; + +// key words + CLASS - : C L A S S - ; + : C L A S S + ; ELSE - : E L S E - ; + : E L S E + ; FALSE - : 'f' A L S E - ; + : 'f' A L S E + ; FI - : F I - ; + : F I + ; IF - : I F - ; + : I F + ; IN - : I N - ; + : I N + ; INHERITS - : I N H E R I T S - ; + : I N H E R I T S + ; ISVOID - : I S V O I D - ; + : I S V O I D + ; LET - : L E T - ; + : L E T + ; LOOP - : L O O P - ; + : L O O P + ; POOL - : P O O L - ; + : P O O L + ; THEN - : T H E N - ; + : T H E N + ; WHILE - : W H I L E - ; + : W H I L E + ; CASE - : C A S E - ; + : C A S E + ; ESAC - : E S A C - ; + : E S A C + ; NEW - : N E W - ; + : N E W + ; OF - : O F - ; + : O F + ; NOT - : N O T - ; + : N O T + ; TRUE - : 't' R U E - ; - // primitives - + : 't' R U E + ; + +// primitives + STRING - : '"' (ESC | ~ ["\\])* '"' - ; + : '"' (ESC | ~ ["\\])* '"' + ; INT - : [0-9]+ - ; + : [0-9]+ + ; TYPEID - : [A-Z] [_0-9A-Za-z]* - ; + : [A-Z] [_0-9A-Za-z]* + ; OBJECTID - : [a-z] [_0-9A-Za-z]* - ; + : [a-z] [_0-9A-Za-z]* + ; ASSIGNMENT - : '<-' - ; + : '<-' + ; CASE_ARROW - : '=>' - ; + : '=>' + ; ADD - : '+' - ; + : '+' + ; MINUS - : '-' - ; + : '-' + ; MULTIPLY - : '*' - ; + : '*' + ; DIVISION - : '/' - ; + : '/' + ; LESS_THAN - : '<' - ; + : '<' + ; LESS_EQUAL - : '<=' - ; + : '<=' + ; EQUAL - : '=' - ; + : '=' + ; INTEGER_NEGATIVE - : '~' - ; + : '~' + ; fragment A - : [aA] - ; + : [aA] + ; fragment C - : [cC] - ; + : [cC] + ; fragment D - : [dD] - ; + : [dD] + ; fragment E - : [eE] - ; + : [eE] + ; fragment F - : [fF] - ; + : [fF] + ; fragment H - : [hH] - ; + : [hH] + ; fragment I - : [iI] - ; + : [iI] + ; fragment L - : [lL] - ; + : [lL] + ; fragment N - : [nN] - ; + : [nN] + ; fragment O - : [oO] - ; + : [oO] + ; fragment P - : [pP] - ; + : [pP] + ; fragment R - : [rR] - ; + : [rR] + ; fragment S - : [sS] - ; + : [sS] + ; fragment T - : [tT] - ; + : [tT] + ; fragment U - : [uU] - ; + : [uU] + ; fragment V - : [vV] - ; + : [vV] + ; fragment W - : [wW] - ; + : [wW] + ; fragment ESC - : '\\' (["\\/bfnrt] | UNICODE) - ; + : '\\' (["\\/bfnrt] | UNICODE) + ; fragment UNICODE - : 'u' HEX HEX HEX HEX - ; + : 'u' HEX HEX HEX HEX + ; fragment HEX - : [0-9a-fA-F] - ; - // comments - + : [0-9a-fA-F] + ; + +// comments + OPEN_COMMENT - : '(*' - ; + : '(*' + ; CLOSE_COMMENT - : '*)' - ; + : '*)' + ; COMMENT - : OPEN_COMMENT (COMMENT | .)*? CLOSE_COMMENT -> skip - ; + : OPEN_COMMENT (COMMENT | .)*? CLOSE_COMMENT -> skip + ; ONE_LINE_COMMENT - : '--' (~ '\n')* '\n'? -> skip - ; - // skip spaces, tabs, newlines, note that \v is not suppoted in antlr - -WHITESPACE - : [ \t\r\n\f]+ -> skip - ; + : '--' (~ '\n')* '\n'? -> skip + ; + +// skip spaces, tabs, newlines, note that \v is not suppoted in antlr +WHITESPACE + : [ \t\r\n\f]+ -> skip + ; \ No newline at end of file diff --git a/esolang/dgol/dgol.g4 b/esolang/dgol/dgol.g4 index 128c108bcd..1e1336e1bf 100644 --- a/esolang/dgol/dgol.g4 +++ b/esolang/dgol/dgol.g4 @@ -29,87 +29,90 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar dgol; module - : (usedeclaration | NL)* (subroutinedefinition | NL)* (programdefinition | librarydefinition) NL* EOF - ; + : (usedeclaration | NL)* (subroutinedefinition | NL)* (programdefinition | librarydefinition) NL* EOF + ; usedeclaration - : 'USE' IDENTIFER NL - ; + : 'USE' IDENTIFER NL + ; subroutinedefinition - : 'SUBROUTINE' IDENTIFER '(' (IDENTIFER (',' IDENTIFER)*)? ')' NL statements 'END' IDENTIFER NL - ; + : 'SUBROUTINE' IDENTIFER '(' (IDENTIFER (',' IDENTIFER)*)? ')' NL statements 'END' IDENTIFER NL + ; programdefinition - : 'PROGRAM' IDENTIFER NL statements 'END' IDENTIFER NL - ; + : 'PROGRAM' IDENTIFER NL statements 'END' IDENTIFER NL + ; librarydefinition - : 'LIBRARY' IDENTIFER (subroutinedeclaration | NL)* 'END' IDENTIFER NL - ; + : 'LIBRARY' IDENTIFER (subroutinedeclaration | NL)* 'END' IDENTIFER NL + ; subroutinedeclaration - : 'SUBROUTINE' IDENTIFER NL - ; + : 'SUBROUTINE' IDENTIFER NL + ; statements - : (statement? NL)* - ; + : (statement? NL)* + ; statement - : letstatement - | ifstatement - | dostatement - | callstatement - | returnstatement - | exitstatement - ; + : letstatement + | ifstatement + | dostatement + | callstatement + | returnstatement + | exitstatement + ; identifierorzero - : IDENTIFER - | '0' - ; + : IDENTIFER + | '0' + ; letstatement - : 'LET' IDENTIFER ('=' identifierorzero | '<' IDENTIFER | '>' identifierorzero) - ; + : 'LET' IDENTIFER ('=' identifierorzero | '<' IDENTIFER | '>' identifierorzero) + ; ifstatement - : ifhead ('ELSE' ifhead)* ('ELSE' NL statements)? 'END' 'IF' - ; + : ifhead ('ELSE' ifhead)* ('ELSE' NL statements)? 'END' 'IF' + ; ifhead - : 'IF' IDENTIFER ('=' | '>') IDENTIFER NL statements - ; + : 'IF' IDENTIFER ('=' | '>') IDENTIFER NL statements + ; dostatement - : 'DO' IDENTIFER ('<' IDENTIFER)? NL statements 'END' 'DO' - ; + : 'DO' IDENTIFER ('<' IDENTIFER)? NL statements 'END' 'DO' + ; callstatement - : 'CALL' IDENTIFER ('.' IDENTIFER)? '(' (identifierorzero (',' identifierorzero)*)? ')' - ; + : 'CALL' IDENTIFER ('.' IDENTIFER)? '(' (identifierorzero (',' identifierorzero)*)? ')' + ; returnstatement - : 'RETURN' - ; + : 'RETURN' + ; exitstatement - : 'EXIT' IDENTIFER - ; + : 'EXIT' IDENTIFER + ; IDENTIFER - : [a-zA-Z] [a-zA-Z0-9]* - ; + : [a-zA-Z] [a-zA-Z0-9]* + ; NL - : [\r\n]+ - ; + : [\r\n]+ + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/esolang/lolcode/lolcode.g4 b/esolang/lolcode/lolcode.g4 index 4e7a3908bb..2499800e68 100644 --- a/esolang/lolcode/lolcode.g4 +++ b/esolang/lolcode/lolcode.g4 @@ -29,172 +29,175 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Adapted from https://github.com/jynnantonix/lolcode/blob/master/BNFGrammar.txt */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar lolcode; program - : 'HAI' code_block 'KTHXBYE'? EOF - ; + : 'HAI' code_block 'KTHXBYE'? EOF + ; code_block - : statement+ - ; + : statement+ + ; statement - : loop - | declaration - | comment - | print_block - | if_block - | input_block - | func_decl - | assignment - | expression - ; + : loop + | declaration + | comment + | print_block + | if_block + | input_block + | func_decl + | assignment + | expression + ; loop - : 'IM IN YR' LABEL 'WILE' expression code_block 'IM OUTTA YR' LABEL - ; + : 'IM IN YR' LABEL 'WILE' expression code_block 'IM OUTTA YR' LABEL + ; declaration - : 'I HAS A' LABEL - | 'I HAS A' LABEL 'ITZ' < value > - ; + : 'I HAS A' LABEL + | 'I HAS A' LABEL 'ITZ' < value> + ; comment - : 'BTW' STRING - | 'OBTW' STRING 'TLDR' - ; + : 'BTW' STRING + | 'OBTW' STRING 'TLDR' + ; print_block - : 'VISIBLE' expression* 'MKAY?'? - ; + : 'VISIBLE' expression* 'MKAY?'? + ; if_block - : 'O RLY?' 'YA RLY' code_block 'OIC' - | 'O RLY?' 'YA RLY' code_block else_if_block 'OIC' - ; + : 'O RLY?' 'YA RLY' code_block 'OIC' + | 'O RLY?' 'YA RLY' code_block else_if_block 'OIC' + ; else_if_block - : 'MEBBE' expression code_block else_if_block - | 'NO WAI' code_block - | 'MEBBE' expression code_block - ; + : 'MEBBE' expression code_block else_if_block + | 'NO WAI' code_block + | 'MEBBE' expression code_block + ; input_block - : 'GIMMEH' LABEL - ; + : 'GIMMEH' LABEL + ; func_decl - : 'HOW DUZ I' LABEL (('YR' LABEL) ('AN YR' LABEL)*)? code_block 'IF U SAY SO' - ; + : 'HOW DUZ I' LABEL (('YR' LABEL) ('AN YR' LABEL)*)? code_block 'IF U SAY SO' + ; assignment - : LABEL 'R' expression - ; + : LABEL 'R' expression + ; expression - : equals - | both - | not_equals - | greater - | less - | add - | sub - | mul - | div - | mod - | cast - | either - | all_ - | any_ - | not_ - | func_ - | LABEL - | ATOM - ; + : equals + | both + | not_equals + | greater + | less + | add + | sub + | mul + | div + | mod + | cast + | either + | all_ + | any_ + | not_ + | func_ + | LABEL + | ATOM + ; equals - : 'BOTH SAEM' expression 'AN' expression - ; + : 'BOTH SAEM' expression 'AN' expression + ; not_equals - : 'DIFFRINT' expression 'AN' expression - ; + : 'DIFFRINT' expression 'AN' expression + ; both - : 'BOTH OF' expression 'AN' expression - ; + : 'BOTH OF' expression 'AN' expression + ; either - : 'EITHER OF' expression 'AN' expression - ; + : 'EITHER OF' expression 'AN' expression + ; greater - : 'BIGGR OF' expression 'AN' expression - ; + : 'BIGGR OF' expression 'AN' expression + ; less - : 'SMALLR OF' expression 'AN' expression - ; + : 'SMALLR OF' expression 'AN' expression + ; add - : 'SUM OF' expression 'AN' expression - ; + : 'SUM OF' expression 'AN' expression + ; sub - : 'DIFF OF' expression 'AN' expression - ; + : 'DIFF OF' expression 'AN' expression + ; mul - : 'PRODUKT OF' expression 'AN' expression - ; + : 'PRODUKT OF' expression 'AN' expression + ; div - : 'QUOSHUNT OF' expression 'AN' expression - ; + : 'QUOSHUNT OF' expression 'AN' expression + ; mod - : 'MOD OF' expression 'AN' expression - ; + : 'MOD OF' expression 'AN' expression + ; cast - : 'MAEK' expression 'A' < type > - ; + : 'MAEK' expression 'A' < type> + ; all_ - : 'ALL OF' expression ('AN' expression)* 'MKAY?' - ; + : 'ALL OF' expression ('AN' expression)* 'MKAY?' + ; any_ - : 'ANY OF' expression ('AN' expression)* 'MKAY?' - ; + : 'ANY OF' expression ('AN' expression)* 'MKAY?' + ; not_ - : 'NOT' expression - ; + : 'NOT' expression + ; func_ - : LABEL expression+ 'MKAY?' - ; + : LABEL expression+ 'MKAY?' + ; LABEL - : ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_')+ - ; + : ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_')+ + ; ATOM - : 'WIN' - | 'FAIL' - | 'NOOB' - | ('0' .. '9')+ - | ('0' .. '9')* '.' ('0' .. '9')* - | STRING - ; + : 'WIN' + | 'FAIL' + | 'NOOB' + | ('0' .. '9')+ + | ('0' .. '9')* '.' ('0' .. '9')* + | STRING + ; STRING - : '"' ('\'"' | ~ '"')* '"' - ; + : '"' ('\'"' | ~ '"')* '"' + ; WS - : [ \r\n] -> skip - ; - + : [ \r\n] -> skip + ; \ No newline at end of file diff --git a/esolang/loop/loop.g4 b/esolang/loop/loop.g4 index 67a148b6f4..3f1d2322d7 100644 --- a/esolang/loop/loop.g4 +++ b/esolang/loop/loop.g4 @@ -29,55 +29,58 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar loop; prog - : statementlist+ EOF - ; + : statementlist+ EOF + ; statementlist - : statement (';' statement)? - ; + : statement (';' statement)? + ; statement - : assignstmt - | incrementstmt - | loopstmt - ; + : assignstmt + | incrementstmt + | loopstmt + ; assignstmt - : var_ ':=' number ';' - ; + : var_ ':=' number ';' + ; incrementstmt - : var_ ':=' var_ ('+' | '-') number - ; + : var_ ':=' var_ ('+' | '-') number + ; loopstmt - : 'LOOP' var_ 'DO' statementlist 'END' - ; + : 'LOOP' var_ 'DO' statementlist 'END' + ; var_ - : ID - ; + : ID + ; number - : NUMBER - ; + : NUMBER + ; ID - : [a-zA-Z] [a-zA-Z0-9]* - ; + : [a-zA-Z] [a-zA-Z0-9]* + ; NUMBER - : [0-9]+ - ; + : [0-9]+ + ; COMMENT - : '/*' .*? '*/' -> skip - ; + : '/*' .*? '*/' -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/esolang/nanofuck/nanofuck.g4 b/esolang/nanofuck/nanofuck.g4 index e9c18e6723..782393f175 100644 --- a/esolang/nanofuck/nanofuck.g4 +++ b/esolang/nanofuck/nanofuck.g4 @@ -29,17 +29,22 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar nanofuck; -file_ : exp EOF ; +file_ + : exp EOF + ; exp - : '*' - | '{' exp? '}' - | exp exp - ; + : '*' + | '{' exp? '}' + | exp exp + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/esolang/sickbay/sickbay.g4 b/esolang/sickbay/sickbay.g4 index fc64f33043..447896392a 100644 --- a/esolang/sickbay/sickbay.g4 +++ b/esolang/sickbay/sickbay.g4 @@ -29,68 +29,71 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar sickbay; sickbay - : line* EOF - ; + : line* EOF + ; line - : intExpr stmt ';'? (':' stmt)* NL - ; + : intExpr stmt ';'? (':' stmt)* NL + ; stmt - : REM - | ('LET' intVar '=' intExpr) - | ('GOTO' INTCONST) - | ('GOSUB' INTCONST) - | ('RETURN' | 'END') - | ('PRINT' (STRCONST | intExpr | intVar)) - | ('PROLONG' INTCONST) - | ('CUTSHORT') - | ('DIM' 'RING' '(' intExpr ')') - | ('INPUT' (intVar | 'CHR$' intVar)) - ; + : REM + | ('LET' intVar '=' intExpr) + | ('GOTO' INTCONST) + | ('GOSUB' INTCONST) + | ('RETURN' | 'END') + | ('PRINT' (STRCONST | intExpr | intVar)) + | ('PROLONG' INTCONST) + | ('CUTSHORT') + | ('DIM' 'RING' '(' intExpr ')') + | ('INPUT' (intVar | 'CHR$' intVar)) + ; intExpr - : intVar - | INTCONST - | 'RND%' '(' intExpr ')' - | '(' intExpr INTOP intExpr ')' - ; + : intVar + | INTCONST + | 'RND%' '(' intExpr ')' + | '(' intExpr INTOP intExpr ')' + ; intVar - : IINTID ('(' intExpr ')')? - ; + : IINTID ('(' intExpr ')')? + ; INTOP - : '+' - | '-' - | '*' - | '/' - ; + : '+' + | '-' + | '*' + | '/' + ; IINTID - : [A-Z] [A-Z0-9%]* - ; + : [A-Z] [A-Z0-9%]* + ; INTCONST - : [0-9] [0-9]* - ; + : [0-9] [0-9]* + ; STRCONST - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; NL - : [\r\n]+ - ; + : [\r\n]+ + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; REM - : 'REM' ([ \t]+) ~[\r\n]* - ; - + : 'REM' ([ \t]+) ~[\r\n]* + ; \ No newline at end of file diff --git a/esolang/snowball/snowball.g4 b/esolang/snowball/snowball.g4 index a0410692c5..c207529344 100644 --- a/esolang/snowball/snowball.g4 +++ b/esolang/snowball/snowball.g4 @@ -29,176 +29,179 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar snowball; program - : p* EOF - ; + : p* EOF + ; p - : declaration - | r_definition - | g_definition - | 'backwardmode' '(' p ')' - ; + : declaration + | r_definition + | g_definition + | 'backwardmode' '(' p ')' + ; declaration - : 'strings' '(' s_name* ')' - | 'integers' '(' i_name* ')' - | 'booleans' '(' b_name* ')' - | 'routines' '(' r_name* ')' - | 'externals' '(' r_name* ')' - | 'groupings' '(' g_name* ')' - ; + : 'strings' '(' s_name* ')' + | 'integers' '(' i_name* ')' + | 'booleans' '(' b_name* ')' + | 'routines' '(' r_name* ')' + | 'externals' '(' r_name* ')' + | 'groupings' '(' g_name* ')' + ; r_definition - : 'define' r_name 'as' c - ; + : 'define' r_name 'as' c + ; g_definition - : 'define' g_name g (PLUS_OR_MINUS g)* - ; + : 'define' g_name g (PLUS_OR_MINUS g)* + ; c - : '(' c* ')' - | i_command - | s_command - | c 'or' c - | c 'and' c - | 'not' c - | 'test' c - | 'try' c - | 'do' c - | 'fail' c - | 'goto' c - | 'gopast' c - | 'repeat' c - | 'loop' ae c - | 'atleast' ae c - | s - | '=' s - | 'insert' s - | 'attach' s - | '<-' s - | 'delete' - | 'hop' ae - | 'next' - | '=>' s_name - | '[' - | ']' - | '->' s_name - | 'setmark' i_name - | 'tomark' ae - | 'atmark' ae - | 'tolimit' - | 'atlimit' - | 'setlimit' c 'for' c - | 'backwards' c - | 'reverse' c - | 'substring' - | 'among' '(' (LITERAL_STRING r_name? | c)* ')' - | 'set' b_name - | 'unset' b_name - | b_name - | r_name - | g_name - | 'non' '-'? g_name - | 'true' - | 'false' - | '?' - ; + : '(' c* ')' + | i_command + | s_command + | c 'or' c + | c 'and' c + | 'not' c + | 'test' c + | 'try' c + | 'do' c + | 'fail' c + | 'goto' c + | 'gopast' c + | 'repeat' c + | 'loop' ae c + | 'atleast' ae c + | s + | '=' s + | 'insert' s + | 'attach' s + | '<-' s + | 'delete' + | 'hop' ae + | 'next' + | '=>' s_name + | '[' + | ']' + | '->' s_name + | 'setmark' i_name + | 'tomark' ae + | 'atmark' ae + | 'tolimit' + | 'atlimit' + | 'setlimit' c 'for' c + | 'backwards' c + | 'reverse' c + | 'substring' + | 'among' '(' (LITERAL_STRING r_name? | c)* ')' + | 'set' b_name + | 'unset' b_name + | b_name + | r_name + | g_name + | 'non' '-'? g_name + | 'true' + | 'false' + | '?' + ; i_command - : '$' i_name '=' ae - | '$' i_name '+=' ae - | '$' i_name '-=' ae - | '$' i_name '*=' ae - | '$' i_name '/=' ae - | '$' i_name '==' ae - | '$' i_name '!=' ae - | '$' i_name '>' ae - | '$' i_name '>=' ae - | '$' i_name '<' ae - | '$' i_name '<=' ae - ; + : '$' i_name '=' ae + | '$' i_name '+=' ae + | '$' i_name '-=' ae + | '$' i_name '*=' ae + | '$' i_name '/=' ae + | '$' i_name '==' ae + | '$' i_name '!=' ae + | '$' i_name '>' ae + | '$' i_name '>=' ae + | '$' i_name '<' ae + | '$' i_name '<=' ae + ; s_command - : '$' s_name c - ; + : '$' s_name c + ; s - : s_name - | LITERAL_STRING - ; + : s_name + | LITERAL_STRING + ; g - : g_name - | LITERAL_STRING - ; + : g_name + | LITERAL_STRING + ; s_name - : NAME - ; + : NAME + ; i_name - : NAME - ; + : NAME + ; b_name - : NAME - ; + : NAME + ; r_name - : NAME - ; + : NAME + ; g_name - : NAME - ; + : NAME + ; ae - : '(' ae ')' - | ae '+' ae - | ae '-' ae - | ae '*' ae - | ae '/' ae - | '-' ae - | 'maxint' - | 'minint' - | 'cursor' - | 'limit' - | 'size' - | 'sizeof' s_name - | i_name - | NUMBER - ; + : '(' ae ')' + | ae '+' ae + | ae '-' ae + | ae '*' ae + | ae '/' ae + | '-' ae + | 'maxint' + | 'minint' + | 'cursor' + | 'limit' + | 'size' + | 'sizeof' s_name + | i_name + | NUMBER + ; LITERAL_STRING - : '\'' ~ '\''* '\'' - ; + : '\'' ~ '\''* '\'' + ; NUMBER - : DIGIT+ - ; + : DIGIT+ + ; PLUS_OR_MINUS - : '+' - | '-' - ; + : '+' + | '-' + ; NAME - : LETTER (LETTER | DIGIT | '_')* - ; + : LETTER (LETTER | DIGIT | '_')* + ; fragment LETTER - : [a-zA-Z] - ; + : [a-zA-Z] + ; fragment DIGIT - : [0-9] - ; + : [0-9] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/esolang/wheel/wheel.g4 b/esolang/wheel/wheel.g4 index ad1315c214..69d8788d0d 100644 --- a/esolang/wheel/wheel.g4 +++ b/esolang/wheel/wheel.g4 @@ -29,46 +29,49 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar wheel; file_ - : codon* EOF - ; + : codon* EOF + ; codon - : SYMBOL VALUE? - ; + : SYMBOL VALUE? + ; VALUE - : DIGIT+ - ; + : DIGIT+ + ; DIGIT - : [0-9] - ; + : [0-9] + ; SYMBOL - : '+' - | '-' - | '<' - | '>' - | 'L' - | 'G' - | 'Z' - | 'Y' - | 'D' - | 'I' - | 'V' - | 'C' - | '*' - | '%' - | '^' - | '#' - | '@' - | '$' - ; + : '+' + | '-' + | '<' + | '>' + | 'L' + | 'G' + | 'Z' + | 'Y' + | 'D' + | 'I' + | 'V' + | 'C' + | '*' + | '%' + | '^' + | '#' + | '@' + | '$' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/evm-bytecode/EVMBLexer.g4 b/evm-bytecode/EVMBLexer.g4 index 661c1d9f3a..6476ebd368 100644 --- a/evm-bytecode/EVMBLexer.g4 +++ b/evm-bytecode/EVMBLexer.g4 @@ -1,654 +1,371 @@ -lexer grammar EVMBLexer; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -STOP - : 'STOP' - ; +lexer grammar EVMBLexer; -ADD - : 'ADD' - ; +STOP: 'STOP'; -MUL - : 'MUL' - ; +ADD: 'ADD'; -SUB - : 'SUB' - ; +MUL: 'MUL'; -DIV - : 'DIV' - ; +SUB: 'SUB'; -SDIV - : 'SDIV' - ; +DIV: 'DIV'; -MOD - : 'MOD' - ; +SDIV: 'SDIV'; -SMOD - : 'SMOD' - ; +MOD: 'MOD'; -ADDMOD - : 'ADDMOD' - ; +SMOD: 'SMOD'; -MULMOD - : 'MULMOD' - ; +ADDMOD: 'ADDMOD'; -EXP - : 'EXP' - ; +MULMOD: 'MULMOD'; -SIGNEXTEND - : 'SIGNEXTEND' - ; +EXP: 'EXP'; -LT - : 'LT' - ; +SIGNEXTEND: 'SIGNEXTEND'; -GT - : 'GT' - ; +LT: 'LT'; -SLT - : 'SLT' - ; +GT: 'GT'; -SGT - : 'SGT' - ; +SLT: 'SLT'; -EQ - : 'EQ' - ; +SGT: 'SGT'; -ISZERO - : 'ISZERO' - ; +EQ: 'EQ'; -AND - : 'AND' - ; +ISZERO: 'ISZERO'; -OR - : 'OR' - ; +AND: 'AND'; -XOR - : 'XOR' - ; +OR: 'OR'; -NOT - : 'NOT' - ; +XOR: 'XOR'; -BYTE - : 'BYTE' - ; +NOT: 'NOT'; -SHL - : 'SHL' - ; +BYTE: 'BYTE'; -SHR - : 'SHR' - ; +SHL: 'SHL'; -SAR - : 'SAR' - ; +SHR: 'SHR'; -SHA3 - : 'SHA3' - ; +SAR: 'SAR'; -ADDRESS - : 'ADDRESS' - ; +SHA3: 'SHA3'; -BALANCE - : 'BALANCE' - ; +ADDRESS: 'ADDRESS'; -ORIGIN - : 'ORIGIN' - ; +BALANCE: 'BALANCE'; -CALLER - : 'CALLER' - ; +ORIGIN: 'ORIGIN'; -CALLVALUE - : 'CALLVALUE' - ; +CALLER: 'CALLER'; -CALLDATALOAD - : 'CALLDATALOAD' - ; +CALLVALUE: 'CALLVALUE'; -CALLDATASIZE - : 'CALLDATASIZE' - ; +CALLDATALOAD: 'CALLDATALOAD'; -CALLDATACOPY - : 'CALLDATACOPY' - ; +CALLDATASIZE: 'CALLDATASIZE'; -CODESIZE - : 'CODESIZE' - ; +CALLDATACOPY: 'CALLDATACOPY'; -CODECOPY - : 'CODECOPY' - ; +CODESIZE: 'CODESIZE'; -GASPRICE - : 'GASPRICE' - ; +CODECOPY: 'CODECOPY'; -EXTCODESIZE - : 'EXTCODESIZE' - ; +GASPRICE: 'GASPRICE'; -EXTCODECOPY - : 'EXTCODECOPY' - ; +EXTCODESIZE: 'EXTCODESIZE'; -RETURNDATASIZE - : 'RETURNDATASIZE' - ; +EXTCODECOPY: 'EXTCODECOPY'; -RETURNDATACOPY - : 'RETURNDATACOPY' - ; +RETURNDATASIZE: 'RETURNDATASIZE'; -EXTCODEHASH - : 'EXTCODEHASH' - ; +RETURNDATACOPY: 'RETURNDATACOPY'; -BLOCKHASH - : 'BLOCKHASH' - ; +EXTCODEHASH: 'EXTCODEHASH'; -COINBASE - : 'COINBASE' - ; +BLOCKHASH: 'BLOCKHASH'; -TIMESTAMP - : 'TIMESTAMP' - ; +COINBASE: 'COINBASE'; -NUMBER - : 'NUMBER' - ; +TIMESTAMP: 'TIMESTAMP'; -DIFFICULTY - : 'DIFFICULTY' - ; +NUMBER: 'NUMBER'; -GASLIMIT - : 'GASLIMIT' - ; +DIFFICULTY: 'DIFFICULTY'; -CHAINID - : 'CHAINID' - ; +GASLIMIT: 'GASLIMIT'; -SELFBALANCE - : 'SELFBALANCE' - ; +CHAINID: 'CHAINID'; -BASEFEE - : 'BASEFEE' - ; +SELFBALANCE: 'SELFBALANCE'; -POP - : 'POP' - ; +BASEFEE: 'BASEFEE'; -MLOAD - : 'MLOAD' - ; +POP: 'POP'; -MSTORE - : 'MSTORE' - ; +MLOAD: 'MLOAD'; -MSTORE8 - : 'MSTORE8' - ; +MSTORE: 'MSTORE'; -SLOAD - : 'SLOAD' - ; +MSTORE8: 'MSTORE8'; -SSTORE - : 'SSTORE' - ; +SLOAD: 'SLOAD'; -JUMP - : 'JUMP' - ; +SSTORE: 'SSTORE'; -JUMPI - : 'JUMPI' - ; +JUMP: 'JUMP'; -PC - : 'PC' - ; +JUMPI: 'JUMPI'; -MSIZE - : 'MSIZE' - ; +PC: 'PC'; -GAS - : 'GAS' - ; +MSIZE: 'MSIZE'; -JUMPDEST - : 'JUMPDEST' - ; +GAS: 'GAS'; -PUSH1 - : 'PUSH1' Head Hexs - ; +JUMPDEST: 'JUMPDEST'; -PUSH2 - : 'PUSH2' Head Hexs Hexs - ; +PUSH1: 'PUSH1' Head Hexs; -PUSH3 - : 'PUSH3' Head Hexs Hexs Hexs - ; +PUSH2: 'PUSH2' Head Hexs Hexs; -PUSH4 - : 'PUSH4' Head Hexs Hexs Hexs Hexs - ; +PUSH3: 'PUSH3' Head Hexs Hexs Hexs; -PUSH5 - : 'PUSH5' Head Hexs Hexs Hexs Hexs Hexs - ; +PUSH4: 'PUSH4' Head Hexs Hexs Hexs Hexs; -PUSH6 - : 'PUSH6' Head Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH5: 'PUSH5' Head Hexs Hexs Hexs Hexs Hexs; -PUSH7 - : 'PUSH7' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH6: 'PUSH6' Head Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH8 - : 'PUSH8' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH7: 'PUSH7' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH9 - : 'PUSH9' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH8: 'PUSH8' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH10 - : 'PUSH10' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH9: 'PUSH9' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH11 - : 'PUSH11' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH10: 'PUSH10' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH12 - : 'PUSH12' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH11: 'PUSH11' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH13 - : 'PUSH13' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH12: 'PUSH12' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH14 - : 'PUSH14' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH13: 'PUSH13' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH15 - : 'PUSH15' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH14: 'PUSH14' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH16 - : 'PUSH16' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH15: 'PUSH15' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs; -PUSH17 - : 'PUSH17' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH16: + 'PUSH16' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH18 - : 'PUSH18' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH17: + 'PUSH17' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH19 - : 'PUSH19' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH18: + 'PUSH18' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH20 - : 'PUSH20' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH19: + 'PUSH19' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH21 - : 'PUSH21' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH20: + 'PUSH20' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH22 - : 'PUSH22' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH21: + 'PUSH21' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH23 - : 'PUSH23' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH22: + 'PUSH22' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH24 - : 'PUSH24' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH23: + 'PUSH23' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH25 - : 'PUSH25' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH24: + 'PUSH24' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH26 - : 'PUSH26' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH25: + 'PUSH25' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH27 - : 'PUSH27' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH26: + 'PUSH26' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs +; -PUSH28 - : 'PUSH28' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH27: + 'PUSH27' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs + Hexs +; -PUSH29 - : 'PUSH29' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH28: + 'PUSH28' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs + Hexs Hexs +; -PUSH30 - : 'PUSH30' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH29: + 'PUSH29' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs + Hexs Hexs Hexs +; -PUSH31 - : 'PUSH31' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH30: + 'PUSH30' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs + Hexs Hexs Hexs Hexs +; -PUSH32 - : 'PUSH32' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs - ; +PUSH31: + 'PUSH31' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs + Hexs Hexs Hexs Hexs Hexs +; -DUP1 - : 'DUP1' - ; +PUSH32: + 'PUSH32' Head Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs Hexs + Hexs Hexs Hexs Hexs Hexs Hexs +; -DUP2 - : 'DUP2' - ; +DUP1: 'DUP1'; -DUP3 - : 'DUP3' - ; +DUP2: 'DUP2'; -DUP4 - : 'DUP4' - ; +DUP3: 'DUP3'; -DUP5 - : 'DUP5' - ; +DUP4: 'DUP4'; -DUP6 - : 'DUP6' - ; +DUP5: 'DUP5'; -DUP7 - : 'DUP7' - ; +DUP6: 'DUP6'; -DUP8 - : 'DUP8' - ; +DUP7: 'DUP7'; -DUP9 - : 'DUP9' - ; +DUP8: 'DUP8'; -DUP10 - : 'DUP10' - ; +DUP9: 'DUP9'; -DUP11 - : 'DUP11' - ; +DUP10: 'DUP10'; -DUP12 - : 'DUP12' - ; +DUP11: 'DUP11'; -DUP13 - : 'DUP13' - ; +DUP12: 'DUP12'; -DUP14 - : 'DUP14' - ; +DUP13: 'DUP13'; -DUP15 - : 'DUP15' - ; +DUP14: 'DUP14'; -DUP16 - : 'DUP16' - ; +DUP15: 'DUP15'; -SWAP1 - : 'SWAP1' - ; +DUP16: 'DUP16'; -SWAP2 - : 'SWAP2' - ; +SWAP1: 'SWAP1'; -SWAP3 - : 'SWAP3' - ; +SWAP2: 'SWAP2'; -SWAP4 - : 'SWAP4' - ; +SWAP3: 'SWAP3'; -SWAP5 - : 'SWAP5' - ; +SWAP4: 'SWAP4'; -SWAP6 - : 'SWAP6' - ; +SWAP5: 'SWAP5'; -SWAP7 - : 'SWAP7' - ; +SWAP6: 'SWAP6'; -SWAP8 - : 'SWAP8' - ; +SWAP7: 'SWAP7'; -SWAP9 - : 'SWAP9' - ; +SWAP8: 'SWAP8'; -SWAP10 - : 'SWAP10' - ; +SWAP9: 'SWAP9'; -SWAP11 - : 'SWAP11' - ; +SWAP10: 'SWAP10'; -SWAP12 - : 'SWAP12' - ; +SWAP11: 'SWAP11'; -SWAP13 - : 'SWAP13' - ; +SWAP12: 'SWAP12'; -SWAP14 - : 'SWAP14' - ; +SWAP13: 'SWAP13'; -SWAP15 - : 'SWAP15' - ; +SWAP14: 'SWAP14'; -SWAP16 - : 'SWAP16' - ; +SWAP15: 'SWAP15'; -LOG0 - : 'LOG0' - ; +SWAP16: 'SWAP16'; -LOG1 - : 'LOG1' - ; +LOG0: 'LOG0'; -LOG2 - : 'LOG2' - ; +LOG1: 'LOG1'; -LOG3 - : 'LOG3' - ; +LOG2: 'LOG2'; -LOG4 - : 'LOG4' - ; +LOG3: 'LOG3'; -JUMPTO - : 'JUMPTO' - ; +LOG4: 'LOG4'; -JUMPIF - : 'JUMPIF' - ; +JUMPTO: 'JUMPTO'; -JUMPSUB - : 'JUMPSUB' - ; +JUMPIF: 'JUMPIF'; -JUMPSUBV - : 'JUMPSUBV' - ; +JUMPSUB: 'JUMPSUB'; -BEGINSUB - : 'BEGINSUB' - ; +JUMPSUBV: 'JUMPSUBV'; -BEGINDATA - : 'BEGINDATA' - ; +BEGINSUB: 'BEGINSUB'; -RETURNSUB - : 'RETURNSUB' - ; +BEGINDATA: 'BEGINDATA'; -PUTLOCAL - : 'PUTLOCAL' - ; +RETURNSUB: 'RETURNSUB'; -GETLOCA - : 'GETLOCA' - ; +PUTLOCAL: 'PUTLOCAL'; -SLOADBYTES - : 'SLOADBYTES' - ; +GETLOCA: 'GETLOCA'; -SSTOREBYTES - : 'SSTOREBYTES' - ; +SLOADBYTES: 'SLOADBYTES'; -SSIZE - : 'SSIZE' - ; +SSTOREBYTES: 'SSTOREBYTES'; -CREATE - : 'CREATE' - ; +SSIZE: 'SSIZE'; -CALL - : 'CALL' - ; +CREATE: 'CREATE'; -CALLCODE - : 'CALLCODE' - ; +CALL: 'CALL'; -RETURN - : 'RETURN' - ; +CALLCODE: 'CALLCODE'; -DELEGATECALL - : 'DELEGATECALL' - ; +RETURN: 'RETURN'; -CALLBLACKBOX - : 'CALLBLACKBOX' - ; +DELEGATECALL: 'DELEGATECALL'; -STATICCALL - : 'STATICCALL' - ; +CALLBLACKBOX: 'CALLBLACKBOX'; -CREATE2 - : 'CREATE2' - ; +STATICCALL: 'STATICCALL'; -TXEXECGAS - : 'TXEXECGAS' - ; +CREATE2: 'CREATE2'; -REVERT - : 'REVERT' - ; +TXEXECGAS: 'TXEXECGAS'; -INVALID - : 'INVALID' - ; +REVERT: 'REVERT'; -SELFDESTRUCT - : 'SELFDESTRUCT' - ; +INVALID: 'INVALID'; -UNKNOW - : '\'' Hexs '\'' ' '? Unknown - ; +SELFDESTRUCT: 'SELFDESTRUCT'; -fragment Unknown - : '(' 'Unknown Opcode' ')' - ; +UNKNOW: '\'' Hexs '\'' ' '? Unknown; -fragment Head - : ' ' '0' [xX] - ; +fragment Unknown: '(' 'Unknown Opcode' ')'; -fragment Hex - : [0-9a-fA-F] - ; +fragment Head: ' ' '0' [xX]; -fragment Hexs - : Hex Hex - ; +fragment Hex: [0-9a-fA-F]; -WS - : [ \n\t\r] -> channel(HIDDEN) - ; +fragment Hexs: Hex Hex; +WS: [ \n\t\r] -> channel(HIDDEN); \ No newline at end of file diff --git a/evm-bytecode/EVMBParser.g4 b/evm-bytecode/EVMBParser.g4 index 431209d5b9..75d1fb2ecd 100644 --- a/evm-bytecode/EVMBParser.g4 +++ b/evm-bytecode/EVMBParser.g4 @@ -1,168 +1,173 @@ +// $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 EVMBParser; -options { tokenVocab = EVMBLexer; } +options { + tokenVocab = EVMBLexer; +} + program - : opcodes+ EOF - ; + : opcodes+ EOF + ; opcodes - : STOP - | ADD - | MUL - | SUB - | DIV - | SDIV - | MOD - | SMOD - | ADDMOD - | MULMOD - | EXP - | SIGNEXTEND - | LT - | GT - | SLT - | SGT - | EQ - | ISZERO - | AND - | OR - | XOR - | NOT - | BYTE - | SHL - | SHR - | SAR - | SHA3 - | ADDRESS - | BALANCE - | ORIGIN - | CALLER - | CALLVALUE - | CALLDATALOAD - | CALLDATASIZE - | CALLDATACOPY - | CODESIZE - | CODECOPY - | GASPRICE - | EXTCODESIZE - | EXTCODECOPY - | RETURNDATASIZE - | RETURNDATACOPY - | EXTCODEHASH - | BLOCKHASH - | COINBASE - | TIMESTAMP - | NUMBER - | DIFFICULTY - | GASLIMIT - | CHAINID - | SELFBALANCE - | BASEFEE - | POP - | MLOAD - | MSTORE - | MSTORE8 - | SLOAD - | SSTORE - | JUMP - | JUMPI - | PC - | MSIZE - | GAS - | JUMPDEST - | PUSH1 - | PUSH2 - | PUSH3 - | PUSH4 - | PUSH5 - | PUSH6 - | PUSH7 - | PUSH8 - | PUSH9 - | PUSH10 - | PUSH11 - | PUSH12 - | PUSH13 - | PUSH14 - | PUSH15 - | PUSH16 - | PUSH17 - | PUSH18 - | PUSH19 - | PUSH20 - | PUSH21 - | PUSH22 - | PUSH23 - | PUSH24 - | PUSH25 - | PUSH26 - | PUSH27 - | PUSH28 - | PUSH29 - | PUSH30 - | PUSH31 - | PUSH32 - | DUP1 - | DUP2 - | DUP3 - | DUP4 - | DUP5 - | DUP6 - | DUP7 - | DUP8 - | DUP9 - | DUP10 - | DUP11 - | DUP12 - | DUP13 - | DUP14 - | DUP15 - | DUP16 - | SWAP1 - | SWAP2 - | SWAP3 - | SWAP4 - | SWAP5 - | SWAP6 - | SWAP7 - | SWAP8 - | SWAP9 - | SWAP10 - | SWAP11 - | SWAP12 - | SWAP13 - | SWAP14 - | SWAP15 - | SWAP16 - | LOG0 - | LOG1 - | LOG2 - | LOG3 - | LOG4 - | JUMPTO - | JUMPIF - | JUMPSUB - | JUMPSUBV - | BEGINSUB - | BEGINDATA - | RETURNSUB - | PUTLOCAL - | GETLOCA - | SLOADBYTES - | SSTOREBYTES - | SSIZE - | CREATE - | CALL - | CALLCODE - | RETURN - | DELEGATECALL - | CALLBLACKBOX - | STATICCALL - | CREATE2 - | TXEXECGAS - | REVERT - | INVALID - | SELFDESTRUCT - | UNKNOW - ; - + : STOP + | ADD + | MUL + | SUB + | DIV + | SDIV + | MOD + | SMOD + | ADDMOD + | MULMOD + | EXP + | SIGNEXTEND + | LT + | GT + | SLT + | SGT + | EQ + | ISZERO + | AND + | OR + | XOR + | NOT + | BYTE + | SHL + | SHR + | SAR + | SHA3 + | ADDRESS + | BALANCE + | ORIGIN + | CALLER + | CALLVALUE + | CALLDATALOAD + | CALLDATASIZE + | CALLDATACOPY + | CODESIZE + | CODECOPY + | GASPRICE + | EXTCODESIZE + | EXTCODECOPY + | RETURNDATASIZE + | RETURNDATACOPY + | EXTCODEHASH + | BLOCKHASH + | COINBASE + | TIMESTAMP + | NUMBER + | DIFFICULTY + | GASLIMIT + | CHAINID + | SELFBALANCE + | BASEFEE + | POP + | MLOAD + | MSTORE + | MSTORE8 + | SLOAD + | SSTORE + | JUMP + | JUMPI + | PC + | MSIZE + | GAS + | JUMPDEST + | PUSH1 + | PUSH2 + | PUSH3 + | PUSH4 + | PUSH5 + | PUSH6 + | PUSH7 + | PUSH8 + | PUSH9 + | PUSH10 + | PUSH11 + | PUSH12 + | PUSH13 + | PUSH14 + | PUSH15 + | PUSH16 + | PUSH17 + | PUSH18 + | PUSH19 + | PUSH20 + | PUSH21 + | PUSH22 + | PUSH23 + | PUSH24 + | PUSH25 + | PUSH26 + | PUSH27 + | PUSH28 + | PUSH29 + | PUSH30 + | PUSH31 + | PUSH32 + | DUP1 + | DUP2 + | DUP3 + | DUP4 + | DUP5 + | DUP6 + | DUP7 + | DUP8 + | DUP9 + | DUP10 + | DUP11 + | DUP12 + | DUP13 + | DUP14 + | DUP15 + | DUP16 + | SWAP1 + | SWAP2 + | SWAP3 + | SWAP4 + | SWAP5 + | SWAP6 + | SWAP7 + | SWAP8 + | SWAP9 + | SWAP10 + | SWAP11 + | SWAP12 + | SWAP13 + | SWAP14 + | SWAP15 + | SWAP16 + | LOG0 + | LOG1 + | LOG2 + | LOG3 + | LOG4 + | JUMPTO + | JUMPIF + | JUMPSUB + | JUMPSUBV + | BEGINSUB + | BEGINDATA + | RETURNSUB + | PUTLOCAL + | GETLOCA + | SLOADBYTES + | SSTOREBYTES + | SSIZE + | CREATE + | CALL + | CALLCODE + | RETURN + | DELEGATECALL + | CALLBLACKBOX + | STATICCALL + | CREATE2 + | TXEXECGAS + | REVERT + | INVALID + | SELFDESTRUCT + | UNKNOW + ; \ No newline at end of file diff --git a/fasta/fasta.g4 b/fasta/fasta.g4 index 5c36b0f16d..8eee4eef4f 100644 --- a/fasta/fasta.g4 +++ b/fasta/fasta.g4 @@ -29,72 +29,75 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar fasta; sequence - : section+ EOF - ; + : section+ EOF + ; section - : descriptionline - | sequencelines - | commentline - ; + : descriptionline + | sequencelines + | commentline + ; sequencelines - : SEQUENCELINE+ - ; + : SEQUENCELINE+ + ; descriptionline - : DESCRIPTIONLINE - ; + : DESCRIPTIONLINE + ; commentline - : COMMENTLINE - ; + : COMMENTLINE + ; COMMENTLINE - : ';' .*? EOL - ; + : ';' .*? EOL + ; DESCRIPTIONLINE - : '>' TEXT ('|' TEXT)* EOL - ; + : '>' TEXT ('|' TEXT)* EOL + ; TEXT - : (DIGIT | LETTER | SYMBOL)+ - ; + : (DIGIT | LETTER | SYMBOL)+ + ; EOL - : '\r'? '\n' - ; + : '\r'? '\n' + ; fragment DIGIT - : [0-9] - ; + : [0-9] + ; fragment LETTER - : [A-Za-z] - ; + : [A-Za-z] + ; fragment SYMBOL - : '.' - | '-' - | '+' - | '_' - | ' ' - | '[' - | ']' - | '(' - | ')' - | ',' - | '/' - | ':' - | '&' - | '\'' - ; + : '.' + | '-' + | '+' + | '_' + | ' ' + | '[' + | ']' + | '(' + | ')' + | ',' + | '/' + | ':' + | '&' + | '\'' + ; SEQUENCELINE - : LETTER+ EOL - ; - + : LETTER+ EOL + ; \ No newline at end of file diff --git a/fdo91/fdo91.g4 b/fdo91/fdo91.g4 index 1e6d77a42e..eb189f982d 100644 --- a/fdo91/fdo91.g4 +++ b/fdo91/fdo91.g4 @@ -22,61 +22,64 @@ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar fdo91; file_ - : atom* EOF - ; + : atom* EOF + ; atom - : 'atom$'? command (literal_args | arglist)? - ; + : 'atom$'? command (literal_args | arglist)? + ; arglist - : '<' arg (',' arg)* '>' - ; + : '<' arg (',' arg)* '>' + ; arg - : literal - | atom+ - ; + : literal + | atom+ + ; literal_args - : literal+ - ; + : literal+ + ; literal - : ID - | NUMBER - | STRING - | GID - ; + : ID + | NUMBER + | STRING + | GID + ; command - : ID - ; + : ID + ; ID - : [a-zA-Z_]+ - ; + : [a-zA-Z_]+ + ; GID - : NUMBER '-' NUMBER ('-' NUMBER)? - ; + : NUMBER '-' NUMBER ('-' NUMBER)? + ; NUMBER - : [0-9]+ - ; + : [0-9]+ + ; STRING - : '"' ~ ["\r\n]* '"' - ; + : '"' ~ ["\r\n]* '"' + ; COMMENT - : '#' ~ [\r\n]* -> skip - ; + : '#' ~ [\r\n]* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/fen/fen.g4 b/fen/fen.g4 index 04619d7ad8..4364d1f4f9 100644 --- a/fen/fen.g4 +++ b/fen/fen.g4 @@ -30,73 +30,73 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar fen; fen - : placement ' ' color ' ' castling ' ' enpassant ' ' halfmoveclock ' ' fullmoveclock EOF - ; + : placement ' ' color ' ' castling ' ' enpassant ' ' halfmoveclock ' ' fullmoveclock EOF + ; color - : 'w' - | 'b' - ; + : 'w' + | 'b' + ; castling - : '-' - | ('Q' | 'K' | 'k' | 'q') + - ; + : '-' + | ('Q' | 'K' | 'k' | 'q')+ + ; enpassant - : '-' - | position - ; + : '-' + | position + ; position - : ('a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h') NUMBER - ; + : ('a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h') NUMBER + ; halfmoveclock - : NUMBER - ; + : NUMBER + ; fullmoveclock - : NUMBER - ; + : NUMBER + ; placement - : rank ('/' rank) + - ; + : rank ('/' rank)+ + ; rank - : (piece | NUMBER) + - ; + : (piece | NUMBER)+ + ; piece - : 'p' - | 'r' - | 'n' - | 'b' - | 'q' - | 'k' - | 'P' - | 'R' - | 'N' - | 'B' - | 'Q' - | 'K' - ; - + : 'p' + | 'r' + | 'n' + | 'b' + | 'q' + | 'k' + | 'P' + | 'R' + | 'N' + | 'B' + | 'Q' + | 'K' + ; fragment DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; NUMBER - : DIGIT + - ; - + : DIGIT+ + ; WS - : [\r\n\t] + -> skip - ; + : [\r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/flatbuffers/FlatBuffers.g4 b/flatbuffers/FlatBuffers.g4 index b5b2f853cf..e674c3b5cb 100644 --- a/flatbuffers/FlatBuffers.g4 +++ b/flatbuffers/FlatBuffers.g4 @@ -1,197 +1,381 @@ -grammar FlatBuffers ; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar FlatBuffers; // Parser rules -schema : include_* ( namespace_decl | type_decl | enum_decl | union_decl | root_decl | file_extension_decl | file_identifier_decl | attribute_decl | rpc_decl | object_ )* EOF ; +schema + : include_* ( + namespace_decl + | type_decl + | enum_decl + | union_decl + | root_decl + | file_extension_decl + | file_identifier_decl + | attribute_decl + | rpc_decl + | object_ + )* EOF + ; -include_ : ( INCLUDE | NATIVE_INCLUDE ) STRING_CONSTANT SEMI ; +include_ + : (INCLUDE | NATIVE_INCLUDE) STRING_CONSTANT SEMI + ; -namespace_decl : NAMESPACE identifier ( DOT identifier )* SEMI ; +namespace_decl + : NAMESPACE identifier (DOT identifier)* SEMI + ; -attribute_decl : ATTRIBUTE STRING_CONSTANT SEMI ; +attribute_decl + : ATTRIBUTE STRING_CONSTANT SEMI + ; -type_decl : ( TABLE | STRUCT ) identifier metadata LC ( field_decl )* RC ; +type_decl + : (TABLE | STRUCT) identifier metadata LC (field_decl)* RC + ; -enum_decl : ENUM identifier ( COLON type_ )? metadata LC commasep_enumval_decl RC ; +enum_decl + : ENUM identifier (COLON type_)? metadata LC commasep_enumval_decl RC + ; -union_decl : UNION identifier metadata LC commasep_unionval_with_opt_alias RC ; +union_decl + : UNION identifier metadata LC commasep_unionval_with_opt_alias RC + ; -root_decl : ROOT_TYPE identifier SEMI ; +root_decl + : ROOT_TYPE identifier SEMI + ; -field_decl : identifier COLON type_ ( EQ scalar )? metadata SEMI ; +field_decl + : identifier COLON type_ (EQ scalar)? metadata SEMI + ; -rpc_decl : RPC_SERVICE identifier LC rpc_method+ RC ; +rpc_decl + : RPC_SERVICE identifier LC rpc_method+ RC + ; -rpc_method : identifier LP identifier RP COLON identifier metadata SEMI ; +rpc_method + : identifier LP identifier RP COLON identifier metadata SEMI + ; -type_ : LB type_ ( COLON integer_const )? RB | BASE_TYPE_NAME | ns_ident ; +type_ + : LB type_ (COLON integer_const)? RB + | BASE_TYPE_NAME + | ns_ident + ; -enumval_decl : ns_ident ( EQ integer_const )? ; +enumval_decl + : ns_ident (EQ integer_const)? + ; -commasep_enumval_decl : enumval_decl ( COMMA enumval_decl )* COMMA? ; +commasep_enumval_decl + : enumval_decl (COMMA enumval_decl)* COMMA? + ; -unionval_with_opt_alias : ns_ident ( COLON ns_ident )? ( EQ integer_const )? ; +unionval_with_opt_alias + : ns_ident (COLON ns_ident)? (EQ integer_const)? + ; -commasep_unionval_with_opt_alias : unionval_with_opt_alias ( COMMA unionval_with_opt_alias )* COMMA? ; +commasep_unionval_with_opt_alias + : unionval_with_opt_alias (COMMA unionval_with_opt_alias)* COMMA? + ; -ident_with_opt_single_value : identifier ( COLON single_value )? ; +ident_with_opt_single_value + : identifier (COLON single_value)? + ; -commasep_ident_with_opt_single_value : ident_with_opt_single_value ( COMMA ident_with_opt_single_value )* ; +commasep_ident_with_opt_single_value + : ident_with_opt_single_value (COMMA ident_with_opt_single_value)* + ; -metadata : ( LP commasep_ident_with_opt_single_value RP )? ; +metadata + : (LP commasep_ident_with_opt_single_value RP)? + ; -scalar : INTEGER_CONSTANT | HEX_INTEGER_CONSTANT | FLOAT_CONSTANT | identifier ; +scalar + : INTEGER_CONSTANT + | HEX_INTEGER_CONSTANT + | FLOAT_CONSTANT + | identifier + ; -object_ : LC commasep_ident_with_value RC ; +object_ + : LC commasep_ident_with_value RC + ; -ident_with_value : identifier COLON value ; +ident_with_value + : identifier COLON value + ; -commasep_ident_with_value : ident_with_value ( COMMA ident_with_value )* COMMA? ; +commasep_ident_with_value + : ident_with_value (COMMA ident_with_value)* COMMA? + ; -single_value : scalar | STRING_CONSTANT ; +single_value + : scalar + | STRING_CONSTANT + ; -value : single_value | object_ | LB commasep_value RB ; +value + : single_value + | object_ + | LB commasep_value RB + ; -commasep_value : value( COMMA value )* COMMA? ; +commasep_value + : value (COMMA value)* COMMA? + ; -file_extension_decl : FILE_EXTENSION STRING_CONSTANT SEMI ; +file_extension_decl + : FILE_EXTENSION STRING_CONSTANT SEMI + ; -file_identifier_decl : FILE_IDENTIFIER STRING_CONSTANT SEMI ; +file_identifier_decl + : FILE_IDENTIFIER STRING_CONSTANT SEMI + ; -ns_ident : identifier ( DOT identifier )* ; +ns_ident + : identifier (DOT identifier)* + ; -integer_const : INTEGER_CONSTANT | HEX_INTEGER_CONSTANT ; +integer_const + : INTEGER_CONSTANT + | HEX_INTEGER_CONSTANT + ; -identifier: IDENT | keywords; +identifier + : IDENT + | keywords + ; keywords - : ATTRIBUTE - | ENUM - | FILE_EXTENSION - | FILE_IDENTIFIER - | INCLUDE - | NATIVE_INCLUDE - | NAMESPACE - | ROOT_TYPE - | RPC_SERVICE - | STRUCT - | TABLE - | UNION - ; + : ATTRIBUTE + | ENUM + | FILE_EXTENSION + | FILE_IDENTIFIER + | INCLUDE + | NATIVE_INCLUDE + | NAMESPACE + | ROOT_TYPE + | RPC_SERVICE + | STRUCT + | TABLE + | UNION + ; // Lexer rules // keywords -ATTRIBUTE: 'attribute'; -ENUM: 'enum'; -FILE_EXTENSION: 'file_extension'; -FILE_IDENTIFIER: 'file_identifier'; -INCLUDE: 'include'; -NATIVE_INCLUDE: 'native_include'; -NAMESPACE: 'namespace'; -ROOT_TYPE: 'root_type'; -RPC_SERVICE:'rpc_service'; -STRUCT: 'struct'; -TABLE: 'table'; -UNION: 'union'; +ATTRIBUTE + : 'attribute' + ; + +ENUM + : 'enum' + ; + +FILE_EXTENSION + : 'file_extension' + ; + +FILE_IDENTIFIER + : 'file_identifier' + ; + +INCLUDE + : 'include' + ; + +NATIVE_INCLUDE + : 'native_include' + ; + +NAMESPACE + : 'namespace' + ; + +ROOT_TYPE + : 'root_type' + ; + +RPC_SERVICE + : 'rpc_service' + ; + +STRUCT + : 'struct' + ; + +TABLE + : 'table' + ; + +UNION + : 'union' + ; // symbols -SEMI: ';'; -EQ: '='; -LP: '('; -RP: ')'; -LB: '['; -RB: ']'; -LC: '{'; -RC: '}'; -DOT: '.'; -COMMA: ','; -COLON: ':'; -PLUS: '+'; -MINUS: '-'; +SEMI + : ';' + ; + +EQ + : '=' + ; + +LP + : '(' + ; + +RP + : ')' + ; + +LB + : '[' + ; + +RB + : ']' + ; -fragment -DECIMAL_DIGIT - : [0-9] +LC + : '{' ; -fragment -HEXADECIMAL_DIGIT - : [0-9a-fA-F] +RC + : '}' ; -fragment -ESCAPE_SEQUENCE - : SIMPLE_ESCAPE_SEQUENCE - | HEXADECIMAL_ESCAPE_SEQUENCE - | UNICODE_ESCAPE_SEQUENCE +DOT + : '.' ; -fragment -SIMPLE_ESCAPE_SEQUENCE - : '\\' ['"?bfnrtv\\/] +COMMA + : ',' ; - -fragment -HEXADECIMAL_ESCAPE_SEQUENCE - : '\\x' HEXADECIMAL_DIGIT+ + +COLON + : ':' + ; + +PLUS + : '+' + ; + +MINUS + : '-' + ; + +fragment DECIMAL_DIGIT + : [0-9] + ; + +fragment HEXADECIMAL_DIGIT + : [0-9a-fA-F] + ; + +fragment ESCAPE_SEQUENCE + : SIMPLE_ESCAPE_SEQUENCE + | HEXADECIMAL_ESCAPE_SEQUENCE + | UNICODE_ESCAPE_SEQUENCE ; -fragment -UNICODE_ESCAPE_SEQUENCE - : '\\u' HEXADECIMAL_DIGIT+ +fragment SIMPLE_ESCAPE_SEQUENCE + : '\\' ['"?bfnrtv\\/] + ; + +fragment HEXADECIMAL_ESCAPE_SEQUENCE + : '\\x' HEXADECIMAL_DIGIT+ + ; + +fragment UNICODE_ESCAPE_SEQUENCE + : '\\u' HEXADECIMAL_DIGIT+ ; STRING_CONSTANT - : '"' SCHAR_SEQUENCE? '"' + : '"' SCHAR_SEQUENCE? '"' ; -fragment -SCHAR_SEQUENCE - : SCHAR+ +fragment SCHAR_SEQUENCE + : SCHAR+ ; -fragment -SCHAR - : ~["\\\r\n] - | ESCAPE_SEQUENCE +fragment SCHAR + : ~["\\\r\n] + | ESCAPE_SEQUENCE ; -BASE_TYPE_NAME : 'bool' | 'byte' | 'ubyte' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'long' | 'ulong' | 'double' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'float32' | 'float64' | 'string' ; +BASE_TYPE_NAME + : 'bool' + | 'byte' + | 'ubyte' + | 'short' + | 'ushort' + | 'int' + | 'uint' + | 'float' + | 'long' + | 'ulong' + | 'double' + | 'int8' + | 'uint8' + | 'int16' + | 'uint16' + | 'int32' + | 'uint32' + | 'int64' + | 'uint64' + | 'float32' + | 'float64' + | 'string' + ; -INTEGER_CONSTANT : [-+]? DECIMAL_DIGIT+ | 'true' | 'false' ; +INTEGER_CONSTANT + : [-+]? DECIMAL_DIGIT+ + | 'true' + | 'false' + ; -IDENT : [a-zA-Z_] [a-zA-Z0-9_]* ; +IDENT + : [a-zA-Z_] [a-zA-Z0-9_]* + ; -HEX_INTEGER_CONSTANT : [-+]? '0' [xX] HEXADECIMAL_DIGIT+ ; +HEX_INTEGER_CONSTANT + : [-+]? '0' [xX] HEXADECIMAL_DIGIT+ + ; -FLOAT_CONSTANT : (PLUS|MINUS)? FLOATLIT ; +FLOAT_CONSTANT + : (PLUS | MINUS)? FLOATLIT + ; // Floating-point literals -fragment -FLOATLIT - : ( DECIMALS DOT DECIMALS? EXPONENT? - | DECIMALS EXPONENT - | DOT DECIMALS EXPONENT? - ) - | 'inf' - | 'nan' +fragment FLOATLIT + : (DECIMALS DOT DECIMALS? EXPONENT? | DECIMALS EXPONENT | DOT DECIMALS EXPONENT?) + | 'inf' + | 'nan' ; -fragment -DECIMALS - : DECIMAL_DIGIT+ +fragment DECIMALS + : DECIMAL_DIGIT+ ; -fragment -EXPONENT - : ('e' | 'E') (PLUS|MINUS)? DECIMALS +fragment EXPONENT + : ('e' | 'E') (PLUS | MINUS)? DECIMALS ; -BLOCK_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); +BLOCK_COMMENT + : '/*' .*? '*/' -> channel(HIDDEN) + ; // fixed original grammar: allow line comments -COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); +COMMENT + : '//' ~[\r\n]* -> channel(HIDDEN) + ; -WS : [ \t\r\n] -> skip ; +WS + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/flowmatic/flowmatic.g4 b/flowmatic/flowmatic.g4 index ac4a7dc39d..45790bef15 100644 --- a/flowmatic/flowmatic.g4 +++ b/flowmatic/flowmatic.g4 @@ -29,140 +29,160 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar flowmatic; flowmatic - : line* END EOF - ; + : line* END EOF + ; line - : label statement (';' statement)* '.' - ; + : label statement (';' statement)* '.' + ; label - : '(' NUM ')' - ; + : '(' NUM ')' + ; statement - : (closeout_statement | test_statement | set_statement | move_statement | compare_statement | otherwise_statement | stop_statement | rewind_statement | transfer_statement | writeitem_statement | jumpto_statement | readitem_statement | input_statement | hsp_statement | output_statement | if_statement)* - ; + : ( + closeout_statement + | test_statement + | set_statement + | move_statement + | compare_statement + | otherwise_statement + | stop_statement + | rewind_statement + | transfer_statement + | writeitem_statement + | jumpto_statement + | readitem_statement + | input_statement + | hsp_statement + | output_statement + | if_statement + )* + ; hsp_statement - : 'HSP' fileletter - ; + : 'HSP' fileletter + ; output_statement - : 'OUTPUT' (filename fileletter)+ - ; + : 'OUTPUT' (filename fileletter)+ + ; input_statement - : 'INPUT' (filename fileletter)+ - ; + : 'INPUT' (filename fileletter)+ + ; jumpto_statement - : 'JUMP' 'TO' operation - ; + : 'JUMP' 'TO' operation + ; readitem_statement - : 'READ-ITEM' fileletter - ; + : 'READ-ITEM' fileletter + ; writeitem_statement - : 'WRITE-ITEM' fileletter - ; + : 'WRITE-ITEM' fileletter + ; transfer_statement - : 'TRANSFER' fileletter 'TO' fileletter - ; + : 'TRANSFER' fileletter 'TO' fileletter + ; if_statement - : 'IF' op GOTO operation - ; + : 'IF' op GOTO operation + ; otherwise_statement - : 'OTHERWISE' GOTO operation - ; + : 'OTHERWISE' GOTO operation + ; rewind_statement - : 'REWIND' fileletter - ; + : 'REWIND' fileletter + ; stop_statement - : 'STOP' - ; + : 'STOP' + ; compare_statement - : 'COMPARE' fieldname '(' fileletter ')' 'WITH' fieldname '(' fileletter ')' - ; + : 'COMPARE' fieldname '(' fileletter ')' 'WITH' fieldname '(' fileletter ')' + ; move_statement - : 'MOVE' fieldname '(' fileletter ')' 'TO' fieldname '(' fileletter ')' - ; + : 'MOVE' fieldname '(' fileletter ')' 'TO' fieldname '(' fileletter ')' + ; set_statement - : 'SET' operation 'TO' GOTO operation - ; + : 'SET' operation 'TO' GOTO operation + ; test_statement - : 'TEST' fieldname '(' fileletter ')' 'AGAINST' num - ; + : 'TEST' fieldname '(' fileletter ')' 'AGAINST' num + ; closeout_statement - : 'CLOSE-OUT' 'FILES' fileletter (';' fileletter)* - ; + : 'CLOSE-OUT' 'FILES' fileletter (';' fileletter)* + ; num - : NUM - | ZERO - ; + : NUM + | ZERO + ; filename - : ID - ; + : ID + ; fileletter - : ID - ; + : ID + ; fieldname - : ID - ; + : ID + ; operation - : 'OPERATION' NUM - ; + : 'OPERATION' NUM + ; op - : 'EQUAL' - | 'GREATER' - | EOD - ; + : 'EQUAL' + | 'GREATER' + | EOD + ; END - : '(' 'END' ')' - ; + : '(' 'END' ')' + ; ZERO - : 'Z'+ - ; + : 'Z'+ + ; GOTO - : 'GO TO' - ; + : 'GO TO' + ; EOD - : 'END OF DATA' - ; + : 'END OF DATA' + ; ID - : [a-zA-Z-]+ - ; + : [a-zA-Z-]+ + ; NUM - : [0-9]+ - ; + : [0-9]+ + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/focal/focal.g4 b/focal/focal.g4 index 1506e3b3c8..16f5ba83e5 100644 --- a/focal/focal.g4 +++ b/focal/focal.g4 @@ -29,176 +29,179 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar focal; prog - : statement+ EOF - ; + : statement+ EOF + ; statement - : linenum command - ; + : linenum command + ; grpnum - : INTEGER - ; + : INTEGER + ; linenum - : grpnum '.' INTEGER - ; + : grpnum '.' INTEGER + ; command - : ask - | do_ - | for_ - | set_ - | quit - | goto_ - | if_ - | type_ - | return_ - | write_ - | comment - ; + : ask + | do_ + | for_ + | set_ + | quit + | goto_ + | if_ + | type_ + | return_ + | write_ + | comment + ; ask - : ('ASK' | 'A') askpair (',' askpair)* - ; + : ('ASK' | 'A') askpair (',' askpair)* + ; askpair - : STRING_LITERAL ',' VARIABLE (',' VARIABLE)* - ; + : STRING_LITERAL ',' VARIABLE (',' VARIABLE)* + ; do_ - : ('DO' | 'D') ('all' | grpnum | linenum) - ; + : ('DO' | 'D') ('all' | grpnum | linenum) + ; for_ - : ('FOR' | 'F') VARIABLE '=' expression ',' expression (',' expression)? ';' command - ; + : ('FOR' | 'F') VARIABLE '=' expression ',' expression (',' expression)? ';' command + ; quit - : 'QUIT' - ; + : 'QUIT' + ; set_ - : ('SET' | 'S') VARIABLE '=' expression (';' command)? - ; + : ('SET' | 'S') VARIABLE '=' expression (';' command)? + ; goto_ - : ('GOTO' | 'G') linenum? - ; + : ('GOTO' | 'G') linenum? + ; if_ - : ('IF') expression linenum (',' linenum) (',' linenum) (';' command)? - ; + : ('IF') expression linenum (',' linenum) (',' linenum) (';' command)? + ; type_ - : ('TYPE' | 'T') typeexpression (',' typeexpression)* (';' command)? - ; + : ('TYPE' | 'T') typeexpression (',' typeexpression)* (';' command)? + ; typeexpression - : expression - | '!'+ - | '#'+ - | STRING_LITERAL - | ('%' INTEGER '.' INTEGER) - ; + : expression + | '!'+ + | '#'+ + | STRING_LITERAL + | ('%' INTEGER '.' INTEGER) + ; return_ - : 'RETURN' - ; + : 'RETURN' + ; write_ - : 'WRITE' (grpnum | linenum)? - ; + : 'WRITE' (grpnum | linenum)? + ; comment - : COMMENT - ; + : COMMENT + ; expression - : primary (PLUSMIN primary)* - ; + : primary (PLUSMIN primary)* + ; primary - : term (MULOP term)* - ; + : term (MULOP term)* + ; term - : ('(' expression ')') - | ('[' expression ']') - | ('<' expression '>') - | number - | VARIABLE - | (VARIABLE '(' expression ')') - | (BUILTIN '(' expression ')') - ; + : ('(' expression ')') + | ('[' expression ']') + | ('<' expression '>') + | number + | VARIABLE + | (VARIABLE '(' expression ')') + | (BUILTIN '(' expression ')') + ; number - : mantissa ('e' signed_)? - ; + : mantissa ('e' signed_)? + ; mantissa - : signed_ - | (signed_ '.') - | ('.' signed_) - | (signed_ '.' signed_) - ; + : signed_ + | (signed_ '.') + | ('.' signed_) + | (signed_ '.' signed_) + ; signed_ - : PLUSMIN? INTEGER - ; + : PLUSMIN? INTEGER + ; PLUSMIN - : '+' - | '-' - ; + : '+' + | '-' + ; MULOP - : '*' - | '/' - | '^' - ; + : '*' + | '/' + | '^' + ; VARIABLE - : ALPHA (ALPHA | DIGIT)* - ; + : ALPHA (ALPHA | DIGIT)* + ; INTEGER - : DIGIT+ - ; + : DIGIT+ + ; ALPHA - : [A-Za-z] - ; + : [A-Za-z] + ; DIGIT - : [0-9] - ; + : [0-9] + ; BUILTIN - : 'fsin' - | 'fcos' - | 'fexp' - | 'flog' - | 'fatn' - | 'fsqt' - | 'fabs' - | 'fsgn' - | 'fitr' - | 'fran' - ; + : 'fsin' + | 'fcos' + | 'fexp' + | 'flog' + | 'fatn' + | 'fsqt' + | 'fabs' + | 'fsgn' + | 'fitr' + | 'fran' + ; STRING_LITERAL - : '"' .*? '"' - ; + : '"' .*? '"' + ; COMMENT - : 'COMMENT' ~ [\r\n]* - ; + : 'COMMENT' ~ [\r\n]* + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/fol/fol.g4 b/fol/fol.g4 index ffe3e353d4..29d239d086 100644 --- a/fol/fol.g4 +++ b/fol/fol.g4 @@ -3,93 +3,114 @@ * */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar fol; /*------------------------------------------------------------------ * PARSER RULES *------------------------------------------------------------------*/ - condition - :formula (ENDLINE formula)* ENDLINE* EOF - ; - formula - : formula bin_connective formula - | NOT formula bin_connective formula - | NOT formula - | FORALL LPAREN variable RPAREN formula - | EXISTS LPAREN variable RPAREN formula - | pred_constant LPAREN term (separator term)* RPAREN - | term EQUAL term - ; +condition + : formula (ENDLINE formula)* ENDLINE* EOF + ; + +formula + : formula bin_connective formula + | NOT formula bin_connective formula + | NOT formula + | FORALL LPAREN variable RPAREN formula + | EXISTS LPAREN variable RPAREN formula + | pred_constant LPAREN term (separator term)* RPAREN + | term EQUAL term + ; term - : ind_constant - | variable - | func_constant LPAREN term (separator term)* RPAREN - ; + : ind_constant + | variable + | func_constant LPAREN term (separator term)* RPAREN + ; bin_connective - : CONJ - | DISJ - | IMPL - | BICOND - ; + : CONJ + | DISJ + | IMPL + | BICOND + ; + //used in FORALL|EXISTS and following predicates variable - : '?'CHARACTER* - ; + : '?' CHARACTER* + ; + //predicate constant - np. _isProfesor(?x) pred_constant - : '_'CHARACTER* - ; + : '_' CHARACTER* + ; + //individual constant - used in single predicates ind_constant - :'#'CHARACTER* - ; + : '#' CHARACTER* + ; + //used to create functions, np. .presidentOf(?America) = #Trump func_constant - :'.'CHARACTER* - ; + : '.' CHARACTER* + ; LPAREN - :'(' - ; + : '(' + ; + RPAREN - :')' - ; + : ')' + ; + separator - :',' - ; + : ',' + ; + EQUAL - :'=' - ; + : '=' + ; + NOT - :'!' - ; + : '!' + ; + FORALL - :'Forall' - ; + : 'Forall' + ; + EXISTS - :'Exists' - ; + : 'Exists' + ; + CHARACTER - :('0' .. '9' | 'a' .. 'z' | 'A' .. 'Z') - ; + : ('0' .. '9' | 'a' .. 'z' | 'A' .. 'Z') + ; + CONJ - :'\\/' - ; + : '\\/' + ; + DISJ - :'^' - ; + : '^' + ; + IMPL - :'->' - ; + : '->' + ; + BICOND - :'<->' - ; + : '<->' + ; + ENDLINE - :('\r'|'\n')+ - ; + : ('\r' | '\n')+ + ; + WHITESPACE - :(' '|'\t')+->skip - ; \ No newline at end of file + : (' ' | '\t')+ -> skip + ; \ No newline at end of file diff --git a/fortran/fortran77/Fortran77Lexer.g4 b/fortran/fortran77/Fortran77Lexer.g4 index ea3740fb2b..91e9acc8a0 100644 --- a/fortran/fortran77/Fortran77Lexer.g4 +++ b/fortran/fortran77/Fortran77Lexer.g4 @@ -26,653 +26,285 @@ /* * Updated by Tom Everett, 2018 */ -lexer grammar Fortran77Lexer; - -options { superClass = Fortran77LexerBase; } - -// Insert here @header for C++ lexer. - -PROGRAM - : 'program' | 'PROGRAM' - ; - - -ENTRY - : 'entry' | 'ENTRY' - ; - - -FUNCTION - : 'function' | 'FUNCTION' - ; - - -BLOCK - : 'block' | 'BLOCK' - ; - - -SUBROUTINE - : 'subroutine' | 'SUBROUTINE' - ; - - -END - : 'END' | 'end' - ; - - -DIMENSION - : 'dimension' | 'DIMENSION' - ; - - -REAL - : 'REAL' | 'real' - ; - - -EQUIVALENCE - : 'EQUIVALENCE' | 'equivalence' - ; - - -COMMON - : 'common' | 'COMMON' - ; - - -POINTER - : 'pointer' | 'POINTER' - ; - - -IMPLICIT - : 'implicit' | 'IMPLICIT' - ; - - -NONE - : 'none' | 'NONE' - ; - - -CHARACTER - : 'character' | 'CHARACTER' - ; - - -PARAMETER - : 'parameter' | 'PARAMETER' - ; - - -EXTERNAL - : 'external' | 'EXTERNAL' - ; - - -INTRINSIC - : 'intrinsic' | 'INTRINSIC' - ; - - -SAVE - : 'save' | 'SAVE' - ; - - -DATA - : 'data' | 'DATA' - ; - - -GO - : 'GO' | 'go' - ; - - -GOTO - : 'GOTO' | 'goto' - ; - - -IF - : 'IF' | 'if' - ; - - -THEN - : 'THEN' | 'then' - ; - - -ELSE - : 'ELSE' | 'else' - ; - - -ENDIF - : 'ENDIF' | 'endif' - ; - - -ELSEIF - : 'ELSEIF' | 'elseif' - ; - - -DO - : 'DO' | 'do' - ; - - -CONTINUE - : 'CONTINUE' | 'continue' - ; - - -STOP - : 'STOP' | 'stop' - ; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -ENDDO - : 'ENDDO' | 'enddo' - ; - - -PAUSE - : 'pause' | 'PAUSE' - ; - - -WRITE - : 'WRITE' | 'write' - ; - - -READ - : 'READ' | 'read' - ; - - -PRINT - : 'PRINT' | 'print' - ; - - -OPEN - : 'OPEN' | 'open' - ; - - -FMT - : 'FMT' | 'fmt' - ; - - -UNIT - : 'UNIT' | 'unit' - ; - - -ERR - : 'err' | 'ERR' - ; - - -IOSTAT - : 'IOSTAT' | 'iostat' - ; - - -FORMAT - : 'FORMAT' | 'format' - ; - - -LET - : 'LET' | 'let' - ; - - -CALL - : 'CALL' | 'call' - ; - - -RETURN - : 'RETURN' | 'return' - ; - - -CLOSE - : 'CLOSE' | 'close' - ; - - -DOUBLE - : 'DOUBLE' | 'double' - ; - - -IOSTART - : 'IOSTART' | 'iostart' - ; - - -SEQUENTIAL - : 'SEQUENTIAL' | 'sequential' - ; - - -LABEL - : 'LABEL' | 'label' - ; - - -FILE - : 'file' | 'FILE' - ; - - -STATUS - : 'STATUS' | 'status' - ; - - -ACCESS - : 'ACCESS' | 'access' - ; - - -POSITION - : 'POSITION' | 'position' - ; - - -FORM - : 'FORM' | 'form' - ; - - -RECL - : 'RECL' | 'recl' - ; - - -BLANK - : 'BLANK' | 'blank' - ; - - -EXIST - : 'EXIST' | 'exist' - ; - - -OPENED - : 'OPENED' | 'opened' - ; - - -NUMBER - : 'NUMBER' | 'number' - ; - - -NAMED - : 'NAMED' | 'named' - ; +lexer grammar Fortran77Lexer; +options { + superClass = Fortran77LexerBase; +} -NAME_ - : 'NAME' | 'name' - ; +// Insert here @header for C++ lexer. +PROGRAM: 'program' | 'PROGRAM'; -FORMATTED - : 'FORMATTED' | 'formatted' - ; +ENTRY: 'entry' | 'ENTRY'; +FUNCTION: 'function' | 'FUNCTION'; -UNFORMATTED - : 'UNFORMATTED' | 'unformatted' - ; +BLOCK: 'block' | 'BLOCK'; +SUBROUTINE: 'subroutine' | 'SUBROUTINE'; -NEXTREC - : 'NEXTREC' | 'nextrec' - ; +END: 'END' | 'end'; +DIMENSION: 'dimension' | 'DIMENSION'; -INQUIRE - : 'INQUIRE' | 'inquire' - ; +REAL: 'REAL' | 'real'; +EQUIVALENCE: 'EQUIVALENCE' | 'equivalence'; -BACKSPACE - : 'BACKSPACE' | 'backspace' - ; +COMMON: 'common' | 'COMMON'; +POINTER: 'pointer' | 'POINTER'; -ENDFILE - : 'ENDFILE' | 'endfile' - ; +IMPLICIT: 'implicit' | 'IMPLICIT'; +NONE: 'none' | 'NONE'; -REWIND - : 'REWIND' | 'rewind' - ; +CHARACTER: 'character' | 'CHARACTER'; +PARAMETER: 'parameter' | 'PARAMETER'; -DOLLAR - : '$' - ; +EXTERNAL: 'external' | 'EXTERNAL'; +INTRINSIC: 'intrinsic' | 'INTRINSIC'; -COMMA - : ',' - ; +SAVE: 'save' | 'SAVE'; +DATA: 'data' | 'DATA'; -LPAREN - : '(' - ; +GO: 'GO' | 'go'; +GOTO: 'GOTO' | 'goto'; -RPAREN - : ')' - ; +IF: 'IF' | 'if'; +THEN: 'THEN' | 'then'; -COLON - : ':' - ; +ELSE: 'ELSE' | 'else'; +ENDIF: 'ENDIF' | 'endif'; -ASSIGN - : '=' - ; +ELSEIF: 'ELSEIF' | 'elseif'; +DO: 'DO' | 'do'; -MINUS - : '-' - ; +CONTINUE: 'CONTINUE' | 'continue'; +STOP: 'STOP' | 'stop'; -PLUS - : '+' - ; +ENDDO: 'ENDDO' | 'enddo'; +PAUSE: 'pause' | 'PAUSE'; -DIV - : '/' - ; +WRITE: 'WRITE' | 'write'; -fragment STARCHAR - : '*' - ; +READ: 'READ' | 'read'; +PRINT: 'PRINT' | 'print'; +OPEN: 'OPEN' | 'open'; -POWER - : '**' - ; +FMT: 'FMT' | 'fmt'; +UNIT: 'UNIT' | 'unit'; -LNOT - : '.not.' | '.NOT.' - ; +ERR: 'err' | 'ERR'; +IOSTAT: 'IOSTAT' | 'iostat'; -LAND - : '.and.' | '.AND.' - ; +FORMAT: 'FORMAT' | 'format'; +LET: 'LET' | 'let'; -LOR - : '.or.' | '.OR.' - ; +CALL: 'CALL' | 'call'; +RETURN: 'RETURN' | 'return'; -EQV - : '.eqv.' | '.EQV.' - ; +CLOSE: 'CLOSE' | 'close'; +DOUBLE: 'DOUBLE' | 'double'; -NEQV - : '.neqv.' | '.NEQV.' - ; +IOSTART: 'IOSTART' | 'iostart'; +SEQUENTIAL: 'SEQUENTIAL' | 'sequential'; -XOR - : '.xor.' | '.XOR.' - ; +LABEL: 'LABEL' | 'label'; +FILE: 'file' | 'FILE'; -EOR - : '.eor.' | '.EOR.' - ; +STATUS: 'STATUS' | 'status'; +ACCESS: 'ACCESS' | 'access'; -LT - : '.lt.' | '.LT.' - ; +POSITION: 'POSITION' | 'position'; +FORM: 'FORM' | 'form'; -LE - : '.le.' | '.LE.' - ; +RECL: 'RECL' | 'recl'; +BLANK: 'BLANK' | 'blank'; -GT - : '.gt.' | '.GT.' - ; +EXIST: 'EXIST' | 'exist'; +OPENED: 'OPENED' | 'opened'; -GE - : '.ge.' | '.GE.' - ; +NUMBER: 'NUMBER' | 'number'; +NAMED: 'NAMED' | 'named'; -NE - : '.ne.' | '.NE.' - ; +NAME_: 'NAME' | 'name'; +FORMATTED: 'FORMATTED' | 'formatted'; -EQ - : '.eq.' | '.EQ.' - ; +UNFORMATTED: 'UNFORMATTED' | 'unformatted'; +NEXTREC: 'NEXTREC' | 'nextrec'; -TRUE - : '.true.' | '.TRUE.' - ; +INQUIRE: 'INQUIRE' | 'inquire'; +BACKSPACE: 'BACKSPACE' | 'backspace'; -FALSE - : '.false.' | '.FALSE.' - ; +ENDFILE: 'ENDFILE' | 'endfile'; +REWIND: 'REWIND' | 'rewind'; -XCON - : 'XCON' - ; +DOLLAR: '$'; +COMMA: ','; -PCON - : 'PCON' - ; +LPAREN: '('; +RPAREN: ')'; -FCON - : 'FCON' - ; +COLON: ':'; +ASSIGN: '='; -CCON - : 'CCON' - ; +MINUS: '-'; +PLUS: '+'; -HOLLERITH - : 'HOLLERITH' - ; +DIV: '/'; +fragment STARCHAR: '*'; -CONCATOP - : 'CONCATOP' - ; +POWER: '**'; +LNOT: '.not.' | '.NOT.'; -CTRLDIRECT - : 'CTRLDIRECT' - ; +LAND: '.and.' | '.AND.'; +LOR: '.or.' | '.OR.'; -CTRLREC - : 'CTRLREC' - ; +EQV: '.eqv.' | '.EQV.'; +NEQV: '.neqv.' | '.NEQV.'; -TO - : 'TO' | 'to' - ; +XOR: '.xor.' | '.XOR.'; +EOR: '.eor.' | '.EOR.'; -SUBPROGRAMBLOCK - : 'SUBPROGRAMBLOCK' - ; +LT: '.lt.' | '.LT.'; +LE: '.le.' | '.LE.'; -DOBLOCK - : 'DOBLOCK' - ; +GT: '.gt.' | '.GT.'; +GE: '.ge.' | '.GE.'; -AIF - : 'AIF' - ; +NE: '.ne.' | '.NE.'; +EQ: '.eq.' | '.EQ.'; -THENBLOCK - : 'THENBLOCK' - ; +TRUE: '.true.' | '.TRUE.'; +FALSE: '.false.' | '.FALSE.'; -ELSEBLOCK - : 'ELSEBLOCK' - ; +XCON: 'XCON'; +PCON: 'PCON'; -CODEROOT - : 'CODEROOT' - ; +FCON: 'FCON'; +CCON: 'CCON'; -COMPLEX - : 'COMPLEX' | 'complex' - ; +HOLLERITH: 'HOLLERITH'; +CONCATOP: 'CONCATOP'; -PRECISION - : 'PRECISION' | 'precision' - ; +CTRLDIRECT: 'CTRLDIRECT'; +CTRLREC: 'CTRLREC'; -INTEGER - : 'INTEGER' | 'integer' - ; +TO: 'TO' | 'to'; +SUBPROGRAMBLOCK: 'SUBPROGRAMBLOCK'; -LOGICAL - : 'LOGICAL' | 'logical' - ; +DOBLOCK: 'DOBLOCK'; +AIF: 'AIF'; -fragment CONTINUATION - : ~ ('0' | ' ') - ; +THENBLOCK: 'THENBLOCK'; +ELSEBLOCK: 'ELSEBLOCK'; -fragment ALNUM - : (ALPHA | NUM) - ; +CODEROOT: 'CODEROOT'; +COMPLEX: 'COMPLEX' | 'complex'; -fragment HEX - : (NUM | 'a' .. 'f') - ; +PRECISION: 'PRECISION' | 'precision'; +INTEGER: 'INTEGER' | 'integer'; -fragment SIGN - : ('+' | '-') - ; +LOGICAL: 'LOGICAL' | 'logical'; +fragment CONTINUATION: ~ ('0' | ' '); -fragment FDESC - : ('i' | 'f' | 'd') (NUM) + '.' (NUM) + | ('e' | 'g') (NUM) + '.' (NUM) + ('e' (NUM) +)? - ; +fragment ALNUM: (ALPHA | NUM); +fragment HEX: (NUM | 'a' .. 'f'); -fragment EXPON - : ('e' | 'E' | 'd' | 'D') (SIGN)? (NUM) + - ; +fragment SIGN: ('+' | '-'); +fragment FDESC: ('i' | 'f' | 'd') (NUM)+ '.' (NUM)+ | ('e' | 'g') (NUM)+ '.' (NUM)+ ('e' (NUM)+)?; -fragment ALPHA - : ('a' .. 'z') | ('A' .. 'Z') - ; +fragment EXPON: ('e' | 'E' | 'd' | 'D') (SIGN)? (NUM)+; +fragment ALPHA: ('a' .. 'z') | ('A' .. 'Z'); -fragment NUM - : ('0' .. '9') - ; +fragment NUM: ('0' .. '9'); // '' is used to drop the charater when forming the lexical token // Strings are assumed to start with a single quote (') and two // single quotes is meant as a literal single quote -SCON - : '\'' ('\'' '\'' | ~ ('\'' | '\n' | '\r') | (('\n' | '\r' ('\n')?) ' ' CONTINUATION) ('\n' | '\r' ('\n')?) ' ' CONTINUATION)* '\'' - ; - -RCON - : NUM+ '.' NUM* EXPON? - ; +SCON: + '\'' ( + '\'' '\'' + | ~ ('\'' | '\n' | '\r') + | (('\n' | '\r' ('\n')?) ' ' CONTINUATION) ('\n' | '\r' ('\n')?) ' ' CONTINUATION + )* '\'' +; -ICON - : NUM+ - ; +RCON: NUM+ '.' NUM* EXPON?; -NAME - : (('i' | 'f' | 'd' | 'g' | 'e') (NUM) + '.') FDESC | (ALNUM +) (ALNUM)* - ; +ICON: NUM+; +NAME: (('i' | 'f' | 'd' | 'g' | 'e') (NUM)+ '.') FDESC | (ALNUM+) (ALNUM)*; -COMMENT - : {this.IsColumnZero()}? ('c' | STARCHAR) (~ [\r\n])* EOL -> channel(HIDDEN) - ; +COMMENT: {this.IsColumnZero()}? ('c' | STARCHAR) (~ [\r\n])* EOL -> channel(HIDDEN); -STAR - : STARCHAR - ; +STAR: STARCHAR; +STRINGLITERAL: '"' ~ ["\r\n]* '"'; -STRINGLITERAL - : '"' ~ ["\r\n]* '"' - ; +EOL: [\r\n]+; -EOL - : [\r\n] + - ; +LINECONT: ((EOL ' $') | (EOL ' +')) -> skip; -LINECONT - : ((EOL ' $') | (EOL ' +')) -> skip - ; - -WS - : [\t ] + -> skip - ; +WS: [\t ]+ -> skip; \ No newline at end of file diff --git a/fortran/fortran77/Fortran77Parser.g4 b/fortran/fortran77/Fortran77Parser.g4 index 13d9e3ece7..cd3b66f573 100644 --- a/fortran/fortran77/Fortran77Parser.g4 +++ b/fortran/fortran77/Fortran77Parser.g4 @@ -26,854 +26,910 @@ /* * Updated by Tom Everett, 2018 */ + +// $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 Fortran77Parser; options - { tokenVocab = Fortran77Lexer; } + { + tokenVocab = Fortran77Lexer; +} program - : executableUnit+ EOL* EOF - ; + : executableUnit+ EOL* EOF + ; executableUnit - : functionSubprogram - | mainProgram - | subroutineSubprogram - | blockdataSubprogram - ; + : functionSubprogram + | mainProgram + | subroutineSubprogram + | blockdataSubprogram + ; mainProgram - : (programStatement)? subprogramBody - ; + : (programStatement)? subprogramBody + ; functionSubprogram - : functionStatement subprogramBody - ; + : functionStatement subprogramBody + ; subroutineSubprogram - : subroutineStatement subprogramBody - ; + : subroutineStatement subprogramBody + ; blockdataSubprogram - : blockdataStatement subprogramBody - ; + : blockdataStatement subprogramBody + ; otherSpecificationStatement - : dimensionStatement - | equivalenceStatement - | intrinsicStatement - | saveStatement - ; + : dimensionStatement + | equivalenceStatement + | intrinsicStatement + | saveStatement + ; executableStatement - : (assignmentStatement | gotoStatement | ifStatement | doStatement | continueStatement | stopStatement | pauseStatement | readStatement | writeStatement | printStatement | rewindStatement | backspaceStatement | openStatement | closeStatement | endfileStatement | inquireStatement | callStatement | returnStatement) - ; + : ( + assignmentStatement + | gotoStatement + | ifStatement + | doStatement + | continueStatement + | stopStatement + | pauseStatement + | readStatement + | writeStatement + | printStatement + | rewindStatement + | backspaceStatement + | openStatement + | closeStatement + | endfileStatement + | inquireStatement + | callStatement + | returnStatement + ) + ; programStatement - : PROGRAM NAME EOL - ; + : PROGRAM NAME EOL + ; entryStatement - : ENTRY NAME (LPAREN namelist RPAREN)? - ; + : ENTRY NAME (LPAREN namelist RPAREN)? + ; functionStatement - : type_? FUNCTION NAME LPAREN namelist? RPAREN EOL? - ; + : type_? FUNCTION NAME LPAREN namelist? RPAREN EOL? + ; blockdataStatement - : BLOCK NAME - ; + : BLOCK NAME + ; subroutineStatement - : SUBROUTINE NAME (LPAREN namelist? RPAREN)? EOL? - ; + : SUBROUTINE NAME (LPAREN namelist? RPAREN)? EOL? + ; namelist - : identifier (COMMA identifier)* - ; + : identifier (COMMA identifier)* + ; statement - : entryStatement - | implicitStatement - | parameterStatement - | typeStatement - | commonStatement - | pointerStatement - | externalStatement - | otherSpecificationStatement - | dataStatement - | (statementFunctionStatement) statementFunctionStatement - | executableStatement - ; + : entryStatement + | implicitStatement + | parameterStatement + | typeStatement + | commonStatement + | pointerStatement + | externalStatement + | otherSpecificationStatement + | dataStatement + | (statementFunctionStatement) statementFunctionStatement + | executableStatement + ; subprogramBody - : wholeStatement+ endStatement - ; + : wholeStatement+ endStatement + ; wholeStatement - : LABEL? statement EOL - ; - + : LABEL? statement EOL + ; + endStatement - : LABEL? END - ; + : LABEL? END + ; dimensionStatement - : DIMENSION arrayDeclarators - ; + : DIMENSION arrayDeclarators + ; arrayDeclarator - : (NAME | REAL) LPAREN arrayDeclaratorExtents RPAREN - ; + : (NAME | REAL) LPAREN arrayDeclaratorExtents RPAREN + ; arrayDeclarators - : arrayDeclarator (COMMA arrayDeclarator)* - ; + : arrayDeclarator (COMMA arrayDeclarator)* + ; arrayDeclaratorExtents - : arrayDeclaratorExtent (COMMA arrayDeclaratorExtent)* - ; + : arrayDeclaratorExtent (COMMA arrayDeclaratorExtent)* + ; arrayDeclaratorExtent - : iexprCode (COLON (iexprCode | STAR))? - | STAR - ; + : iexprCode (COLON (iexprCode | STAR))? + | STAR + ; equivalenceStatement - : EQUIVALENCE equivEntityGroup (COMMA equivEntityGroup)* - ; + : EQUIVALENCE equivEntityGroup (COMMA equivEntityGroup)* + ; equivEntityGroup - : LPAREN equivEntity (COMMA equivEntity)* RPAREN - ; + : LPAREN equivEntity (COMMA equivEntity)* RPAREN + ; equivEntity - : varRef - ; + : varRef + ; commonStatement - : COMMON (commonBlock (COMMA commonBlock)* | commonItems) - ; + : COMMON (commonBlock (COMMA commonBlock)* | commonItems) + ; commonName - : DIV (NAME DIV | DIV) - ; + : DIV (NAME DIV | DIV) + ; commonItem - : NAME - | arrayDeclarator - ; + : NAME + | arrayDeclarator + ; commonItems - : commonItem (COMMA commonItem)* - ; + : commonItem (COMMA commonItem)* + ; commonBlock - : commonName commonItems - ; + : commonName commonItems + ; typeStatement - : typename_ typeStatementNameList - | characterWithLen typeStatementNameCharList - ; + : typename_ typeStatementNameList + | characterWithLen typeStatementNameCharList + ; typeStatementNameList - : typeStatementName (COMMA typeStatementName)* - ; + : typeStatementName (COMMA typeStatementName)* + ; typeStatementName - : NAME - | arrayDeclarator - ; + : NAME + | arrayDeclarator + ; typeStatementNameCharList - : typeStatementNameChar (COMMA typeStatementNameChar)* - ; + : typeStatementNameChar (COMMA typeStatementNameChar)* + ; typeStatementNameChar - : typeStatementName (typeStatementLenSpec)? - ; + : typeStatementName (typeStatementLenSpec)? + ; typeStatementLenSpec - : STAR lenSpecification - ; + : STAR lenSpecification + ; typename_ - : (REAL | COMPLEX (STAR ICON?)? | DOUBLE COMPLEX | DOUBLE PRECISION | INTEGER | LOGICAL | CHARACTER) - ; + : ( + REAL + | COMPLEX (STAR ICON?)? + | DOUBLE COMPLEX + | DOUBLE PRECISION + | INTEGER + | LOGICAL + | CHARACTER + ) + ; type_ - : typename_ - | characterWithLen - ; + : typename_ + | characterWithLen + ; typenameLen - : STAR ICON - ; + : STAR ICON + ; pointerStatement - : POINTER pointerDecl (COMMA pointerDecl)* - ; + : POINTER pointerDecl (COMMA pointerDecl)* + ; pointerDecl - : LPAREN NAME COMMA NAME RPAREN - ; + : LPAREN NAME COMMA NAME RPAREN + ; implicitStatement - : IMPLICIT (implicitNone | implicitSpecs) - ; + : IMPLICIT (implicitNone | implicitSpecs) + ; implicitSpec - : type_ LPAREN implicitLetters RPAREN - ; + : type_ LPAREN implicitLetters RPAREN + ; implicitSpecs - : implicitSpec (COMMA implicitSpec)* - ; + : implicitSpec (COMMA implicitSpec)* + ; implicitNone - : NONE - ; + : NONE + ; implicitLetter - : NAME - ; + : NAME + ; implicitRange - : implicitLetter (MINUS implicitLetter)? - ; + : implicitLetter (MINUS implicitLetter)? + ; implicitLetters - : implicitRange (COMMA implicitRange)* - ; + : implicitRange (COMMA implicitRange)* + ; lenSpecification - : (LPAREN STAR RPAREN) LPAREN STAR RPAREN - | ICON - | LPAREN intConstantExpr RPAREN - ; + : (LPAREN STAR RPAREN) LPAREN STAR RPAREN + | ICON + | LPAREN intConstantExpr RPAREN + ; characterWithLen - : characterExpression (cwlLen)? - ; + : characterExpression (cwlLen)? + ; cwlLen - : STAR lenSpecification - ; + : STAR lenSpecification + ; parameterStatement - : PARAMETER LPAREN paramlist RPAREN - ; + : PARAMETER LPAREN paramlist RPAREN + ; paramlist - : paramassign (COMMA paramassign)* - ; + : paramassign (COMMA paramassign)* + ; paramassign - : NAME ASSIGN constantExpr - ; + : NAME ASSIGN constantExpr + ; externalStatement - : EXTERNAL namelist - ; + : EXTERNAL namelist + ; intrinsicStatement - : INTRINSIC namelist - ; + : INTRINSIC namelist + ; saveStatement - : SAVE (saveEntity (COMMA saveEntity)*)? - ; + : SAVE (saveEntity (COMMA saveEntity)*)? + ; saveEntity - : (NAME | DIV NAME DIV) - ; + : (NAME | DIV NAME DIV) + ; dataStatement - : DATA dataStatementEntity ((COMMA)? dataStatementEntity)* - ; + : DATA dataStatementEntity ((COMMA)? dataStatementEntity)* + ; dataStatementItem - : varRef - | dataImpliedDo - ; + : varRef + | dataImpliedDo + ; dataStatementMultiple - : ((ICON | NAME) STAR)? (constant | NAME) - ; + : ((ICON | NAME) STAR)? (constant | NAME) + ; dataStatementEntity - : dse1 dse2 - ; + : dse1 dse2 + ; dse1 - : dataStatementItem (COMMA dataStatementItem)* DIV - ; + : dataStatementItem (COMMA dataStatementItem)* DIV + ; dse2 - : dataStatementMultiple (COMMA dataStatementMultiple)* DIV - ; + : dataStatementMultiple (COMMA dataStatementMultiple)* DIV + ; dataImpliedDo - : LPAREN dataImpliedDoList COMMA dataImpliedDoRange RPAREN - ; + : LPAREN dataImpliedDoList COMMA dataImpliedDoRange RPAREN + ; dataImpliedDoRange - : NAME ASSIGN intConstantExpr COMMA intConstantExpr (COMMA intConstantExpr)? - ; + : NAME ASSIGN intConstantExpr COMMA intConstantExpr (COMMA intConstantExpr)? + ; dataImpliedDoList - : dataImpliedDoListWhat - | COMMA dataImpliedDoList - ; + : dataImpliedDoListWhat + | COMMA dataImpliedDoList + ; dataImpliedDoListWhat - : (varRef | dataImpliedDo) - ; + : (varRef | dataImpliedDo) + ; gotoStatement - : (GO TO| GOTO) (unconditionalGoto | computedGoto | assignedGoto) - ; + : (GO TO | GOTO) (unconditionalGoto | computedGoto | assignedGoto) + ; unconditionalGoto - : lblRef - ; + : lblRef + ; computedGoto - : LPAREN labelList RPAREN (COMMA)? integerExpr - ; + : LPAREN labelList RPAREN (COMMA)? integerExpr + ; lblRef - : ICON - ; + : ICON + ; labelList - : lblRef (COMMA lblRef)* - ; + : lblRef (COMMA lblRef)* + ; assignedGoto - : NAME ((COMMA)? LPAREN labelList RPAREN)? - ; + : NAME ((COMMA)? LPAREN labelList RPAREN)? + ; ifStatement - : IF LPAREN logicalExpression RPAREN (blockIfStatement | logicalIfStatement | arithmeticIfStatement) - ; + : IF LPAREN logicalExpression RPAREN ( + blockIfStatement + | logicalIfStatement + | arithmeticIfStatement + ) + ; arithmeticIfStatement - : lblRef COMMA lblRef COMMA lblRef - ; + : lblRef COMMA lblRef COMMA lblRef + ; logicalIfStatement - : executableStatement - ; + : executableStatement + ; blockIfStatement - : firstIfBlock elseIfStatement* elseStatement? endIfStatement - ; + : firstIfBlock elseIfStatement* elseStatement? endIfStatement + ; firstIfBlock - : THEN EOL? wholeStatement+ - ; + : THEN EOL? wholeStatement+ + ; elseIfStatement - : (ELSEIF | (ELSE IF)) LPAREN logicalExpression RPAREN THEN EOL? wholeStatement+ - ; + : (ELSEIF | (ELSE IF)) LPAREN logicalExpression RPAREN THEN EOL? wholeStatement+ + ; elseStatement - : ELSE EOL? wholeStatement+ - ; + : ELSE EOL? wholeStatement+ + ; endIfStatement - : (ENDIF | END IF) - ; + : (ENDIF | END IF) + ; doStatement - : DO (doWithLabel | doWithEndDo) - ; + : DO (doWithLabel | doWithEndDo) + ; doVarArgs - : variableName ASSIGN intRealDpExpr COMMA intRealDpExpr (COMMA intRealDpExpr)? - ; + : variableName ASSIGN intRealDpExpr COMMA intRealDpExpr (COMMA intRealDpExpr)? + ; doWithLabel - : lblRef COMMA? doVarArgs EOL? doBody EOL? continueStatement - ; + : lblRef COMMA? doVarArgs EOL? doBody EOL? continueStatement + ; doBody - : (wholeStatement) + - ; + : (wholeStatement)+ + ; doWithEndDo - : doVarArgs EOL? doBody EOL? enddoStatement - ; + : doVarArgs EOL? doBody EOL? enddoStatement + ; enddoStatement - : (ENDDO | (END DO)) - ; + : (ENDDO | (END DO)) + ; continueStatement - : lblRef? CONTINUE - ; + : lblRef? CONTINUE + ; stopStatement - : STOP (ICON | HOLLERITH)? - ; + : STOP (ICON | HOLLERITH)? + ; pauseStatement - : PAUSE (ICON | HOLLERITH) - ; + : PAUSE (ICON | HOLLERITH) + ; writeStatement - : WRITE LPAREN controlInfoList RPAREN ((COMMA? ioList) +)? - ; + : WRITE LPAREN controlInfoList RPAREN ((COMMA? ioList)+)? + ; readStatement - : READ (formatIdentifier ((COMMA ioList) +)?) - ; + : READ (formatIdentifier ((COMMA ioList)+)?) + ; printStatement - : PRINT (formatIdentifier ((COMMA ioList) +)?) - ; + : PRINT (formatIdentifier ((COMMA ioList)+)?) + ; assignmentStatement - : varRef ASSIGN expression - ; + : varRef ASSIGN expression + ; controlInfoList - : controlInfoListItem (COMMA controlInfoListItem)* - ; + : controlInfoListItem (COMMA controlInfoListItem)* + ; controlErrSpec - : controlErr ASSIGN (lblRef | NAME) - ; + : controlErr ASSIGN (lblRef | NAME) + ; controlInfoListItem - : unitIdentifier - | (HOLLERITH | SCON) - | controlFmt ASSIGN formatIdentifier - | controlUnit ASSIGN unitIdentifier - | controlRec ASSIGN integerExpr - | controlEnd ASSIGN lblRef - | controlErrSpec - | controlIostat ASSIGN varRef - ; + : unitIdentifier + | (HOLLERITH | SCON) + | controlFmt ASSIGN formatIdentifier + | controlUnit ASSIGN unitIdentifier + | controlRec ASSIGN integerExpr + | controlEnd ASSIGN lblRef + | controlErrSpec + | controlIostat ASSIGN varRef + ; ioList - : (ioListItem COMMA NAME ASSIGN) ioListItem - | (ioListItem COMMA ioListItem) ioListItem COMMA ioList - | ioListItem - ; + : (ioListItem COMMA NAME ASSIGN) ioListItem + | (ioListItem COMMA ioListItem) ioListItem COMMA ioList + | ioListItem + ; ioListItem - : (LPAREN ioList COMMA NAME ASSIGN) ioImpliedDoList - | expression - ; + : (LPAREN ioList COMMA NAME ASSIGN) ioImpliedDoList + | expression + ; ioImpliedDoList - : LPAREN ioList COMMA NAME ASSIGN intRealDpExpr COMMA intRealDpExpr (COMMA intRealDpExpr)? RPAREN - ; + : LPAREN ioList COMMA NAME ASSIGN intRealDpExpr COMMA intRealDpExpr (COMMA intRealDpExpr)? RPAREN + ; openStatement - : OPEN LPAREN openControl (COMMA openControl)* RPAREN - ; + : OPEN LPAREN openControl (COMMA openControl)* RPAREN + ; openControl - : unitIdentifier - | controlUnit ASSIGN unitIdentifier - | controlErrSpec - | controlFile ASSIGN characterExpression - | controlStatus ASSIGN characterExpression - | (controlAccess | controlPosition) ASSIGN characterExpression - | controlForm ASSIGN characterExpression - | controlRecl ASSIGN integerExpr - | controlBlank ASSIGN characterExpression - | controlIostat ASSIGN varRef - ; + : unitIdentifier + | controlUnit ASSIGN unitIdentifier + | controlErrSpec + | controlFile ASSIGN characterExpression + | controlStatus ASSIGN characterExpression + | (controlAccess | controlPosition) ASSIGN characterExpression + | controlForm ASSIGN characterExpression + | controlRecl ASSIGN integerExpr + | controlBlank ASSIGN characterExpression + | controlIostat ASSIGN varRef + ; controlFmt - : FMT - ; + : FMT + ; controlUnit - : UNIT - ; + : UNIT + ; controlRec - : NAME - ; + : NAME + ; controlEnd - : END - ; + : END + ; controlErr - : ERR - ; + : ERR + ; controlIostat - : IOSTART - ; + : IOSTART + ; controlFile - : FILE - ; + : FILE + ; controlStatus - : STATUS - ; + : STATUS + ; controlAccess - : ACCESS - ; + : ACCESS + ; controlPosition - : POSITION - ; + : POSITION + ; controlForm - : FORM - ; + : FORM + ; controlRecl - : RECL - ; + : RECL + ; controlBlank - : BLANK - ; + : BLANK + ; controlExist - : EXIST - ; + : EXIST + ; controlOpened - : OPENED - ; + : OPENED + ; controlNumber - : NUMBER - ; + : NUMBER + ; controlNamed - : NAMED - ; + : NAMED + ; controlName - : NAME - ; + : NAME + ; controlSequential - : SEQUENTIAL - ; + : SEQUENTIAL + ; controlDirect - : NAME - ; + : NAME + ; controlFormatted - : FORMATTED - ; + : FORMATTED + ; controlUnformatted - : UNFORMATTED - ; + : UNFORMATTED + ; controlNextrec - : NEXTREC - ; + : NEXTREC + ; closeStatement - : CLOSE LPAREN closeControl (COMMA closeControl)* RPAREN - ; + : CLOSE LPAREN closeControl (COMMA closeControl)* RPAREN + ; closeControl - : unitIdentifier - | controlUnit ASSIGN unitIdentifier - | controlErrSpec - | controlStatus ASSIGN characterExpression - | controlIostat ASSIGN varRef - ; + : unitIdentifier + | controlUnit ASSIGN unitIdentifier + | controlErrSpec + | controlStatus ASSIGN characterExpression + | controlIostat ASSIGN varRef + ; inquireStatement - : INQUIRE LPAREN inquireControl (COMMA inquireControl)* RPAREN - ; + : INQUIRE LPAREN inquireControl (COMMA inquireControl)* RPAREN + ; inquireControl - : controlUnit ASSIGN unitIdentifier - | controlFile ASSIGN characterExpression - | controlErrSpec - | (controlIostat | controlExist | controlOpened | controlNumber | controlNamed | controlName | controlAccess | controlSequential | controlDirect | controlForm | controlFormatted | controlUnformatted | controlRecl | controlNextrec | controlBlank) ASSIGN varRef - | unitIdentifier - ; + : controlUnit ASSIGN unitIdentifier + | controlFile ASSIGN characterExpression + | controlErrSpec + | ( + controlIostat + | controlExist + | controlOpened + | controlNumber + | controlNamed + | controlName + | controlAccess + | controlSequential + | controlDirect + | controlForm + | controlFormatted + | controlUnformatted + | controlRecl + | controlNextrec + | controlBlank + ) ASSIGN varRef + | unitIdentifier + ; backspaceStatement - : BACKSPACE berFinish - ; + : BACKSPACE berFinish + ; endfileStatement - : ENDFILE berFinish - ; + : ENDFILE berFinish + ; rewindStatement - : REWIND berFinish - ; + : REWIND berFinish + ; berFinish - : (unitIdentifier (unitIdentifier) | LPAREN berFinishItem (COMMA berFinishItem)* RPAREN) - ; + : (unitIdentifier (unitIdentifier) | LPAREN berFinishItem (COMMA berFinishItem)* RPAREN) + ; berFinishItem - : unitIdentifier - | controlUnit ASSIGN unitIdentifier - | controlErrSpec - | controlIostat ASSIGN varRef - ; + : unitIdentifier + | controlUnit ASSIGN unitIdentifier + | controlErrSpec + | controlIostat ASSIGN varRef + ; unitIdentifier - : iexpr - | STAR - ; + : iexpr + | STAR + ; formatIdentifier - : (SCON | HOLLERITH) - | iexpr - | STAR - ; + : (SCON | HOLLERITH) + | iexpr + | STAR + ; formatStatement - : FORMAT LPAREN fmtSpec RPAREN - ; + : FORMAT LPAREN fmtSpec RPAREN + ; fmtSpec - : (formatedit | formatsep (formatedit)?) (formatsep (formatedit)? | COMMA (formatedit | formatsep (formatedit)?))* - ; + : (formatedit | formatsep (formatedit)?) ( + formatsep (formatedit)? + | COMMA (formatedit | formatsep (formatedit)?) + )* + ; formatsep - : DIV - | COLON - | DOLLAR - ; + : DIV + | COLON + | DOLLAR + ; formatedit - : XCON - | editElement - | ICON editElement - | (PLUS | MINUS)? PCON ((ICON)? editElement)? - ; + : XCON + | editElement + | ICON editElement + | (PLUS | MINUS)? PCON ((ICON)? editElement)? + ; editElement - : (FCON | SCON | HOLLERITH | NAME) - | LPAREN fmtSpec RPAREN - ; + : (FCON | SCON | HOLLERITH | NAME) + | LPAREN fmtSpec RPAREN + ; statementFunctionStatement - : LET sfArgs ASSIGN expression - ; + : LET sfArgs ASSIGN expression + ; sfArgs - : NAME LPAREN namelist RPAREN - ; + : NAME LPAREN namelist RPAREN + ; callStatement - : CALL subroutineCall - ; + : CALL subroutineCall + ; subroutineCall - : NAME (LPAREN (callArgumentList)? RPAREN)? - ; + : NAME (LPAREN (callArgumentList)? RPAREN)? + ; callArgumentList - : callArgument (COMMA callArgument)* - ; + : callArgument (COMMA callArgument)* + ; callArgument - : expression - | STAR lblRef - ; + : expression + | STAR lblRef + ; returnStatement - : RETURN (integerExpr)? - ; + : RETURN (integerExpr)? + ; expression - : ncExpr (COLON ncExpr)? - ; + : ncExpr (COLON ncExpr)? + ; ncExpr - : lexpr0 (concatOp lexpr0)* - ; + : lexpr0 (concatOp lexpr0)* + ; lexpr0 - : lexpr1 ((NEQV | EQV) lexpr1)* - ; + : lexpr1 ((NEQV | EQV) lexpr1)* + ; lexpr1 - : lexpr2 (LOR lexpr2)* - ; + : lexpr2 (LOR lexpr2)* + ; lexpr2 - : lexpr3 (LAND lexpr3)* - ; + : lexpr3 (LAND lexpr3)* + ; lexpr3 - : LNOT lexpr3 - | lexpr4 - ; + : LNOT lexpr3 + | lexpr4 + ; lexpr4 - : aexpr0 ((LT | LE | EQ | NE | GT | GE) aexpr0)? - ; + : aexpr0 ((LT | LE | EQ | NE | GT | GE) aexpr0)? + ; aexpr0 - : aexpr1 ((PLUS | MINUS) aexpr1)* - ; + : aexpr1 ((PLUS | MINUS) aexpr1)* + ; aexpr1 - : aexpr2 ((STAR | DIV) aexpr2)* - ; + : aexpr2 ((STAR | DIV) aexpr2)* + ; aexpr2 - : (PLUS | MINUS)* aexpr3 - ; + : (PLUS | MINUS)* aexpr3 + ; aexpr3 - : aexpr4 (POWER aexpr4)* - ; + : aexpr4 (POWER aexpr4)* + ; aexpr4 - : unsignedArithmeticConstant - | (HOLLERITH | SCON) - | logicalConstant - | varRef - | LPAREN expression RPAREN - ; + : unsignedArithmeticConstant + | (HOLLERITH | SCON) + | logicalConstant + | varRef + | LPAREN expression RPAREN + ; iexpr - : iexpr1 ((PLUS | MINUS) iexpr1)* - ; + : iexpr1 ((PLUS | MINUS) iexpr1)* + ; iexprCode - : iexpr1 ((PLUS | MINUS) iexpr1)* - ; + : iexpr1 ((PLUS | MINUS) iexpr1)* + ; iexpr1 - : iexpr2 ((STAR | DIV) iexpr2)* - ; + : iexpr2 ((STAR | DIV) iexpr2)* + ; iexpr2 - : (PLUS | MINUS)* iexpr3 - ; + : (PLUS | MINUS)* iexpr3 + ; iexpr3 - : iexpr4 (POWER iexpr3)? - ; + : iexpr4 (POWER iexpr3)? + ; iexpr4 - : ICON - | varRefCode - | LPAREN iexprCode RPAREN - ; + : ICON + | varRefCode + | LPAREN iexprCode RPAREN + ; constantExpr - : expression - ; + : expression + ; arithmeticExpression - : expression - ; + : expression + ; integerExpr - : iexpr - ; + : iexpr + ; intRealDpExpr - : expression - ; + : expression + ; arithmeticConstExpr - : expression - ; + : expression + ; intConstantExpr - : expression - ; + : expression + ; characterExpression - : expression - ; + : expression + ; concatOp - : DIV DIV - ; + : DIV DIV + ; logicalExpression - : expression - ; + : expression + ; logicalConstExpr - : expression - ; + : expression + ; arrayElementName - : NAME LPAREN integerExpr (COMMA integerExpr)* RPAREN - ; + : NAME LPAREN integerExpr (COMMA integerExpr)* RPAREN + ; subscripts - : LPAREN (expression (COMMA expression)*)? RPAREN - ; + : LPAREN (expression (COMMA expression)*)? RPAREN + ; varRef - : (NAME | REAL) (subscripts (substringApp)?)? - ; + : (NAME | REAL) (subscripts (substringApp)?)? + ; varRefCode - : NAME (subscripts (substringApp)?)? - ; + : NAME (subscripts (substringApp)?)? + ; substringApp - : LPAREN (ncExpr)? COLON (ncExpr)? RPAREN - ; + : LPAREN (ncExpr)? COLON (ncExpr)? RPAREN + ; variableName - : NAME - ; + : NAME + ; arrayName - : NAME - ; + : NAME + ; subroutineName - : NAME - ; + : NAME + ; functionName - : NAME - ; + : NAME + ; constant - : ((PLUS | MINUS))? unsignedArithmeticConstant - | (SCON | HOLLERITH) - | logicalConstant - ; + : ((PLUS | MINUS))? unsignedArithmeticConstant + | (SCON | HOLLERITH) + | logicalConstant + ; unsignedArithmeticConstant - : (ICON | RCON) - | complexConstant - ; + : (ICON | RCON) + | complexConstant + ; complexConstant - : LPAREN ((PLUS | MINUS))? (ICON | RCON) COMMA ((PLUS | MINUS))? (ICON | RCON) RPAREN - ; + : LPAREN ((PLUS | MINUS))? (ICON | RCON) COMMA ((PLUS | MINUS))? (ICON | RCON) RPAREN + ; logicalConstant - : (TRUE | FALSE) - ; + : (TRUE | FALSE) + ; // needed because Fortran doesn't have reserved keywords. Putting the rule // 'keyword" instead of a few select keywords breaks the parser with harmful // non-determinisms identifier - : NAME - | REAL - ; + : NAME + | REAL + ; \ No newline at end of file diff --git a/fortran/fortran90/Fortran90Lexer.g4 b/fortran/fortran90/Fortran90Lexer.g4 index baee09da5b..ff1bbb254c 100644 --- a/fortran/fortran90/Fortran90Lexer.g4 +++ b/fortran/fortran90/Fortran90Lexer.g4 @@ -1,491 +1,277 @@ -lexer grammar Fortran90Lexer; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -options { superClass = Fortran90LexerBase; } - -// Insert here @header for C++ lexer. - -RECURSIVE - : 'RECURSIVE' | 'recursive' |'Recursive' ; - - -CONTAINS - : - ('contains'|'CONTAINS' |'Contains') - ; - -MODULE - : 'MODULE' | 'module' |'Module' - ; - -ENDMODULE - : 'ENDMODULE' | 'endmodule' |'Endmodule' - ; - -PROGRAM - : 'program' | 'PROGRAM' |'Program' - ; - -ENTRY - : 'entry' | 'ENTRY' |'Entry' - ; - -FUNCTION - : 'function' | 'FUNCTION' | 'Function' - ; - - -BLOCK - : 'block' | 'BLOCK' | 'Block' - ; - -SUBROUTINE - : 'subroutine' | 'SUBROUTINE' | 'Subroutine' - ; - -ENDINTERFACE - : 'ENDINTERFACE' | ' endinterface' |'Endinterface' - ; - -PROCEDURE - : 'procedure' | 'PROCEDURE' | 'Procedure' - ; - -END - : 'END' | 'end'| 'End' - ; - -DIMENSION - : 'dimension' | 'DIMENSION' | 'Dimension' - ; - -TARGET : 'TARGET' | 'target' |'Target' ; - -ALLOCATABLE : 'ALLOCATABLE' | 'allocatable' |'Allocatable' ; - -OPTIONAL : 'OPTIONAL' | 'optional' |'Optional' ; - -NAMELIST : 'NAMELIST' | 'namelist' ; - -INTENT : 'INTENT' | 'intent' |'Intent' ; - -IN : 'IN' | 'in' |'In' ; - -OUT : 'OUT' | 'out' |'Out' ; - -INOUT : 'INOUT' | 'inout' | 'Inout' ; - -OPERATOR : 'operator' | 'OPERATOR' | 'Operator'; - -USE : 'USE' | 'use' |'Use' ; - -ONLY : 'ONLY' | 'only' |'Only' ; - -IMPLIEDT : '=>' ; - -ASSIGNMENT : 'ASSIGNMENT' | 'assignment' |'Assignment' ; - - - -DOP : '.''\\a'+'.'; - -OP - :'==' - | '!=' - | '<=' - |'>=' - |'<' - |'>' - |'/=' - ; - -DOUBLEPRECISION : 'DOUBLEPRECISION' | 'doubleprecision' | 'double precision' | 'DOUBLE PRECISION'; - -DOUBLECOLON : '::' ; - -ASSIGNSTMT : 'assign' | 'ASSIGN' |'Assign'; - -COMMON : 'COMMON' | 'common' |'Common'; - -ELSEWHERE : 'ELSEWHERE' | 'elsewhere' |'Elsewhere' ; - -REAL - : 'REAL' | 'real' |'Real' - ; - - - -EQUIVALENCE - : 'EQUIVALENCE' | 'equivalence' |'Equivalence' - ; - - -BLOCKDATA - : 'blockdata' | 'BLOCKDATA' |'Blockdata' - ; - - -POINTER - : 'pointer' | 'POINTER' |'Pointer' - ; - -fragment PRIVATES - : 'private' | 'PRIVATE' |'Private' - ; - -PRIVATE : PRIVATES ; - -SEQUENCE - : 'sequence' | 'SEQUENCE' |'Sequence' - ; - -fragment PUBLIC - : 'public' | 'PUBLIC' | 'Public' - ; - -ACCESSSPEC - : PRIVATE | PUBLIC - ; - -IMPLICIT - : 'implicit' | 'IMPLICIT' | 'Implicit' - ; - -NONE - : 'none' | 'NONE' | 'None' - ; - -CHARACTER - : 'character' | 'CHARACTER' | 'Character' - ; - - -PARAMETER - : 'parameter' | 'PARAMETER' | 'Parameter' - ; +lexer grammar Fortran90Lexer; +options { + superClass = Fortran90LexerBase; +} -EXTERNAL - : 'external' | 'EXTERNAL' | 'External' - ; +// Insert here @header for C++ lexer. +RECURSIVE: 'RECURSIVE' | 'recursive' | 'Recursive'; -INTRINSIC - : 'intrinsic' | 'INTRINSIC' |'Intrinsic' - ; +CONTAINS: ('contains' | 'CONTAINS' | 'Contains'); +MODULE: 'MODULE' | 'module' | 'Module'; -SAVE - : 'save' | 'SAVE' |'Save' - ; +ENDMODULE: 'ENDMODULE' | 'endmodule' | 'Endmodule'; +PROGRAM: 'program' | 'PROGRAM' | 'Program'; -DATA - : 'data' | 'DATA' | 'Data' - ; +ENTRY: 'entry' | 'ENTRY' | 'Entry'; +FUNCTION: 'function' | 'FUNCTION' | 'Function'; -GO - : 'GO' | 'go' | 'Go' - ; +BLOCK: 'block' | 'BLOCK' | 'Block'; +SUBROUTINE: 'subroutine' | 'SUBROUTINE' | 'Subroutine'; -GOTO - : 'GOTO' | 'goto' | 'Goto' - ; +ENDINTERFACE: 'ENDINTERFACE' | ' endinterface' | 'Endinterface'; +PROCEDURE: 'procedure' | 'PROCEDURE' | 'Procedure'; -IF - : 'IF' | 'if' | 'If' - ; +END: 'END' | 'end' | 'End'; +DIMENSION: 'dimension' | 'DIMENSION' | 'Dimension'; -THEN - : 'THEN' | 'then' - ; +TARGET: 'TARGET' | 'target' | 'Target'; +ALLOCATABLE: 'ALLOCATABLE' | 'allocatable' | 'Allocatable'; -ELSE - : 'ELSE' | 'else' - ; +OPTIONAL: 'OPTIONAL' | 'optional' | 'Optional'; +NAMELIST: 'NAMELIST' | 'namelist'; -ENDIF - : 'ENDIF' | 'endif' - ; +INTENT: 'INTENT' | 'intent' | 'Intent'; -RESULT - : 'RESULT' | 'result' - ; - - -ELSEIF - : 'ELSEIF' | 'elseif' | 'Elseif' - ; +IN: 'IN' | 'in' | 'In'; +OUT: 'OUT' | 'out' | 'Out'; -DO - : 'DO' | 'do' |'Do' - ; +INOUT: 'INOUT' | 'inout' | 'Inout'; -INCLUDE : 'INCLUDE' | 'include' |'Include' ; +OPERATOR: 'operator' | 'OPERATOR' | 'Operator'; -CONTINUE - : 'CONTINUE' | 'continue' |'Continue' - ; +USE: 'USE' | 'use' | 'Use'; -ENDWHERE : 'ENDWHERE' | 'endwhere' | 'Endwhere'; +ONLY: 'ONLY' | 'only' | 'Only'; -WHERE : 'WHERE' | 'where' |'Where' ; +IMPLIEDT: '=>'; -ENDSELECT : 'ENDSELECT' | 'endselect' ; +ASSIGNMENT: 'ASSIGNMENT' | 'assignment' | 'Assignment'; -SELECTCASE : 'SELECTCASE' | 'selectcase'; +DOP: '.' '\\a'+ '.'; -SELECT: 'SELECT' | 'select' ; +OP: '==' | '!=' | '<=' | '>=' | '<' | '>' | '/='; -CASE : 'case' | 'CASE' |'Case' ; +DOUBLEPRECISION: 'DOUBLEPRECISION' | 'doubleprecision' | 'double precision' | 'DOUBLE PRECISION'; -DEFAULT : 'DEFAULT' | 'default' | 'Default'; +DOUBLECOLON: '::'; -DIRECT : 'DIRECT' | 'direct' |'Direct' ; +ASSIGNSTMT: 'assign' | 'ASSIGN' | 'Assign'; -STOP - : 'STOP' | 'stop' | 'Stop' - ; +COMMON: 'COMMON' | 'common' | 'Common'; - REC : 'REC' | 'rec' |'Rec' - ; +ELSEWHERE: 'ELSEWHERE' | 'elsewhere' | 'Elsewhere'; -ENDDO - : 'ENDDO' | 'enddo' - ; +REAL: 'REAL' | 'real' | 'Real'; +EQUIVALENCE: 'EQUIVALENCE' | 'equivalence' | 'Equivalence'; -PAUSE - : 'pause' | 'PAUSE' - ; +BLOCKDATA: 'blockdata' | 'BLOCKDATA' | 'Blockdata'; +POINTER: 'pointer' | 'POINTER' | 'Pointer'; -WRITE - : 'WRITE' | 'write' - ; +fragment PRIVATES: 'private' | 'PRIVATE' | 'Private'; +PRIVATE: PRIVATES; -READ - : 'READ' | 'read' - ; +SEQUENCE: 'sequence' | 'SEQUENCE' | 'Sequence'; +fragment PUBLIC: 'public' | 'PUBLIC' | 'Public'; -PRINT - : 'PRINT' | 'print' - ; +ACCESSSPEC: PRIVATE | PUBLIC; +IMPLICIT: 'implicit' | 'IMPLICIT' | 'Implicit'; -OPEN - : 'OPEN' | 'open' - ; +NONE: 'none' | 'NONE' | 'None'; +CHARACTER: 'character' | 'CHARACTER' | 'Character'; -FMT - : 'FMT' | 'fmt' - ; +PARAMETER: 'parameter' | 'PARAMETER' | 'Parameter'; +EXTERNAL: 'external' | 'EXTERNAL' | 'External'; -UNIT - : 'UNIT' | 'unit' - ; +INTRINSIC: 'intrinsic' | 'INTRINSIC' | 'Intrinsic'; -PAD : 'PAD' | 'pad' ; +SAVE: 'save' | 'SAVE' | 'Save'; -ACTION : 'ACTION' | 'action' ; +DATA: 'data' | 'DATA' | 'Data'; -DELIM : 'DELIM' | 'delim' ; +GO: 'GO' | 'go' | 'Go'; -IOLENGTH : 'IOLENGTH' | 'iolength' ; +GOTO: 'GOTO' | 'goto' | 'Goto'; -READWRITE : 'READWRITE' | 'readwrite' ; +IF: 'IF' | 'if' | 'If'; -ERR - : 'err' | 'ERR' - ; +THEN: 'THEN' | 'then'; -SIZE : 'SIZE' | 'size' ; +ELSE: 'ELSE' | 'else'; -ADVANCE : 'ADVANCE' | 'advance' ; +ENDIF: 'ENDIF' | 'endif'; -NML : 'NML' | 'nml' ; +RESULT: 'RESULT' | 'result'; +ELSEIF: 'ELSEIF' | 'elseif' | 'Elseif'; -IOSTAT - : 'IOSTAT' | 'iostat' - ; +DO: 'DO' | 'do' | 'Do'; +INCLUDE: 'INCLUDE' | 'include' | 'Include'; -FORMAT - : 'FORMAT' | 'format' - ; +CONTINUE: 'CONTINUE' | 'continue' | 'Continue'; +ENDWHERE: 'ENDWHERE' | 'endwhere' | 'Endwhere'; -LET - : 'LET' | 'let' - ; +WHERE: 'WHERE' | 'where' | 'Where'; +ENDSELECT: 'ENDSELECT' | 'endselect'; -CALL - : 'CALL' | 'call' - ; +SELECTCASE: 'SELECTCASE' | 'selectcase'; +SELECT: 'SELECT' | 'select'; -RETURN - : 'RETURN' | 'return' | 'Return' - ; +CASE: 'case' | 'CASE' | 'Case'; +DEFAULT: 'DEFAULT' | 'default' | 'Default'; -CLOSE - : 'CLOSE' | 'close' - ; +DIRECT: 'DIRECT' | 'direct' | 'Direct'; +STOP: 'STOP' | 'stop' | 'Stop'; -DOUBLE - : 'DOUBLE' | 'double' - ; +REC: 'REC' | 'rec' | 'Rec'; +ENDDO: 'ENDDO' | 'enddo'; -IOSTART - : 'IOSTART' | 'iostart' - ; +PAUSE: 'pause' | 'PAUSE'; +WRITE: 'WRITE' | 'write'; -SEQUENTIAL - : 'SEQUENTIAL' | 'sequential' - ; +READ: 'READ' | 'read'; +PRINT: 'PRINT' | 'print'; -LABEL - : 'LABEL' | 'label' - ; +OPEN: 'OPEN' | 'open'; +FMT: 'FMT' | 'fmt'; -FILE - : 'file' | 'FILE' - ; +UNIT: 'UNIT' | 'unit'; +PAD: 'PAD' | 'pad'; -STATUS - : 'STATUS' | 'status' - ; +ACTION: 'ACTION' | 'action'; +DELIM: 'DELIM' | 'delim'; -ACCESS - : 'ACCESS' | 'access' - ; +IOLENGTH: 'IOLENGTH' | 'iolength'; +READWRITE: 'READWRITE' | 'readwrite'; -POSITION - : 'POSITION' | 'position' - ; +ERR: 'err' | 'ERR'; +SIZE: 'SIZE' | 'size'; -FORM - : 'FORM' | 'form' - ; +ADVANCE: 'ADVANCE' | 'advance'; +NML: 'NML' | 'nml'; -RECL - : 'RECL' | 'recl' - ; +IOSTAT: 'IOSTAT' | 'iostat'; +FORMAT: 'FORMAT' | 'format'; -EXIST - : 'EXIST' | 'exist' - ; +LET: 'LET' | 'let'; +CALL: 'CALL' | 'call'; -OPENED - : 'OPENED' | 'opened' - ; +RETURN: 'RETURN' | 'return' | 'Return'; +CLOSE: 'CLOSE' | 'close'; -NUMBER - : 'NUMBER' | 'number' - ; +DOUBLE: 'DOUBLE' | 'double'; +IOSTART: 'IOSTART' | 'iostart'; -NAMED - : 'NAMED' | 'named' - ; +SEQUENTIAL: 'SEQUENTIAL' | 'sequential'; +LABEL: 'LABEL' | 'label'; -NAME_ - : 'NAME' | 'name' - ; +FILE: 'file' | 'FILE'; +STATUS: 'STATUS' | 'status'; -FORMATTED - : 'FORMATTED' | 'formatted' - ; +ACCESS: 'ACCESS' | 'access'; +POSITION: 'POSITION' | 'position'; -UNFORMATTED - : 'UNFORMATTED' | 'unformatted' - ; +FORM: 'FORM' | 'form'; +RECL: 'RECL' | 'recl'; -NEXTREC - : 'NEXTREC' | 'nextrec' - ; +EXIST: 'EXIST' | 'exist'; +OPENED: 'OPENED' | 'opened'; -INQUIRE - : 'INQUIRE' | 'inquire' - ; +NUMBER: 'NUMBER' | 'number'; +NAMED: 'NAMED' | 'named'; -BACKSPACE - : 'BACKSPACE' | 'backspace' - ; +NAME_: 'NAME' | 'name'; +FORMATTED: 'FORMATTED' | 'formatted'; -ENDFILE - : 'ENDFILE' | 'endfile' - ; +UNFORMATTED: 'UNFORMATTED' | 'unformatted'; +NEXTREC: 'NEXTREC' | 'nextrec'; -REWIND - : 'REWIND' | 'rewind' - ; +INQUIRE: 'INQUIRE' | 'inquire'; -ENDBLOCKDATA : 'endblockdata' | 'ENDBLOCKDATA' ; +BACKSPACE: 'BACKSPACE' | 'backspace'; -ENDBLOCK : 'ENDBLOCK' | 'endblock' ; +ENDFILE: 'ENDFILE' | 'endfile'; +REWIND: 'REWIND' | 'rewind'; +ENDBLOCKDATA: 'endblockdata' | 'ENDBLOCKDATA'; +ENDBLOCK: 'ENDBLOCK' | 'endblock'; -fragment NEWLINE - : '\r\n' | '\r' | '\n' - | '\u0085' // ' - | '\u2028' //'' - | '\u2029' //'' - ; - +fragment NEWLINE: + '\r\n' + | '\r' + | '\n' + | '\u0085' // ' + | '\u2028' //'' + | '\u2029' //'' +; -KIND : 'KIND' | 'kind' ; +KIND: 'KIND' | 'kind'; -LEN : 'LEN' | 'len' ; +LEN: 'LEN' | 'len'; //EOS : COMMENTORNEWLINE+ ; //EOS : (COMMENTORNEWLINE? SPACES* [\r\n] [ \t]* )+; //RN : NEWLINE -> channel(HIDDEN) ; -WS - : ([ \t] | NEWLINE)+ -> channel(HIDDEN) - ; +WS: ([ \t] | NEWLINE)+ -> channel(HIDDEN); -COMMENT - : (('\t'* '\u0020'* '!' (~ [\r\n])* [\r\n]* ) - | ( {this.IsColumnZero()}? ('c'| 'C') (~ [\r\n])* [\r\n]*)) -> channel(HIDDEN) ; +COMMENT: + ( + ('\t'* '\u0020'* '!' (~ [\r\n])* [\r\n]*) + | ( {this.IsColumnZero()}? ('c' | 'C') (~ [\r\n])* [\r\n]*) + ) -> channel(HIDDEN) +; /* COMMENTORNEWLINE @@ -496,383 +282,221 @@ COMMENTORNEWLINE ; */ +DOLLAR: '$'; +COMMA: ','; -DOLLAR - : '$' - ; +LPAREN: '('; +PCT: '%'; -COMMA - : ',' - ; +WHILE: 'while' | 'WHILE'; +ALLOCATE: 'ALLOCATE' | 'allocate'; -LPAREN - : '(' - ; +STAT: 'STAT' | 'stat'; -PCT : '%'; +RPAREN: ')'; -WHILE : 'while' | 'WHILE'; +COLON: ':'; -ALLOCATE : 'ALLOCATE' | 'allocate' ; +SEMICOLON: ';'; -STAT : 'STAT' | 'stat'; - -RPAREN - : ')' - ; - - -COLON - : ':' - ; - - -SEMICOLON - : ';' - ; - - -ASSIGN - : '=' - ; - - -MINUS - : '-' - ; - - -PLUS - : '+' - ; - - -DIV - : '/' - ; - -fragment STARCHAR - : '*' - ; - -FORMATSEP - : '/' | ':' - ; - - -POWER - : '**' - ; - - -LNOT - : '.not.' | '.NOT.' - ; - - -LAND - : '.and.' | '.AND.' - ; - - -LOR - : '.or.' | '.OR.' - ; - - -EQV - : '.eqv.' | '.EQV.' - ; - - -NEQV - : '.neqv.' | '.NEQV.' - ; - - -XOR - : '.xor.' | '.XOR.' - ; - - -EOR - : '.eor.' | '.EOR.' - ; - - -LT - : '.lt.' | '.LT.' - ; - - -LE - : '.le.' | '.LE.' - ; - - -GT - : '.gt.' | '.GT.' - ; - - -GE - : '.ge.' | '.GE.' - ; +ASSIGN: '='; +MINUS: '-'; -NE - : '.ne.' | '.NE.' - ; - - -EQ - : '.eq.' | '.EQ.' - ; - - -TRUE - : '.true.' | '.TRUE.' - ; - - -FALSE - : '.false.' | '.FALSE.' - ; - - -XCON - : NUM+ [xX] - ; - - -PCON - : [+-]?NUM+[pP] - ; - +PLUS: '+'; -FCON - : ('a'|'A'|'b'|'B'|'e'|'E'|'d'|'D'|(('e'|'E')('n'|'N'|'s'|'S'))|'q'|'Q'|'f'|'F'|'g'|'G'|'i'|'I'|'l'|'L'|'o'|'O'|'z'|'Z')(NUM+|'*')('.'NUM+(('e'|'E'|'d'|'D'|'q'|'Q')NUM+)?) - ; +DIV: '/'; +fragment STARCHAR: '*'; -CCON - : 'CCON' - ; +FORMATSEP: '/' | ':'; +POWER: '**'; -HOLLERITH - : 'HOLLERITH' - ; +LNOT: '.not.' | '.NOT.'; +LAND: '.and.' | '.AND.'; -CONCATOP - : 'CONCATOP' - ; +LOR: '.or.' | '.OR.'; +EQV: '.eqv.' | '.EQV.'; -CTRLDIRECT - : 'CTRLDIRECT' - ; +NEQV: '.neqv.' | '.NEQV.'; +XOR: '.xor.' | '.XOR.'; -CTRLREC - : 'CTRLREC' - ; +EOR: '.eor.' | '.EOR.'; +LT: '.lt.' | '.LT.'; -TO - : 'TO' - ; - - -SUBPROGRAMBLOCK - : 'SUBPROGRAMBLOCK' - ; - - -DOBLOCK - : 'DOBLOCK' - ; +LE: '.le.' | '.LE.'; +GT: '.gt.' | '.GT.'; -AIF - : 'AIF' - ; +GE: '.ge.' | '.GE.'; +NE: '.ne.' | '.NE.'; -THENBLOCK - : 'THENBLOCK' - ; +EQ: '.eq.' | '.EQ.'; +TRUE: '.true.' | '.TRUE.'; -ELSEBLOCK - : 'ELSEBLOCK' - ; +FALSE: '.false.' | '.FALSE.'; +XCON: NUM+ [xX]; -CODEROOT - : 'CODEROOT' - ; +PCON: [+-]? NUM+ [pP]; +FCON: + ( + 'a' + | 'A' + | 'b' + | 'B' + | 'e' + | 'E' + | 'd' + | 'D' + | (('e' | 'E') ('n' | 'N' | 's' | 'S')) + | 'q' + | 'Q' + | 'f' + | 'F' + | 'g' + | 'G' + | 'i' + | 'I' + | 'l' + | 'L' + | 'o' + | 'O' + | 'z' + | 'Z' + ) (NUM+ | '*') ('.' NUM+ (('e' | 'E' | 'd' | 'D' | 'q' | 'Q') NUM+)?) +; -COMPLEX - : 'COMPLEX' | 'complex' - ; +CCON: 'CCON'; +HOLLERITH: 'HOLLERITH'; -PRECISION - : 'PRECISION' | 'precision' - ; +CONCATOP: 'CONCATOP'; +CTRLDIRECT: 'CTRLDIRECT'; -INTEGER - : 'INTEGER' | 'integer' |'Integer' - ; +CTRLREC: 'CTRLREC'; +TO: 'TO'; -LOGICAL - : 'LOGICAL' | 'logical' | 'Logical' - ; +SUBPROGRAMBLOCK: 'SUBPROGRAMBLOCK'; -fragment SCORE : '_'; +DOBLOCK: 'DOBLOCK'; -UNDERSCORE : SCORE ; +AIF: 'AIF'; -OBRACKETSLASH : '(/'; +THENBLOCK: 'THENBLOCK'; -DOT : '.' ; +ELSEBLOCK: 'ELSEBLOCK'; -CBRACKETSLASH : '/)'; +CODEROOT: 'CODEROOT'; -ZCON : [zZ]'\''[abcdefABCDEF0-9] + '\'' - | [zZ] '"'[abcdefABCDEF0-9] +'"' ; +COMPLEX: 'COMPLEX' | 'complex'; -BCON : [bB]'\'' [01] + '\'' - | [bB]'"'[01] + '"' - ; +PRECISION: 'PRECISION' | 'precision'; - OCON - : [oO]'"'[01234567] + '"' - | [oO]'\''[01234567] + '\'' - ; +INTEGER: 'INTEGER' | 'integer' | 'Integer'; -SCON - : '\'' ('\'' '\'' | ~ ('\'' | '\n' | '\r') | (('\n' | '\r' ('\n')?) ' ' CONTINUATION) ('\n' | '\r' ('\n')?) ' ' CONTINUATION)* '\'' - | - '\'' (~('\'') | ('\'''\''))* ('\'' ) - | - ('"') (~('"') | '""')* ('"') - ; +LOGICAL: 'LOGICAL' | 'logical' | 'Logical'; -RDCON : NUM+ '.' NUM* EXPON? - | NUM* '.' NUM+ EXPON? - | NUM+ EXPON - ; +fragment SCORE: '_'; -DEALLOCATE : 'DEALLOCATE' | 'deallocate' ; +UNDERSCORE: SCORE; -NULLIFY : 'NULLIFY' | 'nullify' ; +OBRACKETSLASH: '(/'; -CYCLE : 'CYCLE' | 'cycle' ; - -ENDTYPE : 'ENDTYPE' | 'endtype' | 'Endtype' |'EndType'; +DOT: '.'; -INTERFACE : 'INTERFACE' | 'interface' | 'Interface' ; - -SPOFF : 'SPOFF'; +CBRACKETSLASH: '/)'; -SPON : 'SPON'; +ZCON: [zZ]'\'' [abcdefABCDEF0-9]+ '\'' | [zZ] '"' [abcdefABCDEF0-9]+ '"'; -ICON - : NUM+ - ; +BCON: [bB]'\'' [01]+ '\'' | [bB]'"' [01]+ '"'; -TYPE - : 'type' | 'TYPE' | 'Type' - ; +OCON: [oO]'"' [01234567]+ '"' | [oO]'\'' [01234567]+ '\''; -NAME - :LETTER ( ALPHANUMERIC_CHARACTER )* - ; +SCON: + '\'' ( + '\'' '\'' + | ~ ('\'' | '\n' | '\r') + | (('\n' | '\r' ('\n')?) ' ' CONTINUATION) ('\n' | '\r' ('\n')?) ' ' CONTINUATION + )* '\'' + | '\'' (~('\'') | ('\'' '\''))* ('\'') + | ('"') (~('"') | '""')* ('"') +; -EXIT : 'EXIT' | 'exit' ; +RDCON: NUM+ '.' NUM* EXPON? | NUM* '.' NUM+ EXPON? | NUM+ EXPON; -BLANK - : 'BLANK' | 'blank' - ; +DEALLOCATE: 'DEALLOCATE' | 'deallocate'; +NULLIFY: 'NULLIFY' | 'nullify'; -ALPHANUMERIC_CHARACTER : LETTER | NUM | SCORE ; +CYCLE: 'CYCLE' | 'cycle'; -fragment LETTER : ('a'..'z' | 'A'..'Z') ; +ENDTYPE: 'ENDTYPE' | 'endtype' | 'Endtype' | 'EndType'; +INTERFACE: 'INTERFACE' | 'interface' | 'Interface'; -STAR - : STARCHAR - ; +SPOFF: 'SPOFF'; +SPON: 'SPON'; +ICON: NUM+; -STRINGLITERAL - : '"' ~ ["\r\n]* '"' - ; +TYPE: 'type' | 'TYPE' | 'Type'; - -EOL - : [\r\n] + - ; +NAME: LETTER ( ALPHANUMERIC_CHARACTER)*; -fragment SPACES - : [ \t] + - ; +EXIT: 'EXIT' | 'exit'; -LINECONT - : (('&' SPACES? COMMENT? NEWLINE (SPACES* [ \t] * '&' )?) | ( SPACES? COMMENT? NEWLINE SPACES* [ \t] * '&' )) -> channel(HIDDEN) - ; +BLANK: 'BLANK' | 'blank'; -fragment CONTINUATION - : ~ ('0' | ' ') - ; +ALPHANUMERIC_CHARACTER: LETTER | NUM | SCORE; +fragment LETTER: ('a' ..'z' | 'A' ..'Z'); -fragment ALNUM - : (ALPHA | NUM) - ; +STAR: STARCHAR; +STRINGLITERAL: '"' ~ ["\r\n]* '"'; -fragment HEX - : (NUM | 'a' .. 'f') - ; +EOL: [\r\n]+; +fragment SPACES: [ \t]+; -fragment SIGN - : ('+' | '-') - ; +LINECONT: + ( + ('&' SPACES? COMMENT? NEWLINE (SPACES* [ \t]* '&')?) + | ( SPACES? COMMENT? NEWLINE SPACES* [ \t]* '&') + ) -> channel(HIDDEN) +; +fragment CONTINUATION: ~ ('0' | ' '); -fragment FDESC - : ('i' | 'f' | 'd') (NUM) + '.' (NUM) + | ('e' | 'g') (NUM) + '.' (NUM) + ('e' (NUM) +)? - ; +fragment ALNUM: (ALPHA | NUM); +fragment HEX: (NUM | 'a' .. 'f'); -fragment EXPON - : ('e' | 'E' | 'd' | 'D') (SIGN)? (NUM) + - ; +fragment SIGN: ('+' | '-'); +fragment FDESC: ('i' | 'f' | 'd') (NUM)+ '.' (NUM)+ | ('e' | 'g') (NUM)+ '.' (NUM)+ ('e' (NUM)+)?; -fragment ALPHA - : ('a' .. 'z') | ('A' .. 'Z') - ; +fragment EXPON: ('e' | 'E' | 'd' | 'D') (SIGN)? (NUM)+; +fragment ALPHA: ('a' .. 'z') | ('A' .. 'Z'); -fragment NUM - : ('0' .. '9') - ; +fragment NUM: ('0' .. '9'); // '' is used to drop the charater when forming the lexical token // Strings are assumed to start with a single quote (') and two -// single quotes is meant as a literal single quote - +// single quotes is meant as a literal single quote \ No newline at end of file diff --git a/fortran/fortran90/Fortran90Parser.g4 b/fortran/fortran90/Fortran90Parser.g4 index c6cf16acef..1a0f055235 100644 --- a/fortran/fortran90/Fortran90Parser.g4 +++ b/fortran/fortran90/Fortran90Parser.g4 @@ -19,576 +19,743 @@ * */ -parser grammar Fortran90Parser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab = Fortran90Lexer; } +parser grammar Fortran90Parser; + +options { + tokenVocab = Fortran90Lexer; +} /* : EOS; commentOrNewLine : COMMENTORNEWLINE ;*/ - program - : executableProgram EOF - ; + : executableProgram EOF + ; -executableProgram : programUnit+ ; +executableProgram + : programUnit+ + ; programUnit - : mainProgram - | functionSubprogram - | subroutineSubprogram - | blockDataSubprogram - | module + : mainProgram + | functionSubprogram + | subroutineSubprogram + | blockDataSubprogram + | module ; -mainProgram : programStmt? mainRange ; +mainProgram + : programStmt? mainRange + ; -programStmt : PROGRAM NAME ; +programStmt + : PROGRAM NAME + ; -mainRange : (body? endProgramStmt) | (bodyPlusInternals endProgramStmt) ; +mainRange + : (body? endProgramStmt) + | (bodyPlusInternals endProgramStmt) + ; -bodyPlusInternals +bodyPlusInternals : body containsStmt internalSubprogram - | containsStmt internalSubprogram - | bodyPlusInternals internalSubprogram + | containsStmt internalSubprogram + | bodyPlusInternals internalSubprogram ; -internalSubprogram : functionSubprogram | subroutineSubprogram ; +internalSubprogram + : functionSubprogram + | subroutineSubprogram + ; -specificationPartConstruct : - implicitStmt - | parameterStmt - | formatStmt - | entryStmt - | declarationConstruct - | includeStmt - | useStmt +specificationPartConstruct + : implicitStmt + | parameterStmt + | formatStmt + | entryStmt + | declarationConstruct + | includeStmt + | useStmt ; -useStmt - : USE NAME - | USE NAME COMMA ONLY COLON - | USE NAME COMMA renameList - | USE NAME COMMA ONLY COLON onlyList +useStmt + : USE NAME + | USE NAME COMMA ONLY COLON + | USE NAME COMMA renameList + | USE NAME COMMA ONLY COLON onlyList ; -onlyList : onlyStmt (COMMA onlyStmt)* ; +onlyList + : onlyStmt (COMMA onlyStmt)* + ; onlyStmt : genericSpec - | ident IMPLIEDT useName - | useName + | ident IMPLIEDT useName + | useName ; -renameList : rename (COMMA rename)* ; +renameList + : rename (COMMA rename)* + ; -rename : ident IMPLIEDT useName ; +rename + : ident IMPLIEDT useName + ; -useName : ident; +useName + : ident + ; -parameterStmt : PARAMETER LPAREN namedConstantDefList RPAREN ; +parameterStmt + : PARAMETER LPAREN namedConstantDefList RPAREN + ; -namedConstantDefList : namedConstantDef+; +namedConstantDefList + : namedConstantDef+ + ; -namedConstantDef: NAME ASSIGN expression ; +namedConstantDef + : NAME ASSIGN expression + ; -endProgramStmt - : END - | END PROGRAM NAME? +endProgramStmt + : END + | END PROGRAM NAME? ; - -blockDataSubprogram +blockDataSubprogram : blockDataStmt blockDataBody endBlockDataStmt - | blockDataStmt endBlockDataStmt + | blockDataStmt endBlockDataStmt ; -blockDataStmt - : BLOCKDATA NAME? - | BLOCK DATA NAME? +blockDataStmt + : BLOCKDATA NAME? + | BLOCK DATA NAME? ; -blockDataBody : blockDataBodyConstruct - | blockDataBody blockDataBodyConstruct +blockDataBody + : blockDataBodyConstruct + | blockDataBody blockDataBodyConstruct ; -blockDataBodyConstruct : specificationPartConstruct; +blockDataBodyConstruct + : specificationPartConstruct + ; -endBlockDataStmt : - ENDBLOCKDATA NAME? - | END BLOCKDATA NAME? - | ENDBLOCK DATA NAME? - | END BLOCK DATA NAME? - | END +endBlockDataStmt + : ENDBLOCKDATA NAME? + | END BLOCKDATA NAME? + | ENDBLOCK DATA NAME? + | END BLOCK DATA NAME? + | END ; -formatStmt: ICON FORMAT LPAREN fmtSpec? RPAREN ; +formatStmt + : ICON FORMAT LPAREN fmtSpec? RPAREN + ; -fmtSpec +fmtSpec : formatedit - | FORMATSEP - | FORMATSEP formatedit - | fmtSpec FORMATSEP - | fmtSpec FORMATSEP formatedit - | fmtSpec COMMA formatedit - | fmtSpec COMMA FORMATSEP - | fmtSpec COMMA FORMATSEP formatedit + | FORMATSEP + | FORMATSEP formatedit + | fmtSpec FORMATSEP + | fmtSpec FORMATSEP formatedit + | fmtSpec COMMA formatedit + | fmtSpec COMMA FORMATSEP + | fmtSpec COMMA FORMATSEP formatedit ; formatedit : editElement - | ICON editElement - | XCON - | PCON - | PCON editElement - | PCON ICON editElement - ; - -editElement + | ICON editElement + | XCON + | PCON + | PCON editElement + | PCON ICON editElement + ; + +editElement : FCON - | mislexedFcon - | SCON - | HOLLERITH - | NAME - | LPAREN fmtSpec RPAREN + | mislexedFcon + | SCON + | HOLLERITH + | NAME + | LPAREN fmtSpec RPAREN ; -mislexedFcon +mislexedFcon : RDCON SPOFF RDCON SPON - | NAME SPOFF RDCON SPON + | NAME SPOFF RDCON SPON ; - - - -module - : moduleStmt moduleBody endModuleStmt +module + : moduleStmt moduleBody endModuleStmt | moduleStmt endModuleStmt ; endModuleStmt - : END MODULE NAME? - | ENDMODULE NAME? - | END + : END MODULE NAME? + | ENDMODULE NAME? + | END ; -entryStmt - : ENTRY NAME subroutineParList RESULT LPAREN NAME RPAREN +entryStmt + : ENTRY NAME subroutineParList RESULT LPAREN NAME RPAREN ; -subroutineParList : (LPAREN subroutinePars? RPAREN)? ; +subroutineParList + : (LPAREN subroutinePars? RPAREN)? + ; -subroutinePars : subroutinePar (COMMA subroutinePar)* ; +subroutinePars + : subroutinePar (COMMA subroutinePar)* + ; -subroutinePar : dummyArgName | STAR ; +subroutinePar + : dummyArgName + | STAR + ; -declarationConstruct +declarationConstruct : derivedTypeDef - | interfaceBlock + | interfaceBlock | typeDeclarationStmt - | specificationStmt + | specificationStmt ; -specificationStmt +specificationStmt : commonStmt - | dataStmt - | dimensionStmt - | equivalenceStmt - | externalStmt - | intrinsicStmt - | saveStmt + | dataStmt + | dimensionStmt + | equivalenceStmt + | externalStmt + | intrinsicStmt + | saveStmt | accessStmt - | allocatableStmt - | intentStmt - | namelistStmt - | optionalStmt - | pointerStmt - | targetStmt + | allocatableStmt + | intentStmt + | namelistStmt + | optionalStmt + | pointerStmt + | targetStmt ; -targetStmt : TARGET DOUBLECOLON? targetObjectList ; +targetStmt + : TARGET DOUBLECOLON? targetObjectList + ; -targetObjectList : targetObject (COMMA targetObject)* ; +targetObjectList + : targetObject (COMMA targetObject)* + ; targetObject : objectName - | objectName LPAREN arraySpec RPAREN + | objectName LPAREN arraySpec RPAREN ; -pointerStmt : POINTER DOUBLECOLON? pointerStmtObjectList ; +pointerStmt + : POINTER DOUBLECOLON? pointerStmtObjectList + ; -pointerStmtObjectList : pointerStmtObject (COMMA pointerStmtObject)* ; +pointerStmtObjectList + : pointerStmtObject (COMMA pointerStmtObject)* + ; -pointerStmtObject +pointerStmtObject : objectName - | objectName LPAREN deferredShapeSpecList RPAREN + | objectName LPAREN deferredShapeSpecList RPAREN ; -optionalStmt : OPTIONAL DOUBLECOLON? optionalParList ; +optionalStmt + : OPTIONAL DOUBLECOLON? optionalParList + ; -optionalParList : optionalPar (COMMA optionalPar)* ; +optionalParList + : optionalPar (COMMA optionalPar)* + ; -optionalPar : dummyArgName ; +optionalPar + : dummyArgName + ; -namelistStmt : NAMELIST namelistGroups ; +namelistStmt + : NAMELIST namelistGroups + ; -namelistGroups +namelistGroups : DIV namelistGroupName DIV namelistGroupObject - | namelistGroups DIV namelistGroupName DIV namelistGroupObject - | namelistGroups COMMA DIV namelistGroupName DIV namelistGroupObject - | namelistGroups COMMA namelistGroupObject + | namelistGroups DIV namelistGroupName DIV namelistGroupObject + | namelistGroups COMMA DIV namelistGroupName DIV namelistGroupObject + | namelistGroups COMMA namelistGroupObject ; -namelistGroupName : NAME ; +namelistGroupName + : NAME + ; -namelistGroupObject : variableName ; +namelistGroupObject + : variableName + ; -intentStmt : INTENT LPAREN intentSpec RPAREN DOUBLECOLON? intentParList ; +intentStmt + : INTENT LPAREN intentSpec RPAREN DOUBLECOLON? intentParList + ; -intentParList : intentPar (COMMA intentPar) ; +intentParList + : intentPar (COMMA intentPar) + ; -intentPar : dummyArgName ; +intentPar + : dummyArgName + ; -dummyArgName : NAME; +dummyArgName + : NAME + ; -intentSpec : (IN | OUT | INOUT); +intentSpec + : (IN | OUT | INOUT) + ; -allocatableStmt : ALLOCATABLE DOUBLECOLON? arrayAllocationList ; +allocatableStmt + : ALLOCATABLE DOUBLECOLON? arrayAllocationList + ; -arrayAllocationList : arrayAllocation (COMMA arrayAllocation)* ; +arrayAllocationList + : arrayAllocation (COMMA arrayAllocation)* + ; -arrayAllocation +arrayAllocation : arrayName | arrayName LPAREN deferredShapeSpecList RPAREN ; -arrayName : ident ; +arrayName + : ident + ; -accessStmt - : ACCESSSPEC DOUBLECOLON? accessIdList - | ACCESSSPEC +accessStmt + : ACCESSSPEC DOUBLECOLON? accessIdList + | ACCESSSPEC ; -accessIdList : accessId (COMMA accessId)* ; +accessIdList + : accessId (COMMA accessId)* + ; -accessId : genericName | genericSpec ; +accessId + : genericName + | genericSpec + ; -genericName : ident ; +genericName + : ident + ; -saveStmt - : SAVE - | SAVE savedEntityList - | SAVE DOUBLECOLON savedEntityList +saveStmt + : SAVE + | SAVE savedEntityList + | SAVE DOUBLECOLON savedEntityList ; -savedEntityList : savedEntity+ ; +savedEntityList + : savedEntity+ + ; -savedEntity : variableName | savedCommonBlock; +savedEntity + : variableName + | savedCommonBlock + ; -savedCommonBlock : DIV commonBlockName DIV ; +savedCommonBlock + : DIV commonBlockName DIV + ; -intrinsicStmt : INTRINSIC intrinsicList ; +intrinsicStmt + : INTRINSIC intrinsicList + ; -intrinsicList : intrinsicProcedureName+ ; +intrinsicList + : intrinsicProcedureName+ + ; -intrinsicProcedureName : NAME ; +intrinsicProcedureName + : NAME + ; -externalStmt : EXTERNAL externalNameList ; +externalStmt + : EXTERNAL externalNameList + ; -externalNameList : externalName+ ; +externalNameList + : externalName+ + ; -externalName : NAME; +externalName + : NAME + ; -equivalenceStmt : EQUIVALENCE equivalenceSetList ; +equivalenceStmt + : EQUIVALENCE equivalenceSetList + ; -equivalenceSetList : equivalenceSet+ ; +equivalenceSetList + : equivalenceSet+ + ; -equivalenceSet : LPAREN equivalenceObject COMMA equivalenceObjectList RPAREN ; +equivalenceSet + : LPAREN equivalenceObject COMMA equivalenceObjectList RPAREN + ; -equivalenceObject : variable; +equivalenceObject + : variable + ; -equivalenceObjectList : equivalenceObject+ ; +equivalenceObjectList + : equivalenceObject+ + ; -dimensionStmt - : DIMENSION arrayDeclaratorList - | DIMENSION DOUBLECOLON arrayDeclaratorList +dimensionStmt + : DIMENSION arrayDeclaratorList + | DIMENSION DOUBLECOLON arrayDeclaratorList ; -arrayDeclaratorList : arrayDeclarator+ ; +arrayDeclaratorList + : arrayDeclarator+ + ; -commonStmt : COMMON comlist ; +commonStmt + : COMMON comlist + ; -comlist +comlist : comblock? commonBlockObject - | comlist COMMA comblock? commonBlockObject - | comlist comblock commonBlockObject + | comlist COMMA comblock? commonBlockObject + | comlist comblock commonBlockObject ; -commonBlockObject : variableName | arrayDeclarator ; +commonBlockObject + : variableName + | arrayDeclarator + ; -arrayDeclarator : variableName LPAREN arraySpec RPAREN ; +arrayDeclarator + : variableName LPAREN arraySpec RPAREN + ; -comblock +comblock : DIV SPOFF DIV SPON - | DIV commonBlockName DIV + | DIV commonBlockName DIV ; -commonBlockName : NAME ; +commonBlockName + : NAME + ; typeDeclarationStmt - : typeSpec entityDeclList - | typeSpec attrSpecSeq? DOUBLECOLON entityDeclList + : typeSpec entityDeclList + | typeSpec attrSpecSeq? DOUBLECOLON entityDeclList ; -attrSpecSeq +attrSpecSeq : COMMA attrSpec - | attrSpecSeq COMMA attrSpec + | attrSpecSeq COMMA attrSpec ; -attrSpec +attrSpec : PARAMETER - | ACCESSSPEC - | ALLOCATABLE - | DIMENSION LPAREN arraySpec RPAREN - | EXTERNAL - | INTENT LPAREN intentSpec RPAREN - | INTRINSIC - | OPTIONAL - | POINTER - | SAVE - | TARGET + | ACCESSSPEC + | ALLOCATABLE + | DIMENSION LPAREN arraySpec RPAREN + | EXTERNAL + | INTENT LPAREN intentSpec RPAREN + | INTRINSIC + | OPTIONAL + | POINTER + | SAVE + | TARGET ; -entityDeclList : entityDecl (COMMA entityDecl)*; +entityDeclList + : entityDecl (COMMA entityDecl)* + ; -entityDecl +entityDecl : objectName - | objectName LPAREN arraySpec RPAREN - | objectName STAR charLength - | objectName LPAREN arraySpec RPAREN STAR charLength + | objectName LPAREN arraySpec RPAREN + | objectName STAR charLength + | objectName LPAREN arraySpec RPAREN STAR charLength | objectName ASSIGN expression - | objectName LPAREN arraySpec RPAREN ASSIGN expression - | objectName STAR charLength ASSIGN expression - | objectName STAR charLength LPAREN arraySpec RPAREN ASSIGN expression + | objectName LPAREN arraySpec RPAREN ASSIGN expression + | objectName STAR charLength ASSIGN expression + | objectName STAR charLength LPAREN arraySpec RPAREN ASSIGN expression ; -objectName : NAME ; +objectName + : NAME + ; -arraySpec - : explicitShapeSpecList | assumedSizeSpec +arraySpec + : explicitShapeSpecList + | assumedSizeSpec | assumedShapeSpecList - | deferredShapeSpecList + | deferredShapeSpecList ; -assumedShapeSpecList +assumedShapeSpecList : lowerBound COLON - | deferredShapeSpecList COMMA lowerBound COLON - | assumedShapeSpecList COMMA assumedShapeSpec + | deferredShapeSpecList COMMA lowerBound COLON + | assumedShapeSpecList COMMA assumedShapeSpec ; -assumedShapeSpec +assumedShapeSpec : lowerBound COLON - | COLON + | COLON ; -assumedSizeSpec +assumedSizeSpec : STAR - | lowerBound COLON STAR - | explicitShapeSpecList COMMA STAR - | explicitShapeSpecList COMMA lowerBound COLON STAR + | lowerBound COLON STAR + | explicitShapeSpecList COMMA STAR + | explicitShapeSpecList COMMA lowerBound COLON STAR ; -interfaceBlock : interfaceStmt interfaceBlockBody endInterfaceStmt ; +interfaceBlock + : interfaceStmt interfaceBlockBody endInterfaceStmt + ; -endInterfaceStmt - : (ENDINTERFACE - | END INTERFACE ) NAME? +endInterfaceStmt + : (ENDINTERFACE | END INTERFACE) NAME? ; interfaceStmt - : INTERFACE NAME - | INTERFACE genericSpec - | INTERFACE + : INTERFACE NAME + | INTERFACE genericSpec + | INTERFACE ; genericSpec : OPERATOR LPAREN definedOperator RPAREN - | ASSIGNMENT LPAREN ASSIGN RPAREN + | ASSIGNMENT LPAREN ASSIGN RPAREN ; -definedOperator +definedOperator : DOP | POWER - | STAR - | (PLUS | MINUS) - | (LT | LE | EQ | NE | GT | GE) - | DIV SPOFF DIV SPON - | LNOT - | LAND - | LOR - | (NEQV | EQV) + | STAR + | (PLUS | MINUS) + | (LT | LE | EQ | NE | GT | GE) + | DIV SPOFF DIV SPON + | LNOT + | LAND + | LOR + | (NEQV | EQV) ; -interfaceBlockBody +interfaceBlockBody : interfaceBodyPartConstruct - | interfaceBlockBody interfaceBodyPartConstruct + | interfaceBlockBody interfaceBodyPartConstruct ; interfaceBodyPartConstruct : interfaceBody - | moduleProcedureStmt + | moduleProcedureStmt ; moduleProcedureStmt - : MODULE PROCEDURE procedureNameList + : MODULE PROCEDURE procedureNameList ; -procedureNameList : procedureName (COMMA procedureName)* ; +procedureNameList + : procedureName (COMMA procedureName)* + ; -procedureName : ident ; +procedureName + : ident + ; -interfaceBody +interfaceBody : functionPrefix NAME functionInterfaceRange - | SUBROUTINE NAME subroutineInterfaceRange + | SUBROUTINE NAME subroutineInterfaceRange ; -subroutineInterfaceRange - : subroutineParList subprogramInterfaceBody? endSubroutineStmt +subroutineInterfaceRange + : subroutineParList subprogramInterfaceBody? endSubroutineStmt ; endSubroutineStmt - : END - | END SUBROUTINE NAME? ; + : END + | END SUBROUTINE NAME? + ; +recursive + : RECURSIVE + ; -recursive : RECURSIVE ; functionPrefix - : recursive? typeSpec? FUNCTION #functionPrefixRec - | typeSpec RECURSIVE FUNCTION #functionPrefixTyp + : recursive? typeSpec? FUNCTION # functionPrefixRec + | typeSpec RECURSIVE FUNCTION # functionPrefixTyp ; functionInterfaceRange - : functionParList subprogramInterfaceBody? endFunctionStmt + : functionParList subprogramInterfaceBody? endFunctionStmt ; -functionParList :LPAREN functionPars? RPAREN ; +functionParList + : LPAREN functionPars? RPAREN + ; -functionPars : functionPar (COMMA functionPar)* ; +functionPars + : functionPar (COMMA functionPar)* + ; -functionPar : dummyArgName; +functionPar + : dummyArgName + ; -subprogramInterfaceBody +subprogramInterfaceBody : specificationPartConstruct - | subprogramInterfaceBody specificationPartConstruct + | subprogramInterfaceBody specificationPartConstruct ; -endFunctionStmt - : END - | END FUNCTION NAME? +endFunctionStmt + : END + | END FUNCTION NAME? ; -derivedTypeDef : derivedTypeStmt derivedTypeBody endTypeStmt ; +derivedTypeDef + : derivedTypeStmt derivedTypeBody endTypeStmt + ; -endTypeStmt - : ENDTYPE NAME - | ENDTYPE - | END TYPE NAME - | END TYPE +endTypeStmt + : ENDTYPE NAME + | ENDTYPE + | END TYPE NAME + | END TYPE ; -derivedTypeStmt - : TYPE NAME - | TYPE DOUBLECOLON NAME - | TYPE COMMA ACCESSSPEC DOUBLECOLON NAME +derivedTypeStmt + : TYPE NAME + | TYPE DOUBLECOLON NAME + | TYPE COMMA ACCESSSPEC DOUBLECOLON NAME ; derivedTypeBody : derivedTypeBodyConstruct - | derivedTypeBody derivedTypeBodyConstruct + | derivedTypeBody derivedTypeBodyConstruct ; derivedTypeBodyConstruct : privateSequenceStmt - | componentDefStmt + | componentDefStmt ; privateSequenceStmt - : PRIVATE - | SEQUENCE + : PRIVATE + | SEQUENCE ; componentDefStmt - : typeSpec COMMA componentAttrSpecList DOUBLECOLON componentDeclList - | typeSpec DOUBLECOLON componentDeclList - | typeSpec componentDeclList + : typeSpec COMMA componentAttrSpecList DOUBLECOLON componentDeclList + | typeSpec DOUBLECOLON componentDeclList + | typeSpec componentDeclList ; -componentDeclList : componentDecl (COMMA componentDecl)*; +componentDeclList + : componentDecl (COMMA componentDecl)* + ; -componentDecl +componentDecl : componentName LPAREN componentArraySpec RPAREN STAR charLength - | componentName LPAREN componentArraySpec RPAREN ASSIGN expression - | componentName LPAREN componentArraySpec RPAREN - | componentName STAR charLength + | componentName LPAREN componentArraySpec RPAREN ASSIGN expression + | componentName LPAREN componentArraySpec RPAREN + | componentName STAR charLength | componentName ASSIGN expression - | componentName STAR charLength ASSIGN expression + | componentName STAR charLength ASSIGN expression | componentName STAR charLength LPAREN componentArraySpec RPAREN ASSIGN expression - | componentName + | componentName ; -componentName : NAME ; -componentAttrSpecList : componentAttrSpec ( COMMA componentAttrSpec)*; +componentName + : NAME + ; + +componentAttrSpecList + : componentAttrSpec (COMMA componentAttrSpec)* + ; -componentAttrSpec +componentAttrSpec : POINTER - | DIMENSION LPAREN componentArraySpec RPAREN + | DIMENSION LPAREN componentArraySpec RPAREN + ; + +componentArraySpec + : explicitShapeSpecList + | deferredShapeSpecList ; -componentArraySpec : explicitShapeSpecList | deferredShapeSpecList ; - -explicitShapeSpecList : explicitShapeSpec (COMMA explicitShapeSpec)* ; +explicitShapeSpecList + : explicitShapeSpec (COMMA explicitShapeSpec)* + ; -explicitShapeSpec : (lowerBound COLON upperBound) | upperBound; +explicitShapeSpec + : (lowerBound COLON upperBound) + | upperBound + ; -lowerBound : expression ; +lowerBound + : expression + ; -upperBound : expression ; +upperBound + : expression + ; -deferredShapeSpecList : deferredShapeSpec (COMMA deferredShapeSpec)* ; +deferredShapeSpecList + : deferredShapeSpec (COMMA deferredShapeSpec)* + ; -deferredShapeSpec : COLON; +deferredShapeSpec + : COLON + ; typeSpec : INTEGER - | REAL - | DOUBLEPRECISION - | COMPLEX - | LOGICAL - | CHARACTER - | CHARACTER lengthSelector + | REAL + | DOUBLEPRECISION + | COMPLEX + | LOGICAL + | CHARACTER + | CHARACTER lengthSelector | INTEGER kindSelector - | REAL kindSelector - | DOUBLE PRECISION - | COMPLEX kindSelector - | CHARACTER charSelector - | LOGICAL kindSelector - | TYPE LPAREN typeName RPAREN + | REAL kindSelector + | DOUBLE PRECISION + | COMPLEX kindSelector + | CHARACTER charSelector + | LOGICAL kindSelector + | TYPE LPAREN typeName RPAREN ; -kindSelector +kindSelector : LPAREN KIND ASSIGN expression RPAREN - | LPAREN expression RPAREN + | LPAREN expression RPAREN ; -typeName : ident ; +typeName + : ident + ; -charSelector +charSelector : LPAREN LEN ASSIGN typeParamValue COMMA KIND ASSIGN expression RPAREN - | LPAREN LEN ASSIGN typeParamValue COMMA expression RPAREN - | LPAREN LEN ASSIGN typeParamValue RPAREN - | LPAREN KIND ASSIGN expression RPAREN - | LPAREN expression RPAREN + | LPAREN LEN ASSIGN typeParamValue COMMA expression RPAREN + | LPAREN LEN ASSIGN typeParamValue RPAREN + | LPAREN KIND ASSIGN expression RPAREN + | LPAREN expression RPAREN ; lengthSelector @@ -596,832 +763,1076 @@ lengthSelector | LPAREN typeParamValue RPAREN ; -charLength +charLength : LPAREN typeParamValue RPAREN - | constant + | constant ; -constant +constant : namedConstantUse - | (PLUS | MINUS)? unsignedArithmeticConstant - | SCON - | HOLLERITH - | logicalConstant + | (PLUS | MINUS)? unsignedArithmeticConstant + | SCON + | HOLLERITH + | logicalConstant | ICON UNDERSCORE SCON - | namedConstantUse UNDERSCORE SCON + | namedConstantUse UNDERSCORE SCON | structureConstructor - | bozLiteralConstant + | bozLiteralConstant ; -bozLiteralConstant : BCON | OCON | ZCON ; +bozLiteralConstant + : BCON + | OCON + | ZCON + ; -structureConstructor : typeName LPAREN exprList RPAREN; +structureConstructor + : typeName LPAREN exprList RPAREN + ; -exprList : expression (COMMA expression) ; +exprList + : expression (COMMA expression) + ; -namedConstantUse : NAME ; +namedConstantUse + : NAME + ; typeParamValue : expression | STAR ; - -moduleStmt - : MODULE moduleName +moduleStmt + : MODULE moduleName ; moduleName : ident ; -ident +ident : NAME ; moduleBody - : specificationPartConstruct #specPartStmt - | moduleSubprogramPartConstruct #submoduleStmt - | moduleBody specificationPartConstruct #complexSpecPart - | moduleBody moduleSubprogramPartConstruct #complexSubmodule + : specificationPartConstruct # specPartStmt + | moduleSubprogramPartConstruct # submoduleStmt + | moduleBody specificationPartConstruct # complexSpecPart + | moduleBody moduleSubprogramPartConstruct # complexSubmodule ; -moduleSubprogramPartConstruct +moduleSubprogramPartConstruct : containsStmt - | moduleSubprogram + | moduleSubprogram ; -containsStmt : CONTAINS ; +containsStmt + : CONTAINS + ; -moduleSubprogram : functionSubprogram | subroutineSubprogram ; +moduleSubprogram + : functionSubprogram + | subroutineSubprogram + ; -functionSubprogram : functionPrefix functionName functionRange ; +functionSubprogram + : functionPrefix functionName functionRange + ; -functionName : NAME; +functionName + : NAME + ; -functionRange - : functionParList body? endFunctionStmt - | functionParList RESULT LPAREN NAME RPAREN body? endFunctionStmt - | functionParList RESULT LPAREN NAME RPAREN bodyPlusInternals endFunctionStmt - | functionParList bodyPlusInternals endFunctionStmt +functionRange + : functionParList body? endFunctionStmt + | functionParList RESULT LPAREN NAME RPAREN body? endFunctionStmt + | functionParList RESULT LPAREN NAME RPAREN bodyPlusInternals endFunctionStmt + | functionParList bodyPlusInternals endFunctionStmt ; -body : bodyConstruct+ ; +body + : bodyConstruct+ + ; bodyConstruct : specificationPartConstruct - | executableConstruct + | executableConstruct ; executableConstruct : actionStmt - | doConstruct - | ifConstruct + | doConstruct + | ifConstruct | caseConstruct | whereConstruct ; -whereConstruct - : where endWhereStmt - | elseWhere endWhereStmt - ; +whereConstruct + : where endWhereStmt + | elseWhere endWhereStmt + ; -elseWhere +elseWhere : where elsewhereStmt - | elseWhere assignmentStmt + | elseWhere assignmentStmt ; -elsewhereStmt : ELSEWHERE ; +elsewhereStmt + : ELSEWHERE + ; -endWhereStmt - : ENDWHERE - | END WHERE +endWhereStmt + : ENDWHERE + | END WHERE ; -where +where : whereConstructStmt - | where assignmentStmt + | where assignmentStmt ; -whereConstructStmt : WHERE LPAREN maskExpr RPAREN ; +whereConstructStmt + : WHERE LPAREN maskExpr RPAREN + ; -maskExpr : expression ; +maskExpr + : expression + ; caseConstruct - : NAME COLON SELECTCASE LPAREN expression RPAREN selectCaseRange - | SELECTCASE LPAREN expression RPAREN selectCaseRange - | NAME COLON SELECT CASE LPAREN expression RPAREN selectCaseRange - | SELECT CASE LPAREN expression RPAREN selectCaseRange + : NAME COLON SELECTCASE LPAREN expression RPAREN selectCaseRange + | SELECTCASE LPAREN expression RPAREN selectCaseRange + | NAME COLON SELECT CASE LPAREN expression RPAREN selectCaseRange + | SELECT CASE LPAREN expression RPAREN selectCaseRange ; -selectCaseRange +selectCaseRange : selectCaseBody endSelectStmt - | endSelectStmt + | endSelectStmt ; -endSelectStmt : (ENDSELECT NAME? ) | ( END SELECT NAME? ); +endSelectStmt + : (ENDSELECT NAME?) + | ( END SELECT NAME?) + ; selectCaseBody - : caseStmt - | selectCaseBody caseBodyConstruct + : caseStmt + | selectCaseBody caseBodyConstruct ; -caseBodyConstruct : caseStmt | executionPartConstruct; +caseBodyConstruct + : caseStmt + | executionPartConstruct + ; caseStmt : CASE caseSelector - | CASE caseSelector NAME + | CASE caseSelector NAME ; -caseSelector +caseSelector : LPAREN caseValueRangeList RPAREN | DEFAULT ; -caseValueRangeList : caseValueRange+ ; +caseValueRangeList + : caseValueRange+ + ; -caseValueRange - : expression #litteralExpression - | expression COLON #afterColonExpression - | COLON expression #beforeColonExpression - | expression COLON expression #midlleColonExpression +caseValueRange + : expression # litteralExpression + | expression COLON # afterColonExpression + | COLON expression # beforeColonExpression + | expression COLON expression # midlleColonExpression ; -ifConstruct : ifThenStmt conditionalBody elseIfConstruct* elseConstruct? endIfStmt ; +ifConstruct + : ifThenStmt conditionalBody elseIfConstruct* elseConstruct? endIfStmt + ; -ifThenStmt : IF LPAREN expression RPAREN THEN ; +ifThenStmt + : IF LPAREN expression RPAREN THEN + ; -conditionalBody : executionPartConstruct*; +conditionalBody + : executionPartConstruct* + ; -elseIfConstruct : elseIfStmt conditionalBody; +elseIfConstruct + : elseIfStmt conditionalBody + ; -elseIfStmt - : ELSEIF LPAREN expression RPAREN THEN - | ELSE IF LPAREN expression RPAREN THEN +elseIfStmt + : ELSEIF LPAREN expression RPAREN THEN + | ELSE IF LPAREN expression RPAREN THEN ; -elseConstruct : elseStmt conditionalBody ; +elseConstruct + : elseStmt conditionalBody + ; -elseStmt : ELSE ; +elseStmt + : ELSE + ; -endIfStmt - : ENDIF - | END IF +endIfStmt + : ENDIF + | END IF ; -doConstruct +doConstruct : labelDoStmt - | blockDoConstruct + | blockDoConstruct ; -blockDoConstruct : nameColon? DO commaLoopControl? executionPartConstruct* endDoStmt +blockDoConstruct + : nameColon? DO commaLoopControl? executionPartConstruct* endDoStmt ; -endDoStmt - : ENDDO endName? - | END DO endName? +endDoStmt + : ENDDO endName? + | END DO endName? ; -endName : ident; +endName + : ident + ; -nameColon : NAME COLON ; +nameColon + : NAME COLON + ; -labelDoStmt : DO doLblRef commaLoopControl executionPartConstruct* doLblDef doLabelStmt; +labelDoStmt + : DO doLblRef commaLoopControl executionPartConstruct* doLblDef doLabelStmt + ; -doLblRef : ICON ; +doLblRef + : ICON + ; -doLblDef : ICON ; +doLblDef + : ICON + ; -doLabelStmt : actionStmt ; +doLabelStmt + : actionStmt + ; -executionPartConstruct +executionPartConstruct : executableConstruct - | formatStmt - | dataStmt - | entryStmt - | doubleDoStmt + | formatStmt + | dataStmt + | entryStmt + | doubleDoStmt ; -doubleDoStmt : DO lblRef commaLoopControl ; +doubleDoStmt + : DO lblRef commaLoopControl + ; -dataStmt : DATA dataStmtSet ((COMMA)? dataStmtSet)* ; +dataStmt + : DATA dataStmtSet ((COMMA)? dataStmtSet)* + ; dataStmtSet - : dse1 dse2 - ; + : dse1 dse2 + ; dse1 - : dataStmtObject (COMMA dataStmtObject)* DIV - ; + : dataStmtObject (COMMA dataStmtObject)* DIV + ; dse2 - : dataStmtValue (COMMA dataStmtValue)* DIV - ; + : dataStmtValue (COMMA dataStmtValue)* DIV + ; -dataStmtValue +dataStmtValue : constant - | constant STAR constant - | namedConstantUse STAR constant + | constant STAR constant + | namedConstantUse STAR constant ; -dataStmtObject : variable | dataImpliedDo ; +dataStmtObject + : variable + | dataImpliedDo + ; -variable : variableName subscriptListRef? substringRange? ; +variable + : variableName subscriptListRef? substringRange? + ; -subscriptListRef : LPAREN subscriptList RPAREN ; +subscriptListRef + : LPAREN subscriptList RPAREN + ; -subscriptList : subscript+ ; +subscriptList + : subscript+ + ; -subscript : expression ; +subscript + : expression + ; -substringRange : LPAREN expression? subscriptTripletTail RPAREN ; +substringRange + : LPAREN expression? subscriptTripletTail RPAREN + ; -dataImpliedDo +dataImpliedDo : LPAREN dataIDoObjectList COMMA impliedDoVariable ASSIGN expression COMMA expression RPAREN - | LPAREN dataIDoObjectList COMMA impliedDoVariable ASSIGN expression COMMA expression COMMA expression RPAREN + | LPAREN dataIDoObjectList COMMA impliedDoVariable ASSIGN expression COMMA expression COMMA expression RPAREN ; -dataIDoObjectList : dataIDoObject+ ; -dataIDoObject - : arrayElement | dataImpliedDo - | structureComponent +dataIDoObjectList + : dataIDoObject+ ; -structureComponent +dataIDoObject + : arrayElement + | dataImpliedDo + | structureComponent + ; + +structureComponent : variableName fieldSelector - | structureComponent fieldSelector + | structureComponent fieldSelector ; -fieldSelector +fieldSelector : LPAREN sectionSubscriptList RPAREN PCT NAME - | PCT NAME + | PCT NAME ; -arrayElement - : variableName LPAREN sectionSubscriptList RPAREN +arrayElement + : variableName LPAREN sectionSubscriptList RPAREN | structureComponent LPAREN sectionSubscriptList RPAREN ; -impliedDoVariable : NAME; +impliedDoVariable + : NAME + ; -commaLoopControl : COMMA? loopControl ; +commaLoopControl + : COMMA? loopControl + ; -loopControl +loopControl : variableName ASSIGN expression COMMA expression commaExpr? | WHILE LPAREN expression RPAREN ; -variableName : NAME; +variableName + : NAME + ; -commaExpr: COMMA expression; +commaExpr + : COMMA expression + ; -semicolonStmt : SEMICOLON actionStmt; +semicolonStmt + : SEMICOLON actionStmt + ; -actionStmt : - arithmeticIfStmt - | assignmentStmt - | assignStmt - | backspaceStmt - | callStmt - | closeStmt - | continueStmt - | endfileStmt - | gotoStmt - | computedGotoStmt - | assignedGotoStmt - | ifStmt +actionStmt + : arithmeticIfStmt + | assignmentStmt + | assignStmt + | backspaceStmt + | callStmt + | closeStmt + | continueStmt + | endfileStmt + | gotoStmt + | computedGotoStmt + | assignedGotoStmt + | ifStmt | inquireStmt - | openStmt - | pauseStmt - | printStmt - | readStmt - | returnStmt - | rewindStmt - | stmtFunctionStmt - | stopStmt - | writeStmt + | openStmt + | pauseStmt + | printStmt + | readStmt + | returnStmt + | rewindStmt + | stmtFunctionStmt + | stopStmt + | writeStmt | allocateStmt | cycleStmt | deallocateStmt | exitStmt - | nullifyStmt - | pointerAssignmentStmt + | nullifyStmt + | pointerAssignmentStmt | whereStmt | semicolonStmt ; -whereStmt : WHERE LPAREN maskExpr RPAREN assignmentStmt; +whereStmt + : WHERE LPAREN maskExpr RPAREN assignmentStmt + ; -pointerAssignmentStmt - : NAME IMPLIEDT target - | NAME sFExprListRef? PCT nameDataRef IMPLIEDT target +pointerAssignmentStmt + : NAME IMPLIEDT target + | NAME sFExprListRef? PCT nameDataRef IMPLIEDT target ; -target : expression; +target + : expression + ; -nullifyStmt : NULLIFY LPAREN pointerObjectList RPAREN ; +nullifyStmt + : NULLIFY LPAREN pointerObjectList RPAREN + ; -pointerObjectList : pointerObject (COMMA pointerObject)* ; +pointerObjectList + : pointerObject (COMMA pointerObject)* + ; -pointerObject : NAME | pointerField ; +pointerObject + : NAME + | pointerField + ; -pointerField - : NAME sFExprListRef? PCT NAME +pointerField + : NAME sFExprListRef? PCT NAME | pointerField fieldSelector ; -exitStmt : EXIT endName? ; - -deallocateStmt - : DEALLOCATE LPAREN allocateObjectList COMMA STAT ASSIGN variable RPAREN - | DEALLOCATE LPAREN allocateObjectList RPAREN +exitStmt + : EXIT endName? ; -allocateObjectList : allocateObject (COMMA allocateObject)*; +deallocateStmt + : DEALLOCATE LPAREN allocateObjectList COMMA STAT ASSIGN variable RPAREN + | DEALLOCATE LPAREN allocateObjectList RPAREN + ; +allocateObjectList + : allocateObject (COMMA allocateObject)* + ; -cycleStmt : CYCLE endName? +cycleStmt + : CYCLE endName? ; -allocateStmt - : ALLOCATE LPAREN allocationList COMMA STAT ASSIGN variable RPAREN - | ALLOCATE LPAREN allocationList RPAREN +allocateStmt + : ALLOCATE LPAREN allocationList COMMA STAT ASSIGN variable RPAREN + | ALLOCATE LPAREN allocationList RPAREN ; -allocationList : allocation (COMMA allocation)* ; +allocationList + : allocation (COMMA allocation)* + ; -allocation +allocation : allocateObject | allocateObject allocatedShape ; -allocateObject +allocateObject : variableName | allocateObject fieldSelector ; -allocatedShape +allocatedShape : LPAREN sectionSubscriptList RPAREN ; +stopStmt + : STOP (ICON | SCON)? + ; -stopStmt : STOP (ICON | SCON)? ; - -writeStmt : WRITE LPAREN ioControlSpecList RPAREN outputItemList? ; +writeStmt + : WRITE LPAREN ioControlSpecList RPAREN outputItemList? + ; -ioControlSpecList +ioControlSpecList : unitIdentifier DOLLAR COMMA - | unitIdentifier COMMA formatIdentifier - | unitIdentifier COMMA ioControlSpec - | ioControlSpec - | ioControlSpecList COMMA ioControlSpec + | unitIdentifier COMMA formatIdentifier + | unitIdentifier COMMA ioControlSpec + | ioControlSpec + | ioControlSpecList COMMA ioControlSpec ; -stmtFunctionStmt : NAME stmtFunctionRange ; +stmtFunctionStmt + : NAME stmtFunctionRange + ; -stmtFunctionRange : LPAREN sFDummyArgNameList? RPAREN ASSIGN expression ; +stmtFunctionRange + : LPAREN sFDummyArgNameList? RPAREN ASSIGN expression + ; -sFDummyArgNameList : sFDummyArgName (COMMA sFDummyArgName)*; +sFDummyArgNameList + : sFDummyArgName (COMMA sFDummyArgName)* + ; -sFDummyArgName : NAME ; +sFDummyArgName + : NAME + ; -returnStmt : RETURN expression? ; +returnStmt + : RETURN expression? + ; -rewindStmt : (REWIND unitIdentifier ) | (REWIND LPAREN positionSpecList RPAREN ) ; +rewindStmt + : (REWIND unitIdentifier) + | (REWIND LPAREN positionSpecList RPAREN) + ; -readStmt - : READ rdCtlSpec inputItemList? - | READ rdFmtId commaInputItemList? +readStmt + : READ rdCtlSpec inputItemList? + | READ rdFmtId commaInputItemList? ; -commaInputItemList : COMMA inputItemList ; +commaInputItemList + : COMMA inputItemList + ; -rdFmtId +rdFmtId : lblRef - | STAR - | cOperand - | cOperand DIV SPOFF DIV SPON cPrimary - | rdFmtIdExpr DIV SPOFF DIV SPON cPrimary + | STAR + | cOperand + | cOperand DIV SPOFF DIV SPON cPrimary + | rdFmtIdExpr DIV SPOFF DIV SPON cPrimary ; -rdFmtIdExpr : LPAREN uFExpr RPAREN ; +rdFmtIdExpr + : LPAREN uFExpr RPAREN + ; -inputItemList : inputItem (COMMA inputItem)* ; +inputItemList + : inputItem (COMMA inputItem)* + ; -inputItem : nameDataRef | inputImpliedDo ; +inputItem + : nameDataRef + | inputImpliedDo + ; -inputImpliedDo : LPAREN inputItemList COMMA impliedDoVariable ASSIGN expression COMMA expression commaExpr? RPAREN; +inputImpliedDo + : LPAREN inputItemList COMMA impliedDoVariable ASSIGN expression COMMA expression commaExpr? RPAREN + ; -rdCtlSpec : rdUnitId | (LPAREN rdIoCtlSpecList RPAREN) ; +rdCtlSpec + : rdUnitId + | (LPAREN rdIoCtlSpecList RPAREN) + ; -rdUnitId : (LPAREN uFExpr RPAREN) | (LPAREN STAR RPAREN) ; +rdUnitId + : (LPAREN uFExpr RPAREN) + | (LPAREN STAR RPAREN) + ; -rdIoCtlSpecList +rdIoCtlSpecList : unitIdentifier COMMA ioControlSpec | unitIdentifier COMMA formatIdentifier | ioControlSpec | rdIoCtlSpecList COMMA ioControlSpec ; -ioControlSpec +ioControlSpec : FMT ASSIGN formatIdentifier - | UNIT ASSIGN unitIdentifier - | REC ASSIGN expression - | END ASSIGN lblRef - | ERR ASSIGN lblRef - | IOSTAT ASSIGN scalarVariable + | UNIT ASSIGN unitIdentifier + | REC ASSIGN expression + | END ASSIGN lblRef + | ERR ASSIGN lblRef + | IOSTAT ASSIGN scalarVariable | NML ASSIGN namelistGroupName - | ADVANCE ASSIGN cExpression - | SIZE ASSIGN variable - | EOR ASSIGN lblRef - ; - -printStmt - : PRINT formatIdentifier COMMA outputItemList - | PRINT formatIdentifier + | ADVANCE ASSIGN cExpression + | SIZE ASSIGN variable + | EOR ASSIGN lblRef ; -outputItemList : expression | outputItemList1 ; +printStmt + : PRINT formatIdentifier COMMA outputItemList + | PRINT formatIdentifier + ; -outputItemList1 - : expression COMMA expression - | expression COMMA outputImpliedDo - | outputImpliedDo - | outputItemList1 COMMA expression - | outputItemList1 COMMA outputImpliedDo +outputItemList + : expression + | outputItemList1 ; +outputItemList1 + : expression COMMA expression + | expression COMMA outputImpliedDo + | outputImpliedDo + | outputItemList1 COMMA expression + | outputItemList1 COMMA outputImpliedDo + ; -outputImpliedDo +outputImpliedDo : LPAREN expression COMMA impliedDoVariable ASSIGN expression COMMA expression commaExpr? RPAREN - | LPAREN outputItemList1 COMMA impliedDoVariable ASSIGN expression COMMA expression commaExpr? RPAREN + | LPAREN outputItemList1 COMMA impliedDoVariable ASSIGN expression COMMA expression commaExpr? RPAREN ; -formatIdentifier : lblRef | cExpression | STAR ; +formatIdentifier + : lblRef + | cExpression + | STAR + ; -pauseStmt : PAUSE (ICON | SCON)? ; +pauseStmt + : PAUSE (ICON | SCON)? + ; -openStmt : OPEN LPAREN connectSpecList RPAREN ; +openStmt + : OPEN LPAREN connectSpecList RPAREN + ; -connectSpecList : unitIdentifierComma? connectSpec? (COMMA connectSpec )*; +connectSpecList + : unitIdentifierComma? connectSpec? (COMMA connectSpec)* + ; -connectSpec +connectSpec : UNIT ASSIGN unitIdentifier - | ERR ASSIGN lblRef - | FILE ASSIGN cExpression - | STATUS ASSIGN cExpression - | ACCESS ASSIGN cExpression - | FORM ASSIGN cExpression - | RECL ASSIGN expression - | BLANK ASSIGN cExpression - | IOSTAT ASSIGN scalarVariable + | ERR ASSIGN lblRef + | FILE ASSIGN cExpression + | STATUS ASSIGN cExpression + | ACCESS ASSIGN cExpression + | FORM ASSIGN cExpression + | RECL ASSIGN expression + | BLANK ASSIGN cExpression + | IOSTAT ASSIGN scalarVariable | POSITION ASSIGN cExpression - | ACTION ASSIGN cExpression - | DELIM ASSIGN cExpression - | PAD ASSIGN cExpression + | ACTION ASSIGN cExpression + | DELIM ASSIGN cExpression + | PAD ASSIGN cExpression ; - -inquireStmt - : INQUIRE LPAREN inquireSpecList RPAREN - | INQUIRE LPAREN IOLENGTH ASSIGN scalarVariable RPAREN outputItemList +inquireStmt + : INQUIRE LPAREN inquireSpecList RPAREN + | INQUIRE LPAREN IOLENGTH ASSIGN scalarVariable RPAREN outputItemList ; -inquireSpecList : unitIdentifier? inquireSpec? (COMMA inquireSpec)*; +inquireSpecList + : unitIdentifier? inquireSpec? (COMMA inquireSpec)* + ; -inquireSpec +inquireSpec : UNIT ASSIGN unitIdentifier - | FILE ASSIGN cExpression - | ERR ASSIGN lblRef - | IOSTAT ASSIGN scalarVariable - | EXIST ASSIGN scalarVariable - | OPENED ASSIGN scalarVariable - | NUMBER ASSIGN scalarVariable - | NAMED ASSIGN scalarVariable - | NAME ASSIGN scalarVariable - | ACCESS ASSIGN scalarVariable - | SEQUENTIAL ASSIGN scalarVariable - | DIRECT ASSIGN scalarVariable - | FORM ASSIGN scalarVariable - | FORMATTED ASSIGN scalarVariable - | UNFORMATTED ASSIGN scalarVariable - | RECL ASSIGN expression - | NEXTREC ASSIGN scalarVariable - | BLANK ASSIGN scalarVariable + | FILE ASSIGN cExpression + | ERR ASSIGN lblRef + | IOSTAT ASSIGN scalarVariable + | EXIST ASSIGN scalarVariable + | OPENED ASSIGN scalarVariable + | NUMBER ASSIGN scalarVariable + | NAMED ASSIGN scalarVariable + | NAME ASSIGN scalarVariable + | ACCESS ASSIGN scalarVariable + | SEQUENTIAL ASSIGN scalarVariable + | DIRECT ASSIGN scalarVariable + | FORM ASSIGN scalarVariable + | FORMATTED ASSIGN scalarVariable + | UNFORMATTED ASSIGN scalarVariable + | RECL ASSIGN expression + | NEXTREC ASSIGN scalarVariable + | BLANK ASSIGN scalarVariable | POSITION ASSIGN scalarVariable - | ACTION ASSIGN scalarVariable - | READ ASSIGN scalarVariable - | WRITE ASSIGN scalarVariable - | READWRITE ASSIGN scalarVariable - | DELIM ASSIGN scalarVariable - | PAD ASSIGN scalarVariable + | ACTION ASSIGN scalarVariable + | READ ASSIGN scalarVariable + | WRITE ASSIGN scalarVariable + | READWRITE ASSIGN scalarVariable + | DELIM ASSIGN scalarVariable + | PAD ASSIGN scalarVariable ; -assignedGotoStmt - : (GOTO | GO TO) variableName - | (GOTO | GO TO) variableName LPAREN lblRefList RPAREN - | (GOTO | GO TO) variableComma LPAREN lblRefList RPAREN +assignedGotoStmt + : (GOTO | GO TO) variableName + | (GOTO | GO TO) variableName LPAREN lblRefList RPAREN + | (GOTO | GO TO) variableComma LPAREN lblRefList RPAREN ; -variableComma : variableName COMMA ; +variableComma + : variableName COMMA + ; -gotoStmt : (GOTO | GO TO) lblRef ; +gotoStmt + : (GOTO | GO TO) lblRef + ; -computedGotoStmt : GOTO LPAREN lblRefList RPAREN COMMA? expression ; +computedGotoStmt + : GOTO LPAREN lblRefList RPAREN COMMA? expression + ; -lblRefList : lblRef (COMMA lblRef)* ; +lblRefList + : lblRef (COMMA lblRef)* + ; -endfileStmt : ((ENDFILE| END FILE) unitIdentifier ) | ((ENDFILE| END FILE) LPAREN positionSpecList RPAREN ); +endfileStmt + : ((ENDFILE | END FILE) unitIdentifier) + | ((ENDFILE | END FILE) LPAREN positionSpecList RPAREN) + ; -continueStmt : CONTINUE ; +continueStmt + : CONTINUE + ; -closeStmt : CLOSE LPAREN closeSpecList RPAREN ; +closeStmt + : CLOSE LPAREN closeSpecList RPAREN + ; -closeSpecList : unitIdentifierComma? closeSpec? (COMMA closeSpec)* ; +closeSpecList + : unitIdentifierComma? closeSpec? (COMMA closeSpec)* + ; -closeSpec +closeSpec : UNIT ASSIGN unitIdentifier - | ERR ASSIGN lblRef - | STATUS ASSIGN cExpression - | IOSTAT scalarVariable + | ERR ASSIGN lblRef + | STATUS ASSIGN cExpression + | IOSTAT scalarVariable ; -cExpression : cPrimary cPrimaryConcatOp* ; +cExpression + : cPrimary cPrimaryConcatOp* + ; -cPrimary : cOperand | (LPAREN cExpression RPAREN); +cPrimary + : cOperand + | (LPAREN cExpression RPAREN) + ; -cOperand +cOperand : SCON | nameDataRef - | functionReference + | functionReference ; -cPrimaryConcatOp : cPrimary DIV SPOFF DIV SPON ; +cPrimaryConcatOp + : cPrimary DIV SPOFF DIV SPON + ; + +callStmt + : CALL subroutineNameUse + | CALL subroutineNameUse LPAREN subroutineArgList RPAREN + ; -callStmt - : CALL subroutineNameUse - | CALL subroutineNameUse LPAREN subroutineArgList RPAREN +subroutineNameUse + : NAME ; -subroutineNameUse : NAME; -subroutineArgList : subroutineArg? (COMMA subroutineArg )*; +subroutineArgList + : subroutineArg? (COMMA subroutineArg)* + ; -subroutineArg +subroutineArg : expression - | HOLLERITH - | STAR lblRef + | HOLLERITH + | STAR lblRef | NAME ASSIGN expression - | NAME ASSIGN HOLLERITH - | NAME ASSIGN STAR lblRef + | NAME ASSIGN HOLLERITH + | NAME ASSIGN STAR lblRef ; -arithmeticIfStmt : IF LPAREN expression RPAREN lblRef COMMA lblRef COMMA lblRef ; +arithmeticIfStmt + : IF LPAREN expression RPAREN lblRef COMMA lblRef COMMA lblRef + ; -lblRef : label; +lblRef + : label + ; -label : ICON; +label + : ICON + ; -assignmentStmt - : label? NAME sFExprListRef? substringRange? ASSIGN expression - | NAME sFExprListRef? PCT nameDataRef ASSIGN expression - | NAME LPAREN sFDummyArgNameList RPAREN PCT nameDataRef ASSIGN expression +assignmentStmt + : label? NAME sFExprListRef? substringRange? ASSIGN expression + | NAME sFExprListRef? PCT nameDataRef ASSIGN expression + | NAME LPAREN sFDummyArgNameList RPAREN PCT nameDataRef ASSIGN expression ; -sFExprListRef : LPAREN sFExprList commaSectionSubscript* RPAREN ; +sFExprListRef + : LPAREN sFExprList commaSectionSubscript* RPAREN + ; -sFExprList +sFExprList : expression COLON? expression? - | COLON expression? + | COLON expression? | expression? COLON expression COLON expression - | expression? DOUBLECOLON expression + | expression? DOUBLECOLON expression + ; + +commaSectionSubscript + : COMMA sectionSubscript ; -commaSectionSubscript : COMMA sectionSubscript; +assignStmt + : ASSIGNSTMT lblRef TO variableName + ; -assignStmt : ASSIGNSTMT lblRef TO variableName ; +backspaceStmt + : BACKSPACE unitIdentifier + | BACKSPACE LPAREN positionSpecList RPAREN + ; -backspaceStmt - : BACKSPACE unitIdentifier - | BACKSPACE LPAREN positionSpecList RPAREN +unitIdentifier + : uFExpr + | STAR ; -unitIdentifier : uFExpr | STAR; -positionSpecList : unitIdentifierComma? positionSpec+ ; +positionSpecList + : unitIdentifierComma? positionSpec+ + ; -unitIdentifierComma : unitIdentifier COMMA? ; +unitIdentifierComma + : unitIdentifier COMMA? + ; -positionSpec +positionSpec : UNIT ASSIGN unitIdentifier - | ERR ASSIGN lblRef - | IOSTAT ASSIGN scalarVariable + | ERR ASSIGN lblRef + | IOSTAT ASSIGN scalarVariable ; -scalarVariable : variableName | arrayElement ; +scalarVariable + : variableName + | arrayElement + ; -uFExpr +uFExpr : uFTerm - | (PLUS | MINUS) uFTerm - | uFExpr (PLUS | MINUS) uFTerm + | (PLUS | MINUS) uFTerm + | uFExpr (PLUS | MINUS) uFTerm ; -uFTerm +uFTerm : uFFactor - | uFTerm (STAR | DIV) uFFactor - | uFTerm (DIV DIV) uFPrimary + | uFTerm (STAR | DIV) uFFactor + | uFTerm (DIV DIV) uFPrimary ; -uFFactor +uFFactor : uFPrimary - | uFPrimary POWER uFFactor + | uFPrimary POWER uFFactor ; -uFPrimary +uFPrimary : ICON - | SCON - | nameDataRef - | functionReference - | LPAREN uFExpr RPAREN + | SCON + | nameDataRef + | functionReference + | LPAREN uFExpr RPAREN ; -subroutineSubprogram - : SUBROUTINE subroutineName subroutineRange - | RECURSIVE SUBROUTINE subroutineName subroutineRange; +subroutineSubprogram + : SUBROUTINE subroutineName subroutineRange + | RECURSIVE SUBROUTINE subroutineName subroutineRange + ; -subroutineName : NAME ; +subroutineName + : NAME + ; -subroutineRange - : subroutineParList body? endSubroutineStmt - | subroutineParList bodyPlusInternals endSubroutineStmt +subroutineRange + : subroutineParList body? endSubroutineStmt + | subroutineParList bodyPlusInternals endSubroutineStmt ; -includeStmt - : INCLUDE SCON +includeStmt + : INCLUDE SCON ; -implicitStmt - : IMPLICIT implicitSpecList - | IMPLICIT NONE ; +implicitStmt + : IMPLICIT implicitSpecList + | IMPLICIT NONE + ; -implicitSpecList : implicitSpec (COMMA implicitSpec)* ; +implicitSpecList + : implicitSpec (COMMA implicitSpec)* + ; implicitSpec - : typeSpec implicitRanges - | typeSpec LPAREN implicitRanges RPAREN - ; + : typeSpec implicitRanges + | typeSpec LPAREN implicitRanges RPAREN + ; -implicitRanges : implicitRange? (COMMA implicitRange)* ; +implicitRanges + : implicitRange? (COMMA implicitRange)* + ; -implicitRange : NAME MINUS NAME ; +implicitRange + : NAME MINUS NAME + ; -expression - : level5Expr +expression + : level5Expr | expression definedBinaryOp level5Expr ; -definedBinaryOp : DOP; +definedBinaryOp + : DOP + ; -level5Expr : equivOperand ((NEQV | EQV) equivOperand)* ; +level5Expr + : equivOperand ((NEQV | EQV) equivOperand)* + ; equivOperand - : orOperand (LOR orOperand)* - ; + : orOperand (LOR orOperand)* + ; orOperand - : andOperand (LAND andOperand )* - ; + : andOperand (LAND andOperand)* + ; andOperand - : LNOT? level4Expr - ; - - -relOp: LT | LE | EQ | NE | GT | GE| OP ; + : LNOT? level4Expr + ; +relOp + : LT + | LE + | EQ + | NE + | GT + | GE + | OP + ; level4Expr - : level3Expr (relOp level3Expr)* - ; + : level3Expr (relOp level3Expr)* + ; level3Expr - : level2Expr (DIV SPOFF? DIV SPON? level2Expr)* - ; + : level2Expr (DIV SPOFF? DIV SPON? level2Expr)* + ; level2Expr - : sign? addOperand ((PLUS | MINUS) addOperand)* - ; + : sign? addOperand ((PLUS | MINUS) addOperand)* + ; -sign : PLUS | MINUS ; +sign + : PLUS + | MINUS + ; addOperand - : multOperand ((STAR | DIV) multOperand)* - ; + : multOperand ((STAR | DIV) multOperand)* + ; multOperand - : level1Expr (POWER level1Expr)* - ; + : level1Expr (POWER level1Expr)* + ; -level1Expr - : primary +level1Expr + : primary | definedUnaryOp primary ; -definedUnaryOp : DOP ; +definedUnaryOp + : DOP + ; primary - : unsignedArithmeticConstant - | nameDataRef - | functionReference - | LPAREN expression RPAREN - | SCON - | logicalConstant - | arrayConstructor - ; + : unsignedArithmeticConstant + | nameDataRef + | functionReference + | LPAREN expression RPAREN + | SCON + | logicalConstant + | arrayConstructor + ; -arrayConstructor : OBRACKETSLASH acValueList CBRACKETSLASH ; +arrayConstructor + : OBRACKETSLASH acValueList CBRACKETSLASH + ; -acValueList : expression |acValueList1 ; +acValueList + : expression + | acValueList1 + ; -acValueList1 +acValueList1 : expression COMMA expression - | expression COMMA acImpliedDo - | acImpliedDo - | acValueList1 COMMA expression - | acValueList1 COMMA acImpliedDo + | expression COMMA acImpliedDo + | acImpliedDo + | acValueList1 COMMA expression + | acValueList1 COMMA acImpliedDo ; -acImpliedDo +acImpliedDo : LPAREN expression COMMA impliedDoVariable ASSIGN expression COMMA expression RPAREN - | LPAREN expression COMMA impliedDoVariable ASSIGN expression COMMA expression COMMA expression RPAREN - | LPAREN acImpliedDo COMMA impliedDoVariable ASSIGN expression COMMA expression RPAREN - | LPAREN acImpliedDo COMMA impliedDoVariable ASSIGN expression COMMA expression COMMA expression RPAREN - ; - + | LPAREN expression COMMA impliedDoVariable ASSIGN expression COMMA expression COMMA expression RPAREN + | LPAREN acImpliedDo COMMA impliedDoVariable ASSIGN expression COMMA expression RPAREN + | LPAREN acImpliedDo COMMA impliedDoVariable ASSIGN expression COMMA expression COMMA expression RPAREN + ; -functionReference +functionReference : NAME LPAREN RPAREN | NAME LPAREN functionArgList RPAREN ; -functionArgList +functionArgList : functionArg - | functionArgList COMMA functionArg - | sectionSubscriptList COMMA functionArg + | functionArgList COMMA functionArg + | sectionSubscriptList COMMA functionArg ; -functionArg - : NAME ASSIGN expression +functionArg + : NAME ASSIGN expression ; - + nameDataRef - : (NAME|REAL|SIZE) complexDataRefTail* + : (NAME | REAL | SIZE) complexDataRefTail* ; -complexDataRefTail - : sectionSubscriptRef - | PCT NAME; - +complexDataRefTail + : sectionSubscriptRef + | PCT NAME + ; -sectionSubscriptRef : LPAREN sectionSubscriptList RPAREN ; +sectionSubscriptRef + : LPAREN sectionSubscriptList RPAREN + ; -sectionSubscriptList : sectionSubscript (COMMA sectionSubscript)* ; +sectionSubscriptList + : sectionSubscript (COMMA sectionSubscript)* + ; -sectionSubscript +sectionSubscript : expression subscriptTripletTail? - | subscriptTripletTail + | subscriptTripletTail ; -subscriptTripletTail - : COLON expression? +subscriptTripletTail + : COLON expression? | COLON expression COLON expression - | DOUBLECOLON expression + | DOUBLECOLON expression ; logicalConstant - : (TRUE | FALSE) - | TRUE UNDERSCORE kindParam - | FALSE UNDERSCORE kindParam DOT - ; - -kindParam : ICON | namedConstantUse ; + : (TRUE | FALSE) + | TRUE UNDERSCORE kindParam + | FALSE UNDERSCORE kindParam DOT + ; +kindParam + : ICON + | namedConstantUse + ; unsignedArithmeticConstant - : (ICON | RDCON) - | complexConst - | ICON UNDERSCORE kindParam - | RDCON UNDERSCORE kindParam - ; + : (ICON | RDCON) + | complexConst + | ICON UNDERSCORE kindParam + | RDCON UNDERSCORE kindParam + ; complexConst - : LPAREN complexComponent COMMA RPAREN - ; + : LPAREN complexComponent COMMA RPAREN + ; -complexComponent - : ((PLUS | MINUS))? ICON +complexComponent + : ((PLUS | MINUS))? ICON | RDCON | NAME ; -constantExpr : expression ; +constantExpr + : expression + ; -ifStmt : IF LPAREN expression RPAREN actionStmt ; +ifStmt + : IF LPAREN expression RPAREN actionStmt + ; \ No newline at end of file diff --git a/freedesktop/desktop-entry/DesktopEntryLexer.g4 b/freedesktop/desktop-entry/DesktopEntryLexer.g4 index eed8cc8a92..c6d2936f52 100644 --- a/freedesktop/desktop-entry/DesktopEntryLexer.g4 +++ b/freedesktop/desktop-entry/DesktopEntryLexer.g4 @@ -22,65 +22,69 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar DesktopEntryLexer; -HASH : '#' -> channel(HIDDEN), pushMode(COMMENT_MODE) ; -LEFT_BRACKET : '[' -> mode(HEADER_MODE) ; -NEWLINE : '\r'? '\n' -> channel(HIDDEN) ; -SPACE : [ \t]+ -> channel(HIDDEN) ; +HASH : '#' -> channel(HIDDEN), pushMode(COMMENT_MODE); +LEFT_BRACKET : '[' -> mode(HEADER_MODE); +NEWLINE : '\r'? '\n' -> channel(HIDDEN); +SPACE : [ \t]+ -> channel(HIDDEN); mode COMMENT_MODE; -COMMENT_TEXT : ~[\r\n]+ -> channel(HIDDEN) ; -NEWLINE_0 : NEWLINE -> channel(HIDDEN), type(NEWLINE), popMode ; +COMMENT_TEXT : ~[\r\n]+ -> channel(HIDDEN); +NEWLINE_0 : NEWLINE -> channel(HIDDEN), type(NEWLINE), popMode; mode HEADER_MODE; -GROUP_NAME : ASCII_PRINTABLE_NO_BRACKETS+ ; -NEWLINE_1 : NEWLINE -> channel(HIDDEN), type(NEWLINE), mode(ENTRY_MODE) ; -RIGHT_BRACKET : ']' ; +GROUP_NAME : ASCII_PRINTABLE_NO_BRACKETS+; +NEWLINE_1 : NEWLINE -> channel(HIDDEN), type(NEWLINE), mode(ENTRY_MODE); +RIGHT_BRACKET : ']'; mode ENTRY_MODE; -HASH_0 : HASH -> channel(HIDDEN), type(HASH), pushMode(COMMENT_MODE) ; -KEY_NAME : IDENTIFIER -> mode(KEY_MODE) ; -LEFT_BRACKET_0 : LEFT_BRACKET -> type(LEFT_BRACKET), mode(HEADER_MODE) ; -NEWLINE_2 : NEWLINE -> channel(HIDDEN), type(NEWLINE) ; -SPACE_0 : SPACE -> channel(HIDDEN), type(SPACE) ; +HASH_0 : HASH -> channel(HIDDEN), type(HASH), pushMode(COMMENT_MODE); +KEY_NAME : IDENTIFIER -> mode(KEY_MODE); +LEFT_BRACKET_0 : LEFT_BRACKET -> type(LEFT_BRACKET), mode(HEADER_MODE); +NEWLINE_2 : NEWLINE -> channel(HIDDEN), type(NEWLINE); +SPACE_0 : SPACE -> channel(HIDDEN), type(SPACE); mode KEY_MODE; -EQUAL : '=' -> mode(VALUE_MODE) ; -LEFT_BRACKET_1 : LEFT_BRACKET -> type(LEFT_BRACKET), pushMode(LOCALE_MODE) ; -SPACE_1 : SPACE -> channel(HIDDEN), type(SPACE) ; +EQUAL : '=' -> mode(VALUE_MODE); +LEFT_BRACKET_1 : LEFT_BRACKET -> type(LEFT_BRACKET), pushMode(LOCALE_MODE); +SPACE_1 : SPACE -> channel(HIDDEN), type(SPACE); mode VALUE_MODE; -TRUE : 'true' ; -FALSE : 'false' ; -NEWLINE_3 : NEWLINE -> channel(HIDDEN), type(NEWLINE), mode(ENTRY_MODE) ; -NUMBER : [0-9]+ ( '.' [0-9]+ )? ; -SEMICOLON : ';' ; -SPACE_2 : SPACE -> channel(HIDDEN), type(SPACE) ; -STRING : ( ~[\n\r\\;] | ESC_SEQ )+ ; +TRUE : 'true'; +FALSE : 'false'; +NEWLINE_3 : NEWLINE -> channel(HIDDEN), type(NEWLINE), mode(ENTRY_MODE); +NUMBER : [0-9]+ ( '.' [0-9]+)?; +SEMICOLON : ';'; +SPACE_2 : SPACE -> channel(HIDDEN), type(SPACE); +STRING : ( ~[\n\r\\;] | ESC_SEQ)+; mode LOCALE_MODE; -AT : '@' -> mode(MODIFIER_MODE) ; -DOT : '.' -> mode(ENCODING_MODE) ; -LANGUAGE : IDENTIFIER ; -RIGHT_BRACKET_0 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode ; -UNDERSCORE : '_' -> mode(COUNTRY_MODE) ; +AT : '@' -> mode(MODIFIER_MODE); +DOT : '.' -> mode(ENCODING_MODE); +LANGUAGE : IDENTIFIER; +RIGHT_BRACKET_0 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode; +UNDERSCORE : '_' -> mode(COUNTRY_MODE); mode COUNTRY_MODE; -AT_0 : '@' -> mode(MODIFIER_MODE) ; -COUNTRY : IDENTIFIER ; -DOT_0 : '.' -> mode(ENCODING_MODE) ; -RIGHT_BRACKET_1 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode ; +AT_0 : '@' -> mode(MODIFIER_MODE); +COUNTRY : IDENTIFIER; +DOT_0 : '.' -> mode(ENCODING_MODE); +RIGHT_BRACKET_1 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode; mode ENCODING_MODE; -AT_1 : '@' -> mode(MODIFIER_MODE) ; -ENCODING : IDENTIFIER ; -RIGHT_BRACKET_2 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode ; +AT_1 : '@' -> mode(MODIFIER_MODE); +ENCODING : IDENTIFIER; +RIGHT_BRACKET_2 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode; mode MODIFIER_MODE; -MODIFIER : IDENTIFIER ; -RIGHT_BRACKET_3 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode ; +MODIFIER : IDENTIFIER; +RIGHT_BRACKET_3 : RIGHT_BRACKET -> type(RIGHT_BRACKET), popMode; -fragment ASCII_PRINTABLE_NO_BRACKETS : [\u0020-\u005a\u005c\u005e-\u007e] ; -fragment ESC_SEQ : '\\' [nrst\\;] ; -fragment IDENTIFIER : [A-Za-z] [A-Za-z0-9\-]* ; +fragment ASCII_PRINTABLE_NO_BRACKETS : [\u0020-\u005a\u005c\u005e-\u007e]; +fragment ESC_SEQ : '\\' [nrst\\;]; +fragment IDENTIFIER : [A-Za-z] [A-Za-z0-9\-]*; \ No newline at end of file diff --git a/freedesktop/desktop-entry/DesktopEntryParser.g4 b/freedesktop/desktop-entry/DesktopEntryParser.g4 index 002de1d3c9..106a625310 100644 --- a/freedesktop/desktop-entry/DesktopEntryParser.g4 +++ b/freedesktop/desktop-entry/DesktopEntryParser.g4 @@ -22,22 +22,78 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 DesktopEntryParser; -options { tokenVocab = DesktopEntryLexer; } - -desktop_entry : group* EOF ; -group : group_header entry* ; -group_header : LEFT_BRACKET group_name RIGHT_BRACKET ; -group_name : GROUP_NAME ; -entry : key locale? EQUAL value? ( SEMICOLON value )* SEMICOLON? ; -key : KEY_NAME ; -locale : LEFT_BRACKET language_ ( UNDERSCORE country )? ( DOT encoding )? ( AT modifier )? RIGHT_BRACKET ; -language_ : LANGUAGE ; -country : COUNTRY ; -encoding : ENCODING ; -modifier : MODIFIER ; -value : string_ | number | true_ | false_ ; -string_ : STRING ; -number : NUMBER ; -true_ : TRUE ; -false_ : FALSE ; + +options { + tokenVocab = DesktopEntryLexer; +} + +desktop_entry + : group* EOF + ; + +group + : group_header entry* + ; + +group_header + : LEFT_BRACKET group_name RIGHT_BRACKET + ; + +group_name + : GROUP_NAME + ; + +entry + : key locale? EQUAL value? (SEMICOLON value)* SEMICOLON? + ; + +key + : KEY_NAME + ; + +locale + : LEFT_BRACKET language_ (UNDERSCORE country)? (DOT encoding)? (AT modifier)? RIGHT_BRACKET + ; + +language_ + : LANGUAGE + ; + +country + : COUNTRY + ; + +encoding + : ENCODING + ; + +modifier + : MODIFIER + ; + +value + : string_ + | number + | true_ + | false_ + ; + +string_ + : STRING + ; + +number + : NUMBER + ; + +true_ + : TRUE + ; + +false_ + : FALSE + ; \ No newline at end of file diff --git a/fusion-tables/FusionTablesSql.g4 b/fusion-tables/FusionTablesSql.g4 index 64d90b23df..1f9902c778 100644 --- a/fusion-tables/FusionTablesSql.g4 +++ b/fusion-tables/FusionTablesSql.g4 @@ -26,381 +26,691 @@ * @author Curiosa Globunznik (curiosa) * @version $Id: FusionTablesSql.g4 1 2016-01-01 00:00:00MET curiosa $ */ - - + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar FusionTablesSql; // credits to bart kier. Took his SQLite grammar as a starting point ant went a long way from there -K_ALTER : A L T E R; -K_AND : A N D; -K_OR : O R; -K_AS : A S; -K_ASC : A S C; -K_AVERAGE: A V E R A G E; -K_BY : B Y; -K_BETWEEN : B E T W E E N; -K_CASE : C A S E; -K_CIRCLE: C I R C L E; -K_COLUMN : C O L U M N; -K_CONTAINS : C O N T A I N S; -K_COUNT : C O U N T; -K_CREATE : C R E A T E; -K_DELETE : D E L E T E; -K_DESC : D E S C; -K_DESCRIBE : D E S C R I B E; -K_DOES : D O E S; -K_CONTAIN : C O N T A I N; -K_DROP : D R O P; -K_ENDS : E N D S; -K_FROM : F R O M; -K_GROUP : G R O U P; -K_HAVING : H A V I N G; -K_IGNORING : I G N O R I N G; -K_IN : I N; -K_INSERT : I N S E R T; -K_INTO : I N T O; -K_JOIN : J O I N; -K_LATLNG : L A T L N G; -K_LEFT : L E F T; -K_LIKE : L I K E; -K_LIMIT : L I M I T; -K_MATCHES : M A T C H E S; -K_MAXIMUM : M A X I M U M; -K_MINIMUM : M I N I M U M; -K_NOT : N O T; -K_EQUAL : E Q U A L; -K_OF : O F; -K_OFFSET : O F F S E T; -K_ON : O N; -K_ORDER : O R D E R; -K_OUTER : O U T E R; -K_RECTANGLE : R E C T A N G L E; -K_RENAME : R E N A M E; -K_ST_DISTANCE : S T '_' D I S T A N C E; -K_SELECT : S E L E C T; -K_ST_INTERSECTS : S T '_' I N T E R S E C T S; -K_SUM : S U M; -K_SET : S E T; -K_SHOW : S H O W; -K_STARTS : S T A R T S; -K_TABLE : T A B L E; -K_TABLES : T A B L E S; -K_TO : T O; -K_UPDATE : U P D A T E; -K_VALUES : V A L U E S; -K_VIEW : V I E W; -K_WHERE : W H E R E; -K_WITH : W I T H; +K_ALTER + : A L T E R + ; + +K_AND + : A N D + ; + +K_OR + : O R + ; + +K_AS + : A S + ; + +K_ASC + : A S C + ; + +K_AVERAGE + : A V E R A G E + ; + +K_BY + : B Y + ; + +K_BETWEEN + : B E T W E E N + ; + +K_CASE + : C A S E + ; + +K_CIRCLE + : C I R C L E + ; + +K_COLUMN + : C O L U M N + ; + +K_CONTAINS + : C O N T A I N S + ; + +K_COUNT + : C O U N T + ; + +K_CREATE + : C R E A T E + ; + +K_DELETE + : D E L E T E + ; + +K_DESC + : D E S C + ; + +K_DESCRIBE + : D E S C R I B E + ; + +K_DOES + : D O E S + ; + +K_CONTAIN + : C O N T A I N + ; + +K_DROP + : D R O P + ; + +K_ENDS + : E N D S + ; + +K_FROM + : F R O M + ; + +K_GROUP + : G R O U P + ; + +K_HAVING + : H A V I N G + ; + +K_IGNORING + : I G N O R I N G + ; + +K_IN + : I N + ; + +K_INSERT + : I N S E R T + ; + +K_INTO + : I N T O + ; + +K_JOIN + : J O I N + ; + +K_LATLNG + : L A T L N G + ; + +K_LEFT + : L E F T + ; + +K_LIKE + : L I K E + ; + +K_LIMIT + : L I M I T + ; + +K_MATCHES + : M A T C H E S + ; + +K_MAXIMUM + : M A X I M U M + ; + +K_MINIMUM + : M I N I M U M + ; + +K_NOT + : N O T + ; + +K_EQUAL + : E Q U A L + ; + +K_OF + : O F + ; + +K_OFFSET + : O F F S E T + ; + +K_ON + : O N + ; + +K_ORDER + : O R D E R + ; + +K_OUTER + : O U T E R + ; + +K_RECTANGLE + : R E C T A N G L E + ; + +K_RENAME + : R E N A M E + ; + +K_ST_DISTANCE + : S T '_' D I S T A N C E + ; + +K_SELECT + : S E L E C T + ; + +K_ST_INTERSECTS + : S T '_' I N T E R S E C T S + ; + +K_SUM + : S U M + ; + +K_SET + : S E T + ; + +K_SHOW + : S H O W + ; + +K_STARTS + : S T A R T S + ; + +K_TABLE + : T A B L E + ; + +K_TABLES + : T A B L E S + ; + +K_TO + : T O + ; + +K_UPDATE + : U P D A T E + ; + +K_VALUES + : V A L U E S + ; + +K_VIEW + : V I E W + ; + +K_WHERE + : W H E R E + ; + +K_WITH + : W I T H + ; fusionTablesSql - : sql_stmt * EOF ; + : sql_stmt* EOF + ; sql_stmt - : ( alter_table_stmt - | select_stmt - | create_view_stmt - | create_table_as_select_stmt - | delete_stmt - | drop_table_stmt - | insert_stmt - | update_stmt - | describe_stmt - | show_tables_stmt - ) ';' - ; + : ( + alter_table_stmt + | select_stmt + | create_view_stmt + | create_table_as_select_stmt + | delete_stmt + | drop_table_stmt + | insert_stmt + | update_stmt + | describe_stmt + | show_tables_stmt + ) ';' + ; table_name_in_ddl - : table_name - ; - + : table_name + ; + table_name_in_dml - : table_name - ; + : table_name + ; create_table_as_select_stmt - : K_CREATE K_TABLE identifier K_AS K_SELECT '*' K_FROM table_name_in_ddl - ; + : K_CREATE K_TABLE identifier K_AS K_SELECT '*' K_FROM table_name_in_ddl + ; describe_stmt - : K_DESCRIBE table_name_in_ddl - ; + : K_DESCRIBE table_name_in_ddl + ; show_tables_stmt - : K_SHOW K_TABLES - ; + : K_SHOW K_TABLES + ; alter_table_stmt - : K_ALTER K_TABLE table_name_in_ddl - ( K_RENAME K_TO identifier ) - ; + : K_ALTER K_TABLE table_name_in_ddl (K_RENAME K_TO identifier) + ; create_view_stmt - : K_CREATE K_VIEW view_name K_AS - '(' - K_SELECT result_column ( ',' result_column )* - K_FROM ((table_name_with_alias ( K_WHERE expr )?) (join_clause) *) - ')' - ; + : K_CREATE K_VIEW view_name K_AS '(' K_SELECT result_column (',' result_column)* K_FROM ( + (table_name_with_alias ( K_WHERE expr)?) (join_clause)* + ) ')' + ; drop_table_stmt - : K_DROP K_TABLE table_name_in_ddl - ; + : K_DROP K_TABLE table_name_in_ddl + ; insert_stmt - : K_INSERT K_INTO - table_name_in_dml ( '(' column_name_in_dml ( ',' column_name_in_dml )* ')' ) - ( K_VALUES '(' literal ( ',' literal)* ')' ) - ; + : K_INSERT K_INTO table_name_in_dml ('(' column_name_in_dml ( ',' column_name_in_dml)* ')') ( + K_VALUES '(' literal ( ',' literal)* ')' + ) + ; update_stmt - : K_UPDATE table_name_in_dml - K_SET column_assignment ( ',' column_assignment )* - K_WHERE eq_comparison - ; + : K_UPDATE table_name_in_dml K_SET column_assignment (',' column_assignment)* K_WHERE eq_comparison + ; -column_assignment : column_name_in_dml '=' literal ; +column_assignment + : column_name_in_dml '=' literal + ; delete_stmt - : K_DELETE K_FROM table_name_in_dml - ( K_WHERE column_name_in_dml '=' literal)? - ; + : K_DELETE K_FROM table_name_in_dml (K_WHERE column_name_in_dml '=' literal)? + ; -eq_comparison : identifier EQ string_literal ; +eq_comparison + : identifier EQ string_literal + ; table_name_with_alias - : table_name ( K_AS table_alias )? - ; + : table_name (K_AS table_alias)? + ; select_stmt - : K_SELECT result_column ( ',' result_column )* - K_FROM table_name_with_alias (join_clause )* - ( K_WHERE expr )? - ( K_GROUP K_BY qualified_column_name ( ',' qualified_column_name )* )? - ( K_ORDER K_BY ordering_term ( ',' ordering_term )* )? - ( - ( K_OFFSET numeric_literal ( K_LIMIT numeric_literal )?) - )? - ; + : K_SELECT result_column (',' result_column)* K_FROM table_name_with_alias (join_clause)* ( + K_WHERE expr + )? (K_GROUP K_BY qualified_column_name ( ',' qualified_column_name)*)? ( + K_ORDER K_BY ordering_term ( ',' ordering_term)* + )? (( K_OFFSET numeric_literal ( K_LIMIT numeric_literal)?))? + ; ordering_term - : (qualified_column_name | K_ST_DISTANCE '(' qualified_column_name ',' coordinate ')') ( K_ASC | K_DESC )? -; + : (qualified_column_name | K_ST_DISTANCE '(' qualified_column_name ',' coordinate ')') ( + K_ASC + | K_DESC + )? + ; join_clause - : ( K_LEFT K_OUTER K_JOIN table_name_with_alias K_ON qualified_column_name '=' qualified_column_name) - ; - + : ( + K_LEFT K_OUTER K_JOIN table_name_with_alias K_ON qualified_column_name '=' qualified_column_name + ) + ; + result_column - : '*' - | table_name '.' '*' - | qualified_column_name - | aggregate_exp - ; - -qualified_column_name : ( table_name '.' )? column_name -; - -aggregate_exp : ( K_SUM | K_COUNT | K_AVERAGE | K_MAXIMUM | K_MINIMUM ) LPAR qualified_column_name RPAR; + : '*' + | table_name '.' '*' + | qualified_column_name + | aggregate_exp + ; + +qualified_column_name + : (table_name '.')? column_name + ; + +aggregate_exp + : (K_SUM | K_COUNT | K_AVERAGE | K_MAXIMUM | K_MINIMUM) LPAR qualified_column_name RPAR + ; expr - : column_name_beginning_expr ( operator_ ) literal (and_or_or expr)? - | column_name_beginning_expr ( K_LIKE | K_MATCHES | K_STARTS K_WITH | K_ENDS K_WITH | K_CONTAINS | K_CONTAINS K_IGNORING K_CASE | K_DOES K_NOT K_CONTAIN | K_NOT K_EQUAL K_TO) string_literal (and_or_or expr)? - | column_name_beginning_expr K_IN '(' string_literal ( ',' string_literal ) * ')' (and_or_or expr)? - | column_name_beginning_expr K_BETWEEN literal K_AND literal (and_or_or expr)? - | K_ST_INTERSECTS LPAR qualified_column_name ',' geometry RPAR (and_or_or expr)? - ; + : column_name_beginning_expr (operator_) literal (and_or_or expr)? + | column_name_beginning_expr ( + K_LIKE + | K_MATCHES + | K_STARTS K_WITH + | K_ENDS K_WITH + | K_CONTAINS + | K_CONTAINS K_IGNORING K_CASE + | K_DOES K_NOT K_CONTAIN + | K_NOT K_EQUAL K_TO + ) string_literal (and_or_or expr)? + | column_name_beginning_expr K_IN '(' string_literal (',' string_literal)* ')' (and_or_or expr)? + | column_name_beginning_expr K_BETWEEN literal K_AND literal (and_or_or expr)? + | K_ST_INTERSECTS LPAR qualified_column_name ',' geometry RPAR (and_or_or expr)? + ; column_name_beginning_expr - : qualified_column_name - ; + : qualified_column_name + ; column_name_in_dml - : column_name - ; + : column_name + ; + +and_or_or + : (K_AND | K_OR) + ; -and_or_or : (K_AND | K_OR) ; +geometry + : circle + | rectangle + ; -geometry : circle | rectangle ; - -circle : K_CIRCLE '(' coordinate ',' numeric_literal ')' ; +circle + : K_CIRCLE '(' coordinate ',' numeric_literal ')' + ; -rectangle : K_RECTANGLE '(' coordinate ',' coordinate ')' ; +rectangle + : K_RECTANGLE '(' coordinate ',' coordinate ')' + ; -coordinate : K_LATLNG '(' numeric_literal ',' numeric_literal ')' ; +coordinate + : K_LATLNG '(' numeric_literal ',' numeric_literal ')' + ; keyword - : - | K_ALTER - | K_AND - | K_OR - | K_AS - | K_ASC - | K_AVERAGE - | K_BY - | K_BETWEEN - | K_CASE - | K_CIRCLE - | K_COLUMN - | K_CONTAIN - | K_CONTAINS - | K_COUNT - | K_CREATE - | K_DELETE - | K_DESC - | K_DOES - | K_DROP - | K_ENDS - | K_EQUAL - | K_FROM - | K_GROUP - | K_HAVING - | K_IGNORING - | K_IN - | K_INSERT - | K_INTO - | K_JOIN - | K_LATLNG - | K_LEFT - | K_LIKE - | K_LIMIT - | K_MATCHES - | K_MAXIMUM - | K_MINIMUM - | K_NOT - | K_OF - | K_OFFSET - | K_ON - | K_ORDER - | K_OUTER - | K_RECTANGLE - | K_RENAME - | K_SELECT - | K_SET - | K_STARTS - | K_ST_DISTANCE - | K_ST_INTERSECTS - | K_SUM - | K_TABLE - | K_TO - | K_UPDATE - | K_VALUES - | K_VIEW - | K_WHERE - | K_WITH - ; - -operator_ - : LT - | LT_EQ - | GT - | GT_EQ - | EQ - ; + : + | K_ALTER + | K_AND + | K_OR + | K_AS + | K_ASC + | K_AVERAGE + | K_BY + | K_BETWEEN + | K_CASE + | K_CIRCLE + | K_COLUMN + | K_CONTAIN + | K_CONTAINS + | K_COUNT + | K_CREATE + | K_DELETE + | K_DESC + | K_DOES + | K_DROP + | K_ENDS + | K_EQUAL + | K_FROM + | K_GROUP + | K_HAVING + | K_IGNORING + | K_IN + | K_INSERT + | K_INTO + | K_JOIN + | K_LATLNG + | K_LEFT + | K_LIKE + | K_LIMIT + | K_MATCHES + | K_MAXIMUM + | K_MINIMUM + | K_NOT + | K_OF + | K_OFFSET + | K_ON + | K_ORDER + | K_OUTER + | K_RECTANGLE + | K_RENAME + | K_SELECT + | K_SET + | K_STARTS + | K_ST_DISTANCE + | K_ST_INTERSECTS + | K_SUM + | K_TABLE + | K_TO + | K_UPDATE + | K_VALUES + | K_VIEW + | K_WHERE + | K_WITH + ; + +operator_ + : LT + | LT_EQ + | GT + | GT_EQ + | EQ + ; literal - : numeric_literal - | string_literal - ; - + : numeric_literal + | string_literal + ; + error_message - : string_literal - ; + : string_literal + ; -identifier: string_literal; +identifier + : string_literal + ; column_alias - : identifier - ; + : identifier + ; + +table_name + : identifier + ; + +column_name + : identifier + ; -table_name - : identifier - ; +new_table_name + : table_name + ; -column_name - : identifier - ; +view_name + : identifier + ; -new_table_name - : table_name - ; +table_alias + : identifier + ; -view_name - : identifier - ; +numeric_literal + : NUMERIC_LITERAL + ; -table_alias - : identifier - ; +string_literal + : STRING_LITERAL + ; -numeric_literal : NUMERIC_LITERAL ; +LT_EQ + : '<=' + ; -string_literal : STRING_LITERAL ; +GT_EQ + : '>=' + ; -LT_EQ : '<='; -GT_EQ : '>='; -GT : '>'; -EQ : '='; -LT : '<'; -LPAR : '('; -RPAR : ')'; +GT + : '>' + ; + +EQ + : '=' + ; + +LT + : '<' + ; + +LPAR + : '(' + ; + +RPAR + : ')' + ; NUMERIC_LITERAL - : DIGIT+ ( '.' DIGIT* )? - | ( '+' | '-' ) NUMERIC_LITERAL - ; + : DIGIT+ ('.' DIGIT*)? + | ( '+' | '-') NUMERIC_LITERAL + ; STRING_LITERAL - : STRING - | QUOTED_STRING - ; + : STRING + | QUOTED_STRING + ; -STRING : ([a-zA-Z_0-9] | '-')+ // TODO unicode support - ; +STRING + : ([a-zA-Z_0-9] | '-')+ // TODO unicode support + ; QUOTED_STRING - : '\'' ( ~'\'' | '\'\'' )* '\'' - ; + : '\'' (~'\'' | '\'\'')* '\'' + ; SINGLELINE_COMMENT - : '--' ~[\r\n]* -> channel(HIDDEN) - ; + : '--' ~[\r\n]* -> channel(HIDDEN) + ; MULTILINE_COMMENT - : '/*' .*? ( '*/' | EOF ) -> channel(HIDDEN) - ; + : '/*' .*? ('*/' | EOF) -> channel(HIDDEN) + ; WHITESPACE - : [ \u000B\t\r\n] -> channel(HIDDEN) - ; - - - -fragment DIGIT : [0-9]; -fragment A : [aA]; -fragment B : [bB]; -fragment C : [cC]; -fragment D : [dD]; -fragment E : [eE]; -fragment F : [fF]; -fragment G : [gG]; -fragment H : [hH]; -fragment I : [iI]; -fragment J : [jJ]; -fragment K : [kK]; -fragment L : [lL]; -fragment M : [mM]; -fragment N : [nN]; -fragment O : [oO]; -fragment P : [pP]; -fragment Q : [qQ]; -fragment R : [rR]; -fragment S : [sS]; -fragment T : [tT]; -fragment U : [uU]; -fragment V : [vV]; -fragment W : [wW]; -fragment X : [xX]; -fragment Y : [yY]; -fragment Z : [zZ]; + : [ \u000B\t\r\n] -> channel(HIDDEN) + ; + +fragment DIGIT + : [0-9] + ; + +fragment A + : [aA] + ; + +fragment B + : [bB] + ; + +fragment C + : [cC] + ; + +fragment D + : [dD] + ; + +fragment E + : [eE] + ; + +fragment F + : [fF] + ; + +fragment G + : [gG] + ; + +fragment H + : [hH] + ; + +fragment I + : [iI] + ; + +fragment J + : [jJ] + ; + +fragment K + : [kK] + ; + +fragment L + : [lL] + ; + +fragment M + : [mM] + ; + +fragment N + : [nN] + ; + +fragment O + : [oO] + ; + +fragment P + : [pP] + ; + +fragment Q + : [qQ] + ; + +fragment R + : [rR] + ; + +fragment S + : [sS] + ; + +fragment T + : [tT] + ; + +fragment U + : [uU] + ; + +fragment V + : [vV] + ; + +fragment W + : [wW] + ; + +fragment X + : [xX] + ; + +fragment Y + : [yY] + ; +fragment Z + : [zZ] + ; \ No newline at end of file diff --git a/gdscript/GDScriptLexer.g4 b/gdscript/GDScriptLexer.g4 index 6b145032ba..31615796bc 100644 --- a/gdscript/GDScriptLexer.g4 +++ b/gdscript/GDScriptLexer.g4 @@ -1,195 +1,160 @@ -lexer grammar GDScriptLexer - ; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +lexer grammar GDScriptLexer; tokens { - INDENT, - DEDENT + INDENT, + DEDENT } options { - superClass = GDScriptLexerBase; + superClass = GDScriptLexerBase; } -EXTENDS: 'extends'; -CLASS_NAME: 'class_name'; -ONREADY: 'onready'; -VAR: 'var'; -SETGET: 'setget'; -EXPORT: 'export'; -CONST: 'const'; -SIGNAL: 'signal'; -ENUM: 'enum'; -STATIC: 'static'; -FUNC: 'func'; -REMOTE: 'remote'; -MASTER: 'master'; -PUPPET: 'puppet'; -REMOTESYNC: 'remotesync'; -MASTERSYNC: 'mastersync'; -PUPPETSYNC: 'puppetsync'; -CLASS: 'class'; -BREAKPOINT: 'breakpoint'; -PASS: 'pass'; -IF: 'if'; -ELIF: 'elif'; -WHILE: 'while'; -FOR: 'for'; -IN: 'in'; -MATCH: 'match'; -CONTINUE: 'continue'; -BREAK: 'break'; -RETURN: 'return'; -ASSERT: 'assert'; -YIELD: 'yield'; -PRELOAD: 'preload'; -AS: 'as'; -ELSE: 'else'; -OR: 'or'; -AND: 'and'; -NOT: 'not'; -IS: 'is'; -TRUE: 'true'; -FALSE: 'false'; -NULL: 'null'; -SELF: 'self'; -TOOL: 'tool'; +EXTENDS : 'extends'; +CLASS_NAME : 'class_name'; +ONREADY : 'onready'; +VAR : 'var'; +SETGET : 'setget'; +EXPORT : 'export'; +CONST : 'const'; +SIGNAL : 'signal'; +ENUM : 'enum'; +STATIC : 'static'; +FUNC : 'func'; +REMOTE : 'remote'; +MASTER : 'master'; +PUPPET : 'puppet'; +REMOTESYNC : 'remotesync'; +MASTERSYNC : 'mastersync'; +PUPPETSYNC : 'puppetsync'; +CLASS : 'class'; +BREAKPOINT : 'breakpoint'; +PASS : 'pass'; +IF : 'if'; +ELIF : 'elif'; +WHILE : 'while'; +FOR : 'for'; +IN : 'in'; +MATCH : 'match'; +CONTINUE : 'continue'; +BREAK : 'break'; +RETURN : 'return'; +ASSERT : 'assert'; +YIELD : 'yield'; +PRELOAD : 'preload'; +AS : 'as'; +ELSE : 'else'; +OR : 'or'; +AND : 'and'; +NOT : 'not'; +IS : 'is'; +TRUE : 'true'; +FALSE : 'false'; +NULL : 'null'; +SELF : 'self'; +TOOL : 'tool'; -NEWLINE - : ( - {atStartOfInput()}? SPACE - | ( '\r'? '\n' | '\r' | '\f') SPACE? - ) {onNewLine();} - ; +NEWLINE: ({atStartOfInput()}? SPACE | ( '\r'? '\n' | '\r' | '\f') SPACE?) {onNewLine();}; -IDENTIFIER - : [_a-zA-Z][_0-9a-zA-Z]* - ; -BUILTINTYPE - : 'bool' - | 'int' - | 'float' - | 'String' - | 'Vector2' - | 'Vector2i' - | 'Rect2' - | 'Rect2i' - | 'Transform2D' - | 'Vector3' - | 'Vector3i' - | 'AABB' - | 'Plane' - | 'Quat' - | 'Basis' - | 'Transform' - | 'Color' - | 'RID' - | 'Object' - | 'StringName' - | 'NodePath' - | 'Dictionary' - | 'Callable' - | 'Signal' - | 'Array' - | 'PackedByteArray' - | 'PackedInt32Array' - | 'PackedInt64Array' - | 'PackedFloat32Array' - | 'PackedFloat64Array' - | 'PackedStringArray' - | 'PackedVector2Array' - | 'PackedVector3Array' - | 'PackedColorArray' - ; -CONSTANT // TODO: really? - : 'PI' - | 'TAU' - | 'INF' - | 'NAN' - ; +IDENTIFIER: [_a-zA-Z][_0-9a-zA-Z]*; +BUILTINTYPE: + 'bool' + | 'int' + | 'float' + | 'String' + | 'Vector2' + | 'Vector2i' + | 'Rect2' + | 'Rect2i' + | 'Transform2D' + | 'Vector3' + | 'Vector3i' + | 'AABB' + | 'Plane' + | 'Quat' + | 'Basis' + | 'Transform' + | 'Color' + | 'RID' + | 'Object' + | 'StringName' + | 'NodePath' + | 'Dictionary' + | 'Callable' + | 'Signal' + | 'Array' + | 'PackedByteArray' + | 'PackedInt32Array' + | 'PackedInt64Array' + | 'PackedFloat32Array' + | 'PackedFloat64Array' + | 'PackedStringArray' + | 'PackedVector2Array' + | 'PackedVector3Array' + | 'PackedColorArray' +; +CONSTANT: 'PI' | 'TAU' | 'INF' | 'NAN'; // TODO: really? -STRING - : '"' STRING_CONTENT* '"' - | '\'' STRING_CONTENT* '\'' - ; -fragment STRING_CONTENT - : ~[\\\r\n'"] - | '\\' [abfnrtv'"\\] - | '\\u' HEX HEX HEX HEX - ; +STRING : '"' STRING_CONTENT* '"' | '\'' STRING_CONTENT* '\''; +fragment STRING_CONTENT : ~[\\\r\n'"] | '\\' [abfnrtv'"\\] | '\\u' HEX HEX HEX HEX; -INTEGER - : '0' [xX] HEX+ - | DEC+ - | '0' [bB] [01]+ - ; -fragment DEC - : [0-9] - ; -fragment HEX - : [0-9a-fA-F] - ; -FLOAT - : DEC? '.' DEC ([eE] [+-] DEC)? - | DEC [eE] [+-] DEC - ; +INTEGER : '0' [xX] HEX+ | DEC+ | '0' [bB] [01]+; +fragment DEC : [0-9]; +fragment HEX : [0-9a-fA-F]; +FLOAT : DEC? '.' DEC ([eE] [+-] DEC)? | DEC [eE] [+-] DEC; -DOT: '.'; -COMMA: ','; -COLON: ':'; -ASSIGN: '='; -COLON_ASSIGN: ':='; -ADD_ASSIGN: '+='; -MINUS_ASSIGN: '-='; -MUL_ASSIGN: '*='; -DIV_ASSIGN: '/='; -MOD_ASSIGN: '%='; -AND_ASSIGN: '&='; -OR_ASSIGN: '|='; -XOR_ASSIGN: '^='; -OPEN_PAREN: '(' {openBrace();}; -CLOSE_PAREN: ')' {closeBrace();}; -OPEN_BRACE: '{' {openBrace();}; -CLOSE_BRACE: '}' {closeBrace();}; -ARROW: '->'; -UNDERSCORE: '_'; -OPEN_BRACK: '[' {openBrace();}; -CLOSE_BRACK: ']' {closeBrace();}; -DOTDOT: '..'; -SEMI_COLON : ';'; -LOGIC_OR: '||'; -LOGIC_AND: '&&'; -LOGIC_NOT: '!'; -LESS_THAN: '<'; -GREATER_THAN: '>'; -EQUALS: '=='; -GT_EQ: '>='; -LT_EQ: '<='; -NOT_EQ: '!='; -OR_OP: '|'; -XOR: '^'; -AND_OP: '&'; -LEFT_SHIFT: '<<'; -RIGHT_SHIFT: '>>'; -ADD: '+'; -MINUS: '-'; -STAR: '*'; -DIV: '/'; -MOD: '%'; -NOT_OP: '~'; -DOLLAR: '$'; +DOT : '.'; +COMMA : ','; +COLON : ':'; +ASSIGN : '='; +COLON_ASSIGN : ':='; +ADD_ASSIGN : '+='; +MINUS_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +MOD_ASSIGN : '%='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +OPEN_PAREN : '(' {openBrace();}; +CLOSE_PAREN : ')' {closeBrace();}; +OPEN_BRACE : '{' {openBrace();}; +CLOSE_BRACE : '}' {closeBrace();}; +ARROW : '->'; +UNDERSCORE : '_'; +OPEN_BRACK : '[' {openBrace();}; +CLOSE_BRACK : ']' {closeBrace();}; +DOTDOT : '..'; +SEMI_COLON : ';'; +LOGIC_OR : '||'; +LOGIC_AND : '&&'; +LOGIC_NOT : '!'; +LESS_THAN : '<'; +GREATER_THAN : '>'; +EQUALS : '=='; +GT_EQ : '>='; +LT_EQ : '<='; +NOT_EQ : '!='; +OR_OP : '|'; +XOR : '^'; +AND_OP : '&'; +LEFT_SHIFT : '<<'; +RIGHT_SHIFT : '>>'; +ADD : '+'; +MINUS : '-'; +STAR : '*'; +DIV : '/'; +MOD : '%'; +NOT_OP : '~'; +DOLLAR : '$'; -SKIP_ - : (SPACE | COMMENT | LINE_JOINING) -> skip - ; +SKIP_: (SPACE | COMMENT | LINE_JOINING) -> skip; -fragment SPACE - : [ \t]+ - ; +fragment SPACE: [ \t]+; -fragment COMMENT - : '#' ~[\r\n]* - ; +fragment COMMENT: '#' ~[\r\n]*; -fragment LINE_JOINING - : '\\' SPACE? ('\r\n' | [\r\n]) - ; \ No newline at end of file +fragment LINE_JOINING: '\\' SPACE? ('\r\n' | [\r\n]); \ No newline at end of file diff --git a/gdscript/GDScriptParser.g4 b/gdscript/GDScriptParser.g4 index f4c8164361..e1767a59ec 100644 --- a/gdscript/GDScriptParser.g4 +++ b/gdscript/GDScriptParser.g4 @@ -1,258 +1,258 @@ -parser grammar GDScriptParser - ; +// $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 GDScriptParser; options { - tokenVocab = GDScriptLexer; + tokenVocab = GDScriptLexer; } program - : (inheritance NEWLINE)? className? topLevelDecl* EOF - ; + : (inheritance NEWLINE)? className? topLevelDecl* EOF + ; inheritance - : 'extends' (IDENTIFIER | STRING) ('.' IDENTIFIER)* - ; + : 'extends' (IDENTIFIER | STRING) ('.' IDENTIFIER)* + ; + className - : 'class_name' IDENTIFIER (',' STRING)? NEWLINE - ; + : 'class_name' IDENTIFIER (',' STRING)? NEWLINE + ; topLevelDecl - : classVarDecl - | constDecl - | signalDecl - | enumDecl - | methodDecl - | constructorDecl - | innerClass - | 'tool' - ; + : classVarDecl + | constDecl + | signalDecl + | enumDecl + | methodDecl + | constructorDecl + | innerClass + | 'tool' + ; classVarDecl - : 'onready'? export? 'var' IDENTIFIER ( - ( ':' typeHint)? ( '=' expression)? - | ':=' expression - ) setget? NEWLINE - ; + : 'onready'? export? 'var' IDENTIFIER (( ':' typeHint)? ( '=' expression)? | ':=' expression) setget? NEWLINE + ; + setget - : 'setget' IDENTIFIER? (',' IDENTIFIER)? - ; + : 'setget' IDENTIFIER? (',' IDENTIFIER)? + ; + export - : 'export' ( - '(' (BUILTINTYPE | IDENTIFIER (',' literal)*)? ')' - )? - ; + : 'export' ('(' (BUILTINTYPE | IDENTIFIER (',' literal)*)? ')')? + ; + typeHint - : BUILTINTYPE - | IDENTIFIER - ; + : BUILTINTYPE + | IDENTIFIER + ; constDecl - : 'const' IDENTIFIER (':' typeHint)? '=' expression NEWLINE - ; + : 'const' IDENTIFIER (':' typeHint)? '=' expression NEWLINE + ; signalDecl - : 'signal' IDENTIFIER signalParList? NEWLINE - ; + : 'signal' IDENTIFIER signalParList? NEWLINE + ; + signalParList - : '(' (IDENTIFIER (',' IDENTIFIER)*)? ')' - ; + : '(' (IDENTIFIER (',' IDENTIFIER)*)? ')' + ; enumDecl - : 'enum' IDENTIFIER? '{' ( - IDENTIFIER ('=' expression)? ( - ',' IDENTIFIER ( '=' expression)? - )* ','? - ) '}' NEWLINE - ; + : 'enum' IDENTIFIER? '{' ( + IDENTIFIER ('=' expression)? (',' IDENTIFIER ( '=' expression)?)* ','? + ) '}' NEWLINE + ; methodDecl - : rpc? 'static'? 'func' IDENTIFIER '(' parList? ')' ( - '->' typeHint - )? ':' stmtOrSuite - ; + : rpc? 'static'? 'func' IDENTIFIER '(' parList? ')' ('->' typeHint)? ':' stmtOrSuite + ; + parList - : parameter (',' parameter)* - ; + : parameter (',' parameter)* + ; + parameter - : 'var'? IDENTIFIER (':' typeHint)? ('=' expression)? - ; + : 'var'? IDENTIFIER (':' typeHint)? ('=' expression)? + ; + rpc - : 'remote' - | 'master' - | 'puppet' - | 'remotesync' - | 'mastersync' - | 'puppetsync' - ; + : 'remote' + | 'master' + | 'puppet' + | 'remotesync' + | 'mastersync' + | 'puppetsync' + ; constructorDecl - : 'func' IDENTIFIER '(' parList? ')' ('.' '(' argList? ')') ':' stmtOrSuite - ; + : 'func' IDENTIFIER '(' parList? ')' ('.' '(' argList? ')') ':' stmtOrSuite + ; + argList - : expression (',' expression)* - ; + : expression (',' expression)* + ; innerClass - : 'class' IDENTIFIER inheritance? ':' NEWLINE INDENT ( - inheritance NEWLINE - )? topLevelDecl+ DEDENT - ; + : 'class' IDENTIFIER inheritance? ':' NEWLINE INDENT (inheritance NEWLINE)? topLevelDecl+ DEDENT + ; stmtOrSuite - : stmt - | NEWLINE INDENT suite DEDENT - ; + : stmt + | NEWLINE INDENT suite DEDENT + ; + suite - : stmt+ - ; + : stmt+ + ; stmt - : varDeclStmt - | ifStmt - | forStmt - | whileStmt - | matchStmt - | flowStmt - | assignmentStmt - | exprStmt - | assertStmt - | yieldStmt - | preloadStmt - | 'breakpoint' stmtEnd - | 'pass' stmtEnd - ; + : varDeclStmt + | ifStmt + | forStmt + | whileStmt + | matchStmt + | flowStmt + | assignmentStmt + | exprStmt + | assertStmt + | yieldStmt + | preloadStmt + | 'breakpoint' stmtEnd + | 'pass' stmtEnd + ; + stmtEnd - : NEWLINE - | ';' - ; + : NEWLINE + | ';' + ; ifStmt - : 'if' expression ':' stmtOrSuite ( - 'elif' expression ':' stmtOrSuite - )* ('else' ':' stmtOrSuite)? - ; + : 'if' expression ':' stmtOrSuite ('elif' expression ':' stmtOrSuite)* ('else' ':' stmtOrSuite)? + ; + whileStmt - : 'while' expression ':' stmtOrSuite - ; + : 'while' expression ':' stmtOrSuite + ; + forStmt - : 'for' IDENTIFIER 'in' expression ':' stmtOrSuite - ; + : 'for' IDENTIFIER 'in' expression ':' stmtOrSuite + ; matchStmt - : 'match' expression NEWLINE INDENT matchBlock DEDENT - ; + : 'match' expression NEWLINE INDENT matchBlock DEDENT + ; + matchBlock - : (patternList ':' stmtOrSuite)+ - ; + : (patternList ':' stmtOrSuite)+ + ; + patternList - : pattern (',' pattern)* - ; + : pattern (',' pattern)* + ; + // Note: you can't have a binding in a pattern list, but to not complicate the grammar more it won't // be restricted syntactically pattern - : literal - | BUILTINTYPE - | CONSTANT - | '_' - | bindingPattern - | arrayPattern - | dictPattern - ; + : literal + | BUILTINTYPE + | CONSTANT + | '_' + | bindingPattern + | arrayPattern + | dictPattern + ; + bindingPattern - : 'var' IDENTIFIER - ; + : 'var' IDENTIFIER + ; + arrayPattern - : '[' (pattern (',' pattern)* '..'?)? ']' - ; + : '[' (pattern (',' pattern)* '..'?)? ']' + ; + dictPattern - : '{' keyValuePattern? (',' keyValuePattern)* '..'? '}' - ; + : '{' keyValuePattern? (',' keyValuePattern)* '..'? '}' + ; + keyValuePattern - : STRING (':' pattern)? - ; + : STRING (':' pattern)? + ; flowStmt - : 'continue' stmtEnd - | 'break' stmtEnd - | 'return' expression? stmtEnd - ; + : 'continue' stmtEnd + | 'break' stmtEnd + | 'return' expression? stmtEnd + ; assignmentStmt - : expression ( - '=' - | '+=' - | '-=' - | '*=' - | '/=' - | '%=' - | '&=' - | '|=' - | '^=' - ) expression stmtEnd - ; + : expression ('=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=') expression stmtEnd + ; + varDeclStmt - : 'var' IDENTIFIER ('=' expression)? stmtEnd - ; + : 'var' IDENTIFIER ('=' expression)? stmtEnd + ; assertStmt - : 'assert' '(' expression (',' STRING)? ')' stmtEnd - ; + : 'assert' '(' expression (',' STRING)? ')' stmtEnd + ; + yieldStmt - : 'yield' '(' (expression ',' expression) ')' - ; + : 'yield' '(' (expression ',' expression) ')' + ; + preloadStmt - : 'preload' '(' CONSTANT ')' - ; + : 'preload' '(' CONSTANT ')' + ; exprStmt - : expression stmtEnd - ; + : expression stmtEnd + ; + expression - : 'true' # primary - | 'false' # primary - | 'null' # primary - | 'self' # primary - | literal # primary - | '[' (expression ( ',' expression)* ','?)? ']' # arrayDecl - | '{' (keyValue (',' keyValue)* ','?)? '}' # dictDecl - | '(' expression ')' # primary - - | expression '[' expression ']' # subscription - | expression '.' IDENTIFIER # attribute - - | expression '(' argList? ')' # call - | '.' IDENTIFIER '(' argList? ')' # call - | '$' (STRING | IDENTIFIER ('/' IDENTIFIER)*) # getNode - - | expression 'is' (IDENTIFIER | BUILTINTYPE) # is - | '~' expression # bitNot - | ('-' | '+') expression # sign - | expression ('*' | '/' | '%') expression # factor - | expression '+' expression # plus - | expression '-' expression # minus - | expression ('<<' | '>>') expression # bitShift - | expression '&' expression # bitAnd - | expression '^' expression # bitXor - | expression '|' expression # bitOr - | expression ('<' | '>' | '<=' | '>=' | '==' | '!=') expression # comparison - | expression 'in' expression # in - | ('!' | 'not') expression # logicNot - | expression ('and' | '&&') expression # logicAnd - | expression ('or' | '||') expression # logicOr - | expression 'if' expression 'else' expression # ternacyExpr - | expression 'as' typeHint # cast - ; + : 'true' # primary + | 'false' # primary + | 'null' # primary + | 'self' # primary + | literal # primary + | '[' (expression ( ',' expression)* ','?)? ']' # arrayDecl + | '{' (keyValue (',' keyValue)* ','?)? '}' # dictDecl + | '(' expression ')' # primary + | expression '[' expression ']' # subscription + | expression '.' IDENTIFIER # attribute + | expression '(' argList? ')' # call + | '.' IDENTIFIER '(' argList? ')' # call + | '$' (STRING | IDENTIFIER ('/' IDENTIFIER)*) # getNode + | expression 'is' (IDENTIFIER | BUILTINTYPE) # is + | '~' expression # bitNot + | ('-' | '+') expression # sign + | expression ('*' | '/' | '%') expression # factor + | expression '+' expression # plus + | expression '-' expression # minus + | expression ('<<' | '>>') expression # bitShift + | expression '&' expression # bitAnd + | expression '^' expression # bitXor + | expression '|' expression # bitOr + | expression ('<' | '>' | '<=' | '>=' | '==' | '!=') expression # comparison + | expression 'in' expression # in + | ('!' | 'not') expression # logicNot + | expression ('and' | '&&') expression # logicAnd + | expression ('or' | '||') expression # logicOr + | expression 'if' expression 'else' expression # ternacyExpr + | expression 'as' typeHint # cast + ; literal - : STRING - | INTEGER - | FLOAT - | IDENTIFIER - | BUILTINTYPE - | CONSTANT - ; + : STRING + | INTEGER + | FLOAT + | IDENTIFIER + | BUILTINTYPE + | CONSTANT + ; keyValue - : expression ':' expression - | IDENTIFIER '=' expression - ; + : expression ':' expression + | IDENTIFIER '=' expression + ; \ No newline at end of file diff --git a/gedcom/gedcom.g4 b/gedcom/gedcom.g4 index 10d483ade9..b7d67b0b31 100644 --- a/gedcom/gedcom.g4 +++ b/gedcom/gedcom.g4 @@ -32,110 +32,112 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // http://user.it.uu.se/~andersa/gedcom/ch1.html +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar gedcom; gedcom - : line+ EOF - ; + : line+ EOF + ; line - : level opt_xref_id? tag line_value? EOL - ; + : level opt_xref_id? tag line_value? EOL + ; level - : DIGIT+ - ; + : DIGIT+ + ; opt_xref_id - : pointer - ; + : pointer + ; tag - : alphanum+ - ; + : alphanum+ + ; line_value - : line_item+ - ; + : line_item+ + ; line_item - : pointer - | escape - | anychar - ; + : pointer + | escape + | anychar + ; escape - : '@' '#' escape_text '@' non_at - ; + : '@' '#' escape_text '@' non_at + ; non_at - : ALPHA - | DIGIT - | otherchar - | '#' - ; + : ALPHA + | DIGIT + | otherchar + | '#' + ; escape_text - : anychar+ - ; + : anychar+ + ; pointer - : '@' alphanum pointer_string '@' - ; + : '@' alphanum pointer_string '@' + ; pointer_string - : pointer_char+ - ; + : pointer_char+ + ; pointer_char - : ALPHA - | DIGIT - | otherchar - | '#' - ; + : ALPHA + | DIGIT + | otherchar + | '#' + ; alphanum - : ALPHA - | DIGIT - ; + : ALPHA + | DIGIT + ; anychar - : ALPHA - | DIGIT - | otherchar - | '#' - | '@@' - ; + : ALPHA + | DIGIT + | otherchar + | '#' + | '@@' + ; ALPHA - : [a-zA-Z_] - ; + : [a-zA-Z_] + ; DIGIT - : [0-9] - ; + : [0-9] + ; otherchar - : '!' - | '"' - | '$' - | '&' - | '\'' - | '(' - | ')' - | '*' - | '+' - | '-' - | ',' - | '.' - | '/' - ; + : '!' + | '"' + | '$' + | '&' + | '\'' + | '(' + | ')' + | '*' + | '+' + | '-' + | ',' + | '.' + | '/' + ; EOL - : [\r\n]+ - ; + : [\r\n]+ + ; WS - : [ \t] -> skip - ; - + : [ \t] -> skip + ; \ No newline at end of file diff --git a/gff3/gff3.g4 b/gff3/gff3.g4 index d3d8c9580d..9ac518a001 100644 --- a/gff3/gff3.g4 +++ b/gff3/gff3.g4 @@ -30,89 +30,106 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar gff3; document - : HEADER line+ EOF - ; + : HEADER line+ EOF + ; line - : commentline - | dataline - ; + : commentline + | dataline + ; dataline - : seqid '\t' source '\t' type_ '\t' start '\t' end '\t' score '\t' strand '\t' phase '\t' attributes? EOL - ; + : seqid '\t' source '\t' type_ '\t' start '\t' end '\t' score '\t' strand '\t' phase '\t' attributes? EOL + ; attributes - : attribute (';' attribute)* - ; + : attribute (';' attribute)* + ; attribute - : TEXT '=' TEXT - ; + : TEXT '=' TEXT + ; seqid - : TEXT - ; + : TEXT + ; source - : TEXT - ; + : TEXT + ; type_ - : TEXT - ; + : TEXT + ; start - : TEXT - ; + : TEXT + ; end - : TEXT - ; + : TEXT + ; strand - : TEXT - ; + : TEXT + ; score - : TEXT - ; + : TEXT + ; phase - : TEXT - ; + : TEXT + ; commentline - : COMMENTLINE - ; + : COMMENTLINE + ; HEADER - : '##gff-version 3' EOL - ; + : '##gff-version 3' EOL + ; COMMENTLINE - : '#' .*? EOL - ; + : '#' .*? EOL + ; EOL - : '\r'? '\n' - ; + : '\r'? '\n' + ; TEXT - : (CHAR | SYMBOL | DIGIT)+ - ; + : (CHAR | SYMBOL | DIGIT)+ + ; fragment CHAR - : [a-zA-Z] - ; + : [a-zA-Z] + ; fragment DIGIT - : [0-9] - ; + : [0-9] + ; fragment SYMBOL - : '.' | ':' | '^' | '*' | '$' | '@' | '%' | '!' | '+' | '_' | '?' | '-' | '|' | ',' | ' ' - ; + : '.' + | ':' + | '^' + | '*' + | '$' + | '@' + | '%' + | '!' + | '+' + | '_' + | '?' + | '-' + | '|' + | ',' + | ' ' + ; \ No newline at end of file diff --git a/glsl/GLSLLexer.g4 b/glsl/GLSLLexer.g4 index 87ee1d145a..b8a139e7e7 100644 --- a/glsl/GLSLLexer.g4 +++ b/glsl/GLSLLexer.g4 @@ -22,366 +22,381 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar GLSLLexer; -channels { COMMENTS , DIRECTIVES } +channels { + COMMENTS, + DIRECTIVES +} -ATOMIC_UINT : 'atomic_uint' ; -ATTRIBUTE : 'attribute' ; -BOOL : 'bool' ; -BREAK : 'break' ; -BUFFER : 'buffer' ; -BVEC2 : 'bvec2' ; -BVEC3 : 'bvec3' ; -BVEC4 : 'bvec4' ; -CASE : 'case' ; -CENTROID : 'centroid' ; -COHERENT : 'coherent' ; -CONST : 'const' ; -CONTINUE : 'continue' ; -DEFAULT : 'default' ; -DISCARD : 'discard' ; -DMAT2 : 'dmat2' ; -DMAT2X2 : 'dmat2x2' ; -DMAT2X3 : 'dmat2x3' ; -DMAT2X4 : 'dmat2x4' ; -DMAT3 : 'dmat3' ; -DMAT3X2 : 'dmat3x2' ; -DMAT3X3 : 'dmat3x3' ; -DMAT3X4 : 'dmat3x4' ; -DMAT4 : 'dmat4' ; -DMAT4X2 : 'dmat4x2' ; -DMAT4X3 : 'dmat4x3' ; -DMAT4X4 : 'dmat4x4' ; -DO : 'do' ; -DOUBLE : 'double' ; -DVEC2 : 'dvec2' ; -DVEC3 : 'dvec3' ; -DVEC4 : 'dvec4' ; -ELSE : 'else' ; -FALSE : 'false' ; -FLAT : 'flat' ; -FLOAT : 'float' ; -FOR : 'for' ; -HIGHP : 'highp' ; -IF : 'if' ; -IIMAGE1D : 'iimage1D' ; -IIMAGE1DARRAY : 'iimage1DArray' ; -IIMAGE2D : 'iimage2D' ; -IIMAGE2DARRAY : 'iimage2DArray' ; -IIMAGE2DMS : 'iimage2DMS' ; -IIMAGE2DMSARRAY : 'iimage2DMSArray' ; -IIMAGE2DRECT : 'iimage2DRect' ; -IIMAGE3D : 'iimage3D' ; -IIMAGEBUFFER : 'iimageBuffer' ; -IIMAGECUBE : 'iimageCube' ; -IIMAGECUBEARRAY : 'iimageCubeArray' ; -IMAGE1D : 'image1D' ; -IMAGE1DARRAY : 'image1DArray' ; -IMAGE2D : 'image2D' ; -IMAGE2DARRAY : 'image2DArray' ; -IMAGE2DMS : 'image2DMS' ; -IMAGE2DMSARRAY : 'image2DMSArray' ; -IMAGE2DRECT : 'image2DRect' ; -IMAGE3D : 'image3D' ; -IMAGEBUFFER : 'imageBuffer' ; -IMAGECUBE : 'imageCube' ; -IMAGECUBEARRAY : 'imageCubeArray' ; -IN : 'in' ; -INOUT : 'inout' ; -INT : 'int' ; -INVARIANT : 'invariant' ; -ISAMPLER1D : 'isampler1D' ; -ISAMPLER1DARRAY : 'isampler1DArray' ; -ISAMPLER2D : 'isampler2D' ; -ISAMPLER2DARRAY : 'isampler2DArray' ; -ISAMPLER2DMS : 'isampler2DMS' ; -ISAMPLER2DMSARRAY : 'isampler2DMSArray' ; -ISAMPLER2DRECT : 'isampler2DRect' ; -ISAMPLER3D : 'isampler3D' ; -ISAMPLERBUFFER : 'isamplerBuffer' ; -ISAMPLERCUBE : 'isamplerCube' ; -ISAMPLERCUBEARRAY : 'isamplerCubeArray' ; -ISUBPASSINPUT : 'isubpassInput' ; -ISUBPASSINPUTMS : 'isubpassInputMS' ; -ITEXTURE1D : 'itexture1D' ; -ITEXTURE1DARRAY : 'itexture1DArray' ; -ITEXTURE2D : 'itexture2D' ; -ITEXTURE2DARRAY : 'itexture2DArray' ; -ITEXTURE2DMS : 'itexture2DMS' ; -ITEXTURE2DMSARRAY : 'itexture2DMSArray' ; -ITEXTURE2DRECT : 'itexture2DRect' ; -ITEXTURE3D : 'itexture3D' ; -ITEXTUREBUFFER : 'itextureBuffer' ; -ITEXTURECUBE : 'itextureCube' ; -ITEXTURECUBEARRAY : 'itextureCubeArray' ; -IVEC2 : 'ivec2' ; -IVEC3 : 'ivec3' ; -IVEC4 : 'ivec4' ; -LAYOUT : 'layout' ; -LOWP : 'lowp' ; -MAT2 : 'mat2' ; -MAT2X2 : 'mat2x2' ; -MAT2X3 : 'mat2x3' ; -MAT2X4 : 'mat2x4' ; -MAT3 : 'mat3' ; -MAT3X2 : 'mat3x2' ; -MAT3X3 : 'mat3x3' ; -MAT3X4 : 'mat3x4' ; -MAT4 : 'mat4' ; -MAT4X2 : 'mat4x2' ; -MAT4X3 : 'mat4x3' ; -MAT4X4 : 'mat4x4' ; -MEDIUMP : 'mediump' ; -NOPERSPECTIVE : 'noperspective' ; -OUT : 'out' ; -PATCH : 'patch' ; -PRECISE : 'precise' ; -PRECISION : 'precision' ; -READONLY : 'readonly' ; -RESTRICT : 'restrict' ; -RETURN : 'return' ; -SAMPLE : 'sample' ; -SAMPLER : 'sampler' ; -SAMPLER1D : 'sampler1D' ; -SAMPLER1DARRAY : 'sampler1DArray' ; -SAMPLER1DARRAYSHADOW : 'sampler1DArrayShadow' ; -SAMPLER1DSHADOW : 'sampler1DShadow' ; -SAMPLER2D : 'sampler2D' ; -SAMPLER2DARRAY : 'sampler2DArray' ; -SAMPLER2DARRAYSHADOW : 'sampler2DArrayShadow' ; -SAMPLER2DMS : 'sampler2DMS' ; -SAMPLER2DMSARRAY : 'sampler2DMSArray' ; -SAMPLER2DRECT : 'sampler2DRect' ; -SAMPLER2DRECTSHADOW : 'sampler2DRectShadow' ; -SAMPLER2DSHADOW : 'sampler2DShadow' ; -SAMPLER3D : 'sampler3D' ; -SAMPLERBUFFER : 'samplerBuffer' ; -SAMPLERCUBE : 'samplerCube' ; -SAMPLERCUBEARRAY : 'samplerCubeArray' ; -SAMPLERCUBEARRAYSHADOW : 'samplerCubeArrayShadow' ; -SAMPLERCUBESHADOW : 'samplerCubeShadow' ; -SAMPLERSHADOW : 'samplerShadow' ; -SHARED : 'shared' ; -SMOOTH : 'smooth' ; -STRUCT : 'struct' ; -SUBPASSINPUT : 'subpassInput' ; -SUBPASSINPUTMS : 'subpassInputMS' ; -SUBROUTINE : 'subroutine' ; -SWITCH : 'switch' ; -TEXTURE1D : 'texture1D' ; -TEXTURE1DARRAY : 'texture1DArray' ; -TEXTURE2D : 'texture2D' ; -TEXTURE2DARRAY : 'texture2DArray' ; -TEXTURE2DMS : 'texture2DMS' ; -TEXTURE2DMSARRAY : 'texture2DMSArray' ; -TEXTURE2DRECT : 'texture2DRect' ; -TEXTURE3D : 'texture3D' ; -TEXTUREBUFFER : 'textureBuffer' ; -TEXTURECUBE : 'textureCube' ; -TEXTURECUBEARRAY : 'textureCubeArray' ; -TRUE : 'true' ; -UIMAGE1D : 'uimage1D' ; -UIMAGE1DARRAY : 'uimage1DArray' ; -UIMAGE2D : 'uimage2D' ; -UIMAGE2DARRAY : 'uimage2DArray' ; -UIMAGE2DMS : 'uimage2DMS' ; -UIMAGE2DMSARRAY : 'uimage2DMSArray' ; -UIMAGE2DRECT : 'uimage2DRect' ; -UIMAGE3D : 'uimage3D' ; -UIMAGEBUFFER : 'uimageBuffer' ; -UIMAGECUBE : 'uimageCube' ; -UIMAGECUBEARRAY : 'uimageCubeArray' ; -UINT : 'uint' ; -UNIFORM : 'uniform' ; -USAMPLER1D : 'usampler1D' ; -USAMPLER1DARRAY : 'usampler1DArray' ; -USAMPLER2D : 'usampler2D' ; -USAMPLER2DARRAY : 'usampler2DArray' ; -USAMPLER2DMS : 'usampler2DMS' ; -USAMPLER2DMSARRAY : 'usampler2DMSArray' ; -USAMPLER2DRECT : 'usampler2DRect' ; -USAMPLER3D : 'usampler3D' ; -USAMPLERBUFFER : 'usamplerBuffer' ; -USAMPLERCUBE : 'usamplerCube' ; -USAMPLERCUBEARRAY : 'usamplerCubeArray' ; -USUBPASSINPUT : 'usubpassInput' ; -USUBPASSINPUTMS : 'usubpassInputMS' ; -UTEXTURE1D : 'utexture1D' ; -UTEXTURE1DARRAY : 'utexture1DArray' ; -UTEXTURE2D : 'utexture2D' ; -UTEXTURE2DARRAY : 'utexture2DArray' ; -UTEXTURE2DMS : 'utexture2DMS' ; -UTEXTURE2DMSARRAY : 'utexture2DMSArray' ; -UTEXTURE2DRECT : 'utexture2DRect' ; -UTEXTURE3D : 'utexture3D' ; -UTEXTUREBUFFER : 'utextureBuffer' ; -UTEXTURECUBE : 'utextureCube' ; -UTEXTURECUBEARRAY : 'utextureCubeArray' ; -UVEC2 : 'uvec2' ; -UVEC3 : 'uvec3' ; -UVEC4 : 'uvec4' ; -VARYING : 'varying' ; -VEC2 : 'vec2' ; -VEC3 : 'vec3' ; -VEC4 : 'vec4' ; -VOID : 'void' ; -VOLATILE : 'volatile' ; -WHILE : 'while' ; -WRITEONLY : 'writeonly' ; +ATOMIC_UINT : 'atomic_uint'; +ATTRIBUTE : 'attribute'; +BOOL : 'bool'; +BREAK : 'break'; +BUFFER : 'buffer'; +BVEC2 : 'bvec2'; +BVEC3 : 'bvec3'; +BVEC4 : 'bvec4'; +CASE : 'case'; +CENTROID : 'centroid'; +COHERENT : 'coherent'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DISCARD : 'discard'; +DMAT2 : 'dmat2'; +DMAT2X2 : 'dmat2x2'; +DMAT2X3 : 'dmat2x3'; +DMAT2X4 : 'dmat2x4'; +DMAT3 : 'dmat3'; +DMAT3X2 : 'dmat3x2'; +DMAT3X3 : 'dmat3x3'; +DMAT3X4 : 'dmat3x4'; +DMAT4 : 'dmat4'; +DMAT4X2 : 'dmat4x2'; +DMAT4X3 : 'dmat4x3'; +DMAT4X4 : 'dmat4x4'; +DO : 'do'; +DOUBLE : 'double'; +DVEC2 : 'dvec2'; +DVEC3 : 'dvec3'; +DVEC4 : 'dvec4'; +ELSE : 'else'; +FALSE : 'false'; +FLAT : 'flat'; +FLOAT : 'float'; +FOR : 'for'; +HIGHP : 'highp'; +IF : 'if'; +IIMAGE1D : 'iimage1D'; +IIMAGE1DARRAY : 'iimage1DArray'; +IIMAGE2D : 'iimage2D'; +IIMAGE2DARRAY : 'iimage2DArray'; +IIMAGE2DMS : 'iimage2DMS'; +IIMAGE2DMSARRAY : 'iimage2DMSArray'; +IIMAGE2DRECT : 'iimage2DRect'; +IIMAGE3D : 'iimage3D'; +IIMAGEBUFFER : 'iimageBuffer'; +IIMAGECUBE : 'iimageCube'; +IIMAGECUBEARRAY : 'iimageCubeArray'; +IMAGE1D : 'image1D'; +IMAGE1DARRAY : 'image1DArray'; +IMAGE2D : 'image2D'; +IMAGE2DARRAY : 'image2DArray'; +IMAGE2DMS : 'image2DMS'; +IMAGE2DMSARRAY : 'image2DMSArray'; +IMAGE2DRECT : 'image2DRect'; +IMAGE3D : 'image3D'; +IMAGEBUFFER : 'imageBuffer'; +IMAGECUBE : 'imageCube'; +IMAGECUBEARRAY : 'imageCubeArray'; +IN : 'in'; +INOUT : 'inout'; +INT : 'int'; +INVARIANT : 'invariant'; +ISAMPLER1D : 'isampler1D'; +ISAMPLER1DARRAY : 'isampler1DArray'; +ISAMPLER2D : 'isampler2D'; +ISAMPLER2DARRAY : 'isampler2DArray'; +ISAMPLER2DMS : 'isampler2DMS'; +ISAMPLER2DMSARRAY : 'isampler2DMSArray'; +ISAMPLER2DRECT : 'isampler2DRect'; +ISAMPLER3D : 'isampler3D'; +ISAMPLERBUFFER : 'isamplerBuffer'; +ISAMPLERCUBE : 'isamplerCube'; +ISAMPLERCUBEARRAY : 'isamplerCubeArray'; +ISUBPASSINPUT : 'isubpassInput'; +ISUBPASSINPUTMS : 'isubpassInputMS'; +ITEXTURE1D : 'itexture1D'; +ITEXTURE1DARRAY : 'itexture1DArray'; +ITEXTURE2D : 'itexture2D'; +ITEXTURE2DARRAY : 'itexture2DArray'; +ITEXTURE2DMS : 'itexture2DMS'; +ITEXTURE2DMSARRAY : 'itexture2DMSArray'; +ITEXTURE2DRECT : 'itexture2DRect'; +ITEXTURE3D : 'itexture3D'; +ITEXTUREBUFFER : 'itextureBuffer'; +ITEXTURECUBE : 'itextureCube'; +ITEXTURECUBEARRAY : 'itextureCubeArray'; +IVEC2 : 'ivec2'; +IVEC3 : 'ivec3'; +IVEC4 : 'ivec4'; +LAYOUT : 'layout'; +LOWP : 'lowp'; +MAT2 : 'mat2'; +MAT2X2 : 'mat2x2'; +MAT2X3 : 'mat2x3'; +MAT2X4 : 'mat2x4'; +MAT3 : 'mat3'; +MAT3X2 : 'mat3x2'; +MAT3X3 : 'mat3x3'; +MAT3X4 : 'mat3x4'; +MAT4 : 'mat4'; +MAT4X2 : 'mat4x2'; +MAT4X3 : 'mat4x3'; +MAT4X4 : 'mat4x4'; +MEDIUMP : 'mediump'; +NOPERSPECTIVE : 'noperspective'; +OUT : 'out'; +PATCH : 'patch'; +PRECISE : 'precise'; +PRECISION : 'precision'; +READONLY : 'readonly'; +RESTRICT : 'restrict'; +RETURN : 'return'; +SAMPLE : 'sample'; +SAMPLER : 'sampler'; +SAMPLER1D : 'sampler1D'; +SAMPLER1DARRAY : 'sampler1DArray'; +SAMPLER1DARRAYSHADOW : 'sampler1DArrayShadow'; +SAMPLER1DSHADOW : 'sampler1DShadow'; +SAMPLER2D : 'sampler2D'; +SAMPLER2DARRAY : 'sampler2DArray'; +SAMPLER2DARRAYSHADOW : 'sampler2DArrayShadow'; +SAMPLER2DMS : 'sampler2DMS'; +SAMPLER2DMSARRAY : 'sampler2DMSArray'; +SAMPLER2DRECT : 'sampler2DRect'; +SAMPLER2DRECTSHADOW : 'sampler2DRectShadow'; +SAMPLER2DSHADOW : 'sampler2DShadow'; +SAMPLER3D : 'sampler3D'; +SAMPLERBUFFER : 'samplerBuffer'; +SAMPLERCUBE : 'samplerCube'; +SAMPLERCUBEARRAY : 'samplerCubeArray'; +SAMPLERCUBEARRAYSHADOW : 'samplerCubeArrayShadow'; +SAMPLERCUBESHADOW : 'samplerCubeShadow'; +SAMPLERSHADOW : 'samplerShadow'; +SHARED : 'shared'; +SMOOTH : 'smooth'; +STRUCT : 'struct'; +SUBPASSINPUT : 'subpassInput'; +SUBPASSINPUTMS : 'subpassInputMS'; +SUBROUTINE : 'subroutine'; +SWITCH : 'switch'; +TEXTURE1D : 'texture1D'; +TEXTURE1DARRAY : 'texture1DArray'; +TEXTURE2D : 'texture2D'; +TEXTURE2DARRAY : 'texture2DArray'; +TEXTURE2DMS : 'texture2DMS'; +TEXTURE2DMSARRAY : 'texture2DMSArray'; +TEXTURE2DRECT : 'texture2DRect'; +TEXTURE3D : 'texture3D'; +TEXTUREBUFFER : 'textureBuffer'; +TEXTURECUBE : 'textureCube'; +TEXTURECUBEARRAY : 'textureCubeArray'; +TRUE : 'true'; +UIMAGE1D : 'uimage1D'; +UIMAGE1DARRAY : 'uimage1DArray'; +UIMAGE2D : 'uimage2D'; +UIMAGE2DARRAY : 'uimage2DArray'; +UIMAGE2DMS : 'uimage2DMS'; +UIMAGE2DMSARRAY : 'uimage2DMSArray'; +UIMAGE2DRECT : 'uimage2DRect'; +UIMAGE3D : 'uimage3D'; +UIMAGEBUFFER : 'uimageBuffer'; +UIMAGECUBE : 'uimageCube'; +UIMAGECUBEARRAY : 'uimageCubeArray'; +UINT : 'uint'; +UNIFORM : 'uniform'; +USAMPLER1D : 'usampler1D'; +USAMPLER1DARRAY : 'usampler1DArray'; +USAMPLER2D : 'usampler2D'; +USAMPLER2DARRAY : 'usampler2DArray'; +USAMPLER2DMS : 'usampler2DMS'; +USAMPLER2DMSARRAY : 'usampler2DMSArray'; +USAMPLER2DRECT : 'usampler2DRect'; +USAMPLER3D : 'usampler3D'; +USAMPLERBUFFER : 'usamplerBuffer'; +USAMPLERCUBE : 'usamplerCube'; +USAMPLERCUBEARRAY : 'usamplerCubeArray'; +USUBPASSINPUT : 'usubpassInput'; +USUBPASSINPUTMS : 'usubpassInputMS'; +UTEXTURE1D : 'utexture1D'; +UTEXTURE1DARRAY : 'utexture1DArray'; +UTEXTURE2D : 'utexture2D'; +UTEXTURE2DARRAY : 'utexture2DArray'; +UTEXTURE2DMS : 'utexture2DMS'; +UTEXTURE2DMSARRAY : 'utexture2DMSArray'; +UTEXTURE2DRECT : 'utexture2DRect'; +UTEXTURE3D : 'utexture3D'; +UTEXTUREBUFFER : 'utextureBuffer'; +UTEXTURECUBE : 'utextureCube'; +UTEXTURECUBEARRAY : 'utextureCubeArray'; +UVEC2 : 'uvec2'; +UVEC3 : 'uvec3'; +UVEC4 : 'uvec4'; +VARYING : 'varying'; +VEC2 : 'vec2'; +VEC3 : 'vec3'; +VEC4 : 'vec4'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; +WRITEONLY : 'writeonly'; -ADD_ASSIGN : '+=' ; -AMPERSAND : '&' ; -AND_ASSIGN : '&=' ; -AND_OP : '&&' ; -BANG : '!' ; -CARET : '^' ; -COLON : ':' ; -COMMA : ',' ; -DASH : '-' ; -DEC_OP : '--' ; -DIV_ASSIGN : '/=' ; -DOT : '.' ; -EQ_OP : '==' ; -EQUAL : '=' ; -GE_OP : '>=' ; -INC_OP : '++' ; -LE_OP : '<=' ; -LEFT_ANGLE : '<' ; -LEFT_ASSIGN : '<<=' ; -LEFT_BRACE : '{' ; -LEFT_BRACKET : '[' ; -LEFT_OP : '<<' ; -LEFT_PAREN : '(' ; -MOD_ASSIGN : '%=' ; -MUL_ASSIGN : '*=' ; -NE_OP : '!=' ; -NUMBER_SIGN : '#' -> channel (DIRECTIVES) , pushMode (DIRECTIVE_MODE) ; -OR_ASSIGN : '|=' ; -OR_OP : '||' ; -PERCENT : '%' ; -PLUS : '+' ; -QUESTION : '?' ; -RIGHT_ANGLE : '>' ; -RIGHT_ASSIGN : '>>=' ; -RIGHT_BRACE : '}' ; -RIGHT_BRACKET : ']' ; -RIGHT_OP : '>>' ; -RIGHT_PAREN : ')' ; -SEMICOLON : ';' ; -SLASH : '/' ; -STAR : '*' ; -SUB_ASSIGN : '-=' ; -TILDE : '~' ; -VERTICAL_BAR : '|' ; -XOR_ASSIGN : '^=' ; -XOR_OP : '^^' ; +ADD_ASSIGN : '+='; +AMPERSAND : '&'; +AND_ASSIGN : '&='; +AND_OP : '&&'; +BANG : '!'; +CARET : '^'; +COLON : ':'; +COMMA : ','; +DASH : '-'; +DEC_OP : '--'; +DIV_ASSIGN : '/='; +DOT : '.'; +EQ_OP : '=='; +EQUAL : '='; +GE_OP : '>='; +INC_OP : '++'; +LE_OP : '<='; +LEFT_ANGLE : '<'; +LEFT_ASSIGN : '<<='; +LEFT_BRACE : '{'; +LEFT_BRACKET : '['; +LEFT_OP : '<<'; +LEFT_PAREN : '('; +MOD_ASSIGN : '%='; +MUL_ASSIGN : '*='; +NE_OP : '!='; +NUMBER_SIGN : '#' -> channel (DIRECTIVES), pushMode (DIRECTIVE_MODE); +OR_ASSIGN : '|='; +OR_OP : '||'; +PERCENT : '%'; +PLUS : '+'; +QUESTION : '?'; +RIGHT_ANGLE : '>'; +RIGHT_ASSIGN : '>>='; +RIGHT_BRACE : '}'; +RIGHT_BRACKET : ']'; +RIGHT_OP : '>>'; +RIGHT_PAREN : ')'; +SEMICOLON : ';'; +SLASH : '/'; +STAR : '*'; +SUB_ASSIGN : '-='; +TILDE : '~'; +VERTICAL_BAR : '|'; +XOR_ASSIGN : '^='; +XOR_OP : '^^'; -DOUBLECONSTANT : FRACTIONAL_CONSTANT EXPONENT_PART? DOUBLE_SUFFIX | DIGIT_SEQUENCE EXPONENT_PART DOUBLE_SUFFIX ; -FLOATCONSTANT : FRACTIONAL_CONSTANT EXPONENT_PART? FLOAT_SUFFIX? | DIGIT_SEQUENCE EXPONENT_PART FLOAT_SUFFIX? ; -INTCONSTANT : DECIMAL_CONSTANT | HEX_CONSTANT | OCTAL_CONSTANT ; -UINTCONSTANT : INTCONSTANT INTEGER_SUFFIX ; -BLOCK_COMMENT : '/*' .*? '*/' -> channel (COMMENTS) ; -LINE_COMMENT : '//' (~ [\r\n\\] | '\\' (NEWLINE | .))* -> channel (COMMENTS) ; -LINE_CONTINUATION : '\\' NEWLINE -> channel (HIDDEN) ; -IDENTIFIER : [a-zA-Z_] [a-zA-Z0-9_]* ; -WHITE_SPACE : [ \t\r\n]+ -> channel (HIDDEN) ; +DOUBLECONSTANT: + FRACTIONAL_CONSTANT EXPONENT_PART? DOUBLE_SUFFIX + | DIGIT_SEQUENCE EXPONENT_PART DOUBLE_SUFFIX +; +FLOATCONSTANT: + FRACTIONAL_CONSTANT EXPONENT_PART? FLOAT_SUFFIX? + | DIGIT_SEQUENCE EXPONENT_PART FLOAT_SUFFIX? +; +INTCONSTANT : DECIMAL_CONSTANT | HEX_CONSTANT | OCTAL_CONSTANT; +UINTCONSTANT : INTCONSTANT INTEGER_SUFFIX; +BLOCK_COMMENT : '/*' .*? '*/' -> channel (COMMENTS); +LINE_COMMENT : '//' (~ [\r\n\\] | '\\' (NEWLINE | .))* -> channel (COMMENTS); +LINE_CONTINUATION : '\\' NEWLINE -> channel (HIDDEN); +IDENTIFIER : [a-zA-Z_] [a-zA-Z0-9_]*; +WHITE_SPACE : [ \t\r\n]+ -> channel (HIDDEN); mode DIRECTIVE_MODE; -DEFINE_DIRECTIVE : 'define' -> channel (DIRECTIVES) , mode (DEFINE_DIRECTIVE_MODE) ; -ELIF_DIRECTIVE : 'elif' -> channel (DIRECTIVES) , popMode , mode (ELIF_DIRECTIVE_MODE) ; -ELSE_DIRECTIVE : 'else' -> channel (DIRECTIVES) , popMode , mode (PROGRAM_TEXT_MODE) ; -ENDIF_DIRECTIVE : 'endif' -> channel (DIRECTIVES) , popMode , popMode , popMode ; -ERROR_DIRECTIVE : 'error' -> channel (DIRECTIVES) , mode (ERROR_DIRECTIVE_MODE) ; -EXTENSION_DIRECTIVE : 'extension' -> channel (DIRECTIVES) , mode (EXTENSION_DIRECTIVE_MODE) ; -IF_DIRECTIVE : 'if' -> channel (DIRECTIVES) , mode (IF_DIRECTIVE_MODE) ; -IFDEF_DIRECTIVE : 'ifdef' -> channel (DIRECTIVES) , mode (IFDEF_DIRECTIVE_MODE) ; -IFNDEF_DIRECTIVE : 'ifndef' -> channel (DIRECTIVES) , mode (IFDEF_DIRECTIVE_MODE) ; -LINE_DIRECTIVE : 'line' -> channel (DIRECTIVES) , mode (LINE_DIRECTIVE_MODE) ; -PRAGMA_DIRECTIVE : 'pragma' -> channel (DIRECTIVES) , mode (PRAGMA_DIRECTIVE_MODE) ; -UNDEF_DIRECTIVE : 'undef' -> channel (DIRECTIVES) , mode (UNDEF_DIRECTIVE_MODE) ; -VERSION_DIRECTIVE : 'version' -> channel (DIRECTIVES) , mode (VERSION_DIRECTIVE_MODE) ; -SPACE_TAB_0 : SPACE_TAB -> skip ; -NEWLINE_0 : NEWLINE -> skip , popMode ; +DEFINE_DIRECTIVE : 'define' -> channel (DIRECTIVES), mode (DEFINE_DIRECTIVE_MODE); +ELIF_DIRECTIVE : 'elif' -> channel (DIRECTIVES), popMode, mode (ELIF_DIRECTIVE_MODE); +ELSE_DIRECTIVE : 'else' -> channel (DIRECTIVES), popMode, mode (PROGRAM_TEXT_MODE); +ENDIF_DIRECTIVE : 'endif' -> channel (DIRECTIVES), popMode, popMode, popMode; +ERROR_DIRECTIVE : 'error' -> channel (DIRECTIVES), mode (ERROR_DIRECTIVE_MODE); +EXTENSION_DIRECTIVE : 'extension' -> channel (DIRECTIVES), mode (EXTENSION_DIRECTIVE_MODE); +IF_DIRECTIVE : 'if' -> channel (DIRECTIVES), mode (IF_DIRECTIVE_MODE); +IFDEF_DIRECTIVE : 'ifdef' -> channel (DIRECTIVES), mode (IFDEF_DIRECTIVE_MODE); +IFNDEF_DIRECTIVE : 'ifndef' -> channel (DIRECTIVES), mode (IFDEF_DIRECTIVE_MODE); +LINE_DIRECTIVE : 'line' -> channel (DIRECTIVES), mode (LINE_DIRECTIVE_MODE); +PRAGMA_DIRECTIVE : 'pragma' -> channel (DIRECTIVES), mode (PRAGMA_DIRECTIVE_MODE); +UNDEF_DIRECTIVE : 'undef' -> channel (DIRECTIVES), mode (UNDEF_DIRECTIVE_MODE); +VERSION_DIRECTIVE : 'version' -> channel (DIRECTIVES), mode (VERSION_DIRECTIVE_MODE); +SPACE_TAB_0 : SPACE_TAB -> skip; +NEWLINE_0 : NEWLINE -> skip, popMode; mode DEFINE_DIRECTIVE_MODE; -MACRO_NAME : IDENTIFIER MACRO_ARGS? -> channel (DIRECTIVES) , mode (MACRO_TEXT_MODE) ; -NEWLINE_1 : NEWLINE -> skip , popMode ; -SPACE_TAB_1 : SPACE_TAB -> skip ; +MACRO_NAME : IDENTIFIER MACRO_ARGS? -> channel (DIRECTIVES), mode (MACRO_TEXT_MODE); +NEWLINE_1 : NEWLINE -> skip, popMode; +SPACE_TAB_1 : SPACE_TAB -> skip; mode ELIF_DIRECTIVE_MODE; -CONSTANT_EXPRESSION : ~ [\r\n]+ -> channel (DIRECTIVES) ; -NEWLINE_2 : NEWLINE -> skip , mode (PROGRAM_TEXT_MODE) ; +CONSTANT_EXPRESSION : ~ [\r\n]+ -> channel (DIRECTIVES); +NEWLINE_2 : NEWLINE -> skip, mode (PROGRAM_TEXT_MODE); mode ERROR_DIRECTIVE_MODE; -ERROR_MESSAGE : ~ [\r\n]+ -> channel (DIRECTIVES) ; -NEWLINE_3 : NEWLINE -> skip , popMode ; +ERROR_MESSAGE : ~ [\r\n]+ -> channel (DIRECTIVES); +NEWLINE_3 : NEWLINE -> skip, popMode; mode EXTENSION_DIRECTIVE_MODE; -BEHAVIOR : ('require' | 'enable' | 'warn' | 'disable') -> channel (DIRECTIVES) ; -COLON_0 : COLON -> channel (DIRECTIVES) , type (COLON) ; -EXTENSION_NAME : IDENTIFIER -> channel (DIRECTIVES) ; -NEWLINE_4 : NEWLINE -> skip , popMode ; -SPACE_TAB_2 : SPACE_TAB -> skip ; +BEHAVIOR : ('require' | 'enable' | 'warn' | 'disable') -> channel (DIRECTIVES); +COLON_0 : COLON -> channel (DIRECTIVES), type (COLON); +EXTENSION_NAME : IDENTIFIER -> channel (DIRECTIVES); +NEWLINE_4 : NEWLINE -> skip, popMode; +SPACE_TAB_2 : SPACE_TAB -> skip; mode IF_DIRECTIVE_MODE; -CONSTANT_EXPRESSION_0 : CONSTANT_EXPRESSION -> channel (DIRECTIVES) , type (CONSTANT_EXPRESSION) ; -NEWLINE_5 : NEWLINE -> skip , pushMode (PROGRAM_TEXT_MODE) ; +CONSTANT_EXPRESSION_0 : CONSTANT_EXPRESSION -> channel (DIRECTIVES), type (CONSTANT_EXPRESSION); +NEWLINE_5 : NEWLINE -> skip, pushMode (PROGRAM_TEXT_MODE); mode IFDEF_DIRECTIVE_MODE; -MACRO_IDENTIFIER : IDENTIFIER -> channel (DIRECTIVES) ; -NEWLINE_6 : NEWLINE -> skip , pushMode (PROGRAM_TEXT_MODE) ; -SPACE_TAB_3 : SPACE_TAB -> skip ; +MACRO_IDENTIFIER : IDENTIFIER -> channel (DIRECTIVES); +NEWLINE_6 : NEWLINE -> skip, pushMode (PROGRAM_TEXT_MODE); +SPACE_TAB_3 : SPACE_TAB -> skip; mode LINE_DIRECTIVE_MODE; -LINE_EXPRESSION : ~ [\r\n]+ -> channel (DIRECTIVES) ; -NEWLINE_7 : NEWLINE -> skip , mode (PROGRAM_TEXT_MODE) ; +LINE_EXPRESSION : ~ [\r\n]+ -> channel (DIRECTIVES); +NEWLINE_7 : NEWLINE -> skip, mode (PROGRAM_TEXT_MODE); mode MACRO_TEXT_MODE; -BLOCK_COMMENT_0 : BLOCK_COMMENT -> channel (COMMENTS) , type(BLOCK_COMMENT) ; -MACRO_ESC_NEWLINE : '\\' NEWLINE -> channel(DIRECTIVES) ; -MACRO_ESC_SEQUENCE : '\\' . -> channel(DIRECTIVES) , type (MACRO_TEXT) ; -MACRO_TEXT : ~ [/\r\n\\]+ -> channel (DIRECTIVES) ; -NEWLINE_8 : NEWLINE -> skip , popMode ; -SLASH_0 : SLASH -> more ; +BLOCK_COMMENT_0 : BLOCK_COMMENT -> channel (COMMENTS), type(BLOCK_COMMENT); +MACRO_ESC_NEWLINE : '\\' NEWLINE -> channel(DIRECTIVES); +MACRO_ESC_SEQUENCE : '\\' . -> channel(DIRECTIVES), type (MACRO_TEXT); +MACRO_TEXT : ~ [/\r\n\\]+ -> channel (DIRECTIVES); +NEWLINE_8 : NEWLINE -> skip, popMode; +SLASH_0 : SLASH -> more; mode PRAGMA_DIRECTIVE_MODE; -DEBUG : 'debug' -> channel (DIRECTIVES) ; -LEFT_PAREN_0 : LEFT_PAREN -> channel (DIRECTIVES) , type (LEFT_PAREN) ; -NEWLINE_9 : NEWLINE -> skip , popMode ; -OFF : 'off' -> channel (DIRECTIVES) ; -ON : 'on' -> channel (DIRECTIVES) ; -OPTIMIZE : 'optimize' -> channel (DIRECTIVES) ; -RIGHT_PAREN_0 : RIGHT_PAREN -> channel (DIRECTIVES) , type (RIGHT_PAREN) ; -SPACE_TAB_5 : SPACE_TAB -> skip ; -STDGL : 'STDGL' -> channel (DIRECTIVES) ; +DEBUG : 'debug' -> channel (DIRECTIVES); +LEFT_PAREN_0 : LEFT_PAREN -> channel (DIRECTIVES), type (LEFT_PAREN); +NEWLINE_9 : NEWLINE -> skip, popMode; +OFF : 'off' -> channel (DIRECTIVES); +ON : 'on' -> channel (DIRECTIVES); +OPTIMIZE : 'optimize' -> channel (DIRECTIVES); +RIGHT_PAREN_0 : RIGHT_PAREN -> channel (DIRECTIVES), type (RIGHT_PAREN); +SPACE_TAB_5 : SPACE_TAB -> skip; +STDGL : 'STDGL' -> channel (DIRECTIVES); mode PROGRAM_TEXT_MODE; -BLOCK_COMMENT_1 : BLOCK_COMMENT -> channel (COMMENTS) , type (BLOCK_COMMENT) ; -LINE_COMMENT_0 : LINE_COMMENT -> channel (COMMENTS) , type (LINE_COMMENT) ; -NUMBER_SIGN_0 : NUMBER_SIGN -> channel (DIRECTIVES) , type (NUMBER_SIGN) , pushMode (DIRECTIVE_MODE) ; -PROGRAM_TEXT : ~ [#/]+ -> channel (DIRECTIVES) ; -SLASH_1 : SLASH -> more ; +BLOCK_COMMENT_1 : BLOCK_COMMENT -> channel (COMMENTS), type (BLOCK_COMMENT); +LINE_COMMENT_0 : LINE_COMMENT -> channel (COMMENTS), type (LINE_COMMENT); +NUMBER_SIGN_0: + NUMBER_SIGN -> channel (DIRECTIVES), type (NUMBER_SIGN), pushMode (DIRECTIVE_MODE) +; +PROGRAM_TEXT : ~ [#/]+ -> channel (DIRECTIVES); +SLASH_1 : SLASH -> more; mode UNDEF_DIRECTIVE_MODE; -MACRO_IDENTIFIER_0 : MACRO_IDENTIFIER -> channel (DIRECTIVES) , type (MACRO_IDENTIFIER) ; -NEWLINE_10 : NEWLINE -> skip , popMode ; -SPACE_TAB_6 : SPACE_TAB -> skip ; +MACRO_IDENTIFIER_0 : MACRO_IDENTIFIER -> channel (DIRECTIVES), type (MACRO_IDENTIFIER); +NEWLINE_10 : NEWLINE -> skip, popMode; +SPACE_TAB_6 : SPACE_TAB -> skip; mode VERSION_DIRECTIVE_MODE; -NEWLINE_11 : NEWLINE -> skip , popMode ; -NUMBER : [0-9]+ -> channel (DIRECTIVES) ; -PROFILE : ('core' | 'compatibility' | 'es') -> channel (DIRECTIVES) ; -SPACE_TAB_7 : SPACE_TAB -> skip ; +NEWLINE_11 : NEWLINE -> skip, popMode; +NUMBER : [0-9]+ -> channel (DIRECTIVES); +PROFILE : ('core' | 'compatibility' | 'es') -> channel (DIRECTIVES); +SPACE_TAB_7 : SPACE_TAB -> skip; -fragment DECIMAL_CONSTANT : [1-9] [0-9]* ; -fragment DIGIT_SEQUENCE : [0-9]+ ; -fragment DOUBLE_SUFFIX : 'lf' | 'LF' ; -fragment EXPONENT_PART : [eE] [+\-]? DIGIT_SEQUENCE ; -fragment FLOAT_SUFFIX : [fF] ; -fragment FRACTIONAL_CONSTANT : '.' DIGIT_SEQUENCE | DIGIT_SEQUENCE '.' DIGIT_SEQUENCE? ; -fragment HEX_CONSTANT : '0' [xX] [0-9a-fA-F]+ ; -fragment INTEGER_SUFFIX : [uU] ; -fragment MACRO_ARGS : '(' (MACRO_ARGS | ~ [()])* ')' ; -fragment NEWLINE : '\r'? '\n' ; -fragment OCTAL_CONSTANT : '0' [0-7]* ; -fragment SPACE_TAB : [ \t]+ ; +fragment DECIMAL_CONSTANT : [1-9] [0-9]*; +fragment DIGIT_SEQUENCE : [0-9]+; +fragment DOUBLE_SUFFIX : 'lf' | 'LF'; +fragment EXPONENT_PART : [eE] [+\-]? DIGIT_SEQUENCE; +fragment FLOAT_SUFFIX : [fF]; +fragment FRACTIONAL_CONSTANT : '.' DIGIT_SEQUENCE | DIGIT_SEQUENCE '.' DIGIT_SEQUENCE?; +fragment HEX_CONSTANT : '0' [xX] [0-9a-fA-F]+; +fragment INTEGER_SUFFIX : [uU]; +fragment MACRO_ARGS : '(' (MACRO_ARGS | ~ [()])* ')'; +fragment NEWLINE : '\r'? '\n'; +fragment OCTAL_CONSTANT : '0' [0-7]*; +fragment SPACE_TAB : [ \t]+; \ No newline at end of file diff --git a/glsl/GLSLParser.g4 b/glsl/GLSLParser.g4 index 623821db3c..4630491785 100644 --- a/glsl/GLSLParser.g4 +++ b/glsl/GLSLParser.g4 @@ -22,434 +22,510 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 GLSLParser; -options { tokenVocab = GLSLLexer; } + +options { + tokenVocab = GLSLLexer; +} translation_unit - : external_declaration* EOF - ; + : external_declaration* EOF + ; + variable_identifier - : IDENTIFIER - ; + : IDENTIFIER + ; + primary_expression - : variable_identifier - | TRUE - | FALSE - | INTCONSTANT - | UINTCONSTANT - | FLOATCONSTANT - | DOUBLECONSTANT - | LEFT_PAREN expression RIGHT_PAREN - ; + : variable_identifier + | TRUE + | FALSE + | INTCONSTANT + | UINTCONSTANT + | FLOATCONSTANT + | DOUBLECONSTANT + | LEFT_PAREN expression RIGHT_PAREN + ; + postfix_expression - : primary_expression - | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET - | postfix_expression LEFT_PAREN function_call_parameters? RIGHT_PAREN - | type_specifier LEFT_PAREN function_call_parameters? RIGHT_PAREN - | postfix_expression DOT field_selection - | postfix_expression INC_OP - | postfix_expression DEC_OP - ; + : primary_expression + | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET + | postfix_expression LEFT_PAREN function_call_parameters? RIGHT_PAREN + | type_specifier LEFT_PAREN function_call_parameters? RIGHT_PAREN + | postfix_expression DOT field_selection + | postfix_expression INC_OP + | postfix_expression DEC_OP + ; + field_selection - : variable_identifier - | function_call - ; + : variable_identifier + | function_call + ; + integer_expression - : expression - ; + : expression + ; + function_call - : function_identifier LEFT_PAREN function_call_parameters? RIGHT_PAREN - ; + : function_identifier LEFT_PAREN function_call_parameters? RIGHT_PAREN + ; + function_identifier - : type_specifier - | postfix_expression - ; + : type_specifier + | postfix_expression + ; + function_call_parameters - : assignment_expression (COMMA assignment_expression)* - | VOID - ; + : assignment_expression (COMMA assignment_expression)* + | VOID + ; + unary_expression - : postfix_expression - | INC_OP unary_expression - | DEC_OP unary_expression - | unary_operator unary_expression - ; + : postfix_expression + | INC_OP unary_expression + | DEC_OP unary_expression + | unary_operator unary_expression + ; + unary_operator - : PLUS - | DASH - | BANG - | TILDE - ; + : PLUS + | DASH + | BANG + | TILDE + ; + assignment_expression - : constant_expression - | unary_expression assignment_operator assignment_expression - ; + : constant_expression + | unary_expression assignment_operator assignment_expression + ; + assignment_operator - : EQUAL - | MUL_ASSIGN - | DIV_ASSIGN - | MOD_ASSIGN - | ADD_ASSIGN - | SUB_ASSIGN - | LEFT_ASSIGN - | RIGHT_ASSIGN - | AND_ASSIGN - | XOR_ASSIGN - | OR_ASSIGN - ; + : EQUAL + | MUL_ASSIGN + | DIV_ASSIGN + | MOD_ASSIGN + | ADD_ASSIGN + | SUB_ASSIGN + | LEFT_ASSIGN + | RIGHT_ASSIGN + | AND_ASSIGN + | XOR_ASSIGN + | OR_ASSIGN + ; + binary_expression - : unary_expression - | binary_expression (STAR | SLASH | PERCENT) binary_expression - | binary_expression (PLUS | DASH) binary_expression - | binary_expression (LEFT_OP | RIGHT_OP) binary_expression - | binary_expression (LEFT_ANGLE | RIGHT_ANGLE | LE_OP | GE_OP) binary_expression - | binary_expression (EQ_OP | NE_OP) binary_expression - | binary_expression AMPERSAND binary_expression - | binary_expression CARET binary_expression - | binary_expression VERTICAL_BAR binary_expression - | binary_expression AND_OP binary_expression - | binary_expression XOR_OP binary_expression - | binary_expression OR_OP binary_expression - ; + : unary_expression + | binary_expression (STAR | SLASH | PERCENT) binary_expression + | binary_expression (PLUS | DASH) binary_expression + | binary_expression (LEFT_OP | RIGHT_OP) binary_expression + | binary_expression (LEFT_ANGLE | RIGHT_ANGLE | LE_OP | GE_OP) binary_expression + | binary_expression (EQ_OP | NE_OP) binary_expression + | binary_expression AMPERSAND binary_expression + | binary_expression CARET binary_expression + | binary_expression VERTICAL_BAR binary_expression + | binary_expression AND_OP binary_expression + | binary_expression XOR_OP binary_expression + | binary_expression OR_OP binary_expression + ; + expression - : assignment_expression - | expression COMMA assignment_expression - ; + : assignment_expression + | expression COMMA assignment_expression + ; + constant_expression - : binary_expression - | binary_expression QUESTION expression COLON assignment_expression - ; + : binary_expression + | binary_expression QUESTION expression COLON assignment_expression + ; + declaration - : function_prototype SEMICOLON - | init_declarator_list SEMICOLON - | PRECISION precision_qualifier type_specifier SEMICOLON - | type_qualifier IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE (IDENTIFIER array_specifier?)? SEMICOLON - | type_qualifier identifier_list? SEMICOLON - ; + : function_prototype SEMICOLON + | init_declarator_list SEMICOLON + | PRECISION precision_qualifier type_specifier SEMICOLON + | type_qualifier IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE ( + IDENTIFIER array_specifier? + )? SEMICOLON + | type_qualifier identifier_list? SEMICOLON + ; + identifier_list - : IDENTIFIER (COMMA IDENTIFIER)* - ; + : IDENTIFIER (COMMA IDENTIFIER)* + ; + function_prototype - : fully_specified_type IDENTIFIER LEFT_PAREN function_parameters? RIGHT_PAREN - ; + : fully_specified_type IDENTIFIER LEFT_PAREN function_parameters? RIGHT_PAREN + ; + function_parameters - : parameter_declaration (COMMA parameter_declaration)* - ; + : parameter_declaration (COMMA parameter_declaration)* + ; + parameter_declarator - : type_specifier IDENTIFIER array_specifier? - ; + : type_specifier IDENTIFIER array_specifier? + ; + parameter_declaration - : type_qualifier (parameter_declarator | parameter_type_specifier) - | parameter_declarator - | parameter_type_specifier - ; + : type_qualifier (parameter_declarator | parameter_type_specifier) + | parameter_declarator + | parameter_type_specifier + ; + parameter_type_specifier - : type_specifier - ; + : type_specifier + ; + init_declarator_list - : single_declaration (COMMA typeless_declaration)* - ; + : single_declaration (COMMA typeless_declaration)* + ; + single_declaration - : fully_specified_type typeless_declaration? - ; + : fully_specified_type typeless_declaration? + ; + typeless_declaration - : IDENTIFIER array_specifier? (EQUAL initializer)? - ; + : IDENTIFIER array_specifier? (EQUAL initializer)? + ; + fully_specified_type - : type_specifier - | type_qualifier type_specifier - ; + : type_specifier + | type_qualifier type_specifier + ; + invariant_qualifier - : INVARIANT - ; + : INVARIANT + ; + interpolation_qualifier - : SMOOTH - | FLAT - | NOPERSPECTIVE - ; + : SMOOTH + | FLAT + | NOPERSPECTIVE + ; + layout_qualifier - : LAYOUT LEFT_PAREN layout_qualifier_id_list RIGHT_PAREN - ; + : LAYOUT LEFT_PAREN layout_qualifier_id_list RIGHT_PAREN + ; + layout_qualifier_id_list - : layout_qualifier_id (COMMA layout_qualifier_id)* - ; + : layout_qualifier_id (COMMA layout_qualifier_id)* + ; + layout_qualifier_id - : IDENTIFIER (EQUAL constant_expression)? - | SHARED - ; + : IDENTIFIER (EQUAL constant_expression)? + | SHARED + ; + precise_qualifier - : PRECISE - ; + : PRECISE + ; + type_qualifier - : single_type_qualifier+ - ; + : single_type_qualifier+ + ; + single_type_qualifier - : storage_qualifier - | layout_qualifier - | precision_qualifier - | interpolation_qualifier - | invariant_qualifier - | precise_qualifier - ; + : storage_qualifier + | layout_qualifier + | precision_qualifier + | interpolation_qualifier + | invariant_qualifier + | precise_qualifier + ; + storage_qualifier - : CONST - | IN - | OUT - | INOUT - | CENTROID - | PATCH - | SAMPLE - | UNIFORM - | BUFFER - | SHARED - | COHERENT - | VOLATILE - | RESTRICT - | READONLY - | WRITEONLY - | SUBROUTINE (LEFT_PAREN type_name_list RIGHT_PAREN)? - | ATTRIBUTE - | VARYING - ; + : CONST + | IN + | OUT + | INOUT + | CENTROID + | PATCH + | SAMPLE + | UNIFORM + | BUFFER + | SHARED + | COHERENT + | VOLATILE + | RESTRICT + | READONLY + | WRITEONLY + | SUBROUTINE (LEFT_PAREN type_name_list RIGHT_PAREN)? + | ATTRIBUTE + | VARYING + ; + type_name_list - : type_name (COMMA type_name)* - ; + : type_name (COMMA type_name)* + ; + type_name - : IDENTIFIER - ; + : IDENTIFIER + ; + type_specifier - : type_specifier_nonarray array_specifier? - ; + : type_specifier_nonarray array_specifier? + ; + array_specifier - : dimension+ - ; + : dimension+ + ; + dimension - : LEFT_BRACKET constant_expression? RIGHT_BRACKET - ; + : LEFT_BRACKET constant_expression? RIGHT_BRACKET + ; + type_specifier_nonarray - : VOID - | FLOAT - | DOUBLE - | INT - | UINT - | BOOL - | VEC2 - | VEC3 - | VEC4 - | DVEC2 - | DVEC3 - | DVEC4 - | BVEC2 - | BVEC3 - | BVEC4 - | IVEC2 - | IVEC3 - | IVEC4 - | UVEC2 - | UVEC3 - | UVEC4 - | MAT2 - | MAT3 - | MAT4 - | MAT2X2 - | MAT2X3 - | MAT2X4 - | MAT3X2 - | MAT3X3 - | MAT3X4 - | MAT4X2 - | MAT4X3 - | MAT4X4 - | DMAT2 - | DMAT3 - | DMAT4 - | DMAT2X2 - | DMAT2X3 - | DMAT2X4 - | DMAT3X2 - | DMAT3X3 - | DMAT3X4 - | DMAT4X2 - | DMAT4X3 - | DMAT4X4 - | ATOMIC_UINT - | SAMPLER2D - | SAMPLER3D - | SAMPLERCUBE - | SAMPLER2DSHADOW - | SAMPLERCUBESHADOW - | SAMPLER2DARRAY - | SAMPLER2DARRAYSHADOW - | SAMPLERCUBEARRAY - | SAMPLERCUBEARRAYSHADOW - | ISAMPLER2D - | ISAMPLER3D - | ISAMPLERCUBE - | ISAMPLER2DARRAY - | ISAMPLERCUBEARRAY - | USAMPLER2D - | USAMPLER3D - | USAMPLERCUBE - | USAMPLER2DARRAY - | USAMPLERCUBEARRAY - | SAMPLER1D - | SAMPLER1DSHADOW - | SAMPLER1DARRAY - | SAMPLER1DARRAYSHADOW - | ISAMPLER1D - | ISAMPLER1DARRAY - | USAMPLER1D - | USAMPLER1DARRAY - | SAMPLER2DRECT - | SAMPLER2DRECTSHADOW - | ISAMPLER2DRECT - | USAMPLER2DRECT - | SAMPLERBUFFER - | ISAMPLERBUFFER - | USAMPLERBUFFER - | SAMPLER2DMS - | ISAMPLER2DMS - | USAMPLER2DMS - | SAMPLER2DMSARRAY - | ISAMPLER2DMSARRAY - | USAMPLER2DMSARRAY - | IMAGE2D - | IIMAGE2D - | UIMAGE2D - | IMAGE3D - | IIMAGE3D - | UIMAGE3D - | IMAGECUBE - | IIMAGECUBE - | UIMAGECUBE - | IMAGEBUFFER - | IIMAGEBUFFER - | UIMAGEBUFFER - | IMAGE1D - | IIMAGE1D - | UIMAGE1D - | IMAGE1DARRAY - | IIMAGE1DARRAY - | UIMAGE1DARRAY - | IMAGE2DRECT - | IIMAGE2DRECT - | UIMAGE2DRECT - | IMAGE2DARRAY - | IIMAGE2DARRAY - | UIMAGE2DARRAY - | IMAGECUBEARRAY - | IIMAGECUBEARRAY - | UIMAGECUBEARRAY - | IMAGE2DMS - | IIMAGE2DMS - | UIMAGE2DMS - | IMAGE2DMSARRAY - | IIMAGE2DMSARRAY - | UIMAGE2DMSARRAY - | struct_specifier - | type_name - ; + : VOID + | FLOAT + | DOUBLE + | INT + | UINT + | BOOL + | VEC2 + | VEC3 + | VEC4 + | DVEC2 + | DVEC3 + | DVEC4 + | BVEC2 + | BVEC3 + | BVEC4 + | IVEC2 + | IVEC3 + | IVEC4 + | UVEC2 + | UVEC3 + | UVEC4 + | MAT2 + | MAT3 + | MAT4 + | MAT2X2 + | MAT2X3 + | MAT2X4 + | MAT3X2 + | MAT3X3 + | MAT3X4 + | MAT4X2 + | MAT4X3 + | MAT4X4 + | DMAT2 + | DMAT3 + | DMAT4 + | DMAT2X2 + | DMAT2X3 + | DMAT2X4 + | DMAT3X2 + | DMAT3X3 + | DMAT3X4 + | DMAT4X2 + | DMAT4X3 + | DMAT4X4 + | ATOMIC_UINT + | SAMPLER2D + | SAMPLER3D + | SAMPLERCUBE + | SAMPLER2DSHADOW + | SAMPLERCUBESHADOW + | SAMPLER2DARRAY + | SAMPLER2DARRAYSHADOW + | SAMPLERCUBEARRAY + | SAMPLERCUBEARRAYSHADOW + | ISAMPLER2D + | ISAMPLER3D + | ISAMPLERCUBE + | ISAMPLER2DARRAY + | ISAMPLERCUBEARRAY + | USAMPLER2D + | USAMPLER3D + | USAMPLERCUBE + | USAMPLER2DARRAY + | USAMPLERCUBEARRAY + | SAMPLER1D + | SAMPLER1DSHADOW + | SAMPLER1DARRAY + | SAMPLER1DARRAYSHADOW + | ISAMPLER1D + | ISAMPLER1DARRAY + | USAMPLER1D + | USAMPLER1DARRAY + | SAMPLER2DRECT + | SAMPLER2DRECTSHADOW + | ISAMPLER2DRECT + | USAMPLER2DRECT + | SAMPLERBUFFER + | ISAMPLERBUFFER + | USAMPLERBUFFER + | SAMPLER2DMS + | ISAMPLER2DMS + | USAMPLER2DMS + | SAMPLER2DMSARRAY + | ISAMPLER2DMSARRAY + | USAMPLER2DMSARRAY + | IMAGE2D + | IIMAGE2D + | UIMAGE2D + | IMAGE3D + | IIMAGE3D + | UIMAGE3D + | IMAGECUBE + | IIMAGECUBE + | UIMAGECUBE + | IMAGEBUFFER + | IIMAGEBUFFER + | UIMAGEBUFFER + | IMAGE1D + | IIMAGE1D + | UIMAGE1D + | IMAGE1DARRAY + | IIMAGE1DARRAY + | UIMAGE1DARRAY + | IMAGE2DRECT + | IIMAGE2DRECT + | UIMAGE2DRECT + | IMAGE2DARRAY + | IIMAGE2DARRAY + | UIMAGE2DARRAY + | IMAGECUBEARRAY + | IIMAGECUBEARRAY + | UIMAGECUBEARRAY + | IMAGE2DMS + | IIMAGE2DMS + | UIMAGE2DMS + | IMAGE2DMSARRAY + | IIMAGE2DMSARRAY + | UIMAGE2DMSARRAY + | struct_specifier + | type_name + ; + precision_qualifier - : HIGHP - | MEDIUMP - | LOWP - ; + : HIGHP + | MEDIUMP + | LOWP + ; + struct_specifier - : STRUCT IDENTIFIER? LEFT_BRACE struct_declaration_list RIGHT_BRACE - ; + : STRUCT IDENTIFIER? LEFT_BRACE struct_declaration_list RIGHT_BRACE + ; + struct_declaration_list - : struct_declaration+ - ; + : struct_declaration+ + ; + struct_declaration - : type_specifier struct_declarator_list SEMICOLON - | type_qualifier type_specifier struct_declarator_list SEMICOLON - ; + : type_specifier struct_declarator_list SEMICOLON + | type_qualifier type_specifier struct_declarator_list SEMICOLON + ; + struct_declarator_list - : struct_declarator (COMMA struct_declarator)* - ; + : struct_declarator (COMMA struct_declarator)* + ; + struct_declarator - : IDENTIFIER array_specifier? - ; + : IDENTIFIER array_specifier? + ; + initializer - : assignment_expression - | LEFT_BRACE initializer_list COMMA? RIGHT_BRACE - ; + : assignment_expression + | LEFT_BRACE initializer_list COMMA? RIGHT_BRACE + ; + initializer_list - : initializer (COMMA initializer)* - ; + : initializer (COMMA initializer)* + ; + declaration_statement - : declaration - ; + : declaration + ; + statement - : compound_statement - | simple_statement - ; + : compound_statement + | simple_statement + ; + simple_statement - : declaration_statement - | expression_statement - | selection_statement - | switch_statement - | case_label - | iteration_statement - | jump_statement - ; + : declaration_statement + | expression_statement + | selection_statement + | switch_statement + | case_label + | iteration_statement + | jump_statement + ; + compound_statement - : LEFT_BRACE statement_list? RIGHT_BRACE - ; + : LEFT_BRACE statement_list? RIGHT_BRACE + ; + statement_no_new_scope - : compound_statement_no_new_scope - | simple_statement - ; + : compound_statement_no_new_scope + | simple_statement + ; + compound_statement_no_new_scope - : LEFT_BRACE statement_list? RIGHT_BRACE - ; + : LEFT_BRACE statement_list? RIGHT_BRACE + ; + statement_list - : statement+ - ; + : statement+ + ; + expression_statement - : SEMICOLON - | expression SEMICOLON - ; + : SEMICOLON + | expression SEMICOLON + ; + selection_statement - : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement - ; + : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement + ; + selection_rest_statement - : statement (ELSE statement)? - ; + : statement (ELSE statement)? + ; + condition - : expression - | fully_specified_type IDENTIFIER EQUAL initializer - ; + : expression + | fully_specified_type IDENTIFIER EQUAL initializer + ; + switch_statement - : SWITCH LEFT_PAREN expression RIGHT_PAREN LEFT_BRACE statement_list? RIGHT_BRACE - ; + : SWITCH LEFT_PAREN expression RIGHT_PAREN LEFT_BRACE statement_list? RIGHT_BRACE + ; + case_label - : CASE expression COLON - | DEFAULT COLON - ; + : CASE expression COLON + | DEFAULT COLON + ; + iteration_statement - : WHILE LEFT_PAREN condition RIGHT_PAREN statement_no_new_scope - | DO statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON - | FOR LEFT_PAREN for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope - ; + : WHILE LEFT_PAREN condition RIGHT_PAREN statement_no_new_scope + | DO statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON + | FOR LEFT_PAREN for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope + ; + for_init_statement - : expression_statement - | declaration_statement - ; + : expression_statement + | declaration_statement + ; + for_rest_statement - : condition? SEMICOLON expression? - ; + : condition? SEMICOLON expression? + ; + jump_statement - : CONTINUE SEMICOLON - | BREAK SEMICOLON - | RETURN expression? SEMICOLON - | DISCARD SEMICOLON - ; + : CONTINUE SEMICOLON + | BREAK SEMICOLON + | RETURN expression? SEMICOLON + | DISCARD SEMICOLON + ; + external_declaration - : function_definition - | declaration - | SEMICOLON - ; + : function_definition + | declaration + | SEMICOLON + ; + function_definition - : function_prototype compound_statement_no_new_scope - ; + : function_prototype compound_statement_no_new_scope + ; \ No newline at end of file diff --git a/glsl/GLSLPreParser.g4 b/glsl/GLSLPreParser.g4 index 7656da5cae..952237d1eb 100644 --- a/glsl/GLSLPreParser.g4 +++ b/glsl/GLSLPreParser.g4 @@ -22,54 +22,159 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 GLSLPreParser; -options { tokenVocab = GLSLLexer; } -translation_unit : compiler_directive* ; +options { + tokenVocab = GLSLLexer; +} + +translation_unit + : compiler_directive* + ; + compiler_directive - : define_directive - | elif_directive - | else_directive - | endif_directive - | error_directive - | extension_directive - | if_directive - | ifdef_directive - | ifndef_directive - | line_directive - | pragma_directive - | undef_directive - | version_directive - ; -behavior : BEHAVIOR ; -constant_expression : CONSTANT_EXPRESSION ; -define_directive : NUMBER_SIGN DEFINE_DIRECTIVE macro_name macro_text ; -elif_directive : NUMBER_SIGN ELIF_DIRECTIVE constant_expression group_of_lines ; -else_directive : NUMBER_SIGN ELSE_DIRECTIVE group_of_lines ; -endif_directive : NUMBER_SIGN ENDIF_DIRECTIVE ; -error_directive : NUMBER_SIGN ERROR_DIRECTIVE error_message ; -error_message : ERROR_MESSAGE ; -extension_directive : NUMBER_SIGN EXTENSION_DIRECTIVE extension_name COLON behavior ; -extension_name : EXTENSION_NAME ; -group_of_lines : (program_text | compiler_directive)* ; -if_directive : NUMBER_SIGN IF_DIRECTIVE constant_expression group_of_lines elif_directive* else_directive? endif_directive ; -ifdef_directive : NUMBER_SIGN IFDEF_DIRECTIVE macro_identifier group_of_lines elif_directive* else_directive? endif_directive ; -ifndef_directive : NUMBER_SIGN IFNDEF_DIRECTIVE macro_identifier group_of_lines elif_directive* else_directive? endif_directive ; -line_directive : NUMBER_SIGN LINE_DIRECTIVE line_expression ; -line_expression : LINE_EXPRESSION ; -macro_esc_newline : MACRO_ESC_NEWLINE ; -macro_identifier : MACRO_IDENTIFIER ; -macro_name : MACRO_NAME ; -macro_text : (macro_text_ | macro_esc_newline)* ; -macro_text_ : MACRO_TEXT ; -number : NUMBER ; -off : OFF ; -on : ON ; -pragma_debug : DEBUG LEFT_PAREN (on | off) RIGHT_PAREN ; -pragma_directive : NUMBER_SIGN PRAGMA_DIRECTIVE (stdgl | pragma_debug | pragma_optimize) ; -pragma_optimize : OPTIMIZE LEFT_PAREN (on | off) RIGHT_PAREN ; -profile : PROFILE ; -program_text : PROGRAM_TEXT ; -stdgl : STDGL ; -undef_directive : NUMBER_SIGN UNDEF_DIRECTIVE macro_identifier ; -version_directive : NUMBER_SIGN VERSION_DIRECTIVE number profile? ; + : define_directive + | elif_directive + | else_directive + | endif_directive + | error_directive + | extension_directive + | if_directive + | ifdef_directive + | ifndef_directive + | line_directive + | pragma_directive + | undef_directive + | version_directive + ; + +behavior + : BEHAVIOR + ; + +constant_expression + : CONSTANT_EXPRESSION + ; + +define_directive + : NUMBER_SIGN DEFINE_DIRECTIVE macro_name macro_text + ; + +elif_directive + : NUMBER_SIGN ELIF_DIRECTIVE constant_expression group_of_lines + ; + +else_directive + : NUMBER_SIGN ELSE_DIRECTIVE group_of_lines + ; + +endif_directive + : NUMBER_SIGN ENDIF_DIRECTIVE + ; + +error_directive + : NUMBER_SIGN ERROR_DIRECTIVE error_message + ; + +error_message + : ERROR_MESSAGE + ; + +extension_directive + : NUMBER_SIGN EXTENSION_DIRECTIVE extension_name COLON behavior + ; + +extension_name + : EXTENSION_NAME + ; + +group_of_lines + : (program_text | compiler_directive)* + ; + +if_directive + : NUMBER_SIGN IF_DIRECTIVE constant_expression group_of_lines elif_directive* else_directive? endif_directive + ; + +ifdef_directive + : NUMBER_SIGN IFDEF_DIRECTIVE macro_identifier group_of_lines elif_directive* else_directive? endif_directive + ; + +ifndef_directive + : NUMBER_SIGN IFNDEF_DIRECTIVE macro_identifier group_of_lines elif_directive* else_directive? endif_directive + ; + +line_directive + : NUMBER_SIGN LINE_DIRECTIVE line_expression + ; + +line_expression + : LINE_EXPRESSION + ; + +macro_esc_newline + : MACRO_ESC_NEWLINE + ; + +macro_identifier + : MACRO_IDENTIFIER + ; + +macro_name + : MACRO_NAME + ; + +macro_text + : (macro_text_ | macro_esc_newline)* + ; + +macro_text_ + : MACRO_TEXT + ; + +number + : NUMBER + ; + +off + : OFF + ; + +on + : ON + ; + +pragma_debug + : DEBUG LEFT_PAREN (on | off) RIGHT_PAREN + ; + +pragma_directive + : NUMBER_SIGN PRAGMA_DIRECTIVE (stdgl | pragma_debug | pragma_optimize) + ; + +pragma_optimize + : OPTIMIZE LEFT_PAREN (on | off) RIGHT_PAREN + ; + +profile + : PROFILE + ; + +program_text + : PROGRAM_TEXT + ; + +stdgl + : STDGL + ; + +undef_directive + : NUMBER_SIGN UNDEF_DIRECTIVE macro_identifier + ; + +version_directive + : NUMBER_SIGN VERSION_DIRECTIVE number profile? + ; \ No newline at end of file diff --git a/gml/gml.g4 b/gml/gml.g4 index dff98c68be..8465ea5000 100644 --- a/gml/gml.g4 +++ b/gml/gml.g4 @@ -30,79 +30,76 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar gml; graph - : kv + EOF - ; + : kv+ EOF + ; list_ - : '[' kv + ']' - ; + : '[' kv+ ']' + ; kv - : key value - ; + : key value + ; value - : integer - | realnum - | stringliteral - | str_ - | list_ - ; + : integer + | realnum + | stringliteral + | str_ + | list_ + ; key - : VALUE - ; + : VALUE + ; integer - : SIGN? DIGIT + - ; + : SIGN? DIGIT+ + ; realnum - : REAL - ; + : REAL + ; str_ - : VALUE - ; + : VALUE + ; stringliteral - : STRINGLITERAL - ; - + : STRINGLITERAL + ; STRINGLITERAL - : '"' ~ '"'* '"' - ; - + : '"' ~ '"'* '"' + ; REAL - : SIGN? DIGIT* '.' DIGIT + MANTISSA? - ; - + : SIGN? DIGIT* '.' DIGIT+ MANTISSA? + ; SIGN - : '+' | '-' - ; - + : '+' + | '-' + ; DIGIT - : [0-9] - ; - + : [0-9] + ; MANTISSA - : 'E' SIGN DIGIT - ; - + : 'E' SIGN DIGIT + ; VALUE - : [a-zA-Z0-9] + - ; - + : [a-zA-Z0-9]+ + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/golang/GoLexer.g4 b/golang/GoLexer.g4 index 5e82671a45..6b873e2b64 100644 --- a/golang/GoLexer.g4 +++ b/golang/GoLexer.g4 @@ -34,207 +34,191 @@ * https://golang.org/ref/spec */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar GoLexer; // Keywords -BREAK : 'break' -> mode(NLSEMI); -DEFAULT : 'default'; -FUNC : 'func'; -INTERFACE : 'interface'; -SELECT : 'select'; -CASE : 'case'; -DEFER : 'defer'; -GO : 'go'; -MAP : 'map'; -STRUCT : 'struct'; -CHAN : 'chan'; -ELSE : 'else'; -GOTO : 'goto'; -PACKAGE : 'package'; -SWITCH : 'switch'; -CONST : 'const'; -FALLTHROUGH : 'fallthrough' -> mode(NLSEMI); -IF : 'if'; -RANGE : 'range'; -TYPE : 'type'; -CONTINUE : 'continue' -> mode(NLSEMI); -FOR : 'for'; -IMPORT : 'import'; -RETURN : 'return' -> mode(NLSEMI); -VAR : 'var'; - -NIL_LIT : 'nil' -> mode(NLSEMI); - -IDENTIFIER : LETTER (LETTER | UNICODE_DIGIT)* -> mode(NLSEMI); +BREAK : 'break' -> mode(NLSEMI); +DEFAULT : 'default'; +FUNC : 'func'; +INTERFACE : 'interface'; +SELECT : 'select'; +CASE : 'case'; +DEFER : 'defer'; +GO : 'go'; +MAP : 'map'; +STRUCT : 'struct'; +CHAN : 'chan'; +ELSE : 'else'; +GOTO : 'goto'; +PACKAGE : 'package'; +SWITCH : 'switch'; +CONST : 'const'; +FALLTHROUGH : 'fallthrough' -> mode(NLSEMI); +IF : 'if'; +RANGE : 'range'; +TYPE : 'type'; +CONTINUE : 'continue' -> mode(NLSEMI); +FOR : 'for'; +IMPORT : 'import'; +RETURN : 'return' -> mode(NLSEMI); +VAR : 'var'; + +NIL_LIT: 'nil' -> mode(NLSEMI); + +IDENTIFIER: LETTER (LETTER | UNICODE_DIGIT)* -> mode(NLSEMI); // Punctuation -L_PAREN : '('; -R_PAREN : ')' -> mode(NLSEMI); -L_CURLY : '{'; -R_CURLY : '}' -> mode(NLSEMI); -L_BRACKET : '['; -R_BRACKET : ']' -> mode(NLSEMI); -ASSIGN : '='; -COMMA : ','; -SEMI : ';'; -COLON : ':'; -DOT : '.'; -PLUS_PLUS : '++' -> mode(NLSEMI); -MINUS_MINUS : '--' -> mode(NLSEMI); -DECLARE_ASSIGN : ':='; -ELLIPSIS : '...'; +L_PAREN : '('; +R_PAREN : ')' -> mode(NLSEMI); +L_CURLY : '{'; +R_CURLY : '}' -> mode(NLSEMI); +L_BRACKET : '['; +R_BRACKET : ']' -> mode(NLSEMI); +ASSIGN : '='; +COMMA : ','; +SEMI : ';'; +COLON : ':'; +DOT : '.'; +PLUS_PLUS : '++' -> mode(NLSEMI); +MINUS_MINUS : '--' -> mode(NLSEMI); +DECLARE_ASSIGN : ':='; +ELLIPSIS : '...'; // Logical -LOGICAL_OR : '||'; -LOGICAL_AND : '&&'; +LOGICAL_OR : '||'; +LOGICAL_AND : '&&'; // Relation operators -EQUALS : '=='; -NOT_EQUALS : '!='; -LESS : '<'; -LESS_OR_EQUALS : '<='; -GREATER : '>'; -GREATER_OR_EQUALS : '>='; +EQUALS : '=='; +NOT_EQUALS : '!='; +LESS : '<'; +LESS_OR_EQUALS : '<='; +GREATER : '>'; +GREATER_OR_EQUALS : '>='; // Arithmetic operators -OR : '|'; -DIV : '/'; -MOD : '%'; -LSHIFT : '<<'; -RSHIFT : '>>'; -BIT_CLEAR : '&^'; -UNDERLYING : '~'; +OR : '|'; +DIV : '/'; +MOD : '%'; +LSHIFT : '<<'; +RSHIFT : '>>'; +BIT_CLEAR : '&^'; +UNDERLYING : '~'; // Unary operators -EXCLAMATION : '!'; +EXCLAMATION: '!'; // Mixed operators -PLUS : '+'; -MINUS : '-'; -CARET : '^'; -STAR : '*'; -AMPERSAND : '&'; -RECEIVE : '<-'; +PLUS : '+'; +MINUS : '-'; +CARET : '^'; +STAR : '*'; +AMPERSAND : '&'; +RECEIVE : '<-'; // Number literals -DECIMAL_LIT : ('0' | [1-9] ('_'? [0-9])*) -> mode(NLSEMI); -BINARY_LIT : '0' [bB] ('_'? BIN_DIGIT)+ -> mode(NLSEMI); -OCTAL_LIT : '0' [oO]? ('_'? OCTAL_DIGIT)+ -> mode(NLSEMI); -HEX_LIT : '0' [xX] ('_'? HEX_DIGIT)+ -> mode(NLSEMI); - +DECIMAL_LIT : ('0' | [1-9] ('_'? [0-9])*) -> mode(NLSEMI); +BINARY_LIT : '0' [bB] ('_'? BIN_DIGIT)+ -> mode(NLSEMI); +OCTAL_LIT : '0' [oO]? ('_'? OCTAL_DIGIT)+ -> mode(NLSEMI); +HEX_LIT : '0' [xX] ('_'? HEX_DIGIT)+ -> mode(NLSEMI); -FLOAT_LIT : (DECIMAL_FLOAT_LIT | HEX_FLOAT_LIT) -> mode(NLSEMI); +FLOAT_LIT: (DECIMAL_FLOAT_LIT | HEX_FLOAT_LIT) -> mode(NLSEMI); -DECIMAL_FLOAT_LIT : DECIMALS ('.' DECIMALS? EXPONENT? | EXPONENT) - | '.' DECIMALS EXPONENT? - ; +DECIMAL_FLOAT_LIT: DECIMALS ('.' DECIMALS? EXPONENT? | EXPONENT) | '.' DECIMALS EXPONENT?; -HEX_FLOAT_LIT : '0' [xX] HEX_MANTISSA HEX_EXPONENT - ; +HEX_FLOAT_LIT: '0' [xX] HEX_MANTISSA HEX_EXPONENT; -fragment HEX_MANTISSA : ('_'? HEX_DIGIT)+ ('.' ( '_'? HEX_DIGIT )*)? - | '.' HEX_DIGIT ('_'? HEX_DIGIT)*; +fragment HEX_MANTISSA: + ('_'? HEX_DIGIT)+ ('.' ( '_'? HEX_DIGIT)*)? + | '.' HEX_DIGIT ('_'? HEX_DIGIT)* +; -fragment HEX_EXPONENT : [pP] [+-]? DECIMALS; +fragment HEX_EXPONENT: [pP] [+-]? DECIMALS; - -IMAGINARY_LIT : (DECIMAL_LIT | BINARY_LIT | OCTAL_LIT | HEX_LIT | FLOAT_LIT) 'i' -> mode(NLSEMI); +IMAGINARY_LIT: (DECIMAL_LIT | BINARY_LIT | OCTAL_LIT | HEX_LIT | FLOAT_LIT) 'i' -> mode(NLSEMI); // Rune literals -fragment RUNE : '\'' (UNICODE_VALUE | BYTE_VALUE) '\'';//: '\'' (~[\n\\] | ESCAPED_VALUE) '\''; - -RUNE_LIT : RUNE -> mode(NLSEMI); +fragment RUNE: '\'' (UNICODE_VALUE | BYTE_VALUE) '\''; //: '\'' (~[\n\\] | ESCAPED_VALUE) '\''; +RUNE_LIT: RUNE -> mode(NLSEMI); - -BYTE_VALUE : OCTAL_BYTE_VALUE | HEX_BYTE_VALUE; +BYTE_VALUE: OCTAL_BYTE_VALUE | HEX_BYTE_VALUE; OCTAL_BYTE_VALUE: '\\' OCTAL_DIGIT OCTAL_DIGIT OCTAL_DIGIT; -HEX_BYTE_VALUE: '\\' 'x' HEX_DIGIT HEX_DIGIT; +HEX_BYTE_VALUE: '\\' 'x' HEX_DIGIT HEX_DIGIT; LITTLE_U_VALUE: '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; -BIG_U_VALUE: '\\' 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; +BIG_U_VALUE: + '\\' 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT +; // String literals -RAW_STRING_LIT : '`' ~'`'* '`' -> mode(NLSEMI); -INTERPRETED_STRING_LIT : '"' (~["\\] | ESCAPED_VALUE)* '"' -> mode(NLSEMI); +RAW_STRING_LIT : '`' ~'`'* '`' -> mode(NLSEMI); +INTERPRETED_STRING_LIT : '"' (~["\\] | ESCAPED_VALUE)* '"' -> mode(NLSEMI); // Hidden tokens -WS : [ \t]+ -> channel(HIDDEN); -COMMENT : '/*' .*? '*/' -> channel(HIDDEN); -TERMINATOR : [\r\n]+ -> channel(HIDDEN); -LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); +WS : [ \t]+ -> channel(HIDDEN); +COMMENT : '/*' .*? '*/' -> channel(HIDDEN); +TERMINATOR : [\r\n]+ -> channel(HIDDEN); +LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); fragment UNICODE_VALUE: ~[\r\n'] | LITTLE_U_VALUE | BIG_U_VALUE | ESCAPED_VALUE; // Fragments -fragment ESCAPED_VALUE - : '\\' ('u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - | 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - | [abfnrtv\\'"] - | OCTAL_DIGIT OCTAL_DIGIT OCTAL_DIGIT - | 'x' HEX_DIGIT HEX_DIGIT) - ; +fragment ESCAPED_VALUE: + '\\' ( + 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT + | 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT + | [abfnrtv\\'"] + | OCTAL_DIGIT OCTAL_DIGIT OCTAL_DIGIT + | 'x' HEX_DIGIT HEX_DIGIT + ) +; -fragment DECIMALS - : [0-9] ('_'? [0-9])* - ; +fragment DECIMALS: [0-9] ('_'? [0-9])*; -fragment OCTAL_DIGIT - : [0-7] - ; +fragment OCTAL_DIGIT: [0-7]; -fragment HEX_DIGIT - : [0-9a-fA-F] - ; +fragment HEX_DIGIT: [0-9a-fA-F]; -fragment BIN_DIGIT - : [01] - ; +fragment BIN_DIGIT: [01]; -fragment EXPONENT - : [eE] [+-]? DECIMALS - ; +fragment EXPONENT: [eE] [+-]? DECIMALS; -fragment LETTER - : UNICODE_LETTER - | '_' - ; +fragment LETTER: UNICODE_LETTER | '_'; //[\p{Nd}] matches a digit zero through nine in any script except ideographic scripts -fragment UNICODE_DIGIT - : [\p{Nd}] - ; +fragment UNICODE_DIGIT: [\p{Nd}]; //[\p{L}] matches any kind of letter from any language -fragment UNICODE_LETTER - : [\p{L}] - ; - +fragment UNICODE_LETTER: [\p{L}]; mode NLSEMI; - // Treat whitespace as normal -WS_NLSEMI : [ \t]+ -> channel(HIDDEN); +WS_NLSEMI: [ \t]+ -> channel(HIDDEN); // Ignore any comments that only span one line -COMMENT_NLSEMI : '/*' ~[\r\n]*? '*/' -> channel(HIDDEN); -LINE_COMMENT_NLSEMI : '//' ~[\r\n]* -> channel(HIDDEN); +COMMENT_NLSEMI : '/*' ~[\r\n]*? '*/' -> channel(HIDDEN); +LINE_COMMENT_NLSEMI : '//' ~[\r\n]* -> channel(HIDDEN); // Emit an EOS token for any newlines, semicolon, multiline comments or the EOF and //return to normal lexing -EOS: ([\r\n]+ | ';' | '/*' .*? '*/' | EOF) -> mode(DEFAULT_MODE); +EOS: ([\r\n]+ | ';' | '/*' .*? '*/' | EOF) -> mode(DEFAULT_MODE); // Did not find an EOS, so go back to normal lexing -OTHER: -> mode(DEFAULT_MODE), channel(HIDDEN); \ No newline at end of file +OTHER: -> mode(DEFAULT_MODE), channel(HIDDEN); \ No newline at end of file diff --git a/golang/GoParser.g4 b/golang/GoParser.g4 index 5cababf753..9808518b29 100644 --- a/golang/GoParser.g4 +++ b/golang/GoParser.g4 @@ -27,360 +27,503 @@ * A Go grammar for ANTLR 4 derived from the Go Language Specification https://golang.org/ref/spec */ +// $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 GoParser; options { - tokenVocab = GoLexer; - superClass = GoParserBase; + tokenVocab = GoLexer; + superClass = GoParserBase; } -sourceFile: - packageClause eos (importDecl eos)* ( - (functionDecl | methodDecl | declaration) eos - )* EOF; +sourceFile + : packageClause eos (importDecl eos)* ((functionDecl | methodDecl | declaration) eos)* EOF + ; -packageClause: PACKAGE packageName = IDENTIFIER; +packageClause + : PACKAGE packageName = IDENTIFIER + ; -importDecl: - IMPORT (importSpec | L_PAREN (importSpec eos)* R_PAREN); +importDecl + : IMPORT (importSpec | L_PAREN (importSpec eos)* R_PAREN) + ; -importSpec: alias = (DOT | IDENTIFIER)? importPath; +importSpec + : alias = (DOT | IDENTIFIER)? importPath + ; -importPath: string_; +importPath + : string_ + ; -declaration: constDecl | typeDecl | varDecl; +declaration + : constDecl + | typeDecl + | varDecl + ; -constDecl: CONST (constSpec | L_PAREN (constSpec eos)* R_PAREN); +constDecl + : CONST (constSpec | L_PAREN (constSpec eos)* R_PAREN) + ; -constSpec: identifierList (type_? ASSIGN expressionList)?; +constSpec + : identifierList (type_? ASSIGN expressionList)? + ; -identifierList: IDENTIFIER (COMMA IDENTIFIER)*; +identifierList + : IDENTIFIER (COMMA IDENTIFIER)* + ; -expressionList: expression (COMMA expression)*; +expressionList + : expression (COMMA expression)* + ; -typeDecl: TYPE (typeSpec | L_PAREN (typeSpec eos)* R_PAREN); +typeDecl + : TYPE (typeSpec | L_PAREN (typeSpec eos)* R_PAREN) + ; -typeSpec: aliasDecl | typeDef; +typeSpec + : aliasDecl + | typeDef + ; -aliasDecl : IDENTIFIER ASSIGN type_; +aliasDecl + : IDENTIFIER ASSIGN type_ + ; -typeDef : IDENTIFIER typeParameters? type_; +typeDef + : IDENTIFIER typeParameters? type_ + ; -typeParameters : L_BRACKET typeParameterDecl (COMMA typeParameterDecl)* R_BRACKET; +typeParameters + : L_BRACKET typeParameterDecl (COMMA typeParameterDecl)* R_BRACKET + ; -typeParameterDecl : identifierList typeElement; +typeParameterDecl + : identifierList typeElement + ; -typeElement : typeTerm (OR typeTerm)*; +typeElement + : typeTerm (OR typeTerm)* + ; -typeTerm : UNDERLYING? type_; +typeTerm + : UNDERLYING? type_ + ; // Function declarations -functionDecl: FUNC IDENTIFIER typeParameters? signature block?; - -methodDecl: FUNC receiver IDENTIFIER signature block?; - -receiver: parameters; - -varDecl: VAR (varSpec | L_PAREN (varSpec eos)* R_PAREN); - -varSpec: - identifierList ( - type_ (ASSIGN expressionList)? - | ASSIGN expressionList - ); - -block: L_CURLY statementList? R_CURLY; - -statementList: ((SEMI? | EOS? | {this.closingBracket()}?) statement eos)+; - -statement: - declaration - | labeledStmt - | simpleStmt - | goStmt - | returnStmt - | breakStmt - | continueStmt - | gotoStmt - | fallthroughStmt - | block - | ifStmt - | switchStmt - | selectStmt - | forStmt - | deferStmt; - -simpleStmt: - sendStmt - | incDecStmt - | assignment - | expressionStmt - | shortVarDecl; - -expressionStmt: expression; - -sendStmt: channel = expression RECEIVE expression; - -incDecStmt: expression (PLUS_PLUS | MINUS_MINUS); - -assignment: expressionList assign_op expressionList; - -assign_op: ( - PLUS - | MINUS - | OR - | CARET - | STAR - | DIV - | MOD - | LSHIFT - | RSHIFT - | AMPERSAND - | BIT_CLEAR - )? ASSIGN; - -shortVarDecl: identifierList DECLARE_ASSIGN expressionList; - -labeledStmt: IDENTIFIER COLON statement?; - -returnStmt: RETURN expressionList?; - -breakStmt: BREAK IDENTIFIER?; - -continueStmt: CONTINUE IDENTIFIER?; - -gotoStmt: GOTO IDENTIFIER; - -fallthroughStmt: FALLTHROUGH; - -deferStmt: DEFER expression; - -ifStmt: - IF ( expression - | eos expression - | simpleStmt eos expression - ) block ( - ELSE (ifStmt | block) - )?; - -switchStmt: exprSwitchStmt | typeSwitchStmt; - -exprSwitchStmt: - SWITCH (expression? - | simpleStmt? eos expression? - ) L_CURLY exprCaseClause* R_CURLY; - -exprCaseClause: exprSwitchCase COLON statementList?; - -exprSwitchCase: CASE expressionList | DEFAULT; - -typeSwitchStmt: - SWITCH ( typeSwitchGuard - | eos typeSwitchGuard - | simpleStmt eos typeSwitchGuard) - L_CURLY typeCaseClause* R_CURLY; - -typeSwitchGuard: (IDENTIFIER DECLARE_ASSIGN)? primaryExpr DOT L_PAREN TYPE R_PAREN; - -typeCaseClause: typeSwitchCase COLON statementList?; - -typeSwitchCase: CASE typeList | DEFAULT; - -typeList: (type_ | NIL_LIT) (COMMA (type_ | NIL_LIT))*; - -selectStmt: SELECT L_CURLY commClause* R_CURLY; - -commClause: commCase COLON statementList?; - -commCase: CASE (sendStmt | recvStmt) | DEFAULT; - -recvStmt: (expressionList ASSIGN | identifierList DECLARE_ASSIGN)? recvExpr = expression; - -forStmt: FOR (expression? | forClause | rangeClause?) block; - -forClause: - initStmt = simpleStmt? eos expression? eos postStmt = simpleStmt?; - -rangeClause: ( - expressionList ASSIGN - | identifierList DECLARE_ASSIGN - )? RANGE expression; - -goStmt: GO expression; - -type_: typeName typeArgs? | typeLit | L_PAREN type_ R_PAREN; - -typeArgs: L_BRACKET typeList COMMA? R_BRACKET; - -typeName: qualifiedIdent | IDENTIFIER; - -typeLit: - arrayType - | structType - | pointerType - | functionType - | interfaceType - | sliceType - | mapType - | channelType; - -arrayType: L_BRACKET arrayLength R_BRACKET elementType; - -arrayLength: expression; - -elementType: type_; - -pointerType: STAR type_; - -interfaceType: - INTERFACE L_CURLY ((methodSpec | typeElement ) eos)* R_CURLY; - -sliceType: L_BRACKET R_BRACKET elementType; +functionDecl + : FUNC IDENTIFIER typeParameters? signature block? + ; + +methodDecl + : FUNC receiver IDENTIFIER signature block? + ; + +receiver + : parameters + ; + +varDecl + : VAR (varSpec | L_PAREN (varSpec eos)* R_PAREN) + ; + +varSpec + : identifierList (type_ (ASSIGN expressionList)? | ASSIGN expressionList) + ; + +block + : L_CURLY statementList? R_CURLY + ; + +statementList + : ((SEMI? | EOS? | {this.closingBracket()}?) statement eos)+ + ; + +statement + : declaration + | labeledStmt + | simpleStmt + | goStmt + | returnStmt + | breakStmt + | continueStmt + | gotoStmt + | fallthroughStmt + | block + | ifStmt + | switchStmt + | selectStmt + | forStmt + | deferStmt + ; + +simpleStmt + : sendStmt + | incDecStmt + | assignment + | expressionStmt + | shortVarDecl + ; + +expressionStmt + : expression + ; + +sendStmt + : channel = expression RECEIVE expression + ; + +incDecStmt + : expression (PLUS_PLUS | MINUS_MINUS) + ; + +assignment + : expressionList assign_op expressionList + ; + +assign_op + : (PLUS | MINUS | OR | CARET | STAR | DIV | MOD | LSHIFT | RSHIFT | AMPERSAND | BIT_CLEAR)? ASSIGN + ; + +shortVarDecl + : identifierList DECLARE_ASSIGN expressionList + ; + +labeledStmt + : IDENTIFIER COLON statement? + ; + +returnStmt + : RETURN expressionList? + ; + +breakStmt + : BREAK IDENTIFIER? + ; + +continueStmt + : CONTINUE IDENTIFIER? + ; + +gotoStmt + : GOTO IDENTIFIER + ; + +fallthroughStmt + : FALLTHROUGH + ; + +deferStmt + : DEFER expression + ; + +ifStmt + : IF (expression | eos expression | simpleStmt eos expression) block (ELSE (ifStmt | block))? + ; + +switchStmt + : exprSwitchStmt + | typeSwitchStmt + ; + +exprSwitchStmt + : SWITCH (expression? | simpleStmt? eos expression?) L_CURLY exprCaseClause* R_CURLY + ; + +exprCaseClause + : exprSwitchCase COLON statementList? + ; + +exprSwitchCase + : CASE expressionList + | DEFAULT + ; + +typeSwitchStmt + : SWITCH (typeSwitchGuard | eos typeSwitchGuard | simpleStmt eos typeSwitchGuard) L_CURLY typeCaseClause* R_CURLY + ; + +typeSwitchGuard + : (IDENTIFIER DECLARE_ASSIGN)? primaryExpr DOT L_PAREN TYPE R_PAREN + ; + +typeCaseClause + : typeSwitchCase COLON statementList? + ; + +typeSwitchCase + : CASE typeList + | DEFAULT + ; + +typeList + : (type_ | NIL_LIT) (COMMA (type_ | NIL_LIT))* + ; + +selectStmt + : SELECT L_CURLY commClause* R_CURLY + ; + +commClause + : commCase COLON statementList? + ; + +commCase + : CASE (sendStmt | recvStmt) + | DEFAULT + ; + +recvStmt + : (expressionList ASSIGN | identifierList DECLARE_ASSIGN)? recvExpr = expression + ; + +forStmt + : FOR (expression? | forClause | rangeClause?) block + ; + +forClause + : initStmt = simpleStmt? eos expression? eos postStmt = simpleStmt? + ; + +rangeClause + : (expressionList ASSIGN | identifierList DECLARE_ASSIGN)? RANGE expression + ; + +goStmt + : GO expression + ; + +type_ + : typeName typeArgs? + | typeLit + | L_PAREN type_ R_PAREN + ; + +typeArgs + : L_BRACKET typeList COMMA? R_BRACKET + ; + +typeName + : qualifiedIdent + | IDENTIFIER + ; + +typeLit + : arrayType + | structType + | pointerType + | functionType + | interfaceType + | sliceType + | mapType + | channelType + ; + +arrayType + : L_BRACKET arrayLength R_BRACKET elementType + ; + +arrayLength + : expression + ; + +elementType + : type_ + ; + +pointerType + : STAR type_ + ; + +interfaceType + : INTERFACE L_CURLY ((methodSpec | typeElement) eos)* R_CURLY + ; + +sliceType + : L_BRACKET R_BRACKET elementType + ; // It's possible to replace `type` with more restricted typeLit list and also pay attention to nil maps -mapType: MAP L_BRACKET type_ R_BRACKET elementType; - -channelType: (CHAN | CHAN RECEIVE | RECEIVE CHAN) elementType; - -methodSpec: - IDENTIFIER parameters result - | IDENTIFIER parameters; - -functionType: FUNC signature; - -signature: - parameters result?; - -result: parameters | type_; - -parameters: - L_PAREN (parameterDecl (COMMA parameterDecl)* COMMA?)? R_PAREN; - -parameterDecl: identifierList? ELLIPSIS? type_; - -expression: - primaryExpr - | unary_op = ( - PLUS - | MINUS - | EXCLAMATION - | CARET - | STAR - | AMPERSAND - | RECEIVE - ) expression - | expression mul_op = ( - STAR - | DIV - | MOD - | LSHIFT - | RSHIFT - | AMPERSAND - | BIT_CLEAR - ) expression - | expression add_op = (PLUS | MINUS | OR | CARET) expression - | expression rel_op = ( - EQUALS - | NOT_EQUALS - | LESS - | LESS_OR_EQUALS - | GREATER - | GREATER_OR_EQUALS - ) expression - | expression LOGICAL_AND expression - | expression LOGICAL_OR expression; - -primaryExpr: - operand - | conversion - | methodExpr - | primaryExpr ( - DOT IDENTIFIER - | index - | slice_ - | typeAssertion - | arguments - ); - - -conversion: type_ L_PAREN expression COMMA? R_PAREN; - -operand: literal | operandName typeArgs? | L_PAREN expression R_PAREN; - -literal: basicLit | compositeLit | functionLit; - -basicLit: - NIL_LIT - | integer - | string_ - | FLOAT_LIT; - -integer: - DECIMAL_LIT - | BINARY_LIT - | OCTAL_LIT - | HEX_LIT - | IMAGINARY_LIT - | RUNE_LIT; - -operandName: IDENTIFIER; - -qualifiedIdent: IDENTIFIER DOT IDENTIFIER; - -compositeLit: literalType literalValue; - -literalType: - structType - | arrayType - | L_BRACKET ELLIPSIS R_BRACKET elementType - | sliceType - | mapType - | typeName typeArgs?; - -literalValue: L_CURLY (elementList COMMA?)? R_CURLY; - -elementList: keyedElement (COMMA keyedElement)*; - -keyedElement: (key COLON)? element; - -key: expression | literalValue; - -element: expression | literalValue; - -structType: STRUCT L_CURLY (fieldDecl eos)* R_CURLY; - -fieldDecl: ( - identifierList type_ - | embeddedField - ) tag = string_?; - -string_: RAW_STRING_LIT | INTERPRETED_STRING_LIT; - -embeddedField: STAR? typeName typeArgs?; - -functionLit: FUNC signature block; // function - -index: L_BRACKET expression R_BRACKET; - -slice_: - L_BRACKET ( - expression? COLON expression? - | expression? COLON expression COLON expression - ) R_BRACKET; - -typeAssertion: DOT L_PAREN type_ R_PAREN; - -arguments: - L_PAREN ( - (expressionList | type_ (COMMA expressionList)?) ELLIPSIS? COMMA? - )? R_PAREN; - -methodExpr: type_ DOT IDENTIFIER; - -eos: - SEMI - | EOF - | EOS - | {this.closingBracket()}? - ; \ No newline at end of file +mapType + : MAP L_BRACKET type_ R_BRACKET elementType + ; + +channelType + : (CHAN | CHAN RECEIVE | RECEIVE CHAN) elementType + ; + +methodSpec + : IDENTIFIER parameters result + | IDENTIFIER parameters + ; + +functionType + : FUNC signature + ; + +signature + : parameters result? + ; + +result + : parameters + | type_ + ; + +parameters + : L_PAREN (parameterDecl (COMMA parameterDecl)* COMMA?)? R_PAREN + ; + +parameterDecl + : identifierList? ELLIPSIS? type_ + ; + +expression + : primaryExpr + | unary_op = (PLUS | MINUS | EXCLAMATION | CARET | STAR | AMPERSAND | RECEIVE) expression + | expression mul_op = (STAR | DIV | MOD | LSHIFT | RSHIFT | AMPERSAND | BIT_CLEAR) expression + | expression add_op = (PLUS | MINUS | OR | CARET) expression + | expression rel_op = ( + EQUALS + | NOT_EQUALS + | LESS + | LESS_OR_EQUALS + | GREATER + | GREATER_OR_EQUALS + ) expression + | expression LOGICAL_AND expression + | expression LOGICAL_OR expression + ; + +primaryExpr + : operand + | conversion + | methodExpr + | primaryExpr ( DOT IDENTIFIER | index | slice_ | typeAssertion | arguments) + ; + +conversion + : type_ L_PAREN expression COMMA? R_PAREN + ; + +operand + : literal + | operandName typeArgs? + | L_PAREN expression R_PAREN + ; + +literal + : basicLit + | compositeLit + | functionLit + ; + +basicLit + : NIL_LIT + | integer + | string_ + | FLOAT_LIT + ; + +integer + : DECIMAL_LIT + | BINARY_LIT + | OCTAL_LIT + | HEX_LIT + | IMAGINARY_LIT + | RUNE_LIT + ; + +operandName + : IDENTIFIER + ; + +qualifiedIdent + : IDENTIFIER DOT IDENTIFIER + ; + +compositeLit + : literalType literalValue + ; + +literalType + : structType + | arrayType + | L_BRACKET ELLIPSIS R_BRACKET elementType + | sliceType + | mapType + | typeName typeArgs? + ; + +literalValue + : L_CURLY (elementList COMMA?)? R_CURLY + ; + +elementList + : keyedElement (COMMA keyedElement)* + ; + +keyedElement + : (key COLON)? element + ; + +key + : expression + | literalValue + ; + +element + : expression + | literalValue + ; + +structType + : STRUCT L_CURLY (fieldDecl eos)* R_CURLY + ; + +fieldDecl + : (identifierList type_ | embeddedField) tag = string_? + ; + +string_ + : RAW_STRING_LIT + | INTERPRETED_STRING_LIT + ; + +embeddedField + : STAR? typeName typeArgs? + ; + +functionLit + : FUNC signature block + ; // function + +index + : L_BRACKET expression R_BRACKET + ; + +slice_ + : L_BRACKET (expression? COLON expression? | expression? COLON expression COLON expression) R_BRACKET + ; + +typeAssertion + : DOT L_PAREN type_ R_PAREN + ; + +arguments + : L_PAREN ((expressionList | type_ (COMMA expressionList)?) ELLIPSIS? COMMA?)? R_PAREN + ; + +methodExpr + : type_ DOT IDENTIFIER + ; + +eos + : SEMI + | EOF + | EOS + | {this.closingBracket()}? + ; \ No newline at end of file diff --git a/graphql/GraphQL.g4 b/graphql/GraphQL.g4 index f0eba09980..4a31fce596 100644 --- a/graphql/GraphQL.g4 +++ b/graphql/GraphQL.g4 @@ -32,171 +32,259 @@ */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar GraphQL; //https://spec.graphql.org/October2021/#sec-Document -document: definition+ EOF; +document + : definition+ EOF + ; -definition: - executableDocument // deviation from 2018 (new) - | typeSystemDocument //https://spec.graphql.org/October2021/#TypeSystemDocument (new in 2021) - | typeSystemExtensionDocument; //https://spec.graphql.org/October2021/#TypeSystemExtensionDocument (new in 2021) +definition + : executableDocument // deviation from 2018 (new) + | typeSystemDocument //https://spec.graphql.org/October2021/#TypeSystemDocument (new in 2021) + | typeSystemExtensionDocument + ; //https://spec.graphql.org/October2021/#TypeSystemExtensionDocument (new in 2021) //https://spec.graphql.org/October2021/#ExecutableDocument -executableDocument: executableDefinition+; //(new) 2021 +executableDocument + : executableDefinition+ + ; //(new) 2021 //https://spec.graphql.org/October2021/#ExecutableDefinition -executableDefinition: operationDefinition | fragmentDefinition; +executableDefinition + : operationDefinition + | fragmentDefinition + ; //https://spec.graphql.org/October2021/#sec-Language.Operations -operationDefinition: - operationType name? variableDefinitions? directives? selectionSet - | selectionSet - ; +operationDefinition + : operationType name? variableDefinitions? directives? selectionSet + | selectionSet + ; -operationType: 'query' | 'mutation' | 'subscription'; +operationType + : 'query' + | 'mutation' + | 'subscription' + ; //https://spec.graphql.org/October2021/#sec-Selection-Sets -selectionSet: '{' selection+ '}'; +selectionSet + : '{' selection+ '}' + ; -selection: field +selection + : field | fragmentSpread | inlineFragment ; + //https://spec.graphql.org/October2021/#sec-Language.Fields -field: alias? name arguments? directives? selectionSet?; +field + : alias? name arguments? directives? selectionSet? + ; //https://spec.graphql.org/October2021/#sec-Language.Arguments -arguments: '(' argument+ ')'; -argument: name ':' value; +arguments + : '(' argument+ ')' + ; + +argument + : name ':' value + ; //https://spec.graphql.org/October2021/#sec-Field-Alias -alias: name ':'; +alias + : name ':' + ; //https://spec.graphql.org/October2021/#sec-Language.Fragments -fragmentSpread: '...' fragmentName directives?; -fragmentDefinition: - 'fragment' fragmentName typeCondition directives? selectionSet; -fragmentName: name; // except on +fragmentSpread + : '...' fragmentName directives? + ; + +fragmentDefinition + : 'fragment' fragmentName typeCondition directives? selectionSet + ; + +fragmentName + : name + ; // except on //https://spec.graphql.org/October2021/#sec-Type-Conditions -typeCondition: 'on' namedType; +typeCondition + : 'on' namedType + ; //https://spec.graphql.org/October2021/#sec-Inline-Fragments -inlineFragment: '...' typeCondition? directives? selectionSet; +inlineFragment + : '...' typeCondition? directives? selectionSet + ; //https://spec.graphql.org/October2021/#sec-Input-Values -value: - variable - | intValue - | floatValue - | stringValue - | booleanValue - | nullValue - | enumValue - | listValue - | objectValue - ; +value + : variable + | intValue + | floatValue + | stringValue + | booleanValue + | nullValue + | enumValue + | listValue + | objectValue + ; //https://spec.graphql.org/October2021/#sec-Int-Value -intValue: INT; +intValue + : INT + ; //https://spec.graphql.org/October2021/#sec-Float-Value -floatValue: FLOAT; +floatValue + : FLOAT + ; //https://spec.graphql.org/October2021/#sec-Boolean-Value booleanValue - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; //https://spec.graphql.org/October2021/#sec-String-Value -stringValue : STRING | BLOCK_STRING; +stringValue + : STRING + | BLOCK_STRING + ; //https://spec.graphql.org/October2021/#sec-Null-Value -nullValue: 'null'; +nullValue + : 'null' + ; //https://spec.graphql.org/October2021/#sec-Enum-Value -enumValue: name; //{ not (nullValue | booleanValue) }; +enumValue + : name + ; //{ not (nullValue | booleanValue) }; //https://spec.graphql.org/October2021/#sec-List-Value -listValue: '[' ']' +listValue + : '[' ']' | '[' value+ ']' ; //https://spec.graphql.org/October2021/#sec-Input-Object-Values -objectValue: '{' objectField* '}'; +objectValue + : '{' objectField* '}' + ; -objectField: name ':' value; +objectField + : name ':' value + ; //https://spec.graphql.org/October2021/#sec-Language.Variables -variable: '$' name; -variableDefinitions: '(' variableDefinition+ ')'; -variableDefinition: variable ':' type_ defaultValue?; -defaultValue: '=' value; +variable + : '$' name + ; + +variableDefinitions + : '(' variableDefinition+ ')' + ; + +variableDefinition + : variable ':' type_ defaultValue? + ; + +defaultValue + : '=' value + ; //https://spec.graphql.org/October2021/#sec-Type-References -type_: namedType '!'? +type_ + : namedType '!'? | listType '!'? ; -namedType: name; -listType: '[' type_ ']'; +namedType + : name + ; +listType + : '[' type_ ']' + ; //https://spec.graphql.org/October2021/#sec-Language.Directives -directives: directive+; -directive: '@' name arguments?; +directives + : directive+ + ; + +directive + : '@' name arguments? + ; // https://spec.graphql.org/October2021/#sec-Type-System // deviation from 2018 specs. Added type system document //https://spec.graphql.org/October2021/#TypeSystemDocument (new in 2021) -typeSystemDocument: typeSystemDefinition+; -typeSystemDefinition: schemaDefinition - | typeDefinition - | directiveDefinition - ; +typeSystemDocument + : typeSystemDefinition+ + ; + +typeSystemDefinition + : schemaDefinition + | typeDefinition + | directiveDefinition + ; // https://spec.graphql.org/October2021/#TypeSystemExtensionDocument (new in 2021) -typeSystemExtensionDocument: typeSystemExtension+; +typeSystemExtensionDocument + : typeSystemExtension+ + ; //https://spec.graphql.org/October2021/#sec-Type-System-Extensions -typeSystemExtension: schemaExtension +typeSystemExtension + : schemaExtension | typeExtension ; // https://spec.graphql.org/October2021/#sec-Schema -schemaDefinition: - 'schema' directives? '{' rootOperationTypeDefinition+ '}'; - -rootOperationTypeDefinition: operationType ':' namedType; +schemaDefinition + : 'schema' directives? '{' rootOperationTypeDefinition+ '}' + ; +rootOperationTypeDefinition + : operationType ':' namedType + ; //https://spec.graphql.org/October2021/#sec-Schema-Extension (deviation from 2018) -schemaExtension: - 'extend' 'schema' directives? '{' rootOperationTypeDefinition+ '}' //(new 2021) +schemaExtension + : 'extend' 'schema' directives? '{' rootOperationTypeDefinition+ '}' //(new 2021) | 'extend' 'schema' directives ; //https://spec.graphql.org/June2018/#OperationTypeDefinition //operationTypeDefinition: operationType ':' namedType; //removed in 2021 - - //https://spec.graphql.org/June2018/#sec-Descriptions -description: stringValue; +description + : stringValue + ; //https://spec.graphql.org/October2021/#sec-Types -typeDefinition: - scalarTypeDefinition - | objectTypeDefinition - | interfaceTypeDefinition - | unionTypeDefinition - | enumTypeDefinition - | inputObjectTypeDefinition; +typeDefinition + : scalarTypeDefinition + | objectTypeDefinition + | interfaceTypeDefinition + | unionTypeDefinition + | enumTypeDefinition + | inputObjectTypeDefinition + ; //https://spec.graphql.org/June2018/#sec-Type-Extensions -typeExtension : scalarTypeExtension +typeExtension + : scalarTypeExtension | objectTypeExtension | interfaceTypeExtension | unionTypeExtension @@ -205,88 +293,136 @@ typeExtension : scalarTypeExtension ; //https://spec.graphql.org/October2021/#sec-Scalars -scalarTypeDefinition: description? 'scalar' name directives?; +scalarTypeDefinition + : description? 'scalar' name directives? + ; //https://spec.graphql.org/October2021/#sec-Scalar-Extensions -scalarTypeExtension: 'extend' 'scalar' name directives; +scalarTypeExtension + : 'extend' 'scalar' name directives + ; // https://spec.graphql.org/October2021/#sec-Objects -objectTypeDefinition : - description? 'type' name implementsInterfaces? directives? fieldsDefinition?; +objectTypeDefinition + : description? 'type' name implementsInterfaces? directives? fieldsDefinition? + ; -implementsInterfaces: 'implements' '&'? namedType +implementsInterfaces + : 'implements' '&'? namedType | implementsInterfaces '&' namedType ; +fieldsDefinition + : '{' fieldDefinition+ '}' + ; -fieldsDefinition: '{' fieldDefinition+ '}'; -fieldDefinition: description? name argumentsDefinition? ':' type_ directives? ; +fieldDefinition + : description? name argumentsDefinition? ':' type_ directives? + ; //https://spec.graphql.org/October2021/#sec-Field-Arguments -argumentsDefinition: '(' inputValueDefinition+ ')'; -inputValueDefinition: description? name ':' type_ defaultValue? directives?; +argumentsDefinition + : '(' inputValueDefinition+ ')' + ; + +inputValueDefinition + : description? name ':' type_ defaultValue? directives? + ; //https://spec.graphql.org/October2021/#sec-Object-Extensions -objectTypeExtension: - 'extend' 'type' name implementsInterfaces? directives? fieldsDefinition +objectTypeExtension + : 'extend' 'type' name implementsInterfaces? directives? fieldsDefinition | 'extend' 'type' name implementsInterfaces? directives | 'extend' 'type' name implementsInterfaces ; //https://spec.graphql.org/October2021/#sec-Interfaces (deviation from 2018) -interfaceTypeDefinition: description? 'interface' name implementsInterfaces? directives? fieldsDefinition?; +interfaceTypeDefinition + : description? 'interface' name implementsInterfaces? directives? fieldsDefinition? + ; //https://spec.graphql.org/October2021/#sec-Interface-Extensions (deviation from 2018) -interfaceTypeExtension: 'extend' 'interface' name implementsInterfaces? directives? fieldsDefinition - | 'extend' 'interface' name implementsInterfaces? directives +interfaceTypeExtension + : 'extend' 'interface' name implementsInterfaces? directives? fieldsDefinition + | 'extend' 'interface' name implementsInterfaces? directives ; //https://spec.graphql.org/October2021/#sec-Unions -unionTypeDefinition: description? 'union' name directives? unionMemberTypes?; -unionMemberTypes: '=' '|'? namedType ('|'namedType)* ; +unionTypeDefinition + : description? 'union' name directives? unionMemberTypes? + ; + +unionMemberTypes + : '=' '|'? namedType ('|' namedType)* + ; //https://spec.graphql.org/October2021/#sec-Union-Extensions -unionTypeExtension : 'extend' 'union' name directives? unionMemberTypes +unionTypeExtension + : 'extend' 'union' name directives? unionMemberTypes | 'extend' 'union' name directives ; //https://spec.graphql.org/October2021/#sec-Enums -enumTypeDefinition: description? 'enum' name directives? enumValuesDefinition?; -enumValuesDefinition: '{' enumValueDefinition+ '}'; -enumValueDefinition: description? enumValue directives?; +enumTypeDefinition + : description? 'enum' name directives? enumValuesDefinition? + ; + +enumValuesDefinition + : '{' enumValueDefinition+ '}' + ; + +enumValueDefinition + : description? enumValue directives? + ; //https://spec.graphql.org/October2021/#sec-Enum-Extensions -enumTypeExtension: 'extend' 'enum' name directives? enumValuesDefinition +enumTypeExtension + : 'extend' 'enum' name directives? enumValuesDefinition | 'extend' 'enum' name directives ; //https://spec.graphql.org/October2021/#sec-Input-Objects -inputObjectTypeDefinition: description? 'input' name directives? inputFieldsDefinition?; -inputFieldsDefinition: '{' inputValueDefinition+ '}'; +inputObjectTypeDefinition + : description? 'input' name directives? inputFieldsDefinition? + ; + +inputFieldsDefinition + : '{' inputValueDefinition+ '}' + ; //https://spec.graphql.org/June2018/#sec-Input-Object-Extensions -inputObjectTypeExtension: 'extend' 'input' name directives? inputFieldsDefinition +inputObjectTypeExtension + : 'extend' 'input' name directives? inputFieldsDefinition | 'extend' 'input' name directives ; //https://spec.graphql.org/October2021/#sec-Type-System.Directives (new 2021, repeatable ) -directiveDefinition: description? 'directive' '@' name argumentsDefinition? 'repeatable'? 'on' directiveLocations; -directiveLocations: directiveLocation ('|' directiveLocation)*; -directiveLocation: executableDirectiveLocation | typeSystemDirectiveLocation; +directiveDefinition + : description? 'directive' '@' name argumentsDefinition? 'repeatable'? 'on' directiveLocations + ; -executableDirectiveLocation: - 'QUERY' +directiveLocations + : directiveLocation ('|' directiveLocation)* + ; + +directiveLocation + : executableDirectiveLocation + | typeSystemDirectiveLocation + ; + +executableDirectiveLocation + : 'QUERY' | 'MUTATION' | 'SUBSCRIPTION' | 'FIELD' | 'FRAGMENT_DEFINITION' | 'FRAGMENT_SPREAD' | 'INLINE_FRAGMENT' - | 'VARIABLE_DEFINITION' // new 2021 + | 'VARIABLE_DEFINITION' // new 2021 ; -typeSystemDirectiveLocation: - 'SCHEMA' +typeSystemDirectiveLocation + : 'SCHEMA' | 'SCALAR' | 'OBJECT' | 'FIELD_DEFINITION' @@ -300,80 +436,136 @@ typeSystemDirectiveLocation: ; //https://spec.graphql.org/October2021/#sec-Names -name: NAME; +name + : NAME + ; //https://spec.graphql.org/October2021/#sec-Language.Source-Text.Lexical-Tokens //Start lexer -NAME: [_A-Za-z] [_0-9A-Za-z]*; +NAME + : [_A-Za-z] [_0-9A-Za-z]* + ; -fragment CHARACTER: ( ESC | ~ ["\\]); -STRING: '"' CHARACTER* '"'; +fragment CHARACTER + : (ESC | ~ ["\\]) + ; + +STRING + : '"' CHARACTER* '"' + ; BLOCK_STRING - : '"""' .*? '"""' + : '"""' .*? '"""' ; -ID: STRING; +ID + : STRING + ; //https://spec.graphql.org/October2021/#EscapedCharacter -fragment ESC: '\\' ( ["\\/bfnrt] | UNICODE); +fragment ESC + : '\\' (["\\/bfnrt] | UNICODE) + ; + +fragment UNICODE + : 'u' HEX HEX HEX HEX + ; + +fragment HEX + : [0-9a-fA-F] + ; + +fragment NONZERO_DIGIT + : [1-9] + ; + +fragment DIGIT + : [0-9] + ; + +fragment FRACTIONAL_PART + : '.' DIGIT+ + ; + +fragment EXPONENTIAL_PART + : EXPONENT_INDICATOR SIGN? DIGIT+ + ; -fragment UNICODE: 'u' HEX HEX HEX HEX; +fragment EXPONENT_INDICATOR + : [eE] + ; -fragment HEX: [0-9a-fA-F]; +fragment SIGN + : [+-] + ; -fragment NONZERO_DIGIT: [1-9]; -fragment DIGIT: [0-9]; -fragment FRACTIONAL_PART: '.' DIGIT+; -fragment EXPONENTIAL_PART: EXPONENT_INDICATOR SIGN? DIGIT+; -fragment EXPONENT_INDICATOR: [eE]; -fragment SIGN: [+-]; -fragment NEGATIVE_SIGN: '-'; +fragment NEGATIVE_SIGN + : '-' + ; //https://spec.graphql.org/October2021/#sec-Float-Value -FLOAT: INT FRACTIONAL_PART +FLOAT + : INT FRACTIONAL_PART | INT EXPONENTIAL_PART | INT FRACTIONAL_PART EXPONENTIAL_PART ; -INT: NEGATIVE_SIGN? '0' +INT + : NEGATIVE_SIGN? '0' | NEGATIVE_SIGN? NONZERO_DIGIT DIGIT* ; //https://spec.graphql.org/October2021/#Punctuator -PUNCTUATOR: '!' +PUNCTUATOR + : '!' | '$' - | '(' | ')' + | '(' + | ')' | '...' | ':' | '=' | '@' - | '[' | ']' - | '{' | '}' + | '[' + | ']' + | '{' + | '}' | '|' ; // no leading zeros -fragment EXP: [Ee] [+\-]? INT; +fragment EXP + : [Ee] [+\-]? INT + ; //https://spec.graphql.org/October2021/#sec-Language.Source-Text.Ignored-Tokens // \- since - means "range" inside [...] -WS: [ \t\n\r]+ -> skip; -COMMA: ',' -> skip; +WS + : [ \t\n\r]+ -> skip + ; + +COMMA + : ',' -> skip + ; + LineComment - : '#' ~[\r\n]* - -> skip + : '#' ~[\r\n]* -> skip + ; + +UNICODE_BOM + : (UTF8_BOM | UTF16_BOM | UTF32_BOM) -> skip + ; + +UTF8_BOM + : '\uEFBBBF' ; -UNICODE_BOM: (UTF8_BOM - | UTF16_BOM - | UTF32_BOM - ) -> skip +UTF16_BOM + : '\uFEFF' ; -UTF8_BOM: '\uEFBBBF'; -UTF16_BOM: '\uFEFF'; -UTF32_BOM: '\u0000FEFF'; +UTF32_BOM + : '\u0000FEFF' + ; \ No newline at end of file diff --git a/graphstream-dgs/DGSLexer.g4 b/graphstream-dgs/DGSLexer.g4 index d7a4056ffe..c217d010a8 100644 --- a/graphstream-dgs/DGSLexer.g4 +++ b/graphstream-dgs/DGSLexer.g4 @@ -37,9 +37,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar DGSLexer; -MAGIC : 'DGS004' | 'DGS003'; +MAGIC: 'DGS004' | 'DGS003'; AN : 'an'; CN : 'cn'; @@ -51,38 +55,37 @@ CG : 'cg'; ST : 'st'; CL : 'cl'; -INT : ('+'|'-')? ( '0' | ( [1-9] ([0-9])* ) ); -REAL : INT ( '.' [0-9]*)? ( [Ee] ('+'|'-')? [0-9]*[1-9] )?; +INT : ('+' | '-')? ( '0' | ( [1-9] ([0-9])*)); +REAL : INT ( '.' [0-9]*)? ( [Ee] ('+' | '-')? [0-9]* [1-9])?; -PLUS : '+'; -MINUS : '-'; -COMMA : ','; +PLUS : '+'; +MINUS : '-'; +COMMA : ','; LBRACE : '{'; RBRACE : '}'; LBRACK : '['; RBRACK : ']'; -DOT : '.'; +DOT : '.'; LANGLE : '<'; RANGLE : '>'; EQUALS : '='; -COLON : ':'; +COLON : ':'; -EOL : '\r'|'\n'|'\r\n'; -WORD : ( 'a'..'z' | 'A'..'Z' ) ( 'a'..'z' | 'A'..'Z' | '0'..'9' | '-' | '_' )* ; -STRING : SQSTRING | DQSTRING; -fragment DQSTRING : '"' (DQESC|.)*? '"'; -fragment DQESC : '\\"' | '\\\\' ; -fragment SQSTRING : '\'' (SQESC|.)*? '\''; -fragment SQESC : '\\\'' | '\\\\' ; +EOL : '\r' | '\n' | '\r\n'; +WORD : ( 'a' ..'z' | 'A' ..'Z') ( 'a' ..'z' | 'A' ..'Z' | '0' ..'9' | '-' | '_')*; +STRING : SQSTRING | DQSTRING; +fragment DQSTRING : '"' (DQESC | .)*? '"'; +fragment DQESC : '\\"' | '\\\\'; +fragment SQSTRING : '\'' (SQESC | .)*? '\''; +fragment SQESC : '\\\'' | '\\\\'; -fragment HEXBYTE : ([0-9a-fA-F]) ([0-9a-fA-F]) ; -COLOR : '#' HEXBYTE HEXBYTE HEXBYTE HEXBYTE? ; +fragment HEXBYTE : ([0-9a-fA-F]) ([0-9a-fA-F]); +COLOR : '#' HEXBYTE HEXBYTE HEXBYTE HEXBYTE?; -START_COMMENT : '#' -> pushMode(CMT), skip; +START_COMMENT: '#' -> pushMode(CMT), skip; -WS : [ \t]+ -> skip; +WS: [ \t]+ -> skip; mode CMT; -COMMENT: .*? EOL -> popMode; - +COMMENT: .*? EOL -> popMode; \ No newline at end of file diff --git a/graphstream-dgs/DGSParser.g4 b/graphstream-dgs/DGSParser.g4 index 221984c7cf..5015369467 100644 --- a/graphstream-dgs/DGSParser.g4 +++ b/graphstream-dgs/DGSParser.g4 @@ -37,34 +37,105 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +// $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 DGSParser; -options { tokenVocab=DGSLexer; } +options { + tokenVocab = DGSLexer; +} + +dgs + : header (event | COMMENT | EOL)* EOF + ; + +header + : MAGIC EOL identifier INT INT EOL + ; + +event + : (an | cn | dn | ae | ce | de | cg | st | cl) (COMMENT | EOL) + ; + +an + : AN identifier attributes + ; + +cn + : CN identifier attributes + ; + +dn + : DN identifier + ; + +ae + : AE identifier identifier direction? identifier attributes + ; + +ce + : CE identifier attributes + ; + +de + : DE identifier + ; + +cg + : CG attributes + ; + +st + : ST REAL + ; + +cl + : CL + ; + +attributes + : attribute* + ; + +attribute + : (PLUS | MINUS)? identifier (assign value ( COMMA value)*)? + ; -dgs : header ( event | COMMENT | EOL )* EOF ; -header : MAGIC EOL identifier INT INT EOL; -event : ( an | cn | dn | ae | ce | de | cg | st | cl ) ( COMMENT | EOL ) ; +value + : STRING + | INT + | REAL + | COLOR + | array_ + | a_map + | identifier + ; -an : AN identifier attributes; -cn : CN identifier attributes; -dn : DN identifier; -ae : AE identifier identifier direction? identifier attributes; -ce : CE identifier attributes; -de : DE identifier; -cg : CG attributes; -st : ST REAL; -cl : CL; +array_ + : LBRACE (value ( COMMA value)*)? RBRACE + ; +a_map + : LBRACK (mapping ( COMMA mapping)*)? RBRACK + ; -attributes : attribute*; -attribute : (PLUS|MINUS)? identifier ( assign value ( COMMA value )* )? ; +mapping + : identifier assign value + ; -value : STRING | INT| REAL | COLOR | array_ | a_map | identifier; +direction + : LANGLE + | RANGLE + ; -array_ : LBRACE ( value ( COMMA value )* )? RBRACE; -a_map : LBRACK ( mapping ( COMMA mapping )* )? RBRACK; -mapping : identifier assign value; -direction : LANGLE | RANGLE ; -assign : EQUALS | COLON ; -identifier : STRING | INT | WORD ( DOT WORD )* ; +assign + : EQUALS + | COLON + ; +identifier + : STRING + | INT + | WORD ( DOT WORD)* + ; \ No newline at end of file diff --git a/gtin/gtin.g4 b/gtin/gtin.g4 index 3f07bf2dd8..aad06d6d30 100644 --- a/gtin/gtin.g4 +++ b/gtin/gtin.g4 @@ -35,236 +35,227 @@ http://www.gtin.info/ */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar gtin; gtin - : (gtin8 | gtin12 | gtin13 | gtin14 | supplemental_code) EOF - ; + : (gtin8 | gtin12 | gtin13 | gtin14 | supplemental_code) EOF + ; gtin8 - : ean8 - ; + : ean8 + ; ean8 - : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit + ; gtin12 - : upc - ; + : upc + ; gtin13 - : ean13 - ; + : ean13 + ; gtin14 - : ean14 - ; + : ean14 + ; upc - : (upc_a | upc_e) - ; + : (upc_a | upc_e) + ; // 12 digits (1+5+5+1) upc_a - : num_system upc_a_manufacturer upc_a_product check_code - ; + : num_system upc_a_manufacturer upc_a_product check_code + ; upc_a_manufacturer - : upc_a_5 - ; + : upc_a_5 + ; upc_a_product - : upc_a_5 - ; + : upc_a_5 + ; upc_a_5 - : any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit + ; upc_e - : any_digit any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit any_digit + ; num_system - : any_digit - ; + : any_digit + ; check_code - : any_digit - ; + : any_digit + ; supplemental_code - : supplemental_code_5 - | supplemental_code_2 - ; + : supplemental_code_5 + | supplemental_code_2 + ; supplemental_code_5 - : any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit + ; supplemental_code_2 - : any_digit any_digit - ; + : any_digit any_digit + ; // 13 digits (3+9+1) ean13 - : (ean13_ismn | ean13_issn | ean13_bookland | ean13_generic) - ; + : (ean13_ismn | ean13_issn | ean13_bookland | ean13_generic) + ; ean13_generic - : gs1_prefix ean_13_manprod check_code - ; + : gs1_prefix ean_13_manprod check_code + ; // (4+9) ean13_ismn - : gs1_prefix_ismn ismn_publisher_number ismn_item_number check_code - ; + : gs1_prefix_ismn ismn_publisher_number ismn_item_number check_code + ; // 4 digits gs1_prefix_ismn - : '9' '7' '9' '0' - ; + : '9' '7' '9' '0' + ; // 4 digits ismn_publisher_number - : any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit + ; // 4 digits ismn_item_number - : any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit + ; ean13_bookland - : (gs1_prefix_bookland_1 | gs1_prefix_bookland_2) bookland_isbn - ; + : (gs1_prefix_bookland_1 | gs1_prefix_bookland_2) bookland_isbn + ; // 9 digits that form the ISBN bookland_isbn - : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit + ; // 4 digits gs1_prefix_bookland_1 - : '9' '7' '9' ('1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') - ; + : '9' '7' '9' ('1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') + ; gs1_prefix_bookland_2 - : '9' '7' '8' any_digit - ; + : '9' '7' '8' any_digit + ; gs1_prefix_issn - : '9' '7' '7' - ; + : '9' '7' '7' + ; // (3+9+1) ean13_issn - : gs1_prefix_issn issn check_code - ; + : gs1_prefix_issn issn check_code + ; // 9 digits that form the ISSN issn - : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit + ; // 9 digits in two groups of variable length ean_13_manprod - : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit + ; gs1_prefix - : any_digit any_digit any_digit - ; + : any_digit any_digit any_digit + ; ean14 - : ean14_packaging ean14_product check_code - ; + : ean14_packaging ean14_product check_code + ; // 2 digits ean14_appid - : any_digit any_digit - ; + : any_digit any_digit + ; // 1 digit ean14_packaging - : ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8') - ; + : ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8') + ; // 12 digits ean14_product - : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit - ; + : any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit any_digit + ; any_digit - : DIGIT_0 - | DIGIT_1 - | DIGIT_2 - | DIGIT_3 - | DIGIT_4 - | DIGIT_5 - | DIGIT_6 - | DIGIT_7 - | DIGIT_8 - | DIGIT_9 - ; - + : DIGIT_0 + | DIGIT_1 + | DIGIT_2 + | DIGIT_3 + | DIGIT_4 + | DIGIT_5 + | DIGIT_6 + | DIGIT_7 + | DIGIT_8 + | DIGIT_9 + ; DIGIT_0 - : '0' - ; - + : '0' + ; DIGIT_1 - : '1' - ; - + : '1' + ; DIGIT_2 - : '2' - ; - + : '2' + ; DIGIT_3 - : '3' - ; - + : '3' + ; DIGIT_4 - : '4' - ; - + : '4' + ; DIGIT_5 - : '5' - ; - + : '5' + ; DIGIT_6 - : '6' - ; - + : '6' + ; DIGIT_7 - : '7' - ; - + : '7' + ; DIGIT_8 - : '8' - ; - + : '8' + ; DIGIT_9 - : '9' - ; - + : '9' + ; HYPHEN - : '-' -> skip - ; - + : '-' -> skip + ; WS - : [ \t\r\n] + -> skip - ; + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/guido/guido.g4 b/guido/guido.g4 index b27faef35e..daea6eddb9 100644 --- a/guido/guido.g4 +++ b/guido/guido.g4 @@ -30,168 +30,164 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar guido; prog - : ((segment +) | sequencelist) EOF - ; + : ((segment+) | sequencelist) EOF + ; segment - : '{' sequencelist + '}' - ; + : '{' sequencelist+ '}' + ; sequencelist - : sequence (',' sequence)* - ; + : sequence (',' sequence)* + ; sequence - : '[' (tag | note | chord) + ']' - ; + : '[' (tag | note | chord)+ ']' + ; tag - : TAGSTART tagname parameters? notes? - ; + : TAGSTART tagname parameters? notes? + ; tagname - : title - | tempo - | clef - | meter - | slur - | key - | barformat - | staff - | t - | repeatEnd - ; + : title + | tempo + | clef + | meter + | slur + | key + | barformat + | staff + | t + | repeatEnd + ; parameters - : '<' parameter (',' parameter)* '>' - ; + : '<' parameter (',' parameter)* '>' + ; parameter - : STRINGLITERAL - | number - | kvpair - ; + : STRINGLITERAL + | number + | kvpair + ; kvpair - : STRING '=' (STRING | NUMBER) + - ; + : STRING '=' (STRING | NUMBER)+ + ; notes - : '(' (note | chord) + ')' - ; + : '(' (note | chord)+ ')' + ; note - : notename accidental? octave? duration? dotting? - ; + : notename accidental? octave? duration? dotting? + ; chord - : '{' note (',' note)* '}' - ; + : '{' note (',' note)* '}' + ; notename - : STRING - | REST - ; + : STRING + | REST + ; accidental - : '#' - | '&' - ; + : '#' + | '&' + ; number - : ('-' | '+')? NUMBER - ; + : ('-' | '+')? NUMBER + ; octave - : number - ; + : number + ; fraction - : number? ('/' number)? - ; + : number? ('/' number)? + ; duration - : '*'? fraction - ; + : '*'? fraction + ; dotting - : '.' + - ; + : '.'+ + ; title - : 'title' - ; + : 'title' + ; tempo - : 'tempo' - ; + : 'tempo' + ; clef - : 'clef' - ; + : 'clef' + ; meter - : 'meter' - ; + : 'meter' + ; slur - : 'slur' - ; + : 'slur' + ; key - : 'key' - ; + : 'key' + ; barformat - : 'barFormat' - ; + : 'barFormat' + ; staff - : 'staff' - ; + : 'staff' + ; repeatEnd - : 'repeatEnd' - ; + : 'repeatEnd' + ; t - : 't' - ; - + : 't' + ; TAGSTART - : '\\' - ; - + : '\\' + ; REST - : '_' - ; - + : '_' + ; NUMBER - : [0-9] + - ; - + : [0-9]+ + ; STRING - : [a-zA-Z] + - ; - + : [a-zA-Z]+ + ; STRINGLITERAL - : '"' ~'"'* '"' - ; - + : '"' ~'"'* '"' + ; COMMENT - : '%' ~ [\r\n]* -> skip - ; - + : '%' ~ [\r\n]* -> skip + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/guitartab/guitartab.g4 b/guitartab/guitartab.g4 index 64bb16c8d5..a05e74f720 100644 --- a/guitartab/guitartab.g4 +++ b/guitartab/guitartab.g4 @@ -29,107 +29,110 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar guitartab; tab - : string+ EOF - ; + : string+ EOF + ; string - : note (position FRET)+ - ; + : note (position FRET)+ + ; position - : (FINGER | BARLNE)+ - ; + : (FINGER | BARLNE)+ + ; note - : BA - | BB - | BC - | BD - | BE - | BF - | BG - | LA - | LB - | LC - | LD - | LE - | LF - | LG - ; + : BA + | BB + | BC + | BD + | BE + | BF + | BG + | LA + | LB + | LC + | LD + | LE + | LF + | LG + ; BA - : 'A' - ; + : 'A' + ; BB - : 'B' - ; + : 'B' + ; BC - : 'C' - ; + : 'C' + ; BD - : 'D' - ; + : 'D' + ; BE - : 'E' - ; + : 'E' + ; BF - : 'F' - ; + : 'F' + ; BG - : 'G' - ; + : 'G' + ; LA - : 'a' - ; + : 'a' + ; LB - : 'b' - ; + : 'b' + ; LC - : 'c' - ; + : 'c' + ; LD - : 'd' - ; + : 'd' + ; LE - : 'e' - ; + : 'e' + ; LF - : 'f' - ; + : 'f' + ; LG - : 'g' - ; + : 'g' + ; FINGER - : 'x' - | 'o' - ; + : 'x' + | 'o' + ; BARLNE - : '-' - ; + : '-' + ; FRET - : '|' - ; + : '|' + ; WHITESPACE - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/gvpr/gvprLexer.g4 b/gvpr/gvprLexer.g4 index 3550c7dd63..9d1ebfc6ed 100644 --- a/gvpr/gvprLexer.g4 +++ b/gvpr/gvprLexer.g4 @@ -1,327 +1,222 @@ -lexer grammar gvprLexer; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -options { superClass = GvprLexerBase; } +lexer grammar gvprLexer; + +options { + superClass = GvprLexerBase; +} // Insert here @header for C++ lexer. -MLCOMMENT : '/*' .*? '*/' -> channel(HIDDEN); -SLCOMMENT : '//' ~[\n\r]* -> channel(HIDDEN); -SHELLCOMMENT : '#' { this.IsColumnZero() }? ~[\n\r]* -> channel(HIDDEN); +MLCOMMENT : '/*' .*? '*/' -> channel(HIDDEN); +SLCOMMENT : '//' ~[\n\r]* -> channel(HIDDEN); +SHELLCOMMENT : '#' { this.IsColumnZero() }? ~[\n\r]* -> channel(HIDDEN); -IntegerConstant - : DecimalConstant IntegerSuffix? +IntegerConstant: + DecimalConstant IntegerSuffix? | OctalConstant IntegerSuffix? | HexadecimalConstant IntegerSuffix? | BinaryConstant - ; - -FloatingConstant - : DecimalFloatingConstant - | HexadecimalFloatingConstant - ; - -CharacterConstant - : '\'' CCharSequence '\'' - | 'L\'' CCharSequence '\'' - | 'u\'' CCharSequence '\'' - | 'U\'' CCharSequence '\'' - ; - -AEQ : '=' ; -AMEQ : '-=' ; -AMP : '&' ; -AND : '&&' ; -APEQ : '+=' ; -ASEQ : '*=' ; -ASLEQ : '/=' ; -BANG : '!' ; -BEGIN : 'BEGIN' ; -BEG_G : 'BEG_G' ; -BREAK : 'break' ; -CASE : 'case' ; -CB : ']' ; -CCBC : '}' ; -CIRCUMFLEX : '^' ; -CHAR : 'char' ; -COLON : ':' ; -COMMA : ',' ; -CONTINUE : 'continue' ; -CP : ')' ; -DEC : '--' ; -DEFAULT : 'default' ; -DOUBLE : 'double' ; -DOLLAR : '$' ; -E : 'E' ; -ELSE : 'else' ; -END : 'END' ; -END_G : 'END_G' ; -EQ : '==' ; -EXIT : 'exit' ; -FLOAT : 'float' ; -FOR : 'for' ; -GE : '>=' ; -GT : '>' ; -GSUB : 'gsub' ; -IF : 'if' ; -IN_OP : 'in' ; -INC : '++' ; -INT : 'int' ; -ITERATER : 'forr' ; -LE : '<=' ; -LT : '<' ; -LONG : 'long' ; -LSH : 'lsh' ; -N : 'N' ; -NE : '!=' ; -OB : '[' ; -OCBC : '{' ; -OP : '(' ; -OR : '||' ; -PERCENT : '%' ; -POUND : '#' ; -PRINTF : 'printf' ; -PROCEDURE : 'procedure' ; -QUERY : 'query' ; -RAND : 'rand' ; -RETURN : 'return' ; -RSH : 'rsh' ; -SCANF : 'scanf' ; -SEMI_COLON : ';' ; -SPLIT : 'split' ; -SPRINTF : 'sprintf' ; -SQUIGGLE : '~' ; -PLUS : '+' ; -QM : '?' ; -DOT : '.' ; -MINUS : '-' ; -SLASH : '/' ; -PIPE : '|' ; -SRAND : 'srand' ; -SSCANF : 'sscanf' ; -STAR : '*' ; -STATIC : 'static' ; -STRING : 'string' ; -SUB : 'sub' ; -SUBSTR : 'substr' ; -SWITCH : 'switch' ; -TOKENS : 'tokens' ; -UNSET : 'unset' ; -UNSIGNED : 'unsigned' ; -VOID : 'void' ; -WHILE : 'while' ; -XPRINT : 'print' ; - -StringLit - : EncodingPrefix? '"' SCharSequence? '"' - ; - -ID - : IdentifierNondigit - ( IdentifierNondigit - | Digit - )* - ; - -WS : [ \t\n\r]+ -> channel(HIDDEN); - -fragment -EncodingPrefix - : 'u8' - | 'u' - | 'U' - | 'L' - ; - -fragment -SCharSequence - : SChar+ - ; - -fragment -SChar - : ~["\\\r\n] - | EscapeSequence - | '\\\n' // Added line - | '\\\r\n' // Added line - ; - -fragment -IdentifierNondigit - : Nondigit - | UniversalCharacterName +; + +FloatingConstant: DecimalFloatingConstant | HexadecimalFloatingConstant; + +CharacterConstant: + '\'' CCharSequence '\'' + | 'L\'' CCharSequence '\'' + | 'u\'' CCharSequence '\'' + | 'U\'' CCharSequence '\'' +; + +AEQ : '='; +AMEQ : '-='; +AMP : '&'; +AND : '&&'; +APEQ : '+='; +ASEQ : '*='; +ASLEQ : '/='; +BANG : '!'; +BEGIN : 'BEGIN'; +BEG_G : 'BEG_G'; +BREAK : 'break'; +CASE : 'case'; +CB : ']'; +CCBC : '}'; +CIRCUMFLEX : '^'; +CHAR : 'char'; +COLON : ':'; +COMMA : ','; +CONTINUE : 'continue'; +CP : ')'; +DEC : '--'; +DEFAULT : 'default'; +DOUBLE : 'double'; +DOLLAR : '$'; +E : 'E'; +ELSE : 'else'; +END : 'END'; +END_G : 'END_G'; +EQ : '=='; +EXIT : 'exit'; +FLOAT : 'float'; +FOR : 'for'; +GE : '>='; +GT : '>'; +GSUB : 'gsub'; +IF : 'if'; +IN_OP : 'in'; +INC : '++'; +INT : 'int'; +ITERATER : 'forr'; +LE : '<='; +LT : '<'; +LONG : 'long'; +LSH : 'lsh'; +N : 'N'; +NE : '!='; +OB : '['; +OCBC : '{'; +OP : '('; +OR : '||'; +PERCENT : '%'; +POUND : '#'; +PRINTF : 'printf'; +PROCEDURE : 'procedure'; +QUERY : 'query'; +RAND : 'rand'; +RETURN : 'return'; +RSH : 'rsh'; +SCANF : 'scanf'; +SEMI_COLON : ';'; +SPLIT : 'split'; +SPRINTF : 'sprintf'; +SQUIGGLE : '~'; +PLUS : '+'; +QM : '?'; +DOT : '.'; +MINUS : '-'; +SLASH : '/'; +PIPE : '|'; +SRAND : 'srand'; +SSCANF : 'sscanf'; +STAR : '*'; +STATIC : 'static'; +STRING : 'string'; +SUB : 'sub'; +SUBSTR : 'substr'; +SWITCH : 'switch'; +TOKENS : 'tokens'; +UNSET : 'unset'; +UNSIGNED : 'unsigned'; +VOID : 'void'; +WHILE : 'while'; +XPRINT : 'print'; + +StringLit: EncodingPrefix? '"' SCharSequence? '"'; + +ID: IdentifierNondigit ( IdentifierNondigit | Digit)*; + +WS: [ \t\n\r]+ -> channel(HIDDEN); + +fragment EncodingPrefix: 'u8' | 'u' | 'U' | 'L'; + +fragment SCharSequence: SChar+; + +fragment SChar: + ~["\\\r\n] + | EscapeSequence + | '\\\n' // Added line + | '\\\r\n' // Added line +; + +fragment IdentifierNondigit: + Nondigit + | UniversalCharacterName //| // other implementation-defined characters... | '$' | '#' - ; - -fragment -Nondigit - : [a-zA-Z_] - ; - -fragment -Digit - : [0-9] - ; - -fragment -BinaryConstant - : '0' [bB] [0-1]+ - ; - -fragment -DecimalConstant - : NonzeroDigit Digit* - ; - -fragment -OctalConstant - : '0' OctalDigit* - ; - -fragment -HexadecimalConstant - : HexadecimalPrefix HexadecimalDigit+ - ; - -fragment -HexadecimalPrefix - : '0' [xX] - ; - -fragment -NonzeroDigit - : [1-9] - ; - -fragment -OctalDigit - : [0-7] - ; - -fragment -HexadecimalDigit - : [0-9a-fA-F] - ; - -fragment -IntegerSuffix - : UnsignedSuffix LongSuffix? - | UnsignedSuffix LongLongSuffix - | LongSuffix UnsignedSuffix? - | LongLongSuffix UnsignedSuffix? - ; - -fragment -UnsignedSuffix - : [uU] - ; - -fragment -LongSuffix - : [lL] - ; - -fragment -LongLongSuffix - : 'll' | 'LL' - ; - -fragment -DecimalFloatingConstant - : FractionalConstant ExponentPart? FloatingSuffix? - | DigitSequence ExponentPart FloatingSuffix? - ; - -fragment -DigitSequence - : Digit+ - ; - -fragment -HexadecimalFloatingConstant - : HexadecimalPrefix (HexadecimalFractionalConstant | HexadecimalDigitSequence) BinaryExponentPart FloatingSuffix? - ; - -fragment -FractionalConstant - : DigitSequence? '.' DigitSequence - | DigitSequence '.' - ; - -fragment -ExponentPart - : [eE] Sign? DigitSequence - ; - -fragment -Sign - : [+-] - ; - -fragment -UniversalCharacterName - : '\\u' HexQuad - | '\\U' HexQuad HexQuad - ; - -fragment -CCharSequence - : CChar+ - ; - -fragment -CChar - : ~['\\\r\n] - | EscapeSequence - ; - - -fragment -FloatingSuffix - : [flFL] - ; - -fragment -HexadecimalFractionalConstant - : HexadecimalDigitSequence? '.' HexadecimalDigitSequence - | HexadecimalDigitSequence '.' - ; - -fragment -HexadecimalDigitSequence - : HexadecimalDigit+ - ; - -fragment -BinaryExponentPart - : [pP] Sign? DigitSequence - ; - -fragment -HexQuad - : HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit - ; - -fragment -EscapeSequence - : SimpleEscapeSequence - | OctalEscapeSequence - | HexadecimalEscapeSequence - | UniversalCharacterName - ; - -fragment -SimpleEscapeSequence - : '\\' ['"?abfnrtv\\.] - ; - -fragment -OctalEscapeSequence - : '\\' OctalDigit OctalDigit? OctalDigit? - ; - -fragment -HexadecimalEscapeSequence - : '\\x' HexadecimalDigit+ - ; +; + +fragment Nondigit: [a-zA-Z_]; + +fragment Digit: [0-9]; + +fragment BinaryConstant: '0' [bB] [0-1]+; + +fragment DecimalConstant: NonzeroDigit Digit*; + +fragment OctalConstant: '0' OctalDigit*; + +fragment HexadecimalConstant: HexadecimalPrefix HexadecimalDigit+; + +fragment HexadecimalPrefix: '0' [xX]; + +fragment NonzeroDigit: [1-9]; + +fragment OctalDigit: [0-7]; + +fragment HexadecimalDigit: [0-9a-fA-F]; + +fragment IntegerSuffix: + UnsignedSuffix LongSuffix? + | UnsignedSuffix LongLongSuffix + | LongSuffix UnsignedSuffix? + | LongLongSuffix UnsignedSuffix? +; + +fragment UnsignedSuffix: [uU]; + +fragment LongSuffix: [lL]; + +fragment LongLongSuffix: 'll' | 'LL'; + +fragment DecimalFloatingConstant: + FractionalConstant ExponentPart? FloatingSuffix? + | DigitSequence ExponentPart FloatingSuffix? +; + +fragment DigitSequence: Digit+; + +fragment HexadecimalFloatingConstant: + HexadecimalPrefix (HexadecimalFractionalConstant | HexadecimalDigitSequence) BinaryExponentPart FloatingSuffix? +; + +fragment FractionalConstant: DigitSequence? '.' DigitSequence | DigitSequence '.'; + +fragment ExponentPart: [eE] Sign? DigitSequence; + +fragment Sign: [+-]; + +fragment UniversalCharacterName: '\\u' HexQuad | '\\U' HexQuad HexQuad; + +fragment CCharSequence: CChar+; + +fragment CChar: ~['\\\r\n] | EscapeSequence; + +fragment FloatingSuffix: [flFL]; + +fragment HexadecimalFractionalConstant: + HexadecimalDigitSequence? '.' HexadecimalDigitSequence + | HexadecimalDigitSequence '.' +; + +fragment HexadecimalDigitSequence: HexadecimalDigit+; + +fragment BinaryExponentPart: [pP] Sign? DigitSequence; + +fragment HexQuad: HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit; + +fragment EscapeSequence: + SimpleEscapeSequence + | OctalEscapeSequence + | HexadecimalEscapeSequence + | UniversalCharacterName +; + +fragment SimpleEscapeSequence: '\\' ['"?abfnrtv\\.]; + +fragment OctalEscapeSequence: '\\' OctalDigit OctalDigit? OctalDigit?; + +fragment HexadecimalEscapeSequence: '\\x' HexadecimalDigit+; \ No newline at end of file diff --git a/gvpr/gvprParser.g4 b/gvpr/gvprParser.g4 index 70642bd4de..e9920ad4d9 100644 --- a/gvpr/gvprParser.g4 +++ b/gvpr/gvprParser.g4 @@ -1,10 +1,18 @@ -parser grammar gvprParser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab = gvprLexer; superClass = GvprParserBase; } +parser grammar gvprParser; + +options { + tokenVocab = gvprLexer; + superClass = GvprParserBase; +} // Insert here @header for C++ parser. -preds: pred* EOF; +preds + : pred* EOF + ; pred : 'BEGIN' ('{' program '}')? @@ -28,7 +36,7 @@ action_ ; statement_list - : statement ( ( { this.IsSemiRequired() }? ';' | { this.IsSemiNotRequired() }? ) statement )* ';'? + : statement (( { this.IsSemiRequired() }? ';' | { this.IsSemiNotRequired() }?) statement)* ';'? ; statement @@ -41,7 +49,7 @@ statement | 'for' '(' expr? ';' expr? ';' expr? ')' statement | 'forr' '(' variable ')' statement | UNSET '(' ID ')' - | UNSET '(' ID ',' expr ')' + | UNSET '(' ID ',' expr ')' | WHILE '(' expr ')' statement | SWITCH '(' expr ')' '{' switch_list '}' | BREAK expr? @@ -99,20 +107,20 @@ else_ expr : '(' expr ')' | '(' declare ')' expr - | (INC|DEC) variable - | variable (INC|DEC) + | (INC | DEC) variable + | variable (INC | DEC) | ('!' expr | '#' ID | '~' expr | '-' expr | '+' expr | '&' variable) - | expr ('*'|'/'|'%') expr - | expr (('+'|'-') expr | IN_OP ID) - | expr (LSH|RSH) expr - | expr ('<'|'>'|LE|GE) expr - | expr (EQ|NE) expr + | expr ('*' | '/' | '%') expr + | expr (('+' | '-') expr | IN_OP ID) + | expr (LSH | RSH) expr + | expr ('<' | '>' | LE | GE) expr + | expr (EQ | NE) expr | expr '&' expr | expr '^' expr | expr '|' expr | expr AND expr | expr OR expr - | expr '?' expr ':' expr + | expr '?' expr ':' expr | expr ',' expr | array_ '[' args ']' | function '(' args ')' @@ -179,7 +187,7 @@ args ; arg_list - : expr // %prec ',' + : expr // %prec ',' | arg_list ',' expr ; @@ -222,6 +230,14 @@ finitialize_ : '(' formals ')' '{' statement_list? '}' ; -label : ID; -declare : (CHAR | DOUBLE | FLOAT | INT | LONG | UNSIGNED | VOID | STRING | ID) '*'? ; -function : ID ; +label + : ID + ; + +declare + : (CHAR | DOUBLE | FLOAT | INT | LONG | UNSIGNED | VOID | STRING | ID) '*'? + ; + +function + : ID + ; \ No newline at end of file diff --git a/haskell/HaskellLexer.g4 b/haskell/HaskellLexer.g4 index ef725daa71..70d5303326 100644 --- a/haskell/HaskellLexer.g4 +++ b/haskell/HaskellLexer.g4 @@ -26,163 +26,203 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar HaskellLexer; -options { superClass=HaskellBaseLexer; } +options { + superClass = HaskellBaseLexer; +} -NEWLINE : ('\r'? '\n' | '\r') { +NEWLINE: + ('\r'? '\n' | '\r') { this.processNEWLINEToken(); -} ; +} +; -TAB : [\t]+ { +TAB: + [\t]+ { this.processTABToken(); -} ; +} +; -WS : [\u0020\u00a0\u1680\u2000\u200a\u202f\u205f\u3000]+ { +WS: + [\u0020\u00a0\u1680\u2000\u200a\u202f\u205f\u3000]+ { this.processWSToken(); -} ; - -AS : 'as' ; -CASE : 'case' ; -CLASS : 'class' ; -DATA : 'data' ; -DEFAULT : 'default' ; -DERIVING : 'deriving' ; -DO : 'do' ; -ELSE : 'else' ; -HIDING : 'hiding' ; -IF : 'if' ; -IMPORT : 'import' ; -IN : 'in' ; -INFIX : 'infix' ; -INFIXL : 'infixl' ; -INFIXR : 'infixr' ; -INSTANCE : 'instance' ; -LET : 'let' ; -MODULE : 'module' ; -NEWTYPE : 'newtype' ; -OF : 'of' ; -QUALIFIED : 'qualified' ; -THEN : 'then' ; -TYPE : 'type' ; -WHERE : 'where' ; -WILDCARD : '_' ; +} +; -FORALL : 'forall' ; -FOREIGN : 'foreign' ; -EXPORT : 'export' ; -SAFE : 'safe' ; -INTERRUPTIBLE : 'interruptible' ; -UNSAFE : 'unsafe' ; -MDO : 'mdo' ; -FAMILY : 'family' ; -ROLE : 'role' ; -STDCALL : 'stdcall' ; -CCALL : 'ccall' ; -CAPI : 'capi' ; -CPPCALL : 'cplusplus' ; -JSCALL : 'javascript' ; -REC : 'rec' ; -GROUP : 'group' ; -BY : 'by' ; -USING : 'using' ; -PATTERN : 'pattern' ; -STOCK : 'stock' ; -ANYCLASS : 'anyclass' ; -VIA : 'via' ; +AS : 'as'; +CASE : 'case'; +CLASS : 'class'; +DATA : 'data'; +DEFAULT : 'default'; +DERIVING : 'deriving'; +DO : 'do'; +ELSE : 'else'; +HIDING : 'hiding'; +IF : 'if'; +IMPORT : 'import'; +IN : 'in'; +INFIX : 'infix'; +INFIXL : 'infixl'; +INFIXR : 'infixr'; +INSTANCE : 'instance'; +LET : 'let'; +MODULE : 'module'; +NEWTYPE : 'newtype'; +OF : 'of'; +QUALIFIED : 'qualified'; +THEN : 'then'; +TYPE : 'type'; +WHERE : 'where'; +WILDCARD : '_'; -LANGUAGE : 'LANGUAGE' ; -OPTIONS_GHC : 'OPTIONS_GHC' ; -OPTIONS : 'OPTIONS' ; -INLINE : 'INLINE' ; -NOINLINE : 'NOINLINE' ; -SPECIALISE : 'SPECIALISE' ; -SPECINLINE : 'SPECIALISE_INLINE'; -SOURCE : 'SOURCE' ; -RULES : 'RULES' ; -SCC : 'SCC' ; -DEPRECATED : 'DEPRECATED' ; -WARNING : 'WARNING' ; -UNPACK : 'UNPACK' ; -NOUNPACK : 'NOUNPACK' ; -ANN : 'ANN' ; -MINIMAL : 'MINIMAL' ; -CTYPE : 'CTYPE' ; -OVERLAPPING : 'OVERLAPPING' ; -OVERLAPPABLE : 'OVERLAPPABLE' ; -OVERLAPS : 'OVERLAPS' ; -INCOHERENT : 'INCOHERENT' ; -COMPLETE : 'COMPLETE' ; +FORALL : 'forall'; +FOREIGN : 'foreign'; +EXPORT : 'export'; +SAFE : 'safe'; +INTERRUPTIBLE : 'interruptible'; +UNSAFE : 'unsafe'; +MDO : 'mdo'; +FAMILY : 'family'; +ROLE : 'role'; +STDCALL : 'stdcall'; +CCALL : 'ccall'; +CAPI : 'capi'; +CPPCALL : 'cplusplus'; +JSCALL : 'javascript'; +REC : 'rec'; +GROUP : 'group'; +BY : 'by'; +USING : 'using'; +PATTERN : 'pattern'; +STOCK : 'stock'; +ANYCLASS : 'anyclass'; +VIA : 'via'; +LANGUAGE : 'LANGUAGE'; +OPTIONS_GHC : 'OPTIONS_GHC'; +OPTIONS : 'OPTIONS'; +INLINE : 'INLINE'; +NOINLINE : 'NOINLINE'; +SPECIALISE : 'SPECIALISE'; +SPECINLINE : 'SPECIALISE_INLINE'; +SOURCE : 'SOURCE'; +RULES : 'RULES'; +SCC : 'SCC'; +DEPRECATED : 'DEPRECATED'; +WARNING : 'WARNING'; +UNPACK : 'UNPACK'; +NOUNPACK : 'NOUNPACK'; +ANN : 'ANN'; +MINIMAL : 'MINIMAL'; +CTYPE : 'CTYPE'; +OVERLAPPING : 'OVERLAPPING'; +OVERLAPPABLE : 'OVERLAPPABLE'; +OVERLAPS : 'OVERLAPS'; +INCOHERENT : 'INCOHERENT'; +COMPLETE : 'COMPLETE'; -LCASE : '\\' (NEWLINE | WS)* 'case' ; +LCASE: '\\' (NEWLINE | WS)* 'case'; -fragment SYMBOL : ASCSYMBOL | UNISYMBOL; -DoubleArrow : '=>' ; -DoubleColon : '::' ; -Arrow : '->' ; -Revarrow : '<-' ; -LarrowTail : '-<' ; -RarrowTail : '>-' ; -LLarrowTail : '-<<' ; -RRarrowTail : '>>-' ; -Hash : '#' ; -Less : '<' ; -Greater : '>' ; -Ampersand : '&' ; -Pipe : '|' ; -Bang : '!' ; -Caret : '^' ; -Plus : '+' ; -Minus : '-' ; -Asterisk : '*' ; -Percent : '%' ; -Divide : '/' ; -Tilde : '~' ; -Atsign : '@' ; -DDollar : '$$' ; -Dollar : '$' ; -DoubleDot : '..' ; -Dot : '.' ; -Semi : ';' ; -QuestionMark : '?' ; -Comma : ',' ; -Colon : ':' ; -Eq : '=' ; -Quote : '\'' ; +fragment SYMBOL : ASCSYMBOL | UNISYMBOL; +DoubleArrow : '=>'; +DoubleColon : '::'; +Arrow : '->'; +Revarrow : '<-'; +LarrowTail : '-<'; +RarrowTail : '>-'; +LLarrowTail : '-<<'; +RRarrowTail : '>>-'; +Hash : '#'; +Less : '<'; +Greater : '>'; +Ampersand : '&'; +Pipe : '|'; +Bang : '!'; +Caret : '^'; +Plus : '+'; +Minus : '-'; +Asterisk : '*'; +Percent : '%'; +Divide : '/'; +Tilde : '~'; +Atsign : '@'; +DDollar : '$$'; +Dollar : '$'; +DoubleDot : '..'; +Dot : '.'; +Semi : ';'; +QuestionMark : '?'; +Comma : ','; +Colon : ':'; +Eq : '='; +Quote : '\''; DoubleQuote : '\'\''; -ReverseSlash : '\\' ; -BackQuote : '`' ; -AopenParen :'(|' WS; -AcloseParen :WS '|)'; -TopenTexpQuote : '[||' ; -TcloseTExpQoute : '||]' ; -TopenExpQuote : '[|' ; -TopenPatQuote : '[p|' ; -TopenTypQoute : '[t|' ; -TopenDecQoute : '[d|' ; -TcloseQoute : '|]' ; -OpenBoxParen : '(#' ; -CloseBoxParen : '#)' ; -OpenRoundBracket : '(' ; -CloseRoundBracket : ')' ; -OpenSquareBracket : '[' ; -CloseSquareBracket : ']' ; - +ReverseSlash : '\\'; +BackQuote : '`'; +AopenParen : '(|' WS; +AcloseParen : WS '|)'; +TopenTexpQuote : '[||'; +TcloseTExpQoute : '||]'; +TopenExpQuote : '[|'; +TopenPatQuote : '[p|'; +TopenTypQoute : '[t|'; +TopenDecQoute : '[d|'; +TcloseQoute : '|]'; +OpenBoxParen : '(#'; +CloseBoxParen : '#)'; +OpenRoundBracket : '('; +CloseRoundBracket : ')'; +OpenSquareBracket : '['; +CloseSquareBracket : ']'; -CHAR : '\'' (' ' | DECIMAL | SMALL | LARGE - | SYMBOL | DIGIT | ',' | ';' | '(' | ')' - | '[' | ']' | '`' | '"') '\''; +CHAR: + '\'' ( + ' ' + | DECIMAL + | SMALL + | LARGE + | SYMBOL + | DIGIT + | ',' + | ';' + | '(' + | ')' + | '[' + | ']' + | '`' + | '"' + ) '\'' +; -STRING : '"' (' ' | DECIMAL | SMALL | LARGE - | SYMBOL | DIGIT | ',' | ';' | '(' | ')' - | '[' | ']' | '`' | '\'')* '"'; +STRING: + '"' ( + ' ' + | DECIMAL + | SMALL + | LARGE + | SYMBOL + | DIGIT + | ',' + | ';' + | '(' + | ')' + | '[' + | ']' + | '`' + | '\'' + )* '"' +; -VARID : SMALL (SMALL | LARGE | DIGIT | '\'' )* '#'*; -CONID : LARGE (SMALL | LARGE | DIGIT | '\'' )* '#'*; +VARID : SMALL (SMALL | LARGE | DIGIT | '\'')* '#'*; +CONID : LARGE (SMALL | LARGE | DIGIT | '\'')* '#'*; -OpenPragmaBracket : '{-#'; -ClosePragmaBracket: '#-}'; +OpenPragmaBracket : '{-#'; +ClosePragmaBracket : '#-}'; // For CPP extension // read about @@ -191,1504 +231,1513 @@ ClosePragmaBracket: '#-}'; // MultiLineMacro : '#' (~ [\n]*? '\\' '\r'? '\n')+ ~ [\n]+ -> skip; // Directive : '#' ~ [\n]* -> skip; -COMMENT : '--' (~[\r\n])* -> skip; -NCOMMENT : '{-'~[#] .*? '-}' -> skip; +COMMENT : '--' (~[\r\n])* -> skip; +NCOMMENT : '{-' ~[#] .*? '-}' -> skip; -OCURLY : '{'; -CCURLY : '}'; +OCURLY : '{'; +CCURLY : '}'; VOCURLY : 'VOCURLY' { this.SetHidden(); }; VCCURLY : 'VCCURLY' { this.SetHidden(); }; SEMI : 'SEMI' { this.SetHidden(); }; - - -DECIMAL : DIGIT+; -OCTAL : '0' [oO] OCTIT+; +DECIMAL : DIGIT+; +OCTAL : '0' [oO] OCTIT+; HEXADECIMAL : '0' [xX] HEXIT+; -fragment DIGIT : ASCDIGIT | UNIDIGIT; +fragment DIGIT: ASCDIGIT | UNIDIGIT; -fragment ASCDIGIT : [0-9]; -fragment UNIDIGIT - // : '\u0030'..'\u0039' // Basic_Latin - : '\u0660'..'\u0669' // Arabic - | '\u06f0'..'\u06f9' // Arabic - | '\u07c0'..'\u07c9' // NKo - | '\u0966'..'\u096f' // Devanagari - | '\u09e6'..'\u09ef' // Bengali - | '\u0a66'..'\u0a6f' // Gurmukhi - | '\u0ae6'..'\u0aef' // Gujarati - | '\u0b66'..'\u0b6f' // Oriya - | '\u0be6'..'\u0bef' // Tamil - | '\u0c66'..'\u0c6f' // Telugu - | '\u0ce6'..'\u0cef' // Kannada - | '\u0d66'..'\u0d6f' // Malayalam - | '\u0de6'..'\u0def' // Sinhala - | '\u0e50'..'\u0e59' // Thai - | '\u0ed0'..'\u0ed9' // Lao - | '\u0f20'..'\u0f29' // Tibetan - | '\u1040'..'\u1049' // Myanmar - | '\u1090'..'\u1099' // Myanmar - | '\u17e0'..'\u17e9' // Khmer - | '\u1810'..'\u1819' // Mongolian - | '\u1946'..'\u194f' // Limbu - | '\u19d0'..'\u19d9' // New_Tai_Lue - | '\u1a80'..'\u1a89' // Tai_Tham - | '\u1a90'..'\u1a99' // Tai_Tham - | '\u1b50'..'\u1b59' // Balinese - | '\u1bb0'..'\u1bb9' // Sundanese - | '\u1c40'..'\u1c49' // Lepcha - | '\u1c50'..'\u1c59' // Ol_Chiki - | '\ua620'..'\ua629' // Vai - | '\ua8d0'..'\ua8d9' // Saurashtra - | '\ua900'..'\ua909' // Kayah_Li - | '\ua9d0'..'\ua9d9' // Javanese - | '\ua9f0'..'\ua9f9' // Myanmar_Extended-B - | '\uaa50'..'\uaa59' // Cham - | '\uabf0'..'\uabf9' // Meetei_Mayek - | '\uff10'..'\uff19' // Halfwidth_and_Fullwidth_Forms +fragment ASCDIGIT: [0-9]; +fragment UNIDIGIT: // : '\u0030'..'\u0039' // Basic_Latin + '\u0660' ..'\u0669' // Arabic + | '\u06f0' ..'\u06f9' // Arabic + | '\u07c0' ..'\u07c9' // NKo + | '\u0966' ..'\u096f' // Devanagari + | '\u09e6' ..'\u09ef' // Bengali + | '\u0a66' ..'\u0a6f' // Gurmukhi + | '\u0ae6' ..'\u0aef' // Gujarati + | '\u0b66' ..'\u0b6f' // Oriya + | '\u0be6' ..'\u0bef' // Tamil + | '\u0c66' ..'\u0c6f' // Telugu + | '\u0ce6' ..'\u0cef' // Kannada + | '\u0d66' ..'\u0d6f' // Malayalam + | '\u0de6' ..'\u0def' // Sinhala + | '\u0e50' ..'\u0e59' // Thai + | '\u0ed0' ..'\u0ed9' // Lao + | '\u0f20' ..'\u0f29' // Tibetan + | '\u1040' ..'\u1049' // Myanmar + | '\u1090' ..'\u1099' // Myanmar + | '\u17e0' ..'\u17e9' // Khmer + | '\u1810' ..'\u1819' // Mongolian + | '\u1946' ..'\u194f' // Limbu + | '\u19d0' ..'\u19d9' // New_Tai_Lue + | '\u1a80' ..'\u1a89' // Tai_Tham + | '\u1a90' ..'\u1a99' // Tai_Tham + | '\u1b50' ..'\u1b59' // Balinese + | '\u1bb0' ..'\u1bb9' // Sundanese + | '\u1c40' ..'\u1c49' // Lepcha + | '\u1c50' ..'\u1c59' // Ol_Chiki + | '\ua620' ..'\ua629' // Vai + | '\ua8d0' ..'\ua8d9' // Saurashtra + | '\ua900' ..'\ua909' // Kayah_Li + | '\ua9d0' ..'\ua9d9' // Javanese + | '\ua9f0' ..'\ua9f9' // Myanmar_Extended-B + | '\uaa50' ..'\uaa59' // Cham + | '\uabf0' ..'\uabf9' // Meetei_Mayek + | '\uff10' ..'\uff19' // Halfwidth_and_Fullwidth_Forms ; fragment OCTIT : [0-7]; -fragment HEXIT : [0-9] | [A-F] |[a-f]; +fragment HEXIT : [0-9] | [A-F] | [a-f]; -FLOAT: (DECIMAL '.' DECIMAL (EXPONENT)?) | (DECIMAL EXPONENT); +FLOAT : (DECIMAL '.' DECIMAL (EXPONENT)?) | (DECIMAL EXPONENT); EXPONENT : [eE] [+-]? DECIMAL; -fragment LARGE : ASCLARGE | UNILARGE; +fragment LARGE: ASCLARGE | UNILARGE; -fragment ASCLARGE : [A-Z]; -fragment UNILARGE - // : '\u0041'..'\u005a' // Basic_Latin - : '\u00c0'..'\u00d6' // Latin-1_Supplement - | '\u00d8'..'\u00de' // Latin-1_Supplement - | '\u0100' // Latin_Extended-A - | '\u0102' // Latin_Extended-A - | '\u0104' // Latin_Extended-A - | '\u0106' // Latin_Extended-A - | '\u0108' // Latin_Extended-A - | '\u010a' // Latin_Extended-A - | '\u010c' // Latin_Extended-A - | '\u010e' // Latin_Extended-A - | '\u0110' // Latin_Extended-A - | '\u0112' // Latin_Extended-A - | '\u0114' // Latin_Extended-A - | '\u0116' // Latin_Extended-A - | '\u0118' // Latin_Extended-A - | '\u011a' // Latin_Extended-A - | '\u011c' // Latin_Extended-A - | '\u011e' // Latin_Extended-A - | '\u0120' // Latin_Extended-A - | '\u0122' // Latin_Extended-A - | '\u0124' // Latin_Extended-A - | '\u0126' // Latin_Extended-A - | '\u0128' // Latin_Extended-A - | '\u012a' // Latin_Extended-A - | '\u012c' // Latin_Extended-A - | '\u012e' // Latin_Extended-A - | '\u0130' // Latin_Extended-A - | '\u0132' // Latin_Extended-A - | '\u0134' // Latin_Extended-A - | '\u0136' // Latin_Extended-A - | '\u0139' // Latin_Extended-A - | '\u013b' // Latin_Extended-A - | '\u013d' // Latin_Extended-A - | '\u013f' // Latin_Extended-A - | '\u0141' // Latin_Extended-A - | '\u0143' // Latin_Extended-A - | '\u0145' // Latin_Extended-A - | '\u0147' // Latin_Extended-A - | '\u014a' // Latin_Extended-A - | '\u014c' // Latin_Extended-A - | '\u014e' // Latin_Extended-A - | '\u0150' // Latin_Extended-A - | '\u0152' // Latin_Extended-A - | '\u0154' // Latin_Extended-A - | '\u0156' // Latin_Extended-A - | '\u0158' // Latin_Extended-A - | '\u015a' // Latin_Extended-A - | '\u015c' // Latin_Extended-A - | '\u015e' // Latin_Extended-A - | '\u0160' // Latin_Extended-A - | '\u0162' // Latin_Extended-A - | '\u0164' // Latin_Extended-A - | '\u0166' // Latin_Extended-A - | '\u0168' // Latin_Extended-A - | '\u016a' // Latin_Extended-A - | '\u016c' // Latin_Extended-A - | '\u016e' // Latin_Extended-A - | '\u0170' // Latin_Extended-A - | '\u0172' // Latin_Extended-A - | '\u0174' // Latin_Extended-A - | '\u0176' // Latin_Extended-A - | '\u0178'..'\u0179' // Latin_Extended-A - | '\u017b' // Latin_Extended-A - | '\u017d' // Latin_Extended-A - | '\u0181'..'\u0182' // Latin_Extended-B - | '\u0184' // Latin_Extended-B - | '\u0186'..'\u0187' // Latin_Extended-B - | '\u0189'..'\u018b' // Latin_Extended-B - | '\u018e'..'\u0191' // Latin_Extended-B - | '\u0193'..'\u0194' // Latin_Extended-B - | '\u0196'..'\u0198' // Latin_Extended-B - | '\u019c'..'\u019d' // Latin_Extended-B - | '\u019f'..'\u01a0' // Latin_Extended-B - | '\u01a2' // Latin_Extended-B - | '\u01a4' // Latin_Extended-B - | '\u01a6'..'\u01a7' // Latin_Extended-B - | '\u01a9' // Latin_Extended-B - | '\u01ac' // Latin_Extended-B - | '\u01ae'..'\u01af' // Latin_Extended-B - | '\u01b1'..'\u01b3' // Latin_Extended-B - | '\u01b5' // Latin_Extended-B - | '\u01b7'..'\u01b8' // Latin_Extended-B - | '\u01bc' // Latin_Extended-B - | '\u01c4' // Latin_Extended-B - | '\u01c7' // Latin_Extended-B - | '\u01ca' // Latin_Extended-B - | '\u01cd' // Latin_Extended-B - | '\u01cf' // Latin_Extended-B - | '\u01d1' // Latin_Extended-B - | '\u01d3' // Latin_Extended-B - | '\u01d5' // Latin_Extended-B - | '\u01d7' // Latin_Extended-B - | '\u01d9' // Latin_Extended-B - | '\u01db' // Latin_Extended-B - | '\u01de' // Latin_Extended-B - | '\u01e0' // Latin_Extended-B - | '\u01e2' // Latin_Extended-B - | '\u01e4' // Latin_Extended-B - | '\u01e6' // Latin_Extended-B - | '\u01e8' // Latin_Extended-B - | '\u01ea' // Latin_Extended-B - | '\u01ec' // Latin_Extended-B - | '\u01ee' // Latin_Extended-B - | '\u01f1' // Latin_Extended-B - | '\u01f4' // Latin_Extended-B - | '\u01f6'..'\u01f8' // Latin_Extended-B - | '\u01fa' // Latin_Extended-B - | '\u01fc' // Latin_Extended-B - | '\u01fe' // Latin_Extended-B - | '\u0200' // Latin_Extended-B - | '\u0202' // Latin_Extended-B - | '\u0204' // Latin_Extended-B - | '\u0206' // Latin_Extended-B - | '\u0208' // Latin_Extended-B - | '\u020a' // Latin_Extended-B - | '\u020c' // Latin_Extended-B - | '\u020e' // Latin_Extended-B - | '\u0210' // Latin_Extended-B - | '\u0212' // Latin_Extended-B - | '\u0214' // Latin_Extended-B - | '\u0216' // Latin_Extended-B - | '\u0218' // Latin_Extended-B - | '\u021a' // Latin_Extended-B - | '\u021c' // Latin_Extended-B - | '\u021e' // Latin_Extended-B - | '\u0220' // Latin_Extended-B - | '\u0222' // Latin_Extended-B - | '\u0224' // Latin_Extended-B - | '\u0226' // Latin_Extended-B - | '\u0228' // Latin_Extended-B - | '\u022a' // Latin_Extended-B - | '\u022c' // Latin_Extended-B - | '\u022e' // Latin_Extended-B - | '\u0230' // Latin_Extended-B - | '\u0232' // Latin_Extended-B - | '\u023a'..'\u023b' // Latin_Extended-B - | '\u023d'..'\u023e' // Latin_Extended-B - | '\u0241' // Latin_Extended-B - | '\u0243'..'\u0246' // Latin_Extended-B - | '\u0248' // Latin_Extended-B - | '\u024a' // Latin_Extended-B - | '\u024c' // Latin_Extended-B - | '\u024e' // Latin_Extended-B - | '\u0370' // Greek_and_Coptic - | '\u0372' // Greek_and_Coptic - | '\u0376' // Greek_and_Coptic - | '\u037f' // Greek_and_Coptic - | '\u0386' // Greek_and_Coptic - | '\u0388'..'\u038a' // Greek_and_Coptic - | '\u038c' // Greek_and_Coptic - | '\u038e'..'\u038f' // Greek_and_Coptic - | '\u0391'..'\u03a1' // Greek_and_Coptic - | '\u03a3'..'\u03ab' // Greek_and_Coptic - | '\u03cf' // Greek_and_Coptic - | '\u03d2'..'\u03d4' // Greek_and_Coptic - | '\u03d8' // Greek_and_Coptic - | '\u03da' // Greek_and_Coptic - | '\u03dc' // Greek_and_Coptic - | '\u03de' // Greek_and_Coptic - | '\u03e0' // Greek_and_Coptic - | '\u03e2' // Greek_and_Coptic - | '\u03e4' // Greek_and_Coptic - | '\u03e6' // Greek_and_Coptic - | '\u03e8' // Greek_and_Coptic - | '\u03ea' // Greek_and_Coptic - | '\u03ec' // Greek_and_Coptic - | '\u03ee' // Greek_and_Coptic - | '\u03f4' // Greek_and_Coptic - | '\u03f7' // Greek_and_Coptic - | '\u03f9'..'\u03fa' // Greek_and_Coptic - | '\u03fd'..'\u042f' // Greek_and_Coptic - | '\u0460' // Cyrillic - | '\u0462' // Cyrillic - | '\u0464' // Cyrillic - | '\u0466' // Cyrillic - | '\u0468' // Cyrillic - | '\u046a' // Cyrillic - | '\u046c' // Cyrillic - | '\u046e' // Cyrillic - | '\u0470' // Cyrillic - | '\u0472' // Cyrillic - | '\u0474' // Cyrillic - | '\u0476' // Cyrillic - | '\u0478' // Cyrillic - | '\u047a' // Cyrillic - | '\u047c' // Cyrillic - | '\u047e' // Cyrillic - | '\u0480' // Cyrillic - | '\u048a' // Cyrillic - | '\u048c' // Cyrillic - | '\u048e' // Cyrillic - | '\u0490' // Cyrillic - | '\u0492' // Cyrillic - | '\u0494' // Cyrillic - | '\u0496' // Cyrillic - | '\u0498' // Cyrillic - | '\u049a' // Cyrillic - | '\u049c' // Cyrillic - | '\u049e' // Cyrillic - | '\u04a0' // Cyrillic - | '\u04a2' // Cyrillic - | '\u04a4' // Cyrillic - | '\u04a6' // Cyrillic - | '\u04a8' // Cyrillic - | '\u04aa' // Cyrillic - | '\u04ac' // Cyrillic - | '\u04ae' // Cyrillic - | '\u04b0' // Cyrillic - | '\u04b2' // Cyrillic - | '\u04b4' // Cyrillic - | '\u04b6' // Cyrillic - | '\u04b8' // Cyrillic - | '\u04ba' // Cyrillic - | '\u04bc' // Cyrillic - | '\u04be' // Cyrillic - | '\u04c0'..'\u04c1' // Cyrillic - | '\u04c3' // Cyrillic - | '\u04c5' // Cyrillic - | '\u04c7' // Cyrillic - | '\u04c9' // Cyrillic - | '\u04cb' // Cyrillic - | '\u04cd' // Cyrillic - | '\u04d0' // Cyrillic - | '\u04d2' // Cyrillic - | '\u04d4' // Cyrillic - | '\u04d6' // Cyrillic - | '\u04d8' // Cyrillic - | '\u04da' // Cyrillic - | '\u04dc' // Cyrillic - | '\u04de' // Cyrillic - | '\u04e0' // Cyrillic - | '\u04e2' // Cyrillic - | '\u04e4' // Cyrillic - | '\u04e6' // Cyrillic - | '\u04e8' // Cyrillic - | '\u04ea' // Cyrillic - | '\u04ec' // Cyrillic - | '\u04ee' // Cyrillic - | '\u04f0' // Cyrillic - | '\u04f2' // Cyrillic - | '\u04f4' // Cyrillic - | '\u04f6' // Cyrillic - | '\u04f8' // Cyrillic - | '\u04fa' // Cyrillic - | '\u04fc' // Cyrillic - | '\u04fe' // Cyrillic - | '\u0500' // Cyrillic_Supplement - | '\u0502' // Cyrillic_Supplement - | '\u0504' // Cyrillic_Supplement - | '\u0506' // Cyrillic_Supplement - | '\u0508' // Cyrillic_Supplement - | '\u050a' // Cyrillic_Supplement - | '\u050c' // Cyrillic_Supplement - | '\u050e' // Cyrillic_Supplement - | '\u0510' // Cyrillic_Supplement - | '\u0512' // Cyrillic_Supplement - | '\u0514' // Cyrillic_Supplement - | '\u0516' // Cyrillic_Supplement - | '\u0518' // Cyrillic_Supplement - | '\u051a' // Cyrillic_Supplement - | '\u051c' // Cyrillic_Supplement - | '\u051e' // Cyrillic_Supplement - | '\u0520' // Cyrillic_Supplement - | '\u0522' // Cyrillic_Supplement - | '\u0524' // Cyrillic_Supplement - | '\u0526' // Cyrillic_Supplement - | '\u0528' // Cyrillic_Supplement - | '\u052a' // Cyrillic_Supplement - | '\u052c' // Cyrillic_Supplement - | '\u052e' // Cyrillic_Supplement - | '\u0531'..'\u0556' // Armenian - | '\u10a0'..'\u10c5' // Georgian - | '\u10c7' // Georgian - | '\u10cd' // Georgian - | '\u13a0'..'\u13f5' // Cherokee - | '\u1e00' // Latin_Extended_Additional - | '\u1e02' // Latin_Extended_Additional - | '\u1e04' // Latin_Extended_Additional - | '\u1e06' // Latin_Extended_Additional - | '\u1e08' // Latin_Extended_Additional - | '\u1e0a' // Latin_Extended_Additional - | '\u1e0c' // Latin_Extended_Additional - | '\u1e0e' // Latin_Extended_Additional - | '\u1e10' // Latin_Extended_Additional - | '\u1e12' // Latin_Extended_Additional - | '\u1e14' // Latin_Extended_Additional - | '\u1e16' // Latin_Extended_Additional - | '\u1e18' // Latin_Extended_Additional - | '\u1e1a' // Latin_Extended_Additional - | '\u1e1c' // Latin_Extended_Additional - | '\u1e1e' // Latin_Extended_Additional - | '\u1e20' // Latin_Extended_Additional - | '\u1e22' // Latin_Extended_Additional - | '\u1e24' // Latin_Extended_Additional - | '\u1e26' // Latin_Extended_Additional - | '\u1e28' // Latin_Extended_Additional - | '\u1e2a' // Latin_Extended_Additional - | '\u1e2c' // Latin_Extended_Additional - | '\u1e2e' // Latin_Extended_Additional - | '\u1e30' // Latin_Extended_Additional - | '\u1e32' // Latin_Extended_Additional - | '\u1e34' // Latin_Extended_Additional - | '\u1e36' // Latin_Extended_Additional - | '\u1e38' // Latin_Extended_Additional - | '\u1e3a' // Latin_Extended_Additional - | '\u1e3c' // Latin_Extended_Additional - | '\u1e3e' // Latin_Extended_Additional - | '\u1e40' // Latin_Extended_Additional - | '\u1e42' // Latin_Extended_Additional - | '\u1e44' // Latin_Extended_Additional - | '\u1e46' // Latin_Extended_Additional - | '\u1e48' // Latin_Extended_Additional - | '\u1e4a' // Latin_Extended_Additional - | '\u1e4c' // Latin_Extended_Additional - | '\u1e4e' // Latin_Extended_Additional - | '\u1e50' // Latin_Extended_Additional - | '\u1e52' // Latin_Extended_Additional - | '\u1e54' // Latin_Extended_Additional - | '\u1e56' // Latin_Extended_Additional - | '\u1e58' // Latin_Extended_Additional - | '\u1e5a' // Latin_Extended_Additional - | '\u1e5c' // Latin_Extended_Additional - | '\u1e5e' // Latin_Extended_Additional - | '\u1e60' // Latin_Extended_Additional - | '\u1e62' // Latin_Extended_Additional - | '\u1e64' // Latin_Extended_Additional - | '\u1e66' // Latin_Extended_Additional - | '\u1e68' // Latin_Extended_Additional - | '\u1e6a' // Latin_Extended_Additional - | '\u1e6c' // Latin_Extended_Additional - | '\u1e6e' // Latin_Extended_Additional - | '\u1e70' // Latin_Extended_Additional - | '\u1e72' // Latin_Extended_Additional - | '\u1e74' // Latin_Extended_Additional - | '\u1e76' // Latin_Extended_Additional - | '\u1e78' // Latin_Extended_Additional - | '\u1e7a' // Latin_Extended_Additional - | '\u1e7c' // Latin_Extended_Additional - | '\u1e7e' // Latin_Extended_Additional - | '\u1e80' // Latin_Extended_Additional - | '\u1e82' // Latin_Extended_Additional - | '\u1e84' // Latin_Extended_Additional - | '\u1e86' // Latin_Extended_Additional - | '\u1e88' // Latin_Extended_Additional - | '\u1e8a' // Latin_Extended_Additional - | '\u1e8c' // Latin_Extended_Additional - | '\u1e8e' // Latin_Extended_Additional - | '\u1e90' // Latin_Extended_Additional - | '\u1e92' // Latin_Extended_Additional - | '\u1e94' // Latin_Extended_Additional - | '\u1e9e' // Latin_Extended_Additional - | '\u1ea0' // Latin_Extended_Additional - | '\u1ea2' // Latin_Extended_Additional - | '\u1ea4' // Latin_Extended_Additional - | '\u1ea6' // Latin_Extended_Additional - | '\u1ea8' // Latin_Extended_Additional - | '\u1eaa' // Latin_Extended_Additional - | '\u1eac' // Latin_Extended_Additional - | '\u1eae' // Latin_Extended_Additional - | '\u1eb0' // Latin_Extended_Additional - | '\u1eb2' // Latin_Extended_Additional - | '\u1eb4' // Latin_Extended_Additional - | '\u1eb6' // Latin_Extended_Additional - | '\u1eb8' // Latin_Extended_Additional - | '\u1eba' // Latin_Extended_Additional - | '\u1ebc' // Latin_Extended_Additional - | '\u1ebe' // Latin_Extended_Additional - | '\u1ec0' // Latin_Extended_Additional - | '\u1ec2' // Latin_Extended_Additional - | '\u1ec4' // Latin_Extended_Additional - | '\u1ec6' // Latin_Extended_Additional - | '\u1ec8' // Latin_Extended_Additional - | '\u1eca' // Latin_Extended_Additional - | '\u1ecc' // Latin_Extended_Additional - | '\u1ece' // Latin_Extended_Additional - | '\u1ed0' // Latin_Extended_Additional - | '\u1ed2' // Latin_Extended_Additional - | '\u1ed4' // Latin_Extended_Additional - | '\u1ed6' // Latin_Extended_Additional - | '\u1ed8' // Latin_Extended_Additional - | '\u1eda' // Latin_Extended_Additional - | '\u1edc' // Latin_Extended_Additional - | '\u1ede' // Latin_Extended_Additional - | '\u1ee0' // Latin_Extended_Additional - | '\u1ee2' // Latin_Extended_Additional - | '\u1ee4' // Latin_Extended_Additional - | '\u1ee6' // Latin_Extended_Additional - | '\u1ee8' // Latin_Extended_Additional - | '\u1eea' // Latin_Extended_Additional - | '\u1eec' // Latin_Extended_Additional - | '\u1eee' // Latin_Extended_Additional - | '\u1ef0' // Latin_Extended_Additional - | '\u1ef2' // Latin_Extended_Additional - | '\u1ef4' // Latin_Extended_Additional - | '\u1ef6' // Latin_Extended_Additional - | '\u1ef8' // Latin_Extended_Additional - | '\u1efa' // Latin_Extended_Additional - | '\u1efc' // Latin_Extended_Additional - | '\u1efe' // Latin_Extended_Additional - | '\u1f08'..'\u1f0f' // Greek_Extended - | '\u1f18'..'\u1f1d' // Greek_Extended - | '\u1f28'..'\u1f2f' // Greek_Extended - | '\u1f38'..'\u1f3f' // Greek_Extended - | '\u1f48'..'\u1f4d' // Greek_Extended - | '\u1f59' // Greek_Extended - | '\u1f5b' // Greek_Extended - | '\u1f5d' // Greek_Extended - | '\u1f5f' // Greek_Extended - | '\u1f68'..'\u1f6f' // Greek_Extended - | '\u1fb8'..'\u1fbb' // Greek_Extended - | '\u1fc8'..'\u1fcb' // Greek_Extended - | '\u1fd8'..'\u1fdb' // Greek_Extended - | '\u1fe8'..'\u1fec' // Greek_Extended - | '\u1ff8'..'\u1ffb' // Greek_Extended - | '\u2102' // Letterlike_Symbols - | '\u2107' // Letterlike_Symbols - | '\u210b'..'\u210d' // Letterlike_Symbols - | '\u2110'..'\u2112' // Letterlike_Symbols - | '\u2115' // Letterlike_Symbols - | '\u2119'..'\u211d' // Letterlike_Symbols - | '\u2124' // Letterlike_Symbols - | '\u2126' // Letterlike_Symbols - | '\u2128' // Letterlike_Symbols - | '\u212a'..'\u212d' // Letterlike_Symbols - | '\u2130'..'\u2133' // Letterlike_Symbols - | '\u213e'..'\u213f' // Letterlike_Symbols - | '\u2145' // Letterlike_Symbols - | '\u2183' // Number_Forms - | '\u2c00'..'\u2c2e' // Glagolitic - | '\u2c60' // Latin_Extended-C - | '\u2c62'..'\u2c64' // Latin_Extended-C - | '\u2c67' // Latin_Extended-C - | '\u2c69' // Latin_Extended-C - | '\u2c6b' // Latin_Extended-C - | '\u2c6d'..'\u2c70' // Latin_Extended-C - | '\u2c72' // Latin_Extended-C - | '\u2c75' // Latin_Extended-C - | '\u2c7e'..'\u2c80' // Latin_Extended-C - | '\u2c82' // Coptic - | '\u2c84' // Coptic - | '\u2c86' // Coptic - | '\u2c88' // Coptic - | '\u2c8a' // Coptic - | '\u2c8c' // Coptic - | '\u2c8e' // Coptic - | '\u2c90' // Coptic - | '\u2c92' // Coptic - | '\u2c94' // Coptic - | '\u2c96' // Coptic - | '\u2c98' // Coptic - | '\u2c9a' // Coptic - | '\u2c9c' // Coptic - | '\u2c9e' // Coptic - | '\u2ca0' // Coptic - | '\u2ca2' // Coptic - | '\u2ca4' // Coptic - | '\u2ca6' // Coptic - | '\u2ca8' // Coptic - | '\u2caa' // Coptic - | '\u2cac' // Coptic - | '\u2cae' // Coptic - | '\u2cb0' // Coptic - | '\u2cb2' // Coptic - | '\u2cb4' // Coptic - | '\u2cb6' // Coptic - | '\u2cb8' // Coptic - | '\u2cba' // Coptic - | '\u2cbc' // Coptic - | '\u2cbe' // Coptic - | '\u2cc0' // Coptic - | '\u2cc2' // Coptic - | '\u2cc4' // Coptic - | '\u2cc6' // Coptic - | '\u2cc8' // Coptic - | '\u2cca' // Coptic - | '\u2ccc' // Coptic - | '\u2cce' // Coptic - | '\u2cd0' // Coptic - | '\u2cd2' // Coptic - | '\u2cd4' // Coptic - | '\u2cd6' // Coptic - | '\u2cd8' // Coptic - | '\u2cda' // Coptic - | '\u2cdc' // Coptic - | '\u2cde' // Coptic - | '\u2ce0' // Coptic - | '\u2ce2' // Coptic - | '\u2ceb' // Coptic - | '\u2ced' // Coptic - | '\u2cf2' // Coptic - | '\ua640' // Cyrillic_Extended-B - | '\ua642' // Cyrillic_Extended-B - | '\ua644' // Cyrillic_Extended-B - | '\ua646' // Cyrillic_Extended-B - | '\ua648' // Cyrillic_Extended-B - | '\ua64a' // Cyrillic_Extended-B - | '\ua64c' // Cyrillic_Extended-B - | '\ua64e' // Cyrillic_Extended-B - | '\ua650' // Cyrillic_Extended-B - | '\ua652' // Cyrillic_Extended-B - | '\ua654' // Cyrillic_Extended-B - | '\ua656' // Cyrillic_Extended-B - | '\ua658' // Cyrillic_Extended-B - | '\ua65a' // Cyrillic_Extended-B - | '\ua65c' // Cyrillic_Extended-B - | '\ua65e' // Cyrillic_Extended-B - | '\ua660' // Cyrillic_Extended-B - | '\ua662' // Cyrillic_Extended-B - | '\ua664' // Cyrillic_Extended-B - | '\ua666' // Cyrillic_Extended-B - | '\ua668' // Cyrillic_Extended-B - | '\ua66a' // Cyrillic_Extended-B - | '\ua66c' // Cyrillic_Extended-B - | '\ua680' // Cyrillic_Extended-B - | '\ua682' // Cyrillic_Extended-B - | '\ua684' // Cyrillic_Extended-B - | '\ua686' // Cyrillic_Extended-B - | '\ua688' // Cyrillic_Extended-B - | '\ua68a' // Cyrillic_Extended-B - | '\ua68c' // Cyrillic_Extended-B - | '\ua68e' // Cyrillic_Extended-B - | '\ua690' // Cyrillic_Extended-B - | '\ua692' // Cyrillic_Extended-B - | '\ua694' // Cyrillic_Extended-B - | '\ua696' // Cyrillic_Extended-B - | '\ua698' // Cyrillic_Extended-B - | '\ua69a' // Cyrillic_Extended-B - | '\ua722' // Latin_Extended-D - | '\ua724' // Latin_Extended-D - | '\ua726' // Latin_Extended-D - | '\ua728' // Latin_Extended-D - | '\ua72a' // Latin_Extended-D - | '\ua72c' // Latin_Extended-D - | '\ua72e' // Latin_Extended-D - | '\ua732' // Latin_Extended-D - | '\ua734' // Latin_Extended-D - | '\ua736' // Latin_Extended-D - | '\ua738' // Latin_Extended-D - | '\ua73a' // Latin_Extended-D - | '\ua73c' // Latin_Extended-D - | '\ua73e' // Latin_Extended-D - | '\ua740' // Latin_Extended-D - | '\ua742' // Latin_Extended-D - | '\ua744' // Latin_Extended-D - | '\ua746' // Latin_Extended-D - | '\ua748' // Latin_Extended-D - | '\ua74a' // Latin_Extended-D - | '\ua74c' // Latin_Extended-D - | '\ua74e' // Latin_Extended-D - | '\ua750' // Latin_Extended-D - | '\ua752' // Latin_Extended-D - | '\ua754' // Latin_Extended-D - | '\ua756' // Latin_Extended-D - | '\ua758' // Latin_Extended-D - | '\ua75a' // Latin_Extended-D - | '\ua75c' // Latin_Extended-D - | '\ua75e' // Latin_Extended-D - | '\ua760' // Latin_Extended-D - | '\ua762' // Latin_Extended-D - | '\ua764' // Latin_Extended-D - | '\ua766' // Latin_Extended-D - | '\ua768' // Latin_Extended-D - | '\ua76a' // Latin_Extended-D - | '\ua76c' // Latin_Extended-D - | '\ua76e' // Latin_Extended-D - | '\ua779' // Latin_Extended-D - | '\ua77b' // Latin_Extended-D - | '\ua77d'..'\ua77e' // Latin_Extended-D - | '\ua780' // Latin_Extended-D - | '\ua782' // Latin_Extended-D - | '\ua784' // Latin_Extended-D - | '\ua786' // Latin_Extended-D - | '\ua78b' // Latin_Extended-D - | '\ua78d' // Latin_Extended-D - | '\ua790' // Latin_Extended-D - | '\ua792' // Latin_Extended-D - | '\ua796' // Latin_Extended-D - | '\ua798' // Latin_Extended-D - | '\ua79a' // Latin_Extended-D - | '\ua79c' // Latin_Extended-D - | '\ua79e' // Latin_Extended-D - | '\ua7a0' // Latin_Extended-D - | '\ua7a2' // Latin_Extended-D - | '\ua7a4' // Latin_Extended-D - | '\ua7a6' // Latin_Extended-D - | '\ua7a8' // Latin_Extended-D - | '\ua7aa'..'\ua7ae' // Latin_Extended-D - | '\ua7b0'..'\ua7b4' // Latin_Extended-D - | '\ua7b6' // Latin_Extended-D - | '\uff21'..'\uff3a' // Halfwidth_and_Fullwidth_Forms +fragment ASCLARGE: [A-Z]; +fragment UNILARGE: // : '\u0041'..'\u005a' // Basic_Latin + '\u00c0' ..'\u00d6' // Latin-1_Supplement + | '\u00d8' ..'\u00de' // Latin-1_Supplement + | '\u0100' // Latin_Extended-A + | '\u0102' // Latin_Extended-A + | '\u0104' // Latin_Extended-A + | '\u0106' // Latin_Extended-A + | '\u0108' // Latin_Extended-A + | '\u010a' // Latin_Extended-A + | '\u010c' // Latin_Extended-A + | '\u010e' // Latin_Extended-A + | '\u0110' // Latin_Extended-A + | '\u0112' // Latin_Extended-A + | '\u0114' // Latin_Extended-A + | '\u0116' // Latin_Extended-A + | '\u0118' // Latin_Extended-A + | '\u011a' // Latin_Extended-A + | '\u011c' // Latin_Extended-A + | '\u011e' // Latin_Extended-A + | '\u0120' // Latin_Extended-A + | '\u0122' // Latin_Extended-A + | '\u0124' // Latin_Extended-A + | '\u0126' // Latin_Extended-A + | '\u0128' // Latin_Extended-A + | '\u012a' // Latin_Extended-A + | '\u012c' // Latin_Extended-A + | '\u012e' // Latin_Extended-A + | '\u0130' // Latin_Extended-A + | '\u0132' // Latin_Extended-A + | '\u0134' // Latin_Extended-A + | '\u0136' // Latin_Extended-A + | '\u0139' // Latin_Extended-A + | '\u013b' // Latin_Extended-A + | '\u013d' // Latin_Extended-A + | '\u013f' // Latin_Extended-A + | '\u0141' // Latin_Extended-A + | '\u0143' // Latin_Extended-A + | '\u0145' // Latin_Extended-A + | '\u0147' // Latin_Extended-A + | '\u014a' // Latin_Extended-A + | '\u014c' // Latin_Extended-A + | '\u014e' // Latin_Extended-A + | '\u0150' // Latin_Extended-A + | '\u0152' // Latin_Extended-A + | '\u0154' // Latin_Extended-A + | '\u0156' // Latin_Extended-A + | '\u0158' // Latin_Extended-A + | '\u015a' // Latin_Extended-A + | '\u015c' // Latin_Extended-A + | '\u015e' // Latin_Extended-A + | '\u0160' // Latin_Extended-A + | '\u0162' // Latin_Extended-A + | '\u0164' // Latin_Extended-A + | '\u0166' // Latin_Extended-A + | '\u0168' // Latin_Extended-A + | '\u016a' // Latin_Extended-A + | '\u016c' // Latin_Extended-A + | '\u016e' // Latin_Extended-A + | '\u0170' // Latin_Extended-A + | '\u0172' // Latin_Extended-A + | '\u0174' // Latin_Extended-A + | '\u0176' // Latin_Extended-A + | '\u0178' ..'\u0179' // Latin_Extended-A + | '\u017b' // Latin_Extended-A + | '\u017d' // Latin_Extended-A + | '\u0181' ..'\u0182' // Latin_Extended-B + | '\u0184' // Latin_Extended-B + | '\u0186' ..'\u0187' // Latin_Extended-B + | '\u0189' ..'\u018b' // Latin_Extended-B + | '\u018e' ..'\u0191' // Latin_Extended-B + | '\u0193' ..'\u0194' // Latin_Extended-B + | '\u0196' ..'\u0198' // Latin_Extended-B + | '\u019c' ..'\u019d' // Latin_Extended-B + | '\u019f' ..'\u01a0' // Latin_Extended-B + | '\u01a2' // Latin_Extended-B + | '\u01a4' // Latin_Extended-B + | '\u01a6' ..'\u01a7' // Latin_Extended-B + | '\u01a9' // Latin_Extended-B + | '\u01ac' // Latin_Extended-B + | '\u01ae' ..'\u01af' // Latin_Extended-B + | '\u01b1' ..'\u01b3' // Latin_Extended-B + | '\u01b5' // Latin_Extended-B + | '\u01b7' ..'\u01b8' // Latin_Extended-B + | '\u01bc' // Latin_Extended-B + | '\u01c4' // Latin_Extended-B + | '\u01c7' // Latin_Extended-B + | '\u01ca' // Latin_Extended-B + | '\u01cd' // Latin_Extended-B + | '\u01cf' // Latin_Extended-B + | '\u01d1' // Latin_Extended-B + | '\u01d3' // Latin_Extended-B + | '\u01d5' // Latin_Extended-B + | '\u01d7' // Latin_Extended-B + | '\u01d9' // Latin_Extended-B + | '\u01db' // Latin_Extended-B + | '\u01de' // Latin_Extended-B + | '\u01e0' // Latin_Extended-B + | '\u01e2' // Latin_Extended-B + | '\u01e4' // Latin_Extended-B + | '\u01e6' // Latin_Extended-B + | '\u01e8' // Latin_Extended-B + | '\u01ea' // Latin_Extended-B + | '\u01ec' // Latin_Extended-B + | '\u01ee' // Latin_Extended-B + | '\u01f1' // Latin_Extended-B + | '\u01f4' // Latin_Extended-B + | '\u01f6' ..'\u01f8' // Latin_Extended-B + | '\u01fa' // Latin_Extended-B + | '\u01fc' // Latin_Extended-B + | '\u01fe' // Latin_Extended-B + | '\u0200' // Latin_Extended-B + | '\u0202' // Latin_Extended-B + | '\u0204' // Latin_Extended-B + | '\u0206' // Latin_Extended-B + | '\u0208' // Latin_Extended-B + | '\u020a' // Latin_Extended-B + | '\u020c' // Latin_Extended-B + | '\u020e' // Latin_Extended-B + | '\u0210' // Latin_Extended-B + | '\u0212' // Latin_Extended-B + | '\u0214' // Latin_Extended-B + | '\u0216' // Latin_Extended-B + | '\u0218' // Latin_Extended-B + | '\u021a' // Latin_Extended-B + | '\u021c' // Latin_Extended-B + | '\u021e' // Latin_Extended-B + | '\u0220' // Latin_Extended-B + | '\u0222' // Latin_Extended-B + | '\u0224' // Latin_Extended-B + | '\u0226' // Latin_Extended-B + | '\u0228' // Latin_Extended-B + | '\u022a' // Latin_Extended-B + | '\u022c' // Latin_Extended-B + | '\u022e' // Latin_Extended-B + | '\u0230' // Latin_Extended-B + | '\u0232' // Latin_Extended-B + | '\u023a' ..'\u023b' // Latin_Extended-B + | '\u023d' ..'\u023e' // Latin_Extended-B + | '\u0241' // Latin_Extended-B + | '\u0243' ..'\u0246' // Latin_Extended-B + | '\u0248' // Latin_Extended-B + | '\u024a' // Latin_Extended-B + | '\u024c' // Latin_Extended-B + | '\u024e' // Latin_Extended-B + | '\u0370' // Greek_and_Coptic + | '\u0372' // Greek_and_Coptic + | '\u0376' // Greek_and_Coptic + | '\u037f' // Greek_and_Coptic + | '\u0386' // Greek_and_Coptic + | '\u0388' ..'\u038a' // Greek_and_Coptic + | '\u038c' // Greek_and_Coptic + | '\u038e' ..'\u038f' // Greek_and_Coptic + | '\u0391' ..'\u03a1' // Greek_and_Coptic + | '\u03a3' ..'\u03ab' // Greek_and_Coptic + | '\u03cf' // Greek_and_Coptic + | '\u03d2' ..'\u03d4' // Greek_and_Coptic + | '\u03d8' // Greek_and_Coptic + | '\u03da' // Greek_and_Coptic + | '\u03dc' // Greek_and_Coptic + | '\u03de' // Greek_and_Coptic + | '\u03e0' // Greek_and_Coptic + | '\u03e2' // Greek_and_Coptic + | '\u03e4' // Greek_and_Coptic + | '\u03e6' // Greek_and_Coptic + | '\u03e8' // Greek_and_Coptic + | '\u03ea' // Greek_and_Coptic + | '\u03ec' // Greek_and_Coptic + | '\u03ee' // Greek_and_Coptic + | '\u03f4' // Greek_and_Coptic + | '\u03f7' // Greek_and_Coptic + | '\u03f9' ..'\u03fa' // Greek_and_Coptic + | '\u03fd' ..'\u042f' // Greek_and_Coptic + | '\u0460' // Cyrillic + | '\u0462' // Cyrillic + | '\u0464' // Cyrillic + | '\u0466' // Cyrillic + | '\u0468' // Cyrillic + | '\u046a' // Cyrillic + | '\u046c' // Cyrillic + | '\u046e' // Cyrillic + | '\u0470' // Cyrillic + | '\u0472' // Cyrillic + | '\u0474' // Cyrillic + | '\u0476' // Cyrillic + | '\u0478' // Cyrillic + | '\u047a' // Cyrillic + | '\u047c' // Cyrillic + | '\u047e' // Cyrillic + | '\u0480' // Cyrillic + | '\u048a' // Cyrillic + | '\u048c' // Cyrillic + | '\u048e' // Cyrillic + | '\u0490' // Cyrillic + | '\u0492' // Cyrillic + | '\u0494' // Cyrillic + | '\u0496' // Cyrillic + | '\u0498' // Cyrillic + | '\u049a' // Cyrillic + | '\u049c' // Cyrillic + | '\u049e' // Cyrillic + | '\u04a0' // Cyrillic + | '\u04a2' // Cyrillic + | '\u04a4' // Cyrillic + | '\u04a6' // Cyrillic + | '\u04a8' // Cyrillic + | '\u04aa' // Cyrillic + | '\u04ac' // Cyrillic + | '\u04ae' // Cyrillic + | '\u04b0' // Cyrillic + | '\u04b2' // Cyrillic + | '\u04b4' // Cyrillic + | '\u04b6' // Cyrillic + | '\u04b8' // Cyrillic + | '\u04ba' // Cyrillic + | '\u04bc' // Cyrillic + | '\u04be' // Cyrillic + | '\u04c0' ..'\u04c1' // Cyrillic + | '\u04c3' // Cyrillic + | '\u04c5' // Cyrillic + | '\u04c7' // Cyrillic + | '\u04c9' // Cyrillic + | '\u04cb' // Cyrillic + | '\u04cd' // Cyrillic + | '\u04d0' // Cyrillic + | '\u04d2' // Cyrillic + | '\u04d4' // Cyrillic + | '\u04d6' // Cyrillic + | '\u04d8' // Cyrillic + | '\u04da' // Cyrillic + | '\u04dc' // Cyrillic + | '\u04de' // Cyrillic + | '\u04e0' // Cyrillic + | '\u04e2' // Cyrillic + | '\u04e4' // Cyrillic + | '\u04e6' // Cyrillic + | '\u04e8' // Cyrillic + | '\u04ea' // Cyrillic + | '\u04ec' // Cyrillic + | '\u04ee' // Cyrillic + | '\u04f0' // Cyrillic + | '\u04f2' // Cyrillic + | '\u04f4' // Cyrillic + | '\u04f6' // Cyrillic + | '\u04f8' // Cyrillic + | '\u04fa' // Cyrillic + | '\u04fc' // Cyrillic + | '\u04fe' // Cyrillic + | '\u0500' // Cyrillic_Supplement + | '\u0502' // Cyrillic_Supplement + | '\u0504' // Cyrillic_Supplement + | '\u0506' // Cyrillic_Supplement + | '\u0508' // Cyrillic_Supplement + | '\u050a' // Cyrillic_Supplement + | '\u050c' // Cyrillic_Supplement + | '\u050e' // Cyrillic_Supplement + | '\u0510' // Cyrillic_Supplement + | '\u0512' // Cyrillic_Supplement + | '\u0514' // Cyrillic_Supplement + | '\u0516' // Cyrillic_Supplement + | '\u0518' // Cyrillic_Supplement + | '\u051a' // Cyrillic_Supplement + | '\u051c' // Cyrillic_Supplement + | '\u051e' // Cyrillic_Supplement + | '\u0520' // Cyrillic_Supplement + | '\u0522' // Cyrillic_Supplement + | '\u0524' // Cyrillic_Supplement + | '\u0526' // Cyrillic_Supplement + | '\u0528' // Cyrillic_Supplement + | '\u052a' // Cyrillic_Supplement + | '\u052c' // Cyrillic_Supplement + | '\u052e' // Cyrillic_Supplement + | '\u0531' ..'\u0556' // Armenian + | '\u10a0' ..'\u10c5' // Georgian + | '\u10c7' // Georgian + | '\u10cd' // Georgian + | '\u13a0' ..'\u13f5' // Cherokee + | '\u1e00' // Latin_Extended_Additional + | '\u1e02' // Latin_Extended_Additional + | '\u1e04' // Latin_Extended_Additional + | '\u1e06' // Latin_Extended_Additional + | '\u1e08' // Latin_Extended_Additional + | '\u1e0a' // Latin_Extended_Additional + | '\u1e0c' // Latin_Extended_Additional + | '\u1e0e' // Latin_Extended_Additional + | '\u1e10' // Latin_Extended_Additional + | '\u1e12' // Latin_Extended_Additional + | '\u1e14' // Latin_Extended_Additional + | '\u1e16' // Latin_Extended_Additional + | '\u1e18' // Latin_Extended_Additional + | '\u1e1a' // Latin_Extended_Additional + | '\u1e1c' // Latin_Extended_Additional + | '\u1e1e' // Latin_Extended_Additional + | '\u1e20' // Latin_Extended_Additional + | '\u1e22' // Latin_Extended_Additional + | '\u1e24' // Latin_Extended_Additional + | '\u1e26' // Latin_Extended_Additional + | '\u1e28' // Latin_Extended_Additional + | '\u1e2a' // Latin_Extended_Additional + | '\u1e2c' // Latin_Extended_Additional + | '\u1e2e' // Latin_Extended_Additional + | '\u1e30' // Latin_Extended_Additional + | '\u1e32' // Latin_Extended_Additional + | '\u1e34' // Latin_Extended_Additional + | '\u1e36' // Latin_Extended_Additional + | '\u1e38' // Latin_Extended_Additional + | '\u1e3a' // Latin_Extended_Additional + | '\u1e3c' // Latin_Extended_Additional + | '\u1e3e' // Latin_Extended_Additional + | '\u1e40' // Latin_Extended_Additional + | '\u1e42' // Latin_Extended_Additional + | '\u1e44' // Latin_Extended_Additional + | '\u1e46' // Latin_Extended_Additional + | '\u1e48' // Latin_Extended_Additional + | '\u1e4a' // Latin_Extended_Additional + | '\u1e4c' // Latin_Extended_Additional + | '\u1e4e' // Latin_Extended_Additional + | '\u1e50' // Latin_Extended_Additional + | '\u1e52' // Latin_Extended_Additional + | '\u1e54' // Latin_Extended_Additional + | '\u1e56' // Latin_Extended_Additional + | '\u1e58' // Latin_Extended_Additional + | '\u1e5a' // Latin_Extended_Additional + | '\u1e5c' // Latin_Extended_Additional + | '\u1e5e' // Latin_Extended_Additional + | '\u1e60' // Latin_Extended_Additional + | '\u1e62' // Latin_Extended_Additional + | '\u1e64' // Latin_Extended_Additional + | '\u1e66' // Latin_Extended_Additional + | '\u1e68' // Latin_Extended_Additional + | '\u1e6a' // Latin_Extended_Additional + | '\u1e6c' // Latin_Extended_Additional + | '\u1e6e' // Latin_Extended_Additional + | '\u1e70' // Latin_Extended_Additional + | '\u1e72' // Latin_Extended_Additional + | '\u1e74' // Latin_Extended_Additional + | '\u1e76' // Latin_Extended_Additional + | '\u1e78' // Latin_Extended_Additional + | '\u1e7a' // Latin_Extended_Additional + | '\u1e7c' // Latin_Extended_Additional + | '\u1e7e' // Latin_Extended_Additional + | '\u1e80' // Latin_Extended_Additional + | '\u1e82' // Latin_Extended_Additional + | '\u1e84' // Latin_Extended_Additional + | '\u1e86' // Latin_Extended_Additional + | '\u1e88' // Latin_Extended_Additional + | '\u1e8a' // Latin_Extended_Additional + | '\u1e8c' // Latin_Extended_Additional + | '\u1e8e' // Latin_Extended_Additional + | '\u1e90' // Latin_Extended_Additional + | '\u1e92' // Latin_Extended_Additional + | '\u1e94' // Latin_Extended_Additional + | '\u1e9e' // Latin_Extended_Additional + | '\u1ea0' // Latin_Extended_Additional + | '\u1ea2' // Latin_Extended_Additional + | '\u1ea4' // Latin_Extended_Additional + | '\u1ea6' // Latin_Extended_Additional + | '\u1ea8' // Latin_Extended_Additional + | '\u1eaa' // Latin_Extended_Additional + | '\u1eac' // Latin_Extended_Additional + | '\u1eae' // Latin_Extended_Additional + | '\u1eb0' // Latin_Extended_Additional + | '\u1eb2' // Latin_Extended_Additional + | '\u1eb4' // Latin_Extended_Additional + | '\u1eb6' // Latin_Extended_Additional + | '\u1eb8' // Latin_Extended_Additional + | '\u1eba' // Latin_Extended_Additional + | '\u1ebc' // Latin_Extended_Additional + | '\u1ebe' // Latin_Extended_Additional + | '\u1ec0' // Latin_Extended_Additional + | '\u1ec2' // Latin_Extended_Additional + | '\u1ec4' // Latin_Extended_Additional + | '\u1ec6' // Latin_Extended_Additional + | '\u1ec8' // Latin_Extended_Additional + | '\u1eca' // Latin_Extended_Additional + | '\u1ecc' // Latin_Extended_Additional + | '\u1ece' // Latin_Extended_Additional + | '\u1ed0' // Latin_Extended_Additional + | '\u1ed2' // Latin_Extended_Additional + | '\u1ed4' // Latin_Extended_Additional + | '\u1ed6' // Latin_Extended_Additional + | '\u1ed8' // Latin_Extended_Additional + | '\u1eda' // Latin_Extended_Additional + | '\u1edc' // Latin_Extended_Additional + | '\u1ede' // Latin_Extended_Additional + | '\u1ee0' // Latin_Extended_Additional + | '\u1ee2' // Latin_Extended_Additional + | '\u1ee4' // Latin_Extended_Additional + | '\u1ee6' // Latin_Extended_Additional + | '\u1ee8' // Latin_Extended_Additional + | '\u1eea' // Latin_Extended_Additional + | '\u1eec' // Latin_Extended_Additional + | '\u1eee' // Latin_Extended_Additional + | '\u1ef0' // Latin_Extended_Additional + | '\u1ef2' // Latin_Extended_Additional + | '\u1ef4' // Latin_Extended_Additional + | '\u1ef6' // Latin_Extended_Additional + | '\u1ef8' // Latin_Extended_Additional + | '\u1efa' // Latin_Extended_Additional + | '\u1efc' // Latin_Extended_Additional + | '\u1efe' // Latin_Extended_Additional + | '\u1f08' ..'\u1f0f' // Greek_Extended + | '\u1f18' ..'\u1f1d' // Greek_Extended + | '\u1f28' ..'\u1f2f' // Greek_Extended + | '\u1f38' ..'\u1f3f' // Greek_Extended + | '\u1f48' ..'\u1f4d' // Greek_Extended + | '\u1f59' // Greek_Extended + | '\u1f5b' // Greek_Extended + | '\u1f5d' // Greek_Extended + | '\u1f5f' // Greek_Extended + | '\u1f68' ..'\u1f6f' // Greek_Extended + | '\u1fb8' ..'\u1fbb' // Greek_Extended + | '\u1fc8' ..'\u1fcb' // Greek_Extended + | '\u1fd8' ..'\u1fdb' // Greek_Extended + | '\u1fe8' ..'\u1fec' // Greek_Extended + | '\u1ff8' ..'\u1ffb' // Greek_Extended + | '\u2102' // Letterlike_Symbols + | '\u2107' // Letterlike_Symbols + | '\u210b' ..'\u210d' // Letterlike_Symbols + | '\u2110' ..'\u2112' // Letterlike_Symbols + | '\u2115' // Letterlike_Symbols + | '\u2119' ..'\u211d' // Letterlike_Symbols + | '\u2124' // Letterlike_Symbols + | '\u2126' // Letterlike_Symbols + | '\u2128' // Letterlike_Symbols + | '\u212a' ..'\u212d' // Letterlike_Symbols + | '\u2130' ..'\u2133' // Letterlike_Symbols + | '\u213e' ..'\u213f' // Letterlike_Symbols + | '\u2145' // Letterlike_Symbols + | '\u2183' // Number_Forms + | '\u2c00' ..'\u2c2e' // Glagolitic + | '\u2c60' // Latin_Extended-C + | '\u2c62' ..'\u2c64' // Latin_Extended-C + | '\u2c67' // Latin_Extended-C + | '\u2c69' // Latin_Extended-C + | '\u2c6b' // Latin_Extended-C + | '\u2c6d' ..'\u2c70' // Latin_Extended-C + | '\u2c72' // Latin_Extended-C + | '\u2c75' // Latin_Extended-C + | '\u2c7e' ..'\u2c80' // Latin_Extended-C + | '\u2c82' // Coptic + | '\u2c84' // Coptic + | '\u2c86' // Coptic + | '\u2c88' // Coptic + | '\u2c8a' // Coptic + | '\u2c8c' // Coptic + | '\u2c8e' // Coptic + | '\u2c90' // Coptic + | '\u2c92' // Coptic + | '\u2c94' // Coptic + | '\u2c96' // Coptic + | '\u2c98' // Coptic + | '\u2c9a' // Coptic + | '\u2c9c' // Coptic + | '\u2c9e' // Coptic + | '\u2ca0' // Coptic + | '\u2ca2' // Coptic + | '\u2ca4' // Coptic + | '\u2ca6' // Coptic + | '\u2ca8' // Coptic + | '\u2caa' // Coptic + | '\u2cac' // Coptic + | '\u2cae' // Coptic + | '\u2cb0' // Coptic + | '\u2cb2' // Coptic + | '\u2cb4' // Coptic + | '\u2cb6' // Coptic + | '\u2cb8' // Coptic + | '\u2cba' // Coptic + | '\u2cbc' // Coptic + | '\u2cbe' // Coptic + | '\u2cc0' // Coptic + | '\u2cc2' // Coptic + | '\u2cc4' // Coptic + | '\u2cc6' // Coptic + | '\u2cc8' // Coptic + | '\u2cca' // Coptic + | '\u2ccc' // Coptic + | '\u2cce' // Coptic + | '\u2cd0' // Coptic + | '\u2cd2' // Coptic + | '\u2cd4' // Coptic + | '\u2cd6' // Coptic + | '\u2cd8' // Coptic + | '\u2cda' // Coptic + | '\u2cdc' // Coptic + | '\u2cde' // Coptic + | '\u2ce0' // Coptic + | '\u2ce2' // Coptic + | '\u2ceb' // Coptic + | '\u2ced' // Coptic + | '\u2cf2' // Coptic + | '\ua640' // Cyrillic_Extended-B + | '\ua642' // Cyrillic_Extended-B + | '\ua644' // Cyrillic_Extended-B + | '\ua646' // Cyrillic_Extended-B + | '\ua648' // Cyrillic_Extended-B + | '\ua64a' // Cyrillic_Extended-B + | '\ua64c' // Cyrillic_Extended-B + | '\ua64e' // Cyrillic_Extended-B + | '\ua650' // Cyrillic_Extended-B + | '\ua652' // Cyrillic_Extended-B + | '\ua654' // Cyrillic_Extended-B + | '\ua656' // Cyrillic_Extended-B + | '\ua658' // Cyrillic_Extended-B + | '\ua65a' // Cyrillic_Extended-B + | '\ua65c' // Cyrillic_Extended-B + | '\ua65e' // Cyrillic_Extended-B + | '\ua660' // Cyrillic_Extended-B + | '\ua662' // Cyrillic_Extended-B + | '\ua664' // Cyrillic_Extended-B + | '\ua666' // Cyrillic_Extended-B + | '\ua668' // Cyrillic_Extended-B + | '\ua66a' // Cyrillic_Extended-B + | '\ua66c' // Cyrillic_Extended-B + | '\ua680' // Cyrillic_Extended-B + | '\ua682' // Cyrillic_Extended-B + | '\ua684' // Cyrillic_Extended-B + | '\ua686' // Cyrillic_Extended-B + | '\ua688' // Cyrillic_Extended-B + | '\ua68a' // Cyrillic_Extended-B + | '\ua68c' // Cyrillic_Extended-B + | '\ua68e' // Cyrillic_Extended-B + | '\ua690' // Cyrillic_Extended-B + | '\ua692' // Cyrillic_Extended-B + | '\ua694' // Cyrillic_Extended-B + | '\ua696' // Cyrillic_Extended-B + | '\ua698' // Cyrillic_Extended-B + | '\ua69a' // Cyrillic_Extended-B + | '\ua722' // Latin_Extended-D + | '\ua724' // Latin_Extended-D + | '\ua726' // Latin_Extended-D + | '\ua728' // Latin_Extended-D + | '\ua72a' // Latin_Extended-D + | '\ua72c' // Latin_Extended-D + | '\ua72e' // Latin_Extended-D + | '\ua732' // Latin_Extended-D + | '\ua734' // Latin_Extended-D + | '\ua736' // Latin_Extended-D + | '\ua738' // Latin_Extended-D + | '\ua73a' // Latin_Extended-D + | '\ua73c' // Latin_Extended-D + | '\ua73e' // Latin_Extended-D + | '\ua740' // Latin_Extended-D + | '\ua742' // Latin_Extended-D + | '\ua744' // Latin_Extended-D + | '\ua746' // Latin_Extended-D + | '\ua748' // Latin_Extended-D + | '\ua74a' // Latin_Extended-D + | '\ua74c' // Latin_Extended-D + | '\ua74e' // Latin_Extended-D + | '\ua750' // Latin_Extended-D + | '\ua752' // Latin_Extended-D + | '\ua754' // Latin_Extended-D + | '\ua756' // Latin_Extended-D + | '\ua758' // Latin_Extended-D + | '\ua75a' // Latin_Extended-D + | '\ua75c' // Latin_Extended-D + | '\ua75e' // Latin_Extended-D + | '\ua760' // Latin_Extended-D + | '\ua762' // Latin_Extended-D + | '\ua764' // Latin_Extended-D + | '\ua766' // Latin_Extended-D + | '\ua768' // Latin_Extended-D + | '\ua76a' // Latin_Extended-D + | '\ua76c' // Latin_Extended-D + | '\ua76e' // Latin_Extended-D + | '\ua779' // Latin_Extended-D + | '\ua77b' // Latin_Extended-D + | '\ua77d' ..'\ua77e' // Latin_Extended-D + | '\ua780' // Latin_Extended-D + | '\ua782' // Latin_Extended-D + | '\ua784' // Latin_Extended-D + | '\ua786' // Latin_Extended-D + | '\ua78b' // Latin_Extended-D + | '\ua78d' // Latin_Extended-D + | '\ua790' // Latin_Extended-D + | '\ua792' // Latin_Extended-D + | '\ua796' // Latin_Extended-D + | '\ua798' // Latin_Extended-D + | '\ua79a' // Latin_Extended-D + | '\ua79c' // Latin_Extended-D + | '\ua79e' // Latin_Extended-D + | '\ua7a0' // Latin_Extended-D + | '\ua7a2' // Latin_Extended-D + | '\ua7a4' // Latin_Extended-D + | '\ua7a6' // Latin_Extended-D + | '\ua7a8' // Latin_Extended-D + | '\ua7aa' ..'\ua7ae' // Latin_Extended-D + | '\ua7b0' ..'\ua7b4' // Latin_Extended-D + | '\ua7b6' // Latin_Extended-D + | '\uff21' ..'\uff3a' // Halfwidth_and_Fullwidth_Forms ; -fragment SMALL : ASCSMALL | UNISMALL; +fragment SMALL : ASCSMALL | UNISMALL; fragment ASCSMALL : [_a-z]; -fragment UNISMALL - // : '\u0061'..'\u007a' // Basic_Latin - : '\u00b5' // Latin-1_Supplement - | '\u00df'..'\u00f6' // Latin-1_Supplement - | '\u00f8'..'\u00ff' // Latin-1_Supplement - | '\u0101' // Latin_Extended-A - | '\u0103' // Latin_Extended-A - | '\u0105' // Latin_Extended-A - | '\u0107' // Latin_Extended-A - | '\u0109' // Latin_Extended-A - | '\u010b' // Latin_Extended-A - | '\u010d' // Latin_Extended-A - | '\u010f' // Latin_Extended-A - | '\u0111' // Latin_Extended-A - | '\u0113' // Latin_Extended-A - | '\u0115' // Latin_Extended-A - | '\u0117' // Latin_Extended-A - | '\u0119' // Latin_Extended-A - | '\u011b' // Latin_Extended-A - | '\u011d' // Latin_Extended-A - | '\u011f' // Latin_Extended-A - | '\u0121' // Latin_Extended-A - | '\u0123' // Latin_Extended-A - | '\u0125' // Latin_Extended-A - | '\u0127' // Latin_Extended-A - | '\u0129' // Latin_Extended-A - | '\u012b' // Latin_Extended-A - | '\u012d' // Latin_Extended-A - | '\u012f' // Latin_Extended-A - | '\u0131' // Latin_Extended-A - | '\u0133' // Latin_Extended-A - | '\u0135' // Latin_Extended-A - | '\u0137'..'\u0138' // Latin_Extended-A - | '\u013a' // Latin_Extended-A - | '\u013c' // Latin_Extended-A - | '\u013e' // Latin_Extended-A - | '\u0140' // Latin_Extended-A - | '\u0142' // Latin_Extended-A - | '\u0144' // Latin_Extended-A - | '\u0146' // Latin_Extended-A - | '\u0148'..'\u0149' // Latin_Extended-A - | '\u014b' // Latin_Extended-A - | '\u014d' // Latin_Extended-A - | '\u014f' // Latin_Extended-A - | '\u0151' // Latin_Extended-A - | '\u0153' // Latin_Extended-A - | '\u0155' // Latin_Extended-A - | '\u0157' // Latin_Extended-A - | '\u0159' // Latin_Extended-A - | '\u015b' // Latin_Extended-A - | '\u015d' // Latin_Extended-A - | '\u015f' // Latin_Extended-A - | '\u0161' // Latin_Extended-A - | '\u0163' // Latin_Extended-A - | '\u0165' // Latin_Extended-A - | '\u0167' // Latin_Extended-A - | '\u0169' // Latin_Extended-A - | '\u016b' // Latin_Extended-A - | '\u016d' // Latin_Extended-A - | '\u016f' // Latin_Extended-A - | '\u0171' // Latin_Extended-A - | '\u0173' // Latin_Extended-A - | '\u0175' // Latin_Extended-A - | '\u0177' // Latin_Extended-A - | '\u017a' // Latin_Extended-A - | '\u017c' // Latin_Extended-A - | '\u017e'..'\u0180' // Latin_Extended-A - | '\u0183' // Latin_Extended-B - | '\u0185' // Latin_Extended-B - | '\u0188' // Latin_Extended-B - | '\u018c'..'\u018d' // Latin_Extended-B - | '\u0192' // Latin_Extended-B - | '\u0195' // Latin_Extended-B - | '\u0199'..'\u019b' // Latin_Extended-B - | '\u019e' // Latin_Extended-B - | '\u01a1' // Latin_Extended-B - | '\u01a3' // Latin_Extended-B - | '\u01a5' // Latin_Extended-B - | '\u01a8' // Latin_Extended-B - | '\u01aa'..'\u01ab' // Latin_Extended-B - | '\u01ad' // Latin_Extended-B - | '\u01b0' // Latin_Extended-B - | '\u01b4' // Latin_Extended-B - | '\u01b6' // Latin_Extended-B - | '\u01b9'..'\u01ba' // Latin_Extended-B - | '\u01bd'..'\u01bf' // Latin_Extended-B - | '\u01c6' // Latin_Extended-B - | '\u01c9' // Latin_Extended-B - | '\u01cc' // Latin_Extended-B - | '\u01ce' // Latin_Extended-B - | '\u01d0' // Latin_Extended-B - | '\u01d2' // Latin_Extended-B - | '\u01d4' // Latin_Extended-B - | '\u01d6' // Latin_Extended-B - | '\u01d8' // Latin_Extended-B - | '\u01da' // Latin_Extended-B - | '\u01dc'..'\u01dd' // Latin_Extended-B - | '\u01df' // Latin_Extended-B - | '\u01e1' // Latin_Extended-B - | '\u01e3' // Latin_Extended-B - | '\u01e5' // Latin_Extended-B - | '\u01e7' // Latin_Extended-B - | '\u01e9' // Latin_Extended-B - | '\u01eb' // Latin_Extended-B - | '\u01ed' // Latin_Extended-B - | '\u01ef'..'\u01f0' // Latin_Extended-B - | '\u01f3' // Latin_Extended-B - | '\u01f5' // Latin_Extended-B - | '\u01f9' // Latin_Extended-B - | '\u01fb' // Latin_Extended-B - | '\u01fd' // Latin_Extended-B - | '\u01ff' // Latin_Extended-B - | '\u0201' // Latin_Extended-B - | '\u0203' // Latin_Extended-B - | '\u0205' // Latin_Extended-B - | '\u0207' // Latin_Extended-B - | '\u0209' // Latin_Extended-B - | '\u020b' // Latin_Extended-B - | '\u020d' // Latin_Extended-B - | '\u020f' // Latin_Extended-B - | '\u0211' // Latin_Extended-B - | '\u0213' // Latin_Extended-B - | '\u0215' // Latin_Extended-B - | '\u0217' // Latin_Extended-B - | '\u0219' // Latin_Extended-B - | '\u021b' // Latin_Extended-B - | '\u021d' // Latin_Extended-B - | '\u021f' // Latin_Extended-B - | '\u0221' // Latin_Extended-B - | '\u0223' // Latin_Extended-B - | '\u0225' // Latin_Extended-B - | '\u0227' // Latin_Extended-B - | '\u0229' // Latin_Extended-B - | '\u022b' // Latin_Extended-B - | '\u022d' // Latin_Extended-B - | '\u022f' // Latin_Extended-B - | '\u0231' // Latin_Extended-B - | '\u0233'..'\u0239' // Latin_Extended-B - | '\u023c' // Latin_Extended-B - | '\u023f'..'\u0240' // Latin_Extended-B - | '\u0242' // Latin_Extended-B - | '\u0247' // Latin_Extended-B - | '\u0249' // Latin_Extended-B - | '\u024b' // Latin_Extended-B - | '\u024d' // Latin_Extended-B - | '\u024f'..'\u0293' // (Absent from Blocks.txt) - | '\u0295'..'\u02af' // IPA_Extensions - | '\u0371' // Greek_and_Coptic - | '\u0373' // Greek_and_Coptic - | '\u0377' // Greek_and_Coptic - | '\u037b'..'\u037d' // Greek_and_Coptic - | '\u0390' // Greek_and_Coptic - | '\u03ac'..'\u03ce' // Greek_and_Coptic - | '\u03d0'..'\u03d1' // Greek_and_Coptic - | '\u03d5'..'\u03d7' // Greek_and_Coptic - | '\u03d9' // Greek_and_Coptic - | '\u03db' // Greek_and_Coptic - | '\u03dd' // Greek_and_Coptic - | '\u03df' // Greek_and_Coptic - | '\u03e1' // Greek_and_Coptic - | '\u03e3' // Greek_and_Coptic - | '\u03e5' // Greek_and_Coptic - | '\u03e7' // Greek_and_Coptic - | '\u03e9' // Greek_and_Coptic - | '\u03eb' // Greek_and_Coptic - | '\u03ed' // Greek_and_Coptic - | '\u03ef'..'\u03f3' // Greek_and_Coptic - | '\u03f5' // Greek_and_Coptic - | '\u03f8' // Greek_and_Coptic - | '\u03fb'..'\u03fc' // Greek_and_Coptic - | '\u0430'..'\u045f' // Cyrillic - | '\u0461' // Cyrillic - | '\u0463' // Cyrillic - | '\u0465' // Cyrillic - | '\u0467' // Cyrillic - | '\u0469' // Cyrillic - | '\u046b' // Cyrillic - | '\u046d' // Cyrillic - | '\u046f' // Cyrillic - | '\u0471' // Cyrillic - | '\u0473' // Cyrillic - | '\u0475' // Cyrillic - | '\u0477' // Cyrillic - | '\u0479' // Cyrillic - | '\u047b' // Cyrillic - | '\u047d' // Cyrillic - | '\u047f' // Cyrillic - | '\u0481' // Cyrillic - | '\u048b' // Cyrillic - | '\u048d' // Cyrillic - | '\u048f' // Cyrillic - | '\u0491' // Cyrillic - | '\u0493' // Cyrillic - | '\u0495' // Cyrillic - | '\u0497' // Cyrillic - | '\u0499' // Cyrillic - | '\u049b' // Cyrillic - | '\u049d' // Cyrillic - | '\u049f' // Cyrillic - | '\u04a1' // Cyrillic - | '\u04a3' // Cyrillic - | '\u04a5' // Cyrillic - | '\u04a7' // Cyrillic - | '\u04a9' // Cyrillic - | '\u04ab' // Cyrillic - | '\u04ad' // Cyrillic - | '\u04af' // Cyrillic - | '\u04b1' // Cyrillic - | '\u04b3' // Cyrillic - | '\u04b5' // Cyrillic - | '\u04b7' // Cyrillic - | '\u04b9' // Cyrillic - | '\u04bb' // Cyrillic - | '\u04bd' // Cyrillic - | '\u04bf' // Cyrillic - | '\u04c2' // Cyrillic - | '\u04c4' // Cyrillic - | '\u04c6' // Cyrillic - | '\u04c8' // Cyrillic - | '\u04ca' // Cyrillic - | '\u04cc' // Cyrillic - | '\u04ce'..'\u04cf' // Cyrillic - | '\u04d1' // Cyrillic - | '\u04d3' // Cyrillic - | '\u04d5' // Cyrillic - | '\u04d7' // Cyrillic - | '\u04d9' // Cyrillic - | '\u04db' // Cyrillic - | '\u04dd' // Cyrillic - | '\u04df' // Cyrillic - | '\u04e1' // Cyrillic - | '\u04e3' // Cyrillic - | '\u04e5' // Cyrillic - | '\u04e7' // Cyrillic - | '\u04e9' // Cyrillic - | '\u04eb' // Cyrillic - | '\u04ed' // Cyrillic - | '\u04ef' // Cyrillic - | '\u04f1' // Cyrillic - | '\u04f3' // Cyrillic - | '\u04f5' // Cyrillic - | '\u04f7' // Cyrillic - | '\u04f9' // Cyrillic - | '\u04fb' // Cyrillic - | '\u04fd' // Cyrillic - | '\u04ff' // (Absent from Blocks.txt) - | '\u0501' // Cyrillic_Supplement - | '\u0503' // Cyrillic_Supplement - | '\u0505' // Cyrillic_Supplement - | '\u0507' // Cyrillic_Supplement - | '\u0509' // Cyrillic_Supplement - | '\u050b' // Cyrillic_Supplement - | '\u050d' // Cyrillic_Supplement - | '\u050f' // Cyrillic_Supplement - | '\u0511' // Cyrillic_Supplement - | '\u0513' // Cyrillic_Supplement - | '\u0515' // Cyrillic_Supplement - | '\u0517' // Cyrillic_Supplement - | '\u0519' // Cyrillic_Supplement - | '\u051b' // Cyrillic_Supplement - | '\u051d' // Cyrillic_Supplement - | '\u051f' // Cyrillic_Supplement - | '\u0521' // Cyrillic_Supplement - | '\u0523' // Cyrillic_Supplement - | '\u0525' // Cyrillic_Supplement - | '\u0527' // Cyrillic_Supplement - | '\u0529' // Cyrillic_Supplement - | '\u052b' // Cyrillic_Supplement - | '\u052d' // Cyrillic_Supplement - | '\u052f' // (Absent from Blocks.txt) - | '\u0561'..'\u0587' // Armenian - | '\u13f8'..'\u13fd' // Cherokee - | '\u1c80'..'\u1c88' // Cyrillic_Extended-C - | '\u1d00'..'\u1d2b' // Phonetic_Extensions - | '\u1d6b'..'\u1d77' // Phonetic_Extensions - | '\u1d79'..'\u1d9a' // Phonetic_Extensions - | '\u1e01' // Latin_Extended_Additional - | '\u1e03' // Latin_Extended_Additional - | '\u1e05' // Latin_Extended_Additional - | '\u1e07' // Latin_Extended_Additional - | '\u1e09' // Latin_Extended_Additional - | '\u1e0b' // Latin_Extended_Additional - | '\u1e0d' // Latin_Extended_Additional - | '\u1e0f' // Latin_Extended_Additional - | '\u1e11' // Latin_Extended_Additional - | '\u1e13' // Latin_Extended_Additional - | '\u1e15' // Latin_Extended_Additional - | '\u1e17' // Latin_Extended_Additional - | '\u1e19' // Latin_Extended_Additional - | '\u1e1b' // Latin_Extended_Additional - | '\u1e1d' // Latin_Extended_Additional - | '\u1e1f' // Latin_Extended_Additional - | '\u1e21' // Latin_Extended_Additional - | '\u1e23' // Latin_Extended_Additional - | '\u1e25' // Latin_Extended_Additional - | '\u1e27' // Latin_Extended_Additional - | '\u1e29' // Latin_Extended_Additional - | '\u1e2b' // Latin_Extended_Additional - | '\u1e2d' // Latin_Extended_Additional - | '\u1e2f' // Latin_Extended_Additional - | '\u1e31' // Latin_Extended_Additional - | '\u1e33' // Latin_Extended_Additional - | '\u1e35' // Latin_Extended_Additional - | '\u1e37' // Latin_Extended_Additional - | '\u1e39' // Latin_Extended_Additional - | '\u1e3b' // Latin_Extended_Additional - | '\u1e3d' // Latin_Extended_Additional - | '\u1e3f' // Latin_Extended_Additional - | '\u1e41' // Latin_Extended_Additional - | '\u1e43' // Latin_Extended_Additional - | '\u1e45' // Latin_Extended_Additional - | '\u1e47' // Latin_Extended_Additional - | '\u1e49' // Latin_Extended_Additional - | '\u1e4b' // Latin_Extended_Additional - | '\u1e4d' // Latin_Extended_Additional - | '\u1e4f' // Latin_Extended_Additional - | '\u1e51' // Latin_Extended_Additional - | '\u1e53' // Latin_Extended_Additional - | '\u1e55' // Latin_Extended_Additional - | '\u1e57' // Latin_Extended_Additional - | '\u1e59' // Latin_Extended_Additional - | '\u1e5b' // Latin_Extended_Additional - | '\u1e5d' // Latin_Extended_Additional - | '\u1e5f' // Latin_Extended_Additional - | '\u1e61' // Latin_Extended_Additional - | '\u1e63' // Latin_Extended_Additional - | '\u1e65' // Latin_Extended_Additional - | '\u1e67' // Latin_Extended_Additional - | '\u1e69' // Latin_Extended_Additional - | '\u1e6b' // Latin_Extended_Additional - | '\u1e6d' // Latin_Extended_Additional - | '\u1e6f' // Latin_Extended_Additional - | '\u1e71' // Latin_Extended_Additional - | '\u1e73' // Latin_Extended_Additional - | '\u1e75' // Latin_Extended_Additional - | '\u1e77' // Latin_Extended_Additional - | '\u1e79' // Latin_Extended_Additional - | '\u1e7b' // Latin_Extended_Additional - | '\u1e7d' // Latin_Extended_Additional - | '\u1e7f' // Latin_Extended_Additional - | '\u1e81' // Latin_Extended_Additional - | '\u1e83' // Latin_Extended_Additional - | '\u1e85' // Latin_Extended_Additional - | '\u1e87' // Latin_Extended_Additional - | '\u1e89' // Latin_Extended_Additional - | '\u1e8b' // Latin_Extended_Additional - | '\u1e8d' // Latin_Extended_Additional - | '\u1e8f' // Latin_Extended_Additional - | '\u1e91' // Latin_Extended_Additional - | '\u1e93' // Latin_Extended_Additional - | '\u1e95'..'\u1e9d' // Latin_Extended_Additional - | '\u1e9f' // Latin_Extended_Additional - | '\u1ea1' // Latin_Extended_Additional - | '\u1ea3' // Latin_Extended_Additional - | '\u1ea5' // Latin_Extended_Additional - | '\u1ea7' // Latin_Extended_Additional - | '\u1ea9' // Latin_Extended_Additional - | '\u1eab' // Latin_Extended_Additional - | '\u1ead' // Latin_Extended_Additional - | '\u1eaf' // Latin_Extended_Additional - | '\u1eb1' // Latin_Extended_Additional - | '\u1eb3' // Latin_Extended_Additional - | '\u1eb5' // Latin_Extended_Additional - | '\u1eb7' // Latin_Extended_Additional - | '\u1eb9' // Latin_Extended_Additional - | '\u1ebb' // Latin_Extended_Additional - | '\u1ebd' // Latin_Extended_Additional - | '\u1ebf' // Latin_Extended_Additional - | '\u1ec1' // Latin_Extended_Additional - | '\u1ec3' // Latin_Extended_Additional - | '\u1ec5' // Latin_Extended_Additional - | '\u1ec7' // Latin_Extended_Additional - | '\u1ec9' // Latin_Extended_Additional - | '\u1ecb' // Latin_Extended_Additional - | '\u1ecd' // Latin_Extended_Additional - | '\u1ecf' // Latin_Extended_Additional - | '\u1ed1' // Latin_Extended_Additional - | '\u1ed3' // Latin_Extended_Additional - | '\u1ed5' // Latin_Extended_Additional - | '\u1ed7' // Latin_Extended_Additional - | '\u1ed9' // Latin_Extended_Additional - | '\u1edb' // Latin_Extended_Additional - | '\u1edd' // Latin_Extended_Additional - | '\u1edf' // Latin_Extended_Additional - | '\u1ee1' // Latin_Extended_Additional - | '\u1ee3' // Latin_Extended_Additional - | '\u1ee5' // Latin_Extended_Additional - | '\u1ee7' // Latin_Extended_Additional - | '\u1ee9' // Latin_Extended_Additional - | '\u1eeb' // Latin_Extended_Additional - | '\u1eed' // Latin_Extended_Additional - | '\u1eef' // Latin_Extended_Additional - | '\u1ef1' // Latin_Extended_Additional - | '\u1ef3' // Latin_Extended_Additional - | '\u1ef5' // Latin_Extended_Additional - | '\u1ef7' // Latin_Extended_Additional - | '\u1ef9' // Latin_Extended_Additional - | '\u1efb' // Latin_Extended_Additional - | '\u1efd' // Latin_Extended_Additional - | '\u1eff'..'\u1f07' // (Absent from Blocks.txt) - | '\u1f10'..'\u1f15' // Greek_Extended - | '\u1f20'..'\u1f27' // Greek_Extended - | '\u1f30'..'\u1f37' // Greek_Extended - | '\u1f40'..'\u1f45' // Greek_Extended - | '\u1f50'..'\u1f57' // Greek_Extended - | '\u1f60'..'\u1f67' // Greek_Extended - | '\u1f70'..'\u1f7d' // Greek_Extended - | '\u1f80'..'\u1f87' // Greek_Extended - | '\u1f90'..'\u1f97' // Greek_Extended - | '\u1fa0'..'\u1fa7' // Greek_Extended - | '\u1fb0'..'\u1fb4' // Greek_Extended - | '\u1fb6'..'\u1fb7' // Greek_Extended - | '\u1fbe' // Greek_Extended - | '\u1fc2'..'\u1fc4' // Greek_Extended - | '\u1fc6'..'\u1fc7' // Greek_Extended - | '\u1fd0'..'\u1fd3' // Greek_Extended - | '\u1fd6'..'\u1fd7' // Greek_Extended - | '\u1fe0'..'\u1fe7' // Greek_Extended - | '\u1ff2'..'\u1ff4' // Greek_Extended - | '\u1ff6'..'\u1ff7' // Greek_Extended - | '\u210a' // Letterlike_Symbols - | '\u210e'..'\u210f' // Letterlike_Symbols - | '\u2113' // Letterlike_Symbols - | '\u212f' // Letterlike_Symbols - | '\u2134' // Letterlike_Symbols - | '\u2139' // Letterlike_Symbols - | '\u213c'..'\u213d' // Letterlike_Symbols - | '\u2146'..'\u2149' // Letterlike_Symbols - | '\u214e' // Letterlike_Symbols - | '\u2184' // Number_Forms - | '\u2c30'..'\u2c5e' // Glagolitic - | '\u2c61' // Latin_Extended-C - | '\u2c65'..'\u2c66' // Latin_Extended-C - | '\u2c68' // Latin_Extended-C - | '\u2c6a' // Latin_Extended-C - | '\u2c6c' // Latin_Extended-C - | '\u2c71' // Latin_Extended-C - | '\u2c73'..'\u2c74' // Latin_Extended-C - | '\u2c76'..'\u2c7b' // Latin_Extended-C - | '\u2c81' // Coptic - | '\u2c83' // Coptic - | '\u2c85' // Coptic - | '\u2c87' // Coptic - | '\u2c89' // Coptic - | '\u2c8b' // Coptic - | '\u2c8d' // Coptic - | '\u2c8f' // Coptic - | '\u2c91' // Coptic - | '\u2c93' // Coptic - | '\u2c95' // Coptic - | '\u2c97' // Coptic - | '\u2c99' // Coptic - | '\u2c9b' // Coptic - | '\u2c9d' // Coptic - | '\u2c9f' // Coptic - | '\u2ca1' // Coptic - | '\u2ca3' // Coptic - | '\u2ca5' // Coptic - | '\u2ca7' // Coptic - | '\u2ca9' // Coptic - | '\u2cab' // Coptic - | '\u2cad' // Coptic - | '\u2caf' // Coptic - | '\u2cb1' // Coptic - | '\u2cb3' // Coptic - | '\u2cb5' // Coptic - | '\u2cb7' // Coptic - | '\u2cb9' // Coptic - | '\u2cbb' // Coptic - | '\u2cbd' // Coptic - | '\u2cbf' // Coptic - | '\u2cc1' // Coptic - | '\u2cc3' // Coptic - | '\u2cc5' // Coptic - | '\u2cc7' // Coptic - | '\u2cc9' // Coptic - | '\u2ccb' // Coptic - | '\u2ccd' // Coptic - | '\u2ccf' // Coptic - | '\u2cd1' // Coptic - | '\u2cd3' // Coptic - | '\u2cd5' // Coptic - | '\u2cd7' // Coptic - | '\u2cd9' // Coptic - | '\u2cdb' // Coptic - | '\u2cdd' // Coptic - | '\u2cdf' // Coptic - | '\u2ce1' // Coptic - | '\u2ce3'..'\u2ce4' // Coptic - | '\u2cec' // Coptic - | '\u2cee' // Coptic - | '\u2cf3' // Coptic - | '\u2d00'..'\u2d25' // Georgian_Supplement - | '\u2d27' // Georgian_Supplement - | '\u2d2d' // Georgian_Supplement - | '\ua641' // Cyrillic_Extended-B - | '\ua643' // Cyrillic_Extended-B - | '\ua645' // Cyrillic_Extended-B - | '\ua647' // Cyrillic_Extended-B - | '\ua649' // Cyrillic_Extended-B - | '\ua64b' // Cyrillic_Extended-B - | '\ua64d' // Cyrillic_Extended-B - | '\ua64f' // Cyrillic_Extended-B - | '\ua651' // Cyrillic_Extended-B - | '\ua653' // Cyrillic_Extended-B - | '\ua655' // Cyrillic_Extended-B - | '\ua657' // Cyrillic_Extended-B - | '\ua659' // Cyrillic_Extended-B - | '\ua65b' // Cyrillic_Extended-B - | '\ua65d' // Cyrillic_Extended-B - | '\ua65f' // Cyrillic_Extended-B - | '\ua661' // Cyrillic_Extended-B - | '\ua663' // Cyrillic_Extended-B - | '\ua665' // Cyrillic_Extended-B - | '\ua667' // Cyrillic_Extended-B - | '\ua669' // Cyrillic_Extended-B - | '\ua66b' // Cyrillic_Extended-B - | '\ua66d' // Cyrillic_Extended-B - | '\ua681' // Cyrillic_Extended-B - | '\ua683' // Cyrillic_Extended-B - | '\ua685' // Cyrillic_Extended-B - | '\ua687' // Cyrillic_Extended-B - | '\ua689' // Cyrillic_Extended-B - | '\ua68b' // Cyrillic_Extended-B - | '\ua68d' // Cyrillic_Extended-B - | '\ua68f' // Cyrillic_Extended-B - | '\ua691' // Cyrillic_Extended-B - | '\ua693' // Cyrillic_Extended-B - | '\ua695' // Cyrillic_Extended-B - | '\ua697' // Cyrillic_Extended-B - | '\ua699' // Cyrillic_Extended-B - | '\ua69b' // Cyrillic_Extended-B - | '\ua723' // Latin_Extended-D - | '\ua725' // Latin_Extended-D - | '\ua727' // Latin_Extended-D - | '\ua729' // Latin_Extended-D - | '\ua72b' // Latin_Extended-D - | '\ua72d' // Latin_Extended-D - | '\ua72f'..'\ua731' // Latin_Extended-D - | '\ua733' // Latin_Extended-D - | '\ua735' // Latin_Extended-D - | '\ua737' // Latin_Extended-D - | '\ua739' // Latin_Extended-D - | '\ua73b' // Latin_Extended-D - | '\ua73d' // Latin_Extended-D - | '\ua73f' // Latin_Extended-D - | '\ua741' // Latin_Extended-D - | '\ua743' // Latin_Extended-D - | '\ua745' // Latin_Extended-D - | '\ua747' // Latin_Extended-D - | '\ua749' // Latin_Extended-D - | '\ua74b' // Latin_Extended-D - | '\ua74d' // Latin_Extended-D - | '\ua74f' // Latin_Extended-D - | '\ua751' // Latin_Extended-D - | '\ua753' // Latin_Extended-D - | '\ua755' // Latin_Extended-D - | '\ua757' // Latin_Extended-D - | '\ua759' // Latin_Extended-D - | '\ua75b' // Latin_Extended-D - | '\ua75d' // Latin_Extended-D - | '\ua75f' // Latin_Extended-D - | '\ua761' // Latin_Extended-D - | '\ua763' // Latin_Extended-D - | '\ua765' // Latin_Extended-D - | '\ua767' // Latin_Extended-D - | '\ua769' // Latin_Extended-D - | '\ua76b' // Latin_Extended-D - | '\ua76d' // Latin_Extended-D - | '\ua76f' // Latin_Extended-D - | '\ua771'..'\ua778' // Latin_Extended-D - | '\ua77a' // Latin_Extended-D - | '\ua77c' // Latin_Extended-D - | '\ua77f' // Latin_Extended-D - | '\ua781' // Latin_Extended-D - | '\ua783' // Latin_Extended-D - | '\ua785' // Latin_Extended-D - | '\ua787' // Latin_Extended-D - | '\ua78c' // Latin_Extended-D - | '\ua78e' // Latin_Extended-D - | '\ua791' // Latin_Extended-D - | '\ua793'..'\ua795' // Latin_Extended-D - | '\ua797' // Latin_Extended-D - | '\ua799' // Latin_Extended-D - | '\ua79b' // Latin_Extended-D - | '\ua79d' // Latin_Extended-D - | '\ua79f' // Latin_Extended-D - | '\ua7a1' // Latin_Extended-D - | '\ua7a3' // Latin_Extended-D - | '\ua7a5' // Latin_Extended-D - | '\ua7a7' // Latin_Extended-D - | '\ua7a9' // Latin_Extended-D - | '\ua7b5' // Latin_Extended-D - | '\ua7b7' // Latin_Extended-D - | '\ua7fa' // Latin_Extended-D - | '\uab30'..'\uab5a' // Latin_Extended-E - | '\uab60'..'\uab65' // Latin_Extended-E - | '\uab70'..'\uabbf' // Cherokee_Supplement - | '\ufb00'..'\ufb06' // Alphabetic_Presentation_Forms - | '\ufb13'..'\ufb17' // Alphabetic_Presentation_Forms - | '\uff41'..'\uff5a' // Halfwidth_and_Fullwidth_Forms +fragment UNISMALL: // : '\u0061'..'\u007a' // Basic_Latin + '\u00b5' // Latin-1_Supplement + | '\u00df' ..'\u00f6' // Latin-1_Supplement + | '\u00f8' ..'\u00ff' // Latin-1_Supplement + | '\u0101' // Latin_Extended-A + | '\u0103' // Latin_Extended-A + | '\u0105' // Latin_Extended-A + | '\u0107' // Latin_Extended-A + | '\u0109' // Latin_Extended-A + | '\u010b' // Latin_Extended-A + | '\u010d' // Latin_Extended-A + | '\u010f' // Latin_Extended-A + | '\u0111' // Latin_Extended-A + | '\u0113' // Latin_Extended-A + | '\u0115' // Latin_Extended-A + | '\u0117' // Latin_Extended-A + | '\u0119' // Latin_Extended-A + | '\u011b' // Latin_Extended-A + | '\u011d' // Latin_Extended-A + | '\u011f' // Latin_Extended-A + | '\u0121' // Latin_Extended-A + | '\u0123' // Latin_Extended-A + | '\u0125' // Latin_Extended-A + | '\u0127' // Latin_Extended-A + | '\u0129' // Latin_Extended-A + | '\u012b' // Latin_Extended-A + | '\u012d' // Latin_Extended-A + | '\u012f' // Latin_Extended-A + | '\u0131' // Latin_Extended-A + | '\u0133' // Latin_Extended-A + | '\u0135' // Latin_Extended-A + | '\u0137' ..'\u0138' // Latin_Extended-A + | '\u013a' // Latin_Extended-A + | '\u013c' // Latin_Extended-A + | '\u013e' // Latin_Extended-A + | '\u0140' // Latin_Extended-A + | '\u0142' // Latin_Extended-A + | '\u0144' // Latin_Extended-A + | '\u0146' // Latin_Extended-A + | '\u0148' ..'\u0149' // Latin_Extended-A + | '\u014b' // Latin_Extended-A + | '\u014d' // Latin_Extended-A + | '\u014f' // Latin_Extended-A + | '\u0151' // Latin_Extended-A + | '\u0153' // Latin_Extended-A + | '\u0155' // Latin_Extended-A + | '\u0157' // Latin_Extended-A + | '\u0159' // Latin_Extended-A + | '\u015b' // Latin_Extended-A + | '\u015d' // Latin_Extended-A + | '\u015f' // Latin_Extended-A + | '\u0161' // Latin_Extended-A + | '\u0163' // Latin_Extended-A + | '\u0165' // Latin_Extended-A + | '\u0167' // Latin_Extended-A + | '\u0169' // Latin_Extended-A + | '\u016b' // Latin_Extended-A + | '\u016d' // Latin_Extended-A + | '\u016f' // Latin_Extended-A + | '\u0171' // Latin_Extended-A + | '\u0173' // Latin_Extended-A + | '\u0175' // Latin_Extended-A + | '\u0177' // Latin_Extended-A + | '\u017a' // Latin_Extended-A + | '\u017c' // Latin_Extended-A + | '\u017e' ..'\u0180' // Latin_Extended-A + | '\u0183' // Latin_Extended-B + | '\u0185' // Latin_Extended-B + | '\u0188' // Latin_Extended-B + | '\u018c' ..'\u018d' // Latin_Extended-B + | '\u0192' // Latin_Extended-B + | '\u0195' // Latin_Extended-B + | '\u0199' ..'\u019b' // Latin_Extended-B + | '\u019e' // Latin_Extended-B + | '\u01a1' // Latin_Extended-B + | '\u01a3' // Latin_Extended-B + | '\u01a5' // Latin_Extended-B + | '\u01a8' // Latin_Extended-B + | '\u01aa' ..'\u01ab' // Latin_Extended-B + | '\u01ad' // Latin_Extended-B + | '\u01b0' // Latin_Extended-B + | '\u01b4' // Latin_Extended-B + | '\u01b6' // Latin_Extended-B + | '\u01b9' ..'\u01ba' // Latin_Extended-B + | '\u01bd' ..'\u01bf' // Latin_Extended-B + | '\u01c6' // Latin_Extended-B + | '\u01c9' // Latin_Extended-B + | '\u01cc' // Latin_Extended-B + | '\u01ce' // Latin_Extended-B + | '\u01d0' // Latin_Extended-B + | '\u01d2' // Latin_Extended-B + | '\u01d4' // Latin_Extended-B + | '\u01d6' // Latin_Extended-B + | '\u01d8' // Latin_Extended-B + | '\u01da' // Latin_Extended-B + | '\u01dc' ..'\u01dd' // Latin_Extended-B + | '\u01df' // Latin_Extended-B + | '\u01e1' // Latin_Extended-B + | '\u01e3' // Latin_Extended-B + | '\u01e5' // Latin_Extended-B + | '\u01e7' // Latin_Extended-B + | '\u01e9' // Latin_Extended-B + | '\u01eb' // Latin_Extended-B + | '\u01ed' // Latin_Extended-B + | '\u01ef' ..'\u01f0' // Latin_Extended-B + | '\u01f3' // Latin_Extended-B + | '\u01f5' // Latin_Extended-B + | '\u01f9' // Latin_Extended-B + | '\u01fb' // Latin_Extended-B + | '\u01fd' // Latin_Extended-B + | '\u01ff' // Latin_Extended-B + | '\u0201' // Latin_Extended-B + | '\u0203' // Latin_Extended-B + | '\u0205' // Latin_Extended-B + | '\u0207' // Latin_Extended-B + | '\u0209' // Latin_Extended-B + | '\u020b' // Latin_Extended-B + | '\u020d' // Latin_Extended-B + | '\u020f' // Latin_Extended-B + | '\u0211' // Latin_Extended-B + | '\u0213' // Latin_Extended-B + | '\u0215' // Latin_Extended-B + | '\u0217' // Latin_Extended-B + | '\u0219' // Latin_Extended-B + | '\u021b' // Latin_Extended-B + | '\u021d' // Latin_Extended-B + | '\u021f' // Latin_Extended-B + | '\u0221' // Latin_Extended-B + | '\u0223' // Latin_Extended-B + | '\u0225' // Latin_Extended-B + | '\u0227' // Latin_Extended-B + | '\u0229' // Latin_Extended-B + | '\u022b' // Latin_Extended-B + | '\u022d' // Latin_Extended-B + | '\u022f' // Latin_Extended-B + | '\u0231' // Latin_Extended-B + | '\u0233' ..'\u0239' // Latin_Extended-B + | '\u023c' // Latin_Extended-B + | '\u023f' ..'\u0240' // Latin_Extended-B + | '\u0242' // Latin_Extended-B + | '\u0247' // Latin_Extended-B + | '\u0249' // Latin_Extended-B + | '\u024b' // Latin_Extended-B + | '\u024d' // Latin_Extended-B + | '\u024f' ..'\u0293' // (Absent from Blocks.txt) + | '\u0295' ..'\u02af' // IPA_Extensions + | '\u0371' // Greek_and_Coptic + | '\u0373' // Greek_and_Coptic + | '\u0377' // Greek_and_Coptic + | '\u037b' ..'\u037d' // Greek_and_Coptic + | '\u0390' // Greek_and_Coptic + | '\u03ac' ..'\u03ce' // Greek_and_Coptic + | '\u03d0' ..'\u03d1' // Greek_and_Coptic + | '\u03d5' ..'\u03d7' // Greek_and_Coptic + | '\u03d9' // Greek_and_Coptic + | '\u03db' // Greek_and_Coptic + | '\u03dd' // Greek_and_Coptic + | '\u03df' // Greek_and_Coptic + | '\u03e1' // Greek_and_Coptic + | '\u03e3' // Greek_and_Coptic + | '\u03e5' // Greek_and_Coptic + | '\u03e7' // Greek_and_Coptic + | '\u03e9' // Greek_and_Coptic + | '\u03eb' // Greek_and_Coptic + | '\u03ed' // Greek_and_Coptic + | '\u03ef' ..'\u03f3' // Greek_and_Coptic + | '\u03f5' // Greek_and_Coptic + | '\u03f8' // Greek_and_Coptic + | '\u03fb' ..'\u03fc' // Greek_and_Coptic + | '\u0430' ..'\u045f' // Cyrillic + | '\u0461' // Cyrillic + | '\u0463' // Cyrillic + | '\u0465' // Cyrillic + | '\u0467' // Cyrillic + | '\u0469' // Cyrillic + | '\u046b' // Cyrillic + | '\u046d' // Cyrillic + | '\u046f' // Cyrillic + | '\u0471' // Cyrillic + | '\u0473' // Cyrillic + | '\u0475' // Cyrillic + | '\u0477' // Cyrillic + | '\u0479' // Cyrillic + | '\u047b' // Cyrillic + | '\u047d' // Cyrillic + | '\u047f' // Cyrillic + | '\u0481' // Cyrillic + | '\u048b' // Cyrillic + | '\u048d' // Cyrillic + | '\u048f' // Cyrillic + | '\u0491' // Cyrillic + | '\u0493' // Cyrillic + | '\u0495' // Cyrillic + | '\u0497' // Cyrillic + | '\u0499' // Cyrillic + | '\u049b' // Cyrillic + | '\u049d' // Cyrillic + | '\u049f' // Cyrillic + | '\u04a1' // Cyrillic + | '\u04a3' // Cyrillic + | '\u04a5' // Cyrillic + | '\u04a7' // Cyrillic + | '\u04a9' // Cyrillic + | '\u04ab' // Cyrillic + | '\u04ad' // Cyrillic + | '\u04af' // Cyrillic + | '\u04b1' // Cyrillic + | '\u04b3' // Cyrillic + | '\u04b5' // Cyrillic + | '\u04b7' // Cyrillic + | '\u04b9' // Cyrillic + | '\u04bb' // Cyrillic + | '\u04bd' // Cyrillic + | '\u04bf' // Cyrillic + | '\u04c2' // Cyrillic + | '\u04c4' // Cyrillic + | '\u04c6' // Cyrillic + | '\u04c8' // Cyrillic + | '\u04ca' // Cyrillic + | '\u04cc' // Cyrillic + | '\u04ce' ..'\u04cf' // Cyrillic + | '\u04d1' // Cyrillic + | '\u04d3' // Cyrillic + | '\u04d5' // Cyrillic + | '\u04d7' // Cyrillic + | '\u04d9' // Cyrillic + | '\u04db' // Cyrillic + | '\u04dd' // Cyrillic + | '\u04df' // Cyrillic + | '\u04e1' // Cyrillic + | '\u04e3' // Cyrillic + | '\u04e5' // Cyrillic + | '\u04e7' // Cyrillic + | '\u04e9' // Cyrillic + | '\u04eb' // Cyrillic + | '\u04ed' // Cyrillic + | '\u04ef' // Cyrillic + | '\u04f1' // Cyrillic + | '\u04f3' // Cyrillic + | '\u04f5' // Cyrillic + | '\u04f7' // Cyrillic + | '\u04f9' // Cyrillic + | '\u04fb' // Cyrillic + | '\u04fd' // Cyrillic + | '\u04ff' // (Absent from Blocks.txt) + | '\u0501' // Cyrillic_Supplement + | '\u0503' // Cyrillic_Supplement + | '\u0505' // Cyrillic_Supplement + | '\u0507' // Cyrillic_Supplement + | '\u0509' // Cyrillic_Supplement + | '\u050b' // Cyrillic_Supplement + | '\u050d' // Cyrillic_Supplement + | '\u050f' // Cyrillic_Supplement + | '\u0511' // Cyrillic_Supplement + | '\u0513' // Cyrillic_Supplement + | '\u0515' // Cyrillic_Supplement + | '\u0517' // Cyrillic_Supplement + | '\u0519' // Cyrillic_Supplement + | '\u051b' // Cyrillic_Supplement + | '\u051d' // Cyrillic_Supplement + | '\u051f' // Cyrillic_Supplement + | '\u0521' // Cyrillic_Supplement + | '\u0523' // Cyrillic_Supplement + | '\u0525' // Cyrillic_Supplement + | '\u0527' // Cyrillic_Supplement + | '\u0529' // Cyrillic_Supplement + | '\u052b' // Cyrillic_Supplement + | '\u052d' // Cyrillic_Supplement + | '\u052f' // (Absent from Blocks.txt) + | '\u0561' ..'\u0587' // Armenian + | '\u13f8' ..'\u13fd' // Cherokee + | '\u1c80' ..'\u1c88' // Cyrillic_Extended-C + | '\u1d00' ..'\u1d2b' // Phonetic_Extensions + | '\u1d6b' ..'\u1d77' // Phonetic_Extensions + | '\u1d79' ..'\u1d9a' // Phonetic_Extensions + | '\u1e01' // Latin_Extended_Additional + | '\u1e03' // Latin_Extended_Additional + | '\u1e05' // Latin_Extended_Additional + | '\u1e07' // Latin_Extended_Additional + | '\u1e09' // Latin_Extended_Additional + | '\u1e0b' // Latin_Extended_Additional + | '\u1e0d' // Latin_Extended_Additional + | '\u1e0f' // Latin_Extended_Additional + | '\u1e11' // Latin_Extended_Additional + | '\u1e13' // Latin_Extended_Additional + | '\u1e15' // Latin_Extended_Additional + | '\u1e17' // Latin_Extended_Additional + | '\u1e19' // Latin_Extended_Additional + | '\u1e1b' // Latin_Extended_Additional + | '\u1e1d' // Latin_Extended_Additional + | '\u1e1f' // Latin_Extended_Additional + | '\u1e21' // Latin_Extended_Additional + | '\u1e23' // Latin_Extended_Additional + | '\u1e25' // Latin_Extended_Additional + | '\u1e27' // Latin_Extended_Additional + | '\u1e29' // Latin_Extended_Additional + | '\u1e2b' // Latin_Extended_Additional + | '\u1e2d' // Latin_Extended_Additional + | '\u1e2f' // Latin_Extended_Additional + | '\u1e31' // Latin_Extended_Additional + | '\u1e33' // Latin_Extended_Additional + | '\u1e35' // Latin_Extended_Additional + | '\u1e37' // Latin_Extended_Additional + | '\u1e39' // Latin_Extended_Additional + | '\u1e3b' // Latin_Extended_Additional + | '\u1e3d' // Latin_Extended_Additional + | '\u1e3f' // Latin_Extended_Additional + | '\u1e41' // Latin_Extended_Additional + | '\u1e43' // Latin_Extended_Additional + | '\u1e45' // Latin_Extended_Additional + | '\u1e47' // Latin_Extended_Additional + | '\u1e49' // Latin_Extended_Additional + | '\u1e4b' // Latin_Extended_Additional + | '\u1e4d' // Latin_Extended_Additional + | '\u1e4f' // Latin_Extended_Additional + | '\u1e51' // Latin_Extended_Additional + | '\u1e53' // Latin_Extended_Additional + | '\u1e55' // Latin_Extended_Additional + | '\u1e57' // Latin_Extended_Additional + | '\u1e59' // Latin_Extended_Additional + | '\u1e5b' // Latin_Extended_Additional + | '\u1e5d' // Latin_Extended_Additional + | '\u1e5f' // Latin_Extended_Additional + | '\u1e61' // Latin_Extended_Additional + | '\u1e63' // Latin_Extended_Additional + | '\u1e65' // Latin_Extended_Additional + | '\u1e67' // Latin_Extended_Additional + | '\u1e69' // Latin_Extended_Additional + | '\u1e6b' // Latin_Extended_Additional + | '\u1e6d' // Latin_Extended_Additional + | '\u1e6f' // Latin_Extended_Additional + | '\u1e71' // Latin_Extended_Additional + | '\u1e73' // Latin_Extended_Additional + | '\u1e75' // Latin_Extended_Additional + | '\u1e77' // Latin_Extended_Additional + | '\u1e79' // Latin_Extended_Additional + | '\u1e7b' // Latin_Extended_Additional + | '\u1e7d' // Latin_Extended_Additional + | '\u1e7f' // Latin_Extended_Additional + | '\u1e81' // Latin_Extended_Additional + | '\u1e83' // Latin_Extended_Additional + | '\u1e85' // Latin_Extended_Additional + | '\u1e87' // Latin_Extended_Additional + | '\u1e89' // Latin_Extended_Additional + | '\u1e8b' // Latin_Extended_Additional + | '\u1e8d' // Latin_Extended_Additional + | '\u1e8f' // Latin_Extended_Additional + | '\u1e91' // Latin_Extended_Additional + | '\u1e93' // Latin_Extended_Additional + | '\u1e95' ..'\u1e9d' // Latin_Extended_Additional + | '\u1e9f' // Latin_Extended_Additional + | '\u1ea1' // Latin_Extended_Additional + | '\u1ea3' // Latin_Extended_Additional + | '\u1ea5' // Latin_Extended_Additional + | '\u1ea7' // Latin_Extended_Additional + | '\u1ea9' // Latin_Extended_Additional + | '\u1eab' // Latin_Extended_Additional + | '\u1ead' // Latin_Extended_Additional + | '\u1eaf' // Latin_Extended_Additional + | '\u1eb1' // Latin_Extended_Additional + | '\u1eb3' // Latin_Extended_Additional + | '\u1eb5' // Latin_Extended_Additional + | '\u1eb7' // Latin_Extended_Additional + | '\u1eb9' // Latin_Extended_Additional + | '\u1ebb' // Latin_Extended_Additional + | '\u1ebd' // Latin_Extended_Additional + | '\u1ebf' // Latin_Extended_Additional + | '\u1ec1' // Latin_Extended_Additional + | '\u1ec3' // Latin_Extended_Additional + | '\u1ec5' // Latin_Extended_Additional + | '\u1ec7' // Latin_Extended_Additional + | '\u1ec9' // Latin_Extended_Additional + | '\u1ecb' // Latin_Extended_Additional + | '\u1ecd' // Latin_Extended_Additional + | '\u1ecf' // Latin_Extended_Additional + | '\u1ed1' // Latin_Extended_Additional + | '\u1ed3' // Latin_Extended_Additional + | '\u1ed5' // Latin_Extended_Additional + | '\u1ed7' // Latin_Extended_Additional + | '\u1ed9' // Latin_Extended_Additional + | '\u1edb' // Latin_Extended_Additional + | '\u1edd' // Latin_Extended_Additional + | '\u1edf' // Latin_Extended_Additional + | '\u1ee1' // Latin_Extended_Additional + | '\u1ee3' // Latin_Extended_Additional + | '\u1ee5' // Latin_Extended_Additional + | '\u1ee7' // Latin_Extended_Additional + | '\u1ee9' // Latin_Extended_Additional + | '\u1eeb' // Latin_Extended_Additional + | '\u1eed' // Latin_Extended_Additional + | '\u1eef' // Latin_Extended_Additional + | '\u1ef1' // Latin_Extended_Additional + | '\u1ef3' // Latin_Extended_Additional + | '\u1ef5' // Latin_Extended_Additional + | '\u1ef7' // Latin_Extended_Additional + | '\u1ef9' // Latin_Extended_Additional + | '\u1efb' // Latin_Extended_Additional + | '\u1efd' // Latin_Extended_Additional + | '\u1eff' ..'\u1f07' // (Absent from Blocks.txt) + | '\u1f10' ..'\u1f15' // Greek_Extended + | '\u1f20' ..'\u1f27' // Greek_Extended + | '\u1f30' ..'\u1f37' // Greek_Extended + | '\u1f40' ..'\u1f45' // Greek_Extended + | '\u1f50' ..'\u1f57' // Greek_Extended + | '\u1f60' ..'\u1f67' // Greek_Extended + | '\u1f70' ..'\u1f7d' // Greek_Extended + | '\u1f80' ..'\u1f87' // Greek_Extended + | '\u1f90' ..'\u1f97' // Greek_Extended + | '\u1fa0' ..'\u1fa7' // Greek_Extended + | '\u1fb0' ..'\u1fb4' // Greek_Extended + | '\u1fb6' ..'\u1fb7' // Greek_Extended + | '\u1fbe' // Greek_Extended + | '\u1fc2' ..'\u1fc4' // Greek_Extended + | '\u1fc6' ..'\u1fc7' // Greek_Extended + | '\u1fd0' ..'\u1fd3' // Greek_Extended + | '\u1fd6' ..'\u1fd7' // Greek_Extended + | '\u1fe0' ..'\u1fe7' // Greek_Extended + | '\u1ff2' ..'\u1ff4' // Greek_Extended + | '\u1ff6' ..'\u1ff7' // Greek_Extended + | '\u210a' // Letterlike_Symbols + | '\u210e' ..'\u210f' // Letterlike_Symbols + | '\u2113' // Letterlike_Symbols + | '\u212f' // Letterlike_Symbols + | '\u2134' // Letterlike_Symbols + | '\u2139' // Letterlike_Symbols + | '\u213c' ..'\u213d' // Letterlike_Symbols + | '\u2146' ..'\u2149' // Letterlike_Symbols + | '\u214e' // Letterlike_Symbols + | '\u2184' // Number_Forms + | '\u2c30' ..'\u2c5e' // Glagolitic + | '\u2c61' // Latin_Extended-C + | '\u2c65' ..'\u2c66' // Latin_Extended-C + | '\u2c68' // Latin_Extended-C + | '\u2c6a' // Latin_Extended-C + | '\u2c6c' // Latin_Extended-C + | '\u2c71' // Latin_Extended-C + | '\u2c73' ..'\u2c74' // Latin_Extended-C + | '\u2c76' ..'\u2c7b' // Latin_Extended-C + | '\u2c81' // Coptic + | '\u2c83' // Coptic + | '\u2c85' // Coptic + | '\u2c87' // Coptic + | '\u2c89' // Coptic + | '\u2c8b' // Coptic + | '\u2c8d' // Coptic + | '\u2c8f' // Coptic + | '\u2c91' // Coptic + | '\u2c93' // Coptic + | '\u2c95' // Coptic + | '\u2c97' // Coptic + | '\u2c99' // Coptic + | '\u2c9b' // Coptic + | '\u2c9d' // Coptic + | '\u2c9f' // Coptic + | '\u2ca1' // Coptic + | '\u2ca3' // Coptic + | '\u2ca5' // Coptic + | '\u2ca7' // Coptic + | '\u2ca9' // Coptic + | '\u2cab' // Coptic + | '\u2cad' // Coptic + | '\u2caf' // Coptic + | '\u2cb1' // Coptic + | '\u2cb3' // Coptic + | '\u2cb5' // Coptic + | '\u2cb7' // Coptic + | '\u2cb9' // Coptic + | '\u2cbb' // Coptic + | '\u2cbd' // Coptic + | '\u2cbf' // Coptic + | '\u2cc1' // Coptic + | '\u2cc3' // Coptic + | '\u2cc5' // Coptic + | '\u2cc7' // Coptic + | '\u2cc9' // Coptic + | '\u2ccb' // Coptic + | '\u2ccd' // Coptic + | '\u2ccf' // Coptic + | '\u2cd1' // Coptic + | '\u2cd3' // Coptic + | '\u2cd5' // Coptic + | '\u2cd7' // Coptic + | '\u2cd9' // Coptic + | '\u2cdb' // Coptic + | '\u2cdd' // Coptic + | '\u2cdf' // Coptic + | '\u2ce1' // Coptic + | '\u2ce3' ..'\u2ce4' // Coptic + | '\u2cec' // Coptic + | '\u2cee' // Coptic + | '\u2cf3' // Coptic + | '\u2d00' ..'\u2d25' // Georgian_Supplement + | '\u2d27' // Georgian_Supplement + | '\u2d2d' // Georgian_Supplement + | '\ua641' // Cyrillic_Extended-B + | '\ua643' // Cyrillic_Extended-B + | '\ua645' // Cyrillic_Extended-B + | '\ua647' // Cyrillic_Extended-B + | '\ua649' // Cyrillic_Extended-B + | '\ua64b' // Cyrillic_Extended-B + | '\ua64d' // Cyrillic_Extended-B + | '\ua64f' // Cyrillic_Extended-B + | '\ua651' // Cyrillic_Extended-B + | '\ua653' // Cyrillic_Extended-B + | '\ua655' // Cyrillic_Extended-B + | '\ua657' // Cyrillic_Extended-B + | '\ua659' // Cyrillic_Extended-B + | '\ua65b' // Cyrillic_Extended-B + | '\ua65d' // Cyrillic_Extended-B + | '\ua65f' // Cyrillic_Extended-B + | '\ua661' // Cyrillic_Extended-B + | '\ua663' // Cyrillic_Extended-B + | '\ua665' // Cyrillic_Extended-B + | '\ua667' // Cyrillic_Extended-B + | '\ua669' // Cyrillic_Extended-B + | '\ua66b' // Cyrillic_Extended-B + | '\ua66d' // Cyrillic_Extended-B + | '\ua681' // Cyrillic_Extended-B + | '\ua683' // Cyrillic_Extended-B + | '\ua685' // Cyrillic_Extended-B + | '\ua687' // Cyrillic_Extended-B + | '\ua689' // Cyrillic_Extended-B + | '\ua68b' // Cyrillic_Extended-B + | '\ua68d' // Cyrillic_Extended-B + | '\ua68f' // Cyrillic_Extended-B + | '\ua691' // Cyrillic_Extended-B + | '\ua693' // Cyrillic_Extended-B + | '\ua695' // Cyrillic_Extended-B + | '\ua697' // Cyrillic_Extended-B + | '\ua699' // Cyrillic_Extended-B + | '\ua69b' // Cyrillic_Extended-B + | '\ua723' // Latin_Extended-D + | '\ua725' // Latin_Extended-D + | '\ua727' // Latin_Extended-D + | '\ua729' // Latin_Extended-D + | '\ua72b' // Latin_Extended-D + | '\ua72d' // Latin_Extended-D + | '\ua72f' ..'\ua731' // Latin_Extended-D + | '\ua733' // Latin_Extended-D + | '\ua735' // Latin_Extended-D + | '\ua737' // Latin_Extended-D + | '\ua739' // Latin_Extended-D + | '\ua73b' // Latin_Extended-D + | '\ua73d' // Latin_Extended-D + | '\ua73f' // Latin_Extended-D + | '\ua741' // Latin_Extended-D + | '\ua743' // Latin_Extended-D + | '\ua745' // Latin_Extended-D + | '\ua747' // Latin_Extended-D + | '\ua749' // Latin_Extended-D + | '\ua74b' // Latin_Extended-D + | '\ua74d' // Latin_Extended-D + | '\ua74f' // Latin_Extended-D + | '\ua751' // Latin_Extended-D + | '\ua753' // Latin_Extended-D + | '\ua755' // Latin_Extended-D + | '\ua757' // Latin_Extended-D + | '\ua759' // Latin_Extended-D + | '\ua75b' // Latin_Extended-D + | '\ua75d' // Latin_Extended-D + | '\ua75f' // Latin_Extended-D + | '\ua761' // Latin_Extended-D + | '\ua763' // Latin_Extended-D + | '\ua765' // Latin_Extended-D + | '\ua767' // Latin_Extended-D + | '\ua769' // Latin_Extended-D + | '\ua76b' // Latin_Extended-D + | '\ua76d' // Latin_Extended-D + | '\ua76f' // Latin_Extended-D + | '\ua771' ..'\ua778' // Latin_Extended-D + | '\ua77a' // Latin_Extended-D + | '\ua77c' // Latin_Extended-D + | '\ua77f' // Latin_Extended-D + | '\ua781' // Latin_Extended-D + | '\ua783' // Latin_Extended-D + | '\ua785' // Latin_Extended-D + | '\ua787' // Latin_Extended-D + | '\ua78c' // Latin_Extended-D + | '\ua78e' // Latin_Extended-D + | '\ua791' // Latin_Extended-D + | '\ua793' ..'\ua795' // Latin_Extended-D + | '\ua797' // Latin_Extended-D + | '\ua799' // Latin_Extended-D + | '\ua79b' // Latin_Extended-D + | '\ua79d' // Latin_Extended-D + | '\ua79f' // Latin_Extended-D + | '\ua7a1' // Latin_Extended-D + | '\ua7a3' // Latin_Extended-D + | '\ua7a5' // Latin_Extended-D + | '\ua7a7' // Latin_Extended-D + | '\ua7a9' // Latin_Extended-D + | '\ua7b5' // Latin_Extended-D + | '\ua7b7' // Latin_Extended-D + | '\ua7fa' // Latin_Extended-D + | '\uab30' ..'\uab5a' // Latin_Extended-E + | '\uab60' ..'\uab65' // Latin_Extended-E + | '\uab70' ..'\uabbf' // Cherokee_Supplement + | '\ufb00' ..'\ufb06' // Alphabetic_Presentation_Forms + | '\ufb13' ..'\ufb17' // Alphabetic_Presentation_Forms + | '\uff41' ..'\uff5a' // Halfwidth_and_Fullwidth_Forms ; +fragment ASCSYMBOL: + '!' + | '#' + | '$' + | '%' + | '&' + | '*' + | '+' + | '.' + | '/' + | '<' + | '=' + | '>' + | '?' + | '@' + | '\\' + | '^' + | '|' + | '-' + | '~' + | ':' +; - -fragment ASCSYMBOL : '!' | '#' | '$' | '%' | '&' | '*' | '+' - | '.' | '/' | '<' | '=' | '>' | '?' | '@' - | '\\' | '^' | '|' | '-' | '~' | ':' ; - -fragment UNISYMBOL - : - CLASSIFY_Sc | CLASSIFY_Sk | CLASSIFY_Sm | CLASSIFY_So - ; +fragment UNISYMBOL: CLASSIFY_Sc | CLASSIFY_Sk | CLASSIFY_Sm | CLASSIFY_So; fragment CLASSIFY_Sc: - '\u0024' // Basic_Latin - | '\u00a2'..'\u00a5' // Latin-1_Supplement - | '\u058f' // (Absent from Blocks.txt) - | '\u060b' // Arabic - | '\u09f2'..'\u09f3' // Bengali - | '\u09fb' // Bengali - | '\u0af1' // Gujarati - | '\u0bf9' // Tamil - | '\u0e3f' // Thai - | '\u17db' // Khmer - | '\u20a0'..'\u20be' // Currency_Symbols - | '\ua838' // Common_Indic_Number_Forms - | '\ufdfc' // Arabic_Presentation_Forms-A - | '\ufe69' // Small_Form_Variants - | '\uff04' // Halfwidth_and_Fullwidth_Forms - | '\uffe0'..'\uffe1' // Halfwidth_and_Fullwidth_Forms - | '\uffe5'..'\uffe6' // Halfwidth_and_Fullwidth_Forms + '\u0024' // Basic_Latin + | '\u00a2' ..'\u00a5' // Latin-1_Supplement + | '\u058f' // (Absent from Blocks.txt) + | '\u060b' // Arabic + | '\u09f2' ..'\u09f3' // Bengali + | '\u09fb' // Bengali + | '\u0af1' // Gujarati + | '\u0bf9' // Tamil + | '\u0e3f' // Thai + | '\u17db' // Khmer + | '\u20a0' ..'\u20be' // Currency_Symbols + | '\ua838' // Common_Indic_Number_Forms + | '\ufdfc' // Arabic_Presentation_Forms-A + | '\ufe69' // Small_Form_Variants + | '\uff04' // Halfwidth_and_Fullwidth_Forms + | '\uffe0' ..'\uffe1' // Halfwidth_and_Fullwidth_Forms + | '\uffe5' ..'\uffe6' // Halfwidth_and_Fullwidth_Forms ; fragment CLASSIFY_Sk: - '\u005e' // Basic_Latin - | '\u0060' // Basic_Latin - | '\u00a8' // Latin-1_Supplement - | '\u00af' // Latin-1_Supplement - | '\u00b4' // Latin-1_Supplement - | '\u00b8' // Latin-1_Supplement - | '\u02c2'..'\u02c5' // Spacing_Modifier_Letters - | '\u02d2'..'\u02df' // Spacing_Modifier_Letters - | '\u02e5'..'\u02eb' // Spacing_Modifier_Letters - | '\u02ed' // Spacing_Modifier_Letters - | '\u02ef'..'\u02ff' // Spacing_Modifier_Letters - | '\u0375' // Greek_and_Coptic - | '\u0384'..'\u0385' // Greek_and_Coptic - | '\u1fbd' // Greek_Extended - | '\u1fbf'..'\u1fc1' // Greek_Extended - | '\u1fcd'..'\u1fcf' // Greek_Extended - | '\u1fdd'..'\u1fdf' // Greek_Extended - | '\u1fed'..'\u1fef' // Greek_Extended - | '\u1ffd'..'\u1ffe' // Greek_Extended - | '\u309b'..'\u309c' // Hiragana - | '\ua700'..'\ua716' // Modifier_Tone_Letters - | '\ua720'..'\ua721' // Latin_Extended-D - | '\ua789'..'\ua78a' // Latin_Extended-D - | '\uab5b' // Latin_Extended-E - | '\ufbb2'..'\ufbc1' // Arabic_Presentation_Forms-A - | '\uff3e' // Halfwidth_and_Fullwidth_Forms - | '\uff40' // Halfwidth_and_Fullwidth_Forms - | '\uffe3' // Halfwidth_and_Fullwidth_Forms + '\u005e' // Basic_Latin + | '\u0060' // Basic_Latin + | '\u00a8' // Latin-1_Supplement + | '\u00af' // Latin-1_Supplement + | '\u00b4' // Latin-1_Supplement + | '\u00b8' // Latin-1_Supplement + | '\u02c2' ..'\u02c5' // Spacing_Modifier_Letters + | '\u02d2' ..'\u02df' // Spacing_Modifier_Letters + | '\u02e5' ..'\u02eb' // Spacing_Modifier_Letters + | '\u02ed' // Spacing_Modifier_Letters + | '\u02ef' ..'\u02ff' // Spacing_Modifier_Letters + | '\u0375' // Greek_and_Coptic + | '\u0384' ..'\u0385' // Greek_and_Coptic + | '\u1fbd' // Greek_Extended + | '\u1fbf' ..'\u1fc1' // Greek_Extended + | '\u1fcd' ..'\u1fcf' // Greek_Extended + | '\u1fdd' ..'\u1fdf' // Greek_Extended + | '\u1fed' ..'\u1fef' // Greek_Extended + | '\u1ffd' ..'\u1ffe' // Greek_Extended + | '\u309b' ..'\u309c' // Hiragana + | '\ua700' ..'\ua716' // Modifier_Tone_Letters + | '\ua720' ..'\ua721' // Latin_Extended-D + | '\ua789' ..'\ua78a' // Latin_Extended-D + | '\uab5b' // Latin_Extended-E + | '\ufbb2' ..'\ufbc1' // Arabic_Presentation_Forms-A + | '\uff3e' // Halfwidth_and_Fullwidth_Forms + | '\uff40' // Halfwidth_and_Fullwidth_Forms + | '\uffe3' // Halfwidth_and_Fullwidth_Forms ; fragment CLASSIFY_Sm: - '\u002b' // Basic_Latin - | '\u003c'..'\u003e' // Basic_Latin - | '\u007c' // Basic_Latin - | '\u007e' // Basic_Latin - | '\u00ac' // Latin-1_Supplement - | '\u00b1' // Latin-1_Supplement - | '\u00d7' // Latin-1_Supplement - | '\u00f7' // Latin-1_Supplement - | '\u03f6' // Greek_and_Coptic - | '\u0606'..'\u0608' // Arabic - | '\u2044' // General_Punctuation - | '\u2052' // General_Punctuation - | '\u207a'..'\u207c' // Superscripts_and_Subscripts - | '\u208a'..'\u208c' // Superscripts_and_Subscripts - | '\u2118' // Letterlike_Symbols - | '\u2140'..'\u2144' // Letterlike_Symbols - | '\u214b' // Letterlike_Symbols - | '\u2190'..'\u2194' // Arrows - | '\u219a'..'\u219b' // Arrows - | '\u21a0' // Arrows - | '\u21a3' // Arrows - | '\u21a6' // Arrows - | '\u21ae' // Arrows - | '\u21ce'..'\u21cf' // Arrows - | '\u21d2' // Arrows - | '\u21d4' // Arrows - | '\u21f4'..'\u22ff' // Arrows - | '\u2320'..'\u2321' // Miscellaneous_Technical - | '\u237c' // Miscellaneous_Technical - | '\u239b'..'\u23b3' // Miscellaneous_Technical - | '\u23dc'..'\u23e1' // Miscellaneous_Technical - | '\u25b7' // Geometric_Shapes - | '\u25c1' // Geometric_Shapes - | '\u25f8'..'\u25ff' // Geometric_Shapes - | '\u266f' // Miscellaneous_Symbols - | '\u27c0'..'\u27c4' // Miscellaneous_Mathematical_Symbols-A - | '\u27c7'..'\u27e5' // Miscellaneous_Mathematical_Symbols-A - | '\u27f0'..'\u27ff' // Supplemental_Arrows-A - | '\u2900'..'\u2982' // Supplemental_Arrows-B - | '\u2999'..'\u29d7' // Miscellaneous_Mathematical_Symbols-B - | '\u29dc'..'\u29fb' // Miscellaneous_Mathematical_Symbols-B - | '\u29fe'..'\u2aff' // Miscellaneous_Mathematical_Symbols-B - | '\u2b30'..'\u2b44' // Miscellaneous_Symbols_and_Arrows - | '\u2b47'..'\u2b4c' // Miscellaneous_Symbols_and_Arrows - | '\ufb29' // Alphabetic_Presentation_Forms - | '\ufe62' // Small_Form_Variants - | '\ufe64'..'\ufe66' // Small_Form_Variants - | '\uff0b' // Halfwidth_and_Fullwidth_Forms - | '\uff1c'..'\uff1e' // Halfwidth_and_Fullwidth_Forms - | '\uff5c' // Halfwidth_and_Fullwidth_Forms - | '\uff5e' // Halfwidth_and_Fullwidth_Forms - | '\uffe2' // Halfwidth_and_Fullwidth_Forms - | '\uffe9'..'\uffec' // Halfwidth_and_Fullwidth_Forms + '\u002b' // Basic_Latin + | '\u003c' ..'\u003e' // Basic_Latin + | '\u007c' // Basic_Latin + | '\u007e' // Basic_Latin + | '\u00ac' // Latin-1_Supplement + | '\u00b1' // Latin-1_Supplement + | '\u00d7' // Latin-1_Supplement + | '\u00f7' // Latin-1_Supplement + | '\u03f6' // Greek_and_Coptic + | '\u0606' ..'\u0608' // Arabic + | '\u2044' // General_Punctuation + | '\u2052' // General_Punctuation + | '\u207a' ..'\u207c' // Superscripts_and_Subscripts + | '\u208a' ..'\u208c' // Superscripts_and_Subscripts + | '\u2118' // Letterlike_Symbols + | '\u2140' ..'\u2144' // Letterlike_Symbols + | '\u214b' // Letterlike_Symbols + | '\u2190' ..'\u2194' // Arrows + | '\u219a' ..'\u219b' // Arrows + | '\u21a0' // Arrows + | '\u21a3' // Arrows + | '\u21a6' // Arrows + | '\u21ae' // Arrows + | '\u21ce' ..'\u21cf' // Arrows + | '\u21d2' // Arrows + | '\u21d4' // Arrows + | '\u21f4' ..'\u22ff' // Arrows + | '\u2320' ..'\u2321' // Miscellaneous_Technical + | '\u237c' // Miscellaneous_Technical + | '\u239b' ..'\u23b3' // Miscellaneous_Technical + | '\u23dc' ..'\u23e1' // Miscellaneous_Technical + | '\u25b7' // Geometric_Shapes + | '\u25c1' // Geometric_Shapes + | '\u25f8' ..'\u25ff' // Geometric_Shapes + | '\u266f' // Miscellaneous_Symbols + | '\u27c0' ..'\u27c4' // Miscellaneous_Mathematical_Symbols-A + | '\u27c7' ..'\u27e5' // Miscellaneous_Mathematical_Symbols-A + | '\u27f0' ..'\u27ff' // Supplemental_Arrows-A + | '\u2900' ..'\u2982' // Supplemental_Arrows-B + | '\u2999' ..'\u29d7' // Miscellaneous_Mathematical_Symbols-B + | '\u29dc' ..'\u29fb' // Miscellaneous_Mathematical_Symbols-B + | '\u29fe' ..'\u2aff' // Miscellaneous_Mathematical_Symbols-B + | '\u2b30' ..'\u2b44' // Miscellaneous_Symbols_and_Arrows + | '\u2b47' ..'\u2b4c' // Miscellaneous_Symbols_and_Arrows + | '\ufb29' // Alphabetic_Presentation_Forms + | '\ufe62' // Small_Form_Variants + | '\ufe64' ..'\ufe66' // Small_Form_Variants + | '\uff0b' // Halfwidth_and_Fullwidth_Forms + | '\uff1c' ..'\uff1e' // Halfwidth_and_Fullwidth_Forms + | '\uff5c' // Halfwidth_and_Fullwidth_Forms + | '\uff5e' // Halfwidth_and_Fullwidth_Forms + | '\uffe2' // Halfwidth_and_Fullwidth_Forms + | '\uffe9' ..'\uffec' // Halfwidth_and_Fullwidth_Forms ; fragment CLASSIFY_So: - '\u00a6' // Latin-1_Supplement - | '\u00a9' // Latin-1_Supplement - | '\u00ae' // Latin-1_Supplement - | '\u00b0' // Latin-1_Supplement - | '\u0482' // Cyrillic - | '\u058d'..'\u058e' // Armenian - | '\u060e'..'\u060f' // Arabic - | '\u06de' // Arabic - | '\u06e9' // Arabic - | '\u06fd'..'\u06fe' // Arabic - | '\u07f6' // NKo - | '\u09fa' // Bengali - | '\u0b70' // Oriya - | '\u0bf3'..'\u0bf8' // Tamil - | '\u0bfa' // Tamil - | '\u0c7f' // (Absent from Blocks.txt) - | '\u0d4f' // Malayalam - | '\u0d79' // Malayalam - | '\u0f01'..'\u0f03' // Tibetan - | '\u0f13' // Tibetan - | '\u0f15'..'\u0f17' // Tibetan - | '\u0f1a'..'\u0f1f' // Tibetan - | '\u0f34' // Tibetan - | '\u0f36' // Tibetan - | '\u0f38' // Tibetan - | '\u0fbe'..'\u0fc5' // Tibetan - | '\u0fc7'..'\u0fcc' // Tibetan - | '\u0fce'..'\u0fcf' // Tibetan - | '\u0fd5'..'\u0fd8' // Tibetan - | '\u109e'..'\u109f' // Myanmar - | '\u1390'..'\u1399' // Ethiopic_Supplement - | '\u1940' // Limbu - | '\u19de'..'\u19ff' // New_Tai_Lue - | '\u1b61'..'\u1b6a' // Balinese - | '\u1b74'..'\u1b7c' // Balinese - | '\u2100'..'\u2101' // Letterlike_Symbols - | '\u2103'..'\u2106' // Letterlike_Symbols - | '\u2108'..'\u2109' // Letterlike_Symbols - | '\u2114' // Letterlike_Symbols - | '\u2116'..'\u2117' // Letterlike_Symbols - | '\u211e'..'\u2123' // Letterlike_Symbols - | '\u2125' // Letterlike_Symbols - | '\u2127' // Letterlike_Symbols - | '\u2129' // Letterlike_Symbols - | '\u212e' // Letterlike_Symbols - | '\u213a'..'\u213b' // Letterlike_Symbols - | '\u214a' // Letterlike_Symbols - | '\u214c'..'\u214d' // Letterlike_Symbols - | '\u214f' // (Absent from Blocks.txt) - | '\u218a'..'\u218b' // Number_Forms - | '\u2195'..'\u2199' // Arrows - | '\u219c'..'\u219f' // Arrows - | '\u21a1'..'\u21a2' // Arrows - | '\u21a4'..'\u21a5' // Arrows - | '\u21a7'..'\u21ad' // Arrows - | '\u21af'..'\u21cd' // Arrows - | '\u21d0'..'\u21d1' // Arrows - | '\u21d3' // Arrows - | '\u21d5'..'\u21f3' // Arrows - | '\u2300'..'\u2307' // Miscellaneous_Technical - | '\u230c'..'\u231f' // Miscellaneous_Technical - | '\u2322'..'\u2328' // Miscellaneous_Technical - | '\u232b'..'\u237b' // Miscellaneous_Technical - | '\u237d'..'\u239a' // Miscellaneous_Technical - | '\u23b4'..'\u23db' // Miscellaneous_Technical - | '\u23e2'..'\u23fe' // Miscellaneous_Technical - | '\u2400'..'\u2426' // Control_Pictures - | '\u2440'..'\u244a' // Optical_Character_Recognition - | '\u249c'..'\u24e9' // Enclosed_Alphanumerics - | '\u2500'..'\u25b6' // Box_Drawing - | '\u25b8'..'\u25c0' // Geometric_Shapes - | '\u25c2'..'\u25f7' // Geometric_Shapes - | '\u2600'..'\u266e' // Miscellaneous_Symbols - | '\u2670'..'\u2767' // Miscellaneous_Symbols - | '\u2794'..'\u27bf' // Dingbats - | '\u2800'..'\u28ff' // Braille_Patterns - | '\u2b00'..'\u2b2f' // Miscellaneous_Symbols_and_Arrows - | '\u2b45'..'\u2b46' // Miscellaneous_Symbols_and_Arrows - | '\u2b4d'..'\u2b73' // Miscellaneous_Symbols_and_Arrows - | '\u2b76'..'\u2b95' // Miscellaneous_Symbols_and_Arrows - | '\u2b98'..'\u2bb9' // Miscellaneous_Symbols_and_Arrows - | '\u2bbd'..'\u2bc8' // Miscellaneous_Symbols_and_Arrows - | '\u2bca'..'\u2bd1' // Miscellaneous_Symbols_and_Arrows - | '\u2bec'..'\u2bef' // Miscellaneous_Symbols_and_Arrows - | '\u2ce5'..'\u2cea' // Coptic - | '\u2e80'..'\u2e99' // CJK_Radicals_Supplement - | '\u2e9b'..'\u2ef3' // CJK_Radicals_Supplement - | '\u2f00'..'\u2fd5' // Kangxi_Radicals - | '\u2ff0'..'\u2ffb' // Ideographic_Description_Characters - | '\u3004' // CJK_Symbols_and_Punctuation - | '\u3012'..'\u3013' // CJK_Symbols_and_Punctuation - | '\u3020' // CJK_Symbols_and_Punctuation - | '\u3036'..'\u3037' // CJK_Symbols_and_Punctuation - | '\u303e'..'\u303f' // CJK_Symbols_and_Punctuation - | '\u3190'..'\u3191' // Kanbun - | '\u3196'..'\u319f' // Kanbun - | '\u31c0'..'\u31e3' // CJK_Strokes - | '\u3200'..'\u321e' // Enclosed_CJK_Letters_and_Months - | '\u322a'..'\u3247' // Enclosed_CJK_Letters_and_Months - | '\u3250' // Enclosed_CJK_Letters_and_Months - | '\u3260'..'\u327f' // Enclosed_CJK_Letters_and_Months - | '\u328a'..'\u32b0' // Enclosed_CJK_Letters_and_Months - | '\u32c0'..'\u32fe' // Enclosed_CJK_Letters_and_Months - | '\u3300'..'\u33ff' // CJK_Compatibility - | '\u4dc0'..'\u4dff' // Yijing_Hexagram_Symbols - | '\ua490'..'\ua4c6' // Yi_Radicals - | '\ua828'..'\ua82b' // Syloti_Nagri - | '\ua836'..'\ua837' // Common_Indic_Number_Forms - | '\ua839' // Common_Indic_Number_Forms - | '\uaa77'..'\uaa79' // Myanmar_Extended-A - | '\ufdfd' // Arabic_Presentation_Forms-A - | '\uffe4' // Halfwidth_and_Fullwidth_Forms - | '\uffe8' // Halfwidth_and_Fullwidth_Forms - | '\uffed'..'\uffee' // Halfwidth_and_Fullwidth_Forms - | '\ufffc'..'\ufffd' // Specials -; + '\u00a6' // Latin-1_Supplement + | '\u00a9' // Latin-1_Supplement + | '\u00ae' // Latin-1_Supplement + | '\u00b0' // Latin-1_Supplement + | '\u0482' // Cyrillic + | '\u058d' ..'\u058e' // Armenian + | '\u060e' ..'\u060f' // Arabic + | '\u06de' // Arabic + | '\u06e9' // Arabic + | '\u06fd' ..'\u06fe' // Arabic + | '\u07f6' // NKo + | '\u09fa' // Bengali + | '\u0b70' // Oriya + | '\u0bf3' ..'\u0bf8' // Tamil + | '\u0bfa' // Tamil + | '\u0c7f' // (Absent from Blocks.txt) + | '\u0d4f' // Malayalam + | '\u0d79' // Malayalam + | '\u0f01' ..'\u0f03' // Tibetan + | '\u0f13' // Tibetan + | '\u0f15' ..'\u0f17' // Tibetan + | '\u0f1a' ..'\u0f1f' // Tibetan + | '\u0f34' // Tibetan + | '\u0f36' // Tibetan + | '\u0f38' // Tibetan + | '\u0fbe' ..'\u0fc5' // Tibetan + | '\u0fc7' ..'\u0fcc' // Tibetan + | '\u0fce' ..'\u0fcf' // Tibetan + | '\u0fd5' ..'\u0fd8' // Tibetan + | '\u109e' ..'\u109f' // Myanmar + | '\u1390' ..'\u1399' // Ethiopic_Supplement + | '\u1940' // Limbu + | '\u19de' ..'\u19ff' // New_Tai_Lue + | '\u1b61' ..'\u1b6a' // Balinese + | '\u1b74' ..'\u1b7c' // Balinese + | '\u2100' ..'\u2101' // Letterlike_Symbols + | '\u2103' ..'\u2106' // Letterlike_Symbols + | '\u2108' ..'\u2109' // Letterlike_Symbols + | '\u2114' // Letterlike_Symbols + | '\u2116' ..'\u2117' // Letterlike_Symbols + | '\u211e' ..'\u2123' // Letterlike_Symbols + | '\u2125' // Letterlike_Symbols + | '\u2127' // Letterlike_Symbols + | '\u2129' // Letterlike_Symbols + | '\u212e' // Letterlike_Symbols + | '\u213a' ..'\u213b' // Letterlike_Symbols + | '\u214a' // Letterlike_Symbols + | '\u214c' ..'\u214d' // Letterlike_Symbols + | '\u214f' // (Absent from Blocks.txt) + | '\u218a' ..'\u218b' // Number_Forms + | '\u2195' ..'\u2199' // Arrows + | '\u219c' ..'\u219f' // Arrows + | '\u21a1' ..'\u21a2' // Arrows + | '\u21a4' ..'\u21a5' // Arrows + | '\u21a7' ..'\u21ad' // Arrows + | '\u21af' ..'\u21cd' // Arrows + | '\u21d0' ..'\u21d1' // Arrows + | '\u21d3' // Arrows + | '\u21d5' ..'\u21f3' // Arrows + | '\u2300' ..'\u2307' // Miscellaneous_Technical + | '\u230c' ..'\u231f' // Miscellaneous_Technical + | '\u2322' ..'\u2328' // Miscellaneous_Technical + | '\u232b' ..'\u237b' // Miscellaneous_Technical + | '\u237d' ..'\u239a' // Miscellaneous_Technical + | '\u23b4' ..'\u23db' // Miscellaneous_Technical + | '\u23e2' ..'\u23fe' // Miscellaneous_Technical + | '\u2400' ..'\u2426' // Control_Pictures + | '\u2440' ..'\u244a' // Optical_Character_Recognition + | '\u249c' ..'\u24e9' // Enclosed_Alphanumerics + | '\u2500' ..'\u25b6' // Box_Drawing + | '\u25b8' ..'\u25c0' // Geometric_Shapes + | '\u25c2' ..'\u25f7' // Geometric_Shapes + | '\u2600' ..'\u266e' // Miscellaneous_Symbols + | '\u2670' ..'\u2767' // Miscellaneous_Symbols + | '\u2794' ..'\u27bf' // Dingbats + | '\u2800' ..'\u28ff' // Braille_Patterns + | '\u2b00' ..'\u2b2f' // Miscellaneous_Symbols_and_Arrows + | '\u2b45' ..'\u2b46' // Miscellaneous_Symbols_and_Arrows + | '\u2b4d' ..'\u2b73' // Miscellaneous_Symbols_and_Arrows + | '\u2b76' ..'\u2b95' // Miscellaneous_Symbols_and_Arrows + | '\u2b98' ..'\u2bb9' // Miscellaneous_Symbols_and_Arrows + | '\u2bbd' ..'\u2bc8' // Miscellaneous_Symbols_and_Arrows + | '\u2bca' ..'\u2bd1' // Miscellaneous_Symbols_and_Arrows + | '\u2bec' ..'\u2bef' // Miscellaneous_Symbols_and_Arrows + | '\u2ce5' ..'\u2cea' // Coptic + | '\u2e80' ..'\u2e99' // CJK_Radicals_Supplement + | '\u2e9b' ..'\u2ef3' // CJK_Radicals_Supplement + | '\u2f00' ..'\u2fd5' // Kangxi_Radicals + | '\u2ff0' ..'\u2ffb' // Ideographic_Description_Characters + | '\u3004' // CJK_Symbols_and_Punctuation + | '\u3012' ..'\u3013' // CJK_Symbols_and_Punctuation + | '\u3020' // CJK_Symbols_and_Punctuation + | '\u3036' ..'\u3037' // CJK_Symbols_and_Punctuation + | '\u303e' ..'\u303f' // CJK_Symbols_and_Punctuation + | '\u3190' ..'\u3191' // Kanbun + | '\u3196' ..'\u319f' // Kanbun + | '\u31c0' ..'\u31e3' // CJK_Strokes + | '\u3200' ..'\u321e' // Enclosed_CJK_Letters_and_Months + | '\u322a' ..'\u3247' // Enclosed_CJK_Letters_and_Months + | '\u3250' // Enclosed_CJK_Letters_and_Months + | '\u3260' ..'\u327f' // Enclosed_CJK_Letters_and_Months + | '\u328a' ..'\u32b0' // Enclosed_CJK_Letters_and_Months + | '\u32c0' ..'\u32fe' // Enclosed_CJK_Letters_and_Months + | '\u3300' ..'\u33ff' // CJK_Compatibility + | '\u4dc0' ..'\u4dff' // Yijing_Hexagram_Symbols + | '\ua490' ..'\ua4c6' // Yi_Radicals + | '\ua828' ..'\ua82b' // Syloti_Nagri + | '\ua836' ..'\ua837' // Common_Indic_Number_Forms + | '\ua839' // Common_Indic_Number_Forms + | '\uaa77' ..'\uaa79' // Myanmar_Extended-A + | '\ufdfd' // Arabic_Presentation_Forms-A + | '\uffe4' // Halfwidth_and_Fullwidth_Forms + | '\uffe8' // Halfwidth_and_Fullwidth_Forms + | '\uffed' ..'\uffee' // Halfwidth_and_Fullwidth_Forms + | '\ufffc' ..'\ufffd' // Specials +; \ No newline at end of file diff --git a/haskell/HaskellParser.g4 b/haskell/HaskellParser.g4 index b1ce5b3aba..390c815edd 100644 --- a/haskell/HaskellParser.g4 +++ b/haskell/HaskellParser.g4 @@ -26,128 +26,126 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 HaskellParser; -options { tokenVocab=HaskellLexer; } +options { + tokenVocab = HaskellLexer; +} -module : OCURLY? semi* pragmas? semi* (module_content | body) CCURLY? semi? EOF; +module + : OCURLY? semi* pragmas? semi* (module_content | body) CCURLY? semi? EOF + ; module_content - : - 'module' modid exports? where_module + : 'module' modid exports? where_module ; where_module - : - 'where' module_body + : 'where' module_body ; module_body - : - open_ body close semi* + : open_ body close semi* ; pragmas - : - pragma+ + : pragma+ ; pragma - : - language_pragma + : language_pragma | options_ghc | simple_options ; language_pragma - : - '{-#' 'LANGUAGE' extension_ (',' extension_)* '#-}' semi? + : '{-#' 'LANGUAGE' extension_ (',' extension_)* '#-}' semi? ; options_ghc - : - '{-#' 'OPTIONS_GHC' ('-' (varid | conid))* '#-}' semi? + : '{-#' 'OPTIONS_GHC' ('-' (varid | conid))* '#-}' semi? ; simple_options - : - '{-#' 'OPTIONS' ('-' (varid | conid))* '#-}' semi? + : '{-#' 'OPTIONS' ('-' (varid | conid))* '#-}' semi? ; extension_ - : - CONID + : CONID ; body - : - (impdecls topdecls) + : (impdecls topdecls) | impdecls | topdecls ; impdecls - : - (impdecl | NEWLINE | semi)+ + : (impdecl | NEWLINE | semi)+ ; exports - : - '(' (exprt (',' exprt)*)? ','? ')' + : '(' (exprt (',' exprt)*)? ','? ')' ; exprt - : - qvar - | ( qtycon ( ('(' '..' ')') | ('(' (cname (',' cname)*)? ')') )? ) - | ( qtycls ( ('(' '..' ')') | ('(' (qvar (',' qvar)*)? ')') )? ) - | ( 'module' modid ) + : qvar + | ( qtycon ( ('(' '..' ')') | ('(' (cname (',' cname)*)? ')'))?) + | ( qtycls ( ('(' '..' ')') | ('(' (qvar (',' qvar)*)? ')'))?) + | ( 'module' modid) ; impdecl - : - 'import' 'qualified'? modid ('as' modid)? impspec? semi+ + : 'import' 'qualified'? modid ('as' modid)? impspec? semi+ ; impspec - : - ('(' (himport (',' himport)* ','?)? ')') - | ( 'hiding' '(' (himport (',' himport)* ','?)? ')' ) + : ('(' (himport (',' himport)* ','?)? ')') + | ( 'hiding' '(' (himport (',' himport)* ','?)? ')') ; himport - : - var_ - | ( tycon ( ('(' '..' ')') | ('(' (cname (',' cname)*)? ')') )? ) - | ( tycls ( ('(' '..' ')') | ('(' sig_vars? ')') )? ) + : var_ + | ( tycon ( ('(' '..' ')') | ('(' (cname (',' cname)*)? ')'))?) + | ( tycls ( ('(' '..' ')') | ('(' sig_vars? ')'))?) ; cname - : - var_ | con + : var_ + | con ; // ------------------------------------------- // Fixity Declarations -fixity: 'infix' | 'infixl' | 'infixr'; +fixity + : 'infix' + | 'infixl' + | 'infixr' + ; -ops : op (',' op)*; +ops + : op (',' op)* + ; // ------------------------------------------- // Top-Level Declarations -topdecls : (topdecl semi+| NEWLINE | semi)+; +topdecls + : (topdecl semi+ | NEWLINE | semi)+ + ; topdecl - : - cl_decl + : cl_decl | ty_decl // Check KindSignatures | standalone_kind_sig | inst_decl | standalone_deriving | role_annot - | ('default' '(' comma_types? ')' ) + | ('default' '(' comma_types? ')') | ('foreign' fdecl) | ('{-#' 'DEPRECATED' deprecations? '#-}') | ('{-#' 'WARNING' warnings? '#-}') @@ -164,8 +162,7 @@ topdecl // Type classes // cl_decl - : - 'class' tycl_hdr fds? where_cls? + : 'class' tycl_hdr fds? where_cls? ; // Type declarations (toplevel) @@ -189,19 +186,16 @@ ty_decl // standalone kind signature standalone_kind_sig - : - 'type' sks_vars '::' ktypedoc + : 'type' sks_vars '::' ktypedoc ; // See also: sig_vars sks_vars - : - oqtycon (',' oqtycon)* + : oqtycon (',' oqtycon)* ; inst_decl - : - ('instance' overlap_pragma? inst_type where_inst?) + : ('instance' overlap_pragma? inst_type where_inst?) | ('type' 'instance' ty_fam_inst_eqn) // 'constrs' in the end of this rules in GHC // This parser no use docs @@ -213,29 +207,24 @@ inst_decl ; overlap_pragma - : - '{-#' 'OVERLAPPABLE' '#-}' + : '{-#' 'OVERLAPPABLE' '#-}' | '{-#' 'OVERLAPPING' '#-}' | '{-#' 'OVERLAPS' '#-}' | '{-#' 'INCOHERENT' '#-}' ; - deriv_strategy_no_via - : - 'stock' + : 'stock' | 'anyclass' | 'newtype' ; deriv_strategy_via - : - 'via' ktype + : 'via' ktype ; deriv_standalone_strategy - : - 'stock' + : 'stock' | 'anyclass' | 'newtype' | deriv_strategy_via @@ -244,8 +233,7 @@ deriv_standalone_strategy // Injective type families opt_injective_info - : - '|' injectivity_cond + : '|' injectivity_cond ; injectivity_cond @@ -255,32 +243,27 @@ injectivity_cond ; inj_varids - : - tyvarid+ + : tyvarid+ ; // Closed type families where_type_family - : - 'where' ty_fam_inst_eqn_list + : 'where' ty_fam_inst_eqn_list ; ty_fam_inst_eqn_list - : - (open_ ty_fam_inst_eqns? close) + : (open_ ty_fam_inst_eqns? close) | ('{' '..' '}') | (open_ '..' close) ; ty_fam_inst_eqns - : - ty_fam_inst_eqn (semi+ ty_fam_inst_eqn)* semi* + : ty_fam_inst_eqn (semi+ ty_fam_inst_eqn)* semi* ; ty_fam_inst_eqn - : - 'forall' tv_bndrs? '.' type_ '=' ktype + : 'forall' tv_bndrs? '.' type_ '=' ktype | type_ '=' ktype ; @@ -294,8 +277,7 @@ ty_fam_inst_eqn // data declarations. at_decl_cls - : - ('data' 'family'? type_ opt_datafam_kind_sig?) + : ('data' 'family'? type_ opt_datafam_kind_sig?) | ('type' 'family'? type_ opt_at_kind_inj_sig?) | ('type' 'instance'? ty_fam_inst_eqn) ; @@ -317,44 +299,37 @@ at_decl_inst // Family result/return kind signatures opt_kind_sig - : - '::' kind + : '::' kind ; opt_datafam_kind_sig - : - '::' kind + : '::' kind ; opt_tyfam_kind_sig - : - ('::' kind) + : ('::' kind) | ('=' tv_bndr) ; opt_at_kind_inj_sig - : - ('::' kind) + : ('::' kind) | ('=' tv_bndr_no_braces '|' injectivity_cond) ; tycl_hdr - : - (tycl_context '=>' type_) + : (tycl_context '=>' type_) | type_ ; tycl_hdr_inst - : - ('forall' tv_bndrs? '.' tycl_context '=>' type_) + : ('forall' tv_bndrs? '.' tycl_context '=>' type_) | ('forall' tv_bndrs? '.' type_) | (tycl_context '=>' type_) | type_ ; capi_ctype - : - ('{-#' 'CTYPE' STRING STRING '#-}') + : ('{-#' 'CTYPE' STRING STRING '#-}') | ('{-#' 'CTYPE' STRING '#-}') ; @@ -362,62 +337,52 @@ capi_ctype // Stand-alone deriving standalone_deriving - : - 'deriving' deriv_standalone_strategy? 'instance' overlap_pragma? inst_type + : 'deriving' deriv_standalone_strategy? 'instance' overlap_pragma? inst_type ; // ------------------------------------------- // Role annotations role_annot - : - 'type' 'role' oqtycon roles? + : 'type' 'role' oqtycon roles? ; roles - : - role+ + : role+ ; role - : - varid | '_' + : varid + | '_' ; - // ------------------------------------------- // Pattern synonyms pattern_synonym_decl - : - ('pattern' pattern_synonym_lhs '=' pat) + : ('pattern' pattern_synonym_lhs '=' pat) | ('pattern' pattern_synonym_lhs '<-' pat where_decls?) ; pattern_synonym_lhs - : - (con vars_?) + : (con vars_?) | (varid conop varid) | (con '{' cvars '}') ; vars_ - : - varid+ + : varid+ ; cvars - : - var_ (',' var_)* + : var_ (',' var_)* ; where_decls - : - 'where' open_ decls? close + : 'where' open_ decls? close ; pattern_synonym_sig - : - 'pattern' con_list '::' sigtypedoc + : 'pattern' con_list '::' sigtypedoc ; // ------------------------------------------- @@ -426,118 +391,99 @@ pattern_synonym_sig // Declaration in class bodies decl_cls - : - at_decl_cls + : at_decl_cls | decl | 'default' infixexp '::' sigtypedoc ; decls_cls - : - decl_cls (semi+ decl_cls)* semi* + : decl_cls (semi+ decl_cls)* semi* ; decllist_cls - : - open_ decls_cls? close + : open_ decls_cls? close ; // Class body // where_cls - : - 'where' decllist_cls + : 'where' decllist_cls ; // Declarations in instance bodies // decl_inst - : - at_decl_inst + : at_decl_inst | decl ; decls_inst - : - decl_inst (semi+ decl_inst)* semi* + : decl_inst (semi+ decl_inst)* semi* ; decllist_inst - : - open_ decls_inst? close + : open_ decls_inst? close ; // Instance body // where_inst - : - 'where' decllist_inst + : 'where' decllist_inst ; // Declarations in binding groups other than classes and instances // decls - : - decl (semi+ decl)* semi* + : decl (semi+ decl)* semi* ; decllist - : - open_ decls? close + : open_ decls? close ; // Binding groups other than those of class and instance declarations // binds - : - decllist + : decllist | (open_ dbinds? close) ; wherebinds - : - 'where' binds + : 'where' binds ; - // ------------------------------------------- // Transformation Rules rules - : - pragma_rule (semi pragma_rule)* semi? + : pragma_rule (semi pragma_rule)* semi? ; pragma_rule - : - pstring rule_activation? rule_foralls? infixexp '=' exp + : pstring rule_activation? rule_foralls? infixexp '=' exp ; rule_activation_marker - : - '~' | varsym + : '~' + | varsym ; rule_activation - : - ('[' integer ']') + : ('[' integer ']') | ('[' rule_activation_marker integer ']') | ('[' rule_activation_marker ']') ; rule_foralls - : - ('forall' rule_vars? '.' ('forall' rule_vars? '.')?) + : ('forall' rule_vars? '.' ('forall' rule_vars? '.')?) ; rule_vars - : - rule_var+ + : rule_var+ ; rule_var - : - varid + : varid | ('(' varid '::' ctype ')') ; @@ -545,42 +491,35 @@ rule_var // Warnings and deprecations (c.f. rules) warnings - : - pragma_warning (semi pragma_warning)* semi? + : pragma_warning (semi pragma_warning)* semi? ; pragma_warning - : - namelist strings + : namelist strings ; deprecations - : - pragma_deprecation (semi pragma_deprecation)* semi? + : pragma_deprecation (semi pragma_deprecation)* semi? ; pragma_deprecation - : - namelist strings + : namelist strings ; strings - : - pstring + : pstring | ('[' stringlist? ']') ; stringlist - : - pstring (',' pstring)* + : pstring (',' pstring)* ; // ------------------------------------------- // Annotations annotation - : - ('{-#' 'ANN' name_var aexp '#-}') + : ('{-#' 'ANN' name_var aexp '#-}') | ('{-#' 'ANN' tycon aexp '#-}') | ('{-#' 'ANN' 'module' aexp '#-}') ; @@ -589,82 +528,81 @@ annotation // Foreign import and export declarations fdecl - : - ('import' callconv safety? fspec) + : ('import' callconv safety? fspec) | ('export' callconv fspec) ; callconv - : - 'ccall' | 'stdcall' | 'cplusplus' | 'javascript' + : 'ccall' + | 'stdcall' + | 'cplusplus' + | 'javascript' ; -safety : 'unsafe' | 'safe' | 'interruptible'; +safety + : 'unsafe' + | 'safe' + | 'interruptible' + ; fspec - : - pstring? var_ '::' sigtypedoc + : pstring? var_ '::' sigtypedoc ; // ------------------------------------------- // Type signatures -opt_sig : '::' sigtype; +opt_sig + : '::' sigtype + ; -opt_tyconsig : '::' gtycon; +opt_tyconsig + : '::' gtycon + ; sigtype - : - ctype + : ctype ; sigtypedoc - : - ctypedoc + : ctypedoc ; sig_vars - : - var_ (',' var_)* + : var_ (',' var_)* ; sigtypes1 - : - sigtype (',' sigtype)* + : sigtype (',' sigtype)* ; // ------------------------------------------- // Types unpackedness - : - ('{-#' 'UNPACK' '#-}') + : ('{-#' 'UNPACK' '#-}') | ('{-#' 'NOUNPACK' '#-}') ; forall_vis_flag - : - '.' + : '.' | '->' ; // A ktype/ktypedoc is a ctype/ctypedoc, possibly with a kind annotation ktype - : - ctype + : ctype | (ctype '::' kind) ; ktypedoc - : - ctypedoc + : ctypedoc | ctypedoc '::' kind ; // A ctype is a for-all type ctype - : - 'forall' tv_bndrs? forall_vis_flag ctype + : 'forall' tv_bndrs? forall_vis_flag ctype | btype '=>' ctype | var_ '::' type_ // not sure about this rule | type_ @@ -681,10 +619,8 @@ ctype // -- If we allow comments on types here, it's not clear if the comment applies // -- to 'field' or to 'Int'. So we must use `ctype` to describe the type. - ctypedoc - : - 'forall' tv_bndrs? forall_vis_flag ctypedoc + : 'forall' tv_bndrs? forall_vis_flag ctypedoc | tycl_context '=>' ctypedoc | var_ '::' type_ | typedoc @@ -692,8 +628,7 @@ ctypedoc // In GHC this rule is context tycl_context - : - btype + : btype ; // constr_context rule @@ -716,8 +651,7 @@ tycl_context // -} constr_context - : - constr_btype + : constr_btype ; // {- Note [GADT decl discards annotations] @@ -738,45 +672,37 @@ constr_context // -} type_ - : - btype + : btype | btype '->' ctype ; typedoc - : - btype + : btype | btype '->' ctypedoc ; constr_btype - : - constr_tyapps + : constr_tyapps ; constr_tyapps - : - constr_tyapp+ + : constr_tyapp+ ; constr_tyapp - : - tyapp + : tyapp ; btype - : - tyapps + : tyapps ; tyapps - : - tyapp+ + : tyapp+ ; tyapp - : - atype + : atype | ('@' atype) | qtyconop | tyvarop @@ -786,8 +712,7 @@ tyapp ; atype - : - ntgtycon + : ntgtycon | tyvar | '*' | ('~' atype) @@ -817,70 +742,57 @@ atype ; inst_type - : - sigtype + : sigtype ; deriv_types - : - ktypedoc (',' ktypedoc)* + : ktypedoc (',' ktypedoc)* ; comma_types - : - ktype (',' ktype)* + : ktype (',' ktype)* ; bar_types2 - : - ktype '|' ktype ('|' ktype)* + : ktype '|' ktype ('|' ktype)* ; tv_bndrs - : - tv_bndr+ + : tv_bndr+ ; tv_bndr - : - tv_bndr_no_braces + : tv_bndr_no_braces | ('{' tyvar '}') | ('{' tyvar '::' kind '}') ; tv_bndr_no_braces - : - tyvar + : tyvar | ('(' tyvar '::' kind ')') ; fds - : - '|' fds1 + : '|' fds1 ; fds1 - : - fd (',' fd)* + : fd (',' fd)* ; fd - : - varids0? '->' varids0? + : varids0? '->' varids0? ; varids0 - : - tyvar+ + : tyvar+ ; - // ------------------------------------------- // Kinds kind - : - ctype + : ctype ; // {- Note [Promotion] @@ -908,13 +820,11 @@ kind // Datatype declarations gadt_constrlist - : - 'where' open_ gadt_constrs? semi* close + : 'where' open_ gadt_constrs? semi* close ; gadt_constrs - : - gadt_constr_with_doc (semi gadt_constr_with_doc)* + : gadt_constr_with_doc (semi gadt_constr_with_doc)* ; // We allow the following forms: @@ -924,16 +834,13 @@ gadt_constrs // forall a. Eq a => D { x,y :: a } :: T a gadt_constr_with_doc - : - gadt_constr + : gadt_constr ; gadt_constr - : - con_list '::' sigtypedoc + : con_list '::' sigtypedoc ; - // {- Note [Difference in parsing GADT and data constructors] // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // GADT constructors have simpler syntax than usual data constructors: @@ -953,13 +860,11 @@ gadt_constr // ; constrs - : - '=' constrs1 + : '=' constrs1 ; constrs1 - : - constr ('|' constr)* + : constr ('|' constr)* ; // {- Note [Constr variations of non-terminals] @@ -1022,48 +927,40 @@ constrs1 // ; constr - : - forall? (constr_context '=>')? constr_stuff + : forall? (constr_context '=>')? constr_stuff ; forall - : - 'forall' tv_bndrs? '.' + : 'forall' tv_bndrs? '.' ; constr_stuff - : - constr_tyapps + : constr_tyapps ; fielddecls - : - fielddecl (',' fielddecl)* + : fielddecl (',' fielddecl)* ; fielddecl - : - sig_vars '::' ctype + : sig_vars '::' ctype ; // A list of one or more deriving clauses at the end of a datatype derivings - : - deriving+ + : deriving+ ; // The outer Located is just to allow the caller to // know the rightmost extremity of the 'deriving' clause deriving - : - ('deriving' deriv_clause_types) + : ('deriving' deriv_clause_types) | ('deriving' deriv_strategy_no_via deriv_clause_types) | ('deriving' deriv_clause_types deriv_strategy_via) ; deriv_clause_types - : - qtycon + : qtycon | '(' ')' | '(' deriv_types ')' ; @@ -1094,8 +991,7 @@ deriv_clause_types // -} decl_no_th - : - sigdecl + : sigdecl | (infixexp opt_sig? rhs) | pattern_synonym_decl // | docdecl @@ -1103,8 +999,7 @@ decl_no_th ; decl - : - decl_no_th + : decl_no_th // Why do we only allow naked declaration splices in top-level // declarations and not here? Short answer: because readFail009 @@ -1114,23 +1009,20 @@ decl ; rhs - : - ('=' exp wherebinds?) - | (gdrhs wherebinds?); + : ('=' exp wherebinds?) + | (gdrhs wherebinds?) + ; gdrhs - : - gdrh+ + : gdrh+ ; gdrh - : - '|' guards '=' exp + : '|' guards '=' exp ; sigdecl - : - (infixexp '::' sigtypedoc) + : (infixexp '::' sigtypedoc) | (var_ ',' sig_vars '::' sigtypedoc) | (fixity integer? ops) | (pattern_synonym_sig) @@ -1141,12 +1033,11 @@ sigdecl | ('{-#' 'SPECIALISE_INLINE' activation? qvar '::' sigtypes1 '#-}') | ('{-#' 'SPECIALISE' 'instance' inst_type '#-}') | ('{-#' 'MINIMAL' '#-}' name_boolformula_opt? '#-}') - |(semi+) + | (semi+) ; activation - : - ('[' integer ']') + : ('[' integer ']') | ('[' rule_activation_marker integer ']') ; @@ -1154,24 +1045,20 @@ activation // Expressions th_quasiquote - : - '[' varid '|' + : '[' varid '|' ; th_qquasiquote - : - '[' qvarid '|' + : '[' qvarid '|' ; quasiquote - : - th_quasiquote + : th_quasiquote | th_qquasiquote ; exp - : - (infixexp '::' sigtype) + : (infixexp '::' sigtype) | (infixexp '-<' exp) | (infixexp '>-' exp) | (infixexp '-<<' exp) @@ -1180,28 +1067,23 @@ exp ; infixexp - : - exp10 (qop exp10p)* + : exp10 (qop exp10p)* ; exp10p - : - exp10 + : exp10 ; exp10 - : - '-'? fexp + : '-'? fexp ; fexp - : - aexp+ ('@' atype)? + : aexp+ ('@' atype)? ; aexp - : - (qvar '@' aexp) + : (qvar '@' aexp) | ('~' aexp) | ('!' aexp) | ('\\' apats '->' exp) @@ -1216,13 +1098,11 @@ aexp ; aexp1 - : - aexp2 ('{' fbinds? '}')* + : aexp2 ('{' fbinds? '}')* ; aexp2 - : - qvar + : qvar | qcon | varid | literal @@ -1257,68 +1137,57 @@ aexp2 ; splice_exp - : - splice_typed + : splice_typed | splice_untyped ; splice_untyped - : - '$' aexp + : '$' aexp ; splice_typed - : - '$$' aexp + : '$$' aexp ; cmdargs - : - acmd+ + : acmd+ ; acmd - : - aexp + : aexp ; cvtopbody - : - open_ cvtopdecls0? close + : open_ cvtopdecls0? close ; cvtopdecls0 - : - topdecls semi* + : topdecls semi* ; // ------------------------------------------- // Tuple expressions texp - : - exp + : exp | (infixexp qop) | (qopm infixexp) | (exp '->' texp) ; tup_exprs - : - (texp commas_tup_tail) + : (texp commas_tup_tail) | (texp bars) | (commas tup_tail?) | (bars texp bars?) ; commas_tup_tail - : - commas tup_tail? + : commas tup_tail? ; tup_tail - : - texp commas_tup_tail + : texp commas_tup_tail | texp ; @@ -1326,8 +1195,7 @@ tup_tail // List expressions list_ - : - texp + : texp | lexps | texp '..' | texp ',' exp '..' @@ -1337,35 +1205,29 @@ list_ ; lexps - : - texp ',' texp (',' texp)* + : texp ',' texp (',' texp)* ; - // ------------------------------------------- // List Comprehensions flattenedpquals - : - pquals + : pquals ; pquals - : - squals ('|' squals)* + : squals ('|' squals)* ; squals - : - transformqual (',' transformqual)* + : transformqual (',' transformqual)* | transformqual (',' qual)* | qual (',' transformqual)* | qual (',' qual)* ; transformqual - : - 'then' exp + : 'then' exp | 'then' exp 'by' exp | 'then' 'group' 'using' exp | 'then' 'group' 'by' exp 'using' exp @@ -1376,19 +1238,15 @@ transformqual // introduces a shift/reduce conflict. Happy chooses to resolve the conflict // in by choosing the "group by" variant, which is what we want. - - // ------------------------------------------- // Guards (Different from GHC) guards - : - guard_ (',' guard_)* + : guard_ (',' guard_)* ; guard_ - : - pat '<-' infixexp + : pat '<-' infixexp | 'let' decllist | infixexp ; @@ -1397,79 +1255,67 @@ guard_ // Case alternatives alts - : - (open_ (alt semi*)+ close) + : (open_ (alt semi*)+ close) | (open_ close) ; -alt : pat alt_rhs ; +alt + : pat alt_rhs + ; alt_rhs - : - ralt wherebinds? + : ralt wherebinds? ; ralt - : - ('->' exp) + : ('->' exp) | gdpats ; - gdpats - : - gdpat+ + : gdpat+ ; // In ghc parser on GitLab second rule is 'gdpats close' // Unclearly, is there possible errors with this implemmentation ifgdpats - : - '{' gdpats '}' + : '{' gdpats '}' | gdpats ; gdpat - : - '|' guards '->' exp + : '|' guards '->' exp ; pat - : - exp + : exp ; bindpat - : - exp + : exp ; apat - : - aexp + : aexp ; apats - : - apat+ + : apat+ ; fpat - : - qvar '=' pat + : qvar '=' pat ; // ------------------------------------------- // Statement sequences stmtlist - : - open_ stmts? close + : open_ stmts? close ; stmts - : - stmt (semi+ stmt)* semi* + : stmt (semi+ stmt)* semi* ; stmt @@ -1478,10 +1324,8 @@ stmt | semi+ ; - qual - : - bindpat '<-' exp + : bindpat '<-' exp | exp | 'let' binds ; @@ -1490,8 +1334,7 @@ qual // Record Field Update/Construction fbinds - : - (fbind (',' fbind)*) + : (fbind (',' fbind)*) | ('..') ; @@ -1504,8 +1347,7 @@ fbinds // 2) In the punning case, use a place-holder // The renamer fills in the final value fbind - : - (qvar '=' exp) + : (qvar '=' exp) | qvar ; @@ -1513,13 +1355,11 @@ fbind // Implicit Parameter Bindings dbinds - : - dbind (semi+ dbind) semi* + : dbind (semi+ dbind) semi* ; dbind - : - varid '=' exp + : varid '=' exp ; // ------------------------------------------- @@ -1527,34 +1367,29 @@ dbind // Warnings and deprecations name_boolformula_opt - : - name_boolformula_and ('|' name_boolformula_and)* + : name_boolformula_and ('|' name_boolformula_and)* ; name_boolformula_and - : - name_boolformula_and_list + : name_boolformula_and_list ; name_boolformula_and_list - : - name_boolformula_atom (',' name_boolformula_atom)* + : name_boolformula_atom (',' name_boolformula_atom)* ; name_boolformula_atom - : - ('(' name_boolformula_opt ')') + : ('(' name_boolformula_opt ')') | name_var ; namelist - : - name_var (',' name_var)* + : name_var (',' name_var)* ; name_var - : - var_ | con + : var_ + | con ; // ------------------------------------------- @@ -1562,49 +1397,69 @@ name_var // There are two different productions here as lifted list constructors // are parsed differently. -qcon_nowiredlist : gen_qcon | sysdcon_nolist; +qcon_nowiredlist + : gen_qcon + | sysdcon_nolist + ; -qcon : gen_qcon | sysdcon; +qcon + : gen_qcon + | sysdcon + ; -gen_qcon : qconid | ( '(' qconsym ')' ); +gen_qcon + : qconid + | ( '(' qconsym ')') + ; -con : conid | ( '(' consym ')' ) | sysdcon; +con + : conid + | ( '(' consym ')') + | sysdcon + ; -con_list : con (',' con)*; +con_list + : con (',' con)* + ; sysdcon_nolist - : - ('(' ')') + : ('(' ')') | ('(' commas ')') | ('(#' '#)') | ('(#' commas '#)') ; sysdcon - : - sysdcon_nolist + : sysdcon_nolist | ('[' ']') ; -conop : consym | ('`' conid '`') ; +conop + : consym + | ('`' conid '`') + ; -qconop : gconsym | ('`' qconid '`') ; +qconop + : gconsym + | ('`' qconid '`') + ; -gconsym: ':' | qconsym ; +gconsym + : ':' + | qconsym + ; // ------------------------------------------- // Type constructors (Be careful!!!) gtycon - : - ntgtycon - | ('(' ')') + : ntgtycon + | ('(' ')') | ('(#' '#)') ; ntgtycon - : - oqtycon + : oqtycon | ('(' commas ')') | ('(#' commas '#)') | ('(' '->' ')') @@ -1612,8 +1467,7 @@ ntgtycon ; oqtycon - : - qtycon + : qtycon | ('(' qtyconsym ')') ; @@ -1637,78 +1491,147 @@ oqtycon // child. // -} -qtyconop: qtyconsym | ('`' qtycon '`'); +qtyconop + : qtyconsym + | ('`' qtycon '`') + ; -qtycon : (modid '.')? tycon; +qtycon + : (modid '.')? tycon + ; -tycon : conid; +tycon + : conid + ; -qtyconsym:qconsym | qvarsym | tyconsym; +qtyconsym + : qconsym + | qvarsym + | tyconsym + ; -tyconsym: consym | varsym | ':' | '-' | '.'; +tyconsym + : consym + | varsym + | ':' + | '-' + | '.' + ; // ------------------------------------------- // Operators -op : varop | conop ; +op + : varop + | conop + ; -varop : varsym | ('`' varid '`') ; +varop + : varsym + | ('`' varid '`') + ; -qop : qvarop | qconop ; +qop + : qvarop + | qconop + ; -qopm : qvaropm | qconop | hole_op; +qopm + : qvaropm + | qconop + | hole_op + ; -hole_op: '`' '_' '`'; +hole_op + : '`' '_' '`' + ; -qvarop : qvarsym | ('`' qvarid '`'); +qvarop + : qvarsym + | ('`' qvarid '`') + ; -qvaropm: qvarsym_no_minus | ('`' qvarid '`'); +qvaropm + : qvarsym_no_minus + | ('`' qvarid '`') + ; // ------------------------------------------- // Type variables -tyvar : varid; +tyvar + : varid + ; -tyvarop: '`' tyvarid '`'; +tyvarop + : '`' tyvarid '`' + ; // Expand this rule later // In GHC: // tyvarid : VARID | special_id | 'unsafe' // | 'safe' | 'interruptible'; -tyvarid : varid | special_id | 'unsafe' | 'safe' | 'interruptible'; +tyvarid + : varid + | special_id + | 'unsafe' + | 'safe' + | 'interruptible' + ; -tycls : conid; +tycls + : conid + ; -qtycls : (modid '.')? tycls; +qtycls + : (modid '.')? tycls + ; // ------------------------------------------- // Variables -var_ : varid | ( '(' varsym ')' ); +var_ + : varid + | ( '(' varsym ')') + ; -qvar : qvarid | ( '(' qvarsym ')'); +qvar + : qvarid + | ( '(' qvarsym ')') + ; // We've inlined qvarsym here so that the decision about // whether it's a qvar or a var can be postponed until // *after* we see the close paren -qvarid : (modid '.')? varid; +qvarid + : (modid '.')? varid + ; // Note that 'role' and 'family' get lexed separately regardless of // the use of extensions. However, because they are listed here, // this is OK and they can be used as normal varids. -varid : (VARID | special_id) '#'*; +varid + : (VARID | special_id) '#'* + ; -qvarsym: (modid '.')? varsym; +qvarsym + : (modid '.')? varsym + ; qvarsym_no_minus : varsym_no_minus | qvarsym ; -varsym : varsym_no_minus | '-'; +varsym + : varsym_no_minus + | '-' + ; -varsym_no_minus : ascSymbol+; +varsym_no_minus + : ascSymbol+ + ; // These special_ids are treated as keywords in various places, // but as ordinary ids elsewhere. 'special_id' collects all these @@ -1731,52 +1654,119 @@ special_id // ------------------------------------------- // Data constructors -qconid : (modid '.')? conid; +qconid + : (modid '.')? conid + ; -conid : CONID '#'*; +conid + : CONID '#'* + ; -qconsym: (modid '.')? consym; +qconsym + : (modid '.')? consym + ; -consym : ':' ascSymbol*; +consym + : ':' ascSymbol* + ; // ------------------------------------------- // Literals -literal : integer | pfloat | pchar | pstring; +literal + : integer + | pfloat + | pchar + | pstring + ; // ------------------------------------------- // Layout -open_ : VOCURLY | OCURLY; -close : VCCURLY | CCURLY; -semi : ';' | SEMI; +open_ + : VOCURLY + | OCURLY + ; + +close + : VCCURLY + | CCURLY + ; + +semi + : ';' + | SEMI + ; // ------------------------------------------- // Miscellaneous (mostly renamings) -modid : (conid '.')* conid; +modid + : (conid '.')* conid + ; -commas: ','+; +commas + : ','+ + ; -bars : '|'+; +bars + : '|'+ + ; // ------------------------------------------- -special : '(' | ')' | ',' | ';' | '[' | ']' | '`' | '{' | '}'; +special + : '(' + | ')' + | ',' + | ';' + | '[' + | ']' + | '`' + | '{' + | '}' + ; -symbol: ascSymbol; -ascSymbol: '!' | '#' | '$' | '%' | '&' | '*' | '+' - | '.' | '/' | '<' | '=' | '>' | '?' | '@' - | '\\' | '^' | '|' | '~' | ':' ; +symbol + : ascSymbol + ; + +ascSymbol + : '!' + | '#' + | '$' + | '%' + | '&' + | '*' + | '+' + | '.' + | '/' + | '<' + | '=' + | '>' + | '?' + | '@' + | '\\' + | '^' + | '|' + | '~' + | ':' + ; integer - : - DECIMAL + : DECIMAL | OCTAL | HEXADECIMAL ; +pfloat + : FLOAT + ; + +pchar + : CHAR + ; -pfloat : FLOAT; -pchar : CHAR; -pstring: STRING; \ No newline at end of file +pstring + : STRING + ; \ No newline at end of file diff --git a/html/HTMLLexer.g4 b/html/HTMLLexer.g4 index b0ba64b55c..99fde39b3a 100644 --- a/html/HTMLLexer.g4 +++ b/html/HTMLLexer.g4 @@ -26,193 +26,109 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -lexer grammar HTMLLexer; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -HTML_COMMENT - : '' - ; +lexer grammar HTMLLexer; -HTML_CONDITIONAL_COMMENT - : '' - ; +HTML_COMMENT: ''; -XML - : '' - ; +HTML_CONDITIONAL_COMMENT: ''; -CDATA - : '' - ; +XML: ''; -DTD - : '' - ; +CDATA: ''; -SCRIPTLET - : '' - | '<%' .*? '%>' - ; +DTD: ''; -SEA_WS - : (' '|'\t'|'\r'? '\n')+ - ; +SCRIPTLET: '' | '<%' .*? '%>'; -SCRIPT_OPEN - : '' ->pushMode(SCRIPT) - ; +SEA_WS: (' ' | '\t' | '\r'? '\n')+; -STYLE_OPEN - : '' ->pushMode(STYLE) - ; +SCRIPT_OPEN: '' -> pushMode(SCRIPT); -TAG_OPEN - : '<' -> pushMode(TAG) - ; +STYLE_OPEN: '' -> pushMode(STYLE); -HTML_TEXT - : ~'<'+ - ; +TAG_OPEN: '<' -> pushMode(TAG); +HTML_TEXT: ~'<'+; // tag declarations mode TAG; -TAG_CLOSE - : '>' -> popMode - ; +TAG_CLOSE: '>' -> popMode; -TAG_SLASH_CLOSE - : '/>' -> popMode - ; - -TAG_SLASH - : '/' - ; +TAG_SLASH_CLOSE: '/>' -> popMode; +TAG_SLASH: '/'; // lexing mode for attribute values -TAG_EQUALS - : '=' -> pushMode(ATTVALUE) - ; +TAG_EQUALS: '=' -> pushMode(ATTVALUE); -TAG_NAME - : TAG_NameStartChar TAG_NameChar* - ; +TAG_NAME: TAG_NameStartChar TAG_NameChar*; -TAG_WHITESPACE - : [ \t\r\n] -> channel(HIDDEN) - ; +TAG_WHITESPACE: [ \t\r\n] -> channel(HIDDEN); -fragment -HEXDIGIT - : [a-fA-F0-9] - ; +fragment HEXDIGIT: [a-fA-F0-9]; -fragment -DIGIT - : [0-9] - ; +fragment DIGIT: [0-9]; -fragment -TAG_NameChar - : TAG_NameStartChar +fragment TAG_NameChar: + TAG_NameStartChar | '-' | '_' | '.' | DIGIT | '\u00B7' - | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; - -fragment -TAG_NameStartChar - : [:a-zA-Z] - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - ; - + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' +; + +fragment TAG_NameStartChar: + [:a-zA-Z] + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' +; // mode SCRIPT; -SCRIPT_BODY - : .*? '' -> popMode - ; - -SCRIPT_SHORT_BODY - : .*? '' -> popMode - ; +SCRIPT_BODY: .*? '' -> popMode; +SCRIPT_SHORT_BODY: .*? '' -> popMode; // mode STYLE; -STYLE_BODY - : .*? '' -> popMode - ; - -STYLE_SHORT_BODY - : .*? '' -> popMode - ; +STYLE_BODY: .*? '' -> popMode; +STYLE_SHORT_BODY: .*? '' -> popMode; // attribute values mode ATTVALUE; // an attribute value may have spaces b/t the '=' and the value -ATTVALUE_VALUE - : ' '* ATTRIBUTE -> popMode - ; - -ATTRIBUTE - : DOUBLE_QUOTE_STRING - | SINGLE_QUOTE_STRING - | ATTCHARS - | HEXCHARS - | DECCHARS - ; - -fragment ATTCHARS - : ATTCHAR+ ' '? - ; - -fragment ATTCHAR - : '-' - | '_' - | '.' - | '/' - | '+' - | ',' - | '?' - | '=' - | ':' - | ';' - | '#' - | [0-9a-zA-Z] - ; - -fragment HEXCHARS - : '#' [0-9a-fA-F]+ - ; - -fragment DECCHARS - : [0-9]+ '%'? - ; - -fragment DOUBLE_QUOTE_STRING - : '"' ~[<"]* '"' - ; - -fragment SINGLE_QUOTE_STRING - : '\'' ~[<']* '\'' - ; +ATTVALUE_VALUE: ' '* ATTRIBUTE -> popMode; + +ATTRIBUTE: DOUBLE_QUOTE_STRING | SINGLE_QUOTE_STRING | ATTCHARS | HEXCHARS | DECCHARS; + +fragment ATTCHARS: ATTCHAR+ ' '?; + +fragment ATTCHAR: '-' | '_' | '.' | '/' | '+' | ',' | '?' | '=' | ':' | ';' | '#' | [0-9a-zA-Z]; + +fragment HEXCHARS: '#' [0-9a-fA-F]+; + +fragment DECCHARS: [0-9]+ '%'?; + +fragment DOUBLE_QUOTE_STRING: '"' ~[<"]* '"'; +fragment SINGLE_QUOTE_STRING: '\'' ~[<']* '\''; \ No newline at end of file diff --git a/html/HTMLParser.g4 b/html/HTMLParser.g4 index b09d48e7d4..4f8510ab3c 100644 --- a/html/HTMLParser.g4 +++ b/html/HTMLParser.g4 @@ -26,9 +26,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 HTMLParser; -options { tokenVocab=HTMLLexer; } +options { + tokenVocab = HTMLLexer; +} htmlDocument : scriptletOrSeaWs* XML? scriptletOrSeaWs* DTD? scriptletOrSeaWs* htmlElements* @@ -44,8 +49,10 @@ htmlElements ; htmlElement - : TAG_OPEN TAG_NAME htmlAttribute* - (TAG_CLOSE (htmlContent TAG_OPEN TAG_SLASH TAG_NAME TAG_CLOSE)? | TAG_SLASH_CLOSE) + : TAG_OPEN TAG_NAME htmlAttribute* ( + TAG_CLOSE (htmlContent TAG_OPEN TAG_SLASH TAG_NAME TAG_CLOSE)? + | TAG_SLASH_CLOSE + ) | SCRIPTLET | script | style @@ -80,4 +87,4 @@ script style : STYLE_OPEN (STYLE_BODY | STYLE_SHORT_BODY) - ; + ; \ No newline at end of file diff --git a/http/http.g4 b/http/http.g4 index e4f38fb5b7..a35d0b3b19 100644 --- a/http/http.g4 +++ b/http/http.g4 @@ -1,20 +1,28 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar http; /* HTTP-message = start‑line ( header‑field  CRLF ) CRLF [ message‑body ] */ -http_message: start_line (header_field CRLF)* CRLF EOF //message_body - ; +http_message + : start_line (header_field CRLF)* CRLF EOF //message_body + ; /* start-line = request‑line / status‑line */ -start_line: request_line; +start_line + : request_line + ; /* request-line = method  SP  request‑target  SP  HTTP‑version  CRLF */ -request_line: method SP request_target SP http_version CRLF; +request_line + : method SP request_target SP http_version CRLF + ; /* method = token ; "GET" ; → RFC 7231 – Section 4.3.1 ; "HEAD" ; → RFC 7231 – Section 4.3.2 ; "POST" @@ -22,251 +30,399 @@ request_line: method SP request_target SP http_version CRLF; 4.3.5 ; "CONNECT" ; → RFC 7231 – Section 4.3.6 ; "OPTIONS" ; → RFC 7231 – Section 4.3.7 ; "TRACE" ; → RFC 7231 – Section 4.3.8 */ -method: - 'GET' - | 'HEAD' - | 'POST' - | 'PUT' - | 'DELETE' - | 'CONNECT' - | 'OPTIONS' - | 'TRACE'; +method + : 'GET' + | 'HEAD' + | 'POST' + | 'PUT' + | 'DELETE' + | 'CONNECT' + | 'OPTIONS' + | 'TRACE' + ; /* request-target = origin-form / absolute-form / authority-form / asterisk-form */ -request_target: origin_form; +request_target + : origin_form + ; /* origin-form = absolute-path  [ "?"  query ] */ -origin_form: absolute_path (QuestionMark query)?; +origin_form + : absolute_path (QuestionMark query)? + ; /* absolute-path = 1*( "/"  segment ) */ -absolute_path: (Slash segment)+; +absolute_path + : (Slash segment)+ + ; /* segment = pchar */ -segment: pchar*; +segment + : pchar* + ; /* query = ( pchar /  "/" /  "?" ) */ -query: (pchar | Slash | QuestionMark)*; +query + : (pchar | Slash | QuestionMark)* + ; /* HTTP-version = HTTP-name '/' DIGIT  "."  DIGIT */ -http_version: http_name DIGIT Dot DIGIT; +http_version + : http_name DIGIT Dot DIGIT + ; /* HTTP-name = %x48.54.54.50 ; "HTTP", case-sensitive */ -http_name: 'HTTP/'; - +http_name + : 'HTTP/' + ; /* header-field = field-name  ":"  OWS  field-value  OWS  */ -header_field: field_name Colon OWS* field_value OWS*; +header_field + : field_name Colon OWS* field_value OWS* + ; /* field-name = token */ -field_name: token; +field_name + : token + ; /* token */ -token: tchar+; +token + : tchar+ + ; + /* field-value = ( field-content / obs-fold ) */ -field_value: (field_content | obs_fold)+; +field_value + : (field_content | obs_fold)+ + ; /* field-content = field-vchar [ 1*( SP / HTAB )  field-vchar ] */ -field_content: field_vchar ((SP | HTAB)+ field_vchar)?; +field_content + : field_vchar ((SP | HTAB)+ field_vchar)? + ; /* field-vchar = VCHAR / obs-text */ -field_vchar: vCHAR | obs_text; +field_vchar + : vCHAR + | obs_text + ; + /* obs-text = %x80-FF */ -obs_text: OBS_TEXT; +obs_text + : OBS_TEXT + ; + /* obs-fold = CRLF  1*( SP / HTAB ) ; see RFC 7230 – Section 3.2.4 */ -obs_fold: CRLF (SP | HTAB)+; +obs_fold + : CRLF (SP | HTAB)+ + ; /* message-body = OCTET */ //message_body: OCTET*; - /* SP = %x20 ; space */ -SP: ' '; +SP + : ' ' + ; + /* pchar = unreserved / pct‑encoded / sub‑delims / ":" / "@" */ -pchar: unreserved | Pct_encoded | sub_delims | Colon | At; +pchar + : unreserved + | Pct_encoded + | sub_delims + | Colon + | At + ; /* unreserved = ALPHA /  DIGIT /  "-" /  "." /  "_" /  "~" */ -unreserved: ALPHA | DIGIT | Minus | Dot | Underscore | Tilde; +unreserved + : ALPHA + | DIGIT + | Minus + | Dot + | Underscore + | Tilde + ; /* ALPHA = %x41‑5A /  %x61‑7A ; A‑Z / a‑z */ -ALPHA: [A-Za-z]; +ALPHA + : [A-Za-z] + ; /* DIGIT = %x30‑39 ; 0-9 */ -DIGIT: [0-9]; +DIGIT + : [0-9] + ; /* pct-encoded = "%"  HEXDIG  HEXDIG */ -Pct_encoded: Percent HEXDIG HEXDIG; +Pct_encoded + : Percent HEXDIG HEXDIG + ; /* HEXDIG = DIGIT /  "A" /  "B" /  "C" /  "D" /  "E" /  "F" */ -HEXDIG: DIGIT | 'A' | 'B' | 'C' | 'D' | 'E' | 'F'; +HEXDIG + : DIGIT + | 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + ; /* sub-delims = "!" /  "$" /  "&" /  "'" /  "(" /  ")" /  "*" /  "+" /  "," /  ";" /  "=" */ -sub_delims: - ExclamationMark - | DollarSign - | Ampersand - | SQuote - | LColumn - | RColumn - | Star - | Plus - | SemiColon - | Period - | Equals; - -LColumn:'('; -RColumn:')'; -SemiColon:';'; -Equals:'='; -Period:','; +sub_delims + : ExclamationMark + | DollarSign + | Ampersand + | SQuote + | LColumn + | RColumn + | Star + | Plus + | SemiColon + | Period + | Equals + ; + +LColumn + : '(' + ; + +RColumn + : ')' + ; + +SemiColon + : ';' + ; + +Equals + : '=' + ; + +Period + : ',' + ; /* CRLF = CR  LF ; Internet standard newline */ -CRLF: '\n'; +CRLF + : '\n' + ; /* tchar = "!" /  "#" /  "$" /  "%" /  "&" /  "'" /  "*" /  "+" /  "-" /  "." /  "^" /  "_" /  "`" /  "|" /  "~" /  DIGIT /  ALPHA */ -tchar: - ExclamationMark - | DollarSign - | Hashtag - | Percent - | Ampersand - | SQuote - | Star - | Plus +tchar + : ExclamationMark + | DollarSign + | Hashtag + | Percent + | Ampersand + | SQuote + | Star + | Plus | Minus - | Dot - | Caret + | Dot + | Caret | Underscore - | BackQuote - | VBar - | Tilde - | DIGIT - | ALPHA; - -Minus :'-'; -Dot : '.'; -Underscore: '_'; -Tilde : '~'; -QuestionMark :'?'; -Slash :'/'; -ExclamationMark: '!'; -Colon:':'; -At: '@'; -DollarSign:'$'; -Hashtag:'#'; -Ampersand:'&'; -Percent:'%'; -SQuote:'\''; -Star:'*'; -Plus:'+'; -Caret:'^'; -BackQuote:'`'; -VBar:'|'; + | BackQuote + | VBar + | Tilde + | DIGIT + | ALPHA + ; + +Minus + : '-' + ; + +Dot + : '.' + ; + +Underscore + : '_' + ; + +Tilde + : '~' + ; + +QuestionMark + : '?' + ; + +Slash + : '/' + ; + +ExclamationMark + : '!' + ; + +Colon + : ':' + ; + +At + : '@' + ; + +DollarSign + : '$' + ; + +Hashtag + : '#' + ; + +Ampersand + : '&' + ; + +Percent + : '%' + ; + +SQuote + : '\'' + ; + +Star + : '*' + ; + +Plus + : '+' + ; + +Caret + : '^' + ; + +BackQuote + : '`' + ; + +VBar + : '|' + ; /* OWS = ( SP / HTAB ) ; optional whitespace */ -OWS: SP | HTAB; +OWS + : SP + | HTAB + ; /* HTAB = %x09 ; horizontal tab */ -HTAB: '\t'; - +HTAB + : '\t' + ; /* VCHAR = %x21-7E ; visible (printing) characters */ -vCHAR: ALPHA | DIGIT | VCHAR; - -VCHAR: - ExclamationMark - | '"' - | Hashtag - | DollarSign - | Percent - | Ampersand - | SQuote - | LColumn - | RColumn - | RColumn - | Star - | Plus - | Period - | Minus - | Dot - | Slash - | Colon - | SemiColon - | '<' - | Equals - | '>' - | QuestionMark - | At - | '[' - | '\\' - | Caret - | Underscore - | ']' - | BackQuote - | '{' - | '}' - | VBar - | Tilde; - -OBS_TEXT: '\u0080' ..'\u00ff'; +vCHAR + : ALPHA + | DIGIT + | VCHAR + ; + +VCHAR + : ExclamationMark + | '"' + | Hashtag + | DollarSign + | Percent + | Ampersand + | SQuote + | LColumn + | RColumn + | RColumn + | Star + | Plus + | Period + | Minus + | Dot + | Slash + | Colon + | SemiColon + | '<' + | Equals + | '>' + | QuestionMark + | At + | '[' + | '\\' + | Caret + | Underscore + | ']' + | BackQuote + | '{' + | '}' + | VBar + | Tilde + ; + +OBS_TEXT + : '\u0080' ..'\u00ff' + ; /* OCTET = %x00-FF ; 8 bits of data diff --git a/hypertalk/HyperTalk.g4 b/hypertalk/HyperTalk.g4 index 2eab509f3a..cd584156f1 100644 --- a/hypertalk/HyperTalk.g4 +++ b/hypertalk/HyperTalk.g4 @@ -22,6 +22,9 @@ * SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar HyperTalk; // Start symbol accepting only well-formed HyperTalk scripts that consist of handlers, functions, whitespace and @@ -60,7 +63,7 @@ function_ handlerName : ID - | commandName // Handlers can take the name of a command keyword (other keywords are disallowed) + | commandName // Handlers can take the name of a command keyword (other keywords are disallowed) ; parameterList @@ -210,7 +213,7 @@ commandStmnt | 'sort' 'the'? cards of expression sortDirection sortStyle 'by' expression | 'sort' 'the'? 'marked' cards of expression sortDirection sortStyle 'by' expression | 'speak' expression - | 'speak' expression 'with' gender=('male'|'female'|'neuter'|'robotic') 'voice' + | 'speak' expression 'with' gender = ('male' | 'female' | 'neuter' | 'robotic') 'voice' | 'speak' expression 'with' 'voice' expression | 'subtract' expression 'from' expression | 'type' expression @@ -416,13 +419,29 @@ expression : factor | 'not' expression | '-' expression - | op=('there is a'|'there is an'|'there is no'|'there is not a'|'there is not an') expression + | op = ('there is a' | 'there is an' | 'there is no' | 'there is not a' | 'there is not an') expression | expression '^' expression - | expression op=('mod'| 'div'| '/'| '*') expression - | expression op=('+'| '-') expression - | expression op=('&&'| '&') expression - | expression op=('>='|'<='|'≤'|'≥'|'<'|'>'|'contains'|'is in'|'is not in'|'is a'|'is an'|'is not a'|'is not an'|'is within'|'is not within') expression - | expression op=('='|'is not'|'is'|'<>'|'≠') expression + | expression op = ('mod' | 'div' | '/' | '*') expression + | expression op = ('+' | '-') expression + | expression op = ('&&' | '&') expression + | expression op = ( + '>=' + | '<=' + | '≤' + | '≥' + | '<' + | '>' + | 'contains' + | 'is in' + | 'is not in' + | 'is a' + | 'is an' + | 'is not a' + | 'is not an' + | 'is within' + | 'is not within' + ) expression + | expression op = ('=' | 'is not' | 'is' | '<>' | '≠') expression | expression 'and' expression | expression 'or' expression ; @@ -815,7 +834,7 @@ position ; message - : 'the'? ('message' | 'msg') ('box' | 'window' | ) + : 'the'? ('message' | 'msg') ('box' | 'window' |) ; cards @@ -933,4 +952,4 @@ WHITESPACE UNLEXED_CHAR : . - ; + ; \ No newline at end of file diff --git a/icalendar/ICalendar.g4 b/icalendar/ICalendar.g4 index 274261d2de..6b99b017d3 100644 --- a/icalendar/ICalendar.g4 +++ b/icalendar/ICalendar.g4 @@ -32,2337 +32,2301 @@ * https://github.com/bkiers/ICalParser */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ICalendar; ////////////////////////////// parser rules ////////////////////////////// parse - : icalstream EOF - ; + : icalstream EOF + ; // 3.4 - iCalendar Object icalstream - : CRLF* icalobject (CRLF + icalobject)* CRLF* - ; + : CRLF* icalobject (CRLF+ icalobject)* CRLF* + ; icalobject - : k_begin COL k_vcalendar CRLF calprop*? component +? k_end COL k_vcalendar - ; + : k_begin COL k_vcalendar CRLF calprop*? component+? k_end COL k_vcalendar + ; calprop - : prodid - | version - | calscale - | method - | x_prop - | iana_prop - ; + : prodid + | version + | calscale + | method + | x_prop + | iana_prop + ; // 3.7.1 - Calendar Scale calscale - : k_calscale (SCOL other_param)* COL k_gregorian CRLF - ; + : k_calscale (SCOL other_param)* COL k_gregorian CRLF + ; // 3.7.2 - Method method - : k_method (SCOL other_param)* COL iana_token CRLF - ; + : k_method (SCOL other_param)* COL iana_token CRLF + ; // 3.7.3 - Product Identifier prodid - : k_prodid (SCOL other_param)* COL text CRLF - ; + : k_prodid (SCOL other_param)* COL text CRLF + ; // 3.7.4 - Version version - : k_version (SCOL other_param)* COL vervalue CRLF - ; + : k_version (SCOL other_param)* COL vervalue CRLF + ; vervalue - : float_num SCOL float_num - | float_num - ; + : float_num SCOL float_num + | float_num + ; component - : eventc - | todoc - | journalc - | freebusyc - | timezonec - | iana_comp - | x_comp - ; + : eventc + | todoc + | journalc + | freebusyc + | timezonec + | iana_comp + | x_comp + ; iana_comp - : k_begin COL iana_token CRLF contentline +? k_end COL iana_token CRLF - ; + : k_begin COL iana_token CRLF contentline+? k_end COL iana_token CRLF + ; x_comp - : k_begin COL x_name CRLF contentline +? k_end COL x_name CRLF - ; + : k_begin COL x_name CRLF contentline+? k_end COL x_name CRLF + ; contentline - : name (SCOL icalparameter)* COL value CRLF - ; + : name (SCOL icalparameter)* COL value CRLF + ; name - : iana_token - | x_name - ; + : iana_token + | x_name + ; value - : value_char* - ; + : value_char* + ; // 3.6.1 - Event Component eventc - : k_begin COL k_vevent CRLF eventprop*? alarmc*? k_end COL k_vevent CRLF - ; + : k_begin COL k_vevent CRLF eventprop*? alarmc*? k_end COL k_vevent CRLF + ; // 3.6.2 - To-Do Component todoc - : k_begin COL k_vtodo CRLF todoprop*? alarmc*? k_end COL k_vtodo CRLF - ; + : k_begin COL k_vtodo CRLF todoprop*? alarmc*? k_end COL k_vtodo CRLF + ; // 3.6.3 - Journal Component journalc - : k_begin COL k_vjournal CRLF jourprop*? k_end COL k_vjournal CRLF - ; + : k_begin COL k_vjournal CRLF jourprop*? k_end COL k_vjournal CRLF + ; // 3.6.4 - Free/Busy Component freebusyc - : k_begin COL k_vfreebusy CRLF fbprop*? k_end COL k_vfreebusy CRLF - ; + : k_begin COL k_vfreebusy CRLF fbprop*? k_end COL k_vfreebusy CRLF + ; // 3.6.5 - Time Zone Component timezonec - : k_begin COL k_vtimezone CRLF timezoneprop*? k_end COL k_vtimezone CRLF - ; + : k_begin COL k_vtimezone CRLF timezoneprop*? k_end COL k_vtimezone CRLF + ; // 3.6.6 - Alarm Component alarmc - : k_begin COL k_valarm CRLF alarmprop +? k_end COL k_valarm CRLF - ; + : k_begin COL k_valarm CRLF alarmprop+? k_end COL k_valarm CRLF + ; eventprop - : dtstamp - | uid - | dtstart - | clazz - | created - | description - | geo - | last_mod - | location - | organizer - | priority - | seq - | status - | summary - | transp - | url - | recurid - | rrule - | dtend - | duration - | attach - | attendee - | categories - | comment - | contact - | exdate - | rstatus - | related - | resources - | rdate - | x_prop - | iana_prop - ; + : dtstamp + | uid + | dtstart + | clazz + | created + | description + | geo + | last_mod + | location + | organizer + | priority + | seq + | status + | summary + | transp + | url + | recurid + | rrule + | dtend + | duration + | attach + | attendee + | categories + | comment + | contact + | exdate + | rstatus + | related + | resources + | rdate + | x_prop + | iana_prop + ; todoprop - : dtstamp - | uid - | clazz - | completed - | created - | description - | dtstart - | geo - | last_mod - | location - | organizer - | percent - | priority - | recurid - | seq - | status - | summary - | url - | rrule - | due - | duration - | attach - | attendee - | categories - | comment - | contact - | exdate - | rstatus - | related - | resources - | rdate - | x_prop - | iana_prop - ; + : dtstamp + | uid + | clazz + | completed + | created + | description + | dtstart + | geo + | last_mod + | location + | organizer + | percent + | priority + | recurid + | seq + | status + | summary + | url + | rrule + | due + | duration + | attach + | attendee + | categories + | comment + | contact + | exdate + | rstatus + | related + | resources + | rdate + | x_prop + | iana_prop + ; jourprop - : dtstamp - | uid - | clazz - | created - | dtstart - | last_mod - | organizer - | recurid - | seq - | status - | summary - | url - | rrule - | attach - | attendee - | categories - | comment - | contact - | description - | exdate - | related - | rdate - | rstatus - | x_prop - | iana_prop - ; + : dtstamp + | uid + | clazz + | created + | dtstart + | last_mod + | organizer + | recurid + | seq + | status + | summary + | url + | rrule + | attach + | attendee + | categories + | comment + | contact + | description + | exdate + | related + | rdate + | rstatus + | x_prop + | iana_prop + ; fbprop - : dtstamp - | uid - | contact - | dtstart - | dtend - | organizer - | url - | attendee - | comment - | freebusy - | rstatus - | x_prop - | iana_prop - ; + : dtstamp + | uid + | contact + | dtstart + | dtend + | organizer + | url + | attendee + | comment + | freebusy + | rstatus + | x_prop + | iana_prop + ; timezoneprop - : tzid - | last_mod - | tzurl - | standardc - | daylightc - | x_prop - | iana_prop - ; + : tzid + | last_mod + | tzurl + | standardc + | daylightc + | x_prop + | iana_prop + ; tzprop - : dtstart - | tzoffsetto - | tzoffsetfrom - | rrule - | comment - | rdate - | tzname - | x_prop - | iana_prop - ; + : dtstart + | tzoffsetto + | tzoffsetfrom + | rrule + | comment + | rdate + | tzname + | x_prop + | iana_prop + ; alarmprop - : action - | description - | trigger - | summary - | attendee - | duration - | repeat_ - | attach - | x_prop - | iana_prop - ; + : action + | description + | trigger + | summary + | attendee + | duration + | repeat_ + | attach + | x_prop + | iana_prop + ; standardc - : k_begin COL k_standard CRLF tzprop*? k_end COL k_standard CRLF - ; + : k_begin COL k_standard CRLF tzprop*? k_end COL k_standard CRLF + ; daylightc - : k_begin COL k_daylight CRLF tzprop*? k_end COL k_daylight CRLF - ; + : k_begin COL k_daylight CRLF tzprop*? k_end COL k_daylight CRLF + ; // 3.8.1.1 - Attachment attach - : k_attach attachparam* (COL uri | SCOL k_encoding ASSIGN k_base D6 D4 SCOL k_value ASSIGN k_binary COL binary) CRLF - ; + : k_attach attachparam* ( + COL uri + | SCOL k_encoding ASSIGN k_base D6 D4 SCOL k_value ASSIGN k_binary COL binary + ) CRLF + ; attachparam - : SCOL fmttypeparam - | SCOL other_param - ; + : SCOL fmttypeparam + | SCOL other_param + ; // 3.8.1.2 - Categories categories - : k_categories catparam* COL text (COMMA text)* CRLF - ; + : k_categories catparam* COL text (COMMA text)* CRLF + ; catparam - : SCOL languageparam - | SCOL other_param - ; + : SCOL languageparam + | SCOL other_param + ; // 3.8.1.3 - Classification clazz - : k_class (SCOL other_param)* COL classvalue CRLF - ; + : k_class (SCOL other_param)* COL classvalue CRLF + ; classvalue - : k_public - | k_private - | k_confidential - | iana_token - | x_name - ; + : k_public + | k_private + | k_confidential + | iana_token + | x_name + ; // 3.8.1.4 - Comment comment - : k_comment commparam* COL text CRLF - ; + : k_comment commparam* COL text CRLF + ; commparam - : SCOL altrepparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL altrepparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.1.5 - Description description - : k_description descparam* COL text CRLF - ; + : k_description descparam* COL text CRLF + ; descparam - : SCOL altrepparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL altrepparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.1.6 - Geographic Position geo - : k_geo (SCOL other_param)* COL geovalue CRLF - ; + : k_geo (SCOL other_param)* COL geovalue CRLF + ; geovalue - : float_num SCOL float_num - ; + : float_num SCOL float_num + ; // 3.8.1.7 - Location location - : k_location locparam* COL text CRLF - ; + : k_location locparam* COL text CRLF + ; locparam - : SCOL altrepparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL altrepparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.1.8 - Percent Complete percent - : k_percent_complete (SCOL other_param)* COL integer CRLF - ; + : k_percent_complete (SCOL other_param)* COL integer CRLF + ; // 3.8.1.9 - Priority priority - : k_priority (SCOL other_param)* COL priovalue CRLF - ; + : k_priority (SCOL other_param)* COL priovalue CRLF + ; priovalue - : integer - ; + : integer + ; // 3.8.1.10 - Resources resources - : k_resources resrcparam* COL text (COMMA text)* CRLF - ; + : k_resources resrcparam* COL text (COMMA text)* CRLF + ; resrcparam - : SCOL altrepparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL altrepparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.1.11 - Status status - : k_status (SCOL other_param)* COL statvalue CRLF - ; + : k_status (SCOL other_param)* COL statvalue CRLF + ; statvalue - : statvalue_event - | statvalue_todo - | statvalue_jour - ; + : statvalue_event + | statvalue_todo + | statvalue_jour + ; statvalue_event - : k_tentative - | k_confirmed - | k_cancelled - ; + : k_tentative + | k_confirmed + | k_cancelled + ; statvalue_todo - : k_needs_action - | k_completed - | k_in_process - | k_cancelled - ; + : k_needs_action + | k_completed + | k_in_process + | k_cancelled + ; statvalue_jour - : k_draft - | k_final - | k_cancelled - ; + : k_draft + | k_final + | k_cancelled + ; // 3.8.1.12 - Summary summary - : k_summary summparam* COL text CRLF - ; + : k_summary summparam* COL text CRLF + ; summparam - : SCOL altrepparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL altrepparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.2.1 - Date-Time Completed completed - : k_completed (SCOL other_param)* COL date_time CRLF - ; + : k_completed (SCOL other_param)* COL date_time CRLF + ; // 3.8.2.2 - Date-Time End dtend - : k_dtend dtendparam* COL date_time_date CRLF - ; + : k_dtend dtendparam* COL date_time_date CRLF + ; dtendparam - : SCOL k_value ASSIGN k_date_time - | SCOL k_value ASSIGN k_date - | SCOL tzidparam - | SCOL other_param - ; + : SCOL k_value ASSIGN k_date_time + | SCOL k_value ASSIGN k_date + | SCOL tzidparam + | SCOL other_param + ; // 3.8.2.3 - Date-Time Due due - : k_due dueparam* COL date_time_date CRLF - ; + : k_due dueparam* COL date_time_date CRLF + ; dueparam - : SCOL k_value ASSIGN k_date_time - | SCOL k_value ASSIGN k_date - | SCOL tzidparam - | SCOL other_param - ; + : SCOL k_value ASSIGN k_date_time + | SCOL k_value ASSIGN k_date + | SCOL tzidparam + | SCOL other_param + ; // 3.8.2.4 - Date-Time Start dtstart - : k_dtstart dtstparam* COL date_time_date CRLF - ; + : k_dtstart dtstparam* COL date_time_date CRLF + ; dtstparam - : SCOL k_value ASSIGN k_date_time - | SCOL k_value ASSIGN k_date - | SCOL tzidparam - | SCOL other_param - ; + : SCOL k_value ASSIGN k_date_time + | SCOL k_value ASSIGN k_date + | SCOL tzidparam + | SCOL other_param + ; // 3.8.2.5 - Duration duration - : k_duration (SCOL other_param)* COL dur_value CRLF - ; + : k_duration (SCOL other_param)* COL dur_value CRLF + ; // 3.8.2.6 - Free/Busy Time freebusy - : k_freebusy fbparam* COL fbvalue CRLF - ; + : k_freebusy fbparam* COL fbvalue CRLF + ; fbparam - : SCOL fbtypeparam - | SCOL other_param - ; + : SCOL fbtypeparam + | SCOL other_param + ; fbvalue - : period (COMMA period)* - ; + : period (COMMA period)* + ; // 3.8.2.7 - Time Transparency transp - : k_transp (SCOL other_param)* COL transvalue CRLF - ; + : k_transp (SCOL other_param)* COL transvalue CRLF + ; transvalue - : k_opaque - | k_transparent - ; + : k_opaque + | k_transparent + ; // 3.8.3.1 - Time Zone Identifier tzid - : k_tzid (SCOL other_param)* COL FSLASH? text CRLF - ; + : k_tzid (SCOL other_param)* COL FSLASH? text CRLF + ; // 3.8.3.2. Time Zone Name tzname - : k_tzname tznparam* COL text CRLF - ; + : k_tzname tznparam* COL text CRLF + ; tznparam - : SCOL languageparam - | SCOL other_param - ; + : SCOL languageparam + | SCOL other_param + ; // 3.8.3.3 - Time Zone Offset From tzoffsetfrom - : k_tzoffsetfrom (SCOL other_param)* COL utc_offset CRLF - ; + : k_tzoffsetfrom (SCOL other_param)* COL utc_offset CRLF + ; // 3.8.3.4 - Time Zone Offset To tzoffsetto - : k_tzoffsetto (SCOL other_param)* COL utc_offset CRLF - ; + : k_tzoffsetto (SCOL other_param)* COL utc_offset CRLF + ; // 3.8.3.5. Time Zone URL tzurl - : k_tzurl (SCOL other_param)* COL uri CRLF - ; + : k_tzurl (SCOL other_param)* COL uri CRLF + ; // 3.8.4.1 - Attendee attendee - : k_attendee attparam* COL cal_address CRLF - ; + : k_attendee attparam* COL cal_address CRLF + ; attparam - : SCOL cutypeparam - | SCOL memberparam - | SCOL roleparam - | SCOL partstatparam - | SCOL rsvpparam - | SCOL deltoparam - | SCOL delfromparam - | SCOL sentbyparam - | SCOL cnparam - | SCOL dirparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL cutypeparam + | SCOL memberparam + | SCOL roleparam + | SCOL partstatparam + | SCOL rsvpparam + | SCOL deltoparam + | SCOL delfromparam + | SCOL sentbyparam + | SCOL cnparam + | SCOL dirparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.4.2 - Contact contact - : k_contact contparam* COL text CRLF - ; + : k_contact contparam* COL text CRLF + ; contparam - : SCOL altrepparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL altrepparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.4.3 - Organizer organizer - : k_organizer orgparam* COL cal_address CRLF - ; + : k_organizer orgparam* COL cal_address CRLF + ; orgparam - : SCOL cnparam - | SCOL dirparam - | SCOL sentbyparam - | SCOL languageparam - | SCOL other_param - ; + : SCOL cnparam + | SCOL dirparam + | SCOL sentbyparam + | SCOL languageparam + | SCOL other_param + ; // 3.8.4.4 - Recurrence ID recurid - : k_recurrence_id ridparam* COL date_time_date CRLF - ; + : k_recurrence_id ridparam* COL date_time_date CRLF + ; ridparam - : SCOL k_value ASSIGN k_date_time - | SCOL k_value ASSIGN k_date - | SCOL tzidparam - | SCOL rangeparam - | SCOL other_param - ; + : SCOL k_value ASSIGN k_date_time + | SCOL k_value ASSIGN k_date + | SCOL tzidparam + | SCOL rangeparam + | SCOL other_param + ; // 3.8.4.5. Related To related - : k_related_to relparam* COL text CRLF - ; + : k_related_to relparam* COL text CRLF + ; relparam - : SCOL reltypeparam - | SCOL other_param - ; + : SCOL reltypeparam + | SCOL other_param + ; // 3.8.4.6 - Uniform Resource Locator url - : k_url (SCOL other_param)* COL uri CRLF - ; + : k_url (SCOL other_param)* COL uri CRLF + ; // 3.8.4.7 - Unique Identifier uid - : k_uid (SCOL other_param)* COL text CRLF - ; + : k_uid (SCOL other_param)* COL text CRLF + ; // 3.8.5.1 - Exception Date-Times exdate - : k_exdate exdtparam* COL date_time_date (COMMA date_time_date)* CRLF - ; + : k_exdate exdtparam* COL date_time_date (COMMA date_time_date)* CRLF + ; exdtparam - : SCOL k_value ASSIGN k_date_time - | SCOL k_value ASSIGN k_date - | SCOL tzidparam - | SCOL other_param - ; + : SCOL k_value ASSIGN k_date_time + | SCOL k_value ASSIGN k_date + | SCOL tzidparam + | SCOL other_param + ; // 3.8.5.2 - Recurrence Date-Times rdate - : k_rdate rdtparam* COL rdtval (COMMA rdtval)* CRLF - ; + : k_rdate rdtparam* COL rdtval (COMMA rdtval)* CRLF + ; rdtparam - : SCOL k_value ASSIGN k_date_time - | SCOL k_value ASSIGN k_date - | SCOL k_value ASSIGN k_period - | SCOL tzidparam - | SCOL other_param - ; + : SCOL k_value ASSIGN k_date_time + | SCOL k_value ASSIGN k_date + | SCOL k_value ASSIGN k_period + | SCOL tzidparam + | SCOL other_param + ; rdtval - : date_time - | date - | period - ; + : date_time + | date + | period + ; date_time_date - : date_time - | date - ; + : date_time + | date + ; // 3.8.5.3 - Recurrence Rule rrule - : k_rrule (SCOL other_param)* COL recur CRLF - ; + : k_rrule (SCOL other_param)* COL recur CRLF + ; // 3.8.6.1 - Action action - : k_action (SCOL other_param)* COL actionvalue CRLF - ; + : k_action (SCOL other_param)* COL actionvalue CRLF + ; actionvalue - : k_audio - | k_display - | k_email - | iana_token - | x_name - ; + : k_audio + | k_display + | k_email + | iana_token + | x_name + ; // 3.8.6.2 - Repeat Count repeat_ - : k_repeat (SCOL other_param)* COL integer CRLF - ; + : k_repeat (SCOL other_param)* COL integer CRLF + ; // 3.8.6.3 - Trigger trigger - : k_trigger trigrel* COL dur_value CRLF - | k_trigger trigabs* COL date_time CRLF - ; + : k_trigger trigrel* COL dur_value CRLF + | k_trigger trigabs* COL date_time CRLF + ; trigrel - : SCOL k_value ASSIGN k_duration - | SCOL trigrelparam - | SCOL other_param - ; + : SCOL k_value ASSIGN k_duration + | SCOL trigrelparam + | SCOL other_param + ; trigabs - : SCOL k_value ASSIGN k_date_time - | SCOL other_param - ; + : SCOL k_value ASSIGN k_date_time + | SCOL other_param + ; // 3.8.7.1 - Date-Time Created created - : k_created (SCOL other_param)* COL date_time CRLF - ; + : k_created (SCOL other_param)* COL date_time CRLF + ; // 3.8.7.2 - Date-Time Stamp dtstamp - : k_dtstamp (SCOL other_param)* COL date_time CRLF - ; + : k_dtstamp (SCOL other_param)* COL date_time CRLF + ; // 3.8.7.3 - Last Modified last_mod - : k_last_modified (SCOL other_param)* COL date_time CRLF - ; + : k_last_modified (SCOL other_param)* COL date_time CRLF + ; // 3.8.7.4 - Sequence Number seq - : k_sequence (SCOL other_param)* COL integer CRLF - ; + : k_sequence (SCOL other_param)* COL integer CRLF + ; // 3.8.8.1 - IANA Properties iana_prop - : iana_token (SCOL icalparameter)* COL value CRLF - ; + : iana_token (SCOL icalparameter)* COL value CRLF + ; // 3.8.8.2 - Non-Standard Propertie x_prop - : x_name (SCOL icalparameter)* COL value CRLF - ; + : x_name (SCOL icalparameter)* COL value CRLF + ; // 3.8.8.3 - Request Status rstatus - : k_request_status rstatparam* COL statcode SCOL text (SCOL text)? - ; + : k_request_status rstatparam* COL statcode SCOL text (SCOL text)? + ; rstatparam - : SCOL languageparam - | SCOL other_param - ; + : SCOL languageparam + | SCOL other_param + ; statcode - : digit + DOT digit + (DOT digit +)? - ; + : digit+ DOT digit+ (DOT digit+)? + ; param_name - : iana_token - | x_name - ; + : iana_token + | x_name + ; param_value - : paramtext - | quoted_string - ; + : paramtext + | quoted_string + ; paramtext - : safe_char* - ; + : safe_char* + ; quoted_string - : DQUOTE qsafe_char* DQUOTE - ; + : DQUOTE qsafe_char* DQUOTE + ; // iCalendar identifier registered with IANA iana_token - : (alpha | MINUS) + - ; + : (alpha | MINUS)+ + ; // 3.2 icalparameter - : altrepparam - | cnparam - | cutypeparam - | delfromparam - | deltoparam - | dirparam - | encodingparam - | fmttypeparam - | fbtypeparam - | languageparam - | memberparam - | partstatparam - | rangeparam - | trigrelparam - | reltypeparam - | roleparam - | rsvpparam - | sentbyparam - | tzidparam - | valuetypeparam - | other_param - ; + : altrepparam + | cnparam + | cutypeparam + | delfromparam + | deltoparam + | dirparam + | encodingparam + | fmttypeparam + | fbtypeparam + | languageparam + | memberparam + | partstatparam + | rangeparam + | trigrelparam + | reltypeparam + | roleparam + | rsvpparam + | sentbyparam + | tzidparam + | valuetypeparam + | other_param + ; // 3.2.1 altrepparam - : k_altrep ASSIGN DQUOTE uri DQUOTE - ; + : k_altrep ASSIGN DQUOTE uri DQUOTE + ; // 3.2.2 cnparam - : k_cn ASSIGN param_value - ; + : k_cn ASSIGN param_value + ; // 3.2.3 cutypeparam - : k_cutype ASSIGN (k_individual | k_group | k_resource | k_room | k_unknown | x_name | iana_token) - ; + : k_cutype ASSIGN ( + k_individual + | k_group + | k_resource + | k_room + | k_unknown + | x_name + | iana_token + ) + ; // 3.2.4 delfromparam - : k_delegated_from ASSIGN DQUOTE cal_address DQUOTE (COMMA DQUOTE cal_address DQUOTE)* - ; + : k_delegated_from ASSIGN DQUOTE cal_address DQUOTE (COMMA DQUOTE cal_address DQUOTE)* + ; // 3.2.5 deltoparam - : k_delegated_to ASSIGN DQUOTE cal_address DQUOTE (COMMA DQUOTE cal_address DQUOTE)* - ; + : k_delegated_to ASSIGN DQUOTE cal_address DQUOTE (COMMA DQUOTE cal_address DQUOTE)* + ; // 3.2.6 dirparam - : k_dir ASSIGN DQUOTE uri DQUOTE - ; + : k_dir ASSIGN DQUOTE uri DQUOTE + ; // 3.2.7 encodingparam - : k_encoding ASSIGN (D8 k_bit | k_base D6 D4) - ; + : k_encoding ASSIGN (D8 k_bit | k_base D6 D4) + ; // 3.2.8 fmttypeparam - : k_fmttype ASSIGN type_name FSLASH subtype_name - ; + : k_fmttype ASSIGN type_name FSLASH subtype_name + ; // 3.2.9 fbtypeparam - : k_fbtype ASSIGN (k_free | k_busy | k_busy_unavailable | k_busy_tentative | x_name | iana_token) - ; + : k_fbtype ASSIGN ( + k_free + | k_busy + | k_busy_unavailable + | k_busy_tentative + | x_name + | iana_token + ) + ; // 3.2.10 languageparam - : k_language ASSIGN language - ; + : k_language ASSIGN language + ; // 3.2.11 memberparam - : k_member ASSIGN DQUOTE cal_address DQUOTE (COMMA DQUOTE cal_address DQUOTE)* - ; + : k_member ASSIGN DQUOTE cal_address DQUOTE (COMMA DQUOTE cal_address DQUOTE)* + ; // 3.2.12 partstatparam - : k_partstat ASSIGN (partstat_event | partstat_todo | partstat_jour) - ; + : k_partstat ASSIGN (partstat_event | partstat_todo | partstat_jour) + ; // 3.2.13 rangeparam - : k_range ASSIGN k_thisandfuture - ; + : k_range ASSIGN k_thisandfuture + ; // 3.2.14 trigrelparam - : k_related ASSIGN (k_start | k_end) - ; + : k_related ASSIGN (k_start | k_end) + ; // 3.2.15 reltypeparam - : k_reltype ASSIGN (k_parent | k_child | k_sibling | x_name | iana_token) - ; + : k_reltype ASSIGN (k_parent | k_child | k_sibling | x_name | iana_token) + ; // 3.2.16 roleparam - : k_role ASSIGN (k_chair | k_req_participant | k_opt_participant | k_non_participant | iana_token | x_name) - ; + : k_role ASSIGN ( + k_chair + | k_req_participant + | k_opt_participant + | k_non_participant + | iana_token + | x_name + ) + ; // 3.2.17 rsvpparam - : k_rsvp ASSIGN (k_true | k_false) - ; + : k_rsvp ASSIGN (k_true | k_false) + ; // 3.2.18 sentbyparam - : k_sent_by ASSIGN DQUOTE cal_address DQUOTE - ; + : k_sent_by ASSIGN DQUOTE cal_address DQUOTE + ; // 3.2.19 tzidparam - : k_tzid ASSIGN FSLASH? paramtext - ; + : k_tzid ASSIGN FSLASH? paramtext + ; // 3.2.20 valuetypeparam - : k_value ASSIGN valuetype - ; + : k_value ASSIGN valuetype + ; valuetype - : k_binary - | k_boolean - | k_cal_address - | k_date - | k_date_time - | k_duration - | k_float - | k_integer - | k_period - | k_recur - | k_text - | k_time - | k_uri - | k_utc_offset - | x_name - | iana_token - ; + : k_binary + | k_boolean + | k_cal_address + | k_date + | k_date_time + | k_duration + | k_float + | k_integer + | k_period + | k_recur + | k_text + | k_time + | k_uri + | k_utc_offset + | x_name + | iana_token + ; // 3.3.1 - A "BASE64" encoded character string, as defined by [RFC4648]. binary - : b_chars b_end? - ; + : b_chars b_end? + ; b_chars - : b_char* - ; + : b_char* + ; b_end - : ASSIGN ASSIGN? - ; + : ASSIGN ASSIGN? + ; // 3.3.2 bool_ - : k_true - | k_false - ; + : k_true + | k_false + ; // 3.3.3 cal_address - : uri - ; + : uri + ; // 3.3.4 date - : date_value - ; + : date_value + ; // 3.3.5 date_time - : date T time - ; + : date T time + ; // 3.3.6 dur_value - : MINUS P (dur_date | dur_time | dur_week) - | PLUS? P (dur_date | dur_time | dur_week) - ; + : MINUS P (dur_date | dur_time | dur_week) + | PLUS? P (dur_date | dur_time | dur_week) + ; // 3.3.7 float_num - : MINUS digits (DOT digits)? - | PLUS? digits (DOT digits)? - ; + : MINUS digits (DOT digits)? + | PLUS? digits (DOT digits)? + ; digits - : digit + - ; + : digit+ + ; // 3.3.8 integer - : MINUS digits - | PLUS? digits - ; + : MINUS digits + | PLUS? digits + ; // 3.3.9 period - : period_explicit - | period_start - ; + : period_explicit + | period_start + ; // 3.3.10 recur - : recur_rule_part (SCOL recur_rule_part)* - ; + : recur_rule_part (SCOL recur_rule_part)* + ; // 3.3.11 text - : (tsafe_char | COL | DQUOTE | ESCAPED_CHAR)* - ; + : (tsafe_char | COL | DQUOTE | ESCAPED_CHAR)* + ; // 3.3.12 time - : time_hour time_minute time_second Z? - ; + : time_hour time_minute time_second Z? + ; // 3.3.13 - As defined in Section 3 of [RFC3986]. uri - : qsafe_char + - ; + : qsafe_char+ + ; // 3.3.14 utc_offset - : time_numzone - ; + : time_numzone + ; // Applications MUST ignore x-param and iana-param values they don't // recognize. other_param - : iana_param - | x_param - ; + : iana_param + | x_param + ; // Some other IANA-registered iCalendar parameter. iana_param - : iana_token ASSIGN param_value (COMMA param_value)* - ; + : iana_token ASSIGN param_value (COMMA param_value)* + ; // A non-standard, experimental parameter. x_param - : x_name ASSIGN param_value (COMMA param_value)* - ; + : x_name ASSIGN param_value (COMMA param_value)* + ; // As defined in Section 4.2 of [RFC4288]. type_name - : reg_name - ; + : reg_name + ; // As defined in Section 4.2 of [RFC4288]. subtype_name - : reg_name - ; + : reg_name + ; // Between 1 and 127 chars allowed as defined in Section 4.2 of [RFC4288]. reg_name - : reg_name_char + - ; + : reg_name_char+ + ; // Loosely matched language (see [RFC5646]). language - : language_char + - ; + : language_char+ + ; partstat_event - : k_needs_action - | k_accepted - | k_declined - | k_tentative - | k_delegated - | x_name - | iana_token - ; + : k_needs_action + | k_accepted + | k_declined + | k_tentative + | k_delegated + | x_name + | iana_token + ; partstat_todo - : k_needs_action - | k_accepted - | k_declined - | k_tentative - | k_delegated - | k_completed - | k_in_process - | x_name - | iana_token - ; + : k_needs_action + | k_accepted + | k_declined + | k_tentative + | k_delegated + | k_completed + | k_in_process + | x_name + | iana_token + ; partstat_jour - : k_needs_action - | k_accepted - | k_declined - | x_name - | iana_token - ; + : k_needs_action + | k_accepted + | k_declined + | x_name + | iana_token + ; b_char - : alpha - | digit - | PLUS - | FSLASH - ; + : alpha + | digit + | PLUS + | FSLASH + ; date_value - : date_fullyear date_month date_mday - ; + : date_fullyear date_month date_mday + ; date_fullyear - : digits_2 digits_2 - ; + : digits_2 digits_2 + ; date_month - : digits_2 - ; + : digits_2 + ; date_mday - : digits_2 - ; + : digits_2 + ; time_hour - : digits_2 - ; + : digits_2 + ; time_minute - : digits_2 - ; + : digits_2 + ; time_second - : digits_2 - ; + : digits_2 + ; dur_date - : dur_day dur_time? - ; + : dur_day dur_time? + ; dur_day - : digit + D - ; + : digit+ D + ; dur_time - : T? (dur_hour | dur_minute | dur_second) - ; + : T? (dur_hour | dur_minute | dur_second) + ; dur_week - : digit + W - ; + : digit+ W + ; dur_hour - : digit + H dur_minute? - ; + : digit+ H dur_minute? + ; dur_minute - : digit + M dur_second? - ; + : digit+ M dur_second? + ; dur_second - : digit + S - ; + : digit+ S + ; period_explicit - : date_time FSLASH date_time - ; + : date_time FSLASH date_time + ; period_start - : date_time FSLASH dur_value - ; + : date_time FSLASH dur_value + ; recur_rule_part - : k_freq ASSIGN freq - | k_until ASSIGN enddate - | k_count ASSIGN count - | k_interval ASSIGN interval - | k_bysecond ASSIGN byseclist - | k_byminute ASSIGN byminlist - | k_byhour ASSIGN byhrlist - | k_byday ASSIGN bywdaylist - | k_bymonthday ASSIGN bymodaylist - | k_byyearday ASSIGN byyrdaylist - | k_byweekno ASSIGN bywknolist - | k_bymonth ASSIGN bymolist - | k_bysetpos ASSIGN bysplist - | k_wkst ASSIGN weekday - ; + : k_freq ASSIGN freq + | k_until ASSIGN enddate + | k_count ASSIGN count + | k_interval ASSIGN interval + | k_bysecond ASSIGN byseclist + | k_byminute ASSIGN byminlist + | k_byhour ASSIGN byhrlist + | k_byday ASSIGN bywdaylist + | k_bymonthday ASSIGN bymodaylist + | k_byyearday ASSIGN byyrdaylist + | k_byweekno ASSIGN bywknolist + | k_bymonth ASSIGN bymolist + | k_bysetpos ASSIGN bysplist + | k_wkst ASSIGN weekday + ; freq - : k_secondly - | k_minutely - | k_hourly - | k_daily - | k_weekly - | k_monthly - | k_yearly - ; + : k_secondly + | k_minutely + | k_hourly + | k_daily + | k_weekly + | k_monthly + | k_yearly + ; enddate - : date - | date_time - ; + : date + | date_time + ; count - : digits - ; + : digits + ; interval - : digits - ; + : digits + ; byseclist - : digits_1_2 (COMMA digits_1_2)* - ; + : digits_1_2 (COMMA digits_1_2)* + ; byminlist - : digits_1_2 (COMMA digits_1_2)* - ; + : digits_1_2 (COMMA digits_1_2)* + ; byhrlist - : digits_1_2 (COMMA digits_1_2)* - ; + : digits_1_2 (COMMA digits_1_2)* + ; bywdaylist - : weekdaynum (COMMA weekdaynum)* - ; + : weekdaynum (COMMA weekdaynum)* + ; weekdaynum - : ((PLUS | MINUS)? digits_1_2)? weekday - ; + : ((PLUS | MINUS)? digits_1_2)? weekday + ; weekday - : S U - | M O - | T U - | W E - | T H - | F R - | S A - ; + : S U + | M O + | T U + | W E + | T H + | F R + | S A + ; bymodaylist - : monthdaynum (COMMA monthdaynum)* - ; + : monthdaynum (COMMA monthdaynum)* + ; monthdaynum - : (PLUS | MINUS)? digits_1_2 - ; + : (PLUS | MINUS)? digits_1_2 + ; byyrdaylist - : yeardaynum (COMMA yeardaynum)* - ; + : yeardaynum (COMMA yeardaynum)* + ; yeardaynum - : (PLUS | MINUS)? ordyrday - ; + : (PLUS | MINUS)? ordyrday + ; ordyrday - : digit (digit digit?)? - ; + : digit (digit digit?)? + ; bywknolist - : weeknum (COMMA weeknum)* - ; + : weeknum (COMMA weeknum)* + ; weeknum - : (PLUS | MINUS)? digits_1_2 - ; + : (PLUS | MINUS)? digits_1_2 + ; bymolist - : digits_1_2 (COMMA digits_1_2)* - ; + : digits_1_2 (COMMA digits_1_2)* + ; bysplist - : yeardaynum (COMMA yeardaynum)* - ; + : yeardaynum (COMMA yeardaynum)* + ; digits_2 - : digit digit - ; + : digit digit + ; digits_1_2 - : digit digit? - ; + : digit digit? + ; // Any character except CONTROL, DQUOTE, ";", ":", "," safe_char - : ~ (CRLF | CONTROL | DQUOTE | SCOL | COL | COMMA) - ; + : ~ (CRLF | CONTROL | DQUOTE | SCOL | COL | COMMA) + ; // Any textual character value_char - : ~ (CRLF | CONTROL | ESCAPED_CHAR) - ; + : ~ (CRLF | CONTROL | ESCAPED_CHAR) + ; // Any character except CONTROL and DQUOTE qsafe_char - : ~ (CRLF | CONTROL | DQUOTE) - ; + : ~ (CRLF | CONTROL | DQUOTE) + ; // Any character except CONTROLs not needed by the current // character set, DQUOTE, ";", ":", "\", "," tsafe_char - : ~ (CRLF | CONTROL | DQUOTE | SCOL | COL | BSLASH | COMMA) - ; + : ~ (CRLF | CONTROL | DQUOTE | SCOL | COL | BSLASH | COMMA) + ; time_numzone - : (PLUS | MINUS) time_hour time_minute time_second? - ; + : (PLUS | MINUS) time_hour time_minute time_second? + ; reg_name_char - : alpha - | digit - | EXCLAMATION - | HASH - | DOLLAR - | AMP - | DOT - | PLUS - | MINUS - | CARET - | USCORE - ; + : alpha + | digit + | EXCLAMATION + | HASH + | DOLLAR + | AMP + | DOT + | PLUS + | MINUS + | CARET + | USCORE + ; language_char - : alpha - | digit - | MINUS - | COL - | WSP - ; + : alpha + | digit + | MINUS + | COL + | WSP + ; // Reserved for experimental use. x_name - : X (alpha_num alpha_num alpha_num + MINUS)? (alpha_num | MINUS) + - ; + : X (alpha_num alpha_num alpha_num+ MINUS)? (alpha_num | MINUS)+ + ; alpha_num - : alpha - | digit - ; + : alpha + | digit + ; // The digits: 0..9 digit - : D0 - | D1 - | D2 - | D3 - | D4 - | D5 - | D6 - | D7 - | D8 - | D9 - ; + : D0 + | D1 + | D2 + | D3 + | D4 + | D5 + | D6 + | D7 + | D8 + | D9 + ; // Any alpha char alpha - : A - | B - | C - | D - | E - | F - | G - | H - | I - | J - | K - | L - | M - | N - | O - | P - | Q - | R - | S - | T - | U - | V - | W - | X - | Y - | Z - ; + : A + | B + | C + | D + | E + | F + | G + | H + | I + | J + | K + | L + | M + | N + | O + | P + | Q + | R + | S + | T + | U + | V + | W + | X + | Y + | Z + ; // Case insensitive keywords k_accepted - : A C C E P T E D - ; + : A C C E P T E D + ; k_action - : A C T I O N - ; + : A C T I O N + ; k_address - : A D D R E S S - ; + : A D D R E S S + ; k_altrep - : A L T R E P - ; + : A L T R E P + ; k_attach - : A T T A C H - ; + : A T T A C H + ; k_attendee - : A T T E N D E E - ; + : A T T E N D E E + ; k_audio - : A U D I O - ; + : A U D I O + ; k_base - : B A S E - ; + : B A S E + ; k_begin - : B E G I N - ; + : B E G I N + ; k_binary - : B I N A R Y - ; + : B I N A R Y + ; k_bit - : B I T - ; + : B I T + ; k_boolean - : B O O L E A N - ; + : B O O L E A N + ; k_busy - : B U S Y - ; + : B U S Y + ; k_busy_unavailable - : B U S Y MINUS U N A V A I L A B L E - ; + : B U S Y MINUS U N A V A I L A B L E + ; k_busy_tentative - : B U S Y MINUS T E N T A T I V E - ; + : B U S Y MINUS T E N T A T I V E + ; k_byday - : B Y D A Y - ; + : B Y D A Y + ; k_byhour - : B Y H O U R - ; + : B Y H O U R + ; k_byminute - : B Y M I N U T E - ; + : B Y M I N U T E + ; k_bymonth - : B Y M O N T H - ; + : B Y M O N T H + ; k_bymonthday - : B Y M O N T H D A Y - ; + : B Y M O N T H D A Y + ; k_bysecond - : B Y S E C O N D - ; + : B Y S E C O N D + ; k_bysetpos - : B Y S E T P O S - ; + : B Y S E T P O S + ; k_byweekno - : B Y W E E K N O - ; + : B Y W E E K N O + ; k_byyearday - : B Y Y E A R D A Y - ; + : B Y Y E A R D A Y + ; k_cal_address - : C A L MINUS A D D R E S S - ; + : C A L MINUS A D D R E S S + ; k_calscale - : C A L S C A L E - ; + : C A L S C A L E + ; k_cancelled - : C A N C E L L E D - ; + : C A N C E L L E D + ; k_categories - : C A T E G O R I E S - ; + : C A T E G O R I E S + ; k_chair - : C H A I R - ; + : C H A I R + ; k_child - : C H I L D - ; + : C H I L D + ; k_class - : C L A S S - ; + : C L A S S + ; k_cn - : C N - ; + : C N + ; k_comment - : C O M M E N T - ; + : C O M M E N T + ; k_completed - : C O M P L E T E D - ; + : C O M P L E T E D + ; k_confidential - : C O N F I D E N T I A L - ; + : C O N F I D E N T I A L + ; k_confirmed - : C O N F I R M E D - ; + : C O N F I R M E D + ; k_contact - : C O N T A C T - ; + : C O N T A C T + ; k_count - : C O U N T - ; + : C O U N T + ; k_created - : C R E A T E D - ; + : C R E A T E D + ; k_cutype - : C U T Y P E - ; + : C U T Y P E + ; k_daily - : D A I L Y - ; + : D A I L Y + ; k_date - : D A T E - ; + : D A T E + ; k_date_time - : D A T E MINUS T I M E - ; + : D A T E MINUS T I M E + ; k_daylight - : D A Y L I G H T - ; + : D A Y L I G H T + ; k_declined - : D E C L I N E D - ; + : D E C L I N E D + ; k_delegated - : D E L E G A T E D - ; + : D E L E G A T E D + ; k_delegated_from - : D E L E G A T E D MINUS F R O M - ; + : D E L E G A T E D MINUS F R O M + ; k_delegated_to - : D E L E G A T E D MINUS T O - ; + : D E L E G A T E D MINUS T O + ; k_description - : D E S C R I P T I O N - ; + : D E S C R I P T I O N + ; k_dir - : D I R - ; + : D I R + ; k_display - : D I S P L A Y - ; + : D I S P L A Y + ; k_draft - : D R A F T - ; + : D R A F T + ; k_dtend - : D T E N D - ; + : D T E N D + ; k_dtstamp - : D T S T A M P - ; + : D T S T A M P + ; k_dtstart - : D T S T A R T - ; + : D T S T A R T + ; k_due - : D U E - ; + : D U E + ; k_duration - : D U R A T I O N - ; + : D U R A T I O N + ; k_email - : E M A I L - ; + : E M A I L + ; k_encoding - : E N C O D I N G - ; + : E N C O D I N G + ; k_end - : E N D - ; + : E N D + ; k_exdate - : E X D A T E - ; + : E X D A T E + ; k_false - : F A L S E - ; + : F A L S E + ; k_fbtype - : F B T Y P E - ; + : F B T Y P E + ; k_final - : F I N A L - ; + : F I N A L + ; k_float - : F L O A T - ; + : F L O A T + ; k_fmttype - : F M T T Y P E - ; + : F M T T Y P E + ; k_fr - : F R - ; + : F R + ; k_free - : F R E E - ; + : F R E E + ; k_freebusy - : F R E E B U S Y - ; + : F R E E B U S Y + ; k_freq - : F R E Q - ; + : F R E Q + ; k_geo - : G E O - ; + : G E O + ; k_gregorian - : G R E G O R I A N - ; + : G R E G O R I A N + ; k_group - : G R O U P - ; + : G R O U P + ; k_hourly - : H O U R L Y - ; + : H O U R L Y + ; k_in_process - : I N MINUS P R O C E S S - ; + : I N MINUS P R O C E S S + ; k_individual - : I N D I V I D U A L - ; + : I N D I V I D U A L + ; k_integer - : I N T E G E R - ; + : I N T E G E R + ; k_interval - : I N T E R V A L - ; + : I N T E R V A L + ; k_language - : L A N G U A G E - ; + : L A N G U A G E + ; k_last_modified - : L A S T MINUS M O D I F I E D - ; + : L A S T MINUS M O D I F I E D + ; k_location - : L O C A T I O N - ; + : L O C A T I O N + ; k_member - : M E M B E R - ; + : M E M B E R + ; k_method - : M E T H O D - ; + : M E T H O D + ; k_minutely - : M I N U T E L Y - ; + : M I N U T E L Y + ; k_mo - : M O - ; + : M O + ; k_monthly - : M O N T H L Y - ; + : M O N T H L Y + ; k_needs_action - : N E E D S MINUS A C T I O N - ; + : N E E D S MINUS A C T I O N + ; k_non_participant - : N O N MINUS P A R T I C I P A N T - ; + : N O N MINUS P A R T I C I P A N T + ; k_opaque - : O P A Q U E - ; + : O P A Q U E + ; k_opt_participant - : O P T MINUS P A R T I C I P A N T - ; + : O P T MINUS P A R T I C I P A N T + ; k_organizer - : O R G A N I Z E R - ; + : O R G A N I Z E R + ; k_parent - : P A R E N T - ; + : P A R E N T + ; k_participant - : P A R T I C I P A N T - ; + : P A R T I C I P A N T + ; k_partstat - : P A R T S T A T - ; + : P A R T S T A T + ; k_percent_complete - : P E R C E N T MINUS C O M P L E T E - ; + : P E R C E N T MINUS C O M P L E T E + ; k_period - : P E R I O D - ; + : P E R I O D + ; k_priority - : P R I O R I T Y - ; + : P R I O R I T Y + ; k_private - : P R I V A T E - ; + : P R I V A T E + ; k_process - : P R O C E S S - ; + : P R O C E S S + ; k_prodid - : P R O D I D - ; + : P R O D I D + ; k_public - : P U B L I C - ; + : P U B L I C + ; k_range - : R A N G E - ; + : R A N G E + ; k_rdate - : R D A T E - ; + : R D A T E + ; k_recur - : R E C U R - ; + : R E C U R + ; k_recurrence_id - : R E C U R R E N C E MINUS I D - ; + : R E C U R R E N C E MINUS I D + ; k_relat - : R E L A T - ; + : R E L A T + ; k_related - : R E L A T E D - ; + : R E L A T E D + ; k_related_to - : R E L A T E D MINUS T O - ; + : R E L A T E D MINUS T O + ; k_reltype - : R E L T Y P E - ; + : R E L T Y P E + ; k_repeat - : R E P E A T - ; + : R E P E A T + ; k_req_participant - : R E Q MINUS P A R T I C I P A N T - ; + : R E Q MINUS P A R T I C I P A N T + ; k_request_status - : R E Q U E S T MINUS S T A T U S - ; + : R E Q U E S T MINUS S T A T U S + ; k_resource - : R E S O U R C E - ; + : R E S O U R C E + ; k_resources - : R E S O U R C E S - ; + : R E S O U R C E S + ; k_role - : R O L E - ; + : R O L E + ; k_room - : R O O M - ; + : R O O M + ; k_rrule - : R R U L E - ; + : R R U L E + ; k_rsvp - : R S V P - ; + : R S V P + ; k_sa - : S A - ; + : S A + ; k_secondly - : S E C O N D L Y - ; + : S E C O N D L Y + ; k_sent_by - : S E N T MINUS B Y - ; + : S E N T MINUS B Y + ; k_sequence - : S E Q U E N C E - ; + : S E Q U E N C E + ; k_sibling - : S I B L I N G - ; + : S I B L I N G + ; k_standard - : S T A N D A R D - ; + : S T A N D A R D + ; k_start - : S T A R T - ; + : S T A R T + ; k_status - : S T A T U S - ; + : S T A T U S + ; k_su - : S U - ; + : S U + ; k_summary - : S U M M A R Y - ; + : S U M M A R Y + ; k_tentative - : T E N T A T I V E - ; + : T E N T A T I V E + ; k_text - : T E X T - ; + : T E X T + ; k_th - : T H - ; + : T H + ; k_thisandfuture - : T H I S A N D F U T U R E - ; + : T H I S A N D F U T U R E + ; k_time - : T I M E - ; + : T I M E + ; k_transp - : T R A N S P - ; + : T R A N S P + ; k_transparent - : T R A N S P A R E N T - ; + : T R A N S P A R E N T + ; k_trigger - : T R I G G E R - ; + : T R I G G E R + ; k_true - : T R U E - ; + : T R U E + ; k_tu - : T U - ; + : T U + ; k_tzid - : T Z I D - ; + : T Z I D + ; k_tzname - : T Z N A M E - ; + : T Z N A M E + ; k_tzoffsetfrom - : T Z O F F S E T F R O M - ; + : T Z O F F S E T F R O M + ; k_tzoffsetto - : T Z O F F S E T T O - ; + : T Z O F F S E T T O + ; k_tzurl - : T Z U R L - ; + : T Z U R L + ; k_uid - : U I D - ; + : U I D + ; k_unknown - : U N K N O W N - ; + : U N K N O W N + ; k_until - : U N T I L - ; + : U N T I L + ; k_uri - : U R I - ; + : U R I + ; k_url - : U R L - ; + : U R L + ; k_utc_offset - : U T C MINUS O F F S E T - ; + : U T C MINUS O F F S E T + ; k_valarm - : V A L A R M - ; + : V A L A R M + ; k_value - : V A L U E - ; + : V A L U E + ; k_vcalendar - : V C A L E N D A R - ; + : V C A L E N D A R + ; k_version - : V E R S I O N - ; + : V E R S I O N + ; k_vevent - : V E V E N T - ; + : V E V E N T + ; k_vfreebusy - : V F R E E B U S Y - ; + : V F R E E B U S Y + ; k_vjournal - : V J O U R N A L - ; + : V J O U R N A L + ; k_vtimezone - : V T I M E Z O N E - ; + : V T I M E Z O N E + ; k_vtodo - : V T O D O - ; + : V T O D O + ; k_we - : W E - ; + : W E + ; k_weekly - : W E E K L Y - ; + : W E E K L Y + ; k_wkst - : W K S T - ; + : W K S T + ; k_yearly - : Y E A R L Y - ; + : Y E A R L Y + ; ////////////////////////////// lexer rules ////////////////////////////// LINE_FOLD - : CRLF WSP -> skip - ; - + : CRLF WSP -> skip + ; WSP - : ' ' | '\t' - ; - + : ' ' + | '\t' + ; ESCAPED_CHAR - : '\\' (CRLF WSP)? '\\' | '\\' (CRLF WSP)? ';' | '\\' (CRLF WSP)? ',' | '\\' (CRLF WSP)? N - ; - + : '\\' (CRLF WSP)? '\\' + | '\\' (CRLF WSP)? ';' + | '\\' (CRLF WSP)? ',' + | '\\' (CRLF WSP)? N + ; CRLF - : '\r'? '\n' | '\r' - ; + : '\r'? '\n' + | '\r' + ; // All the ASCII controls except HTAB and CRLF CONTROL - : [\u0000-\u0008] | [\u000B-\u000C] | [\u000E-\u001F] | [\u007F] - ; - + : [\u0000-\u0008] + | [\u000B-\u000C] + | [\u000E-\u001F] + | [\u007F] + ; A - : [aA] - ; - + : [aA] + ; B - : [bB] - ; - + : [bB] + ; C - : [cC] - ; - + : [cC] + ; D - : [dD] - ; - + : [dD] + ; E - : [eE] - ; - + : [eE] + ; F - : [fF] - ; - + : [fF] + ; G - : [gG] - ; - + : [gG] + ; H - : [hH] - ; - + : [hH] + ; I - : [iI] - ; - + : [iI] + ; J - : [jJ] - ; - + : [jJ] + ; K - : [kK] - ; - + : [kK] + ; L - : [lL] - ; - + : [lL] + ; M - : [mM] - ; - + : [mM] + ; N - : [nN] - ; - + : [nN] + ; O - : [oO] - ; - + : [oO] + ; P - : [pP] - ; - + : [pP] + ; Q - : [qQ] - ; - + : [qQ] + ; R - : [rR] - ; - + : [rR] + ; S - : [sS] - ; - + : [sS] + ; T - : [tT] - ; - + : [tT] + ; U - : [uU] - ; - + : [uU] + ; V - : [vV] - ; - + : [vV] + ; W - : [wW] - ; - + : [wW] + ; X - : [xX] - ; - + : [xX] + ; Y - : [yY] - ; - + : [yY] + ; Z - : [zZ] - ; - + : [zZ] + ; EXCLAMATION - : '!' - ; - + : '!' + ; DQUOTE - : '"' - ; - + : '"' + ; HASH - : '#' - ; - + : '#' + ; DOLLAR - : '$' - ; - + : '$' + ; X25 - : '%' - ; - + : '%' + ; AMP - : '&' - ; - + : '&' + ; X27 - : '\'' - ; - + : '\'' + ; X28 - : '(' - ; - + : '(' + ; X29 - : ')' - ; - + : ')' + ; X2A - : '*' - ; - + : '*' + ; PLUS - : '+' - ; - + : '+' + ; COMMA - : ',' - ; - + : ',' + ; MINUS - : '-' - ; - + : '-' + ; DOT - : '.' - ; - + : '.' + ; FSLASH - : '/' - ; - + : '/' + ; D0 - : '0' - ; - + : '0' + ; D1 - : '1' - ; - + : '1' + ; D2 - : '2' - ; - + : '2' + ; D3 - : '3' - ; - + : '3' + ; D4 - : '4' - ; - + : '4' + ; D5 - : '5' - ; - + : '5' + ; D6 - : '6' - ; - + : '6' + ; D7 - : '7' - ; - + : '7' + ; D8 - : '8' - ; - + : '8' + ; D9 - : '9' - ; - + : '9' + ; COL - : ':' - ; - + : ':' + ; SCOL - : ';' - ; - + : ';' + ; X3C - : '<' - ; - + : '<' + ; ASSIGN - : '=' - ; - + : '=' + ; X3E - : '>' - ; - + : '>' + ; X3F - : '?' - ; - + : '?' + ; X40 - : '@' - ; - + : '@' + ; X5B - : '[' - ; - + : '[' + ; BSLASH - : '\\' - ; - + : '\\' + ; X5D - : ']' - ; - + : ']' + ; CARET - : '^' - ; - + : '^' + ; USCORE - : '_' - ; - + : '_' + ; X60 - : '`' - ; - + : '`' + ; X7B - : '{' - ; - + : '{' + ; X7C - : '|' - ; - + : '|' + ; X7D - : '}' - ; - + : '}' + ; X7E - : '~' - ; - + : '~' + ; NON_US_ASCII - : . - ; + : . + ; \ No newline at end of file diff --git a/icon/icon.g4 b/icon/icon.g4 index 15d30fcb17..670e0e445b 100644 --- a/icon/icon.g4 +++ b/icon/icon.g4 @@ -30,336 +30,334 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar icon; start_ - : prog EOF - ; + : prog EOF + ; prog - : declaration - | (declaration prog) - ; + : declaration + | (declaration prog) + ; endOfExpr - : ';' - ; + : ';' + ; declaration - : link_declaration - | global_declaration - | record_declaration - | procedure_declaration - ; + : link_declaration + | global_declaration + | record_declaration + | procedure_declaration + ; link_declaration - : 'link' link_list - ; + : 'link' link_list + ; link_list - : file_name - | file_name ',' link_list - ; + : file_name + | file_name ',' link_list + ; file_name - : identifier - | string_literal - ; + : identifier + | string_literal + ; global_declaration - : 'global' identifier_list - ; + : 'global' identifier_list + ; identifier_list - : identifier - | identifier_list ',' identifier - ; + : identifier + | identifier_list ',' identifier + ; record_declaration - : 'record' identifier '(' field_list_opt ')' - ; + : 'record' identifier '(' field_list_opt ')' + ; field_list_opt - : field_list - ; + : field_list + ; field_list - : field_name - | field_list ',' field_name - ; + : field_name + | field_list ',' field_name + ; field_name - : identifier - ; + : identifier + ; procedure_declaration - : proc_header locals_opt? initial_opt? expression_sequence 'end' - ; + : proc_header locals_opt? initial_opt? expression_sequence 'end' + ; proc_header - : 'procedure' identifier '(' parameter_list_opt? ')' - ; + : 'procedure' identifier '(' parameter_list_opt? ')' + ; parameter_list_opt - : parameter_list - ; + : parameter_list + ; parameter_list - : (identifier) - | (identifier '[' ']') - | (identifier ',' parameter_list) - ; + : (identifier) + | (identifier '[' ']') + | (identifier ',' parameter_list) + ; locals_opt - : localz - ; + : localz + ; localz - : local_specification identifier_list - | local_specification identifier_list endOfExpr localz - ; + : local_specification identifier_list + | local_specification identifier_list endOfExpr localz + ; local_specification - : 'local' - | 'static' - ; + : 'local' + | 'static' + ; initial_opt - : 'initial' expression endOfExpr - | - ; + : 'initial' expression endOfExpr + | + ; expression_sequence - : expression_opt - | expression_sequence endOfExpr expression_opt - ; + : expression_opt + | expression_sequence endOfExpr expression_opt + ; expression_opt - : expression - ; + : expression + ; expression - : 'break' expression_opt - | 'create' expression - | 'return' expression_opt - | 'suspend' expression_opt suspend_do_clause_opt - | 'fail' - | 'next' - | 'case' expression 'of' '{' case_list '}' - | 'if' expression 'then' expression else_clause_opt - | 'repeat' expression - | 'while' expression while_do_clause_opt - | 'until' expression until_do_clause_opt - | 'every' expression every_do_clause_opt - | expr1 - ; + : 'break' expression_opt + | 'create' expression + | 'return' expression_opt + | 'suspend' expression_opt suspend_do_clause_opt + | 'fail' + | 'next' + | 'case' expression 'of' '{' case_list '}' + | 'if' expression 'then' expression else_clause_opt + | 'repeat' expression + | 'while' expression while_do_clause_opt + | 'until' expression until_do_clause_opt + | 'every' expression every_do_clause_opt + | expr1 + ; suspend_do_clause_opt - : 'do' expression - ; + : 'do' expression + ; while_do_clause_opt - : 'do' expression - ; + : 'do' expression + ; until_do_clause_opt - : 'do' expression - ; + : 'do' expression + ; every_do_clause_opt - : 'do' expression - ; + : 'do' expression + ; else_clause_opt - : 'else' expression - ; + : 'else' expression + ; case_list - : case_clause - | case_list endOfExpr case_clause - ; + : case_clause + | case_list endOfExpr case_clause + ; case_clause - : expression ':' expression - | 'default' ':' expression - ; + : expression ':' expression + | 'default' ':' expression + ; expr1 - : expr1 '&' expr2 - | expr2 - ; + : expr1 '&' expr2 + | expr2 + ; expr2 - : expr2 '?' expr3 - | expr3 - ; + : expr2 '?' expr3 + | expr3 + ; expr3 - : expr4 ':=' expr3 - | expr4 ':=:' expr3 - | expr4 '<-' expr3 - | expr4 '<->' expr3 - | expr4 - ; + : expr4 ':=' expr3 + | expr4 ':=:' expr3 + | expr4 '<-' expr3 + | expr4 '<->' expr3 + | expr4 + ; expr4 - : expr4 'to' expr5 - | expr4 'to' expr5 'by' expr5 - | expr5 - ; + : expr4 'to' expr5 + | expr4 'to' expr5 'by' expr5 + | expr5 + ; expr5 - : expr5 '|' expr6 - | expr6 - ; + : expr5 '|' expr6 + | expr6 + ; expr6 - : expr6 '<' expr7 - | expr6 '<=' expr7 - | expr6 '=' expr7 - | expr6 '>=' expr7 - | expr6 '>' expr7 - | expr6 '~=' expr7 - | expr6 '<<' expr7 - | expr6 '<<=' expr7 - | expr6 '==' expr7 - | expr6 '>>=' expr7 - | expr6 '>>' expr7 - | expr6 '~==' expr7 - | expr6 '===' expr7 - | expr6 '~===' expr7 - | expr7 - ; + : expr6 '<' expr7 + | expr6 '<=' expr7 + | expr6 '=' expr7 + | expr6 '>=' expr7 + | expr6 '>' expr7 + | expr6 '~=' expr7 + | expr6 '<<' expr7 + | expr6 '<<=' expr7 + | expr6 '==' expr7 + | expr6 '>>=' expr7 + | expr6 '>>' expr7 + | expr6 '~==' expr7 + | expr6 '===' expr7 + | expr6 '~===' expr7 + | expr7 + ; expr7 - : expr7 '||' expr8 - | expr7 '|||' expr8 - | expr8 - ; + : expr7 '||' expr8 + | expr7 '|||' expr8 + | expr8 + ; expr8 - : expr8 '+' expr9 - | expr8 '-' expr9 - | expr8 '++' expr9 - | expr8 '--' expr9 - | expr9 - ; + : expr8 '+' expr9 + | expr8 '-' expr9 + | expr8 '++' expr9 + | expr8 '--' expr9 + | expr9 + ; expr9 - : expr9 '*' expr10 - | expr9 '/' expr10 - | expr9 '%' expr10 - | expr9 '**' expr10 - | expr10 - ; + : expr9 '*' expr10 + | expr9 '/' expr10 + | expr9 '%' expr10 + | expr9 '**' expr10 + | expr10 + ; expr10 - : expr11 '^' expr10 - | expr11 - ; + : expr11 '^' expr10 + | expr11 + ; expr11 - : expr11 '\\' expr12 - | expr11 '@' expr12 - | expr11 '!' expr12 - | expr12 - ; + : expr11 '\\' expr12 + | expr11 '@' expr12 + | expr11 '!' expr12 + | expr12 + ; expr12 - : 'not' expr12 - | '|' expr12 - | '!' expr12 - | '*' expr12 - | '+' expr12 - | '-' expr12 - | '.' expr12 - | '/' expr12 - | '\\' expr12 - | '=' expr12 - | '?' expr12 - | '~' expr12 - | '@' expr12 - | '^' expr12 - | expr13 - ; + : 'not' expr12 + | '|' expr12 + | '!' expr12 + | '*' expr12 + | '+' expr12 + | '-' expr12 + | '.' expr12 + | '/' expr12 + | '\\' expr12 + | '=' expr12 + | '?' expr12 + | '~' expr12 + | '@' expr12 + | '^' expr12 + | expr13 + ; expr13 - : '(' expression_list ')' - | '{' expression_sequence '}' - | '[' expression_list ']' - | expr13 '.' field_name - | expr13 '(' expression_list ')' - | expr13 '{' expression_list '}' - | expr13 '[' subscript_list ']' - | identifier - | keyword - | literal - ; + : '(' expression_list ')' + | '{' expression_sequence '}' + | '[' expression_list ']' + | expr13 '.' field_name + | expr13 '(' expression_list ')' + | expr13 '{' expression_list '}' + | expr13 '[' subscript_list ']' + | identifier + | keyword + | literal + ; expression_list - : expression_opt - | expression_list ',' expression_opt - ; + : expression_opt + | expression_list ',' expression_opt + ; subscript_list - : subscript_ - | subscript_list ',' subscript_ - ; + : subscript_ + | subscript_list ',' subscript_ + ; subscript_ - : expression - | expression ':' expression - | expression '+:' expression - | expression '-:' expression - ; + : expression + | expression ':' expression + | expression '+:' expression + | expression '-:' expression + ; keyword - : '&' identifier - ; + : '&' identifier + ; identifier - : IDENTIFIER - ; + : IDENTIFIER + ; literal - : string_literal - | integer_literal - | real_literal - ; + : string_literal + | integer_literal + | real_literal + ; string_literal - : STRING_LITERAL - ; + : STRING_LITERAL + ; real_literal - : REAL_LITERAL - ; + : REAL_LITERAL + ; integer_literal - : INTEGER_LITERAL - ; - + : INTEGER_LITERAL + ; IDENTIFIER - : [a-zA-Z] [a-zA-Z0-9]* - ; - + : [a-zA-Z] [a-zA-Z0-9]* + ; INTEGER_LITERAL - : ('0' .. '9') + - ; - + : ('0' .. '9')+ + ; REAL_LITERAL - : ('0' .. '9')* '.' ('0' .. '9') + (('e' | 'E') ('0' .. '9') +)* - ; - + : ('0' .. '9')* '.' ('0' .. '9')+ (('e' | 'E') ('0' .. '9')+)* + ; STRING_LITERAL - : '"' ~ ["]* '"' - ; - + : '"' ~ ["]* '"' + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/idl/IDL.g4 b/idl/IDL.g4 index f3687f2e17..f4b36062d5 100644 --- a/idl/IDL.g4 +++ b/idl/IDL.g4 @@ -38,1426 +38,1309 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. updates by Oliver Kellogg. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar IDL; specification - : import_decl* definition + EOF - ; + : import_decl* definition+ EOF + ; definition - : annapps - ( type_decl SEMICOLON - | const_decl SEMICOLON - | except_decl SEMICOLON - | interface_or_forward_decl SEMICOLON - | module SEMICOLON - | value SEMICOLON - | type_id_decl SEMICOLON - | type_prefix_decl SEMICOLON - | event SEMICOLON - | component SEMICOLON - | home_decl SEMICOLON - | annotation_decl SEMICOLON - ) - ; + : annapps ( + type_decl SEMICOLON + | const_decl SEMICOLON + | except_decl SEMICOLON + | interface_or_forward_decl SEMICOLON + | module SEMICOLON + | value SEMICOLON + | type_id_decl SEMICOLON + | type_prefix_decl SEMICOLON + | event SEMICOLON + | component SEMICOLON + | home_decl SEMICOLON + | annotation_decl SEMICOLON + ) + ; module - : KW_MODULE identifier LEFT_BRACE definition + RIGHT_BRACE - ; + : KW_MODULE identifier LEFT_BRACE definition+ RIGHT_BRACE + ; interface_or_forward_decl - : annapps - ( interface_decl - | forward_decl - ) - ; + : annapps (interface_decl | forward_decl) + ; interface_decl - : interface_header LEFT_BRACE interface_body RIGHT_BRACE - ; + : interface_header LEFT_BRACE interface_body RIGHT_BRACE + ; forward_decl - : (KW_ABSTRACT | KW_LOCAL)? KW_INTERFACE identifier - ; + : (KW_ABSTRACT | KW_LOCAL)? KW_INTERFACE identifier + ; interface_header - : (KW_ABSTRACT | KW_LOCAL)? KW_INTERFACE identifier (interface_inheritance_spec)? - ; + : (KW_ABSTRACT | KW_LOCAL)? KW_INTERFACE identifier (interface_inheritance_spec)? + ; interface_body - : export_* - ; + : export_* + ; export_ - : annapps - ( type_decl SEMICOLON - | const_decl SEMICOLON - | except_decl SEMICOLON - | attr_decl SEMICOLON - | op_decl SEMICOLON - | type_id_decl SEMICOLON - | type_prefix_decl SEMICOLON - ) - ; + : annapps ( + type_decl SEMICOLON + | const_decl SEMICOLON + | except_decl SEMICOLON + | attr_decl SEMICOLON + | op_decl SEMICOLON + | type_id_decl SEMICOLON + | type_prefix_decl SEMICOLON + ) + ; interface_inheritance_spec - : COLON interface_name (COMMA interface_name)* - ; + : COLON interface_name (COMMA interface_name)* + ; interface_name - : a_scoped_name - ; + : a_scoped_name + ; // scoped_name with optional prefixed annotations a_scoped_name - : annapps scoped_name - ; + : annapps scoped_name + ; scoped_name - : (DOUBLE_COLON)? ID (DOUBLE_COLON ID)* - ; + : (DOUBLE_COLON)? ID (DOUBLE_COLON ID)* + ; value - : annapps - (value_decl | value_abs_decl | value_box_decl | value_forward_decl) - ; - + : annapps (value_decl | value_abs_decl | value_box_decl | value_forward_decl) + ; + value_forward_decl - : (KW_ABSTRACT)? KW_VALUETYPE identifier - ; + : (KW_ABSTRACT)? KW_VALUETYPE identifier + ; value_box_decl - : KW_VALUETYPE identifier type_spec - ; + : KW_VALUETYPE identifier type_spec + ; value_abs_decl - : KW_ABSTRACT KW_VALUETYPE identifier value_inheritance_spec LEFT_BRACE export_* RIGHT_BRACE - ; + : KW_ABSTRACT KW_VALUETYPE identifier value_inheritance_spec LEFT_BRACE export_* RIGHT_BRACE + ; value_decl - : value_header LEFT_BRACE value_element* RIGHT_BRACE - ; + : value_header LEFT_BRACE value_element* RIGHT_BRACE + ; value_header - : (KW_CUSTOM)? KW_VALUETYPE identifier value_inheritance_spec - ; + : (KW_CUSTOM)? KW_VALUETYPE identifier value_inheritance_spec + ; value_inheritance_spec - : (COLON (KW_TRUNCATABLE)? value_name (COMMA value_name)*)? (KW_SUPPORTS interface_name (COMMA interface_name)*)? - ; + : (COLON (KW_TRUNCATABLE)? value_name (COMMA value_name)*)? ( + KW_SUPPORTS interface_name (COMMA interface_name)* + )? + ; value_name - : a_scoped_name - ; + : a_scoped_name + ; value_element - : (export_ | state_member | init_decl) - ; + : (export_ | state_member | init_decl) + ; state_member - : annapps ( KW_PUBLIC annapps | KW_PRIVATE annapps ) type_spec declarators SEMICOLON - ; + : annapps (KW_PUBLIC annapps | KW_PRIVATE annapps) type_spec declarators SEMICOLON + ; init_decl - : annapps KW_FACTORY identifier LEFT_BRACKET (init_param_decls)? RIGHT_BRACKET (raises_expr)? SEMICOLON - ; + : annapps KW_FACTORY identifier LEFT_BRACKET (init_param_decls)? RIGHT_BRACKET (raises_expr)? SEMICOLON + ; init_param_decls - : init_param_decl (COMMA init_param_decl)* - ; + : init_param_decl (COMMA init_param_decl)* + ; init_param_decl - : annapps init_param_attribute annapps param_type_spec annapps simple_declarator - ; + : annapps init_param_attribute annapps param_type_spec annapps simple_declarator + ; init_param_attribute - : KW_IN - ; + : KW_IN + ; const_decl - : KW_CONST const_type identifier EQUAL const_exp - ; + : KW_CONST const_type identifier EQUAL const_exp + ; const_type - : annapps - ( integer_type - | char_type - | wide_char_type - | boolean_type - | floating_pt_type - | string_type - | wide_string_type - | fixed_pt_const_type - | scoped_name - | octet_type - ) - ; + : annapps ( + integer_type + | char_type + | wide_char_type + | boolean_type + | floating_pt_type + | string_type + | wide_string_type + | fixed_pt_const_type + | scoped_name + | octet_type + ) + ; const_exp - : or_expr - ; + : or_expr + ; or_expr - : xor_expr (PIPE xor_expr)* - ; + : xor_expr (PIPE xor_expr)* + ; xor_expr - : and_expr (CARET and_expr)* - ; + : and_expr (CARET and_expr)* + ; and_expr - : shift_expr (AMPERSAND shift_expr)* - ; + : shift_expr (AMPERSAND shift_expr)* + ; shift_expr - : add_expr ((RIGHT_SHIFT | LEFT_SHIFT) add_expr)* - ; + : add_expr ((RIGHT_SHIFT | LEFT_SHIFT) add_expr)* + ; add_expr - : mult_expr ((PLUS | MINUS) mult_expr)* - ; + : mult_expr ((PLUS | MINUS) mult_expr)* + ; mult_expr - : unary_expr ((STAR | SLASH | PERCENT) unary_expr)* - ; + : unary_expr ((STAR | SLASH | PERCENT) unary_expr)* + ; unary_expr - : unary_operator primary_expr - | primary_expr - ; + : unary_operator primary_expr + | primary_expr + ; unary_operator - : (MINUS | PLUS | TILDE) - ; + : (MINUS | PLUS | TILDE) + ; primary_expr - : scoped_name - | literal - | LEFT_BRACKET const_exp RIGHT_BRACKET - ; + : scoped_name + | literal + | LEFT_BRACKET const_exp RIGHT_BRACKET + ; literal - : (HEX_LITERAL | INTEGER_LITERAL | OCTAL_LITERAL | STRING_LITERAL | WIDE_STRING_LITERAL | CHARACTER_LITERAL | WIDE_CHARACTER_LITERAL | FIXED_PT_LITERAL | FLOATING_PT_LITERAL | BOOLEAN_LITERAL) - ; + : ( + HEX_LITERAL + | INTEGER_LITERAL + | OCTAL_LITERAL + | STRING_LITERAL + | WIDE_STRING_LITERAL + | CHARACTER_LITERAL + | WIDE_CHARACTER_LITERAL + | FIXED_PT_LITERAL + | FLOATING_PT_LITERAL + | BOOLEAN_LITERAL + ) + ; positive_int_const - : const_exp - ; + : const_exp + ; type_decl - : KW_TYPEDEF annapps type_declarator - | struct_type - | union_type - | enum_type - | bitset_type - | bitmask_type - | KW_NATIVE annapps simple_declarator - | constr_forward_decl - ; + : KW_TYPEDEF annapps type_declarator + | struct_type + | union_type + | enum_type + | bitset_type + | bitmask_type + | KW_NATIVE annapps simple_declarator + | constr_forward_decl + ; type_declarator - : type_spec declarators - ; + : type_spec declarators + ; type_spec - : simple_type_spec - | constr_type_spec - ; + : simple_type_spec + | constr_type_spec + ; simple_type_spec - : base_type_spec - | template_type_spec - | scoped_name - ; + : base_type_spec + | template_type_spec + | scoped_name + ; bitfield_type_spec - : integer_type - | boolean_type - | octet_type - ; + : integer_type + | boolean_type + | octet_type + ; base_type_spec - : floating_pt_type - | integer_type - | char_type - | wide_char_type - | boolean_type - | octet_type - | any_type - | object_type - | value_base_type - ; + : floating_pt_type + | integer_type + | char_type + | wide_char_type + | boolean_type + | octet_type + | any_type + | object_type + | value_base_type + ; template_type_spec - : sequence_type - | set_type - | map_type - | string_type - | wide_string_type - | fixed_pt_type - ; + : sequence_type + | set_type + | map_type + | string_type + | wide_string_type + | fixed_pt_type + ; constr_type_spec - : struct_type - | union_type - | enum_type - | bitset_type - | bitmask_type - ; + : struct_type + | union_type + | enum_type + | bitset_type + | bitmask_type + ; simple_declarators - : identifier (COMMA identifier)* - ; + : identifier (COMMA identifier)* + ; declarators - : declarator (COMMA declarator)* - ; + : declarator (COMMA declarator)* + ; declarator - : annapps - ( simple_declarator - | complex_declarator - ) - ; + : annapps (simple_declarator | complex_declarator) + ; simple_declarator - : ID - ; + : ID + ; complex_declarator - : array_declarator - ; + : array_declarator + ; floating_pt_type - : (KW_FLOAT | KW_DOUBLE | KW_LONG KW_DOUBLE) - ; + : (KW_FLOAT | KW_DOUBLE | KW_LONG KW_DOUBLE) + ; integer_type - : signed_int - | unsigned_int - ; + : signed_int + | unsigned_int + ; signed_int - : signed_short_int - | signed_long_int - | signed_longlong_int - | signed_tiny_int - ; + : signed_short_int + | signed_long_int + | signed_longlong_int + | signed_tiny_int + ; signed_tiny_int - : KW_INT8 - ; + : KW_INT8 + ; signed_short_int - : KW_SHORT - | KW_INT16 - ; + : KW_SHORT + | KW_INT16 + ; signed_long_int - : KW_LONG - | KW_INT32 - ; + : KW_LONG + | KW_INT32 + ; signed_longlong_int - : KW_LONG KW_LONG - | KW_INT64 - ; + : KW_LONG KW_LONG + | KW_INT64 + ; unsigned_int - : unsigned_short_int - | unsigned_long_int - | unsigned_longlong_int - | unsigned_tiny_int - ; + : unsigned_short_int + | unsigned_long_int + | unsigned_longlong_int + | unsigned_tiny_int + ; unsigned_tiny_int - : KW_UINT8 - ; + : KW_UINT8 + ; unsigned_short_int - : KW_UNSIGNED KW_SHORT - | KW_UINT16 - ; + : KW_UNSIGNED KW_SHORT + | KW_UINT16 + ; unsigned_long_int - : KW_UNSIGNED KW_LONG - | KW_UINT32 - ; + : KW_UNSIGNED KW_LONG + | KW_UINT32 + ; unsigned_longlong_int - : KW_UNSIGNED KW_LONG KW_LONG - | KW_UINT64 - ; + : KW_UNSIGNED KW_LONG KW_LONG + | KW_UINT64 + ; char_type - : KW_CHAR - ; + : KW_CHAR + ; wide_char_type - : KW_WCHAR - ; + : KW_WCHAR + ; boolean_type - : KW_BOOLEAN - ; + : KW_BOOLEAN + ; octet_type - : KW_OCTET - ; + : KW_OCTET + ; any_type - : KW_ANY - ; + : KW_ANY + ; object_type - : KW_OBJECT - ; + : KW_OBJECT + ; annotation_decl - : annotation_def - | annotation_forward_dcl - ; + : annotation_def + | annotation_forward_dcl + ; annotation_def - : annotation_header LEFT_BRACE annotation_body RIGHT_BRACE - ; + : annotation_header LEFT_BRACE annotation_body RIGHT_BRACE + ; annotation_header - : KW_AT_ANNOTATION identifier (annotation_inheritance_spec)? - ; + : KW_AT_ANNOTATION identifier (annotation_inheritance_spec)? + ; annotation_inheritance_spec - : COLON scoped_name - ; + : COLON scoped_name + ; annotation_body - : ( annotation_member - | enum_type SEMICOLON - | const_decl SEMICOLON - | KW_TYPEDEF type_declarator SEMICOLON - )* - ; + : ( + annotation_member + | enum_type SEMICOLON + | const_decl SEMICOLON + | KW_TYPEDEF type_declarator SEMICOLON + )* + ; annotation_member - : const_type simple_declarator (KW_DEFAULT const_exp)? SEMICOLON - ; + : const_type simple_declarator (KW_DEFAULT const_exp)? SEMICOLON + ; annotation_forward_dcl - : KW_AT_ANNOTATION scoped_name - ; + : KW_AT_ANNOTATION scoped_name + ; bitset_type - : KW_BITSET identifier (COLON scoped_name)? LEFT_BRACE bitfield RIGHT_BRACE - ; + : KW_BITSET identifier (COLON scoped_name)? LEFT_BRACE bitfield RIGHT_BRACE + ; bitfield - : ( bitfield_spec (simple_declarators)? SEMICOLON )+ - ; + : (bitfield_spec (simple_declarators)? SEMICOLON)+ + ; bitfield_spec - : annapps KW_BITFIELD LEFT_ANG_BRACKET positive_int_const (COMMA bitfield_type_spec)? RIGHT_ANG_BRACKET - ; + : annapps KW_BITFIELD LEFT_ANG_BRACKET positive_int_const (COMMA bitfield_type_spec)? RIGHT_ANG_BRACKET + ; bitmask_type - : KW_BITMASK identifier LEFT_BRACE bit_values RIGHT_BRACE - ; + : KW_BITMASK identifier LEFT_BRACE bit_values RIGHT_BRACE + ; bit_values - : identifier (COMMA identifier)* - ; + : identifier (COMMA identifier)* + ; struct_type - : KW_STRUCT identifier (COLON scoped_name)? LEFT_BRACE member_list RIGHT_BRACE - ; + : KW_STRUCT identifier (COLON scoped_name)? LEFT_BRACE member_list RIGHT_BRACE + ; member_list - : member * - ; + : member* + ; member - : annapps type_spec declarators SEMICOLON - ; + : annapps type_spec declarators SEMICOLON + ; union_type - : KW_UNION identifier KW_SWITCH LEFT_BRACKET annapps switch_type_spec RIGHT_BRACKET LEFT_BRACE switch_body RIGHT_BRACE - ; + : KW_UNION identifier KW_SWITCH LEFT_BRACKET annapps switch_type_spec RIGHT_BRACKET LEFT_BRACE switch_body RIGHT_BRACE + ; switch_type_spec - : integer_type - | char_type - | wide_char_type - | octet_type - | boolean_type - | enum_type - | scoped_name - ; + : integer_type + | char_type + | wide_char_type + | octet_type + | boolean_type + | enum_type + | scoped_name + ; switch_body - : case_stmt + - ; + : case_stmt+ + ; case_stmt - : case_label + element_spec SEMICOLON - ; + : case_label+ element_spec SEMICOLON + ; case_label - : annapps - ( KW_CASE const_exp COLON - | KW_DEFAULT COLON - ) - ; + : annapps (KW_CASE const_exp COLON | KW_DEFAULT COLON) + ; element_spec - : annapps type_spec declarator - ; + : annapps type_spec declarator + ; enum_type - : KW_ENUM identifier LEFT_BRACE enumerator (COMMA enumerator)* RIGHT_BRACE - ; + : KW_ENUM identifier LEFT_BRACE enumerator (COMMA enumerator)* RIGHT_BRACE + ; enumerator - : identifier - ; + : identifier + ; sequence_type - : KW_SEQUENCE LEFT_ANG_BRACKET annapps simple_type_spec (COMMA positive_int_const)? RIGHT_ANG_BRACKET - ; + : KW_SEQUENCE LEFT_ANG_BRACKET annapps simple_type_spec (COMMA positive_int_const)? RIGHT_ANG_BRACKET + ; set_type - : KW_SET LEFT_ANG_BRACKET simple_type_spec (COMMA positive_int_const)? RIGHT_ANG_BRACKET - ; + : KW_SET LEFT_ANG_BRACKET simple_type_spec (COMMA positive_int_const)? RIGHT_ANG_BRACKET + ; map_type - : KW_MAP LEFT_ANG_BRACKET simple_type_spec COMMA simple_type_spec (COMMA positive_int_const)? RIGHT_ANG_BRACKET - ; + : KW_MAP LEFT_ANG_BRACKET simple_type_spec COMMA simple_type_spec (COMMA positive_int_const)? RIGHT_ANG_BRACKET + ; string_type - : KW_STRING (LEFT_ANG_BRACKET positive_int_const RIGHT_ANG_BRACKET)? - ; + : KW_STRING (LEFT_ANG_BRACKET positive_int_const RIGHT_ANG_BRACKET)? + ; wide_string_type - : KW_WSTRING (LEFT_ANG_BRACKET positive_int_const RIGHT_ANG_BRACKET)? - ; + : KW_WSTRING (LEFT_ANG_BRACKET positive_int_const RIGHT_ANG_BRACKET)? + ; array_declarator - : ID fixed_array_size + - ; + : ID fixed_array_size+ + ; fixed_array_size - : LEFT_SQUARE_BRACKET positive_int_const RIGHT_SQUARE_BRACKET - ; + : LEFT_SQUARE_BRACKET positive_int_const RIGHT_SQUARE_BRACKET + ; attr_decl - : readonly_attr_spec - | attr_spec - ; + : readonly_attr_spec + | attr_spec + ; except_decl - : KW_EXCEPTION identifier LEFT_BRACE member* RIGHT_BRACE - ; + : KW_EXCEPTION identifier LEFT_BRACE member* RIGHT_BRACE + ; op_decl - : (op_attribute)? op_type_spec identifier parameter_decls (raises_expr)? (context_expr)? - ; + : (op_attribute)? op_type_spec identifier parameter_decls (raises_expr)? (context_expr)? + ; op_attribute - : KW_ONEWAY - ; + : KW_ONEWAY + ; op_type_spec - : annapps - ( param_type_spec - | KW_VOID - ) - ; + : annapps (param_type_spec | KW_VOID) + ; parameter_decls - : LEFT_BRACKET ( param_decl (COMMA param_decl)* )? RIGHT_BRACKET - ; + : LEFT_BRACKET (param_decl (COMMA param_decl)*)? RIGHT_BRACKET + ; param_decl - : annapps param_attribute annapps param_type_spec annapps simple_declarator - ; + : annapps param_attribute annapps param_type_spec annapps simple_declarator + ; param_attribute - : KW_IN - | KW_OUT - | KW_INOUT - ; + : KW_IN + | KW_OUT + | KW_INOUT + ; raises_expr - : KW_RAISES LEFT_BRACKET a_scoped_name (COMMA a_scoped_name)* RIGHT_BRACKET - ; + : KW_RAISES LEFT_BRACKET a_scoped_name (COMMA a_scoped_name)* RIGHT_BRACKET + ; context_expr - : KW_CONTEXT LEFT_BRACKET STRING_LITERAL (COMMA STRING_LITERAL)* RIGHT_BRACKET - ; + : KW_CONTEXT LEFT_BRACKET STRING_LITERAL (COMMA STRING_LITERAL)* RIGHT_BRACKET + ; param_type_spec - : base_type_spec - | string_type - | wide_string_type - | scoped_name - ; + : base_type_spec + | string_type + | wide_string_type + | scoped_name + ; fixed_pt_type - : KW_FIXED LEFT_ANG_BRACKET positive_int_const COMMA positive_int_const RIGHT_ANG_BRACKET - ; + : KW_FIXED LEFT_ANG_BRACKET positive_int_const COMMA positive_int_const RIGHT_ANG_BRACKET + ; fixed_pt_const_type - : KW_FIXED - ; + : KW_FIXED + ; value_base_type - : KW_VALUEBASE - ; + : KW_VALUEBASE + ; constr_forward_decl - : KW_STRUCT ID - | KW_UNION ID - ; + : KW_STRUCT ID + | KW_UNION ID + ; import_decl - : annapps KW_IMPORT annapps imported_scope SEMICOLON - ; + : annapps KW_IMPORT annapps imported_scope SEMICOLON + ; imported_scope - : scoped_name - | STRING_LITERAL - ; + : scoped_name + | STRING_LITERAL + ; type_id_decl - : KW_TYPEID a_scoped_name STRING_LITERAL - ; + : KW_TYPEID a_scoped_name STRING_LITERAL + ; type_prefix_decl - : KW_TYPEPREFIX a_scoped_name STRING_LITERAL - ; + : KW_TYPEPREFIX a_scoped_name STRING_LITERAL + ; readonly_attr_spec - : KW_READONLY KW_ATTRIBUTE annapps param_type_spec readonly_attr_declarator - ; + : KW_READONLY KW_ATTRIBUTE annapps param_type_spec readonly_attr_declarator + ; readonly_attr_declarator - : annapps simple_declarator - ( raises_expr - | (COMMA annapps simple_declarator)* - ) - ; + : annapps simple_declarator (raises_expr | (COMMA annapps simple_declarator)*) + ; attr_spec - : KW_ATTRIBUTE annapps param_type_spec attr_declarator - ; + : KW_ATTRIBUTE annapps param_type_spec attr_declarator + ; attr_declarator - : annapps simple_declarator - ( attr_raises_expr - | (COMMA annapps simple_declarator)* - ) - ; + : annapps simple_declarator (attr_raises_expr | (COMMA annapps simple_declarator)*) + ; attr_raises_expr - : get_excep_expr (set_excep_expr)? - | set_excep_expr - ; + : get_excep_expr (set_excep_expr)? + | set_excep_expr + ; get_excep_expr - : KW_GETRAISES exception_list - ; + : KW_GETRAISES exception_list + ; set_excep_expr - : KW_SETRAISES exception_list - ; + : KW_SETRAISES exception_list + ; exception_list - : LEFT_BRACKET a_scoped_name (COMMA a_scoped_name)* RIGHT_BRACKET - ; + : LEFT_BRACKET a_scoped_name (COMMA a_scoped_name)* RIGHT_BRACKET + ; component - : component_decl - | component_forward_decl - ; + : component_decl + | component_forward_decl + ; component_forward_decl - : KW_COMPONENT ID - ; + : KW_COMPONENT ID + ; component_decl - : component_header LEFT_BRACE component_body RIGHT_BRACE - ; + : component_header LEFT_BRACE component_body RIGHT_BRACE + ; component_header - : KW_COMPONENT identifier (component_inheritance_spec)? (supported_interface_spec)? - ; + : KW_COMPONENT identifier (component_inheritance_spec)? (supported_interface_spec)? + ; supported_interface_spec - : KW_SUPPORTS a_scoped_name (COMMA a_scoped_name)* - ; + : KW_SUPPORTS a_scoped_name (COMMA a_scoped_name)* + ; component_inheritance_spec - : COLON a_scoped_name - ; + : COLON a_scoped_name + ; component_body - : component_export* - ; + : component_export* + ; component_export - : annapps - ( provides_decl SEMICOLON - | uses_decl SEMICOLON - | emits_decl SEMICOLON - | publishes_decl SEMICOLON - | consumes_decl SEMICOLON - | attr_decl SEMICOLON - ) - ; + : annapps ( + provides_decl SEMICOLON + | uses_decl SEMICOLON + | emits_decl SEMICOLON + | publishes_decl SEMICOLON + | consumes_decl SEMICOLON + | attr_decl SEMICOLON + ) + ; provides_decl - : KW_PROVIDES interface_type ID - ; + : KW_PROVIDES interface_type ID + ; interface_type - : annapps - ( scoped_name - | KW_OBJECT - ) - ; + : annapps (scoped_name | KW_OBJECT) + ; uses_decl - : KW_USES (KW_MULTIPLE)? interface_type ID - ; + : KW_USES (KW_MULTIPLE)? interface_type ID + ; emits_decl - : KW_EMITS a_scoped_name ID - ; + : KW_EMITS a_scoped_name ID + ; publishes_decl - : KW_PUBLISHES a_scoped_name ID - ; + : KW_PUBLISHES a_scoped_name ID + ; consumes_decl - : KW_CONSUMES a_scoped_name ID - ; + : KW_CONSUMES a_scoped_name ID + ; home_decl - : home_header home_body - ; + : home_header home_body + ; home_header - : KW_HOME identifier (home_inheritance_spec)? (supported_interface_spec)? KW_MANAGES a_scoped_name (primary_key_spec)? - ; + : KW_HOME identifier (home_inheritance_spec)? (supported_interface_spec)? KW_MANAGES a_scoped_name ( + primary_key_spec + )? + ; home_inheritance_spec - : COLON a_scoped_name - ; + : COLON a_scoped_name + ; primary_key_spec - : KW_PRIMARYKEY a_scoped_name - ; + : KW_PRIMARYKEY a_scoped_name + ; home_body - : LEFT_BRACE home_export* RIGHT_BRACE - ; + : LEFT_BRACE home_export* RIGHT_BRACE + ; home_export - : export_ - | annapps - ( factory_decl - | finder_decl - ) - SEMICOLON - ; + : export_ + | annapps ( factory_decl | finder_decl) SEMICOLON + ; factory_decl - : KW_FACTORY identifier LEFT_BRACKET (init_param_decls)? RIGHT_BRACKET (raises_expr)? - ; + : KW_FACTORY identifier LEFT_BRACKET (init_param_decls)? RIGHT_BRACKET (raises_expr)? + ; finder_decl - : KW_FINDER identifier LEFT_BRACKET (init_param_decls)? RIGHT_BRACKET (raises_expr)? - ; + : KW_FINDER identifier LEFT_BRACKET (init_param_decls)? RIGHT_BRACKET (raises_expr)? + ; event - : (event_decl | event_abs_decl | event_forward_decl) - ; + : (event_decl | event_abs_decl | event_forward_decl) + ; event_forward_decl - : (KW_ABSTRACT)? KW_EVENTTYPE ID - ; + : (KW_ABSTRACT)? KW_EVENTTYPE ID + ; event_abs_decl - : KW_ABSTRACT KW_EVENTTYPE identifier value_inheritance_spec LEFT_BRACE export_* RIGHT_BRACE - ; + : KW_ABSTRACT KW_EVENTTYPE identifier value_inheritance_spec LEFT_BRACE export_* RIGHT_BRACE + ; event_decl - : event_header LEFT_BRACE value_element* RIGHT_BRACE - ; + : event_header LEFT_BRACE value_element* RIGHT_BRACE + ; event_header - : (KW_CUSTOM)? KW_EVENTTYPE identifier value_inheritance_spec - ; + : (KW_CUSTOM)? KW_EVENTTYPE identifier value_inheritance_spec + ; annapps - : ( annotation_appl )* - ; + : (annotation_appl)* + ; annotation_appl - : AT scoped_name ( LEFT_BRACKET annotation_appl_params RIGHT_BRACKET )? - ; + : AT scoped_name (LEFT_BRACKET annotation_appl_params RIGHT_BRACKET)? + ; annotation_appl_params - : const_exp - | annotation_appl_param ( COMMA annotation_appl_param )* - ; + : const_exp + | annotation_appl_param ( COMMA annotation_appl_param)* + ; annotation_appl_param - : ID EQUAL const_exp - ; + : ID EQUAL const_exp + ; identifier - : annapps ID - ; - + : annapps ID + ; INTEGER_LITERAL - : ('0' | '1' .. '9' '0' .. '9'*) INTEGER_TYPE_SUFFIX? - ; - + : ('0' | '1' .. '9' '0' .. '9'*) INTEGER_TYPE_SUFFIX? + ; OCTAL_LITERAL - : '0' ('0' .. '7') + INTEGER_TYPE_SUFFIX? - ; - + : '0' ('0' .. '7')+ INTEGER_TYPE_SUFFIX? + ; HEX_LITERAL - : '0' ('x' | 'X') HEX_DIGIT + INTEGER_TYPE_SUFFIX? - ; - + : '0' ('x' | 'X') HEX_DIGIT+ INTEGER_TYPE_SUFFIX? + ; fragment HEX_DIGIT - : ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F') - ; - + : ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F') + ; fragment INTEGER_TYPE_SUFFIX - : ('l' | 'L') - ; - + : ('l' | 'L') + ; FLOATING_PT_LITERAL - : ('0' .. '9') + '.' ('0' .. '9')* EXPONENT? FLOAT_TYPE_SUFFIX? - | '.' ('0' .. '9') + EXPONENT? FLOAT_TYPE_SUFFIX? - | ('0' .. '9') + EXPONENT FLOAT_TYPE_SUFFIX? - | ('0' .. '9') + EXPONENT? FLOAT_TYPE_SUFFIX - ; - + : ('0' .. '9')+ '.' ('0' .. '9')* EXPONENT? FLOAT_TYPE_SUFFIX? + | '.' ('0' .. '9')+ EXPONENT? FLOAT_TYPE_SUFFIX? + | ('0' .. '9')+ EXPONENT FLOAT_TYPE_SUFFIX? + | ('0' .. '9')+ EXPONENT? FLOAT_TYPE_SUFFIX + ; FIXED_PT_LITERAL - : FLOATING_PT_LITERAL - ; - + : FLOATING_PT_LITERAL + ; fragment EXPONENT - : ('e' | 'E') (PLUS | MINUS)? ('0' .. '9') + - ; - + : ('e' | 'E') (PLUS | MINUS)? ('0' .. '9')+ + ; fragment FLOAT_TYPE_SUFFIX - : ('f' | 'F' | 'd' | 'D') - ; - + : ('f' | 'F' | 'd' | 'D') + ; WIDE_CHARACTER_LITERAL - : 'L' CHARACTER_LITERAL - ; - + : 'L' CHARACTER_LITERAL + ; CHARACTER_LITERAL - : '\'' (ESCAPE_SEQUENCE | ~ ('\'' | '\\')) '\'' - ; - + : '\'' (ESCAPE_SEQUENCE | ~ ('\'' | '\\')) '\'' + ; WIDE_STRING_LITERAL - : 'L' STRING_LITERAL - ; - + : 'L' STRING_LITERAL + ; STRING_LITERAL - : '"' (ESCAPE_SEQUENCE | ~ ('\\' | '"'))* '"' - ; - + : '"' (ESCAPE_SEQUENCE | ~ ('\\' | '"'))* '"' + ; BOOLEAN_LITERAL - : 'TRUE' - | 'FALSE' - ; - + : 'TRUE' + | 'FALSE' + ; fragment ESCAPE_SEQUENCE - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') - | UNICODE_ESCAPE - | OCTAL_ESCAPE - ; - + : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') + | UNICODE_ESCAPE + | OCTAL_ESCAPE + ; fragment OCTAL_ESCAPE - : '\\' ('0' .. '3') ('0' .. '7') ('0' .. '7') - | '\\' ('0' .. '7') ('0' .. '7') - | '\\' ('0' .. '7') - ; - + : '\\' ('0' .. '3') ('0' .. '7') ('0' .. '7') + | '\\' ('0' .. '7') ('0' .. '7') + | '\\' ('0' .. '7') + ; fragment UNICODE_ESCAPE - : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT - ; - + : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT + ; fragment LETTER - : '\u0024' - | '\u0041' .. '\u005a' - | '\u005f' - | '\u0061' .. '\u007a' - | '\u00c0' .. '\u00d6' - | '\u00d8' .. '\u00f6' - | '\u00f8' .. '\u00ff' - | '\u0100' .. '\u1fff' - | '\u3040' .. '\u318f' - | '\u3300' .. '\u337f' - | '\u3400' .. '\u3d2d' - | '\u4e00' .. '\u9fff' - | '\uf900' .. '\ufaff' - ; - + : '\u0024' + | '\u0041' .. '\u005a' + | '\u005f' + | '\u0061' .. '\u007a' + | '\u00c0' .. '\u00d6' + | '\u00d8' .. '\u00f6' + | '\u00f8' .. '\u00ff' + | '\u0100' .. '\u1fff' + | '\u3040' .. '\u318f' + | '\u3300' .. '\u337f' + | '\u3400' .. '\u3d2d' + | '\u4e00' .. '\u9fff' + | '\uf900' .. '\ufaff' + ; fragment ID_DIGIT - : '\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' - | '\u1040' .. '\u1049' - ; - + : '\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' + | '\u1040' .. '\u1049' + ; SEMICOLON - : ';' - ; - + : ';' + ; COLON - : ':' - ; - + : ':' + ; COMMA - : ',' - ; - + : ',' + ; LEFT_BRACE - : '{' - ; - + : '{' + ; RIGHT_BRACE - : '}' - ; - + : '}' + ; LEFT_BRACKET - : '(' - ; - + : '(' + ; RIGHT_BRACKET - : ')' - ; - + : ')' + ; LEFT_SQUARE_BRACKET - : '[' - ; - + : '[' + ; RIGHT_SQUARE_BRACKET - : ']' - ; - + : ']' + ; TILDE - : '~' - ; - + : '~' + ; SLASH - : '/' - ; - + : '/' + ; LEFT_ANG_BRACKET - : '<' - ; - + : '<' + ; RIGHT_ANG_BRACKET - : '>' - ; - + : '>' + ; STAR - : '*' - ; - + : '*' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; CARET - : '^' - ; - + : '^' + ; AMPERSAND - : '&' - ; - + : '&' + ; PIPE - : '|' - ; - + : '|' + ; EQUAL - : '=' - ; - + : '=' + ; PERCENT - : '%' - ; - + : '%' + ; DOUBLE_COLON - : '::' - ; - + : '::' + ; RIGHT_SHIFT - : '>>' - ; - + : '>>' + ; LEFT_SHIFT - : '<<' - ; - - -AT : '@' - ; + : '<<' + ; +AT + : '@' + ; KW_SETRAISES - : 'setraises' - ; - + : 'setraises' + ; KW_OUT - : 'out' - ; - + : 'out' + ; KW_EMITS - : 'emits' - ; - + : 'emits' + ; KW_STRING - : 'string' - ; - + : 'string' + ; KW_SWITCH - : 'switch' - ; - + : 'switch' + ; KW_PUBLISHES - : 'publishes' - ; - + : 'publishes' + ; KW_TYPEDEF - : 'typedef' - ; - + : 'typedef' + ; KW_USES - : 'uses' - ; - + : 'uses' + ; KW_PRIMARYKEY - : 'primarykey' - ; - + : 'primarykey' + ; KW_CUSTOM - : 'custom' - ; - + : 'custom' + ; KW_OCTET - : 'octet' - ; - + : 'octet' + ; KW_SEQUENCE - : 'sequence' - ; - + : 'sequence' + ; KW_IMPORT - : 'import' - ; - + : 'import' + ; KW_STRUCT - : 'struct' - ; - + : 'struct' + ; KW_NATIVE - : 'native' - ; - + : 'native' + ; KW_READONLY - : 'readonly' - ; - + : 'readonly' + ; KW_FINDER - : 'finder' - ; - + : 'finder' + ; KW_RAISES - : 'raises' - ; - + : 'raises' + ; KW_VOID - : 'void' - ; - + : 'void' + ; KW_PRIVATE - : 'private' - ; - + : 'private' + ; KW_EVENTTYPE - : 'eventtype' - ; - + : 'eventtype' + ; KW_WCHAR - : 'wchar' - ; - + : 'wchar' + ; KW_IN - : 'in' - ; - + : 'in' + ; KW_DEFAULT - : 'default' - ; - + : 'default' + ; KW_PUBLIC - : 'public' - ; - + : 'public' + ; KW_SHORT - : 'short' - ; - + : 'short' + ; KW_LONG - : 'long' - ; - + : 'long' + ; KW_ENUM - : 'enum' - ; - + : 'enum' + ; KW_WSTRING - : 'wstring' - ; - + : 'wstring' + ; KW_CONTEXT - : 'context' - ; - + : 'context' + ; KW_HOME - : 'home' - ; - + : 'home' + ; KW_FACTORY - : 'factory' - ; - + : 'factory' + ; KW_EXCEPTION - : 'exception' - ; - + : 'exception' + ; KW_GETRAISES - : 'getraises' - ; - + : 'getraises' + ; KW_CONST - : 'const' - ; - + : 'const' + ; KW_VALUEBASE - : 'ValueBase' - ; - + : 'ValueBase' + ; KW_VALUETYPE - : 'valuetype' - ; - + : 'valuetype' + ; KW_SUPPORTS - : 'supports' - ; - + : 'supports' + ; KW_MODULE - : 'module' - ; - + : 'module' + ; KW_OBJECT - : 'Object' - ; - + : 'Object' + ; KW_TRUNCATABLE - : 'truncatable' - ; - + : 'truncatable' + ; KW_UNSIGNED - : 'unsigned' - ; - + : 'unsigned' + ; KW_FIXED - : 'fixed' - ; - + : 'fixed' + ; KW_UNION - : 'union' - ; - + : 'union' + ; KW_ONEWAY - : 'oneway' - ; - + : 'oneway' + ; KW_ANY - : 'any' - ; - + : 'any' + ; KW_CHAR - : 'char' - ; - + : 'char' + ; KW_CASE - : 'case' - ; - + : 'case' + ; KW_FLOAT - : 'float' - ; - + : 'float' + ; KW_BOOLEAN - : 'boolean' - ; - + : 'boolean' + ; KW_MULTIPLE - : 'multiple' - ; - + : 'multiple' + ; KW_ABSTRACT - : 'abstract' - ; - + : 'abstract' + ; KW_INOUT - : 'inout' - ; - + : 'inout' + ; KW_PROVIDES - : 'provides' - ; - + : 'provides' + ; KW_CONSUMES - : 'consumes' - ; - + : 'consumes' + ; KW_DOUBLE - : 'double' - ; - + : 'double' + ; KW_TYPEPREFIX - : 'typeprefix' - ; - + : 'typeprefix' + ; KW_TYPEID - : 'typeid' - ; - + : 'typeid' + ; KW_ATTRIBUTE - : 'attribute' - ; - + : 'attribute' + ; KW_LOCAL - : 'local' - ; - + : 'local' + ; KW_MANAGES - : 'manages' - ; - + : 'manages' + ; KW_INTERFACE - : 'interface' - ; - + : 'interface' + ; KW_COMPONENT - : 'component' - ; + : 'component' + ; KW_SET - : 'set' - ; + : 'set' + ; KW_MAP - : 'map' - ; + : 'map' + ; KW_BITFIELD - : 'bitfield' - ; + : 'bitfield' + ; KW_BITSET - : 'bitset' - ; + : 'bitset' + ; KW_BITMASK - : 'bitmask' - ; + : 'bitmask' + ; KW_INT8 - : 'int8' - ; + : 'int8' + ; KW_UINT8 - : 'uint8' - ; + : 'uint8' + ; KW_INT16 - : 'int16' - ; + : 'int16' + ; KW_UINT16 - : 'uint16' - ; + : 'uint16' + ; KW_INT32 - : 'int32' - ; + : 'int32' + ; KW_UINT32 - : 'uint32' - ; + : 'uint32' + ; KW_INT64 - : 'int64' - ; + : 'int64' + ; KW_UINT64 - : 'uint64' - ; + : 'uint64' + ; KW_AT_ANNOTATION - : '@annotation' - ; + : '@annotation' + ; ID - : LETTER (LETTER | ID_DIGIT)* - ; - + : LETTER (LETTER | ID_DIGIT)* + ; WS - : (' ' | '\r' | '\t' | '\u000C' | '\n') -> channel (HIDDEN) - ; - + : (' ' | '\r' | '\t' | '\u000C' | '\n') -> channel (HIDDEN) + ; COMMENT - : '/*' .*? '*/' -> channel (HIDDEN) - ; - + : '/*' .*? '*/' -> channel (HIDDEN) + ; LINE_COMMENT - : '//' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) - ; - + : '//' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) + ; \ No newline at end of file diff --git a/inf/inf.g4 b/inf/inf.g4 index 31890054f1..bbafe0afe9 100644 --- a/inf/inf.g4 +++ b/inf/inf.g4 @@ -30,54 +30,70 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar inf; inf - : (section | EOL)* EOF - ; + : (section | EOL)* EOF + ; section - : sectionheader line* - ; + : sectionheader line* + ; sectionheader - : '[' string ']' EOL - ; + : '[' string ']' EOL + ; string - : CHARS - | STRING - ; + : CHARS + | STRING + ; line - : stringlist ('=' stringlist)? EOL - ; + : stringlist ('=' stringlist)? EOL + ; stringlist - : string (',' string?)* - ; - + : string (',' string?)* + ; CHARS - : ('A' .. 'Z' | '0' .. '9' | 'a' .. 'z' | '.' | '%' | '"' | '\\' | '/' | '*' | '@' | '&' | '_' | '{' | '}' | '<' | '>' | '-') + - ; - + : ( + 'A' .. 'Z' + | '0' .. '9' + | 'a' .. 'z' + | '.' + | '%' + | '"' + | '\\' + | '/' + | '*' + | '@' + | '&' + | '_' + | '{' + | '}' + | '<' + | '>' + | '-' + )+ + ; STRING - : '"' (~ ('"' | '\n'))* '"' - ; - + : '"' (~ ('"' | '\n'))* '"' + ; COMMENT - : ';' ~ [\r\n]* EOL -> skip - ; - + : ';' ~ [\r\n]* EOL -> skip + ; EOL - : [\r\n]+ - ; - + : [\r\n]+ + ; WS - : [ \t] + -> skip - ; + : [ \t]+ -> skip + ; \ No newline at end of file diff --git a/informix/informix.g4 b/informix/informix.g4 index 9d327c71b7..4004288391 100644 --- a/informix/informix.g4 +++ b/informix/informix.g4 @@ -5,459 +5,505 @@ * */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar informix; compilation_unit - : databaseDeclaration? globalDeclaration? typeDeclarations? mainBlock functionOrReportDefinitions? EOF - ; + : databaseDeclaration? globalDeclaration? typeDeclarations? mainBlock functionOrReportDefinitions? EOF + ; identifier - : IDENT - ; + : IDENT + ; mainBlock - : eol? MAIN eol typeDeclarations? mainStatements? END MAIN eol - ; + : eol? MAIN eol typeDeclarations? mainStatements? END MAIN eol + ; mainStatements - : (deferStatement | codeBlock | eol)+ - ; + : (deferStatement | codeBlock | eol)+ + ; deferStatement - : DEFER (INTERRUPT | QUIT) eol - ; + : DEFER (INTERRUPT | QUIT) eol + ; functionOrReportDefinitions - : (reportDefinition | functionDefinition)+ - ; + : (reportDefinition | functionDefinition)+ + ; returnStatement - : RETURN variableOrConstantList? - ; + : RETURN variableOrConstantList? + ; functionDefinition - : FUNCTION functionIdentifier parameterList? eol typeDeclarations codeBlock? END FUNCTION eol - ; + : FUNCTION functionIdentifier parameterList? eol typeDeclarations codeBlock? END FUNCTION eol + ; parameterList - : LPAREN parameterGroup* RPAREN - ; + : LPAREN parameterGroup* RPAREN + ; parameterGroup - : identifier (COMMA identifier)* - ; + : identifier (COMMA identifier)* + ; globalDeclaration - : GLOBALS (string | eol typeDeclarations END GLOBALS) eol - ; + : GLOBALS (string | eol typeDeclarations END GLOBALS) eol + ; typeDeclarations - : typeDeclaration+ - ; + : typeDeclaration+ + ; typeDeclaration - : DEFINE variableDeclaration (COMMA variableDeclaration)* - ; + : DEFINE variableDeclaration (COMMA variableDeclaration)* + ; variableDeclaration - : constantIdentifier (COMMA constantIdentifier)* type_ - | constantIdentifier type_ (COMMA constantIdentifier type_)* - ; + : constantIdentifier (COMMA constantIdentifier)* type_ + | constantIdentifier type_ (COMMA constantIdentifier type_)* + ; type_ - : typeIdentifier - | indirectType - | largeType - | structuredType - ; + : typeIdentifier + | indirectType + | largeType + | structuredType + ; indirectType - : LIKE tableIdentifier DOT identifier - ; + : LIKE tableIdentifier DOT identifier + ; typeIdentifier - : charType - | numberType - | timeType - ; + : charType + | numberType + | timeType + ; largeType - : TEXT - | BYTE - ; + : TEXT + | BYTE + ; numberType - : (BIGINT | INTEGER | INT | SMALLINT | REAL | SMALLFLOAT) - | (DECIMAL | DEC | NUMERIC | MONEY) (LPAREN numericConstant (COMMA numericConstant)? RPAREN)? - | (FLOAT | DOUBLE) (LPAREN numericConstant RPAREN)? - ; + : (BIGINT | INTEGER | INT | SMALLINT | REAL | SMALLFLOAT) + | (DECIMAL | DEC | NUMERIC | MONEY) (LPAREN numericConstant (COMMA numericConstant)? RPAREN)? + | (FLOAT | DOUBLE) (LPAREN numericConstant RPAREN)? + ; charType - : (VARCHAR | NVARCHAR) LPAREN numericConstant (COMMA numericConstant)? RPAREN - | (CHAR | NCHAR | CHARACTER) (LPAREN numericConstant RPAREN)? - ; + : (VARCHAR | NVARCHAR) LPAREN numericConstant (COMMA numericConstant)? RPAREN + | (CHAR | NCHAR | CHARACTER) (LPAREN numericConstant RPAREN)? + ; timeType - : DATE - | DATETIME datetimeQualifier - | INTERVAL intervalQualifier - ; + : DATE + | DATETIME datetimeQualifier + | INTERVAL intervalQualifier + ; datetimeQualifier - : YEAR TO yearQualifier - | MONTH TO monthQualifier - | DAY TO dayQualifier - | HOUR TO hourQualifier - | MINUTE TO minuteQualifier - | SECOND TO secondQualifier - | FRACTION TO fractionQualifier - ; + : YEAR TO yearQualifier + | MONTH TO monthQualifier + | DAY TO dayQualifier + | HOUR TO hourQualifier + | MINUTE TO minuteQualifier + | SECOND TO secondQualifier + | FRACTION TO fractionQualifier + ; intervalQualifier - : YEAR (LPAREN numericConstant RPAREN)? TO yearQualifier - | MONTH (LPAREN numericConstant RPAREN)? TO monthQualifier - | DAY (LPAREN numericConstant RPAREN)? TO dayQualifier - | HOUR (LPAREN numericConstant RPAREN)? TO hourQualifier - | MINUTE (LPAREN numericConstant RPAREN)? TO minuteQualifier - | SECOND (LPAREN numericConstant RPAREN)? TO secondQualifier - | FRACTION TO fractionQualifier - ; + : YEAR (LPAREN numericConstant RPAREN)? TO yearQualifier + | MONTH (LPAREN numericConstant RPAREN)? TO monthQualifier + | DAY (LPAREN numericConstant RPAREN)? TO dayQualifier + | HOUR (LPAREN numericConstant RPAREN)? TO hourQualifier + | MINUTE (LPAREN numericConstant RPAREN)? TO minuteQualifier + | SECOND (LPAREN numericConstant RPAREN)? TO secondQualifier + | FRACTION TO fractionQualifier + ; unitType - : yearQualifier - ; + : yearQualifier + ; yearQualifier - : YEAR - | monthQualifier - ; + : YEAR + | monthQualifier + ; monthQualifier - : MONTH - | dayQualifier - ; + : MONTH + | dayQualifier + ; dayQualifier - : DAY - | hourQualifier - ; + : DAY + | hourQualifier + ; hourQualifier - : HOUR - | minuteQualifier - ; + : HOUR + | minuteQualifier + ; minuteQualifier - : MINUTE - | secondQualifier - ; + : MINUTE + | secondQualifier + ; secondQualifier - : SECOND - | fractionQualifier - ; + : SECOND + | fractionQualifier + ; fractionQualifier - : FRACTION (LPAREN numericConstant RPAREN)? - ; + : FRACTION (LPAREN numericConstant RPAREN)? + ; structuredType - : recordType - | arrayType - | dynArrayType - ; + : recordType + | arrayType + | dynArrayType + ; recordType - : RECORD (eol (variableDeclaration (COMMA variableDeclaration)*) END RECORD | (LIKE tableIdentifier DOT STAR)) - ; + : RECORD ( + eol (variableDeclaration (COMMA variableDeclaration)*) END RECORD + | (LIKE tableIdentifier DOT STAR) + ) + ; arrayIndexer - : LBRACK numericConstant (COMMA numericConstant | COMMA numericConstant COMMA numericConstant)? RBRACK - ; + : LBRACK numericConstant (COMMA numericConstant | COMMA numericConstant COMMA numericConstant)? RBRACK + ; arrayType - : ARRAY arrayIndexer OF (recordType | typeIdentifier | largeType) - ; + : ARRAY arrayIndexer OF (recordType | typeIdentifier | largeType) + ; dynArrayType - : DYNAMIC ARRAY WITH numericConstant DIMENSIONS OF (recordType | typeIdentifier) - ; + : DYNAMIC ARRAY WITH numericConstant DIMENSIONS OF (recordType | typeIdentifier) + ; string - : STRING_LITERAL - ; + : STRING_LITERAL + ; statement - : (label COLON)? unlabelledStatement - ; + : (label COLON)? unlabelledStatement + ; codeBlock - : (statement | databaseDeclaration)+ - ; + : (statement | databaseDeclaration)+ + ; label - : identifier - ; + : identifier + ; unlabelledStatement - : simpleStatement - | structuredStatement - ; + : simpleStatement + | structuredStatement + ; simpleStatement - : assignmentStatement - | procedureStatement - | sqlStatements SEMI? - | otherFGLStatement - | menuInsideStatement - | constructInsideStatement - | displayInsideStatement - | inputInsideStatement - ; + : assignmentStatement + | procedureStatement + | sqlStatements SEMI? + | otherFGLStatement + | menuInsideStatement + | constructInsideStatement + | displayInsideStatement + | inputInsideStatement + ; runStatement - : RUN (variable | string) (IN FORM MODE | IN LINE MODE)? (WITHOUT WAITING | RETURNING variable)? - ; + : RUN (variable | string) (IN FORM MODE | IN LINE MODE)? (WITHOUT WAITING | RETURNING variable)? + ; assignmentStatement - : LET variable EQUAL expression (COMMA expression)* - ; + : LET variable EQUAL expression (COMMA expression)* + ; procedureStatement - : CALL procedureIdentifier (LPAREN (actualParameter (COMMA actualParameter)*)? RPAREN)? (RETURNING variable (COMMA variable)*)? - ; + : CALL procedureIdentifier (LPAREN (actualParameter (COMMA actualParameter)*)? RPAREN)? ( + RETURNING variable (COMMA variable)* + )? + ; procedureIdentifier - : functionIdentifier - ; + : functionIdentifier + ; actualParameter - : STAR - | expression - ; + : STAR + | expression + ; gotoStatement - : GOTO COLON? label eol - ; + : GOTO COLON? label eol + ; condition - : (TRUE | FALSE) - | logicalTerm (OR logicalTerm)* - ; + : (TRUE | FALSE) + | logicalTerm (OR logicalTerm)* + ; logicalTerm - : logicalFactor (AND logicalFactor)* - ; + : logicalFactor (AND logicalFactor)* + ; logicalFactor - : - // Added "prior" to a comparison expression to support use of a - // condition in a connect_clause. (sqlExpression NOT? IN) sqlExpression NOT? IN expressionSet - | (sqlExpression NOT? LIKE) sqlExpression NOT? LIKE sqlExpression (ESC QUOTED_STRING)? - | (sqlExpression NOT? BETWEEN) sqlExpression NOT? BETWEEN sqlExpression AND sqlExpression - | (sqlExpression IS NOT? NULL_) sqlExpression IS NOT? NULL_ - | quantifiedFactor quantifiedFactor - | (NOT condition) NOT condition - | LPAREN condition RPAREN - | sqlExpression relationalOperator sqlExpression - ; + : + // Added "prior" to a comparison expression to support use of a + // condition in a connect_clause. (sqlExpression NOT? IN) sqlExpression NOT? IN expressionSet + | (sqlExpression NOT? LIKE) sqlExpression NOT? LIKE sqlExpression (ESC QUOTED_STRING)? + | (sqlExpression NOT? BETWEEN) sqlExpression NOT? BETWEEN sqlExpression AND sqlExpression + | (sqlExpression IS NOT? NULL_) sqlExpression IS NOT? NULL_ + | quantifiedFactor quantifiedFactor + | (NOT condition) NOT condition + | LPAREN condition RPAREN + | sqlExpression relationalOperator sqlExpression + ; quantifiedFactor - : (sqlExpression relationalOperator (ALL | ANY)? subquery) sqlExpression relationalOperator (ALL | ANY)? subquery - | (NOT? EXISTS subquery) NOT? EXISTS subquery - | subquery - ; + : (sqlExpression relationalOperator (ALL | ANY)? subquery) sqlExpression relationalOperator ( + ALL + | ANY + )? subquery + | (NOT? EXISTS subquery) NOT? EXISTS subquery + | subquery + ; expressionSet - : sqlExpression sqlExpression - | subquery - ; + : sqlExpression sqlExpression + | subquery + ; subquery - : LPAREN sqlSelectStatement RPAREN - ; + : LPAREN sqlSelectStatement RPAREN + ; sqlExpression - : sqlTerm ((PLUS | MINUS) sqlTerm)* - ; + : sqlTerm ((PLUS | MINUS) sqlTerm)* + ; sqlAlias - : AS? identifier - ; + : AS? identifier + ; sqlTerm - : sqlFactor ((sqlMultiply | DIV | SLASH) sqlFactor)* - ; + : sqlFactor ((sqlMultiply | DIV | SLASH) sqlFactor)* + ; sqlMultiply - : STAR - ; + : STAR + ; sqlFactor - : sqlFactor2 (DOUBLEVERTBAR sqlFactor2)* - ; + : sqlFactor2 (DOUBLEVERTBAR sqlFactor2)* + ; sqlFactor2 - : (sqlVariable (UNITS unitType)?) sqlVariable (UNITS unitType)? - | (sqlLiteral (UNITS unitType)?) sqlLiteral (UNITS unitType)? - | (groupFunction LPAREN (STAR | ALL | DISTINCT)? (sqlExpression (COMMA sqlExpression)*)? RPAREN) groupFunction LPAREN (STAR | ALL | DISTINCT)? (sqlExpression (COMMA sqlExpression)*)? RPAREN - | (sqlFunction (LPAREN sqlExpression (COMMA sqlExpression)* RPAREN)) sqlFunction (LPAREN sqlExpression (COMMA sqlExpression)* RPAREN) - | ((PLUS | MINUS) sqlExpression) (PLUS | MINUS) sqlExpression - | (LPAREN sqlExpression RPAREN) LPAREN sqlExpression RPAREN - | sqlExpressionList - ; + : (sqlVariable (UNITS unitType)?) sqlVariable (UNITS unitType)? + | (sqlLiteral (UNITS unitType)?) sqlLiteral (UNITS unitType)? + | ( + groupFunction LPAREN (STAR | ALL | DISTINCT)? (sqlExpression (COMMA sqlExpression)*)? RPAREN + ) groupFunction LPAREN (STAR | ALL | DISTINCT)? (sqlExpression (COMMA sqlExpression)*)? RPAREN + | (sqlFunction (LPAREN sqlExpression (COMMA sqlExpression)* RPAREN)) sqlFunction ( + LPAREN sqlExpression (COMMA sqlExpression)* RPAREN + ) + | ((PLUS | MINUS) sqlExpression) (PLUS | MINUS) sqlExpression + | (LPAREN sqlExpression RPAREN) LPAREN sqlExpression RPAREN + | sqlExpressionList + ; sqlExpressionList - : LPAREN sqlExpression (COMMA sqlExpression)+ RPAREN - ; + : LPAREN sqlExpression (COMMA sqlExpression)+ RPAREN + ; sqlLiteral - : unsignedConstant | string | NULL_ | FALSE | TRUE - ; + : unsignedConstant + | string + | NULL_ + | FALSE + | TRUE + ; sqlVariable - : columnsTableId columnsTableId - ; + : columnsTableId columnsTableId + ; sqlFunction - : numberFunction - | charFunction - | dateFunction - | otherFunction - ; + : numberFunction + | charFunction + | dateFunction + | otherFunction + ; dateFunction - : YEAR - | DATE - | DAY - | MONTH - ; + : YEAR + | DATE + | DAY + | MONTH + ; numberFunction - : MOD - ; + : MOD + ; charFunction - : LENGTH - ; + : LENGTH + ; groupFunction - : AVG - | COUNT - | MAX - | MIN - | SUM - ; + : AVG + | COUNT + | MAX + | MIN + | SUM + ; otherFunction - : (DECODE | NVL) - | constantIdentifier - ; + : (DECODE | NVL) + | constantIdentifier + ; // This is not being used currently, but might be useful at some point. sqlPseudoColumn - : USER - ; + : USER + ; relationalOperator - : EQUAL | NOT_EQUAL | LE | LT | GE | GT | LIKE - | NOT? MATCHES - ; + : EQUAL + | NOT_EQUAL + | LE + | LT + | GE + | GT + | LIKE + | NOT? MATCHES + ; ifCondition - : TRUE | FALSE - | ifCondition2 (relationalOperator ifCondition2)* - ; + : TRUE + | FALSE + | ifCondition2 (relationalOperator ifCondition2)* + ; ifCondition2 - : ifLogicalTerm (OR ifLogicalTerm)* - ; + : ifLogicalTerm (OR ifLogicalTerm)* + ; ifLogicalTerm - : ifLogicalFactor (AND ifLogicalFactor)* - ; + : ifLogicalFactor (AND ifLogicalFactor)* + ; expression - : simpleExpression (CLIPPED | USING string)* - ; + : simpleExpression (CLIPPED | USING string)* + ; ifLogicalFactor - : - // Added "prior" to a comparison expression to support use of a - // condition in a connect_clause. (simpleExpression IS NOT? NULL_) simpleExpression IS NOT? NULL_ - | (NOT ifCondition) NOT ifCondition - | LPAREN ifCondition RPAREN - | simpleExpression simpleExpression - ; + : + // Added "prior" to a comparison expression to support use of a + // condition in a connect_clause. (simpleExpression IS NOT? NULL_) simpleExpression IS NOT? NULL_ + | (NOT ifCondition) NOT ifCondition + | LPAREN ifCondition RPAREN + | simpleExpression simpleExpression + ; simpleExpression - : sign? term (addingOperator term)* - ; + : sign? term (addingOperator term)* + ; addingOperator - : PLUS - | MINUS - ; + : PLUS + | MINUS + ; term - : factor (multiplyingOperator factor)* - ; + : factor (multiplyingOperator factor)* + ; multiplyingOperator - : STAR - | SLASH - | DIV - | MOD - ; + : STAR + | SLASH + | DIV + | MOD + ; factor - : (GROUP? functionDesignator | variable | constant | LPAREN expression RPAREN | NOT factor) (UNITS unitType)? - ; + : (GROUP? functionDesignator | variable | constant | LPAREN expression RPAREN | NOT factor) ( + UNITS unitType + )? + ; functionDesignator - : functionIdentifier (LPAREN (actualParameter (COMMA actualParameter)*)? RPAREN)? - ; + : functionIdentifier (LPAREN (actualParameter (COMMA actualParameter)*)? RPAREN)? + ; functionIdentifier - : (DAY | YEAR | MONTH | TODAY | WEEKDAY | MDY | COLUMN | SUM | COUNT | AVG | MIN | MAX | EXTEND | DATE | TIME | INFIELD | PREPARE) - | constantIdentifier - ; + : ( + DAY + | YEAR + | MONTH + | TODAY + | WEEKDAY + | MDY + | COLUMN + | SUM + | COUNT + | AVG + | MIN + | MAX + | EXTEND + | DATE + | TIME + | INFIELD + | PREPARE + ) + | constantIdentifier + ; unsignedConstant - : unsignedNumber - | string - | constantIdentifier - | NULL_ - ; + : unsignedNumber + | string + | constantIdentifier + | NULL_ + ; constant - : numericConstant - | constantIdentifier - | sign identifier - | string - ; + : numericConstant + | constantIdentifier + | sign identifier + | string + ; numericConstant - : unsignedNumber - | sign unsignedNumber - ; + : unsignedNumber + | sign unsignedNumber + ; variable - : entireVariable - | componentVariable - ; + : entireVariable + | componentVariable + ; entireVariable - : variableIdentifier - ; + : variableIdentifier + ; variableIdentifier - : constantIdentifier - ; + : constantIdentifier + ; indexingVariable - : LBRACK expression (COMMA expression)* RBRACK - ; + : LBRACK expression (COMMA expression)* RBRACK + ; /* thruNotation @@ -466,2380 +512,2216 @@ thruNotation ; */ componentVariable - : (recordVariable indexingVariable?) ((DOT STAR) | (DOT componentVariable ((THROUGH | THRU) componentVariable)?))? - ; + : (recordVariable indexingVariable?) ( + (DOT STAR) + | (DOT componentVariable ((THROUGH | THRU) componentVariable)?) + )? + ; recordVariable - : constantIdentifier - ; + : constantIdentifier + ; fieldIdentifier - : constantIdentifier - ; + : constantIdentifier + ; structuredStatement - : conditionalStatement - | repetetiveStatement - ; + : conditionalStatement + | repetetiveStatement + ; conditionalStatement - : ifStatement - | caseStatement - ; + : ifStatement + | caseStatement + ; ifStatement - : IF ifCondition THEN codeBlock? (ELSE codeBlock?)? END IF - ; + : IF ifCondition THEN codeBlock? (ELSE codeBlock?)? END IF + ; repetetiveStatement - : whileStatement - | forEachStatement - | forStatement - ; + : whileStatement + | forEachStatement + | forStatement + ; whileStatement - : WHILE ifCondition codeBlock? END WHILE - ; + : WHILE ifCondition codeBlock? END WHILE + ; forStatement - : FOR controlVariable EQUAL forList (STEP numericConstant)? eol codeBlock? END FOR eol - ; + : FOR controlVariable EQUAL forList (STEP numericConstant)? eol codeBlock? END FOR eol + ; forList - : initialValue TO finalValue - ; + : initialValue TO finalValue + ; controlVariable - : identifier - ; + : identifier + ; initialValue - : expression - ; + : expression + ; finalValue - : expression - ; + : expression + ; forEachStatement - : FOREACH identifier (USING variableList)? (INTO variableList)? (WITH REOPTIMIZATION)? eol codeBlock? END FOREACH eol - ; + : FOREACH identifier (USING variableList)? (INTO variableList)? (WITH REOPTIMIZATION)? eol codeBlock? END FOREACH eol + ; variableList - : variable (COMMA variable)* - ; + : variable (COMMA variable)* + ; variableOrConstantList - : expression (COMMA expression)* - ; + : expression (COMMA expression)* + ; caseStatement - : CASE expression (WHEN expression codeBlock?)* (OTHERWISE codeBlock?)? END CASE - | CASE (WHEN ifCondition codeBlock)* (OTHERWISE codeBlock)? END CASE - ; + : CASE expression (WHEN expression codeBlock?)* (OTHERWISE codeBlock?)? END CASE + | CASE (WHEN ifCondition codeBlock)* (OTHERWISE codeBlock)? END CASE + ; otherFGLStatement - : otherProgramFlowStatement - | otherStorageStatement - | reportStatement - | screenStatement - ; + : otherProgramFlowStatement + | otherStorageStatement + | reportStatement + | screenStatement + ; otherProgramFlowStatement - : runStatement - | gotoStatement - | SLEEP expression - | exitStatements - | continueStatements - | returnStatement - ; + : runStatement + | gotoStatement + | SLEEP expression + | exitStatements + | continueStatements + | returnStatement + ; exitTypes - : FOREACH - | FOR - | CASE - | CONSTRUCT - | DISPLAY - | INPUT - | MENU - | REPORT - | WHILE - ; + : FOREACH + | FOR + | CASE + | CONSTRUCT + | DISPLAY + | INPUT + | MENU + | REPORT + | WHILE + ; exitStatements - : EXIT exitTypes - | EXIT PROGRAM (LPAREN expression RPAREN | expression)? - ; + : EXIT exitTypes + | EXIT PROGRAM (LPAREN expression RPAREN | expression)? + ; continueStatements - : CONTINUE exitTypes eol - ; + : CONTINUE exitTypes eol + ; otherStorageStatement - : ALLOCATE ARRAY identifier arrayIndexer - | LOCATE variableList IN (MEMORY | FILE (variable | string)?) - | DEALLOCATE ARRAY identifier - | RESIZE ARRAY identifier arrayIndexer - | FREE variable (COMMA variable)* - | INITIALIZE variable (COMMA variable)* (TO NULL_ | LIKE expression (COMMA expression)*) - | VALIDATE variable (COMMA variable)* LIKE expression (COMMA expression)* - ; + : ALLOCATE ARRAY identifier arrayIndexer + | LOCATE variableList IN (MEMORY | FILE (variable | string)?) + | DEALLOCATE ARRAY identifier + | RESIZE ARRAY identifier arrayIndexer + | FREE variable (COMMA variable)* + | INITIALIZE variable (COMMA variable)* (TO NULL_ | LIKE expression (COMMA expression)*) + | VALIDATE variable (COMMA variable)* LIKE expression (COMMA expression)* + ; printExpressionItem - : COLUMN expression - | (PAGENO | LINENO) - | BYTE variable - | TEXT variable - | expression (SPACE | SPACES)? (WORDWRAP (RIGHT MARGIN numericConstant)?)? - ; + : COLUMN expression + | (PAGENO | LINENO) + | BYTE variable + | TEXT variable + | expression (SPACE | SPACES)? (WORDWRAP (RIGHT MARGIN numericConstant)?)? + ; printExpressionList - : printExpressionItem (COMMA printExpressionItem)* - ; + : printExpressionItem (COMMA printExpressionItem)* + ; reportStatement - : START REPORT constantIdentifier (TO (expression | PIPE expression | PRINTER))? (WITH ((LEFT MARGIN numericConstant) | (RIGHT MARGIN numericConstant) | (TOP MARGIN numericConstant) | (BOTTOM MARGIN numericConstant) | (PAGE LENGTH numericConstant) | (TOP OF PAGE string))*)? - | TERMINATE REPORT constantIdentifier - | FINISH REPORT constantIdentifier - | PAUSE string? - | NEED expression LINES - | PRINT (printExpressionList? SEMI? | FILE string)? - | SKIP2 (expression (LINE | LINES) | TO TOP OF PAGE) - | OUTPUT TO REPORT constantIdentifier LPAREN (expression (COMMA expression)*)? RPAREN - ; + : START REPORT constantIdentifier (TO (expression | PIPE expression | PRINTER))? ( + WITH ( + (LEFT MARGIN numericConstant) + | (RIGHT MARGIN numericConstant) + | (TOP MARGIN numericConstant) + | (BOTTOM MARGIN numericConstant) + | (PAGE LENGTH numericConstant) + | (TOP OF PAGE string) + )* + )? + | TERMINATE REPORT constantIdentifier + | FINISH REPORT constantIdentifier + | PAUSE string? + | NEED expression LINES + | PRINT (printExpressionList? SEMI? | FILE string)? + | SKIP2 (expression (LINE | LINES) | TO TOP OF PAGE) + | OUTPUT TO REPORT constantIdentifier LPAREN (expression (COMMA expression)*)? RPAREN + ; fieldName - : ((identifier (LBRACK numericConstant RBRACK)?) DOT)? identifier - | (identifier (LBRACK numericConstant RBRACK)?) DOT (STAR | identifier thruNotation?) - ; + : ((identifier (LBRACK numericConstant RBRACK)?) DOT)? identifier + | (identifier (LBRACK numericConstant RBRACK)?) DOT (STAR | identifier thruNotation?) + ; thruNotation - : (THROUGH | THRU) (SAME DOT)? identifier - ; + : (THROUGH | THRU) (SAME DOT)? identifier + ; fieldList - : expression (COMMA expression)* - ; + : expression (COMMA expression)* + ; keyList - : expression (COMMA expression)* - ; + : expression (COMMA expression)* + ; constructEvents - : BEFORE CONSTRUCT - | AFTER CONSTRUCT - | BEFORE FIELD fieldList - | AFTER FIELD fieldList - | ON KEY LPAREN keyList RPAREN - ; + : BEFORE CONSTRUCT + | AFTER CONSTRUCT + | BEFORE FIELD fieldList + | AFTER FIELD fieldList + | ON KEY LPAREN keyList RPAREN + ; constructInsideStatement - : NEXT FIELD (fieldName | NEXT | PREVIOUS) eol - | CONTINUE CONSTRUCT eol - | EXIT CONSTRUCT eol - ; + : NEXT FIELD (fieldName | NEXT | PREVIOUS) eol + | CONTINUE CONSTRUCT eol + | EXIT CONSTRUCT eol + ; specialAttribute - : REVERSE - | BLINK - | UNDERLINE - ; + : REVERSE + | BLINK + | UNDERLINE + ; attribute - : (BLACK | BLUE | CYAN | GREEN | MAGENTA | RED | WHITE | YELLOW | BOLD | DIM | NORMAL | INVISIBLE)? specialAttribute (COMMA specialAttribute)* - ; + : ( + BLACK + | BLUE + | CYAN + | GREEN + | MAGENTA + | RED + | WHITE + | YELLOW + | BOLD + | DIM + | NORMAL + | INVISIBLE + )? specialAttribute (COMMA specialAttribute)* + ; attributeList - : (ATTRIBUTE | ATTRIBUTES) LPAREN attribute RPAREN - ; + : (ATTRIBUTE | ATTRIBUTES) LPAREN attribute RPAREN + ; constructGroupStatement - : constructEvents codeBlock+ - ; + : constructEvents codeBlock+ + ; constructStatement - : CONSTRUCT (BY NAME variable ON columnsList | variable ON columnsList FROM fieldList) attributeList? (HELP numericConstant)? (constructGroupStatement+ END CONSTRUCT)? - ; + : CONSTRUCT (BY NAME variable ON columnsList | variable ON columnsList FROM fieldList) attributeList? ( + HELP numericConstant + )? (constructGroupStatement+ END CONSTRUCT)? + ; displayArrayStatement - : DISPLAY ARRAY expression TO expression attributeList? displayEvents* (END DISPLAY)? - ; + : DISPLAY ARRAY expression TO expression attributeList? displayEvents* (END DISPLAY)? + ; displayInsideStatement - : CONTINUE DISPLAY - | EXIT DISPLAY - ; + : CONTINUE DISPLAY + | EXIT DISPLAY + ; displayEvents - : ON KEY LPAREN keyList RPAREN codeBlock+ - ; + : ON KEY LPAREN keyList RPAREN codeBlock+ + ; displayStatement - : DISPLAY (BY NAME (expression (COMMA expression)*) | (expression (COMMA expression)*) (TO fieldList | AT expression COMMA expression)?) attributeList? eol - ; + : DISPLAY ( + BY NAME (expression (COMMA expression)*) + | (expression (COMMA expression)*) (TO fieldList | AT expression COMMA expression)? + ) attributeList? eol + ; errorStatement - : ERROR expression (COMMA expression)* attributeList? - ; + : ERROR expression (COMMA expression)* attributeList? + ; messageStatement - : MESSAGE expression (COMMA expression)* attributeList? - ; + : MESSAGE expression (COMMA expression)* attributeList? + ; promptStatement - : PROMPT expression (COMMA expression)* attributeList? FOR CHAR? variable (HELP numericConstant)? attributeList? ((ON KEY LPAREN keyList RPAREN codeBlock?)* END PROMPT)? - ; + : PROMPT expression (COMMA expression)* attributeList? FOR CHAR? variable ( + HELP numericConstant + )? attributeList? ((ON KEY LPAREN keyList RPAREN codeBlock?)* END PROMPT)? + ; inputEvents - : (BEFORE | AFTER) (INPUT | ROW | INSERT | DELETE) - | BEFORE FIELD fieldList - | AFTER FIELD fieldList - | ON KEY LPAREN keyList RPAREN - ; + : (BEFORE | AFTER) (INPUT | ROW | INSERT | DELETE) + | BEFORE FIELD fieldList + | AFTER FIELD fieldList + | ON KEY LPAREN keyList RPAREN + ; inputInsideStatement - : NEXT FIELD (fieldName | (NEXT | PREVIOUS)) - | (CONTINUE INPUT | EXIT INPUT) - ; + : NEXT FIELD (fieldName | (NEXT | PREVIOUS)) + | (CONTINUE INPUT | EXIT INPUT) + ; inputGroupStatement - : inputEvents codeBlock* - ; + : inputEvents codeBlock* + ; inputStatement - : INPUT (BY NAME expression (COMMA expression)* (WITHOUT DEFAULTS)? | expression (COMMA expression)* (WITHOUT DEFAULTS)? FROM fieldList) attributeList? (HELP numericConstant)? (inputGroupStatement+ END INPUT)? - ; + : INPUT ( + BY NAME expression (COMMA expression)* (WITHOUT DEFAULTS)? + | expression (COMMA expression)* (WITHOUT DEFAULTS)? FROM fieldList + ) attributeList? (HELP numericConstant)? (inputGroupStatement+ END INPUT)? + ; inputArrayStatement - : INPUT ARRAY expression (WITHOUT DEFAULTS)? FROM expression (COMMA expression)* (HELP numericConstant)? attributeList? (inputGroupStatement+ END INPUT)? - ; + : INPUT ARRAY expression (WITHOUT DEFAULTS)? FROM expression (COMMA expression)* ( + HELP numericConstant + )? attributeList? (inputGroupStatement+ END INPUT)? + ; menuEvents - : BEFORE MENU - | COMMAND ((KEY LPAREN keyList RPAREN)? expression expression? (HELP numericConstant)?) - ; + : BEFORE MENU + | COMMAND ((KEY LPAREN keyList RPAREN)? expression expression? (HELP numericConstant)?) + ; menuInsideStatement - : NEXT OPTION (expression | ALL) (COMMA expression)* - | SHOW OPTION (expression | ALL) (COMMA expression)* - | HIDE OPTION (expression | ALL) (COMMA expression)* - | CONTINUE MENU - | EXIT MENU - ; + : NEXT OPTION (expression | ALL) (COMMA expression)* + | SHOW OPTION (expression | ALL) (COMMA expression)* + | HIDE OPTION (expression | ALL) (COMMA expression)* + | CONTINUE MENU + | EXIT MENU + ; menuGroupStatement - : menuEvents codeBlock? - ; + : menuEvents codeBlock? + ; menuStatement - : MENU expression menuGroupStatement* END MENU - ; + : MENU expression menuGroupStatement* END MENU + ; reservedLinePosition - : FIRST (PLUS numericConstant)? - | numericConstant - | LAST (MINUS numericConstant)? - ; + : FIRST (PLUS numericConstant)? + | numericConstant + | LAST (MINUS numericConstant)? + ; specialWindowAttribute - : (BLACK | BLUE | CYAN | GREEN | MAGENTA | RED | WHITE | YELLOW | BOLD | DIM | NORMAL | INVISIBLE) - | REVERSE - | BORDER - | (PROMPT | FORM | MENU | MESSAGE) LINE reservedLinePosition - | COMMENT LINE (reservedLinePosition | OFF) - ; + : ( + BLACK + | BLUE + | CYAN + | GREEN + | MAGENTA + | RED + | WHITE + | YELLOW + | BOLD + | DIM + | NORMAL + | INVISIBLE + ) + | REVERSE + | BORDER + | (PROMPT | FORM | MENU | MESSAGE) LINE reservedLinePosition + | COMMENT LINE (reservedLinePosition | OFF) + ; windowAttribute - : specialWindowAttribute (COMMA specialWindowAttribute)* - ; + : specialWindowAttribute (COMMA specialWindowAttribute)* + ; windowAttributeList - : (ATTRIBUTE | ATTRIBUTES) LPAREN windowAttribute RPAREN - ; + : (ATTRIBUTE | ATTRIBUTES) LPAREN windowAttribute RPAREN + ; optionStatement - : (MESSAGE LINE expression | PROMPT LINE expression | MENU LINE expression | COMMENT LINE expression | ERROR LINE expression | FORM LINE expression | INPUT (WRAP | NO WRAP) | INSERT KEY expression | DELETE KEY expression | NEXT KEY expression | PREVIOUS KEY expression | ACCEPT KEY expression | HELP FILE expression | HELP KEY expression | INPUT attributeList | DISPLAY attributeList | SQL INTERRUPT (ON | OFF) | FIELD ORDER (CONSTRAINED | UNCONSTRAINED)) - ; + : ( + MESSAGE LINE expression + | PROMPT LINE expression + | MENU LINE expression + | COMMENT LINE expression + | ERROR LINE expression + | FORM LINE expression + | INPUT (WRAP | NO WRAP) + | INSERT KEY expression + | DELETE KEY expression + | NEXT KEY expression + | PREVIOUS KEY expression + | ACCEPT KEY expression + | HELP FILE expression + | HELP KEY expression + | INPUT attributeList + | DISPLAY attributeList + | SQL INTERRUPT (ON | OFF) + | FIELD ORDER (CONSTRAINED | UNCONSTRAINED) + ) + ; optionsStatement - : OPTIONS optionStatement (COMMA optionStatement)* - ; + : OPTIONS optionStatement (COMMA optionStatement)* + ; screenStatement - : CLEAR (FORM | WINDOW identifier | WINDOW? SCREEN | fieldList) - | CLOSE WINDOW identifier eol - | CLOSE FORM identifier eol - | constructStatement - | CURRENT WINDOW IS (SCREEN | identifier) eol - | displayStatement - | displayArrayStatement - | DISPLAY FORM identifier attributeList? eol - | errorStatement - | messageStatement - | promptStatement - | inputStatement - | inputArrayStatement - | menuStatement - | OPEN FORM expression FROM expression - | OPEN WINDOW expression AT expression COMMA expression (WITH FORM expression | WITH expression ROWS COMMA expression COLUMNS) windowAttributeList? - | optionsStatement - | SCROLL fieldList (COMMA fieldList)* (UP | DOWN) (BY numericConstant)? - ; + : CLEAR (FORM | WINDOW identifier | WINDOW? SCREEN | fieldList) + | CLOSE WINDOW identifier eol + | CLOSE FORM identifier eol + | constructStatement + | CURRENT WINDOW IS (SCREEN | identifier) eol + | displayStatement + | displayArrayStatement + | DISPLAY FORM identifier attributeList? eol + | errorStatement + | messageStatement + | promptStatement + | inputStatement + | inputArrayStatement + | menuStatement + | OPEN FORM expression FROM expression + | OPEN WINDOW expression AT expression COMMA expression ( + WITH FORM expression + | WITH expression ROWS COMMA expression COLUMNS + ) windowAttributeList? + | optionsStatement + | SCROLL fieldList (COMMA fieldList)* (UP | DOWN) (BY numericConstant)? + ; sqlStatements - : cursorManipulationStatement - | dataDefinitionStatement - | dataManipulationStatement - | dynamicManagementStatement - | queryOptimizationStatement - | dataIntegrityStatement - | clientServerStatement - ; + : cursorManipulationStatement + | dataDefinitionStatement + | dataManipulationStatement + | dynamicManagementStatement + | queryOptimizationStatement + | dataIntegrityStatement + | clientServerStatement + ; cursorManipulationStatement - : CLOSE cursorName eol - | DECLARE cursorName (CURSOR (WITH HOLD)? FOR (sqlSelectStatement (FOR UPDATE (OF columnsList)?)? | sqlInsertStatement | statementId) | SCROLL CURSOR (WITH HOLD)? FOR (sqlSelectStatement | statementId)) - | FETCH (NEXT | (PREVIOUS | PRIOR) | FIRST | LAST | CURRENT | RELATIVE expression | ABSOLUTE expression)? cursorName (INTO variableList)? - | FLUSH cursorName eol - | OPEN cursorName (USING variableList)? - | PUT cursorName (FROM variableOrConstantList)? - ; + : CLOSE cursorName eol + | DECLARE cursorName ( + CURSOR (WITH HOLD)? FOR ( + sqlSelectStatement (FOR UPDATE (OF columnsList)?)? + | sqlInsertStatement + | statementId + ) + | SCROLL CURSOR (WITH HOLD)? FOR (sqlSelectStatement | statementId) + ) + | FETCH ( + NEXT + | (PREVIOUS | PRIOR) + | FIRST + | LAST + | CURRENT + | RELATIVE expression + | ABSOLUTE expression + )? cursorName (INTO variableList)? + | FLUSH cursorName eol + | OPEN cursorName (USING variableList)? + | PUT cursorName (FROM variableOrConstantList)? + ; columnsList - : columnsTableId (COMMA columnsTableId)* - ; + : columnsTableId (COMMA columnsTableId)* + ; statementId - : constantIdentifier - ; + : constantIdentifier + ; cursorName - : identifier - ; + : identifier + ; dataType - : type_ - ; + : type_ + ; columnItem - : constantIdentifier (dataType | (BYTE | TEXT) (IN (TABLE | constantIdentifier))?) (NOT NULL_)? - | UNIQUE LPAREN (constantIdentifier (COMMA constantIdentifier)*)? RPAREN (CONSTRAINT constantIdentifier)? - ; + : constantIdentifier (dataType | (BYTE | TEXT) (IN (TABLE | constantIdentifier))?) (NOT NULL_)? + | UNIQUE LPAREN (constantIdentifier (COMMA constantIdentifier)*)? RPAREN ( + CONSTRAINT constantIdentifier + )? + ; dataDefinitionStatement - : DROP TABLE constantIdentifier - | CREATE TEMP? TABLE constantIdentifier LPAREN columnItem (COMMA columnItem)* RPAREN (WITH NO LOG)? (IN constantIdentifier)? (EXTENT SIZE numericConstant)? (NEXT SIZE numericConstant)? (LOCK MODE LPAREN (PAGE | ROW) RPAREN)? - | CREATE UNIQUE? CLUSTER? INDEX constantIdentifier ON constantIdentifier LPAREN constantIdentifier (ASC | DESC)? (COMMA constantIdentifier (ASC | DESC)?)* RPAREN - | DROP INDEX constantIdentifier - ; + : DROP TABLE constantIdentifier + | CREATE TEMP? TABLE constantIdentifier LPAREN columnItem (COMMA columnItem)* RPAREN ( + WITH NO LOG + )? (IN constantIdentifier)? (EXTENT SIZE numericConstant)? (NEXT SIZE numericConstant)? ( + LOCK MODE LPAREN (PAGE | ROW) RPAREN + )? + | CREATE UNIQUE? CLUSTER? INDEX constantIdentifier ON constantIdentifier LPAREN constantIdentifier ( + ASC + | DESC + )? (COMMA constantIdentifier (ASC | DESC)?)* RPAREN + | DROP INDEX constantIdentifier + ; dataManipulationStatement - : sqlInsertStatement - | sqlDeleteStatement - | sqlSelectStatement - | sqlUpdateStatement - | sqlLoadStatement - | sqlUnLoadStatement - ; + : sqlInsertStatement + | sqlDeleteStatement + | sqlSelectStatement + | sqlUpdateStatement + | sqlLoadStatement + | sqlUnLoadStatement + ; sqlSelectStatement - : mainSelectStatement - ; + : mainSelectStatement + ; columnsTableId - : STAR - | (tableIdentifier indexingVariable?) (DOT STAR | DOT columnsTableId)? - ; + : STAR + | (tableIdentifier indexingVariable?) (DOT STAR | DOT columnsTableId)? + ; selectList - : (sqlExpression sqlAlias? (COMMA sqlExpression sqlAlias?)*) - ; + : (sqlExpression sqlAlias? (COMMA sqlExpression sqlAlias?)*) + ; headSelectStatement - : SELECT (ALL | (DISTINCT | UNIQUE))? selectList - ; + : SELECT (ALL | (DISTINCT | UNIQUE))? selectList + ; tableQualifier - : constantIdentifier COLON - | constantIdentifier ATSYMBOL constantIdentifier COLON - | string - ; + : constantIdentifier COLON + | constantIdentifier ATSYMBOL constantIdentifier COLON + | string + ; tableIdentifier - : tableQualifier? constantIdentifier - ; + : tableQualifier? constantIdentifier + ; fromTable - : OUTER? tableIdentifier sqlAlias? - ; + : OUTER? tableIdentifier sqlAlias? + ; tableExpression - : simpleSelectStatement - ; + : simpleSelectStatement + ; fromSelectStatement - : FROM (fromTable | LPAREN tableExpression RPAREN sqlAlias?) (COMMA (fromTable | LPAREN tableExpression RPAREN sqlAlias?))* - ; + : FROM (fromTable | LPAREN tableExpression RPAREN sqlAlias?) ( + COMMA (fromTable | LPAREN tableExpression RPAREN sqlAlias?) + )* + ; aliasName - : identifier - ; + : identifier + ; mainSelectStatement - : headSelectStatement (INTO variableList)? fromSelectStatement whereStatement? groupByStatement? havingStatement? unionSelectStatement? orderbyStatement? (INTO TEMP identifier)? (WITH NO LOG)? - ; + : headSelectStatement (INTO variableList)? fromSelectStatement whereStatement? groupByStatement? havingStatement? unionSelectStatement? + orderbyStatement? (INTO TEMP identifier)? (WITH NO LOG)? + ; unionSelectStatement - : (UNION ALL? simpleSelectStatement) - ; + : (UNION ALL? simpleSelectStatement) + ; simpleSelectStatement - : headSelectStatement fromSelectStatement whereStatement? groupByStatement? havingStatement? unionSelectStatement? - ; + : headSelectStatement fromSelectStatement whereStatement? groupByStatement? havingStatement? unionSelectStatement? + ; whereStatement - : WHERE condition - ; + : WHERE condition + ; groupByStatement - : GROUP BY variableOrConstantList - ; + : GROUP BY variableOrConstantList + ; havingStatement - : HAVING condition - ; + : HAVING condition + ; orderbyColumn - : expression (ASC | DESC)? - ; + : expression (ASC | DESC)? + ; orderbyStatement - : ORDER BY orderbyColumn (COMMA orderbyColumn)* - ; + : ORDER BY orderbyColumn (COMMA orderbyColumn)* + ; sqlLoadStatement - : LOAD FROM (variable | string) (DELIMITER (variable | string))? (INSERT INTO tableIdentifier (LPAREN columnsList RPAREN)? | sqlInsertStatement) eol - ; + : LOAD FROM (variable | string) (DELIMITER (variable | string))? ( + INSERT INTO tableIdentifier (LPAREN columnsList RPAREN)? + | sqlInsertStatement + ) eol + ; sqlUnLoadStatement - : UNLOAD TO (variable | string) (DELIMITER (variable | string))? sqlSelectStatement eol - ; + : UNLOAD TO (variable | string) (DELIMITER (variable | string))? sqlSelectStatement eol + ; sqlInsertStatement - : INSERT INTO tableIdentifier (LPAREN columnsList RPAREN)? (VALUES LPAREN expression (COMMA expression)* RPAREN | simpleSelectStatement) - ; + : INSERT INTO tableIdentifier (LPAREN columnsList RPAREN)? ( + VALUES LPAREN expression (COMMA expression)* RPAREN + | simpleSelectStatement + ) + ; sqlUpdateStatement - : UPDATE tableIdentifier SET ((columnsTableId EQUAL expression (COMMA columnsTableId EQUAL expression)*) | ((LPAREN columnsList RPAREN | (aliasName DOT)? STAR) EQUAL (LPAREN expression (COMMA expression)* RPAREN | (aliasName DOT)? STAR))) (WHERE (condition | CURRENT OF cursorName))? - ; + : UPDATE tableIdentifier SET ( + (columnsTableId EQUAL expression (COMMA columnsTableId EQUAL expression)*) + | ( + (LPAREN columnsList RPAREN | (aliasName DOT)? STAR) EQUAL ( + LPAREN expression (COMMA expression)* RPAREN + | (aliasName DOT)? STAR + ) + ) + ) (WHERE (condition | CURRENT OF cursorName))? + ; sqlDeleteStatement - : DELETE FROM tableIdentifier (WHERE (condition | CURRENT OF cursorName))? eol - ; + : DELETE FROM tableIdentifier (WHERE (condition | CURRENT OF cursorName))? eol + ; actualParameterList - : actualParameter (COMMA actualParameter)* - ; + : actualParameter (COMMA actualParameter)* + ; dynamicManagementStatement - : PREPARE cursorName FROM expression - | EXECUTE cursorName (USING variableList)? - | FREE (cursorName | statementId) - | LOCK TABLE expression IN (SHARE | EXCLUSIVE) MODE - ; + : PREPARE cursorName FROM expression + | EXECUTE cursorName (USING variableList)? + | FREE (cursorName | statementId) + | LOCK TABLE expression IN (SHARE | EXCLUSIVE) MODE + ; queryOptimizationStatement - : UPDATE STATISTICS (FOR TABLE tableIdentifier)? - | SET LOCK MODE TO (WAIT SECONDS? | NOT WAIT) - | SET EXPLAIN (ON | OFF) - | SET ISOLATION TO (CURSOR STABILITY | (DIRTY | COMMITTED | REPEATABLE) READ) - | SET BUFFERED? LOG - ; + : UPDATE STATISTICS (FOR TABLE tableIdentifier)? + | SET LOCK MODE TO (WAIT SECONDS? | NOT WAIT) + | SET EXPLAIN (ON | OFF) + | SET ISOLATION TO (CURSOR STABILITY | (DIRTY | COMMITTED | REPEATABLE) READ) + | SET BUFFERED? LOG + ; databaseDeclaration - : DATABASE (constantIdentifier (ATSYMBOL constantIdentifier)?) EXCLUSIVE? SEMI? - ; + : DATABASE (constantIdentifier (ATSYMBOL constantIdentifier)?) EXCLUSIVE? SEMI? + ; clientServerStatement - : CLOSE DATABASE - ; + : CLOSE DATABASE + ; dataIntegrityStatement - : wheneverStatement - | BEGIN WORK - | COMMIT WORK - | ROLLBACK WORK - ; + : wheneverStatement + | BEGIN WORK + | COMMIT WORK + | ROLLBACK WORK + ; wheneverStatement - : WHENEVER wheneverType wheneverFlow eol - ; + : WHENEVER wheneverType wheneverFlow eol + ; wheneverType - : NOT FOUND - | ANY? (SQLERROR | ERROR) - | (SQLWARNING | WARNING) - ; + : NOT FOUND + | ANY? (SQLERROR | ERROR) + | (SQLWARNING | WARNING) + ; wheneverFlow - : (CONTINUE | STOP) - | CALL identifier - | (GO TO | GOTO) COLON? identifier - ; + : (CONTINUE | STOP) + | CALL identifier + | (GO TO | GOTO) COLON? identifier + ; reportDefinition - : REPORT identifier parameterList? typeDeclarations? outputReport? (ORDER EXTERNAL? BY variableList)? formatReport? END REPORT - ; + : REPORT identifier parameterList? typeDeclarations? outputReport? ( + ORDER EXTERNAL? BY variableList + )? formatReport? END REPORT + ; outputReport - : OUTPUT (REPORT TO (string | PIPE string | PRINTER))? ((LEFT MARGIN numericConstant) | (RIGHT MARGIN numericConstant) | (TOP MARGIN numericConstant) | (BOTTOM MARGIN numericConstant) | (PAGE LENGTH numericConstant) | (TOP OF PAGE string))* - ; + : OUTPUT (REPORT TO (string | PIPE string | PRINTER))? ( + (LEFT MARGIN numericConstant) + | (RIGHT MARGIN numericConstant) + | (TOP MARGIN numericConstant) + | (BOTTOM MARGIN numericConstant) + | (PAGE LENGTH numericConstant) + | (TOP OF PAGE string) + )* + ; formatReport - : FORMAT (EVERY ROW | ((FIRST? PAGE HEADER | PAGE TRAILER | ON (EVERY ROW | LAST ROW) | (BEFORE | AFTER) GROUP OF variable) codeBlock)+) - ; + : FORMAT ( + EVERY ROW + | ( + ( + FIRST? PAGE HEADER + | PAGE TRAILER + | ON (EVERY ROW | LAST ROW) + | (BEFORE | AFTER) GROUP OF variable + ) codeBlock + )+ + ) + ; eol - : EOL - ; + : EOL + ; unsignedNumber - : unsignedInteger - | unsignedReal - ; + : unsignedInteger + | unsignedReal + ; unsignedInteger - : NUM_INT - ; + : NUM_INT + ; unsignedReal - : NUM_REAL - ; + : NUM_REAL + ; sign - : PLUS - | MINUS - ; + : PLUS + | MINUS + ; constantIdentifier - : (ACCEPT | ASCII | COUNT | CURRENT | FALSE | FIRST | FOUND | GROUP | HIDE | INDEX | INT_FLAG | INTERRUPT | LAST | LENGTH | LINENO | MDY | NO | NOT | NOTFOUND | NULL_ | PAGENO | REAL | SIZE | SQL | STATUS | TEMP | TIME | TODAY | TRUE | USER | WAIT | WEEKDAY | WORK) - | identifier - ; - + : ( + ACCEPT + | ASCII + | COUNT + | CURRENT + | FALSE + | FIRST + | FOUND + | GROUP + | HIDE + | INDEX + | INT_FLAG + | INTERRUPT + | LAST + | LENGTH + | LINENO + | MDY + | NO + | NOT + | NOTFOUND + | NULL_ + | PAGENO + | REAL + | SIZE + | SQL + | STATUS + | TEMP + | TIME + | TODAY + | TRUE + | USER + | WAIT + | WEEKDAY + | WORK + ) + | identifier + ; fragment A - : ('a' | 'A') - ; - + : ('a' | 'A') + ; fragment B - : ('b' | 'B') - ; - + : ('b' | 'B') + ; fragment C - : ('c' | 'C') - ; - + : ('c' | 'C') + ; fragment D - : ('d' | 'D') - ; - + : ('d' | 'D') + ; fragment E - : ('e' | 'E') - ; - + : ('e' | 'E') + ; fragment F - : ('f' | 'F') - ; - + : ('f' | 'F') + ; fragment G - : ('g' | 'G') - ; - + : ('g' | 'G') + ; fragment H - : ('h' | 'H') - ; - + : ('h' | 'H') + ; fragment I - : ('i' | 'I') - ; - + : ('i' | 'I') + ; fragment J - : ('j' | 'J') - ; - + : ('j' | 'J') + ; fragment K - : ('k' | 'K') - ; - + : ('k' | 'K') + ; fragment L - : ('l' | 'L') - ; - + : ('l' | 'L') + ; fragment M - : ('m' | 'M') - ; - + : ('m' | 'M') + ; fragment N - : ('n' | 'N') - ; - + : ('n' | 'N') + ; fragment O - : ('o' | 'O') - ; - + : ('o' | 'O') + ; fragment P - : ('p' | 'P') - ; - + : ('p' | 'P') + ; fragment Q - : ('q' | 'Q') - ; - + : ('q' | 'Q') + ; fragment R - : ('r' | 'R') - ; - + : ('r' | 'R') + ; fragment S - : ('s' | 'S') - ; - + : ('s' | 'S') + ; fragment T - : ('t' | 'T') - ; - + : ('t' | 'T') + ; fragment U - : ('u' | 'U') - ; - + : ('u' | 'U') + ; fragment V - : ('v' | 'V') - ; - + : ('v' | 'V') + ; fragment W - : ('w' | 'W') - ; - + : ('w' | 'W') + ; fragment X - : ('x' | 'X') - ; - + : ('x' | 'X') + ; fragment Y - : ('y' | 'Y') - ; - + : ('y' | 'Y') + ; fragment Z - : ('z' | 'Z') - ; - + : ('z' | 'Z') + ; ABSOLUTE - : A B S O L U T E - ; - + : A B S O L U T E + ; AFTER - : A F T E R - ; - + : A F T E R + ; ACCEPT - : A C C E P T - ; - + : A C C E P T + ; AGGREGATE - : A G G R E G A T E - ; - + : A G G R E G A T E + ; ALLOCATE - : A L L O C A T E - ; - + : A L L O C A T E + ; ALL - : A L L - ; - + : A L L + ; ALL_ROWS - : A L L '_' R O W S - ; - + : A L L '_' R O W S + ; AND - : A N D - ; - + : A N D + ; ANY - : A N Y - ; - + : A N Y + ; AS - : A S - ; - + : A S + ; ASC - : A S C - ; - + : A S C + ; ASCII - : A S C I I - ; - + : A S C I I + ; AT - : A T - ; - + : A T + ; ATTRIBUTE - : A T T R I B U T E - ; - + : A T T R I B U T E + ; ATTRIBUTES - : A T T R I B U T E S - ; - + : A T T R I B U T E S + ; AVERAGE - : A V E R A G E - ; - + : A V E R A G E + ; AVG - : A V G - ; - + : A V G + ; ARRAY - : A R R A Y - ; - + : A R R A Y + ; BEFORE - : B E F O R E - ; - + : B E F O R E + ; BEGIN - : B E G I N - ; + : B E G I N + ; //TRANSACTION CONTROL BETWEEN - : B E T W E E N - ; - + : B E T W E E N + ; BIGINT - : B I G I N T - ; - + : B I G I N T + ; BLACK - : B L A C K - ; - + : B L A C K + ; BLINK - : B L I N K - ; - + : B L I N K + ; BLUE - : B L U E - ; - + : B L U E + ; BOLD - : B O L D - ; - + : B O L D + ; BORDER - : B O R D E R - ; - + : B O R D E R + ; BOTTOM - : B O T T O M - ; - + : B O T T O M + ; BUFFERED - : B U F F E R E D - ; - + : B U F F E R E D + ; BY - : B Y - ; - + : B Y + ; BYTE - : B Y T E - ; - + : B Y T E + ; CACHE - : C A C H E - ; - + : C A C H E + ; CALL - : C A L L - ; - + : C A L L + ; CASE - : C A S E - ; - + : C A S E + ; CHAR - : C H A R - ; - + : C H A R + ; CHARARACTER - : C H A R A R A C T E R - ; - + : C H A R A R A C T E R + ; CHAR_LENGTH - : C H A R '_' L E N G T H - ; - + : C H A R '_' L E N G T H + ; CHECK - : C H E C K - ; - + : C H E C K + ; CLEAR - : C L E A R - ; - + : C L E A R + ; CLIPPED - : C L I P P E D - ; - + : C L I P P E D + ; CLOSE - : C L O S E - ; - + : C L O S E + ; CLUSTER - : C L U S T E R - ; - + : C L U S T E R + ; COLUMN - : C O L U M N - ; - + : C O L U M N + ; COLUMNS - : C O L U M N S - ; - + : C O L U M N S + ; COMMAND - : C O M M A N D - ; - + : C O M M A N D + ; COMMENT - : C O M M E N T - ; - + : C O M M E N T + ; COMMIT - : C O M M I T - ; - + : C O M M I T + ; COMMITTED - : C O M M I T T E D - ; - + : C O M M I T T E D + ; CONSTANT - : C O N S T A N T - ; - + : C O N S T A N T + ; CONSTRAINED - : C O N S T R A I N E D - ; - + : C O N S T R A I N E D + ; CONSTRAINT - : C O N S T R A I N T - ; - + : C O N S T R A I N T + ; CONSTRUCT - : C O N S T R U C T - ; - + : C O N S T R U C T + ; CONTINUE - : C O N T I N U E - ; - + : C O N T I N U E + ; COUNT - : C O U N T - ; - + : C O U N T + ; COPY - : C O P Y - ; - + : C O P Y + ; CRCOLS - : C R C O L S - ; - + : C R C O L S + ; CREATE - : C R E A T E - ; - + : C R E A T E + ; CURRENT - : C U R R E N T - ; - + : C U R R E N T + ; CURSOR - : C U R S O R - ; - + : C U R S O R + ; CYAN - : C Y A N - ; - + : C Y A N + ; DATABASE - : D A T A B A S E - ; - + : D A T A B A S E + ; DATE - : D A T E - ; - + : D A T E + ; DATETIME - : D A T E T I M E - ; - + : D A T E T I M E + ; DAY - : D A Y - ; - + : D A Y + ; DEALLOCATE - : D E A L L O C A T E - ; - + : D E A L L O C A T E + ; DEC - : D E C - ; - + : D E C + ; DECIMAL - : D E C I M A L - ; - + : D E C I M A L + ; DECODE - : D E C O D E - ; - + : D E C O D E + ; DECLARE - : D E C L A R E - ; - + : D E C L A R E + ; DEFAULT - : D E F A U L T - ; - + : D E F A U L T + ; DEFAULTS - : D E F A U L T S - ; - + : D E F A U L T S + ; DEFER - : D E F E R - ; - + : D E F E R + ; DEFINE - : D E F I N E - ; - + : D E F I N E + ; DELETE - : D E L E T E - ; + : D E L E T E + ; //SQL DELIMITER - : D E L I M I T E R - ; + : D E L I M I T E R + ; //SQL DESC - : D E S C - ; - + : D E S C + ; DIM - : D I M - ; - + : D I M + ; DIMENSIONS - : D I M E N S I O N S - ; - + : D I M E N S I O N S + ; DIRTY - : D I R T Y - ; - + : D I R T Y + ; DISPLAY - : D I S P L A Y - ; - + : D I S P L A Y + ; DISTINCT - : D I S T I N C T - ; - + : D I S T I N C T + ; DO - : D O - ; - + : D O + ; DOUBLE - : D O U B L E - ; - + : D O U B L E + ; DOWN - : D O W N - ; - + : D O W N + ; DROP - : D R O P - ; - + : D R O P + ; DYNAMIC - : D Y N A M I C - ; - + : D Y N A M I C + ; ELSE - : E L S E - ; - + : E L S E + ; END - : E N D - ; - + : E N D + ; ERROR - : E R R O R - ; - + : E R R O R + ; ESCAPE - : E S C A P E - ; - + : E S C A P E + ; EVERY - : E V E R Y - ; - + : E V E R Y + ; EXCLUSIVE - : E X C L U S I V E - ; - + : E X C L U S I V E + ; EXEC - : E X E C - ; - + : E X E C + ; EXECUTE - : E X E C U T E - ; - + : E X E C U T E + ; EXIT - : E X I T - ; - + : E X I T + ; EXISTS - : E X I S T S - ; - + : E X I S T S + ; EXPLAIN - : E X P L A I N - ; - + : E X P L A I N + ; EXTEND - : E X T E N D - ; - + : E X T E N D + ; EXTENT - : E X T E N T - ; - + : E X T E N T + ; EXTERNAL - : E X T E R N A L - ; - + : E X T E R N A L + ; FALSE - : F A L S E - ; - + : F A L S E + ; FETCH - : F E T C H - ; - + : F E T C H + ; FIELD - : F I E L D - ; - + : F I E L D + ; FIELD_TOUCHED - : F I E L D '_' T O U C H E D - ; - + : F I E L D '_' T O U C H E D + ; FILE - : F I L E - ; - + : F I L E + ; FINISH - : F I N I S H - ; - + : F I N I S H + ; FIRST - : F I R S T - ; - + : F I R S T + ; FIRST_ROWS - : F I R S T '_' R O W S - ; - + : F I R S T '_' R O W S + ; FLOAT - : F L O A T - ; - + : F L O A T + ; FLUSH - : F L U S H - ; - + : F L U S H + ; FOR - : F O R - ; - + : F O R + ; FORM - : F O R M - ; - + : F O R M + ; FORMAT - : F O R M A T - ; - + : F O R M A T + ; FORMONLY - : F O R M O N L Y - ; - + : F O R M O N L Y + ; FOREACH - : F O R E A C H - ; - + : F O R E A C H + ; FOUND - : F O U N D - ; - + : F O U N D + ; FRACTION - : F R A C T I O N - ; - + : F R A C T I O N + ; FREE - : F R E E - ; - + : F R E E + ; FROM - : F R O M - ; + : F R O M + ; //SQL & PREPARE FUNCTION - : F U N C T I O N - ; - + : F U N C T I O N + ; GET_FLDBUF - : G E T F L D B U F - ; - + : G E T F L D B U F + ; GLOBALS - : G L O B A L S - ; - + : G L O B A L S + ; GO - : G O - ; - + : G O + ; GOTO - : G O T O - ; - + : G O T O + ; GREEN - : G R E E N - ; - + : G R E E N + ; GROUP - : G R O U P - ; + : G R O U P + ; //SQL HAVING - : H A V I N G - ; + : H A V I N G + ; //SQL HEADER - : H E A D E R - ; - + : H E A D E R + ; HELP - : H E L P - ; - + : H E L P + ; HIDE - : H I D E - ; - + : H I D E + ; HOLD - : H O L D - ; + : H O L D + ; //CURSOR HOUR - : H O U R - ; + : H O U R + ; //CURSOR IF - : I F - ; - + : I F + ; IN - : I N - ; + : I N + ; //SQL INNER - : I N N E R - ; + : I N N E R + ; //SQL INDEX - : I N D E X - ; + : I N D E X + ; //SQL INDICATOR - : I N D I C A T O R - ; + : I N D I C A T O R + ; //SQL INFIELD - : I N F I E L D - ; - + : I N F I E L D + ; INITIALIZE - : I N I T I A L I Z E - ; - + : I N I T I A L I Z E + ; INPUT - : I N P U T - ; - + : I N P U T + ; INSERT - : I N S E R T - ; + : I N S E R T + ; //SQL INSTRUCTIONS - : I N S T R U C T I O N S - ; - + : I N S T R U C T I O N S + ; INTO - : I N T O - ; + : I N T O + ; //SQL & CURSOR INT - : I N T - ; - + : I N T + ; INT_FLAG - : I N T '_' F L A G - ; - + : I N T '_' F L A G + ; INTEGER - : I N T E G E R - ; - + : I N T E G E R + ; INTERRUPT - : I N T E R R U P T - ; - + : I N T E R R U P T + ; INTERVAL - : I N T E R V A L - ; - + : I N T E R V A L + ; INVISIBLE - : I N V I S I B L E - ; - + : I N V I S I B L E + ; IS - : I S - ; - + : I S + ; ISNULL - : I S N U L L - ; - + : I S N U L L + ; ISOLATION - : I S O L A T I O N - ; - + : I S O L A T I O N + ; JOIN - : J O I N - ; - + : J O I N + ; KEY - : K E Y - ; - + : K E Y + ; LABEL - : L A B E L - ; - + : L A B E L + ; LAST - : L A S T - ; - + : L A S T + ; LEFT - : L E F T - ; - + : L E F T + ; LENGTH - : L E N G T H - ; - + : L E N G T H + ; LET - : L E T - ; - + : L E T + ; LIKE - : L I K E - ; - + : L I K E + ; LINE - : L I N E - ; - + : L I N E + ; LINENO - : L I N E N O - ; - + : L I N E N O + ; LINES - : L I N E S - ; - + : L I N E S + ; LOAD - : L O A D - ; - + : L O A D + ; LOCATE - : L O C A T E - ; - + : L O C A T E + ; LOCK - : L O C K - ; - + : L O C K + ; LOG - : L O G - ; - + : L O G + ; LONG - : L O N G - ; - + : L O N G + ; MAGENTA - : M A G E N T A - ; - + : M A G E N T A + ; MATCHES - : M A T C H E S - ; - + : M A T C H E S + ; MENU - : M E N U - ; - + : M E N U + ; MESSAGE - : M E S S A G E - ; - + : M E S S A G E + ; MAIN - : M A I N - ; - + : M A I N + ; MARGIN - : M A R G I N - ; - + : M A R G I N + ; MAX - : M A X - ; - + : M A X + ; MDY - : M D Y - ; - + : M D Y + ; MIN - : M I N - ; - + : M I N + ; MINUTE - : M I N U T E - ; - + : M I N U T E + ; MOD - : M O D - ; - + : M O D + ; MODE - : M O D E - ; - + : M O D E + ; MODULE - : M O D U L E - ; - + : M O D U L E + ; MONTH - : M O N T H - ; - + : M O N T H + ; MONEY - : M O N E Y - ; - + : M O N E Y + ; NCHAR - : N C H A R - ; - + : N C H A R + ; NAME - : N A M E - ; - + : N A M E + ; NEED - : N E E D - ; - + : N E E D + ; NEXT - : N E X T - ; - + : N E X T + ; NEW - : N E W - ; - + : N E W + ; NORMAL - : N O R M A L - ; - + : N O R M A L + ; NO - : N O - ; - + : N O + ; NOT - : N O T - ; - + : N O T + ; NOTFOUND - : N O T F O U N D - ; - + : N O T F O U N D + ; NOW - : N O W - ; - + : N O W + ; NUMERIC - : N U M E R I C - ; - + : N U M E R I C + ; NULL_ - : N U L L - ; - + : N U L L + ; NVARCHAR - : N V A R C H A R - ; + : N V A R C H A R + ; //SQL NVL - : N V L - ; - + : N V L + ; OF - : O F - ; - + : O F + ; OFF - : O F F - ; - + : O F F + ; ON - : O N - ; - + : O N + ; OPEN - : O P E N - ; - + : O P E N + ; OPTION - : O P T I O N - ; - + : O P T I O N + ; OPTIONS - : O P T I O N S - ; - + : O P T I O N S + ; OR - : O R - ; - + : O R + ; ORD - : O R D - ; - + : O R D + ; ORDER - : O R D E R - ; + : O R D E R + ; //SQL OUTPUT - : O U T P U T - ; - + : O U T P U T + ; OUTER - : O U T E R - ; + : O U T E R + ; //SQL OTHERWISE - : O T H E R W I S E - ; - + : O T H E R W I S E + ; PAGE - : P A G E - ; - + : P A G E + ; PAGENO - : P A G E N O - ; - + : P A G E N O + ; PAUSE - : P A U S E - ; - + : P A U S E + ; PERCENT - : P E R C E N T - ; - + : P E R C E N T + ; PIPE - : P I P E - ; - + : P I P E + ; PRECISION - : P R E C I S I O N - ; - + : P R E C I S I O N + ; PREPARE - : P R E P A R E - ; - + : P R E P A R E + ; PREVIOUS - : P R E V I O U S - ; - + : P R E V I O U S + ; PRINT - : P R I N T - ; - + : P R I N T + ; PRINTER - : P R I N T E R - ; - + : P R I N T E R + ; PROGRAM - : P R O G R A M - ; - + : P R O G R A M + ; PROMPT - : P R O M P T - ; - + : P R O M P T + ; PUT - : P U T - ; - + : P U T + ; QUIT - : Q U I T - ; - + : Q U I T + ; QUIT_FLAG - : Q U I T '_' F L A G - ; - + : Q U I T '_' F L A G + ; RECORD - : R E C O R D - ; - + : R E C O R D + ; REAL - : R E A L - ; - + : R E A L + ; READ - : R E A D - ; - + : R E A D + ; RED - : R E D - ; - + : R E D + ; RELATIVE - : R E L A T I V E - ; - + : R E L A T I V E + ; REMOVE - : R E M O V E - ; - + : R E M O V E + ; REOPTIMIZATION - : R E O P T I M I Z A T I O N - ; - + : R E O P T I M I Z A T I O N + ; REPEATABLE - : R E P E A T A B L E - ; - + : R E P E A T A B L E + ; REPEAT - : R E P E A T - ; - + : R E P E A T + ; REPORT - : R E P O R T - ; - + : R E P O R T + ; RESIZE - : R E S I Z E - ; - + : R E S I Z E + ; RETURN - : R E T U R N - ; - + : R E T U R N + ; RETURNING - : R E T U R N I N G - ; - + : R E T U R N I N G + ; REVERSE - : R E V E R S E - ; - + : R E V E R S E + ; RIGHT - : R I G H T - ; - + : R I G H T + ; ROLLBACK - : R O L L B A C K - ; - + : R O L L B A C K + ; ROW - : R O W - ; - + : R O W + ; ROWS - : R O W S - ; - + : R O W S + ; RUN - : R U N - ; - + : R U N + ; SCREEN - : S C R E E N - ; - + : S C R E E N + ; SCROLL - : S C R O L L - ; - + : S C R O L L + ; SECOND - : S E C O N D - ; - + : S E C O N D + ; SKIP2 - : S K I P - ; - + : S K I P + ; SELECT - : S E L E C T - ; - + : S E L E C T + ; SET - : S E T - ; - + : S E T + ; SHARE - : S H A R E - ; - + : S H A R E + ; SHOW - : S H O W - ; - + : S H O W + ; SIZE - : S I Z E - ; - + : S I Z E + ; SLEEP - : S L E E P - ; - + : S L E E P + ; SMALLFLOAT - : S M A L L F L O A T - ; - + : S M A L L F L O A T + ; SMALLINT - : S M A L L I N T - ; - + : S M A L L I N T + ; SPACE - : S P A C E - ; - + : S P A C E + ; SPACES - : S P A C E S - ; - + : S P A C E S + ; SQL - : S Q L - ; - + : S Q L + ; SQLERROR - : S Q L E R R O R - ; - + : S Q L E R R O R + ; SQLWARNING - : S Q L W A R N I N G - ; - + : S Q L W A R N I N G + ; START - : S T A R T - ; - + : S T A R T + ; STABILITY - : S T A B I L I T Y - ; - + : S T A B I L I T Y + ; STATISTICS - : S T A T I S T I C S - ; - + : S T A T I S T I C S + ; STATUS - : S T A T U S - ; - + : S T A T U S + ; STOP - : S T O P - ; - + : S T O P + ; SUM - : S U M - ; - + : S U M + ; TABLE - : T A B L E - ; - + : T A B L E + ; TABLES - : T A B L E S - ; - + : T A B L E S + ; TERMINATE - : T E R M I N A T E - ; - + : T E R M I N A T E + ; TEMP - : T E M P - ; - + : T E M P + ; TEXT - : T E X T - ; - + : T E X T + ; THEN - : T H E N - ; - + : T H E N + ; THROUGH - : T H R O U G H - ; - + : T H R O U G H + ; THRU - : T H R U - ; - + : T H R U + ; TIME - : T I M E - ; - + : T I M E + ; TO - : T O - ; - + : T O + ; TODAY - : T O D A Y - ; - + : T O D A Y + ; TOP - : T O P - ; - + : T O P + ; TRAILER - : T R A I L E R - ; - + : T R A I L E R + ; TRUE - : T R U E - ; - + : T R U E + ; TYPE - : T Y P E - ; - + : T Y P E + ; UNCONSTRAINED - : U N C O N S T R A I N E D - ; - + : U N C O N S T R A I N E D + ; UNDERLINE - : U N D E R L I N E - ; - + : U N D E R L I N E + ; UNION - : U N I O N - ; - + : U N I O N + ; UNIQUE - : U N I Q U E - ; - + : U N I Q U E + ; UNITS - : U N I T S - ; - + : U N I T S + ; UNLOAD - : U N L O A D - ; - + : U N L O A D + ; UP - : U P - ; - + : U P + ; UPDATE - : U P D A T E - ; + : U P D A T E + ; //SQL USER - : U S E R - ; - + : U S E R + ; USING - : U S I N G - ; - + : U S I N G + ; VALIDATE - : V A L I D A T E - ; - + : V A L I D A T E + ; VALUES - : V A L U E S - ; + : V A L U E S + ; //SQL VARCHAR - : V A R C H A R - ; + : V A R C H A R + ; //SQL WEEKDAY - : W E E K D A Y - ; - + : W E E K D A Y + ; VIEW - : V I E W - ; + : V I E W + ; //SQL WAIT - : W A I T - ; - + : W A I T + ; WAITING - : W A I T I N G - ; - + : W A I T I N G + ; WARNING - : W A R N I N G - ; - + : W A R N I N G + ; WHEN - : W H E N - ; - + : W H E N + ; WHENEVER - : W H E N E V E R - ; - + : W H E N E V E R + ; WHERE - : W H E R E - ; + : W H E R E + ; //SQL WHILE - : W H I L E - ; - + : W H I L E + ; WHITE - : W H I T E - ; - + : W H I T E + ; WITH - : W I T H - ; - + : W I T H + ; WITHOUT - : W I T H O U T - ; - + : W I T H O U T + ; WINDOW - : W I N D O W - ; - + : W I N D O W + ; WORDWRAP - : W O R D W R A P - ; - + : W O R D W R A P + ; WORK - : W O R K - ; - + : W O R K + ; YEAR - : Y E A R - ; - + : Y E A R + ; YELLOW - : Y E L L O W - ; + : Y E L L O W + ; //---------------------------------------------------------------------------- // OPERATORS //---------------------------------------------------------------------------- PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; STAR - : '*' - ; - + : '*' + ; SLASH - : '/' - ; - + : '/' + ; COMMA - : ',' - ; - + : ',' + ; SEMI - : ';' - ; - + : ';' + ; COLON - : ':' - ; - + : ':' + ; EQUAL - : '=' - ; + : '=' + ; //NOT_EQUAL : "<>" | "!=" ; // Why did I do this? Isn't this handle by just increasing the look ahead? NOT_EQUAL - : '<' (('>') | ('='))? | '!=' | '^=' - ; - + : '<' (('>') | ('='))? + | '!=' + | '^=' + ; LT - : '<' - ; - + : '<' + ; LE - : '<=' - ; - + : '<=' + ; GE - : '>=' - ; - + : '>=' + ; GT - : '>' - ; + : '>' + ; //GT // : '>' ('=')? // ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; LBRACK - : '[' - ; - + : '[' + ; RBRACK - : ']' - ; - + : ']' + ; DOT - : '.' - ; - + : '.' + ; ATSYMBOL - : '@' - ; - + : '@' + ; DOUBLEVERTBAR - : '||' - ; + : '||' + ; //COMMENT_1 // : '{' @@ -2856,8 +2738,8 @@ DOUBLEVERTBAR // if it's a literal or really an identifer IDENT - : ('a' .. 'z' | '_') ('a' .. 'z' | '_' | '0' .. '9')* - ; + : ('a' .. 'z' | '_') ('a' .. 'z' | '_' | '0' .. '9')* + ; // character literals /* @@ -2868,26 +2750,28 @@ CHAR_LITERAL // string literals STRING_LITERAL - : ('"') ( - /*ESC*|*/ ~ ('"' | '\\'))* ('"') | ('\'') ( - /*ESC|~*/ ('\\' | '\''))* ('\'') - ; + : ('"') ( +/*ESC*|*/ ~ ('"' | '\\'))* ('"') + | ('\'') ( +/*ESC|~*/ ('\\' | '\''))* ('\'') + ; // a numeric literal NUM_INT - : '.' (('0' .. '9')+)? | (('0' .. '9') ('0' .. '9')*) - ; - + : '.' (('0' .. '9')+)? + | (('0' .. '9') ('0' .. '9')*) + ; NUM_REAL - : ('0' .. '9')+ '.' ('0' .. '9')* EXPONENT? | '.' ('0' .. '9')+ EXPONENT? | ('0' .. '9')+ EXPONENT - ; - + : ('0' .. '9')+ '.' ('0' .. '9')* EXPONENT? + | '.' ('0' .. '9')+ EXPONENT? + | ('0' .. '9')+ EXPONENT + ; fragment EXPONENT - : ('e' | 'E') ('+' | '-')? ('0' .. '9')+ - ; + : ('e' | 'E') ('+' | '-')? ('0' .. '9')+ + ; // escape sequence -- note that this is protected; it can only be called // from another lexer rule -- it will not ever directly return a token to @@ -2929,26 +2813,23 @@ ESC // hexadecimal digit (again, note it's protected!) HEX_DIGIT - : ('0' .. '9' | 'a' .. 'f') - ; + : ('0' .. '9' | 'a' .. 'f') + ; // Single-line comments SL_COMMENT - : '#' ~ [\r\n]* -> skip - ; - + : '#' ~ [\r\n]* -> skip + ; SL_COMMENT_2 - : '--' ~ [\r\n]* -> skip - ; - + : '--' ~ [\r\n]* -> skip + ; EOL - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : [ \t] + -> skip - ; + : [ \t]+ -> skip + ; \ No newline at end of file diff --git a/infosapient/infosapient.g4 b/infosapient/infosapient.g4 index 4cbc3e0745..54b363eb40 100644 --- a/infosapient/infosapient.g4 +++ b/infosapient/infosapient.g4 @@ -29,79 +29,119 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar infosapient; conditionalRule - : IDENTIFIER premise consequent ';' EOF - ; + : IDENTIFIER premise consequent ';' EOF + ; premise - : IF clause - ; + : IF clause + ; consequent - : THEN attribClause (ELSE attribClause)? - ; + : THEN attribClause (ELSE attribClause)? + ; clause - : '(' clause ')' - | ((expr | attribClause) operator_ (expr | attribClause) (operator_ (expr | attribClause))*) - ; + : '(' clause ')' + | ((expr | attribClause) operator_ (expr | attribClause) (operator_ (expr | attribClause))*) + ; expr - : '(' expr ')' - | attribClause - ; + : '(' expr ')' + | attribClause + ; attribClause - : id_ ('s' | 'are') (hedgeCollection)? (nLiteral | id_ | restrictionHedge) - ; + : id_ ('s' | 'are') (hedgeCollection)? (nLiteral | id_ | restrictionHedge) + ; hedgeCollection - : (hedge)+ - ; + : (hedge)+ + ; restrictionHedge - : ('increased' | 'decreased') - ; + : ('increased' | 'decreased') + ; hedge - : ('about' | 'above' | 'after' | 'around' | 'before' | 'below' | 'closeTo' | 'definitely' | 'extremely' | 'generally' | 'mostly' | 'must' | 'near' | ('negative' | 'negatively') | 'not' | ('positive' | 'positively') | 'roughly' | 'should' | 'slightly' | 'somewhat' | 'very' | 'inVicinityOf') - ; + : ( + 'about' + | 'above' + | 'after' + | 'around' + | 'before' + | 'below' + | 'closeTo' + | 'definitely' + | 'extremely' + | 'generally' + | 'mostly' + | 'must' + | 'near' + | ('negative' | 'negatively') + | 'not' + | ('positive' | 'positively') + | 'roughly' + | 'should' + | 'slightly' + | 'somewhat' + | 'very' + | 'inVicinityOf' + ) + ; operator_ - : ('and' | 'boundedAnd' | 'cosineNot' | 'meanAnd' | 'meanOr' | 'or' | 'productAnd' | 'productOr' | 'sugenoNot' | 'thresholdNot' | 'yagerAnd' | 'yagerNot' | 'yagerOr') - ; + : ( + 'and' + | 'boundedAnd' + | 'cosineNot' + | 'meanAnd' + | 'meanOr' + | 'or' + | 'productAnd' + | 'productOr' + | 'sugenoNot' + | 'thresholdNot' + | 'yagerAnd' + | 'yagerNot' + | 'yagerOr' + ) + ; nLiteral - : FP_LITERAL - ; + : FP_LITERAL + ; id_ - : IDENTIFIER - ; + : IDENTIFIER + ; IDENTIFIER - : [a-zA-Z] [a-zA-Z0-9]* - ; + : [a-zA-Z] [a-zA-Z0-9]* + ; FP_LITERAL - : [0-9]* '.' [0-9]* - ; + : [0-9]* '.' [0-9]* + ; IF - : 'if' - ; + : 'if' + ; THEN - : 'then' - ; + : 'then' + ; ELSE - : 'else' - ; + : 'else' + ; WS - : [\r\n\t]+ -> skip - ; - + : [\r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/iri/IRI.g4 b/iri/IRI.g4 index 2f8a7ddc95..4d481977ea 100644 --- a/iri/IRI.g4 +++ b/iri/IRI.g4 @@ -35,637 +35,580 @@ // copy-pastes from the ABNF syntax from the reference linked above. // +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar IRI; /* * Parser rules */ parse - : iri EOF - ; + : iri EOF + ; /// IRI = scheme ":" ihier-part [ "?" iquery ] [ "#" ifragment ] iri - : scheme ':' ihier_part ('?' iquery)? ('#' ifragment)? - ; + : scheme ':' ihier_part ('?' iquery)? ('#' ifragment)? + ; /// ihier-part = "//" iauthority ipath-abempty/// / ipath-absolute/// / ipath-rootless/// / ipath-empty ihier_part - : '//' iauthority ipath_abempty - | ipath_absolute - | ipath_rootless - | ipath_empty - ; + : '//' iauthority ipath_abempty + | ipath_absolute + | ipath_rootless + | ipath_empty + ; /// IRI-reference = IRI / irelative-ref iri_reference - : iri - | irelative_ref - ; + : iri + | irelative_ref + ; /// absolute-IRI = scheme ":" ihier-part [ "?" iquery ] absolute_iri - : scheme ':' ihier_part ('?' iquery)? - ; + : scheme ':' ihier_part ('?' iquery)? + ; /// irelative-ref = irelative-part [ "?" iquery ] [ "#" ifragment ] irelative_ref - : irelative_part ('?' iquery)? ('#' ifragment)? - ; + : irelative_part ('?' iquery)? ('#' ifragment)? + ; /// irelative-part = "//" iauthority ipath-abempty/// / ipath-absolute/// / ipath-noscheme/// / ipath-empty irelative_part - : '//' iauthority ipath_abempty - | ipath_absolute - | ipath_noscheme - | ipath_empty - ; + : '//' iauthority ipath_abempty + | ipath_absolute + | ipath_noscheme + | ipath_empty + ; /// iauthority = [ iuserinfo "@" ] ihost [ ":" port ] iauthority - : (iuserinfo '@')? ihost (':' port)? - ; + : (iuserinfo '@')? ihost (':' port)? + ; /// iuserinfo = *( iunreserved / pct-encoded / sub-delims / ":" ) iuserinfo - : (iunreserved | pct_encoded | sub_delims | ':')* - ; + : (iunreserved | pct_encoded | sub_delims | ':')* + ; /// ihost = IP-literal / IPv4address / ireg-name ihost - : ip_literal - | ip_v4_address - | ireg_name - ; + : ip_literal + | ip_v4_address + | ireg_name + ; /// ireg-name = *( iunreserved / pct-encoded / sub-delims ) ireg_name - : (iunreserved | pct_encoded | sub_delims)* - ; + : (iunreserved | pct_encoded | sub_delims)* + ; /// ipath = ipath-abempty ; begins with "/" or is empty/// / ipath-absolute ; begins with "/" but not "//"/// / ipath-noscheme ; begins with a non-colon segment/// / ipath-rootless ; begins with a segment/// / ipath-empty ; zero characters ipath - : ipath_abempty - | ipath_absolute - | ipath_noscheme - | ipath_rootless - | ipath_empty - ; + : ipath_abempty + | ipath_absolute + | ipath_noscheme + | ipath_rootless + | ipath_empty + ; /// ipath-abempty = *( "/" isegment ) ipath_abempty - : ('/' isegment)* - ; + : ('/' isegment)* + ; /// ipath-absolute = "/" [ isegment-nz *( "/" isegment ) ] ipath_absolute - : '/' (isegment_nz ('/' isegment)*)? - ; + : '/' (isegment_nz ('/' isegment)*)? + ; /// ipath-noscheme = isegment-nz-nc *( "/" isegment ) ipath_noscheme - : isegment_nz_nc ('/' isegment)* - ; + : isegment_nz_nc ('/' isegment)* + ; /// ipath-rootless = isegment-nz *( "/" isegment ) ipath_rootless - : isegment_nz ('/' isegment)* - ; + : isegment_nz ('/' isegment)* + ; /// ipath-empty = 0 ipath_empty - :/* nothing */ - ; + : /* nothing */ + ; /// isegment = *ipchar isegment - : ipchar* - ; + : ipchar* + ; /// isegment-nz = 1*ipchar isegment_nz - : ipchar + - ; + : ipchar+ + ; /// isegment-nz-nc = 1*( iunreserved / pct-encoded / sub-delims / "@" )/// ; non-zero-length segment without any colon ":" isegment_nz_nc - : (iunreserved | pct_encoded | sub_delims | '@') + - ; + : (iunreserved | pct_encoded | sub_delims | '@')+ + ; /// ipchar = iunreserved / pct-encoded / sub-delims / ":" / "@" ipchar - : iunreserved - | pct_encoded - | sub_delims - | (':' | '@') - ; + : iunreserved + | pct_encoded + | sub_delims + | (':' | '@') + ; /// iquery = *( ipchar / iprivate / "/" / "?" ) iquery - : (ipchar | (IPRIVATE | '/' | '?'))* - ; + : (ipchar | (IPRIVATE | '/' | '?'))* + ; /// ifragment = *( ipchar / "/" / "?" ) ifragment - : (ipchar | ('/' | '?'))* - ; + : (ipchar | ('/' | '?'))* + ; /// iunreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" / ucschar iunreserved - : alpha - | digit - | ('-' | '.' | '_' | '~' | UCSCHAR) - ; + : alpha + | digit + | ('-' | '.' | '_' | '~' | UCSCHAR) + ; /// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) scheme - : alpha (alpha | digit | ('+' | '-' | '.'))* - ; + : alpha (alpha | digit | ('+' | '-' | '.'))* + ; /// port = *DIGIT port - : digit* - ; + : digit* + ; /// IP-literal = "[" ( IPv6address / IPvFuture ) "]" ip_literal - : '[' (ip_v6_address | ip_v_future) ']' - ; + : '[' (ip_v6_address | ip_v_future) ']' + ; /// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) ip_v_future - : V hexdig + '.' (unreserved | sub_delims | ':') + - ; + : V hexdig+ '.' (unreserved | sub_delims | ':')+ + ; /// IPv6address = 6( h16 ":" ) ls32/// / "::" 5( h16 ":" ) ls32/// / [ h16 ] "::" 4( h16 ":" ) ls32/// / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32/// / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32/// / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32/// / [ *4( h16 ":" ) h16 ] "::" ls32/// / [ *5( h16 ":" ) h16 ] "::" h16/// / [ *6( h16 ":" ) h16 ] "::" ip_v6_address - : h16 ':' h16 ':' h16 ':' h16 ':' h16 ':' h16 ':' ls32 - | '::' h16 ':' h16 ':' h16 ':' h16 ':' h16 ':' ls32 - | h16? '::' h16 ':' h16 ':' h16 ':' h16 ':' ls32 - | ((h16 ':')? h16)? '::' h16 ':' h16 ':' h16 ':' ls32 - | (((h16 ':')? h16 ':')? h16)? '::' h16 ':' h16 ':' ls32 - | ((((h16 ':')? h16 ':')? h16 ':')? h16)? '::' h16 ':' ls32 - | (((((h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16)? '::' ls32 - | ((((((h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16)? '::' h16 - | (((((((h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16)? '::' - ; + : h16 ':' h16 ':' h16 ':' h16 ':' h16 ':' h16 ':' ls32 + | '::' h16 ':' h16 ':' h16 ':' h16 ':' h16 ':' ls32 + | h16? '::' h16 ':' h16 ':' h16 ':' h16 ':' ls32 + | ((h16 ':')? h16)? '::' h16 ':' h16 ':' h16 ':' ls32 + | (((h16 ':')? h16 ':')? h16)? '::' h16 ':' h16 ':' ls32 + | ((((h16 ':')? h16 ':')? h16 ':')? h16)? '::' h16 ':' ls32 + | (((((h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16)? '::' ls32 + | ((((((h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16)? '::' h16 + | (((((((h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16 ':')? h16)? '::' + ; /// h16 = 1*4HEXDIG h16 - : hexdig hexdig hexdig hexdig - | hexdig hexdig hexdig - | hexdig hexdig - | hexdig - ; + : hexdig hexdig hexdig hexdig + | hexdig hexdig hexdig + | hexdig hexdig + | hexdig + ; /// ls32 = ( h16 ":" h16 ) / IPv4address ls32 - : h16 ':' h16 - | ip_v4_address - ; + : h16 ':' h16 + | ip_v4_address + ; /// IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet ip_v4_address - : dec_octet '.' dec_octet '.' dec_octet '.' dec_octet - ; + : dec_octet '.' dec_octet '.' dec_octet '.' dec_octet + ; /// dec-octet = DIGIT ; 0-9/// / %x31-39 DIGIT ; 10-99/// / "1" 2DIGIT ; 100-199/// / "2" %x30-34 DIGIT ; 200-249/// / "25" %x30-35 ; 250-255 dec_octet - : digit - | non_zero_digit digit - | D1 digit digit - | D2 (D0 | D1 | D2 | D3 | D4) digit - | D2 D5 (D0 | D1 | D2 | D3 | D4 | D5) - ; + : digit + | non_zero_digit digit + | D1 digit digit + | D2 (D0 | D1 | D2 | D3 | D4) digit + | D2 D5 (D0 | D1 | D2 | D3 | D4 | D5) + ; /// pct-encoded = "%" HEXDIG HEXDIG pct_encoded - : '%' hexdig hexdig - ; + : '%' hexdig hexdig + ; /// unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" unreserved - : alpha - | digit - | ('-' | '.' | '_' | '~') - ; + : alpha + | digit + | ('-' | '.' | '_' | '~') + ; /// reserved = gen-delims / sub-delims reserved - : gen_delims - | sub_delims - ; + : gen_delims + | sub_delims + ; /// gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" gen_delims - : ':' - | '/' - | '?' - | '#' - | '[' - | ']' - | '@' - ; + : ':' + | '/' + | '?' + | '#' + | '[' + | ']' + | '@' + ; /// sub-delims = "!" / "$" / "&" / "'" / "(" / ")"/// / "*" / "+" / "," / ";" / "=" sub_delims - : '!' - | '$' - | '&' - | '\'' - | '(' - | ')' - | '*' - | '+' - | ',' - | ';' - | '=' - ; + : '!' + | '$' + | '&' + | '\'' + | '(' + | ')' + | '*' + | '+' + | ',' + | ';' + | '=' + ; alpha - : A - | B - | C - | D - | E - | F - | G - | H - | I - | J - | K - | L - | M - | N - | O - | P - | Q - | R - | S - | T - | U - | V - | W - | X - | Y - | Z - ; + : A + | B + | C + | D + | E + | F + | G + | H + | I + | J + | K + | L + | M + | N + | O + | P + | Q + | R + | S + | T + | U + | V + | W + | X + | Y + | Z + ; hexdig - : digit - | (A | B | C | D | E | F) - ; + : digit + | (A | B | C | D | E | F) + ; digit - : D0 - | non_zero_digit - ; + : D0 + | non_zero_digit + ; non_zero_digit - : D1 - | D2 - | D3 - | D4 - | D5 - | D6 - | D7 - | D8 - | D9 - ; + : D1 + | D2 + | D3 + | D4 + | D5 + | D6 + | D7 + | D8 + | D9 + ; /* * Lexer rules - *//// ucschar = %xA0-D7FF / %xF900-FDCF / %xFDF0-FFEF/// / %x10000-1FFFD / %x20000-2FFFD / %x30000-3FFFD/// / %x40000-4FFFD / %x50000-5FFFD / %x60000-6FFFD/// / %x70000-7FFFD / %x80000-8FFFD / %x90000-9FFFD/// / %xA0000-AFFFD / %xB0000-BFFFD / %xC0000-CFFFD/// / %xD0000-DFFFD / %xE1000-EFFFD + */ +/// ucschar = %xA0-D7FF / %xF900-FDCF / %xFDF0-FFEF/// / %x10000-1FFFD / %x20000-2FFFD / %x30000-3FFFD/// / %x40000-4FFFD / %x50000-5FFFD / %x60000-6FFFD/// / %x70000-7FFFD / %x80000-8FFFD / %x90000-9FFFD/// / %xA0000-AFFFD / %xB0000-BFFFD / %xC0000-CFFFD/// / %xD0000-DFFFD / %xE1000-EFFFD UCSCHAR - : '\u00A0' .. '\uD7FF' - | '\uF900' .. '\uFDCF' - | '\uFDF0' .. '\uFFEF' - | '\u{10000}' .. '\u{1FFFD}' - | '\u{20000}' .. '\u{2FFFD}' - | '\u{30000}' .. '\u{3FFFD}' - | '\u{40000}' .. '\u{4FFFD}' - | '\u{50000}' .. '\u{5FFFD}' - | '\u{60000}' .. '\u{6FFFD}' - | '\u{70000}' .. '\u{7FFFD}' - | '\u{80000}' .. '\u{8FFFD}' - | '\u{90000}' .. '\u{9FFFD}' - | '\u{A0000}' .. '\u{AFFFD}' - | '\u{B0000}' .. '\u{BFFFD}' - | '\u{C0000}' .. '\u{CFFFD}' - | '\u{D0000}' .. '\u{DFFFD}' - | '\u{E1000}' .. '\u{EFFFD}' - ; + : '\u00A0' .. '\uD7FF' + | '\uF900' .. '\uFDCF' + | '\uFDF0' .. '\uFFEF' + | '\u{10000}' .. '\u{1FFFD}' + | '\u{20000}' .. '\u{2FFFD}' + | '\u{30000}' .. '\u{3FFFD}' + | '\u{40000}' .. '\u{4FFFD}' + | '\u{50000}' .. '\u{5FFFD}' + | '\u{60000}' .. '\u{6FFFD}' + | '\u{70000}' .. '\u{7FFFD}' + | '\u{80000}' .. '\u{8FFFD}' + | '\u{90000}' .. '\u{9FFFD}' + | '\u{A0000}' .. '\u{AFFFD}' + | '\u{B0000}' .. '\u{BFFFD}' + | '\u{C0000}' .. '\u{CFFFD}' + | '\u{D0000}' .. '\u{DFFFD}' + | '\u{E1000}' .. '\u{EFFFD}' + ; /// iprivate = %xE000-F8FF / %xF0000-FFFFD / %x100000-10FFFD IPRIVATE - : '\uE000' .. '\uF8FF' - | '\u{F0000}' .. '\u{FFFFD}' - | '\u{100000}' .. '\u{10FFFD}' - ; - + : '\uE000' .. '\uF8FF' + | '\u{F0000}' .. '\u{FFFFD}' + | '\u{100000}' .. '\u{10FFFD}' + ; D0 - : '0' - ; - + : '0' + ; D1 - : '1' - ; - + : '1' + ; D2 - : '2' - ; - + : '2' + ; D3 - : '3' - ; - + : '3' + ; D4 - : '4' - ; - + : '4' + ; D5 - : '5' - ; - + : '5' + ; D6 - : '6' - ; - + : '6' + ; D7 - : '7' - ; - + : '7' + ; D8 - : '8' - ; - + : '8' + ; D9 - : '9' - ; - + : '9' + ; A - : [aA] - ; - + : [aA] + ; B - : [bB] - ; - + : [bB] + ; C - : [cC] - ; - + : [cC] + ; D - : [dD] - ; - + : [dD] + ; E - : [eE] - ; - + : [eE] + ; F - : [fF] - ; - + : [fF] + ; G - : [gG] - ; - + : [gG] + ; H - : [hH] - ; - + : [hH] + ; I - : [iI] - ; - + : [iI] + ; J - : [jJ] - ; - + : [jJ] + ; K - : [kK] - ; - + : [kK] + ; L - : [lL] - ; - + : [lL] + ; M - : [mM] - ; - + : [mM] + ; N - : [nN] - ; - + : [nN] + ; O - : [oO] - ; - + : [oO] + ; P - : [pP] - ; - + : [pP] + ; Q - : [qQ] - ; - + : [qQ] + ; R - : [rR] - ; - + : [rR] + ; S - : [sS] - ; - + : [sS] + ; T - : [tT] - ; - + : [tT] + ; U - : [uU] - ; - + : [uU] + ; V - : [vV] - ; - + : [vV] + ; W - : [wW] - ; - + : [wW] + ; X - : [xX] - ; - + : [xX] + ; Y - : [yY] - ; - + : [yY] + ; Z - : [zZ] - ; - + : [zZ] + ; COL2 - : '::' - ; - + : '::' + ; COL - : ':' - ; - + : ':' + ; DOT - : '.' - ; - + : '.' + ; PERCENT - : '%' - ; - + : '%' + ; HYPHEN - : '-' - ; - + : '-' + ; TILDE - : '~' - ; - + : '~' + ; USCORE - : '_' - ; - + : '_' + ; EXCL - : '!' - ; - + : '!' + ; DOLLAR - : '$' - ; - + : '$' + ; AMP - : '&' - ; - + : '&' + ; SQUOTE - : '\'' - ; - + : '\'' + ; OPAREN - : '(' - ; - + : '(' + ; CPAREN - : ')' - ; - + : ')' + ; STAR - : '*' - ; - + : '*' + ; PLUS - : '+' - ; - + : '+' + ; COMMA - : ',' - ; - + : ',' + ; SCOL - : ';' - ; - + : ';' + ; EQUALS - : '=' - ; - + : '=' + ; FSLASH2 - : '//' - ; - + : '//' + ; FSLASH - : '/' - ; - + : '/' + ; QMARK - : '?' - ; - + : '?' + ; HASH - : '#' - ; - + : '#' + ; OBRACK - : '[' - ; - + : '[' + ; CBRACK - : ']' - ; - + : ']' + ; AT - : '@' - ; + : '@' + ; \ No newline at end of file diff --git a/iso8601/iso8601.g4 b/iso8601/iso8601.g4 index 3c6b7c4cce..9022727967 100644 --- a/iso8601/iso8601.g4 +++ b/iso8601/iso8601.g4 @@ -18,88 +18,235 @@ // reference document: // https://www.loc.gov/standards/datetime/iso-tc154-wg5_n0038_iso_wd_8601-1_2016-02-16.pdf +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar iso8601; // lexer -Newline: [\r\n] -> channel(HIDDEN); -T: [Tt]; -Z: [Zz]; -W: [Ww]; -P: [Pp]; -Y: [Yy]; -M: [Mm]; -D: [Dd]; -H: [Hh]; -S: [Ss]; -R: [Rr]; -Digit: [0-9]; -Fraction: [,.] Digit+; +Newline + : [\r\n] -> channel(HIDDEN) + ; + +T + : [Tt] + ; + +Z + : [Zz] + ; + +W + : [Ww] + ; + +P + : [Pp] + ; + +Y + : [Yy] + ; + +M + : [Mm] + ; + +D + : [Dd] + ; + +H + : [Hh] + ; + +S + : [Ss] + ; + +R + : [Rr] + ; + +Digit + : [0-9] + ; + +Fraction + : [,.] Digit+ + ; // number -int_: Digit+; -dec: Digit+ Fraction?; -int2: Digit Digit; -int3: Digit Digit Digit; -int4: Digit Digit Digit Digit; -sint2p: ('+'|'-') Digit Digit+; -sint4p: ('+'|'-') Digit Digit Digit Digit+; -dec2: Digit Digit Fraction?; +int_ + : Digit+ + ; + +dec + : Digit+ Fraction? + ; + +int2 + : Digit Digit + ; + +int3 + : Digit Digit Digit + ; + +int4 + : Digit Digit Digit Digit + ; + +sint2p + : ('+' | '-') Digit Digit+ + ; + +sint4p + : ('+' | '-') Digit Digit Digit Digit+ + ; + +dec2 + : Digit Digit Fraction? + ; // datetime element century - : int2 # CompleteCentury - | sint2p # ExpandedCentury + : int2 # CompleteCentury + | sint2p # ExpandedCentury ; + year - : int4 # CompleteYear - | sint4p # ExpandedYear - ; -month: int2; -day: int2; -ordinalDay: int3; -week: int2; -weekDay: Digit; -hour: int2; -minute: int2; -second: int2; -hourFraction: dec2; -minuteFraction: dec2; -secondFraction: dec2; + : int4 # CompleteYear + | sint4p # ExpandedYear + ; + +month + : int2 + ; + +day + : int2 + ; + +ordinalDay + : int3 + ; + +week + : int2 + ; + +weekDay + : Digit + ; + +hour + : int2 + ; + +minute + : int2 + ; + +second + : int2 + ; + +hourFraction + : dec2 + ; + +minuteFraction + : dec2 + ; + +secondFraction + : dec2 + ; // ENTRYRULE 1926-08-17 4.1.2.2 & 4.1.2.4 a -calendarDate: calendarDateBasic | calendarDateExtended; -calendarDateBasic: year month day; -calendarDateExtended: year '-' month '-' day; +calendarDate + : calendarDateBasic + | calendarDateExtended + ; + +calendarDateBasic + : year month day + ; + +calendarDateExtended + : year '-' month '-' day + ; // ENTRYRULE 1926-08 4.1.2.3 a & 4.1.2.4 b -specificMonthCalendarDate: year '-' month; +specificMonthCalendarDate + : year '-' month + ; + // ENTRYRULE 1926 4.1.2.3 b & 4.1.2.4 c -specificYearCalendarDate: year; +specificYearCalendarDate + : year + ; + // ENTRYRULE 19 (it means 20 century here) 4.1.2.3 c & 4.1.2.4 d -specificCenturyCalendarDate: century; +specificCenturyCalendarDate + : century + ; // ENTRYRULE 1926-229 4.1.3.2 & 4.1.3.3 -ordinalDate: ordinalDateBasic | ordinalDateExtended; -ordinalDateBasic: year ordinalDay; -ordinalDateExtended: year '-' ordinalDay; +ordinalDate + : ordinalDateBasic + | ordinalDateExtended + ; + +ordinalDateBasic + : year ordinalDay + ; + +ordinalDateExtended + : year '-' ordinalDay + ; // ENTRYRULE 1926-W33-2 4.1.4.2 & 4.1.4.4 a -weekDate: weekDateBasic | weekDateExtended; -weekDateBasic: year W week weekDay; -weekDateExtended: year '-' W week '-' weekDay; +weekDate + : weekDateBasic + | weekDateExtended + ; + +weekDateBasic + : year W week weekDay + ; + +weekDateExtended + : year '-' W week '-' weekDay + ; // ENTRYRULE 1926-W33 4.1.4.3 & 4.1.4.4 b -specificWeekWeekDate: specificWeekWeekDateBasic | specificWeekWeekDateExtended; -specificWeekWeekDateBasic: year W week; -specificWeekWeekDateExtended: year '-' W week; +specificWeekWeekDate + : specificWeekWeekDateBasic + | specificWeekWeekDateExtended + ; + +specificWeekWeekDateBasic + : year W week + ; + +specificWeekWeekDateExtended + : year '-' W week + ; // ENTRYRULE (any date precise to day) -datePrecise: datePreciseBasic | datePreciseExtended; +datePrecise + : datePreciseBasic + | datePreciseExtended + ; + datePreciseBasic : calendarDateBasic | ordinalDateBasic | weekDateBasic ; + datePreciseExtended : calendarDateExtended | ordinalDateExtended @@ -107,7 +254,11 @@ datePreciseExtended ; // ENTRYRULE (any date format) -date: dateBasic | dateExtended; +date + : dateBasic + | dateExtended + ; + dateBasic : datePreciseBasic | specificMonthCalendarDate @@ -115,6 +266,7 @@ dateBasic | specificCenturyCalendarDate | specificWeekWeekDateBasic ; + dateExtended : datePreciseExtended | specificMonthCalendarDate @@ -124,61 +276,140 @@ dateExtended ; // ENTRYRULE 12:34:56.0721 4.2.2.2 & 4.2.2.4 a -localTimePrecise: localTimePreciseBasic | localTimePreciseExtended; -localTimePreciseBasic: hour minute secondFraction; -localTimePreciseExtended: hour ':' minute ':' secondFraction; +localTimePrecise + : localTimePreciseBasic + | localTimePreciseExtended + ; + +localTimePreciseBasic + : hour minute secondFraction + ; + +localTimePreciseExtended + : hour ':' minute ':' secondFraction + ; // ENTRYRULE 12:34.5 4.2.2.3 a & 4.2.2.4 b -specificMinuteLocalTime: specificMinuteLocalTimeBasic | specificMinuteLocalTimeExtended; -specificMinuteLocalTimeBasic: hour minuteFraction; -specificMinuteLocalTimeExtended: hour ':' minuteFraction; +specificMinuteLocalTime + : specificMinuteLocalTimeBasic + | specificMinuteLocalTimeExtended + ; + +specificMinuteLocalTimeBasic + : hour minuteFraction + ; + +specificMinuteLocalTimeExtended + : hour ':' minuteFraction + ; // ENTRYRULE 12.5 (12:30:00) 4.2.2.3.b & 4.2.2.4 c -specificHourLocalTime: hourFraction; +specificHourLocalTime + : hourFraction + ; // ENTRYRULE (time without T and timezone) -localTime: localTimeBasic | localTimeExtended; +localTime + : localTimeBasic + | localTimeExtended + ; + localTimeBasic : localTimePreciseBasic | specificMinuteLocalTimeBasic | specificHourLocalTime ; + localTimeExtended - : localTimePreciseExtended - | specificMinuteLocalTimeExtended - | specificHourLocalTime - ; + : localTimePreciseExtended + | specificMinuteLocalTimeExtended + | specificHourLocalTime + ; // 4.2.4 -timeZoneUtc: Z; +timeZoneUtc + : Z + ; // ENTRYRULE +08:00 4.2.5.1 -timeZone: timeZoneBasic | timeZoneExtended; -timeZoneBasic: (('+'|'-') hour minute?)|timeZoneUtc; -timeZoneExtended: (('+'|'-') hour (':' minute)?)|timeZoneUtc; +timeZone + : timeZoneBasic + | timeZoneExtended + ; + +timeZoneBasic + : (('+' | '-') hour minute?) + | timeZoneUtc + ; + +timeZoneExtended + : (('+' | '-') hour (':' minute)?) + | timeZoneUtc + ; // ENTRYRULE (time with timezone without T) 4.2.5.2 -localTimeAndTimeZone: localTimeAndTimeZoneBasic | localTimeAndTimeZoneExtended; -localTimeAndTimeZoneBasic: localTimeBasic timeZoneBasic; -localTimeAndTimeZoneExtended: localTimeExtended timeZoneExtended; +localTimeAndTimeZone + : localTimeAndTimeZoneBasic + | localTimeAndTimeZoneExtended + ; + +localTimeAndTimeZoneBasic + : localTimeBasic timeZoneBasic + ; + +localTimeAndTimeZoneExtended + : localTimeExtended timeZoneExtended + ; // ENTRYRULE (any time format) -time: T? localTime timeZone?; +time + : T? localTime timeZone? + ; // ENTRYRULE 1957-10-05T01:28:34+06:00 4.3.2 -datetimePrecise: datetimePreciseBasic | datetimePreciseExtended; -datetimePreciseBasic: calendarDateBasic T localTimePreciseBasic timeZoneBasic?; -datetimePreciseExtended: calendarDateExtended T localTimePreciseExtended timeZoneExtended?; +datetimePrecise + : datetimePreciseBasic + | datetimePreciseExtended + ; + +datetimePreciseBasic + : calendarDateBasic T localTimePreciseBasic timeZoneBasic? + ; + +datetimePreciseExtended + : calendarDateExtended T localTimePreciseExtended timeZoneExtended? + ; // ENTRYRULE (any datetime format)4.3.3 -datetime: datetimeBasic | datetimeExtended; -datetimeBasic: datePreciseBasic T localTimeBasic timeZoneBasic?; -datetimeExtended: datePreciseExtended T localTimeExtended timeZoneExtended?; +datetime + : datetimeBasic + | datetimeExtended + ; + +datetimeBasic + : datePreciseBasic T localTimeBasic timeZoneBasic? + ; + +datetimeExtended + : datePreciseExtended T localTimeExtended timeZoneExtended? + ; // ENTRYRULE (any interval format) 4.4.3.2 & 4.4.4.2.1 -interval: intervalT | intervalYMD; -intervalBasic: intervalT | intervalYMDBasic; -intervalExtended: intervalT | intervalYMDExtended; +interval + : intervalT + | intervalYMD + ; + +intervalBasic + : intervalT + | intervalYMDBasic + ; + +intervalExtended + : intervalT + | intervalYMDExtended + ; + // ENTRYRULE P1Y2M3DT4H5M6.789S intervalT : P (int_ Y)? (int_ M)? (int_ D)? T (int_ H)? (int_ M)? dec S @@ -193,6 +424,7 @@ intervalT monthDateBasic : month day ; + monthDateExtended : month '-' day ; @@ -204,6 +436,7 @@ intervalYMDTimeBasic | dateBasic | localTimeBasic ; + intervalYMDTimeExtended : monthDateExtended | day @@ -214,33 +447,74 @@ intervalYMDTimeExtended ; // ENTRYRULE P0001-02-03T00:00:00 4.4.4.2.2 -intervalYMD: intervalYMDBasic | intervalYMDExtended; -intervalYMDBasic: P intervalYMDTimeBasic; -intervalYMDExtended: P intervalYMDTimeExtended; +intervalYMD + : intervalYMDBasic + | intervalYMDExtended + ; + +intervalYMDBasic + : P intervalYMDTimeBasic + ; + +intervalYMDExtended + : P intervalYMDTimeExtended + ; // ENTRYRULE 1234-05-06T00:07:08/1234-05-06T00:07:09 4.4.4.1 -timeBeginEnd: timeBeginEndBasic | timeBeginEndExtended; -timeBeginEndBasic: intervalYMDTimeBasic '/' intervalYMDTimeBasic; -timeBeginEndExtended: intervalYMDTimeExtended '/' intervalYMDTimeExtended; +timeBeginEnd + : timeBeginEndBasic + | timeBeginEndExtended + ; + +timeBeginEndBasic + : intervalYMDTimeBasic '/' intervalYMDTimeBasic + ; + +timeBeginEndExtended + : intervalYMDTimeExtended '/' intervalYMDTimeExtended + ; // ENTRYRULE 1234-05-06T00:07:08/P1M 4.4.4.3 -timeBeginInterval: timeBeginIntervalBasic|timeBeginIntervalExtended; -timeBeginIntervalBasic: datetimeBasic '/' intervalBasic; -timeBeginIntervalExtended: datetimeExtended '/' intervalExtended; +timeBeginInterval + : timeBeginIntervalBasic + | timeBeginIntervalExtended + ; + +timeBeginIntervalBasic + : datetimeBasic '/' intervalBasic + ; + +timeBeginIntervalExtended + : datetimeExtended '/' intervalExtended + ; // ENTRYRULE P138Y/1234-05-06T00:07:09 4.4.4.4 -timeIntervalEnd: timeIntervalEndBasic|timeIntervalEndExtended; -timeIntervalEndBasic: intervalBasic '/' datetimeBasic; -timeIntervalEndExtended: intervalExtended '/' datetimeExtended; +timeIntervalEnd + : timeIntervalEndBasic + | timeIntervalEndExtended + ; + +timeIntervalEndBasic + : intervalBasic '/' datetimeBasic + ; + +timeIntervalEndExtended + : intervalExtended '/' datetimeExtended + ; // ENTRYRULE (any duration) -duration: durationBasic | durationExtended; +duration + : durationBasic + | durationExtended + ; + durationBasic : timeBeginEndBasic | timeBeginIntervalBasic | timeIntervalEndBasic | intervalBasic ; + durationExtended : timeBeginEndExtended | timeBeginIntervalExtended @@ -248,11 +522,23 @@ durationExtended | intervalExtended ; -recurringCount: R int_?; +recurringCount + : R int_? + ; + // ENTRYRULE R12/1900-01-01T00:00:00/P4294967296S 4.5.3 -recurring: recurringBasic | recurringExtended; -recurringBasic: recurringCount '/' durationBasic; -recurringExtended: recurringCount '/' durationExtended; +recurring + : recurringBasic + | recurringExtended + ; + +recurringBasic + : recurringCount '/' durationBasic + ; + +recurringExtended + : recurringCount '/' durationExtended + ; // try everything // if you just want parse 1926-08-17T12:34:56+08:00 @@ -261,9 +547,5 @@ recurringExtended: recurringCount '/' durationExtended; iso : // put time before date, to mitigate confusion between century and hour - ( time - | date - | datetime - | duration - | recurring - ) EOF; + (time | date | datetime | duration | recurring) EOF + ; \ No newline at end of file diff --git a/istc/istc.g4 b/istc/istc.g4 index b3899886f5..3ad71d2fbc 100644 --- a/istc/istc.g4 +++ b/istc/istc.g4 @@ -30,36 +30,40 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar istc; istc - : 'ISTC' ' ' registration SEP year SEP work SEP check EOF - ; + : 'ISTC' ' ' registration SEP year SEP work SEP check EOF + ; registration - : CHAR CHAR CHAR - ; + : CHAR CHAR CHAR + ; year - : CHAR CHAR CHAR CHAR - ; + : CHAR CHAR CHAR CHAR + ; work - : CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR - ; + : CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR + ; check - : CHAR - ; + : CHAR + ; SEP - : '-' | ' ' - ; + : '-' + | ' ' + ; CHAR - : ('A' .. 'F' | '0' .. '9') - ; + : ('A' .. 'F' | '0' .. '9') + ; WS - : [\r\n\t] + -> skip - ; + : [\r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/itn/itn.g4 b/itn/itn.g4 index 26d8ceee9d..8813d52bae 100644 --- a/itn/itn.g4 +++ b/itn/itn.g4 @@ -29,41 +29,44 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar itn; itinerary - : line* EOF - ; + : line* EOF + ; line - : longitude '|' latitude '|' descr '|' flag '|' - ; + : longitude '|' latitude '|' descr '|' flag '|' + ; longitude - : NUM - ; + : NUM + ; latitude - : NUM - ; + : NUM + ; descr - : TEXT - ; + : TEXT + ; flag - : NUM - ; + : NUM + ; NUM - : [0-9]+ - ; + : [0-9]+ + ; TEXT - : [ a-zA-Z0-9]+ - ; + : [ a-zA-Z0-9]+ + ; WS - : [\r\n\t]+ -> skip - ; - + : [\r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/jam/jam.g4 b/jam/jam.g4 index 8ed8ef66a6..00895f7675 100644 --- a/jam/jam.g4 +++ b/jam/jam.g4 @@ -29,85 +29,88 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar jam; jam - : section* EOF - ; + : section* EOF + ; section - : measure ('|' measure)* - ; + : measure ('|' measure)* + ; measure - : meter? (chord | repeatchord | rest | extendchord | repeatmeasure)+ - ; + : meter? (chord | repeatchord | rest | extendchord | repeatmeasure)+ + ; chord - : note (chordquality bass?) - ; + : note (chordquality bass?) + ; chordquality - : ('m' | 'M' | 'P' | 'd' | 'maj' | 'min' | 'dim' | 'aug')? NUM? (('-' | '+') NUM)? - ; + : ('m' | 'M' | 'P' | 'd' | 'maj' | 'min' | 'dim' | 'aug')? NUM? (('-' | '+') NUM)? + ; repeatchord - : SLASH - ; + : SLASH + ; extendchord - : EQ - ; + : EQ + ; repeatmeasure - : PCT - ; + : PCT + ; rest - : REST - ; + : REST + ; bass - : SLASH KEY - ; + : SLASH KEY + ; note - : KEY ('b' | '#')? - ; + : KEY ('b' | '#')? + ; meter - : '[' NUM '/' NUM ']' - ; + : '[' NUM '/' NUM ']' + ; KEY - : [A-G] - ; + : [A-G] + ; REST - : '-' - ; + : '-' + ; SLASH - : '/' - ; + : '/' + ; EQ - : '=' - ; + : '=' + ; PCT - : '%' - ; + : '%' + ; NUM - : [0-9]+ - ; + : [0-9]+ + ; COMMENT - : '#' ~ [\n\r]+ -> skip - ; + : '#' ~ [\n\r]+ -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/janus/janus.g4 b/janus/janus.g4 index 6f65d85adf..f6ea7844fd 100644 --- a/janus/janus.g4 +++ b/janus/janus.g4 @@ -29,114 +29,117 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar janus; program - : (IDENT ('[' NUM ']')?)* ('PROCEDURE' IDENT statements)* EOF - ; + : (IDENT ('[' NUM ']')?)* ('PROCEDURE' IDENT statements)* EOF + ; statements - : statement+ - ; + : statement+ + ; statement - : ifstmt - | dostmt - | callstmt - | readstmt - | writestmt - | lvalstmt - ; + : ifstmt + | dostmt + | callstmt + | readstmt + | writestmt + | lvalstmt + ; ifstmt - : 'IF' expression ('THEN' statements)? ('ELSE' statements)? 'FI' expression - ; + : 'IF' expression ('THEN' statements)? ('ELSE' statements)? 'FI' expression + ; dostmt - : 'FROM' expression ('DO' statements)? ('LOOP' statements)? 'UNTIL' expression - ; + : 'FROM' expression ('DO' statements)? ('LOOP' statements)? 'UNTIL' expression + ; callstmt - : 'CALL' IDENT - | 'UNCALL' IDENT - ; + : 'CALL' IDENT + | 'UNCALL' IDENT + ; readstmt - : 'READ' IDENT - ; + : 'READ' IDENT + ; writestmt - : 'WRITE' IDENT - ; + : 'WRITE' IDENT + ; lvalstmt - : lvalue modstmt - | lvalue swapstmt - ; + : lvalue modstmt + | lvalue swapstmt + ; modstmt - : '+=' expression - | '-=' expression - | '!=' expression - | '<=>' expression - ; + : '+=' expression + | '-=' expression + | '!=' expression + | '<=>' expression + ; swapstmt - : ':' lvalue - ; + : ':' lvalue + ; expression - : minexp - | minexp BINOP expression - ; + : minexp + | minexp BINOP expression + ; minexp - : '(' expression ')' - | '-' expression - | '~' expression - | lvalue - | constant - ; + : '(' expression ')' + | '-' expression + | '~' expression + | lvalue + | constant + ; lvalue - : IDENT - | IDENT '[' expression ']' - ; + : IDENT + | IDENT '[' expression ']' + ; constant - : NUM - ; + : NUM + ; BINOP - : '+' - | '-' - | '!' - | '<' - | '>' - | '&' - | '|' - | '=' - | '#' - | '<=' - | '>=' - | '*' - | '/' - | '\\' - ; + : '+' + | '-' + | '!' + | '<' + | '>' + | '&' + | '|' + | '=' + | '#' + | '<=' + | '>=' + | '*' + | '/' + | '\\' + ; IDENT - : [a-zA-Z] [a-zA-Z0-9]* - ; + : [a-zA-Z] [a-zA-Z0-9]* + ; NUM - : [0-9] - ; + : [0-9] + ; COMMENT - : ';' ~ [\r\n]* -> skip - ; + : ';' ~ [\r\n]* -> skip + ; WS - : [ \t\r\n]+ -> skip - ; - + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/java/java/JavaLexer.g4 b/java/java/JavaLexer.g4 index a340c6ab55..b3de61fea0 100644 --- a/java/java/JavaLexer.g4 +++ b/java/java/JavaLexer.g4 @@ -29,213 +29,205 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar JavaLexer; // Keywords -ABSTRACT: 'abstract'; -ASSERT: 'assert'; -BOOLEAN: 'boolean'; -BREAK: 'break'; -BYTE: 'byte'; -CASE: 'case'; -CATCH: 'catch'; -CHAR: 'char'; -CLASS: 'class'; -CONST: 'const'; -CONTINUE: 'continue'; -DEFAULT: 'default'; -DO: 'do'; -DOUBLE: 'double'; -ELSE: 'else'; -ENUM: 'enum'; -EXTENDS: 'extends'; -FINAL: 'final'; -FINALLY: 'finally'; -FLOAT: 'float'; -FOR: 'for'; -IF: 'if'; -GOTO: 'goto'; -IMPLEMENTS: 'implements'; -IMPORT: 'import'; -INSTANCEOF: 'instanceof'; -INT: 'int'; -INTERFACE: 'interface'; -LONG: 'long'; -NATIVE: 'native'; -NEW: 'new'; -PACKAGE: 'package'; -PRIVATE: 'private'; -PROTECTED: 'protected'; -PUBLIC: 'public'; -RETURN: 'return'; -SHORT: 'short'; -STATIC: 'static'; -STRICTFP: 'strictfp'; -SUPER: 'super'; -SWITCH: 'switch'; -SYNCHRONIZED: 'synchronized'; -THIS: 'this'; -THROW: 'throw'; -THROWS: 'throws'; -TRANSIENT: 'transient'; -TRY: 'try'; -VOID: 'void'; -VOLATILE: 'volatile'; -WHILE: 'while'; +ABSTRACT : 'abstract'; +ASSERT : 'assert'; +BOOLEAN : 'boolean'; +BREAK : 'break'; +BYTE : 'byte'; +CASE : 'case'; +CATCH : 'catch'; +CHAR : 'char'; +CLASS : 'class'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXTENDS : 'extends'; +FINAL : 'final'; +FINALLY : 'finally'; +FLOAT : 'float'; +FOR : 'for'; +IF : 'if'; +GOTO : 'goto'; +IMPLEMENTS : 'implements'; +IMPORT : 'import'; +INSTANCEOF : 'instanceof'; +INT : 'int'; +INTERFACE : 'interface'; +LONG : 'long'; +NATIVE : 'native'; +NEW : 'new'; +PACKAGE : 'package'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PUBLIC : 'public'; +RETURN : 'return'; +SHORT : 'short'; +STATIC : 'static'; +STRICTFP : 'strictfp'; +SUPER : 'super'; +SWITCH : 'switch'; +SYNCHRONIZED : 'synchronized'; +THIS : 'this'; +THROW : 'throw'; +THROWS : 'throws'; +TRANSIENT : 'transient'; +TRY : 'try'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; // Module related keywords -MODULE: 'module'; -OPEN: 'open'; -REQUIRES: 'requires'; -EXPORTS: 'exports'; -OPENS: 'opens'; -TO: 'to'; -USES: 'uses'; -PROVIDES: 'provides'; -WITH: 'with'; -TRANSITIVE: 'transitive'; +MODULE : 'module'; +OPEN : 'open'; +REQUIRES : 'requires'; +EXPORTS : 'exports'; +OPENS : 'opens'; +TO : 'to'; +USES : 'uses'; +PROVIDES : 'provides'; +WITH : 'with'; +TRANSITIVE : 'transitive'; // Local Variable Type Inference -VAR: 'var'; // reserved type name +VAR: 'var'; // reserved type name // Switch Expressions -YIELD: 'yield'; // reserved type name from Java 14 +YIELD: 'yield'; // reserved type name from Java 14 // Records -RECORD: 'record'; +RECORD: 'record'; // Sealed Classes -SEALED: 'sealed'; -PERMITS: 'permits'; -NON_SEALED: 'non-sealed'; +SEALED : 'sealed'; +PERMITS : 'permits'; +NON_SEALED : 'non-sealed'; // Literals -DECIMAL_LITERAL: ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?; -HEX_LITERAL: '0' [xX] [0-9a-fA-F] ([0-9a-fA-F_]* [0-9a-fA-F])? [lL]?; -OCT_LITERAL: '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?; -BINARY_LITERAL: '0' [bB] [01] ([01_]* [01])? [lL]?; +DECIMAL_LITERAL : ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?; +HEX_LITERAL : '0' [xX] [0-9a-fA-F] ([0-9a-fA-F_]* [0-9a-fA-F])? [lL]?; +OCT_LITERAL : '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?; +BINARY_LITERAL : '0' [bB] [01] ([01_]* [01])? [lL]?; -FLOAT_LITERAL: (Digits '.' Digits? | '.' Digits) ExponentPart? [fFdD]? - | Digits (ExponentPart [fFdD]? | [fFdD]) - ; +FLOAT_LITERAL: + (Digits '.' Digits? | '.' Digits) ExponentPart? [fFdD]? + | Digits (ExponentPart [fFdD]? | [fFdD]) +; -HEX_FLOAT_LITERAL: '0' [xX] (HexDigits '.'? | HexDigits? '.' HexDigits) [pP] [+-]? Digits [fFdD]?; +HEX_FLOAT_LITERAL: '0' [xX] (HexDigits '.'? | HexDigits? '.' HexDigits) [pP] [+-]? Digits [fFdD]?; -BOOL_LITERAL: 'true' - | 'false' - ; +BOOL_LITERAL: 'true' | 'false'; -CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; +CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; -STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; +STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; -TEXT_BLOCK: '"""' [ \t]* [\r\n] (. | EscapeSequence)*? '"""'; +TEXT_BLOCK: '"""' [ \t]* [\r\n] (. | EscapeSequence)*? '"""'; -NULL_LITERAL: 'null'; +NULL_LITERAL: 'null'; // Separators -LPAREN: '('; -RPAREN: ')'; -LBRACE: '{'; -RBRACE: '}'; -LBRACK: '['; -RBRACK: ']'; -SEMI: ';'; -COMMA: ','; -DOT: '.'; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; // Operators -ASSIGN: '='; -GT: '>'; -LT: '<'; -BANG: '!'; -TILDE: '~'; -QUESTION: '?'; -COLON: ':'; -EQUAL: '=='; -LE: '<='; -GE: '>='; -NOTEQUAL: '!='; -AND: '&&'; -OR: '||'; -INC: '++'; -DEC: '--'; -ADD: '+'; -SUB: '-'; -MUL: '*'; -DIV: '/'; -BITAND: '&'; -BITOR: '|'; -CARET: '^'; -MOD: '%'; - -ADD_ASSIGN: '+='; -SUB_ASSIGN: '-='; -MUL_ASSIGN: '*='; -DIV_ASSIGN: '/='; -AND_ASSIGN: '&='; -OR_ASSIGN: '|='; -XOR_ASSIGN: '^='; -MOD_ASSIGN: '%='; -LSHIFT_ASSIGN: '<<='; -RSHIFT_ASSIGN: '>>='; -URSHIFT_ASSIGN: '>>>='; +ASSIGN : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +EQUAL : '=='; +LE : '<='; +GE : '>='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +CARET : '^'; +MOD : '%'; + +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; +URSHIFT_ASSIGN : '>>>='; // Java 8 tokens -ARROW: '->'; -COLONCOLON: '::'; +ARROW : '->'; +COLONCOLON : '::'; // Additional symbols not defined in the lexical specification -AT: '@'; -ELLIPSIS: '...'; +AT : '@'; +ELLIPSIS : '...'; // Whitespace and comments -WS: [ \t\r\n\u000C]+ -> channel(HIDDEN); -COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); +WS : [ \t\r\n\u000C]+ -> channel(HIDDEN); +COMMENT : '/*' .*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); // Identifiers -IDENTIFIER: Letter LetterOrDigit*; +IDENTIFIER: Letter LetterOrDigit*; // Fragment rules -fragment ExponentPart - : [eE] [+-]? Digits - ; +fragment ExponentPart: [eE] [+-]? Digits; -fragment EscapeSequence - : '\\' 'u005c'? [btnfr"'\\] +fragment EscapeSequence: + '\\' 'u005c'? [btnfr"'\\] | '\\' 'u005c'? ([0-3]? [0-7])? [0-7] | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +; -fragment HexDigits - : HexDigit ((HexDigit | '_')* HexDigit)? - ; +fragment HexDigits: HexDigit ((HexDigit | '_')* HexDigit)?; -fragment HexDigit - : [0-9a-fA-F] - ; +fragment HexDigit: [0-9a-fA-F]; -fragment Digits - : [0-9] ([0-9_]* [0-9])? - ; +fragment Digits: [0-9] ([0-9_]* [0-9])?; -fragment LetterOrDigit - : Letter - | [0-9] - ; +fragment LetterOrDigit: Letter | [0-9]; -fragment Letter - : [a-zA-Z$_] // these are the "java letters" below 0x7F - | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate +fragment Letter: + [a-zA-Z$_] // these are the "java letters" below 0x7F + | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - ; +; \ No newline at end of file diff --git a/java/java/JavaParser.g4 b/java/java/JavaParser.g4 index bc249c89a8..1bba37f9dd 100644 --- a/java/java/JavaParser.g4 +++ b/java/java/JavaParser.g4 @@ -29,9 +29,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 JavaParser; -options { tokenVocab=JavaLexer; } +options { + tokenVocab = JavaLexer; +} compilationUnit : packageDeclaration? (importDeclaration | ';')* (typeDeclaration | ';')* @@ -47,8 +52,13 @@ importDeclaration ; typeDeclaration - : classOrInterfaceModifier* - (classDeclaration | enumDeclaration | interfaceDeclaration | annotationTypeDeclaration | recordDeclaration) + : classOrInterfaceModifier* ( + classDeclaration + | enumDeclaration + | interfaceDeclaration + | annotationTypeDeclaration + | recordDeclaration + ) ; modifier @@ -66,9 +76,9 @@ classOrInterfaceModifier | PRIVATE | STATIC | ABSTRACT - | FINAL // FINAL for class only -- does not apply to interfaces + | FINAL // FINAL for class only -- does not apply to interfaces | STRICTFP - | SEALED // Java17 + | SEALED // Java17 | NON_SEALED // Java17 ; @@ -78,11 +88,10 @@ variableModifier ; classDeclaration - : CLASS identifier typeParameters? - (EXTENDS typeType)? - (IMPLEMENTS typeList)? - (PERMITS typeList)? // Java17 - classBody + : CLASS identifier typeParameters? (EXTENDS typeType)? (IMPLEMENTS typeList)? ( + PERMITS typeList + )? // Java17 + classBody ; typeParameters @@ -150,9 +159,7 @@ memberDeclaration for invalid return type after parsing. */ methodDeclaration - : typeTypeOrVoid identifier formalParameters ('[' ']')* - (THROWS qualifiedNameList)? - methodBody + : typeTypeOrVoid identifier formalParameters ('[' ']')* (THROWS qualifiedNameList)? methodBody ; methodBody @@ -174,11 +181,11 @@ genericConstructorDeclaration ; constructorDeclaration - : identifier formalParameters (THROWS qualifiedNameList)? constructorBody=block + : identifier formalParameters (THROWS qualifiedNameList)? constructorBody = block ; compactConstructorDeclaration - : modifier* identifier constructorBody=block + : modifier* identifier constructorBody = block ; fieldDeclaration @@ -253,7 +260,7 @@ variableInitializer ; arrayInitializer - : '{' (variableInitializer (',' variableInitializer)* ','? )? '}' + : '{' (variableInitializer (',' variableInitializer)* ','?)? '}' ; classOrInterfaceType @@ -270,10 +277,11 @@ qualifiedNameList ; formalParameters - : '(' ( receiverParameter? - | receiverParameter (',' formalParameterList)? - | formalParameterList? - ) ')' + : '(' ( + receiverParameter? + | receiverParameter (',' formalParameterList)? + | formalParameterList? + ) ')' ; receiverParameter @@ -334,7 +342,9 @@ altAnnotationQualifiedName ; annotation - : ('@' qualifiedName | altAnnotationQualifiedName) ('(' ( elementValuePairs | elementValue )? ')')? + : ('@' qualifiedName | altAnnotationQualifiedName) ( + '(' ( elementValuePairs | elementValue)? ')' + )? ; elementValuePairs @@ -405,24 +415,22 @@ moduleBody ; moduleDirective - : REQUIRES requiresModifier* qualifiedName ';' - | EXPORTS qualifiedName (TO qualifiedName)? ';' - | OPENS qualifiedName (TO qualifiedName)? ';' - | USES qualifiedName ';' - | PROVIDES qualifiedName WITH qualifiedName ';' - ; + : REQUIRES requiresModifier* qualifiedName ';' + | EXPORTS qualifiedName (TO qualifiedName)? ';' + | OPENS qualifiedName (TO qualifiedName)? ';' + | USES qualifiedName ';' + | PROVIDES qualifiedName WITH qualifiedName ';' + ; requiresModifier - : TRANSITIVE - | STATIC - ; + : TRANSITIVE + | STATIC + ; // RECORDS - Java 17 recordDeclaration - : RECORD identifier typeParameters? recordHeader - (IMPLEMENTS typeList)? - recordBody + : RECORD identifier typeParameters? recordHeader (IMPLEMENTS typeList)? recordBody ; recordHeader @@ -438,7 +446,7 @@ recordComponent ; recordBody - : '{' (classBodyDeclaration | compactConstructorDeclaration)* '}' + : '{' (classBodyDeclaration | compactConstructorDeclaration)* '}' ; // STATEMENTS / BLOCKS @@ -476,7 +484,7 @@ identifier | VAR ; -typeIdentifier // Identifiers that are not restricted for type declarations +typeIdentifier // Identifiers that are not restricted for type declarations : IDENTIFIER | MODULE | OPEN @@ -494,12 +502,11 @@ typeIdentifier // Identifiers that are not restricted for type declarations ; localTypeDeclaration - : classOrInterfaceModifier* - (classDeclaration | interfaceDeclaration | recordDeclaration) + : classOrInterfaceModifier* (classDeclaration | interfaceDeclaration | recordDeclaration) ; statement - : blockLabel=block + : blockLabel = block | ASSERT expression (':' expression)? ';' | IF parExpression statement (ELSE statement)? | FOR '(' forControl ')' statement @@ -515,9 +522,9 @@ statement | CONTINUE identifier? ';' | YIELD expression ';' // Java17 | SEMI - | statementExpression=expression ';' + | statementExpression = expression ';' | switchExpression ';'? // Java17 - | identifierLabel=identifier ':' statement + | identifierLabel = identifier ':' statement ; catchClause @@ -541,7 +548,7 @@ resources ; resource - : variableModifier* ( classOrInterfaceType variableDeclaratorId | VAR identifier ) '=' expression + : variableModifier* (classOrInterfaceType variableDeclaratorId | VAR identifier) '=' expression | qualifiedName ; @@ -553,13 +560,17 @@ switchBlockStatementGroup ; switchLabel - : CASE (constantExpression=expression | enumConstantName=IDENTIFIER | typeType varName=identifier) ':' + : CASE ( + constantExpression = expression + | enumConstantName = IDENTIFIER + | typeType varName = identifier + ) ':' | DEFAULT ':' ; forControl : enhancedForControl - | forInit? ';' expression? ';' forUpdate=expressionList? + | forInit? ';' expression? ';' forUpdate = expressionList? ; forInit @@ -586,54 +597,63 @@ methodCall ; expression - // Expression order in accordance with https://introcs.cs.princeton.edu/java/11precedence/ - // Level 16, Primary, array and member access +// Expression order in accordance with https://introcs.cs.princeton.edu/java/11precedence/ +// Level 16, Primary, array and member access : primary | expression '[' expression ']' - | expression bop='.' - ( - identifier - | methodCall - | THIS - | NEW nonWildcardTypeArguments? innerCreator - | SUPER superSuffix - | explicitGenericInvocation - ) + | expression bop = '.' ( + identifier + | methodCall + | THIS + | NEW nonWildcardTypeArguments? innerCreator + | SUPER superSuffix + | explicitGenericInvocation + ) // Method calls and method references are part of primary, and hence level 16 precedence | methodCall | expression '::' typeArguments? identifier | typeType '::' (typeArguments? identifier | NEW) | classType '::' typeArguments? NEW - | switchExpression // Java17 // Level 15 Post-increment/decrement operators - | expression postfix=('++' | '--') + | expression postfix = ('++' | '--') // Level 14, Unary operators - | prefix=('+'|'-'|'++'|'--'|'~'|'!') expression + | prefix = ('+' | '-' | '++' | '--' | '~' | '!') expression // Level 13 Cast and object creation | '(' annotation* typeType ('&' typeType)* ')' expression | NEW creator // Level 12 to 1, Remaining operators - | expression bop=('*'|'/'|'%') expression // Level 12, Multiplicative operators - | expression bop=('+'|'-') expression // Level 11, Additive operators - | expression ('<' '<' | '>' '>' '>' | '>' '>') expression // Level 10, Shift operators - | expression bop=('<=' | '>=' | '>' | '<') expression // Level 9, Relational operators - | expression bop=INSTANCEOF (typeType | pattern) - | expression bop=('==' | '!=') expression // Level 8, Equality Operators - | expression bop='&' expression // Level 7, Bitwise AND - | expression bop='^' expression // Level 6, Bitwise XOR - | expression bop='|' expression // Level 5, Bitwise OR - | expression bop='&&' expression // Level 4, Logic AND - | expression bop='||' expression // Level 3, Logic OR - | expression bop='?' expression ':' expression // Level 2, Ternary + | expression bop = ('*' | '/' | '%') expression // Level 12, Multiplicative operators + | expression bop = ('+' | '-') expression // Level 11, Additive operators + | expression ('<' '<' | '>' '>' '>' | '>' '>') expression // Level 10, Shift operators + | expression bop = ('<=' | '>=' | '>' | '<') expression // Level 9, Relational operators + | expression bop = INSTANCEOF (typeType | pattern) + | expression bop = ('==' | '!=') expression // Level 8, Equality Operators + | expression bop = '&' expression // Level 7, Bitwise AND + | expression bop = '^' expression // Level 6, Bitwise XOR + | expression bop = '|' expression // Level 5, Bitwise OR + | expression bop = '&&' expression // Level 4, Logic AND + | expression bop = '||' expression // Level 3, Logic OR + | expression bop = '?' expression ':' expression // Level 2, Ternary // Level 1, Assignment - | expression - bop=('=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' | '>>=' | '>>>=' | '<<=' | '%=') - expression + | expression bop = ( + '=' + | '+=' + | '-=' + | '*=' + | '/=' + | '&=' + | '|=' + | '^=' + | '>>=' + | '>>>=' + | '<<=' + | '%=' + ) expression // Level 0, Lambda Expression | lambdaExpression // Java8 @@ -777,4 +797,4 @@ explicitGenericInvocationSuffix arguments : '(' expressionList? ')' - ; + ; \ No newline at end of file diff --git a/java/java20/Java20Lexer.g4 b/java/java20/Java20Lexer.g4 index 228353f76f..2375a99bca 100644 --- a/java/java20/Java20Lexer.g4 +++ b/java/java20/Java20Lexer.g4 @@ -1,8 +1,12 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Java20Lexer; options { - superClass = JavaLexerBase; + superClass = JavaLexerBase; } // Insert here @header for C++ lexer. @@ -11,25 +15,23 @@ options // LEXER -EXPORTS: 'exports'; -MODULE: 'module'; -NONSEALED: 'non-sealed'; -OACA: '<>'; -OPEN: 'open'; -OPENS: 'opens'; -PERMITS: 'permits'; -PROVIDES: 'provides'; -RECORD: 'record'; -REQUIRES: 'requires'; -SEALED: 'sealed'; -TO: 'to'; -TRANSITIVE: 'transitive'; -USES: 'uses'; -VAR: 'var'; -WITH: 'with'; -YIELD: 'yield'; - - +EXPORTS : 'exports'; +MODULE : 'module'; +NONSEALED : 'non-sealed'; +OACA : '<>'; +OPEN : 'open'; +OPENS : 'opens'; +PERMITS : 'permits'; +PROVIDES : 'provides'; +RECORD : 'record'; +REQUIRES : 'requires'; +SEALED : 'sealed'; +TO : 'to'; +TRANSITIVE : 'transitive'; +USES : 'uses'; +VAR : 'var'; +WITH : 'with'; +YIELD : 'yield'; // §3.9 Keywords @@ -45,7 +47,7 @@ CLASS : 'class'; CONST : 'const'; CONTINUE : 'continue'; DEFAULT : 'default'; -DO : 'do' ; +DO : 'do'; DOUBLE : 'double'; ELSE : 'else'; ENUM : 'enum'; @@ -83,338 +85,188 @@ TRY : 'try'; VOID : 'void'; VOLATILE : 'volatile'; WHILE : 'while'; -UNDER_SCORE : '_'; //Introduced in Java 9 +UNDER_SCORE : '_'; //Introduced in Java 9 // §3.10.1 Integer Literals -IntegerLiteral - : DecimalIntegerLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - | BinaryIntegerLiteral - ; - -fragment -DecimalIntegerLiteral - : DecimalNumeral IntegerTypeSuffix? - ; - -fragment -HexIntegerLiteral - : HexNumeral IntegerTypeSuffix? - ; - -fragment -OctalIntegerLiteral - : OctalNumeral IntegerTypeSuffix? - ; - -fragment -BinaryIntegerLiteral - : BinaryNumeral IntegerTypeSuffix? - ; - -fragment -IntegerTypeSuffix - : [lL] - ; - -fragment -DecimalNumeral - : '0' - | NonZeroDigit (Digits? | Underscores Digits) - ; - -fragment -Digits - : Digit (DigitsAndUnderscores? Digit)? - ; - -fragment -Digit - : '0' - | NonZeroDigit - ; - -fragment -NonZeroDigit - : [1-9] - ; - -fragment -DigitsAndUnderscores - : DigitOrUnderscore+ - ; - -fragment -DigitOrUnderscore - : Digit - | '_' - ; - -fragment -Underscores - : '_'+ - ; - -fragment -HexNumeral - : '0' [xX] HexDigits - ; - -fragment -HexDigits - : HexDigit (HexDigitsAndUnderscores? HexDigit)? - ; - -fragment -HexDigit - : [0-9a-fA-F] - ; - -fragment -HexDigitsAndUnderscores - : HexDigitOrUnderscore+ - ; - -fragment -HexDigitOrUnderscore - : HexDigit - | '_' - ; - -fragment -OctalNumeral - : '0' Underscores? OctalDigits - ; - -fragment -OctalDigits - : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)? - ; - -fragment -OctalDigit - : [0-7] - ; - -fragment -OctalDigitsAndUnderscores - : OctalDigitOrUnderscore+ - ; - -fragment -OctalDigitOrUnderscore - : OctalDigit - | '_' - ; - -fragment -BinaryNumeral - : '0' [bB] BinaryDigits - ; - -fragment -BinaryDigits - : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)? - ; - -fragment -BinaryDigit - : [01] - ; - -fragment -BinaryDigitsAndUnderscores - : BinaryDigitOrUnderscore+ - ; - -fragment -BinaryDigitOrUnderscore - : BinaryDigit - | '_' - ; +IntegerLiteral: + DecimalIntegerLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + | BinaryIntegerLiteral +; + +fragment DecimalIntegerLiteral: DecimalNumeral IntegerTypeSuffix?; + +fragment HexIntegerLiteral: HexNumeral IntegerTypeSuffix?; + +fragment OctalIntegerLiteral: OctalNumeral IntegerTypeSuffix?; + +fragment BinaryIntegerLiteral: BinaryNumeral IntegerTypeSuffix?; + +fragment IntegerTypeSuffix: [lL]; + +fragment DecimalNumeral: '0' | NonZeroDigit (Digits? | Underscores Digits); + +fragment Digits: Digit (DigitsAndUnderscores? Digit)?; + +fragment Digit: '0' | NonZeroDigit; + +fragment NonZeroDigit: [1-9]; + +fragment DigitsAndUnderscores: DigitOrUnderscore+; + +fragment DigitOrUnderscore: Digit | '_'; + +fragment Underscores: '_'+; + +fragment HexNumeral: '0' [xX] HexDigits; + +fragment HexDigits: HexDigit (HexDigitsAndUnderscores? HexDigit)?; + +fragment HexDigit: [0-9a-fA-F]; + +fragment HexDigitsAndUnderscores: HexDigitOrUnderscore+; + +fragment HexDigitOrUnderscore: HexDigit | '_'; + +fragment OctalNumeral: '0' Underscores? OctalDigits; + +fragment OctalDigits: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?; + +fragment OctalDigit: [0-7]; + +fragment OctalDigitsAndUnderscores: OctalDigitOrUnderscore+; + +fragment OctalDigitOrUnderscore: OctalDigit | '_'; + +fragment BinaryNumeral: '0' [bB] BinaryDigits; + +fragment BinaryDigits: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?; + +fragment BinaryDigit: [01]; + +fragment BinaryDigitsAndUnderscores: BinaryDigitOrUnderscore+; + +fragment BinaryDigitOrUnderscore: BinaryDigit | '_'; // §3.10.2 Floating-Point Literals -FloatingPointLiteral - : DecimalFloatingPointLiteral - | HexadecimalFloatingPointLiteral - ; - -fragment -DecimalFloatingPointLiteral - : Digits '.' Digits? ExponentPart? FloatTypeSuffix? - | '.' Digits ExponentPart? FloatTypeSuffix? - | Digits ExponentPart FloatTypeSuffix? - | Digits FloatTypeSuffix - ; - -fragment -ExponentPart - : ExponentIndicator SignedInteger - ; - -fragment -ExponentIndicator - : [eE] - ; - -fragment -SignedInteger - : Sign? Digits - ; - -fragment -Sign - : [+-] - ; - -fragment -FloatTypeSuffix - : [fFdD] - ; - -fragment -HexadecimalFloatingPointLiteral - : HexSignificand BinaryExponent FloatTypeSuffix? - ; - -fragment -HexSignificand - : HexNumeral '.'? - | '0' [xX] HexDigits? '.' HexDigits - ; - -fragment -BinaryExponent - : BinaryExponentIndicator SignedInteger - ; - -fragment -BinaryExponentIndicator - : [pP] - ; +FloatingPointLiteral: DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral; + +fragment DecimalFloatingPointLiteral: + Digits '.' Digits? ExponentPart? FloatTypeSuffix? + | '.' Digits ExponentPart? FloatTypeSuffix? + | Digits ExponentPart FloatTypeSuffix? + | Digits FloatTypeSuffix +; + +fragment ExponentPart: ExponentIndicator SignedInteger; + +fragment ExponentIndicator: [eE]; + +fragment SignedInteger: Sign? Digits; + +fragment Sign: [+-]; + +fragment FloatTypeSuffix: [fFdD]; + +fragment HexadecimalFloatingPointLiteral: HexSignificand BinaryExponent FloatTypeSuffix?; + +fragment HexSignificand: HexNumeral '.'? | '0' [xX] HexDigits? '.' HexDigits; + +fragment BinaryExponent: BinaryExponentIndicator SignedInteger; + +fragment BinaryExponentIndicator: [pP]; // §3.10.3 Boolean Literals -BooleanLiteral - : 'true' - | 'false' - ; +BooleanLiteral: 'true' | 'false'; // §3.10.4 Character Literals -CharacterLiteral - : '\'' SingleCharacter '\'' - | '\'' EscapeSequence '\'' - ; +CharacterLiteral: '\'' SingleCharacter '\'' | '\'' EscapeSequence '\''; -fragment -SingleCharacter - : ~['\\\r\n] - ; +fragment SingleCharacter: ~['\\\r\n]; // §3.10.5 String Literals -StringLiteral - : '"' StringCharacters? '"' - ; +StringLiteral: '"' StringCharacters? '"'; -fragment -StringCharacters - : StringCharacter+ - ; +fragment StringCharacters: StringCharacter+; -fragment -StringCharacter - : ~["\\\r\n] - | EscapeSequence - ; +fragment StringCharacter: ~["\\\r\n] | EscapeSequence; -TextBlock - : '"""' [ \t]* [\n\r] [.\r\b]*'"""' - ; +TextBlock: '"""' [ \t]* [\n\r] [.\r\b]* '"""'; // §3.10.6 Escape Sequences for Character and String Literals -fragment -EscapeSequence - : '\\' [btnfr"'\\] - | OctalEscape - | UnicodeEscape // This is not in the spec but prevents having to preprocess the input - ; - -fragment -OctalEscape - : '\\' OctalDigit - | '\\' OctalDigit OctalDigit - | '\\' ZeroToThree OctalDigit OctalDigit - ; - -fragment -ZeroToThree - : [0-3] - ; +fragment EscapeSequence: + '\\' [btnfr"'\\] + | OctalEscape + | UnicodeEscape // This is not in the spec but prevents having to preprocess the input +; + +fragment OctalEscape: + '\\' OctalDigit + | '\\' OctalDigit OctalDigit + | '\\' ZeroToThree OctalDigit OctalDigit +; + +fragment ZeroToThree: [0-3]; // This is not in the spec but prevents having to preprocess the input -fragment -UnicodeEscape - : '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +fragment UnicodeEscape: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit; // §3.10.7 The Null Literal -NullLiteral - : 'null' - ; +NullLiteral: 'null'; // §3.11 Separators -LPAREN : '('; -RPAREN : ')'; -LBRACE : '{'; -RBRACE : '}'; -LBRACK : '['; -RBRACK : ']'; -SEMI : ';'; -COMMA : ','; -DOT : '.'; -ELLIPSIS : '...'; -AT : '@'; -COLONCOLON : '::'; - +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +ELLIPSIS : '...'; +AT : '@'; +COLONCOLON : '::'; // §3.12 Operators -ASSIGN : '='; -GT : '>'; -LT : '<'; -BANG : '!'; -TILDE : '~'; -QUESTION : '?'; -COLON : ':'; -ARROW : '->'; -EQUAL : '=='; -LE : '<='; -GE : '>='; -NOTEQUAL : '!='; -AND : '&&'; -OR : '||'; -INC : '++'; -DEC : '--'; -ADD : '+'; -SUB : '-'; -MUL : '*'; -DIV : '/'; -BITAND : '&'; -BITOR : '|'; -CARET : '^'; -MOD : '%'; +ASSIGN : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +ARROW : '->'; +EQUAL : '=='; +LE : '<='; +GE : '>='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +CARET : '^'; +MOD : '%'; //LSHIFT : '<<'; //RSHIFT : '>>'; //URSHIFT : '>>>'; - + ADD_ASSIGN : '+='; SUB_ASSIGN : '-='; MUL_ASSIGN : '*='; @@ -429,43 +281,30 @@ URSHIFT_ASSIGN : '>>>='; // §3.8 Identifiers (must appear after all keywords in the grammar) -Identifier - : JavaLetter JavaLetterOrDigit* - ; - -fragment -JavaLetter - : [a-zA-Z$_] // these are the "java letters" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { this.Check1() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { this.Check2() }? - ; - -fragment -JavaLetterOrDigit - : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { this.Check3() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { this.Check4() }? - ; +Identifier: JavaLetter JavaLetterOrDigit*; + +fragment JavaLetter: + [a-zA-Z$_] // these are the "java letters" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { this.Check1() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { this.Check2() }? +; + +fragment JavaLetterOrDigit: + [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { this.Check3() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { this.Check4() }? +; // // Whitespace and comments // -WS : [ \t\r\n\u000C]+ -> skip - ; +WS: [ \t\r\n\u000C]+ -> skip; -COMMENT - : '/*' .*? '*/' -> channel(HIDDEN) - ; +COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT - : '//' ~[\r\n]* -> channel(HIDDEN) - ; +LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); \ No newline at end of file diff --git a/java/java20/Java20Parser.g4 b/java/java20/Java20Parser.g4 index 1c9554e80a..253c081dd6 100644 --- a/java/java20/Java20Parser.g4 +++ b/java/java20/Java20Parser.g4 @@ -1,77 +1,80 @@ -parser grammar Java20Parser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab = Java20Lexer; } +parser grammar Java20Parser; + +options { + tokenVocab = Java20Lexer; +} //============= -start: compilationUnit EOF ; +start + : compilationUnit EOF + ; // Paragraph 3.10 // -------------- literal - : IntegerLiteral - | FloatingPointLiteral - | BooleanLiteral - | CharacterLiteral - | StringLiteral - | TextBlock - | NullLiteral - ; - + : IntegerLiteral + | FloatingPointLiteral + | BooleanLiteral + | CharacterLiteral + | StringLiteral + | TextBlock + | NullLiteral + ; // Paragraph 3.8 // ------------- typeIdentifier - : Identifier - ; + : Identifier + ; unqualifiedMethodIdentifier - : Identifier - ; - + : Identifier + ; // Paragraph 4.1 // Type is not used. // Type ::= primitiveType // | referenceType // ; - // Paragraph 4.2 // ------------- primitiveType - : annotation* (numericType | 'boolean') - ; + : annotation* (numericType | 'boolean') + ; numericType - : integralType - | floatingPointType - ; + : integralType + | floatingPointType + ; integralType - : 'byte' - | 'short' - | 'int' - | 'long' - | 'char' - ; + : 'byte' + | 'short' + | 'int' + | 'long' + | 'char' + ; floatingPointType - : 'float' - | 'double' - ; - + : 'float' + | 'double' + ; // Paragraph 4.3 // ------------- referenceType - : classOrInterfaceType - | typeVariable - | arrayType - ; + : classOrInterfaceType + | typeVariable + | arrayType + ; // replace classType in classOrInterfaceType @@ -89,329 +92,318 @@ referenceType // ; // - coit - : '.' annotation* typeIdentifier typeArguments? coit? - ; + : '.' annotation* typeIdentifier typeArguments? coit? + ; classOrInterfaceType - : (packageName '.')? annotation* typeIdentifier typeArguments? coit? - ; + : (packageName '.')? annotation* typeIdentifier typeArguments? coit? + ; classType - : annotation* typeIdentifier typeArguments? - | packageName '.' annotation* typeIdentifier typeArguments? - | classOrInterfaceType '.' annotation* typeIdentifier typeArguments? - ; + : annotation* typeIdentifier typeArguments? + | packageName '.' annotation* typeIdentifier typeArguments? + | classOrInterfaceType '.' annotation* typeIdentifier typeArguments? + ; interfaceType - : classType - ; + : classType + ; typeVariable - : annotation* typeIdentifier - ; - + : annotation* typeIdentifier + ; + arrayType - : primitiveType dims - | classType dims - | typeVariable dims - ; - -dims - : annotation* '[' ']' ( annotation* '[' ']' )* - ; + : primitiveType dims + | classType dims + | typeVariable dims + ; +dims + : annotation* '[' ']' (annotation* '[' ']')* + ; // Paragraph 4.4 // ------------- typeParameter - : typeParameterModifier* typeIdentifier typeBound? - ; - + : typeParameterModifier* typeIdentifier typeBound? + ; + typeParameterModifier - : annotation - ; - + : annotation + ; + typeBound - : 'extends' (typeVariable | classOrInterfaceType additionalBound*) - ; - + : 'extends' (typeVariable | classOrInterfaceType additionalBound*) + ; + additionalBound - : '&' interfaceType - ; - + : '&' interfaceType + ; // Paragraph 4.5.1 // --------------- typeArguments - : '<' typeArgumentList '>' - ; + : '<' typeArgumentList '>' + ; typeArgumentList - : typeArgument ( ',' typeArgument )* - ; + : typeArgument (',' typeArgument)* + ; typeArgument - : referenceType - | wildcard - ; - + : referenceType + | wildcard + ; + wildcard - : annotation* '?' wildcardBounds? - ; - -wildcardBounds - : 'extends' referenceType - | 'super' referenceType - ; + : annotation* '?' wildcardBounds? + ; +wildcardBounds + : 'extends' referenceType + | 'super' referenceType + ; // Paragraph 6.5 // ------------- moduleName - : Identifier ('.' moduleName)? - // left recursion --> right recursion - ; + : Identifier ('.' moduleName)? + // left recursion --> right recursion + ; packageName - : Identifier ('.' packageName)? - // left recursion --> right recursion - ; + : Identifier ('.' packageName)? + // left recursion --> right recursion + ; typeName - : packageName ('.' typeIdentifier)? - ; + : packageName ('.' typeIdentifier)? + ; packageOrTypeName - : Identifier ('.' packageOrTypeName)? - // left recursion --> right recursion - ; - + : Identifier ('.' packageOrTypeName)? + // left recursion --> right recursion + ; + expressionName - : (ambiguousName '.')? Identifier - ; - + : (ambiguousName '.')? Identifier + ; + methodName - : unqualifiedMethodIdentifier - ; + : unqualifiedMethodIdentifier + ; ambiguousName - : Identifier ('.' ambiguousName)? - // left recursion --> right recursion - ; - + : Identifier ('.' ambiguousName)? + // left recursion --> right recursion + ; // Paragraph 7.3 // ------------- compilationUnit - : ordinaryCompilationUnit - | modularCompilationUnit - ; + : ordinaryCompilationUnit + | modularCompilationUnit + ; ordinaryCompilationUnit - : packageDeclaration? importDeclaration* topLevelClassOrInterfaceDeclaration* - ; - + : packageDeclaration? importDeclaration* topLevelClassOrInterfaceDeclaration* + ; + modularCompilationUnit - : importDeclaration* moduleDeclaration - ; - + : importDeclaration* moduleDeclaration + ; // Paragraph 7.4 // ------------- packageDeclaration - : packageModifier* 'package' Identifier ( '.' Identifier )* ';' - ; - + : packageModifier* 'package' Identifier ('.' Identifier)* ';' + ; + packageModifier - : annotation - ; - + : annotation + ; // Paragraph 7.5 // ------------- importDeclaration - : singleTypeImportDeclaration - | typeImportOnDemandDeclaration - | singleStaticImportDeclaration - | staticImportOnDemandDeclaration - ; - + : singleTypeImportDeclaration + | typeImportOnDemandDeclaration + | singleStaticImportDeclaration + | staticImportOnDemandDeclaration + ; + singleTypeImportDeclaration - : 'import' typeName ';' - ; + : 'import' typeName ';' + ; typeImportOnDemandDeclaration - : 'import' packageOrTypeName '.' '*' ';' - ; + : 'import' packageOrTypeName '.' '*' ';' + ; singleStaticImportDeclaration - : 'import' 'static' typeName '.' Identifier ';' - ; + : 'import' 'static' typeName '.' Identifier ';' + ; staticImportOnDemandDeclaration - : 'import' 'static' typeName '.' '*' ';' - ; - + : 'import' 'static' typeName '.' '*' ';' + ; // Paragraph 7.6 // ------------- topLevelClassOrInterfaceDeclaration - : classDeclaration - | interfaceDeclaration - | ';' - ; - + : classDeclaration + | interfaceDeclaration + | ';' + ; // Paragraph 7.7 // ------------- moduleDeclaration - : annotation* 'open'? 'module' Identifier ( '.' Identifier )* '{' moduleDirective* '}' - ; - + : annotation* 'open'? 'module' Identifier ('.' Identifier)* '{' moduleDirective* '}' + ; + moduleDirective - : 'requires' requiresModifier* moduleName ';' - | 'exports' packageName ('to' moduleName ( ',' moduleName )* )? ';' - | 'opens' packageName ('to' moduleName ( ',' moduleName )* )? ';' - | 'uses' typeName ';' - | 'provides' typeName 'with' typeName ( ',' typeName )* ';' - ; - + : 'requires' requiresModifier* moduleName ';' + | 'exports' packageName ('to' moduleName ( ',' moduleName)*)? ';' + | 'opens' packageName ('to' moduleName ( ',' moduleName)*)? ';' + | 'uses' typeName ';' + | 'provides' typeName 'with' typeName ( ',' typeName)* ';' + ; + requiresModifier - : 'transitive' - | 'static' - ; - + : 'transitive' + | 'static' + ; // Paragraph 8.1 // ------------- classDeclaration - : normalClassDeclaration - | enumDeclaration - | recordDeclaration - ; - + : normalClassDeclaration + | enumDeclaration + | recordDeclaration + ; + normalClassDeclaration - : classModifier* 'class' typeIdentifier typeParameters? classExtends? classImplements? classPermits? classBody - ; - + : classModifier* 'class' typeIdentifier typeParameters? classExtends? classImplements? classPermits? classBody + ; + classModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'final' - | 'sealed' - | 'non-sealed' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'final' + | 'sealed' + | 'non-sealed' + | 'strictfp' + ; typeParameters - : '<' typeParameterList '>' - ; + : '<' typeParameterList '>' + ; typeParameterList - : typeParameter ( ',' typeParameter )* - ; + : typeParameter (',' typeParameter)* + ; classExtends - : 'extends' classType - ; + : 'extends' classType + ; classImplements - : 'implements' interfaceTypeList - ; - -interfaceTypeList - : interfaceType ( ',' interfaceType )* - ; + : 'implements' interfaceTypeList + ; + +interfaceTypeList + : interfaceType (',' interfaceType)* + ; classPermits - : 'permits' typeName ( ',' typeName )* - ; + : 'permits' typeName (',' typeName)* + ; classBody - : '{' classBodyDeclaration* '}' - ; - + : '{' classBodyDeclaration* '}' + ; + classBodyDeclaration - : classMemberDeclaration - | instanceInitializer - | staticInitializer - | constructorDeclaration - ; + : classMemberDeclaration + | instanceInitializer + | staticInitializer + | constructorDeclaration + ; classMemberDeclaration - : fieldDeclaration - | methodDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; - + : fieldDeclaration + | methodDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; // Paragraph 8.3 // ------------- fieldDeclaration - : fieldModifier* unannType variableDeclaratorList ';' - ; - + : fieldModifier* unannType variableDeclaratorList ';' + ; + fieldModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'static' - | 'final' - | 'transient' - | 'volatile' - ; - + : annotation + | 'public' + | 'protected' + | 'private' + | 'static' + | 'final' + | 'transient' + | 'volatile' + ; + variableDeclaratorList - : variableDeclarator ( ',' variableDeclarator )* - ; - -variableDeclarator - : variableDeclaratorId ( '=' variableInitializer )? - ; + : variableDeclarator (',' variableDeclarator)* + ; + +variableDeclarator + : variableDeclaratorId ('=' variableInitializer)? + ; variableDeclaratorId - : Identifier dims? - ; - + : Identifier dims? + ; + variableInitializer - : expression - | arrayInitializer - ; - + : expression + | arrayInitializer + ; + unannType - : unannPrimitiveType - | unannReferenceType - ; - + : unannPrimitiveType + | unannReferenceType + ; + unannPrimitiveType - : numericType - | 'boolean' - ; - + : numericType + | 'boolean' + ; + unannReferenceType - : unannClassOrInterfaceType - | unannTypeVariable - | unannArrayType - ; + : unannClassOrInterfaceType + | unannTypeVariable + | unannArrayType + ; // Replace unannClassType in unannClassOrInterfaceType @@ -422,767 +414,729 @@ unannReferenceType // unannClassOrInterfaceType - : (packageName '.' annotation*)? typeIdentifier typeArguments? uCOIT? - ; - -uCOIT : '.' annotation* typeIdentifier typeArguments? uCOIT? - ; - + : (packageName '.' annotation*)? typeIdentifier typeArguments? uCOIT? + ; +uCOIT + : '.' annotation* typeIdentifier typeArguments? uCOIT? + ; unannClassType - : typeIdentifier typeArguments? - | (packageName | unannClassOrInterfaceType) '.' annotation* typeIdentifier typeArguments? - ; + : typeIdentifier typeArguments? + | (packageName | unannClassOrInterfaceType) '.' annotation* typeIdentifier typeArguments? + ; unannInterfaceType - : unannClassType - ; - + : unannClassType + ; + unannTypeVariable - : typeIdentifier - ; - -unannArrayType - : (unannPrimitiveType | unannClassOrInterfaceType | unannTypeVariable) dims - ; + : typeIdentifier + ; +unannArrayType + : (unannPrimitiveType | unannClassOrInterfaceType | unannTypeVariable) dims + ; // Paragraph 8.4 // ------------- methodDeclaration - : methodModifier* methodHeader methodBody - ; - + : methodModifier* methodHeader methodBody + ; + methodModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'final' - | 'synchronized' - | 'native' - | 'strictfp' - ; - + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'final' + | 'synchronized' + | 'native' + | 'strictfp' + ; + methodHeader - : (typeParameters annotation*)? result methodDeclarator throwsT? - ; + : (typeParameters annotation*)? result methodDeclarator throwsT? + ; result - : unannType - | 'void' - ; - + : unannType + | 'void' + ; + methodDeclarator - : Identifier '(' (receiverParameter ',' )? formalParameterList? ')' dims? - ; - -receiverParameter - : annotation* unannType ( Identifier '.' )? 'this' - ; + : Identifier '(' (receiverParameter ',')? formalParameterList? ')' dims? + ; + +receiverParameter + : annotation* unannType (Identifier '.')? 'this' + ; formalParameterList - : formalParameter ( ',' formalParameter )* - ; - + : formalParameter (',' formalParameter)* + ; + formalParameter - : variableModifier* unannType variableDeclaratorId - | variableArityParameter - ; - + : variableModifier* unannType variableDeclaratorId + | variableArityParameter + ; + variableArityParameter - : variableModifier* unannType annotation* '...' Identifier - ; - + : variableModifier* unannType annotation* '...' Identifier + ; + variableModifier - : annotation - | 'final' - ; - + : annotation + | 'final' + ; + throwsT - : 'throws' exceptionTypeList - ; - + : 'throws' exceptionTypeList + ; + exceptionTypeList - : exceptionType ( ',' exceptionType )* - ; + : exceptionType (',' exceptionType)* + ; exceptionType - : classType - | typeVariable - ; + : classType + | typeVariable + ; methodBody - : block - | ';' - ; - + : block + | ';' + ; // Paragraph 8.6 // ------------- instanceInitializer - : block - ; - + : block + ; // Paragraph 8.7 // ------------- staticInitializer - :'static' block - ; - + : 'static' block + ; // Paragraph 8.8 // ------------- constructorDeclaration - : constructorModifier* constructorDeclarator throwsT? constructorBody - ; + : constructorModifier* constructorDeclarator throwsT? constructorBody + ; constructorModifier - : annotation - | 'public' - | 'protected' - | 'private' - ; + : annotation + | 'public' + | 'protected' + | 'private' + ; constructorDeclarator - : typeParameters? simpleTypeName '(' ( receiverParameter ',' )? formalParameterList? ')' - ; + : typeParameters? simpleTypeName '(' (receiverParameter ',')? formalParameterList? ')' + ; simpleTypeName - : typeIdentifier - ; + : typeIdentifier + ; constructorBody - : '{' explicitConstructorInvocation? blockStatements? '}' - ; + : '{' explicitConstructorInvocation? blockStatements? '}' + ; explicitConstructorInvocation - : typeArguments? ('this' | 'super') '(' argumentList? ')' ';' - | (expressionName | primary) '.' typeArguments? 'super' '(' argumentList? ')' ';' - ; - + : typeArguments? ('this' | 'super') '(' argumentList? ')' ';' + | (expressionName | primary) '.' typeArguments? 'super' '(' argumentList? ')' ';' + ; // Paragraph 8.9 // ------------- enumDeclaration - : classModifier* 'enum' typeIdentifier classImplements? enumBody - ; - + : classModifier* 'enum' typeIdentifier classImplements? enumBody + ; + enumBody - : '{' enumConstantList? ','? enumBodyDeclarations? '}' - // It is not my grammarmistake! It is based on //docs.oracle.com/javase/specs/jls/se20/jls20.pdf. - // Notice, javac accepts "enum One { , }" and also "enum Two { , ; {} }" - ; + : '{' enumConstantList? ','? enumBodyDeclarations? '}' + // It is not my grammarmistake! It is based on //docs.oracle.com/javase/specs/jls/se20/jls20.pdf. + // Notice, javac accepts "enum One { , }" and also "enum Two { , ; {} }" + ; enumConstantList - : enumConstant ( ',' enumConstant )* - ; - + : enumConstant (',' enumConstant)* + ; + enumConstant - : enumConstantModifier* Identifier ( '(' argumentList? ')' )? classBody? - ; - + : enumConstantModifier* Identifier ('(' argumentList? ')')? classBody? + ; + enumConstantModifier - : annotation - ; - -enumBodyDeclarations - : ';' classBodyDeclaration* - ; + : annotation + ; +enumBodyDeclarations + : ';' classBodyDeclaration* + ; // Paragraph 8.10 // -------------- recordDeclaration - : classModifier* 'record' typeIdentifier typeParameters? recordHeader classImplements? recordBody - ; - + : classModifier* 'record' typeIdentifier typeParameters? recordHeader classImplements? recordBody + ; + recordHeader - : '(' recordComponentList? ')' - ; + : '(' recordComponentList? ')' + ; recordComponentList - : recordComponent ( ',' recordComponent )* - ; - + : recordComponent (',' recordComponent)* + ; + recordComponent - : recordComponentModifier* unannType Identifier - | variableArityRecordComponent - ; - + : recordComponentModifier* unannType Identifier + | variableArityRecordComponent + ; + variableArityRecordComponent - : recordComponentModifier* unannType annotation* '...' Identifier - ; - + : recordComponentModifier* unannType annotation* '...' Identifier + ; + recordComponentModifier - : annotation - ; - + : annotation + ; + recordBody - : '{' recordBodyDeclaration* '}' - ; - + : '{' recordBodyDeclaration* '}' + ; + recordBodyDeclaration - : classBodyDeclaration - | compactConstructorDeclaration - ; - -compactConstructorDeclaration - : constructorModifier* simpleTypeName constructorBody - ; + : classBodyDeclaration + | compactConstructorDeclaration + ; +compactConstructorDeclaration + : constructorModifier* simpleTypeName constructorBody + ; // Paragraph 9.1 // ------------- interfaceDeclaration - : normalInterfaceDeclaration - | annotationInterfaceDeclaration - ; - + : normalInterfaceDeclaration + | annotationInterfaceDeclaration + ; + normalInterfaceDeclaration - : interfaceModifier* 'interface' typeIdentifier typeParameters? interfaceExtends? interfacePermits? interfaceBody - ; - + : interfaceModifier* 'interface' typeIdentifier typeParameters? interfaceExtends? interfacePermits? interfaceBody + ; + interfaceModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'sealed' - | 'non-sealed' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'sealed' + | 'non-sealed' + | 'strictfp' + ; interfaceExtends - : 'extends' interfaceTypeList - ; - + : 'extends' interfaceTypeList + ; + interfacePermits - : 'permits' typeName ( ',' typeName )* - ; - + : 'permits' typeName (',' typeName)* + ; + interfaceBody - : '{' interfaceMemberDeclaration* '}' - ; + : '{' interfaceMemberDeclaration* '}' + ; interfaceMemberDeclaration - : constantDeclaration - | interfaceMethodDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; - + : constantDeclaration + | interfaceMethodDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; // Paragraph 9.3 // ------------- constantDeclaration - : constantModifier* unannType variableDeclaratorList ';' - ; - -constantModifier - : annotation - | 'public' - | 'static' - | 'final' - ; + : constantModifier* unannType variableDeclaratorList ';' + ; +constantModifier + : annotation + | 'public' + | 'static' + | 'final' + ; // Paragraph 9.4 // ------------- interfaceMethodDeclaration - : interfaceMethodModifier* methodHeader methodBody - ; + : interfaceMethodModifier* methodHeader methodBody + ; interfaceMethodModifier - : annotation - | 'public' - | 'private' - | 'abstract' - | 'default' - | 'static' - | 'strictfp' - ; - + : annotation + | 'public' + | 'private' + | 'abstract' + | 'default' + | 'static' + | 'strictfp' + ; // Paragraph 9.6 // ------------- annotationInterfaceDeclaration - : interfaceModifier* '@' 'interface' typeIdentifier annotationInterfaceBody - ; - + : interfaceModifier* '@' 'interface' typeIdentifier annotationInterfaceBody + ; + annotationInterfaceBody - : '{' annotationInterfaceMemberDeclaration* '}' - ; + : '{' annotationInterfaceMemberDeclaration* '}' + ; annotationInterfaceMemberDeclaration - : annotationInterfaceElementDeclaration - | constantDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; + : annotationInterfaceElementDeclaration + | constantDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; annotationInterfaceElementDeclaration - : annotationInterfaceElementModifier* unannType Identifier '(' ')' dims? defaultValue? ';' - ; - + : annotationInterfaceElementModifier* unannType Identifier '(' ')' dims? defaultValue? ';' + ; + annotationInterfaceElementModifier - : annotation - | 'public' - | 'abstract' - ; - -defaultValue - : 'default' elementValue - ; + : annotation + | 'public' + | 'abstract' + ; +defaultValue + : 'default' elementValue + ; // Paragraph 9.7 // ------------- annotation - : normalAnnotation - | markerAnnotation - | singleElementAnnotation - ; + : normalAnnotation + | markerAnnotation + | singleElementAnnotation + ; - normalAnnotation - : '@' typeName '(' elementValuePairList? ')' - ; + : '@' typeName '(' elementValuePairList? ')' + ; - elementValuePairList - : elementValuePair ( ',' elementValuePair )* - ; - + : elementValuePair (',' elementValuePair)* + ; + elementValuePair - : Identifier '=' elementValue - ; + : Identifier '=' elementValue + ; elementValue - : conditionalExpression - | elementValueArrayInitializer - | annotation - ; - + : conditionalExpression + | elementValueArrayInitializer + | annotation + ; + elementValueArrayInitializer - : '{' elementValueList? ','? '}' - ; - + : '{' elementValueList? ','? '}' + ; + elementValueList - : elementValue ( ',' elementValue )* - ; + : elementValue (',' elementValue)* + ; markerAnnotation - : '@' typeName - ; + : '@' typeName + ; singleElementAnnotation - : '@' typeName '(' elementValue ')' - ; - + : '@' typeName '(' elementValue ')' + ; // Paragraph 10.6 // -------------- arrayInitializer - : '{' variableInitializerList? ','? '}' - // Strange ',' ?! staat ook in antlr_java.g4 - ; - -variableInitializerList - : variableInitializer ( ',' variableInitializer )* - ; + : '{' variableInitializerList? ','? '}' + // Strange ',' ?! staat ook in antlr_java.g4 + ; +variableInitializerList + : variableInitializer (',' variableInitializer)* + ; // Paragraph 14.2 // -------------- block - : '{' blockStatements? '}' - ; + : '{' blockStatements? '}' + ; blockStatements - : blockStatement blockStatement* - ; - + : blockStatement blockStatement* + ; + blockStatement - : localClassOrInterfaceDeclaration - | localVariableDeclarationStatement - | statement - ; - + : localClassOrInterfaceDeclaration + | localVariableDeclarationStatement + | statement + ; // Paragraph 14.3 // -------------- localClassOrInterfaceDeclaration - : classDeclaration - | normalInterfaceDeclaration - ; - + : classDeclaration + | normalInterfaceDeclaration + ; // Paragraph 14.4 // -------------- localVariableDeclaration - : variableModifier* localVariableType variableDeclaratorList? - ; - + : variableModifier* localVariableType variableDeclaratorList? + ; + localVariableType - : unannType - | 'var' - ; + : unannType + | 'var' + ; localVariableDeclarationStatement - : localVariableDeclaration ';' - ; - + : localVariableDeclaration ';' + ; // Paragraph 14.5 // -------------- statement - : statementWithoutTrailingSubstatement - | labeledStatement - | ifThenStatement - | ifThenElseStatement - | whileStatement - | forStatement - ; + : statementWithoutTrailingSubstatement + | labeledStatement + | ifThenStatement + | ifThenElseStatement + | whileStatement + | forStatement + ; statementNoShortIf - : statementWithoutTrailingSubstatement - | labeledStatementNoShortIf - | ifThenElseStatementNoShortIf - | whileStatementNoShortIf - | forStatementNoShortIf - ; + : statementWithoutTrailingSubstatement + | labeledStatementNoShortIf + | ifThenElseStatementNoShortIf + | whileStatementNoShortIf + | forStatementNoShortIf + ; statementWithoutTrailingSubstatement - : block - | emptyStatement - | expressionStatement - | assertStatement - | switchStatement - | doStatement - | breakStatement - | continueStatement - | returnStatement - | synchronizedStatement - | throwStatement - | tryStatement - | yieldStatement - ; - + : block + | emptyStatement + | expressionStatement + | assertStatement + | switchStatement + | doStatement + | breakStatement + | continueStatement + | returnStatement + | synchronizedStatement + | throwStatement + | tryStatement + | yieldStatement + ; // Paragraph 14.6 // -------------- emptyStatement - : ';' - ; - + : ';' + ; // Paragraph 14.7 // -------------- labeledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; labeledStatementNoShortIf - : Identifier ':' statementNoShortIf - ; - + : Identifier ':' statementNoShortIf + ; // Paragraph 14.8 // -------------- expressionStatement - : statementExpression ';' - ; - -statementExpression - : assignment - | preIncrementExpression - | preDecrementExpression - | postIncrementExpression - | postDecrementExpression - | methodInvocation - | classInstanceCreationExpression - ; - + : statementExpression ';' + ; + +statementExpression + : assignment + | preIncrementExpression + | preDecrementExpression + | postIncrementExpression + | postDecrementExpression + | methodInvocation + | classInstanceCreationExpression + ; // Paragraph 14.9 // -------------- ifThenStatement - : 'if' '(' expression ')' statement - ; + : 'if' '(' expression ')' statement + ; ifThenElseStatement - : 'if' '(' expression ')' statementNoShortIf 'else' statement - ; + : 'if' '(' expression ')' statementNoShortIf 'else' statement + ; ifThenElseStatementNoShortIf - : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf - ; - + : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf + ; // Paragraph 14.10 // --------------- assertStatement - : 'assert' expression ( ':' expression )? ';' - ; - + : 'assert' expression (':' expression)? ';' + ; // Paragraph 14.11 // -------------- switchStatement - : 'switch' '(' expression ')' switchBlock - ; + : 'switch' '(' expression ')' switchBlock + ; switchBlock - : '{' switchRule switchRule* '}' - | '{' switchBlockStatementGroup* ( switchLabel ':' )* '}' - ; - + : '{' switchRule switchRule* '}' + | '{' switchBlockStatementGroup* ( switchLabel ':')* '}' + ; + switchRule - : switchLabel '->' ( expression ';' | block | throwStatement ) - ; - + : switchLabel '->' (expression ';' | block | throwStatement) + ; + switchBlockStatementGroup - : switchLabel ':' ( switchLabel ':' )* blockStatements - ; + : switchLabel ':' (switchLabel ':')* blockStatements + ; switchLabel - : 'case' caseConstant ( ',' caseConstant )* - | 'default' - ; + : 'case' caseConstant (',' caseConstant)* + | 'default' + ; caseConstant - : conditionalExpression - ; - + : conditionalExpression + ; // Paragraph 14.12 // --------------- whileStatement - : 'while' '(' expression ')' statement - ; - -whileStatementNoShortIf - : 'while' '(' expression ')' statementNoShortIf - ; + : 'while' '(' expression ')' statement + ; +whileStatementNoShortIf + : 'while' '(' expression ')' statementNoShortIf + ; // Paragraph 14.13 // --------------- doStatement - : 'do' statement 'while' '(' expression ')' ';' - ; - + : 'do' statement 'while' '(' expression ')' ';' + ; // Paragraph 14.14 // --------------- forStatement - : basicForStatement - | enhancedForStatement - ; - + : basicForStatement + | enhancedForStatement + ; + forStatementNoShortIf - : basicForStatementNoShortIf - | enhancedForStatementNoShortIf - ; - + : basicForStatementNoShortIf + | enhancedForStatementNoShortIf + ; + basicForStatement - : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement - ; - + : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement + ; + basicForStatementNoShortIf - : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf - ; - + : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf + ; + forInit - : statementExpressionList - | localVariableDeclaration - ; - + : statementExpressionList + | localVariableDeclaration + ; + forUpdate - : statementExpressionList - ; - + : statementExpressionList + ; + statementExpressionList - : statementExpression ( ',' statementExpression )* - ; - + : statementExpression (',' statementExpression)* + ; + enhancedForStatement - : 'for' '(' localVariableDeclaration ':' expression ')' statement - ; - -enhancedForStatementNoShortIf - : 'for' '(' localVariableDeclaration ':' expression ')' statementNoShortIf - ; + : 'for' '(' localVariableDeclaration ':' expression ')' statement + ; +enhancedForStatementNoShortIf + : 'for' '(' localVariableDeclaration ':' expression ')' statementNoShortIf + ; // Paragraph 14.15 // --------------- breakStatement - : 'break' Identifier? ';' - ; - + : 'break' Identifier? ';' + ; // Paragraph 14.16 // --------------- continueStatement - : 'continue' Identifier? ';' - ; - + : 'continue' Identifier? ';' + ; // Paragraph 14.17 // --------------- returnStatement - : 'return' expression? ';' - ; - + : 'return' expression? ';' + ; // Paragraph 14.18 // --------------- throwStatement - : 'throw' expression ';' - ; - + : 'throw' expression ';' + ; // Paragraph 14.19 // --------------- synchronizedStatement - : 'synchronized' '(' expression ')' block - ; - + : 'synchronized' '(' expression ')' block + ; // Paragraph 14.20 // --------------- tryStatement - : 'try' block catches - | 'try' block finallyBlock - | 'try' block catches? finallyBlock - | tryWithResourcesStatement - ; + : 'try' block catches + | 'try' block finallyBlock + | 'try' block catches? finallyBlock + | tryWithResourcesStatement + ; catches - : catchClause catchClause* - ; - + : catchClause catchClause* + ; + catchClause - : 'catch' '(' catchFormalParameter ')' block - ; - + : 'catch' '(' catchFormalParameter ')' block + ; + catchFormalParameter - : variableModifier* catchType variableDeclaratorId - ; - + : variableModifier* catchType variableDeclaratorId + ; + catchType - : unannClassType ( '|' classType )* - ; - + : unannClassType ('|' classType)* + ; + finallyBlock - : 'finally' block - ; - + : 'finally' block + ; + tryWithResourcesStatement - : 'try' resourceSpecification block catches? finallyBlock? - ; - + : 'try' resourceSpecification block catches? finallyBlock? + ; + resourceSpecification - : '(' resourceList ';'? ')' - ; - + : '(' resourceList ';'? ')' + ; + resourceList - : resource ( ';' resource )* - ; - + : resource (';' resource)* + ; + resource - : localVariableDeclaration - | variableAccess - ; - + : localVariableDeclaration + | variableAccess + ; + variableAccess - : expressionName - | fieldAccess - ; - + : expressionName + | fieldAccess + ; // Paragraph 14.21 //---------------- yieldStatement - : 'yield' expression ';' - ; - + : 'yield' expression ';' + ; // Paragraph 14.30 // -------------- pattern - : typePattern - ; - -typePattern - : localVariableDeclaration - ; + : typePattern + ; +typePattern + : localVariableDeclaration + ; // Paragraph 15.2 // -------------- expression - : lambdaExpression - | assignmentExpression - ; - + : lambdaExpression + | assignmentExpression + ; // Paragraph 15.8 // -------------- primary - : primaryNoNewArray - | arrayCreationExpression - ; + : primaryNoNewArray + | arrayCreationExpression + ; // Replace classInstanceCreationExpression, fieldAccess, arrayAccess, methodInvocation, and // methodReference in primaryNoNewArray. // Replace in these two rules primary by primaryNoNewArray. - + // primaryNoNewArray // : literal // | classLiteral @@ -1244,146 +1198,140 @@ primary // primaryNoNewArray - : literal pNNA? - | classLiteral pNNA? - | 'this' pNNA? - | typeName '.' 'this' pNNA? - | '(' expression ')' pNNA? - | unqualifiedClassInstanceCreationExpression pNNA? - | expressionName '.' unqualifiedClassInstanceCreationExpression pNNA? - | arrayCreationExpression '.' unqualifiedClassInstanceCreationExpression pNNA? - | arrayCreationExpression '.' Identifier pNNA? - | 'super' '.' Identifier pNNA? - | typeName '.' 'super' '.' Identifier pNNA? - | expressionName '[' expression ']' pNNA? - | arrayCreationExpressionWithInitializer '[' expression ']' pNNA? - | methodName '(' argumentList? ')' pNNA? - | typeName '.' typeArguments? Identifier '(' argumentList? ')' pNNA? - | expressionName '.' typeArguments? Identifier '(' argumentList? ')' pNNA? - | arrayCreationExpression '.' typeArguments? Identifier '(' argumentList? ')' pNNA? - | 'super' '.' typeArguments? Identifier '(' argumentList? ')' pNNA? - | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' pNNA? - | expressionName '::' typeArguments? Identifier pNNA? - | arrayCreationExpression '::' typeArguments? Identifier pNNA? - | referenceType '::' typeArguments? Identifier pNNA? - | 'super' '::' typeArguments? Identifier pNNA? - | typeName '.' 'super' '::' typeArguments? Identifier pNNA? - | classType '::' typeArguments? 'new' pNNA? - | arrayType '::' 'new' pNNA? - ; + : literal pNNA? + | classLiteral pNNA? + | 'this' pNNA? + | typeName '.' 'this' pNNA? + | '(' expression ')' pNNA? + | unqualifiedClassInstanceCreationExpression pNNA? + | expressionName '.' unqualifiedClassInstanceCreationExpression pNNA? + | arrayCreationExpression '.' unqualifiedClassInstanceCreationExpression pNNA? + | arrayCreationExpression '.' Identifier pNNA? + | 'super' '.' Identifier pNNA? + | typeName '.' 'super' '.' Identifier pNNA? + | expressionName '[' expression ']' pNNA? + | arrayCreationExpressionWithInitializer '[' expression ']' pNNA? + | methodName '(' argumentList? ')' pNNA? + | typeName '.' typeArguments? Identifier '(' argumentList? ')' pNNA? + | expressionName '.' typeArguments? Identifier '(' argumentList? ')' pNNA? + | arrayCreationExpression '.' typeArguments? Identifier '(' argumentList? ')' pNNA? + | 'super' '.' typeArguments? Identifier '(' argumentList? ')' pNNA? + | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' pNNA? + | expressionName '::' typeArguments? Identifier pNNA? + | arrayCreationExpression '::' typeArguments? Identifier pNNA? + | referenceType '::' typeArguments? Identifier pNNA? + | 'super' '::' typeArguments? Identifier pNNA? + | typeName '.' 'super' '::' typeArguments? Identifier pNNA? + | classType '::' typeArguments? 'new' pNNA? + | arrayType '::' 'new' pNNA? + ; pNNA - : '.' unqualifiedClassInstanceCreationExpression pNNA? - | '.' Identifier pNNA? - | '[' expression ']' pNNA? - | '.' typeArguments? Identifier '(' argumentList? ')' pNNA? - | '::' typeArguments? Identifier pNNA? - ; - + : '.' unqualifiedClassInstanceCreationExpression pNNA? + | '.' Identifier pNNA? + | '[' expression ']' pNNA? + | '.' typeArguments? Identifier '(' argumentList? ')' pNNA? + | '::' typeArguments? Identifier pNNA? + ; + classLiteral - : typeName ( '[' ']' )* '.' 'class' - | numericType ( '[' ']' )* '.' 'class' - | 'boolean' ( '[' ']' )* '.' 'class' - | 'void' '.' 'class' - ; - - + : typeName ('[' ']')* '.' 'class' + | numericType ( '[' ']')* '.' 'class' + | 'boolean' ( '[' ']')* '.' 'class' + | 'void' '.' 'class' + ; + // Paragraph 15.9 // -------------- classInstanceCreationExpression - : unqualifiedClassInstanceCreationExpression - | expressionName '.' unqualifiedClassInstanceCreationExpression - | primary '.' unqualifiedClassInstanceCreationExpression - ; - + : unqualifiedClassInstanceCreationExpression + | expressionName '.' unqualifiedClassInstanceCreationExpression + | primary '.' unqualifiedClassInstanceCreationExpression + ; + unqualifiedClassInstanceCreationExpression - : 'new' typeArguments? classOrInterfaceTypeToInstantiate '(' argumentList? ')' classBody? - ; - + : 'new' typeArguments? classOrInterfaceTypeToInstantiate '(' argumentList? ')' classBody? + ; + classOrInterfaceTypeToInstantiate - : annotation* Identifier ( '.' annotation* Identifier )* typeArgumentsOrDiamond? - ; - -typeArgumentsOrDiamond - : typeArguments - | '<>' - ; + : annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? + ; +typeArgumentsOrDiamond + : typeArguments + | '<>' + ; // Paragraph 15.10 // --------------- arrayCreationExpression - : arrayCreationExpressionWithoutInitializer - | arrayCreationExpressionWithInitializer - ; - + : arrayCreationExpressionWithoutInitializer + | arrayCreationExpressionWithInitializer + ; + arrayCreationExpressionWithoutInitializer - : 'new' primitiveType dimExprs dims? - | 'new' classType dimExprs dims? - ; - + : 'new' primitiveType dimExprs dims? + | 'new' classType dimExprs dims? + ; + arrayCreationExpressionWithInitializer - : 'new' primitiveType dims arrayInitializer - | 'new' classOrInterfaceType dims arrayInitializer - ; - + : 'new' primitiveType dims arrayInitializer + | 'new' classOrInterfaceType dims arrayInitializer + ; + dimExprs - : dimExpr dimExpr* - ; - + : dimExpr dimExpr* + ; + dimExpr - : annotation* '[' expression ']' - ; - -arrayAccess - : expressionName '[' expression ']' - | primaryNoNewArray '[' expression ']' - | arrayCreationExpressionWithInitializer '[' expression ']' - ; + : annotation* '[' expression ']' + ; +arrayAccess + : expressionName '[' expression ']' + | primaryNoNewArray '[' expression ']' + | arrayCreationExpressionWithInitializer '[' expression ']' + ; // Paragraph 15.11 // --------------- fieldAccess - : primary '.' Identifier - | 'super' '.' Identifier - | typeName '.' 'super' '.' Identifier - ; - + : primary '.' Identifier + | 'super' '.' Identifier + | typeName '.' 'super' '.' Identifier + ; // Paragraph 15.12 // --------------- methodInvocation - : methodName '(' argumentList? ')' - | typeName '.' typeArguments? Identifier '(' argumentList? ')' - | expressionName '.' typeArguments? Identifier '(' argumentList? ')' - | primary '.' typeArguments? Identifier '(' argumentList? ')' - | 'super' '.' typeArguments? Identifier '(' argumentList? ')' - | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' - ; - + : methodName '(' argumentList? ')' + | typeName '.' typeArguments? Identifier '(' argumentList? ')' + | expressionName '.' typeArguments? Identifier '(' argumentList? ')' + | primary '.' typeArguments? Identifier '(' argumentList? ')' + | 'super' '.' typeArguments? Identifier '(' argumentList? ')' + | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' + ; + argumentList - : expression ( ',' expression )* - ; - - + : expression (',' expression)* + ; + // Paragraph 15.13 // --------------- methodReference - : expressionName '::' typeArguments? Identifier - | primary '::' typeArguments? Identifier - | referenceType '::' typeArguments? Identifier - | 'super' '::' typeArguments? Identifier - | typeName '.' 'super' '::' typeArguments? Identifier - | classType '::' typeArguments? 'new' - | arrayType '::' 'new' - ; - + : expressionName '::' typeArguments? Identifier + | primary '::' typeArguments? Identifier + | referenceType '::' typeArguments? Identifier + | 'super' '::' typeArguments? Identifier + | typeName '.' 'super' '::' typeArguments? Identifier + | classType '::' typeArguments? 'new' + | arrayType '::' 'new' + ; // Paragraph 15.14 // --------------- @@ -1407,248 +1355,234 @@ methodReference // postfixExpression - : primary pfE? - | expressionName pfE? - ; + : primary pfE? + | expressionName pfE? + ; -pfE : '++' pfE? - | '--' pfE? - ; +pfE + : '++' pfE? + | '--' pfE? + ; postIncrementExpression - : postfixExpression '++' - ; - -postDecrementExpression - : postfixExpression '--' - ; + : postfixExpression '++' + ; +postDecrementExpression + : postfixExpression '--' + ; // Paragraph 15.15 // --------------- unaryExpression - : preIncrementExpression - | preDecrementExpression - | '+' unaryExpression - | '-' unaryExpression - | unaryExpressionNotPlusMinus - ; - + : preIncrementExpression + | preDecrementExpression + | '+' unaryExpression + | '-' unaryExpression + | unaryExpressionNotPlusMinus + ; + preIncrementExpression - : '++' unaryExpression - ; - + : '++' unaryExpression + ; + preDecrementExpression - : '--' unaryExpression - ; - -unaryExpressionNotPlusMinus - : postfixExpression - | '~' unaryExpression - | '!' unaryExpression - | castExpression - | switchExpression - ; + : '--' unaryExpression + ; +unaryExpressionNotPlusMinus + : postfixExpression + | '~' unaryExpression + | '!' unaryExpression + | castExpression + | switchExpression + ; // Paragraph 15.16 // --------------- castExpression - : '(' primitiveType ')' unaryExpression - | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus - | '(' referenceType additionalBound* ')' lambdaExpression - ; - + : '(' primitiveType ')' unaryExpression + | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus + | '(' referenceType additionalBound* ')' lambdaExpression + ; // Paragraph 15.17 // --------------- multiplicativeExpression - : unaryExpression - | multiplicativeExpression '*' unaryExpression - | multiplicativeExpression '/' unaryExpression - | multiplicativeExpression '%' unaryExpression - ; - + : unaryExpression + | multiplicativeExpression '*' unaryExpression + | multiplicativeExpression '/' unaryExpression + | multiplicativeExpression '%' unaryExpression + ; // Paragraph 15.18 // --------------- additiveExpression - : multiplicativeExpression - | additiveExpression '+' multiplicativeExpression - | additiveExpression '-' multiplicativeExpression - ; - + : multiplicativeExpression + | additiveExpression '+' multiplicativeExpression + | additiveExpression '-' multiplicativeExpression + ; // Paragraph 15.19 // --------------- shiftExpression - : additiveExpression - | shiftExpression '<''<' additiveExpression - | shiftExpression '>''>' additiveExpression - | shiftExpression '>''>''>' additiveExpression - ; - + : additiveExpression + | shiftExpression '<' '<' additiveExpression + | shiftExpression '>' '>' additiveExpression + | shiftExpression '>' '>' '>' additiveExpression + ; // Paragraph 15.20 // --------------- relationalExpression - : shiftExpression - | relationalExpression '<' shiftExpression - | relationalExpression '>' shiftExpression - | relationalExpression '<=' shiftExpression - | relationalExpression '>=' shiftExpression -// | instanceofExpression - | relationalExpression 'instanceof' (referenceType | pattern) - // Solves left recursion with instanceofExpression. - ; + : shiftExpression + | relationalExpression '<' shiftExpression + | relationalExpression '>' shiftExpression + | relationalExpression '<=' shiftExpression + | relationalExpression '>=' shiftExpression + // | instanceofExpression + | relationalExpression 'instanceof' (referenceType | pattern) + // Solves left recursion with instanceofExpression. + ; // instanceofExpression // : relationalExpression 'instanceof' (referenceType | pattern) // ; // Resulted to left recursion with relationalExpression. - // Paragraph 15.21 // --------------- equalityExpression - : relationalExpression - | equalityExpression '==' relationalExpression - | equalityExpression '!=' relationalExpression - ; - + : relationalExpression + | equalityExpression '==' relationalExpression + | equalityExpression '!=' relationalExpression + ; // Paragraph 15.22 // --------------- andExpression - : equalityExpression - | andExpression '&' equalityExpression - ; + : equalityExpression + | andExpression '&' equalityExpression + ; exclusiveOrExpression - : andExpression - | exclusiveOrExpression '^' andExpression - ; + : andExpression + | exclusiveOrExpression '^' andExpression + ; inclusiveOrExpression - : exclusiveOrExpression - | inclusiveOrExpression '|' exclusiveOrExpression - ; - + : exclusiveOrExpression + | inclusiveOrExpression '|' exclusiveOrExpression + ; // Paragraph 15.23 // --------------- conditionalAndExpression - : inclusiveOrExpression - | conditionalAndExpression '&&' inclusiveOrExpression - ; - + : inclusiveOrExpression + | conditionalAndExpression '&&' inclusiveOrExpression + ; // Paragraph 15.24 // --------------- conditionalOrExpression - : conditionalAndExpression - | conditionalOrExpression '||' conditionalAndExpression - ; - + : conditionalAndExpression + | conditionalOrExpression '||' conditionalAndExpression + ; // Paragraph 15.25 // --------------- conditionalExpression - : conditionalOrExpression - | conditionalOrExpression '?' expression ':' conditionalExpression - | conditionalOrExpression '?' expression ':' lambdaExpression - ; - + : conditionalOrExpression + | conditionalOrExpression '?' expression ':' conditionalExpression + | conditionalOrExpression '?' expression ':' lambdaExpression + ; // Paragraph 15.26 // --------------- assignmentExpression - : conditionalExpression - | assignment - ; - + : conditionalExpression + | assignment + ; + assignment - : leftHandSide assignmentOperator expression - ; - + : leftHandSide assignmentOperator expression + ; + leftHandSide - : expressionName - | fieldAccess - | arrayAccess - ; + : expressionName + | fieldAccess + | arrayAccess + ; assignmentOperator - : '=' - | '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; - + : '=' + | '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; // Paragraph 15.27 // --------------- lambdaExpression - : lambdaParameters '->' lambdaBody - ; - + : lambdaParameters '->' lambdaBody + ; + lambdaParameters - : '(' lambdaParameterList? ')' - | Identifier - ; - + : '(' lambdaParameterList? ')' + | Identifier + ; + lambdaParameterList - : lambdaParameter ( ',' lambdaParameter )* - | Identifier ( ',' Identifier )* - ; - + : lambdaParameter (',' lambdaParameter)* + | Identifier ( ',' Identifier)* + ; + lambdaParameter - : variableModifier* lambdaParameterType variableDeclaratorId - | variableArityParameter - ; - + : variableModifier* lambdaParameterType variableDeclaratorId + | variableArityParameter + ; + lambdaParameterType - : unannType - | 'var' - ; - + : unannType + | 'var' + ; + lambdaBody - : expression - | block - ; - + : expression + | block + ; // Paragraph 15.28 // --------------- switchExpression - : 'switch' '(' expression ')' switchBlock - ; - + : 'switch' '(' expression ')' switchBlock + ; // Paragraph 15.29 // --------------- constantExpression - : expression - ; \ No newline at end of file + : expression + ; \ No newline at end of file diff --git a/java/java8/Java8Lexer.g4 b/java/java8/Java8Lexer.g4 index bc4d2c1336..7beefbe556 100644 --- a/java/java8/Java8Lexer.g4 +++ b/java/java8/Java8Lexer.g4 @@ -52,342 +52,200 @@ /Users/parrt/antlr/code/grammars-v4/java8/./Test.java Total lexer+parser time 30844ms. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Java8Lexer; // LEXER // §3.9 Keywords -ABSTRACT : 'abstract'; -ASSERT : 'assert'; -BOOLEAN : 'boolean'; -BREAK : 'break'; -BYTE : 'byte'; -CASE : 'case'; -CATCH : 'catch'; -CHAR : 'char'; -CLASS : 'class'; -CONST : 'const'; -CONTINUE : 'continue'; -DEFAULT : 'default'; -DO : 'do'; -DOUBLE : 'double'; -ELSE : 'else'; -ENUM : 'enum'; -EXTENDS : 'extends'; -FINAL : 'final'; -FINALLY : 'finally'; -FLOAT : 'float'; -FOR : 'for'; -IF : 'if'; -GOTO : 'goto'; -IMPLEMENTS : 'implements'; -IMPORT : 'import'; -INSTANCEOF : 'instanceof'; -INT : 'int'; -INTERFACE : 'interface'; -LONG : 'long'; -NATIVE : 'native'; -NEW : 'new'; -PACKAGE : 'package'; -PRIVATE : 'private'; -PROTECTED : 'protected'; -PUBLIC : 'public'; -RETURN : 'return'; -SHORT : 'short'; -STATIC : 'static'; -STRICTFP : 'strictfp'; -SUPER : 'super'; -SWITCH : 'switch'; +ABSTRACT : 'abstract'; +ASSERT : 'assert'; +BOOLEAN : 'boolean'; +BREAK : 'break'; +BYTE : 'byte'; +CASE : 'case'; +CATCH : 'catch'; +CHAR : 'char'; +CLASS : 'class'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXTENDS : 'extends'; +FINAL : 'final'; +FINALLY : 'finally'; +FLOAT : 'float'; +FOR : 'for'; +IF : 'if'; +GOTO : 'goto'; +IMPLEMENTS : 'implements'; +IMPORT : 'import'; +INSTANCEOF : 'instanceof'; +INT : 'int'; +INTERFACE : 'interface'; +LONG : 'long'; +NATIVE : 'native'; +NEW : 'new'; +PACKAGE : 'package'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PUBLIC : 'public'; +RETURN : 'return'; +SHORT : 'short'; +STATIC : 'static'; +STRICTFP : 'strictfp'; +SUPER : 'super'; +SWITCH : 'switch'; SYNCHRONIZED : 'synchronized'; -THIS : 'this'; -THROW : 'throw'; -THROWS : 'throws'; -TRANSIENT : 'transient'; -TRY : 'try'; -VOID : 'void'; -VOLATILE : 'volatile'; -WHILE : 'while'; +THIS : 'this'; +THROW : 'throw'; +THROWS : 'throws'; +TRANSIENT : 'transient'; +TRY : 'try'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; // §3.10.1 Integer Literals -IntegerLiteral - : DecimalIntegerLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - | BinaryIntegerLiteral - ; +IntegerLiteral: + DecimalIntegerLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + | BinaryIntegerLiteral +; -fragment -DecimalIntegerLiteral - : DecimalNumeral IntegerTypeSuffix? - ; +fragment DecimalIntegerLiteral: DecimalNumeral IntegerTypeSuffix?; -fragment -HexIntegerLiteral - : HexNumeral IntegerTypeSuffix? - ; +fragment HexIntegerLiteral: HexNumeral IntegerTypeSuffix?; -fragment -OctalIntegerLiteral - : OctalNumeral IntegerTypeSuffix? - ; +fragment OctalIntegerLiteral: OctalNumeral IntegerTypeSuffix?; -fragment -BinaryIntegerLiteral - : BinaryNumeral IntegerTypeSuffix? - ; +fragment BinaryIntegerLiteral: BinaryNumeral IntegerTypeSuffix?; -fragment -IntegerTypeSuffix - : [lL] - ; +fragment IntegerTypeSuffix: [lL]; -fragment -DecimalNumeral - : '0' - | NonZeroDigit (Digits? | Underscores Digits) - ; +fragment DecimalNumeral: '0' | NonZeroDigit (Digits? | Underscores Digits); -fragment -Digits - : Digit (DigitsAndUnderscores? Digit)? - ; +fragment Digits: Digit (DigitsAndUnderscores? Digit)?; -fragment -Digit - : '0' - | NonZeroDigit - ; +fragment Digit: '0' | NonZeroDigit; -fragment -NonZeroDigit - : [1-9] - ; +fragment NonZeroDigit: [1-9]; -fragment -DigitsAndUnderscores - : DigitOrUnderscore+ - ; +fragment DigitsAndUnderscores: DigitOrUnderscore+; -fragment -DigitOrUnderscore - : Digit - | '_' - ; +fragment DigitOrUnderscore: Digit | '_'; -fragment -Underscores - : '_'+ - ; +fragment Underscores: '_'+; -fragment -HexNumeral - : '0' [xX] HexDigits - ; +fragment HexNumeral: '0' [xX] HexDigits; -fragment -HexDigits - : HexDigit (HexDigitsAndUnderscores? HexDigit)? - ; +fragment HexDigits: HexDigit (HexDigitsAndUnderscores? HexDigit)?; -fragment -HexDigit - : [0-9a-fA-F] - ; +fragment HexDigit: [0-9a-fA-F]; -fragment -HexDigitsAndUnderscores - : HexDigitOrUnderscore+ - ; +fragment HexDigitsAndUnderscores: HexDigitOrUnderscore+; -fragment -HexDigitOrUnderscore - : HexDigit - | '_' - ; +fragment HexDigitOrUnderscore: HexDigit | '_'; -fragment -OctalNumeral - : '0' Underscores? OctalDigits - ; +fragment OctalNumeral: '0' Underscores? OctalDigits; -fragment -OctalDigits - : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)? - ; +fragment OctalDigits: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?; -fragment -OctalDigit - : [0-7] - ; +fragment OctalDigit: [0-7]; -fragment -OctalDigitsAndUnderscores - : OctalDigitOrUnderscore+ - ; +fragment OctalDigitsAndUnderscores: OctalDigitOrUnderscore+; -fragment -OctalDigitOrUnderscore - : OctalDigit - | '_' - ; +fragment OctalDigitOrUnderscore: OctalDigit | '_'; -fragment -BinaryNumeral - : '0' [bB] BinaryDigits - ; +fragment BinaryNumeral: '0' [bB] BinaryDigits; -fragment -BinaryDigits - : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)? - ; +fragment BinaryDigits: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?; -fragment -BinaryDigit - : [01] - ; +fragment BinaryDigit: [01]; -fragment -BinaryDigitsAndUnderscores - : BinaryDigitOrUnderscore+ - ; +fragment BinaryDigitsAndUnderscores: BinaryDigitOrUnderscore+; -fragment -BinaryDigitOrUnderscore - : BinaryDigit - | '_' - ; +fragment BinaryDigitOrUnderscore: BinaryDigit | '_'; // §3.10.2 Floating-Point Literals -FloatingPointLiteral - : DecimalFloatingPointLiteral - | HexadecimalFloatingPointLiteral - ; +FloatingPointLiteral: DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral; -fragment -DecimalFloatingPointLiteral - : Digits '.' Digits? ExponentPart? FloatTypeSuffix? - | '.' Digits ExponentPart? FloatTypeSuffix? - | Digits ExponentPart FloatTypeSuffix? - | Digits FloatTypeSuffix - ; +fragment DecimalFloatingPointLiteral: + Digits '.' Digits? ExponentPart? FloatTypeSuffix? + | '.' Digits ExponentPart? FloatTypeSuffix? + | Digits ExponentPart FloatTypeSuffix? + | Digits FloatTypeSuffix +; -fragment -ExponentPart - : ExponentIndicator SignedInteger - ; +fragment ExponentPart: ExponentIndicator SignedInteger; -fragment -ExponentIndicator - : [eE] - ; +fragment ExponentIndicator: [eE]; -fragment -SignedInteger - : Sign? Digits - ; +fragment SignedInteger: Sign? Digits; -fragment -Sign - : [+-] - ; +fragment Sign: [+-]; -fragment -FloatTypeSuffix - : [fFdD] - ; +fragment FloatTypeSuffix: [fFdD]; -fragment -HexadecimalFloatingPointLiteral - : HexSignificand BinaryExponent FloatTypeSuffix? - ; +fragment HexadecimalFloatingPointLiteral: HexSignificand BinaryExponent FloatTypeSuffix?; -fragment -HexSignificand - : HexNumeral '.'? - | '0' [xX] HexDigits? '.' HexDigits - ; +fragment HexSignificand: HexNumeral '.'? | '0' [xX] HexDigits? '.' HexDigits; -fragment -BinaryExponent - : BinaryExponentIndicator SignedInteger - ; +fragment BinaryExponent: BinaryExponentIndicator SignedInteger; -fragment -BinaryExponentIndicator - : [pP] - ; +fragment BinaryExponentIndicator: [pP]; // §3.10.3 Boolean Literals -BooleanLiteral - : 'true' - | 'false' - ; +BooleanLiteral: 'true' | 'false'; // §3.10.4 Character Literals -CharacterLiteral - : '\'' SingleCharacter '\'' - | '\'' EscapeSequence '\'' - ; +CharacterLiteral: '\'' SingleCharacter '\'' | '\'' EscapeSequence '\''; -fragment -SingleCharacter - : ~['\\\r\n] - ; +fragment SingleCharacter: ~['\\\r\n]; // §3.10.5 String Literals -StringLiteral - : '"' StringCharacters? '"' - ; +StringLiteral: '"' StringCharacters? '"'; -fragment -StringCharacters - : StringCharacter+ - ; +fragment StringCharacters: StringCharacter+; -fragment -StringCharacter - : ~["\\\r\n] - | EscapeSequence - ; +fragment StringCharacter: ~["\\\r\n] | EscapeSequence; // §3.10.6 Escape Sequences for Character and String Literals -fragment -EscapeSequence - : '\\' 'u005c'? [btnfr"'\\] - | OctalEscape - | UnicodeEscape // This is not in the spec but prevents having to preprocess the input - ; +fragment EscapeSequence: + '\\' 'u005c'? [btnfr"'\\] + | OctalEscape + | UnicodeEscape // This is not in the spec but prevents having to preprocess the input +; -fragment -OctalEscape - : '\\' 'u005c'? OctalDigit - | '\\' 'u005c'? OctalDigit OctalDigit - | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit - ; +fragment OctalEscape: + '\\' 'u005c'? OctalDigit + | '\\' 'u005c'? OctalDigit OctalDigit + | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit +; -fragment -ZeroToThree - : [0-3] - ; +fragment ZeroToThree: [0-3]; // This is not in the spec but prevents having to preprocess the input -fragment -UnicodeEscape - : '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +fragment UnicodeEscape: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit; // §3.10.7 The Null Literal -NullLiteral - : 'null' - ; +NullLiteral: 'null'; // §3.11 Separators @@ -397,55 +255,53 @@ LBRACE : '{'; RBRACE : '}'; LBRACK : '['; RBRACK : ']'; -SEMI : ';'; -COMMA : ','; -DOT : '.'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; // §3.12 Operators -ASSIGN : '='; -GT : '>'; -LT : '<'; -BANG : '!'; -TILDE : '~'; -QUESTION : '?'; -COLON : ':'; -EQUAL : '=='; -LE : '<='; -GE : '>='; -NOTEQUAL : '!='; -AND : '&&'; -OR : '||'; -INC : '++'; -DEC : '--'; -ADD : '+'; -SUB : '-'; -MUL : '*'; -DIV : '/'; -BITAND : '&'; -BITOR : '|'; -CARET : '^'; -MOD : '%'; -ARROW : '->'; +ASSIGN : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +EQUAL : '=='; +LE : '<='; +GE : '>='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +CARET : '^'; +MOD : '%'; +ARROW : '->'; COLONCOLON : '::'; -ADD_ASSIGN : '+='; -SUB_ASSIGN : '-='; -MUL_ASSIGN : '*='; -DIV_ASSIGN : '/='; -AND_ASSIGN : '&='; -OR_ASSIGN : '|='; -XOR_ASSIGN : '^='; -MOD_ASSIGN : '%='; -LSHIFT_ASSIGN : '<<='; -RSHIFT_ASSIGN : '>>='; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; URSHIFT_ASSIGN : '>>>='; // §3.8 Identifiers (must appear after all keywords in the grammar) -Identifier - : IdentifierStart IdentifierPart* - ; +Identifier: IdentifierStart IdentifierPart*; /* fragment JavaLetter @@ -466,661 +322,656 @@ JavaLetterOrDigit ;*/ // Dropped SMP support as ANTLR has no native support for it -fragment IdentifierStart - : [\u0024] - | [\u0041-\u005A] - | [\u005F] - | [\u0061-\u007A] - | [\u00A2-\u00A5] - | [\u00AA] - | [\u00B5] - | [\u00BA] - | [\u00C0-\u00D6] - | [\u00D8-\u00F6] - | [\u00F8-\u02C1] - | [\u02C6-\u02D1] - | [\u02E0-\u02E4] - | [\u02EC] - | [\u02EE] - | [\u0370-\u0374] - | [\u0376-\u0377] - | [\u037A-\u037D] - | [\u037F] - | [\u0386] - | [\u0388-\u038A] - | [\u038C] - | [\u038E-\u03A1] - | [\u03A3-\u03F5] - | [\u03F7-\u0481] - | [\u048A-\u052F] - | [\u0531-\u0556] - | [\u0559] - | [\u0561-\u0587] - | [\u058F] - | [\u05D0-\u05EA] - | [\u05F0-\u05F2] - | [\u060B] - | [\u0620-\u064A] - | [\u066E-\u066F] - | [\u0671-\u06D3] - | [\u06D5] - | [\u06E5-\u06E6] - | [\u06EE-\u06EF] - | [\u06FA-\u06FC] - | [\u06FF] - | [\u0710] - | [\u0712-\u072F] - | [\u074D-\u07A5] - | [\u07B1] - | [\u07CA-\u07EA] - | [\u07F4-\u07F5] - | [\u07FA] - | [\u0800-\u0815] - | [\u081A] - | [\u0824] - | [\u0828] - | [\u0840-\u0858] - | [\u0860-\u086A] - | [\u08A0-\u08B4] - | [\u08B6-\u08BD] - | [\u0904-\u0939] - | [\u093D] - | [\u0950] - | [\u0958-\u0961] - | [\u0971-\u0980] - | [\u0985-\u098C] - | [\u098F-\u0990] - | [\u0993-\u09A8] - | [\u09AA-\u09B0] - | [\u09B2] - | [\u09B6-\u09B9] - | [\u09BD] - | [\u09CE] - | [\u09DC-\u09DD] - | [\u09DF-\u09E1] - | [\u09F0-\u09F3] - | [\u09FB-\u09FC] - | [\u0A05-\u0A0A] - | [\u0A0F-\u0A10] - | [\u0A13-\u0A28] - | [\u0A2A-\u0A30] - | [\u0A32-\u0A33] - | [\u0A35-\u0A36] - | [\u0A38-\u0A39] - | [\u0A59-\u0A5C] - | [\u0A5E] - | [\u0A72-\u0A74] - | [\u0A85-\u0A8D] - | [\u0A8F-\u0A91] - | [\u0A93-\u0AA8] - | [\u0AAA-\u0AB0] - | [\u0AB2-\u0AB3] - | [\u0AB5-\u0AB9] - | [\u0ABD] - | [\u0AD0] - | [\u0AE0-\u0AE1] - | [\u0AF1] - | [\u0AF9] - | [\u0B05-\u0B0C] - | [\u0B0F-\u0B10] - | [\u0B13-\u0B28] - | [\u0B2A-\u0B30] - | [\u0B32-\u0B33] - | [\u0B35-\u0B39] - | [\u0B3D] - | [\u0B5C-\u0B5D] - | [\u0B5F-\u0B61] - | [\u0B71] - | [\u0B83] - | [\u0B85-\u0B8A] - | [\u0B8E-\u0B90] - | [\u0B92-\u0B95] - | [\u0B99-\u0B9A] - | [\u0B9C] - | [\u0B9E-\u0B9F] - | [\u0BA3-\u0BA4] - | [\u0BA8-\u0BAA] - | [\u0BAE-\u0BB9] - | [\u0BD0] - | [\u0BF9] - | [\u0C05-\u0C0C] - | [\u0C0E-\u0C10] - | [\u0C12-\u0C28] - | [\u0C2A-\u0C39] - | [\u0C3D] - | [\u0C58-\u0C5A] - | [\u0C60-\u0C61] - | [\u0C80] - | [\u0C85-\u0C8C] - | [\u0C8E-\u0C90] - | [\u0C92-\u0CA8] - | [\u0CAA-\u0CB3] - | [\u0CB5-\u0CB9] - | [\u0CBD] - | [\u0CDE] - | [\u0CE0-\u0CE1] - | [\u0CF1-\u0CF2] - | [\u0D05-\u0D0C] - | [\u0D0E-\u0D10] - | [\u0D12-\u0D3A] - | [\u0D3D] - | [\u0D4E] - | [\u0D54-\u0D56] - | [\u0D5F-\u0D61] - | [\u0D7A-\u0D7F] - | [\u0D85-\u0D96] - | [\u0D9A-\u0DB1] - | [\u0DB3-\u0DBB] - | [\u0DBD] - | [\u0DC0-\u0DC6] - | [\u0E01-\u0E30] - | [\u0E32-\u0E33] - | [\u0E3F-\u0E46] - | [\u0E81-\u0E82] - | [\u0E84] - | [\u0E87-\u0E88] - | [\u0E8A] - | [\u0E8D] - | [\u0E94-\u0E97] - | [\u0E99-\u0E9F] - | [\u0EA1-\u0EA3] - | [\u0EA5] - | [\u0EA7] - | [\u0EAA-\u0EAB] - | [\u0EAD-\u0EB0] - | [\u0EB2-\u0EB3] - | [\u0EBD] - | [\u0EC0-\u0EC4] - | [\u0EC6] - | [\u0EDC-\u0EDF] - | [\u0F00] - | [\u0F40-\u0F47] - | [\u0F49-\u0F6C] - | [\u0F88-\u0F8C] - | [\u1000-\u102A] - | [\u103F] - | [\u1050-\u1055] - | [\u105A-\u105D] - | [\u1061] - | [\u1065-\u1066] - | [\u106E-\u1070] - | [\u1075-\u1081] - | [\u108E] - | [\u10A0-\u10C5] - | [\u10C7] - | [\u10CD] - | [\u10D0-\u10FA] - | [\u10FC-\u1248] - | [\u124A-\u124D] - | [\u1250-\u1256] - | [\u1258] - | [\u125A-\u125D] - | [\u1260-\u1288] - | [\u128A-\u128D] - | [\u1290-\u12B0] - | [\u12B2-\u12B5] - | [\u12B8-\u12BE] - | [\u12C0] - | [\u12C2-\u12C5] - | [\u12C8-\u12D6] - | [\u12D8-\u1310] - | [\u1312-\u1315] - | [\u1318-\u135A] - | [\u1380-\u138F] - | [\u13A0-\u13F5] - | [\u13F8-\u13FD] - | [\u1401-\u166C] - | [\u166F-\u167F] - | [\u1681-\u169A] - | [\u16A0-\u16EA] - | [\u16EE-\u16F8] - | [\u1700-\u170C] - | [\u170E-\u1711] - | [\u1720-\u1731] - | [\u1740-\u1751] - | [\u1760-\u176C] - | [\u176E-\u1770] - | [\u1780-\u17B3] - | [\u17D7] - | [\u17DB-\u17DC] - | [\u1820-\u1877] - | [\u1880-\u1884] - | [\u1887-\u18A8] - | [\u18AA] - | [\u18B0-\u18F5] - | [\u1900-\u191E] - | [\u1950-\u196D] - | [\u1970-\u1974] - | [\u1980-\u19AB] - | [\u19B0-\u19C9] - | [\u1A00-\u1A16] - | [\u1A20-\u1A54] - | [\u1AA7] - | [\u1B05-\u1B33] - | [\u1B45-\u1B4B] - | [\u1B83-\u1BA0] - | [\u1BAE-\u1BAF] - | [\u1BBA-\u1BE5] - | [\u1C00-\u1C23] - | [\u1C4D-\u1C4F] - | [\u1C5A-\u1C7D] - | [\u1C80-\u1C88] - | [\u1CE9-\u1CEC] - | [\u1CEE-\u1CF1] - | [\u1CF5-\u1CF6] - | [\u1D00-\u1DBF] - | [\u1E00-\u1F15] - | [\u1F18-\u1F1D] - | [\u1F20-\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] - | [\u203F-\u2040] - | [\u2054] - | [\u2071] - | [\u207F] - | [\u2090-\u209C] - | [\u20A0-\u20BF] - | [\u2102] - | [\u2107] - | [\u210A-\u2113] - | [\u2115] - | [\u2119-\u211D] - | [\u2124] - | [\u2126] - | [\u2128] - | [\u212A-\u212D] - | [\u212F-\u2139] - | [\u213C-\u213F] - | [\u2145-\u2149] - | [\u214E] - | [\u2160-\u2188] - | [\u2C00-\u2C2E] - | [\u2C30-\u2C5E] - | [\u2C60-\u2CE4] - | [\u2CEB-\u2CEE] - | [\u2CF2-\u2CF3] - | [\u2D00-\u2D25] - | [\u2D27] - | [\u2D2D] - | [\u2D30-\u2D67] - | [\u2D6F] - | [\u2D80-\u2D96] - | [\u2DA0-\u2DA6] - | [\u2DA8-\u2DAE] - | [\u2DB0-\u2DB6] - | [\u2DB8-\u2DBE] - | [\u2DC0-\u2DC6] - | [\u2DC8-\u2DCE] - | [\u2DD0-\u2DD6] - | [\u2DD8-\u2DDE] - | [\u2E2F] - | [\u3005-\u3007] - | [\u3021-\u3029] - | [\u3031-\u3035] - | [\u3038-\u303C] - | [\u3041-\u3096] - | [\u309D-\u309F] - | [\u30A1-\u30FA] - | [\u30FC-\u30FF] - | [\u3105-\u312E] - | [\u3131-\u318E] - | [\u31A0-\u31BA] - | [\u31F0-\u31FF] - | [\u3400-\u4DB5] - | [\u4E00-\u9FEA] - | [\uA000-\uA48C] - | [\uA4D0-\uA4FD] - | [\uA500-\uA60C] - | [\uA610-\uA61F] - | [\uA62A-\uA62B] - | [\uA640-\uA66E] - | [\uA67F-\uA69D] - | [\uA6A0-\uA6EF] - | [\uA717-\uA71F] - | [\uA722-\uA788] - | [\uA78B-\uA7AE] - | [\uA7B0-\uA7B7] - | [\uA7F7-\uA801] - | [\uA803-\uA805] - | [\uA807-\uA80A] - | [\uA80C-\uA822] - | [\uA838] - | [\uA840-\uA873] - | [\uA882-\uA8B3] - | [\uA8F2-\uA8F7] - | [\uA8FB] - | [\uA8FD] - | [\uA90A-\uA925] - | [\uA930-\uA946] - | [\uA960-\uA97C] - | [\uA984-\uA9B2] - | [\uA9CF] - | [\uA9E0-\uA9E4] - | [\uA9E6-\uA9EF] - | [\uA9FA-\uA9FE] - | [\uAA00-\uAA28] - | [\uAA40-\uAA42] - | [\uAA44-\uAA4B] - | [\uAA60-\uAA76] - | [\uAA7A] - | [\uAA7E-\uAAAF] - | [\uAAB1] - | [\uAAB5-\uAAB6] - | [\uAAB9-\uAABD] - | [\uAAC0] - | [\uAAC2] - | [\uAADB-\uAADD] - | [\uAAE0-\uAAEA] - | [\uAAF2-\uAAF4] - | [\uAB01-\uAB06] - | [\uAB09-\uAB0E] - | [\uAB11-\uAB16] - | [\uAB20-\uAB26] - | [\uAB28-\uAB2E] - | [\uAB30-\uAB5A] - | [\uAB5C-\uAB65] - | [\uAB70-\uABE2] - | [\uAC00-\uD7A3] - | [\uD7B0-\uD7C6] - | [\uD7CB-\uD7FB] - | [\uF900-\uFA6D] - | [\uFA70-\uFAD9] - | [\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-\uFDFC] - | [\uFE33-\uFE34] - | [\uFE4D-\uFE4F] - | [\uFE69] - | [\uFE70-\uFE74] - | [\uFE76-\uFEFC] - | [\uFF04] - | [\uFF21-\uFF3A] - | [\uFF3F] - | [\uFF41-\uFF5A] - | [\uFF66-\uFFBE] - | [\uFFC2-\uFFC7] - | [\uFFCA-\uFFCF] - | [\uFFD2-\uFFD7] - | [\uFFDA-\uFFDC] - | [\uFFE0-\uFFE1] - | [\uFFE5-\uFFE6] - ; - -fragment IdentifierPart - : IdentifierStart - | [\u0030-\u0039] - | [\u007F-\u009F] - | [\u00AD] - | [\u0300-\u036F] - | [\u0483-\u0487] - | [\u0591-\u05BD] - | [\u05BF] - | [\u05C1-\u05C2] - | [\u05C4-\u05C5] - | [\u05C7] - | [\u0600-\u0605] - | [\u0610-\u061A] - | [\u061C] - | [\u064B-\u0669] - | [\u0670] - | [\u06D6-\u06DD] - | [\u06DF-\u06E4] - | [\u06E7-\u06E8] - | [\u06EA-\u06ED] - | [\u06F0-\u06F9] - | [\u070F] - | [\u0711] - | [\u0730-\u074A] - | [\u07A6-\u07B0] - | [\u07C0-\u07C9] - | [\u07EB-\u07F3] - | [\u0816-\u0819] - | [\u081B-\u0823] - | [\u0825-\u0827] - | [\u0829-\u082D] - | [\u0859-\u085B] - | [\u08D4-\u0903] - | [\u093A-\u093C] - | [\u093E-\u094F] - | [\u0951-\u0957] - | [\u0962-\u0963] - | [\u0966-\u096F] - | [\u0981-\u0983] - | [\u09BC] - | [\u09BE-\u09C4] - | [\u09C7-\u09C8] - | [\u09CB-\u09CD] - | [\u09D7] - | [\u09E2-\u09E3] - | [\u09E6-\u09EF] - | [\u0A01-\u0A03] - | [\u0A3C] - | [\u0A3E-\u0A42] - | [\u0A47-\u0A48] - | [\u0A4B-\u0A4D] - | [\u0A51] - | [\u0A66-\u0A71] - | [\u0A75] - | [\u0A81-\u0A83] - | [\u0ABC] - | [\u0ABE-\u0AC5] - | [\u0AC7-\u0AC9] - | [\u0ACB-\u0ACD] - | [\u0AE2-\u0AE3] - | [\u0AE6-\u0AEF] - | [\u0AFA-\u0AFF] - | [\u0B01-\u0B03] - | [\u0B3C] - | [\u0B3E-\u0B44] - | [\u0B47-\u0B48] - | [\u0B4B-\u0B4D] - | [\u0B56-\u0B57] - | [\u0B62-\u0B63] - | [\u0B66-\u0B6F] - | [\u0B82] - | [\u0BBE-\u0BC2] - | [\u0BC6-\u0BC8] - | [\u0BCA-\u0BCD] - | [\u0BD7] - | [\u0BE6-\u0BEF] - | [\u0C00-\u0C03] - | [\u0C3E-\u0C44] - | [\u0C46-\u0C48] - | [\u0C4A-\u0C4D] - | [\u0C55-\u0C56] - | [\u0C62-\u0C63] - | [\u0C66-\u0C6F] - | [\u0C81-\u0C83] - | [\u0CBC] - | [\u0CBE-\u0CC4] - | [\u0CC6-\u0CC8] - | [\u0CCA-\u0CCD] - | [\u0CD5-\u0CD6] - | [\u0CE2-\u0CE3] - | [\u0CE6-\u0CEF] - | [\u0D00-\u0D03] - | [\u0D3B-\u0D3C] - | [\u0D3E-\u0D44] - | [\u0D46-\u0D48] - | [\u0D4A-\u0D4D] - | [\u0D57] - | [\u0D62-\u0D63] - | [\u0D66-\u0D6F] - | [\u0D82-\u0D83] - | [\u0DCA] - | [\u0DCF-\u0DD4] - | [\u0DD6] - | [\u0DD8-\u0DDF] - | [\u0DE6-\u0DEF] - | [\u0DF2-\u0DF3] - | [\u0E31] - | [\u0E34-\u0E3A] - | [\u0E47-\u0E4E] - | [\u0E50-\u0E59] - | [\u0EB1] - | [\u0EB4-\u0EB9] - | [\u0EBB-\u0EBC] - | [\u0EC8-\u0ECD] - | [\u0ED0-\u0ED9] - | [\u0F18-\u0F19] - | [\u0F20-\u0F29] - | [\u0F35] - | [\u0F37] - | [\u0F39] - | [\u0F3E-\u0F3F] - | [\u0F71-\u0F84] - | [\u0F86-\u0F87] - | [\u0F8D-\u0F97] - | [\u0F99-\u0FBC] - | [\u0FC6] - | [\u102B-\u103E] - | [\u1040-\u1049] - | [\u1056-\u1059] - | [\u105E-\u1060] - | [\u1062-\u1064] - | [\u1067-\u106D] - | [\u1071-\u1074] - | [\u1082-\u108D] - | [\u108F-\u109D] - | [\u135D-\u135F] - | [\u1712-\u1714] - | [\u1732-\u1734] - | [\u1752-\u1753] - | [\u1772-\u1773] - | [\u17B4-\u17D3] - | [\u17DD] - | [\u17E0-\u17E9] - | [\u180B-\u180E] - | [\u1810-\u1819] - | [\u1885-\u1886] - | [\u18A9] - | [\u1920-\u192B] - | [\u1930-\u193B] - | [\u1946-\u194F] - | [\u19D0-\u19D9] - | [\u1A17-\u1A1B] - | [\u1A55-\u1A5E] - | [\u1A60-\u1A7C] - | [\u1A7F-\u1A89] - | [\u1A90-\u1A99] - | [\u1AB0-\u1ABD] - | [\u1B00-\u1B04] - | [\u1B34-\u1B44] - | [\u1B50-\u1B59] - | [\u1B6B-\u1B73] - | [\u1B80-\u1B82] - | [\u1BA1-\u1BAD] - | [\u1BB0-\u1BB9] - | [\u1BE6-\u1BF3] - | [\u1C24-\u1C37] - | [\u1C40-\u1C49] - | [\u1C50-\u1C59] - | [\u1CD0-\u1CD2] - | [\u1CD4-\u1CE8] - | [\u1CED] - | [\u1CF2-\u1CF4] - | [\u1CF7-\u1CF9] - | [\u1DC0-\u1DF9] - | [\u1DFB-\u1DFF] - | [\u200B-\u200F] - | [\u202A-\u202E] - | [\u2060-\u2064] - | [\u2066-\u206F] - | [\u20D0-\u20DC] - | [\u20E1] - | [\u20E5-\u20F0] - | [\u2CEF-\u2CF1] - | [\u2D7F] - | [\u2DE0-\u2DFF] - | [\u302A-\u302F] - | [\u3099-\u309A] - | [\uA620-\uA629] - | [\uA66F] - | [\uA674-\uA67D] - | [\uA69E-\uA69F] - | [\uA6F0-\uA6F1] - | [\uA802] - | [\uA806] - | [\uA80B] - | [\uA823-\uA827] - | [\uA880-\uA881] - | [\uA8B4-\uA8C5] - | [\uA8D0-\uA8D9] - | [\uA8E0-\uA8F1] - | [\uA900-\uA909] - | [\uA926-\uA92D] - | [\uA947-\uA953] - | [\uA980-\uA983] - | [\uA9B3-\uA9C0] - | [\uA9D0-\uA9D9] - | [\uA9E5] - | [\uA9F0-\uA9F9] - | [\uAA29-\uAA36] - | [\uAA43] - | [\uAA4C-\uAA4D] - | [\uAA50-\uAA59] - | [\uAA7B-\uAA7D] - | [\uAAB0] - | [\uAAB2-\uAAB4] - | [\uAAB7-\uAAB8] - | [\uAABE-\uAABF] - | [\uAAC1] - | [\uAAEB-\uAAEF] - | [\uAAF5-\uAAF6] - | [\uABE3-\uABEA] - | [\uABEC-\uABED] - | [\uABF0-\uABF9] - | [\uFB1E] - | [\uFE00-\uFE0F] - | [\uFE20-\uFE2F] - | [\uFEFF] - | [\uFF10-\uFF19] - | [\uFFF9-\uFFFB] - ; +fragment IdentifierStart: + [\u0024] + | [\u0041-\u005A] + | [\u005F] + | [\u0061-\u007A] + | [\u00A2-\u00A5] + | [\u00AA] + | [\u00B5] + | [\u00BA] + | [\u00C0-\u00D6] + | [\u00D8-\u00F6] + | [\u00F8-\u02C1] + | [\u02C6-\u02D1] + | [\u02E0-\u02E4] + | [\u02EC] + | [\u02EE] + | [\u0370-\u0374] + | [\u0376-\u0377] + | [\u037A-\u037D] + | [\u037F] + | [\u0386] + | [\u0388-\u038A] + | [\u038C] + | [\u038E-\u03A1] + | [\u03A3-\u03F5] + | [\u03F7-\u0481] + | [\u048A-\u052F] + | [\u0531-\u0556] + | [\u0559] + | [\u0561-\u0587] + | [\u058F] + | [\u05D0-\u05EA] + | [\u05F0-\u05F2] + | [\u060B] + | [\u0620-\u064A] + | [\u066E-\u066F] + | [\u0671-\u06D3] + | [\u06D5] + | [\u06E5-\u06E6] + | [\u06EE-\u06EF] + | [\u06FA-\u06FC] + | [\u06FF] + | [\u0710] + | [\u0712-\u072F] + | [\u074D-\u07A5] + | [\u07B1] + | [\u07CA-\u07EA] + | [\u07F4-\u07F5] + | [\u07FA] + | [\u0800-\u0815] + | [\u081A] + | [\u0824] + | [\u0828] + | [\u0840-\u0858] + | [\u0860-\u086A] + | [\u08A0-\u08B4] + | [\u08B6-\u08BD] + | [\u0904-\u0939] + | [\u093D] + | [\u0950] + | [\u0958-\u0961] + | [\u0971-\u0980] + | [\u0985-\u098C] + | [\u098F-\u0990] + | [\u0993-\u09A8] + | [\u09AA-\u09B0] + | [\u09B2] + | [\u09B6-\u09B9] + | [\u09BD] + | [\u09CE] + | [\u09DC-\u09DD] + | [\u09DF-\u09E1] + | [\u09F0-\u09F3] + | [\u09FB-\u09FC] + | [\u0A05-\u0A0A] + | [\u0A0F-\u0A10] + | [\u0A13-\u0A28] + | [\u0A2A-\u0A30] + | [\u0A32-\u0A33] + | [\u0A35-\u0A36] + | [\u0A38-\u0A39] + | [\u0A59-\u0A5C] + | [\u0A5E] + | [\u0A72-\u0A74] + | [\u0A85-\u0A8D] + | [\u0A8F-\u0A91] + | [\u0A93-\u0AA8] + | [\u0AAA-\u0AB0] + | [\u0AB2-\u0AB3] + | [\u0AB5-\u0AB9] + | [\u0ABD] + | [\u0AD0] + | [\u0AE0-\u0AE1] + | [\u0AF1] + | [\u0AF9] + | [\u0B05-\u0B0C] + | [\u0B0F-\u0B10] + | [\u0B13-\u0B28] + | [\u0B2A-\u0B30] + | [\u0B32-\u0B33] + | [\u0B35-\u0B39] + | [\u0B3D] + | [\u0B5C-\u0B5D] + | [\u0B5F-\u0B61] + | [\u0B71] + | [\u0B83] + | [\u0B85-\u0B8A] + | [\u0B8E-\u0B90] + | [\u0B92-\u0B95] + | [\u0B99-\u0B9A] + | [\u0B9C] + | [\u0B9E-\u0B9F] + | [\u0BA3-\u0BA4] + | [\u0BA8-\u0BAA] + | [\u0BAE-\u0BB9] + | [\u0BD0] + | [\u0BF9] + | [\u0C05-\u0C0C] + | [\u0C0E-\u0C10] + | [\u0C12-\u0C28] + | [\u0C2A-\u0C39] + | [\u0C3D] + | [\u0C58-\u0C5A] + | [\u0C60-\u0C61] + | [\u0C80] + | [\u0C85-\u0C8C] + | [\u0C8E-\u0C90] + | [\u0C92-\u0CA8] + | [\u0CAA-\u0CB3] + | [\u0CB5-\u0CB9] + | [\u0CBD] + | [\u0CDE] + | [\u0CE0-\u0CE1] + | [\u0CF1-\u0CF2] + | [\u0D05-\u0D0C] + | [\u0D0E-\u0D10] + | [\u0D12-\u0D3A] + | [\u0D3D] + | [\u0D4E] + | [\u0D54-\u0D56] + | [\u0D5F-\u0D61] + | [\u0D7A-\u0D7F] + | [\u0D85-\u0D96] + | [\u0D9A-\u0DB1] + | [\u0DB3-\u0DBB] + | [\u0DBD] + | [\u0DC0-\u0DC6] + | [\u0E01-\u0E30] + | [\u0E32-\u0E33] + | [\u0E3F-\u0E46] + | [\u0E81-\u0E82] + | [\u0E84] + | [\u0E87-\u0E88] + | [\u0E8A] + | [\u0E8D] + | [\u0E94-\u0E97] + | [\u0E99-\u0E9F] + | [\u0EA1-\u0EA3] + | [\u0EA5] + | [\u0EA7] + | [\u0EAA-\u0EAB] + | [\u0EAD-\u0EB0] + | [\u0EB2-\u0EB3] + | [\u0EBD] + | [\u0EC0-\u0EC4] + | [\u0EC6] + | [\u0EDC-\u0EDF] + | [\u0F00] + | [\u0F40-\u0F47] + | [\u0F49-\u0F6C] + | [\u0F88-\u0F8C] + | [\u1000-\u102A] + | [\u103F] + | [\u1050-\u1055] + | [\u105A-\u105D] + | [\u1061] + | [\u1065-\u1066] + | [\u106E-\u1070] + | [\u1075-\u1081] + | [\u108E] + | [\u10A0-\u10C5] + | [\u10C7] + | [\u10CD] + | [\u10D0-\u10FA] + | [\u10FC-\u1248] + | [\u124A-\u124D] + | [\u1250-\u1256] + | [\u1258] + | [\u125A-\u125D] + | [\u1260-\u1288] + | [\u128A-\u128D] + | [\u1290-\u12B0] + | [\u12B2-\u12B5] + | [\u12B8-\u12BE] + | [\u12C0] + | [\u12C2-\u12C5] + | [\u12C8-\u12D6] + | [\u12D8-\u1310] + | [\u1312-\u1315] + | [\u1318-\u135A] + | [\u1380-\u138F] + | [\u13A0-\u13F5] + | [\u13F8-\u13FD] + | [\u1401-\u166C] + | [\u166F-\u167F] + | [\u1681-\u169A] + | [\u16A0-\u16EA] + | [\u16EE-\u16F8] + | [\u1700-\u170C] + | [\u170E-\u1711] + | [\u1720-\u1731] + | [\u1740-\u1751] + | [\u1760-\u176C] + | [\u176E-\u1770] + | [\u1780-\u17B3] + | [\u17D7] + | [\u17DB-\u17DC] + | [\u1820-\u1877] + | [\u1880-\u1884] + | [\u1887-\u18A8] + | [\u18AA] + | [\u18B0-\u18F5] + | [\u1900-\u191E] + | [\u1950-\u196D] + | [\u1970-\u1974] + | [\u1980-\u19AB] + | [\u19B0-\u19C9] + | [\u1A00-\u1A16] + | [\u1A20-\u1A54] + | [\u1AA7] + | [\u1B05-\u1B33] + | [\u1B45-\u1B4B] + | [\u1B83-\u1BA0] + | [\u1BAE-\u1BAF] + | [\u1BBA-\u1BE5] + | [\u1C00-\u1C23] + | [\u1C4D-\u1C4F] + | [\u1C5A-\u1C7D] + | [\u1C80-\u1C88] + | [\u1CE9-\u1CEC] + | [\u1CEE-\u1CF1] + | [\u1CF5-\u1CF6] + | [\u1D00-\u1DBF] + | [\u1E00-\u1F15] + | [\u1F18-\u1F1D] + | [\u1F20-\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] + | [\u203F-\u2040] + | [\u2054] + | [\u2071] + | [\u207F] + | [\u2090-\u209C] + | [\u20A0-\u20BF] + | [\u2102] + | [\u2107] + | [\u210A-\u2113] + | [\u2115] + | [\u2119-\u211D] + | [\u2124] + | [\u2126] + | [\u2128] + | [\u212A-\u212D] + | [\u212F-\u2139] + | [\u213C-\u213F] + | [\u2145-\u2149] + | [\u214E] + | [\u2160-\u2188] + | [\u2C00-\u2C2E] + | [\u2C30-\u2C5E] + | [\u2C60-\u2CE4] + | [\u2CEB-\u2CEE] + | [\u2CF2-\u2CF3] + | [\u2D00-\u2D25] + | [\u2D27] + | [\u2D2D] + | [\u2D30-\u2D67] + | [\u2D6F] + | [\u2D80-\u2D96] + | [\u2DA0-\u2DA6] + | [\u2DA8-\u2DAE] + | [\u2DB0-\u2DB6] + | [\u2DB8-\u2DBE] + | [\u2DC0-\u2DC6] + | [\u2DC8-\u2DCE] + | [\u2DD0-\u2DD6] + | [\u2DD8-\u2DDE] + | [\u2E2F] + | [\u3005-\u3007] + | [\u3021-\u3029] + | [\u3031-\u3035] + | [\u3038-\u303C] + | [\u3041-\u3096] + | [\u309D-\u309F] + | [\u30A1-\u30FA] + | [\u30FC-\u30FF] + | [\u3105-\u312E] + | [\u3131-\u318E] + | [\u31A0-\u31BA] + | [\u31F0-\u31FF] + | [\u3400-\u4DB5] + | [\u4E00-\u9FEA] + | [\uA000-\uA48C] + | [\uA4D0-\uA4FD] + | [\uA500-\uA60C] + | [\uA610-\uA61F] + | [\uA62A-\uA62B] + | [\uA640-\uA66E] + | [\uA67F-\uA69D] + | [\uA6A0-\uA6EF] + | [\uA717-\uA71F] + | [\uA722-\uA788] + | [\uA78B-\uA7AE] + | [\uA7B0-\uA7B7] + | [\uA7F7-\uA801] + | [\uA803-\uA805] + | [\uA807-\uA80A] + | [\uA80C-\uA822] + | [\uA838] + | [\uA840-\uA873] + | [\uA882-\uA8B3] + | [\uA8F2-\uA8F7] + | [\uA8FB] + | [\uA8FD] + | [\uA90A-\uA925] + | [\uA930-\uA946] + | [\uA960-\uA97C] + | [\uA984-\uA9B2] + | [\uA9CF] + | [\uA9E0-\uA9E4] + | [\uA9E6-\uA9EF] + | [\uA9FA-\uA9FE] + | [\uAA00-\uAA28] + | [\uAA40-\uAA42] + | [\uAA44-\uAA4B] + | [\uAA60-\uAA76] + | [\uAA7A] + | [\uAA7E-\uAAAF] + | [\uAAB1] + | [\uAAB5-\uAAB6] + | [\uAAB9-\uAABD] + | [\uAAC0] + | [\uAAC2] + | [\uAADB-\uAADD] + | [\uAAE0-\uAAEA] + | [\uAAF2-\uAAF4] + | [\uAB01-\uAB06] + | [\uAB09-\uAB0E] + | [\uAB11-\uAB16] + | [\uAB20-\uAB26] + | [\uAB28-\uAB2E] + | [\uAB30-\uAB5A] + | [\uAB5C-\uAB65] + | [\uAB70-\uABE2] + | [\uAC00-\uD7A3] + | [\uD7B0-\uD7C6] + | [\uD7CB-\uD7FB] + | [\uF900-\uFA6D] + | [\uFA70-\uFAD9] + | [\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-\uFDFC] + | [\uFE33-\uFE34] + | [\uFE4D-\uFE4F] + | [\uFE69] + | [\uFE70-\uFE74] + | [\uFE76-\uFEFC] + | [\uFF04] + | [\uFF21-\uFF3A] + | [\uFF3F] + | [\uFF41-\uFF5A] + | [\uFF66-\uFFBE] + | [\uFFC2-\uFFC7] + | [\uFFCA-\uFFCF] + | [\uFFD2-\uFFD7] + | [\uFFDA-\uFFDC] + | [\uFFE0-\uFFE1] + | [\uFFE5-\uFFE6] +; + +fragment IdentifierPart: + IdentifierStart + | [\u0030-\u0039] + | [\u007F-\u009F] + | [\u00AD] + | [\u0300-\u036F] + | [\u0483-\u0487] + | [\u0591-\u05BD] + | [\u05BF] + | [\u05C1-\u05C2] + | [\u05C4-\u05C5] + | [\u05C7] + | [\u0600-\u0605] + | [\u0610-\u061A] + | [\u061C] + | [\u064B-\u0669] + | [\u0670] + | [\u06D6-\u06DD] + | [\u06DF-\u06E4] + | [\u06E7-\u06E8] + | [\u06EA-\u06ED] + | [\u06F0-\u06F9] + | [\u070F] + | [\u0711] + | [\u0730-\u074A] + | [\u07A6-\u07B0] + | [\u07C0-\u07C9] + | [\u07EB-\u07F3] + | [\u0816-\u0819] + | [\u081B-\u0823] + | [\u0825-\u0827] + | [\u0829-\u082D] + | [\u0859-\u085B] + | [\u08D4-\u0903] + | [\u093A-\u093C] + | [\u093E-\u094F] + | [\u0951-\u0957] + | [\u0962-\u0963] + | [\u0966-\u096F] + | [\u0981-\u0983] + | [\u09BC] + | [\u09BE-\u09C4] + | [\u09C7-\u09C8] + | [\u09CB-\u09CD] + | [\u09D7] + | [\u09E2-\u09E3] + | [\u09E6-\u09EF] + | [\u0A01-\u0A03] + | [\u0A3C] + | [\u0A3E-\u0A42] + | [\u0A47-\u0A48] + | [\u0A4B-\u0A4D] + | [\u0A51] + | [\u0A66-\u0A71] + | [\u0A75] + | [\u0A81-\u0A83] + | [\u0ABC] + | [\u0ABE-\u0AC5] + | [\u0AC7-\u0AC9] + | [\u0ACB-\u0ACD] + | [\u0AE2-\u0AE3] + | [\u0AE6-\u0AEF] + | [\u0AFA-\u0AFF] + | [\u0B01-\u0B03] + | [\u0B3C] + | [\u0B3E-\u0B44] + | [\u0B47-\u0B48] + | [\u0B4B-\u0B4D] + | [\u0B56-\u0B57] + | [\u0B62-\u0B63] + | [\u0B66-\u0B6F] + | [\u0B82] + | [\u0BBE-\u0BC2] + | [\u0BC6-\u0BC8] + | [\u0BCA-\u0BCD] + | [\u0BD7] + | [\u0BE6-\u0BEF] + | [\u0C00-\u0C03] + | [\u0C3E-\u0C44] + | [\u0C46-\u0C48] + | [\u0C4A-\u0C4D] + | [\u0C55-\u0C56] + | [\u0C62-\u0C63] + | [\u0C66-\u0C6F] + | [\u0C81-\u0C83] + | [\u0CBC] + | [\u0CBE-\u0CC4] + | [\u0CC6-\u0CC8] + | [\u0CCA-\u0CCD] + | [\u0CD5-\u0CD6] + | [\u0CE2-\u0CE3] + | [\u0CE6-\u0CEF] + | [\u0D00-\u0D03] + | [\u0D3B-\u0D3C] + | [\u0D3E-\u0D44] + | [\u0D46-\u0D48] + | [\u0D4A-\u0D4D] + | [\u0D57] + | [\u0D62-\u0D63] + | [\u0D66-\u0D6F] + | [\u0D82-\u0D83] + | [\u0DCA] + | [\u0DCF-\u0DD4] + | [\u0DD6] + | [\u0DD8-\u0DDF] + | [\u0DE6-\u0DEF] + | [\u0DF2-\u0DF3] + | [\u0E31] + | [\u0E34-\u0E3A] + | [\u0E47-\u0E4E] + | [\u0E50-\u0E59] + | [\u0EB1] + | [\u0EB4-\u0EB9] + | [\u0EBB-\u0EBC] + | [\u0EC8-\u0ECD] + | [\u0ED0-\u0ED9] + | [\u0F18-\u0F19] + | [\u0F20-\u0F29] + | [\u0F35] + | [\u0F37] + | [\u0F39] + | [\u0F3E-\u0F3F] + | [\u0F71-\u0F84] + | [\u0F86-\u0F87] + | [\u0F8D-\u0F97] + | [\u0F99-\u0FBC] + | [\u0FC6] + | [\u102B-\u103E] + | [\u1040-\u1049] + | [\u1056-\u1059] + | [\u105E-\u1060] + | [\u1062-\u1064] + | [\u1067-\u106D] + | [\u1071-\u1074] + | [\u1082-\u108D] + | [\u108F-\u109D] + | [\u135D-\u135F] + | [\u1712-\u1714] + | [\u1732-\u1734] + | [\u1752-\u1753] + | [\u1772-\u1773] + | [\u17B4-\u17D3] + | [\u17DD] + | [\u17E0-\u17E9] + | [\u180B-\u180E] + | [\u1810-\u1819] + | [\u1885-\u1886] + | [\u18A9] + | [\u1920-\u192B] + | [\u1930-\u193B] + | [\u1946-\u194F] + | [\u19D0-\u19D9] + | [\u1A17-\u1A1B] + | [\u1A55-\u1A5E] + | [\u1A60-\u1A7C] + | [\u1A7F-\u1A89] + | [\u1A90-\u1A99] + | [\u1AB0-\u1ABD] + | [\u1B00-\u1B04] + | [\u1B34-\u1B44] + | [\u1B50-\u1B59] + | [\u1B6B-\u1B73] + | [\u1B80-\u1B82] + | [\u1BA1-\u1BAD] + | [\u1BB0-\u1BB9] + | [\u1BE6-\u1BF3] + | [\u1C24-\u1C37] + | [\u1C40-\u1C49] + | [\u1C50-\u1C59] + | [\u1CD0-\u1CD2] + | [\u1CD4-\u1CE8] + | [\u1CED] + | [\u1CF2-\u1CF4] + | [\u1CF7-\u1CF9] + | [\u1DC0-\u1DF9] + | [\u1DFB-\u1DFF] + | [\u200B-\u200F] + | [\u202A-\u202E] + | [\u2060-\u2064] + | [\u2066-\u206F] + | [\u20D0-\u20DC] + | [\u20E1] + | [\u20E5-\u20F0] + | [\u2CEF-\u2CF1] + | [\u2D7F] + | [\u2DE0-\u2DFF] + | [\u302A-\u302F] + | [\u3099-\u309A] + | [\uA620-\uA629] + | [\uA66F] + | [\uA674-\uA67D] + | [\uA69E-\uA69F] + | [\uA6F0-\uA6F1] + | [\uA802] + | [\uA806] + | [\uA80B] + | [\uA823-\uA827] + | [\uA880-\uA881] + | [\uA8B4-\uA8C5] + | [\uA8D0-\uA8D9] + | [\uA8E0-\uA8F1] + | [\uA900-\uA909] + | [\uA926-\uA92D] + | [\uA947-\uA953] + | [\uA980-\uA983] + | [\uA9B3-\uA9C0] + | [\uA9D0-\uA9D9] + | [\uA9E5] + | [\uA9F0-\uA9F9] + | [\uAA29-\uAA36] + | [\uAA43] + | [\uAA4C-\uAA4D] + | [\uAA50-\uAA59] + | [\uAA7B-\uAA7D] + | [\uAAB0] + | [\uAAB2-\uAAB4] + | [\uAAB7-\uAAB8] + | [\uAABE-\uAABF] + | [\uAAC1] + | [\uAAEB-\uAAEF] + | [\uAAF5-\uAAF6] + | [\uABE3-\uABEA] + | [\uABEC-\uABED] + | [\uABF0-\uABF9] + | [\uFB1E] + | [\uFE00-\uFE0F] + | [\uFE20-\uFE2F] + | [\uFEFF] + | [\uFF10-\uFF19] + | [\uFFF9-\uFFFB] +; // // Additional symbols not defined in the lexical specification // -AT : '@'; +AT : '@'; ELLIPSIS : '...'; // // Whitespace and comments // -WS : [ \t\r\n\u000C]+ -> skip - ; +WS: [ \t\r\n\u000C]+ -> skip; -COMMENT - : '/*' .*? '*/' -> skip - ; +COMMENT: '/*' .*? '*/' -> skip; -LINE_COMMENT - : '//' ~[\r\n]* -> skip - ; +LINE_COMMENT: '//' ~[\r\n]* -> skip; \ No newline at end of file diff --git a/java/java8/Java8Parser.g4 b/java/java8/Java8Parser.g4 index fd27496612..8b6b466152 100644 --- a/java/java8/Java8Parser.g4 +++ b/java/java8/Java8Parser.g4 @@ -51,1289 +51,1285 @@ /Users/parrt/antlr/code/grammars-v4/java8/./Test.java Total lexer+parser time 30844ms. */ + +// $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 Java8Parser; options { - tokenVocab=Java8Lexer; + tokenVocab = Java8Lexer; } + /* * Productions from §3 (Lexical Structure) */ literal - : IntegerLiteral - | FloatingPointLiteral - | BooleanLiteral - | CharacterLiteral - | StringLiteral - | NullLiteral - ; + : IntegerLiteral + | FloatingPointLiteral + | BooleanLiteral + | CharacterLiteral + | StringLiteral + | NullLiteral + ; /* * Productions from §4 (Types, Values, and Variables) */ primitiveType - : annotation* numericType - | annotation* 'boolean' - ; + : annotation* numericType + | annotation* 'boolean' + ; numericType - : integralType - | floatingPointType - ; + : integralType + | floatingPointType + ; integralType - : 'byte' - | 'short' - | 'int' - | 'long' - | 'char' - ; + : 'byte' + | 'short' + | 'int' + | 'long' + | 'char' + ; floatingPointType - : 'float' - | 'double' - ; + : 'float' + | 'double' + ; referenceType - : classOrInterfaceType - | typeVariable - | arrayType - ; + : classOrInterfaceType + | typeVariable + | arrayType + ; classOrInterfaceType - : ( classType_lfno_classOrInterfaceType - | interfaceType_lfno_classOrInterfaceType - ) - ( classType_lf_classOrInterfaceType - | interfaceType_lf_classOrInterfaceType - )* - ; + : (classType_lfno_classOrInterfaceType | interfaceType_lfno_classOrInterfaceType) ( + classType_lf_classOrInterfaceType + | interfaceType_lf_classOrInterfaceType + )* + ; classType - : annotation* Identifier typeArguments? - | classOrInterfaceType '.' annotation* Identifier typeArguments? - ; + : annotation* Identifier typeArguments? + | classOrInterfaceType '.' annotation* Identifier typeArguments? + ; classType_lf_classOrInterfaceType - : '.' annotation* Identifier typeArguments? - ; + : '.' annotation* Identifier typeArguments? + ; classType_lfno_classOrInterfaceType - : annotation* Identifier typeArguments? - ; + : annotation* Identifier typeArguments? + ; interfaceType - : classType - ; + : classType + ; interfaceType_lf_classOrInterfaceType - : classType_lf_classOrInterfaceType - ; + : classType_lf_classOrInterfaceType + ; interfaceType_lfno_classOrInterfaceType - : classType_lfno_classOrInterfaceType - ; + : classType_lfno_classOrInterfaceType + ; typeVariable - : annotation* Identifier - ; + : annotation* Identifier + ; arrayType - : primitiveType dims - | classOrInterfaceType dims - | typeVariable dims - ; + : primitiveType dims + | classOrInterfaceType dims + | typeVariable dims + ; dims - : annotation* '[' ']' (annotation* '[' ']')* - ; + : annotation* '[' ']' (annotation* '[' ']')* + ; typeParameter - : typeParameterModifier* Identifier typeBound? - ; + : typeParameterModifier* Identifier typeBound? + ; typeParameterModifier - : annotation - ; + : annotation + ; typeBound - : 'extends' typeVariable - | 'extends' classOrInterfaceType additionalBound* - ; + : 'extends' typeVariable + | 'extends' classOrInterfaceType additionalBound* + ; additionalBound - : '&' interfaceType - ; + : '&' interfaceType + ; typeArguments - : '<' typeArgumentList '>' - ; + : '<' typeArgumentList '>' + ; typeArgumentList - : typeArgument (',' typeArgument)* - ; + : typeArgument (',' typeArgument)* + ; typeArgument - : referenceType - | wildcard - ; + : referenceType + | wildcard + ; wildcard - : annotation* '?' wildcardBounds? - ; + : annotation* '?' wildcardBounds? + ; wildcardBounds - : 'extends' referenceType - | 'super' referenceType - ; + : 'extends' referenceType + | 'super' referenceType + ; /* * Productions from §6 (Names) */ packageName - : Identifier - | packageName '.' Identifier - ; + : Identifier + | packageName '.' Identifier + ; typeName - : Identifier - | packageOrTypeName '.' Identifier - ; + : Identifier + | packageOrTypeName '.' Identifier + ; packageOrTypeName - : Identifier - | packageOrTypeName '.' Identifier - ; + : Identifier + | packageOrTypeName '.' Identifier + ; expressionName - : Identifier - | ambiguousName '.' Identifier - ; + : Identifier + | ambiguousName '.' Identifier + ; methodName - : Identifier - ; + : Identifier + ; ambiguousName - : Identifier - | ambiguousName '.' Identifier - ; + : Identifier + | ambiguousName '.' Identifier + ; /* * Productions from §7 (Packages) */ compilationUnit - : packageDeclaration? importDeclaration* typeDeclaration* EOF - ; + : packageDeclaration? importDeclaration* typeDeclaration* EOF + ; packageDeclaration - : packageModifier* 'package' packageName ';' - ; + : packageModifier* 'package' packageName ';' + ; packageModifier - : annotation - ; + : annotation + ; importDeclaration - : singleTypeImportDeclaration - | typeImportOnDemandDeclaration - | singleStaticImportDeclaration - | staticImportOnDemandDeclaration - ; + : singleTypeImportDeclaration + | typeImportOnDemandDeclaration + | singleStaticImportDeclaration + | staticImportOnDemandDeclaration + ; singleTypeImportDeclaration - : 'import' typeName ';' - ; + : 'import' typeName ';' + ; typeImportOnDemandDeclaration - : 'import' packageOrTypeName '.' '*' ';' - ; + : 'import' packageOrTypeName '.' '*' ';' + ; singleStaticImportDeclaration - : 'import' 'static' typeName '.' Identifier ';' - ; + : 'import' 'static' typeName '.' Identifier ';' + ; staticImportOnDemandDeclaration - : 'import' 'static' typeName '.' '*' ';' - ; + : 'import' 'static' typeName '.' '*' ';' + ; typeDeclaration - : classDeclaration - | interfaceDeclaration - | ';' - ; + : classDeclaration + | interfaceDeclaration + | ';' + ; /* * Productions from §8 (Classes) */ classDeclaration - : normalClassDeclaration - | enumDeclaration - ; + : normalClassDeclaration + | enumDeclaration + ; normalClassDeclaration - : classModifier* 'class' Identifier typeParameters? superclass? superinterfaces? classBody - ; + : classModifier* 'class' Identifier typeParameters? superclass? superinterfaces? classBody + ; classModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'final' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'final' + | 'strictfp' + ; typeParameters - : '<' typeParameterList '>' - ; + : '<' typeParameterList '>' + ; typeParameterList - : typeParameter (',' typeParameter)* - ; + : typeParameter (',' typeParameter)* + ; superclass - : 'extends' classType - ; + : 'extends' classType + ; superinterfaces - : 'implements' interfaceTypeList - ; + : 'implements' interfaceTypeList + ; interfaceTypeList - : interfaceType (',' interfaceType)* - ; + : interfaceType (',' interfaceType)* + ; classBody - : '{' classBodyDeclaration* '}' - ; + : '{' classBodyDeclaration* '}' + ; classBodyDeclaration - : classMemberDeclaration - | instanceInitializer - | staticInitializer - | constructorDeclaration - ; + : classMemberDeclaration + | instanceInitializer + | staticInitializer + | constructorDeclaration + ; classMemberDeclaration - : fieldDeclaration - | methodDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; + : fieldDeclaration + | methodDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; fieldDeclaration - : fieldModifier* unannType variableDeclaratorList ';' - ; + : fieldModifier* unannType variableDeclaratorList ';' + ; fieldModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'static' - | 'final' - | 'transient' - | 'volatile' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'static' + | 'final' + | 'transient' + | 'volatile' + ; variableDeclaratorList - : variableDeclarator (',' variableDeclarator)* - ; + : variableDeclarator (',' variableDeclarator)* + ; variableDeclarator - : variableDeclaratorId ('=' variableInitializer)? - ; + : variableDeclaratorId ('=' variableInitializer)? + ; variableDeclaratorId - : Identifier dims? - ; + : Identifier dims? + ; variableInitializer - : expression - | arrayInitializer - ; + : expression + | arrayInitializer + ; unannType - : unannPrimitiveType - | unannReferenceType - ; + : unannPrimitiveType + | unannReferenceType + ; unannPrimitiveType - : numericType - | 'boolean' - ; + : numericType + | 'boolean' + ; unannReferenceType - : unannClassOrInterfaceType - | unannTypeVariable - | unannArrayType - ; + : unannClassOrInterfaceType + | unannTypeVariable + | unannArrayType + ; unannClassOrInterfaceType - : ( unannClassType_lfno_unannClassOrInterfaceType - | unannInterfaceType_lfno_unannClassOrInterfaceType - ) - ( unannClassType_lf_unannClassOrInterfaceType - | unannInterfaceType_lf_unannClassOrInterfaceType - )* - ; + : ( + unannClassType_lfno_unannClassOrInterfaceType + | unannInterfaceType_lfno_unannClassOrInterfaceType + ) ( + unannClassType_lf_unannClassOrInterfaceType + | unannInterfaceType_lf_unannClassOrInterfaceType + )* + ; unannClassType - : Identifier typeArguments? - | unannClassOrInterfaceType '.' annotation* Identifier typeArguments? - ; + : Identifier typeArguments? + | unannClassOrInterfaceType '.' annotation* Identifier typeArguments? + ; unannClassType_lf_unannClassOrInterfaceType - : '.' annotation* Identifier typeArguments? - ; + : '.' annotation* Identifier typeArguments? + ; unannClassType_lfno_unannClassOrInterfaceType - : Identifier typeArguments? - ; + : Identifier typeArguments? + ; unannInterfaceType - : unannClassType - ; + : unannClassType + ; unannInterfaceType_lf_unannClassOrInterfaceType - : unannClassType_lf_unannClassOrInterfaceType - ; + : unannClassType_lf_unannClassOrInterfaceType + ; unannInterfaceType_lfno_unannClassOrInterfaceType - : unannClassType_lfno_unannClassOrInterfaceType - ; + : unannClassType_lfno_unannClassOrInterfaceType + ; unannTypeVariable - : Identifier - ; + : Identifier + ; unannArrayType - : unannPrimitiveType dims - | unannClassOrInterfaceType dims - | unannTypeVariable dims - ; + : unannPrimitiveType dims + | unannClassOrInterfaceType dims + | unannTypeVariable dims + ; methodDeclaration - : methodModifier* methodHeader methodBody - ; + : methodModifier* methodHeader methodBody + ; methodModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'final' - | 'synchronized' - | 'native' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'final' + | 'synchronized' + | 'native' + | 'strictfp' + ; methodHeader - : result methodDeclarator throws_? - | typeParameters annotation* result methodDeclarator throws_? - ; + : result methodDeclarator throws_? + | typeParameters annotation* result methodDeclarator throws_? + ; result - : unannType - | 'void' - ; + : unannType + | 'void' + ; methodDeclarator - : Identifier '(' formalParameterList? ')' dims? - ; + : Identifier '(' formalParameterList? ')' dims? + ; formalParameterList - : receiverParameter - | formalParameters ',' lastFormalParameter - | lastFormalParameter - ; + : receiverParameter + | formalParameters ',' lastFormalParameter + | lastFormalParameter + ; formalParameters - : formalParameter (',' formalParameter)* - | receiverParameter (',' formalParameter)* - ; + : formalParameter (',' formalParameter)* + | receiverParameter (',' formalParameter)* + ; formalParameter - : variableModifier* unannType variableDeclaratorId - ; + : variableModifier* unannType variableDeclaratorId + ; variableModifier - : annotation - | 'final' - ; + : annotation + | 'final' + ; lastFormalParameter - : variableModifier* unannType annotation* '...' variableDeclaratorId - | formalParameter - ; + : variableModifier* unannType annotation* '...' variableDeclaratorId + | formalParameter + ; receiverParameter - : annotation* unannType (Identifier '.')? 'this' - ; + : annotation* unannType (Identifier '.')? 'this' + ; throws_ - : 'throws' exceptionTypeList - ; + : 'throws' exceptionTypeList + ; exceptionTypeList - : exceptionType (',' exceptionType)* - ; + : exceptionType (',' exceptionType)* + ; exceptionType - : classType - | typeVariable - ; + : classType + | typeVariable + ; methodBody - : block - | ';' - ; + : block + | ';' + ; instanceInitializer - : block - ; + : block + ; staticInitializer - : 'static' block - ; + : 'static' block + ; constructorDeclaration - : constructorModifier* constructorDeclarator throws_? constructorBody - ; + : constructorModifier* constructorDeclarator throws_? constructorBody + ; constructorModifier - : annotation - | 'public' - | 'protected' - | 'private' - ; + : annotation + | 'public' + | 'protected' + | 'private' + ; constructorDeclarator - : typeParameters? simpleTypeName '(' formalParameterList? ')' - ; + : typeParameters? simpleTypeName '(' formalParameterList? ')' + ; simpleTypeName - : Identifier - ; + : Identifier + ; constructorBody - : '{' explicitConstructorInvocation? blockStatements? '}' - ; + : '{' explicitConstructorInvocation? blockStatements? '}' + ; explicitConstructorInvocation - : typeArguments? 'this' '(' argumentList? ')' ';' - | typeArguments? 'super' '(' argumentList? ')' ';' - | expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';' - | primary '.' typeArguments? 'super' '(' argumentList? ')' ';' - ; + : typeArguments? 'this' '(' argumentList? ')' ';' + | typeArguments? 'super' '(' argumentList? ')' ';' + | expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';' + | primary '.' typeArguments? 'super' '(' argumentList? ')' ';' + ; enumDeclaration - : classModifier* 'enum' Identifier superinterfaces? enumBody - ; + : classModifier* 'enum' Identifier superinterfaces? enumBody + ; enumBody - : '{' enumConstantList? ','? enumBodyDeclarations? '}' - ; + : '{' enumConstantList? ','? enumBodyDeclarations? '}' + ; enumConstantList - : enumConstant (',' enumConstant)* - ; + : enumConstant (',' enumConstant)* + ; enumConstant - : enumConstantModifier* Identifier ('(' argumentList? ')')? classBody? - ; + : enumConstantModifier* Identifier ('(' argumentList? ')')? classBody? + ; enumConstantModifier - : annotation - ; + : annotation + ; enumBodyDeclarations - : ';' classBodyDeclaration* - ; + : ';' classBodyDeclaration* + ; /* * Productions from §9 (Interfaces) */ interfaceDeclaration - : normalInterfaceDeclaration - | annotationTypeDeclaration - ; + : normalInterfaceDeclaration + | annotationTypeDeclaration + ; normalInterfaceDeclaration - : interfaceModifier* 'interface' Identifier typeParameters? extendsInterfaces? interfaceBody - ; + : interfaceModifier* 'interface' Identifier typeParameters? extendsInterfaces? interfaceBody + ; interfaceModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'strictfp' + ; extendsInterfaces - : 'extends' interfaceTypeList - ; + : 'extends' interfaceTypeList + ; interfaceBody - : '{' interfaceMemberDeclaration* '}' - ; + : '{' interfaceMemberDeclaration* '}' + ; interfaceMemberDeclaration - : constantDeclaration - | interfaceMethodDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; + : constantDeclaration + | interfaceMethodDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; constantDeclaration - : constantModifier* unannType variableDeclaratorList ';' - ; + : constantModifier* unannType variableDeclaratorList ';' + ; constantModifier - : annotation - | 'public' - | 'static' - | 'final' - ; + : annotation + | 'public' + | 'static' + | 'final' + ; interfaceMethodDeclaration - : interfaceMethodModifier* methodHeader methodBody - ; + : interfaceMethodModifier* methodHeader methodBody + ; interfaceMethodModifier - : annotation - | 'public' - | 'abstract' - | 'default' - | 'static' - | 'strictfp' - ; + : annotation + | 'public' + | 'abstract' + | 'default' + | 'static' + | 'strictfp' + ; annotationTypeDeclaration - : interfaceModifier* '@' 'interface' Identifier annotationTypeBody - ; + : interfaceModifier* '@' 'interface' Identifier annotationTypeBody + ; annotationTypeBody - : '{' annotationTypeMemberDeclaration* '}' - ; + : '{' annotationTypeMemberDeclaration* '}' + ; annotationTypeMemberDeclaration - : annotationTypeElementDeclaration - | constantDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; + : annotationTypeElementDeclaration + | constantDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; annotationTypeElementDeclaration - : annotationTypeElementModifier* unannType Identifier '(' ')' dims? defaultValue? ';' - ; + : annotationTypeElementModifier* unannType Identifier '(' ')' dims? defaultValue? ';' + ; annotationTypeElementModifier - : annotation - | 'public' - | 'abstract' - ; + : annotation + | 'public' + | 'abstract' + ; defaultValue - : 'default' elementValue - ; + : 'default' elementValue + ; annotation - : normalAnnotation - | markerAnnotation - | singleElementAnnotation - ; + : normalAnnotation + | markerAnnotation + | singleElementAnnotation + ; normalAnnotation - : '@' typeName '(' elementValuePairList? ')' - ; + : '@' typeName '(' elementValuePairList? ')' + ; elementValuePairList - : elementValuePair (',' elementValuePair)* - ; + : elementValuePair (',' elementValuePair)* + ; elementValuePair - : Identifier '=' elementValue - ; + : Identifier '=' elementValue + ; elementValue - : conditionalExpression - | elementValueArrayInitializer - | annotation - ; + : conditionalExpression + | elementValueArrayInitializer + | annotation + ; elementValueArrayInitializer - : '{' elementValueList? ','? '}' - ; + : '{' elementValueList? ','? '}' + ; elementValueList - : elementValue (',' elementValue)* - ; + : elementValue (',' elementValue)* + ; markerAnnotation - : '@' typeName - ; + : '@' typeName + ; singleElementAnnotation - : '@' typeName '(' elementValue ')' - ; + : '@' typeName '(' elementValue ')' + ; /* * Productions from §10 (Arrays) */ arrayInitializer - : '{' variableInitializerList? ','? '}' - ; + : '{' variableInitializerList? ','? '}' + ; variableInitializerList - : variableInitializer (',' variableInitializer)* - ; + : variableInitializer (',' variableInitializer)* + ; /* * Productions from §14 (Blocks and Statements) */ block - : '{' blockStatements? '}' - ; + : '{' blockStatements? '}' + ; blockStatements - : blockStatement+ - ; + : blockStatement+ + ; blockStatement - : localVariableDeclarationStatement - | classDeclaration - | statement - ; + : localVariableDeclarationStatement + | classDeclaration + | statement + ; localVariableDeclarationStatement - : localVariableDeclaration ';' - ; + : localVariableDeclaration ';' + ; localVariableDeclaration - : variableModifier* unannType variableDeclaratorList - ; + : variableModifier* unannType variableDeclaratorList + ; statement - : statementWithoutTrailingSubstatement - | labeledStatement - | ifThenStatement - | ifThenElseStatement - | whileStatement - | forStatement - ; + : statementWithoutTrailingSubstatement + | labeledStatement + | ifThenStatement + | ifThenElseStatement + | whileStatement + | forStatement + ; statementNoShortIf - : statementWithoutTrailingSubstatement - | labeledStatementNoShortIf - | ifThenElseStatementNoShortIf - | whileStatementNoShortIf - | forStatementNoShortIf - ; + : statementWithoutTrailingSubstatement + | labeledStatementNoShortIf + | ifThenElseStatementNoShortIf + | whileStatementNoShortIf + | forStatementNoShortIf + ; statementWithoutTrailingSubstatement - : block - | emptyStatement_ - | expressionStatement - | assertStatement - | switchStatement - | doStatement - | breakStatement - | continueStatement - | returnStatement - | synchronizedStatement - | throwStatement - | tryStatement - ; + : block + | emptyStatement_ + | expressionStatement + | assertStatement + | switchStatement + | doStatement + | breakStatement + | continueStatement + | returnStatement + | synchronizedStatement + | throwStatement + | tryStatement + ; emptyStatement_ - : ';' - ; + : ';' + ; labeledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; labeledStatementNoShortIf - : Identifier ':' statementNoShortIf - ; + : Identifier ':' statementNoShortIf + ; expressionStatement - : statementExpression ';' - ; + : statementExpression ';' + ; statementExpression - : assignment - | preIncrementExpression - | preDecrementExpression - | postIncrementExpression - | postDecrementExpression - | methodInvocation - | classInstanceCreationExpression - ; + : assignment + | preIncrementExpression + | preDecrementExpression + | postIncrementExpression + | postDecrementExpression + | methodInvocation + | classInstanceCreationExpression + ; ifThenStatement - : 'if' '(' expression ')' statement - ; + : 'if' '(' expression ')' statement + ; ifThenElseStatement - : 'if' '(' expression ')' statementNoShortIf 'else' statement - ; + : 'if' '(' expression ')' statementNoShortIf 'else' statement + ; ifThenElseStatementNoShortIf - : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf - ; + : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf + ; assertStatement - : 'assert' expression ';' - | 'assert' expression ':' expression ';' - ; + : 'assert' expression ';' + | 'assert' expression ':' expression ';' + ; switchStatement - : 'switch' '(' expression ')' switchBlock - ; + : 'switch' '(' expression ')' switchBlock + ; switchBlock - : '{' switchBlockStatementGroup* switchLabel* '}' - ; + : '{' switchBlockStatementGroup* switchLabel* '}' + ; switchBlockStatementGroup - : switchLabels blockStatements - ; + : switchLabels blockStatements + ; switchLabels - : switchLabel switchLabel* - ; + : switchLabel switchLabel* + ; switchLabel - : 'case' constantExpression ':' - | 'case' enumConstantName ':' - | 'default' ':' - ; + : 'case' constantExpression ':' + | 'case' enumConstantName ':' + | 'default' ':' + ; enumConstantName - : Identifier - ; + : Identifier + ; whileStatement - : 'while' '(' expression ')' statement - ; + : 'while' '(' expression ')' statement + ; whileStatementNoShortIf - : 'while' '(' expression ')' statementNoShortIf - ; + : 'while' '(' expression ')' statementNoShortIf + ; doStatement - : 'do' statement 'while' '(' expression ')' ';' - ; + : 'do' statement 'while' '(' expression ')' ';' + ; forStatement - : basicForStatement - | enhancedForStatement - ; + : basicForStatement + | enhancedForStatement + ; forStatementNoShortIf - : basicForStatementNoShortIf - | enhancedForStatementNoShortIf - ; + : basicForStatementNoShortIf + | enhancedForStatementNoShortIf + ; basicForStatement - : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement - ; + : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement + ; basicForStatementNoShortIf - : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf - ; + : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf + ; forInit - : statementExpressionList - | localVariableDeclaration - ; + : statementExpressionList + | localVariableDeclaration + ; forUpdate - : statementExpressionList - ; + : statementExpressionList + ; statementExpressionList - : statementExpression (',' statementExpression)* - ; + : statementExpression (',' statementExpression)* + ; enhancedForStatement - : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement - ; + : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement + ; enhancedForStatementNoShortIf - : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf - ; + : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf + ; breakStatement - : 'break' Identifier? ';' - ; + : 'break' Identifier? ';' + ; continueStatement - : 'continue' Identifier? ';' - ; + : 'continue' Identifier? ';' + ; returnStatement - : 'return' expression? ';' - ; + : 'return' expression? ';' + ; throwStatement - : 'throw' expression ';' - ; + : 'throw' expression ';' + ; synchronizedStatement - : 'synchronized' '(' expression ')' block - ; + : 'synchronized' '(' expression ')' block + ; tryStatement - : 'try' block catches - | 'try' block catches? finally_ - | tryWithResourcesStatement - ; + : 'try' block catches + | 'try' block catches? finally_ + | tryWithResourcesStatement + ; catches - : catchClause catchClause* - ; + : catchClause catchClause* + ; catchClause - : 'catch' '(' catchFormalParameter ')' block - ; + : 'catch' '(' catchFormalParameter ')' block + ; catchFormalParameter - : variableModifier* catchType variableDeclaratorId - ; + : variableModifier* catchType variableDeclaratorId + ; catchType - : unannClassType ('|' classType)* - ; + : unannClassType ('|' classType)* + ; finally_ - : 'finally' block - ; + : 'finally' block + ; tryWithResourcesStatement - : 'try' resourceSpecification block catches? finally_? - ; + : 'try' resourceSpecification block catches? finally_? + ; resourceSpecification - : '(' resourceList ';'? ')' - ; + : '(' resourceList ';'? ')' + ; resourceList - : resource (';' resource)* - ; + : resource (';' resource)* + ; resource - : variableModifier* unannType variableDeclaratorId '=' expression - ; + : variableModifier* unannType variableDeclaratorId '=' expression + ; /* * Productions from §15 (Expressions) */ primary - : ( primaryNoNewArray_lfno_primary - | arrayCreationExpression - ) - primaryNoNewArray_lf_primary* - ; + : (primaryNoNewArray_lfno_primary | arrayCreationExpression) primaryNoNewArray_lf_primary* + ; primaryNoNewArray - : literal - | typeName ('[' ']')* '.' 'class' - | 'void' '.' 'class' - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression - | fieldAccess - | arrayAccess - | methodInvocation - | methodReference - ; + : literal + | typeName ('[' ']')* '.' 'class' + | 'void' '.' 'class' + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression + | fieldAccess + | arrayAccess + | methodInvocation + | methodReference + ; primaryNoNewArray_lf_arrayAccess - : - ; + : + ; primaryNoNewArray_lfno_arrayAccess - : literal - | typeName ('[' ']')* '.' 'class' - | 'void' '.' 'class' - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression - | fieldAccess - | methodInvocation - | methodReference - ; + : literal + | typeName ('[' ']')* '.' 'class' + | 'void' '.' 'class' + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression + | fieldAccess + | methodInvocation + | methodReference + ; primaryNoNewArray_lf_primary - : classInstanceCreationExpression_lf_primary - | fieldAccess_lf_primary - | arrayAccess_lf_primary - | methodInvocation_lf_primary - | methodReference_lf_primary - ; + : classInstanceCreationExpression_lf_primary + | fieldAccess_lf_primary + | arrayAccess_lf_primary + | methodInvocation_lf_primary + | methodReference_lf_primary + ; primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary - : - ; + : + ; primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary - : classInstanceCreationExpression_lf_primary - | fieldAccess_lf_primary - | methodInvocation_lf_primary - | methodReference_lf_primary - ; + : classInstanceCreationExpression_lf_primary + | fieldAccess_lf_primary + | methodInvocation_lf_primary + | methodReference_lf_primary + ; primaryNoNewArray_lfno_primary - : literal - | typeName ('[' ']')* '.' 'class' - | unannPrimitiveType ('[' ']')* '.' 'class' - | 'void' '.' 'class' - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression_lfno_primary - | fieldAccess_lfno_primary - | arrayAccess_lfno_primary - | methodInvocation_lfno_primary - | methodReference_lfno_primary - ; + : literal + | typeName ('[' ']')* '.' 'class' + | unannPrimitiveType ('[' ']')* '.' 'class' + | 'void' '.' 'class' + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression_lfno_primary + | fieldAccess_lfno_primary + | arrayAccess_lfno_primary + | methodInvocation_lfno_primary + | methodReference_lfno_primary + ; primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary - : - ; + : + ; primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary - : literal - | typeName ('[' ']')* '.' 'class' - | unannPrimitiveType ('[' ']')* '.' 'class' - | 'void' '.' 'class' - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression_lfno_primary - | fieldAccess_lfno_primary - | methodInvocation_lfno_primary - | methodReference_lfno_primary - ; + : literal + | typeName ('[' ']')* '.' 'class' + | unannPrimitiveType ('[' ']')* '.' 'class' + | 'void' '.' 'class' + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression_lfno_primary + | fieldAccess_lfno_primary + | methodInvocation_lfno_primary + | methodReference_lfno_primary + ; classInstanceCreationExpression - : 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - | expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - | primary '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - ; + : 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + | expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + | primary '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + ; classInstanceCreationExpression_lf_primary - : '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - ; + : '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + ; classInstanceCreationExpression_lfno_primary - : 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - | expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - ; + : 'new' typeArguments? annotation* Identifier ('.' annotation* Identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + | expressionName '.' 'new' typeArguments? annotation* Identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + ; typeArgumentsOrDiamond - : typeArguments - | '<' '>' - ; + : typeArguments + | '<' '>' + ; fieldAccess - : primary '.' Identifier - | 'super' '.' Identifier - | typeName '.' 'super' '.' Identifier - ; + : primary '.' Identifier + | 'super' '.' Identifier + | typeName '.' 'super' '.' Identifier + ; fieldAccess_lf_primary - : '.' Identifier - ; + : '.' Identifier + ; fieldAccess_lfno_primary - : 'super' '.' Identifier - | typeName '.' 'super' '.' Identifier - ; + : 'super' '.' Identifier + | typeName '.' 'super' '.' Identifier + ; arrayAccess - : ( expressionName '[' expression ']' - | primaryNoNewArray_lfno_arrayAccess '[' expression ']' - ) - ( primaryNoNewArray_lf_arrayAccess '[' expression ']' - )* - ; + : (expressionName '[' expression ']' | primaryNoNewArray_lfno_arrayAccess '[' expression ']') ( + primaryNoNewArray_lf_arrayAccess '[' expression ']' + )* + ; arrayAccess_lf_primary - : primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']' - ( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']' - )* - ; + : primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']' ( + primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']' + )* + ; arrayAccess_lfno_primary - : ( expressionName '[' expression ']' - | primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']' - ) - ( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']' - )* - ; + : ( + expressionName '[' expression ']' + | primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']' + ) (primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']')* + ; methodInvocation - : methodName '(' argumentList? ')' - | typeName '.' typeArguments? Identifier '(' argumentList? ')' - | expressionName '.' typeArguments? Identifier '(' argumentList? ')' - | primary '.' typeArguments? Identifier '(' argumentList? ')' - | 'super' '.' typeArguments? Identifier '(' argumentList? ')' - | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' - ; + : methodName '(' argumentList? ')' + | typeName '.' typeArguments? Identifier '(' argumentList? ')' + | expressionName '.' typeArguments? Identifier '(' argumentList? ')' + | primary '.' typeArguments? Identifier '(' argumentList? ')' + | 'super' '.' typeArguments? Identifier '(' argumentList? ')' + | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' + ; methodInvocation_lf_primary - : '.' typeArguments? Identifier '(' argumentList? ')' - ; + : '.' typeArguments? Identifier '(' argumentList? ')' + ; methodInvocation_lfno_primary - : methodName '(' argumentList? ')' - | typeName '.' typeArguments? Identifier '(' argumentList? ')' - | expressionName '.' typeArguments? Identifier '(' argumentList? ')' - | 'super' '.' typeArguments? Identifier '(' argumentList? ')' - | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' - ; + : methodName '(' argumentList? ')' + | typeName '.' typeArguments? Identifier '(' argumentList? ')' + | expressionName '.' typeArguments? Identifier '(' argumentList? ')' + | 'super' '.' typeArguments? Identifier '(' argumentList? ')' + | typeName '.' 'super' '.' typeArguments? Identifier '(' argumentList? ')' + ; argumentList - : expression (',' expression)* - ; + : expression (',' expression)* + ; methodReference - : expressionName '::' typeArguments? Identifier - | referenceType '::' typeArguments? Identifier - | primary '::' typeArguments? Identifier - | 'super' '::' typeArguments? Identifier - | typeName '.' 'super' '::' typeArguments? Identifier - | classType '::' typeArguments? 'new' - | arrayType '::' 'new' - ; + : expressionName '::' typeArguments? Identifier + | referenceType '::' typeArguments? Identifier + | primary '::' typeArguments? Identifier + | 'super' '::' typeArguments? Identifier + | typeName '.' 'super' '::' typeArguments? Identifier + | classType '::' typeArguments? 'new' + | arrayType '::' 'new' + ; methodReference_lf_primary - : '::' typeArguments? Identifier - ; + : '::' typeArguments? Identifier + ; methodReference_lfno_primary - : expressionName '::' typeArguments? Identifier - | referenceType '::' typeArguments? Identifier - | 'super' '::' typeArguments? Identifier - | typeName '.' 'super' '::' typeArguments? Identifier - | classType '::' typeArguments? 'new' - | arrayType '::' 'new' - ; + : expressionName '::' typeArguments? Identifier + | referenceType '::' typeArguments? Identifier + | 'super' '::' typeArguments? Identifier + | typeName '.' 'super' '::' typeArguments? Identifier + | classType '::' typeArguments? 'new' + | arrayType '::' 'new' + ; arrayCreationExpression - : 'new' primitiveType dimExprs dims? - | 'new' classOrInterfaceType dimExprs dims? - | 'new' primitiveType dims arrayInitializer - | 'new' classOrInterfaceType dims arrayInitializer - ; + : 'new' primitiveType dimExprs dims? + | 'new' classOrInterfaceType dimExprs dims? + | 'new' primitiveType dims arrayInitializer + | 'new' classOrInterfaceType dims arrayInitializer + ; dimExprs - : dimExpr dimExpr* - ; + : dimExpr dimExpr* + ; dimExpr - : annotation* '[' expression ']' - ; + : annotation* '[' expression ']' + ; constantExpression - : expression - ; + : expression + ; expression - : lambdaExpression - | assignmentExpression - ; + : lambdaExpression + | assignmentExpression + ; lambdaExpression - : lambdaParameters '->' lambdaBody - ; + : lambdaParameters '->' lambdaBody + ; lambdaParameters - : Identifier - | '(' formalParameterList? ')' - | '(' inferredFormalParameterList ')' - ; + : Identifier + | '(' formalParameterList? ')' + | '(' inferredFormalParameterList ')' + ; inferredFormalParameterList - : Identifier (',' Identifier)* - ; + : Identifier (',' Identifier)* + ; lambdaBody - : expression - | block - ; + : expression + | block + ; assignmentExpression - : conditionalExpression - | assignment - ; + : conditionalExpression + | assignment + ; assignment - : leftHandSide assignmentOperator expression - ; + : leftHandSide assignmentOperator expression + ; leftHandSide - : expressionName - | fieldAccess - | arrayAccess - ; + : expressionName + | fieldAccess + | arrayAccess + ; assignmentOperator - : '=' - | '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '=' + | '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; conditionalExpression - : conditionalOrExpression - | conditionalOrExpression '?' expression ':' conditionalExpression - ; + : conditionalOrExpression + | conditionalOrExpression '?' expression ':' conditionalExpression + ; conditionalOrExpression - : conditionalAndExpression - | conditionalOrExpression '||' conditionalAndExpression - ; + : conditionalAndExpression + | conditionalOrExpression '||' conditionalAndExpression + ; conditionalAndExpression - : inclusiveOrExpression - | conditionalAndExpression '&&' inclusiveOrExpression - ; + : inclusiveOrExpression + | conditionalAndExpression '&&' inclusiveOrExpression + ; inclusiveOrExpression - : exclusiveOrExpression - | inclusiveOrExpression '|' exclusiveOrExpression - ; + : exclusiveOrExpression + | inclusiveOrExpression '|' exclusiveOrExpression + ; exclusiveOrExpression - : andExpression - | exclusiveOrExpression '^' andExpression - ; + : andExpression + | exclusiveOrExpression '^' andExpression + ; andExpression - : equalityExpression - | andExpression '&' equalityExpression - ; + : equalityExpression + | andExpression '&' equalityExpression + ; equalityExpression - : relationalExpression - | equalityExpression '==' relationalExpression - | equalityExpression '!=' relationalExpression - ; + : relationalExpression + | equalityExpression '==' relationalExpression + | equalityExpression '!=' relationalExpression + ; relationalExpression - : shiftExpression - | relationalExpression '<' shiftExpression - | relationalExpression '>' shiftExpression - | relationalExpression '<=' shiftExpression - | relationalExpression '>=' shiftExpression - | relationalExpression 'instanceof' referenceType - ; + : shiftExpression + | relationalExpression '<' shiftExpression + | relationalExpression '>' shiftExpression + | relationalExpression '<=' shiftExpression + | relationalExpression '>=' shiftExpression + | relationalExpression 'instanceof' referenceType + ; shiftExpression - : additiveExpression - | shiftExpression '<' '<' additiveExpression - | shiftExpression '>' '>' additiveExpression - | shiftExpression '>' '>' '>' additiveExpression - ; + : additiveExpression + | shiftExpression '<' '<' additiveExpression + | shiftExpression '>' '>' additiveExpression + | shiftExpression '>' '>' '>' additiveExpression + ; additiveExpression - : multiplicativeExpression - | additiveExpression '+' multiplicativeExpression - | additiveExpression '-' multiplicativeExpression - ; + : multiplicativeExpression + | additiveExpression '+' multiplicativeExpression + | additiveExpression '-' multiplicativeExpression + ; multiplicativeExpression - : unaryExpression - | multiplicativeExpression '*' unaryExpression - | multiplicativeExpression '/' unaryExpression - | multiplicativeExpression '%' unaryExpression - ; + : unaryExpression + | multiplicativeExpression '*' unaryExpression + | multiplicativeExpression '/' unaryExpression + | multiplicativeExpression '%' unaryExpression + ; unaryExpression - : preIncrementExpression - | preDecrementExpression - | '+' unaryExpression - | '-' unaryExpression - | unaryExpressionNotPlusMinus - ; + : preIncrementExpression + | preDecrementExpression + | '+' unaryExpression + | '-' unaryExpression + | unaryExpressionNotPlusMinus + ; preIncrementExpression - : '++' unaryExpression - ; + : '++' unaryExpression + ; preDecrementExpression - : '--' unaryExpression - ; + : '--' unaryExpression + ; unaryExpressionNotPlusMinus - : postfixExpression - | '~' unaryExpression - | '!' unaryExpression - | castExpression - ; + : postfixExpression + | '~' unaryExpression + | '!' unaryExpression + | castExpression + ; postfixExpression - : ( primary - | expressionName - ) - ( postIncrementExpression_lf_postfixExpression - | postDecrementExpression_lf_postfixExpression - )* - ; + : (primary | expressionName) ( + postIncrementExpression_lf_postfixExpression + | postDecrementExpression_lf_postfixExpression + )* + ; postIncrementExpression - : postfixExpression '++' - ; + : postfixExpression '++' + ; postIncrementExpression_lf_postfixExpression - : '++' - ; + : '++' + ; postDecrementExpression - : postfixExpression '--' - ; + : postfixExpression '--' + ; postDecrementExpression_lf_postfixExpression - : '--' - ; + : '--' + ; castExpression - : '(' primitiveType ')' unaryExpression - | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus - | '(' referenceType additionalBound* ')' lambdaExpression - ; + : '(' primitiveType ')' unaryExpression + | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus + | '(' referenceType additionalBound* ')' lambdaExpression + ; \ No newline at end of file diff --git a/java/java9/Cpp/Java9Lexer.g4 b/java/java9/Cpp/Java9Lexer.g4 index b83f83b4fa..d263efc806 100644 --- a/java/java9/Cpp/Java9Lexer.g4 +++ b/java/java9/Cpp/Java9Lexer.g4 @@ -62,15 +62,19 @@ Total lexer+parser time 3634ms. Total lexer+parser time 2497ms. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Java9Lexer; options { - superClass = Java9LexerBase; + superClass = Java9LexerBase; } -@header -{ +@header { #include "Java9LexerBase.h" } @@ -78,445 +82,284 @@ options // §3.9 Keywords -ABSTRACT : 'abstract'; -ASSERT : 'assert'; -BOOLEAN : 'boolean'; -BREAK : 'break'; -BYTE : 'byte'; -CASE : 'case'; -CATCH : 'catch'; -CHAR : 'char'; -CLASS : 'class'; -CONST : 'const'; -CONTINUE : 'continue'; -DEFAULT : 'default'; -DO : 'do'; -DOUBLE : 'double'; -ELSE : 'else'; -ENUM : 'enum'; -EXPORTS : 'exports'; -EXTENDS : 'extends'; -FINAL : 'final'; -FINALLY : 'finally'; -FLOAT : 'float'; -FOR : 'for'; -IF : 'if'; -GOTO : 'goto'; -IMPLEMENTS : 'implements'; -IMPORT : 'import'; -INSTANCEOF : 'instanceof'; -INT : 'int'; -INTERFACE : 'interface'; -LONG : 'long'; -MODULE : 'module'; -NATIVE : 'native'; -NEW : 'new'; -OPEN : 'open'; -OPERNS : 'opens'; -PACKAGE : 'package'; -PRIVATE : 'private'; -PROTECTED : 'protected'; -PROVIDES : 'provides'; -PUBLIC : 'public'; -REQUIRES : 'requires'; -RETURN : 'return'; -SHORT : 'short'; -STATIC : 'static'; -STRICTFP : 'strictfp'; -SUPER : 'super'; -SWITCH : 'switch'; +ABSTRACT : 'abstract'; +ASSERT : 'assert'; +BOOLEAN : 'boolean'; +BREAK : 'break'; +BYTE : 'byte'; +CASE : 'case'; +CATCH : 'catch'; +CHAR : 'char'; +CLASS : 'class'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXPORTS : 'exports'; +EXTENDS : 'extends'; +FINAL : 'final'; +FINALLY : 'finally'; +FLOAT : 'float'; +FOR : 'for'; +IF : 'if'; +GOTO : 'goto'; +IMPLEMENTS : 'implements'; +IMPORT : 'import'; +INSTANCEOF : 'instanceof'; +INT : 'int'; +INTERFACE : 'interface'; +LONG : 'long'; +MODULE : 'module'; +NATIVE : 'native'; +NEW : 'new'; +OPEN : 'open'; +OPERNS : 'opens'; +PACKAGE : 'package'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PROVIDES : 'provides'; +PUBLIC : 'public'; +REQUIRES : 'requires'; +RETURN : 'return'; +SHORT : 'short'; +STATIC : 'static'; +STRICTFP : 'strictfp'; +SUPER : 'super'; +SWITCH : 'switch'; SYNCHRONIZED : 'synchronized'; -THIS : 'this'; -THROW : 'throw'; -THROWS : 'throws'; -TO : 'to'; -TRANSIENT : 'transient'; -TRANSITIVE : 'transitive'; -TRY : 'try'; -USES : 'uses'; -VOID : 'void'; -VOLATILE : 'volatile'; -WHILE : 'while'; -WITH : 'with'; -UNDER_SCORE : '_';//Introduced in Java 9 +THIS : 'this'; +THROW : 'throw'; +THROWS : 'throws'; +TO : 'to'; +TRANSIENT : 'transient'; +TRANSITIVE : 'transitive'; +TRY : 'try'; +USES : 'uses'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; +WITH : 'with'; +UNDER_SCORE : '_'; //Introduced in Java 9 // §3.10.1 Integer Literals -IntegerLiteral - : DecimalIntegerLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - | BinaryIntegerLiteral - ; - -fragment -DecimalIntegerLiteral - : DecimalNumeral IntegerTypeSuffix? - ; - -fragment -HexIntegerLiteral - : HexNumeral IntegerTypeSuffix? - ; - -fragment -OctalIntegerLiteral - : OctalNumeral IntegerTypeSuffix? - ; - -fragment -BinaryIntegerLiteral - : BinaryNumeral IntegerTypeSuffix? - ; - -fragment -IntegerTypeSuffix - : [lL] - ; - -fragment -DecimalNumeral - : '0' - | NonZeroDigit (Digits? | Underscores Digits) - ; - -fragment -Digits - : Digit (DigitsAndUnderscores? Digit)? - ; - -fragment -Digit - : '0' - | NonZeroDigit - ; - -fragment -NonZeroDigit - : [1-9] - ; - -fragment -DigitsAndUnderscores - : DigitOrUnderscore+ - ; - -fragment -DigitOrUnderscore - : Digit - | '_' - ; - -fragment -Underscores - : '_'+ - ; - -fragment -HexNumeral - : '0' [xX] HexDigits - ; - -fragment -HexDigits - : HexDigit (HexDigitsAndUnderscores? HexDigit)? - ; - -fragment -HexDigit - : [0-9a-fA-F] - ; - -fragment -HexDigitsAndUnderscores - : HexDigitOrUnderscore+ - ; - -fragment -HexDigitOrUnderscore - : HexDigit - | '_' - ; - -fragment -OctalNumeral - : '0' Underscores? OctalDigits - ; - -fragment -OctalDigits - : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)? - ; - -fragment -OctalDigit - : [0-7] - ; - -fragment -OctalDigitsAndUnderscores - : OctalDigitOrUnderscore+ - ; - -fragment -OctalDigitOrUnderscore - : OctalDigit - | '_' - ; - -fragment -BinaryNumeral - : '0' [bB] BinaryDigits - ; - -fragment -BinaryDigits - : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)? - ; - -fragment -BinaryDigit - : [01] - ; - -fragment -BinaryDigitsAndUnderscores - : BinaryDigitOrUnderscore+ - ; - -fragment -BinaryDigitOrUnderscore - : BinaryDigit - | '_' - ; +IntegerLiteral: + DecimalIntegerLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + | BinaryIntegerLiteral +; + +fragment DecimalIntegerLiteral: DecimalNumeral IntegerTypeSuffix?; + +fragment HexIntegerLiteral: HexNumeral IntegerTypeSuffix?; + +fragment OctalIntegerLiteral: OctalNumeral IntegerTypeSuffix?; + +fragment BinaryIntegerLiteral: BinaryNumeral IntegerTypeSuffix?; + +fragment IntegerTypeSuffix: [lL]; + +fragment DecimalNumeral: '0' | NonZeroDigit (Digits? | Underscores Digits); + +fragment Digits: Digit (DigitsAndUnderscores? Digit)?; + +fragment Digit: '0' | NonZeroDigit; + +fragment NonZeroDigit: [1-9]; + +fragment DigitsAndUnderscores: DigitOrUnderscore+; + +fragment DigitOrUnderscore: Digit | '_'; + +fragment Underscores: '_'+; + +fragment HexNumeral: '0' [xX] HexDigits; + +fragment HexDigits: HexDigit (HexDigitsAndUnderscores? HexDigit)?; + +fragment HexDigit: [0-9a-fA-F]; + +fragment HexDigitsAndUnderscores: HexDigitOrUnderscore+; + +fragment HexDigitOrUnderscore: HexDigit | '_'; + +fragment OctalNumeral: '0' Underscores? OctalDigits; + +fragment OctalDigits: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?; + +fragment OctalDigit: [0-7]; + +fragment OctalDigitsAndUnderscores: OctalDigitOrUnderscore+; + +fragment OctalDigitOrUnderscore: OctalDigit | '_'; + +fragment BinaryNumeral: '0' [bB] BinaryDigits; + +fragment BinaryDigits: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?; + +fragment BinaryDigit: [01]; + +fragment BinaryDigitsAndUnderscores: BinaryDigitOrUnderscore+; + +fragment BinaryDigitOrUnderscore: BinaryDigit | '_'; // §3.10.2 Floating-Point Literals -FloatingPointLiteral - : DecimalFloatingPointLiteral - | HexadecimalFloatingPointLiteral - ; - -fragment -DecimalFloatingPointLiteral - : Digits '.' Digits? ExponentPart? FloatTypeSuffix? - | '.' Digits ExponentPart? FloatTypeSuffix? - | Digits ExponentPart FloatTypeSuffix? - | Digits FloatTypeSuffix - ; - -fragment -ExponentPart - : ExponentIndicator SignedInteger - ; - -fragment -ExponentIndicator - : [eE] - ; - -fragment -SignedInteger - : Sign? Digits - ; - -fragment -Sign - : [+-] - ; - -fragment -FloatTypeSuffix - : [fFdD] - ; - -fragment -HexadecimalFloatingPointLiteral - : HexSignificand BinaryExponent FloatTypeSuffix? - ; - -fragment -HexSignificand - : HexNumeral '.'? - | '0' [xX] HexDigits? '.' HexDigits - ; - -fragment -BinaryExponent - : BinaryExponentIndicator SignedInteger - ; - -fragment -BinaryExponentIndicator - : [pP] - ; +FloatingPointLiteral: DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral; + +fragment DecimalFloatingPointLiteral: + Digits '.' Digits? ExponentPart? FloatTypeSuffix? + | '.' Digits ExponentPart? FloatTypeSuffix? + | Digits ExponentPart FloatTypeSuffix? + | Digits FloatTypeSuffix +; + +fragment ExponentPart: ExponentIndicator SignedInteger; + +fragment ExponentIndicator: [eE]; + +fragment SignedInteger: Sign? Digits; + +fragment Sign: [+-]; + +fragment FloatTypeSuffix: [fFdD]; + +fragment HexadecimalFloatingPointLiteral: HexSignificand BinaryExponent FloatTypeSuffix?; + +fragment HexSignificand: HexNumeral '.'? | '0' [xX] HexDigits? '.' HexDigits; + +fragment BinaryExponent: BinaryExponentIndicator SignedInteger; + +fragment BinaryExponentIndicator: [pP]; // §3.10.3 Boolean Literals -BooleanLiteral - : 'true' - | 'false' - ; +BooleanLiteral: 'true' | 'false'; // §3.10.4 Character Literals -CharacterLiteral - : '\'' SingleCharacter '\'' - | '\'' EscapeSequence '\'' - ; +CharacterLiteral: '\'' SingleCharacter '\'' | '\'' EscapeSequence '\''; -fragment -SingleCharacter - : ~['\\\r\n] - ; +fragment SingleCharacter: ~['\\\r\n]; // §3.10.5 String Literals -StringLiteral - : '"' StringCharacters? '"' - ; +StringLiteral: '"' StringCharacters? '"'; -fragment -StringCharacters - : StringCharacter+ - ; +fragment StringCharacters: StringCharacter+; -fragment -StringCharacter - : ~["\\\r\n] - | EscapeSequence - ; +fragment StringCharacter: ~["\\\r\n] | EscapeSequence; // §3.10.6 Escape Sequences for Character and String Literals -fragment -EscapeSequence - : '\\' 'u005c'? [btnfr"'\\] - | OctalEscape - | UnicodeEscape // This is not in the spec but prevents having to preprocess the input - ; - -fragment -OctalEscape - : '\\' 'u005c'? OctalDigit - | '\\' 'u005c'? OctalDigit OctalDigit - | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit - ; - -fragment -ZeroToThree - : [0-3] - ; +fragment EscapeSequence: + '\\' 'u005c'? [btnfr"'\\] + | OctalEscape + | UnicodeEscape // This is not in the spec but prevents having to preprocess the input +; + +fragment OctalEscape: + '\\' 'u005c'? OctalDigit + | '\\' 'u005c'? OctalDigit OctalDigit + | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit +; + +fragment ZeroToThree: [0-3]; // This is not in the spec but prevents having to preprocess the input -fragment -UnicodeEscape - : '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +fragment UnicodeEscape: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit; // §3.10.7 The Null Literal -NullLiteral - : 'null' - ; +NullLiteral: 'null'; // §3.11 Separators -LPAREN : '('; -RPAREN : ')'; -LBRACE : '{'; -RBRACE : '}'; -LBRACK : '['; -RBRACK : ']'; -SEMI : ';'; -COMMA : ','; -DOT : '.'; -ELLIPSIS : '...'; -AT : '@'; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +ELLIPSIS : '...'; +AT : '@'; COLONCOLON : '::'; - // §3.12 Operators -ASSIGN : '='; -GT : '>'; -LT : '<'; -BANG : '!'; -TILDE : '~'; +ASSIGN : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; QUESTION : '?'; -COLON : ':'; -ARROW : '->'; -EQUAL : '=='; -LE : '<='; -GE : '>='; +COLON : ':'; +ARROW : '->'; +EQUAL : '=='; +LE : '<='; +GE : '>='; NOTEQUAL : '!='; -AND : '&&'; -OR : '||'; -INC : '++'; -DEC : '--'; -ADD : '+'; -SUB : '-'; -MUL : '*'; -DIV : '/'; -BITAND : '&'; -BITOR : '|'; -CARET : '^'; -MOD : '%'; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +CARET : '^'; +MOD : '%'; //LSHIFT : '<<'; //RSHIFT : '>>'; //URSHIFT : '>>>'; -ADD_ASSIGN : '+='; -SUB_ASSIGN : '-='; -MUL_ASSIGN : '*='; -DIV_ASSIGN : '/='; -AND_ASSIGN : '&='; -OR_ASSIGN : '|='; -XOR_ASSIGN : '^='; -MOD_ASSIGN : '%='; -LSHIFT_ASSIGN : '<<='; -RSHIFT_ASSIGN : '>>='; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; URSHIFT_ASSIGN : '>>>='; // §3.8 Identifiers (must appear after all keywords in the grammar) -Identifier - : JavaLetter JavaLetterOrDigit* - ; - -fragment -JavaLetter - : [a-zA-Z$_] // these are the "java letters" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { Check1() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { Check2() }? - ; - -fragment -JavaLetterOrDigit - : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { Check3() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { Check4() }? - ; +Identifier: JavaLetter JavaLetterOrDigit*; + +fragment JavaLetter: + [a-zA-Z$_] // these are the "java letters" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { Check1() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { Check2() }? +; + +fragment JavaLetterOrDigit: + [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { Check3() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { Check4() }? +; // // Whitespace and comments // -WS : [ \t\r\n\u000C]+ -> skip - ; +WS: [ \t\r\n\u000C]+ -> skip; -COMMENT - : '/*' .*? '*/' -> channel(HIDDEN) - ; +COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT - : '//' ~[\r\n]* -> channel(HIDDEN) - ; +LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); \ No newline at end of file diff --git a/java/java9/Dart/Java9Lexer.g4 b/java/java9/Dart/Java9Lexer.g4 index 47ddac2f65..eb7463a599 100644 --- a/java/java9/Dart/Java9Lexer.g4 +++ b/java/java9/Dart/Java9Lexer.g4 @@ -62,14 +62,19 @@ Total lexer+parser time 3634ms. Total lexer+parser time 2497ms. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Java9Lexer; options { - superClass = Java9LexerBase; + superClass = Java9LexerBase; } -@lexer::header{ +@lexer::header { import 'Java9LexerBase.dart'; } @@ -77,445 +82,284 @@ import 'Java9LexerBase.dart'; // §3.9 Keywords -ABSTRACT : 'abstract'; -ASSERT : 'assert'; -BOOLEAN : 'boolean'; -BREAK : 'break'; -BYTE : 'byte'; -CASE : 'case'; -CATCH : 'catch'; -CHAR : 'char'; -CLASS : 'class'; -CONST : 'const'; -CONTINUE : 'continue'; -DEFAULT : 'default'; -DO : 'do'; -DOUBLE : 'double'; -ELSE : 'else'; -ENUM : 'enum'; -EXPORTS : 'exports'; -EXTENDS : 'extends'; -FINAL : 'final'; -FINALLY : 'finally'; -FLOAT : 'float'; -FOR : 'for'; -IF : 'if'; -GOTO : 'goto'; -IMPLEMENTS : 'implements'; -IMPORT : 'import'; -INSTANCEOF : 'instanceof'; -INT : 'int'; -INTERFACE : 'interface'; -LONG : 'long'; -MODULE : 'module'; -NATIVE : 'native'; -NEW : 'new'; -OPEN : 'open'; -OPERNS : 'opens'; -PACKAGE : 'package'; -PRIVATE : 'private'; -PROTECTED : 'protected'; -PROVIDES : 'provides'; -PUBLIC : 'public'; -REQUIRES : 'requires'; -RETURN : 'return'; -SHORT : 'short'; -STATIC : 'static'; -STRICTFP : 'strictfp'; -SUPER : 'super'; -SWITCH : 'switch'; +ABSTRACT : 'abstract'; +ASSERT : 'assert'; +BOOLEAN : 'boolean'; +BREAK : 'break'; +BYTE : 'byte'; +CASE : 'case'; +CATCH : 'catch'; +CHAR : 'char'; +CLASS : 'class'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXPORTS : 'exports'; +EXTENDS : 'extends'; +FINAL : 'final'; +FINALLY : 'finally'; +FLOAT : 'float'; +FOR : 'for'; +IF : 'if'; +GOTO : 'goto'; +IMPLEMENTS : 'implements'; +IMPORT : 'import'; +INSTANCEOF : 'instanceof'; +INT : 'int'; +INTERFACE : 'interface'; +LONG : 'long'; +MODULE : 'module'; +NATIVE : 'native'; +NEW : 'new'; +OPEN : 'open'; +OPERNS : 'opens'; +PACKAGE : 'package'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PROVIDES : 'provides'; +PUBLIC : 'public'; +REQUIRES : 'requires'; +RETURN : 'return'; +SHORT : 'short'; +STATIC : 'static'; +STRICTFP : 'strictfp'; +SUPER : 'super'; +SWITCH : 'switch'; SYNCHRONIZED : 'synchronized'; -THIS : 'this'; -THROW : 'throw'; -THROWS : 'throws'; -TO : 'to'; -TRANSIENT : 'transient'; -TRANSITIVE : 'transitive'; -TRY : 'try'; -USES : 'uses'; -VOID : 'void'; -VOLATILE : 'volatile'; -WHILE : 'while'; -WITH : 'with'; -UNDER_SCORE : '_';//Introduced in Java 9 +THIS : 'this'; +THROW : 'throw'; +THROWS : 'throws'; +TO : 'to'; +TRANSIENT : 'transient'; +TRANSITIVE : 'transitive'; +TRY : 'try'; +USES : 'uses'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; +WITH : 'with'; +UNDER_SCORE : '_'; //Introduced in Java 9 // §3.10.1 Integer Literals -IntegerLiteral - : DecimalIntegerLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - | BinaryIntegerLiteral - ; - -fragment -DecimalIntegerLiteral - : DecimalNumeral IntegerTypeSuffix? - ; - -fragment -HexIntegerLiteral - : HexNumeral IntegerTypeSuffix? - ; - -fragment -OctalIntegerLiteral - : OctalNumeral IntegerTypeSuffix? - ; - -fragment -BinaryIntegerLiteral - : BinaryNumeral IntegerTypeSuffix? - ; - -fragment -IntegerTypeSuffix - : [lL] - ; - -fragment -DecimalNumeral - : '0' - | NonZeroDigit (Digits? | Underscores Digits) - ; - -fragment -Digits - : Digit (DigitsAndUnderscores? Digit)? - ; - -fragment -Digit - : '0' - | NonZeroDigit - ; - -fragment -NonZeroDigit - : [1-9] - ; - -fragment -DigitsAndUnderscores - : DigitOrUnderscore+ - ; - -fragment -DigitOrUnderscore - : Digit - | '_' - ; - -fragment -Underscores - : '_'+ - ; - -fragment -HexNumeral - : '0' [xX] HexDigits - ; - -fragment -HexDigits - : HexDigit (HexDigitsAndUnderscores? HexDigit)? - ; - -fragment -HexDigit - : [0-9a-fA-F] - ; - -fragment -HexDigitsAndUnderscores - : HexDigitOrUnderscore+ - ; - -fragment -HexDigitOrUnderscore - : HexDigit - | '_' - ; - -fragment -OctalNumeral - : '0' Underscores? OctalDigits - ; - -fragment -OctalDigits - : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)? - ; - -fragment -OctalDigit - : [0-7] - ; - -fragment -OctalDigitsAndUnderscores - : OctalDigitOrUnderscore+ - ; - -fragment -OctalDigitOrUnderscore - : OctalDigit - | '_' - ; - -fragment -BinaryNumeral - : '0' [bB] BinaryDigits - ; - -fragment -BinaryDigits - : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)? - ; - -fragment -BinaryDigit - : [01] - ; - -fragment -BinaryDigitsAndUnderscores - : BinaryDigitOrUnderscore+ - ; - -fragment -BinaryDigitOrUnderscore - : BinaryDigit - | '_' - ; +IntegerLiteral: + DecimalIntegerLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + | BinaryIntegerLiteral +; + +fragment DecimalIntegerLiteral: DecimalNumeral IntegerTypeSuffix?; + +fragment HexIntegerLiteral: HexNumeral IntegerTypeSuffix?; + +fragment OctalIntegerLiteral: OctalNumeral IntegerTypeSuffix?; + +fragment BinaryIntegerLiteral: BinaryNumeral IntegerTypeSuffix?; + +fragment IntegerTypeSuffix: [lL]; + +fragment DecimalNumeral: '0' | NonZeroDigit (Digits? | Underscores Digits); + +fragment Digits: Digit (DigitsAndUnderscores? Digit)?; + +fragment Digit: '0' | NonZeroDigit; + +fragment NonZeroDigit: [1-9]; + +fragment DigitsAndUnderscores: DigitOrUnderscore+; + +fragment DigitOrUnderscore: Digit | '_'; + +fragment Underscores: '_'+; + +fragment HexNumeral: '0' [xX] HexDigits; + +fragment HexDigits: HexDigit (HexDigitsAndUnderscores? HexDigit)?; + +fragment HexDigit: [0-9a-fA-F]; + +fragment HexDigitsAndUnderscores: HexDigitOrUnderscore+; + +fragment HexDigitOrUnderscore: HexDigit | '_'; + +fragment OctalNumeral: '0' Underscores? OctalDigits; + +fragment OctalDigits: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?; + +fragment OctalDigit: [0-7]; + +fragment OctalDigitsAndUnderscores: OctalDigitOrUnderscore+; + +fragment OctalDigitOrUnderscore: OctalDigit | '_'; + +fragment BinaryNumeral: '0' [bB] BinaryDigits; + +fragment BinaryDigits: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?; + +fragment BinaryDigit: [01]; + +fragment BinaryDigitsAndUnderscores: BinaryDigitOrUnderscore+; + +fragment BinaryDigitOrUnderscore: BinaryDigit | '_'; // §3.10.2 Floating-Point Literals -FloatingPointLiteral - : DecimalFloatingPointLiteral - | HexadecimalFloatingPointLiteral - ; - -fragment -DecimalFloatingPointLiteral - : Digits '.' Digits? ExponentPart? FloatTypeSuffix? - | '.' Digits ExponentPart? FloatTypeSuffix? - | Digits ExponentPart FloatTypeSuffix? - | Digits FloatTypeSuffix - ; - -fragment -ExponentPart - : ExponentIndicator SignedInteger - ; - -fragment -ExponentIndicator - : [eE] - ; - -fragment -SignedInteger - : Sign? Digits - ; - -fragment -Sign - : [+-] - ; - -fragment -FloatTypeSuffix - : [fFdD] - ; - -fragment -HexadecimalFloatingPointLiteral - : HexSignificand BinaryExponent FloatTypeSuffix? - ; - -fragment -HexSignificand - : HexNumeral '.'? - | '0' [xX] HexDigits? '.' HexDigits - ; - -fragment -BinaryExponent - : BinaryExponentIndicator SignedInteger - ; - -fragment -BinaryExponentIndicator - : [pP] - ; +FloatingPointLiteral: DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral; + +fragment DecimalFloatingPointLiteral: + Digits '.' Digits? ExponentPart? FloatTypeSuffix? + | '.' Digits ExponentPart? FloatTypeSuffix? + | Digits ExponentPart FloatTypeSuffix? + | Digits FloatTypeSuffix +; + +fragment ExponentPart: ExponentIndicator SignedInteger; + +fragment ExponentIndicator: [eE]; + +fragment SignedInteger: Sign? Digits; + +fragment Sign: [+-]; + +fragment FloatTypeSuffix: [fFdD]; + +fragment HexadecimalFloatingPointLiteral: HexSignificand BinaryExponent FloatTypeSuffix?; + +fragment HexSignificand: HexNumeral '.'? | '0' [xX] HexDigits? '.' HexDigits; + +fragment BinaryExponent: BinaryExponentIndicator SignedInteger; + +fragment BinaryExponentIndicator: [pP]; // §3.10.3 Boolean Literals -BooleanLiteral - : 'true' - | 'false' - ; +BooleanLiteral: 'true' | 'false'; // §3.10.4 Character Literals -CharacterLiteral - : '\'' SingleCharacter '\'' - | '\'' EscapeSequence '\'' - ; +CharacterLiteral: '\'' SingleCharacter '\'' | '\'' EscapeSequence '\''; -fragment -SingleCharacter - : ~['\\\r\n] - ; +fragment SingleCharacter: ~['\\\r\n]; // §3.10.5 String Literals -StringLiteral - : '"' StringCharacters? '"' - ; +StringLiteral: '"' StringCharacters? '"'; -fragment -StringCharacters - : StringCharacter+ - ; +fragment StringCharacters: StringCharacter+; -fragment -StringCharacter - : ~["\\\r\n] - | EscapeSequence - ; +fragment StringCharacter: ~["\\\r\n] | EscapeSequence; // §3.10.6 Escape Sequences for Character and String Literals -fragment -EscapeSequence - : '\\' 'u005c'? [btnfr"'\\] - | OctalEscape - | UnicodeEscape // This is not in the spec but prevents having to preprocess the input - ; - -fragment -OctalEscape - : '\\' 'u005c'? OctalDigit - | '\\' 'u005c'? OctalDigit OctalDigit - | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit - ; - -fragment -ZeroToThree - : [0-3] - ; +fragment EscapeSequence: + '\\' 'u005c'? [btnfr"'\\] + | OctalEscape + | UnicodeEscape // This is not in the spec but prevents having to preprocess the input +; + +fragment OctalEscape: + '\\' 'u005c'? OctalDigit + | '\\' 'u005c'? OctalDigit OctalDigit + | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit +; + +fragment ZeroToThree: [0-3]; // This is not in the spec but prevents having to preprocess the input -fragment -UnicodeEscape - : '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +fragment UnicodeEscape: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit; // §3.10.7 The Null Literal -NullLiteral - : 'null' - ; +NullLiteral: 'null'; // §3.11 Separators -LPAREN : '('; -RPAREN : ')'; -LBRACE : '{'; -RBRACE : '}'; -LBRACK : '['; -RBRACK : ']'; -SEMI : ';'; -COMMA : ','; -DOT : '.'; -ELLIPSIS : '...'; -AT : '@'; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +ELLIPSIS : '...'; +AT : '@'; COLONCOLON : '::'; - // §3.12 Operators -ASSIGN : '='; -GT : '>'; -LT : '<'; -BANG : '!'; -TILDE : '~'; +ASSIGN : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; QUESTION : '?'; -COLON : ':'; -ARROW : '->'; -EQUAL : '=='; -LE : '<='; -GE : '>='; +COLON : ':'; +ARROW : '->'; +EQUAL : '=='; +LE : '<='; +GE : '>='; NOTEQUAL : '!='; -AND : '&&'; -OR : '||'; -INC : '++'; -DEC : '--'; -ADD : '+'; -SUB : '-'; -MUL : '*'; -DIV : '/'; -BITAND : '&'; -BITOR : '|'; -CARET : '^'; -MOD : '%'; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +CARET : '^'; +MOD : '%'; //LSHIFT : '<<'; //RSHIFT : '>>'; //URSHIFT : '>>>'; -ADD_ASSIGN : '+='; -SUB_ASSIGN : '-='; -MUL_ASSIGN : '*='; -DIV_ASSIGN : '/='; -AND_ASSIGN : '&='; -OR_ASSIGN : '|='; -XOR_ASSIGN : '^='; -MOD_ASSIGN : '%='; -LSHIFT_ASSIGN : '<<='; -RSHIFT_ASSIGN : '>>='; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; URSHIFT_ASSIGN : '>>>='; // §3.8 Identifiers (must appear after all keywords in the grammar) -Identifier - : JavaLetter JavaLetterOrDigit* - ; - -fragment -JavaLetter - : [a-zA-Z$_] // these are the "java letters" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { this.Check1() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { this.Check2() }? - ; - -fragment -JavaLetterOrDigit - : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { this.Check3() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { this.Check4() }? - ; +Identifier: JavaLetter JavaLetterOrDigit*; + +fragment JavaLetter: + [a-zA-Z$_] // these are the "java letters" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { this.Check1() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { this.Check2() }? +; + +fragment JavaLetterOrDigit: + [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { this.Check3() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { this.Check4() }? +; // // Whitespace and comments // -WS : [ \t\r\n\u000C]+ -> skip - ; +WS: [ \t\r\n\u000C]+ -> skip; -COMMENT - : '/*' .*? '*/' -> channel(HIDDEN) - ; +COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT - : '//' ~[\r\n]* -> channel(HIDDEN) - ; +LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); \ No newline at end of file diff --git a/java/java9/Java9Lexer.g4 b/java/java9/Java9Lexer.g4 index 8a87915762..e15b542a1b 100644 --- a/java/java9/Java9Lexer.g4 +++ b/java/java9/Java9Lexer.g4 @@ -62,456 +62,300 @@ Total lexer+parser time 3634ms. Total lexer+parser time 2497ms. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Java9Lexer; options { - superClass = Java9LexerBase; + superClass = Java9LexerBase; } // LEXER // §3.9 Keywords -ABSTRACT : 'abstract'; -ASSERT : 'assert'; -BOOLEAN : 'boolean'; -BREAK : 'break'; -BYTE : 'byte'; -CASE : 'case'; -CATCH : 'catch'; -CHAR : 'char'; -CLASS : 'class'; -CONST : 'const'; -CONTINUE : 'continue'; -DEFAULT : 'default'; -DO : 'do'; -DOUBLE : 'double'; -ELSE : 'else'; -ENUM : 'enum'; -EXPORTS : 'exports'; -EXTENDS : 'extends'; -FINAL : 'final'; -FINALLY : 'finally'; -FLOAT : 'float'; -FOR : 'for'; -IF : 'if'; -GOTO : 'goto'; -IMPLEMENTS : 'implements'; -IMPORT : 'import'; -INSTANCEOF : 'instanceof'; -INT : 'int'; -INTERFACE : 'interface'; -LONG : 'long'; -MODULE : 'module'; -NATIVE : 'native'; -NEW : 'new'; -OPEN : 'open'; -OPERNS : 'opens'; -PACKAGE : 'package'; -PRIVATE : 'private'; -PROTECTED : 'protected'; -PROVIDES : 'provides'; -PUBLIC : 'public'; -REQUIRES : 'requires'; -RETURN : 'return'; -SHORT : 'short'; -STATIC : 'static'; -STRICTFP : 'strictfp'; -SUPER : 'super'; -SWITCH : 'switch'; +ABSTRACT : 'abstract'; +ASSERT : 'assert'; +BOOLEAN : 'boolean'; +BREAK : 'break'; +BYTE : 'byte'; +CASE : 'case'; +CATCH : 'catch'; +CHAR : 'char'; +CLASS : 'class'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXPORTS : 'exports'; +EXTENDS : 'extends'; +FINAL : 'final'; +FINALLY : 'finally'; +FLOAT : 'float'; +FOR : 'for'; +IF : 'if'; +GOTO : 'goto'; +IMPLEMENTS : 'implements'; +IMPORT : 'import'; +INSTANCEOF : 'instanceof'; +INT : 'int'; +INTERFACE : 'interface'; +LONG : 'long'; +MODULE : 'module'; +NATIVE : 'native'; +NEW : 'new'; +OPEN : 'open'; +OPERNS : 'opens'; +PACKAGE : 'package'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PROVIDES : 'provides'; +PUBLIC : 'public'; +REQUIRES : 'requires'; +RETURN : 'return'; +SHORT : 'short'; +STATIC : 'static'; +STRICTFP : 'strictfp'; +SUPER : 'super'; +SWITCH : 'switch'; SYNCHRONIZED : 'synchronized'; -THIS : 'this'; -THROW : 'throw'; -THROWS : 'throws'; -TO : 'to'; -TRANSIENT : 'transient'; -TRANSITIVE : 'transitive'; -TRY : 'try'; -USES : 'uses'; -VOID : 'void'; -VOLATILE : 'volatile'; -WHILE : 'while'; -WITH : 'with'; -UNDER_SCORE : '_';//Introduced in Java 9 +THIS : 'this'; +THROW : 'throw'; +THROWS : 'throws'; +TO : 'to'; +TRANSIENT : 'transient'; +TRANSITIVE : 'transitive'; +TRY : 'try'; +USES : 'uses'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; +WITH : 'with'; +UNDER_SCORE : '_'; //Introduced in Java 9 // §3.10.1 Integer Literals -IntegerLiteral - : DecimalIntegerLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - | BinaryIntegerLiteral - ; - -fragment -DecimalIntegerLiteral - : DecimalNumeral IntegerTypeSuffix? - ; - -fragment -HexIntegerLiteral - : HexNumeral IntegerTypeSuffix? - ; - -fragment -OctalIntegerLiteral - : OctalNumeral IntegerTypeSuffix? - ; - -fragment -BinaryIntegerLiteral - : BinaryNumeral IntegerTypeSuffix? - ; - -fragment -IntegerTypeSuffix - : [lL] - ; - -fragment -DecimalNumeral - : '0' - | NonZeroDigit (Digits? | Underscores Digits) - ; - -fragment -Digits - : Digit (DigitsAndUnderscores? Digit)? - ; - -fragment -Digit - : '0' - | NonZeroDigit - ; - -fragment -NonZeroDigit - : [1-9] - ; - -fragment -DigitsAndUnderscores - : DigitOrUnderscore+ - ; - -fragment -DigitOrUnderscore - : Digit - | '_' - ; - -fragment -Underscores - : '_'+ - ; - -fragment -HexNumeral - : '0' [xX] HexDigits - ; - -fragment -HexDigits - : HexDigit (HexDigitsAndUnderscores? HexDigit)? - ; - -fragment -HexDigit - : [0-9a-fA-F] - ; - -fragment -HexDigitsAndUnderscores - : HexDigitOrUnderscore+ - ; - -fragment -HexDigitOrUnderscore - : HexDigit - | '_' - ; - -fragment -OctalNumeral - : '0' Underscores? OctalDigits - ; - -fragment -OctalDigits - : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)? - ; - -fragment -OctalDigit - : [0-7] - ; - -fragment -OctalDigitsAndUnderscores - : OctalDigitOrUnderscore+ - ; - -fragment -OctalDigitOrUnderscore - : OctalDigit - | '_' - ; - -fragment -BinaryNumeral - : '0' [bB] BinaryDigits - ; - -fragment -BinaryDigits - : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)? - ; - -fragment -BinaryDigit - : [01] - ; - -fragment -BinaryDigitsAndUnderscores - : BinaryDigitOrUnderscore+ - ; - -fragment -BinaryDigitOrUnderscore - : BinaryDigit - | '_' - ; +IntegerLiteral: + DecimalIntegerLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + | BinaryIntegerLiteral +; + +fragment DecimalIntegerLiteral: DecimalNumeral IntegerTypeSuffix?; + +fragment HexIntegerLiteral: HexNumeral IntegerTypeSuffix?; + +fragment OctalIntegerLiteral: OctalNumeral IntegerTypeSuffix?; + +fragment BinaryIntegerLiteral: BinaryNumeral IntegerTypeSuffix?; + +fragment IntegerTypeSuffix: [lL]; + +fragment DecimalNumeral: '0' | NonZeroDigit (Digits? | Underscores Digits); + +fragment Digits: Digit (DigitsAndUnderscores? Digit)?; + +fragment Digit: '0' | NonZeroDigit; + +fragment NonZeroDigit: [1-9]; + +fragment DigitsAndUnderscores: DigitOrUnderscore+; + +fragment DigitOrUnderscore: Digit | '_'; + +fragment Underscores: '_'+; + +fragment HexNumeral: '0' [xX] HexDigits; + +fragment HexDigits: HexDigit (HexDigitsAndUnderscores? HexDigit)?; + +fragment HexDigit: [0-9a-fA-F]; + +fragment HexDigitsAndUnderscores: HexDigitOrUnderscore+; + +fragment HexDigitOrUnderscore: HexDigit | '_'; + +fragment OctalNumeral: '0' Underscores? OctalDigits; + +fragment OctalDigits: OctalDigit (OctalDigitsAndUnderscores? OctalDigit)?; + +fragment OctalDigit: [0-7]; + +fragment OctalDigitsAndUnderscores: OctalDigitOrUnderscore+; + +fragment OctalDigitOrUnderscore: OctalDigit | '_'; + +fragment BinaryNumeral: '0' [bB] BinaryDigits; + +fragment BinaryDigits: BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)?; + +fragment BinaryDigit: [01]; + +fragment BinaryDigitsAndUnderscores: BinaryDigitOrUnderscore+; + +fragment BinaryDigitOrUnderscore: BinaryDigit | '_'; // §3.10.2 Floating-Point Literals -FloatingPointLiteral - : DecimalFloatingPointLiteral - | HexadecimalFloatingPointLiteral - ; - -fragment -DecimalFloatingPointLiteral - : Digits '.' Digits? ExponentPart? FloatTypeSuffix? - | '.' Digits ExponentPart? FloatTypeSuffix? - | Digits ExponentPart FloatTypeSuffix? - | Digits FloatTypeSuffix - ; - -fragment -ExponentPart - : ExponentIndicator SignedInteger - ; - -fragment -ExponentIndicator - : [eE] - ; - -fragment -SignedInteger - : Sign? Digits - ; - -fragment -Sign - : [+-] - ; - -fragment -FloatTypeSuffix - : [fFdD] - ; - -fragment -HexadecimalFloatingPointLiteral - : HexSignificand BinaryExponent FloatTypeSuffix? - ; - -fragment -HexSignificand - : HexNumeral '.'? - | '0' [xX] HexDigits? '.' HexDigits - ; - -fragment -BinaryExponent - : BinaryExponentIndicator SignedInteger - ; - -fragment -BinaryExponentIndicator - : [pP] - ; +FloatingPointLiteral: DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral; + +fragment DecimalFloatingPointLiteral: + Digits '.' Digits? ExponentPart? FloatTypeSuffix? + | '.' Digits ExponentPart? FloatTypeSuffix? + | Digits ExponentPart FloatTypeSuffix? + | Digits FloatTypeSuffix +; + +fragment ExponentPart: ExponentIndicator SignedInteger; + +fragment ExponentIndicator: [eE]; + +fragment SignedInteger: Sign? Digits; + +fragment Sign: [+-]; + +fragment FloatTypeSuffix: [fFdD]; + +fragment HexadecimalFloatingPointLiteral: HexSignificand BinaryExponent FloatTypeSuffix?; + +fragment HexSignificand: HexNumeral '.'? | '0' [xX] HexDigits? '.' HexDigits; + +fragment BinaryExponent: BinaryExponentIndicator SignedInteger; + +fragment BinaryExponentIndicator: [pP]; // §3.10.3 Boolean Literals -BooleanLiteral - : 'true' - | 'false' - ; +BooleanLiteral: 'true' | 'false'; // §3.10.4 Character Literals -CharacterLiteral - : '\'' SingleCharacter '\'' - | '\'' EscapeSequence '\'' - ; +CharacterLiteral: '\'' SingleCharacter '\'' | '\'' EscapeSequence '\''; -fragment -SingleCharacter - : ~['\\\r\n] - ; +fragment SingleCharacter: ~['\\\r\n]; // §3.10.5 String Literals -StringLiteral - : '"' StringCharacters? '"' - ; +StringLiteral: '"' StringCharacters? '"'; -fragment -StringCharacters - : StringCharacter+ - ; +fragment StringCharacters: StringCharacter+; -fragment -StringCharacter - : ~["\\\r\n] - | EscapeSequence - ; +fragment StringCharacter: ~["\\\r\n] | EscapeSequence; // §3.10.6 Escape Sequences for Character and String Literals -fragment -EscapeSequence - : '\\' 'u005c'? [btnfr"'\\] - | OctalEscape - | UnicodeEscape // This is not in the spec but prevents having to preprocess the input - ; - -fragment -OctalEscape - : '\\' 'u005c'? OctalDigit - | '\\' 'u005c'? OctalDigit OctalDigit - | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit - ; - -fragment -ZeroToThree - : [0-3] - ; +fragment EscapeSequence: + '\\' 'u005c'? [btnfr"'\\] + | OctalEscape + | UnicodeEscape // This is not in the spec but prevents having to preprocess the input +; + +fragment OctalEscape: + '\\' 'u005c'? OctalDigit + | '\\' 'u005c'? OctalDigit OctalDigit + | '\\' 'u005c'? ZeroToThree OctalDigit OctalDigit +; + +fragment ZeroToThree: [0-3]; // This is not in the spec but prevents having to preprocess the input -fragment -UnicodeEscape - : '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +fragment UnicodeEscape: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit; // §3.10.7 The Null Literal -NullLiteral - : 'null' - ; +NullLiteral: 'null'; // §3.11 Separators -LPAREN : '('; -RPAREN : ')'; -LBRACE : '{'; -RBRACE : '}'; -LBRACK : '['; -RBRACK : ']'; -SEMI : ';'; -COMMA : ','; -DOT : '.'; -ELLIPSIS : '...'; -AT : '@'; +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +ELLIPSIS : '...'; +AT : '@'; COLONCOLON : '::'; - // §3.12 Operators -ASSIGN : '='; -GT : '>'; -LT : '<'; -BANG : '!'; -TILDE : '~'; +ASSIGN : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; QUESTION : '?'; -COLON : ':'; -ARROW : '->'; -EQUAL : '=='; -LE : '<='; -GE : '>='; +COLON : ':'; +ARROW : '->'; +EQUAL : '=='; +LE : '<='; +GE : '>='; NOTEQUAL : '!='; -AND : '&&'; -OR : '||'; -INC : '++'; -DEC : '--'; -ADD : '+'; -SUB : '-'; -MUL : '*'; -DIV : '/'; -BITAND : '&'; -BITOR : '|'; -CARET : '^'; -MOD : '%'; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +CARET : '^'; +MOD : '%'; //LSHIFT : '<<'; //RSHIFT : '>>'; //URSHIFT : '>>>'; -ADD_ASSIGN : '+='; -SUB_ASSIGN : '-='; -MUL_ASSIGN : '*='; -DIV_ASSIGN : '/='; -AND_ASSIGN : '&='; -OR_ASSIGN : '|='; -XOR_ASSIGN : '^='; -MOD_ASSIGN : '%='; -LSHIFT_ASSIGN : '<<='; -RSHIFT_ASSIGN : '>>='; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; URSHIFT_ASSIGN : '>>>='; // §3.8 Identifiers (must appear after all keywords in the grammar) -Identifier - : JavaLetter JavaLetterOrDigit* - ; - -fragment -JavaLetter - : [a-zA-Z$_] // these are the "java letters" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { Check1() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { Check2() }? - ; - -fragment -JavaLetterOrDigit - : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F - | // covers all characters above 0x7F which are not a surrogate - ~[\u0000-\u007F\uD800-\uDBFF] - { Check3() }? - | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { Check4() }? - ; +Identifier: JavaLetter JavaLetterOrDigit*; + +fragment JavaLetter: + [a-zA-Z$_] // these are the "java letters" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { Check1() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { Check2() }? +; + +fragment JavaLetterOrDigit: + [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F + | // covers all characters above 0x7F which are not a surrogate + ~[\u0000-\u007F\uD800-\uDBFF] { Check3() }? + | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF + [\uD800-\uDBFF] [\uDC00-\uDFFF] { Check4() }? +; // // Whitespace and comments // -WS : [ \t\r\n\u000C]+ -> skip - ; +WS: [ \t\r\n\u000C]+ -> skip; -COMMENT - : '/*' .*? '*/' -> channel(HIDDEN) - ; +COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT - : '//' ~[\r\n]* -> channel(HIDDEN) - ; +LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); \ No newline at end of file diff --git a/java/java9/Java9Parser.g4 b/java/java9/Java9Parser.g4 index 5291e38a71..3285bbbc81 100644 --- a/java/java9/Java9Parser.g4 +++ b/java/java9/Java9Parser.g4 @@ -62,11 +62,15 @@ Total lexer+parser time 3634ms. Total lexer+parser time 2497ms. */ + +// $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 Java9Parser; options { - tokenVocab = Java9Lexer; + tokenVocab = Java9Lexer; } /* @@ -74,46 +78,46 @@ options */ literal - : IntegerLiteral - | FloatingPointLiteral - | BooleanLiteral - | CharacterLiteral - | StringLiteral - | NullLiteral - ; + : IntegerLiteral + | FloatingPointLiteral + | BooleanLiteral + | CharacterLiteral + | StringLiteral + | NullLiteral + ; /* * Productions from §4 (Types, Values, and Variables) */ primitiveType - : annotation* numericType - | annotation* 'boolean' - ; + : annotation* numericType + | annotation* 'boolean' + ; numericType - : integralType - | floatingPointType - ; + : integralType + | floatingPointType + ; integralType - : 'byte' - | 'short' - | 'int' - | 'long' - | 'char' - ; + : 'byte' + | 'short' + | 'int' + | 'long' + | 'char' + ; floatingPointType - : 'float' - | 'double' - ; + : 'float' + | 'double' + ; referenceType - : classOrInterfaceType - | typeVariable - | arrayType - ; + : classOrInterfaceType + | typeVariable + | arrayType + ; /*classOrInterfaceType : classType @@ -121,310 +125,308 @@ referenceType ; */ classOrInterfaceType - : ( classType_lfno_classOrInterfaceType - | interfaceType_lfno_classOrInterfaceType - ) - ( classType_lf_classOrInterfaceType - | interfaceType_lf_classOrInterfaceType - )* - ; + : (classType_lfno_classOrInterfaceType | interfaceType_lfno_classOrInterfaceType) ( + classType_lf_classOrInterfaceType + | interfaceType_lf_classOrInterfaceType + )* + ; classType - : annotation* identifier typeArguments? - | classOrInterfaceType '.' annotation* identifier typeArguments? - ; + : annotation* identifier typeArguments? + | classOrInterfaceType '.' annotation* identifier typeArguments? + ; classType_lf_classOrInterfaceType - : '.' annotation* identifier typeArguments? - ; + : '.' annotation* identifier typeArguments? + ; classType_lfno_classOrInterfaceType - : annotation* identifier typeArguments? - ; + : annotation* identifier typeArguments? + ; interfaceType - : classType - ; + : classType + ; interfaceType_lf_classOrInterfaceType - : classType_lf_classOrInterfaceType - ; + : classType_lf_classOrInterfaceType + ; interfaceType_lfno_classOrInterfaceType - : classType_lfno_classOrInterfaceType - ; + : classType_lfno_classOrInterfaceType + ; typeVariable - : annotation* identifier - ; + : annotation* identifier + ; arrayType - : primitiveType dims - | classOrInterfaceType dims - | typeVariable dims - ; + : primitiveType dims + | classOrInterfaceType dims + | typeVariable dims + ; dims - : annotation* '[' ']' (annotation* '[' ']')* - ; + : annotation* '[' ']' (annotation* '[' ']')* + ; typeParameter - : typeParameterModifier* identifier typeBound? - ; + : typeParameterModifier* identifier typeBound? + ; typeParameterModifier - : annotation - ; + : annotation + ; typeBound - : 'extends' typeVariable - | 'extends' classOrInterfaceType additionalBound* - ; + : 'extends' typeVariable + | 'extends' classOrInterfaceType additionalBound* + ; additionalBound - : '&' interfaceType - ; + : '&' interfaceType + ; typeArguments - : '<' typeArgumentList '>' - ; + : '<' typeArgumentList '>' + ; typeArgumentList - : typeArgument (',' typeArgument)* - ; + : typeArgument (',' typeArgument)* + ; typeArgument - : referenceType - | wildcard - ; + : referenceType + | wildcard + ; wildcard - : annotation* '?' wildcardBounds? - ; + : annotation* '?' wildcardBounds? + ; wildcardBounds - : 'extends' referenceType - | 'super' referenceType - ; + : 'extends' referenceType + | 'super' referenceType + ; /* * Productions from §6 (Names) */ moduleName - : identifier - | moduleName '.' identifier - ; + : identifier + | moduleName '.' identifier + ; packageName - : identifier - | packageName '.' identifier - ; + : identifier + | packageName '.' identifier + ; typeName - : identifier - | packageOrTypeName '.' identifier - ; + : identifier + | packageOrTypeName '.' identifier + ; packageOrTypeName - : identifier - | packageOrTypeName '.' identifier - ; + : identifier + | packageOrTypeName '.' identifier + ; expressionName - : identifier - | ambiguousName '.' identifier - ; + : identifier + | ambiguousName '.' identifier + ; methodName - : identifier - ; + : identifier + ; ambiguousName - : identifier - | ambiguousName '.' identifier - ; + : identifier + | ambiguousName '.' identifier + ; /* * Productions from §7 (Packages) */ compilationUnit - : ( ordinaryCompilation | modularCompilation ) EOF - ; + : (ordinaryCompilation | modularCompilation) EOF + ; ordinaryCompilation - : packageDeclaration? importDeclaration* typeDeclaration* - ; + : packageDeclaration? importDeclaration* typeDeclaration* + ; modularCompilation - : importDeclaration* moduleDeclaration - ; + : importDeclaration* moduleDeclaration + ; packageDeclaration - : packageModifier* 'package' packageName ';' - ; + : packageModifier* 'package' packageName ';' + ; packageModifier - : annotation - ; + : annotation + ; importDeclaration - : singleTypeImportDeclaration - | typeImportOnDemandDeclaration - | singleStaticImportDeclaration - | staticImportOnDemandDeclaration - ; + : singleTypeImportDeclaration + | typeImportOnDemandDeclaration + | singleStaticImportDeclaration + | staticImportOnDemandDeclaration + ; singleTypeImportDeclaration - : 'import' typeName ';' - ; + : 'import' typeName ';' + ; typeImportOnDemandDeclaration - : 'import' packageOrTypeName '.' '*' ';' - ; + : 'import' packageOrTypeName '.' '*' ';' + ; singleStaticImportDeclaration - : 'import' 'static' typeName '.' identifier ';' - ; + : 'import' 'static' typeName '.' identifier ';' + ; staticImportOnDemandDeclaration - : 'import' 'static' typeName '.' '*' ';' - ; + : 'import' 'static' typeName '.' '*' ';' + ; typeDeclaration - : classDeclaration - | interfaceDeclaration - | ';' - ; + : classDeclaration + | interfaceDeclaration + | ';' + ; moduleDeclaration - : annotation* 'open'? 'module' moduleName '{' moduleDirective* '}' - ; + : annotation* 'open'? 'module' moduleName '{' moduleDirective* '}' + ; moduleDirective - : 'requires' requiresModifier* moduleName ';' - | 'exports' packageName ('to' moduleName (',' moduleName)*)? ';' - | 'opens' packageName ('to' moduleName (',' moduleName)*)? ';' - | 'uses' typeName ';' - | 'provides' typeName 'with' typeName (',' typeName)* ';' - ; + : 'requires' requiresModifier* moduleName ';' + | 'exports' packageName ('to' moduleName (',' moduleName)*)? ';' + | 'opens' packageName ('to' moduleName (',' moduleName)*)? ';' + | 'uses' typeName ';' + | 'provides' typeName 'with' typeName (',' typeName)* ';' + ; requiresModifier - : 'transitive' - | 'static' - ; + : 'transitive' + | 'static' + ; /* * Productions from §8 (Classes) */ classDeclaration - : normalClassDeclaration - | enumDeclaration - ; + : normalClassDeclaration + | enumDeclaration + ; normalClassDeclaration - : classModifier* 'class' identifier typeParameters? superclass? superinterfaces? classBody - ; + : classModifier* 'class' identifier typeParameters? superclass? superinterfaces? classBody + ; classModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'final' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'final' + | 'strictfp' + ; typeParameters - : '<' typeParameterList '>' - ; + : '<' typeParameterList '>' + ; typeParameterList - : typeParameter (',' typeParameter)* - ; + : typeParameter (',' typeParameter)* + ; superclass - : 'extends' classType - ; + : 'extends' classType + ; superinterfaces - : 'implements' interfaceTypeList - ; + : 'implements' interfaceTypeList + ; interfaceTypeList - : interfaceType (',' interfaceType)* - ; + : interfaceType (',' interfaceType)* + ; classBody - : '{' classBodyDeclaration* '}' - ; + : '{' classBodyDeclaration* '}' + ; classBodyDeclaration - : classMemberDeclaration - | instanceInitializer - | staticInitializer - | constructorDeclaration - ; + : classMemberDeclaration + | instanceInitializer + | staticInitializer + | constructorDeclaration + ; classMemberDeclaration - : fieldDeclaration - | methodDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; + : fieldDeclaration + | methodDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; fieldDeclaration - : fieldModifier* unannType variableDeclaratorList ';' - ; + : fieldModifier* unannType variableDeclaratorList ';' + ; fieldModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'static' - | 'final' - | 'transient' - | 'volatile' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'static' + | 'final' + | 'transient' + | 'volatile' + ; variableDeclaratorList - : variableDeclarator (',' variableDeclarator)* - ; + : variableDeclarator (',' variableDeclarator)* + ; variableDeclarator - : variableDeclaratorId ('=' variableInitializer)? - ; + : variableDeclaratorId ('=' variableInitializer)? + ; variableDeclaratorId - : identifier dims? - ; + : identifier dims? + ; variableInitializer - : expression - | arrayInitializer - ; + : expression + | arrayInitializer + ; unannType - : unannPrimitiveType - | unannReferenceType - ; + : unannPrimitiveType + | unannReferenceType + ; unannPrimitiveType - : numericType - | 'boolean' - ; + : numericType + | 'boolean' + ; unannReferenceType - : unannClassOrInterfaceType - | unannTypeVariable - | unannArrayType - ; + : unannClassOrInterfaceType + | unannTypeVariable + | unannArrayType + ; /*unannClassOrInterfaceType : unannClassType @@ -433,580 +435,581 @@ unannReferenceType */ unannClassOrInterfaceType - : ( unannClassType_lfno_unannClassOrInterfaceType - | unannInterfaceType_lfno_unannClassOrInterfaceType - ) - ( unannClassType_lf_unannClassOrInterfaceType - | unannInterfaceType_lf_unannClassOrInterfaceType - )* - ; + : ( + unannClassType_lfno_unannClassOrInterfaceType + | unannInterfaceType_lfno_unannClassOrInterfaceType + ) ( + unannClassType_lf_unannClassOrInterfaceType + | unannInterfaceType_lf_unannClassOrInterfaceType + )* + ; unannClassType - : identifier typeArguments? - | unannClassOrInterfaceType '.' annotation* identifier typeArguments? - ; + : identifier typeArguments? + | unannClassOrInterfaceType '.' annotation* identifier typeArguments? + ; unannClassType_lf_unannClassOrInterfaceType - : '.' annotation* identifier typeArguments? - ; + : '.' annotation* identifier typeArguments? + ; unannClassType_lfno_unannClassOrInterfaceType - : identifier typeArguments? - ; + : identifier typeArguments? + ; unannInterfaceType - : unannClassType - ; + : unannClassType + ; unannInterfaceType_lf_unannClassOrInterfaceType - : unannClassType_lf_unannClassOrInterfaceType - ; + : unannClassType_lf_unannClassOrInterfaceType + ; unannInterfaceType_lfno_unannClassOrInterfaceType - : unannClassType_lfno_unannClassOrInterfaceType - ; + : unannClassType_lfno_unannClassOrInterfaceType + ; unannTypeVariable - : identifier - ; + : identifier + ; unannArrayType - : unannPrimitiveType dims - | unannClassOrInterfaceType dims - | unannTypeVariable dims - ; + : unannPrimitiveType dims + | unannClassOrInterfaceType dims + | unannTypeVariable dims + ; methodDeclaration - : methodModifier* methodHeader methodBody - ; + : methodModifier* methodHeader methodBody + ; methodModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'final' - | 'synchronized' - | 'native' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'final' + | 'synchronized' + | 'native' + | 'strictfp' + ; methodHeader - : result methodDeclarator throws_? - | typeParameters annotation* result methodDeclarator throws_? - ; + : result methodDeclarator throws_? + | typeParameters annotation* result methodDeclarator throws_? + ; result - : unannType - | 'void' - ; + : unannType + | 'void' + ; methodDeclarator - : identifier '(' formalParameterList? ')' dims? - ; + : identifier '(' formalParameterList? ')' dims? + ; formalParameterList - : formalParameters ',' lastFormalParameter - | lastFormalParameter - | receiverParameter - ; + : formalParameters ',' lastFormalParameter + | lastFormalParameter + | receiverParameter + ; formalParameters - : formalParameter (',' formalParameter)* - | receiverParameter (',' formalParameter)* - ; + : formalParameter (',' formalParameter)* + | receiverParameter (',' formalParameter)* + ; formalParameter - : variableModifier* unannType variableDeclaratorId - ; + : variableModifier* unannType variableDeclaratorId + ; variableModifier - : annotation - | 'final' - ; + : annotation + | 'final' + ; lastFormalParameter - : variableModifier* unannType annotation* '...' variableDeclaratorId - | formalParameter - ; + : variableModifier* unannType annotation* '...' variableDeclaratorId + | formalParameter + ; receiverParameter - : annotation* unannType (identifier '.')? 'this' - ; + : annotation* unannType (identifier '.')? 'this' + ; throws_ - : 'throws' exceptionTypeList - ; + : 'throws' exceptionTypeList + ; exceptionTypeList - : exceptionType (',' exceptionType)* - ; + : exceptionType (',' exceptionType)* + ; exceptionType - : classType - | typeVariable - ; + : classType + | typeVariable + ; methodBody - : block - | ';' - ; + : block + | ';' + ; instanceInitializer - : block - ; + : block + ; staticInitializer - : 'static' block - ; + : 'static' block + ; constructorDeclaration - : constructorModifier* constructorDeclarator throws_? constructorBody - ; + : constructorModifier* constructorDeclarator throws_? constructorBody + ; constructorModifier - : annotation - | 'public' - | 'protected' - | 'private' - ; + : annotation + | 'public' + | 'protected' + | 'private' + ; constructorDeclarator - : typeParameters? simpleTypeName '(' formalParameterList? ')' - ; + : typeParameters? simpleTypeName '(' formalParameterList? ')' + ; simpleTypeName - : identifier - ; + : identifier + ; constructorBody - : '{' explicitConstructorInvocation? blockStatements? '}' - ; + : '{' explicitConstructorInvocation? blockStatements? '}' + ; explicitConstructorInvocation - : typeArguments? 'this' '(' argumentList? ')' ';' - | typeArguments? 'super' '(' argumentList? ')' ';' - | expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';' - | primary '.' typeArguments? 'super' '(' argumentList? ')' ';' - ; + : typeArguments? 'this' '(' argumentList? ')' ';' + | typeArguments? 'super' '(' argumentList? ')' ';' + | expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';' + | primary '.' typeArguments? 'super' '(' argumentList? ')' ';' + ; enumDeclaration - : classModifier* 'enum' identifier superinterfaces? enumBody - ; + : classModifier* 'enum' identifier superinterfaces? enumBody + ; enumBody - : '{' enumConstantList? ','? enumBodyDeclarations? '}' - ; + : '{' enumConstantList? ','? enumBodyDeclarations? '}' + ; enumConstantList - : enumConstant (',' enumConstant)* - ; + : enumConstant (',' enumConstant)* + ; enumConstant - : enumConstantModifier* identifier ('(' argumentList? ')')? classBody? - ; + : enumConstantModifier* identifier ('(' argumentList? ')')? classBody? + ; enumConstantModifier - : annotation - ; + : annotation + ; enumBodyDeclarations - : ';' classBodyDeclaration* - ; + : ';' classBodyDeclaration* + ; /* * Productions from §9 (Interfaces) */ interfaceDeclaration - : normalInterfaceDeclaration - | annotationTypeDeclaration - ; + : normalInterfaceDeclaration + | annotationTypeDeclaration + ; normalInterfaceDeclaration - : interfaceModifier* 'interface' identifier typeParameters? extendsInterfaces? interfaceBody - ; + : interfaceModifier* 'interface' identifier typeParameters? extendsInterfaces? interfaceBody + ; interfaceModifier - : annotation - | 'public' - | 'protected' - | 'private' - | 'abstract' - | 'static' - | 'strictfp' - ; + : annotation + | 'public' + | 'protected' + | 'private' + | 'abstract' + | 'static' + | 'strictfp' + ; extendsInterfaces - : 'extends' interfaceTypeList - ; + : 'extends' interfaceTypeList + ; interfaceBody - : '{' interfaceMemberDeclaration* '}' - ; + : '{' interfaceMemberDeclaration* '}' + ; interfaceMemberDeclaration - : constantDeclaration - | interfaceMethodDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; + : constantDeclaration + | interfaceMethodDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; constantDeclaration - : constantModifier* unannType variableDeclaratorList ';' - ; + : constantModifier* unannType variableDeclaratorList ';' + ; constantModifier - : annotation - | 'public' - | 'static' - | 'final' - ; + : annotation + | 'public' + | 'static' + | 'final' + ; interfaceMethodDeclaration - : interfaceMethodModifier* methodHeader methodBody - ; + : interfaceMethodModifier* methodHeader methodBody + ; interfaceMethodModifier - : annotation - | 'public' - | 'private'//Introduced in Java 9 - | 'abstract' - | 'default' - | 'static' - | 'strictfp' - ; + : annotation + | 'public' + | 'private' //Introduced in Java 9 + | 'abstract' + | 'default' + | 'static' + | 'strictfp' + ; annotationTypeDeclaration - : interfaceModifier* '@' 'interface' identifier annotationTypeBody - ; + : interfaceModifier* '@' 'interface' identifier annotationTypeBody + ; annotationTypeBody - : '{' annotationTypeMemberDeclaration* '}' - ; + : '{' annotationTypeMemberDeclaration* '}' + ; annotationTypeMemberDeclaration - : annotationTypeElementDeclaration - | constantDeclaration - | classDeclaration - | interfaceDeclaration - | ';' - ; + : annotationTypeElementDeclaration + | constantDeclaration + | classDeclaration + | interfaceDeclaration + | ';' + ; annotationTypeElementDeclaration - : annotationTypeElementModifier* unannType identifier '(' ')' dims? defaultValue? ';' - ; + : annotationTypeElementModifier* unannType identifier '(' ')' dims? defaultValue? ';' + ; annotationTypeElementModifier - : annotation - | 'public' - | 'abstract' - ; + : annotation + | 'public' + | 'abstract' + ; defaultValue - : 'default' elementValue - ; + : 'default' elementValue + ; annotation - : normalAnnotation - | markerAnnotation - | singleElementAnnotation - ; + : normalAnnotation + | markerAnnotation + | singleElementAnnotation + ; normalAnnotation - : '@' typeName '(' elementValuePairList? ')' - ; + : '@' typeName '(' elementValuePairList? ')' + ; elementValuePairList - : elementValuePair (',' elementValuePair)* - ; + : elementValuePair (',' elementValuePair)* + ; elementValuePair - : identifier '=' elementValue - ; + : identifier '=' elementValue + ; elementValue - : conditionalExpression - | elementValueArrayInitializer - | annotation - ; + : conditionalExpression + | elementValueArrayInitializer + | annotation + ; elementValueArrayInitializer - : '{' elementValueList? ','? '}' - ; + : '{' elementValueList? ','? '}' + ; elementValueList - : elementValue (',' elementValue)* - ; + : elementValue (',' elementValue)* + ; markerAnnotation - : '@' typeName - ; + : '@' typeName + ; singleElementAnnotation - : '@' typeName '(' elementValue ')' - ; + : '@' typeName '(' elementValue ')' + ; /* * Productions from §10 (Arrays) */ arrayInitializer - : '{' variableInitializerList? ','? '}' - ; + : '{' variableInitializerList? ','? '}' + ; variableInitializerList - : variableInitializer (',' variableInitializer)* - ; + : variableInitializer (',' variableInitializer)* + ; /* * Productions from §14 (Blocks and Statements) */ block - : '{' blockStatements? '}' - ; + : '{' blockStatements? '}' + ; blockStatements - : blockStatement+ - ; + : blockStatement+ + ; blockStatement - : localVariableDeclarationStatement - | classDeclaration - | statement - ; + : localVariableDeclarationStatement + | classDeclaration + | statement + ; localVariableDeclarationStatement - : localVariableDeclaration ';' - ; + : localVariableDeclaration ';' + ; localVariableDeclaration - : variableModifier* unannType variableDeclaratorList - ; + : variableModifier* unannType variableDeclaratorList + ; statement - : statementWithoutTrailingSubstatement - | labeledStatement - | ifThenStatement - | ifThenElseStatement - | whileStatement - | forStatement - ; + : statementWithoutTrailingSubstatement + | labeledStatement + | ifThenStatement + | ifThenElseStatement + | whileStatement + | forStatement + ; statementNoShortIf - : statementWithoutTrailingSubstatement - | labeledStatementNoShortIf - | ifThenElseStatementNoShortIf - | whileStatementNoShortIf - | forStatementNoShortIf - ; + : statementWithoutTrailingSubstatement + | labeledStatementNoShortIf + | ifThenElseStatementNoShortIf + | whileStatementNoShortIf + | forStatementNoShortIf + ; statementWithoutTrailingSubstatement - : block - | emptyStatement_ - | expressionStatement - | assertStatement - | switchStatement - | doStatement - | breakStatement - | continueStatement - | returnStatement - | synchronizedStatement - | throwStatement - | tryStatement - ; + : block + | emptyStatement_ + | expressionStatement + | assertStatement + | switchStatement + | doStatement + | breakStatement + | continueStatement + | returnStatement + | synchronizedStatement + | throwStatement + | tryStatement + ; emptyStatement_ - : ';' - ; + : ';' + ; labeledStatement - : identifier ':' statement - ; + : identifier ':' statement + ; labeledStatementNoShortIf - : identifier ':' statementNoShortIf - ; + : identifier ':' statementNoShortIf + ; expressionStatement - : statementExpression ';' - ; + : statementExpression ';' + ; statementExpression - : assignment - | preIncrementExpression - | preDecrementExpression - | postIncrementExpression - | postDecrementExpression - | methodInvocation - | classInstanceCreationExpression - ; + : assignment + | preIncrementExpression + | preDecrementExpression + | postIncrementExpression + | postDecrementExpression + | methodInvocation + | classInstanceCreationExpression + ; ifThenStatement - : 'if' '(' expression ')' statement - ; + : 'if' '(' expression ')' statement + ; ifThenElseStatement - : 'if' '(' expression ')' statementNoShortIf 'else' statement - ; + : 'if' '(' expression ')' statementNoShortIf 'else' statement + ; ifThenElseStatementNoShortIf - : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf - ; + : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf + ; assertStatement - : 'assert' expression ';' - | 'assert' expression ':' expression ';' - ; + : 'assert' expression ';' + | 'assert' expression ':' expression ';' + ; switchStatement - : 'switch' '(' expression ')' switchBlock - ; + : 'switch' '(' expression ')' switchBlock + ; switchBlock - : '{' switchBlockStatementGroup* switchLabel* '}' - ; + : '{' switchBlockStatementGroup* switchLabel* '}' + ; switchBlockStatementGroup - : switchLabels blockStatements - ; + : switchLabels blockStatements + ; switchLabels - : switchLabel+ - ; + : switchLabel+ + ; switchLabel - : 'case' constantExpression ':' - | 'case' enumConstantName ':' - | 'default' ':' - ; + : 'case' constantExpression ':' + | 'case' enumConstantName ':' + | 'default' ':' + ; enumConstantName - : identifier - ; + : identifier + ; whileStatement - : 'while' '(' expression ')' statement - ; + : 'while' '(' expression ')' statement + ; whileStatementNoShortIf - : 'while' '(' expression ')' statementNoShortIf - ; + : 'while' '(' expression ')' statementNoShortIf + ; doStatement - : 'do' statement 'while' '(' expression ')' ';' - ; + : 'do' statement 'while' '(' expression ')' ';' + ; forStatement - : basicForStatement - | enhancedForStatement - ; + : basicForStatement + | enhancedForStatement + ; forStatementNoShortIf - : basicForStatementNoShortIf - | enhancedForStatementNoShortIf - ; + : basicForStatementNoShortIf + | enhancedForStatementNoShortIf + ; basicForStatement - : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement - ; + : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement + ; basicForStatementNoShortIf - : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf - ; + : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf + ; forInit - : statementExpressionList - | localVariableDeclaration - ; + : statementExpressionList + | localVariableDeclaration + ; forUpdate - : statementExpressionList - ; + : statementExpressionList + ; statementExpressionList - : statementExpression (',' statementExpression)* - ; + : statementExpression (',' statementExpression)* + ; enhancedForStatement - : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement - ; + : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement + ; enhancedForStatementNoShortIf - : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf - ; + : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf + ; breakStatement - : 'break' identifier? ';' - ; + : 'break' identifier? ';' + ; continueStatement - : 'continue' identifier? ';' - ; + : 'continue' identifier? ';' + ; returnStatement - : 'return' expression? ';' - ; + : 'return' expression? ';' + ; throwStatement - : 'throw' expression ';' - ; + : 'throw' expression ';' + ; synchronizedStatement - : 'synchronized' '(' expression ')' block - ; + : 'synchronized' '(' expression ')' block + ; tryStatement - : 'try' block catches - | 'try' block catches? finally_ - | tryWithResourcesStatement - ; + : 'try' block catches + | 'try' block catches? finally_ + | tryWithResourcesStatement + ; catches - : catchClause+ - ; + : catchClause+ + ; catchClause - : 'catch' '(' catchFormalParameter ')' block - ; + : 'catch' '(' catchFormalParameter ')' block + ; catchFormalParameter - : variableModifier* catchType variableDeclaratorId - ; + : variableModifier* catchType variableDeclaratorId + ; catchType - : unannClassType ('|' classType)* - ; + : unannClassType ('|' classType)* + ; finally_ - : 'finally' block - ; + : 'finally' block + ; tryWithResourcesStatement - : 'try' resourceSpecification block catches? finally_? - ; + : 'try' resourceSpecification block catches? finally_? + ; resourceSpecification - : '(' resourceList ';'? ')' - ; + : '(' resourceList ';'? ')' + ; resourceList - : resource (';' resource)* - ; + : resource (';' resource)* + ; resource - : variableModifier* unannType variableDeclaratorId '=' expression - | variableAccess//Introduced in Java 9 - ; + : variableModifier* unannType variableDeclaratorId '=' expression + | variableAccess //Introduced in Java 9 + ; variableAccess - : expressionName - | fieldAccess - ; + : expressionName + | fieldAccess + ; /* * Productions from §15 (Expressions) @@ -1019,133 +1022,130 @@ variableAccess */ primary - : ( primaryNoNewArray_lfno_primary - | arrayCreationExpression - ) - primaryNoNewArray_lf_primary* - ; + : (primaryNoNewArray_lfno_primary | arrayCreationExpression) primaryNoNewArray_lf_primary* + ; primaryNoNewArray - : literal - | classLiteral - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression - | fieldAccess - | arrayAccess - | methodInvocation - | methodReference - ; + : literal + | classLiteral + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression + | fieldAccess + | arrayAccess + | methodInvocation + | methodReference + ; primaryNoNewArray_lf_arrayAccess - : - ; + : + ; primaryNoNewArray_lfno_arrayAccess - : literal - | typeName ('[' ']')* '.' 'class' - | 'void' '.' 'class' - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression - | fieldAccess - | methodInvocation - | methodReference - ; + : literal + | typeName ('[' ']')* '.' 'class' + | 'void' '.' 'class' + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression + | fieldAccess + | methodInvocation + | methodReference + ; primaryNoNewArray_lf_primary - : classInstanceCreationExpression_lf_primary - | fieldAccess_lf_primary - | arrayAccess_lf_primary - | methodInvocation_lf_primary - | methodReference_lf_primary - ; + : classInstanceCreationExpression_lf_primary + | fieldAccess_lf_primary + | arrayAccess_lf_primary + | methodInvocation_lf_primary + | methodReference_lf_primary + ; primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary - : - ; + : + ; primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary - : classInstanceCreationExpression_lf_primary - | fieldAccess_lf_primary - | methodInvocation_lf_primary - | methodReference_lf_primary - ; + : classInstanceCreationExpression_lf_primary + | fieldAccess_lf_primary + | methodInvocation_lf_primary + | methodReference_lf_primary + ; primaryNoNewArray_lfno_primary - : literal - | typeName ('[' ']')* '.' 'class' - | unannPrimitiveType ('[' ']')* '.' 'class' - | 'void' '.' 'class' - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression_lfno_primary - | fieldAccess_lfno_primary - | arrayAccess_lfno_primary - | methodInvocation_lfno_primary - | methodReference_lfno_primary - ; + : literal + | typeName ('[' ']')* '.' 'class' + | unannPrimitiveType ('[' ']')* '.' 'class' + | 'void' '.' 'class' + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression_lfno_primary + | fieldAccess_lfno_primary + | arrayAccess_lfno_primary + | methodInvocation_lfno_primary + | methodReference_lfno_primary + ; primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary - : - ; + : + ; primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary - : literal - | typeName ('[' ']')* '.' 'class' - | unannPrimitiveType ('[' ']')* '.' 'class' - | 'void' '.' 'class' - | 'this' - | typeName '.' 'this' - | '(' expression ')' - | classInstanceCreationExpression_lfno_primary - | fieldAccess_lfno_primary - | methodInvocation_lfno_primary - | methodReference_lfno_primary - ; + : literal + | typeName ('[' ']')* '.' 'class' + | unannPrimitiveType ('[' ']')* '.' 'class' + | 'void' '.' 'class' + | 'this' + | typeName '.' 'this' + | '(' expression ')' + | classInstanceCreationExpression_lfno_primary + | fieldAccess_lfno_primary + | methodInvocation_lfno_primary + | methodReference_lfno_primary + ; classLiteral - : (typeName|numericType|'boolean') ('[' ']')* '.' 'class' - | 'void' '.' 'class' - ; + : (typeName | numericType | 'boolean') ('[' ']')* '.' 'class' + | 'void' '.' 'class' + ; classInstanceCreationExpression - : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - | primary '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - ; + : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + | primary '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + ; classInstanceCreationExpression_lf_primary - : '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - ; + : '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + ; classInstanceCreationExpression_lfno_primary - : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? - ; + : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? + ; typeArgumentsOrDiamond - : typeArguments - | '<' '>' - ; + : typeArguments + | '<' '>' + ; fieldAccess - : primary '.' identifier - | 'super' '.' identifier - | typeName '.' 'super' '.' identifier - ; + : primary '.' identifier + | 'super' '.' identifier + | typeName '.' 'super' '.' identifier + ; fieldAccess_lf_primary - : '.' identifier - ; + : '.' identifier + ; fieldAccess_lfno_primary - : 'super' '.' identifier - | typeName '.' 'super' '.' identifier - ; + : 'super' '.' identifier + | typeName '.' 'super' '.' identifier + ; /*arrayAccess : expressionName '[' expression ']' @@ -1154,236 +1154,232 @@ fieldAccess_lfno_primary */ arrayAccess - : ( expressionName '[' expression ']' - | primaryNoNewArray_lfno_arrayAccess '[' expression ']' - ) - ( primaryNoNewArray_lf_arrayAccess '[' expression ']' - )* - ; + : (expressionName '[' expression ']' | primaryNoNewArray_lfno_arrayAccess '[' expression ']') ( + primaryNoNewArray_lf_arrayAccess '[' expression ']' + )* + ; arrayAccess_lf_primary - : primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']' - ( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']' - )* - ; + : primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']' ( + primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']' + )* + ; arrayAccess_lfno_primary - : ( expressionName '[' expression ']' - | primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']' - ) - ( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']' - )* - ; - + : ( + expressionName '[' expression ']' + | primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']' + ) (primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']')* + ; methodInvocation - : methodName '(' argumentList? ')' - | typeName '.' typeArguments? identifier '(' argumentList? ')' - | expressionName '.' typeArguments? identifier '(' argumentList? ')' - | primary '.' typeArguments? identifier '(' argumentList? ')' - | 'super' '.' typeArguments? identifier '(' argumentList? ')' - | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' - ; + : methodName '(' argumentList? ')' + | typeName '.' typeArguments? identifier '(' argumentList? ')' + | expressionName '.' typeArguments? identifier '(' argumentList? ')' + | primary '.' typeArguments? identifier '(' argumentList? ')' + | 'super' '.' typeArguments? identifier '(' argumentList? ')' + | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' + ; methodInvocation_lf_primary - : '.' typeArguments? identifier '(' argumentList? ')' - ; + : '.' typeArguments? identifier '(' argumentList? ')' + ; methodInvocation_lfno_primary - : methodName '(' argumentList? ')' - | typeName '.' typeArguments? identifier '(' argumentList? ')' - | expressionName '.' typeArguments? identifier '(' argumentList? ')' - | 'super' '.' typeArguments? identifier '(' argumentList? ')' - | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' - ; + : methodName '(' argumentList? ')' + | typeName '.' typeArguments? identifier '(' argumentList? ')' + | expressionName '.' typeArguments? identifier '(' argumentList? ')' + | 'super' '.' typeArguments? identifier '(' argumentList? ')' + | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' + ; argumentList - : expression (',' expression)* - ; + : expression (',' expression)* + ; methodReference - : expressionName '::' typeArguments? identifier - | referenceType '::' typeArguments? identifier - | primary '::' typeArguments? identifier - | 'super' '::' typeArguments? identifier - | typeName '.' 'super' '::' typeArguments? identifier - | classType '::' typeArguments? 'new' - | arrayType '::' 'new' - ; + : expressionName '::' typeArguments? identifier + | referenceType '::' typeArguments? identifier + | primary '::' typeArguments? identifier + | 'super' '::' typeArguments? identifier + | typeName '.' 'super' '::' typeArguments? identifier + | classType '::' typeArguments? 'new' + | arrayType '::' 'new' + ; methodReference_lf_primary - : '::' typeArguments? identifier - ; + : '::' typeArguments? identifier + ; methodReference_lfno_primary - : expressionName '::' typeArguments? identifier - | referenceType '::' typeArguments? identifier - | 'super' '::' typeArguments? identifier - | typeName '.' 'super' '::' typeArguments? identifier - | classType '::' typeArguments? 'new' - | arrayType '::' 'new' - ; + : expressionName '::' typeArguments? identifier + | referenceType '::' typeArguments? identifier + | 'super' '::' typeArguments? identifier + | typeName '.' 'super' '::' typeArguments? identifier + | classType '::' typeArguments? 'new' + | arrayType '::' 'new' + ; arrayCreationExpression - : 'new' primitiveType dimExprs dims? - | 'new' classOrInterfaceType dimExprs dims? - | 'new' primitiveType dims arrayInitializer - | 'new' classOrInterfaceType dims arrayInitializer - ; + : 'new' primitiveType dimExprs dims? + | 'new' classOrInterfaceType dimExprs dims? + | 'new' primitiveType dims arrayInitializer + | 'new' classOrInterfaceType dims arrayInitializer + ; dimExprs - : dimExpr+ - ; + : dimExpr+ + ; dimExpr - : annotation* '[' expression ']' - ; + : annotation* '[' expression ']' + ; constantExpression - : expression - ; + : expression + ; expression - : lambdaExpression - | assignmentExpression - ; + : lambdaExpression + | assignmentExpression + ; lambdaExpression - : lambdaParameters '->' lambdaBody - ; + : lambdaParameters '->' lambdaBody + ; lambdaParameters - : identifier - | '(' formalParameterList? ')' - | '(' inferredFormalParameterList ')' - ; + : identifier + | '(' formalParameterList? ')' + | '(' inferredFormalParameterList ')' + ; inferredFormalParameterList - : identifier (',' identifier)* - ; + : identifier (',' identifier)* + ; lambdaBody - : expression - | block - ; + : expression + | block + ; assignmentExpression - : conditionalExpression - | assignment - ; + : conditionalExpression + | assignment + ; assignment - : leftHandSide assignmentOperator expression - ; + : leftHandSide assignmentOperator expression + ; leftHandSide - : expressionName - | fieldAccess - | arrayAccess - ; + : expressionName + | fieldAccess + | arrayAccess + ; assignmentOperator - : '=' - | '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '=' + | '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; conditionalExpression - : conditionalOrExpression - | conditionalOrExpression '?' expression ':' (conditionalExpression|lambdaExpression) - ; + : conditionalOrExpression + | conditionalOrExpression '?' expression ':' (conditionalExpression | lambdaExpression) + ; conditionalOrExpression - : conditionalAndExpression - | conditionalOrExpression '||' conditionalAndExpression - ; + : conditionalAndExpression + | conditionalOrExpression '||' conditionalAndExpression + ; conditionalAndExpression - : inclusiveOrExpression - | conditionalAndExpression '&&' inclusiveOrExpression - ; + : inclusiveOrExpression + | conditionalAndExpression '&&' inclusiveOrExpression + ; inclusiveOrExpression - : exclusiveOrExpression - | inclusiveOrExpression '|' exclusiveOrExpression - ; + : exclusiveOrExpression + | inclusiveOrExpression '|' exclusiveOrExpression + ; exclusiveOrExpression - : andExpression - | exclusiveOrExpression '^' andExpression - ; + : andExpression + | exclusiveOrExpression '^' andExpression + ; andExpression - : equalityExpression - | andExpression '&' equalityExpression - ; + : equalityExpression + | andExpression '&' equalityExpression + ; equalityExpression - : relationalExpression - | equalityExpression '==' relationalExpression - | equalityExpression '!=' relationalExpression - ; + : relationalExpression + | equalityExpression '==' relationalExpression + | equalityExpression '!=' relationalExpression + ; relationalExpression - : shiftExpression - | relationalExpression '<' shiftExpression - | relationalExpression '>' shiftExpression - | relationalExpression '<=' shiftExpression - | relationalExpression '>=' shiftExpression - | relationalExpression 'instanceof' referenceType - ; + : shiftExpression + | relationalExpression '<' shiftExpression + | relationalExpression '>' shiftExpression + | relationalExpression '<=' shiftExpression + | relationalExpression '>=' shiftExpression + | relationalExpression 'instanceof' referenceType + ; shiftExpression - : additiveExpression - | shiftExpression '<' '<' additiveExpression - | shiftExpression '>' '>' additiveExpression - | shiftExpression '>' '>' '>' additiveExpression - ; + : additiveExpression + | shiftExpression '<' '<' additiveExpression + | shiftExpression '>' '>' additiveExpression + | shiftExpression '>' '>' '>' additiveExpression + ; additiveExpression - : multiplicativeExpression - | additiveExpression '+' multiplicativeExpression - | additiveExpression '-' multiplicativeExpression - ; + : multiplicativeExpression + | additiveExpression '+' multiplicativeExpression + | additiveExpression '-' multiplicativeExpression + ; multiplicativeExpression - : unaryExpression - | multiplicativeExpression '*' unaryExpression - | multiplicativeExpression '/' unaryExpression - | multiplicativeExpression '%' unaryExpression - ; + : unaryExpression + | multiplicativeExpression '*' unaryExpression + | multiplicativeExpression '/' unaryExpression + | multiplicativeExpression '%' unaryExpression + ; unaryExpression - : preIncrementExpression - | preDecrementExpression - | '+' unaryExpression - | '-' unaryExpression - | unaryExpressionNotPlusMinus - ; + : preIncrementExpression + | preDecrementExpression + | '+' unaryExpression + | '-' unaryExpression + | unaryExpressionNotPlusMinus + ; preIncrementExpression - : '++' unaryExpression - ; + : '++' unaryExpression + ; preDecrementExpression - : '--' unaryExpression - ; + : '--' unaryExpression + ; unaryExpressionNotPlusMinus - : postfixExpression - | '~' unaryExpression - | '!' unaryExpression - | castExpression - ; + : postfixExpression + | '~' unaryExpression + | '!' unaryExpression + | castExpression + ; /*postfixExpression : primary @@ -1394,35 +1390,43 @@ unaryExpressionNotPlusMinus */ postfixExpression - : ( primary - | expressionName - ) - ( postIncrementExpression_lf_postfixExpression - | postDecrementExpression_lf_postfixExpression - )* - ; + : (primary | expressionName) ( + postIncrementExpression_lf_postfixExpression + | postDecrementExpression_lf_postfixExpression + )* + ; postIncrementExpression - : postfixExpression '++' - ; + : postfixExpression '++' + ; postIncrementExpression_lf_postfixExpression - : '++' - ; + : '++' + ; postDecrementExpression - : postfixExpression '--' - ; + : postfixExpression '--' + ; postDecrementExpression_lf_postfixExpression - : '--' - ; + : '--' + ; castExpression - : '(' primitiveType ')' unaryExpression - | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus - | '(' referenceType additionalBound* ')' lambdaExpression - ; - -identifier : Identifier | 'to' | 'module' | 'open' | 'with' | 'provides' | 'uses' | 'opens' | 'requires' | 'exports'; - + : '(' primitiveType ')' unaryExpression + | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus + | '(' referenceType additionalBound* ')' lambdaExpression + ; + +identifier + : Identifier + | 'to' + | 'module' + | 'open' + | 'with' + | 'provides' + | 'uses' + | 'opens' + | 'requires' + | 'exports' + ; \ No newline at end of file diff --git a/javadoc/JavadocLexer.g4 b/javadoc/JavadocLexer.g4 index 2cde3f3ab0..1898d1e01a 100644 --- a/javadoc/JavadocLexer.g4 +++ b/javadoc/JavadocLexer.g4 @@ -26,54 +26,36 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar JavadocLexer; -NAME - : [a-zA-Z]+ - ; +NAME: [a-zA-Z]+; -NEWLINE - : '\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)? - | '\r\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)? - | '\r' (SPACE? (STAR {_input.LA(1) != '/'}?)+)? - ; +NEWLINE: + '\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)? + | '\r\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)? + | '\r' (SPACE? (STAR {_input.LA(1) != '/'}?)+)? +; -SPACE - : (' '|'\t')+ - ; +SPACE: (' ' | '\t')+; -TEXT_CONTENT - : ~[\n\r\t @*{}/a-zA-Z]+ - ; +TEXT_CONTENT: ~[\n\r\t @*{}/a-zA-Z]+; -AT - : '@' - ; +AT: '@'; -STAR - : '*' - ; +STAR: '*'; -SLASH - : '/' - ; +SLASH: '/'; -JAVADOC_START - : '/**' STAR* - ; +JAVADOC_START: '/**' STAR*; -JAVADOC_END - : SPACE? STAR* '*/' - ; +JAVADOC_END: SPACE? STAR* '*/'; -INLINE_TAG_START - : '{@' - ; +INLINE_TAG_START: '{@'; -BRACE_OPEN - : '{' - ; +BRACE_OPEN: '{'; -BRACE_CLOSE - : '}' - ; +BRACE_CLOSE: '}'; \ No newline at end of file diff --git a/javadoc/JavadocParser.g4 b/javadoc/JavadocParser.g4 index 5027e5b43f..08b26114d6 100644 --- a/javadoc/JavadocParser.g4 +++ b/javadoc/JavadocParser.g4 @@ -26,124 +26,125 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -parser grammar JavadocParser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab=JavadocLexer; } +parser grammar JavadocParser; +options { + tokenVocab = JavadocLexer; +} documentation - : EOF - | JAVADOC_START skipWhitespace* documentationContent JAVADOC_END EOF - | skipWhitespace* documentationContent EOF - ; + : EOF + | JAVADOC_START skipWhitespace* documentationContent JAVADOC_END EOF + | skipWhitespace* documentationContent EOF + ; documentationContent - : description skipWhitespace* - | skipWhitespace* tagSection - | description NEWLINE+ skipWhitespace* tagSection - ; + : description skipWhitespace* + | skipWhitespace* tagSection + | description NEWLINE+ skipWhitespace* tagSection + ; skipWhitespace - : SPACE - | NEWLINE - ; - + : SPACE + | NEWLINE + ; description - : descriptionLine (descriptionNewline+ descriptionLine)* - ; + : descriptionLine (descriptionNewline+ descriptionLine)* + ; descriptionLine - : descriptionLineStart descriptionLineElement* - | inlineTag descriptionLineElement* - ; + : descriptionLineStart descriptionLineElement* + | inlineTag descriptionLineElement* + ; descriptionLineStart - : SPACE? descriptionLineNoSpaceNoAt+ (descriptionLineNoSpaceNoAt | SPACE | AT)* - ; + : SPACE? descriptionLineNoSpaceNoAt+ (descriptionLineNoSpaceNoAt | SPACE | AT)* + ; descriptionLineNoSpaceNoAt - : TEXT_CONTENT - | NAME - | STAR - | SLASH - | BRACE_OPEN - | BRACE_CLOSE - ; + : TEXT_CONTENT + | NAME + | STAR + | SLASH + | BRACE_OPEN + | BRACE_CLOSE + ; descriptionLineElement - : inlineTag - | descriptionLineText - ; + : inlineTag + | descriptionLineText + ; descriptionLineText - : (descriptionLineNoSpaceNoAt | SPACE | AT)+ - ; + : (descriptionLineNoSpaceNoAt | SPACE | AT)+ + ; descriptionNewline - : NEWLINE - ; - + : NEWLINE + ; tagSection - : blockTag+ - ; + : blockTag+ + ; blockTag - : SPACE? AT blockTagName SPACE? blockTagContent* - ; + : SPACE? AT blockTagName SPACE? blockTagContent* + ; blockTagName - : NAME - ; + : NAME + ; blockTagContent - : blockTagText - | inlineTag - | NEWLINE - ; + : blockTagText + | inlineTag + | NEWLINE + ; blockTagText - : blockTagTextElement+ - ; + : blockTagTextElement+ + ; blockTagTextElement - : TEXT_CONTENT - | NAME - | SPACE - | STAR - | SLASH - | BRACE_OPEN - | BRACE_CLOSE - ; - + : TEXT_CONTENT + | NAME + | SPACE + | STAR + | SLASH + | BRACE_OPEN + | BRACE_CLOSE + ; inlineTag - : INLINE_TAG_START inlineTagName SPACE* inlineTagContent? BRACE_CLOSE - ; + : INLINE_TAG_START inlineTagName SPACE* inlineTagContent? BRACE_CLOSE + ; inlineTagName - : NAME - ; + : NAME + ; inlineTagContent - : braceContent+ - ; + : braceContent+ + ; braceExpression - : BRACE_OPEN braceContent* BRACE_CLOSE - ; + : BRACE_OPEN braceContent* BRACE_CLOSE + ; braceContent - : braceExpression - | braceText (NEWLINE* braceText)* - ; + : braceExpression + | braceText (NEWLINE* braceText)* + ; braceText - : TEXT_CONTENT - | NAME - | SPACE - | STAR - | SLASH - | NEWLINE - ; + : TEXT_CONTENT + | NAME + | SPACE + | STAR + | SLASH + | NEWLINE + ; \ No newline at end of file diff --git a/javascript/ecmascript/CSharp/ECMAScript.g4 b/javascript/ecmascript/CSharp/ECMAScript.g4 index 97c616a5f3..4dba3df8bc 100644 --- a/javascript/ecmascript/CSharp/ECMAScript.g4 +++ b/javascript/ecmascript/CSharp/ECMAScript.g4 @@ -24,6 +24,10 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ECMAScript; @parser::members { @@ -167,23 +171,23 @@ grammar ECMAScript; /// Program : /// SourceElements? program - : sourceElements? EOF - ; + : sourceElements? EOF + ; /// SourceElements : /// SourceElement /// SourceElements SourceElement sourceElements - : sourceElement+ - ; + : sourceElement+ + ; /// SourceElement : /// Statement /// FunctionDeclaration sourceElement - : {this.InputStream.LA(1) != Function}? statement - | functionDeclaration - ; + : {this.InputStream.LA(1) != Function}? statement + | functionDeclaration + ; /// Statement : /// Block @@ -202,79 +206,79 @@ sourceElement /// TryStatement /// DebuggerStatement statement - : block - | variableStatement - | emptyStatement_ - | {this.InputStream.LA(1) != OpenBrace}? expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - | debuggerStatement - ; + : block + | variableStatement + | emptyStatement_ + | {this.InputStream.LA(1) != OpenBrace}? expressionStatement + | ifStatement + | iterationStatement + | continueStatement + | breakStatement + | returnStatement + | withStatement + | labelledStatement + | switchStatement + | throwStatement + | tryStatement + | debuggerStatement + ; /// Block : /// { StatementList? } block - : '{' statementList? '}' - ; + : '{' statementList? '}' + ; /// StatementList : /// Statement /// StatementList Statement statementList - : statement+ - ; + : statement+ + ; /// VariableStatement : /// var VariableDeclarationList ; variableStatement - : Var variableDeclarationList eos - ; + : Var variableDeclarationList eos + ; /// VariableDeclarationList : /// VariableDeclaration /// VariableDeclarationList , VariableDeclaration variableDeclarationList - : variableDeclaration ( ',' variableDeclaration )* - ; + : variableDeclaration (',' variableDeclaration)* + ; /// VariableDeclaration : /// Identifier Initialiser? variableDeclaration - : Identifier initialiser? - ; + : Identifier initialiser? + ; /// Initialiser : /// = AssignmentExpression initialiser - : '=' singleExpression - ; + : '=' singleExpression + ; /// EmptyStatement : /// ; emptyStatement_ - : SemiColon - ; + : SemiColon + ; /// ExpressionStatement : /// [lookahead ∉ {{, function}] Expression ; expressionStatement - : expressionSequence eos - ; + : expressionSequence eos + ; /// IfStatement : /// if ( Expression ) Statement else Statement /// if ( Expression ) Statement ifStatement - : If '(' expressionSequence ')' statement ( Else statement )? - ; + : If '(' expressionSequence ')' statement (Else statement)? + ; /// IterationStatement : /// do Statement while ( Expression ); @@ -284,209 +288,209 @@ ifStatement /// for ( LeftHandSideExpression in Expression ) Statement /// for ( var VariableDeclaration in Expression ) Statement iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression In expressionSequence ')' statement # ForInStatement - | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement - ; + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement + ; /// ContinueStatement : /// continue ; /// continue [no LineTerminator here] Identifier ; continueStatement - : Continue ({!here(LineTerminator)}? Identifier)? eos - ; + : Continue ({!here(LineTerminator)}? Identifier)? eos + ; /// BreakStatement : /// break ; /// break [no LineTerminator here] Identifier ; breakStatement - : Break ({!here(LineTerminator)}? Identifier)? eos - ; + : Break ({!here(LineTerminator)}? Identifier)? eos + ; /// ReturnStatement : /// return ; /// return [no LineTerminator here] Expression ; returnStatement - : Return ({!here(LineTerminator)}? expressionSequence)? eos - ; + : Return ({!here(LineTerminator)}? expressionSequence)? eos + ; /// WithStatement : /// with ( Expression ) Statement withStatement - : With '(' expressionSequence ')' statement - ; + : With '(' expressionSequence ')' statement + ; /// SwitchStatement : /// switch ( Expression ) CaseBlock switchStatement - : Switch '(' expressionSequence ')' caseBlock - ; + : Switch '(' expressionSequence ')' caseBlock + ; /// CaseBlock : /// { CaseClauses? } /// { CaseClauses? DefaultClause CaseClauses? } caseBlock - : '{' caseClauses? ( defaultClause caseClauses? )? '}' - ; + : '{' caseClauses? (defaultClause caseClauses?)? '}' + ; /// CaseClauses : /// CaseClause /// CaseClauses CaseClause caseClauses - : caseClause+ - ; + : caseClause+ + ; /// CaseClause : /// case Expression ':' StatementList? caseClause - : Case expressionSequence ':' statementList? - ; + : Case expressionSequence ':' statementList? + ; /// DefaultClause : /// default ':' StatementList? defaultClause - : Default ':' statementList? - ; + : Default ':' statementList? + ; /// LabelledStatement : /// Identifier ':' Statement labelledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; /// ThrowStatement : /// throw [no LineTerminator here] Expression ; throwStatement - : Throw {!here(LineTerminator)}? expressionSequence eos - ; + : Throw {!here(LineTerminator)}? expressionSequence eos + ; /// TryStatement : /// try Block Catch /// try Block Finally /// try Block Catch Finally tryStatement - : Try block catchProduction - | Try block finallyProduction - | Try block catchProduction finallyProduction - ; + : Try block catchProduction + | Try block finallyProduction + | Try block catchProduction finallyProduction + ; /// Catch : /// catch ( Identifier ) Block catchProduction - : Catch '(' Identifier ')' block - ; + : Catch '(' Identifier ')' block + ; /// Finally : /// finally Block finallyProduction - : Finally block - ; + : Finally block + ; /// DebuggerStatement : /// debugger ; debuggerStatement - : Debugger eos - ; + : Debugger eos + ; /// FunctionDeclaration : /// function Identifier ( FormalParameterList? ) { FunctionBody } functionDeclaration - : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' - ; + : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' + ; /// FormalParameterList : /// Identifier /// FormalParameterList , Identifier formalParameterList - : Identifier ( ',' Identifier )* - ; + : Identifier (',' Identifier)* + ; /// FunctionBody : /// SourceElements? functionBody - : sourceElements? - ; + : sourceElements? + ; /// ArrayLiteral : /// [ Elision? ] /// [ ElementList ] /// [ ElementList , Elision? ] arrayLiteral - : '[' elementList? ','? elision? ']' - ; + : '[' elementList? ','? elision? ']' + ; /// ElementList : /// Elision? AssignmentExpression /// ElementList , Elision? AssignmentExpression elementList - : elision? singleExpression ( ',' elision? singleExpression )* - ; + : elision? singleExpression (',' elision? singleExpression)* + ; /// Elision : /// , /// Elision , elision - : ','+ - ; + : ','+ + ; /// ObjectLiteral : /// { } /// { PropertyNameAndValueList } /// { PropertyNameAndValueList , } objectLiteral - : '{' '}' - | '{' propertyNameAndValueList ','? '}' - ; + : '{' '}' + | '{' propertyNameAndValueList ','? '}' + ; /// PropertyNameAndValueList : /// PropertyAssignment /// PropertyNameAndValueList , PropertyAssignment propertyNameAndValueList - : propertyAssignment ( ',' propertyAssignment )* - ; + : propertyAssignment (',' propertyAssignment)* + ; /// PropertyAssignment : /// PropertyName : AssignmentExpression /// get PropertyName ( ) { FunctionBody } /// set PropertyName ( PropertySetParameterList ) { FunctionBody } propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter - ; + : propertyName ':' singleExpression # PropertyExpressionAssignment + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter + ; /// PropertyName : /// IdentifierName /// StringLiteral /// NumericLiteral propertyName - : identifierName - | StringLiteral - | numericLiteral - ; + : identifierName + | StringLiteral + | numericLiteral + ; /// PropertySetParameterList : /// Identifier propertySetParameterList - : Identifier - ; + : Identifier + ; /// Arguments : /// ( ) /// ( ArgumentList ) arguments - : '(' argumentList? ')' - ; + : '(' argumentList? ')' + ; /// ArgumentList : /// AssignmentExpression /// ArgumentList , AssignmentExpression argumentList - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; /// Expression : /// AssignmentExpression @@ -604,422 +608,682 @@ argumentList /// ( Expression ) /// expressionSequence - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; singleExpression - : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '.' identifierName # MemberDotExpression - | singleExpression arguments # ArgumentsExpression - | New singleExpression arguments? # NewExpression - | singleExpression {!here(LineTerminator)}? '++' # PostIncrementExpression - | singleExpression {!here(LineTerminator)}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ( '*' | '/' | '%' ) singleExpression # MultiplicativeExpression - | singleExpression ( '+' | '-' ) singleExpression # AdditiveExpression - | singleExpression ( '<<' | '>>' | '>>>' ) singleExpression # BitShiftExpression - | singleExpression ( '<' | '>' | '<=' | '>=' ) singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ( '==' | '!=' | '===' | '!==' ) singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - ; + : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '.' identifierName # MemberDotExpression + | singleExpression arguments # ArgumentsExpression + | New singleExpression arguments? # NewExpression + | singleExpression {!here(LineTerminator)}? '++' # PostIncrementExpression + | singleExpression {!here(LineTerminator)}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ( '+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + ; /// AssignmentOperator : one of /// *= /= %= += -= <<= >>= >>>= &= ^= |= assignmentOperator - : '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; literal - : ( NullLiteral - | BooleanLiteral - | StringLiteral - | RegularExpressionLiteral - ) - | numericLiteral - ; + : (NullLiteral | BooleanLiteral | StringLiteral | RegularExpressionLiteral) + | numericLiteral + ; numericLiteral - : DecimalLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - ; + : DecimalLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + ; identifierName - : Identifier - | reservedWord - ; + : Identifier + | reservedWord + ; reservedWord - : keyword - | futureReservedWord - | ( NullLiteral - | BooleanLiteral - ) - ; + : keyword + | futureReservedWord + | ( NullLiteral | BooleanLiteral) + ; keyword - : Break - | Do - | Instanceof - | Typeof - | Case - | Else - | New - | Var - | Catch - | Finally - | Return - | Void - | Continue - | For - | Switch - | While - | Debugger - | Function - | This - | With - | Default - | If - | Throw - | Delete - | In - | Try - ; + : Break + | Do + | Instanceof + | Typeof + | Case + | Else + | New + | Var + | Catch + | Finally + | Return + | Void + | Continue + | For + | Switch + | While + | Debugger + | Function + | This + | With + | Default + | If + | Throw + | Delete + | In + | Try + ; futureReservedWord - : Class - | Enum - | Extends - | Super - | Const - | Export - | Import - | Implements - | Let - | Private - | Public - | Interface - | Package - | Protected - | Static - | Yield - ; + : Class + | Enum + | Extends + | Super + | Const + | Export + | Import + | Implements + | Let + | Private + | Public + | Interface + | Package + | Protected + | Static + | Yield + ; getter - : {_input.LT(1).Text.Equals("get")}? Identifier propertyName - ; + : {_input.LT(1).Text.Equals("get")}? Identifier propertyName + ; setter - : {_input.LT(1).Text.Equals("set")}? Identifier propertyName - ; + : {_input.LT(1).Text.Equals("set")}? Identifier propertyName + ; eos - : SemiColon - | EOF - | {lineTerminatorAhead()}? - | {_input.LT(1).Type == CloseBrace}? - ; + : SemiColon + | EOF + | {lineTerminatorAhead()}? + | {_input.LT(1).Type == CloseBrace}? + ; eof - : EOF - ; + : EOF + ; /// RegularExpressionLiteral :: /// / RegularExpressionBody / RegularExpressionFlags RegularExpressionLiteral - : {isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags - ; + : {isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags + ; /// 7.3 Line Terminators LineTerminator - : [\r\n\u2028\u2029] -> channel(HIDDEN) - ; - -OpenBracket : '['; -CloseBracket : ']'; -OpenParen : '('; -CloseParen : ')'; -OpenBrace : '{'; -CloseBrace : '}'; -SemiColon : ';'; -Comma : ','; -Assign : '='; -QuestionMark : '?'; -Colon : ':'; -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 : '|='; + : [\r\n\u2028\u2029] -> channel(HIDDEN) + ; + +OpenBracket + : '[' + ; + +CloseBracket + : ']' + ; + +OpenParen + : '(' + ; + +CloseParen + : ')' + ; + +OpenBrace + : '{' + ; + +CloseBrace + : '}' + ; + +SemiColon + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + +QuestionMark + : '?' + ; + +Colon + : ':' + ; + +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 + : '|=' + ; /// 7.8.1 Null Literals NullLiteral - : 'null' - ; + : 'null' + ; /// 7.8.2 Boolean Literals BooleanLiteral - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; /// 7.8.3 Numeric Literals DecimalLiteral - : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; + : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? + ; /// 7.8.3 Numeric Literals HexIntegerLiteral - : '0' [xX] HexDigit+ - ; + : '0' [xX] HexDigit+ + ; OctalIntegerLiteral - : {!strictMode}? '0' OctalDigit+ - ; + : {!strictMode}? '0' OctalDigit+ + ; /// 7.6.1.1 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'; +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' + ; /// 7.6.1.2 Future Reserved Words -Class : 'class'; -Enum : 'enum'; -Extends : 'extends'; -Super : 'super'; -Const : 'const'; -Export : 'export'; -Import : 'import'; +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 : {strictMode}? 'implements'; -Let : {strictMode}? 'let'; -Private : {strictMode}? 'private'; -Public : {strictMode}? 'public'; -Interface : {strictMode}? 'interface'; -Package : {strictMode}? 'package'; -Protected : {strictMode}? 'protected'; -Static : {strictMode}? 'static'; -Yield : {strictMode}? 'yield'; +Implements + : {strictMode}? 'implements' + ; + +Let + : {strictMode}? 'let' + ; + +Private + : {strictMode}? 'private' + ; + +Public + : {strictMode}? 'public' + ; + +Interface + : {strictMode}? 'interface' + ; + +Package + : {strictMode}? 'package' + ; + +Protected + : {strictMode}? 'protected' + ; + +Static + : {strictMode}? 'static' + ; + +Yield + : {strictMode}? 'yield' + ; /// 7.6 Identifier Names and Identifiers Identifier - : IdentifierStart IdentifierPart* - ; + : IdentifierStart IdentifierPart* + ; /// 7.8.4 String Literals StringLiteral - : '"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'' - ; + : '"' DoubleStringCharacter* '"' + | '\'' SingleStringCharacter* '\'' + ; WhiteSpaces - : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) - ; + : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) + ; /// 7.4 Comments MultiLineComment - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; SingleLineComment - : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) - ; + : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) + ; UnexpectedCharacter - : . - ; + : . + ; fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~['\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment EscapeSequence - : CharacterEscapeSequence - | '0' // no digit ahead! TODO - | HexEscapeSequence - | UnicodeEscapeSequence - ; + : CharacterEscapeSequence + | '0' // no digit ahead! TODO + | HexEscapeSequence + | UnicodeEscapeSequence + ; fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; + : SingleEscapeCharacter + | NonEscapeCharacter + ; fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; + : 'x' HexDigit HexDigit + ; fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit - ; + : 'u' HexDigit HexDigit HexDigit HexDigit + ; fragment SingleEscapeCharacter - : ['"\\bfnrtv] - ; + : ['"\\bfnrtv] + ; fragment NonEscapeCharacter - : ~['"\\bfnrtv0-9xu\r\n] - ; + : ~['"\\bfnrtv0-9xu\r\n] + ; fragment EscapeCharacter - : SingleEscapeCharacter - | DecimalDigit - | [xu] - ; + : SingleEscapeCharacter + | DecimalDigit + | [xu] + ; fragment LineContinuation - : '\\' LineTerminatorSequence - ; + : '\\' LineTerminatorSequence + ; fragment LineTerminatorSequence - : '\r\n' - | LineTerminator - ; + : '\r\n' + | LineTerminator + ; fragment DecimalDigit - : [0-9] - ; + : [0-9] + ; fragment HexDigit - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment OctalDigit - : [0-7] - ; + : [0-7] + ; fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; + : '0' + | [1-9] DecimalDigit* + ; fragment ExponentPart - : [eE] [+-]? DecimalDigit+ - ; + : [eE] [+-]? DecimalDigit+ + ; fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; + : [\p{L}] + | [$_] + | '\\' UnicodeEscapeSequence + ; fragment IdentifierPart - : IdentifierStart - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | ZWNJ - | ZWJ - ; + : IdentifierStart + | [\p{Mn}] + | [\p{Nd}] + | [\p{Pc}] + | ZWNJ + | ZWJ + ; fragment ZWNJ - : '\u200C' - ; + : '\u200C' + ; fragment ZWJ - : '\u200D' - ; + : '\u200D' + ; /// RegularExpressionBody :: /// RegularExpressionFirstChar RegularExpressionChars @@ -1028,47 +1292,47 @@ fragment ZWJ /// [empty] /// RegularExpressionChars RegularExpressionChar fragment RegularExpressionBody - : RegularExpressionFirstChar RegularExpressionChar* - ; + : RegularExpressionFirstChar RegularExpressionChar* + ; /// RegularExpressionFlags :: /// [empty] /// RegularExpressionFlags IdentifierPart fragment RegularExpressionFlags - : IdentifierPart* - ; + : IdentifierPart* + ; /// RegularExpressionFirstChar :: /// RegularExpressionNonTerminator but not one of * or \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionFirstChar - : ~[\r\n\u2028\u2029*\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029*\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionChar :: /// RegularExpressionNonTerminator but not \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionNonTerminator :: /// SourceCharacter but not LineTerminator fragment RegularExpressionNonTerminator - : ~[\r\n\u2028\u2029] - ; + : ~[\r\n\u2028\u2029] + ; /// RegularExpressionBackslashSequence :: /// \ RegularExpressionNonTerminator fragment RegularExpressionBackslashSequence - : '\\' RegularExpressionNonTerminator - ; + : '\\' RegularExpressionNonTerminator + ; /// RegularExpressionClass :: /// [ RegularExpressionClassChars ] @@ -1077,13 +1341,13 @@ fragment RegularExpressionBackslashSequence /// [empty] /// RegularExpressionClassChars RegularExpressionClassChar fragment RegularExpressionClass - : '[' RegularExpressionClassChar* ']' - ; + : '[' RegularExpressionClassChar* ']' + ; /// RegularExpressionClassChar :: /// RegularExpressionNonTerminator but not ] or \ /// RegularExpressionBackslashSequence fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; + : ~[\r\n\u2028\u2029\]\\] + | RegularExpressionBackslashSequence + ; \ No newline at end of file diff --git a/javascript/ecmascript/CSharpSharwell/ECMAScript.g4 b/javascript/ecmascript/CSharpSharwell/ECMAScript.g4 index 94e067c540..ae2e47a3c5 100644 --- a/javascript/ecmascript/CSharpSharwell/ECMAScript.g4 +++ b/javascript/ecmascript/CSharpSharwell/ECMAScript.g4 @@ -24,6 +24,10 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ECMAScript; @parser::members { @@ -167,23 +171,23 @@ grammar ECMAScript; /// Program : /// SourceElements? program - : sourceElements? EOF - ; + : sourceElements? EOF + ; /// SourceElements : /// SourceElement /// SourceElements SourceElement sourceElements - : sourceElement+ - ; + : sourceElement+ + ; /// SourceElement : /// Statement /// FunctionDeclaration sourceElement - : {_input.LA(1) != Function}? statement - | functionDeclaration - ; + : {_input.LA(1) != Function}? statement + | functionDeclaration + ; /// Statement : /// Block @@ -202,79 +206,79 @@ sourceElement /// TryStatement /// DebuggerStatement statement - : block - | variableStatement - | emptyStatement_ - | {_input.LA(1) != OpenBrace}? expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - | debuggerStatement - ; + : block + | variableStatement + | emptyStatement_ + | {_input.LA(1) != OpenBrace}? expressionStatement + | ifStatement + | iterationStatement + | continueStatement + | breakStatement + | returnStatement + | withStatement + | labelledStatement + | switchStatement + | throwStatement + | tryStatement + | debuggerStatement + ; /// Block : /// { StatementList? } block - : '{' statementList? '}' - ; + : '{' statementList? '}' + ; /// StatementList : /// Statement /// StatementList Statement statementList - : statement+ - ; + : statement+ + ; /// VariableStatement : /// var VariableDeclarationList ; variableStatement - : Var variableDeclarationList eos - ; + : Var variableDeclarationList eos + ; /// VariableDeclarationList : /// VariableDeclaration /// VariableDeclarationList , VariableDeclaration variableDeclarationList - : variableDeclaration ( ',' variableDeclaration )* - ; + : variableDeclaration (',' variableDeclaration)* + ; /// VariableDeclaration : /// Identifier Initialiser? variableDeclaration - : Identifier initialiser? - ; + : Identifier initialiser? + ; /// Initialiser : /// = AssignmentExpression initialiser - : '=' singleExpression - ; + : '=' singleExpression + ; /// EmptyStatement : /// ; emptyStatement_ - : SemiColon - ; + : SemiColon + ; /// ExpressionStatement : /// [lookahead ∉ {{, function}] Expression ; expressionStatement - : expressionSequence eos - ; + : expressionSequence eos + ; /// IfStatement : /// if ( Expression ) Statement else Statement /// if ( Expression ) Statement ifStatement - : If '(' expressionSequence ')' statement ( Else statement )? - ; + : If '(' expressionSequence ')' statement (Else statement)? + ; /// IterationStatement : /// do Statement while ( Expression ); @@ -284,208 +288,208 @@ ifStatement /// for ( LeftHandSideExpression in Expression ) Statement /// for ( var VariableDeclaration in Expression ) Statement iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression In expressionSequence ')' statement # ForInStatement - | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement - ; + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement + ; /// ContinueStatement : /// continue ; /// continue [no LineTerminator here] Identifier ; continueStatement - : Continue ({!here(LineTerminator)}? Identifier)? eos - ; + : Continue ({!here(LineTerminator)}? Identifier)? eos + ; /// BreakStatement : /// break ; /// break [no LineTerminator here] Identifier ; breakStatement - : Break ({!here(LineTerminator)}? Identifier)? eos - ; + : Break ({!here(LineTerminator)}? Identifier)? eos + ; /// ReturnStatement : /// return ; /// return [no LineTerminator here] Expression ; returnStatement - : Return ({!here(LineTerminator)}? expressionSequence)? eos - ; + : Return ({!here(LineTerminator)}? expressionSequence)? eos + ; /// WithStatement : /// with ( Expression ) Statement withStatement - : With '(' expressionSequence ')' statement - ; + : With '(' expressionSequence ')' statement + ; /// SwitchStatement : /// switch ( Expression ) CaseBlock switchStatement - : Switch '(' expressionSequence ')' caseBlock - ; + : Switch '(' expressionSequence ')' caseBlock + ; /// CaseBlock : /// { CaseClauses? } /// { CaseClauses? DefaultClause CaseClauses? } caseBlock - : '{' caseClauses? ( defaultClause caseClauses? )? '}' - ; + : '{' caseClauses? (defaultClause caseClauses?)? '}' + ; /// CaseClauses : /// CaseClause /// CaseClauses CaseClause caseClauses - : caseClause+ - ; + : caseClause+ + ; /// CaseClause : /// case Expression ':' StatementList? caseClause - : Case expressionSequence ':' statementList? - ; + : Case expressionSequence ':' statementList? + ; /// DefaultClause : /// default ':' StatementList? defaultClause - : Default ':' statementList? - ; + : Default ':' statementList? + ; /// LabelledStatement : /// Identifier ':' Statement labelledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; /// ThrowStatement : /// throw [no LineTerminator here] Expression ; throwStatement - : Throw {!here(LineTerminator)}? expressionSequence eos - ; + : Throw {!here(LineTerminator)}? expressionSequence eos + ; /// TryStatement : /// try Block Catch /// try Block Finally /// try Block Catch Finally tryStatement - : Try block catchProduction - | Try block finallyProduction - | Try block catchProduction finallyProduction - ; + : Try block catchProduction + | Try block finallyProduction + | Try block catchProduction finallyProduction + ; /// Catch : /// catch ( Identifier ) Block catchProduction - : Catch '(' Identifier ')' block - ; + : Catch '(' Identifier ')' block + ; /// Finally : /// finally Block finallyProduction - : Finally block - ; + : Finally block + ; /// DebuggerStatement : /// debugger ; debuggerStatement - : Debugger eos - ; + : Debugger eos + ; /// FunctionDeclaration : /// function Identifier ( FormalParameterList? ) { FunctionBody } functionDeclaration - : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' - ; + : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' + ; /// FormalParameterList : /// Identifier /// FormalParameterList , Identifier formalParameterList - : Identifier ( ',' Identifier )* - ; + : Identifier (',' Identifier)* + ; /// FunctionBody : /// SourceElements? functionBody - : sourceElements? - ; + : sourceElements? + ; /// ArrayLiteral : /// [ Elision? ] /// [ ElementList ] /// [ ElementList , Elision? ] arrayLiteral - : '[' elementList? ','? elision? ']' - ; + : '[' elementList? ','? elision? ']' + ; /// ElementList : /// Elision? AssignmentExpression /// ElementList , Elision? AssignmentExpression elementList - : elision? singleExpression ( ',' elision? singleExpression )* - ; + : elision? singleExpression (',' elision? singleExpression)* + ; /// Elision : /// , /// Elision , elision - : ','+ - ; + : ','+ + ; /// ObjectLiteral : /// { } /// { PropertyNameAndValueList } /// { PropertyNameAndValueList , } objectLiteral - : '{' propertyNameAndValueList? ','? '}' - ; + : '{' propertyNameAndValueList? ','? '}' + ; /// PropertyNameAndValueList : /// PropertyAssignment /// PropertyNameAndValueList , PropertyAssignment propertyNameAndValueList - : propertyAssignment ( ',' propertyAssignment )* - ; + : propertyAssignment (',' propertyAssignment)* + ; /// PropertyAssignment : /// PropertyName : AssignmentExpression /// get PropertyName ( ) { FunctionBody } /// set PropertyName ( PropertySetParameterList ) { FunctionBody } propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter - ; + : propertyName ':' singleExpression # PropertyExpressionAssignment + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter + ; /// PropertyName : /// IdentifierName /// StringLiteral /// NumericLiteral propertyName - : identifierName - | StringLiteral - | numericLiteral - ; + : identifierName + | StringLiteral + | numericLiteral + ; /// PropertySetParameterList : /// Identifier propertySetParameterList - : Identifier - ; + : Identifier + ; /// Arguments : /// ( ) /// ( ArgumentList ) arguments - : '(' argumentList? ')' - ; + : '(' argumentList? ')' + ; /// ArgumentList : /// AssignmentExpression /// ArgumentList , AssignmentExpression argumentList - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; /// Expression : /// AssignmentExpression @@ -603,426 +607,686 @@ argumentList /// ( Expression ) /// expressionSequence - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; singleExpression - : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '.' identifierName # MemberDotExpression - | singleExpression arguments # ArgumentsExpression - | New singleExpression arguments? # NewExpression - | singleExpression {!here(LineTerminator)}? '++' # PostIncrementExpression - | singleExpression {!here(LineTerminator)}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ( '*' | '/' | '%' ) singleExpression # MultiplicativeExpression - | singleExpression ( '+' | '-' ) singleExpression # AdditiveExpression - | singleExpression ( '<<' | '>>' | '>>>' ) singleExpression # BitShiftExpression - | singleExpression ( '<' | '>' | '<=' | '>=' ) singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ( '==' | '!=' | '===' | '!==' ) singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - ; + : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '.' identifierName # MemberDotExpression + | singleExpression arguments # ArgumentsExpression + | New singleExpression arguments? # NewExpression + | singleExpression {!here(LineTerminator)}? '++' # PostIncrementExpression + | singleExpression {!here(LineTerminator)}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ( '+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + ; /// AssignmentOperator : one of /// *= /= %= += -= <<= >>= >>>= &= ^= |= assignmentOperator - : '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; literal - : ( NullLiteral - | BooleanLiteral - | StringLiteral - | RegularExpressionLiteral - ) - | numericLiteral - ; + : (NullLiteral | BooleanLiteral | StringLiteral | RegularExpressionLiteral) + | numericLiteral + ; numericLiteral - : DecimalLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - ; + : DecimalLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + ; identifierName - : Identifier - | reservedWord - ; + : Identifier + | reservedWord + ; reservedWord - : keyword - | futureReservedWord - | ( NullLiteral - | BooleanLiteral - ) - ; + : keyword + | futureReservedWord + | ( NullLiteral | BooleanLiteral) + ; keyword - : Break - | Do - | Instanceof - | Typeof - | Case - | Else - | New - | Var - | Catch - | Finally - | Return - | Void - | Continue - | For - | Switch - | While - | Debugger - | Function - | This - | With - | Default - | If - | Throw - | Delete - | In - | Try - ; + : Break + | Do + | Instanceof + | Typeof + | Case + | Else + | New + | Var + | Catch + | Finally + | Return + | Void + | Continue + | For + | Switch + | While + | Debugger + | Function + | This + | With + | Default + | If + | Throw + | Delete + | In + | Try + ; futureReservedWord - : Class - | Enum - | Extends - | Super - | Const - | Export - | Import - | Implements - | Let - | Private - | Public - | Interface - | Package - | Protected - | Static - | Yield - ; + : Class + | Enum + | Extends + | Super + | Const + | Export + | Import + | Implements + | Let + | Private + | Public + | Interface + | Package + | Protected + | Static + | Yield + ; getter - : {_input.LT(1).Text.Equals("get")}? Identifier propertyName - ; + : {_input.LT(1).Text.Equals("get")}? Identifier propertyName + ; setter - : {_input.LT(1).Text.Equals("set")}? Identifier propertyName - ; + : {_input.LT(1).Text.Equals("set")}? Identifier propertyName + ; eos - : SemiColon - | EOF - | {lineTerminatorAhead()}? - | {_input.LT(1).Type == CloseBrace}? - ; + : SemiColon + | EOF + | {lineTerminatorAhead()}? + | {_input.LT(1).Type == CloseBrace}? + ; eof - : EOF - ; + : EOF + ; /// RegularExpressionLiteral :: /// / RegularExpressionBody / RegularExpressionFlags RegularExpressionLiteral - : {isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags - ; + : {isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags + ; /// 7.3 Line Terminators LineTerminator - : [\r\n\u2028\u2029] -> channel(HIDDEN) - ; - -OpenBracket : '['; -CloseBracket : ']'; -OpenParen : '('; -CloseParen : ')'; -OpenBrace : '{'; -CloseBrace : '}'; -SemiColon : ';'; -Comma : ','; -Assign : '='; -QuestionMark : '?'; -Colon : ':'; -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 : '|='; + : [\r\n\u2028\u2029] -> channel(HIDDEN) + ; + +OpenBracket + : '[' + ; + +CloseBracket + : ']' + ; + +OpenParen + : '(' + ; + +CloseParen + : ')' + ; + +OpenBrace + : '{' + ; + +CloseBrace + : '}' + ; + +SemiColon + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + +QuestionMark + : '?' + ; + +Colon + : ':' + ; + +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 + : '|=' + ; /// 7.8.1 Null Literals NullLiteral - : 'null' - ; + : 'null' + ; /// 7.8.2 Boolean Literals BooleanLiteral - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; /// 7.8.3 Numeric Literals DecimalLiteral - : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; + : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? + ; /// 7.8.3 Numeric Literals HexIntegerLiteral - : '0' [xX] HexDigit+ - ; + : '0' [xX] HexDigit+ + ; OctalIntegerLiteral - : {!strictMode}? '0' OctalDigit+ - ; + : {!strictMode}? '0' OctalDigit+ + ; /// 7.6.1.1 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'; +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' + ; /// 7.6.1.2 Future Reserved Words -Class : 'class'; -Enum : 'enum'; -Extends : 'extends'; -Super : 'super'; -Const : 'const'; -Export : 'export'; -Import : 'import'; +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 : {strictMode}? 'implements'; -Let : {strictMode}? 'let'; -Private : {strictMode}? 'private'; -Public : {strictMode}? 'public'; -Interface : {strictMode}? 'interface'; -Package : {strictMode}? 'package'; -Protected : {strictMode}? 'protected'; -Static : {strictMode}? 'static'; -Yield : {strictMode}? 'yield'; +Implements + : {strictMode}? 'implements' + ; + +Let + : {strictMode}? 'let' + ; + +Private + : {strictMode}? 'private' + ; + +Public + : {strictMode}? 'public' + ; + +Interface + : {strictMode}? 'interface' + ; + +Package + : {strictMode}? 'package' + ; + +Protected + : {strictMode}? 'protected' + ; + +Static + : {strictMode}? 'static' + ; + +Yield + : {strictMode}? 'yield' + ; /// 7.6 Identifier Names and Identifiers Identifier - : IdentifierStart IdentifierPart* - ; + : IdentifierStart IdentifierPart* + ; /// 7.8.4 String Literals StringLiteral - : '"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'' - ; + : '"' DoubleStringCharacter* '"' + | '\'' SingleStringCharacter* '\'' + ; WhiteSpaces - : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) - ; + : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) + ; /// 7.4 Comments MultiLineComment - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; SingleLineComment - : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) - ; + : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) + ; HtmlComment - : '' -> channel(HIDDEN) - ; + : '' -> channel(HIDDEN) + ; UnexpectedCharacter - : . - ; + : . + ; fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~['\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment EscapeSequence - : CharacterEscapeSequence - | '0' // no digit ahead! TODO - | HexEscapeSequence - | UnicodeEscapeSequence - ; + : CharacterEscapeSequence + | '0' // no digit ahead! TODO + | HexEscapeSequence + | UnicodeEscapeSequence + ; fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; + : SingleEscapeCharacter + | NonEscapeCharacter + ; fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; + : 'x' HexDigit HexDigit + ; fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit - ; + : 'u' HexDigit HexDigit HexDigit HexDigit + ; fragment SingleEscapeCharacter - : ['"\\bfnrtv] - ; + : ['"\\bfnrtv] + ; fragment NonEscapeCharacter - : ~['"\\bfnrtv0-9xu\r\n] - ; + : ~['"\\bfnrtv0-9xu\r\n] + ; fragment EscapeCharacter - : SingleEscapeCharacter - | DecimalDigit - | [xu] - ; + : SingleEscapeCharacter + | DecimalDigit + | [xu] + ; fragment LineContinuation - : '\\' LineTerminatorSequence - ; + : '\\' LineTerminatorSequence + ; fragment LineTerminatorSequence - : '\r\n' - | LineTerminator - ; + : '\r\n' + | LineTerminator + ; fragment DecimalDigit - : [0-9] - ; + : [0-9] + ; fragment HexDigit - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment OctalDigit - : [0-7] - ; + : [0-7] + ; fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; + : '0' + | [1-9] DecimalDigit* + ; fragment ExponentPart - : [eE] [+-]? DecimalDigit+ - ; + : [eE] [+-]? DecimalDigit+ + ; fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; + : [\p{L}] + | [$_] + | '\\' UnicodeEscapeSequence + ; fragment IdentifierPart - : IdentifierStart - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | ZWNJ - | ZWJ - ; + : IdentifierStart + | [\p{Mn}] + | [\p{Nd}] + | [\p{Pc}] + | ZWNJ + | ZWJ + ; fragment ZWNJ - : '\u200C' - ; + : '\u200C' + ; fragment ZWJ - : '\u200D' - ; + : '\u200D' + ; /// RegularExpressionBody :: /// RegularExpressionFirstChar RegularExpressionChars @@ -1031,47 +1295,47 @@ fragment ZWJ /// [empty] /// RegularExpressionChars RegularExpressionChar fragment RegularExpressionBody - : RegularExpressionFirstChar RegularExpressionChar* - ; + : RegularExpressionFirstChar RegularExpressionChar* + ; /// RegularExpressionFlags :: /// [empty] /// RegularExpressionFlags IdentifierPart fragment RegularExpressionFlags - : IdentifierPart* - ; + : IdentifierPart* + ; /// RegularExpressionFirstChar :: /// RegularExpressionNonTerminator but not one of * or \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionFirstChar - : ~[\r\n\u2028\u2029*\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029*\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionChar :: /// RegularExpressionNonTerminator but not \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionNonTerminator :: /// SourceCharacter but not LineTerminator fragment RegularExpressionNonTerminator - : ~[\r\n\u2028\u2029] - ; + : ~[\r\n\u2028\u2029] + ; /// RegularExpressionBackslashSequence :: /// \ RegularExpressionNonTerminator fragment RegularExpressionBackslashSequence - : '\\' RegularExpressionNonTerminator - ; + : '\\' RegularExpressionNonTerminator + ; /// RegularExpressionClass :: /// [ RegularExpressionClassChars ] @@ -1080,13 +1344,13 @@ fragment RegularExpressionBackslashSequence /// [empty] /// RegularExpressionClassChars RegularExpressionClassChar fragment RegularExpressionClass - : '[' RegularExpressionClassChar* ']' - ; + : '[' RegularExpressionClassChar* ']' + ; /// RegularExpressionClassChar :: /// RegularExpressionNonTerminator but not ] or \ /// RegularExpressionBackslashSequence fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; + : ~[\r\n\u2028\u2029\]\\] + | RegularExpressionBackslashSequence + ; \ No newline at end of file diff --git a/javascript/ecmascript/ECMAScript.g4 b/javascript/ecmascript/ECMAScript.g4 index 2fa7049bd0..26b635bdd9 100644 --- a/javascript/ecmascript/ECMAScript.g4 +++ b/javascript/ecmascript/ECMAScript.g4 @@ -24,6 +24,10 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ECMAScript; @parser::members { @@ -184,23 +188,23 @@ grammar ECMAScript; /// Program : /// SourceElements? program - : sourceElements? EOF - ; + : sourceElements? EOF + ; /// SourceElements : /// SourceElement /// SourceElements SourceElement sourceElements - : sourceElement+ - ; + : sourceElement+ + ; /// SourceElement : /// Statement /// FunctionDeclaration sourceElement - : {_input.LA(1) != Function}? statement - | functionDeclaration - ; + : {_input.LA(1) != Function}? statement + | functionDeclaration + ; /// Statement : /// Block @@ -219,79 +223,79 @@ sourceElement /// TryStatement /// DebuggerStatement statement - : block - | variableStatement - | emptyStatement_ - | {_input.LA(1) != OpenBrace}? expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - | debuggerStatement - ; + : block + | variableStatement + | emptyStatement_ + | {_input.LA(1) != OpenBrace}? expressionStatement + | ifStatement + | iterationStatement + | continueStatement + | breakStatement + | returnStatement + | withStatement + | labelledStatement + | switchStatement + | throwStatement + | tryStatement + | debuggerStatement + ; /// Block : /// { StatementList? } block - : '{' statementList? '}' - ; + : '{' statementList? '}' + ; /// StatementList : /// Statement /// StatementList Statement statementList - : statement+ - ; + : statement+ + ; /// VariableStatement : /// var VariableDeclarationList ; variableStatement - : Var variableDeclarationList eos - ; + : Var variableDeclarationList eos + ; /// VariableDeclarationList : /// VariableDeclaration /// VariableDeclarationList , VariableDeclaration variableDeclarationList - : variableDeclaration ( ',' variableDeclaration )* - ; + : variableDeclaration (',' variableDeclaration)* + ; /// VariableDeclaration : /// Identifier Initialiser? variableDeclaration - : Identifier initialiser? - ; + : Identifier initialiser? + ; /// Initialiser : /// = AssignmentExpression initialiser - : '=' singleExpression - ; + : '=' singleExpression + ; /// EmptyStatement : /// ; emptyStatement_ - : SemiColon - ; + : SemiColon + ; /// ExpressionStatement : /// [lookahead ∉ {{, function}] Expression ; expressionStatement - : expressionSequence eos - ; + : expressionSequence eos + ; /// IfStatement : /// if ( Expression ) Statement else Statement /// if ( Expression ) Statement ifStatement - : If '(' expressionSequence ')' statement ( Else statement )? - ; + : If '(' expressionSequence ')' statement (Else statement)? + ; /// IterationStatement : /// do Statement while ( Expression ); @@ -301,209 +305,209 @@ ifStatement /// for ( LeftHandSideExpression in Expression ) Statement /// for ( var VariableDeclaration in Expression ) Statement iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression In expressionSequence ')' statement # ForInStatement - | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement - ; + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement + ; /// ContinueStatement : /// continue ; /// continue [no LineTerminator here] Identifier ; continueStatement - : Continue ({!here(LineTerminator)}? Identifier)? eos - ; + : Continue ({!here(LineTerminator)}? Identifier)? eos + ; /// BreakStatement : /// break ; /// break [no LineTerminator here] Identifier ; breakStatement - : Break ({!here(LineTerminator)}? Identifier)? eos - ; + : Break ({!here(LineTerminator)}? Identifier)? eos + ; /// ReturnStatement : /// return ; /// return [no LineTerminator here] Expression ; returnStatement - : Return ({!here(LineTerminator)}? expressionSequence)? eos - ; + : Return ({!here(LineTerminator)}? expressionSequence)? eos + ; /// WithStatement : /// with ( Expression ) Statement withStatement - : With '(' expressionSequence ')' statement - ; + : With '(' expressionSequence ')' statement + ; /// SwitchStatement : /// switch ( Expression ) CaseBlock switchStatement - : Switch '(' expressionSequence ')' caseBlock - ; + : Switch '(' expressionSequence ')' caseBlock + ; /// CaseBlock : /// { CaseClauses? } /// { CaseClauses? DefaultClause CaseClauses? } caseBlock - : '{' caseClauses? ( defaultClause caseClauses? )? '}' - ; + : '{' caseClauses? (defaultClause caseClauses?)? '}' + ; /// CaseClauses : /// CaseClause /// CaseClauses CaseClause caseClauses - : caseClause+ - ; + : caseClause+ + ; /// CaseClause : /// case Expression ':' StatementList? caseClause - : Case expressionSequence ':' statementList? - ; + : Case expressionSequence ':' statementList? + ; /// DefaultClause : /// default ':' StatementList? defaultClause - : Default ':' statementList? - ; + : Default ':' statementList? + ; /// LabelledStatement : /// Identifier ':' Statement labelledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; /// ThrowStatement : /// throw [no LineTerminator here] Expression ; throwStatement - : Throw {!here(LineTerminator)}? expressionSequence eos - ; + : Throw {!here(LineTerminator)}? expressionSequence eos + ; /// TryStatement : /// try Block Catch /// try Block Finally /// try Block Catch Finally tryStatement - : Try block catchProduction - | Try block finallyProduction - | Try block catchProduction finallyProduction - ; + : Try block catchProduction + | Try block finallyProduction + | Try block catchProduction finallyProduction + ; /// Catch : /// catch ( Identifier ) Block catchProduction - : Catch '(' Identifier ')' block - ; + : Catch '(' Identifier ')' block + ; /// Finally : /// finally Block finallyProduction - : Finally block - ; + : Finally block + ; /// DebuggerStatement : /// debugger ; debuggerStatement - : Debugger eos - ; + : Debugger eos + ; /// FunctionDeclaration : /// function Identifier ( FormalParameterList? ) { FunctionBody } functionDeclaration - : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' - ; + : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' + ; /// FormalParameterList : /// Identifier /// FormalParameterList , Identifier formalParameterList - : Identifier ( ',' Identifier )* - ; + : Identifier (',' Identifier)* + ; /// FunctionBody : /// SourceElements? functionBody - : sourceElements? - ; + : sourceElements? + ; /// ArrayLiteral : /// [ Elision? ] /// [ ElementList ] /// [ ElementList , Elision? ] arrayLiteral - : '[' elementList? ','? elision? ']' - ; + : '[' elementList? ','? elision? ']' + ; /// ElementList : /// Elision? AssignmentExpression /// ElementList , Elision? AssignmentExpression elementList - : elision? singleExpression ( ',' elision? singleExpression )* - ; + : elision? singleExpression (',' elision? singleExpression)* + ; /// Elision : /// , /// Elision , elision - : ','+ - ; + : ','+ + ; /// ObjectLiteral : /// { } /// { PropertyNameAndValueList } /// { PropertyNameAndValueList , } objectLiteral - : '{' '}' - | '{' propertyNameAndValueList ','? '}' - ; + : '{' '}' + | '{' propertyNameAndValueList ','? '}' + ; /// PropertyNameAndValueList : /// PropertyAssignment /// PropertyNameAndValueList , PropertyAssignment propertyNameAndValueList - : propertyAssignment ( ',' propertyAssignment )* - ; + : propertyAssignment (',' propertyAssignment)* + ; /// PropertyAssignment : /// PropertyName : AssignmentExpression /// get PropertyName ( ) { FunctionBody } /// set PropertyName ( PropertySetParameterList ) { FunctionBody } propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter - ; + : propertyName ':' singleExpression # PropertyExpressionAssignment + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter + ; /// PropertyName : /// IdentifierName /// StringLiteral /// NumericLiteral propertyName - : identifierName - | StringLiteral - | numericLiteral - ; + : identifierName + | StringLiteral + | numericLiteral + ; /// PropertySetParameterList : /// Identifier propertySetParameterList - : Identifier - ; + : Identifier + ; /// Arguments : /// ( ) /// ( ArgumentList ) arguments - : '(' argumentList? ')' - ; + : '(' argumentList? ')' + ; /// ArgumentList : /// AssignmentExpression /// ArgumentList , AssignmentExpression argumentList - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; /// Expression : /// AssignmentExpression @@ -621,422 +625,682 @@ argumentList /// ( Expression ) /// expressionSequence - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; singleExpression - : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '.' identifierName # MemberDotExpression - | singleExpression arguments # ArgumentsExpression - | New singleExpression arguments? # NewExpression - | singleExpression {!here(LineTerminator)}? '++' # PostIncrementExpression - | singleExpression {!here(LineTerminator)}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ( '*' | '/' | '%' ) singleExpression # MultiplicativeExpression - | singleExpression ( '+' | '-' ) singleExpression # AdditiveExpression - | singleExpression ( '<<' | '>>' | '>>>' ) singleExpression # BitShiftExpression - | singleExpression ( '<' | '>' | '<=' | '>=' ) singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ( '==' | '!=' | '===' | '!==' ) singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - ; + : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '.' identifierName # MemberDotExpression + | singleExpression arguments # ArgumentsExpression + | New singleExpression arguments? # NewExpression + | singleExpression {!here(LineTerminator)}? '++' # PostIncrementExpression + | singleExpression {!here(LineTerminator)}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ( '+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + ; /// AssignmentOperator : one of /// *= /= %= += -= <<= >>= >>>= &= ^= |= assignmentOperator - : '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; literal - : ( NullLiteral - | BooleanLiteral - | StringLiteral - | RegularExpressionLiteral - ) - | numericLiteral - ; + : (NullLiteral | BooleanLiteral | StringLiteral | RegularExpressionLiteral) + | numericLiteral + ; numericLiteral - : DecimalLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - ; + : DecimalLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + ; identifierName - : Identifier - | reservedWord - ; + : Identifier + | reservedWord + ; reservedWord - : keyword - | futureReservedWord - | ( NullLiteral - | BooleanLiteral - ) - ; + : keyword + | futureReservedWord + | ( NullLiteral | BooleanLiteral) + ; keyword - : Break - | Do - | Instanceof - | Typeof - | Case - | Else - | New - | Var - | Catch - | Finally - | Return - | Void - | Continue - | For - | Switch - | While - | Debugger - | Function - | This - | With - | Default - | If - | Throw - | Delete - | In - | Try - ; + : Break + | Do + | Instanceof + | Typeof + | Case + | Else + | New + | Var + | Catch + | Finally + | Return + | Void + | Continue + | For + | Switch + | While + | Debugger + | Function + | This + | With + | Default + | If + | Throw + | Delete + | In + | Try + ; futureReservedWord - : Class - | Enum - | Extends - | Super - | Const - | Export - | Import - | Implements - | Let - | Private - | Public - | Interface - | Package - | Protected - | Static - | Yield - ; + : Class + | Enum + | Extends + | Super + | Const + | Export + | Import + | Implements + | Let + | Private + | Public + | Interface + | Package + | Protected + | Static + | Yield + ; getter - : {_input.LT(1).getText().equals("get")}? Identifier propertyName - ; + : {_input.LT(1).getText().equals("get")}? Identifier propertyName + ; setter - : {_input.LT(1).getText().equals("set")}? Identifier propertyName - ; + : {_input.LT(1).getText().equals("set")}? Identifier propertyName + ; eos - : SemiColon - | EOF - | {lineTerminatorAhead()}? - | {_input.LT(1).getType() == CloseBrace}? - ; + : SemiColon + | EOF + | {lineTerminatorAhead()}? + | {_input.LT(1).getType() == CloseBrace}? + ; eof - : EOF - ; + : EOF + ; /// RegularExpressionLiteral :: /// / RegularExpressionBody / RegularExpressionFlags RegularExpressionLiteral - : {isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags - ; + : {isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags + ; /// 7.3 Line Terminators LineTerminator - : [\r\n\u2028\u2029] -> channel(HIDDEN) - ; - -OpenBracket : '['; -CloseBracket : ']'; -OpenParen : '('; -CloseParen : ')'; -OpenBrace : '{'; -CloseBrace : '}'; -SemiColon : ';'; -Comma : ','; -Assign : '='; -QuestionMark : '?'; -Colon : ':'; -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 : '|='; + : [\r\n\u2028\u2029] -> channel(HIDDEN) + ; + +OpenBracket + : '[' + ; + +CloseBracket + : ']' + ; + +OpenParen + : '(' + ; + +CloseParen + : ')' + ; + +OpenBrace + : '{' + ; + +CloseBrace + : '}' + ; + +SemiColon + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + +QuestionMark + : '?' + ; + +Colon + : ':' + ; + +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 + : '|=' + ; /// 7.8.1 Null Literals NullLiteral - : 'null' - ; + : 'null' + ; /// 7.8.2 Boolean Literals BooleanLiteral - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; /// 7.8.3 Numeric Literals DecimalLiteral - : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; + : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? + ; /// 7.8.3 Numeric Literals HexIntegerLiteral - : '0' [xX] HexDigit+ - ; + : '0' [xX] HexDigit+ + ; OctalIntegerLiteral - : {!strictMode}? '0' OctalDigit+ - ; + : {!strictMode}? '0' OctalDigit+ + ; /// 7.6.1.1 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'; +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' + ; /// 7.6.1.2 Future Reserved Words -Class : 'class'; -Enum : 'enum'; -Extends : 'extends'; -Super : 'super'; -Const : 'const'; -Export : 'export'; -Import : 'import'; +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 : {strictMode}? 'implements'; -Let : {strictMode}? 'let'; -Private : {strictMode}? 'private'; -Public : {strictMode}? 'public'; -Interface : {strictMode}? 'interface'; -Package : {strictMode}? 'package'; -Protected : {strictMode}? 'protected'; -Static : {strictMode}? 'static'; -Yield : {strictMode}? 'yield'; +Implements + : {strictMode}? 'implements' + ; + +Let + : {strictMode}? 'let' + ; + +Private + : {strictMode}? 'private' + ; + +Public + : {strictMode}? 'public' + ; + +Interface + : {strictMode}? 'interface' + ; + +Package + : {strictMode}? 'package' + ; + +Protected + : {strictMode}? 'protected' + ; + +Static + : {strictMode}? 'static' + ; + +Yield + : {strictMode}? 'yield' + ; /// 7.6 Identifier Names and Identifiers Identifier - : IdentifierStart IdentifierPart* - ; + : IdentifierStart IdentifierPart* + ; /// 7.8.4 String Literals StringLiteral - : '"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'' - ; + : '"' DoubleStringCharacter* '"' + | '\'' SingleStringCharacter* '\'' + ; WhiteSpaces - : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) - ; + : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) + ; /// 7.4 Comments MultiLineComment - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; SingleLineComment - : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) - ; + : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) + ; UnexpectedCharacter - : . - ; + : . + ; fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~['\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment EscapeSequence - : CharacterEscapeSequence - | '0' // no digit ahead! TODO - | HexEscapeSequence - | UnicodeEscapeSequence - ; + : CharacterEscapeSequence + | '0' // no digit ahead! TODO + | HexEscapeSequence + | UnicodeEscapeSequence + ; fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; + : SingleEscapeCharacter + | NonEscapeCharacter + ; fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; + : 'x' HexDigit HexDigit + ; fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit - ; + : 'u' HexDigit HexDigit HexDigit HexDigit + ; fragment SingleEscapeCharacter - : ['"\\bfnrtv] - ; + : ['"\\bfnrtv] + ; fragment NonEscapeCharacter - : ~['"\\bfnrtv0-9xu\r\n] - ; + : ~['"\\bfnrtv0-9xu\r\n] + ; fragment EscapeCharacter - : SingleEscapeCharacter - | DecimalDigit - | [xu] - ; + : SingleEscapeCharacter + | DecimalDigit + | [xu] + ; fragment LineContinuation - : '\\' LineTerminatorSequence - ; + : '\\' LineTerminatorSequence + ; fragment LineTerminatorSequence - : '\r\n' - | LineTerminator - ; + : '\r\n' + | LineTerminator + ; fragment DecimalDigit - : [0-9] - ; + : [0-9] + ; fragment HexDigit - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment OctalDigit - : [0-7] - ; + : [0-7] + ; fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; + : '0' + | [1-9] DecimalDigit* + ; fragment ExponentPart - : [eE] [+-]? DecimalDigit+ - ; + : [eE] [+-]? DecimalDigit+ + ; fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; + : [\p{L}] + | [$_] + | '\\' UnicodeEscapeSequence + ; fragment IdentifierPart - : IdentifierStart - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | ZWNJ - | ZWJ - ; + : IdentifierStart + | [\p{Mn}] + | [\p{Nd}] + | [\p{Pc}] + | ZWNJ + | ZWJ + ; fragment ZWNJ - : '\u200C' - ; + : '\u200C' + ; fragment ZWJ - : '\u200D' - ; + : '\u200D' + ; /// RegularExpressionBody :: /// RegularExpressionFirstChar RegularExpressionChars @@ -1045,47 +1309,47 @@ fragment ZWJ /// [empty] /// RegularExpressionChars RegularExpressionChar fragment RegularExpressionBody - : RegularExpressionFirstChar RegularExpressionChar* - ; + : RegularExpressionFirstChar RegularExpressionChar* + ; /// RegularExpressionFlags :: /// [empty] /// RegularExpressionFlags IdentifierPart fragment RegularExpressionFlags - : IdentifierPart* - ; + : IdentifierPart* + ; /// RegularExpressionFirstChar :: /// RegularExpressionNonTerminator but not one of * or \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionFirstChar - : ~[\r\n\u2028\u2029*\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029*\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionChar :: /// RegularExpressionNonTerminator but not \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionNonTerminator :: /// SourceCharacter but not LineTerminator fragment RegularExpressionNonTerminator - : ~[\r\n\u2028\u2029] - ; + : ~[\r\n\u2028\u2029] + ; /// RegularExpressionBackslashSequence :: /// \ RegularExpressionNonTerminator fragment RegularExpressionBackslashSequence - : '\\' RegularExpressionNonTerminator - ; + : '\\' RegularExpressionNonTerminator + ; /// RegularExpressionClass :: /// [ RegularExpressionClassChars ] @@ -1094,13 +1358,13 @@ fragment RegularExpressionBackslashSequence /// [empty] /// RegularExpressionClassChars RegularExpressionClassChar fragment RegularExpressionClass - : '[' RegularExpressionClassChar* ']' - ; + : '[' RegularExpressionClassChar* ']' + ; /// RegularExpressionClassChar :: /// RegularExpressionNonTerminator but not ] or \ /// RegularExpressionBackslashSequence fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; + : ~[\r\n\u2028\u2029\]\\] + | RegularExpressionBackslashSequence + ; \ No newline at end of file diff --git a/javascript/ecmascript/Go/ECMAScript.g4 b/javascript/ecmascript/Go/ECMAScript.g4 index d9ed113d33..360cbd5c48 100644 --- a/javascript/ecmascript/Go/ECMAScript.g4 +++ b/javascript/ecmascript/Go/ECMAScript.g4 @@ -25,6 +25,10 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ECMAScript; @header { @@ -164,23 +168,23 @@ func (l *ECMAScriptLexer) isRegexPossible() bool { /// Program : /// SourceElements? program - : sourceElements? EOF - ; + : sourceElements? EOF + ; /// SourceElements : /// SourceElement /// SourceElements SourceElement sourceElements - : sourceElement+ - ; + : sourceElement+ + ; /// SourceElement : /// Statement /// FunctionDeclaration sourceElement - : {p.GetInputStream().LA(1) != ECMAScriptParserFunction}? statement - | functionDeclaration - ; + : {p.GetInputStream().LA(1) != ECMAScriptParserFunction}? statement + | functionDeclaration + ; /// Statement : /// Block @@ -199,79 +203,79 @@ sourceElement /// TryStatement /// DebuggerStatement statement - : block - | variableStatement - | voidStatement - | {p.GetInputStream().LA(1) != ECMAScriptParserOpenBrace}? expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - | debuggerStatement - ; + : block + | variableStatement + | voidStatement + | {p.GetInputStream().LA(1) != ECMAScriptParserOpenBrace}? expressionStatement + | ifStatement + | iterationStatement + | continueStatement + | breakStatement + | returnStatement + | withStatement + | labelledStatement + | switchStatement + | throwStatement + | tryStatement + | debuggerStatement + ; /// Block : /// { StatementList? } block - : '{' statementList? '}' - ; + : '{' statementList? '}' + ; /// StatementList : /// Statement /// StatementList Statement statementList - : statement+ - ; + : statement+ + ; /// VariableStatement : /// var VariableDeclarationList ; variableStatement - : Var variableDeclarationList eos - ; + : Var variableDeclarationList eos + ; /// VariableDeclarationList : /// VariableDeclaration /// VariableDeclarationList , VariableDeclaration variableDeclarationList - : variableDeclaration ( ',' variableDeclaration )* - ; + : variableDeclaration (',' variableDeclaration)* + ; /// VariableDeclaration : /// Identifier Initialiser? variableDeclaration - : Identifier initialiser? - ; + : Identifier initialiser? + ; /// Initialiser : /// = AssignmentExpression initialiser - : '=' singleExpression - ; + : '=' singleExpression + ; /// VoidStatement : /// ; voidStatement - : SemiColon - ; + : SemiColon + ; /// ExpressionStatement : /// [lookahead ∉ {{, function}] Expression ; expressionStatement - : expressionSequence eos - ; + : expressionSequence eos + ; /// IfStatement : /// if ( Expression ) Statement else Statement /// if ( Expression ) Statement ifStatement - : If '(' expressionSequence ')' statement ( Else statement )? - ; + : If '(' expressionSequence ')' statement (Else statement)? + ; /// IterationStatement : /// do Statement while ( Expression ); @@ -281,209 +285,209 @@ ifStatement /// for ( LeftHandSideExpression in Expression ) Statement /// for ( var VariableDeclaration in Expression ) Statement iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression In expressionSequence ')' statement # ForInStatement - | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement - ; + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement + ; /// ContinueStatement : /// continue ; /// continue [no LineTerminator here] Identifier ; continueStatement - : Continue Identifier? eos - ; + : Continue Identifier? eos + ; /// BreakStatement : /// break ; /// break [no LineTerminator here] Identifier ; breakStatement - : Break Identifier? eos - ; + : Break Identifier? eos + ; /// ReturnStatement : /// return ; /// return [no LineTerminator here] Expression ; returnStatement - : Return expressionSequence? eos - ; + : Return expressionSequence? eos + ; /// WithStatement : /// with ( Expression ) Statement withStatement - : With '(' expressionSequence ')' statement - ; + : With '(' expressionSequence ')' statement + ; /// SwitchStatement : /// switch ( Expression ) CaseBlock switchStatement - : Switch '(' expressionSequence ')' caseBlock - ; + : Switch '(' expressionSequence ')' caseBlock + ; /// CaseBlock : /// { CaseClauses? } /// { CaseClauses? DefaultClause CaseClauses? } caseBlock - : '{' caseClauses? ( defaultClause caseClauses? )? '}' - ; + : '{' caseClauses? (defaultClause caseClauses?)? '}' + ; /// CaseClauses : /// CaseClause /// CaseClauses CaseClause caseClauses - : caseClause+ - ; + : caseClause+ + ; /// CaseClause : /// case Expression ':' StatementList? caseClause - : Case expressionSequence ':' statementList? - ; + : Case expressionSequence ':' statementList? + ; /// DefaultClause : /// default ':' StatementList? defaultClause - : Default ':' statementList? - ; + : Default ':' statementList? + ; /// LabelledStatement : /// Identifier ':' Statement labelledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; /// ThrowStatement : /// throw [no LineTerminator here] Expression ; throwStatement - : Throw expressionSequence eos - ; + : Throw expressionSequence eos + ; /// TryStatement : /// try Block Catch /// try Block Finally /// try Block Catch Finally tryStatement - : Try block catchProduction - | Try block finallyProduction - | Try block catchProduction finallyProduction - ; + : Try block catchProduction + | Try block finallyProduction + | Try block catchProduction finallyProduction + ; /// Catch : /// catch ( Identifier ) Block catchProduction - : Catch '(' Identifier ')' block - ; + : Catch '(' Identifier ')' block + ; /// Finally : /// finally Block finallyProduction - : Finally block - ; + : Finally block + ; /// DebuggerStatement : /// debugger ; debuggerStatement - : Debugger eos - ; + : Debugger eos + ; /// FunctionDeclaration : /// function Identifier ( FormalParameterList? ) { FunctionBody } functionDeclaration - : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' - ; + : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' + ; /// FormalParameterList : /// Identifier /// FormalParameterList , Identifier formalParameterList - : Identifier ( ',' Identifier )* - ; + : Identifier (',' Identifier)* + ; /// FunctionBody : /// SourceElements? functionBody - : sourceElements? - ; + : sourceElements? + ; /// ArrayLiteral : /// [ Elision? ] /// [ ElementList ] /// [ ElementList , Elision? ] arrayLiteral - : '[' elementList? ','? elision? ']' - ; + : '[' elementList? ','? elision? ']' + ; /// ElementList : /// Elision? AssignmentExpression /// ElementList , Elision? AssignmentExpression elementList - : elision? singleExpression ( ',' elision? singleExpression )* - ; + : elision? singleExpression (',' elision? singleExpression)* + ; /// Elision : /// , /// Elision , elision - : ','+ - ; + : ','+ + ; /// ObjectLiteral : /// { } /// { PropertyNameAndValueList } /// { PropertyNameAndValueList , } objectLiteral - : '{' '}' - | '{' propertyNameAndValueList ','? '}' - ; + : '{' '}' + | '{' propertyNameAndValueList ','? '}' + ; /// PropertyNameAndValueList : /// PropertyAssignment /// PropertyNameAndValueList , PropertyAssignment propertyNameAndValueList - : propertyAssignment ( ',' propertyAssignment )* - ; + : propertyAssignment (',' propertyAssignment)* + ; /// PropertyAssignment : /// PropertyName : AssignmentExpression /// get PropertyName ( ) { FunctionBody } /// set PropertyName ( PropertySetParameterList ) { FunctionBody } propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter - ; + : propertyName ':' singleExpression # PropertyExpressionAssignment + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter + ; /// PropertyName : /// IdentifierName /// StringLiteral /// NumericLiteral propertyName - : identifierName - | StringLiteral - | numericLiteral - ; + : identifierName + | StringLiteral + | numericLiteral + ; /// PropertySetParameterList : /// Identifier propertySetParameterList - : Identifier - ; + : Identifier + ; /// Arguments : /// ( ) /// ( ArgumentList ) arguments - : '(' argumentList? ')' - ; + : '(' argumentList? ')' + ; /// ArgumentList : /// AssignmentExpression /// ArgumentList , AssignmentExpression argumentList - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; /// Expression : /// AssignmentExpression @@ -601,422 +605,682 @@ argumentList /// ( Expression ) /// expressionSequence - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; singleExpression - : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '.' identifierName # MemberDotExpression - | singleExpression arguments # ArgumentsExpression - | New singleExpression arguments? # NewExpression - | singleExpression {!p.here(ECMAScriptParserLineTerminator)}? '++' # PostIncrementExpression - | singleExpression {!p.here(ECMAScriptParserLineTerminator)}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ( '*' | '/' | '%' ) singleExpression # MultiplicativeExpression - | singleExpression ( '+' | '-' ) singleExpression # AdditiveExpression - | singleExpression ( '<<' | '>>' | '>>>' ) singleExpression # BitShiftExpression - | singleExpression ( '<' | '>' | '<=' | '>=' ) singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ( '==' | '!=' | '===' | '!==' ) singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - ; + : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '.' identifierName # MemberDotExpression + | singleExpression arguments # ArgumentsExpression + | New singleExpression arguments? # NewExpression + | singleExpression {!p.here(ECMAScriptParserLineTerminator)}? '++' # PostIncrementExpression + | singleExpression {!p.here(ECMAScriptParserLineTerminator)}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ( '+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + ; /// AssignmentOperator : one of /// *= /= %= += -= <<= >>= >>>= &= ^= |= assignmentOperator - : '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; literal - : ( NullLiteral - | BooleanLiteral - | StringLiteral - | RegularExpressionLiteral - ) - | numericLiteral - ; + : (NullLiteral | BooleanLiteral | StringLiteral | RegularExpressionLiteral) + | numericLiteral + ; numericLiteral - : DecimalLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - ; + : DecimalLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + ; identifierName - : Identifier - | reservedWord - ; + : Identifier + | reservedWord + ; reservedWord - : keyword - | futureReservedWord - | ( NullLiteral - | BooleanLiteral - ) - ; + : keyword + | futureReservedWord + | ( NullLiteral | BooleanLiteral) + ; keyword - : Break - | Do - | Instanceof - | Typeof - | Case - | Else - | New - | Var - | Catch - | Finally - | Return - | Void - | Continue - | For - | Switch - | While - | Debugger - | Function - | This - | With - | Default - | If - | Throw - | Delete - | In - | Try - ; + : Break + | Do + | Instanceof + | Typeof + | Case + | Else + | New + | Var + | Catch + | Finally + | Return + | Void + | Continue + | For + | Switch + | While + | Debugger + | Function + | This + | With + | Default + | If + | Throw + | Delete + | In + | Try + ; futureReservedWord - : Class - | Enum - | Extends - | Super - | Const - | Export - | Import - | Implements - | Let - | Private - | Public - | Interface - | Package - | Protected - | Static - | Yield - ; + : Class + | Enum + | Extends + | Super + | Const + | Export + | Import + | Implements + | Let + | Private + | Public + | Interface + | Package + | Protected + | Static + | Yield + ; getter - : {p.GetTokenStream().LT(1).GetText() == "get"}? Identifier propertyName - ; + : {p.GetTokenStream().LT(1).GetText() == "get"}? Identifier propertyName + ; setter - : {p.GetTokenStream().LT(1).GetText() == "set"}? Identifier propertyName - ; + : {p.GetTokenStream().LT(1).GetText() == "set"}? Identifier propertyName + ; eos - : SemiColon - | EOF - | {p.lineTerminatorAhead()}? - | {p.GetTokenStream().LT(1).GetTokenType() == ECMAScriptParserCloseBrace}? - ; + : SemiColon + | EOF + | {p.lineTerminatorAhead()}? + | {p.GetTokenStream().LT(1).GetTokenType() == ECMAScriptParserCloseBrace}? + ; eof - : EOF - ; + : EOF + ; /// RegularExpressionLiteral :: /// / RegularExpressionBody / RegularExpressionFlags RegularExpressionLiteral - : {p.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags - ; + : {p.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags + ; /// 7.3 Line Terminators LineTerminator - : [\r\n\u2028\u2029] -> channel(HIDDEN) - ; - -OpenBracket : '['; -CloseBracket : ']'; -OpenParen : '('; -CloseParen : ')'; -OpenBrace : '{'; -CloseBrace : '}'; -SemiColon : ';'; -Comma : ','; -Assign : '='; -QuestionMark : '?'; -Colon : ':'; -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 : '|='; + : [\r\n\u2028\u2029] -> channel(HIDDEN) + ; + +OpenBracket + : '[' + ; + +CloseBracket + : ']' + ; + +OpenParen + : '(' + ; + +CloseParen + : ')' + ; + +OpenBrace + : '{' + ; + +CloseBrace + : '}' + ; + +SemiColon + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + +QuestionMark + : '?' + ; + +Colon + : ':' + ; + +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 + : '|=' + ; /// 7.8.1 Null Literals NullLiteral - : 'null' - ; + : 'null' + ; /// 7.8.2 Boolean Literals BooleanLiteral - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; /// 7.8.3 Numeric Literals DecimalLiteral - : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; + : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? + ; /// 7.8.3 Numeric Literals HexIntegerLiteral - : '0' [xX] HexDigit+ - ; + : '0' [xX] HexDigit+ + ; OctalIntegerLiteral - : {!strictMode}? '0' OctalDigit+ - ; + : {!strictMode}? '0' OctalDigit+ + ; /// 7.6.1.1 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'; +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' + ; /// 7.6.1.2 Future Reserved Words -Class : 'class'; -Enum : 'enum'; -Extends : 'extends'; -Super : 'super'; -Const : 'const'; -Export : 'export'; -Import : 'import'; +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 : {strictMode}? 'implements'; -Let : {strictMode}? 'let'; -Private : {strictMode}? 'private'; -Public : {strictMode}? 'public'; -Interface : {strictMode}? 'interface'; -Package : {strictMode}? 'package'; -Protected : {strictMode}? 'protected'; -Static : {strictMode}? 'static'; -Yield : {strictMode}? 'yield'; +Implements + : {strictMode}? 'implements' + ; + +Let + : {strictMode}? 'let' + ; + +Private + : {strictMode}? 'private' + ; + +Public + : {strictMode}? 'public' + ; + +Interface + : {strictMode}? 'interface' + ; + +Package + : {strictMode}? 'package' + ; + +Protected + : {strictMode}? 'protected' + ; + +Static + : {strictMode}? 'static' + ; + +Yield + : {strictMode}? 'yield' + ; /// 7.6 Identifier Names and Identifiers Identifier - : IdentifierStart IdentifierPart* - ; + : IdentifierStart IdentifierPart* + ; /// 7.8.4 String Literals StringLiteral - : '"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'' - ; + : '"' DoubleStringCharacter* '"' + | '\'' SingleStringCharacter* '\'' + ; WhiteSpaces - : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) - ; + : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) + ; /// 7.4 Comments MultiLineComment - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; SingleLineComment - : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) - ; + : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) + ; UnexpectedCharacter - : . - ; + : . + ; fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~['\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment EscapeSequence - : CharacterEscapeSequence - | '0' // no digit ahead! TODO - | HexEscapeSequence - | UnicodeEscapeSequence - ; + : CharacterEscapeSequence + | '0' // no digit ahead! TODO + | HexEscapeSequence + | UnicodeEscapeSequence + ; fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; + : SingleEscapeCharacter + | NonEscapeCharacter + ; fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; + : 'x' HexDigit HexDigit + ; fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit - ; + : 'u' HexDigit HexDigit HexDigit HexDigit + ; fragment SingleEscapeCharacter - : ['"\\bfnrtv] - ; + : ['"\\bfnrtv] + ; fragment NonEscapeCharacter - : ~['"\\bfnrtv0-9xu\r\n] - ; + : ~['"\\bfnrtv0-9xu\r\n] + ; fragment EscapeCharacter - : SingleEscapeCharacter - | DecimalDigit - | [xu] - ; + : SingleEscapeCharacter + | DecimalDigit + | [xu] + ; fragment LineContinuation - : '\\' LineTerminatorSequence - ; + : '\\' LineTerminatorSequence + ; fragment LineTerminatorSequence - : '\r\n' - | LineTerminator - ; + : '\r\n' + | LineTerminator + ; fragment DecimalDigit - : [0-9] - ; + : [0-9] + ; fragment HexDigit - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment OctalDigit - : [0-7] - ; + : [0-7] + ; fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; + : '0' + | [1-9] DecimalDigit* + ; fragment ExponentPart - : [eE] [+-]? DecimalDigit+ - ; + : [eE] [+-]? DecimalDigit+ + ; fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; + : [\p{L}] + | [$_] + | '\\' UnicodeEscapeSequence + ; fragment IdentifierPart - : IdentifierStart - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | ZWNJ - | ZWJ - ; + : IdentifierStart + | [\p{Mn}] + | [\p{Nd}] + | [\p{Pc}] + | ZWNJ + | ZWJ + ; fragment ZWNJ - : '\u200C' - ; + : '\u200C' + ; fragment ZWJ - : '\u200D' - ; + : '\u200D' + ; /// RegularExpressionBody :: /// RegularExpressionFirstChar RegularExpressionChars @@ -1025,47 +1289,47 @@ fragment ZWJ /// [empty] /// RegularExpressionChars RegularExpressionChar fragment RegularExpressionBody - : RegularExpressionFirstChar RegularExpressionChar* - ; + : RegularExpressionFirstChar RegularExpressionChar* + ; /// RegularExpressionFlags :: /// [empty] /// RegularExpressionFlags IdentifierPart fragment RegularExpressionFlags - : IdentifierPart* - ; + : IdentifierPart* + ; /// RegularExpressionFirstChar :: /// RegularExpressionNonTerminator but not one of * or \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionFirstChar - : ~[\r\n\u2028\u2029*\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029*\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionChar :: /// RegularExpressionNonTerminator but not \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionNonTerminator :: /// SourceCharacter but not LineTerminator fragment RegularExpressionNonTerminator - : ~[\r\n\u2028\u2029] - ; + : ~[\r\n\u2028\u2029] + ; /// RegularExpressionBackslashSequence :: /// \ RegularExpressionNonTerminator fragment RegularExpressionBackslashSequence - : '\\' RegularExpressionNonTerminator - ; + : '\\' RegularExpressionNonTerminator + ; /// RegularExpressionClass :: /// [ RegularExpressionClassChars ] @@ -1074,13 +1338,13 @@ fragment RegularExpressionBackslashSequence /// [empty] /// RegularExpressionClassChars RegularExpressionClassChar fragment RegularExpressionClass - : '[' RegularExpressionClassChar* ']' - ; + : '[' RegularExpressionClassChar* ']' + ; /// RegularExpressionClassChar :: /// RegularExpressionNonTerminator but not ] or \ /// RegularExpressionBackslashSequence fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; + : ~[\r\n\u2028\u2029\]\\] + | RegularExpressionBackslashSequence + ; \ No newline at end of file diff --git a/javascript/ecmascript/JavaScript/ECMAScript.g4 b/javascript/ecmascript/JavaScript/ECMAScript.g4 index 88d59d4b54..ca8153a064 100644 --- a/javascript/ecmascript/JavaScript/ECMAScript.g4 +++ b/javascript/ecmascript/JavaScript/ECMAScript.g4 @@ -28,6 +28,10 @@ * https://github.com/bkiers/ecmascript-parser * Developed by : Bart Kiers, bart@big-o.nl */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ECMAScript; @parser::members { @@ -147,23 +151,23 @@ ECMAScriptLexer.prototype.isRegexPossible = function() { /// Program : /// SourceElements? program - : sourceElements? EOF - ; + : sourceElements? EOF + ; /// SourceElements : /// SourceElement /// SourceElements SourceElement sourceElements - : sourceElement+ - ; + : sourceElement+ + ; /// SourceElement : /// Statement /// FunctionDeclaration sourceElement - : {this._input.LA(1).type != ECMAScriptParser.Function}? statement - | functionDeclaration - ; + : {this._input.LA(1).type != ECMAScriptParser.Function}? statement + | functionDeclaration + ; /// Statement : /// Block @@ -182,79 +186,79 @@ sourceElement /// TryStatement /// DebuggerStatement statement - : block - | variableStatement - | emptyStatement_ - | {this._input.LA(1).type != ECMAScriptParser.OpenBrace}? expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - | debuggerStatement - ; + : block + | variableStatement + | emptyStatement_ + | {this._input.LA(1).type != ECMAScriptParser.OpenBrace}? expressionStatement + | ifStatement + | iterationStatement + | continueStatement + | breakStatement + | returnStatement + | withStatement + | labelledStatement + | switchStatement + | throwStatement + | tryStatement + | debuggerStatement + ; /// Block : /// { StatementList? } block - : '{' statementList? '}' - ; + : '{' statementList? '}' + ; /// StatementList : /// Statement /// StatementList Statement statementList - : statement+ - ; + : statement+ + ; /// VariableStatement : /// var VariableDeclarationList ; variableStatement - : Var variableDeclarationList eos - ; + : Var variableDeclarationList eos + ; /// VariableDeclarationList : /// VariableDeclaration /// VariableDeclarationList , VariableDeclaration variableDeclarationList - : variableDeclaration ( ',' variableDeclaration )* - ; + : variableDeclaration (',' variableDeclaration)* + ; /// VariableDeclaration : /// Identifier Initialiser? variableDeclaration - : Identifier initialiser? - ; + : Identifier initialiser? + ; /// Initialiser : /// = AssignmentExpression initialiser - : '=' singleExpression - ; + : '=' singleExpression + ; /// EmptyStatement : /// ; emptyStatement_ - : SemiColon - ; + : SemiColon + ; /// ExpressionStatement : /// [lookahead ∉ {{, function}] Expression ; expressionStatement - : expressionSequence - ; + : expressionSequence + ; /// IfStatement : /// if ( Expression ) Statement else Statement /// if ( Expression ) Statement ifStatement - : If '(' expressionSequence ')' statement ( Else statement )? - ; + : If '(' expressionSequence ')' statement (Else statement)? + ; /// IterationStatement : /// do Statement while ( Expression ); @@ -264,209 +268,209 @@ ifStatement /// for ( LeftHandSideExpression in Expression ) Statement /// for ( var VariableDeclaration in Expression ) Statement iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression In expressionSequence ')' statement # ForInStatement - | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement - ; + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement + ; /// ContinueStatement : /// continue ; /// continue [no LineTerminator here] Identifier ; continueStatement - : Continue ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos - ; + : Continue ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos + ; /// BreakStatement : /// break ; /// break [no LineTerminator here] Identifier ; breakStatement - : Break ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos - ; + : Break ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos + ; /// ReturnStatement : /// return ; /// return [no LineTerminator here] Expression ; returnStatement - : Return ({!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence)? eos - ; + : Return ({!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence)? eos + ; /// WithStatement : /// with ( Expression ) Statement withStatement - : With '(' expressionSequence ')' statement - ; + : With '(' expressionSequence ')' statement + ; /// SwitchStatement : /// switch ( Expression ) CaseBlock switchStatement - : Switch '(' expressionSequence ')' caseBlock - ; + : Switch '(' expressionSequence ')' caseBlock + ; /// CaseBlock : /// { CaseClauses? } /// { CaseClauses? DefaultClause CaseClauses? } caseBlock - : '{' caseClauses? ( defaultClause caseClauses? )? '}' - ; + : '{' caseClauses? (defaultClause caseClauses?)? '}' + ; /// CaseClauses : /// CaseClause /// CaseClauses CaseClause caseClauses - : caseClause+ - ; + : caseClause+ + ; /// CaseClause : /// case Expression ':' StatementList? caseClause - : Case expressionSequence ':' statementList? - ; + : Case expressionSequence ':' statementList? + ; /// DefaultClause : /// default ':' StatementList? defaultClause - : Default ':' statementList? - ; + : Default ':' statementList? + ; /// LabelledStatement : /// Identifier ':' Statement labelledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; /// ThrowStatement : /// throw [no LineTerminator here] Expression ; throwStatement - : Throw {!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence eos - ; + : Throw {!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence eos + ; /// TryStatement : /// try Block Catch /// try Block Finally /// try Block Catch Finally tryStatement - : Try block catchProduction - | Try block finallyProduction - | Try block catchProduction finallyProduction - ; + : Try block catchProduction + | Try block finallyProduction + | Try block catchProduction finallyProduction + ; /// Catch : /// catch ( Identifier ) Block catchProduction - : Catch '(' Identifier ')' block - ; + : Catch '(' Identifier ')' block + ; /// Finally : /// finally Block finallyProduction - : Finally block - ; + : Finally block + ; /// DebuggerStatement : /// debugger ; debuggerStatement - : Debugger eos - ; + : Debugger eos + ; /// FunctionDeclaration : /// function Identifier ( FormalParameterList? ) { FunctionBody } functionDeclaration - : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' - ; + : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' + ; /// FormalParameterList : /// Identifier /// FormalParameterList , Identifier formalParameterList - : Identifier ( ',' Identifier )* - ; + : Identifier (',' Identifier)* + ; /// FunctionBody : /// SourceElements? functionBody - : sourceElements? - ; + : sourceElements? + ; /// ArrayLiteral : /// [ Elision? ] /// [ ElementList ] /// [ ElementList , Elision? ] arrayLiteral - : '[' elementList? ','? elision? ']' - ; + : '[' elementList? ','? elision? ']' + ; /// ElementList : /// Elision? AssignmentExpression /// ElementList , Elision? AssignmentExpression elementList - : elision? singleExpression ( ',' elision? singleExpression )* - ; + : elision? singleExpression (',' elision? singleExpression)* + ; /// Elision : /// , /// Elision , elision - : ','+ - ; + : ','+ + ; /// ObjectLiteral : /// { } /// { PropertyNameAndValueList } /// { PropertyNameAndValueList , } objectLiteral - : '{' '}' - | '{' propertyNameAndValueList ','? '}' - ; + : '{' '}' + | '{' propertyNameAndValueList ','? '}' + ; /// PropertyNameAndValueList : /// PropertyAssignment /// PropertyNameAndValueList , PropertyAssignment propertyNameAndValueList - : propertyAssignment ( ',' propertyAssignment )* - ; + : propertyAssignment (',' propertyAssignment)* + ; /// PropertyAssignment : /// PropertyName : AssignmentExpression /// get PropertyName ( ) { FunctionBody } /// set PropertyName ( PropertySetParameterList ) { FunctionBody } propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter - ; + : propertyName ':' singleExpression # PropertyExpressionAssignment + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter + ; /// PropertyName : /// IdentifierName /// StringLiteral /// NumericLiteral propertyName - : identifierName - | StringLiteral - | numericLiteral - ; + : identifierName + | StringLiteral + | numericLiteral + ; /// PropertySetParameterList : /// Identifier propertySetParameterList - : Identifier - ; + : Identifier + ; /// Arguments : /// ( ) /// ( ArgumentList ) arguments - : '(' argumentList? ')' - ; + : '(' argumentList? ')' + ; /// ArgumentList : /// AssignmentExpression /// ArgumentList , AssignmentExpression argumentList - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; /// Expression : /// AssignmentExpression @@ -584,422 +588,682 @@ argumentList /// ( Expression ) /// expressionSequence - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; singleExpression - : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '.' identifierName # MemberDotExpression - | singleExpression arguments # ArgumentsExpression - | New singleExpression arguments? # NewExpression - | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '++' # PostIncrementExpression - | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ( '*' | '/' | '%' ) singleExpression # MultiplicativeExpression - | singleExpression ( '+' | '-' ) singleExpression # AdditiveExpression - | singleExpression ( '<<' | '>>' | '>>>' ) singleExpression # BitShiftExpression - | singleExpression ( '<' | '>' | '<=' | '>=' ) singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ( '==' | '!=' | '===' | '!==' ) singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' expressionSequence # AssignmentExpression - | singleExpression assignmentOperator expressionSequence # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - ; + : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '.' identifierName # MemberDotExpression + | singleExpression arguments # ArgumentsExpression + | New singleExpression arguments? # NewExpression + | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '++' # PostIncrementExpression + | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ( '+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' expressionSequence # AssignmentExpression + | singleExpression assignmentOperator expressionSequence # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + ; /// AssignmentOperator : one of /// *= /= %= += -= <<= >>= >>>= &= ^= |= assignmentOperator - : '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; literal - : ( NullLiteral - | BooleanLiteral - | StringLiteral - | RegularExpressionLiteral - ) - | numericLiteral - ; + : (NullLiteral | BooleanLiteral | StringLiteral | RegularExpressionLiteral) + | numericLiteral + ; numericLiteral - : DecimalLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - ; + : DecimalLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + ; identifierName - : Identifier - | reservedWord - ; + : Identifier + | reservedWord + ; reservedWord - : keyword - | futureReservedWord - | ( NullLiteral - | BooleanLiteral - ) - ; + : keyword + | futureReservedWord + | ( NullLiteral | BooleanLiteral) + ; keyword - : Break - | Do - | Instanceof - | Typeof - | Case - | Else - | New - | Var - | Catch - | Finally - | Return - | Void - | Continue - | For - | Switch - | While - | Debugger - | Function - | This - | With - | Default - | If - | Throw - | Delete - | In - | Try - ; + : Break + | Do + | Instanceof + | Typeof + | Case + | Else + | New + | Var + | Catch + | Finally + | Return + | Void + | Continue + | For + | Switch + | While + | Debugger + | Function + | This + | With + | Default + | If + | Throw + | Delete + | In + | Try + ; futureReservedWord - : Class - | Enum - | Extends - | Super - | Const - | Export - | Import - | Implements - | Let - | Private - | Public - | Interface - | Package - | Protected - | Static - | Yield - ; + : Class + | Enum + | Extends + | Super + | Const + | Export + | Import + | Implements + | Let + | Private + | Public + | Interface + | Package + | Protected + | Static + | Yield + ; getter - : {this._input.LT(1).text.startsWith("get")}? Identifier propertyName - ; + : {this._input.LT(1).text.startsWith("get")}? Identifier propertyName + ; setter - : {this._input.LT(1).text.startsWith("set")}? Identifier propertyName - ; + : {this._input.LT(1).text.startsWith("set")}? Identifier propertyName + ; eos - : SemiColon - | EOF - | {this.lineTerminatorAhead()}? - | {this._input.LT(1).type == ECMAScriptParser.CloseBrace}? - ; + : SemiColon + | EOF + | {this.lineTerminatorAhead()}? + | {this._input.LT(1).type == ECMAScriptParser.CloseBrace}? + ; eof - : EOF - ; + : EOF + ; /// RegularExpressionLiteral :: /// / RegularExpressionBody / RegularExpressionFlags RegularExpressionLiteral - : {this.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags - ; + : {this.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags + ; /// 7.3 Line Terminators LineTerminator - : [\r\n\u2028\u2029] -> channel(HIDDEN) - ; - -OpenBracket : '['; -CloseBracket : ']'; -OpenParen : '('; -CloseParen : ')'; -OpenBrace : '{'; -CloseBrace : '}'; -SemiColon : ';'; -Comma : ','; -Assign : '='; -QuestionMark : '?'; -Colon : ':'; -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 : '|='; + : [\r\n\u2028\u2029] -> channel(HIDDEN) + ; + +OpenBracket + : '[' + ; + +CloseBracket + : ']' + ; + +OpenParen + : '(' + ; + +CloseParen + : ')' + ; + +OpenBrace + : '{' + ; + +CloseBrace + : '}' + ; + +SemiColon + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + +QuestionMark + : '?' + ; + +Colon + : ':' + ; + +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 + : '|=' + ; /// 7.8.1 Null Literals NullLiteral - : 'null' - ; + : 'null' + ; /// 7.8.2 Boolean Literals BooleanLiteral - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; /// 7.8.3 Numeric Literals DecimalLiteral - : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; + : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? + ; /// 7.8.3 Numeric Literals HexIntegerLiteral - : '0' [xX] HexDigit+ - ; + : '0' [xX] HexDigit+ + ; OctalIntegerLiteral - : {!this.strictMode}? '0' OctalDigit+ - ; + : {!this.strictMode}? '0' OctalDigit+ + ; /// 7.6.1.1 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'; +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' + ; /// 7.6.1.2 Future Reserved Words -Class : 'class'; -Enum : 'enum'; -Extends : 'extends'; -Super : 'super'; -Const : 'const'; -Export : 'export'; -Import : 'import'; +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 : {this.strictMode}? 'implements'; -Let : {this.strictMode}? 'let'; -Private : {this.strictMode}? 'private'; -Public : {this.strictMode}? 'public'; -Interface : {this.strictMode}? 'interface'; -Package : {this.strictMode}? 'package'; -Protected : {this.strictMode}? 'protected'; -Static : {this.strictMode}? 'static'; -Yield : {this.strictMode}? 'yield'; +Implements + : {this.strictMode}? 'implements' + ; + +Let + : {this.strictMode}? 'let' + ; + +Private + : {this.strictMode}? 'private' + ; + +Public + : {this.strictMode}? 'public' + ; + +Interface + : {this.strictMode}? 'interface' + ; + +Package + : {this.strictMode}? 'package' + ; + +Protected + : {this.strictMode}? 'protected' + ; + +Static + : {this.strictMode}? 'static' + ; + +Yield + : {this.strictMode}? 'yield' + ; /// 7.6 Identifier Names and Identifiers Identifier - : IdentifierStart IdentifierPart* - ; + : IdentifierStart IdentifierPart* + ; /// 7.8.4 String Literals StringLiteral - : '"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'' - ; + : '"' DoubleStringCharacter* '"' + | '\'' SingleStringCharacter* '\'' + ; WhiteSpaces - : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) - ; + : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) + ; /// 7.4 Comments MultiLineComment - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; SingleLineComment - : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) - ; + : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) + ; UnexpectedCharacter - : . - ; + : . + ; fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~['\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment EscapeSequence - : CharacterEscapeSequence - | '0' // no digit ahead! TODO - | HexEscapeSequence - | UnicodeEscapeSequence - ; + : CharacterEscapeSequence + | '0' // no digit ahead! TODO + | HexEscapeSequence + | UnicodeEscapeSequence + ; fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; + : SingleEscapeCharacter + | NonEscapeCharacter + ; fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; + : 'x' HexDigit HexDigit + ; fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit - ; + : 'u' HexDigit HexDigit HexDigit HexDigit + ; fragment SingleEscapeCharacter - : ['"\\bfnrtv] - ; + : ['"\\bfnrtv] + ; fragment NonEscapeCharacter - : ~['"\\bfnrtv0-9xu\r\n] - ; + : ~['"\\bfnrtv0-9xu\r\n] + ; fragment EscapeCharacter - : SingleEscapeCharacter - | DecimalDigit - | [xu] - ; + : SingleEscapeCharacter + | DecimalDigit + | [xu] + ; fragment LineContinuation - : '\\' LineTerminatorSequence - ; + : '\\' LineTerminatorSequence + ; fragment LineTerminatorSequence - : '\r\n' - | LineTerminator - ; + : '\r\n' + | LineTerminator + ; fragment DecimalDigit - : [0-9] - ; + : [0-9] + ; fragment HexDigit - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment OctalDigit - : [0-7] - ; + : [0-7] + ; fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; + : '0' + | [1-9] DecimalDigit* + ; fragment ExponentPart - : [eE] [+-]? DecimalDigit+ - ; + : [eE] [+-]? DecimalDigit+ + ; fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; + : [\p{L}] + | [$_] + | '\\' UnicodeEscapeSequence + ; fragment IdentifierPart - : IdentifierStart - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | ZWNJ - | ZWJ - ; + : IdentifierStart + | [\p{Mn}] + | [\p{Nd}] + | [\p{Pc}] + | ZWNJ + | ZWJ + ; fragment ZWNJ - : '\u200C' - ; + : '\u200C' + ; fragment ZWJ - : '\u200D' - ; + : '\u200D' + ; /// RegularExpressionBody :: /// RegularExpressionFirstChar RegularExpressionChars @@ -1008,47 +1272,47 @@ fragment ZWJ /// [empty] /// RegularExpressionChars RegularExpressionChar fragment RegularExpressionBody - : RegularExpressionFirstChar RegularExpressionChar* - ; + : RegularExpressionFirstChar RegularExpressionChar* + ; /// RegularExpressionFlags :: /// [empty] /// RegularExpressionFlags IdentifierPart fragment RegularExpressionFlags - : IdentifierPart* - ; + : IdentifierPart* + ; /// RegularExpressionFirstChar :: /// RegularExpressionNonTerminator but not one of * or \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionFirstChar - : ~[\r\n\u2028\u2029*\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029*\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionChar :: /// RegularExpressionNonTerminator but not \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionNonTerminator :: /// SourceCharacter but not LineTerminator fragment RegularExpressionNonTerminator - : ~[\r\n\u2028\u2029] - ; + : ~[\r\n\u2028\u2029] + ; /// RegularExpressionBackslashSequence :: /// \ RegularExpressionNonTerminator fragment RegularExpressionBackslashSequence - : '\\' RegularExpressionNonTerminator - ; + : '\\' RegularExpressionNonTerminator + ; /// RegularExpressionClass :: /// [ RegularExpressionClassChars ] @@ -1057,13 +1321,13 @@ fragment RegularExpressionBackslashSequence /// [empty] /// RegularExpressionClassChars RegularExpressionClassChar fragment RegularExpressionClass - : '[' RegularExpressionClassChar* ']' - ; + : '[' RegularExpressionClassChar* ']' + ; /// RegularExpressionClassChar :: /// RegularExpressionNonTerminator but not ] or \ /// RegularExpressionBackslashSequence fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; \ No newline at end of file + : ~[\r\n\u2028\u2029\]\\] + | RegularExpressionBackslashSequence + ; \ No newline at end of file diff --git a/javascript/ecmascript/Python/ECMAScript.g4 b/javascript/ecmascript/Python/ECMAScript.g4 index 5305e0a311..13797df39f 100644 --- a/javascript/ecmascript/Python/ECMAScript.g4 +++ b/javascript/ecmascript/Python/ECMAScript.g4 @@ -25,6 +25,10 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ECMAScript; @parser::members { @@ -174,23 +178,23 @@ def isRegexPossible(self): /// Program : /// SourceElements? program - : sourceElements? EOF - ; + : sourceElements? EOF + ; /// SourceElements : /// SourceElement /// SourceElements SourceElement sourceElements - : sourceElement+ - ; + : sourceElement+ + ; /// SourceElement : /// Statement /// FunctionDeclaration sourceElement - : {self._input.LA(1) != ECMAScriptParser.Function}? statement - | functionDeclaration - ; + : {self._input.LA(1) != ECMAScriptParser.Function}? statement + | functionDeclaration + ; /// Statement : /// Block @@ -209,79 +213,79 @@ sourceElement /// TryStatement /// DebuggerStatement statement - : block - | variableStatement - | emptyStatement_ - | {self._input.LA(1) != ECMAScriptParser.OpenBrace}? expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - | debuggerStatement - ; + : block + | variableStatement + | emptyStatement_ + | {self._input.LA(1) != ECMAScriptParser.OpenBrace}? expressionStatement + | ifStatement + | iterationStatement + | continueStatement + | breakStatement + | returnStatement + | withStatement + | labelledStatement + | switchStatement + | throwStatement + | tryStatement + | debuggerStatement + ; /// Block : /// { StatementList? } block - : '{' statementList? '}' - ; + : '{' statementList? '}' + ; /// StatementList : /// Statement /// StatementList Statement statementList - : statement+ - ; + : statement+ + ; /// VariableStatement : /// var VariableDeclarationList ; variableStatement - : Var variableDeclarationList eos - ; + : Var variableDeclarationList eos + ; /// VariableDeclarationList : /// VariableDeclaration /// VariableDeclarationList , VariableDeclaration variableDeclarationList - : variableDeclaration ( ',' variableDeclaration )* - ; + : variableDeclaration (',' variableDeclaration)* + ; /// VariableDeclaration : /// Identifier Initialiser? variableDeclaration - : Identifier initialiser? - ; + : Identifier initialiser? + ; /// Initialiser : /// = AssignmentExpression initialiser - : '=' singleExpression - ; + : '=' singleExpression + ; /// EmptyStatement : /// ; emptyStatement_ - : SemiColon - ; + : SemiColon + ; /// ExpressionStatement : /// [lookahead ∉ {{, function}] Expression ; expressionStatement - : expressionSequence eos - ; + : expressionSequence eos + ; /// IfStatement : /// if ( Expression ) Statement else Statement /// if ( Expression ) Statement ifStatement - : If '(' expressionSequence ')' statement ( Else statement )? - ; + : If '(' expressionSequence ')' statement (Else statement)? + ; /// IterationStatement : /// do Statement while ( Expression ); @@ -291,209 +295,209 @@ ifStatement /// for ( LeftHandSideExpression in Expression ) Statement /// for ( var VariableDeclaration in Expression ) Statement iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression In expressionSequence ')' statement # ForInStatement - | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement - ; + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement + ; /// ContinueStatement : /// continue ; /// continue [no LineTerminator here] Identifier ; continueStatement - : Continue ({not self.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos - ; + : Continue ({not self.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos + ; /// BreakStatement : /// break ; /// break [no LineTerminator here] Identifier ; breakStatement - : Break ({not self.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos - ; + : Break ({not self.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos + ; /// ReturnStatement : /// return ; /// return [no LineTerminator here] Expression ; returnStatement - : Return ({not self.here(ECMAScriptParser.LineTerminator)}? expressionSequence)? eos - ; + : Return ({not self.here(ECMAScriptParser.LineTerminator)}? expressionSequence)? eos + ; /// WithStatement : /// with ( Expression ) Statement withStatement - : With '(' expressionSequence ')' statement - ; + : With '(' expressionSequence ')' statement + ; /// SwitchStatement : /// switch ( Expression ) CaseBlock switchStatement - : Switch '(' expressionSequence ')' caseBlock - ; + : Switch '(' expressionSequence ')' caseBlock + ; /// CaseBlock : /// { CaseClauses? } /// { CaseClauses? DefaultClause CaseClauses? } caseBlock - : '{' caseClauses? ( defaultClause caseClauses? )? '}' - ; + : '{' caseClauses? (defaultClause caseClauses?)? '}' + ; /// CaseClauses : /// CaseClause /// CaseClauses CaseClause caseClauses - : caseClause+ - ; + : caseClause+ + ; /// CaseClause : /// case Expression ':' StatementList? caseClause - : Case expressionSequence ':' statementList? - ; + : Case expressionSequence ':' statementList? + ; /// DefaultClause : /// default ':' StatementList? defaultClause - : Default ':' statementList? - ; + : Default ':' statementList? + ; /// LabelledStatement : /// Identifier ':' Statement labelledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; /// ThrowStatement : /// throw [no LineTerminator here] Expression ; throwStatement - : Throw {not self.here(ECMAScriptParser.LineTerminator)}? expressionSequence eos - ; + : Throw {not self.here(ECMAScriptParser.LineTerminator)}? expressionSequence eos + ; /// TryStatement : /// try Block Catch /// try Block Finally /// try Block Catch Finally tryStatement - : Try block catchProduction - | Try block finallyProduction - | Try block catchProduction finallyProduction - ; + : Try block catchProduction + | Try block finallyProduction + | Try block catchProduction finallyProduction + ; /// Catch : /// catch ( Identifier ) Block catchProduction - : Catch '(' Identifier ')' block - ; + : Catch '(' Identifier ')' block + ; /// Finally : /// finally Block finallyProduction - : Finally block - ; + : Finally block + ; /// DebuggerStatement : /// debugger ; debuggerStatement - : Debugger eos - ; + : Debugger eos + ; /// FunctionDeclaration : /// function Identifier ( FormalParameterList? ) { FunctionBody } functionDeclaration - : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' - ; + : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' + ; /// FormalParameterList : /// Identifier /// FormalParameterList , Identifier formalParameterList - : Identifier ( ',' Identifier )* - ; + : Identifier (',' Identifier)* + ; /// FunctionBody : /// SourceElements? functionBody - : sourceElements? - ; + : sourceElements? + ; /// ArrayLiteral : /// [ Elision? ] /// [ ElementList ] /// [ ElementList , Elision? ] arrayLiteral - : '[' elementList? ','? elision? ']' - ; + : '[' elementList? ','? elision? ']' + ; /// ElementList : /// Elision? AssignmentExpression /// ElementList , Elision? AssignmentExpression elementList - : elision? singleExpression ( ',' elision? singleExpression )* - ; + : elision? singleExpression (',' elision? singleExpression)* + ; /// Elision : /// , /// Elision , elision - : ','+ - ; + : ','+ + ; /// ObjectLiteral : /// { } /// { PropertyNameAndValueList } /// { PropertyNameAndValueList , } objectLiteral - : '{' '}' - | '{' propertyNameAndValueList ','? '}' - ; + : '{' '}' + | '{' propertyNameAndValueList ','? '}' + ; /// PropertyNameAndValueList : /// PropertyAssignment /// PropertyNameAndValueList , PropertyAssignment propertyNameAndValueList - : propertyAssignment ( ',' propertyAssignment )* - ; + : propertyAssignment (',' propertyAssignment)* + ; /// PropertyAssignment : /// PropertyName : AssignmentExpression /// get PropertyName ( ) { FunctionBody } /// set PropertyName ( PropertySetParameterList ) { FunctionBody } propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter - ; + : propertyName ':' singleExpression # PropertyExpressionAssignment + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter + ; /// PropertyName : /// IdentifierName /// StringLiteral /// NumericLiteral propertyName - : identifierName - | StringLiteral - | numericLiteral - ; + : identifierName + | StringLiteral + | numericLiteral + ; /// PropertySetParameterList : /// Identifier propertySetParameterList - : Identifier - ; + : Identifier + ; /// Arguments : /// ( ) /// ( ArgumentList ) arguments - : '(' argumentList? ')' - ; + : '(' argumentList? ')' + ; /// ArgumentList : /// AssignmentExpression /// ArgumentList , AssignmentExpression argumentList - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; /// Expression : /// AssignmentExpression @@ -611,422 +615,682 @@ argumentList /// ( Expression ) /// expressionSequence - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; singleExpression - : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '.' identifierName # MemberDotExpression - | singleExpression arguments # ArgumentsExpression - | New singleExpression arguments? # NewExpression - | singleExpression {not self.here(ECMAScriptParser.LineTerminator)}? '++'# PostIncrementExpression - | singleExpression {not self.here(ECMAScriptParser.LineTerminator)}? '--'# PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ( '*' | '/' | '%' ) singleExpression # MultiplicativeExpression - | singleExpression ( '+' | '-' ) singleExpression # AdditiveExpression - | singleExpression ( '<<' | '>>' | '>>>' ) singleExpression # BitShiftExpression - | singleExpression ( '<' | '>' | '<=' | '>=' ) singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ( '==' | '!=' | '===' | '!==' ) singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - ; + : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '.' identifierName # MemberDotExpression + | singleExpression arguments # ArgumentsExpression + | New singleExpression arguments? # NewExpression + | singleExpression {not self.here(ECMAScriptParser.LineTerminator)}? '++' # PostIncrementExpression + | singleExpression {not self.here(ECMAScriptParser.LineTerminator)}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ( '+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + ; /// AssignmentOperator : one of /// *= /= %= += -= <<= >>= >>>= &= ^= |= assignmentOperator - : '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; literal - : ( NullLiteral - | BooleanLiteral - | StringLiteral - | RegularExpressionLiteral - ) - | numericLiteral - ; + : (NullLiteral | BooleanLiteral | StringLiteral | RegularExpressionLiteral) + | numericLiteral + ; numericLiteral - : DecimalLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - ; + : DecimalLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + ; identifierName - : Identifier - | reservedWord - ; + : Identifier + | reservedWord + ; reservedWord - : keyword - | futureReservedWord - | ( NullLiteral - | BooleanLiteral - ) - ; + : keyword + | futureReservedWord + | ( NullLiteral | BooleanLiteral) + ; keyword - : Break - | Do - | Instanceof - | Typeof - | Case - | Else - | New - | Var - | Catch - | Finally - | Return - | Void - | Continue - | For - | Switch - | While - | Debugger - | Function - | This - | With - | Default - | If - | Throw - | Delete - | In - | Try - ; + : Break + | Do + | Instanceof + | Typeof + | Case + | Else + | New + | Var + | Catch + | Finally + | Return + | Void + | Continue + | For + | Switch + | While + | Debugger + | Function + | This + | With + | Default + | If + | Throw + | Delete + | In + | Try + ; futureReservedWord - : Class - | Enum - | Extends - | Super - | Const - | Export - | Import - | Implements - | Let - | Private - | Public - | Interface - | Package - | Protected - | Static - | Yield - ; + : Class + | Enum + | Extends + | Super + | Const + | Export + | Import + | Implements + | Let + | Private + | Public + | Interface + | Package + | Protected + | Static + | Yield + ; getter - : {self._input.LT(1).text == "get"}? Identifier propertyName - ; + : {self._input.LT(1).text == "get"}? Identifier propertyName + ; setter - : {self._input.LT(1).text == "set"}? Identifier propertyName - ; + : {self._input.LT(1).text == "set"}? Identifier propertyName + ; eos - : SemiColon - | EOF - | {self.lineTerminatorAhead()}? - | {self._input.LT(1).type == ECMAScriptParser.CloseBrace}? - ; + : SemiColon + | EOF + | {self.lineTerminatorAhead()}? + | {self._input.LT(1).type == ECMAScriptParser.CloseBrace}? + ; eof - : EOF - ; + : EOF + ; /// RegularExpressionLiteral :: /// / RegularExpressionBody / RegularExpressionFlags RegularExpressionLiteral - : {self.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags - ; + : {self.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags + ; /// 7.3 Line Terminators LineTerminator - : [\r\n\u2028\u2029] -> channel(HIDDEN) - ; - -OpenBracket : '['; -CloseBracket : ']'; -OpenParen : '('; -CloseParen : ')'; -OpenBrace : '{'; -CloseBrace : '}'; -SemiColon : ';'; -Comma : ','; -Assign : '='; -QuestionMark : '?'; -Colon : ':'; -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 : '|='; + : [\r\n\u2028\u2029] -> channel(HIDDEN) + ; + +OpenBracket + : '[' + ; + +CloseBracket + : ']' + ; + +OpenParen + : '(' + ; + +CloseParen + : ')' + ; + +OpenBrace + : '{' + ; + +CloseBrace + : '}' + ; + +SemiColon + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + +QuestionMark + : '?' + ; + +Colon + : ':' + ; + +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 + : '|=' + ; /// 7.8.1 Null Literals NullLiteral - : 'null' - ; + : 'null' + ; /// 7.8.2 Boolean Literals BooleanLiteral - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; /// 7.8.3 Numeric Literals DecimalLiteral - : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; + : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? + ; /// 7.8.3 Numeric Literals HexIntegerLiteral - : '0' [xX] HexDigit+ - ; + : '0' [xX] HexDigit+ + ; OctalIntegerLiteral - : {not self.strictMode}? '0' OctalDigit+ - ; + : {not self.strictMode}? '0' OctalDigit+ + ; /// 7.6.1.1 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'; +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' + ; /// 7.6.1.2 Future Reserved Words -Class : 'class'; -Enum : 'enum'; -Extends : 'extends'; -Super : 'super'; -Const : 'const'; -Export : 'export'; -Import : 'import'; +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 : {self.strictMode}? 'implements'; -Let : {self.strictMode}? 'let'; -Private : {self.strictMode}? 'private'; -Public : {self.strictMode}? 'public'; -Interface : {self.strictMode}? 'interface'; -Package : {self.strictMode}? 'package'; -Protected : {self.strictMode}? 'protected'; -Static : {self.strictMode}? 'static'; -Yield : {self.strictMode}? 'yield'; +Implements + : {self.strictMode}? 'implements' + ; + +Let + : {self.strictMode}? 'let' + ; + +Private + : {self.strictMode}? 'private' + ; + +Public + : {self.strictMode}? 'public' + ; + +Interface + : {self.strictMode}? 'interface' + ; + +Package + : {self.strictMode}? 'package' + ; + +Protected + : {self.strictMode}? 'protected' + ; + +Static + : {self.strictMode}? 'static' + ; + +Yield + : {self.strictMode}? 'yield' + ; /// 7.6 Identifier Names and Identifiers Identifier - : IdentifierStart IdentifierPart* - ; + : IdentifierStart IdentifierPart* + ; /// 7.8.4 String Literals StringLiteral - : '"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'' - ; + : '"' DoubleStringCharacter* '"' + | '\'' SingleStringCharacter* '\'' + ; WhiteSpaces - : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) - ; + : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) + ; /// 7.4 Comments MultiLineComment - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; SingleLineComment - : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) - ; + : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) + ; UnexpectedCharacter - : . - ; + : . + ; fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~['\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment EscapeSequence - : CharacterEscapeSequence - | '0' // no digit ahead! TODO - | HexEscapeSequence - | UnicodeEscapeSequence - ; + : CharacterEscapeSequence + | '0' // no digit ahead! TODO + | HexEscapeSequence + | UnicodeEscapeSequence + ; fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; + : SingleEscapeCharacter + | NonEscapeCharacter + ; fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; + : 'x' HexDigit HexDigit + ; fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit - ; + : 'u' HexDigit HexDigit HexDigit HexDigit + ; fragment SingleEscapeCharacter - : ['"\\bfnrtv] - ; + : ['"\\bfnrtv] + ; fragment NonEscapeCharacter - : ~['"\\bfnrtv0-9xu\r\n] - ; + : ~['"\\bfnrtv0-9xu\r\n] + ; fragment EscapeCharacter - : SingleEscapeCharacter - | DecimalDigit - | [xu] - ; + : SingleEscapeCharacter + | DecimalDigit + | [xu] + ; fragment LineContinuation - : '\\' LineTerminatorSequence - ; + : '\\' LineTerminatorSequence + ; fragment LineTerminatorSequence - : '\r\n' - | LineTerminator - ; + : '\r\n' + | LineTerminator + ; fragment DecimalDigit - : [0-9] - ; + : [0-9] + ; fragment HexDigit - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment OctalDigit - : [0-7] - ; + : [0-7] + ; fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; + : '0' + | [1-9] DecimalDigit* + ; fragment ExponentPart - : [eE] [+-]? DecimalDigit+ - ; + : [eE] [+-]? DecimalDigit+ + ; fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; + : [\p{L}] + | [$_] + | '\\' UnicodeEscapeSequence + ; fragment IdentifierPart - : IdentifierStart - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | ZWNJ - | ZWJ - ; + : IdentifierStart + | [\p{Mn}] + | [\p{Nd}] + | [\p{Pc}] + | ZWNJ + | ZWJ + ; fragment ZWNJ - : '\u200C' - ; + : '\u200C' + ; fragment ZWJ - : '\u200D' - ; + : '\u200D' + ; /// RegularExpressionBody :: /// RegularExpressionFirstChar RegularExpressionChars @@ -1035,47 +1299,47 @@ fragment ZWJ /// [empty] /// RegularExpressionChars RegularExpressionChar fragment RegularExpressionBody - : RegularExpressionFirstChar RegularExpressionChar* - ; + : RegularExpressionFirstChar RegularExpressionChar* + ; /// RegularExpressionFlags :: /// [empty] /// RegularExpressionFlags IdentifierPart fragment RegularExpressionFlags - : IdentifierPart* - ; + : IdentifierPart* + ; /// RegularExpressionFirstChar :: /// RegularExpressionNonTerminator but not one of * or \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionFirstChar - : ~[\r\n\u2028\u2029*\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029*\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionChar :: /// RegularExpressionNonTerminator but not \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionNonTerminator :: /// SourceCharacter but not LineTerminator fragment RegularExpressionNonTerminator - : ~[\r\n\u2028\u2029] - ; + : ~[\r\n\u2028\u2029] + ; /// RegularExpressionBackslashSequence :: /// \ RegularExpressionNonTerminator fragment RegularExpressionBackslashSequence - : '\\' RegularExpressionNonTerminator - ; + : '\\' RegularExpressionNonTerminator + ; /// RegularExpressionClass :: /// [ RegularExpressionClassChars ] @@ -1084,13 +1348,13 @@ fragment RegularExpressionBackslashSequence /// [empty] /// RegularExpressionClassChars RegularExpressionClassChar fragment RegularExpressionClass - : '[' RegularExpressionClassChar* ']' - ; + : '[' RegularExpressionClassChar* ']' + ; /// RegularExpressionClassChar :: /// RegularExpressionNonTerminator but not ] or \ /// RegularExpressionBackslashSequence fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; + : ~[\r\n\u2028\u2029\]\\] + | RegularExpressionBackslashSequence + ; \ No newline at end of file diff --git a/javascript/ecmascript/TypeScript/ECMAScript.g4 b/javascript/ecmascript/TypeScript/ECMAScript.g4 index 43ea1eafb3..07ef697c58 100644 --- a/javascript/ecmascript/TypeScript/ECMAScript.g4 +++ b/javascript/ecmascript/TypeScript/ECMAScript.g4 @@ -28,6 +28,10 @@ * https://github.com/bkiers/ecmascript-parser * Developed by : Bart Kiers, bart@big-o.nl */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ECMAScript; @parser::members { @@ -84,6 +88,7 @@ grammar ECMAScript; @lexer::header { import { Token } from "antlr4ts"; } + @lexer::members { strictMode = true; @@ -172,23 +177,23 @@ isRegexPossible() { /// Program : /// SourceElements? program - : sourceElements? EOF - ; + : sourceElements? EOF + ; /// SourceElements : /// SourceElement /// SourceElements SourceElement sourceElements - : sourceElement+ - ; + : sourceElement+ + ; /// SourceElement : /// Statement /// FunctionDeclaration sourceElement - : {this._input.LT(1).type != ECMAScriptParser.Function}? statement - | functionDeclaration - ; + : {this._input.LT(1).type != ECMAScriptParser.Function}? statement + | functionDeclaration + ; /// Statement : /// Block @@ -207,79 +212,79 @@ sourceElement /// TryStatement /// DebuggerStatement statement - : block - | variableStatement - | emptyStatement_ - | {this._input.LT(1).type != ECMAScriptParser.OpenBrace}? expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - | debuggerStatement - ; + : block + | variableStatement + | emptyStatement_ + | {this._input.LT(1).type != ECMAScriptParser.OpenBrace}? expressionStatement + | ifStatement + | iterationStatement + | continueStatement + | breakStatement + | returnStatement + | withStatement + | labelledStatement + | switchStatement + | throwStatement + | tryStatement + | debuggerStatement + ; /// Block : /// { StatementList? } block - : '{' statementList? '}' - ; + : '{' statementList? '}' + ; /// StatementList : /// Statement /// StatementList Statement statementList - : statement+ - ; + : statement+ + ; /// VariableStatement : /// var VariableDeclarationList ; variableStatement - : Var variableDeclarationList eos - ; + : Var variableDeclarationList eos + ; /// VariableDeclarationList : /// VariableDeclaration /// VariableDeclarationList , VariableDeclaration variableDeclarationList - : variableDeclaration ( ',' variableDeclaration )* - ; + : variableDeclaration (',' variableDeclaration)* + ; /// VariableDeclaration : /// Identifier Initialiser? variableDeclaration - : Identifier initialiser? - ; + : Identifier initialiser? + ; /// Initialiser : /// = AssignmentExpression initialiser - : '=' singleExpression - ; + : '=' singleExpression + ; /// EmptyStatement : /// ; emptyStatement_ - : SemiColon - ; + : SemiColon + ; /// ExpressionStatement : /// [lookahead ∉ {{, function}] Expression ; expressionStatement - : expressionSequence - ; + : expressionSequence + ; /// IfStatement : /// if ( Expression ) Statement else Statement /// if ( Expression ) Statement ifStatement - : If '(' expressionSequence ')' statement ( Else statement )? - ; + : If '(' expressionSequence ')' statement (Else statement)? + ; /// IterationStatement : /// do Statement while ( Expression ); @@ -289,209 +294,209 @@ ifStatement /// for ( LeftHandSideExpression in Expression ) Statement /// for ( var VariableDeclaration in Expression ) Statement iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement - | For '(' singleExpression In expressionSequence ')' statement # ForInStatement - | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement - ; + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' Var variableDeclarationList ';' expressionSequence? ';' expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression In expressionSequence ')' statement # ForInStatement + | For '(' Var variableDeclaration In expressionSequence ')' statement # ForVarInStatement + ; /// ContinueStatement : /// continue ; /// continue [no LineTerminator here] Identifier ; continueStatement - : Continue ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos - ; + : Continue ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos + ; /// BreakStatement : /// break ; /// break [no LineTerminator here] Identifier ; breakStatement - : Break ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos - ; + : Break ({!this.here(ECMAScriptParser.LineTerminator)}? Identifier)? eos + ; /// ReturnStatement : /// return ; /// return [no LineTerminator here] Expression ; returnStatement - : Return ({!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence)? eos - ; + : Return ({!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence)? eos + ; /// WithStatement : /// with ( Expression ) Statement withStatement - : With '(' expressionSequence ')' statement - ; + : With '(' expressionSequence ')' statement + ; /// SwitchStatement : /// switch ( Expression ) CaseBlock switchStatement - : Switch '(' expressionSequence ')' caseBlock - ; + : Switch '(' expressionSequence ')' caseBlock + ; /// CaseBlock : /// { CaseClauses? } /// { CaseClauses? DefaultClause CaseClauses? } caseBlock - : '{' caseClauses? ( defaultClause caseClauses? )? '}' - ; + : '{' caseClauses? (defaultClause caseClauses?)? '}' + ; /// CaseClauses : /// CaseClause /// CaseClauses CaseClause caseClauses - : caseClause+ - ; + : caseClause+ + ; /// CaseClause : /// case Expression ':' StatementList? caseClause - : Case expressionSequence ':' statementList? - ; + : Case expressionSequence ':' statementList? + ; /// DefaultClause : /// default ':' StatementList? defaultClause - : Default ':' statementList? - ; + : Default ':' statementList? + ; /// LabelledStatement : /// Identifier ':' Statement labelledStatement - : Identifier ':' statement - ; + : Identifier ':' statement + ; /// ThrowStatement : /// throw [no LineTerminator here] Expression ; throwStatement - : Throw {!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence eos - ; + : Throw {!this.here(ECMAScriptParser.LineTerminator)}? expressionSequence eos + ; /// TryStatement : /// try Block Catch /// try Block Finally /// try Block Catch Finally tryStatement - : Try block catchProduction - | Try block finallyProduction - | Try block catchProduction finallyProduction - ; + : Try block catchProduction + | Try block finallyProduction + | Try block catchProduction finallyProduction + ; /// Catch : /// catch ( Identifier ) Block catchProduction - : Catch '(' Identifier ')' block - ; + : Catch '(' Identifier ')' block + ; /// Finally : /// finally Block finallyProduction - : Finally block - ; + : Finally block + ; /// DebuggerStatement : /// debugger ; debuggerStatement - : Debugger eos - ; + : Debugger eos + ; /// FunctionDeclaration : /// function Identifier ( FormalParameterList? ) { FunctionBody } functionDeclaration - : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' - ; + : Function Identifier '(' formalParameterList? ')' '{' functionBody '}' + ; /// FormalParameterList : /// Identifier /// FormalParameterList , Identifier formalParameterList - : Identifier ( ',' Identifier )* - ; + : Identifier (',' Identifier)* + ; /// FunctionBody : /// SourceElements? functionBody - : sourceElements? - ; + : sourceElements? + ; /// ArrayLiteral : /// [ Elision? ] /// [ ElementList ] /// [ ElementList , Elision? ] arrayLiteral - : '[' elementList? ','? elision? ']' - ; + : '[' elementList? ','? elision? ']' + ; /// ElementList : /// Elision? AssignmentExpression /// ElementList , Elision? AssignmentExpression elementList - : elision? singleExpression ( ',' elision? singleExpression )* - ; + : elision? singleExpression (',' elision? singleExpression)* + ; /// Elision : /// , /// Elision , elision - : ','+ - ; + : ','+ + ; /// ObjectLiteral : /// { } /// { PropertyNameAndValueList } /// { PropertyNameAndValueList , } objectLiteral - : '{' '}' - | '{' propertyNameAndValueList ','? '}' - ; + : '{' '}' + | '{' propertyNameAndValueList ','? '}' + ; /// PropertyNameAndValueList : /// PropertyAssignment /// PropertyNameAndValueList , PropertyAssignment propertyNameAndValueList - : propertyAssignment ( ',' propertyAssignment )* - ; + : propertyAssignment (',' propertyAssignment)* + ; /// PropertyAssignment : /// PropertyName : AssignmentExpression /// get PropertyName ( ) { FunctionBody } /// set PropertyName ( PropertySetParameterList ) { FunctionBody } propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter - ; + : propertyName ':' singleExpression # PropertyExpressionAssignment + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' propertySetParameterList ')' '{' functionBody '}' # PropertySetter + ; /// PropertyName : /// IdentifierName /// StringLiteral /// NumericLiteral propertyName - : identifierName - | StringLiteral - | numericLiteral - ; + : identifierName + | StringLiteral + | numericLiteral + ; /// PropertySetParameterList : /// Identifier propertySetParameterList - : Identifier - ; + : Identifier + ; /// Arguments : /// ( ) /// ( ArgumentList ) arguments - : '(' argumentList? ')' - ; + : '(' argumentList? ')' + ; /// ArgumentList : /// AssignmentExpression /// ArgumentList , AssignmentExpression argumentList - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; /// Expression : /// AssignmentExpression @@ -609,422 +614,682 @@ argumentList /// ( Expression ) /// expressionSequence - : singleExpression ( ',' singleExpression )* - ; + : singleExpression (',' singleExpression)* + ; singleExpression - : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '.' identifierName # MemberDotExpression - | singleExpression arguments # ArgumentsExpression - | New singleExpression arguments? # NewExpression - | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '++' # PostIncrementExpression - | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ( '*' | '/' | '%' ) singleExpression # MultiplicativeExpression - | singleExpression ( '+' | '-' ) singleExpression # AdditiveExpression - | singleExpression ( '<<' | '>>' | '>>>' ) singleExpression # BitShiftExpression - | singleExpression ( '<' | '>' | '<=' | '>=' ) singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ( '==' | '!=' | '===' | '!==' ) singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' expressionSequence # AssignmentExpression - | singleExpression assignmentOperator expressionSequence # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - ; + : Function Identifier? '(' formalParameterList? ')' '{' functionBody '}' # FunctionExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '.' identifierName # MemberDotExpression + | singleExpression arguments # ArgumentsExpression + | New singleExpression arguments? # NewExpression + | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '++' # PostIncrementExpression + | singleExpression {!this.here(ECMAScriptParser.LineTerminator)}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ( '+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' expressionSequence # AssignmentExpression + | singleExpression assignmentOperator expressionSequence # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + ; /// AssignmentOperator : one of /// *= /= %= += -= <<= >>= >>>= &= ^= |= assignmentOperator - : '*=' - | '/=' - | '%=' - | '+=' - | '-=' - | '<<=' - | '>>=' - | '>>>=' - | '&=' - | '^=' - | '|=' - ; + : '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '>>>=' + | '&=' + | '^=' + | '|=' + ; literal - : ( NullLiteral - | BooleanLiteral - | StringLiteral - | RegularExpressionLiteral - ) - | numericLiteral - ; + : (NullLiteral | BooleanLiteral | StringLiteral | RegularExpressionLiteral) + | numericLiteral + ; numericLiteral - : DecimalLiteral - | HexIntegerLiteral - | OctalIntegerLiteral - ; + : DecimalLiteral + | HexIntegerLiteral + | OctalIntegerLiteral + ; identifierName - : Identifier - | reservedWord - ; + : Identifier + | reservedWord + ; reservedWord - : keyword - | futureReservedWord - | ( NullLiteral - | BooleanLiteral - ) - ; + : keyword + | futureReservedWord + | ( NullLiteral | BooleanLiteral) + ; keyword - : Break - | Do - | Instanceof - | Typeof - | Case - | Else - | New - | Var - | Catch - | Finally - | Return - | Void - | Continue - | For - | Switch - | While - | Debugger - | Function - | This - | With - | Default - | If - | Throw - | Delete - | In - | Try - ; + : Break + | Do + | Instanceof + | Typeof + | Case + | Else + | New + | Var + | Catch + | Finally + | Return + | Void + | Continue + | For + | Switch + | While + | Debugger + | Function + | This + | With + | Default + | If + | Throw + | Delete + | In + | Try + ; futureReservedWord - : Class - | Enum - | Extends - | Super - | Const - | Export - | Import - | Implements - | Let - | Private - | Public - | Interface - | Package - | Protected - | Static - | Yield - ; + : Class + | Enum + | Extends + | Super + | Const + | Export + | Import + | Implements + | Let + | Private + | Public + | Interface + | Package + | Protected + | Static + | Yield + ; getter - : {this._input.LT(1).text?.startsWith("get") ?? false}? Identifier propertyName - ; + : {this._input.LT(1).text?.startsWith("get") ?? false}? Identifier propertyName + ; setter - : {this._input.LT(1).text?.startsWith("set") ?? false}? Identifier propertyName - ; + : {this._input.LT(1).text?.startsWith("set") ?? false}? Identifier propertyName + ; eos - : SemiColon - | EOF - | {this.lineTerminatorAhead()}? - | {this._input.LT(1).type == ECMAScriptParser.CloseBrace}? - ; + : SemiColon + | EOF + | {this.lineTerminatorAhead()}? + | {this._input.LT(1).type == ECMAScriptParser.CloseBrace}? + ; eof - : EOF - ; + : EOF + ; /// RegularExpressionLiteral :: /// / RegularExpressionBody / RegularExpressionFlags RegularExpressionLiteral - : {this.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags - ; + : {this.isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags + ; /// 7.3 Line Terminators LineTerminator - : [\r\n\u2028\u2029] -> channel(HIDDEN) - ; - -OpenBracket : '['; -CloseBracket : ']'; -OpenParen : '('; -CloseParen : ')'; -OpenBrace : '{'; -CloseBrace : '}'; -SemiColon : ';'; -Comma : ','; -Assign : '='; -QuestionMark : '?'; -Colon : ':'; -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 : '|='; + : [\r\n\u2028\u2029] -> channel(HIDDEN) + ; + +OpenBracket + : '[' + ; + +CloseBracket + : ']' + ; + +OpenParen + : '(' + ; + +CloseParen + : ')' + ; + +OpenBrace + : '{' + ; + +CloseBrace + : '}' + ; + +SemiColon + : ';' + ; + +Comma + : ',' + ; + +Assign + : '=' + ; + +QuestionMark + : '?' + ; + +Colon + : ':' + ; + +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 + : '|=' + ; /// 7.8.1 Null Literals NullLiteral - : 'null' - ; + : 'null' + ; /// 7.8.2 Boolean Literals BooleanLiteral - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; /// 7.8.3 Numeric Literals DecimalLiteral - : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; + : DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? + ; /// 7.8.3 Numeric Literals HexIntegerLiteral - : '0' [xX] HexDigit+ - ; + : '0' [xX] HexDigit+ + ; OctalIntegerLiteral - : {!this.strictMode}? '0' OctalDigit+ - ; + : {!this.strictMode}? '0' OctalDigit+ + ; /// 7.6.1.1 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'; +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' + ; /// 7.6.1.2 Future Reserved Words -Class : 'class'; -Enum : 'enum'; -Extends : 'extends'; -Super : 'super'; -Const : 'const'; -Export : 'export'; -Import : 'import'; +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 : {this.strictMode}? 'implements'; -Let : {this.strictMode}? 'let'; -Private : {this.strictMode}? 'private'; -Public : {this.strictMode}? 'public'; -Interface : {this.strictMode}? 'interface'; -Package : {this.strictMode}? 'package'; -Protected : {this.strictMode}? 'protected'; -Static : {this.strictMode}? 'static'; -Yield : {this.strictMode}? 'yield'; +Implements + : {this.strictMode}? 'implements' + ; + +Let + : {this.strictMode}? 'let' + ; + +Private + : {this.strictMode}? 'private' + ; + +Public + : {this.strictMode}? 'public' + ; + +Interface + : {this.strictMode}? 'interface' + ; + +Package + : {this.strictMode}? 'package' + ; + +Protected + : {this.strictMode}? 'protected' + ; + +Static + : {this.strictMode}? 'static' + ; + +Yield + : {this.strictMode}? 'yield' + ; /// 7.6 Identifier Names and Identifiers Identifier - : IdentifierStart IdentifierPart* - ; + : IdentifierStart IdentifierPart* + ; /// 7.8.4 String Literals StringLiteral - : '"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'' - ; + : '"' DoubleStringCharacter* '"' + | '\'' SingleStringCharacter* '\'' + ; WhiteSpaces - : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) - ; + : [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN) + ; /// 7.4 Comments MultiLineComment - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; SingleLineComment - : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) - ; + : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN) + ; UnexpectedCharacter - : . - ; + : . + ; fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; + : ~['\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; fragment EscapeSequence - : CharacterEscapeSequence - | '0' // no digit ahead! TODO - | HexEscapeSequence - | UnicodeEscapeSequence - ; + : CharacterEscapeSequence + | '0' // no digit ahead! TODO + | HexEscapeSequence + | UnicodeEscapeSequence + ; fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; + : SingleEscapeCharacter + | NonEscapeCharacter + ; fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; + : 'x' HexDigit HexDigit + ; fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit - ; + : 'u' HexDigit HexDigit HexDigit HexDigit + ; fragment SingleEscapeCharacter - : ['"\\bfnrtv] - ; + : ['"\\bfnrtv] + ; fragment NonEscapeCharacter - : ~['"\\bfnrtv0-9xu\r\n] - ; + : ~['"\\bfnrtv0-9xu\r\n] + ; fragment EscapeCharacter - : SingleEscapeCharacter - | DecimalDigit - | [xu] - ; + : SingleEscapeCharacter + | DecimalDigit + | [xu] + ; fragment LineContinuation - : '\\' LineTerminatorSequence - ; + : '\\' LineTerminatorSequence + ; fragment LineTerminatorSequence - : '\r\n' - | LineTerminator - ; + : '\r\n' + | LineTerminator + ; fragment DecimalDigit - : [0-9] - ; + : [0-9] + ; fragment HexDigit - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment OctalDigit - : [0-7] - ; + : [0-7] + ; fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; + : '0' + | [1-9] DecimalDigit* + ; fragment ExponentPart - : [eE] [+-]? DecimalDigit+ - ; + : [eE] [+-]? DecimalDigit+ + ; fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; + : [\p{L}] + | [$_] + | '\\' UnicodeEscapeSequence + ; fragment IdentifierPart - : IdentifierStart - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | ZWNJ - | ZWJ - ; + : IdentifierStart + | [\p{Mn}] + | [\p{Nd}] + | [\p{Pc}] + | ZWNJ + | ZWJ + ; fragment ZWNJ - : '\u200C' - ; + : '\u200C' + ; fragment ZWJ - : '\u200D' - ; + : '\u200D' + ; /// RegularExpressionBody :: /// RegularExpressionFirstChar RegularExpressionChars @@ -1033,47 +1298,47 @@ fragment ZWJ /// [empty] /// RegularExpressionChars RegularExpressionChar fragment RegularExpressionBody - : RegularExpressionFirstChar RegularExpressionChar* - ; + : RegularExpressionFirstChar RegularExpressionChar* + ; /// RegularExpressionFlags :: /// [empty] /// RegularExpressionFlags IdentifierPart fragment RegularExpressionFlags - : IdentifierPart* - ; + : IdentifierPart* + ; /// RegularExpressionFirstChar :: /// RegularExpressionNonTerminator but not one of * or \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionFirstChar - : ~[\r\n\u2028\u2029*\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029*\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionChar :: /// RegularExpressionNonTerminator but not \ or / or [ /// RegularExpressionBackslashSequence /// RegularExpressionClass fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | RegularExpressionClass - ; + : ~[\r\n\u2028\u2029\\/[] + | RegularExpressionBackslashSequence + | RegularExpressionClass + ; /// RegularExpressionNonTerminator :: /// SourceCharacter but not LineTerminator fragment RegularExpressionNonTerminator - : ~[\r\n\u2028\u2029] - ; + : ~[\r\n\u2028\u2029] + ; /// RegularExpressionBackslashSequence :: /// \ RegularExpressionNonTerminator fragment RegularExpressionBackslashSequence - : '\\' RegularExpressionNonTerminator - ; + : '\\' RegularExpressionNonTerminator + ; /// RegularExpressionClass :: /// [ RegularExpressionClassChars ] @@ -1082,13 +1347,13 @@ fragment RegularExpressionBackslashSequence /// [empty] /// RegularExpressionClassChars RegularExpressionClassChar fragment RegularExpressionClass - : '[' RegularExpressionClassChar* ']' - ; + : '[' RegularExpressionClassChar* ']' + ; /// RegularExpressionClassChar :: /// RegularExpressionNonTerminator but not ] or \ /// RegularExpressionBackslashSequence fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; \ No newline at end of file + : ~[\r\n\u2028\u2029\]\\] + | RegularExpressionBackslashSequence + ; \ No newline at end of file diff --git a/javascript/javascript/JavaScriptLexer.g4 b/javascript/javascript/JavaScriptLexer.g4 index e5240f12b3..6c4f3381b7 100644 --- a/javascript/javascript/JavaScriptLexer.g4 +++ b/javascript/javascript/JavaScriptLexer.g4 @@ -28,294 +28,256 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar JavaScriptLexer; -channels { ERROR } +channels { + ERROR +} -options { superClass=JavaScriptLexerBase; } +options { + superClass = JavaScriptLexerBase; +} // Insert here @header for C++ lexer. -HashBangLine: { this.IsStartOfFile()}? '#!' ~[\r\n\u2028\u2029]*; // only allowed at start -MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN); -SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); -RegularExpressionLiteral: '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart*; - -OpenBracket: '['; -CloseBracket: ']'; -OpenParen: '('; -CloseParen: ')'; -OpenBrace: '{' {this.ProcessOpenBrace();}; -TemplateCloseBrace: {this.IsInTemplateString()}? '}' -> popMode; -CloseBrace: '}' {this.ProcessCloseBrace();}; -SemiColon: ';'; -Comma: ','; -Assign: '='; -QuestionMark: '?'; -QuestionMarkDot: '?.'; -Colon: ':'; -Ellipsis: '...'; -Dot: '.'; -PlusPlus: '++'; -MinusMinus: '--'; -Plus: '+'; -Minus: '-'; -BitNot: '~'; -Not: '!'; -Multiply: '*'; -Divide: '/'; -Modulus: '%'; -Power: '**'; -NullCoalesce: '??'; -Hashtag: '#'; -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: '|='; -PowerAssign: '**='; -NullishCoalescingAssign: '??='; -ARROW: '=>'; +HashBangLine : { this.IsStartOfFile()}? '#!' ~[\r\n\u2028\u2029]*; // only allowed at start +MultiLineComment : '/*' .*? '*/' -> channel(HIDDEN); +SingleLineComment : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); +RegularExpressionLiteral: + '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart* +; + +OpenBracket : '['; +CloseBracket : ']'; +OpenParen : '('; +CloseParen : ')'; +OpenBrace : '{' {this.ProcessOpenBrace();}; +TemplateCloseBrace : {this.IsInTemplateString()}? '}' -> popMode; +CloseBrace : '}' {this.ProcessCloseBrace();}; +SemiColon : ';'; +Comma : ','; +Assign : '='; +QuestionMark : '?'; +QuestionMarkDot : '?.'; +Colon : ':'; +Ellipsis : '...'; +Dot : '.'; +PlusPlus : '++'; +MinusMinus : '--'; +Plus : '+'; +Minus : '-'; +BitNot : '~'; +Not : '!'; +Multiply : '*'; +Divide : '/'; +Modulus : '%'; +Power : '**'; +NullCoalesce : '??'; +Hashtag : '#'; +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 : '|='; +PowerAssign : '**='; +NullishCoalescingAssign : '??='; +ARROW : '=>'; /// Null Literals -NullLiteral: 'null'; +NullLiteral: 'null'; /// Boolean Literals -BooleanLiteral: 'true' - | 'false'; +BooleanLiteral: 'true' | 'false'; /// Numeric Literals -DecimalLiteral: DecimalIntegerLiteral '.' [0-9] [0-9_]* ExponentPart? - | '.' [0-9] [0-9_]* ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; +DecimalLiteral: + DecimalIntegerLiteral '.' [0-9] [0-9_]* ExponentPart? + | '.' [0-9] [0-9_]* ExponentPart? + | DecimalIntegerLiteral ExponentPart? +; /// Numeric Literals -HexIntegerLiteral: '0' [xX] [0-9a-fA-F] HexDigit*; -OctalIntegerLiteral: '0' [0-7]+ {!this.IsStrictMode()}?; -OctalIntegerLiteral2: '0' [oO] [0-7] [_0-7]*; -BinaryIntegerLiteral: '0' [bB] [01] [_01]*; +HexIntegerLiteral : '0' [xX] [0-9a-fA-F] HexDigit*; +OctalIntegerLiteral : '0' [0-7]+ {!this.IsStrictMode()}?; +OctalIntegerLiteral2 : '0' [oO] [0-7] [_0-7]*; +BinaryIntegerLiteral : '0' [bB] [01] [_01]*; -BigHexIntegerLiteral: '0' [xX] [0-9a-fA-F] HexDigit* 'n'; -BigOctalIntegerLiteral: '0' [oO] [0-7] [_0-7]* 'n'; -BigBinaryIntegerLiteral: '0' [bB] [01] [_01]* 'n'; -BigDecimalIntegerLiteral: DecimalIntegerLiteral 'n'; +BigHexIntegerLiteral : '0' [xX] [0-9a-fA-F] HexDigit* 'n'; +BigOctalIntegerLiteral : '0' [oO] [0-7] [_0-7]* 'n'; +BigBinaryIntegerLiteral : '0' [bB] [01] [_01]* 'n'; +BigDecimalIntegerLiteral : DecimalIntegerLiteral 'n'; /// 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'; -From: 'from'; -Of: 'of'; +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'; +From : 'from'; +Of : 'of'; /// Future Reserved Words -Class: 'class'; -Enum: 'enum'; -Extends: 'extends'; -Super: 'super'; -Const: 'const'; -Export: 'export'; -Import: 'import'; +Class : 'class'; +Enum : 'enum'; +Extends : 'extends'; +Super : 'super'; +Const : 'const'; +Export : 'export'; +Import : 'import'; -Async: 'async'; -Await: 'await'; -Yield: 'yield'; +Async : 'async'; +Await : 'await'; +Yield : 'yield'; /// The following tokens are also considered to be FutureReservedWords /// when parsing strict mode -Implements: 'implements' {this.IsStrictMode()}?; -StrictLet: 'let' {this.IsStrictMode()}?; -NonStrictLet: 'let' {!this.IsStrictMode()}?; -Private: 'private' {this.IsStrictMode()}?; -Public: 'public' {this.IsStrictMode()}?; -Interface: 'interface' {this.IsStrictMode()}?; -Package: 'package' {this.IsStrictMode()}?; -Protected: 'protected' {this.IsStrictMode()}?; -Static: 'static' {this.IsStrictMode()}?; +Implements : 'implements' {this.IsStrictMode()}?; +StrictLet : 'let' {this.IsStrictMode()}?; +NonStrictLet : 'let' {!this.IsStrictMode()}?; +Private : 'private' {this.IsStrictMode()}?; +Public : 'public' {this.IsStrictMode()}?; +Interface : 'interface' {this.IsStrictMode()}?; +Package : 'package' {this.IsStrictMode()}?; +Protected : 'protected' {this.IsStrictMode()}?; +Static : 'static' {this.IsStrictMode()}?; /// Identifier Names and Identifiers -Identifier: IdentifierStart IdentifierPart*; +Identifier: IdentifierStart IdentifierPart*; /// String Literals -StringLiteral: ('"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();} - ; +StringLiteral: + ('"' DoubleStringCharacter* '"' | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();} +; -BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE); +BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE); -WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); +WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); -LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); +LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); /// Comments - -HtmlComment: '' -> channel(HIDDEN); -CDataComment: '' -> channel(HIDDEN); -UnexpectedCharacter: . -> channel(ERROR); +HtmlComment : '' -> channel(HIDDEN); +CDataComment : '' -> channel(HIDDEN); +UnexpectedCharacter : . -> channel(ERROR); mode TEMPLATE; -BackTickInside: '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode; -TemplateStringStartExpression: '${' -> pushMode(DEFAULT_MODE); -TemplateStringAtom: ~[`]; +BackTickInside : '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode; +TemplateStringStartExpression : '${' -> pushMode(DEFAULT_MODE); +TemplateStringAtom : ~[`]; // Fragment rules -fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; +fragment DoubleStringCharacter: ~["\\\r\n] | '\\' EscapeSequence | LineContinuation; -fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; +fragment SingleStringCharacter: ~['\\\r\n] | '\\' EscapeSequence | LineContinuation; -fragment EscapeSequence - : CharacterEscapeSequence +fragment EscapeSequence: + CharacterEscapeSequence | '0' // no digit ahead! TODO | HexEscapeSequence | UnicodeEscapeSequence | ExtendedUnicodeEscapeSequence - ; +; -fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; +fragment CharacterEscapeSequence: SingleEscapeCharacter | NonEscapeCharacter; -fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; +fragment HexEscapeSequence: 'x' HexDigit HexDigit; -fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit +fragment UnicodeEscapeSequence: + 'u' HexDigit HexDigit HexDigit HexDigit | 'u' '{' 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 - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | '\u200C' - | '\u200D' - ; - -fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; - -fragment RegularExpressionFirstChar - : ~[*\r\n\u2028\u2029\\/[] +; + +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 | [\p{Mn}] | [\p{Nd}] | [\p{Pc}] | '\u200C' | '\u200D'; + +fragment IdentifierStart: [\p{L}] | [$_] | '\\' UnicodeEscapeSequence; + +fragment RegularExpressionFirstChar: + ~[*\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' - ; +; -fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] +fragment RegularExpressionChar: + ~[\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' - ; +; -fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; +fragment RegularExpressionClassChar: ~[\r\n\u2028\u2029\]\\] | RegularExpressionBackslashSequence; -fragment RegularExpressionBackslashSequence - : '\\' ~[\r\n\u2028\u2029] - ; +fragment RegularExpressionBackslashSequence: '\\' ~[\r\n\u2028\u2029]; \ No newline at end of file diff --git a/javascript/javascript/JavaScriptParser.g4 b/javascript/javascript/JavaScriptParser.g4 index 993c2b2fc7..d59d1c1189 100644 --- a/javascript/javascript/JavaScriptParser.g4 +++ b/javascript/javascript/JavaScriptParser.g4 @@ -28,13 +28,17 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $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 JavaScriptParser; // Insert here @header for C++ parser. options { - tokenVocab=JavaScriptLexer; - superClass=JavaScriptParserBase; + tokenVocab = JavaScriptLexer; + superClass = JavaScriptParserBase; } program @@ -122,8 +126,8 @@ aliasName ; exportStatement - : Export Default? (exportFromBlock | declaration) eos # ExportDeclaration - | Export Default singleExpression eos # ExportDefaultDeclaration + : Export Default? (exportFromBlock | declaration) eos # ExportDeclaration + | Export Default singleExpression eos # ExportDefaultDeclaration ; exportFromBlock @@ -169,16 +173,15 @@ ifStatement : If '(' expressionSequence ')' statement (Else statement)? ; - iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' (expressionSequence | variableDeclarationList)? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' (singleExpression | variableDeclarationList) In expressionSequence ')' statement # ForInStatement - | For Await? '(' (singleExpression | variableDeclarationList) Of expressionSequence ')' statement # ForOfStatement + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' (expressionSequence | variableDeclarationList)? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' (singleExpression | variableDeclarationList) In expressionSequence ')' statement # ForInStatement + | For Await? '(' (singleExpression | variableDeclarationList) Of expressionSequence ')' statement # ForOfStatement ; -varModifier // let, const - ECMAScript 6 +varModifier // let, const - ECMAScript 6 : Var | let_ | Const @@ -292,10 +295,10 @@ formalParameterList ; formalParameterArg - : assignable ('=' singleExpression)? // ECMAScript 6: Initialization + : assignable ('=' singleExpression)? // ECMAScript 6: Initialization ; -lastFormalParameterArg // ECMAScript 6: Rest Parameter +lastFormalParameterArg // ECMAScript 6: Rest Parameter : Ellipsis singleExpression ; @@ -320,12 +323,12 @@ arrayElement ; propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment - | Async? '*'? propertyName '(' formalParameterList? ')' functionBody # FunctionProperty - | getter '(' ')' functionBody # PropertyGetter - | setter '(' formalParameterArg ')' functionBody # PropertySetter - | Ellipsis? singleExpression # PropertyShorthand + : propertyName ':' singleExpression # PropertyExpressionAssignment + | '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment + | Async? '*'? propertyName '(' formalParameterList? ')' functionBody # FunctionProperty + | getter '(' ')' functionBody # PropertyGetter + | setter '(' formalParameterArg ')' functionBody # PropertySetter + | Ellipsis? singleExpression # PropertyShorthand ; propertyName @@ -336,7 +339,7 @@ propertyName ; arguments - : '('(argument (',' argument)* ','?)?')' + : '(' (argument (',' argument)* ','?)? ')' ; argument @@ -348,56 +351,56 @@ expressionSequence ; singleExpression - : anonymousFunction # FunctionExpression - | Class identifier? classTail # ClassExpression - | singleExpression '?.' singleExpression # OptionalChainExpression - | singleExpression '?.'? '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '?'? '.' '#'? identifierName # MemberDotExpression + : anonymousFunction # FunctionExpression + | Class identifier? classTail # ClassExpression + | singleExpression '?.' singleExpression # OptionalChainExpression + | singleExpression '?.'? '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '?'? '.' '#'? identifierName # MemberDotExpression // Split to try `new Date()` first, then `new Date`. - | New identifier arguments # NewExpression - | New singleExpression arguments # NewExpression - | New singleExpression # NewExpression - | singleExpression arguments # ArgumentsExpression - | New '.' identifier # MetaExpression // new.target - | singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression - | singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | Await singleExpression # AwaitExpression - | singleExpression '**' singleExpression # PowerExpression - | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression - | singleExpression ('+' | '-') singleExpression # AdditiveExpression - | singleExpression '??' singleExpression # CoalesceExpression - | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression - | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | Import '(' singleExpression ')' # ImportExpression - | singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6 - | yieldStatement # YieldExpression // ECMAScript 6 - | This # ThisExpression - | identifier # IdentifierExpression - | Super # SuperExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression + | New identifier arguments # NewExpression + | New singleExpression arguments # NewExpression + | New singleExpression # NewExpression + | singleExpression arguments # ArgumentsExpression + | New '.' identifier # MetaExpression // new.target + | singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression + | singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | Await singleExpression # AwaitExpression + | singleExpression '**' singleExpression # PowerExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ('+' | '-') singleExpression # AdditiveExpression + | singleExpression '??' singleExpression # CoalesceExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | Import '(' singleExpression ')' # ImportExpression + | singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6 + | yieldStatement # YieldExpression // ECMAScript 6 + | This # ThisExpression + | identifier # IdentifierExpression + | Super # SuperExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression ; initializer @@ -417,8 +420,8 @@ objectLiteral ; anonymousFunction - : Async? Function_ '*'? '(' formalParameterList? ')' functionBody # AnonymousFunctionDecl - | Async? arrowFunctionParameters '=>' arrowFunctionBody # ArrowFunction + : Async? Function_ '*'? '(' formalParameterList? ')' functionBody # AnonymousFunctionDecl + | Async? arrowFunctionParameters '=>' arrowFunctionBody # ArrowFunction ; arrowFunctionParameters @@ -537,7 +540,6 @@ keyword | Delete | In | Try - | Class | Enum | Extends @@ -571,4 +573,4 @@ eos | EOF | {this.lineTerminatorAhead()}? | {this.closeBrace()}? - ; + ; \ No newline at end of file diff --git a/javascript/jsx/JavaScriptLexer.g4 b/javascript/jsx/JavaScriptLexer.g4 index 47b56b9bdb..9f0988797f 100644 --- a/javascript/jsx/JavaScriptLexer.g4 +++ b/javascript/jsx/JavaScriptLexer.g4 @@ -28,240 +28,230 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar JavaScriptLexer; -channels { ERROR } - -options { superClass=JavaScriptLexerBase; } - -HashBangLine: { this.IsStartOfFile()}? '#!' ~[\r\n\u2028\u2029]*; // only allowed at start - -OpenBracket: '['; -CloseBracket: ']'; -OpenParen: '('; -CloseParen: ')'; -OpenBrace: '{' {this.ProcessOpenBrace();}; -TemplateCloseBrace: {this.IsInTemplateString()}? '}' -> popMode; -CloseBrace: '}' {this.ProcessCloseBrace();}; -SemiColon: ';'; -Comma: ','; -Assign: '='; -QuestionMark: '?'; -Colon: ':'; -Ellipsis: '...'; -Dot: '.'; -PlusPlus: '++'; -MinusMinus: '--'; -Plus: '+'; -Minus: '-'; -BitNot: '~'; -Not: '!'; -Multiply: '*'; -Divide: '/'; -Modulus: '%'; -Power: '**'; -NullCoalesce: '??'; -Hashtag: '#'; -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: '|='; -PowerAssign: '**='; -ARROW: '=>'; +channels { + ERROR +} + +options { + superClass = JavaScriptLexerBase; +} + +HashBangLine: { this.IsStartOfFile()}? '#!' ~[\r\n\u2028\u2029]*; // only allowed at start + +OpenBracket : '['; +CloseBracket : ']'; +OpenParen : '('; +CloseParen : ')'; +OpenBrace : '{' {this.ProcessOpenBrace();}; +TemplateCloseBrace : {this.IsInTemplateString()}? '}' -> popMode; +CloseBrace : '}' {this.ProcessCloseBrace();}; +SemiColon : ';'; +Comma : ','; +Assign : '='; +QuestionMark : '?'; +Colon : ':'; +Ellipsis : '...'; +Dot : '.'; +PlusPlus : '++'; +MinusMinus : '--'; +Plus : '+'; +Minus : '-'; +BitNot : '~'; +Not : '!'; +Multiply : '*'; +Divide : '/'; +Modulus : '%'; +Power : '**'; +NullCoalesce : '??'; +Hashtag : '#'; +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 : '|='; +PowerAssign : '**='; +ARROW : '=>'; /// Null Literals -NullLiteral: 'null'; +NullLiteral: 'null'; /// Boolean Literals -BooleanLiteral: 'true' - | 'false'; +BooleanLiteral: 'true' | 'false'; /// Numeric Literals -DecimalLiteral: DecimalIntegerLiteral '.' [0-9] [0-9_]* ExponentPart? - | '.' [0-9] [0-9_]* ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; +DecimalLiteral: + DecimalIntegerLiteral '.' [0-9] [0-9_]* ExponentPart? + | '.' [0-9] [0-9_]* ExponentPart? + | DecimalIntegerLiteral ExponentPart? +; /// Numeric Literals -HexIntegerLiteral: '0' [xX] [0-9a-fA-F] HexDigit*; -OctalIntegerLiteral: '0' [0-7]+ {!this.IsStrictMode()}?; -OctalIntegerLiteral2: '0' [oO] [0-7] [_0-7]*; -BinaryIntegerLiteral: '0' [bB] [01] [_01]*; +HexIntegerLiteral : '0' [xX] [0-9a-fA-F] HexDigit*; +OctalIntegerLiteral : '0' [0-7]+ {!this.IsStrictMode()}?; +OctalIntegerLiteral2 : '0' [oO] [0-7] [_0-7]*; +BinaryIntegerLiteral : '0' [bB] [01] [_01]*; -BigHexIntegerLiteral: '0' [xX] [0-9a-fA-F] HexDigit* 'n'; -BigOctalIntegerLiteral: '0' [oO] [0-7] [_0-7]* 'n'; -BigBinaryIntegerLiteral: '0' [bB] [01] [_01]* 'n'; -BigDecimalIntegerLiteral: DecimalIntegerLiteral 'n'; +BigHexIntegerLiteral : '0' [xX] [0-9a-fA-F] HexDigit* 'n'; +BigOctalIntegerLiteral : '0' [oO] [0-7] [_0-7]* 'n'; +BigBinaryIntegerLiteral : '0' [bB] [01] [_01]* 'n'; +BigDecimalIntegerLiteral : DecimalIntegerLiteral 'n'; /// 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'; -From: 'from'; +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'; +From : 'from'; /// Future Reserved Words -Class: 'class'; -Enum: 'enum'; -Extends: 'extends'; -Super: 'super'; -Const: 'const'; -Export: 'export'; -Import: 'import'; +Class : 'class'; +Enum : 'enum'; +Extends : 'extends'; +Super : 'super'; +Const : 'const'; +Export : 'export'; +Import : 'import'; -Async: 'async'; -Await: 'await'; +Async : 'async'; +Await : 'await'; /// The following tokens are also considered to be FutureReservedWords /// when parsing strict mode -Implements: 'implements' {this.IsStrictMode()}?; -StrictLet: 'let' {this.IsStrictMode()}?; -NonStrictLet: 'let' {!this.IsStrictMode()}?; -Private: 'private' {this.IsStrictMode()}?; -Public: 'public' {this.IsStrictMode()}?; -Interface: 'interface' {this.IsStrictMode()}?; -Package: 'package' {this.IsStrictMode()}?; -Protected: 'protected' {this.IsStrictMode()}?; -Static: 'static' {this.IsStrictMode()}?; -Yield: 'yield' {this.IsStrictMode()}?; +Implements : 'implements' {this.IsStrictMode()}?; +StrictLet : 'let' {this.IsStrictMode()}?; +NonStrictLet : 'let' {!this.IsStrictMode()}?; +Private : 'private' {this.IsStrictMode()}?; +Public : 'public' {this.IsStrictMode()}?; +Interface : 'interface' {this.IsStrictMode()}?; +Package : 'package' {this.IsStrictMode()}?; +Protected : 'protected' {this.IsStrictMode()}?; +Static : 'static' {this.IsStrictMode()}?; +Yield : 'yield' {this.IsStrictMode()}?; /// Identifier Names and Identifiers -Identifier: IdentifierStart IdentifierPart*; +Identifier: IdentifierStart IdentifierPart*; /// String Literals -StringLiteral: ('"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();} - ; +StringLiteral: + ('"' DoubleStringCharacter* '"' | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();} +; LinkLiteral: ('http' 's'? | 'ftp' | 'file') '://' [a-zA-Z0-9./?=]+; // TODO Could be more precise -BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE); +BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE); -WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); +WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); -LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); +LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); /// Comments -JsxComment: '{/*' .*? '*/}' -> channel(HIDDEN); -MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN); -SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); -RegularExpressionLiteral: '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart*; +JsxComment : '{/*' .*? '*/}' -> channel(HIDDEN); +MultiLineComment : '/*' .*? '*/' -> channel(HIDDEN); +SingleLineComment : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); +RegularExpressionLiteral: + '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart* +; - -HtmlComment: '' -> channel(HIDDEN); -CDataComment: '' -> channel(HIDDEN); -UnexpectedCharacter: . -> channel(ERROR); -CDATA: '' -> channel(HIDDEN); +HtmlComment : '' -> channel(HIDDEN); +CDataComment : '' -> channel(HIDDEN); +UnexpectedCharacter : . -> channel(ERROR); +CDATA : '' -> channel(HIDDEN); mode TEMPLATE; -BackTickInside: '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode; -TemplateStringStartExpression: '${' -> pushMode(DEFAULT_MODE); -TemplateStringAtom: ~[`]; +BackTickInside : '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode; +TemplateStringStartExpression : '${' -> pushMode(DEFAULT_MODE); +TemplateStringAtom : ~[`]; // // html tag declarations // mode TAG; -TagOpen - : LessThan -> pushMode(TAG) - ; -TagClose - : MoreThan -> popMode - ; +TagOpen : LessThan -> pushMode(TAG); +TagClose : MoreThan -> popMode; -TagSlashClose - : '/>' -> popMode - ; +TagSlashClose: '/>' -> popMode; -TagSlash - : Divide - ; +TagSlash: Divide; -TagName - : TagNameStartChar TagNameChar* - ; +TagName: TagNameStartChar TagNameChar*; // an attribute value may have spaces b/t the '=' and the value -AttributeValue - : [ ]* Attribute -> popMode - ; - -Attribute - : DoubleQuoteString - | SingleQuoteString - | AttributeChar - | HexChars - | DecChars - ; +AttributeValue: [ ]* Attribute -> popMode; + +Attribute: DoubleQuoteString | SingleQuoteString | AttributeChar | HexChars | DecChars; // // lexing mode for attribute values // mode ATTVALUE; -TagEquals - : Assign -> pushMode(ATTVALUE) - ; +TagEquals: Assign -> pushMode(ATTVALUE); // Fragment rules -fragment AttributeChar - : '-' +fragment AttributeChar: + '-' | '_' | '.' | '/' @@ -273,155 +263,92 @@ fragment AttributeChar | ';' | '#' | [0-9a-zA-Z] - ; - -fragment AttributeChars - : AttributeChar+ ' '? - ; - -fragment HexChars - : '#' [0-9a-fA-F]+ - ; - -fragment DecChars - : [0-9]+ '%'? - ; - -fragment DoubleQuoteString - : '"' ~[<"]* '"' - ; -fragment SingleQuoteString - : '\'' ~[<']* '\'' - ; - -fragment -TagNameStartChar - : [:a-zA-Z] - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - ; - -fragment -TagNameChar - : TagNameStartChar +; + +fragment AttributeChars: AttributeChar+ ' '?; + +fragment HexChars: '#' [0-9a-fA-F]+; + +fragment DecChars: [0-9]+ '%'?; + +fragment DoubleQuoteString : '"' ~[<"]* '"'; +fragment SingleQuoteString : '\'' ~[<']* '\''; + +fragment TagNameStartChar: + [:a-zA-Z] + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' +; + +fragment TagNameChar: + TagNameStartChar | '-' | '_' | '.' | Digit - | '\u00B7' - | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; - -fragment -Digit - : [0-9] - ; - -fragment DoubleStringCharacter - : ~["\\] - | '\\' EscapeSequence - | LineContinuation - ; - -fragment SingleStringCharacter - : ~['\\] - | '\\' EscapeSequence - | LineContinuation - ; - -fragment EscapeSequence - : CharacterEscapeSequence + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' +; + +fragment Digit: [0-9]; + +fragment DoubleStringCharacter: ~["\\] | '\\' EscapeSequence | LineContinuation; + +fragment SingleStringCharacter: ~['\\] | '\\' EscapeSequence | LineContinuation; + +fragment EscapeSequence: + CharacterEscapeSequence | '0' // no digit ahead! TODO | HexEscapeSequence | UnicodeEscapeSequence | ExtendedUnicodeEscapeSequence - ; +; -fragment CharacterEscapeSequence - : SingleEscapeCharacter - | NonEscapeCharacter - ; +fragment CharacterEscapeSequence: SingleEscapeCharacter | NonEscapeCharacter; -fragment HexEscapeSequence - : 'x' HexDigit HexDigit - ; +fragment HexEscapeSequence: 'x' HexDigit HexDigit; -fragment UnicodeEscapeSequence - : 'u' HexDigit HexDigit HexDigit HexDigit +fragment UnicodeEscapeSequence: + 'u' HexDigit HexDigit HexDigit HexDigit | 'u' '{' 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 - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | '\u200C' - | '\u200D' - ; - -fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; - -fragment RegularExpressionFirstChar - : ~[*\r\n\u2028\u2029\\/[] +; + +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 | [\p{Mn}] | [\p{Nd}] | [\p{Pc}] | '\u200C' | '\u200D'; + +fragment IdentifierStart: [\p{L}] | [$_] | '\\' UnicodeEscapeSequence; + +fragment RegularExpressionFirstChar: + ~[*\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' - ; +; -fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] +fragment RegularExpressionChar: + ~[\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' - ; +; -fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; +fragment RegularExpressionClassChar: ~[\r\n\u2028\u2029\]\\] | RegularExpressionBackslashSequence; -fragment RegularExpressionBackslashSequence - : '\\' ~[\r\n\u2028\u2029] - ; +fragment RegularExpressionBackslashSequence: '\\' ~[\r\n\u2028\u2029]; \ No newline at end of file diff --git a/javascript/jsx/JavaScriptParser.g4 b/javascript/jsx/JavaScriptParser.g4 index 9746a16478..3770dd2089 100644 --- a/javascript/jsx/JavaScriptParser.g4 +++ b/javascript/jsx/JavaScriptParser.g4 @@ -28,11 +28,15 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $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 JavaScriptParser; options { - tokenVocab=JavaScriptLexer; - superClass=JavaScriptParserBase; + tokenVocab = JavaScriptLexer; + superClass = JavaScriptParserBase; } program @@ -104,8 +108,8 @@ aliasName ; exportStatement - : Export (exportFromBlock | declaration) eos # ExportDeclaration - | Export Default singleExpression eos # ExportDefaultDeclaration + : Export (exportFromBlock | declaration) eos # ExportDeclaration + | Export Default singleExpression eos # ExportDefaultDeclaration ; exportFromBlock @@ -143,17 +147,16 @@ ifStatement : If '(' expressionSequence ')' statement (Else statement)? ; - iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' (expressionSequence | variableDeclarationList)? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement - | For '(' (singleExpression | variableDeclarationList) In expressionSequence ')' statement # ForInStatement + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' (expressionSequence | variableDeclarationList)? ';' expressionSequence? ';' expressionSequence? ')' statement # ForStatement + | For '(' (singleExpression | variableDeclarationList) In expressionSequence ')' statement # ForInStatement // strange, 'of' is an identifier. and this.p("of") not work in sometime. - | For Await? '(' (singleExpression | variableDeclarationList) identifier{this.p("of")}? expressionSequence ')' statement # ForOfStatement + | For Await? '(' (singleExpression | variableDeclarationList) identifier {this.p("of")}? expressionSequence ')' statement # ForOfStatement ; -varModifier // let, const - ECMAScript 6 +varModifier // let, const - ECMAScript 6 : Var | let_ | Const @@ -237,7 +240,10 @@ classTail ; classElement - : (Static | {this.n("static")}? identifier | Async)* (methodDefinition | assignable '=' objectLiteral ';') + : (Static | {this.n("static")}? identifier | Async)* ( + methodDefinition + | assignable '=' objectLiteral ';' + ) | emptyStatement_ | '#'? propertyName '=' singleExpression ; @@ -254,10 +260,10 @@ formalParameterList ; formalParameterArg - : assignable ('=' singleExpression)? // ECMAScript 6: Initialization + : assignable ('=' singleExpression)? // ECMAScript 6: Initialization ; -lastFormalParameterArg // ECMAScript 6: Rest Parameter +lastFormalParameterArg // ECMAScript 6: Rest Parameter : Ellipsis singleExpression ; @@ -282,12 +288,12 @@ arrayElement ; propertyAssignment - : propertyName ':' singleExpression # PropertyExpressionAssignment - | '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment - | Async? '*'? propertyName '(' formalParameterList? ')' '{' functionBody '}' # FunctionProperty - | getter '(' ')' '{' functionBody '}' # PropertyGetter - | setter '(' formalParameterArg ')' '{' functionBody '}' # PropertySetter - | Ellipsis? singleExpression # PropertyShorthand + : propertyName ':' singleExpression # PropertyExpressionAssignment + | '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment + | Async? '*'? propertyName '(' formalParameterList? ')' '{' functionBody '}' # FunctionProperty + | getter '(' ')' '{' functionBody '}' # PropertyGetter + | setter '(' formalParameterArg ')' '{' functionBody '}' # PropertySetter + | Ellipsis? singleExpression # PropertyShorthand ; propertyName @@ -298,7 +304,7 @@ propertyName ; arguments - : '('(argument (',' argument)* ','?)?')' + : '(' (argument (',' argument)* ','?)? ')' ; argument @@ -306,59 +312,59 @@ argument ; expressionSequence - : Ellipsis? singleExpression (',' Ellipsis? singleExpression)* //2020/10/28 add SpreadExpr for htmltag + : Ellipsis? singleExpression (',' Ellipsis? singleExpression)* //2020/10/28 add SpreadExpr for htmltag ; singleExpression - : anoymousFunction # FunctionExpression - | Class identifier? classTail # ClassExpression - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '?'? '.' '#'? identifierName # MemberDotExpression + : anoymousFunction # FunctionExpression + | Class identifier? classTail # ClassExpression + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '?'? '.' '#'? identifierName # MemberDotExpression // Split to try `new Date()` first, then `new Date`. - | New singleExpression arguments # NewExpression - | New singleExpression # NewExpression - | singleExpression arguments # ArgumentsExpression - | New '.' identifier # MetaExpression // new.target - | singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression - | singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | Await singleExpression # AwaitExpression - | singleExpression '**' singleExpression # PowerExpression - | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression - | singleExpression ('+' | '-') singleExpression # AdditiveExpression - | singleExpression '??' singleExpression # CoalesceExpression - | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression - | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | Import '(' singleExpression ')' # ImportExpression - | singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6 - | yieldStatement # YieldExpression // ECMAScript 6 - | This # ThisExpression - | identifier # IdentifierExpression - | Super # SuperExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | htmlElements # htmlElementExpression - | '(' expressionSequence ')' # ParenthesizedExpression + | New singleExpression arguments # NewExpression + | New singleExpression # NewExpression + | singleExpression arguments # ArgumentsExpression + | New '.' identifier # MetaExpression // new.target + | singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression + | singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | Await singleExpression # AwaitExpression + | singleExpression '**' singleExpression # PowerExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ('+' | '-') singleExpression # AdditiveExpression + | singleExpression '??' singleExpression # CoalesceExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | Import '(' singleExpression ')' # ImportExpression + | singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6 + | yieldStatement # YieldExpression // ECMAScript 6 + | This # ThisExpression + | identifier # IdentifierExpression + | Super # SuperExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | htmlElements # htmlElementExpression + | '(' expressionSequence ')' # ParenthesizedExpression ; htmlElements @@ -366,9 +372,9 @@ htmlElements ; htmlElement - : '<' htmlTagStartName htmlAttribute* '>' htmlContent '<''/' htmlTagClosingName '>' - | '<' htmlTagName htmlAttribute* htmlContent '/''>' - | '<' htmlTagName htmlAttribute* '/''>' + : '<' htmlTagStartName htmlAttribute* '>' htmlContent '<' '/' htmlTagClosingName '>' + | '<' htmlTagName htmlAttribute* htmlContent '/' '>' + | '<' htmlTagName htmlAttribute* '/' '>' | '<' htmlTagName htmlAttribute* '>' ; @@ -397,11 +403,11 @@ htmlAttribute htmlAttributeName : TagName - | Identifier ('-' Identifier)* // 2020/10/28 bugfix: '-' is recognized as MINUS and TagName is splited by '-'. + | Identifier ('-' Identifier)* // 2020/10/28 bugfix: '-' is recognized as MINUS and TagName is splited by '-'. ; htmlChardata - : ~('<'|'{')+ + : ~('<' | '{')+ ; htmlAttributeValue @@ -425,9 +431,9 @@ objectExpressionSequence ; anoymousFunction - : functionDeclaration # FunctionDecl - | Async? Function_ '*'? '(' formalParameterList? ')' '{' functionBody '}' # AnoymousFunctionDecl - | Async? arrowFunctionParameters '=>' arrowFunctionBody # ArrowFunction + : functionDeclaration # FunctionDecl + | Async? Function_ '*'? '(' formalParameterList? ')' '{' functionBody '}' # AnoymousFunctionDecl + | Async? arrowFunctionParameters '=>' arrowFunctionBody # ArrowFunction ; arrowFunctionParameters @@ -541,7 +547,6 @@ keyword | Delete | In | Try - | Class | Enum | Extends diff --git a/javascript/typescript/TypeScriptLexer.g4 b/javascript/typescript/TypeScriptLexer.g4 index 3d71fe675a..04795fced4 100644 --- a/javascript/typescript/TypeScriptLexer.g4 +++ b/javascript/typescript/TypeScriptLexer.g4 @@ -1,166 +1,172 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar TypeScriptLexer; -channels { ERROR } +channels { + ERROR +} options { - superClass=TypeScriptLexerBase; + superClass = TypeScriptLexerBase; } - -MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN); -SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); -RegularExpressionLiteral: '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart*; - -OpenBracket: '['; -CloseBracket: ']'; -OpenParen: '('; -CloseParen: ')'; -OpenBrace: '{' {this.ProcessOpenBrace();}; -TemplateCloseBrace: {this.IsInTemplateString()}? '}' -> popMode; -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: '=>'; +MultiLineComment : '/*' .*? '*/' -> channel(HIDDEN); +SingleLineComment : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); +RegularExpressionLiteral: + '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart* +; + +OpenBracket : '['; +CloseBracket : ']'; +OpenParen : '('; +CloseParen : ')'; +OpenBrace : '{' {this.ProcessOpenBrace();}; +TemplateCloseBrace : {this.IsInTemplateString()}? '}' -> popMode; +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'; +NullLiteral: 'null'; /// Boolean Literals -BooleanLiteral: 'true' - | 'false'; +BooleanLiteral: 'true' | 'false'; /// Numeric Literals -DecimalLiteral: DecimalIntegerLiteral '.' [0-9]* ExponentPart? - | '.' [0-9]+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; +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]+; +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'; -From: 'from'; -ReadOnly: 'readonly'; -Async: 'async'; +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'; +From : 'from'; +ReadOnly : 'readonly'; +Async : 'async'; /// Future Reserved Words -Class: 'class'; -Enum: 'enum'; -Extends: 'extends'; -Super: 'super'; -Const: 'const'; -Export: 'export'; -Import: 'import'; +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' ; +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'; +Any : 'any'; +Number : 'number'; +Boolean : 'boolean'; +String : 'string'; +Symbol : 'symbol'; +TypeAlias: 'type'; -TypeAlias : 'type'; +Get : 'get'; +Set : 'set'; -Get: 'get'; -Set: 'set'; - -Constructor: 'constructor'; -Namespace: 'namespace'; -Require: 'require'; -Module: 'module'; -Declare: 'declare'; +Constructor : 'constructor'; +Namespace : 'namespace'; +Require : 'require'; +Module : 'module'; +Declare : 'declare'; Abstract: 'abstract'; @@ -173,136 +179,84 @@ At: '@'; /// Identifier Names and Identifiers -Identifier: IdentifierStart IdentifierPart*; +Identifier: IdentifierStart IdentifierPart*; /// String Literals -StringLiteral: ('"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();} - ; +StringLiteral: + ('"' DoubleStringCharacter* '"' | '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();} +; -BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE); +BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE); -WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); +WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); -LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); +LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); /// Comments - -HtmlComment: '' -> channel(HIDDEN); -CDataComment: '' -> channel(HIDDEN); -UnexpectedCharacter: . -> channel(ERROR); +HtmlComment : '' -> channel(HIDDEN); +CDataComment : '' -> channel(HIDDEN); +UnexpectedCharacter : . -> channel(ERROR); mode TEMPLATE; -TemplateStringEscapeAtom: '\\' .; -BackTickInside: '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode; -TemplateStringStartExpression: '${' {this.StartTemplateString();} -> pushMode(DEFAULT_MODE); -TemplateStringAtom: ~[`\\]; +TemplateStringEscapeAtom : '\\' .; +BackTickInside : '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode; +TemplateStringStartExpression : '${' {this.StartTemplateString();} -> pushMode(DEFAULT_MODE); +TemplateStringAtom : ~[`\\]; // Fragment rules -fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; +fragment DoubleStringCharacter: ~["\\\r\n] | '\\' EscapeSequence | LineContinuation; -fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; +fragment SingleStringCharacter: ~['\\\r\n] | '\\' EscapeSequence | LineContinuation; -fragment EscapeSequence - : CharacterEscapeSequence +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 - | [\p{Mn}] - | [\p{Nd}] - | [\p{Pc}] - | '\u200C' - | '\u200D' - ; - -fragment IdentifierStart - : [\p{L}] - | [$_] - | '\\' UnicodeEscapeSequence - ; - -fragment RegularExpressionFirstChar - : ~[*\r\n\u2028\u2029\\/[] - | RegularExpressionBackslashSequence - | '[' RegularExpressionClassChar* ']' - ; +; + +fragment CharacterEscapeSequence: SingleEscapeCharacter | NonEscapeCharacter; + +fragment HexEscapeSequence: 'x' HexDigit HexDigit; + +fragment UnicodeEscapeSequence: 'u' HexDigit HexDigit HexDigit HexDigit; + +fragment ExtendedUnicodeEscapeSequence: 'u' '{' HexDigit+ '}'; -fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] +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 | [\p{Mn}] | [\p{Nd}] | [\p{Pc}] | '\u200C' | '\u200D'; + +fragment IdentifierStart: [\p{L}] | [$_] | '\\' UnicodeEscapeSequence; + +fragment RegularExpressionFirstChar: + ~[*\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' - ; +; -fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] +fragment RegularExpressionChar: + ~[\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence - ; + | '[' RegularExpressionClassChar* ']' +; -fragment RegularExpressionBackslashSequence - : '\\' ~[\r\n\u2028\u2029] - ; +fragment RegularExpressionClassChar: ~[\r\n\u2028\u2029\]\\] | RegularExpressionBackslashSequence; +fragment RegularExpressionBackslashSequence: '\\' ~[\r\n\u2028\u2029]; \ No newline at end of file diff --git a/javascript/typescript/TypeScriptParser.g4 b/javascript/typescript/TypeScriptParser.g4 index 6e81b63eab..a120748aee 100644 --- a/javascript/typescript/TypeScriptParser.g4 +++ b/javascript/typescript/TypeScriptParser.g4 @@ -28,11 +28,15 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + +// $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 TypeScriptParser; options { - tokenVocab=TypeScriptLexer; - superClass=TypeScriptParserBase; + tokenVocab = TypeScriptLexer; + superClass = TypeScriptParserBase; } // SupportSyntax @@ -86,21 +90,21 @@ type_ ; unionOrIntersectionOrPrimaryType - : unionOrIntersectionOrPrimaryType '|' unionOrIntersectionOrPrimaryType #Union - | unionOrIntersectionOrPrimaryType '&' unionOrIntersectionOrPrimaryType #Intersection - | primaryType #Primary + : unionOrIntersectionOrPrimaryType '|' unionOrIntersectionOrPrimaryType # Union + | unionOrIntersectionOrPrimaryType '&' unionOrIntersectionOrPrimaryType # Intersection + | primaryType # Primary ; primaryType - : '(' type_ ')' #ParenthesizedPrimType - | predefinedType #PredefinedPrimType - | typeReference #ReferencePrimType - | objectType #ObjectPrimType - | primaryType {notLineTerminator()}? '[' ']' #ArrayPrimType - | '[' tupleElementTypes ']' #TuplePrimType - | typeQuery #QueryPrimType - | This #ThisPrimType - | typeReference Is primaryType #RedefinitionOfType + : '(' type_ ')' # ParenthesizedPrimType + | predefinedType # PredefinedPrimType + | typeReference # ReferencePrimType + | objectType # ObjectPrimType + | primaryType {notLineTerminator()}? '[' ']' # ArrayPrimType + | '[' tupleElementTypes ']' # TuplePrimType + | typeQuery # QueryPrimType + | This # ThisPrimType + | typeReference Is primaryType # RedefinitionOfType ; predefinedType @@ -133,7 +137,7 @@ typeGeneric ; typeIncludeGeneric - :'<' typeArgumentList '<' typeArgumentList ('>' bindingPattern '>' | '>>') + : '<' typeArgumentList '<' typeArgumentList ('>' bindingPattern '>' | '>>') ; typeName @@ -217,7 +221,12 @@ parameter ; optionalParameter - : decoratorList? ( accessibilityModifier? identifierOrPattern ('?' typeAnnotation? | typeAnnotation? initializer)) + : decoratorList? ( + accessibilityModifier? identifierOrPattern ( + '?' typeAnnotation? + | typeAnnotation? initializer + ) + ) ; restParameter @@ -244,7 +253,7 @@ constructSignature ; indexSignature - : '[' Identifier ':' (Number|String) ']' typeAnnotation + : '[' Identifier ':' (Number | String) ']' typeAnnotation ; methodSignature @@ -256,7 +265,10 @@ typeAliasDeclaration ; constructorDeclaration - : accessibilityModifier? Constructor '(' formalParameterList? ')' ( ('{' functionBody '}') | SemiColon)? + : accessibilityModifier? Constructor '(' formalParameterList? ')' ( + ('{' functionBody '}') + | SemiColon + )? ; // A.5 Interface @@ -308,7 +320,8 @@ importAliasDeclaration // Ext.2 Additions to 1.8: Decorators decoratorList - : decorator+ ; + : decorator+ + ; decorator : '@' (decoratorMemberExpression | decoratorCallExpression) @@ -321,7 +334,8 @@ decoratorMemberExpression ; decoratorCallExpression - : decoratorMemberExpression arguments; + : decoratorMemberExpression arguments + ; // ECMAPart program @@ -402,7 +416,9 @@ variableDeclarationList ; variableDeclaration - : ( identifierOrKeyWord | arrayLiteral | objectLiteral) typeAnnotation? singleExpression? ('=' typeParameters? singleExpression)? // ECMAScript 6: Array & Object Matching + : (identifierOrKeyWord | arrayLiteral | objectLiteral) typeAnnotation? singleExpression? ( + '=' typeParameters? singleExpression + )? // ECMAScript 6: Array & Object Matching ; emptyStatement_ @@ -417,15 +433,13 @@ ifStatement : If '(' expressionSequence ')' statement (Else statement)? ; - iterationStatement - : Do statement While '(' expressionSequence ')' eos # DoStatement - | While '(' expressionSequence ')' statement # WhileStatement - | For '(' expressionSequence? SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForStatement - | For '(' varModifier variableDeclarationList SemiColon expressionSequence? SemiColon expressionSequence? ')' - statement # ForVarStatement - | For '(' singleExpression (In | Identifier{this.p("of")}?) expressionSequence ')' statement # ForInStatement - | For '(' varModifier variableDeclaration (In | Identifier{this.p("of")}?) expressionSequence ')' statement # ForVarInStatement + : Do statement While '(' expressionSequence ')' eos # DoStatement + | While '(' expressionSequence ')' statement # WhileStatement + | For '(' expressionSequence? SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForStatement + | For '(' varModifier variableDeclarationList SemiColon expressionSequence? SemiColon expressionSequence? ')' statement # ForVarStatement + | For '(' singleExpression (In | Identifier {this.p("of")}?) expressionSequence ')' statement # ForInStatement + | For '(' varModifier variableDeclaration (In | Identifier {this.p("of")}?) expressionSequence ')' statement # ForVarInStatement ; varModifier @@ -499,7 +513,7 @@ debuggerStatement ; functionDeclaration - : Function_ Identifier callSignature ( ('{' functionBody '}') | SemiColon) + : Function_ Identifier callSignature (('{' functionBody '}') | SemiColon) ; //Ovveride ECMA @@ -512,7 +526,7 @@ classHeritage ; classTail - : '{' classElement* '}' + : '{' classElement* '}' ; classExtendsClause @@ -532,10 +546,10 @@ classElement ; propertyMemberDeclaration - : propertyMemberBase propertyName '?'? typeAnnotation? initializer? SemiColon # PropertyDeclarationExpression - | propertyMemberBase propertyName callSignature ( ('{' functionBody '}') | SemiColon) # MethodDeclarationExpression - | propertyMemberBase (getAccessor | setAccessor) # GetterSetterDeclarationExpression - | abstractDeclaration # AbstractMemberDeclaration + : propertyMemberBase propertyName '?'? typeAnnotation? initializer? SemiColon # PropertyDeclarationExpression + | propertyMemberBase propertyName callSignature (('{' functionBody '}') | SemiColon) # MethodDeclarationExpression + | propertyMemberBase (getAccessor | setAccessor) # GetterSetterDeclarationExpression + | abstractDeclaration # AbstractMemberDeclaration ; propertyMemberBase @@ -547,7 +561,7 @@ indexMemberDeclaration ; generatorMethod - : '*'? Identifier '(' formalParameterList? ')' '{' functionBody '}' + : '*'? Identifier '(' formalParameterList? ')' '{' functionBody '}' ; generatorFunctionDeclaration @@ -573,15 +587,17 @@ iteratorDefinition formalParameterList : formalParameterArg (',' formalParameterArg)* (',' lastFormalParameterArg)? | lastFormalParameterArg - | arrayLiteral // ECMAScript 6: Parameter Context Matching - | objectLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching + | arrayLiteral // ECMAScript 6: Parameter Context Matching + | objectLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching ; formalParameterArg - : decorator? accessibilityModifier? identifierOrKeyWord '?'? typeAnnotation? ('=' singleExpression)? // ECMAScript 6: Initialization + : decorator? accessibilityModifier? identifierOrKeyWord '?'? typeAnnotation? ( + '=' singleExpression + )? // ECMAScript 6: Initialization ; -lastFormalParameterArg // ECMAScript 6: Rest Parameter +lastFormalParameterArg // ECMAScript 6: Rest Parameter : Ellipsis Identifier typeAnnotation? ; @@ -601,7 +617,7 @@ elementList : arrayElement (','+ arrayElement)* ; -arrayElement // ECMAScript 6: Spread Operator +arrayElement // ECMAScript 6: Spread Operator : Ellipsis? (singleExpression | Identifier) ','? ; @@ -611,13 +627,13 @@ objectLiteral // MODIFIED propertyAssignment - : propertyName (':' |'=') singleExpression # PropertyExpressionAssignment - | '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment - | getAccessor # PropertyGetter - | setAccessor # PropertySetter - | generatorMethod # MethodProperty - | identifierOrKeyWord # PropertyShorthand - | restParameter # RestParameterInObject + : propertyName (':' | '=') singleExpression # PropertyExpressionAssignment + | '[' singleExpression ']' ':' singleExpression # ComputedPropertyExpressionAssignment + | getAccessor # PropertyGetter + | setAccessor # PropertySetter + | generatorMethod # MethodProperty + | identifierOrKeyWord # PropertyShorthand + | restParameter # RestParameterInObject ; getAccessor @@ -625,7 +641,7 @@ getAccessor ; setAccessor - : setter '(' ( Identifier | bindingPattern) typeAnnotation? ')' '{' functionBody '}' + : setter '(' (Identifier | bindingPattern) typeAnnotation? ')' '{' functionBody '}' ; propertyName @@ -642,7 +658,7 @@ argumentList : argument (',' argument)* ; -argument // ECMAScript 6: Spread Operator +argument // ECMAScript 6: Spread Operator : Ellipsis? (singleExpression | Identifier) ; @@ -655,54 +671,54 @@ functionExpressionDeclaration ; singleExpression - : functionExpressionDeclaration # FunctionExpression - | arrowFunctionDeclaration # ArrowFunctionExpression // ECMAScript 6 - | singleExpression '[' expressionSequence ']' # MemberIndexExpression - | singleExpression '!'? '.' identifierName nestedTypeGeneric? # MemberDotExpression + : functionExpressionDeclaration # FunctionExpression + | arrowFunctionDeclaration # ArrowFunctionExpression // ECMAScript 6 + | singleExpression '[' expressionSequence ']' # MemberIndexExpression + | singleExpression '!'? '.' identifierName nestedTypeGeneric? # MemberDotExpression // Split to try `new Date()` first, then `new Date`. - | New singleExpression typeArguments? arguments # NewExpression - | New singleExpression typeArguments? # NewExpression - | singleExpression arguments # ArgumentsExpression - | singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression - | singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression - | Delete singleExpression # DeleteExpression - | Void singleExpression # VoidExpression - | Typeof singleExpression # TypeofExpression - | '++' singleExpression # PreIncrementExpression - | '--' singleExpression # PreDecreaseExpression - | '+' singleExpression # UnaryPlusExpression - | '-' singleExpression # UnaryMinusExpression - | '~' singleExpression # BitNotExpression - | '!' singleExpression # NotExpression - | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression - | singleExpression ('+' | '-') singleExpression # AdditiveExpression - | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression - | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression - | singleExpression Instanceof singleExpression # InstanceofExpression - | singleExpression In singleExpression # InExpression - | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression - | singleExpression '&' singleExpression # BitAndExpression - | singleExpression '^' singleExpression # BitXOrExpression - | singleExpression '|' singleExpression # BitOrExpression - | singleExpression '&&' singleExpression # LogicalAndExpression - | singleExpression '||' singleExpression # LogicalOrExpression - | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression - | singleExpression '=' singleExpression # AssignmentExpression - | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression - | singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6 - | iteratorBlock # IteratorsExpression // ECMAScript 6 - | generatorBlock # GeneratorsExpression // ECMAScript 6 - | generatorFunctionDeclaration # GeneratorsFunctionExpression // ECMAScript 6 - | yieldStatement # YieldExpression // ECMAScript 6 - | This # ThisExpression - | identifierName singleExpression? # IdentifierExpression - | Super # SuperExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressionSequence ')' # ParenthesizedExpression - | typeArguments expressionSequence? # GenericTypes - | singleExpression As asExpression # CastAsExpression + | New singleExpression typeArguments? arguments # NewExpression + | New singleExpression typeArguments? # NewExpression + | singleExpression arguments # ArgumentsExpression + | singleExpression {this.notLineTerminator()}? '++' # PostIncrementExpression + | singleExpression {this.notLineTerminator()}? '--' # PostDecreaseExpression + | Delete singleExpression # DeleteExpression + | Void singleExpression # VoidExpression + | Typeof singleExpression # TypeofExpression + | '++' singleExpression # PreIncrementExpression + | '--' singleExpression # PreDecreaseExpression + | '+' singleExpression # UnaryPlusExpression + | '-' singleExpression # UnaryMinusExpression + | '~' singleExpression # BitNotExpression + | '!' singleExpression # NotExpression + | singleExpression ('*' | '/' | '%') singleExpression # MultiplicativeExpression + | singleExpression ('+' | '-') singleExpression # AdditiveExpression + | singleExpression ('<<' | '>>' | '>>>') singleExpression # BitShiftExpression + | singleExpression ('<' | '>' | '<=' | '>=') singleExpression # RelationalExpression + | singleExpression Instanceof singleExpression # InstanceofExpression + | singleExpression In singleExpression # InExpression + | singleExpression ('==' | '!=' | '===' | '!==') singleExpression # EqualityExpression + | singleExpression '&' singleExpression # BitAndExpression + | singleExpression '^' singleExpression # BitXOrExpression + | singleExpression '|' singleExpression # BitOrExpression + | singleExpression '&&' singleExpression # LogicalAndExpression + | singleExpression '||' singleExpression # LogicalOrExpression + | singleExpression '?' singleExpression ':' singleExpression # TernaryExpression + | singleExpression '=' singleExpression # AssignmentExpression + | singleExpression assignmentOperator singleExpression # AssignmentOperatorExpression + | singleExpression templateStringLiteral # TemplateStringExpression // ECMAScript 6 + | iteratorBlock # IteratorsExpression // ECMAScript 6 + | generatorBlock # GeneratorsExpression // ECMAScript 6 + | generatorFunctionDeclaration # GeneratorsFunctionExpression // ECMAScript 6 + | yieldStatement # YieldExpression // ECMAScript 6 + | This # ThisExpression + | identifierName singleExpression? # IdentifierExpression + | Super # SuperExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressionSequence ')' # ParenthesizedExpression + | typeArguments expressionSequence? # GenericTypes + | singleExpression As asExpression # CastAsExpression ; asExpression @@ -851,4 +867,4 @@ eos | EOF | {this.lineTerminatorAhead()}? | {this.closeBrace()}? - ; + ; \ No newline at end of file diff --git a/joss/joss.g4 b/joss/joss.g4 index 0f46fae432..5bf6fecad9 100644 --- a/joss/joss.g4 +++ b/joss/joss.g4 @@ -29,458 +29,461 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar joss; prog - : statement+ EOF - ; + : statement+ EOF + ; statement - : direct '.' - | indirect_ '.' - | formCMD - | assignment - ; + : direct '.' + | indirect_ '.' + | formCMD + | assignment + ; direct - : cancelCMD - | deleteCmdCMD - | goCMD - | arbitraryCMD - ; + : cancelCMD + | deleteCmdCMD + | goCMD + | arbitraryCMD + ; indirect_ - : STEPNUMBER indirectCMD - ; + : STEPNUMBER indirectCMD + ; indirectCMD - : toCMD - | doneCMD - | stopCMD - | demandCMD - | arbitraryCMD - ; + : toCMD + | doneCMD + | stopCMD + | demandCMD + | arbitraryCMD + ; arbitraryCMD - : setCMD - | doCMD - | typeCMD - | deleteValCMD - | LINECMD - | PAGECMD - ; + : setCMD + | doCMD + | typeCMD + | deleteValCMD + | LINECMD + | PAGECMD + ; goCMD - : 'Go' - ; + : 'Go' + ; cancelCMD - : 'Cancel' - ; + : 'Cancel' + ; deleteCmdCMD - : 'Delete' delCmdSel - ; + : 'Delete' delCmdSel + ; delCmdSel - : stepSel - | partSel - | formSel - | delCmdAllSel - ; + : stepSel + | partSel + | formSel + | delCmdAllSel + ; delCmdAllSel - : 'all' - | 'all' delCmdAllType - ; + : 'all' + | 'all' delCmdAllType + ; delCmdAllType - : 'steps' - | 'parts' - | 'forms' - ; + : 'steps' + | 'parts' + | 'forms' + ; doneCMD - : 'Done' - ; + : 'Done' + ; stopCMD - : 'Stop' - ; + : 'Stop' + ; demandCMD - : 'Demand' variable - ; + : 'Demand' variable + ; toCMD - : 'To' toSel - ; + : 'To' toSel + ; toSel - : stepSel - | partSel - ; + : stepSel + | partSel + ; setCMD - : 'Set' assignment - ; + : 'Set' assignment + ; doCMD - : 'Do' doSel - | 'Do' doSel conditional - ; + : 'Do' doSel + | 'Do' doSel conditional + ; doSel - : stepSel - | partSel - ; + : stepSel + | partSel + ; typeCMD - : 'Type' typeContent - ; + : 'Type' typeContent + ; typeContent - : typeForm - | typeData - | typeSel - | typeSys - ; + : typeForm + | typeData + | typeSel + | typeSys + ; typeSys - : 'size' - | 'time' - | 'users' - ; + : 'size' + | 'time' + | 'users' + ; typeForm - : varList 'in' formSel - ; + : varList 'in' formSel + ; typeData - : typeElem - | typeElem ',' typeData - ; + : typeElem + | typeElem ',' typeData + ; typeElem - : '\'' STRING '\'' - | variable - ; + : '\'' STRING '\'' + | variable + ; typeSel - : stepSel - | partSel - | formSel - | typeAllSel - ; + : stepSel + | partSel + | formSel + | typeAllSel + ; typeAllSel - : 'all' - | 'all' typeAllType - ; + : 'all' + | 'all' typeAllType + ; typeAllType - : 'steps' - | 'parts' - | 'forms' - | 'values' - ; + : 'steps' + | 'parts' + | 'forms' + | 'values' + ; deleteValCMD - : varList - | 'all' 'values' - ; + : varList + | 'all' 'values' + ; formCMD - : 'Form' PARTNUMBER ':' - ; + : 'Form' PARTNUMBER ':' + ; formContent - : formObject - | formObject formContent - ; + : formObject + | formObject formContent + ; formObject - : formPH - | STRING - ; + : formPH + | STRING + ; formPH - : sciNotation - | fixedNotation - ; + : sciNotation + | fixedNotation + ; sciNotation - : '..' dot - ; + : '..' dot + ; dot - : '.' - | '.' dot - ; + : '.' + | '.' dot + ; fixedNotation - : '__' uScore '.__' uScore - ; + : '__' uScore '.__' uScore + ; uScore - : '_'+ - ; + : '_'+ + ; stepSel - : 'step' STEPNUMBER - ; + : 'step' STEPNUMBER + ; partSel - : 'part' PARTNUMBER - ; + : 'part' PARTNUMBER + ; formSel - : 'form' PARTNUMBER - ; + : 'form' PARTNUMBER + ; conditional - : if_ - | for_ - ; + : if_ + | for_ + ; if_ - : 'if' boolExp - ; + : 'if' boolExp + ; boolExp - : '(' boolExp ')' - | '[' boolExp ']' - | comparison - | comparison boolOp boolExp - ; + : '(' boolExp ')' + | '[' boolExp ']' + | comparison + | comparison boolOp boolExp + ; boolOp - : 'and' - | 'or' - ; + : 'and' + | 'or' + ; comparison - : mathExp boolComp mathExp - ; + : mathExp boolComp mathExp + ; boolComp - : '=' - | '!=' - | '<=' - | '=>' - | '<' - | '>' - ; + : '=' + | '!=' + | '<=' + | '=>' + | '<' + | '>' + ; for_ - : 'for' range_ - ; + : 'for' range_ + ; range_ - : variable '=' rangeExp - ; + : variable '=' rangeExp + ; rangeExp - : rangeVal - | rangeVal ',' rangeExp - ; + : rangeVal + | rangeVal ',' rangeExp + ; rangeVal - : mathExp '(' mathExp ')' rangeVal - | mathExp - ; + : mathExp '(' mathExp ')' rangeVal + | mathExp + ; mathExp - : term - | term ADDOP mathExp - ; + : term + | term ADDOP mathExp + ; term - : factor - | factor MULOP term - ; + : factor + | factor MULOP term + ; factor - : '(' mathExp ')' - | '[' mathExp ']' - | value - ; + : '(' mathExp ')' + | '[' mathExp ']' + | value + ; assignment - : variable '=' mathExp - ; + : variable '=' mathExp + ; value - : NUMBER - | variable - | function_ - ; + : NUMBER + | variable + | function_ + ; function_ - : funcSqrt - | funcLog - | funcExp - | funcSin - | funcCos - | funcIp - | funcFp - | funcDp - | funcXp - | funcSgn - | funcMax - | funcMin - ; + : funcSqrt + | funcLog + | funcExp + | funcSin + | funcCos + | funcIp + | funcFp + | funcDp + | funcXp + | funcSgn + | funcMax + | funcMin + ; funcSqrt - : 'sqrt(' mathExp ')' - ; + : 'sqrt(' mathExp ')' + ; funcLog - : 'log(' mathExp ')' - ; + : 'log(' mathExp ')' + ; funcExp - : 'exp(' mathExp ')' - ; + : 'exp(' mathExp ')' + ; funcSin - : 'sin(' mathExp ')' - ; + : 'sin(' mathExp ')' + ; funcCos - : 'cos(' mathExp ')' - ; + : 'cos(' mathExp ')' + ; funcIp - : 'ip(' mathExp ')' - ; + : 'ip(' mathExp ')' + ; funcFp - : 'fp(' mathExp ')' - ; + : 'fp(' mathExp ')' + ; funcDp - : 'dp(' mathExp ')' - ; + : 'dp(' mathExp ')' + ; funcXp - : 'xp(' mathExp ')' - ; + : 'xp(' mathExp ')' + ; funcSgn - : 'sgn(' mathExp ')' - ; + : 'sgn(' mathExp ')' + ; funcMax - : 'max(' mathExp ',' argList ')' - ; + : 'max(' mathExp ',' argList ')' + ; funcMin - : 'min(' mathExp ',' argList ')' - ; + : 'min(' mathExp ',' argList ')' + ; argList - : mathExp - | mathExp ',' argList - ; + : mathExp + | mathExp ',' argList + ; variable - : ALPHA - | ALPHA '(' mathExp ')' - ; + : ALPHA + | ALPHA '(' mathExp ')' + ; varList - : variable - | variable ',' varList - ; + : variable + | variable ',' varList + ; LINECMD - : 'Line' - ; + : 'Line' + ; PAGECMD - : 'Page' - ; + : 'Page' + ; MULOP - : '*' - | '/' - ; + : '*' + | '/' + ; ADDOP - : '+' - | '-' - ; + : '+' + | '-' + ; STRING - : CHAR+ - ; + : CHAR+ + ; CHAR - : ALPHA - | DIGIT - | SPECIALCHAR - ; + : ALPHA + | DIGIT + | SPECIALCHAR + ; ALPHA - : [A-Za-z] - ; + : [A-Za-z] + ; SPECIALCHAR - : '.' - | ',' - | ';' - | ':' - | '\'' - | ' ' - | '#' - | '$' - | '?' - ; + : '.' + | ',' + | ';' + | ':' + | '\'' + | ' ' + | '#' + | '$' + | '?' + ; NUMBER - : SIGN? NUMBERPART - ; + : SIGN? NUMBERPART + ; NUMBERPART - : INTPART - | INTPART '.' DECIMALPART - ; + : INTPART + | INTPART '.' DECIMALPART + ; INTPART - : '0' - | NZDIGIT - | NZDIGIT DECIMALPART - ; + : '0' + | NZDIGIT + | NZDIGIT DECIMALPART + ; DECIMALPART - : DIGIT+ - ; + : DIGIT+ + ; DIGIT - : '0' - | NZDIGIT - ; + : '0' + | NZDIGIT + ; NZDIGIT - : [1-9] - ; + : [1-9] + ; SIGN - : '+' - | '-' - ; + : '+' + | '-' + ; PARTNUMBER - : NZDIGIT - | NZDIGIT INTPART - ; + : NZDIGIT + | NZDIGIT INTPART + ; STEPNUMBER - : PARTNUMBER '.' PARTNUMBER - ; + : PARTNUMBER '.' PARTNUMBER + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/jpa/JPA.g4 b/jpa/JPA.g4 index a2277f8f21..7929c84453 100644 --- a/jpa/JPA.g4 +++ b/jpa/JPA.g4 @@ -1,3 +1,6 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar JPA; /* Alexander Kunkel @@ -8,454 +11,465 @@ grammar JPA; /* ported to Antlr4 by Tom Everett */ -file_ : ql_statement EOF ; +file_ + : ql_statement EOF + ; ql_statement - : select_statement - | update_statement - | delete_statement - ; + : select_statement + | update_statement + | delete_statement + ; select_statement - : select_clause from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)? - ; + : select_clause from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)? + ; update_statement - : update_clause (where_clause)? - ; + : update_clause (where_clause)? + ; delete_statement - : delete_clause (where_clause)? - ; + : delete_clause (where_clause)? + ; from_clause - : 'FROM' identification_variable_declaration (',' (identification_variable_declaration | collection_member_declaration))* - ; + : 'FROM' identification_variable_declaration ( + ',' (identification_variable_declaration | collection_member_declaration) + )* + ; identification_variable_declaration - : range_variable_declaration (join | fetch_join)* - ; + : range_variable_declaration (join | fetch_join)* + ; range_variable_declaration - : abstract_schema_name ('AS')? IDENTIFICATION_VARIABLE - ; + : abstract_schema_name ('AS')? IDENTIFICATION_VARIABLE + ; join - : join_spec join_association_path_expression ('AS')? IDENTIFICATION_VARIABLE - ; + : join_spec join_association_path_expression ('AS')? IDENTIFICATION_VARIABLE + ; fetch_join - : join_spec 'FETCH' join_association_path_expression - ; + : join_spec 'FETCH' join_association_path_expression + ; join_spec - : (('LEFT') ('OUTER')? | 'INNER')? 'JOIN' - ; + : (('LEFT') ('OUTER')? | 'INNER')? 'JOIN' + ; join_association_path_expression - : join_collection_valued_path_expression - | join_single_valued_association_path_expression - ; + : join_collection_valued_path_expression + | join_single_valued_association_path_expression + ; join_collection_valued_path_expression - : IDENTIFICATION_VARIABLE '.' collection_valued_association_field - ; + : IDENTIFICATION_VARIABLE '.' collection_valued_association_field + ; join_single_valued_association_path_expression - : IDENTIFICATION_VARIABLE '.' single_valued_association_field - ; + : IDENTIFICATION_VARIABLE '.' single_valued_association_field + ; collection_member_declaration - : 'IN' '(' collection_valued_path_expression ')' ('AS')? IDENTIFICATION_VARIABLE - ; + : 'IN' '(' collection_valued_path_expression ')' ('AS')? IDENTIFICATION_VARIABLE + ; single_valued_path_expression - : state_field_path_expression - | single_valued_association_path_expression - ; + : state_field_path_expression + | single_valued_association_path_expression + ; state_field_path_expression - : (IDENTIFICATION_VARIABLE | single_valued_association_path_expression) '.' state_field - ; + : (IDENTIFICATION_VARIABLE | single_valued_association_path_expression) '.' state_field + ; single_valued_association_path_expression - : IDENTIFICATION_VARIABLE '.' (single_valued_association_field '.')* single_valued_association_field - ; + : IDENTIFICATION_VARIABLE '.' (single_valued_association_field '.')* single_valued_association_field + ; collection_valued_path_expression - : IDENTIFICATION_VARIABLE '.' (single_valued_association_field '.')* collection_valued_association_field - ; + : IDENTIFICATION_VARIABLE '.' (single_valued_association_field '.')* collection_valued_association_field + ; state_field - : (embedded_class_state_field '.')* simple_state_field - ; + : (embedded_class_state_field '.')* simple_state_field + ; update_clause - : 'UPDATE' abstract_schema_name (('AS')? IDENTIFICATION_VARIABLE)? 'SET' update_item (',' update_item)* - ; + : 'UPDATE' abstract_schema_name (('AS')? IDENTIFICATION_VARIABLE)? 'SET' update_item ( + ',' update_item + )* + ; update_item - : (IDENTIFICATION_VARIABLE '.')? (state_field | single_valued_association_field) '=' new_value - ; + : (IDENTIFICATION_VARIABLE '.')? (state_field | single_valued_association_field) '=' new_value + ; new_value - : simple_arithmetic_expression - | string_primary - | datetime_primary - | boolean_primary - | enum_primary - | simple_entity_expression - | 'NULL' - ; + : simple_arithmetic_expression + | string_primary + | datetime_primary + | boolean_primary + | enum_primary + | simple_entity_expression + | 'NULL' + ; delete_clause - : 'DELETE' 'FROM' abstract_schema_name (('AS')? IDENTIFICATION_VARIABLE)? - ; + : 'DELETE' 'FROM' abstract_schema_name (('AS')? IDENTIFICATION_VARIABLE)? + ; select_clause - : 'SELECT' ('DISTINCT')? select_expression (',' select_expression)* - ; + : 'SELECT' ('DISTINCT')? select_expression (',' select_expression)* + ; select_expression - : single_valued_path_expression - | aggregate_expression - | IDENTIFICATION_VARIABLE - | 'OBJECT' '(' IDENTIFICATION_VARIABLE ')' - | constructor_expression - ; + : single_valued_path_expression + | aggregate_expression + | IDENTIFICATION_VARIABLE + | 'OBJECT' '(' IDENTIFICATION_VARIABLE ')' + | constructor_expression + ; constructor_expression - : 'NEW' constructor_name '(' constructor_item (',' constructor_item)* ')' - ; + : 'NEW' constructor_name '(' constructor_item (',' constructor_item)* ')' + ; constructor_item - : single_valued_path_expression - | aggregate_expression - ; + : single_valued_path_expression + | aggregate_expression + ; aggregate_expression - : ('AVG' | 'MAX' | 'MIN' | 'SUM') '(' ('DISTINCT')? state_field_path_expression ')' - | 'COUNT' '(' ('DISTINCT')? (IDENTIFICATION_VARIABLE | state_field_path_expression | single_valued_association_path_expression) ')' - ; + : ('AVG' | 'MAX' | 'MIN' | 'SUM') '(' ('DISTINCT')? state_field_path_expression ')' + | 'COUNT' '(' ('DISTINCT')? ( + IDENTIFICATION_VARIABLE + | state_field_path_expression + | single_valued_association_path_expression + ) ')' + ; where_clause - : 'WHERE' conditional_expression - ; + : 'WHERE' conditional_expression + ; groupby_clause - : 'GROUP' 'BY' groupby_item (',' groupby_item)* - ; + : 'GROUP' 'BY' groupby_item (',' groupby_item)* + ; groupby_item - : single_valued_path_expression - | IDENTIFICATION_VARIABLE - ; + : single_valued_path_expression + | IDENTIFICATION_VARIABLE + ; having_clause - : 'HAVING' conditional_expression - ; + : 'HAVING' conditional_expression + ; orderby_clause - : 'ORDER' 'BY' orderby_item (',' orderby_item)* - ; + : 'ORDER' 'BY' orderby_item (',' orderby_item)* + ; orderby_item - : state_field_path_expression ('ASC' | 'DESC')? - ; + : state_field_path_expression ('ASC' | 'DESC')? + ; subquery - : simple_select_clause subquery_from_clause (where_clause)? (groupby_clause)? (having_clause)? - ; + : simple_select_clause subquery_from_clause (where_clause)? (groupby_clause)? (having_clause)? + ; subquery_from_clause - : 'FROM' subselect_identification_variable_declaration (',' subselect_identification_variable_declaration)* - ; + : 'FROM' subselect_identification_variable_declaration ( + ',' subselect_identification_variable_declaration + )* + ; subselect_identification_variable_declaration - : identification_variable_declaration - | association_path_expression ('AS')? IDENTIFICATION_VARIABLE - | collection_member_declaration - ; + : identification_variable_declaration + | association_path_expression ('AS')? IDENTIFICATION_VARIABLE + | collection_member_declaration + ; association_path_expression - : collection_valued_path_expression - | single_valued_association_path_expression - ; + : collection_valued_path_expression + | single_valued_association_path_expression + ; simple_select_clause - : 'SELECT' ('DISTINCT')? simple_select_expression - ; + : 'SELECT' ('DISTINCT')? simple_select_expression + ; simple_select_expression - : single_valued_path_expression - | aggregate_expression - | IDENTIFICATION_VARIABLE - ; + : single_valued_path_expression + | aggregate_expression + | IDENTIFICATION_VARIABLE + ; conditional_expression - : (conditional_term) ('OR' conditional_term)* - ; + : (conditional_term) ('OR' conditional_term)* + ; conditional_term - : (conditional_factor) ('AND' conditional_factor)* - ; + : (conditional_factor) ('AND' conditional_factor)* + ; conditional_factor - : ('NOT')? conditional_primary - ; + : ('NOT')? conditional_primary + ; conditional_primary - : simple_cond_expression - | '(' conditional_expression ')' - ; + : simple_cond_expression + | '(' conditional_expression ')' + ; simple_cond_expression - : comparison_expression - | between_expression - | like_expression - | in_expression - | null_comparison_expression - | empty_collection_comparison_expression - | collection_member_expression - | exists_expression - ; + : comparison_expression + | between_expression + | like_expression + | in_expression + | null_comparison_expression + | empty_collection_comparison_expression + | collection_member_expression + | exists_expression + ; between_expression - : arithmetic_expression ('NOT')? 'BETWEEN' arithmetic_expression 'AND' arithmetic_expression - | string_expression ('NOT')? 'BETWEEN' string_expression 'AND' string_expression - | datetime_expression ('NOT')? 'BETWEEN' datetime_expression 'AND' datetime_expression - ; + : arithmetic_expression ('NOT')? 'BETWEEN' arithmetic_expression 'AND' arithmetic_expression + | string_expression ('NOT')? 'BETWEEN' string_expression 'AND' string_expression + | datetime_expression ('NOT')? 'BETWEEN' datetime_expression 'AND' datetime_expression + ; in_expression - : state_field_path_expression ('NOT')? 'IN' '(' (in_item (',' in_item)* | subquery) ')' - ; + : state_field_path_expression ('NOT')? 'IN' '(' (in_item (',' in_item)* | subquery) ')' + ; in_item - : literal - | input_parameter - ; + : literal + | input_parameter + ; like_expression - : string_expression ('NOT')? 'LIKE' pattern_value ('ESCAPE' ESCAPE_CHARACTER)? - ; + : string_expression ('NOT')? 'LIKE' pattern_value ('ESCAPE' ESCAPE_CHARACTER)? + ; null_comparison_expression - : (single_valued_path_expression | input_parameter) 'IS' ('NOT')? 'NULL' - ; + : (single_valued_path_expression | input_parameter) 'IS' ('NOT')? 'NULL' + ; empty_collection_comparison_expression - : collection_valued_path_expression 'IS' ('NOT')? 'EMPTY' - ; + : collection_valued_path_expression 'IS' ('NOT')? 'EMPTY' + ; collection_member_expression - : entity_expression ('NOT')? 'MEMBER' ('OF')? collection_valued_path_expression - ; + : entity_expression ('NOT')? 'MEMBER' ('OF')? collection_valued_path_expression + ; exists_expression - : ('NOT')? 'EXISTS' '(' subquery ')' - ; + : ('NOT')? 'EXISTS' '(' subquery ')' + ; all_or_any_expression - : ('ALL' | 'ANY' | 'SOME') '(' subquery ')' - ; + : ('ALL' | 'ANY' | 'SOME') '(' subquery ')' + ; comparison_expression - : string_expression comparison_operator (string_expression | all_or_any_expression) - | boolean_expression ('=' | '<>') (boolean_expression | all_or_any_expression) - | enum_expression ('=' | '<>') (enum_expression | all_or_any_expression) - | datetime_expression comparison_operator (datetime_expression | all_or_any_expression) - | entity_expression ('=' | '<>') (entity_expression | all_or_any_expression) - | arithmetic_expression comparison_operator (arithmetic_expression | all_or_any_expression) - ; + : string_expression comparison_operator (string_expression | all_or_any_expression) + | boolean_expression ('=' | '<>') (boolean_expression | all_or_any_expression) + | enum_expression ('=' | '<>') (enum_expression | all_or_any_expression) + | datetime_expression comparison_operator (datetime_expression | all_or_any_expression) + | entity_expression ('=' | '<>') (entity_expression | all_or_any_expression) + | arithmetic_expression comparison_operator (arithmetic_expression | all_or_any_expression) + ; comparison_operator - : '=' - | '>' - | '>=' - | '<' - | '<=' - | '<>' - ; + : '=' + | '>' + | '>=' + | '<' + | '<=' + | '<>' + ; arithmetic_expression - : simple_arithmetic_expression - | '(' subquery ')' - ; + : simple_arithmetic_expression + | '(' subquery ')' + ; simple_arithmetic_expression - : (arithmetic_term) (('+' | '-') arithmetic_term)* - ; + : (arithmetic_term) (('+' | '-') arithmetic_term)* + ; arithmetic_term - : (arithmetic_factor) (('*' | '/') arithmetic_factor)* - ; + : (arithmetic_factor) (('*' | '/') arithmetic_factor)* + ; arithmetic_factor - : ('+' | '-')? arithmetic_primary - ; + : ('+' | '-')? arithmetic_primary + ; arithmetic_primary - : state_field_path_expression - | numeric_literal - | '(' simple_arithmetic_expression ')' - | input_parameter - | functions_returning_numerics - | aggregate_expression - ; + : state_field_path_expression + | numeric_literal + | '(' simple_arithmetic_expression ')' + | input_parameter + | functions_returning_numerics + | aggregate_expression + ; string_expression - : string_primary - | '(' subquery ')' - ; + : string_primary + | '(' subquery ')' + ; string_primary - : state_field_path_expression - | STRINGLITERAL - | input_parameter - | functions_returning_strings - | aggregate_expression - ; + : state_field_path_expression + | STRINGLITERAL + | input_parameter + | functions_returning_strings + | aggregate_expression + ; datetime_expression - : datetime_primary - | '(' subquery ')' - ; + : datetime_primary + | '(' subquery ')' + ; datetime_primary - : state_field_path_expression - | input_parameter - | functions_returning_datetime - | aggregate_expression - ; + : state_field_path_expression + | input_parameter + | functions_returning_datetime + | aggregate_expression + ; boolean_expression - : boolean_primary - | '(' subquery ')' - ; + : boolean_primary + | '(' subquery ')' + ; boolean_primary - : state_field_path_expression - | boolean_literal - | input_parameter - ; + : state_field_path_expression + | boolean_literal + | input_parameter + ; enum_expression - : enum_primary - | '(' subquery ')' - ; + : enum_primary + | '(' subquery ')' + ; enum_primary - : state_field_path_expression - | enum_literal - | input_parameter - ; + : state_field_path_expression + | enum_literal + | input_parameter + ; entity_expression - : single_valued_association_path_expression - | simple_entity_expression - ; + : single_valued_association_path_expression + | simple_entity_expression + ; simple_entity_expression - : IDENTIFICATION_VARIABLE - | input_parameter - ; + : IDENTIFICATION_VARIABLE + | input_parameter + ; functions_returning_numerics - : 'LENGTH' '(' string_primary ')' - | 'LOCATE' '(' string_primary ',' string_primary (',' simple_arithmetic_expression)? ')' - | 'ABS' '(' simple_arithmetic_expression ')' - | 'SQRT' '(' simple_arithmetic_expression ')' - | 'MOD' '(' simple_arithmetic_expression ',' simple_arithmetic_expression ')' - | 'SIZE' '(' collection_valued_path_expression ')' - ; + : 'LENGTH' '(' string_primary ')' + | 'LOCATE' '(' string_primary ',' string_primary (',' simple_arithmetic_expression)? ')' + | 'ABS' '(' simple_arithmetic_expression ')' + | 'SQRT' '(' simple_arithmetic_expression ')' + | 'MOD' '(' simple_arithmetic_expression ',' simple_arithmetic_expression ')' + | 'SIZE' '(' collection_valued_path_expression ')' + ; functions_returning_datetime - : 'CURRENT_DATE' - | 'CURRENT_TIME' - | 'CURRENT_TIMESTAMP' - ; + : 'CURRENT_DATE' + | 'CURRENT_TIME' + | 'CURRENT_TIMESTAMP' + ; functions_returning_strings - : 'CONCAT' '(' string_primary ',' string_primary ')' - | 'SUBSTRING' '(' string_primary ',' simple_arithmetic_expression ',' simple_arithmetic_expression ')' - | 'TRIM' '(' ((trim_specification)? (TRIM_CHARACTER)? 'FROM')? string_primary ')' - | 'LOWER' '(' string_primary ')' - | 'UPPER' '(' string_primary ')' - ; + : 'CONCAT' '(' string_primary ',' string_primary ')' + | 'SUBSTRING' '(' string_primary ',' simple_arithmetic_expression ',' simple_arithmetic_expression ')' + | 'TRIM' '(' ((trim_specification)? (TRIM_CHARACTER)? 'FROM')? string_primary ')' + | 'LOWER' '(' string_primary ')' + | 'UPPER' '(' string_primary ')' + ; trim_specification - : 'LEADING' - | 'TRAILING' - | 'BOTH' - ; + : 'LEADING' + | 'TRAILING' + | 'BOTH' + ; numeric_literal - : - ; + : + ; pattern_value - : - ; + : + ; input_parameter - : '?' INT_NUMERAL - | ':' IDENTIFICATION_VARIABLE - ; + : '?' INT_NUMERAL + | ':' IDENTIFICATION_VARIABLE + ; literal - : - ; + : + ; constructor_name - : - ; + : + ; enum_literal - : - ; + : + ; boolean_literal - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; simple_state_field - : - ; + : + ; embedded_class_state_field - : - ; + : + ; single_valued_association_field - : - ; + : + ; collection_valued_association_field - : - ; + : + ; abstract_schema_name - : - ; + : + ; IDENTIFICATION_VARIABLE - : ('a' .. 'z' | 'A' .. 'Z' | '_') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_')* - ; + : ('a' .. 'z' | 'A' .. 'Z' | '_') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_')* + ; CHARACTER - : '\'' (~ ('\'' | '\\')) '\'' - ; + : '\'' (~ ('\'' | '\\')) '\'' + ; STRINGLITERAL - : ('\'' (~ ('\\' | '"'))* '\'') - ; + : ('\'' (~ ('\\' | '"'))* '\'') + ; ESCAPE_CHARACTER - : CHARACTER - ; + : CHARACTER + ; WS - : [ \t\r\n] -> skip - ; - \ No newline at end of file + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/json/JSON.g4 b/json/JSON.g4 index 3a67ccbc30..fa5fa09219 100644 --- a/json/JSON.g4 +++ b/json/JSON.g4 @@ -1,82 +1,79 @@ - /** Taken from "The Definitive ANTLR 4 Reference" by Terence Parr */ // Derived from https://json.org + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar JSON; json - : value EOF - ; + : value EOF + ; obj - : '{' pair (',' pair)* '}' - | '{' '}' - ; + : '{' pair (',' pair)* '}' + | '{' '}' + ; pair - : STRING ':' value - ; + : STRING ':' value + ; arr - : '[' value (',' value)* ']' - | '[' ']' - ; + : '[' value (',' value)* ']' + | '[' ']' + ; value - : STRING - | NUMBER - | obj - | arr - | 'true' - | 'false' - | 'null' - ; - + : STRING + | NUMBER + | obj + | arr + | 'true' + | 'false' + | 'null' + ; STRING - : '"' (ESC | SAFECODEPOINT)* '"' - ; - + : '"' (ESC | SAFECODEPOINT)* '"' + ; fragment ESC - : '\\' (["\\/bfnrt] | UNICODE) - ; - + : '\\' (["\\/bfnrt] | UNICODE) + ; fragment UNICODE - : 'u' HEX HEX HEX HEX - ; - + : 'u' HEX HEX HEX HEX + ; fragment HEX - : [0-9a-fA-F] - ; - + : [0-9a-fA-F] + ; fragment SAFECODEPOINT - : ~ ["\\\u0000-\u001F] - ; - + : ~ ["\\\u0000-\u001F] + ; NUMBER - : '-'? INT ('.' [0-9] +)? EXP? - ; - + : '-'? INT ('.' [0-9]+)? EXP? + ; fragment INT - // integer part forbis leading 0s (e.g. `01`) - : '0' | [1-9] [0-9]* - ; +// integer part forbis leading 0s (e.g. `01`) + : '0' + | [1-9] [0-9]* + ; // no leading zeros fragment EXP - // exponent number permits leading 0s (e.g. `1e01`) - : [Ee] [+\-]? [0-9]+ - ; +// exponent number permits leading 0s (e.g. `1e01`) + : [Ee] [+\-]? [0-9]+ + ; // \- since - means "range" inside [...] WS - : [ \t\n\r] + -> skip - ; + : [ \t\n\r]+ -> skip + ; \ No newline at end of file diff --git a/json5/JSON5.g4 b/json5/JSON5.g4 index 5bfd6992bf..4c060d1b8e 100644 --- a/json5/JSON5.g4 +++ b/json5/JSON5.g4 @@ -5,146 +5,149 @@ // JSON5 is a superset of JSON, it included some feature from ES5.1 // See https://json5.org/ // Derived from ../json/JSON.g4 which original derived from http://json.org + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar JSON5; json5 - : value? EOF - ; + : value? EOF + ; obj - : '{' pair (',' pair)* ','? '}' - | '{' '}' - ; + : '{' pair (',' pair)* ','? '}' + | '{' '}' + ; pair - : key ':' value - ; + : key ':' value + ; key - : STRING - | IDENTIFIER - | LITERAL - | NUMERIC_LITERAL - ; + : STRING + | IDENTIFIER + | LITERAL + | NUMERIC_LITERAL + ; value - : STRING - | number - | obj - | arr - | LITERAL - ; + : STRING + | number + | obj + | arr + | LITERAL + ; arr - : '[' value (',' value)* ','? ']' - | '[' ']' - ; + : '[' value (',' value)* ','? ']' + | '[' ']' + ; number - : SYMBOL? - ( NUMERIC_LITERAL - | NUMBER - ) - ; + : SYMBOL? (NUMERIC_LITERAL | NUMBER) + ; // Lexer SINGLE_LINE_COMMENT - : '//' .*? (NEWLINE | EOF) -> skip - ; + : '//' .*? (NEWLINE | EOF) -> skip + ; MULTI_LINE_COMMENT - : '/*' .*? '*/' -> skip - ; + : '/*' .*? '*/' -> skip + ; LITERAL - : 'true' - | 'false' - | 'null' - ; + : 'true' + | 'false' + | 'null' + ; STRING - : '"' DOUBLE_QUOTE_CHAR* '"' - | '\'' SINGLE_QUOTE_CHAR* '\'' - ; + : '"' DOUBLE_QUOTE_CHAR* '"' + | '\'' SINGLE_QUOTE_CHAR* '\'' + ; fragment DOUBLE_QUOTE_CHAR - : ~["\\\r\n] - | ESCAPE_SEQUENCE - ; + : ~["\\\r\n] + | ESCAPE_SEQUENCE + ; fragment SINGLE_QUOTE_CHAR - : ~['\\\r\n] - | ESCAPE_SEQUENCE - ; + : ~['\\\r\n] + | ESCAPE_SEQUENCE + ; fragment ESCAPE_SEQUENCE - : '\\' - ( NEWLINE - | UNICODE_SEQUENCE // \u1234 - | ['"\\/bfnrtv] // single escape char - | ~['"\\bfnrtv0-9xu\r\n] // non escape char - | '0' // \0 - | 'x' HEX HEX // \x3a - ) - ; + : '\\' ( + NEWLINE + | UNICODE_SEQUENCE // \u1234 + | ['"\\/bfnrtv] // single escape char + | ~['"\\bfnrtv0-9xu\r\n] // non escape char + | '0' // \0 + | 'x' HEX HEX // \x3a + ) + ; NUMBER - : INT ('.' [0-9]*)? EXP? // +1.e2, 1234, 1234.5 - | '.' [0-9]+ EXP? // -.2e3 - | '0' [xX] HEX+ // 0x12345678 - ; + : INT ('.' [0-9]*)? EXP? // +1.e2, 1234, 1234.5 + | '.' [0-9]+ EXP? // -.2e3 + | '0' [xX] HEX+ // 0x12345678 + ; NUMERIC_LITERAL - : 'Infinity' - | 'NaN' - ; + : 'Infinity' + | 'NaN' + ; SYMBOL - : '+' | '-' - ; + : '+' + | '-' + ; fragment HEX - : [0-9a-fA-F] - ; + : [0-9a-fA-F] + ; fragment INT - : '0' | [1-9] [0-9]* - ; + : '0' + | [1-9] [0-9]* + ; fragment EXP - : [Ee] SYMBOL? [0-9]* - ; + : [Ee] SYMBOL? [0-9]* + ; IDENTIFIER - : IDENTIFIER_START IDENTIFIER_PART* - ; + : IDENTIFIER_START IDENTIFIER_PART* + ; fragment IDENTIFIER_START - : [\p{L}] - | '$' - | '_' - | '\\' UNICODE_SEQUENCE - ; + : [\p{L}] + | '$' + | '_' + | '\\' UNICODE_SEQUENCE + ; fragment IDENTIFIER_PART - : IDENTIFIER_START - | [\p{M}] - | [\p{N}] - | [\p{Pc}] - | '\u200C' - | '\u200D' - ; + : IDENTIFIER_START + | [\p{M}] + | [\p{N}] + | [\p{Pc}] + | '\u200C' + | '\u200D' + ; fragment UNICODE_SEQUENCE - : 'u' HEX HEX HEX HEX - ; + : 'u' HEX HEX HEX HEX + ; fragment NEWLINE - : '\r\n' - | [\r\n\u2028\u2029] - ; + : '\r\n' + | [\r\n\u2028\u2029] + ; WS - : [ \t\n\r\u00A0\uFEFF\u2003] + -> skip - ; + : [ \t\n\r\u00A0\uFEFF\u2003]+ -> skip + ; \ No newline at end of file diff --git a/karel/karel.g4 b/karel/karel.g4 index 143f19c3cf..21d2fc1c79 100644 --- a/karel/karel.g4 +++ b/karel/karel.g4 @@ -22,90 +22,93 @@ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar karel; karel - : 'BEGINNING-OF-PROGRAM' definition* 'BEGINNING-OF-EXECUTION' statement* 'END-OF-EXECUTION' 'END-OF-PROGRAM' EOF - ; + : 'BEGINNING-OF-PROGRAM' definition* 'BEGINNING-OF-EXECUTION' statement* 'END-OF-EXECUTION' 'END-OF-PROGRAM' EOF + ; definition - : 'DEFINE' IDENTIFIER 'AS' statement - ; + : 'DEFINE' IDENTIFIER 'AS' statement + ; statement - : block - | iteration - | loop - | conditional - | instruction - ; + : block + | iteration + | loop + | conditional + | instruction + ; block - : 'BEGIN' statement* 'END' - ; + : 'BEGIN' statement* 'END' + ; iteration - : 'ITERATE' number 'TIMES' statement - ; + : 'ITERATE' number 'TIMES' statement + ; loop - : 'WHILE' condition 'DO' statement - ; + : 'WHILE' condition 'DO' statement + ; conditional - : 'IF' condition 'THEN' statement ('ELSE' statement)? - ; + : 'IF' condition 'THEN' statement ('ELSE' statement)? + ; instruction - : 'MOVE' - | 'TURNLEFT' - | 'PICKBEEPER' - | 'PUTBEEPER' - | 'TURNOFF' - | IDENTIFIER - ; + : 'MOVE' + | 'TURNLEFT' + | 'PICKBEEPER' + | 'PUTBEEPER' + | 'TURNOFF' + | IDENTIFIER + ; condition - : 'FRONT-IS-CLEAR' - | 'FRONT-IS-BLOCKED' - | 'LEFT-IS-CLEAR' - | 'LEFT-IS-BLOCKED' - | 'RIGHT-IS-CLEAR' - | 'RIGHT-IS-BLOCKED' - | 'BACK-IS-CLEAR' - | 'BACK-IS-BLOCKED' - | 'NEXT-TO-A-BEEPER' - | 'NOT-NEXT-TO-A-BEEPER' - | 'ANY-BEEPERS-IN-BEEPER-BAG' - | 'NO-BEEPERS-IN-BEEPER-BAG' - | 'FACING-NORTH' - | 'NOT-FACING-NORTH' - | 'FACING-SOUTH' - | 'NOT-FACING-SOUTH' - | 'FACING-EAST' - | 'NOT-FACING-EAST' - | 'FACING-WEST' - | 'NOT-FACING-WEST' - ; + : 'FRONT-IS-CLEAR' + | 'FRONT-IS-BLOCKED' + | 'LEFT-IS-CLEAR' + | 'LEFT-IS-BLOCKED' + | 'RIGHT-IS-CLEAR' + | 'RIGHT-IS-BLOCKED' + | 'BACK-IS-CLEAR' + | 'BACK-IS-BLOCKED' + | 'NEXT-TO-A-BEEPER' + | 'NOT-NEXT-TO-A-BEEPER' + | 'ANY-BEEPERS-IN-BEEPER-BAG' + | 'NO-BEEPERS-IN-BEEPER-BAG' + | 'FACING-NORTH' + | 'NOT-FACING-NORTH' + | 'FACING-SOUTH' + | 'NOT-FACING-SOUTH' + | 'FACING-EAST' + | 'NOT-FACING-EAST' + | 'FACING-WEST' + | 'NOT-FACING-WEST' + ; IDENTIFIER - : LETTER (LETTER | DIGIT)* - ; + : LETTER (LETTER | DIGIT)* + ; number - : DIGIT+ - ; + : DIGIT+ + ; LETTER - : [A-Za-z] - | '-' - ; + : [A-Za-z] + | '-' + ; DIGIT - : [0-9] - ; + : [0-9] + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/kirikiri-tjs/TJSLexer.g4 b/kirikiri-tjs/TJSLexer.g4 index 230225703c..5377a0e8f3 100644 --- a/kirikiri-tjs/TJSLexer.g4 +++ b/kirikiri-tjs/TJSLexer.g4 @@ -1,245 +1,212 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar TJSLexer; -channels { ERROR } +channels { + ERROR +} -options { superClass=TJSBaseLexer; } -MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN); -SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); -RegularExpressionLiteral: {this.IsRegexPossible()}? '/' RegularExpressionFirstChar RegularExpressionChar* '/' IdentifierPart*; -OctetLiteral: '<%' .*? '%>'; +options { + superClass = TJSBaseLexer; +} +MultiLineComment : '/*' .*? '*/' -> channel(HIDDEN); +SingleLineComment : '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN); +RegularExpressionLiteral: + {this.IsRegexPossible()}? '/' RegularExpressionFirstChar RegularExpressionChar* '/' IdentifierPart* +; +OctetLiteral: '<%' .*? '%>'; -OpenBracket: '['; -CloseBracket: ']'; -OpenParen: '('; -CloseParen: ')'; -OpenBrace: '{'; -CloseBrace: '}'; -SemiColon: ';'; -Comma: ','; -Assign: '='; +OpenBracket : '['; +CloseBracket : ']'; +OpenParen : '('; +CloseParen : ')'; +OpenBrace : '{'; +CloseBrace : '}'; +SemiColon : ';'; +Comma : ','; +Assign : '='; -Swap: '<->'; +Swap: '<->'; -QuestionMark: '?'; -Colon: ':'; -Ellipsis: '...'; -Dot: '.'; -PlusPlus: '++'; -MinusMinus: '--'; -Plus: '+'; -Minus: '-'; -BitNot: '~'; -Not: '!'; -Multiply: '*'; -Divide: '/'; -Modulus: '%'; -IntDivide: '\\'; -RightShiftArithmetic: '>>'; -LeftShiftArithmetic: '<<'; -RightShiftLogical: '>>>'; -LessThan: '<'; -MoreThan: '>'; -LessThanEquals: '<='; -GreaterThanEquals: '>='; -Equals_: '=='; -NotEquals: '!='; -IdentityEquals: '==='; -IdentityNotEquals: '!=='; -BitAnd: '&'; -BitXOr: '^'; -BitOr: '|'; -And: '&&'; -Or: '||'; -MultiplyAssign: '*='; -DivideAssign: '/='; -ModulusAssign: '%='; -IntDivideAssign: '\\='; -PlusAssign: '+='; -MinusAssign: '-='; -LeftShiftArithmeticAssign: '<<='; -RightShiftArithmeticAssign: '>>='; -RightShiftLogicalAssign: '>>>='; -BitAndAssign: '&='; -BitXorAssign: '^='; -BitOrAssign: '|='; -AndAssign: '&&='; -OrAssign: '||='; -ARROW: '=>'; +QuestionMark : '?'; +Colon : ':'; +Ellipsis : '...'; +Dot : '.'; +PlusPlus : '++'; +MinusMinus : '--'; +Plus : '+'; +Minus : '-'; +BitNot : '~'; +Not : '!'; +Multiply : '*'; +Divide : '/'; +Modulus : '%'; +IntDivide : '\\'; +RightShiftArithmetic : '>>'; +LeftShiftArithmetic : '<<'; +RightShiftLogical : '>>>'; +LessThan : '<'; +MoreThan : '>'; +LessThanEquals : '<='; +GreaterThanEquals : '>='; +Equals_ : '=='; +NotEquals : '!='; +IdentityEquals : '==='; +IdentityNotEquals : '!=='; +BitAnd : '&'; +BitXOr : '^'; +BitOr : '|'; +And : '&&'; +Or : '||'; +MultiplyAssign : '*='; +DivideAssign : '/='; +ModulusAssign : '%='; +IntDivideAssign : '\\='; +PlusAssign : '+='; +MinusAssign : '-='; +LeftShiftArithmeticAssign : '<<='; +RightShiftArithmeticAssign : '>>='; +RightShiftLogicalAssign : '>>>='; +BitAndAssign : '&='; +BitXorAssign : '^='; +BitOrAssign : '|='; +AndAssign : '&&='; +OrAssign : '||='; +ARROW : '=>'; -TObjStart: '%['; +TObjStart: '%['; /// Null Literals -NullLiteral: 'null'; +NullLiteral: 'null'; /// Boolean Literals -BooleanLiteral: 'true' - | 'false'; +BooleanLiteral: 'true' | 'false'; /// Numeric Literals -DecimalLiteral: DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? - | '.' DecimalDigit+ ExponentPart? - | DecimalIntegerLiteral ExponentPart? - ; +DecimalLiteral: + DecimalIntegerLiteral '.' DecimalDigit* ExponentPart? + | '.' DecimalDigit+ ExponentPart? + | DecimalIntegerLiteral ExponentPart? +; -HexIntegerLiteral: '0' [xX] HexDigit+ ('.'HexDigit+)? ExponentPart?; -OctalIntegerLiteral: '0' OctalDigit+ ('.'OctalDigit+)? ExponentPart?; -OctalIntegerLiteral2: '0' [oO] OctalDigit+('.'OctalDigit+)? ExponentPart?; -BinaryIntegerLiteral: '0' [bB] BinaryDigit+('.'BinaryDigit+)? ExponentPart?; +HexIntegerLiteral : '0' [xX] HexDigit+ ('.' HexDigit+)? ExponentPart?; +OctalIntegerLiteral : '0' OctalDigit+ ('.' OctalDigit+)? ExponentPart?; +OctalIntegerLiteral2 : '0' [oO] OctalDigit+ ('.' OctalDigit+)? ExponentPart?; +BinaryIntegerLiteral : '0' [bB] BinaryDigit+ ('.' BinaryDigit+)? ExponentPart?; -NonIdentHexByte: DecimalDigit HexDigit?; +NonIdentHexByte: DecimalDigit HexDigit?; /// 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'; +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'; -Class: 'class'; -Enum: 'enum'; -Extends: 'extends'; -Super: 'super'; -Const: 'const'; -Export: 'export'; -Import: 'import'; +Class : 'class'; +Enum : 'enum'; +Extends : 'extends'; +Super : 'super'; +Const : 'const'; +Export : 'export'; +Import : 'import'; -Static: 'static'; +Static: 'static'; // TJS2 -String: 'string'; -Int: 'int'; -Real: 'real'; -Incontextof: 'incontextof'; -Isvalid: 'isvalid'; -Invalidate: 'invalidate'; -Property: 'property'; -Getter: 'getter'; -Setter: 'setter'; +String : 'string'; +Int : 'int'; +Real : 'real'; +Incontextof : 'incontextof'; +Isvalid : 'isvalid'; +Invalidate : 'invalidate'; +Property : 'property'; +Getter : 'getter'; +Setter : 'setter'; /// Identifier Names and Identifiers -Identifier: IdentifierStart IdentifierPart*; +Identifier: IdentifierStart IdentifierPart*; /// String Literals -StringLiteral: ('"' DoubleStringCharacter* '"' - | '\'' SingleStringCharacter* '\'') - ; +StringLiteral: ('"' DoubleStringCharacter* '"' | '\'' SingleStringCharacter* '\''); -TemplateStringLiteral: ('@"' ('\\"' | ~'"')* '"' // TJS use @"str ${Val} ,str &val; ." - | '@\'' ('\\\'' | ~'\'')* '\'' ) // instead of `str ${Val} .` - ; +TemplateStringLiteral: + ( + '@"' ('\\"' | ~'"')* '"' // TJS use @"str ${Val} ,str &val; ." + | '@\'' ('\\\'' | ~'\'')* '\'' + ) // instead of `str ${Val} .` +; -WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); +WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN); -LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); +LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN); -UnexpectedCharacter: . -> channel(ERROR); +UnexpectedCharacter: . -> channel(ERROR); // Fragment rules -fragment DoubleStringCharacter - : ~["\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; -fragment SingleStringCharacter - : ~['\\\r\n] - | '\\' EscapeSequence - | LineContinuation - ; -fragment EscapeSequence - : CharacterEscapeSequence +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 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 OctalDigit - : [0-7] - ; -fragment BinaryDigit - : [01] - ; +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 OctalDigit : [0-7]; +fragment BinaryDigit : [01]; -fragment DecimalIntegerLiteral - : '0' - | [1-9] DecimalDigit* - ; -fragment DecimalDigit - : [0-9] - ; -fragment ExponentPart - : [eEpP] [+-]? DecimalDigit+ - ; -fragment IdentifierPart - : IdentifierStart +fragment DecimalIntegerLiteral : '0' | [1-9] DecimalDigit*; +fragment DecimalDigit : [0-9]; +fragment ExponentPart : [eEpP] [+-]? DecimalDigit+; +fragment IdentifierPart: + IdentifierStart | UnicodeCombiningMark | UnicodeDigit | UnicodeConnectorPunctuation | '\u200C' | '\u200D' - ; -fragment IdentifierStart - : UnicodeLetter - | [$_] - | '\\' UnicodeEscapeSequence - ; -fragment UnicodeLetter - : [\u0041-\u005A] +; +fragment IdentifierStart: UnicodeLetter | [$_] | '\\' UnicodeEscapeSequence; +fragment UnicodeLetter: + [\u0041-\u005A] | [\u0061-\u007A] | [\u00AA] | [\u00B5] @@ -498,15 +465,15 @@ fragment UnicodeLetter | [\uFFCA-\uFFCF] | [\uFFD2-\uFFD7] | [\uFFDA-\uFFDC] - ; -fragment UnicodeCombiningMark - : [\u0300-\u034E] +; +fragment UnicodeCombiningMark: + [\u0300-\u034E] | [\u0360-\u0362] | [\u0483-\u0486] | [\u0591-\u05A1] | [\u05A3-\u05B9] | [\u05BB-\u05BD] - | [\u05BF] + | [\u05BF] | [\u05C1-\u05C2] | [\u05C4] | [\u064B-\u0655] @@ -600,9 +567,9 @@ fragment UnicodeCombiningMark | [\u3099-\u309A] | [\uFB1E] | [\uFE20-\uFE23] - ; -fragment UnicodeDigit - : [\u0030-\u0039] +; +fragment UnicodeDigit: + [\u0030-\u0039] | [\u0660-\u0669] | [\u06F0-\u06F9] | [\u0966-\u096F] @@ -622,30 +589,25 @@ fragment UnicodeDigit | [\u17E0-\u17E9] | [\u1810-\u1819] | [\uFF10-\uFF19] - ; -fragment UnicodeConnectorPunctuation - : [\u005F] +; +fragment UnicodeConnectorPunctuation: + [\u005F] | [\u203F-\u2040] | [\u30FB] | [\uFE33-\uFE34] | [\uFE4D-\uFE4F] | [\uFF3F] | [\uFF65] - ; -fragment RegularExpressionFirstChar - : ~[*\r\n\u2028\u2029\\/[] +; +fragment RegularExpressionFirstChar: + ~[*\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' - ; -fragment RegularExpressionChar - : ~[\r\n\u2028\u2029\\/[] +; +fragment RegularExpressionChar: + ~[\r\n\u2028\u2029\\/[] | RegularExpressionBackslashSequence | '[' RegularExpressionClassChar* ']' - ; -fragment RegularExpressionClassChar - : ~[\r\n\u2028\u2029\]\\] - | RegularExpressionBackslashSequence - ; -fragment RegularExpressionBackslashSequence - : '\\' ~[\r\n\u2028\u2029] - ; \ No newline at end of file +; +fragment RegularExpressionClassChar : ~[\r\n\u2028\u2029\]\\] | RegularExpressionBackslashSequence; +fragment RegularExpressionBackslashSequence : '\\' ~[\r\n\u2028\u2029]; \ No newline at end of file diff --git a/kirikiri-tjs/TJSParser.g4 b/kirikiri-tjs/TJSParser.g4 index 7e0aca5c85..7021cc1ff1 100644 --- a/kirikiri-tjs/TJSParser.g4 +++ b/kirikiri-tjs/TJSParser.g4 @@ -1,8 +1,11 @@ +// $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 TJSParser; options { - tokenVocab=TJSLexer; - superClass=TJSBaseParser; + tokenVocab = TJSLexer; + superClass = TJSBaseParser; } program @@ -10,7 +13,7 @@ program ; statement - : block + : block | variableStatement | emptyStatement_ | classDeclaration @@ -65,12 +68,13 @@ iterationStatement ; varModifier - : Var | Const - |'('( Var | Const )')' + : Var + | Const + | '(' ( Var | Const) ')' ; typeConverter - : '('(Int | Real | String )')' + : '(' (Int | Real | String) ')' | Int | Real | String @@ -93,7 +97,7 @@ withStatement ; switchStatement - : Switch '(' expressions ')' '{' ( caseClause | defaultClause )* '}' + : Switch '(' expressions ')' '{' (caseClause | defaultClause)* '}' ; caseClause @@ -125,14 +129,11 @@ anoymousFunctionDeclaration ; classDeclaration - : Class Identifier (Extends expression (',' expression)* )? block + : Class Identifier (Extends expression (',' expression)*)? block ; propertyDeclaration - : Property Identifier '{' - ( Getter ('(' ')')? block - | Setter '(' functionParameter ')' block - )* '}' + : Property Identifier '{' (Getter ('(' ')')? block | Setter '(' functionParameter ')' block)* '}' ; functionParameters @@ -158,11 +159,11 @@ arrayElementSeprator ; objectLiteral - : varModifier? '%[' objectProperty? (',' objectProperty)* ','?']' + : varModifier? '%[' objectProperty? (',' objectProperty)* ','? ']' ; objectProperty - : expression (':' |'=' | '=>' | ',') expression // TJS resolve object key in runtime + : expression (':' | '=' | '=>' | ',') expression // TJS resolve object key in runtime ; arguments @@ -181,54 +182,54 @@ expressions // TODO: can we optimize it? expression - : anoymousFunctionDeclaration # FunctionExpression - | expression '[' expressions ']' # MemberIndexExpression - | expression '.' identifierName # MemberDotExpression - | '.' identifierName # WithDotExpression - | expression arguments # CallExpression - | New expression arguments? # NewExpression - | '&' expression # ReferenceExpression - | '*' expression # PointerExpression - | expression '<->' expression # SwapExpression - | expression '!' # EvalExpression // t.f incontextof 's'! => 0721 (s=%[v=>0721]) - | expression Incontextof expression # InContextOfExpression // a incontextof d++ => Error: object++ - | expression '++' # PostIncrementExpression - | expression '--' # PostDecreaseExpression - | expression Isvalid # IsValidExpression // t incontextof ctx isvalid => 1 - | Delete expression # DeleteExpression // delete a.c isvalid => error - | Isvalid expression # IsValidExpression // isvalid delete a.c => 1 - | Typeof expression # TypeofExpression // typeof 1 instanceof "String" => 'Integer' - | expression Instanceof expression # InstanceofExpression // 1 instanceof "Number" isvalid => 0,isvalid 1 instanceof "String"=>1 - | Invalidate expression # InvalidateExpression // invalidate a instanceof "Number" => 0 - | expression In expression # InExpression // TODO: any standard for it? - | '++' expression # PreIncrementExpression - | '--' expression # PreDecreaseExpression // typeof 1 + 1 = 'Integer1' - | '+' expression # UnaryPlusExpression - | '-' expression # UnaryMinusExpression - | '~' expression # BitNotExpression - | '!' expression # NotExpression - | expression ('*' | '/' | '%' | '\\') expression # MultiplicativeExpression - | expression ('+' | '-') expression # AdditiveExpression - | expression ('<<' | '>>' | '>>>') expression # BitShiftExpression - | expression ('<' | '>' | '<=' | '>=') expression # RelationalExpression - | expression ('==' | '!=' | '===' | '!==') expression # EqualityExpression - | expression '&' expression # BitAndExpression - | expression '^' expression # BitXOrExpression - | expression '|' expression # BitOrExpression - | expression '&&' expression # LogicalAndExpression - | expression '||' expression # LogicalOrExpression - | expression '?' expression ':' expression # TernaryExpression - | expression '=' expression # AssignmentExpression - | expression assignmentOperator expression # AssignmentOperatorExpression - | This # ThisExpression - | Identifier # IdentifierExpression - | Super # SuperExpression - | typeConverter expression # TypeConvertExpression - | literal # LiteralExpression - | arrayLiteral # ArrayLiteralExpression - | objectLiteral # ObjectLiteralExpression - | '(' expressions ')' # ParenthesizedExpression - | expression If expressions # IfExpression // b = c = 1 if a ==> (b=c=1)if a + : anoymousFunctionDeclaration # FunctionExpression + | expression '[' expressions ']' # MemberIndexExpression + | expression '.' identifierName # MemberDotExpression + | '.' identifierName # WithDotExpression + | expression arguments # CallExpression + | New expression arguments? # NewExpression + | '&' expression # ReferenceExpression + | '*' expression # PointerExpression + | expression '<->' expression # SwapExpression + | expression '!' # EvalExpression // t.f incontextof 's'! => 0721 (s=%[v=>0721]) + | expression Incontextof expression # InContextOfExpression // a incontextof d++ => Error: object++ + | expression '++' # PostIncrementExpression + | expression '--' # PostDecreaseExpression + | expression Isvalid # IsValidExpression // t incontextof ctx isvalid => 1 + | Delete expression # DeleteExpression // delete a.c isvalid => error + | Isvalid expression # IsValidExpression // isvalid delete a.c => 1 + | Typeof expression # TypeofExpression // typeof 1 instanceof "String" => 'Integer' + | expression Instanceof expression # InstanceofExpression // 1 instanceof "Number" isvalid => 0,isvalid 1 instanceof "String"=>1 + | Invalidate expression # InvalidateExpression // invalidate a instanceof "Number" => 0 + | expression In expression # InExpression // TODO: any standard for it? + | '++' expression # PreIncrementExpression + | '--' expression # PreDecreaseExpression // typeof 1 + 1 = 'Integer1' + | '+' expression # UnaryPlusExpression + | '-' expression # UnaryMinusExpression + | '~' expression # BitNotExpression + | '!' expression # NotExpression + | expression ('*' | '/' | '%' | '\\') expression # MultiplicativeExpression + | expression ('+' | '-') expression # AdditiveExpression + | expression ('<<' | '>>' | '>>>') expression # BitShiftExpression + | expression ('<' | '>' | '<=' | '>=') expression # RelationalExpression + | expression ('==' | '!=' | '===' | '!==') expression # EqualityExpression + | expression '&' expression # BitAndExpression + | expression '^' expression # BitXOrExpression + | expression '|' expression # BitOrExpression + | expression '&&' expression # LogicalAndExpression + | expression '||' expression # LogicalOrExpression + | expression '?' expression ':' expression # TernaryExpression + | expression '=' expression # AssignmentExpression + | expression assignmentOperator expression # AssignmentOperatorExpression + | This # ThisExpression + | Identifier # IdentifierExpression + | Super # SuperExpression + | typeConverter expression # TypeConvertExpression + | literal # LiteralExpression + | arrayLiteral # ArrayLiteralExpression + | objectLiteral # ObjectLiteralExpression + | '(' expressions ')' # ParenthesizedExpression + | expression If expressions # IfExpression // b = c = 1 if a ==> (b=c=1)if a ; assignmentOperator @@ -304,7 +305,6 @@ keyword | Delete | In | Try - | Class | Enum | Extends @@ -313,11 +313,10 @@ keyword | Export | Import | Static - | Incontextof ; eos : SemiColon | EOF - ; + ; \ No newline at end of file diff --git a/kotlin/kotlin-formal/KotlinLexer.g4 b/kotlin/kotlin-formal/KotlinLexer.g4 index 9e557a5f15..13a6976351 100644 --- a/kotlin/kotlin-formal/KotlinLexer.g4 +++ b/kotlin/kotlin-formal/KotlinLexer.g4 @@ -10,262 +10,216 @@ * https://github.com/JetBrains/kotlin/tree/master/compiler/testData/psi */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar KotlinLexer; import UnicodeClasses; -ShebangLine - : '#!' ~[\r\n]* - ; +ShebangLine: '#!' ~[\r\n]*; -DelimitedComment - : '/*' ( DelimitedComment | . )*? '*/' - -> channel(HIDDEN) - ; +DelimitedComment: '/*' ( DelimitedComment | .)*? '*/' -> channel(HIDDEN); -LineComment - : '//' ~[\r\n]* - -> channel(HIDDEN) - ; +LineComment: '//' ~[\r\n]* -> channel(HIDDEN); -WS - : [\u0020\u0009\u000C] - -> channel(HIDDEN) - ; +WS: [\u0020\u0009\u000C] -> channel(HIDDEN); -NL: '\n' | '\r' '\n'? ; +NL: '\n' | '\r' '\n'?; fragment Hidden: DelimitedComment | LineComment | WS; //SEPARATORS & OPERATIONS -RESERVED: '...' ; -DOT: '.' ; -COMMA: ',' ; -LPAREN: '(' -> pushMode(Inside); -RPAREN: ')' -> popMode; -LSQUARE: '[' -> pushMode(Inside); -RSQUARE: ']' -> popMode; -LCURL: '{' -> pushMode(DEFAULT_MODE); -RCURL: '}' -> popMode; -MULT: '*' ; -MOD: '%' ; -DIV: '/' ; -ADD: '+' ; -SUB: '-' ; -INCR: '++' ; -DECR: '--' ; -CONJ: '&&' ; -DISJ: '||' ; -EXCL_WS: '!' Hidden; -EXCL_NO_WS: '!'; -COLON: ':' ; -SEMICOLON: ';' ; -ASSIGNMENT: '=' ; -ADD_ASSIGNMENT: '+=' ; -SUB_ASSIGNMENT: '-=' ; -MULT_ASSIGNMENT: '*=' ; -DIV_ASSIGNMENT: '/=' ; -MOD_ASSIGNMENT: '%=' ; -ARROW: '->' ; -DOUBLE_ARROW: '=>' ; -RANGE: '..' ; -COLONCOLON: '::' ; -DOUBLE_SEMICOLON: ';;' ; -HASH: '#' ; -AT: '@' ; -AT_WS: AT (Hidden | NL) ; +RESERVED : '...'; +DOT : '.'; +COMMA : ','; +LPAREN : '(' -> pushMode(Inside); +RPAREN : ')' -> popMode; +LSQUARE : '[' -> pushMode(Inside); +RSQUARE : ']' -> popMode; +LCURL : '{' -> pushMode(DEFAULT_MODE); +RCURL : '}' -> popMode; +MULT : '*'; +MOD : '%'; +DIV : '/'; +ADD : '+'; +SUB : '-'; +INCR : '++'; +DECR : '--'; +CONJ : '&&'; +DISJ : '||'; +EXCL_WS : '!' Hidden; +EXCL_NO_WS : '!'; +COLON : ':'; +SEMICOLON : ';'; +ASSIGNMENT : '='; +ADD_ASSIGNMENT : '+='; +SUB_ASSIGNMENT : '-='; +MULT_ASSIGNMENT : '*='; +DIV_ASSIGNMENT : '/='; +MOD_ASSIGNMENT : '%='; +ARROW : '->'; +DOUBLE_ARROW : '=>'; +RANGE : '..'; +COLONCOLON : '::'; +DOUBLE_SEMICOLON : ';;'; +HASH : '#'; +AT : '@'; +AT_WS : AT (Hidden | NL); /* Disambiguating ? without spaces and with spaces (sometimes required) */ -QUEST_WS: '?' Hidden ; -QUEST_NO_WS: '?' ; -LANGLE: '<' ; -RANGLE: '>' ; -LE: '<=' ; -GE: '>=' ; -EXCL_EQ: '!=' ; -EXCL_EQEQ: '!==' ; -AS_SAFE: 'as?' ; -EQEQ: '==' ; -EQEQEQ: '===' ; -SINGLE_QUOTE: '\'' ; +QUEST_WS : '?' Hidden; +QUEST_NO_WS : '?'; +LANGLE : '<'; +RANGLE : '>'; +LE : '<='; +GE : '>='; +EXCL_EQ : '!='; +EXCL_EQEQ : '!=='; +AS_SAFE : 'as?'; +EQEQ : '=='; +EQEQEQ : '==='; +SINGLE_QUOTE : '\''; //KEYWORDS -RETURN_AT: 'return@' Identifier ; -CONTINUE_AT: 'continue@' Identifier ; -BREAK_AT: 'break@' Identifier ; - -THIS_AT: 'this@' Identifier ; -SUPER_AT: 'super@' Identifier ; - -PACKAGE: 'package' ; -IMPORT: 'import' ; -CLASS: 'class' ; -INTERFACE: 'interface' ; -FUN: 'fun' ; -OBJECT: 'object' ; -VAL: 'val' ; -VAR: 'var' ; -TYPE_ALIAS: 'typealias' ; -CONSTRUCTOR: 'constructor' ; -BY: 'by' ; -COMPANION: 'companion' ; -INIT: 'init' ; -THIS: 'this' ; -SUPER: 'super' ; -TYPEOF: 'typeof' ; -WHERE: 'where' ; -IF: 'if' ; -ELSE: 'else' ; -WHEN: 'when' ; -TRY: 'try' ; -CATCH: 'catch' ; -FINALLY: 'finally' ; -FOR: 'for' ; -DO: 'do' ; -WHILE: 'while' ; -THROW: 'throw' ; -RETURN: 'return' ; -CONTINUE: 'continue' ; -BREAK: 'break' ; -AS: 'as' ; -IS: 'is' ; -IN: 'in' ; -NOT_IS: '!is' (Hidden | NL) ; -NOT_IN: '!in' (Hidden | NL) ; -OUT: 'out' ; -GETTER: 'get' ; -SETTER: 'set' ; -DYNAMIC: 'dynamic' ; -AT_FILE: '@file' ; -AT_FIELD: '@field' ; -AT_PROPERTY: '@property' ; -AT_GET: '@get' ; -AT_SET: '@set' ; -AT_RECEIVER: '@receiver' ; -AT_PARAM: '@param' ; -AT_SETPARAM: '@setparam' ; -AT_DELEGATE: '@delegate' ; +RETURN_AT : 'return@' Identifier; +CONTINUE_AT : 'continue@' Identifier; +BREAK_AT : 'break@' Identifier; + +THIS_AT : 'this@' Identifier; +SUPER_AT : 'super@' Identifier; + +PACKAGE : 'package'; +IMPORT : 'import'; +CLASS : 'class'; +INTERFACE : 'interface'; +FUN : 'fun'; +OBJECT : 'object'; +VAL : 'val'; +VAR : 'var'; +TYPE_ALIAS : 'typealias'; +CONSTRUCTOR : 'constructor'; +BY : 'by'; +COMPANION : 'companion'; +INIT : 'init'; +THIS : 'this'; +SUPER : 'super'; +TYPEOF : 'typeof'; +WHERE : 'where'; +IF : 'if'; +ELSE : 'else'; +WHEN : 'when'; +TRY : 'try'; +CATCH : 'catch'; +FINALLY : 'finally'; +FOR : 'for'; +DO : 'do'; +WHILE : 'while'; +THROW : 'throw'; +RETURN : 'return'; +CONTINUE : 'continue'; +BREAK : 'break'; +AS : 'as'; +IS : 'is'; +IN : 'in'; +NOT_IS : '!is' (Hidden | NL); +NOT_IN : '!in' (Hidden | NL); +OUT : 'out'; +GETTER : 'get'; +SETTER : 'set'; +DYNAMIC : 'dynamic'; +AT_FILE : '@file'; +AT_FIELD : '@field'; +AT_PROPERTY : '@property'; +AT_GET : '@get'; +AT_SET : '@set'; +AT_RECEIVER : '@receiver'; +AT_PARAM : '@param'; +AT_SETPARAM : '@setparam'; +AT_DELEGATE : '@delegate'; //MODIFIERS -PUBLIC: 'public' ; -PRIVATE: 'private' ; -PROTECTED: 'protected' ; -INTERNAL: 'internal' ; -ENUM: 'enum' ; -SEALED: 'sealed' ; -ANNOTATION: 'annotation' ; -DATA: 'data' ; -INNER: 'inner' ; -TAILREC: 'tailrec' ; -OPERATOR: 'operator' ; -INLINE: 'inline' ; -INFIX: 'infix' ; -EXTERNAL: 'external' ; -SUSPEND: 'suspend' ; -OVERRIDE: 'override' ; -ABSTRACT: 'abstract' ; -FINAL: 'final' ; -OPEN: 'open' ; -CONST: 'const' ; -LATEINIT: 'lateinit' ; -VARARG: 'vararg' ; -NOINLINE: 'noinline' ; -CROSSINLINE: 'crossinline' ; -REIFIED: 'reified' ; - -EXPECT: 'expect' ; -ACTUAL: 'actual' ; - -QUOTE_OPEN: '"' -> pushMode(LineString) ; -TRIPLE_QUOTE_OPEN: '"""' -> pushMode(MultiLineString) ; - -RealLiteral - : FloatLiteral - | DoubleLiteral - ; - -FloatLiteral - : DoubleLiteral [fF] - | DecDigits [fF] - ; - -fragment DecDigitOrSeparator: DecDigit | '_'; -fragment DecDigits - : DecDigit DecDigitOrSeparator* DecDigit - | DecDigit - ; -fragment DoubleExponent: [eE] [+-]? DecDigits; - -DoubleLiteral - : DecDigits? '.' DecDigits DoubleExponent? - | DecDigits DoubleExponent - ; - -LongLiteral - : (IntegerLiteral | HexLiteral | BinLiteral) 'L' - ; - -IntegerLiteral - : DecDigitNoZero DecDigitOrSeparator* DecDigit +PUBLIC : 'public'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +INTERNAL : 'internal'; +ENUM : 'enum'; +SEALED : 'sealed'; +ANNOTATION : 'annotation'; +DATA : 'data'; +INNER : 'inner'; +TAILREC : 'tailrec'; +OPERATOR : 'operator'; +INLINE : 'inline'; +INFIX : 'infix'; +EXTERNAL : 'external'; +SUSPEND : 'suspend'; +OVERRIDE : 'override'; +ABSTRACT : 'abstract'; +FINAL : 'final'; +OPEN : 'open'; +CONST : 'const'; +LATEINIT : 'lateinit'; +VARARG : 'vararg'; +NOINLINE : 'noinline'; +CROSSINLINE : 'crossinline'; +REIFIED : 'reified'; + +EXPECT : 'expect'; +ACTUAL : 'actual'; + +QUOTE_OPEN : '"' -> pushMode(LineString); +TRIPLE_QUOTE_OPEN : '"""' -> pushMode(MultiLineString); + +RealLiteral: FloatLiteral | DoubleLiteral; + +FloatLiteral: DoubleLiteral [fF] | DecDigits [fF]; + +fragment DecDigitOrSeparator : DecDigit | '_'; +fragment DecDigits : DecDigit DecDigitOrSeparator* DecDigit | DecDigit; +fragment DoubleExponent : [eE] [+-]? DecDigits; + +DoubleLiteral: DecDigits? '.' DecDigits DoubleExponent? | DecDigits DoubleExponent; + +LongLiteral: (IntegerLiteral | HexLiteral | BinLiteral) 'L'; + +IntegerLiteral: + DecDigitNoZero DecDigitOrSeparator* DecDigit | DecDigit // including '0' - ; +; -fragment UnicodeDigit - : UNICODE_CLASS_ND - ; +fragment UnicodeDigit: UNICODE_CLASS_ND; -fragment DecDigit - : '0'..'9' - ; +fragment DecDigit: '0' ..'9'; -fragment DecDigitNoZero - : '1'..'9' - ; +fragment DecDigitNoZero: '1' ..'9'; -fragment HexDigitOrSeparator - : HexDigit | '_' - ; +fragment HexDigitOrSeparator: HexDigit | '_'; -HexLiteral - : '0' [xX] HexDigit HexDigitOrSeparator* HexDigit - | '0' [xX] HexDigit - ; +HexLiteral: '0' [xX] HexDigit HexDigitOrSeparator* HexDigit | '0' [xX] HexDigit; -fragment HexDigit - : [0-9a-fA-F] - ; +fragment HexDigit: [0-9a-fA-F]; -fragment BinDigitOrSeparator - : BinDigit | '_' - ; +fragment BinDigitOrSeparator: BinDigit | '_'; -BinLiteral - : '0' [bB] BinDigit BinDigitOrSeparator* BinDigit - | '0' [bB] BinDigit - ; +BinLiteral: '0' [bB] BinDigit BinDigitOrSeparator* BinDigit | '0' [bB] BinDigit; -fragment BinDigit - : [01] - ; +fragment BinDigit: [01]; -BooleanLiteral - : 'true' - | 'false' - ; +BooleanLiteral: 'true' | 'false'; -NullLiteral - : 'null' - ; +NullLiteral: 'null'; -Identifier - : (Letter | '_') (Letter | '_' | UnicodeDigit)* +Identifier: + (Letter | '_') (Letter | '_' | UnicodeDigit)* | '`' ~('\r' | '\n' | '`' | '[' | ']' | '<' | '>')+ '`' - ; +; -fragment IdentifierOrSoftKey - : Identifier //soft keywords: +fragment IdentifierOrSoftKey: + Identifier //soft keywords: | ABSTRACT | ANNOTATION | BY @@ -306,221 +260,191 @@ fragment IdentifierOrSoftKey //strong keywords | CONST | SUSPEND - ; +; -IdentifierAt - : IdentifierOrSoftKey '@' - ; +IdentifierAt: IdentifierOrSoftKey '@'; -FieldIdentifier // why is this even needed? - : '$' IdentifierOrSoftKey - ; +FieldIdentifier: '$' IdentifierOrSoftKey; // why is this even needed? -CharacterLiteral - : '\'' (EscapeSeq | ~[\n\r'\\]) '\'' - ; +CharacterLiteral: '\'' (EscapeSeq | ~[\n\r'\\]) '\''; -fragment EscapeSeq - : UniCharacterLiteral - | EscapedIdentifier - ; +fragment EscapeSeq: UniCharacterLiteral | EscapedIdentifier; -fragment UniCharacterLiteral - : '\\' 'u' HexDigit HexDigit HexDigit HexDigit - ; +fragment UniCharacterLiteral: '\\' 'u' HexDigit HexDigit HexDigit HexDigit; -fragment EscapedIdentifier - : '\\' ('t' | 'b' | 'r' | 'n' | '\'' | '"' | '\\' | '$') - ; +fragment EscapedIdentifier: '\\' ('t' | 'b' | 'r' | 'n' | '\'' | '"' | '\\' | '$'); -fragment Letter - : UNICODE_CLASS_LL +fragment Letter: + UNICODE_CLASS_LL | UNICODE_CLASS_LM | UNICODE_CLASS_LO | UNICODE_CLASS_LT | UNICODE_CLASS_LU | UNICODE_CLASS_NL - ; +; ErrorCharacter: .; -mode Inside ; - -Inside_RPAREN: RPAREN -> popMode, type(RPAREN) ; -Inside_RSQUARE: RSQUARE -> popMode, type(RSQUARE); -Inside_LPAREN: LPAREN -> pushMode(Inside), type(LPAREN) ; -Inside_LSQUARE: LSQUARE -> pushMode(Inside), type(LSQUARE) ; -Inside_LCURL: LCURL -> pushMode(DEFAULT_MODE), type(LCURL) ; -Inside_RCURL: RCURL -> popMode, type(RCURL) ; - -Inside_DOT: DOT -> type(DOT) ; -Inside_COMMA: COMMA -> type(COMMA) ; -Inside_MULT: MULT -> type(MULT) ; -Inside_MOD: MOD -> type(MOD) ; -Inside_DIV: DIV -> type(DIV) ; -Inside_ADD: ADD -> type(ADD) ; -Inside_SUB: SUB -> type(SUB) ; -Inside_INCR: INCR -> type(INCR) ; -Inside_DECR: DECR -> type(DECR) ; -Inside_CONJ: CONJ -> type(CONJ) ; -Inside_DISJ: DISJ -> type(DISJ) ; -Inside_EXCL_WS: '!' (Hidden|NL) -> type(EXCL_WS) ; -Inside_EXCL_NO_WS: EXCL_NO_WS -> type(EXCL_NO_WS) ; -Inside_COLON: COLON -> type(COLON) ; -Inside_SEMICOLON: SEMICOLON -> type(SEMICOLON) ; -Inside_ASSIGNMENT: ASSIGNMENT -> type(ASSIGNMENT) ; -Inside_ADD_ASSIGNMENT: ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT) ; -Inside_SUB_ASSIGNMENT: SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT) ; -Inside_MULT_ASSIGNMENT: MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT) ; -Inside_DIV_ASSIGNMENT: DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT) ; -Inside_MOD_ASSIGNMENT: MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT) ; -Inside_ARROW: ARROW -> type(ARROW) ; -Inside_DOUBLE_ARROW: DOUBLE_ARROW -> type(DOUBLE_ARROW) ; -Inside_RANGE: RANGE -> type(RANGE) ; -Inside_RESERVED: RESERVED -> type(RESERVED) ; -Inside_COLONCOLON: COLONCOLON -> type(COLONCOLON) ; -Inside_DOUBLE_SEMICOLON: DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON) ; -Inside_HASH: HASH -> type(HASH) ; -Inside_AT: AT -> type(AT) ; -Inside_QUEST_WS: '?' (Hidden | NL) -> type(QUEST_WS) ; -Inside_QUEST_NO_WS: QUEST_NO_WS -> type(QUEST_NO_WS) ; -Inside_LANGLE: LANGLE -> type(LANGLE) ; -Inside_RANGLE: RANGLE -> type(RANGLE) ; -Inside_LE: LE -> type(LE) ; -Inside_GE: GE -> type(GE) ; -Inside_EXCL_EQ: EXCL_EQ -> type(EXCL_EQ) ; -Inside_EXCL_EQEQ: EXCL_EQEQ -> type(EXCL_EQEQ) ; -Inside_IS: IS -> type(IS) ; -Inside_NOT_IS: NOT_IS -> type(NOT_IS) ; -Inside_NOT_IN: NOT_IN -> type(NOT_IN) ; -Inside_AS: AS -> type(AS) ; -Inside_AS_SAFE: AS_SAFE -> type(AS_SAFE) ; -Inside_EQEQ: EQEQ -> type(EQEQ) ; -Inside_EQEQEQ: EQEQEQ -> type(EQEQEQ) ; -Inside_SINGLE_QUOTE: SINGLE_QUOTE -> type(SINGLE_QUOTE) ; -Inside_QUOTE_OPEN: QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN) ; -Inside_TRIPLE_QUOTE_OPEN: TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) ; - -Inside_VAL: VAL -> type(VAL) ; -Inside_VAR: VAR -> type(VAR) ; -Inside_FUN: FUN -> type(FUN) ; -Inside_OBJECT: OBJECT -> type(OBJECT) ; -Inside_SUPER: SUPER -> type(SUPER) ; -Inside_IN: IN -> type(IN) ; -Inside_OUT: OUT -> type(OUT) ; -Inside_AT_FIELD: AT_FIELD -> type(AT_FIELD) ; -Inside_AT_FILE: AT_FILE -> type(AT_FILE) ; -Inside_AT_PROPERTY: AT_PROPERTY -> type(AT_PROPERTY) ; -Inside_AT_GET: AT_GET -> type(AT_GET) ; -Inside_AT_SET: AT_SET -> type(AT_SET) ; -Inside_AT_RECEIVER: AT_RECEIVER -> type(AT_RECEIVER) ; -Inside_AT_PARAM: AT_PARAM -> type(AT_PARAM) ; -Inside_AT_SETPARAM: AT_SETPARAM -> type(AT_SETPARAM) ; -Inside_AT_DELEGATE: AT_DELEGATE -> type(AT_DELEGATE) ; -Inside_THROW: THROW -> type(THROW) ; -Inside_RETURN: RETURN -> type(RETURN) ; -Inside_CONTINUE: CONTINUE -> type(CONTINUE) ; -Inside_BREAK: BREAK -> type(BREAK) ; -Inside_RETURN_AT: RETURN_AT -> type(RETURN_AT) ; -Inside_CONTINUE_AT: CONTINUE_AT -> type(CONTINUE_AT) ; -Inside_BREAK_AT: BREAK_AT -> type(BREAK_AT) ; -Inside_IF: IF -> type(IF) ; -Inside_ELSE: ELSE -> type(ELSE) ; -Inside_WHEN: WHEN -> type(WHEN) ; -Inside_TRY: TRY -> type(TRY) ; -Inside_CATCH: CATCH -> type(CATCH) ; -Inside_FINALLY: FINALLY -> type(FINALLY) ; -Inside_FOR: FOR -> type(FOR) ; -Inside_DO: DO -> type(DO) ; -Inside_WHILE: WHILE -> type(WHILE) ; - -Inside_PUBLIC: PUBLIC -> type(PUBLIC) ; -Inside_PRIVATE: PRIVATE -> type(PRIVATE) ; -Inside_PROTECTED: PROTECTED -> type(PROTECTED) ; -Inside_INTERNAL: INTERNAL -> type(INTERNAL) ; -Inside_ENUM: ENUM -> type(ENUM) ; -Inside_SEALED: SEALED -> type(SEALED) ; -Inside_ANNOTATION: ANNOTATION -> type(ANNOTATION) ; -Inside_DATA: DATA -> type(DATA) ; -Inside_INNER: INNER -> type(INNER) ; -Inside_TAILREC: TAILREC -> type(TAILREC) ; -Inside_OPERATOR: OPERATOR -> type(OPERATOR) ; -Inside_INLINE: INLINE -> type(INLINE) ; -Inside_INFIX: INFIX -> type(INFIX) ; -Inside_EXTERNAL: EXTERNAL -> type(EXTERNAL) ; -Inside_SUSPEND: SUSPEND -> type(SUSPEND) ; -Inside_OVERRIDE: OVERRIDE -> type(OVERRIDE) ; -Inside_ABSTRACT: ABSTRACT -> type(ABSTRACT) ; -Inside_FINAL: FINAL -> type(FINAL) ; -Inside_OPEN: OPEN -> type(OPEN) ; -Inside_CONST: CONST -> type(CONST) ; -Inside_LATEINIT: LATEINIT -> type(LATEINIT) ; -Inside_VARARG: VARARG -> type(VARARG) ; -Inside_NOINLINE: NOINLINE -> type(NOINLINE) ; -Inside_CROSSINLINE: CROSSINLINE -> type(CROSSINLINE) ; -Inside_REIFIED: REIFIED -> type(REIFIED) ; -Inside_EXPECT: EXPECT -> type(EXPECT) ; -Inside_ACTUAL: ACTUAL -> type(ACTUAL) ; - -Inside_BooleanLiteral: BooleanLiteral -> type(BooleanLiteral) ; -Inside_IntegerLiteral: IntegerLiteral -> type(IntegerLiteral) ; -Inside_HexLiteral: HexLiteral -> type(HexLiteral) ; -Inside_BinLiteral: BinLiteral -> type(BinLiteral) ; -Inside_CharacterLiteral: CharacterLiteral -> type(CharacterLiteral) ; -Inside_RealLiteral: RealLiteral -> type(RealLiteral) ; -Inside_NullLiteral: NullLiteral -> type(NullLiteral) ; -Inside_LongLiteral: LongLiteral -> type(LongLiteral) ; - -Inside_Identifier: Identifier -> type(Identifier) ; -Inside_IdentifierAt: IdentifierAt -> type(IdentifierAt) ; -Inside_Comment: (LineComment | DelimitedComment) -> channel(HIDDEN) ; -Inside_WS: WS -> channel(HIDDEN) ; -Inside_NL: NL -> channel(HIDDEN) ; - -mode LineString ; - -QUOTE_CLOSE - : '"' -> popMode - ; - -LineStrRef - : FieldIdentifier - ; - -LineStrText - : ~('\\' | '"' | '$')+ | '$' - ; - -LineStrEscapedChar - : EscapedIdentifier - | UniCharacterLiteral - ; - -LineStrExprStart - : '${' -> pushMode(DEFAULT_MODE) - ; - - -mode MultiLineString ; - -TRIPLE_QUOTE_CLOSE - : MultiLineStringQuote? '"""' -> popMode - ; - -MultiLineStringQuote - : '"'+ - ; - -MultiLineStrRef - : FieldIdentifier - ; - -MultiLineStrText - : ~('"' | '$')+ | '$' // multiline does not support escaping, so only '$' should be disallowed - ; - -MultiLineStrExprStart - : '${' -> pushMode(DEFAULT_MODE) - ; - -MultiLineNL: NL -> type(NL) ; +mode Inside; + +Inside_RPAREN : RPAREN -> popMode, type(RPAREN); +Inside_RSQUARE : RSQUARE -> popMode, type(RSQUARE); +Inside_LPAREN : LPAREN -> pushMode(Inside), type(LPAREN); +Inside_LSQUARE : LSQUARE -> pushMode(Inside), type(LSQUARE); +Inside_LCURL : LCURL -> pushMode(DEFAULT_MODE), type(LCURL); +Inside_RCURL : RCURL -> popMode, type(RCURL); + +Inside_DOT : DOT -> type(DOT); +Inside_COMMA : COMMA -> type(COMMA); +Inside_MULT : MULT -> type(MULT); +Inside_MOD : MOD -> type(MOD); +Inside_DIV : DIV -> type(DIV); +Inside_ADD : ADD -> type(ADD); +Inside_SUB : SUB -> type(SUB); +Inside_INCR : INCR -> type(INCR); +Inside_DECR : DECR -> type(DECR); +Inside_CONJ : CONJ -> type(CONJ); +Inside_DISJ : DISJ -> type(DISJ); +Inside_EXCL_WS : '!' (Hidden | NL) -> type(EXCL_WS); +Inside_EXCL_NO_WS : EXCL_NO_WS -> type(EXCL_NO_WS); +Inside_COLON : COLON -> type(COLON); +Inside_SEMICOLON : SEMICOLON -> type(SEMICOLON); +Inside_ASSIGNMENT : ASSIGNMENT -> type(ASSIGNMENT); +Inside_ADD_ASSIGNMENT : ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT); +Inside_SUB_ASSIGNMENT : SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT); +Inside_MULT_ASSIGNMENT : MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT); +Inside_DIV_ASSIGNMENT : DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT); +Inside_MOD_ASSIGNMENT : MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT); +Inside_ARROW : ARROW -> type(ARROW); +Inside_DOUBLE_ARROW : DOUBLE_ARROW -> type(DOUBLE_ARROW); +Inside_RANGE : RANGE -> type(RANGE); +Inside_RESERVED : RESERVED -> type(RESERVED); +Inside_COLONCOLON : COLONCOLON -> type(COLONCOLON); +Inside_DOUBLE_SEMICOLON : DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON); +Inside_HASH : HASH -> type(HASH); +Inside_AT : AT -> type(AT); +Inside_QUEST_WS : '?' (Hidden | NL) -> type(QUEST_WS); +Inside_QUEST_NO_WS : QUEST_NO_WS -> type(QUEST_NO_WS); +Inside_LANGLE : LANGLE -> type(LANGLE); +Inside_RANGLE : RANGLE -> type(RANGLE); +Inside_LE : LE -> type(LE); +Inside_GE : GE -> type(GE); +Inside_EXCL_EQ : EXCL_EQ -> type(EXCL_EQ); +Inside_EXCL_EQEQ : EXCL_EQEQ -> type(EXCL_EQEQ); +Inside_IS : IS -> type(IS); +Inside_NOT_IS : NOT_IS -> type(NOT_IS); +Inside_NOT_IN : NOT_IN -> type(NOT_IN); +Inside_AS : AS -> type(AS); +Inside_AS_SAFE : AS_SAFE -> type(AS_SAFE); +Inside_EQEQ : EQEQ -> type(EQEQ); +Inside_EQEQEQ : EQEQEQ -> type(EQEQEQ); +Inside_SINGLE_QUOTE : SINGLE_QUOTE -> type(SINGLE_QUOTE); +Inside_QUOTE_OPEN : QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN); +Inside_TRIPLE_QUOTE_OPEN: + TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) +; + +Inside_VAL : VAL -> type(VAL); +Inside_VAR : VAR -> type(VAR); +Inside_FUN : FUN -> type(FUN); +Inside_OBJECT : OBJECT -> type(OBJECT); +Inside_SUPER : SUPER -> type(SUPER); +Inside_IN : IN -> type(IN); +Inside_OUT : OUT -> type(OUT); +Inside_AT_FIELD : AT_FIELD -> type(AT_FIELD); +Inside_AT_FILE : AT_FILE -> type(AT_FILE); +Inside_AT_PROPERTY : AT_PROPERTY -> type(AT_PROPERTY); +Inside_AT_GET : AT_GET -> type(AT_GET); +Inside_AT_SET : AT_SET -> type(AT_SET); +Inside_AT_RECEIVER : AT_RECEIVER -> type(AT_RECEIVER); +Inside_AT_PARAM : AT_PARAM -> type(AT_PARAM); +Inside_AT_SETPARAM : AT_SETPARAM -> type(AT_SETPARAM); +Inside_AT_DELEGATE : AT_DELEGATE -> type(AT_DELEGATE); +Inside_THROW : THROW -> type(THROW); +Inside_RETURN : RETURN -> type(RETURN); +Inside_CONTINUE : CONTINUE -> type(CONTINUE); +Inside_BREAK : BREAK -> type(BREAK); +Inside_RETURN_AT : RETURN_AT -> type(RETURN_AT); +Inside_CONTINUE_AT : CONTINUE_AT -> type(CONTINUE_AT); +Inside_BREAK_AT : BREAK_AT -> type(BREAK_AT); +Inside_IF : IF -> type(IF); +Inside_ELSE : ELSE -> type(ELSE); +Inside_WHEN : WHEN -> type(WHEN); +Inside_TRY : TRY -> type(TRY); +Inside_CATCH : CATCH -> type(CATCH); +Inside_FINALLY : FINALLY -> type(FINALLY); +Inside_FOR : FOR -> type(FOR); +Inside_DO : DO -> type(DO); +Inside_WHILE : WHILE -> type(WHILE); + +Inside_PUBLIC : PUBLIC -> type(PUBLIC); +Inside_PRIVATE : PRIVATE -> type(PRIVATE); +Inside_PROTECTED : PROTECTED -> type(PROTECTED); +Inside_INTERNAL : INTERNAL -> type(INTERNAL); +Inside_ENUM : ENUM -> type(ENUM); +Inside_SEALED : SEALED -> type(SEALED); +Inside_ANNOTATION : ANNOTATION -> type(ANNOTATION); +Inside_DATA : DATA -> type(DATA); +Inside_INNER : INNER -> type(INNER); +Inside_TAILREC : TAILREC -> type(TAILREC); +Inside_OPERATOR : OPERATOR -> type(OPERATOR); +Inside_INLINE : INLINE -> type(INLINE); +Inside_INFIX : INFIX -> type(INFIX); +Inside_EXTERNAL : EXTERNAL -> type(EXTERNAL); +Inside_SUSPEND : SUSPEND -> type(SUSPEND); +Inside_OVERRIDE : OVERRIDE -> type(OVERRIDE); +Inside_ABSTRACT : ABSTRACT -> type(ABSTRACT); +Inside_FINAL : FINAL -> type(FINAL); +Inside_OPEN : OPEN -> type(OPEN); +Inside_CONST : CONST -> type(CONST); +Inside_LATEINIT : LATEINIT -> type(LATEINIT); +Inside_VARARG : VARARG -> type(VARARG); +Inside_NOINLINE : NOINLINE -> type(NOINLINE); +Inside_CROSSINLINE : CROSSINLINE -> type(CROSSINLINE); +Inside_REIFIED : REIFIED -> type(REIFIED); +Inside_EXPECT : EXPECT -> type(EXPECT); +Inside_ACTUAL : ACTUAL -> type(ACTUAL); + +Inside_BooleanLiteral : BooleanLiteral -> type(BooleanLiteral); +Inside_IntegerLiteral : IntegerLiteral -> type(IntegerLiteral); +Inside_HexLiteral : HexLiteral -> type(HexLiteral); +Inside_BinLiteral : BinLiteral -> type(BinLiteral); +Inside_CharacterLiteral : CharacterLiteral -> type(CharacterLiteral); +Inside_RealLiteral : RealLiteral -> type(RealLiteral); +Inside_NullLiteral : NullLiteral -> type(NullLiteral); +Inside_LongLiteral : LongLiteral -> type(LongLiteral); + +Inside_Identifier : Identifier -> type(Identifier); +Inside_IdentifierAt : IdentifierAt -> type(IdentifierAt); +Inside_Comment : (LineComment | DelimitedComment) -> channel(HIDDEN); +Inside_WS : WS -> channel(HIDDEN); +Inside_NL : NL -> channel(HIDDEN); + +mode LineString; + +QUOTE_CLOSE: '"' -> popMode; + +LineStrRef: FieldIdentifier; + +LineStrText: ~('\\' | '"' | '$')+ | '$'; + +LineStrEscapedChar: EscapedIdentifier | UniCharacterLiteral; + +LineStrExprStart: '${' -> pushMode(DEFAULT_MODE); + +mode MultiLineString; + +TRIPLE_QUOTE_CLOSE: MultiLineStringQuote? '"""' -> popMode; + +MultiLineStringQuote: '"'+; + +MultiLineStrRef: FieldIdentifier; + +MultiLineStrText: + ~('"' | '$')+ + | '$' // multiline does not support escaping, so only '$' should be disallowed +; + +MultiLineStrExprStart: '${' -> pushMode(DEFAULT_MODE); + +MultiLineNL: NL -> type(NL); \ No newline at end of file diff --git a/kotlin/kotlin-formal/KotlinParser.g4 b/kotlin/kotlin-formal/KotlinParser.g4 index 2705e0bbb3..5d2e0aa7e1 100644 --- a/kotlin/kotlin-formal/KotlinParser.g4 +++ b/kotlin/kotlin-formal/KotlinParser.g4 @@ -10,9 +10,14 @@ * https://github.com/JetBrains/kotlin/tree/master/compiler/testData/psi */ +// $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 KotlinParser; -options { tokenVocab = KotlinLexer; } +options { + tokenVocab = KotlinLexer; +} kotlinFile : shebangLine? NL* fileAnnotation* packageHeader importList topLevelObject* EOF @@ -47,11 +52,12 @@ topLevelObject ; classDeclaration - : modifiers? ('class' | 'interface') NL* simpleIdentifier - (NL* typeParameters)? (NL* primaryConstructor)? - (NL* ':' NL* delegationSpecifiers)? - (NL* typeConstraints)? - (NL* classBody | NL* enumClassBody)? + : modifiers? ('class' | 'interface') NL* simpleIdentifier (NL* typeParameters)? ( + NL* primaryConstructor + )? (NL* ':' NL* delegationSpecifiers)? (NL* typeConstraints)? ( + NL* classBody + | NL* enumClassBody + )? ; primaryConstructor @@ -130,12 +136,9 @@ enumEntry ; functionDeclaration - : modifiers? - 'fun' (NL* typeParameters)? (NL* receiverType NL* '.')? NL* simpleIdentifier - NL* functionValueParameters - (NL* ':' NL* type_)? - (NL* typeConstraints)? - (NL* functionBody)? + : modifiers? 'fun' (NL* typeParameters)? (NL* receiverType NL* '.')? NL* simpleIdentifier NL* functionValueParameters ( + NL* ':' NL* type_ + )? (NL* typeConstraints)? (NL* functionBody)? ; functionValueParameters @@ -160,27 +163,22 @@ functionBody ; objectDeclaration - : modifiers? 'object' - NL* simpleIdentifier - (NL* ':' NL* delegationSpecifiers)? - (NL* classBody)? + : modifiers? 'object' NL* simpleIdentifier (NL* ':' NL* delegationSpecifiers)? (NL* classBody)? ; companionObject - : modifiers? 'companion' NL* 'object' - (NL* simpleIdentifier)? - (NL* ':' NL* delegationSpecifiers)? - (NL* classBody)? + : modifiers? 'companion' NL* 'object' (NL* simpleIdentifier)? ( + NL* ':' NL* delegationSpecifiers + )? (NL* classBody)? ; propertyDeclaration - : modifiers? ('val' | 'var') - (NL* typeParameters)? - (NL* receiverType NL* '.')? - (NL* (multiVariableDeclaration | variableDeclaration)) - (NL* typeConstraints)? - (NL* ('=' NL* expression | propertyDelegate))? - (NL+ ';')? NL* (getter? (NL* semi? setter)? | setter? (NL* semi? getter)?) + : modifiers? ('val' | 'var') (NL* typeParameters)? (NL* receiverType NL* '.')? ( + NL* (multiVariableDeclaration | variableDeclaration) + ) (NL* typeConstraints)? (NL* ('=' NL* expression | propertyDelegate))? (NL+ ';')? NL* ( + getter? (NL* semi? setter)? + | setter? (NL* semi? getter)? + ) /* XXX: actually, it's not that simple. You can put semi only on the same line as getter, but any other semicolons between property and getter are forbidden @@ -207,7 +205,9 @@ getter setter : modifiers? 'set' - | modifiers? 'set' NL* '(' (annotation | parameterModifier)* setterParameter ')' (NL* ':' NL* type_)? NL* functionBody + | modifiers? 'set' NL* '(' (annotation | parameterModifier)* setterParameter ')' ( + NL* ':' NL* type_ + )? NL* functionBody ; typeAlias @@ -233,11 +233,7 @@ typeParameterModifier ; type_ - : typeModifiers? - ( parenthesizedType - | nullableType - | typeReference - | functionType) + : typeModifiers? (parenthesizedType | nullableType | typeReference | functionType) ; typeModifiers @@ -245,7 +241,8 @@ typeModifiers ; typeModifier - : annotation | 'suspend' NL* + : annotation + | 'suspend' NL* ; parenthesizedType @@ -266,10 +263,7 @@ functionType ; receiverType - : typeModifiers? - ( parenthesizedType - | nullableType - | typeReference) + : typeModifiers? (parenthesizedType | nullableType | typeReference) ; userType @@ -306,11 +300,7 @@ statements ; statement - : (label | annotation)* - ( declaration - | assignment - | loopStatement - | expression) + : (label | annotation)* (declaration | assignment | loopStatement | expression) ; declaration @@ -439,7 +429,8 @@ typeArguments ; typeProjection - : typeProjectionModifiers? type_ | '*' + : typeProjectionModifiers? type_ + | '*' ; typeProjectionModifiers @@ -540,12 +531,9 @@ lambdaParameter ; anonymousFunction - : 'fun' - (NL* type_ NL* '.')? - NL* functionValueParameters - (NL* ':' NL* type_)? - (NL* typeConstraints)? - (NL* functionBody)? + : 'fun' (NL* type_ NL* '.')? NL* functionValueParameters (NL* ':' NL* type_)? ( + NL* typeConstraints + )? (NL* functionBody)? ; functionLiteral @@ -574,7 +562,9 @@ controlStructureBody ; ifExpression - : 'if' NL* '(' NL* expression NL* ')' NL* controlStructureBody (';'? NL* 'else' NL* controlStructureBody)? + : 'if' NL* '(' NL* expression NL* ')' NL* controlStructureBody ( + ';'? NL* 'else' NL* controlStructureBody + )? | 'if' NL* '(' NL* expression NL* ')' NL* (';' NL*)? 'else' NL* controlStructureBody ; @@ -635,8 +625,10 @@ doWhileStatement jumpExpression : 'throw' NL* expression | ('return' | RETURN_AT) expression? - | 'continue' | CONTINUE_AT - | 'break' | BREAK_AT + | 'continue' + | CONTINUE_AT + | 'break' + | BREAK_AT ; callableReference // ?:: here is not an actual operator, it's just a lexer hack to avoid (?: + :) vs (? + ::) ambiguity @@ -666,15 +658,18 @@ comparisonOperator ; inOperator - : 'in' | NOT_IN + : 'in' + | NOT_IN ; isOperator - : 'is' | NOT_IS + : 'is' + | NOT_IS ; additiveOperator - : '+' | '-' + : '+' + | '-' ; multiplicativeOperator @@ -703,7 +698,9 @@ postfixUnaryOperator ; memberAccessOperator - : '.' | safeNav | '::' + : '.' + | safeNav + | '::' ; modifiers @@ -711,14 +708,16 @@ modifiers ; modifier - : (classModifier - | memberModifier - | visibilityModifier - | functionModifier - | propertyModifier - | inheritanceModifier - | parameterModifier - | platformModifier) NL* + : ( + classModifier + | memberModifier + | visibilityModifier + | functionModifier + | propertyModifier + | inheritanceModifier + | parameterModifier + | platformModifier + ) NL* ; classModifier @@ -891,4 +890,4 @@ semi semis // writing this as "semi+" sends antlr into infinite loop or smth : (';' | NL)+ | EOF - ; + ; \ No newline at end of file diff --git a/kotlin/kotlin-formal/UnicodeClasses.g4 b/kotlin/kotlin-formal/UnicodeClasses.g4 index e61e1bbc63..642a8b79d2 100644 --- a/kotlin/kotlin-formal/UnicodeClasses.g4 +++ b/kotlin/kotlin-formal/UnicodeClasses.g4 @@ -2,1644 +2,1655 @@ * Taken from http://www.antlr3.org/grammar/1345144569663/AntlrUnicode.txt */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar UnicodeClasses; UNICODE_CLASS_LL: - '\u0061'..'\u007A' | - '\u00B5' | - '\u00DF'..'\u00F6' | - '\u00F8'..'\u00FF' | - '\u0101' | - '\u0103' | - '\u0105' | - '\u0107' | - '\u0109' | - '\u010B' | - '\u010D' | - '\u010F' | - '\u0111' | - '\u0113' | - '\u0115' | - '\u0117' | - '\u0119' | - '\u011B' | - '\u011D' | - '\u011F' | - '\u0121' | - '\u0123' | - '\u0125' | - '\u0127' | - '\u0129' | - '\u012B' | - '\u012D' | - '\u012F' | - '\u0131' | - '\u0133' | - '\u0135' | - '\u0137' | - '\u0138' | - '\u013A' | - '\u013C' | - '\u013E' | - '\u0140' | - '\u0142' | - '\u0144' | - '\u0146' | - '\u0148' | - '\u0149' | - '\u014B' | - '\u014D' | - '\u014F' | - '\u0151' | - '\u0153' | - '\u0155' | - '\u0157' | - '\u0159' | - '\u015B' | - '\u015D' | - '\u015F' | - '\u0161' | - '\u0163' | - '\u0165' | - '\u0167' | - '\u0169' | - '\u016B' | - '\u016D' | - '\u016F' | - '\u0171' | - '\u0173' | - '\u0175' | - '\u0177' | - '\u017A' | - '\u017C' | - '\u017E'..'\u0180' | - '\u0183' | - '\u0185' | - '\u0188' | - '\u018C' | - '\u018D' | - '\u0192' | - '\u0195' | - '\u0199'..'\u019B' | - '\u019E' | - '\u01A1' | - '\u01A3' | - '\u01A5' | - '\u01A8' | - '\u01AA' | - '\u01AB' | - '\u01AD' | - '\u01B0' | - '\u01B4' | - '\u01B6' | - '\u01B9' | - '\u01BA' | - '\u01BD'..'\u01BF' | - '\u01C6' | - '\u01C9' | - '\u01CC' | - '\u01CE' | - '\u01D0' | - '\u01D2' | - '\u01D4' | - '\u01D6' | - '\u01D8' | - '\u01DA' | - '\u01DC' | - '\u01DD' | - '\u01DF' | - '\u01E1' | - '\u01E3' | - '\u01E5' | - '\u01E7' | - '\u01E9' | - '\u01EB' | - '\u01ED' | - '\u01EF' | - '\u01F0' | - '\u01F3' | - '\u01F5' | - '\u01F9' | - '\u01FB' | - '\u01FD' | - '\u01FF' | - '\u0201' | - '\u0203' | - '\u0205' | - '\u0207' | - '\u0209' | - '\u020B' | - '\u020D' | - '\u020F' | - '\u0211' | - '\u0213' | - '\u0215' | - '\u0217' | - '\u0219' | - '\u021B' | - '\u021D' | - '\u021F' | - '\u0221' | - '\u0223' | - '\u0225' | - '\u0227' | - '\u0229' | - '\u022B' | - '\u022D' | - '\u022F' | - '\u0231' | - '\u0233'..'\u0239' | - '\u023C' | - '\u023F' | - '\u0240' | - '\u0242' | - '\u0247' | - '\u0249' | - '\u024B' | - '\u024D' | - '\u024F'..'\u0293' | - '\u0295'..'\u02AF' | - '\u0371' | - '\u0373' | - '\u0377' | - '\u037B'..'\u037D' | - '\u0390' | - '\u03AC'..'\u03CE' | - '\u03D0' | - '\u03D1' | - '\u03D5'..'\u03D7' | - '\u03D9' | - '\u03DB' | - '\u03DD' | - '\u03DF' | - '\u03E1' | - '\u03E3' | - '\u03E5' | - '\u03E7' | - '\u03E9' | - '\u03EB' | - '\u03ED' | - '\u03EF'..'\u03F3' | - '\u03F5' | - '\u03F8' | - '\u03FB' | - '\u03FC' | - '\u0430'..'\u045F' | - '\u0461' | - '\u0463' | - '\u0465' | - '\u0467' | - '\u0469' | - '\u046B' | - '\u046D' | - '\u046F' | - '\u0471' | - '\u0473' | - '\u0475' | - '\u0477' | - '\u0479' | - '\u047B' | - '\u047D' | - '\u047F' | - '\u0481' | - '\u048B' | - '\u048D' | - '\u048F' | - '\u0491' | - '\u0493' | - '\u0495' | - '\u0497' | - '\u0499' | - '\u049B' | - '\u049D' | - '\u049F' | - '\u04A1' | - '\u04A3' | - '\u04A5' | - '\u04A7' | - '\u04A9' | - '\u04AB' | - '\u04AD' | - '\u04AF' | - '\u04B1' | - '\u04B3' | - '\u04B5' | - '\u04B7' | - '\u04B9' | - '\u04BB' | - '\u04BD' | - '\u04BF' | - '\u04C2' | - '\u04C4' | - '\u04C6' | - '\u04C8' | - '\u04CA' | - '\u04CC' | - '\u04CE' | - '\u04CF' | - '\u04D1' | - '\u04D3' | - '\u04D5' | - '\u04D7' | - '\u04D9' | - '\u04DB' | - '\u04DD' | - '\u04DF' | - '\u04E1' | - '\u04E3' | - '\u04E5' | - '\u04E7' | - '\u04E9' | - '\u04EB' | - '\u04ED' | - '\u04EF' | - '\u04F1' | - '\u04F3' | - '\u04F5' | - '\u04F7' | - '\u04F9' | - '\u04FB' | - '\u04FD' | - '\u04FF' | - '\u0501' | - '\u0503' | - '\u0505' | - '\u0507' | - '\u0509' | - '\u050B' | - '\u050D' | - '\u050F' | - '\u0511' | - '\u0513' | - '\u0515' | - '\u0517' | - '\u0519' | - '\u051B' | - '\u051D' | - '\u051F' | - '\u0521' | - '\u0523' | - '\u0525' | - '\u0527' | - '\u0561'..'\u0587' | - '\u1D00'..'\u1D2B' | - '\u1D6B'..'\u1D77' | - '\u1D79'..'\u1D9A' | - '\u1E01' | - '\u1E03' | - '\u1E05' | - '\u1E07' | - '\u1E09' | - '\u1E0B' | - '\u1E0D' | - '\u1E0F' | - '\u1E11' | - '\u1E13' | - '\u1E15' | - '\u1E17' | - '\u1E19' | - '\u1E1B' | - '\u1E1D' | - '\u1E1F' | - '\u1E21' | - '\u1E23' | - '\u1E25' | - '\u1E27' | - '\u1E29' | - '\u1E2B' | - '\u1E2D' | - '\u1E2F' | - '\u1E31' | - '\u1E33' | - '\u1E35' | - '\u1E37' | - '\u1E39' | - '\u1E3B' | - '\u1E3D' | - '\u1E3F' | - '\u1E41' | - '\u1E43' | - '\u1E45' | - '\u1E47' | - '\u1E49' | - '\u1E4B' | - '\u1E4D' | - '\u1E4F' | - '\u1E51' | - '\u1E53' | - '\u1E55' | - '\u1E57' | - '\u1E59' | - '\u1E5B' | - '\u1E5D' | - '\u1E5F' | - '\u1E61' | - '\u1E63' | - '\u1E65' | - '\u1E67' | - '\u1E69' | - '\u1E6B' | - '\u1E6D' | - '\u1E6F' | - '\u1E71' | - '\u1E73' | - '\u1E75' | - '\u1E77' | - '\u1E79' | - '\u1E7B' | - '\u1E7D' | - '\u1E7F' | - '\u1E81' | - '\u1E83' | - '\u1E85' | - '\u1E87' | - '\u1E89' | - '\u1E8B' | - '\u1E8D' | - '\u1E8F' | - '\u1E91' | - '\u1E93' | - '\u1E95'..'\u1E9D' | - '\u1E9F' | - '\u1EA1' | - '\u1EA3' | - '\u1EA5' | - '\u1EA7' | - '\u1EA9' | - '\u1EAB' | - '\u1EAD' | - '\u1EAF' | - '\u1EB1' | - '\u1EB3' | - '\u1EB5' | - '\u1EB7' | - '\u1EB9' | - '\u1EBB' | - '\u1EBD' | - '\u1EBF' | - '\u1EC1' | - '\u1EC3' | - '\u1EC5' | - '\u1EC7' | - '\u1EC9' | - '\u1ECB' | - '\u1ECD' | - '\u1ECF' | - '\u1ED1' | - '\u1ED3' | - '\u1ED5' | - '\u1ED7' | - '\u1ED9' | - '\u1EDB' | - '\u1EDD' | - '\u1EDF' | - '\u1EE1' | - '\u1EE3' | - '\u1EE5' | - '\u1EE7' | - '\u1EE9' | - '\u1EEB' | - '\u1EED' | - '\u1EEF' | - '\u1EF1' | - '\u1EF3' | - '\u1EF5' | - '\u1EF7' | - '\u1EF9' | - '\u1EFB' | - '\u1EFD' | - '\u1EFF'..'\u1F07' | - '\u1F10'..'\u1F15' | - '\u1F20'..'\u1F27' | - '\u1F30'..'\u1F37' | - '\u1F40'..'\u1F45' | - '\u1F50'..'\u1F57' | - '\u1F60'..'\u1F67' | - '\u1F70'..'\u1F7D' | - '\u1F80'..'\u1F87' | - '\u1F90'..'\u1F97' | - '\u1FA0'..'\u1FA7' | - '\u1FB0'..'\u1FB4' | - '\u1FB6' | - '\u1FB7' | - '\u1FBE' | - '\u1FC2'..'\u1FC4' | - '\u1FC6' | - '\u1FC7' | - '\u1FD0'..'\u1FD3' | - '\u1FD6' | - '\u1FD7' | - '\u1FE0'..'\u1FE7' | - '\u1FF2'..'\u1FF4' | - '\u1FF6' | - '\u1FF7' | - '\u210A' | - '\u210E' | - '\u210F' | - '\u2113' | - '\u212F' | - '\u2134' | - '\u2139' | - '\u213C' | - '\u213D' | - '\u2146'..'\u2149' | - '\u214E' | - '\u2184' | - '\u2C30'..'\u2C5E' | - '\u2C61' | - '\u2C65' | - '\u2C66' | - '\u2C68' | - '\u2C6A' | - '\u2C6C' | - '\u2C71' | - '\u2C73' | - '\u2C74' | - '\u2C76'..'\u2C7B' | - '\u2C81' | - '\u2C83' | - '\u2C85' | - '\u2C87' | - '\u2C89' | - '\u2C8B' | - '\u2C8D' | - '\u2C8F' | - '\u2C91' | - '\u2C93' | - '\u2C95' | - '\u2C97' | - '\u2C99' | - '\u2C9B' | - '\u2C9D' | - '\u2C9F' | - '\u2CA1' | - '\u2CA3' | - '\u2CA5' | - '\u2CA7' | - '\u2CA9' | - '\u2CAB' | - '\u2CAD' | - '\u2CAF' | - '\u2CB1' | - '\u2CB3' | - '\u2CB5' | - '\u2CB7' | - '\u2CB9' | - '\u2CBB' | - '\u2CBD' | - '\u2CBF' | - '\u2CC1' | - '\u2CC3' | - '\u2CC5' | - '\u2CC7' | - '\u2CC9' | - '\u2CCB' | - '\u2CCD' | - '\u2CCF' | - '\u2CD1' | - '\u2CD3' | - '\u2CD5' | - '\u2CD7' | - '\u2CD9' | - '\u2CDB' | - '\u2CDD' | - '\u2CDF' | - '\u2CE1' | - '\u2CE3' | - '\u2CE4' | - '\u2CEC' | - '\u2CEE' | - '\u2CF3' | - '\u2D00'..'\u2D25' | - '\u2D27' | - '\u2D2D' | - '\uA641' | - '\uA643' | - '\uA645' | - '\uA647' | - '\uA649' | - '\uA64B' | - '\uA64D' | - '\uA64F' | - '\uA651' | - '\uA653' | - '\uA655' | - '\uA657' | - '\uA659' | - '\uA65B' | - '\uA65D' | - '\uA65F' | - '\uA661' | - '\uA663' | - '\uA665' | - '\uA667' | - '\uA669' | - '\uA66B' | - '\uA66D' | - '\uA681' | - '\uA683' | - '\uA685' | - '\uA687' | - '\uA689' | - '\uA68B' | - '\uA68D' | - '\uA68F' | - '\uA691' | - '\uA693' | - '\uA695' | - '\uA697' | - '\uA723' | - '\uA725' | - '\uA727' | - '\uA729' | - '\uA72B' | - '\uA72D' | - '\uA72F'..'\uA731' | - '\uA733' | - '\uA735' | - '\uA737' | - '\uA739' | - '\uA73B' | - '\uA73D' | - '\uA73F' | - '\uA741' | - '\uA743' | - '\uA745' | - '\uA747' | - '\uA749' | - '\uA74B' | - '\uA74D' | - '\uA74F' | - '\uA751' | - '\uA753' | - '\uA755' | - '\uA757' | - '\uA759' | - '\uA75B' | - '\uA75D' | - '\uA75F' | - '\uA761' | - '\uA763' | - '\uA765' | - '\uA767' | - '\uA769' | - '\uA76B' | - '\uA76D' | - '\uA76F' | - '\uA771'..'\uA778' | - '\uA77A' | - '\uA77C' | - '\uA77F' | - '\uA781' | - '\uA783' | - '\uA785' | - '\uA787' | - '\uA78C' | - '\uA78E' | - '\uA791' | - '\uA793' | - '\uA7A1' | - '\uA7A3' | - '\uA7A5' | - '\uA7A7' | - '\uA7A9' | - '\uA7FA' | - '\uFB00'..'\uFB06' | - '\uFB13'..'\uFB17' | - '\uFF41'..'\uFF5A'; + '\u0061' ..'\u007A' + | '\u00B5' + | '\u00DF' ..'\u00F6' + | '\u00F8' ..'\u00FF' + | '\u0101' + | '\u0103' + | '\u0105' + | '\u0107' + | '\u0109' + | '\u010B' + | '\u010D' + | '\u010F' + | '\u0111' + | '\u0113' + | '\u0115' + | '\u0117' + | '\u0119' + | '\u011B' + | '\u011D' + | '\u011F' + | '\u0121' + | '\u0123' + | '\u0125' + | '\u0127' + | '\u0129' + | '\u012B' + | '\u012D' + | '\u012F' + | '\u0131' + | '\u0133' + | '\u0135' + | '\u0137' + | '\u0138' + | '\u013A' + | '\u013C' + | '\u013E' + | '\u0140' + | '\u0142' + | '\u0144' + | '\u0146' + | '\u0148' + | '\u0149' + | '\u014B' + | '\u014D' + | '\u014F' + | '\u0151' + | '\u0153' + | '\u0155' + | '\u0157' + | '\u0159' + | '\u015B' + | '\u015D' + | '\u015F' + | '\u0161' + | '\u0163' + | '\u0165' + | '\u0167' + | '\u0169' + | '\u016B' + | '\u016D' + | '\u016F' + | '\u0171' + | '\u0173' + | '\u0175' + | '\u0177' + | '\u017A' + | '\u017C' + | '\u017E' ..'\u0180' + | '\u0183' + | '\u0185' + | '\u0188' + | '\u018C' + | '\u018D' + | '\u0192' + | '\u0195' + | '\u0199' ..'\u019B' + | '\u019E' + | '\u01A1' + | '\u01A3' + | '\u01A5' + | '\u01A8' + | '\u01AA' + | '\u01AB' + | '\u01AD' + | '\u01B0' + | '\u01B4' + | '\u01B6' + | '\u01B9' + | '\u01BA' + | '\u01BD' ..'\u01BF' + | '\u01C6' + | '\u01C9' + | '\u01CC' + | '\u01CE' + | '\u01D0' + | '\u01D2' + | '\u01D4' + | '\u01D6' + | '\u01D8' + | '\u01DA' + | '\u01DC' + | '\u01DD' + | '\u01DF' + | '\u01E1' + | '\u01E3' + | '\u01E5' + | '\u01E7' + | '\u01E9' + | '\u01EB' + | '\u01ED' + | '\u01EF' + | '\u01F0' + | '\u01F3' + | '\u01F5' + | '\u01F9' + | '\u01FB' + | '\u01FD' + | '\u01FF' + | '\u0201' + | '\u0203' + | '\u0205' + | '\u0207' + | '\u0209' + | '\u020B' + | '\u020D' + | '\u020F' + | '\u0211' + | '\u0213' + | '\u0215' + | '\u0217' + | '\u0219' + | '\u021B' + | '\u021D' + | '\u021F' + | '\u0221' + | '\u0223' + | '\u0225' + | '\u0227' + | '\u0229' + | '\u022B' + | '\u022D' + | '\u022F' + | '\u0231' + | '\u0233' ..'\u0239' + | '\u023C' + | '\u023F' + | '\u0240' + | '\u0242' + | '\u0247' + | '\u0249' + | '\u024B' + | '\u024D' + | '\u024F' ..'\u0293' + | '\u0295' ..'\u02AF' + | '\u0371' + | '\u0373' + | '\u0377' + | '\u037B' ..'\u037D' + | '\u0390' + | '\u03AC' ..'\u03CE' + | '\u03D0' + | '\u03D1' + | '\u03D5' ..'\u03D7' + | '\u03D9' + | '\u03DB' + | '\u03DD' + | '\u03DF' + | '\u03E1' + | '\u03E3' + | '\u03E5' + | '\u03E7' + | '\u03E9' + | '\u03EB' + | '\u03ED' + | '\u03EF' ..'\u03F3' + | '\u03F5' + | '\u03F8' + | '\u03FB' + | '\u03FC' + | '\u0430' ..'\u045F' + | '\u0461' + | '\u0463' + | '\u0465' + | '\u0467' + | '\u0469' + | '\u046B' + | '\u046D' + | '\u046F' + | '\u0471' + | '\u0473' + | '\u0475' + | '\u0477' + | '\u0479' + | '\u047B' + | '\u047D' + | '\u047F' + | '\u0481' + | '\u048B' + | '\u048D' + | '\u048F' + | '\u0491' + | '\u0493' + | '\u0495' + | '\u0497' + | '\u0499' + | '\u049B' + | '\u049D' + | '\u049F' + | '\u04A1' + | '\u04A3' + | '\u04A5' + | '\u04A7' + | '\u04A9' + | '\u04AB' + | '\u04AD' + | '\u04AF' + | '\u04B1' + | '\u04B3' + | '\u04B5' + | '\u04B7' + | '\u04B9' + | '\u04BB' + | '\u04BD' + | '\u04BF' + | '\u04C2' + | '\u04C4' + | '\u04C6' + | '\u04C8' + | '\u04CA' + | '\u04CC' + | '\u04CE' + | '\u04CF' + | '\u04D1' + | '\u04D3' + | '\u04D5' + | '\u04D7' + | '\u04D9' + | '\u04DB' + | '\u04DD' + | '\u04DF' + | '\u04E1' + | '\u04E3' + | '\u04E5' + | '\u04E7' + | '\u04E9' + | '\u04EB' + | '\u04ED' + | '\u04EF' + | '\u04F1' + | '\u04F3' + | '\u04F5' + | '\u04F7' + | '\u04F9' + | '\u04FB' + | '\u04FD' + | '\u04FF' + | '\u0501' + | '\u0503' + | '\u0505' + | '\u0507' + | '\u0509' + | '\u050B' + | '\u050D' + | '\u050F' + | '\u0511' + | '\u0513' + | '\u0515' + | '\u0517' + | '\u0519' + | '\u051B' + | '\u051D' + | '\u051F' + | '\u0521' + | '\u0523' + | '\u0525' + | '\u0527' + | '\u0561' ..'\u0587' + | '\u1D00' ..'\u1D2B' + | '\u1D6B' ..'\u1D77' + | '\u1D79' ..'\u1D9A' + | '\u1E01' + | '\u1E03' + | '\u1E05' + | '\u1E07' + | '\u1E09' + | '\u1E0B' + | '\u1E0D' + | '\u1E0F' + | '\u1E11' + | '\u1E13' + | '\u1E15' + | '\u1E17' + | '\u1E19' + | '\u1E1B' + | '\u1E1D' + | '\u1E1F' + | '\u1E21' + | '\u1E23' + | '\u1E25' + | '\u1E27' + | '\u1E29' + | '\u1E2B' + | '\u1E2D' + | '\u1E2F' + | '\u1E31' + | '\u1E33' + | '\u1E35' + | '\u1E37' + | '\u1E39' + | '\u1E3B' + | '\u1E3D' + | '\u1E3F' + | '\u1E41' + | '\u1E43' + | '\u1E45' + | '\u1E47' + | '\u1E49' + | '\u1E4B' + | '\u1E4D' + | '\u1E4F' + | '\u1E51' + | '\u1E53' + | '\u1E55' + | '\u1E57' + | '\u1E59' + | '\u1E5B' + | '\u1E5D' + | '\u1E5F' + | '\u1E61' + | '\u1E63' + | '\u1E65' + | '\u1E67' + | '\u1E69' + | '\u1E6B' + | '\u1E6D' + | '\u1E6F' + | '\u1E71' + | '\u1E73' + | '\u1E75' + | '\u1E77' + | '\u1E79' + | '\u1E7B' + | '\u1E7D' + | '\u1E7F' + | '\u1E81' + | '\u1E83' + | '\u1E85' + | '\u1E87' + | '\u1E89' + | '\u1E8B' + | '\u1E8D' + | '\u1E8F' + | '\u1E91' + | '\u1E93' + | '\u1E95' ..'\u1E9D' + | '\u1E9F' + | '\u1EA1' + | '\u1EA3' + | '\u1EA5' + | '\u1EA7' + | '\u1EA9' + | '\u1EAB' + | '\u1EAD' + | '\u1EAF' + | '\u1EB1' + | '\u1EB3' + | '\u1EB5' + | '\u1EB7' + | '\u1EB9' + | '\u1EBB' + | '\u1EBD' + | '\u1EBF' + | '\u1EC1' + | '\u1EC3' + | '\u1EC5' + | '\u1EC7' + | '\u1EC9' + | '\u1ECB' + | '\u1ECD' + | '\u1ECF' + | '\u1ED1' + | '\u1ED3' + | '\u1ED5' + | '\u1ED7' + | '\u1ED9' + | '\u1EDB' + | '\u1EDD' + | '\u1EDF' + | '\u1EE1' + | '\u1EE3' + | '\u1EE5' + | '\u1EE7' + | '\u1EE9' + | '\u1EEB' + | '\u1EED' + | '\u1EEF' + | '\u1EF1' + | '\u1EF3' + | '\u1EF5' + | '\u1EF7' + | '\u1EF9' + | '\u1EFB' + | '\u1EFD' + | '\u1EFF' ..'\u1F07' + | '\u1F10' ..'\u1F15' + | '\u1F20' ..'\u1F27' + | '\u1F30' ..'\u1F37' + | '\u1F40' ..'\u1F45' + | '\u1F50' ..'\u1F57' + | '\u1F60' ..'\u1F67' + | '\u1F70' ..'\u1F7D' + | '\u1F80' ..'\u1F87' + | '\u1F90' ..'\u1F97' + | '\u1FA0' ..'\u1FA7' + | '\u1FB0' ..'\u1FB4' + | '\u1FB6' + | '\u1FB7' + | '\u1FBE' + | '\u1FC2' ..'\u1FC4' + | '\u1FC6' + | '\u1FC7' + | '\u1FD0' ..'\u1FD3' + | '\u1FD6' + | '\u1FD7' + | '\u1FE0' ..'\u1FE7' + | '\u1FF2' ..'\u1FF4' + | '\u1FF6' + | '\u1FF7' + | '\u210A' + | '\u210E' + | '\u210F' + | '\u2113' + | '\u212F' + | '\u2134' + | '\u2139' + | '\u213C' + | '\u213D' + | '\u2146' ..'\u2149' + | '\u214E' + | '\u2184' + | '\u2C30' ..'\u2C5E' + | '\u2C61' + | '\u2C65' + | '\u2C66' + | '\u2C68' + | '\u2C6A' + | '\u2C6C' + | '\u2C71' + | '\u2C73' + | '\u2C74' + | '\u2C76' ..'\u2C7B' + | '\u2C81' + | '\u2C83' + | '\u2C85' + | '\u2C87' + | '\u2C89' + | '\u2C8B' + | '\u2C8D' + | '\u2C8F' + | '\u2C91' + | '\u2C93' + | '\u2C95' + | '\u2C97' + | '\u2C99' + | '\u2C9B' + | '\u2C9D' + | '\u2C9F' + | '\u2CA1' + | '\u2CA3' + | '\u2CA5' + | '\u2CA7' + | '\u2CA9' + | '\u2CAB' + | '\u2CAD' + | '\u2CAF' + | '\u2CB1' + | '\u2CB3' + | '\u2CB5' + | '\u2CB7' + | '\u2CB9' + | '\u2CBB' + | '\u2CBD' + | '\u2CBF' + | '\u2CC1' + | '\u2CC3' + | '\u2CC5' + | '\u2CC7' + | '\u2CC9' + | '\u2CCB' + | '\u2CCD' + | '\u2CCF' + | '\u2CD1' + | '\u2CD3' + | '\u2CD5' + | '\u2CD7' + | '\u2CD9' + | '\u2CDB' + | '\u2CDD' + | '\u2CDF' + | '\u2CE1' + | '\u2CE3' + | '\u2CE4' + | '\u2CEC' + | '\u2CEE' + | '\u2CF3' + | '\u2D00' ..'\u2D25' + | '\u2D27' + | '\u2D2D' + | '\uA641' + | '\uA643' + | '\uA645' + | '\uA647' + | '\uA649' + | '\uA64B' + | '\uA64D' + | '\uA64F' + | '\uA651' + | '\uA653' + | '\uA655' + | '\uA657' + | '\uA659' + | '\uA65B' + | '\uA65D' + | '\uA65F' + | '\uA661' + | '\uA663' + | '\uA665' + | '\uA667' + | '\uA669' + | '\uA66B' + | '\uA66D' + | '\uA681' + | '\uA683' + | '\uA685' + | '\uA687' + | '\uA689' + | '\uA68B' + | '\uA68D' + | '\uA68F' + | '\uA691' + | '\uA693' + | '\uA695' + | '\uA697' + | '\uA723' + | '\uA725' + | '\uA727' + | '\uA729' + | '\uA72B' + | '\uA72D' + | '\uA72F' ..'\uA731' + | '\uA733' + | '\uA735' + | '\uA737' + | '\uA739' + | '\uA73B' + | '\uA73D' + | '\uA73F' + | '\uA741' + | '\uA743' + | '\uA745' + | '\uA747' + | '\uA749' + | '\uA74B' + | '\uA74D' + | '\uA74F' + | '\uA751' + | '\uA753' + | '\uA755' + | '\uA757' + | '\uA759' + | '\uA75B' + | '\uA75D' + | '\uA75F' + | '\uA761' + | '\uA763' + | '\uA765' + | '\uA767' + | '\uA769' + | '\uA76B' + | '\uA76D' + | '\uA76F' + | '\uA771' ..'\uA778' + | '\uA77A' + | '\uA77C' + | '\uA77F' + | '\uA781' + | '\uA783' + | '\uA785' + | '\uA787' + | '\uA78C' + | '\uA78E' + | '\uA791' + | '\uA793' + | '\uA7A1' + | '\uA7A3' + | '\uA7A5' + | '\uA7A7' + | '\uA7A9' + | '\uA7FA' + | '\uFB00' ..'\uFB06' + | '\uFB13' ..'\uFB17' + | '\uFF41' ..'\uFF5A' +; UNICODE_CLASS_LM: - '\u02B0'..'\u02C1' | - '\u02C6'..'\u02D1' | - '\u02E0'..'\u02E4' | - '\u02EC' | - '\u02EE' | - '\u0374' | - '\u037A' | - '\u0559' | - '\u0640' | - '\u06E5' | - '\u06E6' | - '\u07F4' | - '\u07F5' | - '\u07FA' | - '\u081A' | - '\u0824' | - '\u0828' | - '\u0971' | - '\u0E46' | - '\u0EC6' | - '\u10FC' | - '\u17D7' | - '\u1843' | - '\u1AA7' | - '\u1C78'..'\u1C7D' | - '\u1D2C'..'\u1D6A' | - '\u1D78' | - '\u1D9B'..'\u1DBF' | - '\u2071' | - '\u207F' | - '\u2090'..'\u209C' | - '\u2C7C' | - '\u2C7D' | - '\u2D6F' | - '\u2E2F' | - '\u3005' | - '\u3031'..'\u3035' | - '\u303B' | - '\u309D' | - '\u309E' | - '\u30FC'..'\u30FE' | - '\uA015' | - '\uA4F8'..'\uA4FD' | - '\uA60C' | - '\uA67F' | - '\uA717'..'\uA71F' | - '\uA770' | - '\uA788' | - '\uA7F8' | - '\uA7F9' | - '\uA9CF' | - '\uAA70' | - '\uAADD' | - '\uAAF3' | - '\uAAF4' | - '\uFF70' | - '\uFF9E' | - '\uFF9F'; + '\u02B0' ..'\u02C1' + | '\u02C6' ..'\u02D1' + | '\u02E0' ..'\u02E4' + | '\u02EC' + | '\u02EE' + | '\u0374' + | '\u037A' + | '\u0559' + | '\u0640' + | '\u06E5' + | '\u06E6' + | '\u07F4' + | '\u07F5' + | '\u07FA' + | '\u081A' + | '\u0824' + | '\u0828' + | '\u0971' + | '\u0E46' + | '\u0EC6' + | '\u10FC' + | '\u17D7' + | '\u1843' + | '\u1AA7' + | '\u1C78' ..'\u1C7D' + | '\u1D2C' ..'\u1D6A' + | '\u1D78' + | '\u1D9B' ..'\u1DBF' + | '\u2071' + | '\u207F' + | '\u2090' ..'\u209C' + | '\u2C7C' + | '\u2C7D' + | '\u2D6F' + | '\u2E2F' + | '\u3005' + | '\u3031' ..'\u3035' + | '\u303B' + | '\u309D' + | '\u309E' + | '\u30FC' ..'\u30FE' + | '\uA015' + | '\uA4F8' ..'\uA4FD' + | '\uA60C' + | '\uA67F' + | '\uA717' ..'\uA71F' + | '\uA770' + | '\uA788' + | '\uA7F8' + | '\uA7F9' + | '\uA9CF' + | '\uAA70' + | '\uAADD' + | '\uAAF3' + | '\uAAF4' + | '\uFF70' + | '\uFF9E' + | '\uFF9F' +; UNICODE_CLASS_LO: - '\u00AA' | - '\u00BA' | - '\u01BB' | - '\u01C0'..'\u01C3' | - '\u0294' | - '\u05D0'..'\u05EA' | - '\u05F0'..'\u05F2' | - '\u0620'..'\u063F' | - '\u0641'..'\u064A' | - '\u066E' | - '\u066F' | - '\u0671'..'\u06D3' | - '\u06D5' | - '\u06EE' | - '\u06EF' | - '\u06FA'..'\u06FC' | - '\u06FF' | - '\u0710' | - '\u0712'..'\u072F' | - '\u074D'..'\u07A5' | - '\u07B1' | - '\u07CA'..'\u07EA' | - '\u0800'..'\u0815' | - '\u0840'..'\u0858' | - '\u08A0' | - '\u08A2'..'\u08AC' | - '\u0904'..'\u0939' | - '\u093D' | - '\u0950' | - '\u0958'..'\u0961' | - '\u0972'..'\u0977' | - '\u0979'..'\u097F' | - '\u0985'..'\u098C' | - '\u098F' | - '\u0990' | - '\u0993'..'\u09A8' | - '\u09AA'..'\u09B0' | - '\u09B2' | - '\u09B6'..'\u09B9' | - '\u09BD' | - '\u09CE' | - '\u09DC' | - '\u09DD' | - '\u09DF'..'\u09E1' | - '\u09F0' | - '\u09F1' | - '\u0A05'..'\u0A0A' | - '\u0A0F' | - '\u0A10' | - '\u0A13'..'\u0A28' | - '\u0A2A'..'\u0A30' | - '\u0A32' | - '\u0A33' | - '\u0A35' | - '\u0A36' | - '\u0A38' | - '\u0A39' | - '\u0A59'..'\u0A5C' | - '\u0A5E' | - '\u0A72'..'\u0A74' | - '\u0A85'..'\u0A8D' | - '\u0A8F'..'\u0A91' | - '\u0A93'..'\u0AA8' | - '\u0AAA'..'\u0AB0' | - '\u0AB2' | - '\u0AB3' | - '\u0AB5'..'\u0AB9' | - '\u0ABD' | - '\u0AD0' | - '\u0AE0' | - '\u0AE1' | - '\u0B05'..'\u0B0C' | - '\u0B0F' | - '\u0B10' | - '\u0B13'..'\u0B28' | - '\u0B2A'..'\u0B30' | - '\u0B32' | - '\u0B33' | - '\u0B35'..'\u0B39' | - '\u0B3D' | - '\u0B5C' | - '\u0B5D' | - '\u0B5F'..'\u0B61' | - '\u0B71' | - '\u0B83' | - '\u0B85'..'\u0B8A' | - '\u0B8E'..'\u0B90' | - '\u0B92'..'\u0B95' | - '\u0B99' | - '\u0B9A' | - '\u0B9C' | - '\u0B9E' | - '\u0B9F' | - '\u0BA3' | - '\u0BA4' | - '\u0BA8'..'\u0BAA' | - '\u0BAE'..'\u0BB9' | - '\u0BD0' | - '\u0C05'..'\u0C0C' | - '\u0C0E'..'\u0C10' | - '\u0C12'..'\u0C28' | - '\u0C2A'..'\u0C33' | - '\u0C35'..'\u0C39' | - '\u0C3D' | - '\u0C58' | - '\u0C59' | - '\u0C60' | - '\u0C61' | - '\u0C85'..'\u0C8C' | - '\u0C8E'..'\u0C90' | - '\u0C92'..'\u0CA8' | - '\u0CAA'..'\u0CB3' | - '\u0CB5'..'\u0CB9' | - '\u0CBD' | - '\u0CDE' | - '\u0CE0' | - '\u0CE1' | - '\u0CF1' | - '\u0CF2' | - '\u0D05'..'\u0D0C' | - '\u0D0E'..'\u0D10' | - '\u0D12'..'\u0D3A' | - '\u0D3D' | - '\u0D4E' | - '\u0D60' | - '\u0D61' | - '\u0D7A'..'\u0D7F' | - '\u0D85'..'\u0D96' | - '\u0D9A'..'\u0DB1' | - '\u0DB3'..'\u0DBB' | - '\u0DBD' | - '\u0DC0'..'\u0DC6' | - '\u0E01'..'\u0E30' | - '\u0E32' | - '\u0E33' | - '\u0E40'..'\u0E45' | - '\u0E81' | - '\u0E82' | - '\u0E84' | - '\u0E87' | - '\u0E88' | - '\u0E8A' | - '\u0E8D' | - '\u0E94'..'\u0E97' | - '\u0E99'..'\u0E9F' | - '\u0EA1'..'\u0EA3' | - '\u0EA5' | - '\u0EA7' | - '\u0EAA' | - '\u0EAB' | - '\u0EAD'..'\u0EB0' | - '\u0EB2' | - '\u0EB3' | - '\u0EBD' | - '\u0EC0'..'\u0EC4' | - '\u0EDC'..'\u0EDF' | - '\u0F00' | - '\u0F40'..'\u0F47' | - '\u0F49'..'\u0F6C' | - '\u0F88'..'\u0F8C' | - '\u1000'..'\u102A' | - '\u103F' | - '\u1050'..'\u1055' | - '\u105A'..'\u105D' | - '\u1061' | - '\u1065' | - '\u1066' | - '\u106E'..'\u1070' | - '\u1075'..'\u1081' | - '\u108E' | - '\u10D0'..'\u10FA' | - '\u10FD'..'\u1248' | - '\u124A'..'\u124D' | - '\u1250'..'\u1256' | - '\u1258' | - '\u125A'..'\u125D' | - '\u1260'..'\u1288' | - '\u128A'..'\u128D' | - '\u1290'..'\u12B0' | - '\u12B2'..'\u12B5' | - '\u12B8'..'\u12BE' | - '\u12C0' | - '\u12C2'..'\u12C5' | - '\u12C8'..'\u12D6' | - '\u12D8'..'\u1310' | - '\u1312'..'\u1315' | - '\u1318'..'\u135A' | - '\u1380'..'\u138F' | - '\u13A0'..'\u13F4' | - '\u1401'..'\u166C' | - '\u166F'..'\u167F' | - '\u1681'..'\u169A' | - '\u16A0'..'\u16EA' | - '\u1700'..'\u170C' | - '\u170E'..'\u1711' | - '\u1720'..'\u1731' | - '\u1740'..'\u1751' | - '\u1760'..'\u176C' | - '\u176E'..'\u1770' | - '\u1780'..'\u17B3' | - '\u17DC' | - '\u1820'..'\u1842' | - '\u1844'..'\u1877' | - '\u1880'..'\u18A8' | - '\u18AA' | - '\u18B0'..'\u18F5' | - '\u1900'..'\u191C' | - '\u1950'..'\u196D' | - '\u1970'..'\u1974' | - '\u1980'..'\u19AB' | - '\u19C1'..'\u19C7' | - '\u1A00'..'\u1A16' | - '\u1A20'..'\u1A54' | - '\u1B05'..'\u1B33' | - '\u1B45'..'\u1B4B' | - '\u1B83'..'\u1BA0' | - '\u1BAE' | - '\u1BAF' | - '\u1BBA'..'\u1BE5' | - '\u1C00'..'\u1C23' | - '\u1C4D'..'\u1C4F' | - '\u1C5A'..'\u1C77' | - '\u1CE9'..'\u1CEC' | - '\u1CEE'..'\u1CF1' | - '\u1CF5' | - '\u1CF6' | - '\u2135'..'\u2138' | - '\u2D30'..'\u2D67' | - '\u2D80'..'\u2D96' | - '\u2DA0'..'\u2DA6' | - '\u2DA8'..'\u2DAE' | - '\u2DB0'..'\u2DB6' | - '\u2DB8'..'\u2DBE' | - '\u2DC0'..'\u2DC6' | - '\u2DC8'..'\u2DCE' | - '\u2DD0'..'\u2DD6' | - '\u2DD8'..'\u2DDE' | - '\u3006' | - '\u303C' | - '\u3041'..'\u3096' | - '\u309F' | - '\u30A1'..'\u30FA' | - '\u30FF' | - '\u3105'..'\u312D' | - '\u3131'..'\u318E' | - '\u31A0'..'\u31BA' | - '\u31F0'..'\u31FF' | - '\u3400'..'\u4DB5' | - '\u4E00'..'\u9FCC' | - '\uA000'..'\uA014' | - '\uA016'..'\uA48C' | - '\uA4D0'..'\uA4F7' | - '\uA500'..'\uA60B' | - '\uA610'..'\uA61F' | - '\uA62A' | - '\uA62B' | - '\uA66E' | - '\uA6A0'..'\uA6E5' | - '\uA7FB'..'\uA801' | - '\uA803'..'\uA805' | - '\uA807'..'\uA80A' | - '\uA80C'..'\uA822' | - '\uA840'..'\uA873' | - '\uA882'..'\uA8B3' | - '\uA8F2'..'\uA8F7' | - '\uA8FB' | - '\uA90A'..'\uA925' | - '\uA930'..'\uA946' | - '\uA960'..'\uA97C' | - '\uA984'..'\uA9B2' | - '\uAA00'..'\uAA28' | - '\uAA40'..'\uAA42' | - '\uAA44'..'\uAA4B' | - '\uAA60'..'\uAA6F' | - '\uAA71'..'\uAA76' | - '\uAA7A' | - '\uAA80'..'\uAAAF' | - '\uAAB1' | - '\uAAB5' | - '\uAAB6' | - '\uAAB9'..'\uAABD' | - '\uAAC0' | - '\uAAC2' | - '\uAADB' | - '\uAADC' | - '\uAAE0'..'\uAAEA' | - '\uAAF2' | - '\uAB01'..'\uAB06' | - '\uAB09'..'\uAB0E' | - '\uAB11'..'\uAB16' | - '\uAB20'..'\uAB26' | - '\uAB28'..'\uAB2E' | - '\uABC0'..'\uABE2' | - '\uAC00' | - '\uD7A3' | - '\uD7B0'..'\uD7C6' | - '\uD7CB'..'\uD7FB' | - '\uF900'..'\uFA6D' | - '\uFA70'..'\uFAD9' | - '\uFB1D' | - '\uFB1F'..'\uFB28' | - '\uFB2A'..'\uFB36' | - '\uFB38'..'\uFB3C' | - '\uFB3E' | - '\uFB40' | - '\uFB41' | - '\uFB43' | - '\uFB44' | - '\uFB46'..'\uFBB1' | - '\uFBD3'..'\uFD3D' | - '\uFD50'..'\uFD8F' | - '\uFD92'..'\uFDC7' | - '\uFDF0'..'\uFDFB' | - '\uFE70'..'\uFE74' | - '\uFE76'..'\uFEFC' | - '\uFF66'..'\uFF6F' | - '\uFF71'..'\uFF9D' | - '\uFFA0'..'\uFFBE' | - '\uFFC2'..'\uFFC7' | - '\uFFCA'..'\uFFCF' | - '\uFFD2'..'\uFFD7' | - '\uFFDA'..'\uFFDC'; + '\u00AA' + | '\u00BA' + | '\u01BB' + | '\u01C0' ..'\u01C3' + | '\u0294' + | '\u05D0' ..'\u05EA' + | '\u05F0' ..'\u05F2' + | '\u0620' ..'\u063F' + | '\u0641' ..'\u064A' + | '\u066E' + | '\u066F' + | '\u0671' ..'\u06D3' + | '\u06D5' + | '\u06EE' + | '\u06EF' + | '\u06FA' ..'\u06FC' + | '\u06FF' + | '\u0710' + | '\u0712' ..'\u072F' + | '\u074D' ..'\u07A5' + | '\u07B1' + | '\u07CA' ..'\u07EA' + | '\u0800' ..'\u0815' + | '\u0840' ..'\u0858' + | '\u08A0' + | '\u08A2' ..'\u08AC' + | '\u0904' ..'\u0939' + | '\u093D' + | '\u0950' + | '\u0958' ..'\u0961' + | '\u0972' ..'\u0977' + | '\u0979' ..'\u097F' + | '\u0985' ..'\u098C' + | '\u098F' + | '\u0990' + | '\u0993' ..'\u09A8' + | '\u09AA' ..'\u09B0' + | '\u09B2' + | '\u09B6' ..'\u09B9' + | '\u09BD' + | '\u09CE' + | '\u09DC' + | '\u09DD' + | '\u09DF' ..'\u09E1' + | '\u09F0' + | '\u09F1' + | '\u0A05' ..'\u0A0A' + | '\u0A0F' + | '\u0A10' + | '\u0A13' ..'\u0A28' + | '\u0A2A' ..'\u0A30' + | '\u0A32' + | '\u0A33' + | '\u0A35' + | '\u0A36' + | '\u0A38' + | '\u0A39' + | '\u0A59' ..'\u0A5C' + | '\u0A5E' + | '\u0A72' ..'\u0A74' + | '\u0A85' ..'\u0A8D' + | '\u0A8F' ..'\u0A91' + | '\u0A93' ..'\u0AA8' + | '\u0AAA' ..'\u0AB0' + | '\u0AB2' + | '\u0AB3' + | '\u0AB5' ..'\u0AB9' + | '\u0ABD' + | '\u0AD0' + | '\u0AE0' + | '\u0AE1' + | '\u0B05' ..'\u0B0C' + | '\u0B0F' + | '\u0B10' + | '\u0B13' ..'\u0B28' + | '\u0B2A' ..'\u0B30' + | '\u0B32' + | '\u0B33' + | '\u0B35' ..'\u0B39' + | '\u0B3D' + | '\u0B5C' + | '\u0B5D' + | '\u0B5F' ..'\u0B61' + | '\u0B71' + | '\u0B83' + | '\u0B85' ..'\u0B8A' + | '\u0B8E' ..'\u0B90' + | '\u0B92' ..'\u0B95' + | '\u0B99' + | '\u0B9A' + | '\u0B9C' + | '\u0B9E' + | '\u0B9F' + | '\u0BA3' + | '\u0BA4' + | '\u0BA8' ..'\u0BAA' + | '\u0BAE' ..'\u0BB9' + | '\u0BD0' + | '\u0C05' ..'\u0C0C' + | '\u0C0E' ..'\u0C10' + | '\u0C12' ..'\u0C28' + | '\u0C2A' ..'\u0C33' + | '\u0C35' ..'\u0C39' + | '\u0C3D' + | '\u0C58' + | '\u0C59' + | '\u0C60' + | '\u0C61' + | '\u0C85' ..'\u0C8C' + | '\u0C8E' ..'\u0C90' + | '\u0C92' ..'\u0CA8' + | '\u0CAA' ..'\u0CB3' + | '\u0CB5' ..'\u0CB9' + | '\u0CBD' + | '\u0CDE' + | '\u0CE0' + | '\u0CE1' + | '\u0CF1' + | '\u0CF2' + | '\u0D05' ..'\u0D0C' + | '\u0D0E' ..'\u0D10' + | '\u0D12' ..'\u0D3A' + | '\u0D3D' + | '\u0D4E' + | '\u0D60' + | '\u0D61' + | '\u0D7A' ..'\u0D7F' + | '\u0D85' ..'\u0D96' + | '\u0D9A' ..'\u0DB1' + | '\u0DB3' ..'\u0DBB' + | '\u0DBD' + | '\u0DC0' ..'\u0DC6' + | '\u0E01' ..'\u0E30' + | '\u0E32' + | '\u0E33' + | '\u0E40' ..'\u0E45' + | '\u0E81' + | '\u0E82' + | '\u0E84' + | '\u0E87' + | '\u0E88' + | '\u0E8A' + | '\u0E8D' + | '\u0E94' ..'\u0E97' + | '\u0E99' ..'\u0E9F' + | '\u0EA1' ..'\u0EA3' + | '\u0EA5' + | '\u0EA7' + | '\u0EAA' + | '\u0EAB' + | '\u0EAD' ..'\u0EB0' + | '\u0EB2' + | '\u0EB3' + | '\u0EBD' + | '\u0EC0' ..'\u0EC4' + | '\u0EDC' ..'\u0EDF' + | '\u0F00' + | '\u0F40' ..'\u0F47' + | '\u0F49' ..'\u0F6C' + | '\u0F88' ..'\u0F8C' + | '\u1000' ..'\u102A' + | '\u103F' + | '\u1050' ..'\u1055' + | '\u105A' ..'\u105D' + | '\u1061' + | '\u1065' + | '\u1066' + | '\u106E' ..'\u1070' + | '\u1075' ..'\u1081' + | '\u108E' + | '\u10D0' ..'\u10FA' + | '\u10FD' ..'\u1248' + | '\u124A' ..'\u124D' + | '\u1250' ..'\u1256' + | '\u1258' + | '\u125A' ..'\u125D' + | '\u1260' ..'\u1288' + | '\u128A' ..'\u128D' + | '\u1290' ..'\u12B0' + | '\u12B2' ..'\u12B5' + | '\u12B8' ..'\u12BE' + | '\u12C0' + | '\u12C2' ..'\u12C5' + | '\u12C8' ..'\u12D6' + | '\u12D8' ..'\u1310' + | '\u1312' ..'\u1315' + | '\u1318' ..'\u135A' + | '\u1380' ..'\u138F' + | '\u13A0' ..'\u13F4' + | '\u1401' ..'\u166C' + | '\u166F' ..'\u167F' + | '\u1681' ..'\u169A' + | '\u16A0' ..'\u16EA' + | '\u1700' ..'\u170C' + | '\u170E' ..'\u1711' + | '\u1720' ..'\u1731' + | '\u1740' ..'\u1751' + | '\u1760' ..'\u176C' + | '\u176E' ..'\u1770' + | '\u1780' ..'\u17B3' + | '\u17DC' + | '\u1820' ..'\u1842' + | '\u1844' ..'\u1877' + | '\u1880' ..'\u18A8' + | '\u18AA' + | '\u18B0' ..'\u18F5' + | '\u1900' ..'\u191C' + | '\u1950' ..'\u196D' + | '\u1970' ..'\u1974' + | '\u1980' ..'\u19AB' + | '\u19C1' ..'\u19C7' + | '\u1A00' ..'\u1A16' + | '\u1A20' ..'\u1A54' + | '\u1B05' ..'\u1B33' + | '\u1B45' ..'\u1B4B' + | '\u1B83' ..'\u1BA0' + | '\u1BAE' + | '\u1BAF' + | '\u1BBA' ..'\u1BE5' + | '\u1C00' ..'\u1C23' + | '\u1C4D' ..'\u1C4F' + | '\u1C5A' ..'\u1C77' + | '\u1CE9' ..'\u1CEC' + | '\u1CEE' ..'\u1CF1' + | '\u1CF5' + | '\u1CF6' + | '\u2135' ..'\u2138' + | '\u2D30' ..'\u2D67' + | '\u2D80' ..'\u2D96' + | '\u2DA0' ..'\u2DA6' + | '\u2DA8' ..'\u2DAE' + | '\u2DB0' ..'\u2DB6' + | '\u2DB8' ..'\u2DBE' + | '\u2DC0' ..'\u2DC6' + | '\u2DC8' ..'\u2DCE' + | '\u2DD0' ..'\u2DD6' + | '\u2DD8' ..'\u2DDE' + | '\u3006' + | '\u303C' + | '\u3041' ..'\u3096' + | '\u309F' + | '\u30A1' ..'\u30FA' + | '\u30FF' + | '\u3105' ..'\u312D' + | '\u3131' ..'\u318E' + | '\u31A0' ..'\u31BA' + | '\u31F0' ..'\u31FF' + | '\u3400' ..'\u4DB5' + | '\u4E00' ..'\u9FCC' + | '\uA000' ..'\uA014' + | '\uA016' ..'\uA48C' + | '\uA4D0' ..'\uA4F7' + | '\uA500' ..'\uA60B' + | '\uA610' ..'\uA61F' + | '\uA62A' + | '\uA62B' + | '\uA66E' + | '\uA6A0' ..'\uA6E5' + | '\uA7FB' ..'\uA801' + | '\uA803' ..'\uA805' + | '\uA807' ..'\uA80A' + | '\uA80C' ..'\uA822' + | '\uA840' ..'\uA873' + | '\uA882' ..'\uA8B3' + | '\uA8F2' ..'\uA8F7' + | '\uA8FB' + | '\uA90A' ..'\uA925' + | '\uA930' ..'\uA946' + | '\uA960' ..'\uA97C' + | '\uA984' ..'\uA9B2' + | '\uAA00' ..'\uAA28' + | '\uAA40' ..'\uAA42' + | '\uAA44' ..'\uAA4B' + | '\uAA60' ..'\uAA6F' + | '\uAA71' ..'\uAA76' + | '\uAA7A' + | '\uAA80' ..'\uAAAF' + | '\uAAB1' + | '\uAAB5' + | '\uAAB6' + | '\uAAB9' ..'\uAABD' + | '\uAAC0' + | '\uAAC2' + | '\uAADB' + | '\uAADC' + | '\uAAE0' ..'\uAAEA' + | '\uAAF2' + | '\uAB01' ..'\uAB06' + | '\uAB09' ..'\uAB0E' + | '\uAB11' ..'\uAB16' + | '\uAB20' ..'\uAB26' + | '\uAB28' ..'\uAB2E' + | '\uABC0' ..'\uABE2' + | '\uAC00' + | '\uD7A3' + | '\uD7B0' ..'\uD7C6' + | '\uD7CB' ..'\uD7FB' + | '\uF900' ..'\uFA6D' + | '\uFA70' ..'\uFAD9' + | '\uFB1D' + | '\uFB1F' ..'\uFB28' + | '\uFB2A' ..'\uFB36' + | '\uFB38' ..'\uFB3C' + | '\uFB3E' + | '\uFB40' + | '\uFB41' + | '\uFB43' + | '\uFB44' + | '\uFB46' ..'\uFBB1' + | '\uFBD3' ..'\uFD3D' + | '\uFD50' ..'\uFD8F' + | '\uFD92' ..'\uFDC7' + | '\uFDF0' ..'\uFDFB' + | '\uFE70' ..'\uFE74' + | '\uFE76' ..'\uFEFC' + | '\uFF66' ..'\uFF6F' + | '\uFF71' ..'\uFF9D' + | '\uFFA0' ..'\uFFBE' + | '\uFFC2' ..'\uFFC7' + | '\uFFCA' ..'\uFFCF' + | '\uFFD2' ..'\uFFD7' + | '\uFFDA' ..'\uFFDC' +; UNICODE_CLASS_LT: - '\u01C5' | - '\u01C8' | - '\u01CB' | - '\u01F2' | - '\u1F88'..'\u1F8F' | - '\u1F98'..'\u1F9F' | - '\u1FA8'..'\u1FAF' | - '\u1FBC' | - '\u1FCC' | - '\u1FFC'; + '\u01C5' + | '\u01C8' + | '\u01CB' + | '\u01F2' + | '\u1F88' ..'\u1F8F' + | '\u1F98' ..'\u1F9F' + | '\u1FA8' ..'\u1FAF' + | '\u1FBC' + | '\u1FCC' + | '\u1FFC' +; UNICODE_CLASS_LU: - '\u0041'..'\u005A' | - '\u00C0'..'\u00D6' | - '\u00D8'..'\u00DE' | - '\u0100' | - '\u0102' | - '\u0104' | - '\u0106' | - '\u0108' | - '\u010A' | - '\u010C' | - '\u010E' | - '\u0110' | - '\u0112' | - '\u0114' | - '\u0116' | - '\u0118' | - '\u011A' | - '\u011C' | - '\u011E' | - '\u0120' | - '\u0122' | - '\u0124' | - '\u0126' | - '\u0128' | - '\u012A' | - '\u012C' | - '\u012E' | - '\u0130' | - '\u0132' | - '\u0134' | - '\u0136' | - '\u0139' | - '\u013B' | - '\u013D' | - '\u013F' | - '\u0141' | - '\u0143' | - '\u0145' | - '\u0147' | - '\u014A' | - '\u014C' | - '\u014E' | - '\u0150' | - '\u0152' | - '\u0154' | - '\u0156' | - '\u0158' | - '\u015A' | - '\u015C' | - '\u015E' | - '\u0160' | - '\u0162' | - '\u0164' | - '\u0166' | - '\u0168' | - '\u016A' | - '\u016C' | - '\u016E' | - '\u0170' | - '\u0172' | - '\u0174' | - '\u0176' | - '\u0178' | - '\u0179' | - '\u017B' | - '\u017D' | - '\u0181' | - '\u0182' | - '\u0184' | - '\u0186' | - '\u0187' | - '\u0189'..'\u018B' | - '\u018E'..'\u0191' | - '\u0193' | - '\u0194' | - '\u0196'..'\u0198' | - '\u019C' | - '\u019D' | - '\u019F' | - '\u01A0' | - '\u01A2' | - '\u01A4' | - '\u01A6' | - '\u01A7' | - '\u01A9' | - '\u01AC' | - '\u01AE' | - '\u01AF' | - '\u01B1'..'\u01B3' | - '\u01B5' | - '\u01B7' | - '\u01B8' | - '\u01BC' | - '\u01C4' | - '\u01C7' | - '\u01CA' | - '\u01CD' | - '\u01CF' | - '\u01D1' | - '\u01D3' | - '\u01D5' | - '\u01D7' | - '\u01D9' | - '\u01DB' | - '\u01DE' | - '\u01E0' | - '\u01E2' | - '\u01E4' | - '\u01E6' | - '\u01E8' | - '\u01EA' | - '\u01EC' | - '\u01EE' | - '\u01F1' | - '\u01F4' | - '\u01F6'..'\u01F8' | - '\u01FA' | - '\u01FC' | - '\u01FE' | - '\u0200' | - '\u0202' | - '\u0204' | - '\u0206' | - '\u0208' | - '\u020A' | - '\u020C' | - '\u020E' | - '\u0210' | - '\u0212' | - '\u0214' | - '\u0216' | - '\u0218' | - '\u021A' | - '\u021C' | - '\u021E' | - '\u0220' | - '\u0222' | - '\u0224' | - '\u0226' | - '\u0228' | - '\u022A' | - '\u022C' | - '\u022E' | - '\u0230' | - '\u0232' | - '\u023A' | - '\u023B' | - '\u023D' | - '\u023E' | - '\u0241' | - '\u0243'..'\u0246' | - '\u0248' | - '\u024A' | - '\u024C' | - '\u024E' | - '\u0370' | - '\u0372' | - '\u0376' | - '\u0386' | - '\u0388'..'\u038A' | - '\u038C' | - '\u038E' | - '\u038F' | - '\u0391'..'\u03A1' | - '\u03A3'..'\u03AB' | - '\u03CF' | - '\u03D2'..'\u03D4' | - '\u03D8' | - '\u03DA' | - '\u03DC' | - '\u03DE' | - '\u03E0' | - '\u03E2' | - '\u03E4' | - '\u03E6' | - '\u03E8' | - '\u03EA' | - '\u03EC' | - '\u03EE' | - '\u03F4' | - '\u03F7' | - '\u03F9' | - '\u03FA' | - '\u03FD'..'\u042F' | - '\u0460' | - '\u0462' | - '\u0464' | - '\u0466' | - '\u0468' | - '\u046A' | - '\u046C' | - '\u046E' | - '\u0470' | - '\u0472' | - '\u0474' | - '\u0476' | - '\u0478' | - '\u047A' | - '\u047C' | - '\u047E' | - '\u0480' | - '\u048A' | - '\u048C' | - '\u048E' | - '\u0490' | - '\u0492' | - '\u0494' | - '\u0496' | - '\u0498' | - '\u049A' | - '\u049C' | - '\u049E' | - '\u04A0' | - '\u04A2' | - '\u04A4' | - '\u04A6' | - '\u04A8' | - '\u04AA' | - '\u04AC' | - '\u04AE' | - '\u04B0' | - '\u04B2' | - '\u04B4' | - '\u04B6' | - '\u04B8' | - '\u04BA' | - '\u04BC' | - '\u04BE' | - '\u04C0' | - '\u04C1' | - '\u04C3' | - '\u04C5' | - '\u04C7' | - '\u04C9' | - '\u04CB' | - '\u04CD' | - '\u04D0' | - '\u04D2' | - '\u04D4' | - '\u04D6' | - '\u04D8' | - '\u04DA' | - '\u04DC' | - '\u04DE' | - '\u04E0' | - '\u04E2' | - '\u04E4' | - '\u04E6' | - '\u04E8' | - '\u04EA' | - '\u04EC' | - '\u04EE' | - '\u04F0' | - '\u04F2' | - '\u04F4' | - '\u04F6' | - '\u04F8' | - '\u04FA' | - '\u04FC' | - '\u04FE' | - '\u0500' | - '\u0502' | - '\u0504' | - '\u0506' | - '\u0508' | - '\u050A' | - '\u050C' | - '\u050E' | - '\u0510' | - '\u0512' | - '\u0514' | - '\u0516' | - '\u0518' | - '\u051A' | - '\u051C' | - '\u051E' | - '\u0520' | - '\u0522' | - '\u0524' | - '\u0526' | - '\u0531'..'\u0556' | - '\u10A0'..'\u10C5' | - '\u10C7' | - '\u10CD' | - '\u1E00' | - '\u1E02' | - '\u1E04' | - '\u1E06' | - '\u1E08' | - '\u1E0A' | - '\u1E0C' | - '\u1E0E' | - '\u1E10' | - '\u1E12' | - '\u1E14' | - '\u1E16' | - '\u1E18' | - '\u1E1A' | - '\u1E1C' | - '\u1E1E' | - '\u1E20' | - '\u1E22' | - '\u1E24' | - '\u1E26' | - '\u1E28' | - '\u1E2A' | - '\u1E2C' | - '\u1E2E' | - '\u1E30' | - '\u1E32' | - '\u1E34' | - '\u1E36' | - '\u1E38' | - '\u1E3A' | - '\u1E3C' | - '\u1E3E' | - '\u1E40' | - '\u1E42' | - '\u1E44' | - '\u1E46' | - '\u1E48' | - '\u1E4A' | - '\u1E4C' | - '\u1E4E' | - '\u1E50' | - '\u1E52' | - '\u1E54' | - '\u1E56' | - '\u1E58' | - '\u1E5A' | - '\u1E5C' | - '\u1E5E' | - '\u1E60' | - '\u1E62' | - '\u1E64' | - '\u1E66' | - '\u1E68' | - '\u1E6A' | - '\u1E6C' | - '\u1E6E' | - '\u1E70' | - '\u1E72' | - '\u1E74' | - '\u1E76' | - '\u1E78' | - '\u1E7A' | - '\u1E7C' | - '\u1E7E' | - '\u1E80' | - '\u1E82' | - '\u1E84' | - '\u1E86' | - '\u1E88' | - '\u1E8A' | - '\u1E8C' | - '\u1E8E' | - '\u1E90' | - '\u1E92' | - '\u1E94' | - '\u1E9E' | - '\u1EA0' | - '\u1EA2' | - '\u1EA4' | - '\u1EA6' | - '\u1EA8' | - '\u1EAA' | - '\u1EAC' | - '\u1EAE' | - '\u1EB0' | - '\u1EB2' | - '\u1EB4' | - '\u1EB6' | - '\u1EB8' | - '\u1EBA' | - '\u1EBC' | - '\u1EBE' | - '\u1EC0' | - '\u1EC2' | - '\u1EC4' | - '\u1EC6' | - '\u1EC8' | - '\u1ECA' | - '\u1ECC' | - '\u1ECE' | - '\u1ED0' | - '\u1ED2' | - '\u1ED4' | - '\u1ED6' | - '\u1ED8' | - '\u1EDA' | - '\u1EDC' | - '\u1EDE' | - '\u1EE0' | - '\u1EE2' | - '\u1EE4' | - '\u1EE6' | - '\u1EE8' | - '\u1EEA' | - '\u1EEC' | - '\u1EEE' | - '\u1EF0' | - '\u1EF2' | - '\u1EF4' | - '\u1EF6' | - '\u1EF8' | - '\u1EFA' | - '\u1EFC' | - '\u1EFE' | - '\u1F08'..'\u1F0F' | - '\u1F18'..'\u1F1D' | - '\u1F28'..'\u1F2F' | - '\u1F38'..'\u1F3F' | - '\u1F48'..'\u1F4D' | - '\u1F59' | - '\u1F5B' | - '\u1F5D' | - '\u1F5F' | - '\u1F68'..'\u1F6F' | - '\u1FB8'..'\u1FBB' | - '\u1FC8'..'\u1FCB' | - '\u1FD8'..'\u1FDB' | - '\u1FE8'..'\u1FEC' | - '\u1FF8'..'\u1FFB' | - '\u2102' | - '\u2107' | - '\u210B'..'\u210D' | - '\u2110'..'\u2112' | - '\u2115' | - '\u2119'..'\u211D' | - '\u2124' | - '\u2126' | - '\u2128' | - '\u212A'..'\u212D' | - '\u2130'..'\u2133' | - '\u213E' | - '\u213F' | - '\u2145' | - '\u2183' | - '\u2C00'..'\u2C2E' | - '\u2C60' | - '\u2C62'..'\u2C64' | - '\u2C67' | - '\u2C69' | - '\u2C6B' | - '\u2C6D'..'\u2C70' | - '\u2C72' | - '\u2C75' | - '\u2C7E'..'\u2C80' | - '\u2C82' | - '\u2C84' | - '\u2C86' | - '\u2C88' | - '\u2C8A' | - '\u2C8C' | - '\u2C8E' | - '\u2C90' | - '\u2C92' | - '\u2C94' | - '\u2C96' | - '\u2C98' | - '\u2C9A' | - '\u2C9C' | - '\u2C9E' | - '\u2CA0' | - '\u2CA2' | - '\u2CA4' | - '\u2CA6' | - '\u2CA8' | - '\u2CAA' | - '\u2CAC' | - '\u2CAE' | - '\u2CB0' | - '\u2CB2' | - '\u2CB4' | - '\u2CB6' | - '\u2CB8' | - '\u2CBA' | - '\u2CBC' | - '\u2CBE' | - '\u2CC0' | - '\u2CC2' | - '\u2CC4' | - '\u2CC6' | - '\u2CC8' | - '\u2CCA' | - '\u2CCC' | - '\u2CCE' | - '\u2CD0' | - '\u2CD2' | - '\u2CD4' | - '\u2CD6' | - '\u2CD8' | - '\u2CDA' | - '\u2CDC' | - '\u2CDE' | - '\u2CE0' | - '\u2CE2' | - '\u2CEB' | - '\u2CED' | - '\u2CF2' | - '\uA640' | - '\uA642' | - '\uA644' | - '\uA646' | - '\uA648' | - '\uA64A' | - '\uA64C' | - '\uA64E' | - '\uA650' | - '\uA652' | - '\uA654' | - '\uA656' | - '\uA658' | - '\uA65A' | - '\uA65C' | - '\uA65E' | - '\uA660' | - '\uA662' | - '\uA664' | - '\uA666' | - '\uA668' | - '\uA66A' | - '\uA66C' | - '\uA680' | - '\uA682' | - '\uA684' | - '\uA686' | - '\uA688' | - '\uA68A' | - '\uA68C' | - '\uA68E' | - '\uA690' | - '\uA692' | - '\uA694' | - '\uA696' | - '\uA722' | - '\uA724' | - '\uA726' | - '\uA728' | - '\uA72A' | - '\uA72C' | - '\uA72E' | - '\uA732' | - '\uA734' | - '\uA736' | - '\uA738' | - '\uA73A' | - '\uA73C' | - '\uA73E' | - '\uA740' | - '\uA742' | - '\uA744' | - '\uA746' | - '\uA748' | - '\uA74A' | - '\uA74C' | - '\uA74E' | - '\uA750' | - '\uA752' | - '\uA754' | - '\uA756' | - '\uA758' | - '\uA75A' | - '\uA75C' | - '\uA75E' | - '\uA760' | - '\uA762' | - '\uA764' | - '\uA766' | - '\uA768' | - '\uA76A' | - '\uA76C' | - '\uA76E' | - '\uA779' | - '\uA77B' | - '\uA77D' | - '\uA77E' | - '\uA780' | - '\uA782' | - '\uA784' | - '\uA786' | - '\uA78B' | - '\uA78D' | - '\uA790' | - '\uA792' | - '\uA7A0' | - '\uA7A2' | - '\uA7A4' | - '\uA7A6' | - '\uA7A8' | - '\uA7AA' | - '\uFF21'..'\uFF3A'; + '\u0041' ..'\u005A' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00DE' + | '\u0100' + | '\u0102' + | '\u0104' + | '\u0106' + | '\u0108' + | '\u010A' + | '\u010C' + | '\u010E' + | '\u0110' + | '\u0112' + | '\u0114' + | '\u0116' + | '\u0118' + | '\u011A' + | '\u011C' + | '\u011E' + | '\u0120' + | '\u0122' + | '\u0124' + | '\u0126' + | '\u0128' + | '\u012A' + | '\u012C' + | '\u012E' + | '\u0130' + | '\u0132' + | '\u0134' + | '\u0136' + | '\u0139' + | '\u013B' + | '\u013D' + | '\u013F' + | '\u0141' + | '\u0143' + | '\u0145' + | '\u0147' + | '\u014A' + | '\u014C' + | '\u014E' + | '\u0150' + | '\u0152' + | '\u0154' + | '\u0156' + | '\u0158' + | '\u015A' + | '\u015C' + | '\u015E' + | '\u0160' + | '\u0162' + | '\u0164' + | '\u0166' + | '\u0168' + | '\u016A' + | '\u016C' + | '\u016E' + | '\u0170' + | '\u0172' + | '\u0174' + | '\u0176' + | '\u0178' + | '\u0179' + | '\u017B' + | '\u017D' + | '\u0181' + | '\u0182' + | '\u0184' + | '\u0186' + | '\u0187' + | '\u0189' ..'\u018B' + | '\u018E' ..'\u0191' + | '\u0193' + | '\u0194' + | '\u0196' ..'\u0198' + | '\u019C' + | '\u019D' + | '\u019F' + | '\u01A0' + | '\u01A2' + | '\u01A4' + | '\u01A6' + | '\u01A7' + | '\u01A9' + | '\u01AC' + | '\u01AE' + | '\u01AF' + | '\u01B1' ..'\u01B3' + | '\u01B5' + | '\u01B7' + | '\u01B8' + | '\u01BC' + | '\u01C4' + | '\u01C7' + | '\u01CA' + | '\u01CD' + | '\u01CF' + | '\u01D1' + | '\u01D3' + | '\u01D5' + | '\u01D7' + | '\u01D9' + | '\u01DB' + | '\u01DE' + | '\u01E0' + | '\u01E2' + | '\u01E4' + | '\u01E6' + | '\u01E8' + | '\u01EA' + | '\u01EC' + | '\u01EE' + | '\u01F1' + | '\u01F4' + | '\u01F6' ..'\u01F8' + | '\u01FA' + | '\u01FC' + | '\u01FE' + | '\u0200' + | '\u0202' + | '\u0204' + | '\u0206' + | '\u0208' + | '\u020A' + | '\u020C' + | '\u020E' + | '\u0210' + | '\u0212' + | '\u0214' + | '\u0216' + | '\u0218' + | '\u021A' + | '\u021C' + | '\u021E' + | '\u0220' + | '\u0222' + | '\u0224' + | '\u0226' + | '\u0228' + | '\u022A' + | '\u022C' + | '\u022E' + | '\u0230' + | '\u0232' + | '\u023A' + | '\u023B' + | '\u023D' + | '\u023E' + | '\u0241' + | '\u0243' ..'\u0246' + | '\u0248' + | '\u024A' + | '\u024C' + | '\u024E' + | '\u0370' + | '\u0372' + | '\u0376' + | '\u0386' + | '\u0388' ..'\u038A' + | '\u038C' + | '\u038E' + | '\u038F' + | '\u0391' ..'\u03A1' + | '\u03A3' ..'\u03AB' + | '\u03CF' + | '\u03D2' ..'\u03D4' + | '\u03D8' + | '\u03DA' + | '\u03DC' + | '\u03DE' + | '\u03E0' + | '\u03E2' + | '\u03E4' + | '\u03E6' + | '\u03E8' + | '\u03EA' + | '\u03EC' + | '\u03EE' + | '\u03F4' + | '\u03F7' + | '\u03F9' + | '\u03FA' + | '\u03FD' ..'\u042F' + | '\u0460' + | '\u0462' + | '\u0464' + | '\u0466' + | '\u0468' + | '\u046A' + | '\u046C' + | '\u046E' + | '\u0470' + | '\u0472' + | '\u0474' + | '\u0476' + | '\u0478' + | '\u047A' + | '\u047C' + | '\u047E' + | '\u0480' + | '\u048A' + | '\u048C' + | '\u048E' + | '\u0490' + | '\u0492' + | '\u0494' + | '\u0496' + | '\u0498' + | '\u049A' + | '\u049C' + | '\u049E' + | '\u04A0' + | '\u04A2' + | '\u04A4' + | '\u04A6' + | '\u04A8' + | '\u04AA' + | '\u04AC' + | '\u04AE' + | '\u04B0' + | '\u04B2' + | '\u04B4' + | '\u04B6' + | '\u04B8' + | '\u04BA' + | '\u04BC' + | '\u04BE' + | '\u04C0' + | '\u04C1' + | '\u04C3' + | '\u04C5' + | '\u04C7' + | '\u04C9' + | '\u04CB' + | '\u04CD' + | '\u04D0' + | '\u04D2' + | '\u04D4' + | '\u04D6' + | '\u04D8' + | '\u04DA' + | '\u04DC' + | '\u04DE' + | '\u04E0' + | '\u04E2' + | '\u04E4' + | '\u04E6' + | '\u04E8' + | '\u04EA' + | '\u04EC' + | '\u04EE' + | '\u04F0' + | '\u04F2' + | '\u04F4' + | '\u04F6' + | '\u04F8' + | '\u04FA' + | '\u04FC' + | '\u04FE' + | '\u0500' + | '\u0502' + | '\u0504' + | '\u0506' + | '\u0508' + | '\u050A' + | '\u050C' + | '\u050E' + | '\u0510' + | '\u0512' + | '\u0514' + | '\u0516' + | '\u0518' + | '\u051A' + | '\u051C' + | '\u051E' + | '\u0520' + | '\u0522' + | '\u0524' + | '\u0526' + | '\u0531' ..'\u0556' + | '\u10A0' ..'\u10C5' + | '\u10C7' + | '\u10CD' + | '\u1E00' + | '\u1E02' + | '\u1E04' + | '\u1E06' + | '\u1E08' + | '\u1E0A' + | '\u1E0C' + | '\u1E0E' + | '\u1E10' + | '\u1E12' + | '\u1E14' + | '\u1E16' + | '\u1E18' + | '\u1E1A' + | '\u1E1C' + | '\u1E1E' + | '\u1E20' + | '\u1E22' + | '\u1E24' + | '\u1E26' + | '\u1E28' + | '\u1E2A' + | '\u1E2C' + | '\u1E2E' + | '\u1E30' + | '\u1E32' + | '\u1E34' + | '\u1E36' + | '\u1E38' + | '\u1E3A' + | '\u1E3C' + | '\u1E3E' + | '\u1E40' + | '\u1E42' + | '\u1E44' + | '\u1E46' + | '\u1E48' + | '\u1E4A' + | '\u1E4C' + | '\u1E4E' + | '\u1E50' + | '\u1E52' + | '\u1E54' + | '\u1E56' + | '\u1E58' + | '\u1E5A' + | '\u1E5C' + | '\u1E5E' + | '\u1E60' + | '\u1E62' + | '\u1E64' + | '\u1E66' + | '\u1E68' + | '\u1E6A' + | '\u1E6C' + | '\u1E6E' + | '\u1E70' + | '\u1E72' + | '\u1E74' + | '\u1E76' + | '\u1E78' + | '\u1E7A' + | '\u1E7C' + | '\u1E7E' + | '\u1E80' + | '\u1E82' + | '\u1E84' + | '\u1E86' + | '\u1E88' + | '\u1E8A' + | '\u1E8C' + | '\u1E8E' + | '\u1E90' + | '\u1E92' + | '\u1E94' + | '\u1E9E' + | '\u1EA0' + | '\u1EA2' + | '\u1EA4' + | '\u1EA6' + | '\u1EA8' + | '\u1EAA' + | '\u1EAC' + | '\u1EAE' + | '\u1EB0' + | '\u1EB2' + | '\u1EB4' + | '\u1EB6' + | '\u1EB8' + | '\u1EBA' + | '\u1EBC' + | '\u1EBE' + | '\u1EC0' + | '\u1EC2' + | '\u1EC4' + | '\u1EC6' + | '\u1EC8' + | '\u1ECA' + | '\u1ECC' + | '\u1ECE' + | '\u1ED0' + | '\u1ED2' + | '\u1ED4' + | '\u1ED6' + | '\u1ED8' + | '\u1EDA' + | '\u1EDC' + | '\u1EDE' + | '\u1EE0' + | '\u1EE2' + | '\u1EE4' + | '\u1EE6' + | '\u1EE8' + | '\u1EEA' + | '\u1EEC' + | '\u1EEE' + | '\u1EF0' + | '\u1EF2' + | '\u1EF4' + | '\u1EF6' + | '\u1EF8' + | '\u1EFA' + | '\u1EFC' + | '\u1EFE' + | '\u1F08' ..'\u1F0F' + | '\u1F18' ..'\u1F1D' + | '\u1F28' ..'\u1F2F' + | '\u1F38' ..'\u1F3F' + | '\u1F48' ..'\u1F4D' + | '\u1F59' + | '\u1F5B' + | '\u1F5D' + | '\u1F5F' + | '\u1F68' ..'\u1F6F' + | '\u1FB8' ..'\u1FBB' + | '\u1FC8' ..'\u1FCB' + | '\u1FD8' ..'\u1FDB' + | '\u1FE8' ..'\u1FEC' + | '\u1FF8' ..'\u1FFB' + | '\u2102' + | '\u2107' + | '\u210B' ..'\u210D' + | '\u2110' ..'\u2112' + | '\u2115' + | '\u2119' ..'\u211D' + | '\u2124' + | '\u2126' + | '\u2128' + | '\u212A' ..'\u212D' + | '\u2130' ..'\u2133' + | '\u213E' + | '\u213F' + | '\u2145' + | '\u2183' + | '\u2C00' ..'\u2C2E' + | '\u2C60' + | '\u2C62' ..'\u2C64' + | '\u2C67' + | '\u2C69' + | '\u2C6B' + | '\u2C6D' ..'\u2C70' + | '\u2C72' + | '\u2C75' + | '\u2C7E' ..'\u2C80' + | '\u2C82' + | '\u2C84' + | '\u2C86' + | '\u2C88' + | '\u2C8A' + | '\u2C8C' + | '\u2C8E' + | '\u2C90' + | '\u2C92' + | '\u2C94' + | '\u2C96' + | '\u2C98' + | '\u2C9A' + | '\u2C9C' + | '\u2C9E' + | '\u2CA0' + | '\u2CA2' + | '\u2CA4' + | '\u2CA6' + | '\u2CA8' + | '\u2CAA' + | '\u2CAC' + | '\u2CAE' + | '\u2CB0' + | '\u2CB2' + | '\u2CB4' + | '\u2CB6' + | '\u2CB8' + | '\u2CBA' + | '\u2CBC' + | '\u2CBE' + | '\u2CC0' + | '\u2CC2' + | '\u2CC4' + | '\u2CC6' + | '\u2CC8' + | '\u2CCA' + | '\u2CCC' + | '\u2CCE' + | '\u2CD0' + | '\u2CD2' + | '\u2CD4' + | '\u2CD6' + | '\u2CD8' + | '\u2CDA' + | '\u2CDC' + | '\u2CDE' + | '\u2CE0' + | '\u2CE2' + | '\u2CEB' + | '\u2CED' + | '\u2CF2' + | '\uA640' + | '\uA642' + | '\uA644' + | '\uA646' + | '\uA648' + | '\uA64A' + | '\uA64C' + | '\uA64E' + | '\uA650' + | '\uA652' + | '\uA654' + | '\uA656' + | '\uA658' + | '\uA65A' + | '\uA65C' + | '\uA65E' + | '\uA660' + | '\uA662' + | '\uA664' + | '\uA666' + | '\uA668' + | '\uA66A' + | '\uA66C' + | '\uA680' + | '\uA682' + | '\uA684' + | '\uA686' + | '\uA688' + | '\uA68A' + | '\uA68C' + | '\uA68E' + | '\uA690' + | '\uA692' + | '\uA694' + | '\uA696' + | '\uA722' + | '\uA724' + | '\uA726' + | '\uA728' + | '\uA72A' + | '\uA72C' + | '\uA72E' + | '\uA732' + | '\uA734' + | '\uA736' + | '\uA738' + | '\uA73A' + | '\uA73C' + | '\uA73E' + | '\uA740' + | '\uA742' + | '\uA744' + | '\uA746' + | '\uA748' + | '\uA74A' + | '\uA74C' + | '\uA74E' + | '\uA750' + | '\uA752' + | '\uA754' + | '\uA756' + | '\uA758' + | '\uA75A' + | '\uA75C' + | '\uA75E' + | '\uA760' + | '\uA762' + | '\uA764' + | '\uA766' + | '\uA768' + | '\uA76A' + | '\uA76C' + | '\uA76E' + | '\uA779' + | '\uA77B' + | '\uA77D' + | '\uA77E' + | '\uA780' + | '\uA782' + | '\uA784' + | '\uA786' + | '\uA78B' + | '\uA78D' + | '\uA790' + | '\uA792' + | '\uA7A0' + | '\uA7A2' + | '\uA7A4' + | '\uA7A6' + | '\uA7A8' + | '\uA7AA' + | '\uFF21' ..'\uFF3A' +; UNICODE_CLASS_ND: - '\u0030'..'\u0039' | - '\u0660'..'\u0669' | - '\u06F0'..'\u06F9' | - '\u07C0'..'\u07C9' | - '\u0966'..'\u096F' | - '\u09E6'..'\u09EF' | - '\u0A66'..'\u0A6F' | - '\u0AE6'..'\u0AEF' | - '\u0B66'..'\u0B6F' | - '\u0BE6'..'\u0BEF' | - '\u0C66'..'\u0C6F' | - '\u0CE6'..'\u0CEF' | - '\u0D66'..'\u0D6F' | - '\u0E50'..'\u0E59' | - '\u0ED0'..'\u0ED9' | - '\u0F20'..'\u0F29' | - '\u1040'..'\u1049' | - '\u1090'..'\u1099' | - '\u17E0'..'\u17E9' | - '\u1810'..'\u1819' | - '\u1946'..'\u194F' | - '\u19D0'..'\u19D9' | - '\u1A80'..'\u1A89' | - '\u1A90'..'\u1A99' | - '\u1B50'..'\u1B59' | - '\u1BB0'..'\u1BB9' | - '\u1C40'..'\u1C49' | - '\u1C50'..'\u1C59' | - '\uA620'..'\uA629' | - '\uA8D0'..'\uA8D9' | - '\uA900'..'\uA909' | - '\uA9D0'..'\uA9D9' | - '\uAA50'..'\uAA59' | - '\uABF0'..'\uABF9' | - '\uFF10'..'\uFF19'; + '\u0030' ..'\u0039' + | '\u0660' ..'\u0669' + | '\u06F0' ..'\u06F9' + | '\u07C0' ..'\u07C9' + | '\u0966' ..'\u096F' + | '\u09E6' ..'\u09EF' + | '\u0A66' ..'\u0A6F' + | '\u0AE6' ..'\u0AEF' + | '\u0B66' ..'\u0B6F' + | '\u0BE6' ..'\u0BEF' + | '\u0C66' ..'\u0C6F' + | '\u0CE6' ..'\u0CEF' + | '\u0D66' ..'\u0D6F' + | '\u0E50' ..'\u0E59' + | '\u0ED0' ..'\u0ED9' + | '\u0F20' ..'\u0F29' + | '\u1040' ..'\u1049' + | '\u1090' ..'\u1099' + | '\u17E0' ..'\u17E9' + | '\u1810' ..'\u1819' + | '\u1946' ..'\u194F' + | '\u19D0' ..'\u19D9' + | '\u1A80' ..'\u1A89' + | '\u1A90' ..'\u1A99' + | '\u1B50' ..'\u1B59' + | '\u1BB0' ..'\u1BB9' + | '\u1C40' ..'\u1C49' + | '\u1C50' ..'\u1C59' + | '\uA620' ..'\uA629' + | '\uA8D0' ..'\uA8D9' + | '\uA900' ..'\uA909' + | '\uA9D0' ..'\uA9D9' + | '\uAA50' ..'\uAA59' + | '\uABF0' ..'\uABF9' + | '\uFF10' ..'\uFF19' +; UNICODE_CLASS_NL: - '\u16EE'..'\u16F0' | - '\u2160'..'\u2182' | - '\u2185'..'\u2188' | - '\u3007' | - '\u3021'..'\u3029' | - '\u3038'..'\u303A' | - '\uA6E6'..'\uA6EF'; \ No newline at end of file + '\u16EE' ..'\u16F0' + | '\u2160' ..'\u2182' + | '\u2185' ..'\u2188' + | '\u3007' + | '\u3021' ..'\u3029' + | '\u3038' ..'\u303A' + | '\uA6E6' ..'\uA6EF' +; \ No newline at end of file diff --git a/kotlin/kotlin/KotlinLexer.g4 b/kotlin/kotlin/KotlinLexer.g4 index 98663a793e..563fd67f71 100644 --- a/kotlin/kotlin/KotlinLexer.g4 +++ b/kotlin/kotlin/KotlinLexer.g4 @@ -10,578 +10,505 @@ * https://github.com/JetBrains/kotlin/tree/master/compiler/testData/psi */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar KotlinLexer; import UnicodeClasses; -ShebangLine - : '#!' ~[\u000A\u000D]* - -> channel(HIDDEN) - ; +ShebangLine: '#!' ~[\u000A\u000D]* -> channel(HIDDEN); -DelimitedComment - : '/*' ( DelimitedComment | . )*? '*/' - -> channel(HIDDEN) - ; +DelimitedComment: '/*' ( DelimitedComment | .)*? '*/' -> channel(HIDDEN); -LineComment - : '//' ~[\u000A\u000D]* - -> channel(HIDDEN) - ; +LineComment: '//' ~[\u000A\u000D]* -> channel(HIDDEN); -WS - : [\u0020\u0009\u000C] - -> skip - ; +WS: [\u0020\u0009\u000C] -> skip; -NL: '\u000A' | '\u000D' '\u000A' ; +NL: '\u000A' | '\u000D' '\u000A'; //SEPARATORS & OPERATIONS -RESERVED: '...' ; -DOT: '.' ; -COMMA: ',' ; -LPAREN: '(' -> pushMode(Inside) ; -RPAREN: ')' ; -LSQUARE: '[' -> pushMode(Inside) ; -RSQUARE: ']' ; -LCURL: '{' ; -RCURL: '}' ; -MULT: '*' ; -MOD: '%' ; -DIV: '/' ; -ADD: '+' ; -SUB: '-' ; -INCR: '++' ; -DECR: '--' ; -CONJ: '&&' ; -DISJ: '||' ; -EXCL: '!' ; -COLON: ':' ; -SEMICOLON: ';' ; -ASSIGNMENT: '=' ; -ADD_ASSIGNMENT: '+=' ; -SUB_ASSIGNMENT: '-=' ; -MULT_ASSIGNMENT: '*=' ; -DIV_ASSIGNMENT: '/=' ; -MOD_ASSIGNMENT: '%=' ; -ARROW: '->' ; -DOUBLE_ARROW: '=>' ; -RANGE: '..' ; -COLONCOLON: '::' ; -Q_COLONCOLON: '?::' ; -DOUBLE_SEMICOLON: ';;' ; -HASH: '#' ; -AT: '@' ; -QUEST: '?' ; -ELVIS: '?:' ; -LANGLE: '<' ; -RANGLE: '>' ; -LE: '<=' ; -GE: '>=' ; -EXCL_EQ: '!=' ; -EXCL_EQEQ: '!==' ; -AS_SAFE: 'as?' ; -EQEQ: '==' ; -EQEQEQ: '===' ; -SINGLE_QUOTE: '\'' ; +RESERVED : '...'; +DOT : '.'; +COMMA : ','; +LPAREN : '(' -> pushMode(Inside); +RPAREN : ')'; +LSQUARE : '[' -> pushMode(Inside); +RSQUARE : ']'; +LCURL : '{'; +RCURL : '}'; +MULT : '*'; +MOD : '%'; +DIV : '/'; +ADD : '+'; +SUB : '-'; +INCR : '++'; +DECR : '--'; +CONJ : '&&'; +DISJ : '||'; +EXCL : '!'; +COLON : ':'; +SEMICOLON : ';'; +ASSIGNMENT : '='; +ADD_ASSIGNMENT : '+='; +SUB_ASSIGNMENT : '-='; +MULT_ASSIGNMENT : '*='; +DIV_ASSIGNMENT : '/='; +MOD_ASSIGNMENT : '%='; +ARROW : '->'; +DOUBLE_ARROW : '=>'; +RANGE : '..'; +COLONCOLON : '::'; +Q_COLONCOLON : '?::'; +DOUBLE_SEMICOLON : ';;'; +HASH : '#'; +AT : '@'; +QUEST : '?'; +ELVIS : '?:'; +LANGLE : '<'; +RANGLE : '>'; +LE : '<='; +GE : '>='; +EXCL_EQ : '!='; +EXCL_EQEQ : '!=='; +AS_SAFE : 'as?'; +EQEQ : '=='; +EQEQEQ : '==='; +SINGLE_QUOTE : '\''; //KEYWORDS -RETURN_AT: 'return@' Identifier ; -CONTINUE_AT: 'continue@' Identifier ; -BREAK_AT: 'break@' Identifier ; - -FILE: '@file' ; -PACKAGE: 'package' ; -IMPORT: 'import' ; -CLASS: 'class' ; -INTERFACE: 'interface' ; -FUN: 'fun' ; -OBJECT: 'object' ; -VAL: 'val' ; -VAR: 'var' ; -TYPE_ALIAS: 'typealias' ; -CONSTRUCTOR: 'constructor' ; -BY: 'by' ; -COMPANION: 'companion' ; -INIT: 'init' ; -THIS: 'this' ; -SUPER: 'super' ; -TYPEOF: 'typeof' ; -WHERE: 'where' ; -IF: 'if' ; -ELSE: 'else' ; -WHEN: 'when' ; -TRY: 'try' ; -CATCH: 'catch' ; -FINALLY: 'finally' ; -FOR: 'for' ; -DO: 'do' ; -WHILE: 'while' ; -THROW: 'throw' ; -RETURN: 'return' ; -CONTINUE: 'continue' ; -BREAK: 'break' ; -AS: 'as' ; -IS: 'is' ; -IN: 'in' ; -NOT_IS: '!is' (WS | NL)+ ; -NOT_IN: '!in' (WS | NL)+ ; -OUT: 'out' ; -FIELD: '@field' ; -PROPERTY: '@property' ; -GET: '@get' ; -SET: '@set' ; -GETTER: 'get' ; -SETTER: 'set' ; -RECEIVER: '@receiver' ; -PARAM: '@param' ; -SETPARAM: '@setparam' ; -DELEGATE: '@delegate' ; -DYNAMIC: 'dynamic' ; +RETURN_AT : 'return@' Identifier; +CONTINUE_AT : 'continue@' Identifier; +BREAK_AT : 'break@' Identifier; + +FILE : '@file'; +PACKAGE : 'package'; +IMPORT : 'import'; +CLASS : 'class'; +INTERFACE : 'interface'; +FUN : 'fun'; +OBJECT : 'object'; +VAL : 'val'; +VAR : 'var'; +TYPE_ALIAS : 'typealias'; +CONSTRUCTOR : 'constructor'; +BY : 'by'; +COMPANION : 'companion'; +INIT : 'init'; +THIS : 'this'; +SUPER : 'super'; +TYPEOF : 'typeof'; +WHERE : 'where'; +IF : 'if'; +ELSE : 'else'; +WHEN : 'when'; +TRY : 'try'; +CATCH : 'catch'; +FINALLY : 'finally'; +FOR : 'for'; +DO : 'do'; +WHILE : 'while'; +THROW : 'throw'; +RETURN : 'return'; +CONTINUE : 'continue'; +BREAK : 'break'; +AS : 'as'; +IS : 'is'; +IN : 'in'; +NOT_IS : '!is' (WS | NL)+; +NOT_IN : '!in' (WS | NL)+; +OUT : 'out'; +FIELD : '@field'; +PROPERTY : '@property'; +GET : '@get'; +SET : '@set'; +GETTER : 'get'; +SETTER : 'set'; +RECEIVER : '@receiver'; +PARAM : '@param'; +SETPARAM : '@setparam'; +DELEGATE : '@delegate'; +DYNAMIC : 'dynamic'; //MODIFIERS -PUBLIC: 'public' ; -PRIVATE: 'private' ; -PROTECTED: 'protected' ; -INTERNAL: 'internal' ; -ENUM: 'enum' ; -SEALED: 'sealed' ; -ANNOTATION: 'annotation' ; -DATA: 'data' ; -INNER: 'inner' ; -TAILREC: 'tailrec' ; -OPERATOR: 'operator' ; -INLINE: 'inline' ; -INFIX: 'infix' ; -EXTERNAL: 'external' ; -SUSPEND: 'suspend' ; -OVERRIDE: 'override' ; -ABSTRACT: 'abstract' ; -FINAL: 'final' ; -OPEN: 'open' ; -CONST: 'const' ; -LATEINIT: 'lateinit' ; -VARARG: 'vararg' ; -NOINLINE: 'noinline' ; -CROSSINLINE: 'crossinline' ; -REIFIED: 'reified' ; +PUBLIC : 'public'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +INTERNAL : 'internal'; +ENUM : 'enum'; +SEALED : 'sealed'; +ANNOTATION : 'annotation'; +DATA : 'data'; +INNER : 'inner'; +TAILREC : 'tailrec'; +OPERATOR : 'operator'; +INLINE : 'inline'; +INFIX : 'infix'; +EXTERNAL : 'external'; +SUSPEND : 'suspend'; +OVERRIDE : 'override'; +ABSTRACT : 'abstract'; +FINAL : 'final'; +OPEN : 'open'; +CONST : 'const'; +LATEINIT : 'lateinit'; +VARARG : 'vararg'; +NOINLINE : 'noinline'; +CROSSINLINE : 'crossinline'; +REIFIED : 'reified'; // -QUOTE_OPEN: '"' -> pushMode(LineString) ; -TRIPLE_QUOTE_OPEN: '"""' -> pushMode(MultiLineString) ; - -RealLiteral - : FloatLiteral - | DoubleLiteral - ; - -FloatLiteral - : (DoubleLiteral | IntegerLiteral) [fF] - ; - -DoubleLiteral - : ( (DecDigitNoZero DecDigit* | '0')? '.' - | (DecDigitNoZero (DecDigit | '_')* DecDigit)? '.') - ( DecDigit+ - | DecDigit (DecDigit | '_')+ DecDigit - | DecDigit+ [eE] ('+' | '-')? DecDigit+ - | DecDigit+ [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit - | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ - | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit - ) - ; - -LongLiteral - : (IntegerLiteral | HexLiteral | BinLiteral) 'L' - ; - -IntegerLiteral - : ('0' - | DecDigitNoZero DecDigit* - | DecDigitNoZero (DecDigit | '_')+ DecDigit - | DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit+ - | DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit - | DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ - | DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit - ) - ; - -fragment DecDigit - : UNICODE_CLASS_ND - ; - -fragment DecDigitNoZero - : UNICODE_CLASS_ND_NoZeros - ; - -fragment UNICODE_CLASS_ND_NoZeros - : '\u0031'..'\u0039' - | '\u0661'..'\u0669' - | '\u06f1'..'\u06f9' - | '\u07c1'..'\u07c9' - | '\u0967'..'\u096f' - | '\u09e7'..'\u09ef' - | '\u0a67'..'\u0a6f' - | '\u0ae7'..'\u0aef' - | '\u0b67'..'\u0b6f' - | '\u0be7'..'\u0bef' - | '\u0c67'..'\u0c6f' - | '\u0ce7'..'\u0cef' - | '\u0d67'..'\u0d6f' - | '\u0de7'..'\u0def' - | '\u0e51'..'\u0e59' - | '\u0ed1'..'\u0ed9' - | '\u0f21'..'\u0f29' - | '\u1041'..'\u1049' - | '\u1091'..'\u1099' - | '\u17e1'..'\u17e9' - | '\u1811'..'\u1819' - | '\u1947'..'\u194f' - | '\u19d1'..'\u19d9' - | '\u1a81'..'\u1a89' - | '\u1a91'..'\u1a99' - | '\u1b51'..'\u1b59' - | '\u1bb1'..'\u1bb9' - | '\u1c41'..'\u1c49' - | '\u1c51'..'\u1c59' - | '\ua621'..'\ua629' - | '\ua8d1'..'\ua8d9' - | '\ua901'..'\ua909' - | '\ua9d1'..'\ua9d9' - | '\ua9f1'..'\ua9f9' - | '\uaa51'..'\uaa59' - | '\uabf1'..'\uabf9' - | '\uff11'..'\uff19' - ; - -HexLiteral - : '0' [xX] HexDigit (HexDigit | '_')* - ; - -fragment HexDigit - : [0-9a-fA-F] - ; - -BinLiteral - : '0' [bB] BinDigit (BinDigit | '_')* - ; - -fragment BinDigit - : [01] - ; - -BooleanLiteral - : 'true' - | 'false' - ; - -NullLiteral - : 'null' - ; - -Identifier - : (Letter | '_') (Letter | '_' | DecDigit)* - | '`' ~('`')+ '`' - ; - -LabelReference - : '@' Identifier - ; - -LabelDefinition - : Identifier '@' - ; - -FieldIdentifier - : '$' Identifier - ; - -CharacterLiteral - : '\'' (EscapeSeq | .) '\'' - ; - -fragment EscapeSeq - : UniCharacterLiteral - | EscapedIdentifier - ; - -fragment UniCharacterLiteral - : '\\' 'u' HexDigit HexDigit HexDigit HexDigit - ; - -fragment EscapedIdentifier - : '\\' ('t' | 'b' | 'r' | 'n' | '\'' | '"' | '\\' | '$') - ; - -fragment Letter - : UNICODE_CLASS_LL +QUOTE_OPEN : '"' -> pushMode(LineString); +TRIPLE_QUOTE_OPEN : '"""' -> pushMode(MultiLineString); + +RealLiteral: FloatLiteral | DoubleLiteral; + +FloatLiteral: (DoubleLiteral | IntegerLiteral) [fF]; + +DoubleLiteral: + ((DecDigitNoZero DecDigit* | '0')? '.' | (DecDigitNoZero (DecDigit | '_')* DecDigit)? '.') ( + DecDigit+ + | DecDigit (DecDigit | '_')+ DecDigit + | DecDigit+ [eE] ('+' | '-')? DecDigit+ + | DecDigit+ [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit + | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ + | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit + ) +; + +LongLiteral: (IntegerLiteral | HexLiteral | BinLiteral) 'L'; + +IntegerLiteral: + ( + '0' + | DecDigitNoZero DecDigit* + | DecDigitNoZero (DecDigit | '_')+ DecDigit + | DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit+ + | DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit + | DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ + | DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit + ) +; + +fragment DecDigit: UNICODE_CLASS_ND; + +fragment DecDigitNoZero: UNICODE_CLASS_ND_NoZeros; + +fragment UNICODE_CLASS_ND_NoZeros: + '\u0031' ..'\u0039' + | '\u0661' ..'\u0669' + | '\u06f1' ..'\u06f9' + | '\u07c1' ..'\u07c9' + | '\u0967' ..'\u096f' + | '\u09e7' ..'\u09ef' + | '\u0a67' ..'\u0a6f' + | '\u0ae7' ..'\u0aef' + | '\u0b67' ..'\u0b6f' + | '\u0be7' ..'\u0bef' + | '\u0c67' ..'\u0c6f' + | '\u0ce7' ..'\u0cef' + | '\u0d67' ..'\u0d6f' + | '\u0de7' ..'\u0def' + | '\u0e51' ..'\u0e59' + | '\u0ed1' ..'\u0ed9' + | '\u0f21' ..'\u0f29' + | '\u1041' ..'\u1049' + | '\u1091' ..'\u1099' + | '\u17e1' ..'\u17e9' + | '\u1811' ..'\u1819' + | '\u1947' ..'\u194f' + | '\u19d1' ..'\u19d9' + | '\u1a81' ..'\u1a89' + | '\u1a91' ..'\u1a99' + | '\u1b51' ..'\u1b59' + | '\u1bb1' ..'\u1bb9' + | '\u1c41' ..'\u1c49' + | '\u1c51' ..'\u1c59' + | '\ua621' ..'\ua629' + | '\ua8d1' ..'\ua8d9' + | '\ua901' ..'\ua909' + | '\ua9d1' ..'\ua9d9' + | '\ua9f1' ..'\ua9f9' + | '\uaa51' ..'\uaa59' + | '\uabf1' ..'\uabf9' + | '\uff11' ..'\uff19' +; + +HexLiteral: '0' [xX] HexDigit (HexDigit | '_')*; + +fragment HexDigit: [0-9a-fA-F]; + +BinLiteral: '0' [bB] BinDigit (BinDigit | '_')*; + +fragment BinDigit: [01]; + +BooleanLiteral: 'true' | 'false'; + +NullLiteral: 'null'; + +Identifier: (Letter | '_') (Letter | '_' | DecDigit)* | '`' ~('`')+ '`'; + +LabelReference: '@' Identifier; + +LabelDefinition: Identifier '@'; + +FieldIdentifier: '$' Identifier; + +CharacterLiteral: '\'' (EscapeSeq | .) '\''; + +fragment EscapeSeq: UniCharacterLiteral | EscapedIdentifier; + +fragment UniCharacterLiteral: '\\' 'u' HexDigit HexDigit HexDigit HexDigit; + +fragment EscapedIdentifier: '\\' ('t' | 'b' | 'r' | 'n' | '\'' | '"' | '\\' | '$'); + +fragment Letter: + UNICODE_CLASS_LL | UNICODE_CLASS_LM | UNICODE_CLASS_LO | UNICODE_CLASS_LT | UNICODE_CLASS_LU | UNICODE_CLASS_NL - ; - - -mode Inside ; - -Inside_RPAREN: ')' -> popMode, type(RPAREN) ; -Inside_RSQUARE: ']' -> popMode, type(RSQUARE); - -Inside_LPAREN: LPAREN -> pushMode(Inside), type(LPAREN) ; -Inside_LSQUARE: LSQUARE -> pushMode(Inside), type(LSQUARE) ; - -Inside_LCURL: LCURL -> type(LCURL) ; -Inside_RCURL: RCURL -> type(RCURL) ; -Inside_DOT: DOT -> type(DOT) ; -Inside_COMMA: COMMA -> type(COMMA) ; -Inside_MULT: MULT -> type(MULT) ; -Inside_MOD: MOD -> type(MOD) ; -Inside_DIV: DIV -> type(DIV) ; -Inside_ADD: ADD -> type(ADD) ; -Inside_SUB: SUB -> type(SUB) ; -Inside_INCR: INCR -> type(INCR) ; -Inside_DECR: DECR -> type(DECR) ; -Inside_CONJ: CONJ -> type(CONJ) ; -Inside_DISJ: DISJ -> type(DISJ) ; -Inside_EXCL: EXCL -> type(EXCL) ; -Inside_COLON: COLON -> type(COLON) ; -Inside_SEMICOLON: SEMICOLON -> type(SEMICOLON) ; -Inside_ASSIGNMENT: ASSIGNMENT -> type(ASSIGNMENT) ; -Inside_ADD_ASSIGNMENT: ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT) ; -Inside_SUB_ASSIGNMENT: SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT) ; -Inside_MULT_ASSIGNMENT: MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT) ; -Inside_DIV_ASSIGNMENT: DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT) ; -Inside_MOD_ASSIGNMENT: MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT) ; -Inside_ARROW: ARROW -> type(ARROW) ; -Inside_DOUBLE_ARROW: DOUBLE_ARROW -> type(DOUBLE_ARROW) ; -Inside_RANGE: RANGE -> type(RANGE) ; -Inside_RESERVED: RESERVED -> type(RESERVED) ; -Inside_COLONCOLON: COLONCOLON -> type(COLONCOLON) ; -Inside_Q_COLONCOLON: Q_COLONCOLON -> type(Q_COLONCOLON) ; -Inside_DOUBLE_SEMICOLON: DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON) ; -Inside_HASH: HASH -> type(HASH) ; -Inside_AT: AT -> type(AT) ; -Inside_QUEST: QUEST -> type(QUEST) ; -Inside_ELVIS: ELVIS -> type(ELVIS) ; -Inside_LANGLE: LANGLE -> type(LANGLE) ; -Inside_RANGLE: RANGLE -> type(RANGLE) ; -Inside_LE: LE -> type(LE) ; -Inside_GE: GE -> type(GE) ; -Inside_EXCL_EQ: EXCL_EQ -> type(EXCL_EQ) ; -Inside_EXCL_EQEQ: EXCL_EQEQ -> type(EXCL_EQEQ) ; -Inside_NOT_IS: NOT_IS -> type(NOT_IS) ; -Inside_NOT_IN: NOT_IN -> type(NOT_IN) ; -Inside_AS_SAFE: AS_SAFE -> type(AS_SAFE) ; -Inside_EQEQ: EQEQ -> type(EQEQ) ; -Inside_EQEQEQ: EQEQEQ -> type(EQEQEQ) ; -Inside_SINGLE_QUOTE: SINGLE_QUOTE -> type(SINGLE_QUOTE) ; -Inside_QUOTE_OPEN: QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN) ; -Inside_TRIPLE_QUOTE_OPEN: TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) ; - -Inside_VAL: VAL -> type(VAL) ; -Inside_VAR: VAR -> type(VAR) ; -Inside_OBJECT: OBJECT -> type(OBJECT) ; -Inside_SUPER: SUPER -> type(SUPER) ; -Inside_IN: IN -> type(IN) ; -Inside_OUT: OUT -> type(OUT) ; -Inside_FIELD: FIELD -> type(FIELD) ; -Inside_FILE: FILE -> type(FILE) ; -Inside_PROPERTY: PROPERTY -> type(PROPERTY) ; -Inside_GET: GET -> type(GET) ; -Inside_SET: SET -> type(SET) ; -Inside_RECEIVER: RECEIVER -> type(RECEIVER) ; -Inside_PARAM: PARAM -> type(PARAM) ; -Inside_SETPARAM: SETPARAM -> type(SETPARAM) ; -Inside_DELEGATE: DELEGATE -> type(DELEGATE) ; -Inside_THROW: THROW -> type(THROW) ; -Inside_RETURN: RETURN -> type(RETURN) ; -Inside_CONTINUE: CONTINUE -> type(CONTINUE) ; -Inside_BREAK: BREAK -> type(BREAK) ; -Inside_RETURN_AT: RETURN_AT -> type(RETURN_AT) ; -Inside_CONTINUE_AT: CONTINUE_AT -> type(CONTINUE_AT) ; -Inside_BREAK_AT: BREAK_AT -> type(BREAK_AT) ; -Inside_IF: IF -> type(IF) ; -Inside_ELSE: ELSE -> type(ELSE) ; -Inside_WHEN: WHEN -> type(WHEN) ; -Inside_TRY: TRY -> type(TRY) ; -Inside_CATCH: CATCH -> type(CATCH) ; -Inside_FINALLY: FINALLY -> type(FINALLY) ; -Inside_FOR: FOR -> type(FOR) ; -Inside_DO: DO -> type(DO) ; -Inside_WHILE: WHILE -> type(WHILE) ; - -Inside_PUBLIC: PUBLIC -> type(PUBLIC) ; -Inside_PRIVATE: PRIVATE -> type(PRIVATE) ; -Inside_PROTECTED: PROTECTED -> type(PROTECTED) ; -Inside_INTERNAL: INTERNAL -> type(INTERNAL) ; -Inside_ENUM: ENUM -> type(ENUM) ; -Inside_SEALED: SEALED -> type(SEALED) ; -Inside_ANNOTATION: ANNOTATION -> type(ANNOTATION) ; -Inside_DATA: DATA -> type(DATA) ; -Inside_INNER: INNER -> type(INNER) ; -Inside_TAILREC: TAILREC -> type(TAILREC) ; -Inside_OPERATOR: OPERATOR -> type(OPERATOR) ; -Inside_INLINE: INLINE -> type(INLINE) ; -Inside_INFIX: INFIX -> type(INFIX) ; -Inside_EXTERNAL: EXTERNAL -> type(EXTERNAL) ; -Inside_SUSPEND: SUSPEND -> type(SUSPEND) ; -Inside_OVERRIDE: OVERRIDE -> type(OVERRIDE) ; -Inside_ABSTRACT: ABSTRACT -> type(ABSTRACT) ; -Inside_FINAL: FINAL -> type(FINAL) ; -Inside_OPEN: OPEN -> type(OPEN) ; -Inside_CONST: CONST -> type(CONST) ; -Inside_LATEINIT: LATEINIT -> type(LATEINIT) ; -Inside_VARARG: VARARG -> type(VARARG) ; -Inside_NOINLINE: NOINLINE -> type(NOINLINE) ; -Inside_CROSSINLINE: CROSSINLINE -> type(CROSSINLINE) ; -Inside_REIFIED: REIFIED -> type(REIFIED) ; - -Inside_BooleanLiteral: BooleanLiteral -> type(BooleanLiteral) ; -Inside_IntegerLiteral: IntegerLiteral -> type(IntegerLiteral) ; -Inside_HexLiteral: HexLiteral -> type(HexLiteral) ; -Inside_BinLiteral: BinLiteral -> type(BinLiteral) ; -Inside_CharacterLiteral: CharacterLiteral -> type(CharacterLiteral) ; -Inside_RealLiteral: RealLiteral -> type(RealLiteral) ; -Inside_NullLiteral: NullLiteral -> type(NullLiteral) ; - -Inside_LongLiteral: LongLiteral -> type(LongLiteral) ; - -Inside_Identifier: Identifier -> type(Identifier) ; -Inside_LabelReference: LabelReference -> type(LabelReference) ; -Inside_LabelDefinition: LabelDefinition -> type(LabelDefinition) ; -Inside_Comment: (LineComment | DelimitedComment) -> channel(HIDDEN) ; -Inside_WS: WS -> skip ; -Inside_NL: NL -> skip ; - - -mode LineString ; - -QUOTE_CLOSE - : '"' -> popMode - ; - -LineStrRef - : FieldIdentifier - ; - -LineStrText - : ~('\\' | '"' | '$')+ | '$' - ; - -LineStrEscapedChar - : '\\' . - | UniCharacterLiteral - ; - -LineStrExprStart - : '${' -> pushMode(StringExpression) - ; - - -mode MultiLineString ; - -TRIPLE_QUOTE_CLOSE - : MultiLineStringQuote? '"""' -> popMode - ; - -MultiLineStringQuote - : '"'+ - ; - -MultiLineStrRef - : FieldIdentifier - ; - -MultiLineStrText - : ~('\\' | '"' | '$')+ | '$' - ; - -MultiLineStrEscapedChar - : '\\' . - ; - -MultiLineStrExprStart - : '${' -> pushMode(StringExpression) - ; - -MultiLineNL: NL -> skip ; - - -mode StringExpression ; - -StrExpr_RCURL: RCURL -> popMode, type(RCURL) ; - -StrExpr_LPAREN: LPAREN -> pushMode(Inside), type(LPAREN) ; -StrExpr_LSQUARE: LSQUARE -> pushMode(Inside), type(LSQUARE) ; - -StrExpr_RPAREN: ')' -> type(RPAREN) ; -StrExpr_RSQUARE: ']' -> type(RSQUARE); -StrExpr_LCURL: LCURL -> pushMode(StringExpression), type(LCURL) ; -StrExpr_DOT: DOT -> type(DOT) ; -StrExpr_COMMA: COMMA -> type(COMMA) ; -StrExpr_MULT: MULT -> type(MULT) ; -StrExpr_MOD: MOD -> type(MOD) ; -StrExpr_DIV: DIV -> type(DIV) ; -StrExpr_ADD: ADD -> type(ADD) ; -StrExpr_SUB: SUB -> type(SUB) ; -StrExpr_INCR: INCR -> type(INCR) ; -StrExpr_DECR: DECR -> type(DECR) ; -StrExpr_CONJ: CONJ -> type(CONJ) ; -StrExpr_DISJ: DISJ -> type(DISJ) ; -StrExpr_EXCL: EXCL -> type(EXCL) ; -StrExpr_COLON: COLON -> type(COLON) ; -StrExpr_SEMICOLON: SEMICOLON -> type(SEMICOLON) ; -StrExpr_ASSIGNMENT: ASSIGNMENT -> type(ASSIGNMENT) ; -StrExpr_ADD_ASSIGNMENT: ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT) ; -StrExpr_SUB_ASSIGNMENT: SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT) ; -StrExpr_MULT_ASSIGNMENT: MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT) ; -StrExpr_DIV_ASSIGNMENT: DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT) ; -StrExpr_MOD_ASSIGNMENT: MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT) ; -StrExpr_ARROW: ARROW -> type(ARROW) ; -StrExpr_DOUBLE_ARROW: DOUBLE_ARROW -> type(DOUBLE_ARROW) ; -StrExpr_RANGE: RANGE -> type(RANGE) ; -StrExpr_COLONCOLON: COLONCOLON -> type(COLONCOLON) ; -StrExpr_Q_COLONCOLON: Q_COLONCOLON -> type(Q_COLONCOLON) ; -StrExpr_DOUBLE_SEMICOLON: DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON) ; -StrExpr_HASH: HASH -> type(HASH) ; -StrExpr_AT: AT -> type(AT) ; -StrExpr_QUEST: QUEST -> type(QUEST) ; -StrExpr_ELVIS: ELVIS -> type(ELVIS) ; -StrExpr_LANGLE: LANGLE -> type(LANGLE) ; -StrExpr_RANGLE: RANGLE -> type(RANGLE) ; -StrExpr_LE: LE -> type(LE) ; -StrExpr_GE: GE -> type(GE) ; -StrExpr_EXCL_EQ: EXCL_EQ -> type(EXCL_EQ) ; -StrExpr_EXCL_EQEQ: EXCL_EQEQ -> type(EXCL_EQEQ) ; -StrExpr_AS: AS -> type(IS) ; -StrExpr_IS: IS -> type(IN) ; -StrExpr_IN: IN ; -StrExpr_NOT_IS: NOT_IS -> type(NOT_IS) ; -StrExpr_NOT_IN: NOT_IN -> type(NOT_IN) ; -StrExpr_AS_SAFE: AS_SAFE -> type(AS_SAFE) ; -StrExpr_EQEQ: EQEQ -> type(EQEQ) ; -StrExpr_EQEQEQ: EQEQEQ -> type(EQEQEQ) ; -StrExpr_SINGLE_QUOTE: SINGLE_QUOTE -> type(SINGLE_QUOTE) ; -StrExpr_QUOTE_OPEN: QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN) ; -StrExpr_TRIPLE_QUOTE_OPEN: TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) ; - -StrExpr_BooleanLiteral: BooleanLiteral -> type(BooleanLiteral) ; -StrExpr_IntegerLiteral: IntegerLiteral -> type(IntegerLiteral) ; -StrExpr_HexLiteral: HexLiteral -> type(HexLiteral) ; -StrExpr_BinLiteral: BinLiteral -> type(BinLiteral) ; -StrExpr_CharacterLiteral: CharacterLiteral -> type(CharacterLiteral) ; -StrExpr_RealLiteral: RealLiteral -> type(RealLiteral) ; -StrExpr_NullLiteral: NullLiteral -> type(NullLiteral) ; -StrExpr_LongLiteral: LongLiteral -> type(LongLiteral) ; - -StrExpr_Identifier: Identifier -> type(Identifier) ; -StrExpr_LabelReference: LabelReference -> type(LabelReference) ; -StrExpr_LabelDefinition: LabelDefinition -> type(LabelDefinition) ; -StrExpr_Comment: (LineComment | DelimitedComment) -> channel(HIDDEN) ; -StrExpr_WS: WS -> skip ; -StrExpr_NL: NL -> skip ; +; + +mode Inside; + +Inside_RPAREN : ')' -> popMode, type(RPAREN); +Inside_RSQUARE : ']' -> popMode, type(RSQUARE); + +Inside_LPAREN : LPAREN -> pushMode(Inside), type(LPAREN); +Inside_LSQUARE : LSQUARE -> pushMode(Inside), type(LSQUARE); + +Inside_LCURL : LCURL -> type(LCURL); +Inside_RCURL : RCURL -> type(RCURL); +Inside_DOT : DOT -> type(DOT); +Inside_COMMA : COMMA -> type(COMMA); +Inside_MULT : MULT -> type(MULT); +Inside_MOD : MOD -> type(MOD); +Inside_DIV : DIV -> type(DIV); +Inside_ADD : ADD -> type(ADD); +Inside_SUB : SUB -> type(SUB); +Inside_INCR : INCR -> type(INCR); +Inside_DECR : DECR -> type(DECR); +Inside_CONJ : CONJ -> type(CONJ); +Inside_DISJ : DISJ -> type(DISJ); +Inside_EXCL : EXCL -> type(EXCL); +Inside_COLON : COLON -> type(COLON); +Inside_SEMICOLON : SEMICOLON -> type(SEMICOLON); +Inside_ASSIGNMENT : ASSIGNMENT -> type(ASSIGNMENT); +Inside_ADD_ASSIGNMENT : ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT); +Inside_SUB_ASSIGNMENT : SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT); +Inside_MULT_ASSIGNMENT : MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT); +Inside_DIV_ASSIGNMENT : DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT); +Inside_MOD_ASSIGNMENT : MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT); +Inside_ARROW : ARROW -> type(ARROW); +Inside_DOUBLE_ARROW : DOUBLE_ARROW -> type(DOUBLE_ARROW); +Inside_RANGE : RANGE -> type(RANGE); +Inside_RESERVED : RESERVED -> type(RESERVED); +Inside_COLONCOLON : COLONCOLON -> type(COLONCOLON); +Inside_Q_COLONCOLON : Q_COLONCOLON -> type(Q_COLONCOLON); +Inside_DOUBLE_SEMICOLON : DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON); +Inside_HASH : HASH -> type(HASH); +Inside_AT : AT -> type(AT); +Inside_QUEST : QUEST -> type(QUEST); +Inside_ELVIS : ELVIS -> type(ELVIS); +Inside_LANGLE : LANGLE -> type(LANGLE); +Inside_RANGLE : RANGLE -> type(RANGLE); +Inside_LE : LE -> type(LE); +Inside_GE : GE -> type(GE); +Inside_EXCL_EQ : EXCL_EQ -> type(EXCL_EQ); +Inside_EXCL_EQEQ : EXCL_EQEQ -> type(EXCL_EQEQ); +Inside_NOT_IS : NOT_IS -> type(NOT_IS); +Inside_NOT_IN : NOT_IN -> type(NOT_IN); +Inside_AS_SAFE : AS_SAFE -> type(AS_SAFE); +Inside_EQEQ : EQEQ -> type(EQEQ); +Inside_EQEQEQ : EQEQEQ -> type(EQEQEQ); +Inside_SINGLE_QUOTE : SINGLE_QUOTE -> type(SINGLE_QUOTE); +Inside_QUOTE_OPEN : QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN); +Inside_TRIPLE_QUOTE_OPEN: + TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) +; + +Inside_VAL : VAL -> type(VAL); +Inside_VAR : VAR -> type(VAR); +Inside_OBJECT : OBJECT -> type(OBJECT); +Inside_SUPER : SUPER -> type(SUPER); +Inside_IN : IN -> type(IN); +Inside_OUT : OUT -> type(OUT); +Inside_FIELD : FIELD -> type(FIELD); +Inside_FILE : FILE -> type(FILE); +Inside_PROPERTY : PROPERTY -> type(PROPERTY); +Inside_GET : GET -> type(GET); +Inside_SET : SET -> type(SET); +Inside_RECEIVER : RECEIVER -> type(RECEIVER); +Inside_PARAM : PARAM -> type(PARAM); +Inside_SETPARAM : SETPARAM -> type(SETPARAM); +Inside_DELEGATE : DELEGATE -> type(DELEGATE); +Inside_THROW : THROW -> type(THROW); +Inside_RETURN : RETURN -> type(RETURN); +Inside_CONTINUE : CONTINUE -> type(CONTINUE); +Inside_BREAK : BREAK -> type(BREAK); +Inside_RETURN_AT : RETURN_AT -> type(RETURN_AT); +Inside_CONTINUE_AT : CONTINUE_AT -> type(CONTINUE_AT); +Inside_BREAK_AT : BREAK_AT -> type(BREAK_AT); +Inside_IF : IF -> type(IF); +Inside_ELSE : ELSE -> type(ELSE); +Inside_WHEN : WHEN -> type(WHEN); +Inside_TRY : TRY -> type(TRY); +Inside_CATCH : CATCH -> type(CATCH); +Inside_FINALLY : FINALLY -> type(FINALLY); +Inside_FOR : FOR -> type(FOR); +Inside_DO : DO -> type(DO); +Inside_WHILE : WHILE -> type(WHILE); + +Inside_PUBLIC : PUBLIC -> type(PUBLIC); +Inside_PRIVATE : PRIVATE -> type(PRIVATE); +Inside_PROTECTED : PROTECTED -> type(PROTECTED); +Inside_INTERNAL : INTERNAL -> type(INTERNAL); +Inside_ENUM : ENUM -> type(ENUM); +Inside_SEALED : SEALED -> type(SEALED); +Inside_ANNOTATION : ANNOTATION -> type(ANNOTATION); +Inside_DATA : DATA -> type(DATA); +Inside_INNER : INNER -> type(INNER); +Inside_TAILREC : TAILREC -> type(TAILREC); +Inside_OPERATOR : OPERATOR -> type(OPERATOR); +Inside_INLINE : INLINE -> type(INLINE); +Inside_INFIX : INFIX -> type(INFIX); +Inside_EXTERNAL : EXTERNAL -> type(EXTERNAL); +Inside_SUSPEND : SUSPEND -> type(SUSPEND); +Inside_OVERRIDE : OVERRIDE -> type(OVERRIDE); +Inside_ABSTRACT : ABSTRACT -> type(ABSTRACT); +Inside_FINAL : FINAL -> type(FINAL); +Inside_OPEN : OPEN -> type(OPEN); +Inside_CONST : CONST -> type(CONST); +Inside_LATEINIT : LATEINIT -> type(LATEINIT); +Inside_VARARG : VARARG -> type(VARARG); +Inside_NOINLINE : NOINLINE -> type(NOINLINE); +Inside_CROSSINLINE : CROSSINLINE -> type(CROSSINLINE); +Inside_REIFIED : REIFIED -> type(REIFIED); + +Inside_BooleanLiteral : BooleanLiteral -> type(BooleanLiteral); +Inside_IntegerLiteral : IntegerLiteral -> type(IntegerLiteral); +Inside_HexLiteral : HexLiteral -> type(HexLiteral); +Inside_BinLiteral : BinLiteral -> type(BinLiteral); +Inside_CharacterLiteral : CharacterLiteral -> type(CharacterLiteral); +Inside_RealLiteral : RealLiteral -> type(RealLiteral); +Inside_NullLiteral : NullLiteral -> type(NullLiteral); + +Inside_LongLiteral: LongLiteral -> type(LongLiteral); + +Inside_Identifier : Identifier -> type(Identifier); +Inside_LabelReference : LabelReference -> type(LabelReference); +Inside_LabelDefinition : LabelDefinition -> type(LabelDefinition); +Inside_Comment : (LineComment | DelimitedComment) -> channel(HIDDEN); +Inside_WS : WS -> skip; +Inside_NL : NL -> skip; + +mode LineString; + +QUOTE_CLOSE: '"' -> popMode; + +LineStrRef: FieldIdentifier; + +LineStrText: ~('\\' | '"' | '$')+ | '$'; + +LineStrEscapedChar: '\\' . | UniCharacterLiteral; + +LineStrExprStart: '${' -> pushMode(StringExpression); + +mode MultiLineString; + +TRIPLE_QUOTE_CLOSE: MultiLineStringQuote? '"""' -> popMode; + +MultiLineStringQuote: '"'+; + +MultiLineStrRef: FieldIdentifier; + +MultiLineStrText: ~('\\' | '"' | '$')+ | '$'; + +MultiLineStrEscapedChar: '\\' .; + +MultiLineStrExprStart: '${' -> pushMode(StringExpression); + +MultiLineNL: NL -> skip; + +mode StringExpression; + +StrExpr_RCURL: RCURL -> popMode, type(RCURL); + +StrExpr_LPAREN : LPAREN -> pushMode(Inside), type(LPAREN); +StrExpr_LSQUARE : LSQUARE -> pushMode(Inside), type(LSQUARE); + +StrExpr_RPAREN : ')' -> type(RPAREN); +StrExpr_RSQUARE : ']' -> type(RSQUARE); +StrExpr_LCURL : LCURL -> pushMode(StringExpression), type(LCURL); +StrExpr_DOT : DOT -> type(DOT); +StrExpr_COMMA : COMMA -> type(COMMA); +StrExpr_MULT : MULT -> type(MULT); +StrExpr_MOD : MOD -> type(MOD); +StrExpr_DIV : DIV -> type(DIV); +StrExpr_ADD : ADD -> type(ADD); +StrExpr_SUB : SUB -> type(SUB); +StrExpr_INCR : INCR -> type(INCR); +StrExpr_DECR : DECR -> type(DECR); +StrExpr_CONJ : CONJ -> type(CONJ); +StrExpr_DISJ : DISJ -> type(DISJ); +StrExpr_EXCL : EXCL -> type(EXCL); +StrExpr_COLON : COLON -> type(COLON); +StrExpr_SEMICOLON : SEMICOLON -> type(SEMICOLON); +StrExpr_ASSIGNMENT : ASSIGNMENT -> type(ASSIGNMENT); +StrExpr_ADD_ASSIGNMENT : ADD_ASSIGNMENT -> type(ADD_ASSIGNMENT); +StrExpr_SUB_ASSIGNMENT : SUB_ASSIGNMENT -> type(SUB_ASSIGNMENT); +StrExpr_MULT_ASSIGNMENT : MULT_ASSIGNMENT -> type(MULT_ASSIGNMENT); +StrExpr_DIV_ASSIGNMENT : DIV_ASSIGNMENT -> type(DIV_ASSIGNMENT); +StrExpr_MOD_ASSIGNMENT : MOD_ASSIGNMENT -> type(MOD_ASSIGNMENT); +StrExpr_ARROW : ARROW -> type(ARROW); +StrExpr_DOUBLE_ARROW : DOUBLE_ARROW -> type(DOUBLE_ARROW); +StrExpr_RANGE : RANGE -> type(RANGE); +StrExpr_COLONCOLON : COLONCOLON -> type(COLONCOLON); +StrExpr_Q_COLONCOLON : Q_COLONCOLON -> type(Q_COLONCOLON); +StrExpr_DOUBLE_SEMICOLON : DOUBLE_SEMICOLON -> type(DOUBLE_SEMICOLON); +StrExpr_HASH : HASH -> type(HASH); +StrExpr_AT : AT -> type(AT); +StrExpr_QUEST : QUEST -> type(QUEST); +StrExpr_ELVIS : ELVIS -> type(ELVIS); +StrExpr_LANGLE : LANGLE -> type(LANGLE); +StrExpr_RANGLE : RANGLE -> type(RANGLE); +StrExpr_LE : LE -> type(LE); +StrExpr_GE : GE -> type(GE); +StrExpr_EXCL_EQ : EXCL_EQ -> type(EXCL_EQ); +StrExpr_EXCL_EQEQ : EXCL_EQEQ -> type(EXCL_EQEQ); +StrExpr_AS : AS -> type(IS); +StrExpr_IS : IS -> type(IN); +StrExpr_IN : IN; +StrExpr_NOT_IS : NOT_IS -> type(NOT_IS); +StrExpr_NOT_IN : NOT_IN -> type(NOT_IN); +StrExpr_AS_SAFE : AS_SAFE -> type(AS_SAFE); +StrExpr_EQEQ : EQEQ -> type(EQEQ); +StrExpr_EQEQEQ : EQEQEQ -> type(EQEQEQ); +StrExpr_SINGLE_QUOTE : SINGLE_QUOTE -> type(SINGLE_QUOTE); +StrExpr_QUOTE_OPEN : QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN); +StrExpr_TRIPLE_QUOTE_OPEN: + TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) +; + +StrExpr_BooleanLiteral : BooleanLiteral -> type(BooleanLiteral); +StrExpr_IntegerLiteral : IntegerLiteral -> type(IntegerLiteral); +StrExpr_HexLiteral : HexLiteral -> type(HexLiteral); +StrExpr_BinLiteral : BinLiteral -> type(BinLiteral); +StrExpr_CharacterLiteral : CharacterLiteral -> type(CharacterLiteral); +StrExpr_RealLiteral : RealLiteral -> type(RealLiteral); +StrExpr_NullLiteral : NullLiteral -> type(NullLiteral); +StrExpr_LongLiteral : LongLiteral -> type(LongLiteral); + +StrExpr_Identifier : Identifier -> type(Identifier); +StrExpr_LabelReference : LabelReference -> type(LabelReference); +StrExpr_LabelDefinition : LabelDefinition -> type(LabelDefinition); +StrExpr_Comment : (LineComment | DelimitedComment) -> channel(HIDDEN); +StrExpr_WS : WS -> skip; +StrExpr_NL : NL -> skip; \ No newline at end of file diff --git a/kotlin/kotlin/KotlinParser.g4 b/kotlin/kotlin/KotlinParser.g4 index 147f0a3bca..1eeaba386c 100644 --- a/kotlin/kotlin/KotlinParser.g4 +++ b/kotlin/kotlin/KotlinParser.g4 @@ -10,9 +10,14 @@ * https://github.com/JetBrains/kotlin/tree/master/compiler/testData/psi */ +// $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 KotlinParser; -options { tokenVocab = KotlinLexer; } +options { + tokenVocab = KotlinLexer; +} kotlinFile : NL* preamble anysemi* (topLevelObject (anysemi+ topLevelObject?)*)? EOF @@ -59,11 +64,12 @@ topLevelObject ; classDeclaration - : modifierList? (CLASS | INTERFACE) NL* simpleIdentifier - (NL* typeParameters)? (NL* primaryConstructor)? - (NL* COLON NL* delegationSpecifiers)? - (NL* typeConstraints)? - (NL* classBody | NL* enumClassBody)? + : modifierList? (CLASS | INTERFACE) NL* simpleIdentifier (NL* typeParameters)? ( + NL* primaryConstructor + )? (NL* COLON NL* delegationSpecifiers)? (NL* typeConstraints)? ( + NL* classBody + | NL* enumClassBody + )? ; primaryConstructor @@ -101,14 +107,16 @@ classBody ; classMemberDeclaration - : (classDeclaration - | functionDeclaration - | objectDeclaration - | companionObject - | propertyDeclaration - | anonymousInitializer - | secondaryConstructor - | typeAlias) anysemi+ + : ( + classDeclaration + | functionDeclaration + | objectDeclaration + | companionObject + | propertyDeclaration + | anonymousInitializer + | secondaryConstructor + | typeAlias + ) anysemi+ ; anonymousInitializer @@ -116,7 +124,9 @@ anonymousInitializer ; secondaryConstructor - : modifierList? CONSTRUCTOR NL* functionValueParameters (NL* COLON NL* constructorDelegationCall)? NL* block? + : modifierList? CONSTRUCTOR NL* functionValueParameters ( + NL* COLON NL* constructorDelegationCall + )? NL* block? ; constructorDelegationCall @@ -137,15 +147,9 @@ enumEntry ; functionDeclaration - : modifierList? FUN - (NL* type NL* DOT)? - (NL* typeParameters)? - (NL* receiverType NL* DOT)? - (NL* identifier)? - NL* functionValueParameters - (NL* COLON NL* type)? - (NL* typeConstraints)? - (NL* functionBody)? + : modifierList? FUN (NL* type NL* DOT)? (NL* typeParameters)? (NL* receiverType NL* DOT)? ( + NL* identifier + )? NL* functionValueParameters (NL* COLON NL* type)? (NL* typeConstraints)? (NL* functionBody)? ; functionValueParameters @@ -170,28 +174,24 @@ functionBody ; objectDeclaration - : modifierList? OBJECT - NL* simpleIdentifier - (NL* primaryConstructor)? - (NL* COLON NL* delegationSpecifiers)? - (NL* classBody)? + : modifierList? OBJECT NL* simpleIdentifier (NL* primaryConstructor)? ( + NL* COLON NL* delegationSpecifiers + )? (NL* classBody)? ; companionObject - : modifierList? COMPANION NL* modifierList? OBJECT - (NL* simpleIdentifier)? - (NL* COLON NL* delegationSpecifiers)? - (NL* classBody)? + : modifierList? COMPANION NL* modifierList? OBJECT (NL* simpleIdentifier)? ( + NL* COLON NL* delegationSpecifiers + )? (NL* classBody)? ; propertyDeclaration - : modifierList? (VAL | VAR) - (NL* typeParameters)? - (NL* type NL* DOT)? - (NL* (multiVariableDeclaration | variableDeclaration)) - (NL* typeConstraints)? - (NL* (BY | ASSIGNMENT) NL* expression)? - (NL* getter (semi setter)? | NL* setter (semi getter)?)? + : modifierList? (VAL | VAR) (NL* typeParameters)? (NL* type NL* DOT)? ( + NL* (multiVariableDeclaration | variableDeclaration) + ) (NL* typeConstraints)? (NL* (BY | ASSIGNMENT) NL* expression)? ( + NL* getter (semi setter)? + | NL* setter (semi getter)? + )? ; multiVariableDeclaration @@ -204,12 +204,18 @@ variableDeclaration getter : modifierList? GETTER - | modifierList? GETTER NL* LPAREN RPAREN (NL* COLON NL* type)? NL* (block | ASSIGNMENT NL* expression) + | modifierList? GETTER NL* LPAREN RPAREN (NL* COLON NL* type)? NL* ( + block + | ASSIGNMENT NL* expression + ) ; setter : modifierList? SETTER - | modifierList? SETTER NL* LPAREN (annotations | parameterModifier)* (simpleIdentifier | parameter) RPAREN NL* functionBody + | modifierList? SETTER NL* LPAREN (annotations | parameterModifier)* ( + simpleIdentifier + | parameter + ) RPAREN NL* functionBody ; typeAlias @@ -225,11 +231,7 @@ typeParameter ; type - : typeModifierList? - ( functionType - | parenthesizedType - | nullableType - | typeReference) + : typeModifierList? (functionType | parenthesizedType | nullableType | typeReference) ; typeModifierList @@ -251,7 +253,7 @@ typeReference ; functionType - : (functionTypeReceiver NL* DOT NL*)? functionTypeParameters NL* ARROW (NL* type) + : (functionTypeReceiver NL* DOT NL*)? functionTypeParameters NL* ARROW (NL* type) ; functionTypeReceiver @@ -299,11 +301,7 @@ blockLevelExpression ; declaration - : labelDefinition* - ( classDeclaration - | functionDeclaration - | propertyDeclaration - | typeAlias) + : labelDefinition* (classDeclaration | functionDeclaration | propertyDeclaration | typeAlias) ; expression @@ -366,8 +364,8 @@ atomicExpression : parenthesizedExpression | literalConstant | functionLiteral - | thisExpression // THIS labelReference? - | superExpression // SUPER (LANGLE type RANGLE)? labelReference? + | thisExpression // THIS labelReference? + | superExpression // SUPER (LANGLE type RANGLE)? labelReference? | conditionalExpression // ifExpression, whenExpression | tryExpression | objectLiteral @@ -405,7 +403,8 @@ typeArguments ; typeProjection - : typeProjectionModifierList? type | MULT + : typeProjectionModifierList? type + | MULT ; typeProjectionModifierList @@ -438,7 +437,12 @@ lineStringLiteral ; multiLineStringLiteral - : TRIPLE_QUOTE_OPEN (multiLineStringContent | multiLineStringExpression | lineStringLiteral | MultiLineStringQuote)* TRIPLE_QUOTE_CLOSE + : TRIPLE_QUOTE_OPEN ( + multiLineStringContent + | multiLineStringExpression + | lineStringLiteral + | MultiLineStringQuote + )* TRIPLE_QUOTE_CLOSE ; lineStringContent @@ -462,9 +466,10 @@ multiLineStringExpression ; functionLiteral - : annotations* - ( LCURL NL* statements NL* RCURL - | LCURL NL* lambdaParameters NL* ARROW NL* statements NL* RCURL ) + : annotations* ( + LCURL NL* statements NL* RCURL + | LCURL NL* lambdaParameters NL* ARROW NL* statements NL* RCURL + ) ; lambdaParameters @@ -499,8 +504,9 @@ conditionalExpression ; ifExpression - : IF NL* LPAREN expression RPAREN NL* controlStructureBody? SEMICOLON? - (NL* ELSE NL* controlStructureBody?)? + : IF NL* LPAREN expression RPAREN NL* controlStructureBody? SEMICOLON? ( + NL* ELSE NL* controlStructureBody? + )? ; controlStructureBody @@ -564,8 +570,10 @@ doWhileExpression jumpExpression : THROW NL* expression | (RETURN | RETURN_AT) expression? - | CONTINUE | CONTINUE_AT - | BREAK | BREAK_AT + | CONTINUE + | CONTINUE_AT + | BREAK + | BREAK_AT ; callableReference @@ -597,15 +605,18 @@ comparisonOperator ; inOperator - : IN | NOT_IN + : IN + | NOT_IN ; isOperator - : IS | NOT_IS + : IS + | NOT_IS ; additiveOperator - : ADD | SUB + : ADD + | SUB ; multiplicativeOperation @@ -631,14 +642,17 @@ prefixUnaryOperation ; postfixUnaryOperation - : INCR | DECR | EXCL EXCL + : INCR + | DECR + | EXCL EXCL | callSuffix | arrayAccess | NL* memberAccessOperator postfixUnaryExpression ; memberAccessOperator - : DOT | QUEST DOT + : DOT + | QUEST DOT ; modifierList @@ -646,15 +660,17 @@ modifierList ; modifier - : (classModifier - | memberModifier - | visibilityModifier - | varianceAnnotation - | functionModifier - | propertyModifier - | inheritanceModifier - | parameterModifier - | typeParameterModifier) NL* + : ( + classModifier + | memberModifier + | visibilityModifier + | varianceAnnotation + | functionModifier + | propertyModifier + | inheritanceModifier + | parameterModifier + | typeParameterModifier + ) NL* ; classModifier @@ -678,7 +694,8 @@ visibilityModifier ; varianceAnnotation - : IN | OUT + : IN + | OUT ; functionModifier @@ -791,6 +808,12 @@ simpleIdentifier | SUSPEND ; -semi: NL+ | NL* SEMICOLON NL*; +semi + : NL+ + | NL* SEMICOLON NL* + ; -anysemi: NL | SEMICOLON; +anysemi + : NL + | SEMICOLON + ; \ No newline at end of file diff --git a/kotlin/kotlin/UnicodeClasses.g4 b/kotlin/kotlin/UnicodeClasses.g4 index 14d1caebbf..75b628de95 100644 --- a/kotlin/kotlin/UnicodeClasses.g4 +++ b/kotlin/kotlin/UnicodeClasses.g4 @@ -2,1646 +2,1657 @@ * Taken from http://www.antlr3.org/grammar/1345144569663/AntlrUnicode.txt */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar UnicodeClasses; UNICODE_CLASS_LL: - '\u0061'..'\u007A' | - '\u00B5' | - '\u00DF'..'\u00F6' | - '\u00F8'..'\u00FF' | - '\u0101' | - '\u0103' | - '\u0105' | - '\u0107' | - '\u0109' | - '\u010B' | - '\u010D' | - '\u010F' | - '\u0111' | - '\u0113' | - '\u0115' | - '\u0117' | - '\u0119' | - '\u011B' | - '\u011D' | - '\u011F' | - '\u0121' | - '\u0123' | - '\u0125' | - '\u0127' | - '\u0129' | - '\u012B' | - '\u012D' | - '\u012F' | - '\u0131' | - '\u0133' | - '\u0135' | - '\u0137' | - '\u0138' | - '\u013A' | - '\u013C' | - '\u013E' | - '\u0140' | - '\u0142' | - '\u0144' | - '\u0146' | - '\u0148' | - '\u0149' | - '\u014B' | - '\u014D' | - '\u014F' | - '\u0151' | - '\u0153' | - '\u0155' | - '\u0157' | - '\u0159' | - '\u015B' | - '\u015D' | - '\u015F' | - '\u0161' | - '\u0163' | - '\u0165' | - '\u0167' | - '\u0169' | - '\u016B' | - '\u016D' | - '\u016F' | - '\u0171' | - '\u0173' | - '\u0175' | - '\u0177' | - '\u017A' | - '\u017C' | - '\u017E'..'\u0180' | - '\u0183' | - '\u0185' | - '\u0188' | - '\u018C' | - '\u018D' | - '\u0192' | - '\u0195' | - '\u0199'..'\u019B' | - '\u019E' | - '\u01A1' | - '\u01A3' | - '\u01A5' | - '\u01A8' | - '\u01AA' | - '\u01AB' | - '\u01AD' | - '\u01B0' | - '\u01B4' | - '\u01B6' | - '\u01B9' | - '\u01BA' | - '\u01BD'..'\u01BF' | - '\u01C6' | - '\u01C9' | - '\u01CC' | - '\u01CE' | - '\u01D0' | - '\u01D2' | - '\u01D4' | - '\u01D6' | - '\u01D8' | - '\u01DA' | - '\u01DC' | - '\u01DD' | - '\u01DF' | - '\u01E1' | - '\u01E3' | - '\u01E5' | - '\u01E7' | - '\u01E9' | - '\u01EB' | - '\u01ED' | - '\u01EF' | - '\u01F0' | - '\u01F3' | - '\u01F5' | - '\u01F9' | - '\u01FB' | - '\u01FD' | - '\u01FF' | - '\u0201' | - '\u0203' | - '\u0205' | - '\u0207' | - '\u0209' | - '\u020B' | - '\u020D' | - '\u020F' | - '\u0211' | - '\u0213' | - '\u0215' | - '\u0217' | - '\u0219' | - '\u021B' | - '\u021D' | - '\u021F' | - '\u0221' | - '\u0223' | - '\u0225' | - '\u0227' | - '\u0229' | - '\u022B' | - '\u022D' | - '\u022F' | - '\u0231' | - '\u0233'..'\u0239' | - '\u023C' | - '\u023F' | - '\u0240' | - '\u0242' | - '\u0247' | - '\u0249' | - '\u024B' | - '\u024D' | - '\u024F'..'\u0293' | - '\u0295'..'\u02AF' | - '\u0371' | - '\u0373' | - '\u0377' | - '\u037B'..'\u037D' | - '\u0390' | - '\u03AC'..'\u03CE' | - '\u03D0' | - '\u03D1' | - '\u03D5'..'\u03D7' | - '\u03D9' | - '\u03DB' | - '\u03DD' | - '\u03DF' | - '\u03E1' | - '\u03E3' | - '\u03E5' | - '\u03E7' | - '\u03E9' | - '\u03EB' | - '\u03ED' | - '\u03EF'..'\u03F3' | - '\u03F5' | - '\u03F8' | - '\u03FB' | - '\u03FC' | - '\u0430'..'\u045F' | - '\u0461' | - '\u0463' | - '\u0465' | - '\u0467' | - '\u0469' | - '\u046B' | - '\u046D' | - '\u046F' | - '\u0471' | - '\u0473' | - '\u0475' | - '\u0477' | - '\u0479' | - '\u047B' | - '\u047D' | - '\u047F' | - '\u0481' | - '\u048B' | - '\u048D' | - '\u048F' | - '\u0491' | - '\u0493' | - '\u0495' | - '\u0497' | - '\u0499' | - '\u049B' | - '\u049D' | - '\u049F' | - '\u04A1' | - '\u04A3' | - '\u04A5' | - '\u04A7' | - '\u04A9' | - '\u04AB' | - '\u04AD' | - '\u04AF' | - '\u04B1' | - '\u04B3' | - '\u04B5' | - '\u04B7' | - '\u04B9' | - '\u04BB' | - '\u04BD' | - '\u04BF' | - '\u04C2' | - '\u04C4' | - '\u04C6' | - '\u04C8' | - '\u04CA' | - '\u04CC' | - '\u04CE' | - '\u04CF' | - '\u04D1' | - '\u04D3' | - '\u04D5' | - '\u04D7' | - '\u04D9' | - '\u04DB' | - '\u04DD' | - '\u04DF' | - '\u04E1' | - '\u04E3' | - '\u04E5' | - '\u04E7' | - '\u04E9' | - '\u04EB' | - '\u04ED' | - '\u04EF' | - '\u04F1' | - '\u04F3' | - '\u04F5' | - '\u04F7' | - '\u04F9' | - '\u04FB' | - '\u04FD' | - '\u04FF' | - '\u0501' | - '\u0503' | - '\u0505' | - '\u0507' | - '\u0509' | - '\u050B' | - '\u050D' | - '\u050F' | - '\u0511' | - '\u0513' | - '\u0515' | - '\u0517' | - '\u0519' | - '\u051B' | - '\u051D' | - '\u051F' | - '\u0521' | - '\u0523' | - '\u0525' | - '\u0527' | - '\u0561'..'\u0587' | - '\u1D00'..'\u1D2B' | - '\u1D6B'..'\u1D77' | - '\u1D79'..'\u1D9A' | - '\u1E01' | - '\u1E03' | - '\u1E05' | - '\u1E07' | - '\u1E09' | - '\u1E0B' | - '\u1E0D' | - '\u1E0F' | - '\u1E11' | - '\u1E13' | - '\u1E15' | - '\u1E17' | - '\u1E19' | - '\u1E1B' | - '\u1E1D' | - '\u1E1F' | - '\u1E21' | - '\u1E23' | - '\u1E25' | - '\u1E27' | - '\u1E29' | - '\u1E2B' | - '\u1E2D' | - '\u1E2F' | - '\u1E31' | - '\u1E33' | - '\u1E35' | - '\u1E37' | - '\u1E39' | - '\u1E3B' | - '\u1E3D' | - '\u1E3F' | - '\u1E41' | - '\u1E43' | - '\u1E45' | - '\u1E47' | - '\u1E49' | - '\u1E4B' | - '\u1E4D' | - '\u1E4F' | - '\u1E51' | - '\u1E53' | - '\u1E55' | - '\u1E57' | - '\u1E59' | - '\u1E5B' | - '\u1E5D' | - '\u1E5F' | - '\u1E61' | - '\u1E63' | - '\u1E65' | - '\u1E67' | - '\u1E69' | - '\u1E6B' | - '\u1E6D' | - '\u1E6F' | - '\u1E71' | - '\u1E73' | - '\u1E75' | - '\u1E77' | - '\u1E79' | - '\u1E7B' | - '\u1E7D' | - '\u1E7F' | - '\u1E81' | - '\u1E83' | - '\u1E85' | - '\u1E87' | - '\u1E89' | - '\u1E8B' | - '\u1E8D' | - '\u1E8F' | - '\u1E91' | - '\u1E93' | - '\u1E95'..'\u1E9D' | - '\u1E9F' | - '\u1EA1' | - '\u1EA3' | - '\u1EA5' | - '\u1EA7' | - '\u1EA9' | - '\u1EAB' | - '\u1EAD' | - '\u1EAF' | - '\u1EB1' | - '\u1EB3' | - '\u1EB5' | - '\u1EB7' | - '\u1EB9' | - '\u1EBB' | - '\u1EBD' | - '\u1EBF' | - '\u1EC1' | - '\u1EC3' | - '\u1EC5' | - '\u1EC7' | - '\u1EC9' | - '\u1ECB' | - '\u1ECD' | - '\u1ECF' | - '\u1ED1' | - '\u1ED3' | - '\u1ED5' | - '\u1ED7' | - '\u1ED9' | - '\u1EDB' | - '\u1EDD' | - '\u1EDF' | - '\u1EE1' | - '\u1EE3' | - '\u1EE5' | - '\u1EE7' | - '\u1EE9' | - '\u1EEB' | - '\u1EED' | - '\u1EEF' | - '\u1EF1' | - '\u1EF3' | - '\u1EF5' | - '\u1EF7' | - '\u1EF9' | - '\u1EFB' | - '\u1EFD' | - '\u1EFF'..'\u1F07' | - '\u1F10'..'\u1F15' | - '\u1F20'..'\u1F27' | - '\u1F30'..'\u1F37' | - '\u1F40'..'\u1F45' | - '\u1F50'..'\u1F57' | - '\u1F60'..'\u1F67' | - '\u1F70'..'\u1F7D' | - '\u1F80'..'\u1F87' | - '\u1F90'..'\u1F97' | - '\u1FA0'..'\u1FA7' | - '\u1FB0'..'\u1FB4' | - '\u1FB6' | - '\u1FB7' | - '\u1FBE' | - '\u1FC2'..'\u1FC4' | - '\u1FC6' | - '\u1FC7' | - '\u1FD0'..'\u1FD3' | - '\u1FD6' | - '\u1FD7' | - '\u1FE0'..'\u1FE7' | - '\u1FF2'..'\u1FF4' | - '\u1FF6' | - '\u1FF7' | - '\u210A' | - '\u210E' | - '\u210F' | - '\u2113' | - '\u212F' | - '\u2134' | - '\u2139' | - '\u213C' | - '\u213D' | - '\u2146'..'\u2149' | - '\u214E' | - '\u2184' | - '\u2C30'..'\u2C5E' | - '\u2C61' | - '\u2C65' | - '\u2C66' | - '\u2C68' | - '\u2C6A' | - '\u2C6C' | - '\u2C71' | - '\u2C73' | - '\u2C74' | - '\u2C76'..'\u2C7B' | - '\u2C81' | - '\u2C83' | - '\u2C85' | - '\u2C87' | - '\u2C89' | - '\u2C8B' | - '\u2C8D' | - '\u2C8F' | - '\u2C91' | - '\u2C93' | - '\u2C95' | - '\u2C97' | - '\u2C99' | - '\u2C9B' | - '\u2C9D' | - '\u2C9F' | - '\u2CA1' | - '\u2CA3' | - '\u2CA5' | - '\u2CA7' | - '\u2CA9' | - '\u2CAB' | - '\u2CAD' | - '\u2CAF' | - '\u2CB1' | - '\u2CB3' | - '\u2CB5' | - '\u2CB7' | - '\u2CB9' | - '\u2CBB' | - '\u2CBD' | - '\u2CBF' | - '\u2CC1' | - '\u2CC3' | - '\u2CC5' | - '\u2CC7' | - '\u2CC9' | - '\u2CCB' | - '\u2CCD' | - '\u2CCF' | - '\u2CD1' | - '\u2CD3' | - '\u2CD5' | - '\u2CD7' | - '\u2CD9' | - '\u2CDB' | - '\u2CDD' | - '\u2CDF' | - '\u2CE1' | - '\u2CE3' | - '\u2CE4' | - '\u2CEC' | - '\u2CEE' | - '\u2CF3' | - '\u2D00'..'\u2D25' | - '\u2D27' | - '\u2D2D' | - '\uA641' | - '\uA643' | - '\uA645' | - '\uA647' | - '\uA649' | - '\uA64B' | - '\uA64D' | - '\uA64F' | - '\uA651' | - '\uA653' | - '\uA655' | - '\uA657' | - '\uA659' | - '\uA65B' | - '\uA65D' | - '\uA65F' | - '\uA661' | - '\uA663' | - '\uA665' | - '\uA667' | - '\uA669' | - '\uA66B' | - '\uA66D' | - '\uA681' | - '\uA683' | - '\uA685' | - '\uA687' | - '\uA689' | - '\uA68B' | - '\uA68D' | - '\uA68F' | - '\uA691' | - '\uA693' | - '\uA695' | - '\uA697' | - '\uA723' | - '\uA725' | - '\uA727' | - '\uA729' | - '\uA72B' | - '\uA72D' | - '\uA72F'..'\uA731' | - '\uA733' | - '\uA735' | - '\uA737' | - '\uA739' | - '\uA73B' | - '\uA73D' | - '\uA73F' | - '\uA741' | - '\uA743' | - '\uA745' | - '\uA747' | - '\uA749' | - '\uA74B' | - '\uA74D' | - '\uA74F' | - '\uA751' | - '\uA753' | - '\uA755' | - '\uA757' | - '\uA759' | - '\uA75B' | - '\uA75D' | - '\uA75F' | - '\uA761' | - '\uA763' | - '\uA765' | - '\uA767' | - '\uA769' | - '\uA76B' | - '\uA76D' | - '\uA76F' | - '\uA771'..'\uA778' | - '\uA77A' | - '\uA77C' | - '\uA77F' | - '\uA781' | - '\uA783' | - '\uA785' | - '\uA787' | - '\uA78C' | - '\uA78E' | - '\uA791' | - '\uA793' | - '\uA7A1' | - '\uA7A3' | - '\uA7A5' | - '\uA7A7' | - '\uA7A9' | - '\uA7FA' | - '\uFB00'..'\uFB06' | - '\uFB13'..'\uFB17' | - '\uFF41'..'\uFF5A'; + '\u0061' ..'\u007A' + | '\u00B5' + | '\u00DF' ..'\u00F6' + | '\u00F8' ..'\u00FF' + | '\u0101' + | '\u0103' + | '\u0105' + | '\u0107' + | '\u0109' + | '\u010B' + | '\u010D' + | '\u010F' + | '\u0111' + | '\u0113' + | '\u0115' + | '\u0117' + | '\u0119' + | '\u011B' + | '\u011D' + | '\u011F' + | '\u0121' + | '\u0123' + | '\u0125' + | '\u0127' + | '\u0129' + | '\u012B' + | '\u012D' + | '\u012F' + | '\u0131' + | '\u0133' + | '\u0135' + | '\u0137' + | '\u0138' + | '\u013A' + | '\u013C' + | '\u013E' + | '\u0140' + | '\u0142' + | '\u0144' + | '\u0146' + | '\u0148' + | '\u0149' + | '\u014B' + | '\u014D' + | '\u014F' + | '\u0151' + | '\u0153' + | '\u0155' + | '\u0157' + | '\u0159' + | '\u015B' + | '\u015D' + | '\u015F' + | '\u0161' + | '\u0163' + | '\u0165' + | '\u0167' + | '\u0169' + | '\u016B' + | '\u016D' + | '\u016F' + | '\u0171' + | '\u0173' + | '\u0175' + | '\u0177' + | '\u017A' + | '\u017C' + | '\u017E' ..'\u0180' + | '\u0183' + | '\u0185' + | '\u0188' + | '\u018C' + | '\u018D' + | '\u0192' + | '\u0195' + | '\u0199' ..'\u019B' + | '\u019E' + | '\u01A1' + | '\u01A3' + | '\u01A5' + | '\u01A8' + | '\u01AA' + | '\u01AB' + | '\u01AD' + | '\u01B0' + | '\u01B4' + | '\u01B6' + | '\u01B9' + | '\u01BA' + | '\u01BD' ..'\u01BF' + | '\u01C6' + | '\u01C9' + | '\u01CC' + | '\u01CE' + | '\u01D0' + | '\u01D2' + | '\u01D4' + | '\u01D6' + | '\u01D8' + | '\u01DA' + | '\u01DC' + | '\u01DD' + | '\u01DF' + | '\u01E1' + | '\u01E3' + | '\u01E5' + | '\u01E7' + | '\u01E9' + | '\u01EB' + | '\u01ED' + | '\u01EF' + | '\u01F0' + | '\u01F3' + | '\u01F5' + | '\u01F9' + | '\u01FB' + | '\u01FD' + | '\u01FF' + | '\u0201' + | '\u0203' + | '\u0205' + | '\u0207' + | '\u0209' + | '\u020B' + | '\u020D' + | '\u020F' + | '\u0211' + | '\u0213' + | '\u0215' + | '\u0217' + | '\u0219' + | '\u021B' + | '\u021D' + | '\u021F' + | '\u0221' + | '\u0223' + | '\u0225' + | '\u0227' + | '\u0229' + | '\u022B' + | '\u022D' + | '\u022F' + | '\u0231' + | '\u0233' ..'\u0239' + | '\u023C' + | '\u023F' + | '\u0240' + | '\u0242' + | '\u0247' + | '\u0249' + | '\u024B' + | '\u024D' + | '\u024F' ..'\u0293' + | '\u0295' ..'\u02AF' + | '\u0371' + | '\u0373' + | '\u0377' + | '\u037B' ..'\u037D' + | '\u0390' + | '\u03AC' ..'\u03CE' + | '\u03D0' + | '\u03D1' + | '\u03D5' ..'\u03D7' + | '\u03D9' + | '\u03DB' + | '\u03DD' + | '\u03DF' + | '\u03E1' + | '\u03E3' + | '\u03E5' + | '\u03E7' + | '\u03E9' + | '\u03EB' + | '\u03ED' + | '\u03EF' ..'\u03F3' + | '\u03F5' + | '\u03F8' + | '\u03FB' + | '\u03FC' + | '\u0430' ..'\u045F' + | '\u0461' + | '\u0463' + | '\u0465' + | '\u0467' + | '\u0469' + | '\u046B' + | '\u046D' + | '\u046F' + | '\u0471' + | '\u0473' + | '\u0475' + | '\u0477' + | '\u0479' + | '\u047B' + | '\u047D' + | '\u047F' + | '\u0481' + | '\u048B' + | '\u048D' + | '\u048F' + | '\u0491' + | '\u0493' + | '\u0495' + | '\u0497' + | '\u0499' + | '\u049B' + | '\u049D' + | '\u049F' + | '\u04A1' + | '\u04A3' + | '\u04A5' + | '\u04A7' + | '\u04A9' + | '\u04AB' + | '\u04AD' + | '\u04AF' + | '\u04B1' + | '\u04B3' + | '\u04B5' + | '\u04B7' + | '\u04B9' + | '\u04BB' + | '\u04BD' + | '\u04BF' + | '\u04C2' + | '\u04C4' + | '\u04C6' + | '\u04C8' + | '\u04CA' + | '\u04CC' + | '\u04CE' + | '\u04CF' + | '\u04D1' + | '\u04D3' + | '\u04D5' + | '\u04D7' + | '\u04D9' + | '\u04DB' + | '\u04DD' + | '\u04DF' + | '\u04E1' + | '\u04E3' + | '\u04E5' + | '\u04E7' + | '\u04E9' + | '\u04EB' + | '\u04ED' + | '\u04EF' + | '\u04F1' + | '\u04F3' + | '\u04F5' + | '\u04F7' + | '\u04F9' + | '\u04FB' + | '\u04FD' + | '\u04FF' + | '\u0501' + | '\u0503' + | '\u0505' + | '\u0507' + | '\u0509' + | '\u050B' + | '\u050D' + | '\u050F' + | '\u0511' + | '\u0513' + | '\u0515' + | '\u0517' + | '\u0519' + | '\u051B' + | '\u051D' + | '\u051F' + | '\u0521' + | '\u0523' + | '\u0525' + | '\u0527' + | '\u0561' ..'\u0587' + | '\u1D00' ..'\u1D2B' + | '\u1D6B' ..'\u1D77' + | '\u1D79' ..'\u1D9A' + | '\u1E01' + | '\u1E03' + | '\u1E05' + | '\u1E07' + | '\u1E09' + | '\u1E0B' + | '\u1E0D' + | '\u1E0F' + | '\u1E11' + | '\u1E13' + | '\u1E15' + | '\u1E17' + | '\u1E19' + | '\u1E1B' + | '\u1E1D' + | '\u1E1F' + | '\u1E21' + | '\u1E23' + | '\u1E25' + | '\u1E27' + | '\u1E29' + | '\u1E2B' + | '\u1E2D' + | '\u1E2F' + | '\u1E31' + | '\u1E33' + | '\u1E35' + | '\u1E37' + | '\u1E39' + | '\u1E3B' + | '\u1E3D' + | '\u1E3F' + | '\u1E41' + | '\u1E43' + | '\u1E45' + | '\u1E47' + | '\u1E49' + | '\u1E4B' + | '\u1E4D' + | '\u1E4F' + | '\u1E51' + | '\u1E53' + | '\u1E55' + | '\u1E57' + | '\u1E59' + | '\u1E5B' + | '\u1E5D' + | '\u1E5F' + | '\u1E61' + | '\u1E63' + | '\u1E65' + | '\u1E67' + | '\u1E69' + | '\u1E6B' + | '\u1E6D' + | '\u1E6F' + | '\u1E71' + | '\u1E73' + | '\u1E75' + | '\u1E77' + | '\u1E79' + | '\u1E7B' + | '\u1E7D' + | '\u1E7F' + | '\u1E81' + | '\u1E83' + | '\u1E85' + | '\u1E87' + | '\u1E89' + | '\u1E8B' + | '\u1E8D' + | '\u1E8F' + | '\u1E91' + | '\u1E93' + | '\u1E95' ..'\u1E9D' + | '\u1E9F' + | '\u1EA1' + | '\u1EA3' + | '\u1EA5' + | '\u1EA7' + | '\u1EA9' + | '\u1EAB' + | '\u1EAD' + | '\u1EAF' + | '\u1EB1' + | '\u1EB3' + | '\u1EB5' + | '\u1EB7' + | '\u1EB9' + | '\u1EBB' + | '\u1EBD' + | '\u1EBF' + | '\u1EC1' + | '\u1EC3' + | '\u1EC5' + | '\u1EC7' + | '\u1EC9' + | '\u1ECB' + | '\u1ECD' + | '\u1ECF' + | '\u1ED1' + | '\u1ED3' + | '\u1ED5' + | '\u1ED7' + | '\u1ED9' + | '\u1EDB' + | '\u1EDD' + | '\u1EDF' + | '\u1EE1' + | '\u1EE3' + | '\u1EE5' + | '\u1EE7' + | '\u1EE9' + | '\u1EEB' + | '\u1EED' + | '\u1EEF' + | '\u1EF1' + | '\u1EF3' + | '\u1EF5' + | '\u1EF7' + | '\u1EF9' + | '\u1EFB' + | '\u1EFD' + | '\u1EFF' ..'\u1F07' + | '\u1F10' ..'\u1F15' + | '\u1F20' ..'\u1F27' + | '\u1F30' ..'\u1F37' + | '\u1F40' ..'\u1F45' + | '\u1F50' ..'\u1F57' + | '\u1F60' ..'\u1F67' + | '\u1F70' ..'\u1F7D' + | '\u1F80' ..'\u1F87' + | '\u1F90' ..'\u1F97' + | '\u1FA0' ..'\u1FA7' + | '\u1FB0' ..'\u1FB4' + | '\u1FB6' + | '\u1FB7' + | '\u1FBE' + | '\u1FC2' ..'\u1FC4' + | '\u1FC6' + | '\u1FC7' + | '\u1FD0' ..'\u1FD3' + | '\u1FD6' + | '\u1FD7' + | '\u1FE0' ..'\u1FE7' + | '\u1FF2' ..'\u1FF4' + | '\u1FF6' + | '\u1FF7' + | '\u210A' + | '\u210E' + | '\u210F' + | '\u2113' + | '\u212F' + | '\u2134' + | '\u2139' + | '\u213C' + | '\u213D' + | '\u2146' ..'\u2149' + | '\u214E' + | '\u2184' + | '\u2C30' ..'\u2C5E' + | '\u2C61' + | '\u2C65' + | '\u2C66' + | '\u2C68' + | '\u2C6A' + | '\u2C6C' + | '\u2C71' + | '\u2C73' + | '\u2C74' + | '\u2C76' ..'\u2C7B' + | '\u2C81' + | '\u2C83' + | '\u2C85' + | '\u2C87' + | '\u2C89' + | '\u2C8B' + | '\u2C8D' + | '\u2C8F' + | '\u2C91' + | '\u2C93' + | '\u2C95' + | '\u2C97' + | '\u2C99' + | '\u2C9B' + | '\u2C9D' + | '\u2C9F' + | '\u2CA1' + | '\u2CA3' + | '\u2CA5' + | '\u2CA7' + | '\u2CA9' + | '\u2CAB' + | '\u2CAD' + | '\u2CAF' + | '\u2CB1' + | '\u2CB3' + | '\u2CB5' + | '\u2CB7' + | '\u2CB9' + | '\u2CBB' + | '\u2CBD' + | '\u2CBF' + | '\u2CC1' + | '\u2CC3' + | '\u2CC5' + | '\u2CC7' + | '\u2CC9' + | '\u2CCB' + | '\u2CCD' + | '\u2CCF' + | '\u2CD1' + | '\u2CD3' + | '\u2CD5' + | '\u2CD7' + | '\u2CD9' + | '\u2CDB' + | '\u2CDD' + | '\u2CDF' + | '\u2CE1' + | '\u2CE3' + | '\u2CE4' + | '\u2CEC' + | '\u2CEE' + | '\u2CF3' + | '\u2D00' ..'\u2D25' + | '\u2D27' + | '\u2D2D' + | '\uA641' + | '\uA643' + | '\uA645' + | '\uA647' + | '\uA649' + | '\uA64B' + | '\uA64D' + | '\uA64F' + | '\uA651' + | '\uA653' + | '\uA655' + | '\uA657' + | '\uA659' + | '\uA65B' + | '\uA65D' + | '\uA65F' + | '\uA661' + | '\uA663' + | '\uA665' + | '\uA667' + | '\uA669' + | '\uA66B' + | '\uA66D' + | '\uA681' + | '\uA683' + | '\uA685' + | '\uA687' + | '\uA689' + | '\uA68B' + | '\uA68D' + | '\uA68F' + | '\uA691' + | '\uA693' + | '\uA695' + | '\uA697' + | '\uA723' + | '\uA725' + | '\uA727' + | '\uA729' + | '\uA72B' + | '\uA72D' + | '\uA72F' ..'\uA731' + | '\uA733' + | '\uA735' + | '\uA737' + | '\uA739' + | '\uA73B' + | '\uA73D' + | '\uA73F' + | '\uA741' + | '\uA743' + | '\uA745' + | '\uA747' + | '\uA749' + | '\uA74B' + | '\uA74D' + | '\uA74F' + | '\uA751' + | '\uA753' + | '\uA755' + | '\uA757' + | '\uA759' + | '\uA75B' + | '\uA75D' + | '\uA75F' + | '\uA761' + | '\uA763' + | '\uA765' + | '\uA767' + | '\uA769' + | '\uA76B' + | '\uA76D' + | '\uA76F' + | '\uA771' ..'\uA778' + | '\uA77A' + | '\uA77C' + | '\uA77F' + | '\uA781' + | '\uA783' + | '\uA785' + | '\uA787' + | '\uA78C' + | '\uA78E' + | '\uA791' + | '\uA793' + | '\uA7A1' + | '\uA7A3' + | '\uA7A5' + | '\uA7A7' + | '\uA7A9' + | '\uA7FA' + | '\uFB00' ..'\uFB06' + | '\uFB13' ..'\uFB17' + | '\uFF41' ..'\uFF5A' +; UNICODE_CLASS_LM: - '\u02B0'..'\u02C1' | - '\u02C6'..'\u02D1' | - '\u02E0'..'\u02E4' | - '\u02EC' | - '\u02EE' | - '\u0374' | - '\u037A' | - '\u0559' | - '\u0640' | - '\u06E5' | - '\u06E6' | - '\u07F4' | - '\u07F5' | - '\u07FA' | - '\u081A' | - '\u0824' | - '\u0828' | - '\u0971' | - '\u0E46' | - '\u0EC6' | - '\u10FC' | - '\u17D7' | - '\u1843' | - '\u1AA7' | - '\u1C78'..'\u1C7D' | - '\u1D2C'..'\u1D6A' | - '\u1D78' | - '\u1D9B'..'\u1DBF' | - '\u2071' | - '\u207F' | - '\u2090'..'\u209C' | - '\u2C7C' | - '\u2C7D' | - '\u2D6F' | - '\u2E2F' | - '\u3005' | - '\u3031'..'\u3035' | - '\u303B' | - '\u309D' | - '\u309E' | - '\u30FC'..'\u30FE' | - '\uA015' | - '\uA4F8'..'\uA4FD' | - '\uA60C' | - '\uA67F' | - '\uA717'..'\uA71F' | - '\uA770' | - '\uA788' | - '\uA7F8' | - '\uA7F9' | - '\uA9CF' | - '\uAA70' | - '\uAADD' | - '\uAAF3' | - '\uAAF4' | - '\uFF70' | - '\uFF9E' | - '\uFF9F'; + '\u02B0' ..'\u02C1' + | '\u02C6' ..'\u02D1' + | '\u02E0' ..'\u02E4' + | '\u02EC' + | '\u02EE' + | '\u0374' + | '\u037A' + | '\u0559' + | '\u0640' + | '\u06E5' + | '\u06E6' + | '\u07F4' + | '\u07F5' + | '\u07FA' + | '\u081A' + | '\u0824' + | '\u0828' + | '\u0971' + | '\u0E46' + | '\u0EC6' + | '\u10FC' + | '\u17D7' + | '\u1843' + | '\u1AA7' + | '\u1C78' ..'\u1C7D' + | '\u1D2C' ..'\u1D6A' + | '\u1D78' + | '\u1D9B' ..'\u1DBF' + | '\u2071' + | '\u207F' + | '\u2090' ..'\u209C' + | '\u2C7C' + | '\u2C7D' + | '\u2D6F' + | '\u2E2F' + | '\u3005' + | '\u3031' ..'\u3035' + | '\u303B' + | '\u309D' + | '\u309E' + | '\u30FC' ..'\u30FE' + | '\uA015' + | '\uA4F8' ..'\uA4FD' + | '\uA60C' + | '\uA67F' + | '\uA717' ..'\uA71F' + | '\uA770' + | '\uA788' + | '\uA7F8' + | '\uA7F9' + | '\uA9CF' + | '\uAA70' + | '\uAADD' + | '\uAAF3' + | '\uAAF4' + | '\uFF70' + | '\uFF9E' + | '\uFF9F' +; UNICODE_CLASS_LO: - '\u00AA' | - '\u00BA' | - '\u01BB' | - '\u01C0'..'\u01C3' | - '\u0294' | - '\u05D0'..'\u05EA' | - '\u05F0'..'\u05F2' | - '\u0620'..'\u063F' | - '\u0641'..'\u064A' | - '\u066E' | - '\u066F' | - '\u0671'..'\u06D3' | - '\u06D5' | - '\u06EE' | - '\u06EF' | - '\u06FA'..'\u06FC' | - '\u06FF' | - '\u0710' | - '\u0712'..'\u072F' | - '\u074D'..'\u07A5' | - '\u07B1' | - '\u07CA'..'\u07EA' | - '\u0800'..'\u0815' | - '\u0840'..'\u0858' | - '\u08A0' | - '\u08A2'..'\u08AC' | - '\u0904'..'\u0939' | - '\u093D' | - '\u0950' | - '\u0958'..'\u0961' | - '\u0972'..'\u0977' | - '\u0979'..'\u097F' | - '\u0985'..'\u098C' | - '\u098F' | - '\u0990' | - '\u0993'..'\u09A8' | - '\u09AA'..'\u09B0' | - '\u09B2' | - '\u09B6'..'\u09B9' | - '\u09BD' | - '\u09CE' | - '\u09DC' | - '\u09DD' | - '\u09DF'..'\u09E1' | - '\u09F0' | - '\u09F1' | - '\u0A05'..'\u0A0A' | - '\u0A0F' | - '\u0A10' | - '\u0A13'..'\u0A28' | - '\u0A2A'..'\u0A30' | - '\u0A32' | - '\u0A33' | - '\u0A35' | - '\u0A36' | - '\u0A38' | - '\u0A39' | - '\u0A59'..'\u0A5C' | - '\u0A5E' | - '\u0A72'..'\u0A74' | - '\u0A85'..'\u0A8D' | - '\u0A8F'..'\u0A91' | - '\u0A93'..'\u0AA8' | - '\u0AAA'..'\u0AB0' | - '\u0AB2' | - '\u0AB3' | - '\u0AB5'..'\u0AB9' | - '\u0ABD' | - '\u0AD0' | - '\u0AE0' | - '\u0AE1' | - '\u0B05'..'\u0B0C' | - '\u0B0F' | - '\u0B10' | - '\u0B13'..'\u0B28' | - '\u0B2A'..'\u0B30' | - '\u0B32' | - '\u0B33' | - '\u0B35'..'\u0B39' | - '\u0B3D' | - '\u0B5C' | - '\u0B5D' | - '\u0B5F'..'\u0B61' | - '\u0B71' | - '\u0B83' | - '\u0B85'..'\u0B8A' | - '\u0B8E'..'\u0B90' | - '\u0B92'..'\u0B95' | - '\u0B99' | - '\u0B9A' | - '\u0B9C' | - '\u0B9E' | - '\u0B9F' | - '\u0BA3' | - '\u0BA4' | - '\u0BA8'..'\u0BAA' | - '\u0BAE'..'\u0BB9' | - '\u0BD0' | - '\u0C05'..'\u0C0C' | - '\u0C0E'..'\u0C10' | - '\u0C12'..'\u0C28' | - '\u0C2A'..'\u0C33' | - '\u0C35'..'\u0C39' | - '\u0C3D' | - '\u0C58' | - '\u0C59' | - '\u0C60' | - '\u0C61' | - '\u0C85'..'\u0C8C' | - '\u0C8E'..'\u0C90' | - '\u0C92'..'\u0CA8' | - '\u0CAA'..'\u0CB3' | - '\u0CB5'..'\u0CB9' | - '\u0CBD' | - '\u0CDE' | - '\u0CE0' | - '\u0CE1' | - '\u0CF1' | - '\u0CF2' | - '\u0D05'..'\u0D0C' | - '\u0D0E'..'\u0D10' | - '\u0D12'..'\u0D3A' | - '\u0D3D' | - '\u0D4E' | - '\u0D60' | - '\u0D61' | - '\u0D7A'..'\u0D7F' | - '\u0D85'..'\u0D96' | - '\u0D9A'..'\u0DB1' | - '\u0DB3'..'\u0DBB' | - '\u0DBD' | - '\u0DC0'..'\u0DC6' | - '\u0E01'..'\u0E30' | - '\u0E32' | - '\u0E33' | - '\u0E40'..'\u0E45' | - '\u0E81' | - '\u0E82' | - '\u0E84' | - '\u0E87' | - '\u0E88' | - '\u0E8A' | - '\u0E8D' | - '\u0E94'..'\u0E97' | - '\u0E99'..'\u0E9F' | - '\u0EA1'..'\u0EA3' | - '\u0EA5' | - '\u0EA7' | - '\u0EAA' | - '\u0EAB' | - '\u0EAD'..'\u0EB0' | - '\u0EB2' | - '\u0EB3' | - '\u0EBD' | - '\u0EC0'..'\u0EC4' | - '\u0EDC'..'\u0EDF' | - '\u0F00' | - '\u0F40'..'\u0F47' | - '\u0F49'..'\u0F6C' | - '\u0F88'..'\u0F8C' | - '\u1000'..'\u102A' | - '\u103F' | - '\u1050'..'\u1055' | - '\u105A'..'\u105D' | - '\u1061' | - '\u1065' | - '\u1066' | - '\u106E'..'\u1070' | - '\u1075'..'\u1081' | - '\u108E' | - '\u10D0'..'\u10FA' | - '\u10FD'..'\u1248' | - '\u124A'..'\u124D' | - '\u1250'..'\u1256' | - '\u1258' | - '\u125A'..'\u125D' | - '\u1260'..'\u1288' | - '\u128A'..'\u128D' | - '\u1290'..'\u12B0' | - '\u12B2'..'\u12B5' | - '\u12B8'..'\u12BE' | - '\u12C0' | - '\u12C2'..'\u12C5' | - '\u12C8'..'\u12D6' | - '\u12D8'..'\u1310' | - '\u1312'..'\u1315' | - '\u1318'..'\u135A' | - '\u1380'..'\u138F' | - '\u13A0'..'\u13F4' | - '\u1401'..'\u166C' | - '\u166F'..'\u167F' | - '\u1681'..'\u169A' | - '\u16A0'..'\u16EA' | - '\u1700'..'\u170C' | - '\u170E'..'\u1711' | - '\u1720'..'\u1731' | - '\u1740'..'\u1751' | - '\u1760'..'\u176C' | - '\u176E'..'\u1770' | - '\u1780'..'\u17B3' | - '\u17DC' | - '\u1820'..'\u1842' | - '\u1844'..'\u1877' | - '\u1880'..'\u18A8' | - '\u18AA' | - '\u18B0'..'\u18F5' | - '\u1900'..'\u191C' | - '\u1950'..'\u196D' | - '\u1970'..'\u1974' | - '\u1980'..'\u19AB' | - '\u19C1'..'\u19C7' | - '\u1A00'..'\u1A16' | - '\u1A20'..'\u1A54' | - '\u1B05'..'\u1B33' | - '\u1B45'..'\u1B4B' | - '\u1B83'..'\u1BA0' | - '\u1BAE' | - '\u1BAF' | - '\u1BBA'..'\u1BE5' | - '\u1C00'..'\u1C23' | - '\u1C4D'..'\u1C4F' | - '\u1C5A'..'\u1C77' | - '\u1CE9'..'\u1CEC' | - '\u1CEE'..'\u1CF1' | - '\u1CF5' | - '\u1CF6' | - '\u2135'..'\u2138' | - '\u2D30'..'\u2D67' | - '\u2D80'..'\u2D96' | - '\u2DA0'..'\u2DA6' | - '\u2DA8'..'\u2DAE' | - '\u2DB0'..'\u2DB6' | - '\u2DB8'..'\u2DBE' | - '\u2DC0'..'\u2DC6' | - '\u2DC8'..'\u2DCE' | - '\u2DD0'..'\u2DD6' | - '\u2DD8'..'\u2DDE' | - '\u3006' | - '\u303C' | - '\u3041'..'\u3096' | - '\u309F' | - '\u30A1'..'\u30FA' | - '\u30FF' | - '\u3105'..'\u312D' | - '\u3131'..'\u318E' | - '\u31A0'..'\u31BA' | - '\u31F0'..'\u31FF' | - '\u3400' | - '\u4DB5' | - '\u4E00' | - '\u9FCC' | - '\uA000'..'\uA014' | - '\uA016'..'\uA48C' | - '\uA4D0'..'\uA4F7' | - '\uA500'..'\uA60B' | - '\uA610'..'\uA61F' | - '\uA62A' | - '\uA62B' | - '\uA66E' | - '\uA6A0'..'\uA6E5' | - '\uA7FB'..'\uA801' | - '\uA803'..'\uA805' | - '\uA807'..'\uA80A' | - '\uA80C'..'\uA822' | - '\uA840'..'\uA873' | - '\uA882'..'\uA8B3' | - '\uA8F2'..'\uA8F7' | - '\uA8FB' | - '\uA90A'..'\uA925' | - '\uA930'..'\uA946' | - '\uA960'..'\uA97C' | - '\uA984'..'\uA9B2' | - '\uAA00'..'\uAA28' | - '\uAA40'..'\uAA42' | - '\uAA44'..'\uAA4B' | - '\uAA60'..'\uAA6F' | - '\uAA71'..'\uAA76' | - '\uAA7A' | - '\uAA80'..'\uAAAF' | - '\uAAB1' | - '\uAAB5' | - '\uAAB6' | - '\uAAB9'..'\uAABD' | - '\uAAC0' | - '\uAAC2' | - '\uAADB' | - '\uAADC' | - '\uAAE0'..'\uAAEA' | - '\uAAF2' | - '\uAB01'..'\uAB06' | - '\uAB09'..'\uAB0E' | - '\uAB11'..'\uAB16' | - '\uAB20'..'\uAB26' | - '\uAB28'..'\uAB2E' | - '\uABC0'..'\uABE2' | - '\uAC00' | - '\uD7A3' | - '\uD7B0'..'\uD7C6' | - '\uD7CB'..'\uD7FB' | - '\uF900'..'\uFA6D' | - '\uFA70'..'\uFAD9' | - '\uFB1D' | - '\uFB1F'..'\uFB28' | - '\uFB2A'..'\uFB36' | - '\uFB38'..'\uFB3C' | - '\uFB3E' | - '\uFB40' | - '\uFB41' | - '\uFB43' | - '\uFB44' | - '\uFB46'..'\uFBB1' | - '\uFBD3'..'\uFD3D' | - '\uFD50'..'\uFD8F' | - '\uFD92'..'\uFDC7' | - '\uFDF0'..'\uFDFB' | - '\uFE70'..'\uFE74' | - '\uFE76'..'\uFEFC' | - '\uFF66'..'\uFF6F' | - '\uFF71'..'\uFF9D' | - '\uFFA0'..'\uFFBE' | - '\uFFC2'..'\uFFC7' | - '\uFFCA'..'\uFFCF' | - '\uFFD2'..'\uFFD7' | - '\uFFDA'..'\uFFDC'; + '\u00AA' + | '\u00BA' + | '\u01BB' + | '\u01C0' ..'\u01C3' + | '\u0294' + | '\u05D0' ..'\u05EA' + | '\u05F0' ..'\u05F2' + | '\u0620' ..'\u063F' + | '\u0641' ..'\u064A' + | '\u066E' + | '\u066F' + | '\u0671' ..'\u06D3' + | '\u06D5' + | '\u06EE' + | '\u06EF' + | '\u06FA' ..'\u06FC' + | '\u06FF' + | '\u0710' + | '\u0712' ..'\u072F' + | '\u074D' ..'\u07A5' + | '\u07B1' + | '\u07CA' ..'\u07EA' + | '\u0800' ..'\u0815' + | '\u0840' ..'\u0858' + | '\u08A0' + | '\u08A2' ..'\u08AC' + | '\u0904' ..'\u0939' + | '\u093D' + | '\u0950' + | '\u0958' ..'\u0961' + | '\u0972' ..'\u0977' + | '\u0979' ..'\u097F' + | '\u0985' ..'\u098C' + | '\u098F' + | '\u0990' + | '\u0993' ..'\u09A8' + | '\u09AA' ..'\u09B0' + | '\u09B2' + | '\u09B6' ..'\u09B9' + | '\u09BD' + | '\u09CE' + | '\u09DC' + | '\u09DD' + | '\u09DF' ..'\u09E1' + | '\u09F0' + | '\u09F1' + | '\u0A05' ..'\u0A0A' + | '\u0A0F' + | '\u0A10' + | '\u0A13' ..'\u0A28' + | '\u0A2A' ..'\u0A30' + | '\u0A32' + | '\u0A33' + | '\u0A35' + | '\u0A36' + | '\u0A38' + | '\u0A39' + | '\u0A59' ..'\u0A5C' + | '\u0A5E' + | '\u0A72' ..'\u0A74' + | '\u0A85' ..'\u0A8D' + | '\u0A8F' ..'\u0A91' + | '\u0A93' ..'\u0AA8' + | '\u0AAA' ..'\u0AB0' + | '\u0AB2' + | '\u0AB3' + | '\u0AB5' ..'\u0AB9' + | '\u0ABD' + | '\u0AD0' + | '\u0AE0' + | '\u0AE1' + | '\u0B05' ..'\u0B0C' + | '\u0B0F' + | '\u0B10' + | '\u0B13' ..'\u0B28' + | '\u0B2A' ..'\u0B30' + | '\u0B32' + | '\u0B33' + | '\u0B35' ..'\u0B39' + | '\u0B3D' + | '\u0B5C' + | '\u0B5D' + | '\u0B5F' ..'\u0B61' + | '\u0B71' + | '\u0B83' + | '\u0B85' ..'\u0B8A' + | '\u0B8E' ..'\u0B90' + | '\u0B92' ..'\u0B95' + | '\u0B99' + | '\u0B9A' + | '\u0B9C' + | '\u0B9E' + | '\u0B9F' + | '\u0BA3' + | '\u0BA4' + | '\u0BA8' ..'\u0BAA' + | '\u0BAE' ..'\u0BB9' + | '\u0BD0' + | '\u0C05' ..'\u0C0C' + | '\u0C0E' ..'\u0C10' + | '\u0C12' ..'\u0C28' + | '\u0C2A' ..'\u0C33' + | '\u0C35' ..'\u0C39' + | '\u0C3D' + | '\u0C58' + | '\u0C59' + | '\u0C60' + | '\u0C61' + | '\u0C85' ..'\u0C8C' + | '\u0C8E' ..'\u0C90' + | '\u0C92' ..'\u0CA8' + | '\u0CAA' ..'\u0CB3' + | '\u0CB5' ..'\u0CB9' + | '\u0CBD' + | '\u0CDE' + | '\u0CE0' + | '\u0CE1' + | '\u0CF1' + | '\u0CF2' + | '\u0D05' ..'\u0D0C' + | '\u0D0E' ..'\u0D10' + | '\u0D12' ..'\u0D3A' + | '\u0D3D' + | '\u0D4E' + | '\u0D60' + | '\u0D61' + | '\u0D7A' ..'\u0D7F' + | '\u0D85' ..'\u0D96' + | '\u0D9A' ..'\u0DB1' + | '\u0DB3' ..'\u0DBB' + | '\u0DBD' + | '\u0DC0' ..'\u0DC6' + | '\u0E01' ..'\u0E30' + | '\u0E32' + | '\u0E33' + | '\u0E40' ..'\u0E45' + | '\u0E81' + | '\u0E82' + | '\u0E84' + | '\u0E87' + | '\u0E88' + | '\u0E8A' + | '\u0E8D' + | '\u0E94' ..'\u0E97' + | '\u0E99' ..'\u0E9F' + | '\u0EA1' ..'\u0EA3' + | '\u0EA5' + | '\u0EA7' + | '\u0EAA' + | '\u0EAB' + | '\u0EAD' ..'\u0EB0' + | '\u0EB2' + | '\u0EB3' + | '\u0EBD' + | '\u0EC0' ..'\u0EC4' + | '\u0EDC' ..'\u0EDF' + | '\u0F00' + | '\u0F40' ..'\u0F47' + | '\u0F49' ..'\u0F6C' + | '\u0F88' ..'\u0F8C' + | '\u1000' ..'\u102A' + | '\u103F' + | '\u1050' ..'\u1055' + | '\u105A' ..'\u105D' + | '\u1061' + | '\u1065' + | '\u1066' + | '\u106E' ..'\u1070' + | '\u1075' ..'\u1081' + | '\u108E' + | '\u10D0' ..'\u10FA' + | '\u10FD' ..'\u1248' + | '\u124A' ..'\u124D' + | '\u1250' ..'\u1256' + | '\u1258' + | '\u125A' ..'\u125D' + | '\u1260' ..'\u1288' + | '\u128A' ..'\u128D' + | '\u1290' ..'\u12B0' + | '\u12B2' ..'\u12B5' + | '\u12B8' ..'\u12BE' + | '\u12C0' + | '\u12C2' ..'\u12C5' + | '\u12C8' ..'\u12D6' + | '\u12D8' ..'\u1310' + | '\u1312' ..'\u1315' + | '\u1318' ..'\u135A' + | '\u1380' ..'\u138F' + | '\u13A0' ..'\u13F4' + | '\u1401' ..'\u166C' + | '\u166F' ..'\u167F' + | '\u1681' ..'\u169A' + | '\u16A0' ..'\u16EA' + | '\u1700' ..'\u170C' + | '\u170E' ..'\u1711' + | '\u1720' ..'\u1731' + | '\u1740' ..'\u1751' + | '\u1760' ..'\u176C' + | '\u176E' ..'\u1770' + | '\u1780' ..'\u17B3' + | '\u17DC' + | '\u1820' ..'\u1842' + | '\u1844' ..'\u1877' + | '\u1880' ..'\u18A8' + | '\u18AA' + | '\u18B0' ..'\u18F5' + | '\u1900' ..'\u191C' + | '\u1950' ..'\u196D' + | '\u1970' ..'\u1974' + | '\u1980' ..'\u19AB' + | '\u19C1' ..'\u19C7' + | '\u1A00' ..'\u1A16' + | '\u1A20' ..'\u1A54' + | '\u1B05' ..'\u1B33' + | '\u1B45' ..'\u1B4B' + | '\u1B83' ..'\u1BA0' + | '\u1BAE' + | '\u1BAF' + | '\u1BBA' ..'\u1BE5' + | '\u1C00' ..'\u1C23' + | '\u1C4D' ..'\u1C4F' + | '\u1C5A' ..'\u1C77' + | '\u1CE9' ..'\u1CEC' + | '\u1CEE' ..'\u1CF1' + | '\u1CF5' + | '\u1CF6' + | '\u2135' ..'\u2138' + | '\u2D30' ..'\u2D67' + | '\u2D80' ..'\u2D96' + | '\u2DA0' ..'\u2DA6' + | '\u2DA8' ..'\u2DAE' + | '\u2DB0' ..'\u2DB6' + | '\u2DB8' ..'\u2DBE' + | '\u2DC0' ..'\u2DC6' + | '\u2DC8' ..'\u2DCE' + | '\u2DD0' ..'\u2DD6' + | '\u2DD8' ..'\u2DDE' + | '\u3006' + | '\u303C' + | '\u3041' ..'\u3096' + | '\u309F' + | '\u30A1' ..'\u30FA' + | '\u30FF' + | '\u3105' ..'\u312D' + | '\u3131' ..'\u318E' + | '\u31A0' ..'\u31BA' + | '\u31F0' ..'\u31FF' + | '\u3400' + | '\u4DB5' + | '\u4E00' + | '\u9FCC' + | '\uA000' ..'\uA014' + | '\uA016' ..'\uA48C' + | '\uA4D0' ..'\uA4F7' + | '\uA500' ..'\uA60B' + | '\uA610' ..'\uA61F' + | '\uA62A' + | '\uA62B' + | '\uA66E' + | '\uA6A0' ..'\uA6E5' + | '\uA7FB' ..'\uA801' + | '\uA803' ..'\uA805' + | '\uA807' ..'\uA80A' + | '\uA80C' ..'\uA822' + | '\uA840' ..'\uA873' + | '\uA882' ..'\uA8B3' + | '\uA8F2' ..'\uA8F7' + | '\uA8FB' + | '\uA90A' ..'\uA925' + | '\uA930' ..'\uA946' + | '\uA960' ..'\uA97C' + | '\uA984' ..'\uA9B2' + | '\uAA00' ..'\uAA28' + | '\uAA40' ..'\uAA42' + | '\uAA44' ..'\uAA4B' + | '\uAA60' ..'\uAA6F' + | '\uAA71' ..'\uAA76' + | '\uAA7A' + | '\uAA80' ..'\uAAAF' + | '\uAAB1' + | '\uAAB5' + | '\uAAB6' + | '\uAAB9' ..'\uAABD' + | '\uAAC0' + | '\uAAC2' + | '\uAADB' + | '\uAADC' + | '\uAAE0' ..'\uAAEA' + | '\uAAF2' + | '\uAB01' ..'\uAB06' + | '\uAB09' ..'\uAB0E' + | '\uAB11' ..'\uAB16' + | '\uAB20' ..'\uAB26' + | '\uAB28' ..'\uAB2E' + | '\uABC0' ..'\uABE2' + | '\uAC00' + | '\uD7A3' + | '\uD7B0' ..'\uD7C6' + | '\uD7CB' ..'\uD7FB' + | '\uF900' ..'\uFA6D' + | '\uFA70' ..'\uFAD9' + | '\uFB1D' + | '\uFB1F' ..'\uFB28' + | '\uFB2A' ..'\uFB36' + | '\uFB38' ..'\uFB3C' + | '\uFB3E' + | '\uFB40' + | '\uFB41' + | '\uFB43' + | '\uFB44' + | '\uFB46' ..'\uFBB1' + | '\uFBD3' ..'\uFD3D' + | '\uFD50' ..'\uFD8F' + | '\uFD92' ..'\uFDC7' + | '\uFDF0' ..'\uFDFB' + | '\uFE70' ..'\uFE74' + | '\uFE76' ..'\uFEFC' + | '\uFF66' ..'\uFF6F' + | '\uFF71' ..'\uFF9D' + | '\uFFA0' ..'\uFFBE' + | '\uFFC2' ..'\uFFC7' + | '\uFFCA' ..'\uFFCF' + | '\uFFD2' ..'\uFFD7' + | '\uFFDA' ..'\uFFDC' +; UNICODE_CLASS_LT: - '\u01C5' | - '\u01C8' | - '\u01CB' | - '\u01F2' | - '\u1F88'..'\u1F8F' | - '\u1F98'..'\u1F9F' | - '\u1FA8'..'\u1FAF' | - '\u1FBC' | - '\u1FCC' | - '\u1FFC'; + '\u01C5' + | '\u01C8' + | '\u01CB' + | '\u01F2' + | '\u1F88' ..'\u1F8F' + | '\u1F98' ..'\u1F9F' + | '\u1FA8' ..'\u1FAF' + | '\u1FBC' + | '\u1FCC' + | '\u1FFC' +; UNICODE_CLASS_LU: - '\u0041'..'\u005A' | - '\u00C0'..'\u00D6' | - '\u00D8'..'\u00DE' | - '\u0100' | - '\u0102' | - '\u0104' | - '\u0106' | - '\u0108' | - '\u010A' | - '\u010C' | - '\u010E' | - '\u0110' | - '\u0112' | - '\u0114' | - '\u0116' | - '\u0118' | - '\u011A' | - '\u011C' | - '\u011E' | - '\u0120' | - '\u0122' | - '\u0124' | - '\u0126' | - '\u0128' | - '\u012A' | - '\u012C' | - '\u012E' | - '\u0130' | - '\u0132' | - '\u0134' | - '\u0136' | - '\u0139' | - '\u013B' | - '\u013D' | - '\u013F' | - '\u0141' | - '\u0143' | - '\u0145' | - '\u0147' | - '\u014A' | - '\u014C' | - '\u014E' | - '\u0150' | - '\u0152' | - '\u0154' | - '\u0156' | - '\u0158' | - '\u015A' | - '\u015C' | - '\u015E' | - '\u0160' | - '\u0162' | - '\u0164' | - '\u0166' | - '\u0168' | - '\u016A' | - '\u016C' | - '\u016E' | - '\u0170' | - '\u0172' | - '\u0174' | - '\u0176' | - '\u0178' | - '\u0179' | - '\u017B' | - '\u017D' | - '\u0181' | - '\u0182' | - '\u0184' | - '\u0186' | - '\u0187' | - '\u0189'..'\u018B' | - '\u018E'..'\u0191' | - '\u0193' | - '\u0194' | - '\u0196'..'\u0198' | - '\u019C' | - '\u019D' | - '\u019F' | - '\u01A0' | - '\u01A2' | - '\u01A4' | - '\u01A6' | - '\u01A7' | - '\u01A9' | - '\u01AC' | - '\u01AE' | - '\u01AF' | - '\u01B1'..'\u01B3' | - '\u01B5' | - '\u01B7' | - '\u01B8' | - '\u01BC' | - '\u01C4' | - '\u01C7' | - '\u01CA' | - '\u01CD' | - '\u01CF' | - '\u01D1' | - '\u01D3' | - '\u01D5' | - '\u01D7' | - '\u01D9' | - '\u01DB' | - '\u01DE' | - '\u01E0' | - '\u01E2' | - '\u01E4' | - '\u01E6' | - '\u01E8' | - '\u01EA' | - '\u01EC' | - '\u01EE' | - '\u01F1' | - '\u01F4' | - '\u01F6'..'\u01F8' | - '\u01FA' | - '\u01FC' | - '\u01FE' | - '\u0200' | - '\u0202' | - '\u0204' | - '\u0206' | - '\u0208' | - '\u020A' | - '\u020C' | - '\u020E' | - '\u0210' | - '\u0212' | - '\u0214' | - '\u0216' | - '\u0218' | - '\u021A' | - '\u021C' | - '\u021E' | - '\u0220' | - '\u0222' | - '\u0224' | - '\u0226' | - '\u0228' | - '\u022A' | - '\u022C' | - '\u022E' | - '\u0230' | - '\u0232' | - '\u023A' | - '\u023B' | - '\u023D' | - '\u023E' | - '\u0241' | - '\u0243'..'\u0246' | - '\u0248' | - '\u024A' | - '\u024C' | - '\u024E' | - '\u0370' | - '\u0372' | - '\u0376' | - '\u0386' | - '\u0388'..'\u038A' | - '\u038C' | - '\u038E' | - '\u038F' | - '\u0391'..'\u03A1' | - '\u03A3'..'\u03AB' | - '\u03CF' | - '\u03D2'..'\u03D4' | - '\u03D8' | - '\u03DA' | - '\u03DC' | - '\u03DE' | - '\u03E0' | - '\u03E2' | - '\u03E4' | - '\u03E6' | - '\u03E8' | - '\u03EA' | - '\u03EC' | - '\u03EE' | - '\u03F4' | - '\u03F7' | - '\u03F9' | - '\u03FA' | - '\u03FD'..'\u042F' | - '\u0460' | - '\u0462' | - '\u0464' | - '\u0466' | - '\u0468' | - '\u046A' | - '\u046C' | - '\u046E' | - '\u0470' | - '\u0472' | - '\u0474' | - '\u0476' | - '\u0478' | - '\u047A' | - '\u047C' | - '\u047E' | - '\u0480' | - '\u048A' | - '\u048C' | - '\u048E' | - '\u0490' | - '\u0492' | - '\u0494' | - '\u0496' | - '\u0498' | - '\u049A' | - '\u049C' | - '\u049E' | - '\u04A0' | - '\u04A2' | - '\u04A4' | - '\u04A6' | - '\u04A8' | - '\u04AA' | - '\u04AC' | - '\u04AE' | - '\u04B0' | - '\u04B2' | - '\u04B4' | - '\u04B6' | - '\u04B8' | - '\u04BA' | - '\u04BC' | - '\u04BE' | - '\u04C0' | - '\u04C1' | - '\u04C3' | - '\u04C5' | - '\u04C7' | - '\u04C9' | - '\u04CB' | - '\u04CD' | - '\u04D0' | - '\u04D2' | - '\u04D4' | - '\u04D6' | - '\u04D8' | - '\u04DA' | - '\u04DC' | - '\u04DE' | - '\u04E0' | - '\u04E2' | - '\u04E4' | - '\u04E6' | - '\u04E8' | - '\u04EA' | - '\u04EC' | - '\u04EE' | - '\u04F0' | - '\u04F2' | - '\u04F4' | - '\u04F6' | - '\u04F8' | - '\u04FA' | - '\u04FC' | - '\u04FE' | - '\u0500' | - '\u0502' | - '\u0504' | - '\u0506' | - '\u0508' | - '\u050A' | - '\u050C' | - '\u050E' | - '\u0510' | - '\u0512' | - '\u0514' | - '\u0516' | - '\u0518' | - '\u051A' | - '\u051C' | - '\u051E' | - '\u0520' | - '\u0522' | - '\u0524' | - '\u0526' | - '\u0531'..'\u0556' | - '\u10A0'..'\u10C5' | - '\u10C7' | - '\u10CD' | - '\u1E00' | - '\u1E02' | - '\u1E04' | - '\u1E06' | - '\u1E08' | - '\u1E0A' | - '\u1E0C' | - '\u1E0E' | - '\u1E10' | - '\u1E12' | - '\u1E14' | - '\u1E16' | - '\u1E18' | - '\u1E1A' | - '\u1E1C' | - '\u1E1E' | - '\u1E20' | - '\u1E22' | - '\u1E24' | - '\u1E26' | - '\u1E28' | - '\u1E2A' | - '\u1E2C' | - '\u1E2E' | - '\u1E30' | - '\u1E32' | - '\u1E34' | - '\u1E36' | - '\u1E38' | - '\u1E3A' | - '\u1E3C' | - '\u1E3E' | - '\u1E40' | - '\u1E42' | - '\u1E44' | - '\u1E46' | - '\u1E48' | - '\u1E4A' | - '\u1E4C' | - '\u1E4E' | - '\u1E50' | - '\u1E52' | - '\u1E54' | - '\u1E56' | - '\u1E58' | - '\u1E5A' | - '\u1E5C' | - '\u1E5E' | - '\u1E60' | - '\u1E62' | - '\u1E64' | - '\u1E66' | - '\u1E68' | - '\u1E6A' | - '\u1E6C' | - '\u1E6E' | - '\u1E70' | - '\u1E72' | - '\u1E74' | - '\u1E76' | - '\u1E78' | - '\u1E7A' | - '\u1E7C' | - '\u1E7E' | - '\u1E80' | - '\u1E82' | - '\u1E84' | - '\u1E86' | - '\u1E88' | - '\u1E8A' | - '\u1E8C' | - '\u1E8E' | - '\u1E90' | - '\u1E92' | - '\u1E94' | - '\u1E9E' | - '\u1EA0' | - '\u1EA2' | - '\u1EA4' | - '\u1EA6' | - '\u1EA8' | - '\u1EAA' | - '\u1EAC' | - '\u1EAE' | - '\u1EB0' | - '\u1EB2' | - '\u1EB4' | - '\u1EB6' | - '\u1EB8' | - '\u1EBA' | - '\u1EBC' | - '\u1EBE' | - '\u1EC0' | - '\u1EC2' | - '\u1EC4' | - '\u1EC6' | - '\u1EC8' | - '\u1ECA' | - '\u1ECC' | - '\u1ECE' | - '\u1ED0' | - '\u1ED2' | - '\u1ED4' | - '\u1ED6' | - '\u1ED8' | - '\u1EDA' | - '\u1EDC' | - '\u1EDE' | - '\u1EE0' | - '\u1EE2' | - '\u1EE4' | - '\u1EE6' | - '\u1EE8' | - '\u1EEA' | - '\u1EEC' | - '\u1EEE' | - '\u1EF0' | - '\u1EF2' | - '\u1EF4' | - '\u1EF6' | - '\u1EF8' | - '\u1EFA' | - '\u1EFC' | - '\u1EFE' | - '\u1F08'..'\u1F0F' | - '\u1F18'..'\u1F1D' | - '\u1F28'..'\u1F2F' | - '\u1F38'..'\u1F3F' | - '\u1F48'..'\u1F4D' | - '\u1F59' | - '\u1F5B' | - '\u1F5D' | - '\u1F5F' | - '\u1F68'..'\u1F6F' | - '\u1FB8'..'\u1FBB' | - '\u1FC8'..'\u1FCB' | - '\u1FD8'..'\u1FDB' | - '\u1FE8'..'\u1FEC' | - '\u1FF8'..'\u1FFB' | - '\u2102' | - '\u2107' | - '\u210B'..'\u210D' | - '\u2110'..'\u2112' | - '\u2115' | - '\u2119'..'\u211D' | - '\u2124' | - '\u2126' | - '\u2128' | - '\u212A'..'\u212D' | - '\u2130'..'\u2133' | - '\u213E' | - '\u213F' | - '\u2145' | - '\u2183' | - '\u2C00'..'\u2C2E' | - '\u2C60' | - '\u2C62'..'\u2C64' | - '\u2C67' | - '\u2C69' | - '\u2C6B' | - '\u2C6D'..'\u2C70' | - '\u2C72' | - '\u2C75' | - '\u2C7E'..'\u2C80' | - '\u2C82' | - '\u2C84' | - '\u2C86' | - '\u2C88' | - '\u2C8A' | - '\u2C8C' | - '\u2C8E' | - '\u2C90' | - '\u2C92' | - '\u2C94' | - '\u2C96' | - '\u2C98' | - '\u2C9A' | - '\u2C9C' | - '\u2C9E' | - '\u2CA0' | - '\u2CA2' | - '\u2CA4' | - '\u2CA6' | - '\u2CA8' | - '\u2CAA' | - '\u2CAC' | - '\u2CAE' | - '\u2CB0' | - '\u2CB2' | - '\u2CB4' | - '\u2CB6' | - '\u2CB8' | - '\u2CBA' | - '\u2CBC' | - '\u2CBE' | - '\u2CC0' | - '\u2CC2' | - '\u2CC4' | - '\u2CC6' | - '\u2CC8' | - '\u2CCA' | - '\u2CCC' | - '\u2CCE' | - '\u2CD0' | - '\u2CD2' | - '\u2CD4' | - '\u2CD6' | - '\u2CD8' | - '\u2CDA' | - '\u2CDC' | - '\u2CDE' | - '\u2CE0' | - '\u2CE2' | - '\u2CEB' | - '\u2CED' | - '\u2CF2' | - '\uA640' | - '\uA642' | - '\uA644' | - '\uA646' | - '\uA648' | - '\uA64A' | - '\uA64C' | - '\uA64E' | - '\uA650' | - '\uA652' | - '\uA654' | - '\uA656' | - '\uA658' | - '\uA65A' | - '\uA65C' | - '\uA65E' | - '\uA660' | - '\uA662' | - '\uA664' | - '\uA666' | - '\uA668' | - '\uA66A' | - '\uA66C' | - '\uA680' | - '\uA682' | - '\uA684' | - '\uA686' | - '\uA688' | - '\uA68A' | - '\uA68C' | - '\uA68E' | - '\uA690' | - '\uA692' | - '\uA694' | - '\uA696' | - '\uA722' | - '\uA724' | - '\uA726' | - '\uA728' | - '\uA72A' | - '\uA72C' | - '\uA72E' | - '\uA732' | - '\uA734' | - '\uA736' | - '\uA738' | - '\uA73A' | - '\uA73C' | - '\uA73E' | - '\uA740' | - '\uA742' | - '\uA744' | - '\uA746' | - '\uA748' | - '\uA74A' | - '\uA74C' | - '\uA74E' | - '\uA750' | - '\uA752' | - '\uA754' | - '\uA756' | - '\uA758' | - '\uA75A' | - '\uA75C' | - '\uA75E' | - '\uA760' | - '\uA762' | - '\uA764' | - '\uA766' | - '\uA768' | - '\uA76A' | - '\uA76C' | - '\uA76E' | - '\uA779' | - '\uA77B' | - '\uA77D' | - '\uA77E' | - '\uA780' | - '\uA782' | - '\uA784' | - '\uA786' | - '\uA78B' | - '\uA78D' | - '\uA790' | - '\uA792' | - '\uA7A0' | - '\uA7A2' | - '\uA7A4' | - '\uA7A6' | - '\uA7A8' | - '\uA7AA' | - '\uFF21'..'\uFF3A'; + '\u0041' ..'\u005A' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00DE' + | '\u0100' + | '\u0102' + | '\u0104' + | '\u0106' + | '\u0108' + | '\u010A' + | '\u010C' + | '\u010E' + | '\u0110' + | '\u0112' + | '\u0114' + | '\u0116' + | '\u0118' + | '\u011A' + | '\u011C' + | '\u011E' + | '\u0120' + | '\u0122' + | '\u0124' + | '\u0126' + | '\u0128' + | '\u012A' + | '\u012C' + | '\u012E' + | '\u0130' + | '\u0132' + | '\u0134' + | '\u0136' + | '\u0139' + | '\u013B' + | '\u013D' + | '\u013F' + | '\u0141' + | '\u0143' + | '\u0145' + | '\u0147' + | '\u014A' + | '\u014C' + | '\u014E' + | '\u0150' + | '\u0152' + | '\u0154' + | '\u0156' + | '\u0158' + | '\u015A' + | '\u015C' + | '\u015E' + | '\u0160' + | '\u0162' + | '\u0164' + | '\u0166' + | '\u0168' + | '\u016A' + | '\u016C' + | '\u016E' + | '\u0170' + | '\u0172' + | '\u0174' + | '\u0176' + | '\u0178' + | '\u0179' + | '\u017B' + | '\u017D' + | '\u0181' + | '\u0182' + | '\u0184' + | '\u0186' + | '\u0187' + | '\u0189' ..'\u018B' + | '\u018E' ..'\u0191' + | '\u0193' + | '\u0194' + | '\u0196' ..'\u0198' + | '\u019C' + | '\u019D' + | '\u019F' + | '\u01A0' + | '\u01A2' + | '\u01A4' + | '\u01A6' + | '\u01A7' + | '\u01A9' + | '\u01AC' + | '\u01AE' + | '\u01AF' + | '\u01B1' ..'\u01B3' + | '\u01B5' + | '\u01B7' + | '\u01B8' + | '\u01BC' + | '\u01C4' + | '\u01C7' + | '\u01CA' + | '\u01CD' + | '\u01CF' + | '\u01D1' + | '\u01D3' + | '\u01D5' + | '\u01D7' + | '\u01D9' + | '\u01DB' + | '\u01DE' + | '\u01E0' + | '\u01E2' + | '\u01E4' + | '\u01E6' + | '\u01E8' + | '\u01EA' + | '\u01EC' + | '\u01EE' + | '\u01F1' + | '\u01F4' + | '\u01F6' ..'\u01F8' + | '\u01FA' + | '\u01FC' + | '\u01FE' + | '\u0200' + | '\u0202' + | '\u0204' + | '\u0206' + | '\u0208' + | '\u020A' + | '\u020C' + | '\u020E' + | '\u0210' + | '\u0212' + | '\u0214' + | '\u0216' + | '\u0218' + | '\u021A' + | '\u021C' + | '\u021E' + | '\u0220' + | '\u0222' + | '\u0224' + | '\u0226' + | '\u0228' + | '\u022A' + | '\u022C' + | '\u022E' + | '\u0230' + | '\u0232' + | '\u023A' + | '\u023B' + | '\u023D' + | '\u023E' + | '\u0241' + | '\u0243' ..'\u0246' + | '\u0248' + | '\u024A' + | '\u024C' + | '\u024E' + | '\u0370' + | '\u0372' + | '\u0376' + | '\u0386' + | '\u0388' ..'\u038A' + | '\u038C' + | '\u038E' + | '\u038F' + | '\u0391' ..'\u03A1' + | '\u03A3' ..'\u03AB' + | '\u03CF' + | '\u03D2' ..'\u03D4' + | '\u03D8' + | '\u03DA' + | '\u03DC' + | '\u03DE' + | '\u03E0' + | '\u03E2' + | '\u03E4' + | '\u03E6' + | '\u03E8' + | '\u03EA' + | '\u03EC' + | '\u03EE' + | '\u03F4' + | '\u03F7' + | '\u03F9' + | '\u03FA' + | '\u03FD' ..'\u042F' + | '\u0460' + | '\u0462' + | '\u0464' + | '\u0466' + | '\u0468' + | '\u046A' + | '\u046C' + | '\u046E' + | '\u0470' + | '\u0472' + | '\u0474' + | '\u0476' + | '\u0478' + | '\u047A' + | '\u047C' + | '\u047E' + | '\u0480' + | '\u048A' + | '\u048C' + | '\u048E' + | '\u0490' + | '\u0492' + | '\u0494' + | '\u0496' + | '\u0498' + | '\u049A' + | '\u049C' + | '\u049E' + | '\u04A0' + | '\u04A2' + | '\u04A4' + | '\u04A6' + | '\u04A8' + | '\u04AA' + | '\u04AC' + | '\u04AE' + | '\u04B0' + | '\u04B2' + | '\u04B4' + | '\u04B6' + | '\u04B8' + | '\u04BA' + | '\u04BC' + | '\u04BE' + | '\u04C0' + | '\u04C1' + | '\u04C3' + | '\u04C5' + | '\u04C7' + | '\u04C9' + | '\u04CB' + | '\u04CD' + | '\u04D0' + | '\u04D2' + | '\u04D4' + | '\u04D6' + | '\u04D8' + | '\u04DA' + | '\u04DC' + | '\u04DE' + | '\u04E0' + | '\u04E2' + | '\u04E4' + | '\u04E6' + | '\u04E8' + | '\u04EA' + | '\u04EC' + | '\u04EE' + | '\u04F0' + | '\u04F2' + | '\u04F4' + | '\u04F6' + | '\u04F8' + | '\u04FA' + | '\u04FC' + | '\u04FE' + | '\u0500' + | '\u0502' + | '\u0504' + | '\u0506' + | '\u0508' + | '\u050A' + | '\u050C' + | '\u050E' + | '\u0510' + | '\u0512' + | '\u0514' + | '\u0516' + | '\u0518' + | '\u051A' + | '\u051C' + | '\u051E' + | '\u0520' + | '\u0522' + | '\u0524' + | '\u0526' + | '\u0531' ..'\u0556' + | '\u10A0' ..'\u10C5' + | '\u10C7' + | '\u10CD' + | '\u1E00' + | '\u1E02' + | '\u1E04' + | '\u1E06' + | '\u1E08' + | '\u1E0A' + | '\u1E0C' + | '\u1E0E' + | '\u1E10' + | '\u1E12' + | '\u1E14' + | '\u1E16' + | '\u1E18' + | '\u1E1A' + | '\u1E1C' + | '\u1E1E' + | '\u1E20' + | '\u1E22' + | '\u1E24' + | '\u1E26' + | '\u1E28' + | '\u1E2A' + | '\u1E2C' + | '\u1E2E' + | '\u1E30' + | '\u1E32' + | '\u1E34' + | '\u1E36' + | '\u1E38' + | '\u1E3A' + | '\u1E3C' + | '\u1E3E' + | '\u1E40' + | '\u1E42' + | '\u1E44' + | '\u1E46' + | '\u1E48' + | '\u1E4A' + | '\u1E4C' + | '\u1E4E' + | '\u1E50' + | '\u1E52' + | '\u1E54' + | '\u1E56' + | '\u1E58' + | '\u1E5A' + | '\u1E5C' + | '\u1E5E' + | '\u1E60' + | '\u1E62' + | '\u1E64' + | '\u1E66' + | '\u1E68' + | '\u1E6A' + | '\u1E6C' + | '\u1E6E' + | '\u1E70' + | '\u1E72' + | '\u1E74' + | '\u1E76' + | '\u1E78' + | '\u1E7A' + | '\u1E7C' + | '\u1E7E' + | '\u1E80' + | '\u1E82' + | '\u1E84' + | '\u1E86' + | '\u1E88' + | '\u1E8A' + | '\u1E8C' + | '\u1E8E' + | '\u1E90' + | '\u1E92' + | '\u1E94' + | '\u1E9E' + | '\u1EA0' + | '\u1EA2' + | '\u1EA4' + | '\u1EA6' + | '\u1EA8' + | '\u1EAA' + | '\u1EAC' + | '\u1EAE' + | '\u1EB0' + | '\u1EB2' + | '\u1EB4' + | '\u1EB6' + | '\u1EB8' + | '\u1EBA' + | '\u1EBC' + | '\u1EBE' + | '\u1EC0' + | '\u1EC2' + | '\u1EC4' + | '\u1EC6' + | '\u1EC8' + | '\u1ECA' + | '\u1ECC' + | '\u1ECE' + | '\u1ED0' + | '\u1ED2' + | '\u1ED4' + | '\u1ED6' + | '\u1ED8' + | '\u1EDA' + | '\u1EDC' + | '\u1EDE' + | '\u1EE0' + | '\u1EE2' + | '\u1EE4' + | '\u1EE6' + | '\u1EE8' + | '\u1EEA' + | '\u1EEC' + | '\u1EEE' + | '\u1EF0' + | '\u1EF2' + | '\u1EF4' + | '\u1EF6' + | '\u1EF8' + | '\u1EFA' + | '\u1EFC' + | '\u1EFE' + | '\u1F08' ..'\u1F0F' + | '\u1F18' ..'\u1F1D' + | '\u1F28' ..'\u1F2F' + | '\u1F38' ..'\u1F3F' + | '\u1F48' ..'\u1F4D' + | '\u1F59' + | '\u1F5B' + | '\u1F5D' + | '\u1F5F' + | '\u1F68' ..'\u1F6F' + | '\u1FB8' ..'\u1FBB' + | '\u1FC8' ..'\u1FCB' + | '\u1FD8' ..'\u1FDB' + | '\u1FE8' ..'\u1FEC' + | '\u1FF8' ..'\u1FFB' + | '\u2102' + | '\u2107' + | '\u210B' ..'\u210D' + | '\u2110' ..'\u2112' + | '\u2115' + | '\u2119' ..'\u211D' + | '\u2124' + | '\u2126' + | '\u2128' + | '\u212A' ..'\u212D' + | '\u2130' ..'\u2133' + | '\u213E' + | '\u213F' + | '\u2145' + | '\u2183' + | '\u2C00' ..'\u2C2E' + | '\u2C60' + | '\u2C62' ..'\u2C64' + | '\u2C67' + | '\u2C69' + | '\u2C6B' + | '\u2C6D' ..'\u2C70' + | '\u2C72' + | '\u2C75' + | '\u2C7E' ..'\u2C80' + | '\u2C82' + | '\u2C84' + | '\u2C86' + | '\u2C88' + | '\u2C8A' + | '\u2C8C' + | '\u2C8E' + | '\u2C90' + | '\u2C92' + | '\u2C94' + | '\u2C96' + | '\u2C98' + | '\u2C9A' + | '\u2C9C' + | '\u2C9E' + | '\u2CA0' + | '\u2CA2' + | '\u2CA4' + | '\u2CA6' + | '\u2CA8' + | '\u2CAA' + | '\u2CAC' + | '\u2CAE' + | '\u2CB0' + | '\u2CB2' + | '\u2CB4' + | '\u2CB6' + | '\u2CB8' + | '\u2CBA' + | '\u2CBC' + | '\u2CBE' + | '\u2CC0' + | '\u2CC2' + | '\u2CC4' + | '\u2CC6' + | '\u2CC8' + | '\u2CCA' + | '\u2CCC' + | '\u2CCE' + | '\u2CD0' + | '\u2CD2' + | '\u2CD4' + | '\u2CD6' + | '\u2CD8' + | '\u2CDA' + | '\u2CDC' + | '\u2CDE' + | '\u2CE0' + | '\u2CE2' + | '\u2CEB' + | '\u2CED' + | '\u2CF2' + | '\uA640' + | '\uA642' + | '\uA644' + | '\uA646' + | '\uA648' + | '\uA64A' + | '\uA64C' + | '\uA64E' + | '\uA650' + | '\uA652' + | '\uA654' + | '\uA656' + | '\uA658' + | '\uA65A' + | '\uA65C' + | '\uA65E' + | '\uA660' + | '\uA662' + | '\uA664' + | '\uA666' + | '\uA668' + | '\uA66A' + | '\uA66C' + | '\uA680' + | '\uA682' + | '\uA684' + | '\uA686' + | '\uA688' + | '\uA68A' + | '\uA68C' + | '\uA68E' + | '\uA690' + | '\uA692' + | '\uA694' + | '\uA696' + | '\uA722' + | '\uA724' + | '\uA726' + | '\uA728' + | '\uA72A' + | '\uA72C' + | '\uA72E' + | '\uA732' + | '\uA734' + | '\uA736' + | '\uA738' + | '\uA73A' + | '\uA73C' + | '\uA73E' + | '\uA740' + | '\uA742' + | '\uA744' + | '\uA746' + | '\uA748' + | '\uA74A' + | '\uA74C' + | '\uA74E' + | '\uA750' + | '\uA752' + | '\uA754' + | '\uA756' + | '\uA758' + | '\uA75A' + | '\uA75C' + | '\uA75E' + | '\uA760' + | '\uA762' + | '\uA764' + | '\uA766' + | '\uA768' + | '\uA76A' + | '\uA76C' + | '\uA76E' + | '\uA779' + | '\uA77B' + | '\uA77D' + | '\uA77E' + | '\uA780' + | '\uA782' + | '\uA784' + | '\uA786' + | '\uA78B' + | '\uA78D' + | '\uA790' + | '\uA792' + | '\uA7A0' + | '\uA7A2' + | '\uA7A4' + | '\uA7A6' + | '\uA7A8' + | '\uA7AA' + | '\uFF21' ..'\uFF3A' +; UNICODE_CLASS_ND: - '\u0030'..'\u0039' | - '\u0660'..'\u0669' | - '\u06F0'..'\u06F9' | - '\u07C0'..'\u07C9' | - '\u0966'..'\u096F' | - '\u09E6'..'\u09EF' | - '\u0A66'..'\u0A6F' | - '\u0AE6'..'\u0AEF' | - '\u0B66'..'\u0B6F' | - '\u0BE6'..'\u0BEF' | - '\u0C66'..'\u0C6F' | - '\u0CE6'..'\u0CEF' | - '\u0D66'..'\u0D6F' | - '\u0E50'..'\u0E59' | - '\u0ED0'..'\u0ED9' | - '\u0F20'..'\u0F29' | - '\u1040'..'\u1049' | - '\u1090'..'\u1099' | - '\u17E0'..'\u17E9' | - '\u1810'..'\u1819' | - '\u1946'..'\u194F' | - '\u19D0'..'\u19D9' | - '\u1A80'..'\u1A89' | - '\u1A90'..'\u1A99' | - '\u1B50'..'\u1B59' | - '\u1BB0'..'\u1BB9' | - '\u1C40'..'\u1C49' | - '\u1C50'..'\u1C59' | - '\uA620'..'\uA629' | - '\uA8D0'..'\uA8D9' | - '\uA900'..'\uA909' | - '\uA9D0'..'\uA9D9' | - '\uAA50'..'\uAA59' | - '\uABF0'..'\uABF9' | - '\uFF10'..'\uFF19'; + '\u0030' ..'\u0039' + | '\u0660' ..'\u0669' + | '\u06F0' ..'\u06F9' + | '\u07C0' ..'\u07C9' + | '\u0966' ..'\u096F' + | '\u09E6' ..'\u09EF' + | '\u0A66' ..'\u0A6F' + | '\u0AE6' ..'\u0AEF' + | '\u0B66' ..'\u0B6F' + | '\u0BE6' ..'\u0BEF' + | '\u0C66' ..'\u0C6F' + | '\u0CE6' ..'\u0CEF' + | '\u0D66' ..'\u0D6F' + | '\u0E50' ..'\u0E59' + | '\u0ED0' ..'\u0ED9' + | '\u0F20' ..'\u0F29' + | '\u1040' ..'\u1049' + | '\u1090' ..'\u1099' + | '\u17E0' ..'\u17E9' + | '\u1810' ..'\u1819' + | '\u1946' ..'\u194F' + | '\u19D0' ..'\u19D9' + | '\u1A80' ..'\u1A89' + | '\u1A90' ..'\u1A99' + | '\u1B50' ..'\u1B59' + | '\u1BB0' ..'\u1BB9' + | '\u1C40' ..'\u1C49' + | '\u1C50' ..'\u1C59' + | '\uA620' ..'\uA629' + | '\uA8D0' ..'\uA8D9' + | '\uA900' ..'\uA909' + | '\uA9D0' ..'\uA9D9' + | '\uAA50' ..'\uAA59' + | '\uABF0' ..'\uABF9' + | '\uFF10' ..'\uFF19' +; UNICODE_CLASS_NL: - '\u16EE'..'\u16F0' | - '\u2160'..'\u2182' | - '\u2185'..'\u2188' | - '\u3007' | - '\u3021'..'\u3029' | - '\u3038'..'\u303A' | - '\uA6E6'..'\uA6EF'; \ No newline at end of file + '\u16EE' ..'\u16F0' + | '\u2160' ..'\u2182' + | '\u2185' ..'\u2188' + | '\u3007' + | '\u3021' ..'\u3029' + | '\u3038' ..'\u303A' + | '\uA6E6' ..'\uA6EF' +; \ No newline at end of file diff --git a/kquery/KQuery.g4 b/kquery/KQuery.g4 index 4dff097e15..5faad44f16 100644 --- a/kquery/KQuery.g4 +++ b/kquery/KQuery.g4 @@ -25,74 +25,82 @@ */ // Grammar for KLEE KQuery parsing. (A bit more verbose with richer parsing) // Ported to Antlr4 by Sumit Lahiri. (Unoptimized Grammar) + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar KQuery; -kqueryExpression +kqueryExpression : queryStatements EOF ; queryStatements - : ( ktranslationUnit )* + : (ktranslationUnit)* ; - + ktranslationUnit : arrayDeclaration | queryCommand ; -queryCommand - : LeftParen Query evalExprList queryExpr RightParen +queryCommand + : LeftParen Query evalExprList queryExpr RightParen + ; + +queryExpr + : expression (evalExprList evalArrayList?)? ; - -queryExpr - : expression ( evalExprList evalArrayList? )? + +evalExprList + : LeftBracket expressionList RightBracket ; - -evalExprList - : LeftBracket expressionList RightBracket + +evalArrayList + : LeftBracket identifierList RightBracket ; -evalArrayList - : LeftBracket identifierList RightBracket +expressionList + : (expression)* ; -expressionList : ( expression )*; -identifierList : ( Identifier )*; +identifierList + : (Identifier)* + ; arrayDeclaration - : Array arrName LeftBracket numArrayElements RightBracket - Colon domain Arrow rangeLimit Equal arrayInitializer + : Array arrName LeftBracket numArrayElements RightBracket Colon domain Arrow rangeLimit Equal arrayInitializer ; - + numArrayElements : Constant ; - + arrayInitializer - : Symbolic + : Symbolic | LeftBracket numberList RightBracket ; - + expression - : varName #VariableName - | varName Colon expression #NamedAbbreviation - | LeftParen widthOrSizeExpr number RightParen #SizeQuery - | LeftParen arithmeticExpr widthOrSizeExpr leftExpr rightExpr RightParen #ArithExpr - | LeftParen notExpr LeftBracket widthOrSizeExpr RightBracket expression RightParen #NotExprWidth - | LeftParen bitwiseExpr widthOrSizeExpr leftExpr rightExpr RightParen #BitwExprWidth - | LeftParen comparisonExpr (widthOrSizeExpr)? leftExpr rightExpr RightParen #CompExprWidth - | LeftParen concatExpr (widthOrSizeExpr)? leftExpr rightExpr RightParen #ConcatExprWidth - | LeftParen arrExtractExpr widthOrSizeExpr number expression RightParen #ArrExtractExprWidth - | LeftParen bitExtractExpr widthOrSizeExpr expression RightParen #BitExtractExprWidth - | LeftParen genericBitRead widthOrSizeExpr expression (version)? RightParen #ReadExpresssionVersioned - | LeftParen selectExpr widthOrSizeExpr leftExpr rightExpr expression RightParen #SelectExprWidth - | LeftParen exprNegation (widthOrSizeExpr)? expression RightParen #NegationExprWidth - | version #VersionExpr - | number #Singleton + : varName # VariableName + | varName Colon expression # NamedAbbreviation + | LeftParen widthOrSizeExpr number RightParen # SizeQuery + | LeftParen arithmeticExpr widthOrSizeExpr leftExpr rightExpr RightParen # ArithExpr + | LeftParen notExpr LeftBracket widthOrSizeExpr RightBracket expression RightParen # NotExprWidth + | LeftParen bitwiseExpr widthOrSizeExpr leftExpr rightExpr RightParen # BitwExprWidth + | LeftParen comparisonExpr (widthOrSizeExpr)? leftExpr rightExpr RightParen # CompExprWidth + | LeftParen concatExpr (widthOrSizeExpr)? leftExpr rightExpr RightParen # ConcatExprWidth + | LeftParen arrExtractExpr widthOrSizeExpr number expression RightParen # ArrExtractExprWidth + | LeftParen bitExtractExpr widthOrSizeExpr expression RightParen # BitExtractExprWidth + | LeftParen genericBitRead widthOrSizeExpr expression (version)? RightParen # ReadExpresssionVersioned + | LeftParen selectExpr widthOrSizeExpr leftExpr rightExpr expression RightParen # SelectExprWidth + | LeftParen exprNegation (widthOrSizeExpr)? expression RightParen # NegationExprWidth + | version # VersionExpr + | number # Singleton ; genericBitRead - : READ + : READ | READLSB | READMSB ; @@ -101,16 +109,16 @@ bitExtractExpr : ZEXT | SEXT ; - + version - : varName ( Colon expression )? #VersionVariableName - | LeftBracket (updateList)? RightBracket ATR version #UpdationList + : varName (Colon expression)? # VersionVariableName + | LeftBracket (updateList)? RightBracket ATR version # UpdationList ; - + notExpr : NOT ; - + concatExpr : CONCAT ; @@ -126,106 +134,122 @@ selectExpr arrExtractExpr : EXTRACT ; - + varName : Identifier ; - -leftExpr + +leftExpr : expression - ; + ; rightExpr : expression ; - -updateList - : expression Equal expression ( COMMA expression Equal expression )* + +updateList + : expression Equal expression (COMMA expression Equal expression)* ; -bitwiseExpr - : BITWISEAND - | BITWISEOR - | BITWISEXOR - | SHL - | LSHR +bitwiseExpr + : BITWISEAND + | BITWISEOR + | BITWISEXOR + | SHL + | LSHR | ASHR ; - -comparisonExpr - : EQ - | NEQ + +comparisonExpr + : EQ + | NEQ | ULT | UGT - | ULE - | UGE - | SLT - | SLE - | SGT + | ULE + | UGE + | SLT + | SLE + | SGT | SGE ; - -arithmeticExpr + +arithmeticExpr : ADD - | SUB - | MUL - | UDIV - | UREM - | SDIV + | SUB + | MUL + | UDIV + | UREM + | SDIV | SREM ; - -domain : widthOrSizeExpr ; -rangeLimit : widthOrSizeExpr ; -arrName : Identifier ; + +domain + : widthOrSizeExpr + ; + +rangeLimit + : widthOrSizeExpr + ; + +arrName + : Identifier + ; numberList : number+ ; -number - : boolnum +number + : boolnum | signedConstant | constant ; -constant: Constant; -boolnum: Boolean; -signedConstant: SignedConstant; +constant + : Constant + ; + +boolnum + : Boolean + ; + +signedConstant + : SignedConstant + ; Boolean : TrueMatch | FalseMatch ; - -SignedConstant - : (PLUS | MINUS)Constant + +SignedConstant + : (PLUS | MINUS) Constant ; - + Constant - : DIGIT+ - | BinConstant - | OctConstant + : DIGIT+ + | BinConstant + | OctConstant | HexConstant ; - -BinConstant - : BinId (BIN_DIGIT)+ + +BinConstant + : BinId (BIN_DIGIT)+ ; - -OctConstant - : OctId (OCTAL_DIGIT)+ + +OctConstant + : OctId (OCTAL_DIGIT)+ ; - -HexConstant + +HexConstant : HexId (HEX_DIGIT)+ ; -FloatingPointType - : FP DIGIT+([.].*?)? +FloatingPointType + : FP DIGIT+ ([.].*?)? ; - -IntegerType + +IntegerType : INT (DIGIT)+ ; @@ -233,96 +257,240 @@ widthOrSizeExpr : WidthType ; -WidthType +WidthType : WIDTH (DIGIT)+ ; - -BinId : '0b'; -OctId : '0o'; -WIDTH : 'w'; -HexId : '0x'; -TrueMatch : 'true'; -FalseMatch : 'false'; -Query : 'query'; -Array : 'array'; -Symbolic : 'symbolic'; -Colon : ':'; -Arrow : '->'; -Equal : '='; -COMMA : ','; -NOT : 'Not'; -SHL : 'Shl'; -LSHR : 'LShr'; -ASHR : 'AShr'; -CONCAT : 'Concat'; -EXTRACT: 'Extract'; -ZEXT: 'ZExt'; -SEXT: 'SExt'; -READ: 'Read'; -SELECT: 'Select'; -NEGETION: 'Neg'; -READLSB: 'ReadLSB'; -READMSB: 'ReadMSB'; -PLUS : '+'; -MINUS : '-'; -ATR : '@'; -BITWISEAND : 'And'; -BITWISEOR : 'Or'; -BITWISEXOR : 'Xor'; -EQ : 'Eq'; -NEQ : 'Ne' ; -ULT : 'Ult' ; -ULE : 'Ule' ; -UGT : 'Ugt' ; -UGE : 'Uge' ; -SLT : 'Slt' ; -SLE : 'Sle' ; -SGT : 'Sgt' ; -SGE : 'Sge' ; -ADD : 'Add' ; -SUB : 'Sub' ; -MUL : 'Mul' ; -UDIV : 'UDiv'; -UREM : 'URem'; -SDIV : 'SDiv'; -SREM : 'SRem'; - -fragment -DIGIT - : ('0'..'9') - ; - -fragment -BIN_DIGIT + +BinId + : '0b' + ; + +OctId + : '0o' + ; + +WIDTH + : 'w' + ; + +HexId + : '0x' + ; + +TrueMatch + : 'true' + ; + +FalseMatch + : 'false' + ; + +Query + : 'query' + ; + +Array + : 'array' + ; + +Symbolic + : 'symbolic' + ; + +Colon + : ':' + ; + +Arrow + : '->' + ; + +Equal + : '=' + ; + +COMMA + : ',' + ; + +NOT + : 'Not' + ; + +SHL + : 'Shl' + ; + +LSHR + : 'LShr' + ; + +ASHR + : 'AShr' + ; + +CONCAT + : 'Concat' + ; + +EXTRACT + : 'Extract' + ; + +ZEXT + : 'ZExt' + ; + +SEXT + : 'SExt' + ; + +READ + : 'Read' + ; + +SELECT + : 'Select' + ; + +NEGETION + : 'Neg' + ; + +READLSB + : 'ReadLSB' + ; + +READMSB + : 'ReadMSB' + ; + +PLUS + : '+' + ; + +MINUS + : '-' + ; + +ATR + : '@' + ; + +BITWISEAND + : 'And' + ; + +BITWISEOR + : 'Or' + ; + +BITWISEXOR + : 'Xor' + ; + +EQ + : 'Eq' + ; + +NEQ + : 'Ne' + ; + +ULT + : 'Ult' + ; + +ULE + : 'Ule' + ; + +UGT + : 'Ugt' + ; + +UGE + : 'Uge' + ; + +SLT + : 'Slt' + ; + +SLE + : 'Sle' + ; + +SGT + : 'Sgt' + ; + +SGE + : 'Sge' + ; + +ADD + : 'Add' + ; + +SUB + : 'Sub' + ; + +MUL + : 'Mul' + ; + +UDIV + : 'UDiv' + ; + +UREM + : 'URem' + ; + +SDIV + : 'SDiv' + ; + +SREM + : 'SRem' + ; + +fragment DIGIT + : ('0' ..'9') + ; + +fragment BIN_DIGIT : ('0' | '1' | '_') ; -fragment -OCTAL_DIGIT - : ('0'..'7' | '_') +fragment OCTAL_DIGIT + : ('0' ..'7' | '_') ; -fragment -HEX_DIGIT - : ('0'..'9'|'a'..'f'|'A'..'F'|'_') +fragment HEX_DIGIT + : ('0' ..'9' | 'a' ..'f' | 'A' ..'F' | '_') ; - + Identifier - : ('a'..'z' | 'A'..'Z' | '_')('a'..'z' | 'A'..'Z' | '_' | '0'..'9' | '.' )* + : ('a' ..'z' | 'A' ..'Z' | '_') ('a' ..'z' | 'A' ..'Z' | '_' | '0' ..'9' | '.')* + ; + +INT + : 'i' + ; + +FP + : 'fp' ; - -INT : 'i'; -FP : 'fp'; Whitespace - : [ \t]+ -> skip + : [ \t]+ -> skip ; Newline - : ( '\r' '\n'? - | '\n' - ) - -> skip + : ('\r' '\n'? | '\n') -> skip ; BlockComment @@ -332,10 +500,27 @@ BlockComment LineComment : '#' ~[\r\n]* -> skip ; - -LeftParen : '('; -RightParen : ')'; -LeftBracket : '['; -RightBracket : ']'; -LeftBrace : '{'; -RightBrace : '}'; + +LeftParen + : '(' + ; + +RightParen + : ')' + ; + +LeftBracket + : '[' + ; + +RightBracket + : ']' + ; + +LeftBrace + : '{' + ; + +RightBrace + : '}' + ; \ No newline at end of file diff --git a/kuka/krl.g4 b/kuka/krl.g4 index d01c31a1eb..6ee35705b3 100644 --- a/kuka/krl.g4 +++ b/kuka/krl.g4 @@ -1,3 +1,5 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging grammar krl; @@ -22,920 +24,840 @@ grammar krl; Antlr4 port by Tom Everett, 2016 */ module - : (moduleData | moduleRoutines) EOF - ; + : (moduleData | moduleRoutines) EOF + ; moduleRoutines - : mainRoutine (subRoutine | NEWLINE)* - ; + : mainRoutine (subRoutine | NEWLINE)* + ; mainRoutine - : procedureDefinition - | functionDefinition - ; + : procedureDefinition + | functionDefinition + ; subRoutine - : procedureDefinition - | functionDefinition - ; + : procedureDefinition + | functionDefinition + ; procedureDefinition - : GLOBAL? DEF procedureName formalParameters NEWLINE routineBody END - ; + : GLOBAL? DEF procedureName formalParameters NEWLINE routineBody END + ; procedureName - : IDENTIFIER - ; + : IDENTIFIER + ; functionDefinition - : GLOBAL? DEFFCT type_ functionName formalParameters NEWLINE routineBody ENDFCT - ; + : GLOBAL? DEFFCT type_ functionName formalParameters NEWLINE routineBody ENDFCT + ; functionName - : IDENTIFIER - ; + : IDENTIFIER + ; moduleData - : DEFDAT moduleName PUBLIC? NEWLINE dataList ENDDAT NEWLINE* - ; + : DEFDAT moduleName PUBLIC? NEWLINE dataList ENDDAT NEWLINE* + ; moduleName - : IDENTIFIER - ; + : IDENTIFIER + ; dataList - : (NEWLINE | forwardDeclaration NEWLINE | typeDeclaration NEWLINE | variableDeclarationInDataList NEWLINE | arrayInitialisation NEWLINE | importStatement NEWLINE)* - ; + : ( + NEWLINE + | forwardDeclaration NEWLINE + | typeDeclaration NEWLINE + | variableDeclarationInDataList NEWLINE + | arrayInitialisation NEWLINE + | importStatement NEWLINE + )* + ; arrayInitialisation - : IDENTIFIER arrayVariableSuffix '=' unaryPlusMinuxExpression - ; + : IDENTIFIER arrayVariableSuffix '=' unaryPlusMinuxExpression + ; typeDeclaration - : structureDefinition - | enumDefinition - ; + : structureDefinition + | enumDefinition + ; structureDefinition - : GLOBAL? STRUC typeName type_ variableName variableListRest (',' type_ variableName variableListRest)* - ; + : GLOBAL? STRUC typeName type_ variableName variableListRest ( + ',' type_ variableName variableListRest + )* + ; enumDefinition - : GLOBAL? ENUM typeName enumValue (',' enumValue)* - ; + : GLOBAL? ENUM typeName enumValue (',' enumValue)* + ; enumValue - : IDENTIFIER - ; + : IDENTIFIER + ; variableDeclaration - : DECL? (type_ variableName variableListRest | signalDeclaration) - ; + : DECL? (type_ variableName variableListRest | signalDeclaration) + ; signalDeclaration - : SIGNAL IDENTIFIER primary (TO primary)? - ; + : SIGNAL IDENTIFIER primary (TO primary)? + ; variableDeclarationInDataList - : DECL? GLOBAL? CONST? (type_ variableName (variableListRest | variableInitialisation) | signalDeclaration) - ; + : DECL? GLOBAL? CONST? ( + type_ variableName (variableListRest | variableInitialisation) + | signalDeclaration + ) + ; variableListRest - : (',' variableName)* - ; + : (',' variableName)* + ; variableInitialisation - : '=' unaryPlusMinuxExpression - ; + : '=' unaryPlusMinuxExpression + ; structLiteral - : '{' (typeName ':')? structElementList '}' - ; + : '{' (typeName ':')? structElementList '}' + ; structElementList - : structElement (',' structElement)* - ; + : structElement (',' structElement)* + ; structElement - : variableName unaryPlusMinuxExpression - ; + : variableName unaryPlusMinuxExpression + ; formalParameters - : '(' (parameter (',' parameter)*)? ')' - ; + : '(' (parameter (',' parameter)*)? ')' + ; parameter - : variableName (parameterCallType)? - ; + : variableName (parameterCallType)? + ; routineBody - : routineDataSection routineImplementationSection - ; + : routineDataSection routineImplementationSection + ; routineDataSection - : (forwardDeclaration NEWLINE | variableDeclaration NEWLINE | (NEWLINE) NEWLINE | importStatement NEWLINE)* - ; + : ( + forwardDeclaration NEWLINE + | variableDeclaration NEWLINE + | (NEWLINE) NEWLINE + | importStatement NEWLINE + )* + ; forwardDeclaration - : EXT procedureName formalParametersWithType - | EXTFCT type_ functionName formalParametersWithType - ; + : EXT procedureName formalParametersWithType + | EXTFCT type_ functionName formalParametersWithType + ; formalParametersWithType - : '(' (parameterWithType (',' parameterWithType)*)? ')' - ; + : '(' (parameterWithType (',' parameterWithType)*)? ')' + ; parameterWithType - : type_ (parameterCallType)? - ; + : type_ (parameterCallType)? + ; parameterCallType - : ':' IDENTIFIER - ; + : ':' IDENTIFIER + ; importStatement - : IMPORT type_ variableName IS '/R1/' moduleName '..' variableName - ; + : IMPORT type_ variableName IS '/R1/' moduleName '..' variableName + ; variableName - : IDENTIFIER (arrayVariableSuffix)? - ; + : IDENTIFIER (arrayVariableSuffix)? + ; // expression in arrays are optional: a string literal can be assigned to a char array as a whole arrayVariableSuffix - : '[' (expression (',' (expression (',' expression?)?)?)?)? ']' - ; + : '[' (expression (',' (expression (',' expression?)?)?)?)? ']' + ; routineImplementationSection - : statementList - ; + : statementList + ; statementList - : statement* - ; + : statement* + ; statement - : CONTINUE NEWLINE - | EXIT NEWLINE - | FOR IDENTIFIER '=' expression TO expression (IDENTIFIER expression)? NEWLINE statementList ENDFOR - | GOTO IDENTIFIER NEWLINE - | HALT NEWLINE - | IF expression THEN NEWLINE statementList (ELSE NEWLINE statementList)? ENDIF NEWLINE - | LOOP NEWLINE statementList ENDLOOP NEWLINE - | REPEAT NEWLINE statementList UNTIL expression NEWLINE - | SWITCH expression NEWLINE switchBlockStatementGroups ENDSWITCH NEWLINE - | WAIT FOR expression NEWLINE - | WAIT SEC expression NEWLINE - | WHILE expression NEWLINE statementList ENDWHILE NEWLINE - | RETURN (assignmentExpression)? NEWLINE - | BRAKE (IDENTIFIER)? NEWLINE - | assignmentExpression NEWLINE - | IDENTIFIER ':' NEWLINE - | NEWLINE - | GLOBAL? INTERRUPT DECL primary WHEN expression DO assignmentExpression NEWLINE - | INTERRUPT IDENTIFIER primary? NEWLINE - | (PTP | PTP_REL) geometricExpression (C_PTP (C_DIS | C_ORI | C_VEL)?)? NEWLINE - | LIN geometricExpression (C_DIS | C_ORI | C_VEL)? NEWLINE - | LIN_REL geometricExpression (C_DIS | C_ORI | C_VEL)? enumElement? NEWLINE - | (CIRC | CIRC_REL) geometricExpression ',' geometricExpression (',' IDENTIFIER primary)? (C_DIS | C_ORI | C_VEL)? NEWLINE - | TRIGGER WHEN (IDENTIFIER) '=' expression DELAY '=' expression DO assignmentExpression (PRIO '=' expression)? NEWLINE - | analogInputStatement NEWLINE - | analogOutputStatement NEWLINE - ; + : CONTINUE NEWLINE + | EXIT NEWLINE + | FOR IDENTIFIER '=' expression TO expression (IDENTIFIER expression)? NEWLINE statementList ENDFOR + | GOTO IDENTIFIER NEWLINE + | HALT NEWLINE + | IF expression THEN NEWLINE statementList (ELSE NEWLINE statementList)? ENDIF NEWLINE + | LOOP NEWLINE statementList ENDLOOP NEWLINE + | REPEAT NEWLINE statementList UNTIL expression NEWLINE + | SWITCH expression NEWLINE switchBlockStatementGroups ENDSWITCH NEWLINE + | WAIT FOR expression NEWLINE + | WAIT SEC expression NEWLINE + | WHILE expression NEWLINE statementList ENDWHILE NEWLINE + | RETURN (assignmentExpression)? NEWLINE + | BRAKE (IDENTIFIER)? NEWLINE + | assignmentExpression NEWLINE + | IDENTIFIER ':' NEWLINE + | NEWLINE + | GLOBAL? INTERRUPT DECL primary WHEN expression DO assignmentExpression NEWLINE + | INTERRUPT IDENTIFIER primary? NEWLINE + | (PTP | PTP_REL) geometricExpression (C_PTP (C_DIS | C_ORI | C_VEL)?)? NEWLINE + | LIN geometricExpression (C_DIS | C_ORI | C_VEL)? NEWLINE + | LIN_REL geometricExpression (C_DIS | C_ORI | C_VEL)? enumElement? NEWLINE + | (CIRC | CIRC_REL) geometricExpression ',' geometricExpression (',' IDENTIFIER primary)? ( + C_DIS + | C_ORI + | C_VEL + )? NEWLINE + | TRIGGER WHEN (IDENTIFIER) '=' expression DELAY '=' expression DO assignmentExpression ( + PRIO '=' expression + )? NEWLINE + | analogInputStatement NEWLINE + | analogOutputStatement NEWLINE + ; analogOutputStatement - : ANOUT (IDENTIFIER assignmentExpression (IDENTIFIER '=' literal)* | IDENTIFIER IDENTIFIER) - ; + : ANOUT (IDENTIFIER assignmentExpression (IDENTIFIER '=' literal)* | IDENTIFIER IDENTIFIER) + ; analogInputStatement - : ANIN (IDENTIFIER assignmentExpression | IDENTIFIER IDENTIFIER) - ; + : ANIN (IDENTIFIER assignmentExpression | IDENTIFIER IDENTIFIER) + ; switchBlockStatementGroups - : NEWLINE* (caseLabel statementList) + (defaultLabel statementList)? - ; + : NEWLINE* (caseLabel statementList)+ (defaultLabel statementList)? + ; caseLabel - : CASE expression (',' expression)* NEWLINE - ; + : CASE expression (',' expression)* NEWLINE + ; defaultLabel - : DEFAULT NEWLINE - ; + : DEFAULT NEWLINE + ; expressionList - : assignmentExpression (',' assignmentExpression)* - ; + : assignmentExpression (',' assignmentExpression)* + ; assignmentExpression - : expression ('=' expression)* - ; + : expression ('=' expression)* + ; expression - : conditionalOrExpression (relationalOp conditionalOrExpression)* - ; + : conditionalOrExpression (relationalOp conditionalOrExpression)* + ; relationalOp - : '==' - | '<>' - | '<=' - | '>=' - | '<' - | '>' - ; + : '==' + | '<>' + | '<=' + | '>=' + | '<' + | '>' + ; conditionalOrExpression - : exclusiveOrExpression ((OR | B_OR) exclusiveOrExpression)* - ; + : exclusiveOrExpression ((OR | B_OR) exclusiveOrExpression)* + ; exclusiveOrExpression - : conditionalAndExpression ((EXOR | B_EXOR) conditionalAndExpression)* - ; + : conditionalAndExpression ((EXOR | B_EXOR) conditionalAndExpression)* + ; conditionalAndExpression - : additiveExpression ((AND | B_AND) additiveExpression)* - ; + : additiveExpression ((AND | B_AND) additiveExpression)* + ; additiveExpression - : multiplicativeExpression (('+' | '-') multiplicativeExpression)* - ; + : multiplicativeExpression (('+' | '-') multiplicativeExpression)* + ; multiplicativeExpression - : geometricExpression (('*' | '/') geometricExpression)* - ; + : geometricExpression (('*' | '/') geometricExpression)* + ; geometricExpression - : unaryNotExpression (':' unaryNotExpression)* - ; + : unaryNotExpression (':' unaryNotExpression)* + ; unaryNotExpression - : NOT unaryNotExpression - | B_NOT unaryNotExpression - | unaryPlusMinuxExpression - ; + : NOT unaryNotExpression + | B_NOT unaryNotExpression + | unaryPlusMinuxExpression + ; unaryPlusMinuxExpression - : '+' unaryPlusMinuxExpression - | '-' unaryPlusMinuxExpression - | primary - ; + : '+' unaryPlusMinuxExpression + | '-' unaryPlusMinuxExpression + | primary + ; primary - : parExpression - | variableName ('.' variableName)* (arguments)? - | literal - ; + : parExpression + | variableName ('.' variableName)* (arguments)? + | literal + ; parExpression - : '(' assignmentExpression ')' - ; + : '(' assignmentExpression ')' + ; type_ - : primitiveType ('[' (INTLITERAL)? ']')? - | typeName ('[' (INTLITERAL)? ']')? - ; + : primitiveType ('[' (INTLITERAL)? ']')? + | typeName ('[' (INTLITERAL)? ']')? + ; typeName - : IDENTIFIER - ; + : IDENTIFIER + ; primitiveType - : BOOL - | CHAR - | INT - | REAL - ; + : BOOL + | CHAR + | INT + | REAL + ; arguments - : '(' (expressionList)? ')' - ; + : '(' (expressionList)? ')' + ; literal - : INTLITERAL - | FLOATLITERAL - | CHARLITERAL - | STRINGLITERAL - | structLiteral - | TRUE - | FALSE - | enumElement - ; + : INTLITERAL + | FLOATLITERAL + | CHARLITERAL + | STRINGLITERAL + | structLiteral + | TRUE + | FALSE + | enumElement + ; enumElement - : '#' IDENTIFIER - ; - + : '#' IDENTIFIER + ; AND - : A N D - ; - + : A N D + ; ANIN - : A N I N - ; - + : A N I N + ; ANOUT - : A N O U T - ; - + : A N O U T + ; B_AND - : B '_' A N D - ; - + : B '_' A N D + ; B_NOT - : B '_' N O T - ; - + : B '_' N O T + ; B_OR - : B '_' O R - ; - + : B '_' O R + ; B_EXOR - : B '_' E X O R - ; - + : B '_' E X O R + ; BOOL - : B O O L - ; - + : B O O L + ; BRAKE - : B R A K E - ; - + : B R A K E + ; C_DIS - : C '_' D I S - ; - + : C '_' D I S + ; C_ORI - : C '_' O R I - ; - + : C '_' O R I + ; C_PTP - : C '_' P T P - ; - + : C '_' P T P + ; C_VEL - : C '_' V E L - ; - + : C '_' V E L + ; CASE - : C A S E - ; - + : C A S E + ; CAST_FROM - : C A S T '_' F R O M - ; - + : C A S T '_' F R O M + ; CAST_TO - : C A S T '_' T O - ; - + : C A S T '_' T O + ; CHAR - : C H A R - ; - + : C H A R + ; CIRC_REL - : C I R C '_' R E L - ; - + : C I R C '_' R E L + ; CIRC - : C I R C - ; - + : C I R C + ; CONST - : C O N S T - ; - + : C O N S T + ; CONTINUE - : C O N T I N U E - ; - + : C O N T I N U E + ; DELAY - : D E L A Y - ; - + : D E L A Y + ; DECL - : D E C L - ; - + : D E C L + ; DEF - : D E F - ; - + : D E F + ; DEFAULT - : D E F A U L T - ; - + : D E F A U L T + ; DEFDAT - : D E F D A T - ; - + : D E F D A T + ; DEFFCT - : D E F F C T - ; - + : D E F F C T + ; DO - : D O - ; - + : D O + ; ELSE - : E L S E - ; - + : E L S E + ; END - : E N D - ; - + : E N D + ; ENDDAT - : E N D D A T - ; - + : E N D D A T + ; ENDFCT - : E N D F C T - ; - + : E N D F C T + ; ENDFOR - : E N D F O R - ; - + : E N D F O R + ; ENDIF - : E N D I F - ; - + : E N D I F + ; ENDLOOP - : E N D L O O P - ; - + : E N D L O O P + ; ENDSWITCH - : E N D S W I T C H - ; - + : E N D S W I T C H + ; ENDWHILE - : E N D W H I L E - ; - + : E N D W H I L E + ; ENUM - : E N U M - ; - + : E N U M + ; EXIT - : E X I T - ; - + : E X I T + ; EXT - : E X T - ; - + : E X T + ; EXTFCT - : E X T F C T - ; - + : E X T F C T + ; FALSE - : F A L S E - ; - + : F A L S E + ; FOR - : F O R - ; - + : F O R + ; GLOBAL - : G L O B A L - ; - + : G L O B A L + ; GOTO - : G O T O - ; - + : G O T O + ; HALT - : H A L T - ; - + : H A L T + ; IF - : I F - ; - + : I F + ; IMPORT - : I M P O R T - ; - + : I M P O R T + ; INTERRUPT - : I N T E R R U P T - ; - + : I N T E R R U P T + ; INT - : I N T - ; - + : I N T + ; IS - : I S - ; - + : I S + ; LIN_REL - : L I N '_' R E L - ; - + : L I N '_' R E L + ; LIN - : L I N - ; - + : L I N + ; LOOP - : L O O P - ; - + : L O O P + ; MAXIMUM - : M A X I M U M - ; - + : M A X I M U M + ; MINIMUM - : M I N I M U M - ; - + : M I N I M U M + ; NOT - : N O T - ; - + : N O T + ; OR - : O R - ; - + : O R + ; PRIO - : P R I O - ; - + : P R I O + ; PTP_REL - : P T P '_' R E L - ; - + : P T P '_' R E L + ; PTP - : P T P - ; - + : P T P + ; PUBLIC - : P U B L I C - ; - + : P U B L I C + ; REAL - : R E A L - ; - + : R E A L + ; REPEAT - : R E P E A T - ; - + : R E P E A T + ; RETURN - : R E T U R N - ; - + : R E T U R N + ; SEC - : S E C - ; - + : S E C + ; SIGNAL - : S I G N A L - ; - + : S I G N A L + ; STRUC - : S T R U C - ; - + : S T R U C + ; SWITCH - : S W I T C H - ; - + : S W I T C H + ; THEN - : T H E N - ; - + : T H E N + ; TO - : T O - ; - + : T O + ; TRIGGER - : T R I G G E R - ; - + : T R I G G E R + ; TRUE - : T R U E - ; - + : T R U E + ; UNTIL - : U N T I L - ; - + : U N T I L + ; WAIT - : W A I T - ; - + : W A I T + ; WHEN - : W H E N - ; - + : W H E N + ; WHILE - : W H I L E - ; - + : W H I L E + ; EXOR - : E X O R - ; - + : E X O R + ; fragment A - : ('a' | 'A') - ; - + : ('a' | 'A') + ; fragment B - : ('b' | 'B') - ; - + : ('b' | 'B') + ; fragment C - : ('c' | 'C') - ; - + : ('c' | 'C') + ; fragment D - : ('d' | 'D') - ; - + : ('d' | 'D') + ; fragment E - : ('e' | 'E') - ; - + : ('e' | 'E') + ; fragment F - : ('f' | 'F') - ; - + : ('f' | 'F') + ; fragment G - : ('g' | 'G') - ; - + : ('g' | 'G') + ; fragment H - : ('h' | 'H') - ; - + : ('h' | 'H') + ; fragment I - : ('i' | 'I') - ; - + : ('i' | 'I') + ; fragment J - : ('j' | 'J') - ; - + : ('j' | 'J') + ; fragment K - : ('k' | 'K') - ; - + : ('k' | 'K') + ; fragment L - : ('l' | 'L') - ; - + : ('l' | 'L') + ; fragment M - : ('m' | 'M') - ; - + : ('m' | 'M') + ; fragment N - : ('n' | 'N') - ; - + : ('n' | 'N') + ; fragment O - : ('o' | 'O') - ; - + : ('o' | 'O') + ; fragment P - : ('p' | 'P') - ; - + : ('p' | 'P') + ; fragment Q - : ('q' | 'Q') - ; - + : ('q' | 'Q') + ; fragment R - : ('r' | 'R') - ; - + : ('r' | 'R') + ; fragment S - : ('s' | 'S') - ; - + : ('s' | 'S') + ; fragment T - : ('t' | 'T') - ; - + : ('t' | 'T') + ; fragment U - : ('u' | 'U') - ; - + : ('u' | 'U') + ; fragment V - : ('v' | 'V') - ; - + : ('v' | 'V') + ; fragment W - : ('w' | 'W') - ; - + : ('w' | 'W') + ; fragment X - : ('x' | 'X') - ; - + : ('x' | 'X') + ; fragment Y - : ('y' | 'Y') - ; - + : ('y' | 'Y') + ; fragment Z - : ('z' | 'Z') - ; - + : ('z' | 'Z') + ; HEADERLINE - : '&' ~ ('\n' | '\r')* ('\r\n' | '\r' | '\n' | EOF) -> skip - ; - + : '&' ~ ('\n' | '\r')* ('\r\n' | '\r' | '\n' | EOF) -> skip + ; WS - : (' ' | '\t' | '\u000C') -> skip - ; - + : (' ' | '\t' | '\u000C') -> skip + ; NEWLINE - : '\r'? '\n' - ; - + : '\r'? '\n' + ; LINE_COMMENT - : ';' ~ ('\n' | '\r')* -> skip - ; - + : ';' ~ ('\n' | '\r')* -> skip + ; CHARLITERAL - : '\'' (EscapeSequence | ~ ('\'' | '\\' | '\r' | '\n')) '\'' - ; - + : '\'' (EscapeSequence | ~ ('\'' | '\\' | '\r' | '\n')) '\'' + ; STRINGLITERAL - : '"' (EscapeSequence | ~ ('\\' | '"' | '\r' | '\n'))* '"' - ; - + : '"' (EscapeSequence | ~ ('\\' | '"' | '\r' | '\n'))* '"' + ; fragment EscapeSequence - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\' | ('0' .. '3') ('0' .. '7') ('0' .. '7') | ('0' .. '7') ('0' .. '7') | ('0' .. '7')) - ; - + : '\\' ( + 'b' + | 't' + | 'n' + | 'f' + | 'r' + | '"' + | '\'' + | '\\' + | ('0' .. '3') ('0' .. '7') ('0' .. '7') + | ('0' .. '7') ('0' .. '7') + | ('0' .. '7') + ) + ; FLOATLITERAL - : ('0' .. '9') + '.' ('0' .. '9')* Exponent? | '.' ('0' .. '9') + Exponent? | ('0' .. '9') + Exponent - ; - + : ('0' .. '9')+ '.' ('0' .. '9')* Exponent? + | '.' ('0' .. '9')+ Exponent? + | ('0' .. '9')+ Exponent + ; fragment Exponent - : E ('+' | '-')? ('0' .. '9') + - ; - + : E ('+' | '-')? ('0' .. '9')+ + ; INTLITERAL - : ('0' .. '9') + | HexPrefix HexDigit + HexSuffix | BinPrefix BinDigit + BinSuffix - ; - + : ('0' .. '9')+ + | HexPrefix HexDigit+ HexSuffix + | BinPrefix BinDigit+ BinSuffix + ; fragment HexPrefix - : '\'' H - ; - + : '\'' H + ; fragment HexDigit - : ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F') - ; - + : ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F') + ; fragment HexSuffix - : '\'' - ; - + : '\'' + ; fragment BinPrefix - : '\'' B - ; - + : '\'' B + ; fragment BinDigit - : ('0' | '1') - ; - + : ('0' | '1') + ; fragment BinSuffix - : '\'' - ; - + : '\'' + ; IDENTIFIER - : IdentifierStart IdentifierPart* - ; - + : IdentifierStart IdentifierPart* + ; fragment IdentifierStart - : 'a' .. 'z' | 'A' .. 'Z' | '_' | '$' - ; - + : 'a' .. 'z' + | 'A' .. 'Z' + | '_' + | '$' + ; fragment IdentifierPart - : IdentifierStart | '0' .. '9' - ; + : IdentifierStart + | '0' .. '9' + ; \ No newline at end of file diff --git a/lambda/lambda.g4 b/lambda/lambda.g4 index 6eccc7d144..3760874954 100644 --- a/lambda/lambda.g4 +++ b/lambda/lambda.g4 @@ -30,12 +30,19 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar lambda; -file_ : expression EOF ; +file_ + : expression EOF + ; expression - : VARIABLE | function_ | application + : VARIABLE + | function_ + | application ; function_ @@ -50,11 +57,10 @@ scope : expression ; - VARIABLE : [a-z] [a-zA-Z0-9]* ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/lark/LarkLexer.g4 b/lark/LarkLexer.g4 index 1f2b3a770c..5643250db6 100644 --- a/lark/LarkLexer.g4 +++ b/lark/LarkLexer.g4 @@ -1,50 +1,55 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar LarkLexer; -channels { OFF_CHANNEL } - -COLON: ':' ; -LC : '{' ; -RC : '}' ; -LP : '(' ; -RP : ')' ; -LB : '[' ; -RB : ']' ; -COMMA : ',' ; -DOT : '.' ; -ARROW : '->' ; -IGNORE : '%ignore' ; -IMPORT : '%import' ; -OVERRIDE : '%override' ; -DECLARE : '%declare' ; -DD : '..' ; -SQ : '~' ; - -VBAR: '|' ; -OP: [+*] | '?' ; -RULE: '!'? [_?]? [a-z] [_a-z0-9]* ; -TOKEN: '_'? [A-Z] [_A-Z0-9]* ; -STRING: FSTRING 'i'? ; -REGEXP: '/' ('\\' '/' | '\\' '\\' | ~'/' ) ('\\' '/' | '\\' '\\' | ~'/' )*? '/' [imslux]* ; -NL: ('\r'? '\n')+ (' '| '\t' | '\n' | '\r' | '\f' | 'u2B7F' )* -> channel(OFF_CHANNEL) ; +channels { + OFF_CHANNEL +} + +COLON : ':'; +LC : '{'; +RC : '}'; +LP : '('; +RP : ')'; +LB : '['; +RB : ']'; +COMMA : ','; +DOT : '.'; +ARROW : '->'; +IGNORE : '%ignore'; +IMPORT : '%import'; +OVERRIDE : '%override'; +DECLARE : '%declare'; +DD : '..'; +SQ : '~'; + +VBAR : '|'; +OP : [+*] | '?'; +RULE : '!'? [_?]? [a-z] [_a-z0-9]*; +TOKEN : '_'? [A-Z] [_A-Z0-9]*; +STRING : FSTRING 'i'?; +REGEXP : '/' ('\\' '/' | '\\' '\\' | ~'/') ('\\' '/' | '\\' '\\' | ~'/')*? '/' [imslux]*; +NL : ('\r'? '\n')+ (' ' | '\t' | '\n' | '\r' | '\f' | 'u2B7F')* -> channel(OFF_CHANNEL); // // Strings // -fragment FSTRING : '"' (~["\\\r\n] | EscapeSequence)* '"'; -fragment EscapeSequence : '\\' [btnfr"'\\] ; +fragment FSTRING : '"' (~["\\\r\n] | EscapeSequence)* '"'; +fragment EscapeSequence : '\\' [btnfr"'\\]; // // Numbers // -fragment DIGIT: '0' .. '9' ; -fragment HEXDIGIT: 'a' .. 'f' | 'A' .. 'F' | DIGIT ; -fragment INT: DIGIT+ ; -NUMBER: ('+' | '-')? INT ; +fragment DIGIT : '0' .. '9'; +fragment HEXDIGIT : 'a' .. 'f' | 'A' .. 'F' | DIGIT; +fragment INT : DIGIT+; +NUMBER : ('+' | '-')? INT; // // Whitespace // -WS_INLINE: (' ' | '\t')+ -> channel(OFF_CHANNEL) ; - -COMMENT: '//' ~[\n\r]* -> channel(OFF_CHANNEL) ; +WS_INLINE: (' ' | '\t')+ -> channel(OFF_CHANNEL); +COMMENT: '//' ~[\n\r]* -> channel(OFF_CHANNEL); \ No newline at end of file diff --git a/lark/LarkParser.g4 b/lark/LarkParser.g4 index e6862857e6..94f5a7c9e6 100644 --- a/lark/LarkParser.g4 +++ b/lark/LarkParser.g4 @@ -1,48 +1,88 @@ +// $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 LarkParser; options { tokenVocab = LarkLexer; } -start_: item* EOF; - -item: rule_ | token | statement ; - -rule_: RULE rule_params priority? ':' expansions ; - -token: TOKEN token_params priority? ':' expansions ; - -rule_params: ('{' RULE (',' RULE)* '}')? ; - -token_params: ('{' TOKEN (',' TOKEN)* '}')? ; - -priority: '.' NUMBER ; - -statement: '%ignore' expansions - | '%import' import_path ('->' name)? - | '%import' import_path name_list - | '%override' rule_ - | '%declare' name+ - ; - -import_path: '.'? name ('.' name)* ; - -name_list: '(' name (',' name)* ')' ; - -expansions: alias (VBAR alias)* ; - -alias: expansion ('->' RULE)? ; - -expansion: expr* ; - -expr: atom (OP | '~' NUMBER ('..' NUMBER)? )? ; - -atom: '(' expansions ')' | '[' expansions ']' | value ; - -value: STRING '..' STRING - | name - | (REGEXP | STRING) - | name '{' value (',' value)* '}' - ; - -name: RULE | TOKEN ; +start_ + : item* EOF + ; + +item + : rule_ + | token + | statement + ; + +rule_ + : RULE rule_params priority? ':' expansions + ; + +token + : TOKEN token_params priority? ':' expansions + ; + +rule_params + : ('{' RULE (',' RULE)* '}')? + ; + +token_params + : ('{' TOKEN (',' TOKEN)* '}')? + ; + +priority + : '.' NUMBER + ; + +statement + : '%ignore' expansions + | '%import' import_path ('->' name)? + | '%import' import_path name_list + | '%override' rule_ + | '%declare' name+ + ; + +import_path + : '.'? name ('.' name)* + ; + +name_list + : '(' name (',' name)* ')' + ; + +expansions + : alias (VBAR alias)* + ; + +alias + : expansion ('->' RULE)? + ; + +expansion + : expr* + ; + +expr + : atom (OP | '~' NUMBER ('..' NUMBER)?)? + ; + +atom + : '(' expansions ')' + | '[' expansions ']' + | value + ; + +value + : STRING '..' STRING + | name + | (REGEXP | STRING) + | name '{' value (',' value)* '}' + ; + +name + : RULE + | TOKEN + ; \ No newline at end of file diff --git a/lcc/lcc.g4 b/lcc/lcc.g4 index 12efb2369c..e35556deed 100644 --- a/lcc/lcc.g4 +++ b/lcc/lcc.g4 @@ -30,12 +30,14 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging grammar lcc; lcc - : topic ' '? subtopic? ' '? subclasses ' '? ('.' cutters)? (' ' date)? EOF - ; + : topic ' '? subtopic? ' '? subclasses ' '? ('.' cutters)? (' ' date)? EOF + ; topic : LETTER @@ -66,13 +68,13 @@ date ; DIGIT - : ('0'..'9') + : ('0' ..'9') ; LETTER - : ('A'..'Z') + : ('A' ..'Z') ; WS - : [\t\r\n] + -> skip - ; + : [\t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/less/LessLexer.g4 b/less/LessLexer.g4 index 3ad4904df8..15a6fa624a 100644 --- a/less/LessLexer.g4 +++ b/less/LessLexer.g4 @@ -4,780 +4,474 @@ All rights reserved. */ -lexer grammar LessLexer; - - -NULL_ - : 'null' - ; - - -IN - : 'in' - ; - - -Unit - : ('%' | 'px' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'em' | 'ex' | 'deg' | 'rad' | 'grad' | 'ms' | 's' | 'hz' | 'khz') - ; - - -Ellipsis - : '...' - ; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true +lexer grammar LessLexer; -InterpolationStart - : AT BlockStart -> pushMode (IDENTIFY) - ; +NULL_: 'null'; + +IN: 'in'; + +Unit: + ( + '%' + | 'px' + | 'cm' + | 'mm' + | 'in' + | 'pt' + | 'pc' + | 'em' + | 'ex' + | 'deg' + | 'rad' + | 'grad' + | 'ms' + | 's' + | 'hz' + | 'khz' + ) +; + +Ellipsis: '...'; + +InterpolationStart: AT BlockStart -> pushMode (IDENTIFY); //Separators -LPAREN - : '(' - ; - - -RPAREN - : ')' - ; - - -BlockStart - : '{' - ; - - -BlockEnd - : '}' - ; - - -LBRACK - : '[' - ; - - -RBRACK - : ']' - ; - - -GT - : '>' - ; - - -TIL - : '~' - ; - - -LT - : '<' - ; - - -COLON - : ':' - ; - - -SEMI - : ';' - ; - - -COMMA - : ',' - ; - +LPAREN: '('; -DOT - : '.' - ; +RPAREN: ')'; +BlockStart: '{'; -DOLLAR - : '$' - ; +BlockEnd: '}'; +LBRACK: '['; -AT - : '@' - ; +RBRACK: ']'; +GT: '>'; -PARENTREF - : '&' - ; +TIL: '~'; +LT: '<'; -HASH - : '#' - ; +COLON: ':'; +SEMI: ';'; -COLONCOLON - : '::' - ; +COMMA: ','; +DOT: '.'; -PLUS - : '+' - ; +DOLLAR: '$'; +AT: '@'; -TIMES - : '*' - ; +PARENTREF: '&'; +HASH: '#'; -DIV - : '/' - ; +COLONCOLON: '::'; +PLUS: '+'; -MINUS - : '-' - ; +TIMES: '*'; +DIV: '/'; -PERC - : '%' - ; +MINUS: '-'; +PERC: '%'; -EQEQ - : '==' - ; +EQEQ: '=='; +GTEQ: '>='; -GTEQ - : '>=' - ; +LTEQ: '<='; +NOTEQ: '!='; -LTEQ - : '<=' - ; +EQ: '='; +PIPE_EQ: '|='; -NOTEQ - : '!=' - ; - - -EQ - : '=' - ; - - -PIPE_EQ - : '|=' - ; - - -TILD_EQ - : '~=' - ; +TILD_EQ: '~='; // URLs // http://lesscss.org/features/#variables-feature-urls -URL - : 'url' - ; - - -UrlStart - : URL LPAREN -> pushMode (URL_STARTED) - ; - +URL: 'url'; -IMPORT - : '@import' - ; +UrlStart: URL LPAREN -> pushMode (URL_STARTED); +IMPORT: '@import'; -MEDIA - : '@media' - ; +MEDIA: '@media'; +EXTEND: ':extend'; -EXTEND - : ':extend' - ; +IMPORTANT: '!important'; +ARGUMENTS: '@arguments'; -IMPORTANT - : '!important' - ; - - -ARGUMENTS - : '@arguments' - ; - - -REST - : '@rest' - ; +REST: '@rest'; // Import options // http://lesscss.org/features/#import-options -REFERENCE - : 'reference' - ; - - -INLINE - : 'inline' - ; - - -LESS - : 'less' - ; +REFERENCE: 'reference'; +INLINE: 'inline'; -CSS - : 'css' - ; +LESS: 'less'; +CSS: 'css'; -ONCE - : 'once' - ; +ONCE: 'once'; - -MULTIPLE - : 'multiple' - ; +MULTIPLE: 'multiple'; // Mixin Guards -WHEN - : 'when' - ; - - -NOT - : 'not' - ; - - -AND - : 'and' - ; - - -Identifier - : (('_' | '.' | 'a' .. 'z' | 'A' .. 'Z' | '\u0100' .. '\ufffe') ('_' | '-' | '.' | 'a' .. 'z' | 'A' .. 'Z' | '\u0100' .. '\ufffe' | '0' .. '9')* | '-' ('_' | '.' | 'a' .. 'z' | 'A' .. 'Z' | '\u0100' .. '\ufffe') ('_' | '-' | '.' | 'a' .. 'z' | 'A' .. 'Z' | '\u0100' .. '\ufffe' | '0' .. '9')*) -> pushMode (IDENTIFY) - ; - - -fragment STRING - : '"' (~ ('"' | '\n' | '\r'))* '"' | '\'' (~ ('\'' | '\n' | '\r'))* '\'' - ; +WHEN: 'when'; + +NOT: 'not'; + +AND: 'and'; + +Identifier: + ( + ('_' | '.' | 'a' .. 'z' | 'A' .. 'Z' | '\u0100' .. '\ufffe') ( + '_' + | '-' + | '.' + | 'a' .. 'z' + | 'A' .. 'Z' + | '\u0100' .. '\ufffe' + | '0' .. '9' + )* + | '-' ('_' | '.' | 'a' .. 'z' | 'A' .. 'Z' | '\u0100' .. '\ufffe') ( + '_' + | '-' + | '.' + | 'a' .. 'z' + | 'A' .. 'Z' + | '\u0100' .. '\ufffe' + | '0' .. '9' + )* + ) -> pushMode (IDENTIFY) +; + +fragment STRING: '"' (~ ('"' | '\n' | '\r'))* '"' | '\'' (~ ('\'' | '\n' | '\r'))* '\''; // string literals -StringLiteral - : STRING - ; - +StringLiteral: STRING; -Number - : '-' (('0' .. '9')* '.')? ('0' .. '9') + | (('0' .. '9')* '.')? ('0' .. '9') + - ; +Number: '-' (('0' .. '9')* '.')? ('0' .. '9')+ | (('0' .. '9')* '.')? ('0' .. '9')+; - -Color - : '#' ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F') + - ; +Color: '#' ('0' .. '9' | 'a' .. 'f' | 'A' .. 'F')+; // Whitespace -- ignored -WS - : (' ' | '\t' | '\n' | '\r' | '\r\n') + -> skip - ; +WS: (' ' | '\t' | '\n' | '\r' | '\r\n')+ -> skip; // Single-line comments -SL_COMMENT - : '//' (~ ('\n' | '\r'))* ('\n' | '\r' ('\n')?) -> skip - ; +SL_COMMENT: '//' (~ ('\n' | '\r'))* ('\n' | '\r' ('\n')?) -> skip; // multiple-line comments -COMMENT - : '/*' .*? '*/' -> skip - ; - - -FUNCTION_NAME - : COLOR | CONVERT | DATA_URI | DEFAULT | UNIT | GET_UNIT | SVG_GRADIENT | ESCAPE | E | FORMAT | REPLACE | LENGTH | EXTRACT | CEIL | FLOOR | PERCENTAGE | ROUND | SQRT | ABS | SIN | ASIN | COS | ACOS | TAN | ATAN | PI | POW | MOD | MIN | MAX | ISNUMBER | ISSTRING | ISCOLOR | ISKEYWORD | ISURL | ISPIXEL | ISEM | ISPERCENTAGE | ISUNIT | RGB | RGBA | ARGB | HSL | HSLA | HSV | HSVA | HUE | SATURATION | LIGHTNESS | HSVHUE | HSVSATURATION | HSVVALUE | RED | GREEN | BLUE | ALPHA | LUMA | LUMINANCE | SATURATE | DESATURATE | LIGHTEN | DARKEN | FADEIN | FADEOUT | FADE | SPIN | MIX | GREYSCALE | CONTRAST | MULTIPLY | SCREEN | OVERLAY | SOFTLIGHT | HARDLIGHT | DIFFERENCE | EXCLUSION | AVERAGE | NEGATION - ; +COMMENT: '/*' .*? '*/' -> skip; + +FUNCTION_NAME: + COLOR + | CONVERT + | DATA_URI + | DEFAULT + | UNIT + | GET_UNIT + | SVG_GRADIENT + | ESCAPE + | E + | FORMAT + | REPLACE + | LENGTH + | EXTRACT + | CEIL + | FLOOR + | PERCENTAGE + | ROUND + | SQRT + | ABS + | SIN + | ASIN + | COS + | ACOS + | TAN + | ATAN + | PI + | POW + | MOD + | MIN + | MAX + | ISNUMBER + | ISSTRING + | ISCOLOR + | ISKEYWORD + | ISURL + | ISPIXEL + | ISEM + | ISPERCENTAGE + | ISUNIT + | RGB + | RGBA + | ARGB + | HSL + | HSLA + | HSV + | HSVA + | HUE + | SATURATION + | LIGHTNESS + | HSVHUE + | HSVSATURATION + | HSVVALUE + | RED + | GREEN + | BLUE + | ALPHA + | LUMA + | LUMINANCE + | SATURATE + | DESATURATE + | LIGHTEN + | DARKEN + | FADEIN + | FADEOUT + | FADE + | SPIN + | MIX + | GREYSCALE + | CONTRAST + | MULTIPLY + | SCREEN + | OVERLAY + | SOFTLIGHT + | HARDLIGHT + | DIFFERENCE + | EXCLUSION + | AVERAGE + | NEGATION +; // Function reference // Misc http://lesscss.org/functions/#misc-functions -COLOR - : 'color' - ; - - -CONVERT - : 'convert' - ; - +COLOR: 'color'; -DATA_URI - : 'data-uri' - ; +CONVERT: 'convert'; +DATA_URI: 'data-uri'; -DEFAULT - : 'default' - ; +DEFAULT: 'default'; +UNIT: 'unit'; -UNIT - : 'unit' - ; +GET_UNIT: 'get-unit'; - -GET_UNIT - : 'get-unit' - ; - - -SVG_GRADIENT - : 'svg-gradient' - ; +SVG_GRADIENT: 'svg-gradient'; // String http://lesscss.org/functions/#string-functions -ESCAPE - : 'escape' - ; - - -E - : 'e' - ; +ESCAPE: 'escape'; -FORMAT - : '%' - ; +E: 'e'; +FORMAT: '%'; -REPLACE - : 'replace' - ; +REPLACE: 'replace'; // List http://lesscss.org/functions/#list-functions -LENGTH - : 'length' - ; +LENGTH: 'length'; - -EXTRACT - : 'extract' - ; +EXTRACT: 'extract'; // Math http://lesscss.org/functions/#math-functions -CEIL - : 'ceil' - ; - - -FLOOR - : 'floor' - ; - - -PERCENTAGE - : 'percentage' - ; - - -ROUND - : 'round' - ; - - -SQRT - : 'sqrt' - ; - - -ABS - : 'abs' - ; - +CEIL: 'ceil'; -SIN - : 'sin' - ; +FLOOR: 'floor'; +PERCENTAGE: 'percentage'; -ASIN - : 'asin' - ; +ROUND: 'round'; +SQRT: 'sqrt'; -COS - : 'cos' - ; +ABS: 'abs'; +SIN: 'sin'; -ACOS - : 'acos' - ; +ASIN: 'asin'; +COS: 'cos'; -TAN - : 'tan' - ; +ACOS: 'acos'; +TAN: 'tan'; -ATAN - : 'atan' - ; +ATAN: 'atan'; +PI: 'pi'; -PI - : 'pi' - ; +POW: 'pow'; +MOD: 'mod'; -POW - : 'pow' - ; +MIN: 'min'; - -MOD - : 'mod' - ; - - -MIN - : 'min' - ; - - -MAX - : 'max' - ; +MAX: 'max'; // Type http://lesscss.org/functions/#type-functions -ISNUMBER - : 'isnumber' - ; - - -ISSTRING - : 'isstring' - ; - +ISNUMBER: 'isnumber'; -ISCOLOR - : 'iscolor' - ; +ISSTRING: 'isstring'; +ISCOLOR: 'iscolor'; -ISKEYWORD - : 'iskeyword' - ; +ISKEYWORD: 'iskeyword'; +ISURL: 'isurl'; -ISURL - : 'isurl' - ; +ISPIXEL: 'ispixel'; +ISEM: 'isem'; -ISPIXEL - : 'ispixel' - ; +ISPERCENTAGE: 'ispercentage'; - -ISEM - : 'isem' - ; - - -ISPERCENTAGE - : 'ispercentage' - ; - - -ISUNIT - : 'isunit' - ; +ISUNIT: 'isunit'; // Color http://lesscss.org/functions/#color-definition -RGB - : 'rgb' - ; - - -RGBA - : 'rgba' - ; - +RGB: 'rgb'; -ARGB - : 'argb' - ; +RGBA: 'rgba'; +ARGB: 'argb'; -HSL - : 'hsl' - ; +HSL: 'hsl'; +HSLA: 'hsla'; -HSLA - : 'hsla' - ; +HSV: 'hsv'; - -HSV - : 'hsv' - ; - - -HSVA - : 'hsva' - ; +HSVA: 'hsva'; // Color channel http://lesscss.org/functions/#color-channel -HUE - : 'hue' - ; - - -SATURATION - : 'saturation' - ; - - -LIGHTNESS - : 'lightness' - ; - +HUE: 'hue'; -HSVHUE - : 'hsvhue' - ; +SATURATION: 'saturation'; +LIGHTNESS: 'lightness'; -HSVSATURATION - : 'hsvsaturation' - ; +HSVHUE: 'hsvhue'; +HSVSATURATION: 'hsvsaturation'; -HSVVALUE - : 'hsvvalue' - ; +HSVVALUE: 'hsvvalue'; +RED: 'red'; -RED - : 'red' - ; +GREEN: 'green'; +BLUE: 'blue'; -GREEN - : 'green' - ; +ALPHA: 'alpha'; +LUMA: 'luma'; -BLUE - : 'blue' - ; - - -ALPHA - : 'alpha' - ; - - -LUMA - : 'luma' - ; - - -LUMINANCE - : 'luminance' - ; +LUMINANCE: 'luminance'; // Color operation http://lesscss.org/functions/#color-operations -SATURATE - : 'saturate' - ; - - -DESATURATE - : 'desaturate' - ; +SATURATE: 'saturate'; +DESATURATE: 'desaturate'; -LIGHTEN - : 'lighten' - ; +LIGHTEN: 'lighten'; +DARKEN: 'darken'; -DARKEN - : 'darken' - ; +FADEIN: 'fadein'; +FADEOUT: 'fadeout'; -FADEIN - : 'fadein' - ; +FADE: 'fade'; +SPIN: 'spin'; -FADEOUT - : 'fadeout' - ; +MIX: 'mix'; +GREYSCALE: 'greyscale'; -FADE - : 'fade' - ; - - -SPIN - : 'spin' - ; - - -MIX - : 'mix' - ; - - -GREYSCALE - : 'greyscale' - ; - - -CONTRAST - : 'contrast' - ; +CONTRAST: 'contrast'; // Color blending http://lesscss.org/functions/#color-blending -MULTIPLY - : 'multiply' - ; - - -SCREEN - : 'screen' - ; - - -OVERLAY - : 'overlay' - ; - - -SOFTLIGHT - : 'softlight' - ; - - -HARDLIGHT - : 'hardlight' - ; +MULTIPLY: 'multiply'; +SCREEN: 'screen'; -DIFFERENCE - : 'difference' - ; +OVERLAY: 'overlay'; +SOFTLIGHT: 'softlight'; -EXCLUSION - : 'exclusion' - ; +HARDLIGHT: 'hardlight'; +DIFFERENCE: 'difference'; -AVERAGE - : 'average' - ; +EXCLUSION: 'exclusion'; +AVERAGE: 'average'; -NEGATION - : 'negation' - ; +NEGATION: 'negation'; mode URL_STARTED; -UrlEnd - : RPAREN -> popMode - ; +UrlEnd: RPAREN -> popMode; -Url - : STRING | (~ (')' | '\n' | '\r' | ';')) + - ; +Url: STRING | (~ (')' | '\n' | '\r' | ';'))+; mode IDENTIFY; -BlockStart_ID - : BlockStart -> popMode , type (BlockStart) - ; +BlockStart_ID: BlockStart -> popMode, type (BlockStart); -SPACE - : WS -> popMode , skip - ; +SPACE: WS -> popMode, skip; -DOLLAR_ID - : DOLLAR -> type (DOLLAR) - ; +DOLLAR_ID: DOLLAR -> type (DOLLAR); -InterpolationStartAfter - : InterpolationStart - ; +InterpolationStartAfter: InterpolationStart; -InterpolationEnd_ID - : BlockEnd -> type (BlockEnd) - ; +InterpolationEnd_ID: BlockEnd -> type (BlockEnd); -IdentifierAfter - : Identifier - ; +IdentifierAfter: Identifier; -Ellipsis_ID - : Ellipsis -> popMode , type (Ellipsis) - ; +Ellipsis_ID: Ellipsis -> popMode, type (Ellipsis); -DOT_ID - : DOT -> popMode , type (DOT) - ; +DOT_ID: DOT -> popMode, type (DOT); -LPAREN_ID - : LPAREN -> popMode , type (LPAREN) - ; +LPAREN_ID: LPAREN -> popMode, type (LPAREN); -RPAREN_ID - : RPAREN -> popMode , type (RPAREN) - ; +RPAREN_ID: RPAREN -> popMode, type (RPAREN); -COLON_ID - : COLON -> popMode , type (COLON) - ; +COLON_ID: COLON -> popMode, type (COLON); -COMMA_ID - : COMMA -> popMode , type (COMMA) - ; +COMMA_ID: COMMA -> popMode, type (COMMA); -SEMI_ID - : SEMI -> popMode , type (SEMI) - ; \ No newline at end of file +SEMI_ID: SEMI -> popMode, type (SEMI); \ No newline at end of file diff --git a/less/LessParser.g4 b/less/LessParser.g4 index 1b1bced52f..993d0dda48 100644 --- a/less/LessParser.g4 +++ b/less/LessParser.g4 @@ -4,192 +4,197 @@ All rights reserved. */ +// $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 LessParser; options - { tokenVocab = LessLexer; } + { + tokenVocab = LessLexer; +} stylesheet - : statement* EOF - ; + : statement* EOF + ; statement - : importDeclaration - | ruleset - | variableDeclaration ';' - | mixinDefinition - ; + : importDeclaration + | ruleset + | variableDeclaration ';' + | mixinDefinition + ; variableName - : AT variableName - | AT Identifier - ; + : AT variableName + | AT Identifier + ; commandStatement - : (expression +) mathStatement? - ; + : (expression+) mathStatement? + ; mathCharacter - : TIMES - | PLUS - | DIV - | MINUS - | PERC - ; + : TIMES + | PLUS + | DIV + | MINUS + | PERC + ; mathStatement - : mathCharacter commandStatement - ; + : mathCharacter commandStatement + ; expression - : measurement - | identifier IMPORTANT - | identifier - | identifier LPAREN values? RPAREN - | Color - | StringLiteral - | url - | variableName IMPORTANT - | variableName - ; + : measurement + | identifier IMPORTANT + | identifier + | identifier LPAREN values? RPAREN + | Color + | StringLiteral + | url + | variableName IMPORTANT + | variableName + ; function_ - : FUNCTION_NAME LPAREN values? RPAREN - ; + : FUNCTION_NAME LPAREN values? RPAREN + ; conditions - : condition ((AND | COMMA) condition)* - ; + : condition ((AND | COMMA) condition)* + ; condition - : LPAREN conditionStatement RPAREN - | NOT LPAREN conditionStatement RPAREN - ; + : LPAREN conditionStatement RPAREN + | NOT LPAREN conditionStatement RPAREN + ; conditionStatement - : commandStatement (EQ | LT | GT | GTEQ | LTEQ) commandStatement - | commandStatement - ; + : commandStatement (EQ | LT | GT | GTEQ | LTEQ) commandStatement + | commandStatement + ; variableDeclaration - : variableName COLON values - ; + : variableName COLON values + ; //Imports importDeclaration - : '@import' (LPAREN (importOption (COMMA importOption)*) RPAREN)? referenceUrl mediaTypes? ';' - ; + : '@import' (LPAREN (importOption (COMMA importOption)*) RPAREN)? referenceUrl mediaTypes? ';' + ; importOption - : REFERENCE - | INLINE - | LESS - | CSS - | ONCE - | MULTIPLE - ; + : REFERENCE + | INLINE + | LESS + | CSS + | ONCE + | MULTIPLE + ; referenceUrl - : StringLiteral - | UrlStart Url UrlEnd - ; + : StringLiteral + | UrlStart Url UrlEnd + ; mediaTypes - : (Identifier (COMMA Identifier)*) - ; + : (Identifier (COMMA Identifier)*) + ; //Rules ruleset - : selectors block - ; + : selectors block + ; block - : BlockStart (property_ ';' | statement | mixinReference)* property_? BlockEnd - ; + : BlockStart (property_ ';' | statement | mixinReference)* property_? BlockEnd + ; mixinDefinition - : selectors LPAREN (mixinDefinitionParam (';' mixinDefinitionParam)*)? Ellipsis? RPAREN mixinGuard? block - ; + : selectors LPAREN (mixinDefinitionParam (';' mixinDefinitionParam)*)? Ellipsis? RPAREN mixinGuard? block + ; mixinGuard - : WHEN conditions - ; + : WHEN conditions + ; mixinDefinitionParam - : variableName - | variableDeclaration - ; + : variableName + | variableDeclaration + ; mixinReference - : selector LPAREN values? RPAREN IMPORTANT? ';' - ; + : selector LPAREN values? RPAREN IMPORTANT? ';' + ; selectors - : selector (COMMA selector)* - ; + : selector (COMMA selector)* + ; selector - : element + attrib* pseudo? - ; + : element+ attrib* pseudo? + ; attrib - : '[' Identifier (attribRelate (StringLiteral | Identifier))? ']' - ; + : '[' Identifier (attribRelate (StringLiteral | Identifier))? ']' + ; negation - : COLON NOT LPAREN LBRACK? selectors RBRACK? RPAREN - ; + : COLON NOT LPAREN LBRACK? selectors RBRACK? RPAREN + ; pseudo - : (COLON | COLONCOLON) Identifier - ; + : (COLON | COLONCOLON) Identifier + ; element - : selectorPrefix identifier - | identifier - | '#' identifier - | pseudo - | negation - | PARENTREF - | '*' - ; + : selectorPrefix identifier + | identifier + | '#' identifier + | pseudo + | negation + | PARENTREF + | '*' + ; selectorPrefix - : (GT | PLUS | TIL) - ; + : (GT | PLUS | TIL) + ; attribRelate - : '=' - | '~=' - | '|=' - ; + : '=' + | '~=' + | '|=' + ; identifier - : Identifier identifierPart* - | InterpolationStart identifierVariableName BlockEnd identifierPart* - ; + : Identifier identifierPart* + | InterpolationStart identifierVariableName BlockEnd identifierPart* + ; identifierPart - : InterpolationStartAfter identifierVariableName BlockEnd - | IdentifierAfter - ; + : InterpolationStartAfter identifierVariableName BlockEnd + | IdentifierAfter + ; identifierVariableName - : (Identifier | IdentifierAfter) - ; + : (Identifier | IdentifierAfter) + ; property_ - : identifier COLON values - ; + : identifier COLON values + ; values - : commandStatement (COMMA commandStatement)* - ; + : commandStatement (COMMA commandStatement)* + ; url - : UrlStart Url UrlEnd - ; + : UrlStart Url UrlEnd + ; measurement - : Number Unit? - ; + : Number Unit? + ; \ No newline at end of file diff --git a/limbo/limbo.g4 b/limbo/limbo.g4 index 0dfa72e8fc..7a6e42e3fd 100644 --- a/limbo/limbo.g4 +++ b/limbo/limbo.g4 @@ -29,424 +29,427 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar limbo; program - : 'implement' IDENTIFIER ';' top_declaration_sequence EOF - ; + : 'implement' IDENTIFIER ';' top_declaration_sequence EOF + ; top_declaration_sequence - : top_declaration+ - ; + : top_declaration+ + ; top_declaration - : declaration - | identifier_list ':=' expression ';' - | identifier_list ASSIGN expression ';' - | '(' identifier_list ')' ':=' expression ';' - | module_declaration - | function_definition - | adt_declaration - ; + : declaration + | identifier_list ':=' expression ';' + | identifier_list ASSIGN expression ';' + | '(' identifier_list ')' ':=' expression ';' + | module_declaration + | function_definition + | adt_declaration + ; declaration - : identifier_list ':' type_ ';' - | identifier_list ':' type_ ASSIGN expression ';' - | identifier_list ':' 'con' expression ';' - | identifier_list ':' 'import' IDENTIFIER ';' - | identifier_list ':' 'type' type_ ';' - | 'include' string_constant ';' - ; + : identifier_list ':' type_ ';' + | identifier_list ':' type_ ASSIGN expression ';' + | identifier_list ':' 'con' expression ';' + | identifier_list ':' 'import' IDENTIFIER ';' + | identifier_list ':' 'type' type_ ';' + | 'include' string_constant ';' + ; identifier_list - : IDENTIFIER - | identifier_list ',' IDENTIFIER - ; + : IDENTIFIER + | identifier_list ',' IDENTIFIER + ; expression_list - : expression+ - ; + : expression+ + ; type_ - : data_type - | function_type - ; + : data_type + | function_type + ; data_type - : byte_ - | int_ - | big - | real_ - | string_ - | tuple_type - | 'array' 'of' data_type - | 'list' 'of' data_type - | 'chan' 'of' data_type - | adt_type - | 'ref' adt_type - | module_type - | module_qualified_type - | type_name - ; + : byte_ + | int_ + | big + | real_ + | string_ + | tuple_type + | 'array' 'of' data_type + | 'list' 'of' data_type + | 'chan' 'of' data_type + | adt_type + | 'ref' adt_type + | module_type + | module_qualified_type + | type_name + ; string_ - : STRING - ; + : STRING + ; real_ - : REAL - ; + : REAL + ; byte_ - : INT - ; + : INT + ; int_ - : INT - ; + : INT + ; big - : INT - ; + : INT + ; tuple_type - : '(' data_type_list ')' - ; + : '(' data_type_list ')' + ; data_type_list - : data_type (',' data_type)* - ; + : data_type (',' data_type)* + ; adt_type - : IDENTIFIER - | module_qualified_type - ; + : IDENTIFIER + | module_qualified_type + ; module_type - : IDENTIFIER - ; + : IDENTIFIER + ; module_qualified_type - : IDENTIFIER '->' IDENTIFIER - ; + : IDENTIFIER '->' IDENTIFIER + ; type_name - : IDENTIFIER - ; + : IDENTIFIER + ; function_type - : 'fn' function_arg_ret - ; + : 'fn' function_arg_ret + ; function_arg_ret - : '(' formal_arg_list? ')' - | '(' formal_arg_list? ')' ':' data_type - ; + : '(' formal_arg_list? ')' + | '(' formal_arg_list? ')' ':' data_type + ; formal_arg_list - : formal_arg (',' formal_arg)* - ; + : formal_arg (',' formal_arg)* + ; formal_arg - : nil_or_D_list ':' type_ - | nil_or_D ':' 'self' 'refopt' IDENTIFIER - | nil_or_D ':' 'self' IDENTIFIER - | '*' - ; + : nil_or_D_list ':' type_ + | nil_or_D ':' 'self' 'refopt' IDENTIFIER + | nil_or_D ':' 'self' IDENTIFIER + | '*' + ; nil_or_D_list - : nil_or_D (',' nil_or_D)* - ; + : nil_or_D (',' nil_or_D)* + ; nil_or_D - : IDENTIFIER - | 'nil' - ; + : IDENTIFIER + | 'nil' + ; module_declaration - : IDENTIFIER ':' 'module' '{' mod_member_list? '}' ';' - ; + : IDENTIFIER ':' 'module' '{' mod_member_list? '}' ';' + ; mod_member_list - : mod_member+ - ; + : mod_member+ + ; mod_member - : identifier_list ':' function_type ';' - | identifier_list ':' data_type ';' - | adt_declaration ';' - | identifier_list ':' 'con' expression ';' - | identifier_list ':' 'type' type_ ';' - ; + : identifier_list ':' function_type ';' + | identifier_list ':' data_type ';' + | adt_declaration ';' + | identifier_list ':' 'con' expression ';' + | identifier_list ':' 'type' type_ ';' + ; adt_declaration - : IDENTIFIER ':' 'adt' '{' adt_member_list? '}' ';' - ; + : IDENTIFIER ':' 'adt' '{' adt_member_list? '}' ';' + ; adt_member_list - : adt_member - | adt_member_list adt_member - ; + : adt_member + | adt_member_list adt_member + ; adt_member - : identifier_list ':' 'cyclicopt' data_type ';' - | identifier_list ':' 'con' expression ';' - | identifier_list ':' function_type ';' - | 'pick' '{' pick_member_list '}' ';' - ; + : identifier_list ':' 'cyclicopt' data_type ';' + | identifier_list ':' 'con' expression ';' + | identifier_list ':' function_type ';' + | 'pick' '{' pick_member_list '}' ';' + ; pick_member_list - : pick_tag_list '=>' - | pick_member_list pick_tag_list '=>' - | pick_member_list identifier_list ':' 'cyclicopt' data_type ';' - ; + : pick_tag_list '=>' + | pick_member_list pick_tag_list '=>' + | pick_member_list identifier_list ':' 'cyclicopt' data_type ';' + ; pick_tag_list - : IDENTIFIER ('or' IDENTIFIER)* - ; + : IDENTIFIER ('or' IDENTIFIER)* + ; function_definition - : function_name_part function_arg_ret '{' statements_ '}' - ; + : function_name_part function_arg_ret '{' statements_ '}' + ; function_name_part - : IDENTIFIER ('.' IDENTIFIER)* - ; + : IDENTIFIER ('.' IDENTIFIER)* + ; statements_ - : (declaration | statement)* - ; + : (declaration | statement)* + ; statement - : expression ';' - | ';' - | '{' statements_ '}' - | 'if' '(' expression ')' statement - | 'if' '(' expression ')' statement 'else' statement - | label? 'while' '(' expression? ')' statement - | label? 'do' statement 'while' '(' expression? ')' ';' - | label? 'for' '(' expression? ';' expression? ';' expression? ')' statement - | label? 'case' expression '{' qual_statement_sequence '}' - | label? 'alt' '{' qual_statement_sequence '}' - | label? 'pick' IDENTIFIER ':=' expression '{' pqual_statement_sequence '}' - | 'break' IDENTIFIER? ';' - | 'continue' IDENTIFIER? ';' - | 'return' expression? ';' - | 'spawn' term '(' expression_list? ')' ';' - | 'exit' ';' - ; + : expression ';' + | ';' + | '{' statements_ '}' + | 'if' '(' expression ')' statement + | 'if' '(' expression ')' statement 'else' statement + | label? 'while' '(' expression? ')' statement + | label? 'do' statement 'while' '(' expression? ')' ';' + | label? 'for' '(' expression? ';' expression? ';' expression? ')' statement + | label? 'case' expression '{' qual_statement_sequence '}' + | label? 'alt' '{' qual_statement_sequence '}' + | label? 'pick' IDENTIFIER ':=' expression '{' pqual_statement_sequence '}' + | 'break' IDENTIFIER? ';' + | 'continue' IDENTIFIER? ';' + | 'return' expression? ';' + | 'spawn' term '(' expression_list? ')' ';' + | 'exit' ';' + ; label - : IDENTIFIER ':' - ; + : IDENTIFIER ':' + ; qual_statement_sequence - : qual_list '=>' - | qual_statement_sequence qual_list '=>' - | qual_statement_sequence statement - | qual_statement_sequence declaration - ; + : qual_list '=>' + | qual_statement_sequence qual_list '=>' + | qual_statement_sequence statement + | qual_statement_sequence declaration + ; qual_list - : qualifier ('or' qualifier)* - ; + : qualifier ('or' qualifier)* + ; qualifier - : expression - | expression 'to' expression - | '*' - ; + : expression + | expression 'to' expression + | '*' + ; pqual_statement_sequence - : pqual_list '=>' - | pqual_statement_sequence pqual_list '=>' - | pqual_statement_sequence statement - | pqual_statement_sequence declaration - ; + : pqual_list '=>' + | pqual_statement_sequence pqual_list '=>' + | pqual_statement_sequence statement + | pqual_statement_sequence declaration + ; pqual_list - : pqualifier ('or' pqualifier)* - ; + : pqualifier ('or' pqualifier)* + ; pqualifier - : IDENTIFIER - | '*' - ; + : IDENTIFIER + | '*' + ; expression - : binary_expression - | lvalue_expression ASSIGNMENT_OPERATOR expression - | '(' lvalue_expression_list ')' ASSIGN expression - | send_expression - | declare_expression - | load_expression - ; + : binary_expression + | lvalue_expression ASSIGNMENT_OPERATOR expression + | '(' lvalue_expression_list ')' ASSIGN expression + | send_expression + | declare_expression + | load_expression + ; binary_expression - : monadic_expression - | binary_expression BINARY_OPERATOR binary_expression - ; + : monadic_expression + | binary_expression BINARY_OPERATOR binary_expression + ; lvalue_expression - : IDENTIFIER - | 'nil' - | term '[' expression ']' - | term '[' expression ':' ']' - | term '.' IDENTIFIER - | '(' lvalue_expression_list ')' - | '*' monadic_expression - ; + : IDENTIFIER + | 'nil' + | term '[' expression ']' + | term '[' expression ':' ']' + | term '.' IDENTIFIER + | '(' lvalue_expression_list ')' + | '*' monadic_expression + ; lvalue_expression_list - : lvalue_expression (',' lvalue_expression)* - ; + : lvalue_expression (',' lvalue_expression)* + ; init_list - : element (',' element)* - ; + : element (',' element)* + ; term - : IDENTIFIER - // | constant - | real_constant - | string_constant - | 'nil' - | '(' expression_list ')' - | term '.' IDENTIFIER - | term '->' term - | term '(' expression_list? ')' - | term '[' expression ']' - | term '[' expression ':' expression ']' - | term '[' expression ':' ']' - | term '++' - | term '--' - ; + : IDENTIFIER + // | constant + | real_constant + | string_constant + | 'nil' + | '(' expression_list ')' + | term '.' IDENTIFIER + | term '->' term + | term '(' expression_list? ')' + | term '[' expression ']' + | term '[' expression ':' expression ']' + | term '[' expression ':' ']' + | term '++' + | term '--' + ; real_constant - : REAL - ; + : REAL + ; string_constant - : STRING - ; + : STRING + ; element - : expression - | expression '=>' expression - | '*' '=>' expression - ; + : expression + | expression '=>' expression + | '*' '=>' expression + ; send_expression - : lvalue_expression '<-' ASSIGN expression - ; + : lvalue_expression '<-' ASSIGN expression + ; declare_expression - : lvalue_expression ':=' expression - ; + : lvalue_expression ':=' expression + ; load_expression - : 'load' IDENTIFIER expression - ; + : 'load' IDENTIFIER expression + ; monadic_expression - : term - | MONADICOPERATOR monadic_expression - | 'array' '[' expression ']' 'of' data_type - | 'array' '[' expression? ']' 'of' '{' init_list '}' - | 'list' 'of' '{' expression_list '}' - | 'chan' 'of' data_type - | data_type monadic_expression - ; + : term + | MONADICOPERATOR monadic_expression + | 'array' '[' expression ']' 'of' data_type + | 'array' '[' expression? ']' 'of' '{' init_list '}' + | 'list' 'of' '{' expression_list '}' + | 'chan' 'of' data_type + | data_type monadic_expression + ; STRING - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; IDENTIFIER - : [a-zA-Z] [a-zA-Z0-9_]* - ; + : [a-zA-Z] [a-zA-Z0-9_]* + ; REAL - : [0-9]+ '.' ('e' | 'E')? [0-9a-zA-Z]+ - ; + : [0-9]+ '.' ('e' | 'E')? [0-9a-zA-Z]+ + ; INT - : ([0-9]+ 'r' | 'R')? [0-9]+ - ; + : ([0-9]+ 'r' | 'R')? [0-9]+ + ; ASSIGNMENT_OPERATOR - : ASSIGN - | '&=' - | '|=' - | '^=' - | '<<=' - | '>>=' - | '+=' - | '-=' - | '*=' - | '/=' - | '%=' - ; + : ASSIGN + | '&=' + | '|=' + | '^=' + | '<<=' + | '>>=' + | '+=' + | '-=' + | '*=' + | '/=' + | '%=' + ; ASSIGN - : '=' - ; + : '=' + ; BINARY_OPERATOR - : MULT - | '/' - | '%' - | PLUS - | MINUS - | '<<' - | '>>' - | '<' - | '>' - | '<=' - | '>=' - | '==' - | '!=' - | '&' - | '^' - | '|' - | '::' - | '&&' - | '||' - ; + : MULT + | '/' + | '%' + | PLUS + | MINUS + | '<<' + | '>>' + | '<' + | '>' + | '<=' + | '>=' + | '==' + | '!=' + | '&' + | '^' + | '|' + | '::' + | '&&' + | '||' + ; MONADICOPERATOR - : PLUS - | MINUS - | '!' - | '~' - | 'ref' - | MULT - | '++' - | '--' - | '<-' - | 'hd' - | 'tl' - | 'len' - | 'tagof' - ; + : PLUS + | MINUS + | '!' + | '~' + | 'ref' + | MULT + | '++' + | '--' + | '<-' + | 'hd' + | 'tl' + | 'len' + | 'tagof' + ; MULT - : '*' - ; + : '*' + ; PLUS - : '+' - ; + : '+' + ; MINUS - : '-' - ; + : '-' + ; COMMENT - : '#' ~ [\r\n]* -> skip - ; + : '#' ~ [\r\n]* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/lisa/lisa.g4 b/lisa/lisa.g4 index 3853aad2ef..a0fc3784a2 100644 --- a/lisa/lisa.g4 +++ b/lisa/lisa.g4 @@ -22,98 +22,193 @@ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -grammar lisa; - -program: declaration_block program_block EOF; - -declaration_block: 'declare' '{' declaration_statements '}'; - -declaration_statements: declaration_statement+; - -declaration_statement: type_ ID ';'; - -type_: 'int' | 'dfa' | 'nfa' | 'regex' | 'bool' | 'string'; - -program_block: 'program' '{' statements '}'; - -statements: statement+; - -statement: - expression_statement - | if_statement - | while_statement - | generating_statement - | ('break' ';') - | ('continue' ';'); - -generating_statement: - 'generate' '(' generator_type ',' 'int' ',' 'int' ')' statement; - -generator_type: 'random' | 'enumerate'; - -expression_statement: expression ';'; - -if_statement: 'if' '(' expression ')' statement; - -while_statement: WHILE '(' expression ')' statement; - -expression: (variable (exprop expression)*) | simple_expression; - -exprop: '=' | '-+' | '*=' | '/=' | '+='; - -simple_expression: or_expression ('||' or_expression)*; - -or_expression: - unary_relationexpression ('&&' unary_relationexpression)*; - -unary_relationexpression: '!'? relation_expression; -relation_expression: add_expression (relop add_expression)*; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -relop: '<=' | '>=' | '==' | '!=' | '>' | '>'; - -add_expression: term (addop term)*; - -addop: '-' | '+'; - -term: factor (multop factor)*; - -multop: '*' | '/' | '%'; - -factor: '(' simple_expression ')' | constant; - -constant: - integer - | TRUE - | FALSE - | 'next' - | 'hasnext' - | variable - | STRINGLITERAL - | function_ - | type_; - -integer: ('+' | '-')? INTEGER; - -function_: ID '(' parameter_list ')'; - -parameter_list: simple_expression (',' simple_expression)*; - -variable: ID; - -TRUE: 'TRUE'; - -FALSE: 'FALSE'; - -WHILE: 'WHILE'; - -INTEGER: [1-9]([0-9]*); - -ID: [a-zA-Z] ([a-z0-9A-Z_]*); - -STRINGLITERAL: '"' .*? '"'; - -COMMENT: '//' ~[\r\n]* -> skip; - -WS: [ \r\n\t]+ -> skip; +grammar lisa; +program + : declaration_block program_block EOF + ; + +declaration_block + : 'declare' '{' declaration_statements '}' + ; + +declaration_statements + : declaration_statement+ + ; + +declaration_statement + : type_ ID ';' + ; + +type_ + : 'int' + | 'dfa' + | 'nfa' + | 'regex' + | 'bool' + | 'string' + ; + +program_block + : 'program' '{' statements '}' + ; + +statements + : statement+ + ; + +statement + : expression_statement + | if_statement + | while_statement + | generating_statement + | ('break' ';') + | ('continue' ';') + ; + +generating_statement + : 'generate' '(' generator_type ',' 'int' ',' 'int' ')' statement + ; + +generator_type + : 'random' + | 'enumerate' + ; + +expression_statement + : expression ';' + ; + +if_statement + : 'if' '(' expression ')' statement + ; + +while_statement + : WHILE '(' expression ')' statement + ; + +expression + : (variable (exprop expression)*) + | simple_expression + ; + +exprop + : '=' + | '-+' + | '*=' + | '/=' + | '+=' + ; + +simple_expression + : or_expression ('||' or_expression)* + ; + +or_expression + : unary_relationexpression ('&&' unary_relationexpression)* + ; + +unary_relationexpression + : '!'? relation_expression + ; + +relation_expression + : add_expression (relop add_expression)* + ; + +relop + : '<=' + | '>=' + | '==' + | '!=' + | '>' + | '>' + ; + +add_expression + : term (addop term)* + ; + +addop + : '-' + | '+' + ; + +term + : factor (multop factor)* + ; + +multop + : '*' + | '/' + | '%' + ; + +factor + : '(' simple_expression ')' + | constant + ; + +constant + : integer + | TRUE + | FALSE + | 'next' + | 'hasnext' + | variable + | STRINGLITERAL + | function_ + | type_ + ; + +integer + : ('+' | '-')? INTEGER + ; + +function_ + : ID '(' parameter_list ')' + ; + +parameter_list + : simple_expression (',' simple_expression)* + ; + +variable + : ID + ; + +TRUE + : 'TRUE' + ; + +FALSE + : 'FALSE' + ; + +WHILE + : 'WHILE' + ; + +INTEGER + : [1-9]([0-9]*) + ; + +ID + : [a-zA-Z] ([a-z0-9A-Z_]*) + ; + +STRINGLITERAL + : '"' .*? '"' + ; + +COMMENT + : '//' ~[\r\n]* -> skip + ; + +WS + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/lisp/lisp.g4 b/lisp/lisp.g4 index 9ea0d1b21d..6e8221cf96 100644 --- a/lisp/lisp.g4 +++ b/lisp/lisp.g4 @@ -29,39 +29,42 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar lisp; lisp_ - : s_expression+ EOF - ; + : s_expression+ EOF + ; s_expression - : ATOMIC_SYMBOL - | '(' s_expression '.' s_expression ')' - | list - ; + : ATOMIC_SYMBOL + | '(' s_expression '.' s_expression ')' + | list + ; list - : '(' s_expression+ ')' - ; + : '(' s_expression+ ')' + ; ATOMIC_SYMBOL - : LETTER ATOM_PART? - ; + : LETTER ATOM_PART? + ; fragment ATOM_PART - : (LETTER | NUMBER) ATOM_PART - ; + : (LETTER | NUMBER) ATOM_PART + ; fragment LETTER - : [a-z] - ; + : [a-z] + ; fragment NUMBER - : [1-9] - ; + : [1-9] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/llvm-ir/LLVMIR.g4 b/llvm-ir/LLVMIR.g4 index f5af025542..b9509f04aa 100644 --- a/llvm-ir/LLVMIR.g4 +++ b/llvm-ir/LLVMIR.g4 @@ -22,1381 +22,2364 @@ SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar LLVMIR; -compilationUnit: topLevelEntity* EOF; - -targetDef: targetDataLayout | targetTriple; -sourceFilename: 'source_filename' '=' StringLit; -targetDataLayout: 'target' 'datalayout' '=' StringLit; -targetTriple: 'target' 'triple' '=' StringLit; - -topLevelEntity: - sourceFilename - | targetDef - | moduleAsm - | typeDef - | comdatDef - | globalDecl - | globalDef - | indirectSymbolDef - | funcDecl - | funcDef - | attrGroupDef - | namedMetadataDef - | metadataDef - | useListOrder - | useListOrderBB; -moduleAsm: 'module' 'asm' StringLit; -typeDef: LocalIdent '=' 'type' type; -comdatDef: - ComdatName '=' 'comdat' selectionKind = ( - 'any' - | 'exactmatch' - | 'largest' - | 'nodeduplicate' - | 'samesize' - ); -globalDecl: - GlobalIdent '=' externalLinkage preemption? visibility? dllStorageClass? threadLocal? - unnamedAddr? addrSpace? externallyInitialized? immutable type ( - ',' globalField - )* (',' metadataAttachment)* funcAttribute*; -globalDef: - GlobalIdent '=' internalLinkage? preemption? visibility? dllStorageClass? threadLocal? - unnamedAddr? addrSpace? externallyInitialized? immutable type constant ( - ',' globalField - )* (',' metadataAttachment)* funcAttribute*; - -indirectSymbolDef: - GlobalIdent '=' linkage? preemption? visibility? dllStorageClass? threadLocal? unnamedAddr? - indirectSymbolKind = ('alias' | 'ifunc') type ',' indirectSymbol ( - ',' partition - )*; - -funcDecl: 'declare' metadataAttachment* funcHeader; -funcDef: 'define' funcHeader metadataAttachment* funcBody; -attrGroupDef: - 'attributes' AttrGroupId '=' '{' funcAttribute* '}'; -namedMetadataDef: - MetadataName '=' '!' '{' (metadataNode (',' metadataNode)*)? '}'; -metadataDef: - MetadataId '=' distinct? (mdTuple | specializedMDNode); -useListOrder: - 'uselistorder' typeValue ',' '{' IntLit (',' IntLit)* '}'; -useListOrderBB: - 'uselistorder_bb' GlobalIdent ',' LocalIdent ',' '{' IntLit ( - ',' IntLit - )* '}'; - -funcHeader: - linkage? preemption? visibility? dllStorageClass? callingConv? returnAttribute* type GlobalIdent - '(' params ')' unnamedAddr? addrSpace? funcHdrField*; -indirectSymbol: - typeConst - | bitCastExpr - | getElementPtrExpr - | addrSpaceCastExpr - | intToPtrExpr; -callingConv: callingConvEnum | callingConvInt; -callingConvInt: 'cc' IntLit; -funcHdrField: - funcAttribute - | section - | partition - | comdat - | align - | gc - | prefix - | prologue - | personality; -gc: 'gc' StringLit; -prefix: 'prefix' typeConst; -prologue: 'prologue' typeConst; -personality: 'personality' typeConst; -returnAttribute: - returnAttr +compilationUnit + : topLevelEntity* EOF + ; + +targetDef + : targetDataLayout + | targetTriple + ; + +sourceFilename + : 'source_filename' '=' StringLit + ; + +targetDataLayout + : 'target' 'datalayout' '=' StringLit + ; + +targetTriple + : 'target' 'triple' '=' StringLit + ; + +topLevelEntity + : sourceFilename + | targetDef + | moduleAsm + | typeDef + | comdatDef + | globalDecl + | globalDef + | indirectSymbolDef + | funcDecl + | funcDef + | attrGroupDef + | namedMetadataDef + | metadataDef + | useListOrder + | useListOrderBB + ; + +moduleAsm + : 'module' 'asm' StringLit + ; + +typeDef + : LocalIdent '=' 'type' type + ; + +comdatDef + : ComdatName '=' 'comdat' selectionKind = ( + 'any' + | 'exactmatch' + | 'largest' + | 'nodeduplicate' + | 'samesize' + ) + ; + +globalDecl + : GlobalIdent '=' externalLinkage preemption? visibility? dllStorageClass? threadLocal? unnamedAddr? addrSpace? externallyInitialized? immutable + type (',' globalField)* (',' metadataAttachment)* funcAttribute* + ; + +globalDef + : GlobalIdent '=' internalLinkage? preemption? visibility? dllStorageClass? threadLocal? unnamedAddr? addrSpace? externallyInitialized? immutable + type constant (',' globalField)* (',' metadataAttachment)* funcAttribute* + ; + +indirectSymbolDef + : GlobalIdent '=' linkage? preemption? visibility? dllStorageClass? threadLocal? unnamedAddr? indirectSymbolKind = ( + 'alias' + | 'ifunc' + ) type ',' indirectSymbol (',' partition)* + ; + +funcDecl + : 'declare' metadataAttachment* funcHeader + ; + +funcDef + : 'define' funcHeader metadataAttachment* funcBody + ; + +attrGroupDef + : 'attributes' AttrGroupId '=' '{' funcAttribute* '}' + ; + +namedMetadataDef + : MetadataName '=' '!' '{' (metadataNode (',' metadataNode)*)? '}' + ; + +metadataDef + : MetadataId '=' distinct? (mdTuple | specializedMDNode) + ; + +useListOrder + : 'uselistorder' typeValue ',' '{' IntLit (',' IntLit)* '}' + ; + +useListOrderBB + : 'uselistorder_bb' GlobalIdent ',' LocalIdent ',' '{' IntLit (',' IntLit)* '}' + ; + +funcHeader + : linkage? preemption? visibility? dllStorageClass? callingConv? returnAttribute* type GlobalIdent '(' params ')' unnamedAddr? addrSpace? + funcHdrField* + ; + +indirectSymbol + : typeConst + | bitCastExpr + | getElementPtrExpr + | addrSpaceCastExpr + | intToPtrExpr + ; + +callingConv + : callingConvEnum + | callingConvInt + ; + +callingConvInt + : 'cc' IntLit + ; + +funcHdrField + : funcAttribute + | section + | partition + | comdat + | align + | gc + | prefix + | prologue + | personality + ; + +gc + : 'gc' StringLit + ; + +prefix + : 'prefix' typeConst + ; + +prologue + : 'prologue' typeConst + ; + +personality + : 'personality' typeConst + ; + +returnAttribute + : returnAttr | dereferenceable - | align; -funcBody: '{' basicBlock+ useListOrder* '}'; -basicBlock: LabelIdent? instruction* terminator; -instruction: // Instructions producing values. - localDefInst - | valueInstruction - // Instructions not producing values. - | storeInst - | fenceInst; -terminator: - // Terminators producing values. - localDefTerm - | valueTerminator - // Terminators not producing values. - | retTerm - | brTerm - | condBrTerm - | switchTerm - | indirectBrTerm - | resumeTerm - | catchRetTerm - | cleanupRetTerm - | unreachableTerm; -localDefTerm: LocalIdent '=' valueTerminator; -valueTerminator: invokeTerm | callBrTerm | catchSwitchTerm; -retTerm: - 'ret' 'void' (',' metadataAttachment)* - // Value return. - | 'ret' concreteType value (',' metadataAttachment)*; -brTerm: 'br' label (',' metadataAttachment)*; -condBrTerm: - 'br' IntType value ',' label ',' label ( - ',' metadataAttachment - )*; -switchTerm: - 'switch' typeValue ',' label '[' case* ']' ( - ',' metadataAttachment - )*; -indirectBrTerm: - 'indirectbr' typeValue ',' '[' (label (',' label)?)? ']' ( - ',' metadataAttachment - )*; -resumeTerm: 'resume' typeValue (',' metadataAttachment)*; -catchRetTerm: - 'catchret' 'from' value 'to' label (',' metadataAttachment)*; -cleanupRetTerm: - 'cleanupret' 'from' value 'unwind' unwindTarget ( - ',' metadataAttachment - )*; -unreachableTerm: 'unreachable' (',' metadataAttachment)*; -invokeTerm: - 'invoke' callingConv? returnAttribute* addrSpace? type value '(' args ')' funcAttribute* ( - '[' (operandBundle ',')+ ']' - )? 'to' label 'unwind' label (',' metadataAttachment)*; -callBrTerm: - 'callbr' callingConv? returnAttribute* addrSpace? type value '(' args ')' funcAttribute* ( - '[' (operandBundle ',')+ ']' - )? 'to' label '[' (label (',' label)*)? ']' ( - ',' metadataAttachment - )*; -catchSwitchTerm: - 'catchswitch' 'within' exceptionPad '[' handlers ']' 'unwind' unwindTarget ( - ',' metadataAttachment - )*; -label: 'label' LocalIdent; -case: typeConst ',' label; -unwindTarget: 'to' 'caller' | label; -handlers: label (',' label)*; -metadataNode: - MetadataId - // Parse DIExpressions inline as a special case. They are still MDNodes, so they can still - // appear in named metadata. Remove this logic if they become plain Metadata. - | diExpression; -diExpression: - '!DIExpression' '(' ( - diExpressionField (',' diExpressionField)* - )? ')'; -diExpressionField: IntLit | DwarfAttEncoding | DwarfOp; - -globalField: - section - | partition - | comdat - | align - | sanitizerKind = ( - 'no_sanitize_address' - | 'no_sanitize_hwaddress' - | 'sanitize_address_dyninit' - | 'sanitize_memtag' - ); -section: 'section' StringLit; -comdat: 'comdat' ('(' ComdatName ')')?; -partition: 'partition' StringLit; - -constant: - boolConst - | intConst - | floatConst - | nullConst - | noneConst - | structConst - | arrayConst - | vectorConst - | zeroInitializerConst - // @42 @foo - | GlobalIdent - | undefConst - | poisonConst - | blockAddressConst - | dsoLocalEquivalentConst - | noCFIConst - | constantExpr; -boolConst: 'true' | 'false'; -intConst: IntLit; -floatConst: FloatLit; -nullConst: 'null'; -noneConst: 'none'; -structConst: - '{' (typeConst (',' typeConst)*)? '}' - | '<' '{' ( typeConst (',' typeConst)*)? '}' '>'; -arrayConst: - 'c' StringLit - | '[' (typeConst (',' typeConst)*)? ']'; -vectorConst: '<' (typeConst (',' typeConst)*)? '>'; -zeroInitializerConst: 'zeroinitializer'; -undefConst: 'undef'; -poisonConst: 'poison'; -blockAddressConst: - 'blockaddress' '(' GlobalIdent ',' LocalIdent ')'; -dsoLocalEquivalentConst: 'dso_local_equivalent' GlobalIdent; -noCFIConst: 'no_cfi' GlobalIdent; -constantExpr: - // Unary expressions - fNegExpr - // Binary expressions - | addExpr - | subExpr - | mulExpr - // Bitwise expressions - | shlExpr - | lShrExpr - | aShrExpr - | andExpr - | orExpr - | xorExpr - // Vector expressions - | extractElementExpr - | insertElementExpr - | shuffleVectorExpr - // Memory expressions - | getElementPtrExpr - // Conversion expressions - | truncExpr - | zExtExpr - | sExtExpr - | fpTruncExpr - | fpExtExpr - | fpToUiExpr - | fpToSiExpr - | uiToFpExpr - | siToFpExpr - | ptrToIntExpr - | intToPtrExpr - | bitCastExpr - | addrSpaceCastExpr - // Other expressions - | iCmpExpr - | fCmpExpr - | selectExpr; -typeConst: firstClassType constant; - -metadataAttachment: MetadataName mdNode; -mdNode: - mdTuple - // !42 - | MetadataId - //!{ ... } - | specializedMDNode; -mdTuple: '!' '{' (mdField (',' mdField)*)? '}'; + | align + ; + +funcBody + : '{' basicBlock+ useListOrder* '}' + ; + +basicBlock + : LabelIdent? instruction* terminator + ; + +instruction + : // Instructions producing values. + localDefInst + | valueInstruction + // Instructions not producing values. + | storeInst + | fenceInst + ; + +terminator + : + // Terminators producing values. + localDefTerm + | valueTerminator + // Terminators not producing values. + | retTerm + | brTerm + | condBrTerm + | switchTerm + | indirectBrTerm + | resumeTerm + | catchRetTerm + | cleanupRetTerm + | unreachableTerm + ; + +localDefTerm + : LocalIdent '=' valueTerminator + ; + +valueTerminator + : invokeTerm + | callBrTerm + | catchSwitchTerm + ; + +retTerm + : 'ret' 'void' (',' metadataAttachment)* + // Value return. + | 'ret' concreteType value (',' metadataAttachment)* + ; + +brTerm + : 'br' label (',' metadataAttachment)* + ; + +condBrTerm + : 'br' IntType value ',' label ',' label (',' metadataAttachment)* + ; + +switchTerm + : 'switch' typeValue ',' label '[' case* ']' (',' metadataAttachment)* + ; + +indirectBrTerm + : 'indirectbr' typeValue ',' '[' (label (',' label)?)? ']' (',' metadataAttachment)* + ; + +resumeTerm + : 'resume' typeValue (',' metadataAttachment)* + ; + +catchRetTerm + : 'catchret' 'from' value 'to' label (',' metadataAttachment)* + ; + +cleanupRetTerm + : 'cleanupret' 'from' value 'unwind' unwindTarget (',' metadataAttachment)* + ; + +unreachableTerm + : 'unreachable' (',' metadataAttachment)* + ; + +invokeTerm + : 'invoke' callingConv? returnAttribute* addrSpace? type value '(' args ')' funcAttribute* ( + '[' (operandBundle ',')+ ']' + )? 'to' label 'unwind' label (',' metadataAttachment)* + ; + +callBrTerm + : 'callbr' callingConv? returnAttribute* addrSpace? type value '(' args ')' funcAttribute* ( + '[' (operandBundle ',')+ ']' + )? 'to' label '[' (label (',' label)*)? ']' (',' metadataAttachment)* + ; + +catchSwitchTerm + : 'catchswitch' 'within' exceptionPad '[' handlers ']' 'unwind' unwindTarget ( + ',' metadataAttachment + )* + ; + +label + : 'label' LocalIdent + ; + +case + : typeConst ',' label + ; + +unwindTarget + : 'to' 'caller' + | label + ; + +handlers + : label (',' label)* + ; + +metadataNode + : MetadataId + // Parse DIExpressions inline as a special case. They are still MDNodes, so they can still + // appear in named metadata. Remove this logic if they become plain Metadata. + | diExpression + ; + +diExpression + : '!DIExpression' '(' (diExpressionField (',' diExpressionField)*)? ')' + ; + +diExpressionField + : IntLit + | DwarfAttEncoding + | DwarfOp + ; + +globalField + : section + | partition + | comdat + | align + | sanitizerKind = ( + 'no_sanitize_address' + | 'no_sanitize_hwaddress' + | 'sanitize_address_dyninit' + | 'sanitize_memtag' + ) + ; + +section + : 'section' StringLit + ; + +comdat + : 'comdat' ('(' ComdatName ')')? + ; + +partition + : 'partition' StringLit + ; + +constant + : boolConst + | intConst + | floatConst + | nullConst + | noneConst + | structConst + | arrayConst + | vectorConst + | zeroInitializerConst + // @42 @foo + | GlobalIdent + | undefConst + | poisonConst + | blockAddressConst + | dsoLocalEquivalentConst + | noCFIConst + | constantExpr + ; + +boolConst + : 'true' + | 'false' + ; + +intConst + : IntLit + ; + +floatConst + : FloatLit + ; + +nullConst + : 'null' + ; + +noneConst + : 'none' + ; + +structConst + : '{' (typeConst (',' typeConst)*)? '}' + | '<' '{' ( typeConst (',' typeConst)*)? '}' '>' + ; + +arrayConst + : 'c' StringLit + | '[' (typeConst (',' typeConst)*)? ']' + ; + +vectorConst + : '<' (typeConst (',' typeConst)*)? '>' + ; + +zeroInitializerConst + : 'zeroinitializer' + ; + +undefConst + : 'undef' + ; + +poisonConst + : 'poison' + ; + +blockAddressConst + : 'blockaddress' '(' GlobalIdent ',' LocalIdent ')' + ; + +dsoLocalEquivalentConst + : 'dso_local_equivalent' GlobalIdent + ; + +noCFIConst + : 'no_cfi' GlobalIdent + ; + +constantExpr + : + // Unary expressions + fNegExpr + // Binary expressions + | addExpr + | subExpr + | mulExpr + // Bitwise expressions + | shlExpr + | lShrExpr + | aShrExpr + | andExpr + | orExpr + | xorExpr + // Vector expressions + | extractElementExpr + | insertElementExpr + | shuffleVectorExpr + // Memory expressions + | getElementPtrExpr + // Conversion expressions + | truncExpr + | zExtExpr + | sExtExpr + | fpTruncExpr + | fpExtExpr + | fpToUiExpr + | fpToSiExpr + | uiToFpExpr + | siToFpExpr + | ptrToIntExpr + | intToPtrExpr + | bitCastExpr + | addrSpaceCastExpr + // Other expressions + | iCmpExpr + | fCmpExpr + | selectExpr + ; + +typeConst + : firstClassType constant + ; + +metadataAttachment + : MetadataName mdNode + ; + +mdNode + : mdTuple + // !42 + | MetadataId + //!{ ... } + | specializedMDNode + ; + +mdTuple + : '!' '{' (mdField (',' mdField)*)? '}' + ; + // metadataID: MetadataId; -metadata: - typeValue - | mdString - // !{ ... } - | mdTuple - // !7 - | MetadataId - | diArgList - | specializedMDNode; -diArgList: '!DIArgList' '(' (typeValue (',' typeValue)*)? ')'; -typeValue: firstClassType value; -value: - constant - // %42 %foo - | LocalIdent - // TODO: Move InlineAsm from Value to Callee and Invokee? Inline assembler expressions may only - // be used as the callee operand of a call or an invoke instruction. - | inlineAsm; -inlineAsm: - 'asm' sideEffect = 'sideeffect'? alignStackTok = 'alignstack'? intelDialect = 'inteldialect'? - unwind = 'unwind'? StringLit ',' StringLit; -mdString: '!' StringLit; -mdFieldOrInt: IntLit | mdField; -diSPFlag: IntLit | DispFlag; -funcAttribute: - attrString - | attrPair - // not used in attribute groups. - | AttrGroupId - // used in functions. | align # NOTE: removed to resolve reduce/reduce conflict, see above. used - // in attribute groups. - | alignPair - | alignStack - | alignStackPair - | allocKind - | allocSize - | funcAttr - | preallocated - | unwindTable - | vectorScaleRange; -type: - 'void' - | 'opaque' - | type '(' params ')' - | intType - | floatType - | type addrSpace? '*' - | opaquePointerType - | vectorType - | labelType - | arrayType - | structType - | namedType - | mmxType - | tokenType - | metadataType; -params: - ellipsis = '...'? - | param (',' param)* (',' ellipsis = '...')?; -param: type paramAttribute* LocalIdent?; -paramAttribute: - attrString - | attrPair - | align - | alignStack - | byRefAttr - | byval - | dereferenceable - | elementType - | inAlloca - | paramAttr - | preallocated - | structRetAttr; -attrString: StringLit; -attrPair: StringLit '=' StringLit; -align: 'align' IntLit | 'align' '(' IntLit ')'; -alignPair: 'align' '=' IntLit; -alignStack: 'alignstack' '(' IntLit ')'; -alignStackPair: 'alignstack' '=' IntLit; -allocKind: 'allockind' '(' StringLit ')'; -allocSize: 'allocsize' '(' IntLit (',' IntLit)? ')'; -unwindTable: - 'uwtable' - | 'uwtable' '(' unwindTableKind = ('async' | 'sync') ')'; -vectorScaleRange: - 'vscale_range' ('(' (IntLit | IntLit ',' IntLit) ')')?; -byRefAttr: 'byref' '(' type ')'; -byval: 'byval' ( '(' type ')')?; -dereferenceable: - 'dereferenceable' '(' IntLit ')' - | 'dereferenceable_or_null' '(' IntLit ')'; -elementType: 'elementtype' '(' type ')'; -inAlloca: 'inalloca' '(' type ')'; -paramAttr: - 'allocalign' - | 'allocptr' - | 'immarg' - | 'inreg' - | 'nest' - | 'noalias' - | 'nocapture' - | 'nofree' - | 'nonnull' - | 'noundef' - | 'readnone' - | 'readonly' - | 'returned' - | 'signext' - | 'swiftasync' - | 'swifterror' - | 'swiftself' - | 'writeonly' - | 'zeroext'; -preallocated: 'preallocated' '(' type ')'; -structRetAttr: 'sret' '(' type ')'; +metadata + : typeValue + | mdString + // !{ ... } + | mdTuple + // !7 + | MetadataId + | diArgList + | specializedMDNode + ; + +diArgList + : '!DIArgList' '(' (typeValue (',' typeValue)*)? ')' + ; + +typeValue + : firstClassType value + ; + +value + : constant + // %42 %foo + | LocalIdent + // TODO: Move InlineAsm from Value to Callee and Invokee? Inline assembler expressions may only + // be used as the callee operand of a call or an invoke instruction. + | inlineAsm + ; + +inlineAsm + : 'asm' sideEffect = 'sideeffect'? alignStackTok = 'alignstack'? intelDialect = 'inteldialect'? unwind = 'unwind'? StringLit ',' StringLit + ; + +mdString + : '!' StringLit + ; + +mdFieldOrInt + : IntLit + | mdField + ; + +diSPFlag + : IntLit + | DispFlag + ; + +funcAttribute + : attrString + | attrPair + // not used in attribute groups. + | AttrGroupId + // used in functions. | align # NOTE: removed to resolve reduce/reduce conflict, see above. used + // in attribute groups. + | alignPair + | alignStack + | alignStackPair + | allocKind + | allocSize + | funcAttr + | preallocated + | unwindTable + | vectorScaleRange + ; + +type + : 'void' + | 'opaque' + | type '(' params ')' + | intType + | floatType + | type addrSpace? '*' + | opaquePointerType + | vectorType + | labelType + | arrayType + | structType + | namedType + | mmxType + | tokenType + | metadataType + ; + +params + : ellipsis = '...'? + | param (',' param)* (',' ellipsis = '...')? + ; + +param + : type paramAttribute* LocalIdent? + ; + +paramAttribute + : attrString + | attrPair + | align + | alignStack + | byRefAttr + | byval + | dereferenceable + | elementType + | inAlloca + | paramAttr + | preallocated + | structRetAttr + ; + +attrString + : StringLit + ; + +attrPair + : StringLit '=' StringLit + ; + +align + : 'align' IntLit + | 'align' '(' IntLit ')' + ; + +alignPair + : 'align' '=' IntLit + ; + +alignStack + : 'alignstack' '(' IntLit ')' + ; + +alignStackPair + : 'alignstack' '=' IntLit + ; + +allocKind + : 'allockind' '(' StringLit ')' + ; + +allocSize + : 'allocsize' '(' IntLit (',' IntLit)? ')' + ; + +unwindTable + : 'uwtable' + | 'uwtable' '(' unwindTableKind = ('async' | 'sync') ')' + ; + +vectorScaleRange + : 'vscale_range' ('(' (IntLit | IntLit ',' IntLit) ')')? + ; + +byRefAttr + : 'byref' '(' type ')' + ; + +byval + : 'byval' ('(' type ')')? + ; + +dereferenceable + : 'dereferenceable' '(' IntLit ')' + | 'dereferenceable_or_null' '(' IntLit ')' + ; + +elementType + : 'elementtype' '(' type ')' + ; + +inAlloca + : 'inalloca' '(' type ')' + ; + +paramAttr + : 'allocalign' + | 'allocptr' + | 'immarg' + | 'inreg' + | 'nest' + | 'noalias' + | 'nocapture' + | 'nofree' + | 'nonnull' + | 'noundef' + | 'readnone' + | 'readonly' + | 'returned' + | 'signext' + | 'swiftasync' + | 'swifterror' + | 'swiftself' + | 'writeonly' + | 'zeroext' + ; + +preallocated + : 'preallocated' '(' type ')' + ; + +structRetAttr + : 'sret' '(' type ')' + ; // funcType: type '(' params ')'; -firstClassType: concreteType | metadataType; -concreteType: - intType - | floatType - | pointerType - | vectorType - | labelType - | arrayType - | structType - | namedType - | mmxType - | tokenType; - -intType: IntType; -floatType: floatKind; -pointerType: type addrSpace? '*' | opaquePointerType; -vectorType: - '<' IntLit 'x' type '>' - | '<' 'vscale' 'x' IntLit 'x' type '>'; -labelType: 'label'; -arrayType: '[' IntLit 'x' type ']'; -structType: - '{' (type (',' type)*)? '}' - | '<' '{' (type (',' type)*)? '}' '>'; -namedType: LocalIdent; -mmxType: 'x86_mmx'; -tokenType: 'token'; - -opaquePointerType: 'ptr' addrSpace?; -addrSpace: 'addrspace' '(' IntLit ')'; -threadLocal: 'thread_local' ('(' tlsModel ')')?; -metadataType: 'metadata'; +firstClassType + : concreteType + | metadataType + ; + +concreteType + : intType + | floatType + | pointerType + | vectorType + | labelType + | arrayType + | structType + | namedType + | mmxType + | tokenType + ; + +intType + : IntType + ; + +floatType + : floatKind + ; + +pointerType + : type addrSpace? '*' + | opaquePointerType + ; + +vectorType + : '<' IntLit 'x' type '>' + | '<' 'vscale' 'x' IntLit 'x' type '>' + ; + +labelType + : 'label' + ; + +arrayType + : '[' IntLit 'x' type ']' + ; + +structType + : '{' (type (',' type)*)? '}' + | '<' '{' (type (',' type)*)? '}' '>' + ; + +namedType + : LocalIdent + ; + +mmxType + : 'x86_mmx' + ; + +tokenType + : 'token' + ; + +opaquePointerType + : 'ptr' addrSpace? + ; + +addrSpace + : 'addrspace' '(' IntLit ')' + ; + +threadLocal + : 'thread_local' ('(' tlsModel ')')? + ; + +metadataType + : 'metadata' + ; // expr -bitCastExpr: 'bitcast' '(' typeConst 'to' type ')'; -getElementPtrExpr: - 'getelementptr' inBounds? '(' type ',' typeConst ( - ',' gepIndex - )* ')'; -gepIndex: inRange = 'inrange'? typeConst; -addrSpaceCastExpr: 'addrspacecast' '(' typeConst 'to' type ')'; -intToPtrExpr: 'inttoptr' '(' typeConst 'to' type ')'; -iCmpExpr: 'icmp' iPred '(' typeConst ',' typeConst ')'; -fCmpExpr: 'fcmp' fPred '(' typeConst ',' typeConst ')'; -selectExpr: - 'select' '(' typeConst ',' typeConst ',' typeConst ')'; - -truncExpr: 'trunc' '(' typeConst 'to' type ')'; -zExtExpr: 'zext' '(' typeConst 'to' type ')'; -sExtExpr: 'sext' '(' typeConst 'to' type ')'; -fpTruncExpr: 'fptrunc' '(' typeConst 'to' type ')'; -fpExtExpr: 'fpext' '(' typeConst 'to' type ')'; -fpToUiExpr: 'fptoui' '(' typeConst 'to' type ')'; -fpToSiExpr: 'fptosi' '(' typeConst 'to' type ')'; -uiToFpExpr: 'uitofp' '(' typeConst 'to' type ')'; -siToFpExpr: 'sitofp' '(' typeConst 'to' type ')'; -ptrToIntExpr: 'ptrtoint' '(' typeConst 'to' type ')'; -extractElementExpr: - 'extractelement' '(' typeConst ',' typeConst ')'; -insertElementExpr: - 'insertelement' '(' typeConst ',' typeConst ',' typeConst ')'; -shuffleVectorExpr: - 'shufflevector' '(' typeConst ',' typeConst ',' typeConst ')'; -shlExpr: 'shl' overflowFlag* '(' typeConst ',' typeConst ')'; -lShrExpr: - 'lshr' exact = 'exact'? '(' typeConst ',' typeConst ')'; -aShrExpr: - 'ashr' exact = 'exact'? '(' typeConst ',' typeConst ')'; -andExpr: 'and' '(' typeConst ',' typeConst ')'; -orExpr: 'or' '(' typeConst ',' typeConst ')'; -xorExpr: 'xor' '(' typeConst ',' typeConst ')'; -addExpr: 'add' overflowFlag* '(' typeConst ',' typeConst ')'; -subExpr: 'sub' overflowFlag* '(' typeConst ',' typeConst ')'; -mulExpr: 'mul' overflowFlag* '(' typeConst ',' typeConst ')'; -fNegExpr: 'fneg' '(' typeConst ')'; +bitCastExpr + : 'bitcast' '(' typeConst 'to' type ')' + ; + +getElementPtrExpr + : 'getelementptr' inBounds? '(' type ',' typeConst (',' gepIndex)* ')' + ; + +gepIndex + : inRange = 'inrange'? typeConst + ; + +addrSpaceCastExpr + : 'addrspacecast' '(' typeConst 'to' type ')' + ; + +intToPtrExpr + : 'inttoptr' '(' typeConst 'to' type ')' + ; + +iCmpExpr + : 'icmp' iPred '(' typeConst ',' typeConst ')' + ; + +fCmpExpr + : 'fcmp' fPred '(' typeConst ',' typeConst ')' + ; + +selectExpr + : 'select' '(' typeConst ',' typeConst ',' typeConst ')' + ; + +truncExpr + : 'trunc' '(' typeConst 'to' type ')' + ; + +zExtExpr + : 'zext' '(' typeConst 'to' type ')' + ; + +sExtExpr + : 'sext' '(' typeConst 'to' type ')' + ; + +fpTruncExpr + : 'fptrunc' '(' typeConst 'to' type ')' + ; + +fpExtExpr + : 'fpext' '(' typeConst 'to' type ')' + ; + +fpToUiExpr + : 'fptoui' '(' typeConst 'to' type ')' + ; + +fpToSiExpr + : 'fptosi' '(' typeConst 'to' type ')' + ; + +uiToFpExpr + : 'uitofp' '(' typeConst 'to' type ')' + ; + +siToFpExpr + : 'sitofp' '(' typeConst 'to' type ')' + ; + +ptrToIntExpr + : 'ptrtoint' '(' typeConst 'to' type ')' + ; + +extractElementExpr + : 'extractelement' '(' typeConst ',' typeConst ')' + ; + +insertElementExpr + : 'insertelement' '(' typeConst ',' typeConst ',' typeConst ')' + ; + +shuffleVectorExpr + : 'shufflevector' '(' typeConst ',' typeConst ',' typeConst ')' + ; + +shlExpr + : 'shl' overflowFlag* '(' typeConst ',' typeConst ')' + ; + +lShrExpr + : 'lshr' exact = 'exact'? '(' typeConst ',' typeConst ')' + ; + +aShrExpr + : 'ashr' exact = 'exact'? '(' typeConst ',' typeConst ')' + ; + +andExpr + : 'and' '(' typeConst ',' typeConst ')' + ; + +orExpr + : 'or' '(' typeConst ',' typeConst ')' + ; + +xorExpr + : 'xor' '(' typeConst ',' typeConst ')' + ; + +addExpr + : 'add' overflowFlag* '(' typeConst ',' typeConst ')' + ; + +subExpr + : 'sub' overflowFlag* '(' typeConst ',' typeConst ')' + ; + +mulExpr + : 'mul' overflowFlag* '(' typeConst ',' typeConst ')' + ; + +fNegExpr + : 'fneg' '(' typeConst ')' + ; // instructions -localDefInst: LocalIdent '=' valueInstruction; -valueInstruction: - // Unary instructions - fNegInst - // Binary instructions - | addInst - | fAddInst - | subInst - | fSubInst - | mulInst - | fMulInst - | uDivInst - | sDivInst - | fDivInst - | uRemInst - | sRemInst - | fRemInst - // Bitwise instructions - | shlInst - | lShrInst - | aShrInst - | andInst - | orInst - | xorInst - // Vector instructions - | extractElementInst - | insertElementInst - | shuffleVectorInst - // Aggregate instructions - | extractValueInst - | insertValueInst - // Memory instructions - | allocaInst - | loadInst - | cmpXchgInst - | atomicRMWInst - | getElementPtrInst - // Conversion instructions - | truncInst - | zExtInst - | sExtInst - | fpTruncInst - | fpExtInst - | fpToUiInst - | fpToSiInst - | uiToFpInst - | siToFpInst - | ptrToIntInst - | intToPtrInst - | bitCastInst - | addrSpaceCastInst - // Other instructions - | iCmpInst - | fCmpInst - | phiInst - | selectInst - | freezeInst - | callInst - | vaargInst - | landingPadInst - | catchPadInst - | cleanupPadInst; -storeInst: - // Store. - 'store' volatile = 'volatile'? typeValue ',' typeValue ( - ',' align - )? (',' metadataAttachment)* - // atomic='atomic' store. - | 'store' atomic = 'atomic' volatile = 'volatile'? typeValue ',' typeValue syncScope? - atomicOrdering (',' align)? (',' metadataAttachment)*; - -syncScope: 'syncscope' '(' StringLit ')'; - -fenceInst: - 'fence' syncScope? atomicOrdering (',' metadataAttachment)*; -fNegInst: - 'fneg' fastMathFlag* typeValue (',' metadataAttachment)*; -addInst: - 'add' overflowFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -fAddInst: - 'fadd' fastMathFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -subInst: - 'sub' overflowFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -fSubInst: - 'fsub' fastMathFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -mulInst: - 'mul' overflowFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -fMulInst: - 'fmul' fastMathFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -uDivInst: - 'udiv' exact = 'exact'? typeValue ',' value ( - ',' metadataAttachment - )*; -sDivInst: - 'sdiv' exact = 'exact'? typeValue ',' value ( - ',' metadataAttachment - )*; -fDivInst: - 'fdiv' fastMathFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -uRemInst: 'urem' typeValue ',' value ( ',' metadataAttachment)*; -sRemInst: 'srem' typeValue ',' value ( ',' metadataAttachment)*; -fRemInst: - 'frem' fastMathFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -shlInst: - 'shl' overflowFlag* typeValue ',' value ( - ',' metadataAttachment - )*; -lShrInst: - 'lshr' exact = 'exact'? typeValue ',' value ( - ',' metadataAttachment - )*; -aShrInst: - 'ashr' exact = 'exact'? typeValue ',' value ( - ',' metadataAttachment - )*; -andInst: 'and' typeValue ',' value ( ',' metadataAttachment)*; -orInst: 'or' typeValue ',' value ( ',' metadataAttachment)*; -xorInst: 'xor' typeValue ',' value ( ',' metadataAttachment)*; -extractElementInst: - 'extractelement' typeValue ',' typeValue ( - ',' metadataAttachment - )*; -insertElementInst: - 'insertelement' typeValue ',' typeValue ',' typeValue ( - ',' metadataAttachment - )*; -shuffleVectorInst: - 'shufflevector' typeValue ',' typeValue ',' typeValue ( - ',' metadataAttachment - )*; -extractValueInst: - 'extractvalue' typeValue (',' IntLit)+ ( - ',' metadataAttachment - )*; -insertValueInst: - 'insertvalue' typeValue ',' typeValue (',' IntLit)+ ( - ',' metadataAttachment - )*; -allocaInst: - 'alloca' inAllocaTok = 'inalloca'? swiftError = 'swifterror'? type ( - ',' typeValue - )? (',' align)? (',' addrSpace)? (',' metadataAttachment)*; -loadInst: - // Load. - 'load' volatile = 'volatile'? type ',' typeValue (',' align)? ( - ',' metadataAttachment - )* - // atomic='atomic' load. - | 'load' atomic = 'atomic' volatile = 'volatile'? type ',' typeValue syncScope? atomicOrdering ( - ',' align - )? (',' metadataAttachment)*; -cmpXchgInst: - 'cmpxchg' weak = 'weak'? volatile = 'volatile'? typeValue ',' typeValue ',' typeValue syncScope? - atomicOrdering atomicOrdering (',' align)? ( - ',' metadataAttachment - )*; -atomicRMWInst: - 'atomicrmw' volatile = 'volatile'? atomicOp typeValue ',' typeValue syncScope? atomicOrdering ( - ',' align - )? (',' metadataAttachment)*; -getElementPtrInst: - 'getelementptr' inBounds? type ',' typeValue (',' typeValue)* ( - ',' metadataAttachment - )*; -truncInst: - 'trunc' typeValue 'to' type (',' metadataAttachment)*; -zExtInst: 'zext' typeValue 'to' type ( ',' metadataAttachment)*; -sExtInst: 'sext' typeValue 'to' type ( ',' metadataAttachment)*; -fpTruncInst: - 'fptrunc' typeValue 'to' type (',' metadataAttachment)*; -fpExtInst: - 'fpext' typeValue 'to' type (',' metadataAttachment)*; -fpToUiInst: - 'fptoui' typeValue 'to' type (',' metadataAttachment)*; -fpToSiInst: - 'fptosi' typeValue 'to' type (',' metadataAttachment)*; -uiToFpInst: - 'uitofp' typeValue 'to' type (',' metadataAttachment)*; -siToFpInst: - 'sitofp' typeValue 'to' type (',' metadataAttachment)*; -ptrToIntInst: - 'ptrtoint' typeValue 'to' type (',' metadataAttachment)*; -intToPtrInst: - 'inttoptr' typeValue 'to' type (',' metadataAttachment)*; -bitCastInst: - 'bitcast' typeValue 'to' type (',' metadataAttachment)*; -addrSpaceCastInst: - 'addrspacecast' typeValue 'to' type (',' metadataAttachment)*; -iCmpInst: - 'icmp' iPred typeValue ',' value (',' metadataAttachment)*; -fCmpInst: - 'fcmp' fastMathFlag* fPred typeValue ',' value ( - ',' metadataAttachment - )*; -phiInst: - 'phi' fastMathFlag* type (inc (',' inc)*) ( - ',' metadataAttachment - )*; -selectInst: - 'select' fastMathFlag* typeValue ',' typeValue ',' typeValue ( - ',' metadataAttachment - )*; -freezeInst: 'freeze' typeValue; -callInst: - tail = ('musttail' | 'notail' | 'tail')? 'call' fastMathFlag* callingConv? returnAttribute* - addrSpace? type value '(' args ')' funcAttribute* ( - '[' operandBundle (',' operandBundle)* ']' - )? (',' metadataAttachment)*; -vaargInst: - 'va_arg' typeValue ',' type (',' metadataAttachment)*; -landingPadInst: - 'landingpad' type cleanUp = 'cleanup'? clause* ( - ',' metadataAttachment - )*; -catchPadInst: - 'catchpad' 'within' LocalIdent '[' ( - exceptionArg (',' exceptionArg)* - )? ']' (',' metadataAttachment)*; -cleanupPadInst: - 'cleanuppad' 'within' exceptionPad '[' ( - exceptionArg (',' exceptionArg)* - )? ']' (',' metadataAttachment)*; - -inc: '[' value ',' LocalIdent ']'; - -operandBundle: StringLit '(' (typeValue (',' typeValue)*)? ')'; -clause: clauseType = ('catch' | 'filter') typeValue; - -args: - ellipsis = '...'? - | arg (',' arg)* (',' ellipsis = '...')?; -arg: concreteType paramAttribute* value | metadataType metadata; - -exceptionArg: concreteType value | metadataType metadata; -exceptionPad: noneConst | LocalIdent; - -externalLinkage: 'extern_weak' | 'external'; -internalLinkage: - 'appending' - | 'available_externally' - | 'common' - | 'internal' - | 'linkonce' - | 'linkonce_odr' - | 'private' - | 'weak' - | 'weak_odr'; -linkage: internalLinkage | externalLinkage; -preemption: 'dso_local' | 'dso_preemptable'; -visibility: 'default' | 'hidden' | 'protected'; -dllStorageClass: 'dllexport' | 'dllimport'; -tlsModel: 'initialexec' | 'localdynamic' | 'localexec'; -unnamedAddr: 'local_unnamed_addr' | 'unnamed_addr'; -externallyInitialized: 'externally_initialized'; -immutable: 'constant' | 'global'; -funcAttr: - 'alwaysinline' - | 'argmemonly' - | 'builtin' - | 'cold' - | 'convergent' - | 'disable_sanitizer_instrumentation' - | 'fn_ret_thunk_extern' - | 'hot' - | 'inaccessiblemem_or_argmemonly' - | 'inaccessiblememonly' - | 'inlinehint' - | 'jumptable' - | 'minsize' - | 'mustprogress' - | 'naked' - | 'nobuiltin' - | 'nocallback' - | 'nocf_check' - | 'noduplicate' - | 'nofree' - | 'noimplicitfloat' - | 'noinline' - | 'nomerge' - | 'nonlazybind' - | 'noprofile' - | 'norecurse' - | 'noredzone' - | 'noreturn' - | 'nosanitize_bounds' - | 'nosanitize_coverage' - | 'nosync' - | 'nounwind' - | 'null_pointer_is_valid' - | 'optforfuzzing' - | 'optnone' - | 'optsize' - | 'presplitcoroutine' - | 'readnone' - | 'readonly' - | 'returns_twice' - | 'safestack' - | 'sanitize_address' - | 'sanitize_hwaddress' - | 'sanitize_memory' - | 'sanitize_memtag' - | 'sanitize_thread' - | 'shadowcallstack' - | 'speculatable' - | 'speculative_load_hardening' - | 'ssp' - | 'sspreq' - | 'sspstrong' - | 'strictfp' - | 'willreturn' - | 'writeonly'; -distinct: 'distinct'; -inBounds: 'inbounds'; -returnAttr: - 'inreg' - | 'noalias' - | 'nonnull' - | 'noundef' - | 'signext' - | 'zeroext'; -overflowFlag: 'nsw' | 'nuw'; -iPred: - 'eq' - | 'ne' - | 'sge' - | 'sgt' - | 'sle' - | 'slt' - | 'uge' - | 'ugt' - | 'ule' - | 'ult'; -fPred: - 'false' - | 'oeq' - | 'oge' - | 'ogt' - | 'ole' - | 'olt' - | 'one' - | 'ord' - | 'true' - | 'ueq' - | 'uge' - | 'ugt' - | 'ule' - | 'ult' - | 'une' - | 'uno'; -atomicOrdering: - 'acq_rel' - | 'acquire' - | 'monotonic' - | 'release' - | 'seq_cst' - | 'unordered'; -callingConvEnum: - 'aarch64_sve_vector_pcs' - | 'aarch64_vector_pcs' - | 'amdgpu_cs' - | 'amdgpu_es' - | 'amdgpu_gfx' - | 'amdgpu_gs' - | 'amdgpu_hs' - | 'amdgpu_kernel' - | 'amdgpu_ls' - | 'amdgpu_ps' - | 'amdgpu_vs' - | 'anyregcc' - | 'arm_aapcs_vfpcc' - | 'arm_aapcscc' - | 'arm_apcscc' - | 'avr_intrcc' - | 'avr_signalcc' - | 'ccc' - | 'cfguard_checkcc' - | 'coldcc' - | 'cxx_fast_tlscc' - | 'fastcc' - | 'ghccc' - | 'hhvm_ccc' - | 'hhvmcc' - | 'intel_ocl_bicc' - | 'msp430_intrcc' - | 'preserve_allcc' - | 'preserve_mostcc' - | 'ptx_device' - | 'ptx_kernel' - | 'spir_func' - | 'spir_kernel' - | 'swiftcc' - | 'swifttailcc' - | 'tailcc' - | 'webkit_jscc' - | 'win64cc' - | 'x86_64_sysvcc' - | 'x86_fastcallcc' - | 'x86_intrcc' - | 'x86_regcallcc' - | 'x86_stdcallcc' - | 'x86_thiscallcc' - | 'x86_vectorcallcc'; - -fastMathFlag: - 'afn' - | 'arcp' - | 'contract' - | 'fast' - | 'ninf' - | 'nnan' - | 'nsz' - | 'reassoc'; -atomicOp: - 'add' - | 'and' - | 'fadd' - | 'fmax' - | 'fmin' - | 'fsub' - | 'max' - | 'min' - | 'nand' - | 'or' - | 'sub' - | 'umax' - | 'umin' - | 'xchg' - | 'xor'; -floatKind: - 'half' - | 'bfloat' - | 'float' - | 'double' - | 'x86_fp80' - | 'fp128' - | 'ppc_fp128'; +localDefInst + : LocalIdent '=' valueInstruction + ; + +valueInstruction + : + // Unary instructions + fNegInst + // Binary instructions + | addInst + | fAddInst + | subInst + | fSubInst + | mulInst + | fMulInst + | uDivInst + | sDivInst + | fDivInst + | uRemInst + | sRemInst + | fRemInst + // Bitwise instructions + | shlInst + | lShrInst + | aShrInst + | andInst + | orInst + | xorInst + // Vector instructions + | extractElementInst + | insertElementInst + | shuffleVectorInst + // Aggregate instructions + | extractValueInst + | insertValueInst + // Memory instructions + | allocaInst + | loadInst + | cmpXchgInst + | atomicRMWInst + | getElementPtrInst + // Conversion instructions + | truncInst + | zExtInst + | sExtInst + | fpTruncInst + | fpExtInst + | fpToUiInst + | fpToSiInst + | uiToFpInst + | siToFpInst + | ptrToIntInst + | intToPtrInst + | bitCastInst + | addrSpaceCastInst + // Other instructions + | iCmpInst + | fCmpInst + | phiInst + | selectInst + | freezeInst + | callInst + | vaargInst + | landingPadInst + | catchPadInst + | cleanupPadInst + ; + +storeInst + : + // Store. + 'store' volatile = 'volatile'? typeValue ',' typeValue (',' align)? (',' metadataAttachment)* + // atomic='atomic' store. + | 'store' atomic = 'atomic' volatile = 'volatile'? typeValue ',' typeValue syncScope? atomicOrdering ( + ',' align + )? (',' metadataAttachment)* + ; + +syncScope + : 'syncscope' '(' StringLit ')' + ; + +fenceInst + : 'fence' syncScope? atomicOrdering (',' metadataAttachment)* + ; + +fNegInst + : 'fneg' fastMathFlag* typeValue (',' metadataAttachment)* + ; + +addInst + : 'add' overflowFlag* typeValue ',' value (',' metadataAttachment)* + ; + +fAddInst + : 'fadd' fastMathFlag* typeValue ',' value (',' metadataAttachment)* + ; + +subInst + : 'sub' overflowFlag* typeValue ',' value (',' metadataAttachment)* + ; + +fSubInst + : 'fsub' fastMathFlag* typeValue ',' value (',' metadataAttachment)* + ; + +mulInst + : 'mul' overflowFlag* typeValue ',' value (',' metadataAttachment)* + ; + +fMulInst + : 'fmul' fastMathFlag* typeValue ',' value (',' metadataAttachment)* + ; + +uDivInst + : 'udiv' exact = 'exact'? typeValue ',' value (',' metadataAttachment)* + ; + +sDivInst + : 'sdiv' exact = 'exact'? typeValue ',' value (',' metadataAttachment)* + ; + +fDivInst + : 'fdiv' fastMathFlag* typeValue ',' value (',' metadataAttachment)* + ; + +uRemInst + : 'urem' typeValue ',' value (',' metadataAttachment)* + ; + +sRemInst + : 'srem' typeValue ',' value (',' metadataAttachment)* + ; + +fRemInst + : 'frem' fastMathFlag* typeValue ',' value (',' metadataAttachment)* + ; + +shlInst + : 'shl' overflowFlag* typeValue ',' value (',' metadataAttachment)* + ; + +lShrInst + : 'lshr' exact = 'exact'? typeValue ',' value (',' metadataAttachment)* + ; + +aShrInst + : 'ashr' exact = 'exact'? typeValue ',' value (',' metadataAttachment)* + ; + +andInst + : 'and' typeValue ',' value (',' metadataAttachment)* + ; + +orInst + : 'or' typeValue ',' value (',' metadataAttachment)* + ; + +xorInst + : 'xor' typeValue ',' value (',' metadataAttachment)* + ; + +extractElementInst + : 'extractelement' typeValue ',' typeValue (',' metadataAttachment)* + ; + +insertElementInst + : 'insertelement' typeValue ',' typeValue ',' typeValue (',' metadataAttachment)* + ; + +shuffleVectorInst + : 'shufflevector' typeValue ',' typeValue ',' typeValue (',' metadataAttachment)* + ; + +extractValueInst + : 'extractvalue' typeValue (',' IntLit)+ (',' metadataAttachment)* + ; + +insertValueInst + : 'insertvalue' typeValue ',' typeValue (',' IntLit)+ (',' metadataAttachment)* + ; + +allocaInst + : 'alloca' inAllocaTok = 'inalloca'? swiftError = 'swifterror'? type (',' typeValue)? ( + ',' align + )? (',' addrSpace)? (',' metadataAttachment)* + ; + +loadInst + : + // Load. + 'load' volatile = 'volatile'? type ',' typeValue (',' align)? (',' metadataAttachment)* + // atomic='atomic' load. + | 'load' atomic = 'atomic' volatile = 'volatile'? type ',' typeValue syncScope? atomicOrdering ( + ',' align + )? (',' metadataAttachment)* + ; + +cmpXchgInst + : 'cmpxchg' weak = 'weak'? volatile = 'volatile'? typeValue ',' typeValue ',' typeValue syncScope? atomicOrdering atomicOrdering ( + ',' align + )? (',' metadataAttachment)* + ; + +atomicRMWInst + : 'atomicrmw' volatile = 'volatile'? atomicOp typeValue ',' typeValue syncScope? atomicOrdering ( + ',' align + )? (',' metadataAttachment)* + ; + +getElementPtrInst + : 'getelementptr' inBounds? type ',' typeValue (',' typeValue)* (',' metadataAttachment)* + ; + +truncInst + : 'trunc' typeValue 'to' type (',' metadataAttachment)* + ; + +zExtInst + : 'zext' typeValue 'to' type (',' metadataAttachment)* + ; + +sExtInst + : 'sext' typeValue 'to' type (',' metadataAttachment)* + ; + +fpTruncInst + : 'fptrunc' typeValue 'to' type (',' metadataAttachment)* + ; + +fpExtInst + : 'fpext' typeValue 'to' type (',' metadataAttachment)* + ; + +fpToUiInst + : 'fptoui' typeValue 'to' type (',' metadataAttachment)* + ; + +fpToSiInst + : 'fptosi' typeValue 'to' type (',' metadataAttachment)* + ; + +uiToFpInst + : 'uitofp' typeValue 'to' type (',' metadataAttachment)* + ; + +siToFpInst + : 'sitofp' typeValue 'to' type (',' metadataAttachment)* + ; + +ptrToIntInst + : 'ptrtoint' typeValue 'to' type (',' metadataAttachment)* + ; + +intToPtrInst + : 'inttoptr' typeValue 'to' type (',' metadataAttachment)* + ; + +bitCastInst + : 'bitcast' typeValue 'to' type (',' metadataAttachment)* + ; + +addrSpaceCastInst + : 'addrspacecast' typeValue 'to' type (',' metadataAttachment)* + ; + +iCmpInst + : 'icmp' iPred typeValue ',' value (',' metadataAttachment)* + ; + +fCmpInst + : 'fcmp' fastMathFlag* fPred typeValue ',' value (',' metadataAttachment)* + ; + +phiInst + : 'phi' fastMathFlag* type (inc (',' inc)*) (',' metadataAttachment)* + ; + +selectInst + : 'select' fastMathFlag* typeValue ',' typeValue ',' typeValue (',' metadataAttachment)* + ; + +freezeInst + : 'freeze' typeValue + ; + +callInst + : tail = ('musttail' | 'notail' | 'tail')? 'call' fastMathFlag* callingConv? returnAttribute* addrSpace? type value '(' args ')' funcAttribute* ( + '[' operandBundle (',' operandBundle)* ']' + )? (',' metadataAttachment)* + ; + +vaargInst + : 'va_arg' typeValue ',' type (',' metadataAttachment)* + ; + +landingPadInst + : 'landingpad' type cleanUp = 'cleanup'? clause* (',' metadataAttachment)* + ; + +catchPadInst + : 'catchpad' 'within' LocalIdent '[' (exceptionArg (',' exceptionArg)*)? ']' ( + ',' metadataAttachment + )* + ; + +cleanupPadInst + : 'cleanuppad' 'within' exceptionPad '[' (exceptionArg (',' exceptionArg)*)? ']' ( + ',' metadataAttachment + )* + ; + +inc + : '[' value ',' LocalIdent ']' + ; + +operandBundle + : StringLit '(' (typeValue (',' typeValue)*)? ')' + ; + +clause + : clauseType = ('catch' | 'filter') typeValue + ; + +args + : ellipsis = '...'? + | arg (',' arg)* (',' ellipsis = '...')? + ; + +arg + : concreteType paramAttribute* value + | metadataType metadata + ; + +exceptionArg + : concreteType value + | metadataType metadata + ; + +exceptionPad + : noneConst + | LocalIdent + ; + +externalLinkage + : 'extern_weak' + | 'external' + ; + +internalLinkage + : 'appending' + | 'available_externally' + | 'common' + | 'internal' + | 'linkonce' + | 'linkonce_odr' + | 'private' + | 'weak' + | 'weak_odr' + ; + +linkage + : internalLinkage + | externalLinkage + ; + +preemption + : 'dso_local' + | 'dso_preemptable' + ; + +visibility + : 'default' + | 'hidden' + | 'protected' + ; + +dllStorageClass + : 'dllexport' + | 'dllimport' + ; + +tlsModel + : 'initialexec' + | 'localdynamic' + | 'localexec' + ; + +unnamedAddr + : 'local_unnamed_addr' + | 'unnamed_addr' + ; + +externallyInitialized + : 'externally_initialized' + ; + +immutable + : 'constant' + | 'global' + ; + +funcAttr + : 'alwaysinline' + | 'argmemonly' + | 'builtin' + | 'cold' + | 'convergent' + | 'disable_sanitizer_instrumentation' + | 'fn_ret_thunk_extern' + | 'hot' + | 'inaccessiblemem_or_argmemonly' + | 'inaccessiblememonly' + | 'inlinehint' + | 'jumptable' + | 'minsize' + | 'mustprogress' + | 'naked' + | 'nobuiltin' + | 'nocallback' + | 'nocf_check' + | 'noduplicate' + | 'nofree' + | 'noimplicitfloat' + | 'noinline' + | 'nomerge' + | 'nonlazybind' + | 'noprofile' + | 'norecurse' + | 'noredzone' + | 'noreturn' + | 'nosanitize_bounds' + | 'nosanitize_coverage' + | 'nosync' + | 'nounwind' + | 'null_pointer_is_valid' + | 'optforfuzzing' + | 'optnone' + | 'optsize' + | 'presplitcoroutine' + | 'readnone' + | 'readonly' + | 'returns_twice' + | 'safestack' + | 'sanitize_address' + | 'sanitize_hwaddress' + | 'sanitize_memory' + | 'sanitize_memtag' + | 'sanitize_thread' + | 'shadowcallstack' + | 'speculatable' + | 'speculative_load_hardening' + | 'ssp' + | 'sspreq' + | 'sspstrong' + | 'strictfp' + | 'willreturn' + | 'writeonly' + ; + +distinct + : 'distinct' + ; + +inBounds + : 'inbounds' + ; + +returnAttr + : 'inreg' + | 'noalias' + | 'nonnull' + | 'noundef' + | 'signext' + | 'zeroext' + ; + +overflowFlag + : 'nsw' + | 'nuw' + ; + +iPred + : 'eq' + | 'ne' + | 'sge' + | 'sgt' + | 'sle' + | 'slt' + | 'uge' + | 'ugt' + | 'ule' + | 'ult' + ; + +fPred + : 'false' + | 'oeq' + | 'oge' + | 'ogt' + | 'ole' + | 'olt' + | 'one' + | 'ord' + | 'true' + | 'ueq' + | 'uge' + | 'ugt' + | 'ule' + | 'ult' + | 'une' + | 'uno' + ; + +atomicOrdering + : 'acq_rel' + | 'acquire' + | 'monotonic' + | 'release' + | 'seq_cst' + | 'unordered' + ; + +callingConvEnum + : 'aarch64_sve_vector_pcs' + | 'aarch64_vector_pcs' + | 'amdgpu_cs' + | 'amdgpu_es' + | 'amdgpu_gfx' + | 'amdgpu_gs' + | 'amdgpu_hs' + | 'amdgpu_kernel' + | 'amdgpu_ls' + | 'amdgpu_ps' + | 'amdgpu_vs' + | 'anyregcc' + | 'arm_aapcs_vfpcc' + | 'arm_aapcscc' + | 'arm_apcscc' + | 'avr_intrcc' + | 'avr_signalcc' + | 'ccc' + | 'cfguard_checkcc' + | 'coldcc' + | 'cxx_fast_tlscc' + | 'fastcc' + | 'ghccc' + | 'hhvm_ccc' + | 'hhvmcc' + | 'intel_ocl_bicc' + | 'msp430_intrcc' + | 'preserve_allcc' + | 'preserve_mostcc' + | 'ptx_device' + | 'ptx_kernel' + | 'spir_func' + | 'spir_kernel' + | 'swiftcc' + | 'swifttailcc' + | 'tailcc' + | 'webkit_jscc' + | 'win64cc' + | 'x86_64_sysvcc' + | 'x86_fastcallcc' + | 'x86_intrcc' + | 'x86_regcallcc' + | 'x86_stdcallcc' + | 'x86_thiscallcc' + | 'x86_vectorcallcc' + ; + +fastMathFlag + : 'afn' + | 'arcp' + | 'contract' + | 'fast' + | 'ninf' + | 'nnan' + | 'nsz' + | 'reassoc' + ; + +atomicOp + : 'add' + | 'and' + | 'fadd' + | 'fmax' + | 'fmin' + | 'fsub' + | 'max' + | 'min' + | 'nand' + | 'or' + | 'sub' + | 'umax' + | 'umin' + | 'xchg' + | 'xor' + ; + +floatKind + : 'half' + | 'bfloat' + | 'float' + | 'double' + | 'x86_fp80' + | 'fp128' + | 'ppc_fp128' + ; + /*看不懂,直接抄过来的 */ -specializedMDNode: - diBasicType - | diCommonBlock // not in spec as of 2019-12-05 - | diCompileUnit - | diCompositeType - | diDerivedType - | diEnumerator - | diExpression - | diFile - | diGlobalVariable - | diGlobalVariableExpression - | diImportedEntity - | diLabel // not in spec as of 2018-10-14, still not in spec as of 2019-12-05 - | diLexicalBlock - | diLexicalBlockFile - | diLocalVariable - | diLocation - | diMacro - | diMacroFile - | diModule // not in spec as of 2018-02-21, still not in spec as of 2019-12-05 - | diNamespace - | diObjCProperty - | diStringType - | diSubprogram - | diSubrange - | diSubroutineType - | diTemplateTypeParameter - | diTemplateValueParameter - | genericDiNode; // not in spec as of 2018-02-21, still not in spec as of 2019-12-05 - -diBasicType: - '!DIBasicType' '(' (diBasicTypeField (',' diBasicTypeField)*)? ')'; -diCommonBlock: - '!DICommonBlock' '(' ( - diCommonBlockField (',' diCommonBlockField)* - )? ')'; -diCompileUnit: - '!DICompileUnit' '(' ( - diCompileUnitField (',' diCompileUnitField)* - )? ')'; -diCompositeType: - '!DICompositeType' '(' ( - diCompositeTypeField (',' diCompositeTypeField)* - )? ')'; -diCompositeTypeField: - tagField - | nameField - | scopeField - | fileField - | lineField - | baseTypeField - | sizeField - | alignField - | offsetField - | flagsField - | elementsField - | runtimeLangField - | vtableHolderField - | templateParamsField - | identifierField - | discriminatorField - | dataLocationField - | associatedField - | allocatedField - | rankField - | annotationsField; -diDerivedType: - '!DIDerivedType' '(' ( - diDerivedTypeField (',' diDerivedTypeField)* - )? ')'; -diDerivedTypeField: - tagField - | nameField - | scopeField - | fileField - | lineField - | baseTypeField - | sizeField - | alignField - | offsetField - | flagsField - | extraDataField - | dwarfAddressSpaceField - | annotationsField; -diEnumerator: - '!DIEnumerator' '(' ( - diEnumeratorField (',' diEnumeratorField)* - )? ')'; -diEnumeratorField: nameField | valueIntField | isUnsignedField; -diFile: '!DIFile' '(' (diFileField (',' diFileField)*)? ')'; -diFileField: - filenameField - | directoryField - | checksumkindField - | checksumField - | sourceField; -diGlobalVariable: - '!DIGlobalVariable' '(' ( - diGlobalVariableField (',' diGlobalVariableField)* - )? ')'; -diGlobalVariableField: - nameField - | scopeField - | linkageNameField - | fileField - | lineField - | typeField - | isLocalField - | isDefinitionField - | templateParamsField - | declarationField - | alignField - | annotationsField; -diGlobalVariableExpression: - '!DIGlobalVariableExpression' '(' ( - diGlobalVariableExpressionField ( - ',' diGlobalVariableExpressionField - )* - )? ')'; -diGlobalVariableExpressionField: varField | exprField; -diImportedEntity: - '!DIImportedEntity' '(' ( - diImportedEntityField (',' diImportedEntityField)* - )? ')'; -diImportedEntityField: - tagField - | scopeField - | entityField - | fileField - | lineField - | nameField - | elementsField; - -diLabel: '!DILabel' '(' (diLabelField (',' diLabelField)*)? ')'; -diLabelField: scopeField | nameField | fileField | lineField; -diLexicalBlock: - '!DILexicalBlock' '(' ( - diLexicalBlockField (',' diLexicalBlockField)* - )? ')'; -diLexicalBlockField: - scopeField - | fileField - | lineField - | columnField; -diLexicalBlockFile: - '!DILexicalBlockFile' '(' ( - diLexicalBlockFileField (',' diLexicalBlockFileField)* - )? ')'; -diLexicalBlockFileField: - scopeField - | fileField - | discriminatorIntField; -diLocalVariable: - '!DILocalVariable' '(' ( - diLocalVariableField (',' diLocalVariableField)* - )? ')'; -diLocalVariableField: - scopeField - | nameField - | argField - | fileField - | lineField - | typeField - | flagsField - | alignField - | annotationsField; -diLocation: - '!DILocation' '(' (diLocationField (',' diLocationField)*)? ')'; -diLocationField: - lineField - | columnField - | scopeField - | inlinedAtField - | isImplicitCodeField; -diMacro: '!DIMacro' '(' (diMacroField (',' diMacroField)*)? ')'; -diMacroField: - typeMacinfoField - | lineField - | nameField - | valueStringField; -diMacroFile: - '!DIMacroFile' '(' (diMacroFileField (',' diMacroFileField)*)? ')'; -diMacroFileField: - typeMacinfoField - | lineField - | fileField - | nodesField; -diModule: - '!DIModule' '(' (diModuleField (',' diModuleField)*)? ')'; -diModuleField: - scopeField - | nameField - | configMacrosField - | includePathField - | apiNotesField - | fileField - | lineField - | isDeclField; -diNamespace: - '!DINamespace' '(' (diNamespaceField (',' diNamespaceField)*)? ')'; -diNamespaceField: scopeField | nameField | exportSymbolsField; -diObjCProperty: - '!DIObjCProperty' '(' ( - diObjCPropertyField (',' diObjCPropertyField)* - )? ')'; -diObjCPropertyField: - nameField - | fileField - | lineField - | setterField - | getterField - | attributesField - | typeField; -diStringType: - '!DIStringType' '(' ( - diStringTypeField (',' diStringTypeField)* - )? ')'; -diStringTypeField: - tagField - | nameField - | stringLengthField - | stringLengthExpressionField - | stringLocationExpressionField - | sizeField - | alignField - | encodingField; -diSubprogram: - '!DISubprogram' '(' ( - diSubprogramField (',' diSubprogramField)* - )? ')'; -diSubprogramField: - scopeField - | nameField - | linkageNameField - | fileField - | lineField - | typeField - | isLocalField - | isDefinitionField - | scopeLineField - | containingTypeField - | virtualityField - | virtualIndexField - | thisAdjustmentField - | flagsField - | spFlagsField - | isOptimizedField - | unitField - | templateParamsField - | declarationField - | retainedNodesField - | thrownTypesField - | annotationsField - | targetFuncNameField; -diSubrange: - '!DISubrange' '(' (diSubrangeField (',' diSubrangeField)*)? ')'; -diSubrangeField: - countField - | lowerBoundField - | upperBoundField - | strideField; -diSubroutineType: - '!DISubroutineType' '(' ( - diSubroutineTypeField (',' diSubroutineTypeField)* - )? ')'; -diTemplateTypeParameter: - '!DITemplateTypeParameter' '(' ( - diTemplateTypeParameterField ( - ',' diTemplateTypeParameterField - )* - )? ')'; -diTemplateValueParameter: - '!DITemplateValueParameter' '(' ( - diTemplateValueParameterField ( - ',' diTemplateValueParameterField - ) - )? ')'; -genericDiNode: - '!GenericDINode' '(' ( - genericDINodeField (',' genericDINodeField)* - )? ')'; - -diTemplateTypeParameterField: - nameField - | typeField - | defaultedField; -diCompileUnitField: - languageField - | fileField - | producerField - | isOptimizedField - | flagsStringField - | runtimeVersionField - | splitDebugFilenameField - | emissionKindField - | enumsField - | retainedTypesField - | globalsField - | importsField - | macrosField - | dwoIdField - | splitDebugInliningField - | debugInfoForProfilingField - | nameTableKindField - | rangesBaseAddressField - | sysrootField - | sdkField; -diCommonBlockField: - scopeField - | declarationField - | nameField - | fileField - | lineField; -diBasicTypeField: - tagField - | nameField - | sizeField - | alignField - | encodingField - | flagsField; -genericDINodeField: tagField | headerField | operandsField; -tagField: 'tag:' DwarfTag; -headerField: 'header:' StringLit; -operandsField: 'operands:' '{' (mdField (',' mdField)*)? '}'; -diTemplateValueParameterField: - tagField - | nameField - | typeField - | defaultedField - | valueField; -nameField: 'name:' StringLit; -typeField: 'type:' mdField; -defaultedField: 'defaulted:' boolConst; -valueField: 'value:' mdField; -mdField: nullConst | metadata; -diSubroutineTypeField: flagsField | ccField | typesField; -flagsField: 'flags:' diFlags; -diFlags: DiFlag ('|' DiFlag)*; -ccField: 'cc:' DwarfCc | IntLit; -alignField: 'align:' IntLit; -allocatedField: 'allocated:' mdField; -annotationsField: 'annotations:' mdField; -argField: 'arg:' IntLit; -associatedField: 'associated:' mdField; -attributesField: 'attributes:' IntLit; -baseTypeField: 'baseType:' mdField; -checksumField: 'checksum:' StringLit; -checksumkindField: 'checksumkind:' ChecksumKind; -columnField: 'column:' IntLit; -configMacrosField: 'configMacros:' StringLit; -containingTypeField: 'containingType:' mdField; -countField: 'count:' mdFieldOrInt; -debugInfoForProfilingField: 'debugInfoForProfiling:' boolConst; -declarationField: 'declaration:' mdField; -directoryField: 'directory:' StringLit; -discriminatorField: 'discriminator:' mdField; -dataLocationField: 'dataLocation:' mdField; -discriminatorIntField: 'discriminator:' IntLit; -dwarfAddressSpaceField: 'dwarfAddressSpace:' IntLit; -dwoIdField: 'dwoId:' IntLit; -elementsField: 'elements:' mdField; -emissionKindField: - 'emissionKind:' emissionKind = ( - 'DebugDirectivesOnly' - | 'FullDebug' - | 'LineTablesOnly' - | 'NoDebug' - ); -encodingField: 'encoding:' (IntLit | DwarfAttEncoding); -entityField: 'entity:' mdField; -enumsField: 'enums:' mdField; -exportSymbolsField: 'exportSymbols:' boolConst; -exprField: 'expr:' mdField; -extraDataField: 'extraData:' mdField; -fileField: 'file:' mdField; -filenameField: 'filename:' StringLit; -flagsStringField: 'flags:' StringLit; -getterField: 'getter:' StringLit; -globalsField: 'globals:' mdField; -identifierField: 'identifier:' StringLit; -importsField: 'imports:' mdField; -includePathField: 'includePath:' StringLit; -inlinedAtField: 'inlinedAt:' mdField; -isDeclField: 'isDecl:' boolConst; -isDefinitionField: 'isDefinition:' boolConst; -isImplicitCodeField: 'isImplicitCode:' boolConst; -isLocalField: 'isLocal:' boolConst; -isOptimizedField: 'isOptimized:' boolConst; -isUnsignedField: 'isUnsigned:' boolConst; -apiNotesField: 'apinotes:' StringLit; -languageField: 'language:' DwarfLang; -lineField: 'line:' IntLit; -linkageNameField: 'linkageName:' StringLit; -lowerBoundField: 'lowerBound:' mdFieldOrInt; -macrosField: 'macros:' mdField; -nameTableKindField: - 'nameTableKind:' nameTableKind = ('GNU' | 'None' | 'Default'); -nodesField: 'nodes:' mdField; -offsetField: - // TODO: rename OffsetField= attribute to Offset= when inspirer/textmapper#13 is resolved - 'offset:' IntLit; -producerField: 'producer:' StringLit; -rangesBaseAddressField: 'rangesBaseAddress:' boolConst; -rankField: 'rank:' mdFieldOrInt; -retainedNodesField: 'retainedNodes:' mdField; -retainedTypesField: 'retainedTypes:' mdField; -runtimeLangField: 'runtimeLang:' DwarfLang; -runtimeVersionField: 'runtimeVersion:' IntLit; -scopeField: 'scope:' mdField; -scopeLineField: 'scopeLine:' IntLit; -sdkField: 'sdk:' StringLit; -setterField: 'setter:' StringLit; -sizeField: 'size:' IntLit; -sourceField: 'source:' StringLit; -spFlagsField: 'spFlags:' (diSPFlag ('|' diSPFlag)*); -splitDebugFilenameField: 'splitDebugFilename:' StringLit; -splitDebugInliningField: 'splitDebugInlining:' boolConst; -strideField: 'stride:' mdFieldOrInt; -stringLengthField: 'stringLength:' mdField; -stringLengthExpressionField: 'stringLengthExpression:' mdField; -stringLocationExpressionField: - 'stringLocationExpression:' mdField; -sysrootField: 'sysroot:' StringLit; -targetFuncNameField: 'targetFuncName:' StringLit; -templateParamsField: 'templateParams:' mdField; -thisAdjustmentField: 'thisAdjustment:' IntLit; -thrownTypesField: 'thrownTypes:' mdField; -typeMacinfoField: 'type:' DwarfMacinfo; -typesField: 'types:' mdField; -unitField: 'unit:' mdField; -upperBoundField: 'upperBound:' mdFieldOrInt; -valueIntField: 'value:' IntLit; -valueStringField: 'value:' StringLit; -varField: 'var:' mdField; -virtualIndexField: 'virtualIndex:' IntLit; -virtualityField: 'virtuality:' DwarfVirtuality; -vtableHolderField: 'vtableHolder:' mdField; - -fragment AsciiLetter: [A-Za-z]; -fragment Letter: AsciiLetter | [-$._]; -fragment EscapeLetter: Letter | '\\'; -fragment DecimalDigit: [0-9]; -fragment HexDigit: [A-Fa-f] | DecimalDigit; -fragment Decimals: DecimalDigit+; -fragment Name: Letter (Letter | DecimalDigit)*; -fragment EscapeName: - EscapeLetter (EscapeLetter | DecimalDigit)*; -fragment Id: Decimals; -fragment IntHexLit: [us] '0x' HexDigit+; +specializedMDNode + : diBasicType + | diCommonBlock // not in spec as of 2019-12-05 + | diCompileUnit + | diCompositeType + | diDerivedType + | diEnumerator + | diExpression + | diFile + | diGlobalVariable + | diGlobalVariableExpression + | diImportedEntity + | diLabel // not in spec as of 2018-10-14, still not in spec as of 2019-12-05 + | diLexicalBlock + | diLexicalBlockFile + | diLocalVariable + | diLocation + | diMacro + | diMacroFile + | diModule // not in spec as of 2018-02-21, still not in spec as of 2019-12-05 + | diNamespace + | diObjCProperty + | diStringType + | diSubprogram + | diSubrange + | diSubroutineType + | diTemplateTypeParameter + | diTemplateValueParameter + | genericDiNode + ; // not in spec as of 2018-02-21, still not in spec as of 2019-12-05 + +diBasicType + : '!DIBasicType' '(' (diBasicTypeField (',' diBasicTypeField)*)? ')' + ; + +diCommonBlock + : '!DICommonBlock' '(' (diCommonBlockField (',' diCommonBlockField)*)? ')' + ; + +diCompileUnit + : '!DICompileUnit' '(' (diCompileUnitField (',' diCompileUnitField)*)? ')' + ; + +diCompositeType + : '!DICompositeType' '(' (diCompositeTypeField (',' diCompositeTypeField)*)? ')' + ; + +diCompositeTypeField + : tagField + | nameField + | scopeField + | fileField + | lineField + | baseTypeField + | sizeField + | alignField + | offsetField + | flagsField + | elementsField + | runtimeLangField + | vtableHolderField + | templateParamsField + | identifierField + | discriminatorField + | dataLocationField + | associatedField + | allocatedField + | rankField + | annotationsField + ; + +diDerivedType + : '!DIDerivedType' '(' (diDerivedTypeField (',' diDerivedTypeField)*)? ')' + ; + +diDerivedTypeField + : tagField + | nameField + | scopeField + | fileField + | lineField + | baseTypeField + | sizeField + | alignField + | offsetField + | flagsField + | extraDataField + | dwarfAddressSpaceField + | annotationsField + ; + +diEnumerator + : '!DIEnumerator' '(' (diEnumeratorField (',' diEnumeratorField)*)? ')' + ; + +diEnumeratorField + : nameField + | valueIntField + | isUnsignedField + ; + +diFile + : '!DIFile' '(' (diFileField (',' diFileField)*)? ')' + ; + +diFileField + : filenameField + | directoryField + | checksumkindField + | checksumField + | sourceField + ; + +diGlobalVariable + : '!DIGlobalVariable' '(' (diGlobalVariableField (',' diGlobalVariableField)*)? ')' + ; + +diGlobalVariableField + : nameField + | scopeField + | linkageNameField + | fileField + | lineField + | typeField + | isLocalField + | isDefinitionField + | templateParamsField + | declarationField + | alignField + | annotationsField + ; + +diGlobalVariableExpression + : '!DIGlobalVariableExpression' '(' ( + diGlobalVariableExpressionField (',' diGlobalVariableExpressionField)* + )? ')' + ; + +diGlobalVariableExpressionField + : varField + | exprField + ; + +diImportedEntity + : '!DIImportedEntity' '(' (diImportedEntityField (',' diImportedEntityField)*)? ')' + ; + +diImportedEntityField + : tagField + | scopeField + | entityField + | fileField + | lineField + | nameField + | elementsField + ; + +diLabel + : '!DILabel' '(' (diLabelField (',' diLabelField)*)? ')' + ; + +diLabelField + : scopeField + | nameField + | fileField + | lineField + ; + +diLexicalBlock + : '!DILexicalBlock' '(' (diLexicalBlockField (',' diLexicalBlockField)*)? ')' + ; + +diLexicalBlockField + : scopeField + | fileField + | lineField + | columnField + ; + +diLexicalBlockFile + : '!DILexicalBlockFile' '(' (diLexicalBlockFileField (',' diLexicalBlockFileField)*)? ')' + ; + +diLexicalBlockFileField + : scopeField + | fileField + | discriminatorIntField + ; + +diLocalVariable + : '!DILocalVariable' '(' (diLocalVariableField (',' diLocalVariableField)*)? ')' + ; + +diLocalVariableField + : scopeField + | nameField + | argField + | fileField + | lineField + | typeField + | flagsField + | alignField + | annotationsField + ; + +diLocation + : '!DILocation' '(' (diLocationField (',' diLocationField)*)? ')' + ; + +diLocationField + : lineField + | columnField + | scopeField + | inlinedAtField + | isImplicitCodeField + ; + +diMacro + : '!DIMacro' '(' (diMacroField (',' diMacroField)*)? ')' + ; + +diMacroField + : typeMacinfoField + | lineField + | nameField + | valueStringField + ; + +diMacroFile + : '!DIMacroFile' '(' (diMacroFileField (',' diMacroFileField)*)? ')' + ; + +diMacroFileField + : typeMacinfoField + | lineField + | fileField + | nodesField + ; + +diModule + : '!DIModule' '(' (diModuleField (',' diModuleField)*)? ')' + ; + +diModuleField + : scopeField + | nameField + | configMacrosField + | includePathField + | apiNotesField + | fileField + | lineField + | isDeclField + ; + +diNamespace + : '!DINamespace' '(' (diNamespaceField (',' diNamespaceField)*)? ')' + ; + +diNamespaceField + : scopeField + | nameField + | exportSymbolsField + ; + +diObjCProperty + : '!DIObjCProperty' '(' (diObjCPropertyField (',' diObjCPropertyField)*)? ')' + ; + +diObjCPropertyField + : nameField + | fileField + | lineField + | setterField + | getterField + | attributesField + | typeField + ; + +diStringType + : '!DIStringType' '(' (diStringTypeField (',' diStringTypeField)*)? ')' + ; + +diStringTypeField + : tagField + | nameField + | stringLengthField + | stringLengthExpressionField + | stringLocationExpressionField + | sizeField + | alignField + | encodingField + ; + +diSubprogram + : '!DISubprogram' '(' (diSubprogramField (',' diSubprogramField)*)? ')' + ; + +diSubprogramField + : scopeField + | nameField + | linkageNameField + | fileField + | lineField + | typeField + | isLocalField + | isDefinitionField + | scopeLineField + | containingTypeField + | virtualityField + | virtualIndexField + | thisAdjustmentField + | flagsField + | spFlagsField + | isOptimizedField + | unitField + | templateParamsField + | declarationField + | retainedNodesField + | thrownTypesField + | annotationsField + | targetFuncNameField + ; + +diSubrange + : '!DISubrange' '(' (diSubrangeField (',' diSubrangeField)*)? ')' + ; + +diSubrangeField + : countField + | lowerBoundField + | upperBoundField + | strideField + ; + +diSubroutineType + : '!DISubroutineType' '(' (diSubroutineTypeField (',' diSubroutineTypeField)*)? ')' + ; + +diTemplateTypeParameter + : '!DITemplateTypeParameter' '(' ( + diTemplateTypeParameterField ( ',' diTemplateTypeParameterField)* + )? ')' + ; + +diTemplateValueParameter + : '!DITemplateValueParameter' '(' ( + diTemplateValueParameterField ( ',' diTemplateValueParameterField) + )? ')' + ; + +genericDiNode + : '!GenericDINode' '(' (genericDINodeField (',' genericDINodeField)*)? ')' + ; + +diTemplateTypeParameterField + : nameField + | typeField + | defaultedField + ; + +diCompileUnitField + : languageField + | fileField + | producerField + | isOptimizedField + | flagsStringField + | runtimeVersionField + | splitDebugFilenameField + | emissionKindField + | enumsField + | retainedTypesField + | globalsField + | importsField + | macrosField + | dwoIdField + | splitDebugInliningField + | debugInfoForProfilingField + | nameTableKindField + | rangesBaseAddressField + | sysrootField + | sdkField + ; + +diCommonBlockField + : scopeField + | declarationField + | nameField + | fileField + | lineField + ; + +diBasicTypeField + : tagField + | nameField + | sizeField + | alignField + | encodingField + | flagsField + ; + +genericDINodeField + : tagField + | headerField + | operandsField + ; + +tagField + : 'tag:' DwarfTag + ; + +headerField + : 'header:' StringLit + ; + +operandsField + : 'operands:' '{' (mdField (',' mdField)*)? '}' + ; + +diTemplateValueParameterField + : tagField + | nameField + | typeField + | defaultedField + | valueField + ; + +nameField + : 'name:' StringLit + ; + +typeField + : 'type:' mdField + ; + +defaultedField + : 'defaulted:' boolConst + ; + +valueField + : 'value:' mdField + ; + +mdField + : nullConst + | metadata + ; + +diSubroutineTypeField + : flagsField + | ccField + | typesField + ; + +flagsField + : 'flags:' diFlags + ; + +diFlags + : DiFlag ('|' DiFlag)* + ; + +ccField + : 'cc:' DwarfCc + | IntLit + ; + +alignField + : 'align:' IntLit + ; + +allocatedField + : 'allocated:' mdField + ; + +annotationsField + : 'annotations:' mdField + ; + +argField + : 'arg:' IntLit + ; + +associatedField + : 'associated:' mdField + ; + +attributesField + : 'attributes:' IntLit + ; + +baseTypeField + : 'baseType:' mdField + ; + +checksumField + : 'checksum:' StringLit + ; + +checksumkindField + : 'checksumkind:' ChecksumKind + ; + +columnField + : 'column:' IntLit + ; + +configMacrosField + : 'configMacros:' StringLit + ; + +containingTypeField + : 'containingType:' mdField + ; + +countField + : 'count:' mdFieldOrInt + ; + +debugInfoForProfilingField + : 'debugInfoForProfiling:' boolConst + ; + +declarationField + : 'declaration:' mdField + ; + +directoryField + : 'directory:' StringLit + ; + +discriminatorField + : 'discriminator:' mdField + ; + +dataLocationField + : 'dataLocation:' mdField + ; + +discriminatorIntField + : 'discriminator:' IntLit + ; + +dwarfAddressSpaceField + : 'dwarfAddressSpace:' IntLit + ; + +dwoIdField + : 'dwoId:' IntLit + ; + +elementsField + : 'elements:' mdField + ; + +emissionKindField + : 'emissionKind:' emissionKind = ( + 'DebugDirectivesOnly' + | 'FullDebug' + | 'LineTablesOnly' + | 'NoDebug' + ) + ; + +encodingField + : 'encoding:' (IntLit | DwarfAttEncoding) + ; + +entityField + : 'entity:' mdField + ; + +enumsField + : 'enums:' mdField + ; + +exportSymbolsField + : 'exportSymbols:' boolConst + ; + +exprField + : 'expr:' mdField + ; + +extraDataField + : 'extraData:' mdField + ; + +fileField + : 'file:' mdField + ; + +filenameField + : 'filename:' StringLit + ; + +flagsStringField + : 'flags:' StringLit + ; + +getterField + : 'getter:' StringLit + ; + +globalsField + : 'globals:' mdField + ; + +identifierField + : 'identifier:' StringLit + ; + +importsField + : 'imports:' mdField + ; + +includePathField + : 'includePath:' StringLit + ; + +inlinedAtField + : 'inlinedAt:' mdField + ; + +isDeclField + : 'isDecl:' boolConst + ; + +isDefinitionField + : 'isDefinition:' boolConst + ; + +isImplicitCodeField + : 'isImplicitCode:' boolConst + ; + +isLocalField + : 'isLocal:' boolConst + ; + +isOptimizedField + : 'isOptimized:' boolConst + ; + +isUnsignedField + : 'isUnsigned:' boolConst + ; + +apiNotesField + : 'apinotes:' StringLit + ; + +languageField + : 'language:' DwarfLang + ; + +lineField + : 'line:' IntLit + ; + +linkageNameField + : 'linkageName:' StringLit + ; + +lowerBoundField + : 'lowerBound:' mdFieldOrInt + ; + +macrosField + : 'macros:' mdField + ; + +nameTableKindField + : 'nameTableKind:' nameTableKind = ('GNU' | 'None' | 'Default') + ; + +nodesField + : 'nodes:' mdField + ; + +offsetField + : + // TODO: rename OffsetField= attribute to Offset= when inspirer/textmapper#13 is resolved + 'offset:' IntLit + ; + +producerField + : 'producer:' StringLit + ; + +rangesBaseAddressField + : 'rangesBaseAddress:' boolConst + ; + +rankField + : 'rank:' mdFieldOrInt + ; + +retainedNodesField + : 'retainedNodes:' mdField + ; + +retainedTypesField + : 'retainedTypes:' mdField + ; + +runtimeLangField + : 'runtimeLang:' DwarfLang + ; + +runtimeVersionField + : 'runtimeVersion:' IntLit + ; + +scopeField + : 'scope:' mdField + ; + +scopeLineField + : 'scopeLine:' IntLit + ; + +sdkField + : 'sdk:' StringLit + ; + +setterField + : 'setter:' StringLit + ; + +sizeField + : 'size:' IntLit + ; + +sourceField + : 'source:' StringLit + ; + +spFlagsField + : 'spFlags:' (diSPFlag ('|' diSPFlag)*) + ; + +splitDebugFilenameField + : 'splitDebugFilename:' StringLit + ; + +splitDebugInliningField + : 'splitDebugInlining:' boolConst + ; + +strideField + : 'stride:' mdFieldOrInt + ; + +stringLengthField + : 'stringLength:' mdField + ; + +stringLengthExpressionField + : 'stringLengthExpression:' mdField + ; + +stringLocationExpressionField + : 'stringLocationExpression:' mdField + ; + +sysrootField + : 'sysroot:' StringLit + ; + +targetFuncNameField + : 'targetFuncName:' StringLit + ; + +templateParamsField + : 'templateParams:' mdField + ; + +thisAdjustmentField + : 'thisAdjustment:' IntLit + ; + +thrownTypesField + : 'thrownTypes:' mdField + ; + +typeMacinfoField + : 'type:' DwarfMacinfo + ; + +typesField + : 'types:' mdField + ; + +unitField + : 'unit:' mdField + ; + +upperBoundField + : 'upperBound:' mdFieldOrInt + ; + +valueIntField + : 'value:' IntLit + ; + +valueStringField + : 'value:' StringLit + ; + +varField + : 'var:' mdField + ; + +virtualIndexField + : 'virtualIndex:' IntLit + ; + +virtualityField + : 'virtuality:' DwarfVirtuality + ; + +vtableHolderField + : 'vtableHolder:' mdField + ; + +fragment AsciiLetter + : [A-Za-z] + ; + +fragment Letter + : AsciiLetter + | [-$._] + ; + +fragment EscapeLetter + : Letter + | '\\' + ; + +fragment DecimalDigit + : [0-9] + ; + +fragment HexDigit + : [A-Fa-f] + | DecimalDigit + ; + +fragment Decimals + : DecimalDigit+ + ; + +fragment Name + : Letter (Letter | DecimalDigit)* + ; + +fragment EscapeName + : EscapeLetter (EscapeLetter | DecimalDigit)* + ; + +fragment Id + : Decimals + ; + +fragment IntHexLit + : [us] '0x' HexDigit+ + ; + // 浮点型常量 -fragment Sign: [+-]; -fragment FracLit: Sign? Decimals '.' DecimalDigit*; -fragment SciLit: FracLit [eE] Sign? Decimals; +fragment Sign + : [+-] + ; + +fragment FracLit + : Sign? Decimals '.' DecimalDigit* + ; + +fragment SciLit + : FracLit [eE] Sign? Decimals + ; + /* HexFPConstant 0x{_hex_digit}+ // 16 hex digits HexFP80Constant 0xK{_hex_digit}+ // 20 hex digits @@ -1407,33 +2390,124 @@ fragment SciLit: FracLit [eE] Sign? Decimals; HexBFloatConstant 0xR{_hex_digit}+ // 4 hex digits */ -fragment FloatHexLit: '0x' [KLMHR]? HexDigit+; -fragment GlobalName: '@' (Name | QuotedString); -fragment GlobalId: '@' Id; -fragment LocalName: '%' (Name | QuotedString); -fragment LocalId: '%' Id; -fragment QuotedString: '"' (~["\r\n])* '"'; -Comment: ';' .*? '\r'? '\n' -> channel(HIDDEN); -WhiteSpace: [ \t\n\r]+ -> skip; -IntLit: '-'? DecimalDigit+ | IntHexLit; -FloatLit: FracLit | SciLit | FloatHexLit; -StringLit: QuotedString; -GlobalIdent: GlobalName | GlobalId; -LocalIdent: LocalName | LocalId; -LabelIdent: (Letter | DecimalDigit)+ ':' | QuotedString ':'; -AttrGroupId: '#' Id; -ComdatName: '$' (Name | QuotedString); -MetadataName: '!' EscapeName; -MetadataId: '!' Id; -IntType: 'i' DecimalDigit+; -DwarfTag: 'DW_TAG_' (AsciiLetter | DecimalDigit | '_')*; -DwarfAttEncoding: 'DW_ATE_' (AsciiLetter | DecimalDigit | '_')*; -DiFlag: 'DIFlag' (AsciiLetter | DecimalDigit | '_')*; -DispFlag: 'DISPFlag' (AsciiLetter | DecimalDigit | '_')*; -DwarfLang: 'DW_LANG_' (AsciiLetter | DecimalDigit | '_')*; -DwarfCc: 'DW_CC_' (AsciiLetter | DecimalDigit | '_')*; -ChecksumKind: 'CSK_' (AsciiLetter | DecimalDigit | '_')*; -DwarfVirtuality: - 'DW_VIRTUALITY_' (AsciiLetter | DecimalDigit | '_')*; -DwarfMacinfo: 'DW_MACINFO_' (AsciiLetter | DecimalDigit | '_')*; -DwarfOp: 'DW_OP_' (AsciiLetter | DecimalDigit | '_')*; +fragment FloatHexLit + : '0x' [KLMHR]? HexDigit+ + ; + +fragment GlobalName + : '@' (Name | QuotedString) + ; + +fragment GlobalId + : '@' Id + ; + +fragment LocalName + : '%' (Name | QuotedString) + ; + +fragment LocalId + : '%' Id + ; + +fragment QuotedString + : '"' (~["\r\n])* '"' + ; + +Comment + : ';' .*? '\r'? '\n' -> channel(HIDDEN) + ; + +WhiteSpace + : [ \t\n\r]+ -> skip + ; + +IntLit + : '-'? DecimalDigit+ + | IntHexLit + ; + +FloatLit + : FracLit + | SciLit + | FloatHexLit + ; + +StringLit + : QuotedString + ; + +GlobalIdent + : GlobalName + | GlobalId + ; + +LocalIdent + : LocalName + | LocalId + ; + +LabelIdent + : (Letter | DecimalDigit)+ ':' + | QuotedString ':' + ; + +AttrGroupId + : '#' Id + ; + +ComdatName + : '$' (Name | QuotedString) + ; + +MetadataName + : '!' EscapeName + ; + +MetadataId + : '!' Id + ; + +IntType + : 'i' DecimalDigit+ + ; + +DwarfTag + : 'DW_TAG_' (AsciiLetter | DecimalDigit | '_')* + ; + +DwarfAttEncoding + : 'DW_ATE_' (AsciiLetter | DecimalDigit | '_')* + ; + +DiFlag + : 'DIFlag' (AsciiLetter | DecimalDigit | '_')* + ; + +DispFlag + : 'DISPFlag' (AsciiLetter | DecimalDigit | '_')* + ; + +DwarfLang + : 'DW_LANG_' (AsciiLetter | DecimalDigit | '_')* + ; + +DwarfCc + : 'DW_CC_' (AsciiLetter | DecimalDigit | '_')* + ; + +ChecksumKind + : 'CSK_' (AsciiLetter | DecimalDigit | '_')* + ; + +DwarfVirtuality + : 'DW_VIRTUALITY_' (AsciiLetter | DecimalDigit | '_')* + ; + +DwarfMacinfo + : 'DW_MACINFO_' (AsciiLetter | DecimalDigit | '_')* + ; + +DwarfOp + : 'DW_OP_' (AsciiLetter | DecimalDigit | '_')* + ; \ No newline at end of file diff --git a/logo/logo/logo.g4 b/logo/logo/logo.g4 index 372cd84268..31c1e7b09f 100644 --- a/logo/logo/logo.g4 +++ b/logo/logo/logo.g4 @@ -30,215 +30,212 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar logo; prog - : (line? EOL) + line? EOF - ; + : (line? EOL)+ line? EOF + ; line - : cmd + comment? - | comment - | print_ comment? - | procedureDeclaration - ; + : cmd+ comment? + | comment + | print_ comment? + | procedureDeclaration + ; cmd - : repeat_ - | fd - | bk - | rt - | lt - | cs - | pu - | pd - | ht - | st - | home - | label - | setxy - | make - | procedureInvocation - | ife - | stop - | fore - ; + : repeat_ + | fd + | bk + | rt + | lt + | cs + | pu + | pd + | ht + | st + | home + | label + | setxy + | make + | procedureInvocation + | ife + | stop + | fore + ; procedureInvocation - : name expression* - ; + : name expression* + ; procedureDeclaration - : 'to' name parameterDeclarations* EOL? (line? EOL) + 'end' - ; + : 'to' name parameterDeclarations* EOL? (line? EOL)+ 'end' + ; parameterDeclarations - : ':' name (',' parameterDeclarations)* - ; + : ':' name (',' parameterDeclarations)* + ; func_ - : random - ; + : random + ; repeat_ - : 'repeat' number block - ; + : 'repeat' number block + ; block - : '[' cmd + ']' - ; + : '[' cmd+ ']' + ; ife - : 'if' comparison block - ; + : 'if' comparison block + ; comparison - : expression comparisonOperator expression - ; + : expression comparisonOperator expression + ; comparisonOperator - : '<' - | '>' - | '=' - ; + : '<' + | '>' + | '=' + ; make - : 'make' STRINGLITERAL value - ; + : 'make' STRINGLITERAL value + ; print_ - : 'print' (value | quotedstring) - ; + : 'print' (value | quotedstring) + ; quotedstring - : '[' (quotedstring | ~ ']')* ']' - ; + : '[' (quotedstring | ~ ']')* ']' + ; name - : STRING - ; + : STRING + ; value - : STRINGLITERAL - | expression - | deref - ; + : STRINGLITERAL + | expression + | deref + ; signExpression - : (('+' | '-'))* (number | deref | func_) - ; + : (('+' | '-'))* (number | deref | func_) + ; multiplyingExpression - : signExpression (('*' | '/') signExpression)* - ; + : signExpression (('*' | '/') signExpression)* + ; expression - : multiplyingExpression (('+' | '-') multiplyingExpression)* - ; + : multiplyingExpression (('+' | '-') multiplyingExpression)* + ; deref - : ':' name - ; + : ':' name + ; fd - : ('fd' | 'forward') expression - ; + : ('fd' | 'forward') expression + ; bk - : ('bk' | 'backward') expression - ; + : ('bk' | 'backward') expression + ; rt - : ('rt' | 'right') expression - ; + : ('rt' | 'right') expression + ; lt - : ('lt' | 'left') expression - ; + : ('lt' | 'left') expression + ; cs - : 'cs' - | 'clearscreen' - ; + : 'cs' + | 'clearscreen' + ; pu - : 'pu' - | 'penup' - ; + : 'pu' + | 'penup' + ; pd - : 'pd' - | 'pendown' - ; + : 'pd' + | 'pendown' + ; ht - : 'ht' - | 'hideturtle' - ; + : 'ht' + | 'hideturtle' + ; st - : 'st' - | 'showturtle' - ; + : 'st' + | 'showturtle' + ; home - : 'home' - ; + : 'home' + ; stop - : 'stop' - ; + : 'stop' + ; label - : 'label' - ; + : 'label' + ; setxy - : 'setxy' expression expression - ; + : 'setxy' expression expression + ; random - : 'random' expression - ; + : 'random' expression + ; fore - : 'for' '[' name expression expression expression ']' block - ; + : 'for' '[' name expression expression expression ']' block + ; number - : NUMBER - ; + : NUMBER + ; comment - : COMMENT - ; - + : COMMENT + ; STRINGLITERAL - : '"' STRING - ; - + : '"' STRING + ; STRING - : [a-zA-Z] [a-zA-Z0-9_]* - ; - + : [a-zA-Z] [a-zA-Z0-9_]* + ; NUMBER - : [0-9] + - ; - + : [0-9]+ + ; COMMENT - : ';' ~ [\r\n]* - ; - + : ';' ~ [\r\n]* + ; EOL - : '\r'? '\n' - ; - + : '\r'? '\n' + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/logo/ucb-logo/UCBLogo.g4 b/logo/ucb-logo/UCBLogo.g4 index 738b299665..3fa0333771 100755 --- a/logo/ucb-logo/UCBLogo.g4 +++ b/logo/ucb-logo/UCBLogo.g4 @@ -28,6 +28,10 @@ * https://github.com/bkiers/logo-parser * Developed by : Bart Kiers, bart@big-o.nl */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar UCBLogo; @parser::header { @@ -548,205 +552,326 @@ grammar UCBLogo; } parse - : instruction* EOF - ; + : instruction* EOF + ; instruction - : procedure_def #procedureDefInstruction - | macro_def #macroDefInstruction - | procedure_call_extra_input #procedureCallExtraInputInstruction - | procedure_call #procedureCallInstruction - ; + : procedure_def # procedureDefInstruction + | macro_def # macroDefInstruction + | procedure_call_extra_input # procedureCallExtraInputInstruction + | procedure_call # procedureCallInstruction + ; procedure_def - : TO NAME variables body_def - { + : TO NAME variables body_def { procedures.put($NAME.getText(), $variables.amount); } - ; + ; macro_def - : MACRO NAME variables body_def - { + : MACRO NAME variables body_def { procedures.put($NAME.getText(), $variables.amount); } - ; + ; -variables returns [int amount] - : {$amount = 0;} ( VARIABLE {$amount++;} )* - ; +variables + returns[int amount] + : {$amount = 0;} (VARIABLE {$amount++;})* + ; body_def - : {discoveredAllProcedures}? body_instruction* END - | ~END* END - ; + : {discoveredAllProcedures}? body_instruction* END + | ~END* END + ; body_instruction - : procedure_call_extra_input - | procedure_call - ; + : procedure_call_extra_input + | procedure_call + ; procedure_call_extra_input - : '(' {procedureNameAhead()}? NAME expression* ')' - ; + : '(' {procedureNameAhead()}? NAME expression* ')' + ; procedure_call - : {procedureNameAhead()}? NAME expressions[$NAME.getText(), amountParams($NAME.getText())] - ; + : {procedureNameAhead()}? NAME expressions[$NAME.getText(), amountParams($NAME.getText())] + ; expressions[String name, int total] -locals[int n = 0] // a counter to keep track of how many expressions we've parsed - : ( - {$n < $total}? // check if we've parsed enough expressions - expression - {$n++;} // increments the amount of expressions we've parsed - )* - - { + locals[int n = 0] // a counter to keep track of how many expressions we've parsed + : ( + {$n < $total}? // check if we've parsed enough expressions + expression {$n++;} // increments the amount of expressions we've parsed + )* { // Make sure there are enough inputs parsed for 'name'. if ($total > $n) { throw new RuntimeException("not enough inputs to " + name); } } - ; + ; expression - : '-' expression #unaryMinusExpression - | procedure_call_extra_input #procedureCallExtraInput - | procedure_call #procedureCallExpression - | '(' expression ')' #parensExpression - | array_ #arrayExpression - | list_ #listExpression - | WORD #wordExpression - | QUOTED_WORD #quotedWordExpression - | NUMBER #numberExpression - | VARIABLE #variableExpression - | NAME #nameExpression - | expression '*' expression #multiplyExpression - | expression '/' expression #divideExpression - | expression '+' expression #additionExpression - | expression '-' expression #subtractionExpression - | expression '<' expression #lessThanExpression - | expression '>' expression #greaterThanExpression - | expression '<=' expression #lessThanEqualsExpression - | expression '>=' expression #greaterThanEqualsExpression - | expression '=' expression #equalsExpression - | expression '<>' expression #notEqualsExpressionExpression - ; + : '-' expression # unaryMinusExpression + | procedure_call_extra_input # procedureCallExtraInput + | procedure_call # procedureCallExpression + | '(' expression ')' # parensExpression + | array_ # arrayExpression + | list_ # listExpression + | WORD # wordExpression + | QUOTED_WORD # quotedWordExpression + | NUMBER # numberExpression + | VARIABLE # variableExpression + | NAME # nameExpression + | expression '*' expression # multiplyExpression + | expression '/' expression # divideExpression + | expression '+' expression # additionExpression + | expression '-' expression # subtractionExpression + | expression '<' expression # lessThanExpression + | expression '>' expression # greaterThanExpression + | expression '<=' expression # lessThanEqualsExpression + | expression '>=' expression # greaterThanEqualsExpression + | expression '=' expression # equalsExpression + | expression '<>' expression # notEqualsExpressionExpression + ; array_ - : '{' ( ~( '{' | '}' ) | array_ )* '}' - ; + : '{' (~( '{' | '}') | array_)* '}' + ; list_ - : '[' ( ~( '[' | ']' ) | list_ )* ']' - ; + : '[' (~( '[' | ']') | list_)* ']' + ; + +TO + : T O + ; -TO : T O; -END : E N D; -MACRO : '.' M A C R O; +END + : E N D + ; + +MACRO + : '.' M A C R O + ; WORD - : {listDepth > 0}? ~[ \t\r\n[\];] ( ~[ \t\r\n\];~] | LINE_CONTINUATION | '\\' ( [ \t[\]();~] | LINE_BREAK ) )* - | {arrayDepth > 0}? ~[ \t\r\n{};] ( ~[ \t\r\n};~] | LINE_CONTINUATION | '\\' ( [ \t{}();~] | LINE_BREAK ) )* - ; + : {listDepth > 0}? ~[ \t\r\n[\];] ( + ~[ \t\r\n\];~] + | LINE_CONTINUATION + | '\\' ( [ \t[\]();~] | LINE_BREAK) + )* + | {arrayDepth > 0}? ~[ \t\r\n{};] ( + ~[ \t\r\n};~] + | LINE_CONTINUATION + | '\\' ( [ \t{}();~] | LINE_BREAK) + )* + ; SKIP_ - : ( COMMENT | LINE_BREAK | SPACES | LINE_CONTINUATION ) -> skip - ; + : (COMMENT | LINE_BREAK | SPACES | LINE_CONTINUATION) -> skip + ; OPEN_ARRAY - : '{' {arrayDepth++;} - ; + : '{' {arrayDepth++;} + ; CLOSE_ARRAY - : '}' {arrayDepth--;} - ; + : '}' {arrayDepth--;} + ; OPEN_LIST - : '[' {listDepth++;} - ; + : '[' {listDepth++;} + ; CLOSE_LIST - : ']' {listDepth--;} - ; + : ']' {listDepth--;} + ; + +MINUS + : '-' + ; + +PLUS + : '+' + ; + +MULT + : '*' + ; + +DIV + : '/' + ; + +LT + : '<' + ; + +GT + : '>' + ; +EQ + : '=' + ; -MINUS : '-'; -PLUS : '+'; -MULT : '*'; -DIV : '/'; -LT : '<'; -GT : '>'; -EQ : '='; -LT_EQ : '<='; -GT_EQ : '>='; -NOT_EQ : '<>'; +LT_EQ + : '<=' + ; + +GT_EQ + : '>=' + ; + +NOT_EQ + : '<>' + ; QUOTED_WORD - : '"' ( ~[ \t\r\n[\]();~] | LINE_CONTINUATION | '\\' ( [ \t[\]();~] | LINE_BREAK ) )* - ; + : '"' (~[ \t\r\n[\]();~] | LINE_CONTINUATION | '\\' ( [ \t[\]();~] | LINE_BREAK))* + ; NUMBER - : [0-9]+ ( '.' [0-9]+ )? - ; + : [0-9]+ ('.' [0-9]+)? + ; VARIABLE - : ':' NAME - ; + : ':' NAME + ; NAME - : ~[-+*/=<> \t\r\n[\]()":{}] ( ~[-+*/=<> \t\r\n[\](){}] | LINE_CONTINUATION | '\\' [-+*/=<> \t\r\n[\]();~{}] )* - ; + : ~[-+*/=<> \t\r\n[\]()":{}] ( + ~[-+*/=<> \t\r\n[\](){}] + | LINE_CONTINUATION + | '\\' [-+*/=<> \t\r\n[\]();~{}] + )* + ; ANY - : . {System.err.println("unexpected char: " + getText());} - ; + : . {System.err.println("unexpected char: " + getText());} + ; fragment COMMENT - : ';' ~[\r\n~]* - ; + : ';' ~[\r\n~]* + ; fragment LINE_CONTINUATION - : COMMENT? '~' SPACES? LINE_BREAK - ; + : COMMENT? '~' SPACES? LINE_BREAK + ; fragment LINE_BREAK - : '\r'? '\n' - | '\r' - ; + : '\r'? '\n' + | '\r' + ; fragment SPACES - : [ \t]+ - ; + : [ \t]+ + ; fragment SPACE_CHARS - : [ \t\r\n]+ - ; - -fragment A : [Aa]; -fragment B : [Bb]; -fragment C : [Cc]; -fragment D : [Dd]; -fragment E : [Ee]; -fragment F : [Ff]; -fragment G : [Gg]; -fragment H : [Hh]; -fragment I : [Ii]; -fragment J : [Jj]; -fragment K : [Kk]; -fragment L : [Ll]; -fragment M : [Mm]; -fragment N : [Nn]; -fragment O : [Oo]; -fragment P : [Pp]; -fragment Q : [Qq]; -fragment R : [Rr]; -fragment S : [Ss]; -fragment T : [Tt]; -fragment U : [Uu]; -fragment V : [Vv]; -fragment W : [Ww]; -fragment X : [Xx]; -fragment Y : [Yy]; -fragment Z : [Zz]; + : [ \t\r\n]+ + ; + +fragment A + : [Aa] + ; + +fragment B + : [Bb] + ; + +fragment C + : [Cc] + ; + +fragment D + : [Dd] + ; + +fragment E + : [Ee] + ; + +fragment F + : [Ff] + ; + +fragment G + : [Gg] + ; + +fragment H + : [Hh] + ; + +fragment I + : [Ii] + ; + +fragment J + : [Jj] + ; + +fragment K + : [Kk] + ; + +fragment L + : [Ll] + ; + +fragment M + : [Mm] + ; + +fragment N + : [Nn] + ; + +fragment O + : [Oo] + ; + +fragment P + : [Pp] + ; + +fragment Q + : [Qq] + ; + +fragment R + : [Rr] + ; + +fragment S + : [Ss] + ; + +fragment T + : [Tt] + ; + +fragment U + : [Uu] + ; + +fragment V + : [Vv] + ; + +fragment W + : [Ww] + ; + +fragment X + : [Xx] + ; + +fragment Y + : [Yy] + ; + +fragment Z + : [Zz] + ; \ No newline at end of file diff --git a/lpc/LPC.g4 b/lpc/LPC.g4 index b2265068a4..a4f0a51073 100644 --- a/lpc/LPC.g4 +++ b/lpc/LPC.g4 @@ -1,77 +1,86 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar LPC; /* Lex */ TypeModifier - : 'nomask' - | 'private' - | 'otected' - | 'public' - | 'static' - | 'varargs' + : 'nomask' + | 'private' + | 'otected' + | 'public' + | 'static' + | 'varargs' ; Assign - : '=' - | '+=' - | '-=' - | '&=' - | '|=' - | '^=' - | '<<=' - | '>>=' - | '*=' - | '%=' - | '/=' + : '=' + | '+=' + | '-=' + | '&=' + | '|=' + | '^=' + | '<<=' + | '>>=' + | '*=' + | '%=' + | '/=' ; -PlusPlus : '++' ; +PlusPlus + : '++' + ; -MinusMinus : '--' ; +MinusMinus + : '--' + ; -And : '&' ; +And + : '&' + ; AndAnd - : '&&' + : '&&' ; Caret - : '^' + : '^' ; Or - : '|' + : '|' ; OrOr - : '||' + : '||' ; Equal - : '==' + : '==' ; LeftShift - : '<<' + : '<<' ; RightShift - : '>>' + : '>>' ; Not - : '!' + : '!' ; NotEqual - : '!=' + : '!=' ; Compare - //: '<' - : LessEqual - | Great - | GreatEqual +//: '<' + : LessEqual + | Great + | GreatEqual ; /* @@ -82,750 +91,705 @@ Compare // ; LessEqual - : '<=' + : '<=' ; Great - : '>' + : '>' ; GreatEqual - : '>=' + : '>=' ; /* Reserved */ Arrow - : '->' + : '->' ; BasicType - : 'buffer' - | 'float' - | 'function' - | 'int' - | 'mapping' - | 'mixed' - | 'object' + : 'buffer' + | 'float' + | 'function' + | 'int' + | 'mapping' + | 'mixed' + | 'object' // | 'status' - | 'string' - | 'object_tx' - | 'void' + | 'string' + | 'object_tx' + | 'void' ; Break - : 'break' + : 'break' ; Catch - : 'catch' + : 'catch' ; Class - : 'class' + : 'class' ; Colon - : ':' + : ':' ; ColonColon - : '::' + : '::' ; Continue - : 'continue' + : 'continue' ; DefinedName - : 'foo' + : 'foo' ; Efun - : 'efun' + : 'efun' ; Ellipsis - : '...' + : '...' ; Else - : 'else' + : 'else' ; If - : 'if' + : 'if' ; Inherit - : 'inherit' + : 'inherit' ; Return - : 'return' + : 'return' ; For - : 'for' + : 'for' ; Foreach - : 'foreach' + : 'foreach' ; In - : 'in' + : 'in' ; Switch - : 'switch' + : 'switch' ; Case - : 'case' + : 'case' ; While - : 'while' + : 'while' ; Do - : 'do' + : 'do' ; Default - : 'default' + : 'default' ; New - : 'new' + : 'new' ; ParseCommand - : 'parse_command' + : 'parse_command' ; Question - : '?' + : '?' ; Range - : '..' + : '..' ; SScanf - : 'sscanf' + : 'sscanf' ; MappingOpen - : '(' (Whitespace|Newline)* '[' + : '(' (Whitespace | Newline)* '[' ; ArrayOpen - : '(' (Whitespace|Newline)* '{' + : '(' (Whitespace | Newline)* '{' ; FunctionOpen - : '(' Whitespace* ':' {_input.LA(1) != ':'}? // java + : '(' Whitespace* ':' {_input.LA(1) != ':'}? // java ; Number - : IntegerConstant + : IntegerConstant ; Parameter - : '$' DigitSequence + : '$' DigitSequence ; /* Pre processing */ ComplexDefine - : '#' Whitespace* 'define' (~[\\\r\n] | '\\\\' '\r'? '\n' | '\\'. )* - -> skip + : '#' Whitespace* 'define' (~[\\\r\n] | '\\\\' '\r'? '\n' | '\\' .)* -> skip ; ComplexInclude - : '#' Whitespace* 'include' ~[\r\n]* - -> skip + : '#' Whitespace* 'include' ~[\r\n]* -> skip ; ComplexPreprocessor - : '#' ~[\r\n]* - -> skip + : '#' ~[\r\n]* -> skip ; Real - : FractionalConstant + : FractionalConstant ; -fragment -FractionalConstant - : DigitSequence? '.' DigitSequence +fragment FractionalConstant + : DigitSequence? '.' DigitSequence // | DigitSequence '.' {self._input.LA(1) != ord('.')}? // python - | DigitSequence '.' {_input.LA(1) != '.'}? // java + | DigitSequence '.' {_input.LA(1) != '.'}? // java // | DigitSequence '.' {_input->LA(1) != '.'}? // c++ ; DigitSequence - : Digit+ + : Digit+ ; - Identifier - : IdentifierNondigit - ( IdentifierNondigit - | Digit - )* + : IdentifierNondigit (IdentifierNondigit | Digit)* ; -fragment -IdentifierNondigit - : Nondigit +fragment IdentifierNondigit + : Nondigit //| UniversalCharacterName //| // other implementation-defined characters... ; -fragment -Nondigit - : [a-zA-Z_] +fragment Nondigit + : [a-zA-Z_] ; -fragment -Digit - : [0-9] +fragment Digit + : [0-9] ; -fragment -IntegerConstant - : DecimalConstant IntegerSuffix? - | OctalConstant IntegerSuffix? - | HexadecimalConstant IntegerSuffix? - | BinaryConstant +fragment IntegerConstant + : DecimalConstant IntegerSuffix? + | OctalConstant IntegerSuffix? + | HexadecimalConstant IntegerSuffix? + | BinaryConstant ; -fragment -BinaryConstant - : '0' [bB] [0-1]+ +fragment BinaryConstant + : '0' [bB] [0-1]+ ; -fragment -DecimalConstant - : NonzeroDigit Digit* +fragment DecimalConstant + : NonzeroDigit Digit* ; -fragment -OctalConstant - : '0' OctalDigit* +fragment OctalConstant + : '0' OctalDigit* ; -fragment -HexadecimalConstant - : HexadecimalPrefix HexadecimalDigit+ +fragment HexadecimalConstant + : HexadecimalPrefix HexadecimalDigit+ ; -fragment -HexadecimalPrefix - : '0' [xX] +fragment HexadecimalPrefix + : '0' [xX] ; -fragment -NonzeroDigit - : [1-9] +fragment NonzeroDigit + : [1-9] ; -fragment -OctalDigit - : [0-7] +fragment OctalDigit + : [0-7] ; -fragment -HexadecimalDigit - : [0-9a-fA-F] +fragment HexadecimalDigit + : [0-9a-fA-F] ; -fragment -IntegerSuffix - : UnsignedSuffix LongSuffix? - | UnsignedSuffix LongLongSuffix - | LongSuffix UnsignedSuffix? - | LongLongSuffix UnsignedSuffix? +fragment IntegerSuffix + : UnsignedSuffix LongSuffix? + | UnsignedSuffix LongLongSuffix + | LongSuffix UnsignedSuffix? + | LongLongSuffix UnsignedSuffix? ; -fragment -UnsignedSuffix - : [uU] +fragment UnsignedSuffix + : [uU] ; -fragment -LongSuffix - : [lL] +fragment LongSuffix + : [lL] ; -fragment -LongLongSuffix - : 'll' | 'LL' +fragment LongLongSuffix + : 'll' + | 'LL' ; String - : StringPrefix? '"' SCharSequence? '"' + : StringPrefix? '"' SCharSequence? '"' ; StringPrefix - : '@' + : '@' ; CharacterConstant - : '\'' SingleChar? '\'' + : '\'' SingleChar? '\'' ; -fragment -SCharSequence - : SChar+ +fragment SCharSequence + : SChar+ ; -fragment -SChar - : ~["\\\r\n] // BUG, removed \" from here - | EscapeSequence - | '\\\n' // Added line - | '\\\r\n' // Added line - | '\n' // lpc want this - | '\r\n' // lpc want this, too +fragment SChar + : ~["\\\r\n] // BUG, removed \" from here + | EscapeSequence + | '\\\n' // Added line + | '\\\r\n' // Added line + | '\n' // lpc want this + | '\r\n' // lpc want this, too ; -fragment -SingleChar - : '"' - | SChar +fragment SingleChar + : '"' + | SChar ; -fragment -EscapeSequence - : SimpleEscapeSequence - | OctalEscapeSequence - | HexadecimalEscapeSequence - | UniversalCharacterName +fragment EscapeSequence + : SimpleEscapeSequence + | OctalEscapeSequence + | HexadecimalEscapeSequence + | UniversalCharacterName ; -fragment -UniversalCharacterName - : '\\u' HexQuad - | '\\U' HexQuad HexQuad +fragment UniversalCharacterName + : '\\u' HexQuad + | '\\U' HexQuad HexQuad ; -fragment -HexQuad - : HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit +fragment HexQuad + : HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit ; -fragment -HexadecimalEscapeSequence - : '\\x' HexadecimalDigit+ +fragment HexadecimalEscapeSequence + : '\\x' HexadecimalDigit+ ; -fragment -OctalEscapeSequence - : '\\' OctalDigit - | '\\' OctalDigit OctalDigit - | '\\' OctalDigit OctalDigit OctalDigit +fragment OctalEscapeSequence + : '\\' OctalDigit + | '\\' OctalDigit OctalDigit + | '\\' OctalDigit OctalDigit OctalDigit ; -fragment -SimpleEscapeSequence - : '\\' ['"?abfnrtv\\] - | '\\' [^+.[{}\]!@#$%&*()_=\-|/<>] // WTF: LPC escapes these characters (inface, only warn in lpc) +fragment SimpleEscapeSequence + : '\\' ['"?abfnrtv\\] + | '\\' [^+.[{}\]!@#$%&*()_=\-|/<>] // WTF: LPC escapes these characters (inface, only warn in lpc) ; TimeExpression - : 'time_expression' + : 'time_expression' ; - BlockComment - : '/*' .*? '*/' - -> skip + : '/*' .*? '*/' -> skip ; LineComment - : '//' ~[\r\n]* - -> skip + : '//' ~[\r\n]* -> skip ; Whitespace - : [ \t]+ - -> skip + : [ \t]+ -> skip ; Newline - : ( '\r' '\n'? - | '\n' - ) - -> skip + : ('\r' '\n'? | '\n') -> skip ; - lpc_program - : program EOF + : program EOF ; program - : program defination possible_semi_colon - | /* empty */ + : program defination possible_semi_colon + | /* empty */ ; possible_semi_colon - : /* empty */ - | ';' + : /* empty */ + | ';' ; defination - : function_defination - | data_type name_list ';' - | inheritance - | type_decl - | modifier_change + : function_defination + | data_type name_list ';' + | inheritance + | type_decl + | modifier_change ; function_defination - : data_type optional_star identifier '(' argument ')' block_or_semi + : data_type optional_star identifier '(' argument ')' block_or_semi ; modifier_change - : type_modifier_list ':' + : type_modifier_list ':' ; type_modifier_list - : /* empty */ - | TypeModifier type_modifier_list + : /* empty */ + | TypeModifier type_modifier_list ; type_decl - : type_modifier_list Class identifier '{' member_list '}' + : type_modifier_list Class identifier '{' member_list '}' ; member_list - : /* empty */ - | member_list data_type member_name_list ';' + : /* empty */ + | member_list data_type member_name_list ';' ; member_name_list - : member_name - | member_name ',' member_name_list + : member_name + | member_name ',' member_name_list ; member_name - : optional_star identifier + : optional_star identifier ; name_list - : new_name - | new_name ',' name_list + : new_name + | new_name ',' name_list ; new_name - : optional_star identifier - | optional_star identifier Assign expr0 + : optional_star identifier + | optional_star identifier Assign expr0 ; expr0 - : expr4 Assign expr0 - | expr0 Question expr0 Colon expr0 - | expr0 OrOr expr0 - | expr0 AndAnd expr0 - | expr0 Or expr0 - | expr0 Caret expr0 - | expr0 And expr0 - | expr0 Equal expr0 - | expr0 NotEqual expr0 - | expr0 Compare expr0 - | expr0 '<' expr0 - | expr0 LeftShift expr0 - | expr0 RightShift expr0 - - | expr0 ('*'|'%'|'/') expr0 - | expr0 ('+'|'-') expr0 - - | cast expr0 - | PlusPlus expr4 - | MinusMinus expr4 - | Not expr0 - | '~' expr0 - | '-' expr0 - | expr4 PlusPlus /* normal precedence here */ - | expr4 MinusMinus - | expr4 - | sscanf - | parse_command - | time_expression - | Number - | Real + : expr4 Assign expr0 + | expr0 Question expr0 Colon expr0 + | expr0 OrOr expr0 + | expr0 AndAnd expr0 + | expr0 Or expr0 + | expr0 Caret expr0 + | expr0 And expr0 + | expr0 Equal expr0 + | expr0 NotEqual expr0 + | expr0 Compare expr0 + | expr0 '<' expr0 + | expr0 LeftShift expr0 + | expr0 RightShift expr0 + | expr0 ('*' | '%' | '/') expr0 + | expr0 ('+' | '-') expr0 + | cast expr0 + | PlusPlus expr4 + | MinusMinus expr4 + | Not expr0 + | '~' expr0 + | '-' expr0 + | expr4 PlusPlus /* normal precedence here */ + | expr4 MinusMinus + | expr4 + | sscanf + | parse_command + | time_expression + | Number + | Real ; time_expression - : TimeExpression expr_or_block + : TimeExpression expr_or_block ; expr_or_block - : block - | '(' comma_expr ')' + : block + | '(' comma_expr ')' ; comma_expr - : expr0 - | comma_expr ',' expr0 + : expr0 + | comma_expr ',' expr0 ; parse_command - : ParseCommand '(' expr0 ',' expr0 ',' expr0 lvalue_list ')' + : ParseCommand '(' expr0 ',' expr0 ',' expr0 lvalue_list ')' ; sscanf - : SScanf '(' expr0 ',' expr0 lvalue_list ')' + : SScanf '(' expr0 ',' expr0 lvalue_list ')' ; lvalue_list - : /* empty */ - | ',' expr4 lvalue_list + : /* empty */ + | ',' expr4 lvalue_list ; cast - : '(' basic_type optional_star ')' + : '(' basic_type optional_star ')' ; basic_type - : atomic_type + : atomic_type ; atomic_type - : BasicType - | Class DefinedName + : BasicType + | Class DefinedName ; expr4 - : function_call - | expr4 function_arrow_call - | DefinedName - | Identifier - | Parameter - | '$' '(' comma_expr ')' - | expr4 Arrow identifier - | expr4 '[' comma_expr Range '<' comma_expr ']' - | expr4 '[' comma_expr Range comma_expr ']' - | expr4 '[' '<' comma_expr Range comma_expr ']' - | expr4 '[' '<' comma_expr Range '<' comma_expr ']' - | expr4 '[' comma_expr Range ']' - | expr4 '[' '<' comma_expr Range ']' - | expr4 '[' '<' comma_expr ']' - | expr4 '[' comma_expr ']' - | string - | CharacterConstant - | '(' comma_expr ')' - | catch_statement - | BasicType '(' argument ')' block -// | L_NEW_FUNCTION_OPEN ':' ')' -// | L_NEW_FUNCTION_OPEN ',' expr_list2 ':' ')' - | FunctionOpen comma_expr ':' ')' - | MappingOpen expr_list3 ']' ')' - | ArrayOpen expr_list '}' ')' + : function_call + | expr4 function_arrow_call + | DefinedName + | Identifier + | Parameter + | '$' '(' comma_expr ')' + | expr4 Arrow identifier + | expr4 '[' comma_expr Range '<' comma_expr ']' + | expr4 '[' comma_expr Range comma_expr ']' + | expr4 '[' '<' comma_expr Range comma_expr ']' + | expr4 '[' '<' comma_expr Range '<' comma_expr ']' + | expr4 '[' comma_expr Range ']' + | expr4 '[' '<' comma_expr Range ']' + | expr4 '[' '<' comma_expr ']' + | expr4 '[' comma_expr ']' + | string + | CharacterConstant + | '(' comma_expr ')' + | catch_statement + | BasicType '(' argument ')' block + // | L_NEW_FUNCTION_OPEN ':' ')' + // | L_NEW_FUNCTION_OPEN ',' expr_list2 ':' ')' + | FunctionOpen comma_expr ':' ')' + | MappingOpen expr_list3 ']' ')' + | ArrayOpen expr_list '}' ')' ; catch_statement - : Catch expr_or_block + : Catch expr_or_block ; expr_list - : /* empty */ - | expr_list2 - | expr_list2 ',' + : /* empty */ + | expr_list2 + | expr_list2 ',' ; expr_list3 - : /* empty */ - | expr_list4 - | expr_list4 ',' + : /* empty */ + | expr_list4 + | expr_list4 ',' ; expr_list4 - : assoc_pair - | expr_list4 ',' assoc_pair + : assoc_pair + | expr_list4 ',' assoc_pair ; assoc_pair - : expr0 ':' expr0 + : expr0 ':' expr0 ; expr_list2 - : expr_list_node - | expr_list2 ',' expr_list_node + : expr_list_node + | expr_list2 ',' expr_list_node ; expr_list_node - : expr0 - | expr0 Ellipsis + : expr0 + | expr0 Ellipsis ; string - : string_con2 + : string_con2 ; string_con2 - : String - | string_con2 String + : String + | string_con2 String ; string_con1 - : string_con2 - | '(' string_con1 ')' - | string_con1 '+' string_con1 + : string_con2 + | '(' string_con1 ')' + | string_con1 '+' string_con1 ; // combine into expr4 function_call - : efun_override '(' expr_list ')' - | New '(' expr_list ')' - | New '(' Class DefinedName opt_class_init ')' - | DefinedName '(' expr_list ')' - | function_name_call //function_name '(' expr_list ')' - | function_arrow_call //expr4 Arrow identifier '(' expr_list ')' - | '(' '*' comma_expr ')' '(' expr_list ')' + : efun_override '(' expr_list ')' + | New '(' expr_list ')' + | New '(' Class DefinedName opt_class_init ')' + | DefinedName '(' expr_list ')' + | function_name_call //function_name '(' expr_list ')' + | function_arrow_call //expr4 Arrow identifier '(' expr_list ')' + | '(' '*' comma_expr ')' '(' expr_list ')' ; function_name_call - : function_name '(' expr_list ')' + : function_name '(' expr_list ')' ; function_arrow_call - : Arrow identifier '(' expr_list ')' + : Arrow identifier '(' expr_list ')' ; function_name - : Identifier - | ColonColon identifier - | BasicType ColonColon identifier - | identifier ColonColon identifier + : Identifier + | ColonColon identifier + | BasicType ColonColon identifier + | identifier ColonColon identifier ; opt_class_init - : /* empty */ - | opt_class_init ',' class_init + : /* empty */ + | opt_class_init ',' class_init ; class_init - : identifier ':' expr0 + : identifier ':' expr0 ; efun_override - : Efun ColonColon identifier - | Efun ColonColon New + : Efun ColonColon identifier + | Efun ColonColon New ; block_or_semi - : block - | ';' + : block + | ';' ; block - : '{' statements '}' + : '{' statements '}' ; statements - : /* empty */ - | statement statements - | local_declare_statement statements + : /* empty */ + | statement statements + | local_declare_statement statements ; local_declare_statement - : basic_type local_name_list ';' + : basic_type local_name_list ';' ; local_name_list - : new_local_def - | new_local_def ',' local_name_list + : new_local_def + | new_local_def ',' local_name_list ; new_local_def - : optional_star new_local_name - | optional_star new_local_name Assign expr0 + : optional_star new_local_name + | optional_star new_local_name Assign expr0 ; new_local_name - : Identifier - | DefinedName + : Identifier + | DefinedName ; statement - : comma_expr ';' - | cond - | while_statement - | do_statement - | switch_statement - | returnStatement + : comma_expr ';' + | cond + | while_statement + | do_statement + | switch_statement + | returnStatement // decl_block - | block - | for_loop - | foreach_loop - - | /* empty */ ';' - | Break ';' - | Continue ';' + | block + | for_loop + | foreach_loop + | /* empty */ ';' + | Break ';' + | Continue ';' ; while_statement - : While '(' comma_expr ')' statement + : While '(' comma_expr ')' statement ; do_statement - : Do statement While '(' comma_expr ')' ';' + : Do statement While '(' comma_expr ')' ';' ; switch_statement - : Switch '(' comma_expr ')' '{' local_declarations case_statement switch_block '}' + : Switch '(' comma_expr ')' '{' local_declarations case_statement switch_block '}' ; local_declarations - : /* empty */ - | local_declarations basic_type local_name_list ';' + : /* empty */ + | local_declarations basic_type local_name_list ';' ; case_statement - : Case case_label ':' - | Case case_label Range case_label ':' - | Default ':' + : Case case_label ':' + | Case case_label Range case_label ':' + | Default ':' ; switch_block - : case_statement switch_block - | statement switch_block - | /* empty */ + : case_statement switch_block + | statement switch_block + | /* empty */ ; case_label - : constant - | CharacterConstant - | string_con1 + : constant + | CharacterConstant + | string_con1 ; constant - : constant '|' constant - | constant '^' constant - | constant '&' constant - | constant Equal constant - | constant NotEqual constant - | constant Compare constant - | constant '<' constant - | constant LeftShift constant - | constant RightShift constant - | '(' constant ')' - - | constant '*' constant - | constant '%' constant - | constant '/' constant - - | constant '-' constant - | constant '+' constant - | Number - | '-' Number - | Not Number - | '~' Number + : constant '|' constant + | constant '^' constant + | constant '&' constant + | constant Equal constant + | constant NotEqual constant + | constant Compare constant + | constant '<' constant + | constant LeftShift constant + | constant RightShift constant + | '(' constant ')' + | constant '*' constant + | constant '%' constant + | constant '/' constant + | constant '-' constant + | constant '+' constant + | Number + | '-' Number + | Not Number + | '~' Number ; //decl_block @@ -836,92 +800,92 @@ constant // ; foreach_loop - : Foreach '(' foreach_vars In expr0 ')' statement + : Foreach '(' foreach_vars In expr0 ')' statement ; foreach_vars - : foreach_var - | foreach_var ',' foreach_var + : foreach_var + | foreach_var ',' foreach_var ; for_loop - : For '(' first_for_expr ';' for_expr ';' for_expr ')' statement + : For '(' first_for_expr ';' for_expr ';' for_expr ')' statement ; foreach_var - : DefinedName - | single_new_local_def - | Identifier + : DefinedName + | single_new_local_def + | Identifier ; first_for_expr - : for_expr - | single_new_local_def_with_init + : for_expr + | single_new_local_def_with_init ; single_new_local_def_with_init - : single_new_local_def Assign expr0 + : single_new_local_def Assign expr0 ; single_new_local_def - : basic_type optional_star new_local_name + : basic_type optional_star new_local_name ; for_expr - : /* EMPTY */ - | comma_expr + : /* EMPTY */ + | comma_expr ; returnStatement - : Return ';' - | Return comma_expr ';' + : Return ';' + | Return comma_expr ';' ; cond - : If '(' comma_expr ')' statement optional_else_part + : If '(' comma_expr ')' statement optional_else_part ; optional_else_part - : /* empty */ - | Else statement + : /* empty */ + | Else statement ; argument - : /* empty */ - | argument_list - | argument_list Ellipsis + : /* empty */ + | argument_list + | argument_list Ellipsis ; argument_list - : new_arg - | argument_list ',' new_arg + : new_arg + | argument_list ',' new_arg ; new_arg - : basic_type optional_star - | basic_type optional_star new_local_name - | new_local_name + : basic_type optional_star + | basic_type optional_star new_local_name + | new_local_name ; inheritance - : type_modifier_list Inherit string_con1 ';' + : type_modifier_list Inherit string_con1 ';' ; data_type - : type_modifier_list opt_basic_type + : type_modifier_list opt_basic_type ; opt_basic_type - : basic_type - | /* empty */ + : basic_type + | /* empty */ ; optional_star - : /* empty */ - | '*' + : /* empty */ + | '*' ; identifier - : DefinedName - | Identifier - ; + : DefinedName + | Identifier + ; \ No newline at end of file diff --git a/lrc/lrcLexer.g4 b/lrc/lrcLexer.g4 index 1e51abc8a1..ed52aae114 100644 --- a/lrc/lrcLexer.g4 +++ b/lrc/lrcLexer.g4 @@ -29,34 +29,24 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar lrcLexer; -LB - : '[' - ; +LB: '['; -RB - : ']' -> pushMode (LINETEXT) - ; +RB: ']' -> pushMode (LINETEXT); -TIMESTAMP - : NUM ':' NUM '.' NUM - ; +TIMESTAMP: NUM ':' NUM '.' NUM; -NUM - : [0-9]+ - ; +NUM: [0-9]+; -WS - : [ \r\n\t]+ -> skip - ; +WS: [ \r\n\t]+ -> skip; mode LINETEXT; -TEXT - : ~ [\r\n]+ - ; - -EOL - : [\r\n]+ -> skip , popMode - ; +TEXT: ~ [\r\n]+; +EOL: [\r\n]+ -> skip, popMode; \ No newline at end of file diff --git a/lrc/lrcParser.g4 b/lrc/lrcParser.g4 index ff995f4730..01e6a12f2b 100644 --- a/lrc/lrcParser.g4 +++ b/lrc/lrcParser.g4 @@ -29,13 +29,20 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $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 lrcParser; -options { tokenVocab = lrcLexer; } + +options { + tokenVocab = lrcLexer; +} + lrc - : line* EOF - ; + : line* EOF + ; line - : LB TIMESTAMP RB TEXT - ; - + : LB TIMESTAMP RB TEXT + ; \ No newline at end of file diff --git a/ltl/ltl.g4 b/ltl/ltl.g4 index 51724e8468..63b7b4e727 100644 --- a/ltl/ltl.g4 +++ b/ltl/ltl.g4 @@ -32,69 +32,72 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode - // http://www.eecs.qmul.ac.uk/~pm/SaR/2004ltl.pdf +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ltl; -file_ : proposition EOF ; +file_ + : proposition EOF + ; proposition - : 'true' - | 'false' - | ATOMIC - | '(' proposition ')' - | proposition (LTL_AND | LTL_OR | LTL_RIGHTWARDS_SINGLE_ARROW) proposition - | LTL_NOT proposition - | (LTL_GLOBALLY | LTL_FINALLY | LTL_NEXT) proposition - | proposition (LTL_UNTIL | LTL_WEAK | LTL_RELEASE) proposition - ; + : 'true' + | 'false' + | ATOMIC + | '(' proposition ')' + | proposition (LTL_AND | LTL_OR | LTL_RIGHTWARDS_SINGLE_ARROW) proposition + | LTL_NOT proposition + | (LTL_GLOBALLY | LTL_FINALLY | LTL_NEXT) proposition + | proposition (LTL_UNTIL | LTL_WEAK | LTL_RELEASE) proposition + ; ATOMIC - : [a-z]+ - ; + : [a-z]+ + ; LTL_UNTIL - : 'U' - ; + : 'U' + ; LTL_GLOBALLY - : 'G' - ; + : 'G' + ; LTL_FINALLY - : 'F' - ; + : 'F' + ; LTL_NEXT - : 'X' - ; + : 'X' + ; LTL_WEAK - : 'W' - ; + : 'W' + ; LTL_RELEASE - : 'R' - ; + : 'R' + ; LTL_RIGHTWARDS_SINGLE_ARROW - : '\u2192' - ; + : '\u2192' + ; LTL_AND - : '\u2227' - ; + : '\u2227' + ; LTL_OR - : '\u2228' - ; + : '\u2228' + ; LTL_NOT - : '\u2310' - ; + : '\u2310' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/lua/LuaLexer.g4 b/lua/LuaLexer.g4 index 599fe13136..e1cad6bfd6 100644 --- a/lua/LuaLexer.g4 +++ b/lua/LuaLexer.g4 @@ -1,172 +1,123 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar LuaLexer; -options { superClass = LuaLexerBase; } +options { + superClass = LuaLexerBase; +} // Insert here @header for C++ lexer. -SEMI: ';'; -EQ: '='; - -BREAK: 'break'; -GOTO: 'goto'; -DO: 'do'; -END: 'end'; -WHILE: 'while'; -REPEAT: 'repeat'; -UNTIL: 'until'; -IF: 'if'; -THEN: 'then'; -ELSEIF: 'elseif'; -ELSE: 'else'; -FOR: 'for'; -COMMA: ','; -IN: 'in'; -FUNCTION: 'function'; -LOCAL: 'local'; -LT: '<'; -GT: '>'; -RETURN: 'return'; -CONTINUE: 'continue'; -CC: '::'; -NIL: 'nil'; -FALSE: 'false'; -TRUE: 'true'; -DOT: '.'; -SQUIG: '~'; -MINUS: '-'; -POUND: '#'; -OP: '('; -CP: ')'; -NOT: 'not'; -LL: '<<'; -GG: '>>'; -AMP: '&'; -SS: '//'; -PER: '%'; -COL: ':'; -LE: '<='; -GE: '>='; -AND: 'and'; -OR: 'or'; -PLUS: '+'; -STAR: '*'; -OCU: '{'; -CCU: '}'; -OB: '['; -CB: ']'; -EE: '=='; -DD: '..'; -PIPE: '|'; -CARET: '^'; -SLASH: '/'; -DDD: '...'; -SQEQ: '~='; - - -NAME - : [a-zA-Z_][a-zA-Z_0-9]* - ; - -NORMALSTRING - : '"' ( EscapeSequence | ~('\\'|'"') )* '"' - ; - -CHARSTRING - : '\'' ( EscapeSequence | ~('\''|'\\') )* '\'' - ; - -LONGSTRING - : '[' NESTED_STR ']' - ; - -fragment -NESTED_STR - : '=' NESTED_STR '=' - | '[' .*? ']' - ; - -INT - : Digit+ - ; - -HEX - : '0' [xX] HexDigit+ - ; - -FLOAT - : Digit+ '.' Digit* ExponentPart? - | '.' Digit+ ExponentPart? - | Digit+ ExponentPart - ; - -HEX_FLOAT - : '0' [xX] HexDigit+ '.' HexDigit* HexExponentPart? +SEMI : ';'; +EQ : '='; + +BREAK : 'break'; +GOTO : 'goto'; +DO : 'do'; +END : 'end'; +WHILE : 'while'; +REPEAT : 'repeat'; +UNTIL : 'until'; +IF : 'if'; +THEN : 'then'; +ELSEIF : 'elseif'; +ELSE : 'else'; +FOR : 'for'; +COMMA : ','; +IN : 'in'; +FUNCTION : 'function'; +LOCAL : 'local'; +LT : '<'; +GT : '>'; +RETURN : 'return'; +CONTINUE : 'continue'; +CC : '::'; +NIL : 'nil'; +FALSE : 'false'; +TRUE : 'true'; +DOT : '.'; +SQUIG : '~'; +MINUS : '-'; +POUND : '#'; +OP : '('; +CP : ')'; +NOT : 'not'; +LL : '<<'; +GG : '>>'; +AMP : '&'; +SS : '//'; +PER : '%'; +COL : ':'; +LE : '<='; +GE : '>='; +AND : 'and'; +OR : 'or'; +PLUS : '+'; +STAR : '*'; +OCU : '{'; +CCU : '}'; +OB : '['; +CB : ']'; +EE : '=='; +DD : '..'; +PIPE : '|'; +CARET : '^'; +SLASH : '/'; +DDD : '...'; +SQEQ : '~='; + +NAME: [a-zA-Z_][a-zA-Z_0-9]*; + +NORMALSTRING: '"' ( EscapeSequence | ~('\\' | '"'))* '"'; + +CHARSTRING: '\'' ( EscapeSequence | ~('\'' | '\\'))* '\''; + +LONGSTRING: '[' NESTED_STR ']'; + +fragment NESTED_STR: '=' NESTED_STR '=' | '[' .*? ']'; + +INT: Digit+; + +HEX: '0' [xX] HexDigit+; + +FLOAT: Digit+ '.' Digit* ExponentPart? | '.' Digit+ ExponentPart? | Digit+ ExponentPart; + +HEX_FLOAT: + '0' [xX] HexDigit+ '.' HexDigit* HexExponentPart? | '0' [xX] '.' HexDigit+ HexExponentPart? | '0' [xX] HexDigit+ HexExponentPart - ; +; -fragment -ExponentPart - : [eE] [+-]? Digit+ - ; +fragment ExponentPart: [eE] [+-]? Digit+; -fragment -HexExponentPart - : [pP] [+-]? Digit+ - ; +fragment HexExponentPart: [pP] [+-]? Digit+; -fragment -EscapeSequence - : '\\' [abfnrtvz"'|$#\\] // World of Warcraft Lua additionally escapes |$# +fragment EscapeSequence: + '\\' [abfnrtvz"'|$#\\] // World of Warcraft Lua additionally escapes |$# | '\\' '\r'? '\n' | DecimalEscape | HexEscape | UtfEscape - ; - -fragment -DecimalEscape - : '\\' Digit - | '\\' Digit Digit - | '\\' [0-2] Digit Digit - ; - -fragment -HexEscape - : '\\' 'x' HexDigit HexDigit - ; - -fragment -UtfEscape - : '\\' 'u{' HexDigit+ '}' - ; - -fragment -Digit - : [0-9] - ; - -fragment -HexDigit - : [0-9a-fA-F] - ; - -fragment -SingleLineInputCharacter - : ~[\r\n\u0085\u2028\u2029] - ; - -COMMENT - : '--' { this.HandleComment(); } -> channel(HIDDEN) - ; - -WS - : [ \t\u000C\r]+ -> channel(HIDDEN) - ; +; -NL: [\n] -> channel(2); +fragment DecimalEscape: '\\' Digit | '\\' Digit Digit | '\\' [0-2] Digit Digit; + +fragment HexEscape: '\\' 'x' HexDigit HexDigit; + +fragment UtfEscape: '\\' 'u{' HexDigit+ '}'; + +fragment Digit: [0-9]; -SHEBANG - : '#' { this.IsLine1Col0() }? '!'? SingleLineInputCharacter* -> channel(HIDDEN) - ; +fragment HexDigit: [0-9a-fA-F]; + +fragment SingleLineInputCharacter: ~[\r\n\u0085\u2028\u2029]; + +COMMENT: '--' { this.HandleComment(); } -> channel(HIDDEN); + +WS: [ \t\u000C\r]+ -> channel(HIDDEN); + +NL: [\n] -> channel(2); +SHEBANG: '#' { this.IsLine1Col0() }? '!'? SingleLineInputCharacter* -> channel(HIDDEN); \ No newline at end of file diff --git a/lua/LuaParser.g4 b/lua/LuaParser.g4 index 83f11e577b..dca690fa7a 100644 --- a/lua/LuaParser.g4 +++ b/lua/LuaParser.g4 @@ -8,15 +8,26 @@ Based on previous work of: Kazunori Sakamoto, Alexander Alexeev */ -parser grammar LuaParser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab = LuaLexer; } +parser grammar LuaParser; -start_: chunk EOF; +options { + tokenVocab = LuaLexer; +} -chunk: block ; +start_ + : chunk EOF + ; + +chunk + : block + ; -block: stat* retstat? ; +block + : stat* retstat? + ; stat : ';' @@ -78,11 +89,11 @@ exp | functiondef | prefixexp | tableconstructor - | exp ('^') exp + | exp ('^') exp | ('not' | '#' | '-' | '~') exp | exp ('*' | '/' | '%' | '//') exp | exp ('+' | '-') exp - | exp ('..') exp + | exp ('..') exp | exp ('<' | '>' | '<=' | '>=' | '~=' | '==') exp | exp ('and') exp | exp ('or') exp @@ -97,24 +108,25 @@ var // prefixexp ::= var | functioncall | '(' exp ')' prefixexp - : - NAME ('[' exp ']' | '.' NAME)* + : NAME ('[' exp ']' | '.' NAME)* | functioncall ('[' exp ']' | '.' NAME)* | '(' exp ')' ('[' exp ']' | '.' NAME)* ; // functioncall ::= prefixexp args | prefixexp ':' Name args; -functioncall: - NAME ('[' exp ']' | '.' NAME)* args +functioncall + : NAME ('[' exp ']' | '.' NAME)* args | functioncall ('[' exp ']' | '.' NAME)* args | '(' exp ')' ('[' exp ']' | '.' NAME)* args - | NAME ('[' exp ']' | '.' NAME)* ':' NAME args - | functioncall ('[' exp ']' | '.' NAME)* ':' NAME args - | '(' exp ')' ('[' exp ']' | '.' NAME)* ':' NAME args + | NAME ('[' exp ']' | '.' NAME)* ':' NAME args + | functioncall ('[' exp ']' | '.' NAME)* ':' NAME args + | '(' exp ')' ('[' exp ']' | '.' NAME)* ':' NAME args ; args - : '(' explist? ')' | tableconstructor | string + : '(' explist? ')' + | tableconstructor + | string ; functiondef @@ -144,17 +156,25 @@ fieldlist ; field - : '[' exp ']' '=' exp | NAME '=' exp | exp + : '[' exp ']' '=' exp + | NAME '=' exp + | exp ; fieldsep - : ',' | ';' + : ',' + | ';' ; number - : INT | HEX | FLOAT | HEX_FLOAT + : INT + | HEX + | FLOAT + | HEX_FLOAT ; string - : NORMALSTRING | CHARSTRING | LONGSTRING - ; + : NORMALSTRING + | CHARSTRING + | LONGSTRING + ; \ No newline at end of file diff --git a/lucene/LuceneLexer.g4 b/lucene/LuceneLexer.g4 index ff5dbc81fc..f27b4379fe 100644 --- a/lucene/LuceneLexer.g4 +++ b/lucene/LuceneLexer.g4 @@ -27,194 +27,196 @@ * Project : An ANTLR 4 grammar for Lucene * Developed by : Bart Kiers, bart@big-o.nl */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar LuceneLexer; // https://github.com/apache/lucene/blob/main/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj // -AND : 'AND' | '&&'; +AND: 'AND' | '&&'; // -OR : 'OR' | '||'; +OR: 'OR' | '||'; // -NOT : 'NOT' | '!'; +NOT: 'NOT' | '!'; // : Function -FN_PREFIX : 'fn:' -> mode(F_MODE); +FN_PREFIX: 'fn:' -> mode(F_MODE); // -PLUS : '+'; +PLUS: '+'; // -MINUS : '-'; +MINUS: '-'; // -LPAREN : '('; +LPAREN: '('; // -RPAREN : ')'; +RPAREN: ')'; // -OP_COLON : ':'; +OP_COLON: ':'; // -OP_LESSTHAN : '<'; +OP_LESSTHAN: '<'; // " > -OP_MORETHAN : '>'; +OP_MORETHAN: '>'; // =" > -OP_MORETHANEQ : '>='; +OP_MORETHANEQ: '>='; // -CARAT : '^'; +CARAT: '^'; // -TILDE : '~'; +TILDE: '~'; // )* "\""> -QUOTED : '"' QUOTED_CHAR* '"'; +QUOTED: '"' QUOTED_CHAR* '"'; // )+ ( "." (<_NUM_CHAR>)+ )? > -NUMBER : NUM_CHAR+ ( '.' NUM_CHAR+ )?; +NUMBER: NUM_CHAR+ ( '.' NUM_CHAR+)?; // (<_TERM_CHAR>)* > -TERM : TERM_START_CHAR TERM_CHAR*; +TERM: TERM_START_CHAR TERM_CHAR*; // -REGEXPTERM : '/' ( ~'/' | '\\/' )* '/'; +REGEXPTERM: '/' ( ~'/' | '\\/')* '/'; // : Range -RANGEIN_START : '[' -> mode(R_MODE); +RANGEIN_START: '[' -> mode(R_MODE); // : Range -RANGEEX_START : '{' -> mode(R_MODE); +RANGEEX_START: '{' -> mode(R_MODE); // SKIP : { < <_WHITESPACE> > } -DEFAULT_SKIP : WHITESPACE -> skip; +DEFAULT_SKIP: WHITESPACE -> skip; // Fallthrough rule -UNKNOWN : .; +UNKNOWN: .; // <#_WHITESPACE: ( " " | "\t" | "\n" | "\r" | "\u3000") > -fragment WHITESPACE : [ \t\n\r\u3000]; +fragment WHITESPACE: [ \t\n\r\u3000]; // <#_QUOTED_CHAR: ( ~[ "\"", "\\" ] | <_ESCAPED_CHAR> ) > -fragment QUOTED_CHAR : ~["\\] | ESCAPED_CHAR; +fragment QUOTED_CHAR: ~["\\] | ESCAPED_CHAR; // <#_ESCAPED_CHAR: "\\" ~[] > -fragment ESCAPED_CHAR : '\\' .; +fragment ESCAPED_CHAR: '\\' .; // <#_NUM_CHAR: ["0"-"9"] > -fragment NUM_CHAR : [0-9]; +fragment NUM_CHAR: [0-9]; // <#_TERM_START_CHAR: ( ~[ " ", "\t", "\n", "\r", "\u3000", "+", "-", "!", "(", ")", ":", "^", "@", // "<", ">", "=", "[", "]", "\"", "{", "}", "~", "\\", "/"] // | <_ESCAPED_CHAR> ) > -fragment TERM_START_CHAR - : ~[ \t\n\r\u3000+\-!():^@<>=[\]"{}~\\/] - | ESCAPED_CHAR - ; +fragment TERM_START_CHAR: ~[ \t\n\r\u3000+\-!():^@<>=[\]"{}~\\/] | ESCAPED_CHAR; // <#_TERM_CHAR: ( <_TERM_START_CHAR> | <_ESCAPED_CHAR> | "-" | "+" ) > -fragment TERM_CHAR : ( TERM_START_CHAR | ESCAPED_CHAR | [\-+] ); +fragment TERM_CHAR: ( TERM_START_CHAR | ESCAPED_CHAR | [\-+]); // Function mode mode F_MODE; - // SKIP : { < <_WHITESPACE> > } - F_SKIP : WHITESPACE -> skip; +// SKIP : { < <_WHITESPACE> > } +F_SKIP: WHITESPACE -> skip; - // : DEFAULT - F_LPAREN : '(' -> type(LPAREN), mode(DEFAULT_MODE); +// : DEFAULT +F_LPAREN: '(' -> type(LPAREN), mode(DEFAULT_MODE); - // - ATLEAST : 'atleast' | 'atLeast'; +// +ATLEAST: 'atleast' | 'atLeast'; - // - AFTER : 'after'; +// +AFTER: 'after'; - // - BEFORE : 'before'; +// +BEFORE: 'before'; - // - CONTAINED_BY : 'containedBy' | 'containedby'; +// +CONTAINED_BY: 'containedBy' | 'containedby'; - // - CONTAINING : 'containing'; +// +CONTAINING: 'containing'; - // - EXTEND : 'extend'; +// +EXTEND: 'extend'; - // - FN_OR : 'or'; +// +FN_OR: 'or'; - // - FUZZYTERM : 'fuzzyterm' | 'fuzzyTerm'; +// +FUZZYTERM: 'fuzzyterm' | 'fuzzyTerm'; - // - MAXGAPS : 'maxgaps' | 'maxGaps'; +// +MAXGAPS: 'maxgaps' | 'maxGaps'; - // - MAXWIDTH : 'maxwidth' | 'maxWidth'; +// +MAXWIDTH: 'maxwidth' | 'maxWidth'; - // - NON_OVERLAPPING : 'nonOverlapping' | 'nonoverlapping'; +// +NON_OVERLAPPING: 'nonOverlapping' | 'nonoverlapping'; - // - NOT_CONTAINED_BY : 'notContainedBy' | 'notcontainedby'; +// +NOT_CONTAINED_BY: 'notContainedBy' | 'notcontainedby'; - // - NOT_CONTAINING : 'notContaining' | 'notcontaining'; +// +NOT_CONTAINING: 'notContaining' | 'notcontaining'; - // - NOT_WITHIN : 'notWithin' | 'notwithin'; +// +NOT_WITHIN: 'notWithin' | 'notwithin'; - // - ORDERED : 'ordered'; +// +ORDERED: 'ordered'; - // - OVERLAPPING : 'overlapping'; +// +OVERLAPPING: 'overlapping'; - // - PHRASE : 'phrase'; +// +PHRASE: 'phrase'; - // - UNORDERED : 'unordered'; +// +UNORDERED: 'unordered'; - // - UNORDERED_NO_OVERLAPS : 'unorderedNoOverlaps' | 'unorderednooverlaps'; +// +UNORDERED_NO_OVERLAPS: 'unorderedNoOverlaps' | 'unorderednooverlaps'; - // - WILDCARD : 'wildcard'; +// +WILDCARD: 'wildcard'; - // - WITHIN : 'within'; +// +WITHIN: 'within'; // Range mode mode R_MODE; - // SKIP : { < <_WHITESPACE> > } - R_SKIP : WHITESPACE -> skip; +// SKIP : { < <_WHITESPACE> > } +R_SKIP: WHITESPACE -> skip; - // - RANGE_TO : 'TO'; +// +RANGE_TO: 'TO'; - // : DEFAULT - RANGEIN_END : ']' -> mode(DEFAULT_MODE); +// : DEFAULT +RANGEIN_END: ']' -> mode(DEFAULT_MODE); - // : DEFAULT - RANGEEX_END : '}' -> mode(DEFAULT_MODE); +// : DEFAULT +RANGEEX_END: '}' -> mode(DEFAULT_MODE); - // - RANGE_QUOTED : '"' ( ~'"' | '\\"' )+ '"'; +// +RANGE_QUOTED: '"' ( ~'"' | '\\"')+ '"'; - // - RANGE_GOOP : ~[ \]}]+; +// +RANGE_GOOP: ~[ \]}]+; \ No newline at end of file diff --git a/lucene/LuceneParser.g4 b/lucene/LuceneParser.g4 index 150d761191..b32d28a344 100644 --- a/lucene/LuceneParser.g4 +++ b/lucene/LuceneParser.g4 @@ -27,78 +27,88 @@ * Project : An ANTLR 4 grammar for Lucene * Developed by : Bart Kiers, bart@big-o.nl */ + +// $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 LuceneParser; -options { tokenVocab=LuceneLexer; } +options { + tokenVocab = LuceneLexer; +} // https://github.com/apache/lucene/blob/main/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj // TopLevelQuery ::= Query topLevelQuery - : query EOF - ; + : query EOF + ; // Query ::= DisjQuery ( DisjQuery )* query - : disjQuery+ - ; + : disjQuery+ + ; // DisjQuery ::= ConjQuery ( OR ConjQuery )* disjQuery - : conjQuery ( OR conjQuery )* - ; + : conjQuery (OR conjQuery)* + ; // ConjQuery ::= ModClause ( AND ModClause )* conjQuery - : modClause ( AND modClause )* - ; + : modClause (AND modClause)* + ; // ModClause ::= (Modifier)? Clause modClause - : modifier? clause - ; + : modifier? clause + ; // | ( | ) modifier - : PLUS - | MINUS - | NOT - ; + : PLUS + | MINUS + | NOT + ; // Clause ::= FieldRangeExpr // | (FieldName (':' | '='))? (Term | GroupingExpr) clause - : fieldRangeExpr - | ( fieldName ( OP_COLON | OP_EQUAL ) )? ( term | groupingExpr ) - ; + : fieldRangeExpr + | ( fieldName ( OP_COLON | OP_EQUAL))? ( term | groupingExpr) + ; // FieldRangeExpr ::= FieldName ('<' | '>' | '<=' | '>=') ( | | ) fieldRangeExpr - : fieldName ( OP_LESSTHAN | OP_MORETHAN | OP_LESSTHANEQ | OP_MORETHANEQ ) ( TERM | QUOTED | NUMBER ) - ; + : fieldName (OP_LESSTHAN | OP_MORETHAN | OP_LESSTHANEQ | OP_MORETHANEQ) ( + TERM + | QUOTED + | NUMBER + ) + ; // Term ::= ( | ) ('~' )? ('^' )? // | ('^' )? // | TermRangeExpr ('^' )? // | QuotedTerm ('^' )? term - : term fuzzy ( CARAT NUMBER )? - | REGEXPTERM ( CARAT NUMBER )? - | termRangeExpr ( CARAT NUMBER )? - | quotedTerm ( CARAT NUMBER )? - | NUMBER ( CARAT NUMBER )? - | TERM ( CARAT NUMBER )? - ; + : term fuzzy (CARAT NUMBER)? + | REGEXPTERM ( CARAT NUMBER)? + | termRangeExpr ( CARAT NUMBER)? + | quotedTerm ( CARAT NUMBER)? + | NUMBER ( CARAT NUMBER)? + | TERM ( CARAT NUMBER)? + ; // GroupingExpr ::= '(' Query ')' ('^' )? groupingExpr - : LPAREN query RPAREN ( CARAT NUMBER )? - ; + : LPAREN query RPAREN (CARAT NUMBER)? + ; // fieldName - : TERM - ; + : TERM + ; // ( | ) // ( | | ) { left = token; } @@ -106,19 +116,19 @@ fieldName // ( | | ) { right = token; } // ( | ) termRangeExpr - : ( RANGEIN_START | RANGEEX_START ) - left=( RANGE_GOOP | RANGE_QUOTED | RANGE_TO ) - RANGE_TO - right=( RANGE_GOOP | RANGE_QUOTED | RANGE_TO ) - ( RANGEIN_END | RANGEEX_END ) - ; + : (RANGEIN_START | RANGEEX_START) left = (RANGE_GOOP | RANGE_QUOTED | RANGE_TO) RANGE_TO right = ( + RANGE_GOOP + | RANGE_QUOTED + | RANGE_TO + ) (RANGEIN_END | RANGEEX_END) + ; // QuotedTerm ::= ('~' )? quotedTerm - : QUOTED ( CARAT NUMBER )? - ; + : QUOTED (CARAT NUMBER)? + ; // Fuzzy ::= '~' ? fuzzy - : TILDE NUMBER? - ; \ No newline at end of file + : TILDE NUMBER? + ; \ No newline at end of file diff --git a/matlab/matlab.g4 b/matlab/matlab.g4 index d3a079f79a..68c0902b11 100644 --- a/matlab/matlab.g4 +++ b/matlab/matlab.g4 @@ -31,345 +31,322 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * http://www.angelfire.com/ar/CompiladoresUCSE/images/MATLAB.zip */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar matlab; -file_ : statement_list? EOF; +file_ + : statement_list? EOF + ; primary_expression - : IDENTIFIER - | CONSTANT - | STRING_LITERAL - | '(' expression ')' - | '[' ']' - | '[' array_list ']' - ; + : IDENTIFIER + | CONSTANT + | STRING_LITERAL + | '(' expression ')' + | '[' ']' + | '[' array_list ']' + ; postfix_expression - : primary_expression - | array_expression - | postfix_expression TRANSPOSE - | postfix_expression NCTRANSPOSE - ; + : primary_expression + | array_expression + | postfix_expression TRANSPOSE + | postfix_expression NCTRANSPOSE + ; index_expression - : ':' - | expression - ; + : ':' + | expression + ; index_expression_list - : index_expression - | index_expression_list ',' index_expression - ; + : index_expression + | index_expression_list ',' index_expression + ; array_expression - : IDENTIFIER '(' index_expression_list ')' - ; + : IDENTIFIER '(' index_expression_list ')' + ; unary_expression - : postfix_expression - | unary_operator postfix_expression - ; + : postfix_expression + | unary_operator postfix_expression + ; unary_operator - : '+' - | '-' - | '~' - ; + : '+' + | '-' + | '~' + ; multiplicative_expression - : unary_expression - | multiplicative_expression '*' unary_expression - | multiplicative_expression '/' unary_expression - | multiplicative_expression '\\' unary_expression - | multiplicative_expression '^' unary_expression - | multiplicative_expression ARRAYMUL unary_expression - | multiplicative_expression ARRAYDIV unary_expression - | multiplicative_expression ARRAYRDIV unary_expression - | multiplicative_expression ARRAYPOW unary_expression - ; + : unary_expression + | multiplicative_expression '*' unary_expression + | multiplicative_expression '/' unary_expression + | multiplicative_expression '\\' unary_expression + | multiplicative_expression '^' unary_expression + | multiplicative_expression ARRAYMUL unary_expression + | multiplicative_expression ARRAYDIV unary_expression + | multiplicative_expression ARRAYRDIV unary_expression + | multiplicative_expression ARRAYPOW unary_expression + ; additive_expression - : multiplicative_expression - | additive_expression '+' multiplicative_expression - | additive_expression '-' multiplicative_expression - ; + : multiplicative_expression + | additive_expression '+' multiplicative_expression + | additive_expression '-' multiplicative_expression + ; relational_expression - : additive_expression - | relational_expression '<' additive_expression - | relational_expression '>' additive_expression - | relational_expression LE_OP additive_expression - | relational_expression GE_OP additive_expression - ; + : additive_expression + | relational_expression '<' additive_expression + | relational_expression '>' additive_expression + | relational_expression LE_OP additive_expression + | relational_expression GE_OP additive_expression + ; equality_expression - : relational_expression - | equality_expression EQ_OP relational_expression - | equality_expression NE_OP relational_expression - ; + : relational_expression + | equality_expression EQ_OP relational_expression + | equality_expression NE_OP relational_expression + ; and_expression - : equality_expression - | and_expression '&' equality_expression - ; + : equality_expression + | and_expression '&' equality_expression + ; or_expression - : and_expression - | or_expression '|' and_expression - ; + : and_expression + | or_expression '|' and_expression + ; expression - : or_expression - | expression ':' or_expression - ; + : or_expression + | expression ':' or_expression + ; assignment_expression - : postfix_expression '=' expression - ; + : postfix_expression '=' expression + ; eostmt - : ',' - | ';' - | CR - ; + : ',' + | ';' + | CR + ; statement - : global_statement - | clear_statement - | assignment_statement - | expression_statement - | selection_statement - | iteration_statement - | jump_statement - ; + : global_statement + | clear_statement + | assignment_statement + | expression_statement + | selection_statement + | iteration_statement + | jump_statement + ; statement_list - : statement - | statement_list statement - ; + : statement + | statement_list statement + ; identifier_list - : IDENTIFIER - | identifier_list IDENTIFIER - ; + : IDENTIFIER + | identifier_list IDENTIFIER + ; global_statement - : GLOBAL identifier_list eostmt - ; + : GLOBAL identifier_list eostmt + ; clear_statement - : CLEAR identifier_list eostmt - ; + : CLEAR identifier_list eostmt + ; expression_statement - : eostmt - | expression eostmt - ; + : eostmt + | expression eostmt + ; assignment_statement - : assignment_expression eostmt - ; + : assignment_expression eostmt + ; array_element - : expression - | expression_statement - ; + : expression + | expression_statement + ; array_list - : array_element - | array_list array_element - ; + : array_element + | array_list array_element + ; selection_statement - : IF expression statement_list END eostmt - | IF expression statement_list ELSE statement_list END eostmt - | IF expression statement_list elseif_clause END eostmt - | IF expression statement_list elseif_clause ELSE statement_list END eostmt - ; + : IF expression statement_list END eostmt + | IF expression statement_list ELSE statement_list END eostmt + | IF expression statement_list elseif_clause END eostmt + | IF expression statement_list elseif_clause ELSE statement_list END eostmt + ; elseif_clause - : ELSEIF expression statement_list - | elseif_clause ELSEIF expression statement_list - ; + : ELSEIF expression statement_list + | elseif_clause ELSEIF expression statement_list + ; iteration_statement - : WHILE expression statement_list END eostmt - | FOR IDENTIFIER '=' expression statement_list END eostmt - | FOR '(' IDENTIFIER '=' expression ')' statement_list END eostmt - ; + : WHILE expression statement_list END eostmt + | FOR IDENTIFIER '=' expression statement_list END eostmt + | FOR '(' IDENTIFIER '=' expression ')' statement_list END eostmt + ; jump_statement - : BREAK eostmt - | RETURN eostmt - ; + : BREAK eostmt + | RETURN eostmt + ; translation_unit - : statement_list - | FUNCTION function_declare eostmt statement_list - ; + : statement_list + | FUNCTION function_declare eostmt statement_list + ; func_ident_list - : IDENTIFIER - | func_ident_list ',' IDENTIFIER - ; + : IDENTIFIER + | func_ident_list ',' IDENTIFIER + ; func_return_list - : IDENTIFIER - | '[' func_ident_list ']' - ; + : IDENTIFIER + | '[' func_ident_list ']' + ; function_declare_lhs - : IDENTIFIER - | IDENTIFIER '(' ')' - | IDENTIFIER '(' func_ident_list ')' - ; + : IDENTIFIER + | IDENTIFIER '(' ')' + | IDENTIFIER '(' func_ident_list ')' + ; function_declare - : function_declare_lhs - | func_return_list '=' function_declare_lhs - ; - + : function_declare_lhs + | func_return_list '=' function_declare_lhs + ; ARRAYMUL - : '.*' - ; - + : '.*' + ; ARRAYDIV - : '.\\' - ; - + : '.\\' + ; ARRAYRDIV - : './' - ; - + : './' + ; ARRAYPOW - : '.^' - ; - + : '.^' + ; BREAK - : 'break' - ; - + : 'break' + ; RETURN - : 'return' - ; - + : 'return' + ; FUNCTION - : 'function' - ; - + : 'function' + ; FOR - : 'for' - ; - + : 'for' + ; WHILE - : 'while' - ; - + : 'while' + ; END - : 'end' - ; - + : 'end' + ; GLOBAL - : 'global' - ; - + : 'global' + ; IF - : 'if' - ; - + : 'if' + ; CLEAR - : 'clear' - ; - + : 'clear' + ; ELSE - : 'else' - ; - + : 'else' + ; ELSEIF - : 'elseif' - ; - + : 'elseif' + ; LE_OP - : '<=' - ; - + : '<=' + ; GE_OP - : '>=' - ; - + : '>=' + ; EQ_OP - : '==' - ; - + : '==' + ; NE_OP - : '~=' - ; - + : '~=' + ; TRANSPOSE - : 'transpose' - ; - + : 'transpose' + ; NCTRANSPOSE - : '.\'' - ; - + : '.\'' + ; STRING_LITERAL - : '\'' ( ~ '\'' | '\'\'' ) * '\'' - ; - + : '\'' (~ '\'' | '\'\'')* '\'' + ; IDENTIFIER - : [a-zA-Z] [a-zA-Z0-9_]* - ; - + : [a-zA-Z] [a-zA-Z0-9_]* + ; CONSTANT - : NUMBER (E SIGN? NUMBER)? - ; - + : NUMBER (E SIGN? NUMBER)? + ; fragment NUMBER - : ('0' .. '9') + ('.' ('0' .. '9') +)? - ; - + : ('0' .. '9')+ ('.' ('0' .. '9')+)? + ; fragment E - : 'E' | 'e' - ; - + : 'E' + | 'e' + ; fragment SIGN - : ('+' | '-') - ; - + : ('+' | '-') + ; CR - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : [ \t] + -> skip - ; + : [ \t]+ -> skip + ; \ No newline at end of file diff --git a/mckeeman-form/McKeemanForm.g4 b/mckeeman-form/McKeemanForm.g4 index 1a4d5453b9..175242cd0a 100644 --- a/mckeeman-form/McKeemanForm.g4 +++ b/mckeeman-form/McKeemanForm.g4 @@ -1,5 +1,8 @@ // https://www.crockford.com/mckeeman.html +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar McKeemanForm; grammar_ @@ -67,4 +70,4 @@ exclude String : '"' .*? '"' - ; + ; \ No newline at end of file diff --git a/mdx/mdx.g4 b/mdx/mdx.g4 index 1cdd5fbdc0..cedf47dcdf 100644 --- a/mdx/mdx.g4 +++ b/mdx/mdx.g4 @@ -1,489 +1,443 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging grammar mdx; mdx_statement - : (select_statement) EOF - ; + : (select_statement) EOF + ; select_statement - : (WITH formula_specification)? SELECT axis_specification_list? FROM cube_specification (WHERE slicer_specification)? cell_props? - ; + : (WITH formula_specification)? SELECT axis_specification_list? FROM cube_specification ( + WHERE slicer_specification + )? cell_props? + ; formula_specification - : single_formula_specification + - ; + : single_formula_specification+ + ; single_formula_specification - : member_specification - | set_specification - ; + : member_specification + | set_specification + ; set_specification - : SET set_name AS (QUOTE expression QUOTE | expression) - ; + : SET set_name AS (QUOTE expression QUOTE | expression) + ; member_specification - : MEMBER member_name AS ((QUOTE value_expression QUOTE | value_expression) COMMA member_property_def_list?) - ; + : MEMBER member_name AS ( + (QUOTE value_expression QUOTE | value_expression) COMMA member_property_def_list? + ) + ; axis_specification_list - : axis_specification (COMMA axis_specification)* - ; + : axis_specification (COMMA axis_specification)* + ; member_property_def_list - : member_property_definition (COMMA member_property_definition)* - ; + : member_property_definition (COMMA member_property_definition)* + ; member_name - : compound_id - ; + : compound_id + ; member_property_definition - : identifier EQ value_expression - ; + : identifier EQ value_expression + ; set_name - : compound_id - ; + : compound_id + ; compound_id - : identifier (DOT identifier)* - ; + : identifier (DOT identifier)* + ; axis_specification - : (NON EMPTY)? expression dim_props? ON axis_name - ; + : (NON EMPTY)? expression dim_props? ON axis_name + ; axis_name - : identifier - ; + : identifier + ; dim_props - : DIMENSION? PROPERTIES property_list - ; + : DIMENSION? PROPERTIES property_list + ; property_list - : property_ (COMMA property_)* - ; + : property_ (COMMA property_)* + ; property_ - : compound_id - ; + : compound_id + ; cube_specification - : cube_name - ; + : cube_name + ; cube_name - : compound_id - ; + : compound_id + ; slicer_specification - : expression - ; + : expression + ; cell_props - : CELL? PROPERTIES cell_property_list - ; + : CELL? PROPERTIES cell_property_list + ; cell_property_list - : cell_property (COMMA cell_property)* - ; + : cell_property (COMMA cell_property)* + ; cell_property - : mandatory_cell_property - | provider_specific_cell_property - ; + : mandatory_cell_property + | provider_specific_cell_property + ; mandatory_cell_property - : CELL_ORDINAL - | VALUE - | FORMATTED_VALUE - ; + : CELL_ORDINAL + | VALUE + | FORMATTED_VALUE + ; provider_specific_cell_property - : identifier - ; + : identifier + ; expression - : value_expression (COLON value_expression)* - ; + : value_expression (COLON value_expression)* + ; value_expression - : term5 (value_xor_expression | value_or_expression)* - ; + : term5 (value_xor_expression | value_or_expression)* + ; value_xor_expression - : XOR term5 - ; + : XOR term5 + ; value_or_expression - : OR term5 - ; + : OR term5 + ; term5 - : term4 (AND term4)* - ; + : term4 (AND term4)* + ; term4 - : NOT term4 - | term3 - ; + : NOT term4 + | term3 + ; term3 - : term2 (comp_op term2)* - ; + : term2 (comp_op term2)* + ; term2 - : term ((CONCAT | PLUS | MINUS) term)* - ; + : term ((CONCAT | PLUS | MINUS) term)* + ; term - : factor ((SOLIDUS | ASTERISK) factor)* - ; + : factor ((SOLIDUS | ASTERISK) factor)* + ; factor - : MINUS value_expression_primary - | PLUS value_expression_primary - | value_expression_primary - ; + : MINUS value_expression_primary + | PLUS value_expression_primary + | value_expression_primary + ; function_ - : identifier LPAREN (exp_list)? RPAREN - ; + : identifier LPAREN (exp_list)? RPAREN + ; value_expression_primary - : value_expression_primary0 (DOT (unquoted_identifier | quoted_identifier | amp_quoted_identifier | function_))* - ; + : value_expression_primary0 ( + DOT (unquoted_identifier | quoted_identifier | amp_quoted_identifier | function_) + )* + ; value_expression_primary0 - : function_ - | (LPAREN exp_list RPAREN) - | (LBRACE (exp_list)? RBRACE) - | case_expression - | STRING - | NUMBER - | identifier - ; + : function_ + | (LPAREN exp_list RPAREN) + | (LBRACE (exp_list)? RBRACE) + | case_expression + | STRING + | NUMBER + | identifier + ; exp_list - : expression (COMMA expression)* - ; + : expression (COMMA expression)* + ; case_expression - : CASE (value_expression)? (when_list)? (ELSE value_expression)? END - ; + : CASE (value_expression)? (when_list)? (ELSE value_expression)? END + ; when_list - : when_clause (when_clause)* - ; + : when_clause (when_clause)* + ; when_clause - : WHEN value_expression THEN value_expression - ; + : WHEN value_expression THEN value_expression + ; comp_op - : EQ - | NE - | LT - | GT - | LE - | GE - ; + : EQ + | NE + | LT + | GT + | LE + | GE + ; identifier - : (unquoted_identifier | quoted_identifier) - ; + : (unquoted_identifier | quoted_identifier) + ; unquoted_identifier - : keyword - | ID - ; + : keyword + | ID + ; amp_quoted_identifier - : AMP_QUOTED_ID - ; + : AMP_QUOTED_ID + ; quoted_identifier - : QUOTED_ID - ; + : QUOTED_ID + ; keyword - : DIMENSION - | PROPERTIES - ; - + : DIMENSION + | PROPERTIES + ; QUOTE - : '\'' - ; - + : '\'' + ; ASTERISK - : '*' - ; - + : '*' + ; COLON - : ':' - ; - + : ':' + ; SEMICOLON - : ';' - ; - + : ';' + ; COMMA - : ',' - ; - + : ',' + ; CONCAT - : '||' - ; - + : '||' + ; DOT - : '.' - ; - + : '.' + ; EQ - : '=' - ; - + : '=' + ; GE - : '>=' - ; - + : '>=' + ; GT - : '>' - ; - + : '>' + ; LBRACE - : '{' - ; - + : '{' + ; LE - : '<=' - ; - + : '<=' + ; LPAREN - : '(' - ; - + : '(' + ; LT - : '<' - ; - + : '<' + ; MINUS - : '-' - ; - + : '-' + ; NE - : '<>' - ; - + : '<>' + ; PLUS - : '+' - ; - + : '+' + ; RBRACE - : '}' - ; - + : '}' + ; RPAREN - : ')' - ; - + : ')' + ; SOLIDUS - : '/' - ; - + : '/' + ; AND - : 'AND' - ; - + : 'AND' + ; AS - : 'AS' - ; - + : 'AS' + ; CASE - : 'CASE' - ; - + : 'CASE' + ; CELL - : 'CELL' - ; - + : 'CELL' + ; CELL_ORDINAL - : 'CELL_ORDINAL' - ; - + : 'CELL_ORDINAL' + ; CREATE - : 'CREATE' - ; - + : 'CREATE' + ; DIMENSION - : 'DIMENSION' - ; - + : 'DIMENSION' + ; ELSE - : 'ELSE' - ; - + : 'ELSE' + ; EMPTY - : 'EMPTY' - ; - + : 'EMPTY' + ; END - : 'END' - ; - + : 'END' + ; FORMATTED_VALUE - : 'FORMATTED_VALUE' - ; - + : 'FORMATTED_VALUE' + ; FROM - : 'FROM' - ; - + : 'FROM' + ; GLOBAL - : 'GLOBAL' - ; - + : 'GLOBAL' + ; MEMBER - : 'MEMBER' - ; - + : 'MEMBER' + ; NON - : 'NON' - ; - + : 'NON' + ; NOT - : 'NOT' - ; - + : 'NOT' + ; ON - : 'ON' - ; - + : 'ON' + ; OR - : 'OR' - ; - + : 'OR' + ; PROPERTIES - : 'PROPERTIES' - ; - + : 'PROPERTIES' + ; SELECT - : 'SELECT' - ; - + : 'SELECT' + ; SESSION - : 'SESSION' - ; - + : 'SESSION' + ; SET - : 'SET' - ; - + : 'SET' + ; THEN - : 'THEN' - ; - + : 'THEN' + ; VALUE - : 'VALUE' - ; - + : 'VALUE' + ; WHEN - : 'WHEN' - ; - + : 'WHEN' + ; WHERE - : 'WHERE' - ; - + : 'WHERE' + ; XOR - : 'XOR' - ; - + : 'XOR' + ; WITH - : 'WITH' - ; - + : 'WITH' + ; NUMBER - : ('0' .. '9') + - ; - + : ('0' .. '9')+ + ; F - : '0' .. '9' + '.' '0' .. '9'* - ; - + : '0' .. '9'+ '.' '0' .. '9'* + ; ID - : ('a' .. 'z' | 'A' .. 'Z' | '_' | '$') ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '$')* - ; - + : ('a' .. 'z' | 'A' .. 'Z' | '_' | '$') ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '$')* + ; AMP_QUOTED_ID - : '[&' (ID ((' ' | '\t') + ID)* | NUMBER) ']' - ; - + : '[&' (ID ((' ' | '\t')+ ID)* | NUMBER) ']' + ; QUOTED_ID - : ('[' (ID ((' ' | '\t') + ID)* | NUMBER) ']') - ; - + : ('[' (ID ((' ' | '\t')+ ID)* | NUMBER) ']') + ; STRING - : '"' (~ '"')* '"' | '\'' (~ '\'')* '\'' - ; - + : '"' (~ '"')* '"' + | '\'' (~ '\'')* '\'' + ; WS - : (' ' | '\t' | '\r' | '\f' | '\n') + -> skip - ; + : (' ' | '\t' | '\r' | '\f' | '\n')+ -> skip + ; \ No newline at end of file diff --git a/memcached_protocol/memcached_protocol.g4 b/memcached_protocol/memcached_protocol.g4 index b42ff3cebe..485bd76a5a 100644 --- a/memcached_protocol/memcached_protocol.g4 +++ b/memcached_protocol/memcached_protocol.g4 @@ -13,206 +13,215 @@ The memcached protocol is now described here: https://github.com/memcached/memcached/blob/master/doc/protocol.txt */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar memcached_protocol; command_line - : (storage_command | retrieval_command | delete_command | increment_command | decrement_command | statistics_command | flush_command | version_command | verbosity_command | quit_command)+ EOF - ; + : ( + storage_command + | retrieval_command + | delete_command + | increment_command + | decrement_command + | statistics_command + | flush_command + | version_command + | verbosity_command + | quit_command + )+ EOF + ; storage_command - : ((storage_command_name key flags exptime bytes) | ('cas' key flags exptime bytes cas_unique)) noreply? - ; + : ((storage_command_name key flags exptime bytes) | ('cas' key flags exptime bytes cas_unique)) noreply? + ; storage_command_name - : 'set' - | 'add' - | 'replace' - | 'append' - | 'prepend' - ; + : 'set' + | 'add' + | 'replace' + | 'append' + | 'prepend' + ; retrieval_command - : ('get' | 'gets') key + - ; + : ('get' | 'gets') key+ + ; delete_command - : 'delete' key time? noreply? - ; + : 'delete' key time? noreply? + ; increment_command - : 'incr' key value noreply? - ; + : 'incr' key value noreply? + ; decrement_command - : 'decr' key value noreply? - ; + : 'decr' key value noreply? + ; statistics_command - : 'stats' statistics_option? - ; + : 'stats' statistics_option? + ; statistics_option - : 'items' - | 'slabs' - | 'sizes' - ; + : 'items' + | 'slabs' + | 'sizes' + ; flush_command - : 'flush_all' delay? noreply? - ; + : 'flush_all' delay? noreply? + ; version_command - : 'version' - ; + : 'version' + ; verbosity_command - : 'verbosity' verbosity_level - ; + : 'verbosity' verbosity_level + ; quit_command - : 'quit' - ; + : 'quit' + ; storage_response - : error_response - | 'STORED' - | 'NOT_STORED' - | 'EXISTS' - | 'NOT_FOUND' - ; + : error_response + | 'STORED' + | 'NOT_STORED' + | 'EXISTS' + | 'NOT_FOUND' + ; retrieval_response - : error_response - | ('VALUE' key flags bytes cas_unique?) - | end - ; + : error_response + | ('VALUE' key flags bytes cas_unique?) + | end + ; deletion_response - : error_response - | 'DELETED' - | 'NOT_FOUND' - ; + : error_response + | 'DELETED' + | 'NOT_FOUND' + ; incr_or_decr_response - : error_response - | 'NOT_FOUND' - | INTEGER - ; + : error_response + | 'NOT_FOUND' + | INTEGER + ; statistics_response - : error_response - | general_statistic - | size_statistic - | end - ; + : error_response + | general_statistic + | size_statistic + | end + ; error_response - : general_error - | client_error_message - | server_error_message - ; + : general_error + | client_error_message + | server_error_message + ; general_statistic - : 'STAT' statistic_name statistic_value - ; + : 'STAT' statistic_name statistic_value + ; size_statistic - : size count - ; + : size count + ; general_error - : 'ERROR' - ; + : 'ERROR' + ; client_error_message - : 'CLIENT_ERROR' .+? - ; + : 'CLIENT_ERROR' .+? + ; server_error_message - : 'SERVER_ERROR' .+? - ; + : 'SERVER_ERROR' .+? + ; end - : 'END' - ; + : 'END' + ; noreply - : 'noreply' - ; + : 'noreply' + ; key - : . - ; + : . + ; flags - : INTEGER - ; + : INTEGER + ; exptime - : INTEGER - ; + : INTEGER + ; bytes - : INTEGER - ; + : INTEGER + ; cas_unique - : INTEGER - ; + : INTEGER + ; value - : INTEGER - ; + : INTEGER + ; time - : INTEGER - ; + : INTEGER + ; delay - : INTEGER - ; + : INTEGER + ; verbosity_level - : INTEGER - ; + : INTEGER + ; statistic_name - : WORD - ; + : WORD + ; statistic_value - : . - ; + : . + ; size - : INTEGER - ; + : INTEGER + ; count - : INTEGER - ; - + : INTEGER + ; INTEGER - : DIGIT + - ; - + : DIGIT+ + ; WORD - : PRINTABLE_CHAR + - ; - + : PRINTABLE_CHAR+ + ; fragment DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; fragment PRINTABLE_CHAR - : '!' .. '~' - ; - + : '!' .. '~' + ; WHITESPACE - : (' ' | '\t' | '\r' | '\n' | '\u000C') + -> skip - ; + : (' ' | '\t' | '\r' | '\n' | '\u000C')+ -> skip + ; \ No newline at end of file diff --git a/metamath/metamath.g4 b/metamath/metamath.g4 index 84e68ffa64..e212a202bb 100644 --- a/metamath/metamath.g4 +++ b/metamath/metamath.g4 @@ -29,138 +29,142 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar metamath; database - : outermostscopestmt* EOF - ; + : outermostscopestmt* EOF + ; outermostscopestmt - : includestmt - | constantstmt - | stmt - ; + : includestmt + | constantstmt + | stmt + ; includestmt - : '$[' filename '$]' - ; + : '$[' filename '$]' + ; constantstmt - : '$c' constant+ '$.' - ; + : '$c' constant+ '$.' + ; stmt - : block - | variablestmt - | disjointstmt - | hypothesisstmt - | assertstmt - ; + : block + | variablestmt + | disjointstmt + | hypothesisstmt + | assertstmt + ; block - : '${' stmt* '$}' - ; + : '${' stmt* '$}' + ; variablestmt - : '$v' variable+ '$.' - ; + : '$v' variable+ '$.' + ; disjointstmt - : '$d' variable variable variable* '$.' - ; + : '$d' variable variable variable* '$.' + ; hypothesisstmt - : floatingstmt - | essentialstmt - ; + : floatingstmt + | essentialstmt + ; floatingstmt - : LABEL '$f' typecode variable '$.' - ; + : LABEL '$f' typecode variable '$.' + ; essentialstmt - : LABEL '$e' typecode mathsymbol* '$.' - ; + : LABEL '$e' typecode mathsymbol* '$.' + ; assertstmt - : axiomstmt - | provablestmt - ; + : axiomstmt + | provablestmt + ; axiomstmt - : LABEL '$a' typecode mathsymbol* '$.' - ; + : LABEL '$a' typecode mathsymbol* '$.' + ; provablestmt - : LABEL '$p' typecode mathsymbol* '$=' proof '$.' - ; + : LABEL '$p' typecode mathsymbol* '$=' proof '$.' + ; proof - : uncompressedproof - | compressedproof - ; + : uncompressedproof + | compressedproof + ; uncompressedproof - : (LABEL | '?')+ - ; + : (LABEL | '?')+ + ; compressedproof - : '(' LABEL* ')' COMPRESSEDPROOFBLOCK+ - ; + : '(' LABEL* ')' COMPRESSEDPROOFBLOCK+ + ; typecode - : constant - ; + : constant + ; mathsymbol - : (printablecharacter | LPAREN | RPAREN)+ - ; + : (printablecharacter | LPAREN | RPAREN)+ + ; printablecharacter - : PRINTABLECHARACTER | LABEL - ; + : PRINTABLECHARACTER + | LABEL + ; filename - : mathsymbol - ; + : mathsymbol + ; constant - : mathsymbol - ; + : mathsymbol + ; variable - : mathsymbol - ; + : mathsymbol + ; LPAREN - : '(' - ; + : '(' + ; RPAREN - : ')' - ; + : ')' + ; LABEL - : (LETTERORDIGIT | '.' | '-' | '_')+ - ; + : (LETTERORDIGIT | '.' | '-' | '_')+ + ; PRINTABLECHARACTER - : [\u0021-\u007e]+ - ; + : [\u0021-\u007e]+ + ; fragment LETTERORDIGIT - : [A-Za-z0-9] - ; + : [A-Za-z0-9] + ; COMPRESSEDPROOFBLOCK - : ([A-Z] | '?')+ - ; + : ([A-Z] | '?')+ + ; BLOCK_COMMENT - : '$(' .*? '$)' -> skip - ; + : '$(' .*? '$)' -> skip + ; WS - : [ \r\n\t\f]+ -> skip - ; - + : [ \r\n\t\f]+ -> skip + ; \ No newline at end of file diff --git a/metric/metric.g4 b/metric/metric.g4 index be4c62e541..df7c26165c 100644 --- a/metric/metric.g4 +++ b/metric/metric.g4 @@ -29,88 +29,93 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar metric; -file_ : uom EOF ; +file_ + : uom EOF + ; uom - : measure (('*' | '/') measure)* - ; + : measure (('*' | '/') measure)* + ; measure - : prefix_? unit exponent? - ; + : prefix_? unit exponent? + ; exponent - : ('^' INTE) - ; + : ('^' INTE) + ; prefix_ - : 'E' - | 'P' - | 'T' - | 'G' - | 'M' - | 'k' - | 'h' - | 'da' - | 'd' - | 'c' - | 'm' - | 'µ' - | 'n' - | 'p' - | 'f' - | 'a' - ; + : 'E' + | 'P' + | 'T' + | 'G' + | 'M' + | 'k' + | 'h' + | 'da' + | 'd' + | 'c' + | 'm' + | 'µ' + | 'n' + | 'p' + | 'f' + | 'a' + ; unit - : baseunit - | derivedunit - ; + : baseunit + | derivedunit + ; baseunit - : 'm' - | 'g' - | 's' - | 'A' - | 'K' - | 'mol' - | 'cd' - ; + : 'm' + | 'g' + | 's' + | 'A' + | 'K' + | 'mol' + | 'cd' + ; derivedunit - : 'rad' - | 'Hz' - | 'sr' - | 'rad' - | 'N' - | 'Pa' - | 'J' - | 'W' - | 'C' - | 'V' - | 'F' - | 'Ω' - | 'S' - | 'Wb' - | 'rad' - | 'T' - | 'H' - | '˚C' - | 'lm' - | 'lx' - | 'Bq' - | 'Gy' - | 'Sv' - | 'kat' - ; + : 'rad' + | 'Hz' + | 'sr' + | 'rad' + | 'N' + | 'Pa' + | 'J' + | 'W' + | 'C' + | 'V' + | 'F' + | 'Ω' + | 'S' + | 'Wb' + | 'rad' + | 'T' + | 'H' + | '˚C' + | 'lm' + | 'lx' + | 'Bq' + | 'Gy' + | 'Sv' + | 'kat' + ; INTE - : [0-9]+ - ; + : [0-9]+ + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/microc/microc.g4 b/microc/microc.g4 index 2f445d6b58..2d81e21dc8 100644 --- a/microc/microc.g4 +++ b/microc/microc.g4 @@ -29,78 +29,81 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar microc; program - : statement+ EOF - ; + : statement+ EOF + ; statement - : ifstatement - | whilestatement - | blockstatement - | exprstatement - ; + : ifstatement + | whilestatement + | blockstatement + | exprstatement + ; ifstatement - : 'if' paren_expr statement ('else' statement)? - ; + : 'if' paren_expr statement ('else' statement)? + ; whilestatement - : 'while' paren_expr statement - ; + : 'while' paren_expr statement + ; blockstatement - : '{' statement* '}' - ; + : '{' statement* '}' + ; exprstatement - : expr ';' - ; + : expr ';' + ; paren_expr - : '(' expr ')' - ; + : '(' expr ')' + ; expr - : test - | id_ '=' expr - ; + : test + | id_ '=' expr + ; test - : sum_ - | sum_ '<' sum_ - ; + : sum_ + | sum_ '<' sum_ + ; sum_ - : term - | sum_ '+' term - | sum_ '-' term - ; + : term + | sum_ '+' term + | sum_ '-' term + ; term - : id_ - | integer - | paren_expr - ; + : id_ + | integer + | paren_expr + ; id_ - : STRING - ; + : STRING + ; integer - : INT - ; + : INT + ; STRING - : [a-z]+ - ; + : [a-z]+ + ; INT - : [0-9]+ - ; + : [0-9]+ + ; WS - : [ \r\n\t] -> skip - ; - + : [ \r\n\t] -> skip + ; \ No newline at end of file diff --git a/modelica/modelica.g4 b/modelica/modelica.g4 index 7d8b525f21..59dc4b8b50 100644 --- a/modelica/modelica.g4 +++ b/modelica/modelica.g4 @@ -24,412 +24,478 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar modelica; stored_definition - : ('within' (name)? ';')* (('final')? class_definition ';')* EOF - ; + : ('within' (name)? ';')* (('final')? class_definition ';')* EOF + ; class_definition - : ('encapsulated')? class_prefixes class_specifier - ; + : ('encapsulated')? class_prefixes class_specifier + ; class_specifier - : long_class_specifier - | short_class_specifier - | der_class_specifier - ; + : long_class_specifier + | short_class_specifier + | der_class_specifier + ; class_prefixes - : ('partial')? ('class' | 'model' | ('operator')? 'record' | 'block' | ('expandable')? 'connector' | 'type' | 'package' | (('pure' | 'impure'))? ('operator')? 'function' | 'operator') - ; + : ('partial')? ( + 'class' + | 'model' + | ('operator')? 'record' + | 'block' + | ('expandable')? 'connector' + | 'type' + | 'package' + | (('pure' | 'impure'))? ('operator')? 'function' + | 'operator' + ) + ; long_class_specifier - : IDENT string_comment composition 'end' IDENT - | 'extends' IDENT (class_modification)? string_comment composition 'end' IDENT - ; + : IDENT string_comment composition 'end' IDENT + | 'extends' IDENT (class_modification)? string_comment composition 'end' IDENT + ; short_class_specifier - : IDENT '=' base_prefix name (array_subscripts)? (class_modification)? comment - | IDENT '=' 'enumeration' '(' ((enum_list)? | ':') ')' comment - ; + : IDENT '=' base_prefix name (array_subscripts)? (class_modification)? comment + | IDENT '=' 'enumeration' '(' ((enum_list)? | ':') ')' comment + ; der_class_specifier - : IDENT '=' 'der' '(' name ',' IDENT (',' IDENT)* ')' comment - ; + : IDENT '=' 'der' '(' name ',' IDENT (',' IDENT)* ')' comment + ; base_prefix - : type_prefix - ; + : type_prefix + ; enum_list - : enumeration_literal (',' enumeration_literal)* - ; + : enumeration_literal (',' enumeration_literal)* + ; enumeration_literal - : IDENT comment - ; + : IDENT comment + ; composition - : element_list ('public' element_list | 'protected' element_list | equation_section | algorithm_section)* ('external' (language_specification)? (external_function_call)? (annotation)? ';')? (annotation ';')? - ; + : element_list ( + 'public' element_list + | 'protected' element_list + | equation_section + | algorithm_section + )* ('external' (language_specification)? (external_function_call)? (annotation)? ';')? ( + annotation ';' + )? + ; language_specification - : STRING - ; + : STRING + ; external_function_call - : (component_reference '=')? IDENT '(' (expression_list)? ')' - ; + : (component_reference '=')? IDENT '(' (expression_list)? ')' + ; element_list - : (element ';')* - ; + : (element ';')* + ; element - : import_clause - | extends_clause - | ('redeclare')? ('final')? ('inner')? ('outer')? ((class_definition | component_clause) | 'replaceable' (class_definition | component_clause) (constraining_clause comment)?) - ; + : import_clause + | extends_clause + | ('redeclare')? ('final')? ('inner')? ('outer')? ( + (class_definition | component_clause) + | 'replaceable' (class_definition | component_clause) (constraining_clause comment)? + ) + ; import_clause - : 'import' (IDENT '=' name | name '.*' | name '.{' import_list '}' | name ) comment - ; + : 'import' (IDENT '=' name | name '.*' | name '.{' import_list '}' | name) comment + ; import_list - : IDENT (',' IDENT)* - ; + : IDENT (',' IDENT)* + ; extends_clause - : 'extends' name (class_modification)? (annotation)? - ; + : 'extends' name (class_modification)? (annotation)? + ; constraining_clause - : 'constrainedby' name (class_modification)? - ; + : 'constrainedby' name (class_modification)? + ; component_clause - : type_prefix type_specifier (array_subscripts)? component_list - ; + : type_prefix type_specifier (array_subscripts)? component_list + ; type_prefix - : ('flow' | 'stream')? ('discrete' | 'parameter' | 'constant')? ('input' | 'output')? - ; + : ('flow' | 'stream')? ('discrete' | 'parameter' | 'constant')? ('input' | 'output')? + ; type_specifier - : name - ; + : name + ; component_list - : component_declaration (',' component_declaration)* - ; + : component_declaration (',' component_declaration)* + ; component_declaration - : declaration (condition_attribute)? comment - ; + : declaration (condition_attribute)? comment + ; condition_attribute - : 'if' expression - ; + : 'if' expression + ; declaration - : IDENT (array_subscripts)? (modification)? - ; + : IDENT (array_subscripts)? (modification)? + ; modification - : class_modification ('=' expression)? - | '=' expression - | ':=' expression - ; + : class_modification ('=' expression)? + | '=' expression + | ':=' expression + ; class_modification - : '(' (argument_list)? ')' - ; + : '(' (argument_list)? ')' + ; argument_list - : argument (',' argument)* - ; + : argument (',' argument)* + ; argument - : element_modification_or_replaceable - | element_redeclaration - ; + : element_modification_or_replaceable + | element_redeclaration + ; element_modification_or_replaceable - : ('each')? ('final')? (element_modification | element_replaceable) - ; + : ('each')? ('final')? (element_modification | element_replaceable) + ; element_modification - : name (modification)? string_comment - ; + : name (modification)? string_comment + ; element_redeclaration - : 'redeclare' ('each')? ('final')? ((short_class_definition | component_clause1) | element_replaceable) - ; + : 'redeclare' ('each')? ('final')? ( + (short_class_definition | component_clause1) + | element_replaceable + ) + ; element_replaceable - : 'replaceable' (short_class_definition | component_clause1) (constraining_clause)? - ; + : 'replaceable' (short_class_definition | component_clause1) (constraining_clause)? + ; component_clause1 - : type_prefix type_specifier component_declaration1 - ; + : type_prefix type_specifier component_declaration1 + ; component_declaration1 - : declaration comment - ; + : declaration comment + ; short_class_definition - : class_prefixes short_class_specifier - ; + : class_prefixes short_class_specifier + ; equation_section - : ('initial')? 'equation' (equation ';')* - ; + : ('initial')? 'equation' (equation ';')* + ; algorithm_section - : ('initial')? 'algorithm' (statement ';')* - ; + : ('initial')? 'algorithm' (statement ';')* + ; equation - : (simple_expression '=' expression | if_equation | for_equation | connect_clause | when_equation | name function_call_args) comment - ; + : ( + simple_expression '=' expression + | if_equation + | for_equation + | connect_clause + | when_equation + | name function_call_args + ) comment + ; statement - : (component_reference (':=' expression | function_call_args) | '(' output_expression_list ')' ':=' component_reference function_call_args | 'break' | 'return' | if_statement | for_statement | while_statement | when_statement) comment - ; + : ( + component_reference (':=' expression | function_call_args) + | '(' output_expression_list ')' ':=' component_reference function_call_args + | 'break' + | 'return' + | if_statement + | for_statement + | while_statement + | when_statement + ) comment + ; if_equation - : 'if' expression 'then' (equation ';')* ('elseif' expression 'then' (equation ';')*)* ('else' (equation ';')*)? 'end' 'if' - ; + : 'if' expression 'then' (equation ';')* ('elseif' expression 'then' (equation ';')*)* ( + 'else' (equation ';')* + )? 'end' 'if' + ; if_statement - : 'if' expression 'then' (statement ';')* ('elseif' expression 'then' (statement ';')*)* ('else' (statement ';')*)? 'end' 'if' - ; + : 'if' expression 'then' (statement ';')* ('elseif' expression 'then' (statement ';')*)* ( + 'else' (statement ';')* + )? 'end' 'if' + ; for_equation - : 'for' for_indices 'loop' (equation ';')* 'end' 'for' - ; + : 'for' for_indices 'loop' (equation ';')* 'end' 'for' + ; for_statement - : 'for' for_indices 'loop' (statement ';')* 'end' 'for' - ; + : 'for' for_indices 'loop' (statement ';')* 'end' 'for' + ; for_indices - : for_index (',' for_index)* - ; + : for_index (',' for_index)* + ; for_index - : IDENT ('in' expression)? - ; + : IDENT ('in' expression)? + ; while_statement - : 'while' expression 'loop' (statement ';')* 'end' 'while' - ; + : 'while' expression 'loop' (statement ';')* 'end' 'while' + ; when_equation - : 'when' expression 'then' (equation ';')* ('elsewhen' expression 'then' (equation ';')*)* 'end' 'when' - ; + : 'when' expression 'then' (equation ';')* ('elsewhen' expression 'then' (equation ';')*)* 'end' 'when' + ; when_statement - : 'when' expression 'then' (statement ';')* ('elsewhen' expression 'then' (statement ';')*)* 'end' 'when' - ; + : 'when' expression 'then' (statement ';')* ('elsewhen' expression 'then' (statement ';')*)* 'end' 'when' + ; connect_clause - : 'connect' '(' component_reference ',' component_reference ')' - ; + : 'connect' '(' component_reference ',' component_reference ')' + ; expression - : simple_expression - | 'if' expression 'then' expression ('elseif' expression 'then' expression)* 'else' expression - ; + : simple_expression + | 'if' expression 'then' expression ('elseif' expression 'then' expression)* 'else' expression + ; simple_expression - : logical_expression (':' logical_expression (':' logical_expression)?)? - ; + : logical_expression (':' logical_expression (':' logical_expression)?)? + ; logical_expression - : logical_term ('or' logical_term)* - ; + : logical_term ('or' logical_term)* + ; logical_term - : logical_factor ('and' logical_factor)* - ; + : logical_factor ('and' logical_factor)* + ; logical_factor - : ('not')? relation - ; + : ('not')? relation + ; relation - : arithmetic_expression (rel_op arithmetic_expression)? - ; + : arithmetic_expression (rel_op arithmetic_expression)? + ; rel_op - : '<' - | '<=' - | '>' - | '>=' - | '==' - | '<>' - ; + : '<' + | '<=' + | '>' + | '>=' + | '==' + | '<>' + ; arithmetic_expression - : (add_op)? term (add_op term)* - ; + : (add_op)? term (add_op term)* + ; add_op - : '+' - | '-' - | '.+' - | '.-' - ; + : '+' + | '-' + | '.+' + | '.-' + ; term - : factor (mul_op factor)* - ; + : factor (mul_op factor)* + ; mul_op - : '*' - | '/' - | '.*' - | './' - ; + : '*' + | '/' + | '.*' + | './' + ; factor - : primary (('^' | '.^') primary)? - ; + : primary (('^' | '.^') primary)? + ; primary - : UNSIGNED_NUMBER - | STRING - | 'false' - | 'true' - | (name | 'der' | 'initial') function_call_args - | component_reference - | '(' output_expression_list ')' - | '[' expression_list (';' expression_list)* ']' - | '{' function_arguments '}' - | 'end' - ; + : UNSIGNED_NUMBER + | STRING + | 'false' + | 'true' + | (name | 'der' | 'initial') function_call_args + | component_reference + | '(' output_expression_list ')' + | '[' expression_list (';' expression_list)* ']' + | '{' function_arguments '}' + | 'end' + ; name - : ('.')? IDENT ('.' IDENT)* - ; + : ('.')? IDENT ('.' IDENT)* + ; component_reference - : ('.')? IDENT (array_subscripts)? ('.' IDENT (array_subscripts)?)* - ; + : ('.')? IDENT (array_subscripts)? ('.' IDENT (array_subscripts)?)* + ; function_call_args - : '(' (function_arguments)? ')' - ; + : '(' (function_arguments)? ')' + ; function_arguments - : function_argument (',' function_arguments | 'for' for_indices)? - | named_arguments - ; + : function_argument (',' function_arguments | 'for' for_indices)? + | named_arguments + ; named_arguments - : named_argument (',' named_arguments)? - ; + : named_argument (',' named_arguments)? + ; named_argument - : IDENT '=' function_argument - ; + : IDENT '=' function_argument + ; function_argument - : 'function' name '(' (named_arguments)? ')' - | expression - ; + : 'function' name '(' (named_arguments)? ')' + | expression + ; output_expression_list - : (expression)? (',' (expression)?)* - ; + : (expression)? (',' (expression)?)* + ; expression_list - : expression (',' expression)* - ; + : expression (',' expression)* + ; array_subscripts - : '[' subscript_ (',' subscript_)* ']' - ; + : '[' subscript_ (',' subscript_)* ']' + ; subscript_ - : ':' - | expression - ; + : ':' + | expression + ; comment - : string_comment (annotation)? - ; + : string_comment (annotation)? + ; string_comment - : (STRING ('+' STRING)*)? - ; + : (STRING ('+' STRING)*)? + ; annotation - : 'annotation' class_modification - ; - + : 'annotation' class_modification + ; IDENT - : NONDIGIT (DIGIT | NONDIGIT)* | Q_IDENT - ; - + : NONDIGIT (DIGIT | NONDIGIT)* + | Q_IDENT + ; fragment Q_IDENT - : '\'' (Q_CHAR | S_ESCAPE) (Q_CHAR | S_ESCAPE)* '\'' - ; - + : '\'' (Q_CHAR | S_ESCAPE) (Q_CHAR | S_ESCAPE)* '\'' + ; fragment S_CHAR - : ~ ["\\] - ; - + : ~ ["\\] + ; fragment NONDIGIT - : '_' | 'a' .. 'z' | 'A' .. 'Z' - ; - + : '_' + | 'a' .. 'z' + | 'A' .. 'Z' + ; STRING - : '"' ( S_CHAR | S_ESCAPE )* '"' - ; - + : '"' (S_CHAR | S_ESCAPE)* '"' + ; fragment Q_CHAR - : NONDIGIT | DIGIT | '!' | '#' | '$' | '%' | '&' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '>' | '=' | '?' | '@' | '[' | ']' | '^' | '{' | '}' | '|' | '~' - ; - + : NONDIGIT + | DIGIT + | '!' + | '#' + | '$' + | '%' + | '&' + | '(' + | ')' + | '*' + | '+' + | ',' + | '-' + | '.' + | '/' + | ':' + | ';' + | '<' + | '>' + | '=' + | '?' + | '@' + | '[' + | ']' + | '^' + | '{' + | '}' + | '|' + | '~' + ; fragment S_ESCAPE - : '\\' ('’' | '\'' | '"' | '?' | '\\' | 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v') - ; - + : '\\' ('’' | '\'' | '"' | '?' | '\\' | 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v') + ; fragment DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; fragment UNSIGNED_INTEGER - : DIGIT (DIGIT)* - ; - + : DIGIT (DIGIT)* + ; UNSIGNED_NUMBER - : UNSIGNED_INTEGER ('.' (UNSIGNED_INTEGER)?)? (('e' | 'E') ('+' | '-')? UNSIGNED_INTEGER)? - ; - + : UNSIGNED_INTEGER ('.' (UNSIGNED_INTEGER)?)? (('e' | 'E') ('+' | '-')? UNSIGNED_INTEGER)? + ; WS - : [ \r\n\t] + -> channel (HIDDEN) - ; + : [ \r\n\t]+ -> channel (HIDDEN) + ; COMMENT - : '/*' .*? '*/' -> channel (HIDDEN) + : '/*' .*? '*/' -> channel (HIDDEN) ; LINE_COMMENT - : '//' ~[\r\n]* -> channel (HIDDEN) - ; + : '//' ~[\r\n]* -> channel (HIDDEN) + ; \ No newline at end of file diff --git a/modula2pim4/m2pim4.g4 b/modula2pim4/m2pim4.g4 index e0694f17a1..0fc7a53585 100644 --- a/modula2pim4/m2pim4.g4 +++ b/modula2pim4/m2pim4.g4 @@ -29,599 +29,611 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Adapted from m2pim4_LL1.g by Benjamin Kowarsch */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar m2pim4; ident - : IDENT - ; + : IDENT + ; number - : INTEGER - | REAL - ; + : INTEGER + | REAL + ; integer - : INTEGER - ; + : INTEGER + ; real - : REAL - ; + : REAL + ; scaleFactor - : SCALE_FACTOR - ; + : SCALE_FACTOR + ; hexDigit - : HEX_DIGIT - ; + : HEX_DIGIT + ; digit - : DIGIT - ; + : DIGIT + ; octalDigit - : OCTAL_DIGIT - ; + : OCTAL_DIGIT + ; string - : STRING - ; + : STRING + ; qualident - : ident ('.' ident)* - ; + : ident ('.' ident)* + ; constantDeclaration - : ident '=' constExpression - ; + : ident '=' constExpression + ; constExpression - : simpleConstExpr (relation simpleConstExpr)? - ; + : simpleConstExpr (relation simpleConstExpr)? + ; relation - : '=' - | '#' - | '<>' - | '<' - | '<=' - | '>' - | '>=' - | 'IN' { } - ; + : '=' + | '#' + | '<>' + | '<' + | '<=' + | '>' + | '>=' + | 'IN' { } + ; simpleConstExpr - : ('+' | '-' { })? constTerm (addOperator constTerm)* - ; + : ('+' | '-' { })? constTerm (addOperator constTerm)* + ; addOperator - : '+' - | '-' - | OR - ; + : '+' + | '-' + | OR + ; constTerm - : constFactor (mulOperator constFactor)* - ; + : constFactor (mulOperator constFactor)* + ; mulOperator - : '*' - | '/' - | DIV - | MOD - | AND - | '&' - ; + : '*' + | '/' + | DIV + | MOD + | AND + | '&' + ; constFactor - : number - | string - | setOrQualident - | '(' constExpression ')' - | (NOT | '~' { }) constFactor - ; + : number + | string + | setOrQualident + | '(' constExpression ')' + | (NOT | '~' { }) constFactor + ; setOrQualident - : set_ - | qualident set_? - ; + : set_ + | qualident set_? + ; set_ - : '{' (element (',' element)*)? '}' - ; + : '{' (element (',' element)*)? '}' + ; element - : constExpression ('..' constExpression)? - ; + : constExpression ('..' constExpression)? + ; typeDeclaration - : ident '=' type_ - ; + : ident '=' type_ + ; type_ - : simpleType - | arrayType - | recordType - | setType - | pointerType - | procedureType - ; + : simpleType + | arrayType + | recordType + | setType + | pointerType + | procedureType + ; simpleType - : qualident - | enumeration - | subrangeType - ; + : qualident + | enumeration + | subrangeType + ; enumeration - : '(' identList ')' - ; + : '(' identList ')' + ; identList - : ident (',' ident)* - ; + : ident (',' ident)* + ; subrangeType - : '[' constExpression '..' constExpression ']' - ; + : '[' constExpression '..' constExpression ']' + ; arrayType - : ARRAY simpleType (',' simpleType)* OF type_ - ; + : ARRAY simpleType (',' simpleType)* OF type_ + ; recordType - : RECORD fieldListSequence END - ; + : RECORD fieldListSequence END + ; fieldListSequence - : fieldList (';' fieldList)* - ; + : fieldList (';' fieldList)* + ; fieldList - : (identList ':' type_ | CASE ident ((':' | '.' { }) qualident)? OF variant ('|' variant)* (ELSE fieldListSequence)? END)? - ; + : ( + identList ':' type_ + | CASE ident ((':' | '.' { }) qualident)? OF variant ('|' variant)* ( + ELSE fieldListSequence + )? END + )? + ; variant - : caseLabelList ':' fieldListSequence - ; + : caseLabelList ':' fieldListSequence + ; caseLabelList - : caseLabels (',' caseLabels)* - ; + : caseLabels (',' caseLabels)* + ; caseLabels - : constExpression ('..' constExpression)? - ; + : constExpression ('..' constExpression)? + ; setType - : SET OF simpleType - ; + : SET OF simpleType + ; pointerType - : POINTER TO type_ - ; + : POINTER TO type_ + ; procedureType - : PROCEDURE formalTypeList? - ; + : PROCEDURE formalTypeList? + ; formalTypeList - : '(' (VAR? formalType (',' VAR? formalType)*)? ')' (':' qualident)? - ; + : '(' (VAR? formalType (',' VAR? formalType)*)? ')' (':' qualident)? + ; variableDeclaration - : identList ':' type_ - ; + : identList ':' type_ + ; designator - : qualident (designatorTail)? - ; + : qualident (designatorTail)? + ; designatorTail - : (('[' expList ']' | '^') ('.' ident)*) + - ; + : (('[' expList ']' | '^') ('.' ident)*)+ + ; expList - : expression (',' expression)* - ; + : expression (',' expression)* + ; expression - : simpleExpression (relation simpleExpression)? - ; + : simpleExpression (relation simpleExpression)? + ; simpleExpression - : ('+' | '-' { })? term (addOperator term)* - ; + : ('+' | '-' { })? term (addOperator term)* + ; term - : factor (mulOperator factor)* - ; + : factor (mulOperator factor)* + ; factor - : number - | string - | setOrDesignatorOrProcCall - | '(' expression ')' - | (NOT | '~' { }) factor - ; + : number + | string + | setOrDesignatorOrProcCall + | '(' expression ')' + | (NOT | '~' { }) factor + ; setOrDesignatorOrProcCall - : set_ - | qualident (set_ | designatorTail? actualParameters?) - ; + : set_ + | qualident (set_ | designatorTail? actualParameters?) + ; actualParameters - : '(' expList? ')' - ; + : '(' expList? ')' + ; statement - : (assignmentOrProcCall | ifStatement | caseStatement | whileStatement | repeatStatement | loopStatement | forStatement | withStatement | EXIT | RETURN expression?)? - ; + : ( + assignmentOrProcCall + | ifStatement + | caseStatement + | whileStatement + | repeatStatement + | loopStatement + | forStatement + | withStatement + | EXIT + | RETURN expression? + )? + ; assignmentOrProcCall - : designator (':=' expression | actualParameters?) - ; + : designator (':=' expression | actualParameters?) + ; statementSequence - : statement (';' statement)* - ; + : statement (';' statement)* + ; ifStatement - : IF expression THEN statementSequence (ELSIF expression THEN statementSequence)* (ELSE statementSequence)? END - ; + : IF expression THEN statementSequence (ELSIF expression THEN statementSequence)* ( + ELSE statementSequence + )? END + ; caseStatement - : CASE expression OF ccase ('|' ccase)* (ELSE statementSequence)? END - ; + : CASE expression OF ccase ('|' ccase)* (ELSE statementSequence)? END + ; ccase - : caseLabelList ':' statementSequence - ; + : caseLabelList ':' statementSequence + ; whileStatement - : WHILE expression DO statementSequence END - ; + : WHILE expression DO statementSequence END + ; repeatStatement - : REPEAT statementSequence UNTIL expression - ; + : REPEAT statementSequence UNTIL expression + ; forStatement - : FOR ident ':=' expression TO expression (BY constExpression)? DO statementSequence END - ; + : FOR ident ':=' expression TO expression (BY constExpression)? DO statementSequence END + ; loopStatement - : LOOP statementSequence END - ; + : LOOP statementSequence END + ; withStatement - : WITH designator DO statementSequence END - ; + : WITH designator DO statementSequence END + ; procedureDeclaration - : procedureHeading ';' block ident - ; + : procedureHeading ';' block ident + ; procedureHeading - : PROCEDURE ident formalParameters? - ; + : PROCEDURE ident formalParameters? + ; block - : declaration* (BEGIN statementSequence)? END - ; + : declaration* (BEGIN statementSequence)? END + ; declaration - : CONST (constantDeclaration ';')* - | TYPE (typeDeclaration ';')* - | VAR (variableDeclaration ';')* - | procedureDeclaration ';' - | moduleDeclaration ';' - ; + : CONST (constantDeclaration ';')* + | TYPE (typeDeclaration ';')* + | VAR (variableDeclaration ';')* + | procedureDeclaration ';' + | moduleDeclaration ';' + ; formalParameters - : '(' (fpSection (';' fpSection)*)? ')' (':' qualident)? - ; + : '(' (fpSection (';' fpSection)*)? ')' (':' qualident)? + ; fpSection - : VAR? identList ':' formalType - ; + : VAR? identList ':' formalType + ; formalType - : (ARRAY OF)? qualident - ; + : (ARRAY OF)? qualident + ; moduleDeclaration - : MODULE ident priority? ';' importList* exportList? block ident - ; + : MODULE ident priority? ';' importList* exportList? block ident + ; priority - : '[' constExpression ']' - ; + : '[' constExpression ']' + ; exportList - : EXPORT QUALIFIED? identList ';' - ; + : EXPORT QUALIFIED? identList ';' + ; importList - : (FROM ident)? IMPORT identList ';' - ; + : (FROM ident)? IMPORT identList ';' + ; definitionModule - : DEFINITION MODULE ident ';' importList* exportList? definition* END ident '.' - ; + : DEFINITION MODULE ident ';' importList* exportList? definition* END ident '.' + ; definition - : CONST (constantDeclaration ';')* - | TYPE (ident ('=' type_)? ';')* - | VAR (variableDeclaration ';')* - | procedureHeading ';' - ; + : CONST (constantDeclaration ';')* + | TYPE (ident ('=' type_)? ';')* + | VAR (variableDeclaration ';')* + | procedureHeading ';' + ; programModule - : MODULE ident priority? ';' importList* block ident '.' - ; + : MODULE ident priority? ';' importList* block ident '.' + ; compilationUnit - : ( definitionModule | IMPLEMENTATION? programModule ) EOF - ; - + : (definitionModule | IMPLEMENTATION? programModule) EOF + ; AND - : 'AND' - ; - + : 'AND' + ; ARRAY - : 'ARRAY' - ; - + : 'ARRAY' + ; BEGIN - : 'BEGIN' - ; - + : 'BEGIN' + ; BY - : 'BY' - ; - + : 'BY' + ; CASE - : 'CASE' - ; - + : 'CASE' + ; CONST - : 'CONST' - ; - + : 'CONST' + ; DEFINITION - : 'DEFINITION' - ; - + : 'DEFINITION' + ; DIV - : 'DIV' - ; - + : 'DIV' + ; DO - : 'DO' - ; - + : 'DO' + ; ELSE - : 'ELSE' - ; - + : 'ELSE' + ; ELSIF - : 'ELSIF' - ; - + : 'ELSIF' + ; END - : 'END' - ; - + : 'END' + ; EXIT - : 'EXIT' - ; - + : 'EXIT' + ; EXPORT - : 'EXPORT' - ; - + : 'EXPORT' + ; FOR - : 'FOR' - ; - + : 'FOR' + ; FROM - : 'FROM' - ; - + : 'FROM' + ; IF - : 'IF' - ; - + : 'IF' + ; IMPLEMENTATION - : 'IMPLEMENTATION' - ; - + : 'IMPLEMENTATION' + ; IMPORT - : 'IMPORT' - ; - + : 'IMPORT' + ; IN - : 'IN' - ; - + : 'IN' + ; LOOP - : 'LOOP' - ; - + : 'LOOP' + ; MOD - : 'MOD' - ; - + : 'MOD' + ; MODULE - : 'MODULE' - ; - + : 'MODULE' + ; NOT - : 'NOT' - ; - + : 'NOT' + ; OF - : 'OF' - ; - + : 'OF' + ; OR - : 'OR' - ; - + : 'OR' + ; POINTER - : 'POINTER' - ; - + : 'POINTER' + ; PROCEDURE - : 'PROCEDURE' - ; - + : 'PROCEDURE' + ; QUALIFIED - : 'QUALIFIED' - ; - + : 'QUALIFIED' + ; RECORD - : 'RECORD' - ; - + : 'RECORD' + ; REPEAT - : 'REPEAT' - ; - + : 'REPEAT' + ; RETURN - : 'RETURN' - ; - + : 'RETURN' + ; SET - : 'SET' - ; - + : 'SET' + ; THEN - : 'THEN' - ; - + : 'THEN' + ; TO - : 'TO' - ; - + : 'TO' + ; TYPE - : 'TYPE' - ; - + : 'TYPE' + ; UNTIL - : 'UNTIL' - ; - + : 'UNTIL' + ; VAR - : 'VAR' - ; - + : 'VAR' + ; WHILE - : 'WHILE' - ; - + : 'WHILE' + ; WITH - : 'WITH' - ; - + : 'WITH' + ; IDENT - : LETTER (LETTER | DIGIT)* - ; - + : LETTER (LETTER | DIGIT)* + ; INTEGER - : DIGIT + | OCTAL_DIGIT + ('B' | 'C') | DIGIT (HEX_DIGIT)* 'H' - ; - + : DIGIT+ + | OCTAL_DIGIT+ ('B' | 'C') + | DIGIT (HEX_DIGIT)* 'H' + ; REAL - : DIGIT + '.' DIGIT* SCALE_FACTOR? - ; - + : DIGIT+ '.' DIGIT* SCALE_FACTOR? + ; STRING - : '\'' (CHARACTER | '"')* '\'' | '"' (CHARACTER | '\'')* '"' - ; - + : '\'' (CHARACTER | '"')* '\'' + | '"' (CHARACTER | '\'')* '"' + ; fragment LETTER - : 'A' .. 'Z' | 'a' .. 'z' - ; - + : 'A' .. 'Z' + | 'a' .. 'z' + ; DIGIT - : OCTAL_DIGIT | '8' | '9' - ; - + : OCTAL_DIGIT + | '8' + | '9' + ; OCTAL_DIGIT - : '0' .. '7' - ; - + : '0' .. '7' + ; HEX_DIGIT - : DIGIT | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' - ; - + : DIGIT + | 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + ; SCALE_FACTOR - : 'E' ('+' | '-')? DIGIT + - ; - + : 'E' ('+' | '-')? DIGIT+ + ; fragment CHARACTER - : DIGIT | LETTER | ' ' | '!' | '#' | '$' | '%' | '&' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~' - ; - + : DIGIT + | LETTER + | ' ' + | '!' + | '#' + | '$' + | '%' + | '&' + | '(' + | ')' + | '*' + | '+' + | ',' + | '-' + | '.' + | ':' + | ';' + | '<' + | '=' + | '>' + | '?' + | '@' + | '[' + | '\\' + | ']' + | '^' + | '_' + | '`' + | '{' + | '|' + | '}' + | '~' + ; COMMENT - : '(*' .*? '*)' -> skip - ; - + : '(*' .*? '*)' -> skip + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/molecule/molecule.g4 b/molecule/molecule.g4 index a93e56f076..2eb9a29250 100644 --- a/molecule/molecule.g4 +++ b/molecule/molecule.g4 @@ -30,26 +30,29 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar molecule; molecule - : part_ ('·' part_)* EOF - ; + : part_ ('·' part_)* EOF + ; part_ - : (count? structure)+; + : (count? structure)+ + ; structure - : symbol count? - ; + : symbol count? + ; symbol - : - element - | group - | ion - ; - + : element + | group + | ion + ; + group : '(' structure+ ')' ; @@ -59,21 +62,138 @@ ion ; element - : ELEMENT - ; + : ELEMENT + ; ELEMENT - : 'H' | 'He' | 'Li' | 'Be' | 'B' | 'C' | 'N' | 'O' | 'F' | 'Ne' | 'Na' | 'Mg' | 'Al' | 'Si' | 'P' | 'S' | 'Cl' | 'Ar' | 'K' | 'Ca' | 'Sc' | 'Ti' | 'V' | 'Cr' | 'Mn' | 'Fe' | 'Co' | 'Ni' | 'Cu' | 'Zn' | 'Ga' | 'Ge' | 'As' | 'Se' | 'Br' | 'Kr' | 'Rb' | 'Sr' | 'Y' | 'Zr' | 'Nb' | 'Mo' | 'Tc' | 'Ru' | 'Rh' | 'Pd' | 'Ag' | 'Cd' | 'In' | 'Sn' | 'Sb' | 'Te' | 'I' | 'Xe' | 'Cs' | 'Ba' | 'La' | 'Ce' | 'Pr' | 'Nd' | 'Pm' | 'Sm' | 'Eu' | 'Gd' | 'Tb' | 'Dy' | 'Ho' | 'Er' | 'Tm' | 'Yb' | 'Lu' | 'Hf' | 'Ta' | 'W' | 'Re' | 'Os' | 'Ir' | 'Pt' | 'Au' | 'Hg' | 'Tl' | 'Pb' | 'Bi' | 'Po' | 'At' | 'Rn' | 'Fr' | 'Ra' | 'Ac' | 'Th' | 'Pa' | 'U' | 'Np' | 'Pu' | 'Am' | 'Cm' | 'Bk' | 'Cf' | 'Es' | 'Fm' | 'Md' | 'No' | 'Lr' | 'Rf' | 'Db' | 'Sg' | 'Bh' | 'Hs' | 'Mt' | 'Ds' | 'Rg' | 'Cn' | 'Nh' | 'Fl' | 'Mc' | 'Lv' | 'Ts' | 'Og' - ; + : 'H' + | 'He' + | 'Li' + | 'Be' + | 'B' + | 'C' + | 'N' + | 'O' + | 'F' + | 'Ne' + | 'Na' + | 'Mg' + | 'Al' + | 'Si' + | 'P' + | 'S' + | 'Cl' + | 'Ar' + | 'K' + | 'Ca' + | 'Sc' + | 'Ti' + | 'V' + | 'Cr' + | 'Mn' + | 'Fe' + | 'Co' + | 'Ni' + | 'Cu' + | 'Zn' + | 'Ga' + | 'Ge' + | 'As' + | 'Se' + | 'Br' + | 'Kr' + | 'Rb' + | 'Sr' + | 'Y' + | 'Zr' + | 'Nb' + | 'Mo' + | 'Tc' + | 'Ru' + | 'Rh' + | 'Pd' + | 'Ag' + | 'Cd' + | 'In' + | 'Sn' + | 'Sb' + | 'Te' + | 'I' + | 'Xe' + | 'Cs' + | 'Ba' + | 'La' + | 'Ce' + | 'Pr' + | 'Nd' + | 'Pm' + | 'Sm' + | 'Eu' + | 'Gd' + | 'Tb' + | 'Dy' + | 'Ho' + | 'Er' + | 'Tm' + | 'Yb' + | 'Lu' + | 'Hf' + | 'Ta' + | 'W' + | 'Re' + | 'Os' + | 'Ir' + | 'Pt' + | 'Au' + | 'Hg' + | 'Tl' + | 'Pb' + | 'Bi' + | 'Po' + | 'At' + | 'Rn' + | 'Fr' + | 'Ra' + | 'Ac' + | 'Th' + | 'Pa' + | 'U' + | 'Np' + | 'Pu' + | 'Am' + | 'Cm' + | 'Bk' + | 'Cf' + | 'Es' + | 'Fm' + | 'Md' + | 'No' + | 'Lr' + | 'Rf' + | 'Db' + | 'Sg' + | 'Bh' + | 'Hs' + | 'Mt' + | 'Ds' + | 'Rg' + | 'Cn' + | 'Nh' + | 'Fl' + | 'Mc' + | 'Lv' + | 'Ts' + | 'Og' + ; count - : NUMBER - ; + : NUMBER + ; NUMBER - : ('0' .. '9') + - ; + : ('0' .. '9')+ + ; WS - : [ \t\r\n] + -> skip - ; + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/moo/moo.g4 b/moo/moo.g4 index 5676d8ac60..8910471681 100644 --- a/moo/moo.g4 +++ b/moo/moo.g4 @@ -36,382 +36,357 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * https://www.hayseed.net/MOO/manuals/ProgrammersManual.html */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar moo; prog - : declaration + EOF - ; + : declaration+ EOF + ; declaration - : programdecl - | verbdecl - | propertydecl - | rmpropertydecl - | setpropertydecl - | displaypropertydecl - | kidsdecl - | parentdecl - | describedecl - | contentsdecl - | noteditdecl - | createdecl - | editdecl - | addaliasdecl - ; + : programdecl + | verbdecl + | propertydecl + | rmpropertydecl + | setpropertydecl + | displaypropertydecl + | kidsdecl + | parentdecl + | describedecl + | contentsdecl + | noteditdecl + | createdecl + | editdecl + | addaliasdecl + ; programdecl - : '@program' programname ':' name statement + '.' - ; + : '@program' programname ':' name statement+ '.' + ; programname - : name - | stringliteral - ; + : name + | stringliteral + ; verbdecl - : '@verb' (verbname ':' name) name + permissions? - ; + : '@verb' (verbname ':' name) name+ permissions? + ; verbname - : name - | stringliteral - ; + : name + | stringliteral + ; propertydecl - : ('@property' | '@prop') property_ '='? expression? permissions? - ; + : ('@property' | '@prop') property_ '='? expression? permissions? + ; rmpropertydecl - : ('@rmproperty' | '@rmprop') name - ; + : ('@rmproperty' | '@rmprop') name + ; setpropertydecl - : '@set' property_ 'to' expression - ; + : '@set' property_ 'to' expression + ; displaypropertydecl - : ('@display' | '@disp') property_ - ; + : ('@display' | '@disp') property_ + ; kidsdecl - : '@kids' name - ; + : '@kids' name + ; parentdecl - : '@parent' name - ; + : '@parent' name + ; describedecl - : '@describe' property_ 'as' expression - ; + : '@describe' property_ 'as' expression + ; contentsdecl - : '@contents' name - ; + : '@contents' name + ; noteditdecl - : '@notedit' property_ - ; + : '@notedit' property_ + ; createdecl - : '@create' sysname 'called' expressionlist - ; + : '@create' sysname 'called' expressionlist + ; editdecl - : '@edit' property_ - ; + : '@edit' property_ + ; addaliasdecl - : '@addalias' name (',' name)* 'to' expression - ; + : '@addalias' name (',' name)* 'to' expression + ; statement - : ifblock - | whileblock - | doblock - | forblock - | assignblock - | tryblock - | command SEMICOLON - ; + : ifblock + | whileblock + | doblock + | forblock + | assignblock + | tryblock + | command SEMICOLON + ; ifblock - : 'if' condition statement + ('elseif' condition statement +)? ('else' statement +)? 'endif' ';'? - ; + : 'if' condition statement+ ('elseif' condition statement+)? ('else' statement+)? 'endif' ';'? + ; whileblock - : 'while' condition statement + - ; + : 'while' condition statement+ + ; doblock - : 'do' statement + 'while' condition - ; + : 'do' statement+ 'while' condition + ; forblock - : 'for' name 'in' expression statement + 'endfor' - ; + : 'for' name 'in' expression statement+ 'endfor' + ; tryblock - : 'try' statement + 'except' property_ statement + 'endtry' - ; + : 'try' statement+ 'except' property_ statement+ 'endtry' + ; assignblock - : property_ ASSIGN expression SEMICOLON - ; + : property_ ASSIGN expression SEMICOLON + ; condition - : LPAREN expression (relop expression)* RPAREN - ; + : LPAREN expression (relop expression)* RPAREN + ; relop - : EQ - | NEQ - | GT - | GTE - | LT - | LTE - | AND - | OR - ; + : EQ + | NEQ + | GT + | GTE + | LT + | LTE + | AND + | OR + ; expressionlist - : expression (COMMA expression)* - ; + : expression (COMMA expression)* + ; expression - : term ((PLUS | MINUS) term)* - ; + : term ((PLUS | MINUS) term)* + ; term - : factor ((TIMES | DIV | MOD) factor)* - ; + : factor ((TIMES | DIV | MOD) factor)* + ; factor - : signedAtom (POW signedAtom)* - ; + : signedAtom (POW signedAtom)* + ; signedAtom - : PLUS signedAtom - | MINUS signedAtom - | atom - ; + : PLUS signedAtom + | MINUS signedAtom + | atom + ; atom - : stringliteral - | functioninvocation - | verbinvocation - | property_ - | integer - | real - | list_ - | objref - | '(' expression ')' - | ('!' expression) - ; + : stringliteral + | functioninvocation + | verbinvocation + | property_ + | integer + | real + | list_ + | objref + | '(' expression ')' + | ('!' expression) + ; objref - : OBJREF - ; + : OBJREF + ; functioninvocation - : name '(' expressionlist ')' - ; + : name '(' expressionlist ')' + ; command - : verbinvocation - | returncommand - ; + : verbinvocation + | returncommand + ; returncommand - : 'return' expression? - ; + : 'return' expression? + ; verbinvocation - : property_ ':' verb - ; + : property_ ':' verb + ; verb - : name ('(' expressionlist? ')')? - ; + : name ('(' expressionlist? ')')? + ; property_ - : propertyname (('.' name) | '[' expression ']')* - ; + : propertyname (('.' name) | '[' expression ']')* + ; propertyname - : name - | stringliteral - ; + : name + | stringliteral + ; list_ - : '{' expressionlist? '}' - ; + : '{' expressionlist? '}' + ; stringliteral - : STRINGLITERAL - ; + : STRINGLITERAL + ; integer - : INTEGER - ; + : INTEGER + ; real - : REAL - ; + : REAL + ; name - : username - | sysname - ; + : username + | sysname + ; sysname - : DOLLAR STRING? - ; + : DOLLAR STRING? + ; username - : STRING - ; + : STRING + ; permissions - : PERMISSIONS - ; - + : PERMISSIONS + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; TIMES - : '*' - ; - + : '*' + ; MOD - : '%' - ; - + : '%' + ; DIV - : '/' - ; - + : '/' + ; GT - : '>' - ; - + : '>' + ; LT - : '<' - ; - + : '<' + ; GTE - : '>=' - ; - + : '>=' + ; LTE - : '<=' - ; - + : '<=' + ; EQ - : '==' - ; - + : '==' + ; AND - : '&&' - ; - + : '&&' + ; OR - : '||' - ; - + : '||' + ; NEQ - : '!=' - ; - + : '!=' + ; POW - : '^' - ; - + : '^' + ; COMMA - : ',' - ; - + : ',' + ; ASSIGN - : '=' - ; - + : '=' + ; SEMICOLON - : ';' - ; - + : ';' + ; DOLLAR - : '$' - ; - + : '$' + ; OBJREF - : '#' [0-9] + - ; - + : '#' [0-9]+ + ; PERMISSIONS - : [rcxd] + - ; - + : [rcxd]+ + ; STRING - : [a-zA-Z] [a-zA-Z0-9!_*] + - ; - + : [a-zA-Z] [a-zA-Z0-9!_*]+ + ; STRINGLITERAL - : '"' ~ ["]* '"' - ; - + : '"' ~ ["]* '"' + ; INTEGER - : [0-9] + - ; - + : [0-9]+ + ; REAL - : [0-9] + '.' [0-9] + - ; - + : [0-9]+ '.' [0-9]+ + ; COMMENT - : ';' ~ [\r\n]* -> skip - ; - + : ';' ~ [\r\n]* -> skip + ; WS - : [ \r\n\t] -> skip - ; + : [ \r\n\t] -> skip + ; \ No newline at end of file diff --git a/morsecode/morsecode.g4 b/morsecode/morsecode.g4 index b343d91d8e..da2ed32959 100644 --- a/morsecode/morsecode.g4 +++ b/morsecode/morsecode.g4 @@ -30,209 +30,210 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar morsecode; morsecode - : letter (SPACE letter)+ EOF - ; + : letter (SPACE letter)+ EOF + ; letter - : a - | b - | c - | d - | e - | f - | g - | h - | i - | j - | k - | l - | m - | n - | o - | p - | q - | r - | s - | t - | u - | v - | w - | x - | y - | z - | one - | two - | three - | four - | five - | six - | seven - | eight - | nine - | zero - ; + : a + | b + | c + | d + | e + | f + | g + | h + | i + | j + | k + | l + | m + | n + | o + | p + | q + | r + | s + | t + | u + | v + | w + | x + | y + | z + | one + | two + | three + | four + | five + | six + | seven + | eight + | nine + | zero + ; a - : DOT DASH - ; + : DOT DASH + ; b - : DASH DOT DOT DOT - ; + : DASH DOT DOT DOT + ; c - : DASH DOT DASH DOT - ; + : DASH DOT DASH DOT + ; d - : DASH DOT DOT - ; + : DASH DOT DOT + ; e - : DOT - ; + : DOT + ; f - : DOT DOT DASH DOT - ; + : DOT DOT DASH DOT + ; g - : DASH DASH DOT - ; + : DASH DASH DOT + ; h - : DOT DOT DOT DOT - ; + : DOT DOT DOT DOT + ; i - : DOT DOT - ; + : DOT DOT + ; j - : DOT DASH DASH DASH - ; + : DOT DASH DASH DASH + ; k - : DASH DOT DASH - ; + : DASH DOT DASH + ; l - : DOT DASH DOT DOT - ; + : DOT DASH DOT DOT + ; m - : DASH DASH - ; + : DASH DASH + ; n - : DASH DOT - ; + : DASH DOT + ; o - : DASH DASH DASH - ; + : DASH DASH DASH + ; p - : DOT DASH DASH DOT - ; + : DOT DASH DASH DOT + ; q - : DASH DASH DOT DASH - ; + : DASH DASH DOT DASH + ; r - : DOT DASH DOT - ; + : DOT DASH DOT + ; s - : DOT DOT DOT - ; + : DOT DOT DOT + ; t - : DASH - ; + : DASH + ; u - : DOT DOT DASH - ; + : DOT DOT DASH + ; v - : DOT DOT DOT DASH - ; + : DOT DOT DOT DASH + ; w - : DOT DASH DASH - ; + : DOT DASH DASH + ; x - : DASH DOT DOT DASH - ; + : DASH DOT DOT DASH + ; y - : DASH DOT DASH DASH - ; + : DASH DOT DASH DASH + ; z - : DASH DASH DOT DOT - ; + : DASH DASH DOT DOT + ; one - : DOT DASH DASH DASH DASH - ; + : DOT DASH DASH DASH DASH + ; two - : DOT DOT DASH DASH DASH - ; + : DOT DOT DASH DASH DASH + ; three - : DOT DOT DOT DASH DASH - ; + : DOT DOT DOT DASH DASH + ; four - : DOT DOT DOT DOT DASH - ; + : DOT DOT DOT DOT DASH + ; five - : DOT DOT DOT DOT DOT - ; + : DOT DOT DOT DOT DOT + ; six - : DASH DOT DOT DOT DOT - ; + : DASH DOT DOT DOT DOT + ; seven - : DASH DASH DOT DOT DOT - ; + : DASH DASH DOT DOT DOT + ; eight - : DASH DASH DASH DOT DOT - ; + : DASH DASH DASH DOT DOT + ; nine - : DASH DASH DASH DASH DOT - ; + : DASH DASH DASH DASH DOT + ; zero - : DASH DASH DASH DASH DASH - ; - + : DASH DASH DASH DASH DASH + ; DOT - : '.' - ; - + : '.' + ; DASH - : '-' - ; + : '-' + ; SPACE : ' ' ; WS - : [\t\r\n] -> skip - ; + : [\t\r\n] -> skip + ; \ No newline at end of file diff --git a/mps/mps.g4 b/mps/mps.g4 index fb9ab07d77..0a2ec02916 100644 --- a/mps/mps.g4 +++ b/mps/mps.g4 @@ -5,189 +5,179 @@ * */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar mps; modell - : firstrow rows columns rhs ranges? bounds? endata EOF - ; + : firstrow rows columns rhs ranges? bounds? endata EOF + ; firstrow - : NAMEINDICATORCARD IDENTIFIER? KEYWORDFREE? - ; + : NAMEINDICATORCARD IDENTIFIER? KEYWORDFREE? + ; rows - : ROWINDICATORCARD (rowdatacard) + - ; + : ROWINDICATORCARD (rowdatacard)+ + ; columns - : COLUMNINDICATORCARD columndatacards - ; + : COLUMNINDICATORCARD columndatacards + ; rhs - : RHSINDICATORCARD rhsdatacards - ; + : RHSINDICATORCARD rhsdatacards + ; ranges - : RANGESINDICATORCARD rangesdatacards - ; + : RANGESINDICATORCARD rangesdatacards + ; bounds - : BOUNDSINDICATORCARD boundsdatacards - ; + : BOUNDSINDICATORCARD boundsdatacards + ; endata - : ENDATAINDICATORCARD - ; + : ENDATAINDICATORCARD + ; rowdatacard - : ROWTYPE IDENTIFIER - ; + : ROWTYPE IDENTIFIER + ; columndatacards - : (columndatacard | intblock) + - ; + : (columndatacard | intblock)+ + ; rhsdatacards - : rhsdatacard + - ; + : rhsdatacard+ + ; rangesdatacards - : rangesdatacard + - ; + : rangesdatacard+ + ; boundsdatacards - : boundsdatacard + - ; + : boundsdatacard+ + ; columndatacard - : IDENTIFIER IDENTIFIER NUMERICALVALUE (IDENTIFIER NUMERICALVALUE)? - ; + : IDENTIFIER IDENTIFIER NUMERICALVALUE (IDENTIFIER NUMERICALVALUE)? + ; rhsdatacard - : (IDENTIFIER | RHSINDICATORCARD) IDENTIFIER NUMERICALVALUE (IDENTIFIER NUMERICALVALUE)? - ; + : (IDENTIFIER | RHSINDICATORCARD) IDENTIFIER NUMERICALVALUE (IDENTIFIER NUMERICALVALUE)? + ; rangesdatacard - : (IDENTIFIER | RANGESINDICATORCARD) IDENTIFIER NUMERICALVALUE (IDENTIFIER NUMERICALVALUE)? - ; + : (IDENTIFIER | RANGESINDICATORCARD) IDENTIFIER NUMERICALVALUE (IDENTIFIER NUMERICALVALUE)? + ; boundsdatacard - : BOUNDKEY (IDENTIFIER | BOUNDSINDICATORCARD) IDENTIFIER NUMERICALVALUE? - ; + : BOUNDKEY (IDENTIFIER | BOUNDSINDICATORCARD) IDENTIFIER NUMERICALVALUE? + ; intblock - : startmarker columndatacard + endmarker - ; + : startmarker columndatacard+ endmarker + ; startmarker - : IDENTIFIER KEYWORDMARKER STARTMARKER - ; + : IDENTIFIER KEYWORDMARKER STARTMARKER + ; endmarker - : IDENTIFIER KEYWORDMARKER ENDMARKER - ; - + : IDENTIFIER KEYWORDMARKER ENDMARKER + ; NAMEINDICATORCARD - : 'NAME' - ; - + : 'NAME' + ; ROWINDICATORCARD - : 'ROWS' - ; - + : 'ROWS' + ; COLUMNINDICATORCARD - : 'COLUMNS' - ; - + : 'COLUMNS' + ; RHSINDICATORCARD - : 'RHS' - ; - + : 'RHS' + ; RANGESINDICATORCARD - : 'RANGES' - ; - + : 'RANGES' + ; BOUNDSINDICATORCARD - : 'BOUNDS' - ; - + : 'BOUNDS' + ; ENDATAINDICATORCARD - : 'ENDATA' - ; - + : 'ENDATA' + ; KEYWORDMARKER - : '\'MARKER\'' - ; - + : '\'MARKER\'' + ; STARTMARKER - : '\'INTORG\'' - ; - + : '\'INTORG\'' + ; ENDMARKER - : '\'INTEND\'' - ; - + : '\'INTEND\'' + ; KEYWORDFREE - : 'FREE' - ; - + : 'FREE' + ; BOUNDKEY - : ('UP' | 'LO' | 'FX' | 'LI' | 'UI' | 'SC' | 'FR' | 'BV' | 'MI' | 'PL') - ; - + : ('UP' | 'LO' | 'FX' | 'LI' | 'UI' | 'SC' | 'FR' | 'BV' | 'MI' | 'PL') + ; ROWTYPE - : ('E' | 'L' | 'G' | 'N') - ; - + : ('E' | 'L' | 'G' | 'N') + ; IDENTIFIER - : LETTER CHARACTER* - ; - + : LETTER CHARACTER* + ; NUMERICALVALUE - : DIGIT DIGITS* - ; - + : DIGIT DIGITS* + ; WS - : (' ' | '\t' | '\n' | '\r' | '\f') + -> skip - ; - + : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip + ; LINE_COMMENT - : ('*' | '$') ~ ('\n' | '\r')* '\r'? '\n' -> skip - ; - + : ('*' | '$') ~ ('\n' | '\r')* '\r'? '\n' -> skip + ; fragment CHARACTER - : (LETTER | DIGIT) - ; - + : (LETTER | DIGIT) + ; fragment LETTER - : ('a' .. 'z' | 'A' .. 'Z' | '_' | '/' | '#' | '@' | '(' | ')') - ; - + : ('a' .. 'z' | 'A' .. 'Z' | '_' | '/' | '#' | '@' | '(' | ')') + ; fragment DIGIT - : '0' .. '9' | '-' | '+' | '.' | ',' - ; - + : '0' .. '9' + | '-' + | '+' + | '.' + | ',' + ; fragment DIGITS - : DIGIT | 'D' | 'E' | 'e' | 'd' - ; + : DIGIT + | 'D' + | 'E' + | 'e' + | 'd' + ; \ No newline at end of file diff --git a/muddb/muddb.g4 b/muddb/muddb.g4 index 528efc1c76..093ee43ff2 100644 --- a/muddb/muddb.g4 +++ b/muddb/muddb.g4 @@ -30,108 +30,107 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar muddb; db - : room* END EOL* EOF - ; + : room* END EOL* EOF + ; room - : roomno name description location contents exits next_ key fail_message succ_message ofail osuccess owner pennies flags password - ; + : roomno name description location contents exits next_ key fail_message succ_message ofail osuccess owner pennies flags password + ; roomno - : STRING EOL - ; + : STRING EOL + ; name - : string - ; + : string + ; description - : string - ; + : string + ; location - : ref - ; + : ref + ; contents - : ref - ; + : ref + ; exits - : ref - ; + : ref + ; next_ - : ref - ; + : ref + ; key - : bool_ - ; + : bool_ + ; fail_message - : string - ; + : string + ; succ_message - : string - ; + : string + ; ofail - : string - ; + : string + ; osuccess - : string - ; + : string + ; owner - : ref - ; + : ref + ; pennies - : ref - ; + : ref + ; flags - : ref - ; + : ref + ; password - : string - ; + : string + ; string - : STRING? EOL - ; + : STRING? EOL + ; ref - : NUM? EOL - ; + : NUM? EOL + ; bool_ - : NUM? EOL - ; - + : NUM? EOL + ; END - : '***END OF DUMP***' - ; - + : '***END OF DUMP***' + ; NUM - : '-'? [0-9] + - ; - + : '-'? [0-9]+ + ; STRING - : [a-zA-Z0-9,;:'.* \t!<>{}()[\]@?=_"`+\-/#]+ - ; - + : [a-zA-Z0-9,;:'.* \t!<>{}()[\]@?=_"`+\-/#]+ + ; EOL - : ('\r' '\n' | '\n' | '\r') - ; + : ('\r' '\n' | '\n' | '\r') + ; \ No newline at end of file diff --git a/mumath/mumath.g4 b/mumath/mumath.g4 index fec013942e..d113c6ff49 100644 --- a/mumath/mumath.g4 +++ b/mumath/mumath.g4 @@ -5,274 +5,243 @@ * */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar mumath; program - : ((functionDefinition | assignment | functionDesignator) (SEMI | DOLLAR))* EOF - ; + : ((functionDefinition | assignment | functionDesignator) (SEMI | DOLLAR))* EOF + ; assignment - : (ID COLON) + expression - ; + : (ID COLON)+ expression + ; list_ - : LPAREN (RPAREN | ID (COMMA ID)* RPAREN) - ; + : LPAREN (RPAREN | ID (COMMA ID)* RPAREN) + ; functionDefinition - : FUNCTION ID list_ COMMA statments (COMMA)? ENDFUN - ; + : FUNCTION ID list_ COMMA statments (COMMA)? ENDFUN + ; actualParameter - : expression - | assignment - ; + : expression + | assignment + ; statments - : (loop | when | block | assignment | expression | functionDesignator) (COMMA statments)* - ; + : (loop | when | block | assignment | expression | functionDesignator) (COMMA statments)* + ; block - : BLOCK statments COMMA ENDBLOCK - ; + : BLOCK statments COMMA ENDBLOCK + ; loop - : LOOP statments (COMMA)? ENDLOOP - ; + : LOOP statments (COMMA)? ENDLOOP + ; when - : WHEN expression ((COMMA)? EXIT COMMA statments (COMMA)? EXIT) - ; + : WHEN expression ((COMMA)? EXIT COMMA statments (COMMA)? EXIT) + ; expression - : simpleExpression (relationalOperator simpleExpression)* - ; + : simpleExpression (relationalOperator simpleExpression)* + ; relationalOperator - : equal - | (NOT_EQUAL | LT | LE | GE | GT | EQUATION) - ; + : equal + | (NOT_EQUAL | LT | LE | GE | GT | EQUATION) + ; simpleExpression - : (MINUS)? term (addingOperator term)* - ; + : (MINUS)? term (addingOperator term)* + ; addingOperator - : PLUS - | MINUS - | OR - ; + : PLUS + | MINUS + | OR + ; term - : factor (multiplyingOperator factor)* - ; + : factor (multiplyingOperator factor)* + ; multiplyingOperator - : (STAR | SLASH | MOD | AND | POWER) - ; + : (STAR | SLASH | MOD | AND | POWER) + ; factor - : ID - | constant - | LPAREN expression RPAREN - | functionDesignator - | NOT factor - ; + : ID + | constant + | LPAREN expression RPAREN + | functionDesignator + | NOT factor + ; constant - : (NUMBER | STRING | QUOTE ID | QUOTE STRING) - ; + : (NUMBER | STRING | QUOTE ID | QUOTE STRING) + ; functionDesignator - : ID LPAREN ((actualParameter (COMMA actualParameter)*) |) RPAREN - ; + : ID LPAREN ((actualParameter (COMMA actualParameter)*) |) RPAREN + ; equal - : (EQF | EQC) - ; - + : (EQF | EQC) + ; BLOCK - : 'BLOCK' - ; - + : 'BLOCK' + ; ENDBLOCK - : 'ENDBLOCK' - ; - + : 'ENDBLOCK' + ; FUNCTION - : 'FUNCTION' - ; - + : 'FUNCTION' + ; ENDFUN - : 'ENDFUN' - ; - + : 'ENDFUN' + ; EQF - : 'EQ' - ; - + : 'EQ' + ; LOOP - : 'LOOP' - ; - + : 'LOOP' + ; ENDLOOP - : 'ENDLOOP' - ; - + : 'ENDLOOP' + ; WHEN - : 'WHEN' - ; - + : 'WHEN' + ; EXIT - : 'EXIT' - ; - + : 'EXIT' + ; OR - : 'OR' - ; + : 'OR' + ; AND - : 'AND' - ; + : 'AND' + ; NOT - : 'NOT' - ; + : 'NOT' + ; MOD - : 'mod' - ; + : 'mod' + ; WS - : (' ' | '\t' | '\n' | '\r') -> skip - ; - + : (' ' | '\t' | '\n' | '\r') -> skip + ; COMMENT - : '%' ('\n' | ~ ('%' | '\n'))* '%' -> skip - ; - + : '%' ('\n' | ~ ('%' | '\n'))* '%' -> skip + ; EQUATION - : '==' - ; - + : '==' + ; QUOTE - : '\'' - ; - + : '\'' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; STAR - : '*' - ; - + : '*' + ; SLASH - : '/' - ; - + : '/' + ; COMMA - : ',' - ; - + : ',' + ; SEMI - : ';' - ; - + : ';' + ; DOLLAR - : '$' - ; - + : '$' + ; COLON - : ':' - ; - + : ':' + ; EQC - : '=' - ; - + : '=' + ; NOT_EQUAL - : '<>' - ; - + : '<>' + ; LT - : '<' - ; - + : '<' + ; LE - : '<=' - ; - + : '<=' + ; GE - : '>=' - ; - + : '>=' + ; GT - : '>' - ; - + : '>' + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; POWER - : '^' - ; - + : '^' + ; ID - : ('A' .. 'Z' | '@' | '{' | '#') ('A' .. 'Z' | '0' .. '9' | '#' | '}')* (ARR)? - ; - + : ('A' .. 'Z' | '@' | '{' | '#') ('A' .. 'Z' | '0' .. '9' | '#' | '}')* (ARR)? + ; ARR - : '[' NUMBER ']' - ; - + : '[' NUMBER ']' + ; STRING - : '"' (~ '"')* '"' - ; - + : '"' (~ '"')* '"' + ; NUMBER - : ('0' .. '9') + - ; + : ('0' .. '9')+ + ; \ No newline at end of file diff --git a/mumps/mumps.g4 b/mumps/mumps.g4 index 124993e790..aca04d8023 100644 --- a/mumps/mumps.g4 +++ b/mumps/mumps.g4 @@ -30,25 +30,28 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar mumps; program - : line + eof - ; + : line+ eof + ; eof - : SPACE* CR? - ; + : SPACE* CR? + ; line - : code - | routinedecl - | CR - ; + : code + | routinedecl + | CR + ; code - : (label | (SPACE + DOT +) | SPACE +) (command + | if_ | subproc)? SPACE* CR - ; + : (label | (SPACE+ DOT+) | SPACE+) (command+ | if_ | subproc)? SPACE* CR + ; /* * A line may begin with a label. If so, the label must begin in column one. @@ -58,70 +61,70 @@ code * some number of blanks, possibly zero, before the first command. */ label - : identifier SPACE + - ; + : identifier SPACE+ + ; routinedecl - : PERCENT? identifier (LPAREN paramlist? RPAREN)? SPACE* CR - ; + : PERCENT? identifier (LPAREN paramlist? RPAREN)? SPACE* CR + ; paramlist - : param (COMMA param)* - ; + : param (COMMA param)* + ; param - : variable - ; + : variable + ; subproc - : identifier (LPAREN paramlist? RPAREN)? (SPACE* command) + - ; + : identifier (LPAREN paramlist? RPAREN)? (SPACE* command)+ + ; command - : set_ - | for_ - | write_ - | read_ - | quit_ - | halt_ - | hang_ - | new_ - | break_ - | do_ - | kill_ - | view_ - | merge_ - | xecute_ - | (CLOSE | ELSE | GOTO | JOB | LOCK | OPEN | TCOMMIT | TRESTART | TROLLBACK | TSTART | USE) - ; + : set_ + | for_ + | write_ + | read_ + | quit_ + | halt_ + | hang_ + | new_ + | break_ + | do_ + | kill_ + | view_ + | merge_ + | xecute_ + | (CLOSE | ELSE | GOTO | JOB | LOCK | OPEN | TCOMMIT | TRESTART | TROLLBACK | TSTART | USE) + ; postcondition - : COLON expression - ; + : COLON expression + ; expression - : term (SPACE* (ADD | MULTIPLY | SUBTRACT | DIVIDE | INTDIVIDE | MODULO | EXPONENT) expression)* - ; + : term (SPACE* (ADD | MULTIPLY | SUBTRACT | DIVIDE | INTDIVIDE | MODULO | EXPONENT) expression)* + ; term - : variable - | function_ - | NUMBER - | LPAREN expression RPAREN - ; + : variable + | function_ + | NUMBER + | LPAREN expression RPAREN + ; condition - : term - | (term (NGT | NLT | LT | GT | EQUALS) term) - ; + : term + | (term (NGT | NLT | LT | GT | EQUALS) term) + ; identifier - : IDENTIFIER - ; + : IDENTIFIER + ; variable - : (CARAT | AMPERSAND)* identifier - ; + : (CARAT | AMPERSAND)* identifier + ; function_ : DOLLAR identifier (LPAREN arglist RPAREN)? @@ -137,510 +140,426 @@ function_ * command word and its post-conditional, if present, and the argument. */ break_ - : BREAK postcondition? - ; + : BREAK postcondition? + ; do_ - : DO postcondition? SPACE + identifier (LPAREN paramlist? RPAREN)? - ; + : DO postcondition? SPACE+ identifier (LPAREN paramlist? RPAREN)? + ; for_ - : FOR SPACE + term EQUALS term COLON (term COLON)? term SPACE + (command SPACE?)* COLON SPACE* condition - ; + : FOR SPACE+ term EQUALS term COLON (term COLON)? term SPACE+ (command SPACE?)* COLON SPACE* condition + ; halt_ - : HALT postcondition? - ; + : HALT postcondition? + ; hang_ - : HANG postcondition? SPACE + term - ; + : HANG postcondition? SPACE+ term + ; if_ - : IF SPACE + condition SPACE* command - ; + : IF SPACE+ condition SPACE* command + ; kill_ - : KILL postcondition? SPACE + arglist - ; + : KILL postcondition? SPACE+ arglist + ; merge_ - : MERGE postcondition? SPACE + term EQUALS term (',' term EQUALS term)* - ; + : MERGE postcondition? SPACE+ term EQUALS term (',' term EQUALS term)* + ; new_ - : NEW postcondition? SPACE + arglist - ; + : NEW postcondition? SPACE+ arglist + ; quit_ - : QUIT postcondition? (SPACE + term)? - ; + : QUIT postcondition? (SPACE+ term)? + ; read_ - : READ postcondition? SPACE + arglist - ; + : READ postcondition? SPACE+ arglist + ; set_ - : SET postcondition? SPACE + assign (',' assign)* - ; + : SET postcondition? SPACE+ assign (',' assign)* + ; view_ - : VIEW postcondition? SPACE + IDENTIFIER - ; + : VIEW postcondition? SPACE+ IDENTIFIER + ; write_ - : WRITE postcondition? SPACE + arglist - ; + : WRITE postcondition? SPACE+ arglist + ; xecute_ - : XECUTE postcondition? SPACE + STRING_LITERAL - ; + : XECUTE postcondition? SPACE+ STRING_LITERAL + ; assign - : (LPAREN? arglist RPAREN?)? SPACE* EQUALS SPACE* arg - ; + : (LPAREN? arglist RPAREN?)? SPACE* EQUALS SPACE* arg + ; arglist - : arg (SPACE* COMMA arg)* - ; + : arg (SPACE* COMMA arg)* + ; arg - : expression - | (BANG | STRING_LITERAL) - ; + : expression + | (BANG | STRING_LITERAL) + ; /* * Command Tokens */ BREAK - : B R E A K - ; - + : B R E A K + ; CLOSE - : C L O S E - ; - + : C L O S E + ; DO - : D O - ; - + : D O + ; ELSE - : E L S E - ; - + : E L S E + ; FOR - : F O R - ; - + : F O R + ; GOTO - : G O T O - ; - + : G O T O + ; HALT - : H A L T - ; - + : H A L T + ; HANG - : H A N G - ; - + : H A N G + ; IF - : I F - ; - + : I F + ; JOB - : J O B - ; - + : J O B + ; KILL - : K I L L - ; - + : K I L L + ; LOCK - : L O C K - ; - + : L O C K + ; MERGE - : M E R G E - ; - + : M E R G E + ; NEW - : N E W - ; - + : N E W + ; OPEN - : O P E N - ; - + : O P E N + ; QUIT - : Q U I T - ; - + : Q U I T + ; READ - : R E A D - ; - + : R E A D + ; SET - : S E T - ; - + : S E T + ; TCOMMIT - : T C O M M I T - ; - + : T C O M M I T + ; TRESTART - : T R E S T A R T - ; - + : T R E S T A R T + ; TROLLBACK - : T R O L L B A C K - ; - + : T R O L L B A C K + ; TSTART - : T S T A R T - ; - + : T S T A R T + ; USE - : U S E - ; - + : U S E + ; VIEW - : V I E W - ; - + : V I E W + ; WRITE - : W R I T E - ; - + : W R I T E + ; XECUTE - : X E C U T E - ; - + : X E C U T E + ; COLON - : ':' - ; - + : ':' + ; COMMA - : ',' - ; - + : ',' + ; DOLLAR - : '$' - ; - + : '$' + ; PERCENT - : '%' - ; - + : '%' + ; AMPERSAND - : '&' - ; - + : '&' + ; INDIRECT - : '@' - ; - + : '@' + ; CARAT - : '^' - ; - + : '^' + ; BANG - : '!' - ; - + : '!' + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; LBRACE - : '{' - ; - + : '{' + ; RBRACE - : '}' - ; - + : '}' + ; NGT - : '\'>' - ; - + : '\'>' + ; NLT - : '\'<' - ; - + : '\'<' + ; GT - : '>' - ; - + : '>' + ; LT - : '<' - ; - + : '<' + ; ADD - : '+' - ; - + : '+' + ; SUBTRACT - : '-' - ; - + : '-' + ; MULTIPLY - : '*' - ; - + : '*' + ; DIVIDE - : '/' - ; - + : '/' + ; INTDIVIDE - : '\\' - ; - + : '\\' + ; MODULO - : '#' - ; - + : '#' + ; EXPONENT - : '**' - ; - + : '**' + ; EQUALS - : '=' - ; - + : '=' + ; QUESTION - : '?' - ; - + : '?' + ; DOT - : '.' - ; - + : '.' + ; CONCAT - : '_' - ; - + : '_' + ; IDENTIFIER - : ('a' .. 'z' | 'A' .. 'Z') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9')* - ; - + : ('a' .. 'z' | 'A' .. 'Z') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9')* + ; STRING_LITERAL - : '"' ('""' | ~'"')* '"' - ; - + : '"' ('""' | ~'"')* '"' + ; NUMBER - : ('0' .. '9') + ('.' ('0' .. '9') +)? - ; - + : ('0' .. '9')+ ('.' ('0' .. '9')+)? + ; NOT - : '\'' - ; - + : '\'' + ; fragment A - : ('a' | 'A') - ; - + : ('a' | 'A') + ; fragment B - : ('b' | 'B') - ; - + : ('b' | 'B') + ; fragment C - : ('c' | 'C') - ; - + : ('c' | 'C') + ; fragment D - : ('d' | 'D') - ; - + : ('d' | 'D') + ; fragment E - : ('e' | 'E') - ; - + : ('e' | 'E') + ; fragment F - : ('f' | 'F') - ; - + : ('f' | 'F') + ; fragment G - : ('g' | 'G') - ; - + : ('g' | 'G') + ; fragment H - : ('h' | 'H') - ; - + : ('h' | 'H') + ; fragment I - : ('i' | 'I') - ; - + : ('i' | 'I') + ; fragment J - : ('j' | 'J') - ; - + : ('j' | 'J') + ; fragment K - : ('k' | 'K') - ; - + : ('k' | 'K') + ; fragment L - : ('l' | 'L') - ; - + : ('l' | 'L') + ; fragment M - : ('m' | 'M') - ; - + : ('m' | 'M') + ; fragment N - : ('n' | 'N') - ; - + : ('n' | 'N') + ; fragment O - : ('o' | 'O') - ; - + : ('o' | 'O') + ; fragment P - : ('p' | 'P') - ; - + : ('p' | 'P') + ; fragment Q - : ('q' | 'Q') - ; - + : ('q' | 'Q') + ; fragment R - : ('r' | 'R') - ; - + : ('r' | 'R') + ; fragment S - : ('s' | 'S') - ; - + : ('s' | 'S') + ; fragment T - : ('t' | 'T') - ; - + : ('t' | 'T') + ; fragment U - : ('u' | 'U') - ; - + : ('u' | 'U') + ; fragment V - : ('v' | 'V') - ; - + : ('v' | 'V') + ; fragment W - : ('w' | 'W') - ; - + : ('w' | 'W') + ; fragment X - : ('x' | 'X') - ; - + : ('x' | 'X') + ; fragment Y - : ('y' | 'Y') - ; - + : ('y' | 'Y') + ; fragment Z - : ('z' | 'Z') - ; - + : ('z' | 'Z') + ; COMMENT - : ';' ~[\r\n]* -> skip - ; + : ';' ~[\r\n]* -> skip + ; SPACE - : ' ' - ; + : ' ' + ; CR - : [\r\n]+ - ; - + : [\r\n]+ + ; WS - : [\t] -> skip - ; + : [\t] -> skip + ; \ No newline at end of file diff --git a/muparser/MuParser.g4 b/muparser/MuParser.g4 index 1b6aeba6c9..c89649cb69 100644 --- a/muparser/MuParser.g4 +++ b/muparser/MuParser.g4 @@ -37,135 +37,195 @@ * Parser Rules */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar MuParser; prog - : expr+ EOF # progExpr - ; + : expr+ EOF # progExpr + ; expr - : expr POW expr # powExpr - | SUB expr # unaryMinusExpr - | expr op=(MUL | DIV) expr # mulDivExpr - | expr op=(ADD | SUB) expr # addSubExpr - | expr op=(LTEQ | GTEQ | LT | GT) expr # relationalExpr - | expr op=(EQ | NEQ) expr # equalityExpr - | expr AND expr # andExpr - | expr OR expr # orExpr - | expr QUESTION expr COLON expr # iteExpr - | op=FUNCTION OPAR expr CPAR # functionExpr - | op=FUNCTIONMULTI OPAR expr (',' expr)* CPAR # functionMultiExpr - | atom # atomExpr - | ID op=( ASSIGN - | ASSIGNADD - | ASSIGNSUB - | ASSIGNMUL - | ASSIGNDIV) expr # assignExpr - ; + : expr POW expr # powExpr + | SUB expr # unaryMinusExpr + | expr op = (MUL | DIV) expr # mulDivExpr + | expr op = (ADD | SUB) expr # addSubExpr + | expr op = (LTEQ | GTEQ | LT | GT) expr # relationalExpr + | expr op = (EQ | NEQ) expr # equalityExpr + | expr AND expr # andExpr + | expr OR expr # orExpr + | expr QUESTION expr COLON expr # iteExpr + | op = FUNCTION OPAR expr CPAR # functionExpr + | op = FUNCTIONMULTI OPAR expr (',' expr)* CPAR # functionMultiExpr + | atom # atomExpr + | ID op = (ASSIGN | ASSIGNADD | ASSIGNSUB | ASSIGNMUL | ASSIGNDIV) expr # assignExpr + ; atom - : OPAR expr CPAR # parExpr - | (INT | FLOAT) # numberAtom - | (TRUE | FALSE) # booleanAtom - | (E | PI) # predefinedConstantAtom - | ID # idAtom - ; + : OPAR expr CPAR # parExpr + | (INT | FLOAT) # numberAtom + | (TRUE | FALSE) # booleanAtom + | (E | PI) # predefinedConstantAtom + | ID # idAtom + ; /* * Lexer Rules */ FUNCTION - : 'sin' - | 'cos' - | 'tan' - | 'asin' - | 'acos' - | 'atan' - | 'sinh' - | 'cosh' - | 'tanh' - | 'asinh' - | 'acosh' - | 'atanh' - | 'log2' - | 'log10' - | 'log' - | 'ln' - | 'exp' - | 'sqrt' - | 'sign' - | 'rint' - | 'abs' - ; + : 'sin' + | 'cos' + | 'tan' + | 'asin' + | 'acos' + | 'atan' + | 'sinh' + | 'cosh' + | 'tanh' + | 'asinh' + | 'acosh' + | 'atanh' + | 'log2' + | 'log10' + | 'log' + | 'ln' + | 'exp' + | 'sqrt' + | 'sign' + | 'rint' + | 'abs' + ; FUNCTIONMULTI - : 'min' - | 'max' - | 'sum' - | 'avg' - ; - -ASSIGN : '=' ; -ASSIGNADD : '+=' ; -ASSIGNSUB : '-=' ; -ASSIGNMUL : '*=' ; -ASSIGNDIV : '/=' ; -AND : '&&' ; -OR : '||' ; -LTEQ : '<=' ; -GTEQ : '>=' ; -NEQ : '!=' ; -EQ : '==' ; -LT : '<' ; -GT : '>' ; -ADD : '+' ; -SUB : '-' ; -MUL : '*' ; -DIV : '/' ; -POW : '^' ; -NOT : '!' ; - -QUESTION : '?' ; -COLON : ':' ; + : 'min' + | 'max' + | 'sum' + | 'avg' + ; + +ASSIGN + : '=' + ; + +ASSIGNADD + : '+=' + ; + +ASSIGNSUB + : '-=' + ; + +ASSIGNMUL + : '*=' + ; + +ASSIGNDIV + : '/=' + ; + +AND + : '&&' + ; + +OR + : '||' + ; + +LTEQ + : '<=' + ; + +GTEQ + : '>=' + ; + +NEQ + : '!=' + ; + +EQ + : '==' + ; + +LT + : '<' + ; + +GT + : '>' + ; + +ADD + : '+' + ; + +SUB + : '-' + ; + +MUL + : '*' + ; + +DIV + : '/' + ; + +POW + : '^' + ; + +NOT + : '!' + ; + +QUESTION + : '?' + ; + +COLON + : ':' + ; OPAR - : '(' - ; + : '(' + ; CPAR - : ')' - ; + : ')' + ; INT - : [0-9]+ - ; + : [0-9]+ + ; FLOAT - : [0-9]+ '.' [0-9]* - | '.' [0-9]+ - ; + : [0-9]+ '.' [0-9]* + | '.' [0-9]+ + ; TRUE - : 'true' - ; + : 'true' + ; FALSE - : 'false' - ; + : 'false' + ; E - : '_e' - ; + : '_e' + ; PI - : '_pi' - ; + : '_pi' + ; ID - : [a-zA-Z_] [a-zA-Z_0-9]* - ; + : [a-zA-Z_] [a-zA-Z_0-9]* + ; SPACE - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/newick/newick.g4 b/newick/newick.g4 index 8cfa4c66b6..cd47267d11 100644 --- a/newick/newick.g4 +++ b/newick/newick.g4 @@ -29,60 +29,63 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar newick; tree_ - : ( (rootLeaf ';') | (rootInternal ';') | (branch ';') ) EOF - ; + : ((rootLeaf ';') | (rootInternal ';') | (branch ';')) EOF + ; rootLeaf - : name - | '(' branch ')' name - ; + : name + | '(' branch ')' name + ; rootInternal - : '(' branch ',' branchSet ')' name - ; + : '(' branch ',' branchSet ')' name + ; subtree - : leaf - | internal_ - ; + : leaf + | internal_ + ; leaf - : name - ; + : name + ; internal_ - : '(' branchSet ')' name - ; + : '(' branchSet ')' name + ; branchSet - : branch - | branch ',' branchSet - ; + : branch + | branch ',' branchSet + ; branch - : subtree length - ; + : subtree length + ; name - : STRING? - ; + : STRING? + ; length - : (':' NUMBER)? - ; + : (':' NUMBER)? + ; NUMBER - : [0-9]+ ('.' [0-9]+)? - ; + : [0-9]+ ('.' [0-9]+)? + ; STRING - : [a-zA-Z] [a-zA-Z0-9]* - ; + : [a-zA-Z] [a-zA-Z0-9]* + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/oberon/oberon.g4 b/oberon/oberon.g4 index c1adbc4296..1aa44f1de8 100644 --- a/oberon/oberon.g4 +++ b/oberon/oberon.g4 @@ -33,432 +33,447 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* * https://people.inf.ethz.ch/wirth/Oberon/Oberon07.Report.pdf */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar oberon; ident - : IDENT - ; + : IDENT + ; qualident - : (ident '.')? ident - ; + : (ident '.')? ident + ; identdef - : ident '*'? - ; + : ident '*'? + ; integer - : (DIGIT+) - | (DIGIT HEXDIGIT* 'H') - ; + : (DIGIT+) + | (DIGIT HEXDIGIT* 'H') + ; real - : DIGIT+ '.' DIGIT* scaleFactor? - ; + : DIGIT+ '.' DIGIT* scaleFactor? + ; scaleFactor - : 'E' ('+' | '-')? DIGIT+ - ; + : 'E' ('+' | '-')? DIGIT+ + ; number - : integer - | real - ; + : integer + | real + ; constDeclaration - : identdef '=' constExpression - ; + : identdef '=' constExpression + ; constExpression - : expression - ; + : expression + ; typeDeclaration - : identdef '=' type_ - ; + : identdef '=' type_ + ; type_ - : qualident - | arrayType - | recordType - | pointerType - | procedureType - ; + : qualident + | arrayType + | recordType + | pointerType + | procedureType + ; arrayType - : ARRAY length (',' length)* OF type_ - ; + : ARRAY length (',' length)* OF type_ + ; length - : constExpression - ; + : constExpression + ; recordType - : RECORD ('(' baseType ')')? fieldListSequence? END - ; + : RECORD ('(' baseType ')')? fieldListSequence? END + ; baseType - : qualident - ; + : qualident + ; fieldListSequence - : fieldList (';' fieldList)* - ; + : fieldList (';' fieldList)* + ; fieldList - : identList ':' type_ - ; + : identList ':' type_ + ; identList - : identdef (',' identdef)* - ; + : identdef (',' identdef)* + ; pointerType - : POINTER TO type_ - ; + : POINTER TO type_ + ; procedureType - : PROCEDURE formalParameters? - ; + : PROCEDURE formalParameters? + ; variableDeclaration - : identList ':' type_ - ; + : identList ':' type_ + ; expression - : simpleExpression (relation simpleExpression)? - ; + : simpleExpression (relation simpleExpression)? + ; relation - : '=' - | '#' - | '<' - | '<=' - | '>' - | '>=' - | IN - | IS - ; + : '=' + | '#' + | '<' + | '<=' + | '>' + | '>=' + | IN + | IS + ; simpleExpression - : ('+' | '-')? term (addOperator term)* - ; + : ('+' | '-')? term (addOperator term)* + ; addOperator - : '+' - | '-' - | OR - ; + : '+' + | '-' + | OR + ; term - : factor (mulOperator factor)* - ; + : factor (mulOperator factor)* + ; mulOperator - : '*' - | '/' - | DIV - | MOD - | '&' - ; + : '*' + | '/' + | DIV + | MOD + | '&' + ; factor - : number - | STRING - | NIL - | TRUE - | FALSE - | set_ - | designator (actualParameters)? - | '(' expression ')' - | '~' factor - ; + : number + | STRING + | NIL + | TRUE + | FALSE + | set_ + | designator (actualParameters)? + | '(' expression ')' + | '~' factor + ; designator - : qualident selector* - ; + : qualident selector* + ; selector - : '.' ident - | '[' expList ']' - | '^' - | '(' qualident ')' - ; + : '.' ident + | '[' expList ']' + | '^' + | '(' qualident ')' + ; set_ - : '{' (element (',' element)*)? '}' - ; + : '{' (element (',' element)*)? '}' + ; element - : expression ('..' expression)? - ; + : expression ('..' expression)? + ; expList - : expression (',' expression)* - ; + : expression (',' expression)* + ; actualParameters - : '(' expList? ')' - ; + : '(' expList? ')' + ; statement - : (assignment | procedureCall | ifStatement | caseStatement | whileStatement | repeatStatement | forStatement)? - ; + : ( + assignment + | procedureCall + | ifStatement + | caseStatement + | whileStatement + | repeatStatement + | forStatement + )? + ; assignment - : designator ':=' expression - ; + : designator ':=' expression + ; procedureCall - : designator actualParameters? - ; + : designator actualParameters? + ; statementSequence - : statement (';' statement)* - ; + : statement (';' statement)* + ; ifStatement - : IF expression THEN statementSequence (ELSIF expression THEN statementSequence)* (ELSE statementSequence)? END - ; + : IF expression THEN statementSequence (ELSIF expression THEN statementSequence)* ( + ELSE statementSequence + )? END + ; caseStatement - : CASE expression OF case_ ('|' case_)* END - ; + : CASE expression OF case_ ('|' case_)* END + ; case_ - : (caseLabelList ':' statementSequence)? - ; + : (caseLabelList ':' statementSequence)? + ; caseLabelList - : labelRange (',' labelRange)* - ; + : labelRange (',' labelRange)* + ; labelRange - : label ('..' label)? - ; + : label ('..' label)? + ; label - : integer - | STRING - | qualident - ; + : integer + | STRING + | qualident + ; whileStatement - : WHILE expression DO statementSequence (ELSIF expression DO statementSequence)* END - ; + : WHILE expression DO statementSequence (ELSIF expression DO statementSequence)* END + ; repeatStatement - : REPEAT statementSequence UNTIL expression - ; + : REPEAT statementSequence UNTIL expression + ; forStatement - : FOR ident ':=' expression TO expression (BY constExpression)? DO statementSequence END - ; + : FOR ident ':=' expression TO expression (BY constExpression)? DO statementSequence END + ; procedureDeclaration - : procedureHeading ';' procedureBody ident - ; + : procedureHeading ';' procedureBody ident + ; procedureHeading - : PROCEDURE identdef formalParameters? - ; + : PROCEDURE identdef formalParameters? + ; procedureBody - : declarationSequence (BEGIN statementSequence)? (RETURN expression)? END - ; + : declarationSequence (BEGIN statementSequence)? (RETURN expression)? END + ; declarationSequence - : (CONST (constDeclaration ';')*)? (TYPE (typeDeclaration ';')*)? (VAR (variableDeclaration ';')*)? (procedureDeclaration ';')* - ; + : (CONST (constDeclaration ';')*)? (TYPE (typeDeclaration ';')*)? ( + VAR (variableDeclaration ';')* + )? (procedureDeclaration ';')* + ; formalParameters - : '(' (fPSection (';' fPSection)*)? ')' (':' qualident)? - ; + : '(' (fPSection (';' fPSection)*)? ')' (':' qualident)? + ; fPSection - : VAR? ident (',' ident)* ':' formalType - ; + : VAR? ident (',' ident)* ':' formalType + ; formalType - : (ARRAY OF)* qualident - ; + : (ARRAY OF)* qualident + ; module - : MODULE ident ';' importList? declarationSequence (BEGIN statementSequence)? END ident '.' EOF - ; + : MODULE ident ';' importList? declarationSequence (BEGIN statementSequence)? END ident '.' EOF + ; importList - : IMPORT import_ (',' import_)* ';' - ; + : IMPORT import_ (',' import_)* ';' + ; import_ - : ident (':=' ident)? - ; + : ident (':=' ident)? + ; ARRAY - : 'ARRAY' - ; + : 'ARRAY' + ; OF - : 'OF' - ; + : 'OF' + ; END - : 'END' - ; + : 'END' + ; POINTER - : 'POINTER' - ; + : 'POINTER' + ; TO - : 'TO' - ; + : 'TO' + ; RECORD - : 'RECORD' - ; + : 'RECORD' + ; PROCEDURE - : 'PROCEDURE' - ; + : 'PROCEDURE' + ; IN - : 'IN' - ; + : 'IN' + ; IS - : 'IS' - ; + : 'IS' + ; OR - : 'OR' - ; + : 'OR' + ; DIV - : 'DIV' - ; + : 'DIV' + ; MOD - : 'MOD' - ; + : 'MOD' + ; NIL - : 'NIL' - ; + : 'NIL' + ; TRUE - : 'TRUE' - ; + : 'TRUE' + ; FALSE - : 'FALSE' - ; + : 'FALSE' + ; IF - : 'IF' - ; + : 'IF' + ; THEN - : 'THEN' - ; + : 'THEN' + ; ELSIF - : 'ELSIF' - ; + : 'ELSIF' + ; ELSE - : 'ELSE' - ; + : 'ELSE' + ; CASE - : 'CASE' - ; + : 'CASE' + ; WHILE - : 'WHILE' - ; + : 'WHILE' + ; DO - : 'DO' - ; + : 'DO' + ; REPEAT - : 'REPEAT' - ; + : 'REPEAT' + ; UNTIL - : 'UNTIL' - ; + : 'UNTIL' + ; FOR - : 'FOR' - ; + : 'FOR' + ; BY - : 'BY' - ; + : 'BY' + ; BEGIN - : 'BEGIN' - ; + : 'BEGIN' + ; RETURN - : 'RETURN' - ; + : 'RETURN' + ; CONST - : 'CONST' - ; + : 'CONST' + ; TYPE - : 'TYPE' - ; + : 'TYPE' + ; VAR - : 'VAR' - ; + : 'VAR' + ; MODULE - : 'MODULE' - ; + : 'MODULE' + ; IMPORT - : 'IMPORT' - ; + : 'IMPORT' + ; STRING - : ('"' .*? '"') - | (DIGIT HEXDIGIT* 'X') - ; + : ('"' .*? '"') + | (DIGIT HEXDIGIT* 'X') + ; HEXDIGIT - : DIGIT - | 'A' - | 'B' - | 'C' - | 'D' - | 'E' - | 'F' - ; + : DIGIT + | 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + ; IDENT - : LETTER (LETTER | DIGIT)* - ; + : LETTER (LETTER | DIGIT)* + ; LETTER - : [a-zA-Z] - ; + : [a-zA-Z] + ; DIGIT - : [0-9] - ; + : [0-9] + ; COMMENT - : '(*' .*? '*)' -> skip - ; + : '(*' .*? '*)' -> skip + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/objc/ObjectiveCLexer.g4 b/objc/ObjectiveCLexer.g4 index 4db1be0e61..44a33546de 100644 --- a/objc/ObjectiveCLexer.g4 +++ b/objc/ObjectiveCLexer.g4 @@ -26,365 +26,374 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ObjectiveCLexer; -channels { COMMENTS_CHANNEL, DIRECTIVE_CHANNEL, IGNORED_MACROS } +channels { + COMMENTS_CHANNEL, + DIRECTIVE_CHANNEL, + IGNORED_MACROS +} // Words you can't use -AUTO: 'auto'; -BREAK: 'break'; -CASE: 'case'; -CHAR: 'char'; -CONST: 'const'; -CONTINUE: 'continue'; -DEFAULT: 'default'; -DO: 'do'; -DOUBLE: 'double'; -ELSE: 'else'; -ENUM: 'enum'; -EXTERN: 'extern'; -FLOAT: 'float'; -FOR: 'for'; -GOTO: 'goto'; -IF: 'if'; -INLINE: 'inline'; -INT: 'int'; -LONG: 'long'; -REGISTER: 'register'; -RESTRICT: 'restrict'; -RETURN: 'return'; -SHORT: 'short'; -SIGNED: 'signed'; -SIZEOF: 'sizeof'; -STATIC: 'static'; -STRUCT: 'struct'; -SWITCH: 'switch'; -TYPEDEF: 'typedef'; -UNION: 'union'; -UNSIGNED: 'unsigned'; -VOID: 'void'; -VOLATILE: 'volatile'; -WHILE: 'while'; -BOOL_: '_Bool'; -COMPLEX: '_Complex'; -IMAGINERY: '_Imaginery'; -TRUE: 'true'; -FALSE: 'false'; +AUTO : 'auto'; +BREAK : 'break'; +CASE : 'case'; +CHAR : 'char'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXTERN : 'extern'; +FLOAT : 'float'; +FOR : 'for'; +GOTO : 'goto'; +IF : 'if'; +INLINE : 'inline'; +INT : 'int'; +LONG : 'long'; +REGISTER : 'register'; +RESTRICT : 'restrict'; +RETURN : 'return'; +SHORT : 'short'; +SIGNED : 'signed'; +SIZEOF : 'sizeof'; +STATIC : 'static'; +STRUCT : 'struct'; +SWITCH : 'switch'; +TYPEDEF : 'typedef'; +UNION : 'union'; +UNSIGNED : 'unsigned'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; +BOOL_ : '_Bool'; +COMPLEX : '_Complex'; +IMAGINERY : '_Imaginery'; +TRUE : 'true'; +FALSE : 'false'; // Words you shouldn't use -BOOL: 'BOOL'; -Class: 'Class'; -BYCOPY: 'bycopy'; -BYREF: 'byref'; -ID: 'id'; -IMP: 'IMP'; -IN: 'in'; -INOUT: 'inout'; -NIL: 'nil'; -NO: 'NO'; -NULL_: 'NULL'; -ONEWAY: 'oneway'; -OUT: 'out'; -PROTOCOL_: 'Protocol'; -SEL: 'SEL'; -SELF: 'self'; -SUPER: 'super'; -YES: 'YES'; -AUTORELEASEPOOL: '@autoreleasepool'; -CATCH: '@catch'; -CLASS: '@class'; -DYNAMIC: '@dynamic'; -ENCODE: '@encode'; -END: '@end'; -FINALLY: '@finally'; -IMPLEMENTATION: '@implementation'; -INTERFACE: '@interface'; -IMPORT: '@import'; -PACKAGE: '@package'; -PROTOCOL: '@protocol'; -OPTIONAL: '@optional'; -PRIVATE: '@private'; -PROPERTY: '@property'; -PROTECTED: '@protected'; -PUBLIC: '@public'; -REQUIRED: '@required'; -SELECTOR: '@selector'; -SYNCHRONIZED: '@synchronized'; -SYNTHESIZE: '@synthesize'; -THROW: '@throw'; -TRY: '@try'; -ATOMIC: 'atomic'; -NONATOMIC: 'nonatomic'; -RETAIN: 'retain'; +BOOL : 'BOOL'; +Class : 'Class'; +BYCOPY : 'bycopy'; +BYREF : 'byref'; +ID : 'id'; +IMP : 'IMP'; +IN : 'in'; +INOUT : 'inout'; +NIL : 'nil'; +NO : 'NO'; +NULL_ : 'NULL'; +ONEWAY : 'oneway'; +OUT : 'out'; +PROTOCOL_ : 'Protocol'; +SEL : 'SEL'; +SELF : 'self'; +SUPER : 'super'; +YES : 'YES'; +AUTORELEASEPOOL : '@autoreleasepool'; +CATCH : '@catch'; +CLASS : '@class'; +DYNAMIC : '@dynamic'; +ENCODE : '@encode'; +END : '@end'; +FINALLY : '@finally'; +IMPLEMENTATION : '@implementation'; +INTERFACE : '@interface'; +IMPORT : '@import'; +PACKAGE : '@package'; +PROTOCOL : '@protocol'; +OPTIONAL : '@optional'; +PRIVATE : '@private'; +PROPERTY : '@property'; +PROTECTED : '@protected'; +PUBLIC : '@public'; +REQUIRED : '@required'; +SELECTOR : '@selector'; +SYNCHRONIZED : '@synchronized'; +SYNTHESIZE : '@synthesize'; +THROW : '@throw'; +TRY : '@try'; +ATOMIC : 'atomic'; +NONATOMIC : 'nonatomic'; +RETAIN : 'retain'; // Attributes with `__` prefix -ATTRIBUTE: '__attribute__'; -AUTORELEASING_QUALIFIER: '__autoreleasing'; -BLOCK: '__block'; -BRIDGE: '__bridge'; -BRIDGE_RETAINED: '__bridge_retained'; -BRIDGE_TRANSFER: '__bridge_transfer'; -COVARIANT: '__covariant'; -CONTRAVARIANT: '__contravariant'; -DEPRECATED: '__deprecated'; -KINDOF: '__kindof'; -STRONG_QUALIFIER: '__strong'; -TYPEOF: 'typeof' | '__typeof' | '__typeof__'; -UNSAFE_UNRETAINED_QUALIFIER:'__unsafe_unretained'; -UNUSED: '__unused'; -WEAK_QUALIFIER: '__weak'; +ATTRIBUTE : '__attribute__'; +AUTORELEASING_QUALIFIER : '__autoreleasing'; +BLOCK : '__block'; +BRIDGE : '__bridge'; +BRIDGE_RETAINED : '__bridge_retained'; +BRIDGE_TRANSFER : '__bridge_transfer'; +COVARIANT : '__covariant'; +CONTRAVARIANT : '__contravariant'; +DEPRECATED : '__deprecated'; +KINDOF : '__kindof'; +STRONG_QUALIFIER : '__strong'; +TYPEOF : 'typeof' | '__typeof' | '__typeof__'; +UNSAFE_UNRETAINED_QUALIFIER : '__unsafe_unretained'; +UNUSED : '__unused'; +WEAK_QUALIFIER : '__weak'; // Nullability specifiers -NULL_UNSPECIFIED: 'null_unspecified' | '__null_unspecified' | '_Null_unspecified'; -NULLABLE: 'nullable' | '__nullable' | '_Nullable'; -NONNULL: 'nonnull' | '__nonnull' | '_Nonnull'; -NULL_RESETTABLE: 'null_resettable'; +NULL_UNSPECIFIED : 'null_unspecified' | '__null_unspecified' | '_Null_unspecified'; +NULLABLE : 'nullable' | '__nullable' | '_Nullable'; +NONNULL : 'nonnull' | '__nonnull' | '_Nonnull'; +NULL_RESETTABLE : 'null_resettable'; // NS prefix -NS_INLINE: 'NS_INLINE'; -NS_ENUM: 'NS_ENUM'; -NS_OPTIONS: 'NS_OPTIONS'; +NS_INLINE : 'NS_INLINE'; +NS_ENUM : 'NS_ENUM'; +NS_OPTIONS : 'NS_OPTIONS'; // Property attributes -ASSIGN: 'assign'; -COPY: 'copy'; -GETTER: 'getter'; -SETTER: 'setter'; -STRONG: 'strong'; -READONLY: 'readonly'; -READWRITE: 'readwrite'; -WEAK: 'weak'; -UNSAFE_UNRETAINED: 'unsafe_unretained'; +ASSIGN : 'assign'; +COPY : 'copy'; +GETTER : 'getter'; +SETTER : 'setter'; +STRONG : 'strong'; +READONLY : 'readonly'; +READWRITE : 'readwrite'; +WEAK : 'weak'; +UNSAFE_UNRETAINED : 'unsafe_unretained'; // Interface Builder attributes -IB_OUTLET: 'IBOutlet'; -IB_OUTLET_COLLECTION: 'IBOutletCollection'; -IB_INSPECTABLE: 'IBInspectable'; -IB_DESIGNABLE: 'IB_DESIGNABLE'; +IB_OUTLET : 'IBOutlet'; +IB_OUTLET_COLLECTION : 'IBOutletCollection'; +IB_INSPECTABLE : 'IBInspectable'; +IB_DESIGNABLE : 'IB_DESIGNABLE'; // Ignored macros -NS_ASSUME_NONNULL_BEGIN: 'NS_ASSUME_NONNULL_BEGIN' ~[\r\n]* -> channel(IGNORED_MACROS); -NS_ASSUME_NONNULL_END: 'NS_ASSUME_NONNULL_END' ~[\r\n]* -> channel(IGNORED_MACROS); -EXTERN_SUFFIX: [_A-Z]+ '_EXTERN' -> channel(IGNORED_MACROS); -IOS_SUFFIX: [_A-Z]+ '_IOS(' ~')'+ ')' -> channel(IGNORED_MACROS); -MAC_SUFFIX: [_A-Z]+ '_MAC(' ~')'+ ')' -> channel(IGNORED_MACROS); -TVOS_PROHIBITED: '__TVOS_PROHIBITED' -> channel(IGNORED_MACROS); +NS_ASSUME_NONNULL_BEGIN : 'NS_ASSUME_NONNULL_BEGIN' ~[\r\n]* -> channel(IGNORED_MACROS); +NS_ASSUME_NONNULL_END : 'NS_ASSUME_NONNULL_END' ~[\r\n]* -> channel(IGNORED_MACROS); +EXTERN_SUFFIX : [_A-Z]+ '_EXTERN' -> channel(IGNORED_MACROS); +IOS_SUFFIX : [_A-Z]+ '_IOS(' ~')'+ ')' -> channel(IGNORED_MACROS); +MAC_SUFFIX : [_A-Z]+ '_MAC(' ~')'+ ')' -> channel(IGNORED_MACROS); +TVOS_PROHIBITED : '__TVOS_PROHIBITED' -> channel(IGNORED_MACROS); // Identifier -IDENTIFIER: Letter LetterOrDec*; +IDENTIFIER: Letter LetterOrDec*; // Separators -LP: '('; -RP: ')'; -LBRACE: '{'; -RBRACE: '}'; -LBRACK: '['; -RBRACK: ']'; -SEMI: ';'; -COMMA: ','; -DOT: '.'; -STRUCTACCESS: '->'; -AT: '@'; +LP : '('; +RP : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +STRUCTACCESS : '->'; +AT : '@'; // Operators -ASSIGNMENT: '='; -GT: '>'; -LT: '<'; -BANG: '!'; -TILDE: '~'; -QUESTION: '?'; -COLON: ':'; -EQUAL: '=='; -LE: '<='; -GE: '>='; -NOTEQUAL: '!='; -AND: '&&'; -OR: '||'; -INC: '++'; -DEC: '--'; -ADD: '+'; -SUB: '-'; -MUL: '*'; -DIV: '/'; -BITAND: '&'; -BITOR: '|'; -BITXOR: '^'; -MOD: '%'; +ASSIGNMENT : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +EQUAL : '=='; +LE : '<='; +GE : '>='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +BITXOR : '^'; +MOD : '%'; // Assignments -ADD_ASSIGN: '+='; -SUB_ASSIGN: '-='; -MUL_ASSIGN: '*='; -DIV_ASSIGN: '/='; -AND_ASSIGN: '&='; -OR_ASSIGN: '|='; -XOR_ASSIGN: '^='; -MOD_ASSIGN: '%='; -LSHIFT_ASSIGN: '<<='; -RSHIFT_ASSIGN: '>>='; -ELIPSIS: '...'; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; +ELIPSIS : '...'; // Literals -CHARACTER_LITERAL: '\'' (EscapeSequence | ~('\'' | '\\')) '\''; -STRING_START: StringStart -> mode(STRING_MODE); +CHARACTER_LITERAL : '\'' (EscapeSequence | ~('\'' | '\\')) '\''; +STRING_START : StringStart -> mode(STRING_MODE); -HEX_LITERAL: '0' [xX] HexDigit+ IntegerTypeSuffix?; -OCTAL_LITERAL: '0' [0-7]+ IntegerTypeSuffix?; -BINARY_LITERAL: '0' [bB] [01]+ IntegerTypeSuffix?; -DECIMAL_LITERAL: [0-9]+ IntegerTypeSuffix?; +HEX_LITERAL : '0' [xX] HexDigit+ IntegerTypeSuffix?; +OCTAL_LITERAL : '0' [0-7]+ IntegerTypeSuffix?; +BINARY_LITERAL : '0' [bB] [01]+ IntegerTypeSuffix?; +DECIMAL_LITERAL : [0-9]+ IntegerTypeSuffix?; -FLOATING_POINT_LITERAL - : (Dec+ '.' Dec* | '.' Dec+) Exponent? FloatTypeSuffix? - | Dec+ (Exponent FloatTypeSuffix? | FloatTypeSuffix) - ; +FLOATING_POINT_LITERAL: + (Dec+ '.' Dec* | '.' Dec+) Exponent? FloatTypeSuffix? + | Dec+ (Exponent FloatTypeSuffix? | FloatTypeSuffix) +; // Comments and whitespaces -WS: Ws+ -> channel(HIDDEN); -MULTI_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); -SINGLE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); -BACKSLASH: '\\' -> channel(HIDDEN); +WS : Ws+ -> channel(HIDDEN); +MULTI_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +SINGLE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); +BACKSLASH : '\\' -> channel(HIDDEN); -SHARP: '#' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_MODE); +SHARP: '#' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_MODE); // Strings mode STRING_MODE; -STRING_NEWLINE: '\\' '\r'? '\n' -> channel(DEFAULT_TOKEN_CHANNEL); -STRING_ESCAPE: EscapeSequence -> channel(DEFAULT_TOKEN_CHANNEL), type(STRING_VALUE); -STRING_END: '"' -> channel(DEFAULT_TOKEN_CHANNEL), mode(DEFAULT_MODE); -STRING_VALUE: ~["\\]+ -> channel(DEFAULT_TOKEN_CHANNEL); +STRING_NEWLINE : '\\' '\r'? '\n' -> channel(DEFAULT_TOKEN_CHANNEL); +STRING_ESCAPE : EscapeSequence -> channel(DEFAULT_TOKEN_CHANNEL), type(STRING_VALUE); +STRING_END : '"' -> channel(DEFAULT_TOKEN_CHANNEL), mode(DEFAULT_MODE); +STRING_VALUE : ~["\\]+ -> channel(DEFAULT_TOKEN_CHANNEL); // Preprocessor directives mode DIRECTIVE_MODE; -DIRECTIVE_IMPORT: 'import' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); -DIRECTIVE_INCLUDE: 'include' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); -DIRECTIVE_PRAGMA: 'pragma' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); - -DIRECTIVE_DEFINE: 'define' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DEFINE); -DIRECTIVE_DEFINED: 'defined' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_IF: 'if' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ELIF: 'elif' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ELSE: 'else' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_UNDEF: 'undef' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_IFDEF: 'ifdef' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_IFNDEF: 'ifndef' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ENDIF: 'endif' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_TRUE: T R U E -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_FALSE: F A L S E -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ERROR: 'error' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); -DIRECTIVE_WARNING: 'warning' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); - -DIRECTIVE_BANG: '!' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_LP: '(' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_RP: ')' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_EQUAL: '==' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_NOTEQUAL: '!=' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_AND: '&&' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_OR: '||' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_LT: '<' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_GT: '>' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_LE: '<=' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_GE: '>=' -> channel(DIRECTIVE_CHANNEL); - -DIRECTIVE_WS: [ \t]+ -> channel(HIDDEN), type(WS); -DIRECTIVE_STRING: StringStart -> channel(DEFAULT_TOKEN_CHANNEL), mode(STRING_MODE); -DIRECTIVE_ID: Letter LetterOrDec* -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_DECIMAL_LITERAL: Dec+ -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_FLOAT: (Dec+ '.' Dec* | '.' Dec+) -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_NEWLINE: '\r'? '\n' -> channel(HIDDEN), mode(DEFAULT_MODE); -DIRECTIVE_MULTI_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); -DIRECTIVE_SINGLE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); -DIRECTIVE_BACKSLASH_NEWLINE: '\\' '\r'? '\n' -> skip; +DIRECTIVE_IMPORT : 'import' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_INCLUDE : 'include' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_PRAGMA : 'pragma' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); + +DIRECTIVE_DEFINE : 'define' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DEFINE); +DIRECTIVE_DEFINED : 'defined' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_IF : 'if' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ELIF : 'elif' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ELSE : 'else' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_UNDEF : 'undef' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_IFDEF : 'ifdef' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_IFNDEF : 'ifndef' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ENDIF : 'endif' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_TRUE : T R U E -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_FALSE : F A L S E -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ERROR : 'error' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_WARNING : 'warning' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); + +DIRECTIVE_BANG : '!' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_LP : '(' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_RP : ')' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_EQUAL : '==' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_NOTEQUAL : '!=' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_AND : '&&' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_OR : '||' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_LT : '<' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_GT : '>' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_LE : '<=' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_GE : '>=' -> channel(DIRECTIVE_CHANNEL); + +DIRECTIVE_WS : [ \t]+ -> channel(HIDDEN), type(WS); +DIRECTIVE_STRING : StringStart -> channel(DEFAULT_TOKEN_CHANNEL), mode(STRING_MODE); +DIRECTIVE_ID : Letter LetterOrDec* -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_DECIMAL_LITERAL : Dec+ -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_FLOAT : (Dec+ '.' Dec* | '.' Dec+) -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_NEWLINE : '\r'? '\n' -> channel(HIDDEN), mode(DEFAULT_MODE); +DIRECTIVE_MULTI_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +DIRECTIVE_SINGLE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); +DIRECTIVE_BACKSLASH_NEWLINE : '\\' '\r'? '\n' -> skip; mode DEFINE; -DIRECTIVE_DEFINE_ID: Letter LetterOrDec* ('(' (LetterOrDec | [,. \t])* ')')? -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_ID), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_DEFINE_ID: + Letter LetterOrDec* ('(' (LetterOrDec | [,. \t])* ')')? -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_ID), mode(DIRECTIVE_TEXT_MODE) +; mode DIRECTIVE_TEXT_MODE; -DIRECTIVE_TEXT_NEWLINE: '\\' '\r'? '\n' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_BACKSLASH_ESCAPE: '\\' . -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); -DIRECTIVE_TEXT_BACKSLASH_NEWLINE: '\r'? '\n' -> channel(HIDDEN), type(DIRECTIVE_NEWLINE), mode(DEFAULT_MODE); -DIRECTIVE_TEXT_MULTI_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_MULTI_COMMENT); -DIRECTIVE_TEXT_SINGLE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_SINGLE_COMMENT); -DIRECTIVE_SLASH: '/' -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); -DIRECTIVE_TEXT: ~[\r\n\\/]+ -> channel(DIRECTIVE_CHANNEL); - -fragment LetterOrDec - : Letter - | Dec - ; - -fragment Letter - : [$A-Za-z_] +DIRECTIVE_TEXT_NEWLINE : '\\' '\r'? '\n' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_BACKSLASH_ESCAPE : '\\' . -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); +DIRECTIVE_TEXT_BACKSLASH_NEWLINE: + '\r'? '\n' -> channel(HIDDEN), type(DIRECTIVE_NEWLINE), mode(DEFAULT_MODE) +; +DIRECTIVE_TEXT_MULTI_COMMENT: + '/*' .*? '*/' -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_MULTI_COMMENT) +; +DIRECTIVE_TEXT_SINGLE_COMMENT: + '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_SINGLE_COMMENT) +; +DIRECTIVE_SLASH : '/' -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); +DIRECTIVE_TEXT : ~[\r\n\\/]+ -> channel(DIRECTIVE_CHANNEL); + +fragment LetterOrDec: Letter | Dec; + +fragment Letter: + [$A-Za-z_] | ~[\u0000-\u00FF\uD800-\uDBFF] | [\uD800-\uDBFF] [\uDC00-\uDFFF] | [\u00E9] - ; +; -fragment IntegerTypeSuffix: [uUlL] [uUlL]? [uUlL]?; -fragment Exponent: [eE] [+\-]? Dec+; -fragment Dec: [0-9]; -fragment FloatTypeSuffix: [fFdD]; +fragment IntegerTypeSuffix : [uUlL] [uUlL]? [uUlL]?; +fragment Exponent : [eE] [+\-]? Dec+; +fragment Dec : [0-9]; +fragment FloatTypeSuffix : [fFdD]; -fragment StringStart: (('L' | '@') Ws*)? '"'; +fragment StringStart: (('L' | '@') Ws*)? '"'; -fragment EscapeSequence - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') +fragment EscapeSequence: + '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') | OctalEscape | UnicodeEscape - ; - -fragment OctalEscape - : '\\' [0-3] [0-7] [0-7] - | '\\' [0-7] [0-7] - | '\\' [0-7] - ; - -fragment UnicodeEscape: '\\' 'u' HexDigit HexDigit HexDigit HexDigit; -fragment HexDigit: [0-9a-fA-F]; - -fragment Ws: [ \r\n\t\u000C]; -fragment A: [aA]; -fragment B: [bB]; -fragment C: [cC]; -fragment D: [dD]; -fragment E: [eE]; -fragment F: [fF]; -fragment G: [gG]; -fragment H: [hH]; -fragment I: [iI]; -fragment J: [jJ]; -fragment K: [kK]; -fragment L: [lL]; -fragment M: [mM]; -fragment N: [nN]; -fragment O: [oO]; -fragment P: [pP]; -fragment Q: [qQ]; -fragment R: [rR]; -fragment S: [sS]; -fragment T: [tT]; -fragment U: [uU]; -fragment V: [vV]; -fragment W: [wW]; -fragment X: [xX]; -fragment Y: [yY]; -fragment Z: [zZ]; +; + +fragment OctalEscape: '\\' [0-3] [0-7] [0-7] | '\\' [0-7] [0-7] | '\\' [0-7]; + +fragment UnicodeEscape : '\\' 'u' HexDigit HexDigit HexDigit HexDigit; +fragment HexDigit : [0-9a-fA-F]; + +fragment Ws : [ \r\n\t\u000C]; +fragment A : [aA]; +fragment B : [bB]; +fragment C : [cC]; +fragment D : [dD]; +fragment E : [eE]; +fragment F : [fF]; +fragment G : [gG]; +fragment H : [hH]; +fragment I : [iI]; +fragment J : [jJ]; +fragment K : [kK]; +fragment L : [lL]; +fragment M : [mM]; +fragment N : [nN]; +fragment O : [oO]; +fragment P : [pP]; +fragment Q : [qQ]; +fragment R : [rR]; +fragment S : [sS]; +fragment T : [tT]; +fragment U : [uU]; +fragment V : [vV]; +fragment W : [wW]; +fragment X : [xX]; +fragment Y : [yY]; +fragment Z : [zZ]; \ No newline at end of file diff --git a/objc/ObjectiveCParser.g4 b/objc/ObjectiveCParser.g4 index 4599c956aa..de552191f3 100644 --- a/objc/ObjectiveCParser.g4 +++ b/objc/ObjectiveCParser.g4 @@ -26,9 +26,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 ObjectiveCParser; -options { tokenVocab=ObjectiveCLexer; } +options { + tokenVocab = ObjectiveCLexer; +} translationUnit : topLevelDeclaration* EOF @@ -53,28 +58,23 @@ importDeclaration ; classInterface - : IB_DESIGNABLE? - '@interface' - className=genericTypeSpecifier (':' superclassName=identifier)? (LT protocolList GT)? instanceVariables? interfaceDeclarationList? - '@end' + : IB_DESIGNABLE? '@interface' className = genericTypeSpecifier ( + ':' superclassName = identifier + )? (LT protocolList GT)? instanceVariables? interfaceDeclarationList? '@end' ; categoryInterface - : '@interface' - categoryName=genericTypeSpecifier LP className=identifier? RP (LT protocolList GT)? instanceVariables? interfaceDeclarationList? - '@end' + : '@interface' categoryName = genericTypeSpecifier LP className = identifier? RP ( + LT protocolList GT + )? instanceVariables? interfaceDeclarationList? '@end' ; classImplementation - : '@implementation' - className=genericTypeSpecifier (':' superclassName=identifier)? instanceVariables? implementationDefinitionList? - '@end' + : '@implementation' className = genericTypeSpecifier (':' superclassName = identifier)? instanceVariables? implementationDefinitionList? '@end' ; categoryImplementation - : '@implementation' - className=genericTypeSpecifier LP categoryName=identifier RP implementationDefinitionList? - '@end' + : '@implementation' className = genericTypeSpecifier LP categoryName = identifier RP implementationDefinitionList? '@end' ; genericTypeSpecifier @@ -82,13 +82,11 @@ genericTypeSpecifier ; protocolDeclaration - : '@protocol' - protocolName (LT protocolList GT)? protocolDeclarationSection* - '@end' + : '@protocol' protocolName (LT protocolList GT)? protocolDeclarationSection* '@end' ; protocolDeclarationSection - : modifier=(REQUIRED | OPTIONAL) interfaceDeclarationList* + : modifier = (REQUIRED | OPTIONAL) interfaceDeclarationList* | interfaceDeclarationList+ ; @@ -131,7 +129,7 @@ propertyAttribute protocolName : LT protocolList GT - | ('__covariant' | '__contravariant')? identifier + | ('__covariant' | '__contravariant')? identifier ; instanceVariables @@ -151,11 +149,13 @@ accessModifier ; interfaceDeclarationList - : (declaration - | classMethodDeclaration - | instanceMethodDeclaration - | propertyDeclaration - | functionDeclaration)+ + : ( + declaration + | classMethodDeclaration + | instanceMethodDeclaration + | propertyDeclaration + | functionDeclaration + )+ ; classMethodDeclaration @@ -171,12 +171,14 @@ methodDeclaration ; implementationDefinitionList - : (functionDefinition - | declaration - | classMethodDefinition - | instanceMethodDefinition - | propertyImplementation - )+; + : ( + functionDefinition + | declaration + | classMethodDefinition + | instanceMethodDefinition + | propertyImplementation + )+ + ; classMethodDefinition : '+' methodDefinition @@ -222,7 +224,10 @@ propertySynthesizeItem ; blockType - : nullabilitySpecifier? typeSpecifier nullabilitySpecifier? LP '^' (nullabilitySpecifier | typeSpecifier)? RP blockParameters? + : nullabilitySpecifier? typeSpecifier nullabilitySpecifier? LP '^' ( + nullabilitySpecifier + | typeSpecifier + )? RP blockParameters? ; genericsSpecifier @@ -313,7 +318,9 @@ throwStatement ; tryBlock - : '@try' tryStatement=compoundStatement catchStatement* ('@finally' finallyStatement=compoundStatement)? + : '@try' tryStatement = compoundStatement catchStatement* ( + '@finally' finallyStatement = compoundStatement + )? ; catchStatement @@ -388,7 +395,10 @@ varDeclaration ; typedefDeclaration - : attributeSpecifier? TYPEDEF (declarationSpecifiers typeDeclaratorList | declarationSpecifiers) ';' + : attributeSpecifier? TYPEDEF ( + declarationSpecifiers typeDeclaratorList + | declarationSpecifiers + ) ';' ; typeDeclaratorList @@ -400,14 +410,16 @@ typeDeclarator ; declarationSpecifiers - : (storageClassSpecifier - | attributeSpecifier - | arcBehaviourSpecifier - | nullabilitySpecifier - | ibOutletQualifier - | typePrefix - | typeQualifier - | typeSpecifier)+ + : ( + storageClassSpecifier + | attributeSpecifier + | arcBehaviourSpecifier + | nullabilitySpecifier + | ibOutletQualifier + | typePrefix + | typeQualifier + | typeSpecifier + )+ ; attributeSpecifier @@ -431,12 +443,14 @@ fieldDeclaration ; specifierQualifierList - : (arcBehaviourSpecifier - | nullabilitySpecifier - | ibOutletQualifier - | typePrefix - | typeQualifier - | typeSpecifier)+ + : ( + arcBehaviourSpecifier + | nullabilitySpecifier + | ibOutletQualifier + | typePrefix + | typeQualifier + | typeSpecifier + )+ ; ibOutletQualifier @@ -522,7 +536,10 @@ fieldDeclarator ; enumSpecifier - : 'enum' (identifier? ':' typeName)? (identifier ('{' enumeratorList '}')? | '{' enumeratorList '}') + : 'enum' (identifier? ':' typeName)? ( + identifier ('{' enumeratorList '}')? + | '{' enumeratorList '}' + ) | ('NS_OPTIONS' | 'NS_ENUM') LP typeName ',' identifier RP '{' enumeratorList '}' ; @@ -620,7 +637,7 @@ labeledStatement ; rangeExpression - : constantExpression ('...' constantExpression)? + : constantExpression ('...' constantExpression)? ; compoundStatement @@ -628,7 +645,7 @@ compoundStatement ; selectionStatement - : IF LP expression RP ifBody=statement (ELSE elseBody=statement)? + : IF LP expression RP ifBody = statement (ELSE elseBody = statement)? | switchStatement ; @@ -690,26 +707,33 @@ expressions expression : castExpression - - | expression op=(MUL | DIV | MOD) expression - | expression op=(ADD | SUB) expression + | expression op = (MUL | DIV | MOD) expression + | expression op = (ADD | SUB) expression | expression (LT LT | GT GT) expression - | expression op=(LE | GE | LT | GT) expression - | expression op=(NOTEQUAL | EQUAL) expression - | expression op=BITAND expression - | expression op=BITXOR expression - | expression op=BITOR expression - | expression op=AND expression - | expression op=OR expression - - | expression QUESTION trueExpression=expression? COLON falseExpression=expression + | expression op = (LE | GE | LT | GT) expression + | expression op = (NOTEQUAL | EQUAL) expression + | expression op = BITAND expression + | expression op = BITXOR expression + | expression op = BITOR expression + | expression op = AND expression + | expression op = OR expression + | expression QUESTION trueExpression = expression? COLON falseExpression = expression | LP compoundStatement RP - - | unaryExpression assignmentOperator assignmentExpression=expression + | unaryExpression assignmentOperator assignmentExpression = expression ; assignmentOperator - : '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|=' + : '=' + | '*=' + | '/=' + | '%=' + | '+=' + | '-=' + | '<<=' + | '>>=' + | '&=' + | '^=' + | '|=' ; castExpression @@ -731,7 +755,7 @@ constantExpression unaryExpression : postfixExpression | SIZEOF (unaryExpression | LP typeSpecifier RP) - | op=(INC | DEC) unaryExpression + | op = (INC | DEC) unaryExpression | unaryOperator castExpression ; @@ -746,14 +770,14 @@ unaryOperator postfixExpression : primaryExpression postfix* - | postfixExpression (DOT | STRUCTACCESS) identifier postfix* // TODO: get rid of property and postfix expression. + | postfixExpression (DOT | STRUCTACCESS) identifier postfix* // TODO: get rid of property and postfix expression. ; postfix : LBRACK expression RBRACK | LP argumentExpressionList? RP - | LP (COMMA | macroArguments+=~RP)+ RP - | op=(INC | DEC) + | LP (COMMA | macroArguments += ~RP)+ RP + | op = (INC | DEC) ; argumentExpressionList @@ -801,7 +825,6 @@ stringLiteral identifier : IDENTIFIER - | BOOL | Class | BYCOPY @@ -819,7 +842,6 @@ identifier | ATOMIC | NONATOMIC | RETAIN - | AUTORELEASING_QUALIFIER | BLOCK | BRIDGE_RETAINED @@ -829,16 +851,13 @@ identifier | DEPRECATED | KINDOF | UNUSED - | NS_INLINE | NS_ENUM | NS_OPTIONS - | NULL_UNSPECIFIED | NULLABLE | NONNULL | NULL_RESETTABLE - | ASSIGN | COPY | GETTER @@ -848,9 +867,8 @@ identifier | READWRITE | WEAK | UNSAFE_UNRETAINED - | IB_OUTLET | IB_OUTLET_COLLECTION | IB_INSPECTABLE | IB_DESIGNABLE - ; + ; \ No newline at end of file diff --git a/objc/one-step-processing/ObjectiveCLexer.g4 b/objc/one-step-processing/ObjectiveCLexer.g4 index 4db1be0e61..44a33546de 100644 --- a/objc/one-step-processing/ObjectiveCLexer.g4 +++ b/objc/one-step-processing/ObjectiveCLexer.g4 @@ -26,365 +26,374 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ObjectiveCLexer; -channels { COMMENTS_CHANNEL, DIRECTIVE_CHANNEL, IGNORED_MACROS } +channels { + COMMENTS_CHANNEL, + DIRECTIVE_CHANNEL, + IGNORED_MACROS +} // Words you can't use -AUTO: 'auto'; -BREAK: 'break'; -CASE: 'case'; -CHAR: 'char'; -CONST: 'const'; -CONTINUE: 'continue'; -DEFAULT: 'default'; -DO: 'do'; -DOUBLE: 'double'; -ELSE: 'else'; -ENUM: 'enum'; -EXTERN: 'extern'; -FLOAT: 'float'; -FOR: 'for'; -GOTO: 'goto'; -IF: 'if'; -INLINE: 'inline'; -INT: 'int'; -LONG: 'long'; -REGISTER: 'register'; -RESTRICT: 'restrict'; -RETURN: 'return'; -SHORT: 'short'; -SIGNED: 'signed'; -SIZEOF: 'sizeof'; -STATIC: 'static'; -STRUCT: 'struct'; -SWITCH: 'switch'; -TYPEDEF: 'typedef'; -UNION: 'union'; -UNSIGNED: 'unsigned'; -VOID: 'void'; -VOLATILE: 'volatile'; -WHILE: 'while'; -BOOL_: '_Bool'; -COMPLEX: '_Complex'; -IMAGINERY: '_Imaginery'; -TRUE: 'true'; -FALSE: 'false'; +AUTO : 'auto'; +BREAK : 'break'; +CASE : 'case'; +CHAR : 'char'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXTERN : 'extern'; +FLOAT : 'float'; +FOR : 'for'; +GOTO : 'goto'; +IF : 'if'; +INLINE : 'inline'; +INT : 'int'; +LONG : 'long'; +REGISTER : 'register'; +RESTRICT : 'restrict'; +RETURN : 'return'; +SHORT : 'short'; +SIGNED : 'signed'; +SIZEOF : 'sizeof'; +STATIC : 'static'; +STRUCT : 'struct'; +SWITCH : 'switch'; +TYPEDEF : 'typedef'; +UNION : 'union'; +UNSIGNED : 'unsigned'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; +BOOL_ : '_Bool'; +COMPLEX : '_Complex'; +IMAGINERY : '_Imaginery'; +TRUE : 'true'; +FALSE : 'false'; // Words you shouldn't use -BOOL: 'BOOL'; -Class: 'Class'; -BYCOPY: 'bycopy'; -BYREF: 'byref'; -ID: 'id'; -IMP: 'IMP'; -IN: 'in'; -INOUT: 'inout'; -NIL: 'nil'; -NO: 'NO'; -NULL_: 'NULL'; -ONEWAY: 'oneway'; -OUT: 'out'; -PROTOCOL_: 'Protocol'; -SEL: 'SEL'; -SELF: 'self'; -SUPER: 'super'; -YES: 'YES'; -AUTORELEASEPOOL: '@autoreleasepool'; -CATCH: '@catch'; -CLASS: '@class'; -DYNAMIC: '@dynamic'; -ENCODE: '@encode'; -END: '@end'; -FINALLY: '@finally'; -IMPLEMENTATION: '@implementation'; -INTERFACE: '@interface'; -IMPORT: '@import'; -PACKAGE: '@package'; -PROTOCOL: '@protocol'; -OPTIONAL: '@optional'; -PRIVATE: '@private'; -PROPERTY: '@property'; -PROTECTED: '@protected'; -PUBLIC: '@public'; -REQUIRED: '@required'; -SELECTOR: '@selector'; -SYNCHRONIZED: '@synchronized'; -SYNTHESIZE: '@synthesize'; -THROW: '@throw'; -TRY: '@try'; -ATOMIC: 'atomic'; -NONATOMIC: 'nonatomic'; -RETAIN: 'retain'; +BOOL : 'BOOL'; +Class : 'Class'; +BYCOPY : 'bycopy'; +BYREF : 'byref'; +ID : 'id'; +IMP : 'IMP'; +IN : 'in'; +INOUT : 'inout'; +NIL : 'nil'; +NO : 'NO'; +NULL_ : 'NULL'; +ONEWAY : 'oneway'; +OUT : 'out'; +PROTOCOL_ : 'Protocol'; +SEL : 'SEL'; +SELF : 'self'; +SUPER : 'super'; +YES : 'YES'; +AUTORELEASEPOOL : '@autoreleasepool'; +CATCH : '@catch'; +CLASS : '@class'; +DYNAMIC : '@dynamic'; +ENCODE : '@encode'; +END : '@end'; +FINALLY : '@finally'; +IMPLEMENTATION : '@implementation'; +INTERFACE : '@interface'; +IMPORT : '@import'; +PACKAGE : '@package'; +PROTOCOL : '@protocol'; +OPTIONAL : '@optional'; +PRIVATE : '@private'; +PROPERTY : '@property'; +PROTECTED : '@protected'; +PUBLIC : '@public'; +REQUIRED : '@required'; +SELECTOR : '@selector'; +SYNCHRONIZED : '@synchronized'; +SYNTHESIZE : '@synthesize'; +THROW : '@throw'; +TRY : '@try'; +ATOMIC : 'atomic'; +NONATOMIC : 'nonatomic'; +RETAIN : 'retain'; // Attributes with `__` prefix -ATTRIBUTE: '__attribute__'; -AUTORELEASING_QUALIFIER: '__autoreleasing'; -BLOCK: '__block'; -BRIDGE: '__bridge'; -BRIDGE_RETAINED: '__bridge_retained'; -BRIDGE_TRANSFER: '__bridge_transfer'; -COVARIANT: '__covariant'; -CONTRAVARIANT: '__contravariant'; -DEPRECATED: '__deprecated'; -KINDOF: '__kindof'; -STRONG_QUALIFIER: '__strong'; -TYPEOF: 'typeof' | '__typeof' | '__typeof__'; -UNSAFE_UNRETAINED_QUALIFIER:'__unsafe_unretained'; -UNUSED: '__unused'; -WEAK_QUALIFIER: '__weak'; +ATTRIBUTE : '__attribute__'; +AUTORELEASING_QUALIFIER : '__autoreleasing'; +BLOCK : '__block'; +BRIDGE : '__bridge'; +BRIDGE_RETAINED : '__bridge_retained'; +BRIDGE_TRANSFER : '__bridge_transfer'; +COVARIANT : '__covariant'; +CONTRAVARIANT : '__contravariant'; +DEPRECATED : '__deprecated'; +KINDOF : '__kindof'; +STRONG_QUALIFIER : '__strong'; +TYPEOF : 'typeof' | '__typeof' | '__typeof__'; +UNSAFE_UNRETAINED_QUALIFIER : '__unsafe_unretained'; +UNUSED : '__unused'; +WEAK_QUALIFIER : '__weak'; // Nullability specifiers -NULL_UNSPECIFIED: 'null_unspecified' | '__null_unspecified' | '_Null_unspecified'; -NULLABLE: 'nullable' | '__nullable' | '_Nullable'; -NONNULL: 'nonnull' | '__nonnull' | '_Nonnull'; -NULL_RESETTABLE: 'null_resettable'; +NULL_UNSPECIFIED : 'null_unspecified' | '__null_unspecified' | '_Null_unspecified'; +NULLABLE : 'nullable' | '__nullable' | '_Nullable'; +NONNULL : 'nonnull' | '__nonnull' | '_Nonnull'; +NULL_RESETTABLE : 'null_resettable'; // NS prefix -NS_INLINE: 'NS_INLINE'; -NS_ENUM: 'NS_ENUM'; -NS_OPTIONS: 'NS_OPTIONS'; +NS_INLINE : 'NS_INLINE'; +NS_ENUM : 'NS_ENUM'; +NS_OPTIONS : 'NS_OPTIONS'; // Property attributes -ASSIGN: 'assign'; -COPY: 'copy'; -GETTER: 'getter'; -SETTER: 'setter'; -STRONG: 'strong'; -READONLY: 'readonly'; -READWRITE: 'readwrite'; -WEAK: 'weak'; -UNSAFE_UNRETAINED: 'unsafe_unretained'; +ASSIGN : 'assign'; +COPY : 'copy'; +GETTER : 'getter'; +SETTER : 'setter'; +STRONG : 'strong'; +READONLY : 'readonly'; +READWRITE : 'readwrite'; +WEAK : 'weak'; +UNSAFE_UNRETAINED : 'unsafe_unretained'; // Interface Builder attributes -IB_OUTLET: 'IBOutlet'; -IB_OUTLET_COLLECTION: 'IBOutletCollection'; -IB_INSPECTABLE: 'IBInspectable'; -IB_DESIGNABLE: 'IB_DESIGNABLE'; +IB_OUTLET : 'IBOutlet'; +IB_OUTLET_COLLECTION : 'IBOutletCollection'; +IB_INSPECTABLE : 'IBInspectable'; +IB_DESIGNABLE : 'IB_DESIGNABLE'; // Ignored macros -NS_ASSUME_NONNULL_BEGIN: 'NS_ASSUME_NONNULL_BEGIN' ~[\r\n]* -> channel(IGNORED_MACROS); -NS_ASSUME_NONNULL_END: 'NS_ASSUME_NONNULL_END' ~[\r\n]* -> channel(IGNORED_MACROS); -EXTERN_SUFFIX: [_A-Z]+ '_EXTERN' -> channel(IGNORED_MACROS); -IOS_SUFFIX: [_A-Z]+ '_IOS(' ~')'+ ')' -> channel(IGNORED_MACROS); -MAC_SUFFIX: [_A-Z]+ '_MAC(' ~')'+ ')' -> channel(IGNORED_MACROS); -TVOS_PROHIBITED: '__TVOS_PROHIBITED' -> channel(IGNORED_MACROS); +NS_ASSUME_NONNULL_BEGIN : 'NS_ASSUME_NONNULL_BEGIN' ~[\r\n]* -> channel(IGNORED_MACROS); +NS_ASSUME_NONNULL_END : 'NS_ASSUME_NONNULL_END' ~[\r\n]* -> channel(IGNORED_MACROS); +EXTERN_SUFFIX : [_A-Z]+ '_EXTERN' -> channel(IGNORED_MACROS); +IOS_SUFFIX : [_A-Z]+ '_IOS(' ~')'+ ')' -> channel(IGNORED_MACROS); +MAC_SUFFIX : [_A-Z]+ '_MAC(' ~')'+ ')' -> channel(IGNORED_MACROS); +TVOS_PROHIBITED : '__TVOS_PROHIBITED' -> channel(IGNORED_MACROS); // Identifier -IDENTIFIER: Letter LetterOrDec*; +IDENTIFIER: Letter LetterOrDec*; // Separators -LP: '('; -RP: ')'; -LBRACE: '{'; -RBRACE: '}'; -LBRACK: '['; -RBRACK: ']'; -SEMI: ';'; -COMMA: ','; -DOT: '.'; -STRUCTACCESS: '->'; -AT: '@'; +LP : '('; +RP : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +STRUCTACCESS : '->'; +AT : '@'; // Operators -ASSIGNMENT: '='; -GT: '>'; -LT: '<'; -BANG: '!'; -TILDE: '~'; -QUESTION: '?'; -COLON: ':'; -EQUAL: '=='; -LE: '<='; -GE: '>='; -NOTEQUAL: '!='; -AND: '&&'; -OR: '||'; -INC: '++'; -DEC: '--'; -ADD: '+'; -SUB: '-'; -MUL: '*'; -DIV: '/'; -BITAND: '&'; -BITOR: '|'; -BITXOR: '^'; -MOD: '%'; +ASSIGNMENT : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +EQUAL : '=='; +LE : '<='; +GE : '>='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +BITXOR : '^'; +MOD : '%'; // Assignments -ADD_ASSIGN: '+='; -SUB_ASSIGN: '-='; -MUL_ASSIGN: '*='; -DIV_ASSIGN: '/='; -AND_ASSIGN: '&='; -OR_ASSIGN: '|='; -XOR_ASSIGN: '^='; -MOD_ASSIGN: '%='; -LSHIFT_ASSIGN: '<<='; -RSHIFT_ASSIGN: '>>='; -ELIPSIS: '...'; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; +ELIPSIS : '...'; // Literals -CHARACTER_LITERAL: '\'' (EscapeSequence | ~('\'' | '\\')) '\''; -STRING_START: StringStart -> mode(STRING_MODE); +CHARACTER_LITERAL : '\'' (EscapeSequence | ~('\'' | '\\')) '\''; +STRING_START : StringStart -> mode(STRING_MODE); -HEX_LITERAL: '0' [xX] HexDigit+ IntegerTypeSuffix?; -OCTAL_LITERAL: '0' [0-7]+ IntegerTypeSuffix?; -BINARY_LITERAL: '0' [bB] [01]+ IntegerTypeSuffix?; -DECIMAL_LITERAL: [0-9]+ IntegerTypeSuffix?; +HEX_LITERAL : '0' [xX] HexDigit+ IntegerTypeSuffix?; +OCTAL_LITERAL : '0' [0-7]+ IntegerTypeSuffix?; +BINARY_LITERAL : '0' [bB] [01]+ IntegerTypeSuffix?; +DECIMAL_LITERAL : [0-9]+ IntegerTypeSuffix?; -FLOATING_POINT_LITERAL - : (Dec+ '.' Dec* | '.' Dec+) Exponent? FloatTypeSuffix? - | Dec+ (Exponent FloatTypeSuffix? | FloatTypeSuffix) - ; +FLOATING_POINT_LITERAL: + (Dec+ '.' Dec* | '.' Dec+) Exponent? FloatTypeSuffix? + | Dec+ (Exponent FloatTypeSuffix? | FloatTypeSuffix) +; // Comments and whitespaces -WS: Ws+ -> channel(HIDDEN); -MULTI_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); -SINGLE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); -BACKSLASH: '\\' -> channel(HIDDEN); +WS : Ws+ -> channel(HIDDEN); +MULTI_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +SINGLE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); +BACKSLASH : '\\' -> channel(HIDDEN); -SHARP: '#' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_MODE); +SHARP: '#' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_MODE); // Strings mode STRING_MODE; -STRING_NEWLINE: '\\' '\r'? '\n' -> channel(DEFAULT_TOKEN_CHANNEL); -STRING_ESCAPE: EscapeSequence -> channel(DEFAULT_TOKEN_CHANNEL), type(STRING_VALUE); -STRING_END: '"' -> channel(DEFAULT_TOKEN_CHANNEL), mode(DEFAULT_MODE); -STRING_VALUE: ~["\\]+ -> channel(DEFAULT_TOKEN_CHANNEL); +STRING_NEWLINE : '\\' '\r'? '\n' -> channel(DEFAULT_TOKEN_CHANNEL); +STRING_ESCAPE : EscapeSequence -> channel(DEFAULT_TOKEN_CHANNEL), type(STRING_VALUE); +STRING_END : '"' -> channel(DEFAULT_TOKEN_CHANNEL), mode(DEFAULT_MODE); +STRING_VALUE : ~["\\]+ -> channel(DEFAULT_TOKEN_CHANNEL); // Preprocessor directives mode DIRECTIVE_MODE; -DIRECTIVE_IMPORT: 'import' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); -DIRECTIVE_INCLUDE: 'include' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); -DIRECTIVE_PRAGMA: 'pragma' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); - -DIRECTIVE_DEFINE: 'define' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DEFINE); -DIRECTIVE_DEFINED: 'defined' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_IF: 'if' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ELIF: 'elif' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ELSE: 'else' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_UNDEF: 'undef' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_IFDEF: 'ifdef' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_IFNDEF: 'ifndef' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ENDIF: 'endif' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_TRUE: T R U E -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_FALSE: F A L S E -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_ERROR: 'error' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); -DIRECTIVE_WARNING: 'warning' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); - -DIRECTIVE_BANG: '!' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_LP: '(' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_RP: ')' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_EQUAL: '==' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_NOTEQUAL: '!=' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_AND: '&&' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_OR: '||' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_LT: '<' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_GT: '>' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_LE: '<=' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_GE: '>=' -> channel(DIRECTIVE_CHANNEL); - -DIRECTIVE_WS: [ \t]+ -> channel(HIDDEN), type(WS); -DIRECTIVE_STRING: StringStart -> channel(DEFAULT_TOKEN_CHANNEL), mode(STRING_MODE); -DIRECTIVE_ID: Letter LetterOrDec* -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_DECIMAL_LITERAL: Dec+ -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_FLOAT: (Dec+ '.' Dec* | '.' Dec+) -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_NEWLINE: '\r'? '\n' -> channel(HIDDEN), mode(DEFAULT_MODE); -DIRECTIVE_MULTI_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); -DIRECTIVE_SINGLE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); -DIRECTIVE_BACKSLASH_NEWLINE: '\\' '\r'? '\n' -> skip; +DIRECTIVE_IMPORT : 'import' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_INCLUDE : 'include' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_PRAGMA : 'pragma' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); + +DIRECTIVE_DEFINE : 'define' [ \t]+ -> channel(DIRECTIVE_CHANNEL), mode(DEFINE); +DIRECTIVE_DEFINED : 'defined' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_IF : 'if' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ELIF : 'elif' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ELSE : 'else' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_UNDEF : 'undef' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_IFDEF : 'ifdef' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_IFNDEF : 'ifndef' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ENDIF : 'endif' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_TRUE : T R U E -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_FALSE : F A L S E -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_ERROR : 'error' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_WARNING : 'warning' -> channel(DIRECTIVE_CHANNEL), mode(DIRECTIVE_TEXT_MODE); + +DIRECTIVE_BANG : '!' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_LP : '(' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_RP : ')' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_EQUAL : '==' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_NOTEQUAL : '!=' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_AND : '&&' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_OR : '||' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_LT : '<' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_GT : '>' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_LE : '<=' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_GE : '>=' -> channel(DIRECTIVE_CHANNEL); + +DIRECTIVE_WS : [ \t]+ -> channel(HIDDEN), type(WS); +DIRECTIVE_STRING : StringStart -> channel(DEFAULT_TOKEN_CHANNEL), mode(STRING_MODE); +DIRECTIVE_ID : Letter LetterOrDec* -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_DECIMAL_LITERAL : Dec+ -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_FLOAT : (Dec+ '.' Dec* | '.' Dec+) -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_NEWLINE : '\r'? '\n' -> channel(HIDDEN), mode(DEFAULT_MODE); +DIRECTIVE_MULTI_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +DIRECTIVE_SINGLE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); +DIRECTIVE_BACKSLASH_NEWLINE : '\\' '\r'? '\n' -> skip; mode DEFINE; -DIRECTIVE_DEFINE_ID: Letter LetterOrDec* ('(' (LetterOrDec | [,. \t])* ')')? -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_ID), mode(DIRECTIVE_TEXT_MODE); +DIRECTIVE_DEFINE_ID: + Letter LetterOrDec* ('(' (LetterOrDec | [,. \t])* ')')? -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_ID), mode(DIRECTIVE_TEXT_MODE) +; mode DIRECTIVE_TEXT_MODE; -DIRECTIVE_TEXT_NEWLINE: '\\' '\r'? '\n' -> channel(DIRECTIVE_CHANNEL); -DIRECTIVE_BACKSLASH_ESCAPE: '\\' . -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); -DIRECTIVE_TEXT_BACKSLASH_NEWLINE: '\r'? '\n' -> channel(HIDDEN), type(DIRECTIVE_NEWLINE), mode(DEFAULT_MODE); -DIRECTIVE_TEXT_MULTI_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_MULTI_COMMENT); -DIRECTIVE_TEXT_SINGLE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_SINGLE_COMMENT); -DIRECTIVE_SLASH: '/' -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); -DIRECTIVE_TEXT: ~[\r\n\\/]+ -> channel(DIRECTIVE_CHANNEL); - -fragment LetterOrDec - : Letter - | Dec - ; - -fragment Letter - : [$A-Za-z_] +DIRECTIVE_TEXT_NEWLINE : '\\' '\r'? '\n' -> channel(DIRECTIVE_CHANNEL); +DIRECTIVE_BACKSLASH_ESCAPE : '\\' . -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); +DIRECTIVE_TEXT_BACKSLASH_NEWLINE: + '\r'? '\n' -> channel(HIDDEN), type(DIRECTIVE_NEWLINE), mode(DEFAULT_MODE) +; +DIRECTIVE_TEXT_MULTI_COMMENT: + '/*' .*? '*/' -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_MULTI_COMMENT) +; +DIRECTIVE_TEXT_SINGLE_COMMENT: + '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL), type(DIRECTIVE_SINGLE_COMMENT) +; +DIRECTIVE_SLASH : '/' -> channel(DIRECTIVE_CHANNEL), type(DIRECTIVE_TEXT); +DIRECTIVE_TEXT : ~[\r\n\\/]+ -> channel(DIRECTIVE_CHANNEL); + +fragment LetterOrDec: Letter | Dec; + +fragment Letter: + [$A-Za-z_] | ~[\u0000-\u00FF\uD800-\uDBFF] | [\uD800-\uDBFF] [\uDC00-\uDFFF] | [\u00E9] - ; +; -fragment IntegerTypeSuffix: [uUlL] [uUlL]? [uUlL]?; -fragment Exponent: [eE] [+\-]? Dec+; -fragment Dec: [0-9]; -fragment FloatTypeSuffix: [fFdD]; +fragment IntegerTypeSuffix : [uUlL] [uUlL]? [uUlL]?; +fragment Exponent : [eE] [+\-]? Dec+; +fragment Dec : [0-9]; +fragment FloatTypeSuffix : [fFdD]; -fragment StringStart: (('L' | '@') Ws*)? '"'; +fragment StringStart: (('L' | '@') Ws*)? '"'; -fragment EscapeSequence - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') +fragment EscapeSequence: + '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') | OctalEscape | UnicodeEscape - ; - -fragment OctalEscape - : '\\' [0-3] [0-7] [0-7] - | '\\' [0-7] [0-7] - | '\\' [0-7] - ; - -fragment UnicodeEscape: '\\' 'u' HexDigit HexDigit HexDigit HexDigit; -fragment HexDigit: [0-9a-fA-F]; - -fragment Ws: [ \r\n\t\u000C]; -fragment A: [aA]; -fragment B: [bB]; -fragment C: [cC]; -fragment D: [dD]; -fragment E: [eE]; -fragment F: [fF]; -fragment G: [gG]; -fragment H: [hH]; -fragment I: [iI]; -fragment J: [jJ]; -fragment K: [kK]; -fragment L: [lL]; -fragment M: [mM]; -fragment N: [nN]; -fragment O: [oO]; -fragment P: [pP]; -fragment Q: [qQ]; -fragment R: [rR]; -fragment S: [sS]; -fragment T: [tT]; -fragment U: [uU]; -fragment V: [vV]; -fragment W: [wW]; -fragment X: [xX]; -fragment Y: [yY]; -fragment Z: [zZ]; +; + +fragment OctalEscape: '\\' [0-3] [0-7] [0-7] | '\\' [0-7] [0-7] | '\\' [0-7]; + +fragment UnicodeEscape : '\\' 'u' HexDigit HexDigit HexDigit HexDigit; +fragment HexDigit : [0-9a-fA-F]; + +fragment Ws : [ \r\n\t\u000C]; +fragment A : [aA]; +fragment B : [bB]; +fragment C : [cC]; +fragment D : [dD]; +fragment E : [eE]; +fragment F : [fF]; +fragment G : [gG]; +fragment H : [hH]; +fragment I : [iI]; +fragment J : [jJ]; +fragment K : [kK]; +fragment L : [lL]; +fragment M : [mM]; +fragment N : [nN]; +fragment O : [oO]; +fragment P : [pP]; +fragment Q : [qQ]; +fragment R : [rR]; +fragment S : [sS]; +fragment T : [tT]; +fragment U : [uU]; +fragment V : [vV]; +fragment W : [wW]; +fragment X : [xX]; +fragment Y : [yY]; +fragment Z : [zZ]; \ No newline at end of file diff --git a/objc/one-step-processing/ObjectiveCPreprocessorParser.g4 b/objc/one-step-processing/ObjectiveCPreprocessorParser.g4 index de7f12dab1..7bbfce56e4 100644 --- a/objc/one-step-processing/ObjectiveCPreprocessorParser.g4 +++ b/objc/one-step-processing/ObjectiveCPreprocessorParser.g4 @@ -23,23 +23,28 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 ObjectiveCPreprocessorParser; -options { tokenVocab=ObjectiveCLexer; } +options { + tokenVocab = ObjectiveCLexer; +} directive - : SHARP (DIRECTIVE_IMPORT | DIRECTIVE_INCLUDE) directiveText #preprocessorImport - | SHARP DIRECTIVE_IF preprocessorExpression #preprocessorConditional - | SHARP DIRECTIVE_ELIF preprocessorExpression #preprocessorConditional - | SHARP DIRECTIVE_ELSE #preprocessorConditional - | SHARP DIRECTIVE_ENDIF #preprocessorConditional - | SHARP DIRECTIVE_IFDEF DIRECTIVE_ID #preprocessorDef - | SHARP DIRECTIVE_IFNDEF DIRECTIVE_ID #preprocessorDef - | SHARP DIRECTIVE_UNDEF DIRECTIVE_ID #preprocessorDef - | SHARP DIRECTIVE_PRAGMA directiveText #preprocessorPragma - | SHARP DIRECTIVE_ERROR directiveText #preprocessorError - | SHARP DIRECTIVE_WARNING directiveText #preprocessorWarning - | SHARP DIRECTIVE_DEFINE DIRECTIVE_ID directiveText? #preprocessorDefine + : SHARP (DIRECTIVE_IMPORT | DIRECTIVE_INCLUDE) directiveText # preprocessorImport + | SHARP DIRECTIVE_IF preprocessorExpression # preprocessorConditional + | SHARP DIRECTIVE_ELIF preprocessorExpression # preprocessorConditional + | SHARP DIRECTIVE_ELSE # preprocessorConditional + | SHARP DIRECTIVE_ENDIF # preprocessorConditional + | SHARP DIRECTIVE_IFDEF DIRECTIVE_ID # preprocessorDef + | SHARP DIRECTIVE_IFNDEF DIRECTIVE_ID # preprocessorDef + | SHARP DIRECTIVE_UNDEF DIRECTIVE_ID # preprocessorDef + | SHARP DIRECTIVE_PRAGMA directiveText # preprocessorPragma + | SHARP DIRECTIVE_ERROR directiveText # preprocessorError + | SHARP DIRECTIVE_WARNING directiveText # preprocessorWarning + | SHARP DIRECTIVE_DEFINE DIRECTIVE_ID directiveText? # preprocessorDefine ; directiveText @@ -47,21 +52,16 @@ directiveText ; preprocessorExpression - : DIRECTIVE_TRUE #preprocessorConstant - | DIRECTIVE_FALSE #preprocessorConstant - | DIRECTIVE_DECIMAL_LITERAL #preprocessorConstant - | DIRECTIVE_STRING #preprocessorConstant - | DIRECTIVE_ID - (DIRECTIVE_LP preprocessorExpression DIRECTIVE_RP)? #preprocessorConditionalSymbol - | DIRECTIVE_LP preprocessorExpression DIRECTIVE_RP #preprocessorParenthesis - | DIRECTIVE_BANG preprocessorExpression #preprocessorNot - | preprocessorExpression - op=(DIRECTIVE_EQUAL | DIRECTIVE_NOTEQUAL) preprocessorExpression #preprocessorBinary - | preprocessorExpression op=DIRECTIVE_AND preprocessorExpression #preprocessorBinary - | preprocessorExpression op=DIRECTIVE_OR preprocessorExpression #preprocessorBinary - | preprocessorExpression - op=(DIRECTIVE_LT | DIRECTIVE_GT | DIRECTIVE_LE | DIRECTIVE_GE) - preprocessorExpression #preprocessorBinary - | DIRECTIVE_DEFINED - (DIRECTIVE_ID | DIRECTIVE_LP DIRECTIVE_ID DIRECTIVE_RP) #preprocessorDefined + : DIRECTIVE_TRUE # preprocessorConstant + | DIRECTIVE_FALSE # preprocessorConstant + | DIRECTIVE_DECIMAL_LITERAL # preprocessorConstant + | DIRECTIVE_STRING # preprocessorConstant + | DIRECTIVE_ID (DIRECTIVE_LP preprocessorExpression DIRECTIVE_RP)? # preprocessorConditionalSymbol + | DIRECTIVE_LP preprocessorExpression DIRECTIVE_RP # preprocessorParenthesis + | DIRECTIVE_BANG preprocessorExpression # preprocessorNot + | preprocessorExpression op = (DIRECTIVE_EQUAL | DIRECTIVE_NOTEQUAL) preprocessorExpression # preprocessorBinary + | preprocessorExpression op = DIRECTIVE_AND preprocessorExpression # preprocessorBinary + | preprocessorExpression op = DIRECTIVE_OR preprocessorExpression # preprocessorBinary + | preprocessorExpression op = (DIRECTIVE_LT | DIRECTIVE_GT | DIRECTIVE_LE | DIRECTIVE_GE) preprocessorExpression # preprocessorBinary + | DIRECTIVE_DEFINED (DIRECTIVE_ID | DIRECTIVE_LP DIRECTIVE_ID DIRECTIVE_RP) # preprocessorDefined ; \ No newline at end of file diff --git a/objc/two-step-processing/ObjectiveCLexer.g4 b/objc/two-step-processing/ObjectiveCLexer.g4 index 70c73bf180..703b4364ef 100644 --- a/objc/two-step-processing/ObjectiveCLexer.g4 +++ b/objc/two-step-processing/ObjectiveCLexer.g4 @@ -25,305 +25,305 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ObjectiveCLexer; -channels { COMMENTS_CHANNEL, IGNORED_MACROS } +channels { + COMMENTS_CHANNEL, + IGNORED_MACROS +} // Words you can't use -AUTO: 'auto'; -BREAK: 'break'; -CASE: 'case'; -CHAR: 'char'; -CONST: 'const'; -CONTINUE: 'continue'; -DEFAULT: 'default'; -DO: 'do'; -DOUBLE: 'double'; -ELSE: 'else'; -ENUM: 'enum'; -EXTERN: 'extern'; -FLOAT: 'float'; -FOR: 'for'; -GOTO: 'goto'; -IF: 'if'; -INLINE: 'inline'; -INT: 'int'; -LONG: 'long'; -REGISTER: 'register'; -RESTRICT: 'restrict'; -RETURN: 'return'; -SHORT: 'short'; -SIGNED: 'signed'; -SIZEOF: 'sizeof'; -STATIC: 'static'; -STRUCT: 'struct'; -SWITCH: 'switch'; -TYPEDEF: 'typedef'; -UNION: 'union'; -UNSIGNED: 'unsigned'; -VOID: 'void'; -VOLATILE: 'volatile'; -WHILE: 'while'; -BOOL_: '_Bool'; -COMPLEX: '_Complex'; -IMAGINERY: '_Imaginery'; -TRUE: 'true'; -FALSE: 'false'; +AUTO : 'auto'; +BREAK : 'break'; +CASE : 'case'; +CHAR : 'char'; +CONST : 'const'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DO : 'do'; +DOUBLE : 'double'; +ELSE : 'else'; +ENUM : 'enum'; +EXTERN : 'extern'; +FLOAT : 'float'; +FOR : 'for'; +GOTO : 'goto'; +IF : 'if'; +INLINE : 'inline'; +INT : 'int'; +LONG : 'long'; +REGISTER : 'register'; +RESTRICT : 'restrict'; +RETURN : 'return'; +SHORT : 'short'; +SIGNED : 'signed'; +SIZEOF : 'sizeof'; +STATIC : 'static'; +STRUCT : 'struct'; +SWITCH : 'switch'; +TYPEDEF : 'typedef'; +UNION : 'union'; +UNSIGNED : 'unsigned'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHILE : 'while'; +BOOL_ : '_Bool'; +COMPLEX : '_Complex'; +IMAGINERY : '_Imaginery'; +TRUE : 'true'; +FALSE : 'false'; // Words you shouldn't use -BOOL: 'BOOL'; -Class: 'Class'; -BYCOPY: 'bycopy'; -BYREF: 'byref'; -ID: 'id'; -IMP: 'IMP'; -IN: 'in'; -INOUT: 'inout'; -NIL: 'nil'; -NO: 'NO'; -NULL_: 'NULL'; -ONEWAY: 'oneway'; -OUT: 'out'; -PROTOCOL_: 'Protocol'; -SEL: 'SEL'; -SELF: 'self'; -SUPER: 'super'; -YES: 'YES'; -AUTORELEASEPOOL: '@autoreleasepool'; -CATCH: '@catch'; -CLASS: '@class'; -DYNAMIC: '@dynamic'; -ENCODE: '@encode'; -END: '@end'; -FINALLY: '@finally'; -IMPLEMENTATION: '@implementation'; -INTERFACE: '@interface'; -IMPORT: '@import'; -PACKAGE: '@package'; -PROTOCOL: '@protocol'; -OPTIONAL: '@optional'; -PRIVATE: '@private'; -PROPERTY: '@property'; -PROTECTED: '@protected'; -PUBLIC: '@public'; -REQUIRED: '@required'; -SELECTOR: '@selector'; -SYNCHRONIZED: '@synchronized'; -SYNTHESIZE: '@synthesize'; -THROW: '@throw'; -TRY: '@try'; -ATOMIC: 'atomic'; -NONATOMIC: 'nonatomic'; -RETAIN: 'retain'; +BOOL : 'BOOL'; +Class : 'Class'; +BYCOPY : 'bycopy'; +BYREF : 'byref'; +ID : 'id'; +IMP : 'IMP'; +IN : 'in'; +INOUT : 'inout'; +NIL : 'nil'; +NO : 'NO'; +NULL_ : 'NULL'; +ONEWAY : 'oneway'; +OUT : 'out'; +PROTOCOL_ : 'Protocol'; +SEL : 'SEL'; +SELF : 'self'; +SUPER : 'super'; +YES : 'YES'; +AUTORELEASEPOOL : '@autoreleasepool'; +CATCH : '@catch'; +CLASS : '@class'; +DYNAMIC : '@dynamic'; +ENCODE : '@encode'; +END : '@end'; +FINALLY : '@finally'; +IMPLEMENTATION : '@implementation'; +INTERFACE : '@interface'; +IMPORT : '@import'; +PACKAGE : '@package'; +PROTOCOL : '@protocol'; +OPTIONAL : '@optional'; +PRIVATE : '@private'; +PROPERTY : '@property'; +PROTECTED : '@protected'; +PUBLIC : '@public'; +REQUIRED : '@required'; +SELECTOR : '@selector'; +SYNCHRONIZED : '@synchronized'; +SYNTHESIZE : '@synthesize'; +THROW : '@throw'; +TRY : '@try'; +ATOMIC : 'atomic'; +NONATOMIC : 'nonatomic'; +RETAIN : 'retain'; // Attributes with `__` prefix -ATTRIBUTE: '__attribute__'; -AUTORELEASING_QUALIFIER: '__autoreleasing'; -BLOCK: '__block'; -BRIDGE: '__bridge'; -BRIDGE_RETAINED: '__bridge_retained'; -BRIDGE_TRANSFER: '__bridge_transfer'; -COVARIANT: '__covariant'; -CONTRAVARIANT: '__contravariant'; -DEPRECATED: '__deprecated'; -KINDOF: '__kindof'; -STRONG_QUALIFIER: '__strong'; -TYPEOF: 'typeof' | '__typeof' | '__typeof__'; -UNSAFE_UNRETAINED_QUALIFIER:'__unsafe_unretained'; -UNUSED: '__unused'; -WEAK_QUALIFIER: '__weak'; +ATTRIBUTE : '__attribute__'; +AUTORELEASING_QUALIFIER : '__autoreleasing'; +BLOCK : '__block'; +BRIDGE : '__bridge'; +BRIDGE_RETAINED : '__bridge_retained'; +BRIDGE_TRANSFER : '__bridge_transfer'; +COVARIANT : '__covariant'; +CONTRAVARIANT : '__contravariant'; +DEPRECATED : '__deprecated'; +KINDOF : '__kindof'; +STRONG_QUALIFIER : '__strong'; +TYPEOF : 'typeof' | '__typeof' | '__typeof__'; +UNSAFE_UNRETAINED_QUALIFIER : '__unsafe_unretained'; +UNUSED : '__unused'; +WEAK_QUALIFIER : '__weak'; // Nullability specifiers -NULL_UNSPECIFIED: 'null_unspecified' | '__null_unspecified' | '_Null_unspecified'; -NULLABLE: 'nullable' | '__nullable' | '_Nullable'; -NONNULL: 'nonnull' | '__nonnull' | '_Nonnull'; -NULL_RESETTABLE: 'null_resettable'; +NULL_UNSPECIFIED : 'null_unspecified' | '__null_unspecified' | '_Null_unspecified'; +NULLABLE : 'nullable' | '__nullable' | '_Nullable'; +NONNULL : 'nonnull' | '__nonnull' | '_Nonnull'; +NULL_RESETTABLE : 'null_resettable'; // NS prefix -NS_INLINE: 'NS_INLINE'; -NS_ENUM: 'NS_ENUM'; -NS_OPTIONS: 'NS_OPTIONS'; +NS_INLINE : 'NS_INLINE'; +NS_ENUM : 'NS_ENUM'; +NS_OPTIONS : 'NS_OPTIONS'; // Property attributes -ASSIGN: 'assign'; -COPY: 'copy'; -GETTER: 'getter'; -SETTER: 'setter'; -STRONG: 'strong'; -READONLY: 'readonly'; -READWRITE: 'readwrite'; -WEAK: 'weak'; -UNSAFE_UNRETAINED: 'unsafe_unretained'; +ASSIGN : 'assign'; +COPY : 'copy'; +GETTER : 'getter'; +SETTER : 'setter'; +STRONG : 'strong'; +READONLY : 'readonly'; +READWRITE : 'readwrite'; +WEAK : 'weak'; +UNSAFE_UNRETAINED : 'unsafe_unretained'; // Interface Builder attributes -IB_OUTLET: 'IBOutlet'; -IB_OUTLET_COLLECTION: 'IBOutletCollection'; -IB_INSPECTABLE: 'IBInspectable'; -IB_DESIGNABLE: 'IB_DESIGNABLE'; +IB_OUTLET : 'IBOutlet'; +IB_OUTLET_COLLECTION : 'IBOutletCollection'; +IB_INSPECTABLE : 'IBInspectable'; +IB_DESIGNABLE : 'IB_DESIGNABLE'; // Ignored macros -NS_ASSUME_NONNULL_BEGIN: 'NS_ASSUME_NONNULL_BEGIN' ~[\r\n]* -> channel(IGNORED_MACROS); -NS_ASSUME_NONNULL_END: 'NS_ASSUME_NONNULL_END' ~[\r\n]* -> channel(IGNORED_MACROS); -EXTERN_SUFFIX: [_A-Z]+ '_EXTERN' -> channel(IGNORED_MACROS); -IOS_SUFFIX: [_A-Z]+ '_IOS(' ~')'+ ')' -> channel(IGNORED_MACROS); -MAC_SUFFIX: [_A-Z]+ '_MAC(' ~')'+ ')' -> channel(IGNORED_MACROS); -TVOS_PROHIBITED: '__TVOS_PROHIBITED' -> channel(IGNORED_MACROS); +NS_ASSUME_NONNULL_BEGIN : 'NS_ASSUME_NONNULL_BEGIN' ~[\r\n]* -> channel(IGNORED_MACROS); +NS_ASSUME_NONNULL_END : 'NS_ASSUME_NONNULL_END' ~[\r\n]* -> channel(IGNORED_MACROS); +EXTERN_SUFFIX : [_A-Z]+ '_EXTERN' -> channel(IGNORED_MACROS); +IOS_SUFFIX : [_A-Z]+ '_IOS(' ~')'+ ')' -> channel(IGNORED_MACROS); +MAC_SUFFIX : [_A-Z]+ '_MAC(' ~')'+ ')' -> channel(IGNORED_MACROS); +TVOS_PROHIBITED : '__TVOS_PROHIBITED' -> channel(IGNORED_MACROS); // Identifier -IDENTIFIER: Letter LetterOrDec*; +IDENTIFIER: Letter LetterOrDec*; // Separators -LP: '('; -RP: ')'; -LBRACE: '{'; -RBRACE: '}'; -LBRACK: '['; -RBRACK: ']'; -SEMI: ';'; -COMMA: ','; -DOT: '.'; -STRUCTACCESS: '->'; -AT: '@'; +LP : '('; +RP : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; +STRUCTACCESS : '->'; +AT : '@'; // Operators -ASSIGNMENT: '='; -GT: '>'; -LT: '<'; -BANG: '!'; -TILDE: '~'; -QUESTION: '?'; -COLON: ':'; -EQUAL: '=='; -LE: '<='; -GE: '>='; -NOTEQUAL: '!='; -AND: '&&'; -OR: '||'; -INC: '++'; -DEC: '--'; -ADD: '+'; -SUB: '-'; -MUL: '*'; -DIV: '/'; -BITAND: '&'; -BITOR: '|'; -BITXOR: '^'; -MOD: '%'; +ASSIGNMENT : '='; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +EQUAL : '=='; +LE : '<='; +GE : '>='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +BITXOR : '^'; +MOD : '%'; // Assignments -ADD_ASSIGN: '+='; -SUB_ASSIGN: '-='; -MUL_ASSIGN: '*='; -DIV_ASSIGN: '/='; -AND_ASSIGN: '&='; -OR_ASSIGN: '|='; -XOR_ASSIGN: '^='; -MOD_ASSIGN: '%='; -LSHIFT_ASSIGN: '<<='; -RSHIFT_ASSIGN: '>>='; -ELIPSIS: '...'; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +RSHIFT_ASSIGN : '>>='; +ELIPSIS : '...'; // Literals -CHARACTER_LITERAL: '\'' (EscapeSequence | ~('\'' | '\\')) '\''; -STRING_START: StringStart -> mode(STRING_MODE); +CHARACTER_LITERAL : '\'' (EscapeSequence | ~('\'' | '\\')) '\''; +STRING_START : StringStart -> mode(STRING_MODE); -HEX_LITERAL: '0' [xX] HexDigit+ IntegerTypeSuffix?; -OCTAL_LITERAL: '0' [0-7]+ IntegerTypeSuffix?; -BINARY_LITERAL: '0' [bB] [01]+ IntegerTypeSuffix?; -DECIMAL_LITERAL: [0-9]+ IntegerTypeSuffix?; +HEX_LITERAL : '0' [xX] HexDigit+ IntegerTypeSuffix?; +OCTAL_LITERAL : '0' [0-7]+ IntegerTypeSuffix?; +BINARY_LITERAL : '0' [bB] [01]+ IntegerTypeSuffix?; +DECIMAL_LITERAL : [0-9]+ IntegerTypeSuffix?; -FLOATING_POINT_LITERAL - : (Dec+ '.' Dec* | '.' Dec+) Exponent? FloatTypeSuffix? - | Dec+ (Exponent FloatTypeSuffix? | FloatTypeSuffix) - ; +FLOATING_POINT_LITERAL: + (Dec+ '.' Dec* | '.' Dec+) Exponent? FloatTypeSuffix? + | Dec+ (Exponent FloatTypeSuffix? | FloatTypeSuffix) +; // Comments and whitespaces -WS: Ws+ -> channel(HIDDEN); -MULTI_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); -SINGLE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); -BACKSLASH: '\\' -> channel(HIDDEN); +WS : Ws+ -> channel(HIDDEN); +MULTI_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +SINGLE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); +BACKSLASH : '\\' -> channel(HIDDEN); // Strings mode STRING_MODE; -STRING_NEWLINE: '\\' '\r'? '\n' -> channel(DEFAULT_TOKEN_CHANNEL); -STRING_ESCAPE: EscapeSequence -> channel(DEFAULT_TOKEN_CHANNEL), type(STRING_VALUE); -STRING_END: '"' -> channel(DEFAULT_TOKEN_CHANNEL), mode(DEFAULT_MODE); -STRING_VALUE: ~["\\]+ -> channel(DEFAULT_TOKEN_CHANNEL); +STRING_NEWLINE : '\\' '\r'? '\n' -> channel(DEFAULT_TOKEN_CHANNEL); +STRING_ESCAPE : EscapeSequence -> channel(DEFAULT_TOKEN_CHANNEL), type(STRING_VALUE); +STRING_END : '"' -> channel(DEFAULT_TOKEN_CHANNEL), mode(DEFAULT_MODE); +STRING_VALUE : ~["\\]+ -> channel(DEFAULT_TOKEN_CHANNEL); -fragment LetterOrDec - : Letter - | Dec - ; +fragment LetterOrDec: Letter | Dec; -fragment Letter - : [$A-Za-z_] +fragment Letter: + [$A-Za-z_] | ~[\u0000-\u00FF\uD800-\uDBFF] | [\uD800-\uDBFF] [\uDC00-\uDFFF] | [\u00E9] - ; +; -fragment IntegerTypeSuffix: [uUlL] [uUlL]? [uUlL]?; -fragment Exponent: [eE] [+\-]? Dec+; -fragment Dec: [0-9]; -fragment FloatTypeSuffix: [fFdD]; +fragment IntegerTypeSuffix : [uUlL] [uUlL]? [uUlL]?; +fragment Exponent : [eE] [+\-]? Dec+; +fragment Dec : [0-9]; +fragment FloatTypeSuffix : [fFdD]; -fragment StringStart: (('L' | '@') Ws*)? '"'; +fragment StringStart: (('L' | '@') Ws*)? '"'; -fragment EscapeSequence - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') +fragment EscapeSequence: + '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') | OctalEscape | UnicodeEscape - ; - -fragment OctalEscape - : '\\' [0-3] [0-7] [0-7] - | '\\' [0-7] [0-7] - | '\\' [0-7] - ; - -fragment UnicodeEscape: '\\' 'u' HexDigit HexDigit HexDigit HexDigit; -fragment HexDigit: [0-9a-fA-F]; - -fragment Ws: [ \r\n\t\u000C]; -fragment A: [aA]; -fragment B: [bB]; -fragment C: [cC]; -fragment D: [dD]; -fragment E: [eE]; -fragment F: [fF]; -fragment G: [gG]; -fragment H: [hH]; -fragment I: [iI]; -fragment J: [jJ]; -fragment K: [kK]; -fragment L: [lL]; -fragment M: [mM]; -fragment N: [nN]; -fragment O: [oO]; -fragment P: [pP]; -fragment Q: [qQ]; -fragment R: [rR]; -fragment S: [sS]; -fragment T: [tT]; -fragment U: [uU]; -fragment V: [vV]; -fragment W: [wW]; -fragment X: [xX]; -fragment Y: [yY]; -fragment Z: [zZ]; \ No newline at end of file +; + +fragment OctalEscape: '\\' [0-3] [0-7] [0-7] | '\\' [0-7] [0-7] | '\\' [0-7]; + +fragment UnicodeEscape : '\\' 'u' HexDigit HexDigit HexDigit HexDigit; +fragment HexDigit : [0-9a-fA-F]; + +fragment Ws : [ \r\n\t\u000C]; +fragment A : [aA]; +fragment B : [bB]; +fragment C : [cC]; +fragment D : [dD]; +fragment E : [eE]; +fragment F : [fF]; +fragment G : [gG]; +fragment H : [hH]; +fragment I : [iI]; +fragment J : [jJ]; +fragment K : [kK]; +fragment L : [lL]; +fragment M : [mM]; +fragment N : [nN]; +fragment O : [oO]; +fragment P : [pP]; +fragment Q : [qQ]; +fragment R : [rR]; +fragment S : [sS]; +fragment T : [tT]; +fragment U : [uU]; +fragment V : [vV]; +fragment W : [wW]; +fragment X : [xX]; +fragment Y : [yY]; +fragment Z : [zZ]; \ No newline at end of file diff --git a/objc/two-step-processing/ObjectiveCPreprocessorLexer.g4 b/objc/two-step-processing/ObjectiveCPreprocessorLexer.g4 index ad4fe0f2fd..016c1edc11 100644 --- a/objc/two-step-processing/ObjectiveCPreprocessorLexer.g4 +++ b/objc/two-step-processing/ObjectiveCPreprocessorLexer.g4 @@ -22,128 +22,128 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ObjectiveCPreprocessorLexer; -channels { COMMENTS_CHANNEL } +channels { + COMMENTS_CHANNEL +} -SHARP: '#' -> mode(DIRECTIVE_MODE); -COMMENT: '/*' .*? '*/' -> type(CODE); -LINE_COMMENT: '//' ~[\r\n]* -> type(CODE); -SLASH: '/' -> type(CODE); -CHARACTER_LITERAL: '\'' (EscapeSequence | ~('\''|'\\')) '\'' -> type(CODE); -QUOTE_STRING: '\'' (EscapeSequence | ~('\''|'\\'))* '\'' -> type(CODE); -STRING: StringFragment -> type(CODE); -CODE: ~[#'"/]+; +SHARP : '#' -> mode(DIRECTIVE_MODE); +COMMENT : '/*' .*? '*/' -> type(CODE); +LINE_COMMENT : '//' ~[\r\n]* -> type(CODE); +SLASH : '/' -> type(CODE); +CHARACTER_LITERAL : '\'' (EscapeSequence | ~('\'' | '\\')) '\'' -> type(CODE); +QUOTE_STRING : '\'' (EscapeSequence | ~('\'' | '\\'))* '\'' -> type(CODE); +STRING : StringFragment -> type(CODE); +CODE : ~[#'"/]+; mode DIRECTIVE_MODE; -IMPORT: 'import' [ \t]+ -> mode(DIRECTIVE_TEXT); -INCLUDE: 'include' [ \t]+ -> mode(DIRECTIVE_TEXT); -PRAGMA: 'pragma' -> mode(DIRECTIVE_TEXT); - -DEFINE: 'define' [ \t]+ -> mode(DIRECTIVE_DEFINE); -DEFINED: 'defined'; -IF: 'if'; -ELIF: 'elif'; -ELSE: 'else'; -UNDEF: 'undef'; -IFDEF: 'ifdef'; -IFNDEF: 'ifndef'; -ENDIF: 'endif'; -TRUE: T R U E; -FALSE: F A L S E; -ERROR: 'error' -> mode(DIRECTIVE_TEXT); - -BANG: '!' ; -LPAREN: '(' ; -RPAREN: ')' ; -EQUAL: '=='; -NOTEQUAL: '!='; -AND: '&&'; -OR: '||'; -LT: '<' ; -GT: '>' ; -LE: '<='; -GE: '>='; - -DIRECTIVE_WHITESPACES: [ \t]+ -> channel(HIDDEN); -DIRECTIVE_STRING: StringFragment; -CONDITIONAL_SYMBOL: LETTER (LETTER | [0-9])*; -DECIMAL_LITERAL: [0-9]+; -FLOAT: ([0-9]+ '.' [0-9]* | '.' [0-9]+); -NEW_LINE: '\r'? '\n' -> mode(DEFAULT_MODE); -DIRECITVE_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); -DIRECITVE_LINE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); -DIRECITVE_NEW_LINE: '\\' '\r'? '\n' -> channel(HIDDEN); +IMPORT : 'import' [ \t]+ -> mode(DIRECTIVE_TEXT); +INCLUDE : 'include' [ \t]+ -> mode(DIRECTIVE_TEXT); +PRAGMA : 'pragma' -> mode(DIRECTIVE_TEXT); + +DEFINE : 'define' [ \t]+ -> mode(DIRECTIVE_DEFINE); +DEFINED : 'defined'; +IF : 'if'; +ELIF : 'elif'; +ELSE : 'else'; +UNDEF : 'undef'; +IFDEF : 'ifdef'; +IFNDEF : 'ifndef'; +ENDIF : 'endif'; +TRUE : T R U E; +FALSE : F A L S E; +ERROR : 'error' -> mode(DIRECTIVE_TEXT); + +BANG : '!'; +LPAREN : '('; +RPAREN : ')'; +EQUAL : '=='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +LT : '<'; +GT : '>'; +LE : '<='; +GE : '>='; + +DIRECTIVE_WHITESPACES : [ \t]+ -> channel(HIDDEN); +DIRECTIVE_STRING : StringFragment; +CONDITIONAL_SYMBOL : LETTER (LETTER | [0-9])*; +DECIMAL_LITERAL : [0-9]+; +FLOAT : ([0-9]+ '.' [0-9]* | '.' [0-9]+); +NEW_LINE : '\r'? '\n' -> mode(DEFAULT_MODE); +DIRECITVE_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +DIRECITVE_LINE_COMMENT : '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL); +DIRECITVE_NEW_LINE : '\\' '\r'? '\n' -> channel(HIDDEN); mode DIRECTIVE_DEFINE; -DIRECTIVE_DEFINE_CONDITIONAL_SYMBOL: LETTER (LETTER | [0-9])* ('(' (LETTER | [0-9,. \t])* ')')? -> type(CONDITIONAL_SYMBOL), mode(DIRECTIVE_TEXT); +DIRECTIVE_DEFINE_CONDITIONAL_SYMBOL: + LETTER (LETTER | [0-9])* ('(' (LETTER | [0-9,. \t])* ')')? -> type(CONDITIONAL_SYMBOL), mode(DIRECTIVE_TEXT) +; mode DIRECTIVE_TEXT; -DIRECITVE_TEXT_NEW_LINE: '\\' '\r'? '\n' -> channel(HIDDEN); -BACK_SLASH_ESCAPE: '\\' . -> type(TEXT); -TEXT_NEW_LINE: '\r'? '\n' -> type(NEW_LINE), mode(DEFAULT_MODE); -DIRECTIVE_COMMENT: '/*' .*? '*/' -> channel(COMMENTS_CHANNEL), type(DIRECITVE_COMMENT); -DIRECTIVE_LINE_COMMENT: '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL), type(DIRECITVE_LINE_COMMENT); -DIRECTIVE_SLASH: '/' -> type(TEXT); -TEXT: ~[\r\n\\/]+; - -fragment -EscapeSequence - : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\') +DIRECITVE_TEXT_NEW_LINE : '\\' '\r'? '\n' -> channel(HIDDEN); +BACK_SLASH_ESCAPE : '\\' . -> type(TEXT); +TEXT_NEW_LINE : '\r'? '\n' -> type(NEW_LINE), mode(DEFAULT_MODE); +DIRECTIVE_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL), type(DIRECITVE_COMMENT); +DIRECTIVE_LINE_COMMENT: + '//' ~[\r\n]* -> channel(COMMENTS_CHANNEL), type(DIRECITVE_LINE_COMMENT) +; +DIRECTIVE_SLASH : '/' -> type(TEXT); +TEXT : ~[\r\n\\/]+; + +fragment EscapeSequence: + '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') | OctalEscape | UnicodeEscape - ; +; -fragment -OctalEscape - : '\\' [0-3] [0-7] [0-7] - | '\\' [0-7] [0-7] - | '\\' [0-7] - ; +fragment OctalEscape: '\\' [0-3] [0-7] [0-7] | '\\' [0-7] [0-7] | '\\' [0-7]; -fragment -UnicodeEscape - : '\\' 'u' HexDigit HexDigit HexDigit HexDigit - ; +fragment UnicodeEscape: '\\' 'u' HexDigit HexDigit HexDigit HexDigit; -fragment HexDigit: [0-9a-fA-F]; +fragment HexDigit: [0-9a-fA-F]; -fragment -StringFragment: '"' (~('\\' | '"') | '\\' .)* '"'; +fragment StringFragment: '"' (~('\\' | '"') | '\\' .)* '"'; -fragment LETTER - : [$A-Za-z_] +fragment LETTER: + [$A-Za-z_] | ~[\u0000-\u00FF\uD800-\uDBFF] | [\uD800-\uDBFF] [\uDC00-\uDFFF] | [\u00E9] - ; - -fragment A: [aA]; -fragment B: [bB]; -fragment C: [cC]; -fragment D: [dD]; -fragment E: [eE]; -fragment F: [fF]; -fragment G: [gG]; -fragment H: [hH]; -fragment I: [iI]; -fragment J: [jJ]; -fragment K: [kK]; -fragment L: [lL]; -fragment M: [mM]; -fragment N: [nN]; -fragment O: [oO]; -fragment P: [pP]; -fragment Q: [qQ]; -fragment R: [rR]; -fragment S: [sS]; -fragment T: [tT]; -fragment U: [uU]; -fragment V: [vV]; -fragment W: [wW]; -fragment X: [xX]; -fragment Y: [yY]; -fragment Z: [zZ]; \ No newline at end of file +; + +fragment A : [aA]; +fragment B : [bB]; +fragment C : [cC]; +fragment D : [dD]; +fragment E : [eE]; +fragment F : [fF]; +fragment G : [gG]; +fragment H : [hH]; +fragment I : [iI]; +fragment J : [jJ]; +fragment K : [kK]; +fragment L : [lL]; +fragment M : [mM]; +fragment N : [nN]; +fragment O : [oO]; +fragment P : [pP]; +fragment Q : [qQ]; +fragment R : [rR]; +fragment S : [sS]; +fragment T : [tT]; +fragment U : [uU]; +fragment V : [vV]; +fragment W : [wW]; +fragment X : [xX]; +fragment Y : [yY]; +fragment Z : [zZ]; \ No newline at end of file diff --git a/objc/two-step-processing/ObjectiveCPreprocessorParser.g4 b/objc/two-step-processing/ObjectiveCPreprocessorParser.g4 index 3f9809b0b4..c7c1380064 100644 --- a/objc/two-step-processing/ObjectiveCPreprocessorParser.g4 +++ b/objc/two-step-processing/ObjectiveCPreprocessorParser.g4 @@ -22,9 +22,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 ObjectiveCPreprocessorParser; -options { tokenVocab=ObjectiveCPreprocessorLexer; } +options { + tokenVocab = ObjectiveCPreprocessorLexer; +} objectiveCDocument : text* EOF @@ -40,17 +45,17 @@ code ; directive - : (IMPORT | INCLUDE) directive_text #preprocessorImport - | IF preprocessor_expression #preprocessorConditional - | ELIF preprocessor_expression #preprocessorConditional - | ELSE #preprocessorConditional - | ENDIF #preprocessorConditional - | IFDEF CONDITIONAL_SYMBOL #preprocessorDef - | IFNDEF CONDITIONAL_SYMBOL #preprocessorDef - | UNDEF CONDITIONAL_SYMBOL #preprocessorDef - | PRAGMA directive_text #preprocessorPragma - | ERROR directive_text #preprocessorError - | DEFINE CONDITIONAL_SYMBOL directive_text? #preprocessorDefine + : (IMPORT | INCLUDE) directive_text # preprocessorImport + | IF preprocessor_expression # preprocessorConditional + | ELIF preprocessor_expression # preprocessorConditional + | ELSE # preprocessorConditional + | ENDIF # preprocessorConditional + | IFDEF CONDITIONAL_SYMBOL # preprocessorDef + | IFNDEF CONDITIONAL_SYMBOL # preprocessorDef + | UNDEF CONDITIONAL_SYMBOL # preprocessorDef + | PRAGMA directive_text # preprocessorPragma + | ERROR directive_text # preprocessorError + | DEFINE CONDITIONAL_SYMBOL directive_text? # preprocessorDefine ; directive_text @@ -58,16 +63,16 @@ directive_text ; preprocessor_expression - : TRUE #preprocessorConstant - | FALSE #preprocessorConstant - | DECIMAL_LITERAL #preprocessorConstant - | DIRECTIVE_STRING #preprocessorConstant - | CONDITIONAL_SYMBOL (LPAREN preprocessor_expression RPAREN)? #preprocessorConditionalSymbol - | LPAREN preprocessor_expression RPAREN #preprocessorParenthesis - | BANG preprocessor_expression #preprocessorNot - | preprocessor_expression op=(EQUAL | NOTEQUAL) preprocessor_expression #preprocessorBinary - | preprocessor_expression op=AND preprocessor_expression #preprocessorBinary - | preprocessor_expression op=OR preprocessor_expression #preprocessorBinary - | preprocessor_expression op=(LT | GT | LE | GE) preprocessor_expression #preprocessorBinary - | DEFINED (CONDITIONAL_SYMBOL | LPAREN CONDITIONAL_SYMBOL RPAREN) #preprocessorDefined + : TRUE # preprocessorConstant + | FALSE # preprocessorConstant + | DECIMAL_LITERAL # preprocessorConstant + | DIRECTIVE_STRING # preprocessorConstant + | CONDITIONAL_SYMBOL (LPAREN preprocessor_expression RPAREN)? # preprocessorConditionalSymbol + | LPAREN preprocessor_expression RPAREN # preprocessorParenthesis + | BANG preprocessor_expression # preprocessorNot + | preprocessor_expression op = (EQUAL | NOTEQUAL) preprocessor_expression # preprocessorBinary + | preprocessor_expression op = AND preprocessor_expression # preprocessorBinary + | preprocessor_expression op = OR preprocessor_expression # preprocessorBinary + | preprocessor_expression op = (LT | GT | LE | GE) preprocessor_expression # preprocessorBinary + | DEFINED (CONDITIONAL_SYMBOL | LPAREN CONDITIONAL_SYMBOL RPAREN) # preprocessorDefined ; \ No newline at end of file diff --git a/ocl/OCL.g4 b/ocl/OCL.g4 index 80c8946b11..98760079d9 100644 --- a/ocl/OCL.g4 +++ b/ocl/OCL.g4 @@ -13,15 +13,18 @@ * SPDX-License-Identifier: EPL-2.0 * *****************************/ -grammar OCL; - +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar OCL; + specification - : 'package' ID '{' classifier* '}' EOF - ; + : 'package' ID '{' classifier* '}' EOF + ; expressions - : expression (';' expression)* ';'? EOF - ; + : expression (';' expression)* ';'? EOF + ; classifier : classDefinition @@ -31,303 +34,316 @@ classifier ; interfaceDefinition - : 'interface' ID ('extends' ID)? '{' classBody? '}' - ; + : 'interface' ID ('extends' ID)? '{' classBody? '}' + ; classDefinition - : 'class' ID ('extends' ID)? ('implements' idList)? '{' classBody? '}' - ; + : 'class' ID ('extends' ID)? ('implements' idList)? '{' classBody? '}' + ; classBody : classBodyElement+ - ; + ; classBodyElement - : attributeDefinition + : attributeDefinition | operationDefinition - | invariant + | invariant | stereotype - ; + ; -attributeDefinition - : 'attribute' ID ('identity' | 'derived')? ':' type ';' +attributeDefinition + : 'attribute' ID ('identity' | 'derived')? ':' type ';' | 'static' 'attribute' ID ':' type ';' - ; + ; operationDefinition - : ('static')? 'operation' ID - '(' parameterDeclarations? ')' ':' type - 'pre:' expression 'post:' expression - ('activity:' statement)? ';' - ; + : ('static')? 'operation' ID '(' parameterDeclarations? ')' ':' type 'pre:' expression 'post:' expression ( + 'activity:' statement + )? ';' + ; parameterDeclarations - : (parameterDeclaration ',')* parameterDeclaration - ; + : (parameterDeclaration ',')* parameterDeclaration + ; parameterDeclaration - : ID ':' type - ; + : ID ':' type + ; idList - : (ID ',')* ID - ; + : (ID ',')* ID + ; usecaseDefinition - : 'usecase' ID (':' type)? '{' usecaseBody? '}' - | 'usecase' ID '(' parameterDeclarations ')' (':' type)? '{' usecaseBody? '}' - ; + : 'usecase' ID (':' type)? '{' usecaseBody? '}' + | 'usecase' ID '(' parameterDeclarations ')' (':' type)? '{' usecaseBody? '}' + ; usecaseBody - : usecaseBodyElement+ - ; + : usecaseBodyElement+ + ; usecaseBodyElement - : 'parameter' ID ':' type ';' - | 'precondition' expression ';' - | 'extends' ID ';' - | 'extendedBy' ID ';' - | 'activity:' statement ';' - | '::' expression - | stereotype - ; + : 'parameter' ID ':' type ';' + | 'precondition' expression ';' + | 'extends' ID ';' + | 'extendedBy' ID ';' + | 'activity:' statement ';' + | '::' expression + | stereotype + ; invariant - : 'invariant' expression ';' - ; + : 'invariant' expression ';' + ; stereotype - : 'stereotype' ID ';' - | 'stereotype' ID '=' STRING_LITERAL ';' - | 'stereotype' ID '=' ID ';' - ; + : 'stereotype' ID ';' + | 'stereotype' ID '=' STRING_LITERAL ';' + | 'stereotype' ID '=' ID ';' + ; -enumeration - : 'enumeration' ID '{' enumerationLiteral+ '}' - ; +enumeration + : 'enumeration' ID '{' enumerationLiteral+ '}' + ; enumerationLiteral - : 'literal' ID - ; + : 'literal' ID + ; type - : 'Sequence' '(' type ')' - | 'Set' '(' type ')' - | 'Bag' '(' type ')' - | 'OrderedSet' '(' type ')' - | 'Map' '(' type ',' type ')' - | 'Function' '(' type ',' type ')' + : 'Sequence' '(' type ')' + | 'Set' '(' type ')' + | 'Bag' '(' type ')' + | 'OrderedSet' '(' type ')' + | 'Map' '(' type ',' type ')' + | 'Function' '(' type ',' type ')' | ID - ; - + ; expressionList : (expression ',')* expression - ; + ; expression - : logicalExpression - | conditionalExpression - | lambdaExpression + : logicalExpression + | conditionalExpression + | lambdaExpression | letExpression ; - // Basic expressions can appear on the LHS of . or -> basicExpression - : 'null' - | basicExpression '.' ID - | basicExpression '(' expressionList? ')' - | basicExpression '[' expression ']' - | ID '@pre' - | INT + : 'null' + | basicExpression '.' ID + | basicExpression '(' expressionList? ')' + | basicExpression '[' expression ']' + | ID '@pre' + | INT | FLOAT_LITERAL | STRING_LITERAL - | ID + | ID | '(' expression ')' - ; + ; conditionalExpression : 'if' expression 'then' expression 'else' expression 'endif' - ; + ; -lambdaExpression +lambdaExpression : 'lambda' ID ':' type 'in' expression - ; + ; // A let is just an application of a lambda: letExpression : 'let' ID ':' type '=' expression 'in' expression - ; + ; logicalExpression - : 'not' logicalExpression - | logicalExpression 'and' logicalExpression - | logicalExpression '&' logicalExpression - | logicalExpression 'or' logicalExpression - | logicalExpression 'xor' logicalExpression - | logicalExpression '=>' logicalExpression - | logicalExpression 'implies' logicalExpression + : 'not' logicalExpression + | logicalExpression 'and' logicalExpression + | logicalExpression '&' logicalExpression + | logicalExpression 'or' logicalExpression + | logicalExpression 'xor' logicalExpression + | logicalExpression '=>' logicalExpression + | logicalExpression 'implies' logicalExpression | equalityExpression - ; + ; -equalityExpression - : additiveExpression - ('=' | '<' | '>' | '>=' | '<=' | '/=' | '<>' | - ':'| '/:' | '<:') additiveExpression +equalityExpression + : additiveExpression ('=' | '<' | '>' | '>=' | '<=' | '/=' | '<>' | ':' | '/:' | '<:') additiveExpression | additiveExpression - ; + ; additiveExpression - : additiveExpression '+' additiveExpression + : additiveExpression '+' additiveExpression | additiveExpression '-' factorExpression - | factorExpression ('..' | '|->') factorExpression + | factorExpression ('..' | '|->') factorExpression | factorExpression - ; + ; -factorExpression - : factor2Expression ('*' | '/' | 'mod' | 'div') - factorExpression +factorExpression + : factor2Expression ('*' | '/' | 'mod' | 'div') factorExpression | factor2Expression - ; - + ; // factor2Expressions can appear on LHS of -> // ->subrange is used for ->substring and ->subSequence factor2Expression - : ('-' | '+') factor2Expression - | factor2Expression '->size()' - | factor2Expression '->copy()' - | factor2Expression ('->isEmpty()' | - '->notEmpty()' | - '->asSet()' | '->asBag()' | - '->asOrderedSet()' | - '->asSequence()' | - '->sort()' ) - | factor2Expression '->any()' - | factor2Expression '->log()' - | factor2Expression '->exp()' - | factor2Expression '->sin()' - | factor2Expression '->cos()' - | factor2Expression '->tan()' - | factor2Expression '->asin()' - | factor2Expression '->acos()' - | factor2Expression '->atan()' - | factor2Expression '->log10()' - | factor2Expression '->first()' - | factor2Expression '->last()' - | factor2Expression '->front()' - | factor2Expression '->tail()' - | factor2Expression '->reverse()' - | factor2Expression '->tanh()' - | factor2Expression '->sinh()' - | factor2Expression '->cosh()' - | factor2Expression '->floor()' - | factor2Expression '->ceil()' - | factor2Expression '->round()' - | factor2Expression '->abs()' - | factor2Expression '->oclType()' - | factor2Expression '->allInstances()' - | factor2Expression '->oclIsUndefined()' - | factor2Expression '->oclIsInvalid()' - | factor2Expression '->oclIsNew()' - | factor2Expression '->sum()' - | factor2Expression '->prd()' - | factor2Expression '->max()' - | factor2Expression '->min()' - | factor2Expression '->sqrt()' - | factor2Expression '->cbrt()' - | factor2Expression '->sqr()' - | factor2Expression '->characters()' - | factor2Expression '->toInteger()' - | factor2Expression '->toReal()' - | factor2Expression '->toBoolean()' - | factor2Expression '->toUpperCase()' - | factor2Expression '->toLowerCase()' - | factor2Expression ('->unionAll()' | '->intersectAll()' | - '->concatenateAll()') - - | factor2Expression ('->pow' | '->gcd') '(' expression ')' - | factor2Expression ('->at' | '->union' | '->intersection' - | '->includes' | '->excludes' | '->including' - | '->excluding' | '->includesAll' - | '->symmetricDifference' - | '->excludesAll' | '->prepend' | '->append' - | '->count' | '->apply') - '(' expression ')' - | factor2Expression ('->hasMatch' | '->isMatch' | - '->firstMatch' | '->indexOf' | - '->lastIndexOf' | '->split' | - '->hasPrefix' | - '->hasSuffix' | - '->equalsIgnoreCase' ) - '(' expression ')' - | factor2Expression ('->oclAsType' | '->oclIsTypeOf' | - '->oclIsKindOf' | - '->oclAsSet') '(' expression ')' - | factor2Expression '->collect' '(' identifier '|' expression ')' - | factor2Expression '->select' '(' identifier '|' expression ')' - | factor2Expression '->reject' '(' identifier '|' expression ')' - | factor2Expression '->forAll' '(' identifier '|' expression ')' - | factor2Expression '->exists' '(' identifier '|' expression ')' - | factor2Expression '->exists1' '(' identifier '|' expression ')' - | factor2Expression '->one' '(' identifier '|' expression ')' - | factor2Expression '->any' '(' identifier '|' expression ')' - | factor2Expression '->closure' '(' identifier '|' expression ')' - | factor2Expression '->sortedBy' '(' identifier '|' expression ')' - | factor2Expression '->isUnique' '(' identifier '|' expression ')' - - | factor2Expression '->subrange' '(' expression ',' expression ')' - | factor2Expression '->replace' '(' expression ',' expression ')' - | factor2Expression '->replaceAll' '(' expression ',' expression ')' - | factor2Expression '->replaceAllMatches' '(' expression ',' expression ')' - | factor2Expression '->replaceFirstMatch' '(' expression ',' expression ')' - | factor2Expression '->insertAt' '(' expression ',' expression ')' - | factor2Expression '->insertInto' '(' expression ',' expression ')' - | factor2Expression '->setAt' '(' expression ',' expression ')' - | factor2Expression '->iterate' '(' identifier ';' identifier '=' expression '|' expression ')' - | setExpression - | basicExpression - ; - -setExpression - : 'OrderedSet{' expressionList? '}' - | 'Bag{' expressionList? '}' - | 'Set{' expressionList? '}' - | 'Sequence{' expressionList? '}' - | 'Map{' expressionList? '}' - ; + : ('-' | '+') factor2Expression + | factor2Expression '->size()' + | factor2Expression '->copy()' + | factor2Expression ( + '->isEmpty()' + | '->notEmpty()' + | '->asSet()' + | '->asBag()' + | '->asOrderedSet()' + | '->asSequence()' + | '->sort()' + ) + | factor2Expression '->any()' + | factor2Expression '->log()' + | factor2Expression '->exp()' + | factor2Expression '->sin()' + | factor2Expression '->cos()' + | factor2Expression '->tan()' + | factor2Expression '->asin()' + | factor2Expression '->acos()' + | factor2Expression '->atan()' + | factor2Expression '->log10()' + | factor2Expression '->first()' + | factor2Expression '->last()' + | factor2Expression '->front()' + | factor2Expression '->tail()' + | factor2Expression '->reverse()' + | factor2Expression '->tanh()' + | factor2Expression '->sinh()' + | factor2Expression '->cosh()' + | factor2Expression '->floor()' + | factor2Expression '->ceil()' + | factor2Expression '->round()' + | factor2Expression '->abs()' + | factor2Expression '->oclType()' + | factor2Expression '->allInstances()' + | factor2Expression '->oclIsUndefined()' + | factor2Expression '->oclIsInvalid()' + | factor2Expression '->oclIsNew()' + | factor2Expression '->sum()' + | factor2Expression '->prd()' + | factor2Expression '->max()' + | factor2Expression '->min()' + | factor2Expression '->sqrt()' + | factor2Expression '->cbrt()' + | factor2Expression '->sqr()' + | factor2Expression '->characters()' + | factor2Expression '->toInteger()' + | factor2Expression '->toReal()' + | factor2Expression '->toBoolean()' + | factor2Expression '->toUpperCase()' + | factor2Expression '->toLowerCase()' + | factor2Expression ('->unionAll()' | '->intersectAll()' | '->concatenateAll()') + | factor2Expression ('->pow' | '->gcd') '(' expression ')' + | factor2Expression ( + '->at' + | '->union' + | '->intersection' + | '->includes' + | '->excludes' + | '->including' + | '->excluding' + | '->includesAll' + | '->symmetricDifference' + | '->excludesAll' + | '->prepend' + | '->append' + | '->count' + | '->apply' + ) '(' expression ')' + | factor2Expression ( + '->hasMatch' + | '->isMatch' + | '->firstMatch' + | '->indexOf' + | '->lastIndexOf' + | '->split' + | '->hasPrefix' + | '->hasSuffix' + | '->equalsIgnoreCase' + ) '(' expression ')' + | factor2Expression ('->oclAsType' | '->oclIsTypeOf' | '->oclIsKindOf' | '->oclAsSet') '(' expression ')' + | factor2Expression '->collect' '(' identifier '|' expression ')' + | factor2Expression '->select' '(' identifier '|' expression ')' + | factor2Expression '->reject' '(' identifier '|' expression ')' + | factor2Expression '->forAll' '(' identifier '|' expression ')' + | factor2Expression '->exists' '(' identifier '|' expression ')' + | factor2Expression '->exists1' '(' identifier '|' expression ')' + | factor2Expression '->one' '(' identifier '|' expression ')' + | factor2Expression '->any' '(' identifier '|' expression ')' + | factor2Expression '->closure' '(' identifier '|' expression ')' + | factor2Expression '->sortedBy' '(' identifier '|' expression ')' + | factor2Expression '->isUnique' '(' identifier '|' expression ')' + | factor2Expression '->subrange' '(' expression ',' expression ')' + | factor2Expression '->replace' '(' expression ',' expression ')' + | factor2Expression '->replaceAll' '(' expression ',' expression ')' + | factor2Expression '->replaceAllMatches' '(' expression ',' expression ')' + | factor2Expression '->replaceFirstMatch' '(' expression ',' expression ')' + | factor2Expression '->insertAt' '(' expression ',' expression ')' + | factor2Expression '->insertInto' '(' expression ',' expression ')' + | factor2Expression '->setAt' '(' expression ',' expression ')' + | factor2Expression '->iterate' '(' identifier ';' identifier '=' expression '|' expression ')' + | setExpression + | basicExpression + ; -statement - : 'skip' - | 'return' - | 'continue' - | 'break' - | 'var' ID ':' type - | 'if' expression 'then' statement 'else' statement - | 'while' expression 'do' statement - | 'for' ID ':' expression 'do' statement - | 'return' expression - | basicExpression ':=' expression - | statement ';' statement - | 'execute' expression - | 'call' basicExpression - | '(' statement ')' - ; +setExpression + : 'OrderedSet{' expressionList? '}' + | 'Bag{' expressionList? '}' + | 'Set{' expressionList? '}' + | 'Sequence{' expressionList? '}' + | 'Map{' expressionList? '}' + ; -identifier: ID ; +statement + : 'skip' + | 'return' + | 'continue' + | 'break' + | 'var' ID ':' type + | 'if' expression 'then' statement 'else' statement + | 'while' expression 'do' statement + | 'for' ID ':' expression 'do' statement + | 'return' expression + | basicExpression ':=' expression + | statement ';' statement + | 'execute' expression + | 'call' basicExpression + | '(' statement ')' + ; -FLOAT_LITERAL: Digits '.' Digits ; +identifier + : ID + ; -STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; +FLOAT_LITERAL + : Digits '.' Digits + ; -NULL_LITERAL: 'null'; +STRING_LITERAL + : '"' (~["\\\r\n] | EscapeSequence)* '"' + ; -MULTILINE_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); +NULL_LITERAL + : 'null' + ; +MULTILINE_COMMENT + : '/*' .*? '*/' -> channel(HIDDEN) + ; fragment EscapeSequence : '\\' [btnfr"'\\] @@ -343,13 +359,22 @@ fragment HexDigit : [0-9a-fA-F] ; - fragment Digits : [0-9]+ ; -NEWLINE : [\r\n]+ -> skip ; -INT : [0-9]+ ; -ID : [a-zA-Z$]+[a-zA-Z0-9_$]* ; // match identifiers -WS : [ \t\n\r]+ -> skip ; +NEWLINE + : [\r\n]+ -> skip + ; + +INT + : [0-9]+ + ; + +ID + : [a-zA-Z$]+ [a-zA-Z0-9_$]* + ; // match identifiers +WS + : [ \t\n\r]+ -> skip + ; \ No newline at end of file diff --git a/oncrpc/oncrpcv2.g4 b/oncrpc/oncrpcv2.g4 index ec573015c7..3607e138ec 100644 --- a/oncrpc/oncrpcv2.g4 +++ b/oncrpc/oncrpcv2.g4 @@ -1,16 +1,33 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar oncrpcv2; + import xdr; //oncrpcv2 additions on top of xdr (rfc 5531) -programDef: 'program' IDENTIFIER '{' - versionDef - versionDef* - '}' '=' constant ';'; -versionDef: 'version' IDENTIFIER '{' - procedureDef - procedureDef* - '}' '=' constant ';'; -procedureDef: procReturn IDENTIFIER '(' procFirstArg (',' typeSpecifier)* ')' '=' constant ';'; -procReturn: 'void' | typeSpecifier; -procFirstArg: 'void' | typeSpecifier; -oncrpcv2Specification : (xdrSpecification | programDef)* EOF; //this is the top level rule for oncrpcv2 (rfc 5531) +programDef + : 'program' IDENTIFIER '{' versionDef versionDef* '}' '=' constant ';' + ; + +versionDef + : 'version' IDENTIFIER '{' procedureDef procedureDef* '}' '=' constant ';' + ; + +procedureDef + : procReturn IDENTIFIER '(' procFirstArg (',' typeSpecifier)* ')' '=' constant ';' + ; + +procReturn + : 'void' + | typeSpecifier + ; + +procFirstArg + : 'void' + | typeSpecifier + ; + +oncrpcv2Specification + : (xdrSpecification | programDef)* EOF + ; //this is the top level rule for oncrpcv2 (rfc 5531) \ No newline at end of file diff --git a/oncrpc/xdr.g4 b/oncrpc/xdr.g4 index 5de6df52ae..89c56a3bef 100644 --- a/oncrpc/xdr.g4 +++ b/oncrpc/xdr.g4 @@ -1,57 +1,115 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar xdr; // parser rules -declaration: - typeSpecifier IDENTIFIER - | typeSpecifier IDENTIFIER '[' value ']' - | typeSpecifier IDENTIFIER '<' value? '>' - | 'opaque' IDENTIFIER '[' value ']' - | 'opaque' IDENTIFIER '<' value? '>' - | 'string' IDENTIFIER '<' value? '>' - | typeSpecifier '*' IDENTIFIER - | 'void' -; -value: constant | IDENTIFIER; -constant: DECIMAL | HEXADECIMAL | OCTAL; -typeSpecifier: - 'unsigned'? 'int' - | 'unsigned'? 'hyper' - | 'float' - | 'double' - | 'quadruple' - | 'bool' - | enumTypeSpec - | structTypeSpec - | unionTypeSpec - | IDENTIFIER -; -enumTypeSpec: 'enum' enumBody; -enumBody: '{' (IDENTIFIER '=' value) (',' IDENTIFIER '=' value)* '}'; -structTypeSpec: 'struct' structBody; -structBody: '{' (declaration ';') (declaration ';')* '}'; -unionTypeSpec: 'union' unionBody; -unionBody: 'switch' '(' declaration ')' '{' - caseSpec - caseSpec* - ('default' ':' declaration ';')? - '}'; -caseSpec: ('case' value ':') ('case' value ':')* declaration ';'; -constantDef: 'const' IDENTIFIER '=' constant ';'; -typeDef: - 'typedef' declaration ';' - | 'enum' IDENTIFIER enumBody ';' - | 'struct' IDENTIFIER structBody ';' - | 'union' IDENTIFIER unionBody ';' -; -definition: typeDef | constantDef; -xdrSpecification: definition+; //this is the top level rule for xdr (rfc 4506) +declaration + : typeSpecifier IDENTIFIER + | typeSpecifier IDENTIFIER '[' value ']' + | typeSpecifier IDENTIFIER '<' value? '>' + | 'opaque' IDENTIFIER '[' value ']' + | 'opaque' IDENTIFIER '<' value? '>' + | 'string' IDENTIFIER '<' value? '>' + | typeSpecifier '*' IDENTIFIER + | 'void' + ; + +value + : constant + | IDENTIFIER + ; + +constant + : DECIMAL + | HEXADECIMAL + | OCTAL + ; + +typeSpecifier + : 'unsigned'? 'int' + | 'unsigned'? 'hyper' + | 'float' + | 'double' + | 'quadruple' + | 'bool' + | enumTypeSpec + | structTypeSpec + | unionTypeSpec + | IDENTIFIER + ; + +enumTypeSpec + : 'enum' enumBody + ; + +enumBody + : '{' (IDENTIFIER '=' value) (',' IDENTIFIER '=' value)* '}' + ; + +structTypeSpec + : 'struct' structBody + ; + +structBody + : '{' (declaration ';') (declaration ';')* '}' + ; + +unionTypeSpec + : 'union' unionBody + ; + +unionBody + : 'switch' '(' declaration ')' '{' caseSpec caseSpec* ('default' ':' declaration ';')? '}' + ; + +caseSpec + : ('case' value ':') ('case' value ':')* declaration ';' + ; + +constantDef + : 'const' IDENTIFIER '=' constant ';' + ; + +typeDef + : 'typedef' declaration ';' + | 'enum' IDENTIFIER enumBody ';' + | 'struct' IDENTIFIER structBody ';' + | 'union' IDENTIFIER unionBody ';' + ; + +definition + : typeDef + | constantDef + ; + +xdrSpecification + : definition+ + ; //this is the top level rule for xdr (rfc 4506) // lexer rules -COMMENT : '/*' .*? '*/' -> skip; -OCTAL : '0' [1-7] ([0-7])*; -DECIMAL : ('-')? ([0-9])+; -HEXADECIMAL : '0x' ([a-fA-F0-9])+; -IDENTIFIER : [a-zA-Z] ([a-zA-Z0-9_])*; -WS : [ \t\r\n]+ -> skip; \ No newline at end of file +COMMENT + : '/*' .*? '*/' -> skip + ; + +OCTAL + : '0' [1-7] ([0-7])* + ; + +DECIMAL + : ('-')? ([0-9])+ + ; + +HEXADECIMAL + : '0x' ([a-fA-F0-9])+ + ; + +IDENTIFIER + : [a-zA-Z] ([a-zA-Z0-9_])* + ; + +WS + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/orwell/orwell.g4 b/orwell/orwell.g4 index c8a88fd91c..2dbc0433c2 100644 --- a/orwell/orwell.g4 +++ b/orwell/orwell.g4 @@ -29,350 +29,353 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar orwell; program - : decl+ EOF - ; + : decl+ EOF + ; decl - : syndecl - | condecl - | typedecl - | opdecl - | def_ - ; + : syndecl + | condecl + | typedecl + | opdecl + | def_ + ; syndecl - : tylhs '==' type_ - ; + : tylhs '==' type_ + ; condecl - : tylhs ':==' construct ('|' construct)* - ; + : tylhs ':==' construct ('|' construct)* + ; typedecl - : name (',' name)* '::' type_ - ; + : name (',' name)* '::' type_ + ; name - : var_ '(' (var_ prefix | infix) ')' - ; + : var_ '(' (var_ prefix | infix) ')' + ; tylhs - : (tyvar infix tyvar) - | (prefix tyvar) - | tylhs1 - ; + : (tyvar infix tyvar) + | (prefix tyvar) + | tylhs1 + ; tylhs1 - : tylhsprimary tyvar* - ; + : tylhsprimary tyvar* + ; tylhsprimary - : tyname '(' (tylhs | tylhssection) ')' - ; + : tyname '(' (tylhs | tylhssection) ')' + ; tylhssection - : prefix - | infix - | (infix tyvar) - | (tyvar infix) - ; + : prefix + | infix + | (infix tyvar) + | (tyvar infix) + ; type_ - : tyterm1 (infix type_)? - ; + : tyterm1 (infix type_)? + ; tyterm1 - : prefix tyterm1 - | tyterm2 - ; + : prefix tyterm1 + | tyterm2 + ; tyterm2 - : typrimary - | typrimaryname typrimary* - ; + : typrimary + | typrimaryname typrimary* + ; typrimaryname - : tyname - | '(' (type_ | tysection) ')' - ; + : tyname + | '(' (type_ | tysection) ')' + ; typrimary - : typrimaryname - | tyvar tytuple - | tylist - ; + : typrimaryname + | tyvar tytuple + | tylist + ; tysection - : prefix infix - | (infix tyterm1) - | (tyterm1 infix) - ; + : prefix infix + | (infix tyterm1) + | (tyterm1 infix) + ; tylist - : '[' type_ ']' - ; + : '[' type_ ']' + ; tytuple - : '(' type_ (',' type_)* ')' - ; + : '(' type_ (',' type_)* ')' + ; construct - : (con typrimary*) - | (typrimary infix typrimary) - | (prefix typrimary) - ; + : (con typrimary*) + | (typrimary infix typrimary) + | (prefix typrimary) + ; opdecl - : opkind OP+ - ; + : opkind OP+ + ; opkind - : (assoc DIGIT) - | '%prefix' - | '%prefixcon' - ; + : (assoc DIGIT) + | '%prefix' + | '%prefixcon' + ; assoc - : '%left' - | '%right' - | '%non' - | '%leftcon' - | '%rightcon' - | '%noncon' - ; + : '%left' + | '%right' + | '%non' + | '%leftcon' + | '%rightcon' + | '%noncon' + ; def_ - : pat '=' rhs ('%else'? pat '=' rhs)* - ; + : pat '=' rhs ('%else'? pat '=' rhs)* + ; rhs - : (term | conditional) wherepart? - ; + : (term | conditional) wherepart? + ; conditional - : ifpart ('=' ifpart)* ('=' otherpart)? - ; + : ifpart ('=' ifpart)* ('=' otherpart)? + ; ifpart - : term ',' 'if' term - ; + : term ',' 'if' term + ; otherpart - : term ',' 'otherwise' - ; + : term ',' 'otherwise' + ; wherepart - : 'where' def_+ - ; + : 'where' def_+ + ; pat - : pat1 (infix pat)? - ; + : pat1 (infix pat)? + ; pat1 - : prefix pat1 - | pat2 - ; + : prefix pat1 + | pat2 + ; pat2 - : patprimary - | (patprimaryname patprimary*) - ; + : patprimary + | (patprimaryname patprimary*) + ; patprimaryname - : var_ - | ('(' (pat | patsection) ')') - ; + : var_ + | ('(' (pat | patsection) ')') + ; patprimary - : patprimaryname - | literal - | pattuple - | patlist - ; + : patprimaryname + | literal + | pattuple + | patlist + ; patsection - : prefix - | infix - | (infix pat1) - | (pat1 infix) - ; + : prefix + | infix + | (infix pat1) + | (pat1 infix) + ; pattuple - : '(' pat ',' pat (',' pat)* ')' - ; + : '(' pat ',' pat (',' pat)* ')' + ; patlist - : '[' (pat (',' pat)*)? ']' - ; + : '[' (pat (',' pat)*)? ']' + ; term - : term1 (infix term)? - ; + : term1 (infix term)? + ; term1 - : (prefix term1) - | term2 - ; + : (prefix term1) + | term2 + ; term2 - : primary - | (primaryname primary*) - ; + : primary + | (primaryname primary*) + ; primaryname - : var_ - | '(' (term | section) ')' - ; + : var_ + | '(' (term | section) ')' + ; primary - : primaryname - | fliteral - | tuple_ - | list_ - ; + : primaryname + | fliteral + | tuple_ + | list_ + ; section - : prefix - | infix - | (infix term1) - | (term1 infix) - ; + : prefix + | infix + | (infix term1) + | (term1 infix) + ; list_ - : listform - | upto - | comp - ; + : listform + | upto + | comp + ; tuple_ - : '(' term ',' term (',' term)* ')' - ; + : '(' term ',' term (',' term)* ')' + ; listform - : '[' (term (',' term)*)? ']' - ; + : '[' (term (',' term)*)? ']' + ; upto - : '[' term (',' term)? '..' term? ']' - ; + : '[' term (',' term)? '..' term? ']' + ; comp - : '[' term '|' (qualifier (';' qualifier)*)? ']' - ; + : '[' term '|' (qualifier (';' qualifier)*)? ']' + ; qualifier - : term - | pat '<-' term - ; + : term + | pat '<-' term + ; fliteral - : FLOAT - | literal - ; + : FLOAT + | literal + ; literal - : INTEGER - | CHAR - | STRING - ; + : INTEGER + | CHAR + | STRING + ; infix - : OP - ; + : OP + ; prefix - : OP - ; + : OP + ; tyname - : ID - ; + : ID + ; tyvar - : ID - ; + : ID + ; con - : ID - ; + : ID + ; var_ - : ID - ; + : ID + ; INTEGER - : DIGIT+ - ; + : DIGIT+ + ; FLOAT - : INTEGER '.' INTEGER ('e' '—'? INTEGER)? - ; + : INTEGER '.' INTEGER ('e' '—'? INTEGER)? + ; STRING - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; ESCCHAR - : '\\' (CHAR | DIGIT (DIGIT DIGIT?)?) - ; + : '\\' (CHAR | DIGIT (DIGIT DIGIT?)?) + ; PRAGMA - : '%' ID - ; + : '%' ID + ; OP - : SYMBOL+ - | ('$' ID) - ; + : SYMBOL+ + | ('$' ID) + ; ID - : LETTER (LETTER | SYMBOL | DIGIT | '\'' | '_')* - ; + : LETTER (LETTER | SYMBOL | DIGIT | '\'' | '_')* + ; fragment SYMBOL - : '+' - | '-' - | '*' - | '=' - | '<' - | '>' - | '~' - | '&' - | '\\' - | '/' - | '^' - | ':' - | '#' - | '!' - | '.' - | ';' - | '|' - | '?' - | '@' - | '`' - | '$' - | '%' - | '{' - | '}' - ; + : '+' + | '-' + | '*' + | '=' + | '<' + | '>' + | '~' + | '&' + | '\\' + | '/' + | '^' + | ':' + | '#' + | '!' + | '.' + | ';' + | '|' + | '?' + | '@' + | '`' + | '$' + | '%' + | '{' + | '}' + ; fragment LETTER - : [a-zA-Z] - ; + : [a-zA-Z] + ; DIGIT - : '0' .. '9' - ; + : '0' .. '9' + ; CHAR - : [0-9a-zA-Z] - ; + : [0-9a-zA-Z] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/p/p.g4 b/p/p.g4 index 69bbe782f6..66d2ebe7b9 100644 --- a/p/p.g4 +++ b/p/p.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2013 Tom Everett @@ -26,33 +25,38 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar p; prog - : symbol+ EOF - ; + : symbol+ EOF + ; symbol - : iterate - | atom - ; + : iterate + | atom + ; iterate : '(' symbol+ ')' ; atom - : R | L + : R + | L ; R - : 'R' - ; + : 'R' + ; L - : 'λ' - ; + : 'λ' + ; WS - : [ \t\r\n] -> skip - ; \ No newline at end of file + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/parkingsign/parkingsign.g4 b/parkingsign/parkingsign.g4 index 0f8a4aff72..87dc78025a 100644 --- a/parkingsign/parkingsign.g4 +++ b/parkingsign/parkingsign.g4 @@ -70,58 +70,64 @@ VEHICLES WITH DISTRICT NO. 78 PERMITS EXEMPTED DISTRICT NO.34 PERMITS EXEMPT */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar parkingsign; + /* There can be multiple parking signs on the same pole that together determine the parking rules for the location. Assume we have at least one sign in the image we are analyzing. */ - parkingSigns - : parkingSign* EOF - ; + : parkingSign* EOF + ; parkingSign - : streetSweepingSign - | noParkingSign - | noStoppingSign - | passengerLoadingSign - | singleTimeLimitSign - | doubleTimeLimitSign - | temporaryNoParkingSign - | permitSign - ; + : streetSweepingSign + | noParkingSign + | noStoppingSign + | passengerLoadingSign + | singleTimeLimitSign + | doubleTimeLimitSign + | temporaryNoParkingSign + | permitSign + ; + /* Sometimes there are the words NO PARKING and sometimes there is a graphic P with a circle and line through it. We don't include the graphic in the grammar */ - - + streetSweepingSign - : noParking? timeRange day streetSweeping - ; - // Sometimes the exception is on a different sign below the no parking sign - + : noParking? timeRange day streetSweeping + ; + +// Sometimes the exception is on a different sign below the no parking sign + noParkingSign - : noParking? (anyTime | timeRange) EXCEPT? dayRange? - ; + : noParking? (anyTime | timeRange) EXCEPT? dayRange? + ; noStoppingSign - : towAway? (noStopping | valetOnly) timeRange+ EXCEPT? dayRange? - ; + : towAway? (noStopping | valetOnly) timeRange+ EXCEPT? dayRange? + ; passengerLoadingSign - : towAway? loadingOnly timeRange+ EXCEPT? dayRange? - ; + : towAway? loadingOnly timeRange+ EXCEPT? dayRange? + ; temporaryNoParkingSign - : towAway TEMPORARY noParking (anyTime | timeRange) EXCEPT? dayRange? - ; + : towAway TEMPORARY noParking (anyTime | timeRange) EXCEPT? dayRange? + ; singleTimeLimitSign - : ((INT HOUR) | (INT minute)) PARKING timeRange EXCEPT? dayRange? - ; + : ((INT HOUR) | (INT minute)) PARKING timeRange EXCEPT? dayRange? + ; + /* The double time limit sign is a challenge in that the order of the tokens is not ideal. If there is 2 hour parking Mon-Sat from 8am to 8pm and on @@ -129,332 +135,332 @@ Sun from 11am to 8pm, the order of the tokens will be 2 HOUR PARKING MON TO SAT SUN 8 AM 11 AM TO TO 11 AM 8 PM because of the vertical arrangement of the day/time ranges */ - - + doubleTimeLimitSign - : INT HOUR PARKING dayRange dayRange time time TO TO time time (EXCEPT HOLIDAYS)? - ; + : INT HOUR PARKING dayRange dayRange time time TO TO time time (EXCEPT HOLIDAYS)? + ; permitSign - : (VEHICLES WITH)? DISTRICT NO INT PERMITS exempt - ; - // Phrases - + : (VEHICLES WITH)? DISTRICT NO INT PERMITS exempt + ; + +// Phrases + streetSweeping - : STREET (SWEEPING | CLEANING) - ; + : STREET (SWEEPING | CLEANING) + ; noParking - : NO PARKING - ; + : NO PARKING + ; noStopping - : NO STOPPING - ; + : NO STOPPING + ; valetOnly - : VALET PARKING ONLY - ; + : VALET PARKING ONLY + ; loadingOnly - : PASSENGER LOADING ONLY - ; + : PASSENGER LOADING ONLY + ; schoolDays - : SCHOOL DAYS - ; + : SCHOOL DAYS + ; timeRange - : (time to time) - | (INT to time) - ; + : (time to time) + | (INT to time) + ; everyDay - : DAILY - | NIGHTLY - ; + : DAILY + | NIGHTLY + ; dayToDay - : day to day - ; + : day to day + ; dayAndDay - : day and_ day - ; + : day and_ day + ; dayRange - : everyDay - | schoolDays - | HOLIDAYS - | dayAndDay - | dayToDay - | day ONLY - | day - ; + : everyDay + | schoolDays + | HOLIDAYS + | dayAndDay + | dayToDay + | day ONLY + | day + ; dayRangePlus - : dayRange - ; + : dayRange + ; to - : TO - | DASH - | THRU - ; + : TO + | DASH + | THRU + ; and_ - : AND - | AMPERSAND - ; + : AND + | AMPERSAND + ; towAway - : TOW DASH? AWAY - ; + : TOW DASH? AWAY + ; minute - : MIN - | MINUTE - ; + : MIN + | MINUTE + ; exempt - : EXEMPT - | EXEMPTED - ; + : EXEMPT + | EXEMPTED + ; anyTime - : ANYTIME - | (ANY TIME) - ; + : ANYTIME + | (ANY TIME) + ; NO - : 'NO' - ; // two meanings : negative (no) and abbreviation for number (No.) - + : 'NO' + ; // two meanings : negative (no) and abbreviation for number (No.) + PARKING - : 'PARKING' - ; + : 'PARKING' + ; TO - : 'TO' - ; + : 'TO' + ; THRU - : 'THRU' - ; + : 'THRU' + ; DASH - : '-' - ; + : '-' + ; ANYTIME - : 'ANYTIME' - ; + : 'ANYTIME' + ; ANY - : 'ANY' - ; + : 'ANY' + ; TIME - : 'TIME' - ; + : 'TIME' + ; EXCEPT - : 'EXCEPT' - ; + : 'EXCEPT' + ; DAILY - : 'DAILY' - ; + : 'DAILY' + ; NIGHTLY - : 'NIGHTLY' - ; + : 'NIGHTLY' + ; SCHOOL - : 'SCHOOL' - ; + : 'SCHOOL' + ; DAYS - : 'DAYS' - ; + : 'DAYS' + ; HOLIDAYS - : 'HOLIDAYS' - ; + : 'HOLIDAYS' + ; AND - : 'AND' - ; + : 'AND' + ; AMPERSAND - : '&' - ; + : '&' + ; TOW - : 'TOW' - ; + : 'TOW' + ; AWAY - : 'AWAY' - ; + : 'AWAY' + ; STOPPING - : 'STOPPING' - ; + : 'STOPPING' + ; VALET - : 'VALET' - ; + : 'VALET' + ; ONLY - : 'ONLY' - ; + : 'ONLY' + ; VEHICLES - : 'VEHICLES' - ; + : 'VEHICLES' + ; WITH - : 'WITH' - ; + : 'WITH' + ; DISTRICT - : 'DISTRICT' - ; + : 'DISTRICT' + ; PERMITS - : 'PERMITS' - ; + : 'PERMITS' + ; EXEMPTED - : 'EXEMPTED' - ; + : 'EXEMPTED' + ; EXEMPT - : 'EXEMPT' - ; + : 'EXEMPT' + ; HOUR - : 'HOUR' - ; + : 'HOUR' + ; MINUTE - : 'MINUTE' - ; + : 'MINUTE' + ; MIN - : 'MIN' - ; + : 'MIN' + ; TEMPORARY - : 'TEMPORARY' - ; + : 'TEMPORARY' + ; PASSENGER - : 'PASSENGER' - ; + : 'PASSENGER' + ; LOADING - : 'LOADING' - ; + : 'LOADING' + ; day - : MON - | TUE - | WED - | THU - | FRI - | SAT - | SUN - ; + : MON + | TUE + | WED + | THU + | FRI + | SAT + | SUN + ; MON - : 'MONDAY' - | 'MON' - ; + : 'MONDAY' + | 'MON' + ; TUE - : 'TUESDAY' - | 'TUE' - ; + : 'TUESDAY' + | 'TUE' + ; WED - : 'WEDNESDAY' - | 'WED' - ; + : 'WEDNESDAY' + | 'WED' + ; THU - : 'THURSDAY' - | 'THU' - ; + : 'THURSDAY' + | 'THU' + ; FRI - : 'FRIDAY' - | 'FRI' - ; + : 'FRIDAY' + | 'FRI' + ; SAT - : 'SATURDAY' - | 'SAT' - ; + : 'SATURDAY' + | 'SAT' + ; SUN - : 'SUNDAY' - | 'SUN' - ; + : 'SUNDAY' + | 'SUN' + ; STREET - : 'STREET' - ; + : 'STREET' + ; SWEEPING - : 'SWEEPING' - ; + : 'SWEEPING' + ; CLEANING - : 'CLEANING' - ; + : 'CLEANING' + ; time - : INT (':' INT)? (am | pm)? - | twelveNoon - | twelveMidnight - ; + : INT (':' INT)? (am | pm)? + | twelveNoon + | twelveMidnight + ; twelveNoon - : NOON - | ('12' NOON) - ; + : NOON + | ('12' NOON) + ; twelveMidnight - : MIDNIGHT - | ('12' MIDNIGHT) - ; + : MIDNIGHT + | ('12' MIDNIGHT) + ; am - : 'AM' - | ('A.M.') - ; + : 'AM' + | ('A.M.') + ; pm - : 'PM' - | ('P.M.') - ; + : 'PM' + | ('P.M.') + ; NOON - : 'NOON' - ; + : 'NOON' + ; MIDNIGHT - : 'MIDNIGHT' - ; + : 'MIDNIGHT' + ; INT - : [0-9]+ - ; - // skip whitespace and periods (e.g., 7a.m.) - -WS - : [ \t\r\n.]+ -> skip - ; + : [0-9]+ + ; +// skip whitespace and periods (e.g., 7a.m.) + +WS + : [ \t\r\n.]+ -> skip + ; \ No newline at end of file diff --git a/pascal/pascal.g4 b/pascal/pascal.g4 index 1969457413..cecae30431 100644 --- a/pascal/pascal.g4 +++ b/pascal/pascal.g4 @@ -33,860 +33,798 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Adapted from pascal.g by Hakki Dogusan, Piet Schoutteten and Marton Papp */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar pascal; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} program - : programHeading (INTERFACE)? block DOT EOF - ; + : programHeading (INTERFACE)? block DOT EOF + ; programHeading - : PROGRAM identifier (LPAREN identifierList RPAREN)? SEMI - | UNIT identifier SEMI - ; + : PROGRAM identifier (LPAREN identifierList RPAREN)? SEMI + | UNIT identifier SEMI + ; identifier - : IDENT - ; + : IDENT + ; block - : (labelDeclarationPart | constantDefinitionPart | typeDefinitionPart | variableDeclarationPart | procedureAndFunctionDeclarationPart | usesUnitsPart | IMPLEMENTATION)* compoundStatement - ; + : ( + labelDeclarationPart + | constantDefinitionPart + | typeDefinitionPart + | variableDeclarationPart + | procedureAndFunctionDeclarationPart + | usesUnitsPart + | IMPLEMENTATION + )* compoundStatement + ; usesUnitsPart - : USES identifierList SEMI - ; + : USES identifierList SEMI + ; labelDeclarationPart - : LABEL label (COMMA label)* SEMI - ; + : LABEL label (COMMA label)* SEMI + ; label - : unsignedInteger - ; + : unsignedInteger + ; constantDefinitionPart - : CONST (constantDefinition SEMI) + - ; + : CONST (constantDefinition SEMI)+ + ; constantDefinition - : identifier EQUAL constant - ; + : identifier EQUAL constant + ; constantChr - : CHR LPAREN unsignedInteger RPAREN - ; + : CHR LPAREN unsignedInteger RPAREN + ; constant - : unsignedNumber - | sign unsignedNumber - | identifier - | sign identifier - | string - | constantChr - ; + : unsignedNumber + | sign unsignedNumber + | identifier + | sign identifier + | string + | constantChr + ; unsignedNumber - : unsignedInteger - | unsignedReal - ; + : unsignedInteger + | unsignedReal + ; unsignedInteger - : NUM_INT - ; + : NUM_INT + ; unsignedReal - : NUM_REAL - ; + : NUM_REAL + ; sign - : PLUS - | MINUS - ; + : PLUS + | MINUS + ; bool_ - : TRUE - | FALSE - ; + : TRUE + | FALSE + ; string - : STRING_LITERAL - ; + : STRING_LITERAL + ; typeDefinitionPart - : TYPE (typeDefinition SEMI) + - ; + : TYPE (typeDefinition SEMI)+ + ; typeDefinition - : identifier EQUAL (type_ | functionType | procedureType) - ; + : identifier EQUAL (type_ | functionType | procedureType) + ; functionType - : FUNCTION (formalParameterList)? COLON resultType - ; + : FUNCTION (formalParameterList)? COLON resultType + ; procedureType - : PROCEDURE (formalParameterList)? - ; + : PROCEDURE (formalParameterList)? + ; type_ - : simpleType - | structuredType - | pointerType - ; + : simpleType + | structuredType + | pointerType + ; simpleType - : scalarType - | subrangeType - | typeIdentifier - | stringtype - ; + : scalarType + | subrangeType + | typeIdentifier + | stringtype + ; scalarType - : LPAREN identifierList RPAREN - ; + : LPAREN identifierList RPAREN + ; subrangeType - : constant DOTDOT constant - ; + : constant DOTDOT constant + ; typeIdentifier - : identifier - | (CHAR | BOOLEAN | INTEGER | REAL | STRING) - ; + : identifier + | (CHAR | BOOLEAN | INTEGER | REAL | STRING) + ; structuredType - : PACKED unpackedStructuredType - | unpackedStructuredType - ; + : PACKED unpackedStructuredType + | unpackedStructuredType + ; unpackedStructuredType - : arrayType - | recordType - | setType - | fileType - ; + : arrayType + | recordType + | setType + | fileType + ; stringtype - : STRING LBRACK (identifier | unsignedNumber) RBRACK - ; + : STRING LBRACK (identifier | unsignedNumber) RBRACK + ; arrayType - : ARRAY LBRACK typeList RBRACK OF componentType - | ARRAY LBRACK2 typeList RBRACK2 OF componentType - ; + : ARRAY LBRACK typeList RBRACK OF componentType + | ARRAY LBRACK2 typeList RBRACK2 OF componentType + ; typeList - : indexType (COMMA indexType)* - ; + : indexType (COMMA indexType)* + ; indexType - : simpleType - ; + : simpleType + ; componentType - : type_ - ; + : type_ + ; recordType - : RECORD fieldList? END - ; + : RECORD fieldList? END + ; fieldList - : fixedPart (SEMI variantPart)? - | variantPart - ; + : fixedPart (SEMI variantPart)? + | variantPart + ; fixedPart - : recordSection (SEMI recordSection)* - ; + : recordSection (SEMI recordSection)* + ; recordSection - : identifierList COLON type_ - ; + : identifierList COLON type_ + ; variantPart - : CASE tag OF variant (SEMI variant)* - ; + : CASE tag OF variant (SEMI variant)* + ; tag - : identifier COLON typeIdentifier - | typeIdentifier - ; + : identifier COLON typeIdentifier + | typeIdentifier + ; variant - : constList COLON LPAREN fieldList RPAREN - ; + : constList COLON LPAREN fieldList RPAREN + ; setType - : SET OF baseType - ; + : SET OF baseType + ; baseType - : simpleType - ; + : simpleType + ; fileType - : FILE OF type_ - | FILE - ; + : FILE OF type_ + | FILE + ; pointerType - : POINTER typeIdentifier - ; + : POINTER typeIdentifier + ; variableDeclarationPart - : VAR variableDeclaration (SEMI variableDeclaration)* SEMI - ; + : VAR variableDeclaration (SEMI variableDeclaration)* SEMI + ; variableDeclaration - : identifierList COLON type_ - ; + : identifierList COLON type_ + ; procedureAndFunctionDeclarationPart - : procedureOrFunctionDeclaration SEMI - ; + : procedureOrFunctionDeclaration SEMI + ; procedureOrFunctionDeclaration - : procedureDeclaration - | functionDeclaration - ; + : procedureDeclaration + | functionDeclaration + ; procedureDeclaration - : PROCEDURE identifier (formalParameterList)? SEMI block - ; + : PROCEDURE identifier (formalParameterList)? SEMI block + ; formalParameterList - : LPAREN formalParameterSection (SEMI formalParameterSection)* RPAREN - ; + : LPAREN formalParameterSection (SEMI formalParameterSection)* RPAREN + ; formalParameterSection - : parameterGroup - | VAR parameterGroup - | FUNCTION parameterGroup - | PROCEDURE parameterGroup - ; + : parameterGroup + | VAR parameterGroup + | FUNCTION parameterGroup + | PROCEDURE parameterGroup + ; parameterGroup - : identifierList COLON typeIdentifier - ; + : identifierList COLON typeIdentifier + ; identifierList - : identifier (COMMA identifier)* - ; + : identifier (COMMA identifier)* + ; constList - : constant (COMMA constant)* - ; + : constant (COMMA constant)* + ; functionDeclaration - : FUNCTION identifier (formalParameterList)? COLON resultType SEMI block - ; + : FUNCTION identifier (formalParameterList)? COLON resultType SEMI block + ; resultType - : typeIdentifier - ; + : typeIdentifier + ; statement - : label COLON unlabelledStatement - | unlabelledStatement - ; + : label COLON unlabelledStatement + | unlabelledStatement + ; unlabelledStatement - : simpleStatement - | structuredStatement - ; + : simpleStatement + | structuredStatement + ; simpleStatement - : assignmentStatement - | procedureStatement - | gotoStatement - | emptyStatement_ - ; + : assignmentStatement + | procedureStatement + | gotoStatement + | emptyStatement_ + ; assignmentStatement - : variable ASSIGN expression - ; + : variable ASSIGN expression + ; variable - : (AT identifier | identifier) (LBRACK expression (COMMA expression)* RBRACK | LBRACK2 expression (COMMA expression)* RBRACK2 | DOT identifier | POINTER)* - ; + : (AT identifier | identifier) ( + LBRACK expression (COMMA expression)* RBRACK + | LBRACK2 expression (COMMA expression)* RBRACK2 + | DOT identifier + | POINTER + )* + ; expression - : simpleExpression (relationaloperator expression)? - ; + : simpleExpression (relationaloperator expression)? + ; relationaloperator - : EQUAL - | NOT_EQUAL - | LT - | LE - | GE - | GT - | IN - ; + : EQUAL + | NOT_EQUAL + | LT + | LE + | GE + | GT + | IN + ; simpleExpression - : term (additiveoperator simpleExpression)? - ; + : term (additiveoperator simpleExpression)? + ; additiveoperator - : PLUS - | MINUS - | OR - ; + : PLUS + | MINUS + | OR + ; term - : signedFactor (multiplicativeoperator term)? - ; + : signedFactor (multiplicativeoperator term)? + ; multiplicativeoperator - : STAR - | SLASH - | DIV - | MOD - | AND - ; + : STAR + | SLASH + | DIV + | MOD + | AND + ; signedFactor - : (PLUS | MINUS)? factor - ; + : (PLUS | MINUS)? factor + ; factor - : variable - | LPAREN expression RPAREN - | functionDesignator - | unsignedConstant - | set_ - | NOT factor - | bool_ - ; + : variable + | LPAREN expression RPAREN + | functionDesignator + | unsignedConstant + | set_ + | NOT factor + | bool_ + ; unsignedConstant - : unsignedNumber - | constantChr - | string - | NIL - ; + : unsignedNumber + | constantChr + | string + | NIL + ; functionDesignator - : identifier LPAREN parameterList RPAREN - ; + : identifier LPAREN parameterList RPAREN + ; parameterList - : actualParameter (COMMA actualParameter)* - ; + : actualParameter (COMMA actualParameter)* + ; set_ - : LBRACK elementList RBRACK - | LBRACK2 elementList RBRACK2 - ; + : LBRACK elementList RBRACK + | LBRACK2 elementList RBRACK2 + ; elementList - : element (COMMA element)* - | - ; + : element (COMMA element)* + | + ; element - : expression (DOTDOT expression)? - ; + : expression (DOTDOT expression)? + ; procedureStatement - : identifier (LPAREN parameterList RPAREN)? - ; + : identifier (LPAREN parameterList RPAREN)? + ; actualParameter - : expression parameterwidth* - ; + : expression parameterwidth* + ; parameterwidth - : COLON expression - ; + : COLON expression + ; gotoStatement - : GOTO label - ; + : GOTO label + ; emptyStatement_ - : - ; + : + ; empty_ - : - /* empty */ - ; + : + /* empty */ + ; structuredStatement - : compoundStatement - | conditionalStatement - | repetetiveStatement - | withStatement - ; + : compoundStatement + | conditionalStatement + | repetetiveStatement + | withStatement + ; compoundStatement - : BEGIN statements END - ; + : BEGIN statements END + ; statements - : statement (SEMI statement)* - ; + : statement (SEMI statement)* + ; conditionalStatement - : ifStatement - | caseStatement - ; + : ifStatement + | caseStatement + ; ifStatement - : IF expression THEN statement (: ELSE statement)? - ; - -caseStatement - : CASE expression OF caseListElement (SEMI caseListElement)* (SEMI ELSE statements)? END - ; - -caseListElement - : constList COLON statement - ; - -repetetiveStatement - : whileStatement - | repeatStatement - | forStatement - ; - -whileStatement - : WHILE expression DO statement - ; - -repeatStatement - : REPEAT statements UNTIL expression - ; - -forStatement - : FOR identifier ASSIGN forList DO statement - ; - -forList - : initialValue (TO | DOWNTO) finalValue - ; - -initialValue - : expression - ; - -finalValue - : expression - ; - -withStatement - : WITH recordVariableList DO statement - ; - -recordVariableList - : variable (COMMA variable)* - ; - -AND - : 'AND' - ; - - -ARRAY - : 'ARRAY' - ; - - -BEGIN - : 'BEGIN' - ; - - -BOOLEAN - : 'BOOLEAN' - ; - - -CASE - : 'CASE' - ; - - -CHAR - : 'CHAR' - ; - - -CHR - : 'CHR' - ; - - -CONST - : 'CONST' - ; - - -DIV - : 'DIV' - ; - - -DO - : 'DO' - ; - - -DOWNTO - : 'DOWNTO' - ; - - -ELSE - : 'ELSE' - ; - - -END - : 'END' - ; - - -FILE - : 'FILE' - ; - - -FOR - : 'FOR' - ; - - -FUNCTION - : 'FUNCTION' - ; - - -GOTO - : 'GOTO' - ; - - -IF - : 'IF' - ; - - -IN - : 'IN' - ; - - -INTEGER - : 'INTEGER' - ; - - -LABEL - : 'LABEL' - ; - - -MOD - : 'MOD' - ; - - -NIL - : 'NIL' - ; - - -NOT - : 'NOT' - ; - - -OF - : 'OF' - ; - - -OR - : 'OR' - ; - - -PACKED - : 'PACKED' - ; - - -PROCEDURE - : 'PROCEDURE' - ; - - -PROGRAM - : 'PROGRAM' - ; - - -REAL - : 'REAL' - ; - - -RECORD - : 'RECORD' - ; - - -REPEAT - : 'REPEAT' - ; - - -SET - : 'SET' - ; - - -THEN - : 'THEN' - ; - - -TO - : 'TO' - ; + : IF expression THEN statement (: ELSE statement)? + ; + caseStatement + : CASE expression OF caseListElement (SEMI caseListElement)* (SEMI ELSE statements)? END + ; -TYPE - : 'TYPE' - ; + caseListElement + : constList COLON statement + ; + repetetiveStatement + : whileStatement + | repeatStatement + | forStatement + ; -UNTIL - : 'UNTIL' - ; + whileStatement + : WHILE expression DO statement + ; + repeatStatement + : REPEAT statements UNTIL expression + ; -VAR - : 'VAR' - ; + forStatement + : FOR identifier ASSIGN forList DO statement + ; + forList + : initialValue (TO | DOWNTO) finalValue + ; -WHILE - : 'WHILE' - ; + initialValue + : expression + ; + finalValue + : expression + ; -WITH - : 'WITH' - ; + withStatement + : WITH recordVariableList DO statement + ; + recordVariableList + : variable (COMMA variable)* + ; -PLUS - : '+' - ; + AND + : 'AND' + ; + ARRAY + : 'ARRAY' + ; -MINUS - : '-' - ; + BEGIN + : 'BEGIN' + ; + BOOLEAN + : 'BOOLEAN' + ; -STAR - : '*' - ; + CASE + : 'CASE' + ; + CHAR + : 'CHAR' + ; -SLASH - : '/' - ; + CHR + : 'CHR' + ; + CONST + : 'CONST' + ; -ASSIGN - : ':=' - ; + DIV + : 'DIV' + ; + DO + : 'DO' + ; -COMMA - : ',' - ; + DOWNTO + : 'DOWNTO' + ; + ELSE + : 'ELSE' + ; -SEMI - : ';' - ; + END + : 'END' + ; + FILE + : 'FILE' + ; -COLON - : ':' - ; + FOR + : 'FOR' + ; + FUNCTION + : 'FUNCTION' + ; -EQUAL - : '=' - ; + GOTO + : 'GOTO' + ; + IF + : 'IF' + ; -NOT_EQUAL - : '<>' - ; + IN + : 'IN' + ; + INTEGER + : 'INTEGER' + ; -LT - : '<' - ; + LABEL + : 'LABEL' + ; + MOD + : 'MOD' + ; -LE - : '<=' - ; + NIL + : 'NIL' + ; + NOT + : 'NOT' + ; -GE - : '>=' - ; + OF + : 'OF' + ; + OR + : 'OR' + ; -GT - : '>' - ; + PACKED + : 'PACKED' + ; + PROCEDURE + : 'PROCEDURE' + ; -LPAREN - : '(' - ; + PROGRAM + : 'PROGRAM' + ; + REAL + : 'REAL' + ; -RPAREN - : ')' - ; + RECORD + : 'RECORD' + ; + REPEAT + : 'REPEAT' + ; -LBRACK - : '[' - ; + SET + : 'SET' + ; + THEN + : 'THEN' + ; -LBRACK2 - : '(.' - ; + TO + : 'TO' + ; + TYPE + : 'TYPE' + ; -RBRACK - : ']' - ; + UNTIL + : 'UNTIL' + ; + VAR + : 'VAR' + ; -RBRACK2 - : '.)' - ; + WHILE + : 'WHILE' + ; + WITH + : 'WITH' + ; -POINTER - : '^' - ; + PLUS + : '+' + ; + MINUS + : '-' + ; -AT - : '@' - ; + STAR + : '*' + ; + SLASH + : '/' + ; -DOT - : '.' - ; + ASSIGN + : ':=' + ; + COMMA + : ',' + ; -DOTDOT - : '..' - ; + SEMI + : ';' + ; + COLON + : ':' + ; -LCURLY - : '{' - ; + EQUAL + : '=' + ; + NOT_EQUAL + : '<>' + ; -RCURLY - : '}' - ; + LT + : '<' + ; + LE + : '<=' + ; -UNIT - : 'UNIT' - ; + GE + : '>=' + ; + GT + : '>' + ; -INTERFACE - : 'INTERFACE' - ; + LPAREN + : '(' + ; + RPAREN + : ')' + ; -USES - : 'USES' - ; + LBRACK + : '[' + ; + LBRACK2 + : '(.' + ; -STRING - : 'STRING' - ; + RBRACK + : ']' + ; + RBRACK2 + : '.)' + ; -IMPLEMENTATION - : 'IMPLEMENTATION' - ; + POINTER + : '^' + ; + AT + : '@' + ; -TRUE - : 'TRUE' - ; + DOT + : '.' + ; + DOTDOT + : '..' + ; -FALSE - : 'FALSE' - ; + LCURLY + : '{' + ; + RCURLY + : '}' + ; -WS - : [ \t\r\n] -> skip - ; + UNIT + : 'UNIT' + ; + INTERFACE + : 'INTERFACE' + ; -COMMENT_1 - : '(*' .*? '*)' -> skip - ; + USES + : 'USES' + ; + STRING + : 'STRING' + ; -COMMENT_2 - : '{' .*? '}' -> skip - ; + IMPLEMENTATION + : 'IMPLEMENTATION' + ; + TRUE + : 'TRUE' + ; -IDENT - : ('A' .. 'Z') ('A' .. 'Z' | '0' .. '9' | '_')* - ; + FALSE + : 'FALSE' + ; + WS + : [ \t\r\n] -> skip + ; -STRING_LITERAL - : '\'' ('\'\'' | ~ ('\''))* '\'' - ; + COMMENT_1 + : '(*' .*? '*)' -> skip + ; + COMMENT_2 + : '{' .*? '}' -> skip + ; -NUM_INT - : ('0' .. '9') + - ; + IDENT + : ('A' .. 'Z') ('A' .. 'Z' | '0' .. '9' | '_')* + ; + STRING_LITERAL + : '\'' ('\'\'' | ~ ('\''))* '\'' + ; -NUM_REAL - : ('0' .. '9') + (('.' ('0' .. '9') + (EXPONENT)?)? | EXPONENT) - ; + NUM_INT + : ('0' .. '9')+ + ; + NUM_REAL + : ('0' .. '9')+ (('.' ('0' .. '9')+ (EXPONENT)?)? | EXPONENT) + ; -fragment EXPONENT - : ('E') ('+' | '-')? ('0' .. '9') + - ; + fragment EXPONENT + : ('E') ('+' | '-')? ('0' .. '9')+ + ; \ No newline at end of file diff --git a/pbm/pbm.g4 b/pbm/pbm.g4 index 814f928d7e..7decf4e970 100644 --- a/pbm/pbm.g4 +++ b/pbm/pbm.g4 @@ -29,45 +29,48 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar pbm; file_ - : magic width height table EOF - ; + : magic width height table EOF + ; magic - : MAGIC - ; + : MAGIC + ; width - : number - ; + : number + ; height - : number - ; + : number + ; table - : ('0' | '1')+ - ; + : ('0' | '1')+ + ; number - : DIGITS - ; + : DIGITS + ; MAGIC - : 'P' [0-9] - ; + : 'P' [0-9] + ; DIGITS - : [0-9]+ - ; + : [0-9]+ + ; COMMENT - : '#' (~ [\r\n])* -> skip - ; + : '#' (~ [\r\n])* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/pcre/PCRE.g4 b/pcre/PCRE.g4 index 588fa3ca7a..26e9942504 100644 --- a/pcre/PCRE.g4 +++ b/pcre/PCRE.g4 @@ -31,182 +31,189 @@ * Based on http://www.pcre.org/pcre.txt * (REVISION Last updated: 14 June 2021) */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar PCRE; pcre - : alternation? EOF - ; + : alternation? EOF + ; alternation - : expr ( '|' expr? )* - ; + : expr ('|' expr?)* + ; expr - : element+ - ; + : element+ + ; element - : atom quantifier? - ; + : atom quantifier? + ; atom - : option_setting - | backtracking_control - | callout - | capture - | atomic_group - | lookaround - | backreference - | subroutine_reference - | conditional_pattern - | comment - | character - | character_type - | character_class - | posix_character_class - | letter - | digit - | anchor - | match_point_reset - | quoting - | other - ; + : option_setting + | backtracking_control + | callout + | capture + | atomic_group + | lookaround + | backreference + | subroutine_reference + | conditional_pattern + | comment + | character + | character_type + | character_class + | posix_character_class + | letter + | digit + | anchor + | match_point_reset + | quoting + | other + ; capture - : '(' ( alternation - | '?' ( '<' name '>' alternation - | '\'' name '\'' alternation - | 'P' '<' name '>' alternation - | ( option_setting_flag+ ( '-' option_setting_flag+ )? )? ':' alternation - | '|' alternation - ) - ) - ')' - ; + : '(' ( + alternation + | '?' ( + '<' name '>' alternation + | '\'' name '\'' alternation + | 'P' '<' name '>' alternation + | ( option_setting_flag+ ( '-' option_setting_flag+)?)? ':' alternation + | '|' alternation + ) + ) ')' + ; atomic_group - : '(' '?' '>' alternation ')' - ; + : '(' '?' '>' alternation ')' + ; lookaround - : '(' '?' ( '=' | '!' | '<' '=' | '<' '!' ) alternation ')' - ; + : '(' '?' ('=' | '!' | '<' '=' | '<' '!') alternation ')' + ; backreference - : '\\' ( 'g' digits + : '\\' ( + 'g' digits | 'g' '{' '-'? digits '}' | 'g' '{' name '}' | 'k' '<' name '>' | 'k' '\'' name '\'' | 'k' '{' name '}' - ) - | '(' '?' 'P' '=' name ')' - ; + ) + | '(' '?' 'P' '=' name ')' + ; subroutine_reference - : '(' '?' ( 'R' - | ( '+' | '-' )? digits - | '&' name - | 'P' '>' name - ) - ')' - | '\\' 'g' ( '<' name '>' - | '\'' name '\'' - | '<' ( '+' | '-' )? digits '>' - | '\'' ( '+' | '-' )? digits '\'' - ) - ; + : '(' '?' ('R' | ( '+' | '-')? digits | '&' name | 'P' '>' name) ')' + | '\\' 'g' ( + '<' name '>' + | '\'' name '\'' + | '<' ( '+' | '-')? digits '>' + | '\'' ( '+' | '-')? digits '\'' + ) + ; conditional_pattern - : '(' '?' ( '(' ( ( '+' | '-' )? digits - | '<' name '>' - | '\'' name '\'' - | 'R' digits? - | 'R' '&' name - | name - ) - ')' - | callout - | lookaround - ) - expr - ( '|' no_pattern=expr )? ')' - ; + : '(' '?' ( + '(' ( + ( '+' | '-')? digits + | '<' name '>' + | '\'' name '\'' + | 'R' digits? + | 'R' '&' name + | name + ) ')' + | callout + | lookaround + ) expr ('|' no_pattern = expr)? ')' + ; comment - : '(' '?' '#' ~')'+ ')' - ; + : '(' '?' '#' ~')'+ ')' + ; quantifier - : ( '?' | '*' | '+' ) ( possessive='+' | lazy='?' )? - | '{' from=digits ( ',' to=digits? )? '}' ( possessive='+' | lazy='?' )? - ; + : ('?' | '*' | '+') (possessive = '+' | lazy = '?')? + | '{' from = digits ( ',' to = digits?)? '}' ( possessive = '+' | lazy = '?')? + ; option_setting - : '(' ( '*' ( utf ( '8' | '1' '6' | '3' '2' )? - | ucp - | no_auto_possess - | no_start_opt - | newline_conventions - | limit_match '=' digits - | limit_recursion '=' digits - | bsr_anycrlf - | bsr_unicode - ) - | '?' ( option_setting_flag+ ( '-' option_setting_flag+ )? - | '-' option_setting_flag+ - ) - ) - ')' - ; + : '(' ( + '*' ( + utf ( '8' | '1' '6' | '3' '2')? + | ucp + | no_auto_possess + | no_start_opt + | newline_conventions + | limit_match '=' digits + | limit_recursion '=' digits + | bsr_anycrlf + | bsr_unicode + ) + | '?' (option_setting_flag+ ( '-' option_setting_flag+)? | '-' option_setting_flag+) + ) ')' + ; option_setting_flag - : 'i' | 'J' | 'm' | 's' | 'U' | 'x' - ; + : 'i' + | 'J' + | 'm' + | 's' + | 'U' + | 'x' + ; backtracking_control - : '(' '*' ( accept_ - | fail - | mark? ':' name - | commit - | prune ( ':' name )? - | skip ( ':' name )? - | then ( ':' name )? - ) - ')' - ; + : '(' '*' ( + accept_ + | fail + | mark? ':' name + | commit + | prune ( ':' name)? + | skip ( ':' name)? + | then ( ':' name)? + ) ')' + ; callout - : '(' '?' 'C' digits? ')' - ; + : '(' '?' 'C' digits? ')' + ; newline_conventions - : cr - | lf - | crlf - | anycrlf - | any - ; + : cr + | lf + | crlf + | anycrlf + | any + ; character - : '\\' ( 'a' + : '\\' ( + 'a' | 'c' . | 'e' | 'f' | 'n' | 'r' | 't' - | digit ( digit digit? )? // can also be a backreference + | digit (digit digit?)? // can also be a backreference | 'o' '{' digit digit digit+ '}' | 'x' hex hex | 'x' '{' hex hex hex+ '}' - | 'u' hex hex hex hex ( hex hex hex hex )? - ) - ; + | 'u' hex hex hex hex ( hex hex hex hex)? + ) + ; character_type - : '.' - | '\\' ( 'C' + : '.' + | '\\' ( + 'C' | 'd' | 'D' | 'h' @@ -223,225 +230,614 @@ character_type | 'w' | 'W' | 'X' - ) - ; + ) + ; character_class - : '[' negate='^'? ']' character_class_atom* ']' - | '[' negate='^'? character_class_atom+ ']' - ; + : '[' negate = '^'? ']' character_class_atom* ']' + | '[' negate = '^'? character_class_atom+ ']' + ; character_class_atom - : character_class_range - | posix_character_class - | character - | character_type - | '\\' . - | ~( '\\' | ']' ) - ; + : character_class_range + | posix_character_class + | character + | character_type + | '\\' . + | ~( '\\' | ']') + ; character_class_range - : character_class_range_atom '-' character_class_range_atom - ; + : character_class_range_atom '-' character_class_range_atom + ; character_class_range_atom - : character - | ~']' - ; + : character + | ~']' + ; posix_character_class - : '[:' negate='^'? letters ':]' - ; + : '[:' negate = '^'? letters ':]' + ; anchor - : '\\' ( 'b' | 'B' | 'A' | 'z' | 'Z' | 'G' ) - | '^' - | '$' - ; + : '\\' ('b' | 'B' | 'A' | 'z' | 'Z' | 'G') + | '^' + | '$' + ; match_point_reset - : '\\' 'K' - ; + : '\\' 'K' + ; quoting - : '\\' ('Q' .*? '\\' 'E' | .) - ; + : '\\' ('Q' .*? '\\' 'E' | .) + ; // Helper rules -digits : digit+; -digit : D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9; -hex : digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F'; -letters : letter+; +digits + : digit+ + ; + +digit + : D0 + | D1 + | D2 + | D3 + | D4 + | D5 + | D6 + | D7 + | D8 + | D9 + ; + +hex + : digit + | 'a' + | 'b' + | 'c' + | 'd' + | 'e' + | 'f' + | 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + ; + +letters + : letter+ + ; letter - : 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' - | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' - | '_' - ; + : 'a' + | 'b' + | 'c' + | 'd' + | 'e' + | 'f' + | 'g' + | 'h' + | 'i' + | 'j' + | 'k' + | 'l' + | 'm' + | 'n' + | 'o' + | 'p' + | 'q' + | 'r' + | 's' + | 't' + | 'u' + | 'v' + | 'w' + | 'x' + | 'y' + | 'z' + | 'A' + | 'B' + | 'C' + | 'D' + | 'E' + | 'F' + | 'G' + | 'H' + | 'I' + | 'J' + | 'K' + | 'L' + | 'M' + | 'N' + | 'O' + | 'P' + | 'Q' + | 'R' + | 'S' + | 'T' + | 'U' + | 'V' + | 'W' + | 'X' + | 'Y' + | 'Z' + | '_' + ; name - : letter ( letter | digit )* - ; + : letter (letter | digit)* + ; other - : '}' - | ']' - | ',' - | '-' - | '_' - | '=' - | '&' - | '<' - | '>' - | '\'' - | ':' - | '#' - | '!' - | OTHER - ; - -utf : 'U' 'T' 'F'; -ucp : 'U' 'C' 'P'; -no_auto_possess : 'N' 'O' '_' 'A' 'U' 'T' 'O' '_' 'P' 'O' 'S' 'S' 'E' 'S' 'S'; -no_start_opt : 'N' 'O' '_' 'S' 'T' 'A' 'R' 'T' '_' 'O' 'P' 'T'; -cr : 'C' 'R'; -lf : 'L' 'F'; -crlf : 'C' 'R' 'L' 'F'; -anycrlf : 'A' 'N' 'Y' 'C' 'R' 'L' 'F'; -any : 'A' 'N' 'Y'; -limit_match : 'L' 'I' 'M' 'I' 'T' '_' 'M' 'A' 'T' 'C' 'H'; -limit_recursion : 'L' 'I' 'M' 'I' 'T' '_' 'R' 'E' 'C' 'U' 'R' 'S' 'I' 'O' 'N'; -bsr_anycrlf : 'B' 'S' 'R' '_' 'A' 'N' 'Y' 'C' 'R' 'L' 'F'; -bsr_unicode : 'B' 'S' 'R' '_' 'U' 'N' 'I' 'C' 'O' 'D' 'E'; -accept_ : 'A' 'C' 'C' 'E' 'P' 'T'; -fail : 'F' ( 'A' 'I' 'L' )?; -mark : 'M' 'A' 'R' 'K'; -commit : 'C' 'O' 'M' 'M' 'I' 'T'; -prune : 'P' 'R' 'U' 'N' 'E'; -skip : 'S' 'K' 'I' 'P'; -then : 'T' 'H' 'E' 'N'; + : '}' + | ']' + | ',' + | '-' + | '_' + | '=' + | '&' + | '<' + | '>' + | '\'' + | ':' + | '#' + | '!' + | OTHER + ; + +utf + : 'U' 'T' 'F' + ; + +ucp + : 'U' 'C' 'P' + ; + +no_auto_possess + : 'N' 'O' '_' 'A' 'U' 'T' 'O' '_' 'P' 'O' 'S' 'S' 'E' 'S' 'S' + ; + +no_start_opt + : 'N' 'O' '_' 'S' 'T' 'A' 'R' 'T' '_' 'O' 'P' 'T' + ; + +cr + : 'C' 'R' + ; + +lf + : 'L' 'F' + ; + +crlf + : 'C' 'R' 'L' 'F' + ; + +anycrlf + : 'A' 'N' 'Y' 'C' 'R' 'L' 'F' + ; + +any + : 'A' 'N' 'Y' + ; + +limit_match + : 'L' 'I' 'M' 'I' 'T' '_' 'M' 'A' 'T' 'C' 'H' + ; + +limit_recursion + : 'L' 'I' 'M' 'I' 'T' '_' 'R' 'E' 'C' 'U' 'R' 'S' 'I' 'O' 'N' + ; + +bsr_anycrlf + : 'B' 'S' 'R' '_' 'A' 'N' 'Y' 'C' 'R' 'L' 'F' + ; + +bsr_unicode + : 'B' 'S' 'R' '_' 'U' 'N' 'I' 'C' 'O' 'D' 'E' + ; + +accept_ + : 'A' 'C' 'C' 'E' 'P' 'T' + ; + +fail + : 'F' ('A' 'I' 'L')? + ; + +mark + : 'M' 'A' 'R' 'K' + ; + +commit + : 'C' 'O' 'M' 'M' 'I' 'T' + ; + +prune + : 'P' 'R' 'U' 'N' 'E' + ; + +skip + : 'S' 'K' 'I' 'P' + ; + +then + : 'T' 'H' 'E' 'N' + ; /// \ general escape character with several uses -BSlash : '\\'; +BSlash + : '\\' + ; /// $ assert end of string (or line, in multiline mode) -Dollar : '$'; +Dollar + : '$' + ; /// . match any character except newline (by default) -Dot : '.'; +Dot + : '.' + ; /// [ start character class definition -OBrack : '['; +OBrack + : '[' + ; /// ^ assert start of string (or line, in multiline mode) -Caret : '^'; +Caret + : '^' + ; /// | start of alternative branch -Pipe : '|'; +Pipe + : '|' + ; /// ? extends the meaning of (, also 0 or 1 quantifier.txt, also quantifier.txt minimizer -QMark : '?'; +QMark + : '?' + ; /// * 0 or more quantifier.txt -Star : '*'; +Star + : '*' + ; /// + 1 or more quantifier.txt, also "possessive quantifier.txt" -Plus : '+'; +Plus + : '+' + ; /// { start min/max quantifier.txt -OBrace : '{'; +OBrace + : '{' + ; -CBrace : '}'; +CBrace + : '}' + ; /// ( start subpattern -OPar : '('; +OPar + : '(' + ; /// ) end subpattern -CPar : ')'; +CPar + : ')' + ; /// ] terminates the character class -CBrack : ']'; - -OPosixBrack : '[:'; -CPosixBrack : ':]'; - -Comma : ','; -Dash : '-'; -UScore : '_'; -Eq : '='; -Amp : '&'; -Lt : '<'; -Gt : '>'; -Quote : '\''; -Col : ':'; -Hash : '#'; -Excl : '!'; - -Au : 'A'; -Bu : 'B'; -Cu : 'C'; -Du : 'D'; -Eu : 'E'; -Fu : 'F'; -Gu : 'G'; -Hu : 'H'; -Iu : 'I'; -Ju : 'J'; -Ku : 'K'; -Lu : 'L'; -Mu : 'M'; -Nu : 'N'; -Ou : 'O'; -Pu : 'P'; -Qu : 'Q'; -Ru : 'R'; -Su : 'S'; -Tu : 'T'; -Uu : 'U'; -Vu : 'V'; -Wu : 'W'; -Xu : 'X'; -Yu : 'Y'; -Zu : 'Z'; - -Al : 'a'; -Bl : 'b'; -Cl : 'c'; -Dl : 'd'; -El : 'e'; -Fl : 'f'; -Gl : 'g'; -Hl : 'h'; -Il : 'i'; -Jl : 'j'; -Kl : 'k'; -Ll : 'l'; -Ml : 'm'; -Nl : 'n'; -Ol : 'o'; -Pl : 'p'; -Ql : 'q'; -Rl : 'r'; -Sl : 's'; -Tl : 't'; -Ul : 'u'; -Vl : 'v'; -Wl : 'w'; -Xl : 'x'; -Yl : 'y'; -Zl : 'z'; - -D0 : '0'; -D1 : '1'; -D2 : '2'; -D3 : '3'; -D4 : '4'; -D5 : '5'; -D6 : '6'; -D7 : '7'; -D8 : '8'; -D9 : '9'; +CBrack + : ']' + ; + +OPosixBrack + : '[:' + ; + +CPosixBrack + : ':]' + ; + +Comma + : ',' + ; + +Dash + : '-' + ; + +UScore + : '_' + ; + +Eq + : '=' + ; + +Amp + : '&' + ; + +Lt + : '<' + ; + +Gt + : '>' + ; + +Quote + : '\'' + ; + +Col + : ':' + ; + +Hash + : '#' + ; + +Excl + : '!' + ; + +Au + : 'A' + ; + +Bu + : 'B' + ; + +Cu + : 'C' + ; + +Du + : 'D' + ; + +Eu + : 'E' + ; + +Fu + : 'F' + ; + +Gu + : 'G' + ; + +Hu + : 'H' + ; + +Iu + : 'I' + ; + +Ju + : 'J' + ; + +Ku + : 'K' + ; + +Lu + : 'L' + ; + +Mu + : 'M' + ; + +Nu + : 'N' + ; + +Ou + : 'O' + ; + +Pu + : 'P' + ; + +Qu + : 'Q' + ; + +Ru + : 'R' + ; + +Su + : 'S' + ; + +Tu + : 'T' + ; + +Uu + : 'U' + ; + +Vu + : 'V' + ; + +Wu + : 'W' + ; + +Xu + : 'X' + ; + +Yu + : 'Y' + ; + +Zu + : 'Z' + ; + +Al + : 'a' + ; + +Bl + : 'b' + ; + +Cl + : 'c' + ; + +Dl + : 'd' + ; + +El + : 'e' + ; + +Fl + : 'f' + ; + +Gl + : 'g' + ; + +Hl + : 'h' + ; + +Il + : 'i' + ; + +Jl + : 'j' + ; + +Kl + : 'k' + ; + +Ll + : 'l' + ; + +Ml + : 'm' + ; + +Nl + : 'n' + ; + +Ol + : 'o' + ; + +Pl + : 'p' + ; + +Ql + : 'q' + ; + +Rl + : 'r' + ; + +Sl + : 's' + ; + +Tl + : 't' + ; + +Ul + : 'u' + ; + +Vl + : 'v' + ; + +Wl + : 'w' + ; + +Xl + : 'x' + ; + +Yl + : 'y' + ; + +Zl + : 'z' + ; + +D0 + : '0' + ; + +D1 + : '1' + ; + +D2 + : '2' + ; + +D3 + : '3' + ; + +D4 + : '4' + ; + +D5 + : '5' + ; + +D6 + : '6' + ; + +D7 + : '7' + ; + +D8 + : '8' + ; + +D9 + : '9' + ; OTHER - : . - ; + : . + ; \ No newline at end of file diff --git a/pddl/Pddl.g4 b/pddl/Pddl.g4 index eb43c2abe9..8c89525e91 100644 --- a/pddl/Pddl.g4 +++ b/pddl/Pddl.g4 @@ -1,4 +1,3 @@ - /** * PDDL grammar for ANTLR v3 * Zeyn Saigol @@ -7,113 +6,120 @@ * * $Id: Pddl.g 120 2008-10-02 14:59:50Z zas $ */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Pddl; /************* Start of grammar *******************/ pddlDoc - : ( domain | problem ) EOF - ; + : (domain | problem) EOF + ; /************* DOMAINS ****************************/ domain - : '(' 'define' domainName requireDef? typesDef? constantsDef? predicatesDef? functionsDef? constraints? structureDef* ')' - ; + : '(' 'define' domainName requireDef? typesDef? constantsDef? predicatesDef? functionsDef? constraints? structureDef* ')' + ; domainName - : '(' 'domain' NAME ')' - ; + : '(' 'domain' NAME ')' + ; requireDef - : '(' ':requirements' REQUIRE_KEY+ ')' - ; + : '(' ':requirements' REQUIRE_KEY+ ')' + ; typesDef - : '(' ':types' typedNameList ')' - ; + : '(' ':types' typedNameList ')' + ; // If have any typed names, they must come FIRST! typedNameList - : ( NAME* | singleTypeNameList+ NAME* ) - ; + : (NAME* | singleTypeNameList+ NAME*) + ; singleTypeNameList - : ( NAME+ '-' t = type_ ) - ; + : (NAME+ '-' t = type_) + ; type_ - : ( '(' 'either' primType+ ')' ) | primType - ; + : ('(' 'either' primType+ ')') + | primType + ; primType - : NAME - ; + : NAME + ; functionsDef - : '(' ':functions' functionList ')' - ; + : '(' ':functions' functionList ')' + ; functionList - : ( atomicFunctionSkeleton+ ( '-' functionType )? )* - ; + : (atomicFunctionSkeleton+ ( '-' functionType)?)* + ; atomicFunctionSkeleton - : '(' functionSymbol typedVariableList ')' - ; + : '(' functionSymbol typedVariableList ')' + ; functionSymbol - : NAME - ; + : NAME + ; functionType - : 'number' - ; + : 'number' + ; // Currently in PDDL only numeric functions are allowed constantsDef - : '(' ':constants' typedNameList ')' - ; + : '(' ':constants' typedNameList ')' + ; predicatesDef - : '(' ':predicates' atomicFormulaSkeleton+ ')' - ; + : '(' ':predicates' atomicFormulaSkeleton+ ')' + ; atomicFormulaSkeleton - : '(' predicate typedVariableList ')' - ; + : '(' predicate typedVariableList ')' + ; predicate - : NAME - ; + : NAME + ; // If have any typed variables, they must come FIRST! typedVariableList - : ( VARIABLE* | singleTypeVarList+ VARIABLE* ) - ; + : (VARIABLE* | singleTypeVarList+ VARIABLE*) + ; singleTypeVarList - : ( VARIABLE+ '-' t = type_ ) - ; + : (VARIABLE+ '-' t = type_) + ; constraints - : '(' ':constraints' conGD ')' - ; + : '(' ':constraints' conGD ')' + ; structureDef - : actionDef | durativeActionDef | derivedDef - ; + : actionDef + | durativeActionDef + | derivedDef + ; /************* ACTIONS ****************************/ actionDef - : '(' ':action' actionSymbol ':parameters' '(' typedVariableList ')' actionDefBody ')' - ; + : '(' ':action' actionSymbol ':parameters' '(' typedVariableList ')' actionDefBody ')' + ; actionSymbol - : NAME - ; + : NAME + ; // Should allow preGD instead of goalDesc for preconditions - // but I can't get the LL(*) parsing to work // This means 'preference' preconditions cannot be used actionDefBody - : ( ':precondition' ( ( '(' ')' ) | goalDesc ) )? ( ':effect' ( ( '(' ')' ) | effect ) )? - ; + : (':precondition' ( ( '(' ')') | goalDesc))? (':effect' ( ( '(' ')') | effect))? + ; //preGD // : prefGD @@ -126,435 +132,480 @@ actionDefBody // | goalDesc // ; goalDesc - : atomicTermFormula | '(' 'and' goalDesc* ')' | '(' 'or' goalDesc* ')' | '(' 'not' goalDesc ')' | '(' 'imply' goalDesc goalDesc ')' | '(' 'exists' '(' typedVariableList ')' goalDesc ')' | '(' 'forall' '(' typedVariableList ')' goalDesc ')' | fComp - ; + : atomicTermFormula + | '(' 'and' goalDesc* ')' + | '(' 'or' goalDesc* ')' + | '(' 'not' goalDesc ')' + | '(' 'imply' goalDesc goalDesc ')' + | '(' 'exists' '(' typedVariableList ')' goalDesc ')' + | '(' 'forall' '(' typedVariableList ')' goalDesc ')' + | fComp + ; fComp - : '(' binaryComp fExp fExp ')' - ; + : '(' binaryComp fExp fExp ')' + ; atomicTermFormula - : '(' predicate term* ')' - ; + : '(' predicate term* ')' + ; term - : NAME | VARIABLE - ; + : NAME + | VARIABLE + ; /************* DURATIVE ACTIONS ****************************/ durativeActionDef - : '(' ':durative-action' actionSymbol ':parameters' '(' typedVariableList ')' daDefBody ')' - ; + : '(' ':durative-action' actionSymbol ':parameters' '(' typedVariableList ')' daDefBody ')' + ; daDefBody - : ':duration' durationConstraint | ':condition' ( ( '(' ')' ) | daGD ) | ':effect' ( ( '(' ')' ) | daEffect ) - ; + : ':duration' durationConstraint + | ':condition' ( ( '(' ')') | daGD) + | ':effect' ( ( '(' ')') | daEffect) + ; daGD - : prefTimedGD | '(' 'and' daGD* ')' | '(' 'forall' '(' typedVariableList ')' daGD ')' - ; + : prefTimedGD + | '(' 'and' daGD* ')' + | '(' 'forall' '(' typedVariableList ')' daGD ')' + ; prefTimedGD - : timedGD | '(' 'preference' NAME? timedGD ')' - ; + : timedGD + | '(' 'preference' NAME? timedGD ')' + ; timedGD - : '(' 'at' timeSpecifier goalDesc ')' | '(' 'over' interval goalDesc ')' - ; + : '(' 'at' timeSpecifier goalDesc ')' + | '(' 'over' interval goalDesc ')' + ; timeSpecifier - : 'start' | 'end' - ; + : 'start' + | 'end' + ; interval - : 'all' - ; + : 'all' + ; /************* DERIVED DEFINITIONS ****************************/ derivedDef - : '(' ':derived' typedVariableList goalDesc ')' - ; + : '(' ':derived' typedVariableList goalDesc ')' + ; /************* EXPRESSIONS ****************************/ fExp - : NUMBER | '(' binaryOp fExp fExp2 ')' | '(' '-' fExp ')' | fHead - ; + : NUMBER + | '(' binaryOp fExp fExp2 ')' + | '(' '-' fExp ')' + | fHead + ; // This is purely a workaround for an ANTLR bug in tree construction // http://www.antlr.org/wiki/display/ANTLR3/multiple+occurences+of+a+token+mix+up+the+list+management+in+tree+rewrites fExp2 - : fExp - ; + : fExp + ; fHead - : '(' functionSymbol term* ')' | functionSymbol - ; + : '(' functionSymbol term* ')' + | functionSymbol + ; effect - : '(' 'and' cEffect* ')' | cEffect - ; + : '(' 'and' cEffect* ')' + | cEffect + ; cEffect - : '(' 'forall' '(' typedVariableList ')' effect ')' | '(' 'when' goalDesc condEffect ')' | pEffect - ; + : '(' 'forall' '(' typedVariableList ')' effect ')' + | '(' 'when' goalDesc condEffect ')' + | pEffect + ; pEffect - : '(' assignOp fHead fExp ')' | '(' 'not' atomicTermFormula ')' | atomicTermFormula - ; + : '(' assignOp fHead fExp ')' + | '(' 'not' atomicTermFormula ')' + | atomicTermFormula + ; // TODO: why is this different from the "and cEffect" above? Does it matter? condEffect - : '(' 'and' pEffect* ')' | pEffect - ; + : '(' 'and' pEffect* ')' + | pEffect + ; // TODO: should these be uppercase & lexer section? binaryOp - : '*' | '+' | '-' | '/' - ; + : '*' + | '+' + | '-' + | '/' + ; binaryComp - : '>' | '<' | '=' | '>=' | '<=' - ; + : '>' + | '<' + | '=' + | '>=' + | '<=' + ; assignOp - : 'assign' | 'scale-up' | 'scale-down' | 'increase' | 'decrease' - ; + : 'assign' + | 'scale-up' + | 'scale-down' + | 'increase' + | 'decrease' + ; /************* DURATIONS ****************************/ durationConstraint - : '(' 'and' simpleDurationConstraint+ ')' | '(' ')' | simpleDurationConstraint - ; + : '(' 'and' simpleDurationConstraint+ ')' + | '(' ')' + | simpleDurationConstraint + ; simpleDurationConstraint - : '(' durOp '?duration' durValue ')' | '(' 'at' timeSpecifier simpleDurationConstraint ')' - ; + : '(' durOp '?duration' durValue ')' + | '(' 'at' timeSpecifier simpleDurationConstraint ')' + ; durOp - : '<=' | '>=' | '=' - ; + : '<=' + | '>=' + | '=' + ; durValue - : NUMBER | fExp - ; + : NUMBER + | fExp + ; daEffect - : '(' 'and' daEffect* ')' | timedEffect | '(' 'forall' '(' typedVariableList ')' daEffect ')' | '(' 'when' daGD timedEffect ')' | '(' assignOp fHead fExpDA ')' - ; + : '(' 'and' daEffect* ')' + | timedEffect + | '(' 'forall' '(' typedVariableList ')' daEffect ')' + | '(' 'when' daGD timedEffect ')' + | '(' assignOp fHead fExpDA ')' + ; timedEffect - : '(' 'at' timeSpecifier daEffect ')' | '(' 'at' timeSpecifier fAssignDA ')' | '(' assignOp fHead fExp ')' - ; + : '(' 'at' timeSpecifier daEffect ')' + | '(' 'at' timeSpecifier fAssignDA ')' + | '(' assignOp fHead fExp ')' + ; fAssignDA - : '(' assignOp fHead fExpDA ')' - ; + : '(' assignOp fHead fExpDA ')' + ; fExpDA - : '(' ( ( binaryOp fExpDA fExpDA ) | ( '-' fExpDA ) ) ')' | '?duration' | fExp - ; + : '(' (( binaryOp fExpDA fExpDA) | ( '-' fExpDA)) ')' + | '?duration' + | fExp + ; /************* PROBLEMS ****************************/ problem - : '(' 'define' problemDecl problemDomain requireDef? objectDecl? init_ goal probConstraints? metricSpec? ')' - // lengthSpec? This is not defined anywhere in the BNF spec ')' - ; + : '(' 'define' problemDecl problemDomain requireDef? objectDecl? init_ goal probConstraints? metricSpec? ')' + // lengthSpec? This is not defined anywhere in the BNF spec ')' + ; problemDecl - : '(' 'problem' NAME ')' - ; + : '(' 'problem' NAME ')' + ; problemDomain - : '(' ':domain' NAME ')' - ; + : '(' ':domain' NAME ')' + ; objectDecl - : '(' ':objects' typedNameList ')' - ; + : '(' ':objects' typedNameList ')' + ; init_ - : '(' ':init' initEl* ')' - ; + : '(' ':init' initEl* ')' + ; initEl - : nameLiteral | '(' '=' fHead NUMBER ')' | '(' 'at' NUMBER nameLiteral ')' - ; + : nameLiteral + | '(' '=' fHead NUMBER ')' + | '(' 'at' NUMBER nameLiteral ')' + ; nameLiteral - : atomicNameFormula | '(' 'not' atomicNameFormula ')' - ; + : atomicNameFormula + | '(' 'not' atomicNameFormula ')' + ; atomicNameFormula - : '(' predicate NAME* ')' - ; + : '(' predicate NAME* ')' + ; // Should allow preGD instead of goalDesc - // but I can't get the LL(*) parsing to work // This means 'preference' preconditions cannot be used //goal : '(' ':goal' preGD ')' -> ^(GOAL preGD); goal - : '(' ':goal' goalDesc ')' - ; + : '(' ':goal' goalDesc ')' + ; probConstraints - : '(' ':constraints' prefConGD ')' - ; + : '(' ':constraints' prefConGD ')' + ; prefConGD - : '(' 'and' prefConGD* ')' | '(' 'forall' '(' typedVariableList ')' prefConGD ')' | '(' 'preference' NAME? conGD ')' | conGD - ; + : '(' 'and' prefConGD* ')' + | '(' 'forall' '(' typedVariableList ')' prefConGD ')' + | '(' 'preference' NAME? conGD ')' + | conGD + ; metricSpec - : '(' ':metric' optimization metricFExp ')' - ; + : '(' ':metric' optimization metricFExp ')' + ; optimization - : 'minimize' | 'maximize' - ; + : 'minimize' + | 'maximize' + ; metricFExp - : '(' binaryOp metricFExp metricFExp ')' | '(' ( '*' | '/' ) metricFExp metricFExp+ ')' | '(' '-' metricFExp ')' | NUMBER | '(' functionSymbol NAME* ')' | functionSymbol | 'total-time' | '(' 'is-violated' NAME ')' - ; + : '(' binaryOp metricFExp metricFExp ')' + | '(' ( '*' | '/') metricFExp metricFExp+ ')' + | '(' '-' metricFExp ')' + | NUMBER + | '(' functionSymbol NAME* ')' + | functionSymbol + | 'total-time' + | '(' 'is-violated' NAME ')' + ; /************* CONSTRAINTS ****************************/ conGD - : '(' 'and' conGD* ')' | '(' 'forall' '(' typedVariableList ')' conGD ')' | '(' 'at' 'end' goalDesc ')' | '(' 'always' goalDesc ')' | '(' 'sometime' goalDesc ')' | '(' 'within' NUMBER goalDesc ')' | '(' 'at-most-once' goalDesc ')' | '(' 'sometime-after' goalDesc goalDesc ')' | '(' 'sometime-before' goalDesc goalDesc ')' | '(' 'always-within' NUMBER goalDesc goalDesc ')' | '(' 'hold-during' NUMBER NUMBER goalDesc ')' | '(' 'hold-after' NUMBER goalDesc ')' - ; - + : '(' 'and' conGD* ')' + | '(' 'forall' '(' typedVariableList ')' conGD ')' + | '(' 'at' 'end' goalDesc ')' + | '(' 'always' goalDesc ')' + | '(' 'sometime' goalDesc ')' + | '(' 'within' NUMBER goalDesc ')' + | '(' 'at-most-once' goalDesc ')' + | '(' 'sometime-after' goalDesc goalDesc ')' + | '(' 'sometime-before' goalDesc goalDesc ')' + | '(' 'always-within' NUMBER goalDesc goalDesc ')' + | '(' 'hold-during' NUMBER NUMBER goalDesc ')' + | '(' 'hold-after' NUMBER goalDesc ')' + ; /************* LEXER ****************************/ REQUIRE_KEY - : ':strips' | ':typing' | ':negative-preconditions' | ':disjunctive-preconditions' | ':equality' | ':existential-preconditions' | ':universal-preconditions' | ':quantified-preconditions' | ':conditional-effects' | ':fluents' | ':adl' | ':durative-actions' | ':derived-predicates' | ':timed-initial-literals' | ':preferences' | ':constraints' - ; - + : ':strips' + | ':typing' + | ':negative-preconditions' + | ':disjunctive-preconditions' + | ':equality' + | ':existential-preconditions' + | ':universal-preconditions' + | ':quantified-preconditions' + | ':conditional-effects' + | ':fluents' + | ':adl' + | ':durative-actions' + | ':derived-predicates' + | ':timed-initial-literals' + | ':preferences' + | ':constraints' + ; DOMAIN - : 'DOMAIN' - ; - + : 'DOMAIN' + ; DOMAIN_NAME - : 'DOMAIN_NAME' - ; - + : 'DOMAIN_NAME' + ; REQUIREMENTS - : 'REQUIREMENTS' - ; - + : 'REQUIREMENTS' + ; TYPES - : 'TYPES' - ; - + : 'TYPES' + ; EITHER_TYPE - : 'EITHER_TYPE' - ; - + : 'EITHER_TYPE' + ; CONSTANTS - : 'CONSTANTS' - ; - + : 'CONSTANTS' + ; FUNCTIONS - : 'FUNCTIONS' - ; - + : 'FUNCTIONS' + ; PREDICATES - : 'PREDICATES' - ; - + : 'PREDICATES' + ; ACTION - : 'ACTION' - ; - + : 'ACTION' + ; DURATIVE_ACTION - : 'DURATIVE_ACTION' - ; - + : 'DURATIVE_ACTION' + ; PROBLEM - : 'PROBLEM' - ; - + : 'PROBLEM' + ; PROBLEM_NAME - : 'PROBLEM_NAME' - ; - + : 'PROBLEM_NAME' + ; PROBLEM_DOMAIN - : 'PROBLEM_DOMAIN' - ; - + : 'PROBLEM_DOMAIN' + ; OBJECTS - : 'OBJECTS' - ; - + : 'OBJECTS' + ; INIT - : 'INIT' - ; - + : 'INIT' + ; FUNC_HEAD - : 'FUNC_HEAD' - ; - + : 'FUNC_HEAD' + ; PRECONDITION - : 'PRECONDITION' - ; - + : 'PRECONDITION' + ; EFFECT - : 'EFFECT' - ; - + : 'EFFECT' + ; AND_GD - : 'AND_GD' - ; - + : 'AND_GD' + ; OR_GD - : 'OR_GD' - ; - + : 'OR_GD' + ; NOT_GD - : 'NOT_GD' - ; - + : 'NOT_GD' + ; IMPLY_GD - : 'IMPLY_GD' - ; - + : 'IMPLY_GD' + ; EXISTS_GD - : 'EXISTS_GD' - ; - + : 'EXISTS_GD' + ; FORALL_GD - : 'FORALL_GD' - ; - + : 'FORALL_GD' + ; COMPARISON_GD - : 'COMPARISON_GD' - ; - + : 'COMPARISON_GD' + ; AND_EFFECT - : 'AND_EFFECT' - ; - + : 'AND_EFFECT' + ; FORALL_EFFECT - : 'FORALL_EFFECT' - ; - + : 'FORALL_EFFECT' + ; WHEN_EFFECT - : 'WHEN_EFFECT' - ; - + : 'WHEN_EFFECT' + ; ASSIGN_EFFECT - : 'ASSIGN_EFFECT' - ; - + : 'ASSIGN_EFFECT' + ; NOT_EFFECT - : 'NOT_EFFECT' - ; - + : 'NOT_EFFECT' + ; PRED_HEAD - : 'PRED_HEAD' - ; - + : 'PRED_HEAD' + ; GOAL - : 'GOAL' - ; - + : 'GOAL' + ; BINARY_OP - : 'BINARY_OP' - ; - + : 'BINARY_OP' + ; UNARY_MINUS - : 'UNARY_MINUS' - ; - + : 'UNARY_MINUS' + ; INIT_EQ - : 'INIT_EQ' - ; - + : 'INIT_EQ' + ; INIT_AT - : 'INIT_AT' - ; - + : 'INIT_AT' + ; NOT_PRED_INIT - : 'NOT_PRED_INIT' - ; - + : 'NOT_PRED_INIT' + ; PRED_INST - : 'PRED_INST' - ; - + : 'PRED_INST' + ; PROBLEM_CONSTRAINT - : 'PROBLEM_CONSTRAINT' - ; - + : 'PROBLEM_CONSTRAINT' + ; PROBLEM_METRIC - : 'PROBLEM_METRIC' - ; - + : 'PROBLEM_METRIC' + ; NAME - : LETTER ANY_CHAR* - ; - + : LETTER ANY_CHAR* + ; fragment LETTER - : 'a' .. 'z' | 'A' .. 'Z' - ; - + : 'a' .. 'z' + | 'A' .. 'Z' + ; fragment ANY_CHAR - : LETTER | '0' .. '9' | '-' | '_' - ; - + : LETTER + | '0' .. '9' + | '-' + | '_' + ; VARIABLE - : '?' LETTER ANY_CHAR* - ; - + : '?' LETTER ANY_CHAR* + ; NUMBER - : DIGIT+ ( '.' DIGIT+ )? - ; - + : DIGIT+ ('.' DIGIT+)? + ; fragment DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; LINE_COMMENT - : ';' ~ ( '\n' | '\r' )* '\r'? '\n' -> skip - ; - + : ';' ~ ('\n' | '\r')* '\r'? '\n' -> skip + ; WHITESPACE - : ( ' ' | '\t' | '\r' | '\n' )+ -> skip - ; + : (' ' | '\t' | '\r' | '\n')+ -> skip + ; \ No newline at end of file diff --git a/pdn/pdn.g4 b/pdn/pdn.g4 index 327ccff846..13af91777e 100644 --- a/pdn/pdn.g4 +++ b/pdn/pdn.g4 @@ -30,85 +30,81 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar pdn; game - : tags moves EOF - ; + : tags moves EOF + ; tags - : tag* - ; + : tag* + ; tag - : '[' text string ']' - ; + : '[' text string ']' + ; moves - : move+ (result | '*')+ - ; + : move+ (result | '*')+ + ; move - : movenum movespec+ - ; + : movenum movespec+ + ; movespec - : (MOVE1 | MOVE2) (result | '*')? - ; + : (MOVE1 | MOVE2) (result | '*')? + ; movenum - : number '.' - ; + : number '.' + ; result - : '1/2-1/2' - | '1-0' - | '0-1' - ; + : '1/2-1/2' + | '1-0' + | '0-1' + ; text - : TEXT - ; + : TEXT + ; string - : STRING - ; + : STRING + ; number - : NUMBER - ; - + : NUMBER + ; MOVE1 - : ('0' .. '9') + 'x' ('0' .. '9') + - ; - + : ('0' .. '9')+ 'x' ('0' .. '9')+ + ; MOVE2 - : ('0' .. '9') + '-' ('0' .. '9') + - ; - + : ('0' .. '9')+ '-' ('0' .. '9')+ + ; NUMBER - : ('0' .. '9') + - ; - + : ('0' .. '9')+ + ; TEXT - : [a-zA-Z] [a-zA-Z0-9_] + - ; - + : [a-zA-Z] [a-zA-Z0-9_]+ + ; STRING - : '"' ('""' | ~ '"')* '"' - ; - + : '"' ('""' | ~ '"')* '"' + ; COMMENT - : '{' .*? '}' -> skip - ; - + : '{' .*? '}' -> skip + ; WS - : [ \t\r\n] + -> skip - ; + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/pegen/pegen_v3_10Lexer.g4 b/pegen/pegen_v3_10Lexer.g4 index a8c1da2bee..64080ce0f9 100644 --- a/pegen/pegen_v3_10Lexer.g4 +++ b/pegen/pegen_v3_10Lexer.g4 @@ -2,117 +2,115 @@ // Tokens assumed to be derived from https://raw.githubusercontent.com/python/cpython/3.10/Grammar/Tokens // Ken Domino, 2 Sep 2021 +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar pegen_v3_10Lexer; -options { superClass = Adaptor; } -tokens { ACTION } +options { + superClass = Adaptor; +} +tokens { + ACTION +} -MEMO: 'memo'; -OP: 'op'; -NAME: LETTER ('_' | DIGIT | LETTER)* ; -fragment LETTER : CAPITAL | SMALL ; -fragment CAPITAL : [A-Z\u00C0-\u00D6\u00D8-\u00DE] ; -fragment SMALL : [a-z\u00DF-\u00F6\u00F8-\u00FF] ; -fragment DIGIT : [0-9] ; -NUMBER : DIGIT+; -STRING : '"""' .*? '"""' | '\'\'\'' .*? '\'\'\'' ; -STRING2 : '"' -> more, mode(STRINGMODE); -CHAR : '\'' -> more, mode(CHARMODE); -fragment NEWLINE : [\n\r]+ ; -LPAR : '('; -RPAR : ')'; -LSQB : '['; -RSQB : ']'; -COLON : ':'; -COMMA : ','; -SEMI : ';'; -PLUS : '+'; -MINUS : '-'; -STAR : '*'; -SLASH : '/'; -VBAR : '|'; -AMPER : '&'; -LESS : '<'; -GREATER : '>'; -EQUAL : '='; -DOT : '.'; -PERCENT : '%'; -LBRACE : '{' -> more, pushMode(ACTION_MODE) ; -RBRACE : '}'; -EQEQUAL : '=='; -NOTEQUAL : '!='; -LESSEQUAL : '<='; -GREATEREQUAL : '>='; -TILDE : '~'; -CIRCUMFLEX : '^'; -LEFTSHIFT : '<<'; -RIGHTSHIFT : '>>'; -DOUBLESTAR : '**'; -PLUSEQUAL : '+='; -MINEQUAL : '-='; -STAREQUAL : '*='; -SLASHEQUAL : '/='; -PERCENTEQUAL : '%='; -AMPEREQUAL : '&='; -VBAREQUAL : '|='; -CIRCUMFLEXEQUAL : '^='; -LEFTSHIFTEQUAL : '<<='; -RIGHTSHIFTEQUAL : '>>='; -DOUBLESTAREQUAL : '**='; -DOUBLESLASH : '//'; -DOUBLESLASHEQUAL : '//='; -AT : '@'; -ATEQUAL : '@='; -RARROW : '->'; -ELLIPSIS : '...'; -COLONEQUAL : ':='; -DOLLAR: '$'; -BANG: '!'; -QUESTION: '?'; +MEMO : 'memo'; +OP : 'op'; +NAME : LETTER ('_' | DIGIT | LETTER)*; +fragment LETTER : CAPITAL | SMALL; +fragment CAPITAL : [A-Z\u00C0-\u00D6\u00D8-\u00DE]; +fragment SMALL : [a-z\u00DF-\u00F6\u00F8-\u00FF]; +fragment DIGIT : [0-9]; +NUMBER : DIGIT+; +STRING : '"""' .*? '"""' | '\'\'\'' .*? '\'\'\''; +STRING2 : '"' -> more, mode(STRINGMODE); +CHAR : '\'' -> more, mode(CHARMODE); +fragment NEWLINE : [\n\r]+; +LPAR : '('; +RPAR : ')'; +LSQB : '['; +RSQB : ']'; +COLON : ':'; +COMMA : ','; +SEMI : ';'; +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +SLASH : '/'; +VBAR : '|'; +AMPER : '&'; +LESS : '<'; +GREATER : '>'; +EQUAL : '='; +DOT : '.'; +PERCENT : '%'; +LBRACE : '{' -> more, pushMode(ACTION_MODE); +RBRACE : '}'; +EQEQUAL : '=='; +NOTEQUAL : '!='; +LESSEQUAL : '<='; +GREATEREQUAL : '>='; +TILDE : '~'; +CIRCUMFLEX : '^'; +LEFTSHIFT : '<<'; +RIGHTSHIFT : '>>'; +DOUBLESTAR : '**'; +PLUSEQUAL : '+='; +MINEQUAL : '-='; +STAREQUAL : '*='; +SLASHEQUAL : '/='; +PERCENTEQUAL : '%='; +AMPEREQUAL : '&='; +VBAREQUAL : '|='; +CIRCUMFLEXEQUAL : '^='; +LEFTSHIFTEQUAL : '<<='; +RIGHTSHIFTEQUAL : '>>='; +DOUBLESTAREQUAL : '**='; +DOUBLESLASH : '//'; +DOUBLESLASHEQUAL : '//='; +AT : '@'; +ATEQUAL : '@='; +RARROW : '->'; +ELLIPSIS : '...'; +COLONEQUAL : ':='; +DOLLAR : '$'; +BANG : '!'; +QUESTION : '?'; -SKIP_ - : ( SPACES | COMMENT | LINE_JOINING | NEWLINE ) -> skip - ; +SKIP_: ( SPACES | COMMENT | LINE_JOINING | NEWLINE) -> skip; -fragment SPACES - : [ \t]+ - ; +fragment SPACES: [ \t]+; -fragment COMMENT - : '#' ~[\r\n\f]* - ; +fragment COMMENT: '#' ~[\r\n\f]*; -fragment LINE_JOINING - : '\\' SPACES? ( '\r'? '\n' | '\r' | '\f') - ; +fragment LINE_JOINING: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f'); // Escapable sequences -fragment -Escapable : ('"' | '\\' | 'n' | 't' | 'r' | 'f' | '\n' | '\r'); +fragment Escapable: ('"' | '\\' | 'n' | 't' | 'r' | 'f' | '\n' | '\r'); mode STRESCAPE; -STRESCAPED : Escapable -> more, popMode ; +STRESCAPED: Escapable -> more, popMode; mode STRINGMODE; -STRINGESC : '\\' -> more , pushMode(STRESCAPE); -STRINGEND : '"' -> type(STRING), mode(DEFAULT_MODE); +STRINGESC : '\\' -> more, pushMode(STRESCAPE); +STRINGEND : '"' -> type(STRING), mode(DEFAULT_MODE); STRINGTEXT : (~["\\] | '""') -> more; mode CHARESCAPE; -CHARESCAPED : Escapable -> more, popMode ; +CHARESCAPED: Escapable -> more, popMode; mode CHARMODE; -CHARESC : '\\' -> more , pushMode(CHARESCAPE); -CHAREND : '\'' -> type(STRING), mode(DEFAULT_MODE); +CHARESC : '\\' -> more, pushMode(CHARESCAPE); +CHAREND : '\'' -> type(STRING), mode(DEFAULT_MODE); CHARTEXT : ~['\\] -> more; mode ACTION_MODE; -NESTED_ACTION : LBRACE -> more, pushMode (ACTION_MODE) ; -ACTION_ESCAPE : EscAny -> more ; -ACTION : RBRACE { this.AtEnd() }? -> popMode ; -CLOSE : RBRACE -> more, popMode ; -UNTERMINATED_ACTION : EOF -> popMode ; -CONTENT : . -> more ; -fragment EscAny : Esc . ; -fragment Esc : '\\' ; - +NESTED_ACTION : LBRACE -> more, pushMode (ACTION_MODE); +ACTION_ESCAPE : EscAny -> more; +ACTION : RBRACE { this.AtEnd() }? -> popMode; +CLOSE : RBRACE -> more, popMode; +UNTERMINATED_ACTION : EOF -> popMode; +CONTENT : . -> more; +fragment EscAny : Esc .; +fragment Esc : '\\'; \ No newline at end of file diff --git a/pegen/pegen_v3_10Parser.g4 b/pegen/pegen_v3_10Parser.g4 index a0604c9f1b..c3fc71e397 100644 --- a/pegen/pegen_v3_10Parser.g4 +++ b/pegen/pegen_v3_10Parser.g4 @@ -2,15 +2,26 @@ // Tokens assumed to be derived from https://raw.githubusercontent.com/python/cpython/3.10/Grammar/Tokens // Ken Domino, 2 Sep 2021 +// $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 pegen_v3_10Parser; -options { tokenVocab=pegen_v3_10Lexer; } +options { + tokenVocab = pegen_v3_10Lexer; +} -start: grammar_ EOF ; +start + : grammar_ EOF + ; -grammar_ : metas? rules ; +grammar_ + : metas? rules + ; -metas : meta+ ; +metas + : meta+ + ; meta : '@' name newline @@ -18,7 +29,9 @@ meta | '@' name string newline ; -rules : rule_+ ; +rules + : rule_+ + ; rule_ : rulename memoflag? ':' alts newline indent more_alts dedent @@ -30,12 +43,18 @@ rulename : name attribute? ; -attribute : ('[' name '*'? ']'); +attribute + : ('[' name '*'? ']') + ; // In the future this may return something more complicated -memoflag : '(' 'memo' ')' ; +memoflag + : '(' 'memo' ')' + ; -alts : alt ('|' alt)* ; +alts + : alt ('|' alt)* + ; more_alts : ('|' alts newline)+ @@ -46,7 +65,9 @@ alt | items action? ; -items : named_item+ ; +items + : named_item+ + ; named_item : attribute_name? item @@ -54,7 +75,11 @@ named_item | lookahead ; -attribute_name : name '[' name '*' ']' '=' | name '[' name ']' '=' | name '=' ; +attribute_name + : name '[' name '*' ']' '=' + | name '[' name ']' '=' + | name '=' + ; forced_atom : '&' '&' atom @@ -68,11 +93,11 @@ lookahead item : '[' alts ']' - | atom '?' - | atom '*' - | atom '+' - | atom '.' atom '+' - | atom + | atom '?' + | atom '*' + | atom '+' + | atom '.' atom '+' + | atom ; atom @@ -81,10 +106,30 @@ atom | string ; -action: ACTION; -name : NAME ; -string : STRING ; -newline : ; -indent : ; -dedent : ; -number : NUMBER ; \ No newline at end of file +action + : ACTION + ; + +name + : NAME + ; + +string + : STRING + ; + +newline + : + ; + +indent + : + ; + +dedent + : + ; + +number + : NUMBER + ; \ No newline at end of file diff --git a/peoplecode/PeopleCode.g4 b/peoplecode/PeopleCode.g4 index ddac86bfb1..b366bd5ed7 100644 --- a/peoplecode/PeopleCode.g4 +++ b/peoplecode/PeopleCode.g4 @@ -22,137 +22,276 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar PeopleCode; //******************************************************// // Parser Rules // //******************************************************// -program : stmtList EOF ; +program + : stmtList EOF + ; // Multiple semicolons may be present; the last/only statement may not have a semicolon. -stmtList: (stmt ';'+)* stmt? ; - -stmt : appClassImport # StmtAppClassImport - | extFuncImport # StmtExternalFuncImport - | classDeclaration # StmtClassDeclaration - | methodImpl # StmtMethodImpl - | getImpl # StmtGetImpl - | setImpl # StmtSetImpl - | funcImpl # StmtFuncImpl - | varDeclaration # StmtVarDeclaration - | ifStmt # StmtIf - | forStmt # StmtFor - | whileStmt # StmtWhile - | evaluateStmt # StmtEvaluate - | tryCatchStmt # StmtTryCatch - | 'Exit' # StmtExit - | 'Break' # StmtBreak - | 'Error' expr # StmtError - | 'Warning' expr # StmtWarning - | 'Return' expr? # StmtReturn - | 'throw' expr # StmtThrow - | expr '=' expr # StmtAssign // Must be higher than fn call to properly resolve '=' ambiguity. - | expr # StmtExpr // For fn calls; the value of expr is not assigned to anything. - ; - -expr : '(' expr ')' # ExprParenthesized - | '@' expr # ExprDynamicReference - | literal # ExprLiteral - | id_ # ExprId - | createInvocation # ExprCreate - | expr '.' id_ # ExprDotAccess - | expr '[' exprList ']' # ExprArrayIndex // &array[&i, &j] is shorthand for &array[&i][&j] - | expr '(' exprList? ')' # ExprFnOrIdxCall - | '-' expr # ExprNegate - | 'Not' expr # ExprNot - | expr (m='*'|d='/') expr # ExprMulDiv - | expr (a='+'|s='-') expr # ExprAddSub - | expr (le='<='|ge='>='|l='<'|g='>') expr # ExprComparison - | expr (e='='|i='<>') expr # ExprEquality - | expr ( - op='And' - | op='Or' - ) expr # ExprBoolean // order of precedence: Not, And, then Or - | expr '|' expr # ExprConcat - ; - -exprList: expr (',' expr)* ; - -varDeclaration : varScope=GENERIC_ID varType varDeclarator (',' varDeclarator)* ; -varDeclarator : VAR_ID ('=' expr)? ; +stmtList + : (stmt ';'+)* stmt? + ; + +stmt + : appClassImport # StmtAppClassImport + | extFuncImport # StmtExternalFuncImport + | classDeclaration # StmtClassDeclaration + | methodImpl # StmtMethodImpl + | getImpl # StmtGetImpl + | setImpl # StmtSetImpl + | funcImpl # StmtFuncImpl + | varDeclaration # StmtVarDeclaration + | ifStmt # StmtIf + | forStmt # StmtFor + | whileStmt # StmtWhile + | evaluateStmt # StmtEvaluate + | tryCatchStmt # StmtTryCatch + | 'Exit' # StmtExit + | 'Break' # StmtBreak + | 'Error' expr # StmtError + | 'Warning' expr # StmtWarning + | 'Return' expr? # StmtReturn + | 'throw' expr # StmtThrow + | expr '=' expr # StmtAssign // Must be higher than fn call to properly resolve '=' ambiguity. + | expr # StmtExpr // For fn calls; the value of expr is not assigned to anything. + ; + +expr + : '(' expr ')' # ExprParenthesized + | '@' expr # ExprDynamicReference + | literal # ExprLiteral + | id_ # ExprId + | createInvocation # ExprCreate + | expr '.' id_ # ExprDotAccess + | expr '[' exprList ']' # ExprArrayIndex // &array[&i, &j] is shorthand for &array[&i][&j] + | expr '(' exprList? ')' # ExprFnOrIdxCall + | '-' expr # ExprNegate + | 'Not' expr # ExprNot + | expr (m = '*' | d = '/') expr # ExprMulDiv + | expr (a = '+' | s = '-') expr # ExprAddSub + | expr (le = '<=' | ge = '>=' | l = '<' | g = '>') expr # ExprComparison + | expr (e = '=' | i = '<>') expr # ExprEquality + | expr (op = 'And' | op = 'Or') expr # ExprBoolean // order of precedence: Not, And, then Or + | expr '|' expr # ExprConcat + ; + +exprList + : expr (',' expr)* + ; + +varDeclaration + : varScope = GENERIC_ID varType varDeclarator (',' varDeclarator)* + ; + +varDeclarator + : VAR_ID ('=' expr)? + ; // - The first alt catches primitive types (i.e., "any", "integer"), complex types // (i.e., "Record"), arrays of any dimension (i.e., "array of array of Record"), // and app class names without path prefixes (i.e., "Address" for "EO:CA:Address"). // - Note: the 'of' clause is only valid after "array" - I'm opting to enforce this // at runtime rather than syntactically. -varType : GENERIC_ID ('of' varType)? | appClassPath ; +varType + : GENERIC_ID ('of' varType)? + | appClassPath + ; + +appClassImport + : 'import' (appPkgPath | appClassPath) + ; + +appPkgPath + : GENERIC_ID (':' GENERIC_ID)* ':' '*' + ; + +appClassPath + : GENERIC_ID (':' GENERIC_ID)+ + ; + +extFuncImport + : 'Declare' 'Function' GENERIC_ID 'PeopleCode' recDefnPath event + ; + +recDefnPath + : GENERIC_ID '.' GENERIC_ID + ; + +event + : 'FieldFormula' + | 'FieldChange' + ; + +classDeclaration + : 'class' GENERIC_ID classBlock* 'end-class' + ; + +classBlock + : aLvl = 'private'? (classBlockStmt ';'*)+ + ; + +classBlockStmt + : method + | constant + | property_ + | instance + ; + +method + : 'method' GENERIC_ID formalParamList returnType? + ; + +constant + : 'Constant' VAR_ID '=' expr + ; -appClassImport : 'import' (appPkgPath|appClassPath) ; -appPkgPath : GENERIC_ID (':' GENERIC_ID)* ':' '*' ; -appClassPath : GENERIC_ID (':' GENERIC_ID)+ ; +property_ + : 'property' varType GENERIC_ID g = 'get'? s = 'set'? r = 'readonly'? + ; -extFuncImport : 'Declare' 'Function' GENERIC_ID 'PeopleCode' recDefnPath event ; -recDefnPath : GENERIC_ID '.' GENERIC_ID ; -event : 'FieldFormula' | 'FieldChange' ; +instance + : 'instance' varType VAR_ID (',' VAR_ID)* + ; -classDeclaration : 'class' GENERIC_ID classBlock* 'end-class' ; -classBlock : aLvl='private'? (classBlockStmt ';'*)+ ; -classBlockStmt : method | constant | property_ | instance ; -method : 'method' GENERIC_ID formalParamList returnType? ; -constant : 'Constant' VAR_ID '=' expr ; -property_ : 'property' varType GENERIC_ID g='get'? s='set'? r='readonly'? ; -instance : 'instance' varType VAR_ID (',' VAR_ID)* ; +methodImpl + : 'method' GENERIC_ID stmtList endmethod = 'end-method' + ; -methodImpl : 'method' GENERIC_ID stmtList endmethod='end-method' ; -getImpl : 'get' GENERIC_ID stmtList endget='end-get' ; -setImpl : 'set' GENERIC_ID stmtList endset='end-set' ; +getImpl + : 'get' GENERIC_ID stmtList endget = 'end-get' + ; -funcImpl : funcSignature stmtList endfunction='End-Function' ; -funcSignature : 'Function' GENERIC_ID formalParamList? returnType? ';'? ; -formalParamList : '(' ( param (',' param)* )? ')' ; -param : VAR_ID ('As' varType)? ; -returnType : 'Returns' varType ; +setImpl + : 'set' GENERIC_ID stmtList endset = 'end-set' + ; -ifStmt : 'If' expr 'Then' ';'? stmtList (elsetok='Else' ';'? stmtList)? endif='End-If' ; +funcImpl + : funcSignature stmtList endfunction = 'End-Function' + ; -forStmt : 'For' VAR_ID '=' expr 'To' expr (';' | ('Step' expr))? stmtList endfor='End-For' ; +funcSignature + : 'Function' GENERIC_ID formalParamList? returnType? ';'? + ; -whileStmt : 'While' expr ';'? stmtList 'End-While' ; +formalParamList + : '(' (param (',' param)*)? ')' + ; -evaluateStmt : 'Evaluate' expr whenBranch+ whenOtherBranch? endevaluate='End-Evaluate' ; -whenBranch : 'When' (op='='|op='>')? expr stmtList ; -whenOtherBranch : 'When-Other' stmtList ; +param + : VAR_ID ('As' varType)? + ; -tryCatchStmt : trytok='try' stmtList catchSignature stmtList endtry='end-try' ; -catchSignature : 'catch' exClass='Exception' VAR_ID ; +returnType + : 'Returns' varType + ; -createInvocation : 'create' (appClassPath|GENERIC_ID) '(' exprList? ')' ; +ifStmt + : 'If' expr 'Then' ';'? stmtList (elsetok = 'Else' ';'? stmtList)? endif = 'End-If' + ; -literal : DecimalLiteral - | IntegerLiteral - | StringLiteral - | BoolLiteral - ; +forStmt + : 'For' VAR_ID '=' expr 'To' expr (';' | ('Step' expr))? stmtList endfor = 'End-For' + ; -id_ : SYS_VAR_ID | VAR_ID | GENERIC_ID ; +whileStmt + : 'While' expr ';'? stmtList 'End-While' + ; + +evaluateStmt + : 'Evaluate' expr whenBranch+ whenOtherBranch? endevaluate = 'End-Evaluate' + ; + +whenBranch + : 'When' (op = '=' | op = '>')? expr stmtList + ; + +whenOtherBranch + : 'When-Other' stmtList + ; + +tryCatchStmt + : trytok = 'try' stmtList catchSignature stmtList endtry = 'end-try' + ; + +catchSignature + : 'catch' exClass = 'Exception' VAR_ID + ; + +createInvocation + : 'create' (appClassPath | GENERIC_ID) '(' exprList? ')' + ; + +literal + : DecimalLiteral + | IntegerLiteral + | StringLiteral + | BoolLiteral + ; + +id_ + : SYS_VAR_ID + | VAR_ID + | GENERIC_ID + ; //*******************************************************// // Lexer Rules // //*******************************************************// -DecimalLiteral : IntegerLiteral '.' [0-9]+ ; -IntegerLiteral : '0' | '1'..'9' '0'..'9'* ; -StringLiteral : '"' ( ~'"' )* '"' ; -BoolLiteral : 'True' | 'False' ; +DecimalLiteral + : IntegerLiteral '.' [0-9]+ + ; + +IntegerLiteral + : '0' + | '1' ..'9' '0' ..'9'* + ; + +StringLiteral + : '"' (~'"')* '"' + ; + +BoolLiteral + : 'True' + | 'False' + ; + +VAR_ID + : '&' GENERIC_ID + ; + +SYS_VAR_ID + : '%' GENERIC_ID + ; + +GENERIC_ID + : [a-zA-Z] [0-9a-zA-Z_#]* + ; + +REM + : WS? [rR][eE][mM] WS .*? ';' -> skip + ; + +COMMENT_1 + : '/*' .*? '*/' -> skip + ; + +COMMENT_2 + : '<*' .*? '*>' -> skip + ; -VAR_ID : '&' GENERIC_ID ; -SYS_VAR_ID : '%' GENERIC_ID ; -GENERIC_ID : [a-zA-Z] [0-9a-zA-Z_#]* ; +COMMENT_3 + : '/+' .*? '+/' ';'? -> skip + ; -REM : WS? [rR][eE][mM] WS .*? ';' -> skip; -COMMENT_1 : '/*' .*? '*/' -> skip; -COMMENT_2 : '<*' .*? '*>' -> skip; -COMMENT_3 : '/+' .*? '+/' ';'? -> skip; -WS : [ \t\r\n]+ -> skip; \ No newline at end of file +WS + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/pgn/PGN.g4 b/pgn/PGN.g4 index ae843d3299..8d989c8016 100644 --- a/pgn/PGN.g4 +++ b/pgn/PGN.g4 @@ -37,101 +37,105 @@ // The inline comments starting with "///" in this grammar are direct // copy-pastes from the PGN reference linked above. // + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar PGN; // The entry point of the grammar. parse - : pgn_database EOF - ; + : pgn_database EOF + ; /// ::= /// pgn_database - : pgn_game* - ; + : pgn_game* + ; /// ::= pgn_game - : tag_section movetext_section - ; + : tag_section movetext_section + ; /// ::= /// tag_section - : tag_pair* - ; + : tag_pair* + ; /// ::= [ ] tag_pair - : LEFT_BRACKET tag_name tag_value RIGHT_BRACKET - ; + : LEFT_BRACKET tag_name tag_value RIGHT_BRACKET + ; /// ::= tag_name - : SYMBOL - ; + : SYMBOL + ; /// ::= tag_value - : STRING - ; - + : STRING + ; + /// ::= movetext_section - : element_sequence game_termination - ; + : element_sequence game_termination + ; /// ::= /// /// element_sequence - : (element | recursive_variation)* - ; + : (element | recursive_variation)* + ; /// ::= /// /// element - : move_number_indication - | san_move - | NUMERIC_ANNOTATION_GLYPH - ; + : move_number_indication + | san_move + | NUMERIC_ANNOTATION_GLYPH + ; move_number_indication - : INTEGER PERIOD? - ; + : INTEGER PERIOD? + ; san_move - : SYMBOL - ; + : SYMBOL + ; /// ::= ( ) recursive_variation - : LEFT_PARENTHESIS element_sequence RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS element_sequence RIGHT_PARENTHESIS + ; /// ::= 1-0 /// 0-1 /// 1/2-1/2 /// * game_termination - : WHITE_WINS - | BLACK_WINS - | DRAWN_GAME - | ASTERISK - ; + : WHITE_WINS + | BLACK_WINS + | DRAWN_GAME + | ASTERISK + ; WHITE_WINS - : '1-0' - ; + : '1-0' + ; BLACK_WINS - : '0-1' - ; + : '0-1' + ; DRAWN_GAME - : '1/2-1/2' - ; + : '1/2-1/2' + ; /// Comment text may appear in PGN data. There are two kinds of comments. The /// first kind is the "rest of line" comment; this comment type starts with a @@ -139,16 +143,16 @@ DRAWN_GAME /// starts with a left brace character and continues to the next right brace /// character. Comments cannot appear inside any token. REST_OF_LINE_COMMENT - : ';' ~[\r\n]* -> skip - ; + : ';' ~[\r\n]* -> skip + ; /// Brace comments do not nest; a left brace character appearing in a brace comment /// loses its special meaning and is ignored. A semicolon appearing inside of a /// brace comment loses its special meaning and is ignored. Braces appearing /// inside of a semicolon comments lose their special meaning and are ignored. BRACE_COMMENT - : '{' ~'}'* '}' -> skip - ; + : '{' ~'}'* '}' -> skip + ; /// There is a special escape mechanism for PGN data. This mechanism is triggered /// by a percent sign character ("%") appearing in the first column of a line; the @@ -159,12 +163,12 @@ BRACE_COMMENT /// A percent sign appearing in any other place other than the first position in a /// line does not trigger the escape mechanism. ESCAPE - : {getCharPositionInLine() == 0}? '%' ~[\r\n]* -> skip - ; + : {getCharPositionInLine() == 0}? '%' ~[\r\n]* -> skip + ; SPACES - : [ \t\r\n]+ -> skip - ; + : [ \t\r\n]+ -> skip + ; /// A string token is a sequence of zero or more printing characters delimited by a /// pair of quote characters (ASCII decimal value 34, hexadecimal value 0x22). An @@ -176,8 +180,8 @@ SPACES /// of strings. A string token is terminated by its closing quote. Currently, a /// string is limited to a maximum of 255 characters of data. STRING - : '"' ('\\\\' | '\\"' | ~[\\"])* '"' - ; + : '"' ('\\\\' | '\\"' | ~[\\"])* '"' + ; /// An integer token is a sequence of one or more decimal digit characters. It is /// a special case of the more general "symbol" token class described below. @@ -185,61 +189,61 @@ STRING /// An integer token is terminated just prior to the first non-symbol character /// following the integer digit sequence. INTEGER - : [0-9]+ - ; + : [0-9]+ + ; /// A period character (".") is a token by itself. It is used for move number /// indications (see below). It is self terminating. PERIOD - : '.' - ; + : '.' + ; /// An asterisk character ("*") is a token by itself. It is used as one of the /// possible game termination markers (see below); it indicates an incomplete game /// or a game with an unknown or otherwise unavailable result. It is self /// terminating. ASTERISK - : '*' - ; + : '*' + ; /// The left and right bracket characters ("[" and "]") are tokens. They are used /// to delimit tag pairs (see below). Both are self terminating. LEFT_BRACKET - : '[' - ; + : '[' + ; RIGHT_BRACKET - : ']' - ; + : ']' + ; /// The left and right parenthesis characters ("(" and ")") are tokens. They are /// used to delimit Recursive Annotation Variations (see below). Both are self /// terminating. LEFT_PARENTHESIS - : '(' - ; + : '(' + ; RIGHT_PARENTHESIS - : ')' - ; + : ')' + ; /// The left and right angle bracket characters ("<" and ">") are tokens. They are /// reserved for future expansion. Both are self terminating. LEFT_ANGLE_BRACKET - : '<' - ; + : '<' + ; RIGHT_ANGLE_BRACKET - : '>' - ; + : '>' + ; /// A Numeric Annotation Glyph ("NAG", see below) is a token; it is composed of a /// dollar sign character ("$") immediately followed by one or more digit /// characters. It is terminated just prior to the first non-digit character /// following the digit sequence. NUMERIC_ANNOTATION_GLYPH - : '$' [0-9]+ - ; + : '$' [0-9]+ + ; /// A symbol token starts with a letter or digit character and is immediately /// followed by a sequence of zero or more symbol continuation characters. These @@ -251,19 +255,19 @@ NUMERIC_ANNOTATION_GLYPH /// following the symbol character sequence. Currently, a symbol is limited to a /// maximum of 255 characters in length. SYMBOL - : [a-zA-Z0-9] [a-zA-Z0-9_+#=:-]* - ; + : [a-zA-Z0-9] [a-zA-Z0-9_+#=:-]* + ; /// Import format PGN allows for the use of traditional suffix annotations for /// moves. There are exactly six such annotations available: "!", "?", "!!", "!?", /// "?!", and "??". At most one such suffix annotation may appear per move, and if /// present, it is always the last part of the move symbol. SUFFIX_ANNOTATION - : [?!] [?!]? - ; + : [?!] [?!]? + ; // A fall through rule that will catch any character not matched by any of the // previous lexer rules. UNEXPECTED_CHAR - : . - ; + : . + ; \ No newline at end of file diff --git a/php/PhpLexer.g4 b/php/PhpLexer.g4 index 3d52ac9784..cad89a4f3f 100644 --- a/php/PhpLexer.g4 +++ b/php/PhpLexer.g4 @@ -24,85 +24,91 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PhpLexer; -channels { PhpComments, ErrorLexem, SkipChannel } +channels { + PhpComments, + ErrorLexem, + SkipChannel +} options { - superClass=PhpLexerBase; + superClass = PhpLexerBase; caseInsensitive = true; } // Insert here @header for C++ lexer. -SeaWhitespace: [ \t\r\n]+ -> channel(HIDDEN); -HtmlText: ~[<#]+; -XmlStart: ' pushMode(XML); -PHPStartEcho: PhpStartEchoFragment -> type(Echo), pushMode(PHP); -PHPStart: PhpStartFragment -> channel(SkipChannel), pushMode(PHP); -HtmlScriptOpen: ' pushMode(INSIDE); -HtmlStyleOpen: ' pushMode(INSIDE); -HtmlComment: '' -> channel(HIDDEN); -HtmlDtd: ''; -HtmlOpen: '<' -> pushMode(INSIDE); -Shebang - : '#' { this.IsNewLineOrStart(-2) }? '!' ~[\r\n]* - ; -NumberSign: '#' ~'<'* -> more; -Error: . -> channel(ErrorLexem); +SeaWhitespace : [ \t\r\n]+ -> channel(HIDDEN); +HtmlText : ~[<#]+; +XmlStart : ' pushMode(XML); +PHPStartEcho : PhpStartEchoFragment -> type(Echo), pushMode(PHP); +PHPStart : PhpStartFragment -> channel(SkipChannel), pushMode(PHP); +HtmlScriptOpen : ' pushMode(INSIDE); +HtmlStyleOpen : ' pushMode(INSIDE); +HtmlComment : '' -> channel(HIDDEN); +HtmlDtd : ''; +HtmlOpen : '<' -> pushMode(INSIDE); +Shebang : '#' { this.IsNewLineOrStart(-2) }? '!' ~[\r\n]*; +NumberSign : '#' ~'<'* -> more; +Error : . -> channel(ErrorLexem); // TODO: parse xml attributes. mode XML; -XmlText: ~'?'+; -XmlClose: '?>' -> popMode; -XmlText2: '?' -> type(XmlText); +XmlText : ~'?'+; +XmlClose : '?>' -> popMode; +XmlText2 : '?' -> type(XmlText); mode INSIDE; -PHPStartEchoInside: PhpStartEchoFragment -> type(Echo), pushMode(PHP); -PHPStartInside: PhpStartFragment -> channel(SkipChannel), pushMode(PHP); -HtmlClose: '>' { this.PushModeOnHtmlClose(); }; -HtmlSlashClose: '/>' -> popMode; -HtmlSlash: '/'; -HtmlEquals: '='; - -HtmlStartQuoteString: '\\'? '\'' -> pushMode(HtmlQuoteStringMode); -HtmlStartDoubleQuoteString: '\\'? '"' -> pushMode(HtmlDoubleQuoteStringMode); -HtmlHex: '#' HexDigit+ ; -HtmlDecimal: Digit+; -HtmlSpace: [ \t\r\n]+ -> channel(HIDDEN); -HtmlName: HtmlNameStartChar HtmlNameChar*; -ErrorInside: . -> channel(ErrorLexem); +PHPStartEchoInside : PhpStartEchoFragment -> type(Echo), pushMode(PHP); +PHPStartInside : PhpStartFragment -> channel(SkipChannel), pushMode(PHP); +HtmlClose : '>' { this.PushModeOnHtmlClose(); }; +HtmlSlashClose : '/>' -> popMode; +HtmlSlash : '/'; +HtmlEquals : '='; + +HtmlStartQuoteString : '\\'? '\'' -> pushMode(HtmlQuoteStringMode); +HtmlStartDoubleQuoteString : '\\'? '"' -> pushMode(HtmlDoubleQuoteStringMode); +HtmlHex : '#' HexDigit+; +HtmlDecimal : Digit+; +HtmlSpace : [ \t\r\n]+ -> channel(HIDDEN); +HtmlName : HtmlNameStartChar HtmlNameChar*; +ErrorInside : . -> channel(ErrorLexem); mode HtmlQuoteStringMode; -PHPStartEchoInsideQuoteString: PhpStartEchoFragment -> type(Echo), pushMode(PHP); -PHPStartInsideQuoteString: PhpStartFragment -> channel(SkipChannel), pushMode(PHP); -HtmlEndQuoteString: '\'' '\''? -> popMode; -HtmlQuoteString: ~[<']+; -ErrorHtmlQuote: . -> channel(ErrorLexem); +PHPStartEchoInsideQuoteString : PhpStartEchoFragment -> type(Echo), pushMode(PHP); +PHPStartInsideQuoteString : PhpStartFragment -> channel(SkipChannel), pushMode(PHP); +HtmlEndQuoteString : '\'' '\''? -> popMode; +HtmlQuoteString : ~[<']+; +ErrorHtmlQuote : . -> channel(ErrorLexem); mode HtmlDoubleQuoteStringMode; -PHPStartEchoDoubleQuoteString: PhpStartEchoFragment -> type(Echo), pushMode(PHP); -PHPStartDoubleQuoteString: PhpStartFragment -> channel(SkipChannel), pushMode(PHP); -HtmlEndDoubleQuoteString: '"' '"'? -> popMode; -HtmlDoubleQuoteString: ~[<"]+; -ErrorHtmlDoubleQuote: . -> channel(ErrorLexem); +PHPStartEchoDoubleQuoteString : PhpStartEchoFragment -> type(Echo), pushMode(PHP); +PHPStartDoubleQuoteString : PhpStartFragment -> channel(SkipChannel), pushMode(PHP); +HtmlEndDoubleQuoteString : '"' '"'? -> popMode; +HtmlDoubleQuoteString : ~[<"]+; +ErrorHtmlDoubleQuote : . -> channel(ErrorLexem); // Parse JavaScript with https://github.com/antlr/grammars-v4/tree/master/javascript if necessary. // Php blocks can exist inside Script blocks too. mode SCRIPT; -ScriptText: ~'<'+; +ScriptText: ~'<'+; // TODO: handle JS strings, but handle type(ScriptText); //ScriptString2: '\'' (~'\'' | '\\' ('\r'? '\n' | .))* '\'' -> type(ScriptText); -HtmlScriptClose: '' -> popMode; -PHPStartInsideScriptEcho: PhpStartEchoFragment -> type(Echo), pushMode(PHP); -PHPStartInsideScript: PhpStartFragment -> channel(SkipChannel), pushMode(PHP); -ScriptText2: '<' -> type(ScriptText); +HtmlScriptClose : '' -> popMode; +PHPStartInsideScriptEcho : PhpStartEchoFragment -> type(Echo), pushMode(PHP); +PHPStartInsideScript : PhpStartFragment -> channel(SkipChannel), pushMode(PHP); +ScriptText2 : '<' -> type(ScriptText); mode STYLE; @@ -110,275 +116,276 @@ StyleBody: .*? '' -> popMode; mode PHP; -PHPEnd: ('?' | '%' {this.HasAspTags()}?) '>' - | '' {this.HasPhpScriptTag()}?; -Whitespace: [ \t\r\n]+ -> channel(SkipChannel); -MultiLineComment: '/*' .*? '*/' -> channel(PhpComments); -SingleLineComment: '//' -> channel(SkipChannel), pushMode(SingleLineCommentMode); -ShellStyleComment: '#' -> channel(SkipChannel), pushMode(SingleLineCommentMode); - -AttributeStart: '#['; - -Abstract: 'abstract'; -Array: 'array'; -As: 'as'; -BinaryCast: 'binary'; -BoolType: 'bool' 'ean'?; -BooleanConstant: 'true' - | 'false'; -Break: 'break'; -Callable: 'callable'; -Case: 'case'; -Catch: 'catch'; -Class: 'class'; -Clone: 'clone'; -Const: 'const'; -Continue: 'continue'; -Declare: 'declare'; -Default: 'default'; -Do: 'do'; -DoubleCast: 'real'; -DoubleType: 'double'; -Echo: 'echo'; -Else: 'else'; -ElseIf: 'elseif'; -Empty: 'empty'; -Enum_: 'enum'; - -EndDeclare: 'enddeclare'; -EndFor: 'endfor'; -EndForeach: 'endforeach'; -EndIf: 'endif'; -EndSwitch: 'endswitch'; -EndWhile: 'endwhile'; - -Eval: 'eval'; -Exit: 'die'; -Extends: 'extends'; -Final: 'final'; -Finally: 'finally'; -FloatCast: 'float'; -For: 'for'; -Foreach: 'foreach'; -Function_: 'function'; -Global: 'global'; -Goto: 'goto'; -If: 'if'; -Implements: 'implements'; -Import: 'import'; -Include: 'include'; -IncludeOnce: 'include_once'; -InstanceOf: 'instanceof'; -InsteadOf: 'insteadof'; -Int8Cast: 'int8'; -Int16Cast: 'int16'; -Int64Type: 'int64'; -IntType: 'int' 'eger'?; -Interface: 'interface'; -IsSet: 'isset'; -List: 'list'; -LogicalAnd: 'and'; -LogicalOr: 'or'; -LogicalXor: 'xor'; -Match_: 'match'; -Namespace: 'namespace'; -New: 'new'; -Null: 'null'; -ObjectType: 'object'; -Parent_: 'parent'; -Partial: 'partial'; -Print: 'print'; -Private: 'private'; -Protected: 'protected'; -Public: 'public'; -Readonly: 'readonly'; -Require: 'require'; -RequireOnce: 'require_once'; -Resource: 'resource'; -Return: 'return'; -Static: 'static'; -StringType: 'string'; -Switch: 'switch'; -Throw: 'throw'; -Trait: 'trait'; -Try: 'try'; -Typeof: 'clrtypeof'; -UintCast: 'uint' ('8' | '16' | '64')?; -UnicodeCast: 'unicode'; -Unset: 'unset'; -Use: 'use'; -Var: 'var'; -While: 'while'; -Yield: 'yield'; -From: 'from'; -LambdaFn: 'fn'; -Ticks: 'ticks'; -Encoding: 'encoding'; -StrictTypes: 'strict_types'; - -Get: '__get'; -Set: '__set'; -Call: '__call'; -CallStatic: '__callstatic'; -Constructor: '__construct'; -Destruct: '__destruct'; -Wakeup: '__wakeup'; -Sleep: '__sleep'; -Autoload: '__autoload'; -IsSet__: '__isset'; -Unset__: '__unset'; -ToString__: '__tostring'; -Invoke: '__invoke'; -SetState: '__set_state'; -Clone__: '__clone'; -DebugInfo: '__debuginfo'; -Namespace__: '__namespace__'; -Class__: '__class__'; -Traic__: '__trait__'; -Function__: '__function__'; -Method__: '__method__'; -Line__: '__line__'; -File__: '__file__'; -Dir__: '__dir__'; - -Spaceship: '<=>'; -Lgeneric: '<:'; -Rgeneric: ':>'; -DoubleArrow: '=>'; -Inc: '++'; -Dec: '--'; -IsIdentical: '==='; -IsNoidentical: '!=='; -IsEqual: '=='; -IsNotEq: '<>' - | '!='; -IsSmallerOrEqual: '<='; -IsGreaterOrEqual: '>='; -PlusEqual: '+='; -MinusEqual: '-='; -MulEqual: '*='; -Pow: '**'; -PowEqual: '**='; -DivEqual: '/='; -Concaequal: '.='; -ModEqual: '%='; -ShiftLeftEqual: '<<='; -ShiftRightEqual: '>>='; -AndEqual: '&='; -OrEqual: '|='; -XorEqual: '^='; -BooleanOr: '||'; -BooleanAnd: '&&'; - -NullCoalescing: '??'; -NullCoalescingEqual:'??='; - -ShiftLeft: '<<'; -ShiftRight: '>>'; -DoubleColon: '::'; -ObjectOperator: '->'; -NamespaceSeparator: '\\'; -Ellipsis: '...'; -Less: '<'; -Greater: '>'; -Ampersand: '&'; -Pipe: '|'; -Bang: '!'; -Caret: '^'; -Plus: '+'; -Minus: '-'; -Asterisk: '*'; -Percent: '%'; -Divide: '/'; -Tilde: '~'; -SuppressWarnings: '@'; -Dollar: '$'; -Dot: '.'; -QuestionMark: '?'; -OpenRoundBracket: '('; -CloseRoundBracket: ')'; -OpenSquareBracket: '['; -CloseSquareBracket: ']'; -OpenCurlyBracket: '{'; -CloseCurlyBracket: '}' -{ this.PopModeOnCurlyBracketClose(); }; -Comma: ','; -Colon: ':'; -SemiColon: ';'; -Eq: '='; -Quote: '\''; -BackQuote: '`'; - -VarName: '$' NameString; -Label: [a-z_][a-z_0-9]*; -Octal: '0' 'o'? OctalDigit+ ('_' OctalDigit+)*; -Decimal: '0' | NonZeroDigit Digit* ('_' Digit+)*; -Real: (LNum '.' LNum? | LNum? '.' LNum ) ExponentPart? - | LNum+ ExponentPart; -Hex: '0x' HexDigit+ ('_' HexDigit+)*; -Binary: '0b' [01]+ ('_' [01]+)*; - -BackQuoteString: '`' ~'`'* '`'; -SingleQuoteString: '\'' (~('\'' | '\\') | '\\' . )* '\''; -DoubleQuote: '"' -> pushMode(InterpolationString); - -StartNowDoc - : '<<<' [ \t]* '\'' NameString '\'' { this.ShouldPushHereDocMode(1) }? -> pushMode(HereDoc) - ; -StartHereDoc - : '<<<' [ \t]* NameString { this.ShouldPushHereDocMode(1) }? -> pushMode(HereDoc) - ; -ErrorPhp: . -> channel(ErrorLexem); +PHPEnd : ('?' | '%' {this.HasAspTags()}?) '>' | '' {this.HasPhpScriptTag()}?; +Whitespace : [ \t\r\n]+ -> channel(SkipChannel); +MultiLineComment : '/*' .*? '*/' -> channel(PhpComments); +SingleLineComment : '//' -> channel(SkipChannel), pushMode(SingleLineCommentMode); +ShellStyleComment : '#' -> channel(SkipChannel), pushMode(SingleLineCommentMode); + +AttributeStart: '#['; + +Abstract : 'abstract'; +Array : 'array'; +As : 'as'; +BinaryCast : 'binary'; +BoolType : 'bool' 'ean'?; +BooleanConstant : 'true' | 'false'; +Break : 'break'; +Callable : 'callable'; +Case : 'case'; +Catch : 'catch'; +Class : 'class'; +Clone : 'clone'; +Const : 'const'; +Continue : 'continue'; +Declare : 'declare'; +Default : 'default'; +Do : 'do'; +DoubleCast : 'real'; +DoubleType : 'double'; +Echo : 'echo'; +Else : 'else'; +ElseIf : 'elseif'; +Empty : 'empty'; +Enum_ : 'enum'; + +EndDeclare : 'enddeclare'; +EndFor : 'endfor'; +EndForeach : 'endforeach'; +EndIf : 'endif'; +EndSwitch : 'endswitch'; +EndWhile : 'endwhile'; + +Eval : 'eval'; +Exit : 'die'; +Extends : 'extends'; +Final : 'final'; +Finally : 'finally'; +FloatCast : 'float'; +For : 'for'; +Foreach : 'foreach'; +Function_ : 'function'; +Global : 'global'; +Goto : 'goto'; +If : 'if'; +Implements : 'implements'; +Import : 'import'; +Include : 'include'; +IncludeOnce : 'include_once'; +InstanceOf : 'instanceof'; +InsteadOf : 'insteadof'; +Int8Cast : 'int8'; +Int16Cast : 'int16'; +Int64Type : 'int64'; +IntType : 'int' 'eger'?; +Interface : 'interface'; +IsSet : 'isset'; +List : 'list'; +LogicalAnd : 'and'; +LogicalOr : 'or'; +LogicalXor : 'xor'; +Match_ : 'match'; +Namespace : 'namespace'; +New : 'new'; +Null : 'null'; +ObjectType : 'object'; +Parent_ : 'parent'; +Partial : 'partial'; +Print : 'print'; +Private : 'private'; +Protected : 'protected'; +Public : 'public'; +Readonly : 'readonly'; +Require : 'require'; +RequireOnce : 'require_once'; +Resource : 'resource'; +Return : 'return'; +Static : 'static'; +StringType : 'string'; +Switch : 'switch'; +Throw : 'throw'; +Trait : 'trait'; +Try : 'try'; +Typeof : 'clrtypeof'; +UintCast : 'uint' ('8' | '16' | '64')?; +UnicodeCast : 'unicode'; +Unset : 'unset'; +Use : 'use'; +Var : 'var'; +While : 'while'; +Yield : 'yield'; +From : 'from'; +LambdaFn : 'fn'; +Ticks : 'ticks'; +Encoding : 'encoding'; +StrictTypes : 'strict_types'; + +Get : '__get'; +Set : '__set'; +Call : '__call'; +CallStatic : '__callstatic'; +Constructor : '__construct'; +Destruct : '__destruct'; +Wakeup : '__wakeup'; +Sleep : '__sleep'; +Autoload : '__autoload'; +IsSet__ : '__isset'; +Unset__ : '__unset'; +ToString__ : '__tostring'; +Invoke : '__invoke'; +SetState : '__set_state'; +Clone__ : '__clone'; +DebugInfo : '__debuginfo'; +Namespace__ : '__namespace__'; +Class__ : '__class__'; +Traic__ : '__trait__'; +Function__ : '__function__'; +Method__ : '__method__'; +Line__ : '__line__'; +File__ : '__file__'; +Dir__ : '__dir__'; + +Spaceship : '<=>'; +Lgeneric : '<:'; +Rgeneric : ':>'; +DoubleArrow : '=>'; +Inc : '++'; +Dec : '--'; +IsIdentical : '==='; +IsNoidentical : '!=='; +IsEqual : '=='; +IsNotEq : '<>' | '!='; +IsSmallerOrEqual : '<='; +IsGreaterOrEqual : '>='; +PlusEqual : '+='; +MinusEqual : '-='; +MulEqual : '*='; +Pow : '**'; +PowEqual : '**='; +DivEqual : '/='; +Concaequal : '.='; +ModEqual : '%='; +ShiftLeftEqual : '<<='; +ShiftRightEqual : '>>='; +AndEqual : '&='; +OrEqual : '|='; +XorEqual : '^='; +BooleanOr : '||'; +BooleanAnd : '&&'; + +NullCoalescing : '??'; +NullCoalescingEqual : '??='; + +ShiftLeft : '<<'; +ShiftRight : '>>'; +DoubleColon : '::'; +ObjectOperator : '->'; +NamespaceSeparator : '\\'; +Ellipsis : '...'; +Less : '<'; +Greater : '>'; +Ampersand : '&'; +Pipe : '|'; +Bang : '!'; +Caret : '^'; +Plus : '+'; +Minus : '-'; +Asterisk : '*'; +Percent : '%'; +Divide : '/'; +Tilde : '~'; +SuppressWarnings : '@'; +Dollar : '$'; +Dot : '.'; +QuestionMark : '?'; +OpenRoundBracket : '('; +CloseRoundBracket : ')'; +OpenSquareBracket : '['; +CloseSquareBracket : ']'; +OpenCurlyBracket : '{'; +CloseCurlyBracket : '}' { this.PopModeOnCurlyBracketClose(); }; +Comma : ','; +Colon : ':'; +SemiColon : ';'; +Eq : '='; +Quote : '\''; +BackQuote : '`'; + +VarName : '$' NameString; +Label : [a-z_][a-z_0-9]*; +Octal : '0' 'o'? OctalDigit+ ('_' OctalDigit+)*; +Decimal : '0' | NonZeroDigit Digit* ('_' Digit+)*; +Real : (LNum '.' LNum? | LNum? '.' LNum) ExponentPart? | LNum+ ExponentPart; +Hex : '0x' HexDigit+ ('_' HexDigit+)*; +Binary : '0b' [01]+ ('_' [01]+)*; + +BackQuoteString : '`' ~'`'* '`'; +SingleQuoteString : '\'' (~('\'' | '\\') | '\\' .)* '\''; +DoubleQuote : '"' -> pushMode(InterpolationString); + +StartNowDoc: + '<<<' [ \t]* '\'' NameString '\'' { this.ShouldPushHereDocMode(1) }? -> pushMode(HereDoc) +; +StartHereDoc : '<<<' [ \t]* NameString { this.ShouldPushHereDocMode(1) }? -> pushMode(HereDoc); +ErrorPhp : . -> channel(ErrorLexem); mode InterpolationString; -VarNameInInterpolation: '$' NameString -> type(VarName); // TODO: fix such cases: "$people->john" -DollarString: '$' -> type(StringPart); -CurlyDollar: '{' { this.IsCurlyDollar(1) }? { this.SetInsideString(); } -> channel(SkipChannel), pushMode(PHP); -CurlyString: '{' -> type(StringPart); -EscapedChar: '\\' . -> type(StringPart); -DoubleQuoteInInterpolation: '"' -> type(DoubleQuote), popMode; -UnicodeEscape: '\\u{' [a-z0-9][a-z0-9]+ '}'; -StringPart: ~[${\\"]+; +VarNameInInterpolation : '$' NameString -> type(VarName); // TODO: fix such cases: "$people->john" +DollarString : '$' -> type(StringPart); +CurlyDollar: + '{' { this.IsCurlyDollar(1) }? { this.SetInsideString(); } -> channel(SkipChannel), pushMode(PHP) +; +CurlyString : '{' -> type(StringPart); +EscapedChar : '\\' . -> type(StringPart); +DoubleQuoteInInterpolation : '"' -> type(DoubleQuote), popMode; +UnicodeEscape : '\\u{' [a-z0-9][a-z0-9]+ '}'; +StringPart : ~[${\\"]+; mode SingleLineCommentMode; -Comment: ~[\r\n?]+ -> channel(PhpComments); -PHPEndSingleLineComment: '?' '>'; -CommentQuestionMark: '?' -> type(Comment), channel(PhpComments); -CommentEnd: [\r\n] -> channel(SkipChannel), popMode; // exit from comment. +Comment : ~[\r\n?]+ -> channel(PhpComments); +PHPEndSingleLineComment : '?' '>'; +CommentQuestionMark : '?' -> type(Comment), channel(PhpComments); +CommentEnd : [\r\n] -> channel(SkipChannel), popMode; // exit from comment. -mode HereDoc; // TODO: interpolation for heredoc strings. +mode HereDoc; +// TODO: interpolation for heredoc strings. HereDocText: ~[\r\n]*? ('\r'? '\n' | '\r'); // fragments. // '' will be transformed to '' -fragment PhpStartEchoFragment: '<' ('?' '=' | { this.HasAspTags() }? '%' '='); -fragment PhpStartFragment: '<' ('?' 'php'? | { this.HasAspTags() }? '%'); -fragment NameString options { caseInsensitive = false; }: [a-zA-Z_\u0080-\ufffe][a-zA-Z0-9_\u0080-\ufffe]*; -fragment HtmlNameChar options { caseInsensitive = false; } - : HtmlNameStartChar +fragment PhpStartEchoFragment : '<' ('?' '=' | { this.HasAspTags() }? '%' '='); +fragment PhpStartFragment : '<' ('?' 'php'? | { this.HasAspTags() }? '%'); +fragment NameString options { + caseInsensitive = false; +}: [a-zA-Z_\u0080-\ufffe][a-zA-Z0-9_\u0080-\ufffe]*; +fragment HtmlNameChar options { + caseInsensitive = false; +}: + HtmlNameStartChar | '-' | '_' | '.' | Digit | '\u00B7' - | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; -fragment HtmlNameStartChar options { caseInsensitive = false; } - : [:a-zA-Z] - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - ; -fragment LNum: Digit+ ('_' Digit+)*; -fragment ExponentPart: 'e' [+-]? LNum; -fragment NonZeroDigit: [1-9]; -fragment Digit: [0-9]; -fragment OctalDigit: [0-7]; -fragment HexDigit: [a-f0-9]; + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' +; +fragment HtmlNameStartChar options { + caseInsensitive = false; +}: + [:a-zA-Z] + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD'; +fragment LNum : Digit+ ('_' Digit+)*; +fragment ExponentPart : 'e' [+-]? LNum; +fragment NonZeroDigit : [1-9]; +fragment Digit : [0-9]; +fragment OctalDigit : [0-7]; +fragment HexDigit : [a-f0-9]; \ No newline at end of file diff --git a/php/PhpParser.g4 b/php/PhpParser.g4 index 541dbba00c..3ba7eb3dd6 100644 --- a/php/PhpParser.g4 +++ b/php/PhpParser.g4 @@ -23,9 +23,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 PhpParser; -options { tokenVocab=PhpLexer; } +options { + tokenVocab = PhpLexer; +} // HTML // Also see here: https://github.com/antlr/grammars-v4/tree/master/html @@ -58,12 +63,9 @@ htmlElement | HtmlDecimal | HtmlQuoteString | HtmlDoubleQuoteString - | StyleBody - | HtmlScriptOpen | HtmlScriptClose - | XmlStart XmlText* XmlClose ; @@ -107,7 +109,10 @@ useDeclarationContent ; namespaceDeclaration - : Namespace (namespaceNameList? OpenCurlyBracket namespaceStatement* CloseCurlyBracket | namespaceNameList SemiColon) + : Namespace ( + namespaceNameList? OpenCurlyBracket namespaceStatement* CloseCurlyBracket + | namespaceNameList SemiColon + ) ; namespaceStatement @@ -119,15 +124,18 @@ namespaceStatement ; functionDeclaration - : attributes? Function_ '&'? identifier typeParameterListInBrackets? '(' formalParameterList ')' - (':' QuestionMark? typeHint)? blockStatement + : attributes? Function_ '&'? identifier typeParameterListInBrackets? '(' formalParameterList ')' ( + ':' QuestionMark? typeHint + )? blockStatement ; classDeclaration : attributes? Private? modifier? Partial? ( - classEntryType identifier typeParameterListInBrackets? (Extends qualifiedStaticTypeRef)? (Implements interfaceList)? - | Interface identifier typeParameterListInBrackets? (Extends interfaceList)? ) - OpenCurlyBracket classStatement* CloseCurlyBracket + classEntryType identifier typeParameterListInBrackets? (Extends qualifiedStaticTypeRef)? ( + Implements interfaceList + )? + | Interface identifier typeParameterListInBrackets? (Extends interfaceList)? + ) OpenCurlyBracket classStatement* CloseCurlyBracket ; classEntryType @@ -253,7 +261,10 @@ doWhileStatement ; forStatement - : For '(' forInit? SemiColon expressionList? SemiColon forUpdate? ')' (statement | ':' innerStatementList EndFor SemiColon ) + : For '(' forInit? SemiColon expressionList? SemiColon forUpdate? ')' ( + statement + | ':' innerStatementList EndFor SemiColon + ) ; forInit @@ -265,7 +276,10 @@ forUpdate ; switchStatement - : Switch parentheses (OpenCurlyBracket SemiColon? switchBlock* CloseCurlyBracket | ':' SemiColon? switchBlock* EndSwitch SemiColon) + : Switch parentheses ( + OpenCurlyBracket SemiColon? switchBlock* CloseCurlyBracket + | ':' SemiColon? switchBlock* EndSwitch SemiColon + ) ; switchBlock @@ -293,12 +307,12 @@ unsetStatement ; foreachStatement - : Foreach - ( '(' expression As arrayDestructuring ')' + : Foreach ( + '(' expression As arrayDestructuring ')' | '(' chain As '&'? assignable ('=>' '&'? chain)? ')' | '(' expression As assignable ('=>' '&'? chain)? ')' - | '(' chain As List '(' assignmentList ')' ')' ) - (statement | ':' innerStatementList EndForeach SemiColon) + | '(' chain As List '(' assignmentList ')' ')' + ) (statement | ':' innerStatementList EndForeach SemiColon) ; tryCatchFinally @@ -373,12 +387,16 @@ staticVariableStatement ; classStatement - : attributes? ( propertyModifiers typeHint? variableInitializer (',' variableInitializer)* SemiColon - | memberModifiers? ( Const typeHint? identifierInitializer (',' identifierInitializer)* SemiColon - | Function_ '&'? identifier typeParameterListInBrackets? '(' formalParameterList ')' - (baseCtorCall | returnTypeDecl)? methodBody - ) - ) + : attributes? ( + propertyModifiers typeHint? variableInitializer (',' variableInitializer)* SemiColon + | memberModifiers? ( + Const typeHint? identifierInitializer (',' identifierInitializer)* SemiColon + | Function_ '&'? identifier typeParameterListInBrackets? '(' formalParameterList ')' ( + baseCtorCall + | returnTypeDecl + )? methodBody + ) + ) | Use qualifiedNamespaceNameList traitAdaptations ; @@ -439,10 +457,7 @@ globalConstantDeclaration ; enumDeclaration - : Enum_ identifier (Colon (IntType | StringType))? (Implements interfaceList)? - OpenCurlyBracket - enumItem* - CloseCurlyBracket + : Enum_ identifier (Colon (IntType | StringType))? (Implements interfaceList)? OpenCurlyBracket enumItem* CloseCurlyBracket ; enumItem @@ -462,71 +477,54 @@ parentheses // Expressions // Grouped by priorities: http://php.net/manual/en/language.operators.precedence.php expression - : Clone expression #CloneExpression - | newExpr #NewExpression - - | stringConstant '[' expression ']' #IndexerExpression - - | '(' castOperation ')' expression #CastExpression - | ('~' | '@') expression #UnaryOperatorExpression - - | ('!' | '+' | '-') expression #UnaryOperatorExpression - - | ('++' | '--') chain #PrefixIncDecExpression - | chain ('++' | '--') #PostfixIncDecExpression - - | Print expression #PrintExpression - - | arrayCreation #ArrayCreationExpression - | chain #ChainExpression - | constant #ScalarExpression - | string #ScalarExpression - | Label #ScalarExpression - - | BackQuoteString #BackQuoteStringExpression - | parentheses #ParenthesisExpression - - | Yield #SpecialWordExpression - | List '(' assignmentList ')' Eq expression #SpecialWordExpression - | IsSet '(' chainList ')' #SpecialWordExpression - | Empty '(' chain ')' #SpecialWordExpression - | Eval '(' expression ')' #SpecialWordExpression - | Exit ( '(' ')' | parentheses )? #SpecialWordExpression - | (Include | IncludeOnce) expression #SpecialWordExpression - | (Require | RequireOnce) expression #SpecialWordExpression - - | lambdaFunctionExpr #LambdaFunctionExpression - | matchExpr #MatchExpression - - | expression op='**' expression #ArithmeticExpression - | expression InstanceOf typeRef #InstanceOfExpression - | expression op=('*' | Divide | '%') expression #ArithmeticExpression - - | expression op=('+' | '-' | '.') expression #ArithmeticExpression - - | expression op=('<<' | '>>') expression #ComparisonExpression - | expression op=(Less | '<=' | Greater | '>=') expression #ComparisonExpression - | expression op=('===' | '!==' | '==' | IsNotEq) expression #ComparisonExpression - - | expression op='&' expression #BitwiseExpression - | expression op='^' expression #BitwiseExpression - | expression op='|' expression #BitwiseExpression - | expression op='&&' expression #BitwiseExpression - | expression op='||' expression #BitwiseExpression - - | expression op=QuestionMark expression? ':' expression #ConditionalExpression - | expression op='??' expression #NullCoalescingExpression - | expression op='<=>' expression #SpaceshipExpression - - | Throw expression #SpecialWordExpression - - | arrayDestructuring Eq expression #ArrayDestructExpression - | assignable assignmentOperator attributes? expression #AssignmentExpression - | assignable Eq attributes? '&' (chain | newExpr) #AssignmentExpression - - | expression op=LogicalAnd expression #LogicalExpression - | expression op=LogicalXor expression #LogicalExpression - | expression op=LogicalOr expression #LogicalExpression + : Clone expression # CloneExpression + | newExpr # NewExpression + | stringConstant '[' expression ']' # IndexerExpression + | '(' castOperation ')' expression # CastExpression + | ('~' | '@') expression # UnaryOperatorExpression + | ('!' | '+' | '-') expression # UnaryOperatorExpression + | ('++' | '--') chain # PrefixIncDecExpression + | chain ('++' | '--') # PostfixIncDecExpression + | Print expression # PrintExpression + | arrayCreation # ArrayCreationExpression + | chain # ChainExpression + | constant # ScalarExpression + | string # ScalarExpression + | Label # ScalarExpression + | BackQuoteString # BackQuoteStringExpression + | parentheses # ParenthesisExpression + | Yield # SpecialWordExpression + | List '(' assignmentList ')' Eq expression # SpecialWordExpression + | IsSet '(' chainList ')' # SpecialWordExpression + | Empty '(' chain ')' # SpecialWordExpression + | Eval '(' expression ')' # SpecialWordExpression + | Exit ( '(' ')' | parentheses)? # SpecialWordExpression + | (Include | IncludeOnce) expression # SpecialWordExpression + | (Require | RequireOnce) expression # SpecialWordExpression + | lambdaFunctionExpr # LambdaFunctionExpression + | matchExpr # MatchExpression + | expression op = '**' expression # ArithmeticExpression + | expression InstanceOf typeRef # InstanceOfExpression + | expression op = ('*' | Divide | '%') expression # ArithmeticExpression + | expression op = ('+' | '-' | '.') expression # ArithmeticExpression + | expression op = ('<<' | '>>') expression # ComparisonExpression + | expression op = (Less | '<=' | Greater | '>=') expression # ComparisonExpression + | expression op = ('===' | '!==' | '==' | IsNotEq) expression # ComparisonExpression + | expression op = '&' expression # BitwiseExpression + | expression op = '^' expression # BitwiseExpression + | expression op = '|' expression # BitwiseExpression + | expression op = '&&' expression # BitwiseExpression + | expression op = '||' expression # BitwiseExpression + | expression op = QuestionMark expression? ':' expression # ConditionalExpression + | expression op = '??' expression # NullCoalescingExpression + | expression op = '<=>' expression # SpaceshipExpression + | Throw expression # SpecialWordExpression + | arrayDestructuring Eq expression # ArrayDestructExpression + | assignable assignmentOperator attributes? expression # AssignmentExpression + | assignable Eq attributes? '&' (chain | newExpr) # AssignmentExpression + | expression op = LogicalAnd expression # LogicalExpression + | expression op = LogicalXor expression # LogicalExpression + | expression op = LogicalOr expression # LogicalExpression ; assignable @@ -553,7 +551,7 @@ keyedDestructItem lambdaFunctionExpr : Static? Function_ '&'? '(' formalParameterList ')' lambdaFunctionUseVars? (':' typeHint)? blockStatement - | LambdaFn '(' formalParameterList')' '=>' expression + | LambdaFn '(' formalParameterList ')' '=>' expression ; matchExpr @@ -620,9 +618,11 @@ typeRef anonymousClass : attributes? Private? modifier? Partial? ( - classEntryType typeParameterListInBrackets? (Extends qualifiedStaticTypeRef)? (Implements interfaceList)? - | Interface identifier typeParameterListInBrackets? (Extends interfaceList)? ) - OpenCurlyBracket classStatement* CloseCurlyBracket + classEntryType typeParameterListInBrackets? (Extends qualifiedStaticTypeRef)? ( + Implements interfaceList + )? + | Interface identifier typeParameterListInBrackets? (Extends interfaceList)? + ) OpenCurlyBracket classStatement* CloseCurlyBracket ; indirectTypeRef @@ -640,7 +640,7 @@ namespaceNameList namespaceNameTail : identifier (As identifier)? - | OpenCurlyBracket namespaceNameTail (','namespaceNameTail)* ','? CloseCurlyBracket + | OpenCurlyBracket namespaceNameTail (',' namespaceNameTail)* ','? CloseCurlyBracket ; qualifiedNamespaceNameList @@ -648,7 +648,7 @@ qualifiedNamespaceNameList ; arguments - : '(' ( actualArgument (',' actualArgument)* | yieldExpression)? ','? ')' + : '(' (actualArgument (',' actualArgument)* | yieldExpression)? ','? ')' ; actualArgument @@ -693,7 +693,10 @@ numericConstant classConstant : (Class | Parent_) '::' (identifier | Constructor | Get | Set) - | (qualifiedStaticTypeRef | keyedVariable | string) '::' (identifier | keyedVariable) // 'foo'::$bar works in php7 + | (qualifiedStaticTypeRef | keyedVariable | string) '::' ( + identifier + | keyedVariable + ) // 'foo'::$bar works in php7 ; stringConstant @@ -776,7 +779,7 @@ assignmentList assignmentListElement : chain - | List '(' assignmentList ')' + | List '(' assignmentList ')' | arrayItem ; @@ -787,7 +790,6 @@ modifier identifier : Label - | Abstract | Array | As @@ -881,7 +883,6 @@ identifier | Ticks | Encoding | StrictTypes - | Get | Set | Call @@ -976,4 +977,4 @@ castOperation | ObjectType | Resource | Unset - ; + ; \ No newline at end of file diff --git a/pii/pii.g4 b/pii/pii.g4 index 34152f8096..3b5092d641 100644 --- a/pii/pii.g4 +++ b/pii/pii.g4 @@ -32,50 +32,52 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://web.archive.org/web/20021118041502/http://www.icsti.org/forum/23/index.html#identifiers +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar pii; pii - : (issn | isbn) item check EOF - ; + : (issn | isbn) item check EOF + ; issn - : 'S' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT year - ; + : 'S' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT year + ; isbn - : 'B' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT - ; + : 'B' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT + ; year - : DIGIT DIGIT - ; + : DIGIT DIGIT + ; item - : DIGIT DIGIT DIGIT DIGIT DIGIT - ; + : DIGIT DIGIT DIGIT DIGIT DIGIT + ; check - : DIGIT - | 'X' - ; + : DIGIT + | 'X' + ; DIGIT - : [0-9] - ; + : [0-9] + ; LPAREN - : '(' -> skip - ; + : '(' -> skip + ; RPAREN - : ')' -> skip - ; + : ')' -> skip + ; DASH - : '-' -> skip - ; + : '-' -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/pike/pike.g4 b/pike/pike.g4 index 051a627ccb..37ddee987b 100644 --- a/pike/pike.g4 +++ b/pike/pike.g4 @@ -33,356 +33,393 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* * http://www.mit.edu/afs.new/sipb/project/pike/tutorial/tutorial_onepage.html#D */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar pike; program - : definition* EOF? - ; + : definition* EOF? + ; definition - : impo - | inheritance - | function_declaration - | function_definition - | variables - | constant - | class_def - ; + : impo + | inheritance + | function_declaration + | function_definition + | variables + | constant + | class_def + ; impo - : modifiers? 'import' constant_identifier ';' - ; + : modifiers? 'import' constant_identifier ';' + ; inheritance - : modifiers? 'inherit' program_specifier (':' identifier)? ';' - ; + : modifiers? 'inherit' program_specifier (':' identifier)? ';' + ; function_declaration - : modifiers? type_ identifier '(' arguments? ')' ';' - ; + : modifiers? type_ identifier '(' arguments? ')' ';' + ; function_definition - : modifiers? type_ identifier '(' arguments? ')' block - ; + : modifiers? type_ identifier '(' arguments? ')' block + ; variables - : modifiers? type_ variable_names ';' - ; + : modifiers? type_ variable_names ';' + ; variable_names - : variable_name (',' variable_name)* - ; + : variable_name (',' variable_name)* + ; variable_name - : '*'* identifier ('=' expression2)? - ; + : '*'* identifier ('=' expression2)? + ; constant - : modifiers? 'constant' constant_names ';' - ; + : modifiers? 'constant' constant_names ';' + ; constant_names - : constant_name (',' constant_name)* - ; + : constant_name (',' constant_name)* + ; constant_name - : identifier '=' expression2 - ; + : identifier '=' expression2 + ; class_def - : modifiers? 'class' ';'? - ; + : modifiers? 'class' ';'? + ; class_implementation - : 'class' identifier? '{' program '}' - ; + : 'class' identifier? '{' program '}' + ; modifiers - : 'static' - | 'private' - | 'nomask' - | 'public' - | 'protected' - | 'inline' - ; + : 'static' + | 'private' + | 'nomask' + | 'public' + | 'protected' + | 'inline' + ; block - : '{' statement* '}' - ; + : '{' statement* '}' + ; statement - : expression2 ';' - | cond - | while_stmt - | do_while_stmt - | for_stmt - | switch_stmt - | case_stmt - | default_stmt - | block - | return_stmt - | foreach_stmt - | break_stmt - | continue_stmt - | ';' - ; + : expression2 ';' + | cond + | while_stmt + | do_while_stmt + | for_stmt + | switch_stmt + | case_stmt + | default_stmt + | block + | return_stmt + | foreach_stmt + | break_stmt + | continue_stmt + | ';' + ; cond - : 'if' statement ('else' statement)? - ; + : 'if' statement ('else' statement)? + ; while_stmt - : 'while' '(' expression ')' statement - ; + : 'while' '(' expression ')' statement + ; return_stmt - : 'return' expression - ; + : 'return' expression + ; do_while_stmt - : 'do' statement while_stmt '(' expression ')' ';' - ; + : 'do' statement while_stmt '(' expression ')' ';' + ; for_stmt - : 'for' '(' expression? ';' expression? ';' expression? ')' statement - ; + : 'for' '(' expression? ';' expression? ';' expression? ')' statement + ; switch_stmt - : 'switch' '(' expression ')' block - ; + : 'switch' '(' expression ')' block + ; case_stmt - : 'case' expression ('..' expression)? ':' - ; + : 'case' expression ('..' expression)? ':' + ; default_stmt - : 'default' ':' - ; + : 'default' ':' + ; foreach_stmt - : 'foreach' '(' expression ':' expression6 ')' statement - ; + : 'foreach' '(' expression ':' expression6 ')' statement + ; break_stmt - : 'break' ';' - ; + : 'break' ';' + ; continue_stmt - : 'continue' ';' - ; + : 'continue' ';' + ; expression - : expression2 (',' expression2)* - ; + : expression2 (',' expression2)* + ; expression2 - : (lvalue ('=' | '+=' | '*=' | '/=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '%='))* expression3 - ; + : (lvalue ('=' | '+=' | '*=' | '/=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '%='))* expression3 + ; expression3 - : expression4 ('?' expression3 ':' expression3)? - ; + : expression4 ('?' expression3 ':' expression3)? + ; expression4 - : (expression5 ('||' | '&&' | '|' | '^' | '&' | '==' | '!=' | '>' | '<' | '>=' | '<=' | '<<' | '>>' | '+' | '*' | '/' | '%'))* expression5 - ; + : ( + expression5 ( + '||' + | '&&' + | '|' + | '^' + | '&' + | '==' + | '!=' + | '>' + | '<' + | '>=' + | '<=' + | '<<' + | '>>' + | '+' + | '*' + | '/' + | '%' + ) + )* expression5 + ; expression5 - : expression6 - | '(' type_ ')' expression5 - | '--' expression6 - | '++' expression6 - | expression6 '--' - | expression6 '++' - | '~' expression5 - | '-' expression5 - | '!' expression5 - ; + : expression6 + | '(' type_ ')' expression5 + | '--' expression6 + | '++' expression6 + | expression6 '--' + | expression6 '++' + | '~' expression5 + | '-' expression5 + | '!' expression5 + ; expression6 - : (STRING | NUMBER | FLOAT | catch_ | gauge | sscanf | lambda | class_implementation | constant_identifier | mapping | multiset | array | parenthesis) extension* - ; + : ( + STRING + | NUMBER + | FLOAT + | catch_ + | gauge + | sscanf + | lambda + | class_implementation + | constant_identifier + | mapping + | multiset + | array + | parenthesis + ) extension* + ; extension - : '(' expression_list ')' - | '->' identifier - | '[' expression ('..' expression)? ']' - ; + : '(' expression_list ')' + | '->' identifier + | '[' expression ('..' expression)? ']' + ; catch_ - : 'catch' ('(' expression ')' | block) - ; + : 'catch' ('(' expression ')' | block) + ; gauge - : 'gauge' ('(' expression ')' | block) - ; + : 'gauge' ('(' expression ')' | block) + ; sscanf - : 'sscanf' '(' expression2 ',' expression2 (',' lvalue)* ')' - ; + : 'sscanf' '(' expression2 ',' expression2 (',' lvalue)* ')' + ; lvalue - : 'lambda' expression6 - | type_ identifier - ; + : 'lambda' expression6 + | type_ identifier + ; lambda - : 'lambda' '(' arguments? ')' block - ; + : 'lambda' '(' arguments? ')' block + ; constant_identifier - : identifier ('.' identifier)* - ; + : identifier ('.' identifier)* + ; array - : '({' expression_list '})' - ; + : '({' expression_list '})' + ; multiset - : '(<' expression_list '>)' - ; + : '(<' expression_list '>)' + ; mapping - : '([' (expression ':' expression (',' expression ':' expression)*)? ','? '])' - ; + : '([' (expression ':' expression (',' expression ':' expression)*)? ','? '])' + ; program_specifier - : constant_identifier - ; + : constant_identifier + ; parenthesis - : '(' expression ')' - ; + : '(' expression ')' + ; expression_list - : (splice_expression (',' splice_expression)*)? ','? - ; + : (splice_expression (',' splice_expression)*)? ','? + ; splice_expression - : '@'? expression2 - ; + : '@'? expression2 + ; argument - : type_ ('...')? identifier - ; + : type_ ('...')? identifier + ; arguments - : (argument (',' argument)*) (',')? - ; + : (argument (',' argument)*) (',')? + ; type_ - : type__ ('*')* - ; + : type__ ('*')* + ; type__ - : INTTYPE - | STRINGTYPE - | FLOATTYPE - | PROGRAMTYPE - | (OBJECTTYPE ('(' program_specifier ')')?) - | (MAPPINGTYPE ('(' type_ ':' type_ ')')?) - | (ARRAYTYPE ('(' type_ ')')?) - | (MULTISETTYPE ('(' type_ ')')?) - | (FUNCTIONTYPE function_type?) - ; + : INTTYPE + | STRINGTYPE + | FLOATTYPE + | PROGRAMTYPE + | (OBJECTTYPE ('(' program_specifier ')')?) + | (MAPPINGTYPE ('(' type_ ':' type_ ')')?) + | (ARRAYTYPE ('(' type_ ')')?) + | (MULTISETTYPE ('(' type_ ')')?) + | (FUNCTIONTYPE function_type?) + ; function_type - : '(' type_ (',' type_)* ('...')? ')' - ; + : '(' type_ (',' type_)* ('...')? ')' + ; identifier - : IDENTIFIER - ; + : IDENTIFIER + ; INTTYPE - : 'int' - ; + : 'int' + ; FLOATTYPE - : 'float' - ; + : 'float' + ; STRINGTYPE - : 'string' - ; + : 'string' + ; PROGRAMTYPE - : 'program' - ; + : 'program' + ; OBJECTTYPE - : 'object' - ; + : 'object' + ; MAPPINGTYPE - : 'mapping' - ; + : 'mapping' + ; ARRAYTYPE - : 'array' - ; + : 'array' + ; MULTISETTYPE - : 'multiset' - ; + : 'multiset' + ; FUNCTIONTYPE - : 'function' - ; + : 'function' + ; IDENTIFIER - : LETTER (LETTER | DIGIT | IDSYMBOL)* - ; + : LETTER (LETTER | DIGIT | IDSYMBOL)* + ; LETTER - : 'a' .. 'z' - | 'A' .. 'Z' - | '_' - ; + : 'a' .. 'z' + | 'A' .. 'Z' + | '_' + ; FLOAT - : DIGIT+ '.' DIGIT+ - ; + : DIGIT+ '.' DIGIT+ + ; NUMBER - : '0x'? DIGIT+ - ; + : '0x'? DIGIT+ + ; STRING - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; fragment DIGIT - : '0' .. '9' - ; + : '0' .. '9' + ; fragment IDSYMBOL - : '`+' - | '`/' - | '`%' - | '`*' - | '`&' - | '`|' - | '`^' - | '`~' - | '`<' - | '`<<' - | '`<=' - | '`>' - | '`>>' - | '`>=' - | '`==' - | '`!=' - | '`!' - | '`()' - | '`-' - | '`->' - | '`->=' - | '`[]' - | '`[]=' - ; + : '`+' + | '`/' + | '`%' + | '`*' + | '`&' + | '`|' + | '`^' + | '`~' + | '`<' + | '`<<' + | '`<=' + | '`>' + | '`>>' + | '`>=' + | '`==' + | '`!=' + | '`!' + | '`()' + | '`-' + | '`->' + | '`->=' + | '`[]' + | '`[]=' + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/pl0/pl0.g4 b/pl0/pl0.g4 index 91d989251e..0246b88443 100644 --- a/pl0/pl0.g4 +++ b/pl0/pl0.g4 @@ -30,292 +30,254 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar pl0; program - : block '.' EOF - ; + : block '.' EOF + ; block - : consts? vars_? procedure* statement - ; + : consts? vars_? procedure* statement + ; consts - : CONST ident '=' number (',' ident '=' number)* ';' - ; + : CONST ident '=' number (',' ident '=' number)* ';' + ; vars_ - : VAR ident (',' ident)* ';' - ; + : VAR ident (',' ident)* ';' + ; procedure - : PROCEDURE ident ';' block ';' - ; + : PROCEDURE ident ';' block ';' + ; statement - : (assignstmt | callstmt | writestmt | qstmt | bangstmt | beginstmt | ifstmt | whilestmt)? - ; + : (assignstmt | callstmt | writestmt | qstmt | bangstmt | beginstmt | ifstmt | whilestmt)? + ; assignstmt - : ident ':=' expression - ; + : ident ':=' expression + ; callstmt - : CALL ident - ; + : CALL ident + ; writestmt - : WRITE ident - ; + : WRITE ident + ; qstmt - : '?' ident - ; + : '?' ident + ; bangstmt - : '!' expression - ; + : '!' expression + ; beginstmt - : BEGIN statement (';' statement)* END - ; + : BEGIN statement (';' statement)* END + ; ifstmt - : IF condition THEN statement - ; + : IF condition THEN statement + ; whilestmt - : WHILE condition DO statement - ; + : WHILE condition DO statement + ; condition - : ODD expression - | expression ('=' | '#' | '<' | '<=' | '>' | '>=') expression - ; + : ODD expression + | expression ('=' | '#' | '<' | '<=' | '>' | '>=') expression + ; expression - : ('+' | '-')? term (('+' | '-') term)* - ; + : ('+' | '-')? term (('+' | '-') term)* + ; term - : factor (('*' | '/') factor)* - ; + : factor (('*' | '/') factor)* + ; factor - : ident - | number - | '(' expression ')' - ; + : ident + | number + | '(' expression ')' + ; ident - : STRING - ; + : STRING + ; number - : NUMBER - ; - + : NUMBER + ; WRITE - : W R I T E - ; - + : W R I T E + ; WHILE - : W H I L E - ; - + : W H I L E + ; DO - : D O - ; - + : D O + ; IF - : I F - ; - + : I F + ; THEN - : T H E N - ; - + : T H E N + ; ODD - : O D D - ; - + : O D D + ; BEGIN - : B E G I N - ; - + : B E G I N + ; END - : E N D - ; - + : E N D + ; CALL - : C A L L - ; - + : C A L L + ; CONST - : C O N S T - ; - + : C O N S T + ; VAR - : V A R - ; - + : V A R + ; PROCEDURE - : P R O C E D U R E - ; - + : P R O C E D U R E + ; fragment A - : ('a' | 'A') - ; - + : ('a' | 'A') + ; fragment B - : ('b' | 'B') - ; - + : ('b' | 'B') + ; fragment C - : ('c' | 'C') - ; - + : ('c' | 'C') + ; fragment D - : ('d' | 'D') - ; - + : ('d' | 'D') + ; fragment E - : ('e' | 'E') - ; - + : ('e' | 'E') + ; fragment F - : ('f' | 'F') - ; - + : ('f' | 'F') + ; fragment G - : ('g' | 'G') - ; - + : ('g' | 'G') + ; fragment H - : ('h' | 'H') - ; - + : ('h' | 'H') + ; fragment I - : ('i' | 'I') - ; - + : ('i' | 'I') + ; fragment J - : ('j' | 'J') - ; - + : ('j' | 'J') + ; fragment K - : ('k' | 'K') - ; - + : ('k' | 'K') + ; fragment L - : ('l' | 'L') - ; - + : ('l' | 'L') + ; fragment M - : ('m' | 'M') - ; - + : ('m' | 'M') + ; fragment N - : ('n' | 'N') - ; - + : ('n' | 'N') + ; fragment O - : ('o' | 'O') - ; - + : ('o' | 'O') + ; fragment P - : ('p' | 'P') - ; - + : ('p' | 'P') + ; fragment Q - : ('q' | 'Q') - ; - + : ('q' | 'Q') + ; fragment R - : ('r' | 'R') - ; - + : ('r' | 'R') + ; fragment S - : ('s' | 'S') - ; - + : ('s' | 'S') + ; fragment T - : ('t' | 'T') - ; - + : ('t' | 'T') + ; fragment U - : ('u' | 'U') - ; - + : ('u' | 'U') + ; fragment V - : ('v' | 'V') - ; - + : ('v' | 'V') + ; fragment W - : ('w' | 'W') - ; - + : ('w' | 'W') + ; fragment X - : ('x' | 'X') - ; - + : ('x' | 'X') + ; fragment Y - : ('y' | 'Y') - ; - + : ('y' | 'Y') + ; fragment Z - : ('z' | 'Z') - ; - + : ('z' | 'Z') + ; STRING - : [a-zA-Z] [a-zA-Z]* - ; - + : [a-zA-Z] [a-zA-Z]* + ; NUMBER - : [0-9] + - ; - + : [0-9]+ + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/plucid/plucid.g4 b/plucid/plucid.g4 index 4e0acce9c6..ccaf09ff7f 100644 --- a/plucid/plucid.g4 +++ b/plucid/plucid.g4 @@ -29,331 +29,335 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar plucid; program - : expression EOF - ; + : expression EOF + ; expression - : constant - | identifier - | 'error' - | 'eod' - | prefix_operator expression - | expression infix_operator expression - | 'filter' (expression ',' expression ',' expression) - | 'substr' (expression ',' expression ',' expression) - | 'length' expression - | 'arg' expression - | list_expression - | if_expression - | case_expression - | cond_expression - | function_call - ; - // | where_clause - - // ; + : constant + | identifier + | 'error' + | 'eod' + | prefix_operator expression + | expression infix_operator expression + | 'filter' (expression ',' expression ',' expression) + | 'substr' (expression ',' expression ',' expression) + | 'length' expression + | 'arg' expression + | list_expression + | if_expression + | case_expression + | cond_expression + | function_call + ; + +// | where_clause + +// ; constant - : numeric_constant - | word_constant - | STRING_CONSTANT - | list_constant - ; + : numeric_constant + | word_constant + | STRING_CONSTANT + | list_constant + ; numeric_constant - : integer_constant - | real_constant - ; + : integer_constant + | real_constant + ; integer_constant - : DIGIT+ - | (N_SIGN integer_constant) - ; + : DIGIT+ + | (N_SIGN integer_constant) + ; real_constant - : integer_constant '.' DIGIT* - ; + : integer_constant '.' DIGIT* + ; word_constant - : QUOTE word_constant_less_the_quotes QUOTE - ; + : QUOTE word_constant_less_the_quotes QUOTE + ; word_constant_less_the_quotes - : (LETTER ALPHANUMERIC*) - | SIGN+ - | BRACKET - | PERIOD - | SEPARATOR - | QUOTE - ; + : (LETTER ALPHANUMERIC*) + | SIGN+ + | BRACKET + | PERIOD + | SEPARATOR + | QUOTE + ; list_constant - : 'nil' - | '[]' - | ('[' list_constant_element* ']') - ; + : 'nil' + | '[]' + | ('[' list_constant_element* ']') + ; list_constant_element - : numeric_constant - | word_constant_less_the_quotes - | STRING_CONSTANT - | list_constant - ; + : numeric_constant + | word_constant_less_the_quotes + | STRING_CONSTANT + | list_constant + ; identifier - : LETTER ALPHANUMERIC* - ; + : LETTER ALPHANUMERIC* + ; prefix_operator - : P_NUMERIC_OPERATOR - | P_WORD_OPERATOR - | P_STRING_OPERATOR - | P_LIST_OPERATOR - | P_LUCID_OPERATOR - | P_SPECIAL_OPERATOR - ; + : P_NUMERIC_OPERATOR + | P_WORD_OPERATOR + | P_STRING_OPERATOR + | P_LIST_OPERATOR + | P_LUCID_OPERATOR + | P_SPECIAL_OPERATOR + ; infix_operator - : I_NUMERIC_OPERATOR - | I_WORD_OPERATOR - | I_STRING_OPERATOR - | I_LIST_OPERATOR - | I_LUCID_OPERATOR - ; + : I_NUMERIC_OPERATOR + | I_WORD_OPERATOR + | I_STRING_OPERATOR + | I_LIST_OPERATOR + | I_LUCID_OPERATOR + ; list_expression - : '[%%]' - | ('[%' expressions_list* '%]') - ; + : '[%%]' + | ('[%' expressions_list* '%]') + ; expressions_list - : expression_item - | (expression_item ',' expressions_list*) - ; + : expression_item + | (expression_item ',' expressions_list*) + ; expression_item - : expression - | list_expression - ; + : expression + | list_expression + ; if_expression - : 'if' expression 'then' expression endif - ; + : 'if' expression 'then' expression endif + ; endif - : 'else' expression 'fi' - | 'elseif' expression 'then' expression 'endif' - ; + : 'else' expression 'fi' + | 'elseif' expression 'then' expression 'endif' + ; case_expression - : 'case' expression 'of' cbody 'end' - ; + : 'case' expression 'of' cbody 'end' + ; cond_expression - : 'cond' cbody 'end' - ; + : 'cond' cbody 'end' + ; cbody - : (expression ':' expression ';')* defaultcase - ; + : (expression ':' expression ';')* defaultcase + ; defaultcase - : 'default' ':' expression - ; + : 'default' ':' expression + ; function_call - : identifier '(' actuals_list ')' - ; + : identifier '(' actuals_list ')' + ; actuals_list - : expression - | (expression ',' actuals_list) - ; + : expression + | (expression ',' actuals_list) + ; where_clause - : expression 'where' body 'end' - ; + : expression 'where' body 'end' + ; body - : declarations_list definitions_list - ; + : declarations_list definitions_list + ; declarations_list - : (current_declaration ';')* - ; + : (current_declaration ';')* + ; current_declaration - : identifier 'is' 'current' expression - ; + : identifier 'is' 'current' expression + ; definitions_list - : (definition ';')* - ; + : (definition ';')* + ; definition - : simple_definition - | function_definition - ; + : simple_definition + | function_definition + ; simple_definition - : identifier '=' expression - ; + : identifier '=' expression + ; function_definition - : identifier (formals_list) '=' expression - ; + : identifier (formals_list) '=' expression + ; formals_list - : identifier - | (identifier ',' formals_list) - ; + : identifier + | (identifier ',' formals_list) + ; N_SIGN - : '˜' - ; + : '˜' + ; SIGN - : '+' - | '-' - | '*' - | '$' - | '&' - | '=' - | '<' - | '>' - | ':' - | '#' - | 'ˆ' - ; + : '+' + | '-' + | '*' + | '$' + | '&' + | '=' + | '<' + | '>' + | ':' + | '#' + | 'ˆ' + ; QUOTE - : '"' - ; + : '"' + ; BRACKET - : '(' - | ')' - | '[%' - | '%]' - | '(%' - | '%)' - ; + : '(' + | ')' + | '[%' + | '%]' + | '(%' + | '%)' + ; PERIOD - : '.' - ; + : '.' + ; SEPARATOR - : ',' - | ';' - ; + : ',' + | ';' + ; STRING_CONSTANT - : '‘' .*? '’' - ; + : '‘' .*? '’' + ; P_NUMERIC_OPERATOR - : 'sin' - | 'cos' - | 'tan' - | 'sqrt' - | 'abs' - | 'log10' - | 'log' - | 'isnumber' - ; + : 'sin' + | 'cos' + | 'tan' + | 'sqrt' + | 'abs' + | 'log10' + | 'log' + | 'isnumber' + ; P_WORD_OPERATOR - : 'isword' - | 'not' - | 'mkstring' - ; + : 'isword' + | 'not' + | 'mkstring' + ; P_STRING_OPERATOR - : 'isstring' - | 'mkword' - ; + : 'isstring' + | 'mkword' + ; P_LIST_OPERATOR - : 'hd' - | 'tl' - | 'isatom' - | 'isnull' - | 'islist' - ; + : 'hd' + | 'tl' + | 'isatom' + | 'isnull' + | 'islist' + ; P_LUCID_OPERATOR - : 'first' - | 'next' - ; + : 'first' + | 'next' + ; P_SPECIAL_OPERATOR - : 'iseod' - | 'iserror' - ; + : 'iseod' + | 'iserror' + ; I_NUMERIC_OPERATOR - : '+' - | '-' - | '**' - | '*' - | 'div' - | 'mod' - | '/' - | 'eq' - | 'ne' - | '<=' - | '<' - | '>' - | '>=' - ; + : '+' + | '-' + | '**' + | '*' + | 'div' + | 'mod' + | '/' + | 'eq' + | 'ne' + | '<=' + | '<' + | '>' + | '>=' + ; I_WORD_OPERATOR - : 'and' - | 'or' - | 'eq' - | 'ne' - ; + : 'and' + | 'or' + | 'eq' + | 'ne' + ; I_STRING_OPERATOR - : 'ˆ' - | 'eq' - | 'ne' - ; + : 'ˆ' + | 'eq' + | 'ne' + ; I_LIST_OPERATOR - : '<>' - | '::' - | 'eq' - | 'ne' - ; + : '<>' + | '::' + | 'eq' + | 'ne' + ; I_LUCID_OPERATOR - : 'fby' - | 'whenever' - | 'wvr' - | 'upon' - | 'asa' - | 'attime' - ; + : 'fby' + | 'whenever' + | 'wvr' + | 'upon' + | 'asa' + | 'attime' + ; ALPHANUMERIC - : DIGIT - | LETTER - ; + : DIGIT + | LETTER + ; DIGIT - : [0-9] - ; + : [0-9] + ; LETTER - : [a-zA-Z] - ; + : [a-zA-Z] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/ply/ply.g4 b/ply/ply.g4 index 4a87968170..15fbaeb646 100644 --- a/ply/ply.g4 +++ b/ply/ply.g4 @@ -30,104 +30,102 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ply; ply - : header vertices? faces? EOF - ; + : header vertices? faces? EOF + ; header - : plydeclaration format_ (element | property_)* end_header - ; + : plydeclaration format_ (element | property_)* end_header + ; end_header - : 'end_header' EOL - ; + : 'end_header' EOL + ; format_ - : 'format' 'ascii 1.0' EOL - ; + : 'format' 'ascii 1.0' EOL + ; element - : 'element' string number EOL - ; + : 'element' string number EOL + ; property_ - : scalarproperty - | listproperty - ; + : scalarproperty + | listproperty + ; scalarproperty - : 'property' type_ string EOL - ; + : 'property' type_ string EOL + ; listproperty - : 'property' 'list' type_ type_ string EOL - ; + : 'property' 'list' type_ type_ string EOL + ; type_ - : 'char' - | 'uchar' - | 'short' - | 'ushort' - | 'int' - | 'uint' - | 'float' - | 'double' - | 'float32' - | 'uint8' - | 'int32' - ; + : 'char' + | 'uchar' + | 'short' + | 'ushort' + | 'int' + | 'uint' + | 'float' + | 'double' + | 'float32' + | 'uint8' + | 'int32' + ; plydeclaration - : 'ply' EOL - ; + : 'ply' EOL + ; vertices - : vertex + - ; + : vertex+ + ; faces - : face + - ; + : face+ + ; vertex - : number number number EOL - ; + : number number number EOL + ; face - : number number number number + EOL - ; + : number number number number+ EOL + ; number - : NUMBER - ; + : NUMBER + ; string - : STRING - ; - + : STRING + ; STRING - : [a-zA-Z] [a-zA-Z0-9_.]* - ; - + : [a-zA-Z] [a-zA-Z0-9_.]* + ; NUMBER - : ('-' | '+')? ('0' .. '9') + ('.' ('0' .. '9') +)? - ; - + : ('-' | '+')? ('0' .. '9')+ ('.' ('0' .. '9')+)? + ; COMMENT - : 'comment' ~ [\r\n]* EOL -> skip - ; - + : 'comment' ~ [\r\n]* EOL -> skip + ; EOL - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : [ \t\r\n] -> skip - ; + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/pmmn/PMMN.g4 b/pmmn/PMMN.g4 index 148f874126..da014da05f 100644 --- a/pmmn/PMMN.g4 +++ b/pmmn/PMMN.g4 @@ -29,50 +29,55 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar PMMN; -file_ : commandlist EOF; +file_ + : commandlist EOF + ; commandlist - : command - | commandlist command - ; + : command + | commandlist command + ; block - : '{' commandlist '}' - ; + : '{' commandlist '}' + ; command - : 'inc' '(' counter ')' ';' - | test ';' - | 'if' '(' test ')' block - | 'if' '(' test ')' block 'else' block - | 'while' '(' test ')' block - ; + : 'inc' '(' counter ')' ';' + | test ';' + | 'if' '(' test ')' block + | 'if' '(' test ')' block 'else' block + | 'while' '(' test ')' block + ; test - : 'dec' '(' counter ')' - ; + : 'dec' '(' counter ')' + ; counter - : DIGIT - | counter DIGIT - ; + : DIGIT + | counter DIGIT + ; DIGIT - : '0' - | '1' - | '2' - | '3' - | '4' - | '5' - | '6' - | '7' - | '8' - | '9' - ; + : '0' + | '1' + | '2' + | '3' + | '4' + | '5' + | '6' + | '7' + | '8' + | '9' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/postalcode/postalcode.g4 b/postalcode/postalcode.g4 index 2b41ad44d7..4839fce9fe 100644 --- a/postalcode/postalcode.g4 +++ b/postalcode/postalcode.g4 @@ -25,21 +25,24 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar postalcode; postalcode - : LETTER DIGIT LETTER DIGIT LETTER DIGIT EOF - ; + : LETTER DIGIT LETTER DIGIT LETTER DIGIT EOF + ; DIGIT - : '0' .. '9' - ; + : '0' .. '9' + ; LETTER - : 'A' .. 'Z' - ; + : 'A' .. 'Z' + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/powerbuilder/PowerBuilderLexer.g4 b/powerbuilder/PowerBuilderLexer.g4 index 36ed960753..0e7a5defff 100644 --- a/powerbuilder/PowerBuilderLexer.g4 +++ b/powerbuilder/PowerBuilderLexer.g4 @@ -26,6 +26,10 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PowerBuilderLexer; options { @@ -33,193 +37,185 @@ options { } // Keywords -ANY: 'ANY'; -BLOB: 'BLOB'; -BOOLEAN: 'BOOLEAN'; -BYTE: 'BYTE'; -CHARACTER: 'CHARACTER'; -CHAR: 'CHAR'; -DATE_TYPE: 'DATE'; -DATETIME: 'DATETIME'; -DECIMAL: 'DECIMAL'; -DEC: 'DEC'; -DOUBLE: 'DOUBLE'; -INTEGER: 'INTEGER'; -INT: 'INT'; -LONG: 'LONG'; -LONGLONG: 'LONGLONG'; -REAL: 'REAL'; -STRING: 'STRING'; -TIME_TYPE: 'TIME'; -UNSIGNEDINTEGER: 'UNSIGNEDINTEGER'; -UINT: 'UINT'; -UNSIGNEDLONG: 'UNSIGNEDLONG'; -ULONG: 'ULONG'; -WINDOW: 'WINDOW'; -TRUE: 'TRUE'; -FALSE: 'FALSE'; -GLOBAL: 'GLOBAL'; -SHARED: 'SHARED'; -END: 'END'; -INDIRECT: 'INDIRECT'; -VARIABLES: 'VARIABLES'; -FORWARD: 'FORWARD'; -PUBLIC: 'PUBLIC'; -PRIVATE: 'PRIVATE'; -FUNCTION: 'FUNCTION'; -SUBROUTINE: 'SUBROUTINE'; -READONLY: 'READONLY'; -PROTOTYPES: 'PROTOTYPES'; -TYPE: 'TYPE'; -ON: 'ON'; -TO: 'TO'; -FROM: 'FROM'; -REF: 'REF'; -NULL_: 'NULL'; -UPDATE: 'UPDATE'; -CASE: 'CASE'; -DYNAMIC: 'DYNAMIC'; -WITHIN: 'WITHIN'; -PRIVATEWRITE: 'PRIVATEWRITE'; -PROTECTED: 'PROTECTED'; -PRIVATEREAD: 'PRIVATEREAD'; -PROTECTEDREAD: 'PROTECTEDREAD'; -PROTECTEDWRITE: 'PROTECTEDWRITE'; -LOCAL: 'LOCAL'; -EVENT: 'EVENT'; -OPEN: 'OPEN'; -GOTO: 'GOTO'; -ELSE: 'ELSE'; -IF: 'IF'; -THEN: 'THEN'; -ELSEIF: 'ELSEIF'; -TRY: 'TRY'; -EXIT: 'EXIT'; -CHOOSE: 'CHOOSE'; -IS: 'IS'; -CONTINUE: 'CONTINUE'; -DO: 'DO'; -WHILE: 'WHILE'; -FOR: 'FOR'; -CLOSE: 'CLOSE'; -NEXT: 'NEXT'; -LOOP: 'LOOP'; -UNTIL: 'UNTIL'; -STEP: 'STEP'; -CATCH: 'CATCH'; -FINALLY: 'FINALLY'; -THROW: 'THROW'; -RELEASE: 'RELEASE'; -CREATE: 'CREATE'; -DESTROY: 'DESTROY'; -USING: 'USING'; -POST: 'POST'; -TRIGGER: 'TRIGGER'; -SELECT: 'SELECT'; -DELETE: 'DELETE'; -INSERT: 'INSERT'; -DESCRIBE: 'DESCRIBE'; -RETURN: 'RETURN'; -OR: 'OR'; -AND: 'AND'; -NOT: 'NOT'; -CALL: 'CALL'; -HALT: 'HALT'; -SUPER: 'SUPER'; -LIBRARY: 'LIBRARY'; -SYSTEM: 'SYSTEM'; -RPCFUNC: 'RPCFUNC'; -ALIAS: 'ALIAS'; -THROWS: 'THROWS'; -AUTOINSTANTIATE: 'AUTOINSTANTIATE'; -DESCRIPTOR: 'DESCRIPTOR'; -SQLCA: 'SQLCA'; -IMMEDIATE: 'IMMEDIATE'; -EXECUTE: 'EXECUTE'; -DECLARE: 'DECLARE'; -PROCEDURE: 'PROCEDURE'; -INTO: 'INTO'; -VALUES: 'VALUES'; -WHERE: 'WHERE'; -COMMIT: 'COMMIT'; -CURSOR: 'CURSOR'; -PREPARE: 'PREPARE'; -FETCH: 'FETCH'; -SET: 'SET'; -CONNECT: 'CONNECT'; -DISCONNECT: 'DISCONNECT'; -CONSTANT: 'CONSTANT'; -SELECTBLOB: 'SELECTBLOB'; -UPDATEBLOB: 'UPDATEBLOB'; -ROLLBACK: 'ROLLBACK'; +ANY : 'ANY'; +BLOB : 'BLOB'; +BOOLEAN : 'BOOLEAN'; +BYTE : 'BYTE'; +CHARACTER : 'CHARACTER'; +CHAR : 'CHAR'; +DATE_TYPE : 'DATE'; +DATETIME : 'DATETIME'; +DECIMAL : 'DECIMAL'; +DEC : 'DEC'; +DOUBLE : 'DOUBLE'; +INTEGER : 'INTEGER'; +INT : 'INT'; +LONG : 'LONG'; +LONGLONG : 'LONGLONG'; +REAL : 'REAL'; +STRING : 'STRING'; +TIME_TYPE : 'TIME'; +UNSIGNEDINTEGER : 'UNSIGNEDINTEGER'; +UINT : 'UINT'; +UNSIGNEDLONG : 'UNSIGNEDLONG'; +ULONG : 'ULONG'; +WINDOW : 'WINDOW'; +TRUE : 'TRUE'; +FALSE : 'FALSE'; +GLOBAL : 'GLOBAL'; +SHARED : 'SHARED'; +END : 'END'; +INDIRECT : 'INDIRECT'; +VARIABLES : 'VARIABLES'; +FORWARD : 'FORWARD'; +PUBLIC : 'PUBLIC'; +PRIVATE : 'PRIVATE'; +FUNCTION : 'FUNCTION'; +SUBROUTINE : 'SUBROUTINE'; +READONLY : 'READONLY'; +PROTOTYPES : 'PROTOTYPES'; +TYPE : 'TYPE'; +ON : 'ON'; +TO : 'TO'; +FROM : 'FROM'; +REF : 'REF'; +NULL_ : 'NULL'; +UPDATE : 'UPDATE'; +CASE : 'CASE'; +DYNAMIC : 'DYNAMIC'; +WITHIN : 'WITHIN'; +PRIVATEWRITE : 'PRIVATEWRITE'; +PROTECTED : 'PROTECTED'; +PRIVATEREAD : 'PRIVATEREAD'; +PROTECTEDREAD : 'PROTECTEDREAD'; +PROTECTEDWRITE : 'PROTECTEDWRITE'; +LOCAL : 'LOCAL'; +EVENT : 'EVENT'; +OPEN : 'OPEN'; +GOTO : 'GOTO'; +ELSE : 'ELSE'; +IF : 'IF'; +THEN : 'THEN'; +ELSEIF : 'ELSEIF'; +TRY : 'TRY'; +EXIT : 'EXIT'; +CHOOSE : 'CHOOSE'; +IS : 'IS'; +CONTINUE : 'CONTINUE'; +DO : 'DO'; +WHILE : 'WHILE'; +FOR : 'FOR'; +CLOSE : 'CLOSE'; +NEXT : 'NEXT'; +LOOP : 'LOOP'; +UNTIL : 'UNTIL'; +STEP : 'STEP'; +CATCH : 'CATCH'; +FINALLY : 'FINALLY'; +THROW : 'THROW'; +RELEASE : 'RELEASE'; +CREATE : 'CREATE'; +DESTROY : 'DESTROY'; +USING : 'USING'; +POST : 'POST'; +TRIGGER : 'TRIGGER'; +SELECT : 'SELECT'; +DELETE : 'DELETE'; +INSERT : 'INSERT'; +DESCRIBE : 'DESCRIBE'; +RETURN : 'RETURN'; +OR : 'OR'; +AND : 'AND'; +NOT : 'NOT'; +CALL : 'CALL'; +HALT : 'HALT'; +SUPER : 'SUPER'; +LIBRARY : 'LIBRARY'; +SYSTEM : 'SYSTEM'; +RPCFUNC : 'RPCFUNC'; +ALIAS : 'ALIAS'; +THROWS : 'THROWS'; +AUTOINSTANTIATE : 'AUTOINSTANTIATE'; +DESCRIPTOR : 'DESCRIPTOR'; +SQLCA : 'SQLCA'; +IMMEDIATE : 'IMMEDIATE'; +EXECUTE : 'EXECUTE'; +DECLARE : 'DECLARE'; +PROCEDURE : 'PROCEDURE'; +INTO : 'INTO'; +VALUES : 'VALUES'; +WHERE : 'WHERE'; +COMMIT : 'COMMIT'; +CURSOR : 'CURSOR'; +PREPARE : 'PREPARE'; +FETCH : 'FETCH'; +SET : 'SET'; +CONNECT : 'CONNECT'; +DISCONNECT : 'DISCONNECT'; +CONSTANT : 'CONSTANT'; +SELECTBLOB : 'SELECTBLOB'; +UPDATEBLOB : 'UPDATEBLOB'; +ROLLBACK : 'ROLLBACK'; // Operators -EQ: '='; -GT: '>'; -GTE: '>='; -LT: '<'; -LTE: '<='; -GTLT: '<>'; -PLUS: '+'; -MINUS: '-'; -PLUSEQ: '+='; -MINUSEQ: '-='; -COLONCOLON: '::'; -MULT: '*'; -DIV: '/'; -MULTEQ: '*='; -DIVEQ: '/='; -CARAT: '^'; -LCURLY: '{'; -RCURLY: '}'; -LBRACE: '['; -RBRACE: ']'; -TICK: '`'; -DQUOTED_STRING: '"' ('~~' | ~'"' | '~"')* '"'; -QUOTED_STRING: '\'' (~'\'' | '~\'')* '\''; -COMMA: ','; -SEMI: ';'; -LPAREN: '('; -RPAREN: ')'; -COLON: ':'; -DQUOTE: '"'; -TQ: '???'; -DOUBLE_PIPE: '||'; -DOTDOTDOT: '...'; -AT: '@'; -UNDERSCORE: '_'; +EQ : '='; +GT : '>'; +GTE : '>='; +LT : '<'; +LTE : '<='; +GTLT : '<>'; +PLUS : '+'; +MINUS : '-'; +PLUSEQ : '+='; +MINUSEQ : '-='; +COLONCOLON : '::'; +MULT : '*'; +DIV : '/'; +MULTEQ : '*='; +DIVEQ : '/='; +CARAT : '^'; +LCURLY : '{'; +RCURLY : '}'; +LBRACE : '['; +RBRACE : ']'; +TICK : '`'; +DQUOTED_STRING : '"' ('~~' | ~'"' | '~"')* '"'; +QUOTED_STRING : '\'' (~'\'' | '~\'')* '\''; +COMMA : ','; +SEMI : ';'; +LPAREN : '('; +RPAREN : ')'; +COLON : ':'; +DQUOTE : '"'; +TQ : '???'; +DOUBLE_PIPE : '||'; +DOTDOTDOT : '...'; +AT : '@'; +UNDERSCORE : '_'; // Literals -NUMBER: (NUM '.' NUM | '.' NUM | NUM) ('E' ('+' | '-')? NUM)? ('D' | 'F')?; -DOT: '.'; -DATE: DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; -TIME: DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT ('.' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT)?; +NUMBER : (NUM '.' NUM | '.' NUM | NUM) ('E' ('+' | '-')? NUM)? ('D' | 'F')?; +DOT : '.'; +DATE : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; +TIME : DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT ('.' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT)?; -ENUM: ID_PARTS '!'; -ID: ID_PARTS; +ENUM : ID_PARTS '!'; +ID : ID_PARTS; // Hidden -EXPORT_HEADER: 'HA'? '$' ~[\r\n]* -> channel(HIDDEN); -LINE_CONTINUATION: '&' WS* [\r\n] -> channel(HIDDEN); -SL_COMMENT: '//' ~ [\r\n]* -> channel(HIDDEN); -ML_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -WS: [ \t\r\n]+ -> channel(HIDDEN); +EXPORT_HEADER : 'HA'? '$' ~[\r\n]* -> channel(HIDDEN); +LINE_CONTINUATION : '&' WS* [\r\n] -> channel(HIDDEN); +SL_COMMENT : '//' ~ [\r\n]* -> channel(HIDDEN); +ML_COMMENT : '/*' .*? '*/' -> channel(HIDDEN); +WS : [ \t\r\n]+ -> channel(HIDDEN); // Fragments -fragment ID_PARTS - : [A-Z] ([A-Z] | DIGIT | '-' | '$' | '#' | '%' | '_')* - ; +fragment ID_PARTS: [A-Z] ([A-Z] | DIGIT | '-' | '$' | '#' | '%' | '_')*; -fragment NUM - : DIGIT+ - ; +fragment NUM: DIGIT+; -fragment DIGIT - : '0' .. '9' - ; +fragment DIGIT: '0' .. '9'; -fragment LETTER - : 'A' .. 'Z' - ; \ No newline at end of file +fragment LETTER: 'A' .. 'Z'; \ No newline at end of file diff --git a/powerbuilder/PowerBuilderParser.g4 b/powerbuilder/PowerBuilderParser.g4 index 3e7a4ec760..824344a5e3 100644 --- a/powerbuilder/PowerBuilderParser.g4 +++ b/powerbuilder/PowerBuilderParser.g4 @@ -26,668 +26,696 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 PowerBuilderParser; -options { tokenVocab = PowerBuilderLexer; } +options { + tokenVocab = PowerBuilderLexer; +} start_rule - : (RELEASE NUMBER SEMI)? body_rule+ EOF - ; + : (RELEASE NUMBER SEMI)? body_rule+ EOF + ; body_rule - : datatype_decl - | access_modif - | forward_decl - | type_variables_decl - | global_variables_decl - | variable_decl - | constant_decl - | function_forward_decl - | functions_forward_decl - | function_body - | on_body - | event_body - ; + : datatype_decl + | access_modif + | forward_decl + | type_variables_decl + | global_variables_decl + | variable_decl + | constant_decl + | function_forward_decl + | functions_forward_decl + | function_body + | on_body + | event_body + ; forward_decl - : FORWARD (datatype_decl | variable_decl | global_variables_decl)+ END FORWARD - ; + : FORWARD (datatype_decl | variable_decl | global_variables_decl)+ END FORWARD + ; datatype_decl - : scope_modif? TYPE identifier_name FROM (identifier_name TICK)? data_type_name - (WITHIN identifier_name)? AUTOINSTANTIATE? (DESCRIPTOR DQUOTED_STRING EQ DQUOTED_STRING)? - (variable_decl | event_forward_decl)* - END TYPE - ; + : scope_modif? TYPE identifier_name FROM (identifier_name TICK)? data_type_name ( + WITHIN identifier_name + )? AUTOINSTANTIATE? (DESCRIPTOR DQUOTED_STRING EQ DQUOTED_STRING)? ( + variable_decl + | event_forward_decl + )* END TYPE + ; type_variables_decl - : TYPE VARIABLES (variable_decl | constant_decl | public_statement)* END VARIABLES - ; + : TYPE VARIABLES (variable_decl | constant_decl | public_statement)* END VARIABLES + ; global_variables_decl - : GLOBAL variable_decl - | (GLOBAL | SHARED) VARIABLES variable_decl* END VARIABLES - ; + : GLOBAL variable_decl + | (GLOBAL | SHARED) VARIABLES variable_decl* END VARIABLES + ; variable_decl - : access_type? variable_decl_sub SEMI? - ; + : access_type? variable_decl_sub SEMI? + ; variable_decl_sub - : INDIRECT? access_modif_part? scope_modif? (variable_decl_sub0 | variable_decl_sub1 | variable_decl_sub2 | variable_decl_event) - ; + : INDIRECT? access_modif_part? scope_modif? ( + variable_decl_sub0 + | variable_decl_sub1 + | variable_decl_sub2 + | variable_decl_event + ) + ; variable_decl_sub0 - : data_type_name decimal_decl_sub? variable_name (COMMA variable_name)* (EQ assignment_rhs)? - ; + : data_type_name decimal_decl_sub? variable_name (COMMA variable_name)* (EQ assignment_rhs)? + ; variable_decl_sub1 - : data_type_name assignment_statement (COMMA data_type_name? assignment_statement)* - ; + : data_type_name assignment_statement (COMMA data_type_name? assignment_statement)* + ; variable_decl_sub2 - : data_type_name decimal_decl_sub? identifier_name_ex array_decl_sub? (EQ? LCURLY expression_list RCURLY)? - ; + : data_type_name decimal_decl_sub? identifier_name_ex array_decl_sub? ( + EQ? LCURLY expression_list RCURLY + )? + ; variable_decl_event - : EVENT identifier (LPAREN expression_list RPAREN)? - ; + : EVENT identifier (LPAREN expression_list RPAREN)? + ; decimal_decl_sub - : LCURLY NUMBER RCURLY - ; + : LCURLY NUMBER RCURLY + ; array_decl_sub - : LBRACE ((PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)? (COMMA (PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)?)*)? RBRACE - ; + : LBRACE ( + (PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)? ( + COMMA (PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)? + )* + )? RBRACE + ; constant_decl_sub - : access_type? CONSTANT variable_decl_sub - ; + : access_type? CONSTANT variable_decl_sub + ; constant_decl - : constant_decl_sub SEMI? - ; + : constant_decl_sub SEMI? + ; function_forward_decl - : access_modif_part? scope_modif? (FUNCTION data_type_name | SUBROUTINE) - identifier_name LPAREN parameters_list_sub? RPAREN - function_forward_decl_alias? - ; + : access_modif_part? scope_modif? (FUNCTION data_type_name | SUBROUTINE) identifier_name LPAREN parameters_list_sub? RPAREN + function_forward_decl_alias? + ; function_forward_decl_alias - : ALIAS FOR identifier_name LIBRARY (DQUOTED_STRING | QUOTED_STRING) - | LIBRARY (DQUOTED_STRING | QUOTED_STRING) (ALIAS FOR (DQUOTED_STRING | QUOTED_STRING))? - | RPCFUNC ALIAS FOR (DQUOTED_STRING | QUOTED_STRING)? (THROWS identifier_name)? - | THROWS identifier_name - ; + : ALIAS FOR identifier_name LIBRARY (DQUOTED_STRING | QUOTED_STRING) + | LIBRARY (DQUOTED_STRING | QUOTED_STRING) (ALIAS FOR (DQUOTED_STRING | QUOTED_STRING))? + | RPCFUNC ALIAS FOR (DQUOTED_STRING | QUOTED_STRING)? (THROWS identifier_name)? + | THROWS identifier_name + ; parameter_sub - : READONLY? REF? data_type_name decimal_decl_sub? identifier_name array_decl_sub? - ; + : READONLY? REF? data_type_name decimal_decl_sub? identifier_name array_decl_sub? + ; parameters_list_sub - : parameter_sub (COMMA parameter_sub)* (COMMA DOTDOTDOT)? - ; + : parameter_sub (COMMA parameter_sub)* (COMMA DOTDOTDOT)? + ; functions_forward_decl - : (FORWARD | TYPE) PROTOTYPES function_forward_decl* END PROTOTYPES - ; + : (FORWARD | TYPE) PROTOTYPES function_forward_decl* END PROTOTYPES + ; function_body - : access_type? scope_modif? (FUNCTION data_type_name | SUBROUTINE) identifier_name LPAREN parameters_list_sub? RPAREN - (THROWS identifier_name)? - SEMI? (statement SEMI?)* END (FUNCTION | SUBROUTINE) - ; + : access_type? scope_modif? (FUNCTION data_type_name | SUBROUTINE) identifier_name LPAREN parameters_list_sub? RPAREN ( + THROWS identifier_name + )? SEMI? (statement SEMI?)* END (FUNCTION | SUBROUTINE) + ; on_body - : ON identifier (DOT (CREATE | DESTROY) | OPEN | CLOSE)? SEMI? (statement SEMI?)* END ON - ; + : ON identifier (DOT (CREATE | DESTROY) | OPEN | CLOSE)? SEMI? (statement SEMI?)* END ON + ; event_forward_decl - : EVENT ( (identifier_name | CREATE | DESTROY) identifier_name? (LPAREN parameters_list_sub? RPAREN)? - | TYPE data_type_name identifier_name (LPAREN parameters_list_sub? RPAREN) - ) - ; + : EVENT ( + (identifier_name | CREATE | DESTROY) identifier_name? (LPAREN parameters_list_sub? RPAREN)? + | TYPE data_type_name identifier_name (LPAREN parameters_list_sub? RPAREN) + ) + ; event_body - : EVENT (TYPE data_type_name)? (identifier_name COLONCOLON)? (identifier_name | OPEN | CLOSE) - (LPAREN parameters_list_sub? RPAREN)? SEMI? (statement SEMI?)* - END EVENT - ; + : EVENT (TYPE data_type_name)? (identifier_name COLONCOLON)? (identifier_name | OPEN | CLOSE) ( + LPAREN parameters_list_sub? RPAREN + )? SEMI? (statement SEMI?)* END EVENT + ; access_type - : PUBLIC - | PRIVATE - | PROTECTED - ; + : PUBLIC + | PRIVATE + | PROTECTED + ; access_modif - : access_type ':' - ; + : access_type ':' + ; access_modif_part - : PUBLIC - | PRIVATE - | PRIVATEREAD - | PRIVATEWRITE - | PROTECTED - | PROTECTEDREAD - | PROTECTEDWRITE - ; + : PUBLIC + | PRIVATE + | PRIVATEREAD + | PRIVATEWRITE + | PROTECTED + | PROTECTEDREAD + | PROTECTEDWRITE + ; scope_modif - : GLOBAL - | LOCAL - ; + : GLOBAL + | LOCAL + ; expression - : close_call_sub - | value - | function_call_statement - | LCURLY expression (COMMA expression)* RCURLY - | expression (PLUS | MINUS | MULT | DIV | CARAT) expression - | LPAREN expression RPAREN - | boolean_expression - ; + : close_call_sub + | value + | function_call_statement + | LCURLY expression (COMMA expression)* RCURLY + | expression (PLUS | MINUS | MULT | DIV | CARAT) expression + | LPAREN expression RPAREN + | boolean_expression + ; value - : string_literal (PLUS string_literal)* - | ENUM - | NUMBER - | TRUE - | FALSE - | DATE - | TIME - ; + : string_literal (PLUS string_literal)* + | ENUM + | NUMBER + | TRUE + | FALSE + | DATE + | TIME + ; expression_list - : REF? expression (COMMA REF? expression)* - ; + : REF? expression (COMMA REF? expression)* + ; boolean_expression - : unary_sign_expr - | mul_expr - | add_expr - | condition_or - | LPAREN boolean_expression RPAREN - ; + : unary_sign_expr + | mul_expr + | add_expr + | condition_or + | LPAREN boolean_expression RPAREN + ; condition_or - : condition_and (OR condition_and)* - | LPAREN boolean_expression RPAREN - ; + : condition_and (OR condition_and)* + | LPAREN boolean_expression RPAREN + ; condition_and - : condition_not (AND condition_not)* - | LPAREN boolean_expression RPAREN - ; + : condition_not (AND condition_not)* + | LPAREN boolean_expression RPAREN + ; condition_not - : NOT? condition_comparison - | LPAREN boolean_expression RPAREN - ; + : NOT? condition_comparison + | LPAREN boolean_expression RPAREN + ; condition_comparison - : add_expr ((EQ | GT | LT | GTLT | GTE | LTE) add_expr)? - | LPAREN boolean_expression RPAREN - ; + : add_expr ((EQ | GT | LT | GTLT | GTE | LTE) add_expr)? + | LPAREN boolean_expression RPAREN + ; add_expr - : mul_expr ((MINUS | PLUS) mul_expr)* - | LPAREN boolean_expression RPAREN - ; + : mul_expr ((MINUS | PLUS) mul_expr)* + | LPAREN boolean_expression RPAREN + ; mul_expr - : unary_sign_expr ((MULT | DIV | CARAT) unary_sign_expr)* - | LPAREN boolean_expression RPAREN - ; + : unary_sign_expr ((MULT | DIV | CARAT) unary_sign_expr)* + | LPAREN boolean_expression RPAREN + ; unary_sign_expr - : ENUM - | (MINUS | PLUS)? (variable_name | bind_param | value) - | function_call_statement - | LCURLY function_call_statement RCURLY - | LPAREN unary_sign_expr RPAREN - | set_value - ; + : ENUM + | (MINUS | PLUS)? (variable_name | bind_param | value) + | function_call_statement + | LCURLY function_call_statement RCURLY + | LPAREN unary_sign_expr RPAREN + | set_value + ; statement - : increment_decrement_statement - | public_statement - | if_simple_statement - | execute_statement - | throw_statement - | DESCRIBE identifier_name - | assignment_statement - | try_catch_statement - | close_sql_statement - | statement_sub - | if_statement - | post_event - | function_call_statement - | super_call_statement - | event_call_statement - | declare_procedure_statement - | constant_decl - | variable_decl - | super_call_statement - | do_loop_while_statement - | do_while_loop_statement - | create_call_statement - | destroy_call_statement - | label_stat - | throw_statement - | goto_statement - | choose_statement - | return_statement - | for_loop_statement - | continue_statement - | exit_statement - | sql_statement - | sql_commit_statement - | open_cursor_statement - | prepare_sql_stateent - | declare_cursor_statement - | close_cursor_statement - | fetch_into_statement - | call_statement - ; + : increment_decrement_statement + | public_statement + | if_simple_statement + | execute_statement + | throw_statement + | DESCRIBE identifier_name + | assignment_statement + | try_catch_statement + | close_sql_statement + | statement_sub + | if_statement + | post_event + | function_call_statement + | super_call_statement + | event_call_statement + | declare_procedure_statement + | constant_decl + | variable_decl + | super_call_statement + | do_loop_while_statement + | do_while_loop_statement + | create_call_statement + | destroy_call_statement + | label_stat + | throw_statement + | goto_statement + | choose_statement + | return_statement + | for_loop_statement + | continue_statement + | exit_statement + | sql_statement + | sql_commit_statement + | open_cursor_statement + | prepare_sql_stateent + | declare_cursor_statement + | close_cursor_statement + | fetch_into_statement + | call_statement + ; public_statement - : (PUBLIC | PROTECTED | PRIVATE) COLON - ; + : (PUBLIC | PROTECTED | PRIVATE) COLON + ; -throw_statement : THROW expression; +throw_statement + : THROW expression + ; goto_statement - : GOTO variable_name (statement SEMI?)* variable_name COLON (statement SEMI?)* - ; + : GOTO variable_name (statement SEMI?)* variable_name COLON (statement SEMI?)* + ; statement_sub - : function_virtual_call_expression_sub - | function_call_expression_sub - | return_statement - | open_call_sub - | close_call_sub - | variable_decl_sub - | super_call_statement - | create_call_sub - | destroy_call_sub - | continue_sub - | assignment_statement - ; + : function_virtual_call_expression_sub + | function_call_expression_sub + | return_statement + | open_call_sub + | close_call_sub + | variable_decl_sub + | super_call_statement + | create_call_sub + | destroy_call_sub + | continue_sub + | assignment_statement + ; try_catch_statement - : TRY - (statement SEMI?)* - ( - CATCH LPAREN variable_decl_sub RPAREN - (statement SEMI?)* - )* - ( - FINALLY - (statement SEMI?)* - )? - END TRY + : TRY (statement SEMI?)* (CATCH LPAREN variable_decl_sub RPAREN (statement SEMI?)*)* ( + FINALLY (statement SEMI?)* + )? END TRY ; sql_statement - : sql_insert_statement - | sql_delete_statement - | sql_select_statement - | sql_update_statement - | sql_connect_statement - ; + : sql_insert_statement + | sql_delete_statement + | sql_select_statement + | sql_update_statement + | sql_connect_statement + ; sql_insert_statement - : INSERT INTO variable_name LPAREN variable_name (COMMA variable_name)* RPAREN VALUES LPAREN sql_values (COMMA sql_values)* RPAREN SEMI? - ; + : INSERT INTO variable_name LPAREN variable_name (COMMA variable_name)* RPAREN VALUES LPAREN sql_values ( + COMMA sql_values + )* RPAREN SEMI? + ; sql_values - : value - | bind_param - ; + : value + | bind_param + ; sql_delete_statement - : DELETE FROM variable_name where_clause SEMI? - ; + : DELETE FROM variable_name where_clause SEMI? + ; sql_select_statement - : (SELECT | SELECTBLOB) select_clause INTO bind_param (COMMA bind_param)* FROM variable_name (COMMA variable_name)* - where_clause? (USING variable_name)? SEMI? - ; + : (SELECT | SELECTBLOB) select_clause INTO bind_param (COMMA bind_param)* FROM variable_name ( + COMMA variable_name + )* where_clause? (USING variable_name)? SEMI? + ; sql_update_statement - : (UPDATE | UPDATEBLOB) variable_name SET set_value (COMMA set_value)* where_clause? - ; + : (UPDATE | UPDATEBLOB) variable_name SET set_value (COMMA set_value)* where_clause? + ; - sql_connect_statement - : (CONNECT | DISCONNECT | ROLLBACK) (USING (SQLCA | identifier_name))? SEMI - ; +sql_connect_statement + : (CONNECT | DISCONNECT | ROLLBACK) (USING (SQLCA | identifier_name))? SEMI + ; set_value - : variable_name (EQ bind_param | IS NOT? NULL_) - ; + : variable_name (EQ bind_param | IS NOT? NULL_) + ; where_clause - : WHERE (set_value (COMMA set_value)* | condition_or) - ; + : WHERE (set_value (COMMA set_value)* | condition_or) + ; select_clause - : variable_name (COMMA variable_name)* - | function_call_statement - ; + : variable_name (COMMA variable_name)* + | function_call_statement + ; sql_commit_statement - : COMMIT USING? (SQLCA | variable_name)? SEMI? - ; + : COMMIT USING? (SQLCA | variable_name)? SEMI? + ; execute_statement - : EXECUTE (IMMEDIATE? ((variable_name | value) SEMI? | bind_param (USING (SQLCA | variable_name))? SEMI) | - DYNAMIC? identifier (USING DESCRIPTOR? (SQLCA | identifier))? SEMI?) - ; + : EXECUTE ( + IMMEDIATE? ( + (variable_name | value) SEMI? + | bind_param (USING (SQLCA | variable_name))? SEMI + ) + | DYNAMIC? identifier (USING DESCRIPTOR? (SQLCA | identifier))? SEMI? + ) + ; close_sql_statement - : CLOSE variable_name SEMI - ; + : CLOSE variable_name SEMI + ; declare_procedure_statement - : DECLARE variable_name DYNAMIC? PROCEDURE FOR variable_name SEMI? - ; + : DECLARE variable_name DYNAMIC? PROCEDURE FOR variable_name SEMI? + ; declare_cursor_statement - : DECLARE variable_name DYNAMIC? CURSOR FOR variable_name SEMI - ; + : DECLARE variable_name DYNAMIC? CURSOR FOR variable_name SEMI + ; open_cursor_statement - : OPEN DYNAMIC? variable_name (USING (DESCRIPTOR | identifier))? identifier? SEMI? - ; + : OPEN DYNAMIC? variable_name (USING (DESCRIPTOR | identifier))? identifier? SEMI? + ; close_cursor_statement - : CLOSE variable_name - ; + : CLOSE variable_name + ; fetch_into_statement - : FETCH (variable_name INTO bind_param | identifier USING DESCRIPTOR? identifier) SEMI? - ; + : FETCH (variable_name INTO bind_param | identifier USING DESCRIPTOR? identifier) SEMI? + ; prepare_sql_stateent - : PREPARE variable_name FROM bind_param USING (SQLCA | identifier_name) SEMI - ; + : PREPARE variable_name FROM bind_param USING (SQLCA | identifier_name) SEMI + ; increment_decrement_statement - : variable_name (PLUS PLUS | MINUS MINUS) - ; + : variable_name (PLUS PLUS | MINUS MINUS) + ; assignment_rhs - : value - | expression (COMMA expression)* - | function_call_statement - | describe_function_call - | create_call_statement - | super_call_statement - | event_call_statement - ; + : value + | expression (COMMA expression)* + | function_call_statement + | describe_function_call + | create_call_statement + | super_call_statement + | event_call_statement + ; describe_function_call - : (identifier DOT)? DESCRIBE LPAREN expression_list? RPAREN - | DESCRIBE identifier INTO identifier - ; + : (identifier DOT)? DESCRIBE LPAREN expression_list? RPAREN + | DESCRIBE identifier INTO identifier + ; assignment_statement - : AT variable_name EQ bind_param SEMI - | (function_call_statement DOT)? variable_name (EQ | PLUSEQ | MINUSEQ | MULTEQ | DIVEQ) assignment_rhs SEMI? - ; + : AT variable_name EQ bind_param SEMI + | (function_call_statement DOT)? variable_name (EQ | PLUSEQ | MINUSEQ | MULTEQ | DIVEQ) assignment_rhs SEMI? + ; variable_name - : identifier - ; + : identifier + ; return_statement - : RETURN (expression)? - ; + : RETURN (expression)? + ; function_call_expression_sub - : (variable_name DOT)* FUNCTION? POST? DYNAMIC? EVENT? function_name LPAREN expression_list? RPAREN - (DOT (variable_name | function_call_expression_sub))* - ; + : (variable_name DOT)* FUNCTION? POST? DYNAMIC? EVENT? function_name LPAREN expression_list? RPAREN ( + DOT (variable_name | function_call_expression_sub) + )* + ; function_name - : POST - | OPEN - | CLOSE - | variable_name - | dataTypeSub - ; + : POST + | OPEN + | CLOSE + | variable_name + | dataTypeSub + ; function_event_call - : function_name DOT EVENT? POST? DYNAMIC? function_call_expression_sub - ; + : function_name DOT EVENT? POST? DYNAMIC? function_call_expression_sub + ; function_virtual_call_expression_sub - : identifier DOT (TRIGGER EVENT | DYNAMIC EVENT? | EVENT TRIGGER? DYNAMIC) function_call_expression_sub - ; + : identifier DOT (TRIGGER EVENT | DYNAMIC EVENT? | EVENT TRIGGER? DYNAMIC) function_call_expression_sub + ; open_call_sub - : OPEN LPAREN expression_list RPAREN - ; + : OPEN LPAREN expression_list RPAREN + ; close_call_sub - : CLOSE LPAREN expression_list RPAREN - | HALT CLOSE? - ; + : CLOSE LPAREN expression_list RPAREN + | HALT CLOSE? + ; function_call_statement - : function_call_expression_sub - | ancestor_function_call - | describe_function_call - | ancestor_event_call_statement - | function_event_call - | function_virtual_call_expression_sub - | open_call_sub - | close_call_sub - ; + : function_call_expression_sub + | ancestor_function_call + | describe_function_call + | ancestor_event_call_statement + | function_event_call + | function_virtual_call_expression_sub + | open_call_sub + | close_call_sub + ; ancestor_function_call - : COLONCOLON function_call_expression_sub - ; + : COLONCOLON function_call_expression_sub + ; call_statement - : CALL variable_name (COLONCOLON (CREATE | DESTROY | OPEN | CLOSE | identifier))? SEMI? - ; + : CALL variable_name (COLONCOLON (CREATE | DESTROY | OPEN | CLOSE | identifier))? SEMI? + ; super_call_statement - : CALL (identifier_name TICK)? (atom_sub_call1 | atom_sub_member1) - | CALL SUPER COLONCOLON (EVENT | CREATE | DESTROY | OPEN | CLOSE | identifier) function_call_statement? - | SUPER COLONCOLON (EVENT | FUNCTION)? POST? function_call_statement - ; + : CALL (identifier_name TICK)? (atom_sub_call1 | atom_sub_member1) + | CALL SUPER COLONCOLON (EVENT | CREATE | DESTROY | OPEN | CLOSE | identifier) function_call_statement? + | SUPER COLONCOLON (EVENT | FUNCTION)? POST? function_call_statement + ; ancestor_event_call_statement - : (identifier_name DOT)? identifier_name COLONCOLON (EVENT | FUNCTION)? (TRIGGER | POST)? function_call_statement - ; + : (identifier_name DOT)? identifier_name COLONCOLON (EVENT | FUNCTION)? (TRIGGER | POST)? function_call_statement + ; event_call_statement_sub - : variable_name? EVENT function_call_statement? - ; + : variable_name? EVENT function_call_statement? + ; event_call_statement - : event_call_statement_sub - ; + : event_call_statement_sub + ; create_call_sub - : CREATE (USING expression | USING? (identifier_name DOT)? data_type_name (LPAREN expression_list? RPAREN)?) - ; + : CREATE ( + USING expression + | USING? (identifier_name DOT)? data_type_name (LPAREN expression_list? RPAREN)? + ) + ; create_call_statement - : create_call_sub - ; + : create_call_sub + ; destroy_call_sub - : DESTROY expression - ; + : DESTROY expression + ; destroy_call_statement - : destroy_call_sub - ; + : destroy_call_sub + ; for_loop_statement - : FOR variable_name EQ expression TO expression (STEP expression)? statement* (NEXT | END FOR) - ; + : FOR variable_name EQ expression TO expression (STEP expression)? statement* (NEXT | END FOR) + ; do_while_loop_statement - : DO (WHILE | UNTIL) boolean_expression (statement SEMI?)* LOOP - ; + : DO (WHILE | UNTIL) boolean_expression (statement SEMI?)* LOOP + ; do_loop_while_statement - : DO statement* LOOP (WHILE | UNTIL) boolean_expression - ; + : DO statement* LOOP (WHILE | UNTIL) boolean_expression + ; if_statement - : IF boolean_expression THEN (statement SEMI?)* elseif_statement* else_statement? END IF SEMI? - ; + : IF boolean_expression THEN (statement SEMI?)* elseif_statement* else_statement? END IF SEMI? + ; elseif_statement - : ELSEIF boolean_expression THEN (statement SEMI?)* - ; + : ELSEIF boolean_expression THEN (statement SEMI?)* + ; else_statement - : ELSE (statement SEMI?)* - ; + : ELSE (statement SEMI?)* + ; if_simple_statement - : IF boolean_expression THEN statement (ELSE statement)? SEMI? - ; + : IF boolean_expression THEN statement (ELSE statement)? SEMI? + ; continue_statement - : CONTINUE - ; + : CONTINUE + ; continue_sub - : CONTINUE - ; + : CONTINUE + ; post_event - : (atom_sub_member1 DOT)? (POST | TRIGGER) EVENT? identifier_name_ex LPAREN expression_list? RPAREN - ; + : (atom_sub_member1 DOT)? (POST | TRIGGER) EVENT? identifier_name_ex LPAREN expression_list? RPAREN + ; exit_statement - : EXIT - ; + : EXIT + ; choose_statement - : CHOOSE CASE expression (choose_case_cond_sub - | choose_case_else_sub - | choose_case_value_sub)+ - END CHOOSE - ; + : CHOOSE CASE expression (choose_case_cond_sub | choose_case_else_sub | choose_case_value_sub)+ END CHOOSE + ; choose_case_value_sub - : CASE expression (TO expression)? (COMMA expression (TO expression)?)* (statement SEMI?)* - ; + : CASE expression (TO expression)? (COMMA expression (TO expression)?)* (statement SEMI?)* + ; choose_case_cond_sub - : CASE IS (EQ | GT | LT | GTLT | GTE | LTE) expression (statement SEMI?)* - ; + : CASE IS (EQ | GT | LT | GTLT | GTE | LTE) expression (statement SEMI?)* + ; choose_case_else_sub - : CASE ELSE (statement SEMI?)* - ; + : CASE ELSE (statement SEMI?)* + ; label_stat - : identifier_name COLON - ; + : identifier_name COLON + ; identifier - : identifier_name_ex (DOT identifier_name_ex)* (identifier_array)? (DOT identifier_name_ex (identifier_array)?)* - ; + : identifier_name_ex (DOT identifier_name_ex)* (identifier_array)? ( + DOT identifier_name_ex (identifier_array)? + )* + ; string_literal - : (DQUOTED_STRING | QUOTED_STRING) (PLUS (variable_name | DQUOTED_STRING | QUOTED_STRING))* - ; + : (DQUOTED_STRING | QUOTED_STRING) (PLUS (variable_name | DQUOTED_STRING | QUOTED_STRING))* + ; identifier_array - : LBRACE ( (identifier | value) (COMMA (identifier | value))* - | (identifier | function_call_statement) (operator? NUMBER)? - | operator? NUMBER - )? - RBRACE - ; + : LBRACE ( + (identifier | value) (COMMA (identifier | value))* + | (identifier | function_call_statement) (operator? NUMBER)? + | operator? NUMBER + )? RBRACE + ; -operator: PLUS | MINUS | MULT | DIV; +operator + : PLUS + | MINUS + | MULT + | DIV + ; identifier_name_ex - : identifier_name - | SELECT - | TYPE - | UPDATE - | DELETE - | OPEN - | CLOSE - | GOTO - | INSERT - | TIME_TYPE - | READONLY - | SQLCA - | CREATE - | VALUES - | WINDOW - | SYSTEM - | DATE_TYPE - ; + : identifier_name + | SELECT + | TYPE + | UPDATE + | DELETE + | OPEN + | CLOSE + | GOTO + | INSERT + | TIME_TYPE + | READONLY + | SQLCA + | CREATE + | VALUES + | WINDOW + | SYSTEM + | DATE_TYPE + ; identifier_name - : UNDERSCORE? ID - ; + : UNDERSCORE? ID + ; bind_param - : COLON identifier - ; + : COLON identifier + ; atom_sub - : array_access_atom - | identifier_name (LPAREN expression_list? RPAREN)? - ; + : array_access_atom + | identifier_name (LPAREN expression_list? RPAREN)? + ; atom_sub_call1 - : (identifier | DESCRIBE) LPAREN expression_list? RPAREN - ; + : (identifier | DESCRIBE) LPAREN expression_list? RPAREN + ; atom_sub_member1 - : identifier - ; + : identifier + ; array_access_atom - : identifier_name LBRACE expression_list RBRACE - ; + : identifier_name LBRACE expression_list RBRACE + ; data_type_name - : dataTypeSub - | identifier_name - ; + : dataTypeSub + | identifier_name + ; dataTypeSub - : ANY - | BLOB - | BOOLEAN - | BYTE - | CHARACTER - | CHAR - | DATE_TYPE - | DATETIME - | DECIMAL - | DEC - | DOUBLE - | INTEGER - | INT - | LONG - | LONGLONG - | REAL - | STRING - | TIME_TYPE - | UNSIGNEDINTEGER - | UINT - | UNSIGNEDLONG - | ULONG - | WINDOW - ; + : ANY + | BLOB + | BOOLEAN + | BYTE + | CHARACTER + | CHAR + | DATE_TYPE + | DATETIME + | DECIMAL + | DEC + | DOUBLE + | INTEGER + | INT + | LONG + | LONGLONG + | REAL + | STRING + | TIME_TYPE + | UNSIGNEDINTEGER + | UINT + | UNSIGNEDLONG + | ULONG + | WINDOW + ; \ No newline at end of file diff --git a/powerbuilderdw/PowerBuilderDWLexer.g4 b/powerbuilderdw/PowerBuilderDWLexer.g4 index d6283e480b..0d3e505fc5 100644 --- a/powerbuilderdw/PowerBuilderDWLexer.g4 +++ b/powerbuilderdw/PowerBuilderDWLexer.g4 @@ -26,6 +26,10 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PowerBuilderDWLexer; options { @@ -33,187 +37,179 @@ options { } // Keywords -TABLE: 'TABLE'; -COLUMN: 'COLUMN'; -RETRIEVE: 'RETRIEVE'; -PBSELECT: 'PBSELECT'; -VERSION: 'VERSION'; -ARGUMENTS: 'ARGUMENTS'; -SORT: 'SORT'; -ANY: 'ANY'; -BLOB: 'BLOB'; -BOOLEAN: 'BOOLEAN'; -BYTE: 'BYTE'; -CHARACTER: 'CHARACTER'; -CHAR: 'CHAR'; -DATE_TYPE: 'DATE'; -DATETIME: 'DATETIME'; -DECIMAL: 'DECIMAL'; -DEC: 'DEC'; -DOUBLE: 'DOUBLE'; -INTEGER: 'INTEGER'; -INT: 'INT'; -LONG: 'LONG'; -LONGLONG: 'LONGLONG'; -REAL: 'REAL'; -STRING: 'STRING'; -TIME_TYPE: 'TIME'; -UNSIGNEDINTEGER: 'UNSIGNEDINTEGER'; -UINT: 'UINT'; -UNSIGNEDLONG: 'UNSIGNEDLONG'; -ULONG: 'ULONG'; -WINDOW: 'WINDOW'; -TRUE: 'TRUE'; -FALSE: 'FALSE'; -GLOBAL: 'GLOBAL'; -SHARED: 'SHARED'; -END: 'END'; -INDIRECT : 'INDIRECT'; -VARIABLES: 'VARIABLES'; -FORWARD: 'FORWARD'; -PUBLIC: 'PUBLIC'; -PRIVATE: 'PRIVATE'; -FUNCTION: 'FUNCTION'; -SUBROUTINE: 'SUBROUTINE'; -READONLY: 'READONLY'; -PROTOTYPES: 'PROTOTYPES'; -TYPE: 'TYPE'; -ON: 'ON'; -TO: 'TO'; -FROM: 'FROM'; -REF: 'REF'; -NULL_: 'NULL'; -UPDATE: 'UPDATE'; -CASE: 'CASE'; -DYNAMIC: 'DYNAMIC'; -WITHIN: 'WITHIN'; -PRIVATEWRITE: 'PRIVATEWRITE'; -PROTECTED: 'PROTECTED'; -PRIVATEREAD: 'PRIVATEREAD'; -PROTECTEDREAD: 'PROTECTEDREAD'; -PROTECTEDWRITE: 'PROTECTEDWRITE'; -LOCAL: 'LOCAL'; -EVENT: 'EVENT'; -OPEN: 'OPEN'; -GOTO: 'GOTO'; -ELSE: 'ELSE'; -IF: 'IF'; -THEN: 'THEN'; -ELSEIF: 'ELSEIF'; -TRY: 'TRY'; -EXIT: 'EXIT'; -CHOOSE: 'CHOOSE'; -IS: 'IS'; -CONTINUE: 'CONTINUE'; -DO: 'DO'; -WHILE: 'WHILE'; -FOR: 'FOR'; -CLOSE: 'CLOSE'; -NEXT: 'NEXT'; -LOOP: 'LOOP'; -UNTIL: 'UNTIL'; -STEP: 'STEP'; -CATCH: 'CATCH'; -FINALLY: 'FINALLY'; -THROW: 'THROW'; -RELEASE: 'RELEASE'; -CREATE: 'CREATE'; -DESTROY: 'DESTROY'; -USING: 'USING'; -POST: 'POST'; -TRIGGER: 'TRIGGER'; -SELECT: 'SELECT'; -DELETE: 'DELETE'; -INSERT: 'INSERT'; -DESCRIBE: 'DESCRIBE'; -RETURN: 'RETURN'; -OR: 'OR'; -AND: 'AND'; -NOT: 'NOT'; -CALL: 'CALL'; -HALT: 'HALT'; -SUPER: 'SUPER'; -LIBRARY: 'LIBRARY'; -SYSTEM: 'SYSTEM'; -RPCFUNC: 'RPCFUNC'; -ALIAS: 'ALIAS'; -THROWS: 'THROWS'; -AUTOINSTANTIATE: 'AUTOINSTANTIATE'; -DESCRIPTOR: 'DESCRIPTOR'; +TABLE : 'TABLE'; +COLUMN : 'COLUMN'; +RETRIEVE : 'RETRIEVE'; +PBSELECT : 'PBSELECT'; +VERSION : 'VERSION'; +ARGUMENTS : 'ARGUMENTS'; +SORT : 'SORT'; +ANY : 'ANY'; +BLOB : 'BLOB'; +BOOLEAN : 'BOOLEAN'; +BYTE : 'BYTE'; +CHARACTER : 'CHARACTER'; +CHAR : 'CHAR'; +DATE_TYPE : 'DATE'; +DATETIME : 'DATETIME'; +DECIMAL : 'DECIMAL'; +DEC : 'DEC'; +DOUBLE : 'DOUBLE'; +INTEGER : 'INTEGER'; +INT : 'INT'; +LONG : 'LONG'; +LONGLONG : 'LONGLONG'; +REAL : 'REAL'; +STRING : 'STRING'; +TIME_TYPE : 'TIME'; +UNSIGNEDINTEGER : 'UNSIGNEDINTEGER'; +UINT : 'UINT'; +UNSIGNEDLONG : 'UNSIGNEDLONG'; +ULONG : 'ULONG'; +WINDOW : 'WINDOW'; +TRUE : 'TRUE'; +FALSE : 'FALSE'; +GLOBAL : 'GLOBAL'; +SHARED : 'SHARED'; +END : 'END'; +INDIRECT : 'INDIRECT'; +VARIABLES : 'VARIABLES'; +FORWARD : 'FORWARD'; +PUBLIC : 'PUBLIC'; +PRIVATE : 'PRIVATE'; +FUNCTION : 'FUNCTION'; +SUBROUTINE : 'SUBROUTINE'; +READONLY : 'READONLY'; +PROTOTYPES : 'PROTOTYPES'; +TYPE : 'TYPE'; +ON : 'ON'; +TO : 'TO'; +FROM : 'FROM'; +REF : 'REF'; +NULL_ : 'NULL'; +UPDATE : 'UPDATE'; +CASE : 'CASE'; +DYNAMIC : 'DYNAMIC'; +WITHIN : 'WITHIN'; +PRIVATEWRITE : 'PRIVATEWRITE'; +PROTECTED : 'PROTECTED'; +PRIVATEREAD : 'PRIVATEREAD'; +PROTECTEDREAD : 'PROTECTEDREAD'; +PROTECTEDWRITE : 'PROTECTEDWRITE'; +LOCAL : 'LOCAL'; +EVENT : 'EVENT'; +OPEN : 'OPEN'; +GOTO : 'GOTO'; +ELSE : 'ELSE'; +IF : 'IF'; +THEN : 'THEN'; +ELSEIF : 'ELSEIF'; +TRY : 'TRY'; +EXIT : 'EXIT'; +CHOOSE : 'CHOOSE'; +IS : 'IS'; +CONTINUE : 'CONTINUE'; +DO : 'DO'; +WHILE : 'WHILE'; +FOR : 'FOR'; +CLOSE : 'CLOSE'; +NEXT : 'NEXT'; +LOOP : 'LOOP'; +UNTIL : 'UNTIL'; +STEP : 'STEP'; +CATCH : 'CATCH'; +FINALLY : 'FINALLY'; +THROW : 'THROW'; +RELEASE : 'RELEASE'; +CREATE : 'CREATE'; +DESTROY : 'DESTROY'; +USING : 'USING'; +POST : 'POST'; +TRIGGER : 'TRIGGER'; +SELECT : 'SELECT'; +DELETE : 'DELETE'; +INSERT : 'INSERT'; +DESCRIBE : 'DESCRIBE'; +RETURN : 'RETURN'; +OR : 'OR'; +AND : 'AND'; +NOT : 'NOT'; +CALL : 'CALL'; +HALT : 'HALT'; +SUPER : 'SUPER'; +LIBRARY : 'LIBRARY'; +SYSTEM : 'SYSTEM'; +RPCFUNC : 'RPCFUNC'; +ALIAS : 'ALIAS'; +THROWS : 'THROWS'; +AUTOINSTANTIATE : 'AUTOINSTANTIATE'; +DESCRIPTOR : 'DESCRIPTOR'; // Operators -EQ: '='; -GT: '>'; -GTE: '>='; -LT: '<'; -LTE: '<='; -GTLT: '<>'; -PLUS: '+'; -MINUS: '-'; -PLUSEQ: '+='; -MINUSEQ: '-='; -COLONCOLON: '::'; -MULT: '*'; -DIV: '/'; -MULTEQ: '*='; -DIVEQ: '/='; -CARAT: '^'; -LCURLY: '{'; -RCURLY: '}'; -LBRACE: '['; -RBRACE: ']'; -BRACES: '[]'; -TICK: '`'; -DQUOTED_STRING: '"' ('~~' | ~'"' | '~"')* '"'; -QUOTED_STRING: '\'' (~'\'' | '~\'')* '\''; -COMMA: ','; -SEMI: ';'; -LPAREN: '('; -RPAREN: ')'; -COLON: ':'; -DQUOTE: '"'; -TQ: '???'; -DOUBLE_PIPE: '||'; -DOTDOTDOT: '...'; +EQ : '='; +GT : '>'; +GTE : '>='; +LT : '<'; +LTE : '<='; +GTLT : '<>'; +PLUS : '+'; +MINUS : '-'; +PLUSEQ : '+='; +MINUSEQ : '-='; +COLONCOLON : '::'; +MULT : '*'; +DIV : '/'; +MULTEQ : '*='; +DIVEQ : '/='; +CARAT : '^'; +LCURLY : '{'; +RCURLY : '}'; +LBRACE : '['; +RBRACE : ']'; +BRACES : '[]'; +TICK : '`'; +DQUOTED_STRING : '"' ('~~' | ~'"' | '~"')* '"'; +QUOTED_STRING : '\'' (~'\'' | '~\'')* '\''; +COMMA : ','; +SEMI : ';'; +LPAREN : '('; +RPAREN : ')'; +COLON : ':'; +DQUOTE : '"'; +TQ : '???'; +DOUBLE_PIPE : '||'; +DOTDOTDOT : '...'; // Literals -NUMBER: (NUM '.' NUM | '.' NUM | NUM) ('E' ('+' | '-')? NUM)? ('D' | 'F')?; -DOT: '.'; -DATE: DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; -TIME: DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT (':' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT)?; -BINDPAR: ':' ID_PARTS; -EXPORT_HEADER: '$' LETTER ((LETTER | DIGIT | '-' | '#' | '%' | '_'))* '$' (LETTER | DIGIT | '.' | ' ' | '_')+ ~[\r\n]; -ENUM: ID_PARTS '!'; -ID: ID_PARTS; -RET_LIT: RETRIEVE EQ DQUOTED_STRING; -ARGS_LIT: ARGUMENTS EQ LPAREN LPAREN .+? RPAREN RPAREN ; -SORT_LIT: SORT EQ DQUOTED_STRING; - - +NUMBER : (NUM '.' NUM | '.' NUM | NUM) ('E' ('+' | '-')? NUM)? ('D' | 'F')?; +DOT : '.'; +DATE : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; +TIME : DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT (':' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT)?; +BINDPAR : ':' ID_PARTS; +EXPORT_HEADER: + '$' LETTER ((LETTER | DIGIT | '-' | '#' | '%' | '_'))* '$' (LETTER | DIGIT | '.' | ' ' | '_')+ ~[\r\n] +; +ENUM : ID_PARTS '!'; +ID : ID_PARTS; +RET_LIT : RETRIEVE EQ DQUOTED_STRING; +ARGS_LIT : ARGUMENTS EQ LPAREN LPAREN .+? RPAREN RPAREN; +SORT_LIT : SORT EQ DQUOTED_STRING; // Hidden -LINE_CONTINUATION: '&' WS* [\r\n] -> channel(HIDDEN); -SL_COMMENT: '//' ~ [\r\n]* -> channel(HIDDEN); -ML_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); -WS: [ \t\r\n]+ -> channel(HIDDEN); +LINE_CONTINUATION : '&' WS* [\r\n] -> channel(HIDDEN); +SL_COMMENT : '//' ~ [\r\n]* -> channel(HIDDEN); +ML_COMMENT : '/*' .*? '*/' -> channel(HIDDEN); +WS : [ \t\r\n]+ -> channel(HIDDEN); // Fragments -fragment ID_PARTS - : [A-Z] ([A-Z] | DIGIT | '-' | '$' | '#' | '%' | '_')* - ; +fragment ID_PARTS: [A-Z] ([A-Z] | DIGIT | '-' | '$' | '#' | '%' | '_')*; -fragment NUM - : DIGIT+ - ; +fragment NUM: DIGIT+; -fragment DIGIT - : '0' .. '9' - ; +fragment DIGIT: '0' .. '9'; -fragment LETTER - : 'A' .. 'Z' - ; \ No newline at end of file +fragment LETTER: 'A' .. 'Z'; \ No newline at end of file diff --git a/powerbuilderdw/PowerBuilderDWParser.g4 b/powerbuilderdw/PowerBuilderDWParser.g4 index 45656b27c3..879efb7a09 100644 --- a/powerbuilderdw/PowerBuilderDWParser.g4 +++ b/powerbuilderdw/PowerBuilderDWParser.g4 @@ -1,163 +1,174 @@ - +// $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 PowerBuilderDWParser; -options { -tokenVocab = PowerBuilderDWLexer; +options { + tokenVocab = PowerBuilderDWLexer; } start_rule - : header_rule? datawindow_rule + EOF - ; + : header_rule? datawindow_rule+ EOF + ; header_rule - : EXPORT_HEADER* (RELEASE NUMBER SEMI)? - ; + : EXPORT_HEADER* (RELEASE NUMBER SEMI)? + ; datawindow_rule - :datawindow_property+ + : datawindow_property+ ; datawindow_property - : attribute_name LPAREN datawindow_property_attribute_sub* RPAREN - | TABLE LPAREN table_attribute+ RPAREN - | COLUMN LPAREN datawindow_property_attribute_sub* RPAREN - ; + : attribute_name LPAREN datawindow_property_attribute_sub* RPAREN + | TABLE LPAREN table_attribute+ RPAREN + | COLUMN LPAREN datawindow_property_attribute_sub* RPAREN + ; table_attribute : column_attribute | retrieve_attribute ; - - column_attribute - : COLUMN EQ LPAREN TYPE EQ dataTypeSub LPAREN numeric_atom RPAREN datawindow_property_attribute_sub+ RPAREN + : COLUMN EQ LPAREN TYPE EQ dataTypeSub LPAREN numeric_atom RPAREN datawindow_property_attribute_sub+ RPAREN ; retrieve_attribute - : RET_LIT ARGS_LIT? SORT_LIT? + : RET_LIT ARGS_LIT? SORT_LIT? ; datawindow_property_attribute_sub - : ( NULL_ - | numeric_atom - | DQUOTED_STRING - | DATE - | TIME - | attribute_name eq=EQ (attribute_value array_decl_sub? | LPAREN datawindow_property_attribute_sub+ RPAREN) - ) COMMA? - ; + : ( + NULL_ + | numeric_atom + | DQUOTED_STRING + | DATE + | TIME + | attribute_name eq = EQ ( + attribute_value array_decl_sub? + | LPAREN datawindow_property_attribute_sub+ RPAREN + ) + ) COMMA? + ; attribute_name - : (identifier_name | TYPE | UPDATE) NUMBER? (DOT (identifier_name | CASE | TYPE | ON | DYNAMIC))* - ; + : (identifier_name | TYPE | UPDATE) NUMBER? ( + DOT (identifier_name | CASE | TYPE | ON | DYNAMIC) + )* + ; identifier_name - : ID - ; + : ID + ; attribute_value - : atom_sub_call1 - | atom_sub_member1 - | MINUS? numeric_atom - | boolean_atom - | ENUM - | DQUOTED_STRING - | QUOTED_STRING - | DATE - | TIME - | TYPE - | TO - | FROM - | REF - | NULL_ - | OPEN - | LPAREN LPAREN (expression | dataTypeSub) (COMMA (expression | dataTypeSub))? RPAREN (COMMA LPAREN (expression | dataTypeSub) (COMMA (expression | dataTypeSub))? RPAREN)* RPAREN - | dataTypeSub (LPAREN NUMBER RPAREN)? - ; + : atom_sub_call1 + | atom_sub_member1 + | MINUS? numeric_atom + | boolean_atom + | ENUM + | DQUOTED_STRING + | QUOTED_STRING + | DATE + | TIME + | TYPE + | TO + | FROM + | REF + | NULL_ + | OPEN + | LPAREN LPAREN (expression | dataTypeSub) (COMMA (expression | dataTypeSub))? RPAREN ( + COMMA LPAREN (expression | dataTypeSub) (COMMA (expression | dataTypeSub))? RPAREN + )* RPAREN + | dataTypeSub (LPAREN NUMBER RPAREN)? + ; numeric_atom - : NUMBER - ; + : NUMBER + ; dataTypeSub - : ANY - | BLOB - | BOOLEAN - | BYTE - | CHARACTER - | CHAR - | DATE_TYPE - | DATETIME - | DECIMAL - | DEC - | DOUBLE - | INTEGER - | INT - | LONG - | LONGLONG - | REAL - | STRING - | TIME_TYPE - | UNSIGNEDINTEGER - | UINT - | UNSIGNEDLONG - | ULONG - | WINDOW - ; + : ANY + | BLOB + | BOOLEAN + | BYTE + | CHARACTER + | CHAR + | DATE_TYPE + | DATETIME + | DECIMAL + | DEC + | DOUBLE + | INTEGER + | INT + | LONG + | LONGLONG + | REAL + | STRING + | TIME_TYPE + | UNSIGNEDINTEGER + | UINT + | UNSIGNEDLONG + | ULONG + | WINDOW + ; expression - : close_call_sub - | LCURLY - ; + : close_call_sub + | LCURLY + ; array_decl_sub - : BRACES - | LBRACE ((PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)? (COMMA (PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)?)*)? RBRACE - ; + : BRACES + | LBRACE ( + (PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)? ( + COMMA (PLUS | MINUS)? NUMBER (TO (PLUS | MINUS)? NUMBER)? + )* + )? RBRACE + ; close_call_sub - : CLOSE LPAREN expression_list RPAREN - | HALT CLOSE - ; + : CLOSE LPAREN expression_list RPAREN + | HALT CLOSE + ; expression_list - : REF? expression (COMMA REF? expression)* - ; + : REF? expression (COMMA REF? expression)* + ; atom_sub_call1 - : (identifier | DESCRIBE) LPAREN expression_list? RPAREN - ; + : (identifier | DESCRIBE) LPAREN expression_list? RPAREN + ; identifier - : identifier_name - | SUPER COLONCOLON (CREATE | DESTROY | identifier_name_ex) - | identifier_name COLONCOLON (CREATE | DESTROY) - | identifier_name DOT (CREATE | DESTROY) - | identifier_name COLONCOLON identifier_name_ex - ; + : identifier_name + | SUPER COLONCOLON (CREATE | DESTROY | identifier_name_ex) + | identifier_name COLONCOLON (CREATE | DESTROY) + | identifier_name DOT (CREATE | DESTROY) + | identifier_name COLONCOLON identifier_name_ex + ; identifier_name_ex - : identifier_name - | SELECT - | TYPE - | UPDATE - | DELETE - | OPEN - | CLOSE - | GOTO - | INSERT - | DESCRIBE - | TIME - | READONLY - ; + : identifier_name + | SELECT + | TYPE + | UPDATE + | DELETE + | OPEN + | CLOSE + | GOTO + | INSERT + | DESCRIBE + | TIME + | READONLY + ; atom_sub_member1 - : identifier - ; + : identifier + ; boolean_atom - : TRUE - | FALSE - ; \ No newline at end of file + : TRUE + | FALSE + ; \ No newline at end of file diff --git a/powerquery/PowerQueryLexer.g4 b/powerquery/PowerQueryLexer.g4 index 1e30b9ecdf..1f58599464 100644 --- a/powerquery/PowerQueryLexer.g4 +++ b/powerquery/PowerQueryLexer.g4 @@ -1,232 +1,225 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PowerQueryLexer; options { caseInsensitive = true; } -fragment LEXICAL_UNIT: LEXICAL_ELEMENTS; -fragment LEXICAL_ELEMENTS: LEXICAL_ELEMENT LEXICAL_ELEMENTS?; -fragment LEXICAL_ELEMENT: WHITESPACE | TOKEN COMMENT; +fragment LEXICAL_UNIT : LEXICAL_ELEMENTS; +fragment LEXICAL_ELEMENTS : LEXICAL_ELEMENT LEXICAL_ELEMENTS?; +fragment LEXICAL_ELEMENT : WHITESPACE | TOKEN COMMENT; -WHITESPACE:( - [\p{White_Space}] - | [\u0009\u000B\u000C] - | [\u000D][\u000A] NEW_LINE_CHAR) -> skip; -NEW_LINE_CHAR: [\u000D\u000A\u0085\u2028\u2029] -> skip; -COMMENT: (SINGLE_LINE_COMMENT | DELIMITED_COMMENT) -> skip; -fragment SINGLE_LINE_COMMENT: '//' SINGLE_LINE_COMMENT_CHARS?; -fragment SINGLE_LINE_COMMENT_CHARS: - SINGLE_LINE_COMMENT_CHAR SINGLE_LINE_COMMENT_CHARS?; -fragment SINGLE_LINE_COMMENT_CHAR: ~'\n'; -fragment DELIMITED_COMMENT: - '/*' DELIMITED_COMMENT_TEXT? ASTERISKS '/'; -fragment DELIMITED_COMMENT_TEXT: - DELIMITED_COMMENT_SECTION DELIMITED_COMMENT_TEXT?; -fragment DELIMITED_COMMENT_SECTION: ( - '/' - | ASTERISKS? NOT_SLASH_OR_ASTERISKS - ); -fragment ASTERISKS: '*' ASTERISKS?; -fragment NOT_SLASH_OR_ASTERISKS: [^*/]; +WHITESPACE : ( [\p{White_Space}] | [\u0009\u000B\u000C] | [\u000D][\u000A] NEW_LINE_CHAR) -> skip; +NEW_LINE_CHAR : [\u000D\u000A\u0085\u2028\u2029] -> skip; +COMMENT : (SINGLE_LINE_COMMENT | DELIMITED_COMMENT) -> skip; +fragment SINGLE_LINE_COMMENT : '//' SINGLE_LINE_COMMENT_CHARS?; +fragment SINGLE_LINE_COMMENT_CHARS : SINGLE_LINE_COMMENT_CHAR SINGLE_LINE_COMMENT_CHARS?; +fragment SINGLE_LINE_COMMENT_CHAR : ~'\n'; +fragment DELIMITED_COMMENT : '/*' DELIMITED_COMMENT_TEXT? ASTERISKS '/'; +fragment DELIMITED_COMMENT_TEXT : DELIMITED_COMMENT_SECTION DELIMITED_COMMENT_TEXT?; +fragment DELIMITED_COMMENT_SECTION : ( '/' | ASTERISKS? NOT_SLASH_OR_ASTERISKS); +fragment ASTERISKS : '*' ASTERISKS?; +fragment NOT_SLASH_OR_ASTERISKS : [^*/]; fragment KEYWORD: - AND - | AS - | EACH - | ELSE - | ERROR - | IF - | IN - | IS - | LET - | META - | NOT - | OR - | OTHERWISE - | SECTION - | SHARED - | THEN - | TRY - | TYPE - | '#binary' - | '#date' - | '#datetime' - | '#datetimezone' - | '#duration' - | '#infinity' - | '#nan' - | '#sections' - | '#shared' - | '#table' - | '#time'; + AND + | AS + | EACH + | ELSE + | ERROR + | IF + | IN + | IS + | LET + | META + | NOT + | OR + | OTHERWISE + | SECTION + | SHARED + | THEN + | TRY + | TYPE + | '#binary' + | '#date' + | '#datetime' + | '#datetimezone' + | '#duration' + | '#infinity' + | '#nan' + | '#sections' + | '#shared' + | '#table' + | '#time' +; -fragment TOKEN: IDENTIFIER | KEYWORD | LITERAL | OPERATOR_OR_PUNCTUATOR; -CHARACHTER_ESCAPE_SEQUENCE: '#(' ESCAPE_SEQUENCE_LIST ')'; +fragment TOKEN : IDENTIFIER | KEYWORD | LITERAL | OPERATOR_OR_PUNCTUATOR; +CHARACHTER_ESCAPE_SEQUENCE : '#(' ESCAPE_SEQUENCE_LIST ')'; fragment ESCAPE_SEQUENCE_LIST: - SINGLE_ESCAPE_SEQUENCE - | SINGLE_ESCAPE_SEQUENCE ',' ESCAPE_SEQUENCE_LIST; + SINGLE_ESCAPE_SEQUENCE + | SINGLE_ESCAPE_SEQUENCE ',' ESCAPE_SEQUENCE_LIST +; fragment SINGLE_ESCAPE_SEQUENCE: - LONG_UNICODE_ESCAPE_SEQUENCE - | SHORT_UNICODE_ESCAPE_SEQUENCE - | CONTROL_CHAR_ESCAPE_SEQUENCE - | ESCAPE_ESCAPE; + LONG_UNICODE_ESCAPE_SEQUENCE + | SHORT_UNICODE_ESCAPE_SEQUENCE + | CONTROL_CHAR_ESCAPE_SEQUENCE + | ESCAPE_ESCAPE +; fragment LONG_UNICODE_ESCAPE_SEQUENCE: - HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; -fragment SHORT_UNICODE_ESCAPE_SEQUENCE: - HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; -fragment CONTROL_CHAR_ESCAPE_SEQUENCE: CONTROL_CHAR; -fragment CONTROL_CHAR: [\r\n\t]; -fragment ESCAPE_ESCAPE: '#'; -EQUALS: '='; -COMMA: ','; -OPEN_BRACKET: '['; -CLOSE_BRACKET: ']'; -OPEN_BRACE: '{'; -CLOSE_BRACE: '}'; -OPEN_PAREN: '(' ; -CLOSE_PAREN: ')'; -OPTIONAL: '?'; -OPTIONAL_TEXT: 'optional'; -TABLE: 'table'; -NULLABLE: 'nullable'; -SEMICOLON: ';'; -SECTION: 'section'; -SHARED: 'shared'; -AND: 'and'; -OR: 'or'; -OTHERWISE: 'otherwise'; -TRY: 'try'; -ERROR: 'error'; -FUNCTION_START: 'function ('; -ELLIPSES: '...'; -TYPE: 'type'; -EACH: 'each'; -LET: 'let'; -IN: 'in'; -IF: 'if'; -THEN: 'then'; -ELSE: 'else'; -TEXT: 'text'; -RECORD: 'record'; -NUMBER: 'number'; -NONE: 'none'; -LOGICAL: 'logical'; -LIST: 'list'; -FUNCTION: 'fuction'; -DURATION: 'duration'; -DATETIMEZONE: 'datetimezone'; -ANY: 'any'; -ANYNONNULL: 'anynonnull'; -BINARY: 'binary'; -DATE: 'date'; -DATETIME: 'datetime'; -AT: '@'; -AS: 'as'; -ARROW: '=>'; -DOTDOT: '..'; -BANG: '!'; -NOT: 'not'; -PLUS: '+'; -MINUS: '-'; -META: 'meta'; -IS: 'is'; -NEQ: '<>'; -GE: '>'; -LE: '<'; -SLASH: '/'; -STAR: '*'; -AMP: '&'; -LEQ: '<='; -GEQ: '>='; + HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT +; +fragment SHORT_UNICODE_ESCAPE_SEQUENCE : HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; +fragment CONTROL_CHAR_ESCAPE_SEQUENCE : CONTROL_CHAR; +fragment CONTROL_CHAR : [\r\n\t]; +fragment ESCAPE_ESCAPE : '#'; +EQUALS : '='; +COMMA : ','; +OPEN_BRACKET : '['; +CLOSE_BRACKET : ']'; +OPEN_BRACE : '{'; +CLOSE_BRACE : '}'; +OPEN_PAREN : '('; +CLOSE_PAREN : ')'; +OPTIONAL : '?'; +OPTIONAL_TEXT : 'optional'; +TABLE : 'table'; +NULLABLE : 'nullable'; +SEMICOLON : ';'; +SECTION : 'section'; +SHARED : 'shared'; +AND : 'and'; +OR : 'or'; +OTHERWISE : 'otherwise'; +TRY : 'try'; +ERROR : 'error'; +FUNCTION_START : 'function ('; +ELLIPSES : '...'; +TYPE : 'type'; +EACH : 'each'; +LET : 'let'; +IN : 'in'; +IF : 'if'; +THEN : 'then'; +ELSE : 'else'; +TEXT : 'text'; +RECORD : 'record'; +NUMBER : 'number'; +NONE : 'none'; +LOGICAL : 'logical'; +LIST : 'list'; +FUNCTION : 'fuction'; +DURATION : 'duration'; +DATETIMEZONE : 'datetimezone'; +ANY : 'any'; +ANYNONNULL : 'anynonnull'; +BINARY : 'binary'; +DATE : 'date'; +DATETIME : 'datetime'; +AT : '@'; +AS : 'as'; +ARROW : '=>'; +DOTDOT : '..'; +BANG : '!'; +NOT : 'not'; +PLUS : '+'; +MINUS : '-'; +META : 'meta'; +IS : 'is'; +NEQ : '<>'; +GE : '>'; +LE : '<'; +SLASH : '/'; +STAR : '*'; +AMP : '&'; +LEQ : '<='; +GEQ : '>='; fragment TEXT_LITERAL_CHAR: - SINGLE_TEXT_CHAR - | CHARACHTER_ESCAPE_SEQUENCE - | DOUBLE_QUOTE_ESACAPE_SEQUENCE; -fragment NUMBER_LITERAL: DECIMAL_NUMBER_LITERAL | HEX_NUMBER_LITERAL; -LITERAL: - LOGICAL_LITERAL - | NUMBER_LITERAL - | TEXT_LITERAL - | NULL_LITERAL - | VERBATIM_LITERAL; -fragment LOGICAL_LITERAL: 'true' | 'false'; -fragment DECIMAL_DIGITS: DECIMAL_DIGIT DECIMAL_DIGITS?; -fragment DECIMAL_DIGIT: [0-9]; -fragment HEX_NUMBER_LITERAL: '0x' HEX_DIGITS; -fragment HEX_DIGITS: HEX_DIGIT HEX_DIGITS?; -fragment HEX_DIGIT: [0-9a-f]; + SINGLE_TEXT_CHAR + | CHARACHTER_ESCAPE_SEQUENCE + | DOUBLE_QUOTE_ESACAPE_SEQUENCE +; +fragment NUMBER_LITERAL : DECIMAL_NUMBER_LITERAL | HEX_NUMBER_LITERAL; +LITERAL : LOGICAL_LITERAL | NUMBER_LITERAL | TEXT_LITERAL | NULL_LITERAL | VERBATIM_LITERAL; +fragment LOGICAL_LITERAL : 'true' | 'false'; +fragment DECIMAL_DIGITS : DECIMAL_DIGIT DECIMAL_DIGITS?; +fragment DECIMAL_DIGIT : [0-9]; +fragment HEX_NUMBER_LITERAL : '0x' HEX_DIGITS; +fragment HEX_DIGITS : HEX_DIGIT HEX_DIGITS?; +fragment HEX_DIGIT : [0-9a-f]; fragment DECIMAL_NUMBER_LITERAL: - DECIMAL_DIGITS '.' DECIMAL_DIGITS EXPONENT_PART? - | '.' DECIMAL_DIGITS EXPONENT_PART? - | DECIMAL_DIGITS EXPONENT_PART?; -fragment EXPONENT_PART: '[Ee]' SIGN? DECIMAL_DIGITS; -fragment SIGN: [+-]; + DECIMAL_DIGITS '.' DECIMAL_DIGITS EXPONENT_PART? + | '.' DECIMAL_DIGITS EXPONENT_PART? + | DECIMAL_DIGITS EXPONENT_PART? +; +fragment EXPONENT_PART : '[Ee]' SIGN? DECIMAL_DIGITS; +fragment SIGN : [+-]; -TEXT_LITERAL: '"' TEXT_LITERAL_CHARS? '"'; -fragment TEXT_LITERAL_CHARS: TEXT_LITERAL_CHAR TEXT_LITERAL_CHARS?; -fragment DOUBLE_QUOTE_ESACAPE_SEQUENCE: '""'; -fragment NULL_LITERAL: 'null'; -fragment VERBATIM_LITERAL: '#!' TEXT_LITERAL_CHARS? '"'; +TEXT_LITERAL : '"' TEXT_LITERAL_CHARS? '"'; +fragment TEXT_LITERAL_CHARS : TEXT_LITERAL_CHAR TEXT_LITERAL_CHARS?; +fragment DOUBLE_QUOTE_ESACAPE_SEQUENCE : '""'; +fragment NULL_LITERAL : 'null'; +fragment VERBATIM_LITERAL : '#!' TEXT_LITERAL_CHARS? '"'; -IDENTIFIER: REGULAR_IDENTIFIER | QUOTED_IDENTIFIER; -REGULAR_IDENTIFIER: - AVAILABLE_IDENTIFIER - | AVAILABLE_IDENTIFIER '.' REGULAR_IDENTIFIER; -AVAILABLE_IDENTIFIER: KEYWORD_OR_IDENTIFIER; -fragment IDENTIFIER_START_CHAR: LETTER_CHAR | '_'; -KEYWORD_OR_IDENTIFIER: - LETTER_CHAR - | '_' - | IDENTIFIER_START_CHAR IDENTIFIER_PART_CHARS; -fragment IDENTIFIER_PART_CHARS: - IDENTIFIER_PART_CHAR IDENTIFIER_PART_CHARS?; +IDENTIFIER : REGULAR_IDENTIFIER | QUOTED_IDENTIFIER; +REGULAR_IDENTIFIER : AVAILABLE_IDENTIFIER | AVAILABLE_IDENTIFIER '.' REGULAR_IDENTIFIER; +AVAILABLE_IDENTIFIER : KEYWORD_OR_IDENTIFIER; +fragment IDENTIFIER_START_CHAR : LETTER_CHAR | '_'; +KEYWORD_OR_IDENTIFIER : LETTER_CHAR | '_' | IDENTIFIER_START_CHAR IDENTIFIER_PART_CHARS; +fragment IDENTIFIER_PART_CHARS : IDENTIFIER_PART_CHAR IDENTIFIER_PART_CHARS?; fragment IDENTIFIER_PART_CHAR: - LETTER_CHAR - | DECIMAL_DIGIT_CHAR - | '_' - | CONNECTING_CHAR - | COMBINING_CHAR - | FORMATTING_CHAR; + LETTER_CHAR + | DECIMAL_DIGIT_CHAR + | '_' + | CONNECTING_CHAR + | COMBINING_CHAR + | FORMATTING_CHAR +; fragment GENERALIZED_IDENTIFIER: - GENERALIZED_IDENTIFIER_PART [\u0020]+ GENERALIZED_IDENTIFIER - | GENERALIZED_IDENTIFIER_PART; + GENERALIZED_IDENTIFIER_PART [\u0020]+ GENERALIZED_IDENTIFIER + | GENERALIZED_IDENTIFIER_PART +; fragment GENERALIZED_IDENTIFIER_PART: - GENERALIZED_IDENTIFIER_SEGMENT - | DECIMAL_DIGIT_CHAR GENERALIZED_IDENTIFIER_SEGMENT; + GENERALIZED_IDENTIFIER_SEGMENT + | DECIMAL_DIGIT_CHAR GENERALIZED_IDENTIFIER_SEGMENT +; fragment GENERALIZED_IDENTIFIER_SEGMENT: - KEYWORD_OR_IDENTIFIER - | KEYWORD_OR_IDENTIFIER '.' KEYWORD_OR_IDENTIFIER; -fragment LETTER_CHAR: [\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}]; -fragment COMBINING_CHAR: [\p{Mn}\p{Mc}]; -fragment DECIMAL_DIGIT_CHAR: [\p{Nd}]; -fragment CONNECTING_CHAR: [\p{Pc}]; -fragment FORMATTING_CHAR: [\p{Cf}]; -fragment QUOTED_IDENTIFIER: '#"' TEXT_LITERAL_CHARS? '"'; + KEYWORD_OR_IDENTIFIER + | KEYWORD_OR_IDENTIFIER '.' KEYWORD_OR_IDENTIFIER +; +fragment LETTER_CHAR : [\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}]; +fragment COMBINING_CHAR : [\p{Mn}\p{Mc}]; +fragment DECIMAL_DIGIT_CHAR : [\p{Nd}]; +fragment CONNECTING_CHAR : [\p{Pc}]; +fragment FORMATTING_CHAR : [\p{Cf}]; +fragment QUOTED_IDENTIFIER : '#"' TEXT_LITERAL_CHARS? '"'; fragment OPERATOR_OR_PUNCTUATOR: - COMMA - | SEMICOLON - | EQUALS - | LE - | LEQ - | GE - | GEQ - | NEQ - | PLUS - | MINUS - | STAR - | SLASH - | AMP - | OPEN_PAREN - | CLOSE_PAREN - | OPEN_BRACKET - | CLOSE_BRACKET - | OPEN_BRACE - | CLOSE_BRACE - | AT - | OPTIONAL - | ARROW - | DOTDOT - | ELLIPSES; - + COMMA + | SEMICOLON + | EQUALS + | LE + | LEQ + | GE + | GEQ + | NEQ + | PLUS + | MINUS + | STAR + | SLASH + | AMP + | OPEN_PAREN + | CLOSE_PAREN + | OPEN_BRACKET + | CLOSE_BRACKET + | OPEN_BRACE + | CLOSE_BRACE + | AT + | OPTIONAL + | ARROW + | DOTDOT + | ELLIPSES +; fragment SINGLE_TEXT_CHAR: ~'"' | '#' ~'('; \ No newline at end of file diff --git a/powerquery/PowerQueryParser.g4 b/powerquery/PowerQueryParser.g4 index 0bdd250933..0358473c4b 100644 --- a/powerquery/PowerQueryParser.g4 +++ b/powerquery/PowerQueryParser.g4 @@ -1,241 +1,499 @@ +// $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 PowerQueryParser; + options { - tokenVocab = PowerQueryLexer; + tokenVocab = PowerQueryLexer; } -document: section_document | expression_document; -section_document: section; -section: - literal_attribs? SECTION section_name SEMICOLON section_members?; -section_name: IDENTIFIER; -section_members: section_member section_members?; -section_member: - literal_attribs? SHARED? section_member_name EQUALS expression SEMICOLON; -section_member_name: IDENTIFIER; - -expression_document: expression; -expression: - logical_or_expression - | each_expression - | function_expression - | let_expression - | if_expression - | let_expression - | error_raising_expression - | error_handling_expression; - -logical_or_expression: - logical_and_expression - | logical_and_expression OR logical_or_expression; -logical_and_expression: - is_expression - | logical_and_expression AND is_expression; - -is_expression: - as_expression - | is_expression IS nullable_primitive_type; -nullable_primitive_type: NULLABLE? primitive_type; - -as_expression: - equality_expression - | as_expression AS nullable_primitive_type; - -equality_expression: - relational_expression - | relational_expression EQUALS equality_expression - | relational_expression NEQ equality_expression; - -relational_expression: - additive_expression - | additive_expression LE relational_expression - | additive_expression GE relational_expression - | additive_expression LEQ additive_expression - | additive_expression GEQ relational_expression; - -additive_expression: - multiplicative_expression - | multiplicative_expression PLUS additive_expression - | multiplicative_expression MINUS additive_expression - | multiplicative_expression AMP additive_expression; -multiplicative_expression: - metadata_expression - | metadata_expression STAR multiplicative_expression - | metadata_expression SLASH multiplicative_expression; - -metadata_expression: - unary_expression - | unary_expression META unary_expression; -unary_expression: - type_expression - | PLUS unary_expression - | MINUS unary_expression - | NOT unary_expression; - -primary_expression: - literal_expression - | list_expression - | record_expression - | identifier_expression - | section_access_expression - | parenthesized_expression - | primary_expression field_selector - | implicit_target_field_selection - | primary_expression required_projection - | primary_expression optional_projection //projection - | implicit_target_projection //field_access_expression - | primary_expression OPEN_BRACE item_selector CLOSE_BRACE - | primary_expression OPEN_BRACE item_selector CLOSE_BRACE OPTIONAL //item access expression - | primary_expression OPEN_PAREN argument_list? CLOSE_PAREN //invoke_expression - | not_implemented_expression; -literal_expression: LITERAL; -identifier_expression: identifier_reference; -identifier_reference: - exclusive_identifier_reference - | inclusive_identifier_reference; -exclusive_identifier_reference: IDENTIFIER; -inclusive_identifier_reference: AT IDENTIFIER; - -section_access_expression: IDENTIFIER BANG IDENTIFIER; - -parenthesized_expression: OPEN_PAREN expression CLOSE_PAREN; -not_implemented_expression: ELLIPSES; -argument_list: expression | expression COMMA argument_list; -list_expression: OPEN_BRACE item_list? CLOSE_BRACE; -item_list: item | item COMMA item_list; -item: expression | expression DOTDOT expression; - -record_expression: OPEN_BRACKET field_list? CLOSE_BRACKET; -field_list: field | field COMMA field_list; -field: field_name EQUALS expression; -field_name: IDENTIFIER; -item_selector: expression; - -field_selector: - required_field_selector - | optional_field_selector; -required_field_selector: OPEN_BRACKET field_name CLOSE_BRACKET; -optional_field_selector: - OPEN_BRACKET field_name CLOSE_BRACKET OPTIONAL; -implicit_target_field_selection: field_selector; -required_projection: - OPEN_BRACKET required_selector_list CLOSE_BRACKET; -optional_projection: - OPEN_BRACKET required_selector_list CLOSE_BRACKET OPTIONAL; -required_selector_list: - required_field_selector - | required_field_selector COMMA required_selector_list; -implicit_target_projection: - required_projection - | optional_projection; - -function_expression: - OPEN_PAREN parameter_list? CLOSE_PAREN return_type? '=>' function_body; -function_body: expression; -parameter_list: - fixed_parameter_list - | fixed_parameter_list COMMA optional_parameter_list; -fixed_parameter_list: - parameter - | parameter COMMA fixed_parameter_list; -parameter: parameter_name parameter_type?; -parameter_name: IDENTIFIER; -parameter_type: assertion; -return_type: assertion; -assertion: AS nullable_primitive_type; -optional_parameter_list: - optional_parameter - | optional_parameter COMMA optional_parameter_list; -optional_parameter: OPTIONAL_TEXT parameter; - -each_expression: EACH each_expression_body; -each_expression_body: function_body; - -let_expression: LET variable_list IN expression; -variable_list: variable | variable COMMA variable_list; -variable: variable_name EQUALS expression; -variable_name: IDENTIFIER; - -if_expression: - IF if_condition THEN true_expression ELSE false_expression; -if_condition: expression; -true_expression: expression; -false_expression: expression; - -type_expression: primary_expression | TYPE primary_type; -type_expr: parenthesized_expression | primary_type; -primary_type: - primitive_type - | record_type - | list_type - | function_type - | table_type - | nullable_type; -primitive_type: - ANY - | ANYNONNULL - | BINARY - | DATE - | DATETIME - | DATETIMEZONE - | DURATION - | FUNCTION - | LIST - | LOGICAL - | NONE - | NUMBER - | RECORD - | TABLE - | TEXT - | TYPE - | LITERAL; -record_type: - OPEN_BRACKET open_record_marker CLOSE_BRACKET - | OPEN_BRACKET field_specification_list? CLOSE_BRACKET - | OPEN_BRACKET field_specification_list COMMA open_record_marker CLOSE_BRACKET; -field_specification_list: - field_specification - | field_specification COMMA field_specification_list; -field_specification: - OPTIONAL_TEXT? field_name field_type_specification?; -field_type_specification: EQUALS field_type; -field_type: type_expr; -open_record_marker: ELLIPSES; -list_type: OPEN_BRACE item_type CLOSE_BRACE; -item_type: type_expr; -function_type: - FUNCTION_START parameter_specification_list? CLOSE_PAREN return_type; -parameter_specification_list: - required_parameter_specification_list - | required_parameter_specification_list COMMA optional_parameter_specification_list - | optional_parameter_specification_list; -required_parameter_specification_list: - required_parameter_specification - | required_parameter_specification COMMA required_parameter_specification_list; -required_parameter_specification: parameter_specification; -optional_parameter_specification_list: - optional_parameter_specification - | optional_parameter_specification COMMA optional_parameter_specification_list; -optional_parameter_specification: - OPTIONAL_TEXT parameter_specification; -parameter_specification: parameter_name parameter_type; -table_type: TABLE row_type; -row_type: OPEN_BRACKET field_specification_list CLOSE_BRACKET; -nullable_type: NULLABLE type_expr; - -error_raising_expression: ERROR expression; -error_handling_expression: - TRY protected_expression otherwise_clause?; -protected_expression: expression; -otherwise_clause: OTHERWISE default_expression; -default_expression: expression; - -literal_attribs: record_literal; -record_literal: OPEN_BRACKET literal_field_list? CLOSE_BRACKET; -literal_field_list: - literal_field - | literal_field COMMA literal_field_list; -literal_field: field_name EQUALS any_literal; -list_literal: OPEN_BRACE literal_item_list? CLOSE_BRACE; -literal_item_list: - any_literal - | any_literal COMMA literal_item_list; -any_literal: record_literal | list_literal | LITERAL; + +document + : section_document + | expression_document + ; + +section_document + : section + ; + +section + : literal_attribs? SECTION section_name SEMICOLON section_members? + ; + +section_name + : IDENTIFIER + ; + +section_members + : section_member section_members? + ; + +section_member + : literal_attribs? SHARED? section_member_name EQUALS expression SEMICOLON + ; + +section_member_name + : IDENTIFIER + ; + +expression_document + : expression + ; + +expression + : logical_or_expression + | each_expression + | function_expression + | let_expression + | if_expression + | let_expression + | error_raising_expression + | error_handling_expression + ; + +logical_or_expression + : logical_and_expression + | logical_and_expression OR logical_or_expression + ; + +logical_and_expression + : is_expression + | logical_and_expression AND is_expression + ; + +is_expression + : as_expression + | is_expression IS nullable_primitive_type + ; + +nullable_primitive_type + : NULLABLE? primitive_type + ; + +as_expression + : equality_expression + | as_expression AS nullable_primitive_type + ; + +equality_expression + : relational_expression + | relational_expression EQUALS equality_expression + | relational_expression NEQ equality_expression + ; + +relational_expression + : additive_expression + | additive_expression LE relational_expression + | additive_expression GE relational_expression + | additive_expression LEQ additive_expression + | additive_expression GEQ relational_expression + ; + +additive_expression + : multiplicative_expression + | multiplicative_expression PLUS additive_expression + | multiplicative_expression MINUS additive_expression + | multiplicative_expression AMP additive_expression + ; + +multiplicative_expression + : metadata_expression + | metadata_expression STAR multiplicative_expression + | metadata_expression SLASH multiplicative_expression + ; + +metadata_expression + : unary_expression + | unary_expression META unary_expression + ; + +unary_expression + : type_expression + | PLUS unary_expression + | MINUS unary_expression + | NOT unary_expression + ; + +primary_expression + : literal_expression + | list_expression + | record_expression + | identifier_expression + | section_access_expression + | parenthesized_expression + | primary_expression field_selector + | implicit_target_field_selection + | primary_expression required_projection + | primary_expression optional_projection //projection + | implicit_target_projection //field_access_expression + | primary_expression OPEN_BRACE item_selector CLOSE_BRACE + | primary_expression OPEN_BRACE item_selector CLOSE_BRACE OPTIONAL //item access expression + | primary_expression OPEN_PAREN argument_list? CLOSE_PAREN //invoke_expression + | not_implemented_expression + ; + +literal_expression + : LITERAL + ; + +identifier_expression + : identifier_reference + ; + +identifier_reference + : exclusive_identifier_reference + | inclusive_identifier_reference + ; + +exclusive_identifier_reference + : IDENTIFIER + ; + +inclusive_identifier_reference + : AT IDENTIFIER + ; + +section_access_expression + : IDENTIFIER BANG IDENTIFIER + ; + +parenthesized_expression + : OPEN_PAREN expression CLOSE_PAREN + ; + +not_implemented_expression + : ELLIPSES + ; + +argument_list + : expression + | expression COMMA argument_list + ; + +list_expression + : OPEN_BRACE item_list? CLOSE_BRACE + ; + +item_list + : item + | item COMMA item_list + ; + +item + : expression + | expression DOTDOT expression + ; + +record_expression + : OPEN_BRACKET field_list? CLOSE_BRACKET + ; + +field_list + : field + | field COMMA field_list + ; + +field + : field_name EQUALS expression + ; + +field_name + : IDENTIFIER + ; + +item_selector + : expression + ; + +field_selector + : required_field_selector + | optional_field_selector + ; + +required_field_selector + : OPEN_BRACKET field_name CLOSE_BRACKET + ; + +optional_field_selector + : OPEN_BRACKET field_name CLOSE_BRACKET OPTIONAL + ; + +implicit_target_field_selection + : field_selector + ; + +required_projection + : OPEN_BRACKET required_selector_list CLOSE_BRACKET + ; + +optional_projection + : OPEN_BRACKET required_selector_list CLOSE_BRACKET OPTIONAL + ; + +required_selector_list + : required_field_selector + | required_field_selector COMMA required_selector_list + ; + +implicit_target_projection + : required_projection + | optional_projection + ; + +function_expression + : OPEN_PAREN parameter_list? CLOSE_PAREN return_type? '=>' function_body + ; + +function_body + : expression + ; + +parameter_list + : fixed_parameter_list + | fixed_parameter_list COMMA optional_parameter_list + ; + +fixed_parameter_list + : parameter + | parameter COMMA fixed_parameter_list + ; + +parameter + : parameter_name parameter_type? + ; + +parameter_name + : IDENTIFIER + ; + +parameter_type + : assertion + ; + +return_type + : assertion + ; + +assertion + : AS nullable_primitive_type + ; + +optional_parameter_list + : optional_parameter + | optional_parameter COMMA optional_parameter_list + ; + +optional_parameter + : OPTIONAL_TEXT parameter + ; + +each_expression + : EACH each_expression_body + ; + +each_expression_body + : function_body + ; + +let_expression + : LET variable_list IN expression + ; + +variable_list + : variable + | variable COMMA variable_list + ; + +variable + : variable_name EQUALS expression + ; + +variable_name + : IDENTIFIER + ; + +if_expression + : IF if_condition THEN true_expression ELSE false_expression + ; + +if_condition + : expression + ; + +true_expression + : expression + ; + +false_expression + : expression + ; + +type_expression + : primary_expression + | TYPE primary_type + ; + +type_expr + : parenthesized_expression + | primary_type + ; + +primary_type + : primitive_type + | record_type + | list_type + | function_type + | table_type + | nullable_type + ; + +primitive_type + : ANY + | ANYNONNULL + | BINARY + | DATE + | DATETIME + | DATETIMEZONE + | DURATION + | FUNCTION + | LIST + | LOGICAL + | NONE + | NUMBER + | RECORD + | TABLE + | TEXT + | TYPE + | LITERAL + ; + +record_type + : OPEN_BRACKET open_record_marker CLOSE_BRACKET + | OPEN_BRACKET field_specification_list? CLOSE_BRACKET + | OPEN_BRACKET field_specification_list COMMA open_record_marker CLOSE_BRACKET + ; + +field_specification_list + : field_specification + | field_specification COMMA field_specification_list + ; + +field_specification + : OPTIONAL_TEXT? field_name field_type_specification? + ; + +field_type_specification + : EQUALS field_type + ; + +field_type + : type_expr + ; + +open_record_marker + : ELLIPSES + ; + +list_type + : OPEN_BRACE item_type CLOSE_BRACE + ; + +item_type + : type_expr + ; + +function_type + : FUNCTION_START parameter_specification_list? CLOSE_PAREN return_type + ; + +parameter_specification_list + : required_parameter_specification_list + | required_parameter_specification_list COMMA optional_parameter_specification_list + | optional_parameter_specification_list + ; + +required_parameter_specification_list + : required_parameter_specification + | required_parameter_specification COMMA required_parameter_specification_list + ; + +required_parameter_specification + : parameter_specification + ; + +optional_parameter_specification_list + : optional_parameter_specification + | optional_parameter_specification COMMA optional_parameter_specification_list + ; + +optional_parameter_specification + : OPTIONAL_TEXT parameter_specification + ; + +parameter_specification + : parameter_name parameter_type + ; + +table_type + : TABLE row_type + ; + +row_type + : OPEN_BRACKET field_specification_list CLOSE_BRACKET + ; + +nullable_type + : NULLABLE type_expr + ; + +error_raising_expression + : ERROR expression + ; + +error_handling_expression + : TRY protected_expression otherwise_clause? + ; + +protected_expression + : expression + ; + +otherwise_clause + : OTHERWISE default_expression + ; + +default_expression + : expression + ; + +literal_attribs + : record_literal + ; + +record_literal + : OPEN_BRACKET literal_field_list? CLOSE_BRACKET + ; + +literal_field_list + : literal_field + | literal_field COMMA literal_field_list + ; + +literal_field + : field_name EQUALS any_literal + ; + +list_literal + : OPEN_BRACE literal_item_list? CLOSE_BRACE + ; + +literal_item_list + : any_literal + | any_literal COMMA literal_item_list + ; + +any_literal + : record_literal + | list_literal + | LITERAL + ; \ No newline at end of file diff --git a/prolog/prolog.g4 b/prolog/prolog.g4 index eae18dd79b..540ab509a0 100644 --- a/prolog/prolog.g4 +++ b/prolog/prolog.g4 @@ -30,75 +30,105 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -grammar prolog; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging +grammar prolog; // Prolog text and data formed from terms (6.2) -p_text: (directive | clause) * EOF ; - -directive: ':-' term '.' ; // also 3.58 +p_text + : (directive | clause)* EOF + ; -clause: term '.' ; // also 3.33 +directive + : ':-' term '.' + ; // also 3.58 +clause + : term '.' + ; // also 3.33 // Abstract Syntax (6.3): terms formed from tokens termlist - : term ( ',' term )* + : term (',' term)* ; -term - : VARIABLE # variable - | '(' term ')' # braced_term - | '-'? integer # integer_term //TODO: negative case should be covered by unary_operator - | '-'? FLOAT # float +term + : VARIABLE # variable + | '(' term ')' # braced_term + | '-'? integer # integer_term //TODO: negative case should be covered by unary_operator + | '-'? FLOAT # float // structure / compound term - | atom '(' termlist ')' # compound_term - | term operator_ term # binary_operator - | operator_ term # unary_operator - | '[' termlist ( '|' term )? ']' # list_term - | '{' termlist '}' # curly_bracketed_term - - | atom # atom_term + | atom '(' termlist ')' # compound_term + | term operator_ term # binary_operator + | operator_ term # unary_operator + | '[' termlist ( '|' term)? ']' # list_term + | '{' termlist '}' # curly_bracketed_term + | atom # atom_term ; //TODO: operator priority, associativity, arity. Filter valid priority ranges for e.g. [list] syntax //TODO: modifying operator table operator_ - : ':-' | '-->' + : ':-' + | '-->' | '?-' - | 'dynamic' | 'multifile' | 'discontiguous' | 'public' //TODO: move operators used in directives to "built-in" definition of dialect + | 'dynamic' + | 'multifile' + | 'discontiguous' + | 'public' //TODO: move operators used in directives to "built-in" definition of dialect | ';' | '->' | ',' | '\\+' - | '=' | '\\=' - | '==' | '\\==' | '@<' | '@=<' | '@>' | '@>=' + | '=' + | '\\=' + | '==' + | '\\==' + | '@<' + | '@=<' + | '@>' + | '@>=' | '=..' - | 'is' | '=:=' | '=\\=' | '<' | '=<' | '>' | '>=' + | 'is' + | '=:=' + | '=\\=' + | '<' + | '=<' + | '>' + | '>=' | ':' // modules: 5.2.1 - | '+' | '-' | '/\\' | '\\/' - | '*' | '/' | '//' | 'rem' | 'mod' | '<<' | '>>' //TODO: '/' cannot be used as atom because token here not in GRAPHIC. only works because , is operator too. example: swipl/filesex.pl:177 + | '+' + | '-' + | '/\\' + | '\\/' + | '*' + | '/' + | '//' + | 'rem' + | 'mod' + | '<<' + | '>>' //TODO: '/' cannot be used as atom because token here not in GRAPHIC. only works because , is operator too. example: swipl/filesex.pl:177 | '**' | '^' | '\\' ; -atom // 6.4.2 and 6.1.2 - : '[' ']' # empty_list //NOTE [] is not atom anymore in swipl 7 and later - | '{' '}' # empty_braces - | LETTER_DIGIT # name - | GRAPHIC_TOKEN # graphic - | QUOTED # quoted_string - | DOUBLE_QUOTED_LIST# dq_string - | BACK_QUOTED_STRING# backq_string - | ';' # semicolon - | '!' # cut +atom // 6.4.2 and 6.1.2 + : '[' ']' # empty_list //NOTE [] is not atom anymore in swipl 7 and later + | '{' '}' # empty_braces + | LETTER_DIGIT # name + | GRAPHIC_TOKEN # graphic + | QUOTED # quoted_string + | DOUBLE_QUOTED_LIST # dq_string + | BACK_QUOTED_STRING # backq_string + | ';' # semicolon + | '!' # cut ; - integer // 6.4.4 : DECIMAL | CHARACTER_CODE_CONSTANT @@ -107,7 +137,6 @@ integer // 6.4.4 | HEX ; - // Lexer (6.4 & 6.5): Tokens formed from Characters LETTER_DIGIT // 6.4.2 @@ -121,23 +150,61 @@ VARIABLE // 6.4.3 ; // 6.4.4 -DECIMAL: DIGIT+ ; -BINARY: '0b' [01]+ ; -OCTAL: '0o' [0-7]+ ; -HEX: '0x' HEX_DIGIT+ ; +DECIMAL + : DIGIT+ + ; + +BINARY + : '0b' [01]+ + ; + +OCTAL + : '0o' [0-7]+ + ; -CHARACTER_CODE_CONSTANT: '0' '\'' SINGLE_QUOTED_CHARACTER ; +HEX + : '0x' HEX_DIGIT+ + ; + +CHARACTER_CODE_CONSTANT + : '0' '\'' SINGLE_QUOTED_CHARACTER + ; -FLOAT: DECIMAL '.' [0-9]+ ( [eE] [+-] DECIMAL )? ; +FLOAT + : DECIMAL '.' [0-9]+ ([eE] [+-] DECIMAL)? + ; +GRAPHIC_TOKEN + : (GRAPHIC | '\\')+ + ; // 6.4.2 -GRAPHIC_TOKEN: (GRAPHIC | '\\')+ ; // 6.4.2 -fragment GRAPHIC: [#$&*+./:<=>?@^~] | '-' ; // 6.5.1 graphic char +fragment GRAPHIC + : [#$&*+./:<=>?@^~] + | '-' + ; // 6.5.1 graphic char // 6.4.2.1 -fragment SINGLE_QUOTED_CHARACTER: NON_QUOTE_CHAR | '\'\'' | '"' | '`' ; -fragment DOUBLE_QUOTED_CHARACTER: NON_QUOTE_CHAR | '\'' | '""' | '`' ; -fragment BACK_QUOTED_CHARACTER: NON_QUOTE_CHAR | '\'' | '"' | '``' ; +fragment SINGLE_QUOTED_CHARACTER + : NON_QUOTE_CHAR + | '\'\'' + | '"' + | '`' + ; + +fragment DOUBLE_QUOTED_CHARACTER + : NON_QUOTE_CHAR + | '\'' + | '""' + | '`' + ; + +fragment BACK_QUOTED_CHARACTER + : NON_QUOTE_CHAR + | '\'' + | '"' + | '``' + ; + fragment NON_QUOTE_CHAR : GRAPHIC | ALPHANUMERIC @@ -148,33 +215,81 @@ fragment NON_QUOTE_CHAR | OCTAL_ESCAPE | HEX_ESCAPE ; -fragment META_ESCAPE: '\\' [\\'"`] ; // meta char -fragment CONTROL_ESCAPE: '\\' [abrftnv] ; -fragment OCTAL_ESCAPE: '\\' [0-7]+ '\\' ; -fragment HEX_ESCAPE: '\\x' HEX_DIGIT+ '\\' ; -QUOTED: '\'' (CONTINUATION_ESCAPE | SINGLE_QUOTED_CHARACTER )*? '\'' ; // 6.4.2 -DOUBLE_QUOTED_LIST: '"' (CONTINUATION_ESCAPE | DOUBLE_QUOTED_CHARACTER )*? '"'; // 6.4.6 -BACK_QUOTED_STRING: '`' (CONTINUATION_ESCAPE | BACK_QUOTED_CHARACTER )*? '`'; // 6.4.7 -fragment CONTINUATION_ESCAPE: '\\\n' ; +fragment META_ESCAPE + : '\\' [\\'"`] + ; // meta char + +fragment CONTROL_ESCAPE + : '\\' [abrftnv] + ; + +fragment OCTAL_ESCAPE + : '\\' [0-7]+ '\\' + ; + +fragment HEX_ESCAPE + : '\\x' HEX_DIGIT+ '\\' + ; + +QUOTED + : '\'' (CONTINUATION_ESCAPE | SINGLE_QUOTED_CHARACTER)*? '\'' + ; // 6.4.2 + +DOUBLE_QUOTED_LIST + : '"' (CONTINUATION_ESCAPE | DOUBLE_QUOTED_CHARACTER)*? '"' + ; // 6.4.6 + +BACK_QUOTED_STRING + : '`' (CONTINUATION_ESCAPE | BACK_QUOTED_CHARACTER)*? '`' + ; // 6.4.7 + +fragment CONTINUATION_ESCAPE + : '\\\n' + ; // 6.5.2 -fragment ALPHANUMERIC: ALPHA | DIGIT ; -fragment ALPHA: '_' | SMALL_LETTER | CAPITAL_LETTER ; -fragment SMALL_LETTER: [a-z_]; +fragment ALPHANUMERIC + : ALPHA + | DIGIT + ; -fragment CAPITAL_LETTER: [A-Z]; +fragment ALPHA + : '_' + | SMALL_LETTER + | CAPITAL_LETTER + ; -fragment DIGIT: [0-9] ; -fragment HEX_DIGIT: [0-9a-fA-F] ; +fragment SMALL_LETTER + : [a-z_] + ; -// 6.5.3 -fragment SOLO: [!(),;[{}|%] | ']' ; +fragment CAPITAL_LETTER + : [A-Z] + ; + +fragment DIGIT + : [0-9] + ; +fragment HEX_DIGIT + : [0-9a-fA-F] + ; + +// 6.5.3 +fragment SOLO + : [!(),;[{}|%] + | ']' + ; WS - : [ \t\r\n]+ -> skip - ; + : [ \t\r\n]+ -> skip + ; + +COMMENT + : '%' ~[\n\r]* ([\n\r] | EOF) -> channel(HIDDEN) + ; -COMMENT: '%' ~[\n\r]* ( [\n\r] | EOF) -> channel(HIDDEN) ; -MULTILINE_COMMENT: '/*' ( MULTILINE_COMMENT | . )*? ('*/' | EOF) -> channel(HIDDEN); +MULTILINE_COMMENT + : '/*' (MULTILINE_COMMENT | .)*? ('*/' | EOF) -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/promql/PromQLLexer.g4 b/promql/PromQLLexer.g4 index eddb383239..b273b6054b 100644 --- a/promql/PromQLLexer.g4 +++ b/promql/PromQLLexer.g4 @@ -26,72 +26,74 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PromQLLexer; -channels { WHITESPACE, COMMENTS } +channels { + WHITESPACE, + COMMENTS +} // All keywords in PromQL are case insensitive, it is just function, // label and metric names that are not. -options { caseInsensitive=true; } +options { + caseInsensitive = true; +} fragment NUMERAL: [0-9]+ ('.' [0-9]+)?; -fragment SCIENTIFIC_NUMBER - : NUMERAL ('e' [-+]? NUMERAL)? - ; +fragment SCIENTIFIC_NUMBER: NUMERAL ('e' [-+]? NUMERAL)?; -NUMBER - : NUMERAL - | SCIENTIFIC_NUMBER; +NUMBER: NUMERAL | SCIENTIFIC_NUMBER; -STRING - : '\'' (~('\'' | '\\') | '\\' .)* '\'' - | '"' (~('"' | '\\') | '\\' .)* '"' - ; +STRING: '\'' (~('\'' | '\\') | '\\' .)* '\'' | '"' (~('"' | '\\') | '\\' .)* '"'; // Binary operators -ADD: '+'; -SUB: '-'; -MULT: '*'; -DIV: '/'; -MOD: '%'; -POW: '^'; +ADD : '+'; +SUB : '-'; +MULT : '*'; +DIV : '/'; +MOD : '%'; +POW : '^'; -AND: 'and'; -OR: 'or'; -UNLESS: 'unless'; +AND : 'and'; +OR : 'or'; +UNLESS : 'unless'; // Comparison operators -EQ: '='; -DEQ: '=='; -NE: '!='; -GT: '>'; -LT: '<'; -GE: '>='; -LE: '<='; -RE: '=~'; -NRE: '!~'; +EQ : '='; +DEQ : '=='; +NE : '!='; +GT : '>'; +LT : '<'; +GE : '>='; +LE : '<='; +RE : '=~'; +NRE : '!~'; // Aggregation modifiers -BY: 'by'; -WITHOUT: 'without'; +BY : 'by'; +WITHOUT : 'without'; // Join modifiers -ON: 'on'; -IGNORING: 'ignoring'; -GROUP_LEFT: 'group_left'; -GROUP_RIGHT: 'group_right'; +ON : 'on'; +IGNORING : 'ignoring'; +GROUP_LEFT : 'group_left'; +GROUP_RIGHT : 'group_right'; OFFSET: 'offset'; BOOL: 'bool'; -AGGREGATION_OPERATOR - : 'sum' +AGGREGATION_OPERATOR: + 'sum' | 'min' | 'max' | 'avg' @@ -103,10 +105,12 @@ AGGREGATION_OPERATOR | 'bottomk' | 'topk' | 'quantile' - ; +; -FUNCTION options { caseInsensitive=false; } - : 'abs' +FUNCTION options { + caseInsensitive = false; +}: + 'abs' | 'absent' | 'absent_over_time' | 'ceil' @@ -175,37 +179,30 @@ FUNCTION options { caseInsensitive=false; } | 'tanh' | 'deg' | 'pi' - | 'rad' - ; + | 'rad'; -LEFT_BRACE: '{'; -RIGHT_BRACE: '}'; +LEFT_BRACE : '{'; +RIGHT_BRACE : '}'; -LEFT_PAREN: '('; -RIGHT_PAREN: ')'; +LEFT_PAREN : '('; +RIGHT_PAREN : ')'; -LEFT_BRACKET: '['; -RIGHT_BRACKET: ']'; +LEFT_BRACKET : '['; +RIGHT_BRACKET : ']'; COMMA: ','; AT: '@'; -SUBQUERY_RANGE - : LEFT_BRACKET DURATION ':' DURATION? RIGHT_BRACKET; +SUBQUERY_RANGE: LEFT_BRACKET DURATION ':' DURATION? RIGHT_BRACKET; -TIME_RANGE - : LEFT_BRACKET DURATION RIGHT_BRACKET; +TIME_RANGE: LEFT_BRACKET DURATION RIGHT_BRACKET; // The proper order (longest to the shortest) must be validated after parsing DURATION: ([0-9]+ ('ms' | [smhdwy]))+; -METRIC_NAME: [a-z_:] [a-z0-9_:]*; -LABEL_NAME: [a-z_] [a-z0-9_]*; - - +METRIC_NAME : [a-z_:] [a-z0-9_:]*; +LABEL_NAME : [a-z_] [a-z0-9_]*; -WS: [\r\t\n ]+ -> channel(WHITESPACE); -SL_COMMENT - : '#' .*? '\n' -> channel(COMMENTS) - ; +WS : [\r\t\n ]+ -> channel(WHITESPACE); +SL_COMMENT : '#' .*? '\n' -> channel(COMMENTS); \ No newline at end of file diff --git a/promql/PromQLParser.g4 b/promql/PromQLParser.g4 index a513baf6cb..6ad7d93887 100644 --- a/promql/PromQLParser.g4 +++ b/promql/PromQLParser.g4 @@ -26,19 +26,26 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 PromQLParser; -options { tokenVocab = PromQLLexer; } +options { + tokenVocab = PromQLLexer; +} -expression: vectorOperation EOF; +expression + : vectorOperation EOF + ; // Binary operations are ordered by precedence // Unary operations have the same precedence as multiplications vectorOperation - : vectorOperation powOp vectorOperation - | vectorOperation subqueryOp + : vectorOperation powOp vectorOperation + | vectorOperation subqueryOp | unaryOp vectorOperation | vectorOperation multOp vectorOperation | vectorOperation addOp vectorOperation @@ -52,16 +59,45 @@ vectorOperation // Operators -unaryOp: (ADD | SUB); -powOp: POW grouping?; -multOp: (MULT | DIV | MOD) grouping?; -addOp: (ADD | SUB) grouping?; -compareOp: (DEQ | NE | GT | LT | GE | LE) BOOL? grouping?; -andUnlessOp: (AND | UNLESS) grouping?; -orOp: OR grouping?; -vectorMatchOp: (ON | UNLESS) grouping?; -subqueryOp: SUBQUERY_RANGE offsetOp?; -offsetOp: OFFSET DURATION; +unaryOp + : (ADD | SUB) + ; + +powOp + : POW grouping? + ; + +multOp + : (MULT | DIV | MOD) grouping? + ; + +addOp + : (ADD | SUB) grouping? + ; + +compareOp + : (DEQ | NE | GT | LT | GE | LE) BOOL? grouping? + ; + +andUnlessOp + : (AND | UNLESS) grouping? + ; + +orOp + : OR grouping? + ; + +vectorMatchOp + : (ON | UNLESS) grouping? + ; + +subqueryOp + : SUBQUERY_RANGE offsetOp? + ; + +offsetOp + : OFFSET DURATION + ; vector : function_ @@ -73,7 +109,9 @@ vector | parens ; -parens: LEFT_PAREN vectorOperation RIGHT_PAREN; +parens + : LEFT_PAREN vectorOperation RIGHT_PAREN + ; // Selectors @@ -82,11 +120,24 @@ instantSelector | LEFT_BRACE labelMatcherList RIGHT_BRACE ; -labelMatcher: labelName labelMatcherOperator STRING; -labelMatcherOperator: EQ | NE | RE | NRE; -labelMatcherList: labelMatcher (COMMA labelMatcher)* COMMA?; +labelMatcher + : labelName labelMatcherOperator STRING + ; + +labelMatcherOperator + : EQ + | NE + | RE + | NRE + ; + +labelMatcherList + : labelMatcher (COMMA labelMatcher)* COMMA? + ; -matrixSelector: instantSelector TIME_RANGE; +matrixSelector + : instantSelector TIME_RANGE + ; offset : instantSelector OFFSET DURATION @@ -95,10 +146,18 @@ offset // Functions -function_: FUNCTION LEFT_PAREN (parameter (COMMA parameter)*)? RIGHT_PAREN; +function_ + : FUNCTION LEFT_PAREN (parameter (COMMA parameter)*)? RIGHT_PAREN + ; + +parameter + : literal + | vectorOperation + ; -parameter: literal | vectorOperation; -parameterList: LEFT_PAREN (parameter (COMMA parameter)*)? RIGHT_PAREN; +parameterList + : LEFT_PAREN (parameter (COMMA parameter)*)? RIGHT_PAREN + ; // Aggregations @@ -107,21 +166,48 @@ aggregation | AGGREGATION_OPERATOR (by | without) parameterList | AGGREGATION_OPERATOR parameterList ( by | without) ; -by: BY labelNameList; -without: WITHOUT labelNameList; + +by + : BY labelNameList + ; + +without + : WITHOUT labelNameList + ; // Vector one-to-one/one-to-many joins -grouping: (on_ | ignoring) (groupLeft | groupRight)?; -on_: ON labelNameList; -ignoring: IGNORING labelNameList; -groupLeft: GROUP_LEFT labelNameList?; -groupRight: GROUP_RIGHT labelNameList?; +grouping + : (on_ | ignoring) (groupLeft | groupRight)? + ; + +on_ + : ON labelNameList + ; + +ignoring + : IGNORING labelNameList + ; + +groupLeft + : GROUP_LEFT labelNameList? + ; + +groupRight + : GROUP_RIGHT labelNameList? + ; // Label names -labelName: keyword | METRIC_NAME | LABEL_NAME; -labelNameList: LEFT_PAREN (labelName (COMMA labelName)*)? RIGHT_PAREN; +labelName + : keyword + | METRIC_NAME + | LABEL_NAME + ; + +labelNameList + : LEFT_PAREN (labelName (COMMA labelName)*)? RIGHT_PAREN + ; keyword : AND @@ -139,4 +225,7 @@ keyword | FUNCTION ; -literal: NUMBER | STRING; +literal + : NUMBER + | STRING + ; \ No newline at end of file diff --git a/propcalc/propcalc.g4 b/propcalc/propcalc.g4 index 3224a0e659..eaeffc4c91 100644 --- a/propcalc/propcalc.g4 +++ b/propcalc/propcalc.g4 @@ -30,95 +30,88 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar propcalc; proposition - : expression THEREFORE expression EOF - ; + : expression THEREFORE expression EOF + ; expression - : relExpression ((AND | OR) relExpression)* - ; + : relExpression ((AND | OR) relExpression)* + ; relExpression - : atom - | equiv - | implies - ; + : atom + | equiv + | implies + ; atoms - : atom (',' atom)* - ; + : atom (',' atom)* + ; atom - : variable - | NOT atom - | LPAREN expression RPAREN - ; + : variable + | NOT atom + | LPAREN expression RPAREN + ; equiv - : atom EQUIV atom - ; + : atom EQUIV atom + ; implies - : atom IMPLIES atom - ; + : atom IMPLIES atom + ; variable - : LETTER* - ; - + : LETTER* + ; AND - : '^' - ; - + : '^' + ; OR - : 'v' - ; - + : 'v' + ; NOT - : '!' - ; - + : '!' + ; EQ - : '=' - ; - + : '=' + ; IMPLIES - : '->' - ; - + : '->' + ; THEREFORE - : '|-' - ; - + : '|-' + ; EQUIV - : '<->' - ; - + : '<->' + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; LETTER - : ('a' .. 'z') | ('A' .. 'Z') - ; - + : ('a' .. 'z') + | ('A' .. 'Z') + ; WS - : [ \r\n\t] + -> channel (HIDDEN) - ; + : [ \r\n\t]+ -> channel (HIDDEN) + ; \ No newline at end of file diff --git a/properties/PropertiesLexer.g4 b/properties/PropertiesLexer.g4 index 9af46d799b..b04e840d8c 100644 --- a/properties/PropertiesLexer.g4 +++ b/properties/PropertiesLexer.g4 @@ -1,27 +1,21 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PropertiesLexer; -COMMENT - : [!#] ~[\r\n]* - ; -NEWLINE - : [\r\n]+ - ; -DELIMITER - : [:=] -> pushMode(VALUE_MODE) - ; -SLASH - : '\\' -> more, pushMode(INSIDE) - ; -CHARACTER - : ~ [!#:=\r\n] - ; +COMMENT : [!#] ~[\r\n]*; +NEWLINE : [\r\n]+; +DELIMITER : [:=] -> pushMode(VALUE_MODE); +SLASH : '\\' -> more, pushMode(INSIDE); +CHARACTER : ~ [!#:=\r\n]; mode INSIDE; -SLASH_DELIMITER: ~[\r\n] -> type(CHARACTER), popMode; -SLASH_JOINT: '\r'? '\n' -> type(CHARACTER), popMode; +SLASH_DELIMITER : ~[\r\n] -> type(CHARACTER), popMode; +SLASH_JOINT : '\r'? '\n' -> type(CHARACTER), popMode; mode VALUE_MODE; -VALUE_TERM: '\r'? '\n' -> type(NEWLINE), popMode; -VALUE_SLASH: '\\' -> more, pushMode(INSIDE); -VALUE_CHARACTER: ~ [\r\n] -> type(CHARACTER); +VALUE_TERM : '\r'? '\n' -> type(NEWLINE), popMode; +VALUE_SLASH : '\\' -> more, pushMode(INSIDE); +VALUE_CHARACTER : ~ [\r\n] -> type(CHARACTER); \ No newline at end of file diff --git a/properties/PropertiesParser.g4 b/properties/PropertiesParser.g4 index badbbc4d19..9fe8ff243b 100644 --- a/properties/PropertiesParser.g4 +++ b/properties/PropertiesParser.g4 @@ -1,24 +1,34 @@ +// $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 PropertiesParser; -options { tokenVocab=PropertiesLexer; } +options { + tokenVocab = PropertiesLexer; +} propertiesFile : row* ; + row : comment | line ; + line - : key (DELIMITER value=key?)? eol + : key (DELIMITER value = key?)? eol ; + key : CHARACTER+ ; + eol : NEWLINE+ | EOF ; + comment : COMMENT eol ; \ No newline at end of file diff --git a/protobuf2/Protobuf2.g4 b/protobuf2/Protobuf2.g4 index 3603f10f8f..437349b2d3 100644 --- a/protobuf2/Protobuf2.g4 +++ b/protobuf2/Protobuf2.g4 @@ -8,418 +8,702 @@ * @author Boyce-Lee */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Protobuf2; proto - : syntax - ( - importStatement - | packageStatement - | optionStatement - | topLevelDef - | emptyStatement_ - )* EOF - ; + : syntax (importStatement | packageStatement | optionStatement | topLevelDef | emptyStatement_)* EOF + ; // Syntax syntax - : SYNTAX EQ (PROTO2_LIT_SINGLE | PROTO2_LIT_DOBULE) SEMI - ; + : SYNTAX EQ (PROTO2_LIT_SINGLE | PROTO2_LIT_DOBULE) SEMI + ; // Import Statement importStatement - : IMPORT ( WEAK | PUBLIC )? strLit SEMI - ; + : IMPORT (WEAK | PUBLIC)? strLit SEMI + ; // Package packageStatement - : PACKAGE fullIdent SEMI - ; + : PACKAGE fullIdent SEMI + ; // Option optionStatement - : OPTION optionName EQ constant SEMI - ; + : OPTION optionName EQ constant SEMI + ; optionName - : fullIdent - | ( ident | LP fullIdent RP ) ( DOT fullIdent )? - ; + : fullIdent + | ( ident | LP fullIdent RP) ( DOT fullIdent)? + ; // Normal Field fieldLabel - : REQUIRED | OPTIONAL | REPEATED - ; + : REQUIRED + | OPTIONAL + | REPEATED + ; field - : fieldLabel type_ fieldName EQ fieldNumber ( LB fieldOptions RB )? SEMI - ; + : fieldLabel type_ fieldName EQ fieldNumber (LB fieldOptions RB)? SEMI + ; fieldOptions - : fieldOption ( COMMA fieldOption )* - ; + : fieldOption (COMMA fieldOption)* + ; fieldOption - : optionName EQ constant - ; + : optionName EQ constant + ; fieldNumber - : intLit - ; + : intLit + ; // Group field group - : fieldLabel GROUP groupName EQ fieldNumber messageBody - ; + : fieldLabel GROUP groupName EQ fieldNumber messageBody + ; // Oneof and oneof field oneof - : ONEOF oneofName LC ( optionStatement | oneofField | emptyStatement_ )* RC - ; + : ONEOF oneofName LC (optionStatement | oneofField | emptyStatement_)* RC + ; oneofField - : type_ fieldName EQ fieldNumber ( LB fieldOptions RB )? SEMI - ; + : type_ fieldName EQ fieldNumber (LB fieldOptions RB)? SEMI + ; // Map field mapField - : MAP LT keyType COMMA type_ GT mapName - EQ fieldNumber ( LB fieldOptions RB )? SEMI - ; + : MAP LT keyType COMMA type_ GT mapName EQ fieldNumber (LB fieldOptions RB)? SEMI + ; + keyType - : INT32 - | INT64 - | UINT32 - | UINT64 - | SINT32 - | SINT64 - | FIXED32 - | FIXED64 - | SFIXED32 - | SFIXED64 - | BOOL - | STRING - ; + : INT32 + | INT64 + | UINT32 + | UINT64 + | SINT32 + | SINT64 + | FIXED32 + | FIXED64 + | SFIXED32 + | SFIXED64 + | BOOL + | STRING + ; // field types type_ - : DOUBLE - | FLOAT - | INT32 - | INT64 - | UINT32 - | UINT64 - | SINT32 - | SINT64 - | FIXED32 - | FIXED64 - | SFIXED32 - | SFIXED64 - | BOOL - | STRING - | BYTES - | messageType - | enumType - ; + : DOUBLE + | FLOAT + | INT32 + | INT64 + | UINT32 + | UINT64 + | SINT32 + | SINT64 + | FIXED32 + | FIXED64 + | SFIXED32 + | SFIXED64 + | BOOL + | STRING + | BYTES + | messageType + | enumType + ; // Extensions extensions - : EXTENSIONS ranges SEMI - ; + : EXTENSIONS ranges SEMI + ; // Reserved reserved - : RESERVED ( ranges | reservedFieldNames ) SEMI - ; + : RESERVED (ranges | reservedFieldNames) SEMI + ; ranges - : range_ ( COMMA range_ )* - ; + : range_ (COMMA range_)* + ; range_ - : intLit ( TO ( intLit | MAX ) )? - ; + : intLit (TO ( intLit | MAX))? + ; reservedFieldNames - : strLit ( COMMA strLit )* - ; + : strLit (COMMA strLit)* + ; // Top Level definitions topLevelDef - : messageDef - | enumDef - | serviceDef - | extendDef - ; + : messageDef + | enumDef + | serviceDef + | extendDef + ; // enum enumDef - : ENUM enumName enumBody - ; + : ENUM enumName enumBody + ; enumBody - : LC enumElement* RC - ; + : LC enumElement* RC + ; enumElement - : optionStatement - | enumField - | emptyStatement_ - ; + : optionStatement + | enumField + | emptyStatement_ + ; enumField - : ident EQ MINUS? intLit enumValueOptions?SEMI - ; + : ident EQ MINUS? intLit enumValueOptions? SEMI + ; enumValueOptions - : LB enumValueOption ( COMMA enumValueOption )* RB - ; + : LB enumValueOption (COMMA enumValueOption)* RB + ; enumValueOption - : optionName EQ constant - ; + : optionName EQ constant + ; // message messageDef - : MESSAGE messageName messageBody - ; + : MESSAGE messageName messageBody + ; messageBody - : LC messageElement* RC - ; + : LC messageElement* RC + ; messageElement - : field - | enumDef - | messageDef - | extendDef - | optionStatement - | oneof - | mapField - | extensions - | group - | reserved - | emptyStatement_ - ; + : field + | enumDef + | messageDef + | extendDef + | optionStatement + | oneof + | mapField + | extensions + | group + | reserved + | emptyStatement_ + ; // extend extendDef - : EXTEND messageType LC extendElement* RC - ; + : EXTEND messageType LC extendElement* RC + ; extendElement - : field - | group - | emptyStatement_ - ; + : field + | group + | emptyStatement_ + ; // service serviceDef - : SERVICE serviceName LC serviceElement* RC - ; + : SERVICE serviceName LC serviceElement* RC + ; serviceElement - : optionStatement - | rpc - | stream - | emptyStatement_ - ; + : optionStatement + | rpc + | stream + | emptyStatement_ + ; rpc - : RPC rpcName LP STREAM? messageType RP - RETURNS LP STREAM? messageType RP - (LC ( optionStatement | emptyStatement_ )* RC | SEMI) - ; + : RPC rpcName LP STREAM? messageType RP RETURNS LP STREAM? messageType RP ( + LC ( optionStatement | emptyStatement_)* RC + | SEMI + ) + ; stream - : STREAM streamName LP messageType COMMA messageType RP - ( LC ( optionStatement | emptyStatement_ )* RC | SEMI ) - ; + : STREAM streamName LP messageType COMMA messageType RP ( + LC ( optionStatement | emptyStatement_)* RC + | SEMI + ) + ; // lexical constant - : fullIdent - | (MINUS | PLUS )? intLit - | ( MINUS | PLUS )? floatLit - | strLit - | boolLit - | blockLit - ; + : fullIdent + | (MINUS | PLUS)? intLit + | ( MINUS | PLUS)? floatLit + | strLit + | boolLit + | blockLit + ; // not specified in specification but used in tests blockLit - : LC ( ident COLON constant )* RC - ; + : LC (ident COLON constant)* RC + ; -emptyStatement_: SEMI; +emptyStatement_ + : SEMI + ; // Lexical elements -ident: IDENTIFIER | keywords; -fullIdent: ident ( DOT ident )*; -messageName: ident; -enumName: ident; -fieldName: ident; -groupName: ident; -oneofName: ident; -mapName: ident; -serviceName: ident; -rpcName: ident; -streamName: ident; -messageType: DOT? ( ident DOT )* messageName; -enumType: DOT? ( ident DOT )* enumName; - -intLit: INT_LIT; -strLit: STR_LIT | PROTO2_LIT_SINGLE | PROTO2_LIT_DOBULE; -boolLit: BOOL_LIT; -floatLit: FLOAT_LIT; +ident + : IDENTIFIER + | keywords + ; + +fullIdent + : ident (DOT ident)* + ; + +messageName + : ident + ; + +enumName + : ident + ; + +fieldName + : ident + ; + +groupName + : ident + ; + +oneofName + : ident + ; + +mapName + : ident + ; + +serviceName + : ident + ; + +rpcName + : ident + ; + +streamName + : ident + ; + +messageType + : DOT? (ident DOT)* messageName + ; + +enumType + : DOT? (ident DOT)* enumName + ; + +intLit + : INT_LIT + ; + +strLit + : STR_LIT + | PROTO2_LIT_SINGLE + | PROTO2_LIT_DOBULE + ; + +boolLit + : BOOL_LIT + ; + +floatLit + : FLOAT_LIT + ; // keywords -SYNTAX: 'syntax'; -IMPORT: 'import'; -WEAK: 'weak'; -PUBLIC: 'public'; -PACKAGE: 'package'; -OPTION: 'option'; -REPEATED: 'repeated'; -OPTIONAL: 'optional'; -REQUIRED: 'required'; -GROUP: 'group'; -ONEOF: 'oneof'; -MAP: 'map'; -INT32: 'int32'; -INT64: 'int64'; -UINT32: 'uint32'; -UINT64: 'uint64'; -SINT32: 'sint32'; -SINT64: 'sint64'; -FIXED32: 'fixed32'; -FIXED64: 'fixed64'; -SFIXED32: 'sfixed32'; -SFIXED64: 'sfixed64'; -BOOL: 'bool'; -STRING: 'string'; -DOUBLE: 'double'; -FLOAT: 'float'; -BYTES: 'bytes'; -RESERVED: 'reserved'; -EXTENSIONS: 'extensions'; -TO: 'to'; -MAX: 'max'; -ENUM: 'enum'; -EXTEND: 'extend'; -MESSAGE: 'message'; -SERVICE: 'service'; -RPC: 'rpc'; -STREAM: 'stream'; -RETURNS: 'returns'; - -PROTO2_LIT_SINGLE: '"proto2"'; -PROTO2_LIT_DOBULE: '\'proto2\''; +SYNTAX + : 'syntax' + ; + +IMPORT + : 'import' + ; + +WEAK + : 'weak' + ; + +PUBLIC + : 'public' + ; + +PACKAGE + : 'package' + ; + +OPTION + : 'option' + ; + +REPEATED + : 'repeated' + ; + +OPTIONAL + : 'optional' + ; + +REQUIRED + : 'required' + ; + +GROUP + : 'group' + ; + +ONEOF + : 'oneof' + ; + +MAP + : 'map' + ; + +INT32 + : 'int32' + ; + +INT64 + : 'int64' + ; + +UINT32 + : 'uint32' + ; + +UINT64 + : 'uint64' + ; + +SINT32 + : 'sint32' + ; + +SINT64 + : 'sint64' + ; + +FIXED32 + : 'fixed32' + ; + +FIXED64 + : 'fixed64' + ; + +SFIXED32 + : 'sfixed32' + ; + +SFIXED64 + : 'sfixed64' + ; + +BOOL + : 'bool' + ; + +STRING + : 'string' + ; + +DOUBLE + : 'double' + ; + +FLOAT + : 'float' + ; + +BYTES + : 'bytes' + ; + +RESERVED + : 'reserved' + ; + +EXTENSIONS + : 'extensions' + ; + +TO + : 'to' + ; + +MAX + : 'max' + ; + +ENUM + : 'enum' + ; + +EXTEND + : 'extend' + ; + +MESSAGE + : 'message' + ; + +SERVICE + : 'service' + ; + +RPC + : 'rpc' + ; + +STREAM + : 'stream' + ; + +RETURNS + : 'returns' + ; + +PROTO2_LIT_SINGLE + : '"proto2"' + ; + +PROTO2_LIT_DOBULE + : '\'proto2\'' + ; // symbols -SEMI: ';'; -EQ: '='; -LP: '('; -RP: ')'; -LB: '['; -RB: ']'; -LC: '{'; -RC: '}'; -LT: '<'; -GT: '>'; -DOT: '.'; -COMMA: ','; -COLON: ':'; -PLUS: '+'; -MINUS: '-'; - -STR_LIT: '\'' CHAR_VALUE*? '\'' | '"' CHAR_VALUE*? '"'; -fragment CHAR_VALUE: HEX_ESCAPE | OCT_ESCAPE | CHAR_ESCAPE | ~[\u0000\n\\]; -fragment HEX_ESCAPE: '\\' ( 'x' | 'X' ) HEX_DIGIT HEX_DIGIT; -fragment OCT_ESCAPE: '\\' OCTAL_DIGIT OCTAL_DIGIT OCTAL_DIGIT; -fragment CHAR_ESCAPE: '\\' ( 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '\'' | '"' ); - -BOOL_LIT: 'true' | 'false'; - -FLOAT_LIT : DECIMALS DOT DECIMALS? EXPONENT? | DECIMALS EXPONENT | DOT DECIMALS EXPONENT? | 'inf' | 'nan'; -fragment EXPONENT : ( 'e' | 'E' ) (PLUS | MINUS)? DECIMALS; -fragment DECIMALS : DECIMAL_DIGIT+; - -INT_LIT : DECIMAL_LIT | OCTAL_LIT | HEX_LIT; -fragment DECIMAL_LIT : [1-9] DECIMAL_DIGIT*; -fragment OCTAL_LIT : '0' OCTAL_DIGIT*; -fragment HEX_LIT : '0' ( 'x' | 'X' ) HEX_DIGIT+ ; - -IDENTIFIER: LETTER ( LETTER | DECIMAL_DIGIT )*; - -fragment LETTER: [A-Za-z_]; -fragment DECIMAL_DIGIT: [0-9]; -fragment OCTAL_DIGIT: [0-7]; -fragment HEX_DIGIT: [0-9A-Fa-f]; +SEMI + : ';' + ; + +EQ + : '=' + ; + +LP + : '(' + ; + +RP + : ')' + ; + +LB + : '[' + ; + +RB + : ']' + ; + +LC + : '{' + ; + +RC + : '}' + ; + +LT + : '<' + ; + +GT + : '>' + ; + +DOT + : '.' + ; + +COMMA + : ',' + ; + +COLON + : ':' + ; + +PLUS + : '+' + ; + +MINUS + : '-' + ; + +STR_LIT + : '\'' CHAR_VALUE*? '\'' + | '"' CHAR_VALUE*? '"' + ; + +fragment CHAR_VALUE + : HEX_ESCAPE + | OCT_ESCAPE + | CHAR_ESCAPE + | ~[\u0000\n\\] + ; + +fragment HEX_ESCAPE + : '\\' ('x' | 'X') HEX_DIGIT HEX_DIGIT + ; + +fragment OCT_ESCAPE + : '\\' OCTAL_DIGIT OCTAL_DIGIT OCTAL_DIGIT + ; + +fragment CHAR_ESCAPE + : '\\' ('a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '\'' | '"') + ; + +BOOL_LIT + : 'true' + | 'false' + ; + +FLOAT_LIT + : DECIMALS DOT DECIMALS? EXPONENT? + | DECIMALS EXPONENT + | DOT DECIMALS EXPONENT? + | 'inf' + | 'nan' + ; + +fragment EXPONENT + : ('e' | 'E') (PLUS | MINUS)? DECIMALS + ; + +fragment DECIMALS + : DECIMAL_DIGIT+ + ; + +INT_LIT + : DECIMAL_LIT + | OCTAL_LIT + | HEX_LIT + ; + +fragment DECIMAL_LIT + : [1-9] DECIMAL_DIGIT* + ; + +fragment OCTAL_LIT + : '0' OCTAL_DIGIT* + ; + +fragment HEX_LIT + : '0' ('x' | 'X') HEX_DIGIT+ + ; + +IDENTIFIER + : LETTER (LETTER | DECIMAL_DIGIT)* + ; + +fragment LETTER + : [A-Za-z_] + ; + +fragment DECIMAL_DIGIT + : [0-9] + ; + +fragment OCTAL_DIGIT + : [0-7] + ; + +fragment HEX_DIGIT + : [0-9A-Fa-f] + ; // comments -WS : [ \t\r\n\u000C]+ -> skip; -LINE_COMMENT: '//' ~[\r\n]* -> skip; -COMMENT: '/*' .*? '*/' -> skip; +WS + : [ \t\r\n\u000C]+ -> skip + ; + +LINE_COMMENT + : '//' ~[\r\n]* -> skip + ; + +COMMENT + : '/*' .*? '*/' -> skip + ; keywords - : SYNTAX - | IMPORT - | WEAK - | PUBLIC - | PACKAGE - | OPTION - | REPEATED - | OPTIONAL - | REQUIRED - | GROUP - | ONEOF - | MAP - | INT32 - | INT64 - | UINT32 - | UINT64 - | SINT32 - | SINT64 - | FIXED32 - | FIXED64 - | SFIXED32 - | SFIXED64 - | BOOL - | STRING - | DOUBLE - | FLOAT - | BYTES - | RESERVED - | EXTENSIONS - | TO - | MAX - | ENUM - | MESSAGE - | EXTEND - | SERVICE - | RPC - | STREAM - | STREAM - | RETURNS - | BOOL_LIT - ; + : SYNTAX + | IMPORT + | WEAK + | PUBLIC + | PACKAGE + | OPTION + | REPEATED + | OPTIONAL + | REQUIRED + | GROUP + | ONEOF + | MAP + | INT32 + | INT64 + | UINT32 + | UINT64 + | SINT32 + | SINT64 + | FIXED32 + | FIXED64 + | SFIXED32 + | SFIXED64 + | BOOL + | STRING + | DOUBLE + | FLOAT + | BYTES + | RESERVED + | EXTENSIONS + | TO + | MAX + | ENUM + | MESSAGE + | EXTEND + | SERVICE + | RPC + | STREAM + | STREAM + | RETURNS + | BOOL_LIT + ; \ No newline at end of file diff --git a/protobuf3/Protobuf3.g4 b/protobuf3/Protobuf3.g4 index 0f84c0713f..bb7302d125 100644 --- a/protobuf3/Protobuf3.g4 +++ b/protobuf3/Protobuf3.g4 @@ -12,198 +12,195 @@ * @author anatawa12 */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Protobuf3; proto - : syntax - ( - importStatement - | packageStatement - | optionStatement - | topLevelDef - | emptyStatement_ - )* EOF - ; + : syntax (importStatement | packageStatement | optionStatement | topLevelDef | emptyStatement_)* EOF + ; // Syntax syntax - : SYNTAX EQ (PROTO3_LIT_SINGLE | PROTO3_LIT_DOBULE) SEMI - ; + : SYNTAX EQ (PROTO3_LIT_SINGLE | PROTO3_LIT_DOBULE) SEMI + ; // Import Statement importStatement - : IMPORT ( WEAK | PUBLIC )? strLit SEMI - ; + : IMPORT (WEAK | PUBLIC)? strLit SEMI + ; // Package packageStatement - : PACKAGE fullIdent SEMI - ; + : PACKAGE fullIdent SEMI + ; // Option optionStatement - : OPTION optionName EQ constant SEMI - ; + : OPTION optionName EQ constant SEMI + ; optionName - : fullIdent - | LP fullIdent RP ( DOT fullIdent )? - ; + : fullIdent + | LP fullIdent RP ( DOT fullIdent)? + ; // Normal Field fieldLabel - : OPTIONAL | REPEATED - ; + : OPTIONAL + | REPEATED + ; field - : fieldLabel? type_ fieldName EQ fieldNumber ( LB fieldOptions RB )? SEMI - ; + : fieldLabel? type_ fieldName EQ fieldNumber (LB fieldOptions RB)? SEMI + ; fieldOptions - : fieldOption ( COMMA fieldOption )* - ; + : fieldOption (COMMA fieldOption)* + ; fieldOption - : optionName EQ constant - ; + : optionName EQ constant + ; fieldNumber - : intLit - ; + : intLit + ; // Oneof and oneof field oneof - : ONEOF oneofName LC ( optionStatement | oneofField | emptyStatement_ )* RC - ; + : ONEOF oneofName LC (optionStatement | oneofField | emptyStatement_)* RC + ; oneofField - : type_ fieldName EQ fieldNumber ( LB fieldOptions RB )? SEMI - ; + : type_ fieldName EQ fieldNumber (LB fieldOptions RB)? SEMI + ; // Map field mapField - : MAP LT keyType COMMA type_ GT mapName - EQ fieldNumber ( LB fieldOptions RB )? SEMI - ; + : MAP LT keyType COMMA type_ GT mapName EQ fieldNumber (LB fieldOptions RB)? SEMI + ; + keyType - : INT32 - | INT64 - | UINT32 - | UINT64 - | SINT32 - | SINT64 - | FIXED32 - | FIXED64 - | SFIXED32 - | SFIXED64 - | BOOL - | STRING - ; + : INT32 + | INT64 + | UINT32 + | UINT64 + | SINT32 + | SINT64 + | FIXED32 + | FIXED64 + | SFIXED32 + | SFIXED64 + | BOOL + | STRING + ; // field types type_ - : DOUBLE - | FLOAT - | INT32 - | INT64 - | UINT32 - | UINT64 - | SINT32 - | SINT64 - | FIXED32 - | FIXED64 - | SFIXED32 - | SFIXED64 - | BOOL - | STRING - | BYTES - | messageType - | enumType - ; + : DOUBLE + | FLOAT + | INT32 + | INT64 + | UINT32 + | UINT64 + | SINT32 + | SINT64 + | FIXED32 + | FIXED64 + | SFIXED32 + | SFIXED64 + | BOOL + | STRING + | BYTES + | messageType + | enumType + ; // Reserved reserved - : RESERVED ( ranges | reservedFieldNames ) SEMI - ; + : RESERVED (ranges | reservedFieldNames) SEMI + ; ranges - : range_ ( COMMA range_ )* - ; + : range_ (COMMA range_)* + ; range_ - : intLit ( TO ( intLit | MAX ) )? - ; + : intLit (TO ( intLit | MAX))? + ; reservedFieldNames - : strLit ( COMMA strLit )* - ; + : strLit (COMMA strLit)* + ; // Top Level definitions topLevelDef - : messageDef - | enumDef - | extendDef - | serviceDef - ; + : messageDef + | enumDef + | extendDef + | serviceDef + ; // enum enumDef - : ENUM enumName enumBody - ; + : ENUM enumName enumBody + ; enumBody - : LC enumElement* RC - ; + : LC enumElement* RC + ; enumElement - : optionStatement - | enumField - | emptyStatement_ - ; + : optionStatement + | enumField + | emptyStatement_ + ; enumField - : ident EQ ( MINUS )? intLit enumValueOptions?SEMI - ; + : ident EQ (MINUS)? intLit enumValueOptions? SEMI + ; enumValueOptions - : LB enumValueOption ( COMMA enumValueOption )* RB - ; + : LB enumValueOption (COMMA enumValueOption)* RB + ; enumValueOption - : optionName EQ constant - ; + : optionName EQ constant + ; // message messageDef - : MESSAGE messageName messageBody - ; + : MESSAGE messageName messageBody + ; messageBody - : LC messageElement* RC - ; + : LC messageElement* RC + ; messageElement - : field - | enumDef - | messageDef - | extendDef - | optionStatement - | oneof - | mapField - | reserved - | emptyStatement_ - ; + : field + | enumDef + | messageDef + | extendDef + | optionStatement + | oneof + | mapField + | reserved + | emptyStatement_ + ; // Extend definition // @@ -213,188 +210,453 @@ messageElement // it also was discussed here: https://github.com/protocolbuffers/protobuf/issues/4610 extendDef - : EXTEND messageType LC ( field - | emptyStatement_ - )* RC + : EXTEND messageType LC (field | emptyStatement_)* RC ; // service serviceDef - : SERVICE serviceName LC serviceElement* RC - ; + : SERVICE serviceName LC serviceElement* RC + ; serviceElement - : optionStatement - | rpc - | emptyStatement_ - ; + : optionStatement + | rpc + | emptyStatement_ + ; rpc - : RPC rpcName LP ( STREAM )? messageType RP - RETURNS LP ( STREAM )? messageType RP - (LC ( optionStatement | emptyStatement_ )* RC | SEMI) - ; + : RPC rpcName LP (STREAM)? messageType RP RETURNS LP (STREAM)? messageType RP ( + LC ( optionStatement | emptyStatement_)* RC + | SEMI + ) + ; // lexical constant - : fullIdent - | (MINUS | PLUS )? intLit - | ( MINUS | PLUS )? floatLit - | strLit - | boolLit - | blockLit - ; + : fullIdent + | (MINUS | PLUS)? intLit + | ( MINUS | PLUS)? floatLit + | strLit + | boolLit + | blockLit + ; // not specified in specification but used in tests blockLit - : LC ( ident COLON constant )* RC - ; + : LC (ident COLON constant)* RC + ; -emptyStatement_: SEMI; +emptyStatement_ + : SEMI + ; // Lexical elements -ident: IDENTIFIER | keywords; -fullIdent: ident ( DOT ident )*; -messageName: ident; -enumName: ident; -fieldName: ident; -oneofName: ident; -mapName: ident; -serviceName: ident; -rpcName: ident; -messageType: ( DOT )? ( ident DOT )* messageName; -enumType: ( DOT )? ( ident DOT )* enumName; - -intLit: INT_LIT; -strLit: STR_LIT | PROTO3_LIT_SINGLE | PROTO3_LIT_DOBULE; -boolLit: BOOL_LIT; -floatLit: FLOAT_LIT; +ident + : IDENTIFIER + | keywords + ; + +fullIdent + : ident (DOT ident)* + ; + +messageName + : ident + ; + +enumName + : ident + ; + +fieldName + : ident + ; + +oneofName + : ident + ; + +mapName + : ident + ; + +serviceName + : ident + ; + +rpcName + : ident + ; + +messageType + : (DOT)? (ident DOT)* messageName + ; + +enumType + : (DOT)? (ident DOT)* enumName + ; + +intLit + : INT_LIT + ; + +strLit + : STR_LIT + | PROTO3_LIT_SINGLE + | PROTO3_LIT_DOBULE + ; + +boolLit + : BOOL_LIT + ; + +floatLit + : FLOAT_LIT + ; // keywords -SYNTAX: 'syntax'; -IMPORT: 'import'; -WEAK: 'weak'; -PUBLIC: 'public'; -PACKAGE: 'package'; -OPTION: 'option'; -OPTIONAL: 'optional'; -REPEATED: 'repeated'; -ONEOF: 'oneof'; -MAP: 'map'; -INT32: 'int32'; -INT64: 'int64'; -UINT32: 'uint32'; -UINT64: 'uint64'; -SINT32: 'sint32'; -SINT64: 'sint64'; -FIXED32: 'fixed32'; -FIXED64: 'fixed64'; -SFIXED32: 'sfixed32'; -SFIXED64: 'sfixed64'; -BOOL: 'bool'; -STRING: 'string'; -DOUBLE: 'double'; -FLOAT: 'float'; -BYTES: 'bytes'; -RESERVED: 'reserved'; -TO: 'to'; -MAX: 'max'; -ENUM: 'enum'; -MESSAGE: 'message'; -SERVICE: 'service'; -EXTEND: 'extend'; -RPC: 'rpc'; -STREAM: 'stream'; -RETURNS: 'returns'; - -PROTO3_LIT_SINGLE: '"proto3"'; -PROTO3_LIT_DOBULE: '\'proto3\''; +SYNTAX + : 'syntax' + ; + +IMPORT + : 'import' + ; + +WEAK + : 'weak' + ; + +PUBLIC + : 'public' + ; + +PACKAGE + : 'package' + ; + +OPTION + : 'option' + ; + +OPTIONAL + : 'optional' + ; + +REPEATED + : 'repeated' + ; + +ONEOF + : 'oneof' + ; + +MAP + : 'map' + ; + +INT32 + : 'int32' + ; + +INT64 + : 'int64' + ; + +UINT32 + : 'uint32' + ; + +UINT64 + : 'uint64' + ; + +SINT32 + : 'sint32' + ; + +SINT64 + : 'sint64' + ; + +FIXED32 + : 'fixed32' + ; + +FIXED64 + : 'fixed64' + ; + +SFIXED32 + : 'sfixed32' + ; + +SFIXED64 + : 'sfixed64' + ; + +BOOL + : 'bool' + ; + +STRING + : 'string' + ; + +DOUBLE + : 'double' + ; + +FLOAT + : 'float' + ; + +BYTES + : 'bytes' + ; + +RESERVED + : 'reserved' + ; + +TO + : 'to' + ; + +MAX + : 'max' + ; + +ENUM + : 'enum' + ; + +MESSAGE + : 'message' + ; + +SERVICE + : 'service' + ; + +EXTEND + : 'extend' + ; + +RPC + : 'rpc' + ; + +STREAM + : 'stream' + ; + +RETURNS + : 'returns' + ; + +PROTO3_LIT_SINGLE + : '"proto3"' + ; + +PROTO3_LIT_DOBULE + : '\'proto3\'' + ; // symbols -SEMI: ';'; -EQ: '='; -LP: '('; -RP: ')'; -LB: '['; -RB: ']'; -LC: '{'; -RC: '}'; -LT: '<'; -GT: '>'; -DOT: '.'; -COMMA: ','; -COLON: ':'; -PLUS: '+'; -MINUS: '-'; - -STR_LIT: ( '\'' ( CHAR_VALUE )*? '\'' ) | ( '"' ( CHAR_VALUE )*? '"' ); -fragment CHAR_VALUE: HEX_ESCAPE | OCT_ESCAPE | CHAR_ESCAPE | ~[\u0000\n\\]; -fragment HEX_ESCAPE: '\\' ( 'x' | 'X' ) HEX_DIGIT HEX_DIGIT; -fragment OCT_ESCAPE: '\\' OCTAL_DIGIT OCTAL_DIGIT OCTAL_DIGIT; -fragment CHAR_ESCAPE: '\\' ( 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '\'' | '"' ); - -BOOL_LIT: 'true' | 'false'; - -FLOAT_LIT : ( DECIMALS DOT DECIMALS? EXPONENT? | DECIMALS EXPONENT | DOT DECIMALS EXPONENT? ) | 'inf' | 'nan'; -fragment EXPONENT : ( 'e' | 'E' ) (PLUS | MINUS)? DECIMALS; -fragment DECIMALS : DECIMAL_DIGIT+; - -INT_LIT : DECIMAL_LIT | OCTAL_LIT | HEX_LIT; -fragment DECIMAL_LIT : ( [1-9] ) DECIMAL_DIGIT*; -fragment OCTAL_LIT : '0' OCTAL_DIGIT*; -fragment HEX_LIT : '0' ( 'x' | 'X' ) HEX_DIGIT+ ; - -IDENTIFIER: LETTER ( LETTER | DECIMAL_DIGIT )*; - -fragment LETTER: [A-Za-z_]; -fragment DECIMAL_DIGIT: [0-9]; -fragment OCTAL_DIGIT: [0-7]; -fragment HEX_DIGIT: [0-9A-Fa-f]; +SEMI + : ';' + ; + +EQ + : '=' + ; + +LP + : '(' + ; + +RP + : ')' + ; + +LB + : '[' + ; + +RB + : ']' + ; + +LC + : '{' + ; + +RC + : '}' + ; + +LT + : '<' + ; + +GT + : '>' + ; + +DOT + : '.' + ; + +COMMA + : ',' + ; + +COLON + : ':' + ; + +PLUS + : '+' + ; + +MINUS + : '-' + ; + +STR_LIT + : ('\'' ( CHAR_VALUE)*? '\'') + | ( '"' ( CHAR_VALUE)*? '"') + ; + +fragment CHAR_VALUE + : HEX_ESCAPE + | OCT_ESCAPE + | CHAR_ESCAPE + | ~[\u0000\n\\] + ; + +fragment HEX_ESCAPE + : '\\' ('x' | 'X') HEX_DIGIT HEX_DIGIT + ; + +fragment OCT_ESCAPE + : '\\' OCTAL_DIGIT OCTAL_DIGIT OCTAL_DIGIT + ; + +fragment CHAR_ESCAPE + : '\\' ('a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '\'' | '"') + ; + +BOOL_LIT + : 'true' + | 'false' + ; + +FLOAT_LIT + : (DECIMALS DOT DECIMALS? EXPONENT? | DECIMALS EXPONENT | DOT DECIMALS EXPONENT?) + | 'inf' + | 'nan' + ; + +fragment EXPONENT + : ('e' | 'E') (PLUS | MINUS)? DECIMALS + ; + +fragment DECIMALS + : DECIMAL_DIGIT+ + ; + +INT_LIT + : DECIMAL_LIT + | OCTAL_LIT + | HEX_LIT + ; + +fragment DECIMAL_LIT + : ([1-9]) DECIMAL_DIGIT* + ; + +fragment OCTAL_LIT + : '0' OCTAL_DIGIT* + ; + +fragment HEX_LIT + : '0' ('x' | 'X') HEX_DIGIT+ + ; + +IDENTIFIER + : LETTER (LETTER | DECIMAL_DIGIT)* + ; + +fragment LETTER + : [A-Za-z_] + ; + +fragment DECIMAL_DIGIT + : [0-9] + ; + +fragment OCTAL_DIGIT + : [0-7] + ; + +fragment HEX_DIGIT + : [0-9A-Fa-f] + ; // comments -WS : [ \t\r\n\u000C]+ -> skip; -LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); -COMMENT: '/*' .*? '*/' -> channel(HIDDEN); +WS + : [ \t\r\n\u000C]+ -> skip + ; + +LINE_COMMENT + : '//' ~[\r\n]* -> channel(HIDDEN) + ; + +COMMENT + : '/*' .*? '*/' -> channel(HIDDEN) + ; keywords - : SYNTAX - | IMPORT - | WEAK - | PUBLIC - | PACKAGE - | OPTION - | OPTIONAL - | REPEATED - | ONEOF - | MAP - | INT32 - | INT64 - | UINT32 - | UINT64 - | SINT32 - | SINT64 - | FIXED32 - | FIXED64 - | SFIXED32 - | SFIXED64 - | BOOL - | STRING - | DOUBLE - | FLOAT - | BYTES - | RESERVED - | TO - | MAX - | ENUM - | MESSAGE - | SERVICE - | EXTEND - | RPC - | STREAM - | RETURNS - | BOOL_LIT - ; + : SYNTAX + | IMPORT + | WEAK + | PUBLIC + | PACKAGE + | OPTION + | OPTIONAL + | REPEATED + | ONEOF + | MAP + | INT32 + | INT64 + | UINT32 + | UINT64 + | SINT32 + | SINT64 + | FIXED32 + | FIXED64 + | SFIXED32 + | SFIXED64 + | BOOL + | STRING + | DOUBLE + | FLOAT + | BYTES + | RESERVED + | TO + | MAX + | ENUM + | MESSAGE + | SERVICE + | EXTEND + | RPC + | STREAM + | RETURNS + | BOOL_LIT + ; \ No newline at end of file diff --git a/prov-n/PROV_N.g4 b/prov-n/PROV_N.g4 index 38edc67fb8..72cd10d197 100644 --- a/prov-n/PROV_N.g4 +++ b/prov-n/PROV_N.g4 @@ -22,20 +22,23 @@ * */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar PROV_N; document - : DOCUMENT (namespaceDeclarations)? (expression)* (bundle (bundle)*)? ENDDOCUMENT EOF - ; + : DOCUMENT (namespaceDeclarations)? (expression)* (bundle (bundle)*)? ENDDOCUMENT EOF + ; /* parser */ namespaceDeclarations - : (defaultNamespaceDeclaration | namespaceDeclaration) namespaceDeclaration* - ; + : (defaultNamespaceDeclaration | namespaceDeclaration) namespaceDeclaration* + ; defaultNamespaceDeclaration - : 'default' IRI_REF - ; + : 'default' IRI_REF + ; /* TODO ambiquity with PREFIX token prefix ex -- is recognized as 'prefix' token QUALIFIED_NAME token and 'namespace' token @@ -43,271 +46,308 @@ defaultNamespaceDeclaration */ namespaceDeclaration - : 'prefix' PREFX namespace_ - ; + : 'prefix' PREFX namespace_ + ; namespace_ - : IRI_REF - ; + : IRI_REF + ; bundle - : BUNDLE identifier (namespaceDeclarations)? (expression)* ENDBUNDLE - ; + : BUNDLE identifier (namespaceDeclarations)? (expression)* ENDBUNDLE + ; identifier - : PREFX | QUALIFIED_NAME - ; + : PREFX + | QUALIFIED_NAME + ; expression - : (entityExpression | activityExpression | generationExpression | usageExpression | startExpression | endExpression | invalidationExpression | communicationExpression | agentExpression | associationExpression | attributionExpression | delegationExpression | derivationExpression | influenceExpression | alternateExpression | specializationExpression | membershipExpression | extensibilityExpression) - ; + : ( + entityExpression + | activityExpression + | generationExpression + | usageExpression + | startExpression + | endExpression + | invalidationExpression + | communicationExpression + | agentExpression + | associationExpression + | attributionExpression + | delegationExpression + | derivationExpression + | influenceExpression + | alternateExpression + | specializationExpression + | membershipExpression + | extensibilityExpression + ) + ; entityExpression - : 'entity' '(' identifier optionalAttributeValuePairs ')' - ; + : 'entity' '(' identifier optionalAttributeValuePairs ')' + ; optionalAttributeValuePairs - : (',' '[' attributeValuePairs ']')? - ; + : (',' '[' attributeValuePairs ']')? + ; attributeValuePairs - : (| attributeValuePair (',' attributeValuePair)*) - ; + : ( | attributeValuePair (',' attributeValuePair)*) + ; attributeValuePair - : attribute '=' literal - ; + : attribute '=' literal + ; attribute - : PREFX | QUALIFIED_NAME - ; + : PREFX + | QUALIFIED_NAME + ; literal - : typedLiteral - | convenienceNotation - ; + : typedLiteral + | convenienceNotation + ; typedLiteral - : STRING_LITERAL '%%' datatype - ; + : STRING_LITERAL '%%' datatype + ; datatype - : PREFX | QUALIFIED_NAME - ; + : PREFX + | QUALIFIED_NAME + ; convenienceNotation - : STRING_LITERAL (LANGTAG)? - | INT_LITERAL - | QUALIFIED_NAME_LITERAL - ; + : STRING_LITERAL (LANGTAG)? + | INT_LITERAL + | QUALIFIED_NAME_LITERAL + ; activityExpression - : 'activity' '(' identifier (',' timeOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' - ; + : 'activity' '(' identifier (',' timeOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' + ; timeOrMarker - : (time | '-') - ; + : (time | '-') + ; time - : DATETIME - ; + : DATETIME + ; generationExpression - : 'wasGeneratedBy' '(' optionalIdentifier eIdentifier (',' aIdentifierOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' - ; + : 'wasGeneratedBy' '(' optionalIdentifier eIdentifier ( + ',' aIdentifierOrMarker ',' timeOrMarker + )? optionalAttributeValuePairs ')' + ; optionalIdentifier - : (identifierOrMarker ';')? - ; + : (identifierOrMarker ';')? + ; identifierOrMarker - : (identifier | '-') - ; + : (identifier | '-') + ; eIdentifier - : identifier - ; + : identifier + ; eIdentifierOrMarker - : (eIdentifier | '-') - ; + : (eIdentifier | '-') + ; aIdentifierOrMarker - : (aIdentifier | '-') - ; + : (aIdentifier | '-') + ; aIdentifier - : identifier - ; + : identifier + ; agIdentifierOrMarker - : (agIdentifier | '-') - ; + : (agIdentifier | '-') + ; agIdentifier - : identifier - ; + : identifier + ; cIdentifier - : identifier - ; + : identifier + ; gIdentifier - : identifier - ; + : identifier + ; gIdentifierOrMarker - : (gIdentifier | '-') - ; + : (gIdentifier | '-') + ; uIdentifier - : identifier - ; + : identifier + ; uIdentifierOrMarker - : (uIdentifier | '-') - ; + : (uIdentifier | '-') + ; usageExpression - : 'used' '(' optionalIdentifier aIdentifier (',' eIdentifierOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' - ; + : 'used' '(' optionalIdentifier aIdentifier (',' eIdentifierOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' + ; startExpression - : 'wasStartedBy' '(' optionalIdentifier aIdentifier (',' eIdentifierOrMarker ',' aIdentifierOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' - ; + : 'wasStartedBy' '(' optionalIdentifier aIdentifier ( + ',' eIdentifierOrMarker ',' aIdentifierOrMarker ',' timeOrMarker + )? optionalAttributeValuePairs ')' + ; endExpression - : 'wasEndedBy' '(' optionalIdentifier aIdentifier (',' eIdentifierOrMarker ',' aIdentifierOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' - ; + : 'wasEndedBy' '(' optionalIdentifier aIdentifier ( + ',' eIdentifierOrMarker ',' aIdentifierOrMarker ',' timeOrMarker + )? optionalAttributeValuePairs ')' + ; invalidationExpression - : 'wasInvalidatedBy' '(' optionalIdentifier eIdentifier (',' aIdentifierOrMarker ',' timeOrMarker)? optionalAttributeValuePairs ')' - ; + : 'wasInvalidatedBy' '(' optionalIdentifier eIdentifier ( + ',' aIdentifierOrMarker ',' timeOrMarker + )? optionalAttributeValuePairs ')' + ; communicationExpression - : 'wasInformedBy' '(' optionalIdentifier aIdentifier ',' aIdentifier optionalAttributeValuePairs ')' - ; + : 'wasInformedBy' '(' optionalIdentifier aIdentifier ',' aIdentifier optionalAttributeValuePairs ')' + ; agentExpression - : 'agent' '(' identifier optionalAttributeValuePairs ')' - ; + : 'agent' '(' identifier optionalAttributeValuePairs ')' + ; associationExpression - : 'wasAssociatedWith' '(' optionalIdentifier aIdentifier (',' agIdentifierOrMarker ',' eIdentifierOrMarker)? optionalAttributeValuePairs ')' - ; + : 'wasAssociatedWith' '(' optionalIdentifier aIdentifier ( + ',' agIdentifierOrMarker ',' eIdentifierOrMarker + )? optionalAttributeValuePairs ')' + ; attributionExpression - : 'wasAttributedTo' '(' optionalIdentifier eIdentifier ',' agIdentifier optionalAttributeValuePairs ')' - ; + : 'wasAttributedTo' '(' optionalIdentifier eIdentifier ',' agIdentifier optionalAttributeValuePairs ')' + ; delegationExpression - : 'actedOnBehalfOf' '(' optionalIdentifier agIdentifier ',' agIdentifier (',' aIdentifierOrMarker)? optionalAttributeValuePairs ')' - ; + : 'actedOnBehalfOf' '(' optionalIdentifier agIdentifier ',' agIdentifier ( + ',' aIdentifierOrMarker + )? optionalAttributeValuePairs ')' + ; derivationExpression - : 'wasDerivedFrom' '(' optionalIdentifier eIdentifier ',' eIdentifier (',' aIdentifierOrMarker ',' gIdentifierOrMarker ',' uIdentifierOrMarker)? optionalAttributeValuePairs ')' - ; + : 'wasDerivedFrom' '(' optionalIdentifier eIdentifier ',' eIdentifier ( + ',' aIdentifierOrMarker ',' gIdentifierOrMarker ',' uIdentifierOrMarker + )? optionalAttributeValuePairs ')' + ; influenceExpression - : 'wasInfluencedBy' '(' optionalIdentifier eIdentifier ',' eIdentifier optionalAttributeValuePairs ')' - ; + : 'wasInfluencedBy' '(' optionalIdentifier eIdentifier ',' eIdentifier optionalAttributeValuePairs ')' + ; alternateExpression - : 'alternateOf' '(' eIdentifier ',' eIdentifier ')' - ; + : 'alternateOf' '(' eIdentifier ',' eIdentifier ')' + ; specializationExpression - : 'specializationOf' '(' eIdentifier ',' eIdentifier ')' - ; + : 'specializationOf' '(' eIdentifier ',' eIdentifier ')' + ; membershipExpression - : 'hadMember' '(' cIdentifier ',' eIdentifier ')' - ; + : 'hadMember' '(' cIdentifier ',' eIdentifier ')' + ; extensibilityExpression - : (PREFX|QUALIFIED_NAME) '(' optionalIdentifier extensibilityArgument (',' extensibilityArgument)* optionalAttributeValuePairs ')' - ; + : (PREFX | QUALIFIED_NAME) '(' optionalIdentifier extensibilityArgument ( + ',' extensibilityArgument + )* optionalAttributeValuePairs ')' + ; extensibilityArgument - : (identifierOrMarker | literal | time | extensibilityExpression | extensibilityTuple) - ; + : (identifierOrMarker | literal | time | extensibilityExpression | extensibilityTuple) + ; extensibilityTuple - : '{' extensibilityArgument (',' extensibilityArgument)* '}' - | '(' extensibilityArgument (',' extensibilityArgument)* ')' - ; + : '{' extensibilityArgument (',' extensibilityArgument)* '}' + | '(' extensibilityArgument (',' extensibilityArgument)* ')' + ; /* lexer */ DOCUMENT - : 'document' - ; - + : 'document' + ; ENDDOCUMENT - : 'endDocument' - ; - + : 'endDocument' + ; BUNDLE - : 'bundle' - ; - + : 'bundle' + ; ENDBUNDLE - : 'endBundle' - ; - + : 'endBundle' + ; WS - : [ \t\r\n\u000C] + -> channel (HIDDEN) - ; - + : [ \t\r\n\u000C]+ -> channel (HIDDEN) + ; COMMENT - : '/*' .*? '*/' -> channel (HIDDEN) - ; - + : '/*' .*? '*/' -> channel (HIDDEN) + ; LINE_COMMENT - : '//' ~ [\r\n]* -> channel (HIDDEN) - ; - + : '//' ~ [\r\n]* -> channel (HIDDEN) + ; IRI_REF - : LESS ~ ('<' | '>' | '"' | '{' | '}' | '|' | '^' | '\\' | '`' | '\u0000' .. '\u0020')* GREATER - ; - + : LESS ~ ('<' | '>' | '"' | '{' | '}' | '|' | '^' | '\\' | '`' | '\u0000' .. '\u0020')* GREATER + ; LESS - : '<' - ; - + : '<' + ; GREATER - : '>' - ; - + : '>' + ; DOT - : '.' - ; - + : '.' + ; MINUS - : '-' - ; - + : '-' + ; fragment PN_PREFIX - : PN_CHARS_BASE ((PN_CHARS | DOT)* PN_CHARS)? - ; - + : PN_CHARS_BASE ((PN_CHARS | DOT)* PN_CHARS)? + ; fragment PN_CHARS_BASE - : 'A' .. 'Z' | 'a' .. 'z' | '\u00C0' .. '\u00D6' | '\u00D8' .. '\u00F6' | '\u00F8' .. '\u02FF' | '\u0370' .. '\u037D' | '\u037F' .. '\u1FFF' | '\u200C' .. '\u200D' | '\u2070' .. '\u218F' | '\u2C00' .. '\u2FEF' | '\u3001' .. '\uD7FF' | '\uF900' .. '\uFDCF' | '\uFDF0' .. '\uFFFD' - ; + : 'A' .. 'Z' + | 'a' .. 'z' + | '\u00C0' .. '\u00D6' + | '\u00D8' .. '\u00F6' + | '\u00F8' .. '\u02FF' + | '\u0370' .. '\u037D' + | '\u037F' .. '\u1FFF' + | '\u200C' .. '\u200D' + | '\u2070' .. '\u218F' + | '\u2C00' .. '\u2FEF' + | '\u3001' .. '\uD7FF' + | '\uF900' .. '\uFDCF' + | '\uFDF0' .. '\uFFFD' + ; /* Note PN_CHARS_BASE is same as NCNAMESTARTCHAR (XML Schema) http://www.w3.org/TR/rdf-sparql-query/#rPN_CHARS_U @@ -315,8 +355,9 @@ fragment PN_CHARS_BASE */ fragment PN_CHARS_U - : PN_CHARS_BASE | '_' - ; + : PN_CHARS_BASE + | '_' + ; /* Note: this is the same as NCNAMECHAR (XML Schema) except for '.' http://www.w3.org/TR/rdf-sparql-query/#rPN_CHARS @@ -325,84 +366,98 @@ fragment PN_CHARS_U */ fragment PN_CHARS - : PN_CHARS_U | MINUS | DIGIT | '\u00B7' | '\u0300' .. '\u036F' | '\u203F' .. '\u2040' - ; - + : PN_CHARS_U + | MINUS + | DIGIT + | '\u00B7' + | '\u0300' .. '\u036F' + | '\u203F' .. '\u2040' + ; fragment DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; PREFX - : PN_PREFIX - ; + : PN_PREFIX + ; QUALIFIED_NAME - : (PN_PREFIX ':')? PN_LOCAL | PN_PREFIX ':' - ; - + : (PN_PREFIX ':')? PN_LOCAL + | PN_PREFIX ':' + ; fragment PN_LOCAL - : (PN_CHARS_U | DIGIT | PN_CHARS_OTHERS) ((PN_CHARS | DOT | PN_CHARS_OTHERS)* (PN_CHARS | PN_CHARS_OTHERS))? - ; - + : (PN_CHARS_U | DIGIT | PN_CHARS_OTHERS) ( + (PN_CHARS | DOT | PN_CHARS_OTHERS)* (PN_CHARS | PN_CHARS_OTHERS) + )? + ; fragment PN_CHARS_OTHERS - : '/' | '@' | '~' | '&' | '+' | '*' | '?' | '#' | '$' | '!' | PERCENT | PN_CHARS_ESC - ; - + : '/' + | '@' + | '~' + | '&' + | '+' + | '*' + | '?' + | '#' + | '$' + | '!' + | PERCENT + | PN_CHARS_ESC + ; fragment PN_CHARS_ESC - : '\\' ('=' | '\'' | '(' | ')' | ',' | '-' | ':' | ';' | '[' | ']' | '.') - ; - + : '\\' ('=' | '\'' | '(' | ')' | ',' | '-' | ':' | ';' | '[' | ']' | '.') + ; fragment PERCENT - : '%' HEX HEX - ; - + : '%' HEX HEX + ; HEX - : DIGIT | [A-F] | [a-f] - ; - + : DIGIT + | [A-F] + | [a-f] + ; STRING_LITERAL - : STRING_LITERAL2 | STRING_LITERAL_LONG2 - ; - + : STRING_LITERAL2 + | STRING_LITERAL_LONG2 + ; INT_LITERAL - : ('-')? (DIGIT) + - ; - + : ('-')? (DIGIT)+ + ; QUALIFIED_NAME_LITERAL - : '\'' QUALIFIED_NAME '\'' - ; - + : '\'' QUALIFIED_NAME '\'' + ; ECHAR - : '\\' [btnfr"'\\] - ; - + : '\\' [btnfr"'\\] + ; STRING_LITERAL2 - : '"' ((~ ["\\\r\n]) | ECHAR)* '"' - ; - + : '"' ((~ ["\\\r\n]) | ECHAR)* '"' + ; STRING_LITERAL_LONG2 - : '"""' (('"' | '""')? (~ ["\\] | ECHAR))* '"""' - ; - + : '"""' (('"' | '""')? (~ ["\\] | ECHAR))* '"""' + ; DATETIME - : '-'? ([1-9] [0-9] [0-9] [0-9] + | '0' [0-9] [0-9] [0-9]) '-' ('0' [1-9] | '1' [0-2]) '-' ('0' [1-9] | [12] [0-9] | '3' [01]) 'T' ((([01] [0-9]) | ('2' [0-3])) ':' [0-5] [0-9] ':' [0-5] [0-9] ('.' [0-9] +)? | ('24:00:00' ('.' '0' +)?)) ('Z' | ('+' | '-') (('0' [0-9] | '1' [0-3]) ':' [0-5] [0-9] | '14:00'))? - ; - + : '-'? ([1-9] [0-9] [0-9] [0-9]+ | '0' [0-9] [0-9] [0-9]) '-' ('0' [1-9] | '1' [0-2]) '-' ( + '0' [1-9] + | [12] [0-9] + | '3' [01] + ) 'T' ( + (([01] [0-9]) | ('2' [0-3])) ':' [0-5] [0-9] ':' [0-5] [0-9] ('.' [0-9]+)? + | ('24:00:00' ('.' '0'+)?) + ) ('Z' | ('+' | '-') (('0' [0-9] | '1' [0-3]) ':' [0-5] [0-9] | '14:00'))? + ; LANGTAG - : '@' [a-zA-Z] + ('-' [a-zA-Z0-9] +)* - ; + : '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* + ; \ No newline at end of file diff --git a/python/python/PythonLexer.g4 b/python/python/PythonLexer.g4 index afc5d5fcf1..3a428bb7db 100644 --- a/python/python/PythonLexer.g4 +++ b/python/python/PythonLexer.g4 @@ -25,55 +25,65 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PythonLexer; -options { superClass=PythonLexerBase; } +options { + superClass = PythonLexerBase; +} // Insert here @header for C++ lexer. // Artificial tokens only for parser purposes -tokens { INDENT, DEDENT, LINE_BREAK } +tokens { + INDENT, + DEDENT, + LINE_BREAK +} // Keywords -DEF : 'def'; -RETURN : 'return'; -RAISE : 'raise'; -FROM : 'from'; -IMPORT : 'import'; -NONLOCAL : 'nonlocal'; -AS : 'as'; -GLOBAL : 'global'; -ASSERT : 'assert'; -IF : 'if'; -ELIF : 'elif'; -ELSE : 'else'; -WHILE : 'while'; -FOR : 'for'; -IN : 'in'; -TRY : 'try'; -NONE : 'None'; -FINALLY : 'finally'; -WITH : 'with'; -EXCEPT : 'except'; -LAMBDA : 'lambda'; -OR : 'or'; -AND : 'and'; -NOT : 'not'; -IS : 'is'; -CLASS : 'class'; -YIELD : 'yield'; -DEL : 'del'; -PASS : 'pass'; -CONTINUE : 'continue'; -BREAK : 'break'; -ASYNC : 'async'; -AWAIT : 'await'; -PRINT : 'print'; -EXEC : 'exec'; -TRUE : 'True'; -FALSE : 'False'; +DEF : 'def'; +RETURN : 'return'; +RAISE : 'raise'; +FROM : 'from'; +IMPORT : 'import'; +NONLOCAL : 'nonlocal'; +AS : 'as'; +GLOBAL : 'global'; +ASSERT : 'assert'; +IF : 'if'; +ELIF : 'elif'; +ELSE : 'else'; +WHILE : 'while'; +FOR : 'for'; +IN : 'in'; +TRY : 'try'; +NONE : 'None'; +FINALLY : 'finally'; +WITH : 'with'; +EXCEPT : 'except'; +LAMBDA : 'lambda'; +OR : 'or'; +AND : 'and'; +NOT : 'not'; +IS : 'is'; +CLASS : 'class'; +YIELD : 'yield'; +DEL : 'del'; +PASS : 'pass'; +CONTINUE : 'continue'; +BREAK : 'break'; +ASYNC : 'async'; +AWAIT : 'await'; +PRINT : 'print'; +EXEC : 'exec'; +TRUE : 'True'; +FALSE : 'False'; // Operators @@ -120,110 +130,84 @@ RIGHT_SHIFT_ASSIGN : '>>='; POWER_ASSIGN : '**='; IDIV_ASSIGN : '//='; -STRING : ([uU] | [fF] [rR]? | [rR] [fF]?)? (SHORT_STRING | LONG_STRING) - | ([bB] [rR]? | [rR] [bB]) (SHORT_BYTES | LONG_BYTES) - ; +STRING: + ([uU] | [fF] [rR]? | [rR] [fF]?)? (SHORT_STRING | LONG_STRING) + | ([bB] [rR]? | [rR] [bB]) (SHORT_BYTES | LONG_BYTES) +; -DECIMAL_INTEGER : [1-9] [0-9]* - | '0'+ - ; -OCT_INTEGER : '0' [oO] [0-7]+; -HEX_INTEGER : '0' [xX] [0-9a-fA-F]+; -BIN_INTEGER : '0' [bB] [01]+; +DECIMAL_INTEGER : [1-9] [0-9]* | '0'+; +OCT_INTEGER : '0' [oO] [0-7]+; +HEX_INTEGER : '0' [xX] [0-9a-fA-F]+; +BIN_INTEGER : '0' [bB] [01]+; -IMAG_NUMBER : (EXPONENT_OR_POINT_FLOAT | [0-9]+) [jJ]; -FLOAT_NUMBER : EXPONENT_OR_POINT_FLOAT; +IMAG_NUMBER : (EXPONENT_OR_POINT_FLOAT | [0-9]+) [jJ]; +FLOAT_NUMBER : EXPONENT_OR_POINT_FLOAT; -OPEN_PAREN : '(' {this.IncIndentLevel();}; -CLOSE_PAREN : ')' {this.DecIndentLevel();}; -OPEN_BRACE : '{' {this.IncIndentLevel();}; -CLOSE_BRACE : '}' {this.DecIndentLevel();}; -OPEN_BRACKET : '[' {this.IncIndentLevel();}; -CLOSE_BRACKET : ']' {this.DecIndentLevel();}; +OPEN_PAREN : '(' {this.IncIndentLevel();}; +CLOSE_PAREN : ')' {this.DecIndentLevel();}; +OPEN_BRACE : '{' {this.IncIndentLevel();}; +CLOSE_BRACE : '}' {this.DecIndentLevel();}; +OPEN_BRACKET : '[' {this.IncIndentLevel();}; +CLOSE_BRACKET : ']' {this.DecIndentLevel();}; -NAME : ID_START ID_CONTINUE*; +NAME: ID_START ID_CONTINUE*; -LINE_JOIN : '\\' [ \t]* RN -> channel(HIDDEN); -NEWLINE : RN {this.HandleNewLine();} -> channel(HIDDEN); -WS : [ \t]+ {this.HandleSpaces();} -> channel(HIDDEN); -COMMENT : '#' ~[\r\n\f]* -> channel(HIDDEN); +LINE_JOIN : '\\' [ \t]* RN -> channel(HIDDEN); +NEWLINE : RN {this.HandleNewLine();} -> channel(HIDDEN); +WS : [ \t]+ {this.HandleSpaces();} -> channel(HIDDEN); +COMMENT : '#' ~[\r\n\f]* -> channel(HIDDEN); // Fragments -fragment SHORT_STRING - : '\'' ('\\' (RN | .) | ~[\\\r\n'])* '\'' - | '"' ('\\' (RN | .) | ~[\\\r\n"])* '"' - ; - -fragment LONG_STRING - : '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' - | '"""' LONG_STRING_ITEM*? '"""' - ; - -fragment LONG_STRING_ITEM - : ~'\\' - | '\\' (RN | .) - ; - -fragment RN - : '\r'? '\n' - ; - -fragment EXPONENT_OR_POINT_FLOAT - : ([0-9]+ | POINT_FLOAT) [eE] [+-]? [0-9]+ - | POINT_FLOAT - ; - -fragment POINT_FLOAT - : [0-9]* '.' [0-9]+ - | [0-9]+ '.' - ; - -fragment SHORT_BYTES - : '\'' (SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ)* '\'' +fragment SHORT_STRING: + '\'' ('\\' (RN | .) | ~[\\\r\n'])* '\'' + | '"' ('\\' (RN | .) | ~[\\\r\n"])* '"' +; + +fragment LONG_STRING: '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' | '"""' LONG_STRING_ITEM*? '"""'; + +fragment LONG_STRING_ITEM: ~'\\' | '\\' (RN | .); + +fragment RN: '\r'? '\n'; + +fragment EXPONENT_OR_POINT_FLOAT: ([0-9]+ | POINT_FLOAT) [eE] [+-]? [0-9]+ | POINT_FLOAT; + +fragment POINT_FLOAT: [0-9]* '.' [0-9]+ | [0-9]+ '.'; + +fragment SHORT_BYTES: + '\'' (SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ)* '\'' | '"' (SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ)* '"' - ; +; -fragment LONG_BYTES - : '\'\'\'' LONG_BYTES_ITEM*? '\'\'\'' - | '"""' LONG_BYTES_ITEM*? '"""' - ; +fragment LONG_BYTES: '\'\'\'' LONG_BYTES_ITEM*? '\'\'\'' | '"""' LONG_BYTES_ITEM*? '"""'; -fragment LONG_BYTES_ITEM - : LONG_BYTES_CHAR - | BYTES_ESCAPE_SEQ - ; +fragment LONG_BYTES_ITEM: LONG_BYTES_CHAR | BYTES_ESCAPE_SEQ; -fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE - : [\u0000-\u0009] +fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE: + [\u0000-\u0009] | [\u000B-\u000C] | [\u000E-\u0026] | [\u0028-\u005B] | [\u005D-\u007F] - ; +; -fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE - : [\u0000-\u0009] +fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE: + [\u0000-\u0009] | [\u000B-\u000C] | [\u000E-\u0021] | [\u0023-\u005B] | [\u005D-\u007F] - ; +; /// Any ASCII character except "\" -fragment LONG_BYTES_CHAR - : [\u0000-\u005B] - | [\u005D-\u007F] - ; +fragment LONG_BYTES_CHAR: [\u0000-\u005B] | [\u005D-\u007F]; /// "\" -fragment BYTES_ESCAPE_SEQ - : '\\' [\u0000-\u007F] - ; +fragment BYTES_ESCAPE_SEQ: '\\' [\u0000-\u007F]; /// All characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property -fragment ID_CONTINUE - : ID_START +fragment ID_CONTINUE: + ID_START | [0-9] | [\u0300-\u036F] | [\u0483-\u0486] @@ -425,11 +409,11 @@ fragment ID_CONTINUE | [\uFE4D-\uFE4F] | [\uFF10-\uFF19] | '\uFF3F' - ; +; /// All characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property -fragment ID_START - : '_' +fragment ID_START: + '_' | [A-Z] | [a-z] | '\u00AA' @@ -756,4 +740,4 @@ fragment ID_START | [\uFFCA-\uFFCF] | [\uFFD2-\uFFD7] | [\uFFDA-\uFFDC] - ; +; \ No newline at end of file diff --git a/python/python/PythonParser.g4 b/python/python/PythonParser.g4 index d192bce37f..f29bba7abb 100644 --- a/python/python/PythonParser.g4 +++ b/python/python/PythonParser.g4 @@ -25,16 +25,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 PythonParser; // Insert here @header for C++ parser. -options { tokenVocab=PythonLexer; superClass=PythonParserBase; } +options { + tokenVocab = PythonLexer; + superClass = PythonParserBase; +} root - : (single_input - | file_input - | eval_input)? EOF + : (single_input | file_input | eval_input)? EOF ; // A single interactive statement; @@ -60,12 +64,12 @@ stmt ; compound_stmt - : IF cond=test COLON suite elif_clause* else_clause? #if_stmt - | WHILE test COLON suite else_clause? #while_stmt - | ASYNC? FOR exprlist IN testlist COLON suite else_clause? #for_stmt - | TRY COLON suite (except_clause+ else_clause? finally_clause? | finally_clause) #try_stmt - | ASYNC? WITH with_item (COMMA with_item)* COLON suite #with_stmt - | decorator* (classdef | funcdef) #class_or_func_def_stmt + : IF cond = test COLON suite elif_clause* else_clause? # if_stmt + | WHILE test COLON suite else_clause? # while_stmt + | ASYNC? FOR exprlist IN testlist COLON suite else_clause? # for_stmt + | TRY COLON suite (except_clause+ else_clause? finally_clause? | finally_clause) # try_stmt + | ASYNC? WITH with_item (COMMA with_item)* COLON suite # with_stmt + | decorator* (classdef | funcdef) # class_or_func_def_stmt ; suite @@ -90,14 +94,19 @@ finally_clause ; with_item - // NB compile.c makes sure that the default except clause is last +// NB compile.c makes sure that the default except clause is last : test (AS expr)? ; // Python 2 : EXCEPT test COMMA name // Python 3 : EXCEPT test AS name except_clause - : EXCEPT (test ({this.CheckVersion(2)}? COMMA name {this.SetVersion(2);} | {this.CheckVersion(3)}? AS name {this.SetVersion(3);})?)? COLON suite + : EXCEPT ( + test ( + {this.CheckVersion(2)}? COMMA name {this.SetVersion(2);} + | {this.CheckVersion(3)}? AS name {this.SetVersion(3);} + )? + )? COLON suite ; classdef @@ -144,23 +153,28 @@ simple_stmt // TODO 1: left part augmented assignment should be `test` only, no stars or lists // TODO 2: semantically annotated declaration is not an assignment small_stmt - : testlist_star_expr assign_part? #expr_stmt - | {this.CheckVersion(2)}? PRINT ((test (COMMA test)* COMMA?) - | RIGHT_SHIFT test ((COMMA test)+ COMMA?)) {this.SetVersion(2);} #print_stmt // Python 2 - | DEL exprlist #del_stmt - | PASS #pass_stmt - | BREAK #break_stmt - | CONTINUE #continue_stmt - | RETURN testlist? #return_stmt - | RAISE (test (COMMA test (COMMA test)?)?)? (FROM test)? #raise_stmt - | yield_expr #yield_stmt - | IMPORT dotted_as_names #import_stmt - | FROM ((DOT | ELLIPSIS)* dotted_name | (DOT | ELLIPSIS)+) - IMPORT (STAR | OPEN_PAREN import_as_names CLOSE_PAREN | import_as_names) #from_stmt - | GLOBAL name (COMMA name)* #global_stmt - | {this.CheckVersion(2)}? EXEC expr (IN test (COMMA test)?)? {this.SetVersion(2);} #exec_stmt // Python 2 - | ASSERT test (COMMA test)? #assert_stmt - | {this.CheckVersion(3)}? NONLOCAL name (COMMA name)* {this.SetVersion(3);} #nonlocal_stmt // Python 3 + : testlist_star_expr assign_part? # expr_stmt + | {this.CheckVersion(2)}? PRINT ( + (test (COMMA test)* COMMA?) + | RIGHT_SHIFT test ((COMMA test)+ COMMA?) + ) {this.SetVersion(2);} # print_stmt // Python 2 + | DEL exprlist # del_stmt + | PASS # pass_stmt + | BREAK # break_stmt + | CONTINUE # continue_stmt + | RETURN testlist? # return_stmt + | RAISE (test (COMMA test (COMMA test)?)?)? (FROM test)? # raise_stmt + | yield_expr # yield_stmt + | IMPORT dotted_as_names # import_stmt + | FROM ((DOT | ELLIPSIS)* dotted_name | (DOT | ELLIPSIS)+) IMPORT ( + STAR + | OPEN_PAREN import_as_names CLOSE_PAREN + | import_as_names + ) # from_stmt + | GLOBAL name (COMMA name)* # global_stmt + | {this.CheckVersion(2)}? EXEC expr (IN test (COMMA test)?)? {this.SetVersion(2);} # exec_stmt // Python 2 + | ASSERT test (COMMA test)? # assert_stmt + | {this.CheckVersion(3)}? NONLOCAL name (COMMA name)* {this.SetVersion(3);} # nonlocal_stmt // Python 3 ; testlist_star_expr @@ -173,25 +187,24 @@ star_expr ; assign_part - // if left expression in assign is bool literal, it's mean that is Python 2 here - : ASSIGN ( testlist_star_expr (ASSIGN testlist_star_expr)* (ASSIGN yield_expr)? - | yield_expr) +// if left expression in assign is bool literal, it's mean that is Python 2 here + : ASSIGN (testlist_star_expr (ASSIGN testlist_star_expr)* (ASSIGN yield_expr)? | yield_expr) | {this.CheckVersion(3)}? COLON test (ASSIGN testlist)? {this.SetVersion(3);} // annassign Python3 rule - | op=( ADD_ASSIGN - | SUB_ASSIGN - | MULT_ASSIGN - | AT_ASSIGN - | DIV_ASSIGN - | MOD_ASSIGN - | AND_ASSIGN - | OR_ASSIGN - | XOR_ASSIGN - | LEFT_SHIFT_ASSIGN - | RIGHT_SHIFT_ASSIGN - | POWER_ASSIGN - | IDIV_ASSIGN - ) - (yield_expr | testlist) + | op = ( + ADD_ASSIGN + | SUB_ASSIGN + | MULT_ASSIGN + | AT_ASSIGN + | DIV_ASSIGN + | MOD_ASSIGN + | AND_ASSIGN + | OR_ASSIGN + | XOR_ASSIGN + | LEFT_SHIFT_ASSIGN + | RIGHT_SHIFT_ASSIGN + | POWER_ASSIGN + | IDIV_ASSIGN + ) (yield_expr | testlist) ; exprlist @@ -230,7 +243,10 @@ test // the same as `typedargslist`, but with no types varargslist - : (vardef_parameters COMMA)? (varargs (COMMA vardef_parameters)? (COMMA varkwargs)? | varkwargs) COMMA? + : (vardef_parameters COMMA)? ( + varargs (COMMA vardef_parameters)? (COMMA varkwargs)? + | varkwargs + ) COMMA? | vardef_parameters COMMA? ; @@ -255,25 +271,35 @@ varkwargs logical_test : comparison | NOT logical_test - | logical_test op=AND logical_test - | logical_test op=OR logical_test + | logical_test op = AND logical_test + | logical_test op = OR logical_test ; comparison - : comparison (LESS_THAN | GREATER_THAN | EQUALS | GT_EQ | LT_EQ | NOT_EQ_1 | NOT_EQ_2 | optional=NOT? IN | IS optional=NOT?) comparison + : comparison ( + LESS_THAN + | GREATER_THAN + | EQUALS + | GT_EQ + | LT_EQ + | NOT_EQ_1 + | NOT_EQ_2 + | optional = NOT? IN + | IS optional = NOT? + ) comparison | expr ; expr : AWAIT? atom trailer* - | expr op=POWER expr - | op=(ADD | MINUS | NOT_OP) expr - | expr op=(STAR | DIV | MOD | IDIV | AT) expr - | expr op=(ADD | MINUS) expr - | expr op=(LEFT_SHIFT | RIGHT_SHIFT) expr - | expr op=AND_OP expr - | expr op=XOR expr - | expr op=OR_OP expr + | expr op = POWER expr + | op = (ADD | MINUS | NOT_OP) expr + | expr op = (STAR | DIV | MOD | IDIV | AT) expr + | expr op = (ADD | MINUS) expr + | expr op = (LEFT_SHIFT | RIGHT_SHIFT) expr + | expr op = AND_OP expr + | expr op = XOR expr + | expr op = OR_OP expr ; atom @@ -350,8 +376,8 @@ arguments ; arglist - // The reason that keywords are test nodes instead of name is that using name - // results in an ambiguity. ast.c makes sure it's a name. +// The reason that keywords are test nodes instead of name is that using name +// results in an ambiguity. ast.c makes sure it's a name. : argument (COMMA argument)* COMMA? ; @@ -383,4 +409,4 @@ comp_for comp_iter : comp_for | IF test comp_iter? - ; + ; \ No newline at end of file diff --git a/python/python2-js/Python2.g4 b/python/python2-js/Python2.g4 index c43626c4b6..348e536b10 100644 --- a/python/python2-js/Python2.g4 +++ b/python/python2-js/Python2.g4 @@ -9,10 +9,18 @@ * * Compiles with ANTLR 4.7, generated lexer/parser for Python 2 target. */ - - grammar Python2; - tokens { INDENT, DEDENT, NEWLINE, ENDMARKER } +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar Python2; + +tokens { + INDENT, + DEDENT, + NEWLINE, + ENDMARKER +} @lexer::header { var Python2Parser = require('./Python2Parser').Python2Parser; @@ -153,258 +161,459 @@ * NB: compound_stmt in single_input is followed by extra NEWLINE! */ -single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE - ; -file_input: (NEWLINE | stmt)* ENDMARKER - ; -eval_input: testlist NEWLINE* ENDMARKER +single_input + : NEWLINE + | simple_stmt + | compound_stmt NEWLINE ; +file_input + : (NEWLINE | stmt)* ENDMARKER + ; -decorator: '@' dotted_name ( '(' (arglist)? ')' )? NEWLINE +eval_input + : testlist NEWLINE* ENDMARKER ; -decorators: decorator+ + +decorator + : '@' dotted_name ('(' (arglist)? ')')? NEWLINE ; -decorated: decorators (classdef | funcdef) + +decorators + : decorator+ ; -funcdef: 'def' NAME parameters ':' suite + +decorated + : decorators (classdef | funcdef) ; -parameters: '(' (varargslist)? ')' + +funcdef + : 'def' NAME parameters ':' suite ; -varargslist: ((fpdef ('=' test)? ',')* - ('*' NAME (',' '**' NAME)? | '**' NAME) | - fpdef ('=' test)? (',' fpdef ('=' test)?)* (',')?) + +parameters + : '(' (varargslist)? ')' ; -fpdef: NAME | '(' fplist ')' + +varargslist + : ( + (fpdef ('=' test)? ',')* ('*' NAME (',' '**' NAME)? | '**' NAME) + | fpdef ('=' test)? (',' fpdef ('=' test)?)* (',')? + ) ; -fplist: fpdef (',' fpdef)* (',')? + +fpdef + : NAME + | '(' fplist ')' ; +fplist + : fpdef (',' fpdef)* (',')? + ; -stmt: simple_stmt | compound_stmt +stmt + : simple_stmt + | compound_stmt ; -simple_stmt: small_stmt (';' small_stmt)* (';')? NEWLINE + +simple_stmt + : small_stmt (';' small_stmt)* (';')? NEWLINE ; -small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | - import_stmt | global_stmt | exec_stmt | assert_stmt) + +small_stmt + : ( + expr_stmt + | print_stmt + | del_stmt + | pass_stmt + | flow_stmt + | import_stmt + | global_stmt + | exec_stmt + | assert_stmt + ) ; -expr_stmt: testlist (augassign (yield_expr|testlist) | - ('=' (yield_expr|testlist))*) + +expr_stmt + : testlist (augassign (yield_expr | testlist) | ('=' (yield_expr | testlist))*) ; -augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | - '<<=' | '>>=' | '**=' | '//=') -// For normal assignments, additional restrictions enforced by the interpreter + +augassign + : ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=') + // For normal assignments, additional restrictions enforced by the interpreter ; + //print_stmt: 'print' ( ( test (',' test)* (',')? )? | // '>>' test ( (',' test)+ (',')? )? ) // ; -print_stmt: {this._input.LT(1).text=='print'}? - // tt: this change allows print to be treated as a NAME - // while preserving the print statement syntax. - NAME ( ( test (',' test)* (',')? )? | - '>>' test ( (',' test)+ (',')? )? ) - ; -del_stmt: 'del' exprlist +print_stmt + : {this._input.LT(1).text=='print'}? + // tt: this change allows print to be treated as a NAME + // while preserving the print statement syntax. + NAME (( test (',' test)* (',')?)? | '>>' test ( (',' test)+ (',')?)?) ; -pass_stmt: 'pass' + +del_stmt + : 'del' exprlist ; -flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt + +pass_stmt + : 'pass' ; -break_stmt: 'break' + +flow_stmt + : break_stmt + | continue_stmt + | return_stmt + | raise_stmt + | yield_stmt ; -continue_stmt: 'continue' + +break_stmt + : 'break' ; -return_stmt: 'return' (testlist)? + +continue_stmt + : 'continue' ; -yield_stmt: yield_expr + +return_stmt + : 'return' (testlist)? ; -raise_stmt: 'raise' (test (',' test (',' test)?)?)? + +yield_stmt + : yield_expr ; -import_stmt: import_name | import_from + +raise_stmt + : 'raise' (test (',' test (',' test)?)?)? ; -import_name: 'import' dotted_as_names + +import_stmt + : import_name + | import_from ; -import_from: ('from' ('.'* dotted_name | '.'+) - 'import' ('*' | '(' import_as_names ')' | import_as_names)) + +import_name + : 'import' dotted_as_names ; -import_as_name: NAME ('as' NAME)? + +import_from + : ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) ; -dotted_as_name: dotted_name ('as' NAME)? + +import_as_name + : NAME ('as' NAME)? ; -import_as_names: import_as_name (',' import_as_name)* (',')? + +dotted_as_name + : dotted_name ('as' NAME)? ; -dotted_as_names: dotted_as_name (',' dotted_as_name)* + +import_as_names + : import_as_name (',' import_as_name)* (',')? ; -dotted_name: NAME ('.' NAME)* + +dotted_as_names + : dotted_as_name (',' dotted_as_name)* ; -global_stmt: 'global' NAME (',' NAME)* + +dotted_name + : NAME ('.' NAME)* ; -exec_stmt: 'exec' expr ('in' test (',' test)?)? + +global_stmt + : 'global' NAME (',' NAME)* ; -assert_stmt: 'assert' test (',' test)? + +exec_stmt + : 'exec' expr ('in' test (',' test)?)? ; +assert_stmt + : 'assert' test (',' test)? + ; -compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated +compound_stmt + : if_stmt + | while_stmt + | for_stmt + | try_stmt + | with_stmt + | funcdef + | classdef + | decorated ; -if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)? + +if_stmt + : 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)? ; -while_stmt: 'while' test ':' suite ('else' ':' suite)? + +while_stmt + : 'while' test ':' suite ('else' ':' suite)? ; -for_stmt: 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)? + +for_stmt + : 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)? ; -try_stmt: ('try' ':' suite - ((except_clause ':' suite)+ - ('else' ':' suite)? - ('finally' ':' suite)? | - 'finally' ':' suite)) + +try_stmt + : ( + 'try' ':' suite ( + (except_clause ':' suite)+ ('else' ':' suite)? ('finally' ':' suite)? + | 'finally' ':' suite + ) + ) ; -with_stmt: 'with' with_item (',' with_item)* ':' suite + +with_stmt + : 'with' with_item (',' with_item)* ':' suite ; -with_item: test ('as' expr)? -// NB compile.c makes sure that the default except clause is last + +with_item + : test ('as' expr)? + // NB compile.c makes sure that the default except clause is last ; -except_clause: 'except' (test (('as' | ',') test)?)? + +except_clause + : 'except' (test (('as' | ',') test)?)? ; -suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT + +suite + : simple_stmt + | NEWLINE INDENT stmt+ DEDENT ; + // Backward compatibility cruft to support: // [ x for x in lambda: True, lambda: False if x() ] // even while also allowing: // lambda x: 5 if x else 2 // (But not a mix of the two) -testlist_safe: old_test ((',' old_test)+ (',')?)? - ; -old_test: or_test | old_lambdef +testlist_safe + : old_test ((',' old_test)+ (',')?)? ; -old_lambdef: 'lambda' (varargslist)? ':' old_test - ; - -test: or_test ('if' or_test 'else' test)? | lambdef - ; -or_test: and_test ('or' and_test)* - ; -and_test: not_test ('and' not_test)* +old_test + : or_test + | old_lambdef ; -not_test: 'not' not_test | comparison - ; -comparison: expr (comp_op expr)* + +old_lambdef + : 'lambda' (varargslist)? ':' old_test ; -comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' + +test + : or_test ('if' or_test 'else' test)? + | lambdef ; -expr: xor_expr ('|' xor_expr)* + +or_test + : and_test ('or' and_test)* ; -xor_expr: and_expr ('^' and_expr)* + +and_test + : not_test ('and' not_test)* ; -and_expr: shift_expr ('&' shift_expr)* + +not_test + : 'not' not_test + | comparison ; -shift_expr: arith_expr (('<<'|'>>') arith_expr)* + +comparison + : expr (comp_op expr)* ; -arith_expr: term (('+'|'-') term)* + +comp_op + : '<' + | '>' + | '==' + | '>=' + | '<=' + | '<>' + | '!=' + | 'in' + | 'not' 'in' + | 'is' + | 'is' 'not' ; -term: factor (('*'|'/'|'%'|'//') factor)* + +expr + : xor_expr ('|' xor_expr)* ; -factor: ('+'|'-'|'~') factor | power + +xor_expr + : and_expr ('^' and_expr)* ; -power: atom trailer* ('**' factor)? + +and_expr + : shift_expr ('&' shift_expr)* ; -atom: ('(' (yield_expr|testlist_comp)? ')' | - '[' (listmaker)? ']' | - '{' (dictorsetmaker)? '}' | - '`' testlist1 '`' | '.' '.' '.' | // tt: added elipses. - NAME | NUMBER | STRING+) + +shift_expr + : arith_expr (('<<' | '>>') arith_expr)* ; -listmaker: test ( list_for | (',' test)* (',')? ) + +arith_expr + : term (('+' | '-') term)* ; -testlist_comp: test ( comp_for | (',' test)* (',')? ) + +term + : factor (('*' | '/' | '%' | '//') factor)* ; -lambdef: 'lambda' (varargslist)? ':' test + +factor + : ('+' | '-' | '~') factor + | power ; -trailer: '(' (arglist)? ')' | '[' subscriptlist ']' | '.' NAME + +power + : atom trailer* ('**' factor)? ; -subscriptlist: subscript (',' subscript)* (',')? + +atom + : ( + '(' (yield_expr | testlist_comp)? ')' + | '[' (listmaker)? ']' + | '{' (dictorsetmaker)? '}' + | '`' testlist1 '`' + | '.' '.' '.' + | // tt: added elipses. + NAME + | NUMBER + | STRING+ + ) ; -subscript: '.' '.' '.' | test | (test)? ':' (test)? (sliceop)? + +listmaker + : test (list_for | (',' test)* (',')?) ; -sliceop: ':' (test)? + +testlist_comp + : test (comp_for | (',' test)* (',')?) ; -exprlist: expr (',' expr)* (',')? + +lambdef + : 'lambda' (varargslist)? ':' test ; -testlist: test (',' test)* (',')? + +trailer + : '(' (arglist)? ')' + | '[' subscriptlist ']' + | '.' NAME ; -dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* (',')?)) | - (test (comp_for | (',' test)* (',')?)) ) + +subscriptlist + : subscript (',' subscript)* (',')? ; +subscript + : '.' '.' '.' + | test + | (test)? ':' (test)? (sliceop)? + ; -classdef: 'class' NAME ('(' (testlist)? ')')? ':' suite +sliceop + : ':' (test)? ; +exprlist + : expr (',' expr)* (',')? + ; -arglist: (argument ',')* (argument (',')? - |'*' test (',' argument)* (',' '**' test)? - |'**' test) -// The reason that keywords are test nodes instead of NAME is that using NAME -// results in an ambiguity. ast.c makes sure it's a NAME. +testlist + : test (',' test)* (',')? ; -argument: test (comp_for)? | test '=' test + +dictorsetmaker + : ( + (test ':' test (comp_for | (',' test ':' test)* (',')?)) + | (test (comp_for | (',' test)* (',')?)) + ) ; +classdef + : 'class' NAME ('(' (testlist)? ')')? ':' suite + ; -list_iter: list_for | list_if +arglist + : (argument ',')* (argument (',')? | '*' test (',' argument)* (',' '**' test)? | '**' test) + // The reason that keywords are test nodes instead of NAME is that using NAME + // results in an ambiguity. ast.c makes sure it's a NAME. ; -list_for: 'for' exprlist 'in' testlist_safe (list_iter)? + +argument + : test (comp_for)? + | test '=' test ; -list_if: 'if' old_test (list_iter)? + +list_iter + : list_for + | list_if ; +list_for + : 'for' exprlist 'in' testlist_safe (list_iter)? + ; -comp_iter: comp_for | comp_if +list_if + : 'if' old_test (list_iter)? ; -comp_for: 'for' exprlist 'in' or_test (comp_iter)? + +comp_iter + : comp_for + | comp_if ; -comp_if: 'if' old_test (comp_iter)? + +comp_for + : 'for' exprlist 'in' or_test (comp_iter)? ; +comp_if + : 'if' old_test (comp_iter)? + ; -testlist1: test (',' test)* +testlist1 + : test (',' test)* ; // not used in grammar, but may appear in "node" passed from Parser to Compiler -encoding_decl: NAME +encoding_decl + : NAME ; -yield_expr: 'yield' 'from'? (testlist)? +yield_expr + : 'yield' 'from'? (testlist)? ; - + /***************************************************************************** * Lexer rules *****************************************************************************/ -NAME: [a-zA-Z_] [a-zA-Z0-9_]* +NAME + : [a-zA-Z_] [a-zA-Z0-9_]* ; NUMBER - : '0' ([xX] [0-9a-fA-F]+ ([lL] | [eE] [+-]? [0-9]+)? - | [oO] [0-7]+ [lL]? - | [bB] [01]+ [lL]?) - | ([0-9]+ '.' [0-9]* | '.' [0-9]+) ([eE] [+-]? [0-9]+)? [jJ]? - | [0-9]+ ([lL] | [eE] [+-]? [0-9]+ [jJ]? | [jJ])? + : '0' ([xX] [0-9a-fA-F]+ ([lL] | [eE] [+-]? [0-9]+)? | [oO] [0-7]+ [lL]? | [bB] [01]+ [lL]?) + | ([0-9]+ '.' [0-9]* | '.' [0-9]+) ([eE] [+-]? [0-9]+)? [jJ]? + | [0-9]+ ([lL] | [eE] [+-]? [0-9]+ [jJ]? | [jJ])? ; STRING - : ([uUbB]? [rR]? | [rR]? [uUbB]?) - ( '\'' ('\\' (([ \t]+ ('\r'? '\n')?)|.) | ~[\\\r\n'])* '\'' - | '"' ('\\' (([ \t]+ ('\r'? '\n')?)|.) | ~[\\\r\n"])* '"' - | '"""' ('\\' . | ~'\\' )*? '"""' - | '\'\'\'' ('\\' . | ~'\\' )*? '\'\'\'' + : ([uUbB]? [rR]? | [rR]? [uUbB]?) ( + '\'' ('\\' (([ \t]+ ('\r'? '\n')?) | .) | ~[\\\r\n'])* '\'' + | '"' ('\\' (([ \t]+ ('\r'? '\n')?) | .) | ~[\\\r\n"])* '"' + | '"""' ('\\' . | ~'\\')*? '"""' + | '\'\'\'' ('\\' . | ~'\\')*? '\'\'\'' ) ; -LINENDING: (('\r'? '\n')+ {this._lineContinuation=false} - | '\\' [ \t]* ('\r'? '\n') {this._lineContinuation=true}) -{ +LINENDING + : ( + ('\r'? '\n')+ {this._lineContinuation=false} + | '\\' [ \t]* ('\r'? '\n') {this._lineContinuation=true} + ) { if (this._openBRCount == 0 && !this._lineContinuation) { if (!this._suppressNewlines) { this.emitNewline() @@ -417,10 +626,10 @@ if (this._openBRCount == 0 && !this._lineContinuation) { } } } -> channel(HIDDEN) - ; + ; -WHITESPACE: ('\t' | ' ')+ -{ +WHITESPACE + : ('\t' | ' ')+ { if (this._tokenStartColumn == 0 && this._openBRCount == 0 && !this._lineContinuation) { @@ -448,17 +657,37 @@ if (this._tokenStartColumn == 0 && this._openBRCount == 0 } } } -} -> channel(HIDDEN) +} -> channel(HIDDEN) ; -COMMENT: '#' ~[\r\n]* -> skip; +COMMENT + : '#' ~[\r\n]* -> skip + ; -OPEN_PAREN: '(' {this._openBRCount += 1}; -CLOSE_PAREN: ')' {this._openBRCount -= 1}; -OPEN_BRACE: '{' {this._openBRCount += 1}; -CLOSE_BRACE: '}' {this._openBRCount -= 1}; -OPEN_BRACKET: '[' {this._openBRCount += 1}; -CLOSE_BRACKET: ']' {this._openBRCount -= 1}; +OPEN_PAREN + : '(' {this._openBRCount += 1} + ; -UNKNOWN: . -> skip; +CLOSE_PAREN + : ')' {this._openBRCount -= 1} + ; + +OPEN_BRACE + : '{' {this._openBRCount += 1} + ; + +CLOSE_BRACE + : '}' {this._openBRCount -= 1} + ; + +OPEN_BRACKET + : '[' {this._openBRCount += 1} + ; + +CLOSE_BRACKET + : ']' {this._openBRCount -= 1} + ; +UNKNOWN + : . -> skip + ; \ No newline at end of file diff --git a/python/python2/Python2.g4 b/python/python2/Python2.g4 index a90eeb265e..b09eb84a31 100644 --- a/python/python2/Python2.g4 +++ b/python/python2/Python2.g4 @@ -9,10 +9,18 @@ * * Compiles with ANTLR 4.7, generated lexer/parser for Python 2 target. */ - - grammar Python2; - tokens { INDENT, DEDENT, NEWLINE, ENDMARKER } +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar Python2; + +tokens { + INDENT, + DEDENT, + NEWLINE, + ENDMARKER +} @lexer::header { from Python2Parser import Python2Parser @@ -110,258 +118,459 @@ def createToken(self, type_, text="", length=0): * NB: compound_stmt in single_input is followed by extra NEWLINE! */ -single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE - ; -file_input: (NEWLINE | stmt)* ENDMARKER - ; -eval_input: testlist NEWLINE* ENDMARKER +single_input + : NEWLINE + | simple_stmt + | compound_stmt NEWLINE ; +file_input + : (NEWLINE | stmt)* ENDMARKER + ; -decorator: '@' dotted_name ( '(' (arglist)? ')' )? NEWLINE +eval_input + : testlist NEWLINE* ENDMARKER ; -decorators: decorator+ + +decorator + : '@' dotted_name ('(' (arglist)? ')')? NEWLINE ; -decorated: decorators (classdef | funcdef) + +decorators + : decorator+ ; -funcdef: 'def' NAME parameters ':' suite + +decorated + : decorators (classdef | funcdef) ; -parameters: '(' (varargslist)? ')' + +funcdef + : 'def' NAME parameters ':' suite ; -varargslist: ((fpdef ('=' test)? ',')* - ('*' NAME (',' '**' NAME)? | '**' NAME) | - fpdef ('=' test)? (',' fpdef ('=' test)?)* (',')?) + +parameters + : '(' (varargslist)? ')' ; -fpdef: NAME | '(' fplist ')' + +varargslist + : ( + (fpdef ('=' test)? ',')* ('*' NAME (',' '**' NAME)? | '**' NAME) + | fpdef ('=' test)? (',' fpdef ('=' test)?)* (',')? + ) ; -fplist: fpdef (',' fpdef)* (',')? + +fpdef + : NAME + | '(' fplist ')' ; +fplist + : fpdef (',' fpdef)* (',')? + ; -stmt: simple_stmt | compound_stmt +stmt + : simple_stmt + | compound_stmt ; -simple_stmt: small_stmt (';' small_stmt)* (';')? NEWLINE + +simple_stmt + : small_stmt (';' small_stmt)* (';')? NEWLINE ; -small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | - import_stmt | global_stmt | exec_stmt | assert_stmt) + +small_stmt + : ( + expr_stmt + | print_stmt + | del_stmt + | pass_stmt + | flow_stmt + | import_stmt + | global_stmt + | exec_stmt + | assert_stmt + ) ; -expr_stmt: testlist (augassign (yield_expr|testlist) | - ('=' (yield_expr|testlist))*) + +expr_stmt + : testlist (augassign (yield_expr | testlist) | ('=' (yield_expr | testlist))*) ; -augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | - '<<=' | '>>=' | '**=' | '//=') -// For normal assignments, additional restrictions enforced by the interpreter + +augassign + : ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=') + // For normal assignments, additional restrictions enforced by the interpreter ; + //print_stmt: 'print' ( ( test (',' test)* (',')? )? | // '>>' test ( (',' test)+ (',')? )? ) // ; -print_stmt: {self._input.LT(1).text=='print'}? - // tt: this change allows print to be treated as a NAME - // while preserving the print statement syntax. - NAME ( ( test (',' test)* (',')? )? | - '>>' test ( (',' test)+ (',')? )? ) - ; -del_stmt: 'del' exprlist +print_stmt + : {self._input.LT(1).text=='print'}? + // tt: this change allows print to be treated as a NAME + // while preserving the print statement syntax. + NAME (( test (',' test)* (',')?)? | '>>' test ( (',' test)+ (',')?)?) ; -pass_stmt: 'pass' + +del_stmt + : 'del' exprlist ; -flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt + +pass_stmt + : 'pass' ; -break_stmt: 'break' + +flow_stmt + : break_stmt + | continue_stmt + | return_stmt + | raise_stmt + | yield_stmt ; -continue_stmt: 'continue' + +break_stmt + : 'break' ; -return_stmt: 'return' (testlist)? + +continue_stmt + : 'continue' ; -yield_stmt: yield_expr + +return_stmt + : 'return' (testlist)? ; -raise_stmt: 'raise' (test (',' test (',' test)?)?)? + +yield_stmt + : yield_expr ; -import_stmt: import_name | import_from + +raise_stmt + : 'raise' (test (',' test (',' test)?)?)? ; -import_name: 'import' dotted_as_names + +import_stmt + : import_name + | import_from ; -import_from: ('from' ('.'* dotted_name | '.'+) - 'import' ('*' | '(' import_as_names ')' | import_as_names)) + +import_name + : 'import' dotted_as_names ; -import_as_name: NAME ('as' NAME)? + +import_from + : ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) ; -dotted_as_name: dotted_name ('as' NAME)? + +import_as_name + : NAME ('as' NAME)? ; -import_as_names: import_as_name (',' import_as_name)* (',')? + +dotted_as_name + : dotted_name ('as' NAME)? ; -dotted_as_names: dotted_as_name (',' dotted_as_name)* + +import_as_names + : import_as_name (',' import_as_name)* (',')? ; -dotted_name: NAME ('.' NAME)* + +dotted_as_names + : dotted_as_name (',' dotted_as_name)* ; -global_stmt: 'global' NAME (',' NAME)* + +dotted_name + : NAME ('.' NAME)* ; -exec_stmt: 'exec' expr ('in' test (',' test)?)? + +global_stmt + : 'global' NAME (',' NAME)* ; -assert_stmt: 'assert' test (',' test)? + +exec_stmt + : 'exec' expr ('in' test (',' test)?)? ; +assert_stmt + : 'assert' test (',' test)? + ; -compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated +compound_stmt + : if_stmt + | while_stmt + | for_stmt + | try_stmt + | with_stmt + | funcdef + | classdef + | decorated ; -if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)? + +if_stmt + : 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)? ; -while_stmt: 'while' test ':' suite ('else' ':' suite)? + +while_stmt + : 'while' test ':' suite ('else' ':' suite)? ; -for_stmt: 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)? + +for_stmt + : 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)? ; -try_stmt: ('try' ':' suite - ((except_clause ':' suite)+ - ('else' ':' suite)? - ('finally' ':' suite)? | - 'finally' ':' suite)) + +try_stmt + : ( + 'try' ':' suite ( + (except_clause ':' suite)+ ('else' ':' suite)? ('finally' ':' suite)? + | 'finally' ':' suite + ) + ) ; -with_stmt: 'with' with_item (',' with_item)* ':' suite + +with_stmt + : 'with' with_item (',' with_item)* ':' suite ; -with_item: test ('as' expr)? -// NB compile.c makes sure that the default except clause is last + +with_item + : test ('as' expr)? + // NB compile.c makes sure that the default except clause is last ; -except_clause: 'except' (test (('as' | ',') test)?)? + +except_clause + : 'except' (test (('as' | ',') test)?)? ; -suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT + +suite + : simple_stmt + | NEWLINE INDENT stmt+ DEDENT ; + // Backward compatibility cruft to support: // [ x for x in lambda: True, lambda: False if x() ] // even while also allowing: // lambda x: 5 if x else 2 // (But not a mix of the two) -testlist_safe: old_test ((',' old_test)+ (',')?)? - ; -old_test: or_test | old_lambdef +testlist_safe + : old_test ((',' old_test)+ (',')?)? ; -old_lambdef: 'lambda' (varargslist)? ':' old_test - ; - -test: or_test ('if' or_test 'else' test)? | lambdef - ; -or_test: and_test ('or' and_test)* - ; -and_test: not_test ('and' not_test)* +old_test + : or_test + | old_lambdef ; -not_test: 'not' not_test | comparison - ; -comparison: expr (comp_op expr)* + +old_lambdef + : 'lambda' (varargslist)? ':' old_test ; -comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' + +test + : or_test ('if' or_test 'else' test)? + | lambdef ; -expr: xor_expr ('|' xor_expr)* + +or_test + : and_test ('or' and_test)* ; -xor_expr: and_expr ('^' and_expr)* + +and_test + : not_test ('and' not_test)* ; -and_expr: shift_expr ('&' shift_expr)* + +not_test + : 'not' not_test + | comparison ; -shift_expr: arith_expr (('<<'|'>>') arith_expr)* + +comparison + : expr (comp_op expr)* ; -arith_expr: term (('+'|'-') term)* + +comp_op + : '<' + | '>' + | '==' + | '>=' + | '<=' + | '<>' + | '!=' + | 'in' + | 'not' 'in' + | 'is' + | 'is' 'not' ; -term: factor (('*'|'/'|'%'|'//') factor)* + +expr + : xor_expr ('|' xor_expr)* ; -factor: ('+'|'-'|'~') factor | power + +xor_expr + : and_expr ('^' and_expr)* ; -power: atom trailer* ('**' factor)? + +and_expr + : shift_expr ('&' shift_expr)* ; -atom: ('(' (yield_expr|testlist_comp)? ')' | - '[' (listmaker)? ']' | - '{' (dictorsetmaker)? '}' | - '`' testlist1 '`' | '.' '.' '.' | // tt: added elipses. - NAME | NUMBER | STRING+) + +shift_expr + : arith_expr (('<<' | '>>') arith_expr)* ; -listmaker: test ( list_for | (',' test)* (',')? ) + +arith_expr + : term (('+' | '-') term)* ; -testlist_comp: test ( comp_for | (',' test)* (',')? ) + +term + : factor (('*' | '/' | '%' | '//') factor)* ; -lambdef: 'lambda' (varargslist)? ':' test + +factor + : ('+' | '-' | '~') factor + | power ; -trailer: '(' (arglist)? ')' | '[' subscriptlist ']' | '.' NAME + +power + : atom trailer* ('**' factor)? ; -subscriptlist: subscript (',' subscript)* (',')? + +atom + : ( + '(' (yield_expr | testlist_comp)? ')' + | '[' (listmaker)? ']' + | '{' (dictorsetmaker)? '}' + | '`' testlist1 '`' + | '.' '.' '.' + | // tt: added elipses. + NAME + | NUMBER + | STRING+ + ) ; -subscript: '.' '.' '.' | test | (test)? ':' (test)? (sliceop)? + +listmaker + : test (list_for | (',' test)* (',')?) ; -sliceop: ':' (test)? + +testlist_comp + : test (comp_for | (',' test)* (',')?) ; -exprlist: expr (',' expr)* (',')? + +lambdef + : 'lambda' (varargslist)? ':' test ; -testlist: test (',' test)* (',')? + +trailer + : '(' (arglist)? ')' + | '[' subscriptlist ']' + | '.' NAME ; -dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* (',')?)) | - (test (comp_for | (',' test)* (',')?)) ) + +subscriptlist + : subscript (',' subscript)* (',')? ; +subscript + : '.' '.' '.' + | test + | (test)? ':' (test)? (sliceop)? + ; -classdef: 'class' NAME ('(' (testlist)? ')')? ':' suite +sliceop + : ':' (test)? ; +exprlist + : expr (',' expr)* (',')? + ; -arglist: (argument ',')* (argument (',')? - |'*' test (',' argument)* (',' '**' test)? - |'**' test) -// The reason that keywords are test nodes instead of NAME is that using NAME -// results in an ambiguity. ast.c makes sure it's a NAME. +testlist + : test (',' test)* (',')? ; -argument: test (comp_for)? | test '=' test + +dictorsetmaker + : ( + (test ':' test (comp_for | (',' test ':' test)* (',')?)) + | (test (comp_for | (',' test)* (',')?)) + ) ; +classdef + : 'class' NAME ('(' (testlist)? ')')? ':' suite + ; -list_iter: list_for | list_if +arglist + : (argument ',')* (argument (',')? | '*' test (',' argument)* (',' '**' test)? | '**' test) + // The reason that keywords are test nodes instead of NAME is that using NAME + // results in an ambiguity. ast.c makes sure it's a NAME. ; -list_for: 'for' exprlist 'in' testlist_safe (list_iter)? + +argument + : test (comp_for)? + | test '=' test ; -list_if: 'if' old_test (list_iter)? + +list_iter + : list_for + | list_if ; +list_for + : 'for' exprlist 'in' testlist_safe (list_iter)? + ; -comp_iter: comp_for | comp_if +list_if + : 'if' old_test (list_iter)? ; -comp_for: 'for' exprlist 'in' or_test (comp_iter)? + +comp_iter + : comp_for + | comp_if ; -comp_if: 'if' old_test (comp_iter)? + +comp_for + : 'for' exprlist 'in' or_test (comp_iter)? ; +comp_if + : 'if' old_test (comp_iter)? + ; -testlist1: test (',' test)* +testlist1 + : test (',' test)* ; // not used in grammar, but may appear in "node" passed from Parser to Compiler -encoding_decl: NAME +encoding_decl + : NAME ; -yield_expr: 'yield' 'from'? (testlist)? +yield_expr + : 'yield' 'from'? (testlist)? ; - + /***************************************************************************** * Lexer rules *****************************************************************************/ -NAME: [a-zA-Z_] [a-zA-Z0-9_]* +NAME + : [a-zA-Z_] [a-zA-Z0-9_]* ; NUMBER - : '0' ([xX] [0-9a-fA-F]+ ([lL] | [eE] [+-]? [0-9]+)? - | [oO] [0-7]+ [lL]? - | [bB] [01]+ [lL]?) - | ([0-9]+ '.' [0-9]* | '.' [0-9]+) ([eE] [+-]? [0-9]+)? [jJ]? - | [0-9]+ ([lL] | [eE] [+-]? [0-9]+ [jJ]? | [jJ])? + : '0' ([xX] [0-9a-fA-F]+ ([lL] | [eE] [+-]? [0-9]+)? | [oO] [0-7]+ [lL]? | [bB] [01]+ [lL]?) + | ([0-9]+ '.' [0-9]* | '.' [0-9]+) ([eE] [+-]? [0-9]+)? [jJ]? + | [0-9]+ ([lL] | [eE] [+-]? [0-9]+ [jJ]? | [jJ])? ; STRING - : ([uUbB]? [rR]? | [rR]? [uUbB]?) - ( '\'' ('\\' (([ \t]+ ('\r'? '\n')?)|.) | ~[\\\r\n'])* '\'' - | '"' ('\\' (([ \t]+ ('\r'? '\n')?)|.) | ~[\\\r\n"])* '"' - | '"""' ('\\' . | ~'\\' )*? '"""' - | '\'\'\'' ('\\' . | ~'\\' )*? '\'\'\'' + : ([uUbB]? [rR]? | [rR]? [uUbB]?) ( + '\'' ('\\' (([ \t]+ ('\r'? '\n')?) | .) | ~[\\\r\n'])* '\'' + | '"' ('\\' (([ \t]+ ('\r'? '\n')?) | .) | ~[\\\r\n"])* '"' + | '"""' ('\\' . | ~'\\')*? '"""' + | '\'\'\'' ('\\' . | ~'\\')*? '\'\'\'' ) ; -LINENDING: (('\r'? '\n')+ {self._lineContinuation=False} - | '\\' [ \t]* ('\r'? '\n') {self._lineContinuation=True}) -{ +LINENDING + : ( + ('\r'? '\n')+ {self._lineContinuation=False} + | '\\' [ \t]* ('\r'? '\n') {self._lineContinuation=True} + ) { if self._openBRCount == 0 and not self._lineContinuation: if not self._suppressNewlines: self.emitNewline() @@ -371,10 +580,10 @@ if self._openBRCount == 0 and not self._lineContinuation: self._suppressNewlines = False self.emitFullDedent() } -> channel(HIDDEN) - ; + ; -WHITESPACE: ('\t' | ' ')+ -{ +WHITESPACE + : ('\t' | ' ')+ { if (self._tokenStartColumn == 0 and self._openBRCount == 0 and not self._lineContinuation): @@ -395,17 +604,37 @@ if (self._tokenStartColumn == 0 and self._openBRCount == 0 self._indents.pop() if wsCount != self._indents.wsval(): raise Exception() -} -> channel(HIDDEN) +} -> channel(HIDDEN) ; -COMMENT: '#' ~[\r\n]* -> skip; +COMMENT + : '#' ~[\r\n]* -> skip + ; -OPEN_PAREN: '(' {self._openBRCount += 1}; -CLOSE_PAREN: ')' {self._openBRCount -= 1}; -OPEN_BRACE: '{' {self._openBRCount += 1}; -CLOSE_BRACE: '}' {self._openBRCount -= 1}; -OPEN_BRACKET: '[' {self._openBRCount += 1}; -CLOSE_BRACKET: ']' {self._openBRCount -= 1}; +OPEN_PAREN + : '(' {self._openBRCount += 1} + ; -UNKNOWN: . -> skip; +CLOSE_PAREN + : ')' {self._openBRCount -= 1} + ; + +OPEN_BRACE + : '{' {self._openBRCount += 1} + ; + +CLOSE_BRACE + : '}' {self._openBRCount -= 1} + ; + +OPEN_BRACKET + : '[' {self._openBRCount += 1} + ; + +CLOSE_BRACKET + : ']' {self._openBRCount -= 1} + ; +UNKNOWN + : . -> skip + ; \ No newline at end of file diff --git a/python/python2_7_18/PythonLexer.g4 b/python/python2_7_18/PythonLexer.g4 index 6a045a38a6..8b9daddb38 100644 --- a/python/python2_7_18/PythonLexer.g4 +++ b/python/python2_7_18/PythonLexer.g4 @@ -20,16 +20,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /* +/* * Project : an ANTLR4 lexer grammar for Python 2.7.18 * https://github.com/RobEin/ANTLR4-parser-for-Python-2.7.18 * Developed by : Robert Einhorn, robert.einhorn.hu@gmail.com * */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PythonLexer; -options { superClass=PythonLexerBase; } -tokens { INDENT, DEDENT } // https://docs.python.org/2.7/reference/lexical_analysis.html#indentation +options { + superClass = PythonLexerBase; +} +tokens { + INDENT, + DEDENT +} // https://docs.python.org/2.7/reference/lexical_analysis.html#indentation /* * lexer rules // https://docs.python.org/2.7/library/tokenize.html @@ -69,12 +78,12 @@ WITH : 'with'; YIELD : 'yield'; // https://docs.python.org/2.7/library/token.html#token.OP -LPAR : '('; // OPEN_PAREN -LSQB : '['; // OPEN_BRACK -LBRACE : '{'; // OPEN_BRACE -RPAR : ')'; // CLOSE_PAREN -RSQB : ']'; // CLOSE_BRACK -RBRACE : '}'; // CLOSE_BRACE +LPAR : '('; // OPEN_PAREN +LSQB : '['; // OPEN_BRACK +LBRACE : '{'; // OPEN_BRACE +RPAR : ')'; // CLOSE_PAREN +RSQB : ']'; // CLOSE_BRACK +RBRACE : '}'; // CLOSE_BRACE COLON : ':'; COMMA : ','; SEMI : ';'; @@ -115,35 +124,28 @@ DOUBLESLASH : '//'; DOUBLESLASHEQUAL : '//='; AT : '@'; - // https://docs.python.org/2.7/reference/lexical_analysis.html#identifiers -NAME : IDENTIFIER; +NAME: IDENTIFIER; // https://docs.python.org/2.7/reference/lexical_analysis.html#numeric-literals -NUMBER - : INTEGER - | LONG_INTEGER - | FLOAT_NUMBER - | IMAG_NUMBER - ; +NUMBER: INTEGER | LONG_INTEGER | FLOAT_NUMBER | IMAG_NUMBER; // https://docs.python.org/2.7/reference/lexical_analysis.html#string-literals -STRING : STRING_LITERAL; +STRING: STRING_LITERAL; // https://docs.python.org/2.7/reference/lexical_analysis.html#physical-lines -NEWLINE : OS_INDEPENDENT_NL; +NEWLINE: OS_INDEPENDENT_NL; // https://docs.python.org/2.7/reference/lexical_analysis.html#comments -COMMENT : '#' ~[\r\n]* -> channel(HIDDEN); +COMMENT: '#' ~[\r\n]* -> channel(HIDDEN); // https://docs.python.org/2.7/reference/lexical_analysis.html#whitespace-between-tokens -WS : [ \t\f]+ -> channel(HIDDEN); +WS: [ \t\f]+ -> channel(HIDDEN); // https://docs.python.org/2.7/reference/lexical_analysis.html#explicit-line-joining -EXPLICIT_LINE_JOINING : '\\' NEWLINE -> channel(HIDDEN); - -ERROR_TOKEN : . ; // catch unrecognized characters and redirect these errors to the parser +EXPLICIT_LINE_JOINING: '\\' NEWLINE -> channel(HIDDEN); +ERROR_TOKEN: .; // catch unrecognized characters and redirect these errors to the parser /* * fragments @@ -152,31 +154,47 @@ ERROR_TOKEN : . ; // catch unrecognized characters and redirect these errors to // https://docs.python.org/2.7/reference/lexical_analysis.html#literals // https://docs.python.org/2.7/reference/lexical_analysis.html#string-literals -fragment STRING_LITERAL : STRING_PREFIX? (SHORT_STRING | LONG_STRING); -fragment STRING_PREFIX : 'r' | 'u' | 'ur' | 'R' | 'U' | 'UR' | 'Ur' | 'uR' | 'b' | 'B' | 'br' | 'Br' | 'bR' | 'BR'; - -fragment SHORT_STRING - : '\'' SHORT_STRING_ITEM_FOR_SINGLE_QUOTE* '\'' - | '"' SHORT_STRING_ITEM_FOR_DOUBLE_QUOTE* '"' - ; - -fragment LONG_STRING - : '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' - | '"""' LONG_STRING_ITEM*? '"""' - ; +fragment STRING_LITERAL: STRING_PREFIX? (SHORT_STRING | LONG_STRING); +fragment STRING_PREFIX: + 'r' + | 'u' + | 'ur' + | 'R' + | 'U' + | 'UR' + | 'Ur' + | 'uR' + | 'b' + | 'B' + | 'br' + | 'Br' + | 'bR' + | 'BR' +; + +fragment SHORT_STRING: + '\'' SHORT_STRING_ITEM_FOR_SINGLE_QUOTE* '\'' + | '"' SHORT_STRING_ITEM_FOR_DOUBLE_QUOTE* '"' +; + +fragment LONG_STRING: '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' | '"""' LONG_STRING_ITEM*? '"""'; fragment SHORT_STRING_ITEM_FOR_SINGLE_QUOTE : SHORT_STRING_CHAR_NO_SINGLE_QUOTE | ESCAPE_SEQ; fragment SHORT_STRING_ITEM_FOR_DOUBLE_QUOTE : SHORT_STRING_CHAR_NO_DOUBLE_QUOTE | ESCAPE_SEQ; -fragment LONG_STRING_ITEM : LONG_STRING_CHAR | ESCAPE_SEQ; +fragment LONG_STRING_ITEM: LONG_STRING_CHAR | ESCAPE_SEQ; -fragment SHORT_STRING_CHAR_NO_SINGLE_QUOTE : ~[\\\r\n']; // -fragment SHORT_STRING_CHAR_NO_DOUBLE_QUOTE : ~[\\\r\n"]; // -fragment LONG_STRING_CHAR : ~'\\'; // -fragment ESCAPE_SEQ - : '\\' OS_INDEPENDENT_NL // \ escape sequence - | '\\' [\u0000-\u007F] // "\" - ; // the \ (not \n) escape sequences will be removed from the string literals by the PythonLexerBase class +fragment SHORT_STRING_CHAR_NO_SINGLE_QUOTE: + ~[\\\r\n'] +; // +fragment SHORT_STRING_CHAR_NO_DOUBLE_QUOTE: + ~[\\\r\n"] +; // +fragment LONG_STRING_CHAR: ~'\\'; // +fragment ESCAPE_SEQ: + '\\' OS_INDEPENDENT_NL // \ escape sequence + | '\\' [\u0000-\u007F] // "\" +; // the \ (not \n) escape sequences will be removed from the string literals by the PythonLexerBase class // https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals fragment LONG_INTEGER : INTEGER ('l' | 'L'); @@ -199,14 +217,14 @@ fragment FRACTION : '.' DIGIT+; fragment EXPONENT : ('e' | 'E') ('+' | '-')? DIGIT+; // https://docs.python.org/2.7/reference/lexical_analysis.html#imaginary-literals -fragment IMAG_NUMBER : (FLOAT_NUMBER | INT_PART) ('j' | 'J'); +fragment IMAG_NUMBER: (FLOAT_NUMBER | INT_PART) ('j' | 'J'); // https://docs.python.org/2.7/reference/lexical_analysis.html#physical-lines -fragment OS_INDEPENDENT_NL : '\r'? '\n'; // Unix, Windows +fragment OS_INDEPENDENT_NL: '\r'? '\n'; // Unix, Windows // https://docs.python.org/2.7/reference/lexical_analysis.html#identifiers fragment IDENTIFIER : (LETTER | '_') (LETTER | DIGIT | '_')*; fragment LETTER : LOWERCASE | UPPERCASE; fragment LOWERCASE : [a-z]; fragment UPPERCASE : [A-Z]; -fragment DIGIT : [0-9]; +fragment DIGIT : [0-9]; \ No newline at end of file diff --git a/python/python2_7_18/PythonParser.g4 b/python/python2_7_18/PythonParser.g4 index adb24d77d4..7423635403 100644 --- a/python/python2_7_18/PythonParser.g4 +++ b/python/python2_7_18/PythonParser.g4 @@ -20,14 +20,23 @@ 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 Python 2.7.18 grammar * https://github.com/RobEin/ANTLR4-parser-for-Python-2.7.18 * Developed by : Robert Einhorn */ -parser grammar PythonParser; // https://docs.python.org/2.7/reference/grammar.html -options { tokenVocab=PythonLexer; } +// $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 PythonParser; + +// https://docs.python.org/2.7/reference/grammar.html + +options { + tokenVocab = PythonLexer; +} + // ANTLR4 grammar for Python // Start symbols for the grammar: @@ -35,128 +44,419 @@ options { tokenVocab=PythonLexer; } // file_input is a module or sequence of commands read from an input file; // eval_input is the input for the eval() and input() functions. // NB: compound_stmt in single_input is followed by extra NEWLINE! -single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE; -file_input: (NEWLINE | stmt)* EOF; -eval_input: testlist NEWLINE* EOF; - -decorator: '@' dotted_name ( '(' arglist? ')' )? NEWLINE; -decorators: decorator+; -decorated: decorators (classdef | funcdef); -funcdef: 'def' NAME parameters ':' suite; -parameters: '(' varargslist? ')'; -varargslist: ((fpdef ('=' test)? ',')* - ('*' NAME (',' '**' NAME)? | '**' NAME) | - fpdef ('=' test)? (',' fpdef ('=' test)?)* ','?); -fpdef: NAME | '(' fplist ')'; -fplist: fpdef (',' fpdef)* ','?; - -stmt: simple_stmt | compound_stmt; -simple_stmt: small_stmt (';' small_stmt)* ';'? NEWLINE; -small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | - import_stmt | global_stmt | exec_stmt | assert_stmt); -expr_stmt: testlist (augassign (yield_expr|testlist) | - ('=' (yield_expr|testlist))*); -augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | - '<<=' | '>>=' | '**=' | '//='); +single_input + : NEWLINE + | simple_stmt + | compound_stmt NEWLINE + ; + +file_input + : (NEWLINE | stmt)* EOF + ; + +eval_input + : testlist NEWLINE* EOF + ; + +decorator + : '@' dotted_name ('(' arglist? ')')? NEWLINE + ; + +decorators + : decorator+ + ; + +decorated + : decorators (classdef | funcdef) + ; + +funcdef + : 'def' NAME parameters ':' suite + ; + +parameters + : '(' varargslist? ')' + ; + +varargslist + : ( + (fpdef ('=' test)? ',')* ('*' NAME (',' '**' NAME)? | '**' NAME) + | fpdef ('=' test)? (',' fpdef ('=' test)?)* ','? + ) + ; + +fpdef + : NAME + | '(' fplist ')' + ; + +fplist + : fpdef (',' fpdef)* ','? + ; + +stmt + : simple_stmt + | compound_stmt + ; + +simple_stmt + : small_stmt (';' small_stmt)* ';'? NEWLINE + ; + +small_stmt + : ( + expr_stmt + | print_stmt + | del_stmt + | pass_stmt + | flow_stmt + | import_stmt + | global_stmt + | exec_stmt + | assert_stmt + ) + ; + +expr_stmt + : testlist (augassign (yield_expr | testlist) | ('=' (yield_expr | testlist))*) + ; + +augassign + : ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=') + ; + // For normal assignments, additional restrictions enforced by the interpreter -print_stmt: 'print' ( ( test (',' test)* ','? )? | - '>>' test ( (',' test)+ ','? )? ); -del_stmt: 'del' exprlist; -pass_stmt: 'pass'; -flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt; -break_stmt: 'break'; -continue_stmt: 'continue'; -return_stmt: 'return' testlist?; -yield_stmt: yield_expr; -raise_stmt: 'raise' (test (',' test (',' test)?)?)?; -import_stmt: import_name | import_from; -import_name: 'import' dotted_as_names; -import_from: ('from' ('.'* dotted_name | '.'+) - 'import' ('*' | '(' import_as_names ')' | import_as_names)); -import_as_name: NAME ('as' NAME)?; -dotted_as_name: dotted_name ('as' NAME)?; -import_as_names: import_as_name (',' import_as_name)* ','?; -dotted_as_names: dotted_as_name (',' dotted_as_name)*; -dotted_name: NAME ('.' NAME)*; -global_stmt: 'global' NAME (',' NAME)*; -exec_stmt: 'exec' expr ('in' test (',' test)?)?; -assert_stmt: 'assert' test (',' test)?; - -compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated; -if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)?; -while_stmt: 'while' test ':' suite ('else' ':' suite)?; -for_stmt: 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)?; -try_stmt: ('try' ':' suite - ((except_clause ':' suite)+ - ('else' ':' suite)? - ('finally' ':' suite)? | - 'finally' ':' suite)); -with_stmt: 'with' with_item (',' with_item)* ':' suite; -with_item: test ('as' expr)?; +print_stmt + : 'print' (( test (',' test)* ','?)? | '>>' test ( (',' test)+ ','?)?) + ; + +del_stmt + : 'del' exprlist + ; + +pass_stmt + : 'pass' + ; + +flow_stmt + : break_stmt + | continue_stmt + | return_stmt + | raise_stmt + | yield_stmt + ; + +break_stmt + : 'break' + ; + +continue_stmt + : 'continue' + ; + +return_stmt + : 'return' testlist? + ; + +yield_stmt + : yield_expr + ; + +raise_stmt + : 'raise' (test (',' test (',' test)?)?)? + ; + +import_stmt + : import_name + | import_from + ; + +import_name + : 'import' dotted_as_names + ; + +import_from + : ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) + ; + +import_as_name + : NAME ('as' NAME)? + ; + +dotted_as_name + : dotted_name ('as' NAME)? + ; + +import_as_names + : import_as_name (',' import_as_name)* ','? + ; + +dotted_as_names + : dotted_as_name (',' dotted_as_name)* + ; + +dotted_name + : NAME ('.' NAME)* + ; + +global_stmt + : 'global' NAME (',' NAME)* + ; + +exec_stmt + : 'exec' expr ('in' test (',' test)?)? + ; + +assert_stmt + : 'assert' test (',' test)? + ; + +compound_stmt + : if_stmt + | while_stmt + | for_stmt + | try_stmt + | with_stmt + | funcdef + | classdef + | decorated + ; + +if_stmt + : 'if' test ':' suite ('elif' test ':' suite)* ('else' ':' suite)? + ; + +while_stmt + : 'while' test ':' suite ('else' ':' suite)? + ; + +for_stmt + : 'for' exprlist 'in' testlist ':' suite ('else' ':' suite)? + ; + +try_stmt + : ( + 'try' ':' suite ( + (except_clause ':' suite)+ ('else' ':' suite)? ('finally' ':' suite)? + | 'finally' ':' suite + ) + ) + ; + +with_stmt + : 'with' with_item (',' with_item)* ':' suite + ; + +with_item + : test ('as' expr)? + ; + // NB compile.c makes sure that the default except clause is last -except_clause: 'except' (test (('as' | ',') test)?)?; -suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT; +except_clause + : 'except' (test (('as' | ',') test)?)? + ; + +suite + : simple_stmt + | NEWLINE INDENT stmt+ DEDENT + ; // Backward compatibility cruft to support: // [ x for x in lambda: True, lambda: False if x() ] // even while also allowing: // lambda x: 5 if x else 2 // (But not a mix of the two) -testlist_safe: old_test ((',' old_test)+ ','?)?; -old_test: or_test | old_lambdef; -old_lambdef: 'lambda' varargslist? ':' old_test; - -test: or_test ('if' or_test 'else' test)? | lambdef; -or_test: and_test ('or' and_test)*; -and_test: not_test ('and' not_test)*; -not_test: 'not' not_test | comparison; -comparison: expr (comp_op expr)*; -comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'; -expr: xor_expr ('|' xor_expr)*; -xor_expr: and_expr ('^' and_expr)*; -and_expr: shift_expr ('&' shift_expr)*; -shift_expr: arith_expr (('<<'|'>>') arith_expr)*; -arith_expr: term (('+'|'-') term)*; -term: factor (('*'|'/'|'%'|'//') factor)*; -factor: ('+'|'-'|'~') factor | power; -power: atom trailer* ('**' factor)?; -atom: ('(' (yield_expr|testlist_comp)? ')' | - '[' listmaker? ']' | - '{' dictorsetmaker? '}' | - '`' testlist1 '`' | - NAME | NUMBER | STRING+); -listmaker: test ( list_for | (',' test)* ','? ); -testlist_comp: test ( comp_for | (',' test)* ','? ); -lambdef: 'lambda' varargslist? ':' test; -trailer: '(' arglist? ')' | '[' subscriptlist ']' | '.' NAME; -subscriptlist: subscript (',' subscript)* ','?; -subscript: '.' '.' '.' | test | test? ':' test? sliceop?; -sliceop: ':' test?; -exprlist: expr (',' expr)* ','?; -testlist: test (',' test)* ','?; -dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* ','?)) | - (test (comp_for | (',' test)* ','?)) ); - -classdef: 'class' NAME ('(' testlist? ')')? ':' suite; - -arglist: (argument ',')* (argument ','? - |'*' test (',' argument)* (',' '**' test)? - |'**' test); +testlist_safe + : old_test ((',' old_test)+ ','?)? + ; + +old_test + : or_test + | old_lambdef + ; + +old_lambdef + : 'lambda' varargslist? ':' old_test + ; + +test + : or_test ('if' or_test 'else' test)? + | lambdef + ; + +or_test + : and_test ('or' and_test)* + ; + +and_test + : not_test ('and' not_test)* + ; + +not_test + : 'not' not_test + | comparison + ; + +comparison + : expr (comp_op expr)* + ; + +comp_op + : '<' + | '>' + | '==' + | '>=' + | '<=' + | '<>' + | '!=' + | 'in' + | 'not' 'in' + | 'is' + | 'is' 'not' + ; + +expr + : xor_expr ('|' xor_expr)* + ; + +xor_expr + : and_expr ('^' and_expr)* + ; + +and_expr + : shift_expr ('&' shift_expr)* + ; + +shift_expr + : arith_expr (('<<' | '>>') arith_expr)* + ; + +arith_expr + : term (('+' | '-') term)* + ; + +term + : factor (('*' | '/' | '%' | '//') factor)* + ; + +factor + : ('+' | '-' | '~') factor + | power + ; + +power + : atom trailer* ('**' factor)? + ; + +atom + : ( + '(' (yield_expr | testlist_comp)? ')' + | '[' listmaker? ']' + | '{' dictorsetmaker? '}' + | '`' testlist1 '`' + | NAME + | NUMBER + | STRING+ + ) + ; + +listmaker + : test (list_for | (',' test)* ','?) + ; + +testlist_comp + : test (comp_for | (',' test)* ','?) + ; + +lambdef + : 'lambda' varargslist? ':' test + ; + +trailer + : '(' arglist? ')' + | '[' subscriptlist ']' + | '.' NAME + ; + +subscriptlist + : subscript (',' subscript)* ','? + ; + +subscript + : '.' '.' '.' + | test + | test? ':' test? sliceop? + ; + +sliceop + : ':' test? + ; + +exprlist + : expr (',' expr)* ','? + ; + +testlist + : test (',' test)* ','? + ; + +dictorsetmaker + : ( + (test ':' test (comp_for | (',' test ':' test)* ','?)) + | (test (comp_for | (',' test)* ','?)) + ) + ; + +classdef + : 'class' NAME ('(' testlist? ')')? ':' suite + ; + +arglist + : (argument ',')* (argument ','? | '*' test (',' argument)* (',' '**' test)? | '**' test) + ; + // The reason that keywords are test nodes instead of NAME is that using NAME // results in an ambiguity. ast.c makes sure it's a NAME. -argument: test comp_for? | test '=' test; +argument + : test comp_for? + | test '=' test + ; + +list_iter + : list_for + | list_if + ; + +list_for + : 'for' exprlist 'in' testlist_safe list_iter? + ; + +list_if + : 'if' old_test list_iter? + ; + +comp_iter + : comp_for + | comp_if + ; -list_iter: list_for | list_if; -list_for: 'for' exprlist 'in' testlist_safe list_iter?; -list_if: 'if' old_test list_iter?; +comp_for + : 'for' exprlist 'in' or_test comp_iter? + ; -comp_iter: comp_for | comp_if; -comp_for: 'for' exprlist 'in' or_test comp_iter?; -comp_if: 'if' old_test comp_iter?; +comp_if + : 'if' old_test comp_iter? + ; -testlist1: test (',' test)*; +testlist1 + : test (',' test)* + ; // not used in grammar, but may appear in "node" passed from Parser to Compiler -encoding_decl: NAME; +encoding_decl + : NAME + ; -yield_expr: 'yield' testlist?; +yield_expr + : 'yield' testlist? + ; \ No newline at end of file diff --git a/python/python3/Python3Lexer.g4 b/python/python3/Python3Lexer.g4 index 8053f59bc2..8b36564b96 100644 --- a/python/python3/Python3Lexer.g4 +++ b/python/python3/Python3Lexer.g4 @@ -28,15 +28,23 @@ * https://github.com/bkiers/python3-parser * Developed by : Bart Kiers, bart@big-o.nl */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Python3Lexer; // All comments that start with "///" are copy-pasted from // The Python Language Reference -tokens { INDENT, DEDENT } +tokens { + INDENT, + DEDENT +} options { - superClass=Python3LexerBase; + superClass = Python3LexerBase; } // Insert here @header for C++ lexer. @@ -45,175 +53,134 @@ options { * lexer rules */ -STRING - : STRING_LITERAL - | BYTES_LITERAL - ; - -NUMBER - : INTEGER - | FLOAT_NUMBER - | IMAG_NUMBER - ; - -INTEGER - : DECIMAL_INTEGER - | OCT_INTEGER - | HEX_INTEGER - | BIN_INTEGER - ; - -AND : 'and'; -AS : 'as'; -ASSERT : 'assert'; -ASYNC : 'async'; -AWAIT : 'await'; -BREAK : 'break'; -CASE : 'case' ; -CLASS : 'class'; -CONTINUE : 'continue'; -DEF : 'def'; -DEL : 'del'; -ELIF : 'elif'; -ELSE : 'else'; -EXCEPT : 'except'; -FALSE : 'False'; -FINALLY : 'finally'; -FOR : 'for'; -FROM : 'from'; -GLOBAL : 'global'; -IF : 'if'; -IMPORT : 'import'; -IN : 'in'; -IS : 'is'; -LAMBDA : 'lambda'; -MATCH : 'match' ; -NONE : 'None'; -NONLOCAL : 'nonlocal'; -NOT : 'not'; -OR : 'or'; -PASS : 'pass'; -RAISE : 'raise'; -RETURN : 'return'; -TRUE : 'True'; -TRY : 'try'; -UNDERSCORE : '_' ; -WHILE : 'while'; -WITH : 'with'; -YIELD : 'yield'; - -NEWLINE - : ( {this.atStartOfInput()}? SPACES - | ( '\r'? '\n' | '\r' | '\f' ) SPACES? - ) - {this.onNewLine();} - ; +STRING: STRING_LITERAL | BYTES_LITERAL; + +NUMBER: INTEGER | FLOAT_NUMBER | IMAG_NUMBER; + +INTEGER: DECIMAL_INTEGER | OCT_INTEGER | HEX_INTEGER | BIN_INTEGER; + +AND : 'and'; +AS : 'as'; +ASSERT : 'assert'; +ASYNC : 'async'; +AWAIT : 'await'; +BREAK : 'break'; +CASE : 'case'; +CLASS : 'class'; +CONTINUE : 'continue'; +DEF : 'def'; +DEL : 'del'; +ELIF : 'elif'; +ELSE : 'else'; +EXCEPT : 'except'; +FALSE : 'False'; +FINALLY : 'finally'; +FOR : 'for'; +FROM : 'from'; +GLOBAL : 'global'; +IF : 'if'; +IMPORT : 'import'; +IN : 'in'; +IS : 'is'; +LAMBDA : 'lambda'; +MATCH : 'match'; +NONE : 'None'; +NONLOCAL : 'nonlocal'; +NOT : 'not'; +OR : 'or'; +PASS : 'pass'; +RAISE : 'raise'; +RETURN : 'return'; +TRUE : 'True'; +TRY : 'try'; +UNDERSCORE : '_'; +WHILE : 'while'; +WITH : 'with'; +YIELD : 'yield'; + +NEWLINE: ({this.atStartOfInput()}? SPACES | ( '\r'? '\n' | '\r' | '\f') SPACES?) {this.onNewLine();}; /// identifier ::= id_start id_continue* -NAME - : ID_START ID_CONTINUE* - ; +NAME: ID_START ID_CONTINUE*; /// stringliteral ::= [stringprefix](shortstring | longstring) /// stringprefix ::= "r" | "u" | "R" | "U" | "f" | "F" /// | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF" -STRING_LITERAL - : ( [rR] | [uU] | [fF] | ( [fF] [rR] ) | ( [rR] [fF] ) )? ( SHORT_STRING | LONG_STRING ) - ; +STRING_LITERAL: ( [rR] | [uU] | [fF] | ( [fF] [rR]) | ( [rR] [fF]))? ( SHORT_STRING | LONG_STRING); /// bytesliteral ::= bytesprefix(shortbytes | longbytes) /// bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB" -BYTES_LITERAL - : ( [bB] | ( [bB] [rR] ) | ( [rR] [bB] ) ) ( SHORT_BYTES | LONG_BYTES ) - ; +BYTES_LITERAL: ( [bB] | ( [bB] [rR]) | ( [rR] [bB])) ( SHORT_BYTES | LONG_BYTES); /// decimalinteger ::= nonzerodigit digit* | "0"+ -DECIMAL_INTEGER - : NON_ZERO_DIGIT DIGIT* - | '0'+ - ; +DECIMAL_INTEGER: NON_ZERO_DIGIT DIGIT* | '0'+; /// octinteger ::= "0" ("o" | "O") octdigit+ -OCT_INTEGER - : '0' [oO] OCT_DIGIT+ - ; +OCT_INTEGER: '0' [oO] OCT_DIGIT+; /// hexinteger ::= "0" ("x" | "X") hexdigit+ -HEX_INTEGER - : '0' [xX] HEX_DIGIT+ - ; +HEX_INTEGER: '0' [xX] HEX_DIGIT+; /// bininteger ::= "0" ("b" | "B") bindigit+ -BIN_INTEGER - : '0' [bB] BIN_DIGIT+ - ; +BIN_INTEGER: '0' [bB] BIN_DIGIT+; /// floatnumber ::= pointfloat | exponentfloat -FLOAT_NUMBER - : POINT_FLOAT - | EXPONENT_FLOAT - ; +FLOAT_NUMBER: POINT_FLOAT | EXPONENT_FLOAT; /// imagnumber ::= (floatnumber | intpart) ("j" | "J") -IMAG_NUMBER - : ( FLOAT_NUMBER | INT_PART ) [jJ] - ; - -DOT : '.'; -ELLIPSIS : '...'; -STAR : '*'; -OPEN_PAREN : '(' {this.openBrace();}; -CLOSE_PAREN : ')' {this.closeBrace();}; -COMMA : ','; -COLON : ':'; -SEMI_COLON : ';'; -POWER : '**'; -ASSIGN : '='; -OPEN_BRACK : '[' {this.openBrace();}; -CLOSE_BRACK : ']' {this.closeBrace();}; -OR_OP : '|'; -XOR : '^'; -AND_OP : '&'; -LEFT_SHIFT : '<<'; -RIGHT_SHIFT : '>>'; -ADD : '+'; -MINUS : '-'; -DIV : '/'; -MOD : '%'; -IDIV : '//'; -NOT_OP : '~'; -OPEN_BRACE : '{' {this.openBrace();}; -CLOSE_BRACE : '}' {this.closeBrace();}; -LESS_THAN : '<'; -GREATER_THAN : '>'; -EQUALS : '=='; -GT_EQ : '>='; -LT_EQ : '<='; -NOT_EQ_1 : '<>'; -NOT_EQ_2 : '!='; -AT : '@'; -ARROW : '->'; -ADD_ASSIGN : '+='; -SUB_ASSIGN : '-='; -MULT_ASSIGN : '*='; -AT_ASSIGN : '@='; -DIV_ASSIGN : '/='; -MOD_ASSIGN : '%='; -AND_ASSIGN : '&='; -OR_ASSIGN : '|='; -XOR_ASSIGN : '^='; -LEFT_SHIFT_ASSIGN : '<<='; +IMAG_NUMBER: ( FLOAT_NUMBER | INT_PART) [jJ]; + +DOT : '.'; +ELLIPSIS : '...'; +STAR : '*'; +OPEN_PAREN : '(' {this.openBrace();}; +CLOSE_PAREN : ')' {this.closeBrace();}; +COMMA : ','; +COLON : ':'; +SEMI_COLON : ';'; +POWER : '**'; +ASSIGN : '='; +OPEN_BRACK : '[' {this.openBrace();}; +CLOSE_BRACK : ']' {this.closeBrace();}; +OR_OP : '|'; +XOR : '^'; +AND_OP : '&'; +LEFT_SHIFT : '<<'; +RIGHT_SHIFT : '>>'; +ADD : '+'; +MINUS : '-'; +DIV : '/'; +MOD : '%'; +IDIV : '//'; +NOT_OP : '~'; +OPEN_BRACE : '{' {this.openBrace();}; +CLOSE_BRACE : '}' {this.closeBrace();}; +LESS_THAN : '<'; +GREATER_THAN : '>'; +EQUALS : '=='; +GT_EQ : '>='; +LT_EQ : '<='; +NOT_EQ_1 : '<>'; +NOT_EQ_2 : '!='; +AT : '@'; +ARROW : '->'; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MULT_ASSIGN : '*='; +AT_ASSIGN : '@='; +DIV_ASSIGN : '/='; +MOD_ASSIGN : '%='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +LEFT_SHIFT_ASSIGN : '<<='; RIGHT_SHIFT_ASSIGN : '>>='; -POWER_ASSIGN : '**='; -IDIV_ASSIGN : '//='; +POWER_ASSIGN : '**='; +IDIV_ASSIGN : '//='; -SKIP_ - : ( SPACES | COMMENT | LINE_JOINING ) -> skip - ; +SKIP_: ( SPACES | COMMENT | LINE_JOINING) -> skip; -UNKNOWN_CHAR - : . - ; +UNKNOWN_CHAR: .; /* * fragments @@ -222,143 +189,93 @@ UNKNOWN_CHAR /// shortstring ::= "'" shortstringitem* "'" | '"' shortstringitem* '"' /// shortstringitem ::= shortstringchar | stringescapeseq /// shortstringchar ::= -fragment SHORT_STRING - : '\'' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f'] )* '\'' - | '"' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f"] )* '"' - ; +fragment SHORT_STRING: + '\'' (STRING_ESCAPE_SEQ | ~[\\\r\n\f'])* '\'' + | '"' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f"])* '"' +; /// longstring ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""' -fragment LONG_STRING - : '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' - | '"""' LONG_STRING_ITEM*? '"""' - ; +fragment LONG_STRING: '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' | '"""' LONG_STRING_ITEM*? '"""'; /// longstringitem ::= longstringchar | stringescapeseq -fragment LONG_STRING_ITEM - : LONG_STRING_CHAR - | STRING_ESCAPE_SEQ - ; +fragment LONG_STRING_ITEM: LONG_STRING_CHAR | STRING_ESCAPE_SEQ; /// longstringchar ::= -fragment LONG_STRING_CHAR - : ~'\\' - ; +fragment LONG_STRING_CHAR: ~'\\'; /// stringescapeseq ::= "\" -fragment STRING_ESCAPE_SEQ - : '\\' . - | '\\' NEWLINE - ; +fragment STRING_ESCAPE_SEQ: '\\' . | '\\' NEWLINE; /// nonzerodigit ::= "1"..."9" -fragment NON_ZERO_DIGIT - : [1-9] - ; +fragment NON_ZERO_DIGIT: [1-9]; /// digit ::= "0"..."9" -fragment DIGIT - : [0-9] - ; +fragment DIGIT: [0-9]; /// octdigit ::= "0"..."7" -fragment OCT_DIGIT - : [0-7] - ; +fragment OCT_DIGIT: [0-7]; /// hexdigit ::= digit | "a"..."f" | "A"..."F" -fragment HEX_DIGIT - : [0-9a-fA-F] - ; +fragment HEX_DIGIT: [0-9a-fA-F]; /// bindigit ::= "0" | "1" -fragment BIN_DIGIT - : [01] - ; +fragment BIN_DIGIT: [01]; /// pointfloat ::= [intpart] fraction | intpart "." -fragment POINT_FLOAT - : INT_PART? FRACTION - | INT_PART '.' - ; +fragment POINT_FLOAT: INT_PART? FRACTION | INT_PART '.'; /// exponentfloat ::= (intpart | pointfloat) exponent -fragment EXPONENT_FLOAT - : ( INT_PART | POINT_FLOAT ) EXPONENT - ; +fragment EXPONENT_FLOAT: ( INT_PART | POINT_FLOAT) EXPONENT; /// intpart ::= digit+ -fragment INT_PART - : DIGIT+ - ; +fragment INT_PART: DIGIT+; /// fraction ::= "." digit+ -fragment FRACTION - : '.' DIGIT+ - ; +fragment FRACTION: '.' DIGIT+; /// exponent ::= ("e" | "E") ["+" | "-"] digit+ -fragment EXPONENT - : [eE] [+-]? DIGIT+ - ; +fragment EXPONENT: [eE] [+-]? DIGIT+; /// shortbytes ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"' /// shortbytesitem ::= shortbyteschar | bytesescapeseq -fragment SHORT_BYTES - : '\'' ( SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ )* '\'' - | '"' ( SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ )* '"' - ; +fragment SHORT_BYTES: + '\'' (SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ)* '\'' + | '"' ( SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ)* '"' +; /// longbytes ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""' -fragment LONG_BYTES - : '\'\'\'' LONG_BYTES_ITEM*? '\'\'\'' - | '"""' LONG_BYTES_ITEM*? '"""' - ; +fragment LONG_BYTES: '\'\'\'' LONG_BYTES_ITEM*? '\'\'\'' | '"""' LONG_BYTES_ITEM*? '"""'; /// longbytesitem ::= longbyteschar | bytesescapeseq -fragment LONG_BYTES_ITEM - : LONG_BYTES_CHAR - | BYTES_ESCAPE_SEQ - ; +fragment LONG_BYTES_ITEM: LONG_BYTES_CHAR | BYTES_ESCAPE_SEQ; /// shortbyteschar ::= -fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE - : [\u0000-\u0009] - | [\u000B-\u000C] - | [\u000E-\u0026] - | [\u0028-\u005B] - | [\u005D-\u007F] - ; - -fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE - : [\u0000-\u0009] - | [\u000B-\u000C] - | [\u000E-\u0021] - | [\u0023-\u005B] - | [\u005D-\u007F] - ; +fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE: + [\u0000-\u0009] + | [\u000B-\u000C] + | [\u000E-\u0026] + | [\u0028-\u005B] + | [\u005D-\u007F] +; + +fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE: + [\u0000-\u0009] + | [\u000B-\u000C] + | [\u000E-\u0021] + | [\u0023-\u005B] + | [\u005D-\u007F] +; /// longbyteschar ::= -fragment LONG_BYTES_CHAR - : [\u0000-\u005B] - | [\u005D-\u007F] - ; +fragment LONG_BYTES_CHAR: [\u0000-\u005B] | [\u005D-\u007F]; /// bytesescapeseq ::= "\" -fragment BYTES_ESCAPE_SEQ - : '\\' [\u0000-\u007F] - ; - -fragment SPACES - : [ \t]+ - ; +fragment BYTES_ESCAPE_SEQ: '\\' [\u0000-\u007F]; -fragment COMMENT - : '#' ~[\r\n\f]* - ; +fragment SPACES: [ \t]+; -fragment LINE_JOINING - : '\\' SPACES? ( '\r'? '\n' | '\r' | '\f') - ; +fragment COMMENT: '#' ~[\r\n\f]*; +fragment LINE_JOINING: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f'); // TODO: ANTLR seems lack of some Unicode property support... //$ curl https://www.unicode.org/Public/13.0.0/ucd/PropList.txt | grep Other_ID_ @@ -371,36 +288,26 @@ fragment LINE_JOINING //1369..1371 ; Other_ID_Continue # No [9] ETHIOPIC DIGIT ONE..ETHIOPIC DIGIT NINE //19DA ; Other_ID_Continue # No NEW TAI LUE THAM DIGIT ONE -fragment UNICODE_OIDS - : '\u1885'..'\u1886' - | '\u2118' - | '\u212e' - | '\u309b'..'\u309c' - ; +fragment UNICODE_OIDS: '\u1885' ..'\u1886' | '\u2118' | '\u212e' | '\u309b' ..'\u309c'; -fragment UNICODE_OIDC - : '\u00b7' - | '\u0387' - | '\u1369'..'\u1371' - | '\u19da' - ; +fragment UNICODE_OIDC: '\u00b7' | '\u0387' | '\u1369' ..'\u1371' | '\u19da'; /// id_start ::= -fragment ID_START - : '_' - | [\p{L}] - | [\p{Nl}] - //| [\p{Other_ID_Start}] - | UNICODE_OIDS - ; +fragment ID_START: + '_' + | [\p{L}] + | [\p{Nl}] + //| [\p{Other_ID_Start}] + | UNICODE_OIDS +; /// id_continue ::= -fragment ID_CONTINUE - : ID_START - | [\p{Mn}] - | [\p{Mc}] - | [\p{Nd}] - | [\p{Pc}] - //| [\p{Other_ID_Continue}] - | UNICODE_OIDC - ; \ No newline at end of file +fragment ID_CONTINUE: + ID_START + | [\p{Mn}] + | [\p{Mc}] + | [\p{Nd}] + | [\p{Pc}] + //| [\p{Other_ID_Continue}] + | UNICODE_OIDC +; \ No newline at end of file diff --git a/python/python3/Python3Parser.g4 b/python/python3/Python3Parser.g4 index a2f335b588..4c5a27cf2a 100644 --- a/python/python3/Python3Parser.g4 +++ b/python/python3/Python3Parser.g4 @@ -31,11 +31,14 @@ // Scraping from https://docs.python.org/3/reference/grammar.html +// $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 Python3Parser; options { superClass = Python3ParserBase; - tokenVocab=Python3Lexer; + tokenVocab = Python3Lexer; } // Insert here @header for C++ parser. @@ -43,154 +46,526 @@ options { // All comments that start with "///" are copy-pasted from // The Python Language Reference -single_input: NEWLINE | simple_stmts | compound_stmt NEWLINE; -file_input: (NEWLINE | stmt)* EOF; -eval_input: testlist NEWLINE* EOF; - -decorator: '@' dotted_name ( '(' arglist? ')' )? NEWLINE; -decorators: decorator+; -decorated: decorators (classdef | funcdef | async_funcdef); - -async_funcdef: ASYNC funcdef; -funcdef: 'def' name parameters ('->' test)? ':' block; - -parameters: '(' typedargslist? ')'; -typedargslist: (tfpdef ('=' test)? (',' tfpdef ('=' test)?)* (',' ( - '*' tfpdef? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef ','? )? )? - | '**' tfpdef ','? )? )? - | '*' tfpdef? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef ','? )? )? - | '**' tfpdef ','?); -tfpdef: name (':' test)?; -varargslist: (vfpdef ('=' test)? (',' vfpdef ('=' test)?)* (',' ( - '*' vfpdef? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef ','? )? )? - | '**' vfpdef (',')?)?)? - | '*' vfpdef? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef ','? )? )? - | '**' vfpdef ','? -); -vfpdef: name; - -stmt: simple_stmts | compound_stmt; -simple_stmts: simple_stmt (';' simple_stmt)* ';'? NEWLINE; -simple_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | - import_stmt | global_stmt | nonlocal_stmt | assert_stmt); -expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) | - ('=' (yield_expr|testlist_star_expr))*); -annassign: ':' test ('=' test)?; -testlist_star_expr: (test|star_expr) (',' (test|star_expr))* ','?; -augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' | - '<<=' | '>>=' | '**=' | '//='); +single_input + : NEWLINE + | simple_stmts + | compound_stmt NEWLINE + ; + +file_input + : (NEWLINE | stmt)* EOF + ; + +eval_input + : testlist NEWLINE* EOF + ; + +decorator + : '@' dotted_name ('(' arglist? ')')? NEWLINE + ; + +decorators + : decorator+ + ; + +decorated + : decorators (classdef | funcdef | async_funcdef) + ; + +async_funcdef + : ASYNC funcdef + ; + +funcdef + : 'def' name parameters ('->' test)? ':' block + ; + +parameters + : '(' typedargslist? ')' + ; + +typedargslist + : ( + tfpdef ('=' test)? (',' tfpdef ('=' test)?)* ( + ',' ( + '*' tfpdef? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef ','?)?)? + | '**' tfpdef ','? + )? + )? + | '*' tfpdef? (',' tfpdef ('=' test)?)* (',' ('**' tfpdef ','?)?)? + | '**' tfpdef ','? + ) + ; + +tfpdef + : name (':' test)? + ; + +varargslist + : ( + vfpdef ('=' test)? (',' vfpdef ('=' test)?)* ( + ',' ( + '*' vfpdef? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef ','?)?)? + | '**' vfpdef (',')? + )? + )? + | '*' vfpdef? (',' vfpdef ('=' test)?)* (',' ('**' vfpdef ','?)?)? + | '**' vfpdef ','? + ) + ; + +vfpdef + : name + ; + +stmt + : simple_stmts + | compound_stmt + ; + +simple_stmts + : simple_stmt (';' simple_stmt)* ';'? NEWLINE + ; + +simple_stmt + : ( + expr_stmt + | del_stmt + | pass_stmt + | flow_stmt + | import_stmt + | global_stmt + | nonlocal_stmt + | assert_stmt + ) + ; + +expr_stmt + : testlist_star_expr ( + annassign + | augassign (yield_expr | testlist) + | ('=' (yield_expr | testlist_star_expr))* + ) + ; + +annassign + : ':' test ('=' test)? + ; + +testlist_star_expr + : (test | star_expr) (',' (test | star_expr))* ','? + ; + +augassign + : ( + '+=' + | '-=' + | '*=' + | '@=' + | '/=' + | '%=' + | '&=' + | '|=' + | '^=' + | '<<=' + | '>>=' + | '**=' + | '//=' + ) + ; + // For normal and annotated assignments, additional restrictions enforced by the interpreter -del_stmt: 'del' exprlist; -pass_stmt: 'pass'; -flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt; -break_stmt: 'break'; -continue_stmt: 'continue'; -return_stmt: 'return' testlist?; -yield_stmt: yield_expr; -raise_stmt: 'raise' (test ('from' test)?)?; -import_stmt: import_name | import_from; -import_name: 'import' dotted_as_names; +del_stmt + : 'del' exprlist + ; + +pass_stmt + : 'pass' + ; + +flow_stmt + : break_stmt + | continue_stmt + | return_stmt + | raise_stmt + | yield_stmt + ; + +break_stmt + : 'break' + ; + +continue_stmt + : 'continue' + ; + +return_stmt + : 'return' testlist? + ; + +yield_stmt + : yield_expr + ; + +raise_stmt + : 'raise' (test ('from' test)?)? + ; + +import_stmt + : import_name + | import_from + ; + +import_name + : 'import' dotted_as_names + ; + // note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS -import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+) - 'import' ('*' | '(' import_as_names ')' | import_as_names)); -import_as_name: name ('as' name)?; -dotted_as_name: dotted_name ('as' name)?; -import_as_names: import_as_name (',' import_as_name)* ','?; -dotted_as_names: dotted_as_name (',' dotted_as_name)*; -dotted_name: name ('.' name)*; -global_stmt: 'global' name (',' name)*; -nonlocal_stmt: 'nonlocal' name (',' name)*; -assert_stmt: 'assert' test (',' test)?; - -compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt | match_stmt; -async_stmt: ASYNC (funcdef | with_stmt | for_stmt); -if_stmt: 'if' test ':' block ('elif' test ':' block)* ('else' ':' block)?; -while_stmt: 'while' test ':' block ('else' ':' block)?; -for_stmt: 'for' exprlist 'in' testlist ':' block ('else' ':' block)?; -try_stmt: ('try' ':' block - ((except_clause ':' block)+ - ('else' ':' block)? - ('finally' ':' block)? | - 'finally' ':' block)); -with_stmt: 'with' with_item (',' with_item)* ':' block; -with_item: test ('as' expr)?; +import_from + : ( + 'from' (('.' | '...')* dotted_name | ('.' | '...')+) 'import' ( + '*' + | '(' import_as_names ')' + | import_as_names + ) + ) + ; + +import_as_name + : name ('as' name)? + ; + +dotted_as_name + : dotted_name ('as' name)? + ; + +import_as_names + : import_as_name (',' import_as_name)* ','? + ; + +dotted_as_names + : dotted_as_name (',' dotted_as_name)* + ; + +dotted_name + : name ('.' name)* + ; + +global_stmt + : 'global' name (',' name)* + ; + +nonlocal_stmt + : 'nonlocal' name (',' name)* + ; + +assert_stmt + : 'assert' test (',' test)? + ; + +compound_stmt + : if_stmt + | while_stmt + | for_stmt + | try_stmt + | with_stmt + | funcdef + | classdef + | decorated + | async_stmt + | match_stmt + ; + +async_stmt + : ASYNC (funcdef | with_stmt | for_stmt) + ; + +if_stmt + : 'if' test ':' block ('elif' test ':' block)* ('else' ':' block)? + ; + +while_stmt + : 'while' test ':' block ('else' ':' block)? + ; + +for_stmt + : 'for' exprlist 'in' testlist ':' block ('else' ':' block)? + ; + +try_stmt + : ( + 'try' ':' block ( + (except_clause ':' block)+ ('else' ':' block)? ('finally' ':' block)? + | 'finally' ':' block + ) + ) + ; + +with_stmt + : 'with' with_item (',' with_item)* ':' block + ; + +with_item + : test ('as' expr)? + ; + // NB compile.c makes sure that the default except clause is last -except_clause: 'except' (test ('as' name)?)?; -block: simple_stmts | NEWLINE INDENT stmt+ DEDENT; -match_stmt: 'match' subject_expr ':' NEWLINE INDENT case_block+ DEDENT ; -subject_expr: star_named_expression ',' star_named_expressions? | test ; -star_named_expressions: ',' star_named_expression+ ','? ; -star_named_expression: '*' expr | test ; -case_block: 'case' patterns guard? ':' block ; -guard: 'if' test ; -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_pattern: signed_number { this.CannotBePlusMinus() }? | complex_number | strings | 'None' | 'True' | 'False' ; -literal_expr: signed_number { this.CannotBePlusMinus() }? | complex_number | strings | 'None' | 'True' | 'False' ; -complex_number: signed_real_number '+' imaginary_number - | signed_real_number '-' imaginary_number - ; -signed_number: NUMBER | '-' NUMBER ; -signed_real_number: real_number | '-' real_number ; -real_number: NUMBER ; -imaginary_number: NUMBER ; -capture_pattern: pattern_capture_target ; -pattern_capture_target: /* cannot be '_' */ name { this.CannotBeDotLpEq() }? ; -wildcard_pattern: '_' ; -value_pattern: attr { this.CannotBeDotLpEq() }? ; -attr: name ('.' name)+ ; -name_or_attr: attr | 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: - '*' pattern_capture_target - | '*' wildcard_pattern - ; -mapping_pattern: '{' '}' - | '{' double_star_pattern ','? '}' - | '{' items_pattern ',' double_star_pattern ','? '}' - | '{' items_pattern ','? '}' - ; -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 '(' ')' - | name_or_attr '(' positional_patterns ','? ')' - | name_or_attr '(' keyword_patterns ','? ')' - | name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' - ; -positional_patterns: pattern (',' pattern)* ; -keyword_patterns: keyword_pattern (',' keyword_pattern)* ; -keyword_pattern: name '=' pattern ; - -test: or_test ('if' or_test 'else' test)? | lambdef; -test_nocond: or_test | lambdef_nocond; -lambdef: 'lambda' varargslist? ':' test; -lambdef_nocond: 'lambda' varargslist? ':' test_nocond; -or_test: and_test ('or' and_test)*; -and_test: not_test ('and' not_test)*; -not_test: 'not' not_test | comparison; -comparison: expr (comp_op expr)*; +except_clause + : 'except' (test ('as' name)?)? + ; + +block + : simple_stmts + | NEWLINE INDENT stmt+ DEDENT + ; + +match_stmt + : 'match' subject_expr ':' NEWLINE INDENT case_block+ DEDENT + ; + +subject_expr + : star_named_expression ',' star_named_expressions? + | test + ; + +star_named_expressions + : ',' star_named_expression+ ','? + ; + +star_named_expression + : '*' expr + | test + ; + +case_block + : 'case' patterns guard? ':' block + ; + +guard + : 'if' test + ; + +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_pattern + : signed_number { this.CannotBePlusMinus() }? + | complex_number + | strings + | 'None' + | 'True' + | 'False' + ; + +literal_expr + : signed_number { this.CannotBePlusMinus() }? + | complex_number + | strings + | 'None' + | 'True' + | 'False' + ; + +complex_number + : signed_real_number '+' imaginary_number + | signed_real_number '-' imaginary_number + ; + +signed_number + : NUMBER + | '-' NUMBER + ; + +signed_real_number + : real_number + | '-' real_number + ; + +real_number + : NUMBER + ; + +imaginary_number + : NUMBER + ; + +capture_pattern + : pattern_capture_target + ; + +pattern_capture_target + : /* cannot be '_' */ name { this.CannotBeDotLpEq() }? + ; + +wildcard_pattern + : '_' + ; + +value_pattern + : attr { this.CannotBeDotLpEq() }? + ; + +attr + : name ('.' name)+ + ; + +name_or_attr + : attr + | 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 + : '*' pattern_capture_target + | '*' wildcard_pattern + ; + +mapping_pattern + : '{' '}' + | '{' double_star_pattern ','? '}' + | '{' items_pattern ',' double_star_pattern ','? '}' + | '{' items_pattern ','? '}' + ; + +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 '(' ')' + | name_or_attr '(' positional_patterns ','? ')' + | name_or_attr '(' keyword_patterns ','? ')' + | name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' + ; + +positional_patterns + : pattern (',' pattern)* + ; + +keyword_patterns + : keyword_pattern (',' keyword_pattern)* + ; + +keyword_pattern + : name '=' pattern + ; + +test + : or_test ('if' or_test 'else' test)? + | lambdef + ; + +test_nocond + : or_test + | lambdef_nocond + ; + +lambdef + : 'lambda' varargslist? ':' test + ; + +lambdef_nocond + : 'lambda' varargslist? ':' test_nocond + ; + +or_test + : and_test ('or' and_test)* + ; + +and_test + : not_test ('and' not_test)* + ; + +not_test + : 'not' not_test + | comparison + ; + +comparison + : expr (comp_op expr)* + ; + // <> isn't actually a valid comparison operator in Python. It's here for the // sake of a __future__ import described in PEP 401 (which really works :-) -comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'; -star_expr: '*' expr; +comp_op + : '<' + | '>' + | '==' + | '>=' + | '<=' + | '<>' + | '!=' + | 'in' + | 'not' 'in' + | 'is' + | 'is' 'not' + ; + +star_expr + : '*' expr + ; -expr: - atom_expr +expr + : atom_expr | expr '**' expr - | ('+'|'-'|'~')+ expr - | expr ('*'|'@'|'/'|'%'|'//') expr - | expr ('+'|'-') expr + | ('+' | '-' | '~')+ expr + | expr ('*' | '@' | '/' | '%' | '//') expr + | expr ('+' | '-') expr | expr ('<<' | '>>') expr | expr '&' expr | expr '^' expr @@ -205,27 +580,74 @@ expr: //term: factor (('*'|'@'|'/'|'%'|'//') factor)*; //factor: ('+'|'-'|'~') factor | power; //power: atom_expr ('**' factor)?; -atom_expr: AWAIT? atom trailer*; -atom: '(' (yield_expr|testlist_comp)? ')' - | '[' testlist_comp? ']' - | '{' dictorsetmaker? '}' - | name | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False' ; -name : NAME | '_' | 'match' ; -testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* ','? ); -trailer: '(' arglist? ')' | '[' subscriptlist ']' | '.' name ; -subscriptlist: subscript_ (',' subscript_)* ','?; -subscript_: test | test? ':' test? sliceop?; -sliceop: ':' test?; -exprlist: (expr|star_expr) (',' (expr|star_expr))* ','?; -testlist: test (',' test)* ','?; -dictorsetmaker: ( ((test ':' test | '**' expr) - (comp_for | (',' (test ':' test | '**' expr))* ','?)) | - ((test | star_expr) - (comp_for | (',' (test | star_expr))* ','?)) ); - -classdef: 'class' name ('(' arglist? ')')? ':' block; - -arglist: argument (',' argument)* ','?; +atom_expr + : AWAIT? atom trailer* + ; + +atom + : '(' (yield_expr | testlist_comp)? ')' + | '[' testlist_comp? ']' + | '{' dictorsetmaker? '}' + | name + | NUMBER + | STRING+ + | '...' + | 'None' + | 'True' + | 'False' + ; + +name + : NAME + | '_' + | 'match' + ; + +testlist_comp + : (test | star_expr) (comp_for | (',' (test | star_expr))* ','?) + ; + +trailer + : '(' arglist? ')' + | '[' subscriptlist ']' + | '.' name + ; + +subscriptlist + : subscript_ (',' subscript_)* ','? + ; + +subscript_ + : test + | test? ':' test? sliceop? + ; + +sliceop + : ':' test? + ; + +exprlist + : (expr | star_expr) (',' (expr | star_expr))* ','? + ; + +testlist + : test (',' test)* ','? + ; + +dictorsetmaker + : ( + ((test ':' test | '**' expr) (comp_for | (',' (test ':' test | '**' expr))* ','?)) + | ((test | star_expr) (comp_for | (',' (test | star_expr))* ','?)) + ) + ; + +classdef + : 'class' name ('(' arglist? ')')? ':' block + ; + +arglist + : argument (',' argument)* ','? + ; // The reason that keywords are test nodes instead of NAME is that using NAME // results in an ambiguity. ast.c makes sure it's a NAME. @@ -236,19 +658,37 @@ arglist: argument (',' argument)* ','?; // Illegal combinations and orderings are blocked in ast.c: // multiple (test comp_for) arguments are blocked; keyword unpackings // that precede iterable unpackings are blocked; etc. -argument: ( test comp_for? | - test '=' test | - '**' test | - '*' test ); +argument + : (test comp_for? | test '=' test | '**' test | '*' test) + ; + +comp_iter + : comp_for + | comp_if + ; -comp_iter: comp_for | comp_if; -comp_for: ASYNC? 'for' exprlist 'in' or_test comp_iter?; -comp_if: 'if' test_nocond comp_iter?; +comp_for + : ASYNC? 'for' exprlist 'in' or_test comp_iter? + ; + +comp_if + : 'if' test_nocond comp_iter? + ; // not used in grammar, but may appear in "node" passed from Parser to Compiler -encoding_decl: name; +encoding_decl + : name + ; -yield_expr: 'yield' yield_arg?; -yield_arg: 'from' test | testlist; +yield_expr + : 'yield' yield_arg? + ; + +yield_arg + : 'from' test + | testlist + ; -strings: STRING+ ; +strings + : STRING+ + ; \ No newline at end of file diff --git a/python/python3_12_0/PythonLexer.g4 b/python/python3_12_0/PythonLexer.g4 index 886f0e5762..8363649b26 100644 --- a/python/python3_12_0/PythonLexer.g4 +++ b/python/python3_12_0/PythonLexer.g4 @@ -20,22 +20,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /* +/* * Project : an ANTLR4 lexer grammar for Python 3 * https://github.com/RobEin/ANTLR4-parser-for-Python-3.12 * Developed by : Robert Einhorn, robert.einhorn.hu@gmail.com */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PythonLexer; -options { superClass=PythonLexerBase; } +options { + superClass = PythonLexerBase; +} tokens { - INDENT, DEDENT // https://docs.python.org/3.12/reference/lexical_analysis.html#indentation - , FSTRING_START, FSTRING_MIDDLE, FSTRING_END // https://peps.python.org/pep-0701/#specification + INDENT, + DEDENT, // https://docs.python.org/3.12/reference/lexical_analysis.html#indentation + FSTRING_START, + FSTRING_MIDDLE, + FSTRING_END // https://peps.python.org/pep-0701/#specification } - // https://docs.python.org/3.12/reference/lexical_analysis.html /* @@ -130,85 +138,100 @@ COLONEQUAL : ':='; EXCLAMATION : '!'; // https://docs.python.org/3.12/reference/lexical_analysis.html#identifiers -NAME - : ID_START ID_CONTINUE* - ; +NAME: ID_START ID_CONTINUE*; // https://docs.python.org/3.12/reference/lexical_analysis.html#numeric-literals -NUMBER - : INTEGER - | FLOAT_NUMBER - | IMAG_NUMBER - ; +NUMBER: INTEGER | FLOAT_NUMBER | IMAG_NUMBER; // https://docs.python.org/3.12/reference/lexical_analysis.html#string-and-bytes-literals -STRING - : STRING_LITERAL - | BYTES_LITERAL - ; +STRING: STRING_LITERAL | BYTES_LITERAL; // https://peps.python.org/pep-0484/#type-comments -TYPE_COMMENT - : '#' WS? 'type:' ~[\r\n]* - ; +TYPE_COMMENT: '#' WS? 'type:' ~[\r\n]*; // https://docs.python.org/3.12/reference/lexical_analysis.html#physical-lines -NEWLINE - : OS_INDEPENDENT_NL - ; +NEWLINE: OS_INDEPENDENT_NL; // https://docs.python.org/3.12/reference/lexical_analysis.html#comments -COMMENT : '#' ~[\r\n]* -> channel(HIDDEN); +COMMENT: '#' ~[\r\n]* -> channel(HIDDEN); // https://docs.python.org/3.12/reference/lexical_analysis.html#whitespace-between-tokens -WS : [ \t\f]+ -> channel(HIDDEN); +WS: [ \t\f]+ -> channel(HIDDEN); // https://docs.python.org/3.12/reference/lexical_analysis.html#explicit-line-joining -EXPLICIT_LINE_JOINING : '\\' NEWLINE -> channel(HIDDEN); +EXPLICIT_LINE_JOINING: '\\' NEWLINE -> channel(HIDDEN); // https://docs.python.org/3.12/reference/lexical_analysis.html#formatted-string-literals -SINGLE_QUOTE_FSTRING_START : F_STRING_PREFIX ['] -> type(FSTRING_START), pushMode(SINGLE_QUOTE_FSTRING_MODE); -DOUBLE_QUOTE_FSTRING_START : F_STRING_PREFIX ["] -> type(FSTRING_START), pushMode(DOUBLE_QUOTE_FSTRING_MODE); -LONG_SINGLE_QUOTE_FSTRING_START : F_STRING_PREFIX ['][']['] -> type(FSTRING_START), pushMode(LONG_SINGLE_QUOTE_FSTRING_MODE); -LONG_DOUBLE_QUOTE_FSTRING_START : F_STRING_PREFIX ["]["]["] -> type(FSTRING_START), pushMode(LONG_DOUBLE_QUOTE_FSTRING_MODE); - -ERROR_TOKEN : . ; // catch the unrecognized characters and redirect these errors to the parser +SINGLE_QUOTE_FSTRING_START: + F_STRING_PREFIX ['] -> type(FSTRING_START), pushMode(SINGLE_QUOTE_FSTRING_MODE) +; +DOUBLE_QUOTE_FSTRING_START: + F_STRING_PREFIX ["] -> type(FSTRING_START), pushMode(DOUBLE_QUOTE_FSTRING_MODE) +; +LONG_SINGLE_QUOTE_FSTRING_START: + F_STRING_PREFIX ['][']['] -> type(FSTRING_START), pushMode(LONG_SINGLE_QUOTE_FSTRING_MODE) +; +LONG_DOUBLE_QUOTE_FSTRING_START: + F_STRING_PREFIX ["]["]["] -> type(FSTRING_START), pushMode(LONG_DOUBLE_QUOTE_FSTRING_MODE) +; +ERROR_TOKEN: .; // catch the unrecognized characters and redirect these errors to the parser /* * other lexer modes */ mode SINGLE_QUOTE_FSTRING_MODE; - SINGLE_QUOTE_FSTRING_END : ['] -> type(FSTRING_END), popMode; - SINGLE_QUOTE_FSTRING_MIDDLE : SINGLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); - SINGLE_QUOTE_FSTRING_LBRACE : '{' -> type(LBRACE); // will be closed in DEFAULT_MODE or SINGLE_QUOTE_FORMAT_SPECIFICATION_RBRACE +SINGLE_QUOTE_FSTRING_END : ['] -> type(FSTRING_END), popMode; +SINGLE_QUOTE_FSTRING_MIDDLE : SINGLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); +SINGLE_QUOTE_FSTRING_LBRACE: + '{' -> type(LBRACE) +; // will be closed in DEFAULT_MODE or SINGLE_QUOTE_FORMAT_SPECIFICATION_RBRACE mode DOUBLE_QUOTE_FSTRING_MODE; - DOUBLE_QUOTE_FSTRING_END : ["] -> type(FSTRING_END), popMode; - DOUBLE_QUOTE_FSTRING_MIDDLE : DOUBLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); - DOUBLE_QUOTE_FSTRING_LBRACE : '{' -> type(LBRACE); // will be closed in DEFAULT_MODE or DOUBLE_QUOTE_FORMAT_SPECIFICATION_RBRACE +DOUBLE_QUOTE_FSTRING_END : ["] -> type(FSTRING_END), popMode; +DOUBLE_QUOTE_FSTRING_MIDDLE : DOUBLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); +DOUBLE_QUOTE_FSTRING_LBRACE: + '{' -> type(LBRACE) +; // will be closed in DEFAULT_MODE or DOUBLE_QUOTE_FORMAT_SPECIFICATION_RBRACE mode LONG_SINGLE_QUOTE_FSTRING_MODE; - LONG_SINGLE_QUOTE_FSTRING_END : ['][']['] -> type(FSTRING_END), popMode; - LONG_SINGLE_QUOTE_FSTRING_MIDDLE : SINGLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); - LONG_SINGLE_QUOTE_FSTRING_LBRACE : '{' -> type(LBRACE); // will be closed in DEFAULT_MODE or SINGLE_QUOTE_FORMAT_SPECIFICATION_RBRACE +LONG_SINGLE_QUOTE_FSTRING_END : ['][']['] -> type(FSTRING_END), popMode; +LONG_SINGLE_QUOTE_FSTRING_MIDDLE : SINGLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); +LONG_SINGLE_QUOTE_FSTRING_LBRACE: + '{' -> type(LBRACE) +; // will be closed in DEFAULT_MODE or SINGLE_QUOTE_FORMAT_SPECIFICATION_RBRACE mode LONG_DOUBLE_QUOTE_FSTRING_MODE; - LONG_DOUBLE_QUOTE_FSTRING_END : ["]["]["] -> type(FSTRING_END), popMode; - LONG_DOUBLE_QUOTE_FSTRING_MIDDLE : DOUBLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); - LONG_DOUBLE_QUOTE_FSTRING_LBRACE : '{' -> type(LBRACE); // will be closed in DEFAULT_MODE or DOUBLE_QUOTE_FORMAT_SPECIFICATION_RBRACE - -mode SINGLE_QUOTE_FORMAT_SPECIFICATION_MODE; // only used after a format specifier colon - SINGLE_QUOTE_FORMAT_SPECIFICATION_FSTRING_MIDDLE : FORMAT_SPEC_CHAR_NO_SINGLE_QUOTE+ -> type(FSTRING_MIDDLE); - SINGLE_QUOTE_FORMAT_SPECIFICATION_LBRACE : '{' -> type(LBRACE); // will be closed in DEFAULT_MODE by PythonLexerBase class - SINGLE_QUOTE_FORMAT_SPECIFICATION_RBRACE : '}' -> type(RBRACE); // popMode to ..._QUOTE_FSTRING_MODE by PythonLexerBase class +LONG_DOUBLE_QUOTE_FSTRING_END : ["]["]["] -> type(FSTRING_END), popMode; +LONG_DOUBLE_QUOTE_FSTRING_MIDDLE : DOUBLE_QUOTE_FSTRING_LITERAL -> type(FSTRING_MIDDLE); +LONG_DOUBLE_QUOTE_FSTRING_LBRACE: + '{' -> type(LBRACE) +; // will be closed in DEFAULT_MODE or DOUBLE_QUOTE_FORMAT_SPECIFICATION_RBRACE -mode DOUBLE_QUOTE_FORMAT_SPECIFICATION_MODE; // only used after a format specifier colon - DOUBLE_QUOTE_FORMAT_SPECIFICATION_FSTRING_MIDDLE : FORMAT_SPEC_CHAR_NO_DOUBLE_QUOTE+ -> type(FSTRING_MIDDLE); - DOUBLE_QUOTE_FORMAT_SPECIFICATION_LBRACE : '{' -> type(LBRACE); // will be closed in DEFAULT_MODE by PythonLexerBase class - DOUBLE_QUOTE_FORMAT_SPECIFICATION_RBRACE : '}' -> type(RBRACE); // popMode to ..._QUOTE_FSTRING_MODE by PythonLexerBase class +mode SINGLE_QUOTE_FORMAT_SPECIFICATION_MODE; +// only used after a format specifier colon +SINGLE_QUOTE_FORMAT_SPECIFICATION_FSTRING_MIDDLE: + FORMAT_SPEC_CHAR_NO_SINGLE_QUOTE+ -> type(FSTRING_MIDDLE) +; +SINGLE_QUOTE_FORMAT_SPECIFICATION_LBRACE: + '{' -> type(LBRACE) +; // will be closed in DEFAULT_MODE by PythonLexerBase class +SINGLE_QUOTE_FORMAT_SPECIFICATION_RBRACE: + '}' -> type(RBRACE) +; // popMode to ..._QUOTE_FSTRING_MODE by PythonLexerBase class +mode DOUBLE_QUOTE_FORMAT_SPECIFICATION_MODE; +// only used after a format specifier colon +DOUBLE_QUOTE_FORMAT_SPECIFICATION_FSTRING_MIDDLE: + FORMAT_SPEC_CHAR_NO_DOUBLE_QUOTE+ -> type(FSTRING_MIDDLE) +; +DOUBLE_QUOTE_FORMAT_SPECIFICATION_LBRACE: + '{' -> type(LBRACE) +; // will be closed in DEFAULT_MODE by PythonLexerBase class +DOUBLE_QUOTE_FORMAT_SPECIFICATION_RBRACE: + '}' -> type(RBRACE) +; // popMode to ..._QUOTE_FSTRING_MODE by PythonLexerBase class /* * fragments @@ -220,64 +243,68 @@ mode DOUBLE_QUOTE_FORMAT_SPECIFICATION_MODE; // only used after a format specifi fragment STRING_LITERAL : STRING_PREFIX? (SHORT_STRING | LONG_STRING); fragment STRING_PREFIX : 'r' | 'u' | 'R' | 'U'; -fragment SHORT_STRING - : '\'' SHORT_STRING_ITEM_FOR_SINGLE_QUOTE* '\'' - | '"' SHORT_STRING_ITEM_FOR_DOUBLE_QUOTE* '"' - ; +fragment SHORT_STRING: + '\'' SHORT_STRING_ITEM_FOR_SINGLE_QUOTE* '\'' + | '"' SHORT_STRING_ITEM_FOR_DOUBLE_QUOTE* '"' +; -fragment LONG_STRING - : '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' - | '"""' LONG_STRING_ITEM*? '"""' - ; +fragment LONG_STRING: '\'\'\'' LONG_STRING_ITEM*? '\'\'\'' | '"""' LONG_STRING_ITEM*? '"""'; -fragment SHORT_STRING_ITEM_FOR_SINGLE_QUOTE : SHORT_STRING_CHAR_NO_SINGLE_QUOTE | STRING_ESCAPE_SEQ; -fragment SHORT_STRING_ITEM_FOR_DOUBLE_QUOTE : SHORT_STRING_CHAR_NO_DOUBLE_QUOTE | STRING_ESCAPE_SEQ; +fragment SHORT_STRING_ITEM_FOR_SINGLE_QUOTE: + SHORT_STRING_CHAR_NO_SINGLE_QUOTE + | STRING_ESCAPE_SEQ +; +fragment SHORT_STRING_ITEM_FOR_DOUBLE_QUOTE: + SHORT_STRING_CHAR_NO_DOUBLE_QUOTE + | STRING_ESCAPE_SEQ +; -fragment LONG_STRING_ITEM : LONG_STRING_CHAR | STRING_ESCAPE_SEQ; +fragment LONG_STRING_ITEM: LONG_STRING_CHAR | STRING_ESCAPE_SEQ; -fragment SHORT_STRING_CHAR_NO_SINGLE_QUOTE : ~[\\\r\n']; // -fragment SHORT_STRING_CHAR_NO_DOUBLE_QUOTE : ~[\\\r\n"]; // +fragment SHORT_STRING_CHAR_NO_SINGLE_QUOTE: + ~[\\\r\n'] +; // +fragment SHORT_STRING_CHAR_NO_DOUBLE_QUOTE: + ~[\\\r\n"] +; // -fragment LONG_STRING_CHAR : ~'\\'; // +fragment LONG_STRING_CHAR: ~'\\'; // -fragment STRING_ESCAPE_SEQ - : '\\' OS_INDEPENDENT_NL // \ escape sequence - | '\\' . // "\" - ; // the \ (not \n) escape sequences will be removed from the string literals by the PythonLexerBase class +fragment STRING_ESCAPE_SEQ: + '\\' OS_INDEPENDENT_NL // \ escape sequence + | '\\' . // "\" +; // the \ (not \n) escape sequences will be removed from the string literals by the PythonLexerBase class fragment BYTES_LITERAL : BYTES_PREFIX (SHORT_BYTES | LONG_BYTES); fragment BYTES_PREFIX : 'b' | 'B' | 'br' | 'Br' | 'bR' | 'BR' | 'rb' | 'rB' | 'Rb' | 'RB'; -fragment SHORT_BYTES - : '\'' SHORT_BYTES_ITEM_FOR_SINGLE_QUOTE* '\'' - | '"' SHORT_BYTES_ITEM_FOR_DOUBLE_QUOTE* '"' - ; +fragment SHORT_BYTES: + '\'' SHORT_BYTES_ITEM_FOR_SINGLE_QUOTE* '\'' + | '"' SHORT_BYTES_ITEM_FOR_DOUBLE_QUOTE* '"' +; -fragment LONG_BYTES - : '\'\'\'' LONG_BYTES_ITEM*? '\'\'\'' - | '"""' LONG_BYTES_ITEM*? '"""' - ; +fragment LONG_BYTES: '\'\'\'' LONG_BYTES_ITEM*? '\'\'\'' | '"""' LONG_BYTES_ITEM*? '"""'; -fragment SHORT_BYTES_ITEM_FOR_SINGLE_QUOTE : SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ; -fragment SHORT_BYTES_ITEM_FOR_DOUBLE_QUOTE : SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ; +fragment SHORT_BYTES_ITEM_FOR_SINGLE_QUOTE : SHORT_BYTES_CHAR_NO_SINGLE_QUOTE | BYTES_ESCAPE_SEQ; +fragment SHORT_BYTES_ITEM_FOR_DOUBLE_QUOTE : SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE | BYTES_ESCAPE_SEQ; -fragment LONG_BYTES_ITEM : LONG_BYTES_CHAR | BYTES_ESCAPE_SEQ; +fragment LONG_BYTES_ITEM: LONG_BYTES_CHAR | BYTES_ESCAPE_SEQ; -fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE // - : [\u0000-\u0009] +fragment SHORT_BYTES_CHAR_NO_SINGLE_QUOTE: // + [\u0000-\u0009] | [\u000B-\u000C] | [\u000E-\u0026] | [\u0028-\u005B] | [\u005D-\u007F] - ; +; -fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE // - : [\u0000-\u0009] +fragment SHORT_BYTES_CHAR_NO_DOUBLE_QUOTE: // + [\u0000-\u0009] | [\u000B-\u000C] | [\u000E-\u0021] | [\u0023-\u005B] | [\u005D-\u007F] - ; +; fragment LONG_BYTES_CHAR : [\u0000-\u005B] | [\u005D-\u007F]; // fragment BYTES_ESCAPE_SEQ : '\\' [\u0000-\u007F]; // "\" @@ -287,10 +314,10 @@ fragment SINGLE_QUOTE_FSTRING_LITERAL : (FORMAT_SPEC_CHAR_NO_SINGLE_QUOTE | DOUB fragment DOUBLE_QUOTE_FSTRING_LITERAL : (FORMAT_SPEC_CHAR_NO_DOUBLE_QUOTE | DOUBLE_BRACES)+; // https://docs.python.org/3.12/reference/lexical_analysis.html#formatted-string-literals -fragment F_STRING_PREFIX : 'f' | 'F' | 'fr' | 'Fr' | 'fR' | 'FR' | 'rf' | 'rF' | 'Rf' | 'RF'; +fragment F_STRING_PREFIX : 'f' | 'F' | 'fr' | 'Fr' | 'fR' | 'FR' | 'rf' | 'rF' | 'Rf' | 'RF'; fragment FORMAT_SPEC_CHAR_NO_SINGLE_QUOTE : ~[{}']; fragment FORMAT_SPEC_CHAR_NO_DOUBLE_QUOTE : ~[{}"]; -fragment DOUBLE_BRACES : '{{' | '}}'; +fragment DOUBLE_BRACES : '{{' | '}}'; // https://docs.python.org/3.12/reference/lexical_analysis.html#integer-literals fragment INTEGER : DEC_INTEGER | BIN_INTEGER | OCT_INTEGER | HEX_INTEGER; @@ -313,360 +340,1098 @@ fragment FRACTION : '.' DIGIT_PART; fragment EXPONENT : ('e' | 'E') ('+' | '-')? DIGIT_PART; // https://docs.python.org/3.12/reference/lexical_analysis.html#imaginary-literals -fragment IMAG_NUMBER : (FLOAT_NUMBER | DIGIT_PART) ('j' | 'J'); +fragment IMAG_NUMBER: (FLOAT_NUMBER | DIGIT_PART) ('j' | 'J'); // https://docs.python.org/3.12/reference/lexical_analysis.html#physical-lines -fragment OS_INDEPENDENT_NL : '\r'? '\n'; // Unix, Windows - -fragment ID_CONTINUE // based on: https://github.com/asmeurer/python-unicode-variable-names - : ID_START - | '\u0030' .. '\u0039' | '\u00B7' | '\u0300' .. '\u036F' | '\u0387' - | '\u0483' .. '\u0487' | '\u0591' .. '\u05BD' | '\u05BF' | '\u05C1' - | '\u05C2' | '\u05C4' | '\u05C5' | '\u05C7' | '\u0610' .. '\u061A' - | '\u064B' .. '\u0669' | '\u0670' | '\u06D6' .. '\u06DC' - | '\u06DF' .. '\u06E4' | '\u06E7' | '\u06E8' | '\u06EA' .. '\u06ED' - | '\u06F0' .. '\u06F9' | '\u0711' | '\u0730' .. '\u074A' - | '\u07A6' .. '\u07B0' | '\u07C0' .. '\u07C9' | '\u07EB' .. '\u07F3' - | '\u07FD' | '\u0816' .. '\u0819' | '\u081B' .. '\u0823' - | '\u0825' .. '\u0827' | '\u0829' .. '\u082D' | '\u0859' .. '\u085B' - | '\u08D3' .. '\u08E1' | '\u08E3' .. '\u0903' | '\u093A' .. '\u093C' - | '\u093E' .. '\u094F' | '\u0951' .. '\u0957' | '\u0962' | '\u0963' - | '\u0966' .. '\u096F' | '\u0981' .. '\u0983' | '\u09BC' - | '\u09BE' .. '\u09C4' | '\u09C7' | '\u09C8' | '\u09CB' .. '\u09CD' - | '\u09D7' | '\u09E2' | '\u09E3' | '\u09E6' .. '\u09EF' | '\u09FE' - | '\u0A01' .. '\u0A03' | '\u0A3C' | '\u0A3E' .. '\u0A42' | '\u0A47' - | '\u0A48' | '\u0A4B' .. '\u0A4D' | '\u0A51' | '\u0A66' .. '\u0A71' - | '\u0A75' | '\u0A81' .. '\u0A83' | '\u0ABC' | '\u0ABE' .. '\u0AC5' - | '\u0AC7' .. '\u0AC9' | '\u0ACB' .. '\u0ACD' | '\u0AE2' | '\u0AE3' - | '\u0AE6' .. '\u0AEF' | '\u0AFA' .. '\u0AFF' | '\u0B01' .. '\u0B03' - | '\u0B3C' | '\u0B3E' .. '\u0B44' | '\u0B47' | '\u0B48' - | '\u0B4B' .. '\u0B4D' | '\u0B55' .. '\u0B57' | '\u0B62' | '\u0B63' - | '\u0B66' .. '\u0B6F' | '\u0B82' | '\u0BBE' .. '\u0BC2' - | '\u0BC6' .. '\u0BC8' | '\u0BCA' .. '\u0BCD' | '\u0BD7' - | '\u0BE6' .. '\u0BEF' | '\u0C00' .. '\u0C04' | '\u0C3E' .. '\u0C44' - | '\u0C46' .. '\u0C48' | '\u0C4A' .. '\u0C4D' | '\u0C55' | '\u0C56' - | '\u0C62' | '\u0C63' | '\u0C66' .. '\u0C6F' | '\u0C81' .. '\u0C83' - | '\u0CBC' | '\u0CBE' .. '\u0CC4' | '\u0CC6' .. '\u0CC8' - | '\u0CCA' .. '\u0CCD' | '\u0CD5' | '\u0CD6' | '\u0CE2' | '\u0CE3' - | '\u0CE6' .. '\u0CEF' | '\u0D00' .. '\u0D03' | '\u0D3B' | '\u0D3C' - | '\u0D3E' .. '\u0D44' | '\u0D46' .. '\u0D48' | '\u0D4A' .. '\u0D4D' - | '\u0D57' | '\u0D62' | '\u0D63' | '\u0D66' .. '\u0D6F' - | '\u0D81' .. '\u0D83' | '\u0DCA' | '\u0DCF' .. '\u0DD4' | '\u0DD6' - | '\u0DD8' .. '\u0DDF' | '\u0DE6' .. '\u0DEF' | '\u0DF2' | '\u0DF3' - | '\u0E31' | '\u0E33' .. '\u0E3A' | '\u0E47' .. '\u0E4E' - | '\u0E50' .. '\u0E59' | '\u0EB1' | '\u0EB3' .. '\u0EBC' - | '\u0EC8' .. '\u0ECD' | '\u0ED0' .. '\u0ED9' | '\u0F18' | '\u0F19' - | '\u0F20' .. '\u0F29' | '\u0F35' | '\u0F37' | '\u0F39' | '\u0F3E' - | '\u0F3F' | '\u0F71' .. '\u0F84' | '\u0F86' | '\u0F87' - | '\u0F8D' .. '\u0F97' | '\u0F99' .. '\u0FBC' | '\u0FC6' - | '\u102B' .. '\u103E' | '\u1040' .. '\u1049' | '\u1056' .. '\u1059' - | '\u105E' .. '\u1060' | '\u1062' .. '\u1064' | '\u1067' .. '\u106D' - | '\u1071' .. '\u1074' | '\u1082' .. '\u108D' | '\u108F' .. '\u109D' - | '\u135D' .. '\u135F' | '\u1369' .. '\u1371' | '\u1712' .. '\u1714' - | '\u1732' .. '\u1734' | '\u1752' | '\u1753' | '\u1772' | '\u1773' - | '\u17B4' .. '\u17D3' | '\u17DD' | '\u17E0' .. '\u17E9' - | '\u180B' .. '\u180D' | '\u1810' .. '\u1819' | '\u18A9' - | '\u1920' .. '\u192B' | '\u1930' .. '\u193B' | '\u1946' .. '\u194F' - | '\u19D0' .. '\u19DA' | '\u1A17' .. '\u1A1B' | '\u1A55' .. '\u1A5E' - | '\u1A60' .. '\u1A7C' | '\u1A7F' .. '\u1A89' | '\u1A90' .. '\u1A99' - | '\u1AB0' .. '\u1ABD' | '\u1ABF' | '\u1AC0' | '\u1B00' .. '\u1B04' - | '\u1B34' .. '\u1B44' | '\u1B50' .. '\u1B59' | '\u1B6B' .. '\u1B73' - | '\u1B80' .. '\u1B82' | '\u1BA1' .. '\u1BAD' | '\u1BB0' .. '\u1BB9' - | '\u1BE6' .. '\u1BF3' | '\u1C24' .. '\u1C37' | '\u1C40' .. '\u1C49' - | '\u1C50' .. '\u1C59' | '\u1CD0' .. '\u1CD2' | '\u1CD4' .. '\u1CE8' - | '\u1CED' | '\u1CF4' | '\u1CF7' .. '\u1CF9' | '\u1DC0' .. '\u1DF9' - | '\u1DFB' .. '\u1DFF' | '\u203F' | '\u2040' | '\u2054' - | '\u20D0' .. '\u20DC' | '\u20E1' | '\u20E5' .. '\u20F0' - | '\u2CEF' .. '\u2CF1' | '\u2D7F' | '\u2DE0' .. '\u2DFF' - | '\u302A' .. '\u302F' | '\u3099' | '\u309A' | '\uA620' .. '\uA629' - | '\uA66F' | '\uA674' .. '\uA67D' | '\uA69E' | '\uA69F' | '\uA6F0' - | '\uA6F1' | '\uA802' | '\uA806' | '\uA80B' | '\uA823' .. '\uA827' - | '\uA82C' | '\uA880' | '\uA881' | '\uA8B4' .. '\uA8C5' - | '\uA8D0' .. '\uA8D9' | '\uA8E0' .. '\uA8F1' | '\uA8FF' .. '\uA909' - | '\uA926' .. '\uA92D' | '\uA947' .. '\uA953' | '\uA980' .. '\uA983' - | '\uA9B3' .. '\uA9C0' | '\uA9D0' .. '\uA9D9' | '\uA9E5' - | '\uA9F0' .. '\uA9F9' | '\uAA29' .. '\uAA36' | '\uAA43' | '\uAA4C' - | '\uAA4D' | '\uAA50' .. '\uAA59' | '\uAA7B' .. '\uAA7D' | '\uAAB0' - | '\uAAB2' .. '\uAAB4' | '\uAAB7' | '\uAAB8' | '\uAABE' | '\uAABF' - | '\uAAC1' | '\uAAEB' .. '\uAAEF' | '\uAAF5' | '\uAAF6' - | '\uABE3' .. '\uABEA' | '\uABEC' | '\uABED' | '\uABF0' .. '\uABF9' - | '\uFB1E' | '\uFE00' .. '\uFE0F' | '\uFE20' .. '\uFE2F' | '\uFE33' - | '\uFE34' | '\uFE4D' .. '\uFE4F' | '\uFF10' .. '\uFF19' | '\uFF3F' - | '\uFF9E' | '\uFF9F' - | '\u{101FD}' | '\u{102E0}' | '\u{10376}' .. '\u{1037A}' - | '\u{104A0}' .. '\u{104A9}' | '\u{10A01}' .. '\u{10A03}' | '\u{10A05}' - | '\u{10A06}' | '\u{10A0C}' .. '\u{10A0F}' | '\u{10A38}' .. '\u{10A3A}' - | '\u{10A3F}' | '\u{10AE5}' | '\u{10AE6}' | '\u{10D24}' .. '\u{10D27}' - | '\u{10D30}' .. '\u{10D39}' | '\u{10EAB}' | '\u{10EAC}' - | '\u{10F46}' .. '\u{10F50}' | '\u{11000}' .. '\u{11002}' - | '\u{11038}' .. '\u{11046}' | '\u{11066}' .. '\u{1106F}' - | '\u{1107F}' .. '\u{11082}' | '\u{110B0}' .. '\u{110BA}' - | '\u{110F0}' .. '\u{110F9}' | '\u{11100}' .. '\u{11102}' - | '\u{11127}' .. '\u{11134}' | '\u{11136}' .. '\u{1113F}' | '\u{11145}' - | '\u{11146}' | '\u{11173}' | '\u{11180}' .. '\u{11182}' - | '\u{111B3}' .. '\u{111C0}' | '\u{111C9}' .. '\u{111CC}' - | '\u{111CE}' .. '\u{111D9}' | '\u{1122C}' .. '\u{11237}' | '\u{1123E}' - | '\u{112DF}' .. '\u{112EA}' | '\u{112F0}' .. '\u{112F9}' - | '\u{11300}' .. '\u{11303}' | '\u{1133B}' | '\u{1133C}' - | '\u{1133E}' .. '\u{11344}' | '\u{11347}' | '\u{11348}' - | '\u{1134B}' .. '\u{1134D}' | '\u{11357}' | '\u{11362}' | '\u{11363}' - | '\u{11366}' .. '\u{1136C}' | '\u{11370}' .. '\u{11374}' - | '\u{11435}' .. '\u{11446}' | '\u{11450}' .. '\u{11459}' | '\u{1145E}' - | '\u{114B0}' .. '\u{114C3}' | '\u{114D0}' .. '\u{114D9}' - | '\u{115AF}' .. '\u{115B5}' | '\u{115B8}' .. '\u{115C0}' | '\u{115DC}' - | '\u{115DD}' | '\u{11630}' .. '\u{11640}' | '\u{11650}' .. '\u{11659}' - | '\u{116AB}' .. '\u{116B7}' | '\u{116C0}' .. '\u{116C9}' - | '\u{1171D}' .. '\u{1172B}' | '\u{11730}' .. '\u{11739}' - | '\u{1182C}' .. '\u{1183A}' | '\u{118E0}' .. '\u{118E9}' - | '\u{11930}' .. '\u{11935}' | '\u{11937}' | '\u{11938}' - | '\u{1193B}' .. '\u{1193E}' | '\u{11940}' | '\u{11942}' | '\u{11943}' - | '\u{11950}' .. '\u{11959}' | '\u{119D1}' .. '\u{119D7}' - | '\u{119DA}' .. '\u{119E0}' | '\u{119E4}' | '\u{11A01}' .. '\u{11A0A}' - | '\u{11A33}' .. '\u{11A39}' | '\u{11A3B}' .. '\u{11A3E}' | '\u{11A47}' - | '\u{11A51}' .. '\u{11A5B}' | '\u{11A8A}' .. '\u{11A99}' - | '\u{11C2F}' .. '\u{11C36}' | '\u{11C38}' .. '\u{11C3F}' - | '\u{11C50}' .. '\u{11C59}' | '\u{11C92}' .. '\u{11CA7}' - | '\u{11CA9}' .. '\u{11CB6}' | '\u{11D31}' .. '\u{11D36}' | '\u{11D3A}' - | '\u{11D3C}' | '\u{11D3D}' | '\u{11D3F}' .. '\u{11D45}' | '\u{11D47}' - | '\u{11D50}' .. '\u{11D59}' | '\u{11D8A}' .. '\u{11D8E}' | '\u{11D90}' - | '\u{11D91}' | '\u{11D93}' .. '\u{11D97}' | '\u{11DA0}' .. '\u{11DA9}' - | '\u{11EF3}' .. '\u{11EF6}' | '\u{16A60}' .. '\u{16A69}' - | '\u{16AF0}' .. '\u{16AF4}' | '\u{16B30}' .. '\u{16B36}' - | '\u{16B50}' .. '\u{16B59}' | '\u{16F4F}' | '\u{16F51}' .. '\u{16F87}' - | '\u{16F8F}' .. '\u{16F92}' | '\u{16FE4}' | '\u{16FF0}' | '\u{16FF1}' - | '\u{1BC9D}' | '\u{1BC9E}' | '\u{1D165}' .. '\u{1D169}' - | '\u{1D16D}' .. '\u{1D172}' | '\u{1D17B}' .. '\u{1D182}' - | '\u{1D185}' .. '\u{1D18B}' | '\u{1D1AA}' .. '\u{1D1AD}' - | '\u{1D242}' .. '\u{1D244}' | '\u{1D7CE}' .. '\u{1D7FF}' - | '\u{1DA00}' .. '\u{1DA36}' | '\u{1DA3B}' .. '\u{1DA6C}' | '\u{1DA75}' - | '\u{1DA84}' | '\u{1DA9B}' .. '\u{1DA9F}' | '\u{1DAA1}' .. '\u{1DAAF}' - | '\u{1E000}' .. '\u{1E006}' | '\u{1E008}' .. '\u{1E018}' - | '\u{1E01B}' .. '\u{1E021}' | '\u{1E023}' | '\u{1E024}' - | '\u{1E026}' .. '\u{1E02A}' | '\u{1E130}' .. '\u{1E136}' - | '\u{1E140}' .. '\u{1E149}' | '\u{1E2EC}' .. '\u{1E2F9}' - | '\u{1E8D0}' .. '\u{1E8D6}' | '\u{1E944}' .. '\u{1E94A}' - | '\u{1E950}' .. '\u{1E959}' | '\u{1FBF0}' .. '\u{1FBF9}' - | '\u{E0100}' .. '\u{E01EF}' - ; - -fragment ID_START // based on: https://github.com/asmeurer/python-unicode-variable-names - : '\u0041' .. '\u005A' | '\u005F' | '\u0061' .. '\u007A' | '\u00AA' - | '\u00B5' | '\u00BA' | '\u00C0' .. '\u00D6' | '\u00D8' .. '\u00F6' - | '\u00F8' .. '\u02C1' | '\u02C6' .. '\u02D1' | '\u02E0' .. '\u02E4' - | '\u02EC' | '\u02EE' | '\u0370' .. '\u0374' | '\u0376' | '\u0377' - | '\u037B' .. '\u037D' | '\u037F' | '\u0386' | '\u0388' .. '\u038A' - | '\u038C' | '\u038E' .. '\u03A1' | '\u03A3' .. '\u03F5' - | '\u03F7' .. '\u0481' | '\u048A' .. '\u052F' | '\u0531' .. '\u0556' - | '\u0559' | '\u0560' .. '\u0588' | '\u05D0' .. '\u05EA' - | '\u05EF' .. '\u05F2' | '\u0620' .. '\u064A' | '\u066E' | '\u066F' - | '\u0671' .. '\u06D3' | '\u06D5' | '\u06E5' | '\u06E6' | '\u06EE' - | '\u06EF' | '\u06FA' .. '\u06FC' | '\u06FF' | '\u0710' - | '\u0712' .. '\u072F' | '\u074D' .. '\u07A5' | '\u07B1' - | '\u07CA' .. '\u07EA' | '\u07F4' | '\u07F5' | '\u07FA' - | '\u0800' .. '\u0815' | '\u081A' | '\u0824' | '\u0828' - | '\u0840' .. '\u0858' | '\u0860' .. '\u086A' | '\u08A0' .. '\u08B4' - | '\u08B6' .. '\u08C7' | '\u0904' .. '\u0939' | '\u093D' | '\u0950' - | '\u0958' .. '\u0961' | '\u0971' .. '\u0980' | '\u0985' .. '\u098C' - | '\u098F' | '\u0990' | '\u0993' .. '\u09A8' | '\u09AA' .. '\u09B0' - | '\u09B2' | '\u09B6' .. '\u09B9' | '\u09BD' | '\u09CE' | '\u09DC' - | '\u09DD' | '\u09DF' .. '\u09E1' | '\u09F0' | '\u09F1' | '\u09FC' - | '\u0A05' .. '\u0A0A' | '\u0A0F' | '\u0A10' | '\u0A13' .. '\u0A28' - | '\u0A2A' .. '\u0A30' | '\u0A32' | '\u0A33' | '\u0A35' | '\u0A36' - | '\u0A38' | '\u0A39' | '\u0A59' .. '\u0A5C' | '\u0A5E' - | '\u0A72' .. '\u0A74' | '\u0A85' .. '\u0A8D' | '\u0A8F' .. '\u0A91' - | '\u0A93' .. '\u0AA8' | '\u0AAA' .. '\u0AB0' | '\u0AB2' | '\u0AB3' - | '\u0AB5' .. '\u0AB9' | '\u0ABD' | '\u0AD0' | '\u0AE0' | '\u0AE1' - | '\u0AF9' | '\u0B05' .. '\u0B0C' | '\u0B0F' | '\u0B10' - | '\u0B13' .. '\u0B28' | '\u0B2A' .. '\u0B30' | '\u0B32' | '\u0B33' - | '\u0B35' .. '\u0B39' | '\u0B3D' | '\u0B5C' | '\u0B5D' - | '\u0B5F' .. '\u0B61' | '\u0B71' | '\u0B83' | '\u0B85' .. '\u0B8A' - | '\u0B8E' .. '\u0B90' | '\u0B92' .. '\u0B95' | '\u0B99' | '\u0B9A' - | '\u0B9C' | '\u0B9E' | '\u0B9F' | '\u0BA3' | '\u0BA4' - | '\u0BA8' .. '\u0BAA' | '\u0BAE' .. '\u0BB9' | '\u0BD0' - | '\u0C05' .. '\u0C0C' | '\u0C0E' .. '\u0C10' | '\u0C12' .. '\u0C28' - | '\u0C2A' .. '\u0C39' | '\u0C3D' | '\u0C58' .. '\u0C5A' | '\u0C60' - | '\u0C61' | '\u0C80' | '\u0C85' .. '\u0C8C' | '\u0C8E' .. '\u0C90' - | '\u0C92' .. '\u0CA8' | '\u0CAA' .. '\u0CB3' | '\u0CB5' .. '\u0CB9' - | '\u0CBD' | '\u0CDE' | '\u0CE0' | '\u0CE1' | '\u0CF1' | '\u0CF2' - | '\u0D04' .. '\u0D0C' | '\u0D0E' .. '\u0D10' | '\u0D12' .. '\u0D3A' - | '\u0D3D' | '\u0D4E' | '\u0D54' .. '\u0D56' | '\u0D5F' .. '\u0D61' - | '\u0D7A' .. '\u0D7F' | '\u0D85' .. '\u0D96' | '\u0D9A' .. '\u0DB1' - | '\u0DB3' .. '\u0DBB' | '\u0DBD' | '\u0DC0' .. '\u0DC6' - | '\u0E01' .. '\u0E30' | '\u0E32' | '\u0E40' .. '\u0E46' | '\u0E81' - | '\u0E82' | '\u0E84' | '\u0E86' .. '\u0E8A' | '\u0E8C' .. '\u0EA3' - | '\u0EA5' | '\u0EA7' .. '\u0EB0' | '\u0EB2' | '\u0EBD' - | '\u0EC0' .. '\u0EC4' | '\u0EC6' | '\u0EDC' .. '\u0EDF' | '\u0F00' - | '\u0F40' .. '\u0F47' | '\u0F49' .. '\u0F6C' | '\u0F88' .. '\u0F8C' - | '\u1000' .. '\u102A' | '\u103F' | '\u1050' .. '\u1055' - | '\u105A' .. '\u105D' | '\u1061' | '\u1065' | '\u1066' - | '\u106E' .. '\u1070' | '\u1075' .. '\u1081' | '\u108E' - | '\u10A0' .. '\u10C5' | '\u10C7' | '\u10CD' | '\u10D0' .. '\u10FA' - | '\u10FC' .. '\u1248' | '\u124A' .. '\u124D' | '\u1250' .. '\u1256' - | '\u1258' | '\u125A' .. '\u125D' | '\u1260' .. '\u1288' - | '\u128A' .. '\u128D' | '\u1290' .. '\u12B0' | '\u12B2' .. '\u12B5' - | '\u12B8' .. '\u12BE' | '\u12C0' | '\u12C2' .. '\u12C5' - | '\u12C8' .. '\u12D6' | '\u12D8' .. '\u1310' | '\u1312' .. '\u1315' - | '\u1318' .. '\u135A' | '\u1380' .. '\u138F' | '\u13A0' .. '\u13F5' - | '\u13F8' .. '\u13FD' | '\u1401' .. '\u166C' | '\u166F' .. '\u167F' - | '\u1681' .. '\u169A' | '\u16A0' .. '\u16EA' | '\u16EE' .. '\u16F8' - | '\u1700' .. '\u170C' | '\u170E' .. '\u1711' | '\u1720' .. '\u1731' - | '\u1740' .. '\u1751' | '\u1760' .. '\u176C' | '\u176E' .. '\u1770' - | '\u1780' .. '\u17B3' | '\u17D7' | '\u17DC' | '\u1820' .. '\u1878' - | '\u1880' .. '\u18A8' | '\u18AA' | '\u18B0' .. '\u18F5' - | '\u1900' .. '\u191E' | '\u1950' .. '\u196D' | '\u1970' .. '\u1974' - | '\u1980' .. '\u19AB' | '\u19B0' .. '\u19C9' | '\u1A00' .. '\u1A16' - | '\u1A20' .. '\u1A54' | '\u1AA7' | '\u1B05' .. '\u1B33' - | '\u1B45' .. '\u1B4B' | '\u1B83' .. '\u1BA0' | '\u1BAE' | '\u1BAF' - | '\u1BBA' .. '\u1BE5' | '\u1C00' .. '\u1C23' | '\u1C4D' .. '\u1C4F' - | '\u1C5A' .. '\u1C7D' | '\u1C80' .. '\u1C88' | '\u1C90' .. '\u1CBA' - | '\u1CBD' .. '\u1CBF' | '\u1CE9' .. '\u1CEC' | '\u1CEE' .. '\u1CF3' - | '\u1CF5' | '\u1CF6' | '\u1CFA' | '\u1D00' .. '\u1DBF' - | '\u1E00' .. '\u1F15' | '\u1F18' .. '\u1F1D' | '\u1F20' .. '\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' - | '\u2071' | '\u207F' | '\u2090' .. '\u209C' | '\u2102' | '\u2107' - | '\u210A' .. '\u2113' | '\u2115' | '\u2118' .. '\u211D' | '\u2124' - | '\u2126' | '\u2128' | '\u212A' .. '\u2139' | '\u213C' .. '\u213F' - | '\u2145' .. '\u2149' | '\u214E' | '\u2160' .. '\u2188' - | '\u2C00' .. '\u2C2E' | '\u2C30' .. '\u2C5E' | '\u2C60' .. '\u2CE4' - | '\u2CEB' .. '\u2CEE' | '\u2CF2' | '\u2CF3' | '\u2D00' .. '\u2D25' - | '\u2D27' | '\u2D2D' | '\u2D30' .. '\u2D67' | '\u2D6F' - | '\u2D80' .. '\u2D96' | '\u2DA0' .. '\u2DA6' | '\u2DA8' .. '\u2DAE' - | '\u2DB0' .. '\u2DB6' | '\u2DB8' .. '\u2DBE' | '\u2DC0' .. '\u2DC6' - | '\u2DC8' .. '\u2DCE' | '\u2DD0' .. '\u2DD6' | '\u2DD8' .. '\u2DDE' - | '\u3005' .. '\u3007' | '\u3021' .. '\u3029' | '\u3031' .. '\u3035' - | '\u3038' .. '\u303C' | '\u3041' .. '\u3096' | '\u309D' .. '\u309F' - | '\u30A1' .. '\u30FA' | '\u30FC' .. '\u30FF' | '\u3105' .. '\u312F' - | '\u3131' .. '\u318E' | '\u31A0' .. '\u31BF' | '\u31F0' .. '\u31FF' - | '\u3400' .. '\u4DBF' | '\u4E00' .. '\u9FFC' | '\uA000' .. '\uA48C' - | '\uA4D0' .. '\uA4FD' | '\uA500' .. '\uA60C' | '\uA610' .. '\uA61F' - | '\uA62A' | '\uA62B' | '\uA640' .. '\uA66E' | '\uA67F' .. '\uA69D' - | '\uA6A0' .. '\uA6EF' | '\uA717' .. '\uA71F' | '\uA722' .. '\uA788' - | '\uA78B' .. '\uA7BF' | '\uA7C2' .. '\uA7CA' | '\uA7F5' .. '\uA801' - | '\uA803' .. '\uA805' | '\uA807' .. '\uA80A' | '\uA80C' .. '\uA822' - | '\uA840' .. '\uA873' | '\uA882' .. '\uA8B3' | '\uA8F2' .. '\uA8F7' - | '\uA8FB' | '\uA8FD' | '\uA8FE' | '\uA90A' .. '\uA925' - | '\uA930' .. '\uA946' | '\uA960' .. '\uA97C' | '\uA984' .. '\uA9B2' - | '\uA9CF' | '\uA9E0' .. '\uA9E4' | '\uA9E6' .. '\uA9EF' - | '\uA9FA' .. '\uA9FE' | '\uAA00' .. '\uAA28' | '\uAA40' .. '\uAA42' - | '\uAA44' .. '\uAA4B' | '\uAA60' .. '\uAA76' | '\uAA7A' - | '\uAA7E' .. '\uAAAF' | '\uAAB1' | '\uAAB5' | '\uAAB6' - | '\uAAB9' .. '\uAABD' | '\uAAC0' | '\uAAC2' | '\uAADB' .. '\uAADD' - | '\uAAE0' .. '\uAAEA' | '\uAAF2' .. '\uAAF4' | '\uAB01' .. '\uAB06' - | '\uAB09' .. '\uAB0E' | '\uAB11' .. '\uAB16' | '\uAB20' .. '\uAB26' - | '\uAB28' .. '\uAB2E' | '\uAB30' .. '\uAB5A' | '\uAB5C' .. '\uAB69' - | '\uAB70' .. '\uABE2' | '\uAC00' .. '\uD7A3' | '\uD7B0' .. '\uD7C6' - | '\uD7CB' .. '\uD7FB' | '\uF900' .. '\uFA6D' | '\uFA70' .. '\uFAD9' - | '\uFB00' .. '\uFB06' | '\uFB13' .. '\uFB17' | '\uFB1D' - | '\uFB1F' .. '\uFB28' | '\uFB2A' .. '\uFB36' | '\uFB38' .. '\uFB3C' - | '\uFB3E' | '\uFB40' | '\uFB41' | '\uFB43' | '\uFB44' - | '\uFB46' .. '\uFBB1' | '\uFBD3' .. '\uFC5D' | '\uFC64' .. '\uFD3D' - | '\uFD50' .. '\uFD8F' | '\uFD92' .. '\uFDC7' | '\uFDF0' .. '\uFDF9' - | '\uFE71' | '\uFE73' | '\uFE77' | '\uFE79' | '\uFE7B' | '\uFE7D' - | '\uFE7F' .. '\uFEFC' | '\uFF21' .. '\uFF3A' | '\uFF41' .. '\uFF5A' - | '\uFF66' .. '\uFF9D' | '\uFFA0' .. '\uFFBE' | '\uFFC2' .. '\uFFC7' - | '\uFFCA' .. '\uFFCF' | '\uFFD2' .. '\uFFD7' | '\uFFDA' .. '\uFFDC' - | '\u{10000}' .. '\u{1000B}' | '\u{1000D}' .. '\u{10026}' - | '\u{10028}' .. '\u{1003A}' | '\u{1003C}' | '\u{1003D}' - | '\u{1003F}' .. '\u{1004D}' | '\u{10050}' .. '\u{1005D}' - | '\u{10080}' .. '\u{100FA}' | '\u{10140}' .. '\u{10174}' - | '\u{10280}' .. '\u{1029C}' | '\u{102A0}' .. '\u{102D0}' - | '\u{10300}' .. '\u{1031F}' | '\u{1032D}' .. '\u{1034A}' - | '\u{10350}' .. '\u{10375}' | '\u{10380}' .. '\u{1039D}' - | '\u{103A0}' .. '\u{103C3}' | '\u{103C8}' .. '\u{103CF}' - | '\u{103D1}' .. '\u{103D5}' | '\u{10400}' .. '\u{1049D}' - | '\u{104B0}' .. '\u{104D3}' | '\u{104D8}' .. '\u{104FB}' - | '\u{10500}' .. '\u{10527}' | '\u{10530}' .. '\u{10563}' - | '\u{10600}' .. '\u{10736}' | '\u{10740}' .. '\u{10755}' - | '\u{10760}' .. '\u{10767}' | '\u{10800}' .. '\u{10805}' | '\u{10808}' - | '\u{1080A}' .. '\u{10835}' | '\u{10837}' | '\u{10838}' | '\u{1083C}' - | '\u{1083F}' .. '\u{10855}' | '\u{10860}' .. '\u{10876}' - | '\u{10880}' .. '\u{1089E}' | '\u{108E0}' .. '\u{108F2}' | '\u{108F4}' - | '\u{108F5}' | '\u{10900}' .. '\u{10915}' | '\u{10920}' .. '\u{10939}' - | '\u{10980}' .. '\u{109B7}' | '\u{109BE}' | '\u{109BF}' | '\u{10A00}' - | '\u{10A10}' .. '\u{10A13}' | '\u{10A15}' .. '\u{10A17}' - | '\u{10A19}' .. '\u{10A35}' | '\u{10A60}' .. '\u{10A7C}' - | '\u{10A80}' .. '\u{10A9C}' | '\u{10AC0}' .. '\u{10AC7}' - | '\u{10AC9}' .. '\u{10AE4}' | '\u{10B00}' .. '\u{10B35}' - | '\u{10B40}' .. '\u{10B55}' | '\u{10B60}' .. '\u{10B72}' - | '\u{10B80}' .. '\u{10B91}' | '\u{10C00}' .. '\u{10C48}' - | '\u{10C80}' .. '\u{10CB2}' | '\u{10CC0}' .. '\u{10CF2}' - | '\u{10D00}' .. '\u{10D23}' | '\u{10E80}' .. '\u{10EA9}' | '\u{10EB0}' - | '\u{10EB1}' | '\u{10F00}' .. '\u{10F1C}' | '\u{10F27}' - | '\u{10F30}' .. '\u{10F45}' | '\u{10FB0}' .. '\u{10FC4}' - | '\u{10FE0}' .. '\u{10FF6}' | '\u{11003}' .. '\u{11037}' - | '\u{11083}' .. '\u{110AF}' | '\u{110D0}' .. '\u{110E8}' - | '\u{11103}' .. '\u{11126}' | '\u{11144}' | '\u{11147}' - | '\u{11150}' .. '\u{11172}' | '\u{11176}' | '\u{11183}' .. '\u{111B2}' - | '\u{111C1}' .. '\u{111C4}' | '\u{111DA}' | '\u{111DC}' - | '\u{11200}' .. '\u{11211}' | '\u{11213}' .. '\u{1122B}' - | '\u{11280}' .. '\u{11286}' | '\u{11288}' | '\u{1128A}' .. '\u{1128D}' - | '\u{1128F}' .. '\u{1129D}' | '\u{1129F}' .. '\u{112A8}' - | '\u{112B0}' .. '\u{112DE}' | '\u{11305}' .. '\u{1130C}' | '\u{1130F}' - | '\u{11310}' | '\u{11313}' .. '\u{11328}' | '\u{1132A}' .. '\u{11330}' - | '\u{11332}' | '\u{11333}' | '\u{11335}' .. '\u{11339}' | '\u{1133D}' - | '\u{11350}' | '\u{1135D}' .. '\u{11361}' | '\u{11400}' .. '\u{11434}' - | '\u{11447}' .. '\u{1144A}' | '\u{1145F}' .. '\u{11461}' - | '\u{11480}' .. '\u{114AF}' | '\u{114C4}' | '\u{114C5}' | '\u{114C7}' - | '\u{11580}' .. '\u{115AE}' | '\u{115D8}' .. '\u{115DB}' - | '\u{11600}' .. '\u{1162F}' | '\u{11644}' | '\u{11680}' .. '\u{116AA}' - | '\u{116B8}' | '\u{11700}' .. '\u{1171A}' | '\u{11800}' .. '\u{1182B}' - | '\u{118A0}' .. '\u{118DF}' | '\u{118FF}' .. '\u{11906}' | '\u{11909}' - | '\u{1190C}' .. '\u{11913}' | '\u{11915}' | '\u{11916}' - | '\u{11918}' .. '\u{1192F}' | '\u{1193F}' | '\u{11941}' - | '\u{119A0}' .. '\u{119A7}' | '\u{119AA}' .. '\u{119D0}' | '\u{119E1}' - | '\u{119E3}' | '\u{11A00}' | '\u{11A0B}' .. '\u{11A32}' | '\u{11A3A}' - | '\u{11A50}' | '\u{11A5C}' .. '\u{11A89}' | '\u{11A9D}' - | '\u{11AC0}' .. '\u{11AF8}' | '\u{11C00}' .. '\u{11C08}' - | '\u{11C0A}' .. '\u{11C2E}' | '\u{11C40}' | '\u{11C72}' .. '\u{11C8F}' - | '\u{11D00}' .. '\u{11D06}' | '\u{11D08}' | '\u{11D09}' - | '\u{11D0B}' .. '\u{11D30}' | '\u{11D46}' | '\u{11D60}' .. '\u{11D65}' - | '\u{11D67}' | '\u{11D68}' | '\u{11D6A}' .. '\u{11D89}' | '\u{11D98}' - | '\u{11EE0}' .. '\u{11EF2}' | '\u{11FB0}' | '\u{12000}' .. '\u{12399}' - | '\u{12400}' .. '\u{1246E}' | '\u{12480}' .. '\u{12543}' - | '\u{13000}' .. '\u{1342E}' | '\u{14400}' .. '\u{14646}' - | '\u{16800}' .. '\u{16A38}' | '\u{16A40}' .. '\u{16A5E}' - | '\u{16AD0}' .. '\u{16AED}' | '\u{16B00}' .. '\u{16B2F}' - | '\u{16B40}' .. '\u{16B43}' | '\u{16B63}' .. '\u{16B77}' - | '\u{16B7D}' .. '\u{16B8F}' | '\u{16E40}' .. '\u{16E7F}' - | '\u{16F00}' .. '\u{16F4A}' | '\u{16F50}' | '\u{16F93}' .. '\u{16F9F}' - | '\u{16FE0}' | '\u{16FE1}' | '\u{16FE3}' | '\u{17000}' .. '\u{187F7}' - | '\u{18800}' .. '\u{18CD5}' | '\u{18D00}' .. '\u{18D08}' - | '\u{1B000}' .. '\u{1B11E}' | '\u{1B150}' .. '\u{1B152}' - | '\u{1B164}' .. '\u{1B167}' | '\u{1B170}' .. '\u{1B2FB}' - | '\u{1BC00}' .. '\u{1BC6A}' | '\u{1BC70}' .. '\u{1BC7C}' - | '\u{1BC80}' .. '\u{1BC88}' | '\u{1BC90}' .. '\u{1BC99}' - | '\u{1D400}' .. '\u{1D454}' | '\u{1D456}' .. '\u{1D49C}' | '\u{1D49E}' - | '\u{1D49F}' | '\u{1D4A2}' | '\u{1D4A5}' | '\u{1D4A6}' - | '\u{1D4A9}' .. '\u{1D4AC}' | '\u{1D4AE}' .. '\u{1D4B9}' | '\u{1D4BB}' - | '\u{1D4BD}' .. '\u{1D4C3}' | '\u{1D4C5}' .. '\u{1D505}' - | '\u{1D507}' .. '\u{1D50A}' | '\u{1D50D}' .. '\u{1D514}' - | '\u{1D516}' .. '\u{1D51C}' | '\u{1D51E}' .. '\u{1D539}' - | '\u{1D53B}' .. '\u{1D53E}' | '\u{1D540}' .. '\u{1D544}' | '\u{1D546}' - | '\u{1D54A}' .. '\u{1D550}' | '\u{1D552}' .. '\u{1D6A5}' - | '\u{1D6A8}' .. '\u{1D6C0}' | '\u{1D6C2}' .. '\u{1D6DA}' - | '\u{1D6DC}' .. '\u{1D6FA}' | '\u{1D6FC}' .. '\u{1D714}' - | '\u{1D716}' .. '\u{1D734}' | '\u{1D736}' .. '\u{1D74E}' - | '\u{1D750}' .. '\u{1D76E}' | '\u{1D770}' .. '\u{1D788}' - | '\u{1D78A}' .. '\u{1D7A8}' | '\u{1D7AA}' .. '\u{1D7C2}' - | '\u{1D7C4}' .. '\u{1D7CB}' | '\u{1E100}' .. '\u{1E12C}' - | '\u{1E137}' .. '\u{1E13D}' | '\u{1E14E}' | '\u{1E2C0}' .. '\u{1E2EB}' - | '\u{1E800}' .. '\u{1E8C4}' | '\u{1E900}' .. '\u{1E943}' | '\u{1E94B}' - | '\u{1EE00}' .. '\u{1EE03}' | '\u{1EE05}' .. '\u{1EE1F}' | '\u{1EE21}' - | '\u{1EE22}' | '\u{1EE24}' | '\u{1EE27}' | '\u{1EE29}' .. '\u{1EE32}' - | '\u{1EE34}' .. '\u{1EE37}' | '\u{1EE39}' | '\u{1EE3B}' | '\u{1EE42}' - | '\u{1EE47}' | '\u{1EE49}' | '\u{1EE4B}' | '\u{1EE4D}' .. '\u{1EE4F}' - | '\u{1EE51}' | '\u{1EE52}' | '\u{1EE54}' | '\u{1EE57}' | '\u{1EE59}' - | '\u{1EE5B}' | '\u{1EE5D}' | '\u{1EE5F}' | '\u{1EE61}' | '\u{1EE62}' - | '\u{1EE64}' | '\u{1EE67}' .. '\u{1EE6A}' | '\u{1EE6C}' .. '\u{1EE72}' - | '\u{1EE74}' .. '\u{1EE77}' | '\u{1EE79}' .. '\u{1EE7C}' | '\u{1EE7E}' - | '\u{1EE80}' .. '\u{1EE89}' | '\u{1EE8B}' .. '\u{1EE9B}' - | '\u{1EEA1}' .. '\u{1EEA3}' | '\u{1EEA5}' .. '\u{1EEA9}' - | '\u{1EEAB}' .. '\u{1EEBB}' | '\u{20000}' .. '\u{2A6DD}' - | '\u{2A700}' .. '\u{2B734}' | '\u{2B740}' .. '\u{2B81D}' - | '\u{2B820}' .. '\u{2CEA1}' | '\u{2CEB0}' .. '\u{2EBE0}' - | '\u{2F800}' .. '\u{2FA1D}' | '\u{30000}' .. '\u{3134A}' - ; +fragment OS_INDEPENDENT_NL: '\r'? '\n'; // Unix, Windows + +fragment ID_CONTINUE: // based on: https://github.com/asmeurer/python-unicode-variable-names + ID_START + | '\u0030' .. '\u0039' + | '\u00B7' + | '\u0300' .. '\u036F' + | '\u0387' + | '\u0483' .. '\u0487' + | '\u0591' .. '\u05BD' + | '\u05BF' + | '\u05C1' + | '\u05C2' + | '\u05C4' + | '\u05C5' + | '\u05C7' + | '\u0610' .. '\u061A' + | '\u064B' .. '\u0669' + | '\u0670' + | '\u06D6' .. '\u06DC' + | '\u06DF' .. '\u06E4' + | '\u06E7' + | '\u06E8' + | '\u06EA' .. '\u06ED' + | '\u06F0' .. '\u06F9' + | '\u0711' + | '\u0730' .. '\u074A' + | '\u07A6' .. '\u07B0' + | '\u07C0' .. '\u07C9' + | '\u07EB' .. '\u07F3' + | '\u07FD' + | '\u0816' .. '\u0819' + | '\u081B' .. '\u0823' + | '\u0825' .. '\u0827' + | '\u0829' .. '\u082D' + | '\u0859' .. '\u085B' + | '\u08D3' .. '\u08E1' + | '\u08E3' .. '\u0903' + | '\u093A' .. '\u093C' + | '\u093E' .. '\u094F' + | '\u0951' .. '\u0957' + | '\u0962' + | '\u0963' + | '\u0966' .. '\u096F' + | '\u0981' .. '\u0983' + | '\u09BC' + | '\u09BE' .. '\u09C4' + | '\u09C7' + | '\u09C8' + | '\u09CB' .. '\u09CD' + | '\u09D7' + | '\u09E2' + | '\u09E3' + | '\u09E6' .. '\u09EF' + | '\u09FE' + | '\u0A01' .. '\u0A03' + | '\u0A3C' + | '\u0A3E' .. '\u0A42' + | '\u0A47' + | '\u0A48' + | '\u0A4B' .. '\u0A4D' + | '\u0A51' + | '\u0A66' .. '\u0A71' + | '\u0A75' + | '\u0A81' .. '\u0A83' + | '\u0ABC' + | '\u0ABE' .. '\u0AC5' + | '\u0AC7' .. '\u0AC9' + | '\u0ACB' .. '\u0ACD' + | '\u0AE2' + | '\u0AE3' + | '\u0AE6' .. '\u0AEF' + | '\u0AFA' .. '\u0AFF' + | '\u0B01' .. '\u0B03' + | '\u0B3C' + | '\u0B3E' .. '\u0B44' + | '\u0B47' + | '\u0B48' + | '\u0B4B' .. '\u0B4D' + | '\u0B55' .. '\u0B57' + | '\u0B62' + | '\u0B63' + | '\u0B66' .. '\u0B6F' + | '\u0B82' + | '\u0BBE' .. '\u0BC2' + | '\u0BC6' .. '\u0BC8' + | '\u0BCA' .. '\u0BCD' + | '\u0BD7' + | '\u0BE6' .. '\u0BEF' + | '\u0C00' .. '\u0C04' + | '\u0C3E' .. '\u0C44' + | '\u0C46' .. '\u0C48' + | '\u0C4A' .. '\u0C4D' + | '\u0C55' + | '\u0C56' + | '\u0C62' + | '\u0C63' + | '\u0C66' .. '\u0C6F' + | '\u0C81' .. '\u0C83' + | '\u0CBC' + | '\u0CBE' .. '\u0CC4' + | '\u0CC6' .. '\u0CC8' + | '\u0CCA' .. '\u0CCD' + | '\u0CD5' + | '\u0CD6' + | '\u0CE2' + | '\u0CE3' + | '\u0CE6' .. '\u0CEF' + | '\u0D00' .. '\u0D03' + | '\u0D3B' + | '\u0D3C' + | '\u0D3E' .. '\u0D44' + | '\u0D46' .. '\u0D48' + | '\u0D4A' .. '\u0D4D' + | '\u0D57' + | '\u0D62' + | '\u0D63' + | '\u0D66' .. '\u0D6F' + | '\u0D81' .. '\u0D83' + | '\u0DCA' + | '\u0DCF' .. '\u0DD4' + | '\u0DD6' + | '\u0DD8' .. '\u0DDF' + | '\u0DE6' .. '\u0DEF' + | '\u0DF2' + | '\u0DF3' + | '\u0E31' + | '\u0E33' .. '\u0E3A' + | '\u0E47' .. '\u0E4E' + | '\u0E50' .. '\u0E59' + | '\u0EB1' + | '\u0EB3' .. '\u0EBC' + | '\u0EC8' .. '\u0ECD' + | '\u0ED0' .. '\u0ED9' + | '\u0F18' + | '\u0F19' + | '\u0F20' .. '\u0F29' + | '\u0F35' + | '\u0F37' + | '\u0F39' + | '\u0F3E' + | '\u0F3F' + | '\u0F71' .. '\u0F84' + | '\u0F86' + | '\u0F87' + | '\u0F8D' .. '\u0F97' + | '\u0F99' .. '\u0FBC' + | '\u0FC6' + | '\u102B' .. '\u103E' + | '\u1040' .. '\u1049' + | '\u1056' .. '\u1059' + | '\u105E' .. '\u1060' + | '\u1062' .. '\u1064' + | '\u1067' .. '\u106D' + | '\u1071' .. '\u1074' + | '\u1082' .. '\u108D' + | '\u108F' .. '\u109D' + | '\u135D' .. '\u135F' + | '\u1369' .. '\u1371' + | '\u1712' .. '\u1714' + | '\u1732' .. '\u1734' + | '\u1752' + | '\u1753' + | '\u1772' + | '\u1773' + | '\u17B4' .. '\u17D3' + | '\u17DD' + | '\u17E0' .. '\u17E9' + | '\u180B' .. '\u180D' + | '\u1810' .. '\u1819' + | '\u18A9' + | '\u1920' .. '\u192B' + | '\u1930' .. '\u193B' + | '\u1946' .. '\u194F' + | '\u19D0' .. '\u19DA' + | '\u1A17' .. '\u1A1B' + | '\u1A55' .. '\u1A5E' + | '\u1A60' .. '\u1A7C' + | '\u1A7F' .. '\u1A89' + | '\u1A90' .. '\u1A99' + | '\u1AB0' .. '\u1ABD' + | '\u1ABF' + | '\u1AC0' + | '\u1B00' .. '\u1B04' + | '\u1B34' .. '\u1B44' + | '\u1B50' .. '\u1B59' + | '\u1B6B' .. '\u1B73' + | '\u1B80' .. '\u1B82' + | '\u1BA1' .. '\u1BAD' + | '\u1BB0' .. '\u1BB9' + | '\u1BE6' .. '\u1BF3' + | '\u1C24' .. '\u1C37' + | '\u1C40' .. '\u1C49' + | '\u1C50' .. '\u1C59' + | '\u1CD0' .. '\u1CD2' + | '\u1CD4' .. '\u1CE8' + | '\u1CED' + | '\u1CF4' + | '\u1CF7' .. '\u1CF9' + | '\u1DC0' .. '\u1DF9' + | '\u1DFB' .. '\u1DFF' + | '\u203F' + | '\u2040' + | '\u2054' + | '\u20D0' .. '\u20DC' + | '\u20E1' + | '\u20E5' .. '\u20F0' + | '\u2CEF' .. '\u2CF1' + | '\u2D7F' + | '\u2DE0' .. '\u2DFF' + | '\u302A' .. '\u302F' + | '\u3099' + | '\u309A' + | '\uA620' .. '\uA629' + | '\uA66F' + | '\uA674' .. '\uA67D' + | '\uA69E' + | '\uA69F' + | '\uA6F0' + | '\uA6F1' + | '\uA802' + | '\uA806' + | '\uA80B' + | '\uA823' .. '\uA827' + | '\uA82C' + | '\uA880' + | '\uA881' + | '\uA8B4' .. '\uA8C5' + | '\uA8D0' .. '\uA8D9' + | '\uA8E0' .. '\uA8F1' + | '\uA8FF' .. '\uA909' + | '\uA926' .. '\uA92D' + | '\uA947' .. '\uA953' + | '\uA980' .. '\uA983' + | '\uA9B3' .. '\uA9C0' + | '\uA9D0' .. '\uA9D9' + | '\uA9E5' + | '\uA9F0' .. '\uA9F9' + | '\uAA29' .. '\uAA36' + | '\uAA43' + | '\uAA4C' + | '\uAA4D' + | '\uAA50' .. '\uAA59' + | '\uAA7B' .. '\uAA7D' + | '\uAAB0' + | '\uAAB2' .. '\uAAB4' + | '\uAAB7' + | '\uAAB8' + | '\uAABE' + | '\uAABF' + | '\uAAC1' + | '\uAAEB' .. '\uAAEF' + | '\uAAF5' + | '\uAAF6' + | '\uABE3' .. '\uABEA' + | '\uABEC' + | '\uABED' + | '\uABF0' .. '\uABF9' + | '\uFB1E' + | '\uFE00' .. '\uFE0F' + | '\uFE20' .. '\uFE2F' + | '\uFE33' + | '\uFE34' + | '\uFE4D' .. '\uFE4F' + | '\uFF10' .. '\uFF19' + | '\uFF3F' + | '\uFF9E' + | '\uFF9F' + | '\u{101FD}' + | '\u{102E0}' + | '\u{10376}' .. '\u{1037A}' + | '\u{104A0}' .. '\u{104A9}' + | '\u{10A01}' .. '\u{10A03}' + | '\u{10A05}' + | '\u{10A06}' + | '\u{10A0C}' .. '\u{10A0F}' + | '\u{10A38}' .. '\u{10A3A}' + | '\u{10A3F}' + | '\u{10AE5}' + | '\u{10AE6}' + | '\u{10D24}' .. '\u{10D27}' + | '\u{10D30}' .. '\u{10D39}' + | '\u{10EAB}' + | '\u{10EAC}' + | '\u{10F46}' .. '\u{10F50}' + | '\u{11000}' .. '\u{11002}' + | '\u{11038}' .. '\u{11046}' + | '\u{11066}' .. '\u{1106F}' + | '\u{1107F}' .. '\u{11082}' + | '\u{110B0}' .. '\u{110BA}' + | '\u{110F0}' .. '\u{110F9}' + | '\u{11100}' .. '\u{11102}' + | '\u{11127}' .. '\u{11134}' + | '\u{11136}' .. '\u{1113F}' + | '\u{11145}' + | '\u{11146}' + | '\u{11173}' + | '\u{11180}' .. '\u{11182}' + | '\u{111B3}' .. '\u{111C0}' + | '\u{111C9}' .. '\u{111CC}' + | '\u{111CE}' .. '\u{111D9}' + | '\u{1122C}' .. '\u{11237}' + | '\u{1123E}' + | '\u{112DF}' .. '\u{112EA}' + | '\u{112F0}' .. '\u{112F9}' + | '\u{11300}' .. '\u{11303}' + | '\u{1133B}' + | '\u{1133C}' + | '\u{1133E}' .. '\u{11344}' + | '\u{11347}' + | '\u{11348}' + | '\u{1134B}' .. '\u{1134D}' + | '\u{11357}' + | '\u{11362}' + | '\u{11363}' + | '\u{11366}' .. '\u{1136C}' + | '\u{11370}' .. '\u{11374}' + | '\u{11435}' .. '\u{11446}' + | '\u{11450}' .. '\u{11459}' + | '\u{1145E}' + | '\u{114B0}' .. '\u{114C3}' + | '\u{114D0}' .. '\u{114D9}' + | '\u{115AF}' .. '\u{115B5}' + | '\u{115B8}' .. '\u{115C0}' + | '\u{115DC}' + | '\u{115DD}' + | '\u{11630}' .. '\u{11640}' + | '\u{11650}' .. '\u{11659}' + | '\u{116AB}' .. '\u{116B7}' + | '\u{116C0}' .. '\u{116C9}' + | '\u{1171D}' .. '\u{1172B}' + | '\u{11730}' .. '\u{11739}' + | '\u{1182C}' .. '\u{1183A}' + | '\u{118E0}' .. '\u{118E9}' + | '\u{11930}' .. '\u{11935}' + | '\u{11937}' + | '\u{11938}' + | '\u{1193B}' .. '\u{1193E}' + | '\u{11940}' + | '\u{11942}' + | '\u{11943}' + | '\u{11950}' .. '\u{11959}' + | '\u{119D1}' .. '\u{119D7}' + | '\u{119DA}' .. '\u{119E0}' + | '\u{119E4}' + | '\u{11A01}' .. '\u{11A0A}' + | '\u{11A33}' .. '\u{11A39}' + | '\u{11A3B}' .. '\u{11A3E}' + | '\u{11A47}' + | '\u{11A51}' .. '\u{11A5B}' + | '\u{11A8A}' .. '\u{11A99}' + | '\u{11C2F}' .. '\u{11C36}' + | '\u{11C38}' .. '\u{11C3F}' + | '\u{11C50}' .. '\u{11C59}' + | '\u{11C92}' .. '\u{11CA7}' + | '\u{11CA9}' .. '\u{11CB6}' + | '\u{11D31}' .. '\u{11D36}' + | '\u{11D3A}' + | '\u{11D3C}' + | '\u{11D3D}' + | '\u{11D3F}' .. '\u{11D45}' + | '\u{11D47}' + | '\u{11D50}' .. '\u{11D59}' + | '\u{11D8A}' .. '\u{11D8E}' + | '\u{11D90}' + | '\u{11D91}' + | '\u{11D93}' .. '\u{11D97}' + | '\u{11DA0}' .. '\u{11DA9}' + | '\u{11EF3}' .. '\u{11EF6}' + | '\u{16A60}' .. '\u{16A69}' + | '\u{16AF0}' .. '\u{16AF4}' + | '\u{16B30}' .. '\u{16B36}' + | '\u{16B50}' .. '\u{16B59}' + | '\u{16F4F}' + | '\u{16F51}' .. '\u{16F87}' + | '\u{16F8F}' .. '\u{16F92}' + | '\u{16FE4}' + | '\u{16FF0}' + | '\u{16FF1}' + | '\u{1BC9D}' + | '\u{1BC9E}' + | '\u{1D165}' .. '\u{1D169}' + | '\u{1D16D}' .. '\u{1D172}' + | '\u{1D17B}' .. '\u{1D182}' + | '\u{1D185}' .. '\u{1D18B}' + | '\u{1D1AA}' .. '\u{1D1AD}' + | '\u{1D242}' .. '\u{1D244}' + | '\u{1D7CE}' .. '\u{1D7FF}' + | '\u{1DA00}' .. '\u{1DA36}' + | '\u{1DA3B}' .. '\u{1DA6C}' + | '\u{1DA75}' + | '\u{1DA84}' + | '\u{1DA9B}' .. '\u{1DA9F}' + | '\u{1DAA1}' .. '\u{1DAAF}' + | '\u{1E000}' .. '\u{1E006}' + | '\u{1E008}' .. '\u{1E018}' + | '\u{1E01B}' .. '\u{1E021}' + | '\u{1E023}' + | '\u{1E024}' + | '\u{1E026}' .. '\u{1E02A}' + | '\u{1E130}' .. '\u{1E136}' + | '\u{1E140}' .. '\u{1E149}' + | '\u{1E2EC}' .. '\u{1E2F9}' + | '\u{1E8D0}' .. '\u{1E8D6}' + | '\u{1E944}' .. '\u{1E94A}' + | '\u{1E950}' .. '\u{1E959}' + | '\u{1FBF0}' .. '\u{1FBF9}' + | '\u{E0100}' .. '\u{E01EF}' +; + +fragment ID_START: // based on: https://github.com/asmeurer/python-unicode-variable-names + '\u0041' .. '\u005A' + | '\u005F' + | '\u0061' .. '\u007A' + | '\u00AA' + | '\u00B5' + | '\u00BA' + | '\u00C0' .. '\u00D6' + | '\u00D8' .. '\u00F6' + | '\u00F8' .. '\u02C1' + | '\u02C6' .. '\u02D1' + | '\u02E0' .. '\u02E4' + | '\u02EC' + | '\u02EE' + | '\u0370' .. '\u0374' + | '\u0376' + | '\u0377' + | '\u037B' .. '\u037D' + | '\u037F' + | '\u0386' + | '\u0388' .. '\u038A' + | '\u038C' + | '\u038E' .. '\u03A1' + | '\u03A3' .. '\u03F5' + | '\u03F7' .. '\u0481' + | '\u048A' .. '\u052F' + | '\u0531' .. '\u0556' + | '\u0559' + | '\u0560' .. '\u0588' + | '\u05D0' .. '\u05EA' + | '\u05EF' .. '\u05F2' + | '\u0620' .. '\u064A' + | '\u066E' + | '\u066F' + | '\u0671' .. '\u06D3' + | '\u06D5' + | '\u06E5' + | '\u06E6' + | '\u06EE' + | '\u06EF' + | '\u06FA' .. '\u06FC' + | '\u06FF' + | '\u0710' + | '\u0712' .. '\u072F' + | '\u074D' .. '\u07A5' + | '\u07B1' + | '\u07CA' .. '\u07EA' + | '\u07F4' + | '\u07F5' + | '\u07FA' + | '\u0800' .. '\u0815' + | '\u081A' + | '\u0824' + | '\u0828' + | '\u0840' .. '\u0858' + | '\u0860' .. '\u086A' + | '\u08A0' .. '\u08B4' + | '\u08B6' .. '\u08C7' + | '\u0904' .. '\u0939' + | '\u093D' + | '\u0950' + | '\u0958' .. '\u0961' + | '\u0971' .. '\u0980' + | '\u0985' .. '\u098C' + | '\u098F' + | '\u0990' + | '\u0993' .. '\u09A8' + | '\u09AA' .. '\u09B0' + | '\u09B2' + | '\u09B6' .. '\u09B9' + | '\u09BD' + | '\u09CE' + | '\u09DC' + | '\u09DD' + | '\u09DF' .. '\u09E1' + | '\u09F0' + | '\u09F1' + | '\u09FC' + | '\u0A05' .. '\u0A0A' + | '\u0A0F' + | '\u0A10' + | '\u0A13' .. '\u0A28' + | '\u0A2A' .. '\u0A30' + | '\u0A32' + | '\u0A33' + | '\u0A35' + | '\u0A36' + | '\u0A38' + | '\u0A39' + | '\u0A59' .. '\u0A5C' + | '\u0A5E' + | '\u0A72' .. '\u0A74' + | '\u0A85' .. '\u0A8D' + | '\u0A8F' .. '\u0A91' + | '\u0A93' .. '\u0AA8' + | '\u0AAA' .. '\u0AB0' + | '\u0AB2' + | '\u0AB3' + | '\u0AB5' .. '\u0AB9' + | '\u0ABD' + | '\u0AD0' + | '\u0AE0' + | '\u0AE1' + | '\u0AF9' + | '\u0B05' .. '\u0B0C' + | '\u0B0F' + | '\u0B10' + | '\u0B13' .. '\u0B28' + | '\u0B2A' .. '\u0B30' + | '\u0B32' + | '\u0B33' + | '\u0B35' .. '\u0B39' + | '\u0B3D' + | '\u0B5C' + | '\u0B5D' + | '\u0B5F' .. '\u0B61' + | '\u0B71' + | '\u0B83' + | '\u0B85' .. '\u0B8A' + | '\u0B8E' .. '\u0B90' + | '\u0B92' .. '\u0B95' + | '\u0B99' + | '\u0B9A' + | '\u0B9C' + | '\u0B9E' + | '\u0B9F' + | '\u0BA3' + | '\u0BA4' + | '\u0BA8' .. '\u0BAA' + | '\u0BAE' .. '\u0BB9' + | '\u0BD0' + | '\u0C05' .. '\u0C0C' + | '\u0C0E' .. '\u0C10' + | '\u0C12' .. '\u0C28' + | '\u0C2A' .. '\u0C39' + | '\u0C3D' + | '\u0C58' .. '\u0C5A' + | '\u0C60' + | '\u0C61' + | '\u0C80' + | '\u0C85' .. '\u0C8C' + | '\u0C8E' .. '\u0C90' + | '\u0C92' .. '\u0CA8' + | '\u0CAA' .. '\u0CB3' + | '\u0CB5' .. '\u0CB9' + | '\u0CBD' + | '\u0CDE' + | '\u0CE0' + | '\u0CE1' + | '\u0CF1' + | '\u0CF2' + | '\u0D04' .. '\u0D0C' + | '\u0D0E' .. '\u0D10' + | '\u0D12' .. '\u0D3A' + | '\u0D3D' + | '\u0D4E' + | '\u0D54' .. '\u0D56' + | '\u0D5F' .. '\u0D61' + | '\u0D7A' .. '\u0D7F' + | '\u0D85' .. '\u0D96' + | '\u0D9A' .. '\u0DB1' + | '\u0DB3' .. '\u0DBB' + | '\u0DBD' + | '\u0DC0' .. '\u0DC6' + | '\u0E01' .. '\u0E30' + | '\u0E32' + | '\u0E40' .. '\u0E46' + | '\u0E81' + | '\u0E82' + | '\u0E84' + | '\u0E86' .. '\u0E8A' + | '\u0E8C' .. '\u0EA3' + | '\u0EA5' + | '\u0EA7' .. '\u0EB0' + | '\u0EB2' + | '\u0EBD' + | '\u0EC0' .. '\u0EC4' + | '\u0EC6' + | '\u0EDC' .. '\u0EDF' + | '\u0F00' + | '\u0F40' .. '\u0F47' + | '\u0F49' .. '\u0F6C' + | '\u0F88' .. '\u0F8C' + | '\u1000' .. '\u102A' + | '\u103F' + | '\u1050' .. '\u1055' + | '\u105A' .. '\u105D' + | '\u1061' + | '\u1065' + | '\u1066' + | '\u106E' .. '\u1070' + | '\u1075' .. '\u1081' + | '\u108E' + | '\u10A0' .. '\u10C5' + | '\u10C7' + | '\u10CD' + | '\u10D0' .. '\u10FA' + | '\u10FC' .. '\u1248' + | '\u124A' .. '\u124D' + | '\u1250' .. '\u1256' + | '\u1258' + | '\u125A' .. '\u125D' + | '\u1260' .. '\u1288' + | '\u128A' .. '\u128D' + | '\u1290' .. '\u12B0' + | '\u12B2' .. '\u12B5' + | '\u12B8' .. '\u12BE' + | '\u12C0' + | '\u12C2' .. '\u12C5' + | '\u12C8' .. '\u12D6' + | '\u12D8' .. '\u1310' + | '\u1312' .. '\u1315' + | '\u1318' .. '\u135A' + | '\u1380' .. '\u138F' + | '\u13A0' .. '\u13F5' + | '\u13F8' .. '\u13FD' + | '\u1401' .. '\u166C' + | '\u166F' .. '\u167F' + | '\u1681' .. '\u169A' + | '\u16A0' .. '\u16EA' + | '\u16EE' .. '\u16F8' + | '\u1700' .. '\u170C' + | '\u170E' .. '\u1711' + | '\u1720' .. '\u1731' + | '\u1740' .. '\u1751' + | '\u1760' .. '\u176C' + | '\u176E' .. '\u1770' + | '\u1780' .. '\u17B3' + | '\u17D7' + | '\u17DC' + | '\u1820' .. '\u1878' + | '\u1880' .. '\u18A8' + | '\u18AA' + | '\u18B0' .. '\u18F5' + | '\u1900' .. '\u191E' + | '\u1950' .. '\u196D' + | '\u1970' .. '\u1974' + | '\u1980' .. '\u19AB' + | '\u19B0' .. '\u19C9' + | '\u1A00' .. '\u1A16' + | '\u1A20' .. '\u1A54' + | '\u1AA7' + | '\u1B05' .. '\u1B33' + | '\u1B45' .. '\u1B4B' + | '\u1B83' .. '\u1BA0' + | '\u1BAE' + | '\u1BAF' + | '\u1BBA' .. '\u1BE5' + | '\u1C00' .. '\u1C23' + | '\u1C4D' .. '\u1C4F' + | '\u1C5A' .. '\u1C7D' + | '\u1C80' .. '\u1C88' + | '\u1C90' .. '\u1CBA' + | '\u1CBD' .. '\u1CBF' + | '\u1CE9' .. '\u1CEC' + | '\u1CEE' .. '\u1CF3' + | '\u1CF5' + | '\u1CF6' + | '\u1CFA' + | '\u1D00' .. '\u1DBF' + | '\u1E00' .. '\u1F15' + | '\u1F18' .. '\u1F1D' + | '\u1F20' .. '\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' + | '\u2071' + | '\u207F' + | '\u2090' .. '\u209C' + | '\u2102' + | '\u2107' + | '\u210A' .. '\u2113' + | '\u2115' + | '\u2118' .. '\u211D' + | '\u2124' + | '\u2126' + | '\u2128' + | '\u212A' .. '\u2139' + | '\u213C' .. '\u213F' + | '\u2145' .. '\u2149' + | '\u214E' + | '\u2160' .. '\u2188' + | '\u2C00' .. '\u2C2E' + | '\u2C30' .. '\u2C5E' + | '\u2C60' .. '\u2CE4' + | '\u2CEB' .. '\u2CEE' + | '\u2CF2' + | '\u2CF3' + | '\u2D00' .. '\u2D25' + | '\u2D27' + | '\u2D2D' + | '\u2D30' .. '\u2D67' + | '\u2D6F' + | '\u2D80' .. '\u2D96' + | '\u2DA0' .. '\u2DA6' + | '\u2DA8' .. '\u2DAE' + | '\u2DB0' .. '\u2DB6' + | '\u2DB8' .. '\u2DBE' + | '\u2DC0' .. '\u2DC6' + | '\u2DC8' .. '\u2DCE' + | '\u2DD0' .. '\u2DD6' + | '\u2DD8' .. '\u2DDE' + | '\u3005' .. '\u3007' + | '\u3021' .. '\u3029' + | '\u3031' .. '\u3035' + | '\u3038' .. '\u303C' + | '\u3041' .. '\u3096' + | '\u309D' .. '\u309F' + | '\u30A1' .. '\u30FA' + | '\u30FC' .. '\u30FF' + | '\u3105' .. '\u312F' + | '\u3131' .. '\u318E' + | '\u31A0' .. '\u31BF' + | '\u31F0' .. '\u31FF' + | '\u3400' .. '\u4DBF' + | '\u4E00' .. '\u9FFC' + | '\uA000' .. '\uA48C' + | '\uA4D0' .. '\uA4FD' + | '\uA500' .. '\uA60C' + | '\uA610' .. '\uA61F' + | '\uA62A' + | '\uA62B' + | '\uA640' .. '\uA66E' + | '\uA67F' .. '\uA69D' + | '\uA6A0' .. '\uA6EF' + | '\uA717' .. '\uA71F' + | '\uA722' .. '\uA788' + | '\uA78B' .. '\uA7BF' + | '\uA7C2' .. '\uA7CA' + | '\uA7F5' .. '\uA801' + | '\uA803' .. '\uA805' + | '\uA807' .. '\uA80A' + | '\uA80C' .. '\uA822' + | '\uA840' .. '\uA873' + | '\uA882' .. '\uA8B3' + | '\uA8F2' .. '\uA8F7' + | '\uA8FB' + | '\uA8FD' + | '\uA8FE' + | '\uA90A' .. '\uA925' + | '\uA930' .. '\uA946' + | '\uA960' .. '\uA97C' + | '\uA984' .. '\uA9B2' + | '\uA9CF' + | '\uA9E0' .. '\uA9E4' + | '\uA9E6' .. '\uA9EF' + | '\uA9FA' .. '\uA9FE' + | '\uAA00' .. '\uAA28' + | '\uAA40' .. '\uAA42' + | '\uAA44' .. '\uAA4B' + | '\uAA60' .. '\uAA76' + | '\uAA7A' + | '\uAA7E' .. '\uAAAF' + | '\uAAB1' + | '\uAAB5' + | '\uAAB6' + | '\uAAB9' .. '\uAABD' + | '\uAAC0' + | '\uAAC2' + | '\uAADB' .. '\uAADD' + | '\uAAE0' .. '\uAAEA' + | '\uAAF2' .. '\uAAF4' + | '\uAB01' .. '\uAB06' + | '\uAB09' .. '\uAB0E' + | '\uAB11' .. '\uAB16' + | '\uAB20' .. '\uAB26' + | '\uAB28' .. '\uAB2E' + | '\uAB30' .. '\uAB5A' + | '\uAB5C' .. '\uAB69' + | '\uAB70' .. '\uABE2' + | '\uAC00' .. '\uD7A3' + | '\uD7B0' .. '\uD7C6' + | '\uD7CB' .. '\uD7FB' + | '\uF900' .. '\uFA6D' + | '\uFA70' .. '\uFAD9' + | '\uFB00' .. '\uFB06' + | '\uFB13' .. '\uFB17' + | '\uFB1D' + | '\uFB1F' .. '\uFB28' + | '\uFB2A' .. '\uFB36' + | '\uFB38' .. '\uFB3C' + | '\uFB3E' + | '\uFB40' + | '\uFB41' + | '\uFB43' + | '\uFB44' + | '\uFB46' .. '\uFBB1' + | '\uFBD3' .. '\uFC5D' + | '\uFC64' .. '\uFD3D' + | '\uFD50' .. '\uFD8F' + | '\uFD92' .. '\uFDC7' + | '\uFDF0' .. '\uFDF9' + | '\uFE71' + | '\uFE73' + | '\uFE77' + | '\uFE79' + | '\uFE7B' + | '\uFE7D' + | '\uFE7F' .. '\uFEFC' + | '\uFF21' .. '\uFF3A' + | '\uFF41' .. '\uFF5A' + | '\uFF66' .. '\uFF9D' + | '\uFFA0' .. '\uFFBE' + | '\uFFC2' .. '\uFFC7' + | '\uFFCA' .. '\uFFCF' + | '\uFFD2' .. '\uFFD7' + | '\uFFDA' .. '\uFFDC' + | '\u{10000}' .. '\u{1000B}' + | '\u{1000D}' .. '\u{10026}' + | '\u{10028}' .. '\u{1003A}' + | '\u{1003C}' + | '\u{1003D}' + | '\u{1003F}' .. '\u{1004D}' + | '\u{10050}' .. '\u{1005D}' + | '\u{10080}' .. '\u{100FA}' + | '\u{10140}' .. '\u{10174}' + | '\u{10280}' .. '\u{1029C}' + | '\u{102A0}' .. '\u{102D0}' + | '\u{10300}' .. '\u{1031F}' + | '\u{1032D}' .. '\u{1034A}' + | '\u{10350}' .. '\u{10375}' + | '\u{10380}' .. '\u{1039D}' + | '\u{103A0}' .. '\u{103C3}' + | '\u{103C8}' .. '\u{103CF}' + | '\u{103D1}' .. '\u{103D5}' + | '\u{10400}' .. '\u{1049D}' + | '\u{104B0}' .. '\u{104D3}' + | '\u{104D8}' .. '\u{104FB}' + | '\u{10500}' .. '\u{10527}' + | '\u{10530}' .. '\u{10563}' + | '\u{10600}' .. '\u{10736}' + | '\u{10740}' .. '\u{10755}' + | '\u{10760}' .. '\u{10767}' + | '\u{10800}' .. '\u{10805}' + | '\u{10808}' + | '\u{1080A}' .. '\u{10835}' + | '\u{10837}' + | '\u{10838}' + | '\u{1083C}' + | '\u{1083F}' .. '\u{10855}' + | '\u{10860}' .. '\u{10876}' + | '\u{10880}' .. '\u{1089E}' + | '\u{108E0}' .. '\u{108F2}' + | '\u{108F4}' + | '\u{108F5}' + | '\u{10900}' .. '\u{10915}' + | '\u{10920}' .. '\u{10939}' + | '\u{10980}' .. '\u{109B7}' + | '\u{109BE}' + | '\u{109BF}' + | '\u{10A00}' + | '\u{10A10}' .. '\u{10A13}' + | '\u{10A15}' .. '\u{10A17}' + | '\u{10A19}' .. '\u{10A35}' + | '\u{10A60}' .. '\u{10A7C}' + | '\u{10A80}' .. '\u{10A9C}' + | '\u{10AC0}' .. '\u{10AC7}' + | '\u{10AC9}' .. '\u{10AE4}' + | '\u{10B00}' .. '\u{10B35}' + | '\u{10B40}' .. '\u{10B55}' + | '\u{10B60}' .. '\u{10B72}' + | '\u{10B80}' .. '\u{10B91}' + | '\u{10C00}' .. '\u{10C48}' + | '\u{10C80}' .. '\u{10CB2}' + | '\u{10CC0}' .. '\u{10CF2}' + | '\u{10D00}' .. '\u{10D23}' + | '\u{10E80}' .. '\u{10EA9}' + | '\u{10EB0}' + | '\u{10EB1}' + | '\u{10F00}' .. '\u{10F1C}' + | '\u{10F27}' + | '\u{10F30}' .. '\u{10F45}' + | '\u{10FB0}' .. '\u{10FC4}' + | '\u{10FE0}' .. '\u{10FF6}' + | '\u{11003}' .. '\u{11037}' + | '\u{11083}' .. '\u{110AF}' + | '\u{110D0}' .. '\u{110E8}' + | '\u{11103}' .. '\u{11126}' + | '\u{11144}' + | '\u{11147}' + | '\u{11150}' .. '\u{11172}' + | '\u{11176}' + | '\u{11183}' .. '\u{111B2}' + | '\u{111C1}' .. '\u{111C4}' + | '\u{111DA}' + | '\u{111DC}' + | '\u{11200}' .. '\u{11211}' + | '\u{11213}' .. '\u{1122B}' + | '\u{11280}' .. '\u{11286}' + | '\u{11288}' + | '\u{1128A}' .. '\u{1128D}' + | '\u{1128F}' .. '\u{1129D}' + | '\u{1129F}' .. '\u{112A8}' + | '\u{112B0}' .. '\u{112DE}' + | '\u{11305}' .. '\u{1130C}' + | '\u{1130F}' + | '\u{11310}' + | '\u{11313}' .. '\u{11328}' + | '\u{1132A}' .. '\u{11330}' + | '\u{11332}' + | '\u{11333}' + | '\u{11335}' .. '\u{11339}' + | '\u{1133D}' + | '\u{11350}' + | '\u{1135D}' .. '\u{11361}' + | '\u{11400}' .. '\u{11434}' + | '\u{11447}' .. '\u{1144A}' + | '\u{1145F}' .. '\u{11461}' + | '\u{11480}' .. '\u{114AF}' + | '\u{114C4}' + | '\u{114C5}' + | '\u{114C7}' + | '\u{11580}' .. '\u{115AE}' + | '\u{115D8}' .. '\u{115DB}' + | '\u{11600}' .. '\u{1162F}' + | '\u{11644}' + | '\u{11680}' .. '\u{116AA}' + | '\u{116B8}' + | '\u{11700}' .. '\u{1171A}' + | '\u{11800}' .. '\u{1182B}' + | '\u{118A0}' .. '\u{118DF}' + | '\u{118FF}' .. '\u{11906}' + | '\u{11909}' + | '\u{1190C}' .. '\u{11913}' + | '\u{11915}' + | '\u{11916}' + | '\u{11918}' .. '\u{1192F}' + | '\u{1193F}' + | '\u{11941}' + | '\u{119A0}' .. '\u{119A7}' + | '\u{119AA}' .. '\u{119D0}' + | '\u{119E1}' + | '\u{119E3}' + | '\u{11A00}' + | '\u{11A0B}' .. '\u{11A32}' + | '\u{11A3A}' + | '\u{11A50}' + | '\u{11A5C}' .. '\u{11A89}' + | '\u{11A9D}' + | '\u{11AC0}' .. '\u{11AF8}' + | '\u{11C00}' .. '\u{11C08}' + | '\u{11C0A}' .. '\u{11C2E}' + | '\u{11C40}' + | '\u{11C72}' .. '\u{11C8F}' + | '\u{11D00}' .. '\u{11D06}' + | '\u{11D08}' + | '\u{11D09}' + | '\u{11D0B}' .. '\u{11D30}' + | '\u{11D46}' + | '\u{11D60}' .. '\u{11D65}' + | '\u{11D67}' + | '\u{11D68}' + | '\u{11D6A}' .. '\u{11D89}' + | '\u{11D98}' + | '\u{11EE0}' .. '\u{11EF2}' + | '\u{11FB0}' + | '\u{12000}' .. '\u{12399}' + | '\u{12400}' .. '\u{1246E}' + | '\u{12480}' .. '\u{12543}' + | '\u{13000}' .. '\u{1342E}' + | '\u{14400}' .. '\u{14646}' + | '\u{16800}' .. '\u{16A38}' + | '\u{16A40}' .. '\u{16A5E}' + | '\u{16AD0}' .. '\u{16AED}' + | '\u{16B00}' .. '\u{16B2F}' + | '\u{16B40}' .. '\u{16B43}' + | '\u{16B63}' .. '\u{16B77}' + | '\u{16B7D}' .. '\u{16B8F}' + | '\u{16E40}' .. '\u{16E7F}' + | '\u{16F00}' .. '\u{16F4A}' + | '\u{16F50}' + | '\u{16F93}' .. '\u{16F9F}' + | '\u{16FE0}' + | '\u{16FE1}' + | '\u{16FE3}' + | '\u{17000}' .. '\u{187F7}' + | '\u{18800}' .. '\u{18CD5}' + | '\u{18D00}' .. '\u{18D08}' + | '\u{1B000}' .. '\u{1B11E}' + | '\u{1B150}' .. '\u{1B152}' + | '\u{1B164}' .. '\u{1B167}' + | '\u{1B170}' .. '\u{1B2FB}' + | '\u{1BC00}' .. '\u{1BC6A}' + | '\u{1BC70}' .. '\u{1BC7C}' + | '\u{1BC80}' .. '\u{1BC88}' + | '\u{1BC90}' .. '\u{1BC99}' + | '\u{1D400}' .. '\u{1D454}' + | '\u{1D456}' .. '\u{1D49C}' + | '\u{1D49E}' + | '\u{1D49F}' + | '\u{1D4A2}' + | '\u{1D4A5}' + | '\u{1D4A6}' + | '\u{1D4A9}' .. '\u{1D4AC}' + | '\u{1D4AE}' .. '\u{1D4B9}' + | '\u{1D4BB}' + | '\u{1D4BD}' .. '\u{1D4C3}' + | '\u{1D4C5}' .. '\u{1D505}' + | '\u{1D507}' .. '\u{1D50A}' + | '\u{1D50D}' .. '\u{1D514}' + | '\u{1D516}' .. '\u{1D51C}' + | '\u{1D51E}' .. '\u{1D539}' + | '\u{1D53B}' .. '\u{1D53E}' + | '\u{1D540}' .. '\u{1D544}' + | '\u{1D546}' + | '\u{1D54A}' .. '\u{1D550}' + | '\u{1D552}' .. '\u{1D6A5}' + | '\u{1D6A8}' .. '\u{1D6C0}' + | '\u{1D6C2}' .. '\u{1D6DA}' + | '\u{1D6DC}' .. '\u{1D6FA}' + | '\u{1D6FC}' .. '\u{1D714}' + | '\u{1D716}' .. '\u{1D734}' + | '\u{1D736}' .. '\u{1D74E}' + | '\u{1D750}' .. '\u{1D76E}' + | '\u{1D770}' .. '\u{1D788}' + | '\u{1D78A}' .. '\u{1D7A8}' + | '\u{1D7AA}' .. '\u{1D7C2}' + | '\u{1D7C4}' .. '\u{1D7CB}' + | '\u{1E100}' .. '\u{1E12C}' + | '\u{1E137}' .. '\u{1E13D}' + | '\u{1E14E}' + | '\u{1E2C0}' .. '\u{1E2EB}' + | '\u{1E800}' .. '\u{1E8C4}' + | '\u{1E900}' .. '\u{1E943}' + | '\u{1E94B}' + | '\u{1EE00}' .. '\u{1EE03}' + | '\u{1EE05}' .. '\u{1EE1F}' + | '\u{1EE21}' + | '\u{1EE22}' + | '\u{1EE24}' + | '\u{1EE27}' + | '\u{1EE29}' .. '\u{1EE32}' + | '\u{1EE34}' .. '\u{1EE37}' + | '\u{1EE39}' + | '\u{1EE3B}' + | '\u{1EE42}' + | '\u{1EE47}' + | '\u{1EE49}' + | '\u{1EE4B}' + | '\u{1EE4D}' .. '\u{1EE4F}' + | '\u{1EE51}' + | '\u{1EE52}' + | '\u{1EE54}' + | '\u{1EE57}' + | '\u{1EE59}' + | '\u{1EE5B}' + | '\u{1EE5D}' + | '\u{1EE5F}' + | '\u{1EE61}' + | '\u{1EE62}' + | '\u{1EE64}' + | '\u{1EE67}' .. '\u{1EE6A}' + | '\u{1EE6C}' .. '\u{1EE72}' + | '\u{1EE74}' .. '\u{1EE77}' + | '\u{1EE79}' .. '\u{1EE7C}' + | '\u{1EE7E}' + | '\u{1EE80}' .. '\u{1EE89}' + | '\u{1EE8B}' .. '\u{1EE9B}' + | '\u{1EEA1}' .. '\u{1EEA3}' + | '\u{1EEA5}' .. '\u{1EEA9}' + | '\u{1EEAB}' .. '\u{1EEBB}' + | '\u{20000}' .. '\u{2A6DD}' + | '\u{2A700}' .. '\u{2B734}' + | '\u{2B740}' .. '\u{2B81D}' + | '\u{2B820}' .. '\u{2CEA1}' + | '\u{2CEB0}' .. '\u{2EBE0}' + | '\u{2F800}' .. '\u{2FA1D}' + | '\u{30000}' .. '\u{3134A}' +; \ No newline at end of file diff --git a/python/python3_12_0/PythonParser.g4 b/python/python3_12_0/PythonParser.g4 index cd54ecab06..37fda9805e 100644 --- a/python/python3_12_0/PythonParser.g4 +++ b/python/python3_12_0/PythonParser.g4 @@ -20,40 +20,66 @@ 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.12 * Developed by : Robert Einhorn * */ -parser grammar PythonParser; // Python 3.12.0 https://docs.python.org/3.12/reference/grammar.html#full-grammar-specification +// $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 PythonParser; + +// Python 3.12.0 https://docs.python.org/3.12/reference/grammar.html#full-grammar-specification + options { - tokenVocab=PythonLexer; - superClass=PythonParserBase; + tokenVocab = PythonLexer; + superClass = PythonParserBase; } // STARTING RULES // ============== -file_input: statements? EOF; -interactive: statement_newline; -eval: expressions NEWLINE* EOF; -func_type: '(' type_expressions? ')' '->' expression NEWLINE* EOF; -fstring_input: star_expressions; +file_input + : statements? EOF + ; + +interactive + : statement_newline + ; + +eval + : expressions NEWLINE* EOF + ; + +func_type + : '(' type_expressions? ')' '->' expression NEWLINE* EOF + ; + +fstring_input + : star_expressions + ; // GENERAL STATEMENTS // ================== -statements: statement+; +statements + : statement+ + ; -statement: compound_stmt | simple_stmts; +statement + : compound_stmt + | simple_stmts + ; statement_newline : compound_stmt NEWLINE | simple_stmts | NEWLINE - | EOF; + | EOF + ; simple_stmts : simple_stmt (';' simple_stmt)* ';'? NEWLINE @@ -75,7 +101,8 @@ simple_stmt | 'break' | 'continue' | global_stmt - | nonlocal_stmt; + | nonlocal_stmt + ; compound_stmt : function_def @@ -85,20 +112,26 @@ compound_stmt | for_stmt | try_stmt | while_stmt - | match_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); + : 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; +annotated_rhs + : yield_expr + | star_expressions + ; augassign : '+=' @@ -113,53 +146,81 @@ augassign | '<<=' | '>>=' | '**=' - | '//='; + | '//=' + ; return_stmt - : 'return' star_expressions?; + : 'return' star_expressions? + ; raise_stmt - : 'raise' (expression ('from' expression )?)? + : 'raise' (expression ('from' expression)?)? ; -global_stmt: 'global' NAME (',' NAME)*; +global_stmt + : 'global' NAME (',' NAME)* + ; -nonlocal_stmt: 'nonlocal' NAME (',' NAME)*; +nonlocal_stmt + : 'nonlocal' NAME (',' NAME)* + ; del_stmt - : 'del' del_targets; + : 'del' del_targets + ; -yield_stmt: yield_expr; +yield_stmt + : yield_expr + ; -assert_stmt: 'assert' expression (',' expression )?; +assert_stmt + : 'assert' expression (',' expression)? + ; import_stmt : import_name - | import_from; + | import_from + ; // Import statements // ----------------- -import_name: 'import' dotted_as_names; +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; + | '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 (',' import_from_as_name)* + ; + import_from_as_name - : NAME ('as' NAME )?; + : NAME ('as' NAME)? + ; + dotted_as_names - : dotted_as_name (',' dotted_as_name)*; + : dotted_as_name (',' dotted_as_name)* + ; + dotted_as_name - : dotted_name ('as' NAME )?; + : dotted_name ('as' NAME)? + ; + dotted_name : dotted_name '.' NAME - | NAME; + | NAME + ; // COMPOUND STATEMENTS // =================== @@ -169,43 +230,52 @@ dotted_name block : NEWLINE INDENT statements DEDENT - | simple_stmts; + | simple_stmts + ; -decorators: ('@' named_expression NEWLINE )+; +decorators + : ('@' named_expression NEWLINE)+ + ; // Class definitions // ----------------- class_def : decorators class_def_raw - | class_def_raw; + | class_def_raw + ; class_def_raw - : 'class' NAME type_params? ('(' arguments? ')' )? ':' block; + : 'class' NAME type_params? ('(' arguments? ')')? ':' block + ; // Function definitions // -------------------- function_def : decorators function_def_raw - | 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; + : '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 + ; 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; + | star_etc + ; // Some duplication here because we can't write (',' | {isCurrentTokenType(RPAR)}?), // which is because we don't support empty alternatives (yet). @@ -213,6 +283,7 @@ parameters slash_no_default : param_no_default+ '/' ','? ; + slash_with_default : param_no_default* param_with_default+ '/' ','? ; @@ -221,10 +292,12 @@ star_etc : '*' param_no_default param_maybe_default* kwds? | '*' param_no_default_star_annotation param_maybe_default* kwds? | '*' ',' param_maybe_default+ kwds? - | kwds; + | kwds + ; kwds - : '**' param_no_default; + : '**' param_no_default + ; // One parameter. This *includes* a following comma and type comment. // @@ -242,20 +315,38 @@ kwds 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; + +param + : NAME annotation? + ; + +param_star_annotation + : NAME star_annotation + ; + +annotation + : ':' expression + ; + +star_annotation + : ':' star_expression + ; + +default_assignment + : '=' expression + ; // If statement // ------------ @@ -263,17 +354,21 @@ default_assignment: '=' expression; if_stmt : 'if' named_expression ':' block (elif_stmt | else_block?) ; + elif_stmt : 'elif' named_expression ':' block (elif_stmt | else_block?) ; + else_block - : 'else' ':' block; + : 'else' ':' block + ; // While statement // --------------- while_stmt - : 'while' named_expression ':' block else_block?; + : 'while' named_expression ':' block else_block? + ; // For statement // ------------- @@ -286,9 +381,10 @@ for_stmt // -------------- with_stmt - : ASYNC? 'with' ( '(' with_item (',' with_item)* ','? ')' ':' - | with_item (',' with_item)* ':' TYPE_COMMENT? - ) block + : ASYNC? 'with' ( + '(' with_item (',' with_item)* ','? ')' ':' + | with_item (',' with_item)* ':' TYPE_COMMENT? + ) block ; with_item @@ -301,48 +397,61 @@ with_item try_stmt : 'try' ':' block finally_block | 'try' ':' block except_block+ else_block? finally_block? - | 'try' ':' block except_star_block+ else_block? finally_block?; - + | 'try' ':' block except_star_block+ else_block? finally_block? + ; // Except statement // ---------------- except_block - : 'except' (expression ('as' NAME )?)? ':' block + : 'except' (expression ('as' NAME)?)? ':' block ; + except_star_block - : 'except' '*' expression ('as' NAME )? ':' block; + : 'except' '*' expression ('as' NAME)? ':' block + ; + finally_block - : 'finally' ':' block; + : 'finally' ':' block + ; // Match statement // --------------- match_stmt - : soft_kw_match subject_expr ':' NEWLINE INDENT case_block+ DEDENT; + : soft_kw_match subject_expr ':' NEWLINE INDENT case_block+ DEDENT + ; subject_expr : star_named_expression ',' star_named_expressions? - | named_expression; + | named_expression + ; case_block - : soft_kw_case patterns guard? ':' block; + : soft_kw_case patterns guard? ':' block + ; -guard: 'if' named_expression; +guard + : 'if' named_expression + ; patterns : open_sequence_pattern - | pattern; + | pattern + ; pattern : as_pattern - | or_pattern; + | or_pattern + ; as_pattern - : or_pattern 'as' pattern_capture_target; + : or_pattern 'as' pattern_capture_target + ; or_pattern - : closed_pattern ('|' closed_pattern)*; + : closed_pattern ('|' closed_pattern)* + ; closed_pattern : literal_pattern @@ -352,7 +461,8 @@ closed_pattern | group_pattern | sequence_pattern | mapping_pattern - | class_pattern; + | class_pattern + ; // Literal patterns are used for equality and identity constraints literal_pattern @@ -361,7 +471,8 @@ literal_pattern | strings | 'None' | 'True' - | 'False'; + | 'False' + ; // Literal expressions are used to restrict permitted mapping pattern keys literal_expr @@ -370,7 +481,8 @@ literal_expr | strings | 'None' | 'True' - | 'False'; + | 'False' + ; complex_number : signed_real_number ('+' | '-') imaginary_number @@ -385,50 +497,63 @@ signed_real_number ; real_number - : NUMBER; + : NUMBER + ; imaginary_number - : NUMBER; + : NUMBER + ; capture_pattern - : pattern_capture_target; + : pattern_capture_target + ; pattern_capture_target - : {self.isnotEqualCurrentTokenText("_")}? NAME; + : {self.isnotEqualCurrentTokenText("_")}? NAME + ; wildcard_pattern - : soft_kw_wildcard; + : soft_kw_wildcard + ; value_pattern - : attr; + : attr + ; attr : NAME ('.' NAME)+ ; + name_or_attr : NAME ('.' NAME)* ; group_pattern - : '(' pattern ')'; + : '(' pattern ')' + ; sequence_pattern : '[' maybe_sequence_pattern? ']' - | '(' open_sequence_pattern? ')'; + | '(' open_sequence_pattern? ')' + ; open_sequence_pattern - : maybe_star_pattern ',' maybe_sequence_pattern?; + : maybe_star_pattern ',' maybe_sequence_pattern? + ; maybe_sequence_pattern - : maybe_star_pattern (',' maybe_star_pattern)* ','?; + : maybe_star_pattern (',' maybe_star_pattern)* ','? + ; maybe_star_pattern : star_pattern - | pattern; + | pattern + ; star_pattern : '*' pattern_capture_target - | '*' wildcard_pattern; + | '*' wildcard_pattern + ; mapping_pattern : LBRACE RBRACE @@ -437,59 +562,68 @@ mapping_pattern ; items_pattern - : key_value_pattern (',' key_value_pattern)*; + : key_value_pattern (',' key_value_pattern)* + ; key_value_pattern - : (literal_expr | attr) ':' pattern; + : (literal_expr | attr) ':' pattern + ; double_star_pattern - : '**' pattern_capture_target; + : '**' pattern_capture_target + ; class_pattern : name_or_attr '(' ((positional_patterns (',' keyword_patterns)? | keyword_patterns) ','?)? ')' ; - - positional_patterns - : pattern (',' pattern)*; + : pattern (',' pattern)* + ; keyword_patterns - : keyword_pattern (',' keyword_pattern)*; + : keyword_pattern (',' keyword_pattern)* + ; keyword_pattern - : NAME '=' pattern; + : NAME '=' pattern + ; // Type statement // --------------- type_alias - : soft_kw_type NAME type_params? '=' expression; + : soft_kw_type NAME type_params? '=' expression + ; // Type parameter declaration // -------------------------- -type_params: '[' type_param_seq ']'; +type_params + : '[' type_param_seq ']' + ; -type_param_seq: type_param (',' type_param)* ','?; +type_param_seq + : type_param (',' type_param)* ','? + ; type_param : NAME type_param_bound? - | '*' NAME (':' expression)? + | '*' NAME (':' expression)? | '**' NAME (':' expression)? ; - -type_param_bound: ':' expression; +type_param_bound + : ':' expression + ; // EXPRESSIONS // ----------- expressions - : expression (',' expression )* ','? + : expression (',' expression)* ','? ; - expression : disjunction ('if' disjunction 'else' expression)? | lambdef @@ -500,38 +634,44 @@ yield_expr ; star_expressions - : star_expression (',' star_expression )* ','? + : star_expression (',' star_expression)* ','? ; - star_expression : '*' bitwise_or - | expression; + | expression + ; -star_named_expressions: star_named_expression (',' star_named_expression)* ','?; +star_named_expressions + : star_named_expression (',' star_named_expression)* ','? + ; star_named_expression : '*' bitwise_or - | named_expression; + | named_expression + ; assignment_expression - : NAME ':=' expression; + : NAME ':=' expression + ; named_expression : assignment_expression - | expression; + | expression + ; disjunction - : conjunction ('or' conjunction )* + : conjunction ('or' conjunction)* ; conjunction - : inversion ('and' inversion )* + : inversion ('and' inversion)* ; inversion : 'not' inversion - | comparison; + | comparison + ; // Comparison operators // -------------------- @@ -550,34 +690,66 @@ compare_op_bitwise_or_pair | notin_bitwise_or | in_bitwise_or | isnot_bitwise_or - | is_bitwise_or; + | is_bitwise_or + ; + +eq_bitwise_or + : '==' 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_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_or + ; + +lte_bitwise_or + : '<=' bitwise_or + ; + +lt_bitwise_or + : '<' bitwise_or + ; + +gte_bitwise_or + : '>=' bitwise_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_xor '^' bitwise_and - | bitwise_and; + | bitwise_and + ; bitwise_and : bitwise_and '&' shift_expr - | shift_expr; + | shift_expr + ; shift_expr : shift_expr ('<<' | '>>') sum @@ -597,14 +769,12 @@ term | factor ; - - - factor : '+' factor | '-' factor | '~' factor - | power; + | power + ; power : await_primary ('**' factor)? @@ -617,22 +787,23 @@ power await_primary : AWAIT primary - | primary; + | primary + ; primary : primary ('.' NAME | genexp | '(' arguments? ')' | '[' slices ']') | atom ; - - slices : slice - | (slice | starred_expression) (',' (slice | starred_expression))* ','?; + | (slice | starred_expression) (',' (slice | starred_expression))* ','? + ; slice - : expression? ':' expression? (':' expression? )? - | named_expression; + : expression? ':' expression? (':' expression?)? + | named_expression + ; atom : NAME @@ -644,19 +815,23 @@ atom | (tuple | group | genexp) | (list | listcomp) | (dict | set | dictcomp | setcomp) - | '...'; + | '...' + ; group - : '(' (yield_expr | named_expression) ')'; + : '(' (yield_expr | named_expression) ')' + ; // Lambda functions // ---------------- lambdef - : 'lambda' lambda_params? ':' expression; + : 'lambda' lambda_params? ':' expression + ; lambda_params - : lambda_parameters; + : lambda_parameters + ; // lambda_parameters etc. duplicates parameters but without annotations // or type comments, and if there's no comma after a parameter, we expect @@ -667,7 +842,8 @@ lambda_parameters | 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_star_etc + ; lambda_slash_no_default : lambda_param_no_default+ '/' ','? @@ -680,112 +856,159 @@ lambda_slash_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_kwds - : '**' lambda_param_no_default; + : '**' 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; + +lambda_param + : NAME + ; // LITERALS // ======== fstring_middle : fstring_replacement_field - | FSTRING_MIDDLE; + | FSTRING_MIDDLE + ; + fstring_replacement_field - : LBRACE (yield_expr | star_expressions) '='? fstring_conversion? fstring_full_format_spec? RBRACE; + : LBRACE (yield_expr | star_expressions) '='? fstring_conversion? fstring_full_format_spec? RBRACE + ; + fstring_conversion - : '!' NAME; + : '!' NAME + ; + fstring_full_format_spec - : ':' fstring_format_spec*; + : ':' fstring_format_spec* + ; + fstring_format_spec : FSTRING_MIDDLE - | fstring_replacement_field; + | fstring_replacement_field + ; + fstring - : FSTRING_START fstring_middle* FSTRING_END; + : FSTRING_START fstring_middle* FSTRING_END + ; -string: STRING; -strings: (fstring|string)+; +string + : STRING + ; + +strings + : (fstring | string)+ + ; list - : '[' star_named_expressions? ']'; + : '[' star_named_expressions? ']' + ; tuple - : '(' (star_named_expression ',' star_named_expressions? )? ')'; + : '(' (star_named_expression ',' star_named_expressions?)? ')' + ; -set: LBRACE star_named_expressions RBRACE; +set + : LBRACE star_named_expressions RBRACE + ; // Dicts // ----- dict - : LBRACE double_starred_kvpairs? RBRACE; + : LBRACE double_starred_kvpairs? RBRACE + ; -double_starred_kvpairs: double_starred_kvpair (',' double_starred_kvpair)* ','?; +double_starred_kvpairs + : double_starred_kvpair (',' double_starred_kvpair)* ','? + ; double_starred_kvpair : '**' bitwise_or - | kvpair; + | kvpair + ; -kvpair: expression ':' expression; +kvpair + : expression ':' expression + ; // Comprehensions & Generators // --------------------------- for_if_clauses - : for_if_clause+; + : for_if_clause+ + ; for_if_clause - : ASYNC? 'for' star_targets 'in' disjunction ('if' disjunction )* + : ASYNC? 'for' star_targets 'in' disjunction ('if' disjunction)* ; listcomp - : '[' named_expression for_if_clauses ']'; + : '[' named_expression for_if_clauses ']' + ; setcomp - : LBRACE named_expression for_if_clauses RBRACE; + : LBRACE named_expression for_if_clauses RBRACE + ; genexp - : '(' ( assignment_expression | expression) for_if_clauses ')'; + : '(' (assignment_expression | expression) for_if_clauses ')' + ; dictcomp - : LBRACE kvpair for_if_clauses RBRACE; + : LBRACE kvpair for_if_clauses RBRACE + ; // FUNCTION CALL ARGUMENTS // ======================= arguments - : args ','?; + : args ','? + ; args - : (starred_expression | ( assignment_expression | expression)) (',' (starred_expression | ( assignment_expression | expression)))* (',' kwargs )? - | kwargs; + : (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_starred (',' kwarg_or_starred)* ( + ',' kwarg_or_double_starred (',' kwarg_or_double_starred)* + )? | kwarg_or_double_starred (',' kwarg_or_double_starred)* ; starred_expression - : '*' expression; + : '*' expression + ; kwarg_or_starred : NAME '=' expression - | starred_expression; + | starred_expression + ; kwarg_or_double_starred : NAME '=' expression - | '**' expression; + | '**' expression + ; // ASSIGNMENT TARGETS // ================== @@ -795,18 +1018,21 @@ kwarg_or_double_starred // NOTE: star_targets may contain *bitwise_or, targets may not. star_targets - : star_target (',' star_target )* ','? + : star_target (',' star_target)* ','? ; -star_targets_list_seq: star_target (',' star_target)+ ','?; +star_targets_list_seq + : star_target (',' star_target)+ ','? + ; star_targets_tuple_seq - : star_target (',' | (',' star_target )+ ','?) + : star_target (',' | (',' star_target)+ ','?) ; star_target : '*' (star_target) - | target_with_star_atom; + | target_with_star_atom + ; target_with_star_atom : t_primary ('.' NAME | '[' slices ']') @@ -817,12 +1043,14 @@ star_atom : NAME | '(' target_with_star_atom ')' | '(' star_targets_tuple_seq? ')' - | '[' star_targets_list_seq? ']'; + | '[' star_targets_list_seq? ']' + ; single_target : single_subscript_attribute_target | NAME - | '(' single_target ')'; + | '(' single_target ')' + ; single_subscript_attribute_target : t_primary ('.' NAME | '[' slices ']') @@ -833,14 +1061,12 @@ t_primary | atom ; - - - - // Targets for del statements // -------------------------- -del_targets: del_target (',' del_target)* ','?; +del_targets + : del_target (',' del_target)* ','? + ; del_target : t_primary ('.' NAME | '[' slices ']') @@ -851,12 +1077,12 @@ del_t_atom : NAME | '(' del_target ')' | '(' del_targets? ')' - | '[' del_targets? ']'; + | '[' del_targets? ']' + ; // TYPING ELEMENTS // --------------- - // type_expressions allow */** but ignore them type_expressions : expression (',' expression)* (',' ('*' expression (',' '**' expression)? | '**' expression))? @@ -864,16 +1090,26 @@ type_expressions | '**' expression ; - - func_type_comment - : NEWLINE TYPE_COMMENT // Must be followed by indented block - | TYPE_COMMENT; + : NEWLINE TYPE_COMMENT // Must be followed by indented block + | TYPE_COMMENT + ; // *** Soft Keywords: https://docs.python.org/3.12/reference/lexical_analysis.html#soft-keywords -soft_kw_match : {self.isEqualCurrentTokenText("match")}? NAME; -soft_kw_case : {self.isEqualCurrentTokenText("case")}? NAME; -soft_kw_wildcard : {self.isEqualCurrentTokenText("_")}? NAME; -soft_kw_type : {self.isEqualCurrentTokenText("type")}? NAME; +soft_kw_match + : {self.isEqualCurrentTokenText("match")}? NAME + ; + +soft_kw_case + : {self.isEqualCurrentTokenText("case")}? NAME + ; + +soft_kw_wildcard + : {self.isEqualCurrentTokenText("_")}? NAME + ; + +soft_kw_type + : {self.isEqualCurrentTokenText("type")}? NAME + ; -// ========================= END OF THE GRAMMAR =========================== +// ========================= END OF THE GRAMMAR =========================== \ No newline at end of file diff --git a/qif/qifLexer.g4 b/qif/qifLexer.g4 index 37a227bb00..400084a605 100644 --- a/qif/qifLexer.g4 +++ b/qif/qifLexer.g4 @@ -29,83 +29,49 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar qifLexer; -TYPE - : '!Type:' -> pushMode (LINETEXT) - ; +TYPE: '!Type:' -> pushMode (LINETEXT); -T - : 'T' -> pushMode (LINETEXT) - ; +T: 'T' -> pushMode (LINETEXT); -C - : 'C' - ; +C: 'C'; -N - : 'N' -> pushMode (LINETEXT) - ; +N: 'N' -> pushMode (LINETEXT); -M - : 'M' -> pushMode (LINETEXT) - ; +M: 'M' -> pushMode (LINETEXT); -P - : 'P' -> pushMode (LINETEXT) - ; +P: 'P' -> pushMode (LINETEXT); -L - : 'L' -> pushMode (ACCTCATE) - ; +L: 'L' -> pushMode (ACCTCATE); -D - : 'D' -> pushMode (LINETEXT) - ; +D: 'D' -> pushMode (LINETEXT); -STATE - : ('X' | 'x' | '*') - ; +STATE: ('X' | 'x' | '*'); -EOR - : '^' - ; +EOR: '^'; -WS - : [ \r\n\t]+ -> skip - ; +WS: [ \r\n\t]+ -> skip; mode LINETEXT; -DATE - : [0-9]+ '/' [0-9]+ '/' [0-9]+ - ; +DATE: [0-9]+ '/' [0-9]+ '/' [0-9]+; -NUM - : '-'? [0-9,]+ ('.' [0-9]+)? - ; +NUM: '-'? [0-9,]+ ('.' [0-9]+)?; -TEXT - : ~ [\r\n]+ - ; +TEXT: ~ [\r\n]+; -EOL - : [\r\n]+ -> skip , popMode - ; +EOL: [\r\n]+ -> skip, popMode; mode ACCTCATE; -LB - : '[' - ; - -ACCNTCATNAME - : [a-zA-Z0-9 ]+ - ; +LB: '['; -RB - : ']' - ; +ACCNTCATNAME: [a-zA-Z0-9 ]+; -EOL2 - : [\r\n]+ -> skip , popMode - ; +RB: ']'; +EOL2: [\r\n]+ -> skip, popMode; \ No newline at end of file diff --git a/qif/qifParser.g4 b/qif/qifParser.g4 index 669d61ec5d..62b9c8478e 100644 --- a/qif/qifParser.g4 +++ b/qif/qifParser.g4 @@ -29,58 +29,64 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $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 qifParser; -options { tokenVocab = qifLexer; } +options { + tokenVocab = qifLexer; +} + qif - : record* EOF - ; + : record* EOF + ; record - : (recordtype | date | total | check | state_ | memo | payee | accountorcategory)* eor - ; + : (recordtype | date | total | check | state_ | memo | payee | accountorcategory)* eor + ; recordtype - : TYPE TEXT - ; + : TYPE TEXT + ; date - : D DATE - ; + : D DATE + ; total - : T NUM - ; + : T NUM + ; check - : N NUM - ; + : N NUM + ; state_ - : C STATE - ; + : C STATE + ; memo - : M TEXT - ; + : M TEXT + ; payee - : P TEXT - ; + : P TEXT + ; accountorcategory - : L (account | category) - ; + : L (account | category) + ; account - : LB ACCNTCATNAME RB - ; + : LB ACCNTCATNAME RB + ; category - : ACCNTCATNAME - ; + : ACCNTCATNAME + ; eor - : EOR - ; - + : EOR + ; \ No newline at end of file diff --git a/quakemap/quakemap.g4 b/quakemap/quakemap.g4 index f1c5276fb3..094177489d 100644 --- a/quakemap/quakemap.g4 +++ b/quakemap/quakemap.g4 @@ -30,60 +30,59 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar quakemap; map_ - : entity* EOF - ; + : entity* EOF + ; entity - : '{' keyvalue* brush* '}' - ; + : '{' keyvalue* brush* '}' + ; keyvalue - : string string - ; + : string string + ; brush - : '{' brushline + '}' - ; + : '{' brushline+ '}' + ; brushline - : coord* text num* - ; + : coord* text num* + ; coord - : '(' num* ')' - ; + : '(' num* ')' + ; num - : NUMBER - ; + : NUMBER + ; string - : STRING - ; + : STRING + ; text - : TEXT - ; - + : TEXT + ; TEXT - : [a-zA-Z] [a-zA-Z0-9_] + - ; - + : [a-zA-Z] [a-zA-Z0-9_]+ + ; NUMBER - : ('+' | '-')? ('0' .. '9') + ('.' ('0' .. '9') +)? - ; - + : ('+' | '-')? ('0' .. '9')+ ('.' ('0' .. '9')+)? + ; STRING - : '"' ('""' | ~ '"')* '"' - ; - + : '"' ('""' | ~ '"')* '"' + ; WS - : [ \r\n\t] + -> skip - ; + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/r/R.g4 b/r/R.g4 index d2e9fd0676..b5aa1cc2b8 100644 --- a/r/R.g4 +++ b/r/R.g4 @@ -42,12 +42,14 @@ $ javac *.java $ java TestR sample.R ... prints parse tree ... */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar R; -prog: ( expr (';'|NL)* - | NL - )* - EOF +prog + : (expr (';' | NL)* | NL)* EOF ; /* @@ -57,139 +59,164 @@ expr_or_assign ; */ -expr: expr '[[' sublist ']' ']' // '[[' follows R's yacc grammar - | expr '[' sublist ']' - | expr ('::'|':::') expr - | expr ('$'|'@') expr - | expr '^' expr - | ('-'|'+') expr - | expr ':' expr - | expr USER_OP expr // anything wrappedin %: '%' .* '%' - | expr ('*'|'/') expr - | expr ('+'|'-') expr - | expr ('>'|'>='|'<'|'<='|'=='|'!=') expr - | '!' expr - | expr ('&'|'&&') expr - | expr ('|'|'||') expr - | '~' expr - | expr '~' expr - | expr ('<-'|'<<-'|'='|'->'|'->>'|':=') expr - | 'function' '(' formlist? ')' expr // define function - | expr '(' sublist ')' // call function - | '{' exprlist '}' // compound statement - | 'if' '(' expr ')' expr - | 'if' '(' expr ')' expr 'else' expr - | 'for' '(' ID 'in' expr ')' expr - | 'while' '(' expr ')' expr - | 'repeat' expr - | '?' expr // get help on expr, usually string or ID - | 'next' - | 'break' - | '(' expr ')' - | ID - | STRING - | HEX - | INT - | FLOAT - | COMPLEX - | 'NULL' - | 'NA' - | 'Inf' - | 'NaN' - | 'TRUE' - | 'FALSE' +expr + : expr '[[' sublist ']' ']' // '[[' follows R's yacc grammar + | expr '[' sublist ']' + | expr ('::' | ':::') expr + | expr ('$' | '@') expr + | expr '^' expr + | ('-' | '+') expr + | expr ':' expr + | expr USER_OP expr // anything wrappedin %: '%' .* '%' + | expr ('*' | '/') expr + | expr ('+' | '-') expr + | expr ('>' | '>=' | '<' | '<=' | '==' | '!=') expr + | '!' expr + | expr ('&' | '&&') expr + | expr ('|' | '||') expr + | '~' expr + | expr '~' expr + | expr ('<-' | '<<-' | '=' | '->' | '->>' | ':=') expr + | 'function' '(' formlist? ')' expr // define function + | expr '(' sublist ')' // call function + | '{' exprlist '}' // compound statement + | 'if' '(' expr ')' expr + | 'if' '(' expr ')' expr 'else' expr + | 'for' '(' ID 'in' expr ')' expr + | 'while' '(' expr ')' expr + | 'repeat' expr + | '?' expr // get help on expr, usually string or ID + | 'next' + | 'break' + | '(' expr ')' + | ID + | STRING + | HEX + | INT + | FLOAT + | COMPLEX + | 'NULL' + | 'NA' + | 'Inf' + | 'NaN' + | 'TRUE' + | 'FALSE' ; exprlist - : expr ((';'|NL) expr?)* + : expr ((';' | NL) expr?)* | ; -formlist : form (',' form)* ; +formlist + : form (',' form)* + ; -form: ID - | ID '=' expr - | '...' - | '.' +form + : ID + | ID '=' expr + | '...' + | '.' ; -sublist : sub (',' sub)* ; +sublist + : sub (',' sub)* + ; -sub : expr - | ID '=' - | ID '=' expr - | STRING '=' - | STRING '=' expr - | 'NULL' '=' - | 'NULL' '=' expr - | '...' - | '.' +sub + : expr + | ID '=' + | ID '=' expr + | STRING '=' + | STRING '=' expr + | 'NULL' '=' + | 'NULL' '=' expr + | '...' + | '.' | ; -HEX : '0' ('x'|'X') HEXDIGIT+ [Ll]? ; +HEX + : '0' ('x' | 'X') HEXDIGIT+ [Ll]? + ; + +INT + : DIGIT+ [Ll]? + ; + +fragment HEXDIGIT + : ('0' ..'9' | 'a' ..'f' | 'A' ..'F') + ; -INT : DIGIT+ [Ll]? ; +FLOAT + : DIGIT+ '.' DIGIT* EXP? [Ll]? + | DIGIT+ EXP? [Ll]? + | '.' DIGIT+ EXP? [Ll]? + ; -fragment -HEXDIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ; +fragment DIGIT + : '0' ..'9' + ; -FLOAT: DIGIT+ '.' DIGIT* EXP? [Ll]? - | DIGIT+ EXP? [Ll]? - | '.' DIGIT+ EXP? [Ll]? +fragment EXP + : ('E' | 'e') ('+' | '-')? INT ; -fragment -DIGIT: '0'..'9' ; -fragment -EXP : ('E' | 'e') ('+' | '-')? INT ; COMPLEX - : INT 'i' - | FLOAT 'i' + : INT 'i' + | FLOAT 'i' ; STRING - : '"' ( ESC | ~[\\"] )*? '"' - | '\'' ( ESC | ~[\\'] )*? '\'' - | '`' ( ESC | ~[\\'] )*? '`' + : '"' (ESC | ~[\\"])*? '"' + | '\'' ( ESC | ~[\\'])*? '\'' + | '`' ( ESC | ~[\\'])*? '`' + ; + +fragment ESC + : '\\' [abtnfrv"'\\] + | UNICODE_ESCAPE + | HEX_ESCAPE + | OCTAL_ESCAPE ; -fragment -ESC : '\\' [abtnfrv"'\\] - | UNICODE_ESCAPE - | HEX_ESCAPE - | OCTAL_ESCAPE +fragment UNICODE_ESCAPE + : '\\' 'u' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT + | '\\' 'u' '{' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT '}' ; -fragment -UNICODE_ESCAPE - : '\\' 'u' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT - | '\\' 'u' '{' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT '}' +fragment OCTAL_ESCAPE + : '\\' [0-3] [0-7] [0-7] + | '\\' [0-7] [0-7] + | '\\' [0-7] ; -fragment -OCTAL_ESCAPE - : '\\' [0-3] [0-7] [0-7] - | '\\' [0-7] [0-7] - | '\\' [0-7] +fragment HEX_ESCAPE + : '\\' HEXDIGIT HEXDIGIT? ; -fragment -HEX_ESCAPE - : '\\' HEXDIGIT HEXDIGIT? +ID + : '.' (LETTER | '_' | '.') (LETTER | DIGIT | '_' | '.')* + | LETTER (LETTER | DIGIT | '_' | '.')* ; -ID : '.' (LETTER|'_'|'.') (LETTER|DIGIT|'_'|'.')* - | LETTER (LETTER|DIGIT|'_'|'.')* +fragment LETTER + : [a-zA-Z] ; - -fragment LETTER : [a-zA-Z] ; -USER_OP : '%' .*? '%' ; +USER_OP + : '%' .*? '%' + ; -COMMENT : '#' .*? '\r'? '\n' -> type(NL) ; +COMMENT + : '#' .*? '\r'? '\n' -> type(NL) + ; // Match both UNIX and Windows newlines -NL : '\r'? '\n' ; +NL + : '\r'? '\n' + ; -WS : [ \t\u000C]+ -> skip ; +WS + : [ \t\u000C]+ -> skip + ; \ No newline at end of file diff --git a/r/RFilter.g4 b/r/RFilter.g4 index 93f9edb883..00763f58e0 100644 --- a/r/RFilter.g4 +++ b/r/RFilter.g4 @@ -30,31 +30,40 @@ We strip NL inside expressions. */ +// $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 RFilter; -options { tokenVocab=R; } +options { + tokenVocab = R; +} @members { protected int curlies = 0; } // TODO: MAKE THIS GET ONE COMMAND ONLY -stream : (elem|NL|';')* EOF ; - -eat : (NL {((WritableToken)$NL).setChannel(Token.HIDDEN_CHANNEL);})+ ; - -elem: op eat? - | atom - | '{' eat? {curlies++;} (elem|NL|';')* {curlies--;} '}' - | '(' (elem|eat)* ')' - | '[' (elem|eat)* ']' - | '[[' (elem|eat)* ']' ']' - | 'function' eat? '(' (elem|eat)* ')' eat? - | 'for' eat? '(' (elem|eat)* ')' eat? - | 'while' eat? '(' (elem|eat)* ')' eat? - | 'if' eat? '(' (elem|eat)* ')' eat? - | 'else' - { +stream + : (elem | NL | ';')* EOF + ; + +eat + : (NL {((WritableToken)$NL).setChannel(Token.HIDDEN_CHANNEL);})+ + ; + +elem + : op eat? + | atom + | '{' eat? {curlies++;} (elem | NL | ';')* {curlies--;} '}' + | '(' (elem | eat)* ')' + | '[' (elem | eat)* ']' + | '[[' (elem | eat)* ']' ']' + | 'function' eat? '(' (elem | eat)* ')' eat? + | 'for' eat? '(' (elem | eat)* ')' eat? + | 'while' eat? '(' (elem | eat)* ')' eat? + | 'if' eat? '(' (elem | eat)* ')' eat? + | 'else' { // ``inside a compound expression, a newline before else is discarded, // whereas at the outermost level, the newline terminates the if // construction and a subsequent else causes a syntax error.'' @@ -79,11 +88,54 @@ elem: op eat? } ; -atom: 'next' | 'break' | ID | STRING | HEX | INT | FLOAT | COMPLEX | 'NULL' - | 'NA' | 'Inf' | 'NaN' | 'TRUE' | 'FALSE' +atom + : 'next' + | 'break' + | ID + | STRING + | HEX + | INT + | FLOAT + | COMPLEX + | 'NULL' + | 'NA' + | 'Inf' + | 'NaN' + | 'TRUE' + | 'FALSE' ; -op : '+'|'-'|'*'|'/'|'^'|'<'|'<='|'>='|'>'|'=='|'!='|'&'|'&&'|USER_OP| - 'repeat'|'in'|'?'|'!'|'='|':'|'~'|'$'|'@'|'<-'|'->'|'='|'::'|':::'| - ','|'...'|'||'| '|' - ; +op + : '+' + | '-' + | '*' + | '/' + | '^' + | '<' + | '<=' + | '>=' + | '>' + | '==' + | '!=' + | '&' + | '&&' + | USER_OP + | 'repeat' + | 'in' + | '?' + | '!' + | '=' + | ':' + | '~' + | '$' + | '@' + | '<-' + | '->' + | '=' + | '::' + | ':::' + | ',' + | '...' + | '||' + | '|' + ; \ No newline at end of file diff --git a/racket-bsl/BSL.g4 b/racket-bsl/BSL.g4 index 4cb1964aaa..0286d6074e 100644 --- a/racket-bsl/BSL.g4 +++ b/racket-bsl/BSL.g4 @@ -1,4 +1,8 @@ /* Based on documentation provided at https://docs.racket-lang.org/htdp-langs/beginner.html */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar BSL; program @@ -19,12 +23,13 @@ definition | '(' 'define-struct' name '(' name* ')' ')' ; -expr: '(' name expr+ ')' +expr + : '(' name expr+ ')' | '(' 'cond' ('[' expr expr ']')+ ')' - | '(' 'cond' ('[' expr expr ']')* '[' 'else ' expr ']' ')' - | '(' 'if' expr expr expr ')' + | '(' 'cond' ('[' expr expr ']')* '[' 'else ' expr ']' ')' + | '(' 'if' expr expr expr ')' | '(' 'and' expr expr+ ')' - | '(' 'or' expr expr+ ')' + | '(' 'or' expr expr+ ')' | '’()' | name | NUMBER @@ -49,10 +54,12 @@ libraryRequire | '(' 'require' '(' name STRING pkg ')' ')' ; -pkg: '(' STRING STRING NUMBER NUMBER ')' - ; +pkg + : '(' STRING STRING NUMBER NUMBER ')' + ; -name: SYMBOL +name + : SYMBOL | NAME ; @@ -63,7 +70,8 @@ SYMBOL // A name or a variable is a sequence of characters not including a space or one of the following: // " , ' ` ( ) [ ] { } | ; # -NAME: ([$%&!*+\\^_~]|[--:<-Za-z])+ +NAME + : ([$%&!*+\\^_~] | [--:<-Za-z])+ ; // A number is a number such as 123, 3/2, or 5.5. @@ -73,9 +81,10 @@ NUMBER | INT '/' INT ; -INT: [1-9] [0-9]* - | '0' - ; +INT + : [1-9] [0-9]* + | '0' + ; BOOLEAN : '#true' @@ -100,12 +109,14 @@ CHARACTER | '#' '\u005C' 'space' ; -LANG: '#lang' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) +LANG + : '#lang' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) ; COMMENT - : ';' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) - ; + : ';' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) + ; -WS: (' ' | '\r' | '\t' | '\u000C' | '\n') -> channel (HIDDEN) - ; +WS + : (' ' | '\r' | '\t' | '\u000C' | '\n') -> channel (HIDDEN) + ; \ No newline at end of file diff --git a/racket-isl/ISL.g4 b/racket-isl/ISL.g4 index b86ef6b244..45a53ea6aa 100644 --- a/racket-isl/ISL.g4 +++ b/racket-isl/ISL.g4 @@ -1,4 +1,8 @@ /* Based on documentation provided at https://docs.racket-lang.org/htdp-langs/intermediate-lam.html */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ISL; program @@ -18,7 +22,8 @@ definition | '(' 'define-struct' name '(' name* ')' ')' ; -expr: '(' 'begin' expr+ ')' +expr + : '(' 'begin' expr+ ')' | '(' 'begin0' expr+ ')' | '(' 'set!' NAME expr ')' | '(' 'delay' expr ')' @@ -29,13 +34,13 @@ expr: '(' 'begin' expr+ ')' | '(' 'shared' '(' ('[' name expr ']')* ')' expr ')' | '(' 'let' '(' ('[' name expr ']')* ')' expr ')' | '(' 'let*' '(' ('[' name expr ']')* ')' expr ')' - | '(' 'recur' name '(' ('[' name expr']')* ')' expr ')' + | '(' 'recur' name '(' ('[' name expr ']')* ')' expr ')' | '(' expr expr* ')' | '(' 'cond' ('[' expr expr ']')+ ')' - | '(' 'cond' ('[' expr expr ']')* '[' 'else ' expr ']' ')' - | '(' 'if' expr expr expr ')' + | '(' 'cond' ('[' expr expr ']')* '[' 'else ' expr ']' ')' + | '(' 'if' expr expr expr ')' | '(' 'and' expr expr expr+ ')' - | '(' 'or' expr expr expr+ ')' + | '(' 'or' expr expr expr+ ')' | '(' 'time' expr ')' | name | '’' quoted @@ -86,10 +91,12 @@ libraryRequire | '(' 'require' '(' name STRING pkg ')' ')' ; -pkg: '(' STRING STRING NUMBER NUMBER ')' - ; +pkg + : '(' STRING STRING NUMBER NUMBER ')' + ; -name: SYMBOL +name + : SYMBOL | NAME ; @@ -100,7 +107,8 @@ SYMBOL // A name or a variable is a sequence of characters not including a space or one of the following: // " , ' ` ( ) [ ] { } | ; # -NAME: ([$%&!*+\\^_~] | [--:<-Za-z])+ +NAME + : ([$%&!*+\\^_~] | [--:<-Za-z])+ ; // A number is a number such as 123, 3/2, or 5.5. @@ -110,9 +118,10 @@ NUMBER | INT '/' INT ; -INT: [1-9] [0-9]* - | '0' - ; +INT + : [1-9] [0-9]* + | '0' + ; BOOLEAN : '#true' @@ -137,12 +146,14 @@ CHARACTER | '#' '\u005C' 'space' ; -LANG: '#lang' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) +LANG + : '#lang' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) ; COMMENT : ';' ~ ('\n' | '\r')* '\r'? '\n' -> channel (HIDDEN) ; -WS: (' ' | '\r' | '\t' | '\u000C' | '\n') -> channel (HIDDEN) - ; +WS + : (' ' | '\r' | '\t' | '\u000C' | '\n') -> channel (HIDDEN) + ; \ No newline at end of file diff --git a/rcs/RCS.g4 b/rcs/RCS.g4 index 9ccee28b39..8cb4309234 100644 --- a/rcs/RCS.g4 +++ b/rcs/RCS.g4 @@ -1,4 +1,3 @@ - /* * The Apache Software License, Version 1.1 * @@ -58,247 +57,226 @@ //---------------------------------------------------------------------------- // The JRCS parser //---------------------------------------------------------------------------- + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar RCS; rcstext - : admin deltalist desc deltatextlist EOF - ; + : admin deltalist desc deltatextlist EOF + ; rcsheader - : admin - ; + : admin + ; rcsrevisions - : admin deltalist - ; + : admin deltalist + ; admin - : head ( branch )? access symbols ( locks )? ( strict )? ( comment )? ( expand )? ( newphrase )* - ; + : head (branch)? access symbols (locks)? (strict)? (comment)? (expand)? (newphrase)* + ; head - : LITERAL_HEAD REVISION SEMI - ; + : LITERAL_HEAD REVISION SEMI + ; branch - : LITERAL_BRANCH REVISION SEMI - ; + : LITERAL_BRANCH REVISION SEMI + ; access - : LITERAL_ACCESS ( IDENT )* SEMI - ; + : LITERAL_ACCESS (IDENT)* SEMI + ; symbols - : LITERAL_SYMBOLS ( tags )* SEMI - ; + : LITERAL_SYMBOLS (tags)* SEMI + ; tags - : IDENT COLON REVISION - ; + : IDENT COLON REVISION + ; locks - : LITERAL_LOCKS ( IDENT )* SEMI - ; + : LITERAL_LOCKS (IDENT)* SEMI + ; strict - : LITERAL_STRICT SEMI - ; + : LITERAL_STRICT SEMI + ; comment - : LITERAL_COMMENT ( STRING )? SEMI - ; + : LITERAL_COMMENT (STRING)? SEMI + ; expand - : LITERAL_EXPAND ( STRING )? SEMI - ; + : LITERAL_EXPAND (STRING)? SEMI + ; deltalist - : ( delta )* - ; + : (delta)* + ; delta - : REVISION delta_date delta_author delta_state delta_branches delta_next ( newphrase )* - ; + : REVISION delta_date delta_author delta_state delta_branches delta_next (newphrase)* + ; delta_date - : LITERAL_DATE REVISION SEMI - ; + : LITERAL_DATE REVISION SEMI + ; delta_author - : LITERAL_AUTHOR IDENT SEMI - ; + : LITERAL_AUTHOR IDENT SEMI + ; delta_state - : LITERAL_STATE IDENT SEMI - ; + : LITERAL_STATE IDENT SEMI + ; delta_branches - : LITERAL_BRANCHES ( REVISION )* SEMI - ; + : LITERAL_BRANCHES (REVISION)* SEMI + ; delta_next - : LITERAL_NEXT ( REVISION )? SEMI - ; + : LITERAL_NEXT (REVISION)? SEMI + ; desc - : LITERAL_DESC STRING - ; + : LITERAL_DESC STRING + ; deltatextlist - : ( deltatext )* - ; + : (deltatext)* + ; deltatext - : REVISION deltatext_log ( newphrase )* deltatext_text - ; + : REVISION deltatext_log (newphrase)* deltatext_text + ; deltatext_log - : LITERAL_LOG STRING - ; + : LITERAL_LOG STRING + ; deltatext_text - : LITERAL_TEXT STRING - ; + : LITERAL_TEXT STRING + ; newphrase - : ( IDENT )+ SEMI - ; - + : (IDENT)+ SEMI + ; COMMA - : 'COMMA' - ; - + : 'COMMA' + ; LOGS - : 'LOGS' - ; - + : 'LOGS' + ; ADMIN - : 'ADMIN' - ; - + : 'ADMIN' + ; DELTAS - : 'DELTAS' - ; - + : 'DELTAS' + ; LITERAL_HEAD - : 'head' - ; - + : 'head' + ; LITERAL_BRANCH - : 'branch' - ; - + : 'branch' + ; LITERAL_ACCESS - : 'access' - ; - + : 'access' + ; LITERAL_SYMBOLS - : 'symbols' - ; - + : 'symbols' + ; LITERAL_LOCKS - : 'locks' - ; - + : 'locks' + ; LITERAL_STRICT - : 'strict' - ; - + : 'strict' + ; LITERAL_COMMENT - : 'comment' - ; - + : 'comment' + ; LITERAL_EXPAND - : 'expand' - ; - + : 'expand' + ; LITERAL_DATE - : 'date' - ; - + : 'date' + ; LITERAL_AUTHOR - : 'author' - ; - + : 'author' + ; LITERAL_STATE - : 'state' - ; - + : 'state' + ; LITERAL_BRANCHES - : 'branches' - ; - + : 'branches' + ; LITERAL_NEXT - : 'next' - ; - + : 'next' + ; LITERAL_DESC - : 'desc' - ; - + : 'desc' + ; LITERAL_LOG - : 'log' - ; - + : 'log' + ; LITERAL_TEXT - : 'text' - ; + : 'text' + ; // an identifier. Note that testLiterals is set to true! This means // that after we match the rule, we look in the literals table to see // if it's a literal or really an identifer IDENT - : ( ~ ( '$' | ',' | '.' | ':' | ';' | '@' | ' ' | '\t' | '\n' | '\r' | '\f' ) )+ - ; - + : (~ ( '$' | ',' | '.' | ':' | ';' | '@' | ' ' | '\t' | '\n' | '\r' | '\f'))+ + ; INT - : ( '0' .. '9' )+ - ; - + : ('0' .. '9')+ + ; REVISION - : INT ( '.' INT )* - ; - - + : INT ('.' INT)* + ; STRING - : '@' (~[@] | '@@')* '@'; - + : '@' (~[@] | '@@')* '@' + ; SEMI - : ';' - ; - + : ';' + ; COLON - : ':' - ; + : ':' + ; // Whitespace -- ignored WS - : ( ' ' | '\t' | '\f' | ( '\r\n' | '\r' | '\n' ) )+ -> skip - ; + : (' ' | '\t' | '\f' | ( '\r\n' | '\r' | '\n'))+ -> skip + ; \ No newline at end of file diff --git a/recfile/recfile.g4 b/recfile/recfile.g4 index f021792827..dd57053a2a 100644 --- a/recfile/recfile.g4 +++ b/recfile/recfile.g4 @@ -29,45 +29,48 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar recfile; file_ - : line* EOF - ; + : line* EOF + ; line - : (descriptor | record)? EOL - ; + : (descriptor | record)? EOL + ; descriptor - : '%' key ':' (EOL '+')? value - ; + : '%' key ':' (EOL '+')? value + ; record - : key ':' (EOL '+')? value - ; + : key ':' (EOL '+')? value + ; key - : STRING - ; + : STRING + ; value - : STRING - ; + : STRING + ; STRING - : [a-zA-Z0-9'.] [a-zA-Z0-9_ '.]* - ; + : [a-zA-Z0-9'.] [a-zA-Z0-9_ '.]* + ; EOL - : [\r\n]+ - ; + : [\r\n]+ + ; COMMENT - : '#' ~ [\r\n]+ -> skip - ; + : '#' ~ [\r\n]+ -> skip + ; WS - : [ \t]+ -> skip - ; - + : [ \t]+ -> skip + ; \ No newline at end of file diff --git a/redcode/redcode.g4 b/redcode/redcode.g4 index ce9082e5a6..7741eef2d9 100644 --- a/redcode/redcode.g4 +++ b/redcode/redcode.g4 @@ -26,196 +26,172 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar redcode; file_ - : line + EOF - ; + : line+ EOF + ; line - : (comment | instruction) EOL - ; + : (comment | instruction) EOL + ; instruction - : opcode ('.' modifier)? mmode? number (',' mmode? number)? comment? - ; + : opcode ('.' modifier)? mmode? number (',' mmode? number)? comment? + ; opcode - : DAT - | MOV - | ADD - | SUB - | MUL - | DIV - | MOD - | JMP - | JMZ - | JMN - | DJN - | CMP - | SLT - | SPL - | ORG - | DJZ - ; + : DAT + | MOV + | ADD + | SUB + | MUL + | DIV + | MOD + | JMP + | JMZ + | JMN + | DJN + | CMP + | SLT + | SPL + | ORG + | DJZ + ; modifier - : A - | B - | AB - | BA - | F - | X - | I - ; + : A + | B + | AB + | BA + | F + | X + | I + ; mmode - : '#' - | '$' - | '@' - | '<' - | '>' - ; + : '#' + | '$' + | '@' + | '<' + | '>' + ; number - : ('+' | '-')? NUMBER - ; + : ('+' | '-')? NUMBER + ; comment - : COMMENT - ; - + : COMMENT + ; A - : 'A' - ; - + : 'A' + ; B - : 'B' - ; - + : 'B' + ; AB - : 'AB' - ; - + : 'AB' + ; BA - : 'BA' - ; - + : 'BA' + ; F - : 'F' - ; - + : 'F' + ; X - : 'X' - ; - + : 'X' + ; I - : 'I' - ; - + : 'I' + ; DAT - : 'DAT' - ; - + : 'DAT' + ; MOV - : 'MOV' - ; - + : 'MOV' + ; ADD - : 'ADD' - ; - + : 'ADD' + ; SUB - : 'SUB' - ; - + : 'SUB' + ; MUL - : 'MUL' - ; - + : 'MUL' + ; DIV - : 'DIV' - ; - + : 'DIV' + ; MOD - : 'MOD' - ; - + : 'MOD' + ; JMP - : 'JMP' - ; - + : 'JMP' + ; JMZ - : 'JMZ' - ; - + : 'JMZ' + ; JMN - : 'JMN' - ; - + : 'JMN' + ; DJN - : 'DJN' - ; - + : 'DJN' + ; CMP - : 'CMP' - ; - + : 'CMP' + ; SLT - : 'SLT' - ; - + : 'SLT' + ; DJZ - : 'DJZ' - ; - + : 'DJZ' + ; SPL - : 'SPL' - ; - + : 'SPL' + ; ORG - : 'ORG' - ; - + : 'ORG' + ; NUMBER - : [0-9] + - ; - + : [0-9]+ + ; COMMENT - : ';' ~ [\r\n]* - ; - + : ';' ~ [\r\n]* + ; EOL - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/refal/refal.g4 b/refal/refal.g4 index 131d30b54c..6abb2677f9 100644 --- a/refal/refal.g4 +++ b/refal/refal.g4 @@ -29,145 +29,150 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar refal; -file_ : program EOF; +file_ + : program EOF + ; program - : f_definition (';'? program)? - | external_decl ';' program - | program external_decl ';' - ; + : f_definition (';'? program)? + | external_decl ';' program + | program external_decl ';' + ; f_definition - : '$ENTRY'? f_name '{' block_ '}' - ; + : '$ENTRY'? f_name '{' block_ '}' + ; external_decl - : ('$EXTERNAL' | '$EXTERN' | '$EXTRN') f_name_list - ; + : ('$EXTERNAL' | '$EXTERN' | '$EXTRN') f_name_list + ; f_name_list - : f_name (',' f_name_list ';')? - ; + : f_name (',' f_name_list ';')? + ; f_name - : identifier - ; + : identifier + ; block_ - : sentence (';' block_?)? - ; + : sentence (';' block_?)? + ; sentence - : left_side conditions ('=' right_side | ',' block_ending) - ; + : left_side conditions ('=' right_side | ',' block_ending) + ; left_side - : pattern - ; + : pattern + ; conditions - : (',' arg_ ':' pattern conditions)? - ; + : (',' arg_ ':' pattern conditions)? + ; pattern - : expression_ - ; + : expression_ + ; arg_ - : expression_ - ; + : expression_ + ; right_side - : expression_ - ; + : expression_ + ; expression_ - : (term_ expression_)? - ; + : (term_ expression_)? + ; term_ - : symbol - | variable - | '<' expression_ '>' - ; + : symbol + | variable + | '<' expression_ '>' + ; block_ending - : arg_ ':' '{' block_ '}' - ; + : arg_ ':' '{' block_ '}' + ; symbol - : identifier - | DIGITS - | STRING - | STRING2 - | CHAR - ; + : identifier + | DIGITS + | STRING + | STRING2 + | CHAR + ; identifier - : IDENTIFER - | STRING - ; + : IDENTIFER + | STRING + ; variable - : svar - | tvar - | evar - ; + : svar + | tvar + | evar + ; svar - : 's' '.' index - ; + : 's' '.' index + ; tvar - : 't' '.' index - ; + : 't' '.' index + ; evar - : 'e' '.' index - ; + : 'e' '.' index + ; index - : identifier - | DIGITS - ; + : identifier + | DIGITS + ; DIGITS - : [0-9]+ - ; + : [0-9]+ + ; IDENTIFER - : [a-zA-Z] [a-zA-Z0-9_-]* - ; + : [a-zA-Z] [a-zA-Z0-9_-]* + ; STRING - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; STRING2 - : '\'' ~ '\''* '\'' - ; + : '\'' ~ '\''* '\'' + ; CHAR - : '\\\'' - | '\\"' - | '\\\\' - | '\\n' - | '\\r' - | '\\t' - | '\\x' [0-9] [0-9] - ; + : '\\\'' + | '\\"' + | '\\\\' + | '\\n' + | '\\r' + | '\\t' + | '\\x' [0-9] [0-9] + ; LINE_COMMENT - : '*' ~ [\r\n]* -> skip - ; + : '*' ~ [\r\n]* -> skip + ; BLOCK_COMMENT - : '/*' .*? '*/' -> skip - ; + : '/*' .*? '*/' -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/rego/RegoLexer.g4 b/rego/RegoLexer.g4 index cdafad5ba7..f07d916fdb 100644 --- a/rego/RegoLexer.g4 +++ b/rego/RegoLexer.g4 @@ -5,245 +5,138 @@ Copyright Arroyo Networks 2019 Authors: Josh Marshall */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true lexer grammar RegoLexer; -channels { COMMENTS_AND_FORMATTING } - +channels { + COMMENTS_AND_FORMATTING +} /*<1>*/ -Comment - : [^\\] '#' [^\r\n]* -> Channel(COMMENTS_AND_FORMATTING) - ; +Comment: [^\\] '#' [^\r\n]* -> Channel(COMMENTS_AND_FORMATTING); -fragment -DoubleQuote - : '"' - ; +fragment DoubleQuote: '"'; -fragment -BackTick - : '`' - ; +fragment BackTick: '`'; -fragment -QuotedString - : DoubleQuote Char* DoubleQuote - ; +fragment QuotedString: DoubleQuote Char* DoubleQuote; -fragment -RawString - : BackTick ~[`]* BackTick - ; +fragment RawString: BackTick ~[`]* BackTick; /*<2>*/ -String - : QuotedString - | RawString - ; +String: QuotedString | RawString; /*Antlr doesn't support the '{4}' syntax.*/ -fragment -UnicodeEscape - : 'u' [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F] - ; +fragment UnicodeEscape: 'u' [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]; /*<3>*/ -Bool - : 'true' | 'false' - ; +Bool: 'true' | 'false'; /*<4>*/ -Null - : 'null' - ; +Null: 'null'; /*<5>*/ -As - : 'as' - ; +As: 'as'; /*<6>*/ -Default - : 'default' - ; +Default: 'default'; /*<7>*/ -Else - : 'else' - ; +Else: 'else'; /*<8>*/ -Import - : 'import' - ; +Import: 'import'; /*<9>*/ -Package - : 'package' - ; +Package: 'package'; /*<10>*/ -Not - : 'not' - ; +Not: 'not'; /*<11>*/ -With - : 'with' - ; +With: 'with'; /*<12>*/ -Set - : 'set(' - ; +Set: 'set('; /*<13>*/ -LSBrace - : '[' - ; +LSBrace: '['; /*<14>*/ -LCBrace - : '{' - ; +LCBrace: '{'; /*<15>*/ -LParan - : '(' - ; +LParan: '('; /*<16>*/ -RSBrace - : ']' - ; +RSBrace: ']'; /*<17>*/ -RCBrace - : '}' - ; +RCBrace: '}'; /*<18>*/ -RParan - : ')' - ; +RParan: ')'; /*<19>*/ -Mid - : '|' - ; +Mid: '|'; /*<20>*/ -FactorOperator - : '*' - | '/' - | '%' - ; +FactorOperator: '*' | '/' | '%'; -fragment -Plus - : '+' - ; +fragment Plus: '+'; -fragment -Minus - : '-' - ; +fragment Minus: '-'; /*<21>*/ -ArithOperator - : Plus - | Minus - ; +ArithOperator: Plus | Minus; /*<22>*/ -RelationOperator - : '==' - | '!=' - | '<=' - | '>=' - | '>' - | '<' - ; +RelationOperator: '==' | '!=' | '<=' | '>=' | '>' | '<'; /*<23>*/ -EqOper - : ':=' - | '=' - ; +EqOper: ':=' | '='; /*<24>*/ -Comma - : ',' - ; +Comma: ','; /*<25>*/ -Semicolon - : ';' - ; +Semicolon: ';'; /*<26>*/ -Colon - : ':' - ; +Colon: ':'; /*<27>*/ -Ampersand - : '&' - ; +Ampersand: '&'; /*<28>*/ -Dot - : '.' - ; +Dot: '.'; /*<29>*/ -WhiteSpace - : [ \t] -> Channel(COMMENTS_AND_FORMATTING) - ; +WhiteSpace: [ \t] -> Channel(COMMENTS_AND_FORMATTING); /*<30>*/ -LineEnd - : [\n] -> Channel(COMMENTS_AND_FORMATTING) - ; +LineEnd: [\n] -> Channel(COMMENTS_AND_FORMATTING); /*<31>*/ -WindowsLineEnd - : [\r] -> skip - ; +WindowsLineEnd: [\r] -> skip; /*****************************************************************************/ -fragment -E - : 'e' | 'E' - ; +fragment E: 'e' | 'E'; -fragment -Real - : (DecimalDigit* '.' DecimalDigit+ | DecimalDigit+ '.'?) - ; +fragment Real: (DecimalDigit* '.' DecimalDigit+ | DecimalDigit+ '.'?); /*<32>*/ -UnsignedNumber - : Real (E (Plus | Minus)? Real)? - ; +UnsignedNumber: Real (E (Plus | Minus)? Real)?; -fragment -AsciiLetter - : [A-Za-z_] - ; +fragment AsciiLetter: [A-Za-z_]; -fragment -DecimalDigit - : [0-9] - ; +fragment DecimalDigit: [0-9]; -fragment -Char - : ~[\u0000-\u001f"\\] - | '\\' EscapeSequence - ; +fragment Char: ~[\u0000-\u001f"\\] | '\\' EscapeSequence; /* fragment @@ -252,23 +145,11 @@ MyEscapedChar ; */ -fragment -EscapeSequence - : SingleCharEscape - | UnicodeEscape - ; +fragment EscapeSequence: SingleCharEscape | UnicodeEscape; -fragment -SingleCharEscape - : [\\/bfnrt] - | DoubleQuote - | BackTick - ; +fragment SingleCharEscape: [\\/bfnrt] | DoubleQuote | BackTick; /*****************************************************************************/ - /*<33>*/ -Name - : AsciiLetter (AsciiLetter | DecimalDigit)* - ; \ No newline at end of file +Name: AsciiLetter (AsciiLetter | DecimalDigit)*; \ No newline at end of file diff --git a/rego/RegoParser.g4 b/rego/RegoParser.g4 index 507c2dca9b..3c2b998040 100644 --- a/rego/RegoParser.g4 +++ b/rego/RegoParser.g4 @@ -5,211 +5,214 @@ Copyright Arroyo Networks 2019 Authors: Josh Marshall */ -parser grammar RegoParser; - -options { tokenVocab=RegoLexer; } +// $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 RegoParser; +options { + tokenVocab = RegoLexer; +} /*****************************************************************************/ /* Rules */ -root - : stmt* EOF - ; +root + : stmt* EOF + ; stmt - : regoPackage - | importDirective - | regoRules - | regoBody - ; + : regoPackage + | importDirective + | regoRules + | regoBody + ; /*****************************************************************************/ regoPackage - : Package ref - ; + : Package ref + ; /*****************************************************************************/ importDirective - : Import import_target=ref ( As import_target_rename_as=ref )? - ; + : Import import_target = ref (As import_target_rename_as = ref)? + ; /*****************************************************************************/ -regoRules - : Default Name EqOper term - | ruleHead ruleBody* - ; +regoRules + : Default Name EqOper term + | ruleHead ruleBody* + ; -ruleHead - : Name ( LParan exprTermList? RParan )? ( LSBrace exprTerm RSBrace )? ( EqOper exprTerm )? - ; +ruleHead + : Name (LParan exprTermList? RParan)? (LSBrace exprTerm RSBrace)? (EqOper exprTerm)? + ; ruleBody - : ( Else (EqOper exprTerm)? )? nonEmptyBraceEnclosedBody - ; + : (Else (EqOper exprTerm)?)? nonEmptyBraceEnclosedBody + ; -ruleExt - : regoElse - | nonEmptyBraceEnclosedBody - ; +ruleExt + : regoElse + | nonEmptyBraceEnclosedBody + ; -regoElse - : Else EqOper term nonEmptyBraceEnclosedBody - | Else nonEmptyBraceEnclosedBody - ; +regoElse + : Else EqOper term nonEmptyBraceEnclosedBody + | Else nonEmptyBraceEnclosedBody + ; /*****************************************************************************/ -regoBody - : query - | nonEmptyBraceEnclosedBody - ; +regoBody + : query + | nonEmptyBraceEnclosedBody + ; -nonEmptyBraceEnclosedBody - : LCBrace query RCBrace - ; +nonEmptyBraceEnclosedBody + : LCBrace query RCBrace + ; query - : literal ( Semicolon? literal )* - ; + : literal (Semicolon? literal)* + ; -literal - : Not? literalExpr withKeyword* - ; +literal + : Not? literalExpr withKeyword* + ; -literalExpr - : exprTerm (EqOper exprTerm)* - ; +literalExpr + : exprTerm (EqOper exprTerm)* + ; -withKeyword - : With exprTerm As exprTerm - ; +withKeyword + : With exprTerm As exprTerm + ; functionCall - : ref LParan exprTermList? RParan - ; + : ref LParan exprTermList? RParan + ; /*****************************************************************************/ -exprTermPair - : exprTerm Colon exprTerm - ; +exprTermPair + : exprTerm Colon exprTerm + ; -termPair - : term Colon term - ; +termPair + : term Colon term + ; -exprTermPairList - : exprTermPair ( Comma exprTermPair )* - ; +exprTermPairList + : exprTermPair (Comma exprTermPair)* + ; /*****************************************************************************/ -exprTerm - : relationExpr ( RelationOperator relationExpr )* - ; - -exprTermList - : exprTerm ( Comma exprTerm )* - ; - -relationExpr - : bitwiseOrExpr ( Mid bitwiseOrExpr )* - ; - -bitwiseOrExpr - : bitwiseAndExpr ( Ampersand bitwiseAndExpr )* - ; - -bitwiseAndExpr - : arithExpr ( ArithOperator arithExpr )* - ; - -arithExpr - : factorExpr ( FactorOperator factorExpr )* - ; - -factorExpr - : LParan exprTerm RParan - | term - ; - -term - : arrayComprehension - | objectComprehension - | setComprehension - | object_ - | array_ - | set_ - | ArithOperator? scalar - | functionCall - | Not? ref - ; +exprTerm + : relationExpr (RelationOperator relationExpr)* + ; + +exprTermList + : exprTerm (Comma exprTerm)* + ; + +relationExpr + : bitwiseOrExpr (Mid bitwiseOrExpr)* + ; + +bitwiseOrExpr + : bitwiseAndExpr (Ampersand bitwiseAndExpr)* + ; + +bitwiseAndExpr + : arithExpr (ArithOperator arithExpr)* + ; + +arithExpr + : factorExpr (FactorOperator factorExpr)* + ; + +factorExpr + : LParan exprTerm RParan + | term + ; + +term + : arrayComprehension + | objectComprehension + | setComprehension + | object_ + | array_ + | set_ + | ArithOperator? scalar + | functionCall + | Not? ref + ; /*****************************************************************************/ -arrayComprehension - : LSBrace term Mid query RSBrace - ; +arrayComprehension + : LSBrace term Mid query RSBrace + ; -setComprehension - : LCBrace term Mid query RCBrace - ; +setComprehension + : LCBrace term Mid query RCBrace + ; -objectComprehension - : LCBrace termPair Mid query RCBrace - ; +objectComprehension + : LCBrace termPair Mid query RCBrace + ; -object_ - : LCBrace ( objectItem ( Comma objectItem )* Comma? )? RCBrace - ; +object_ + : LCBrace (objectItem ( Comma objectItem)* Comma?)? RCBrace + ; objectItem - : ( scalar | ref ) Colon term - ; + : (scalar | ref) Colon term + ; -array_ - : LSBrace exprTermList? RSBrace - ; +array_ + : LSBrace exprTermList? RSBrace + ; -set_ - : emptySet - | nonEmptySet - ; +set_ + : emptySet + | nonEmptySet + ; emptySet - : Set RParan - ; + : Set RParan + ; nonEmptySet - : LCBrace exprTermList RCBrace - ; + : LCBrace exprTermList RCBrace + ; -ref - : Name refOperand* - ; +ref + : Name refOperand* + ; -refOperand - : refOperandDot - | refOperandCanonical - ; +refOperand + : refOperandDot + | refOperandCanonical + ; /*Allow an exprTerm here for more dynamic lookups?*/ -refOperandDot - : Dot Name - ; - -refOperandCanonical - : LSBrace exprTerm RSBrace - ; - -scalar - : UnsignedNumber - | String - | Bool - | Null - ; \ No newline at end of file +refOperandDot + : Dot Name + ; + +refOperandCanonical + : LSBrace exprTerm RSBrace + ; + +scalar + : UnsignedNumber + | String + | Bool + | Null + ; \ No newline at end of file diff --git a/restructuredtext/ReStructuredText.g4 b/restructuredtext/ReStructuredText.g4 index 6ab3963d2c..4741d04ac7 100644 --- a/restructuredtext/ReStructuredText.g4 +++ b/restructuredtext/ReStructuredText.g4 @@ -1,3 +1,6 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ReStructuredText; // Copyright (C) 2011 Bart Kiers @@ -27,445 +30,450 @@ grammar ReStructuredText; */ parse - : (element | empty_line)+? EOF - ; + : (element | empty_line)+? EOF + ; element - : section | sectionElement - ; - + : section + | sectionElement + ; + sectionElement - : listItemBullet | listItemEnumerated | paragraph | lineBlock | comment - ; + : listItemBullet + | listItemEnumerated + | paragraph + | lineBlock + | comment + ; comment - : Space* Comment Space* (commentLineNoBreak commentParagraphs?)? - ; - + : Space* Comment Space* (commentLineNoBreak commentParagraphs?)? + ; + commentParagraphs - : main=commentParagraph commentRest - ; + : main = commentParagraph commentRest + ; commentRest - : (empty_line commentParagraph)* - ; + : (empty_line commentParagraph)* + ; commentParagraph - : commentLine+ - ; + : commentLine+ + ; commentLineNoBreak - : commentLineAtoms - ; + : commentLineAtoms + ; commentLine - : LineBreak Space Space Space commentLineNoBreak - ; + : LineBreak Space Space Space commentLineNoBreak + ; commentLineAtoms - : ~(LineBreak)+ - ; + : ~(LineBreak)+ + ; paragraph - : lines - ; + : lines + ; section - : (LineBreak overline=SectionSeparator)? title LineBreak? SectionSeparator (LineBreak)* sectionElement* - ; + : (LineBreak overline = SectionSeparator)? title LineBreak? SectionSeparator (LineBreak)* sectionElement* + ; title - : LineBreak textStart - | LineBreak lineSpecial Space+ (paragraphNoBreak)? - | lineNormal - | lineStar - ; + : LineBreak textStart + | LineBreak lineSpecial Space+ (paragraphNoBreak)? + | lineNormal + | lineStar + ; lineBlock - : LineBreak lineBlockLine LineBreak? lineBlockLine* - ; + : LineBreak lineBlockLine LineBreak? lineBlockLine* + ; lineBlockLine - : Block Space indentation? span*? starText - | Block Space indentation? span+ - ; + : Block Space indentation? span*? starText + | Block Space indentation? span+ + ; listItemBullet - : bulletCrossLine - | bulletSimple - | LineBreak Space* special=(Minus | Plus) - ; + : bulletCrossLine + | bulletSimple + | LineBreak Space* special = (Minus | Plus) + ; bulletCrossLine - : LineBreak Space* bullet Space* (paragraph+)? - ; + : LineBreak Space* bullet Space* (paragraph+)? + ; -bulletSimple - : LineBreak Space* bullet Space+ paragraphNoBreak paragraph* - ; +bulletSimple + : LineBreak Space* bullet Space+ paragraphNoBreak paragraph* + ; bullet - : Star - | Minus - | Plus - ; + : Star + | Minus + | Plus + ; listItemEnumerated - : LineBreak enumerated=lineSpecial Space+ (paragraphNoBreak paragraph*)? - ; - + : LineBreak enumerated = lineSpecial Space+ (paragraphNoBreak paragraph*)? + ; + paragraphNoBreak - : lineNoBreak lines* - ; + : lineNoBreak lines* + ; lineNoBreak - : indentation? spanLineStartNoStar span*? - ; - + : indentation? spanLineStartNoStar span*? + ; + lines - : linesStar - | linesNormal - ; + : linesStar + | linesNormal + ; linesNormal - : lineNormal (linesStar | linesNormal?) - ; - + : lineNormal (linesStar | linesNormal?) + ; + linesStar - : lineStar - | lineStar lineNoBreak linesNormal?? - | lineStar lineNoBreak linesStar - ; + : lineStar + | lineStar lineNoBreak linesNormal?? + | lineStar lineNoBreak linesStar + ; lineNormal - : LineBreak indentation? spanLineStartNoStar+? (span*? spanNoStar+?)? - | lineSpecial - ; - + : LineBreak indentation? spanLineStartNoStar+? (span*? spanNoStar+?)? + | lineSpecial + ; + lineStar - : LineBreak indentation? spanLineStartNoStar*? starText - | LineBreak indentation? text_fragment+ starText - ; - + : LineBreak indentation? spanLineStartNoStar*? starText + | LineBreak indentation? text_fragment+ starText + ; + lineSpecial - : Numbers Dot - | LineBreak indentation? Numbers - | LineBreak indentation? SectionSeparator (Space+ SectionSeparator) Space* // for table. - //| Alphabet Dot - ; - + : Numbers Dot + | LineBreak indentation? Numbers + | LineBreak indentation? SectionSeparator (Space+ SectionSeparator) Space* // for table. + //| Alphabet Dot + ; + empty_line - : LineBreak Space* - ; + : LineBreak Space* + ; indentation - : Space+ - ; + : Space+ + ; spanLineStartNoStar - : reference - | referenceIn - | hyperlinkTarget - | hyperlink - | hyperlinkDoc - | backTickText - | quotedLiteral - | textLineStart - ; + : reference + | referenceIn + | hyperlinkTarget + | hyperlink + | hyperlinkDoc + | backTickText + | quotedLiteral + | textLineStart + ; textLineStart - : lineStart_fragment+ text_fragment* - ; - + : lineStart_fragment+ text_fragment* + ; + lineStart_fragment - : (Minus ~(Space | LineBreak | Star)) - | (Plus ~(Space | Star)) - | (Numbers Dot ~(Space | LineBreak | Star)) - | (Numbers ~(Dot | LineBreak | Star)) - //| (Alphabet Dot ~(Space | LineBreak | Star)) - | (Alphabet Dot) - | (Block ~(Space | Star)) - | (UnderScore ~(Space | Star)) - | (Alphabet ~(Dot | LineBreak | Star)) - | Alphabet - | separator separator - | TimeStar - | SquareLeft - | SquareRight - | RoundLeft - | RoundRight - | SemiColon - | Colon - | QuotationDouble - | QuotationSingle - | Dot - | UnderScore - | AngleLeft - | AngleRight - | Any - ; - + : (Minus ~(Space | LineBreak | Star)) + | (Plus ~(Space | Star)) + | (Numbers Dot ~(Space | LineBreak | Star)) + | (Numbers ~(Dot | LineBreak | Star)) + //| (Alphabet Dot ~(Space | LineBreak | Star)) + | (Alphabet Dot) + | (Block ~(Space | Star)) + | (UnderScore ~(Space | Star)) + | (Alphabet ~(Dot | LineBreak | Star)) + | Alphabet + | separator separator + | TimeStar + | SquareLeft + | SquareRight + | RoundLeft + | RoundRight + | SemiColon + | Colon + | QuotationDouble + | QuotationSingle + | Dot + | UnderScore + | AngleLeft + | AngleRight + | Any + ; + text - : textStart+ text_fragment* - ; + : textStart+ text_fragment* + ; textStart - : forcedText - | lineStart_fragment - | text_fragment_start text_fragment_start+ - | Space - ; - -forcedText - : RoundLeft Star RoundRight - | SquareLeft Star SquareRight - | QuotationSingle Star QuotationSingle - | QuotationSingle QuotationDouble Star QuotationDouble QuotationSingle - ; + : forcedText + | lineStart_fragment + | text_fragment_start text_fragment_start+ + | Space + ; + +forcedText + : RoundLeft Star RoundRight + | SquareLeft Star SquareRight + | QuotationSingle Star QuotationSingle + | QuotationSingle QuotationDouble Star QuotationDouble QuotationSingle + ; spanNoStar - : reference - | referenceIn - | hyperlinkTarget - | hyperlink - | hyperlinkDoc - | backTickText - | quotedLiteral - | text - ; + : reference + | referenceIn + | hyperlinkTarget + | hyperlink + | hyperlinkDoc + | backTickText + | quotedLiteral + | text + ; span - : starText - | spanNoStar - ; + : starText + | spanNoStar + ; quotedLiteral - : AngleRight Space lineNoBreak - ; + : AngleRight Space lineNoBreak + ; text_fragment_start - : SemiColon - | Numbers - | Alphabet - | Space - | SquareLeft - | SquareRight - | RoundLeft - | RoundRight - | Colon - | separator - | AngleLeft - | AngleRight - | QuotationDouble - | Dot - | Star Space - | Any - ; + : SemiColon + | Numbers + | Alphabet + | Space + | SquareLeft + | SquareRight + | RoundLeft + | RoundRight + | Colon + | separator + | AngleLeft + | AngleRight + | QuotationDouble + | Dot + | Star Space + | Any + ; text_fragment - : text_fragment_start - | forcedText - | Block - | Literal - | Comment - | Dot - | Quote - ; + : text_fragment_start + | forcedText + | Block + | Literal + | Comment + | Dot + | Quote + ; starText - : Star+ LineBreak - | Star+ starNoSpace starAtoms (LineBreak Star* starNoSpace starAtoms)* Star* LineBreak - | Star+ starNoSpace starAtoms Star* LineBreak - | Star+ Space+ starAtoms Star+ LineBreak - ; + : Star+ LineBreak + | Star+ starNoSpace starAtoms (LineBreak Star* starNoSpace starAtoms)* Star* LineBreak + | Star+ starNoSpace starAtoms Star* LineBreak + | Star+ Space+ starAtoms Star+ LineBreak + ; starAtoms - : starAtom* (Star* starAtom)* - ; + : starAtom* (Star* starAtom)* + ; starNoSpace - : ~(Star | LineBreak | Space | SectionSeparator) - ; + : ~(Star | LineBreak | Space | SectionSeparator) + ; starAtom - : ~(Star | LineBreak) - ; + : ~(Star | LineBreak) + ; backTickText - : (Colon titled=Alphabet Colon)? body UnderScore? - ; + : (Colon titled = Alphabet Colon)? body UnderScore? + ; body - : BackTick BackTick* backTickAtoms BackTick+ - | BackTick backTickNoSpace backTickAtoms BackTick+ - | BackTick BackTick - ; + : BackTick BackTick* backTickAtoms BackTick+ + | BackTick backTickNoSpace backTickAtoms BackTick+ + | BackTick BackTick + ; backTickAtoms - : backTickAtom+ - ; + : backTickAtom+ + ; backTickNoSpace - : ~(BackTick | LineBreak | Space) - ; + : ~(BackTick | LineBreak | Space) + ; backTickAtom - : ~(BackTick | LineBreak) - | BackTick ~(BackTick | LineBreak) - ; + : ~(BackTick | LineBreak) + | BackTick ~(BackTick | LineBreak) + ; reference - : Any+ UnderScore - ; + : Any+ UnderScore + ; referenceIn - : UnderScore hyperlinkAtom+ Colon Space url - ; + : UnderScore hyperlinkAtom+ Colon Space url + ; hyperlinkTarget - : UnderScore Any+ - ; - + : UnderScore Any+ + ; + hyperlink - : BackTick hyperlinkAtom+ Space AngleLeft url AngleRight BackTick UnderScore Space - ; - + : BackTick hyperlinkAtom+ Space AngleLeft url AngleRight BackTick UnderScore Space + ; + hyperlinkDoc - : ':doc:' BackTick hyperlinkAtom+ Space AngleLeft url AngleRight BackTick - | ':doc:' BackTick url BackTick - ; + : ':doc:' BackTick hyperlinkAtom+ Space AngleLeft url AngleRight BackTick + | ':doc:' BackTick url BackTick + ; url - : urlAtom+ - ; - + : urlAtom+ + ; + urlAtom - : ~( LineBreak | BackTick ) - ; - + : ~(LineBreak | BackTick) + ; + hyperlinkAtom - : ~( LineBreak | AngleLeft | AngleRight | BackTick | Star ) - ; + : ~(LineBreak | AngleLeft | AngleRight | BackTick | Star) + ; separator - : (Minus | Equal | Plus | Hat) - ; + : (Minus | Equal | Plus | Hat) + ; SectionSeparator - : (Minus | Equal | Plus | Hat) (Minus | Equal | Plus | Hat) (Minus | Equal | Plus | Hat)+ - ; + : (Minus | Equal | Plus | Hat) (Minus | Equal | Plus | Hat) (Minus | Equal | Plus | Hat)+ + ; Literal - : Colon LineBreak LineBreak* Colon Colon - ; + : Colon LineBreak LineBreak* Colon Colon + ; TimeStar - : Numbers Star - | 'x' Star - ; + : Numbers Star + | 'x' Star + ; Alphabet - : [A-Za-z]+ - ; - + : [A-Za-z]+ + ; + Numbers - : [0-9]+ - ; + : [0-9]+ + ; Quote - : Colon Colon - ; + : Colon Colon + ; SquareLeft - : '[' - ; + : '[' + ; SquareRight - : ']' - ; + : ']' + ; RoundLeft - : '(' - ; - + : '(' + ; + RoundRight - : ')' - ; - + : ')' + ; + AngleLeft - : '<' - ; + : '<' + ; AngleRight - : '>' - ; + : '>' + ; Hat - : '^' - ; - + : '^' + ; + QuotationDouble - : '"' - ; + : '"' + ; QuotationSingle - : '\'' - ; + : '\'' + ; Dot - : '.' - ; - + : '.' + ; + SemiColon - : ';' - ; - + : ';' + ; + Colon - : ':' - ; + : ':' + ; Equal - : '=' - ; + : '=' + ; Plus - : '+' - ; + : '+' + ; Minus - : '-' - ; + : '-' + ; Block - : '|' - ; + : '|' + ; Comment - : ('.. ' LineBreak?) - | ('..' LineBreak) - ; + : ('.. ' LineBreak?) + | ('..' LineBreak) + ; UnderScore - : '_' - ; + : '_' + ; BackTick - : '`' - ; + : '`' + ; Star - : '*' - ; + : '*' + ; Space - : ' ' - | '\t' - ; + : ' ' + | '\t' + ; LineBreak - : '\r'? '\n' - ; + : '\r'? '\n' + ; Any - : . - ; \ No newline at end of file + : . + ; \ No newline at end of file diff --git a/rexx/RexxLexer.g4 b/rexx/RexxLexer.g4 index f8db1714aa..c6bc3cc17a 100644 --- a/rexx/RexxLexer.g4 +++ b/rexx/RexxLexer.g4 @@ -1,366 +1,337 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar RexxLexer; // Main rules // %INCLUDE statement -STMT_INCLUDE : Include_Statement ; +STMT_INCLUDE: Include_Statement; // Skippable stuff -LINE_COMMENT : Line_Comment_ - -> channel(HIDDEN); -BLOCK_COMMENT : Block_Comment_ - -> channel(HIDDEN); -WHITESPACES : Whitespaces_ -> channel(HIDDEN); -CONTINUATION : Continue_ -> channel(HIDDEN); +LINE_COMMENT : Line_Comment_ -> channel(HIDDEN); +BLOCK_COMMENT : Block_Comment_ -> channel(HIDDEN); +WHITESPACES : Whitespaces_ -> channel(HIDDEN); +CONTINUATION : Continue_ -> channel(HIDDEN); // Keywords -KWD_ADDRESS : A D D R E S S ; -KWD_ARG : A R G ; -KWD_BY : B Y ; -KWD_CALL : C A L L ; -KWD_DIGITS : D I G I T S ; -KWD_DO : D O ; -KWD_DROP : D R O P ; -KWD_ELSE : E L S E ; -KWD_END : E N D ; -KWD_ENGINEERING : E N G I N E E R I N G ; -KWD_ERROR : E R R O R ; -KWD_EXIT : E X I T ; -KWD_EXPOSE : E X P O S E ; -KWD_EXTERNAL : E X T E R N A L ; -KWD_FAILURE : F A I L U R E ; -KWD_FOR : F O R ; -KWD_FOREVER : F O R E V E R ; -KWD_FORM : F O R M ; -KWD_FUZZ : F U Z Z ; -KWD_HALT : H A L T ; -KWD_IF : I F ; -KWD_INTERPRET : I N T E R P R E T ; -KWD_ITERATE : I T E R A T E ; -KWD_LEAVE : L E A V E ; -KWD_NAME : N A M E ; -KWD_NOP : N O P ; -KWD_NOVALUE : N O V A L U E ; -KWD_NUMERIC : N U M E R I C ; -KWD_OFF : O F F ; -KWD_ON : O N ; -KWD_OPTIONS : O P T I O N S ; -KWD_OTHERWISE : O T H E R W I S E ; -KWD_PARSE : P A R S E ; -KWD_PROCEDURE : P R O C E D U R E ; -KWD_PULL : P U L L ; -KWD_PUSH : P U S H ; -KWD_QUEUE : Q U E U E ; -KWD_RETURN : R E T U R N ; -KWD_SAY : S A Y ; -KWD_SCIENTIFIC : S C I E N T I F I C ; -KWD_SELECT : S E L E C T ; -KWD_SIGNAL : S I G N A L ; -KWD_SOURCE : S O U R C E ; -KWD_SYNTAX : S Y N T A X ; -KWD_THEN : T H E N ; -KWD_TO : T O ; -KWD_TRACE : T R A C E ; -KWD_UNTIL : U N T I L ; -KWD_UPPER : U P P E R ; -KWD_VALUE : V A L U E ; -KWD_VAR : V A R ; -KWD_VERSION : V E R S I O N ; -KWD_WHEN : W H E N ; -KWD_WHILE : W H I L E ; -KWD_WITH : W I T H ; +KWD_ADDRESS : A D D R E S S; +KWD_ARG : A R G; +KWD_BY : B Y; +KWD_CALL : C A L L; +KWD_DIGITS : D I G I T S; +KWD_DO : D O; +KWD_DROP : D R O P; +KWD_ELSE : E L S E; +KWD_END : E N D; +KWD_ENGINEERING : E N G I N E E R I N G; +KWD_ERROR : E R R O R; +KWD_EXIT : E X I T; +KWD_EXPOSE : E X P O S E; +KWD_EXTERNAL : E X T E R N A L; +KWD_FAILURE : F A I L U R E; +KWD_FOR : F O R; +KWD_FOREVER : F O R E V E R; +KWD_FORM : F O R M; +KWD_FUZZ : F U Z Z; +KWD_HALT : H A L T; +KWD_IF : I F; +KWD_INTERPRET : I N T E R P R E T; +KWD_ITERATE : I T E R A T E; +KWD_LEAVE : L E A V E; +KWD_NAME : N A M E; +KWD_NOP : N O P; +KWD_NOVALUE : N O V A L U E; +KWD_NUMERIC : N U M E R I C; +KWD_OFF : O F F; +KWD_ON : O N; +KWD_OPTIONS : O P T I O N S; +KWD_OTHERWISE : O T H E R W I S E; +KWD_PARSE : P A R S E; +KWD_PROCEDURE : P R O C E D U R E; +KWD_PULL : P U L L; +KWD_PUSH : P U S H; +KWD_QUEUE : Q U E U E; +KWD_RETURN : R E T U R N; +KWD_SAY : S A Y; +KWD_SCIENTIFIC : S C I E N T I F I C; +KWD_SELECT : S E L E C T; +KWD_SIGNAL : S I G N A L; +KWD_SOURCE : S O U R C E; +KWD_SYNTAX : S Y N T A X; +KWD_THEN : T H E N; +KWD_TO : T O; +KWD_TRACE : T R A C E; +KWD_UNTIL : U N T I L; +KWD_UPPER : U P P E R; +KWD_VALUE : V A L U E; +KWD_VAR : V A R; +KWD_VERSION : V E R S I O N; +KWD_WHEN : W H E N; +KWD_WHILE : W H I L E; +KWD_WITH : W I T H; // Brackets -BR_O : Br_O_ ; -BR_C : Br_C_ ; +BR_O : Br_O_; +BR_C : Br_C_; // Special variables: RC, RESULT, SIGL -SPECIAL_VAR : R C - | R E S U L T - | S I G L - ; +SPECIAL_VAR: R C | R E S U L T | S I G L; // Label, const, var, number -NUMBER : Number_ ; -CONST_SYMBOL : Const_symbol_ ; -VAR_SYMBOL : Var_Symbol_ ; +NUMBER : Number_; +CONST_SYMBOL : Const_symbol_; +VAR_SYMBOL : Var_Symbol_; // String and concatenation -BINARY_STRING : Binary_string_ ; -HEX_STRING : Hex_string_ ; -STRING : String_ ; +BINARY_STRING : Binary_string_; +HEX_STRING : Hex_string_; +STRING : String_; // In concatenation don't need the blanks - will be precoeesed by WHITESPACES -CONCAT : VBar_ VBar_ ; +CONCAT: VBar_ VBar_; // Operations // Assignment (also comparison and template operator) -EQ : Eq_ ; +EQ: Eq_; // Math: +, -, *, /, //, %, ** // Note: '+' and '-' are also used in prefix expressions and templates -PLUS : Plus_ ; -MINUS : Minus_ ; -MUL : Asterisk_ ; -DIV : Slash_ ; -QUOTINENT : Percent_sign_ ; -REMAINDER : Slash_ Slash_ ; -POW : Asterisk_ Asterisk_ ; +PLUS : Plus_; +MINUS : Minus_; +MUL : Asterisk_; +DIV : Slash_; +QUOTINENT : Percent_sign_; +REMAINDER : Slash_ Slash_; +POW : Asterisk_ Asterisk_; // Logical: NOT, OR, AND, XOR // Note: '\\' also used for prefix expressions -NOT : Not_ ; -OR : VBar_ ; -XOR : Amp_ Amp_ ; -AND : Amp_ ; +NOT : Not_; +OR : VBar_; +XOR : Amp_ Amp_; +AND : Amp_; // Comparison // Strict comparison: ==, \==, >>, <<, >>=, <<=, \>>, \<< -CMPS_Eq : Eq_ Eq_ ; -CMPS_Neq : Not_ Eq_ Eq_ ; -CMPS_M : More_ More_ ; -CMPS_L : Less_ Less_ ; -CMPS_MEq : More_ More_ Eq_ ; -CMPS_LEq : Less_ Less_ Eq_ ; -CMPS_NM : Not_ More_ More_ ; -CMPS_NL : Not_ Less_ Less_ ; +CMPS_Eq : Eq_ Eq_; +CMPS_Neq : Not_ Eq_ Eq_; +CMPS_M : More_ More_; +CMPS_L : Less_ Less_; +CMPS_MEq : More_ More_ Eq_; +CMPS_LEq : Less_ Less_ Eq_; +CMPS_NM : Not_ More_ More_; +CMPS_NL : Not_ Less_ Less_; // Non-strict: =, \=, <>, ><, >, <, >=, <=, \>, \< // Note: '=' is taken from Assignment (EQ) -CMP_NEq : Not_ Eq_ ; -CMP_LM : Less_ More_ ; -CMP_ML : More_ Less_ ; -CMP_M : More_ ; -CMP_L : Less_ ; -CMP_MEq : More_ Eq_ ; -CMP_LEq : Less_ Eq_ ; -CMP_NM : Not_ More_ ; -CMP_NL : Not_ Less_ ; +CMP_NEq : Not_ Eq_; +CMP_LM : Less_ More_; +CMP_ML : More_ Less_; +CMP_M : More_; +CMP_L : Less_; +CMP_MEq : More_ Eq_; +CMP_LEq : Less_ Eq_; +CMP_NM : Not_ More_; +CMP_NL : Not_ Less_; // Additional elements // . -STOP : Stop_ ; +STOP: Stop_; // , -COMMA : Comma_ ; +COMMA: Comma_; // : -COLON : Colon_ ; +COLON: Colon_; // End of line -EOL : Eol_ ; +EOL: Eol_; // Semicolumn -SEMICOL : Scol_ ; +SEMICOL: Scol_; // -------------------------------------------------------- // Fragments // Comments // Include statement - need to account for this -fragment Include_Statement : Comment_S Bo? - Percent_sign_ I N C L U D E - Bo Var_Symbol_+ Bo? - Comment_E - ; +fragment Include_Statement: + Comment_S Bo? Percent_sign_ I N C L U D E Bo Var_Symbol_+ Bo? Comment_E +; // Line comment - no EOL allowed inside. -fragment Line_Comment_ : Comment_S - Line_Commentpart*? - Asterisk_*? - ( Comment_E | EOF ) - ; -fragment Line_Commentpart : Line_Comment_ - | Slash_ Line_Comment_ - | Slash_ ~[*\n\r]+? - | Asterisk_ ~[/\n\r]+? - | ~[/*\n\r]+ - ; -fragment Block_Comment_ : Comment_S - Block_Commentpart*? - Asterisk_*? - ( Comment_E | EOF ) - ; -fragment Block_Commentpart : Block_Comment_ - | Slash_ Block_Comment_ - | Slash_ ~[*]+? - | Asterisk_ ~[/]+? - | ~[/*]+ - ; -fragment Comment_E : Asterisk_ Slash_ ; -fragment Comment_S : Slash_ Asterisk_ ; +fragment Line_Comment_: Comment_S Line_Commentpart*? Asterisk_*? ( Comment_E | EOF); +fragment Line_Commentpart: + Line_Comment_ + | Slash_ Line_Comment_ + | Slash_ ~[*\n\r]+? + | Asterisk_ ~[/\n\r]+? + | ~[/*\n\r]+ +; +fragment Block_Comment_: Comment_S Block_Commentpart*? Asterisk_*? ( Comment_E | EOF); +fragment Block_Commentpart: + Block_Comment_ + | Slash_ Block_Comment_ + | Slash_ ~[*]+? + | Asterisk_ ~[/]+? + | ~[/*]+ +; +fragment Comment_E : Asterisk_ Slash_; +fragment Comment_S : Slash_ Asterisk_; // Whitespaces -fragment Whitespaces_ : Blank+ ; +fragment Whitespaces_: Blank+; // Continuation - full comments, but no EOL between -fragment Continue_ : Comma_ - ( Block_Comment_ | Line_Comment_ | Blank )*? - Eol_; -fragment Eol_ : New_Line_ Caret_Return_ - | Caret_Return_ New_Line_ - | New_Line_ - | Caret_Return_ - ; +fragment Continue_ : Comma_ ( Block_Comment_ | Line_Comment_ | Blank)*? Eol_; +fragment Eol_ : New_Line_ Caret_Return_ | Caret_Return_ New_Line_ | New_Line_ | Caret_Return_; // Whitespaces -fragment Bo : Blank+ ; -fragment Blank : Space_ - | Other_blank_character - ; -fragment Other_blank_character : Form_Feed_ - | HTab_ - | VTab_ - ; +fragment Bo : Blank+; +fragment Blank : Space_ | Other_blank_character; +fragment Other_blank_character : Form_Feed_ | HTab_ | VTab_; // Label, const, var, number // Label, var -fragment Var_Symbol_ : General_letter Var_symbol_char*; -fragment Var_symbol_char : General_letter - | Digit_ - | Stop_ - ; -fragment General_letter : Underscore_ - | Exclamation_mark_ - | Question_mark_ - | A - | B - | C - | D - | E - | F - | G - | H - | I - | J - | K - | L - | M - | N - | O - | P - | Q - | R - | S - | T - | U - | V - | W - | X - | Y - | Z - | Extra_letter - ; -fragment Extra_letter : Hash_ - | At_ - | Dollar_ - ; +fragment Var_Symbol_ : General_letter Var_symbol_char*; +fragment Var_symbol_char : General_letter | Digit_ | Stop_; +fragment General_letter: + Underscore_ + | Exclamation_mark_ + | Question_mark_ + | A + | B + | C + | D + | E + | F + | G + | H + | I + | J + | K + | L + | M + | N + | O + | P + | Q + | R + | S + | T + | U + | V + | W + | X + | Y + | Z + | Extra_letter +; +fragment Extra_letter: Hash_ | At_ | Dollar_; // Const -fragment Const_symbol_ : ( Digit_ | Stop_ ) Var_symbol_char* ; -fragment Digit_ : [0-9] ; +fragment Const_symbol_ : ( Digit_ | Stop_) Var_symbol_char*; +fragment Digit_ : [0-9]; // Number -fragment Number_ : Plain_number Exponent_? ; -fragment Plain_number : Digit_+ Stop_? Digit_* - | Stop_ Digit_+ - ; -fragment Exponent_ : E ( Plus_ | Minus_ )? Digit_+ ; +fragment Number_ : Plain_number Exponent_?; +fragment Plain_number : Digit_+ Stop_? Digit_* | Stop_ Digit_+; +fragment Exponent_ : E ( Plus_ | Minus_)? Digit_+; // String and concatenation -fragment String_ : Quoted_string ; -fragment Binary_string_ : Quote_ Binary_string_value_ Quote_ B - | Apostrophe_ Binary_string_value_ Apostrophe_ B - ; -fragment Binary_string_value_ : Binary_digit_? Binary_digit_? Binary_digit_? Binary_digit_ (' '* Binary_digit_ Binary_digit_ Binary_digit_ Binary_digit_)* ; -fragment Binary_digit_ : [0-1] ; -fragment Hex_string_ : Quote_ Hex_string_value_ Quote_ X - | Apostrophe_ Hex_string_value_ Apostrophe_ X - ; -fragment Hex_string_value_ : Hex_digit_? Hex_digit_ (' '* Hex_digit_ Hex_digit_)* ; -fragment Hex_digit_ : Digit_ | A | B | C | D | E | F ; -fragment Quoted_string : Quotation_mark_string - | Apostrophe_string - ; -fragment Quotation_mark_string : Quote_ (String_char | Embedded_quotation_mark | Apostrophe_)* Quote_ ; -fragment Embedded_quotation_mark: Quote_ Quote_ ; -fragment Apostrophe_string : Apostrophe_ (String_char | Embedded_apostrophe | Quote_)* Apostrophe_ ; -fragment Embedded_apostrophe : Apostrophe_ Apostrophe_ ; -fragment String_char : String_or_comment_char | Asterisk_ | Slash_ ; -fragment String_or_comment_char : Digit_ - | Stop_ - | Special - | Operator_only - | General_letter - | Blank - | Other_character - ; -fragment Special : Comma_ - | Colon_ - | Scol_ - | Br_C_ - | Br_O_ - ; -fragment Operator_only : Plus_ - | Minus_ - | Percent_sign_ - | VBar_ - | Amp_ - | Eq_ - | Not_ - | More_ - | Less_ - ; -fragment Other_character : ~["'\n\r*/] ; -fragment Not_ : Backslash_ - | Other_negator - ; -fragment Other_negator : Caret_ - | Logical_Not_ - | Slash_ - ; +fragment String_: Quoted_string; +fragment Binary_string_: + Quote_ Binary_string_value_ Quote_ B + | Apostrophe_ Binary_string_value_ Apostrophe_ B +; +fragment Binary_string_value_: + Binary_digit_? Binary_digit_? Binary_digit_? Binary_digit_ ( + ' '* Binary_digit_ Binary_digit_ Binary_digit_ Binary_digit_ + )* +; +fragment Binary_digit_: [0-1]; +fragment Hex_string_: + Quote_ Hex_string_value_ Quote_ X + | Apostrophe_ Hex_string_value_ Apostrophe_ X +; +fragment Hex_string_value_ : Hex_digit_? Hex_digit_ (' '* Hex_digit_ Hex_digit_)*; +fragment Hex_digit_ : Digit_ | A | B | C | D | E | F; +fragment Quoted_string : Quotation_mark_string | Apostrophe_string; +fragment Quotation_mark_string: + Quote_ (String_char | Embedded_quotation_mark | Apostrophe_)* Quote_ +; +fragment Embedded_quotation_mark : Quote_ Quote_; +fragment Apostrophe_string : Apostrophe_ (String_char | Embedded_apostrophe | Quote_)* Apostrophe_; +fragment Embedded_apostrophe : Apostrophe_ Apostrophe_; +fragment String_char : String_or_comment_char | Asterisk_ | Slash_; +fragment String_or_comment_char: + Digit_ + | Stop_ + | Special + | Operator_only + | General_letter + | Blank + | Other_character +; +fragment Special: Comma_ | Colon_ | Scol_ | Br_C_ | Br_O_; +fragment Operator_only: + Plus_ + | Minus_ + | Percent_sign_ + | VBar_ + | Amp_ + | Eq_ + | Not_ + | More_ + | Less_ +; +fragment Other_character : ~["'\n\r*/]; +fragment Not_ : Backslash_ | Other_negator; +fragment Other_negator : Caret_ | Logical_Not_ | Slash_; // Single characters -fragment Stop_ : '.' ; -fragment Comma_ : ',' ; -fragment Colon_ : ':' ; -fragment Scol_ : ';' ; -fragment Eq_ : '=' ; -fragment Plus_ : '+' ; -fragment Minus_ : '-' ; -fragment Caret_ : '^' ; -fragment Logical_Not_ : '¬' ; -fragment Underscore_ : '_' ; -fragment Exclamation_mark_ : '!' ; -fragment Question_mark_ : '?' ; -fragment Br_O_ : '(' ; -fragment Br_C_ : ')' ; -fragment Space_ : ' ' ; -fragment Form_Feed_ : '\f' ; -fragment HTab_ : '\t' ; -fragment VTab_ : '\u000b' ; -fragment Caret_Return_ : '\r' ; -fragment New_Line_ : '\n' ; -fragment Quote_ : '"' ; -fragment Apostrophe_ : '\'' ; -fragment Slash_ : '/' ; -fragment Backslash_ : '\\' ; -fragment Asterisk_ : '*' ; -fragment More_ : '>' ; -fragment Less_ : '<' ; -fragment Percent_sign_ : '%' ; -fragment VBar_ : '|' ; -fragment Amp_ : '&' ; -fragment Hash_ : '#' ; -fragment At_ : '@' ; -fragment Dollar_ : '$' ; +fragment Stop_ : '.'; +fragment Comma_ : ','; +fragment Colon_ : ':'; +fragment Scol_ : ';'; +fragment Eq_ : '='; +fragment Plus_ : '+'; +fragment Minus_ : '-'; +fragment Caret_ : '^'; +fragment Logical_Not_ : '¬'; +fragment Underscore_ : '_'; +fragment Exclamation_mark_ : '!'; +fragment Question_mark_ : '?'; +fragment Br_O_ : '('; +fragment Br_C_ : ')'; +fragment Space_ : ' '; +fragment Form_Feed_ : '\f'; +fragment HTab_ : '\t'; +fragment VTab_ : '\u000b'; +fragment Caret_Return_ : '\r'; +fragment New_Line_ : '\n'; +fragment Quote_ : '"'; +fragment Apostrophe_ : '\''; +fragment Slash_ : '/'; +fragment Backslash_ : '\\'; +fragment Asterisk_ : '*'; +fragment More_ : '>'; +fragment Less_ : '<'; +fragment Percent_sign_ : '%'; +fragment VBar_ : '|'; +fragment Amp_ : '&'; +fragment Hash_ : '#'; +fragment At_ : '@'; +fragment Dollar_ : '$'; // Letters -fragment A : ('a'|'A'); -fragment B : ('b'|'B'); -fragment C : ('c'|'C'); -fragment D : ('d'|'D'); -fragment E : ('e'|'E'); -fragment F : ('f'|'F'); -fragment G : ('g'|'G'); -fragment H : ('h'|'H'); -fragment I : ('i'|'I'); -fragment J : ('j'|'J'); -fragment K : ('k'|'K'); -fragment L : ('l'|'L'); -fragment M : ('m'|'M'); -fragment N : ('n'|'N'); -fragment O : ('o'|'O'); -fragment P : ('p'|'P'); -fragment Q : ('q'|'Q'); -fragment R : ('r'|'R'); -fragment S : ('s'|'S'); -fragment T : ('t'|'T'); -fragment U : ('u'|'U'); -fragment V : ('v'|'V'); -fragment W : ('w'|'W'); -fragment X : ('x'|'X'); -fragment Y : ('y'|'Y'); -fragment Z : ('z'|'Z'); +fragment A : ('a' | 'A'); +fragment B : ('b' | 'B'); +fragment C : ('c' | 'C'); +fragment D : ('d' | 'D'); +fragment E : ('e' | 'E'); +fragment F : ('f' | 'F'); +fragment G : ('g' | 'G'); +fragment H : ('h' | 'H'); +fragment I : ('i' | 'I'); +fragment J : ('j' | 'J'); +fragment K : ('k' | 'K'); +fragment L : ('l' | 'L'); +fragment M : ('m' | 'M'); +fragment N : ('n' | 'N'); +fragment O : ('o' | 'O'); +fragment P : ('p' | 'P'); +fragment Q : ('q' | 'Q'); +fragment R : ('r' | 'R'); +fragment S : ('s' | 'S'); +fragment T : ('t' | 'T'); +fragment U : ('u' | 'U'); +fragment V : ('v' | 'V'); +fragment W : ('w' | 'W'); +fragment X : ('x' | 'X'); +fragment Y : ('y' | 'Y'); +fragment Z : ('z' | 'Z'); // Unsupported characters -UNSUPPORTED_CHARACTER : . ; +UNSUPPORTED_CHARACTER: .; \ No newline at end of file diff --git a/rexx/RexxParser.g4 b/rexx/RexxParser.g4 index eec877a47f..650ff73155 100644 --- a/rexx/RexxParser.g4 +++ b/rexx/RexxParser.g4 @@ -1,275 +1,522 @@ +// $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 RexxParser; options { - superClass=RexxParserBase; - tokenVocab=RexxLexer; + superClass = RexxParserBase; + tokenVocab = RexxLexer; } -file_ : program_ EOF ; - -program_ : ncl? instruction_list? ; - ncl : null_clause+ ; - null_clause : delim+ label_list? - | label_list - | include_statement - ; - delim : SEMICOL - | EOL - ; - label_list : ( label COLON delim* )+ ; - label : VAR_SYMBOL - | CONST_SYMBOL - | NUMBER - ; - include_statement : STMT_INCLUDE ; - instruction_list : instruction+ ; - instruction : group_ - | single_instruction ncl? - ; -single_instruction : assignment - | keyword_instruction - | command_ - ; - assignment : ( VAR_SYMBOL | SPECIAL_VAR | CONST_SYMBOL ) EQ expression? ; - keyword_instruction : address_ - | arg_ - | call_ - | drop_ - | exit_ - | interpret_ - | iterate_ - | leave_ - | nop_ - | numeric_ - | options_ - | parse_ - | procedure_ - | pull_ - | push_ - | queue_ - | return_ - | say_ - | signal_ - | trace_ - | upper_ - ; - command_ : expression ; -group_ : do_ - | if_ - | select_ - ; -do_ : KWD_DO do_rep? do_cond? ncl - instruction_list? - KWD_END var_symbol? ncl? ; - do_rep : assignment do_cnt? - | KWD_FOREVER - | expression - ; - do_cnt : dot dob? dof? - | dot dof? dob? - | dob dot? dof? - | dob dof? dot? - | dof dot? dob? - | dof dob? dot? - ; - dot : KWD_TO expression ; - dob : KWD_BY expression ; - dof : KWD_FOR expression ; - do_cond : KWD_WHILE expression - | KWD_UNTIL expression - ; - if_ : KWD_IF expression delim* then_ (delim+ else_)? ; - then_ : KWD_THEN ncl? instruction ; - else_ : KWD_ELSE ncl? instruction ; - select_ : KWD_SELECT delim+ select_body KWD_END ncl? ; - select_body : when_+ otherwise_? ; - when_ : KWD_WHEN expression delim* then_ ; - otherwise_ : KWD_OTHERWISE delim* instruction_list? ; +file_ + : program_ EOF + ; + +program_ + : ncl? instruction_list? + ; + +ncl + : null_clause+ + ; + +null_clause + : delim+ label_list? + | label_list + | include_statement + ; + +delim + : SEMICOL + | EOL + ; + +label_list + : (label COLON delim*)+ + ; + +label + : VAR_SYMBOL + | CONST_SYMBOL + | NUMBER + ; + +include_statement + : STMT_INCLUDE + ; + +instruction_list + : instruction+ + ; + +instruction + : group_ + | single_instruction ncl? + ; + +single_instruction + : assignment + | keyword_instruction + | command_ + ; + +assignment + : (VAR_SYMBOL | SPECIAL_VAR | CONST_SYMBOL) EQ expression? + ; + +keyword_instruction + : address_ + | arg_ + | call_ + | drop_ + | exit_ + | interpret_ + | iterate_ + | leave_ + | nop_ + | numeric_ + | options_ + | parse_ + | procedure_ + | pull_ + | push_ + | queue_ + | return_ + | say_ + | signal_ + | trace_ + | upper_ + ; + +command_ + : expression + ; + +group_ + : do_ + | if_ + | select_ + ; + +do_ + : KWD_DO do_rep? do_cond? ncl instruction_list? KWD_END var_symbol? ncl? + ; + +do_rep + : assignment do_cnt? + | KWD_FOREVER + | expression + ; + +do_cnt + : dot dob? dof? + | dot dof? dob? + | dob dot? dof? + | dob dof? dot? + | dof dot? dob? + | dof dob? dot? + ; + +dot + : KWD_TO expression + ; + +dob + : KWD_BY expression + ; + +dof + : KWD_FOR expression + ; + +do_cond + : KWD_WHILE expression + | KWD_UNTIL expression + ; + +if_ + : KWD_IF expression delim* then_ (delim+ else_)? + ; + +then_ + : KWD_THEN ncl? instruction + ; + +else_ + : KWD_ELSE ncl? instruction + ; + +select_ + : KWD_SELECT delim+ select_body KWD_END ncl? + ; + +select_body + : when_+ otherwise_? + ; + +when_ + : KWD_WHEN expression delim* then_ + ; + +otherwise_ + : KWD_OTHERWISE delim* instruction_list? + ; /* Note: The next part concentrates on the instructions. It leaves unspecified the various forms of symbol, template and expression. */ -address_ : KWD_ADDRESS - ( taken_constant expression? | valueexp )? - ; - taken_constant : symbol - | STRING - ; - valueexp : KWD_VALUE expression ; -arg_ : KWD_ARG template_list? ; -call_ : KWD_CALL ( callon_spec | function_name call_parms? ) ; - callon_spec : KWD_ON callable_condition ( KWD_NAME function_name )? - | KWD_OFF callable_condition - ; - callable_condition : KWD_ERROR - | KWD_FAILURE - | KWD_HALT - ; - call_parms : BR_O expression_list? BR_C - | expression_list - ; - expression_list : COMMA* expression - ( COMMA+ expression )* ; -drop_ : KWD_DROP variable_list ; - variable_list : ( vref | var_symbol )+ ; - vref : BR_O var_symbol BR_C ; - var_symbol : VAR_SYMBOL - | SPECIAL_VAR - ; -exit_ : KWD_EXIT expression? ; -interpret_ : KWD_INTERPRET expression ; -iterate_ : KWD_ITERATE var_symbol? ; -leave_ : KWD_LEAVE var_symbol? ; -nop_ : KWD_NOP ; -numeric_ : KWD_NUMERIC ( numeric_digits | numeric_form | numeric_fuzz ) ; - numeric_digits : KWD_DIGITS expression? ; - numeric_form : KWD_FORM - ( KWD_ENGINEERING - | KWD_SCIENTIFIC - | valueexp - | expression - )? - ; - numeric_fuzz : KWD_FUZZ expression? ; -options_ : KWD_OPTIONS expression ; -parse_ : KWD_PARSE KWD_UPPER? parse_type template_list? ; - parse_type : parse_key - | parse_value - | parse_var - ; - parse_key : KWD_ARG - | KWD_EXTERNAL - | KWD_NUMERIC - | KWD_PULL - | KWD_SOURCE - | KWD_VERSION - ; - parse_value : KWD_VALUE expression? KWD_WITH ; - parse_var : KWD_VAR var_symbol ; -procedure_ : KWD_PROCEDURE ( KWD_EXPOSE variable_list )? ; -pull_ : KWD_PULL template_list? ; -push_ : KWD_PUSH expression? ; -queue_ : KWD_QUEUE expression? ; -return_ : KWD_RETURN expression? ; -say_ : KWD_SAY expression? ; -signal_ : KWD_SIGNAL ( signal_spec | valueexp | taken_constant ) ; - signal_spec : KWD_ON condition ( KWD_NAME function_name )? - | KWD_OFF condition - ; - condition : callable_condition - | KWD_NOVALUE - | KWD_SYNTAX - ; -trace_ : KWD_TRACE - ( taken_constant - | valueexp - | expression - | KWD_ERROR - | KWD_FAILURE - | KWD_OFF - ) - ; -upper_ : KWD_UPPER var_symbol+ ; // if stem -> error (cannot do 'upper j.') +address_ + : KWD_ADDRESS (taken_constant expression? | valueexp)? + ; + +taken_constant + : symbol + | STRING + ; + +valueexp + : KWD_VALUE expression + ; + +arg_ + : KWD_ARG template_list? + ; + +call_ + : KWD_CALL (callon_spec | function_name call_parms?) + ; + +callon_spec + : KWD_ON callable_condition (KWD_NAME function_name)? + | KWD_OFF callable_condition + ; + +callable_condition + : KWD_ERROR + | KWD_FAILURE + | KWD_HALT + ; + +call_parms + : BR_O expression_list? BR_C + | expression_list + ; + +expression_list + : COMMA* expression (COMMA+ expression)* + ; + +drop_ + : KWD_DROP variable_list + ; + +variable_list + : (vref | var_symbol)+ + ; + +vref + : BR_O var_symbol BR_C + ; + +var_symbol + : VAR_SYMBOL + | SPECIAL_VAR + ; + +exit_ + : KWD_EXIT expression? + ; + +interpret_ + : KWD_INTERPRET expression + ; + +iterate_ + : KWD_ITERATE var_symbol? + ; + +leave_ + : KWD_LEAVE var_symbol? + ; + +nop_ + : KWD_NOP + ; + +numeric_ + : KWD_NUMERIC (numeric_digits | numeric_form | numeric_fuzz) + ; + +numeric_digits + : KWD_DIGITS expression? + ; + +numeric_form + : KWD_FORM (KWD_ENGINEERING | KWD_SCIENTIFIC | valueexp | expression)? + ; + +numeric_fuzz + : KWD_FUZZ expression? + ; + +options_ + : KWD_OPTIONS expression + ; + +parse_ + : KWD_PARSE KWD_UPPER? parse_type template_list? + ; + +parse_type + : parse_key + | parse_value + | parse_var + ; + +parse_key + : KWD_ARG + | KWD_EXTERNAL + | KWD_NUMERIC + | KWD_PULL + | KWD_SOURCE + | KWD_VERSION + ; + +parse_value + : KWD_VALUE expression? KWD_WITH + ; + +parse_var + : KWD_VAR var_symbol + ; + +procedure_ + : KWD_PROCEDURE (KWD_EXPOSE variable_list)? + ; + +pull_ + : KWD_PULL template_list? + ; + +push_ + : KWD_PUSH expression? + ; + +queue_ + : KWD_QUEUE expression? + ; + +return_ + : KWD_RETURN expression? + ; + +say_ + : KWD_SAY expression? + ; + +signal_ + : KWD_SIGNAL (signal_spec | valueexp | taken_constant) + ; + +signal_spec + : KWD_ON condition (KWD_NAME function_name)? + | KWD_OFF condition + ; + +condition + : callable_condition + | KWD_NOVALUE + | KWD_SYNTAX + ; + +trace_ + : KWD_TRACE (taken_constant | valueexp | expression | KWD_ERROR | KWD_FAILURE | KWD_OFF) + ; + +upper_ + : KWD_UPPER var_symbol+ + ; // if stem -> error (cannot do 'upper j.') /* Note: The next section describes templates. */ -template_list : COMMA* template_ ( COMMA+ template_ )* ; - template_ : ( trigger_ | target_ )+ ; - target_ : VAR_SYMBOL - | SPECIAL_VAR - | STOP - ; - trigger_ : pattern_ - | positional_ - ; - pattern_ : STRING - | vref - ; - positional_ : absolute_positional - | relative_positional - ; - absolute_positional : NUMBER - | EQ position_ - ; - position_ : NUMBER - | vref - ; - relative_positional : (PLUS | MINUS) position_ ; +template_list + : COMMA* template_ (COMMA+ template_)* + ; + +template_ + : (trigger_ | target_)+ + ; + +target_ + : VAR_SYMBOL + | SPECIAL_VAR + | STOP + ; + +trigger_ + : pattern_ + | positional_ + ; + +pattern_ + : STRING + | vref + ; + +positional_ + : absolute_positional + | relative_positional + ; + +absolute_positional + : NUMBER + | EQ position_ + ; + +position_ + : NUMBER + | vref + ; + +relative_positional + : (PLUS | MINUS) position_ + ; // Note: The final part specifies the various forms of symbol, and expression. -symbol : var_symbol - | CONST_SYMBOL - | NUMBER - ; -expression : and_expression - ( or_operator and_expression )* ; - or_operator : OR - | XOR - ; - and_expression : comparison ( AND comparison )* ; -comparison : concatenation ( comparison_operator concatenation )* ; - comparison_operator : normal_compare - | strict_compare - ; - normal_compare : EQ - | CMP_NEq - | CMP_LM - | CMP_ML - | CMP_M - | CMP_L - | CMP_MEq - | CMP_LEq - | CMP_NM - | CMP_NL - ; - strict_compare : CMPS_Eq - | CMPS_Neq - | CMPS_M - | CMPS_L - | CMPS_MEq - | CMPS_LEq - | CMPS_NM - | CMPS_NL - ; -concatenation : addition (concatenation_op addition)* ; - concatenation_op : { $parser.is_prev_token_whitespace() }? blank_concatenation_op // If previous token is whitespace, this is blank-concatenation. - | normal_concatenation_op - ; - normal_concatenation_op : { $parser.is_prev_token_not_whitespace() }? // If previous token is not whitespace, this is abuttal-concatenation. - // Note: no token or rule to match here, just the predicate. - | CONCAT - ; - blank_concatenation_op : ; // Note: no token or rule to match here, just the predicate. - -addition : multiplication ( additive_operator multiplication )* ; - additive_operator : PLUS - | MINUS - ; -multiplication : power_expression ( multiplicative_operator power_expression )* ; - multiplicative_operator : MUL - | DIV - | QUOTINENT - | REMAINDER - ; -power_expression : prefix_expression ( POW prefix_expression )* ; - prefix_expression : ( PLUS | MINUS | NOT )* term ; - term : function_ - | BR_O expression BR_C - | symbol - | binary_string - | hex_string - | string - ; - binary_string : BINARY_STRING ; - hex_string : HEX_STRING ; - string : STRING ; - function_ : function_name function_parameters ; - function_name : KWD_ADDRESS - | KWD_ARG - | KWD_DIGITS - | KWD_FORM - | KWD_FUZZ - | KWD_TRACE - | KWD_VALUE - | taken_constant - ; - function_parameters : BR_O expression_list? BR_C ; +symbol + : var_symbol + | CONST_SYMBOL + | NUMBER + ; + +expression + : and_expression (or_operator and_expression)* + ; + +or_operator + : OR + | XOR + ; + +and_expression + : comparison (AND comparison)* + ; + +comparison + : concatenation (comparison_operator concatenation)* + ; + +comparison_operator + : normal_compare + | strict_compare + ; + +normal_compare + : EQ + | CMP_NEq + | CMP_LM + | CMP_ML + | CMP_M + | CMP_L + | CMP_MEq + | CMP_LEq + | CMP_NM + | CMP_NL + ; + +strict_compare + : CMPS_Eq + | CMPS_Neq + | CMPS_M + | CMPS_L + | CMPS_MEq + | CMPS_LEq + | CMPS_NM + | CMPS_NL + ; + +concatenation + : addition (concatenation_op addition)* + ; + +concatenation_op + : { $parser.is_prev_token_whitespace() }? blank_concatenation_op // If previous token is whitespace, this is blank-concatenation. + | normal_concatenation_op + ; + +normal_concatenation_op + : { $parser.is_prev_token_not_whitespace() }? // If previous token is not whitespace, this is abuttal-concatenation. + // Note: no token or rule to match here, just the predicate. + | CONCAT + ; + +blank_concatenation_op + : + ; // Note: no token or rule to match here, just the predicate. + +addition + : multiplication (additive_operator multiplication)* + ; + +additive_operator + : PLUS + | MINUS + ; + +multiplication + : power_expression (multiplicative_operator power_expression)* + ; + +multiplicative_operator + : MUL + | DIV + | QUOTINENT + | REMAINDER + ; + +power_expression + : prefix_expression (POW prefix_expression)* + ; + +prefix_expression + : (PLUS | MINUS | NOT)* term + ; + +term + : function_ + | BR_O expression BR_C + | symbol + | binary_string + | hex_string + | string + ; + +binary_string + : BINARY_STRING + ; + +hex_string + : HEX_STRING + ; + +string + : STRING + ; + +function_ + : function_name function_parameters + ; + +function_name + : KWD_ADDRESS + | KWD_ARG + | KWD_DIGITS + | KWD_FORM + | KWD_FUZZ + | KWD_TRACE + | KWD_VALUE + | taken_constant + ; + +function_parameters + : BR_O expression_list? BR_C + ; \ No newline at end of file diff --git a/rfc1035/domain.g4 b/rfc1035/domain.g4 index 7372bd487d..cd7c4521b7 100644 --- a/rfc1035/domain.g4 +++ b/rfc1035/domain.g4 @@ -25,39 +25,42 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar domain; domain - : (subdomain | ' ') EOF - ; + : (subdomain | ' ') EOF + ; subdomain - : LABEL ('.' LABEL)* - ; + : LABEL ('.' LABEL)* + ; LABEL - : LETTER (LDH_STR* LET_DIG)* - ; + : LETTER (LDH_STR* LET_DIG)* + ; LDH_STR - : LET_DIG_HYP LDH_STR? - ; + : LET_DIG_HYP LDH_STR? + ; LET_DIG_HYP - : LET_DIG - | '-' - ; + : LET_DIG + | '-' + ; LET_DIG - : LETTER - | DIGIT - ; + : LETTER + | DIGIT + ; LETTER - : [a-zA-Z] - ; + : [a-zA-Z] + ; DIGIT - : [0-9] - ; - + : [0-9] + ; \ No newline at end of file diff --git a/rfc1960/filter.g4 b/rfc1960/filter.g4 index 15c4816728..7780b0ba3d 100644 --- a/rfc1960/filter.g4 +++ b/rfc1960/filter.g4 @@ -25,108 +25,113 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar filter; -file_ : filter_ EOF ; +file_ + : filter_ EOF + ; filter_ - : '(' filtercomp ')' - ; + : '(' filtercomp ')' + ; filtercomp - : and_ - | or_ - | not_ - | item - ; + : and_ + | or_ + | not_ + | item + ; and_ - : '&' filterlist - ; + : '&' filterlist + ; or_ - : '|' filterlist - ; + : '|' filterlist + ; not_ - : '!' filter_ - ; + : '!' filter_ + ; filterlist - : filter_ - | filter_ filterlist - ; + : filter_ + | filter_ filterlist + ; item - : simple - | present - | substring - ; + : simple + | present + | substring + ; simple - : attr filtertype value - ; + : attr filtertype value + ; filtertype - : EQUAL - | APPROX - | GREATER - | LESS - ; + : EQUAL + | APPROX + | GREATER + | LESS + ; EQUAL - : '=' - ; + : '=' + ; APPROX - : '~=' - ; + : '~=' + ; GREATER - : '>=' - ; + : '>=' + ; LESS - : '<=' - ; + : '<=' + ; present - : attr '=*' - ; + : attr '=*' + ; substring - : attr '=' initial? any_ final_? - ; + : attr '=' initial? any_ final_? + ; initial - : value - ; + : value + ; any_ - : '*' starval? - ; + : '*' starval? + ; starval - : value '*' starval? - ; + : value '*' starval? + ; final_ - : value - ; + : value + ; attr - : OCTETSTRING - ; + : OCTETSTRING + ; value - : OCTETSTRING - ; + : OCTETSTRING + ; + /* * cheap hack */ - OCTETSTRING - : [a-zA-Z0-9. ]+ - ; - + : [a-zA-Z0-9. ]+ + ; \ No newline at end of file diff --git a/rfc3080/beep.g4 b/rfc3080/beep.g4 index cd9256a56e..ce9f075cd0 100644 --- a/rfc3080/beep.g4 +++ b/rfc3080/beep.g4 @@ -25,118 +25,121 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar beep; frame - : data EOF - ; + : data EOF + ; data - : header payload_trailer - ; + : header payload_trailer + ; header - : msg - | rpy - | err - | ans - | nul - ; + : msg + | rpy + | err + | ans + | nul + ; msg - : MSG SP common - ; + : MSG SP common + ; rpy - : RPY SP common - ; + : RPY SP common + ; ans - : ANS SP common SP ansno - ; + : ANS SP common SP ansno + ; err - : ERR SP common - ; + : ERR SP common + ; nul - : NUL SP common - ; + : NUL SP common + ; common - : channel SP msgno SP more SP seqno SP size - ; + : channel SP msgno SP more SP seqno SP size + ; channel - : NUMBER - ; + : NUMBER + ; msgno - : NUMBER - ; + : NUMBER + ; more - : DOT - | STAR - ; + : DOT + | STAR + ; seqno - : NUMBER - ; + : NUMBER + ; size - : NUMBER - ; + : NUMBER + ; ansno - : NUMBER - ; + : NUMBER + ; payload_trailer - : PAYLOAD_TRAILER CRLF? - ; + : PAYLOAD_TRAILER CRLF? + ; DOT - : '.' - ; + : '.' + ; STAR - : '*' - ; + : '*' + ; NUL - : 'NUL' - ; + : 'NUL' + ; ERR - : 'ERR' - ; + : 'ERR' + ; ANS - : 'ANS' - ; + : 'ANS' + ; RPY - : 'RPY' - ; + : 'RPY' + ; MSG - : 'MSG' - ; + : 'MSG' + ; NUMBER - : [0-9]+ - ; + : [0-9]+ + ; SP - : ' ' - ; + : ' ' + ; CRLF - : [\r\n]+ - ; + : [\r\n]+ + ; PAYLOAD_TRAILER - : CRLF .*? 'END' - ; - + : CRLF .*? 'END' + ; \ No newline at end of file diff --git a/rfc822/rfc822-datetime/datetime.g4 b/rfc822/rfc822-datetime/datetime.g4 index 3309980e38..7b225ba22a 100644 --- a/rfc822/rfc822-datetime/datetime.g4 +++ b/rfc822/rfc822-datetime/datetime.g4 @@ -26,98 +26,96 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar datetime; date_time - : (day ',')? date time EOF - ; + : (day ',')? date time EOF + ; day - : 'Mon' - | 'Tue' - | 'Wed' - | 'Thu' - | 'Fri' - | 'Sat' - | 'Sun' - ; + : 'Mon' + | 'Tue' + | 'Wed' + | 'Thu' + | 'Fri' + | 'Sat' + | 'Sun' + ; date - : two_digit + month two_digit - ; + : two_digit+ month two_digit + ; month - : 'Jan' - | 'Feb' - | 'Mar' - | 'Apr' - | 'May' - | 'Jun' - | 'Jul' - | 'Aug' - | 'Sep' - | 'Oct' - | 'Nov' - | 'Dec' - ; + : 'Jan' + | 'Feb' + | 'Mar' + | 'Apr' + | 'May' + | 'Jun' + | 'Jul' + | 'Aug' + | 'Sep' + | 'Oct' + | 'Nov' + | 'Dec' + ; time - : hour zone - ; + : hour zone + ; hour - : two_digit ':' two_digit (':' two_digit)? - ; + : two_digit ':' two_digit (':' two_digit)? + ; zone - : 'UT' - | 'GMT' - | 'EST' - | 'EDT' - | 'CST' - | 'CDT' - | 'MST' - | 'MDT' - | 'PST' - | 'PDT' - | ALPHA - | (('+' | '-') four_digit) - ; + : 'UT' + | 'GMT' + | 'EST' + | 'EDT' + | 'CST' + | 'CDT' + | 'MST' + | 'MDT' + | 'PST' + | 'PDT' + | ALPHA + | (('+' | '-') four_digit) + ; two_digit - : alphanumeric alphanumeric - ; + : alphanumeric alphanumeric + ; four_digit - : alphanumeric alphanumeric alphanumeric alphanumeric - ; + : alphanumeric alphanumeric alphanumeric alphanumeric + ; alphanumeric - : ALPHA - | DIGIT - ; - + : ALPHA + | DIGIT + ; fragment CHAR - : [\u0000-\u007F] - ; - + : [\u0000-\u007F] + ; ALPHA - : [a-zA-Z] - ; - + : [a-zA-Z] + ; DIGIT - : [0-9] - ; - + : [0-9] + ; fragment NOTALPHANUMERIC - : ~ [a-zA-Z0-9] - ; - + : ~ [a-zA-Z0-9] + ; WS - : [ \r\n\t] -> skip - ; + : [ \r\n\t] -> skip + ; \ No newline at end of file diff --git a/rfc822/rfc822-emailaddress/emailaddress.g4 b/rfc822/rfc822-emailaddress/emailaddress.g4 index 2320fc85c2..9c7c341494 100644 --- a/rfc822/rfc822-emailaddress/emailaddress.g4 +++ b/rfc822/rfc822-emailaddress/emailaddress.g4 @@ -30,114 +30,164 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar emailaddress; emailaddress - : (mailbox - | group ) EOF ; + : (mailbox | group) EOF + ; + +group + : phrase ':' mailbox* ';' + ; -group - : phrase ':' mailbox* ';'; +mailbox + : addrspec + | (phrase routeaddr) + ; -mailbox - : addrspec - | (phrase routeaddr ); +routeaddr + : '<' route* addrspec '>' + ; -routeaddr - : '<' route* addrspec '>'; +route + : '@' domain ':' + ; -route - : '@' domain ':'; +addrspec + : localpart '@' domain + ; -addrspec - : localpart '@' domain; +localpart + : word ('.' word)* + ; -localpart - : word ('.' word)*; - -domain - : subdomain ('.' subdomain)*; +domain + : subdomain ('.' subdomain)* + ; -subdomain - : domainref | domainliteral; +subdomain + : domainref + | domainliteral + ; -domainref - : atom; +domainref + : atom + ; -phrase - : word+; +phrase + : word+ + ; -word - : atom | quotedstring; +word + : atom + | quotedstring + ; lwspchar - : SPACE | HTAB; + : SPACE + | HTAB + ; lwsp - : (CRLF? lwspchar)+; + : (CRLF? lwspchar)+ + ; delimeters - : SPECIALS + : SPECIALS | lwsp - | comment; + | comment + ; //text - // : CHAR+; +// : CHAR+; -atom - : CHAR+; +atom + : CHAR+ + ; -quotedpair - : '\\' CHAR; +quotedpair + : '\\' CHAR + ; domainliteral - : '[' (DTEXT | quotedpair)* ']'; + : '[' (DTEXT | quotedpair)* ']' + ; -quotedstring - : '\'' (QTEXT | quotedpair)* '\''; +quotedstring + : '\'' (QTEXT | quotedpair)* '\'' + ; -comment - : '(' (CTEXT | quotedpair | comment)* ')'; +comment + : '(' (CTEXT | quotedpair | comment)* ')' + ; CHAR - : [\u0000-\u0127]; - + : [\u0000-\u0127] + ; + ALPHA - : [\u0065-\u0090]; + : [\u0065-\u0090] + ; DIGIT - : [\u0048-\u0057]; + : [\u0048-\u0057] + ; CTL - : [\u0000-\u0031]; + : [\u0000-\u0031] + ; CR - : '\n'; + : '\n' + ; LF - : '\r'; + : '\r' + ; SPACE - : ' '; + : ' ' + ; HTAB - : '\t'; + : '\t' + ; CRLF - : '\r\n'; + : '\r\n' + ; SPECIALS - : '(' | ')' | '<' | '>' | '@' | ',' | ';' | ':' | '\\' | '\''| '.' | '[' | ']' ; + : '(' + | ')' + | '<' + | '>' + | '@' + | ',' + | ';' + | ':' + | '\\' + | '\'' + | '.' + | '[' + | ']' + ; QUOTE - : '"'; + : '"' + ; QTEXT - : ~[\r\n]; + : ~[\r\n] + ; DTEXT - : ~[[\]\n\\]; + : ~[[\]\n\\] + ; CTEXT - : ~[()\n\\]; - \ No newline at end of file + : ~[()\n\\] + ; \ No newline at end of file diff --git a/robotwars/robotwar.g4 b/robotwars/robotwar.g4 index 271d6db567..0cc4eb7b07 100644 --- a/robotwars/robotwar.g4 +++ b/robotwars/robotwar.g4 @@ -26,341 +26,300 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar robotwar; program - : line + EOF - ; + : line+ EOF + ; line - : (label | comment | statement)? EOL - ; + : (label | comment | statement)? EOL + ; label - : ID - ; - + : ID + ; + statement - : ifstatement - | tostatement - | gosubstatement - | gotostatement - | endsubstatement - | accumstatement - ; + : ifstatement + | tostatement + | gosubstatement + | gotostatement + | endsubstatement + | accumstatement + ; accumstatement - : accumexpression; + : accumexpression + ; accumexpression - : ('=' - | '#' - | ('<' expression) - | ('>' expression)) statement + : ('=' | '#' | ('<' expression) | ('>' expression)) statement ; gosubstatement - : 'GOSUB' label - ; + : 'GOSUB' label + ; gotostatement - : 'GOTO' label - ; + : 'GOTO' label + ; tostatement - : expression? ('TO' register_) + - ; + : expression? ('TO' register_)+ + ; endsubstatement - : 'ENDSUB' - ; + : 'ENDSUB' + ; ifstatement - : 'IF'? condition (EOL | COMMA | DOT)? statement - ; + : 'IF'? condition (EOL | COMMA | DOT)? statement + ; condition - : expression comparison expression - ; + : expression comparison expression + ; expression - : (argument (operation argument)*) - | (operation argument) - | argument - ; + : (argument (operation argument)*) + | (operation argument) + | argument + ; operation - : '+' - | '-' - | '*' - | '/' - ; + : '+' + | '-' + | '*' + | '/' + ; comparison - : '<' - | '>' - | '=' - | '#' - ; + : '<' + | '>' + | '=' + | '#' + ; argument - : number - | register_ - | DATA - ; + : number + | register_ + | DATA + ; register_ - : A - | B - | C - | D - | E - | F - | G - | H - | I - | J - | K - | L - | M - | N - | O - | P - | Q - | R - | S - | T - | U - | V - | W - | X - | Y - | Z - | AIM - | SHOT - | RADAR - | SPEEDX - | SPEEDY - | RANDOM - | INDEX - | DATA - | DAMAGE - ; - + : A + | B + | C + | D + | E + | F + | G + | H + | I + | J + | K + | L + | M + | N + | O + | P + | Q + | R + | S + | T + | U + | V + | W + | X + | Y + | Z + | AIM + | SHOT + | RADAR + | SPEEDX + | SPEEDY + | RANDOM + | INDEX + | DATA + | DAMAGE + ; A - : 'A' - ; - + : 'A' + ; B - : 'B' - ; - + : 'B' + ; C - : 'C' - ; - + : 'C' + ; D - : 'D' - ; - + : 'D' + ; E - : 'E' - ; - + : 'E' + ; F - : 'F' - ; - + : 'F' + ; G - : 'G' - ; - + : 'G' + ; H - : 'H' - ; - + : 'H' + ; I - : 'I' - ; - + : 'I' + ; J - : 'J' - ; - + : 'J' + ; K - : 'K' - ; - + : 'K' + ; L - : 'L' - ; - + : 'L' + ; M - : 'M' - ; - + : 'M' + ; N - : 'N' - ; - + : 'N' + ; O - : 'O' - ; - + : 'O' + ; P - : 'P' - ; - + : 'P' + ; Q - : 'Q' - ; - + : 'Q' + ; R - : 'R' - ; - + : 'R' + ; S - : 'S' - ; - + : 'S' + ; T - : 'T' - ; - + : 'T' + ; U - : 'U' - ; - + : 'U' + ; V - : 'V' - ; - + : 'V' + ; W - : 'W' - ; - + : 'W' + ; X - : 'X' - ; - + : 'X' + ; Y - : 'Y' - ; - + : 'Y' + ; Z - : 'Z' - ; - + : 'Z' + ; AIM - : 'AIM' - ; - + : 'AIM' + ; SHOT - : 'SHOT' - ; - + : 'SHOT' + ; RADAR - : 'RADAR' - ; - + : 'RADAR' + ; DAMAGE - : 'DAMAGE' - ; - + : 'DAMAGE' + ; SPEEDX - : 'SPEEDX' - ; - + : 'SPEEDX' + ; SPEEDY - : 'SPEEDY' - ; - + : 'SPEEDY' + ; RANDOM - : 'RANDOM' - ; - + : 'RANDOM' + ; INDEX - : 'INDEX' - ; - + : 'INDEX' + ; DATA - : 'DATA' - ; - + : 'DATA' + ; DOT - : '.' - ; - + : '.' + ; COMMA - : ',' - ; - + : ',' + ; ID - : ('a' .. 'z' | 'A' .. 'Z') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9') + - ; + : ('a' .. 'z' | 'A' .. 'Z') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9')+ + ; number - : ('+' | '-')? NUMBER - ; + : ('+' | '-')? NUMBER + ; comment - : COMMENT - ; - + : COMMENT + ; NUMBER - : [0-9] + - ; - + : [0-9]+ + ; COMMENT - : ';' ~ [\r\n]* - ; - + : ';' ~ [\r\n]* + ; EOL - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/romannumerals/romannumerals.g4 b/romannumerals/romannumerals.g4 index f267ff4907..ae913d53e4 100644 --- a/romannumerals/romannumerals.g4 +++ b/romannumerals/romannumerals.g4 @@ -33,173 +33,156 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Essentials of the grammar from here: https://compilers.iecc.com/comparch/article/07-03-118 */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar romannumerals; expression - : thousands EOF - ; + : thousands EOF + ; thousands - : thous_part hundreds - | thous_part - | hundreds - ; + : thous_part hundreds + | thous_part + | hundreds + ; thous_part - : thous_part M - | M - ; + : thous_part M + | M + ; hundreds - : hun_part tens - | hun_part - | tens - ; + : hun_part tens + | hun_part + | tens + ; hun_part - : hun_rep - | CD - | D - | D hun_rep - | CM - ; + : hun_rep + | CD + | D + | D hun_rep + | CM + ; hun_rep - : C - | CC - | CCC - ; + : C + | CC + | CCC + ; tens - : tens_part ones - | tens_part - | ones - ; + : tens_part ones + | tens_part + | ones + ; tens_part - : tens_rep - | XL - | L - | L tens_rep - | XC - ; + : tens_rep + | XL + | L + | L tens_rep + | XC + ; tens_rep - : X - | XX - | XXX - ; + : X + | XX + | XXX + ; ones - : ones_rep - | IV - | V - | V ones_rep - | IX - ; + : ones_rep + | IV + | V + | V ones_rep + | IX + ; ones_rep - : I - | II - | III - ; - + : I + | II + | III + ; M - : 'M' - ; - + : 'M' + ; CD - : 'CD' - ; - + : 'CD' + ; D - : 'D' - ; - + : 'D' + ; CM - : 'CM' - ; - + : 'CM' + ; C - : 'C' - ; - + : 'C' + ; CC - : 'CC' - ; - + : 'CC' + ; CCC - : 'CCC' - ; - + : 'CCC' + ; XL - : 'XL' - ; - + : 'XL' + ; L - : 'L' - ; - + : 'L' + ; XC - : 'XC' - ; - + : 'XC' + ; X - : 'X' - ; - + : 'X' + ; XX - : 'XX' - ; - + : 'XX' + ; XXX - : 'XXX' - ; - + : 'XXX' + ; IV - : 'IV' - ; - + : 'IV' + ; V - : 'V' - ; - + : 'V' + ; IX - : 'IX' - ; - + : 'IX' + ; I - : 'I' - ; - + : 'I' + ; II - : 'II' - ; - + : 'II' + ; III - : 'III' - ; - + : 'III' + ; WS - : [ \r\n\t] + -> skip - ; + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/ron/ron.g4 b/ron/ron.g4 index d5b1e18a9c..25fcacfd1e 100644 --- a/ron/ron.g4 +++ b/ron/ron.g4 @@ -29,92 +29,95 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ron; ron_ - : value* EOF - ; + : value* EOF + ; classname - : ID - ; + : ID + ; value - : classname? (number | STRING | BOOLEAN | CHAR | ID | tuple | list | struct | map) - ; + : classname? (number | STRING | BOOLEAN | CHAR | ID | tuple | list | struct | map) + ; values - : value (',' value)* ','? - ; + : value (',' value)* ','? + ; number - : DECIMAL - | HEX - | BINARY - ; + : DECIMAL + | HEX + | BINARY + ; tuple - : '(' values ')' - ; + : '(' values ')' + ; list - : '[' values ']' - ; + : '[' values ']' + ; struct - : '(' structitem (',' structitem)* ')' ','? - ; + : '(' structitem (',' structitem)* ')' ','? + ; structitem - : ID ':' (value | struct) ','? - ; + : ID ':' (value | struct) ','? + ; map - : '{' mapitem (',' mapitem)* '}' ','? - ; + : '{' mapitem (',' mapitem)* '}' ','? + ; mapitem - : (ID | STRING | number) ':' value ','? - ; + : (ID | STRING | number) ':' value ','? + ; DECIMAL - : [0-9]+ ('.' [0-9]+)? - ; + : [0-9]+ ('.' [0-9]+)? + ; HEX - : ('0x' | '0X') [0-9A-F]+ - ; + : ('0x' | '0X') [0-9A-F]+ + ; BINARY - : ('0b' | '0B') [0-1]+ - ; + : ('0b' | '0B') [0-1]+ + ; STRING - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; BOOLEAN - : 'true' - | 'false' - ; + : 'true' + | 'false' + ; CHAR - : '\'' ~ '\'' '\'' - ; + : '\'' ~ '\'' '\'' + ; ID - : [a-zA-Z_]+ - ; + : [a-zA-Z_]+ + ; LINE_COMMENT - : '//' ~ [\r\n]* -> skip - ; + : '//' ~ [\r\n]* -> skip + ; MULTILINE_COMMENT - : '/*' .*? '*/' -> skip - ; + : '/*' .*? '*/' -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/rpn/rpn.g4 b/rpn/rpn.g4 index 8b8671a5fb..0364487127 100644 --- a/rpn/rpn.g4 +++ b/rpn/rpn.g4 @@ -30,155 +30,141 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar rpn; expression - : signedAtom term* EOF - ; + : signedAtom term* EOF + ; term - : signedAtom - | oper - ; + : signedAtom + | oper + ; oper - : POW - | PLUS - | MINUS - | TIMES - | DIV - | COS - | TAN - | SIN - | ACOS - | ATAN - | ASIN - | LOG - | LN - ; + : POW + | PLUS + | MINUS + | TIMES + | DIV + | COS + | TAN + | SIN + | ACOS + | ATAN + | ASIN + | LOG + | LN + ; signedAtom - : PLUS signedAtom - | MINUS signedAtom - | scientific - | variable - ; + : PLUS signedAtom + | MINUS signedAtom + | scientific + | variable + ; variable - : VARIABLE - ; + : VARIABLE + ; scientific - : SCIENTIFIC_NUMBER - ; - + : SCIENTIFIC_NUMBER + ; SCIENTIFIC_NUMBER - : NUMBER (E SIGN? NUMBER)? - ; + : NUMBER (E SIGN? NUMBER)? + ; //The integer part gets its potential sign from the signedAtom rule fragment NUMBER - : ('0' .. '9') + ('.' ('0' .. '9') +)? - ; - + : ('0' .. '9')+ ('.' ('0' .. '9')+)? + ; fragment E - : 'E' | 'e' - ; - + : 'E' + | 'e' + ; fragment SIGN - : ('+' | '-') - ; - + : ('+' | '-') + ; VARIABLE - : VALID_ID_START VALID_ID_CHAR* - ; - + : VALID_ID_START VALID_ID_CHAR* + ; fragment VALID_ID_START - : ('a' .. 'z') | ('A' .. 'Z') | '_' - ; - + : ('a' .. 'z') + | ('A' .. 'Z') + | '_' + ; fragment VALID_ID_CHAR - : VALID_ID_START | ('0' .. '9') - ; - + : VALID_ID_START + | ('0' .. '9') + ; POW - : '^' - ; - + : '^' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; TIMES - : '*' - ; - + : '*' + ; DIV - : '/' - ; - + : '/' + ; COS - : 'cos' - ; - + : 'cos' + ; SIN - : 'sin' - ; - + : 'sin' + ; TAN - : 'tan' - ; - + : 'tan' + ; ACOS - : 'acos' - ; - + : 'acos' + ; ASIN - : 'asin' - ; - + : 'asin' + ; ATAN - : 'atan' - ; - + : 'atan' + ; LN - : 'ln' - ; - + : 'ln' + ; LOG - : 'log' - ; - + : 'log' + ; POINT - : '.' - ; - + : '.' + ; WS - : [ \r\n\t] + -> skip - ; + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/ruby/Corundum.g4 b/ruby/Corundum.g4 index 066daa2c59..0ea3e2e2db 100644 --- a/ruby/Corundum.g4 +++ b/ruby/Corundum.g4 @@ -33,382 +33,681 @@ * (PIR) here: https://github.com/AlexBelov/corundum */ -grammar Corundum; - -prog : expression_list EOF; - -expression_list : expression terminator - | expression_list expression terminator - | terminator - ; - -expression : function_definition - | function_inline_call - | require_block - | if_statement - | unless_statement - | rvalue - | return_statement - | while_statement - | for_statement - | pir_inline - ; - -global_get : var_name=lvalue op=ASSIGN global_name=id_global; - -global_set : global_name=id_global op=ASSIGN result=all_result; - -global_result : id_global; - -function_inline_call : function_call; - -require_block : REQUIRE literal_t; - -pir_inline : PIR crlf pir_expression_list END; - -pir_expression_list : expression_list; - -function_definition : function_definition_header function_definition_body END; - -function_definition_body : expression_list; - -function_definition_header : DEF function_name crlf - | DEF function_name function_definition_params crlf - ; - -function_name : id_function - | id_ - ; - -function_definition_params : LEFT_RBRACKET RIGHT_RBRACKET - | LEFT_RBRACKET function_definition_params_list RIGHT_RBRACKET - | function_definition_params_list - ; - -function_definition_params_list : function_definition_param_id - | function_definition_params_list COMMA function_definition_param_id - ; - -function_definition_param_id : id_; - -return_statement : RETURN all_result; - -function_call : name=function_name LEFT_RBRACKET params=function_call_param_list RIGHT_RBRACKET - | name=function_name params=function_call_param_list - | name=function_name LEFT_RBRACKET RIGHT_RBRACKET - ; - -function_call_param_list : function_call_params; - -function_call_params : function_param - | function_call_params COMMA function_param - ; - -function_param : ( function_unnamed_param | function_named_param ); - -function_unnamed_param : ( int_result | float_result | string_result | dynamic_result ); - -function_named_param : id_ op=ASSIGN ( int_result | float_result | string_result | dynamic_result ); - -function_call_assignment : function_call; - -all_result : ( int_result | float_result | string_result | dynamic_result | global_result ); - -elsif_statement : if_elsif_statement; - -if_elsif_statement : ELSIF cond_expression crlf statement_body - | ELSIF cond_expression crlf statement_body else_token crlf statement_body - | ELSIF cond_expression crlf statement_body if_elsif_statement - ; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -if_statement : IF cond_expression crlf statement_body END - | IF cond_expression crlf statement_body else_token crlf statement_body END - | IF cond_expression crlf statement_body elsif_statement END - ; - -unless_statement : UNLESS cond_expression crlf statement_body END - | UNLESS cond_expression crlf statement_body else_token crlf statement_body END - | UNLESS cond_expression crlf statement_body elsif_statement END - ; - -while_statement : WHILE cond_expression crlf statement_body END; - -for_statement : FOR LEFT_RBRACKET init_expression SEMICOLON cond_expression SEMICOLON loop_expression RIGHT_RBRACKET crlf statement_body END - | FOR init_expression SEMICOLON cond_expression SEMICOLON loop_expression crlf statement_body END - ; - -init_expression : for_init_list; - -all_assignment : ( int_assignment | float_assignment | string_assignment | dynamic_assignment ); - -for_init_list : for_init_list COMMA all_assignment - | all_assignment - ; - -cond_expression : comparison_list; - -loop_expression : for_loop_list; - -for_loop_list : for_loop_list COMMA all_assignment - | all_assignment - ; - -statement_body : statement_expression_list; - -statement_expression_list : expression terminator - | RETRY terminator - | break_expression terminator - | statement_expression_list expression terminator - | statement_expression_list RETRY terminator - | statement_expression_list break_expression terminator - ; - -assignment : var_id=lvalue op=ASSIGN rvalue - | var_id=lvalue op=( PLUS_ASSIGN | MINUS_ASSIGN | MUL_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | EXP_ASSIGN ) rvalue - ; - -dynamic_assignment : var_id=lvalue op=ASSIGN dynamic_result - | var_id=lvalue op=( PLUS_ASSIGN | MINUS_ASSIGN | MUL_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | EXP_ASSIGN ) dynamic_result - ; - -int_assignment : var_id=lvalue op=ASSIGN int_result - | var_id=lvalue op=( PLUS_ASSIGN | MINUS_ASSIGN | MUL_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | EXP_ASSIGN ) int_result - ; - -float_assignment : var_id=lvalue op=ASSIGN float_result - | var_id=lvalue op=( PLUS_ASSIGN | MINUS_ASSIGN | MUL_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | EXP_ASSIGN ) float_result - ; - -string_assignment : var_id=lvalue op=ASSIGN string_result - | var_id=lvalue op=PLUS_ASSIGN string_result - ; - -initial_array_assignment : var_id=lvalue op=ASSIGN LEFT_SBRACKET RIGHT_SBRACKET; - -array_assignment : arr_def=array_selector op=ASSIGN arr_val=all_result; - -array_definition : LEFT_SBRACKET array_definition_elements RIGHT_SBRACKET; - -array_definition_elements : ( int_result | dynamic_result ) - | array_definition_elements COMMA ( int_result | dynamic_result ) - ; - -array_selector : id_ LEFT_SBRACKET ( int_result | dynamic_result ) RIGHT_SBRACKET - | id_global LEFT_SBRACKET ( int_result | dynamic_result ) RIGHT_SBRACKET - ; - -dynamic_result : dynamic_result op=( MUL | DIV | MOD ) int_result - | int_result op=( MUL | DIV | MOD ) dynamic_result - | dynamic_result op=( MUL | DIV | MOD ) float_result - | float_result op=( MUL | DIV | MOD ) dynamic_result - | dynamic_result op=( MUL | DIV | MOD ) dynamic_result - | dynamic_result op=MUL string_result - | string_result op=MUL dynamic_result - | dynamic_result op=( PLUS | MINUS ) int_result - | int_result op=( PLUS | MINUS ) dynamic_result - | dynamic_result op=( PLUS | MINUS ) float_result - | float_result op=( PLUS | MINUS ) dynamic_result - | dynamic_result op=( PLUS | MINUS ) dynamic_result - | LEFT_RBRACKET dynamic_result RIGHT_RBRACKET - | dynamic_ - ; - -dynamic_ : id_ - | function_call_assignment - | array_selector - ; - -int_result : int_result op=( MUL | DIV | MOD ) int_result - | int_result op=( PLUS | MINUS ) int_result - | LEFT_RBRACKET int_result RIGHT_RBRACKET - | int_t - ; - -float_result : float_result op=( MUL | DIV | MOD ) float_result - | int_result op=( MUL | DIV | MOD ) float_result - | float_result op=( MUL | DIV | MOD ) int_result - | float_result op=( PLUS | MINUS ) float_result - | int_result op=( PLUS | MINUS ) float_result - | float_result op=( PLUS | MINUS ) int_result - | LEFT_RBRACKET float_result RIGHT_RBRACKET - | float_t - ; - -string_result : string_result op=MUL int_result - | int_result op=MUL string_result - | string_result op=PLUS string_result - | literal_t - ; - -comparison_list : left=comparison op=BIT_AND right=comparison_list - | left=comparison op=AND right=comparison_list - | left=comparison op=BIT_OR right=comparison_list - | left=comparison op=OR right=comparison_list - | LEFT_RBRACKET comparison_list RIGHT_RBRACKET - | comparison - ; - -comparison : left=comp_var op=( LESS | GREATER | LESS_EQUAL | GREATER_EQUAL ) right=comp_var - | left=comp_var op=( EQUAL | NOT_EQUAL ) right=comp_var - ; - -comp_var : all_result - | array_selector - | id_ - ; +grammar Corundum; -lvalue : id_ - //| id_global - ; +prog + : expression_list EOF + ; + +expression_list + : expression terminator + | expression_list expression terminator + | terminator + ; + +expression + : function_definition + | function_inline_call + | require_block + | if_statement + | unless_statement + | rvalue + | return_statement + | while_statement + | for_statement + | pir_inline + ; + +global_get + : var_name = lvalue op = ASSIGN global_name = id_global + ; + +global_set + : global_name = id_global op = ASSIGN result = all_result + ; + +global_result + : id_global + ; + +function_inline_call + : function_call + ; + +require_block + : REQUIRE literal_t + ; + +pir_inline + : PIR crlf pir_expression_list END + ; + +pir_expression_list + : expression_list + ; + +function_definition + : function_definition_header function_definition_body END + ; + +function_definition_body + : expression_list + ; + +function_definition_header + : DEF function_name crlf + | DEF function_name function_definition_params crlf + ; + +function_name + : id_function + | id_ + ; + +function_definition_params + : LEFT_RBRACKET RIGHT_RBRACKET + | LEFT_RBRACKET function_definition_params_list RIGHT_RBRACKET + | function_definition_params_list + ; + +function_definition_params_list + : function_definition_param_id + | function_definition_params_list COMMA function_definition_param_id + ; + +function_definition_param_id + : id_ + ; + +return_statement + : RETURN all_result + ; + +function_call + : name = function_name LEFT_RBRACKET params = function_call_param_list RIGHT_RBRACKET + | name = function_name params = function_call_param_list + | name = function_name LEFT_RBRACKET RIGHT_RBRACKET + ; + +function_call_param_list + : function_call_params + ; + +function_call_params + : function_param + | function_call_params COMMA function_param + ; + +function_param + : (function_unnamed_param | function_named_param) + ; + +function_unnamed_param + : (int_result | float_result | string_result | dynamic_result) + ; + +function_named_param + : id_ op = ASSIGN (int_result | float_result | string_result | dynamic_result) + ; + +function_call_assignment + : function_call + ; + +all_result + : (int_result | float_result | string_result | dynamic_result | global_result) + ; + +elsif_statement + : if_elsif_statement + ; + +if_elsif_statement + : ELSIF cond_expression crlf statement_body + | ELSIF cond_expression crlf statement_body else_token crlf statement_body + | ELSIF cond_expression crlf statement_body if_elsif_statement + ; + +if_statement + : IF cond_expression crlf statement_body END + | IF cond_expression crlf statement_body else_token crlf statement_body END + | IF cond_expression crlf statement_body elsif_statement END + ; + +unless_statement + : UNLESS cond_expression crlf statement_body END + | UNLESS cond_expression crlf statement_body else_token crlf statement_body END + | UNLESS cond_expression crlf statement_body elsif_statement END + ; + +while_statement + : WHILE cond_expression crlf statement_body END + ; + +for_statement + : FOR LEFT_RBRACKET init_expression SEMICOLON cond_expression SEMICOLON loop_expression RIGHT_RBRACKET crlf statement_body END + | FOR init_expression SEMICOLON cond_expression SEMICOLON loop_expression crlf statement_body END + ; + +init_expression + : for_init_list + ; + +all_assignment + : (int_assignment | float_assignment | string_assignment | dynamic_assignment) + ; + +for_init_list + : for_init_list COMMA all_assignment + | all_assignment + ; + +cond_expression + : comparison_list + ; + +loop_expression + : for_loop_list + ; + +for_loop_list + : for_loop_list COMMA all_assignment + | all_assignment + ; + +statement_body + : statement_expression_list + ; + +statement_expression_list + : expression terminator + | RETRY terminator + | break_expression terminator + | statement_expression_list expression terminator + | statement_expression_list RETRY terminator + | statement_expression_list break_expression terminator + ; + +assignment + : var_id = lvalue op = ASSIGN rvalue + | var_id = lvalue op = ( + PLUS_ASSIGN + | MINUS_ASSIGN + | MUL_ASSIGN + | DIV_ASSIGN + | MOD_ASSIGN + | EXP_ASSIGN + ) rvalue + ; + +dynamic_assignment + : var_id = lvalue op = ASSIGN dynamic_result + | var_id = lvalue op = ( + PLUS_ASSIGN + | MINUS_ASSIGN + | MUL_ASSIGN + | DIV_ASSIGN + | MOD_ASSIGN + | EXP_ASSIGN + ) dynamic_result + ; + +int_assignment + : var_id = lvalue op = ASSIGN int_result + | var_id = lvalue op = ( + PLUS_ASSIGN + | MINUS_ASSIGN + | MUL_ASSIGN + | DIV_ASSIGN + | MOD_ASSIGN + | EXP_ASSIGN + ) int_result + ; + +float_assignment + : var_id = lvalue op = ASSIGN float_result + | var_id = lvalue op = ( + PLUS_ASSIGN + | MINUS_ASSIGN + | MUL_ASSIGN + | DIV_ASSIGN + | MOD_ASSIGN + | EXP_ASSIGN + ) float_result + ; + +string_assignment + : var_id = lvalue op = ASSIGN string_result + | var_id = lvalue op = PLUS_ASSIGN string_result + ; + +initial_array_assignment + : var_id = lvalue op = ASSIGN LEFT_SBRACKET RIGHT_SBRACKET + ; + +array_assignment + : arr_def = array_selector op = ASSIGN arr_val = all_result + ; + +array_definition + : LEFT_SBRACKET array_definition_elements RIGHT_SBRACKET + ; + +array_definition_elements + : (int_result | dynamic_result) + | array_definition_elements COMMA ( int_result | dynamic_result) + ; + +array_selector + : id_ LEFT_SBRACKET (int_result | dynamic_result) RIGHT_SBRACKET + | id_global LEFT_SBRACKET ( int_result | dynamic_result) RIGHT_SBRACKET + ; + +dynamic_result + : dynamic_result op = (MUL | DIV | MOD) int_result + | int_result op = ( MUL | DIV | MOD) dynamic_result + | dynamic_result op = ( MUL | DIV | MOD) float_result + | float_result op = ( MUL | DIV | MOD) dynamic_result + | dynamic_result op = ( MUL | DIV | MOD) dynamic_result + | dynamic_result op = MUL string_result + | string_result op = MUL dynamic_result + | dynamic_result op = ( PLUS | MINUS) int_result + | int_result op = ( PLUS | MINUS) dynamic_result + | dynamic_result op = ( PLUS | MINUS) float_result + | float_result op = ( PLUS | MINUS) dynamic_result + | dynamic_result op = ( PLUS | MINUS) dynamic_result + | LEFT_RBRACKET dynamic_result RIGHT_RBRACKET + | dynamic_ + ; + +dynamic_ + : id_ + | function_call_assignment + | array_selector + ; + +int_result + : int_result op = (MUL | DIV | MOD) int_result + | int_result op = ( PLUS | MINUS) int_result + | LEFT_RBRACKET int_result RIGHT_RBRACKET + | int_t + ; + +float_result + : float_result op = (MUL | DIV | MOD) float_result + | int_result op = ( MUL | DIV | MOD) float_result + | float_result op = ( MUL | DIV | MOD) int_result + | float_result op = ( PLUS | MINUS) float_result + | int_result op = ( PLUS | MINUS) float_result + | float_result op = ( PLUS | MINUS) int_result + | LEFT_RBRACKET float_result RIGHT_RBRACKET + | float_t + ; + +string_result + : string_result op = MUL int_result + | int_result op = MUL string_result + | string_result op = PLUS string_result + | literal_t + ; + +comparison_list + : left = comparison op = BIT_AND right = comparison_list + | left = comparison op = AND right = comparison_list + | left = comparison op = BIT_OR right = comparison_list + | left = comparison op = OR right = comparison_list + | LEFT_RBRACKET comparison_list RIGHT_RBRACKET + | comparison + ; + +comparison + : left = comp_var op = (LESS | GREATER | LESS_EQUAL | GREATER_EQUAL) right = comp_var + | left = comp_var op = ( EQUAL | NOT_EQUAL) right = comp_var + ; + +comp_var + : all_result + | array_selector + | id_ + ; + +lvalue + : id_ + //| id_global + ; + +rvalue + : lvalue + | initial_array_assignment + | array_assignment + | int_result + | float_result + | string_result + | global_set + | global_get + | dynamic_assignment + | string_assignment + | float_assignment + | int_assignment + | assignment + | function_call + | literal_t + | bool_t + | float_t + | int_t + | nil_t + | rvalue EXP rvalue + | ( NOT | BIT_NOT) rvalue + | rvalue ( MUL | DIV | MOD) rvalue + | rvalue ( PLUS | MINUS) rvalue + | rvalue ( BIT_SHL | BIT_SHR) rvalue + | rvalue BIT_AND rvalue + | rvalue ( BIT_OR | BIT_XOR) rvalue + | rvalue ( LESS | GREATER | LESS_EQUAL | GREATER_EQUAL) rvalue + | rvalue ( EQUAL | NOT_EQUAL) rvalue + | rvalue ( OR | AND) rvalue + | LEFT_RBRACKET rvalue RIGHT_RBRACKET + ; + +break_expression + : BREAK + ; + +literal_t + : LITERAL + ; + +float_t + : FLOAT + ; + +int_t + : INT + ; + +bool_t + : TRUE + | FALSE + ; + +nil_t + : NIL + ; + +id_ + : ID + ; + +id_global + : ID_GLOBAL + ; + +id_function + : ID_FUNCTION + ; + +terminator + : terminator SEMICOLON + | terminator crlf + | SEMICOLON + | crlf + ; + +else_token + : ELSE + ; + +crlf + : CRLF + ; + +fragment ESCAPED_QUOTE + : '\\"' + ; + +LITERAL + : '"' (ESCAPED_QUOTE | ~('\n' | '\r'))*? '"' + | '\'' ( ESCAPED_QUOTE | ~('\n' | '\r'))*? '\'' + ; + +COMMA + : ',' + ; + +SEMICOLON + : ';' + ; + +CRLF + : '\r'? '\n' + ; + +REQUIRE + : 'require' + ; + +END + : 'end' + ; + +DEF + : 'def' + ; + +RETURN + : 'return' + ; + +PIR + : 'pir' + ; + +IF + : 'if' + ; + +ELSE + : 'else' + ; + +ELSIF + : 'elsif' + ; + +UNLESS + : 'unless' + ; + +WHILE + : 'while' + ; + +RETRY + : 'retry' + ; + +BREAK + : 'break' + ; -rvalue : lvalue +FOR + : 'for' + ; - | initial_array_assignment - | array_assignment +TRUE + : 'true' + ; - | int_result - | float_result - | string_result +FALSE + : 'false' + ; - | global_set - | global_get - | dynamic_assignment - | string_assignment - | float_assignment - | int_assignment - | assignment +PLUS + : '+' + ; + +MINUS + : '-' + ; + +MUL + : '*' + ; + +DIV + : '/' + ; + +MOD + : '%' + ; + +EXP + : '**' + ; + +EQUAL + : '==' + ; - | function_call - | literal_t - | bool_t - | float_t - | int_t - | nil_t - - | rvalue EXP rvalue - - | ( NOT | BIT_NOT )rvalue - - | rvalue ( MUL | DIV | MOD ) rvalue - | rvalue ( PLUS | MINUS ) rvalue - - | rvalue ( BIT_SHL | BIT_SHR ) rvalue - - | rvalue BIT_AND rvalue - - | rvalue ( BIT_OR | BIT_XOR )rvalue - - | rvalue ( LESS | GREATER | LESS_EQUAL | GREATER_EQUAL ) rvalue - - | rvalue ( EQUAL | NOT_EQUAL ) rvalue - - | rvalue ( OR | AND ) rvalue - - | LEFT_RBRACKET rvalue RIGHT_RBRACKET - ; - -break_expression : BREAK; - -literal_t : LITERAL; - -float_t : FLOAT; - -int_t : INT; - -bool_t : TRUE - | FALSE - ; - -nil_t : NIL; - -id_ : ID; +NOT_EQUAL + : '!=' + ; -id_global : ID_GLOBAL; - -id_function : ID_FUNCTION; +GREATER + : '>' + ; -terminator : terminator SEMICOLON - | terminator crlf - | SEMICOLON - | crlf - ; +LESS + : '<' + ; -else_token : ELSE; +LESS_EQUAL + : '<=' + ; -crlf : CRLF; +GREATER_EQUAL + : '>=' + ; -fragment ESCAPED_QUOTE : '\\"'; -LITERAL : '"' ( ESCAPED_QUOTE | ~('\n'|'\r') )*? '"' - | '\'' ( ESCAPED_QUOTE | ~('\n'|'\r') )*? '\''; +ASSIGN + : '=' + ; -COMMA : ','; -SEMICOLON : ';'; -CRLF : '\r'? '\n'; +PLUS_ASSIGN + : '+=' + ; -REQUIRE : 'require'; -END : 'end'; -DEF : 'def'; -RETURN : 'return'; -PIR : 'pir'; +MINUS_ASSIGN + : '-=' + ; -IF: 'if'; -ELSE : 'else'; -ELSIF : 'elsif'; -UNLESS : 'unless'; -WHILE : 'while'; -RETRY : 'retry'; -BREAK : 'break'; -FOR : 'for'; +MUL_ASSIGN + : '*=' + ; -TRUE : 'true'; -FALSE : 'false'; +DIV_ASSIGN + : '/=' + ; -PLUS : '+'; -MINUS : '-'; -MUL : '*'; -DIV : '/'; -MOD : '%'; -EXP : '**'; +MOD_ASSIGN + : '%=' + ; -EQUAL : '=='; -NOT_EQUAL : '!='; -GREATER : '>'; -LESS : '<'; -LESS_EQUAL : '<='; -GREATER_EQUAL : '>='; +EXP_ASSIGN + : '**=' + ; -ASSIGN : '='; -PLUS_ASSIGN : '+='; -MINUS_ASSIGN : '-='; -MUL_ASSIGN : '*='; -DIV_ASSIGN : '/='; -MOD_ASSIGN : '%='; -EXP_ASSIGN : '**='; +BIT_AND + : '&' + ; -BIT_AND : '&'; -BIT_OR : '|'; -BIT_XOR : '^'; -BIT_NOT : '~'; -BIT_SHL : '<<'; -BIT_SHR : '>>'; +BIT_OR + : '|' + ; -AND : 'and' | '&&'; -OR : 'or' | '||'; -NOT : 'not' | '!'; +BIT_XOR + : '^' + ; -LEFT_RBRACKET : '('; -RIGHT_RBRACKET : ')'; -LEFT_SBRACKET : '['; -RIGHT_SBRACKET : ']'; +BIT_NOT + : '~' + ; -NIL : 'nil'; +BIT_SHL + : '<<' + ; -SL_COMMENT : ('#' ~('\r' | '\n')* '\r'? '\n') -> skip; -ML_COMMENT : ('=begin' .*? '=end' '\r'? '\n') -> skip; -WS : (' '|'\t')+ -> skip; +BIT_SHR + : '>>' + ; -INT : [0-9]+; -FLOAT : [0-9]*'.'[0-9]+; -ID : [a-zA-Z_][a-zA-Z0-9_]*; -ID_GLOBAL : '$'ID; -ID_FUNCTION : ID[?]; +AND + : 'and' + | '&&' + ; + +OR + : 'or' + | '||' + ; + +NOT + : 'not' + | '!' + ; + +LEFT_RBRACKET + : '(' + ; + +RIGHT_RBRACKET + : ')' + ; + +LEFT_SBRACKET + : '[' + ; + +RIGHT_SBRACKET + : ']' + ; + +NIL + : 'nil' + ; + +SL_COMMENT + : ('#' ~('\r' | '\n')* '\r'? '\n') -> skip + ; + +ML_COMMENT + : ('=begin' .*? '=end' '\r'? '\n') -> skip + ; + +WS + : (' ' | '\t')+ -> skip + ; + +INT + : [0-9]+ + ; + +FLOAT + : [0-9]* '.' [0-9]+ + ; + +ID + : [a-zA-Z_][a-zA-Z0-9_]* + ; + +ID_GLOBAL + : '$' ID + ; + +ID_FUNCTION + : ID [?] + ; \ No newline at end of file diff --git a/rust/RustLexer.g4 b/rust/RustLexer.g4 index 305823784d..dfd351a51a 100644 --- a/rust/RustLexer.g4 +++ b/rust/RustLexer.g4 @@ -16,165 +16,120 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER I OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -lexer grammar RustLexer - ; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +lexer grammar RustLexer; options { - superClass = RustLexerBase; + superClass = RustLexerBase; } // https://doc.rust-lang.org/reference/keywords.html strict -KW_AS: 'as'; -KW_BREAK: 'break'; -KW_CONST: 'const'; -KW_CONTINUE: 'continue'; -KW_CRATE: 'crate'; -KW_ELSE: 'else'; -KW_ENUM: 'enum'; -KW_EXTERN: 'extern'; -KW_FALSE: 'false'; -KW_FN: 'fn'; -KW_FOR: 'for'; -KW_IF: 'if'; -KW_IMPL: 'impl'; -KW_IN: 'in'; -KW_LET: 'let'; -KW_LOOP: 'loop'; -KW_MATCH: 'match'; -KW_MOD: 'mod'; -KW_MOVE: 'move'; -KW_MUT: 'mut'; -KW_PUB: 'pub'; -KW_REF: 'ref'; -KW_RETURN: 'return'; -KW_SELFVALUE: 'self'; -KW_SELFTYPE: 'Self'; -KW_STATIC: 'static'; -KW_STRUCT: 'struct'; -KW_SUPER: 'super'; -KW_TRAIT: 'trait'; -KW_TRUE: 'true'; -KW_TYPE: 'type'; -KW_UNSAFE: 'unsafe'; -KW_USE: 'use'; -KW_WHERE: 'where'; -KW_WHILE: 'while'; +KW_AS : 'as'; +KW_BREAK : 'break'; +KW_CONST : 'const'; +KW_CONTINUE : 'continue'; +KW_CRATE : 'crate'; +KW_ELSE : 'else'; +KW_ENUM : 'enum'; +KW_EXTERN : 'extern'; +KW_FALSE : 'false'; +KW_FN : 'fn'; +KW_FOR : 'for'; +KW_IF : 'if'; +KW_IMPL : 'impl'; +KW_IN : 'in'; +KW_LET : 'let'; +KW_LOOP : 'loop'; +KW_MATCH : 'match'; +KW_MOD : 'mod'; +KW_MOVE : 'move'; +KW_MUT : 'mut'; +KW_PUB : 'pub'; +KW_REF : 'ref'; +KW_RETURN : 'return'; +KW_SELFVALUE : 'self'; +KW_SELFTYPE : 'Self'; +KW_STATIC : 'static'; +KW_STRUCT : 'struct'; +KW_SUPER : 'super'; +KW_TRAIT : 'trait'; +KW_TRUE : 'true'; +KW_TYPE : 'type'; +KW_UNSAFE : 'unsafe'; +KW_USE : 'use'; +KW_WHERE : 'where'; +KW_WHILE : 'while'; // 2018+ -KW_ASYNC: 'async'; -KW_AWAIT: 'await'; -KW_DYN: 'dyn'; +KW_ASYNC : 'async'; +KW_AWAIT : 'await'; +KW_DYN : 'dyn'; // reserved -KW_ABSTRACT: 'abstract'; -KW_BECOME: 'become'; -KW_BOX: 'box'; -KW_DO: 'do'; -KW_FINAL: 'final'; -KW_MACRO: 'macro'; -KW_OVERRIDE: 'override'; -KW_PRIV: 'priv'; -KW_TYPEOF: 'typeof'; -KW_UNSIZED: 'unsized'; -KW_VIRTUAL: 'virtual'; -KW_YIELD: 'yield'; +KW_ABSTRACT : 'abstract'; +KW_BECOME : 'become'; +KW_BOX : 'box'; +KW_DO : 'do'; +KW_FINAL : 'final'; +KW_MACRO : 'macro'; +KW_OVERRIDE : 'override'; +KW_PRIV : 'priv'; +KW_TYPEOF : 'typeof'; +KW_UNSIZED : 'unsized'; +KW_VIRTUAL : 'virtual'; +KW_YIELD : 'yield'; // reserved 2018+ KW_TRY: 'try'; // weak -KW_UNION: 'union'; -KW_STATICLIFETIME: '\'static'; +KW_UNION : 'union'; +KW_STATICLIFETIME : '\'static'; -KW_MACRORULES: 'macro_rules'; -KW_UNDERLINELIFETIME: '\'_'; -KW_DOLLARCRATE: '$crate'; +KW_MACRORULES : 'macro_rules'; +KW_UNDERLINELIFETIME : '\'_'; +KW_DOLLARCRATE : '$crate'; // rule itself allow any identifier, but keyword has been matched before NON_KEYWORD_IDENTIFIER: XID_Start XID_Continue* | '_' XID_Continue+; // [\p{L}\p{Nl}\p{Other_ID_Start}-\p{Pattern_Syntax}-\p{Pattern_White_Space}] -fragment XID_Start - : [\p{L}\p{Nl}] - | UNICODE_OIDS - ; +fragment XID_Start: [\p{L}\p{Nl}] | UNICODE_OIDS; // [\p{ID_Start}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\p{Other_ID_Continue}-\p{Pattern_Syntax}-\p{Pattern_White_Space}] -fragment XID_Continue - : XID_Start - | [\p{Mn}\p{Mc}\p{Nd}\p{Pc}] - | UNICODE_OIDC - ; - -fragment UNICODE_OIDS - : '\u1885'..'\u1886' - | '\u2118' - | '\u212e' - | '\u309b'..'\u309c' - ; - -fragment UNICODE_OIDC - : '\u00b7' - | '\u0387' - | '\u1369'..'\u1371' - | '\u19da' - ; +fragment XID_Continue: XID_Start | [\p{Mn}\p{Mc}\p{Nd}\p{Pc}] | UNICODE_OIDC; + +fragment UNICODE_OIDS: '\u1885' ..'\u1886' | '\u2118' | '\u212e' | '\u309b' ..'\u309c'; + +fragment UNICODE_OIDC: '\u00b7' | '\u0387' | '\u1369' ..'\u1371' | '\u19da'; RAW_IDENTIFIER: 'r#' NON_KEYWORD_IDENTIFIER; // comments https://doc.rust-lang.org/reference/comments.html LINE_COMMENT: ('//' (~[/!] | '//') ~[\r\n]* | '//') -> channel (HIDDEN); -BLOCK_COMMENT - : - ( - '/*' - ( - ~[*!] - | '**' - | BLOCK_COMMENT_OR_DOC - ) - ( - BLOCK_COMMENT_OR_DOC - | ~[*] - )*? '*/' - | '/**/' - | '/***/' - ) -> channel (HIDDEN) - ; +BLOCK_COMMENT: + ( + '/*' (~[*!] | '**' | BLOCK_COMMENT_OR_DOC) (BLOCK_COMMENT_OR_DOC | ~[*])*? '*/' + | '/**/' + | '/***/' + ) -> channel (HIDDEN) +; INNER_LINE_DOC: '//!' ~[\n\r]* -> channel (HIDDEN); // isolated cr -INNER_BLOCK_DOC - : '/*!' - ( - BLOCK_COMMENT_OR_DOC - | ~[*] - )*? '*/' -> channel (HIDDEN) - ; +INNER_BLOCK_DOC: '/*!' ( BLOCK_COMMENT_OR_DOC | ~[*])*? '*/' -> channel (HIDDEN); OUTER_LINE_DOC: '///' (~[/] ~[\n\r]*)? -> channel (HIDDEN); // isolated cr -OUTER_BLOCK_DOC - : '/**' - ( - ~[*] - | BLOCK_COMMENT_OR_DOC - ) - ( - BLOCK_COMMENT_OR_DOC - | ~[*] - )*? '*/' -> channel (HIDDEN) - ; - -BLOCK_COMMENT_OR_DOC - : - ( - BLOCK_COMMENT - | INNER_BLOCK_DOC - | OUTER_BLOCK_DOC - ) -> channel (HIDDEN) - ; +OUTER_BLOCK_DOC: + '/**' (~[*] | BLOCK_COMMENT_OR_DOC) (BLOCK_COMMENT_OR_DOC | ~[*])*? '*/' -> channel (HIDDEN) +; + +BLOCK_COMMENT_OR_DOC: ( BLOCK_COMMENT | INNER_BLOCK_DOC | OUTER_BLOCK_DOC) -> channel (HIDDEN); SHEBANG: {this.SOF()}? '\ufeff'? '#!' ~[\r\n]* -> channel(HIDDEN); @@ -182,30 +137,13 @@ SHEBANG: {this.SOF()}? '\ufeff'? '#!' ~[\r\n]* -> channel(HIDDEN); // : '\r' {_input.LA(1)!='\n'}// not followed with \n ; // whitespace https://doc.rust-lang.org/reference/whitespace.html -WHITESPACE: [\p{Zs}] -> channel(HIDDEN); -NEWLINE: ('\r\n' | [\r\n]) -> channel(HIDDEN); +WHITESPACE : [\p{Zs}] -> channel(HIDDEN); +NEWLINE : ('\r\n' | [\r\n]) -> channel(HIDDEN); // tokens char and string -CHAR_LITERAL - : '\'' - ( - ~['\\\n\r\t] - | QUOTE_ESCAPE - | ASCII_ESCAPE - | UNICODE_ESCAPE - ) '\'' - ; - -STRING_LITERAL - : '"' - ( - ~["] - | QUOTE_ESCAPE - | ASCII_ESCAPE - | UNICODE_ESCAPE - | ESC_NEWLINE - )* '"' - ; +CHAR_LITERAL: '\'' ( ~['\\\n\r\t] | QUOTE_ESCAPE | ASCII_ESCAPE | UNICODE_ESCAPE) '\''; + +STRING_LITERAL: '"' ( ~["] | QUOTE_ESCAPE | ASCII_ESCAPE | UNICODE_ESCAPE | ESC_NEWLINE)* '"'; RAW_STRING_LITERAL: 'r' RAW_STRING_CONTENT; @@ -223,9 +161,9 @@ fragment BYTE_ESCAPE: '\\x' HEX_DIGIT HEX_DIGIT | COMMON_ESCAPE; fragment COMMON_ESCAPE: '\\' [nrt\\0]; -fragment UNICODE_ESCAPE - : '\\u{' HEX_DIGIT HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? '}' - ; +fragment UNICODE_ESCAPE: + '\\u{' HEX_DIGIT HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? HEX_DIGIT? '}' +; fragment QUOTE_ESCAPE: '\\' ['"]; @@ -233,15 +171,7 @@ fragment ESC_NEWLINE: '\\' '\n'; // number -INTEGER_LITERAL - : - ( - DEC_LITERAL - | BIN_LITERAL - | OCT_LITERAL - | HEX_LITERAL - ) INTEGER_SUFFIX? - ; +INTEGER_LITERAL: ( DEC_LITERAL | BIN_LITERAL | OCT_LITERAL | HEX_LITERAL) INTEGER_SUFFIX?; DEC_LITERAL: DEC_DIGIT (DEC_DIGIT | '_')*; @@ -251,28 +181,27 @@ OCT_LITERAL: '0o' '_'* OCT_DIGIT (OCT_DIGIT | '_')*; BIN_LITERAL: '0b' '_'* [01] [01_]*; -FLOAT_LITERAL - : {this.floatLiteralPossible()}? (DEC_LITERAL '.' {this.floatDotPossible()}? - | DEC_LITERAL - ( - '.' DEC_LITERAL - )? FLOAT_EXPONENT? FLOAT_SUFFIX?) - ; - -fragment INTEGER_SUFFIX - : 'u8' - | 'u16' - | 'u32' - | 'u64' - | 'u128' - | 'usize' - | 'i8' - | 'i16' - | 'i32' - | 'i64' - | 'i128' - | 'isize' - ; +FLOAT_LITERAL: + {this.floatLiteralPossible()}? ( + DEC_LITERAL '.' {this.floatDotPossible()}? + | DEC_LITERAL ( '.' DEC_LITERAL)? FLOAT_EXPONENT? FLOAT_SUFFIX? + ) +; + +fragment INTEGER_SUFFIX: + 'u8' + | 'u16' + | 'u32' + | 'u64' + | 'u128' + | 'usize' + | 'i8' + | 'i16' + | 'i32' + | 'i64' + | 'i128' + | 'isize' +; fragment FLOAT_SUFFIX: 'f32' | 'f64'; @@ -288,54 +217,54 @@ fragment HEX_DIGIT: [0-9a-fA-F]; LIFETIME_OR_LABEL: '\'' NON_KEYWORD_IDENTIFIER; -PLUS: '+'; -MINUS: '-'; -STAR: '*'; -SLASH: '/'; -PERCENT: '%'; -CARET: '^'; -NOT: '!'; -AND: '&'; -OR: '|'; -ANDAND: '&&'; -OROR: '||'; +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +SLASH : '/'; +PERCENT : '%'; +CARET : '^'; +NOT : '!'; +AND : '&'; +OR : '|'; +ANDAND : '&&'; +OROR : '||'; //SHL: '<<'; SHR: '>>'; removed to avoid confusion in type parameter -PLUSEQ: '+='; -MINUSEQ: '-='; -STAREQ: '*='; -SLASHEQ: '/='; -PERCENTEQ: '%='; -CARETEQ: '^='; -ANDEQ: '&='; -OREQ: '|='; -SHLEQ: '<<='; -SHREQ: '>>='; -EQ: '='; -EQEQ: '=='; -NE: '!='; -GT: '>'; -LT: '<'; -GE: '>='; -LE: '<='; -AT: '@'; -UNDERSCORE: '_'; -DOT: '.'; -DOTDOT: '..'; -DOTDOTDOT: '...'; -DOTDOTEQ: '..='; -COMMA: ','; -SEMI: ';'; -COLON: ':'; -PATHSEP: '::'; -RARROW: '->'; -FATARROW: '=>'; -POUND: '#'; -DOLLAR: '$'; -QUESTION: '?'; - -LCURLYBRACE: '{'; -RCURLYBRACE: '}'; -LSQUAREBRACKET: '['; -RSQUAREBRACKET: ']'; -LPAREN: '('; -RPAREN: ')'; +PLUSEQ : '+='; +MINUSEQ : '-='; +STAREQ : '*='; +SLASHEQ : '/='; +PERCENTEQ : '%='; +CARETEQ : '^='; +ANDEQ : '&='; +OREQ : '|='; +SHLEQ : '<<='; +SHREQ : '>>='; +EQ : '='; +EQEQ : '=='; +NE : '!='; +GT : '>'; +LT : '<'; +GE : '>='; +LE : '<='; +AT : '@'; +UNDERSCORE : '_'; +DOT : '.'; +DOTDOT : '..'; +DOTDOTDOT : '...'; +DOTDOTEQ : '..='; +COMMA : ','; +SEMI : ';'; +COLON : ':'; +PATHSEP : '::'; +RARROW : '->'; +FATARROW : '=>'; +POUND : '#'; +DOLLAR : '$'; +QUESTION : '?'; + +LCURLYBRACE : '{'; +RCURLYBRACE : '}'; +LSQUAREBRACKET : '['; +RSQUAREBRACKET : ']'; +LPAREN : '('; +RPAREN : ')'; \ No newline at end of file diff --git a/rust/RustParser.g4 b/rust/RustParser.g4 index bc50c3bafb..13fbca9a17 100644 --- a/rust/RustParser.g4 +++ b/rust/RustParser.g4 @@ -16,96 +16,112 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER I OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -parser grammar RustParser - ; +// $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 RustParser; options { - tokenVocab = RustLexer; - superClass = RustParserBase; + tokenVocab = RustLexer; + superClass = RustParserBase; } + // entry point // 4 crate - : innerAttribute* item* EOF - ; + : innerAttribute* item* EOF + ; // 3 macroInvocation - : simplePath '!' delimTokenTree - ; + : simplePath '!' delimTokenTree + ; + delimTokenTree - : '(' tokenTree* ')' - | '[' tokenTree* ']' - | '{' tokenTree* '}' - ; + : '(' tokenTree* ')' + | '[' tokenTree* ']' + | '{' tokenTree* '}' + ; + tokenTree - : tokenTreeToken+ - | delimTokenTree - ; + : tokenTreeToken+ + | delimTokenTree + ; + tokenTreeToken - : macroIdentifierLikeToken - | macroLiteralToken - | macroPunctuationToken - | macroRepOp - | '$' - ; + : macroIdentifierLikeToken + | macroLiteralToken + | macroPunctuationToken + | macroRepOp + | '$' + ; macroInvocationSemi - : simplePath '!' '(' tokenTree* ')' ';' - | simplePath '!' '[' tokenTree* ']' ';' - | simplePath '!' '{' tokenTree* '}' - ; + : simplePath '!' '(' tokenTree* ')' ';' + | simplePath '!' '[' tokenTree* ']' ';' + | simplePath '!' '{' tokenTree* '}' + ; // 3.1 macroRulesDefinition - : 'macro_rules' '!' identifier macroRulesDef - ; + : 'macro_rules' '!' identifier macroRulesDef + ; + macroRulesDef - : '(' macroRules ')' ';' - | '[' macroRules ']' ';' - | '{' macroRules '}' - ; + : '(' macroRules ')' ';' + | '[' macroRules ']' ';' + | '{' macroRules '}' + ; + macroRules - : macroRule (';' macroRule)* ';'? - ; + : macroRule (';' macroRule)* ';'? + ; + macroRule - : macroMatcher '=>' macroTranscriber - ; + : macroMatcher '=>' macroTranscriber + ; + macroMatcher - : '(' macroMatch* ')' - | '[' macroMatch* ']' - | '{' macroMatch* '}' - ; + : '(' macroMatch* ')' + | '[' macroMatch* ']' + | '{' macroMatch* '}' + ; + macroMatch - : macroMatchToken+ - | macroMatcher - | '$' (identifier | 'self') ':' macroFragSpec - | '$' '(' macroMatch+ ')' macroRepSep? macroRepOp - ; + : macroMatchToken+ + | macroMatcher + | '$' (identifier | 'self') ':' macroFragSpec + | '$' '(' macroMatch+ ')' macroRepSep? macroRepOp + ; + macroMatchToken - : macroIdentifierLikeToken - | macroLiteralToken - | macroPunctuationToken - | macroRepOp - ; + : macroIdentifierLikeToken + | macroLiteralToken + | macroPunctuationToken + | macroRepOp + ; + macroFragSpec - : identifier // do validate here is wasting token - ; + : identifier // do validate here is wasting token + ; + macroRepSep - : macroIdentifierLikeToken - | macroLiteralToken - | macroPunctuationToken - | '$' - ; + : macroIdentifierLikeToken + | macroLiteralToken + | macroPunctuationToken + | '$' + ; + macroRepOp - : '*' - | '+' - | '?' - ; + : '*' + | '+' + | '?' + ; + macroTranscriber - : delimTokenTree - ; + : delimTokenTree + ; //configurationPredicate // : configurationOption | configurationAll | configurationAny | configurationNot ; configurationOption: identifier ( @@ -118,251 +134,278 @@ macroTranscriber // 6 item - : outerAttribute* (visItem | macroItem) - ; + : outerAttribute* (visItem | macroItem) + ; + visItem - : visibility? - ( - module - | externCrate - | useDeclaration - | function_ - | typeAlias - | struct_ - | enumeration - | union_ - | constantItem - | staticItem - | trait_ - | implementation - | externBlock - ) - ; + : visibility? ( + module + | externCrate + | useDeclaration + | function_ + | typeAlias + | struct_ + | enumeration + | union_ + | constantItem + | staticItem + | trait_ + | implementation + | externBlock + ) + ; + macroItem - : macroInvocationSemi - | macroRulesDefinition - ; + : macroInvocationSemi + | macroRulesDefinition + ; // 6.1 module - : 'unsafe'? 'mod' identifier (';' | '{' innerAttribute* item* '}') - ; + : 'unsafe'? 'mod' identifier (';' | '{' innerAttribute* item* '}') + ; // 6.2 externCrate - : 'extern' 'crate' crateRef asClause? ';' - ; + : 'extern' 'crate' crateRef asClause? ';' + ; + crateRef - : identifier - | 'self' - ; + : identifier + | 'self' + ; + asClause - : 'as' (identifier | '_') - ; + : 'as' (identifier | '_') + ; // 6.3 useDeclaration - : 'use' useTree ';' - ; + : 'use' useTree ';' + ; + useTree - : (simplePath? '::')? ('*' | '{' ( useTree (',' useTree)* ','?)? '}') - | simplePath ('as' (identifier | '_'))? - ; + : (simplePath? '::')? ('*' | '{' ( useTree (',' useTree)* ','?)? '}') + | simplePath ('as' (identifier | '_'))? + ; // 6.4 function_ - : functionQualifiers 'fn' identifier genericParams? '(' functionParameters? ')' functionReturnType? whereClause? - (blockExpression | ';') - ; + : functionQualifiers 'fn' identifier genericParams? '(' functionParameters? ')' functionReturnType? whereClause? ( + blockExpression + | ';' + ) + ; + functionQualifiers - : 'const'? 'async'? 'unsafe'? ('extern' abi?)? - ; + : 'const'? 'async'? 'unsafe'? ('extern' abi?)? + ; + abi - : STRING_LITERAL - | RAW_STRING_LITERAL - ; + : STRING_LITERAL + | RAW_STRING_LITERAL + ; + functionParameters - : selfParam ','? - | (selfParam ',')? functionParam (',' functionParam)* ','? - ; + : selfParam ','? + | (selfParam ',')? functionParam (',' functionParam)* ','? + ; + selfParam - : outerAttribute* (shorthandSelf | typedSelf) - ; + : outerAttribute* (shorthandSelf | typedSelf) + ; + shorthandSelf - : ('&' lifetime?)? 'mut'? 'self' - ; + : ('&' lifetime?)? 'mut'? 'self' + ; + typedSelf - : 'mut'? 'self' ':' type_ - ; + : 'mut'? 'self' ':' type_ + ; + functionParam - : outerAttribute* (functionParamPattern | '...' | type_) - ; + : outerAttribute* (functionParamPattern | '...' | type_) + ; + functionParamPattern - : pattern ':' (type_ | '...') - ; + : pattern ':' (type_ | '...') + ; + functionReturnType - : '->' type_ - ; + : '->' type_ + ; // 6.5 typeAlias - : 'type' identifier genericParams? whereClause? ('=' type_)? ';' - ; + : 'type' identifier genericParams? whereClause? ('=' type_)? ';' + ; // 6.6 struct_ - : structStruct - | tupleStruct - ; + : structStruct + | tupleStruct + ; + structStruct - : 'struct' identifier genericParams? whereClause? ('{' structFields? '}' | ';') - ; + : 'struct' identifier genericParams? whereClause? ('{' structFields? '}' | ';') + ; + tupleStruct - : 'struct' identifier genericParams? '(' tupleFields? ')' whereClause? ';' - ; + : 'struct' identifier genericParams? '(' tupleFields? ')' whereClause? ';' + ; + structFields - : structField (',' structField)* ','? - ; + : structField (',' structField)* ','? + ; + structField - : outerAttribute* visibility? identifier ':' type_ - ; + : outerAttribute* visibility? identifier ':' type_ + ; + tupleFields - : tupleField (',' tupleField)* ','? - ; + : tupleField (',' tupleField)* ','? + ; + tupleField - : outerAttribute* visibility? type_ - ; + : outerAttribute* visibility? type_ + ; // 6.7 enumeration - : 'enum' identifier genericParams? whereClause? '{' enumItems? '}' - ; + : 'enum' identifier genericParams? whereClause? '{' enumItems? '}' + ; + enumItems - : enumItem (',' enumItem)* ','? - ; + : enumItem (',' enumItem)* ','? + ; + enumItem - : outerAttribute* visibility? identifier - ( - enumItemTuple - | enumItemStruct - | enumItemDiscriminant - )? - ; + : outerAttribute* visibility? identifier ( + enumItemTuple + | enumItemStruct + | enumItemDiscriminant + )? + ; + enumItemTuple - : '(' tupleFields? ')' - ; + : '(' tupleFields? ')' + ; + enumItemStruct - : '{' structFields? '}' - ; + : '{' structFields? '}' + ; + enumItemDiscriminant - : '=' expression - ; + : '=' expression + ; // 6.8 union_ - : 'union' identifier genericParams? whereClause? '{' structFields '}' - ; + : 'union' identifier genericParams? whereClause? '{' structFields '}' + ; // 6.9 constantItem - : 'const' (identifier | '_') ':' type_ ('=' expression)? ';' - ; + : 'const' (identifier | '_') ':' type_ ('=' expression)? ';' + ; // 6.10 staticItem - : 'static' 'mut'? identifier ':' type_ ('=' expression)? ';' - ; + : 'static' 'mut'? identifier ':' type_ ('=' expression)? ';' + ; // 6.11 trait_ - : 'unsafe'? 'trait' identifier genericParams? (':' typeParamBounds?)? whereClause? '{' innerAttribute* associatedItem* '}' - ; + : 'unsafe'? 'trait' identifier genericParams? (':' typeParamBounds?)? whereClause? '{' innerAttribute* associatedItem* '}' + ; // 6.12 implementation - : inherentImpl - | traitImpl - ; + : inherentImpl + | traitImpl + ; + inherentImpl - : 'impl' genericParams? type_ whereClause? '{' innerAttribute* associatedItem* '}' - ; + : 'impl' genericParams? type_ whereClause? '{' innerAttribute* associatedItem* '}' + ; + traitImpl - : 'unsafe'? 'impl' genericParams? '!'? typePath 'for' type_ whereClause? '{' innerAttribute* associatedItem* '}' - ; + : 'unsafe'? 'impl' genericParams? '!'? typePath 'for' type_ whereClause? '{' innerAttribute* associatedItem* '}' + ; // 6.13 externBlock - : 'unsafe'? 'extern' abi? '{' innerAttribute* externalItem* '}' - ; + : 'unsafe'? 'extern' abi? '{' innerAttribute* externalItem* '}' + ; + externalItem - : outerAttribute* - ( - macroInvocationSemi - | visibility? ( staticItem | function_) - ) - ; + : outerAttribute* (macroInvocationSemi | visibility? ( staticItem | function_)) + ; // 6.14 genericParams - : '<' ((genericParam ',')* genericParam ','? )?'>' - ; + : '<' ((genericParam ',')* genericParam ','?)? '>' + ; + genericParam - : outerAttribute* - ( - lifetimeParam - | typeParam - | constParam - ); + : outerAttribute* (lifetimeParam | typeParam | constParam) + ; + lifetimeParam - : outerAttribute? LIFETIME_OR_LABEL (':' lifetimeBounds)? - ; + : outerAttribute? LIFETIME_OR_LABEL (':' lifetimeBounds)? + ; + typeParam - : outerAttribute? identifier (':' typeParamBounds?)? ('=' type_)? - ; + : outerAttribute? identifier (':' typeParamBounds?)? ('=' type_)? + ; + constParam - : 'const' identifier ':' type_ - ; + : 'const' identifier ':' type_ + ; whereClause - : 'where' (whereClauseItem ',')* whereClauseItem? - ; + : 'where' (whereClauseItem ',')* whereClauseItem? + ; + whereClauseItem - : lifetimeWhereClauseItem - | typeBoundWhereClauseItem - ; + : lifetimeWhereClauseItem + | typeBoundWhereClauseItem + ; + lifetimeWhereClauseItem - : lifetime ':' lifetimeBounds - ; + : lifetime ':' lifetimeBounds + ; + typeBoundWhereClauseItem - : forLifetimes? type_ ':' typeParamBounds? - ; + : forLifetimes? type_ ':' typeParamBounds? + ; + forLifetimes - : 'for' genericParams - ; + : 'for' genericParams + ; // 6.15 associatedItem - : outerAttribute* - ( - macroInvocationSemi - | visibility? ( typeAlias | constantItem | function_ ) - ) - ; + : outerAttribute* (macroInvocationSemi | visibility? ( typeAlias | constantItem | function_)) + ; // 7 innerAttribute - : '#' '!' '[' attr ']' - ; + : '#' '!' '[' attr ']' + ; + outerAttribute - : '#' '[' attr ']' - ; + : '#' '[' attr ']' + ; + attr - : simplePath attrInput? - ; + : simplePath attrInput? + ; + attrInput - : delimTokenTree - | '=' literalExpression - ; // w/o suffix + : delimTokenTree + | '=' literalExpression + ; // w/o suffix //metaItem // : simplePath ( '=' literalExpression //w | '(' metaSeq ')' )? ; metaSeq: metaItemInner (',' metaItemInner)* ','?; @@ -375,717 +418,782 @@ attrInput // 8 statement - : ';' - | item - | letStatement - | expressionStatement - | macroInvocationSemi - ; + : ';' + | item + | letStatement + | expressionStatement + | macroInvocationSemi + ; letStatement - : outerAttribute* 'let' patternNoTopAlt (':' type_)? ('=' expression)? ';' - ; + : outerAttribute* 'let' patternNoTopAlt (':' type_)? ('=' expression)? ';' + ; expressionStatement - : expression ';' - | expressionWithBlock ';'? - ; + : expression ';' + | expressionWithBlock ';'? + ; // 8.2 expression - : outerAttribute+ expression # AttributedExpression // technical, remove left recursive - | literalExpression # LiteralExpression_ - | pathExpression # PathExpression_ - | expression '.' pathExprSegment '(' callParams? ')' # MethodCallExpression // 8.2.10 - | expression '.' identifier # FieldExpression // 8.2.11 - | expression '.' tupleIndex # TupleIndexingExpression // 8.2.7 - | expression '.' 'await' # AwaitExpression // 8.2.18 - | expression '(' callParams? ')' # CallExpression // 8.2.9 - | expression '[' expression ']' # IndexExpression // 8.2.6 - | expression '?' # ErrorPropagationExpression // 8.2.4 - | ('&' | '&&') 'mut'? expression # BorrowExpression // 8.2.4 - | '*' expression # DereferenceExpression // 8.2.4 - | ('-' | '!') expression # NegationExpression // 8.2.4 - | expression 'as' typeNoBounds # TypeCastExpression // 8.2.4 - | expression ('*' | '/' | '%') expression # ArithmeticOrLogicalExpression // 8.2.4 - | expression ('+' | '-') expression # ArithmeticOrLogicalExpression // 8.2.4 - | expression (shl | shr) expression # ArithmeticOrLogicalExpression // 8.2.4 - | expression '&' expression # ArithmeticOrLogicalExpression // 8.2.4 - | expression '^' expression # ArithmeticOrLogicalExpression // 8.2.4 - | expression '|' expression # ArithmeticOrLogicalExpression // 8.2.4 - | expression comparisonOperator expression # ComparisonExpression // 8.2.4 - | expression '&&' expression # LazyBooleanExpression // 8.2.4 - | expression '||' expression # LazyBooleanExpression // 8.2.4 - | expression '..' expression? # RangeExpression // 8.2.14 - | '..' expression? # RangeExpression // 8.2.14 - | '..=' expression # RangeExpression // 8.2.14 - | expression '..=' expression # RangeExpression // 8.2.14 - | expression '=' expression # AssignmentExpression // 8.2.4 - | expression compoundAssignOperator expression # CompoundAssignmentExpression // 8.2.4 - | 'continue' LIFETIME_OR_LABEL? expression? # ContinueExpression // 8.2.13 - | 'break' LIFETIME_OR_LABEL? expression? # BreakExpression // 8.2.13 - | 'return' expression? # ReturnExpression // 8.2.17 - | '(' innerAttribute* expression ')' # GroupedExpression // 8.2.5 - | '[' innerAttribute* arrayElements? ']' # ArrayExpression // 8.2.6 - | '(' innerAttribute* tupleElements? ')' # TupleExpression // 8.2.7 - | structExpression # StructExpression_ // 8.2.8 - | enumerationVariantExpression # EnumerationVariantExpression_ - | closureExpression # ClosureExpression_ // 8.2.12 - | expressionWithBlock # ExpressionWithBlock_ - | macroInvocation # MacroInvocationAsExpression - ; + : outerAttribute+ expression # AttributedExpression // technical, remove left recursive + | literalExpression # LiteralExpression_ + | pathExpression # PathExpression_ + | expression '.' pathExprSegment '(' callParams? ')' # MethodCallExpression // 8.2.10 + | expression '.' identifier # FieldExpression // 8.2.11 + | expression '.' tupleIndex # TupleIndexingExpression // 8.2.7 + | expression '.' 'await' # AwaitExpression // 8.2.18 + | expression '(' callParams? ')' # CallExpression // 8.2.9 + | expression '[' expression ']' # IndexExpression // 8.2.6 + | expression '?' # ErrorPropagationExpression // 8.2.4 + | ('&' | '&&') 'mut'? expression # BorrowExpression // 8.2.4 + | '*' expression # DereferenceExpression // 8.2.4 + | ('-' | '!') expression # NegationExpression // 8.2.4 + | expression 'as' typeNoBounds # TypeCastExpression // 8.2.4 + | expression ('*' | '/' | '%') expression # ArithmeticOrLogicalExpression // 8.2.4 + | expression ('+' | '-') expression # ArithmeticOrLogicalExpression // 8.2.4 + | expression (shl | shr) expression # ArithmeticOrLogicalExpression // 8.2.4 + | expression '&' expression # ArithmeticOrLogicalExpression // 8.2.4 + | expression '^' expression # ArithmeticOrLogicalExpression // 8.2.4 + | expression '|' expression # ArithmeticOrLogicalExpression // 8.2.4 + | expression comparisonOperator expression # ComparisonExpression // 8.2.4 + | expression '&&' expression # LazyBooleanExpression // 8.2.4 + | expression '||' expression # LazyBooleanExpression // 8.2.4 + | expression '..' expression? # RangeExpression // 8.2.14 + | '..' expression? # RangeExpression // 8.2.14 + | '..=' expression # RangeExpression // 8.2.14 + | expression '..=' expression # RangeExpression // 8.2.14 + | expression '=' expression # AssignmentExpression // 8.2.4 + | expression compoundAssignOperator expression # CompoundAssignmentExpression // 8.2.4 + | 'continue' LIFETIME_OR_LABEL? expression? # ContinueExpression // 8.2.13 + | 'break' LIFETIME_OR_LABEL? expression? # BreakExpression // 8.2.13 + | 'return' expression? # ReturnExpression // 8.2.17 + | '(' innerAttribute* expression ')' # GroupedExpression // 8.2.5 + | '[' innerAttribute* arrayElements? ']' # ArrayExpression // 8.2.6 + | '(' innerAttribute* tupleElements? ')' # TupleExpression // 8.2.7 + | structExpression # StructExpression_ // 8.2.8 + | enumerationVariantExpression # EnumerationVariantExpression_ + | closureExpression # ClosureExpression_ // 8.2.12 + | expressionWithBlock # ExpressionWithBlock_ + | macroInvocation # MacroInvocationAsExpression + ; comparisonOperator - : '==' - | '!=' - | '>' - | '<' - | '>=' - | '<=' - ; + : '==' + | '!=' + | '>' + | '<' + | '>=' + | '<=' + ; compoundAssignOperator - : '+=' - | '-=' - | '*=' - | '/=' - | '%=' - | '&=' - | '|=' - | '^=' - | '<<=' - | '>>=' - ; + : '+=' + | '-=' + | '*=' + | '/=' + | '%=' + | '&=' + | '|=' + | '^=' + | '<<=' + | '>>=' + ; expressionWithBlock - : outerAttribute+ expressionWithBlock // technical - | blockExpression - | asyncBlockExpression - | unsafeBlockExpression - | loopExpression - | ifExpression - | ifLetExpression - | matchExpression - ; + : outerAttribute+ expressionWithBlock // technical + | blockExpression + | asyncBlockExpression + | unsafeBlockExpression + | loopExpression + | ifExpression + | ifLetExpression + | matchExpression + ; // 8.2.1 literalExpression - : CHAR_LITERAL - | STRING_LITERAL - | RAW_STRING_LITERAL - | BYTE_LITERAL - | BYTE_STRING_LITERAL - | RAW_BYTE_STRING_LITERAL - | INTEGER_LITERAL - | FLOAT_LITERAL - | KW_TRUE - | KW_FALSE - ; + : CHAR_LITERAL + | STRING_LITERAL + | RAW_STRING_LITERAL + | BYTE_LITERAL + | BYTE_STRING_LITERAL + | RAW_BYTE_STRING_LITERAL + | INTEGER_LITERAL + | FLOAT_LITERAL + | KW_TRUE + | KW_FALSE + ; // 8.2.2 pathExpression - : pathInExpression - | qualifiedPathInExpression - ; + : pathInExpression + | qualifiedPathInExpression + ; // 8.2.3 blockExpression - : '{' innerAttribute* statements? '}' - ; + : '{' innerAttribute* statements? '}' + ; + statements - : statement+ expression? - | expression - ; + : statement+ expression? + | expression + ; asyncBlockExpression - : 'async' 'move'? blockExpression - ; + : 'async' 'move'? blockExpression + ; + unsafeBlockExpression - : 'unsafe' blockExpression - ; + : 'unsafe' blockExpression + ; // 8.2.6 arrayElements - : expression (',' expression)* ','? - | expression ';' expression - ; + : expression (',' expression)* ','? + | expression ';' expression + ; // 8.2.7 tupleElements - : (expression ',')+ expression? - ; + : (expression ',')+ expression? + ; + tupleIndex - : INTEGER_LITERAL - ; + : INTEGER_LITERAL + ; // 8.2.8 structExpression - : structExprStruct - | structExprTuple - | structExprUnit - ; + : structExprStruct + | structExprTuple + | structExprUnit + ; + structExprStruct - : pathInExpression '{' innerAttribute* (structExprFields | structBase)? '}' - ; + : pathInExpression '{' innerAttribute* (structExprFields | structBase)? '}' + ; + structExprFields - : structExprField (',' structExprField)* (',' structBase | ','?) - ; + : structExprField (',' structExprField)* (',' structBase | ','?) + ; + // outerAttribute here is not in doc structExprField - : outerAttribute* (identifier | (identifier | tupleIndex) ':' expression) - ; + : outerAttribute* (identifier | (identifier | tupleIndex) ':' expression) + ; + structBase - : '..' expression - ; + : '..' expression + ; + structExprTuple - : pathInExpression '(' innerAttribute* (expression ( ',' expression)* ','?)? ')' - ; + : pathInExpression '(' innerAttribute* (expression ( ',' expression)* ','?)? ')' + ; + structExprUnit - : pathInExpression - ; + : pathInExpression + ; enumerationVariantExpression - : enumExprStruct - | enumExprTuple - | enumExprFieldless - ; + : enumExprStruct + | enumExprTuple + | enumExprFieldless + ; + enumExprStruct - : pathInExpression '{' enumExprFields? '}' - ; + : pathInExpression '{' enumExprFields? '}' + ; + enumExprFields - : enumExprField (',' enumExprField)* ','? - ; + : enumExprField (',' enumExprField)* ','? + ; + enumExprField - : identifier - | (identifier | tupleIndex) ':' expression - ; + : identifier + | (identifier | tupleIndex) ':' expression + ; + enumExprTuple - : pathInExpression '(' (expression (',' expression)* ','?)? ')' - ; + : pathInExpression '(' (expression (',' expression)* ','?)? ')' + ; + enumExprFieldless - : pathInExpression - ; + : pathInExpression + ; // 8.2.9 callParams - : expression (',' expression)* ','? - ; + : expression (',' expression)* ','? + ; // 8.2.12 closureExpression - : 'move'? ('||' | '|' closureParameters? '|') - ( - expression - | '->' typeNoBounds blockExpression - ) - ; + : 'move'? ('||' | '|' closureParameters? '|') (expression | '->' typeNoBounds blockExpression) + ; + closureParameters - : closureParam (',' closureParam)* ','? - ; + : closureParam (',' closureParam)* ','? + ; + closureParam - : outerAttribute* pattern (':' type_)? - ; + : outerAttribute* pattern (':' type_)? + ; // 8.2.13 loopExpression - : loopLabel? - ( - infiniteLoopExpression - | predicateLoopExpression - | predicatePatternLoopExpression - | iteratorLoopExpression - ) - ; + : loopLabel? ( + infiniteLoopExpression + | predicateLoopExpression + | predicatePatternLoopExpression + | iteratorLoopExpression + ) + ; + infiniteLoopExpression - : 'loop' blockExpression - ; + : 'loop' blockExpression + ; + predicateLoopExpression - : 'while' expression /*except structExpression*/ blockExpression - ; + : 'while' expression /*except structExpression*/ blockExpression + ; + predicatePatternLoopExpression - : 'while' 'let' pattern '=' expression blockExpression - ; + : 'while' 'let' pattern '=' expression blockExpression + ; + iteratorLoopExpression - : 'for' pattern 'in' expression blockExpression - ; + : 'for' pattern 'in' expression blockExpression + ; + loopLabel - : LIFETIME_OR_LABEL ':' - ; + : LIFETIME_OR_LABEL ':' + ; // 8.2.15 ifExpression - : 'if' expression blockExpression - ( - 'else' (blockExpression | ifExpression | ifLetExpression) - )? - ; + : 'if' expression blockExpression ('else' (blockExpression | ifExpression | ifLetExpression))? + ; + ifLetExpression - : 'if' 'let' pattern '=' expression blockExpression - ( - 'else' (blockExpression | ifExpression | ifLetExpression) - )? - ; + : 'if' 'let' pattern '=' expression blockExpression ( + 'else' (blockExpression | ifExpression | ifLetExpression) + )? + ; // 8.2.16 matchExpression - : 'match' expression '{' innerAttribute* matchArms? '}' - ; + : 'match' expression '{' innerAttribute* matchArms? '}' + ; + matchArms - : (matchArm '=>' matchArmExpression)* matchArm '=>' expression ','? - ; + : (matchArm '=>' matchArmExpression)* matchArm '=>' expression ','? + ; + matchArmExpression - : expression ',' - | expressionWithBlock ','? - ; + : expression ',' + | expressionWithBlock ','? + ; + matchArm - : outerAttribute* pattern matchArmGuard? - ; + : outerAttribute* pattern matchArmGuard? + ; matchArmGuard - : 'if' expression - ; + : 'if' expression + ; // 9 pattern - : '|'? patternNoTopAlt ('|' patternNoTopAlt)* - ; + : '|'? patternNoTopAlt ('|' patternNoTopAlt)* + ; patternNoTopAlt - : patternWithoutRange - | rangePattern - ; + : patternWithoutRange + | rangePattern + ; + patternWithoutRange - : literalPattern - | identifierPattern - | wildcardPattern - | restPattern - | referencePattern - | structPattern - | tupleStructPattern - | tuplePattern - | groupedPattern - | slicePattern - | pathPattern - | macroInvocation - ; + : literalPattern + | identifierPattern + | wildcardPattern + | restPattern + | referencePattern + | structPattern + | tupleStructPattern + | tuplePattern + | groupedPattern + | slicePattern + | pathPattern + | macroInvocation + ; literalPattern - : KW_TRUE - | KW_FALSE - | CHAR_LITERAL - | BYTE_LITERAL - | STRING_LITERAL - | RAW_STRING_LITERAL - | BYTE_STRING_LITERAL - | RAW_BYTE_STRING_LITERAL - | '-'? INTEGER_LITERAL - | '-'? FLOAT_LITERAL - ; + : KW_TRUE + | KW_FALSE + | CHAR_LITERAL + | BYTE_LITERAL + | STRING_LITERAL + | RAW_STRING_LITERAL + | BYTE_STRING_LITERAL + | RAW_BYTE_STRING_LITERAL + | '-'? INTEGER_LITERAL + | '-'? FLOAT_LITERAL + ; identifierPattern - : 'ref'? 'mut'? identifier ('@' pattern)? - ; + : 'ref'? 'mut'? identifier ('@' pattern)? + ; + wildcardPattern - : '_' - ; + : '_' + ; + restPattern - : '..' - ; + : '..' + ; + rangePattern - : rangePatternBound '..=' rangePatternBound # InclusiveRangePattern - | rangePatternBound '..' # HalfOpenRangePattern - | rangePatternBound '...' rangePatternBound # ObsoleteRangePattern - ; + : rangePatternBound '..=' rangePatternBound # InclusiveRangePattern + | rangePatternBound '..' # HalfOpenRangePattern + | rangePatternBound '...' rangePatternBound # ObsoleteRangePattern + ; + rangePatternBound - : CHAR_LITERAL - | BYTE_LITERAL - | '-'? INTEGER_LITERAL - | '-'? FLOAT_LITERAL - | pathPattern - ; + : CHAR_LITERAL + | BYTE_LITERAL + | '-'? INTEGER_LITERAL + | '-'? FLOAT_LITERAL + | pathPattern + ; + referencePattern - : ('&' | '&&') 'mut'? patternWithoutRange - ; + : ('&' | '&&') 'mut'? patternWithoutRange + ; + structPattern - : pathInExpression '{' structPatternElements? '}' - ; + : pathInExpression '{' structPatternElements? '}' + ; + structPatternElements - : structPatternFields (',' structPatternEtCetera?)? - | structPatternEtCetera - ; + : structPatternFields (',' structPatternEtCetera?)? + | structPatternEtCetera + ; + structPatternFields - : structPatternField (',' structPatternField)* - ; + : structPatternField (',' structPatternField)* + ; + structPatternField - : outerAttribute* - ( - tupleIndex ':' pattern - | identifier ':' pattern - | 'ref'? 'mut'? identifier - ) - ; + : outerAttribute* (tupleIndex ':' pattern | identifier ':' pattern | 'ref'? 'mut'? identifier) + ; + structPatternEtCetera - : outerAttribute* '..' - ; + : outerAttribute* '..' + ; + tupleStructPattern - : pathInExpression '(' tupleStructItems? ')' - ; + : pathInExpression '(' tupleStructItems? ')' + ; + tupleStructItems - : pattern (',' pattern)* ','? - ; + : pattern (',' pattern)* ','? + ; + tuplePattern - : '(' tuplePatternItems? ')' - ; + : '(' tuplePatternItems? ')' + ; + tuplePatternItems - : pattern ',' - | restPattern - | pattern (',' pattern)+ ','? - ; + : pattern ',' + | restPattern + | pattern (',' pattern)+ ','? + ; + groupedPattern - : '(' pattern ')' - ; + : '(' pattern ')' + ; + slicePattern - : '[' slicePatternItems? ']' - ; + : '[' slicePatternItems? ']' + ; + slicePatternItems - : pattern (',' pattern)* ','? - ; + : pattern (',' pattern)* ','? + ; + pathPattern - : pathInExpression - | qualifiedPathInExpression - ; + : pathInExpression + | qualifiedPathInExpression + ; // 10.1 type_ - : typeNoBounds - | implTraitType - | traitObjectType - ; + : typeNoBounds + | implTraitType + | traitObjectType + ; + typeNoBounds - : parenthesizedType - | implTraitTypeOneBound - | traitObjectTypeOneBound - | typePath - | tupleType - | neverType - | rawPointerType - | referenceType - | arrayType - | sliceType - | inferredType - | qualifiedPathInType - | bareFunctionType - | macroInvocation - ; + : parenthesizedType + | implTraitTypeOneBound + | traitObjectTypeOneBound + | typePath + | tupleType + | neverType + | rawPointerType + | referenceType + | arrayType + | sliceType + | inferredType + | qualifiedPathInType + | bareFunctionType + | macroInvocation + ; + parenthesizedType - : '(' type_ ')' - ; + : '(' type_ ')' + ; // 10.1.4 neverType - : '!' - ; + : '!' + ; // 10.1.5 tupleType - : '(' ((type_ ',')+ type_?)? ')' - ; + : '(' ((type_ ',')+ type_?)? ')' + ; // 10.1.6 arrayType - : '[' type_ ';' expression ']' - ; + : '[' type_ ';' expression ']' + ; // 10.1.7 sliceType - : '[' type_ ']' - ; + : '[' type_ ']' + ; // 10.1.13 referenceType - : '&' lifetime? 'mut'? typeNoBounds - ; + : '&' lifetime? 'mut'? typeNoBounds + ; + rawPointerType - : '*' ('mut' | 'const') typeNoBounds - ; + : '*' ('mut' | 'const') typeNoBounds + ; // 10.1.14 bareFunctionType - : forLifetimes? functionTypeQualifiers 'fn' '(' functionParametersMaybeNamedVariadic? ')' bareFunctionReturnType? - ; + : forLifetimes? functionTypeQualifiers 'fn' '(' functionParametersMaybeNamedVariadic? ')' bareFunctionReturnType? + ; + functionTypeQualifiers - : 'unsafe'? ('extern' abi?)? - ; + : 'unsafe'? ('extern' abi?)? + ; + bareFunctionReturnType - : '->' typeNoBounds - ; + : '->' typeNoBounds + ; + functionParametersMaybeNamedVariadic - : maybeNamedFunctionParameters - | maybeNamedFunctionParametersVariadic - ; + : maybeNamedFunctionParameters + | maybeNamedFunctionParametersVariadic + ; + maybeNamedFunctionParameters - : maybeNamedParam (',' maybeNamedParam)* ','? - ; + : maybeNamedParam (',' maybeNamedParam)* ','? + ; + maybeNamedParam - : outerAttribute* ((identifier | '_') ':')? type_ - ; + : outerAttribute* ((identifier | '_') ':')? type_ + ; + maybeNamedFunctionParametersVariadic - : (maybeNamedParam ',')* maybeNamedParam ',' outerAttribute* '...' - ; + : (maybeNamedParam ',')* maybeNamedParam ',' outerAttribute* '...' + ; // 10.1.15 traitObjectType - : 'dyn'? typeParamBounds - ; + : 'dyn'? typeParamBounds + ; + traitObjectTypeOneBound - : 'dyn'? traitBound - ; + : 'dyn'? traitBound + ; + implTraitType - : 'impl' typeParamBounds - ; + : 'impl' typeParamBounds + ; + implTraitTypeOneBound - : 'impl' traitBound - ; + : 'impl' traitBound + ; // 10.1.18 inferredType - : '_' - ; + : '_' + ; // 10.6 typeParamBounds - : typeParamBound ('+' typeParamBound)* '+'? - ; + : typeParamBound ('+' typeParamBound)* '+'? + ; + typeParamBound - : lifetime - | traitBound - ; + : lifetime + | traitBound + ; + traitBound - : '?'? forLifetimes? typePath - | '(' '?'? forLifetimes? typePath ')' - ; + : '?'? forLifetimes? typePath + | '(' '?'? forLifetimes? typePath ')' + ; + lifetimeBounds - : (lifetime '+')* lifetime? - ; + : (lifetime '+')* lifetime? + ; + lifetime - : LIFETIME_OR_LABEL - | '\'static' - | '\'_' - ; + : LIFETIME_OR_LABEL + | '\'static' + | '\'_' + ; // 12.4 simplePath - : '::'? simplePathSegment ('::' simplePathSegment)* - ; + : '::'? simplePathSegment ('::' simplePathSegment)* + ; + simplePathSegment - : identifier - | 'super' - | 'self' - | 'crate' - | '$crate' - ; + : identifier + | 'super' + | 'self' + | 'crate' + | '$crate' + ; pathInExpression - : '::'? pathExprSegment ('::' pathExprSegment)* - ; + : '::'? pathExprSegment ('::' pathExprSegment)* + ; + pathExprSegment - : pathIdentSegment ('::' genericArgs)? - ; + : pathIdentSegment ('::' genericArgs)? + ; + pathIdentSegment - : identifier - | 'super' - | 'self' - | 'Self' - | 'crate' - | '$crate' - ; + : identifier + | 'super' + | 'self' + | 'Self' + | 'crate' + | '$crate' + ; //TODO: let x : T<_>=something; genericArgs - : '<' '>' - | '<' genericArgsLifetimes (',' genericArgsTypes)? (',' genericArgsBindings)? ','? '>' - | '<' genericArgsTypes (',' genericArgsBindings)? ','? '>' - | '<' (genericArg ',')* genericArg ','? '>' - ; + : '<' '>' + | '<' genericArgsLifetimes (',' genericArgsTypes)? (',' genericArgsBindings)? ','? '>' + | '<' genericArgsTypes (',' genericArgsBindings)? ','? '>' + | '<' (genericArg ',')* genericArg ','? '>' + ; + genericArg - : lifetime - | type_ - | genericArgsConst - | genericArgsBinding - ; + : lifetime + | type_ + | genericArgsConst + | genericArgsBinding + ; + genericArgsConst - : blockExpression - | '-'? literalExpression - | simplePathSegment - ; + : blockExpression + | '-'? literalExpression + | simplePathSegment + ; + genericArgsLifetimes - : lifetime (',' lifetime)* - ; + : lifetime (',' lifetime)* + ; + genericArgsTypes - : type_ (',' type_)* - ; + : type_ (',' type_)* + ; + genericArgsBindings - : genericArgsBinding (',' genericArgsBinding)* - ; + : genericArgsBinding (',' genericArgsBinding)* + ; + genericArgsBinding - : identifier '=' type_ - ; + : identifier '=' type_ + ; qualifiedPathInExpression - : qualifiedPathType ('::' pathExprSegment)+ - ; + : qualifiedPathType ('::' pathExprSegment)+ + ; + qualifiedPathType - : '<' type_ ('as' typePath)? '>' - ; + : '<' type_ ('as' typePath)? '>' + ; + qualifiedPathInType - : qualifiedPathType ('::' typePathSegment)+ - ; + : qualifiedPathType ('::' typePathSegment)+ + ; typePath - : '::'? typePathSegment ('::' typePathSegment)* - ; + : '::'? typePathSegment ('::' typePathSegment)* + ; + typePathSegment - : pathIdentSegment '::'? (genericArgs | typePathFn)? - ; + : pathIdentSegment '::'? (genericArgs | typePathFn)? + ; + typePathFn - : '(' typePathInputs? ')' ('->' type_)? - ; + : '(' typePathInputs? ')' ('->' type_)? + ; + typePathInputs - : type_ (',' type_)* ','? - ; + : type_ (',' type_)* ','? + ; // 12.6 visibility - : 'pub' ('(' ( 'crate' | 'self' | 'super' | 'in' simplePath) ')')? - ; + : 'pub' ('(' ( 'crate' | 'self' | 'super' | 'in' simplePath) ')')? + ; // technical identifier - : NON_KEYWORD_IDENTIFIER - | RAW_IDENTIFIER - | 'macro_rules' - ; + : NON_KEYWORD_IDENTIFIER + | RAW_IDENTIFIER + | 'macro_rules' + ; + keyword - : KW_AS - | KW_BREAK - | KW_CONST - | KW_CONTINUE - | KW_CRATE - | KW_ELSE - | KW_ENUM - | KW_EXTERN - | KW_FALSE - | KW_FN - | KW_FOR - | KW_IF - | KW_IMPL - | KW_IN - | KW_LET - | KW_LOOP - | KW_MATCH - | KW_MOD - | KW_MOVE - | KW_MUT - | KW_PUB - | KW_REF - | KW_RETURN - | KW_SELFVALUE - | KW_SELFTYPE - | KW_STATIC - | KW_STRUCT - | KW_SUPER - | KW_TRAIT - | KW_TRUE - | KW_TYPE - | KW_UNSAFE - | KW_USE - | KW_WHERE - | KW_WHILE - - // 2018+ - | KW_ASYNC - | KW_AWAIT - | KW_DYN - // reserved - | KW_ABSTRACT - | KW_BECOME - | KW_BOX - | KW_DO - | KW_FINAL - | KW_MACRO - | KW_OVERRIDE - | KW_PRIV - | KW_TYPEOF - | KW_UNSIZED - | KW_VIRTUAL - | KW_YIELD - | KW_TRY - | KW_UNION - | KW_STATICLIFETIME - ; + : KW_AS + | KW_BREAK + | KW_CONST + | KW_CONTINUE + | KW_CRATE + | KW_ELSE + | KW_ENUM + | KW_EXTERN + | KW_FALSE + | KW_FN + | KW_FOR + | KW_IF + | KW_IMPL + | KW_IN + | KW_LET + | KW_LOOP + | KW_MATCH + | KW_MOD + | KW_MOVE + | KW_MUT + | KW_PUB + | KW_REF + | KW_RETURN + | KW_SELFVALUE + | KW_SELFTYPE + | KW_STATIC + | KW_STRUCT + | KW_SUPER + | KW_TRAIT + | KW_TRUE + | KW_TYPE + | KW_UNSAFE + | KW_USE + | KW_WHERE + | KW_WHILE + + // 2018+ + | KW_ASYNC + | KW_AWAIT + | KW_DYN + // reserved + | KW_ABSTRACT + | KW_BECOME + | KW_BOX + | KW_DO + | KW_FINAL + | KW_MACRO + | KW_OVERRIDE + | KW_PRIV + | KW_TYPEOF + | KW_UNSIZED + | KW_VIRTUAL + | KW_YIELD + | KW_TRY + | KW_UNION + | KW_STATICLIFETIME + ; + macroIdentifierLikeToken - : keyword - | identifier - | KW_MACRORULES - | KW_UNDERLINELIFETIME - | KW_DOLLARCRATE - | LIFETIME_OR_LABEL - ; + : keyword + | identifier + | KW_MACRORULES + | KW_UNDERLINELIFETIME + | KW_DOLLARCRATE + | LIFETIME_OR_LABEL + ; + macroLiteralToken - : literalExpression - ; + : literalExpression + ; + // macroDelimiterToken: '{' | '}' | '[' | ']' | '(' | ')'; macroPunctuationToken - : '-' - //| '+' | '*' - | '/' - | '%' - | '^' - | '!' - | '&' - | '|' - | '&&' - | '||' - // already covered by '<' and '>' in macro | shl | shr - | '+=' - | '-=' - | '*=' - | '/=' - | '%=' - | '^=' - | '&=' - | '|=' - | '<<=' - | '>>=' - | '=' - | '==' - | '!=' - | '>' - | '<' - | '>=' - | '<=' - | '@' - | '_' - | '.' - | '..' - | '...' - | '..=' - | ',' - | ';' - | ':' - | '::' - | '->' - | '=>' - | '#' - //| '$' | '?' - ; + : '-' + //| '+' | '*' + | '/' + | '%' + | '^' + | '!' + | '&' + | '|' + | '&&' + | '||' + // already covered by '<' and '>' in macro | shl | shr + | '+=' + | '-=' + | '*=' + | '/=' + | '%=' + | '^=' + | '&=' + | '|=' + | '<<=' + | '>>=' + | '=' + | '==' + | '!=' + | '>' + | '<' + | '>=' + | '<=' + | '@' + | '_' + | '.' + | '..' + | '...' + | '..=' + | ',' + | ';' + | ':' + | '::' + | '->' + | '=>' + | '#' + //| '$' | '?' + ; // LA can be removed, legal rust code still pass but the cost is `let c = a < < b` will pass... i hope antlr5 can add // some new syntax? dsl? for these stuff so i needn't write it in (at least) 5 language shl - : '<' {this.next('<')}? '<' - ; + : '<' {this.next('<')}? '<' + ; + shr - : '>' {this.next('>')}? '>' - ; \ No newline at end of file + : '>' {this.next('>')}? '>' + ; \ No newline at end of file diff --git a/scala/Scala.g4 b/scala/Scala.g4 index 825022f8f0..2bdc0e3c9a 100644 --- a/scala/Scala.g4 +++ b/scala/Scala.g4 @@ -30,160 +30,166 @@ Derived from https://github.com/scala/scala/blob/2.12.x/spec/13-syntax-summary.md */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Scala; literal - : '-'? IntegerLiteral - | '-'? FloatingPointLiteral - | BooleanLiteral - | CharacterLiteral - | StringLiteral - | SymbolLiteral - | 'null' - ; + : '-'? IntegerLiteral + | '-'? FloatingPointLiteral + | BooleanLiteral + | CharacterLiteral + | StringLiteral + | SymbolLiteral + | 'null' + ; qualId - : Id ('.' Id)* - ; + : Id ('.' Id)* + ; ids - : Id (',' Id)* - ; + : Id (',' Id)* + ; stableId - : Id - | stableId '.' Id - | (Id '.')? ('this' | 'super' classQualifier? '.' Id) - ; + : Id + | stableId '.' Id + | (Id '.')? ('this' | 'super' classQualifier? '.' Id) + ; classQualifier - : '[' Id ']' - ; + : '[' Id ']' + ; type_ - : functionArgTypes '=>' type_ - | infixType existentialClause? - ; + : functionArgTypes '=>' type_ + | infixType existentialClause? + ; functionArgTypes - : infixType - | '(' (paramType (',' paramType)*)? ')' - ; + : infixType + | '(' (paramType (',' paramType)*)? ')' + ; existentialClause - : 'forSome' '{' existentialDcl+ '}' - ; + : 'forSome' '{' existentialDcl+ '}' + ; existentialDcl - : 'type' typeDcl - | 'val' valDcl - ; + : 'type' typeDcl + | 'val' valDcl + ; infixType - : compoundType (Id compoundType)* - ; + : compoundType (Id compoundType)* + ; compoundType - : annotType ('with' annotType)* refinement? - | refinement - ; + : annotType ('with' annotType)* refinement? + | refinement + ; annotType - : simpleType annotation* - ; + : simpleType annotation* + ; simpleType - : simpleType typeArgs - | simpleType '#' Id - | stableId ('.' 'type')? - | '(' types ')' - ; + : simpleType typeArgs + | simpleType '#' Id + | stableId ('.' 'type')? + | '(' types ')' + ; typeArgs - : '[' types ']' - ; + : '[' types ']' + ; types - : type_ (',' type_)* - ; + : type_ (',' type_)* + ; refinement - : NL? '{' refineStat+ '}' - ; + : NL? '{' refineStat+ '}' + ; refineStat - : dcl - | 'type' typeDef - ; + : dcl + | 'type' typeDef + ; typePat - : type_ - ; + : type_ + ; ascription - : ':' infixType - | ':' annotation + - | ':' '_' '*' - ; + : ':' infixType + | ':' annotation+ + | ':' '_' '*' + ; expr - : (bindings | 'implicit'? Id | '_') '=>' expr - | expr1 - ; + : (bindings | 'implicit'? Id | '_') '=>' expr + | expr1 + ; expr1 - : 'if' '(' expr ')' NL* expr ('else' expr)? - | 'while' '(' expr ')' NL* expr - | 'try' expr ('catch' expr)? ('finally' expr)? - | 'do' expr 'while' '(' expr ')' - | 'for' ('(' enumerators ')' | '{' enumerators '}') 'yield'? expr - | 'throw' expr - | 'return' expr? - | ((simpleExpr | simpleExpr1 '_'?) '.')? Id '=' expr - | simpleExpr1 argumentExprs '=' expr - | postfixExpr ascription? - | postfixExpr 'match' '{' caseClauses '}' - ; + : 'if' '(' expr ')' NL* expr ('else' expr)? + | 'while' '(' expr ')' NL* expr + | 'try' expr ('catch' expr)? ('finally' expr)? + | 'do' expr 'while' '(' expr ')' + | 'for' ('(' enumerators ')' | '{' enumerators '}') 'yield'? expr + | 'throw' expr + | 'return' expr? + | ((simpleExpr | simpleExpr1 '_'?) '.')? Id '=' expr + | simpleExpr1 argumentExprs '=' expr + | postfixExpr ascription? + | postfixExpr 'match' '{' caseClauses '}' + ; prefixDef - : '-' | '+' | '~' | '!' - ; + : '-' + | '+' + | '~' + | '!' + ; postfixExpr - : infixExpr Id? (prefixDef simpleExpr1)* NL? - ; + : infixExpr Id? (prefixDef simpleExpr1)* NL? + ; infixExpr - : prefixExpr - | infixExpr Id NL? infixExpr - ; + : prefixExpr + | infixExpr Id NL? infixExpr + ; prefixExpr - : prefixDef? (simpleExpr | simpleExpr1 '_'?) - ; + : prefixDef? (simpleExpr | simpleExpr1 '_'?) + ; simpleExpr - : 'new' (classTemplate | templateBody) - | blockExpr - ; + : 'new' (classTemplate | templateBody) + | blockExpr + ; // Dublicate lines to prevent left-recursive code. // can't use (simpleExpr|simpleExpr1) '.' Id simpleExpr1 - : literal - | stableId - | '_' - | '(' exprs? ')' - | simpleExpr '.' Id - | simpleExpr1 '_'? '.' Id - | simpleExpr typeArgs - | simpleExpr1 '_'? typeArgs - | simpleExpr1 argumentExprs - ; + : literal + | stableId + | '_' + | '(' exprs? ')' + | simpleExpr '.' Id + | simpleExpr1 '_'? '.' Id + | simpleExpr typeArgs + | simpleExpr1 '_'? typeArgs + | simpleExpr1 argumentExprs + ; exprs - : expr (',' expr)* - ; + : expr (',' expr)* + ; argumentExprs : '(' args ')' @@ -193,540 +199,564 @@ argumentExprs args : exprs? - | (exprs ',')? postfixExpr (':' | '_' | '*') ? + | (exprs ',')? postfixExpr (':' | '_' | '*')? ; blockExpr - : '{' caseClauses '}' - | '{' block '}' - ; + : '{' caseClauses '}' + | '{' block '}' + ; block - : blockStat+ resultExpr? - ; + : blockStat+ resultExpr? + ; blockStat - : import_ - | annotation* ('implicit' | 'lazy')? def_ - | annotation* localModifier* tmplDef - | expr1 - ; + : import_ + | annotation* ('implicit' | 'lazy')? def_ + | annotation* localModifier* tmplDef + | expr1 + ; resultExpr - : expr1 - | (bindings | ('implicit'? Id | '_') ':' compoundType) '=>' block - ; + : expr1 + | (bindings | ('implicit'? Id | '_') ':' compoundType) '=>' block + ; enumerators - : generator+ - ; + : generator+ + ; generator - : pattern1 '<-' expr (guard_ | pattern1 '=' expr)* - ; + : pattern1 '<-' expr (guard_ | pattern1 '=' expr)* + ; caseClauses - : caseClause + - ; + : caseClause+ + ; caseClause - : 'case' pattern guard_? '=>' block - ; + : 'case' pattern guard_? '=>' block + ; guard_ - : 'if' postfixExpr - ; + : 'if' postfixExpr + ; pattern - : pattern1 ('|' pattern1)* - ; + : pattern1 ('|' pattern1)* + ; pattern1 - : (BoundVarid| '_' | Id) ':' typePat - | pattern2 - ; + : (BoundVarid | '_' | Id) ':' typePat + | pattern2 + ; pattern2 - : Id ('@' pattern3)? - | pattern3 - ; + : Id ('@' pattern3)? + | pattern3 + ; pattern3 - : simplePattern - | simplePattern (Id NL? simplePattern)* - ; + : simplePattern + | simplePattern (Id NL? simplePattern)* + ; simplePattern - : '_' - | Varid - | literal - | stableId ('(' patterns? ')')? - | stableId '(' (patterns ',')? (Id '@')? '_' '*' ')' - | '(' patterns? ')' - ; + : '_' + | Varid + | literal + | stableId ('(' patterns? ')')? + | stableId '(' (patterns ',')? (Id '@')? '_' '*' ')' + | '(' patterns? ')' + ; patterns - : pattern (',' patterns)? - | '_' '*' - ; + : pattern (',' patterns)? + | '_' '*' + ; typeParamClause - : '[' variantTypeParam (',' variantTypeParam)* ']' - ; + : '[' variantTypeParam (',' variantTypeParam)* ']' + ; funTypeParamClause - : '[' typeParam (',' typeParam)* ']' - ; + : '[' typeParam (',' typeParam)* ']' + ; variantTypeParam - : annotation* ('+' | '-')? typeParam - ; + : annotation* ('+' | '-')? typeParam + ; typeParam - : (Id | '_') typeParamClause? ('>:' type_)? ('<:' type_)? ('<%' type_)* (':' type_)* - ; + : (Id | '_') typeParamClause? ('>:' type_)? ('<:' type_)? ('<%' type_)* (':' type_)* + ; paramClauses - : paramClause* (NL? '(' 'implicit' params ')')? - ; + : paramClause* (NL? '(' 'implicit' params ')')? + ; paramClause - : NL? '(' params? ')' - ; + : NL? '(' params? ')' + ; params - : param (',' param)* - ; + : param (',' param)* + ; param - : annotation* Id (':' paramType)? ('=' expr)? - ; + : annotation* Id (':' paramType)? ('=' expr)? + ; paramType - : type_ - | '=>' type_ - | type_ '*' - ; + : type_ + | '=>' type_ + | type_ '*' + ; classParamClauses - : classParamClause* (NL? '(' 'implicit' classParams ')')? - ; + : classParamClause* (NL? '(' 'implicit' classParams ')')? + ; classParamClause - : NL? '(' classParams? ')' - ; + : NL? '(' classParams? ')' + ; classParams - : classParam (',' classParam)* - ; + : classParam (',' classParam)* + ; classParam - : annotation* modifier* ('val' | 'var')? Id ':' paramType ('=' expr)? - ; + : annotation* modifier* ('val' | 'var')? Id ':' paramType ('=' expr)? + ; bindings - : '(' binding (',' binding)* ')' - ; + : '(' binding (',' binding)* ')' + ; binding - : (Id | '_') (':' type_)? - ; + : (Id | '_') (':' type_)? + ; modifier - : localModifier - | accessModifier - | 'override' - ; + : localModifier + | accessModifier + | 'override' + ; localModifier - : 'abstract' - | 'final' - | 'sealed' - | 'implicit' - | 'lazy' - ; + : 'abstract' + | 'final' + | 'sealed' + | 'implicit' + | 'lazy' + ; accessModifier - : ('private' | 'protected') accessQualifier? - ; + : ('private' | 'protected') accessQualifier? + ; accessQualifier - : '[' (Id | 'this') ']' - ; + : '[' (Id | 'this') ']' + ; annotation - : '@' simpleType argumentExprs* - ; + : '@' simpleType argumentExprs* + ; constrAnnotation - : '@' simpleType argumentExprs - ; + : '@' simpleType argumentExprs + ; templateBody - : NL? '{' selfType? templateStat+ '}' - ; + : NL? '{' selfType? templateStat+ '}' + ; templateStat - : import_ - | (annotation NL?)* modifier* def_ - | (annotation NL?)* modifier* dcl - | expr - ; + : import_ + | (annotation NL?)* modifier* def_ + | (annotation NL?)* modifier* dcl + | expr + ; selfType - : Id (':' type_)? '=>' - | 'this' ':' type_ '=>' - ; + : Id (':' type_)? '=>' + | 'this' ':' type_ '=>' + ; import_ - : 'import' importExpr (',' importExpr)* - ; + : 'import' importExpr (',' importExpr)* + ; importExpr - : stableId ('.' (Id | '_' | importSelectors))? - ; + : stableId ('.' (Id | '_' | importSelectors))? + ; importSelectors - : '{' (importSelector ',')* (importSelector | '_') '}' - ; + : '{' (importSelector ',')* (importSelector | '_') '}' + ; importSelector - : Id ('=>' (Id | '_'))? - ; + : Id ('=>' (Id | '_'))? + ; dcl - : 'val' valDcl - | 'var' varDcl - | 'def' funDcl - | 'type' NL* typeDcl - ; + : 'val' valDcl + | 'var' varDcl + | 'def' funDcl + | 'type' NL* typeDcl + ; valDcl - : ids ':' type_ - ; + : ids ':' type_ + ; varDcl - : ids ':' type_ - ; + : ids ':' type_ + ; funDcl - : funSig (':' type_)? - ; + : funSig (':' type_)? + ; funSig - : Id funTypeParamClause? paramClauses - ; + : Id funTypeParamClause? paramClauses + ; typeDcl - : Id typeParamClause? ('>:' type_)? ('<:' type_)? - ; + : Id typeParamClause? ('>:' type_)? ('<:' type_)? + ; patVarDef - : 'val' patDef - | 'var' varDef - ; + : 'val' patDef + | 'var' varDef + ; def_ - : patVarDef - | 'def' funDef - | 'type' NL* typeDef - | tmplDef - ; + : patVarDef + | 'def' funDef + | 'type' NL* typeDef + | tmplDef + ; patDef - : pattern2 (',' pattern2)* (':' type_)? '=' expr - ; + : pattern2 (',' pattern2)* (':' type_)? '=' expr + ; varDef - : patDef - | ids ':' type_ '=' '_' - ; + : patDef + | ids ':' type_ '=' '_' + ; funDef - : funSig (':' type_)? '=' expr - | funSig NL? '{' block '}' - | 'this' paramClause paramClauses ('=' constrExpr | NL? constrBlock) - ; + : funSig (':' type_)? '=' expr + | funSig NL? '{' block '}' + | 'this' paramClause paramClauses ('=' constrExpr | NL? constrBlock) + ; typeDef - : Id typeParamClause? '=' type_ - ; + : Id typeParamClause? '=' type_ + ; tmplDef - : 'case'? 'class' classDef - | 'case'? 'object' objectDef - | 'trait' traitDef - ; + : 'case'? 'class' classDef + | 'case'? 'object' objectDef + | 'trait' traitDef + ; classDef - : Id typeParamClause? constrAnnotation* accessModifier? classParamClauses classTemplateOpt - ; + : Id typeParamClause? constrAnnotation* accessModifier? classParamClauses classTemplateOpt + ; traitDef - : Id typeParamClause? traitTemplateOpt - ; + : Id typeParamClause? traitTemplateOpt + ; objectDef - : Id classTemplateOpt - ; + : Id classTemplateOpt + ; classTemplateOpt - : 'extends' classTemplate - | ('extends'? templateBody)? - ; + : 'extends' classTemplate + | ('extends'? templateBody)? + ; traitTemplateOpt - : 'extends' traitTemplate - | ('extends'? templateBody)? - ; + : 'extends' traitTemplate + | ('extends'? templateBody)? + ; classTemplate - : earlyDefs? classParents templateBody? - ; + : earlyDefs? classParents templateBody? + ; traitTemplate - : earlyDefs? traitParents templateBody? - ; + : earlyDefs? traitParents templateBody? + ; classParents - : constr ('with' annotType)* - ; + : constr ('with' annotType)* + ; traitParents - : annotType ('with' annotType)* - ; + : annotType ('with' annotType)* + ; constr - : annotType argumentExprs* - ; + : annotType argumentExprs* + ; earlyDefs - : '{' earlyDef+ '}' 'with' - ; + : '{' earlyDef+ '}' 'with' + ; earlyDef - : (annotation NL?)* modifier* patVarDef - ; + : (annotation NL?)* modifier* patVarDef + ; constrExpr - : selfInvocation - | constrBlock - ; + : selfInvocation + | constrBlock + ; constrBlock - : '{' selfInvocation (blockStat)* '}' - ; + : '{' selfInvocation (blockStat)* '}' + ; selfInvocation - : 'this' argumentExprs + - ; + : 'this' argumentExprs+ + ; topStatSeq - : topStat+ - ; + : topStat+ + ; topStat - : (annotation NL?)* modifier* tmplDef - | import_ - | packaging - | packageObject - ; + : (annotation NL?)* modifier* tmplDef + | import_ + | packaging + | packageObject + ; packaging - : 'package' qualId NL? '{' topStatSeq '}' - ; + : 'package' qualId NL? '{' topStatSeq '}' + ; packageObject - : 'package' 'object' objectDef - ; - + : 'package' 'object' objectDef + ; compilationUnit - : ('package' qualId)* topStatSeq - ; + : ('package' qualId)* topStatSeq + ; // Lexer - Id - : Plainid - | '`' (CharNoBackQuoteOrNewline | UnicodeEscape | CharEscapeSeq )+ '`' - ; - + : Plainid + | '`' (CharNoBackQuoteOrNewline | UnicodeEscape | CharEscapeSeq)+ '`' + ; BooleanLiteral - : 'true' | 'false' - ; - + : 'true' + | 'false' + ; CharacterLiteral - : '\'' (PrintableChar | CharEscapeSeq) '\'' - ; - + : '\'' (PrintableChar | CharEscapeSeq) '\'' + ; SymbolLiteral - : '\'' Plainid - ; - + : '\'' Plainid + ; IntegerLiteral - : (DecimalNumeral | HexNumeral) ('L' | 'l')? - ; - + : (DecimalNumeral | HexNumeral) ('L' | 'l')? + ; StringLiteral - : '"' StringElement* '"' | '"""' MultiLineChars '"""' - ; + : '"' StringElement* '"' + | '"""' MultiLineChars '"""' + ; FloatingPointLiteral - : Digit + '.' Digit + ExponentPart? FloatType? | '.' Digit + ExponentPart? FloatType? | Digit ExponentPart FloatType? | Digit + ExponentPart? FloatType - ; - + : Digit+ '.' Digit+ ExponentPart? FloatType? + | '.' Digit+ ExponentPart? FloatType? + | Digit ExponentPart FloatType? + | Digit+ ExponentPart? FloatType + ; Varid - : Lower Idrest - ; + : Lower Idrest + ; BoundVarid - : Varid - | '`' Varid '`' - ; -Paren - : '(' | ')' | '[' | ']' | '{' | '}' - ; + : Varid + | '`' Varid '`' + ; +Paren + : '(' + | ')' + | '[' + | ']' + | '{' + | '}' + ; Delim - : '`' | '\'' | '"' | '.' | ';' | ',' - ; + : '`' + | '\'' + | '"' + | '.' + | ';' + | ',' + ; Semi - : (';' | (NL)+) -> skip - ; + : (';' | (NL)+) -> skip + ; NL - : '\n' - | '\r' '\n'? - ; - + : '\n' + | '\r' '\n'? + ; // \u0020-\u0026 """ !"#$%""" // \u0028-\u007E """()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~""" fragment CharNoBackQuoteOrNewline - : [\u0020-\u0026\u0028-\u007E] - ; + : [\u0020-\u0026\u0028-\u007E] + ; // fragments fragment UnicodeEscape - : '\\' 'u' 'u'? HexDigit HexDigit HexDigit HexDigit - ; - + : '\\' 'u' 'u'? HexDigit HexDigit HexDigit HexDigit + ; fragment WhiteSpace - : '\u0020' | '\u0009' | '\u000D' | '\u000A' - ; - + : '\u0020' + | '\u0009' + | '\u000D' + | '\u000A' + ; fragment Opchar - : '!' | '#' | '%' | '&' | '*' | '+' | '-' | ':' | '<' | '=' | '>' | '?' | '@' | '\\' | '^' | '|' | '~' - ; - + : '!' + | '#' + | '%' + | '&' + | '*' + | '+' + | '-' + | ':' + | '<' + | '=' + | '>' + | '?' + | '@' + | '\\' + | '^' + | '|' + | '~' + ; fragment Op - : '/'? Opchar + - ; - + : '/'? Opchar+ + ; fragment Idrest - : (Letter | Digit)* ('_' Op)? - ; - + : (Letter | Digit)* ('_' Op)? + ; fragment StringElement - : '\u0020' | '\u0021' | '\u0023' .. '\u007F' | CharEscapeSeq - ; - + : '\u0020' + | '\u0021' + | '\u0023' .. '\u007F' + | CharEscapeSeq + ; fragment MultiLineChars - : (StringElement | NL) * - ; - + : (StringElement | NL)* + ; fragment HexDigit - : '0' .. '9' | 'A' .. 'F' | 'a' .. 'f' - ; - + : '0' .. '9' + | 'A' .. 'F' + | 'a' .. 'f' + ; fragment FloatType - : 'F' | 'f' | 'D' | 'd' - ; - + : 'F' + | 'f' + | 'D' + | 'd' + ; fragment Upper - : 'A' .. 'Z' | '$' | '_' | UnicodeClass_LU - ; - + : 'A' .. 'Z' + | '$' + | '_' + | UnicodeClass_LU + ; fragment Lower - : 'a' .. 'z' | UnicodeClass_LL - ; - + : 'a' .. 'z' + | UnicodeClass_LL + ; fragment Letter - : Upper | Lower | UnicodeClass_LO | UnicodeClass_LT // TODO Add category Nl - ; + : Upper + | Lower + | UnicodeClass_LO + | UnicodeClass_LT // TODO Add category Nl + ; // and Unicode categories Lo, Lt, Nl fragment ExponentPart - : ('E' | 'e') ('+' | '-')? Digit + - ; - + : ('E' | 'e') ('+' | '-')? Digit+ + ; fragment PrintableChar - : '\u0020' .. '\u007F' - ; + : '\u0020' .. '\u007F' + ; fragment PrintableCharExceptWhitespace - : '\u0021' .. '\u007F' - ; - + : '\u0021' .. '\u007F' + ; fragment CharEscapeSeq - : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') - ; - + : '\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\') + ; fragment DecimalNumeral - : '0' | NonZeroDigit Digit* - ; - + : '0' + | NonZeroDigit Digit* + ; fragment HexNumeral - : '0' 'x' HexDigit HexDigit + - ; - + : '0' 'x' HexDigit HexDigit+ + ; fragment Digit - : '0' | NonZeroDigit - ; - + : '0' + | NonZeroDigit + ; fragment NonZeroDigit - : '1' .. '9' - ; - + : '1' .. '9' + ; fragment VaridFragment - : Varid - ; - + : Varid + ; fragment Plainid - : Upper Idrest | Lower Idrest | Op - ; - + : Upper Idrest + | Lower Idrest + | Op + ; // // Unicode categories @@ -734,622 +764,620 @@ fragment Plainid // fragment UnicodeLetter - : UnicodeClass_LU - | UnicodeClass_LL - | UnicodeClass_LT - | UnicodeClass_LM - | UnicodeClass_LO - ; + : UnicodeClass_LU + | UnicodeClass_LL + | UnicodeClass_LT + | UnicodeClass_LM + | UnicodeClass_LO + ; fragment UnicodeClass_LU - : '\u0041'..'\u005a' - | '\u00c0'..'\u00d6' - | '\u00d8'..'\u00de' - | '\u0100'..'\u0136' - | '\u0139'..'\u0147' - | '\u014a'..'\u0178' - | '\u0179'..'\u017d' - | '\u0181'..'\u0182' - | '\u0184'..'\u0186' - | '\u0187'..'\u0189' - | '\u018a'..'\u018b' - | '\u018e'..'\u0191' - | '\u0193'..'\u0194' - | '\u0196'..'\u0198' - | '\u019c'..'\u019d' - | '\u019f'..'\u01a0' - | '\u01a2'..'\u01a6' - | '\u01a7'..'\u01a9' - | '\u01ac'..'\u01ae' - | '\u01af'..'\u01b1' - | '\u01b2'..'\u01b3' - | '\u01b5'..'\u01b7' - | '\u01b8'..'\u01bc' - | '\u01c4'..'\u01cd' - | '\u01cf'..'\u01db' - | '\u01de'..'\u01ee' - | '\u01f1'..'\u01f4' - | '\u01f6'..'\u01f8' - | '\u01fa'..'\u0232' - | '\u023a'..'\u023b' - | '\u023d'..'\u023e' - | '\u0241'..'\u0243' - | '\u0244'..'\u0246' - | '\u0248'..'\u024e' - | '\u0370'..'\u0372' - | '\u0376'..'\u037f' - | '\u0386'..'\u0388' - | '\u0389'..'\u038a' - | '\u038c'..'\u038e' - | '\u038f'..'\u0391' - | '\u0392'..'\u03a1' - | '\u03a3'..'\u03ab' - | '\u03cf'..'\u03d2' - | '\u03d3'..'\u03d4' - | '\u03d8'..'\u03ee' - | '\u03f4'..'\u03f7' - | '\u03f9'..'\u03fa' - | '\u03fd'..'\u042f' - | '\u0460'..'\u0480' - | '\u048a'..'\u04c0' - | '\u04c1'..'\u04cd' - | '\u04d0'..'\u052e' - | '\u0531'..'\u0556' - | '\u10a0'..'\u10c5' - | '\u10c7'..'\u10cd' - | '\u1e00'..'\u1e94' - | '\u1e9e'..'\u1efe' - | '\u1f08'..'\u1f0f' - | '\u1f18'..'\u1f1d' - | '\u1f28'..'\u1f2f' - | '\u1f38'..'\u1f3f' - | '\u1f48'..'\u1f4d' - | '\u1f59'..'\u1f5f' - | '\u1f68'..'\u1f6f' - | '\u1fb8'..'\u1fbb' - | '\u1fc8'..'\u1fcb' - | '\u1fd8'..'\u1fdb' - | '\u1fe8'..'\u1fec' - | '\u1ff8'..'\u1ffb' - | '\u2102'..'\u2107' - | '\u210b'..'\u210d' - | '\u2110'..'\u2112' - | '\u2115'..'\u2119' - | '\u211a'..'\u211d' - | '\u2124'..'\u212a' - | '\u212b'..'\u212d' - | '\u2130'..'\u2133' - | '\u213e'..'\u213f' - | '\u2145'..'\u2183' - | '\u2c00'..'\u2c2e' - | '\u2c60'..'\u2c62' - | '\u2c63'..'\u2c64' - | '\u2c67'..'\u2c6d' - | '\u2c6e'..'\u2c70' - | '\u2c72'..'\u2c75' - | '\u2c7e'..'\u2c80' - | '\u2c82'..'\u2ce2' - | '\u2ceb'..'\u2ced' - | '\u2cf2'..'\ua640' - | '\ua642'..'\ua66c' - | '\ua680'..'\ua69a' - | '\ua722'..'\ua72e' - | '\ua732'..'\ua76e' - | '\ua779'..'\ua77d' - | '\ua77e'..'\ua786' - | '\ua78b'..'\ua78d' - | '\ua790'..'\ua792' - | '\ua796'..'\ua7aa' - | '\ua7ab'..'\ua7ad' - | '\ua7b0'..'\ua7b1' - | '\uff21'..'\uff3a' - ; + : '\u0041' ..'\u005a' + | '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00de' + | '\u0100' ..'\u0136' + | '\u0139' ..'\u0147' + | '\u014a' ..'\u0178' + | '\u0179' ..'\u017d' + | '\u0181' ..'\u0182' + | '\u0184' ..'\u0186' + | '\u0187' ..'\u0189' + | '\u018a' ..'\u018b' + | '\u018e' ..'\u0191' + | '\u0193' ..'\u0194' + | '\u0196' ..'\u0198' + | '\u019c' ..'\u019d' + | '\u019f' ..'\u01a0' + | '\u01a2' ..'\u01a6' + | '\u01a7' ..'\u01a9' + | '\u01ac' ..'\u01ae' + | '\u01af' ..'\u01b1' + | '\u01b2' ..'\u01b3' + | '\u01b5' ..'\u01b7' + | '\u01b8' ..'\u01bc' + | '\u01c4' ..'\u01cd' + | '\u01cf' ..'\u01db' + | '\u01de' ..'\u01ee' + | '\u01f1' ..'\u01f4' + | '\u01f6' ..'\u01f8' + | '\u01fa' ..'\u0232' + | '\u023a' ..'\u023b' + | '\u023d' ..'\u023e' + | '\u0241' ..'\u0243' + | '\u0244' ..'\u0246' + | '\u0248' ..'\u024e' + | '\u0370' ..'\u0372' + | '\u0376' ..'\u037f' + | '\u0386' ..'\u0388' + | '\u0389' ..'\u038a' + | '\u038c' ..'\u038e' + | '\u038f' ..'\u0391' + | '\u0392' ..'\u03a1' + | '\u03a3' ..'\u03ab' + | '\u03cf' ..'\u03d2' + | '\u03d3' ..'\u03d4' + | '\u03d8' ..'\u03ee' + | '\u03f4' ..'\u03f7' + | '\u03f9' ..'\u03fa' + | '\u03fd' ..'\u042f' + | '\u0460' ..'\u0480' + | '\u048a' ..'\u04c0' + | '\u04c1' ..'\u04cd' + | '\u04d0' ..'\u052e' + | '\u0531' ..'\u0556' + | '\u10a0' ..'\u10c5' + | '\u10c7' ..'\u10cd' + | '\u1e00' ..'\u1e94' + | '\u1e9e' ..'\u1efe' + | '\u1f08' ..'\u1f0f' + | '\u1f18' ..'\u1f1d' + | '\u1f28' ..'\u1f2f' + | '\u1f38' ..'\u1f3f' + | '\u1f48' ..'\u1f4d' + | '\u1f59' ..'\u1f5f' + | '\u1f68' ..'\u1f6f' + | '\u1fb8' ..'\u1fbb' + | '\u1fc8' ..'\u1fcb' + | '\u1fd8' ..'\u1fdb' + | '\u1fe8' ..'\u1fec' + | '\u1ff8' ..'\u1ffb' + | '\u2102' ..'\u2107' + | '\u210b' ..'\u210d' + | '\u2110' ..'\u2112' + | '\u2115' ..'\u2119' + | '\u211a' ..'\u211d' + | '\u2124' ..'\u212a' + | '\u212b' ..'\u212d' + | '\u2130' ..'\u2133' + | '\u213e' ..'\u213f' + | '\u2145' ..'\u2183' + | '\u2c00' ..'\u2c2e' + | '\u2c60' ..'\u2c62' + | '\u2c63' ..'\u2c64' + | '\u2c67' ..'\u2c6d' + | '\u2c6e' ..'\u2c70' + | '\u2c72' ..'\u2c75' + | '\u2c7e' ..'\u2c80' + | '\u2c82' ..'\u2ce2' + | '\u2ceb' ..'\u2ced' + | '\u2cf2' ..'\ua640' + | '\ua642' ..'\ua66c' + | '\ua680' ..'\ua69a' + | '\ua722' ..'\ua72e' + | '\ua732' ..'\ua76e' + | '\ua779' ..'\ua77d' + | '\ua77e' ..'\ua786' + | '\ua78b' ..'\ua78d' + | '\ua790' ..'\ua792' + | '\ua796' ..'\ua7aa' + | '\ua7ab' ..'\ua7ad' + | '\ua7b0' ..'\ua7b1' + | '\uff21' ..'\uff3a' + ; fragment UnicodeClass_LL - : '\u0061'..'\u007A' - | '\u00b5'..'\u00df' - | '\u00e0'..'\u00f6' - | '\u00f8'..'\u00ff' - | '\u0101'..'\u0137' - | '\u0138'..'\u0148' - | '\u0149'..'\u0177' - | '\u017a'..'\u017e' - | '\u017f'..'\u0180' - | '\u0183'..'\u0185' - | '\u0188'..'\u018c' - | '\u018d'..'\u0192' - | '\u0195'..'\u0199' - | '\u019a'..'\u019b' - | '\u019e'..'\u01a1' - | '\u01a3'..'\u01a5' - | '\u01a8'..'\u01aa' - | '\u01ab'..'\u01ad' - | '\u01b0'..'\u01b4' - | '\u01b6'..'\u01b9' - | '\u01ba'..'\u01bd' - | '\u01be'..'\u01bf' - | '\u01c6'..'\u01cc' - | '\u01ce'..'\u01dc' - | '\u01dd'..'\u01ef' - | '\u01f0'..'\u01f3' - | '\u01f5'..'\u01f9' - | '\u01fb'..'\u0233' - | '\u0234'..'\u0239' - | '\u023c'..'\u023f' - | '\u0240'..'\u0242' - | '\u0247'..'\u024f' - | '\u0250'..'\u0293' - | '\u0295'..'\u02af' - | '\u0371'..'\u0373' - | '\u0377'..'\u037b' - | '\u037c'..'\u037d' - | '\u0390'..'\u03ac' - | '\u03ad'..'\u03ce' - | '\u03d0'..'\u03d1' - | '\u03d5'..'\u03d7' - | '\u03d9'..'\u03ef' - | '\u03f0'..'\u03f3' - | '\u03f5'..'\u03fb' - | '\u03fc'..'\u0430' - | '\u0431'..'\u045f' - | '\u0461'..'\u0481' - | '\u048b'..'\u04bf' - | '\u04c2'..'\u04ce' - | '\u04cf'..'\u052f' - | '\u0561'..'\u0587' - | '\u1d00'..'\u1d2b' - | '\u1d6b'..'\u1d77' - | '\u1d79'..'\u1d9a' - | '\u1e01'..'\u1e95' - | '\u1e96'..'\u1e9d' - | '\u1e9f'..'\u1eff' - | '\u1f00'..'\u1f07' - | '\u1f10'..'\u1f15' - | '\u1f20'..'\u1f27' - | '\u1f30'..'\u1f37' - | '\u1f40'..'\u1f45' - | '\u1f50'..'\u1f57' - | '\u1f60'..'\u1f67' - | '\u1f70'..'\u1f7d' - | '\u1f80'..'\u1f87' - | '\u1f90'..'\u1f97' - | '\u1fa0'..'\u1fa7' - | '\u1fb0'..'\u1fb4' - | '\u1fb6'..'\u1fb7' - | '\u1fbe'..'\u1fc2' - | '\u1fc3'..'\u1fc4' - | '\u1fc6'..'\u1fc7' - | '\u1fd0'..'\u1fd3' - | '\u1fd6'..'\u1fd7' - | '\u1fe0'..'\u1fe7' - | '\u1ff2'..'\u1ff4' - | '\u1ff6'..'\u1ff7' - | '\u210a'..'\u210e' - | '\u210f'..'\u2113' - | '\u212f'..'\u2139' - | '\u213c'..'\u213d' - | '\u2146'..'\u2149' - | '\u214e'..'\u2184' - | '\u2c30'..'\u2c5e' - | '\u2c61'..'\u2c65' - | '\u2c66'..'\u2c6c' - | '\u2c71'..'\u2c73' - | '\u2c74'..'\u2c76' - | '\u2c77'..'\u2c7b' - | '\u2c81'..'\u2ce3' - | '\u2ce4'..'\u2cec' - | '\u2cee'..'\u2cf3' - | '\u2d00'..'\u2d25' - | '\u2d27'..'\u2d2d' - | '\ua641'..'\ua66d' - | '\ua681'..'\ua69b' - | '\ua723'..'\ua72f' - | '\ua730'..'\ua731' - | '\ua733'..'\ua771' - | '\ua772'..'\ua778' - | '\ua77a'..'\ua77c' - | '\ua77f'..'\ua787' - | '\ua78c'..'\ua78e' - | '\ua791'..'\ua793' - | '\ua794'..'\ua795' - | '\ua797'..'\ua7a9' - | '\ua7fa'..'\uab30' - | '\uab31'..'\uab5a' - | '\uab64'..'\uab65' - | '\ufb00'..'\ufb06' - | '\ufb13'..'\ufb17' - | '\uff41'..'\uff5a' - ; + : '\u0061' ..'\u007A' + | '\u00b5' ..'\u00df' + | '\u00e0' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0101' ..'\u0137' + | '\u0138' ..'\u0148' + | '\u0149' ..'\u0177' + | '\u017a' ..'\u017e' + | '\u017f' ..'\u0180' + | '\u0183' ..'\u0185' + | '\u0188' ..'\u018c' + | '\u018d' ..'\u0192' + | '\u0195' ..'\u0199' + | '\u019a' ..'\u019b' + | '\u019e' ..'\u01a1' + | '\u01a3' ..'\u01a5' + | '\u01a8' ..'\u01aa' + | '\u01ab' ..'\u01ad' + | '\u01b0' ..'\u01b4' + | '\u01b6' ..'\u01b9' + | '\u01ba' ..'\u01bd' + | '\u01be' ..'\u01bf' + | '\u01c6' ..'\u01cc' + | '\u01ce' ..'\u01dc' + | '\u01dd' ..'\u01ef' + | '\u01f0' ..'\u01f3' + | '\u01f5' ..'\u01f9' + | '\u01fb' ..'\u0233' + | '\u0234' ..'\u0239' + | '\u023c' ..'\u023f' + | '\u0240' ..'\u0242' + | '\u0247' ..'\u024f' + | '\u0250' ..'\u0293' + | '\u0295' ..'\u02af' + | '\u0371' ..'\u0373' + | '\u0377' ..'\u037b' + | '\u037c' ..'\u037d' + | '\u0390' ..'\u03ac' + | '\u03ad' ..'\u03ce' + | '\u03d0' ..'\u03d1' + | '\u03d5' ..'\u03d7' + | '\u03d9' ..'\u03ef' + | '\u03f0' ..'\u03f3' + | '\u03f5' ..'\u03fb' + | '\u03fc' ..'\u0430' + | '\u0431' ..'\u045f' + | '\u0461' ..'\u0481' + | '\u048b' ..'\u04bf' + | '\u04c2' ..'\u04ce' + | '\u04cf' ..'\u052f' + | '\u0561' ..'\u0587' + | '\u1d00' ..'\u1d2b' + | '\u1d6b' ..'\u1d77' + | '\u1d79' ..'\u1d9a' + | '\u1e01' ..'\u1e95' + | '\u1e96' ..'\u1e9d' + | '\u1e9f' ..'\u1eff' + | '\u1f00' ..'\u1f07' + | '\u1f10' ..'\u1f15' + | '\u1f20' ..'\u1f27' + | '\u1f30' ..'\u1f37' + | '\u1f40' ..'\u1f45' + | '\u1f50' ..'\u1f57' + | '\u1f60' ..'\u1f67' + | '\u1f70' ..'\u1f7d' + | '\u1f80' ..'\u1f87' + | '\u1f90' ..'\u1f97' + | '\u1fa0' ..'\u1fa7' + | '\u1fb0' ..'\u1fb4' + | '\u1fb6' ..'\u1fb7' + | '\u1fbe' ..'\u1fc2' + | '\u1fc3' ..'\u1fc4' + | '\u1fc6' ..'\u1fc7' + | '\u1fd0' ..'\u1fd3' + | '\u1fd6' ..'\u1fd7' + | '\u1fe0' ..'\u1fe7' + | '\u1ff2' ..'\u1ff4' + | '\u1ff6' ..'\u1ff7' + | '\u210a' ..'\u210e' + | '\u210f' ..'\u2113' + | '\u212f' ..'\u2139' + | '\u213c' ..'\u213d' + | '\u2146' ..'\u2149' + | '\u214e' ..'\u2184' + | '\u2c30' ..'\u2c5e' + | '\u2c61' ..'\u2c65' + | '\u2c66' ..'\u2c6c' + | '\u2c71' ..'\u2c73' + | '\u2c74' ..'\u2c76' + | '\u2c77' ..'\u2c7b' + | '\u2c81' ..'\u2ce3' + | '\u2ce4' ..'\u2cec' + | '\u2cee' ..'\u2cf3' + | '\u2d00' ..'\u2d25' + | '\u2d27' ..'\u2d2d' + | '\ua641' ..'\ua66d' + | '\ua681' ..'\ua69b' + | '\ua723' ..'\ua72f' + | '\ua730' ..'\ua731' + | '\ua733' ..'\ua771' + | '\ua772' ..'\ua778' + | '\ua77a' ..'\ua77c' + | '\ua77f' ..'\ua787' + | '\ua78c' ..'\ua78e' + | '\ua791' ..'\ua793' + | '\ua794' ..'\ua795' + | '\ua797' ..'\ua7a9' + | '\ua7fa' ..'\uab30' + | '\uab31' ..'\uab5a' + | '\uab64' ..'\uab65' + | '\ufb00' ..'\ufb06' + | '\ufb13' ..'\ufb17' + | '\uff41' ..'\uff5a' + ; fragment UnicodeClass_LT - : '\u01c5'..'\u01cb' - | '\u01f2'..'\u1f88' - | '\u1f89'..'\u1f8f' - | '\u1f98'..'\u1f9f' - | '\u1fa8'..'\u1faf' - | '\u1fbc'..'\u1fcc' - | '\u1ffc'..'\u1ffc' - ; + : '\u01c5' ..'\u01cb' + | '\u01f2' ..'\u1f88' + | '\u1f89' ..'\u1f8f' + | '\u1f98' ..'\u1f9f' + | '\u1fa8' ..'\u1faf' + | '\u1fbc' ..'\u1fcc' + | '\u1ffc' ..'\u1ffc' + ; fragment UnicodeClass_LM - : '\u02b0'..'\u02c1' - | '\u02c6'..'\u02d1' - | '\u02e0'..'\u02e4' - | '\u02ec'..'\u02ee' - | '\u0374'..'\u037a' - | '\u0559'..'\u0640' - | '\u06e5'..'\u06e6' - | '\u07f4'..'\u07f5' - | '\u07fa'..'\u081a' - | '\u0824'..'\u0828' - | '\u0971'..'\u0e46' - | '\u0ec6'..'\u10fc' - | '\u17d7'..'\u1843' - | '\u1aa7'..'\u1c78' - | '\u1c79'..'\u1c7d' - | '\u1d2c'..'\u1d6a' - | '\u1d78'..'\u1d9b' - | '\u1d9c'..'\u1dbf' - | '\u2071'..'\u207f' - | '\u2090'..'\u209c' - | '\u2c7c'..'\u2c7d' - | '\u2d6f'..'\u2e2f' - | '\u3005'..'\u3031' - | '\u3032'..'\u3035' - | '\u303b'..'\u309d' - | '\u309e'..'\u30fc' - | '\u30fd'..'\u30fe' - | '\ua015'..'\ua4f8' - | '\ua4f9'..'\ua4fd' - | '\ua60c'..'\ua67f' - | '\ua69c'..'\ua69d' - | '\ua717'..'\ua71f' - | '\ua770'..'\ua788' - | '\ua7f8'..'\ua7f9' - | '\ua9cf'..'\ua9e6' - | '\uaa70'..'\uaadd' - | '\uaaf3'..'\uaaf4' - | '\uab5c'..'\uab5f' - | '\uff70'..'\uff9e' - | '\uff9f'..'\uff9f' - ; + : '\u02b0' ..'\u02c1' + | '\u02c6' ..'\u02d1' + | '\u02e0' ..'\u02e4' + | '\u02ec' ..'\u02ee' + | '\u0374' ..'\u037a' + | '\u0559' ..'\u0640' + | '\u06e5' ..'\u06e6' + | '\u07f4' ..'\u07f5' + | '\u07fa' ..'\u081a' + | '\u0824' ..'\u0828' + | '\u0971' ..'\u0e46' + | '\u0ec6' ..'\u10fc' + | '\u17d7' ..'\u1843' + | '\u1aa7' ..'\u1c78' + | '\u1c79' ..'\u1c7d' + | '\u1d2c' ..'\u1d6a' + | '\u1d78' ..'\u1d9b' + | '\u1d9c' ..'\u1dbf' + | '\u2071' ..'\u207f' + | '\u2090' ..'\u209c' + | '\u2c7c' ..'\u2c7d' + | '\u2d6f' ..'\u2e2f' + | '\u3005' ..'\u3031' + | '\u3032' ..'\u3035' + | '\u303b' ..'\u309d' + | '\u309e' ..'\u30fc' + | '\u30fd' ..'\u30fe' + | '\ua015' ..'\ua4f8' + | '\ua4f9' ..'\ua4fd' + | '\ua60c' ..'\ua67f' + | '\ua69c' ..'\ua69d' + | '\ua717' ..'\ua71f' + | '\ua770' ..'\ua788' + | '\ua7f8' ..'\ua7f9' + | '\ua9cf' ..'\ua9e6' + | '\uaa70' ..'\uaadd' + | '\uaaf3' ..'\uaaf4' + | '\uab5c' ..'\uab5f' + | '\uff70' ..'\uff9e' + | '\uff9f' ..'\uff9f' + ; fragment UnicodeClass_LO - : '\u00aa'..'\u00ba' - | '\u01bb'..'\u01c0' - | '\u01c1'..'\u01c3' - | '\u0294'..'\u05d0' - | '\u05d1'..'\u05ea' - | '\u05f0'..'\u05f2' - | '\u0620'..'\u063f' - | '\u0641'..'\u064a' - | '\u066e'..'\u066f' - | '\u0671'..'\u06d3' - | '\u06d5'..'\u06ee' - | '\u06ef'..'\u06fa' - | '\u06fb'..'\u06fc' - | '\u06ff'..'\u0710' - | '\u0712'..'\u072f' - | '\u074d'..'\u07a5' - | '\u07b1'..'\u07ca' - | '\u07cb'..'\u07ea' - | '\u0800'..'\u0815' - | '\u0840'..'\u0858' - | '\u08a0'..'\u08b2' - | '\u0904'..'\u0939' - | '\u093d'..'\u0950' - | '\u0958'..'\u0961' - | '\u0972'..'\u0980' - | '\u0985'..'\u098c' - | '\u098f'..'\u0990' - | '\u0993'..'\u09a8' - | '\u09aa'..'\u09b0' - | '\u09b2'..'\u09b6' - | '\u09b7'..'\u09b9' - | '\u09bd'..'\u09ce' - | '\u09dc'..'\u09dd' - | '\u09df'..'\u09e1' - | '\u09f0'..'\u09f1' - | '\u0a05'..'\u0a0a' - | '\u0a0f'..'\u0a10' - | '\u0a13'..'\u0a28' - | '\u0a2a'..'\u0a30' - | '\u0a32'..'\u0a33' - | '\u0a35'..'\u0a36' - | '\u0a38'..'\u0a39' - | '\u0a59'..'\u0a5c' - | '\u0a5e'..'\u0a72' - | '\u0a73'..'\u0a74' - | '\u0a85'..'\u0a8d' - | '\u0a8f'..'\u0a91' - | '\u0a93'..'\u0aa8' - | '\u0aaa'..'\u0ab0' - | '\u0ab2'..'\u0ab3' - | '\u0ab5'..'\u0ab9' - | '\u0abd'..'\u0ad0' - | '\u0ae0'..'\u0ae1' - | '\u0b05'..'\u0b0c' - | '\u0b0f'..'\u0b10' - | '\u0b13'..'\u0b28' - | '\u0b2a'..'\u0b30' - | '\u0b32'..'\u0b33' - | '\u0b35'..'\u0b39' - | '\u0b3d'..'\u0b5c' - | '\u0b5d'..'\u0b5f' - | '\u0b60'..'\u0b61' - | '\u0b71'..'\u0b83' - | '\u0b85'..'\u0b8a' - | '\u0b8e'..'\u0b90' - | '\u0b92'..'\u0b95' - | '\u0b99'..'\u0b9a' - | '\u0b9c'..'\u0b9e' - | '\u0b9f'..'\u0ba3' - | '\u0ba4'..'\u0ba8' - | '\u0ba9'..'\u0baa' - | '\u0bae'..'\u0bb9' - | '\u0bd0'..'\u0c05' - | '\u0c06'..'\u0c0c' - | '\u0c0e'..'\u0c10' - | '\u0c12'..'\u0c28' - | '\u0c2a'..'\u0c39' - | '\u0c3d'..'\u0c58' - | '\u0c59'..'\u0c60' - | '\u0c61'..'\u0c85' - | '\u0c86'..'\u0c8c' - | '\u0c8e'..'\u0c90' - | '\u0c92'..'\u0ca8' - | '\u0caa'..'\u0cb3' - | '\u0cb5'..'\u0cb9' - | '\u0cbd'..'\u0cde' - | '\u0ce0'..'\u0ce1' - | '\u0cf1'..'\u0cf2' - | '\u0d05'..'\u0d0c' - | '\u0d0e'..'\u0d10' - | '\u0d12'..'\u0d3a' - | '\u0d3d'..'\u0d4e' - | '\u0d60'..'\u0d61' - | '\u0d7a'..'\u0d7f' - | '\u0d85'..'\u0d96' - | '\u0d9a'..'\u0db1' - | '\u0db3'..'\u0dbb' - | '\u0dbd'..'\u0dc0' - | '\u0dc1'..'\u0dc6' - | '\u0e01'..'\u0e30' - | '\u0e32'..'\u0e33' - | '\u0e40'..'\u0e45' - | '\u0e81'..'\u0e82' - | '\u0e84'..'\u0e87' - | '\u0e88'..'\u0e8a' - | '\u0e8d'..'\u0e94' - | '\u0e95'..'\u0e97' - | '\u0e99'..'\u0e9f' - | '\u0ea1'..'\u0ea3' - | '\u0ea5'..'\u0ea7' - | '\u0eaa'..'\u0eab' - | '\u0ead'..'\u0eb0' - | '\u0eb2'..'\u0eb3' - | '\u0ebd'..'\u0ec0' - | '\u0ec1'..'\u0ec4' - | '\u0edc'..'\u0edf' - | '\u0f00'..'\u0f40' - | '\u0f41'..'\u0f47' - | '\u0f49'..'\u0f6c' - | '\u0f88'..'\u0f8c' - | '\u1000'..'\u102a' - | '\u103f'..'\u1050' - | '\u1051'..'\u1055' - | '\u105a'..'\u105d' - | '\u1061'..'\u1065' - | '\u1066'..'\u106e' - | '\u106f'..'\u1070' - | '\u1075'..'\u1081' - | '\u108e'..'\u10d0' - | '\u10d1'..'\u10fa' - | '\u10fd'..'\u1248' - | '\u124a'..'\u124d' - | '\u1250'..'\u1256' - | '\u1258'..'\u125a' - | '\u125b'..'\u125d' - | '\u1260'..'\u1288' - | '\u128a'..'\u128d' - | '\u1290'..'\u12b0' - | '\u12b2'..'\u12b5' - | '\u12b8'..'\u12be' - | '\u12c0'..'\u12c2' - | '\u12c3'..'\u12c5' - | '\u12c8'..'\u12d6' - | '\u12d8'..'\u1310' - | '\u1312'..'\u1315' - | '\u1318'..'\u135a' - | '\u1380'..'\u138f' - | '\u13a0'..'\u13f4' - | '\u1401'..'\u166c' - | '\u166f'..'\u167f' - | '\u1681'..'\u169a' - | '\u16a0'..'\u16ea' - | '\u16f1'..'\u16f8' - | '\u1700'..'\u170c' - | '\u170e'..'\u1711' - | '\u1720'..'\u1731' - | '\u1740'..'\u1751' - | '\u1760'..'\u176c' - | '\u176e'..'\u1770' - | '\u1780'..'\u17b3' - | '\u17dc'..'\u1820' - | '\u1821'..'\u1842' - | '\u1844'..'\u1877' - | '\u1880'..'\u18a8' - | '\u18aa'..'\u18b0' - | '\u18b1'..'\u18f5' - | '\u1900'..'\u191e' - | '\u1950'..'\u196d' - | '\u1970'..'\u1974' - | '\u1980'..'\u19ab' - | '\u19c1'..'\u19c7' - | '\u1a00'..'\u1a16' - | '\u1a20'..'\u1a54' - | '\u1b05'..'\u1b33' - | '\u1b45'..'\u1b4b' - | '\u1b83'..'\u1ba0' - | '\u1bae'..'\u1baf' - | '\u1bba'..'\u1be5' - | '\u1c00'..'\u1c23' - | '\u1c4d'..'\u1c4f' - | '\u1c5a'..'\u1c77' - | '\u1ce9'..'\u1cec' - | '\u1cee'..'\u1cf1' - | '\u1cf5'..'\u1cf6' - | '\u2135'..'\u2138' - | '\u2d30'..'\u2d67' - | '\u2d80'..'\u2d96' - | '\u2da0'..'\u2da6' - | '\u2da8'..'\u2dae' - | '\u2db0'..'\u2db6' - | '\u2db8'..'\u2dbe' - | '\u2dc0'..'\u2dc6' - | '\u2dc8'..'\u2dce' - | '\u2dd0'..'\u2dd6' - | '\u2dd8'..'\u2dde' - | '\u3006'..'\u303c' - | '\u3041'..'\u3096' - | '\u309f'..'\u30a1' - | '\u30a2'..'\u30fa' - | '\u30ff'..'\u3105' - | '\u3106'..'\u312d' - | '\u3131'..'\u318e' - | '\u31a0'..'\u31ba' - | '\u31f0'..'\u31ff' - | '\u3400'..'\u4db5' - | '\u4e00'..'\u9fcc' - | '\ua000'..'\ua014' - | '\ua016'..'\ua48c' - | '\ua4d0'..'\ua4f7' - | '\ua500'..'\ua60b' - | '\ua610'..'\ua61f' - | '\ua62a'..'\ua62b' - | '\ua66e'..'\ua6a0' - | '\ua6a1'..'\ua6e5' - | '\ua7f7'..'\ua7fb' - | '\ua7fc'..'\ua801' - | '\ua803'..'\ua805' - | '\ua807'..'\ua80a' - | '\ua80c'..'\ua822' - | '\ua840'..'\ua873' - | '\ua882'..'\ua8b3' - | '\ua8f2'..'\ua8f7' - | '\ua8fb'..'\ua90a' - | '\ua90b'..'\ua925' - | '\ua930'..'\ua946' - | '\ua960'..'\ua97c' - | '\ua984'..'\ua9b2' - | '\ua9e0'..'\ua9e4' - | '\ua9e7'..'\ua9ef' - | '\ua9fa'..'\ua9fe' - | '\uaa00'..'\uaa28' - | '\uaa40'..'\uaa42' - | '\uaa44'..'\uaa4b' - | '\uaa60'..'\uaa6f' - | '\uaa71'..'\uaa76' - | '\uaa7a'..'\uaa7e' - | '\uaa7f'..'\uaaaf' - | '\uaab1'..'\uaab5' - | '\uaab6'..'\uaab9' - | '\uaaba'..'\uaabd' - | '\uaac0'..'\uaac2' - | '\uaadb'..'\uaadc' - | '\uaae0'..'\uaaea' - | '\uaaf2'..'\uab01' - | '\uab02'..'\uab06' - | '\uab09'..'\uab0e' - | '\uab11'..'\uab16' - | '\uab20'..'\uab26' - | '\uab28'..'\uab2e' - | '\uabc0'..'\uabe2' - | '\uac00'..'\ud7a3' - | '\ud7b0'..'\ud7c6' - | '\ud7cb'..'\ud7fb' - | '\uf900'..'\ufa6d' - | '\ufa70'..'\ufad9' - | '\ufb1d'..'\ufb1f' - | '\ufb20'..'\ufb28' - | '\ufb2a'..'\ufb36' - | '\ufb38'..'\ufb3c' - | '\ufb3e'..'\ufb40' - | '\ufb41'..'\ufb43' - | '\ufb44'..'\ufb46' - | '\ufb47'..'\ufbb1' - | '\ufbd3'..'\ufd3d' - | '\ufd50'..'\ufd8f' - | '\ufd92'..'\ufdc7' - | '\ufdf0'..'\ufdfb' - | '\ufe70'..'\ufe74' - | '\ufe76'..'\ufefc' - | '\uff66'..'\uff6f' - | '\uff71'..'\uff9d' - | '\uffa0'..'\uffbe' - | '\uffc2'..'\uffc7' - | '\uffca'..'\uffcf' - | '\uffd2'..'\uffd7' - | '\uffda'..'\uffdc' - ; + : '\u00aa' ..'\u00ba' + | '\u01bb' ..'\u01c0' + | '\u01c1' ..'\u01c3' + | '\u0294' ..'\u05d0' + | '\u05d1' ..'\u05ea' + | '\u05f0' ..'\u05f2' + | '\u0620' ..'\u063f' + | '\u0641' ..'\u064a' + | '\u066e' ..'\u066f' + | '\u0671' ..'\u06d3' + | '\u06d5' ..'\u06ee' + | '\u06ef' ..'\u06fa' + | '\u06fb' ..'\u06fc' + | '\u06ff' ..'\u0710' + | '\u0712' ..'\u072f' + | '\u074d' ..'\u07a5' + | '\u07b1' ..'\u07ca' + | '\u07cb' ..'\u07ea' + | '\u0800' ..'\u0815' + | '\u0840' ..'\u0858' + | '\u08a0' ..'\u08b2' + | '\u0904' ..'\u0939' + | '\u093d' ..'\u0950' + | '\u0958' ..'\u0961' + | '\u0972' ..'\u0980' + | '\u0985' ..'\u098c' + | '\u098f' ..'\u0990' + | '\u0993' ..'\u09a8' + | '\u09aa' ..'\u09b0' + | '\u09b2' ..'\u09b6' + | '\u09b7' ..'\u09b9' + | '\u09bd' ..'\u09ce' + | '\u09dc' ..'\u09dd' + | '\u09df' ..'\u09e1' + | '\u09f0' ..'\u09f1' + | '\u0a05' ..'\u0a0a' + | '\u0a0f' ..'\u0a10' + | '\u0a13' ..'\u0a28' + | '\u0a2a' ..'\u0a30' + | '\u0a32' ..'\u0a33' + | '\u0a35' ..'\u0a36' + | '\u0a38' ..'\u0a39' + | '\u0a59' ..'\u0a5c' + | '\u0a5e' ..'\u0a72' + | '\u0a73' ..'\u0a74' + | '\u0a85' ..'\u0a8d' + | '\u0a8f' ..'\u0a91' + | '\u0a93' ..'\u0aa8' + | '\u0aaa' ..'\u0ab0' + | '\u0ab2' ..'\u0ab3' + | '\u0ab5' ..'\u0ab9' + | '\u0abd' ..'\u0ad0' + | '\u0ae0' ..'\u0ae1' + | '\u0b05' ..'\u0b0c' + | '\u0b0f' ..'\u0b10' + | '\u0b13' ..'\u0b28' + | '\u0b2a' ..'\u0b30' + | '\u0b32' ..'\u0b33' + | '\u0b35' ..'\u0b39' + | '\u0b3d' ..'\u0b5c' + | '\u0b5d' ..'\u0b5f' + | '\u0b60' ..'\u0b61' + | '\u0b71' ..'\u0b83' + | '\u0b85' ..'\u0b8a' + | '\u0b8e' ..'\u0b90' + | '\u0b92' ..'\u0b95' + | '\u0b99' ..'\u0b9a' + | '\u0b9c' ..'\u0b9e' + | '\u0b9f' ..'\u0ba3' + | '\u0ba4' ..'\u0ba8' + | '\u0ba9' ..'\u0baa' + | '\u0bae' ..'\u0bb9' + | '\u0bd0' ..'\u0c05' + | '\u0c06' ..'\u0c0c' + | '\u0c0e' ..'\u0c10' + | '\u0c12' ..'\u0c28' + | '\u0c2a' ..'\u0c39' + | '\u0c3d' ..'\u0c58' + | '\u0c59' ..'\u0c60' + | '\u0c61' ..'\u0c85' + | '\u0c86' ..'\u0c8c' + | '\u0c8e' ..'\u0c90' + | '\u0c92' ..'\u0ca8' + | '\u0caa' ..'\u0cb3' + | '\u0cb5' ..'\u0cb9' + | '\u0cbd' ..'\u0cde' + | '\u0ce0' ..'\u0ce1' + | '\u0cf1' ..'\u0cf2' + | '\u0d05' ..'\u0d0c' + | '\u0d0e' ..'\u0d10' + | '\u0d12' ..'\u0d3a' + | '\u0d3d' ..'\u0d4e' + | '\u0d60' ..'\u0d61' + | '\u0d7a' ..'\u0d7f' + | '\u0d85' ..'\u0d96' + | '\u0d9a' ..'\u0db1' + | '\u0db3' ..'\u0dbb' + | '\u0dbd' ..'\u0dc0' + | '\u0dc1' ..'\u0dc6' + | '\u0e01' ..'\u0e30' + | '\u0e32' ..'\u0e33' + | '\u0e40' ..'\u0e45' + | '\u0e81' ..'\u0e82' + | '\u0e84' ..'\u0e87' + | '\u0e88' ..'\u0e8a' + | '\u0e8d' ..'\u0e94' + | '\u0e95' ..'\u0e97' + | '\u0e99' ..'\u0e9f' + | '\u0ea1' ..'\u0ea3' + | '\u0ea5' ..'\u0ea7' + | '\u0eaa' ..'\u0eab' + | '\u0ead' ..'\u0eb0' + | '\u0eb2' ..'\u0eb3' + | '\u0ebd' ..'\u0ec0' + | '\u0ec1' ..'\u0ec4' + | '\u0edc' ..'\u0edf' + | '\u0f00' ..'\u0f40' + | '\u0f41' ..'\u0f47' + | '\u0f49' ..'\u0f6c' + | '\u0f88' ..'\u0f8c' + | '\u1000' ..'\u102a' + | '\u103f' ..'\u1050' + | '\u1051' ..'\u1055' + | '\u105a' ..'\u105d' + | '\u1061' ..'\u1065' + | '\u1066' ..'\u106e' + | '\u106f' ..'\u1070' + | '\u1075' ..'\u1081' + | '\u108e' ..'\u10d0' + | '\u10d1' ..'\u10fa' + | '\u10fd' ..'\u1248' + | '\u124a' ..'\u124d' + | '\u1250' ..'\u1256' + | '\u1258' ..'\u125a' + | '\u125b' ..'\u125d' + | '\u1260' ..'\u1288' + | '\u128a' ..'\u128d' + | '\u1290' ..'\u12b0' + | '\u12b2' ..'\u12b5' + | '\u12b8' ..'\u12be' + | '\u12c0' ..'\u12c2' + | '\u12c3' ..'\u12c5' + | '\u12c8' ..'\u12d6' + | '\u12d8' ..'\u1310' + | '\u1312' ..'\u1315' + | '\u1318' ..'\u135a' + | '\u1380' ..'\u138f' + | '\u13a0' ..'\u13f4' + | '\u1401' ..'\u166c' + | '\u166f' ..'\u167f' + | '\u1681' ..'\u169a' + | '\u16a0' ..'\u16ea' + | '\u16f1' ..'\u16f8' + | '\u1700' ..'\u170c' + | '\u170e' ..'\u1711' + | '\u1720' ..'\u1731' + | '\u1740' ..'\u1751' + | '\u1760' ..'\u176c' + | '\u176e' ..'\u1770' + | '\u1780' ..'\u17b3' + | '\u17dc' ..'\u1820' + | '\u1821' ..'\u1842' + | '\u1844' ..'\u1877' + | '\u1880' ..'\u18a8' + | '\u18aa' ..'\u18b0' + | '\u18b1' ..'\u18f5' + | '\u1900' ..'\u191e' + | '\u1950' ..'\u196d' + | '\u1970' ..'\u1974' + | '\u1980' ..'\u19ab' + | '\u19c1' ..'\u19c7' + | '\u1a00' ..'\u1a16' + | '\u1a20' ..'\u1a54' + | '\u1b05' ..'\u1b33' + | '\u1b45' ..'\u1b4b' + | '\u1b83' ..'\u1ba0' + | '\u1bae' ..'\u1baf' + | '\u1bba' ..'\u1be5' + | '\u1c00' ..'\u1c23' + | '\u1c4d' ..'\u1c4f' + | '\u1c5a' ..'\u1c77' + | '\u1ce9' ..'\u1cec' + | '\u1cee' ..'\u1cf1' + | '\u1cf5' ..'\u1cf6' + | '\u2135' ..'\u2138' + | '\u2d30' ..'\u2d67' + | '\u2d80' ..'\u2d96' + | '\u2da0' ..'\u2da6' + | '\u2da8' ..'\u2dae' + | '\u2db0' ..'\u2db6' + | '\u2db8' ..'\u2dbe' + | '\u2dc0' ..'\u2dc6' + | '\u2dc8' ..'\u2dce' + | '\u2dd0' ..'\u2dd6' + | '\u2dd8' ..'\u2dde' + | '\u3006' ..'\u303c' + | '\u3041' ..'\u3096' + | '\u309f' ..'\u30a1' + | '\u30a2' ..'\u30fa' + | '\u30ff' ..'\u3105' + | '\u3106' ..'\u312d' + | '\u3131' ..'\u318e' + | '\u31a0' ..'\u31ba' + | '\u31f0' ..'\u31ff' + | '\u3400' ..'\u4db5' + | '\u4e00' ..'\u9fcc' + | '\ua000' ..'\ua014' + | '\ua016' ..'\ua48c' + | '\ua4d0' ..'\ua4f7' + | '\ua500' ..'\ua60b' + | '\ua610' ..'\ua61f' + | '\ua62a' ..'\ua62b' + | '\ua66e' ..'\ua6a0' + | '\ua6a1' ..'\ua6e5' + | '\ua7f7' ..'\ua7fb' + | '\ua7fc' ..'\ua801' + | '\ua803' ..'\ua805' + | '\ua807' ..'\ua80a' + | '\ua80c' ..'\ua822' + | '\ua840' ..'\ua873' + | '\ua882' ..'\ua8b3' + | '\ua8f2' ..'\ua8f7' + | '\ua8fb' ..'\ua90a' + | '\ua90b' ..'\ua925' + | '\ua930' ..'\ua946' + | '\ua960' ..'\ua97c' + | '\ua984' ..'\ua9b2' + | '\ua9e0' ..'\ua9e4' + | '\ua9e7' ..'\ua9ef' + | '\ua9fa' ..'\ua9fe' + | '\uaa00' ..'\uaa28' + | '\uaa40' ..'\uaa42' + | '\uaa44' ..'\uaa4b' + | '\uaa60' ..'\uaa6f' + | '\uaa71' ..'\uaa76' + | '\uaa7a' ..'\uaa7e' + | '\uaa7f' ..'\uaaaf' + | '\uaab1' ..'\uaab5' + | '\uaab6' ..'\uaab9' + | '\uaaba' ..'\uaabd' + | '\uaac0' ..'\uaac2' + | '\uaadb' ..'\uaadc' + | '\uaae0' ..'\uaaea' + | '\uaaf2' ..'\uab01' + | '\uab02' ..'\uab06' + | '\uab09' ..'\uab0e' + | '\uab11' ..'\uab16' + | '\uab20' ..'\uab26' + | '\uab28' ..'\uab2e' + | '\uabc0' ..'\uabe2' + | '\uac00' ..'\ud7a3' + | '\ud7b0' ..'\ud7c6' + | '\ud7cb' ..'\ud7fb' + | '\uf900' ..'\ufa6d' + | '\ufa70' ..'\ufad9' + | '\ufb1d' ..'\ufb1f' + | '\ufb20' ..'\ufb28' + | '\ufb2a' ..'\ufb36' + | '\ufb38' ..'\ufb3c' + | '\ufb3e' ..'\ufb40' + | '\ufb41' ..'\ufb43' + | '\ufb44' ..'\ufb46' + | '\ufb47' ..'\ufbb1' + | '\ufbd3' ..'\ufd3d' + | '\ufd50' ..'\ufd8f' + | '\ufd92' ..'\ufdc7' + | '\ufdf0' ..'\ufdfb' + | '\ufe70' ..'\ufe74' + | '\ufe76' ..'\ufefc' + | '\uff66' ..'\uff6f' + | '\uff71' ..'\uff9d' + | '\uffa0' ..'\uffbe' + | '\uffc2' ..'\uffc7' + | '\uffca' ..'\uffcf' + | '\uffd2' ..'\uffd7' + | '\uffda' ..'\uffdc' + ; fragment UnicodeDigit // UnicodeClass_ND - : '\u0030'..'\u0039' - | '\u0660'..'\u0669' - | '\u06f0'..'\u06f9' - | '\u07c0'..'\u07c9' - | '\u0966'..'\u096f' - | '\u09e6'..'\u09ef' - | '\u0a66'..'\u0a6f' - | '\u0ae6'..'\u0aef' - | '\u0b66'..'\u0b6f' - | '\u0be6'..'\u0bef' - | '\u0c66'..'\u0c6f' - | '\u0ce6'..'\u0cef' - | '\u0d66'..'\u0d6f' - | '\u0de6'..'\u0def' - | '\u0e50'..'\u0e59' - | '\u0ed0'..'\u0ed9' - | '\u0f20'..'\u0f29' - | '\u1040'..'\u1049' - | '\u1090'..'\u1099' - | '\u17e0'..'\u17e9' - | '\u1810'..'\u1819' - | '\u1946'..'\u194f' - | '\u19d0'..'\u19d9' - | '\u1a80'..'\u1a89' - | '\u1a90'..'\u1a99' - | '\u1b50'..'\u1b59' - | '\u1bb0'..'\u1bb9' - | '\u1c40'..'\u1c49' - | '\u1c50'..'\u1c59' - | '\ua620'..'\ua629' - | '\ua8d0'..'\ua8d9' - | '\ua900'..'\ua909' - | '\ua9d0'..'\ua9d9' - | '\ua9f0'..'\ua9f9' - | '\uaa50'..'\uaa59' - | '\uabf0'..'\uabf9' - | '\uff10'..'\uff19' - ; - + : '\u0030' ..'\u0039' + | '\u0660' ..'\u0669' + | '\u06f0' ..'\u06f9' + | '\u07c0' ..'\u07c9' + | '\u0966' ..'\u096f' + | '\u09e6' ..'\u09ef' + | '\u0a66' ..'\u0a6f' + | '\u0ae6' ..'\u0aef' + | '\u0b66' ..'\u0b6f' + | '\u0be6' ..'\u0bef' + | '\u0c66' ..'\u0c6f' + | '\u0ce6' ..'\u0cef' + | '\u0d66' ..'\u0d6f' + | '\u0de6' ..'\u0def' + | '\u0e50' ..'\u0e59' + | '\u0ed0' ..'\u0ed9' + | '\u0f20' ..'\u0f29' + | '\u1040' ..'\u1049' + | '\u1090' ..'\u1099' + | '\u17e0' ..'\u17e9' + | '\u1810' ..'\u1819' + | '\u1946' ..'\u194f' + | '\u19d0' ..'\u19d9' + | '\u1a80' ..'\u1a89' + | '\u1a90' ..'\u1a99' + | '\u1b50' ..'\u1b59' + | '\u1bb0' ..'\u1bb9' + | '\u1c40' ..'\u1c49' + | '\u1c50' ..'\u1c59' + | '\ua620' ..'\ua629' + | '\ua8d0' ..'\ua8d9' + | '\ua900' ..'\ua909' + | '\ua9d0' ..'\ua9d9' + | '\ua9f0' ..'\ua9f9' + | '\uaa50' ..'\uaa59' + | '\uabf0' ..'\uabf9' + | '\uff10' ..'\uff19' + ; // // Whitespace and comments // NEWLINE - : NL+ -> skip - ; + : NL+ -> skip + ; WS - : WhiteSpace+ -> skip - ; + : WhiteSpace+ -> skip + ; COMMENT - : '/*' (COMMENT | .)* '*/' -> skip - ; - + : '/*' (COMMENT | .)* '*/' -> skip + ; LINE_COMMENT - : '//' (~[\r\n])* -> skip - ; + : '//' (~[\r\n])* -> skip + ; \ No newline at end of file diff --git a/scotty/scotty.g4 b/scotty/scotty.g4 index 7eace43084..b9dcf82e25 100644 --- a/scotty/scotty.g4 +++ b/scotty/scotty.g4 @@ -29,68 +29,71 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar scotty; prog - : program_lines EOF - ; + : program_lines EOF + ; program_lines - : prefix_exp - | fn_def program_lines - | var_assign program_lines - ; + : prefix_exp + | fn_def program_lines + | var_assign program_lines + ; var_assign - : identifier '=' prefix_exp - ; + : identifier '=' prefix_exp + ; fn_def - : 'fun' identifier identifier '=' prefix_exp - ; + : 'fun' identifier identifier '=' prefix_exp + ; prefix_exp - : ('+' prefix_exp prefix_exp) - | ('-' prefix_exp prefix_exp) - | ('*' prefix_exp prefix_exp) - | ('/' prefix_exp prefix_exp) - | ('(' identifier prefix_exp ')') - | identifier - | number - ; + : ('+' prefix_exp prefix_exp) + | ('-' prefix_exp prefix_exp) + | ('*' prefix_exp prefix_exp) + | ('/' prefix_exp prefix_exp) + | ('(' identifier prefix_exp ')') + | identifier + | number + ; identifier - : LETTER id_tail - | LETTER - ; + : LETTER id_tail + | LETTER + ; id_tail - : LETTER id_tail - | DIGIT id_tail - | LETTER - | DIGIT - ; + : LETTER id_tail + | DIGIT id_tail + | LETTER + | DIGIT + ; number - : '-' digits - | digits - ; + : '-' digits + | digits + ; digits - : DIGIT digits - | '.' digits - | DIGIT - ; + : DIGIT digits + | '.' digits + | DIGIT + ; DIGIT - : [0-9] - ; + : [0-9] + ; LETTER - : [A-Za-z] - ; + : [A-Za-z] + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/scss/ScssLexer.g4 b/scss/ScssLexer.g4 index 3d5a8d8147..aa452f9c81 100644 --- a/scss/ScssLexer.g4 +++ b/scss/ScssLexer.g4 @@ -27,6 +27,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar ScssLexer; fragment Hex : [0-9a-fA-F]; @@ -36,30 +40,30 @@ fragment Escape : Unicode | '\\' ~[\r\n\f0-9a-fA-F]; fragment Whitespace : Space |; fragment Newline : '\n' | '\r\n' | '\r' | '\f'; fragment ZeroToFourZeros : '0'? '0'? '0'? '0'?; -fragment DashChar : '-' | '\\' ZeroToFourZeros '2d' NewlineOrSpace ; +fragment DashChar : '-' | '\\' ZeroToFourZeros '2d' NewlineOrSpace; -fragment Nmstart : [_a-zA-Z] | Nonascii | Escape; -fragment Nmchar : [_a-zA-Z0-9\-] | Nonascii | Escape; -fragment Nonascii: ~[\u0000-\u007f]; -fragment Name : Nmchar+; -fragment Url : ( [!#$%&*-~] | Nonascii | Escape )*; +fragment Nmstart : [_a-zA-Z] | Nonascii | Escape; +fragment Nmchar : [_a-zA-Z0-9\-] | Nonascii | Escape; +fragment Nonascii : ~[\u0000-\u007f]; +fragment Name : Nmchar+; +fragment Url : ( [!#$%&*-~] | Nonascii | Escape)*; Comment : (LineComment | MultiLineComment) -> skip; -MultiLineComment : '/*' ~'*'* '*'+ ( ~[/*] ~'*'* '*'+ )* '/'; +MultiLineComment : '/*' ~'*'* '*'+ ( ~[/*] ~'*'* '*'+)* '/'; LineComment : '//' ~([\n\r\u2028\u2029])*; Space : [ \t\r\n\f]+ -> skip; -Uri : 'url(' Whitespace (Url | String_) (Space (Url | String_))* Whitespace ')'; -Format : 'format(' Whitespace String_ Whitespace ')'; +Uri : 'url(' Whitespace (Url | String_) (Space (Url | String_))* Whitespace ')'; +Format : 'format(' Whitespace String_ Whitespace ')'; -AbsLength : 'px' | 'cm' | 'mm' | 'pt' | 'pc' | 'q'; -FontRelative : 'em' | 'ex' | 'ch' | 'rem'; -ViewportRelative: 'vw' | 'vh' | 'vmin' | 'vmax'; -Angle : 'deg' | 'rad' | 'grad' | 'turn'; -Resolution : 'dpi' | 'dpcm' | 'dppx'; -Freq : 'hz' | 'khz' | 'fr'; -Time : 'ms' | 's'; -Percentage : '%'; +AbsLength : 'px' | 'cm' | 'mm' | 'pt' | 'pc' | 'q'; +FontRelative : 'em' | 'ex' | 'ch' | 'rem'; +ViewportRelative : 'vw' | 'vh' | 'vmin' | 'vmax'; +Angle : 'deg' | 'rad' | 'grad' | 'turn'; +Resolution : 'dpi' | 'dpcm' | 'dppx'; +Freq : 'hz' | 'khz' | 'fr'; +Time : 'ms' | 's'; +Percentage : '%'; Import : '@import'; Include : '@include'; @@ -78,53 +82,53 @@ Extend : '@extend'; Warn : '@warn'; Error : '@error'; -If : 'if'; -AtIf : '@if'; -AtFor : '@for'; -AtElse : '@else'; -AtWhile : '@while'; -AtEach : '@each'; - -From : 'from'; -To : 'to'; -Through : 'through'; -Only : 'only'; -Not : 'not'; -And : 'and'; -Using : 'using'; -As : 'as'; -With : 'with'; -Or : 'or'; -In : 'in'; +If : 'if'; +AtIf : '@if'; +AtFor : '@for'; +AtElse : '@else'; +AtWhile : '@while'; +AtEach : '@each'; + +From : 'from'; +To : 'to'; +Through : 'through'; +Only : 'only'; +Not : 'not'; +And : 'and'; +Using : 'using'; +As : 'as'; +With : 'with'; +Or : 'or'; +In : 'in'; Default : '!default'; Important : '!important'; -Lparen : '('; -Rparen : ')'; -Lbrack : '['; -Rbrack : ']'; -BlockStart: '{'; -BlockEnd : '}' ; - -Dot : '.' ; -Comma : ','; -Colon : ':'; -Semi : ';'; - -Tilde : '~'; -Under : '_'; -Dollar : '$'; -At : '@'; -Amp : '&'; -Hash : '#'; -True : 'true'; -False : 'false'; - -Plus : '+'; -Div : '/'; -Minus : '-'; -Times : '*'; +Lparen : '('; +Rparen : ')'; +Lbrack : '['; +Rbrack : ']'; +BlockStart : '{'; +BlockEnd : '}'; + +Dot : '.'; +Comma : ','; +Colon : ':'; +Semi : ';'; + +Tilde : '~'; +Under : '_'; +Dollar : '$'; +At : '@'; +Amp : '&'; +Hash : '#'; +True : 'true'; +False : 'false'; + +Plus : '+'; +Div : '/'; +Minus : '-'; +Times : '*'; Eq : '='; NotEq : '!='; @@ -149,13 +153,13 @@ SubstringMatch : '*='; VendorPrefix: '-moz-' | '-webkit-' | '-o-'; -Variable : '--' (Interpolation|Nmstart) (Interpolation|Nmchar)*; -fragment Interpolation: Hash BlockStart Dollar? Ident BlockEnd; -Number : [0-9]+ | [0-9]* '.' [0-9]+; -String_ - : '"' ( ~[\n\r\f\\"] | '\\' Newline | Escape )* '"' - | '\'' ( ~[\n\r\f\\'] | '\\' Newline | Escape )* '\'' - ; +Variable : '--' (Interpolation | Nmstart) (Interpolation | Nmchar)*; +fragment Interpolation : Hash BlockStart Dollar? Ident BlockEnd; +Number : [0-9]+ | [0-9]* '.' [0-9]+; +String_: + '"' (~[\n\r\f\\"] | '\\' Newline | Escape)* '"' + | '\'' ( ~[\n\r\f\\'] | '\\' Newline | Escape)* '\'' +; // Give Ident least priority so that more specific rules matches first -Ident : Nmstart Nmchar*; +Ident: Nmstart Nmchar*; \ No newline at end of file diff --git a/scss/ScssParser.g4 b/scss/ScssParser.g4 index 94266b3b00..f91c400490 100644 --- a/scss/ScssParser.g4 +++ b/scss/ScssParser.g4 @@ -27,12 +27,18 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 ScssParser; -options { tokenVocab=ScssLexer; } +options { + tokenVocab = ScssLexer; +} stylesheet - : statement* EOF; + : statement* EOF + ; statement : importDeclaration @@ -76,7 +82,8 @@ asClause ; withClause - : With Lparen parameters Rparen; + : With Lparen parameters Rparen + ; // Declarations variableDeclaration @@ -94,8 +101,8 @@ variableValue ; variableName - : ( ( Minus Minus ) Dollar | plusMinus Dollar | Dollar) identifier - | plusMinus? namespace_? Dollar ( identifier | measurment ) + : (( Minus Minus) Dollar | plusMinus Dollar | Dollar) identifier + | plusMinus? namespace_? Dollar ( identifier | measurment) | Variable ; @@ -108,38 +115,41 @@ propertyDeclaration ; prio - : Important | Default + : Important + | Default ; propertyValue - : ( value + : ( + value | value? prio? block | variableName | listSpaceSeparated | listCommaSeparated | expression | functionCall - ) prio?; + ) prio? + ; mediaDeclaration : Media mediaQueryList block ; mediaQueryList - : ( mediaQuery ( Comma mediaQuery )* )? + : (mediaQuery ( Comma mediaQuery)*)? ; mediaQuery - : ( Only | Not )? ( identifier | value ) ( And mediaExpression )* - | mediaExpression ( And mediaExpression )* + : (Only | Not)? (identifier | value) (And mediaExpression)* + | mediaExpression ( And mediaExpression)* ; mediaExpression - : Lparen identifier ( Colon value )? Rparen + : Lparen identifier (Colon value)? Rparen ; mixinDeclaration - : Mixin ( identifier| identifier Lparen parameters Rparen ) block + : Mixin (identifier | identifier Lparen parameters Rparen) block ; contentDeclaration @@ -164,8 +174,7 @@ percentageStatement ; includeDeclaration - : Include namespace_? (identifier | functionCall) - ( Semi | Using Lparen parameters Rparen )? block? + : Include namespace_? (identifier | functionCall) (Semi | Using Lparen parameters Rparen)? block? ; interpolationDeclaration @@ -173,8 +182,16 @@ interpolationDeclaration ; extendDeclaration - : Extend ( Percentage | parentRef )? - ( id | typeSelector | universal | className | attrib | pseudo | interpolation | parentRef )+ Semi? + : Extend (Percentage | parentRef)? ( + id + | typeSelector + | universal + | className + | attrib + | pseudo + | interpolation + | parentRef + )+ Semi? ; warndingDeclaration @@ -186,7 +203,7 @@ errorDeclaration ; atStatementDeclaration - : At ( identifier Lparen parameters Rparen | identifier ) block + : At (identifier Lparen parameters Rparen | identifier) block ; // Structure @@ -200,11 +217,11 @@ block // Selectors selectorGroup - : selector ( Comma selector )* + : selector (Comma selector)* ; selector - : combinator? selectorSequence ( combinator selectorSequence )* + : combinator? selectorSequence (combinator selectorSequence)* ; combinator @@ -215,8 +232,25 @@ combinator ; selectorSequence - : ( typeSelector | universal ) ( id | className | attrib | pseudo | negation | interpolation ( variableName | Percentage )? | parentRef )* - | ( typeSelector| id | className | attrib | pseudo | negation | interpolation ( variableName | Percentage )? | parentRef )+ + : (typeSelector | universal) ( + id + | className + | attrib + | pseudo + | negation + | interpolation ( variableName | Percentage)? + | parentRef + )* + | ( + typeSelector + | id + | className + | attrib + | pseudo + | negation + | interpolation ( variableName | Percentage)? + | parentRef + )+ ; id @@ -224,11 +258,11 @@ id ; typeSelector - : typeNamespacePrefix? ( Percentage | parentRef )? ( identifier | variableName ) + : typeNamespacePrefix? (Percentage | parentRef)? (identifier | variableName) ; typeNamespacePrefix - : ( identifier | Times )? Pipe + : (identifier | Times)? Pipe ; universal @@ -236,11 +270,11 @@ universal ; className - : Dot ( Minus | identifier | interpolation )+ + : Dot (Minus | identifier | interpolation)+ ; interpolation - : namespace_? Hash BlockStart namespace_? ( ifExpression | value | parentRef ) BlockEnd measurment? + : namespace_? Hash BlockStart namespace_? (ifExpression | value | parentRef) BlockEnd measurment? ; parentRef @@ -248,13 +282,16 @@ parentRef ; attrib - : Lbrack typeNamespacePrefix? identifier - ( ( PrefixMatch | SuffixMatch | SubstringMatch | Eq | Includes | DashMatch ) - ( identifier | String_ ) )? Rbrack + : Lbrack typeNamespacePrefix? identifier ( + (PrefixMatch | SuffixMatch | SubstringMatch | Eq | Includes | DashMatch) ( + identifier + | String_ + ) + )? Rbrack ; pseudo - : Colon Colon? ( interpolation | identifier | functionalPseudo ) + : Colon Colon? (interpolation | identifier | functionalPseudo) ; functionalPseudo @@ -262,7 +299,7 @@ functionalPseudo ; pseudoParameter - : ( ( value | className | interpolation ) Comma?) + : (( value | className | interpolation) Comma?) ; negation @@ -320,8 +357,7 @@ value // Function functionDeclaration - : Function ( namespace_? identifier )? - Lparen parameters Rparen BlockStart functionBody? BlockEnd + : Function (namespace_? identifier)? Lparen parameters Rparen BlockStart functionBody? BlockEnd ; parameters @@ -329,7 +365,7 @@ parameters ; parameter - : ( value | variableDeclaration | listSpaceSeparated | mapDeclaration ) arglist? prio? + : (value | variableDeclaration | listSpaceSeparated | mapDeclaration) arglist? prio? ; functionBody @@ -350,7 +386,7 @@ functionCall ; expression - : Not? expressionPart (operator_ Not? expressionPart )* + : Not? expressionPart (operator_ Not? expressionPart)* ; expressionPart @@ -376,17 +412,14 @@ expressionPart ; ifExpression - : If Lparen ( expression | parentRef ) Comma value Comma value Rparen measurment? prio? + : If Lparen (expression | parentRef) Comma value Comma value Rparen measurment? prio? ; - // List & Map listDeclaration - : ( listBracketed - | listCommaSeparated - | listSpaceSeparated - ) - | Lparen listDeclaration Rparen; + : (listBracketed | listCommaSeparated | listSpaceSeparated) + | Lparen listDeclaration Rparen + ; listCommaSeparated : listElement (Comma listElement)* Comma? @@ -397,7 +430,7 @@ listSpaceSeparated ; listBracketed - : Lbrack ( listSpaceSeparated | listCommaSeparated ) Rbrack + : Lbrack (listSpaceSeparated | listCommaSeparated) Rbrack ; listElement @@ -442,7 +475,7 @@ elseStatement ; forDeclaration - : AtFor variableName From Number ( To | Through ) through block + : AtFor variableName From Number (To | Through) through block ; through @@ -487,15 +520,15 @@ repeat // Primitives unit - : ( length | dimension | percentage | degree ) + : (length | dimension | percentage | degree) ; length - : plusMinus? Number ( AbsLength | FontRelative | ViewportRelative ) + : plusMinus? Number (AbsLength | FontRelative | ViewportRelative) ; dimension - : plusMinus? Number ( Time | Freq | Resolution | Angle) + : plusMinus? Number (Time | Freq | Resolution | Angle) ; percentage @@ -535,7 +568,7 @@ hexcolor ; color - : ( Number | Ident )+ + : (Number | Ident)+ ; boolean @@ -548,7 +581,7 @@ number ; identifier - : ( VendorPrefix | Minus )? Ident + : (VendorPrefix | Minus)? Ident | From | To ; \ No newline at end of file diff --git a/semver/SemanticVersionLexer.g4 b/semver/SemanticVersionLexer.g4 index c7d5318066..93490ba62a 100644 --- a/semver/SemanticVersionLexer.g4 +++ b/semver/SemanticVersionLexer.g4 @@ -1,27 +1,33 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar SemanticVersionLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} -fragment POSITIVE_DIGIT: [1-9]; -fragment LETTER: [a-z]; +fragment POSITIVE_DIGIT : [1-9]; +fragment LETTER : [a-z]; -DASH: '-'; -PLUS: '+'; -DOT: '.'; +DASH : '-'; +PLUS : '+'; +DOT : '.'; //most common pre-release "modifiers" -ALPHA: 'alpha'; -BETA: 'beta'; -RC: 'rc' | 'release' ('-' | '.') 'candidate'; -SNAPSHOT: 'snapshot'; -PREVIEW: 'p' | 'pre' | 'preview'; -DEV: 'dev' | 'devel' | 'development'; -MILESTONE: 'mt' | 'milestone'; -DAILY: 'daily'; -NIGHTLY: 'nightly'; -BUILD: 'bld' | 'build'; -TEST: 'test'; -EXPERIMENTAL: 'experimental'; +ALPHA : 'alpha'; +BETA : 'beta'; +RC : 'rc' | 'release' ('-' | '.') 'candidate'; +SNAPSHOT : 'snapshot'; +PREVIEW : 'p' | 'pre' | 'preview'; +DEV : 'dev' | 'devel' | 'development'; +MILESTONE : 'mt' | 'milestone'; +DAILY : 'daily'; +NIGHTLY : 'nightly'; +BUILD : 'bld' | 'build'; +TEST : 'test'; +EXPERIMENTAL : 'experimental'; NUMBER: '0' | POSITIVE_DIGIT+; diff --git a/semver/SemanticVersionParser.g4 b/semver/SemanticVersionParser.g4 index c11ba4ab94..69995901c0 100644 --- a/semver/SemanticVersionParser.g4 +++ b/semver/SemanticVersionParser.g4 @@ -1,8 +1,14 @@ +// $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 SemanticVersionParser; -options { tokenVocab = SemanticVersionLexer; } +options { + tokenVocab = SemanticVersionLexer; +} -tag: ALPHA +tag + : ALPHA | BETA | RC | SNAPSHOT @@ -16,22 +22,26 @@ tag: ALPHA | EXPERIMENTAL ; -build: - value = NUMBER #BuildNumber - | DASH #BuildDash - | tag (DOT | DASH)? version = (NUMBER | IDENTIFIER)? #BuildTagged - | value = IDENTIFIER #BuildIdentifier - | left = build (DOT | DASH)? right = build #BuildIdentifierExtended +build + : value = NUMBER # BuildNumber + | DASH # BuildDash + | tag (DOT | DASH)? version = (NUMBER | IDENTIFIER)? # BuildTagged + | value = IDENTIFIER # BuildIdentifier + | left = build (DOT | DASH)? right = build # BuildIdentifierExtended ; -preRelease: - value = NUMBER #PreReleaseNumber - | DASH #PreReleaseDash - | tag (DOT | DASH)? version = (NUMBER | IDENTIFIER)? #PreReleaseTagged - | value = IDENTIFIER #PreReleaseIdentifier - | left = preRelease (DOT | DASH)? right = preRelease #PreReleaseIdentifierExtended +preRelease + : value = NUMBER # PreReleaseNumber + | DASH # PreReleaseDash + | tag (DOT | DASH)? version = (NUMBER | IDENTIFIER)? # PreReleaseTagged + | value = IDENTIFIER # PreReleaseIdentifier + | left = preRelease (DOT | DASH)? right = preRelease # PreReleaseIdentifierExtended ; -versionCore: major = NUMBER DOT minor = NUMBER DOT patch = NUMBER; +versionCore + : major = NUMBER DOT minor = NUMBER DOT patch = NUMBER + ; -semver: versionCore (DASH preRelease (PLUS build)? | PLUS build)? EOF; \ No newline at end of file +semver + : versionCore (DASH preRelease (PLUS build)? | PLUS build)? EOF + ; \ No newline at end of file diff --git a/sexpression/sexpression.g4 b/sexpression/sexpression.g4 index 402e50b165..f5d7124878 100644 --- a/sexpression/sexpression.g4 +++ b/sexpression/sexpression.g4 @@ -26,68 +26,71 @@ THE SOFTWARE. /* Port to Antlr4 by Tom Everett */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar sexpression; sexpr - : item* EOF - ; + : item* EOF + ; item - : atom - | list_ - | LPAREN item DOT item RPAREN - ; + : atom + | list_ + | LPAREN item DOT item RPAREN + ; list_ - : LPAREN item* RPAREN - ; + : LPAREN item* RPAREN + ; atom - : STRING - | SYMBOL - | NUMBER - | DOT - ; + : STRING + | SYMBOL + | NUMBER + | DOT + ; STRING - : '"' ('\\' . | ~ ('\\' | '"'))* '"' - ; + : '"' ('\\' . | ~ ('\\' | '"'))* '"' + ; WHITESPACE - : (' ' | '\n' | '\t' | '\r')+ -> skip - ; + : (' ' | '\n' | '\t' | '\r')+ -> skip + ; NUMBER - : ('+' | '-')? (DIGIT)+ ('.' (DIGIT)+)? - ; + : ('+' | '-')? (DIGIT)+ ('.' (DIGIT)+)? + ; SYMBOL - : SYMBOL_START (SYMBOL_START | DIGIT)* - ; + : SYMBOL_START (SYMBOL_START | DIGIT)* + ; LPAREN - : '(' - ; + : '(' + ; RPAREN - : ')' - ; + : ')' + ; DOT - : '.' - ; + : '.' + ; fragment SYMBOL_START - : ('a' .. 'z') - | ('A' .. 'Z') - | '+' - | '-' - | '*' - | '/' - | '.' - ; + : ('a' .. 'z') + | ('A' .. 'Z') + | '+' + | '-' + | '*' + | '/' + | '.' + ; fragment DIGIT - : ('0' .. '9') - ; - + : ('0' .. '9') + ; \ No newline at end of file diff --git a/sgf/sgf.g4 b/sgf/sgf.g4 index 595c254cc5..55ff798a3b 100644 --- a/sgf/sgf.g4 +++ b/sgf/sgf.g4 @@ -5,135 +5,166 @@ See agpl-3.0.txt for legal details. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar sgf; -collection : gameTree+ EOF; -gameTree : '(' sequence gameTree* ')'; -sequence : node+; -node : ';' property_*; -property_ : - move - | setup - | nodeAnnotation - | moveAnnotation - | markup - | root - | gameInfo - | timing - | misc - | loa - | go_ - | privateProp - ; - -move : - COLOR (NONE | TEXT) - | 'KO' NONE - | 'MN' TEXT - ; - -setup : - 'AB' TEXT+ - | 'AE' TEXT+ - | 'AW' TEXT+ - | 'PL' TEXT - ; - -nodeAnnotation : - 'C' TEXT - | 'DM' TEXT - | 'GB' TEXT - | 'GW' TEXT - | 'HO' TEXT - | 'N' TEXT - | 'UC' TEXT - | 'V' TEXT - ; - -moveAnnotation: - 'BM' TEXT - | 'DO' NONE - | 'IT' NONE - | 'TE' TEXT - ; - -markup : - 'AR' TEXT+ - | 'CR' TEXT+ - | 'DD' (NONE | TEXT+) - | 'LB' TEXT+ - | 'LN' TEXT+ - | 'MA' TEXT+ - | 'SL' TEXT+ - | 'SQ' TEXT+ - | 'TR' TEXT+ - ; - -root : 'AP' TEXT - | 'CA' TEXT - | 'FF' TEXT - | 'GM' TEXT - | 'ST' TEXT - | 'SZ' TEXT - ; - -gameInfo : - 'AN' TEXT - | 'BR' TEXT - | 'BT' TEXT - | 'CP' TEXT - | 'DT' TEXT - | 'EV' TEXT - | 'GN' TEXT - | 'GC' TEXT - | 'ON' TEXT - | 'OT' TEXT - | 'PB' TEXT - | 'PC' TEXT - | 'PW' TEXT - | 'RE' TEXT - | 'RO' TEXT - | 'RU' TEXT - | 'SO' TEXT - | 'TM' TEXT - | 'US' TEXT - | 'WR' TEXT - | 'WT' TEXT - ; - -timing : - 'BL' TEXT - | 'OB' TEXT - | 'OW' TEXT - | 'WL' TEXT - ; - -misc : - 'FG' (NONE | TEXT) - | 'PM' TEXT - | 'VW' TEXT+ - ; - -loa : - 'AS' TEXT - | 'IP' TEXT - | 'IY' TEXT - | 'SE' TEXT - | 'SU' TEXT - ; - -go_ : - 'HA' TEXT - | 'KM' TEXT - | 'TB' (NONE | TEXT+) - | 'TW' (NONE | TEXT+) - ; - -privateProp : UCLETTER (NONE | TEXT+); - -COLOR : ('W'|'B'); -UCLETTER : 'A'..'Z' 'A'..'Z'+; -NONE : '[]'; -TEXT : '['('\\]'|.)*?']'; - -WS : [ \n\r\t]+ -> skip; +collection + : gameTree+ EOF + ; + +gameTree + : '(' sequence gameTree* ')' + ; + +sequence + : node+ + ; + +node + : ';' property_* + ; + +property_ + : move + | setup + | nodeAnnotation + | moveAnnotation + | markup + | root + | gameInfo + | timing + | misc + | loa + | go_ + | privateProp + ; + +move + : COLOR (NONE | TEXT) + | 'KO' NONE + | 'MN' TEXT + ; + +setup + : 'AB' TEXT+ + | 'AE' TEXT+ + | 'AW' TEXT+ + | 'PL' TEXT + ; + +nodeAnnotation + : 'C' TEXT + | 'DM' TEXT + | 'GB' TEXT + | 'GW' TEXT + | 'HO' TEXT + | 'N' TEXT + | 'UC' TEXT + | 'V' TEXT + ; + +moveAnnotation + : 'BM' TEXT + | 'DO' NONE + | 'IT' NONE + | 'TE' TEXT + ; + +markup + : 'AR' TEXT+ + | 'CR' TEXT+ + | 'DD' (NONE | TEXT+) + | 'LB' TEXT+ + | 'LN' TEXT+ + | 'MA' TEXT+ + | 'SL' TEXT+ + | 'SQ' TEXT+ + | 'TR' TEXT+ + ; + +root + : 'AP' TEXT + | 'CA' TEXT + | 'FF' TEXT + | 'GM' TEXT + | 'ST' TEXT + | 'SZ' TEXT + ; + +gameInfo + : 'AN' TEXT + | 'BR' TEXT + | 'BT' TEXT + | 'CP' TEXT + | 'DT' TEXT + | 'EV' TEXT + | 'GN' TEXT + | 'GC' TEXT + | 'ON' TEXT + | 'OT' TEXT + | 'PB' TEXT + | 'PC' TEXT + | 'PW' TEXT + | 'RE' TEXT + | 'RO' TEXT + | 'RU' TEXT + | 'SO' TEXT + | 'TM' TEXT + | 'US' TEXT + | 'WR' TEXT + | 'WT' TEXT + ; + +timing + : 'BL' TEXT + | 'OB' TEXT + | 'OW' TEXT + | 'WL' TEXT + ; + +misc + : 'FG' (NONE | TEXT) + | 'PM' TEXT + | 'VW' TEXT+ + ; + +loa + : 'AS' TEXT + | 'IP' TEXT + | 'IY' TEXT + | 'SE' TEXT + | 'SU' TEXT + ; + +go_ + : 'HA' TEXT + | 'KM' TEXT + | 'TB' (NONE | TEXT+) + | 'TW' (NONE | TEXT+) + ; + +privateProp + : UCLETTER (NONE | TEXT+) + ; + +COLOR + : ('W' | 'B') + ; + +UCLETTER + : 'A' ..'Z' 'A' ..'Z'+ + ; + +NONE + : '[]' + ; + +TEXT + : '[' ('\\]' | .)*? ']' + ; + +WS + : [ \n\r\t]+ -> skip + ; \ No newline at end of file diff --git a/sharc/SHARCLexer.g4 b/sharc/SHARCLexer.g4 index f153657fff..d31ac1763e 100644 --- a/sharc/SHARCLexer.g4 +++ b/sharc/SHARCLexer.g4 @@ -1,2170 +1,883 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true lexer grammar SHARCLexer; //tokens -StringLiteral - : - //'"' (ID | EscapeSequence | NormalChar | WS )* '"' '"' ~ ( '\n' | '\r' | '"' )* '"' - ; +StringLiteral: + //'"' (ID | EscapeSequence | NormalChar | WS )* '"' '"' ~ ( '\n' | '\r' | '"' )* '"' +; +CharLiteral: + // '\'' (ID | EscapeSequence | NormalChar | WS )* '\'' '\'' ~ ( '\n' | '\r' | '\'' )* '\'' +; -CharLiteral - : - // '\'' (ID | EscapeSequence | NormalChar | WS )* '\'' '\'' ~ ( '\n' | '\r' | '\'' )* '\'' - ; +fragment HexPrefix: '0x' | '0X'; +fragment HexDigit: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F'); -fragment HexPrefix - : '0x' | '0X' - ; +INT: + ('0' .. '9')+ '.' ('0' .. '9')* Exponent? + | '.' ( '0' .. '9')+ Exponent? + | ( '0' .. '9')+ Exponent + | ( '0' .. '9')+ + | HexPrefix ( HexDigit)+ +; +fragment Exponent: ( 'e' | 'E') ( '+' | '-')? ( '0' .. '9')+; -fragment HexDigit - : ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) - ; +fragment LCHAR: CHAR | '_'; +fragment CHAR: LC | UC; -INT - : ( '0' .. '9' )+ '.' ( '0' .. '9' )* Exponent? | '.' ( '0' .. '9' )+ Exponent? | ( '0' .. '9' )+ Exponent | ( '0' .. '9' )+ | HexPrefix ( HexDigit )+ - ; +fragment LC: 'a' .. 'z'; +fragment UC: 'A' .. 'Z'; -fragment Exponent - : ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ - ; +WS: ( ' ' | '\t' | '\r' | '\n') -> skip; +DOT_ADI_: '_ADI_'; -fragment LCHAR - : CHAR | '_' - ; +DOT_DATE_: '_DATE_'; +DOT_FILE_: '_FILE'; -fragment CHAR - : LC | UC - ; +DOT_ALGIGN: '.align'; +DOT_COMPRESS: '.compress'; -fragment LC - : 'a' .. 'z' - ; +DOT_ELIF: '.elif'; +DOT_ELSE: '.else'; -fragment UC - : 'A' .. 'Z' - ; +DOT_ENDIF: '.endif'; +DOT_EXTERN: '.extern'; -WS - : ( ' ' | '\t' | '\r' | '\n' ) -> skip - ; +DOT_FILE: '.file'; +DOT_FILE_ATTR: '.file_attr'; -DOT_ADI_ - : '_ADI_' - ; +DOT_FORCECOMPRESS: '.forcecompress'; +DOT_GLOBAL: '.global'; -DOT_DATE_ - : '_DATE_' - ; +DOT_IF: '.if'; +DOT_IMPORT: '.import'; -DOT_FILE_ - : '_FILE' - ; +DOT_INCBINARY: '.inc/binary'; +DOT_LEFTMARGIN: '.leftmargin'; -DOT_ALGIGN - : '.align' - ; +DOT_LIST: '.list'; +DOT_LIST_DATA: '.list_data'; -DOT_COMPRESS - : '.compress' - ; +DOT_LIST_DATFILE: '.list_datfile'; +DOT_LIST_DEFTAB: '.list_deftab'; -DOT_ELIF - : '.elif' - ; +DOT_LIST_LOCTAB: '.list_loctab'; +DOT_LIST_WRAPDATA: '.list_wrapdata'; -DOT_ELSE - : '.else' - ; +DOT_NEWPAGE: '.newpage'; +DOT_NOCOMPRESS: '.nocompress'; -DOT_ENDIF - : '.endif' - ; +DOT_NOLIST_DATA: '.nolist_data'; +DOT_NOLIST_DATFILE: '.nolist_datfile'; -DOT_EXTERN - : '.extern' - ; +DOT_NOLIST_WRAPDATA: '.nolist_wrapdata'; +DOT_PAGELENGTH: '.pagelength'; -DOT_FILE - : '.file' - ; +DOT_PAGEWIDTH: '.pagewidth'; +DOT_PRECISION: '.precision'; -DOT_FILE_ATTR - : '.file_attr' - ; +DOT_ROUND_MINUS: '.round_minus'; +DOT_ROUND_NEAREST: '.round_nearest'; -DOT_FORCECOMPRESS - : '.forcecompress' - ; +DOT_ROUND_PLUS: '.round_plus'; +DOT_ROUND_ZERO: '.round_zero'; -DOT_GLOBAL - : '.global' - ; +DOT_PREVIOUS: '.previous'; +DOT_SECTION: '.section'; -DOT_IF - : '.if' - ; +DOT_SEGMENT: '.segment'; +DOT_ENDSEG: '.endseg'; -DOT_IMPORT - : '.import' - ; +DOT_STRUCT: '.struct'; +DOT_TYPE: '.type'; -DOT_INCBINARY - : '.inc/binary' - ; +DOT_VAR: '.var'; +DOT_WEAK: '.weak'; -DOT_LEFTMARGIN - : '.leftmargin' - ; +ABS: 'abs'; +AC: 'ac'; -DOT_LIST - : '.list' - ; +ACS: 'acs'; +ACT: 'act'; -DOT_LIST_DATA - : '.list_data' - ; +ADDRESS: 'address'; +AND: 'and'; -DOT_LIST_DATFILE - : '.list_datfile' - ; +ASHIFT: 'ashift'; +ASTAT: 'astat'; -DOT_LIST_DEFTAB - : '.list_deftab' - ; +AV: 'av'; +B0: 'b0'; -DOT_LIST_LOCTAB - : '.list_loctab' - ; +B1: 'b1'; +B2: 'b2'; -DOT_LIST_WRAPDATA - : '.list_wrapdata' - ; +B3: 'b3'; +B4: 'b4'; -DOT_NEWPAGE - : '.newpage' - ; +B5: 'b5'; +B6: 'b6'; -DOT_NOCOMPRESS - : '.nocompress' - ; +B7: 'b7'; +B8: 'b8'; -DOT_NOLIST_DATA - : '.nolist_data' - ; +B9: 'b9'; +B10: 'b10'; -DOT_NOLIST_DATFILE - : '.nolist_datfile' - ; +B11: 'b11'; +B12: 'b12'; -DOT_NOLIST_WRAPDATA - : '.nolist_wrapdata' - ; +B13: 'b13'; +B14: 'b14'; -DOT_PAGELENGTH - : '.pagelength' - ; +B15: 'b15'; +BB: 'bb'; -DOT_PAGEWIDTH - : '.pagewidth' - ; +BCLR: 'bclr'; +BF: 'bf'; -DOT_PRECISION - : '.precision' - ; +BIT: 'bit'; +BITREV: 'bitrev'; -DOT_ROUND_MINUS - : '.round_minus' - ; +BM: 'bm'; +BSET: 'bset'; -DOT_ROUND_NEAREST - : '.round_nearest' - ; +BTGL: 'btgl'; +BTST: 'btst'; -DOT_ROUND_PLUS - : '.round_plus' - ; +BY: 'by'; +CA: 'ca'; -DOT_ROUND_ZERO - : '.round_zero' - ; +CACHE: 'cache'; +CALL: 'call'; -DOT_PREVIOUS - : '.previous' - ; +CH: 'ch'; +CI: 'ci'; -DOT_SECTION - : '.section' - ; +CJUMP: 'cjump'; +CL: 'cl'; -DOT_SEGMENT - : '.segment' - ; +CLR: 'clr'; +CLIP: 'clip'; -DOT_ENDSEG - : '.endseg' - ; +COMP: 'comp'; +COPYSIGN: 'copysign'; -DOT_STRUCT - : '.struct' - ; +COS: 'cos'; +CURLCNTR: 'curlcntr'; -DOT_TYPE - : '.type' - ; +DADDR: 'daddr'; +DB: 'db'; -DOT_VAR - : '.var' - ; +DEC: 'dec'; +DEF: 'def'; -DOT_WEAK - : '.weak' - ; +DIM: 'dim'; +DM: 'dm'; -ABS - : 'abs' - ; +DMA1E: 'dm1e'; +DMA1s: 'dm1s'; -AC - : 'ac' - ; +DMA2E: 'dm2e'; +DMA2s: 'dm2s'; -ACS - : 'acs' - ; +DMADR: 'dmadr'; +DMABANK1: 'dmabank1'; -ACT - : 'act' - ; +DMABANK2: 'dmabank2'; +DMABANK3: 'dmabank3'; -ADDRESS - : 'address' - ; +DMAWAIT: 'dmawait'; +DO: 'do'; -AND - : 'and' - ; +DOVL: 'dovl'; +EB: 'eb'; -ASHIFT - : 'ashift' - ; +ECE: 'ece'; +EF: 'ef'; -ASTAT - : 'astat' - ; +ELSE: 'else'; +EMUCLK: 'emuclk'; -AV - : 'av' - ; +EMUCLK2: 'emuclk2'; +EMUIDLE: 'emuidle'; -B0 - : 'b0' - ; +EMUN: 'emun'; +EOS: 'eos'; -B1 - : 'b1' - ; +EQ: 'eq'; +EX: 'ex'; -B2 - : 'b2' - ; +EXP: 'exp'; +EXP2: 'exp2'; -B3 - : 'b3' - ; +F0: 'f0'; +F1: 'f1'; -B4 - : 'b4' - ; +F2: 'f2'; +F3: 'f3'; -B5 - : 'b5' - ; +F4: 'f4'; +F5: 'f5'; -B6 - : 'b6' - ; +F6: 'f6'; +F7: 'f7'; -B7 - : 'b7' - ; +F8: 'f8'; +F9: 'f9'; -B8 - : 'b8' - ; +F10: 'f10'; +F11: 'f11'; -B9 - : 'b9' - ; +F12: 'f12'; +F13: 'f13'; -B10 - : 'b10' - ; +F14: 'f14'; +F15: 'f15'; -B11 - : 'b11' - ; +FADDR: 'faddr'; +FDEP: 'fdep'; -B12 - : 'b12' - ; +FEXT: 'fext'; +FILE: 'file'; -B13 - : 'b13' - ; +FIX: 'fix'; +FLAG0_IN: 'flag0_in'; -B14 - : 'b14' - ; +FLAG1_IN: 'flag1_in'; +FLAG2_IN: 'flag2_in'; -B15 - : 'b15' - ; +FLAG3_IN: 'flag3_in'; +FLOAT: 'float'; -BB - : 'bb' - ; +FLUSH: 'flush'; +FMERG: 'fmerg'; -BCLR - : 'bclr' - ; +FOREVER: 'forever'; +FPACK: 'fpack'; -BF - : 'bf' - ; +FRACTIONAL: 'fractional'; +FTA: 'fta'; -BIT - : 'bit' - ; +FTB: 'ftb'; +FTC: 'ftc'; -BITREV - : 'bitrev' - ; +FUNPACK: 'funpack'; +GCC_COMPILED: 'gcc_compiled'; -BM - : 'bm' - ; +GE: 'ge'; +GT: 'gt'; -BSET - : 'bset' - ; +I0: 'i0'; +I1: 'i1'; -BTGL - : 'btgl' - ; +I2: 'i2'; +I3: 'i3'; -BTST - : 'btst' - ; +I4: 'i4'; +I5: 'i5'; -BY - : 'by' - ; +I6: 'i6'; +I7: 'i7'; -CA - : 'ca' - ; +I8: 'i8'; +I9: 'i9'; -CACHE - : 'cache' - ; +I10: 'i10'; +I11: 'i11'; -CALL - : 'call' - ; +I12: 'i12'; +I13: 'i13'; -CH - : 'ch' - ; +I14: 'i14'; +I15: 'i15'; -CI - : 'ci' - ; +IDLE: 'idle'; +IDLE16: 'idle16'; -CJUMP - : 'cjump' - ; +IDLEI15: 'idlei15'; +IDLEI16: 'idlei16'; -CL - : 'cl' - ; +IF: 'if'; +IMASK: 'imask'; -CLR - : 'clr' - ; +IMASKP: 'imaskp'; +INC: 'inc'; -CLIP - : 'clip' - ; +IRPTL: 'irptl'; +JUMP: 'jump'; -COMP - : 'comp' - ; +L0: 'l0'; +L1: 'l1'; -COPYSIGN - : 'copysign' - ; +L2: 'l2'; +L3: 'l3'; -COS - : 'cos' - ; +L4: 'l4'; +L5: 'l5'; -CURLCNTR - : 'curlcntr' - ; +L6: 'l6'; +L7: 'l7'; -DADDR - : 'daddr' - ; +L8: 'l8'; +L9: 'l9'; -DB - : 'db' - ; +L10: 'l10'; +L11: 'l11'; -DEC - : 'dec' - ; +L12: 'l12'; +L13: 'l13'; -DEF - : 'def' - ; +L14: 'l14'; +L15: 'l15'; -DIM - : 'dim' - ; +LA: 'la'; +LADDR: 'laddr'; -DM - : 'dm' - ; +LCE: 'lce'; +LCNTR: 'lcntr'; -DMA1E - : 'dm1e' - ; +LE: 'le'; +LEFTO: 'lefto'; -DMA1s - : 'dm1s' - ; +LEFTZ: 'leftz'; +LENGTH: 'length'; -DMA2E - : 'dm2e' - ; +LINE: 'line'; +LN: 'ln'; -DMA2s - : 'dm2s' - ; +LOAD: 'load'; +LOG2: 'log2'; -DMADR - : 'dmadr' - ; +LOGB: 'logb'; +LOOP: 'loop'; -DMABANK1 - : 'dmabank1' - ; +LR: 'lr'; +LSHIFT: 'lshift'; -DMABANK2 - : 'dmabank2' - ; +LT: 'lt'; +M0: 'm0'; -DMABANK3 - : 'dmabank3' - ; +M1: 'm1'; +M2: 'm2'; -DMAWAIT - : 'dmawait' - ; +M3: 'm3'; +M4: 'm4'; -DO - : 'do' - ; +M5: 'm5'; +M6: 'm6'; -DOVL - : 'dovl' - ; +M7: 'm7'; +M8: 'm8'; -EB - : 'eb' - ; +M9: 'm9'; +M10: 'm10'; -ECE - : 'ece' - ; +M11: 'm11'; +M12: 'm12'; -EF - : 'ef' - ; +M13: 'm13'; +M14: 'm14'; -ELSE - : 'else' - ; +M15: 'm15'; +MANT: 'mant'; -EMUCLK - : 'emuclk' - ; +MAX: 'max'; +MBM: 'mbm'; -EMUCLK2 - : 'emuclk2' - ; +MIN: 'min'; +MOD: 'mod'; -EMUIDLE - : 'emuidle' - ; +MODE1: 'mode1'; +MODE2: 'mode2'; -EMUN - : 'emun' - ; +MODIFY: 'modify'; +MR0B: 'mr0b'; -EOS - : 'eos' - ; +MR0F: 'mr0f'; +MR1B: 'mr1b'; -EQ - : 'eq' - ; +MR1F: 'mr1f'; +MR2B: 'mr2b'; -EX - : 'ex' - ; +MR2F: 'mr2f'; +MRB: 'mrb'; -EXP - : 'exp' - ; +MRF: 'mrf'; +MS: 'ms'; -EXP2 - : 'exp2' - ; +MV: 'mv'; +NBM: 'nbm'; -F0 - : 'f0' - ; +NE: 'ne'; +NOFO: 'nofo'; -F1 - : 'f1' - ; +NOFZ: 'nofz'; +NOP: 'nop'; -F2 - : 'f2' - ; +NOPSPECIAL: 'nopspecial'; +NOT: 'not'; -F3 - : 'f3' - ; +NU: 'nu'; +NW: 'nw'; -F4 - : 'f4' - ; +OFFSETOF: 'offsetof'; +OR: 'or'; -F5 - : 'f5' - ; +P20: 'p20'; +P32: 'p32'; -F6 - : 'f6' - ; +P40: 'p40'; +PACK: 'pack'; -F7 - : 'f7' - ; +PAGE: 'page'; +PASS: 'pass'; -F8 - : 'f8' - ; +PC: 'pc'; +PCSTK: 'pcstk'; -F9 - : 'f9' - ; +PCSTKP: 'pcstkp'; +PM: 'pm'; -F10 - : 'f10' - ; +PMADR: 'pmadr'; +PMBANK1: 'pmbank1'; -F11 - : 'f11' - ; +PMDAE: 'pmdae'; +PMDAS: 'pmdas'; -F12 - : 'f12' - ; +POP: 'pop'; +POVL0: 'povl0'; -F13 - : 'f13' - ; +POVL1: 'povl1'; +PSA1E: 'psa1e'; -F14 - : 'f14' - ; +PSA1S: 'psa1s'; +PSA2E: 'psa2e'; -F15 - : 'f15' - ; +PSA3E: 'psa3e'; +PSA3S: 'psa3s'; -FADDR - : 'faddr' - ; +PSA4E: 'psa4e'; +PSA4S: 'psa4s'; -FDEP - : 'fdep' - ; +PUSH: 'push'; +PX: 'px'; -FEXT - : 'fext' - ; +PX1: 'px1'; +PX2: 'px2'; -FILE - : 'file' - ; +RETAIN_NAME: 'retain_name'; +R0: 'r0'; -FIX - : 'fix' - ; +R1: 'r1'; +R2: 'r2'; -FLAG0_IN - : 'flag0_in' - ; +R3: 'r3'; +R4: 'r4'; -FLAG1_IN - : 'flag1_in' - ; +R5: 'r5'; +R6: 'r6'; -FLAG2_IN - : 'flag2_in' - ; +R7: 'r7'; +R8: 'r8'; -FLAG3_IN - : 'flag3_in' - ; +R9: 'r9'; +R10: 'r10'; -FLOAT - : 'float' - ; +R11: 'r11'; +R12: 'r12'; -FLUSH - : 'flush' - ; +R13: 'r13'; +R14: 'r14'; -FMERG - : 'fmerg' - ; +R15: 'r15'; +READ: 'read'; -FOREVER - : 'forever' - ; +RECIPS: 'recips'; +RFRAME: 'rframe'; -FPACK - : 'fpack' - ; +RND: 'rnd'; +ROT: 'rot'; -FRACTIONAL - : 'fractional' - ; +RS: 'rs'; +RSQRTS: 'rsqrts'; -FTA - : 'fta' - ; +RTI: 'rti'; +RTS: 'rts'; -FTB - : 'ftb' - ; +SAT: 'sat'; +SCALB: 'scalb'; -FTC - : 'ftc' - ; +SCL: 'scl'; +SE: 'se'; -FUNPACK - : 'funpack' - ; +SET: 'set'; +SF: 'sf'; -GCC_COMPILED - : 'gcc_compiled' - ; +SI: 'si'; +SIN: 'sin'; -GE - : 'ge' - ; +SIZE: 'size'; +SIZEOF: 'sizeof'; -GT - : 'gt' - ; +SQR: 'sqr'; +SR: 'sr'; -I0 - : 'i0' - ; +SSF: 'ssf'; +SSFR: 'ssfr'; -I1 - : 'i1' - ; +SSI: 'ssi'; +SSIR: 'ssir'; -I2 - : 'i2' - ; +ST: 'st'; +STEP: 'step'; -I3 - : 'i3' - ; +STKY: 'stky'; +STRUCT: 'struct'; -I4 - : 'i4' - ; +STS: 'sts'; +SUF: 'suf'; -I5 - : 'i5' - ; +SUFR: 'sufr'; +SUI: 'sui'; -I6 - : 'i6' - ; +SV: 'sv'; +SW: 'sw'; -I7 - : 'i7' - ; +SZ: 'sz'; +TAG: 'tag'; -I8 - : 'i8' - ; +TCOUNT: 'tcount'; +TF: 'tf'; -I9 - : 'i9' - ; +TGL: 'tgl'; +TPERIOD: 'tperiod'; -I10 - : 'i10' - ; +TRUE: 'true'; +TRUNC: 'trunc'; -I11 - : 'i11' - ; +TST: 'tst'; +TYPE: 'type'; -I12 - : 'i12' - ; +TRAP: 'trap'; +UF: 'uf'; -I13 - : 'i13' - ; +UI: 'ui'; +UNPACK: 'unpack'; -I14 - : 'i14' - ; +UNTIL: 'until'; +UR: 'ur'; -I15 - : 'i15' - ; +USF: 'usf'; +USFR: 'usfr'; -IDLE - : 'idle' - ; +USI: 'usi'; +USIR: 'usir'; -IDLE16 - : 'idle16' - ; +USTAT1: 'ustat1'; +USTAT2: 'ustat2'; -IDLEI15 - : 'idlei15' - ; +UUF: 'uuf'; +UUFR: 'uufr'; -IDLEI16 - : 'idlei16' - ; +UUI: 'uui'; +UUIR: 'uuir'; -IF - : 'if' - ; +VAL: 'val'; +WITH: 'with'; -IMASK - : 'imask' - ; +XOR: 'xor'; +PLUS: '+'; -IMASKP - : 'imaskp' - ; +MINUS: '-'; +MULT: '*'; -INC - : 'inc' - ; +DIV: '/'; +DIV_MOD: '%'; -IRPTL - : 'irptl' - ; +EQU: '='; +I_OR: '|'; -JUMP - : 'jump' - ; +I_XOR: '^'; +COMMA: ','; -L0 - : 'l0' - ; +COLON: ':'; +SEMICOLON: ';'; -L1 - : 'l1' - ; +LPARENTHESE: '('; +RPARENTHESE: ')'; -L2 - : 'l2' - ; +LBRACKET: '['; +RBRACKET: ']'; -L3 - : 'l3' - ; +LBRACE: '{'; +RBRACE: '}'; -L4 - : 'l4' - ; +AT: '@'; +NO_INIT: 'no_init'; -L5 - : 'l5' - ; +ZERO_INIT: 'zero_init'; +RUNTIME_INIT: 'runtime_init'; -L6 - : 'l6' - ; +CODE: 'code'; +DATA: 'data'; -L7 - : 'l7' - ; +DATA64: 'data64'; +DMAONLY: 'dmaonly'; -L8 - : 'l8' - ; +SECTION: 'SECTION'; +SECTION_INFO: 'SECTION_INFO'; -L9 - : 'l9' - ; +STMT: 'STMT'; +ADDR: 'ADDR'; -L10 - : 'l10' - ; +BIT_DATA: 'BIT_DATA'; +JUMP_INT: 'JUMP_INT'; -L11 - : 'l11' - ; +JUMP_PC: 'JUMP_PC'; +JUMP_MD: 'JUMP_MD'; -L12 - : 'l12' - ; +MODIFIER: 'MODIFIER'; +MULTI_MOD: 'MULTI_MOD'; -L13 - : 'l13' - ; +LABLE: 'LABLE'; +VARDEF: 'VARDEF'; -L14 - : 'l14' - ; +ARRDEF: 'ARRDEF'; +DM_ACCESS: 'DM_ACCESS'; -L15 - : 'l15' - ; +PM_ACCESS: 'PM_ACCESS'; +CONDITION: 'CONDITION'; -LA - : 'la' - ; +IF_STMT: 'IF_STMT'; +VALUE_EXP: 'VALUE_EXP'; -LADDR - : 'laddr' - ; +NULL_: 'NULL'; +CHAR_LITERAL: 'CHAR_LITERAL'; -LCE - : 'lce' - ; +STR_LITERAL: 'STR_LITERAL'; +DIRECTIVE: 'DIRECTIVE'; -LCNTR - : 'lcntr' - ; +NEGATE: 'NEGATE'; +ID: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '.') ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '.' | '0' .. '9')*; -LE - : 'le' - ; - - -LEFTO - : 'lefto' - ; - - -LEFTZ - : 'leftz' - ; - - -LENGTH - : 'length' - ; - - -LINE - : 'line' - ; - - -LN - : 'ln' - ; - - -LOAD - : 'load' - ; - - -LOG2 - : 'log2' - ; - - -LOGB - : 'logb' - ; - - -LOOP - : 'loop' - ; - - -LR - : 'lr' - ; - - -LSHIFT - : 'lshift' - ; - - -LT - : 'lt' - ; - - -M0 - : 'm0' - ; - - -M1 - : 'm1' - ; - - -M2 - : 'm2' - ; - - -M3 - : 'm3' - ; - - -M4 - : 'm4' - ; - - -M5 - : 'm5' - ; - - -M6 - : 'm6' - ; - - -M7 - : 'm7' - ; - - -M8 - : 'm8' - ; - - -M9 - : 'm9' - ; - - -M10 - : 'm10' - ; - - -M11 - : 'm11' - ; - - -M12 - : 'm12' - ; - - -M13 - : 'm13' - ; - - -M14 - : 'm14' - ; - - -M15 - : 'm15' - ; - - -MANT - : 'mant' - ; - - -MAX - : 'max' - ; - - -MBM - : 'mbm' - ; - - -MIN - : 'min' - ; - - -MOD - : 'mod' - ; - - -MODE1 - : 'mode1' - ; - - -MODE2 - : 'mode2' - ; - - -MODIFY - : 'modify' - ; - - -MR0B - : 'mr0b' - ; - - -MR0F - : 'mr0f' - ; - - -MR1B - : 'mr1b' - ; - - -MR1F - : 'mr1f' - ; - - -MR2B - : 'mr2b' - ; - - -MR2F - : 'mr2f' - ; - - -MRB - : 'mrb' - ; - - -MRF - : 'mrf' - ; - - -MS - : 'ms' - ; - - -MV - : 'mv' - ; - - -NBM - : 'nbm' - ; - - -NE - : 'ne' - ; - - -NOFO - : 'nofo' - ; - - -NOFZ - : 'nofz' - ; - - -NOP - : 'nop' - ; - - -NOPSPECIAL - : 'nopspecial' - ; - - -NOT - : 'not' - ; - - -NU - : 'nu' - ; - - -NW - : 'nw' - ; - - -OFFSETOF - : 'offsetof' - ; - - -OR - : 'or' - ; - - -P20 - : 'p20' - ; - - -P32 - : 'p32' - ; - - -P40 - : 'p40' - ; - - -PACK - : 'pack' - ; - - -PAGE - : 'page' - ; - - -PASS - : 'pass' - ; - - -PC - : 'pc' - ; - - -PCSTK - : 'pcstk' - ; - - -PCSTKP - : 'pcstkp' - ; - - -PM - : 'pm' - ; - - -PMADR - : 'pmadr' - ; - - -PMBANK1 - : 'pmbank1' - ; - - -PMDAE - : 'pmdae' - ; - - -PMDAS - : 'pmdas' - ; - - -POP - : 'pop' - ; - - -POVL0 - : 'povl0' - ; - - -POVL1 - : 'povl1' - ; - - -PSA1E - : 'psa1e' - ; - - -PSA1S - : 'psa1s' - ; - - -PSA2E - : 'psa2e' - ; - - -PSA3E - : 'psa3e' - ; - - -PSA3S - : 'psa3s' - ; - - -PSA4E - : 'psa4e' - ; - - -PSA4S - : 'psa4s' - ; - - -PUSH - : 'push' - ; - - -PX - : 'px' - ; - - -PX1 - : 'px1' - ; - - -PX2 - : 'px2' - ; - - -RETAIN_NAME - : 'retain_name' - ; - - -R0 - : 'r0' - ; - - -R1 - : 'r1' - ; - - -R2 - : 'r2' - ; - - -R3 - : 'r3' - ; - - -R4 - : 'r4' - ; - - -R5 - : 'r5' - ; - - -R6 - : 'r6' - ; - - -R7 - : 'r7' - ; - - -R8 - : 'r8' - ; - - -R9 - : 'r9' - ; - - -R10 - : 'r10' - ; - - -R11 - : 'r11' - ; - - -R12 - : 'r12' - ; - - -R13 - : 'r13' - ; - - -R14 - : 'r14' - ; - - -R15 - : 'r15' - ; - - -READ - : 'read' - ; - - -RECIPS - : 'recips' - ; - - -RFRAME - : 'rframe' - ; - - -RND - : 'rnd' - ; - - -ROT - : 'rot' - ; - - -RS - : 'rs' - ; - - -RSQRTS - : 'rsqrts' - ; - - -RTI - : 'rti' - ; - - -RTS - : 'rts' - ; - - -SAT - : 'sat' - ; - - -SCALB - : 'scalb' - ; - - -SCL - : 'scl' - ; - - -SE - : 'se' - ; - - -SET - : 'set' - ; - - -SF - : 'sf' - ; - - -SI - : 'si' - ; - - -SIN - : 'sin' - ; - - -SIZE - : 'size' - ; - - -SIZEOF - : 'sizeof' - ; - - -SQR - : 'sqr' - ; - - -SR - : 'sr' - ; - - -SSF - : 'ssf' - ; - - -SSFR - : 'ssfr' - ; - - -SSI - : 'ssi' - ; - - -SSIR - : 'ssir' - ; - - -ST - : 'st' - ; - - -STEP - : 'step' - ; - - -STKY - : 'stky' - ; - - -STRUCT - : 'struct' - ; - - -STS - : 'sts' - ; - - -SUF - : 'suf' - ; - - -SUFR - : 'sufr' - ; - - -SUI - : 'sui' - ; - - -SV - : 'sv' - ; - - -SW - : 'sw' - ; - - -SZ - : 'sz' - ; - - -TAG - : 'tag' - ; - - -TCOUNT - : 'tcount' - ; - - -TF - : 'tf' - ; - - -TGL - : 'tgl' - ; - - -TPERIOD - : 'tperiod' - ; - - -TRUE - : 'true' - ; - - -TRUNC - : 'trunc' - ; - - -TST - : 'tst' - ; - - -TYPE - : 'type' - ; - - -TRAP - : 'trap' - ; - - -UF - : 'uf' - ; - - -UI - : 'ui' - ; - - -UNPACK - : 'unpack' - ; - - -UNTIL - : 'until' - ; - - -UR - : 'ur' - ; - - -USF - : 'usf' - ; - - -USFR - : 'usfr' - ; - - -USI - : 'usi' - ; - - -USIR - : 'usir' - ; - - -USTAT1 - : 'ustat1' - ; - - -USTAT2 - : 'ustat2' - ; - - -UUF - : 'uuf' - ; - - -UUFR - : 'uufr' - ; - - -UUI - : 'uui' - ; - - -UUIR - : 'uuir' - ; - - -VAL - : 'val' - ; - - -WITH - : 'with' - ; - - -XOR - : 'xor' - ; - - -PLUS - : '+' - ; - - -MINUS - : '-' - ; - - -MULT - : '*' - ; - - -DIV - : '/' - ; - - -DIV_MOD - : '%' - ; - - -EQU - : '=' - ; - - -I_OR - : '|' - ; - - -I_XOR - : '^' - ; - - -COMMA - : ',' - ; - - -COLON - : ':' - ; - - -SEMICOLON - : ';' - ; - - -LPARENTHESE - : '(' - ; - - -RPARENTHESE - : ')' - ; - - -LBRACKET - : '[' - ; - - -RBRACKET - : ']' - ; - - -LBRACE - : '{' - ; - - -RBRACE - : '}' - ; - - -AT - : '@' - ; - - -NO_INIT - : 'no_init' - ; - - -ZERO_INIT - : 'zero_init' - ; - - -RUNTIME_INIT - : 'runtime_init' - ; - - -CODE - : 'code' - ; - - -DATA - : 'data' - ; - - -DATA64 - : 'data64' - ; - - -DMAONLY - : 'dmaonly' - ; - - -SECTION - : 'SECTION' - ; - - -SECTION_INFO - : 'SECTION_INFO' - ; - - -STMT - : 'STMT' - ; - - -ADDR - : 'ADDR' - ; - - -BIT_DATA - : 'BIT_DATA' - ; - - -JUMP_INT - : 'JUMP_INT' - ; - - -JUMP_PC - : 'JUMP_PC' - ; - - -JUMP_MD - : 'JUMP_MD' - ; - - -MODIFIER - : 'MODIFIER' - ; - - -MULTI_MOD - : 'MULTI_MOD' - ; - - -LABLE - : 'LABLE' - ; - - -VARDEF - : 'VARDEF' - ; - - -ARRDEF - : 'ARRDEF' - ; - - -DM_ACCESS - : 'DM_ACCESS' - ; - - -PM_ACCESS - : 'PM_ACCESS' - ; - - -CONDITION - : 'CONDITION' - ; - - -IF_STMT - : 'IF_STMT' - ; - - -VALUE_EXP - : 'VALUE_EXP' - ; - - -NULL_ - : 'NULL' - ; - - -CHAR_LITERAL - : 'CHAR_LITERAL' - ; - - -STR_LITERAL - : 'STR_LITERAL' - ; - - -DIRECTIVE - : 'DIRECTIVE' - ; - - -NEGATE - : 'NEGATE' - ; - - -ID - : ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '.') ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '.' | '0' .. '9' )* - ; - - -COMMENT - : ( '//' ~ ( '\n' | '\r' )* '\r'? '\n' | '/*' .*? '*/' ) -> skip - ; +COMMENT: ( '//' ~ ( '\n' | '\r')* '\r'? '\n' | '/*' .*? '*/') -> skip; \ No newline at end of file diff --git a/sharc/SHARCParser.g4 b/sharc/SHARCParser.g4 index a2f63d45b5..9463a7a723 100644 --- a/sharc/SHARCParser.g4 +++ b/sharc/SHARCParser.g4 @@ -1,393 +1,526 @@ +// $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 SHARCParser; -options { tokenVocab=SHARCLexer; } +options { + tokenVocab = SHARCLexer; +} prog - : ( statement SEMICOLON )+ EOF - ; + : (statement SEMICOLON)+ EOF + ; statement - : stmt_atom | ( ID COLON )+ stmt_atom - ; + : stmt_atom + | ( ID COLON)+ stmt_atom + ; stmt_atom - : stmt | sec | seg | end_seg | directive_exp - ; + : stmt + | sec + | seg + | end_seg + | directive_exp + ; //segment sec - : DOT_SECTION seg_qualifier ID - ; + : DOT_SECTION seg_qualifier ID + ; seg - : DOT_SEGMENT seg_qualifier ID - ; + : DOT_SEGMENT seg_qualifier ID + ; end_seg - : DOT_ENDSEG - ; + : DOT_ENDSEG + ; seg_qualifier - : seg_qualifier1 ( seg_qualifier2 | seg_qualifier3 )? | seg_qualifier2 ( seg_qualifier1 | seg_qualifier3 )? | seg_qualifier3 ( seg_qualifier1 | seg_qualifier2 )? - ; + : seg_qualifier1 (seg_qualifier2 | seg_qualifier3)? + | seg_qualifier2 ( seg_qualifier1 | seg_qualifier3)? + | seg_qualifier3 ( seg_qualifier1 | seg_qualifier2)? + ; seg_qualifier1 - : ( DIV ( seg_qualifier_1 | seg_qualifier_2 ) ) - ; + : (DIV ( seg_qualifier_1 | seg_qualifier_2)) + ; seg_qualifier2 - : ( DIV seg_qualifier_3 ) - ; + : (DIV seg_qualifier_3) + ; seg_qualifier3 - : ( DIV DMAONLY ) - ; + : (DIV DMAONLY) + ; seg_qualifier_1 - : PM | CODE - ; + : PM + | CODE + ; seg_qualifier_2 - : DM | DATA | DATA64 - ; + : DM + | DATA + | DATA64 + ; seg_qualifier_3 - : NO_INIT | ZERO_INIT | RUNTIME_INIT - ; + : NO_INIT + | ZERO_INIT + | RUNTIME_INIT + ; stmt - : compute | flow_control_exp | imm_mov_exp | misc_exp | declaration | if_compute_mov | compute_mov_exp - ; + : compute + | flow_control_exp + | imm_mov_exp + | misc_exp + | declaration + | if_compute_mov + | compute_mov_exp + ; //.VAR foo[N]="123.dat"; declaration - : DOT_VAR ( declaration_exp1 | declaration_exp2 | declaration_exp3 | declaration_exp4 | declaration_exp5 ) - ; + : DOT_VAR ( + declaration_exp1 + | declaration_exp2 + | declaration_exp3 + | declaration_exp4 + | declaration_exp5 + ) + ; declaration_exp1 - : ID ( COMMA ID )* - ; + : ID (COMMA ID)* + ; declaration_exp2 - : EQU initExpression ( COMMA initExpression )* - ; + : EQU initExpression (COMMA initExpression)* + ; declaration_exp3 - : ID LBRACKET RBRACKET ( EQU declaration_exp_f2 )? - ; + : ID LBRACKET RBRACKET (EQU declaration_exp_f2)? + ; declaration_exp4 - : ID LBRACKET value_exp RBRACKET ( EQU declaration_exp_f2 )? - ; + : ID LBRACKET value_exp RBRACKET (EQU declaration_exp_f2)? + ; declaration_exp5 - : ID EQU value_exp - ; + : ID EQU value_exp + ; declaration_exp_f1 - : initExpression ( COMMA initExpression )* | StringLiteral - ; + : initExpression (COMMA initExpression)* + | StringLiteral + ; declaration_exp_f2 - : LBRACE declaration_exp_f1 RBRACE | declaration_exp_f1 - ; + : LBRACE declaration_exp_f1 RBRACE + | declaration_exp_f1 + ; initExpression - : value_exp | CharLiteral - ; + : value_exp + | CharLiteral + ; //get addr var_addr - : AT ID | LENGTH LPARENTHESE ID RPARENTHESE - ; + : AT ID + | LENGTH LPARENTHESE ID RPARENTHESE + ; value_exp - : value_exp2 - ; + : value_exp2 + ; value_exp2 - : term ( ( PLUS | MINUS | MULT | DIV | DIV_MOD | I_OR | I_XOR ) term )* - ; + : term (( PLUS | MINUS | MULT | DIV | DIV_MOD | I_OR | I_XOR) term)* + ; term - : ( op = MINUS )? factor - ; + : (op = MINUS)? factor + ; factor - : atom | LPARENTHESE value_exp2 RPARENTHESE - ; + : atom + | LPARENTHESE value_exp2 RPARENTHESE + ; atom - : INT | var_addr | ID - ; + : INT + | var_addr + | ID + ; compute - : dual_op | fixpoint_alu_op | floating_point_alu_op | multi_op | shifter_op - ; + : dual_op + | fixpoint_alu_op + | floating_point_alu_op + | multi_op + | shifter_op + ; //==================================================================================================== if_compute_mov - : IF condition if_compute_mov_exp - ; + : IF condition if_compute_mov_exp + ; if_compute_mov_exp - : compute_mov_exp | compute - ; + : compute_mov_exp + | compute + ; //move or modify instructions compute_mov_exp - : ( compute COMMA )? ( mov_exp_1 | mov_exp_3a | mov_exp_3b | mov_exp_3c | mov_exp_3d | mov_exp_4a | mov_exp_4b | mov_exp_4c | mov_exp_4d | mov_exp_5 | mov_exp_7 ) - ; + : (compute COMMA)? ( + mov_exp_1 + | mov_exp_3a + | mov_exp_3b + | mov_exp_3c + | mov_exp_3d + | mov_exp_4a + | mov_exp_4b + | mov_exp_4c + | mov_exp_4d + | mov_exp_5 + | mov_exp_7 + ) + ; mov_exp_1 - : mov_exp_1_1 COMMA mov_exp_1_2 - ; + : mov_exp_1_1 COMMA mov_exp_1_2 + ; //DM(Ia, Mb) = dreg //dreg = DM(Ia, Mb) mov_exp_1_1 - : mem_addr_dm_ia_mb EQU d_reg | d_reg EQU mem_addr_dm_ia_mb - ; + : mem_addr_dm_ia_mb EQU d_reg + | d_reg EQU mem_addr_dm_ia_mb + ; //PM(Ic, Md) = dreg //dreg = PM(Ic, Md) mov_exp_1_2 - : mem_addr_pm_ic_md EQU d_reg | d_reg EQU mem_addr_pm_ic_md - ; + : mem_addr_pm_ic_md EQU d_reg + | d_reg EQU mem_addr_pm_ic_md + ; //DM(Ia, Mb) = ureg //PM(Ic, Md) mov_exp_3a - : ( mem_addr_dm_ia_mb | mem_addr_pm_ic_md ) EQU u_reg - ; + : (mem_addr_dm_ia_mb | mem_addr_pm_ic_md) EQU u_reg + ; //DM(Mb, Ia) = ureg //PM(Md, Ic) mov_exp_3b - : ( mem_addr_dm_mb_ia | mem_addr_pm_md_ic ) EQU u_reg - ; + : (mem_addr_dm_mb_ia | mem_addr_pm_md_ic) EQU u_reg + ; //u_reg = DM(Ia, Mb) // PM(Ic, Md) mov_exp_3c - : u_reg EQU ( mem_addr_dm_ia_mb | mem_addr_pm_ic_md ) - ; + : u_reg EQU (mem_addr_dm_ia_mb | mem_addr_pm_ic_md) + ; //u_reg = DM(Mb, Ia) // PM(Md, Ic) mov_exp_3d - : u_reg EQU ( mem_addr_dm_mb_ia | mem_addr_pm_md_ic ) - ; + : u_reg EQU (mem_addr_dm_mb_ia | mem_addr_pm_md_ic) + ; //DM(Ia, ) = dreg //PM(Ic, ) mov_exp_4a - : ( mem_addr_dm_ia_int | mem_addr_pm_ic_int ) EQU d_reg - ; + : (mem_addr_dm_ia_int | mem_addr_pm_ic_int) EQU d_reg + ; //DM(, Ia) = dreg //PM(Ic, ) mov_exp_4b - : imm_mov_15a - ; + : imm_mov_15a + ; //d_reg = DM(Ia, ) // PM(Ic, ) mov_exp_4c - : d_reg EQU ( mem_addr_dm_ia_int | mem_addr_pm_ic_int ) - ; + : d_reg EQU (mem_addr_dm_ia_int | mem_addr_pm_ic_int) + ; //d_reg = DM(, Ia) // PM(, Ic) mov_exp_4d - : imm_mov_15b - ; + : imm_mov_15b + ; //ureg1 = ureg2 mov_exp_5 - : u_reg2 EQU u_reg - ; + : u_reg2 EQU u_reg + ; //DM(Ia, Mb) = dreg //PM(Ic, Md) mov_exp_6a - : ( mem_addr_dm_ia_mb | mem_addr_pm_ic_md ) EQU d_reg - ; + : (mem_addr_dm_ia_mb | mem_addr_pm_ic_md) EQU d_reg + ; //dreg = DM(Ia, Mb) // PM(Ic, Md) mov_exp_6b - : d_reg EQU ( mem_addr_dm_ia_mb | mem_addr_pm_ic_md ) - ; + : d_reg EQU (mem_addr_dm_ia_mb | mem_addr_pm_ic_md) + ; //MODIFY (Ia, Mb) // (Ic, Md) mov_exp_7 - : MODIFY ( LPARENTHESE ia COMMA mb RPARENTHESE | LPARENTHESE ic COMMA md RPARENTHESE ) - ; + : MODIFY (LPARENTHESE ia COMMA mb RPARENTHESE | LPARENTHESE ic COMMA md RPARENTHESE) + ; mem_addr_ia_mb - : LPARENTHESE ia COMMA mb RPARENTHESE - ; + : LPARENTHESE ia COMMA mb RPARENTHESE + ; mem_addr_ic_md - : LPARENTHESE ic COMMA md RPARENTHESE - ; + : LPARENTHESE ic COMMA md RPARENTHESE + ; mem_addr_md_ic - : LPARENTHESE md COMMA ic RPARENTHESE - ; + : LPARENTHESE md COMMA ic RPARENTHESE + ; mem_addr_mb_ia - : LPARENTHESE mb COMMA ia RPARENTHESE - ; + : LPARENTHESE mb COMMA ia RPARENTHESE + ; mem_addr_ia_int - : LPARENTHESE ia COMMA value_exp RPARENTHESE - ; + : LPARENTHESE ia COMMA value_exp RPARENTHESE + ; mem_addr_ic_int - : LPARENTHESE ic COMMA value_exp RPARENTHESE - ; + : LPARENTHESE ic COMMA value_exp RPARENTHESE + ; mem_addr_int_ia - : LPARENTHESE value_exp COMMA ia RPARENTHESE - ; + : LPARENTHESE value_exp COMMA ia RPARENTHESE + ; mem_addr_int_ic - : LPARENTHESE value_exp COMMA ic RPARENTHESE - ; + : LPARENTHESE value_exp COMMA ic RPARENTHESE + ; mem_addr_int - : - //LPARENTHESE value_exp RPARENTHESE - //^(DIRECT value_exp) LPARENTHESE mem_addr_int_ RPARENTHESE - ; + : + //LPARENTHESE value_exp RPARENTHESE + //^(DIRECT value_exp) LPARENTHESE mem_addr_int_ RPARENTHESE + ; mem_addr_int_ - : atom | atom ( PLUS | MINUS ) atom - ; + : atom + | atom ( PLUS | MINUS) atom + ; mem_addr_dm_ia_mb - : DM mem_addr_ia_mb - ; + : DM mem_addr_ia_mb + ; mem_addr_pm_ic_md - : PM mem_addr_ic_md - ; + : PM mem_addr_ic_md + ; mem_addr_dm_mb_ia - : DM mem_addr_mb_ia - ; + : DM mem_addr_mb_ia + ; mem_addr_pm_md_ic - : PM mem_addr_md_ic - ; + : PM mem_addr_md_ic + ; mem_addr_dm_ia_int - : DM mem_addr_ia_int - ; + : DM mem_addr_ia_int + ; mem_addr_pm_ic_int - : PM mem_addr_ic_int - ; + : PM mem_addr_ic_int + ; mem_addr_dm_int_ia - : DM mem_addr_int_ia - ; + : DM mem_addr_int_ia + ; mem_addr_pm_int_ic - : PM mem_addr_int_ic - ; + : PM mem_addr_int_ic + ; mem_addr_dm_int - : DM mem_addr_int - ; + : DM mem_addr_int + ; mem_addr_pm_int - : PM mem_addr_int - ; + : PM mem_addr_int + ; //==================================================================================================== fixpoint_alu_op - : r_reg EQU r_exp | COMP LPARENTHESE r_reg COMMA r_reg RPARENTHESE - ; + : r_reg EQU r_exp + | COMP LPARENTHESE r_reg COMMA r_reg RPARENTHESE + ; r_exp - : r_reg add_or_sub r_reg | r_reg PLUS r_reg PLUS CI | r_reg PLUS r_reg PLUS CI MINUS INT | LPARENTHESE r_reg PLUS r_reg RPARENTHESE DIV INT | r_reg PLUS CI | r_reg PLUS CI MINUS INT | r_reg PLUS INT | r_reg MINUS INT | MINUS r_reg | ABS r_reg | PASS r_reg | r_reg AND r_reg | r_reg OR r_reg | r_reg XOR r_reg | NOT r_reg | MIN LPARENTHESE r_reg COMMA r_reg RPARENTHESE | MAX LPARENTHESE r_reg COMMA r_reg RPARENTHESE | CLIP r_reg BY r_reg | MANT f_reg | LOGB f_reg | FIX f_reg ( BY r_reg )? | TRUNC f_reg ( BY r_reg )? - ; + : r_reg add_or_sub r_reg + | r_reg PLUS r_reg PLUS CI + | r_reg PLUS r_reg PLUS CI MINUS INT + | LPARENTHESE r_reg PLUS r_reg RPARENTHESE DIV INT + | r_reg PLUS CI + | r_reg PLUS CI MINUS INT + | r_reg PLUS INT + | r_reg MINUS INT + | MINUS r_reg + | ABS r_reg + | PASS r_reg + | r_reg AND r_reg + | r_reg OR r_reg + | r_reg XOR r_reg + | NOT r_reg + | MIN LPARENTHESE r_reg COMMA r_reg RPARENTHESE + | MAX LPARENTHESE r_reg COMMA r_reg RPARENTHESE + | CLIP r_reg BY r_reg + | MANT f_reg + | LOGB f_reg + | FIX f_reg ( BY r_reg)? + | TRUNC f_reg ( BY r_reg)? + ; //==================================================================================================== floating_point_alu_op - : f_reg EQU f_exp | COMP LPARENTHESE f_reg COMMA f_reg RPARENTHESE - ; + : f_reg EQU f_exp + | COMP LPARENTHESE f_reg COMMA f_reg RPARENTHESE + ; f_exp - : f_reg PLUS f_reg | f_reg MINUS f_reg | ABS LPARENTHESE f_reg PLUS f_reg RPARENTHESE | ABS LPARENTHESE f_reg MINUS f_reg RPARENTHESE | LPARENTHESE f_reg PLUS f_reg RPARENTHESE DIV INT | MINUS f_reg | ABS f_reg | PASS f_reg | RND f_reg | SCALB f_reg BY r_reg | FLOAT r_reg ( BY r_reg )? | RECIPS f_reg | RSQRTS f_reg | f_reg COPYSIGN f_reg | MIN LPARENTHESE f_reg COMMA f_reg RPARENTHESE | MAX LPARENTHESE f_reg COMMA f_reg RPARENTHESE | CLIP f_reg BY f_reg | f_reg MULT f_reg - ; + : f_reg PLUS f_reg + | f_reg MINUS f_reg + | ABS LPARENTHESE f_reg PLUS f_reg RPARENTHESE + | ABS LPARENTHESE f_reg MINUS f_reg RPARENTHESE + | LPARENTHESE f_reg PLUS f_reg RPARENTHESE DIV INT + | MINUS f_reg + | ABS f_reg + | PASS f_reg + | RND f_reg + | SCALB f_reg BY r_reg + | FLOAT r_reg ( BY r_reg)? + | RECIPS f_reg + | RSQRTS f_reg + | f_reg COPYSIGN f_reg + | MIN LPARENTHESE f_reg COMMA f_reg RPARENTHESE + | MAX LPARENTHESE f_reg COMMA f_reg RPARENTHESE + | CLIP f_reg BY f_reg + | f_reg MULT f_reg + ; //==================================================================================================== multi_op - : r_reg EQU multi_exp_r | MRF EQU multi_exp_mrf | MRB EQU multi_exp_mrb | mr EQU INT | ( mrf | mrb ) EQU r_reg | r_reg EQU ( mrf | mrb ) - ; + : r_reg EQU multi_exp_r + | MRF EQU multi_exp_mrf + | MRB EQU multi_exp_mrb + | mr EQU INT + | ( mrf | mrb) EQU r_reg + | r_reg EQU ( mrf | mrb) + ; multi_r - : r_reg MULT r_reg multi_mod2? - ; + : r_reg MULT r_reg multi_mod2? + ; multi_exp_r - : multi_r | mr add_or_sub multi_r | SAT mr multi_mod1? | RND mr multi_mod1? | mr - ; + : multi_r + | mr add_or_sub multi_r + | SAT mr multi_mod1? + | RND mr multi_mod1? + | mr + ; multi_exp_mrf - : multi_r | MRF add_or_sub multi_r | SAT MRF multi_mod1? | RND MRF multi_mod1? - ; + : multi_r + | MRF add_or_sub multi_r + | SAT MRF multi_mod1? + | RND MRF multi_mod1? + ; multi_exp_mrb - : multi_r | MRB add_or_sub multi_r | SAT MRB multi_mod1? | RND MRB multi_mod1? - ; + : multi_r + | MRB add_or_sub multi_r + | SAT MRB multi_mod1? + | RND MRB multi_mod1? + ; mr - : MRB | MRF - ; + : MRB + | MRF + ; //==================================================================================================== shifter_op - : r_reg EQU shifter_exp | BTST r_reg BY sec_op | f_reg EQU FUNPACK r_reg - ; + : r_reg EQU shifter_exp + | BTST r_reg BY sec_op + | f_reg EQU FUNPACK r_reg + ; shifter_exp - : LSHIFT r_reg BY sec_op | r_reg OR LSHIFT r_reg BY sec_op | ASHIFT r_reg BY sec_op | r_reg OR ASHIFT r_reg BY sec_op | ROT r_reg BY sec_op | BCLR r_reg BY sec_op | BSET r_reg BY sec_op | BTGL r_reg BY sec_op | FDEP r_reg BY sec_op2 ( LPARENTHESE SE RPARENTHESE )? | FEXT r_reg BY sec_op2 ( LPARENTHESE SE RPARENTHESE )? | r_reg OR FDEP r_reg BY sec_op2 | EXP r_reg ( LPARENTHESE EX RPARENTHESE )? | LEFTZ r_reg | LEFTO r_reg | FPACK f_reg - ; + : LSHIFT r_reg BY sec_op + | r_reg OR LSHIFT r_reg BY sec_op + | ASHIFT r_reg BY sec_op + | r_reg OR ASHIFT r_reg BY sec_op + | ROT r_reg BY sec_op + | BCLR r_reg BY sec_op + | BSET r_reg BY sec_op + | BTGL r_reg BY sec_op + | FDEP r_reg BY sec_op2 ( LPARENTHESE SE RPARENTHESE)? + | FEXT r_reg BY sec_op2 ( LPARENTHESE SE RPARENTHESE)? + | r_reg OR FDEP r_reg BY sec_op2 + | EXP r_reg ( LPARENTHESE EX RPARENTHESE)? + | LEFTZ r_reg + | LEFTO r_reg + | FPACK f_reg + ; sec_op - : r_reg | atom | MINUS atom - ; + : r_reg + | atom + | MINUS atom + ; sec_op2 - : r_reg | bit_data - ; + : r_reg + | bit_data + ; bit_data - : INT COLON INT - ; + : INT COLON INT + ; add_or_sub - : PLUS | MINUS - ; + : PLUS + | MINUS + ; dual_op - : dual_add_r | parallel_multi - ; + : dual_add_r + | parallel_multi + ; dual_add_r - : r_reg EQU r_reg PLUS r_reg COMMA r_reg EQU r_reg MINUS r_reg - ; + : r_reg EQU r_reg PLUS r_reg COMMA r_reg EQU r_reg MINUS r_reg + ; parallel_multi - : multi_op ( COMMA fixpoint_alu_op )+ | floating_point_alu_op ( COMMA floating_point_alu_op )+ - ; + : multi_op (COMMA fixpoint_alu_op)+ + | floating_point_alu_op ( COMMA floating_point_alu_op)+ + ; //==================================================================================================== /* @@ -498,287 +631,537 @@ parallel_multi_add_r //==================================================================================================== // program flow control instructions flow_control_exp - : flow_contorl_8 | flow_control_9_and_11 | flow_control_10 | flow_control_8a | flow_control_8b | flow_control_9a | flow_control_9b | flow_control_11a | flow_control_11b | flow_control_12 | flow_control_13 - ; + : flow_contorl_8 + | flow_control_9_and_11 + | flow_control_10 + | flow_control_8a + | flow_control_8b + | flow_control_9a + | flow_control_9b + | flow_control_11a + | flow_control_11b + | flow_control_12 + | flow_control_13 + ; ///////////////////////////////// flow_contorl_8 - : IF condition flow_contorl_8_exp - ; + : IF condition flow_contorl_8_exp + ; flow_contorl_8_exp - : flow_control_8a | flow_control_8b - ; + : flow_control_8a + | flow_control_8b + ; flow_control_9_and_11 - : IF condition flow_control_9_and_11_exp COMMA ELSE compute - ; + : IF condition flow_control_9_and_11_exp COMMA ELSE compute + ; flow_control_9_and_11_exp - : flow_control_9a | flow_control_9b | flow_control_11a | flow_control_11b - ; + : flow_control_9a + | flow_control_9b + | flow_control_11a + | flow_control_11b + ; flow_control_10 - : IF condition JUMP flow_control_10_frag COMMA ELSE ( compute COMMA )? mov_exp_1_1 - ; + : IF condition JUMP flow_control_10_frag COMMA ELSE (compute COMMA)? mov_exp_1_1 + ; flow_control_10_frag - : mem_addr_md_ic | jump_addr_pc - ; + : mem_addr_md_ic + | jump_addr_pc + ; flow_control_12 - : LCNTR EQU lcntr_v ( COMMA DO jump_addr_int_or_pc UNTIL LCE ) - ; + : LCNTR EQU lcntr_v (COMMA DO jump_addr_int_or_pc UNTIL LCE) + ; lcntr_v - : value_exp | u_reg - ; + : value_exp + | u_reg + ; //DO UNTIL termination // (PC, ) flow_control_13 - : DO jump_addr_int_or_pc UNTIL condition - ; + : DO jump_addr_int_or_pc UNTIL condition + ; flow_control_8a - : JUMP jump_addr_int jump_modifier? - ; + : JUMP jump_addr_int jump_modifier? + ; flow_control_8b - : CALL jump_addr_int jump_modifier2? - ; + : CALL jump_addr_int jump_modifier2? + ; flow_control_9a - : JUMP flow_control_10_frag jump_modifier? ( COMMA compute )? - ; + : JUMP flow_control_10_frag jump_modifier? (COMMA compute)? + ; flow_control_9b - : CALL flow_control_10_frag jump_modifier2? ( COMMA compute )? - ; + : CALL flow_control_10_frag jump_modifier2? (COMMA compute)? + ; flow_control_11a - : RTS jump_modifier3? ( COMMA compute )? - ; + : RTS jump_modifier3? (COMMA compute)? + ; flow_control_11b - : RTI jump_modifier2? ( COMMA compute )? - ; + : RTI jump_modifier2? (COMMA compute)? + ; ////////////////////////////////// jump_addr_int_or_pc - : jump_addr_int | jump_addr_pc - ; + : jump_addr_int + | jump_addr_pc + ; jump_addr_md_or_pc - : mem_addr_md_ic | jump_addr_pc - ; + : mem_addr_md_ic + | jump_addr_pc + ; jump_addr_pc - : LPARENTHESE PC COMMA value_exp RPARENTHESE - ; + : LPARENTHESE PC COMMA value_exp RPARENTHESE + ; jump_addr_int - : value_exp - ; + : value_exp + ; jump_modifier - : jump_modifier_ - ; + : jump_modifier_ + ; jump_modifier_ - : LPARENTHESE ( jump_modifier_1 | LA | CI ) RPARENTHESE - ; + : LPARENTHESE (jump_modifier_1 | LA | CI) RPARENTHESE + ; jump_modifier_1 - : DB ( COMMA ( LA | CI ) )? - ; + : DB (COMMA ( LA | CI))? + ; jump_modifier2 - : LPARENTHESE DB RPARENTHESE - ; + : LPARENTHESE DB RPARENTHESE + ; jump_modifier3 - : jump_modifier3_ - ; + : jump_modifier3_ + ; jump_modifier3_ - : LPARENTHESE ( jump_modifier3_1 | LR ) RPARENTHESE - ; + : LPARENTHESE (jump_modifier3_1 | LR) RPARENTHESE + ; jump_modifier3_1 - : DB ( COMMA LR )? - ; + : DB (COMMA LR)? + ; //==================================================================================================== // imm_mov_exp - : imm_mov_14a | imm_mov_14b | imm_mov_16 | imm_mov_17 - ; + : imm_mov_14a + | imm_mov_14b + | imm_mov_16 + | imm_mov_17 + ; imm_mov_14a - : ( mem_addr_dm_int | mem_addr_pm_int ) EQU u_reg - ; + : (mem_addr_dm_int | mem_addr_pm_int) EQU u_reg + ; imm_mov_15a - : ( mem_addr_dm_int_ia | mem_addr_pm_int_ic ) EQU u_reg - ; + : (mem_addr_dm_int_ia | mem_addr_pm_int_ic) EQU u_reg + ; imm_mov_14b - : u_reg EQU ( mem_addr_dm_int | mem_addr_pm_int ) - ; + : u_reg EQU (mem_addr_dm_int | mem_addr_pm_int) + ; imm_mov_15b - : u_reg EQU ( mem_addr_dm_int_ia | mem_addr_pm_int_ic ) - ; + : u_reg EQU (mem_addr_dm_int_ia | mem_addr_pm_int_ic) + ; imm_mov_16 - : ( mem_addr_dm_ia_mb | mem_addr_pm_ic_md ) EQU value_exp - ; + : (mem_addr_dm_ia_mb | mem_addr_pm_ic_md) EQU value_exp + ; imm_mov_17 - : u_reg2 EQU value_exp - ; + : u_reg2 EQU value_exp + ; u_reg2 - : d_reg | PC | PCSTK | PCSTKP | FADDR | DADDR | LADDR | CURLCNTR | dag_reg | PX1 | PX2 | PX | TPERIOD | TCOUNT | s_reg - ; + : d_reg + | PC + | PCSTK + | PCSTKP + | FADDR + | DADDR + | LADDR + | CURLCNTR + | dag_reg + | PX1 + | PX2 + | PX + | TPERIOD + | TCOUNT + | s_reg + ; misc_exp - : BIT ( SET | CLR | TGL | TST | XOR ) s_reg value_exp | BITREV ( mem_addr_ia_int | mem_addr_ic_int ) | MODIFY LPARENTHESE ia COMMA value_exp RPARENTHESE | MODIFY LPARENTHESE ic COMMA value_exp RPARENTHESE | misc_20 ( COMMA misc_20 )* | FLUSH CACHE | NOP | IDLE | IDLE16 | CJUMP jump_addr_int_or_pc jump_modifier2? | RFRAME - ; + : BIT (SET | CLR | TGL | TST | XOR) s_reg value_exp + | BITREV ( mem_addr_ia_int | mem_addr_ic_int) + | MODIFY LPARENTHESE ia COMMA value_exp RPARENTHESE + | MODIFY LPARENTHESE ic COMMA value_exp RPARENTHESE + | misc_20 ( COMMA misc_20)* + | FLUSH CACHE + | NOP + | IDLE + | IDLE16 + | CJUMP jump_addr_int_or_pc jump_modifier2? + | RFRAME + ; misc_20 - : ( PUSH | POP ) ( LOOP | STS | PCSTK ) - ; + : (PUSH | POP) (LOOP | STS | PCSTK) + ; //==================================================================================================== directive_exp - : DOT_ALGIGN INT | DOT_COMPRESS | DOT_EXTERN ID ( COMMA ID )* | DOT_FILE StringLiteral | DOT_FILE_ATTR . | DOT_FORCECOMPRESS | DOT_GLOBAL ID ( COMMA ID )* | DOT_IMPORT StringLiteral ( COMMA StringLiteral )* | DOT_LEFTMARGIN value_exp | DOT_LIST | DOT_LIST_DATA | DOT_LIST_DATFILE | DOT_LIST_DEFTAB value_exp | DOT_LIST_LOCTAB value_exp | DOT_LIST_WRAPDATA | DOT_NEWPAGE | DOT_NOCOMPRESS | DOT_NOLIST_DATA | DOT_NOLIST_DATFILE | DOT_NOLIST_WRAPDATA | DOT_PAGELENGTH value_exp | DOT_PAGEWIDTH value_exp | DOT_PRECISION ( EQU? ) INT | DOT_ROUND_MINUS | DOT_ROUND_NEAREST | DOT_ROUND_PLUS | DOT_ROUND_ZERO | DOT_PREVIOUS | DOT_WEAK ID - ; + : DOT_ALGIGN INT + | DOT_COMPRESS + | DOT_EXTERN ID ( COMMA ID)* + | DOT_FILE StringLiteral + | DOT_FILE_ATTR . + | DOT_FORCECOMPRESS + | DOT_GLOBAL ID ( COMMA ID)* + | DOT_IMPORT StringLiteral ( COMMA StringLiteral)* + | DOT_LEFTMARGIN value_exp + | DOT_LIST + | DOT_LIST_DATA + | DOT_LIST_DATFILE + | DOT_LIST_DEFTAB value_exp + | DOT_LIST_LOCTAB value_exp + | DOT_LIST_WRAPDATA + | DOT_NEWPAGE + | DOT_NOCOMPRESS + | DOT_NOLIST_DATA + | DOT_NOLIST_DATFILE + | DOT_NOLIST_WRAPDATA + | DOT_PAGELENGTH value_exp + | DOT_PAGEWIDTH value_exp + | DOT_PRECISION ( EQU?) INT + | DOT_ROUND_MINUS + | DOT_ROUND_NEAREST + | DOT_ROUND_PLUS + | DOT_ROUND_ZERO + | DOT_PREVIOUS + | DOT_WEAK ID + ; //==================================================================================================== b_reg - : B0 | B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | B10 | B11 | B12 | B13 | B14 | B15 - ; + : B0 + | B1 + | B2 + | B3 + | B4 + | B5 + | B6 + | B7 + | B8 + | B9 + | B10 + | B11 + | B12 + | B13 + | B14 + | B15 + ; l_reg - : L0 | L1 | L2 | L3 | L4 | L5 | L6 | L7 | L8 | L9 | L10 | L11 | L12 | L13 | L14 | L15 - ; + : L0 + | L1 + | L2 + | L3 + | L4 + | L5 + | L6 + | L7 + | L8 + | L9 + | L10 + | L11 + | L12 + | L13 + | L14 + | L15 + ; r_reg - : R0 | R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9 | R10 | R11 | R12 | R13 | R14 | R15 - ; + : R0 + | R1 + | R2 + | R3 + | R4 + | R5 + | R6 + | R7 + | R8 + | R9 + | R10 + | R11 + | R12 + | R13 + | R14 + | R15 + ; f_reg - : F0 | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | F13 | F14 | F15 - ; + : F0 + | F1 + | F2 + | F3 + | F4 + | F5 + | F6 + | F7 + | F8 + | F9 + | F10 + | F11 + | F12 + | F13 + | F14 + | F15 + ; // system register s_reg - : MODE1 | MODE2 | IRPTL | IMASK | IMASKP | ASTAT | STKY | USTAT1 | USTAT2 - ; + : MODE1 + | MODE2 + | IRPTL + | IMASK + | IMASKP + | ASTAT + | STKY + | USTAT1 + | USTAT2 + ; ia - : I0 | I1 | I2 | I3 | I4 | I5 | I6 | I7 - ; + : I0 + | I1 + | I2 + | I3 + | I4 + | I5 + | I6 + | I7 + ; mb - : M0 | M1 | M2 | M3 | M4 | M5 | M6 | M7 - ; + : M0 + | M1 + | M2 + | M3 + | M4 + | M5 + | M6 + | M7 + ; ic - : I8 | I9 | I10 | I11 | I12 | I13 | I14 | I15 - ; + : I8 + | I9 + | I10 + | I11 + | I12 + | I13 + | I14 + | I15 + ; md - : M8 | M9 | M10 | M11 | M12 | M13 | M14 | M15 - ; + : M8 + | M9 + | M10 + | M11 + | M12 + | M13 + | M14 + | M15 + ; i_reg - : ia | ic - ; + : ia + | ic + ; m_reg - : mb | md - ; + : mb + | md + ; dag_reg - : i_reg | m_reg | b_reg | l_reg - ; + : i_reg + | m_reg + | b_reg + | l_reg + ; d_reg - : r_reg | f_reg - ; + : r_reg + | f_reg + ; // universal register u_reg - : d_reg | PC | PCSTK | PCSTKP | FADDR | DADDR | LADDR | CURLCNTR | LCNTR | dag_reg | PX1 | PX2 | PX | TPERIOD | TCOUNT | s_reg - ; + : d_reg + | PC + | PCSTK + | PCSTKP + | FADDR + | DADDR + | LADDR + | CURLCNTR + | LCNTR + | dag_reg + | PX1 + | PX2 + | PX + | TPERIOD + | TCOUNT + | s_reg + ; condition - : ccondition - ; + : ccondition + ; ccondition - : EQ | LT | LE | AC | AV | MV | MS | SV | SZ | FLAG0_IN | FLAG1_IN | FLAG2_IN | FLAG3_IN | TF | BM | LCE | NOT LCE | NE | GE | GT | NOT AC | NOT AV | NOT MV | NOT MS | NOT SV | NOT SZ | NOT FLAG0_IN | NOT FLAG1_IN | NOT FLAG2_IN | NOT FLAG3_IN | NOT TF | NBM | FOREVER | TRUE - ; + : EQ + | LT + | LE + | AC + | AV + | MV + | MS + | SV + | SZ + | FLAG0_IN + | FLAG1_IN + | FLAG2_IN + | FLAG3_IN + | TF + | BM + | LCE + | NOT LCE + | NE + | GE + | GT + | NOT AC + | NOT AV + | NOT MV + | NOT MS + | NOT SV + | NOT SZ + | NOT FLAG0_IN + | NOT FLAG1_IN + | NOT FLAG2_IN + | NOT FLAG3_IN + | NOT TF + | NBM + | FOREVER + | TRUE + ; multi_mod1 - : multi_mod1_ - ; + : multi_mod1_ + ; multi_mod1_ - : LPARENTHESE ( SI | UI | SF | UF ) RPARENTHESE - ; + : LPARENTHESE (SI | UI | SF | UF) RPARENTHESE + ; multi_mod2 - : multi_mod2_ - ; + : multi_mod2_ + ; multi_mod2_ - : LPARENTHESE ( SSI | SUI | USI | UUI | SSF | SUF | USF | UUF | SSFR | SUFR | USFR | UUFR ) RPARENTHESE - ; + : LPARENTHESE (SSI | SUI | USI | UUI | SSF | SUF | USF | UUF | SSFR | SUFR | USFR | UUFR) RPARENTHESE + ; r3_0 - : R0 | R2 | R3 - ; + : R0 + | R2 + | R3 + ; r7_4 - : R4 | R5 | R6 | R7 - ; + : R4 + | R5 + | R6 + | R7 + ; r11_8 - : R8 | R9 | R10 | R11 - ; + : R8 + | R9 + | R10 + | R11 + ; r15_12 - : R12 | R13 | R14 | R15 - ; + : R12 + | R13 + | R14 + | R15 + ; f3_0 - : F0 | F2 | F3 - ; + : F0 + | F2 + | F3 + ; f7_4 - : F4 | F5 | F6 | F7 - ; + : F4 + | F5 + | F6 + | F7 + ; f11_8 - : F8 | F9 | F10 | F11 - ; + : F8 + | F9 + | F10 + | F11 + ; f15_12 - : F12 | F13 | F14 | F15 - ; + : F12 + | F13 + | F14 + | F15 + ; addr - : ID | INT - ; + : ID + | INT + ; mrf - : MR0F | MR1F | MR2F - ; + : MR0F + | MR1F + | MR2F + ; mrb - : MR0B | MR1B | MR2B - ; + : MR0B + | MR1B + | MR2B + ; \ No newline at end of file diff --git a/sici/sici.g4 b/sici/sici.g4 index d710f37e70..5ec473241c 100644 --- a/sici/sici.g4 +++ b/sici/sici.g4 @@ -32,73 +32,75 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://en.wikipedia.org/wiki/Serial_Item_and_Contribution_Identifier +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar sici; sici - : item contribution control* EOF - ; + : item contribution control* EOF + ; item - : issn chronology enumeration - ; + : issn chronology enumeration + ; issn - : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT DIGIT DIGIT - ; + : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT DIGIT DIGIT + ; chronology - : '(' (DIGIT | '/')+ ')' - ; + : '(' (DIGIT | '/')+ ')' + ; enumeration - : DIGIT+ ':' DIGIT+ - ; + : DIGIT+ ':' DIGIT+ + ; contribution - : '<' location ':' title '>' - ; + : '<' location ':' title '>' + ; location - : DIGIT+ - ; + : DIGIT+ + ; title - : LETTER+ - ; + : LETTER+ + ; control - : csi '.' dpi '.' mfi ';' version check - ; + : csi '.' dpi '.' mfi ';' version check + ; csi - : DIGIT - ; + : DIGIT + ; dpi - : DIGIT - ; + : DIGIT + ; mfi - : LETTER LETTER - ; + : LETTER LETTER + ; version - : DIGIT (DIGIT | '-') - ; + : DIGIT (DIGIT | '-') + ; check - : LETTER - ; + : LETTER + ; LETTER - : [a-zA-Z] - ; + : [a-zA-Z] + ; DIGIT - : [0-9] - ; + : [0-9] + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/sieve/sieve.g4 b/sieve/sieve.g4 index f9538e476c..7ea7bffb85 100644 --- a/sieve/sieve.g4 +++ b/sieve/sieve.g4 @@ -33,152 +33,160 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* https://www.ietf.org/rfc/rfc5228.txt */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar sieve; start_ - : commands EOF - ; + : commands EOF + ; commands - : command+ - ; + : command+ + ; command - : IDENTIFIER arguments (';' | block) - ; + : IDENTIFIER arguments (';' | block) + ; arguments - : argument* (test | testlist)? - ; + : argument* (test | testlist)? + ; argument - : stringlist - | string - | NUMBER - | TAG - ; + : stringlist + | string + | NUMBER + | TAG + ; testlist - : '(' test (',' test)* ')' - ; + : '(' test (',' test)* ')' + ; test - : IDENTIFIER arguments - ; + : IDENTIFIER arguments + ; stringlist - : '[' string (',' string)* ']' - ; + : '[' string (',' string)* ']' + ; string - : QUOTEDSTRING - | multiline - ; + : QUOTEDSTRING + | multiline + ; block - : '{' commands '}' - ; + : '{' commands '}' + ; multiline - : 'text:' (multilineliteral | multilinedotstart)* '.' - ; + : 'text:' (multilineliteral | multilinedotstart)* '.' + ; comparator - : ':comparator' string - ; + : ':comparator' string + ; multilineliteral - : OCTETNOTPERIOD OCTETNOTCRLF* - ; + : OCTETNOTPERIOD OCTETNOTCRLF* + ; multilinedotstart - : '.' OCTETNOTCRLF+ - ; + : '.' OCTETNOTCRLF+ + ; LINECOMMENT - : '#' ~ [\r\n]* -> skip - ; + : '#' ~ [\r\n]* -> skip + ; WS - : [ \t\r\n]+ -> skip - ; + : [ \t\r\n]+ -> skip + ; QUOTEDSTRING - : '"' OCTETNOTQSPECIAL+ '"' - ; + : '"' OCTETNOTQSPECIAL+ '"' + ; DIGIT - : [0-9] - ; + : [0-9] + ; ALPHA - : [A-Za-z] - ; + : [A-Za-z] + ; IDENTIFIER - : (ALPHA | '_') (ALPHA | DIGIT | '_')* - ; + : (ALPHA | '_') (ALPHA | DIGIT | '_')* + ; TAG - : ':' IDENTIFIER - ; - // a single octet other than NUL, CR, or LF + : ':' IDENTIFIER + ; + +// a single octet other than NUL, CR, or LF OCTETNOTCRLF - : [\u0001-\u0009] - | [\u000B-\u000C] - | [\u000E-\u00FF] - ; - // a single octet other than NUL,CR, LF, or period + : [\u0001-\u0009] + | [\u000B-\u000C] + | [\u000E-\u00FF] + ; + +// a single octet other than NUL,CR, LF, or period OCTETNOTPERIOD - : [\u0001-\u0009] - | [\u000B-\u000C] - | [\u000E-\u002D] - | [\u002F-\u00FF] - ; - // a single octet other than NUL, CR, LF, double-quote, or backslash + : [\u0001-\u0009] + | [\u000B-\u000C] + | [\u000E-\u002D] + | [\u002F-\u00FF] + ; + +// a single octet other than NUL, CR, LF, double-quote, or backslash OCTETNOTQSPECIAL - : [\u0001-\u0009] - | [\u000B-\u000C] - | [\u000E-\u0021] - | [\u0023-\u005B] - | [\u005D-\u00FF] - ; - // either a CRLF pair, OR a single octet other than NUL, CR, LF, or star + : [\u0001-\u0009] + | [\u000B-\u000C] + | [\u000E-\u0021] + | [\u0023-\u005B] + | [\u005D-\u00FF] + ; + +// either a CRLF pair, OR a single octet other than NUL, CR, LF, or star NOTSTAR - : [\u0001-\u0009] - | [\u000B-\u000C] - | [\u000E-\u0029] - | [\u002B-\u00FF] - ; - // either a CRLF pair, OR a single octet other than NUL, CR, LF, star, or slash + : [\u0001-\u0009] + | [\u000B-\u000C] + | [\u000E-\u0029] + | [\u002B-\u00FF] + ; + +// either a CRLF pair, OR a single octet other than NUL, CR, LF, star, or slash ADDRESSPART - : ':localpart' - | ':domain' - | ':all' - ; + : ':localpart' + | ':domain' + | ':all' + ; MATCHTYPE - : ':is' - | ':contains' - | ':matches' - ; + : ':is' + | ':contains' + | ':matches' + ; NUMBER - : DIGIT+ QUANTIFIER? - ; + : DIGIT+ QUANTIFIER? + ; STAR - : '*' - ; + : '*' + ; QUANTIFIER - : 'K' - | 'M' - | 'G' - ; - + : 'K' + | 'M' + | 'G' + ; \ No newline at end of file diff --git a/smalltalk/Smalltalk.g4 b/smalltalk/Smalltalk.g4 index eacbea9e04..6d18467a1e 100644 --- a/smalltalk/Smalltalk.g4 +++ b/smalltalk/Smalltalk.g4 @@ -5,89 +5,355 @@ 2015/01/18 James Ladd (object@redline.st) */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Smalltalk; -script : sequence EOF; -sequence : temps ws? statements? | ws? statements; -ws : (SEPARATOR | COMMENT)+; -temps : PIPE (ws? IDENTIFIER)+ ws? PIPE; -statements : answer ws? # StatementAnswer - | expressions ws? PERIOD ws? answer # StatementExpressionsAnswer - | expressions PERIOD? ws? # StatementExpressions - ; -answer : CARROT ws? expression ws? PERIOD?; -expression : assignment | cascade | keywordSend | binarySend | primitive; -expressions : expression expressionList*; -expressionList : PERIOD ws? expression; -cascade : (keywordSend | binarySend) (ws? SEMI_COLON ws? message)+; -message : binaryMessage | unaryMessage | keywordMessage; -assignment : variable ws? ASSIGNMENT ws? expression; -variable : IDENTIFIER; -binarySend : unarySend binaryTail?; -unarySend : operand ws? unaryTail?; -keywordSend : binarySend keywordMessage; -keywordMessage : ws? (keywordPair ws?)+; -keywordPair : KEYWORD ws? binarySend ws?; -operand : literal | reference | subexpression; -subexpression : OPEN_PAREN ws? expression ws? CLOSE_PAREN; -literal : runtimeLiteral | parsetimeLiteral; -runtimeLiteral : dynamicDictionary | dynamicArray | block; -block : BLOCK_START blockParamList? ws? sequence? BLOCK_END; -blockParamList : (ws? BLOCK_PARAM)+; -dynamicDictionary : DYNDICT_START ws? expressions? ws? DYNARR_END; -dynamicArray : DYNARR_START ws? expressions? ws? DYNARR_END; -parsetimeLiteral : pseudoVariable | number | charConstant | literalArray | string | symbol; -number : numberExp | hex_ | stFloat | stInteger; -numberExp : (stFloat | stInteger) EXP stInteger; -charConstant : CHARACTER_CONSTANT; -hex_ : MINUS? HEX HEXDIGIT+; -stInteger : MINUS? DIGIT+; -stFloat : MINUS? DIGIT+ PERIOD DIGIT+; -pseudoVariable : RESERVED_WORD; -string : STRING; -symbol : HASH bareSymbol; -primitive : LT ws? KEYWORD ws? DIGIT+ ws? GT; -bareSymbol : (IDENTIFIER | BINARY_SELECTOR) | KEYWORD+ | string; -literalArray : LITARR_START literalArrayRest; -literalArrayRest : ws? ((parsetimeLiteral | bareLiteralArray | bareSymbol) ws?)* CLOSE_PAREN; -bareLiteralArray : OPEN_PAREN literalArrayRest; -unaryTail : unaryMessage ws? unaryTail? ws?; -unaryMessage : ws? unarySelector; -unarySelector : IDENTIFIER; -keywords : KEYWORD+; -reference : variable; -binaryTail : binaryMessage binaryTail?; -binaryMessage : ws? BINARY_SELECTOR ws? (unarySend | operand); - -SEPARATOR : [ \t\r\n]; -STRING : '\'' (.)*? '\''; -COMMENT : '"' (.)*? '"'; -BLOCK_START : '['; -BLOCK_END : ']'; -CLOSE_PAREN : ')'; -OPEN_PAREN : '('; -PIPE : '|'; -PERIOD : '.'; -SEMI_COLON : ';'; -BINARY_SELECTOR : ('\\' | '+' | '*' | '/' | '=' | '>' | '<' | ',' | '@' | '%' | '~' | PIPE | '&' | '-' | '?')+; -LT : '<'; -GT : '>'; -MINUS : '-'; -RESERVED_WORD : 'nil' | 'true' | 'false' | 'self' | 'super'; -IDENTIFIER : [a-zA-Z]+[a-zA-Z0-9_]*; -CARROT : '^'; -COLON : ':'; -ASSIGNMENT : ':='; -HASH : '#'; -DOLLAR : '$'; -EXP : 'e'; -HEX : '16r'; -LITARR_START : '#('; -DYNDICT_START : '#{'; -DYNARR_END : '}'; -DYNARR_START : '{'; -DIGIT : [0-9]; -HEXDIGIT : [0-9a-fA-F]; -KEYWORD : IDENTIFIER COLON; -BLOCK_PARAM : COLON IDENTIFIER; -CHARACTER_CONSTANT : DOLLAR (HEXDIGIT | DOLLAR); +script + : sequence EOF + ; + +sequence + : temps ws? statements? + | ws? statements + ; + +ws + : (SEPARATOR | COMMENT)+ + ; + +temps + : PIPE (ws? IDENTIFIER)+ ws? PIPE + ; + +statements + : answer ws? # StatementAnswer + | expressions ws? PERIOD ws? answer # StatementExpressionsAnswer + | expressions PERIOD? ws? # StatementExpressions + ; + +answer + : CARROT ws? expression ws? PERIOD? + ; + +expression + : assignment + | cascade + | keywordSend + | binarySend + | primitive + ; + +expressions + : expression expressionList* + ; + +expressionList + : PERIOD ws? expression + ; + +cascade + : (keywordSend | binarySend) (ws? SEMI_COLON ws? message)+ + ; + +message + : binaryMessage + | unaryMessage + | keywordMessage + ; + +assignment + : variable ws? ASSIGNMENT ws? expression + ; + +variable + : IDENTIFIER + ; + +binarySend + : unarySend binaryTail? + ; + +unarySend + : operand ws? unaryTail? + ; + +keywordSend + : binarySend keywordMessage + ; + +keywordMessage + : ws? (keywordPair ws?)+ + ; + +keywordPair + : KEYWORD ws? binarySend ws? + ; + +operand + : literal + | reference + | subexpression + ; + +subexpression + : OPEN_PAREN ws? expression ws? CLOSE_PAREN + ; + +literal + : runtimeLiteral + | parsetimeLiteral + ; + +runtimeLiteral + : dynamicDictionary + | dynamicArray + | block + ; + +block + : BLOCK_START blockParamList? ws? sequence? BLOCK_END + ; + +blockParamList + : (ws? BLOCK_PARAM)+ + ; + +dynamicDictionary + : DYNDICT_START ws? expressions? ws? DYNARR_END + ; + +dynamicArray + : DYNARR_START ws? expressions? ws? DYNARR_END + ; + +parsetimeLiteral + : pseudoVariable + | number + | charConstant + | literalArray + | string + | symbol + ; + +number + : numberExp + | hex_ + | stFloat + | stInteger + ; + +numberExp + : (stFloat | stInteger) EXP stInteger + ; + +charConstant + : CHARACTER_CONSTANT + ; + +hex_ + : MINUS? HEX HEXDIGIT+ + ; + +stInteger + : MINUS? DIGIT+ + ; + +stFloat + : MINUS? DIGIT+ PERIOD DIGIT+ + ; + +pseudoVariable + : RESERVED_WORD + ; + +string + : STRING + ; + +symbol + : HASH bareSymbol + ; + +primitive + : LT ws? KEYWORD ws? DIGIT+ ws? GT + ; + +bareSymbol + : (IDENTIFIER | BINARY_SELECTOR) + | KEYWORD+ + | string + ; + +literalArray + : LITARR_START literalArrayRest + ; + +literalArrayRest + : ws? ((parsetimeLiteral | bareLiteralArray | bareSymbol) ws?)* CLOSE_PAREN + ; + +bareLiteralArray + : OPEN_PAREN literalArrayRest + ; + +unaryTail + : unaryMessage ws? unaryTail? ws? + ; + +unaryMessage + : ws? unarySelector + ; + +unarySelector + : IDENTIFIER + ; + +keywords + : KEYWORD+ + ; + +reference + : variable + ; + +binaryTail + : binaryMessage binaryTail? + ; + +binaryMessage + : ws? BINARY_SELECTOR ws? (unarySend | operand) + ; + +SEPARATOR + : [ \t\r\n] + ; + +STRING + : '\'' (.)*? '\'' + ; + +COMMENT + : '"' (.)*? '"' + ; + +BLOCK_START + : '[' + ; + +BLOCK_END + : ']' + ; + +CLOSE_PAREN + : ')' + ; + +OPEN_PAREN + : '(' + ; + +PIPE + : '|' + ; + +PERIOD + : '.' + ; + +SEMI_COLON + : ';' + ; + +BINARY_SELECTOR + : ('\\' | '+' | '*' | '/' | '=' | '>' | '<' | ',' | '@' | '%' | '~' | PIPE | '&' | '-' | '?')+ + ; + +LT + : '<' + ; + +GT + : '>' + ; + +MINUS + : '-' + ; + +RESERVED_WORD + : 'nil' + | 'true' + | 'false' + | 'self' + | 'super' + ; + +IDENTIFIER + : [a-zA-Z]+ [a-zA-Z0-9_]* + ; + +CARROT + : '^' + ; + +COLON + : ':' + ; + +ASSIGNMENT + : ':=' + ; + +HASH + : '#' + ; + +DOLLAR + : '$' + ; + +EXP + : 'e' + ; + +HEX + : '16r' + ; + +LITARR_START + : '#(' + ; + +DYNDICT_START + : '#{' + ; + +DYNARR_END + : '}' + ; + +DYNARR_START + : '{' + ; + +DIGIT + : [0-9] + ; + +HEXDIGIT + : [0-9a-fA-F] + ; + +KEYWORD + : IDENTIFIER COLON + ; + +BLOCK_PARAM + : COLON IDENTIFIER + ; + +CHARACTER_CONSTANT + : DOLLAR (HEXDIGIT | DOLLAR) + ; \ No newline at end of file diff --git a/smiles/smiles.g4 b/smiles/smiles.g4 index 539142074e..53ea9a68ca 100644 --- a/smiles/smiles.g4 +++ b/smiles/smiles.g4 @@ -16,353 +16,534 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -grammar smiles; - -smiles: chain terminator? EOF; - -atom: bracket_atom | aliphatic_organic | aromatic_organic | '*'; - -aliphatic_organic: - UB - | UC - | UN - | UO - | US - | UP - | UF - | UC LL - | UB LR - | UI; - -aromatic_organic: LB | LC | LN | LO | LS | LP; - -bracket_atom: - '[' isotope? symbol chiral? hcount? charge? class_? ']'; - -isotope: DIGIT+; - -symbol: element_symbols | aromatic_symbol | '*'; - -element_symbols: UH - | UH LE - | UL LI - | UB LE - | UB - | UC - | UN - | UO - | UF - | UN LE - | UN LA - | UM LG - | UA LL - | US LI - | UP - | US - | UC LL - | UA LR - | UK - | UC LA - | US LC - | UT LI - | UV - | UC LR - | UM LN - | UF LE - | UC LO - | UN LI - | UC LU - | UZ LN - | UG LA - | UG LE - | UA LS - | US LE - | UB LR - | UK LR - | UR LB - | US LR - | UY - | UZ LR - | UN LB - | UM LO - | UT LC - | UR LU - | UR LH - | UP LD - | UA LG - | UC LD - | UI LN - | US LN - | US LB - | UT LE - | UI - | UX LE - | UC LS - | UB LA - | UH LF - | UT LA - | UW - | UR LE - | UO LS - | UI LR - | UP LT - | UA LU - | UH LG - | UT LL - | UP LB - | UB LI - | UP LO - | UA LT - | UR LN - | UF LR - | UR LA - | UR LF - | UD LB - | US LG - | UB LH - | UH LS - | UM LT - | UD LS - | UR LG - | UC LN - | UF LL - | UL LV - | UL LA - | UC LE - | UP LR - | UN LD - | UP LM - | US LM - | UE LU - | UG LD - | UT LB - | UD LY - | UH LO - | UE LR - | UT LM - | UY LB - | UL LU - | UA LC - | UT LH - | UP LA - | UU - | UN LP - | UP LU - | UA LM - | UC LM - | UB LK - | UC LF - | UE LS - | UF LM - | UM LD - | UN LO - | UL LR; - -aromatic_symbol: LC | LN | LO | LP | LS | LS LE | LA LS; - -chiral: - '@' - | '@@' - | '@TH1' - | '@TH2' - | '@AL1' - | '@AL2' - | '@SP1' - | '@SP2' - | '@SP3' - | '@TB1' - | '@TB2' - | '@TB3' - | '@TB3' - | '@TB4' - | '@TB5' - | '@TB6' - | '@TB7' - | '@TB8' - | '@TB9' - | '@TB10' - | '@TB11' - | '@TB12' - | '@TB13' - | '@TB14' - | '@TB15' - | '@TB16' - | '@TB17' - | '@TB18' - | '@TB19' - | '@TB20' - | '@TB21' - | '@TB22' - | '@TB23' - | '@TB24' - | '@TB25' - | '@TB26' - | '@TB27' - | '@TB28' - | '@TB29' - | '@TB30' - | '@OH1' - | '@OH2' - | '@OH3' - | '@OH4' - | '@OH5' - | '@OH6' - | '@OH7' - | '@OH8' - | '@OH9' - | '@OH10' - | '@OH11' - | '@OH12' - | '@OH13' - | '@OH14' - | '@OH15' - | '@OH16' - | '@OH17' - | '@OH18' - | '@OH19' - | '@OH20' - | '@OH21' - | '@OH22' - | '@OH23' - | '@OH24' - | '@OH25' - | '@OH26' - | '@OH27' - | '@OH28' - | '@OH29' - | '@OH30' - | ('@TB' | '@OH') DIGIT DIGIT; - -hcount: UH DIGIT?; - -charge: ('+' | '-') DIGIT? DIGIT? | '--' | '++'; - -class_: ':' DIGIT+; - -bond: '-' | '=' | '#' | '$' | ':' | '/' | '\\'; - -ringbond: bond? (DIGIT | '%' DIGIT DIGIT); - -branched_atom: atom ringbond* branch*; - -branch: '(' (bond | DOT)? chain ')'; - -chain: branched_atom ( (bond | DOT)? branched_atom)*; - -terminator: SPACE TAB | LINEFEED | CARRIAGE_RETURN; - -LA: 'a'; - -LB: 'b'; - -LC: 'c'; -LD: 'd'; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -LE: 'e'; - -LF: 'f'; - -LG: 'g'; - -LH: 'h'; - -LI: 'i'; - -LJ: 'j'; - -LK: 'k'; - -LL: 'l'; - -LM: 'm'; - -LN: 'n'; - -LO: 'o'; - -LP: 'p'; - -LQ: 'q'; - -LR: 'r'; +grammar smiles; -LS: 's'; +smiles + : chain terminator? EOF + ; + +atom + : bracket_atom + | aliphatic_organic + | aromatic_organic + | '*' + ; + +aliphatic_organic + : UB + | UC + | UN + | UO + | US + | UP + | UF + | UC LL + | UB LR + | UI + ; + +aromatic_organic + : LB + | LC + | LN + | LO + | LS + | LP + ; + +bracket_atom + : '[' isotope? symbol chiral? hcount? charge? class_? ']' + ; + +isotope + : DIGIT+ + ; + +symbol + : element_symbols + | aromatic_symbol + | '*' + ; + +element_symbols + : UH + | UH LE + | UL LI + | UB LE + | UB + | UC + | UN + | UO + | UF + | UN LE + | UN LA + | UM LG + | UA LL + | US LI + | UP + | US + | UC LL + | UA LR + | UK + | UC LA + | US LC + | UT LI + | UV + | UC LR + | UM LN + | UF LE + | UC LO + | UN LI + | UC LU + | UZ LN + | UG LA + | UG LE + | UA LS + | US LE + | UB LR + | UK LR + | UR LB + | US LR + | UY + | UZ LR + | UN LB + | UM LO + | UT LC + | UR LU + | UR LH + | UP LD + | UA LG + | UC LD + | UI LN + | US LN + | US LB + | UT LE + | UI + | UX LE + | UC LS + | UB LA + | UH LF + | UT LA + | UW + | UR LE + | UO LS + | UI LR + | UP LT + | UA LU + | UH LG + | UT LL + | UP LB + | UB LI + | UP LO + | UA LT + | UR LN + | UF LR + | UR LA + | UR LF + | UD LB + | US LG + | UB LH + | UH LS + | UM LT + | UD LS + | UR LG + | UC LN + | UF LL + | UL LV + | UL LA + | UC LE + | UP LR + | UN LD + | UP LM + | US LM + | UE LU + | UG LD + | UT LB + | UD LY + | UH LO + | UE LR + | UT LM + | UY LB + | UL LU + | UA LC + | UT LH + | UP LA + | UU + | UN LP + | UP LU + | UA LM + | UC LM + | UB LK + | UC LF + | UE LS + | UF LM + | UM LD + | UN LO + | UL LR + ; + +aromatic_symbol + : LC + | LN + | LO + | LP + | LS + | LS LE + | LA LS + ; + +chiral + : '@' + | '@@' + | '@TH1' + | '@TH2' + | '@AL1' + | '@AL2' + | '@SP1' + | '@SP2' + | '@SP3' + | '@TB1' + | '@TB2' + | '@TB3' + | '@TB3' + | '@TB4' + | '@TB5' + | '@TB6' + | '@TB7' + | '@TB8' + | '@TB9' + | '@TB10' + | '@TB11' + | '@TB12' + | '@TB13' + | '@TB14' + | '@TB15' + | '@TB16' + | '@TB17' + | '@TB18' + | '@TB19' + | '@TB20' + | '@TB21' + | '@TB22' + | '@TB23' + | '@TB24' + | '@TB25' + | '@TB26' + | '@TB27' + | '@TB28' + | '@TB29' + | '@TB30' + | '@OH1' + | '@OH2' + | '@OH3' + | '@OH4' + | '@OH5' + | '@OH6' + | '@OH7' + | '@OH8' + | '@OH9' + | '@OH10' + | '@OH11' + | '@OH12' + | '@OH13' + | '@OH14' + | '@OH15' + | '@OH16' + | '@OH17' + | '@OH18' + | '@OH19' + | '@OH20' + | '@OH21' + | '@OH22' + | '@OH23' + | '@OH24' + | '@OH25' + | '@OH26' + | '@OH27' + | '@OH28' + | '@OH29' + | '@OH30' + | ('@TB' | '@OH') DIGIT DIGIT + ; + +hcount + : UH DIGIT? + ; + +charge + : ('+' | '-') DIGIT? DIGIT? + | '--' + | '++' + ; + +class_ + : ':' DIGIT+ + ; + +bond + : '-' + | '=' + | '#' + | '$' + | ':' + | '/' + | '\\' + ; + +ringbond + : bond? (DIGIT | '%' DIGIT DIGIT) + ; + +branched_atom + : atom ringbond* branch* + ; + +branch + : '(' (bond | DOT)? chain ')' + ; + +chain + : branched_atom ((bond | DOT)? branched_atom)* + ; + +terminator + : SPACE TAB + | LINEFEED + | CARRIAGE_RETURN + ; + +LA + : 'a' + ; + +LB + : 'b' + ; + +LC + : 'c' + ; + +LD + : 'd' + ; + +LE + : 'e' + ; + +LF + : 'f' + ; + +LG + : 'g' + ; + +LH + : 'h' + ; + +LI + : 'i' + ; + +LJ + : 'j' + ; + +LK + : 'k' + ; + +LL + : 'l' + ; + +LM + : 'm' + ; + +LN + : 'n' + ; + +LO + : 'o' + ; + +LP + : 'p' + ; + +LQ + : 'q' + ; + +LR + : 'r' + ; + +LS + : 's' + ; -LT: 't'; +LT + : 't' + ; -LU: 'u'; +LU + : 'u' + ; -LV: 'v'; +LV + : 'v' + ; -LW: 'w'; +LW + : 'w' + ; -LX: 'x'; +LX + : 'x' + ; -LY: 'y'; +LY + : 'y' + ; -LZ: 'z'; +LZ + : 'z' + ; -UA: 'A'; +UA + : 'A' + ; -UB: 'B'; +UB + : 'B' + ; -UC: 'C'; +UC + : 'C' + ; -UD: 'D'; +UD + : 'D' + ; -UE: 'E'; +UE + : 'E' + ; -UF: 'F'; +UF + : 'F' + ; -UG: 'G'; +UG + : 'G' + ; -UH: 'H'; +UH + : 'H' + ; -UI: 'I'; +UI + : 'I' + ; -UJ: 'J'; +UJ + : 'J' + ; -UK: 'K'; +UK + : 'K' + ; -UL: 'L'; +UL + : 'L' + ; -UM: 'M'; +UM + : 'M' + ; -UN: 'N'; +UN + : 'N' + ; -UO: 'O'; +UO + : 'O' + ; -UP: 'P'; +UP + : 'P' + ; -UQ: 'Q'; +UQ + : 'Q' + ; -UR: 'R'; +UR + : 'R' + ; -US: 'S'; +US + : 'S' + ; -UT: 'T'; +UT + : 'T' + ; -UU: 'U'; +UU + : 'U' + ; -UV: 'V'; +UV + : 'V' + ; -UW: 'W'; +UW + : 'W' + ; -UX: 'X'; +UX + : 'X' + ; -UY: 'Y'; +UY + : 'Y' + ; -UZ: 'Z'; +UZ + : 'Z' + ; -DOT: '.'; +DOT + : '.' + ; -LINEFEED: '\r'; +LINEFEED + : '\r' + ; -CARRIAGE_RETURN: '\n'; +CARRIAGE_RETURN + : '\n' + ; -SPACE: ' '; +SPACE + : ' ' + ; -DIGIT: '0' .. '9'; +DIGIT + : '0' .. '9' + ; -TAB: '\t'; +TAB + : '\t' + ; \ No newline at end of file diff --git a/smtlibv2/SMTLIBv2.g4 b/smtlibv2/SMTLIBv2.g4 index 9f1106ed6e..3d3f26ec2b 100644 --- a/smtlibv2/SMTLIBv2.g4 +++ b/smtlibv2/SMTLIBv2.g4 @@ -27,17 +27,17 @@ * SOFTWARE. **/ -grammar SMTLIBv2; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging +grammar SMTLIBv2; // Lexer Rules Start - Comment : Semicolon ~[\r\n]* -> skip ; - ParOpen : '(' ; @@ -54,58 +54,72 @@ String : '"' (PrintableCharNoDquote | WhiteSpaceChar)+ '"' ; -QuotedSymbol: - '|' (PrintableCharNoBackslash | WhiteSpaceChar)+ '|' +QuotedSymbol + : '|' (PrintableCharNoBackslash | WhiteSpaceChar)+ '|' ; - // Predefined Symbols PS_Not : 'not' ; + PS_Bool : 'Bool' ; + PS_ContinuedExecution : 'continued-execution' ; + PS_Error : 'error' ; + PS_False : 'false' ; + PS_ImmediateExit : 'immediate-exit' ; + PS_Incomplete : 'incomplete' ; + PS_Logic : 'logic' ; + PS_Memout : 'memout' ; + PS_Sat : 'sat' ; + PS_Success : 'success' ; + PS_Theory : 'theory' ; + PS_True : 'true' ; + PS_Unknown : 'unknown' ; + PS_Unsupported : 'unsupported' ; + PS_Unsat : 'unsat' ; @@ -114,139 +128,176 @@ PS_Unsat // Command names - CMD_Assert : 'assert' ; + CMD_CheckSat : 'check-sat' ; + CMD_CheckSatAssuming : 'check-sat-assuming' ; + CMD_DeclareConst : 'declare-const' ; + CMD_DeclareDatatype : 'declare-datatype' ; + CMD_DeclareDatatypes : 'declare-datatypes' ; + CMD_DeclareFun : 'declare-fun' ; + CMD_DeclareSort : 'declare-sort' ; + CMD_DefineFun : 'define-fun' ; + CMD_DefineFunRec : 'define-fun-rec' ; + CMD_DefineFunsRec : 'define-funs-rec' ; + CMD_DefineSort : 'define-sort' ; + CMD_Echo : 'echo' ; + CMD_Exit : 'exit' ; + CMD_GetAssertions : 'get-assertions' ; + CMD_GetAssignment : 'get-assignment' ; + CMD_GetInfo : 'get-info' ; + CMD_GetModel : 'get-model' ; + CMD_GetOption : 'get-option' ; + CMD_GetProof : 'get-proof' ; + CMD_GetUnsatAssumptions : 'get-unsat-assumptions' ; + CMD_GetUnsatCore : 'get-unsat-core' ; + CMD_GetValue : 'get-value' ; + CMD_Pop : 'pop' ; + CMD_Push : 'push' ; + CMD_Reset : 'reset' ; + CMD_ResetAssertions : 'reset-assertions' ; + CMD_SetInfo : 'set-info' ; + CMD_SetLogic : 'set-logic' ; + CMD_SetOption : 'set-option' ; - - - // General reserved words GRW_Exclamation : '!' ; + GRW_Underscore : '_' ; + GRW_As : 'as' ; + GRW_Binary : 'BINARY' ; + GRW_Decimal : 'DECIMAL' ; + GRW_Exists : 'exists' ; + GRW_Hexadecimal : 'HEXADECIMAL' ; + GRW_Forall : 'forall' ; + GRW_Let : 'let' ; + GRW_Match : 'match' ; + GRW_Numeral : 'NUMERAL' ; + GRW_Par : 'par' ; + GRW_String : 'string' ; @@ -256,8 +307,8 @@ Numeral | [1-9] Digit* ; -Binary: - BinaryDigit+ +Binary + : BinaryDigit+ ; HexDecimal @@ -268,13 +319,12 @@ Decimal : Numeral '.' '0'* Numeral ; - - fragment HexDigit - : '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' + : '0' .. '9' + | 'a' .. 'f' + | 'A' .. 'F' ; - Colon : ':' ; @@ -284,7 +334,7 @@ fragment Digit ; fragment Sym - : 'a'..'z' + : 'a' ..'z' | 'A' .. 'Z' | '+' | '=' @@ -305,8 +355,6 @@ fragment Sym | '.' ; - - fragment BinaryDigit : [01] ; @@ -347,128 +395,166 @@ fragment WhiteSpaceChar // Predefined Keywords - - PK_AllStatistics : ':all-statistics' ; + PK_AssertionStackLevels : ':assertion-stack-levels' ; + PK_Authors : ':authors' ; + PK_Category : ':category' ; + PK_Chainable : ':chainable' ; + PK_Definition : ':definition' ; + PK_DiagnosticOutputChannel : ':diagnostic-output-channel' ; + PK_ErrorBehaviour : ':error-behavior' ; + PK_Extension : ':extensions' ; + PK_Funs : ':funs' ; + PK_FunsDescription : ':funs-description' ; + PK_GlobalDeclarations : ':global-declarations' ; + PK_InteractiveMode : ':interactive-mode' ; + PK_Language : ':language' ; + PK_LeftAssoc : ':left-assoc' ; + PK_License : ':license' ; + PK_Named : ':named' ; + PK_Name : ':name' ; + PK_Notes : ':notes' ; + PK_Pattern : ':pattern' ; + PK_PrintSuccess : ':print-success' ; + PK_ProduceAssertions : ':produce-assertions' ; + PK_ProduceAssignments : ':produce-assignments' ; + PK_ProduceModels : ':produce-models' ; + PK_ProduceProofs : ':produce-proofs' ; + PK_ProduceUnsatAssumptions : ':produce-unsat-assumptions' ; + PK_ProduceUnsatCores : ':produce-unsat-cores' ; + PK_RandomSeed : ':random-seed' ; + PK_ReasonUnknown : ':reason-unknown' ; + PK_RegularOutputChannel : ':regular-output-channel' ; + PK_ReproducibleResourceLimit : ':reproducible-resource-limit' ; + PK_RightAssoc : ':right-assoc' ; + PK_SmtLibVersion : ':smt-lib-version' ; + PK_Sorts : ':sorts' ; + PK_SortsDescription : ':sorts-description' ; + PK_Source : ':source' ; + PK_Status : ':status' ; + PK_Theories : ':theories' ; + PK_Values : ':values' ; + PK_Verbosity : ':verbosity' ; + PK_Version : ':version' ; @@ -477,9 +563,9 @@ RS_Model // for model responses : 'model' ; -UndefinedSymbol: - Sym (Digit | Sym)*; - +UndefinedSymbol + : Sym (Digit | Sym)* + ; // Parser Rules Start @@ -509,7 +595,6 @@ generalReservedWord | RS_Model ; - simpleSymbol : predefSymbol | UndefinedSymbol @@ -582,8 +667,6 @@ predefKeyword | PK_Version ; - - symbol : simpleSymbol | quotedSymbol @@ -624,7 +707,6 @@ spec_constant | string ; - s_expr : spec_constant | symbol @@ -664,7 +746,6 @@ sort | ParOpen identifier sort+ ParClose ; - // Terms and Formulas qual_identifer @@ -700,11 +781,11 @@ term | ParOpen GRW_Exclamation term attribute+ ParClose ; - // Theory Declarations sort_symbol_decl - : ParOpen identifier numeral attribute* ParClose; + : ParOpen identifier numeral attribute* ParClose + ; meta_spec_constant : GRW_Numeral @@ -720,8 +801,7 @@ fun_symbol_decl par_fun_symbol_decl : fun_symbol_decl - | ParOpen GRW_Par ParOpen symbol+ ParClose ParOpen identifier sort+ - attribute* ParClose ParClose + | ParOpen GRW_Par ParOpen symbol+ ParClose ParOpen identifier sort+ attribute* ParClose ParClose ; theory_attribute @@ -739,7 +819,6 @@ theory_decl : ParOpen PS_Theory symbol theory_attribute+ ParClose ; - // Logic Declarations logic_attribue @@ -755,7 +834,6 @@ logic : ParOpen PS_Logic symbol logic_attribue+ ParClose ; - // Scripts sort_dec @@ -772,8 +850,7 @@ constructor_dec datatype_dec : ParOpen constructor_dec+ ParClose - | ParOpen GRW_Par ParOpen symbol+ ParClose ParOpen constructor_dec+ - ParClose ParClose + | ParOpen GRW_Par ParOpen symbol+ ParClose ParOpen constructor_dec+ ParClose ParClose ; function_dec @@ -789,7 +866,6 @@ prop_literal | ParOpen PS_Not symbol ParClose ; - script : command* ; @@ -815,7 +891,7 @@ cmd_declareDatatype ; cmd_declareDatatypes - // cardinalitiees for sort_dec and datatype_dec have to be n+1 +// cardinalitiees for sort_dec and datatype_dec have to be n+1 : CMD_DeclareDatatypes ParOpen sort_dec+ ParClose ParOpen datatype_dec+ ParClose ; @@ -836,7 +912,7 @@ cmd_defineFunRec ; cmd_defineFunsRec - // cardinalitiees for function_dec and term have to be n+1 +// cardinalitiees for function_dec and term have to be n+1 : CMD_DefineFunsRec ParOpen function_dec+ ParClose ParOpen term+ ParClose ; @@ -949,7 +1025,6 @@ command | ParOpen cmd_setOption ParClose ; - b_value : PS_True | PS_False @@ -1089,8 +1164,8 @@ general_response | ParOpen PS_Error string ParClose ; - // Parser Rules End -WS : [ \t\r\n]+ -> skip - ; +WS + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/snobol/snobol.g4 b/snobol/snobol.g4 index e66b271a00..c830eb594d 100644 --- a/snobol/snobol.g4 +++ b/snobol/snobol.g4 @@ -24,435 +24,392 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar snobol; prog - : lin + EOF - ; + : lin+ EOF + ; lin - : line? EOL - ; + : line? EOL + ; line - : (label? subject pattern? (EQ expression +)? (COLON transfer)?) - | (COLON transfer) - | (COMMENT | END) - ; + : (label? subject pattern? (EQ expression+)? (COLON transfer)?) + | (COLON transfer) + | (COMMENT | END) + ; label - : STRING - ; + : STRING + ; subject - : (AMP? STRING ('[' STRING (',' STRING)* ']')?) - ; + : (AMP? STRING ('[' STRING (',' STRING)* ']')?) + ; pattern - : STRINGLITERAL1 - | STRINGLITERAL2 - ; + : STRINGLITERAL1 + | STRINGLITERAL2 + ; expression - : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* - ; + : multiplyingExpression ((PLUS | MINUS) multiplyingExpression)* + ; multiplyingExpression - : powExpression ((TIMES | DIV) powExpression)* - ; + : powExpression ((TIMES | DIV) powExpression)* + ; powExpression - : atom (POW expression)? - ; + : atom (POW expression)? + ; atom - : (STRINGLITERAL1 | STRINGLITERAL2 | INTEGER) - | subject - | command - | '[' expression (',' expression)* ']' - | LPAREN expression RPAREN - ; + : (STRINGLITERAL1 | STRINGLITERAL2 | INTEGER) + | subject + | command + | '[' expression (',' expression)* ']' + | LPAREN expression RPAREN + ; command - : ident - | differ - | eq - | ne - | ge - | le - | lt - | integer - | lgt - | atan - | chop - | cos - | exp - | ln - | remdr - | sin - | tan - | date - | dupl - | reverse - | replace - | size - | trim - | array_ - | sort - | table - | break_ - ; + : ident + | differ + | eq + | ne + | ge + | le + | lt + | integer + | lgt + | atan + | chop + | cos + | exp + | ln + | remdr + | sin + | tan + | date + | dupl + | reverse + | replace + | size + | trim + | array_ + | sort + | table + | break_ + ; ident - : 'ident' LPAREN expression RPAREN - ; + : 'ident' LPAREN expression RPAREN + ; differ - : 'differ' LPAREN expression RPAREN - ; + : 'differ' LPAREN expression RPAREN + ; eq - : 'eq' LPAREN expression RPAREN - ; + : 'eq' LPAREN expression RPAREN + ; ne - : 'ne' LPAREN expression RPAREN - ; + : 'ne' LPAREN expression RPAREN + ; ge - : 'ge' LPAREN expression RPAREN - ; + : 'ge' LPAREN expression RPAREN + ; gt - : 'gt' LPAREN expression RPAREN - ; + : 'gt' LPAREN expression RPAREN + ; le - : 'le' LPAREN expression RPAREN - ; + : 'le' LPAREN expression RPAREN + ; lt - : 'lt' LPAREN expression RPAREN - ; + : 'lt' LPAREN expression RPAREN + ; integer - : 'integer' LPAREN expression RPAREN - ; + : 'integer' LPAREN expression RPAREN + ; lgt - : 'lgt' LPAREN expression RPAREN - ; + : 'lgt' LPAREN expression RPAREN + ; atan - : 'atan' LPAREN expression RPAREN - ; + : 'atan' LPAREN expression RPAREN + ; chop - : 'chop' LPAREN expression RPAREN - ; + : 'chop' LPAREN expression RPAREN + ; cos - : 'cos' LPAREN expression RPAREN - ; + : 'cos' LPAREN expression RPAREN + ; exp - : 'exp' LPAREN expression RPAREN - ; + : 'exp' LPAREN expression RPAREN + ; ln - : 'ln' LPAREN expression RPAREN - ; + : 'ln' LPAREN expression RPAREN + ; remdr - : 'remdr' LPAREN expression RPAREN - ; + : 'remdr' LPAREN expression RPAREN + ; sin - : 'sin' LPAREN expression RPAREN - ; + : 'sin' LPAREN expression RPAREN + ; tan - : 'tan' LPAREN expression RPAREN - ; + : 'tan' LPAREN expression RPAREN + ; dupl - : 'dupl' LPAREN expression COMMA expression RPAREN - ; + : 'dupl' LPAREN expression COMMA expression RPAREN + ; reverse - : 'reverse' LPAREN expression RPAREN - ; + : 'reverse' LPAREN expression RPAREN + ; date - : 'date' LPAREN RPAREN - ; + : 'date' LPAREN RPAREN + ; replace - : 'replace' LPAREN expression COMMA expression COMMA expression RPAREN - ; + : 'replace' LPAREN expression COMMA expression COMMA expression RPAREN + ; size - : 'size' LPAREN expression RPAREN - ; + : 'size' LPAREN expression RPAREN + ; trim - : 'trim' LPAREN expression RPAREN - ; + : 'trim' LPAREN expression RPAREN + ; array_ - : 'array' LPAREN expression COMMA expression RPAREN - ; + : 'array' LPAREN expression COMMA expression RPAREN + ; convert - : 'convert' LPAREN expression COMMA expression RPAREN - ; + : 'convert' LPAREN expression COMMA expression RPAREN + ; table - : 'table' LPAREN expression RPAREN - ; + : 'table' LPAREN expression RPAREN + ; sort - : 'sort' LPAREN expression RPAREN - ; + : 'sort' LPAREN expression RPAREN + ; break_ - : 'break' LPAREN expression RPAREN - ; + : 'break' LPAREN expression RPAREN + ; transfer - : (transferpre? LPAREN (label | END) RPAREN)? - ; + : (transferpre? LPAREN (label | END) RPAREN)? + ; transferpre - : ('f' | 'F' | 's' | 'S') - ; - + : ('f' | 'F' | 's' | 'S') + ; COMMA - : ',' - ; - + : ',' + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; AMP - : '&' - ; - + : '&' + ; PLUS - : '+' - ; - + : '+' + ; MINUS - : '-' - ; - + : '-' + ; TIMES - : '*' - ; - + : '*' + ; DIV - : '/' - ; - + : '/' + ; POW - : '^' - ; - + : '^' + ; EQ - : '=' - ; - + : '=' + ; COLON - : ':' - ; - + : ':' + ; END - : 'END' - ; - + : 'END' + ; STRINGLITERAL1 - : '"' ~ ["\r\n]* '"' - ; - + : '"' ~ ["\r\n]* '"' + ; STRINGLITERAL2 - : '\'' ~['\r\n]* '\'' - ; - + : '\'' ~['\r\n]* '\'' + ; STRING - : ('a' .. 'z' | 'A' .. 'Z') ('0' .. '9' | 'a' .. 'z' | 'A' .. 'Z')* - ; - + : ('a' .. 'z' | 'A' .. 'Z') ('0' .. '9' | 'a' .. 'z' | 'A' .. 'Z')* + ; INTEGER - : ('+' | '-')? ('0' .. '9') + - ; - + : ('+' | '-')? ('0' .. '9')+ + ; REAL - : ('+' | '-')? ('0' .. '9') + ('.' ('0' .. '9') +)? (('e' | 'E') REAL)* - ; - + : ('+' | '-')? ('0' .. '9')+ ('.' ('0' .. '9')+)? (('e' | 'E') REAL)* + ; fragment A - : ('a' | 'A') - ; - + : ('a' | 'A') + ; fragment B - : ('b' | 'B') - ; - + : ('b' | 'B') + ; fragment C - : ('c' | 'C') - ; - + : ('c' | 'C') + ; fragment D - : ('d' | 'D') - ; - + : ('d' | 'D') + ; fragment E - : ('e' | 'E') - ; - + : ('e' | 'E') + ; fragment F - : ('f' | 'F') - ; - + : ('f' | 'F') + ; fragment G - : ('g' | 'G') - ; - + : ('g' | 'G') + ; fragment H - : ('h' | 'H') - ; - + : ('h' | 'H') + ; fragment I - : ('i' | 'I') - ; - + : ('i' | 'I') + ; fragment J - : ('j' | 'J') - ; - + : ('j' | 'J') + ; fragment K - : ('k' | 'K') - ; - + : ('k' | 'K') + ; fragment L - : ('l' | 'L') - ; - + : ('l' | 'L') + ; fragment M - : ('m' | 'M') - ; - + : ('m' | 'M') + ; fragment N - : ('n' | 'N') - ; - + : ('n' | 'N') + ; fragment O - : ('o' | 'O') - ; - + : ('o' | 'O') + ; fragment P - : ('p' | 'P') - ; - + : ('p' | 'P') + ; fragment Q - : ('q' | 'Q') - ; - + : ('q' | 'Q') + ; fragment R - : ('r' | 'R') - ; - + : ('r' | 'R') + ; fragment S - : ('s' | 'S') - ; - + : ('s' | 'S') + ; fragment T - : ('t' | 'T') - ; - + : ('t' | 'T') + ; fragment U - : ('u' | 'U') - ; - + : ('u' | 'U') + ; fragment V - : ('v' | 'V') - ; - + : ('v' | 'V') + ; fragment W - : ('w' | 'W') - ; - + : ('w' | 'W') + ; fragment X - : ('x' | 'X') - ; - + : ('x' | 'X') + ; fragment Y - : ('y' | 'Y') - ; - + : ('y' | 'Y') + ; fragment Z - : ('z' | 'Z') - ; - + : ('z' | 'Z') + ; COMMENT - : '*' ~ [\r\n]* - ; - + : '*' ~ [\r\n]* + ; EOL - : [\r\n] + - ; - + : [\r\n]+ + ; WS - : (' ' | '\t') + -> skip - ; + : (' ' | '\t')+ -> skip + ; \ No newline at end of file diff --git a/solidity/Solidity.g4 b/solidity/Solidity.g4 index 172ce5259e..399c6c68aa 100644 --- a/solidity/Solidity.g4 +++ b/solidity/Solidity.g4 @@ -14,478 +14,791 @@ // along with this program. If not, see . // Copied from https://solidity.readthedocs.io/en/latest/grammar.html +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Solidity; sourceUnit - : (pragmaDirective | importDirective | structDefinition | enumDefinition | contractDefinition)* EOF ; + : (pragmaDirective | importDirective | structDefinition | enumDefinition | contractDefinition)* EOF + ; pragmaDirective - : 'pragma' pragmaName pragmaValue ';' ; + : 'pragma' pragmaName pragmaValue ';' + ; pragmaName - : identifier ; + : identifier + ; pragmaValue - : version | expression ; + : version + | expression + ; version - : versionConstraint versionConstraint? ; + : versionConstraint versionConstraint? + ; versionConstraint - : versionOperator? VersionLiteral ; + : versionOperator? VersionLiteral + ; versionOperator - : '^' | '~' | '>=' | '>' | '<' | '<=' | '=' ; + : '^' + | '~' + | '>=' + | '>' + | '<' + | '<=' + | '=' + ; importDirective - : 'import' StringLiteralFragment ('as' identifier)? ';' - | 'import' ('*' | identifier) ('as' identifier)? 'from' StringLiteralFragment ';' - | 'import' '{' importDeclaration ( ',' importDeclaration )* '}' 'from' StringLiteralFragment ';' ; + : 'import' StringLiteralFragment ('as' identifier)? ';' + | 'import' ('*' | identifier) ('as' identifier)? 'from' StringLiteralFragment ';' + | 'import' '{' importDeclaration (',' importDeclaration)* '}' 'from' StringLiteralFragment ';' + ; importDeclaration - : identifier ('as' identifier)? ; + : identifier ('as' identifier)? + ; contractDefinition - : 'abstract'? ( 'contract' | 'interface' | 'library' ) identifier - ( 'is' inheritanceSpecifier (',' inheritanceSpecifier )* )? - '{' contractPart* '}' ; + : 'abstract'? ('contract' | 'interface' | 'library') identifier ( + 'is' inheritanceSpecifier (',' inheritanceSpecifier)* + )? '{' contractPart* '}' + ; inheritanceSpecifier - : userDefinedTypeName ( '(' expressionList? ')' )? ; + : userDefinedTypeName ('(' expressionList? ')')? + ; contractPart - : stateVariableDeclaration - | usingForDeclaration - | structDefinition - | modifierDefinition - | functionDefinition - | eventDefinition - | enumDefinition ; + : stateVariableDeclaration + | usingForDeclaration + | structDefinition + | modifierDefinition + | functionDefinition + | eventDefinition + | enumDefinition + ; stateVariableDeclaration - : typeName - ( PublicKeyword | InternalKeyword | PrivateKeyword | ConstantKeyword | ImmutableKeyword | overrideSpecifier )* - identifier ('=' expression)? ';' ; - -overrideSpecifier : 'override' ( '(' userDefinedTypeName (',' userDefinedTypeName)* ')' )? ; + : typeName ( + PublicKeyword + | InternalKeyword + | PrivateKeyword + | ConstantKeyword + | ImmutableKeyword + | overrideSpecifier + )* identifier ('=' expression)? ';' + ; + +overrideSpecifier + : 'override' ('(' userDefinedTypeName (',' userDefinedTypeName)* ')')? + ; usingForDeclaration - : 'using' identifier 'for' ('*' | typeName) ';' ; + : 'using' identifier 'for' ('*' | typeName) ';' + ; structDefinition - : 'struct' identifier - '{' ( variableDeclaration ';' (variableDeclaration ';')* )? '}' ; + : 'struct' identifier '{' (variableDeclaration ';' (variableDeclaration ';')*)? '}' + ; modifierDefinition - : 'modifier' identifier parameterList? ( VirtualKeyword | overrideSpecifier )* ( ';' | block ) ; + : 'modifier' identifier parameterList? (VirtualKeyword | overrideSpecifier)* (';' | block) + ; functionDefinition - : functionDescriptor parameterList modifierList returnParameters? ( ';' | block ) ; + : functionDescriptor parameterList modifierList returnParameters? (';' | block) + ; functionDescriptor - : 'function' ( identifier | ReceiveKeyword | FallbackKeyword )? - | ConstructorKeyword - | FallbackKeyword - | ReceiveKeyword ; + : 'function' (identifier | ReceiveKeyword | FallbackKeyword)? + | ConstructorKeyword + | FallbackKeyword + | ReceiveKeyword + ; returnParameters - : 'returns' parameterList ; + : 'returns' parameterList + ; modifierList - : ( modifierInvocation | stateMutability | ExternalKeyword - | PublicKeyword | InternalKeyword | PrivateKeyword | VirtualKeyword | overrideSpecifier )* ; + : ( + modifierInvocation + | stateMutability + | ExternalKeyword + | PublicKeyword + | InternalKeyword + | PrivateKeyword + | VirtualKeyword + | overrideSpecifier + )* + ; modifierInvocation - : identifier ( '(' expressionList? ')' )? ; + : identifier ('(' expressionList? ')')? + ; eventDefinition - : 'event' identifier eventParameterList AnonymousKeyword? ';' ; + : 'event' identifier eventParameterList AnonymousKeyword? ';' + ; enumDefinition - : 'enum' identifier '{' enumValue? (',' enumValue)* '}' ; + : 'enum' identifier '{' enumValue? (',' enumValue)* '}' + ; enumValue - : identifier ; + : identifier + ; parameterList - : '(' ( parameter (',' parameter)* )? ')' ; + : '(' (parameter (',' parameter)*)? ')' + ; parameter - : typeName storageLocation? identifier? ; + : typeName storageLocation? identifier? + ; eventParameterList - : '(' ( eventParameter (',' eventParameter)* )? ')' ; + : '(' (eventParameter (',' eventParameter)*)? ')' + ; eventParameter - : typeName IndexedKeyword? identifier? ; + : typeName IndexedKeyword? identifier? + ; variableDeclaration - : typeName storageLocation? identifier ; + : typeName storageLocation? identifier + ; typeName - : elementaryTypeName - | userDefinedTypeName - | mapping - | typeName '[' expression? ']' - | functionTypeName ; + : elementaryTypeName + | userDefinedTypeName + | mapping + | typeName '[' expression? ']' + | functionTypeName + ; userDefinedTypeName - : identifier ( '.' identifier )* ; + : identifier ('.' identifier)* + ; mapping - : 'mapping' '(' (elementaryTypeName | userDefinedTypeName) '=>' typeName ')' ; + : 'mapping' '(' (elementaryTypeName | userDefinedTypeName) '=>' typeName ')' + ; functionTypeName - : 'function' parameterList modifierList returnParameters? ; + : 'function' parameterList modifierList returnParameters? + ; storageLocation - : 'memory' | 'storage' | 'calldata'; + : 'memory' + | 'storage' + | 'calldata' + ; stateMutability - : PureKeyword | ConstantKeyword | ViewKeyword | PayableKeyword ; + : PureKeyword + | ConstantKeyword + | ViewKeyword + | PayableKeyword + ; block - : '{' statement* '}' ; + : '{' statement* '}' + ; statement - : ifStatement - | tryStatement - | whileStatement - | forStatement - | block - | inlineAssemblyStatement - | doWhileStatement - | continueStatement - | breakStatement - | returnStatement - | throwStatement - | emitStatement - | simpleStatement ; + : ifStatement + | tryStatement + | whileStatement + | forStatement + | block + | inlineAssemblyStatement + | doWhileStatement + | continueStatement + | breakStatement + | returnStatement + | throwStatement + | emitStatement + | simpleStatement + ; expressionStatement - : expression ';' ; + : expression ';' + ; ifStatement - : 'if' '(' expression ')' statement ( 'else' statement )? ; + : 'if' '(' expression ')' statement ('else' statement)? + ; -tryStatement : 'try' expression returnParameters? block catchClause+ ; +tryStatement + : 'try' expression returnParameters? block catchClause+ + ; // In reality catch clauses still are not processed as below // the identifier can only be a set string: "Error". But plans // of the Solidity team include possible expansion so we'll // leave this as is, befitting with the Solidity docs. -catchClause : 'catch' ( identifier? parameterList )? block ; +catchClause + : 'catch' (identifier? parameterList)? block + ; whileStatement - : 'while' '(' expression ')' statement ; + : 'while' '(' expression ')' statement + ; forStatement - : 'for' '(' ( simpleStatement | ';' ) ( expressionStatement | ';' ) expression? ')' statement ; + : 'for' '(' (simpleStatement | ';') (expressionStatement | ';') expression? ')' statement + ; simpleStatement - : ( variableDeclarationStatement | expressionStatement ) ; + : (variableDeclarationStatement | expressionStatement) + ; inlineAssemblyStatement - : 'assembly' StringLiteralFragment? assemblyBlock ; + : 'assembly' StringLiteralFragment? assemblyBlock + ; doWhileStatement - : 'do' statement 'while' '(' expression ')' ';' ; + : 'do' statement 'while' '(' expression ')' ';' + ; continueStatement - : 'continue' ';' ; + : 'continue' ';' + ; breakStatement - : 'break' ';' ; + : 'break' ';' + ; returnStatement - : 'return' expression? ';' ; + : 'return' expression? ';' + ; // throw is no longer supported by latest Solidity. throwStatement - : 'throw' ';' ; + : 'throw' ';' + ; emitStatement - : 'emit' functionCall ';' ; + : 'emit' functionCall ';' + ; // 'var' is no longer supported by latest Solidity. variableDeclarationStatement - : ( 'var' identifierList | variableDeclaration | '(' variableDeclarationList ')' ) ( '=' expression )? ';'; + : ('var' identifierList | variableDeclaration | '(' variableDeclarationList ')') ( + '=' expression + )? ';' + ; variableDeclarationList - : variableDeclaration? (',' variableDeclaration? )* ; + : variableDeclaration? (',' variableDeclaration?)* + ; identifierList - : '(' ( identifier? ',' )* identifier? ')' ; + : '(' (identifier? ',')* identifier? ')' + ; elementaryTypeName - : 'address' PayableKeyword? | 'bool' | 'string' | 'var' | Int | Uint | 'byte' | Byte | Fixed | Ufixed ; + : 'address' PayableKeyword? + | 'bool' + | 'string' + | 'var' + | Int + | Uint + | 'byte' + | Byte + | Fixed + | Ufixed + ; Int - : 'int' | 'int8' | 'int16' | 'int24' | 'int32' | 'int40' | 'int48' | 'int56' | 'int64' | 'int72' | 'int80' | 'int88' | 'int96' | 'int104' | 'int112' | 'int120' | 'int128' | 'int136' | 'int144' | 'int152' | 'int160' | 'int168' | 'int176' | 'int184' | 'int192' | 'int200' | 'int208' | 'int216' | 'int224' | 'int232' | 'int240' | 'int248' | 'int256' ; + : 'int' + | 'int8' + | 'int16' + | 'int24' + | 'int32' + | 'int40' + | 'int48' + | 'int56' + | 'int64' + | 'int72' + | 'int80' + | 'int88' + | 'int96' + | 'int104' + | 'int112' + | 'int120' + | 'int128' + | 'int136' + | 'int144' + | 'int152' + | 'int160' + | 'int168' + | 'int176' + | 'int184' + | 'int192' + | 'int200' + | 'int208' + | 'int216' + | 'int224' + | 'int232' + | 'int240' + | 'int248' + | 'int256' + ; Uint - : 'uint' | 'uint8' | 'uint16' | 'uint24' | 'uint32' | 'uint40' | 'uint48' | 'uint56' | 'uint64' | 'uint72' | 'uint80' | 'uint88' | 'uint96' | 'uint104' | 'uint112' | 'uint120' | 'uint128' | 'uint136' | 'uint144' | 'uint152' | 'uint160' | 'uint168' | 'uint176' | 'uint184' | 'uint192' | 'uint200' | 'uint208' | 'uint216' | 'uint224' | 'uint232' | 'uint240' | 'uint248' | 'uint256' ; + : 'uint' + | 'uint8' + | 'uint16' + | 'uint24' + | 'uint32' + | 'uint40' + | 'uint48' + | 'uint56' + | 'uint64' + | 'uint72' + | 'uint80' + | 'uint88' + | 'uint96' + | 'uint104' + | 'uint112' + | 'uint120' + | 'uint128' + | 'uint136' + | 'uint144' + | 'uint152' + | 'uint160' + | 'uint168' + | 'uint176' + | 'uint184' + | 'uint192' + | 'uint200' + | 'uint208' + | 'uint216' + | 'uint224' + | 'uint232' + | 'uint240' + | 'uint248' + | 'uint256' + ; Byte - : 'bytes' | 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' | 'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' | 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32' ; + : 'bytes' + | 'bytes1' + | 'bytes2' + | 'bytes3' + | 'bytes4' + | 'bytes5' + | 'bytes6' + | 'bytes7' + | 'bytes8' + | 'bytes9' + | 'bytes10' + | 'bytes11' + | 'bytes12' + | 'bytes13' + | 'bytes14' + | 'bytes15' + | 'bytes16' + | 'bytes17' + | 'bytes18' + | 'bytes19' + | 'bytes20' + | 'bytes21' + | 'bytes22' + | 'bytes23' + | 'bytes24' + | 'bytes25' + | 'bytes26' + | 'bytes27' + | 'bytes28' + | 'bytes29' + | 'bytes30' + | 'bytes31' + | 'bytes32' + ; Fixed - : 'fixed' | ( 'fixed' [0-9]+ 'x' [0-9]+ ) ; + : 'fixed' + | ( 'fixed' [0-9]+ 'x' [0-9]+) + ; Ufixed - : 'ufixed' | ( 'ufixed' [0-9]+ 'x' [0-9]+ ) ; + : 'ufixed' + | ( 'ufixed' [0-9]+ 'x' [0-9]+) + ; expression - : expression ('++' | '--') - | 'new' typeName - | expression '[' expression? ']' - | expression '[' expression? ':' expression? ']' - | expression '.' identifier - | expression '{' nameValueList '}' - | expression '(' functionCallArguments ')' - | PayableKeyword '(' expression ')' - | '(' expression ')' - | ('++' | '--') expression - | ('+' | '-') expression - | ('after' | 'delete') expression - | '!' expression - | '~' expression - | expression '**' expression - | expression ('*' | '/' | '%') expression - | expression ('+' | '-') expression - | expression ('<<' | '>>') expression - | expression '&' expression - | expression '^' expression - | expression '|' expression - | expression ('<' | '>' | '<=' | '>=') expression - | expression ('==' | '!=') expression - | expression '&&' expression - | expression '||' expression - | expression '?' expression ':' expression - | expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=') expression - | primaryExpression ; + : expression ('++' | '--') + | 'new' typeName + | expression '[' expression? ']' + | expression '[' expression? ':' expression? ']' + | expression '.' identifier + | expression '{' nameValueList '}' + | expression '(' functionCallArguments ')' + | PayableKeyword '(' expression ')' + | '(' expression ')' + | ('++' | '--') expression + | ('+' | '-') expression + | ('after' | 'delete') expression + | '!' expression + | '~' expression + | expression '**' expression + | expression ('*' | '/' | '%') expression + | expression ('+' | '-') expression + | expression ('<<' | '>>') expression + | expression '&' expression + | expression '^' expression + | expression '|' expression + | expression ('<' | '>' | '<=' | '>=') expression + | expression ('==' | '!=') expression + | expression '&&' expression + | expression '||' expression + | expression '?' expression ':' expression + | expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=') expression + | primaryExpression + ; primaryExpression - : BooleanLiteral - | numberLiteral - | hexLiteral - | stringLiteral - | identifier ('[' ']')? - | TypeKeyword - | tupleExpression - | typeNameExpression ('[' ']')? ; + : BooleanLiteral + | numberLiteral + | hexLiteral + | stringLiteral + | identifier ('[' ']')? + | TypeKeyword + | tupleExpression + | typeNameExpression ('[' ']')? + ; expressionList - : expression (',' expression)* ; + : expression (',' expression)* + ; nameValueList - : nameValue (',' nameValue)* ','? ; + : nameValue (',' nameValue)* ','? + ; nameValue - : identifier ':' expression ; + : identifier ':' expression + ; functionCallArguments - : '{' nameValueList? '}' - | expressionList? ; + : '{' nameValueList? '}' + | expressionList? + ; functionCall - : expression '(' functionCallArguments ')' ; + : expression '(' functionCallArguments ')' + ; tupleExpression - : '(' ( expression? ( ',' expression? )* ) ')' - | '[' ( expression ( ',' expression )* )? ']' ; + : '(' (expression? ( ',' expression?)*) ')' + | '[' ( expression ( ',' expression)*)? ']' + ; typeNameExpression - : elementaryTypeName - | userDefinedTypeName ; + : elementaryTypeName + | userDefinedTypeName + ; assemblyItem - : identifier - | assemblyBlock - | assemblyExpression - | assemblyLocalDefinition - | assemblyAssignment - | assemblyStackAssignment - | labelDefinition - | assemblySwitch - | assemblyFunctionDefinition - | assemblyFor - | assemblyIf - | BreakKeyword - | ContinueKeyword - | LeaveKeyword - | subAssembly - | numberLiteral - | stringLiteral - | hexLiteral ; + : identifier + | assemblyBlock + | assemblyExpression + | assemblyLocalDefinition + | assemblyAssignment + | assemblyStackAssignment + | labelDefinition + | assemblySwitch + | assemblyFunctionDefinition + | assemblyFor + | assemblyIf + | BreakKeyword + | ContinueKeyword + | LeaveKeyword + | subAssembly + | numberLiteral + | stringLiteral + | hexLiteral + ; assemblyBlock - : '{' assemblyItem* '}' ; + : '{' assemblyItem* '}' + ; assemblyExpression - : assemblyCall | assemblyLiteral ; + : assemblyCall + | assemblyLiteral + ; assemblyCall - : ( 'return' | 'address' | 'byte' | identifier ) ( '(' assemblyExpression? ( ',' assemblyExpression )* ')' )? ; + : ('return' | 'address' | 'byte' | identifier) ( + '(' assemblyExpression? ( ',' assemblyExpression)* ')' + )? + ; assemblyLocalDefinition - : 'let' assemblyIdentifierList ( ':=' assemblyExpression )? ; + : 'let' assemblyIdentifierList (':=' assemblyExpression)? + ; assemblyAssignment - : assemblyIdentifierList ':=' assemblyExpression ; + : assemblyIdentifierList ':=' assemblyExpression + ; assemblyIdentifierList - : identifier ( ',' identifier )* ; + : identifier (',' identifier)* + ; assemblyStackAssignment - : '=:' identifier ; + : '=:' identifier + ; labelDefinition - : identifier ':' ; + : identifier ':' + ; assemblySwitch - : 'switch' assemblyExpression assemblyCase* ; + : 'switch' assemblyExpression assemblyCase* + ; assemblyCase - : 'case' assemblyLiteral assemblyType? assemblyBlock - | 'default' assemblyBlock ; + : 'case' assemblyLiteral assemblyType? assemblyBlock + | 'default' assemblyBlock + ; assemblyFunctionDefinition - : 'function' identifier '(' assemblyTypedVariableList? ')' - assemblyFunctionReturns? assemblyBlock ; + : 'function' identifier '(' assemblyTypedVariableList? ')' assemblyFunctionReturns? assemblyBlock + ; assemblyFunctionReturns - : ( '-' '>' assemblyTypedVariableList ) ; + : ('-' '>' assemblyTypedVariableList) + ; assemblyFor - : 'for' assemblyBlock assemblyExpression assemblyBlock assemblyBlock ; + : 'for' assemblyBlock assemblyExpression assemblyBlock assemblyBlock + ; assemblyIf - : 'if' assemblyExpression assemblyBlock ; + : 'if' assemblyExpression assemblyBlock + ; assemblyLiteral - : ( stringLiteral | DecimalNumber | HexNumber | hexLiteral | BooleanLiteral ) assemblyType? ; + : (stringLiteral | DecimalNumber | HexNumber | hexLiteral | BooleanLiteral) assemblyType? + ; assemblyTypedVariableList - : identifier assemblyType? ( ',' assemblyTypedVariableList )? ; + : identifier assemblyType? (',' assemblyTypedVariableList)? + ; assemblyType - : ':' identifier ; + : ':' identifier + ; subAssembly - : 'assembly' identifier assemblyBlock ; + : 'assembly' identifier assemblyBlock + ; numberLiteral - : (DecimalNumber | HexNumber) NumberUnit? ; + : (DecimalNumber | HexNumber) NumberUnit? + ; identifier - : ('from' | 'calldata' | 'address' | Identifier) ; + : ('from' | 'calldata' | 'address' | Identifier) + ; BooleanLiteral - : 'true' | 'false' ; + : 'true' + | 'false' + ; DecimalNumber - : ( DecimalDigits | (DecimalDigits? '.' DecimalDigits) ) ( [eE] '-'? DecimalDigits )? ; + : (DecimalDigits | (DecimalDigits? '.' DecimalDigits)) ([eE] '-'? DecimalDigits)? + ; -fragment -DecimalDigits - : [0-9] ( '_'? [0-9] )* ; +fragment DecimalDigits + : [0-9] ('_'? [0-9])* + ; HexNumber - : '0' [xX] HexDigits ; + : '0' [xX] HexDigits + ; -fragment -HexDigits - : HexCharacter ( '_'? HexCharacter )* ; +fragment HexDigits + : HexCharacter ('_'? HexCharacter)* + ; NumberUnit - : 'wei' | 'szabo' | 'finney' | 'ether' - | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years' ; + : 'wei' + | 'szabo' + | 'finney' + | 'ether' + | 'seconds' + | 'minutes' + | 'hours' + | 'days' + | 'weeks' + | 'years' + ; HexLiteralFragment - : 'hex' (('"' HexDigits? '"') | ('\'' HexDigits? '\'')) ; + : 'hex' (('"' HexDigits? '"') | ('\'' HexDigits? '\'')) + ; -hexLiteral : HexLiteralFragment+ ; +hexLiteral + : HexLiteralFragment+ + ; -fragment -HexPair - : HexCharacter HexCharacter ; +fragment HexPair + : HexCharacter HexCharacter + ; -fragment -HexCharacter - : [0-9A-Fa-f] ; +fragment HexCharacter + : [0-9A-Fa-f] + ; ReservedKeyword - : 'after' - | 'case' - | 'default' - | 'final' - | 'in' - | 'inline' - | 'let' - | 'match' - | 'null' - | 'of' - | 'relocatable' - | 'static' - | 'switch' - | 'typeof' ; - -AnonymousKeyword : 'anonymous' ; -BreakKeyword : 'break' ; -ConstantKeyword : 'constant' ; -ImmutableKeyword : 'immutable' ; -ContinueKeyword : 'continue' ; -LeaveKeyword : 'leave' ; -ExternalKeyword : 'external' ; -IndexedKeyword : 'indexed' ; -InternalKeyword : 'internal' ; -PayableKeyword : 'payable' ; -PrivateKeyword : 'private' ; -PublicKeyword : 'public' ; -VirtualKeyword : 'virtual' ; -PureKeyword : 'pure' ; -TypeKeyword : 'type' ; -ViewKeyword : 'view' ; - -ConstructorKeyword : 'constructor' ; -FallbackKeyword : 'fallback' ; -ReceiveKeyword : 'receive' ; + : 'after' + | 'case' + | 'default' + | 'final' + | 'in' + | 'inline' + | 'let' + | 'match' + | 'null' + | 'of' + | 'relocatable' + | 'static' + | 'switch' + | 'typeof' + ; + +AnonymousKeyword + : 'anonymous' + ; + +BreakKeyword + : 'break' + ; + +ConstantKeyword + : 'constant' + ; + +ImmutableKeyword + : 'immutable' + ; + +ContinueKeyword + : 'continue' + ; + +LeaveKeyword + : 'leave' + ; + +ExternalKeyword + : 'external' + ; + +IndexedKeyword + : 'indexed' + ; + +InternalKeyword + : 'internal' + ; + +PayableKeyword + : 'payable' + ; + +PrivateKeyword + : 'private' + ; + +PublicKeyword + : 'public' + ; + +VirtualKeyword + : 'virtual' + ; + +PureKeyword + : 'pure' + ; + +TypeKeyword + : 'type' + ; + +ViewKeyword + : 'view' + ; + +ConstructorKeyword + : 'constructor' + ; + +FallbackKeyword + : 'fallback' + ; + +ReceiveKeyword + : 'receive' + ; Identifier - : IdentifierStart IdentifierPart* ; + : IdentifierStart IdentifierPart* + ; -fragment -IdentifierStart - : [a-zA-Z$_] ; +fragment IdentifierStart + : [a-zA-Z$_] + ; -fragment -IdentifierPart - : [a-zA-Z0-9$_] ; +fragment IdentifierPart + : [a-zA-Z0-9$_] + ; stringLiteral - : StringLiteralFragment+ ; + : StringLiteralFragment+ + ; StringLiteralFragment - : '"' DoubleQuotedStringCharacter* '"' - | '\'' SingleQuotedStringCharacter* '\'' ; + : '"' DoubleQuotedStringCharacter* '"' + | '\'' SingleQuotedStringCharacter* '\'' + ; -fragment -DoubleQuotedStringCharacter - : ~["\r\n\\] | ('\\' .) ; +fragment DoubleQuotedStringCharacter + : ~["\r\n\\] + | ('\\' .) + ; -fragment -SingleQuotedStringCharacter - : ~['\r\n\\] | ('\\' .) ; +fragment SingleQuotedStringCharacter + : ~['\r\n\\] + | ('\\' .) + ; VersionLiteral - : [0-9]+ '.' [0-9]+ ('.' [0-9]+)? ; + : [0-9]+ '.' [0-9]+ ('.' [0-9]+)? + ; WS - : [ \t\r\n\u000C]+ -> skip ; + : [ \t\r\n\u000C]+ -> skip + ; COMMENT - : '/*' .*? '*/' -> channel(HIDDEN) ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; LINE_COMMENT - : '//' ~[\r\n]* -> channel(HIDDEN) ; + : '//' ~[\r\n]* -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/sparql/SparqlLexer.g4 b/sparql/SparqlLexer.g4 index ee906183c9..e7d05543ef 100644 --- a/sparql/SparqlLexer.g4 +++ b/sparql/SparqlLexer.g4 @@ -1,222 +1,175 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar SparqlLexer; -options { caseInsensitive=true; } +options { + caseInsensitive = true; +} // Keywords -A options { caseInsensitive=false; } : 'a'; - -ASC: 'ASC'; -ASK: 'ASK'; -BASE: 'BASE'; -BOUND: 'BOUND'; -BY: 'BY'; -CONSTRUCT: 'CONSTRUCT'; -DATATYPE: 'DATATYPE'; -DESC: 'DESC'; -DESCRIBE: 'DESCRIBE'; -DISTINCT: 'DISTINCT'; -FILTER: 'FILTER'; -FROM: 'FROM'; -GRAPH: 'GRAPH'; -LANG: 'LANG'; -LANGMATCHES: 'LANGMATCHES'; -LIMIT: 'LIMIT'; -NAMED: 'NAMED'; -OFFSET: 'OFFSET'; -OPTIONAL: 'OPTIONAL'; -ORDER: 'ORDER'; -PREFIX: 'PREFIX'; -REDUCED: 'REDUCED'; -REGEX: 'REGEX'; -SELECT: 'SELECT'; -STR: 'STR'; -UNION: 'UNION'; -WHERE: 'WHERE'; -TRUE: 'true'; -FALSE: 'false'; - -IS_LITERAL: 'isLITERAL'; -IS_BLANK: 'isBLANK'; -IS_URI: 'isURI'; -IS_IRI: 'isIRI'; -SAME_TERM: 'sameTerm'; +A options { + caseInsensitive = false; +}: 'a'; + +ASC : 'ASC'; +ASK : 'ASK'; +BASE : 'BASE'; +BOUND : 'BOUND'; +BY : 'BY'; +CONSTRUCT : 'CONSTRUCT'; +DATATYPE : 'DATATYPE'; +DESC : 'DESC'; +DESCRIBE : 'DESCRIBE'; +DISTINCT : 'DISTINCT'; +FILTER : 'FILTER'; +FROM : 'FROM'; +GRAPH : 'GRAPH'; +LANG : 'LANG'; +LANGMATCHES : 'LANGMATCHES'; +LIMIT : 'LIMIT'; +NAMED : 'NAMED'; +OFFSET : 'OFFSET'; +OPTIONAL : 'OPTIONAL'; +ORDER : 'ORDER'; +PREFIX : 'PREFIX'; +REDUCED : 'REDUCED'; +REGEX : 'REGEX'; +SELECT : 'SELECT'; +STR : 'STR'; +UNION : 'UNION'; +WHERE : 'WHERE'; +TRUE : 'true'; +FALSE : 'false'; + +IS_LITERAL : 'isLITERAL'; +IS_BLANK : 'isBLANK'; +IS_URI : 'isURI'; +IS_IRI : 'isIRI'; +SAME_TERM : 'sameTerm'; // OPERATORS -COMMA: ','; -DOT: '.'; -DOUBLE_AMP: '&&'; -DOUBLE_BAR: '||'; -DOUBLE_CARET: '^^'; -EQUAL: '='; -EXCLAMATION: '!'; -GREATER: '>'; -GREATER_OR_EQUAL: '>='; -LESS: '<'; -LESS_OR_EQUAL: '<='; -L_CURLY: '{'; -L_PAREN: '('; -L_SQUARE: '['; -MINUS: '-'; -NOT_EQUAL: '!='; -PLUS: '+'; -R_CURLY: '}'; -R_PAREN: ')'; -R_SQUARE: ']'; -SEMICOLON: ';'; -SLASH: '/'; -STAR: '*'; +COMMA : ','; +DOT : '.'; +DOUBLE_AMP : '&&'; +DOUBLE_BAR : '||'; +DOUBLE_CARET : '^^'; +EQUAL : '='; +EXCLAMATION : '!'; +GREATER : '>'; +GREATER_OR_EQUAL : '>='; +LESS : '<'; +LESS_OR_EQUAL : '<='; +L_CURLY : '{'; +L_PAREN : '('; +L_SQUARE : '['; +MINUS : '-'; +NOT_EQUAL : '!='; +PLUS : '+'; +R_CURLY : '}'; +R_PAREN : ')'; +R_SQUARE : ']'; +SEMICOLON : ';'; +SLASH : '/'; +STAR : '*'; // MISC -IRI_REF - : '<' (~('<' | '>' | '"' | '{' | '}' | '|' | '^' | '\\' | '`') | PN_CHARS)* '>' - ; +IRI_REF: '<' (~('<' | '>' | '"' | '{' | '}' | '|' | '^' | '\\' | '`') | PN_CHARS)* '>'; + +PNAME_NS: PN_PREFIX? ':'; + +PNAME_LN: PNAME_NS PN_LOCAL; -PNAME_NS - : PN_PREFIX? ':' - ; +BLANK_NODE_LABEL: '_:' PN_LOCAL; -PNAME_LN - : PNAME_NS PN_LOCAL - ; +VAR1: '?' VARNAME; -BLANK_NODE_LABEL - : '_:' PN_LOCAL - ; +VAR2: '$' VARNAME; -VAR1 - : '?' VARNAME - ; +LANGTAG: '@' PN_CHARS_BASE+ ('-' (PN_CHARS_BASE | DIGIT)+)*; -VAR2 - : '$' VARNAME - ; +INTEGER: DIGIT+; -LANGTAG - : '@' PN_CHARS_BASE+ ('-' (PN_CHARS_BASE | DIGIT)+)* - ; +DECIMAL: DIGIT+ '.' DIGIT* | '.' DIGIT+; -INTEGER - : DIGIT+ - ; +DOUBLE: DIGIT+ '.' DIGIT* EXPONENT | '.'? DIGIT+ EXPONENT; -DECIMAL - : DIGIT+ '.' DIGIT* - | '.' DIGIT+ - ; +INTEGER_POSITIVE: '+' INTEGER; -DOUBLE - : DIGIT+ '.' DIGIT* EXPONENT - | '.'? DIGIT+ EXPONENT - ; +DECIMAL_POSITIVE: '+' DECIMAL; -INTEGER_POSITIVE - : '+' INTEGER - ; +DOUBLE_POSITIVE: '+' DOUBLE; -DECIMAL_POSITIVE - : '+' DECIMAL - ; +INTEGER_NEGATIVE: '-' INTEGER; -DOUBLE_POSITIVE - : '+' DOUBLE - ; +DECIMAL_NEGATIVE: '-' DECIMAL; -INTEGER_NEGATIVE - : '-' INTEGER - ; +DOUBLE_NEGATIVE: '-' DOUBLE; -DECIMAL_NEGATIVE - : '-' DECIMAL - ; +EXPONENT: 'E' ('+' | '-')? DIGIT+; -DOUBLE_NEGATIVE - : '-' DOUBLE - ; +STRING_LITERAL1: '\'' (~('\u0027' | '\u005C' | '\u000A' | '\u000D') | ECHAR)* '\''; -EXPONENT - : 'E' ('+' | '-')? DIGIT+ - ; +STRING_LITERAL2: '"' (~('\u0022' | '\u005C' | '\u000A' | '\u000D') | ECHAR)* '"'; -STRING_LITERAL1 - : '\'' (~('\u0027' | '\u005C' | '\u000A' | '\u000D') | ECHAR)* '\'' - ; +STRING_LITERAL_LONG1: '\'\'\'' (('\'' | '\'\'')? (~('\'' | '\\') | ECHAR))* '\'\'\''; -STRING_LITERAL2 - : '"' (~('\u0022' | '\u005C' | '\u000A' | '\u000D') | ECHAR)* '"' - ; +STRING_LITERAL_LONG2: '"""' (( '"' | '""')? (~('\'' | '\\') | ECHAR))* '"""'; -STRING_LITERAL_LONG1 - : '\'\'\'' (('\'' | '\'\'' )? (~('\'' | '\\') | ECHAR))* '\'\'\'' - ; +ECHAR options { + caseInsensitive = false; +}: '\\' ('t' | 'b' | 'n' | 'r' | 'f' | '"' | '\''); -STRING_LITERAL_LONG2 - : '"""' (( '"' | '""')? (~('\'' | '\\') | ECHAR))* '"""' - ; +NIL: '(' WS* ')'; -ECHAR options { caseInsensitive=false; } - : '\\' ('t' | 'b' | 'n' | 'r' | 'f' | '"' | '\'') - ; +ANON: '[' WS* ']'; -NIL - : '(' WS* ')' - ; +PN_CHARS_U: PN_CHARS_BASE | '_'; -ANON - : '[' WS* ']' - ; +VARNAME: + (PN_CHARS_U | DIGIT) ( + PN_CHARS_U + | DIGIT + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' + )* +; -PN_CHARS_U - : PN_CHARS_BASE - | '_' - ; - -VARNAME - : (PN_CHARS_U | DIGIT) (PN_CHARS_U | DIGIT | '\u00B7' | '\u0300'..'\u036F' | '\u203F'..'\u2040')* - ; - -fragment -PN_CHARS - : PN_CHARS_U +fragment PN_CHARS: + PN_CHARS_U | '-' | DIGIT /*| '\u00B7' | '\u0300'..'\u036F' | '\u203F'..'\u2040'*/ - ; - -PN_PREFIX - : PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? - ; - -PN_LOCAL - : (PN_CHARS_U | DIGIT) ((PN_CHARS | '.')* PN_CHARS)? - ; - -fragment -PN_CHARS_BASE options { caseInsensitive=false; } - : 'A'..'Z' - | 'a'..'z' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - ; - -fragment -DIGIT - : '0'..'9' - ; - -WS - : [ \t\n\r]+ -> channel(HIDDEN) - ; +; + +PN_PREFIX: PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)?; + +PN_LOCAL: (PN_CHARS_U | DIGIT) ((PN_CHARS | '.')* PN_CHARS)?; + +fragment PN_CHARS_BASE options { + caseInsensitive = false; +}: + 'A' ..'Z' + | 'a' ..'z' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00F6' + | '\u00F8' ..'\u02FF' + | '\u0370' ..'\u037D' + | '\u037F' ..'\u1FFF' + | '\u200C' ..'\u200D' + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD'; + +fragment DIGIT: '0' ..'9'; + +WS: [ \t\n\r]+ -> channel(HIDDEN); \ No newline at end of file diff --git a/sparql/SparqlParser.g4 b/sparql/SparqlParser.g4 index f811fe6029..3882d98b93 100644 --- a/sparql/SparqlParser.g4 +++ b/sparql/SparqlParser.g4 @@ -31,10 +31,13 @@ * @author Michele Mostarda (michele) * @version $Id: Sparql.g 5 2007-10-30 17:20:36Z simone $ */ - /* +/* * Ported to Antlr4 by Tom Everett */ +// $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 SparqlParser; options { @@ -266,7 +269,11 @@ numericExpression ; additiveExpression - : multiplicativeExpression (('+' | '-') multiplicativeExpression | numericLiteralPositive | numericLiteralNegative)* + : multiplicativeExpression ( + ('+' | '-') multiplicativeExpression + | numericLiteralPositive + | numericLiteralNegative + )* ; multiplicativeExpression @@ -365,6 +372,4 @@ prefixedName blankNode : BLANK_NODE_LABEL | ANON - ; - - + ; \ No newline at end of file diff --git a/spass/SpassLexer.g4 b/spass/SpassLexer.g4 index c0c2550b40..c4c5bd2357 100644 --- a/spass/SpassLexer.g4 +++ b/spass/SpassLexer.g4 @@ -20,106 +20,110 @@ 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. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar SpassLexer; -Special_symbol : '-' ; -And: 'and' ; -Author: 'author' ; -Axioms: 'axioms' ; -Begin_problem: 'begin_problem' ; -Clause: 'clause' ; -CloseB: ']' ; -CloseBc: '}' ; -CloseP: ')' ; -ClR: 'ClR' ; -Cnf: 'cnf' ; -Colon: ':' ; -Comma: ',' ; -Con: 'Con' ; -Conjectures: 'conjectures' ; -Date: 'date' ; -Description: 'description' ; -Dnf: 'dnf' ; -Dot: '.' ; -EmS: 'EmS' ; -End_of_list: 'end_of_list' ; -End_problem: 'end_problem' ; -EqF: 'EqF' ; -EqR: 'EqR' ; -Equal: 'equal' ; -Equiv: 'equiv' ; -Exists: 'exists' ; -Fac: 'Fac' ; -False_: 'false' ; -Forall: 'forall' ; -Formula: 'formula' ; -Freely: 'freely' ; -Functions: 'functions' ; -Generated_by: 'generated_by' ; -GeR: 'GeR' ; -Hypothesis: 'hypothesis' ; -Implied: 'implied' ; -Implies: 'implies' ; -Inp: 'Inp' ; -KIV: 'KIV' ; -LEM: 'LEM' ; -List_of_clauses: 'list_of_clauses' ; -List_of_declarations: 'list_of_declarations' ; -List_of_descriptions: 'list_of_descriptions' ; -List_of_formulae: 'list_of_formulae' ; -List_of_general_settings: 'list_of_general_settings' ; -List_of_proof: 'list_of_proof' ; -List_of_settings: 'list_of_settings' ; -List_of_symbols: 'list_of_symbols' ; -Logic: 'logic' ; -MOne: '-1' ; -MPm: 'MPm' ; -Name: 'name' ; -Not: 'not' ; -Obv: 'Obv' ; -OHy: 'OHy' ; -OpenB: '[' ; -OpenBc: '{' ; -OpenP: '(' ; -OPm: 'OPm' ; -Or: 'or' ; -OTTER: 'OTTER' ; -Predicate: 'predicate' ; -Predicates: 'predicates' ; -PROTEIN: 'PROTEIN' ; -Rew: 'Rew' ; -RRE: 'RRE' ; -Satisfiable: 'satisfiable' ; -SATURATE: 'SATURATE' ; -SETHEO: 'SETHEO' ; -SHy: 'SHy' ; -SoR: 'SoR' ; -Sort: 'sort' ; -Sorts: 'sorts' ; -SPASS: 'SPASS' ; -SpL: 'SpL' ; -Splitlevel: 'splitlevel' ; -SPm: 'SPm' ; -SpR: 'SpR' ; -Spt: 'Spt' ; -SSi: 'SSi' ; -Status: 'status' ; -Step: 'step' ; -Subsort: 'subsort' ; -Ter: 'Ter' ; -ThreeTAP: '3TAP' ; -True_: 'true' ; -UnC: 'UnC' ; -Unknown: 'unknown' ; -Unsatisfiable: 'unsatisfiable' ; -URR: 'URR' ; -Version: 'version' ; -WS : [ \n\r\t]+ -> channel(HIDDEN) ; -Open: '{*' -> pushMode(TextMode) ; -Identifier : Letter (Letter | Digit | Special_symbol)* ; -Letter : 'a' .. 'z' | 'A' .. 'Z' ; -Digit : '0' .. '9' ; +Special_symbol : '-'; +And : 'and'; +Author : 'author'; +Axioms : 'axioms'; +Begin_problem : 'begin_problem'; +Clause : 'clause'; +CloseB : ']'; +CloseBc : '}'; +CloseP : ')'; +ClR : 'ClR'; +Cnf : 'cnf'; +Colon : ':'; +Comma : ','; +Con : 'Con'; +Conjectures : 'conjectures'; +Date : 'date'; +Description : 'description'; +Dnf : 'dnf'; +Dot : '.'; +EmS : 'EmS'; +End_of_list : 'end_of_list'; +End_problem : 'end_problem'; +EqF : 'EqF'; +EqR : 'EqR'; +Equal : 'equal'; +Equiv : 'equiv'; +Exists : 'exists'; +Fac : 'Fac'; +False_ : 'false'; +Forall : 'forall'; +Formula : 'formula'; +Freely : 'freely'; +Functions : 'functions'; +Generated_by : 'generated_by'; +GeR : 'GeR'; +Hypothesis : 'hypothesis'; +Implied : 'implied'; +Implies : 'implies'; +Inp : 'Inp'; +KIV : 'KIV'; +LEM : 'LEM'; +List_of_clauses : 'list_of_clauses'; +List_of_declarations : 'list_of_declarations'; +List_of_descriptions : 'list_of_descriptions'; +List_of_formulae : 'list_of_formulae'; +List_of_general_settings : 'list_of_general_settings'; +List_of_proof : 'list_of_proof'; +List_of_settings : 'list_of_settings'; +List_of_symbols : 'list_of_symbols'; +Logic : 'logic'; +MOne : '-1'; +MPm : 'MPm'; +Name : 'name'; +Not : 'not'; +Obv : 'Obv'; +OHy : 'OHy'; +OpenB : '['; +OpenBc : '{'; +OpenP : '('; +OPm : 'OPm'; +Or : 'or'; +OTTER : 'OTTER'; +Predicate : 'predicate'; +Predicates : 'predicates'; +PROTEIN : 'PROTEIN'; +Rew : 'Rew'; +RRE : 'RRE'; +Satisfiable : 'satisfiable'; +SATURATE : 'SATURATE'; +SETHEO : 'SETHEO'; +SHy : 'SHy'; +SoR : 'SoR'; +Sort : 'sort'; +Sorts : 'sorts'; +SPASS : 'SPASS'; +SpL : 'SpL'; +Splitlevel : 'splitlevel'; +SPm : 'SPm'; +SpR : 'SpR'; +Spt : 'Spt'; +SSi : 'SSi'; +Status : 'status'; +Step : 'step'; +Subsort : 'subsort'; +Ter : 'Ter'; +ThreeTAP : '3TAP'; +True_ : 'true'; +UnC : 'UnC'; +Unknown : 'unknown'; +Unsatisfiable : 'unsatisfiable'; +URR : 'URR'; +Version : 'version'; +WS : [ \n\r\t]+ -> channel(HIDDEN); +Open : '{*' -> pushMode(TextMode); +Identifier : Letter (Letter | Digit | Special_symbol)*; +Letter : 'a' .. 'z' | 'A' .. 'Z'; +Digit : '0' .. '9'; mode TextMode; -Close: '*}' -> popMode ; -JustText: (~'*' | '*' ~'}' )+ ; +Close : '*}' -> popMode; +JustText : (~'*' | '*' ~'}')+; \ No newline at end of file diff --git a/spass/SpassParser.g4 b/spass/SpassParser.g4 index 22fd3c3bec..9924c1e594 100644 --- a/spass/SpassParser.g4 +++ b/spass/SpassParser.g4 @@ -20,88 +20,305 @@ 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. */ +// $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 SpassParser; -options { tokenVocab=SpassLexer; } - -problem : 'begin_problem' '(' identifier ')' '.' description logical_part settings* 'end_problem' '.' EOF ; -description : 'list_of_descriptions' '.' - 'name' '(' ( Open text_ Close )? ')' '.' - 'author' '(' ( Open text_ Close )? ')' '.' - ( 'version' '(' ( Open text_ Close )? ')' '.' )? - ( 'logic' '(' ( Open text_ Close )? ')' '.' )? - 'status' '(' log_state ')' '.' - 'description' '(' ( Open text_ Close )? ')' '.' - ( 'date' '(' ( Open text_ Close )? ')' '.' )? - 'end_of_list' '.' - ; -log_state : 'satisfiable' | 'unsatisfiable' | 'unknown' ; -logical_part : symbol_list? declaration_list? formula_list* clause_list* proof_list* ; -symbol_list : 'list_of_symbols' '.' - ( 'functions' '[' ( fun_sym | '(' fun_sym ',' arity ')' ) ( ',' ( fun_sym | '(' fun_sym ',' arity ')' ) )* ']' '.' )? - ( 'predicates' '[' ( pred_sym | '(' pred_sym ',' arity ')' ) ( ',' ( pred_sym | '(' pred_sym ',' arity ')' ) )* ']' '.' )? - ( 'sorts' '[' sort_sym ( ',' sort_sym )* ']' '.' )? - 'end_of_list' '.' - ; -declaration_list : 'list_of_declarations' '.' - declaration* - 'end_of_list' '.' - ; -declaration : subsort_decl | term_decl | pred_decl | gen_decl ; -gen_decl : 'sort' sort_sym 'freely'? 'generated_by' func_list '.' ; -func_list : '[' fun_sym ( ',' fun_sym )* ']' ; -subsort_decl : 'subsort' '(' sort_sym ',' sort_sym ')' '.' ; -term_decl : 'forall' '(' term_list ',' term ')' '.' | term '.' ; -pred_decl : 'predicate' '(' pred_sym ( ',' sort_sym )+ ')' '.' ; -sort_sym : identifier ; -pred_sym : identifier ; -fun_sym : identifier ; -formula_list : 'list_of_formulae' '(' origin_type ')' '.' - ( 'formula' '(' term? ( ',' label )? ')' '.' )* - 'end_of_list' '.' - ; -origin_type : 'axioms' | 'conjectures' ; -label : identifier | number ; -term : quant_sym '(' term_list ',' term ')' | symbol | symbol '(' term ( ',' term )* ')' ; -term_list : '[' term ( ',' term )* ']' ; -quant_sym : 'forall' | 'exists' | identifier ; -symbol : 'equal' | 'true' | 'false' | 'or' | 'and' | 'not' | 'implies' | 'implied' | 'equiv' | identifier ; -clause_list : 'list_of_clauses' '(' origin_type ',' clause_type ')' '.' - ( 'clause' '(' ( cnf_clause | dnf_clause)? ( ',' label )? ')' '.' )* - 'end_of_list' '.' - ; -clause_type : 'cnf' | 'dnf' ; -cnf_clause : 'forall' '(' term_list ',' cnf_clause_body ')' | cnf_clause_body ; -dnf_clause : 'exists' '(' term_list ',' dnf_clause_body ')' | dnf_clause_body ; -cnf_clause_body : 'or' '(' term ( ',' term )* ')' ; -dnf_clause_body : 'and' '(' term ( ',' term )* ')' ; -proof_list : 'list_of_proof' ( '(' proof_type ( ',' assoc_list )? ')' )? '.' - ( 'step' '(' reference ',' result ',' rule_appl ',' parent_list ( ',' assoc_list )? ')' '.' )* - 'end_of_list' '.' - ; -reference : term | identifier | user_reference ; -result : term | user_result ; -rule_appl : term | identifier | user_rule_appl ; -parent_list : '[' parent_ ( ',' parent_ )* ']' ; -parent_ : term | identifier | user_parent ; -assoc_list : '[' key ':' value ( ',' key ':' value )* ']' ; -key : term | identifier | user_key ; -value : term | identifier | user_value ; -proof_type : identifier | user_proof_type ; -user_reference : number ; -user_result : cnf_clause ; -user_rule_appl : 'GeR' | 'SpL' | 'SpR' | 'EqF' | 'Rew' | 'Obv' | 'EmS' | 'SoR' | 'EqR' | 'MPm' | 'SPm' | 'OPm' | 'SHy' | 'OHy' | 'URR' | 'Fac' | 'Spt' | 'Inp' | 'Con' | 'RRE' | 'SSi' | 'ClR' | 'UnC' | 'Ter' ; -user_parent : number ; -user_proof_type : 'SPASS' ; -user_key : 'splitlevel' ; -user_value : number ; -settings : 'list_of_general_settings' setting_entry+ 'end_of_list' '.' - | 'list_of_settings' '(' setting_label ')' '.' ( Open text_ Close )? 'end_of_list' '.' - ; -setting_entry : 'hypothesis' '[' label ( ',' label )* ']' '.' ; -setting_label : 'KIV' | 'LEM' | 'OTTER' | 'PROTEIN' | 'SATURATE' | '3TAP' | 'SETHEO' | 'SPASS' ; -identifier : Identifier ; -arity : '-1' | number ; -number : Digit+ ; -text_ : JustText ; +options { + tokenVocab = SpassLexer; +} + +problem + : 'begin_problem' '(' identifier ')' '.' description logical_part settings* 'end_problem' '.' EOF + ; + +description + : 'list_of_descriptions' '.' 'name' '(' (Open text_ Close)? ')' '.' 'author' '(' ( + Open text_ Close + )? ')' '.' ('version' '(' ( Open text_ Close)? ')' '.')? ( + 'logic' '(' ( Open text_ Close)? ')' '.' + )? 'status' '(' log_state ')' '.' 'description' '(' (Open text_ Close)? ')' '.' ( + 'date' '(' ( Open text_ Close)? ')' '.' + )? 'end_of_list' '.' + ; + +log_state + : 'satisfiable' + | 'unsatisfiable' + | 'unknown' + ; + +logical_part + : symbol_list? declaration_list? formula_list* clause_list* proof_list* + ; + +symbol_list + : 'list_of_symbols' '.' ( + 'functions' '[' (fun_sym | '(' fun_sym ',' arity ')') ( + ',' ( fun_sym | '(' fun_sym ',' arity ')') + )* ']' '.' + )? ( + 'predicates' '[' (pred_sym | '(' pred_sym ',' arity ')') ( + ',' ( pred_sym | '(' pred_sym ',' arity ')') + )* ']' '.' + )? ('sorts' '[' sort_sym ( ',' sort_sym)* ']' '.')? 'end_of_list' '.' + ; + +declaration_list + : 'list_of_declarations' '.' declaration* 'end_of_list' '.' + ; + +declaration + : subsort_decl + | term_decl + | pred_decl + | gen_decl + ; + +gen_decl + : 'sort' sort_sym 'freely'? 'generated_by' func_list '.' + ; + +func_list + : '[' fun_sym (',' fun_sym)* ']' + ; + +subsort_decl + : 'subsort' '(' sort_sym ',' sort_sym ')' '.' + ; + +term_decl + : 'forall' '(' term_list ',' term ')' '.' + | term '.' + ; + +pred_decl + : 'predicate' '(' pred_sym (',' sort_sym)+ ')' '.' + ; + +sort_sym + : identifier + ; + +pred_sym + : identifier + ; + +fun_sym + : identifier + ; + +formula_list + : 'list_of_formulae' '(' origin_type ')' '.' ('formula' '(' term? ( ',' label)? ')' '.')* 'end_of_list' '.' + ; + +origin_type + : 'axioms' + | 'conjectures' + ; + +label + : identifier + | number + ; + +term + : quant_sym '(' term_list ',' term ')' + | symbol + | symbol '(' term ( ',' term)* ')' + ; + +term_list + : '[' term (',' term)* ']' + ; + +quant_sym + : 'forall' + | 'exists' + | identifier + ; + +symbol + : 'equal' + | 'true' + | 'false' + | 'or' + | 'and' + | 'not' + | 'implies' + | 'implied' + | 'equiv' + | identifier + ; + +clause_list + : 'list_of_clauses' '(' origin_type ',' clause_type ')' '.' ( + 'clause' '(' ( cnf_clause | dnf_clause)? ( ',' label)? ')' '.' + )* 'end_of_list' '.' + ; + +clause_type + : 'cnf' + | 'dnf' + ; + +cnf_clause + : 'forall' '(' term_list ',' cnf_clause_body ')' + | cnf_clause_body + ; + +dnf_clause + : 'exists' '(' term_list ',' dnf_clause_body ')' + | dnf_clause_body + ; + +cnf_clause_body + : 'or' '(' term (',' term)* ')' + ; + +dnf_clause_body + : 'and' '(' term (',' term)* ')' + ; + +proof_list + : 'list_of_proof' ('(' proof_type ( ',' assoc_list)? ')')? '.' ( + 'step' '(' reference ',' result ',' rule_appl ',' parent_list (',' assoc_list)? ')' '.' + )* 'end_of_list' '.' + ; + +reference + : term + | identifier + | user_reference + ; + +result + : term + | user_result + ; + +rule_appl + : term + | identifier + | user_rule_appl + ; + +parent_list + : '[' parent_ (',' parent_)* ']' + ; + +parent_ + : term + | identifier + | user_parent + ; + +assoc_list + : '[' key ':' value (',' key ':' value)* ']' + ; + +key + : term + | identifier + | user_key + ; + +value + : term + | identifier + | user_value + ; + +proof_type + : identifier + | user_proof_type + ; + +user_reference + : number + ; + +user_result + : cnf_clause + ; + +user_rule_appl + : 'GeR' + | 'SpL' + | 'SpR' + | 'EqF' + | 'Rew' + | 'Obv' + | 'EmS' + | 'SoR' + | 'EqR' + | 'MPm' + | 'SPm' + | 'OPm' + | 'SHy' + | 'OHy' + | 'URR' + | 'Fac' + | 'Spt' + | 'Inp' + | 'Con' + | 'RRE' + | 'SSi' + | 'ClR' + | 'UnC' + | 'Ter' + ; + +user_parent + : number + ; + +user_proof_type + : 'SPASS' + ; + +user_key + : 'splitlevel' + ; + +user_value + : number + ; + +settings + : 'list_of_general_settings' setting_entry+ 'end_of_list' '.' + | 'list_of_settings' '(' setting_label ')' '.' (Open text_ Close)? 'end_of_list' '.' + ; + +setting_entry + : 'hypothesis' '[' label (',' label)* ']' '.' + ; + +setting_label + : 'KIV' + | 'LEM' + | 'OTTER' + | 'PROTEIN' + | 'SATURATE' + | '3TAP' + | 'SETHEO' + | 'SPASS' + ; + +identifier + : Identifier + ; + +arity + : '-1' + | number + ; + +number + : Digit+ + ; +text_ + : JustText + ; \ No newline at end of file diff --git a/sql/athena/AthenaLexer.g4 b/sql/athena/AthenaLexer.g4 index 389a1f840d..7df1f12f10 100644 --- a/sql/athena/AthenaLexer.g4 +++ b/sql/athena/AthenaLexer.g4 @@ -21,221 +21,202 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar AthenaLexer; -options { caseInsensitive = true; } - -ADD : 'ADD'; -ALL : 'ALL'; -ALTER : 'ALTER'; -ANALYZE : 'ANALYZE'; -AND : 'AND'; -ANY : 'ANY'; -ARRAY : 'ARRAY'; -AS : 'AS'; -ASC : 'ASC'; -AVRO : 'AVRO'; -BETWEEN : 'BETWEEN'; -BIGINT : 'BIGINT'; -BIN_PACK : 'BIN_PACK'; -BINARY : 'BINARY'; -BOOLEAN : 'BOOLEAN'; -BUCKETS : 'BUCKETS'; -BY : 'BY'; -CASCADE : 'CASCADE'; -CASE : 'CASE'; -CAST : 'CAST'; -CHAR : 'CHAR'; -CLUSTERED : 'CLUSTERED'; -COLLECTION : 'COLLECTION'; -COLUMNS : 'COLUMNS'; -COMMENT : 'COMMENT'; -CREATE : 'CREATE'; -DATA : 'DATA'; -DATABASE : 'DATABASE'; -DATABASES : 'DATABASES'; -DATE : 'DATE'; -DBPROPERTIES : 'DBPROPERTIES'; -DEALLOCATE : 'DEALLOCATE'; -DECIMAL : 'DECIMAL'; -DEFINED : 'DEFINED'; -DELETE : 'DELETE'; -DELIMITED : 'DELIMITED'; -DESC : 'DESC'; -DESCRIBE : 'DESCRIBE'; -DISTINCT : 'DISTINCT'; -DISTRIBUTED : 'DISTRIBUTED'; -DOUBLE : 'DOUBLE'; -DROP : 'DROP'; -ELSE : 'ELSE'; -END : 'END'; -ESCAPED : 'ESCAPED'; -EXCEPT : 'EXCEPT'; -EXECUTE : 'EXECUTE'; -EXISTS : 'EXISTS'; -EXPLAIN : 'EXPLAIN'; -EXTENDED : 'EXTENDED'; -EXTERNAL : 'EXTERNAL'; -FALSE : 'FALSE'; -FIELDS : 'FIELDS'; -FIRST : 'FIRST'; -FLOAT : 'FLOAT'; -FORMAT : 'FORMAT'; -FORMATTED : 'FORMATTED'; -FROM : 'FROM'; -GRAPHVIZ : 'GRAPHVIZ'; -GROUP : 'GROUP'; -HAVING : 'HAVING'; -IF : 'IF'; -IN : 'IN'; -INPUTFORMAT : 'INPUTFORMAT'; -INSERT : 'INSERT'; -INT : 'INT'; -INTEGER : 'INTEGER'; -INTERSECT : 'INTERSECT'; -INTO : 'INTO'; -IO : 'IO'; -ION : 'ION'; -IS : 'IS'; -ITEMS : 'ITEMS'; -JSON : 'JSON'; -KEYS : 'KEYS'; -LAST : 'LAST'; -LIKE : 'LIKE'; -LIMIT : 'LIMIT'; -LINES : 'LINES'; -LOCATION : 'LOCATION'; -LOGICAL : 'LOGICAL'; -MAP : 'MAP'; -MATCHED : 'MATCHED'; -MERGE : 'MERGE'; -MSCK : 'MSCK'; -NO : 'NO'; -NOT : 'NOT'; -NULL_ : 'NULL'; -NULLS : 'NULLS'; -OFFSET : 'OFFSET'; -ON : 'ON'; -OPTIMIZE : 'OPTIMIZE'; -OR : 'OR'; -ORC : 'ORC'; -ORDER : 'ORDER'; -OUTPUTFORMAT : 'OUTPUTFORMAT'; -PARQUET : 'PARQUET'; -PARTITION : 'PARTITION'; -PARTITIONED : 'PARTITIONED'; -PARTITIONS : 'PARTITIONS'; -PREPARE : 'PREPARE'; -RCFILE : 'RCFILE'; -RENAME : 'RENAME'; -REPAIR : 'REPAIR'; -REPLACE : 'REPLACE'; -RESTRICT : 'RESTRICT'; -REWRITE : 'REWRITE'; -ROW : 'ROW'; -ROWS : 'ROWS'; -SCHEMA : 'SCHEMA'; -SCHEMAS : 'SCHEMAS'; -SELECT : 'SELECT'; -SEQUENCEFILE : 'SEQUENCEFILE'; -SERDE : 'SERDE'; -SERDEPROPERTIES : 'SERDEPROPERTIES'; -SET : 'SET'; -SHOW : 'SHOW'; -SMALLINT : 'SMALLINT'; -SOME : 'SOME'; -STORED : 'STORED'; -STRING : 'STRING'; -STRUCT : 'STRUCT'; -TABLE : 'TABLE'; -TABLES : 'TABLES'; -TBLPROPERTIES : 'TBLPROPERTIES'; -TERMINATED : 'TERMINATED'; -TEXT : 'TEXT'; -TEXTFILE : 'TEXTFILE'; -THEN : 'THEN'; -TIMESTAMP : 'TIMESTAMP'; -TINYINT : 'TINYINT'; -TO : 'TO'; -TRUE : 'TRUE'; -TYPE : 'TYPE'; -UNION : 'UNION'; -UNLOAD : 'UNLOAD'; -UPDATE : 'UPDATE'; -USING : 'USING'; -VACUUM : 'VACUUM'; -VALIDATE : 'VALIDATE'; -VALUES : 'VALUES'; -VARCHAR : 'VARCHAR'; -VIEW : 'VIEW'; -VIEWS : 'VIEWS'; -WHEN : 'WHEN'; -WHERE : 'WHERE'; -WITH : 'WITH'; - -EQ : '='; -SEMI : ';'; -LP : '('; -RP : ')'; -DOT : '.'; -COMMA : ','; -LT : '<'; -GT : '>'; -LE : '<='; -GE : '>='; -NE : '<>'; -BOX : '!='; -COLON : ':'; -QM : '?'; -STAR: '*'; -PLUS: '+'; -MINUS: '-'; -DIVIDE: '/'; -MODULE: '%'; - -fragment -Letter - : 'A'..'Z' - ; - -fragment -DIGIT - : '0'..'9' - ; - -fragment -DEC_DOT_DEC - : (DIGIT+ '.' DIGIT+ | DIGIT+ '.' | '.' DIGIT+) - ; - -IDENTIFIER - : Letter (Letter | DIGIT | '_')* - ; - -SQ_STRING_LITERAL - : '\'' ( ~('\''|'\\') | ('\\' .) )* '\'' - ; - -DQ_STRING_LITERAL - : '"' ( ~('"'|'\\') | ('\\' .) )* '"' - ; - -INTEGRAL_LITERAL - : DIGIT+ - ; - -FLOAT_LITERAL - : DEC_DOT_DEC - ; - -REAL_LITERAL - : (INTEGRAL_LITERAL | DEC_DOT_DEC) ('E' [+-]? DIGIT+) - ; - -WS - : (' '|'\r'|'\t'|'\n') -> channel(HIDDEN) - ; - -LINE_COMMENT - : '--' (~('\n'|'\r'))* -> channel(HIDDEN) - ; +options { + caseInsensitive = true; +} + +ADD : 'ADD'; +ALL : 'ALL'; +ALTER : 'ALTER'; +ANALYZE : 'ANALYZE'; +AND : 'AND'; +ANY : 'ANY'; +ARRAY : 'ARRAY'; +AS : 'AS'; +ASC : 'ASC'; +AVRO : 'AVRO'; +BETWEEN : 'BETWEEN'; +BIGINT : 'BIGINT'; +BIN_PACK : 'BIN_PACK'; +BINARY : 'BINARY'; +BOOLEAN : 'BOOLEAN'; +BUCKETS : 'BUCKETS'; +BY : 'BY'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CHAR : 'CHAR'; +CLUSTERED : 'CLUSTERED'; +COLLECTION : 'COLLECTION'; +COLUMNS : 'COLUMNS'; +COMMENT : 'COMMENT'; +CREATE : 'CREATE'; +DATA : 'DATA'; +DATABASE : 'DATABASE'; +DATABASES : 'DATABASES'; +DATE : 'DATE'; +DBPROPERTIES : 'DBPROPERTIES'; +DEALLOCATE : 'DEALLOCATE'; +DECIMAL : 'DECIMAL'; +DEFINED : 'DEFINED'; +DELETE : 'DELETE'; +DELIMITED : 'DELIMITED'; +DESC : 'DESC'; +DESCRIBE : 'DESCRIBE'; +DISTINCT : 'DISTINCT'; +DISTRIBUTED : 'DISTRIBUTED'; +DOUBLE : 'DOUBLE'; +DROP : 'DROP'; +ELSE : 'ELSE'; +END : 'END'; +ESCAPED : 'ESCAPED'; +EXCEPT : 'EXCEPT'; +EXECUTE : 'EXECUTE'; +EXISTS : 'EXISTS'; +EXPLAIN : 'EXPLAIN'; +EXTENDED : 'EXTENDED'; +EXTERNAL : 'EXTERNAL'; +FALSE : 'FALSE'; +FIELDS : 'FIELDS'; +FIRST : 'FIRST'; +FLOAT : 'FLOAT'; +FORMAT : 'FORMAT'; +FORMATTED : 'FORMATTED'; +FROM : 'FROM'; +GRAPHVIZ : 'GRAPHVIZ'; +GROUP : 'GROUP'; +HAVING : 'HAVING'; +IF : 'IF'; +IN : 'IN'; +INPUTFORMAT : 'INPUTFORMAT'; +INSERT : 'INSERT'; +INT : 'INT'; +INTEGER : 'INTEGER'; +INTERSECT : 'INTERSECT'; +INTO : 'INTO'; +IO : 'IO'; +ION : 'ION'; +IS : 'IS'; +ITEMS : 'ITEMS'; +JSON : 'JSON'; +KEYS : 'KEYS'; +LAST : 'LAST'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +LINES : 'LINES'; +LOCATION : 'LOCATION'; +LOGICAL : 'LOGICAL'; +MAP : 'MAP'; +MATCHED : 'MATCHED'; +MERGE : 'MERGE'; +MSCK : 'MSCK'; +NO : 'NO'; +NOT : 'NOT'; +NULL_ : 'NULL'; +NULLS : 'NULLS'; +OFFSET : 'OFFSET'; +ON : 'ON'; +OPTIMIZE : 'OPTIMIZE'; +OR : 'OR'; +ORC : 'ORC'; +ORDER : 'ORDER'; +OUTPUTFORMAT : 'OUTPUTFORMAT'; +PARQUET : 'PARQUET'; +PARTITION : 'PARTITION'; +PARTITIONED : 'PARTITIONED'; +PARTITIONS : 'PARTITIONS'; +PREPARE : 'PREPARE'; +RCFILE : 'RCFILE'; +RENAME : 'RENAME'; +REPAIR : 'REPAIR'; +REPLACE : 'REPLACE'; +RESTRICT : 'RESTRICT'; +REWRITE : 'REWRITE'; +ROW : 'ROW'; +ROWS : 'ROWS'; +SCHEMA : 'SCHEMA'; +SCHEMAS : 'SCHEMAS'; +SELECT : 'SELECT'; +SEQUENCEFILE : 'SEQUENCEFILE'; +SERDE : 'SERDE'; +SERDEPROPERTIES : 'SERDEPROPERTIES'; +SET : 'SET'; +SHOW : 'SHOW'; +SMALLINT : 'SMALLINT'; +SOME : 'SOME'; +STORED : 'STORED'; +STRING : 'STRING'; +STRUCT : 'STRUCT'; +TABLE : 'TABLE'; +TABLES : 'TABLES'; +TBLPROPERTIES : 'TBLPROPERTIES'; +TERMINATED : 'TERMINATED'; +TEXT : 'TEXT'; +TEXTFILE : 'TEXTFILE'; +THEN : 'THEN'; +TIMESTAMP : 'TIMESTAMP'; +TINYINT : 'TINYINT'; +TO : 'TO'; +TRUE : 'TRUE'; +TYPE : 'TYPE'; +UNION : 'UNION'; +UNLOAD : 'UNLOAD'; +UPDATE : 'UPDATE'; +USING : 'USING'; +VACUUM : 'VACUUM'; +VALIDATE : 'VALIDATE'; +VALUES : 'VALUES'; +VARCHAR : 'VARCHAR'; +VIEW : 'VIEW'; +VIEWS : 'VIEWS'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WITH : 'WITH'; + +EQ : '='; +SEMI : ';'; +LP : '('; +RP : ')'; +DOT : '.'; +COMMA : ','; +LT : '<'; +GT : '>'; +LE : '<='; +GE : '>='; +NE : '<>'; +BOX : '!='; +COLON : ':'; +QM : '?'; +STAR : '*'; +PLUS : '+'; +MINUS : '-'; +DIVIDE : '/'; +MODULE : '%'; + +fragment Letter: 'A' ..'Z'; + +fragment DIGIT: '0' ..'9'; + +fragment DEC_DOT_DEC: (DIGIT+ '.' DIGIT+ | DIGIT+ '.' | '.' DIGIT+); + +IDENTIFIER: Letter (Letter | DIGIT | '_')*; + +SQ_STRING_LITERAL: '\'' ( ~('\'' | '\\') | ('\\' .))* '\''; + +DQ_STRING_LITERAL: '"' ( ~('"' | '\\') | ('\\' .))* '"'; + +INTEGRAL_LITERAL: DIGIT+; + +FLOAT_LITERAL: DEC_DOT_DEC; + +REAL_LITERAL: (INTEGRAL_LITERAL | DEC_DOT_DEC) ('E' [+-]? DIGIT+); + +WS: (' ' | '\r' | '\t' | '\n') -> channel(HIDDEN); + +LINE_COMMENT: '--' (~('\n' | '\r'))* -> channel(HIDDEN); \ No newline at end of file diff --git a/sql/athena/AthenaParser.g4 b/sql/athena/AthenaParser.g4 index 72b80de9de..fe82fd7fdb 100644 --- a/sql/athena/AthenaParser.g4 +++ b/sql/athena/AthenaParser.g4 @@ -21,9 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 AthenaParser; -options { tokenVocab=AthenaLexer; } +options { + tokenVocab = AthenaLexer; +} stmt : command SEMI? EOF @@ -82,20 +87,15 @@ dml_command DML */ select - : (WITH with_query (',' with_query)*)? - select_statement + : (WITH with_query (',' with_query)*)? select_statement ; select_statement - : SELECT all_distinct? select_list - (FROM from_item (',' from_item)*)? - (WHERE condition)? - (GROUP BY all_distinct? grouping_element (','grouping_element)*)? - (HAVING condition)? - ((UNION | INTERSECT | EXCEPT) all_distinct? select_statement)? - (ORDER BY order_item (',' order_item)*)? - (OFFSET count (ROW | ROWS)?)? - (LIMIT (count | ALL))? + : SELECT all_distinct? select_list (FROM from_item (',' from_item)*)? (WHERE condition)? ( + GROUP BY all_distinct? grouping_element (',' grouping_element)* + )? (HAVING condition)? ((UNION | INTERSECT | EXCEPT) all_distinct? select_statement)? ( + ORDER BY order_item (',' order_item)* + )? (OFFSET count (ROW | ROWS)?)? (LIMIT (count | ALL))? ; all_distinct @@ -104,7 +104,7 @@ all_distinct ; order_item - : expression (ASC|DESC)? (NULLS (FIRST|LAST))? + : expression (ASC | DESC)? (NULLS (FIRST | LAST))? ; from_item @@ -128,10 +128,10 @@ condition ; insert_into - : INSERT INTO destination_table ('(' column_list ')')? - ( select_statement + : INSERT INTO destination_table ('(' column_list ')')? ( + select_statement | VALUES value_list (',' value_list)* - ) + ) ; value_list @@ -144,24 +144,21 @@ select_list select_item : expression (AS? alias)? - | (table_name '.')?'*' + | (table_name '.')? '*' ; delete_stmt - : DELETE FROM (db_name'.')? table_name (WHERE predicate)? + : DELETE FROM (db_name '.')? table_name (WHERE predicate)? ; update - : UPDATE (db_name'.')? table_name - SET col_name '=' expression (',' col_name '=' expression)* - (WHERE predicate)? + : UPDATE (db_name '.')? table_name SET col_name '=' expression (',' col_name '=' expression)* ( + WHERE predicate + )? ; merge_into - : MERGE INTO target_table (AS? target_alias)? - USING (source_table | query) (AS? source_alias)? - ON search_condition - when_clauses + : MERGE INTO target_table (AS? target_alias)? USING (source_table | query) (AS? source_alias)? ON search_condition when_clauses ; search_condition @@ -253,9 +250,7 @@ deallocate ; unload - : UNLOAD '(' select ')' - TO string - WITH '(' property_list ')' + : UNLOAD '(' select ')' TO string WITH '(' property_list ')' ; property_list @@ -288,8 +283,9 @@ kv_pair ; alter_table_add_cols - : ALTER TABLE table_name (PARTITION '(' part_col_name_value (',' part_col_name_value)* ')')? - ADD COLUMNS (col_name data_type) + : ALTER TABLE table_name (PARTITION '(' part_col_name_value (',' part_col_name_value)* ')')? ADD COLUMNS ( + col_name data_type + ) ; part_col_name_value @@ -305,12 +301,15 @@ partition_col_value ; alter_table_add_part - : ALTER TABLE table_name ADD if_not_exists? - (PARTITION '(' part_col_name_value (',' part_col_name_value)* ')' (LOCATION string)?)+ + : ALTER TABLE table_name ADD if_not_exists? ( + PARTITION '(' part_col_name_value (',' part_col_name_value)* ')' (LOCATION string)? + )+ ; alter_table_drop_part - : ALTER TABLE table_name DROP if_exists? PARTITION '('partition_spec')' (',' PARTITION '('partition_spec')')* + : ALTER TABLE table_name DROP if_exists? PARTITION '(' partition_spec ')' ( + ',' PARTITION '(' partition_spec ')' + )* ; partition_spec @@ -318,17 +317,17 @@ partition_spec ; alter_table_rename_part - : ALTER TABLE table_name PARTITION (partition_spec) RENAME TO PARTITION (np=partition_spec) + : ALTER TABLE table_name PARTITION (partition_spec) RENAME TO PARTITION (np = partition_spec) ; alter_table_replace_part - : ALTER TABLE table_name - (PARTITION '('part_col_name_value (',' part_col_name_value)* ')')? - REPLACE COLUMNS '('col_name data_type (',' col_name data_type)* ')' + : ALTER TABLE table_name (PARTITION '(' part_col_name_value (',' part_col_name_value)* ')')? REPLACE COLUMNS '(' col_name data_type ( + ',' col_name data_type + )* ')' ; alter_table_set_location - : ALTER TABLE table_name (PARTITION '('partition_spec')')? SET LOCATION string + : ALTER TABLE table_name (PARTITION '(' partition_spec ')')? SET LOCATION string ; alter_table_set_props @@ -336,22 +335,19 @@ alter_table_set_props ; create_database - : CREATE db_schema if_not_exists? database_name - (COMMENT string)? - (LOCATION string)? - (WITH DBPROPERTIES '(' kv_pair (',' kv_pair)* ')')? + : CREATE db_schema if_not_exists? database_name (COMMENT string)? (LOCATION string)? ( + WITH DBPROPERTIES '(' kv_pair (',' kv_pair)* ')' + )? ; create_table - : CREATE EXTERNAL TABLE if_not_exists? - (db_name'.')? table_name ('(' col_def_with_comment (',' col_def_with_comment)* ')')? - (COMMENT table_comment)? - (PARTITIONED BY '('col_def_with_comment (',' col_def_with_comment)* ')')? - (CLUSTERED BY '(' col_name (',' col_name)* ')' INTO num_buckets BUCKETS)? - (ROW FORMAT row_format)? - (STORED AS file_format)? - LOCATION string - (TBLPROPERTIES '(' property_list ')')? + : CREATE EXTERNAL TABLE if_not_exists? (db_name '.')? table_name ( + '(' col_def_with_comment (',' col_def_with_comment)* ')' + )? (COMMENT table_comment)? ( + PARTITIONED BY '(' col_def_with_comment (',' col_def_with_comment)* ')' + )? (CLUSTERED BY '(' col_name (',' col_name)* ')' INTO num_buckets BUCKETS)? ( + ROW FORMAT row_format + )? (STORED AS file_format)? LOCATION string (TBLPROPERTIES '(' property_list ')')? ; table_comment @@ -359,8 +355,8 @@ table_comment ; row_format - : DELIMITED table_row_format_field_identifier? table_row_format_coll_items_identifier? - table_row_format_map_keys_identifier? table_row_format_lines_identifier? table_row_null_format? + : DELIMITED table_row_format_field_identifier? table_row_format_coll_items_identifier? table_row_format_map_keys_identifier? + table_row_format_lines_identifier? table_row_null_format? | SERDE string (WITH SERDEPROPERTIES '(' property_list ')')? ; @@ -408,10 +404,7 @@ col_comment ; create_table_as - : CREATE TABLE table_name - ( WITH '(' prop_exp (',' prop_exp)* ')')? - AS query - (WITH NO? DATA)? + : CREATE TABLE table_name (WITH '(' prop_exp (',' prop_exp)* ')')? AS query (WITH NO? DATA)? ; property_name @@ -428,7 +421,7 @@ create_view describe : DESCRIBE (EXTENDED | FORMATTED)? (db_name '.')? table_name (PARTITION partition_spec)? - //(col_name ( [.field_name] | [.'$elem$'] | [.'$key$'] | [.'$value$'] ) )? //TODO - poor documentation vs actual functionality + //(col_name ( [.field_name] | [.'$elem$'] | [.'$key$'] | [.'$value$'] ) )? //TODO - poor documentation vs actual functionality ; field_name @@ -519,7 +512,13 @@ table_subquery ; comparison_operator - : '<' | '=' | '>' | '<=' | '>=' | '<>' | '!=' + : '<' + | '=' + | '>' + | '<=' + | '>=' + | '<>' + | '!=' ; expression @@ -529,28 +528,21 @@ expression | id_ '(' expression_list_ ')' | case_expression | when_expression - | op=(PLUS | MINUS) expression - | expression op=(STAR | DIVIDE | MODULE) expression - | expression op=(PLUS | MINUS) expression + | op = (PLUS | MINUS) expression + | expression op = (STAR | DIVIDE | MODULE) expression + | expression op = (PLUS | MINUS) expression | expression DOT expression | CAST '(' expression AS data_type ')' ; case_expression - : CASE expression - (WHEN expression THEN expression)+ - (ELSE expression)? - END + : CASE expression (WHEN expression THEN expression)+ (ELSE expression)? END ; when_expression - : CASE - (WHEN expression THEN expression)+ - (ELSE expression)? - END + : CASE (WHEN expression THEN expression)+ (ELSE expression)? END ; - primitive_expression : literal | id_ @@ -677,4 +669,4 @@ or_replace from_in : FROM | IN - ; + ; \ No newline at end of file diff --git a/sql/derby/DerbyLexer.g4 b/sql/derby/DerbyLexer.g4 index 338f03efe0..ef8bdfe26d 100644 --- a/sql/derby/DerbyLexer.g4 +++ b/sql/derby/DerbyLexer.g4 @@ -21,410 +21,411 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -lexer grammar DerbyLexer; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -options { caseInsensitive = true; } +lexer grammar DerbyLexer; -ABS: 'ABS'; -ABSVAL: 'ABSVAL'; -ACOS: 'ACOS'; -ACTION: 'ACTION'; -ADD: 'ADD'; -AGGREGATE: 'AGGREGATE'; -ALL: 'ALL'; -ALLOCATE: 'ALLOCATE'; -ALTER: 'ALTER'; -ALWAYS: 'ALWAYS'; -AND: 'AND'; -ANY: 'ANY'; -ARE: 'ARE'; -AS: 'AS'; -ASC: 'ASC'; -ASIN: 'ASIN'; -ASSERTION: 'ASSERTION'; -AT: 'AT'; -ATAN2: 'ATAN2'; -ATAN: 'ATAN'; -AUTHORIZATION: 'AUTHORIZATION'; -AVG: 'AVG'; -BEGIN: 'BEGIN'; -BETWEEN: 'BETWEEN'; -BIGINT: 'BIGINT'; -BINARY: 'BINARY'; -BIT: 'BIT'; -BLOB: 'BLOB'; -BOOLEAN: 'BOOLEAN'; -BOTH: 'BOTH'; -BY: 'BY'; -CALL: 'CALL'; -CALLED: 'CALLED'; -CASCADE: 'CASCADE'; -CASCADED: 'CASCADED'; -CASE: 'CASE'; -CAST: 'CAST'; -CEIL: 'CEIL'; -CEILING: 'CEILING'; -CHAR: 'CHAR'; -CHARACTER: 'CHARACTER'; -CHARACTER_LENGTH: 'CHARACTER_LENGTH'; -CHECK: 'CHECK'; -CLOB: 'CLOB'; -CLOSE: 'CLOSE'; -COALESCE: 'COALESCE'; -COLLATE: 'COLLATE'; -COLLATION: 'COLLATION'; -COLUMN: 'COLUMN'; -COMMIT: 'COMMIT'; -COMMITTED: 'COMMITTED'; -CONNECT: 'CONNECT'; -CONNECTION: 'CONNECTION'; -CONSTRAINT: 'CONSTRAINT'; -CONSTRAINTS: 'CONSTRAINTS'; -CONTAINS: 'CONTAINS'; -CONTINUE: 'CONTINUE'; -CONVERT: 'CONVERT'; -CORRESPONDING: 'CORRESPONDING'; -COS: 'COS'; -COUNT: 'COUNT'; -CREATE: 'CREATE'; -CROSS: 'CROSS'; -CS: 'CS'; -CURRENT: 'CURRENT'; -CURRENT_DATE: 'CURRENT_DATE'; -CURRENT_ROLE: 'CURRENT_ROLE'; -CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -CURRENT_USER: 'CURRENT_USER'; -CURSOR: 'CURSOR'; -CYCLE: 'CYCLE'; -DATA: 'DATA'; -DATE: 'DATE'; -DAY: 'DAY'; -DEALLOCATE: 'DEALLOCATE'; -DEC: 'DEC'; -DECIMAL: 'DECIMAL'; -DECLARE: 'DECLARE'; -DEFAULT: 'DEFAULT'; -DEFERRABLE: 'DEFERRABLE'; -DEFERRED: 'DEFERRED'; -DEFINER: 'DEFINER'; -DEGREES: 'DEGREES'; -DELETE: 'DELETE'; -DERBY: 'DERBY'; -DERBY_JDBC_RESULT_SET: 'DERBY_JDBC_RESULT_SET'; -DESC: 'DESC'; -DESCRIBE: 'DESCRIBE'; -DETERMINISTIC: 'DETERMINISTIC'; -DIAGNOSTICS: 'DIAGNOSTICS'; -DIRTY: 'DIRTY'; -DISCONNECT: 'DISCONNECT'; -DISTINCT: 'DISTINCT'; -DOUBLE: 'DOUBLE'; -DROP: 'DROP'; -DYNAMIC: 'DYNAMIC'; -ELSE: 'ELSE'; -END: 'END'; -END_EXEC: 'END_EXEC'; -ESCAPE: 'ESCAPE'; -EXCEPT: 'EXCEPT'; -EXCEPTION: 'EXCEPTION'; -EXCLUSIVE: 'EXCLUSIVE'; -EXEC: 'EXEC'; -EXECUTE: 'EXEC' 'UTE'?; -EXISTS: 'EXISTS'; -EXP: 'EXP'; -EXPLAIN: 'EXPLAIN'; -EXTERNAL: 'EXTERNAL'; -FALSE: 'FALSE'; -FETCH: 'FETCH'; -FIRST: 'FIRST'; -FLOAT: 'FLOAT'; -FLOOR: 'FLOOR'; -FOR: 'FOR'; -FOREIGN: 'FOREIGN'; -FOUND: 'FOUND'; -FROM: 'FROM'; -FULL: 'FULL'; -FUNCTION: 'FUNCTION'; -GENERATED: 'GENERATED'; -GET: 'GET'; -GETCURRENTCONNECTION: 'GETCURRENTCONNECTION'; -GIGA: 'G'; -GLOBAL: 'GLOBAL'; -GO: 'GO'; -GOTO: 'GOTO'; -GRANT: 'GRANT'; -GROUP: 'GROUP'; -HAVING: 'HAVING'; -HOUR: 'HOUR'; -IDENTITY: 'IDENTITY'; -IDENTITY_VAL_LOCAL: 'IDENTITY_VAL_LOCAL'; -IMMEDIATE: 'IMMEDIATE'; -IN: 'IN'; -INCREMENT: 'INCREMENT'; -INDEX: 'INDEX'; -INDICATOR: 'INDICATOR'; -INITIALLY: 'INITIALLY'; -INNER: 'INNER'; -INOUT: 'INOUT'; -INPUT: 'INPUT'; -INSENSITIVE: 'INSENSITIVE'; -INSERT: 'INSERT'; -INT: 'INT'; -INTEGER: 'INTEGER'; -INTERSECT: 'INTERSECT'; -INTO: 'INTO'; -INVOKER: 'INVOKER'; -IS: 'IS'; -ISOLATION: 'ISOLATION'; -JAVA: 'JAVA'; -JOIN: 'JOIN'; -KEY: 'KEY'; -KILO: 'K'; -LANGUAGE: 'LANGUAGE'; -LARGE: 'LARGE'; -LAST: 'LAST'; -LCASE: 'LCASE'; -LEADING: 'LEADING'; -LEFT: 'LEFT'; -LENGTH: 'LENGTH'; -LIKE: 'LIKE'; -LN: 'LN'; -LOCATE: 'LOCATE'; -LOCK: 'LOCK'; -LOCKSIZE: 'LOCKSIZE'; -LOG10: 'LOG10'; -LOG: 'LOG'; -LOGGED: 'LOGGED'; -LONG: 'LONG'; -LOWER: 'LOWER'; -LTRIM: 'LTRIM'; -MATCH: 'MATCH'; -MATCHED: 'MATCHED'; -MAX: 'MAX'; -MAXVALUE: 'MAXVALUE'; -MEGA: 'M'; -MERGE: 'MERGE'; -MIN: 'MIN'; -MINUTE: 'MINUTE'; -MINVALUE: 'MINVALUE'; -MOD: 'MOD'; -MODE: 'MODE'; -MODIFIES: 'MODIFIES'; -MONTH: 'MONTH'; -NAME: 'NAME'; -NATIONAL: 'NATIONAL'; -NATURAL: 'NATURAL'; -NCHAR: 'NCHAR'; -NEXT: 'NEXT'; -NO: 'NO'; -NONE: 'NONE'; -NOT: 'NOT'; -NULL_: 'NULL'; -NULLIF: 'NULLIF'; -NULLS: 'NULLS'; -NUMERIC: 'NUMERIC'; -NVARCHAR: 'NVARCHAR'; -OBJECT: 'OBJECT'; -OF: 'OF'; -OFFSET: 'OFFSET'; -ON: 'ON'; -ONLY: 'ONLY'; -OPEN: 'OPEN'; -OPTION: 'OPTION'; -OR: 'OR'; -ORDER: 'ORDER'; -OUT: 'OUT'; -OUTER: 'OUTER'; -OUTPUT: 'OUTPUT'; -OVERLAPS: 'OVERLAPS'; -PAD: 'PAD'; -PARAMETER: 'PARAMETER'; -PARTIAL: 'PARTIAL'; -PI: 'PI'; -PRECISION: 'PRECISION'; -PREPARE: 'PREPARE'; -PRESERVE: 'PRESERVE'; -PRIMARY: 'PRIMARY'; -PRIOR: 'PRIOR'; -PRIVILEGES: 'PRIVILEGES'; -PROCEDURE: 'PROCEDURE'; -PUBLIC: 'PUBLIC'; -RADIANS: 'RADIANS'; -READ: 'READ'; -READS: 'READS'; -REAL: 'REAL'; -REFERENCES: 'REFERENCES'; -RELATIVE: 'RELATIVE'; -RENAME: 'RENAME'; -REPEATABLE: 'REPEATABLE'; -RESET: 'RESET'; -RESTART: 'RESTART'; -RESTRICT: 'RESTRICT'; -RESULT: 'RESULT'; -RETURNS: 'RETURNS'; -REVOKE: 'REVOKE'; -RIGHT: 'RIGHT'; -ROLE: 'ROLE'; -ROLLBACK: 'ROLLBACK'; -ROLLUP: 'ROLLUP'; -ROW: 'ROW'; -ROWS: 'ROWS'; -RR: 'RR'; -RS: 'RS'; -RTRIM: 'RTRIM'; -SCHEMA: 'SCHEMA'; -SCROLL: 'SCROLL'; -SECOND: 'SECOND'; -SECURITY: 'SECURITY'; -SELECT: 'SELECT'; -SEQUENCE: 'SEQUENCE'; -SERIALIZABLE: 'SERIALIZABLE'; -SESSION_USER: 'SESSION_USER'; -SET: 'SET'; -SETS: 'SETS'; -SHARE: 'SHARE'; -SIN: 'SIN'; -SMALLINT: 'SMALLINT'; -SOME: 'SOME'; -SPACE: 'SPACE'; -SQL: 'SQL'; -SQLCODE: 'SQLCODE'; -SQLERROR: 'SQLERROR'; -SQLID: 'SQLID'; -SQLSTATE: 'SQLSTATE'; -SQRT: 'SQRT'; -STABILITY: 'STABILITY'; -START: 'START'; -STDDEV_POP: 'STDDEV_POP'; -STDDEV_SAMP: 'STDDEV_SAMP'; -STYLE: 'STYLE'; -SUBSTR: 'SUBSTR'; -SUBSTRING: 'SUBSTRING'; -SUM: 'SUM'; -SYNONYM: 'SYNONYM'; -SYSTEM_USER: 'SYSTEM_USER'; -TABLE: 'TABLE'; -TAN: 'TAN'; -TEMPORARY: 'TEMPORARY'; -THEN: 'THEN'; -TIME: 'TIME'; -TIMESTAMP: 'TIMESTAMP'; -TIMEZONE_HOUR: 'TIMEZONE_HOUR'; -TIMEZONE_MINUTE: 'TIMEZONE_MINUTE'; -TO: 'TO'; -TRANSACTION: 'TRANSACTION'; -TRANSLATE: 'TRANSLATE'; -TRANSLATION: 'TRANSLATION'; -TRIGGER: 'TRIGGER'; -TRIM: 'TRIM'; -TRUE: 'TRUE'; -TRUNCATE: 'TRUNCATE'; -TYPE: 'TYPE'; -UCASE: 'UCASE'; -UNCOMMITTED: 'UNCOMMITTED'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; -UNKNOWN: 'UNKNOWN'; -UPDATE: 'UPDATE'; -UPPER: 'UPPER'; -UR: 'UR'; -USAGE: 'USAGE'; -USER: 'USER'; -USING: 'USING'; -VALUES: 'VALUES'; -VAR_POP: 'VAR_POP'; -VAR_SAMP: 'VAR_SAMP'; -VARCHAR: 'VARCHAR'; -VARYING: 'VARYING'; -VIEW: 'VIEW'; -WHEN: 'WHEN'; -WHENEVER: 'WHENEVER'; -WHERE: 'WHERE'; -WINDOW: 'WINDOW'; -WITH: 'WITH'; -WORK: 'WORK'; -WRITE: 'WRITE'; -XML: 'XML'; -XMLEXISTS: 'XMLEXISTS'; -XMLPARSE: 'XMLPARSE'; -XMLQUERY: 'XMLQUERY'; -XMLSERIALIZE: 'XMLSERIALIZE'; -YEAR: 'YEAR'; +options { + caseInsensitive = true; +} +ABS : 'ABS'; +ABSVAL : 'ABSVAL'; +ACOS : 'ACOS'; +ACTION : 'ACTION'; +ADD : 'ADD'; +AGGREGATE : 'AGGREGATE'; +ALL : 'ALL'; +ALLOCATE : 'ALLOCATE'; +ALTER : 'ALTER'; +ALWAYS : 'ALWAYS'; +AND : 'AND'; +ANY : 'ANY'; +ARE : 'ARE'; +AS : 'AS'; +ASC : 'ASC'; +ASIN : 'ASIN'; +ASSERTION : 'ASSERTION'; +AT : 'AT'; +ATAN2 : 'ATAN2'; +ATAN : 'ATAN'; +AUTHORIZATION : 'AUTHORIZATION'; +AVG : 'AVG'; +BEGIN : 'BEGIN'; +BETWEEN : 'BETWEEN'; +BIGINT : 'BIGINT'; +BINARY : 'BINARY'; +BIT : 'BIT'; +BLOB : 'BLOB'; +BOOLEAN : 'BOOLEAN'; +BOTH : 'BOTH'; +BY : 'BY'; +CALL : 'CALL'; +CALLED : 'CALLED'; +CASCADE : 'CASCADE'; +CASCADED : 'CASCADED'; +CASE : 'CASE'; +CAST : 'CAST'; +CEIL : 'CEIL'; +CEILING : 'CEILING'; +CHAR : 'CHAR'; +CHARACTER : 'CHARACTER'; +CHARACTER_LENGTH : 'CHARACTER_LENGTH'; +CHECK : 'CHECK'; +CLOB : 'CLOB'; +CLOSE : 'CLOSE'; +COALESCE : 'COALESCE'; +COLLATE : 'COLLATE'; +COLLATION : 'COLLATION'; +COLUMN : 'COLUMN'; +COMMIT : 'COMMIT'; +COMMITTED : 'COMMITTED'; +CONNECT : 'CONNECT'; +CONNECTION : 'CONNECTION'; +CONSTRAINT : 'CONSTRAINT'; +CONSTRAINTS : 'CONSTRAINTS'; +CONTAINS : 'CONTAINS'; +CONTINUE : 'CONTINUE'; +CONVERT : 'CONVERT'; +CORRESPONDING : 'CORRESPONDING'; +COS : 'COS'; +COUNT : 'COUNT'; +CREATE : 'CREATE'; +CROSS : 'CROSS'; +CS : 'CS'; +CURRENT : 'CURRENT'; +CURRENT_DATE : 'CURRENT_DATE'; +CURRENT_ROLE : 'CURRENT_ROLE'; +CURRENT_TIME : 'CURRENT_TIME'; +CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +CURRENT_USER : 'CURRENT_USER'; +CURSOR : 'CURSOR'; +CYCLE : 'CYCLE'; +DATA : 'DATA'; +DATE : 'DATE'; +DAY : 'DAY'; +DEALLOCATE : 'DEALLOCATE'; +DEC : 'DEC'; +DECIMAL : 'DECIMAL'; +DECLARE : 'DECLARE'; +DEFAULT : 'DEFAULT'; +DEFERRABLE : 'DEFERRABLE'; +DEFERRED : 'DEFERRED'; +DEFINER : 'DEFINER'; +DEGREES : 'DEGREES'; +DELETE : 'DELETE'; +DERBY : 'DERBY'; +DERBY_JDBC_RESULT_SET : 'DERBY_JDBC_RESULT_SET'; +DESC : 'DESC'; +DESCRIBE : 'DESCRIBE'; +DETERMINISTIC : 'DETERMINISTIC'; +DIAGNOSTICS : 'DIAGNOSTICS'; +DIRTY : 'DIRTY'; +DISCONNECT : 'DISCONNECT'; +DISTINCT : 'DISTINCT'; +DOUBLE : 'DOUBLE'; +DROP : 'DROP'; +DYNAMIC : 'DYNAMIC'; +ELSE : 'ELSE'; +END : 'END'; +END_EXEC : 'END_EXEC'; +ESCAPE : 'ESCAPE'; +EXCEPT : 'EXCEPT'; +EXCEPTION : 'EXCEPTION'; +EXCLUSIVE : 'EXCLUSIVE'; +EXEC : 'EXEC'; +EXECUTE : 'EXEC' 'UTE'?; +EXISTS : 'EXISTS'; +EXP : 'EXP'; +EXPLAIN : 'EXPLAIN'; +EXTERNAL : 'EXTERNAL'; +FALSE : 'FALSE'; +FETCH : 'FETCH'; +FIRST : 'FIRST'; +FLOAT : 'FLOAT'; +FLOOR : 'FLOOR'; +FOR : 'FOR'; +FOREIGN : 'FOREIGN'; +FOUND : 'FOUND'; +FROM : 'FROM'; +FULL : 'FULL'; +FUNCTION : 'FUNCTION'; +GENERATED : 'GENERATED'; +GET : 'GET'; +GETCURRENTCONNECTION : 'GETCURRENTCONNECTION'; +GIGA : 'G'; +GLOBAL : 'GLOBAL'; +GO : 'GO'; +GOTO : 'GOTO'; +GRANT : 'GRANT'; +GROUP : 'GROUP'; +HAVING : 'HAVING'; +HOUR : 'HOUR'; +IDENTITY : 'IDENTITY'; +IDENTITY_VAL_LOCAL : 'IDENTITY_VAL_LOCAL'; +IMMEDIATE : 'IMMEDIATE'; +IN : 'IN'; +INCREMENT : 'INCREMENT'; +INDEX : 'INDEX'; +INDICATOR : 'INDICATOR'; +INITIALLY : 'INITIALLY'; +INNER : 'INNER'; +INOUT : 'INOUT'; +INPUT : 'INPUT'; +INSENSITIVE : 'INSENSITIVE'; +INSERT : 'INSERT'; +INT : 'INT'; +INTEGER : 'INTEGER'; +INTERSECT : 'INTERSECT'; +INTO : 'INTO'; +INVOKER : 'INVOKER'; +IS : 'IS'; +ISOLATION : 'ISOLATION'; +JAVA : 'JAVA'; +JOIN : 'JOIN'; +KEY : 'KEY'; +KILO : 'K'; +LANGUAGE : 'LANGUAGE'; +LARGE : 'LARGE'; +LAST : 'LAST'; +LCASE : 'LCASE'; +LEADING : 'LEADING'; +LEFT : 'LEFT'; +LENGTH : 'LENGTH'; +LIKE : 'LIKE'; +LN : 'LN'; +LOCATE : 'LOCATE'; +LOCK : 'LOCK'; +LOCKSIZE : 'LOCKSIZE'; +LOG10 : 'LOG10'; +LOG : 'LOG'; +LOGGED : 'LOGGED'; +LONG : 'LONG'; +LOWER : 'LOWER'; +LTRIM : 'LTRIM'; +MATCH : 'MATCH'; +MATCHED : 'MATCHED'; +MAX : 'MAX'; +MAXVALUE : 'MAXVALUE'; +MEGA : 'M'; +MERGE : 'MERGE'; +MIN : 'MIN'; +MINUTE : 'MINUTE'; +MINVALUE : 'MINVALUE'; +MOD : 'MOD'; +MODE : 'MODE'; +MODIFIES : 'MODIFIES'; +MONTH : 'MONTH'; +NAME : 'NAME'; +NATIONAL : 'NATIONAL'; +NATURAL : 'NATURAL'; +NCHAR : 'NCHAR'; +NEXT : 'NEXT'; +NO : 'NO'; +NONE : 'NONE'; +NOT : 'NOT'; +NULL_ : 'NULL'; +NULLIF : 'NULLIF'; +NULLS : 'NULLS'; +NUMERIC : 'NUMERIC'; +NVARCHAR : 'NVARCHAR'; +OBJECT : 'OBJECT'; +OF : 'OF'; +OFFSET : 'OFFSET'; +ON : 'ON'; +ONLY : 'ONLY'; +OPEN : 'OPEN'; +OPTION : 'OPTION'; +OR : 'OR'; +ORDER : 'ORDER'; +OUT : 'OUT'; +OUTER : 'OUTER'; +OUTPUT : 'OUTPUT'; +OVERLAPS : 'OVERLAPS'; +PAD : 'PAD'; +PARAMETER : 'PARAMETER'; +PARTIAL : 'PARTIAL'; +PI : 'PI'; +PRECISION : 'PRECISION'; +PREPARE : 'PREPARE'; +PRESERVE : 'PRESERVE'; +PRIMARY : 'PRIMARY'; +PRIOR : 'PRIOR'; +PRIVILEGES : 'PRIVILEGES'; +PROCEDURE : 'PROCEDURE'; +PUBLIC : 'PUBLIC'; +RADIANS : 'RADIANS'; +READ : 'READ'; +READS : 'READS'; +REAL : 'REAL'; +REFERENCES : 'REFERENCES'; +RELATIVE : 'RELATIVE'; +RENAME : 'RENAME'; +REPEATABLE : 'REPEATABLE'; +RESET : 'RESET'; +RESTART : 'RESTART'; +RESTRICT : 'RESTRICT'; +RESULT : 'RESULT'; +RETURNS : 'RETURNS'; +REVOKE : 'REVOKE'; +RIGHT : 'RIGHT'; +ROLE : 'ROLE'; +ROLLBACK : 'ROLLBACK'; +ROLLUP : 'ROLLUP'; +ROW : 'ROW'; +ROWS : 'ROWS'; +RR : 'RR'; +RS : 'RS'; +RTRIM : 'RTRIM'; +SCHEMA : 'SCHEMA'; +SCROLL : 'SCROLL'; +SECOND : 'SECOND'; +SECURITY : 'SECURITY'; +SELECT : 'SELECT'; +SEQUENCE : 'SEQUENCE'; +SERIALIZABLE : 'SERIALIZABLE'; +SESSION_USER : 'SESSION_USER'; +SET : 'SET'; +SETS : 'SETS'; +SHARE : 'SHARE'; +SIN : 'SIN'; +SMALLINT : 'SMALLINT'; +SOME : 'SOME'; +SPACE : 'SPACE'; +SQL : 'SQL'; +SQLCODE : 'SQLCODE'; +SQLERROR : 'SQLERROR'; +SQLID : 'SQLID'; +SQLSTATE : 'SQLSTATE'; +SQRT : 'SQRT'; +STABILITY : 'STABILITY'; +START : 'START'; +STDDEV_POP : 'STDDEV_POP'; +STDDEV_SAMP : 'STDDEV_SAMP'; +STYLE : 'STYLE'; +SUBSTR : 'SUBSTR'; +SUBSTRING : 'SUBSTRING'; +SUM : 'SUM'; +SYNONYM : 'SYNONYM'; +SYSTEM_USER : 'SYSTEM_USER'; +TABLE : 'TABLE'; +TAN : 'TAN'; +TEMPORARY : 'TEMPORARY'; +THEN : 'THEN'; +TIME : 'TIME'; +TIMESTAMP : 'TIMESTAMP'; +TIMEZONE_HOUR : 'TIMEZONE_HOUR'; +TIMEZONE_MINUTE : 'TIMEZONE_MINUTE'; +TO : 'TO'; +TRANSACTION : 'TRANSACTION'; +TRANSLATE : 'TRANSLATE'; +TRANSLATION : 'TRANSLATION'; +TRIGGER : 'TRIGGER'; +TRIM : 'TRIM'; +TRUE : 'TRUE'; +TRUNCATE : 'TRUNCATE'; +TYPE : 'TYPE'; +UCASE : 'UCASE'; +UNCOMMITTED : 'UNCOMMITTED'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; +UNKNOWN : 'UNKNOWN'; +UPDATE : 'UPDATE'; +UPPER : 'UPPER'; +UR : 'UR'; +USAGE : 'USAGE'; +USER : 'USER'; +USING : 'USING'; +VALUES : 'VALUES'; +VAR_POP : 'VAR_POP'; +VAR_SAMP : 'VAR_SAMP'; +VARCHAR : 'VARCHAR'; +VARYING : 'VARYING'; +VIEW : 'VIEW'; +WHEN : 'WHEN'; +WHENEVER : 'WHENEVER'; +WHERE : 'WHERE'; +WINDOW : 'WINDOW'; +WITH : 'WITH'; +WORK : 'WORK'; +WRITE : 'WRITE'; +XML : 'XML'; +XMLEXISTS : 'XMLEXISTS'; +XMLPARSE : 'XMLPARSE'; +XMLQUERY : 'XMLQUERY'; +XMLSERIALIZE : 'XMLSERIALIZE'; +YEAR : 'YEAR'; -WHITE_SPACE: [ \t\r\n]+ -> skip; +WHITE_SPACE: [ \t\r\n]+ -> skip; -SQL_COMMENT: '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); -LINE_COMMENT: '--' ~[\r\n]* -> channel(HIDDEN); +SQL_COMMENT : '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); // TODO: ID can be not only Latin. -DOUBLE_QUOTE_ID: '"' ~'"'+ '"'; -SINGLE_QUOTE: '\''; +DOUBLE_QUOTE_ID : '"' ~'"'+ '"'; +SINGLE_QUOTE : '\''; -ID: [A-Z_] [A-Z0-9_]*; +ID: [A-Z_] [A-Z0-9_]*; +STRING_LITERAL : '\'' (~'\'' | '\'\'')* '\''; +DECIMAL_LITERAL : DEC_DIGIT+; +FLOAT_LITERAL : DEC_DOT_DEC; +REAL_LITERAL : (DECIMAL_LITERAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+); +CHAR_LITERAL : '\'' (~['\\\r\n] | EscapeSequence) '\''; -STRING_LITERAL: '\'' (~'\'' | '\'\'')* '\''; -DECIMAL_LITERAL: DEC_DIGIT+; -FLOAT_LITERAL: DEC_DOT_DEC; -REAL_LITERAL: (DECIMAL_LITERAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+); -CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; - -fragment EscapeSequence - : '\\' [btnfr"'\\] +fragment EscapeSequence: + '\\' [btnfr"'\\] | '\\' ([0-3]? [0-7])? [0-7] | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +; -fragment HexDigit - : [0-9a-f] - ; +fragment HexDigit: [0-9a-f]; //ARROW: '->'; //ASSOC: '=>'; -NE: '!='; -LTGT: '<>'; -EQ: '='; -GT: '>'; -GE: '>='; -LT: '<'; -LE: '<='; -EXCLAMATION: '!'; -PIPE_PIPE: '||'; -DOT: '.'; -UNDERLINE: '_'; -LR_BRACKET: '('; -RR_BRACKET: ')'; -COMMA: ','; -SEMI: ';'; -STAR: '*'; -DIVIDE: '/'; -MODULE: '%'; -PLUS: '+'; -MINUS: '-'; - -PLACEHOLDER: '?'; +NE : '!='; +LTGT : '<>'; +EQ : '='; +GT : '>'; +GE : '>='; +LT : '<'; +LE : '<='; +EXCLAMATION : '!'; +PIPE_PIPE : '||'; +DOT : '.'; +UNDERLINE : '_'; +LR_BRACKET : '('; +RR_BRACKET : ')'; +COMMA : ','; +SEMI : ';'; +STAR : '*'; +DIVIDE : '/'; +MODULE : '%'; +PLUS : '+'; +MINUS : '-'; -fragment LETTER: [A-Z_]; -fragment DEC_DOT_DEC: (DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+); -fragment DEC_DIGIT: [0-9]; +PLACEHOLDER: '?'; +fragment LETTER : [A-Z_]; +fragment DEC_DOT_DEC : (DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+); +fragment DEC_DIGIT : [0-9]; -fragment FullWidthLetter options { caseInsensitive=false; } - : '\u00c0'..'\u00d6' - | '\u00d8'..'\u00f6' - | '\u00f8'..'\u00ff' - | '\u0100'..'\u1fff' - | '\u2c00'..'\u2fff' - | '\u3040'..'\u318f' - | '\u3300'..'\u337f' - | '\u3400'..'\u3fff' - | '\u4e00'..'\u9fff' - | '\ua000'..'\ud7ff' - | '\uf900'..'\ufaff' - | '\uff00'..'\ufff0' - // | '\u10000'..'\u1F9FF' //not support four bytes chars - // | '\u20000'..'\u2FA1F' - ; +fragment FullWidthLetter options { + caseInsensitive = false; +}: + '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0100' ..'\u1fff' + | '\u2c00' ..'\u2fff' + | '\u3040' ..'\u318f' + | '\u3300' ..'\u337f' + | '\u3400' ..'\u3fff' + | '\u4e00' ..'\u9fff' + | '\ua000' ..'\ud7ff' + | '\uf900' ..'\ufaff' + | '\uff00' ..'\ufff0' + ; // | '\u20000'..'\u2FA1F' \ No newline at end of file diff --git a/sql/derby/DerbyParser.g4 b/sql/derby/DerbyParser.g4 index 29adac10f6..86f939494c 100644 --- a/sql/derby/DerbyParser.g4 +++ b/sql/derby/DerbyParser.g4 @@ -21,9 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 DerbyParser; -options { tokenVocab=DerbyLexer; } +options { + tokenVocab = DerbyLexer; +} derby_file : batch* EOF @@ -272,27 +277,25 @@ keyword ; insert_statement - : INSERT INTO table_name - ( '(' simple_column_name (COMMA simple_column_name )* ')' )* - query order_by_clause? - offset_clause? - fetch_clause? + : INSERT INTO table_name ('(' simple_column_name (COMMA simple_column_name)* ')')* query order_by_clause? offset_clause? fetch_clause? ; offset_clause - : OFFSET ( integer_literal | '?' ) row_rows + : OFFSET (integer_literal | '?') row_rows ; fetch_clause - : FETCH first_next ( integer_literal | '?' ) row_rows ONLY + : FETCH first_next (integer_literal | '?') row_rows ONLY ; first_next - : FIRST | NEXT + : FIRST + | NEXT ; row_rows - : ROW | ROWS + : ROW + | ROWS ; integer_literal @@ -300,9 +303,7 @@ integer_literal ; merge_statement - : MERGE INTO table_name ( AS? correlation_name )? - USING table_name ( AS? correlation_name )? - ON search_condition merge_when_clause* + : MERGE INTO table_name (AS? correlation_name)? USING table_name (AS? correlation_name)? ON search_condition merge_when_clause* ; merge_when_clause @@ -311,19 +312,21 @@ merge_when_clause ; merge_when_matched - : WHEN MATCHED ( AND match_refinement )? THEN ( merge_update | DELETE ) + : WHEN MATCHED (AND match_refinement)? THEN (merge_update | DELETE) ; merge_when_not_matched - : WHEN NOT MATCHED ( AND match_refinement ) THEN merge_insert + : WHEN NOT MATCHED (AND match_refinement) THEN merge_insert ; merge_update - : UPDATE SET column_name EQ value (COMMA column_name EQ value )* + : UPDATE SET column_name EQ value (COMMA column_name EQ value)* ; merge_insert - : INSERT ( '(' simple_column_name (COMMA simple_column_name )* ')' )? VALUES '(' value (COMMA value )* ')' + : INSERT ('(' simple_column_name (COMMA simple_column_name)* ')')? VALUES '(' value ( + COMMA value + )* ')' ; search_condition @@ -335,12 +338,10 @@ match_refinement ; update_statement - : UPDATE table_name ( AS? correlation_name )? - SET column_name EQ value ( COMMA column_name EQ value )* - where_clause? - | UPDATE table_name - SET column_name EQ value ( COMMA column_name EQ value )* - WHERE CURRENT OF cursor_nName + : UPDATE table_name (AS? correlation_name)? SET column_name EQ value ( + COMMA column_name EQ value + )* where_clause? + | UPDATE table_name SET column_name EQ value (COMMA column_name EQ value)* WHERE CURRENT OF cursor_nName ; where_clause @@ -353,20 +354,16 @@ boolean_expression | NOT expression | expression comparison_operator expression | expression IS NOT? NULL_ - | character_expression NOT? LIKE character_expression ( ESCAPE string )? + | character_expression NOT? LIKE character_expression ( ESCAPE string)? | expression NOT? BETWEEN expression AND expression | expression NOT? IN table_subquery - | expression NOT? IN '(' expression (COMMA expression )* ')' + | expression NOT? IN '(' expression (COMMA expression)* ')' | NOT? EXISTS table_subquery - | expression comparison_operator ( ALL | ANY | SOME ) table_subquery + | expression comparison_operator ( ALL | ANY | SOME) table_subquery ; table_subquery - : '(' query - order_by_clause? - offset_clause? - fetch_clause? - ')' + : '(' query order_by_clause? offset_clause? fetch_clause? ')' ; character_expression @@ -374,49 +371,53 @@ character_expression ; comparison_operator - : '<' | '=' | '>' | '<=' | '>=' | '<>' + : '<' + | '=' + | '>' + | '<=' + | '>=' + | '<>' ; value - : expression | DEFAULT + : expression + | DEFAULT ; delete_statement - : DELETE FROM table_name ( AS? correlation_name )? - where_clause? + : DELETE FROM table_name (AS? correlation_name)? where_clause? | DELETE FROM table_name WHERE CURRENT OF cursor_nName ; // other commands other_command : CALL procedure_name '(' expr_list ')' - | DECLARE GLOBAL TEMPORARY TABLE table_name - column_definition (COMMA column_definition )* - ( ON COMMIT ( DELETE | PRESERVE ) ROWS )? - NOT LOGGED ( ON ROLLBACK DELETE ROWS )? - | GRANT privilege_type ON TABLE? ( table_name | view_name ) TO grantees + | DECLARE GLOBAL TEMPORARY TABLE table_name column_definition (COMMA column_definition)* ( + ON COMMIT ( DELETE | PRESERVE) ROWS + )? NOT LOGGED (ON ROLLBACK DELETE ROWS)? + | GRANT privilege_type ON TABLE? ( table_name | view_name) TO grantees | GRANT EXECUTE ON FUNCTION function_name TO grantees | GRANT EXECUTE ON PROCEDURE procedure_name TO grantees | GRANT USAGE ON SEQUENCE sequence_name TO grantees | GRANT USAGE ON TYPE type_name TO grantees | GRANT USAGE ON DERBY AGGREGATE aggregate_name TO grantees - | GRANT role_name (COMMA role_name )* TO grantees + | GRANT role_name (COMMA role_name)* TO grantees | LOCK TABLE table_name IN (SHARE | EXCLUSIVE) MODE | RENAME COLUMN table_name DOT simple_column_name TO simple_column_name | RENAME INDEX index_name TO index_name | RENAME TABLE RENAME TABLE table_name TO table_name - | REVOKE privilege_type ON TABLE? ( table_name | view_name ) FROM revokees + | REVOKE privilege_type ON TABLE? ( table_name | view_name) FROM revokees | REVOKE EXECUTE ON FUNCTION function_name FROM revokees RESTRICT | REVOKE EXECUTE ON PROCEDURE procedure_name FROM revokees RESTRICT | REVOKE USAGE ON SEQUENCE sequence_name FROM revokees RESTRICT | REVOKE USAGE ON TYPE type_name FROM revokees RESTRICT | REVOKE USAGE ON DERBY AGGREGATE aggregate_name FROM revokees RESTRICT - | REVOKE role_name (COMMA role_name )* FROM revokees - | SET CONSTRAINTS constraint_name_list ( DEFERRED | IMMEDIATE ) + | REVOKE role_name (COMMA role_name)* FROM revokees + | SET CONSTRAINTS constraint_name_list ( DEFERRED | IMMEDIATE) | SET CURRENT? ISOLATION EQ? isolation_level - | SET ROLE ( role_name | string | '?' | NONE ) - | SET CURRENT? SCHEMA EQ? ( schema_name | USER | '?' | string ) - | SET CURRENT SQLID EQ? ( schema_name | USER | '?' | string ) + | SET ROLE ( role_name | string | '?' | NONE) + | SET CURRENT? SCHEMA EQ? ( schema_name | USER | '?' | string) + | SET CURRENT SQLID EQ? ( schema_name | USER | '?' | string) ; grantees @@ -424,7 +425,9 @@ grantees ; grantee - : authorization_identifier | role_name | PUBLIC + : authorization_identifier + | role_name + | PUBLIC ; isolation_level @@ -443,14 +446,14 @@ isolation_level constraint_name_list : ALL - | constraint_name (COMMA constraint_name )* + | constraint_name (COMMA constraint_name)* ; column_definition : simple_column_name data_type? - //columnLevelConstraint* - with_default* -// columnLevelConstraint* + //columnLevelConstraint* + with_default* + // columnLevelConstraint* ; with_default @@ -461,22 +464,29 @@ with_default default_constant_expression : NULL_ - | CURRENT ( SCHEMA | SQLID ) - | USER | CURRENT_USER | SESSION_USER | CURRENT_ROLE + | CURRENT ( SCHEMA | SQLID) + | USER + | CURRENT_USER + | SESSION_USER + | CURRENT_ROLE | DATE | TIME | TIMESTAMP - | CURRENT DATE | CURRENT_DATE - | CURRENT TIME | CURRENT_TIME - | CURRENT TIMESTAMP | CURRENT_TIMESTAMP + | CURRENT DATE + | CURRENT_DATE + | CURRENT TIME + | CURRENT_TIME + | CURRENT TIMESTAMP + | CURRENT_TIMESTAMP | literal ; generated_column_spec - : GENERATED always_by_default AS IDENTITY - ( '(' START WITH integer_constant - | INCREMENT BY integer_constant - | NO? CYCLE ')' )? + : GENERATED always_by_default AS IDENTITY ( + '(' START WITH integer_constant + | INCREMENT BY integer_constant + | NO? CYCLE ')' + )? ; generation_clause @@ -484,53 +494,50 @@ generation_clause ; column_level_constraint - : ( CONSTRAINT constraint_name )? - ( - NOT NULL_ - | CHECK '(' search_condition ')' - | PRIMARY KEY - | UNIQUE - | references_clause - ) - constraint_characteristics? + : (CONSTRAINT constraint_name)? ( + NOT NULL_ + | CHECK '(' search_condition ')' + | PRIMARY KEY + | UNIQUE + | references_clause + ) constraint_characteristics? ; table_level_constraint - : ( CONSTRAINT constraint_name )? - ( - CHECK '(' search_condition ')' | - ( - PRIMARY KEY '(' simple_column_name_list ')' | - UNIQUE '(' simple_column_name_list ')' | - FOREIGN KEY '(' simple_column_name_list ')' - references_clause - ) - ) constraint_characteristics? + : (CONSTRAINT constraint_name)? ( + CHECK '(' search_condition ')' + | ( + PRIMARY KEY '(' simple_column_name_list ')' + | UNIQUE '(' simple_column_name_list ')' + | FOREIGN KEY '(' simple_column_name_list ')' references_clause + ) + ) constraint_characteristics? ; references_clause - : REFERENCES table_name ( '(' simple_column_name_list ')' )? - ( ON DELETE ( NO ACTION | RESTRICT | CASCADE | SET NULL_ ) )? - ( ON UPDATE no_action_restrict )? - | ( ON UPDATE no_action_restrict )? - ( ON DELETE ( NO ACTION | RESTRICT | CASCADE | SET NULL_ ) )? + : REFERENCES table_name ('(' simple_column_name_list ')')? ( + ON DELETE ( NO ACTION | RESTRICT | CASCADE | SET NULL_) + )? (ON UPDATE no_action_restrict)? + | (ON UPDATE no_action_restrict)? (ON DELETE ( NO ACTION | RESTRICT | CASCADE | SET NULL_))? ; no_action_restrict - : NO ACTION | RESTRICT + : NO ACTION + | RESTRICT ; constraint_characteristics - : constraint_check_time ( NOT? DEFERRABLE )? + : constraint_check_time (NOT? DEFERRABLE)? | NOT? DEFERRABLE constraint_check_time? ; constraint_check_time - : INITIALLY DEFERRED | INITIALLY IMMEDIATE + : INITIALLY DEFERRED + | INITIALLY IMMEDIATE ; simple_column_name_list - : simple_column_name (COMMA simple_column_name )* + : simple_column_name (COMMA simple_column_name)* ; truncate_table @@ -543,7 +550,7 @@ privilege_type ; privilege_list - : table_privilege (COMMA table_privilege )* + : table_privilege (COMMA table_privilege)* ; table_privilege @@ -556,7 +563,7 @@ table_privilege ; column_list - : '(' column_identifier (COMMA column_identifier )* ')' + : '(' column_identifier (COMMA column_identifier)* ')' ; column_identifier @@ -568,7 +575,9 @@ revokees ; revokee - : authorization_identifier | role_name | PUBLIC + : authorization_identifier + | role_name + | PUBLIC ; authorization_identifier @@ -581,17 +590,18 @@ alter_command ; alter_table - : ALTER TABLE table_name - ADD COLUMN column_definition - | ADD constraint_clause - | DROP COLUMN? column_name cascade_restrict? - | DROP ( PRIMARY KEY | - FOREIGN KEY constraint_name | - UNIQUE constraint_name | - CHECK constraint_name | - CONSTRAINT constraint_name ) - | ALTER COLUMN? column_alteration - | LOCKSIZE row_table + : ALTER TABLE table_name ADD COLUMN column_definition + | ADD constraint_clause + | DROP COLUMN? column_name cascade_restrict? + | DROP ( + PRIMARY KEY + | FOREIGN KEY constraint_name + | UNIQUE constraint_name + | CHECK constraint_name + | CONSTRAINT constraint_name + ) + | ALTER COLUMN? column_alteration + | LOCKSIZE row_table ; constraint_clause @@ -600,18 +610,20 @@ constraint_clause ; cascade_restrict - : CASCADE | RESTRICT + : CASCADE + | RESTRICT ; row_table - : ROW | TABLE + : ROW + | TABLE ; column_alteration - : column_name SET DATA TYPE BLOB( integer ) - | column_name SET DATA TYPE CLOB( integer ) - | column_name SET DATA TYPE VARCHAR( integer ) - | column_name SET DATA TYPE VARCHAR( integer ) FOR BIT DATA + : column_name SET DATA TYPE BLOB (integer) + | column_name SET DATA TYPE CLOB ( integer) + | column_name SET DATA TYPE VARCHAR ( integer) + | column_name SET DATA TYPE VARCHAR ( integer) FOR BIT DATA | column_name SET INCREMENT BY integer_constant | column_name RESTART WITH integer_constant | column_name SET GENERATED always_by_default @@ -635,19 +647,24 @@ defaultValue ; constant_expression_null - : num | string | NULL_ + : num + | string + | NULL_ ; always_by_default - : ALWAYS | BY DEFAULT + : ALWAYS + | BY DEFAULT ; set_drop - : SET | DROP + : SET + | DROP ; with_set - : WITH | SET + : WITH + | SET ; // create commands @@ -675,8 +692,7 @@ value_data_type ; create_function - : CREATE FUNCTION function_name '(' function_parameter (COMMA function_parameter)* ')' RETURNS return_data_type - function_element* + : CREATE FUNCTION function_name '(' function_parameter (COMMA function_parameter)* ')' RETURNS return_data_type function_element* ; function_parameter @@ -689,7 +705,7 @@ return_data_type ; table_type - : TABLE '(' column_element (COMMA column_element ) ')' + : TABLE '(' column_element (COMMA column_element) ')' ; column_element @@ -700,23 +716,24 @@ function_element : LANGUAGE JAVA | (DETERMINISTIC | NOT DETERMINISTIC) | EXTERNAL NAME single_quoted_string - | PARAMETER STYLE ( JAVA | DERBY_JDBC_RESULT_SET | DERBY ) - | EXTERNAL SECURITY ( DEFINER | INVOKER ) - | ( NO SQL | CONTAINS SQL | READS SQL DATA ) - | ( RETURNS NULL_ ON NULL_ INPUT | CALLED ON NULL_ INPUT ) + | PARAMETER STYLE ( JAVA | DERBY_JDBC_RESULT_SET | DERBY) + | EXTERNAL SECURITY ( DEFINER | INVOKER) + | ( NO SQL | CONTAINS SQL | READS SQL DATA) + | ( RETURNS NULL_ ON NULL_ INPUT | CALLED ON NULL_ INPUT) ; create_index - : CREATE UNIQUE? INDEX index_name ON table_name '(' simple_column_name asc_desc? (',' simple_column_name asc_desc? )* ')' + : CREATE UNIQUE? INDEX index_name ON table_name '(' simple_column_name asc_desc? ( + ',' simple_column_name asc_desc? + )* ')' ; create_procedure - : CREATE PROCEDURE procedure_name '(' procedure_parameter (COMMA procedure_parameter)* ')' - procedure_element* + : CREATE PROCEDURE procedure_name '(' procedure_parameter (COMMA procedure_parameter)* ')' procedure_element* ; procedure_parameter - : ( IN | OUT | INOUT )? parameter_name? data_type + : (IN | OUT | INOUT)? parameter_name? data_type ; data_type @@ -738,7 +755,7 @@ data_type | SMALLINT | TIME | TIMESTAMP - | (VARCHAR | CHAR VARYING | CHARACTER VARYING ) ('(' num ')')? + | (VARCHAR | CHAR VARYING | CHARACTER VARYING) ('(' num ')')? //| (VARCHAR | CHAR VARYING | CHARACTER VARYING ) //('(' num ')')? FOR BIT DATA | XML ; @@ -746,14 +763,11 @@ data_type procedure_element : DYNAMIC? RESULT SETS integer | LANGUAGE JAVA - | ( DETERMINISTIC | NOT DETERMINISTIC ) + | ( DETERMINISTIC | NOT DETERMINISTIC) | EXTERNAL NAME single_quoted_string - | PARAMETER STYLE ( JAVA | DERBY ) - | EXTERNAL SECURITY ( DEFINER | INVOKER ) - | ( NO SQL - | MODIFIES SQL DATA - | CONTAINS SQL - | READS SQL DATA ) + | PARAMETER STYLE ( JAVA | DERBY) + | EXTERNAL SECURITY ( DEFINER | INVOKER) + | ( NO SQL | MODIFIES SQL DATA | CONTAINS SQL | READS SQL DATA) ; create_role @@ -761,25 +775,23 @@ create_role ; create_schema - : CREATE SCHEMA - ( - schema_name AUTHORIZATION user_name - | schema_name - | AUTHORIZATION user_name - ) + : CREATE SCHEMA (schema_name AUTHORIZATION user_name | schema_name | AUTHORIZATION user_name) ; create_sequence - : CREATE SEQUENCE sequence_name (COMMA sequence_element )* + : CREATE SEQUENCE sequence_name (COMMA sequence_element)* ; sequence_element : AS data_type | START WITH signedInteger | INCREMENT BY signedInteger - | MAXVALUE signedInteger | NO MAXVALUE - | MINVALUE signedInteger | NO MINVALUE - | CYCLE | NO CYCLE + | MAXVALUE signedInteger + | NO MAXVALUE + | MINVALUE signedInteger + | NO MINVALUE + | CYCLE + | NO CYCLE ; signedInteger @@ -787,36 +799,34 @@ signedInteger ; create_synonym - : CREATE SYNONYM synonym_name FOR ( view_name | table_name ) + : CREATE SYNONYM synonym_name FOR (view_name | table_name) ; create_table : CREATE TABLE table_name -// { -// ( { columnDefinition | tableLevelConstraint } -// [ , { columnDefinition | tableLevelConstraint } ] * ) -// | -// [ ( simpleColumnName [ , simpleColumnName ] * ) ] -// AS queryExpression - WITH NO DATA -// } + // { + // ( { columnDefinition | tableLevelConstraint } + // [ , { columnDefinition | tableLevelConstraint } ] * ) + // | + // [ ( simpleColumnName [ , simpleColumnName ] * ) ] + // AS queryExpression + WITH NO DATA + // } ; create_trigger : CREATE TRIGGER trigger_name -// { AFTER | NO CASCADE BEFORE } -// { INSERT | DELETE | UPDATE [ OF columnName [ , columnName ]* ] } -// ON tableName -// [ referencingClause ] -// [ FOR EACH { ROW | STATEMENT } ] [ MODE DB2SQL ] -// [ WHEN ( booleanExpression ) ] -// triggeredSQLStatement + // { AFTER | NO CASCADE BEFORE } + // { INSERT | DELETE | UPDATE [ OF columnName [ , columnName ]* ] } + // ON tableName + // [ referencingClause ] + // [ FOR EACH { ROW | STATEMENT } ] [ MODE DB2SQL ] + // [ WHEN ( booleanExpression ) ] + // triggeredSQLStatement ; create_type - : CREATE TYPE type_name - EXTERNAL NAME single_quoted_string - LANGUAGE JAVA + : CREATE TYPE type_name EXTERNAL NAME single_quoted_string LANGUAGE JAVA ; single_quoted_string @@ -824,19 +834,11 @@ single_quoted_string ; create_view - : CREATE VIEW view_name - ( '(' simple_column_name (COMMA simple_column_name )* ')' )? - AS query order_by_clause? - offset_clause? - fetch_clause? + : CREATE VIEW view_name ('(' simple_column_name (COMMA simple_column_name)* ')')? AS query order_by_clause? offset_clause? fetch_clause? ; query - : '(' query - order_by_clause? - offset_clause? - fetch_clause? - ')' + : '(' query order_by_clause? offset_clause? fetch_clause? ')' | query INTERSECT all_distinct? query | query EXCEPT all_distinct? query | query UNION all_distinct? query @@ -845,21 +847,15 @@ query ; select_expression - : SELECT all_distinct? select_item (COMMA select_item )* - from_clause - where_clause? - group_by_clause? - having_clause? -// [ WINDOW clause ] - order_by_clause? - offset_clause? - fetch_clause? + : SELECT all_distinct? select_item (COMMA select_item)* from_clause where_clause? group_by_clause? having_clause? + // [ WINDOW clause ] + order_by_clause? offset_clause? fetch_clause? ; select_item : '*' - | ( table_name | correlation_name ) DOT '*' - | expression (AS simple_column_name )? + | ( table_name | correlation_name) DOT '*' + | expression (AS simple_column_name)? ; simple_column_name @@ -956,7 +952,7 @@ constraint_name ; column_name - : ( ( table_name | correlation_name ) DOT )? id_ + : (( table_name | correlation_name) DOT)? id_ ; correlation_name @@ -1010,8 +1006,8 @@ cursor_nName id_ : ID | DOUBLE_QUOTE_ID -// | DOUBLE_QUOTE_BLANK -// | keyword + // | DOUBLE_QUOTE_BLANK + // | keyword ; num @@ -1029,9 +1025,9 @@ expression | table_subquery | function_call | case_expression - | op=('+' | '-') expression - | expression op=(STAR | DIVIDE | MODULE) expression - | expression op=(PLUS | MINUS ) expression + | op = ('+' | '-') expression + | expression op = (STAR | DIVIDE | MODULE) expression + | expression op = (PLUS | MINUS) expression | expression DOT expression | expression comparison_operator expression | expression AND expression @@ -1039,7 +1035,7 @@ expression | NOT expression | expression NOT? IN '(' expr_list ')' | CAST '(' expression AS data_type ')' -// | over_clause + // | over_clause ; primitive_expression @@ -1058,7 +1054,8 @@ literal : string // string, date, time, timestamp | sign? DECIMAL_LITERAL | sign? (REAL_LITERAL | FLOAT_LITERAL) - | TRUE | FALSE + | TRUE + | FALSE | NULL_ ; @@ -1074,38 +1071,32 @@ case_expression ; searched_case - : CASE - WHEN boolean_expression THEN expression - ( WHEN boolean_expression THEN expression )* - ( ELSE expression )? - END + : CASE WHEN boolean_expression THEN expression (WHEN boolean_expression THEN expression)* ( + ELSE expression + )? END ; simple_case - : CASE value_expression - WHEN value_expression (COMMA value_expression )* THEN expression - ( WHEN value_expression (COMMA value_expression )* THEN expression )* - ( ELSE expression )? - END + : CASE value_expression WHEN value_expression (COMMA value_expression)* THEN expression ( + WHEN value_expression (COMMA value_expression)* THEN expression + )* (ELSE expression)? END ; extended_case - : CASE value_expression - WHEN when_operand (COMMA when_operand )* THEN expression - ( WHEN when_operand (COMMA when_operand )* THEN expression )* - ( ELSE expression )? - END + : CASE value_expression WHEN when_operand (COMMA when_operand)* THEN expression ( + WHEN when_operand (COMMA when_operand)* THEN expression + )* (ELSE expression)? END ; when_operand - : value_expression | - comparison_operator expression | - IS NOT? NULL_ | - NOT? LIKE string ( ESCAPE string )? | - NOT? BETWEEN expression AND expression | - NOT? IN table_subquery | - NOT? IN '(' expr_list ')' | - comparison_operator ( ALL | ANY | SOME ) table_subquery + : value_expression + | comparison_operator expression + | IS NOT? NULL_ + | NOT? LIKE string ( ESCAPE string)? + | NOT? BETWEEN expression AND expression + | NOT? IN table_subquery + | NOT? IN '(' expr_list ')' + | comparison_operator ( ALL | ANY | SOME) table_subquery ; value_expression @@ -1113,14 +1104,16 @@ value_expression ; standard_built_in_function - : ABS | ABSVAL + : ABS + | ABSVAL | ACOS | ASIN | ATAN | ATAN2 | BIGINT | CAST - | CEIL | CEILING + | CEIL + | CEILING | CHAR | PIPE_PIPE | COS @@ -1138,12 +1131,15 @@ standard_built_in_function | FLOOR | HOUR | IDENTITY_VAL_LOCAL - | INT | INTEGER + | INT + | INTEGER | LENGTH - | LN | LOG + | LN + | LOG | LOG10 | LOCATE - | LCASE | LOWER + | LCASE + | LOWER | LTRIM | MINUTE | MOD @@ -1161,7 +1157,8 @@ standard_built_in_function | TIME | TIMESTAMP | TRIM - | UCASE | UPPER + | UCASE + | UPPER | USER | VARCHAR | YEAR @@ -1181,29 +1178,22 @@ aggreagate_built_in_function // select select_statement - : query - order_by_clause? - offset_clause? - fetch_clause? - for_update_clause? - ( WITH ( RR | RS | CS | UR ) )? + : query order_by_clause? offset_clause? fetch_clause? for_update_clause? ( + WITH ( RR | RS | CS | UR) + )? ; for_update_clause - : FOR - ( - READ ONLY - | FETCH ONLY - | UPDATE ( OF simple_column_name (COMMA simple_column_name )* )? - ) + : FOR (READ ONLY | FETCH ONLY | UPDATE ( OF simple_column_name (COMMA simple_column_name)*)?) ; all_distinct - : ALL | DISTINCT + : ALL + | DISTINCT ; from_clause - : FROM table_expression (COMMA table_expression )* + : FROM table_expression (COMMA table_expression)* ; table_expression @@ -1212,28 +1202,31 @@ table_expression ; join_operation - : INNER? JOIN table_expression ( ON boolean_expression | using_clause ) - | LEFT OUTER? JOIN table_expression ( ON boolean_expression | using_clause ) - | RIGHT OUTER? JOIN table_expression ( ON boolean_expression | using_clause ) - | CROSS JOIN ( table_view_or_function_expression | table_expression ) - | NATURAL ( ( LEFT | RIGHT ) OUTER? | INNER )? JOIN ( table_view_or_function_expression | table_expression ) + : INNER? JOIN table_expression (ON boolean_expression | using_clause) + | LEFT OUTER? JOIN table_expression ( ON boolean_expression | using_clause) + | RIGHT OUTER? JOIN table_expression ( ON boolean_expression | using_clause) + | CROSS JOIN ( table_view_or_function_expression | table_expression) + | NATURAL (( LEFT | RIGHT) OUTER? | INNER)? JOIN ( + table_view_or_function_expression + | table_expression + ) ; table_view_or_function_expression - : ( table_name | view_name ) correlation_clause? - | ( table_subquery | table_function_invocation ) correlation_clause + : (table_name | view_name) correlation_clause? + | ( table_subquery | table_function_invocation) correlation_clause ; using_clause - : USING '(' simple_column_name (COMMA simple_column_name )* ')' + : USING '(' simple_column_name (COMMA simple_column_name)* ')' ; correlation_clause - : AS? correlation_name ( '(' simple_column_name (COMMA simple_column_name )* ')' )? + : AS? correlation_name ('(' simple_column_name (COMMA simple_column_name)* ')')? ; table_function_invocation - : TABLE function_name '(' ( function_arg (COMMA function_arg )* )? ')' + : TABLE function_name '(' (function_arg (COMMA function_arg)*)? ')' ; function_arg @@ -1241,10 +1234,7 @@ function_arg ; group_by_clause - : GROUP BY ( - column_name (COMMA column_name )* - | ROLLUP '(' column_name (COMMA column_name )* ')' - ) + : GROUP BY (column_name (COMMA column_name)* | ROLLUP '(' column_name (COMMA column_name)* ')') ; having_clause @@ -1252,15 +1242,16 @@ having_clause ; order_by_clause - : ORDER BY order_by_item (COMMA order_by_item )* + : ORDER BY order_by_item (COMMA order_by_item)* ; order_by_item - : ( column_name | columnPosition | expression ) asc_desc? ( NULLS FIRST | NULLS LAST )? + : (column_name | columnPosition | expression) asc_desc? (NULLS FIRST | NULLS LAST)? ; asc_desc - : ASC | DESC + : ASC + | DESC ; columnPosition @@ -1269,9 +1260,7 @@ columnPosition values_expression : ( - VALUES '(' value (COMMA value )* ')' (COMMA '(' value (COMMA value )* ')' )* - | VALUES value (COMMA value )* - ) order_by_clause? - offset_clause? - fetch_clause? - ; + VALUES '(' value (COMMA value)* ')' (COMMA '(' value (COMMA value)* ')')* + | VALUES value (COMMA value)* + ) order_by_clause? offset_clause? fetch_clause? + ; \ No newline at end of file diff --git a/sql/drill/DrillLexer.g4 b/sql/drill/DrillLexer.g4 index 84017d42f3..db6b60803c 100644 --- a/sql/drill/DrillLexer.g4 +++ b/sql/drill/DrillLexer.g4 @@ -21,171 +21,177 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar DrillLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} -ALL : 'ALL'; -ALTER : 'ALTER'; -ANALYZE : 'ANALYZE'; -AND : 'AND'; -ANY : 'ANY'; -AS : 'AS'; -ASC : 'ASC'; -ASSIGN : 'ASSIGN'; -BETWEEN : 'BETWEEN'; -BIGINT : 'BIGINT'; -BINARY : 'BINARY'; -BOOLEAN : 'BOOLEAN'; -BY : 'BY'; -CAST : 'CAST'; -CHAR : 'CHAR'; -CHARACTER : 'CHARACTER'; -COLUMNS : 'COLUMNS'; -COMPUTE : 'COMPUTE'; -CREATE : 'CREATE'; -CROSS : 'CROSS'; -DATABASE : 'DATABASE'; -DATABASES : 'DATABASES'; -DATE : 'DATE'; -DAY : 'DAY'; -DEC : 'DEC'; -DECIMAL : 'DECIMAL'; -DEFAULT : 'DEFAULT'; -DESC : 'DESC'; -DESCRIBE : 'DESCRIBE'; -DISTINCT : 'DISTINCT'; -DOUBLE : 'DOUBLE'; -DROP : 'DROP'; -ESCAPE : 'ESCAPE'; -ESTIMATE : 'ESTIMATE'; -EXISTS : 'EXISTS'; -FALSE : 'FALSE'; -FETCH : 'FETCH'; -FILES : 'FILES'; -FIRST : 'FIRST'; -FLOAT : 'FLOAT'; -FOR : 'FOR'; -FORMAT : 'FORMAT'; -FROM : 'FROM'; -FULL : 'FULL'; -FUNCTION : 'FUNCTION'; -GROUP : 'GROUP'; -HAVING : 'HAVING'; -HOUR : 'HOUR'; -IF : 'IF'; -IN : 'IN'; -INNER : 'INNER'; -INT : 'INT'; -INTEGER : 'INTEGER'; -INTERVAL : 'INTERVAL'; -IS : 'IS'; -JAR : 'JAR'; -JOIN : 'JOIN'; -LAST : 'LAST'; -LATERAL : 'LATERAL'; -LEFT : 'LEFT'; -LEVEL : 'LEVEL'; -LIKE : 'LIKE'; -LIMIT : 'LIMIT'; -LOAD : 'LOAD'; -METADATA : 'METADATA'; -MINUTE : 'MINUTE'; -MONTH : 'MONTH'; -NATURAL : 'NATURAL'; -NEXT : 'NEXT'; -NONE : 'NONE'; -NOT : 'NOT'; -NULL_ : 'NULL'; -NULLS : 'NULLS'; -NUMERIC : 'NUMERIC'; -OFFSET : 'OFFSET'; -ON : 'ON'; -OR : 'OR'; -ORDER : 'ORDER'; -OUTER : 'OUTER'; -OVER : 'OVER'; -PARTITION : 'PARTITION'; -PATH : 'PATH'; -PERCENT : 'PERCENT'; -PRECISION : 'PRECISION'; -PROPERTIES : 'PROPERTIES'; -REFRESH : 'REFRESH'; -REPLACE : 'REPLACE'; -RESET : 'RESET'; -RIGHT : 'RIGHT'; -ROW : 'ROW'; -ROWS : 'ROWS'; -SAMPLE : 'SAMPLE'; -SCHEMA : 'SCHEMA'; -SCHEMAS : 'SCHEMAS'; -SECOND : 'SECOND'; -SELECT : 'SELECT'; -SESSION : 'SESSION'; -SET : 'SET'; -SHOW : 'SHOW'; -SMALLINT : 'SMALLINT'; -SOME : 'SOME'; -STATISTICS : 'STATISTICS'; -SYSTEM : 'SYSTEM'; -TABLE : 'TABLE'; -TABLES : 'TABLES'; -TEMPORARY : 'TEMPORARY'; -TIME : 'TIME'; -TIMESTAMP : 'TIMESTAMP'; -TRUE : 'TRUE'; -UNION : 'UNION'; -UNNEST : 'UNNEST'; -USE : 'USE'; -USING : 'USING'; -VARCHAR : 'VARCHAR'; -VARYING : 'VARYING'; -VIEW : 'VIEW'; -WHERE : 'WHERE'; -WITH : 'WITH'; -YEAR : 'YEAR'; +ALL : 'ALL'; +ALTER : 'ALTER'; +ANALYZE : 'ANALYZE'; +AND : 'AND'; +ANY : 'ANY'; +AS : 'AS'; +ASC : 'ASC'; +ASSIGN : 'ASSIGN'; +BETWEEN : 'BETWEEN'; +BIGINT : 'BIGINT'; +BINARY : 'BINARY'; +BOOLEAN : 'BOOLEAN'; +BY : 'BY'; +CAST : 'CAST'; +CHAR : 'CHAR'; +CHARACTER : 'CHARACTER'; +COLUMNS : 'COLUMNS'; +COMPUTE : 'COMPUTE'; +CREATE : 'CREATE'; +CROSS : 'CROSS'; +DATABASE : 'DATABASE'; +DATABASES : 'DATABASES'; +DATE : 'DATE'; +DAY : 'DAY'; +DEC : 'DEC'; +DECIMAL : 'DECIMAL'; +DEFAULT : 'DEFAULT'; +DESC : 'DESC'; +DESCRIBE : 'DESCRIBE'; +DISTINCT : 'DISTINCT'; +DOUBLE : 'DOUBLE'; +DROP : 'DROP'; +ESCAPE : 'ESCAPE'; +ESTIMATE : 'ESTIMATE'; +EXISTS : 'EXISTS'; +FALSE : 'FALSE'; +FETCH : 'FETCH'; +FILES : 'FILES'; +FIRST : 'FIRST'; +FLOAT : 'FLOAT'; +FOR : 'FOR'; +FORMAT : 'FORMAT'; +FROM : 'FROM'; +FULL : 'FULL'; +FUNCTION : 'FUNCTION'; +GROUP : 'GROUP'; +HAVING : 'HAVING'; +HOUR : 'HOUR'; +IF : 'IF'; +IN : 'IN'; +INNER : 'INNER'; +INT : 'INT'; +INTEGER : 'INTEGER'; +INTERVAL : 'INTERVAL'; +IS : 'IS'; +JAR : 'JAR'; +JOIN : 'JOIN'; +LAST : 'LAST'; +LATERAL : 'LATERAL'; +LEFT : 'LEFT'; +LEVEL : 'LEVEL'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +LOAD : 'LOAD'; +METADATA : 'METADATA'; +MINUTE : 'MINUTE'; +MONTH : 'MONTH'; +NATURAL : 'NATURAL'; +NEXT : 'NEXT'; +NONE : 'NONE'; +NOT : 'NOT'; +NULL_ : 'NULL'; +NULLS : 'NULLS'; +NUMERIC : 'NUMERIC'; +OFFSET : 'OFFSET'; +ON : 'ON'; +OR : 'OR'; +ORDER : 'ORDER'; +OUTER : 'OUTER'; +OVER : 'OVER'; +PARTITION : 'PARTITION'; +PATH : 'PATH'; +PERCENT : 'PERCENT'; +PRECISION : 'PRECISION'; +PROPERTIES : 'PROPERTIES'; +REFRESH : 'REFRESH'; +REPLACE : 'REPLACE'; +RESET : 'RESET'; +RIGHT : 'RIGHT'; +ROW : 'ROW'; +ROWS : 'ROWS'; +SAMPLE : 'SAMPLE'; +SCHEMA : 'SCHEMA'; +SCHEMAS : 'SCHEMAS'; +SECOND : 'SECOND'; +SELECT : 'SELECT'; +SESSION : 'SESSION'; +SET : 'SET'; +SHOW : 'SHOW'; +SMALLINT : 'SMALLINT'; +SOME : 'SOME'; +STATISTICS : 'STATISTICS'; +SYSTEM : 'SYSTEM'; +TABLE : 'TABLE'; +TABLES : 'TABLES'; +TEMPORARY : 'TEMPORARY'; +TIME : 'TIME'; +TIMESTAMP : 'TIMESTAMP'; +TRUE : 'TRUE'; +UNION : 'UNION'; +UNNEST : 'UNNEST'; +USE : 'USE'; +USING : 'USING'; +VARCHAR : 'VARCHAR'; +VARYING : 'VARYING'; +VIEW : 'VIEW'; +WHERE : 'WHERE'; +WITH : 'WITH'; +YEAR : 'YEAR'; -WHITE_SPACE : [ \t\r\n]+ -> channel(HIDDEN); +WHITE_SPACE: [ \t\r\n]+ -> channel(HIDDEN); -SQL_COMMENT : '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); -LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); +SQL_COMMENT : '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); -IDENTIFIER : [A-Z_] [A-Z0-9_]*; +IDENTIFIER: [A-Z_] [A-Z0-9_]*; -BS_STRING_LITERAL : '`' ~'`'+ '`'; +BS_STRING_LITERAL : '`' ~'`'+ '`'; SQ_STRING_LITERAL : '\'' ~'\''+ '\''; DQ_STRING_LITERAL : '"' ~'"'+ '"'; -DECIMAL_LITERAL : DEC_DIGIT+; -FLOAT_LITERAL : DEC_DOT_DEC; -REAL_LITERAL : (DECIMAL_LITERAL | DEC_DOT_DEC) 'E' [+-]? DEC_DIGIT+; -CHAR_LITERAL : '\'' ~['\\\r\n] '\''; +DECIMAL_LITERAL : DEC_DIGIT+; +FLOAT_LITERAL : DEC_DOT_DEC; +REAL_LITERAL : (DECIMAL_LITERAL | DEC_DOT_DEC) 'E' [+-]? DEC_DIGIT+; +CHAR_LITERAL : '\'' ~['\\\r\n] '\''; -NE : '!='; -LTGT : '<>'; -EQ : '='; -GT : '>'; -GE : '>='; -LT : '<'; -LE : '<='; -EXCLAMATION : '!'; -PIPE_PIPE : '||'; -DOT : '.'; -UNDERLINE : '_'; -LRB : '('; -RRB : ')'; -LSB : '['; -RSB : ']'; -LCB : '{'; -RCB : '}'; -COMMA : ','; -SEMI : ';'; -STAR : '*'; -DIVIDE : '/'; -MODULE : '%'; -PLUS : '+'; -MINUS : '-'; +NE : '!='; +LTGT : '<>'; +EQ : '='; +GT : '>'; +GE : '>='; +LT : '<'; +LE : '<='; +EXCLAMATION : '!'; +PIPE_PIPE : '||'; +DOT : '.'; +UNDERLINE : '_'; +LRB : '('; +RRB : ')'; +LSB : '['; +RSB : ']'; +LCB : '{'; +RCB : '}'; +COMMA : ','; +SEMI : ';'; +STAR : '*'; +DIVIDE : '/'; +MODULE : '%'; +PLUS : '+'; +MINUS : '-'; fragment LETTER : [A-Z_]; -fragment DEC_DOT_DEC : DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+; -fragment DEC_DIGIT : [0-9]; +fragment DEC_DOT_DEC : DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+; +fragment DEC_DIGIT : [0-9]; \ No newline at end of file diff --git a/sql/drill/DrillParser.g4 b/sql/drill/DrillParser.g4 index 8018c2d188..3d9f322e56 100644 --- a/sql/drill/DrillParser.g4 +++ b/sql/drill/DrillParser.g4 @@ -21,9 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 DrillParser; -options { tokenVocab=DrillLexer; } +options { + tokenVocab = DrillLexer; +} drill_file : batch* EOF @@ -53,11 +58,10 @@ create_command ; create_schema - : CREATE or_replace? SCHEMA - (LOAD string)? - ('(' column_definition (',' column_definition)* ')')? - (FOR TABLE table_name | PATH string)? - (PROPERTIES '(' kv_list ')')? + : CREATE or_replace? SCHEMA (LOAD string)? ('(' column_definition (',' column_definition)* ')')? ( + FOR TABLE table_name + | PATH string + )? (PROPERTIES '(' kv_list ')')? ; column_definition @@ -105,9 +109,7 @@ alter_command ; alter_system - : ALTER SYSTEM ( SET option_name '=' value - | RESET (option_name | ALL) - ) + : ALTER SYSTEM (SET option_name '=' value | RESET (option_name | ALL)) ; option_name @@ -156,10 +158,11 @@ refresh_table_metadata ; analyze_command - : ANALYZE TABLE (table_name | TABLE '(' id_ '(' param_list ')' ')')? - (COLUMNS (column_list_paren | NONE))? - (REFRESH METADATA (string LEVEL)?)? - ((COMPUTE | ESTIMATE) STATISTICS (SAMPLE number PERCENT)?)? + : ANALYZE TABLE (table_name | TABLE '(' id_ '(' param_list ')' ')')? ( + COLUMNS (column_list_paren | NONE) + )? (REFRESH METADATA (string LEVEL)?)? ( + (COMPUTE | ESTIMATE) STATISTICS (SAMPLE number PERCENT)? + )? ; param_list @@ -174,7 +177,7 @@ describe_command show_command : SHOW (TABLES | DATABASES | SCHEMAS) - | SHOW FILES ((FROM | IN ) fs=id_ '.' dir=id_)? + | SHOW FILES ((FROM | IN) fs = id_ '.' dir = id_)? ; use_command @@ -182,15 +185,7 @@ use_command ; select_stmt - : with_clause? - select_clause - from_clause? - where_clause? - group_by_clause? - having_clause? - order_by_clause? - limit_clause? - offset_clause? + : with_clause? select_clause from_clause? where_clause? group_by_clause? having_clause? order_by_clause? limit_clause? offset_clause? ; with_clause @@ -206,10 +201,9 @@ select_clause ; select_item - : ( COLUMNS '[' number ']' - | ((table_name | column_alias) '.')? '*' - | expression - ) (AS? column_alias)? + : (COLUMNS '[' number ']' | ((table_name | column_alias) '.')? '*' | expression) ( + AS? column_alias + )? ; from_clause @@ -238,10 +232,7 @@ join_clause ; join_type - : ( INNER? - | (LEFT | RIGHT | FULL) OUTER? - | CROSS - ) JOIN + : (INNER? | (LEFT | RIGHT | FULL) OUTER? | CROSS) JOIN ; table_reference @@ -275,10 +266,7 @@ boolean_expression ; table_subquery - : '(' query - order_by_clause? - offset_clause? - ')' + : '(' query order_by_clause? offset_clause? ')' ; expression @@ -286,10 +274,10 @@ expression | '(' expression ')' | table_subquery | function_call -// | case_expression - | op=('+' | '-') expression - | expression op=(STAR | DIVIDE | MODULE) expression - | expression op=(PLUS | MINUS ) expression + // | case_expression + | op = ('+' | '-') expression + | expression op = (STAR | DIVIDE | MODULE) expression + | expression op = (PLUS | MINUS) expression | expression DOT expression | expression comparison_operator expression | expression AND expression @@ -316,12 +304,17 @@ literal function_call : function_name '(' expr_list? ')' -// | standard_built_in_function '(' expr_list? ')' -// | aggreagate_built_in_function '(' expr_list? ')' + // | standard_built_in_function '(' expr_list? ')' + // | aggreagate_built_in_function '(' expr_list? ')' ; comparison_operator - : '<' | '=' | '>' | '<=' | '>=' | '<>' + : '<' + | '=' + | '>' + | '<=' + | '>=' + | '<>' ; expr_list @@ -354,22 +347,13 @@ number ; query - : '(' query - order_by_clause? - offset_clause? - ')' + : '(' query order_by_clause? offset_clause? ')' | query UNION ALL? query | select_stmt ; select_expression - : select_clause - from_clause? - where_clause? - group_by_clause? - having_clause? - order_by_clause? - offset_clause? + : select_clause from_clause? where_clause? group_by_clause? having_clause? order_by_clause? offset_clause? ; data_type @@ -468,4 +452,4 @@ table_path value : literal - ; + ; \ No newline at end of file diff --git a/sql/hive/v2/FromClauseParser.g4 b/sql/hive/v2/FromClauseParser.g4 index 3dcff10a91..341791c821 100644 --- a/sql/hive/v2/FromClauseParser.g4 +++ b/sql/hive/v2/FromClauseParser.g4 @@ -17,6 +17,9 @@ @author Canwei He */ +// $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 FromClauseParser; //----------------------------------------------------------------------------------- @@ -50,7 +53,6 @@ fromSource | joinSource ; - atomjoinSource : tableSource lateralView* | virtualTableSource lateralView* @@ -60,7 +62,9 @@ atomjoinSource ; joinSource - : atomjoinSource (joinToken joinSourcePart (KW_ON expression | KW_USING columnParenthesesList)?)* + : atomjoinSource ( + joinToken joinSourcePart (KW_ON expression | KW_USING columnParenthesesList)? + )* ; joinSourcePart @@ -84,29 +88,33 @@ joinToken | KW_INNER KW_JOIN | COMMA | KW_CROSS KW_JOIN - | KW_LEFT KW_OUTER? KW_JOIN + | KW_LEFT KW_OUTER? KW_JOIN | KW_RIGHT KW_OUTER? KW_JOIN - | KW_FULL KW_OUTER? KW_JOIN + | KW_FULL KW_OUTER? KW_JOIN | KW_LEFT KW_SEMI KW_JOIN ; lateralView - : KW_LATERAL KW_VIEW KW_OUTER function tableAlias (KW_AS identifier (COMMA identifier)*)? - | COMMA? KW_LATERAL KW_VIEW function tableAlias (KW_AS identifier (COMMA identifier)*)? - | COMMA? KW_LATERAL KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias (LPAREN identifier (COMMA identifier)* RPAREN)? - ; + : KW_LATERAL KW_VIEW KW_OUTER function tableAlias (KW_AS identifier (COMMA identifier)*)? + | COMMA? KW_LATERAL KW_VIEW function tableAlias (KW_AS identifier (COMMA identifier)*)? + | COMMA? KW_LATERAL KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias ( + LPAREN identifier (COMMA identifier)* RPAREN + )? + ; tableAlias : identifier ; tableBucketSample - : KW_TABLESAMPLE LPAREN KW_BUCKET Number KW_OUT KW_OF Number (KW_ON expression (COMMA expression)*)? RPAREN + : KW_TABLESAMPLE LPAREN KW_BUCKET Number KW_OUT KW_OF Number ( + KW_ON expression (COMMA expression)* + )? RPAREN ; splitSample - : KW_TABLESAMPLE LPAREN Number (KW_PERCENT|KW_ROWS) RPAREN - | KW_TABLESAMPLE LPAREN ByteLengthLiteral RPAREN + : KW_TABLESAMPLE LPAREN Number (KW_PERCENT | KW_ROWS) RPAREN + | KW_TABLESAMPLE LPAREN ByteLengthLiteral RPAREN ; tableSample @@ -137,25 +145,24 @@ subQuerySource //---------------------- Rules for parsing PTF clauses ----------------------------- partitioningSpec - : partitionByClause orderByClause? - | orderByClause - | distributeByClause sortByClause? - | sortByClause - | clusterByClause - ; + : partitionByClause orderByClause? + | orderByClause + | distributeByClause sortByClause? + | sortByClause + | clusterByClause + ; partitionTableFunctionSource - : subQuerySource - | tableSource - | partitionedTableFunction - ; + : subQuerySource + | tableSource + | partitionedTableFunction + ; partitionedTableFunction - : identifier LPAREN KW_ON - partitionTableFunctionSource partitioningSpec? - (Identifier LPAREN expression RPAREN ( COMMA Identifier LPAREN expression RPAREN)*)? - RPAREN identifier? - ; + : identifier LPAREN KW_ON partitionTableFunctionSource partitioningSpec? ( + Identifier LPAREN expression RPAREN (COMMA Identifier LPAREN expression RPAREN)* + )? RPAREN identifier? + ; //----------------------- Rules for parsing whereClause ----------------------------- // where a=b and ... @@ -198,4 +205,4 @@ virtualTableSource : KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias (LPAREN identifier (COMMA identifier)*)? RPAREN ; -//----------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------- \ No newline at end of file diff --git a/sql/hive/v2/HintParser.g4 b/sql/hive/v2/HintParser.g4 index 8de43aead8..042639cc79 100644 --- a/sql/hive/v2/HintParser.g4 +++ b/sql/hive/v2/HintParser.g4 @@ -16,11 +16,15 @@ @author Canwei He */ + +// $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 HintParser; options { - tokenVocab=HiveLexer; + tokenVocab = HiveLexer; } // starting rule @@ -50,4 +54,4 @@ hintArgName : Identifier | Number | KW_NONE - ; + ; \ No newline at end of file diff --git a/sql/hive/v2/HiveLexer.g4 b/sql/hive/v2/HiveLexer.g4 index 8b12903bf9..f7fc1d1277 100644 --- a/sql/hive/v2/HiveLexer.g4 +++ b/sql/hive/v2/HiveLexer.g4 @@ -18,435 +18,427 @@ based on the Hive 3.1.2 grammar by Canwei He */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar HiveLexer; -options { caseInsensitive = true; } - -KW_TRUE: 'TRUE'; -KW_FALSE: 'FALSE'; -KW_ALL: 'ALL'; -KW_NONE: 'NONE'; -KW_AND: 'AND'; -KW_OR: 'OR'; -KW_NOT: 'NOT' | '!'; -KW_LIKE: 'LIKE'; -KW_ANY: 'ANY'; -KW_IF: 'IF'; -KW_EXISTS: 'EXISTS'; -KW_ASC: 'ASC'; -KW_DESC: 'DESC'; -KW_NULLS: 'NULLS'; -KW_LAST: 'LAST'; -KW_ORDER: 'ORDER'; -KW_GROUP: 'GROUP'; -KW_BY: 'BY'; -KW_HAVING: 'HAVING'; -KW_WHERE: 'WHERE'; -KW_FROM: 'FROM'; -KW_AS: 'AS'; -KW_SELECT: 'SELECT'; -KW_DISTINCT: 'DISTINCT'; -KW_INSERT: 'INSERT'; -KW_OVERWRITE: 'OVERWRITE'; -KW_OUTER: 'OUTER'; -KW_UNIQUEJOIN: 'UNIQUEJOIN'; -KW_PRESERVE: 'PRESERVE'; -KW_JOIN: 'JOIN'; -KW_LEFT: 'LEFT'; -KW_RIGHT: 'RIGHT'; -KW_FULL: 'FULL'; -KW_ON: 'ON'; -KW_PARTITION: 'PARTITION'; -KW_PARTITIONS: 'PARTITIONS'; -KW_TABLE: 'TABLE'; -KW_TABLES: 'TABLES'; -KW_COLUMNS: 'COLUMNS'; -KW_INDEX: 'INDEX'; -KW_INDEXES: 'INDEXES'; -KW_REBUILD: 'REBUILD'; -KW_FUNCTIONS: 'FUNCTIONS'; -KW_SHOW: 'SHOW'; -KW_MSCK: 'MSCK'; -KW_REPAIR: 'REPAIR'; -KW_DIRECTORY: 'DIRECTORY'; -KW_LOCAL: 'LOCAL'; -KW_TRANSFORM: 'TRANSFORM'; -KW_USING: 'USING'; -KW_CLUSTER: 'CLUSTER'; -KW_DISTRIBUTE: 'DISTRIBUTE'; -KW_SORT: 'SORT'; -KW_UNION: 'UNION'; -KW_EXCEPT: 'EXCEPT'; -KW_LOAD: 'LOAD'; -KW_EXPORT: 'EXPORT'; -KW_IMPORT: 'IMPORT'; -KW_REPLICATION: 'REPLICATION'; -KW_METADATA: 'METADATA'; -KW_DATA: 'DATA'; -KW_INPATH: 'INPATH'; -KW_IS: 'IS'; -KW_NULL: 'NULL'; -KW_CREATE: 'CREATE'; -KW_EXTERNAL: 'EXTERNAL'; -KW_ALTER: 'ALTER'; -KW_CHANGE: 'CHANGE'; -KW_COLUMN: 'COLUMN'; -KW_FIRST: 'FIRST'; -KW_AFTER: 'AFTER'; -KW_DESCRIBE: 'DESCRIBE'; -KW_DROP: 'DROP'; -KW_RENAME: 'RENAME'; -KW_TO: 'TO'; -KW_COMMENT: 'COMMENT'; -KW_BOOLEAN: 'BOOLEAN'; -KW_TINYINT: 'TINYINT'; -KW_SMALLINT: 'SMALLINT'; -KW_INT: 'INT' 'EGER'?; -KW_BIGINT: 'BIGINT'; -KW_FLOAT: 'FLOAT'; -KW_DOUBLE: 'DOUBLE'; -KW_PRECISION: 'PRECISION'; -KW_DATE: 'DATE'; -KW_DATETIME: 'DATETIME'; -KW_TIMESTAMP: 'TIMESTAMP'; -KW_TIMESTAMPLOCALTZ: 'TIMESTAMPLOCALTZ'; -KW_TIME: 'TIME'; -KW_ZONE: 'ZONE'; -KW_INTERVAL: 'INTERVAL'; -KW_DECIMAL: 'DECIMAL'; -KW_STRING: 'STRING'; -KW_CHAR: 'CHAR'; -KW_VARCHAR: 'VARCHAR'; -KW_ARRAY: 'ARRAY'; -KW_STRUCT: 'STRUCT'; -KW_MAP: 'MAP'; -KW_UNIONTYPE: 'UNIONTYPE'; -KW_REDUCE: 'REDUCE'; -KW_PARTITIONED: 'PARTITIONED'; -KW_CLUSTERED: 'CLUSTERED'; -KW_SORTED: 'SORTED'; -KW_INTO: 'INTO'; -KW_BUCKETS: 'BUCKETS'; -KW_ROW: 'ROW'; -KW_ROWS: 'ROWS'; -KW_FORMAT: 'FORMAT'; -KW_DELIMITED: 'DELIMITED'; -KW_FIELDS: 'FIELDS'; -KW_TERMINATED: 'TERMINATED'; -KW_ESCAPED: 'ESCAPED'; -KW_COLLECTION: 'COLLECTION'; -KW_ITEMS: 'ITEMS'; -KW_KEYS: 'KEYS'; -KW_KEY_TYPE: '$KEY$'; -KW_KILL: 'KILL'; -KW_LINES: 'LINES'; -KW_STORED: 'STORED'; -KW_FILEFORMAT: 'FILEFORMAT'; -KW_INPUTFORMAT: 'INPUTFORMAT'; -KW_OUTPUTFORMAT: 'OUTPUTFORMAT'; -KW_INPUTDRIVER: 'INPUTDRIVER'; -KW_OUTPUTDRIVER: 'OUTPUTDRIVER'; -KW_ENABLE: 'ENABLE'; -KW_DISABLE: 'DISABLE'; -KW_LOCATION: 'LOCATION'; -KW_TABLESAMPLE: 'TABLESAMPLE'; -KW_BUCKET: 'BUCKET'; -KW_OUT: 'OUT'; -KW_OF: 'OF'; -KW_PERCENT: 'PERCENT'; -KW_CAST: 'CAST'; -KW_ADD: 'ADD'; -KW_REPLACE: 'REPLACE'; -KW_RLIKE: 'RLIKE'; -KW_REGEXP: 'REGEXP'; -KW_TEMPORARY: 'TEMPORARY'; -KW_FUNCTION: 'FUNCTION'; -KW_MACRO: 'MACRO'; -KW_FILE: 'FILE'; -KW_JAR: 'JAR'; -KW_EXPLAIN: 'EXPLAIN'; -KW_EXTENDED: 'EXTENDED'; -KW_FORMATTED: 'FORMATTED'; -KW_DEPENDENCY: 'DEPENDENCY'; -KW_LOGICAL: 'LOGICAL'; -KW_SERDE: 'SERDE'; -KW_WITH: 'WITH'; -KW_DEFERRED: 'DEFERRED'; -KW_SERDEPROPERTIES: 'SERDEPROPERTIES'; -KW_DBPROPERTIES: 'DBPROPERTIES'; -KW_LIMIT: 'LIMIT'; -KW_OFFSET: 'OFFSET'; -KW_SET: 'SET'; -KW_UNSET: 'UNSET'; -KW_TBLPROPERTIES: 'TBLPROPERTIES'; -KW_IDXPROPERTIES: 'IDXPROPERTIES'; -KW_VALUE_TYPE: '$VALUE$'; -KW_ELEM_TYPE: '$ELEM$'; -KW_DEFINED: 'DEFINED'; -KW_CASE: 'CASE'; -KW_WHEN: 'WHEN'; -KW_THEN: 'THEN'; -KW_ELSE: 'ELSE'; -KW_END: 'END'; -KW_MAPJOIN: 'MAPJOIN'; -KW_STREAMTABLE: 'STREAMTABLE'; -KW_CLUSTERSTATUS: 'CLUSTERSTATUS'; -KW_UTC: 'UTC'; -KW_UTCTIMESTAMP: 'UTCTIMESTAMP'; -KW_LONG: 'LONG'; -KW_DELETE: 'DELETE'; -KW_PLUS: 'PLUS'; -KW_MINUS: 'MINUS'; -KW_FETCH: 'FETCH'; -KW_INTERSECT: 'INTERSECT'; -KW_VIEW: 'VIEW'; -KW_VIEWS: 'VIEWS'; -KW_IN: 'IN'; -KW_DATABASE: 'DATABASE'; -KW_DATABASES: 'DATABASES'; -KW_MATERIALIZED: 'MATERIALIZED'; -KW_SCHEMA: 'SCHEMA'; -KW_SCHEMAS: 'SCHEMAS'; -KW_GRANT: 'GRANT'; -KW_REVOKE: 'REVOKE'; -KW_SSL: 'SSL'; -KW_UNDO: 'UNDO'; -KW_LOCK: 'LOCK'; -KW_LOCKS: 'LOCKS'; -KW_UNLOCK: 'UNLOCK'; -KW_SHARED: 'SHARED'; -KW_EXCLUSIVE: 'EXCLUSIVE'; -KW_PROCEDURE: 'PROCEDURE'; -KW_UNSIGNED: 'UNSIGNED'; -KW_WHILE: 'WHILE'; -KW_READ: 'READ'; -KW_READS: 'READS'; -KW_PURGE: 'PURGE'; -KW_RANGE: 'RANGE'; -KW_ANALYZE: 'ANALYZE'; -KW_BEFORE: 'BEFORE'; -KW_BETWEEN: 'BETWEEN'; -KW_BOTH: 'BOTH'; -KW_BINARY: 'BINARY'; -KW_CROSS: 'CROSS'; -KW_CONTINUE: 'CONTINUE'; -KW_CURSOR: 'CURSOR'; -KW_TRIGGER: 'TRIGGER'; -KW_RECORDREADER: 'RECORDREADER'; -KW_RECORDWRITER: 'RECORDWRITER'; -KW_SEMI: 'SEMI'; -KW_LATERAL: 'LATERAL'; -KW_TOUCH: 'TOUCH'; -KW_ARCHIVE: 'ARCHIVE'; -KW_UNARCHIVE: 'UNARCHIVE'; -KW_COMPUTE: 'COMPUTE'; -KW_STATISTICS: 'STATISTICS'; -KW_USE: 'USE'; -KW_OPTION: 'OPTION'; -KW_CONCATENATE: 'CONCATENATE'; -KW_SHOW_DATABASE: 'SHOW_DATABASE'; -KW_UPDATE: 'UPDATE'; -KW_RESTRICT: 'RESTRICT'; -KW_CASCADE: 'CASCADE'; -KW_SKEWED: 'SKEWED'; -KW_ROLLUP: 'ROLLUP'; -KW_CUBE: 'CUBE'; -KW_DIRECTORIES: 'DIRECTORIES'; -KW_FOR: 'FOR'; -KW_WINDOW: 'WINDOW'; -KW_UNBOUNDED: 'UNBOUNDED'; -KW_PRECEDING: 'PRECEDING'; -KW_FOLLOWING: 'FOLLOWING'; -KW_CURRENT: 'CURRENT'; -KW_CURRENT_DATE: 'CURRENT_DATE'; -KW_CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -KW_LESS: 'LESS'; -KW_MORE: 'MORE'; -KW_OVER: 'OVER'; -KW_GROUPING: 'GROUPING'; -KW_SETS: 'SETS'; -KW_TRUNCATE: 'TRUNCATE'; -KW_NOSCAN: 'NOSCAN'; -KW_USER: 'USER'; -KW_ROLE: 'ROLE'; -KW_ROLES: 'ROLES'; -KW_INNER: 'INNER'; -KW_EXCHANGE: 'EXCHANGE'; -KW_URI: 'URI'; -KW_SERVER: 'SERVER'; -KW_ADMIN: 'ADMIN'; -KW_OWNER: 'OWNER'; -KW_PRINCIPALS: 'PRINCIPALS'; -KW_COMPACT: 'COMPACT'; -KW_COMPACTIONS: 'COMPACTIONS'; -KW_TRANSACTIONS: 'TRANSACTIONS'; -KW_REWRITE: 'REWRITE'; -KW_AUTHORIZATION: 'AUTHORIZATION'; -KW_REOPTIMIZATION: 'REOPTIMIZATION'; -KW_CONF: 'CONF'; -KW_VALUES: 'VALUES'; -KW_RELOAD: 'RELOAD'; -KW_YEAR: 'YEAR' 'S'?; -KW_QUERY: 'QUERY'; -KW_QUARTER: 'QUARTER'; -KW_MONTH: 'MONTH' 'S'?; -KW_WEEK: 'WEEK' 'S'?; -KW_DAY: 'DAY' 'S'?; -KW_DOW: 'DOW'; -KW_HOUR: 'HOUR' 'S'?; -KW_MINUTE: 'MINUTE' 'S'?; -KW_SECOND: 'SECOND' 'S'?; -KW_START: 'START'; -KW_TRANSACTION: 'TRANSACTION'; -KW_COMMIT: 'COMMIT'; -KW_ROLLBACK: 'ROLLBACK'; -KW_WORK: 'WORK'; -KW_ONLY: 'ONLY'; -KW_WRITE: 'WRITE'; -KW_ISOLATION: 'ISOLATION'; -KW_LEVEL: 'LEVEL'; -KW_SNAPSHOT: 'SNAPSHOT'; -KW_AUTOCOMMIT: 'AUTOCOMMIT'; -KW_CACHE: 'CACHE'; -KW_PRIMARY: 'PRIMARY'; -KW_FOREIGN: 'FOREIGN'; -KW_REFERENCES: 'REFERENCES'; -KW_CONSTRAINT: 'CONSTRAINT'; -KW_ENFORCED: 'ENFORCED'; -KW_VALIDATE: 'VALIDATE'; -KW_NOVALIDATE: 'NOVALIDATE'; -KW_RELY: 'RELY'; -KW_NORELY: 'NORELY'; -KW_UNIQUE: 'UNIQUE'; -KW_KEY: 'KEY'; -KW_ABORT: 'ABORT'; -KW_EXTRACT: 'EXTRACT'; -KW_FLOOR: 'FLOOR'; -KW_MERGE: 'MERGE'; -KW_MATCHED: 'MATCHED'; -KW_REPL: 'REPL'; -KW_DUMP: 'DUMP'; -KW_STATUS: 'STATUS'; -KW_VECTORIZATION: 'VECTORIZATION'; -KW_SUMMARY: 'SUMMARY'; -KW_OPERATOR: 'OPERATOR'; -KW_EXPRESSION: 'EXPRESSION'; -KW_DETAIL: 'DETAIL'; -KW_WAIT: 'WAIT'; -KW_RESOURCE: 'RESOURCE'; -KW_PLAN: 'PLAN'; -KW_QUERY_PARALLELISM: 'QUERY_PARALLELISM'; -KW_PLANS: 'PLANS'; -KW_ACTIVATE: 'ACTIVATE'; -KW_DEFAULT: 'DEFAULT'; -KW_CHECK: 'CHECK'; -KW_POOL: 'POOL'; -KW_MOVE: 'MOVE'; -KW_DO: 'DO'; -KW_ALLOC_FRACTION: 'ALLOC_FRACTION'; -KW_SCHEDULING_POLICY: 'SCHEDULING_POLICY'; -KW_PATH: 'PATH'; -KW_MAPPING: 'MAPPING'; -KW_WORKLOAD: 'WORKLOAD'; -KW_MANAGEMENT: 'MANAGEMENT'; -KW_ACTIVE: 'ACTIVE'; -KW_UNMANAGED: 'UNMANAGED'; -KW_APPLICATION: 'APPLICATION'; -KW_SYNC: 'SYNC'; +options { + caseInsensitive = true; +} + +KW_TRUE : 'TRUE'; +KW_FALSE : 'FALSE'; +KW_ALL : 'ALL'; +KW_NONE : 'NONE'; +KW_AND : 'AND'; +KW_OR : 'OR'; +KW_NOT : 'NOT' | '!'; +KW_LIKE : 'LIKE'; +KW_ANY : 'ANY'; +KW_IF : 'IF'; +KW_EXISTS : 'EXISTS'; +KW_ASC : 'ASC'; +KW_DESC : 'DESC'; +KW_NULLS : 'NULLS'; +KW_LAST : 'LAST'; +KW_ORDER : 'ORDER'; +KW_GROUP : 'GROUP'; +KW_BY : 'BY'; +KW_HAVING : 'HAVING'; +KW_WHERE : 'WHERE'; +KW_FROM : 'FROM'; +KW_AS : 'AS'; +KW_SELECT : 'SELECT'; +KW_DISTINCT : 'DISTINCT'; +KW_INSERT : 'INSERT'; +KW_OVERWRITE : 'OVERWRITE'; +KW_OUTER : 'OUTER'; +KW_UNIQUEJOIN : 'UNIQUEJOIN'; +KW_PRESERVE : 'PRESERVE'; +KW_JOIN : 'JOIN'; +KW_LEFT : 'LEFT'; +KW_RIGHT : 'RIGHT'; +KW_FULL : 'FULL'; +KW_ON : 'ON'; +KW_PARTITION : 'PARTITION'; +KW_PARTITIONS : 'PARTITIONS'; +KW_TABLE : 'TABLE'; +KW_TABLES : 'TABLES'; +KW_COLUMNS : 'COLUMNS'; +KW_INDEX : 'INDEX'; +KW_INDEXES : 'INDEXES'; +KW_REBUILD : 'REBUILD'; +KW_FUNCTIONS : 'FUNCTIONS'; +KW_SHOW : 'SHOW'; +KW_MSCK : 'MSCK'; +KW_REPAIR : 'REPAIR'; +KW_DIRECTORY : 'DIRECTORY'; +KW_LOCAL : 'LOCAL'; +KW_TRANSFORM : 'TRANSFORM'; +KW_USING : 'USING'; +KW_CLUSTER : 'CLUSTER'; +KW_DISTRIBUTE : 'DISTRIBUTE'; +KW_SORT : 'SORT'; +KW_UNION : 'UNION'; +KW_EXCEPT : 'EXCEPT'; +KW_LOAD : 'LOAD'; +KW_EXPORT : 'EXPORT'; +KW_IMPORT : 'IMPORT'; +KW_REPLICATION : 'REPLICATION'; +KW_METADATA : 'METADATA'; +KW_DATA : 'DATA'; +KW_INPATH : 'INPATH'; +KW_IS : 'IS'; +KW_NULL : 'NULL'; +KW_CREATE : 'CREATE'; +KW_EXTERNAL : 'EXTERNAL'; +KW_ALTER : 'ALTER'; +KW_CHANGE : 'CHANGE'; +KW_COLUMN : 'COLUMN'; +KW_FIRST : 'FIRST'; +KW_AFTER : 'AFTER'; +KW_DESCRIBE : 'DESCRIBE'; +KW_DROP : 'DROP'; +KW_RENAME : 'RENAME'; +KW_TO : 'TO'; +KW_COMMENT : 'COMMENT'; +KW_BOOLEAN : 'BOOLEAN'; +KW_TINYINT : 'TINYINT'; +KW_SMALLINT : 'SMALLINT'; +KW_INT : 'INT' 'EGER'?; +KW_BIGINT : 'BIGINT'; +KW_FLOAT : 'FLOAT'; +KW_DOUBLE : 'DOUBLE'; +KW_PRECISION : 'PRECISION'; +KW_DATE : 'DATE'; +KW_DATETIME : 'DATETIME'; +KW_TIMESTAMP : 'TIMESTAMP'; +KW_TIMESTAMPLOCALTZ : 'TIMESTAMPLOCALTZ'; +KW_TIME : 'TIME'; +KW_ZONE : 'ZONE'; +KW_INTERVAL : 'INTERVAL'; +KW_DECIMAL : 'DECIMAL'; +KW_STRING : 'STRING'; +KW_CHAR : 'CHAR'; +KW_VARCHAR : 'VARCHAR'; +KW_ARRAY : 'ARRAY'; +KW_STRUCT : 'STRUCT'; +KW_MAP : 'MAP'; +KW_UNIONTYPE : 'UNIONTYPE'; +KW_REDUCE : 'REDUCE'; +KW_PARTITIONED : 'PARTITIONED'; +KW_CLUSTERED : 'CLUSTERED'; +KW_SORTED : 'SORTED'; +KW_INTO : 'INTO'; +KW_BUCKETS : 'BUCKETS'; +KW_ROW : 'ROW'; +KW_ROWS : 'ROWS'; +KW_FORMAT : 'FORMAT'; +KW_DELIMITED : 'DELIMITED'; +KW_FIELDS : 'FIELDS'; +KW_TERMINATED : 'TERMINATED'; +KW_ESCAPED : 'ESCAPED'; +KW_COLLECTION : 'COLLECTION'; +KW_ITEMS : 'ITEMS'; +KW_KEYS : 'KEYS'; +KW_KEY_TYPE : '$KEY$'; +KW_KILL : 'KILL'; +KW_LINES : 'LINES'; +KW_STORED : 'STORED'; +KW_FILEFORMAT : 'FILEFORMAT'; +KW_INPUTFORMAT : 'INPUTFORMAT'; +KW_OUTPUTFORMAT : 'OUTPUTFORMAT'; +KW_INPUTDRIVER : 'INPUTDRIVER'; +KW_OUTPUTDRIVER : 'OUTPUTDRIVER'; +KW_ENABLE : 'ENABLE'; +KW_DISABLE : 'DISABLE'; +KW_LOCATION : 'LOCATION'; +KW_TABLESAMPLE : 'TABLESAMPLE'; +KW_BUCKET : 'BUCKET'; +KW_OUT : 'OUT'; +KW_OF : 'OF'; +KW_PERCENT : 'PERCENT'; +KW_CAST : 'CAST'; +KW_ADD : 'ADD'; +KW_REPLACE : 'REPLACE'; +KW_RLIKE : 'RLIKE'; +KW_REGEXP : 'REGEXP'; +KW_TEMPORARY : 'TEMPORARY'; +KW_FUNCTION : 'FUNCTION'; +KW_MACRO : 'MACRO'; +KW_FILE : 'FILE'; +KW_JAR : 'JAR'; +KW_EXPLAIN : 'EXPLAIN'; +KW_EXTENDED : 'EXTENDED'; +KW_FORMATTED : 'FORMATTED'; +KW_DEPENDENCY : 'DEPENDENCY'; +KW_LOGICAL : 'LOGICAL'; +KW_SERDE : 'SERDE'; +KW_WITH : 'WITH'; +KW_DEFERRED : 'DEFERRED'; +KW_SERDEPROPERTIES : 'SERDEPROPERTIES'; +KW_DBPROPERTIES : 'DBPROPERTIES'; +KW_LIMIT : 'LIMIT'; +KW_OFFSET : 'OFFSET'; +KW_SET : 'SET'; +KW_UNSET : 'UNSET'; +KW_TBLPROPERTIES : 'TBLPROPERTIES'; +KW_IDXPROPERTIES : 'IDXPROPERTIES'; +KW_VALUE_TYPE : '$VALUE$'; +KW_ELEM_TYPE : '$ELEM$'; +KW_DEFINED : 'DEFINED'; +KW_CASE : 'CASE'; +KW_WHEN : 'WHEN'; +KW_THEN : 'THEN'; +KW_ELSE : 'ELSE'; +KW_END : 'END'; +KW_MAPJOIN : 'MAPJOIN'; +KW_STREAMTABLE : 'STREAMTABLE'; +KW_CLUSTERSTATUS : 'CLUSTERSTATUS'; +KW_UTC : 'UTC'; +KW_UTCTIMESTAMP : 'UTCTIMESTAMP'; +KW_LONG : 'LONG'; +KW_DELETE : 'DELETE'; +KW_PLUS : 'PLUS'; +KW_MINUS : 'MINUS'; +KW_FETCH : 'FETCH'; +KW_INTERSECT : 'INTERSECT'; +KW_VIEW : 'VIEW'; +KW_VIEWS : 'VIEWS'; +KW_IN : 'IN'; +KW_DATABASE : 'DATABASE'; +KW_DATABASES : 'DATABASES'; +KW_MATERIALIZED : 'MATERIALIZED'; +KW_SCHEMA : 'SCHEMA'; +KW_SCHEMAS : 'SCHEMAS'; +KW_GRANT : 'GRANT'; +KW_REVOKE : 'REVOKE'; +KW_SSL : 'SSL'; +KW_UNDO : 'UNDO'; +KW_LOCK : 'LOCK'; +KW_LOCKS : 'LOCKS'; +KW_UNLOCK : 'UNLOCK'; +KW_SHARED : 'SHARED'; +KW_EXCLUSIVE : 'EXCLUSIVE'; +KW_PROCEDURE : 'PROCEDURE'; +KW_UNSIGNED : 'UNSIGNED'; +KW_WHILE : 'WHILE'; +KW_READ : 'READ'; +KW_READS : 'READS'; +KW_PURGE : 'PURGE'; +KW_RANGE : 'RANGE'; +KW_ANALYZE : 'ANALYZE'; +KW_BEFORE : 'BEFORE'; +KW_BETWEEN : 'BETWEEN'; +KW_BOTH : 'BOTH'; +KW_BINARY : 'BINARY'; +KW_CROSS : 'CROSS'; +KW_CONTINUE : 'CONTINUE'; +KW_CURSOR : 'CURSOR'; +KW_TRIGGER : 'TRIGGER'; +KW_RECORDREADER : 'RECORDREADER'; +KW_RECORDWRITER : 'RECORDWRITER'; +KW_SEMI : 'SEMI'; +KW_LATERAL : 'LATERAL'; +KW_TOUCH : 'TOUCH'; +KW_ARCHIVE : 'ARCHIVE'; +KW_UNARCHIVE : 'UNARCHIVE'; +KW_COMPUTE : 'COMPUTE'; +KW_STATISTICS : 'STATISTICS'; +KW_USE : 'USE'; +KW_OPTION : 'OPTION'; +KW_CONCATENATE : 'CONCATENATE'; +KW_SHOW_DATABASE : 'SHOW_DATABASE'; +KW_UPDATE : 'UPDATE'; +KW_RESTRICT : 'RESTRICT'; +KW_CASCADE : 'CASCADE'; +KW_SKEWED : 'SKEWED'; +KW_ROLLUP : 'ROLLUP'; +KW_CUBE : 'CUBE'; +KW_DIRECTORIES : 'DIRECTORIES'; +KW_FOR : 'FOR'; +KW_WINDOW : 'WINDOW'; +KW_UNBOUNDED : 'UNBOUNDED'; +KW_PRECEDING : 'PRECEDING'; +KW_FOLLOWING : 'FOLLOWING'; +KW_CURRENT : 'CURRENT'; +KW_CURRENT_DATE : 'CURRENT_DATE'; +KW_CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +KW_LESS : 'LESS'; +KW_MORE : 'MORE'; +KW_OVER : 'OVER'; +KW_GROUPING : 'GROUPING'; +KW_SETS : 'SETS'; +KW_TRUNCATE : 'TRUNCATE'; +KW_NOSCAN : 'NOSCAN'; +KW_USER : 'USER'; +KW_ROLE : 'ROLE'; +KW_ROLES : 'ROLES'; +KW_INNER : 'INNER'; +KW_EXCHANGE : 'EXCHANGE'; +KW_URI : 'URI'; +KW_SERVER : 'SERVER'; +KW_ADMIN : 'ADMIN'; +KW_OWNER : 'OWNER'; +KW_PRINCIPALS : 'PRINCIPALS'; +KW_COMPACT : 'COMPACT'; +KW_COMPACTIONS : 'COMPACTIONS'; +KW_TRANSACTIONS : 'TRANSACTIONS'; +KW_REWRITE : 'REWRITE'; +KW_AUTHORIZATION : 'AUTHORIZATION'; +KW_REOPTIMIZATION : 'REOPTIMIZATION'; +KW_CONF : 'CONF'; +KW_VALUES : 'VALUES'; +KW_RELOAD : 'RELOAD'; +KW_YEAR : 'YEAR' 'S'?; +KW_QUERY : 'QUERY'; +KW_QUARTER : 'QUARTER'; +KW_MONTH : 'MONTH' 'S'?; +KW_WEEK : 'WEEK' 'S'?; +KW_DAY : 'DAY' 'S'?; +KW_DOW : 'DOW'; +KW_HOUR : 'HOUR' 'S'?; +KW_MINUTE : 'MINUTE' 'S'?; +KW_SECOND : 'SECOND' 'S'?; +KW_START : 'START'; +KW_TRANSACTION : 'TRANSACTION'; +KW_COMMIT : 'COMMIT'; +KW_ROLLBACK : 'ROLLBACK'; +KW_WORK : 'WORK'; +KW_ONLY : 'ONLY'; +KW_WRITE : 'WRITE'; +KW_ISOLATION : 'ISOLATION'; +KW_LEVEL : 'LEVEL'; +KW_SNAPSHOT : 'SNAPSHOT'; +KW_AUTOCOMMIT : 'AUTOCOMMIT'; +KW_CACHE : 'CACHE'; +KW_PRIMARY : 'PRIMARY'; +KW_FOREIGN : 'FOREIGN'; +KW_REFERENCES : 'REFERENCES'; +KW_CONSTRAINT : 'CONSTRAINT'; +KW_ENFORCED : 'ENFORCED'; +KW_VALIDATE : 'VALIDATE'; +KW_NOVALIDATE : 'NOVALIDATE'; +KW_RELY : 'RELY'; +KW_NORELY : 'NORELY'; +KW_UNIQUE : 'UNIQUE'; +KW_KEY : 'KEY'; +KW_ABORT : 'ABORT'; +KW_EXTRACT : 'EXTRACT'; +KW_FLOOR : 'FLOOR'; +KW_MERGE : 'MERGE'; +KW_MATCHED : 'MATCHED'; +KW_REPL : 'REPL'; +KW_DUMP : 'DUMP'; +KW_STATUS : 'STATUS'; +KW_VECTORIZATION : 'VECTORIZATION'; +KW_SUMMARY : 'SUMMARY'; +KW_OPERATOR : 'OPERATOR'; +KW_EXPRESSION : 'EXPRESSION'; +KW_DETAIL : 'DETAIL'; +KW_WAIT : 'WAIT'; +KW_RESOURCE : 'RESOURCE'; +KW_PLAN : 'PLAN'; +KW_QUERY_PARALLELISM : 'QUERY_PARALLELISM'; +KW_PLANS : 'PLANS'; +KW_ACTIVATE : 'ACTIVATE'; +KW_DEFAULT : 'DEFAULT'; +KW_CHECK : 'CHECK'; +KW_POOL : 'POOL'; +KW_MOVE : 'MOVE'; +KW_DO : 'DO'; +KW_ALLOC_FRACTION : 'ALLOC_FRACTION'; +KW_SCHEDULING_POLICY : 'SCHEDULING_POLICY'; +KW_PATH : 'PATH'; +KW_MAPPING : 'MAPPING'; +KW_WORKLOAD : 'WORKLOAD'; +KW_MANAGEMENT : 'MANAGEMENT'; +KW_ACTIVE : 'ACTIVE'; +KW_UNMANAGED : 'UNMANAGED'; +KW_APPLICATION : 'APPLICATION'; +KW_SYNC : 'SYNC'; // Operators // NOTE: if you add a new function/operator, add it to sysFuncNames so that describe function _FUNC_ will work. -DOT : '.'; // generated as a part of Number rule -COLON : ':' ; -COMMA : ',' ; -SEMICOLON : ';' ; - -LPAREN : '(' ; -RPAREN : ')' ; -LSQUARE : '[' ; -RSQUARE : ']' ; -LCURLY : '{'; -RCURLY : '}'; - -EQUAL : '=' | '=='; -EQUAL_NS : '<=>'; -NOTEQUAL : '<>' | '!='; -LESSTHANOREQUALTO : '<='; -LESSTHAN : '<'; +DOT : '.'; // generated as a part of Number rule +COLON : ':'; +COMMA : ','; +SEMICOLON : ';'; + +LPAREN : '('; +RPAREN : ')'; +LSQUARE : '['; +RSQUARE : ']'; +LCURLY : '{'; +RCURLY : '}'; + +EQUAL : '=' | '=='; +EQUAL_NS : '<=>'; +NOTEQUAL : '<>' | '!='; +LESSTHANOREQUALTO : '<='; +LESSTHAN : '<'; GREATERTHANOREQUALTO : '>='; -GREATERTHAN : '>'; +GREATERTHAN : '>'; DIVIDE : '/'; -PLUS : '+'; -MINUS : '-'; -STAR : '*'; -MOD : '%'; -DIV : 'DIV'; - -AMPERSAND : '&'; -TILDE : '~'; -BITWISEOR : '|'; +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +MOD : '%'; +DIV : 'DIV'; + +AMPERSAND : '&'; +TILDE : '~'; +BITWISEOR : '|'; CONCATENATE : '||'; -BITWISEXOR : '^'; -QUESTION : '?'; -DOLLAR : '$'; +BITWISEXOR : '^'; +QUESTION : '?'; +DOLLAR : '$'; // LITERALS -fragment -Letter - : 'A'..'Z' - ; - -fragment -HexDigit - : 'A'..'F' - ; - -fragment -Digit - : '0'..'9' - ; - -fragment -Exponent - : 'E' ( PLUS|MINUS )? (Digit)+ - ; - -fragment -RegexComponent - : 'A'..'Z' | '0'..'9' | '_' - | PLUS | STAR | QUESTION | MINUS | DOT - | LPAREN | RPAREN | LSQUARE | RSQUARE | LCURLY | RCURLY - | BITWISEXOR | BITWISEOR | DOLLAR | '!' - ; - -StringLiteral - : ( '\'' ( ~('\''|'\\') | ('\\' .) )* '\'' - | '"' ( ~('"'|'\\') | ('\\' .) )* '"' - )+ - ; - -CharSetLiteral - : StringLiteral - | '0' 'X' (HexDigit|Digit)+ - ; - -IntegralLiteral - : (Digit)+ ('L' | 'S' | 'Y') - ; - -NumberLiteral - : Number ('D' | 'B' 'D') - ; - -ByteLengthLiteral - : (Digit)+ ('B' | 'K' | 'M' | 'G') - ; - -Number - : (Digit)+ ( DOT (Digit)* (Exponent)? | Exponent)? - ; +fragment Letter: 'A' ..'Z'; + +fragment HexDigit: 'A' ..'F'; + +fragment Digit: '0' ..'9'; + +fragment Exponent: 'E' ( PLUS | MINUS)? (Digit)+; + +fragment RegexComponent: + 'A' ..'Z' + | '0' ..'9' + | '_' + | PLUS + | STAR + | QUESTION + | MINUS + | DOT + | LPAREN + | RPAREN + | LSQUARE + | RSQUARE + | LCURLY + | RCURLY + | BITWISEXOR + | BITWISEOR + | DOLLAR + | '!' +; + +StringLiteral: ( '\'' ( ~('\'' | '\\') | ('\\' .))* '\'' | '"' ( ~('"' | '\\') | ('\\' .))* '"')+; + +CharSetLiteral: StringLiteral | '0' 'X' (HexDigit | Digit)+; + +IntegralLiteral: (Digit)+ ('L' | 'S' | 'Y'); + +NumberLiteral: Number ('D' | 'B' 'D'); + +ByteLengthLiteral: (Digit)+ ('B' | 'K' | 'M' | 'G'); + +Number: (Digit)+ ( DOT (Digit)* (Exponent)? | Exponent)?; /* An Identifier can be: @@ -469,42 +461,27 @@ An Identifier can be: - hint name - window name */ -Identifier - : (Letter | Digit) (Letter | Digit | '_')* - | QuotedIdentifier /* though at the language level we allow all Identifiers to be QuotedIdentifiers; +Identifier: + (Letter | Digit) (Letter | Digit | '_')* + | QuotedIdentifier /* though at the language level we allow all Identifiers to be QuotedIdentifiers; at the API level only columns are allowed to be of this form */ | '`' RegexComponent+ '`' - ; +; -QuotedIdentifier - : - '`' ( '``' | ~('`') )* '`' - ; +QuotedIdentifier: '`' ( '``' | ~('`'))* '`'; -CharSetName - : '_' (Letter | Digit | '_' | '-' | '.' | ':' )+ - ; +CharSetName: '_' (Letter | Digit | '_' | '-' | '.' | ':')+; -WS : (' '|'\r'|'\t'|'\n') -> channel(HIDDEN) - ; +WS: (' ' | '\r' | '\t' | '\n') -> channel(HIDDEN); -LINE_COMMENT - : '--' (~('\n'|'\r'))* -> channel(HIDDEN) - ; +LINE_COMMENT: '--' (~('\n' | '\r'))* -> channel(HIDDEN); /* QUERY_HINT有可能是一般注释,这时直接忽略。 也有可能是查询注释,这时用原来的逻辑提取出来 */ -QUERY_HINT - : SHOW_HINT - | HIDDEN_HINT - ; - -SHOW_HINT - : '/*+' (QUERY_HINT | .)*? '*/' ->channel(HIDDEN) - ; - -HIDDEN_HINT - : '/*' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN) - ; +QUERY_HINT: SHOW_HINT | HIDDEN_HINT; + +SHOW_HINT: '/*+' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN); + +HIDDEN_HINT: '/*' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN); \ No newline at end of file diff --git a/sql/hive/v2/HiveParser.g4 b/sql/hive/v2/HiveParser.g4 index 5d44d39896..d05e85402b 100644 --- a/sql/hive/v2/HiveParser.g4 +++ b/sql/hive/v2/HiveParser.g4 @@ -17,40 +17,41 @@ @author wyruweso based on the Hive 3.1.2 grammar by Canwei He */ + +// $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 HiveParser; import SelectClauseParser, FromClauseParser, IdentifiersParser; options { - tokenVocab=HiveLexer; + tokenVocab = HiveLexer; } // starting rule statements - : (statement statementSeparator)* EOF - ; + : (statement statementSeparator)* EOF + ; statementSeparator - : SEMICOLON - | - ; + : SEMICOLON + | + ; empty - : statementSeparator - ; + : statementSeparator + ; statement - : explainStatement - | execStatement - ; + : explainStatement + | execStatement + ; explainStatement - : KW_EXPLAIN ( - explainOption* execStatement - | KW_REWRITE queryStatementExpression - ) - ; + : KW_EXPLAIN (explainOption* execStatement | KW_REWRITE queryStatementExpression) + ; explainOption : KW_EXTENDED @@ -98,35 +99,22 @@ replicationClause ; exportStatement - : KW_EXPORT - KW_TABLE tableOrPartition - KW_TO StringLiteral - replicationClause? + : KW_EXPORT KW_TABLE tableOrPartition KW_TO StringLiteral replicationClause? ; importStatement - : KW_IMPORT - (KW_EXTERNAL? KW_TABLE tableOrPartition)? - KW_FROM (path=StringLiteral) - tableLocation? + : KW_IMPORT (KW_EXTERNAL? KW_TABLE tableOrPartition)? KW_FROM (path = StringLiteral) tableLocation? ; replDumpStatement - : KW_REPL KW_DUMP - identifier (DOT identifier)? - (KW_FROM Number - (KW_TO Number)? - (KW_LIMIT Number)? - )? - (KW_WITH replConfigs)? + : KW_REPL KW_DUMP identifier (DOT identifier)? ( + KW_FROM Number (KW_TO Number)? (KW_LIMIT Number)? + )? (KW_WITH replConfigs)? ; replLoadStatement - : KW_REPL KW_LOAD - (identifier (DOT identifier)?)? - KW_FROM StringLiteral - (KW_WITH replConfigs)? - ; + : KW_REPL KW_LOAD (identifier (DOT identifier)?)? KW_FROM StringLiteral (KW_WITH replConfigs)? + ; replConfigs : LPAREN replConfigsList RPAREN @@ -137,10 +125,8 @@ replConfigsList ; replStatusStatement - : KW_REPL KW_STATUS - identifier (DOT identifier)? - (KW_WITH replConfigs)? - ; + : KW_REPL KW_STATUS identifier (DOT identifier)? (KW_WITH replConfigs)? + ; ddlStatement : createDatabaseStatement @@ -215,65 +201,46 @@ orReplace ; createDatabaseStatement - : KW_CREATE (KW_DATABASE|KW_SCHEMA) - ifNotExists? - identifier - databaseComment? - dbLocation? - (KW_WITH KW_DBPROPERTIES dbProperties)? + : KW_CREATE (KW_DATABASE | KW_SCHEMA) ifNotExists? identifier databaseComment? dbLocation? ( + KW_WITH KW_DBPROPERTIES dbProperties + )? ; dbLocation - : - KW_LOCATION StringLiteral + : KW_LOCATION StringLiteral ; dbProperties - : - LPAREN dbPropertiesList RPAREN + : LPAREN dbPropertiesList RPAREN ; dbPropertiesList - : - keyValueProperty (COMMA keyValueProperty)* + : keyValueProperty (COMMA keyValueProperty)* ; - switchDatabaseStatement : KW_USE identifier ; dropDatabaseStatement - : KW_DROP (KW_DATABASE|KW_SCHEMA) ifExists? identifier restrictOrCascade? + : KW_DROP (KW_DATABASE | KW_SCHEMA) ifExists? identifier restrictOrCascade? ; databaseComment - : KW_COMMENT StringLiteral ; createTableStatement - : KW_CREATE KW_TEMPORARY? KW_EXTERNAL? KW_TABLE ifNotExists? tableName - ( KW_LIKE tableName - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - | (LPAREN columnNameTypeOrConstraintList RPAREN)? - tableComment? - tablePartition? - tableBuckets? - tableSkewed? - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - (KW_AS selectStatementWithCTE)? - ) + : KW_CREATE KW_TEMPORARY? KW_EXTERNAL? KW_TABLE ifNotExists? tableName ( + KW_LIKE tableName tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? + | (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? tablePartition? tableBuckets? tableSkewed? tableRowFormat? tableFileFormat? + tableLocation? tablePropertiesPrefixed? (KW_AS selectStatementWithCTE)? + ) ; truncateTableStatement - : KW_TRUNCATE KW_TABLE tablePartitionPrefix (KW_COLUMNS LPAREN columnNameList RPAREN)?; + : KW_TRUNCATE KW_TABLE tablePartitionPrefix (KW_COLUMNS LPAREN columnNameList RPAREN)? + ; dropTableStatement : KW_DROP KW_TABLE ifExists? tableName KW_PURGE? replicationClause? @@ -283,7 +250,7 @@ alterStatement : KW_ALTER KW_TABLE tableName alterTableStatementSuffix | KW_ALTER KW_VIEW tableName KW_AS? alterViewStatementSuffix | KW_ALTER KW_MATERIALIZED KW_VIEW tableName alterMaterializedViewStatementSuffix - | KW_ALTER (KW_DATABASE|KW_SCHEMA) alterDatabaseStatementSuffix + | KW_ALTER (KW_DATABASE | KW_SCHEMA) alterDatabaseStatementSuffix | KW_ALTER KW_INDEX alterIndexStatementSuffix ; @@ -305,24 +272,24 @@ alterTableStatementSuffix ; alterTblPartitionStatementSuffix - : alterStatementSuffixFileFormat - | alterStatementSuffixLocation - | alterStatementSuffixMergeFiles - | alterStatementSuffixSerdeProperties - | alterStatementSuffixRenamePart - | alterStatementSuffixBucketNum - | alterTblPartitionStatementSuffixSkewedLocation - | alterStatementSuffixClusterbySortby - | alterStatementSuffixCompact - | alterStatementSuffixUpdateStatsCol - | alterStatementSuffixUpdateStats - | alterStatementSuffixRenameCol - | alterStatementSuffixAddCol - ; + : alterStatementSuffixFileFormat + | alterStatementSuffixLocation + | alterStatementSuffixMergeFiles + | alterStatementSuffixSerdeProperties + | alterStatementSuffixRenamePart + | alterStatementSuffixBucketNum + | alterTblPartitionStatementSuffixSkewedLocation + | alterStatementSuffixClusterbySortby + | alterStatementSuffixCompact + | alterStatementSuffixUpdateStatsCol + | alterStatementSuffixUpdateStats + | alterStatementSuffixRenameCol + | alterStatementSuffixAddCol + ; alterStatementPartitionKeyType - : KW_PARTITION KW_COLUMN LPAREN columnNameType RPAREN - ; + : KW_PARTITION KW_COLUMN LPAREN columnNameType RPAREN + ; alterViewStatementSuffix : alterViewSuffixProperties @@ -364,19 +331,23 @@ alterStatementSuffixAddCol ; alterStatementSuffixAddConstraint - : KW_ADD (alterForeignKeyWithName | alterConstraintWithName) - ; + : KW_ADD (alterForeignKeyWithName | alterConstraintWithName) + ; alterStatementSuffixDropConstraint - : KW_DROP KW_CONSTRAINT identifier - ; + : KW_DROP KW_CONSTRAINT identifier + ; alterStatementSuffixRenameCol - : KW_CHANGE KW_COLUMN? identifier identifier colType alterColumnConstraint? (KW_COMMENT StringLiteral)? alterStatementChangeColPosition? restrictOrCascade? + : KW_CHANGE KW_COLUMN? identifier identifier colType alterColumnConstraint? ( + KW_COMMENT StringLiteral + )? alterStatementChangeColPosition? restrictOrCascade? ; alterStatementSuffixUpdateStatsCol - : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties (KW_COMMENT StringLiteral)? + : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties ( + KW_COMMENT StringLiteral + )? ; alterStatementSuffixUpdateStats @@ -384,7 +355,8 @@ alterStatementSuffixUpdateStats ; alterStatementChangeColPosition - : first=KW_FIRST|KW_AFTER identifier + : first = KW_FIRST + | KW_AFTER identifier ; alterStatementSuffixAddPartitions @@ -439,23 +411,22 @@ alterStatementSuffixSerdeProperties ; alterIndexStatementSuffix - : identifier KW_ON tableName - partitionSpec? - KW_REBUILD; + : identifier KW_ON tableName partitionSpec? KW_REBUILD + ; alterStatementSuffixFileFormat - : KW_SET KW_FILEFORMAT fileFormat - ; + : KW_SET KW_FILEFORMAT fileFormat + ; alterStatementSuffixClusterbySortby - : KW_NOT KW_CLUSTERED - | KW_NOT KW_SORTED - | tableBuckets - ; + : KW_NOT KW_CLUSTERED + | KW_NOT KW_SORTED + | tableBuckets + ; alterTblPartitionStatementSuffixSkewedLocation - : KW_SET KW_SKEWED KW_LOCATION skewedLocations - ; + : KW_SET KW_SKEWED KW_LOCATION skewedLocations + ; skewedLocations : LPAREN skewedLocationsList RPAREN @@ -470,15 +441,14 @@ skewedLocationMap ; alterStatementSuffixLocation - : KW_SET KW_LOCATION StringLiteral - ; - + : KW_SET KW_LOCATION StringLiteral + ; alterStatementSuffixSkewedby - : tableSkewed - | KW_NOT KW_SKEWED - | KW_NOT storedAsDirs - ; + : tableSkewed + | KW_NOT KW_SKEWED + | KW_NOT storedAsDirs + ; alterStatementSuffixExchangePartition : KW_EXCHANGE partitionSpec KW_WITH KW_TABLE tableName @@ -489,7 +459,9 @@ alterStatementSuffixRenamePart ; alterStatementSuffixStatsPart - : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties (KW_COMMENT StringLiteral)? + : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties ( + KW_COMMENT StringLiteral + )? ; alterStatementSuffixMergeFiles @@ -501,30 +473,28 @@ alterStatementSuffixBucketNum ; createIndexStatement - : KW_CREATE KW_INDEX identifier KW_ON KW_TABLE tableName columnParenthesesList KW_AS StringLiteral - (KW_WITH KW_DEFERRED KW_REBUILD)? - (KW_IDXPROPERTIES tableProperties)? - (KW_IN KW_TABLE tableName)? - (KW_PARTITIONED KW_BY columnParenthesesList)? - (tableRowFormat? tableFileFormat)? - (KW_LOCATION locationPath)? - tablePropertiesPrefixed? - tableComment?; + : KW_CREATE KW_INDEX identifier KW_ON KW_TABLE tableName columnParenthesesList KW_AS StringLiteral ( + KW_WITH KW_DEFERRED KW_REBUILD + )? (KW_IDXPROPERTIES tableProperties)? (KW_IN KW_TABLE tableName)? ( + KW_PARTITIONED KW_BY columnParenthesesList + )? (tableRowFormat? tableFileFormat)? (KW_LOCATION locationPath)? tablePropertiesPrefixed? tableComment? + ; locationPath : identifier (DOT identifier)* ; dropIndexStatement - : KW_DROP KW_INDEX identifier KW_ON tableName; + : KW_DROP KW_INDEX identifier KW_ON tableName + ; tablePartitionPrefix - : tableName partitionSpec? - ; + : tableName partitionSpec? + ; blocking - : KW_AND KW_WAIT - ; + : KW_AND KW_WAIT + ; alterStatementSuffixCompact : KW_COMPACT StringLiteral blocking? (KW_WITH KW_OVERWRITE KW_TBLPROPERTIES tableProperties)? @@ -535,7 +505,9 @@ alterStatementSuffixSetOwner ; fileFormat - : KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral KW_SERDE StringLiteral (KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral)? + : KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral KW_SERDE StringLiteral ( + KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral + )? | identifier ; @@ -544,15 +516,10 @@ inputFileFormat ; tabTypeExpr - : identifier (DOT identifier)? - ( identifier (DOT - ( KW_ELEM_TYPE - | KW_KEY_TYPE - | KW_VALUE_TYPE - | identifier ) - )* - )? - ; + : identifier (DOT identifier)? ( + identifier (DOT ( KW_ELEM_TYPE | KW_KEY_TYPE | KW_VALUE_TYPE | identifier))* + )? + ; partTypeExpr : tabTypeExpr partitionSpec? @@ -563,51 +530,52 @@ tabPartColTypeExpr ; descStatement - : (KW_DESCRIBE|KW_DESC) - ( - (KW_DATABASE|KW_SCHEMA) KW_EXTENDED? identifier - | KW_FUNCTION KW_EXTENDED? descFuncNames - | ((KW_FORMATTED|KW_EXTENDED) tabPartColTypeExpr) - | tabPartColTypeExpr + : (KW_DESCRIBE | KW_DESC) ( + (KW_DATABASE | KW_SCHEMA) KW_EXTENDED? identifier + | KW_FUNCTION KW_EXTENDED? descFuncNames + | ((KW_FORMATTED | KW_EXTENDED) tabPartColTypeExpr) + | tabPartColTypeExpr ) ; analyzeStatement - : KW_ANALYZE KW_TABLE (tableOrPartition) - ( KW_COMPUTE KW_STATISTICS (KW_NOSCAN | (KW_FOR KW_COLUMNS columnNameList?))? - | KW_CACHE KW_METADATA - ) + : KW_ANALYZE KW_TABLE (tableOrPartition) ( + KW_COMPUTE KW_STATISTICS (KW_NOSCAN | (KW_FOR KW_COLUMNS columnNameList?))? + | KW_CACHE KW_METADATA + ) ; showStatement - : KW_SHOW (KW_DATABASES|KW_SCHEMAS) (KW_LIKE showStmtIdentifier)? - | KW_SHOW KW_TABLES ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_VIEWS ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_MATERIALIZED KW_VIEWS ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_COLUMNS (KW_FROM|KW_IN) tableName ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_FUNCTIONS (KW_LIKE showFunctionIdentifier|showFunctionIdentifier)? + : KW_SHOW (KW_DATABASES | KW_SCHEMAS) (KW_LIKE showStmtIdentifier)? + | KW_SHOW KW_TABLES ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_VIEWS ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_MATERIALIZED KW_VIEWS ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_COLUMNS (KW_FROM | KW_IN) tableName ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_FUNCTIONS (KW_LIKE showFunctionIdentifier | showFunctionIdentifier)? | KW_SHOW KW_PARTITIONS tableName partitionSpec? - | KW_SHOW KW_CREATE ( - (KW_DATABASE|KW_SCHEMA) identifier - | - KW_TABLE tableName - ) - | KW_SHOW KW_TABLE KW_EXTENDED ((KW_FROM|KW_IN) identifier)? KW_LIKE showStmtIdentifier partitionSpec? + | KW_SHOW KW_CREATE ((KW_DATABASE | KW_SCHEMA) identifier | KW_TABLE tableName) + | KW_SHOW KW_TABLE KW_EXTENDED ((KW_FROM | KW_IN) identifier)? KW_LIKE showStmtIdentifier partitionSpec? | KW_SHOW KW_TBLPROPERTIES tableName (LPAREN StringLiteral RPAREN)? - | KW_SHOW KW_LOCKS - ( - (KW_DATABASE|KW_SCHEMA) identifier KW_EXTENDED? - | - partTypeExpr? KW_EXTENDED? - ) + | KW_SHOW KW_LOCKS ( + (KW_DATABASE | KW_SCHEMA) identifier KW_EXTENDED? + | partTypeExpr? KW_EXTENDED? + ) | KW_SHOW KW_COMPACTIONS | KW_SHOW KW_TRANSACTIONS | KW_SHOW KW_CONF StringLiteral - | KW_SHOW KW_RESOURCE - ( - (KW_PLAN identifier) - | KW_PLANS - ) + | KW_SHOW KW_RESOURCE ( (KW_PLAN identifier) | KW_PLANS) ; lockStatement @@ -615,11 +583,12 @@ lockStatement ; lockDatabase - : KW_LOCK (KW_DATABASE|KW_SCHEMA) identifier lockMode + : KW_LOCK (KW_DATABASE | KW_SCHEMA) identifier lockMode ; lockMode - : KW_SHARED | KW_EXCLUSIVE + : KW_SHARED + | KW_EXCLUSIVE ; unlockStatement @@ -627,7 +596,7 @@ unlockStatement ; unlockDatabase - : KW_UNLOCK (KW_DATABASE|KW_SCHEMA) identifier + : KW_UNLOCK (KW_DATABASE | KW_SCHEMA) identifier ; createRoleStatement @@ -639,10 +608,7 @@ dropRoleStatement ; grantPrivileges - : KW_GRANT privilegeList - privilegeObject? - KW_TO principalSpecification - withGrantOption? + : KW_GRANT privilegeList privilegeObject? KW_TO principalSpecification withGrantOption? ; revokePrivileges @@ -661,7 +627,6 @@ showRoleGrants : KW_SHOW KW_ROLE KW_GRANT principalName ; - showRoles : KW_SHOW KW_ROLES ; @@ -671,14 +636,7 @@ showCurrentRole ; setRole - : KW_SET KW_ROLE - ( - KW_ALL - | - KW_NONE - | - identifier - ) + : KW_SET KW_ROLE (KW_ALL | KW_NONE | identifier) ; showGrants @@ -689,7 +647,6 @@ showRolePrincipals : KW_SHOW KW_PRINCIPALS identifier ; - privilegeIncludeColObject : KW_ALL | privObjectCols @@ -701,14 +658,14 @@ privilegeObject // database or table type. Type is optional, default type is table privObject - : (KW_DATABASE|KW_SCHEMA) identifier + : (KW_DATABASE | KW_SCHEMA) identifier | KW_TABLE? tableName partitionSpec? | KW_URI StringLiteral | KW_SERVER identifier ; privObjectCols - : (KW_DATABASE|KW_SCHEMA) identifier + : (KW_DATABASE | KW_SCHEMA) identifier | KW_TABLE? tableName (LPAREN columnNameList RPAREN)? partitionSpec? | KW_URI StringLiteral | KW_SERVER identifier @@ -751,41 +708,41 @@ withGrantOption grantOptionFor : KW_GRANT KW_OPTION KW_FOR -; + ; adminOptionFor : KW_ADMIN KW_OPTION KW_FOR -; + ; withAdminOption : KW_WITH KW_ADMIN KW_OPTION ; metastoreCheck - : KW_MSCK KW_REPAIR? - (KW_TABLE tableName - ((KW_ADD | KW_DROP | KW_SYNC) KW_PARTITIONS)? | - partitionSpec?) + : KW_MSCK KW_REPAIR? ( + KW_TABLE tableName ((KW_ADD | KW_DROP | KW_SYNC) KW_PARTITIONS)? + | partitionSpec? + ) ; resourceList - : - resource (COMMA resource)* - ; + : resource (COMMA resource)* + ; resource - : resourceType StringLiteral - ; + : resourceType StringLiteral + ; resourceType - : KW_JAR - | KW_FILE - | KW_ARCHIVE - ; + : KW_JAR + | KW_FILE + | KW_ARCHIVE + ; createFunctionStatement - : KW_CREATE KW_TEMPORARY? KW_FUNCTION functionIdentifier KW_AS StringLiteral - (KW_USING resourceList)? + : KW_CREATE KW_TEMPORARY? KW_FUNCTION functionIdentifier KW_AS StringLiteral ( + KW_USING resourceList + )? ; dropFunctionStatement @@ -797,8 +754,7 @@ reloadFunctionStatement ; createMacroStatement - : KW_CREATE KW_TEMPORARY KW_MACRO Identifier - LPAREN columnNameTypeList? RPAREN expression + : KW_CREATE KW_TEMPORARY KW_MACRO Identifier LPAREN columnNameTypeList? RPAREN expression ; dropMacroStatement @@ -806,16 +762,12 @@ dropMacroStatement ; createViewStatement - : KW_CREATE orReplace? KW_VIEW ifNotExists? tableName - (LPAREN columnNameCommentList RPAREN)? tableComment? viewPartition? - tablePropertiesPrefixed? - KW_AS - selectStatementWithCTE + : KW_CREATE orReplace? KW_VIEW ifNotExists? tableName (LPAREN columnNameCommentList RPAREN)? tableComment? viewPartition? tablePropertiesPrefixed? + KW_AS selectStatementWithCTE ; createMaterializedViewStatement - : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? tableName - rewriteDisabled? tableComment? tableRowFormat? tableFileFormat? tableLocation? + : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? tableName rewriteDisabled? tableComment? tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? KW_AS selectStatementWithCTE ; @@ -850,7 +802,9 @@ tablePartition ; tableBuckets - : KW_CLUSTERED KW_BY LPAREN columnNameList RPAREN (KW_SORTED KW_BY LPAREN columnNameOrderList RPAREN)? KW_INTO Number KW_BUCKETS + : KW_CLUSTERED KW_BY LPAREN columnNameList RPAREN ( + KW_SORTED KW_BY LPAREN columnNameOrderList RPAREN + )? KW_INTO Number KW_BUCKETS ; tableSkewed @@ -875,7 +829,8 @@ rowFormatSerde ; rowFormatDelimited - : KW_ROW KW_FORMAT KW_DELIMITED tableRowFormatFieldIdentifier? tableRowFormatCollItemsIdentifier? tableRowFormatMapKeysIdentifier? tableRowFormatLinesIdentifier? tableRowNullFormat? + : KW_ROW KW_FORMAT KW_DELIMITED tableRowFormatFieldIdentifier? tableRowFormatCollItemsIdentifier? tableRowFormatMapKeysIdentifier? + tableRowFormatLinesIdentifier? tableRowNullFormat? ; tableRowFormat @@ -923,11 +878,13 @@ tableRowFormatLinesIdentifier tableRowNullFormat : KW_NULL KW_DEFINED KW_AS StringLiteral ; + tableFileFormat - : KW_STORED KW_AS KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral (KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral)? - | KW_STORED KW_BY StringLiteral - (KW_WITH KW_SERDEPROPERTIES tableProperties)? - | KW_STORED KW_AS identifier + : KW_STORED KW_AS KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral ( + KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral + )? + | KW_STORED KW_BY StringLiteral (KW_WITH KW_SERDEPROPERTIES tableProperties)? + | KW_STORED KW_AS identifier ; tableLocation @@ -987,8 +944,8 @@ enforcedSpecification ; relySpecification - : KW_RELY - | (KW_NORELY)? + : KW_RELY + | (KW_NORELY)? ; createConstraint @@ -1000,15 +957,15 @@ alterConstraintWithName ; pkConstraint - : tableConstraintPrimaryKey pkCols=columnParenthesesList + : tableConstraintPrimaryKey pkCols = columnParenthesesList ; createForeignKey - : (KW_CONSTRAINT identifier)? KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsCreate? + : (KW_CONSTRAINT identifier)? KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsCreate? ; alterForeignKeyWithName - : KW_CONSTRAINT identifier KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsAlter? + : KW_CONSTRAINT identifier KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsAlter? ; skewedValueElement @@ -1068,13 +1025,13 @@ columnNameType ; columnNameTypeOrConstraint - : ( tableConstraint ) - | ( columnNameTypeConstraint ) + : (tableConstraint) + | ( columnNameTypeConstraint) ; tableConstraint - : ( createForeignKey ) - | ( createConstraint ) + : (createForeignKey) + | ( createConstraint) ; columnNameTypeConstraint @@ -1082,8 +1039,8 @@ columnNameTypeConstraint ; columnConstraint - : ( foreignKeyConstraint ) - | ( colConstraint ) + : (foreignKeyConstraint) + | ( colConstraint) ; foreignKeyConstraint @@ -1095,8 +1052,8 @@ colConstraint ; alterColumnConstraint - : ( alterForeignKeyConstraint ) - | ( alterColConstraint ) + : (alterForeignKeyConstraint) + | ( alterColConstraint) ; alterForeignKeyConstraint @@ -1191,9 +1148,7 @@ queryStatementExpression /* Would be nice to do this as a gated semantic perdicate But the predicate gets pushed as a lookahead decision. Calling rule doesnot know about topLevel - */ - withClause? - queryStatementExpressionBody + */ withClause? queryStatementExpressionBody ; queryStatementExpressionBody @@ -1210,10 +1165,8 @@ cteStatement ; fromStatement - : (singleFromStatement) - (setOperator singleFromStatement)* - ; - + : (singleFromStatement) (setOperator singleFromStatement)* + ; singleFromStatement : fromClause body+ @@ -1226,27 +1179,21 @@ The valuesClause rule below ensures that the parse tree for very similar to the tree for "insert into table FOO select a,b from BAR". */ regularBody - : insertClause ( selectStatement | valuesClause) + : insertClause (selectStatement | valuesClause) | selectStatement ; atomSelectStatement - : selectClause - fromClause? - whereClause? - groupByClause? - havingClause? - window_clause? + : selectClause fromClause? whereClause? groupByClause? havingClause? window_clause? | LPAREN selectStatement RPAREN ; selectStatement - : atomSelectStatement setOpSelectStatement? orderByClause? clusterByClause? distributeByClause? sortByClause? limitClause? + : atomSelectStatement setOpSelectStatement? orderByClause? clusterByClause? distributeByClause? sortByClause? limitClause? ; setOpSelectStatement - : - (setOperator atomSelectStatement)+ + : (setOperator atomSelectStatement)+ ; selectStatementWithCTE @@ -1254,30 +1201,10 @@ selectStatementWithCTE ; body - : insertClause - selectClause - lateralView? - whereClause? - groupByClause? - havingClause? - window_clause? - orderByClause? - clusterByClause? - distributeByClause? - sortByClause? - limitClause? - | - selectClause - lateralView? - whereClause? - groupByClause? - havingClause? - window_clause? - orderByClause? - clusterByClause? - distributeByClause? - sortByClause? - limitClause? + : insertClause selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? orderByClause? clusterByClause? + distributeByClause? sortByClause? limitClause? + | selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? orderByClause? clusterByClause? distributeByClause? + sortByClause? limitClause? ; insertClause @@ -1286,97 +1213,99 @@ insertClause ; destination - : KW_LOCAL? KW_DIRECTORY StringLiteral tableRowFormat? tableFileFormat? - | KW_TABLE tableOrPartition - ; + : KW_LOCAL? KW_DIRECTORY StringLiteral tableRowFormat? tableFileFormat? + | KW_TABLE tableOrPartition + ; limitClause - : KW_LIMIT ((Number COMMA)? Number) - | KW_LIMIT Number KW_OFFSET Number - ; + : KW_LIMIT ((Number COMMA)? Number) + | KW_LIMIT Number KW_OFFSET Number + ; //DELETE FROM WHERE ...; deleteStatement - : KW_DELETE KW_FROM tableName whereClause? - ; + : KW_DELETE KW_FROM tableName whereClause? + ; /*SET = (3 + col2)*/ columnAssignmentClause - : tableOrColumn EQUAL expression - ; + : tableOrColumn EQUAL expression + ; /*SET col1 = 5, col2 = (4 + col4), ...*/ setColumnsClause - : KW_SET columnAssignmentClause (COMMA columnAssignmentClause)* - ; + : KW_SET columnAssignmentClause (COMMA columnAssignmentClause)* + ; /* UPDATE SET col1 = val1, col2 = val2... WHERE ... */ updateStatement - : KW_UPDATE tableName setColumnsClause whereClause? - ; + : KW_UPDATE tableName setColumnsClause whereClause? + ; /* BEGIN user defined transaction boundaries; follows SQL 2003 standard exactly except for addition of "setAutoCommitStatement" which is not in the standard doc but is supported by most SQL engines. */ sqlTransactionStatement - : startTransactionStatement - | commitStatement - | rollbackStatement - | setAutoCommitStatement - ; + : startTransactionStatement + | commitStatement + | rollbackStatement + | setAutoCommitStatement + ; startTransactionStatement - : KW_START KW_TRANSACTION ( transactionMode ( COMMA transactionMode )* )? - ; + : KW_START KW_TRANSACTION (transactionMode ( COMMA transactionMode)*)? + ; transactionMode - : isolationLevel - | transactionAccessMode - ; + : isolationLevel + | transactionAccessMode + ; transactionAccessMode - : KW_READ KW_ONLY - | KW_READ KW_WRITE - ; + : KW_READ KW_ONLY + | KW_READ KW_WRITE + ; isolationLevel - : KW_ISOLATION KW_LEVEL levelOfIsolation - ; + : KW_ISOLATION KW_LEVEL levelOfIsolation + ; /*READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE may be supported later*/ levelOfIsolation - : KW_SNAPSHOT - ; + : KW_SNAPSHOT + ; commitStatement - : KW_COMMIT KW_WORK? - ; + : KW_COMMIT KW_WORK? + ; rollbackStatement - : KW_ROLLBACK KW_WORK? - ; + : KW_ROLLBACK KW_WORK? + ; + setAutoCommitStatement - : KW_SET KW_AUTOCOMMIT booleanValueTok - ; + : KW_SET KW_AUTOCOMMIT booleanValueTok + ; + /* END user defined transaction boundaries */ abortTransactionStatement - : KW_ABORT KW_TRANSACTIONS Number+ - ; - + : KW_ABORT KW_TRANSACTIONS Number+ + ; /* BEGIN SQL Merge statement */ mergeStatement - : KW_MERGE KW_INTO tableName (KW_AS? identifier)? KW_USING joinSourcePart KW_ON expression whenClauses - ; + : KW_MERGE KW_INTO tableName (KW_AS? identifier)? KW_USING joinSourcePart KW_ON expression whenClauses + ; + /* Allow 0,1 or 2 WHEN MATCHED clauses and 0 or 1 WHEN NOT MATCHED Each WHEN clause may have AND . @@ -1384,25 +1313,30 @@ If 2 WHEN MATCHED clauses are present, 1 must be UPDATE the other DELETE and the must have AND */ whenClauses - : (whenMatchedAndClause|whenMatchedThenClause)* whenNotMatchedClause? - ; + : (whenMatchedAndClause | whenMatchedThenClause)* whenNotMatchedClause? + ; + whenNotMatchedClause - : KW_WHEN KW_NOT KW_MATCHED (KW_AND expression)? KW_THEN KW_INSERT KW_VALUES valueRowConstructor - ; + : KW_WHEN KW_NOT KW_MATCHED (KW_AND expression)? KW_THEN KW_INSERT KW_VALUES valueRowConstructor + ; + whenMatchedAndClause - : KW_WHEN KW_MATCHED KW_AND expression KW_THEN updateOrDelete - ; + : KW_WHEN KW_MATCHED KW_AND expression KW_THEN updateOrDelete + ; + whenMatchedThenClause - : KW_WHEN KW_MATCHED KW_THEN updateOrDelete - ; + : KW_WHEN KW_MATCHED KW_THEN updateOrDelete + ; + updateOrDelete - : KW_UPDATE setColumnsClause - | KW_DELETE - ; + : KW_UPDATE setColumnsClause + | KW_DELETE + ; + /* END SQL Merge statement */ killQueryStatement - : KW_KILL KW_QUERY StringLiteral+ - ; + : KW_KILL KW_QUERY StringLiteral+ + ; \ No newline at end of file diff --git a/sql/hive/v2/IdentifiersParser.g4 b/sql/hive/v2/IdentifiersParser.g4 index bf0064297c..6a5c766e52 100644 --- a/sql/hive/v2/IdentifiersParser.g4 +++ b/sql/hive/v2/IdentifiersParser.g4 @@ -16,6 +16,10 @@ @author Canwei He */ + +// $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 IdentifiersParser; //----------------------------------------------------------------------------------- @@ -38,29 +42,24 @@ groupByEmpty // standard rollup syntax rollupStandard - : (KW_ROLLUP | KW_CUBE) - LPAREN expression ( COMMA expression)* RPAREN + : (KW_ROLLUP | KW_CUBE) LPAREN expression (COMMA expression)* RPAREN ; // old hive rollup syntax rollupOldSyntax - : expressionsNotInParenthesis - (KW_WITH KW_ROLLUP | KW_WITH KW_CUBE) ? - (KW_GROUPING KW_SETS - LPAREN groupingSetExpression ( COMMA groupingSetExpression)* RPAREN ) ? + : expressionsNotInParenthesis (KW_WITH KW_ROLLUP | KW_WITH KW_CUBE)? ( + KW_GROUPING KW_SETS LPAREN groupingSetExpression (COMMA groupingSetExpression)* RPAREN + )? ; - groupingSetExpression - : groupingSetExpressionMultiple - | groupingExpressionSingle - ; + : groupingSetExpressionMultiple + | groupingExpressionSingle + ; groupingSetExpressionMultiple - : LPAREN - expression? (COMMA expression)* - RPAREN - ; + : LPAREN expression? (COMMA expression)* RPAREN + ; groupingExpressionSingle : expression @@ -101,7 +100,7 @@ columnRefOrderNotInParenthesis // order by a,b orderByClause - : KW_ORDER KW_BY columnRefOrder ( COMMA columnRefOrder)* + : KW_ORDER KW_BY columnRefOrder (COMMA columnRefOrder)* ; clusterByClause @@ -117,61 +116,37 @@ distributeByClause ; sortByClause - : KW_SORT KW_BY - ( - columnRefOrderInParenthesis - | - columnRefOrderNotInParenthesis - ) + : KW_SORT KW_BY (columnRefOrderInParenthesis | columnRefOrderNotInParenthesis) ; // fun(par1, par2, par3) function - : functionName - LPAREN - ( + : functionName LPAREN ( STAR | (KW_DISTINCT | KW_ALL)? (selectExpression (COMMA selectExpression)*)? - ) - RPAREN (KW_OVER window_specification)? + ) RPAREN (KW_OVER window_specification)? ; functionName : // Keyword IF is also a function name functionIdentifier - | - sql11ReservedKeywordsUsedAsFunctionName + | sql11ReservedKeywordsUsedAsFunctionName ; castExpression - : KW_CAST - LPAREN - expression - KW_AS - primitiveType - RPAREN + : KW_CAST LPAREN expression KW_AS primitiveType RPAREN ; caseExpression - : KW_CASE expression - (KW_WHEN expression KW_THEN expression)+ - (KW_ELSE expression)? - KW_END + : KW_CASE expression (KW_WHEN expression KW_THEN expression)+ (KW_ELSE expression)? KW_END ; whenExpression - : KW_CASE - ( KW_WHEN expression KW_THEN expression)+ - (KW_ELSE expression)? - KW_END + : KW_CASE (KW_WHEN expression KW_THEN expression)+ (KW_ELSE expression)? KW_END ; floorExpression - : KW_FLOOR - LPAREN - expression - (KW_TO floorDateQualifiers)? - RPAREN + : KW_FLOOR LPAREN expression (KW_TO floorDateQualifiers)? RPAREN ; floorDateQualifiers @@ -186,12 +161,7 @@ floorDateQualifiers ; extractExpression - : KW_EXTRACT - LPAREN - timeQualifiers - KW_FROM - expression - RPAREN + : KW_EXTRACT LPAREN timeQualifiers KW_FROM expression RPAREN ; timeQualifiers @@ -401,25 +371,24 @@ booleanValue ; booleanValueTok - : KW_TRUE - | KW_FALSE - ; + : KW_TRUE + | KW_FALSE + ; tableOrPartition - : tableName partitionSpec? - ; + : tableName partitionSpec? + ; partitionSpec - : KW_PARTITION - LPAREN partitionVal (COMMA partitionVal)* RPAREN - ; + : KW_PARTITION LPAREN partitionVal (COMMA partitionVal)* RPAREN + ; partitionVal : identifier (EQUAL constant)? ; dropPartitionSpec - : KW_PARTITION LPAREN dropPartitionVal (COMMA dropPartitionVal )* RPAREN + : KW_PARTITION LPAREN dropPartitionVal (COMMA dropPartitionVal)* RPAREN ; dropPartitionVal @@ -511,24 +480,156 @@ principalIdentifier //If you are not sure, please refer to the SQL2011 column in //http://www.postgresql.org/docs/9.5/static/sql-keywords-appendix.html nonReserved - : KW_ABORT | KW_ADD | KW_ADMIN | KW_AFTER | KW_ANALYZE | KW_ARCHIVE | KW_ASC | KW_BEFORE | KW_BUCKET | KW_BUCKETS - | KW_CASCADE | KW_CHANGE | KW_CHECK | KW_CLUSTER | KW_CLUSTERED | KW_CLUSTERSTATUS | KW_COLLECTION | KW_COLUMNS - | KW_COMMENT | KW_COMPACT | KW_COMPACTIONS | KW_COMPUTE | KW_CONCATENATE | KW_CONTINUE | KW_DATA | KW_DAY - | KW_DATABASES | KW_DATETIME | KW_DBPROPERTIES | KW_DEFERRED | KW_DEFINED | KW_DELIMITED | KW_DEPENDENCY - | KW_DESC | KW_DIRECTORIES | KW_DIRECTORY | KW_DISABLE | KW_DISTRIBUTE | KW_DOW | KW_ELEM_TYPE - | KW_ENABLE | KW_ENFORCED | KW_ESCAPED | KW_EXCLUSIVE | KW_EXPLAIN | KW_EXPORT | KW_FIELDS | KW_FILE | KW_FILEFORMAT - | KW_FIRST | KW_FORMAT | KW_FORMATTED | KW_FUNCTIONS | KW_HOUR | KW_IDXPROPERTIES - | KW_INDEX | KW_INDEXES | KW_INPATH | KW_INPUTDRIVER | KW_INPUTFORMAT | KW_ITEMS | KW_JAR | KW_KILL - | KW_KEYS | KW_KEY_TYPE | KW_LAST | KW_LIMIT | KW_OFFSET | KW_LINES | KW_LOAD | KW_LOCATION | KW_LOCK | KW_LOCKS | KW_LOGICAL | KW_LONG - | KW_MAPJOIN | KW_MATERIALIZED | KW_METADATA | KW_MINUTE | KW_MONTH | KW_MSCK | KW_NOSCAN | KW_NULLS - | KW_OPTION | KW_OUTPUTDRIVER | KW_OUTPUTFORMAT | KW_OVERWRITE | KW_OWNER | KW_PARTITIONED | KW_PARTITIONS | KW_PLUS - | KW_PRINCIPALS | KW_PURGE | KW_QUERY | KW_QUARTER | KW_READ | KW_REBUILD | KW_RECORDREADER | KW_RECORDWRITER - | KW_RELOAD | KW_RENAME | KW_REPAIR | KW_REPLACE | KW_REPLICATION | KW_RESTRICT | KW_REWRITE - | KW_ROLE | KW_ROLES | KW_SCHEMA | KW_SCHEMAS | KW_SECOND | KW_SEMI | KW_SERDE | KW_SERDEPROPERTIES | KW_SERVER | KW_SETS | KW_SHARED - | KW_SHOW | KW_SHOW_DATABASE | KW_SKEWED | KW_SORT | KW_SORTED | KW_SSL | KW_STATISTICS | KW_STORED - | KW_STREAMTABLE | KW_STRING | KW_STRUCT | KW_TABLES | KW_TBLPROPERTIES | KW_TEMPORARY | KW_TERMINATED - | KW_TINYINT | KW_TOUCH | KW_TRANSACTIONS | KW_UNARCHIVE | KW_UNDO | KW_UNIONTYPE | KW_UNLOCK | KW_UNSET - | KW_UNSIGNED | KW_URI | KW_USE | KW_UTC | KW_UTCTIMESTAMP | KW_VALUE_TYPE | KW_VIEW | KW_WEEK | KW_WHILE | KW_YEAR + : KW_ABORT + | KW_ADD + | KW_ADMIN + | KW_AFTER + | KW_ANALYZE + | KW_ARCHIVE + | KW_ASC + | KW_BEFORE + | KW_BUCKET + | KW_BUCKETS + | KW_CASCADE + | KW_CHANGE + | KW_CHECK + | KW_CLUSTER + | KW_CLUSTERED + | KW_CLUSTERSTATUS + | KW_COLLECTION + | KW_COLUMNS + | KW_COMMENT + | KW_COMPACT + | KW_COMPACTIONS + | KW_COMPUTE + | KW_CONCATENATE + | KW_CONTINUE + | KW_DATA + | KW_DAY + | KW_DATABASES + | KW_DATETIME + | KW_DBPROPERTIES + | KW_DEFERRED + | KW_DEFINED + | KW_DELIMITED + | KW_DEPENDENCY + | KW_DESC + | KW_DIRECTORIES + | KW_DIRECTORY + | KW_DISABLE + | KW_DISTRIBUTE + | KW_DOW + | KW_ELEM_TYPE + | KW_ENABLE + | KW_ENFORCED + | KW_ESCAPED + | KW_EXCLUSIVE + | KW_EXPLAIN + | KW_EXPORT + | KW_FIELDS + | KW_FILE + | KW_FILEFORMAT + | KW_FIRST + | KW_FORMAT + | KW_FORMATTED + | KW_FUNCTIONS + | KW_HOUR + | KW_IDXPROPERTIES + | KW_INDEX + | KW_INDEXES + | KW_INPATH + | KW_INPUTDRIVER + | KW_INPUTFORMAT + | KW_ITEMS + | KW_JAR + | KW_KILL + | KW_KEYS + | KW_KEY_TYPE + | KW_LAST + | KW_LIMIT + | KW_OFFSET + | KW_LINES + | KW_LOAD + | KW_LOCATION + | KW_LOCK + | KW_LOCKS + | KW_LOGICAL + | KW_LONG + | KW_MAPJOIN + | KW_MATERIALIZED + | KW_METADATA + | KW_MINUTE + | KW_MONTH + | KW_MSCK + | KW_NOSCAN + | KW_NULLS + | KW_OPTION + | KW_OUTPUTDRIVER + | KW_OUTPUTFORMAT + | KW_OVERWRITE + | KW_OWNER + | KW_PARTITIONED + | KW_PARTITIONS + | KW_PLUS + | KW_PRINCIPALS + | KW_PURGE + | KW_QUERY + | KW_QUARTER + | KW_READ + | KW_REBUILD + | KW_RECORDREADER + | KW_RECORDWRITER + | KW_RELOAD + | KW_RENAME + | KW_REPAIR + | KW_REPLACE + | KW_REPLICATION + | KW_RESTRICT + | KW_REWRITE + | KW_ROLE + | KW_ROLES + | KW_SCHEMA + | KW_SCHEMAS + | KW_SECOND + | KW_SEMI + | KW_SERDE + | KW_SERDEPROPERTIES + | KW_SERVER + | KW_SETS + | KW_SHARED + | KW_SHOW + | KW_SHOW_DATABASE + | KW_SKEWED + | KW_SORT + | KW_SORTED + | KW_SSL + | KW_STATISTICS + | KW_STORED + | KW_STREAMTABLE + | KW_STRING + | KW_STRUCT + | KW_TABLES + | KW_TBLPROPERTIES + | KW_TEMPORARY + | KW_TERMINATED + | KW_TINYINT + | KW_TOUCH + | KW_TRANSACTIONS + | KW_UNARCHIVE + | KW_UNDO + | KW_UNIONTYPE + | KW_UNLOCK + | KW_UNSET + | KW_UNSIGNED + | KW_URI + | KW_USE + | KW_UTC + | KW_UTCTIMESTAMP + | KW_VALUE_TYPE + | KW_VIEW + | KW_WEEK + | KW_WHILE + | KW_YEAR | KW_WORK | KW_TRANSACTION | KW_WRITE @@ -542,8 +643,11 @@ nonReserved | KW_NOVALIDATE | KW_KEY | KW_MATCHED - | KW_REPL | KW_DUMP | KW_STATUS - | KW_CACHE | KW_VIEWS + | KW_REPL + | KW_DUMP + | KW_STATUS + | KW_CACHE + | KW_VIEWS | KW_VECTORIZATION | KW_SUMMARY | KW_OPERATOR @@ -553,12 +657,39 @@ nonReserved | KW_ZONE | KW_DEFAULT | KW_REOPTIMIZATION - | KW_RESOURCE | KW_PLAN | KW_PLANS | KW_QUERY_PARALLELISM | KW_ACTIVATE | KW_MOVE | KW_DO - | KW_POOL | KW_ALLOC_FRACTION | KW_SCHEDULING_POLICY | KW_PATH | KW_MAPPING | KW_WORKLOAD | KW_MANAGEMENT | KW_ACTIVE | KW_UNMANAGED - -; + | KW_RESOURCE + | KW_PLAN + | KW_PLANS + | KW_QUERY_PARALLELISM + | KW_ACTIVATE + | KW_MOVE + | KW_DO + | KW_POOL + | KW_ALLOC_FRACTION + | KW_SCHEDULING_POLICY + | KW_PATH + | KW_MAPPING + | KW_WORKLOAD + | KW_MANAGEMENT + | KW_ACTIVE + | KW_UNMANAGED + ; //The following SQL2011 reserved keywords are used as function name only, but not as identifiers. sql11ReservedKeywordsUsedAsFunctionName - : KW_IF | KW_ARRAY | KW_MAP | KW_BIGINT | KW_BINARY | KW_BOOLEAN | KW_CURRENT_DATE | KW_CURRENT_TIMESTAMP | KW_DATE | KW_DOUBLE | KW_FLOAT | KW_GROUPING | KW_INT | KW_SMALLINT | KW_TIMESTAMP - ; + : KW_IF + | KW_ARRAY + | KW_MAP + | KW_BIGINT + | KW_BINARY + | KW_BOOLEAN + | KW_CURRENT_DATE + | KW_CURRENT_TIMESTAMP + | KW_DATE + | KW_DOUBLE + | KW_FLOAT + | KW_GROUPING + | KW_INT + | KW_SMALLINT + | KW_TIMESTAMP + ; \ No newline at end of file diff --git a/sql/hive/v2/SelectClauseParser.g4 b/sql/hive/v2/SelectClauseParser.g4 index 16281a5a23..56b34ab337 100644 --- a/sql/hive/v2/SelectClauseParser.g4 +++ b/sql/hive/v2/SelectClauseParser.g4 @@ -16,42 +16,41 @@ @author Canwei He */ + +// $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 SelectClauseParser; //----------------------- Rules for parsing selectClause ----------------------------- // select a,b,c ... selectClause - : KW_SELECT QUERY_HINT? (((KW_ALL | KW_DISTINCT)? selectList) - | (KW_TRANSFORM selectTrfmClause)) + : KW_SELECT QUERY_HINT? ( + ((KW_ALL | KW_DISTINCT)? selectList) + | (KW_TRANSFORM selectTrfmClause) + ) | trfmClause ; selectList - : selectItem ( COMMA selectItem )* + : selectItem (COMMA selectItem)* ; selectTrfmClause - : LPAREN selectExpressionList RPAREN - rowFormat? recordWriter? - KW_USING StringLiteral - ( KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)))? - rowFormat? recordReader? + : LPAREN selectExpressionList RPAREN rowFormat? recordWriter? KW_USING StringLiteral ( + KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)) + )? rowFormat? recordReader? ; selectItem : tableAllColumns - | ( expression - ((KW_AS? identifier) | (KW_AS LPAREN identifier (COMMA identifier)* RPAREN))? - ) + | (expression ((KW_AS? identifier) | (KW_AS LPAREN identifier (COMMA identifier)* RPAREN))?) ; trfmClause - : ( KW_MAP selectExpressionList - | KW_REDUCE selectExpressionList ) - rowFormat? recordWriter? - KW_USING StringLiteral - ( KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)))? - rowFormat? recordReader? + : (KW_MAP selectExpressionList | KW_REDUCE selectExpressionList) rowFormat? recordWriter? KW_USING StringLiteral ( + KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)) + )? rowFormat? recordReader? ; selectExpression @@ -65,18 +64,15 @@ selectExpressionList //---------------------- Rules for windowing clauses ------------------------------- window_clause - : - KW_WINDOW window_defn (COMMA window_defn)* + : KW_WINDOW window_defn (COMMA window_defn)* ; window_defn - : - identifier KW_AS window_specification + : identifier KW_AS window_specification ; window_specification - : - (identifier | ( LPAREN identifier? partitioningSpec? window_frame? RPAREN)) + : (identifier | ( LPAREN identifier? partitioningSpec? window_frame? RPAREN)) ; window_frame @@ -85,8 +81,7 @@ window_frame ; window_range_expression - : - KW_ROWS window_frame_start_boundary + : KW_ROWS window_frame_start_boundary | KW_ROWS KW_BETWEEN window_frame_boundary KW_AND window_frame_boundary ; @@ -96,15 +91,13 @@ window_value_expression ; window_frame_start_boundary - : - KW_UNBOUNDED KW_PRECEDING + : KW_UNBOUNDED KW_PRECEDING | KW_CURRENT KW_ROW | Number KW_PRECEDING ; - window_frame_boundary - : - KW_UNBOUNDED (KW_PRECEDING|KW_FOLLOWING) +window_frame_boundary + : KW_UNBOUNDED (KW_PRECEDING | KW_FOLLOWING) | KW_CURRENT KW_ROW - | Number (KW_PRECEDING | KW_FOLLOWING ) - ; + | Number (KW_PRECEDING | KW_FOLLOWING) + ; \ No newline at end of file diff --git a/sql/hive/v3/FromClauseParser.g4 b/sql/hive/v3/FromClauseParser.g4 index 78a48f262f..4d350a118b 100644 --- a/sql/hive/v3/FromClauseParser.g4 +++ b/sql/hive/v3/FromClauseParser.g4 @@ -17,6 +17,9 @@ @author Canwei He */ +// $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 FromClauseParser; //----------------------------------------------------------------------------------- @@ -50,7 +53,6 @@ fromSource | joinSource ; - atomjoinSource : tableSource lateralView* | virtualTableSource lateralView* @@ -60,7 +62,9 @@ atomjoinSource ; joinSource - : atomjoinSource (joinToken joinSourcePart (KW_ON expression | KW_USING columnParenthesesList)?)* + : atomjoinSource ( + joinToken joinSourcePart (KW_ON expression | KW_USING columnParenthesesList)? + )* ; joinSourcePart @@ -84,29 +88,33 @@ joinToken | KW_INNER KW_JOIN | COMMA | KW_CROSS KW_JOIN - | KW_LEFT KW_OUTER? KW_JOIN + | KW_LEFT KW_OUTER? KW_JOIN | KW_RIGHT KW_OUTER? KW_JOIN - | KW_FULL KW_OUTER? KW_JOIN + | KW_FULL KW_OUTER? KW_JOIN | KW_LEFT KW_SEMI KW_JOIN ; lateralView - : KW_LATERAL KW_VIEW KW_OUTER function_ tableAlias (KW_AS identifier (COMMA identifier)*)? - | COMMA? KW_LATERAL KW_VIEW function_ tableAlias (KW_AS identifier (COMMA identifier)*)? - | COMMA? KW_LATERAL KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias (LPAREN identifier (COMMA identifier)* RPAREN)? - ; + : KW_LATERAL KW_VIEW KW_OUTER function_ tableAlias (KW_AS identifier (COMMA identifier)*)? + | COMMA? KW_LATERAL KW_VIEW function_ tableAlias (KW_AS identifier (COMMA identifier)*)? + | COMMA? KW_LATERAL KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias ( + LPAREN identifier (COMMA identifier)* RPAREN + )? + ; tableAlias : identifier ; tableBucketSample - : KW_TABLESAMPLE LPAREN KW_BUCKET Number KW_OUT KW_OF Number (KW_ON expression (COMMA expression)*)? RPAREN + : KW_TABLESAMPLE LPAREN KW_BUCKET Number KW_OUT KW_OF Number ( + KW_ON expression (COMMA expression)* + )? RPAREN ; splitSample - : KW_TABLESAMPLE LPAREN Number (KW_PERCENT|KW_ROWS) RPAREN - | KW_TABLESAMPLE LPAREN ByteLengthLiteral RPAREN + : KW_TABLESAMPLE LPAREN Number (KW_PERCENT | KW_ROWS) RPAREN + | KW_TABLESAMPLE LPAREN ByteLengthLiteral RPAREN ; tableSample @@ -137,25 +145,24 @@ subQuerySource //---------------------- Rules for parsing PTF clauses ----------------------------- partitioningSpec - : partitionByClause orderByClause? - | orderByClause - | distributeByClause sortByClause? - | sortByClause - | clusterByClause - ; + : partitionByClause orderByClause? + | orderByClause + | distributeByClause sortByClause? + | sortByClause + | clusterByClause + ; partitionTableFunctionSource - : subQuerySource - | tableSource - | partitionedTableFunction - ; + : subQuerySource + | tableSource + | partitionedTableFunction + ; partitionedTableFunction - : identifier LPAREN KW_ON - partitionTableFunctionSource partitioningSpec? - (Identifier LPAREN expression RPAREN ( COMMA Identifier LPAREN expression RPAREN)*)? - RPAREN identifier? - ; + : identifier LPAREN KW_ON partitionTableFunctionSource partitioningSpec? ( + Identifier LPAREN expression RPAREN (COMMA Identifier LPAREN expression RPAREN)* + )? RPAREN identifier? + ; //----------------------- Rules for parsing whereClause ----------------------------- // where a=b and ... @@ -198,4 +205,4 @@ virtualTableSource : KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias (LPAREN identifier (COMMA identifier)*)? RPAREN ; -//----------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------- \ No newline at end of file diff --git a/sql/hive/v3/HintParser.g4 b/sql/hive/v3/HintParser.g4 index 8de43aead8..042639cc79 100644 --- a/sql/hive/v3/HintParser.g4 +++ b/sql/hive/v3/HintParser.g4 @@ -16,11 +16,15 @@ @author Canwei He */ + +// $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 HintParser; options { - tokenVocab=HiveLexer; + tokenVocab = HiveLexer; } // starting rule @@ -50,4 +54,4 @@ hintArgName : Identifier | Number | KW_NONE - ; + ; \ No newline at end of file diff --git a/sql/hive/v3/HiveLexer.g4 b/sql/hive/v3/HiveLexer.g4 index 954b504aa7..719bc6e130 100644 --- a/sql/hive/v3/HiveLexer.g4 +++ b/sql/hive/v3/HiveLexer.g4 @@ -17,439 +17,431 @@ @author Canwei He */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar HiveLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} //关键词 -KW_TRUE : 'TRUE'; +KW_TRUE : 'TRUE'; KW_FALSE : 'FALSE'; -KW_ALL : 'ALL'; -KW_NONE: 'NONE'; -KW_AND : 'AND'; -KW_OR : 'OR'; -KW_NOT : 'NOT' | '!'; -KW_LIKE : 'LIKE'; -KW_ANY : 'ANY'; - -KW_IF : 'IF'; +KW_ALL : 'ALL'; +KW_NONE : 'NONE'; +KW_AND : 'AND'; +KW_OR : 'OR'; +KW_NOT : 'NOT' | '!'; +KW_LIKE : 'LIKE'; +KW_ANY : 'ANY'; + +KW_IF : 'IF'; KW_EXISTS : 'EXISTS'; -KW_ASC : 'ASC'; -KW_DESC : 'DESC'; -KW_NULLS : 'NULLS'; -KW_LAST : 'LAST'; -KW_ORDER : 'ORDER'; -KW_GROUP : 'GROUP'; -KW_BY : 'BY'; -KW_HAVING : 'HAVING'; -KW_WHERE : 'WHERE'; -KW_FROM : 'FROM'; -KW_AS : 'AS'; -KW_SELECT : 'SELECT'; -KW_DISTINCT : 'DISTINCT'; -KW_INSERT : 'INSERT'; -KW_OVERWRITE : 'OVERWRITE'; -KW_OUTER : 'OUTER'; -KW_UNIQUEJOIN : 'UNIQUEJOIN'; -KW_PRESERVE : 'PRESERVE'; -KW_JOIN : 'JOIN'; -KW_LEFT : 'LEFT'; -KW_RIGHT : 'RIGHT'; -KW_FULL : 'FULL'; -KW_ON : 'ON'; -KW_PARTITION : 'PARTITION'; -KW_PARTITIONS : 'PARTITIONS'; -KW_TABLE: 'TABLE'; -KW_TABLES: 'TABLES'; -KW_COLUMNS: 'COLUMNS'; -KW_INDEX: 'INDEX'; -KW_INDEXES: 'INDEXES'; -KW_REBUILD: 'REBUILD'; -KW_FUNCTIONS: 'FUNCTIONS'; -KW_SHOW: 'SHOW'; -KW_MSCK: 'MSCK'; -KW_REPAIR: 'REPAIR'; -KW_DIRECTORY: 'DIRECTORY'; -KW_LOCAL: 'LOCAL'; -KW_TRANSFORM : 'TRANSFORM'; -KW_USING: 'USING'; -KW_CLUSTER: 'CLUSTER'; -KW_DISTRIBUTE: 'DISTRIBUTE'; -KW_SORT: 'SORT'; -KW_UNION: 'UNION'; -KW_EXCEPT: 'EXCEPT'; -KW_LOAD: 'LOAD'; -KW_EXPORT: 'EXPORT'; -KW_IMPORT: 'IMPORT'; -KW_REPLICATION: 'REPLICATION'; -KW_METADATA: 'METADATA'; -KW_DATA: 'DATA'; -KW_INPATH: 'INPATH'; -KW_IS: 'IS'; -KW_NULL: 'NULL'; -KW_CREATE: 'CREATE'; -KW_EXTERNAL: 'EXTERNAL'; -KW_ALTER: 'ALTER'; -KW_CHANGE: 'CHANGE'; -KW_COLUMN: 'COLUMN'; -KW_FIRST: 'FIRST'; -KW_AFTER: 'AFTER'; -KW_DESCRIBE: 'DESCRIBE'; -KW_DROP: 'DROP'; -KW_RENAME: 'RENAME'; -KW_TO: 'TO'; -KW_COMMENT: 'COMMENT'; -KW_BOOLEAN: 'BOOLEAN'; -KW_TINYINT: 'TINYINT'; -KW_SMALLINT: 'SMALLINT'; -KW_INT: 'INT' | 'INTEGER'; -KW_BIGINT: 'BIGINT'; -KW_FLOAT: 'FLOAT'; -KW_DOUBLE: 'DOUBLE'; -KW_PRECISION: 'PRECISION'; -KW_DATE: 'DATE'; -KW_DATETIME: 'DATETIME'; -KW_TIMESTAMP: 'TIMESTAMP'; -KW_TIMESTAMPLOCALTZ: 'TIMESTAMPLOCALTZ'; -KW_TIME: 'TIME'; -KW_ZONE: 'ZONE'; -KW_INTERVAL: 'INTERVAL'; -KW_DECIMAL: 'DECIMAL' | 'NUMERIC'; -KW_STRING: 'STRING'; -KW_CHAR: 'CHAR'; -KW_VARCHAR: 'VARCHAR'; -KW_ARRAY: 'ARRAY'; -KW_STRUCT: 'STRUCT'; -KW_MAP: 'MAP'; -KW_UNIONTYPE: 'UNIONTYPE'; -KW_REDUCE: 'REDUCE'; -KW_PARTITIONED: 'PARTITIONED'; -KW_CLUSTERED: 'CLUSTERED'; -KW_SORTED: 'SORTED'; -KW_INTO: 'INTO'; -KW_BUCKETS: 'BUCKETS'; -KW_ROW: 'ROW'; -KW_ROWS: 'ROWS'; -KW_FORMAT: 'FORMAT'; -KW_DELIMITED: 'DELIMITED'; -KW_FIELDS: 'FIELDS'; -KW_TERMINATED: 'TERMINATED'; -KW_ESCAPED: 'ESCAPED'; -KW_COLLECTION: 'COLLECTION'; -KW_ITEMS: 'ITEMS'; -KW_KEYS: 'KEYS'; -KW_KEY_TYPE: '$KEY$'; -KW_KILL: 'KILL'; -KW_LINES: 'LINES'; -KW_STORED: 'STORED'; -KW_FILEFORMAT: 'FILEFORMAT'; -KW_INPUTFORMAT: 'INPUTFORMAT'; -KW_OUTPUTFORMAT: 'OUTPUTFORMAT'; -KW_INPUTDRIVER: 'INPUTDRIVER'; -KW_OUTPUTDRIVER: 'OUTPUTDRIVER'; -KW_ENABLE: 'ENABLE'; -KW_DISABLE: 'DISABLE'; -KW_LOCATION: 'LOCATION'; -KW_TABLESAMPLE: 'TABLESAMPLE'; -KW_BUCKET: 'BUCKET'; -KW_OUT: 'OUT'; -KW_OF: 'OF'; -KW_PERCENT: 'PERCENT'; -KW_CAST: 'CAST'; -KW_ADD: 'ADD'; -KW_REPLACE: 'REPLACE'; -KW_RLIKE: 'RLIKE'; -KW_REGEXP: 'REGEXP'; -KW_TEMPORARY: 'TEMPORARY'; -KW_FUNCTION: 'FUNCTION'; -KW_MACRO: 'MACRO'; -KW_FILE: 'FILE'; -KW_JAR: 'JAR'; -KW_EXPLAIN: 'EXPLAIN'; -KW_EXTENDED: 'EXTENDED'; -KW_FORMATTED: 'FORMATTED'; -KW_DEPENDENCY: 'DEPENDENCY'; -KW_LOGICAL: 'LOGICAL'; -KW_SERDE: 'SERDE'; -KW_WITH: 'WITH'; -KW_DEFERRED: 'DEFERRED'; -KW_SERDEPROPERTIES: 'SERDEPROPERTIES'; -KW_DBPROPERTIES: 'DBPROPERTIES'; -KW_LIMIT: 'LIMIT'; -KW_OFFSET: 'OFFSET'; -KW_SET: 'SET'; -KW_UNSET: 'UNSET'; -KW_TBLPROPERTIES: 'TBLPROPERTIES'; -KW_IDXPROPERTIES: 'IDXPROPERTIES'; -KW_VALUE_TYPE: '$VALUE$'; -KW_ELEM_TYPE: '$ELEM$'; -KW_DEFINED: 'DEFINED'; -KW_CASE: 'CASE'; -KW_WHEN: 'WHEN'; -KW_THEN: 'THEN'; -KW_ELSE: 'ELSE'; -KW_END: 'END'; -KW_MAPJOIN: 'MAPJOIN'; -KW_STREAMTABLE: 'STREAMTABLE'; -KW_CLUSTERSTATUS: 'CLUSTERSTATUS'; -KW_UTC: 'UTC'; -KW_UTCTIMESTAMP: 'UTC_TMESTAMP'; -KW_LONG: 'LONG'; -KW_DELETE: 'DELETE'; -KW_PLUS: 'PLUS'; -KW_MINUS: 'MINUS'; -KW_FETCH: 'FETCH'; -KW_INTERSECT: 'INTERSECT'; -KW_VIEW: 'VIEW'; -KW_VIEWS: 'VIEWS'; -KW_IN: 'IN'; -KW_DATABASE: 'DATABASE'; -KW_DATABASES: 'DATABASES'; -KW_MATERIALIZED: 'MATERIALIZED'; -KW_SCHEMA: 'SCHEMA'; -KW_SCHEMAS: 'SCHEMAS'; -KW_GRANT: 'GRANT'; -KW_REVOKE: 'REVOKE'; -KW_SSL: 'SSL'; -KW_UNDO: 'UNDO'; -KW_LOCK: 'LOCK'; -KW_LOCKS: 'LOCKS'; -KW_UNLOCK: 'UNLOCK'; -KW_SHARED: 'SHARED'; -KW_EXCLUSIVE: 'EXCLUSIVE'; -KW_PROCEDURE: 'PROCEDURE'; -KW_UNSIGNED: 'UNSIGNED'; -KW_WHILE: 'WHILE'; -KW_READ: 'READ'; -KW_READS: 'READS'; -KW_PURGE: 'PURGE'; -KW_RANGE: 'RANGE'; -KW_ANALYZE: 'ANALYZE'; -KW_BEFORE: 'BEFORE'; -KW_BETWEEN: 'BETWEEN'; -KW_BOTH: 'BOTH'; -KW_BINARY: 'BINARY'; -KW_CROSS: 'CROSS'; -KW_CONTINUE: 'CONTINUE'; -KW_CURSOR: 'CURSOR'; -KW_TRIGGER: 'TRIGGER'; -KW_RECORDREADER: 'RECORDREADER'; -KW_RECORDWRITER: 'RECORDWRITER'; -KW_SEMI: 'SEMI'; -KW_LATERAL: 'LATERAL'; -KW_TOUCH: 'TOUCH'; -KW_ARCHIVE: 'ARCHIVE'; -KW_UNARCHIVE: 'UNARCHIVE'; -KW_COMPUTE: 'COMPUTE'; -KW_STATISTICS: 'STATISTICS'; -KW_USE: 'USE'; -KW_OPTION: 'OPTION'; -KW_CONCATENATE: 'CONCATENATE'; -KW_SHOW_DATABASE: 'SHOW_DATABASE'; -KW_UPDATE: 'UPDATE'; -KW_RESTRICT: 'RESTRICT'; -KW_CASCADE: 'CASCADE'; -KW_SKEWED: 'SKEWED'; -KW_ROLLUP: 'ROLLUP'; -KW_CUBE: 'CUBE'; -KW_DIRECTORIES: 'DIRECTORIES'; -KW_FOR: 'FOR'; -KW_WINDOW: 'WINDOW'; -KW_UNBOUNDED: 'UNBOUNDED'; -KW_PRECEDING: 'PRECEDING'; -KW_FOLLOWING: 'FOLLOWING'; -KW_CURRENT: 'CURRENT'; -KW_CURRENT_DATE: 'CURRENT_DATE'; -KW_CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -KW_LESS: 'LESS'; -KW_MORE: 'MORE'; -KW_OVER: 'OVER'; -KW_GROUPING: 'GROUPING'; -KW_SETS: 'SETS'; -KW_TRUNCATE: 'TRUNCATE'; -KW_NOSCAN: 'NOSCAN'; -KW_USER: 'USER'; -KW_ROLE: 'ROLE'; -KW_ROLES: 'ROLES'; -KW_INNER: 'INNER'; -KW_EXCHANGE: 'EXCHANGE'; -KW_URI: 'URI'; -KW_SERVER : 'SERVER'; -KW_ADMIN: 'ADMIN'; -KW_OWNER: 'OWNER'; -KW_PRINCIPALS: 'PRINCIPALS'; -KW_COMPACT: 'COMPACT'; -KW_COMPACTIONS: 'COMPACTIONS'; -KW_TRANSACTIONS: 'TRANSACTIONS'; -KW_REWRITE : 'REWRITE'; -KW_AUTHORIZATION: 'AUTHORIZATION'; -KW_REOPTIMIZATION: 'REOPTIMIZATION'; -KW_CONF: 'CONF'; -KW_VALUES: 'VALUES'; -KW_RELOAD: 'RELOAD'; -KW_YEAR: 'YEAR' | 'YEARS'; -KW_QUERY: 'QUERY'; -KW_QUARTER: 'QUARTER'; -KW_MONTH: 'MONTH' | 'MONTHS'; -KW_WEEK: 'WEEK' | 'WEEKS'; -KW_DAY: 'DAY' | 'DAYS'; -KW_DOW: 'DAYOFWEEK'; -KW_HOUR: 'HOUR' | 'HOURS'; -KW_MINUTE: 'MINUTE' | 'MINUTES'; -KW_SECOND: 'SECOND' | 'SECONDS'; -KW_START: 'START'; -KW_TRANSACTION: 'TRANSACTION'; -KW_COMMIT: 'COMMIT'; -KW_ROLLBACK: 'ROLLBACK'; -KW_WORK: 'WORK'; -KW_ONLY: 'ONLY'; -KW_WRITE: 'WRITE'; -KW_ISOLATION: 'ISOLATION'; -KW_LEVEL: 'LEVEL'; -KW_SNAPSHOT: 'SNAPSHOT'; -KW_AUTOCOMMIT: 'AUTOCOMMIT'; -KW_CACHE: 'CACHE'; -KW_PRIMARY: 'PRIMARY'; -KW_FOREIGN: 'FOREIGN'; -KW_REFERENCES: 'REFERENCES'; -KW_CONSTRAINT: 'CONSTRAINT'; -KW_ENFORCED: 'ENFORCED'; -KW_VALIDATE: 'VALIDATE'; -KW_NOVALIDATE: 'NOVALIDATE'; -KW_RELY: 'RELY'; -KW_NORELY: 'NORELY'; -KW_UNIQUE: 'UNIQUE'; -KW_KEY: 'KEY'; -KW_ABORT: 'ABORT'; -KW_EXTRACT: 'EXTRACT'; -KW_FLOOR: 'FLOOR'; -KW_MERGE: 'MERGE'; -KW_MATCHED: 'MATCHED'; -KW_REPL: 'REPL'; -KW_DUMP: 'DUMP'; -KW_STATUS: 'STATUS'; -KW_VECTORIZATION: 'VECTORIZATION'; -KW_SUMMARY: 'SUMMARY'; -KW_OPERATOR: 'OPERATOR'; -KW_EXPRESSION: 'EXPRESSION'; -KW_DETAIL: 'DETAIL'; -KW_WAIT: 'WAIT'; -KW_RESOURCE: 'RESOURCE'; -KW_PLAN: 'PLAN'; -KW_QUERY_PARALLELISM: 'QUERY_PARALLELISM'; -KW_PLANS: 'PLANS'; -KW_ACTIVATE: 'ACTIVATE'; -KW_DEFAULT: 'DEFAULT'; -KW_CHECK: 'CHECK'; -KW_POOL: 'POOL'; -KW_MOVE: 'MOVE'; -KW_DO: 'DO'; -KW_ALLOC_FRACTION: 'ALLOC_FRACTION'; -KW_SCHEDULING_POLICY: 'SCHEDULING_POLICY'; -KW_PATH: 'PATH'; -KW_MAPPING: 'MAPPING'; -KW_WORKLOAD: 'WORKLOAD'; -KW_MANAGEMENT: 'MANAGEMENT'; -KW_ACTIVE: 'ACTIVE'; -KW_UNMANAGED: 'UNMANAGED'; -KW_APPLICATION: 'APPLICATION'; -KW_SYNC: 'SYNC'; +KW_ASC : 'ASC'; +KW_DESC : 'DESC'; +KW_NULLS : 'NULLS'; +KW_LAST : 'LAST'; +KW_ORDER : 'ORDER'; +KW_GROUP : 'GROUP'; +KW_BY : 'BY'; +KW_HAVING : 'HAVING'; +KW_WHERE : 'WHERE'; +KW_FROM : 'FROM'; +KW_AS : 'AS'; +KW_SELECT : 'SELECT'; +KW_DISTINCT : 'DISTINCT'; +KW_INSERT : 'INSERT'; +KW_OVERWRITE : 'OVERWRITE'; +KW_OUTER : 'OUTER'; +KW_UNIQUEJOIN : 'UNIQUEJOIN'; +KW_PRESERVE : 'PRESERVE'; +KW_JOIN : 'JOIN'; +KW_LEFT : 'LEFT'; +KW_RIGHT : 'RIGHT'; +KW_FULL : 'FULL'; +KW_ON : 'ON'; +KW_PARTITION : 'PARTITION'; +KW_PARTITIONS : 'PARTITIONS'; +KW_TABLE : 'TABLE'; +KW_TABLES : 'TABLES'; +KW_COLUMNS : 'COLUMNS'; +KW_INDEX : 'INDEX'; +KW_INDEXES : 'INDEXES'; +KW_REBUILD : 'REBUILD'; +KW_FUNCTIONS : 'FUNCTIONS'; +KW_SHOW : 'SHOW'; +KW_MSCK : 'MSCK'; +KW_REPAIR : 'REPAIR'; +KW_DIRECTORY : 'DIRECTORY'; +KW_LOCAL : 'LOCAL'; +KW_TRANSFORM : 'TRANSFORM'; +KW_USING : 'USING'; +KW_CLUSTER : 'CLUSTER'; +KW_DISTRIBUTE : 'DISTRIBUTE'; +KW_SORT : 'SORT'; +KW_UNION : 'UNION'; +KW_EXCEPT : 'EXCEPT'; +KW_LOAD : 'LOAD'; +KW_EXPORT : 'EXPORT'; +KW_IMPORT : 'IMPORT'; +KW_REPLICATION : 'REPLICATION'; +KW_METADATA : 'METADATA'; +KW_DATA : 'DATA'; +KW_INPATH : 'INPATH'; +KW_IS : 'IS'; +KW_NULL : 'NULL'; +KW_CREATE : 'CREATE'; +KW_EXTERNAL : 'EXTERNAL'; +KW_ALTER : 'ALTER'; +KW_CHANGE : 'CHANGE'; +KW_COLUMN : 'COLUMN'; +KW_FIRST : 'FIRST'; +KW_AFTER : 'AFTER'; +KW_DESCRIBE : 'DESCRIBE'; +KW_DROP : 'DROP'; +KW_RENAME : 'RENAME'; +KW_TO : 'TO'; +KW_COMMENT : 'COMMENT'; +KW_BOOLEAN : 'BOOLEAN'; +KW_TINYINT : 'TINYINT'; +KW_SMALLINT : 'SMALLINT'; +KW_INT : 'INT' | 'INTEGER'; +KW_BIGINT : 'BIGINT'; +KW_FLOAT : 'FLOAT'; +KW_DOUBLE : 'DOUBLE'; +KW_PRECISION : 'PRECISION'; +KW_DATE : 'DATE'; +KW_DATETIME : 'DATETIME'; +KW_TIMESTAMP : 'TIMESTAMP'; +KW_TIMESTAMPLOCALTZ : 'TIMESTAMPLOCALTZ'; +KW_TIME : 'TIME'; +KW_ZONE : 'ZONE'; +KW_INTERVAL : 'INTERVAL'; +KW_DECIMAL : 'DECIMAL' | 'NUMERIC'; +KW_STRING : 'STRING'; +KW_CHAR : 'CHAR'; +KW_VARCHAR : 'VARCHAR'; +KW_ARRAY : 'ARRAY'; +KW_STRUCT : 'STRUCT'; +KW_MAP : 'MAP'; +KW_UNIONTYPE : 'UNIONTYPE'; +KW_REDUCE : 'REDUCE'; +KW_PARTITIONED : 'PARTITIONED'; +KW_CLUSTERED : 'CLUSTERED'; +KW_SORTED : 'SORTED'; +KW_INTO : 'INTO'; +KW_BUCKETS : 'BUCKETS'; +KW_ROW : 'ROW'; +KW_ROWS : 'ROWS'; +KW_FORMAT : 'FORMAT'; +KW_DELIMITED : 'DELIMITED'; +KW_FIELDS : 'FIELDS'; +KW_TERMINATED : 'TERMINATED'; +KW_ESCAPED : 'ESCAPED'; +KW_COLLECTION : 'COLLECTION'; +KW_ITEMS : 'ITEMS'; +KW_KEYS : 'KEYS'; +KW_KEY_TYPE : '$KEY$'; +KW_KILL : 'KILL'; +KW_LINES : 'LINES'; +KW_STORED : 'STORED'; +KW_FILEFORMAT : 'FILEFORMAT'; +KW_INPUTFORMAT : 'INPUTFORMAT'; +KW_OUTPUTFORMAT : 'OUTPUTFORMAT'; +KW_INPUTDRIVER : 'INPUTDRIVER'; +KW_OUTPUTDRIVER : 'OUTPUTDRIVER'; +KW_ENABLE : 'ENABLE'; +KW_DISABLE : 'DISABLE'; +KW_LOCATION : 'LOCATION'; +KW_TABLESAMPLE : 'TABLESAMPLE'; +KW_BUCKET : 'BUCKET'; +KW_OUT : 'OUT'; +KW_OF : 'OF'; +KW_PERCENT : 'PERCENT'; +KW_CAST : 'CAST'; +KW_ADD : 'ADD'; +KW_REPLACE : 'REPLACE'; +KW_RLIKE : 'RLIKE'; +KW_REGEXP : 'REGEXP'; +KW_TEMPORARY : 'TEMPORARY'; +KW_FUNCTION : 'FUNCTION'; +KW_MACRO : 'MACRO'; +KW_FILE : 'FILE'; +KW_JAR : 'JAR'; +KW_EXPLAIN : 'EXPLAIN'; +KW_EXTENDED : 'EXTENDED'; +KW_FORMATTED : 'FORMATTED'; +KW_DEPENDENCY : 'DEPENDENCY'; +KW_LOGICAL : 'LOGICAL'; +KW_SERDE : 'SERDE'; +KW_WITH : 'WITH'; +KW_DEFERRED : 'DEFERRED'; +KW_SERDEPROPERTIES : 'SERDEPROPERTIES'; +KW_DBPROPERTIES : 'DBPROPERTIES'; +KW_LIMIT : 'LIMIT'; +KW_OFFSET : 'OFFSET'; +KW_SET : 'SET'; +KW_UNSET : 'UNSET'; +KW_TBLPROPERTIES : 'TBLPROPERTIES'; +KW_IDXPROPERTIES : 'IDXPROPERTIES'; +KW_VALUE_TYPE : '$VALUE$'; +KW_ELEM_TYPE : '$ELEM$'; +KW_DEFINED : 'DEFINED'; +KW_CASE : 'CASE'; +KW_WHEN : 'WHEN'; +KW_THEN : 'THEN'; +KW_ELSE : 'ELSE'; +KW_END : 'END'; +KW_MAPJOIN : 'MAPJOIN'; +KW_STREAMTABLE : 'STREAMTABLE'; +KW_CLUSTERSTATUS : 'CLUSTERSTATUS'; +KW_UTC : 'UTC'; +KW_UTCTIMESTAMP : 'UTC_TMESTAMP'; +KW_LONG : 'LONG'; +KW_DELETE : 'DELETE'; +KW_PLUS : 'PLUS'; +KW_MINUS : 'MINUS'; +KW_FETCH : 'FETCH'; +KW_INTERSECT : 'INTERSECT'; +KW_VIEW : 'VIEW'; +KW_VIEWS : 'VIEWS'; +KW_IN : 'IN'; +KW_DATABASE : 'DATABASE'; +KW_DATABASES : 'DATABASES'; +KW_MATERIALIZED : 'MATERIALIZED'; +KW_SCHEMA : 'SCHEMA'; +KW_SCHEMAS : 'SCHEMAS'; +KW_GRANT : 'GRANT'; +KW_REVOKE : 'REVOKE'; +KW_SSL : 'SSL'; +KW_UNDO : 'UNDO'; +KW_LOCK : 'LOCK'; +KW_LOCKS : 'LOCKS'; +KW_UNLOCK : 'UNLOCK'; +KW_SHARED : 'SHARED'; +KW_EXCLUSIVE : 'EXCLUSIVE'; +KW_PROCEDURE : 'PROCEDURE'; +KW_UNSIGNED : 'UNSIGNED'; +KW_WHILE : 'WHILE'; +KW_READ : 'READ'; +KW_READS : 'READS'; +KW_PURGE : 'PURGE'; +KW_RANGE : 'RANGE'; +KW_ANALYZE : 'ANALYZE'; +KW_BEFORE : 'BEFORE'; +KW_BETWEEN : 'BETWEEN'; +KW_BOTH : 'BOTH'; +KW_BINARY : 'BINARY'; +KW_CROSS : 'CROSS'; +KW_CONTINUE : 'CONTINUE'; +KW_CURSOR : 'CURSOR'; +KW_TRIGGER : 'TRIGGER'; +KW_RECORDREADER : 'RECORDREADER'; +KW_RECORDWRITER : 'RECORDWRITER'; +KW_SEMI : 'SEMI'; +KW_LATERAL : 'LATERAL'; +KW_TOUCH : 'TOUCH'; +KW_ARCHIVE : 'ARCHIVE'; +KW_UNARCHIVE : 'UNARCHIVE'; +KW_COMPUTE : 'COMPUTE'; +KW_STATISTICS : 'STATISTICS'; +KW_USE : 'USE'; +KW_OPTION : 'OPTION'; +KW_CONCATENATE : 'CONCATENATE'; +KW_SHOW_DATABASE : 'SHOW_DATABASE'; +KW_UPDATE : 'UPDATE'; +KW_RESTRICT : 'RESTRICT'; +KW_CASCADE : 'CASCADE'; +KW_SKEWED : 'SKEWED'; +KW_ROLLUP : 'ROLLUP'; +KW_CUBE : 'CUBE'; +KW_DIRECTORIES : 'DIRECTORIES'; +KW_FOR : 'FOR'; +KW_WINDOW : 'WINDOW'; +KW_UNBOUNDED : 'UNBOUNDED'; +KW_PRECEDING : 'PRECEDING'; +KW_FOLLOWING : 'FOLLOWING'; +KW_CURRENT : 'CURRENT'; +KW_CURRENT_DATE : 'CURRENT_DATE'; +KW_CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +KW_LESS : 'LESS'; +KW_MORE : 'MORE'; +KW_OVER : 'OVER'; +KW_GROUPING : 'GROUPING'; +KW_SETS : 'SETS'; +KW_TRUNCATE : 'TRUNCATE'; +KW_NOSCAN : 'NOSCAN'; +KW_USER : 'USER'; +KW_ROLE : 'ROLE'; +KW_ROLES : 'ROLES'; +KW_INNER : 'INNER'; +KW_EXCHANGE : 'EXCHANGE'; +KW_URI : 'URI'; +KW_SERVER : 'SERVER'; +KW_ADMIN : 'ADMIN'; +KW_OWNER : 'OWNER'; +KW_PRINCIPALS : 'PRINCIPALS'; +KW_COMPACT : 'COMPACT'; +KW_COMPACTIONS : 'COMPACTIONS'; +KW_TRANSACTIONS : 'TRANSACTIONS'; +KW_REWRITE : 'REWRITE'; +KW_AUTHORIZATION : 'AUTHORIZATION'; +KW_REOPTIMIZATION : 'REOPTIMIZATION'; +KW_CONF : 'CONF'; +KW_VALUES : 'VALUES'; +KW_RELOAD : 'RELOAD'; +KW_YEAR : 'YEAR' | 'YEARS'; +KW_QUERY : 'QUERY'; +KW_QUARTER : 'QUARTER'; +KW_MONTH : 'MONTH' | 'MONTHS'; +KW_WEEK : 'WEEK' | 'WEEKS'; +KW_DAY : 'DAY' | 'DAYS'; +KW_DOW : 'DAYOFWEEK'; +KW_HOUR : 'HOUR' | 'HOURS'; +KW_MINUTE : 'MINUTE' | 'MINUTES'; +KW_SECOND : 'SECOND' | 'SECONDS'; +KW_START : 'START'; +KW_TRANSACTION : 'TRANSACTION'; +KW_COMMIT : 'COMMIT'; +KW_ROLLBACK : 'ROLLBACK'; +KW_WORK : 'WORK'; +KW_ONLY : 'ONLY'; +KW_WRITE : 'WRITE'; +KW_ISOLATION : 'ISOLATION'; +KW_LEVEL : 'LEVEL'; +KW_SNAPSHOT : 'SNAPSHOT'; +KW_AUTOCOMMIT : 'AUTOCOMMIT'; +KW_CACHE : 'CACHE'; +KW_PRIMARY : 'PRIMARY'; +KW_FOREIGN : 'FOREIGN'; +KW_REFERENCES : 'REFERENCES'; +KW_CONSTRAINT : 'CONSTRAINT'; +KW_ENFORCED : 'ENFORCED'; +KW_VALIDATE : 'VALIDATE'; +KW_NOVALIDATE : 'NOVALIDATE'; +KW_RELY : 'RELY'; +KW_NORELY : 'NORELY'; +KW_UNIQUE : 'UNIQUE'; +KW_KEY : 'KEY'; +KW_ABORT : 'ABORT'; +KW_EXTRACT : 'EXTRACT'; +KW_FLOOR : 'FLOOR'; +KW_MERGE : 'MERGE'; +KW_MATCHED : 'MATCHED'; +KW_REPL : 'REPL'; +KW_DUMP : 'DUMP'; +KW_STATUS : 'STATUS'; +KW_VECTORIZATION : 'VECTORIZATION'; +KW_SUMMARY : 'SUMMARY'; +KW_OPERATOR : 'OPERATOR'; +KW_EXPRESSION : 'EXPRESSION'; +KW_DETAIL : 'DETAIL'; +KW_WAIT : 'WAIT'; +KW_RESOURCE : 'RESOURCE'; +KW_PLAN : 'PLAN'; +KW_QUERY_PARALLELISM : 'QUERY_PARALLELISM'; +KW_PLANS : 'PLANS'; +KW_ACTIVATE : 'ACTIVATE'; +KW_DEFAULT : 'DEFAULT'; +KW_CHECK : 'CHECK'; +KW_POOL : 'POOL'; +KW_MOVE : 'MOVE'; +KW_DO : 'DO'; +KW_ALLOC_FRACTION : 'ALLOC_FRACTION'; +KW_SCHEDULING_POLICY : 'SCHEDULING_POLICY'; +KW_PATH : 'PATH'; +KW_MAPPING : 'MAPPING'; +KW_WORKLOAD : 'WORKLOAD'; +KW_MANAGEMENT : 'MANAGEMENT'; +KW_ACTIVE : 'ACTIVE'; +KW_UNMANAGED : 'UNMANAGED'; +KW_APPLICATION : 'APPLICATION'; +KW_SYNC : 'SYNC'; // Operators // NOTE: if you add a new function/operator, add it to sysFuncNames so that describe function _FUNC_ will work. -DOT : '.'; // generated as a part of Number rule -COLON : ':' ; -COMMA : ',' ; -SEMICOLON : ';' ; - -LPAREN : '(' ; -RPAREN : ')' ; -LSQUARE : '[' ; -RSQUARE : ']' ; -LCURLY : '{'; -RCURLY : '}'; - -EQUAL : '=' | '=='; -EQUAL_NS : '<=>'; -NOTEQUAL : '<>' | '!='; -LESSTHANOREQUALTO : '<='; -LESSTHAN : '<'; +DOT : '.'; // generated as a part of Number rule +COLON : ':'; +COMMA : ','; +SEMICOLON : ';'; + +LPAREN : '('; +RPAREN : ')'; +LSQUARE : '['; +RSQUARE : ']'; +LCURLY : '{'; +RCURLY : '}'; + +EQUAL : '=' | '=='; +EQUAL_NS : '<=>'; +NOTEQUAL : '<>' | '!='; +LESSTHANOREQUALTO : '<='; +LESSTHAN : '<'; GREATERTHANOREQUALTO : '>='; -GREATERTHAN : '>'; +GREATERTHAN : '>'; DIVIDE : '/'; -PLUS : '+'; -MINUS : '-'; -STAR : '*'; -MOD : '%'; -DIV : 'DIV'; - -AMPERSAND : '&'; -TILDE : '~'; -BITWISEOR : '|'; +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +MOD : '%'; +DIV : 'DIV'; + +AMPERSAND : '&'; +TILDE : '~'; +BITWISEOR : '|'; CONCATENATE : '||'; -BITWISEXOR : '^'; -QUESTION : '?'; -DOLLAR : '$'; +BITWISEXOR : '^'; +QUESTION : '?'; +DOLLAR : '$'; // LITERALS -fragment -Letter - : 'A'..'Z' - ; - -fragment -HexDigit - : 'A'..'F' - ; - -fragment -Digit - : '0'..'9' - ; - -fragment -Exponent - : 'E' ( PLUS|MINUS )? (Digit)+ - ; - -fragment -RegexComponent - : 'A'..'Z' | '0'..'9' | '_' - | PLUS | STAR | QUESTION | MINUS | DOT - | LPAREN | RPAREN | LSQUARE | RSQUARE | LCURLY | RCURLY - | BITWISEXOR | BITWISEOR | DOLLAR | '!' - ; - -StringLiteral - : ( '\'' ( ~('\''|'\\') | ('\\' .) )* '\'' - | '"' ( ~('"'|'\\') | ('\\' .) )* '"' - )+ - ; - -CharSetLiteral - : StringLiteral - | '0' 'X' (HexDigit|Digit)+ - ; - -IntegralLiteral - : (Digit)+ ('L' | 'S' | 'Y') - ; - -NumberLiteral - : Number ('D' | 'B' 'D') - ; - -ByteLengthLiteral - : Digit+ ('B' | 'K' | 'M' | 'G') - ; - -Number - : (Digit)+ ( DOT (Digit)* (Exponent)? | Exponent)? - ; +fragment Letter: 'A' ..'Z'; + +fragment HexDigit: 'A' ..'F'; + +fragment Digit: '0' ..'9'; + +fragment Exponent: 'E' ( PLUS | MINUS)? (Digit)+; + +fragment RegexComponent: + 'A' ..'Z' + | '0' ..'9' + | '_' + | PLUS + | STAR + | QUESTION + | MINUS + | DOT + | LPAREN + | RPAREN + | LSQUARE + | RSQUARE + | LCURLY + | RCURLY + | BITWISEXOR + | BITWISEOR + | DOLLAR + | '!' +; + +StringLiteral: ( '\'' ( ~('\'' | '\\') | ('\\' .))* '\'' | '"' ( ~('"' | '\\') | ('\\' .))* '"')+; + +CharSetLiteral: StringLiteral | '0' 'X' (HexDigit | Digit)+; + +IntegralLiteral: (Digit)+ ('L' | 'S' | 'Y'); + +NumberLiteral: Number ('D' | 'B' 'D'); + +ByteLengthLiteral: Digit+ ('B' | 'K' | 'M' | 'G'); + +Number: (Digit)+ ( DOT (Digit)* (Exponent)? | Exponent)?; /* An Identifier can be: @@ -472,42 +464,27 @@ An Identifier can be: - hint name - window name */ -Identifier - : (Letter | Digit) (Letter | Digit | '_')* - | QuotedIdentifier /* though at the language level we allow all Identifiers to be QuotedIdentifiers; +Identifier: + (Letter | Digit) (Letter | Digit | '_')* + | QuotedIdentifier /* though at the language level we allow all Identifiers to be QuotedIdentifiers; at the API level only columns are allowed to be of this form */ | '`' RegexComponent+ '`' - ; +; -QuotedIdentifier - : - '`' ( '``' | ~('`') )* '`' - ; +QuotedIdentifier: '`' ( '``' | ~('`'))* '`'; -CharSetName - : '_' (Letter | Digit | '_' | '-' | '.' | ':' )+ - ; +CharSetName: '_' (Letter | Digit | '_' | '-' | '.' | ':')+; -WS : (' '|'\r'|'\t'|'\n') -> channel(HIDDEN) - ; +WS: (' ' | '\r' | '\t' | '\n') -> channel(HIDDEN); -LINE_COMMENT - : '--' (~('\n'|'\r'))* -> channel(HIDDEN) - ; +LINE_COMMENT: '--' (~('\n' | '\r'))* -> channel(HIDDEN); /* QUERY_HINT有可能是一般注释,这时直接忽略。 也有可能是查询注释,这时用原来的逻辑提取出来 */ -QUERY_HINT - : SHOW_HINT - | HIDDEN_HINT - ; - -SHOW_HINT - : '/*+' (QUERY_HINT | .)*? '*/' ->channel(HIDDEN) - ; - -HIDDEN_HINT - : '/*' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN) - ; +QUERY_HINT: SHOW_HINT | HIDDEN_HINT; + +SHOW_HINT: '/*+' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN); + +HIDDEN_HINT: '/*' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN); \ No newline at end of file diff --git a/sql/hive/v3/HiveParser.g4 b/sql/hive/v3/HiveParser.g4 index 8e697b7a02..89b25f92b3 100644 --- a/sql/hive/v3/HiveParser.g4 +++ b/sql/hive/v3/HiveParser.g4 @@ -17,36 +17,37 @@ @author wyruweso based on the Hive 3.1.2 grammar by Canwei He */ + +// $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 HiveParser; import SelectClauseParser, FromClauseParser, IdentifiersParser; options { - tokenVocab=HiveLexer; + tokenVocab = HiveLexer; } // starting rule statements - : (statement statementSeparator)* EOF - ; + : (statement statementSeparator)* EOF + ; statementSeparator - : SEMICOLON - | - ; + : SEMICOLON + | + ; statement - : explainStatement - | execStatement - ; + : explainStatement + | execStatement + ; explainStatement - : KW_EXPLAIN ( - explainOption* execStatement - | KW_REWRITE queryStatementExpression - ) - ; + : KW_EXPLAIN (explainOption* execStatement | KW_REWRITE queryStatementExpression) + ; explainOption : KW_EXTENDED @@ -94,35 +95,22 @@ replicationClause ; exportStatement - : KW_EXPORT - KW_TABLE tableOrPartition - KW_TO StringLiteral - replicationClause? + : KW_EXPORT KW_TABLE tableOrPartition KW_TO StringLiteral replicationClause? ; importStatement - : KW_IMPORT - (KW_EXTERNAL? KW_TABLE tableOrPartition)? - KW_FROM (path=StringLiteral) - tableLocation? + : KW_IMPORT (KW_EXTERNAL? KW_TABLE tableOrPartition)? KW_FROM (path = StringLiteral) tableLocation? ; replDumpStatement - : KW_REPL KW_DUMP - identifier (DOT identifier)? - (KW_FROM Number - (KW_TO Number)? - (KW_LIMIT Number)? - )? - (KW_WITH replConfigs)? + : KW_REPL KW_DUMP identifier (DOT identifier)? ( + KW_FROM Number (KW_TO Number)? (KW_LIMIT Number)? + )? (KW_WITH replConfigs)? ; replLoadStatement - : KW_REPL KW_LOAD - (identifier (DOT identifier)?)? - KW_FROM StringLiteral - (KW_WITH replConfigs)? - ; + : KW_REPL KW_LOAD (identifier (DOT identifier)?)? KW_FROM StringLiteral (KW_WITH replConfigs)? + ; replConfigs : LPAREN replConfigsList RPAREN @@ -133,10 +121,8 @@ replConfigsList ; replStatusStatement - : KW_REPL KW_STATUS - identifier (DOT identifier)? - (KW_WITH replConfigs)? - ; + : KW_REPL KW_STATUS identifier (DOT identifier)? (KW_WITH replConfigs)? + ; ddlStatement : createDatabaseStatement @@ -211,65 +197,46 @@ orReplace ; createDatabaseStatement - : KW_CREATE (KW_DATABASE|KW_SCHEMA) - ifNotExists? - identifier - databaseComment? - dbLocation? - (KW_WITH KW_DBPROPERTIES dbProperties)? + : KW_CREATE (KW_DATABASE | KW_SCHEMA) ifNotExists? identifier databaseComment? dbLocation? ( + KW_WITH KW_DBPROPERTIES dbProperties + )? ; dbLocation - : - KW_LOCATION StringLiteral + : KW_LOCATION StringLiteral ; dbProperties - : - LPAREN dbPropertiesList RPAREN + : LPAREN dbPropertiesList RPAREN ; dbPropertiesList - : - keyValueProperty (COMMA keyValueProperty)* + : keyValueProperty (COMMA keyValueProperty)* ; - switchDatabaseStatement : KW_USE identifier ; dropDatabaseStatement - : KW_DROP (KW_DATABASE|KW_SCHEMA) ifExists? identifier restrictOrCascade? + : KW_DROP (KW_DATABASE | KW_SCHEMA) ifExists? identifier restrictOrCascade? ; databaseComment - : KW_COMMENT StringLiteral ; createTableStatement - : KW_CREATE KW_TEMPORARY? KW_EXTERNAL? KW_TABLE ifNotExists? tableName - ( KW_LIKE tableName - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - | (LPAREN columnNameTypeOrConstraintList RPAREN)? - tableComment? - tablePartition? - tableBuckets? - tableSkewed? - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - (KW_AS selectStatementWithCTE)? - ) + : KW_CREATE KW_TEMPORARY? KW_EXTERNAL? KW_TABLE ifNotExists? tableName ( + KW_LIKE tableName tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? + | (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? tablePartition? tableBuckets? tableSkewed? tableRowFormat? tableFileFormat? + tableLocation? tablePropertiesPrefixed? (KW_AS selectStatementWithCTE)? + ) ; truncateTableStatement - : KW_TRUNCATE KW_TABLE tablePartitionPrefix (KW_COLUMNS LPAREN columnNameList RPAREN)?; + : KW_TRUNCATE KW_TABLE tablePartitionPrefix (KW_COLUMNS LPAREN columnNameList RPAREN)? + ; dropTableStatement : KW_DROP KW_TABLE ifExists? tableName KW_PURGE? replicationClause? @@ -279,7 +246,7 @@ alterStatement : KW_ALTER KW_TABLE tableName alterTableStatementSuffix | KW_ALTER KW_VIEW tableName KW_AS? alterViewStatementSuffix | KW_ALTER KW_MATERIALIZED KW_VIEW tableName alterMaterializedViewStatementSuffix - | KW_ALTER (KW_DATABASE|KW_SCHEMA) alterDatabaseStatementSuffix + | KW_ALTER (KW_DATABASE | KW_SCHEMA) alterDatabaseStatementSuffix | KW_ALTER KW_INDEX alterIndexStatementSuffix ; @@ -301,24 +268,24 @@ alterTableStatementSuffix ; alterTblPartitionStatementSuffix - : alterStatementSuffixFileFormat - | alterStatementSuffixLocation - | alterStatementSuffixMergeFiles - | alterStatementSuffixSerdeProperties - | alterStatementSuffixRenamePart - | alterStatementSuffixBucketNum - | alterTblPartitionStatementSuffixSkewedLocation - | alterStatementSuffixClusterbySortby - | alterStatementSuffixCompact - | alterStatementSuffixUpdateStatsCol - | alterStatementSuffixUpdateStats - | alterStatementSuffixRenameCol - | alterStatementSuffixAddCol - ; + : alterStatementSuffixFileFormat + | alterStatementSuffixLocation + | alterStatementSuffixMergeFiles + | alterStatementSuffixSerdeProperties + | alterStatementSuffixRenamePart + | alterStatementSuffixBucketNum + | alterTblPartitionStatementSuffixSkewedLocation + | alterStatementSuffixClusterbySortby + | alterStatementSuffixCompact + | alterStatementSuffixUpdateStatsCol + | alterStatementSuffixUpdateStats + | alterStatementSuffixRenameCol + | alterStatementSuffixAddCol + ; alterStatementPartitionKeyType - : KW_PARTITION KW_COLUMN LPAREN columnNameType RPAREN - ; + : KW_PARTITION KW_COLUMN LPAREN columnNameType RPAREN + ; alterViewStatementSuffix : alterViewSuffixProperties @@ -360,19 +327,23 @@ alterStatementSuffixAddCol ; alterStatementSuffixAddConstraint - : KW_ADD (alterForeignKeyWithName | alterConstraintWithName) - ; + : KW_ADD (alterForeignKeyWithName | alterConstraintWithName) + ; alterStatementSuffixDropConstraint - : KW_DROP KW_CONSTRAINT identifier - ; + : KW_DROP KW_CONSTRAINT identifier + ; alterStatementSuffixRenameCol - : KW_CHANGE KW_COLUMN? identifier identifier colType alterColumnConstraint? (KW_COMMENT StringLiteral)? alterStatementChangeColPosition? restrictOrCascade? + : KW_CHANGE KW_COLUMN? identifier identifier colType alterColumnConstraint? ( + KW_COMMENT StringLiteral + )? alterStatementChangeColPosition? restrictOrCascade? ; alterStatementSuffixUpdateStatsCol - : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties (KW_COMMENT StringLiteral)? + : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties ( + KW_COMMENT StringLiteral + )? ; alterStatementSuffixUpdateStats @@ -380,7 +351,8 @@ alterStatementSuffixUpdateStats ; alterStatementChangeColPosition - : first=KW_FIRST|KW_AFTER identifier + : first = KW_FIRST + | KW_AFTER identifier ; alterStatementSuffixAddPartitions @@ -435,23 +407,22 @@ alterStatementSuffixSerdeProperties ; alterIndexStatementSuffix - : identifier KW_ON tableName - partitionSpec? - KW_REBUILD; + : identifier KW_ON tableName partitionSpec? KW_REBUILD + ; alterStatementSuffixFileFormat - : KW_SET KW_FILEFORMAT fileFormat - ; + : KW_SET KW_FILEFORMAT fileFormat + ; alterStatementSuffixClusterbySortby - : KW_NOT KW_CLUSTERED - | KW_NOT KW_SORTED - | tableBuckets - ; + : KW_NOT KW_CLUSTERED + | KW_NOT KW_SORTED + | tableBuckets + ; alterTblPartitionStatementSuffixSkewedLocation - : KW_SET KW_SKEWED KW_LOCATION skewedLocations - ; + : KW_SET KW_SKEWED KW_LOCATION skewedLocations + ; skewedLocations : LPAREN skewedLocationsList RPAREN @@ -466,15 +437,14 @@ skewedLocationMap ; alterStatementSuffixLocation - : KW_SET KW_LOCATION StringLiteral - ; - + : KW_SET KW_LOCATION StringLiteral + ; alterStatementSuffixSkewedby - : tableSkewed - | KW_NOT KW_SKEWED - | KW_NOT storedAsDirs - ; + : tableSkewed + | KW_NOT KW_SKEWED + | KW_NOT storedAsDirs + ; alterStatementSuffixExchangePartition : KW_EXCHANGE partitionSpec KW_WITH KW_TABLE tableName @@ -485,7 +455,9 @@ alterStatementSuffixRenamePart ; alterStatementSuffixStatsPart - : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties (KW_COMMENT StringLiteral)? + : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? identifier KW_SET tableProperties ( + KW_COMMENT StringLiteral + )? ; alterStatementSuffixMergeFiles @@ -497,30 +469,28 @@ alterStatementSuffixBucketNum ; createIndexStatement - : KW_CREATE KW_INDEX identifier KW_ON KW_TABLE tableName columnParenthesesList KW_AS StringLiteral - (KW_WITH KW_DEFERRED KW_REBUILD)? - (KW_IDXPROPERTIES tableProperties)? - (KW_IN KW_TABLE tableName)? - (KW_PARTITIONED KW_BY columnParenthesesList)? - (tableRowFormat? tableFileFormat)? - (KW_LOCATION locationPath)? - tablePropertiesPrefixed? - tableComment?; + : KW_CREATE KW_INDEX identifier KW_ON KW_TABLE tableName columnParenthesesList KW_AS StringLiteral ( + KW_WITH KW_DEFERRED KW_REBUILD + )? (KW_IDXPROPERTIES tableProperties)? (KW_IN KW_TABLE tableName)? ( + KW_PARTITIONED KW_BY columnParenthesesList + )? (tableRowFormat? tableFileFormat)? (KW_LOCATION locationPath)? tablePropertiesPrefixed? tableComment? + ; locationPath : identifier (DOT identifier)* ; dropIndexStatement - : KW_DROP KW_INDEX identifier KW_ON tableName; + : KW_DROP KW_INDEX identifier KW_ON tableName + ; tablePartitionPrefix - : tableName partitionSpec? - ; + : tableName partitionSpec? + ; blocking - : KW_AND KW_WAIT - ; + : KW_AND KW_WAIT + ; alterStatementSuffixCompact : KW_COMPACT StringLiteral blocking? (KW_WITH KW_OVERWRITE KW_TBLPROPERTIES tableProperties)? @@ -531,7 +501,9 @@ alterStatementSuffixSetOwner ; fileFormat - : KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral KW_SERDE StringLiteral (KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral)? + : KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral KW_SERDE StringLiteral ( + KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral + )? | identifier ; @@ -540,15 +512,10 @@ inputFileFormat ; tabTypeExpr - : identifier (DOT identifier)? - ( identifier (DOT - ( KW_ELEM_TYPE - | KW_KEY_TYPE - | KW_VALUE_TYPE - | identifier ) - )* - )? - ; + : identifier (DOT identifier)? ( + identifier (DOT ( KW_ELEM_TYPE | KW_KEY_TYPE | KW_VALUE_TYPE | identifier))* + )? + ; partTypeExpr : tabTypeExpr partitionSpec? @@ -559,51 +526,52 @@ tabPartColTypeExpr ; descStatement - : (KW_DESCRIBE|KW_DESC) - ( - (KW_DATABASE|KW_SCHEMA) KW_EXTENDED? identifier - | KW_FUNCTION KW_EXTENDED? descFuncNames - | ((KW_FORMATTED|KW_EXTENDED) tabPartColTypeExpr) - | tabPartColTypeExpr + : (KW_DESCRIBE | KW_DESC) ( + (KW_DATABASE | KW_SCHEMA) KW_EXTENDED? identifier + | KW_FUNCTION KW_EXTENDED? descFuncNames + | ((KW_FORMATTED | KW_EXTENDED) tabPartColTypeExpr) + | tabPartColTypeExpr ) ; analyzeStatement - : KW_ANALYZE KW_TABLE (tableOrPartition) - ( KW_COMPUTE KW_STATISTICS (KW_NOSCAN | (KW_FOR KW_COLUMNS columnNameList?))? - | KW_CACHE KW_METADATA - ) + : KW_ANALYZE KW_TABLE (tableOrPartition) ( + KW_COMPUTE KW_STATISTICS (KW_NOSCAN | (KW_FOR KW_COLUMNS columnNameList?))? + | KW_CACHE KW_METADATA + ) ; showStatement - : KW_SHOW (KW_DATABASES|KW_SCHEMAS) (KW_LIKE showStmtIdentifier)? - | KW_SHOW KW_TABLES ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_VIEWS ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_MATERIALIZED KW_VIEWS ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_COLUMNS (KW_FROM|KW_IN) tableName ((KW_FROM|KW_IN) identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_FUNCTIONS (KW_LIKE showFunctionIdentifier|showFunctionIdentifier)? + : KW_SHOW (KW_DATABASES | KW_SCHEMAS) (KW_LIKE showStmtIdentifier)? + | KW_SHOW KW_TABLES ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_VIEWS ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_MATERIALIZED KW_VIEWS ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_COLUMNS (KW_FROM | KW_IN) tableName ((KW_FROM | KW_IN) identifier)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_FUNCTIONS (KW_LIKE showFunctionIdentifier | showFunctionIdentifier)? | KW_SHOW KW_PARTITIONS tableName partitionSpec? - | KW_SHOW KW_CREATE ( - (KW_DATABASE|KW_SCHEMA) identifier - | - KW_TABLE tableName - ) - | KW_SHOW KW_TABLE KW_EXTENDED ((KW_FROM|KW_IN) identifier)? KW_LIKE showStmtIdentifier partitionSpec? + | KW_SHOW KW_CREATE ((KW_DATABASE | KW_SCHEMA) identifier | KW_TABLE tableName) + | KW_SHOW KW_TABLE KW_EXTENDED ((KW_FROM | KW_IN) identifier)? KW_LIKE showStmtIdentifier partitionSpec? | KW_SHOW KW_TBLPROPERTIES tableName (LPAREN StringLiteral RPAREN)? - | KW_SHOW KW_LOCKS - ( - (KW_DATABASE|KW_SCHEMA) identifier KW_EXTENDED? - | - partTypeExpr? KW_EXTENDED? - ) + | KW_SHOW KW_LOCKS ( + (KW_DATABASE | KW_SCHEMA) identifier KW_EXTENDED? + | partTypeExpr? KW_EXTENDED? + ) | KW_SHOW KW_COMPACTIONS | KW_SHOW KW_TRANSACTIONS | KW_SHOW KW_CONF StringLiteral - | KW_SHOW KW_RESOURCE - ( - (KW_PLAN identifier) - | KW_PLANS - ) + | KW_SHOW KW_RESOURCE ( (KW_PLAN identifier) | KW_PLANS) ; lockStatement @@ -611,11 +579,12 @@ lockStatement ; lockDatabase - : KW_LOCK (KW_DATABASE|KW_SCHEMA) identifier lockMode + : KW_LOCK (KW_DATABASE | KW_SCHEMA) identifier lockMode ; lockMode - : KW_SHARED | KW_EXCLUSIVE + : KW_SHARED + | KW_EXCLUSIVE ; unlockStatement @@ -623,7 +592,7 @@ unlockStatement ; unlockDatabase - : KW_UNLOCK (KW_DATABASE|KW_SCHEMA) identifier + : KW_UNLOCK (KW_DATABASE | KW_SCHEMA) identifier ; createRoleStatement @@ -635,10 +604,7 @@ dropRoleStatement ; grantPrivileges - : KW_GRANT privilegeList - privilegeObject? - KW_TO principalSpecification - withGrantOption? + : KW_GRANT privilegeList privilegeObject? KW_TO principalSpecification withGrantOption? ; revokePrivileges @@ -657,7 +623,6 @@ showRoleGrants : KW_SHOW KW_ROLE KW_GRANT principalName ; - showRoles : KW_SHOW KW_ROLES ; @@ -667,14 +632,7 @@ showCurrentRole ; setRole - : KW_SET KW_ROLE - ( - KW_ALL - | - KW_NONE - | - identifier - ) + : KW_SET KW_ROLE (KW_ALL | KW_NONE | identifier) ; showGrants @@ -685,7 +643,6 @@ showRolePrincipals : KW_SHOW KW_PRINCIPALS identifier ; - privilegeIncludeColObject : KW_ALL | privObjectCols @@ -697,14 +654,14 @@ privilegeObject // database or table type. Type is optional, default type is table privObject - : (KW_DATABASE|KW_SCHEMA) identifier + : (KW_DATABASE | KW_SCHEMA) identifier | KW_TABLE? tableName partitionSpec? | KW_URI StringLiteral | KW_SERVER identifier ; privObjectCols - : (KW_DATABASE|KW_SCHEMA) identifier + : (KW_DATABASE | KW_SCHEMA) identifier | KW_TABLE? tableName (LPAREN columnNameList RPAREN)? partitionSpec? | KW_URI StringLiteral | KW_SERVER identifier @@ -747,41 +704,41 @@ withGrantOption grantOptionFor : KW_GRANT KW_OPTION KW_FOR -; + ; adminOptionFor : KW_ADMIN KW_OPTION KW_FOR -; + ; withAdminOption : KW_WITH KW_ADMIN KW_OPTION ; metastoreCheck - : KW_MSCK KW_REPAIR? - (KW_TABLE tableName - ((KW_ADD | KW_DROP | KW_SYNC) KW_PARTITIONS)? | - partitionSpec?) + : KW_MSCK KW_REPAIR? ( + KW_TABLE tableName ((KW_ADD | KW_DROP | KW_SYNC) KW_PARTITIONS)? + | partitionSpec? + ) ; resourceList - : - resource (COMMA resource)* - ; + : resource (COMMA resource)* + ; resource - : resourceType StringLiteral - ; + : resourceType StringLiteral + ; resourceType - : KW_JAR - | KW_FILE - | KW_ARCHIVE - ; + : KW_JAR + | KW_FILE + | KW_ARCHIVE + ; createFunctionStatement - : KW_CREATE KW_TEMPORARY? KW_FUNCTION functionIdentifier KW_AS StringLiteral - (KW_USING resourceList)? + : KW_CREATE KW_TEMPORARY? KW_FUNCTION functionIdentifier KW_AS StringLiteral ( + KW_USING resourceList + )? ; dropFunctionStatement @@ -793,8 +750,7 @@ reloadFunctionStatement ; createMacroStatement - : KW_CREATE KW_TEMPORARY KW_MACRO Identifier - LPAREN columnNameTypeList? RPAREN expression + : KW_CREATE KW_TEMPORARY KW_MACRO Identifier LPAREN columnNameTypeList? RPAREN expression ; dropMacroStatement @@ -802,16 +758,12 @@ dropMacroStatement ; createViewStatement - : KW_CREATE orReplace? KW_VIEW ifNotExists? tableName - (LPAREN columnNameCommentList RPAREN)? tableComment? viewPartition? - tablePropertiesPrefixed? - KW_AS - selectStatementWithCTE + : KW_CREATE orReplace? KW_VIEW ifNotExists? tableName (LPAREN columnNameCommentList RPAREN)? tableComment? viewPartition? tablePropertiesPrefixed? + KW_AS selectStatementWithCTE ; createMaterializedViewStatement - : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? tableName - rewriteDisabled? tableComment? tableRowFormat? tableFileFormat? tableLocation? + : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? tableName rewriteDisabled? tableComment? tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? KW_AS selectStatementWithCTE ; @@ -846,7 +798,9 @@ tablePartition ; tableBuckets - : KW_CLUSTERED KW_BY LPAREN columnNameList RPAREN (KW_SORTED KW_BY LPAREN columnNameOrderList RPAREN)? KW_INTO Number KW_BUCKETS + : KW_CLUSTERED KW_BY LPAREN columnNameList RPAREN ( + KW_SORTED KW_BY LPAREN columnNameOrderList RPAREN + )? KW_INTO Number KW_BUCKETS ; tableSkewed @@ -871,7 +825,8 @@ rowFormatSerde ; rowFormatDelimited - : KW_ROW KW_FORMAT KW_DELIMITED tableRowFormatFieldIdentifier? tableRowFormatCollItemsIdentifier? tableRowFormatMapKeysIdentifier? tableRowFormatLinesIdentifier? tableRowNullFormat? + : KW_ROW KW_FORMAT KW_DELIMITED tableRowFormatFieldIdentifier? tableRowFormatCollItemsIdentifier? tableRowFormatMapKeysIdentifier? + tableRowFormatLinesIdentifier? tableRowNullFormat? ; tableRowFormat @@ -919,11 +874,13 @@ tableRowFormatLinesIdentifier tableRowNullFormat : KW_NULL KW_DEFINED KW_AS StringLiteral ; + tableFileFormat - : KW_STORED KW_AS KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral (KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral)? - | KW_STORED KW_BY StringLiteral - (KW_WITH KW_SERDEPROPERTIES tableProperties)? - | KW_STORED KW_AS identifier + : KW_STORED KW_AS KW_INPUTFORMAT StringLiteral KW_OUTPUTFORMAT StringLiteral ( + KW_INPUTDRIVER StringLiteral KW_OUTPUTDRIVER StringLiteral + )? + | KW_STORED KW_BY StringLiteral (KW_WITH KW_SERDEPROPERTIES tableProperties)? + | KW_STORED KW_AS identifier ; tableLocation @@ -983,8 +940,8 @@ enforcedSpecification ; relySpecification - : KW_RELY - | (KW_NORELY)? + : KW_RELY + | (KW_NORELY)? ; createConstraint @@ -996,15 +953,15 @@ alterConstraintWithName ; pkConstraint - : tableConstraintPrimaryKey pkCols=columnParenthesesList + : tableConstraintPrimaryKey pkCols = columnParenthesesList ; createForeignKey - : (KW_CONSTRAINT identifier)? KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsCreate? + : (KW_CONSTRAINT identifier)? KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsCreate? ; alterForeignKeyWithName - : KW_CONSTRAINT identifier KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsAlter? + : KW_CONSTRAINT identifier KW_FOREIGN KW_KEY columnParenthesesList KW_REFERENCES tableName columnParenthesesList constraintOptsAlter? ; skewedValueElement @@ -1064,13 +1021,13 @@ columnNameType ; columnNameTypeOrConstraint - : ( tableConstraint ) - | ( columnNameTypeConstraint ) + : (tableConstraint) + | ( columnNameTypeConstraint) ; tableConstraint - : ( createForeignKey ) - | ( createConstraint ) + : (createForeignKey) + | ( createConstraint) ; columnNameTypeConstraint @@ -1078,8 +1035,8 @@ columnNameTypeConstraint ; columnConstraint - : ( foreignKeyConstraint ) - | ( colConstraint ) + : (foreignKeyConstraint) + | ( colConstraint) ; foreignKeyConstraint @@ -1091,8 +1048,8 @@ colConstraint ; alterColumnConstraint - : ( alterForeignKeyConstraint ) - | ( alterColConstraint ) + : (alterForeignKeyConstraint) + | ( alterColConstraint) ; alterForeignKeyConstraint @@ -1187,9 +1144,7 @@ queryStatementExpression /* Would be nice to do this as a gated semantic perdicate But the predicate gets pushed as a lookahead decision. Calling rule doesnot know about topLevel - */ - withClause? - queryStatementExpressionBody + */ withClause? queryStatementExpressionBody ; queryStatementExpressionBody @@ -1206,10 +1161,8 @@ cteStatement ; fromStatement - : (singleFromStatement) - (setOperator singleFromStatement)* - ; - + : (singleFromStatement) (setOperator singleFromStatement)* + ; singleFromStatement : fromClause body+ @@ -1222,27 +1175,21 @@ The valuesClause rule below ensures that the parse tree for very similar to the tree for "insert into table FOO select a,b from BAR". */ regularBody - : insertClause ( selectStatement | valuesClause) + : insertClause (selectStatement | valuesClause) | selectStatement ; atomSelectStatement - : selectClause - fromClause? - whereClause? - groupByClause? - havingClause? - window_clause? + : selectClause fromClause? whereClause? groupByClause? havingClause? window_clause? | LPAREN selectStatement RPAREN ; selectStatement - : atomSelectStatement setOpSelectStatement? orderByClause? clusterByClause? distributeByClause? sortByClause? limitClause? + : atomSelectStatement setOpSelectStatement? orderByClause? clusterByClause? distributeByClause? sortByClause? limitClause? ; setOpSelectStatement - : - (setOperator atomSelectStatement)+ + : (setOperator atomSelectStatement)+ ; selectStatementWithCTE @@ -1250,30 +1197,10 @@ selectStatementWithCTE ; body - : insertClause - selectClause - lateralView? - whereClause? - groupByClause? - havingClause? - window_clause? - orderByClause? - clusterByClause? - distributeByClause? - sortByClause? - limitClause? - | - selectClause - lateralView? - whereClause? - groupByClause? - havingClause? - window_clause? - orderByClause? - clusterByClause? - distributeByClause? - sortByClause? - limitClause? + : insertClause selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? orderByClause? clusterByClause? + distributeByClause? sortByClause? limitClause? + | selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? orderByClause? clusterByClause? distributeByClause? + sortByClause? limitClause? ; insertClause @@ -1282,97 +1209,99 @@ insertClause ; destination - : KW_LOCAL? KW_DIRECTORY StringLiteral tableRowFormat? tableFileFormat? - | KW_TABLE tableOrPartition - ; + : KW_LOCAL? KW_DIRECTORY StringLiteral tableRowFormat? tableFileFormat? + | KW_TABLE tableOrPartition + ; limitClause - : KW_LIMIT ((Number COMMA)? Number) - | KW_LIMIT Number KW_OFFSET Number - ; + : KW_LIMIT ((Number COMMA)? Number) + | KW_LIMIT Number KW_OFFSET Number + ; //DELETE FROM WHERE ...; deleteStatement - : KW_DELETE KW_FROM tableName whereClause? - ; + : KW_DELETE KW_FROM tableName whereClause? + ; /*SET = (3 + col2)*/ columnAssignmentClause - : tableOrColumn EQUAL expression - ; + : tableOrColumn EQUAL expression + ; /*SET col1 = 5, col2 = (4 + col4), ...*/ setColumnsClause - : KW_SET columnAssignmentClause (COMMA columnAssignmentClause)* - ; + : KW_SET columnAssignmentClause (COMMA columnAssignmentClause)* + ; /* UPDATE
SET col1 = val1, col2 = val2... WHERE ... */ updateStatement - : KW_UPDATE tableName setColumnsClause whereClause? - ; + : KW_UPDATE tableName setColumnsClause whereClause? + ; /* BEGIN user defined transaction boundaries; follows SQL 2003 standard exactly except for addition of "setAutoCommitStatement" which is not in the standard doc but is supported by most SQL engines. */ sqlTransactionStatement - : startTransactionStatement - | commitStatement - | rollbackStatement - | setAutoCommitStatement - ; + : startTransactionStatement + | commitStatement + | rollbackStatement + | setAutoCommitStatement + ; startTransactionStatement - : KW_START KW_TRANSACTION ( transactionMode ( COMMA transactionMode )* )? - ; + : KW_START KW_TRANSACTION (transactionMode ( COMMA transactionMode)*)? + ; transactionMode - : isolationLevel - | transactionAccessMode - ; + : isolationLevel + | transactionAccessMode + ; transactionAccessMode - : KW_READ KW_ONLY - | KW_READ KW_WRITE - ; + : KW_READ KW_ONLY + | KW_READ KW_WRITE + ; isolationLevel - : KW_ISOLATION KW_LEVEL levelOfIsolation - ; + : KW_ISOLATION KW_LEVEL levelOfIsolation + ; /*READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE may be supported later*/ levelOfIsolation - : KW_SNAPSHOT - ; + : KW_SNAPSHOT + ; commitStatement - : KW_COMMIT KW_WORK? - ; + : KW_COMMIT KW_WORK? + ; rollbackStatement - : KW_ROLLBACK KW_WORK? - ; + : KW_ROLLBACK KW_WORK? + ; + setAutoCommitStatement - : KW_SET KW_AUTOCOMMIT booleanValueTok - ; + : KW_SET KW_AUTOCOMMIT booleanValueTok + ; + /* END user defined transaction boundaries */ abortTransactionStatement - : KW_ABORT KW_TRANSACTIONS Number+ - ; - + : KW_ABORT KW_TRANSACTIONS Number+ + ; /* BEGIN SQL Merge statement */ mergeStatement - : KW_MERGE KW_INTO tableName (KW_AS? identifier)? KW_USING joinSourcePart KW_ON expression whenClauses - ; + : KW_MERGE KW_INTO tableName (KW_AS? identifier)? KW_USING joinSourcePart KW_ON expression whenClauses + ; + /* Allow 0,1 or 2 WHEN MATCHED clauses and 0 or 1 WHEN NOT MATCHED Each WHEN clause may have AND . @@ -1380,25 +1309,30 @@ If 2 WHEN MATCHED clauses are present, 1 must be UPDATE the other DELETE and the must have AND */ whenClauses - : (whenMatchedAndClause|whenMatchedThenClause)* whenNotMatchedClause? - ; + : (whenMatchedAndClause | whenMatchedThenClause)* whenNotMatchedClause? + ; + whenNotMatchedClause - : KW_WHEN KW_NOT KW_MATCHED (KW_AND expression)? KW_THEN KW_INSERT KW_VALUES valueRowConstructor - ; + : KW_WHEN KW_NOT KW_MATCHED (KW_AND expression)? KW_THEN KW_INSERT KW_VALUES valueRowConstructor + ; + whenMatchedAndClause - : KW_WHEN KW_MATCHED KW_AND expression KW_THEN updateOrDelete - ; + : KW_WHEN KW_MATCHED KW_AND expression KW_THEN updateOrDelete + ; + whenMatchedThenClause - : KW_WHEN KW_MATCHED KW_THEN updateOrDelete - ; + : KW_WHEN KW_MATCHED KW_THEN updateOrDelete + ; + updateOrDelete - : KW_UPDATE setColumnsClause - | KW_DELETE - ; + : KW_UPDATE setColumnsClause + | KW_DELETE + ; + /* END SQL Merge statement */ killQueryStatement - : KW_KILL KW_QUERY StringLiteral+ - ; + : KW_KILL KW_QUERY StringLiteral+ + ; \ No newline at end of file diff --git a/sql/hive/v3/IdentifiersParser.g4 b/sql/hive/v3/IdentifiersParser.g4 index b5b1417e53..53b3932aed 100644 --- a/sql/hive/v3/IdentifiersParser.g4 +++ b/sql/hive/v3/IdentifiersParser.g4 @@ -16,6 +16,10 @@ @author Canwei He */ + +// $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 IdentifiersParser; //----------------------------------------------------------------------------------- @@ -38,29 +42,24 @@ groupByEmpty // standard rollup syntax rollupStandard - : (KW_ROLLUP | KW_CUBE) - LPAREN expression ( COMMA expression)* RPAREN + : (KW_ROLLUP | KW_CUBE) LPAREN expression (COMMA expression)* RPAREN ; // old hive rollup syntax rollupOldSyntax - : expressionsNotInParenthesis - (KW_WITH KW_ROLLUP | KW_WITH KW_CUBE) ? - (KW_GROUPING KW_SETS - LPAREN groupingSetExpression ( COMMA groupingSetExpression)* RPAREN ) ? + : expressionsNotInParenthesis (KW_WITH KW_ROLLUP | KW_WITH KW_CUBE)? ( + KW_GROUPING KW_SETS LPAREN groupingSetExpression (COMMA groupingSetExpression)* RPAREN + )? ; - groupingSetExpression - : groupingSetExpressionMultiple - | groupingExpressionSingle - ; + : groupingSetExpressionMultiple + | groupingExpressionSingle + ; groupingSetExpressionMultiple - : LPAREN - expression? (COMMA expression)* - RPAREN - ; + : LPAREN expression? (COMMA expression)* RPAREN + ; groupingExpressionSingle : expression @@ -101,7 +100,7 @@ columnRefOrderNotInParenthesis // order by a,b orderByClause - : KW_ORDER KW_BY columnRefOrder ( COMMA columnRefOrder)* + : KW_ORDER KW_BY columnRefOrder (COMMA columnRefOrder)* ; clusterByClause @@ -117,61 +116,37 @@ distributeByClause ; sortByClause - : KW_SORT KW_BY - ( - columnRefOrderInParenthesis - | - columnRefOrderNotInParenthesis - ) + : KW_SORT KW_BY (columnRefOrderInParenthesis | columnRefOrderNotInParenthesis) ; // fun(par1, par2, par3) function_ - : functionName - LPAREN - ( + : functionName LPAREN ( STAR | (KW_DISTINCT | KW_ALL)? (selectExpression (COMMA selectExpression)*)? - ) - RPAREN (KW_OVER window_specification)? + ) RPAREN (KW_OVER window_specification)? ; functionName : // Keyword IF is also a function name functionIdentifier - | - sql11ReservedKeywordsUsedAsFunctionName + | sql11ReservedKeywordsUsedAsFunctionName ; castExpression - : KW_CAST - LPAREN - expression - KW_AS - primitiveType - RPAREN + : KW_CAST LPAREN expression KW_AS primitiveType RPAREN ; caseExpression - : KW_CASE expression - (KW_WHEN expression KW_THEN expression)+ - (KW_ELSE expression)? - KW_END + : KW_CASE expression (KW_WHEN expression KW_THEN expression)+ (KW_ELSE expression)? KW_END ; whenExpression - : KW_CASE - ( KW_WHEN expression KW_THEN expression)+ - (KW_ELSE expression)? - KW_END + : KW_CASE (KW_WHEN expression KW_THEN expression)+ (KW_ELSE expression)? KW_END ; floorExpression - : KW_FLOOR - LPAREN - expression - (KW_TO floorDateQualifiers)? - RPAREN + : KW_FLOOR LPAREN expression (KW_TO floorDateQualifiers)? RPAREN ; floorDateQualifiers @@ -186,12 +161,7 @@ floorDateQualifiers ; extractExpression - : KW_EXTRACT - LPAREN - timeQualifiers - KW_FROM - expression - RPAREN + : KW_EXTRACT LPAREN timeQualifiers KW_FROM expression RPAREN ; timeQualifiers @@ -401,25 +371,24 @@ booleanValue ; booleanValueTok - : KW_TRUE - | KW_FALSE - ; + : KW_TRUE + | KW_FALSE + ; tableOrPartition - : tableName partitionSpec? - ; + : tableName partitionSpec? + ; partitionSpec - : KW_PARTITION - LPAREN partitionVal (COMMA partitionVal)* RPAREN - ; + : KW_PARTITION LPAREN partitionVal (COMMA partitionVal)* RPAREN + ; partitionVal : identifier (EQUAL constant)? ; dropPartitionSpec - : KW_PARTITION LPAREN dropPartitionVal (COMMA dropPartitionVal )* RPAREN + : KW_PARTITION LPAREN dropPartitionVal (COMMA dropPartitionVal)* RPAREN ; dropPartitionVal @@ -511,24 +480,156 @@ principalIdentifier //If you are not sure, please refer to the SQL2011 column in //http://www.postgresql.org/docs/9.5/static/sql-keywords-appendix.html nonReserved - : KW_ABORT | KW_ADD | KW_ADMIN | KW_AFTER | KW_ANALYZE | KW_ARCHIVE | KW_ASC | KW_BEFORE | KW_BUCKET | KW_BUCKETS - | KW_CASCADE | KW_CHANGE | KW_CHECK | KW_CLUSTER | KW_CLUSTERED | KW_CLUSTERSTATUS | KW_COLLECTION | KW_COLUMNS - | KW_COMMENT | KW_COMPACT | KW_COMPACTIONS | KW_COMPUTE | KW_CONCATENATE | KW_CONTINUE | KW_DATA | KW_DAY - | KW_DATABASES | KW_DATETIME | KW_DBPROPERTIES | KW_DEFERRED | KW_DEFINED | KW_DELIMITED | KW_DEPENDENCY - | KW_DESC | KW_DIRECTORIES | KW_DIRECTORY | KW_DISABLE | KW_DISTRIBUTE | KW_DOW | KW_ELEM_TYPE - | KW_ENABLE | KW_ENFORCED | KW_ESCAPED | KW_EXCLUSIVE | KW_EXPLAIN | KW_EXPORT | KW_FIELDS | KW_FILE | KW_FILEFORMAT - | KW_FIRST | KW_FORMAT | KW_FORMATTED | KW_FUNCTIONS | KW_HOUR | KW_IDXPROPERTIES - | KW_INDEX | KW_INDEXES | KW_INPATH | KW_INPUTDRIVER | KW_INPUTFORMAT | KW_ITEMS | KW_JAR | KW_KILL - | KW_KEYS | KW_KEY_TYPE | KW_LAST | KW_LIMIT | KW_OFFSET | KW_LINES | KW_LOAD | KW_LOCATION | KW_LOCK | KW_LOCKS | KW_LOGICAL | KW_LONG - | KW_MAPJOIN | KW_MATERIALIZED | KW_METADATA | KW_MINUTE | KW_MONTH | KW_MSCK | KW_NOSCAN | KW_NULLS - | KW_OPTION | KW_OUTPUTDRIVER | KW_OUTPUTFORMAT | KW_OVERWRITE | KW_OWNER | KW_PARTITIONED | KW_PARTITIONS | KW_PLUS - | KW_PRINCIPALS | KW_PURGE | KW_QUERY | KW_QUARTER | KW_READ | KW_REBUILD | KW_RECORDREADER | KW_RECORDWRITER - | KW_RELOAD | KW_RENAME | KW_REPAIR | KW_REPLACE | KW_REPLICATION | KW_RESTRICT | KW_REWRITE - | KW_ROLE | KW_ROLES | KW_SCHEMA | KW_SCHEMAS | KW_SECOND | KW_SEMI | KW_SERDE | KW_SERDEPROPERTIES | KW_SERVER | KW_SETS | KW_SHARED - | KW_SHOW | KW_SHOW_DATABASE | KW_SKEWED | KW_SORT | KW_SORTED | KW_SSL | KW_STATISTICS | KW_STORED - | KW_STREAMTABLE | KW_STRING | KW_STRUCT | KW_TABLES | KW_TBLPROPERTIES | KW_TEMPORARY | KW_TERMINATED - | KW_TINYINT | KW_TOUCH | KW_TRANSACTIONS | KW_UNARCHIVE | KW_UNDO | KW_UNIONTYPE | KW_UNLOCK | KW_UNSET - | KW_UNSIGNED | KW_URI | KW_USE | KW_UTC | KW_UTCTIMESTAMP | KW_VALUE_TYPE | KW_VIEW | KW_WEEK | KW_WHILE | KW_YEAR + : KW_ABORT + | KW_ADD + | KW_ADMIN + | KW_AFTER + | KW_ANALYZE + | KW_ARCHIVE + | KW_ASC + | KW_BEFORE + | KW_BUCKET + | KW_BUCKETS + | KW_CASCADE + | KW_CHANGE + | KW_CHECK + | KW_CLUSTER + | KW_CLUSTERED + | KW_CLUSTERSTATUS + | KW_COLLECTION + | KW_COLUMNS + | KW_COMMENT + | KW_COMPACT + | KW_COMPACTIONS + | KW_COMPUTE + | KW_CONCATENATE + | KW_CONTINUE + | KW_DATA + | KW_DAY + | KW_DATABASES + | KW_DATETIME + | KW_DBPROPERTIES + | KW_DEFERRED + | KW_DEFINED + | KW_DELIMITED + | KW_DEPENDENCY + | KW_DESC + | KW_DIRECTORIES + | KW_DIRECTORY + | KW_DISABLE + | KW_DISTRIBUTE + | KW_DOW + | KW_ELEM_TYPE + | KW_ENABLE + | KW_ENFORCED + | KW_ESCAPED + | KW_EXCLUSIVE + | KW_EXPLAIN + | KW_EXPORT + | KW_FIELDS + | KW_FILE + | KW_FILEFORMAT + | KW_FIRST + | KW_FORMAT + | KW_FORMATTED + | KW_FUNCTIONS + | KW_HOUR + | KW_IDXPROPERTIES + | KW_INDEX + | KW_INDEXES + | KW_INPATH + | KW_INPUTDRIVER + | KW_INPUTFORMAT + | KW_ITEMS + | KW_JAR + | KW_KILL + | KW_KEYS + | KW_KEY_TYPE + | KW_LAST + | KW_LIMIT + | KW_OFFSET + | KW_LINES + | KW_LOAD + | KW_LOCATION + | KW_LOCK + | KW_LOCKS + | KW_LOGICAL + | KW_LONG + | KW_MAPJOIN + | KW_MATERIALIZED + | KW_METADATA + | KW_MINUTE + | KW_MONTH + | KW_MSCK + | KW_NOSCAN + | KW_NULLS + | KW_OPTION + | KW_OUTPUTDRIVER + | KW_OUTPUTFORMAT + | KW_OVERWRITE + | KW_OWNER + | KW_PARTITIONED + | KW_PARTITIONS + | KW_PLUS + | KW_PRINCIPALS + | KW_PURGE + | KW_QUERY + | KW_QUARTER + | KW_READ + | KW_REBUILD + | KW_RECORDREADER + | KW_RECORDWRITER + | KW_RELOAD + | KW_RENAME + | KW_REPAIR + | KW_REPLACE + | KW_REPLICATION + | KW_RESTRICT + | KW_REWRITE + | KW_ROLE + | KW_ROLES + | KW_SCHEMA + | KW_SCHEMAS + | KW_SECOND + | KW_SEMI + | KW_SERDE + | KW_SERDEPROPERTIES + | KW_SERVER + | KW_SETS + | KW_SHARED + | KW_SHOW + | KW_SHOW_DATABASE + | KW_SKEWED + | KW_SORT + | KW_SORTED + | KW_SSL + | KW_STATISTICS + | KW_STORED + | KW_STREAMTABLE + | KW_STRING + | KW_STRUCT + | KW_TABLES + | KW_TBLPROPERTIES + | KW_TEMPORARY + | KW_TERMINATED + | KW_TINYINT + | KW_TOUCH + | KW_TRANSACTIONS + | KW_UNARCHIVE + | KW_UNDO + | KW_UNIONTYPE + | KW_UNLOCK + | KW_UNSET + | KW_UNSIGNED + | KW_URI + | KW_USE + | KW_UTC + | KW_UTCTIMESTAMP + | KW_VALUE_TYPE + | KW_VIEW + | KW_WEEK + | KW_WHILE + | KW_YEAR | KW_WORK | KW_TRANSACTION | KW_WRITE @@ -542,8 +643,11 @@ nonReserved | KW_NOVALIDATE | KW_KEY | KW_MATCHED - | KW_REPL | KW_DUMP | KW_STATUS - | KW_CACHE | KW_VIEWS + | KW_REPL + | KW_DUMP + | KW_STATUS + | KW_CACHE + | KW_VIEWS | KW_VECTORIZATION | KW_SUMMARY | KW_OPERATOR @@ -553,12 +657,39 @@ nonReserved | KW_ZONE | KW_DEFAULT | KW_REOPTIMIZATION - | KW_RESOURCE | KW_PLAN | KW_PLANS | KW_QUERY_PARALLELISM | KW_ACTIVATE | KW_MOVE | KW_DO - | KW_POOL | KW_ALLOC_FRACTION | KW_SCHEDULING_POLICY | KW_PATH | KW_MAPPING | KW_WORKLOAD | KW_MANAGEMENT | KW_ACTIVE | KW_UNMANAGED - -; + | KW_RESOURCE + | KW_PLAN + | KW_PLANS + | KW_QUERY_PARALLELISM + | KW_ACTIVATE + | KW_MOVE + | KW_DO + | KW_POOL + | KW_ALLOC_FRACTION + | KW_SCHEDULING_POLICY + | KW_PATH + | KW_MAPPING + | KW_WORKLOAD + | KW_MANAGEMENT + | KW_ACTIVE + | KW_UNMANAGED + ; //The following SQL2011 reserved keywords are used as function name only, but not as identifiers. sql11ReservedKeywordsUsedAsFunctionName - : KW_IF | KW_ARRAY | KW_MAP | KW_BIGINT | KW_BINARY | KW_BOOLEAN | KW_CURRENT_DATE | KW_CURRENT_TIMESTAMP | KW_DATE | KW_DOUBLE | KW_FLOAT | KW_GROUPING | KW_INT | KW_SMALLINT | KW_TIMESTAMP - ; + : KW_IF + | KW_ARRAY + | KW_MAP + | KW_BIGINT + | KW_BINARY + | KW_BOOLEAN + | KW_CURRENT_DATE + | KW_CURRENT_TIMESTAMP + | KW_DATE + | KW_DOUBLE + | KW_FLOAT + | KW_GROUPING + | KW_INT + | KW_SMALLINT + | KW_TIMESTAMP + ; \ No newline at end of file diff --git a/sql/hive/v3/ResourcePlanParser.g4 b/sql/hive/v3/ResourcePlanParser.g4 index 21a5f3952b..da5b4b15b0 100644 --- a/sql/hive/v3/ResourcePlanParser.g4 +++ b/sql/hive/v3/ResourcePlanParser.g4 @@ -16,8 +16,11 @@ @author Canwei He */ -parser grammar ResourcePlanParser; +// $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 ResourcePlanParser; resourcePlanDdlStatements : createResourcePlanStatement @@ -37,65 +40,59 @@ resourcePlanDdlStatements ; rpAssign - : (KW_QUERY_PARALLELISM EQUAL Number) - | (KW_DEFAULT KW_POOL EQUAL poolPath) - ; + : (KW_QUERY_PARALLELISM EQUAL Number) + | (KW_DEFAULT KW_POOL EQUAL poolPath) + ; rpAssignList - : rpAssign (COMMA rpAssign)* - ; + : rpAssign (COMMA rpAssign)* + ; rpUnassign - : (KW_QUERY_PARALLELISM) - | (KW_DEFAULT KW_POOL) - ; + : (KW_QUERY_PARALLELISM) + | (KW_DEFAULT KW_POOL) + ; rpUnassignList - : rpUnassign (COMMA rpUnassign)* - ; + : rpUnassign (COMMA rpUnassign)* + ; createResourcePlanStatement : KW_CREATE KW_RESOURCE KW_PLAN ( - (identifier KW_LIKE identifier) + (identifier KW_LIKE identifier) | (identifier (KW_WITH rpAssignList)?) - ) + ) ; - withReplace : KW_WITH KW_REPLACE ; - activate : KW_ACTIVATE withReplace? ; - enable : KW_ENABLE ; - disable : KW_DISABLE ; - unmanaged : KW_UNMANAGED ; - alterResourcePlanStatement : KW_ALTER KW_RESOURCE KW_PLAN identifier ( - (KW_VALIDATE) + (KW_VALIDATE) | (KW_DISABLE) | (KW_SET rpAssignList) | (KW_UNSET rpUnassignList) | (KW_RENAME KW_TO identifier) | ((activate enable? | enable activate?)) - ) + ) ; /** It might make sense to make this more generic, if something else could be enabled/disabled. @@ -106,9 +103,9 @@ globalWmStatement replaceResourcePlanStatement : KW_REPLACE ( - (KW_ACTIVE KW_RESOURCE KW_PLAN KW_WITH identifier) + (KW_ACTIVE KW_RESOURCE KW_PLAN KW_WITH identifier) | (KW_RESOURCE KW_PLAN identifier KW_WITH identifier) - ) + ) ; dropResourcePlanStatement @@ -124,7 +121,8 @@ triggerExpression ; triggerExpressionStandalone - : triggerExpression EOF ; + : triggerExpression EOF + ; /* The rules triggerOrExpression and triggerAndExpression are not being used right now. @@ -142,7 +140,6 @@ triggerAtomExpression : identifier comparisionOperator triggerLiteral ; - triggerLiteral : Number | StringLiteral @@ -158,24 +155,23 @@ triggerActionExpression ; triggerActionExpressionStandalone - : triggerActionExpression EOF ; + : triggerActionExpression EOF + ; createTriggerStatement - : KW_CREATE KW_TRIGGER identifier DOT identifier - KW_WHEN triggerExpression KW_DO triggerActionExpression + : KW_CREATE KW_TRIGGER identifier DOT identifier KW_WHEN triggerExpression KW_DO triggerActionExpression ; alterTriggerStatement : KW_ALTER KW_TRIGGER identifier DOT identifier ( (KW_WHEN triggerExpression KW_DO triggerActionExpression) - | (KW_ADD KW_TO KW_POOL poolPath) - | (KW_DROP KW_FROM KW_POOL poolPath) - | (KW_ADD KW_TO KW_UNMANAGED) - | (KW_DROP KW_FROM KW_UNMANAGED) + | (KW_ADD KW_TO KW_POOL poolPath) + | (KW_DROP KW_FROM KW_POOL poolPath) + | (KW_ADD KW_TO KW_UNMANAGED) + | (KW_DROP KW_FROM KW_UNMANAGED) ) ; - dropTriggerStatement : KW_DROP KW_TRIGGER identifier DOT identifier ; @@ -183,10 +179,10 @@ dropTriggerStatement poolAssign : ( (KW_ALLOC_FRACTION EQUAL Number) - | (KW_QUERY_PARALLELISM EQUAL Number) - | (KW_SCHEDULING_POLICY EQUAL StringLiteral) - | (KW_PATH EQUAL poolPath) - ) + | (KW_QUERY_PARALLELISM EQUAL Number) + | (KW_SCHEDULING_POLICY EQUAL StringLiteral) + | (KW_PATH EQUAL poolPath) + ) ; poolAssignList @@ -194,8 +190,7 @@ poolAssignList ; createPoolStatement - : KW_CREATE KW_POOL identifier DOT poolPath - KW_WITH poolAssignList + : KW_CREATE KW_POOL identifier DOT poolPath KW_WITH poolAssignList ; alterPoolStatement @@ -204,7 +199,7 @@ alterPoolStatement | (KW_UNSET KW_SCHEDULING_POLICY) | (KW_ADD KW_TRIGGER identifier) | (KW_DROP KW_TRIGGER identifier) - ) + ) ; dropPoolStatement @@ -212,20 +207,23 @@ dropPoolStatement ; createMappingStatement - : (KW_CREATE (KW_USER | KW_GROUP | KW_APPLICATION) - KW_MAPPING StringLiteral - KW_IN identifier ((KW_TO poolPath) | unmanaged) - (KW_WITH KW_ORDER Number)?) + : ( + KW_CREATE (KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING StringLiteral KW_IN identifier ( + (KW_TO poolPath) + | unmanaged + ) (KW_WITH KW_ORDER Number)? + ) ; alterMappingStatement - : (KW_ALTER (KW_USER | KW_GROUP | KW_APPLICATION) - KW_MAPPING StringLiteral - KW_IN identifier ((KW_TO poolPath) | unmanaged) - (KW_WITH KW_ORDER Number)?) + : ( + KW_ALTER (KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING StringLiteral KW_IN identifier ( + (KW_TO poolPath) + | unmanaged + ) (KW_WITH KW_ORDER Number)? + ) ; dropMappingStatement - : KW_DROP (KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING - StringLiteral KW_IN identifier + : KW_DROP (KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING StringLiteral KW_IN identifier ; \ No newline at end of file diff --git a/sql/hive/v3/SelectClauseParser.g4 b/sql/hive/v3/SelectClauseParser.g4 index 16281a5a23..56b34ab337 100644 --- a/sql/hive/v3/SelectClauseParser.g4 +++ b/sql/hive/v3/SelectClauseParser.g4 @@ -16,42 +16,41 @@ @author Canwei He */ + +// $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 SelectClauseParser; //----------------------- Rules for parsing selectClause ----------------------------- // select a,b,c ... selectClause - : KW_SELECT QUERY_HINT? (((KW_ALL | KW_DISTINCT)? selectList) - | (KW_TRANSFORM selectTrfmClause)) + : KW_SELECT QUERY_HINT? ( + ((KW_ALL | KW_DISTINCT)? selectList) + | (KW_TRANSFORM selectTrfmClause) + ) | trfmClause ; selectList - : selectItem ( COMMA selectItem )* + : selectItem (COMMA selectItem)* ; selectTrfmClause - : LPAREN selectExpressionList RPAREN - rowFormat? recordWriter? - KW_USING StringLiteral - ( KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)))? - rowFormat? recordReader? + : LPAREN selectExpressionList RPAREN rowFormat? recordWriter? KW_USING StringLiteral ( + KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)) + )? rowFormat? recordReader? ; selectItem : tableAllColumns - | ( expression - ((KW_AS? identifier) | (KW_AS LPAREN identifier (COMMA identifier)* RPAREN))? - ) + | (expression ((KW_AS? identifier) | (KW_AS LPAREN identifier (COMMA identifier)* RPAREN))?) ; trfmClause - : ( KW_MAP selectExpressionList - | KW_REDUCE selectExpressionList ) - rowFormat? recordWriter? - KW_USING StringLiteral - ( KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)))? - rowFormat? recordReader? + : (KW_MAP selectExpressionList | KW_REDUCE selectExpressionList) rowFormat? recordWriter? KW_USING StringLiteral ( + KW_AS ((LPAREN (aliasList | columnNameTypeList) RPAREN) | (aliasList | columnNameTypeList)) + )? rowFormat? recordReader? ; selectExpression @@ -65,18 +64,15 @@ selectExpressionList //---------------------- Rules for windowing clauses ------------------------------- window_clause - : - KW_WINDOW window_defn (COMMA window_defn)* + : KW_WINDOW window_defn (COMMA window_defn)* ; window_defn - : - identifier KW_AS window_specification + : identifier KW_AS window_specification ; window_specification - : - (identifier | ( LPAREN identifier? partitioningSpec? window_frame? RPAREN)) + : (identifier | ( LPAREN identifier? partitioningSpec? window_frame? RPAREN)) ; window_frame @@ -85,8 +81,7 @@ window_frame ; window_range_expression - : - KW_ROWS window_frame_start_boundary + : KW_ROWS window_frame_start_boundary | KW_ROWS KW_BETWEEN window_frame_boundary KW_AND window_frame_boundary ; @@ -96,15 +91,13 @@ window_value_expression ; window_frame_start_boundary - : - KW_UNBOUNDED KW_PRECEDING + : KW_UNBOUNDED KW_PRECEDING | KW_CURRENT KW_ROW | Number KW_PRECEDING ; - window_frame_boundary - : - KW_UNBOUNDED (KW_PRECEDING|KW_FOLLOWING) +window_frame_boundary + : KW_UNBOUNDED (KW_PRECEDING | KW_FOLLOWING) | KW_CURRENT KW_ROW - | Number (KW_PRECEDING | KW_FOLLOWING ) - ; + | Number (KW_PRECEDING | KW_FOLLOWING) + ; \ No newline at end of file diff --git a/sql/hive/v4/HiveLexer.g4 b/sql/hive/v4/HiveLexer.g4 index ac2fd0bdc3..552082325d 100644 --- a/sql/hive/v4/HiveLexer.g4 +++ b/sql/hive/v4/HiveLexer.g4 @@ -14,458 +14,450 @@ See the License for the specific language governing permissions and limitations under the License. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar HiveLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} // Keywords -KW_ABORT : 'ABORT'; -KW_ACTIVATE : 'ACTIVATE'; -KW_ACTIVE : 'ACTIVE'; -KW_ADD : 'ADD'; -KW_ADMIN : 'ADMIN'; -KW_AFTER : 'AFTER'; -KW_ALL : 'ALL'; -KW_ALLOC_FRACTION : 'ALLOC_FRACTION'; -KW_ALTER : 'ALTER'; -KW_ANALYZE : 'ANALYZE'; -KW_AND : 'AND'; -KW_ANTI : 'ANTI'; -KW_ANY : 'ANY'; -KW_APPLICATION : 'APPLICATION'; -KW_ARCHIVE : 'ARCHIVE'; -KW_ARRAY : 'ARRAY'; -KW_AS : 'AS'; -KW_ASC : 'ASC'; -KW_AST : 'AST'; -KW_AT : 'AT'; -KW_AUTHORIZATION : 'AUTHORIZATION'; -KW_AUTOCOMMIT : 'AUTOCOMMIT'; -KW_BATCH : 'KW_BATCH'; -KW_BEFORE : 'BEFORE'; -KW_BETWEEN : 'BETWEEN'; -KW_BIGINT : 'BIGINT'; -KW_BINARY : 'BINARY'; -KW_BOOLEAN : 'BOOLEAN'; -KW_BOTH : 'BOTH'; -KW_BUCKET : 'BUCKET'; -KW_BUCKETS : 'BUCKETS'; -KW_BY : 'BY'; -KW_CACHE : 'CACHE'; -KW_CASCADE : 'CASCADE'; -KW_CASE : 'CASE'; -KW_CAST : 'CAST'; -KW_CBO : 'CBO'; -KW_CHANGE : 'CHANGE'; -KW_CHAR : 'CHAR'; -KW_CHECK : 'CHECK'; -KW_CLUSTER : 'CLUSTER'; -KW_CLUSTERED : 'CLUSTERED'; -KW_CLUSTERSTATUS : 'CLUSTERSTATUS'; -KW_COLLECTION : 'COLLECTION'; -KW_COLUMN : 'COLUMN'; -KW_COLUMNS : 'COLUMNS'; -KW_COMMENT : 'COMMENT'; -KW_COMMIT : 'COMMIT'; -KW_COMPACT : 'COMPACT'; -KW_COMPACTIONS : 'COMPACTIONS'; -KW_COMPACT_ID : 'COMPACTIONID'; -KW_COMPUTE : 'COMPUTE'; -KW_CONCATENATE : 'CONCATENATE'; -KW_CONF : 'CONF'; -KW_CONSTRAINT : 'CONSTRAINT'; -KW_CONTINUE : 'CONTINUE'; -KW_COST : 'COST'; -KW_CREATE : 'CREATE'; -KW_CRON : 'CRON'; -KW_CROSS : 'CROSS'; -KW_CUBE : 'CUBE'; -KW_CURRENT : 'CURRENT'; -KW_CURRENT_DATE : 'CURRENT_DATE'; -KW_CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; -KW_CURSOR : 'CURSOR'; -KW_DATA : 'DATA'; -KW_DATABASE : 'DATABASE'; -KW_DATABASES : 'DATABASES'; -KW_DATACONNECTOR : 'CONNECTOR'; -KW_DATACONNECTORS : 'CONNECTORS'; -KW_DATE : 'DATE'; -KW_DATETIME : 'DATETIME'; -KW_DAY : 'DAY' 'S'?; -KW_DAYOFWEEK : 'KW_DAYOFWEEK'; -KW_DBPROPERTIES : 'DBPROPERTIES'; -KW_DCPROPERTIES : 'DCPROPERTIES'; -KW_DDL : 'DDL'; -KW_DEBUG : 'DEBUG'; -KW_DECIMAL : 'DEC' 'IMAL'? | 'NUMERIC'; -KW_DEFAULT : 'DEFAULT'; -KW_DEFERRED : 'DEFERRED'; -KW_DEFINED : 'DEFINED'; -KW_DELETE : 'DELETE'; -KW_DELIMITED : 'DELIMITED'; -KW_DEPENDENCY : 'DEPENDENCY'; -KW_DESC : 'DESC'; -KW_DESCRIBE : 'DESCRIBE'; -KW_DETAIL : 'DETAIL'; -KW_DIRECTORIES : 'DIRECTORIES'; -KW_DIRECTORY : 'DIRECTORY'; -KW_DISABLE : 'DISABLE' 'D'?; -KW_DISTINCT : 'DISTINCT'; -KW_DISTRIBUTE : 'DISTRIBUTE'; -KW_DISTRIBUTED : 'DISTRIBUTED'; -KW_DO : 'DO'; -KW_DOUBLE : 'DOUBLE'; -KW_DOW : 'DAYOFWEEK'; -KW_DROP : 'DROP'; -KW_DUMP : 'DUMP'; -KW_ELEM_TYPE : '$ELEM$'; -KW_ELSE : 'ELSE'; -KW_ENABLE : 'ENABLE' 'D'?; -KW_END : 'END'; -KW_ENFORCED : 'ENFORCED'; -KW_ESCAPED : 'ESCAPED'; -KW_EVERY : 'EVERY'; -KW_EXCEPT : 'EXCEPT'; -KW_EXCHANGE : 'EXCHANGE'; -KW_EXCLUSIVE : 'EXCLUSIVE'; -KW_EXECUTE : 'EXECUTE'; -KW_EXECUTED : 'EXECUTED'; -KW_EXISTS : 'EXISTS'; -KW_EXPIRE_SNAPSHOTS : 'EXPIRE_SNAPSHOTS'; -KW_EXPLAIN : 'EXPLAIN'; -KW_EXPORT : 'EXPORT'; -KW_EXPRESSION : 'EXPRESSION'; -KW_EXTENDED : 'EXTENDED'; -KW_EXTERNAL : 'EXTERNAL'; -KW_EXTRACT : 'EXTRACT'; -KW_FALSE : 'FALSE'; -KW_FETCH : 'FETCH'; -KW_FIELDS : 'FIELDS'; -KW_FILE : 'FILE'; -KW_FILEFORMAT : 'FILEFORMAT'; -KW_FIRST : 'FIRST'; -KW_FLOAT : 'FLOAT'; -KW_FLOOR : 'FLOOR'; -KW_FOLLOWING : 'FOLLOWING'; -KW_FOR : 'FOR'; -KW_FORCE : 'FORCE'; -KW_FOREIGN : 'FOREIGN'; -KW_FORMAT : 'FORMAT'; -KW_FORMATTED : 'FORMATTED'; -KW_FROM : 'FROM'; -KW_FULL : 'FULL'; -KW_FUNCTION : 'FUNCTION'; -KW_FUNCTIONS : 'FUNCTIONS'; -KW_GRANT : 'GRANT'; -KW_GROUP : 'GROUP'; -KW_GROUPING : 'GROUPING'; -KW_HAVING : 'HAVING'; -KW_HOLD_DDLTIME : 'KW_HOLD_DDLTIME'; -KW_HOUR : 'HOUR' 'S'?; -KW_IDXPROPERTIES : 'IDXPROPERTIES'; -KW_IF : 'IF'; -KW_IGNORE : 'IGNORE'; -KW_IMPORT : 'IMPORT'; -KW_IN : 'IN'; -KW_INDEX : 'INDEX'; -KW_INDEXES : 'INDEXES'; -KW_INNER : 'INNER'; -KW_INPATH : 'INPATH'; -KW_INPUTDRIVER : 'INPUTDRIVER'; -KW_INPUTFORMAT : 'INPUTFORMAT'; -KW_INSERT : 'INSERT'; -KW_INT : 'INT' 'EGER'?; -KW_INTERSECT : 'INTERSECT'; -KW_INTERVAL : 'INTERVAL'; -KW_INTO : 'INTO'; -KW_IS : 'IS'; -KW_ISOLATION : 'ISOLATION'; -KW_ITEMS : 'ITEMS'; -KW_JAR : 'JAR'; -KW_JOIN : 'JOIN'; -KW_JOINCOST : 'JOINCOST'; -KW_KEY : 'KEY'; -KW_KEYS : 'KEYS'; -KW_KEY_TYPE : '$KEY$'; -KW_KILL : 'KILL'; -KW_LAST : 'LAST'; -KW_LATERAL : 'LATERAL'; -KW_LEADING : 'LEADING'; -KW_LEFT : 'LEFT'; -KW_LESS : 'LESS'; -KW_LEVEL : 'LEVEL'; -KW_LIKE : 'LIKE'; -KW_LIMIT : 'LIMIT'; -KW_LINES : 'LINES'; -KW_LOAD : 'LOAD'; -KW_LOCAL : 'LOCAL'; -KW_LOCATION : 'LOCATION'; -KW_LOCK : 'LOCK'; -KW_LOCKS : 'LOCKS'; -KW_LOGICAL : 'LOGICAL'; -KW_LONG : 'LONG'; -KW_MACRO : 'MACRO'; -KW_MANAGED : 'MANAGED'; -KW_MANAGEDLOCATION : 'MANAGEDLOCATION'; -KW_MANAGEMENT : 'MANAGEMENT'; -KW_MAP : 'MAP'; -KW_MAPJOIN : 'MAPJOIN'; -KW_MAPPING : 'MAPPING'; -KW_MATCHED : 'MATCHED'; -KW_MATERIALIZED : 'MATERIALIZED'; -KW_MERGE : 'MERGE'; -KW_METADATA : 'METADATA'; -KW_MINUS : 'MINUS'; -KW_MINUTE : 'MINUTE' 'S'?; -KW_MONTH : 'MONTH' 'S'?; -KW_MORE : 'MORE'; -KW_MOVE : 'MOVE'; -KW_MSCK : 'MSCK'; -KW_NONE : 'NONE'; -KW_NORELY : 'NORELY'; -KW_NOSCAN : 'NOSCAN'; -KW_NOT : 'NOT' | '!'; -KW_NOVALIDATE : 'NOVALIDATE'; -KW_NO_DROP : 'KW_NO_DROP'; -KW_NULL : 'NULL'; -KW_NULLS : 'NULLS'; -KW_OF : 'OF'; -KW_OFFLINE : 'KW_OFFLINE'; -KW_OFFSET : 'OFFSET'; -KW_ON : 'ON'; -KW_ONLY : 'ONLY'; -KW_OPERATOR : 'OPERATOR'; -KW_OPTION : 'OPTION'; -KW_OR : 'OR'; -KW_ORDER : 'ORDER'; -KW_OUT : 'OUT'; -KW_OUTER : 'OUTER'; -KW_OUTPUTDRIVER : 'OUTPUTDRIVER'; -KW_OUTPUTFORMAT : 'OUTPUTFORMAT'; -KW_OVER : 'OVER'; -KW_OVERWRITE : 'OVERWRITE'; -KW_OWNER : 'OWNER'; -KW_PARTITION : 'PARTITION'; -KW_PARTITIONED : 'PARTITIONED'; -KW_PARTITIONS : 'PARTITIONS'; -KW_PATH : 'PATH'; -KW_PERCENT : 'PERCENT'; -KW_PKFK_JOIN : 'PKFK_JOIN'; -KW_PLAN : 'PLAN'; -KW_PLANS : 'PLANS'; -KW_PLUS : 'PLUS'; -KW_POOL : 'POOL'; -KW_PRECEDING : 'PRECEDING'; -KW_PRECISION : 'PRECISION'; -KW_PREPARE : 'PREPARE'; -KW_PRESERVE : 'PRESERVE'; -KW_PRIMARY : 'PRIMARY'; -KW_PRINCIPALS : 'PRINCIPALS'; -KW_PROCEDURE : 'PROCEDURE'; -KW_PROTECTION : 'KW_PROTECTION'; -KW_PURGE : 'PURGE'; -KW_QUALIFY : 'QUALIFY'; -KW_QUARTER : 'QUARTER'; -KW_QUERY : 'QUERY'; -KW_QUERY_PARALLELISM : 'QUERY_PARALLELISM'; -KW_RANGE : 'RANGE'; -KW_READ : 'READ'; -KW_READONLY : 'KW_READONLY'; -KW_READS : 'READS'; -KW_REAL : 'REAL'; -KW_REBUILD : 'REBUILD'; -KW_RECORDREADER : 'RECORDREADER'; -KW_RECORDWRITER : 'RECORDWRITER'; -KW_REDUCE : 'REDUCE'; -KW_REFERENCES : 'REFERENCES'; -KW_REGEXP : 'REGEXP'; -KW_RELOAD : 'RELOAD'; -KW_RELY : 'RELY'; -KW_REMOTE : 'REMOTE'; -KW_RENAME : 'RENAME'; -KW_REOPTIMIZATION : 'REOPTIMIZATION'; -KW_REPAIR : 'REPAIR'; -KW_REPL : 'REPL'; -KW_REPLACE : 'REPLACE'; -KW_REPLICATION : 'REPLICATION'; -KW_RESOURCE : 'RESOURCE'; -KW_RESPECT : 'RESPECT'; -KW_RESTRICT : 'RESTRICT'; -KW_REVOKE : 'REVOKE'; -KW_REWRITE : 'REWRITE'; -KW_RIGHT : 'RIGHT'; -KW_RLIKE : 'RLIKE'; -KW_ROLE : 'ROLE'; -KW_ROLES : 'ROLES'; -KW_ROLLBACK : 'ROLLBACK'; -KW_ROLLUP : 'ROLLUP'; -KW_ROW : 'ROW'; -KW_ROWS : 'ROWS'; -KW_SCHEDULED : 'SCHEDULED'; -KW_SCHEDULING_POLICY : 'SCHEDULING_POLICY'; -KW_SCHEMA : 'SCHEMA'; -KW_SCHEMAS : 'SCHEMAS'; -KW_SECOND : 'SECOND' 'S'?; -KW_SELECT : 'SELECT'; -KW_SEMI : 'SEMI'; -KW_SERDE : 'SERDE'; -KW_SERDEPROPERTIES : 'SERDEPROPERTIES'; -KW_SERVER : 'SERVER'; -KW_SET : 'SET'; -KW_SETS : 'SETS'; -KW_SET_CURRENT_SNAPSHOT : 'SET_CURRENT_SNAPSHOT'; -KW_SHARED : 'SHARED'; -KW_SHOW : 'SHOW'; -KW_SHOW_DATABASE : 'SHOW_DATABASE'; -KW_SKEWED : 'SKEWED'; -KW_SMALLINT : 'SMALLINT'; -KW_SNAPSHOT : 'SNAPSHOT'; -KW_SOME : 'SOME'; -KW_SORT : 'SORT'; -KW_SORTED : 'SORTED'; -KW_SPEC : 'SPEC'; -KW_SSL : 'SSL'; -KW_START : 'START'; -KW_STATISTICS : 'STATISTICS'; -KW_STATUS : 'STATUS'; -KW_STORED : 'STORED'; -KW_STREAMTABLE : 'STREAMTABLE'; -KW_STRING : 'STRING'; -KW_STRUCT : 'STRUCT'; -KW_SUMMARY : 'SUMMARY'; -KW_SYNC : 'SYNC'; -KW_SYSTEM_TIME : 'SYSTEM_TIME'; -KW_SYSTEM_VERSION : 'SYSTEM_VERSION'; -KW_TABLE : 'TABLE'; -KW_TABLES : 'TABLES'; -KW_TABLESAMPLE : 'TABLESAMPLE'; -KW_TBLPROPERTIES : 'TBLPROPERTIES'; -KW_TEMPORARY : 'TEMPORARY'; -KW_TERMINATED : 'TERMINATED'; -KW_THEN : 'THEN'; -KW_TIME : 'TIME'; -KW_TIMESTAMP : 'TIMESTAMP'; -KW_TIMESTAMPLOCALTZ : 'TIMESTAMPLOCALTZ'; -KW_TIMESTAMPTZ : 'KW_TIMESTAMPTZ'; -KW_TINYINT : 'TINYINT'; -KW_TO : 'TO'; -KW_TOUCH : 'TOUCH'; -KW_TRAILING : 'TRAILING'; -KW_TRANSACTION : 'TRANSACTION'; -KW_TRANSACTIONAL : 'TRANSACTIONAL'; -KW_TRANSACTIONS : 'TRANSACTIONS'; -KW_TRANSFORM : 'TRANSFORM'; -KW_TRIGGER : 'TRIGGER'; -KW_TRIM : 'TRIM'; -KW_TRUE : 'TRUE'; -KW_TRUNCATE : 'TRUNCATE'; -KW_TYPE : 'TYPE'; -KW_UNARCHIVE : 'UNARCHIVE'; -KW_UNBOUNDED : 'UNBOUNDED'; -KW_UNDO : 'UNDO'; -KW_UNION : 'UNION'; -KW_UNIONTYPE : 'UNIONTYPE'; -KW_UNIQUE : 'UNIQUE'; -KW_UNIQUEJOIN : 'UNIQUEJOIN'; -KW_UNKNOWN : 'UNKNOWN'; -KW_UNLOCK : 'UNLOCK'; -KW_UNMANAGED : 'UNMANAGED'; -KW_UNSET : 'UNSET'; -KW_UNSIGNED : 'UNSIGNED'; -KW_UPDATE : 'UPDATE'; -KW_URI : 'URI'; -KW_URL : 'URL'; -KW_USE : 'USE'; -KW_USER : 'USER'; -KW_USING : 'USING'; -KW_UTC : 'UTC'; -KW_UTCTIMESTAMP : 'UTC_TMESTAMP'; -KW_VALIDATE : 'VALIDATE'; -KW_VALUES : 'VALUES'; -KW_VALUE_TYPE : '$VALUE$'; -KW_VARCHAR : 'VARCHAR'; -KW_VECTORIZATION : 'VECTORIZATION'; -KW_VIEW : 'VIEW'; -KW_VIEWS : 'VIEWS'; -KW_WAIT : 'WAIT'; -KW_WEEK : 'WEEK' 'S'?; -KW_WHEN : 'WHEN'; -KW_WHERE : 'WHERE'; -KW_WHILE : 'WHILE'; -KW_WINDOW : 'WINDOW'; -KW_WITH : 'WITH'; -KW_WITHIN : 'WITHIN'; -KW_WORK : 'WORK'; -KW_WORKLOAD : 'WORKLOAD'; -KW_WRITE : 'WRITE'; -KW_YEAR : 'YEAR' 'S'?; -KW_ZONE : 'ZONE'; +KW_ABORT : 'ABORT'; +KW_ACTIVATE : 'ACTIVATE'; +KW_ACTIVE : 'ACTIVE'; +KW_ADD : 'ADD'; +KW_ADMIN : 'ADMIN'; +KW_AFTER : 'AFTER'; +KW_ALL : 'ALL'; +KW_ALLOC_FRACTION : 'ALLOC_FRACTION'; +KW_ALTER : 'ALTER'; +KW_ANALYZE : 'ANALYZE'; +KW_AND : 'AND'; +KW_ANTI : 'ANTI'; +KW_ANY : 'ANY'; +KW_APPLICATION : 'APPLICATION'; +KW_ARCHIVE : 'ARCHIVE'; +KW_ARRAY : 'ARRAY'; +KW_AS : 'AS'; +KW_ASC : 'ASC'; +KW_AST : 'AST'; +KW_AT : 'AT'; +KW_AUTHORIZATION : 'AUTHORIZATION'; +KW_AUTOCOMMIT : 'AUTOCOMMIT'; +KW_BATCH : 'KW_BATCH'; +KW_BEFORE : 'BEFORE'; +KW_BETWEEN : 'BETWEEN'; +KW_BIGINT : 'BIGINT'; +KW_BINARY : 'BINARY'; +KW_BOOLEAN : 'BOOLEAN'; +KW_BOTH : 'BOTH'; +KW_BUCKET : 'BUCKET'; +KW_BUCKETS : 'BUCKETS'; +KW_BY : 'BY'; +KW_CACHE : 'CACHE'; +KW_CASCADE : 'CASCADE'; +KW_CASE : 'CASE'; +KW_CAST : 'CAST'; +KW_CBO : 'CBO'; +KW_CHANGE : 'CHANGE'; +KW_CHAR : 'CHAR'; +KW_CHECK : 'CHECK'; +KW_CLUSTER : 'CLUSTER'; +KW_CLUSTERED : 'CLUSTERED'; +KW_CLUSTERSTATUS : 'CLUSTERSTATUS'; +KW_COLLECTION : 'COLLECTION'; +KW_COLUMN : 'COLUMN'; +KW_COLUMNS : 'COLUMNS'; +KW_COMMENT : 'COMMENT'; +KW_COMMIT : 'COMMIT'; +KW_COMPACT : 'COMPACT'; +KW_COMPACTIONS : 'COMPACTIONS'; +KW_COMPACT_ID : 'COMPACTIONID'; +KW_COMPUTE : 'COMPUTE'; +KW_CONCATENATE : 'CONCATENATE'; +KW_CONF : 'CONF'; +KW_CONSTRAINT : 'CONSTRAINT'; +KW_CONTINUE : 'CONTINUE'; +KW_COST : 'COST'; +KW_CREATE : 'CREATE'; +KW_CRON : 'CRON'; +KW_CROSS : 'CROSS'; +KW_CUBE : 'CUBE'; +KW_CURRENT : 'CURRENT'; +KW_CURRENT_DATE : 'CURRENT_DATE'; +KW_CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +KW_CURSOR : 'CURSOR'; +KW_DATA : 'DATA'; +KW_DATABASE : 'DATABASE'; +KW_DATABASES : 'DATABASES'; +KW_DATACONNECTOR : 'CONNECTOR'; +KW_DATACONNECTORS : 'CONNECTORS'; +KW_DATE : 'DATE'; +KW_DATETIME : 'DATETIME'; +KW_DAY : 'DAY' 'S'?; +KW_DAYOFWEEK : 'KW_DAYOFWEEK'; +KW_DBPROPERTIES : 'DBPROPERTIES'; +KW_DCPROPERTIES : 'DCPROPERTIES'; +KW_DDL : 'DDL'; +KW_DEBUG : 'DEBUG'; +KW_DECIMAL : 'DEC' 'IMAL'? | 'NUMERIC'; +KW_DEFAULT : 'DEFAULT'; +KW_DEFERRED : 'DEFERRED'; +KW_DEFINED : 'DEFINED'; +KW_DELETE : 'DELETE'; +KW_DELIMITED : 'DELIMITED'; +KW_DEPENDENCY : 'DEPENDENCY'; +KW_DESC : 'DESC'; +KW_DESCRIBE : 'DESCRIBE'; +KW_DETAIL : 'DETAIL'; +KW_DIRECTORIES : 'DIRECTORIES'; +KW_DIRECTORY : 'DIRECTORY'; +KW_DISABLE : 'DISABLE' 'D'?; +KW_DISTINCT : 'DISTINCT'; +KW_DISTRIBUTE : 'DISTRIBUTE'; +KW_DISTRIBUTED : 'DISTRIBUTED'; +KW_DO : 'DO'; +KW_DOUBLE : 'DOUBLE'; +KW_DOW : 'DAYOFWEEK'; +KW_DROP : 'DROP'; +KW_DUMP : 'DUMP'; +KW_ELEM_TYPE : '$ELEM$'; +KW_ELSE : 'ELSE'; +KW_ENABLE : 'ENABLE' 'D'?; +KW_END : 'END'; +KW_ENFORCED : 'ENFORCED'; +KW_ESCAPED : 'ESCAPED'; +KW_EVERY : 'EVERY'; +KW_EXCEPT : 'EXCEPT'; +KW_EXCHANGE : 'EXCHANGE'; +KW_EXCLUSIVE : 'EXCLUSIVE'; +KW_EXECUTE : 'EXECUTE'; +KW_EXECUTED : 'EXECUTED'; +KW_EXISTS : 'EXISTS'; +KW_EXPIRE_SNAPSHOTS : 'EXPIRE_SNAPSHOTS'; +KW_EXPLAIN : 'EXPLAIN'; +KW_EXPORT : 'EXPORT'; +KW_EXPRESSION : 'EXPRESSION'; +KW_EXTENDED : 'EXTENDED'; +KW_EXTERNAL : 'EXTERNAL'; +KW_EXTRACT : 'EXTRACT'; +KW_FALSE : 'FALSE'; +KW_FETCH : 'FETCH'; +KW_FIELDS : 'FIELDS'; +KW_FILE : 'FILE'; +KW_FILEFORMAT : 'FILEFORMAT'; +KW_FIRST : 'FIRST'; +KW_FLOAT : 'FLOAT'; +KW_FLOOR : 'FLOOR'; +KW_FOLLOWING : 'FOLLOWING'; +KW_FOR : 'FOR'; +KW_FORCE : 'FORCE'; +KW_FOREIGN : 'FOREIGN'; +KW_FORMAT : 'FORMAT'; +KW_FORMATTED : 'FORMATTED'; +KW_FROM : 'FROM'; +KW_FULL : 'FULL'; +KW_FUNCTION : 'FUNCTION'; +KW_FUNCTIONS : 'FUNCTIONS'; +KW_GRANT : 'GRANT'; +KW_GROUP : 'GROUP'; +KW_GROUPING : 'GROUPING'; +KW_HAVING : 'HAVING'; +KW_HOLD_DDLTIME : 'KW_HOLD_DDLTIME'; +KW_HOUR : 'HOUR' 'S'?; +KW_IDXPROPERTIES : 'IDXPROPERTIES'; +KW_IF : 'IF'; +KW_IGNORE : 'IGNORE'; +KW_IMPORT : 'IMPORT'; +KW_IN : 'IN'; +KW_INDEX : 'INDEX'; +KW_INDEXES : 'INDEXES'; +KW_INNER : 'INNER'; +KW_INPATH : 'INPATH'; +KW_INPUTDRIVER : 'INPUTDRIVER'; +KW_INPUTFORMAT : 'INPUTFORMAT'; +KW_INSERT : 'INSERT'; +KW_INT : 'INT' 'EGER'?; +KW_INTERSECT : 'INTERSECT'; +KW_INTERVAL : 'INTERVAL'; +KW_INTO : 'INTO'; +KW_IS : 'IS'; +KW_ISOLATION : 'ISOLATION'; +KW_ITEMS : 'ITEMS'; +KW_JAR : 'JAR'; +KW_JOIN : 'JOIN'; +KW_JOINCOST : 'JOINCOST'; +KW_KEY : 'KEY'; +KW_KEYS : 'KEYS'; +KW_KEY_TYPE : '$KEY$'; +KW_KILL : 'KILL'; +KW_LAST : 'LAST'; +KW_LATERAL : 'LATERAL'; +KW_LEADING : 'LEADING'; +KW_LEFT : 'LEFT'; +KW_LESS : 'LESS'; +KW_LEVEL : 'LEVEL'; +KW_LIKE : 'LIKE'; +KW_LIMIT : 'LIMIT'; +KW_LINES : 'LINES'; +KW_LOAD : 'LOAD'; +KW_LOCAL : 'LOCAL'; +KW_LOCATION : 'LOCATION'; +KW_LOCK : 'LOCK'; +KW_LOCKS : 'LOCKS'; +KW_LOGICAL : 'LOGICAL'; +KW_LONG : 'LONG'; +KW_MACRO : 'MACRO'; +KW_MANAGED : 'MANAGED'; +KW_MANAGEDLOCATION : 'MANAGEDLOCATION'; +KW_MANAGEMENT : 'MANAGEMENT'; +KW_MAP : 'MAP'; +KW_MAPJOIN : 'MAPJOIN'; +KW_MAPPING : 'MAPPING'; +KW_MATCHED : 'MATCHED'; +KW_MATERIALIZED : 'MATERIALIZED'; +KW_MERGE : 'MERGE'; +KW_METADATA : 'METADATA'; +KW_MINUS : 'MINUS'; +KW_MINUTE : 'MINUTE' 'S'?; +KW_MONTH : 'MONTH' 'S'?; +KW_MORE : 'MORE'; +KW_MOVE : 'MOVE'; +KW_MSCK : 'MSCK'; +KW_NONE : 'NONE'; +KW_NORELY : 'NORELY'; +KW_NOSCAN : 'NOSCAN'; +KW_NOT : 'NOT' | '!'; +KW_NOVALIDATE : 'NOVALIDATE'; +KW_NO_DROP : 'KW_NO_DROP'; +KW_NULL : 'NULL'; +KW_NULLS : 'NULLS'; +KW_OF : 'OF'; +KW_OFFLINE : 'KW_OFFLINE'; +KW_OFFSET : 'OFFSET'; +KW_ON : 'ON'; +KW_ONLY : 'ONLY'; +KW_OPERATOR : 'OPERATOR'; +KW_OPTION : 'OPTION'; +KW_OR : 'OR'; +KW_ORDER : 'ORDER'; +KW_OUT : 'OUT'; +KW_OUTER : 'OUTER'; +KW_OUTPUTDRIVER : 'OUTPUTDRIVER'; +KW_OUTPUTFORMAT : 'OUTPUTFORMAT'; +KW_OVER : 'OVER'; +KW_OVERWRITE : 'OVERWRITE'; +KW_OWNER : 'OWNER'; +KW_PARTITION : 'PARTITION'; +KW_PARTITIONED : 'PARTITIONED'; +KW_PARTITIONS : 'PARTITIONS'; +KW_PATH : 'PATH'; +KW_PERCENT : 'PERCENT'; +KW_PKFK_JOIN : 'PKFK_JOIN'; +KW_PLAN : 'PLAN'; +KW_PLANS : 'PLANS'; +KW_PLUS : 'PLUS'; +KW_POOL : 'POOL'; +KW_PRECEDING : 'PRECEDING'; +KW_PRECISION : 'PRECISION'; +KW_PREPARE : 'PREPARE'; +KW_PRESERVE : 'PRESERVE'; +KW_PRIMARY : 'PRIMARY'; +KW_PRINCIPALS : 'PRINCIPALS'; +KW_PROCEDURE : 'PROCEDURE'; +KW_PROTECTION : 'KW_PROTECTION'; +KW_PURGE : 'PURGE'; +KW_QUALIFY : 'QUALIFY'; +KW_QUARTER : 'QUARTER'; +KW_QUERY : 'QUERY'; +KW_QUERY_PARALLELISM : 'QUERY_PARALLELISM'; +KW_RANGE : 'RANGE'; +KW_READ : 'READ'; +KW_READONLY : 'KW_READONLY'; +KW_READS : 'READS'; +KW_REAL : 'REAL'; +KW_REBUILD : 'REBUILD'; +KW_RECORDREADER : 'RECORDREADER'; +KW_RECORDWRITER : 'RECORDWRITER'; +KW_REDUCE : 'REDUCE'; +KW_REFERENCES : 'REFERENCES'; +KW_REGEXP : 'REGEXP'; +KW_RELOAD : 'RELOAD'; +KW_RELY : 'RELY'; +KW_REMOTE : 'REMOTE'; +KW_RENAME : 'RENAME'; +KW_REOPTIMIZATION : 'REOPTIMIZATION'; +KW_REPAIR : 'REPAIR'; +KW_REPL : 'REPL'; +KW_REPLACE : 'REPLACE'; +KW_REPLICATION : 'REPLICATION'; +KW_RESOURCE : 'RESOURCE'; +KW_RESPECT : 'RESPECT'; +KW_RESTRICT : 'RESTRICT'; +KW_REVOKE : 'REVOKE'; +KW_REWRITE : 'REWRITE'; +KW_RIGHT : 'RIGHT'; +KW_RLIKE : 'RLIKE'; +KW_ROLE : 'ROLE'; +KW_ROLES : 'ROLES'; +KW_ROLLBACK : 'ROLLBACK'; +KW_ROLLUP : 'ROLLUP'; +KW_ROW : 'ROW'; +KW_ROWS : 'ROWS'; +KW_SCHEDULED : 'SCHEDULED'; +KW_SCHEDULING_POLICY : 'SCHEDULING_POLICY'; +KW_SCHEMA : 'SCHEMA'; +KW_SCHEMAS : 'SCHEMAS'; +KW_SECOND : 'SECOND' 'S'?; +KW_SELECT : 'SELECT'; +KW_SEMI : 'SEMI'; +KW_SERDE : 'SERDE'; +KW_SERDEPROPERTIES : 'SERDEPROPERTIES'; +KW_SERVER : 'SERVER'; +KW_SET : 'SET'; +KW_SETS : 'SETS'; +KW_SET_CURRENT_SNAPSHOT : 'SET_CURRENT_SNAPSHOT'; +KW_SHARED : 'SHARED'; +KW_SHOW : 'SHOW'; +KW_SHOW_DATABASE : 'SHOW_DATABASE'; +KW_SKEWED : 'SKEWED'; +KW_SMALLINT : 'SMALLINT'; +KW_SNAPSHOT : 'SNAPSHOT'; +KW_SOME : 'SOME'; +KW_SORT : 'SORT'; +KW_SORTED : 'SORTED'; +KW_SPEC : 'SPEC'; +KW_SSL : 'SSL'; +KW_START : 'START'; +KW_STATISTICS : 'STATISTICS'; +KW_STATUS : 'STATUS'; +KW_STORED : 'STORED'; +KW_STREAMTABLE : 'STREAMTABLE'; +KW_STRING : 'STRING'; +KW_STRUCT : 'STRUCT'; +KW_SUMMARY : 'SUMMARY'; +KW_SYNC : 'SYNC'; +KW_SYSTEM_TIME : 'SYSTEM_TIME'; +KW_SYSTEM_VERSION : 'SYSTEM_VERSION'; +KW_TABLE : 'TABLE'; +KW_TABLES : 'TABLES'; +KW_TABLESAMPLE : 'TABLESAMPLE'; +KW_TBLPROPERTIES : 'TBLPROPERTIES'; +KW_TEMPORARY : 'TEMPORARY'; +KW_TERMINATED : 'TERMINATED'; +KW_THEN : 'THEN'; +KW_TIME : 'TIME'; +KW_TIMESTAMP : 'TIMESTAMP'; +KW_TIMESTAMPLOCALTZ : 'TIMESTAMPLOCALTZ'; +KW_TIMESTAMPTZ : 'KW_TIMESTAMPTZ'; +KW_TINYINT : 'TINYINT'; +KW_TO : 'TO'; +KW_TOUCH : 'TOUCH'; +KW_TRAILING : 'TRAILING'; +KW_TRANSACTION : 'TRANSACTION'; +KW_TRANSACTIONAL : 'TRANSACTIONAL'; +KW_TRANSACTIONS : 'TRANSACTIONS'; +KW_TRANSFORM : 'TRANSFORM'; +KW_TRIGGER : 'TRIGGER'; +KW_TRIM : 'TRIM'; +KW_TRUE : 'TRUE'; +KW_TRUNCATE : 'TRUNCATE'; +KW_TYPE : 'TYPE'; +KW_UNARCHIVE : 'UNARCHIVE'; +KW_UNBOUNDED : 'UNBOUNDED'; +KW_UNDO : 'UNDO'; +KW_UNION : 'UNION'; +KW_UNIONTYPE : 'UNIONTYPE'; +KW_UNIQUE : 'UNIQUE'; +KW_UNIQUEJOIN : 'UNIQUEJOIN'; +KW_UNKNOWN : 'UNKNOWN'; +KW_UNLOCK : 'UNLOCK'; +KW_UNMANAGED : 'UNMANAGED'; +KW_UNSET : 'UNSET'; +KW_UNSIGNED : 'UNSIGNED'; +KW_UPDATE : 'UPDATE'; +KW_URI : 'URI'; +KW_URL : 'URL'; +KW_USE : 'USE'; +KW_USER : 'USER'; +KW_USING : 'USING'; +KW_UTC : 'UTC'; +KW_UTCTIMESTAMP : 'UTC_TMESTAMP'; +KW_VALIDATE : 'VALIDATE'; +KW_VALUES : 'VALUES'; +KW_VALUE_TYPE : '$VALUE$'; +KW_VARCHAR : 'VARCHAR'; +KW_VECTORIZATION : 'VECTORIZATION'; +KW_VIEW : 'VIEW'; +KW_VIEWS : 'VIEWS'; +KW_WAIT : 'WAIT'; +KW_WEEK : 'WEEK' 'S'?; +KW_WHEN : 'WHEN'; +KW_WHERE : 'WHERE'; +KW_WHILE : 'WHILE'; +KW_WINDOW : 'WINDOW'; +KW_WITH : 'WITH'; +KW_WITHIN : 'WITHIN'; +KW_WORK : 'WORK'; +KW_WORKLOAD : 'WORKLOAD'; +KW_WRITE : 'WRITE'; +KW_YEAR : 'YEAR' 'S'?; +KW_ZONE : 'ZONE'; // Operators // NOTE: if you add a new function/operator, add it to sysFuncNames so that describe function _FUNC_ will work. -DOT : '.'; // generated as a part of Number rule -COLON : ':' ; -COMMA : ',' ; -SEMICOLON : ';' ; +DOT : '.'; // generated as a part of Number rule +COLON : ':'; +COMMA : ','; +SEMICOLON : ';'; -LPAREN : '(' ; -RPAREN : ')' ; -LSQUARE : '[' ; -RSQUARE : ']' ; -LCURLY : '{'; -RCURLY : '}'; +LPAREN : '('; +RPAREN : ')'; +LSQUARE : '['; +RSQUARE : ']'; +LCURLY : '{'; +RCURLY : '}'; -EQUAL : '=' | '=='; -EQUAL_NS : '<=>'; -NOTEQUAL : '<>' | '!='; -LESSTHANOREQUALTO : '<='; -LESSTHAN : '<'; +EQUAL : '=' | '=='; +EQUAL_NS : '<=>'; +NOTEQUAL : '<>' | '!='; +LESSTHANOREQUALTO : '<='; +LESSTHAN : '<'; GREATERTHANOREQUALTO : '>='; -GREATERTHAN : '>'; +GREATERTHAN : '>'; DIVIDE : '/'; -PLUS : '+'; -MINUS : '-'; -STAR : '*'; -MOD : '%'; -DIV : 'DIV'; +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +MOD : '%'; +DIV : 'DIV'; -AMPERSAND : '&'; -TILDE : '~'; -BITWISEOR : '|'; +AMPERSAND : '&'; +TILDE : '~'; +BITWISEOR : '|'; CONCATENATE : '||'; -BITWISEXOR : '^'; -QUESTION : '?'; -DOLLAR : '$'; +BITWISEXOR : '^'; +QUESTION : '?'; +DOLLAR : '$'; // LITERALS -StringLiteral - : ( '\'' ( ~('\''|'\\') | ('\\' .) )* '\'' - | '"' ( ~('"'|'\\') | ('\\' .) )* '"' - )+ - ; +StringLiteral: ( '\'' ( ~('\'' | '\\') | ('\\' .))* '\'' | '"' ( ~('"' | '\\') | ('\\' .))* '"')+; -CharSetLiteral - : StringLiteral - | '0' 'X' (HexDigit | Digit)+ - ; +CharSetLiteral: StringLiteral | '0' 'X' (HexDigit | Digit)+; -IntegralLiteral - : Digit+ ('L' | 'S' | 'Y') - ; +IntegralLiteral: Digit+ ('L' | 'S' | 'Y'); -NumberLiteral - : Number ('B'? 'D') - ; +NumberLiteral: Number ('B'? 'D'); -ByteLengthLiteral - : Digit+ [BKMG] - ; +ByteLengthLiteral: Digit+ [BKMG]; -Number - : Digit+ (DOT Digit* Exponent? | Exponent)? - ; +Number: Digit+ (DOT Digit* Exponent? | Exponent)?; /* An Identifier can be: @@ -488,66 +480,47 @@ An Identifier can be: - hint name - window name */ -Identifier - : (Letter | Digit) (Letter | Digit | '_')* - | QuotedIdentifier - | '`' RegexComponent+ '`' - ; +Identifier: (Letter | Digit) (Letter | Digit | '_')* | QuotedIdentifier | '`' RegexComponent+ '`'; -fragment -QuotedIdentifier - : '`' ('``' | ~'`')* '`' - ; +fragment QuotedIdentifier: '`' ('``' | ~'`')* '`'; -fragment -Letter - : 'A'..'Z' - ; +fragment Letter: 'A' ..'Z'; -fragment -HexDigit - : 'A'..'F' - ; +fragment HexDigit: 'A' ..'F'; -fragment -Digit - : '0'..'9' - ; +fragment Digit: '0' ..'9'; -fragment -Exponent - : ('E') ( PLUS|MINUS )? (Digit)+ - ; +fragment Exponent: ('E') ( PLUS | MINUS)? (Digit)+; -fragment -RegexComponent - : 'A'..'Z' | '0'..'9' | '_' - | PLUS | STAR | QUESTION | MINUS | DOT - | LPAREN | RPAREN | LSQUARE | RSQUARE | LCURLY | RCURLY - | BITWISEXOR | BITWISEOR | DOLLAR | '!' - ; +fragment RegexComponent: + 'A' ..'Z' + | '0' ..'9' + | '_' + | PLUS + | STAR + | QUESTION + | MINUS + | DOT + | LPAREN + | RPAREN + | LSQUARE + | RSQUARE + | LCURLY + | RCURLY + | BITWISEXOR + | BITWISEOR + | DOLLAR + | '!' +; -CharSetName - : '_' (Letter | Digit | '_' | '-' | '.' | ':')+ - ; +CharSetName: '_' (Letter | Digit | '_' | '-' | '.' | ':')+; -WHITE_SPACE - : (' '|'\r'|'\t'|'\n') -> channel(HIDDEN) - ; +WHITE_SPACE: (' ' | '\r' | '\t' | '\n') -> channel(HIDDEN); -LINE_COMMENT - : '--' ~('\n' | '\r')* -> channel(HIDDEN) - ; +LINE_COMMENT: '--' ~('\n' | '\r')* -> channel(HIDDEN); -QUERY_HINT - : SHOW_HINT - | HIDDEN_HINT - ; +QUERY_HINT: SHOW_HINT | HIDDEN_HINT; -SHOW_HINT - : '/*+' (QUERY_HINT | .)*? '*/' ->channel(HIDDEN) - ; +SHOW_HINT: '/*+' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN); -HIDDEN_HINT - : '/*' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN) - ; +HIDDEN_HINT: '/*' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN); \ No newline at end of file diff --git a/sql/hive/v4/HiveParser.g4 b/sql/hive/v4/HiveParser.g4 index 84c8bfc185..077b584fca 100644 --- a/sql/hive/v4/HiveParser.g4 +++ b/sql/hive/v4/HiveParser.g4 @@ -14,11 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ + +// $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 HiveParser; options { - tokenVocab=HiveLexer; + tokenVocab = HiveLexer; } // starting rule @@ -27,10 +31,7 @@ statement ; explainStatement - : KW_EXPLAIN ( - explainOption* execStatement - | KW_REWRITE queryStatementExpression - ) + : KW_EXPLAIN (explainOption* execStatement | KW_REWRITE queryStatementExpression) ; explainOption @@ -86,35 +87,27 @@ replicationClause ; exportStatement - : KW_EXPORT - KW_TABLE tableOrPartition - KW_TO StringLiteral - replicationClause? + : KW_EXPORT KW_TABLE tableOrPartition KW_TO StringLiteral replicationClause? ; importStatement - : KW_IMPORT - (KW_EXTERNAL? KW_TABLE tableOrPartition)? - KW_FROM path=StringLiteral - tableLocation? + : KW_IMPORT (KW_EXTERNAL? KW_TABLE tableOrPartition)? KW_FROM path = StringLiteral tableLocation? ; replDumpStatement - : KW_REPL KW_DUMP - dbPolicy=replDbPolicy - (KW_REPLACE oldDbPolicy=replDbPolicy)? - (KW_WITH replConf=replConfigs)? + : KW_REPL KW_DUMP dbPolicy = replDbPolicy (KW_REPLACE oldDbPolicy = replDbPolicy)? ( + KW_WITH replConf = replConfigs + )? ; replDbPolicy - : dbName=id_ (DOT tablePolicy=replTableLevelPolicy)? + : dbName = id_ (DOT tablePolicy = replTableLevelPolicy)? ; replLoadStatement - : KW_REPL KW_LOAD - sourceDbPolicy=replDbPolicy - (KW_INTO dbName=id_)? - (KW_WITH replConf=replConfigs)? + : KW_REPL KW_LOAD sourceDbPolicy = replDbPolicy (KW_INTO dbName = id_)? ( + KW_WITH replConf = replConfigs + )? ; replConfigs @@ -126,13 +119,11 @@ replConfigsList ; replTableLevelPolicy - : replTablesIncludeList=StringLiteral (DOT replTablesExcludeList=StringLiteral)? + : replTablesIncludeList = StringLiteral (DOT replTablesExcludeList = StringLiteral)? ; replStatusStatement - : KW_REPL KW_STATUS - dbName=id_ - (KW_WITH replConf=replConfigs)? + : KW_REPL KW_STATUS dbName = id_ (KW_WITH replConf = replConfigs)? ; ddlStatement @@ -217,27 +208,20 @@ orReplace ; createDatabaseStatement - : KW_CREATE db_schema - ifNotExists? - name=id_ - databaseComment? - dbLocation? - dbManagedLocation? - (KW_WITH KW_DBPROPERTIES dbprops=dbProperties)? - | KW_CREATE KW_REMOTE db_schema - ifNotExists? - name=id_ - databaseComment? - dbConnectorName - (KW_WITH KW_DBPROPERTIES dbprops=dbProperties)? + : KW_CREATE db_schema ifNotExists? name = id_ databaseComment? dbLocation? dbManagedLocation? ( + KW_WITH KW_DBPROPERTIES dbprops = dbProperties + )? + | KW_CREATE KW_REMOTE db_schema ifNotExists? name = id_ databaseComment? dbConnectorName ( + KW_WITH KW_DBPROPERTIES dbprops = dbProperties + )? ; dbLocation - : KW_LOCATION locn=StringLiteral + : KW_LOCATION locn = StringLiteral ; dbManagedLocation - : KW_MANAGEDLOCATION locn=StringLiteral + : KW_MANAGEDLOCATION locn = StringLiteral ; dbProperties @@ -249,7 +233,7 @@ dbPropertiesList ; dbConnectorName - : KW_USING dcName=id_ + : KW_USING dcName = id_ ; switchDatabaseStatement @@ -261,7 +245,7 @@ dropDatabaseStatement ; databaseComment - : KW_COMMENT comment=StringLiteral + : KW_COMMENT comment = StringLiteral ; truncateTableStatement @@ -273,12 +257,11 @@ dropTableStatement ; inputFileFormat - : KW_INPUTFORMAT inFmt=StringLiteral KW_SERDE serdeCls=StringLiteral + : KW_INPUTFORMAT inFmt = StringLiteral KW_SERDE serdeCls = StringLiteral ; tabTypeExpr - : id_ (DOT id_)? - (id_ (DOT (KW_ELEM_TYPE | KW_KEY_TYPE | KW_VALUE_TYPE | id_))*)? + : id_ (DOT id_)? (id_ (DOT (KW_ELEM_TYPE | KW_KEY_TYPE | KW_VALUE_TYPE | id_))*)? ; partTypeExpr @@ -290,21 +273,23 @@ tabPartColTypeExpr ; descStatement - : (KW_DESCRIBE | KW_DESC) - ( - db_schema KW_EXTENDED? dbName=id_ - | KW_DATACONNECTOR KW_EXTENDED? dcName=id_ - | KW_FUNCTION KW_EXTENDED? name=descFuncNames - | (descOptions=KW_FORMATTED | descOptions=KW_EXTENDED) parttype=tabPartColTypeExpr - | parttype=tabPartColTypeExpr + : (KW_DESCRIBE | KW_DESC) ( + db_schema KW_EXTENDED? dbName = id_ + | KW_DATACONNECTOR KW_EXTENDED? dcName = id_ + | KW_FUNCTION KW_EXTENDED? name = descFuncNames + | (descOptions = KW_FORMATTED | descOptions = KW_EXTENDED) parttype = tabPartColTypeExpr + | parttype = tabPartColTypeExpr ) ; analyzeStatement - : KW_ANALYZE KW_TABLE parttype=tableOrPartition - ( KW_COMPUTE KW_STATISTICS (noscan=KW_NOSCAN | KW_FOR KW_COLUMNS statsColumnName=columnNameList?)? - | KW_CACHE KW_METADATA - ) + : KW_ANALYZE KW_TABLE parttype = tableOrPartition ( + KW_COMPUTE KW_STATISTICS ( + noscan = KW_NOSCAN + | KW_FOR KW_COLUMNS statsColumnName = columnNameList? + )? + | KW_CACHE KW_METADATA + ) ; from_in @@ -319,24 +304,33 @@ db_schema showStatement : KW_SHOW (KW_DATABASES | KW_SCHEMAS) (KW_LIKE showStmtIdentifier)? - | KW_SHOW isExtended=KW_EXTENDED? KW_TABLES (from_in db_name=id_)? filter=showTablesFilterExpr? - | KW_SHOW KW_VIEWS (from_in db_name=id_)? (KW_LIKE showStmtIdentifier | showStmtIdentifier)? - | KW_SHOW KW_MATERIALIZED KW_VIEWS (from_in db_name=id_)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? - | KW_SHOW KW_SORTED? KW_COLUMNS from_in tableName (from_in db_name=id_)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? + | KW_SHOW isExtended = KW_EXTENDED? KW_TABLES (from_in db_name = id_)? filter = showTablesFilterExpr? + | KW_SHOW KW_VIEWS (from_in db_name = id_)? (KW_LIKE showStmtIdentifier | showStmtIdentifier)? + | KW_SHOW KW_MATERIALIZED KW_VIEWS (from_in db_name = id_)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? + | KW_SHOW KW_SORTED? KW_COLUMNS from_in tableName (from_in db_name = id_)? ( + KW_LIKE showStmtIdentifier + | showStmtIdentifier + )? | KW_SHOW KW_FUNCTIONS (KW_LIKE showFunctionIdentifier)? - | KW_SHOW KW_PARTITIONS tabName=tableName partitionSpec? whereClause? orderByClause? limitClause? - | KW_SHOW KW_CREATE (db_schema db_name=id_ | KW_TABLE tabName=tableName) - | KW_SHOW KW_TABLE KW_EXTENDED (from_in db_name=id_)? KW_LIKE showStmtIdentifier partitionSpec? - | KW_SHOW KW_TBLPROPERTIES tableName (LPAREN prptyName=StringLiteral RPAREN)? - | KW_SHOW KW_LOCKS (db_schema dbName=id_ isExtended=KW_EXTENDED? | parttype=partTypeExpr? isExtended=KW_EXTENDED?) - | KW_SHOW KW_COMPACTIONS - ( compactionId - | db_schema dbName=id_ compactionPool? compactionType? compactionStatus? orderByClause? limitClause? - | parttype=partTypeExpr? compactionPool? compactionType? compactionStatus? orderByClause? limitClause? - ) + | KW_SHOW KW_PARTITIONS tabName = tableName partitionSpec? whereClause? orderByClause? limitClause? + | KW_SHOW KW_CREATE (db_schema db_name = id_ | KW_TABLE tabName = tableName) + | KW_SHOW KW_TABLE KW_EXTENDED (from_in db_name = id_)? KW_LIKE showStmtIdentifier partitionSpec? + | KW_SHOW KW_TBLPROPERTIES tableName (LPAREN prptyName = StringLiteral RPAREN)? + | KW_SHOW KW_LOCKS ( + db_schema dbName = id_ isExtended = KW_EXTENDED? + | parttype = partTypeExpr? isExtended = KW_EXTENDED? + ) + | KW_SHOW KW_COMPACTIONS ( + compactionId + | db_schema dbName = id_ compactionPool? compactionType? compactionStatus? orderByClause? limitClause? + | parttype = partTypeExpr? compactionPool? compactionType? compactionStatus? orderByClause? limitClause? + ) | KW_SHOW KW_TRANSACTIONS | KW_SHOW KW_CONF StringLiteral - | KW_SHOW KW_RESOURCE (KW_PLAN rp_name=id_ | KW_PLANS) + | KW_SHOW KW_RESOURCE (KW_PLAN rp_name = id_ | KW_PLANS) | KW_SHOW KW_DATACONNECTORS ; @@ -351,7 +345,7 @@ lockStatement ; lockDatabase - : KW_LOCK db_schema dbName=id_ lockMode + : KW_LOCK db_schema dbName = id_ lockMode ; lockMode @@ -364,22 +358,19 @@ unlockStatement ; unlockDatabase - : KW_UNLOCK db_schema dbName=id_ + : KW_UNLOCK db_schema dbName = id_ ; createRoleStatement - : KW_CREATE KW_ROLE roleName=id_ + : KW_CREATE KW_ROLE roleName = id_ ; dropRoleStatement - : KW_DROP KW_ROLE roleName=id_ + : KW_DROP KW_ROLE roleName = id_ ; grantPrivileges - : KW_GRANT privList=privilegeList - privilegeObject? - KW_TO principalSpecification - withGrantOption? + : KW_GRANT privList = privilegeList privilegeObject? KW_TO principalSpecification withGrantOption? ; revokePrivileges @@ -407,11 +398,7 @@ showCurrentRole ; setRole - : KW_SET KW_ROLE - ( all=KW_ALL - | none=KW_NONE - | id_ - ) + : KW_SET KW_ROLE (all = KW_ALL | none = KW_NONE | id_) ; showGrants @@ -419,7 +406,7 @@ showGrants ; showRolePrincipals - : KW_SHOW KW_PRINCIPALS roleName=id_ + : KW_SHOW KW_PRINCIPALS roleName = id_ ; privilegeIncludeColObject @@ -437,14 +424,14 @@ database or table type. Type is optional, default type is table privObject : db_schema id_ | KW_TABLE? tableName partitionSpec? - | KW_URI path=StringLiteral + | KW_URI path = StringLiteral | KW_SERVER id_ ; privObjectCols : db_schema id_ - | KW_TABLE? tableName (LPAREN cols=columnNameList RPAREN)? partitionSpec? - | KW_URI path=StringLiteral + | KW_TABLE? tableName (LPAREN cols = columnNameList RPAREN)? partitionSpec? + | KW_URI path = StringLiteral | KW_SERVER id_ ; @@ -453,7 +440,7 @@ privilegeList ; privlegeDef - : privilegeType (LPAREN cols=columnNameList RPAREN)? + : privilegeType (LPAREN cols = columnNameList RPAREN)? ; privilegeType @@ -496,18 +483,19 @@ withAdminOption ; metastoreCheck - : KW_MSCK repair=KW_REPAIR? - (KW_TABLE tableName - (opt=(KW_ADD | KW_DROP | KW_SYNC) parts=KW_PARTITIONS partitionSelectorSpec?)? - ) + : KW_MSCK repair = KW_REPAIR? ( + KW_TABLE tableName ( + opt = (KW_ADD | KW_DROP | KW_SYNC) parts = KW_PARTITIONS partitionSelectorSpec? + )? + ) ; resourceList - : resource (COMMA resource)* + : resource (COMMA resource)* ; resource - : resType=resourceType resPath=StringLiteral + : resType = resourceType resPath = StringLiteral ; resourceType @@ -517,12 +505,13 @@ resourceType ; createFunctionStatement - : KW_CREATE temp=KW_TEMPORARY? KW_FUNCTION functionIdentifier KW_AS StringLiteral - (KW_USING rList=resourceList)? + : KW_CREATE temp = KW_TEMPORARY? KW_FUNCTION functionIdentifier KW_AS StringLiteral ( + KW_USING rList = resourceList + )? ; dropFunctionStatement - : KW_DROP temp=KW_TEMPORARY? KW_FUNCTION ifExists? functionIdentifier + : KW_DROP temp = KW_TEMPORARY? KW_FUNCTION ifExists? functionIdentifier ; reloadFunctionsStatement @@ -530,8 +519,7 @@ reloadFunctionsStatement ; createMacroStatement - : KW_CREATE KW_TEMPORARY KW_MACRO Identifier - LPAREN columnNameTypeList? RPAREN expression + : KW_CREATE KW_TEMPORARY KW_MACRO Identifier LPAREN columnNameTypeList? RPAREN expression ; dropMacroStatement @@ -539,15 +527,13 @@ dropMacroStatement ; createViewStatement - : KW_CREATE orReplace? KW_VIEW ifNotExists? name=tableName - (LPAREN columnNameCommentList RPAREN)? tableComment? viewPartition? - tablePropertiesPrefixed? - KW_AS - selectStatementWithCTE + : KW_CREATE orReplace? KW_VIEW ifNotExists? name = tableName ( + LPAREN columnNameCommentList RPAREN + )? tableComment? viewPartition? tablePropertiesPrefixed? KW_AS selectStatementWithCTE ; viewPartition - : KW_PARTITIONED KW_ON (LPAREN columnNameList | KW_SPEC LPAREN spec=partitionTransformSpec) RPAREN + : KW_PARTITIONED KW_ON (LPAREN columnNameList | KW_SPEC LPAREN spec = partitionTransformSpec) RPAREN ; viewOrganization @@ -564,11 +550,11 @@ viewComplexSpec ; viewDistSpec - : KW_DISTRIBUTED KW_ON LPAREN colList=columnNameList RPAREN + : KW_DISTRIBUTED KW_ON LPAREN colList = columnNameList RPAREN ; viewSortSpec - : KW_SORTED KW_ON LPAREN colList=columnNameList RPAREN + : KW_SORTED KW_ON LPAREN colList = columnNameList RPAREN ; dropViewStatement @@ -576,10 +562,8 @@ dropViewStatement ; createMaterializedViewStatement - : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? name=tableName - rewriteDisabled? tableComment? viewPartition? viewOrganization? - tableRowFormat? tableFileFormat? tableLocation? - tablePropertiesPrefixed? KW_AS selectStatementWithCTE + : KW_CREATE KW_MATERIALIZED KW_VIEW ifNotExists? name = tableName rewriteDisabled? tableComment? viewPartition? viewOrganization? tableRowFormat? + tableFileFormat? tableLocation? tablePropertiesPrefixed? KW_AS selectStatementWithCTE ; dropMaterializedViewStatement @@ -587,19 +571,15 @@ dropMaterializedViewStatement ; createScheduledQueryStatement - : KW_CREATE KW_SCHEDULED KW_QUERY name=id_ - scheduleSpec - executedAsSpec? - enableSpecification? - definedAsSpec + : KW_CREATE KW_SCHEDULED KW_QUERY name = id_ scheduleSpec executedAsSpec? enableSpecification? definedAsSpec ; dropScheduledQueryStatement - : KW_DROP KW_SCHEDULED KW_QUERY name=id_ + : KW_DROP KW_SCHEDULED KW_QUERY name = id_ ; alterScheduledQueryStatement - : KW_ALTER KW_SCHEDULED KW_QUERY name=id_ mod=alterScheduledQueryChange + : KW_ALTER KW_SCHEDULED KW_QUERY name = id_ mod = alterScheduledQueryChange ; alterScheduledQueryChange @@ -611,13 +591,14 @@ alterScheduledQueryChange ; scheduleSpec - : KW_CRON cronString=StringLiteral - | KW_EVERY value=Number? qualifier=intervalQualifiers - ((KW_AT | KW_OFFSET KW_BY) offsetTs=StringLiteral)? + : KW_CRON cronString = StringLiteral + | KW_EVERY value = Number? qualifier = intervalQualifiers ( + (KW_AT | KW_OFFSET KW_BY) offsetTs = StringLiteral + )? ; executedAsSpec - : KW_EXECUTED KW_AS executedAs=StringLiteral + : KW_EXECUTED KW_AS executedAs = StringLiteral ; definedAsSpec @@ -635,14 +616,14 @@ showStmtIdentifier ; tableComment - : KW_COMMENT comment=StringLiteral + : KW_COMMENT comment = StringLiteral ; createTablePartitionSpec - : KW_PARTITIONED KW_BY - ( LPAREN (opt1=createTablePartitionColumnTypeSpec | opt2=createTablePartitionColumnSpec) - | KW_SPEC LPAREN spec=partitionTransformSpec - ) RPAREN + : KW_PARTITIONED KW_BY ( + LPAREN (opt1 = createTablePartitionColumnTypeSpec | opt2 = createTablePartitionColumnSpec) + | KW_SPEC LPAREN spec = partitionTransformSpec + ) RPAREN ; createTablePartitionColumnTypeSpec @@ -664,20 +645,21 @@ columnNameTransformConstraint partitionTransformType : columnName | (KW_YEAR | KW_MONTH | KW_DAY | KW_HOUR) LPAREN columnName RPAREN - | (KW_TRUNCATE | KW_BUCKET) LPAREN value=Number COMMA columnName RPAREN + | (KW_TRUNCATE | KW_BUCKET) LPAREN value = Number COMMA columnName RPAREN ; tableBuckets - : KW_CLUSTERED KW_BY LPAREN bucketCols=columnNameList RPAREN - (KW_SORTED KW_BY LPAREN sortCols=columnNameOrderList RPAREN)? KW_INTO num=Number KW_BUCKETS + : KW_CLUSTERED KW_BY LPAREN bucketCols = columnNameList RPAREN ( + KW_SORTED KW_BY LPAREN sortCols = columnNameOrderList RPAREN + )? KW_INTO num = Number KW_BUCKETS ; tableImplBuckets - : KW_CLUSTERED KW_INTO num=Number KW_BUCKETS + : KW_CLUSTERED KW_INTO num = Number KW_BUCKETS ; tableSkewed - : KW_SKEWED KW_BY LPAREN skewedCols=columnNameList RPAREN KW_ON LPAREN skewedValues=skewedValueElement RPAREN storedAsDirs? + : KW_SKEWED KW_BY LPAREN skewedCols = columnNameList RPAREN KW_ON LPAREN skewedValues = skewedValueElement RPAREN storedAsDirs? ; rowFormat @@ -694,12 +676,14 @@ recordWriter ; rowFormatSerde - : KW_ROW KW_FORMAT KW_SERDE name=StringLiteral (KW_WITH KW_SERDEPROPERTIES serdeprops=tableProperties)? + : KW_ROW KW_FORMAT KW_SERDE name = StringLiteral ( + KW_WITH KW_SERDEPROPERTIES serdeprops = tableProperties + )? ; rowFormatDelimited - : KW_ROW KW_FORMAT KW_DELIMITED tableRowFormatFieldIdentifier? tableRowFormatCollItemsIdentifier? - tableRowFormatMapKeysIdentifier? tableRowFormatLinesIdentifier? tableRowNullFormat? + : KW_ROW KW_FORMAT KW_DELIMITED tableRowFormatFieldIdentifier? tableRowFormatCollItemsIdentifier? tableRowFormatMapKeysIdentifier? + tableRowFormatLinesIdentifier? tableRowNullFormat? ; tableRowFormat @@ -721,49 +705,50 @@ tablePropertiesList ; keyValueProperty - : key=StringLiteral EQUAL value=StringLiteral + : key = StringLiteral EQUAL value = StringLiteral ; keyProperty - : key=StringLiteral + : key = StringLiteral ; tableRowFormatFieldIdentifier - : KW_FIELDS KW_TERMINATED KW_BY fldIdnt=StringLiteral (KW_ESCAPED KW_BY fldEscape=StringLiteral)? + : KW_FIELDS KW_TERMINATED KW_BY fldIdnt = StringLiteral ( + KW_ESCAPED KW_BY fldEscape = StringLiteral + )? ; tableRowFormatCollItemsIdentifier - : KW_COLLECTION KW_ITEMS KW_TERMINATED KW_BY collIdnt=StringLiteral + : KW_COLLECTION KW_ITEMS KW_TERMINATED KW_BY collIdnt = StringLiteral ; tableRowFormatMapKeysIdentifier - : KW_MAP KW_KEYS KW_TERMINATED KW_BY mapKeysIdnt=StringLiteral + : KW_MAP KW_KEYS KW_TERMINATED KW_BY mapKeysIdnt = StringLiteral ; tableRowFormatLinesIdentifier - : KW_LINES KW_TERMINATED KW_BY linesIdnt=StringLiteral + : KW_LINES KW_TERMINATED KW_BY linesIdnt = StringLiteral ; tableRowNullFormat - : KW_NULL KW_DEFINED KW_AS nullIdnt=StringLiteral + : KW_NULL KW_DEFINED KW_AS nullIdnt = StringLiteral ; tableFileFormat - : KW_STORED KW_AS KW_INPUTFORMAT - inFmt=StringLiteral KW_OUTPUTFORMAT - outFmt=StringLiteral - (KW_INPUTDRIVER inDriver=StringLiteral KW_OUTPUTDRIVER outDriver=StringLiteral)? - | KW_STORED KW_BY storageHandler=StringLiteral - (KW_WITH KW_SERDEPROPERTIES serdeprops=tableProperties)? - (KW_STORED KW_AS fileformat=id_)? - | KW_STORED KW_BY genericSpec=id_ - (KW_WITH KW_SERDEPROPERTIES serdeprops=tableProperties)? - (KW_STORED KW_AS fileformat=id_)? - | KW_STORED KW_AS genericSpec=id_ + : KW_STORED KW_AS KW_INPUTFORMAT inFmt = StringLiteral KW_OUTPUTFORMAT outFmt = StringLiteral ( + KW_INPUTDRIVER inDriver = StringLiteral KW_OUTPUTDRIVER outDriver = StringLiteral + )? + | KW_STORED KW_BY storageHandler = StringLiteral ( + KW_WITH KW_SERDEPROPERTIES serdeprops = tableProperties + )? (KW_STORED KW_AS fileformat = id_)? + | KW_STORED KW_BY genericSpec = id_ (KW_WITH KW_SERDEPROPERTIES serdeprops = tableProperties)? ( + KW_STORED KW_AS fileformat = id_ + )? + | KW_STORED KW_AS genericSpec = id_ ; tableLocation - : KW_LOCATION locn=StringLiteral + : KW_LOCATION locn = StringLiteral ; columnNameTypeList @@ -819,16 +804,16 @@ enforcedSpecification ; relySpecification - : KW_RELY - | KW_NORELY + : KW_RELY + | KW_NORELY ; createConstraint - : (KW_CONSTRAINT constraintName=id_)? tableLevelConstraint constraintOptsCreate? + : (KW_CONSTRAINT constraintName = id_)? tableLevelConstraint constraintOptsCreate? ; alterConstraintWithName - : KW_CONSTRAINT constraintName=id_ tableLevelConstraint constraintOptsAlter? + : KW_CONSTRAINT constraintName = id_ tableLevelConstraint constraintOptsAlter? ; tableLevelConstraint @@ -837,7 +822,7 @@ tableLevelConstraint ; pkUkConstraint - : tableConstraintType pkCols=columnParenthesesList + : tableConstraintType pkCols = columnParenthesesList ; checkConstraint @@ -845,13 +830,13 @@ checkConstraint ; createForeignKey - : (KW_CONSTRAINT constraintName=id_)? KW_FOREIGN KW_KEY fkCols=columnParenthesesList - KW_REFERENCES tabName=tableName parCols=columnParenthesesList constraintOptsCreate? + : (KW_CONSTRAINT constraintName = id_)? KW_FOREIGN KW_KEY fkCols = columnParenthesesList KW_REFERENCES tabName = tableName parCols = + columnParenthesesList constraintOptsCreate? ; alterForeignKeyWithName - : KW_CONSTRAINT constraintName=id_ KW_FOREIGN KW_KEY fkCols=columnParenthesesList - KW_REFERENCES tabName=tableName parCols=columnParenthesesList constraintOptsAlter? + : KW_CONSTRAINT constraintName = id_ KW_FOREIGN KW_KEY fkCols = columnParenthesesList KW_REFERENCES tabName = tableName parCols = + columnParenthesesList constraintOptsAlter? ; skewedValueElement @@ -864,7 +849,7 @@ skewedColumnValuePairList ; skewedColumnValuePair - : LPAREN colValues=skewedColumnValues RPAREN + : LPAREN colValues = skewedColumnValues RPAREN ; skewedColumnValues @@ -890,7 +875,7 @@ nullOrdering ; columnNameOrder - : id_ orderSpec=orderSpecification? nullSpec=nullOrdering? + : id_ orderSpec = orderSpecification? nullSpec = nullOrdering? ; columnNameCommentList @@ -898,7 +883,7 @@ columnNameCommentList ; columnNameComment - : colName=id_ (KW_COMMENT comment=StringLiteral)? + : colName = id_ (KW_COMMENT comment = StringLiteral)? ; orderSpecificationRewrite @@ -907,11 +892,11 @@ orderSpecificationRewrite ; columnRefOrder - : expression orderSpec=orderSpecificationRewrite? nullSpec=nullOrdering? + : expression orderSpec = orderSpecificationRewrite? nullSpec = nullOrdering? ; columnNameType - : colName=id_ colType (KW_COMMENT comment=StringLiteral)? + : colName = id_ colType (KW_COMMENT comment = StringLiteral)? ; columnNameTypeOrConstraint @@ -925,7 +910,7 @@ tableConstraint ; columnNameTypeConstraint - : colName=id_ colType columnConstraint? (KW_COMMENT comment=StringLiteral)? + : colName = id_ colType columnConstraint? (KW_COMMENT comment = StringLiteral)? ; columnConstraint @@ -934,11 +919,11 @@ columnConstraint ; foreignKeyConstraint - : (KW_CONSTRAINT constraintName=id_)? KW_REFERENCES tabName=tableName LPAREN colName=columnName RPAREN constraintOptsCreate? + : (KW_CONSTRAINT constraintName = id_)? KW_REFERENCES tabName = tableName LPAREN colName = columnName RPAREN constraintOptsCreate? ; colConstraint - : (KW_CONSTRAINT constraintName=id_)? columnConstraintType constraintOptsCreate? + : (KW_CONSTRAINT constraintName = id_)? columnConstraintType constraintOptsCreate? ; alterColumnConstraint @@ -947,11 +932,11 @@ alterColumnConstraint ; alterForeignKeyConstraint - : (KW_CONSTRAINT constraintName=id_)? KW_REFERENCES tabName=tableName LPAREN colName=columnName RPAREN constraintOptsAlter? + : (KW_CONSTRAINT constraintName = id_)? KW_REFERENCES tabName = tableName LPAREN colName = columnName RPAREN constraintOptsAlter? ; alterColConstraint - : (KW_CONSTRAINT constraintName=id_)? columnConstraintType constraintOptsAlter? + : (KW_CONSTRAINT constraintName = id_)? columnConstraintType constraintOptsAlter? ; columnConstraintType @@ -981,7 +966,7 @@ constraintOptsAlter ; columnNameColonType - : colName=id_ COLON colType (KW_COMMENT comment=StringLiteral)? + : colName = id_ COLON colType (KW_COMMENT comment = StringLiteral)? ; colType @@ -997,7 +982,8 @@ type | listType | structType | mapType - | unionType; + | unionType + ; primitiveType : KW_TINYINT @@ -1020,8 +1006,8 @@ primitiveType //| KW_INTERVAL KW_DAY KW_TO KW_SECOND | KW_STRING | KW_BINARY - | KW_DECIMAL (LPAREN prec=Number (COMMA scale=Number)? RPAREN)? - | (KW_VARCHAR | KW_CHAR) LPAREN length=Number RPAREN + | KW_DECIMAL (LPAREN prec = Number (COMMA scale = Number)? RPAREN)? + | (KW_VARCHAR | KW_CHAR) LPAREN length = Number RPAREN ; listType @@ -1033,7 +1019,7 @@ structType ; mapType - : KW_MAP LESSTHAN left=primitiveType COMMA right=type GREATERTHAN + : KW_MAP LESSTHAN left = primitiveType COMMA right = type GREATERTHAN ; unionType @@ -1045,11 +1031,11 @@ setOperator ; queryStatementExpression - /* Would be nice to do this as a gated semantic perdicate +/* Would be nice to do this as a gated semantic perdicate But the predicate gets pushed as a lookahead decision. Calling rule doesnot know about topLevel */ - : w=withClause? queryStatementExpressionBody + : w = withClause? queryStatementExpressionBody ; queryStatementExpressionBody @@ -1062,15 +1048,15 @@ withClause ; cteStatement - : id_ (LPAREN colAliases=columnNameList RPAREN)? KW_AS LPAREN queryStatementExpression RPAREN + : id_ (LPAREN colAliases = columnNameList RPAREN)? KW_AS LPAREN queryStatementExpression RPAREN ; fromStatement - : singleFromStatement (u=setOperator r=singleFromStatement)* + : singleFromStatement (u = setOperator r = singleFromStatement)* ; singleFromStatement - : fromClause b+=body+ + : fromClause b += body+ ; /* @@ -1080,81 +1066,50 @@ The valuesClause rule below ensures that the parse tree for very similar to the tree for "insert into table FOO select a,b from BAR". */ regularBody - : i=insertClause s=selectStatement + : i = insertClause s = selectStatement | selectStatement ; atomSelectStatement - : s=selectClause - f=fromClause? - w=whereClause? - g=groupByClause? - h=havingClause? - win=window_clause? - q=qualifyClause? + : s = selectClause f = fromClause? w = whereClause? g = groupByClause? h = havingClause? win = window_clause? q = qualifyClause? | LPAREN selectStatement RPAREN | valuesSource ; selectStatement - : a=atomSelectStatement - set=setOpSelectStatement? - o=orderByClause? - c=clusterByClause? - d=distributeByClause? - sort=sortByClause? - l=limitClause? + : a = atomSelectStatement set = setOpSelectStatement? o = orderByClause? c = clusterByClause? d = distributeByClause? sort = sortByClause? l = + limitClause? ; setOpSelectStatement - : (u=setOperator b=atomSelectStatement)+ + : (u = setOperator b = atomSelectStatement)+ ; selectStatementWithCTE - : w=withClause? selectStatement + : w = withClause? selectStatement ; body - : insertClause - selectClause - lateralView? - whereClause? - groupByClause? - havingClause? - window_clause? - qualifyClause? - orderByClause? - clusterByClause? - distributeByClause? - sortByClause? - limitClause? - | selectClause - lateralView? - whereClause? - groupByClause? - havingClause? - window_clause? - qualifyClause? - orderByClause? - clusterByClause? - distributeByClause? - sortByClause? - limitClause? + : insertClause selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? qualifyClause? orderByClause? clusterByClause? + distributeByClause? sortByClause? limitClause? + | selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? qualifyClause? orderByClause? clusterByClause? + distributeByClause? sortByClause? limitClause? ; insertClause - : KW_INSERT ( KW_OVERWRITE destination ifNotExists? - | KW_INTO KW_TABLE? tableOrPartition (LPAREN targetCols=columnNameList RPAREN)? - ) + : KW_INSERT ( + KW_OVERWRITE destination ifNotExists? + | KW_INTO KW_TABLE? tableOrPartition (LPAREN targetCols = columnNameList RPAREN)? + ) ; destination - : local=KW_LOCAL? KW_DIRECTORY StringLiteral tableRowFormat? tableFileFormat? + : local = KW_LOCAL? KW_DIRECTORY StringLiteral tableRowFormat? tableFileFormat? | KW_TABLE tableOrPartition ; limitClause - : KW_LIMIT ((offset=Number COMMA)? num=Number | num=Number KW_OFFSET offset=Number) + : KW_LIMIT ((offset = Number COMMA)? num = Number | num = Number KW_OFFSET offset = Number) ; /** @@ -1199,7 +1154,7 @@ sqlTransactionStatement ; startTransactionStatement - : KW_START KW_TRANSACTION (transactionMode (COMMA transactionMode)* )? + : KW_START KW_TRANSACTION (transactionMode (COMMA transactionMode)*)? ; transactionMode @@ -1231,6 +1186,7 @@ rollbackStatement setAutoCommitStatement : KW_SET KW_AUTOCOMMIT booleanValueTok ; + /* END user defined transaction boundaries */ @@ -1249,6 +1205,7 @@ BEGIN SQL Merge statement mergeStatement : KW_MERGE QUERY_HINT? KW_INTO tableName (KW_AS? id_)? KW_USING joinSourcePart KW_ON expression whenClauses ; + /* Allow 0,1 or 2 WHEN MATCHED clauses and 0 or 1 WHEN NOT MATCHED Each WHEN clause may have AND . @@ -1260,7 +1217,7 @@ whenClauses ; whenNotMatchedClause - : KW_WHEN KW_NOT KW_MATCHED (KW_AND expression)? KW_THEN KW_INSERT targetCols=columnParenthesesList? KW_VALUES valueRowConstructor + : KW_WHEN KW_NOT KW_MATCHED (KW_AND expression)? KW_THEN KW_INSERT targetCols = columnParenthesesList? KW_VALUES valueRowConstructor ; whenMatchedAndClause @@ -1275,6 +1232,7 @@ updateOrDelete : KW_UPDATE setColumnsClause | KW_DELETE ; + /* END SQL Merge statement */ @@ -1287,19 +1245,19 @@ killQueryStatement BEGIN SHOW COMPACTIONS statement */ compactionId - : KW_COMPACT_ID EQUAL compactId=Number + : KW_COMPACT_ID EQUAL compactId = Number ; compactionPool - : KW_POOL poolName=StringLiteral + : KW_POOL poolName = StringLiteral ; compactionType - : KW_TYPE compactType=StringLiteral + : KW_TYPE compactType = StringLiteral ; compactionStatus - : KW_STATUS status=StringLiteral + : KW_STATUS status = StringLiteral ; /* @@ -1307,12 +1265,13 @@ END SHOW COMPACTIONS statement */ alterStatement - : KW_ALTER ( KW_TABLE tableName alterTableStatementSuffix - | KW_VIEW tableName KW_AS? alterViewStatementSuffix - | KW_MATERIALIZED KW_VIEW tableNameTree=tableName alterMaterializedViewStatementSuffix - | db_schema alterDatabaseStatementSuffix - | KW_DATACONNECTOR alterDataConnectorStatementSuffix - ) + : KW_ALTER ( + KW_TABLE tableName alterTableStatementSuffix + | KW_VIEW tableName KW_AS? alterViewStatementSuffix + | KW_MATERIALIZED KW_VIEW tableNameTree = tableName alterMaterializedViewStatementSuffix + | db_schema alterDatabaseStatementSuffix + | KW_DATACONNECTOR alterDataConnectorStatementSuffix + ) ; alterTableStatementSuffix @@ -1370,8 +1329,8 @@ alterMaterializedViewStatementSuffix ; alterMaterializedViewSuffixRewrite - : mvRewriteFlag=rewriteEnabled - | mvRewriteFlag2=rewriteDisabled + : mvRewriteFlag = rewriteEnabled + | mvRewriteFlag2 = rewriteDisabled ; alterMaterializedViewSuffixRebuild @@ -1385,19 +1344,19 @@ alterDatabaseStatementSuffix ; alterDatabaseSuffixProperties - : name=id_ KW_SET KW_DBPROPERTIES dbProperties + : name = id_ KW_SET KW_DBPROPERTIES dbProperties ; alterDatabaseSuffixSetOwner - : dbName=id_ KW_SET KW_OWNER principalName + : dbName = id_ KW_SET KW_OWNER principalName ; alterDatabaseSuffixSetLocation - : dbName=id_ KW_SET (KW_LOCATION | KW_MANAGEDLOCATION) newLocation=StringLiteral + : dbName = id_ KW_SET (KW_LOCATION | KW_MANAGEDLOCATION) newLocation = StringLiteral ; alterDatabaseSuffixSetManagedLocation - : dbName=id_ KW_SET KW_MANAGEDLOCATION newLocation=StringLiteral + : dbName = id_ KW_SET KW_MANAGEDLOCATION newLocation = StringLiteral ; alterStatementSuffixRename @@ -1405,11 +1364,11 @@ alterStatementSuffixRename ; alterStatementSuffixAddCol - : (add=KW_ADD | replace=KW_REPLACE) KW_COLUMNS LPAREN columnNameTypeList RPAREN restrictOrCascade? + : (add = KW_ADD | replace = KW_REPLACE) KW_COLUMNS LPAREN columnNameTypeList RPAREN restrictOrCascade? ; alterStatementSuffixAddConstraint - : KW_ADD (fk=alterForeignKeyWithName | alterConstraintWithName) + : KW_ADD (fk = alterForeignKeyWithName | alterConstraintWithName) ; alterStatementSuffixUpdateColumns @@ -1417,16 +1376,19 @@ alterStatementSuffixUpdateColumns ; alterStatementSuffixDropConstraint - : KW_DROP KW_CONSTRAINT cName=id_ + : KW_DROP KW_CONSTRAINT cName = id_ ; alterStatementSuffixRenameCol - : KW_CHANGE KW_COLUMN? oldName=id_ newName=id_ colType alterColumnConstraint? - (KW_COMMENT comment=StringLiteral)? alterStatementChangeColPosition? restrictOrCascade? + : KW_CHANGE KW_COLUMN? oldName = id_ newName = id_ colType alterColumnConstraint? ( + KW_COMMENT comment = StringLiteral + )? alterStatementChangeColPosition? restrictOrCascade? ; alterStatementSuffixUpdateStatsCol - : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=id_ KW_SET tableProperties (KW_COMMENT comment=StringLiteral)? + : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName = id_ KW_SET tableProperties ( + KW_COMMENT comment = StringLiteral + )? ; alterStatementSuffixUpdateStats @@ -1434,8 +1396,8 @@ alterStatementSuffixUpdateStats ; alterStatementChangeColPosition - : first=KW_FIRST - | KW_AFTER afterCol=id_ + : first = KW_FIRST + | KW_AFTER afterCol = id_ ; alterStatementSuffixAddPartitions @@ -1459,11 +1421,13 @@ alterStatementSuffixUnArchive ; partitionLocation - : KW_LOCATION locn=StringLiteral + : KW_LOCATION locn = StringLiteral ; alterStatementSuffixDropPartitions - : KW_DROP ifExists? KW_PARTITION partitionSelectorSpec (COMMA KW_PARTITION partitionSelectorSpec)* KW_PURGE? replicationClause? + : KW_DROP ifExists? KW_PARTITION partitionSelectorSpec ( + COMMA KW_PARTITION partitionSelectorSpec + )* KW_PURGE? replicationClause? ; alterStatementSuffixProperties @@ -1477,9 +1441,10 @@ alterViewSuffixProperties ; alterStatementSuffixSerdeProperties - : KW_SET ( KW_SERDE serdeName=StringLiteral (KW_WITH KW_SERDEPROPERTIES tableProperties)? - | KW_SERDEPROPERTIES tableProperties - ) + : KW_SET ( + KW_SERDE serdeName = StringLiteral (KW_WITH KW_SERDEPROPERTIES tableProperties)? + | KW_SERDEPROPERTIES tableProperties + ) | KW_UNSET KW_SERDEPROPERTIES tableProperties ; @@ -1509,11 +1474,11 @@ skewedLocationsList ; skewedLocationMap - : key=skewedValueLocationElement EQUAL value=StringLiteral + : key = skewedValueLocationElement EQUAL value = StringLiteral ; alterStatementSuffixLocation - : KW_SET KW_LOCATION newLoc=StringLiteral + : KW_SET KW_LOCATION newLoc = StringLiteral ; alterStatementSuffixSkewedby @@ -1522,7 +1487,7 @@ alterStatementSuffixSkewedby ; alterStatementSuffixExchangePartition - : KW_EXCHANGE partitionSpec KW_WITH KW_TABLE exchangename=tableName + : KW_EXCHANGE partitionSpec KW_WITH KW_TABLE exchangename = tableName ; alterStatementSuffixRenamePart @@ -1530,7 +1495,9 @@ alterStatementSuffixRenamePart ; alterStatementSuffixStatsPart - : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=id_ KW_SET tableProperties (KW_COMMENT comment=StringLiteral)? + : KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName = id_ KW_SET tableProperties ( + KW_COMMENT comment = StringLiteral + )? ; alterStatementSuffixMergeFiles @@ -1538,7 +1505,7 @@ alterStatementSuffixMergeFiles ; alterStatementSuffixBucketNum - : KW_INTO num=Number KW_BUCKETS + : KW_INTO num = Number KW_BUCKETS ; blocking @@ -1546,11 +1513,13 @@ blocking ; compactPool - : KW_POOL poolName=StringLiteral + : KW_POOL poolName = StringLiteral ; alterStatementSuffixCompact - : KW_COMPACT compactType=StringLiteral tableImplBuckets? blocking? compactPool? (KW_WITH KW_OVERWRITE KW_TBLPROPERTIES tableProperties)? + : KW_COMPACT compactType = StringLiteral tableImplBuckets? blocking? compactPool? ( + KW_WITH KW_OVERWRITE KW_TBLPROPERTIES tableProperties + )? ; alterStatementSuffixSetOwner @@ -1558,20 +1527,22 @@ alterStatementSuffixSetOwner ; alterStatementSuffixSetPartSpec - : KW_SET KW_PARTITION KW_SPEC LPAREN spec=partitionTransformSpec RPAREN + : KW_SET KW_PARTITION KW_SPEC LPAREN spec = partitionTransformSpec RPAREN ; alterStatementSuffixExecute - : KW_EXECUTE ( KW_ROLLBACK LPAREN rollbackParam=(StringLiteral | Number) - | KW_EXPIRE_SNAPSHOTS LPAREN expireParam=StringLiteral - | KW_SET_CURRENT_SNAPSHOT LPAREN snapshotParam=Number - ) RPAREN + : KW_EXECUTE ( + KW_ROLLBACK LPAREN rollbackParam = (StringLiteral | Number) + | KW_EXPIRE_SNAPSHOTS LPAREN expireParam = StringLiteral + | KW_SET_CURRENT_SNAPSHOT LPAREN snapshotParam = Number + ) RPAREN ; fileFormat - : KW_INPUTFORMAT inFmt=StringLiteral KW_OUTPUTFORMAT outFmt=StringLiteral KW_SERDE serdeCls=StringLiteral - (KW_INPUTDRIVER inDriver=StringLiteral KW_OUTPUTDRIVER outDriver=StringLiteral)? - | genericSpec=id_ + : KW_INPUTFORMAT inFmt = StringLiteral KW_OUTPUTFORMAT outFmt = StringLiteral KW_SERDE serdeCls = StringLiteral ( + KW_INPUTDRIVER inDriver = StringLiteral KW_OUTPUTDRIVER outDriver = StringLiteral + )? + | genericSpec = id_ ; alterDataConnectorStatementSuffix @@ -1581,79 +1552,55 @@ alterDataConnectorStatementSuffix ; alterDataConnectorSuffixProperties - : name=id_ KW_SET KW_DCPROPERTIES dcProperties + : name = id_ KW_SET KW_DCPROPERTIES dcProperties ; alterDataConnectorSuffixSetOwner - : dcName=id_ KW_SET KW_OWNER principalName + : dcName = id_ KW_SET KW_OWNER principalName ; alterDataConnectorSuffixSetUrl - : dcName=id_ KW_SET KW_URL newUri=StringLiteral + : dcName = id_ KW_SET KW_URL newUri = StringLiteral ; likeTableOrFile : KW_LIKE KW_FILE - | KW_LIKE KW_FILE format=id_ uri=StringLiteral - | KW_LIKE likeName=tableName + | KW_LIKE KW_FILE format = id_ uri = StringLiteral + | KW_LIKE likeName = tableName ; /** Rules for parsing createtable */ createTableStatement - : KW_CREATE temp=KW_TEMPORARY? trans=KW_TRANSACTIONAL? ext=KW_EXTERNAL? KW_TABLE ifNotExists? name=tableName - ( likeTableOrFile - createTablePartitionSpec? - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - | (LPAREN columnNameTypeOrConstraintList RPAREN)? - tableComment? - createTablePartitionSpec? - tableBuckets? - tableSkewed? - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - (KW_AS selectStatementWithCTE)? - ) - | KW_CREATE mgd=KW_MANAGED KW_TABLE ifNotExists? name=tableName - ( likeTableOrFile - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - | (LPAREN columnNameTypeOrConstraintList RPAREN)? - tableComment? - createTablePartitionSpec? - tableBuckets? - tableSkewed? - tableRowFormat? - tableFileFormat? - tableLocation? - tablePropertiesPrefixed? - (KW_AS selectStatementWithCTE)? - ) + : KW_CREATE temp = KW_TEMPORARY? trans = KW_TRANSACTIONAL? ext = KW_EXTERNAL? KW_TABLE ifNotExists? name = tableName ( + likeTableOrFile createTablePartitionSpec? tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? + | (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? createTablePartitionSpec? tableBuckets? tableSkewed? tableRowFormat? + tableFileFormat? tableLocation? tablePropertiesPrefixed? (KW_AS selectStatementWithCTE)? + ) + | KW_CREATE mgd = KW_MANAGED KW_TABLE ifNotExists? name = tableName ( + likeTableOrFile tableRowFormat? tableFileFormat? tableLocation? tablePropertiesPrefixed? + | (LPAREN columnNameTypeOrConstraintList RPAREN)? tableComment? createTablePartitionSpec? tableBuckets? tableSkewed? tableRowFormat? + tableFileFormat? tableLocation? tablePropertiesPrefixed? (KW_AS selectStatementWithCTE)? + ) ; createDataConnectorStatement - : KW_CREATE KW_DATACONNECTOR ifNotExists? name=id_ dataConnectorType dataConnectorUrl dataConnectorComment? - (KW_WITH KW_DCPROPERTIES dcprops=dcProperties)? + : KW_CREATE KW_DATACONNECTOR ifNotExists? name = id_ dataConnectorType dataConnectorUrl dataConnectorComment? ( + KW_WITH KW_DCPROPERTIES dcprops = dcProperties + )? ; dataConnectorComment - : KW_COMMENT comment=StringLiteral + : KW_COMMENT comment = StringLiteral ; dataConnectorUrl - : KW_URL url=StringLiteral + : KW_URL url = StringLiteral ; dataConnectorType - : KW_TYPE dcType=StringLiteral + : KW_TYPE dcType = StringLiteral ; dcProperties @@ -1708,7 +1655,9 @@ atomjoinSource ; joinSource - : atomjoinSource (joinToken joinSourcePart (KW_ON expression | KW_USING columnParenthesesList)?)* + : atomjoinSource ( + joinToken joinSourcePart (KW_ON expression | KW_USING columnParenthesesList)? + )* ; joinSourcePart @@ -1729,18 +1678,20 @@ uniqueJoinToken joinToken : COMMA - | ( KW_INNER - | KW_CROSS - | (KW_RIGHT | KW_FULL) KW_OUTER? - | KW_LEFT (KW_SEMI | KW_ANTI | KW_OUTER)? - )? KW_JOIN + | ( + KW_INNER + | KW_CROSS + | (KW_RIGHT | KW_FULL) KW_OUTER? + | KW_LEFT (KW_SEMI | KW_ANTI | KW_OUTER)? + )? KW_JOIN ; lateralView : KW_LATERAL KW_VIEW KW_OUTER function_ tableAlias (KW_AS id_ (COMMA id_)*)? - | COMMA? KW_LATERAL ( KW_VIEW function_ tableAlias (KW_AS id_ (COMMA id_)*)? - | KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias (LPAREN id_ (COMMA id_)* RPAREN)? - ) + | COMMA? KW_LATERAL ( + KW_VIEW function_ tableAlias (KW_AS id_ (COMMA id_)*)? + | KW_TABLE LPAREN valuesClause RPAREN KW_AS? tableAlias (LPAREN id_ (COMMA id_)* RPAREN)? + ) ; tableAlias @@ -1748,8 +1699,9 @@ tableAlias ; tableBucketSample - : KW_TABLESAMPLE LPAREN KW_BUCKET numerator=Number KW_OUT KW_OF denominator=Number - (KW_ON expr+=expression (COMMA expr+=expression)*)? RPAREN + : KW_TABLESAMPLE LPAREN KW_BUCKET numerator = Number KW_OUT KW_OF denominator = Number ( + KW_ON expr += expression (COMMA expr += expression)* + )? RPAREN ; splitSample @@ -1762,26 +1714,29 @@ tableSample ; tableSource - : tabname=tableName props=tableProperties? ts=tableSample? asOf=asOfClause? (KW_AS? alias=id_)? + : tabname = tableName props = tableProperties? ts = tableSample? asOf = asOfClause? ( + KW_AS? alias = id_ + )? ; asOfClause - : KW_FOR ( KW_SYSTEM_TIME KW_AS KW_OF asOfTime=expression - | KW_FOR KW_SYSTEM_VERSION KW_AS KW_OF asOfVersion=Number - ) + : KW_FOR ( + KW_SYSTEM_TIME KW_AS KW_OF asOfTime = expression + | KW_FOR KW_SYSTEM_VERSION KW_AS KW_OF asOfVersion = Number + ) ; uniqueJoinTableSource - : tabname=tableName ts=tableSample? (KW_AS? alias=id_)? + : tabname = tableName ts = tableSample? (KW_AS? alias = id_)? ; tableName - : db=id_ DOT tab=id_ (DOT meta=id_)? - | tab=id_ + : db = id_ DOT tab = id_ (DOT meta = id_)? + | tab = id_ ; viewName - : (db=id_ DOT)? view=id_ + : (db = id_ DOT)? view = id_ ; subQuerySource @@ -1806,10 +1761,9 @@ partitionTableFunctionSource ; partitionedTableFunction - : n=id_ LPAREN KW_ON - ptfsrc=partitionTableFunctionSource spec=partitioningSpec? - (Identifier LPAREN expression RPAREN (COMMA Identifier LPAREN expression RPAREN)*)? - RPAREN alias=id_? + : n = id_ LPAREN KW_ON ptfsrc = partitionTableFunctionSource spec = partitioningSpec? ( + Identifier LPAREN expression RPAREN (COMMA Identifier LPAREN expression RPAREN)* + )? RPAREN alias = id_? ; /** @@ -1884,11 +1838,9 @@ selectList ; selectTrfmClause - : LPAREN selectExpressionList RPAREN - rowFormat recordWriter - KW_USING StringLiteral - (KW_AS (LPAREN (aliasList | columnNameTypeList) RPAREN | aliasList | columnNameTypeList))? - rowFormat recordReader + : LPAREN selectExpressionList RPAREN rowFormat recordWriter KW_USING StringLiteral ( + KW_AS (LPAREN (aliasList | columnNameTypeList) RPAREN | aliasList | columnNameTypeList) + )? rowFormat recordReader ; selectItem @@ -1897,11 +1849,9 @@ selectItem ; trfmClause - : (KW_MAP | KW_REDUCE) selectExpressionList - rowFormat recordWriter - KW_USING StringLiteral - (KW_AS (LPAREN (aliasList | columnNameTypeList) RPAREN | aliasList | columnNameTypeList))? - rowFormat recordReader + : (KW_MAP | KW_REDUCE) selectExpressionList rowFormat recordWriter KW_USING StringLiteral ( + KW_AS (LPAREN (aliasList | columnNameTypeList) RPAREN | aliasList | columnNameTypeList) + )? rowFormat recordReader ; selectExpression @@ -1935,15 +1885,17 @@ window_frame ; window_range_expression - : KW_ROWS ( window_frame_start_boundary - | KW_BETWEEN window_frame_boundary KW_AND window_frame_boundary - ) + : KW_ROWS ( + window_frame_start_boundary + | KW_BETWEEN window_frame_boundary KW_AND window_frame_boundary + ) ; window_value_expression - : KW_RANGE ( window_frame_start_boundary - | KW_BETWEEN window_frame_boundary KW_AND window_frame_boundary - ) + : KW_RANGE ( + window_frame_start_boundary + | KW_BETWEEN window_frame_boundary KW_AND window_frame_boundary + ) ; window_frame_start_boundary @@ -1975,15 +1927,14 @@ groupByEmpty // standard rollup syntax rollupStandard - : (rollup=KW_ROLLUP | cube=KW_CUBE) - LPAREN expression (COMMA expression)* RPAREN + : (rollup = KW_ROLLUP | cube = KW_CUBE) LPAREN expression (COMMA expression)* RPAREN ; // old hive rollup syntax rollupOldSyntax - : expr=expressionsNotInParenthesis - (rollup=KW_WITH KW_ROLLUP | cube=KW_WITH KW_CUBE)? - (sets=KW_GROUPING KW_SETS LPAREN groupingSetExpression (COMMA groupingSetExpression)* RPAREN)? + : expr = expressionsNotInParenthesis (rollup = KW_WITH KW_ROLLUP | cube = KW_WITH KW_CUBE)? ( + sets = KW_GROUPING KW_SETS LPAREN groupingSetExpression (COMMA groupingSetExpression)* RPAREN + )? ; groupingSetExpression @@ -2016,7 +1967,7 @@ expressionsInParenthesis ; expressionsNotInParenthesis - : first=expressionOrDefault more=expressionPart? + : first = expressionOrDefault more = expressionPart? ; expressionPart @@ -2033,14 +1984,14 @@ Parses comma separated list of expressions with optionally specified aliases. [] [, []] */ firstExpressionsWithAlias - : first=expression KW_AS? colAlias=id_? (COMMA expressionWithAlias)* + : first = expression KW_AS? colAlias = id_? (COMMA expressionWithAlias)* ; /** Parses expressions which may have alias. If alias is not specified generate one. */ expressionWithAlias - : expression KW_AS? alias=id_? + : expression KW_AS? alias = id_? ; expressions @@ -2079,26 +2030,26 @@ sortByClause // TRIM([LEADING|TRAILING|BOTH] trim_characters FROM str) trimFunction - : KW_TRIM LPAREN (leading=KW_LEADING | trailing=KW_TRAILING | KW_BOTH)? - trim_characters=selectExpression? KW_FROM str=selectExpression RPAREN + : KW_TRIM LPAREN (leading = KW_LEADING | trailing = KW_TRAILING | KW_BOTH)? trim_characters = selectExpression? KW_FROM str = selectExpression + RPAREN ; // fun(par1, par2, par3) function_ : trimFunction - | functionName - LPAREN - (star=STAR | dist=all_distinct? (selectExpression (COMMA selectExpression)*)?) - ( + | functionName LPAREN ( + star = STAR + | dist = all_distinct? (selectExpression (COMMA selectExpression)*)? + ) ( // SELECT rank(3) WITHIN GROUP () - RPAREN within=KW_WITHIN KW_GROUP LPAREN ordBy=orderByClause RPAREN + RPAREN within = KW_WITHIN KW_GROUP LPAREN ordBy = orderByClause RPAREN // No null treatment: SELECT first_value(b) OVER () // Standard null treatment spec: SELECT first_value(b) IGNORE NULLS OVER () - | RPAREN nt=null_treatment? KW_OVER ws=window_specification + | RPAREN nt = null_treatment? KW_OVER ws = window_specification // Non-standard null treatment spec: SELECT first_value(b IGNORE NULLS) OVER () - | nt=null_treatment RPAREN KW_OVER ws=window_specification + | nt = null_treatment RPAREN KW_OVER ws = window_specification | RPAREN - ) + ) ; null_treatment @@ -2112,31 +2063,19 @@ functionName ; castExpression - : KW_CAST - LPAREN - expression - KW_AS - toType=primitiveType - (fmt=KW_FORMAT StringLiteral)? - RPAREN + : KW_CAST LPAREN expression KW_AS toType = primitiveType (fmt = KW_FORMAT StringLiteral)? RPAREN ; caseExpression - : KW_CASE expression - (KW_WHEN expression KW_THEN expression)+ - (KW_ELSE expression)? - KW_END + : KW_CASE expression (KW_WHEN expression KW_THEN expression)+ (KW_ELSE expression)? KW_END ; whenExpression - : KW_CASE - (KW_WHEN expression KW_THEN expression)+ - (KW_ELSE expression)? - KW_END + : KW_CASE (KW_WHEN expression KW_THEN expression)+ (KW_ELSE expression)? KW_END ; floorExpression - : KW_FLOOR LPAREN expression (KW_TO floorUnit=floorDateQualifiers)? RPAREN + : KW_FLOOR LPAREN expression (KW_TO floorUnit = floorDateQualifiers)? RPAREN ; floorDateQualifiers @@ -2151,7 +2090,7 @@ floorDateQualifiers ; extractExpression - : KW_EXTRACT LPAREN timeUnit=timeQualifiers KW_FROM expression RPAREN + : KW_EXTRACT LPAREN timeUnit = timeQualifiers KW_FROM expression RPAREN ; timeQualifiers @@ -2183,7 +2122,7 @@ constant ; prepareStmtParam - : p=parameterIdx + : p = parameterIdx ; parameterIdx @@ -2195,7 +2134,7 @@ stringLiteralSequence ; charSetStringLiteral - : csName=CharSetName csLiteral=CharSetLiteral + : csName = CharSetName csLiteral = CharSetLiteral ; dateLiteral @@ -2218,12 +2157,12 @@ intervalValue ; intervalLiteral - : value=intervalValue qualifiers=intervalQualifiers + : value = intervalValue qualifiers = intervalQualifiers ; intervalExpression - : LPAREN value=intervalValue RPAREN qualifiers=intervalQualifiers - | KW_INTERVAL (value=intervalValue | LPAREN expr=expression RPAREN) qualifiers=intervalQualifiers + : LPAREN value = intervalValue RPAREN qualifiers = intervalQualifiers + | KW_INTERVAL (value = intervalValue | LPAREN expr = expression RPAREN) qualifiers = intervalQualifiers ; intervalQualifiers @@ -2274,7 +2213,9 @@ precedenceBitwiseXorOperator ; precedenceBitwiseXorExpression - : precedenceUnaryPrefixExpression (precedenceBitwiseXorOperator precedenceUnaryPrefixExpression)* + : precedenceUnaryPrefixExpression ( + precedenceBitwiseXorOperator precedenceUnaryPrefixExpression + )* ; precedenceStarOperator @@ -2302,8 +2243,7 @@ precedenceConcatenateOperator ; precedenceConcatenateExpression - : precedencePlusExpression (precedenceConcatenateOperator plus=precedencePlusExpression)* - + : precedencePlusExpression (precedenceConcatenateOperator plus = precedencePlusExpression)* ; precedenceAmpersandOperator @@ -2346,19 +2286,19 @@ precedenceSimilarExpression ; precedenceSimilarExpressionMain - : a=precedenceBitwiseOrExpression part=precedenceSimilarExpressionPart? + : a = precedenceBitwiseOrExpression part = precedenceSimilarExpressionPart? ; precedenceSimilarExpressionPart - : precedenceSimilarOperator equalExpr=precedenceBitwiseOrExpression + : precedenceSimilarOperator equalExpr = precedenceBitwiseOrExpression | precedenceSimilarExpressionAtom | KW_NOT precedenceSimilarExpressionPartNot ; precedenceSimilarExpressionAtom : KW_IN precedenceSimilarExpressionIn - | KW_BETWEEN min=precedenceBitwiseOrExpression KW_AND max=precedenceBitwiseOrExpression - | KW_LIKE (KW_ANY | KW_ALL) expr=expressionsInParenthesis + | KW_BETWEEN min = precedenceBitwiseOrExpression KW_AND max = precedenceBitwiseOrExpression + | KW_LIKE (KW_ANY | KW_ALL) expr = expressionsInParenthesis | precedenceSimilarExpressionQuantifierPredicate ; @@ -2374,11 +2314,11 @@ quantifierType precedenceSimilarExpressionIn : subQueryExpression - | expr=expressionsInParenthesis + | expr = expressionsInParenthesis ; precedenceSimilarExpressionPartNot - : precedenceRegexpOperator notExpr=precedenceBitwiseOrExpression + : precedenceRegexpOperator notExpr = precedenceBitwiseOrExpression | precedenceSimilarExpressionAtom ; @@ -2394,10 +2334,10 @@ precedenceEqualOperator ; precedenceEqualExpression - : precedenceSimilarExpression - ( equal+=precedenceEqualOperator p+=precedenceSimilarExpression - | dist+=precedenceDistinctOperator p+=precedenceSimilarExpression - )* + : precedenceSimilarExpression ( + equal += precedenceEqualOperator p += precedenceSimilarExpression + | dist += precedenceDistinctOperator p += precedenceSimilarExpression + )* ; isCondition @@ -2412,7 +2352,7 @@ isCondition ; precedenceUnarySuffixExpression - : precedenceEqualExpression (a=KW_IS isCondition)? + : precedenceEqualExpression (a = KW_IS isCondition)? ; precedenceNotOperator @@ -2541,7 +2481,7 @@ id_ ; functionIdentifier - : id_ (DOT fn=id_)? + : id_ (DOT fn = id_)? ; principalIdentifier @@ -2877,7 +2817,7 @@ resourcePlanDdlStatements ; rpAssign - : KW_QUERY_PARALLELISM EQUAL parallelism=Number + : KW_QUERY_PARALLELISM EQUAL parallelism = Number | KW_DEFAULT KW_POOL EQUAL poolPath ; @@ -2895,8 +2835,10 @@ rpUnassignList ; createResourcePlanStatement - : KW_CREATE KW_RESOURCE KW_PLAN ifNotExists? - (name=id_ KW_LIKE likeName=id_ | name=id_ (KW_WITH rpAssignList)?) + : KW_CREATE KW_RESOURCE KW_PLAN ifNotExists? ( + name = id_ KW_LIKE likeName = id_ + | name = id_ (KW_WITH rpAssignList)? + ) ; withReplace @@ -2920,15 +2862,15 @@ unmanaged ; alterResourcePlanStatement - : KW_ALTER KW_RESOURCE KW_PLAN name=id_ ( - KW_VALIDATE + : KW_ALTER KW_RESOURCE KW_PLAN name = id_ ( + KW_VALIDATE | KW_DISABLE | KW_SET rpAssignList | KW_UNSET rpUnassignList - | KW_RENAME KW_TO newName=id_ + | KW_RENAME KW_TO newName = id_ | activate enable? | enable activate? - ) + ) ; /** It might make sense to make this more generic, if something else could be enabled/disabled. @@ -2939,13 +2881,13 @@ globalWmStatement replaceResourcePlanStatement : KW_REPLACE ( - KW_ACTIVE KW_RESOURCE KW_PLAN KW_WITH src=id_ - | KW_RESOURCE KW_PLAN dest=id_ KW_WITH src=id_ - ) + KW_ACTIVE KW_RESOURCE KW_PLAN KW_WITH src = id_ + | KW_RESOURCE KW_PLAN dest = id_ KW_WITH src = id_ + ) ; dropResourcePlanStatement - : KW_DROP KW_RESOURCE KW_PLAN ifExists? name=id_ + : KW_DROP KW_RESOURCE KW_PLAN ifExists? name = id_ ; poolPath @@ -2995,27 +2937,27 @@ triggerActionExpressionStandalone ; createTriggerStatement - : KW_CREATE KW_TRIGGER rpName=id_ DOT triggerName=id_ - KW_WHEN triggerExpression KW_DO triggerActionExpression + : KW_CREATE KW_TRIGGER rpName = id_ DOT triggerName = id_ KW_WHEN triggerExpression KW_DO triggerActionExpression ; alterTriggerStatement - : KW_ALTER KW_TRIGGER rpName=id_ DOT triggerName=id_ - ( KW_WHEN triggerExpression KW_DO triggerActionExpression - | (KW_ADD KW_TO | KW_DROP KW_FROM) (KW_POOL poolName=poolPath | KW_UNMANAGED) - ) + : KW_ALTER KW_TRIGGER rpName = id_ DOT triggerName = id_ ( + KW_WHEN triggerExpression KW_DO triggerActionExpression + | (KW_ADD KW_TO | KW_DROP KW_FROM) (KW_POOL poolName = poolPath | KW_UNMANAGED) + ) ; dropTriggerStatement - : KW_DROP KW_TRIGGER rpName=id_ DOT triggerName=id_ + : KW_DROP KW_TRIGGER rpName = id_ DOT triggerName = id_ ; poolAssign - : ( KW_ALLOC_FRACTION EQUAL allocFraction=Number - | KW_QUERY_PARALLELISM EQUAL parallelism=Number - | KW_SCHEDULING_POLICY EQUAL policy=StringLiteral - | KW_PATH EQUAL path=poolPath - ) + : ( + KW_ALLOC_FRACTION EQUAL allocFraction = Number + | KW_QUERY_PARALLELISM EQUAL parallelism = Number + | KW_SCHEDULING_POLICY EQUAL policy = StringLiteral + | KW_PATH EQUAL path = poolPath + ) ; poolAssignList @@ -3023,37 +2965,35 @@ poolAssignList ; createPoolStatement - : KW_CREATE KW_POOL rpName=id_ DOT poolPath - KW_WITH poolAssignList + : KW_CREATE KW_POOL rpName = id_ DOT poolPath KW_WITH poolAssignList ; alterPoolStatement - : KW_ALTER KW_POOL rpName=id_ DOT poolPath - ( KW_SET poolAssignList + : KW_ALTER KW_POOL rpName = id_ DOT poolPath ( + KW_SET poolAssignList | KW_UNSET KW_SCHEDULING_POLICY - | (KW_ADD | KW_DROP) KW_TRIGGER triggerName=id_ - ) + | (KW_ADD | KW_DROP) KW_TRIGGER triggerName = id_ + ) ; dropPoolStatement - : KW_DROP KW_POOL rpName=id_ DOT poolPath + : KW_DROP KW_POOL rpName = id_ DOT poolPath ; createMappingStatement - : KW_CREATE mappingType=(KW_USER | KW_GROUP | KW_APPLICATION) - KW_MAPPING name=StringLiteral - KW_IN rpName=id_ (KW_TO path=poolPath | unmanaged) - (KW_WITH KW_ORDER order=Number)? + : KW_CREATE mappingType = (KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING name = StringLiteral KW_IN rpName = id_ ( + KW_TO path = poolPath + | unmanaged + ) (KW_WITH KW_ORDER order = Number)? ; alterMappingStatement - : KW_ALTER mappingType=(KW_USER | KW_GROUP | KW_APPLICATION) - KW_MAPPING name=StringLiteral - KW_IN rpName=id_ (KW_TO path=poolPath | unmanaged) - (KW_WITH KW_ORDER order=Number)? + : KW_ALTER mappingType = (KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING name = StringLiteral KW_IN rpName = id_ ( + KW_TO path = poolPath + | unmanaged + ) (KW_WITH KW_ORDER order = Number)? ; dropMappingStatement - : KW_DROP mappingType=(KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING - name=StringLiteral KW_IN rpName=id_ - ; + : KW_DROP mappingType = (KW_USER | KW_GROUP | KW_APPLICATION) KW_MAPPING name = StringLiteral KW_IN rpName = id_ + ; \ No newline at end of file diff --git a/sql/informix-sql/InformixSQLLexer.g4 b/sql/informix-sql/InformixSQLLexer.g4 index d812647e23..4134ec2165 100644 --- a/sql/informix-sql/InformixSQLLexer.g4 +++ b/sql/informix-sql/InformixSQLLexer.g4 @@ -22,199 +22,204 @@ * see as https://www.ibm.com/docs/en/informix-servers/14.10?topic=programming-guide-sql-syntax */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true lexer grammar InformixSQLLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} -SCOL: ';'; -DOT: '.'; -COMMA: ','; -OPEN_PAR: '('; -CLOSE_PAR: ')'; +SCOL : ';'; +DOT : '.'; +COMMA : ','; +OPEN_PAR : '('; +CLOSE_PAR : ')'; // Interval type Keywords -ABORT: 'ABORT'; -ACTION: 'ACTION'; -ACCESS_METHOD: 'ACCESS_METHOD'; -ADD: 'ADD'; -AFTER: 'AFTER'; -AGGREGATE: 'AGGREGATE'; -ALL: 'ALL'; -ALTER: 'ALTER'; -ANALYZE: 'ANALYZE'; -AND: 'AND'; -APPEND: 'APPEND'; -AS: 'AS'; -ASC: 'ASC'; -ATTACH: 'ATTACH'; -AUTOFREE: 'AUTOFREE'; -AUTOINCREMENT: 'AUTOINCREMENT'; -BEFORE: 'BEFORE'; -BEGIN: 'BEGIN'; -BETWEEN: 'BETWEEN'; -BY: 'BY'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CAST: 'CAST'; -CHECK: 'CHECK'; -CLOSE: 'CLOSE'; -COLLATE: 'COLLATE'; -COLLATION: 'COLLATION'; -COLUMN: 'COLUMN'; -COMMIT: 'COMMIT'; -COMPONENT: 'COMPONENT'; -CONFLICT: 'CONFLICT'; -CONSTRAINT: 'CONSTRAINT'; -CONTEXT: 'CONTEXT'; -CREATE: 'CREATE'; -CROSS: 'CROSS'; -CURRENT_DATE: 'CURRENT_DATE'; -CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -DATABASE: 'DATABASE'; -DATASKIP: 'DATASKIP'; -DEFAULT: 'DEFAULT'; -DEFERRABLE: 'DEFERRABLE'; -DEFERRED: 'DEFERRED'; -DELETE: 'DELETE'; -DEBUG: 'DEBUG'; -DESC: 'DESC'; -DETACH: 'DETACH'; -DISABLED: 'DISABLED'; -DISTINCT: 'DISTINCT'; -DROP: 'DROP'; -EACH: 'EACH'; -ELSE: 'ELSE'; -ENABLED: 'ENABLED'; -END: 'END'; -ESCAPE: 'ESCAPE'; -EXCEPT: 'EXCEPT'; -EXCLUSIVE: 'EXCLUSIVE'; -EXISTS: 'EXISTS'; -EXPLAIN: 'EXPLAIN'; -FAIL: 'FAIL'; -FOR: 'FOR'; -FOREIGN: 'FOREIGN'; -FILE: 'FILE'; -FROM: 'FROM'; -FULL: 'FULL'; -GLOB: 'GLOB'; -GROUP: 'GROUP'; -HAVING: 'HAVING'; -IF: 'IF'; -IGNORE: 'IGNORE'; -IMMEDIATE: 'IMMEDIATE'; -IN: 'IN'; -INDEX: 'INDEX'; -INDEXED: 'INDEXED'; -INITIALLY: 'INITIALLY'; -INNER: 'INNER'; -INSERT: 'INSERT'; -INSTEAD: 'INSTEAD'; -INTERSECT: 'INTERSECT'; -INTO: 'INTO'; -IS: 'IS'; -ISNULL: 'ISNULL'; -JOIN: 'JOIN'; -KEY: 'KEY'; -LABEL: 'LABEL'; -LEFT: 'LEFT'; -LIKE: 'LIKE'; -LIMIT: 'LIMIT'; -MATCH: 'MATCH'; -NATURAL: 'NATURAL'; -NO: 'NO'; -NOT: 'NOT'; -NOTNULL: 'NOTNULL'; -NULL: 'NULL'; -OF: 'OF'; -OFF: 'OFF'; -OFFSET: 'OFFSET'; -ON: 'ON'; -ONLINE: 'ONLINE'; -OR: 'OR'; -ORDER: 'ORDER'; -OUTER: 'OUTER'; -POLICY: 'POLICY'; -PLAN: 'PLAN'; -PRAGMA: 'PRAGMA'; -PRIMARY: 'PRIMARY'; -QUERY: 'QUERY'; -RAISE: 'RAISE'; -RECURSIVE: 'RECURSIVE'; -REFERENCES: 'REFERENCES'; -REGEXP: 'REGEXP'; -REINDEX: 'REINDEX'; -RELEASE: 'RELEASE'; -RENAME: 'RENAME'; -REPLACE: 'REPLACE'; -RESTRICT: 'RESTRICT'; -RIGHT: 'RIGHT'; -ROLLBACK: 'ROLLBACK'; -ROW: 'ROW'; -ROLE: 'ROLE'; -ROWS: 'ROWS'; -SAVEPOINT: 'SAVEPOINT'; -SECURITY: 'SECURITY'; -SELECT: 'SELECT'; -SET: 'SET'; -SEQUENCE: 'SEQUENCE'; -SYNONYM: 'SYNONYM'; -TABLE: 'TABLE'; -TEMP: 'TEMP'; -TEMPORARY: 'TEMPORARY'; -THEN: 'THEN'; -TO: 'TO'; -TRANSACTION: 'TRANSACTION'; -TRIGGER: 'TRIGGER'; -TRUSTED: 'TRUSTED'; -TYPE: 'TYPE'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; -UPDATE: 'UPDATE'; -USER: 'USER'; -USING: 'USING'; -VACUUM: 'VACUUM'; -VALUES: 'VALUES'; -VIEW: 'VIEW'; -VIRTUAL: 'VIRTUAL'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WITH: 'WITH'; -WITHOUT: 'WITHOUT'; -WORK: 'WORK'; -XADATASOURCE: 'XADATASOURCE'; -FIRST_VALUE: 'FIRST_VALUE'; -OVER: 'OVER'; -PARTITION: 'PARTITION'; -RANGE: 'RANGE'; -PRECEDING: 'PRECEDING'; -UNBOUNDED: 'UNBOUNDED'; -CURRENT: 'CURRENT'; -FOLLOWING: 'FOLLOWING'; -CUME_DIST: 'CUME_DIST'; -DENSE_RANK: 'DENSE_RANK'; -LAG: 'LAG'; -LAST_VALUE: 'LAST_VALUE'; -LEAD: 'LEAD'; -NTH_VALUE: 'NTH_VALUE'; -NTILE: 'NTILE'; -PERCENT_RANK: 'PERCENT_RANK'; -RANK: 'RANK'; -ROW_NUMBER: 'ROW_NUMBER'; -GENERATED: 'GENERATED'; -ALWAYS: 'ALWAYS'; -STORED: 'STORED'; -TRUE: 'TRUE'; -FALSE: 'FALSE'; -WINDOW: 'WINDOW'; -NULLS: 'NULLS'; -FIRST: 'FIRST'; -LAST: 'LAST'; -FILTER: 'FILTER'; -GROUPS: 'GROUPS'; -EXCLUDE: 'EXCLUDE'; +ABORT : 'ABORT'; +ACTION : 'ACTION'; +ACCESS_METHOD : 'ACCESS_METHOD'; +ADD : 'ADD'; +AFTER : 'AFTER'; +AGGREGATE : 'AGGREGATE'; +ALL : 'ALL'; +ALTER : 'ALTER'; +ANALYZE : 'ANALYZE'; +AND : 'AND'; +APPEND : 'APPEND'; +AS : 'AS'; +ASC : 'ASC'; +ATTACH : 'ATTACH'; +AUTOFREE : 'AUTOFREE'; +AUTOINCREMENT : 'AUTOINCREMENT'; +BEFORE : 'BEFORE'; +BEGIN : 'BEGIN'; +BETWEEN : 'BETWEEN'; +BY : 'BY'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CHECK : 'CHECK'; +CLOSE : 'CLOSE'; +COLLATE : 'COLLATE'; +COLLATION : 'COLLATION'; +COLUMN : 'COLUMN'; +COMMIT : 'COMMIT'; +COMPONENT : 'COMPONENT'; +CONFLICT : 'CONFLICT'; +CONSTRAINT : 'CONSTRAINT'; +CONTEXT : 'CONTEXT'; +CREATE : 'CREATE'; +CROSS : 'CROSS'; +CURRENT_DATE : 'CURRENT_DATE'; +CURRENT_TIME : 'CURRENT_TIME'; +CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +DATABASE : 'DATABASE'; +DATASKIP : 'DATASKIP'; +DEFAULT : 'DEFAULT'; +DEFERRABLE : 'DEFERRABLE'; +DEFERRED : 'DEFERRED'; +DELETE : 'DELETE'; +DEBUG : 'DEBUG'; +DESC : 'DESC'; +DETACH : 'DETACH'; +DISABLED : 'DISABLED'; +DISTINCT : 'DISTINCT'; +DROP : 'DROP'; +EACH : 'EACH'; +ELSE : 'ELSE'; +ENABLED : 'ENABLED'; +END : 'END'; +ESCAPE : 'ESCAPE'; +EXCEPT : 'EXCEPT'; +EXCLUSIVE : 'EXCLUSIVE'; +EXISTS : 'EXISTS'; +EXPLAIN : 'EXPLAIN'; +FAIL : 'FAIL'; +FOR : 'FOR'; +FOREIGN : 'FOREIGN'; +FILE : 'FILE'; +FROM : 'FROM'; +FULL : 'FULL'; +GLOB : 'GLOB'; +GROUP : 'GROUP'; +HAVING : 'HAVING'; +IF : 'IF'; +IGNORE : 'IGNORE'; +IMMEDIATE : 'IMMEDIATE'; +IN : 'IN'; +INDEX : 'INDEX'; +INDEXED : 'INDEXED'; +INITIALLY : 'INITIALLY'; +INNER : 'INNER'; +INSERT : 'INSERT'; +INSTEAD : 'INSTEAD'; +INTERSECT : 'INTERSECT'; +INTO : 'INTO'; +IS : 'IS'; +ISNULL : 'ISNULL'; +JOIN : 'JOIN'; +KEY : 'KEY'; +LABEL : 'LABEL'; +LEFT : 'LEFT'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +MATCH : 'MATCH'; +NATURAL : 'NATURAL'; +NO : 'NO'; +NOT : 'NOT'; +NOTNULL : 'NOTNULL'; +NULL : 'NULL'; +OF : 'OF'; +OFF : 'OFF'; +OFFSET : 'OFFSET'; +ON : 'ON'; +ONLINE : 'ONLINE'; +OR : 'OR'; +ORDER : 'ORDER'; +OUTER : 'OUTER'; +POLICY : 'POLICY'; +PLAN : 'PLAN'; +PRAGMA : 'PRAGMA'; +PRIMARY : 'PRIMARY'; +QUERY : 'QUERY'; +RAISE : 'RAISE'; +RECURSIVE : 'RECURSIVE'; +REFERENCES : 'REFERENCES'; +REGEXP : 'REGEXP'; +REINDEX : 'REINDEX'; +RELEASE : 'RELEASE'; +RENAME : 'RENAME'; +REPLACE : 'REPLACE'; +RESTRICT : 'RESTRICT'; +RIGHT : 'RIGHT'; +ROLLBACK : 'ROLLBACK'; +ROW : 'ROW'; +ROLE : 'ROLE'; +ROWS : 'ROWS'; +SAVEPOINT : 'SAVEPOINT'; +SECURITY : 'SECURITY'; +SELECT : 'SELECT'; +SET : 'SET'; +SEQUENCE : 'SEQUENCE'; +SYNONYM : 'SYNONYM'; +TABLE : 'TABLE'; +TEMP : 'TEMP'; +TEMPORARY : 'TEMPORARY'; +THEN : 'THEN'; +TO : 'TO'; +TRANSACTION : 'TRANSACTION'; +TRIGGER : 'TRIGGER'; +TRUSTED : 'TRUSTED'; +TYPE : 'TYPE'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; +UPDATE : 'UPDATE'; +USER : 'USER'; +USING : 'USING'; +VACUUM : 'VACUUM'; +VALUES : 'VALUES'; +VIEW : 'VIEW'; +VIRTUAL : 'VIRTUAL'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WITH : 'WITH'; +WITHOUT : 'WITHOUT'; +WORK : 'WORK'; +XADATASOURCE : 'XADATASOURCE'; +FIRST_VALUE : 'FIRST_VALUE'; +OVER : 'OVER'; +PARTITION : 'PARTITION'; +RANGE : 'RANGE'; +PRECEDING : 'PRECEDING'; +UNBOUNDED : 'UNBOUNDED'; +CURRENT : 'CURRENT'; +FOLLOWING : 'FOLLOWING'; +CUME_DIST : 'CUME_DIST'; +DENSE_RANK : 'DENSE_RANK'; +LAG : 'LAG'; +LAST_VALUE : 'LAST_VALUE'; +LEAD : 'LEAD'; +NTH_VALUE : 'NTH_VALUE'; +NTILE : 'NTILE'; +PERCENT_RANK : 'PERCENT_RANK'; +RANK : 'RANK'; +ROW_NUMBER : 'ROW_NUMBER'; +GENERATED : 'GENERATED'; +ALWAYS : 'ALWAYS'; +STORED : 'STORED'; +TRUE : 'TRUE'; +FALSE : 'FALSE'; +WINDOW : 'WINDOW'; +NULLS : 'NULLS'; +FIRST : 'FIRST'; +LAST : 'LAST'; +FILTER : 'FILTER'; +GROUPS : 'GROUPS'; +EXCLUDE : 'EXCLUDE'; IDENTIFIER: '"' (~'"' | '""')* '"' @@ -232,15 +237,26 @@ STRING_LITERAL: '\'' (~'\'' | '\'\'')* '\''; CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'\'' | NEWLINE)* '\''; // Use quoted string as char_string -CHAR_STRING_PERL : 'Q' '\'' (QS_ANGLE | QS_BRACE | QS_BRACK | QS_PAREN | QS_EXCLAM | QS_SHARP | QS_QUOTE | QS_DQUOTE) '\'' -> type(CHAR_STRING); -fragment QS_ANGLE : '<' ~'>'* '>'; -fragment QS_BRACE : '{' ~'}'* '}'; -fragment QS_BRACK : '[' ~']'* ']'; -fragment QS_PAREN : '(' ~')'* ')'; -fragment QS_EXCLAM : '!' ~'!'* '!'; -fragment QS_SHARP : '#' ~'#'* '#'; -fragment QS_QUOTE : '\'' ~'\''* '\''; -fragment QS_DQUOTE : '"' ~'"'* '"'; +CHAR_STRING_PERL: + 'Q' '\'' ( + QS_ANGLE + | QS_BRACE + | QS_BRACK + | QS_PAREN + | QS_EXCLAM + | QS_SHARP + | QS_QUOTE + | QS_DQUOTE + ) '\'' -> type(CHAR_STRING) +; +fragment QS_ANGLE : '<' ~'>'* '>'; +fragment QS_BRACE : '{' ~'}'* '}'; +fragment QS_BRACK : '[' ~']'* ']'; +fragment QS_PAREN : '(' ~')'* ')'; +fragment QS_EXCLAM : '!' ~'!'* '!'; +fragment QS_SHARP : '#' ~'#'* '#'; +fragment QS_QUOTE : '\'' ~'\''* '\''; +fragment QS_DQUOTE : '"' ~'"'* '"'; SINGLE_LINE_COMMENT: '--' ~[\r\n]* ('\r'? '\n' | EOF) -> channel(HIDDEN); @@ -248,8 +264,7 @@ MULTILINE_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); SPACES: [ \u000B\t\r\n] -> channel(HIDDEN); - -fragment NEWLINE_EOF : NEWLINE | EOF; -fragment HEX_DIGIT: [0-9A-F]; -fragment DIGIT: [0-9]; -fragment NEWLINE : '\r'? '\n'; \ No newline at end of file +fragment NEWLINE_EOF : NEWLINE | EOF; +fragment HEX_DIGIT : [0-9A-F]; +fragment DIGIT : [0-9]; +fragment NEWLINE : '\r'? '\n'; \ No newline at end of file diff --git a/sql/informix-sql/InformixSQLParser.g4 b/sql/informix-sql/InformixSQLParser.g4 index 2047a7fd14..382b6282ca 100644 --- a/sql/informix-sql/InformixSQLParser.g4 +++ b/sql/informix-sql/InformixSQLParser.g4 @@ -22,6 +22,9 @@ * see as https://www.ibm.com/docs/en/informix-servers/14.10?topic=programming-guide-sql-syntax */ +// $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 InformixSQLParser; options { @@ -34,121 +37,123 @@ sqlScript ; unitStatement - : (createRole - | closeStmt - | closeDatabaseStmt - | commitWorkStmt - | dropAccessMethod - | dropAggregate - | dropDatabase - | dropIndex - | dropRole - | dropSynonym - | dropTable - | dropTrigger - | dropTrustedContext - | dropType - | dropUser - | dropView - | dropXadatasource - | dropXadataTypeSource - | databaseStmt - | releaseSavepoint - | renameColumn - | renameConstraint - | renameDatabase - | renameIndex - | renameSecurity - | renameSequence - | renameTable - | renameTrustedContext - | renameUser - | rollbackWork - | savepointStmt - | setAutofree - | setCollation - | setDataskip - | setDebugFile + : ( + createRole + | closeStmt + | closeDatabaseStmt + | commitWorkStmt + | dropAccessMethod + | dropAggregate + | dropDatabase + | dropIndex + | dropRole + | dropSynonym + | dropTable + | dropTrigger + | dropTrustedContext + | dropType + | dropUser + | dropView + | dropXadatasource + | dropXadataTypeSource + | databaseStmt + | releaseSavepoint + | renameColumn + | renameConstraint + | renameDatabase + | renameIndex + | renameSecurity + | renameSequence + | renameTable + | renameTrustedContext + | renameUser + | rollbackWork + | savepointStmt + | setAutofree + | setCollation + | setDataskip + | setDebugFile ) SCOL ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-create-role-statement createRole - : CREATE ROLE (IF NOT EXISTS)? roleName=anyName + : CREATE ROLE (IF NOT EXISTS)? roleName = anyName ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-role-statement dropRole - : DROP ROLE (IF EXISTS)? roleName=anyName + : DROP ROLE (IF EXISTS)? roleName = anyName ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-synonym-statement dropSynonym - : DROP SYNONYM (IF EXISTS)? synonymName=identifier + : DROP SYNONYM (IF EXISTS)? synonymName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-table-statement dropTable - : DROP TABLE (IF EXISTS)? tableName=identifier (CASCADE | RESTRICT)? + : DROP TABLE (IF EXISTS)? tableName = identifier (CASCADE | RESTRICT)? ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-trigger-statement dropTrigger - : DROP TRIGGER (IF EXISTS)? triggerName=identifier + : DROP TRIGGER (IF EXISTS)? triggerName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-trusted-context-statement dropTrustedContext - : DROP TRUSTED CONTEXT contextName=anyName + : DROP TRUSTED CONTEXT contextName = anyName ; + // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-type-statement dropType - : DROP TYPE (IF EXISTS)? dataTypeName=identifier RESTRICT + : DROP TYPE (IF EXISTS)? dataTypeName = identifier RESTRICT ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-user-statement-unix-linux dropUser - : DROP USER userName=anyName + : DROP USER userName = anyName ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-view-statement dropView - : DROP VIEW (IF EXISTS)? viewName=identifier (CASCADE | RESTRICT)? + : DROP VIEW (IF EXISTS)? viewName = identifier (CASCADE | RESTRICT)? ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-xadatasource-statement dropXadatasource - : DROP XADATASOURCE (IF EXISTS)? xaSourceName=identifier RESTRICT + : DROP XADATASOURCE (IF EXISTS)? xaSourceName = identifier RESTRICT ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-xadatasource-type-statement dropXadataTypeSource - : DROP XADATASOURCE TYPE (IF EXISTS)? xaSourceName=identifier RESTRICT + : DROP XADATASOURCE TYPE (IF EXISTS)? xaSourceName = identifier RESTRICT ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-access-method-statement dropAccessMethod - : DROP ACCESS_METHOD (IF EXISTS)? accessMethodName=identifier RESTRICT + : DROP ACCESS_METHOD (IF EXISTS)? accessMethodName = identifier RESTRICT ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-aggregate-statement dropAggregate - : DROP AGGREGATE (IF EXISTS)? aggregateName=identifier + : DROP AGGREGATE (IF EXISTS)? aggregateName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-database-statement dropDatabase - : DROP DATABASE (IF EXISTS)? databaseName=identifier + : DROP DATABASE (IF EXISTS)? databaseName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-drop-index-statement dropIndex - : DROP INDEX (IF EXISTS)? indexName=identifier ONLINE? + : DROP INDEX (IF EXISTS)? indexName = identifier ONLINE? ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-close-statement closeStmt - : CLOSE cursorId=identifier + : CLOSE cursorId = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-close-database-statement @@ -158,7 +163,7 @@ closeDatabaseStmt // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-database-statement databaseStmt - : DATABASE databaseName=anyName EXCLUSIVE? + : DATABASE databaseName = anyName EXCLUSIVE? ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-commit-work-statement @@ -168,77 +173,77 @@ commitWorkStmt // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-release-savepoint-statement releaseSavepoint - : RELEASE SAVEPOINT savepointName=identifier + : RELEASE SAVEPOINT savepointName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-column-statement renameColumn - : RENAME COLUMN oldColumn=identifier TO newColumn=identifier + : RENAME COLUMN oldColumn = identifier TO newColumn = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-constraint-statement renameConstraint - : RENAME CONSTRAINT oldConstraint=identifier TO newConstraint=identifier + : RENAME CONSTRAINT oldConstraint = identifier TO newConstraint = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-database-statement renameDatabase - : RENAME DATABASE oldDatabase=identifier TO newDatabase=identifier + : RENAME DATABASE oldDatabase = identifier TO newDatabase = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-index-statement renameIndex - : RENAME INDEX oldIndex=identifier TO newIndex=identifier + : RENAME INDEX oldIndex = identifier TO newIndex = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-security-statement renameSecurity - : RENAME SECURITY (POLICY | LABEL (policy=identifier? | COMPONENT)) oldSecurity=identifier TO newSecurity=identifier + : RENAME SECURITY (POLICY | LABEL (policy = identifier? | COMPONENT)) oldSecurity = identifier TO newSecurity = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-sequence-statement renameSequence - : RENAME SEQUENCE oldSequence=identifier TO newSequence=identifier + : RENAME SEQUENCE oldSequence = identifier TO newSequence = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-table-statement renameTable - : RENAME TABLE oldTableName=identifier TO newTableName=identifier + : RENAME TABLE oldTableName = identifier TO newTableName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-trusted-context-statement renameTrustedContext - : RENAME TRUSTED CONTEXT oldTrustedContextName=identifier TO newTrustedContextName=identifier + : RENAME TRUSTED CONTEXT oldTrustedContextName = identifier TO newTrustedContextName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rename-user-statement-unix-linux renameUser - : RENAME USER oldUserName=identifier TO newUserName=identifier + : RENAME USER oldUserName = identifier TO newUserName = identifier ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-rollback-work-statement rollbackWork - : ROLLBACK WORK? (TO SAVEPOINT savepoint=identifier?)? + : ROLLBACK WORK? (TO SAVEPOINT savepoint = identifier?)? ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-savepoint-statement savepointStmt - : SAVEPOINT savepoint=identifier UNIQUE? + : SAVEPOINT savepoint = identifier UNIQUE? ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-set-autofree-statement setAutofree - : SET AUTOFREE (ENABLED | DISABLED)? (FOR (cursorId=identifier | cursorIdVar=anyName))? + : SET AUTOFREE (ENABLED | DISABLED)? (FOR (cursorId = identifier | cursorIdVar = anyName))? ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-set-collation-statement setCollation - : SET (COLLATION locale=quotedString | NO COLLATION) + : SET (COLLATION locale = quotedString | NO COLLATION) ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-set-dataskip-statement setDataskip - : SET DATASKIP (ON (identifier (COMMA identifier)*)? | OFF | DEFAULT) + : SET DATASKIP (ON (identifier (COMMA identifier)*)? | OFF | DEFAULT) ; // https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-set-debug-file-statement @@ -442,4 +447,4 @@ keyword | FILTER | GROUPS | EXCLUDE -; \ No newline at end of file + ; \ No newline at end of file diff --git a/sql/mariadb/MariaDBLexer.g4 b/sql/mariadb/MariaDBLexer.g4 index dce4428f03..1b4c38c24d 100644 --- a/sql/mariadb/MariaDBLexer.g4 +++ b/sql/mariadb/MariaDBLexer.g4 @@ -21,1351 +21,1356 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar MariaDBLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} -channels { MYSQLCOMMENT, ERRORCHANNEL } +channels { + MYSQLCOMMENT, + ERRORCHANNEL +} // SKIP -SPACE: [ \t\r\n]+ -> channel(HIDDEN); -SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel(MYSQLCOMMENT); -COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT: ( - ('--' [ \t]* | '#') ~[\r\n]* ('\r'? '\n' | EOF) - | '--' ('\r'? '\n' | EOF) - ) -> channel(HIDDEN); - +SPACE : [ \t\r\n]+ -> channel(HIDDEN); +SPEC_MYSQL_COMMENT : '/*!' .+? '*/' -> channel(MYSQLCOMMENT); +COMMENT_INPUT : '/*' .*? '*/' -> channel(HIDDEN); +LINE_COMMENT: + (('--' [ \t]* | '#') ~[\r\n]* ('\r'? '\n' | EOF) | '--' ('\r'? '\n' | EOF)) -> channel(HIDDEN) +; // Keywords // Common Keywords -ADD: 'ADD'; -ALL: 'ALL'; -ALTER: 'ALTER'; -ALWAYS: 'ALWAYS'; -ANALYZE: 'ANALYZE'; -AND: 'AND'; -ARRAY: 'ARRAY'; -AS: 'AS'; -ASC: 'ASC'; -ATTRIBUTE: 'ATTRIBUTE'; -BEFORE: 'BEFORE'; -BETWEEN: 'BETWEEN'; -BODY: 'BODY'; -BOTH: 'BOTH'; -BUCKETS: 'BUCKETS'; -BY: 'BY'; -CALL: 'CALL'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CAST: 'CAST'; -CHANGE: 'CHANGE'; -CHARACTER: 'CHARACTER'; -CHECK: 'CHECK'; -COLLATE: 'COLLATE'; -COLUMN: 'COLUMN'; -CONDITION: 'CONDITION'; -CONSTRAINT: 'CONSTRAINT'; -CONTINUE: 'CONTINUE'; -CONVERT: 'CONVERT'; -CREATE: 'CREATE'; -CROSS: 'CROSS'; -CURRENT: 'CURRENT'; -CURRENT_ROLE: 'CURRENT_ROLE'; -CURRENT_USER: 'CURRENT_USER'; -CURSOR: 'CURSOR'; -DATABASE: 'DATABASE'; -DATABASES: 'DATABASES'; -DECLARE: 'DECLARE'; -DEFAULT: 'DEFAULT'; -DELAYED: 'DELAYED'; -DELETE: 'DELETE'; -DESC: 'DESC'; -DESCRIBE: 'DESCRIBE'; -DETERMINISTIC: 'DETERMINISTIC'; -DIAGNOSTICS: 'DIAGNOSTICS'; -DISTINCT: 'DISTINCT'; -DISTINCTROW: 'DISTINCTROW'; -DROP: 'DROP'; -EACH: 'EACH'; -ELSE: 'ELSE'; -ELSEIF: 'ELSEIF'; -EMPTY: 'EMPTY'; -ENCLOSED: 'ENCLOSED'; -ESCAPED: 'ESCAPED'; -EXCEPT: 'EXCEPT'; -EXISTS: 'EXISTS'; -EXIT: 'EXIT'; -EXPLAIN: 'EXPLAIN'; -FALSE: 'FALSE'; -FETCH: 'FETCH'; -FOR: 'FOR'; -FORCE: 'FORCE'; -FOREIGN: 'FOREIGN'; -FROM: 'FROM'; -FULLTEXT: 'FULLTEXT'; -GENERATED: 'GENERATED'; -GET: 'GET'; -GRANT: 'GRANT'; -GROUP: 'GROUP'; -HAVING: 'HAVING'; -HIGH_PRIORITY: 'HIGH_PRIORITY'; -HISTOGRAM: 'HISTOGRAM'; -IF: 'IF'; -IGNORE: 'IGNORE'; -IGNORED: 'IGNORED'; -IN: 'IN'; -INDEX: 'INDEX'; -INFILE: 'INFILE'; -INNER: 'INNER'; -INOUT: 'INOUT'; -INSERT: 'INSERT'; -INTERVAL: 'INTERVAL'; -INTO: 'INTO'; -IS: 'IS'; -ITERATE: 'ITERATE'; -JOIN: 'JOIN'; -KEY: 'KEY'; -KEYS: 'KEYS'; -KILL: 'KILL'; -LATERAL: 'LATERAL'; -LEADING: 'LEADING'; -LEAVE: 'LEAVE'; -LEFT: 'LEFT'; -LIKE: 'LIKE'; -LIMIT: 'LIMIT'; -LINEAR: 'LINEAR'; -LINES: 'LINES'; -LOAD: 'LOAD'; -LOCK: 'LOCK'; -LOCKED: 'LOCKED'; -LOOP: 'LOOP'; -LOW_PRIORITY: 'LOW_PRIORITY'; -MASTER_BIND: 'MASTER_BIND'; -MASTER_SSL_VERIFY_SERVER_CERT: 'MASTER_SSL_VERIFY_SERVER_CERT'; -MATCH: 'MATCH'; -MAXVALUE: 'MAXVALUE'; -MINVALUE: 'MINVALUE'; -MODIFIES: 'MODIFIES'; -NATURAL: 'NATURAL'; -NOT: 'NOT'; -NO_WRITE_TO_BINLOG: 'NO_WRITE_TO_BINLOG'; -NULL_LITERAL: 'NULL'; -NUMBER: 'NUMBER'; -ON: 'ON'; -OPTIMIZE: 'OPTIMIZE'; -OPTION: 'OPTION'; -OPTIONAL: 'OPTIONAL'; -OPTIONALLY: 'OPTIONALLY'; -OR: 'OR'; -ORDER: 'ORDER'; -OUT: 'OUT'; -OUTER: 'OUTER'; -OUTFILE: 'OUTFILE'; -OVER: 'OVER'; -PARTITION: 'PARTITION'; -PRIMARY: 'PRIMARY'; -PACKAGE: 'PACKAGE'; -PROCEDURE: 'PROCEDURE'; -PURGE: 'PURGE'; -RANGE: 'RANGE'; -READ: 'READ'; -READS: 'READS'; -REFERENCES: 'REFERENCES'; -REGEXP: 'REGEXP'; -RELEASE: 'RELEASE'; -RENAME: 'RENAME'; -REPEAT: 'REPEAT'; -REPLACE: 'REPLACE'; -REQUIRE: 'REQUIRE'; -RESIGNAL: 'RESIGNAL'; -RESTRICT: 'RESTRICT'; -RETAIN: 'RETAIN'; -RETURN: 'RETURN'; -REVOKE: 'REVOKE'; -RIGHT: 'RIGHT'; -RLIKE: 'RLIKE'; -SCHEMA: 'SCHEMA'; -SCHEMAS: 'SCHEMAS'; -SELECT: 'SELECT'; -SET: 'SET'; -SEPARATOR: 'SEPARATOR'; -SHOW: 'SHOW'; -SIGNAL: 'SIGNAL'; -SKIP_: 'SKIP'; -SPATIAL: 'SPATIAL'; -SQL: 'SQL'; -SQLEXCEPTION: 'SQLEXCEPTION'; -SQLSTATE: 'SQLSTATE'; -SQLWARNING: 'SQLWARNING'; -SQL_BIG_RESULT: 'SQL_BIG_RESULT'; -SQL_CALC_FOUND_ROWS: 'SQL_CALC_FOUND_ROWS'; -SQL_SMALL_RESULT: 'SQL_SMALL_RESULT'; -SSL: 'SSL'; -STACKED: 'STACKED'; -STARTING: 'STARTING'; -STATEMENT: 'STATEMENT'; -STRAIGHT_JOIN: 'STRAIGHT_JOIN'; -TABLE: 'TABLE'; -TERMINATED: 'TERMINATED'; -THEN: 'THEN'; -TO: 'TO'; -TRAILING: 'TRAILING'; -TRIGGER: 'TRIGGER'; -TRUE: 'TRUE'; -UNDO: 'UNDO'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; -UNLOCK: 'UNLOCK'; -UNSIGNED: 'UNSIGNED'; -UPDATE: 'UPDATE'; -USAGE: 'USAGE'; -USE: 'USE'; -USING: 'USING'; -VALUES: 'VALUES'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WHILE: 'WHILE'; -WITH: 'WITH'; -WRITE: 'WRITE'; -XOR: 'XOR'; -ZEROFILL: 'ZEROFILL'; +ADD : 'ADD'; +ALL : 'ALL'; +ALTER : 'ALTER'; +ALWAYS : 'ALWAYS'; +ANALYZE : 'ANALYZE'; +AND : 'AND'; +ARRAY : 'ARRAY'; +AS : 'AS'; +ASC : 'ASC'; +ATTRIBUTE : 'ATTRIBUTE'; +BEFORE : 'BEFORE'; +BETWEEN : 'BETWEEN'; +BODY : 'BODY'; +BOTH : 'BOTH'; +BUCKETS : 'BUCKETS'; +BY : 'BY'; +CALL : 'CALL'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CHANGE : 'CHANGE'; +CHARACTER : 'CHARACTER'; +CHECK : 'CHECK'; +COLLATE : 'COLLATE'; +COLUMN : 'COLUMN'; +CONDITION : 'CONDITION'; +CONSTRAINT : 'CONSTRAINT'; +CONTINUE : 'CONTINUE'; +CONVERT : 'CONVERT'; +CREATE : 'CREATE'; +CROSS : 'CROSS'; +CURRENT : 'CURRENT'; +CURRENT_ROLE : 'CURRENT_ROLE'; +CURRENT_USER : 'CURRENT_USER'; +CURSOR : 'CURSOR'; +DATABASE : 'DATABASE'; +DATABASES : 'DATABASES'; +DECLARE : 'DECLARE'; +DEFAULT : 'DEFAULT'; +DELAYED : 'DELAYED'; +DELETE : 'DELETE'; +DESC : 'DESC'; +DESCRIBE : 'DESCRIBE'; +DETERMINISTIC : 'DETERMINISTIC'; +DIAGNOSTICS : 'DIAGNOSTICS'; +DISTINCT : 'DISTINCT'; +DISTINCTROW : 'DISTINCTROW'; +DROP : 'DROP'; +EACH : 'EACH'; +ELSE : 'ELSE'; +ELSEIF : 'ELSEIF'; +EMPTY : 'EMPTY'; +ENCLOSED : 'ENCLOSED'; +ESCAPED : 'ESCAPED'; +EXCEPT : 'EXCEPT'; +EXISTS : 'EXISTS'; +EXIT : 'EXIT'; +EXPLAIN : 'EXPLAIN'; +FALSE : 'FALSE'; +FETCH : 'FETCH'; +FOR : 'FOR'; +FORCE : 'FORCE'; +FOREIGN : 'FOREIGN'; +FROM : 'FROM'; +FULLTEXT : 'FULLTEXT'; +GENERATED : 'GENERATED'; +GET : 'GET'; +GRANT : 'GRANT'; +GROUP : 'GROUP'; +HAVING : 'HAVING'; +HIGH_PRIORITY : 'HIGH_PRIORITY'; +HISTOGRAM : 'HISTOGRAM'; +IF : 'IF'; +IGNORE : 'IGNORE'; +IGNORED : 'IGNORED'; +IN : 'IN'; +INDEX : 'INDEX'; +INFILE : 'INFILE'; +INNER : 'INNER'; +INOUT : 'INOUT'; +INSERT : 'INSERT'; +INTERVAL : 'INTERVAL'; +INTO : 'INTO'; +IS : 'IS'; +ITERATE : 'ITERATE'; +JOIN : 'JOIN'; +KEY : 'KEY'; +KEYS : 'KEYS'; +KILL : 'KILL'; +LATERAL : 'LATERAL'; +LEADING : 'LEADING'; +LEAVE : 'LEAVE'; +LEFT : 'LEFT'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +LINEAR : 'LINEAR'; +LINES : 'LINES'; +LOAD : 'LOAD'; +LOCK : 'LOCK'; +LOCKED : 'LOCKED'; +LOOP : 'LOOP'; +LOW_PRIORITY : 'LOW_PRIORITY'; +MASTER_BIND : 'MASTER_BIND'; +MASTER_SSL_VERIFY_SERVER_CERT : 'MASTER_SSL_VERIFY_SERVER_CERT'; +MATCH : 'MATCH'; +MAXVALUE : 'MAXVALUE'; +MINVALUE : 'MINVALUE'; +MODIFIES : 'MODIFIES'; +NATURAL : 'NATURAL'; +NOT : 'NOT'; +NO_WRITE_TO_BINLOG : 'NO_WRITE_TO_BINLOG'; +NULL_LITERAL : 'NULL'; +NUMBER : 'NUMBER'; +ON : 'ON'; +OPTIMIZE : 'OPTIMIZE'; +OPTION : 'OPTION'; +OPTIONAL : 'OPTIONAL'; +OPTIONALLY : 'OPTIONALLY'; +OR : 'OR'; +ORDER : 'ORDER'; +OUT : 'OUT'; +OUTER : 'OUTER'; +OUTFILE : 'OUTFILE'; +OVER : 'OVER'; +PARTITION : 'PARTITION'; +PRIMARY : 'PRIMARY'; +PACKAGE : 'PACKAGE'; +PROCEDURE : 'PROCEDURE'; +PURGE : 'PURGE'; +RANGE : 'RANGE'; +READ : 'READ'; +READS : 'READS'; +REFERENCES : 'REFERENCES'; +REGEXP : 'REGEXP'; +RELEASE : 'RELEASE'; +RENAME : 'RENAME'; +REPEAT : 'REPEAT'; +REPLACE : 'REPLACE'; +REQUIRE : 'REQUIRE'; +RESIGNAL : 'RESIGNAL'; +RESTRICT : 'RESTRICT'; +RETAIN : 'RETAIN'; +RETURN : 'RETURN'; +REVOKE : 'REVOKE'; +RIGHT : 'RIGHT'; +RLIKE : 'RLIKE'; +SCHEMA : 'SCHEMA'; +SCHEMAS : 'SCHEMAS'; +SELECT : 'SELECT'; +SET : 'SET'; +SEPARATOR : 'SEPARATOR'; +SHOW : 'SHOW'; +SIGNAL : 'SIGNAL'; +SKIP_ : 'SKIP'; +SPATIAL : 'SPATIAL'; +SQL : 'SQL'; +SQLEXCEPTION : 'SQLEXCEPTION'; +SQLSTATE : 'SQLSTATE'; +SQLWARNING : 'SQLWARNING'; +SQL_BIG_RESULT : 'SQL_BIG_RESULT'; +SQL_CALC_FOUND_ROWS : 'SQL_CALC_FOUND_ROWS'; +SQL_SMALL_RESULT : 'SQL_SMALL_RESULT'; +SSL : 'SSL'; +STACKED : 'STACKED'; +STARTING : 'STARTING'; +STATEMENT : 'STATEMENT'; +STRAIGHT_JOIN : 'STRAIGHT_JOIN'; +TABLE : 'TABLE'; +TERMINATED : 'TERMINATED'; +THEN : 'THEN'; +TO : 'TO'; +TRAILING : 'TRAILING'; +TRIGGER : 'TRIGGER'; +TRUE : 'TRUE'; +UNDO : 'UNDO'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; +UNLOCK : 'UNLOCK'; +UNSIGNED : 'UNSIGNED'; +UPDATE : 'UPDATE'; +USAGE : 'USAGE'; +USE : 'USE'; +USING : 'USING'; +VALUES : 'VALUES'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WHILE : 'WHILE'; +WITH : 'WITH'; +WRITE : 'WRITE'; +XOR : 'XOR'; +ZEROFILL : 'ZEROFILL'; // DATA TYPE Keywords -TINYINT: 'TINYINT'; -SMALLINT: 'SMALLINT'; -MEDIUMINT: 'MEDIUMINT'; -MIDDLEINT: 'MIDDLEINT'; -INT: 'INT'; -INT1: 'INT1'; -INT2: 'INT2'; -INT3: 'INT3'; -INT4: 'INT4'; -INT8: 'INT8'; -INTEGER: 'INTEGER'; -BIGINT: 'BIGINT'; -REAL: 'REAL'; -DOUBLE: 'DOUBLE'; -PRECISION: 'PRECISION'; -FLOAT: 'FLOAT'; -FLOAT4: 'FLOAT4'; -FLOAT8: 'FLOAT8'; -DECIMAL: 'DECIMAL'; -DEC: 'DEC'; -NUMERIC: 'NUMERIC'; -DATE: 'DATE'; -TIME: 'TIME'; -TIMESTAMP: 'TIMESTAMP'; -DATETIME: 'DATETIME'; -YEAR: 'YEAR'; -CHAR: 'CHAR'; -VARCHAR: 'VARCHAR'; -NVARCHAR: 'NVARCHAR'; -NATIONAL: 'NATIONAL'; -BINARY: 'BINARY'; -VARBINARY: 'VARBINARY'; -TINYBLOB: 'TINYBLOB'; -BLOB: 'BLOB'; -MEDIUMBLOB: 'MEDIUMBLOB'; -LONG: 'LONG'; -LONGBLOB: 'LONGBLOB'; -TINYTEXT: 'TINYTEXT'; -TEXT: 'TEXT'; -MEDIUMTEXT: 'MEDIUMTEXT'; -LONGTEXT: 'LONGTEXT'; -ENUM: 'ENUM'; -VARYING: 'VARYING'; -SERIAL: 'SERIAL'; - +TINYINT : 'TINYINT'; +SMALLINT : 'SMALLINT'; +MEDIUMINT : 'MEDIUMINT'; +MIDDLEINT : 'MIDDLEINT'; +INT : 'INT'; +INT1 : 'INT1'; +INT2 : 'INT2'; +INT3 : 'INT3'; +INT4 : 'INT4'; +INT8 : 'INT8'; +INTEGER : 'INTEGER'; +BIGINT : 'BIGINT'; +REAL : 'REAL'; +DOUBLE : 'DOUBLE'; +PRECISION : 'PRECISION'; +FLOAT : 'FLOAT'; +FLOAT4 : 'FLOAT4'; +FLOAT8 : 'FLOAT8'; +DECIMAL : 'DECIMAL'; +DEC : 'DEC'; +NUMERIC : 'NUMERIC'; +DATE : 'DATE'; +TIME : 'TIME'; +TIMESTAMP : 'TIMESTAMP'; +DATETIME : 'DATETIME'; +YEAR : 'YEAR'; +CHAR : 'CHAR'; +VARCHAR : 'VARCHAR'; +NVARCHAR : 'NVARCHAR'; +NATIONAL : 'NATIONAL'; +BINARY : 'BINARY'; +VARBINARY : 'VARBINARY'; +TINYBLOB : 'TINYBLOB'; +BLOB : 'BLOB'; +MEDIUMBLOB : 'MEDIUMBLOB'; +LONG : 'LONG'; +LONGBLOB : 'LONGBLOB'; +TINYTEXT : 'TINYTEXT'; +TEXT : 'TEXT'; +MEDIUMTEXT : 'MEDIUMTEXT'; +LONGTEXT : 'LONGTEXT'; +ENUM : 'ENUM'; +VARYING : 'VARYING'; +SERIAL : 'SERIAL'; // Interval type Keywords -YEAR_MONTH: 'YEAR_MONTH'; -DAY_HOUR: 'DAY_HOUR'; -DAY_MINUTE: 'DAY_MINUTE'; -DAY_SECOND: 'DAY_SECOND'; -HOUR_MINUTE: 'HOUR_MINUTE'; -HOUR_SECOND: 'HOUR_SECOND'; -MINUTE_SECOND: 'MINUTE_SECOND'; -SECOND_MICROSECOND: 'SECOND_MICROSECOND'; -MINUTE_MICROSECOND: 'MINUTE_MICROSECOND'; -HOUR_MICROSECOND: 'HOUR_MICROSECOND'; -DAY_MICROSECOND: 'DAY_MICROSECOND'; +YEAR_MONTH : 'YEAR_MONTH'; +DAY_HOUR : 'DAY_HOUR'; +DAY_MINUTE : 'DAY_MINUTE'; +DAY_SECOND : 'DAY_SECOND'; +HOUR_MINUTE : 'HOUR_MINUTE'; +HOUR_SECOND : 'HOUR_SECOND'; +MINUTE_SECOND : 'MINUTE_SECOND'; +SECOND_MICROSECOND : 'SECOND_MICROSECOND'; +MINUTE_MICROSECOND : 'MINUTE_MICROSECOND'; +HOUR_MICROSECOND : 'HOUR_MICROSECOND'; +DAY_MICROSECOND : 'DAY_MICROSECOND'; // JSON keywords -JSON_ARRAY: 'JSON_ARRAY'; -JSON_ARRAYAGG: 'JSON_ARRAYAGG'; -JSON_ARRAY_APPEND: 'JSON_ARRAY_APPEND'; -JSON_ARRAY_INSERT: 'JSON_ARRAY_INSERT'; -JSON_CONTAINS: 'JSON_CONTAINS'; -JSON_CONTAINS_PATH: 'JSON_CONTAINS_PATH'; -JSON_DEPTH: 'JSON_DEPTH'; -JSON_EXTRACT: 'JSON_EXTRACT'; -JSON_INSERT: 'JSON_INSERT'; -JSON_KEYS: 'JSON_KEYS'; -JSON_LENGTH: 'JSON_LENGTH'; -JSON_MERGE: 'JSON_MERGE'; -JSON_MERGE_PATCH: 'JSON_MERGE_PATCH'; -JSON_MERGE_PRESERVE: 'JSON_MERGE_PRESERVE'; -JSON_OBJECT: 'JSON_OBJECT'; -JSON_OBJECTAGG: 'JSON_OBJECTAGG'; -JSON_OVERLAPS: 'JSON_OVERLAPS'; -JSON_PRETTY: 'JSON_PRETTY'; -JSON_QUOTE: 'JSON_QUOTE'; -JSON_REMOVE: 'JSON_REMOVE'; -JSON_REPLACE: 'JSON_REPLACE'; -JSON_SCHEMA_VALID: 'JSON_SCHEMA_VALID'; -JSON_SCHEMA_VALIDATION_REPORT: 'JSON_SCHEMA_VALIDATION_REPORT'; -JSON_SEARCH: 'JSON_SEARCH'; -JSON_SET: 'JSON_SET'; -JSON_STORAGE_FREE: 'JSON_STORAGE_FREE'; -JSON_STORAGE_SIZE: 'JSON_STORAGE_SIZE'; -JSON_TABLE: 'JSON_TABLE'; -JSON_TYPE: 'JSON_TYPE'; -JSON_UNQUOTE: 'JSON_UNQUOTE'; -JSON_VALID: 'JSON_VALID'; -JSON_VALUE: 'JSON_VALUE'; -NESTED: 'NESTED'; -ORDINALITY: 'ORDINALITY'; -PATH: 'PATH'; +JSON_ARRAY : 'JSON_ARRAY'; +JSON_ARRAYAGG : 'JSON_ARRAYAGG'; +JSON_ARRAY_APPEND : 'JSON_ARRAY_APPEND'; +JSON_ARRAY_INSERT : 'JSON_ARRAY_INSERT'; +JSON_CONTAINS : 'JSON_CONTAINS'; +JSON_CONTAINS_PATH : 'JSON_CONTAINS_PATH'; +JSON_DEPTH : 'JSON_DEPTH'; +JSON_EXTRACT : 'JSON_EXTRACT'; +JSON_INSERT : 'JSON_INSERT'; +JSON_KEYS : 'JSON_KEYS'; +JSON_LENGTH : 'JSON_LENGTH'; +JSON_MERGE : 'JSON_MERGE'; +JSON_MERGE_PATCH : 'JSON_MERGE_PATCH'; +JSON_MERGE_PRESERVE : 'JSON_MERGE_PRESERVE'; +JSON_OBJECT : 'JSON_OBJECT'; +JSON_OBJECTAGG : 'JSON_OBJECTAGG'; +JSON_OVERLAPS : 'JSON_OVERLAPS'; +JSON_PRETTY : 'JSON_PRETTY'; +JSON_QUOTE : 'JSON_QUOTE'; +JSON_REMOVE : 'JSON_REMOVE'; +JSON_REPLACE : 'JSON_REPLACE'; +JSON_SCHEMA_VALID : 'JSON_SCHEMA_VALID'; +JSON_SCHEMA_VALIDATION_REPORT : 'JSON_SCHEMA_VALIDATION_REPORT'; +JSON_SEARCH : 'JSON_SEARCH'; +JSON_SET : 'JSON_SET'; +JSON_STORAGE_FREE : 'JSON_STORAGE_FREE'; +JSON_STORAGE_SIZE : 'JSON_STORAGE_SIZE'; +JSON_TABLE : 'JSON_TABLE'; +JSON_TYPE : 'JSON_TYPE'; +JSON_UNQUOTE : 'JSON_UNQUOTE'; +JSON_VALID : 'JSON_VALID'; +JSON_VALUE : 'JSON_VALUE'; +NESTED : 'NESTED'; +ORDINALITY : 'ORDINALITY'; +PATH : 'PATH'; // Group function Keywords -AVG: 'AVG'; -BIT_AND: 'BIT_AND'; -BIT_OR: 'BIT_OR'; -BIT_XOR: 'BIT_XOR'; -COUNT: 'COUNT'; -CUME_DIST: 'CUME_DIST'; -DENSE_RANK: 'DENSE_RANK'; -FIRST_VALUE: 'FIRST_VALUE'; -GROUP_CONCAT: 'GROUP_CONCAT'; -LAG: 'LAG'; -LAST_VALUE: 'LAST_VALUE'; -LEAD: 'LEAD'; -MAX: 'MAX'; -MIN: 'MIN'; -NTILE: 'NTILE'; -NTH_VALUE: 'NTH_VALUE'; -PERCENT_RANK: 'PERCENT_RANK'; -RANK: 'RANK'; -ROW_NUMBER: 'ROW_NUMBER'; -STD: 'STD'; -STDDEV: 'STDDEV'; -STDDEV_POP: 'STDDEV_POP'; -STDDEV_SAMP: 'STDDEV_SAMP'; -SUM: 'SUM'; -VAR_POP: 'VAR_POP'; -VAR_SAMP: 'VAR_SAMP'; -VARIANCE: 'VARIANCE'; +AVG : 'AVG'; +BIT_AND : 'BIT_AND'; +BIT_OR : 'BIT_OR'; +BIT_XOR : 'BIT_XOR'; +COUNT : 'COUNT'; +CUME_DIST : 'CUME_DIST'; +DENSE_RANK : 'DENSE_RANK'; +FIRST_VALUE : 'FIRST_VALUE'; +GROUP_CONCAT : 'GROUP_CONCAT'; +LAG : 'LAG'; +LAST_VALUE : 'LAST_VALUE'; +LEAD : 'LEAD'; +MAX : 'MAX'; +MIN : 'MIN'; +NTILE : 'NTILE'; +NTH_VALUE : 'NTH_VALUE'; +PERCENT_RANK : 'PERCENT_RANK'; +RANK : 'RANK'; +ROW_NUMBER : 'ROW_NUMBER'; +STD : 'STD'; +STDDEV : 'STDDEV'; +STDDEV_POP : 'STDDEV_POP'; +STDDEV_SAMP : 'STDDEV_SAMP'; +SUM : 'SUM'; +VAR_POP : 'VAR_POP'; +VAR_SAMP : 'VAR_SAMP'; +VARIANCE : 'VARIANCE'; // Common function Keywords -CURRENT_DATE: 'CURRENT_DATE'; -CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -LOCALTIME: 'LOCALTIME'; -CURDATE: 'CURDATE'; -CURTIME: 'CURTIME'; -DATE_ADD: 'DATE_ADD'; -DATE_SUB: 'DATE_SUB'; -EXTRACT: 'EXTRACT'; -LOCALTIMESTAMP: 'LOCALTIMESTAMP'; -NOW: 'NOW'; -POSITION: 'POSITION'; -SUBSTR: 'SUBSTR'; -SUBSTRING: 'SUBSTRING'; -SYSDATE: 'SYSDATE'; -TRIM: 'TRIM'; -UTC_DATE: 'UTC_DATE'; -UTC_TIME: 'UTC_TIME'; -UTC_TIMESTAMP: 'UTC_TIMESTAMP'; +CURRENT_DATE : 'CURRENT_DATE'; +CURRENT_TIME : 'CURRENT_TIME'; +CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +LOCALTIME : 'LOCALTIME'; +CURDATE : 'CURDATE'; +CURTIME : 'CURTIME'; +DATE_ADD : 'DATE_ADD'; +DATE_SUB : 'DATE_SUB'; +EXTRACT : 'EXTRACT'; +LOCALTIMESTAMP : 'LOCALTIMESTAMP'; +NOW : 'NOW'; +POSITION : 'POSITION'; +SUBSTR : 'SUBSTR'; +SUBSTRING : 'SUBSTRING'; +SYSDATE : 'SYSDATE'; +TRIM : 'TRIM'; +UTC_DATE : 'UTC_DATE'; +UTC_TIME : 'UTC_TIME'; +UTC_TIMESTAMP : 'UTC_TIMESTAMP'; // Keywords, but can be ID // Common Keywords, but can be ID -ACCOUNT: 'ACCOUNT'; -ACTION: 'ACTION'; -AFTER: 'AFTER'; -AGGREGATE: 'AGGREGATE'; -ALGORITHM: 'ALGORITHM'; -ANY: 'ANY'; -AT: 'AT'; -AUTHORS: 'AUTHORS'; -AUTOCOMMIT: 'AUTOCOMMIT'; -AUTOEXTEND_SIZE: 'AUTOEXTEND_SIZE'; -AUTO_INCREMENT: 'AUTO_INCREMENT'; -AVG_ROW_LENGTH: 'AVG_ROW_LENGTH'; -BEGIN: 'BEGIN'; -BINLOG: 'BINLOG'; -BIT: 'BIT'; -BLOCK: 'BLOCK'; -BOOL: 'BOOL'; -BOOLEAN: 'BOOLEAN'; -BTREE: 'BTREE'; -CACHE: 'CACHE'; -CASCADED: 'CASCADED'; -CHAIN: 'CHAIN'; -CHANGED: 'CHANGED'; -CHANNEL: 'CHANNEL'; -CHECKSUM: 'CHECKSUM'; -PAGE_CHECKSUM: 'PAGE_CHECKSUM'; -CIPHER: 'CIPHER'; -CLASS_ORIGIN: 'CLASS_ORIGIN'; -CLIENT: 'CLIENT'; -CLOSE: 'CLOSE'; -CLUSTERING: 'CLUSTERING'; -COALESCE: 'COALESCE'; -CODE: 'CODE'; -COLUMNS: 'COLUMNS'; -COLUMN_FORMAT: 'COLUMN_FORMAT'; -COLUMN_NAME: 'COLUMN_NAME'; -COMMENT: 'COMMENT'; -COMMIT: 'COMMIT'; -COMPACT: 'COMPACT'; -COMPLETION: 'COMPLETION'; -COMPRESSED: 'COMPRESSED'; -COMPRESSION: 'COMPRESSION' | QUOTE_SYMB? 'COMPRESSION' QUOTE_SYMB?; -CONCURRENT: 'CONCURRENT'; -CONNECT: 'CONNECT'; -CONNECTION: 'CONNECTION'; -CONSISTENT: 'CONSISTENT'; -CONSTRAINT_CATALOG: 'CONSTRAINT_CATALOG'; -CONSTRAINT_SCHEMA: 'CONSTRAINT_SCHEMA'; -CONSTRAINT_NAME: 'CONSTRAINT_NAME'; -CONTAINS: 'CONTAINS'; -CONTEXT: 'CONTEXT'; -CONTRIBUTORS: 'CONTRIBUTORS'; -COPY: 'COPY'; -CPU: 'CPU'; -CYCLE: 'CYCLE'; -CURSOR_NAME: 'CURSOR_NAME'; -DATA: 'DATA'; -DATAFILE: 'DATAFILE'; -DEALLOCATE: 'DEALLOCATE'; -DEFAULT_AUTH: 'DEFAULT_AUTH'; -DEFINER: 'DEFINER'; -DELAY_KEY_WRITE: 'DELAY_KEY_WRITE'; -DES_KEY_FILE: 'DES_KEY_FILE'; -DIRECTORY: 'DIRECTORY'; -DISABLE: 'DISABLE'; -DISCARD: 'DISCARD'; -DISK: 'DISK'; -DO: 'DO'; -DUMPFILE: 'DUMPFILE'; -DUPLICATE: 'DUPLICATE'; -DYNAMIC: 'DYNAMIC'; -ENABLE: 'ENABLE'; -ENCRYPTED: 'ENCRYPTED'; -ENCRYPTION: 'ENCRYPTION'; -ENCRYPTION_KEY_ID: 'ENCRYPTION_KEY_ID'; -END: 'END'; -ENDS: 'ENDS'; -ENGINE: 'ENGINE'; -ENGINES: 'ENGINES'; -ERROR: 'ERROR'; -ERRORS: 'ERRORS'; -ESCAPE: 'ESCAPE'; -EVEN: 'EVEN'; -EVENT: 'EVENT'; -EVENTS: 'EVENTS'; -EVERY: 'EVERY'; -EXCHANGE: 'EXCHANGE'; -EXCLUSIVE: 'EXCLUSIVE'; -EXPIRE: 'EXPIRE'; -EXPORT: 'EXPORT'; -EXTENDED: 'EXTENDED'; -EXTENT_SIZE: 'EXTENT_SIZE'; -FAILED_LOGIN_ATTEMPTS: 'FAILED_LOGIN_ATTEMPTS'; -FAST: 'FAST'; -FAULTS: 'FAULTS'; -FIELDS: 'FIELDS'; -FILE_BLOCK_SIZE: 'FILE_BLOCK_SIZE'; -FILTER: 'FILTER'; -FIRST: 'FIRST'; -FIXED: 'FIXED'; -FLUSH: 'FLUSH'; -FOLLOWING: 'FOLLOWING'; -FOLLOWS: 'FOLLOWS'; -FOUND: 'FOUND'; -FULL: 'FULL'; -FUNCTION: 'FUNCTION'; -GENERAL: 'GENERAL'; -GLOBAL: 'GLOBAL'; -GRANTS: 'GRANTS'; -GROUP_REPLICATION: 'GROUP_REPLICATION'; -HANDLER: 'HANDLER'; -HASH: 'HASH'; -HELP: 'HELP'; -HISTORY: 'HISTORY'; -HOST: 'HOST'; -HOSTS: 'HOSTS'; -IDENTIFIED: 'IDENTIFIED'; -IGNORE_SERVER_IDS: 'IGNORE_SERVER_IDS'; -IMPORT: 'IMPORT'; -INCREMENT: 'INCREMENT'; -INDEXES: 'INDEXES'; -INITIAL_SIZE: 'INITIAL_SIZE'; -INPLACE: 'INPLACE'; -INSERT_METHOD: 'INSERT_METHOD'; -INSTALL: 'INSTALL'; -INSTANCE: 'INSTANCE'; -INSTANT: 'INSTANT'; -INVISIBLE: 'INVISIBLE'; -INVOKER: 'INVOKER'; -IO: 'IO'; -IO_THREAD: 'IO_THREAD'; -IPC: 'IPC'; -ISOLATION: 'ISOLATION'; -ISSUER: 'ISSUER'; -JSON: 'JSON'; -KEY_BLOCK_SIZE: 'KEY_BLOCK_SIZE'; -LANGUAGE: 'LANGUAGE'; -LAST: 'LAST'; -LEAVES: 'LEAVES'; -LESS: 'LESS'; -LEVEL: 'LEVEL'; -LIST: 'LIST'; -LOCAL: 'LOCAL'; -LOCALES: 'LOCALES'; -LOGFILE: 'LOGFILE'; -LOGS: 'LOGS'; -MASTER: 'MASTER'; -MASTER_AUTO_POSITION: 'MASTER_AUTO_POSITION'; -MASTER_CONNECT_RETRY: 'MASTER_CONNECT_RETRY'; -MASTER_DELAY: 'MASTER_DELAY'; -MASTER_HEARTBEAT_PERIOD: 'MASTER_HEARTBEAT_PERIOD'; -MASTER_HOST: 'MASTER_HOST'; -MASTER_LOG_FILE: 'MASTER_LOG_FILE'; -MASTER_LOG_POS: 'MASTER_LOG_POS'; -MASTER_PASSWORD: 'MASTER_PASSWORD'; -MASTER_PORT: 'MASTER_PORT'; -MASTER_RETRY_COUNT: 'MASTER_RETRY_COUNT'; -MASTER_SSL: 'MASTER_SSL'; -MASTER_SSL_CA: 'MASTER_SSL_CA'; -MASTER_SSL_CAPATH: 'MASTER_SSL_CAPATH'; -MASTER_SSL_CERT: 'MASTER_SSL_CERT'; -MASTER_SSL_CIPHER: 'MASTER_SSL_CIPHER'; -MASTER_SSL_CRL: 'MASTER_SSL_CRL'; -MASTER_SSL_CRLPATH: 'MASTER_SSL_CRLPATH'; -MASTER_SSL_KEY: 'MASTER_SSL_KEY'; -MASTER_TLS_VERSION: 'MASTER_TLS_VERSION'; -MASTER_USER: 'MASTER_USER'; -MAX_CONNECTIONS_PER_HOUR: 'MAX_CONNECTIONS_PER_HOUR'; -MAX_QUERIES_PER_HOUR: 'MAX_QUERIES_PER_HOUR'; -MAX_ROWS: 'MAX_ROWS'; -MAX_SIZE: 'MAX_SIZE'; -MAX_UPDATES_PER_HOUR: 'MAX_UPDATES_PER_HOUR'; -MAX_USER_CONNECTIONS: 'MAX_USER_CONNECTIONS'; -MEDIUM: 'MEDIUM'; -MEMBER: 'MEMBER'; -MERGE: 'MERGE'; -MESSAGE_TEXT: 'MESSAGE_TEXT'; -MID: 'MID'; -MIGRATE: 'MIGRATE'; -MIN_ROWS: 'MIN_ROWS'; -MODE: 'MODE'; -MODIFY: 'MODIFY'; -MUTEX: 'MUTEX'; -MYSQL: 'MYSQL'; -MYSQL_ERRNO: 'MYSQL_ERRNO'; -NAME: 'NAME'; -NAMES: 'NAMES'; -NCHAR: 'NCHAR'; -NEVER: 'NEVER'; -NEXT: 'NEXT'; -NO: 'NO'; -NOCACHE: 'NOCACHE'; -NOCOPY: 'NOCOPY'; -NOCYCLE: 'NOCYCLE'; -NOMAXVALUE: 'NOMAXVALUE'; -NOMINVALUE: 'NOMINVALUE'; -NOWAIT: 'NOWAIT'; -NODEGROUP: 'NODEGROUP'; -NONE: 'NONE'; -ODBC: 'ODBC'; -OFFLINE: 'OFFLINE'; -OFFSET: 'OFFSET'; -OF: 'OF'; -OJ: 'OJ'; -OLD_PASSWORD: 'OLD_PASSWORD'; -ONE: 'ONE'; -ONLINE: 'ONLINE'; -ONLY: 'ONLY'; -OPEN: 'OPEN'; -OPTIMIZER_COSTS: 'OPTIMIZER_COSTS'; -OPTIONS: 'OPTIONS'; -OWNER: 'OWNER'; -PACK_KEYS: 'PACK_KEYS'; -PAGE: 'PAGE'; -PAGE_COMPRESSED: 'PAGE_COMPRESSED'; -PAGE_COMPRESSION_LEVEL: 'PAGE_COMPRESSION_LEVEL'; -PARSER: 'PARSER'; -PARTIAL: 'PARTIAL'; -PARTITIONING: 'PARTITIONING'; -PARTITIONS: 'PARTITIONS'; -PASSWORD: 'PASSWORD'; -PASSWORD_LOCK_TIME: 'PASSWORD_LOCK_TIME'; -PHASE: 'PHASE'; -PLUGIN: 'PLUGIN'; -PLUGIN_DIR: 'PLUGIN_DIR'; -PLUGINS: 'PLUGINS'; -PORT: 'PORT'; -PRECEDES: 'PRECEDES'; -PRECEDING: 'PRECEDING'; -PREPARE: 'PREPARE'; -PRESERVE: 'PRESERVE'; -PREV: 'PREV'; -PROCESSLIST: 'PROCESSLIST'; -PROFILE: 'PROFILE'; -PROFILES: 'PROFILES'; -PROXY: 'PROXY'; -QUERY: 'QUERY'; -QUERY_RESPONSE_TIME: 'QUERY_RESPONSE_TIME'; -QUICK: 'QUICK'; -REBUILD: 'REBUILD'; -RECOVER: 'RECOVER'; -RECURSIVE: 'RECURSIVE'; -REDO_BUFFER_SIZE: 'REDO_BUFFER_SIZE'; -REDUNDANT: 'REDUNDANT'; -RELAY: 'RELAY'; -RELAY_LOG_FILE: 'RELAY_LOG_FILE'; -RELAY_LOG_POS: 'RELAY_LOG_POS'; -RELAYLOG: 'RELAYLOG'; -REMOVE: 'REMOVE'; -REORGANIZE: 'REORGANIZE'; -REPAIR: 'REPAIR'; -REPLICATE_DO_DB: 'REPLICATE_DO_DB'; -REPLICATE_DO_TABLE: 'REPLICATE_DO_TABLE'; -REPLICATE_IGNORE_DB: 'REPLICATE_IGNORE_DB'; -REPLICATE_IGNORE_TABLE: 'REPLICATE_IGNORE_TABLE'; -REPLICATE_REWRITE_DB: 'REPLICATE_REWRITE_DB'; -REPLICATE_WILD_DO_TABLE: 'REPLICATE_WILD_DO_TABLE'; -REPLICATE_WILD_IGNORE_TABLE: 'REPLICATE_WILD_IGNORE_TABLE'; -REPLICATION: 'REPLICATION'; -RESET: 'RESET'; -RESTART: 'RESTART'; -RESUME: 'RESUME'; -RETURNED_SQLSTATE: 'RETURNED_SQLSTATE'; -RETURNING: 'RETURNING'; -RETURNS: 'RETURNS'; -REUSE: 'REUSE'; -ROLE: 'ROLE'; -ROLLBACK: 'ROLLBACK'; -ROLLUP: 'ROLLUP'; -ROTATE: 'ROTATE'; -ROW: 'ROW'; -ROWS: 'ROWS'; -ROW_FORMAT: 'ROW_FORMAT'; -RTREE: 'RTREE'; -SAVEPOINT: 'SAVEPOINT'; -SCHEDULE: 'SCHEDULE'; -SECURITY: 'SECURITY'; -SEQUENCE: 'SEQUENCE'; -SERVER: 'SERVER'; -SESSION: 'SESSION'; -SHARE: 'SHARE'; -SHARED: 'SHARED'; -SIGNED: 'SIGNED'; -SIMPLE: 'SIMPLE'; -SLAVE: 'SLAVE'; -SLAVES: 'SLAVES'; -SLOW: 'SLOW'; -SNAPSHOT: 'SNAPSHOT'; -SOCKET: 'SOCKET'; -SOME: 'SOME'; -SONAME: 'SONAME'; -SOUNDS: 'SOUNDS'; -SOURCE: 'SOURCE'; -SQL_AFTER_GTIDS: 'SQL_AFTER_GTIDS'; -SQL_AFTER_MTS_GAPS: 'SQL_AFTER_MTS_GAPS'; -SQL_BEFORE_GTIDS: 'SQL_BEFORE_GTIDS'; -SQL_BUFFER_RESULT: 'SQL_BUFFER_RESULT'; -SQL_CACHE: 'SQL_CACHE'; -SQL_NO_CACHE: 'SQL_NO_CACHE'; -SQL_THREAD: 'SQL_THREAD'; -START: 'START'; -STARTS: 'STARTS'; -STATS_AUTO_RECALC: 'STATS_AUTO_RECALC'; -STATS_PERSISTENT: 'STATS_PERSISTENT'; -STATS_SAMPLE_PAGES: 'STATS_SAMPLE_PAGES'; -STATUS: 'STATUS'; -STOP: 'STOP'; -STORAGE: 'STORAGE'; -STORED: 'STORED'; -STRING: 'STRING'; -SUBCLASS_ORIGIN: 'SUBCLASS_ORIGIN'; -SUBJECT: 'SUBJECT'; -SUBPARTITION: 'SUBPARTITION'; -SUBPARTITIONS: 'SUBPARTITIONS'; -SUSPEND: 'SUSPEND'; -SWAPS: 'SWAPS'; -SWITCHES: 'SWITCHES'; -TABLE_NAME: 'TABLE_NAME'; -TABLESPACE: 'TABLESPACE'; -TABLE_TYPE: 'TABLE_TYPE'; -TEMPORARY: 'TEMPORARY'; -TEMPTABLE: 'TEMPTABLE'; -THAN: 'THAN'; -TRADITIONAL: 'TRADITIONAL'; -TRANSACTION: 'TRANSACTION'; -TRANSACTIONAL: 'TRANSACTIONAL'; -TRIGGERS: 'TRIGGERS'; -TRUNCATE: 'TRUNCATE'; -TYPES: 'TYPES'; -UNBOUNDED: 'UNBOUNDED'; -UNDEFINED: 'UNDEFINED'; -UNDOFILE: 'UNDOFILE'; -UNDO_BUFFER_SIZE: 'UNDO_BUFFER_SIZE'; -UNINSTALL: 'UNINSTALL'; -UNKNOWN: 'UNKNOWN'; -UNTIL: 'UNTIL'; -UPGRADE: 'UPGRADE'; -USER: 'USER'; -USE_FRM: 'USE_FRM'; -USER_RESOURCES: 'USER_RESOURCES'; -VALIDATION: 'VALIDATION'; -VALUE: 'VALUE'; -VARIABLES: 'VARIABLES'; -VIEW: 'VIEW'; -VIRTUAL: 'VIRTUAL'; -VISIBLE: 'VISIBLE'; -WAIT: 'WAIT'; -WARNINGS: 'WARNINGS'; -WINDOW: 'WINDOW'; -WITHOUT: 'WITHOUT'; -WORK: 'WORK'; -WRAPPER: 'WRAPPER'; -WSREP_MEMBERSHIP: 'WSREP_MEMBERSHIP'; -WSREP_STATUS: 'WSREP_STATUS'; -X509: 'X509'; -XA: 'XA'; -XML: 'XML'; -YES: 'YES'; +ACCOUNT : 'ACCOUNT'; +ACTION : 'ACTION'; +AFTER : 'AFTER'; +AGGREGATE : 'AGGREGATE'; +ALGORITHM : 'ALGORITHM'; +ANY : 'ANY'; +AT : 'AT'; +AUTHORS : 'AUTHORS'; +AUTOCOMMIT : 'AUTOCOMMIT'; +AUTOEXTEND_SIZE : 'AUTOEXTEND_SIZE'; +AUTO_INCREMENT : 'AUTO_INCREMENT'; +AVG_ROW_LENGTH : 'AVG_ROW_LENGTH'; +BEGIN : 'BEGIN'; +BINLOG : 'BINLOG'; +BIT : 'BIT'; +BLOCK : 'BLOCK'; +BOOL : 'BOOL'; +BOOLEAN : 'BOOLEAN'; +BTREE : 'BTREE'; +CACHE : 'CACHE'; +CASCADED : 'CASCADED'; +CHAIN : 'CHAIN'; +CHANGED : 'CHANGED'; +CHANNEL : 'CHANNEL'; +CHECKSUM : 'CHECKSUM'; +PAGE_CHECKSUM : 'PAGE_CHECKSUM'; +CIPHER : 'CIPHER'; +CLASS_ORIGIN : 'CLASS_ORIGIN'; +CLIENT : 'CLIENT'; +CLOSE : 'CLOSE'; +CLUSTERING : 'CLUSTERING'; +COALESCE : 'COALESCE'; +CODE : 'CODE'; +COLUMNS : 'COLUMNS'; +COLUMN_FORMAT : 'COLUMN_FORMAT'; +COLUMN_NAME : 'COLUMN_NAME'; +COMMENT : 'COMMENT'; +COMMIT : 'COMMIT'; +COMPACT : 'COMPACT'; +COMPLETION : 'COMPLETION'; +COMPRESSED : 'COMPRESSED'; +COMPRESSION : 'COMPRESSION' | QUOTE_SYMB? 'COMPRESSION' QUOTE_SYMB?; +CONCURRENT : 'CONCURRENT'; +CONNECT : 'CONNECT'; +CONNECTION : 'CONNECTION'; +CONSISTENT : 'CONSISTENT'; +CONSTRAINT_CATALOG : 'CONSTRAINT_CATALOG'; +CONSTRAINT_SCHEMA : 'CONSTRAINT_SCHEMA'; +CONSTRAINT_NAME : 'CONSTRAINT_NAME'; +CONTAINS : 'CONTAINS'; +CONTEXT : 'CONTEXT'; +CONTRIBUTORS : 'CONTRIBUTORS'; +COPY : 'COPY'; +CPU : 'CPU'; +CYCLE : 'CYCLE'; +CURSOR_NAME : 'CURSOR_NAME'; +DATA : 'DATA'; +DATAFILE : 'DATAFILE'; +DEALLOCATE : 'DEALLOCATE'; +DEFAULT_AUTH : 'DEFAULT_AUTH'; +DEFINER : 'DEFINER'; +DELAY_KEY_WRITE : 'DELAY_KEY_WRITE'; +DES_KEY_FILE : 'DES_KEY_FILE'; +DIRECTORY : 'DIRECTORY'; +DISABLE : 'DISABLE'; +DISCARD : 'DISCARD'; +DISK : 'DISK'; +DO : 'DO'; +DUMPFILE : 'DUMPFILE'; +DUPLICATE : 'DUPLICATE'; +DYNAMIC : 'DYNAMIC'; +ENABLE : 'ENABLE'; +ENCRYPTED : 'ENCRYPTED'; +ENCRYPTION : 'ENCRYPTION'; +ENCRYPTION_KEY_ID : 'ENCRYPTION_KEY_ID'; +END : 'END'; +ENDS : 'ENDS'; +ENGINE : 'ENGINE'; +ENGINES : 'ENGINES'; +ERROR : 'ERROR'; +ERRORS : 'ERRORS'; +ESCAPE : 'ESCAPE'; +EVEN : 'EVEN'; +EVENT : 'EVENT'; +EVENTS : 'EVENTS'; +EVERY : 'EVERY'; +EXCHANGE : 'EXCHANGE'; +EXCLUSIVE : 'EXCLUSIVE'; +EXPIRE : 'EXPIRE'; +EXPORT : 'EXPORT'; +EXTENDED : 'EXTENDED'; +EXTENT_SIZE : 'EXTENT_SIZE'; +FAILED_LOGIN_ATTEMPTS : 'FAILED_LOGIN_ATTEMPTS'; +FAST : 'FAST'; +FAULTS : 'FAULTS'; +FIELDS : 'FIELDS'; +FILE_BLOCK_SIZE : 'FILE_BLOCK_SIZE'; +FILTER : 'FILTER'; +FIRST : 'FIRST'; +FIXED : 'FIXED'; +FLUSH : 'FLUSH'; +FOLLOWING : 'FOLLOWING'; +FOLLOWS : 'FOLLOWS'; +FOUND : 'FOUND'; +FULL : 'FULL'; +FUNCTION : 'FUNCTION'; +GENERAL : 'GENERAL'; +GLOBAL : 'GLOBAL'; +GRANTS : 'GRANTS'; +GROUP_REPLICATION : 'GROUP_REPLICATION'; +HANDLER : 'HANDLER'; +HASH : 'HASH'; +HELP : 'HELP'; +HISTORY : 'HISTORY'; +HOST : 'HOST'; +HOSTS : 'HOSTS'; +IDENTIFIED : 'IDENTIFIED'; +IGNORE_SERVER_IDS : 'IGNORE_SERVER_IDS'; +IMPORT : 'IMPORT'; +INCREMENT : 'INCREMENT'; +INDEXES : 'INDEXES'; +INITIAL_SIZE : 'INITIAL_SIZE'; +INPLACE : 'INPLACE'; +INSERT_METHOD : 'INSERT_METHOD'; +INSTALL : 'INSTALL'; +INSTANCE : 'INSTANCE'; +INSTANT : 'INSTANT'; +INVISIBLE : 'INVISIBLE'; +INVOKER : 'INVOKER'; +IO : 'IO'; +IO_THREAD : 'IO_THREAD'; +IPC : 'IPC'; +ISOLATION : 'ISOLATION'; +ISSUER : 'ISSUER'; +JSON : 'JSON'; +KEY_BLOCK_SIZE : 'KEY_BLOCK_SIZE'; +LANGUAGE : 'LANGUAGE'; +LAST : 'LAST'; +LEAVES : 'LEAVES'; +LESS : 'LESS'; +LEVEL : 'LEVEL'; +LIST : 'LIST'; +LOCAL : 'LOCAL'; +LOCALES : 'LOCALES'; +LOGFILE : 'LOGFILE'; +LOGS : 'LOGS'; +MASTER : 'MASTER'; +MASTER_AUTO_POSITION : 'MASTER_AUTO_POSITION'; +MASTER_CONNECT_RETRY : 'MASTER_CONNECT_RETRY'; +MASTER_DELAY : 'MASTER_DELAY'; +MASTER_HEARTBEAT_PERIOD : 'MASTER_HEARTBEAT_PERIOD'; +MASTER_HOST : 'MASTER_HOST'; +MASTER_LOG_FILE : 'MASTER_LOG_FILE'; +MASTER_LOG_POS : 'MASTER_LOG_POS'; +MASTER_PASSWORD : 'MASTER_PASSWORD'; +MASTER_PORT : 'MASTER_PORT'; +MASTER_RETRY_COUNT : 'MASTER_RETRY_COUNT'; +MASTER_SSL : 'MASTER_SSL'; +MASTER_SSL_CA : 'MASTER_SSL_CA'; +MASTER_SSL_CAPATH : 'MASTER_SSL_CAPATH'; +MASTER_SSL_CERT : 'MASTER_SSL_CERT'; +MASTER_SSL_CIPHER : 'MASTER_SSL_CIPHER'; +MASTER_SSL_CRL : 'MASTER_SSL_CRL'; +MASTER_SSL_CRLPATH : 'MASTER_SSL_CRLPATH'; +MASTER_SSL_KEY : 'MASTER_SSL_KEY'; +MASTER_TLS_VERSION : 'MASTER_TLS_VERSION'; +MASTER_USER : 'MASTER_USER'; +MAX_CONNECTIONS_PER_HOUR : 'MAX_CONNECTIONS_PER_HOUR'; +MAX_QUERIES_PER_HOUR : 'MAX_QUERIES_PER_HOUR'; +MAX_ROWS : 'MAX_ROWS'; +MAX_SIZE : 'MAX_SIZE'; +MAX_UPDATES_PER_HOUR : 'MAX_UPDATES_PER_HOUR'; +MAX_USER_CONNECTIONS : 'MAX_USER_CONNECTIONS'; +MEDIUM : 'MEDIUM'; +MEMBER : 'MEMBER'; +MERGE : 'MERGE'; +MESSAGE_TEXT : 'MESSAGE_TEXT'; +MID : 'MID'; +MIGRATE : 'MIGRATE'; +MIN_ROWS : 'MIN_ROWS'; +MODE : 'MODE'; +MODIFY : 'MODIFY'; +MUTEX : 'MUTEX'; +MYSQL : 'MYSQL'; +MYSQL_ERRNO : 'MYSQL_ERRNO'; +NAME : 'NAME'; +NAMES : 'NAMES'; +NCHAR : 'NCHAR'; +NEVER : 'NEVER'; +NEXT : 'NEXT'; +NO : 'NO'; +NOCACHE : 'NOCACHE'; +NOCOPY : 'NOCOPY'; +NOCYCLE : 'NOCYCLE'; +NOMAXVALUE : 'NOMAXVALUE'; +NOMINVALUE : 'NOMINVALUE'; +NOWAIT : 'NOWAIT'; +NODEGROUP : 'NODEGROUP'; +NONE : 'NONE'; +ODBC : 'ODBC'; +OFFLINE : 'OFFLINE'; +OFFSET : 'OFFSET'; +OF : 'OF'; +OJ : 'OJ'; +OLD_PASSWORD : 'OLD_PASSWORD'; +ONE : 'ONE'; +ONLINE : 'ONLINE'; +ONLY : 'ONLY'; +OPEN : 'OPEN'; +OPTIMIZER_COSTS : 'OPTIMIZER_COSTS'; +OPTIONS : 'OPTIONS'; +OWNER : 'OWNER'; +PACK_KEYS : 'PACK_KEYS'; +PAGE : 'PAGE'; +PAGE_COMPRESSED : 'PAGE_COMPRESSED'; +PAGE_COMPRESSION_LEVEL : 'PAGE_COMPRESSION_LEVEL'; +PARSER : 'PARSER'; +PARTIAL : 'PARTIAL'; +PARTITIONING : 'PARTITIONING'; +PARTITIONS : 'PARTITIONS'; +PASSWORD : 'PASSWORD'; +PASSWORD_LOCK_TIME : 'PASSWORD_LOCK_TIME'; +PHASE : 'PHASE'; +PLUGIN : 'PLUGIN'; +PLUGIN_DIR : 'PLUGIN_DIR'; +PLUGINS : 'PLUGINS'; +PORT : 'PORT'; +PRECEDES : 'PRECEDES'; +PRECEDING : 'PRECEDING'; +PREPARE : 'PREPARE'; +PRESERVE : 'PRESERVE'; +PREV : 'PREV'; +PROCESSLIST : 'PROCESSLIST'; +PROFILE : 'PROFILE'; +PROFILES : 'PROFILES'; +PROXY : 'PROXY'; +QUERY : 'QUERY'; +QUERY_RESPONSE_TIME : 'QUERY_RESPONSE_TIME'; +QUICK : 'QUICK'; +REBUILD : 'REBUILD'; +RECOVER : 'RECOVER'; +RECURSIVE : 'RECURSIVE'; +REDO_BUFFER_SIZE : 'REDO_BUFFER_SIZE'; +REDUNDANT : 'REDUNDANT'; +RELAY : 'RELAY'; +RELAY_LOG_FILE : 'RELAY_LOG_FILE'; +RELAY_LOG_POS : 'RELAY_LOG_POS'; +RELAYLOG : 'RELAYLOG'; +REMOVE : 'REMOVE'; +REORGANIZE : 'REORGANIZE'; +REPAIR : 'REPAIR'; +REPLICATE_DO_DB : 'REPLICATE_DO_DB'; +REPLICATE_DO_TABLE : 'REPLICATE_DO_TABLE'; +REPLICATE_IGNORE_DB : 'REPLICATE_IGNORE_DB'; +REPLICATE_IGNORE_TABLE : 'REPLICATE_IGNORE_TABLE'; +REPLICATE_REWRITE_DB : 'REPLICATE_REWRITE_DB'; +REPLICATE_WILD_DO_TABLE : 'REPLICATE_WILD_DO_TABLE'; +REPLICATE_WILD_IGNORE_TABLE : 'REPLICATE_WILD_IGNORE_TABLE'; +REPLICATION : 'REPLICATION'; +RESET : 'RESET'; +RESTART : 'RESTART'; +RESUME : 'RESUME'; +RETURNED_SQLSTATE : 'RETURNED_SQLSTATE'; +RETURNING : 'RETURNING'; +RETURNS : 'RETURNS'; +REUSE : 'REUSE'; +ROLE : 'ROLE'; +ROLLBACK : 'ROLLBACK'; +ROLLUP : 'ROLLUP'; +ROTATE : 'ROTATE'; +ROW : 'ROW'; +ROWS : 'ROWS'; +ROW_FORMAT : 'ROW_FORMAT'; +RTREE : 'RTREE'; +SAVEPOINT : 'SAVEPOINT'; +SCHEDULE : 'SCHEDULE'; +SECURITY : 'SECURITY'; +SEQUENCE : 'SEQUENCE'; +SERVER : 'SERVER'; +SESSION : 'SESSION'; +SHARE : 'SHARE'; +SHARED : 'SHARED'; +SIGNED : 'SIGNED'; +SIMPLE : 'SIMPLE'; +SLAVE : 'SLAVE'; +SLAVES : 'SLAVES'; +SLOW : 'SLOW'; +SNAPSHOT : 'SNAPSHOT'; +SOCKET : 'SOCKET'; +SOME : 'SOME'; +SONAME : 'SONAME'; +SOUNDS : 'SOUNDS'; +SOURCE : 'SOURCE'; +SQL_AFTER_GTIDS : 'SQL_AFTER_GTIDS'; +SQL_AFTER_MTS_GAPS : 'SQL_AFTER_MTS_GAPS'; +SQL_BEFORE_GTIDS : 'SQL_BEFORE_GTIDS'; +SQL_BUFFER_RESULT : 'SQL_BUFFER_RESULT'; +SQL_CACHE : 'SQL_CACHE'; +SQL_NO_CACHE : 'SQL_NO_CACHE'; +SQL_THREAD : 'SQL_THREAD'; +START : 'START'; +STARTS : 'STARTS'; +STATS_AUTO_RECALC : 'STATS_AUTO_RECALC'; +STATS_PERSISTENT : 'STATS_PERSISTENT'; +STATS_SAMPLE_PAGES : 'STATS_SAMPLE_PAGES'; +STATUS : 'STATUS'; +STOP : 'STOP'; +STORAGE : 'STORAGE'; +STORED : 'STORED'; +STRING : 'STRING'; +SUBCLASS_ORIGIN : 'SUBCLASS_ORIGIN'; +SUBJECT : 'SUBJECT'; +SUBPARTITION : 'SUBPARTITION'; +SUBPARTITIONS : 'SUBPARTITIONS'; +SUSPEND : 'SUSPEND'; +SWAPS : 'SWAPS'; +SWITCHES : 'SWITCHES'; +TABLE_NAME : 'TABLE_NAME'; +TABLESPACE : 'TABLESPACE'; +TABLE_TYPE : 'TABLE_TYPE'; +TEMPORARY : 'TEMPORARY'; +TEMPTABLE : 'TEMPTABLE'; +THAN : 'THAN'; +TRADITIONAL : 'TRADITIONAL'; +TRANSACTION : 'TRANSACTION'; +TRANSACTIONAL : 'TRANSACTIONAL'; +TRIGGERS : 'TRIGGERS'; +TRUNCATE : 'TRUNCATE'; +TYPES : 'TYPES'; +UNBOUNDED : 'UNBOUNDED'; +UNDEFINED : 'UNDEFINED'; +UNDOFILE : 'UNDOFILE'; +UNDO_BUFFER_SIZE : 'UNDO_BUFFER_SIZE'; +UNINSTALL : 'UNINSTALL'; +UNKNOWN : 'UNKNOWN'; +UNTIL : 'UNTIL'; +UPGRADE : 'UPGRADE'; +USER : 'USER'; +USE_FRM : 'USE_FRM'; +USER_RESOURCES : 'USER_RESOURCES'; +VALIDATION : 'VALIDATION'; +VALUE : 'VALUE'; +VARIABLES : 'VARIABLES'; +VIEW : 'VIEW'; +VIRTUAL : 'VIRTUAL'; +VISIBLE : 'VISIBLE'; +WAIT : 'WAIT'; +WARNINGS : 'WARNINGS'; +WINDOW : 'WINDOW'; +WITHOUT : 'WITHOUT'; +WORK : 'WORK'; +WRAPPER : 'WRAPPER'; +WSREP_MEMBERSHIP : 'WSREP_MEMBERSHIP'; +WSREP_STATUS : 'WSREP_STATUS'; +X509 : 'X509'; +XA : 'XA'; +XML : 'XML'; +YES : 'YES'; // Date format Keywords -EUR: 'EUR'; -USA: 'USA'; -JIS: 'JIS'; -ISO: 'ISO'; -INTERNAL: 'INTERNAL'; - +EUR : 'EUR'; +USA : 'USA'; +JIS : 'JIS'; +ISO : 'ISO'; +INTERNAL : 'INTERNAL'; // Interval type Keywords -QUARTER: 'QUARTER'; -MONTH: 'MONTH'; -DAY: 'DAY'; -HOUR: 'HOUR'; -MINUTE: 'MINUTE'; -WEEK: 'WEEK'; -SECOND: 'SECOND'; -MICROSECOND: 'MICROSECOND'; - +QUARTER : 'QUARTER'; +MONTH : 'MONTH'; +DAY : 'DAY'; +HOUR : 'HOUR'; +MINUTE : 'MINUTE'; +WEEK : 'WEEK'; +SECOND : 'SECOND'; +MICROSECOND : 'MICROSECOND'; // userstat plugin Keywords -USER_STATISTICS: 'USER_STATISTICS'; -CLIENT_STATISTICS: 'CLIENT_STATISTICS'; -INDEX_STATISTICS: 'INDEX_STATISTICS'; -TABLE_STATISTICS: 'TABLE_STATISTICS'; - +USER_STATISTICS : 'USER_STATISTICS'; +CLIENT_STATISTICS : 'CLIENT_STATISTICS'; +INDEX_STATISTICS : 'INDEX_STATISTICS'; +TABLE_STATISTICS : 'TABLE_STATISTICS'; // PRIVILEGES -ADMIN: 'ADMIN'; -APPLICATION_PASSWORD_ADMIN: 'APPLICATION_PASSWORD_ADMIN'; -AUDIT_ADMIN: 'AUDIT_ADMIN'; -BACKUP_ADMIN: 'BACKUP_ADMIN'; -BINLOG_ADMIN: 'BINLOG_ADMIN'; -BINLOG_ENCRYPTION_ADMIN: 'BINLOG_ENCRYPTION_ADMIN'; -CLONE_ADMIN: 'CLONE_ADMIN'; -CONNECTION_ADMIN: 'CONNECTION_ADMIN'; -ENCRYPTION_KEY_ADMIN: 'ENCRYPTION_KEY_ADMIN'; -EXECUTE: 'EXECUTE'; -FILE: 'FILE'; -FIREWALL_ADMIN: 'FIREWALL_ADMIN'; -FIREWALL_USER: 'FIREWALL_USER'; -FLUSH_OPTIMIZER_COSTS: 'FLUSH_OPTIMIZER_COSTS'; -FLUSH_STATUS: 'FLUSH_STATUS'; -FLUSH_TABLES: 'FLUSH_TABLES'; -FLUSH_USER_RESOURCES: 'FLUSH_USER_RESOURCES'; -GROUP_REPLICATION_ADMIN: 'GROUP_REPLICATION_ADMIN'; -INNODB_REDO_LOG_ARCHIVE: 'INNODB_REDO_LOG_ARCHIVE'; -INNODB_REDO_LOG_ENABLE: 'INNODB_REDO_LOG_ENABLE'; -INVOKE: 'INVOKE'; -LAMBDA: 'LAMBDA'; -NDB_STORED_USER: 'NDB_STORED_USER'; -PASSWORDLESS_USER_ADMIN: 'PASSWORDLESS_USER_ADMIN'; -PERSIST_RO_VARIABLES_ADMIN: 'PERSIST_RO_VARIABLES_ADMIN'; -PRIVILEGES: 'PRIVILEGES'; -PROCESS: 'PROCESS'; -RELOAD: 'RELOAD'; -REPLICATION_APPLIER: 'REPLICATION_APPLIER'; -REPLICATION_SLAVE_ADMIN: 'REPLICATION_SLAVE_ADMIN'; -RESOURCE_GROUP_ADMIN: 'RESOURCE_GROUP_ADMIN'; -RESOURCE_GROUP_USER: 'RESOURCE_GROUP_USER'; -ROLE_ADMIN: 'ROLE_ADMIN'; -ROUTINE: 'ROUTINE'; -S3: 'S3'; -SERVICE_CONNECTION_ADMIN: 'SERVICE_CONNECTION_ADMIN'; -SESSION_VARIABLES_ADMIN: QUOTE_SYMB? 'SESSION_VARIABLES_ADMIN' QUOTE_SYMB?; -SET_USER_ID: 'SET_USER_ID'; -SHOW_ROUTINE: 'SHOW_ROUTINE'; -SHUTDOWN: 'SHUTDOWN'; -SUPER: 'SUPER'; -SYSTEM_VARIABLES_ADMIN: 'SYSTEM_VARIABLES_ADMIN'; -TABLES: 'TABLES'; -TABLE_ENCRYPTION_ADMIN: 'TABLE_ENCRYPTION_ADMIN'; -VERSION_TOKEN_ADMIN: 'VERSION_TOKEN_ADMIN'; -XA_RECOVER_ADMIN: 'XA_RECOVER_ADMIN'; - +ADMIN : 'ADMIN'; +APPLICATION_PASSWORD_ADMIN : 'APPLICATION_PASSWORD_ADMIN'; +AUDIT_ADMIN : 'AUDIT_ADMIN'; +BACKUP_ADMIN : 'BACKUP_ADMIN'; +BINLOG_ADMIN : 'BINLOG_ADMIN'; +BINLOG_ENCRYPTION_ADMIN : 'BINLOG_ENCRYPTION_ADMIN'; +CLONE_ADMIN : 'CLONE_ADMIN'; +CONNECTION_ADMIN : 'CONNECTION_ADMIN'; +ENCRYPTION_KEY_ADMIN : 'ENCRYPTION_KEY_ADMIN'; +EXECUTE : 'EXECUTE'; +FILE : 'FILE'; +FIREWALL_ADMIN : 'FIREWALL_ADMIN'; +FIREWALL_USER : 'FIREWALL_USER'; +FLUSH_OPTIMIZER_COSTS : 'FLUSH_OPTIMIZER_COSTS'; +FLUSH_STATUS : 'FLUSH_STATUS'; +FLUSH_TABLES : 'FLUSH_TABLES'; +FLUSH_USER_RESOURCES : 'FLUSH_USER_RESOURCES'; +GROUP_REPLICATION_ADMIN : 'GROUP_REPLICATION_ADMIN'; +INNODB_REDO_LOG_ARCHIVE : 'INNODB_REDO_LOG_ARCHIVE'; +INNODB_REDO_LOG_ENABLE : 'INNODB_REDO_LOG_ENABLE'; +INVOKE : 'INVOKE'; +LAMBDA : 'LAMBDA'; +NDB_STORED_USER : 'NDB_STORED_USER'; +PASSWORDLESS_USER_ADMIN : 'PASSWORDLESS_USER_ADMIN'; +PERSIST_RO_VARIABLES_ADMIN : 'PERSIST_RO_VARIABLES_ADMIN'; +PRIVILEGES : 'PRIVILEGES'; +PROCESS : 'PROCESS'; +RELOAD : 'RELOAD'; +REPLICATION_APPLIER : 'REPLICATION_APPLIER'; +REPLICATION_SLAVE_ADMIN : 'REPLICATION_SLAVE_ADMIN'; +RESOURCE_GROUP_ADMIN : 'RESOURCE_GROUP_ADMIN'; +RESOURCE_GROUP_USER : 'RESOURCE_GROUP_USER'; +ROLE_ADMIN : 'ROLE_ADMIN'; +ROUTINE : 'ROUTINE'; +S3 : 'S3'; +SERVICE_CONNECTION_ADMIN : 'SERVICE_CONNECTION_ADMIN'; +SESSION_VARIABLES_ADMIN : QUOTE_SYMB? 'SESSION_VARIABLES_ADMIN' QUOTE_SYMB?; +SET_USER_ID : 'SET_USER_ID'; +SHOW_ROUTINE : 'SHOW_ROUTINE'; +SHUTDOWN : 'SHUTDOWN'; +SUPER : 'SUPER'; +SYSTEM_VARIABLES_ADMIN : 'SYSTEM_VARIABLES_ADMIN'; +TABLES : 'TABLES'; +TABLE_ENCRYPTION_ADMIN : 'TABLE_ENCRYPTION_ADMIN'; +VERSION_TOKEN_ADMIN : 'VERSION_TOKEN_ADMIN'; +XA_RECOVER_ADMIN : 'XA_RECOVER_ADMIN'; // Charsets -ARMSCII8: 'ARMSCII8'; -ASCII: 'ASCII'; -BIG5: 'BIG5'; -CP1250: 'CP1250'; -CP1251: 'CP1251'; -CP1256: 'CP1256'; -CP1257: 'CP1257'; -CP850: 'CP850'; -CP852: 'CP852'; -CP866: 'CP866'; -CP932: 'CP932'; -DEC8: 'DEC8'; -EUCJPMS: 'EUCJPMS'; -EUCKR: 'EUCKR'; -GB18030: 'GB18030'; -GB2312: 'GB2312'; -GBK: 'GBK'; -GEOSTD8: 'GEOSTD8'; -GREEK: 'GREEK'; -HEBREW: 'HEBREW'; -HP8: 'HP8'; -KEYBCS2: 'KEYBCS2'; -KOI8R: 'KOI8R'; -KOI8U: 'KOI8U'; -LATIN1: 'LATIN1'; -LATIN2: 'LATIN2'; -LATIN5: 'LATIN5'; -LATIN7: 'LATIN7'; -MACCE: 'MACCE'; -MACROMAN: 'MACROMAN'; -SJIS: 'SJIS'; -SWE7: 'SWE7'; -TIS620: 'TIS620'; -UCS2: 'UCS2'; -UJIS: 'UJIS'; -UTF16: 'UTF16'; -UTF16LE: 'UTF16LE'; -UTF32: 'UTF32'; -UTF8: 'UTF8'; -UTF8MB3: 'UTF8MB3'; -UTF8MB4: 'UTF8MB4'; - +ARMSCII8 : 'ARMSCII8'; +ASCII : 'ASCII'; +BIG5 : 'BIG5'; +CP1250 : 'CP1250'; +CP1251 : 'CP1251'; +CP1256 : 'CP1256'; +CP1257 : 'CP1257'; +CP850 : 'CP850'; +CP852 : 'CP852'; +CP866 : 'CP866'; +CP932 : 'CP932'; +DEC8 : 'DEC8'; +EUCJPMS : 'EUCJPMS'; +EUCKR : 'EUCKR'; +GB18030 : 'GB18030'; +GB2312 : 'GB2312'; +GBK : 'GBK'; +GEOSTD8 : 'GEOSTD8'; +GREEK : 'GREEK'; +HEBREW : 'HEBREW'; +HP8 : 'HP8'; +KEYBCS2 : 'KEYBCS2'; +KOI8R : 'KOI8R'; +KOI8U : 'KOI8U'; +LATIN1 : 'LATIN1'; +LATIN2 : 'LATIN2'; +LATIN5 : 'LATIN5'; +LATIN7 : 'LATIN7'; +MACCE : 'MACCE'; +MACROMAN : 'MACROMAN'; +SJIS : 'SJIS'; +SWE7 : 'SWE7'; +TIS620 : 'TIS620'; +UCS2 : 'UCS2'; +UJIS : 'UJIS'; +UTF16 : 'UTF16'; +UTF16LE : 'UTF16LE'; +UTF32 : 'UTF32'; +UTF8 : 'UTF8'; +UTF8MB3 : 'UTF8MB3'; +UTF8MB4 : 'UTF8MB4'; // DB Engines -ARCHIVE: 'ARCHIVE'; -BLACKHOLE: 'BLACKHOLE'; -CSV: 'CSV'; -FEDERATED: 'FEDERATED'; -INNODB: 'INNODB'; -MEMORY: 'MEMORY'; -MRG_MYISAM: 'MRG_MYISAM'; -MYISAM: 'MYISAM'; -NDB: 'NDB'; -NDBCLUSTER: 'NDBCLUSTER'; -PERFORMANCE_SCHEMA: 'PERFORMANCE_SCHEMA'; -TOKUDB: 'TOKUDB'; - +ARCHIVE : 'ARCHIVE'; +BLACKHOLE : 'BLACKHOLE'; +CSV : 'CSV'; +FEDERATED : 'FEDERATED'; +INNODB : 'INNODB'; +MEMORY : 'MEMORY'; +MRG_MYISAM : 'MRG_MYISAM'; +MYISAM : 'MYISAM'; +NDB : 'NDB'; +NDBCLUSTER : 'NDBCLUSTER'; +PERFORMANCE_SCHEMA : 'PERFORMANCE_SCHEMA'; +TOKUDB : 'TOKUDB'; // Transaction Levels -REPEATABLE: 'REPEATABLE'; -COMMITTED: 'COMMITTED'; -UNCOMMITTED: 'UNCOMMITTED'; -SERIALIZABLE: 'SERIALIZABLE'; - +REPEATABLE : 'REPEATABLE'; +COMMITTED : 'COMMITTED'; +UNCOMMITTED : 'UNCOMMITTED'; +SERIALIZABLE : 'SERIALIZABLE'; // Spatial data types -GEOMETRYCOLLECTION: 'GEOMETRYCOLLECTION'; -GEOMCOLLECTION: 'GEOMCOLLECTION'; -GEOMETRY: 'GEOMETRY'; -LINESTRING: 'LINESTRING'; -MULTILINESTRING: 'MULTILINESTRING'; -MULTIPOINT: 'MULTIPOINT'; -MULTIPOLYGON: 'MULTIPOLYGON'; -POINT: 'POINT'; -POLYGON: 'POLYGON'; - +GEOMETRYCOLLECTION : 'GEOMETRYCOLLECTION'; +GEOMCOLLECTION : 'GEOMCOLLECTION'; +GEOMETRY : 'GEOMETRY'; +LINESTRING : 'LINESTRING'; +MULTILINESTRING : 'MULTILINESTRING'; +MULTIPOINT : 'MULTIPOINT'; +MULTIPOLYGON : 'MULTIPOLYGON'; +POINT : 'POINT'; +POLYGON : 'POLYGON'; // Common function names -ABS: 'ABS'; -ACOS: 'ACOS'; -ADDDATE: 'ADDDATE'; -ADDTIME: 'ADDTIME'; -AES_DECRYPT: 'AES_DECRYPT'; -AES_ENCRYPT: 'AES_ENCRYPT'; -AREA: 'AREA'; -ASBINARY: 'ASBINARY'; -ASIN: 'ASIN'; -ASTEXT: 'ASTEXT'; -ASWKB: 'ASWKB'; -ASWKT: 'ASWKT'; -ASYMMETRIC_DECRYPT: 'ASYMMETRIC_DECRYPT'; -ASYMMETRIC_DERIVE: 'ASYMMETRIC_DERIVE'; -ASYMMETRIC_ENCRYPT: 'ASYMMETRIC_ENCRYPT'; -ASYMMETRIC_SIGN: 'ASYMMETRIC_SIGN'; -ASYMMETRIC_VERIFY: 'ASYMMETRIC_VERIFY'; -ATAN: 'ATAN'; -ATAN2: 'ATAN2'; -BENCHMARK: 'BENCHMARK'; -BIN: 'BIN'; -BIT_COUNT: 'BIT_COUNT'; -BIT_LENGTH: 'BIT_LENGTH'; -BUFFER: 'BUFFER'; -CATALOG_NAME: 'CATALOG_NAME'; -CEIL: 'CEIL'; -CEILING: 'CEILING'; -CENTROID: 'CENTROID'; -CHARACTER_LENGTH: 'CHARACTER_LENGTH'; -CHARSET: 'CHARSET'; -CHAR_LENGTH: 'CHAR_LENGTH'; -COERCIBILITY: 'COERCIBILITY'; -COLLATION: 'COLLATION'; -COMPRESS: 'COMPRESS'; -CONCAT: 'CONCAT'; -CONCAT_WS: 'CONCAT_WS'; -CONNECTION_ID: 'CONNECTION_ID'; -CONV: 'CONV'; -CONVERT_TZ: 'CONVERT_TZ'; -COS: 'COS'; -COT: 'COT'; -CRC32: 'CRC32'; -CREATE_ASYMMETRIC_PRIV_KEY: 'CREATE_ASYMMETRIC_PRIV_KEY'; -CREATE_ASYMMETRIC_PUB_KEY: 'CREATE_ASYMMETRIC_PUB_KEY'; -CREATE_DH_PARAMETERS: 'CREATE_DH_PARAMETERS'; -CREATE_DIGEST: 'CREATE_DIGEST'; -CROSSES: 'CROSSES'; -DATEDIFF: 'DATEDIFF'; -DATE_FORMAT: 'DATE_FORMAT'; -DAYNAME: 'DAYNAME'; -DAYOFMONTH: 'DAYOFMONTH'; -DAYOFWEEK: 'DAYOFWEEK'; -DAYOFYEAR: 'DAYOFYEAR'; -DECODE: 'DECODE'; -DEGREES: 'DEGREES'; -DES_DECRYPT: 'DES_DECRYPT'; -DES_ENCRYPT: 'DES_ENCRYPT'; -DIMENSION: 'DIMENSION'; -DISJOINT: 'DISJOINT'; -ELT: 'ELT'; -ENCODE: 'ENCODE'; -ENCRYPT: 'ENCRYPT'; -ENDPOINT: 'ENDPOINT'; -ENGINE_ATTRIBUTE: 'ENGINE_ATTRIBUTE'; -ENVELOPE: 'ENVELOPE'; -EQUALS: 'EQUALS'; -EXP: 'EXP'; -EXPORT_SET: 'EXPORT_SET'; -EXTERIORRING: 'EXTERIORRING'; -EXTRACTVALUE: 'EXTRACTVALUE'; -FIELD: 'FIELD'; -FIND_IN_SET: 'FIND_IN_SET'; -FLOOR: 'FLOOR'; -FORMAT: 'FORMAT'; -FOUND_ROWS: 'FOUND_ROWS'; -FROM_BASE64: 'FROM_BASE64'; -FROM_DAYS: 'FROM_DAYS'; -FROM_UNIXTIME: 'FROM_UNIXTIME'; -GEOMCOLLFROMTEXT: 'GEOMCOLLFROMTEXT'; -GEOMCOLLFROMWKB: 'GEOMCOLLFROMWKB'; -GEOMETRYCOLLECTIONFROMTEXT: 'GEOMETRYCOLLECTIONFROMTEXT'; -GEOMETRYCOLLECTIONFROMWKB: 'GEOMETRYCOLLECTIONFROMWKB'; -GEOMETRYFROMTEXT: 'GEOMETRYFROMTEXT'; -GEOMETRYFROMWKB: 'GEOMETRYFROMWKB'; -GEOMETRYN: 'GEOMETRYN'; -GEOMETRYTYPE: 'GEOMETRYTYPE'; -GEOMFROMTEXT: 'GEOMFROMTEXT'; -GEOMFROMWKB: 'GEOMFROMWKB'; -GET_FORMAT: 'GET_FORMAT'; -GET_LOCK: 'GET_LOCK'; -GLENGTH: 'GLENGTH'; -GREATEST: 'GREATEST'; -GTID_SUBSET: 'GTID_SUBSET'; -GTID_SUBTRACT: 'GTID_SUBTRACT'; -HEX: 'HEX'; -IFNULL: 'IFNULL'; -INET6_ATON: 'INET6_ATON'; -INET6_NTOA: 'INET6_NTOA'; -INET_ATON: 'INET_ATON'; -INET_NTOA: 'INET_NTOA'; -INSTR: 'INSTR'; -INTERIORRINGN: 'INTERIORRINGN'; -INTERSECTS: 'INTERSECTS'; -ISCLOSED: 'ISCLOSED'; -ISEMPTY: 'ISEMPTY'; -ISNULL: 'ISNULL'; -ISSIMPLE: 'ISSIMPLE'; -IS_FREE_LOCK: 'IS_FREE_LOCK'; -IS_IPV4: 'IS_IPV4'; -IS_IPV4_COMPAT: 'IS_IPV4_COMPAT'; -IS_IPV4_MAPPED: 'IS_IPV4_MAPPED'; -IS_IPV6: 'IS_IPV6'; -IS_USED_LOCK: 'IS_USED_LOCK'; -LAST_INSERT_ID: 'LAST_INSERT_ID'; -LCASE: 'LCASE'; -LEAST: 'LEAST'; -LENGTH: 'LENGTH'; -LINEFROMTEXT: 'LINEFROMTEXT'; -LINEFROMWKB: 'LINEFROMWKB'; -LINESTRINGFROMTEXT: 'LINESTRINGFROMTEXT'; -LINESTRINGFROMWKB: 'LINESTRINGFROMWKB'; -LN: 'LN'; -LOAD_FILE: 'LOAD_FILE'; -LOCATE: 'LOCATE'; -LOG: 'LOG'; -LOG10: 'LOG10'; -LOG2: 'LOG2'; -LOWER: 'LOWER'; -LPAD: 'LPAD'; -LTRIM: 'LTRIM'; -MAKEDATE: 'MAKEDATE'; -MAKETIME: 'MAKETIME'; -MAKE_SET: 'MAKE_SET'; -MASTER_POS_WAIT: 'MASTER_POS_WAIT'; -MBRCONTAINS: 'MBRCONTAINS'; -MBRDISJOINT: 'MBRDISJOINT'; -MBREQUAL: 'MBREQUAL'; -MBRINTERSECTS: 'MBRINTERSECTS'; -MBROVERLAPS: 'MBROVERLAPS'; -MBRTOUCHES: 'MBRTOUCHES'; -MBRWITHIN: 'MBRWITHIN'; -MD5: 'MD5'; -MLINEFROMTEXT: 'MLINEFROMTEXT'; -MLINEFROMWKB: 'MLINEFROMWKB'; -MONTHNAME: 'MONTHNAME'; -MPOINTFROMTEXT: 'MPOINTFROMTEXT'; -MPOINTFROMWKB: 'MPOINTFROMWKB'; -MPOLYFROMTEXT: 'MPOLYFROMTEXT'; -MPOLYFROMWKB: 'MPOLYFROMWKB'; -MULTILINESTRINGFROMTEXT: 'MULTILINESTRINGFROMTEXT'; -MULTILINESTRINGFROMWKB: 'MULTILINESTRINGFROMWKB'; -MULTIPOINTFROMTEXT: 'MULTIPOINTFROMTEXT'; -MULTIPOINTFROMWKB: 'MULTIPOINTFROMWKB'; -MULTIPOLYGONFROMTEXT: 'MULTIPOLYGONFROMTEXT'; -MULTIPOLYGONFROMWKB: 'MULTIPOLYGONFROMWKB'; -NAME_CONST: 'NAME_CONST'; -NULLIF: 'NULLIF'; -NUMGEOMETRIES: 'NUMGEOMETRIES'; -NUMINTERIORRINGS: 'NUMINTERIORRINGS'; -NUMPOINTS: 'NUMPOINTS'; -OCT: 'OCT'; -OCTET_LENGTH: 'OCTET_LENGTH'; -ORD: 'ORD'; -OVERLAPS: 'OVERLAPS'; -PERIOD_ADD: 'PERIOD_ADD'; -PERIOD_DIFF: 'PERIOD_DIFF'; -PI: 'PI'; -POINTFROMTEXT: 'POINTFROMTEXT'; -POINTFROMWKB: 'POINTFROMWKB'; -POINTN: 'POINTN'; -POLYFROMTEXT: 'POLYFROMTEXT'; -POLYFROMWKB: 'POLYFROMWKB'; -POLYGONFROMTEXT: 'POLYGONFROMTEXT'; -POLYGONFROMWKB: 'POLYGONFROMWKB'; -POW: 'POW'; -POWER: 'POWER'; -QUOTE: 'QUOTE'; -RADIANS: 'RADIANS'; -RAND: 'RAND'; -RANDOM_BYTES: 'RANDOM_BYTES'; -RELEASE_LOCK: 'RELEASE_LOCK'; -REVERSE: 'REVERSE'; -ROUND: 'ROUND'; -ROW_COUNT: 'ROW_COUNT'; -RPAD: 'RPAD'; -RTRIM: 'RTRIM'; -SEC_TO_TIME: 'SEC_TO_TIME'; -SECONDARY_ENGINE_ATTRIBUTE: 'SECONDARY_ENGINE_ATTRIBUTE'; -SESSION_USER: 'SESSION_USER'; -SHA: 'SHA'; -SHA1: 'SHA1'; -SHA2: 'SHA2'; -SCHEMA_NAME: 'SCHEMA_NAME'; -SIGN: 'SIGN'; -SIN: 'SIN'; -SLEEP: 'SLEEP'; -SOUNDEX: 'SOUNDEX'; -SQL_THREAD_WAIT_AFTER_GTIDS: 'SQL_THREAD_WAIT_AFTER_GTIDS'; -SQRT: 'SQRT'; -SRID: 'SRID'; -STARTPOINT: 'STARTPOINT'; -STRCMP: 'STRCMP'; -STR_TO_DATE: 'STR_TO_DATE'; -ST_AREA: 'ST_AREA'; -ST_ASBINARY: 'ST_ASBINARY'; -ST_ASTEXT: 'ST_ASTEXT'; -ST_ASWKB: 'ST_ASWKB'; -ST_ASWKT: 'ST_ASWKT'; -ST_BUFFER: 'ST_BUFFER'; -ST_CENTROID: 'ST_CENTROID'; -ST_CONTAINS: 'ST_CONTAINS'; -ST_CROSSES: 'ST_CROSSES'; -ST_DIFFERENCE: 'ST_DIFFERENCE'; -ST_DIMENSION: 'ST_DIMENSION'; -ST_DISJOINT: 'ST_DISJOINT'; -ST_DISTANCE: 'ST_DISTANCE'; -ST_ENDPOINT: 'ST_ENDPOINT'; -ST_ENVELOPE: 'ST_ENVELOPE'; -ST_EQUALS: 'ST_EQUALS'; -ST_EXTERIORRING: 'ST_EXTERIORRING'; -ST_GEOMCOLLFROMTEXT: 'ST_GEOMCOLLFROMTEXT'; -ST_GEOMCOLLFROMTXT: 'ST_GEOMCOLLFROMTXT'; -ST_GEOMCOLLFROMWKB: 'ST_GEOMCOLLFROMWKB'; -ST_GEOMETRYCOLLECTIONFROMTEXT: 'ST_GEOMETRYCOLLECTIONFROMTEXT'; -ST_GEOMETRYCOLLECTIONFROMWKB: 'ST_GEOMETRYCOLLECTIONFROMWKB'; -ST_GEOMETRYFROMTEXT: 'ST_GEOMETRYFROMTEXT'; -ST_GEOMETRYFROMWKB: 'ST_GEOMETRYFROMWKB'; -ST_GEOMETRYN: 'ST_GEOMETRYN'; -ST_GEOMETRYTYPE: 'ST_GEOMETRYTYPE'; -ST_GEOMFROMTEXT: 'ST_GEOMFROMTEXT'; -ST_GEOMFROMWKB: 'ST_GEOMFROMWKB'; -ST_INTERIORRINGN: 'ST_INTERIORRINGN'; -ST_INTERSECTION: 'ST_INTERSECTION'; -ST_INTERSECTS: 'ST_INTERSECTS'; -ST_ISCLOSED: 'ST_ISCLOSED'; -ST_ISEMPTY: 'ST_ISEMPTY'; -ST_ISSIMPLE: 'ST_ISSIMPLE'; -ST_LINEFROMTEXT: 'ST_LINEFROMTEXT'; -ST_LINEFROMWKB: 'ST_LINEFROMWKB'; -ST_LINESTRINGFROMTEXT: 'ST_LINESTRINGFROMTEXT'; -ST_LINESTRINGFROMWKB: 'ST_LINESTRINGFROMWKB'; -ST_NUMGEOMETRIES: 'ST_NUMGEOMETRIES'; -ST_NUMINTERIORRING: 'ST_NUMINTERIORRING'; -ST_NUMINTERIORRINGS: 'ST_NUMINTERIORRINGS'; -ST_NUMPOINTS: 'ST_NUMPOINTS'; -ST_OVERLAPS: 'ST_OVERLAPS'; -ST_POINTFROMTEXT: 'ST_POINTFROMTEXT'; -ST_POINTFROMWKB: 'ST_POINTFROMWKB'; -ST_POINTN: 'ST_POINTN'; -ST_POLYFROMTEXT: 'ST_POLYFROMTEXT'; -ST_POLYFROMWKB: 'ST_POLYFROMWKB'; -ST_POLYGONFROMTEXT: 'ST_POLYGONFROMTEXT'; -ST_POLYGONFROMWKB: 'ST_POLYGONFROMWKB'; -ST_SRID: 'ST_SRID'; -ST_STARTPOINT: 'ST_STARTPOINT'; -ST_SYMDIFFERENCE: 'ST_SYMDIFFERENCE'; -ST_TOUCHES: 'ST_TOUCHES'; -ST_UNION: 'ST_UNION'; -ST_WITHIN: 'ST_WITHIN'; -ST_X: 'ST_X'; -ST_Y: 'ST_Y'; -SUBDATE: 'SUBDATE'; -SUBSTRING_INDEX: 'SUBSTRING_INDEX'; -SUBTIME: 'SUBTIME'; -SYSTEM_USER: 'SYSTEM_USER'; -TAN: 'TAN'; -TIMEDIFF: 'TIMEDIFF'; -TIMESTAMPADD: 'TIMESTAMPADD'; -TIMESTAMPDIFF: 'TIMESTAMPDIFF'; -TIME_FORMAT: 'TIME_FORMAT'; -TIME_TO_SEC: 'TIME_TO_SEC'; -TOUCHES: 'TOUCHES'; -TO_BASE64: 'TO_BASE64'; -TO_DAYS: 'TO_DAYS'; -TO_SECONDS: 'TO_SECONDS'; -UCASE: 'UCASE'; -UNCOMPRESS: 'UNCOMPRESS'; -UNCOMPRESSED_LENGTH: 'UNCOMPRESSED_LENGTH'; -UNHEX: 'UNHEX'; -UNIX_TIMESTAMP: 'UNIX_TIMESTAMP'; -UPDATEXML: 'UPDATEXML'; -UPPER: 'UPPER'; -UUID: 'UUID'; -UUID_SHORT: 'UUID_SHORT'; -VALIDATE_PASSWORD_STRENGTH: 'VALIDATE_PASSWORD_STRENGTH'; -VERSION: 'VERSION'; -WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS: 'WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS'; -WEEKDAY: 'WEEKDAY'; -WEEKOFYEAR: 'WEEKOFYEAR'; -WEIGHT_STRING: 'WEIGHT_STRING'; -WITHIN: 'WITHIN'; -YEARWEEK: 'YEARWEEK'; -Y_FUNCTION: 'Y'; -X_FUNCTION: 'X'; - +ABS : 'ABS'; +ACOS : 'ACOS'; +ADDDATE : 'ADDDATE'; +ADDTIME : 'ADDTIME'; +AES_DECRYPT : 'AES_DECRYPT'; +AES_ENCRYPT : 'AES_ENCRYPT'; +AREA : 'AREA'; +ASBINARY : 'ASBINARY'; +ASIN : 'ASIN'; +ASTEXT : 'ASTEXT'; +ASWKB : 'ASWKB'; +ASWKT : 'ASWKT'; +ASYMMETRIC_DECRYPT : 'ASYMMETRIC_DECRYPT'; +ASYMMETRIC_DERIVE : 'ASYMMETRIC_DERIVE'; +ASYMMETRIC_ENCRYPT : 'ASYMMETRIC_ENCRYPT'; +ASYMMETRIC_SIGN : 'ASYMMETRIC_SIGN'; +ASYMMETRIC_VERIFY : 'ASYMMETRIC_VERIFY'; +ATAN : 'ATAN'; +ATAN2 : 'ATAN2'; +BENCHMARK : 'BENCHMARK'; +BIN : 'BIN'; +BIT_COUNT : 'BIT_COUNT'; +BIT_LENGTH : 'BIT_LENGTH'; +BUFFER : 'BUFFER'; +CATALOG_NAME : 'CATALOG_NAME'; +CEIL : 'CEIL'; +CEILING : 'CEILING'; +CENTROID : 'CENTROID'; +CHARACTER_LENGTH : 'CHARACTER_LENGTH'; +CHARSET : 'CHARSET'; +CHAR_LENGTH : 'CHAR_LENGTH'; +COERCIBILITY : 'COERCIBILITY'; +COLLATION : 'COLLATION'; +COMPRESS : 'COMPRESS'; +CONCAT : 'CONCAT'; +CONCAT_WS : 'CONCAT_WS'; +CONNECTION_ID : 'CONNECTION_ID'; +CONV : 'CONV'; +CONVERT_TZ : 'CONVERT_TZ'; +COS : 'COS'; +COT : 'COT'; +CRC32 : 'CRC32'; +CREATE_ASYMMETRIC_PRIV_KEY : 'CREATE_ASYMMETRIC_PRIV_KEY'; +CREATE_ASYMMETRIC_PUB_KEY : 'CREATE_ASYMMETRIC_PUB_KEY'; +CREATE_DH_PARAMETERS : 'CREATE_DH_PARAMETERS'; +CREATE_DIGEST : 'CREATE_DIGEST'; +CROSSES : 'CROSSES'; +DATEDIFF : 'DATEDIFF'; +DATE_FORMAT : 'DATE_FORMAT'; +DAYNAME : 'DAYNAME'; +DAYOFMONTH : 'DAYOFMONTH'; +DAYOFWEEK : 'DAYOFWEEK'; +DAYOFYEAR : 'DAYOFYEAR'; +DECODE : 'DECODE'; +DEGREES : 'DEGREES'; +DES_DECRYPT : 'DES_DECRYPT'; +DES_ENCRYPT : 'DES_ENCRYPT'; +DIMENSION : 'DIMENSION'; +DISJOINT : 'DISJOINT'; +ELT : 'ELT'; +ENCODE : 'ENCODE'; +ENCRYPT : 'ENCRYPT'; +ENDPOINT : 'ENDPOINT'; +ENGINE_ATTRIBUTE : 'ENGINE_ATTRIBUTE'; +ENVELOPE : 'ENVELOPE'; +EQUALS : 'EQUALS'; +EXP : 'EXP'; +EXPORT_SET : 'EXPORT_SET'; +EXTERIORRING : 'EXTERIORRING'; +EXTRACTVALUE : 'EXTRACTVALUE'; +FIELD : 'FIELD'; +FIND_IN_SET : 'FIND_IN_SET'; +FLOOR : 'FLOOR'; +FORMAT : 'FORMAT'; +FOUND_ROWS : 'FOUND_ROWS'; +FROM_BASE64 : 'FROM_BASE64'; +FROM_DAYS : 'FROM_DAYS'; +FROM_UNIXTIME : 'FROM_UNIXTIME'; +GEOMCOLLFROMTEXT : 'GEOMCOLLFROMTEXT'; +GEOMCOLLFROMWKB : 'GEOMCOLLFROMWKB'; +GEOMETRYCOLLECTIONFROMTEXT : 'GEOMETRYCOLLECTIONFROMTEXT'; +GEOMETRYCOLLECTIONFROMWKB : 'GEOMETRYCOLLECTIONFROMWKB'; +GEOMETRYFROMTEXT : 'GEOMETRYFROMTEXT'; +GEOMETRYFROMWKB : 'GEOMETRYFROMWKB'; +GEOMETRYN : 'GEOMETRYN'; +GEOMETRYTYPE : 'GEOMETRYTYPE'; +GEOMFROMTEXT : 'GEOMFROMTEXT'; +GEOMFROMWKB : 'GEOMFROMWKB'; +GET_FORMAT : 'GET_FORMAT'; +GET_LOCK : 'GET_LOCK'; +GLENGTH : 'GLENGTH'; +GREATEST : 'GREATEST'; +GTID_SUBSET : 'GTID_SUBSET'; +GTID_SUBTRACT : 'GTID_SUBTRACT'; +HEX : 'HEX'; +IFNULL : 'IFNULL'; +INET6_ATON : 'INET6_ATON'; +INET6_NTOA : 'INET6_NTOA'; +INET_ATON : 'INET_ATON'; +INET_NTOA : 'INET_NTOA'; +INSTR : 'INSTR'; +INTERIORRINGN : 'INTERIORRINGN'; +INTERSECTS : 'INTERSECTS'; +ISCLOSED : 'ISCLOSED'; +ISEMPTY : 'ISEMPTY'; +ISNULL : 'ISNULL'; +ISSIMPLE : 'ISSIMPLE'; +IS_FREE_LOCK : 'IS_FREE_LOCK'; +IS_IPV4 : 'IS_IPV4'; +IS_IPV4_COMPAT : 'IS_IPV4_COMPAT'; +IS_IPV4_MAPPED : 'IS_IPV4_MAPPED'; +IS_IPV6 : 'IS_IPV6'; +IS_USED_LOCK : 'IS_USED_LOCK'; +LAST_INSERT_ID : 'LAST_INSERT_ID'; +LCASE : 'LCASE'; +LEAST : 'LEAST'; +LENGTH : 'LENGTH'; +LINEFROMTEXT : 'LINEFROMTEXT'; +LINEFROMWKB : 'LINEFROMWKB'; +LINESTRINGFROMTEXT : 'LINESTRINGFROMTEXT'; +LINESTRINGFROMWKB : 'LINESTRINGFROMWKB'; +LN : 'LN'; +LOAD_FILE : 'LOAD_FILE'; +LOCATE : 'LOCATE'; +LOG : 'LOG'; +LOG10 : 'LOG10'; +LOG2 : 'LOG2'; +LOWER : 'LOWER'; +LPAD : 'LPAD'; +LTRIM : 'LTRIM'; +MAKEDATE : 'MAKEDATE'; +MAKETIME : 'MAKETIME'; +MAKE_SET : 'MAKE_SET'; +MASTER_POS_WAIT : 'MASTER_POS_WAIT'; +MBRCONTAINS : 'MBRCONTAINS'; +MBRDISJOINT : 'MBRDISJOINT'; +MBREQUAL : 'MBREQUAL'; +MBRINTERSECTS : 'MBRINTERSECTS'; +MBROVERLAPS : 'MBROVERLAPS'; +MBRTOUCHES : 'MBRTOUCHES'; +MBRWITHIN : 'MBRWITHIN'; +MD5 : 'MD5'; +MLINEFROMTEXT : 'MLINEFROMTEXT'; +MLINEFROMWKB : 'MLINEFROMWKB'; +MONTHNAME : 'MONTHNAME'; +MPOINTFROMTEXT : 'MPOINTFROMTEXT'; +MPOINTFROMWKB : 'MPOINTFROMWKB'; +MPOLYFROMTEXT : 'MPOLYFROMTEXT'; +MPOLYFROMWKB : 'MPOLYFROMWKB'; +MULTILINESTRINGFROMTEXT : 'MULTILINESTRINGFROMTEXT'; +MULTILINESTRINGFROMWKB : 'MULTILINESTRINGFROMWKB'; +MULTIPOINTFROMTEXT : 'MULTIPOINTFROMTEXT'; +MULTIPOINTFROMWKB : 'MULTIPOINTFROMWKB'; +MULTIPOLYGONFROMTEXT : 'MULTIPOLYGONFROMTEXT'; +MULTIPOLYGONFROMWKB : 'MULTIPOLYGONFROMWKB'; +NAME_CONST : 'NAME_CONST'; +NULLIF : 'NULLIF'; +NUMGEOMETRIES : 'NUMGEOMETRIES'; +NUMINTERIORRINGS : 'NUMINTERIORRINGS'; +NUMPOINTS : 'NUMPOINTS'; +OCT : 'OCT'; +OCTET_LENGTH : 'OCTET_LENGTH'; +ORD : 'ORD'; +OVERLAPS : 'OVERLAPS'; +PERIOD_ADD : 'PERIOD_ADD'; +PERIOD_DIFF : 'PERIOD_DIFF'; +PI : 'PI'; +POINTFROMTEXT : 'POINTFROMTEXT'; +POINTFROMWKB : 'POINTFROMWKB'; +POINTN : 'POINTN'; +POLYFROMTEXT : 'POLYFROMTEXT'; +POLYFROMWKB : 'POLYFROMWKB'; +POLYGONFROMTEXT : 'POLYGONFROMTEXT'; +POLYGONFROMWKB : 'POLYGONFROMWKB'; +POW : 'POW'; +POWER : 'POWER'; +QUOTE : 'QUOTE'; +RADIANS : 'RADIANS'; +RAND : 'RAND'; +RANDOM_BYTES : 'RANDOM_BYTES'; +RELEASE_LOCK : 'RELEASE_LOCK'; +REVERSE : 'REVERSE'; +ROUND : 'ROUND'; +ROW_COUNT : 'ROW_COUNT'; +RPAD : 'RPAD'; +RTRIM : 'RTRIM'; +SEC_TO_TIME : 'SEC_TO_TIME'; +SECONDARY_ENGINE_ATTRIBUTE : 'SECONDARY_ENGINE_ATTRIBUTE'; +SESSION_USER : 'SESSION_USER'; +SHA : 'SHA'; +SHA1 : 'SHA1'; +SHA2 : 'SHA2'; +SCHEMA_NAME : 'SCHEMA_NAME'; +SIGN : 'SIGN'; +SIN : 'SIN'; +SLEEP : 'SLEEP'; +SOUNDEX : 'SOUNDEX'; +SQL_THREAD_WAIT_AFTER_GTIDS : 'SQL_THREAD_WAIT_AFTER_GTIDS'; +SQRT : 'SQRT'; +SRID : 'SRID'; +STARTPOINT : 'STARTPOINT'; +STRCMP : 'STRCMP'; +STR_TO_DATE : 'STR_TO_DATE'; +ST_AREA : 'ST_AREA'; +ST_ASBINARY : 'ST_ASBINARY'; +ST_ASTEXT : 'ST_ASTEXT'; +ST_ASWKB : 'ST_ASWKB'; +ST_ASWKT : 'ST_ASWKT'; +ST_BUFFER : 'ST_BUFFER'; +ST_CENTROID : 'ST_CENTROID'; +ST_CONTAINS : 'ST_CONTAINS'; +ST_CROSSES : 'ST_CROSSES'; +ST_DIFFERENCE : 'ST_DIFFERENCE'; +ST_DIMENSION : 'ST_DIMENSION'; +ST_DISJOINT : 'ST_DISJOINT'; +ST_DISTANCE : 'ST_DISTANCE'; +ST_ENDPOINT : 'ST_ENDPOINT'; +ST_ENVELOPE : 'ST_ENVELOPE'; +ST_EQUALS : 'ST_EQUALS'; +ST_EXTERIORRING : 'ST_EXTERIORRING'; +ST_GEOMCOLLFROMTEXT : 'ST_GEOMCOLLFROMTEXT'; +ST_GEOMCOLLFROMTXT : 'ST_GEOMCOLLFROMTXT'; +ST_GEOMCOLLFROMWKB : 'ST_GEOMCOLLFROMWKB'; +ST_GEOMETRYCOLLECTIONFROMTEXT : 'ST_GEOMETRYCOLLECTIONFROMTEXT'; +ST_GEOMETRYCOLLECTIONFROMWKB : 'ST_GEOMETRYCOLLECTIONFROMWKB'; +ST_GEOMETRYFROMTEXT : 'ST_GEOMETRYFROMTEXT'; +ST_GEOMETRYFROMWKB : 'ST_GEOMETRYFROMWKB'; +ST_GEOMETRYN : 'ST_GEOMETRYN'; +ST_GEOMETRYTYPE : 'ST_GEOMETRYTYPE'; +ST_GEOMFROMTEXT : 'ST_GEOMFROMTEXT'; +ST_GEOMFROMWKB : 'ST_GEOMFROMWKB'; +ST_INTERIORRINGN : 'ST_INTERIORRINGN'; +ST_INTERSECTION : 'ST_INTERSECTION'; +ST_INTERSECTS : 'ST_INTERSECTS'; +ST_ISCLOSED : 'ST_ISCLOSED'; +ST_ISEMPTY : 'ST_ISEMPTY'; +ST_ISSIMPLE : 'ST_ISSIMPLE'; +ST_LINEFROMTEXT : 'ST_LINEFROMTEXT'; +ST_LINEFROMWKB : 'ST_LINEFROMWKB'; +ST_LINESTRINGFROMTEXT : 'ST_LINESTRINGFROMTEXT'; +ST_LINESTRINGFROMWKB : 'ST_LINESTRINGFROMWKB'; +ST_NUMGEOMETRIES : 'ST_NUMGEOMETRIES'; +ST_NUMINTERIORRING : 'ST_NUMINTERIORRING'; +ST_NUMINTERIORRINGS : 'ST_NUMINTERIORRINGS'; +ST_NUMPOINTS : 'ST_NUMPOINTS'; +ST_OVERLAPS : 'ST_OVERLAPS'; +ST_POINTFROMTEXT : 'ST_POINTFROMTEXT'; +ST_POINTFROMWKB : 'ST_POINTFROMWKB'; +ST_POINTN : 'ST_POINTN'; +ST_POLYFROMTEXT : 'ST_POLYFROMTEXT'; +ST_POLYFROMWKB : 'ST_POLYFROMWKB'; +ST_POLYGONFROMTEXT : 'ST_POLYGONFROMTEXT'; +ST_POLYGONFROMWKB : 'ST_POLYGONFROMWKB'; +ST_SRID : 'ST_SRID'; +ST_STARTPOINT : 'ST_STARTPOINT'; +ST_SYMDIFFERENCE : 'ST_SYMDIFFERENCE'; +ST_TOUCHES : 'ST_TOUCHES'; +ST_UNION : 'ST_UNION'; +ST_WITHIN : 'ST_WITHIN'; +ST_X : 'ST_X'; +ST_Y : 'ST_Y'; +SUBDATE : 'SUBDATE'; +SUBSTRING_INDEX : 'SUBSTRING_INDEX'; +SUBTIME : 'SUBTIME'; +SYSTEM_USER : 'SYSTEM_USER'; +TAN : 'TAN'; +TIMEDIFF : 'TIMEDIFF'; +TIMESTAMPADD : 'TIMESTAMPADD'; +TIMESTAMPDIFF : 'TIMESTAMPDIFF'; +TIME_FORMAT : 'TIME_FORMAT'; +TIME_TO_SEC : 'TIME_TO_SEC'; +TOUCHES : 'TOUCHES'; +TO_BASE64 : 'TO_BASE64'; +TO_DAYS : 'TO_DAYS'; +TO_SECONDS : 'TO_SECONDS'; +UCASE : 'UCASE'; +UNCOMPRESS : 'UNCOMPRESS'; +UNCOMPRESSED_LENGTH : 'UNCOMPRESSED_LENGTH'; +UNHEX : 'UNHEX'; +UNIX_TIMESTAMP : 'UNIX_TIMESTAMP'; +UPDATEXML : 'UPDATEXML'; +UPPER : 'UPPER'; +UUID : 'UUID'; +UUID_SHORT : 'UUID_SHORT'; +VALIDATE_PASSWORD_STRENGTH : 'VALIDATE_PASSWORD_STRENGTH'; +VERSION : 'VERSION'; +WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS : 'WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS'; +WEEKDAY : 'WEEKDAY'; +WEEKOFYEAR : 'WEEKOFYEAR'; +WEIGHT_STRING : 'WEIGHT_STRING'; +WITHIN : 'WITHIN'; +YEARWEEK : 'YEARWEEK'; +Y_FUNCTION : 'Y'; +X_FUNCTION : 'X'; // MariaDB tokens -VIA: 'VIA'; -LASTVAL: 'LASTVAL'; -NEXTVAL: 'NEXTVAL'; -SETVAL: 'SETVAL'; -PREVIOUS: 'PREVIOUS'; -PERSISTENT: 'PERSISTENT'; // Same as STORED for MySQL -BINLOG_MONITOR: 'BINLOG_MONITOR'; -BINLOG_REPLAY: 'BINLOG_REPLAY'; -FEDERATED_ADMIN: 'FEDERATED_ADMIN'; -READ_ONLY_ADMIN: 'READ_ONLY_ADMIN'; -REPLICA: 'REPLICA'; -REPLICAS: 'REPLICAS'; -REPLICATION_MASTER_ADMIN: 'REPLICATION_MASTER_ADMIN'; -MONITOR: 'MONITOR'; -READ_ONLY: 'READ_ONLY'; -REPLAY: 'REPLAY'; +VIA : 'VIA'; +LASTVAL : 'LASTVAL'; +NEXTVAL : 'NEXTVAL'; +SETVAL : 'SETVAL'; +PREVIOUS : 'PREVIOUS'; +PERSISTENT : 'PERSISTENT'; // Same as STORED for MySQL +BINLOG_MONITOR : 'BINLOG_MONITOR'; +BINLOG_REPLAY : 'BINLOG_REPLAY'; +FEDERATED_ADMIN : 'FEDERATED_ADMIN'; +READ_ONLY_ADMIN : 'READ_ONLY_ADMIN'; +REPLICA : 'REPLICA'; +REPLICAS : 'REPLICAS'; +REPLICATION_MASTER_ADMIN : 'REPLICATION_MASTER_ADMIN'; +MONITOR : 'MONITOR'; +READ_ONLY : 'READ_ONLY'; +REPLAY : 'REPLAY'; // Operators // Operators. Assigns -VAR_ASSIGN: ':='; -PLUS_ASSIGN: '+='; -MINUS_ASSIGN: '-='; -MULT_ASSIGN: '*='; -DIV_ASSIGN: '/='; -MOD_ASSIGN: '%='; -AND_ASSIGN: '&='; -XOR_ASSIGN: '^='; -OR_ASSIGN: '|='; - +VAR_ASSIGN : ':='; +PLUS_ASSIGN : '+='; +MINUS_ASSIGN : '-='; +MULT_ASSIGN : '*='; +DIV_ASSIGN : '/='; +MOD_ASSIGN : '%='; +AND_ASSIGN : '&='; +XOR_ASSIGN : '^='; +OR_ASSIGN : '|='; // Operators. Arithmetics -STAR: '*'; -DIVIDE: '/'; -MODULE: '%'; -PLUS: '+'; -MINUS: '-'; -DIV: 'DIV'; -MOD: 'MOD'; - +STAR : '*'; +DIVIDE : '/'; +MODULE : '%'; +PLUS : '+'; +MINUS : '-'; +DIV : 'DIV'; +MOD : 'MOD'; // Operators. Comparation -EQUAL_SYMBOL: '='; -GREATER_SYMBOL: '>'; -LESS_SYMBOL: '<'; -EXCLAMATION_SYMBOL: '!'; - +EQUAL_SYMBOL : '='; +GREATER_SYMBOL : '>'; +LESS_SYMBOL : '<'; +EXCLAMATION_SYMBOL : '!'; // Operators. Bit -BIT_NOT_OP: '~'; -BIT_OR_OP: '|'; -BIT_AND_OP: '&'; -BIT_XOR_OP: '^'; - +BIT_NOT_OP : '~'; +BIT_OR_OP : '|'; +BIT_AND_OP : '&'; +BIT_XOR_OP : '^'; // Constructors symbols -DOT: '.'; -LR_BRACKET: '('; -RR_BRACKET: ')'; -COMMA: ','; -SEMI: ';'; -AT_SIGN: '@'; -ZERO_DECIMAL: '0'; -ONE_DECIMAL: '1'; -TWO_DECIMAL: '2'; -SINGLE_QUOTE_SYMB: '\''; -DOUBLE_QUOTE_SYMB: '"'; -REVERSE_QUOTE_SYMB: '`'; -COLON_SYMB: ':'; - -fragment QUOTE_SYMB - : SINGLE_QUOTE_SYMB | DOUBLE_QUOTE_SYMB | REVERSE_QUOTE_SYMB - ; - - +DOT : '.'; +LR_BRACKET : '('; +RR_BRACKET : ')'; +COMMA : ','; +SEMI : ';'; +AT_SIGN : '@'; +ZERO_DECIMAL : '0'; +ONE_DECIMAL : '1'; +TWO_DECIMAL : '2'; +SINGLE_QUOTE_SYMB : '\''; +DOUBLE_QUOTE_SYMB : '"'; +REVERSE_QUOTE_SYMB : '`'; +COLON_SYMB : ':'; + +fragment QUOTE_SYMB: SINGLE_QUOTE_SYMB | DOUBLE_QUOTE_SYMB | REVERSE_QUOTE_SYMB; // Charsets -CHARSET_REVERSE_QOUTE_STRING: '`' CHARSET_NAME '`'; - - +CHARSET_REVERSE_QOUTE_STRING: '`' CHARSET_NAME '`'; // File's sizes - -FILESIZE_LITERAL: DEC_DIGIT+ ('K'|'M'|'G'|'T'); - - +FILESIZE_LITERAL: DEC_DIGIT+ ('K' | 'M' | 'G' | 'T'); // Literal Primitives - -START_NATIONAL_STRING_LITERAL: 'N' SQUOTA_STRING; -STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING; -DECIMAL_LITERAL: DEC_DIGIT+; -HEXADECIMAL_LITERAL: 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\'' - | '0X' HEX_DIGIT+; - -REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+ - | DEC_DIGIT+ '.' EXPONENT_NUM_PART - | (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART) - | DEC_DIGIT+ EXPONENT_NUM_PART; -NULL_SPEC_LITERAL: '\\' 'N'; -BIT_STRING: BIT_STRING_L; -STRING_CHARSET_NAME: '_' CHARSET_NAME; - - - +START_NATIONAL_STRING_LITERAL : 'N' SQUOTA_STRING; +STRING_LITERAL : DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING; +DECIMAL_LITERAL : DEC_DIGIT+; +HEXADECIMAL_LITERAL : 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\'' | '0X' HEX_DIGIT+; + +REAL_LITERAL: + (DEC_DIGIT+)? '.' DEC_DIGIT+ + | DEC_DIGIT+ '.' EXPONENT_NUM_PART + | (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART) + | DEC_DIGIT+ EXPONENT_NUM_PART +; +NULL_SPEC_LITERAL : '\\' 'N'; +BIT_STRING : BIT_STRING_L; +STRING_CHARSET_NAME : '_' CHARSET_NAME; // Hack for dotID // Prevent recognize string: .123somelatin AS ((.123), FLOAT_LITERAL), ((somelatin), ID) // it must recoginze: .123somelatin AS ((.), DOT), (123somelatin, ID) -DOT_ID: '.' ID_LITERAL; - - +DOT_ID: '.' ID_LITERAL; // Identifiers -ID: ID_LITERAL; +ID: ID_LITERAL; // DOUBLE_QUOTE_ID: '"' ~'"'+ '"'; -REVERSE_QUOTE_ID: BQUOTA_STRING; -HOST_IP_ADDRESS: (AT_SIGN IP_ADDRESS); -LOCAL_ID: AT_SIGN - ( - STRING_LITERAL | [A-Z0-9._$\u0080-\uFFFF]+ - ); -GLOBAL_ID: AT_SIGN AT_SIGN - ( - [A-Z0-9._$\u0080-\uFFFF]+ | BQUOTA_STRING - ); - +REVERSE_QUOTE_ID : BQUOTA_STRING; +HOST_IP_ADDRESS : (AT_SIGN IP_ADDRESS); +LOCAL_ID : AT_SIGN ( STRING_LITERAL | [A-Z0-9._$\u0080-\uFFFF]+); +GLOBAL_ID : AT_SIGN AT_SIGN ( [A-Z0-9._$\u0080-\uFFFF]+ | BQUOTA_STRING); // Fragments for Literal primitives -fragment CHARSET_NAME: ARMSCII8 | ASCII | BIG5 | BINARY | CP1250 - | CP1251 | CP1256 | CP1257 | CP850 - | CP852 | CP866 | CP932 | DEC8 | EUCJPMS - | EUCKR | GB2312 | GBK | GEOSTD8 | GREEK - | HEBREW | HP8 | KEYBCS2 | KOI8R | KOI8U - | LATIN1 | LATIN2 | LATIN5 | LATIN7 - | MACCE | MACROMAN | SJIS | SWE7 | TIS620 - | UCS2 | UJIS | UTF16 | UTF16LE | UTF32 - | UTF8 | UTF8MB3 | UTF8MB4; - -fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+; -fragment ID_LITERAL: [A-Z_$0-9\u0080-\uFFFF]*?[A-Z_$\u0080-\uFFFF]+?[A-Z_$0-9\u0080-\uFFFF]*; -fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'; -fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''; -fragment BQUOTA_STRING: '`' ( ~'`' | '``' )* '`'; -fragment HEX_DIGIT: [0-9A-F]; -fragment DEC_DIGIT: [0-9]; -fragment BIT_STRING_L: 'B' '\'' [01]+ '\''; -fragment IP_ADDRESS: [0-9]+ '.' [0-9.]+ | [0-9A-F:]+ ':' [0-9A-F:]+; - +fragment CHARSET_NAME: + ARMSCII8 + | ASCII + | BIG5 + | BINARY + | CP1250 + | CP1251 + | CP1256 + | CP1257 + | CP850 + | CP852 + | CP866 + | CP932 + | DEC8 + | EUCJPMS + | EUCKR + | GB2312 + | GBK + | GEOSTD8 + | GREEK + | HEBREW + | HP8 + | KEYBCS2 + | KOI8R + | KOI8U + | LATIN1 + | LATIN2 + | LATIN5 + | LATIN7 + | MACCE + | MACROMAN + | SJIS + | SWE7 + | TIS620 + | UCS2 + | UJIS + | UTF16 + | UTF16LE + | UTF32 + | UTF8 + | UTF8MB3 + | UTF8MB4 +; + +fragment EXPONENT_NUM_PART : 'E' [-+]? DEC_DIGIT+; +fragment ID_LITERAL : [A-Z_$0-9\u0080-\uFFFF]*? [A-Z_$\u0080-\uFFFF]+? [A-Z_$0-9\u0080-\uFFFF]*; +fragment DQUOTA_STRING : '"' ( '\\' . | '""' | ~('"' | '\\'))* '"'; +fragment SQUOTA_STRING : '\'' ('\\' . | '\'\'' | ~('\'' | '\\'))* '\''; +fragment BQUOTA_STRING : '`' ( ~'`' | '``')* '`'; +fragment HEX_DIGIT : [0-9A-F]; +fragment DEC_DIGIT : [0-9]; +fragment BIT_STRING_L : 'B' '\'' [01]+ '\''; +fragment IP_ADDRESS : [0-9]+ '.' [0-9.]+ | [0-9A-F:]+ ':' [0-9A-F:]+; // Last tokens must generate Errors -ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL); +ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL); \ No newline at end of file diff --git a/sql/mariadb/MariaDBParser.g4 b/sql/mariadb/MariaDBParser.g4 index 949675a0e0..f70e4158e1 100644 --- a/sql/mariadb/MariaDBParser.g4 +++ b/sql/mariadb/MariaDBParser.g4 @@ -21,10 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -parser grammar MariaDBParser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab=MariaDBLexer; } +parser grammar MariaDBParser; +options { + tokenVocab = MariaDBLexer; +} // Top Level Description @@ -33,18 +37,26 @@ root ; sqlStatements - : (sqlStatement (MINUS MINUS)? SEMI? | emptyStatement_)* - (sqlStatement ((MINUS MINUS)? SEMI)? | emptyStatement_) + : (sqlStatement (MINUS MINUS)? SEMI? | emptyStatement_)* ( + sqlStatement ((MINUS MINUS)? SEMI)? + | emptyStatement_ + ) ; sqlStatement - : setStatementFor? (ddlStatement | dmlStatement | transactionStatement // setStatementFor is MariaDB-specific only - | replicationStatement | preparedStatement - | administrationStatement | utilityStatement) + : setStatementFor? ( + ddlStatement + | dmlStatement + | transactionStatement // setStatementFor is MariaDB-specific only + | replicationStatement + | preparedStatement + | administrationStatement + | utilityStatement + ) ; -setStatementFor // setStatementFor is MariaDB-specific only - :SET STATEMENT ID EQUAL_SYMBOL constant (COMMA ID EQUAL_SYMBOL constant)* FOR +setStatementFor // setStatementFor is MariaDB-specific only + : SET STATEMENT ID EQUAL_SYMBOL constant (COMMA ID EQUAL_SYMBOL constant)* FOR ; emptyStatement_ @@ -52,133 +64,203 @@ emptyStatement_ ; ddlStatement - : createDatabase | createEvent | createIndex - | createLogfileGroup | createProcedure | createFunction - | createServer | createTable | createTablespaceInnodb - | createTablespaceNdb | createTrigger | createView | createRole | createSequence - | alterDatabase | alterEvent | alterFunction - | alterInstance | alterLogfileGroup | alterProcedure - | alterServer | alterTable | alterTablespace | alterView | alterSequence - | dropDatabase | dropEvent | dropIndex - | dropLogfileGroup | dropProcedure | dropFunction - | dropServer | dropTable | dropTablespace - | dropTrigger | dropView | dropRole | dropSequence | setRole - | renameTable | truncateTable + : createDatabase + | createEvent + | createIndex + | createLogfileGroup + | createProcedure + | createFunction + | createServer + | createTable + | createTablespaceInnodb + | createTablespaceNdb + | createTrigger + | createView + | createRole + | createSequence + | alterDatabase + | alterEvent + | alterFunction + | alterInstance + | alterLogfileGroup + | alterProcedure + | alterServer + | alterTable + | alterTablespace + | alterView + | alterSequence + | dropDatabase + | dropEvent + | dropIndex + | dropLogfileGroup + | dropProcedure + | dropFunction + | dropServer + | dropTable + | dropTablespace + | dropTrigger + | dropView + | dropRole + | dropSequence + | setRole + | renameTable + | truncateTable ; dmlStatement - : selectStatement | insertStatement | updateStatement - | deleteStatement | replaceStatement | callStatement - | loadDataStatement | loadXmlStatement | doStatement - | handlerStatement | valuesStatement + : selectStatement + | insertStatement + | updateStatement + | deleteStatement + | replaceStatement + | callStatement + | loadDataStatement + | loadXmlStatement + | doStatement + | handlerStatement + | valuesStatement ; transactionStatement : startTransaction - | beginWork | commitWork | rollbackWork - | savepointStatement | rollbackStatement - | releaseStatement | lockTables | unlockTables + | beginWork + | commitWork + | rollbackWork + | savepointStatement + | rollbackStatement + | releaseStatement + | lockTables + | unlockTables ; replicationStatement - : changeMaster | changeReplicationFilter | purgeBinaryLogs - | resetMaster | resetSlave | startSlave | stopSlave - | startGroupReplication | stopGroupReplication - | xaStartTransaction | xaEndTransaction | xaPrepareStatement - | xaCommitWork | xaRollbackWork | xaRecoverWork + : changeMaster + | changeReplicationFilter + | purgeBinaryLogs + | resetMaster + | resetSlave + | startSlave + | stopSlave + | startGroupReplication + | stopGroupReplication + | xaStartTransaction + | xaEndTransaction + | xaPrepareStatement + | xaCommitWork + | xaRollbackWork + | xaRecoverWork ; preparedStatement - : prepareStatement | executeStatement | deallocatePrepare + : prepareStatement + | executeStatement + | deallocatePrepare ; // remark: NOT INCLUDED IN sqlStatement, but include in body // of routine's statements compoundStatement : blockStatement - | caseStatement | ifStatement | leaveStatement - | loopStatement | repeatStatement | whileStatement - | iterateStatement | returnStatement | cursorStatement + | caseStatement + | ifStatement + | leaveStatement + | loopStatement + | repeatStatement + | whileStatement + | iterateStatement + | returnStatement + | cursorStatement ; administrationStatement - : alterUser | createUser | dropUser | grantStatement - | grantProxy | renameUser | revokeStatement - | revokeProxy | analyzeTable | checkTable - | checksumTable | optimizeTable | repairTable - | createUdfunction | installPlugin | uninstallPlugin - | setStatement | showStatement | binlogStatement - | cacheIndexStatement | flushStatement | killStatement - | loadIndexIntoCache | resetStatement - | shutdownStatement | explainStatement + : alterUser + | createUser + | dropUser + | grantStatement + | grantProxy + | renameUser + | revokeStatement + | revokeProxy + | analyzeTable + | checkTable + | checksumTable + | optimizeTable + | repairTable + | createUdfunction + | installPlugin + | uninstallPlugin + | setStatement + | showStatement + | binlogStatement + | cacheIndexStatement + | flushStatement + | killStatement + | loadIndexIntoCache + | resetStatement + | shutdownStatement + | explainStatement ; utilityStatement - : simpleDescribeStatement | fullDescribeStatement - | helpStatement | useStatement | signalStatement - | resignalStatement | diagnosticsStatement + : simpleDescribeStatement + | fullDescribeStatement + | helpStatement + | useStatement + | signalStatement + | resignalStatement + | diagnosticsStatement ; - // Data Definition Language // Create statements createDatabase - : CREATE dbFormat=(DATABASE | SCHEMA) - ifNotExists? uid createDatabaseOption* // here ifNotExists is MariaDB-specific only + : CREATE dbFormat = (DATABASE | SCHEMA) ifNotExists? uid createDatabaseOption* // here ifNotExists is MariaDB-specific only ; createEvent - : CREATE ownerStatement? EVENT ifNotExists? fullId // here ifNotExists is MariaDB-specific only - ON SCHEDULE scheduleExpression - (ON COMPLETION NOT? PRESERVE)? enableType? - (COMMENT STRING_LITERAL)? - DO routineBody + : CREATE ownerStatement? EVENT ifNotExists? fullId // here ifNotExists is MariaDB-specific only + ON SCHEDULE scheduleExpression (ON COMPLETION NOT? PRESERVE)? enableType? ( + COMMENT STRING_LITERAL + )? DO routineBody ; createIndex - : CREATE orReplace? // here orReplace is MariaDB-specific only - intimeAction=(ONLINE | OFFLINE)? - indexCategory=(UNIQUE | FULLTEXT | SPATIAL)? INDEX - ifNotExists? // here ifNotExists is MariaDB-specific only - uid indexType? - ON tableName indexColumnNames - waitNowaitClause? // waitNowaitClause is MariaDB-specific only - indexOption* - ( - ALGORITHM EQUAL_SYMBOL? algType=(DEFAULT | INPLACE | COPY | NOCOPY | INSTANT) // NOCOPY, INSTANT are MariaDB-specific only - | LOCK EQUAL_SYMBOL? lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) - )* + : CREATE orReplace? // here orReplace is MariaDB-specific only + intimeAction = (ONLINE | OFFLINE)? indexCategory = (UNIQUE | FULLTEXT | SPATIAL)? INDEX ifNotExists? // here ifNotExists is MariaDB-specific only + uid indexType? ON tableName indexColumnNames waitNowaitClause? // waitNowaitClause is MariaDB-specific only + indexOption* ( + ALGORITHM EQUAL_SYMBOL? algType = ( + DEFAULT + | INPLACE + | COPY + | NOCOPY + | INSTANT + ) // NOCOPY, INSTANT are MariaDB-specific only + | LOCK EQUAL_SYMBOL? lockType = (DEFAULT | NONE | SHARED | EXCLUSIVE) + )* ; createLogfileGroup - : CREATE LOGFILE GROUP uid - ADD UNDOFILE undoFile=STRING_LITERAL - (INITIAL_SIZE '='? initSize=fileSizeLiteral)? - (UNDO_BUFFER_SIZE '='? undoSize=fileSizeLiteral)? - (REDO_BUFFER_SIZE '='? redoSize=fileSizeLiteral)? - (NODEGROUP '='? uid)? - WAIT? - (COMMENT '='? comment=STRING_LITERAL)? - ENGINE '='? engineName + : CREATE LOGFILE GROUP uid ADD UNDOFILE undoFile = STRING_LITERAL ( + INITIAL_SIZE '='? initSize = fileSizeLiteral + )? (UNDO_BUFFER_SIZE '='? undoSize = fileSizeLiteral)? ( + REDO_BUFFER_SIZE '='? redoSize = fileSizeLiteral + )? (NODEGROUP '='? uid)? WAIT? (COMMENT '='? comment = STRING_LITERAL)? ENGINE '='? engineName ; createProcedure - : CREATE orReplace? ownerStatement? // here orReplace is MariaDB-specific only - PROCEDURE fullId - '(' procedureParameter? (',' procedureParameter)* ')' - routineOption* - routineBody + : CREATE orReplace? ownerStatement? // here orReplace is MariaDB-specific only + PROCEDURE fullId '(' procedureParameter? (',' procedureParameter)* ')' routineOption* routineBody ; createFunction - : CREATE orReplace? ownerStatement? AGGREGATE? // here orReplace is MariaDB-specific only - FUNCTION ifNotExists? fullId - '(' functionParameter? (',' functionParameter)* ')' - RETURNS dataType - routineOption* - (routineBody | returnStatement) + : CREATE orReplace? ownerStatement? AGGREGATE? // here orReplace is MariaDB-specific only + FUNCTION ifNotExists? fullId '(' functionParameter? (',' functionParameter)* ')' RETURNS dataType routineOption* ( + routineBody + | returnStatement + ) ; createRole @@ -186,58 +268,46 @@ createRole ; createServer - : CREATE SERVER uid - FOREIGN DATA WRAPPER wrapperName=(MYSQL | STRING_LITERAL) - OPTIONS '(' serverOption (',' serverOption)* ')' + : CREATE SERVER uid FOREIGN DATA WRAPPER wrapperName = (MYSQL | STRING_LITERAL) OPTIONS '(' serverOption ( + ',' serverOption + )* ')' ; createTable - : CREATE orReplace? TEMPORARY? TABLE ifNotExists? // here orReplace is MariaDB-specific only - tableName - ( - LIKE tableName - | '(' LIKE parenthesisTable=tableName ')' - ) #copyCreateTable - | CREATE orReplace? TEMPORARY? TABLE ifNotExists? // here orReplace is MariaDB-specific only - tableName createDefinitions? - ( tableOption (','? tableOption)* )? - partitionDefinitions? keyViolate=(IGNORE | REPLACE)? - AS? selectStatement #queryCreateTable - | CREATE orReplace? TEMPORARY? TABLE ifNotExists? // here orReplace is MariaDB-specific only - tableName createDefinitions - ( tableOption (','? tableOption)* )? - partitionDefinitions? #columnCreateTable + : CREATE orReplace? TEMPORARY? TABLE ifNotExists? // here orReplace is MariaDB-specific only + tableName (LIKE tableName | '(' LIKE parenthesisTable = tableName ')') # copyCreateTable + | CREATE orReplace? TEMPORARY? TABLE ifNotExists? // here orReplace is MariaDB-specific only + tableName createDefinitions? (tableOption (','? tableOption)*)? partitionDefinitions? keyViolate = ( + IGNORE + | REPLACE + )? AS? selectStatement # queryCreateTable + | CREATE orReplace? TEMPORARY? TABLE ifNotExists? // here orReplace is MariaDB-specific only + tableName createDefinitions (tableOption (','? tableOption)*)? partitionDefinitions? # columnCreateTable ; createTablespaceInnodb - : CREATE TABLESPACE uid - ADD DATAFILE datafile=STRING_LITERAL - (FILE_BLOCK_SIZE '=' fileBlockSize=fileSizeLiteral)? - (ENGINE '='? engineName)? + : CREATE TABLESPACE uid ADD DATAFILE datafile = STRING_LITERAL ( + FILE_BLOCK_SIZE '=' fileBlockSize = fileSizeLiteral + )? (ENGINE '='? engineName)? ; createTablespaceNdb - : CREATE TABLESPACE uid - ADD DATAFILE datafile=STRING_LITERAL - USE LOGFILE GROUP uid - (EXTENT_SIZE '='? extentSize=fileSizeLiteral)? - (INITIAL_SIZE '='? initialSize=fileSizeLiteral)? - (AUTOEXTEND_SIZE '='? autoextendSize=fileSizeLiteral)? - (MAX_SIZE '='? maxSize=fileSizeLiteral)? - (NODEGROUP '='? uid)? - WAIT? - (COMMENT '='? comment=STRING_LITERAL)? - ENGINE '='? engineName + : CREATE TABLESPACE uid ADD DATAFILE datafile = STRING_LITERAL USE LOGFILE GROUP uid ( + EXTENT_SIZE '='? extentSize = fileSizeLiteral + )? (INITIAL_SIZE '='? initialSize = fileSizeLiteral)? ( + AUTOEXTEND_SIZE '='? autoextendSize = fileSizeLiteral + )? (MAX_SIZE '='? maxSize = fileSizeLiteral)? (NODEGROUP '='? uid)? WAIT? ( + COMMENT '='? comment = STRING_LITERAL + )? ENGINE '='? engineName ; createTrigger - : CREATE orReplace? ownerStatement? // here orReplace is MariaDB-specific only - TRIGGER thisTrigger=fullId - triggerTime=(BEFORE | AFTER) - triggerEvent=(INSERT | UPDATE | DELETE) - ON tableName FOR EACH ROW - (triggerPlace=(FOLLOWS | PRECEDES) otherTrigger=fullId)? - routineBody + : CREATE orReplace? ownerStatement? // here orReplace is MariaDB-specific only + TRIGGER thisTrigger = fullId triggerTime = (BEFORE | AFTER) triggerEvent = ( + INSERT + | UPDATE + | DELETE + ) ON tableName FOR EACH ROW (triggerPlace = (FOLLOWS | PRECEDES) otherTrigger = fullId)? routineBody ; withClause @@ -245,8 +315,9 @@ withClause ; commonTableExpressions - : cteName ('(' cteColumnName (',' cteColumnName)* ')')? AS '(' dmlStatement ')' - (',' commonTableExpressions)? + : cteName ('(' cteColumnName (',' cteColumnName)* ')')? AS '(' dmlStatement ')' ( + ',' commonTableExpressions + )? ; cteName @@ -258,23 +329,17 @@ cteColumnName ; createView - : CREATE orReplace? - ( - ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE) - )? - ownerStatement? - (SQL SECURITY secContext=(DEFINER | INVOKER))? - VIEW fullId ('(' uidList ')')? AS - ( + : CREATE orReplace? (ALGORITHM '=' algType = (UNDEFINED | MERGE | TEMPTABLE))? ownerStatement? ( + SQL SECURITY secContext = (DEFINER | INVOKER) + )? VIEW fullId ('(' uidList ')')? AS ( '(' withClause? selectStatement ')' - | - withClause? selectStatement (WITH checkOption=(CASCADED | LOCAL)? CHECK OPTION)? - ) + | withClause? selectStatement (WITH checkOption = (CASCADED | LOCAL)? CHECK OPTION)? + ) ; -createSequence // sequence is MariaDB-specific only - : CREATE orReplace? TEMPORARY? SEQUENCE ifNotExists? fullId // here orReplace is MariaDB-specific only - (sequenceSpec | tableOption)* +createSequence // sequence is MariaDB-specific only + : CREATE orReplace? TEMPORARY? SEQUENCE ifNotExists? fullId // here orReplace is MariaDB-specific only + (sequenceSpec | tableOption)* ; sequenceSpec @@ -309,24 +374,22 @@ charSet ; currentUserExpression - : CURRENT_USER ( '(' ')')? + : CURRENT_USER ('(' ')')? ; ownerStatement - : DEFINER '=' (userName | currentUserExpression | CURRENT_ROLE) // CURRENT_ROLE is MariaDB-specific only + : DEFINER '=' ( + userName + | currentUserExpression + | CURRENT_ROLE + ) // CURRENT_ROLE is MariaDB-specific only ; scheduleExpression - : AT timestampValue intervalExpr* #preciseSchedule - | EVERY (decimalLiteral | expression) intervalType - ( - STARTS startTimestamp=timestampValue - (startIntervals+=intervalExpr)* - )? - ( - ENDS endTimestamp=timestampValue - (endIntervals+=intervalExpr)* - )? #intervalSchedule + : AT timestampValue intervalExpr* # preciseSchedule + | EVERY (decimalLiteral | expression) intervalType ( + STARTS startTimestamp = timestampValue (startIntervals += intervalExpr)* + )? (ENDS endTimestamp = timestampValue (endIntervals += intervalExpr)*)? # intervalSchedule ; timestampValue @@ -342,18 +405,28 @@ intervalExpr intervalType : intervalTypeBase - | YEAR | YEAR_MONTH | DAY_HOUR | DAY_MINUTE - | DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND - | SECOND_MICROSECOND | MINUTE_MICROSECOND - | HOUR_MICROSECOND | DAY_MICROSECOND + | YEAR + | YEAR_MONTH + | DAY_HOUR + | DAY_MINUTE + | DAY_SECOND + | HOUR_MINUTE + | HOUR_SECOND + | MINUTE_SECOND + | SECOND_MICROSECOND + | MINUTE_MICROSECOND + | HOUR_MICROSECOND + | DAY_MICROSECOND ; enableType - : ENABLE | DISABLE | DISABLE ON SLAVE + : ENABLE + | DISABLE + | DISABLE ON SLAVE ; indexType - : USING (BTREE | HASH | RTREE) // RTREE is MariaDB-specific only + : USING (BTREE | HASH | RTREE) // RTREE is MariaDB-specific only ; indexOption @@ -364,12 +437,12 @@ indexOption | (VISIBLE | INVISIBLE) | ENGINE_ATTRIBUTE EQUAL_SYMBOL? STRING_LITERAL | SECONDARY_ENGINE_ATTRIBUTE EQUAL_SYMBOL? STRING_LITERAL - | CLUSTERING EQUAL_SYMBOL (YES | NO) // MariaDB-specific only - | (IGNORED | NOT IGNORED) // MariaDB-specific only + | CLUSTERING EQUAL_SYMBOL (YES | NO) // MariaDB-specific only + | (IGNORED | NOT IGNORED) // MariaDB-specific only ; procedureParameter - : direction=(IN | OUT | INOUT)? uid dataType + : direction = (IN | OUT | INOUT)? uid dataType ; functionParameter @@ -377,14 +450,11 @@ functionParameter ; routineOption - : COMMENT STRING_LITERAL #routineComment - | LANGUAGE SQL #routineLanguage - | NOT? DETERMINISTIC #routineBehavior - | ( - CONTAINS SQL | NO SQL | READS SQL DATA - | MODIFIES SQL DATA - ) #routineData - | SQL SECURITY context=(DEFINER | INVOKER) #routineSecurity + : COMMENT STRING_LITERAL # routineComment + | LANGUAGE SQL # routineLanguage + | NOT? DETERMINISTIC # routineBehavior + | ( CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA) # routineData + | SQL SECURITY context = (DEFINER | INVOKER) # routineSecurity ; serverOption @@ -402,9 +472,9 @@ createDefinitions ; createDefinition - : uid columnDefinition #columnDeclaration - | tableConstraint #constraintDeclaration - | indexColumnDefinition #indexDeclaration + : uid columnDefinition # columnDeclaration + | tableConstraint # constraintDeclaration + | indexColumnDefinition # indexDeclaration ; columnDefinition @@ -412,112 +482,101 @@ columnDefinition ; columnConstraint - : nullNotnull #nullColumnConstraint - | DEFAULT defaultValue #defaultColumnConstraint - | VISIBLE #visibilityColumnConstraint - | INVISIBLE #invisibilityColumnConstraint - | (AUTO_INCREMENT | ON UPDATE currentTimestamp) #autoIncrementColumnConstraint - | PRIMARY? KEY #primaryKeyColumnConstraint - | UNIQUE KEY? #uniqueKeyColumnConstraint - | COMMENT STRING_LITERAL #commentColumnConstraint - | COLUMN_FORMAT colformat=(FIXED | DYNAMIC | DEFAULT) #formatColumnConstraint - | STORAGE storageval=(DISK | MEMORY | DEFAULT) #storageColumnConstraint - | referenceDefinition #referenceColumnConstraint - | COLLATE collationName #collateColumnConstraint - | (GENERATED ALWAYS)? AS '(' expression ')' (VIRTUAL | STORED | PERSISTENT)? #generatedColumnConstraint - | SERIAL DEFAULT VALUE #serialDefaultColumnConstraint - | (CONSTRAINT name=uid?)? - CHECK '(' expression ')' #checkColumnConstraint + : nullNotnull # nullColumnConstraint + | DEFAULT defaultValue # defaultColumnConstraint + | VISIBLE # visibilityColumnConstraint + | INVISIBLE # invisibilityColumnConstraint + | (AUTO_INCREMENT | ON UPDATE currentTimestamp) # autoIncrementColumnConstraint + | PRIMARY? KEY # primaryKeyColumnConstraint + | UNIQUE KEY? # uniqueKeyColumnConstraint + | COMMENT STRING_LITERAL # commentColumnConstraint + | COLUMN_FORMAT colformat = (FIXED | DYNAMIC | DEFAULT) # formatColumnConstraint + | STORAGE storageval = (DISK | MEMORY | DEFAULT) # storageColumnConstraint + | referenceDefinition # referenceColumnConstraint + | COLLATE collationName # collateColumnConstraint + | (GENERATED ALWAYS)? AS '(' expression ')' (VIRTUAL | STORED | PERSISTENT)? # generatedColumnConstraint + | SERIAL DEFAULT VALUE # serialDefaultColumnConstraint + | (CONSTRAINT name = uid?)? CHECK '(' expression ')' # checkColumnConstraint ; tableConstraint - : (CONSTRAINT name=uid?)? - PRIMARY KEY index=uid? indexType? - indexColumnNames indexOption* #primaryKeyTableConstraint - | (CONSTRAINT name=uid?)? - UNIQUE indexFormat=(INDEX | KEY)? index=uid? - indexType? indexColumnNames indexOption* #uniqueKeyTableConstraint - | (CONSTRAINT name=uid?)? - FOREIGN KEY index=uid? indexColumnNames - referenceDefinition #foreignKeyTableConstraint - | (CONSTRAINT name=uid?)? - CHECK '(' expression ')' #checkTableConstraint + : (CONSTRAINT name = uid?)? PRIMARY KEY index = uid? indexType? indexColumnNames indexOption* # primaryKeyTableConstraint + | (CONSTRAINT name = uid?)? UNIQUE indexFormat = (INDEX | KEY)? index = uid? indexType? indexColumnNames indexOption* # uniqueKeyTableConstraint + | (CONSTRAINT name = uid?)? FOREIGN KEY index = uid? indexColumnNames referenceDefinition # foreignKeyTableConstraint + | (CONSTRAINT name = uid?)? CHECK '(' expression ')' # checkTableConstraint ; referenceDefinition - : REFERENCES tableName indexColumnNames? - (MATCH matchType=(FULL | PARTIAL | SIMPLE))? - referenceAction? + : REFERENCES tableName indexColumnNames? (MATCH matchType = (FULL | PARTIAL | SIMPLE))? referenceAction? ; referenceAction - : ON DELETE onDelete=referenceControlType - ( - ON UPDATE onUpdate=referenceControlType - )? - | ON UPDATE onUpdate=referenceControlType - ( - ON DELETE onDelete=referenceControlType - )? + : ON DELETE onDelete = referenceControlType (ON UPDATE onUpdate = referenceControlType)? + | ON UPDATE onUpdate = referenceControlType (ON DELETE onDelete = referenceControlType)? ; referenceControlType - : RESTRICT | CASCADE | SET NULL_LITERAL | NO ACTION + : RESTRICT + | CASCADE + | SET NULL_LITERAL + | NO ACTION ; indexColumnDefinition - : indexFormat=(INDEX | KEY) uid? indexType? - indexColumnNames indexOption* #simpleIndexDeclaration - | (FULLTEXT | SPATIAL) - indexFormat=(INDEX | KEY)? uid? - indexColumnNames indexOption* #specialIndexDeclaration + : indexFormat = (INDEX | KEY) uid? indexType? indexColumnNames indexOption* # simpleIndexDeclaration + | (FULLTEXT | SPATIAL) indexFormat = (INDEX | KEY)? uid? indexColumnNames indexOption* # specialIndexDeclaration ; tableOption - : ENGINE '='? engineName? #tableOptionEngine - | ENGINE_ATTRIBUTE '='? STRING_LITERAL #tableOptionEngineAttribute - | AUTOEXTEND_SIZE '='? decimalLiteral #tableOptionAutoextendSize - | AUTO_INCREMENT '='? decimalLiteral #tableOptionAutoIncrement - | AVG_ROW_LENGTH '='? decimalLiteral #tableOptionAverage - | DEFAULT? charSet '='? (charsetName|DEFAULT) #tableOptionCharset - | (CHECKSUM | PAGE_CHECKSUM) '='? boolValue=('0' | '1') #tableOptionChecksum - | DEFAULT? COLLATE '='? collationName #tableOptionCollate - | COMMENT '='? STRING_LITERAL #tableOptionComment - | COMPRESSION '='? (STRING_LITERAL | ID) #tableOptionCompression - | CONNECTION '='? STRING_LITERAL #tableOptionConnection - | (DATA | INDEX) DIRECTORY '='? STRING_LITERAL #tableOptionDataDirectory - | DELAY_KEY_WRITE '='? boolValue=('0' | '1') #tableOptionDelay - | ENCRYPTION '='? STRING_LITERAL #tableOptionEncryption - | encryptedLiteral '='? (YES | NO) #tableOptionEncrypted - | (PAGE_COMPRESSED | STRING_LITERAL) '='? ('0' | '1') #tableOptionPageCompressed - | (PAGE_COMPRESSION_LEVEL | STRING_LITERAL) '='? decimalLiteral #tableOptionPageCompressionLevel - | ENCRYPTION_KEY_ID '='? decimalLiteral #tableOptionEncryptionKeyId - | INDEX DIRECTORY '='? STRING_LITERAL #tableOptionIndexDirectory - | INSERT_METHOD '='? insertMethod=(NO | FIRST | LAST) #tableOptionInsertMethod - | KEY_BLOCK_SIZE '='? fileSizeLiteral #tableOptionKeyBlockSize - | MAX_ROWS '='? decimalLiteral #tableOptionMaxRows - | MIN_ROWS '='? decimalLiteral #tableOptionMinRows - | PACK_KEYS '='? extBoolValue=('0' | '1' | DEFAULT) #tableOptionPackKeys - | PASSWORD '='? STRING_LITERAL #tableOptionPassword - | ROW_FORMAT '='? - rowFormat=( - DEFAULT | DYNAMIC | FIXED | COMPRESSED - | REDUNDANT | COMPACT | ID - ) #tableOptionRowFormat - | START TRANSACTION #tableOptionStartTransaction - | SECONDARY_ENGINE_ATTRIBUTE '='? STRING_LITERAL #tableOptionSecondaryEngineAttribute - | STATS_AUTO_RECALC '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionRecalculation - | STATS_PERSISTENT '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionPersistent - | STATS_SAMPLE_PAGES '='? (DEFAULT | decimalLiteral) #tableOptionSamplePage - | TABLESPACE uid tablespaceStorage? #tableOptionTablespace - | TABLE_TYPE '=' tableType #tableOptionTableType - | tablespaceStorage #tableOptionTablespace - | TRANSACTIONAL '='? ('0' | '1') #tableOptionTransactional - | UNION '='? '(' tables ')' #tableOptionUnion + : ENGINE '='? engineName? # tableOptionEngine + | ENGINE_ATTRIBUTE '='? STRING_LITERAL # tableOptionEngineAttribute + | AUTOEXTEND_SIZE '='? decimalLiteral # tableOptionAutoextendSize + | AUTO_INCREMENT '='? decimalLiteral # tableOptionAutoIncrement + | AVG_ROW_LENGTH '='? decimalLiteral # tableOptionAverage + | DEFAULT? charSet '='? (charsetName | DEFAULT) # tableOptionCharset + | (CHECKSUM | PAGE_CHECKSUM) '='? boolValue = ('0' | '1') # tableOptionChecksum + | DEFAULT? COLLATE '='? collationName # tableOptionCollate + | COMMENT '='? STRING_LITERAL # tableOptionComment + | COMPRESSION '='? (STRING_LITERAL | ID) # tableOptionCompression + | CONNECTION '='? STRING_LITERAL # tableOptionConnection + | (DATA | INDEX) DIRECTORY '='? STRING_LITERAL # tableOptionDataDirectory + | DELAY_KEY_WRITE '='? boolValue = ('0' | '1') # tableOptionDelay + | ENCRYPTION '='? STRING_LITERAL # tableOptionEncryption + | encryptedLiteral '='? (YES | NO) # tableOptionEncrypted + | (PAGE_COMPRESSED | STRING_LITERAL) '='? ('0' | '1') # tableOptionPageCompressed + | (PAGE_COMPRESSION_LEVEL | STRING_LITERAL) '='? decimalLiteral # tableOptionPageCompressionLevel + | ENCRYPTION_KEY_ID '='? decimalLiteral # tableOptionEncryptionKeyId + | INDEX DIRECTORY '='? STRING_LITERAL # tableOptionIndexDirectory + | INSERT_METHOD '='? insertMethod = (NO | FIRST | LAST) # tableOptionInsertMethod + | KEY_BLOCK_SIZE '='? fileSizeLiteral # tableOptionKeyBlockSize + | MAX_ROWS '='? decimalLiteral # tableOptionMaxRows + | MIN_ROWS '='? decimalLiteral # tableOptionMinRows + | PACK_KEYS '='? extBoolValue = ('0' | '1' | DEFAULT) # tableOptionPackKeys + | PASSWORD '='? STRING_LITERAL # tableOptionPassword + | ROW_FORMAT '='? rowFormat = ( + DEFAULT + | DYNAMIC + | FIXED + | COMPRESSED + | REDUNDANT + | COMPACT + | ID + ) # tableOptionRowFormat + | START TRANSACTION # tableOptionStartTransaction + | SECONDARY_ENGINE_ATTRIBUTE '='? STRING_LITERAL # tableOptionSecondaryEngineAttribute + | STATS_AUTO_RECALC '='? extBoolValue = (DEFAULT | '0' | '1') # tableOptionRecalculation + | STATS_PERSISTENT '='? extBoolValue = (DEFAULT | '0' | '1') # tableOptionPersistent + | STATS_SAMPLE_PAGES '='? (DEFAULT | decimalLiteral) # tableOptionSamplePage + | TABLESPACE uid tablespaceStorage? # tableOptionTablespace + | TABLE_TYPE '=' tableType # tableOptionTableType + | tablespaceStorage # tableOptionTablespace + | TRANSACTIONAL '='? ('0' | '1') # tableOptionTransactional + | UNION '='? '(' tables ')' # tableOptionUnion ; tableType - : MYSQL | ODBC + : MYSQL + | ODBC ; tablespaceStorage @@ -525,57 +584,43 @@ tablespaceStorage ; partitionDefinitions - : PARTITION BY partitionFunctionDefinition - (PARTITIONS count=decimalLiteral)? - ( - SUBPARTITION BY subpartitionFunctionDefinition - (SUBPARTITIONS subCount=decimalLiteral)? - )? - ('(' partitionDefinition (',' partitionDefinition)* ')')? + : PARTITION BY partitionFunctionDefinition (PARTITIONS count = decimalLiteral)? ( + SUBPARTITION BY subpartitionFunctionDefinition (SUBPARTITIONS subCount = decimalLiteral)? + )? ('(' partitionDefinition (',' partitionDefinition)* ')')? ; partitionFunctionDefinition - : LINEAR? HASH '(' expression ')' #partitionFunctionHash - | LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))? - '(' uidList ')' #partitionFunctionKey - | RANGE ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionRange - | LIST ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionList + : LINEAR? HASH '(' expression ')' # partitionFunctionHash + | LINEAR? KEY (ALGORITHM '=' algType = ('1' | '2'))? '(' uidList ')' # partitionFunctionKey + | RANGE ('(' expression ')' | COLUMNS '(' uidList ')') # partitionFunctionRange + | LIST ('(' expression ')' | COLUMNS '(' uidList ')') # partitionFunctionList ; subpartitionFunctionDefinition - : LINEAR? HASH '(' expression ')' #subPartitionFunctionHash - | LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))? - '(' uidList ')' #subPartitionFunctionKey + : LINEAR? HASH '(' expression ')' # subPartitionFunctionHash + | LINEAR? KEY (ALGORITHM '=' algType = ('1' | '2'))? '(' uidList ')' # subPartitionFunctionKey ; partitionDefinition - : PARTITION uid VALUES LESS THAN - '(' - partitionDefinerAtom (',' partitionDefinerAtom)* - ')' - partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionComparison - | PARTITION uid VALUES LESS THAN - partitionDefinerAtom partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionComparison - | PARTITION uid VALUES IN - '(' - partitionDefinerAtom (',' partitionDefinerAtom)* - ')' - partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionListAtom - | PARTITION uid VALUES IN - '(' - partitionDefinerVector (',' partitionDefinerVector)* - ')' - partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionListVector - | PARTITION uid partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionSimple + : PARTITION uid VALUES LESS THAN '(' partitionDefinerAtom (',' partitionDefinerAtom)* ')' partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionComparison + | PARTITION uid VALUES LESS THAN partitionDefinerAtom partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionComparison + | PARTITION uid VALUES IN '(' partitionDefinerAtom (',' partitionDefinerAtom)* ')' partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionListAtom + | PARTITION uid VALUES IN '(' partitionDefinerVector (',' partitionDefinerVector)* ')' partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionListVector + | PARTITION uid partitionOption* ('(' subpartitionDefinition (',' subpartitionDefinition)* ')')? # partitionSimple ; partitionDefinerAtom - : constant | expression | MAXVALUE + : constant + | expression + | MAXVALUE ; partitionDefinerVector @@ -587,33 +632,27 @@ subpartitionDefinition ; partitionOption - : DEFAULT? STORAGE? ENGINE '='? engineName #partitionOptionEngine - | COMMENT '='? comment=STRING_LITERAL #partitionOptionComment - | DATA DIRECTORY '='? dataDirectory=STRING_LITERAL #partitionOptionDataDirectory - | INDEX DIRECTORY '='? indexDirectory=STRING_LITERAL #partitionOptionIndexDirectory - | MAX_ROWS '='? maxRows=decimalLiteral #partitionOptionMaxRows - | MIN_ROWS '='? minRows=decimalLiteral #partitionOptionMinRows - | TABLESPACE '='? tablespace=uid #partitionOptionTablespace - | NODEGROUP '='? nodegroup=uid #partitionOptionNodeGroup + : DEFAULT? STORAGE? ENGINE '='? engineName # partitionOptionEngine + | COMMENT '='? comment = STRING_LITERAL # partitionOptionComment + | DATA DIRECTORY '='? dataDirectory = STRING_LITERAL # partitionOptionDataDirectory + | INDEX DIRECTORY '='? indexDirectory = STRING_LITERAL # partitionOptionIndexDirectory + | MAX_ROWS '='? maxRows = decimalLiteral # partitionOptionMaxRows + | MIN_ROWS '='? minRows = decimalLiteral # partitionOptionMinRows + | TABLESPACE '='? tablespace = uid # partitionOptionTablespace + | NODEGROUP '='? nodegroup = uid # partitionOptionNodeGroup ; // Alter statements alterDatabase - : ALTER dbFormat=(DATABASE | SCHEMA) uid? - createDatabaseOption+ #alterSimpleDatabase - | ALTER dbFormat=(DATABASE | SCHEMA) uid - UPGRADE DATA DIRECTORY NAME #alterUpgradeName + : ALTER dbFormat = (DATABASE | SCHEMA) uid? createDatabaseOption+ # alterSimpleDatabase + | ALTER dbFormat = (DATABASE | SCHEMA) uid UPGRADE DATA DIRECTORY NAME # alterUpgradeName ; alterEvent - : ALTER ownerStatement? - EVENT fullId - (ON SCHEDULE scheduleExpression)? - (ON COMPLETION NOT? PRESERVE)? - (RENAME TO fullId)? enableType? - (COMMENT STRING_LITERAL)? - (DO routineBody)? + : ALTER ownerStatement? EVENT fullId (ON SCHEDULE scheduleExpression)? ( + ON COMPLETION NOT? PRESERVE + )? (RENAME TO fullId)? enableType? (COMMENT STRING_LITERAL)? (DO routineBody)? ; alterFunction @@ -625,10 +664,7 @@ alterInstance ; alterLogfileGroup - : ALTER LOGFILE GROUP uid - ADD UNDOFILE STRING_LITERAL - (INITIAL_SIZE '='? fileSizeLiteral)? - WAIT? ENGINE '='? engineName + : ALTER LOGFILE GROUP uid ADD UNDOFILE STRING_LITERAL (INITIAL_SIZE '='? fileSizeLiteral)? WAIT? ENGINE '='? engineName ; alterProcedure @@ -636,122 +672,101 @@ alterProcedure ; alterServer - : ALTER SERVER uid OPTIONS - '(' serverOption (',' serverOption)* ')' + : ALTER SERVER uid OPTIONS '(' serverOption (',' serverOption)* ')' ; alterTable - : ALTER intimeAction=(ONLINE | OFFLINE)? - IGNORE? TABLE ifExists? tableName waitNowaitClause? // waitNowaitClause is MariaDB-specific only - (alterSpecification (',' alterSpecification)*)? - partitionDefinitions? + : ALTER intimeAction = (ONLINE | OFFLINE)? IGNORE? TABLE ifExists? tableName waitNowaitClause? // waitNowaitClause is MariaDB-specific only + (alterSpecification (',' alterSpecification)*)? partitionDefinitions? ; alterTablespace - : ALTER TABLESPACE uid - objectAction=(ADD | DROP) DATAFILE STRING_LITERAL - (INITIAL_SIZE '=' fileSizeLiteral)? - WAIT? - ENGINE '='? engineName + : ALTER TABLESPACE uid objectAction = (ADD | DROP) DATAFILE STRING_LITERAL ( + INITIAL_SIZE '=' fileSizeLiteral + )? WAIT? ENGINE '='? engineName ; alterView - : ALTER - ( - ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE) - )? - ownerStatement? - (SQL SECURITY secContext=(DEFINER | INVOKER))? - VIEW fullId ('(' uidList ')')? AS selectStatement - (WITH checkOpt=(CASCADED | LOCAL)? CHECK OPTION)? + : ALTER (ALGORITHM '=' algType = (UNDEFINED | MERGE | TEMPTABLE))? ownerStatement? ( + SQL SECURITY secContext = (DEFINER | INVOKER) + )? VIEW fullId ('(' uidList ')')? AS selectStatement ( + WITH checkOpt = (CASCADED | LOCAL)? CHECK OPTION + )? ; -alterSequence // sequence is MariaDB-specific only +alterSequence // sequence is MariaDB-specific only : ALTER SEQUENCE ifExists? fullId sequenceSpec+ ; // details alterSpecification - : tableOption (','? tableOption)* #alterByTableOption - | ADD COLUMN? ifNotExists? uid columnDefinition (FIRST | AFTER uid)? #alterByAddColumn // here ifNotExists is MariaDB-specific only - | ADD COLUMN? ifNotExists? // here ifNotExists is MariaDB-specific only - '(' - uid columnDefinition ( ',' uid columnDefinition)* - ')' #alterByAddColumns - | ADD indexFormat=(INDEX | KEY) ifNotExists? uid? indexType? // here ifNotExists is MariaDB-specific only - indexColumnNames indexOption* #alterByAddIndex - | ADD (CONSTRAINT name=uid?)? PRIMARY KEY index=uid? - indexType? indexColumnNames indexOption* #alterByAddPrimaryKey - | ADD (CONSTRAINT name=uid?)? UNIQUE ifNotExists? - indexFormat=(INDEX | KEY)? indexName=uid? - indexType? indexColumnNames indexOption* #alterByAddUniqueKey - | ADD keyType=(FULLTEXT | SPATIAL) - indexFormat=(INDEX | KEY)? uid? - indexColumnNames indexOption* #alterByAddSpecialIndex - | ADD (CONSTRAINT name=uid?)? FOREIGN KEY ifNotExists? // here ifNotExists is MariaDB-specific only - indexName=uid? indexColumnNames referenceDefinition #alterByAddForeignKey - | ADD (CONSTRAINT name=uid?)? CHECK '(' expression ')' #alterByAddCheckTableConstraint - | ALGORITHM '='? - algType=(DEFAULT | INSTANT | INPLACE | COPY | NOCOPY) #alterBySetAlgorithm - | ALTER COLUMN? uid - (SET DEFAULT defaultValue | DROP DEFAULT) #alterByChangeDefault - | CHANGE COLUMN? ifExists? oldColumn=uid // here ifExists is MariaDB-specific only - newColumn=uid columnDefinition - (FIRST | AFTER afterColumn=uid)? #alterByChangeColumn - | RENAME COLUMN oldColumn=uid TO newColumn=uid #alterByRenameColumn - | LOCK '='? lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) #alterByLock - | MODIFY COLUMN? ifExists? // here ifExists is MariaDB-specific only - uid columnDefinition (FIRST | AFTER uid)? #alterByModifyColumn - | DROP COLUMN? ifExists? uid RESTRICT? #alterByDropColumn // here ifExists is MariaDB-specific only - | DROP (CONSTRAINT | CHECK) ifExists? uid #alterByDropConstraintCheck // here ifExists is MariaDB-specific only - | DROP PRIMARY KEY #alterByDropPrimaryKey - | DROP indexFormat=(INDEX | KEY) ifExists? uid #alterByDropIndex // here ifExists is MariaDB-specific only - | RENAME indexFormat=(INDEX | KEY) uid TO uid #alterByRenameIndex - | ALTER INDEX uid (VISIBLE | INVISIBLE) #alterByAlterIndexVisibility - | DROP FOREIGN KEY ifExists? uid #alterByDropForeignKey // here ifExists is MariaDB-specific only - | DISABLE KEYS #alterByDisableKeys - | ENABLE KEYS #alterByEnableKeys - | RENAME renameFormat=(TO | AS)? (uid | fullId) #alterByRename - | ORDER BY uidList #alterByOrder - | CONVERT TO CHARACTER SET charsetName - (COLLATE collationName)? #alterByConvertCharset - | DEFAULT? CHARACTER SET '=' charsetName - (COLLATE '=' collationName)? #alterByDefaultCharset - | DISCARD TABLESPACE #alterByDiscardTablespace - | IMPORT TABLESPACE #alterByImportTablespace - | FORCE #alterByForce - | validationFormat=(WITHOUT | WITH) VALIDATION #alterByValidate - | ADD COLUMN? ifNotExists? // here ifNotExists is MariaDB-specific only - '(' createDefinition (',' createDefinition)* ')' #alterByAddDefinitions - | alterPartitionSpecification #alterPartition + : tableOption (','? tableOption)* # alterByTableOption + | ADD COLUMN? ifNotExists? uid columnDefinition (FIRST | AFTER uid)? # alterByAddColumn // here ifNotExists is MariaDB-specific only + | ADD COLUMN? ifNotExists? // here ifNotExists is MariaDB-specific only + '(' uid columnDefinition (',' uid columnDefinition)* ')' # alterByAddColumns + | ADD indexFormat = (INDEX | KEY) ifNotExists? uid? indexType? // here ifNotExists is MariaDB-specific only + indexColumnNames indexOption* # alterByAddIndex + | ADD (CONSTRAINT name = uid?)? PRIMARY KEY index = uid? indexType? indexColumnNames indexOption* # alterByAddPrimaryKey + | ADD (CONSTRAINT name = uid?)? UNIQUE ifNotExists? indexFormat = (INDEX | KEY)? indexName = uid? indexType? indexColumnNames indexOption* # + alterByAddUniqueKey + | ADD keyType = (FULLTEXT | SPATIAL) indexFormat = (INDEX | KEY)? uid? indexColumnNames indexOption* # alterByAddSpecialIndex + | ADD (CONSTRAINT name = uid?)? FOREIGN KEY ifNotExists? // here ifNotExists is MariaDB-specific only + indexName = uid? indexColumnNames referenceDefinition # alterByAddForeignKey + | ADD (CONSTRAINT name = uid?)? CHECK '(' expression ')' # alterByAddCheckTableConstraint + | ALGORITHM '='? algType = (DEFAULT | INSTANT | INPLACE | COPY | NOCOPY) # alterBySetAlgorithm + | ALTER COLUMN? uid (SET DEFAULT defaultValue | DROP DEFAULT) # alterByChangeDefault + | CHANGE COLUMN? ifExists? oldColumn = uid // here ifExists is MariaDB-specific only + newColumn = uid columnDefinition (FIRST | AFTER afterColumn = uid)? # alterByChangeColumn + | RENAME COLUMN oldColumn = uid TO newColumn = uid # alterByRenameColumn + | LOCK '='? lockType = (DEFAULT | NONE | SHARED | EXCLUSIVE) # alterByLock + | MODIFY COLUMN? ifExists? // here ifExists is MariaDB-specific only + uid columnDefinition (FIRST | AFTER uid)? # alterByModifyColumn + | DROP COLUMN? ifExists? uid RESTRICT? # alterByDropColumn // here ifExists is MariaDB-specific only + | DROP (CONSTRAINT | CHECK) ifExists? uid # alterByDropConstraintCheck // here ifExists is MariaDB-specific only + | DROP PRIMARY KEY # alterByDropPrimaryKey + | DROP indexFormat = (INDEX | KEY) ifExists? uid # alterByDropIndex // here ifExists is MariaDB-specific only + | RENAME indexFormat = (INDEX | KEY) uid TO uid # alterByRenameIndex + | ALTER INDEX uid (VISIBLE | INVISIBLE) # alterByAlterIndexVisibility + | DROP FOREIGN KEY ifExists? uid # alterByDropForeignKey // here ifExists is MariaDB-specific only + | DISABLE KEYS # alterByDisableKeys + | ENABLE KEYS # alterByEnableKeys + | RENAME renameFormat = (TO | AS)? (uid | fullId) # alterByRename + | ORDER BY uidList # alterByOrder + | CONVERT TO CHARACTER SET charsetName (COLLATE collationName)? # alterByConvertCharset + | DEFAULT? CHARACTER SET '=' charsetName (COLLATE '=' collationName)? # alterByDefaultCharset + | DISCARD TABLESPACE # alterByDiscardTablespace + | IMPORT TABLESPACE # alterByImportTablespace + | FORCE # alterByForce + | validationFormat = (WITHOUT | WITH) VALIDATION # alterByValidate + | ADD COLUMN? ifNotExists? // here ifNotExists is MariaDB-specific only + '(' createDefinition (',' createDefinition)* ')' # alterByAddDefinitions + | alterPartitionSpecification # alterPartition ; alterPartitionSpecification - : ADD PARTITION ifNotExists? // here ifNotExists is MariaDB-specific only - '(' partitionDefinition (',' partitionDefinition)* ')' #alterByAddPartition - | DROP PARTITION ifExists? uidList #alterByDropPartition // here ifExists is MariaDB-specific only - | DISCARD PARTITION (uidList | ALL) TABLESPACE #alterByDiscardPartition - | IMPORT PARTITION (uidList | ALL) TABLESPACE #alterByImportPartition - | TRUNCATE PARTITION (uidList | ALL) #alterByTruncatePartition - | COALESCE PARTITION decimalLiteral #alterByCoalescePartition - | REORGANIZE PARTITION uidList - INTO '(' partitionDefinition (',' partitionDefinition)* ')' #alterByReorganizePartition - | EXCHANGE PARTITION uid WITH TABLE tableName - (validationFormat=(WITH | WITHOUT) VALIDATION)? #alterByExchangePartition - | ANALYZE PARTITION (uidList | ALL) #alterByAnalyzePartition - | CHECK PARTITION (uidList | ALL) #alterByCheckPartition - | OPTIMIZE PARTITION (uidList | ALL) #alterByOptimizePartition - | REBUILD PARTITION (uidList | ALL) #alterByRebuildPartition - | REPAIR PARTITION (uidList | ALL) #alterByRepairPartition - | REMOVE PARTITIONING #alterByRemovePartitioning - | UPGRADE PARTITIONING #alterByUpgradePartitioning + : ADD PARTITION ifNotExists? // here ifNotExists is MariaDB-specific only + '(' partitionDefinition (',' partitionDefinition)* ')' # alterByAddPartition + | DROP PARTITION ifExists? uidList # alterByDropPartition // here ifExists is MariaDB-specific only + | DISCARD PARTITION (uidList | ALL) TABLESPACE # alterByDiscardPartition + | IMPORT PARTITION (uidList | ALL) TABLESPACE # alterByImportPartition + | TRUNCATE PARTITION (uidList | ALL) # alterByTruncatePartition + | COALESCE PARTITION decimalLiteral # alterByCoalescePartition + | REORGANIZE PARTITION uidList INTO '(' partitionDefinition (',' partitionDefinition)* ')' # alterByReorganizePartition + | EXCHANGE PARTITION uid WITH TABLE tableName (validationFormat = (WITH | WITHOUT) VALIDATION)? # alterByExchangePartition + | ANALYZE PARTITION (uidList | ALL) # alterByAnalyzePartition + | CHECK PARTITION (uidList | ALL) # alterByCheckPartition + | OPTIMIZE PARTITION (uidList | ALL) # alterByOptimizePartition + | REBUILD PARTITION (uidList | ALL) # alterByRebuildPartition + | REPAIR PARTITION (uidList | ALL) # alterByRepairPartition + | REMOVE PARTITIONING # alterByRemovePartitioning + | UPGRADE PARTITIONING # alterByUpgradePartitioning ; // Drop statements dropDatabase - : DROP dbFormat=(DATABASE | SCHEMA) ifExists? uid + : DROP dbFormat = (DATABASE | SCHEMA) ifExists? uid ; dropEvent @@ -759,14 +774,11 @@ dropEvent ; dropIndex - : DROP INDEX ifExists? intimeAction=(ONLINE | OFFLINE)? // here ifExists is MariaDB-specific only - uid ON tableName - ( - ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY) - | LOCK '='? - lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) - )* - waitNowaitClause? // waitNowaitClause is MariaDB-specific only + : DROP INDEX ifExists? intimeAction = (ONLINE | OFFLINE)? // here ifExists is MariaDB-specific only + uid ON tableName ( + ALGORITHM '='? algType = (DEFAULT | INPLACE | COPY) + | LOCK '='? lockType = (DEFAULT | NONE | SHARED | EXCLUSIVE) + )* waitNowaitClause? // waitNowaitClause is MariaDB-specific only ; dropLogfileGroup @@ -786,8 +798,7 @@ dropServer ; dropTable - : DROP TEMPORARY? TABLE ifExists? - tables waitNowaitClause? dropType=(RESTRICT | CASCADE)? // waitNowaitClause is MariaDB-specific only + : DROP TEMPORARY? TABLE ifExists? tables waitNowaitClause? dropType = (RESTRICT | CASCADE)? // waitNowaitClause is MariaDB-specific only ; dropTablespace @@ -799,8 +810,7 @@ dropTrigger ; dropView - : DROP VIEW ifExists? - fullId (',' fullId)* dropType=(RESTRICT | CASCADE)? + : DROP VIEW ifExists? fullId (',' fullId)* dropType = (RESTRICT | CASCADE)? ; dropRole @@ -808,45 +818,41 @@ dropRole ; setRole - : SET DEFAULT ROLE (NONE | ALL | roleName (',' roleName)*) - TO (userName | uid) (',' (userName | uid))* + : SET DEFAULT ROLE (NONE | ALL | roleName (',' roleName)*) TO (userName | uid) ( + ',' (userName | uid) + )* | SET ROLE roleOption ; -dropSequence // sequence is MariaDB-specific only +dropSequence // sequence is MariaDB-specific only : DROP TEMPORARY? SEQUENCE ifExists? COMMENT_INPUT? fullId (',' fullId)* ; // Other DDL statements renameTable - : RENAME TABLE - renameTableClause (',' renameTableClause)* + : RENAME TABLE renameTableClause (',' renameTableClause)* ; renameTableClause - : tableName waitNowaitClause? TO tableName // waitNowaitClause is MariaDB-specific only + : tableName waitNowaitClause? TO tableName // waitNowaitClause is MariaDB-specific only ; truncateTable - : TRUNCATE TABLE? tableName waitNowaitClause? // waitNowaitClause is MariaDB-specific only + : TRUNCATE TABLE? tableName waitNowaitClause? // waitNowaitClause is MariaDB-specific only ; - // Data Manipulation Language // Primary DML Statements - callStatement - : CALL fullId - ( - '(' (constants | expressions)? ')' - )? + : CALL fullId ('(' (constants | expressions)? ')')? ; deleteStatement - : singleDeleteStatement | multipleDeleteStatement + : singleDeleteStatement + | multipleDeleteStatement ; doStatement @@ -861,107 +867,77 @@ handlerStatement ; insertStatement - : INSERT - priority=(LOW_PRIORITY | DELAYED | HIGH_PRIORITY)? - IGNORE? INTO? tableName - (PARTITION '(' partitions=uidList? ')' )? - ( - ('(' columns=uidList ')')? insertStatementValue - | SET - setFirst=updatedElement - (',' setElements+=updatedElement)* - ) - ( - ON DUPLICATE KEY UPDATE - duplicatedFirst=updatedElement - (',' duplicatedElements+=updatedElement)* - )? + : INSERT priority = (LOW_PRIORITY | DELAYED | HIGH_PRIORITY)? IGNORE? INTO? tableName ( + PARTITION '(' partitions = uidList? ')' + )? ( + ('(' columns = uidList ')')? insertStatementValue + | SET setFirst = updatedElement (',' setElements += updatedElement)* + ) ( + ON DUPLICATE KEY UPDATE duplicatedFirst = updatedElement ( + ',' duplicatedElements += updatedElement + )* + )? ; loadDataStatement - : LOAD DATA - priority=(LOW_PRIORITY | CONCURRENT)? - LOCAL? INFILE filename=STRING_LITERAL - violation=(REPLACE | IGNORE)? - INTO TABLE tableName - (PARTITION '(' uidList ')' )? - (CHARACTER SET charset=charsetName)? - ( - fieldsFormat=(FIELDS | COLUMNS) - selectFieldsInto+ - )? - ( - LINES - selectLinesInto+ - )? - ( - IGNORE decimalLiteral linesFormat=(LINES | ROWS) - )? - ( '(' assignmentField (',' assignmentField)* ')' )? - (SET updatedElement (',' updatedElement)*)? + : LOAD DATA priority = (LOW_PRIORITY | CONCURRENT)? LOCAL? INFILE filename = STRING_LITERAL violation = ( + REPLACE + | IGNORE + )? INTO TABLE tableName (PARTITION '(' uidList ')')? (CHARACTER SET charset = charsetName)? ( + fieldsFormat = (FIELDS | COLUMNS) selectFieldsInto+ + )? (LINES selectLinesInto+)? (IGNORE decimalLiteral linesFormat = (LINES | ROWS))? ( + '(' assignmentField (',' assignmentField)* ')' + )? (SET updatedElement (',' updatedElement)*)? ; loadXmlStatement - : LOAD XML - priority=(LOW_PRIORITY | CONCURRENT)? - LOCAL? INFILE filename=STRING_LITERAL - violation=(REPLACE | IGNORE)? - INTO TABLE tableName - (CHARACTER SET charset=charsetName)? - (ROWS IDENTIFIED BY '<' tag=STRING_LITERAL '>')? - ( IGNORE decimalLiteral linesFormat=(LINES | ROWS) )? - ( '(' assignmentField (',' assignmentField)* ')' )? - (SET updatedElement (',' updatedElement)*)? + : LOAD XML priority = (LOW_PRIORITY | CONCURRENT)? LOCAL? INFILE filename = STRING_LITERAL violation = ( + REPLACE + | IGNORE + )? INTO TABLE tableName (CHARACTER SET charset = charsetName)? ( + ROWS IDENTIFIED BY '<' tag = STRING_LITERAL '>' + )? (IGNORE decimalLiteral linesFormat = (LINES | ROWS))? ( + '(' assignmentField (',' assignmentField)* ')' + )? (SET updatedElement (',' updatedElement)*)? ; replaceStatement - : REPLACE priority=(LOW_PRIORITY | DELAYED)? - INTO? tableName - (PARTITION '(' partitions=uidList ')' )? - ( - ('(' columns=uidList ')')? insertStatementValue - | SET - setFirst=updatedElement - (',' setElements+=updatedElement)* - ) + : REPLACE priority = (LOW_PRIORITY | DELAYED)? INTO? tableName ( + PARTITION '(' partitions = uidList ')' + )? ( + ('(' columns = uidList ')')? insertStatementValue + | SET setFirst = updatedElement (',' setElements += updatedElement)* + ) ; selectStatement - : querySpecification lockClause? #simpleSelect - | queryExpression lockClause? #parenthesisSelect - | querySpecificationNointo unionStatement+ - ( - UNION unionType=(ALL | DISTINCT)? - (querySpecification | queryExpression) - )? - orderByClause? limitClause? lockClause? #unionSelect - | queryExpressionNointo unionParenthesis+ - ( - UNION unionType=(ALL | DISTINCT)? - queryExpression - )? - orderByClause? limitClause? lockClause? #unionParenthesisSelect - | querySpecificationNointo (',' lateralStatement)+ #withLateralStatement + : querySpecification lockClause? # simpleSelect + | queryExpression lockClause? # parenthesisSelect + | querySpecificationNointo unionStatement+ ( + UNION unionType = (ALL | DISTINCT)? (querySpecification | queryExpression) + )? orderByClause? limitClause? lockClause? # unionSelect + | queryExpressionNointo unionParenthesis+ (UNION unionType = (ALL | DISTINCT)? queryExpression)? orderByClause? limitClause? lockClause? # + unionParenthesisSelect + | querySpecificationNointo (',' lateralStatement)+ # withLateralStatement ; updateStatement - : singleUpdateStatement | multipleUpdateStatement + : singleUpdateStatement + | multipleUpdateStatement ; // https://mariadb.com/kb/en/table-value-constructors/ valuesStatement - : VALUES - '(' expressionsWithDefaults? ')' - (',' '(' expressionsWithDefaults? ')')* + : VALUES '(' expressionsWithDefaults? ')' (',' '(' expressionsWithDefaults? ')')* ; // details insertStatementValue : selectStatement - | insertFormat=(VALUES | VALUE) - '(' expressionsWithDefaults? ')' - (',' '(' expressionsWithDefaults? ')')* + | insertFormat = (VALUES | VALUE) '(' expressionsWithDefaults? ')' ( + ',' '(' expressionsWithDefaults? ')' + )* ; updatedElement @@ -969,33 +945,27 @@ updatedElement ; assignmentField - : uid | LOCAL_ID + : uid + | LOCAL_ID ; lockClause - : (FOR UPDATE | LOCK IN SHARE MODE) lockOption? // lockOption is MariaDB-specific only + : (FOR UPDATE | LOCK IN SHARE MODE) lockOption? // lockOption is MariaDB-specific only ; // Detailed DML Statements singleDeleteStatement - : DELETE priority=LOW_PRIORITY? QUICK? IGNORE? - FROM tableName - (PARTITION '(' uidList ')' )? - (WHERE expression)? - orderByClause? (LIMIT limitClauseAtom)? + : DELETE priority = LOW_PRIORITY? QUICK? IGNORE? FROM tableName (PARTITION '(' uidList ')')? ( + WHERE expression + )? orderByClause? (LIMIT limitClauseAtom)? ; multipleDeleteStatement - : DELETE priority=LOW_PRIORITY? QUICK? IGNORE? - ( - tableName ('.' '*')? ( ',' tableName ('.' '*')? )* - FROM tableSources - | FROM - tableName ('.' '*')? ( ',' tableName ('.' '*')? )* - USING tableSources - ) - (WHERE expression)? + : DELETE priority = LOW_PRIORITY? QUICK? IGNORE? ( + tableName ('.' '*')? ( ',' tableName ('.' '*')?)* FROM tableSources + | FROM tableName ('.' '*')? ( ',' tableName ('.' '*')?)* USING tableSources + ) (WHERE expression)? ; handlerOpenStatement @@ -1003,17 +973,14 @@ handlerOpenStatement ; handlerReadIndexStatement - : HANDLER tableName READ index=uid - ( + : HANDLER tableName READ index = uid ( comparisonOperator '(' constants ')' - | moveOrder=(FIRST | NEXT | PREV | LAST) - ) - (WHERE expression)? (LIMIT limitClauseAtom)? + | moveOrder = (FIRST | NEXT | PREV | LAST) + ) (WHERE expression)? (LIMIT limitClauseAtom)? ; handlerReadStatement - : HANDLER tableName READ moveOrder=(FIRST | NEXT) - (WHERE expression)? (LIMIT limitClauseAtom)? + : HANDLER tableName READ moveOrder = (FIRST | NEXT) (WHERE expression)? (LIMIT limitClauseAtom)? ; handlerCloseStatement @@ -1021,15 +988,15 @@ handlerCloseStatement ; singleUpdateStatement - : UPDATE priority=LOW_PRIORITY? IGNORE? tableName (AS? uid)? - SET updatedElement (',' updatedElement)* - (WHERE expression)? orderByClause? limitClause? + : UPDATE priority = LOW_PRIORITY? IGNORE? tableName (AS? uid)? SET updatedElement ( + ',' updatedElement + )* (WHERE expression)? orderByClause? limitClause? ; multipleUpdateStatement - : UPDATE priority=LOW_PRIORITY? IGNORE? tableSources - SET updatedElement (',' updatedElement)* - (WHERE expression)? + : UPDATE priority = LOW_PRIORITY? IGNORE? tableSources SET updatedElement (',' updatedElement)* ( + WHERE expression + )? ; // details @@ -1039,7 +1006,7 @@ orderByClause ; orderByExpression - : expression order=(ASC | DESC)? + : expression order = (ASC | DESC)? ; tableSources @@ -1047,46 +1014,32 @@ tableSources ; tableSource - : tableSourceItem joinPart* #tableSourceBase - | '(' tableSourceItem joinPart* ')' #tableSourceNested - | jsonTable #tableJson + : tableSourceItem joinPart* # tableSourceBase + | '(' tableSourceItem joinPart* ')' # tableSourceNested + | jsonTable # tableJson ; tableSourceItem - : tableName - (PARTITION '(' uidList ')' )? (AS? alias=uid)? - (indexHint (',' indexHint)* )? #atomTableItem - | ( - selectStatement - | '(' parenthesisSubquery=selectStatement ')' - ) - AS? alias=uid #subqueryTableItem - | '(' tableSources ')' #tableSourcesItem + : tableName (PARTITION '(' uidList ')')? (AS? alias = uid)? (indexHint (',' indexHint)*)? # atomTableItem + | (selectStatement | '(' parenthesisSubquery = selectStatement ')') AS? alias = uid # subqueryTableItem + | '(' tableSources ')' # tableSourcesItem ; indexHint - : indexHintAction=(USE | IGNORE | FORCE) - keyFormat=(INDEX|KEY) ( FOR indexHintType)? - '(' uidList ')' + : indexHintAction = (USE | IGNORE | FORCE) keyFormat = (INDEX | KEY) (FOR indexHintType)? '(' uidList ')' ; indexHintType - : JOIN | ORDER BY | GROUP BY + : JOIN + | ORDER BY + | GROUP BY ; joinPart - : (INNER | CROSS)? JOIN LATERAL? tableSourceItem - ( - ON expression - | USING '(' uidList ')' - )? #innerJoin - | STRAIGHT_JOIN tableSourceItem (ON expression)? #straightJoin - | (LEFT | RIGHT) OUTER? JOIN LATERAL? tableSourceItem - ( - ON expression - | USING '(' uidList ')' - ) #outerJoin - | NATURAL ((LEFT | RIGHT) OUTER?)? JOIN tableSourceItem #naturalJoin + : (INNER | CROSS)? JOIN LATERAL? tableSourceItem (ON expression | USING '(' uidList ')')? # innerJoin + | STRAIGHT_JOIN tableSourceItem (ON expression)? # straightJoin + | (LEFT | RIGHT) OUTER? JOIN LATERAL? tableSourceItem (ON expression | USING '(' uidList ')') # outerJoin + | NATURAL ((LEFT | RIGHT) OUTER?)? JOIN tableSourceItem # naturalJoin ; // Select Statement's Details @@ -1102,53 +1055,46 @@ queryExpressionNointo ; querySpecification - : SELECT selectSpec* selectElements selectIntoExpression? - fromClause? groupByClause? havingClause? windowClause? orderByClause? limitClause? - | SELECT selectSpec* selectElements - fromClause? groupByClause? havingClause? windowClause? orderByClause? limitClause? selectIntoExpression? + : SELECT selectSpec* selectElements selectIntoExpression? fromClause? groupByClause? havingClause? windowClause? orderByClause? limitClause? + | SELECT selectSpec* selectElements fromClause? groupByClause? havingClause? windowClause? orderByClause? limitClause? selectIntoExpression? ; querySpecificationNointo - : SELECT selectSpec* selectElements - fromClause? groupByClause? havingClause? windowClause? orderByClause? limitClause? + : SELECT selectSpec* selectElements fromClause? groupByClause? havingClause? windowClause? orderByClause? limitClause? ; unionParenthesis - : UNION unionType=(ALL | DISTINCT)? queryExpressionNointo + : UNION unionType = (ALL | DISTINCT)? queryExpressionNointo ; unionStatement - : UNION unionType=(ALL | DISTINCT)? - (querySpecificationNointo | queryExpressionNointo) + : UNION unionType = (ALL | DISTINCT)? (querySpecificationNointo | queryExpressionNointo) ; lateralStatement - : LATERAL (querySpecificationNointo | - queryExpressionNointo | - ('(' (querySpecificationNointo | queryExpressionNointo) ')' (AS? uid)?) - ) + : LATERAL ( + querySpecificationNointo + | queryExpressionNointo + | ('(' (querySpecificationNointo | queryExpressionNointo) ')' (AS? uid)?) + ) ; // JSON // https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html jsonTable - : JSON_TABLE '(' - STRING_LITERAL ',' - STRING_LITERAL - COLUMNS '(' jsonColumnList ')' - ')' (AS? uid)? + : JSON_TABLE '(' STRING_LITERAL ',' STRING_LITERAL COLUMNS '(' jsonColumnList ')' ')' (AS? uid)? ; jsonColumnList : jsonColumn (',' jsonColumn)* ; - jsonColumn - : fullColumnName ( FOR ORDINALITY - | dataType ( PATH STRING_LITERAL jsonOnEmpty? jsonOnError? - | EXISTS PATH STRING_LITERAL ) ) + : fullColumnName ( + FOR ORDINALITY + | dataType (PATH STRING_LITERAL jsonOnEmpty? jsonOnError? | EXISTS PATH STRING_LITERAL) + ) | NESTED PATH? STRING_LITERAL COLUMNS '(' jsonColumnList ')' ; @@ -1164,90 +1110,84 @@ jsonOnError selectSpec : (ALL | DISTINCT | DISTINCTROW) - | HIGH_PRIORITY | STRAIGHT_JOIN | SQL_SMALL_RESULT - | SQL_BIG_RESULT | SQL_BUFFER_RESULT + | HIGH_PRIORITY + | STRAIGHT_JOIN + | SQL_SMALL_RESULT + | SQL_BIG_RESULT + | SQL_BUFFER_RESULT | (SQL_CACHE | SQL_NO_CACHE) | SQL_CALC_FOUND_ROWS ; selectElements - : (star='*' | selectElement ) (',' selectElement)* + : (star = '*' | selectElement) (',' selectElement)* ; selectElement - : fullId '.' '*' #selectStarElement - | fullColumnName (AS? uid)? #selectColumnElement - | functionCall (AS? uid)? #selectFunctionElement - | (LOCAL_ID VAR_ASSIGN)? expression (AS? uid)? #selectExpressionElement + : fullId '.' '*' # selectStarElement + | fullColumnName (AS? uid)? # selectColumnElement + | functionCall (AS? uid)? # selectFunctionElement + | (LOCAL_ID VAR_ASSIGN)? expression (AS? uid)? # selectExpressionElement ; selectIntoExpression - : INTO assignmentField (',' assignmentField )* #selectIntoVariables - | INTO DUMPFILE STRING_LITERAL #selectIntoDumpFile + : INTO assignmentField (',' assignmentField)* # selectIntoVariables + | INTO DUMPFILE STRING_LITERAL # selectIntoDumpFile | ( - INTO OUTFILE filename=STRING_LITERAL - (CHARACTER SET charset=charsetName)? - ( - fieldsFormat=(FIELDS | COLUMNS) - selectFieldsInto+ - )? - ( - LINES selectLinesInto+ - )? - ) #selectIntoTextFile + INTO OUTFILE filename = STRING_LITERAL (CHARACTER SET charset = charsetName)? ( + fieldsFormat = (FIELDS | COLUMNS) selectFieldsInto+ + )? (LINES selectLinesInto+)? + ) # selectIntoTextFile ; selectFieldsInto - : TERMINATED BY terminationField=STRING_LITERAL - | OPTIONALLY? ENCLOSED BY enclosion=STRING_LITERAL - | ESCAPED BY escaping=STRING_LITERAL + : TERMINATED BY terminationField = STRING_LITERAL + | OPTIONALLY? ENCLOSED BY enclosion = STRING_LITERAL + | ESCAPED BY escaping = STRING_LITERAL ; selectLinesInto - : STARTING BY starting=STRING_LITERAL - | TERMINATED BY terminationLine=STRING_LITERAL + : STARTING BY starting = STRING_LITERAL + | TERMINATED BY terminationLine = STRING_LITERAL ; fromClause - : (FROM tableSources)? - (WHERE whereExpr=expression)? + : (FROM tableSources)? (WHERE whereExpr = expression)? ; groupByClause - : GROUP BY - groupByItem (',' groupByItem)* - (WITH ROLLUP)? + : GROUP BY groupByItem (',' groupByItem)* (WITH ROLLUP)? ; havingClause - : HAVING havingExpr=expression + : HAVING havingExpr = expression ; windowClause - : WINDOW windowName AS '(' windowSpec ')' (',' windowName AS '(' windowSpec ')')* + : WINDOW windowName AS '(' windowSpec ')' (',' windowName AS '(' windowSpec ')')* ; groupByItem - : expression order=(ASC | DESC)? + : expression order = (ASC | DESC)? ; limitClause - : LIMIT - ( - (offset=limitClauseAtom ',')? limit=limitClauseAtom - | limit=limitClauseAtom OFFSET offset=limitClauseAtom + : LIMIT ( + (offset = limitClauseAtom ',')? limit = limitClauseAtom + | limit = limitClauseAtom OFFSET offset = limitClauseAtom ) ; limitClauseAtom - : decimalLiteral | mysqlVariable | simpleId - ; - + : decimalLiteral + | mysqlVariable + | simpleId + ; // Transaction's Statements startTransaction - : START TRANSACTION (transactionMode (',' transactionMode)* )? + : START TRANSACTION (transactionMode (',' transactionMode)*)? ; beginWork @@ -1255,15 +1195,11 @@ beginWork ; commitWork - : COMMIT WORK? - (AND nochain=NO? CHAIN)? - (norelease=NO? RELEASE)? + : COMMIT WORK? (AND nochain = NO? CHAIN)? (norelease = NO? RELEASE)? ; rollbackWork - : ROLLBACK WORK? - (AND nochain=NO? CHAIN)? - (norelease=NO? RELEASE)? + : ROLLBACK WORK? (AND nochain = NO? CHAIN)? (norelease = NO? RELEASE)? ; savepointStatement @@ -1279,23 +1215,23 @@ releaseStatement ; lockTables - : LOCK (TABLE | TABLES) lockTableElement (',' lockTableElement)* waitNowaitClause? // waitNowaitClause is MariaDB-specific only + : LOCK (TABLE | TABLES) lockTableElement (',' lockTableElement)* waitNowaitClause? // waitNowaitClause is MariaDB-specific only ; unlockTables : UNLOCK TABLES ; - // details setAutocommitStatement - : SET AUTOCOMMIT '=' autocommitValue=('0' | '1') + : SET AUTOCOMMIT '=' autocommitValue = ('0' | '1') ; setTransactionStatement - : SET transactionContext=(GLOBAL | SESSION)? TRANSACTION - transactionOption (',' transactionOption)* + : SET transactionContext = (GLOBAL | SESSION)? TRANSACTION transactionOption ( + ',' transactionOption + )* ; transactionMode @@ -1309,7 +1245,8 @@ lockTableElement ; lockAction - : READ LOCAL? | LOW_PRIORITY? WRITE + : READ LOCAL? + | LOW_PRIORITY? WRITE ; transactionOption @@ -1325,27 +1262,23 @@ transactionLevel | SERIALIZABLE ; - // Replication's Statements // Base Replication changeMaster - : CHANGE MASTER TO - masterOption (',' masterOption)* channelOption? + : CHANGE MASTER TO masterOption (',' masterOption)* channelOption? ; changeReplicationFilter - : CHANGE REPLICATION FILTER - replicationFilter (',' replicationFilter)* + : CHANGE REPLICATION FILTER replicationFilter (',' replicationFilter)* ; purgeBinaryLogs - : PURGE purgeFormat=(BINARY | MASTER) LOGS - ( - TO fileName=STRING_LITERAL - | BEFORE timeValue=STRING_LITERAL - ) + : PURGE purgeFormat = (BINARY | MASTER) LOGS ( + TO fileName = STRING_LITERAL + | BEFORE timeValue = STRING_LITERAL + ) ; resetMaster @@ -1357,9 +1290,7 @@ resetSlave ; startSlave - : START SLAVE (threadType (',' threadType)*)? - (UNTIL untilOption)? - connectionOption* channelOption? + : START SLAVE (threadType (',' threadType)*)? (UNTIL untilOption)? connectionOption* channelOption? ; stopSlave @@ -1377,27 +1308,42 @@ stopGroupReplication // details masterOption - : stringMasterOption '=' STRING_LITERAL #masterStringOption - | decimalMasterOption '=' decimalLiteral #masterDecimalOption - | boolMasterOption '=' boolVal=('0' | '1') #masterBoolOption - | MASTER_HEARTBEAT_PERIOD '=' REAL_LITERAL #masterRealOption - | IGNORE_SERVER_IDS '=' '(' (uid (',' uid)*)? ')' #masterUidListOption + : stringMasterOption '=' STRING_LITERAL # masterStringOption + | decimalMasterOption '=' decimalLiteral # masterDecimalOption + | boolMasterOption '=' boolVal = ('0' | '1') # masterBoolOption + | MASTER_HEARTBEAT_PERIOD '=' REAL_LITERAL # masterRealOption + | IGNORE_SERVER_IDS '=' '(' (uid (',' uid)*)? ')' # masterUidListOption ; stringMasterOption - : MASTER_BIND | MASTER_HOST | MASTER_USER | MASTER_PASSWORD - | MASTER_LOG_FILE | RELAY_LOG_FILE | MASTER_SSL_CA - | MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CRL - | MASTER_SSL_CRLPATH | MASTER_SSL_KEY | MASTER_SSL_CIPHER + : MASTER_BIND + | MASTER_HOST + | MASTER_USER + | MASTER_PASSWORD + | MASTER_LOG_FILE + | RELAY_LOG_FILE + | MASTER_SSL_CA + | MASTER_SSL_CAPATH + | MASTER_SSL_CERT + | MASTER_SSL_CRL + | MASTER_SSL_CRLPATH + | MASTER_SSL_KEY + | MASTER_SSL_CIPHER | MASTER_TLS_VERSION ; + decimalMasterOption - : MASTER_PORT | MASTER_CONNECT_RETRY | MASTER_RETRY_COUNT - | MASTER_DELAY | MASTER_LOG_POS | RELAY_LOG_POS + : MASTER_PORT + | MASTER_CONNECT_RETRY + | MASTER_RETRY_COUNT + | MASTER_DELAY + | MASTER_LOG_POS + | RELAY_LOG_POS ; boolMasterOption - : MASTER_AUTO_POSITION | MASTER_SSL + : MASTER_AUTO_POSITION + | MASTER_SSL | MASTER_SSL_VERIFY_SERVER_CERT ; @@ -1406,40 +1352,36 @@ channelOption ; replicationFilter - : REPLICATE_DO_DB '=' '(' uidList ')' #doDbReplication - | REPLICATE_IGNORE_DB '=' '(' uidList ')' #ignoreDbReplication - | REPLICATE_DO_TABLE '=' '(' tables ')' #doTableReplication - | REPLICATE_IGNORE_TABLE '=' '(' tables ')' #ignoreTableReplication - | REPLICATE_WILD_DO_TABLE '=' '(' simpleStrings ')' #wildDoTableReplication - | REPLICATE_WILD_IGNORE_TABLE - '=' '(' simpleStrings ')' #wildIgnoreTableReplication - | REPLICATE_REWRITE_DB '=' - '(' tablePair (',' tablePair)* ')' #rewriteDbReplication + : REPLICATE_DO_DB '=' '(' uidList ')' # doDbReplication + | REPLICATE_IGNORE_DB '=' '(' uidList ')' # ignoreDbReplication + | REPLICATE_DO_TABLE '=' '(' tables ')' # doTableReplication + | REPLICATE_IGNORE_TABLE '=' '(' tables ')' # ignoreTableReplication + | REPLICATE_WILD_DO_TABLE '=' '(' simpleStrings ')' # wildDoTableReplication + | REPLICATE_WILD_IGNORE_TABLE '=' '(' simpleStrings ')' # wildIgnoreTableReplication + | REPLICATE_REWRITE_DB '=' '(' tablePair (',' tablePair)* ')' # rewriteDbReplication ; tablePair - : '(' firstTable=tableName ',' secondTable=tableName ')' + : '(' firstTable = tableName ',' secondTable = tableName ')' ; threadType - : IO_THREAD | SQL_THREAD + : IO_THREAD + | SQL_THREAD ; untilOption - : gtids=(SQL_BEFORE_GTIDS | SQL_AFTER_GTIDS) - '=' gtuidSet #gtidsUntilOption - | MASTER_LOG_FILE '=' STRING_LITERAL - ',' MASTER_LOG_POS '=' decimalLiteral #masterLogUntilOption - | RELAY_LOG_FILE '=' STRING_LITERAL - ',' RELAY_LOG_POS '=' decimalLiteral #relayLogUntilOption - | SQL_AFTER_MTS_GAPS #sqlGapsUntilOption + : gtids = (SQL_BEFORE_GTIDS | SQL_AFTER_GTIDS) '=' gtuidSet # gtidsUntilOption + | MASTER_LOG_FILE '=' STRING_LITERAL ',' MASTER_LOG_POS '=' decimalLiteral # masterLogUntilOption + | RELAY_LOG_FILE '=' STRING_LITERAL ',' RELAY_LOG_POS '=' decimalLiteral # relayLogUntilOption + | SQL_AFTER_MTS_GAPS # sqlGapsUntilOption ; connectionOption - : USER '=' conOptUser=STRING_LITERAL #userConnectionOption - | PASSWORD '=' conOptPassword=STRING_LITERAL #passwordConnectionOption - | DEFAULT_AUTH '=' conOptDefAuth=STRING_LITERAL #defaultAuthConnectionOption - | PLUGIN_DIR '=' conOptPluginDir=STRING_LITERAL #pluginDirConnectionOption + : USER '=' conOptUser = STRING_LITERAL # userConnectionOption + | PASSWORD '=' conOptPassword = STRING_LITERAL # passwordConnectionOption + | DEFAULT_AUTH '=' conOptDefAuth = STRING_LITERAL # defaultAuthConnectionOption + | PLUGIN_DIR '=' conOptPluginDir = STRING_LITERAL # pluginDirConnectionOption ; gtuidSet @@ -1447,11 +1389,10 @@ gtuidSet | STRING_LITERAL ; - // XA Transactions xaStartTransaction - : XA xaStart=(START | BEGIN) xid xaAction=(JOIN | RESUME)? + : XA xaStart = (START | BEGIN) xid xaAction = (JOIN | RESUME)? ; xaEndTransaction @@ -1474,12 +1415,10 @@ xaRecoverWork : XA RECOVER (CONVERT xid)? ; - // Prepared Statements prepareStatement - : PREPARE uid FROM - (query=STRING_LITERAL | variable=LOCAL_ID) + : PREPARE uid FROM (query = STRING_LITERAL | variable = LOCAL_ID) ; executeStatement @@ -1487,42 +1426,34 @@ executeStatement ; deallocatePrepare - : dropFormat=(DEALLOCATE | DROP) PREPARE uid + : dropFormat = (DEALLOCATE | DROP) PREPARE uid ; - // Compound Statements routineBody - : blockStatement | sqlStatement + : blockStatement + | sqlStatement ; // details blockStatement - : (uid ':')? BEGIN - ( - (declareVariable SEMI)* - (declareCondition SEMI)* - (declareCursor SEMI)* - (declareHandler SEMI)* - procedureSqlStatement* - )? - END uid? + : (uid ':')? BEGIN ( + (declareVariable SEMI)* (declareCondition SEMI)* (declareCursor SEMI)* ( + declareHandler SEMI + )* procedureSqlStatement* + )? END uid? ; caseStatement - : CASE (uid | expression)? caseAlternative+ - (ELSE procedureSqlStatement+)? - END CASE + : CASE (uid | expression)? caseAlternative+ (ELSE procedureSqlStatement+)? END CASE ; ifStatement - : IF expression - THEN thenStatements+=procedureSqlStatement+ - elifAlternative* - (ELSE elseStatements+=procedureSqlStatement+ )? - END IF + : IF expression THEN thenStatements += procedureSqlStatement+ elifAlternative* ( + ELSE elseStatements += procedureSqlStatement+ + )? END IF ; iterateStatement @@ -1534,16 +1465,11 @@ leaveStatement ; loopStatement - : (uid ':')? - LOOP procedureSqlStatement+ - END LOOP uid? + : (uid ':')? LOOP procedureSqlStatement+ END LOOP uid? ; repeatStatement - : (uid ':')? - REPEAT procedureSqlStatement+ - UNTIL expression - END REPEAT uid? + : (uid ':')? REPEAT procedureSqlStatement+ UNTIL expression END REPEAT uid? ; returnStatement @@ -1551,16 +1477,13 @@ returnStatement ; whileStatement - : (uid ':')? - WHILE expression - DO procedureSqlStatement+ - END WHILE uid? + : (uid ':')? WHILE expression DO procedureSqlStatement+ END WHILE uid? ; cursorStatement - : CLOSE uid #CloseCursor - | FETCH (NEXT? FROM)? uid INTO uidList #FetchCursor - | OPEN uid #OpenCursor + : CLOSE uid # CloseCursor + | FETCH (NEXT? FROM)? uid INTO uidList # FetchCursor + | OPEN uid # OpenCursor ; // details @@ -1570,8 +1493,7 @@ declareVariable ; declareCondition - : DECLARE uid CONDITION FOR - ( decimalLiteral | SQLSTATE VALUE? STRING_LITERAL) + : DECLARE uid CONDITION FOR (decimalLiteral | SQLSTATE VALUE? STRING_LITERAL) ; declareCursor @@ -1579,19 +1501,18 @@ declareCursor ; declareHandler - : DECLARE handlerAction=(CONTINUE | EXIT | UNDO) - HANDLER FOR - handlerConditionValue (',' handlerConditionValue)* - routineBody + : DECLARE handlerAction = (CONTINUE | EXIT | UNDO) HANDLER FOR handlerConditionValue ( + ',' handlerConditionValue + )* routineBody ; handlerConditionValue - : decimalLiteral #handlerConditionCode - | SQLSTATE VALUE? STRING_LITERAL #handlerConditionState - | uid #handlerConditionName - | SQLWARNING #handlerConditionWarning - | NOT FOUND #handlerConditionNotfound - | SQLEXCEPTION #handlerConditionException + : decimalLiteral # handlerConditionCode + | SQLSTATE VALUE? STRING_LITERAL # handlerConditionState + | uid # handlerConditionName + | SQLWARNING # handlerConditionWarning + | NOT FOUND # handlerConditionNotfound + | SQLEXCEPTION # handlerConditionException ; procedureSqlStatement @@ -1599,13 +1520,11 @@ procedureSqlStatement ; caseAlternative - : WHEN (constant | expression) - THEN procedureSqlStatement+ + : WHEN (constant | expression) THEN procedureSqlStatement+ ; elifAlternative - : ELSEIF expression - THEN procedureSqlStatement+ + : ELSEIF expression THEN procedureSqlStatement+ ; // Administration Statements @@ -1613,30 +1532,23 @@ elifAlternative // Account management statements alterUser - : ALTER USER - userSpecification (',' userSpecification)* #alterUserMysqlV56 - | ALTER USER ifExists? - userAuthOption (',' userAuthOption)* - ( - REQUIRE - (tlsNone=NONE | tlsOption (AND? tlsOption)* ) - )? - (WITH userResourceOption+)? - (userPasswordOption | userLockOption)* - (COMMENT STRING_LITERAL | ATTRIBUTE STRING_LITERAL)? #alterUserMysqlV80 + : ALTER USER userSpecification (',' userSpecification)* # alterUserMysqlV56 + | ALTER USER ifExists? userAuthOption (',' userAuthOption)* ( + REQUIRE (tlsNone = NONE | tlsOption (AND? tlsOption)*) + )? (WITH userResourceOption+)? (userPasswordOption | userLockOption)* ( + COMMENT STRING_LITERAL + | ATTRIBUTE STRING_LITERAL + )? # alterUserMysqlV80 ; createUser - : CREATE USER userAuthOption (',' userAuthOption)* #createUserMysqlV56 - | CREATE USER ifNotExists? - userAuthOption (',' userAuthOption)* - ( - REQUIRE - (tlsNone=NONE | tlsOption (AND? tlsOption)* ) - )? - (WITH userResourceOption+)? - (userPasswordOption | userLockOption)* - (COMMENT STRING_LITERAL | ATTRIBUTE STRING_LITERAL)? #createUserMysqlV80 + : CREATE USER userAuthOption (',' userAuthOption)* # createUserMysqlV56 + | CREATE USER ifNotExists? userAuthOption (',' userAuthOption)* ( + REQUIRE (tlsNone = NONE | tlsOption (AND? tlsOption)*) + )? (WITH userResourceOption+)? (userPasswordOption | userLockOption)* ( + COMMENT STRING_LITERAL + | ATTRIBUTE STRING_LITERAL + )? # createUserMysqlV80 ; dropUser @@ -1644,20 +1556,16 @@ dropUser ; grantStatement - : GRANT privelegeClause (',' privelegeClause)* - ON - privilegeObject=(TABLE | FUNCTION | PROCEDURE)? - privilegeLevel - TO userAuthOption (',' userAuthOption)* - ( - REQUIRE - (tlsNone=NONE | tlsOption (AND? tlsOption)* ) - )? - (WITH (GRANT OPTION | userResourceOption)* )? - (AS userName WITH ROLE roleOption)? - | GRANT (userName | uid) (',' (userName | uid))* - TO (userName | uid) (',' (userName | uid))* - (WITH ADMIN OPTION)? + : GRANT privelegeClause (',' privelegeClause)* ON privilegeObject = ( + TABLE + | FUNCTION + | PROCEDURE + )? privilegeLevel TO userAuthOption (',' userAuthOption)* ( + REQUIRE (tlsNone = NONE | tlsOption (AND? tlsOption)*) + )? (WITH (GRANT OPTION | userResourceOption)*)? (AS userName WITH ROLE roleOption)? + | GRANT (userName | uid) (',' (userName | uid))* TO (userName | uid) (',' (userName | uid))* ( + WITH ADMIN OPTION + )? ; roleOption @@ -1668,36 +1576,31 @@ roleOption ; grantProxy - : GRANT PROXY ON fromFirst=userName - TO toFirst=userName (',' toOther+=userName)* - (WITH GRANT OPTION)? + : GRANT PROXY ON fromFirst = userName TO toFirst = userName (',' toOther += userName)* ( + WITH GRANT OPTION + )? ; renameUser - : RENAME USER - renameUserClause (',' renameUserClause)* + : RENAME USER renameUserClause (',' renameUserClause)* ; revokeStatement - : REVOKE privelegeClause (',' privelegeClause)* - ON - privilegeObject=(TABLE | FUNCTION | PROCEDURE)? - privilegeLevel - FROM userName (',' userName)* #detailRevoke - | REVOKE ALL PRIVILEGES? ',' GRANT OPTION - FROM userName (',' userName)* #shortRevoke - | REVOKE uid (',' uid)* - FROM (userName | uid) (',' (userName | uid))* #roleRevoke + : REVOKE privelegeClause (',' privelegeClause)* ON privilegeObject = ( + TABLE + | FUNCTION + | PROCEDURE + )? privilegeLevel FROM userName (',' userName)* # detailRevoke + | REVOKE ALL PRIVILEGES? ',' GRANT OPTION FROM userName (',' userName)* # shortRevoke + | REVOKE uid (',' uid)* FROM (userName | uid) (',' (userName | uid))* # roleRevoke ; revokeProxy - : REVOKE PROXY ON onUser=userName - FROM fromFirst=userName (',' fromOther+=userName)* + : REVOKE PROXY ON onUser = userName FROM fromFirst = userName (',' fromOther += userName)* ; setPasswordStatement - : SET PASSWORD (FOR userName)? - '=' ( passwordFunctionClause | STRING_LITERAL) + : SET PASSWORD (FOR userName)? '=' (passwordFunctionClause | STRING_LITERAL) ; // details @@ -1707,20 +1610,16 @@ userSpecification ; userAuthOption - : userName IDENTIFIED BY PASSWORD hashed=STRING_LITERAL #hashAuthOption - | userName - IDENTIFIED BY STRING_LITERAL (RETAIN CURRENT PASSWORD)? #stringAuthOption - | userName - IDENTIFIED (WITH | VIA) // VIA is MariaDB-specific only - authenticationRule (OR authenticationRule)* #moduleAuthOption // OR is MariaDB-specific only - | userName #simpleAuthOption + : userName IDENTIFIED BY PASSWORD hashed = STRING_LITERAL # hashAuthOption + | userName IDENTIFIED BY STRING_LITERAL (RETAIN CURRENT PASSWORD)? # stringAuthOption + | userName IDENTIFIED (WITH | VIA) // VIA is MariaDB-specific only + authenticationRule (OR authenticationRule)* # moduleAuthOption // OR is MariaDB-specific only + | userName # simpleAuthOption ; authenticationRule - : authPlugin - ((BY | USING | AS) STRING_LITERAL)? #module - | authPlugin - (USING | AS) passwordFunctionClause #passwordModuleOption // MariaDB + : authPlugin ((BY | USING | AS) STRING_LITERAL)? # module + | authPlugin (USING | AS) passwordFunctionClause # passwordModuleOption // MariaDB ; tlsOption @@ -1739,11 +1638,11 @@ userResourceOption ; userPasswordOption - : PASSWORD EXPIRE - (expireType=DEFAULT - | expireType=NEVER - | expireType=INTERVAL decimalLiteral DAY - )? + : PASSWORD EXPIRE ( + expireType = DEFAULT + | expireType = NEVER + | expireType = INTERVAL decimalLiteral DAY + )? | PASSWORD HISTORY (DEFAULT | decimalLiteral) | PASSWORD REUSE INTERVAL (DEFAULT | decimalLiteral DAY) | PASSWORD REQUIRE CURRENT (OPTIONAL | DEFAULT)? @@ -1752,66 +1651,113 @@ userPasswordOption ; userLockOption - : ACCOUNT lockType=(LOCK | UNLOCK) + : ACCOUNT lockType = (LOCK | UNLOCK) ; privelegeClause - : privilege ( '(' uidList ')' )? + : privilege ('(' uidList ')')? ; privilege : ALL PRIVILEGES? | ALTER ROUTINE? - | CREATE - (TEMPORARY TABLES | ROUTINE | VIEW | USER | TABLESPACE | ROLE)? - | DELETE | DROP (ROLE)? | EVENT | EXECUTE | FILE | GRANT OPTION - | INDEX | INSERT | LOCK TABLES | PROCESS | PROXY - | REFERENCES | RELOAD + | CREATE (TEMPORARY TABLES | ROUTINE | VIEW | USER | TABLESPACE | ROLE)? + | DELETE + | DROP (ROLE)? + | EVENT + | EXECUTE + | FILE + | GRANT OPTION + | INDEX + | INSERT + | LOCK TABLES + | PROCESS + | PROXY + | REFERENCES + | RELOAD | REPLICATION (CLIENT | SLAVE | REPLICA | MASTER) ADMIN? | SELECT | SHOW (VIEW | DATABASES | SCHEMAS) - | SHUTDOWN | SUPER | TRIGGER | UPDATE | USAGE - | APPLICATION_PASSWORD_ADMIN | AUDIT_ADMIN | BACKUP_ADMIN | BINLOG_ADMIN | BINLOG_ENCRYPTION_ADMIN | CLONE_ADMIN - | CONNECTION_ADMIN | ENCRYPTION_KEY_ADMIN | FIREWALL_ADMIN | FIREWALL_USER | FLUSH_OPTIMIZER_COSTS - | FLUSH_STATUS | FLUSH_TABLES | FLUSH_USER_RESOURCES | GROUP_REPLICATION_ADMIN - | INNODB_REDO_LOG_ARCHIVE | INNODB_REDO_LOG_ENABLE | NDB_STORED_USER | PASSWORDLESS_USER_ADMIN | PERSIST_RO_VARIABLES_ADMIN | REPLICATION_APPLIER - | REPLICATION_SLAVE_ADMIN | RESOURCE_GROUP_ADMIN | RESOURCE_GROUP_USER | ROLE_ADMIN + | SHUTDOWN + | SUPER + | TRIGGER + | UPDATE + | USAGE + | APPLICATION_PASSWORD_ADMIN + | AUDIT_ADMIN + | BACKUP_ADMIN + | BINLOG_ADMIN + | BINLOG_ENCRYPTION_ADMIN + | CLONE_ADMIN + | CONNECTION_ADMIN + | ENCRYPTION_KEY_ADMIN + | FIREWALL_ADMIN + | FIREWALL_USER + | FLUSH_OPTIMIZER_COSTS + | FLUSH_STATUS + | FLUSH_TABLES + | FLUSH_USER_RESOURCES + | GROUP_REPLICATION_ADMIN + | INNODB_REDO_LOG_ARCHIVE + | INNODB_REDO_LOG_ENABLE + | NDB_STORED_USER + | PASSWORDLESS_USER_ADMIN + | PERSIST_RO_VARIABLES_ADMIN + | REPLICATION_APPLIER + | REPLICATION_SLAVE_ADMIN + | RESOURCE_GROUP_ADMIN + | RESOURCE_GROUP_USER + | ROLE_ADMIN | SERVICE_CONNECTION_ADMIN - | SESSION_VARIABLES_ADMIN | SET_USER_ID | SHOW_ROUTINE | SYSTEM_USER | SYSTEM_VARIABLES_ADMIN - | TABLE_ENCRYPTION_ADMIN | VERSION_TOKEN_ADMIN | XA_RECOVER_ADMIN + | SESSION_VARIABLES_ADMIN + | SET_USER_ID + | SHOW_ROUTINE + | SYSTEM_USER + | SYSTEM_VARIABLES_ADMIN + | TABLE_ENCRYPTION_ADMIN + | VERSION_TOKEN_ADMIN + | XA_RECOVER_ADMIN // MariaDB - | BINLOG_MONITOR | BINLOG_REPLAY | FEDERATED_ADMIN | READ_ONLY_ADMIN | REPLICATION_MASTER_ADMIN - | BINLOG (ADMIN | MONITOR | REPLAY) | FEDERATED ADMIN | (READ ONLY | READ_ONLY) ADMIN + | BINLOG_MONITOR + | BINLOG_REPLAY + | FEDERATED_ADMIN + | READ_ONLY_ADMIN + | REPLICATION_MASTER_ADMIN + | BINLOG (ADMIN | MONITOR | REPLAY) + | FEDERATED ADMIN + | (READ ONLY | READ_ONLY) ADMIN | ADMIN OPTION | CONNECTION ADMIN - | DELETE HISTORY | REPLICA MONITOR + | DELETE HISTORY + | REPLICA MONITOR | GRANT OPTION | SET USER | SLAVE MONITOR // MySQL on Amazon RDS - | LOAD FROM S3 | SELECT INTO S3 | INVOKE LAMBDA + | LOAD FROM S3 + | SELECT INTO S3 + | INVOKE LAMBDA ; privilegeLevel - : '*' #currentSchemaPriviLevel - | '*' '.' '*' #globalPrivLevel - | uid '.' '*' #definiteSchemaPrivLevel - | uid '.' uid #definiteFullTablePrivLevel - | uid dottedId #definiteFullTablePrivLevel2 - | uid #definiteTablePrivLevel + : '*' # currentSchemaPriviLevel + | '*' '.' '*' # globalPrivLevel + | uid '.' '*' # definiteSchemaPrivLevel + | uid '.' uid # definiteFullTablePrivLevel + | uid dottedId # definiteFullTablePrivLevel2 + | uid # definiteTablePrivLevel ; renameUserClause - : fromFirst=userName TO toFirst=userName + : fromFirst = userName TO toFirst = userName ; // Table maintenance statements analyzeTable - : ANALYZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)? - (TABLE | TABLES) tables - ( UPDATE HISTOGRAM ON fullColumnName (',' fullColumnName)* (WITH decimalLiteral BUCKETS)? )? - ( DROP HISTOGRAM ON fullColumnName (',' fullColumnName)* )? + : ANALYZE actionOption = (NO_WRITE_TO_BINLOG | LOCAL)? (TABLE | TABLES) tables ( + UPDATE HISTOGRAM ON fullColumnName (',' fullColumnName)* (WITH decimalLiteral BUCKETS)? + )? (DROP HISTOGRAM ON fullColumnName (',' fullColumnName)*)? ; checkTable @@ -1819,33 +1765,33 @@ checkTable ; checksumTable - : CHECKSUM TABLE tables actionOption=(QUICK | EXTENDED)? + : CHECKSUM TABLE tables actionOption = (QUICK | EXTENDED)? ; optimizeTable - : OPTIMIZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)? - (TABLE | TABLES) tables waitNowaitClause? // waitNowaitClause is MariaDB-specific only + : OPTIMIZE actionOption = (NO_WRITE_TO_BINLOG | LOCAL)? (TABLE | TABLES) tables waitNowaitClause? // waitNowaitClause is MariaDB-specific only ; repairTable - : REPAIR actionOption=(NO_WRITE_TO_BINLOG | LOCAL)? - TABLE tables - QUICK? EXTENDED? USE_FRM? + : REPAIR actionOption = (NO_WRITE_TO_BINLOG | LOCAL)? TABLE tables QUICK? EXTENDED? USE_FRM? ; // details checkTableOption - : FOR UPGRADE | QUICK | FAST | MEDIUM | EXTENDED | CHANGED + : FOR UPGRADE + | QUICK + | FAST + | MEDIUM + | EXTENDED + | CHANGED ; - // Plugin and udf statements createUdfunction - : CREATE orReplace? AGGREGATE? FUNCTION ifNotExists? uid // here orReplace is MariaDB-specific only - RETURNS returnType=(STRING | INTEGER | REAL | DECIMAL) - SONAME STRING_LITERAL + : CREATE orReplace? AGGREGATE? FUNCTION ifNotExists? uid // here orReplace is MariaDB-specific only + RETURNS returnType = (STRING | INTEGER | REAL | DECIMAL) SONAME STRING_LITERAL ; installPlugin @@ -1856,86 +1802,76 @@ uninstallPlugin : UNINSTALL PLUGIN uid ; - // Set and show statements setStatement - : SET variableClause ('=' | ':=') (expression | ON) - (',' variableClause ('=' | ':=') (expression | ON))* #setVariable - | SET charSet (charsetName | DEFAULT) #setCharset - | SET NAMES - (charsetName (COLLATE collationName)? | DEFAULT) #setNames - | setPasswordStatement #setPassword - | setTransactionStatement #setTransaction - | setAutocommitStatement #setAutocommit - | SET fullId ('=' | ':=') expression - (',' fullId ('=' | ':=') expression)* #setNewValueInsideTrigger + : SET variableClause ('=' | ':=') (expression | ON) ( + ',' variableClause ('=' | ':=') (expression | ON) + )* # setVariable + | SET charSet (charsetName | DEFAULT) # setCharset + | SET NAMES (charsetName (COLLATE collationName)? | DEFAULT) # setNames + | setPasswordStatement # setPassword + | setTransactionStatement # setTransaction + | setAutocommitStatement # setAutocommit + | SET fullId ('=' | ':=') expression (',' fullId ('=' | ':=') expression)* # setNewValueInsideTrigger ; showStatement - : SHOW logFormat=(BINARY | MASTER) LOGS #showMasterLogs - | SHOW BINLOG - EVENTS (IN filename=STRING_LITERAL)? - (FROM fromPosition=decimalLiteral)? - limitClause? #showBinLogEvents - | SHOW RELAYLOG - (connectionName=STRING_LITERAL)? - EVENTS (IN filename=STRING_LITERAL)? - (FROM fromPosition=decimalLiteral)? - limitClause? - (FOR CHANNEL channelName=STRING_LITERAL)? #showRelayLogEvents - | SHOW showCommonEntity showFilter? #showObjectFilter - | SHOW FULL? columnsFormat=(COLUMNS | FIELDS) - tableFormat=(FROM | IN) tableName - (schemaFormat=(FROM | IN) uid)? showFilter? #showColumns - | SHOW CREATE schemaFormat=(DATABASE | SCHEMA) - ifNotExists? uid #showCreateDb - | SHOW CREATE - namedEntity=( - EVENT | FUNCTION | PROCEDURE - | SEQUENCE | TABLE | TRIGGER | VIEW - ) - fullId #showCreateFullIdObject - | SHOW CREATE PACKAGE BODY? fullId #showCreatePackage - | SHOW CREATE USER userName #showCreateUser - | SHOW ENGINE engineName engineOption=(STATUS | MUTEX) #showEngine - | SHOW INNODB STATUS #showInnoDBStatus - | SHOW showGlobalInfoClause #showGlobalInfo - | SHOW errorFormat=(ERRORS | WARNINGS) - limitClause? #showErrors - | SHOW COUNT '(' '*' ')' errorFormat=(ERRORS | WARNINGS) #showCountErrors - | SHOW showSchemaEntity - (schemaFormat=(FROM | IN) uid)? showFilter? #showSchemaFilter - | SHOW routine=(FUNCTION | PROCEDURE) CODE fullId #showRoutine - | SHOW GRANTS (FOR userName)? #showGrants - | SHOW indexFormat=(INDEX | INDEXES | KEYS) - tableFormat=(FROM | IN) tableName - (schemaFormat=(FROM | IN) uid)? (WHERE expression)? #showIndexes - | SHOW OPEN TABLES ( schemaFormat=(FROM | IN) fullId)? - showFilter? #showOpenTables - | SHOW PROFILE - (showProfileType (',' showProfileType)*)? - (FOR QUERY queryCount=decimalLiteral)? - limitClause? #showProfile - | SHOW (SLAVE | REPLICA) (connectionName=STRING_LITERAL)? STATUS (FOR CHANNEL channelName=STRING_LITERAL)? #showSlaveStatus + : SHOW logFormat = (BINARY | MASTER) LOGS # showMasterLogs + | SHOW BINLOG EVENTS (IN filename = STRING_LITERAL)? (FROM fromPosition = decimalLiteral)? limitClause? # showBinLogEvents + | SHOW RELAYLOG (connectionName = STRING_LITERAL)? EVENTS (IN filename = STRING_LITERAL)? ( + FROM fromPosition = decimalLiteral + )? limitClause? (FOR CHANNEL channelName = STRING_LITERAL)? # showRelayLogEvents + | SHOW showCommonEntity showFilter? # showObjectFilter + | SHOW FULL? columnsFormat = (COLUMNS | FIELDS) tableFormat = (FROM | IN) tableName ( + schemaFormat = (FROM | IN) uid + )? showFilter? # showColumns + | SHOW CREATE schemaFormat = (DATABASE | SCHEMA) ifNotExists? uid # showCreateDb + | SHOW CREATE namedEntity = (EVENT | FUNCTION | PROCEDURE | SEQUENCE | TABLE | TRIGGER | VIEW) fullId # showCreateFullIdObject + | SHOW CREATE PACKAGE BODY? fullId # showCreatePackage + | SHOW CREATE USER userName # showCreateUser + | SHOW ENGINE engineName engineOption = (STATUS | MUTEX) # showEngine + | SHOW INNODB STATUS # showInnoDBStatus + | SHOW showGlobalInfoClause # showGlobalInfo + | SHOW errorFormat = (ERRORS | WARNINGS) limitClause? # showErrors + | SHOW COUNT '(' '*' ')' errorFormat = (ERRORS | WARNINGS) # showCountErrors + | SHOW showSchemaEntity (schemaFormat = (FROM | IN) uid)? showFilter? # showSchemaFilter + | SHOW routine = (FUNCTION | PROCEDURE) CODE fullId # showRoutine + | SHOW GRANTS (FOR userName)? # showGrants + | SHOW indexFormat = (INDEX | INDEXES | KEYS) tableFormat = (FROM | IN) tableName ( + schemaFormat = (FROM | IN) uid + )? (WHERE expression)? # showIndexes + | SHOW OPEN TABLES (schemaFormat = (FROM | IN) fullId)? showFilter? # showOpenTables + | SHOW PROFILE (showProfileType (',' showProfileType)*)? ( + FOR QUERY queryCount = decimalLiteral + )? limitClause? # showProfile + | SHOW (SLAVE | REPLICA) (connectionName = STRING_LITERAL)? STATUS ( + FOR CHANNEL channelName = STRING_LITERAL + )? # showSlaveStatus | SHOW (USER_STATISTICS | CLIENT_STATISTICS | INDEX_STATISTICS | TABLE_STATISTICS) # showUserstatPlugin - | SHOW EXPLAIN formatJsonStatement? FOR decimalLiteral #showExplain - | SHOW PACKAGE BODY? STATUS showFilter? #showPackageStatus + | SHOW EXPLAIN formatJsonStatement? FOR decimalLiteral # showExplain + | SHOW PACKAGE BODY? STATUS showFilter? # showPackageStatus ; explainStatement - : EXPLAIN formatJsonStatement? FOR CONNECTION decimalLiteral #explainForConnection + : EXPLAIN formatJsonStatement? FOR CONNECTION decimalLiteral # explainForConnection ; // details variableClause - : LOCAL_ID | GLOBAL_ID | ( ('@' '@')? (GLOBAL | SESSION | LOCAL) )? uid + : LOCAL_ID + | GLOBAL_ID + | ( ('@' '@')? (GLOBAL | SESSION | LOCAL))? uid ; showCommonEntity - : CHARACTER SET | COLLATION | DATABASES | SCHEMAS - | FUNCTION STATUS | PROCEDURE STATUS + : CHARACTER SET + | COLLATION + | DATABASES + | SCHEMAS + | FUNCTION STATUS + | PROCEDURE STATUS | (GLOBAL | SESSION)? (STATUS | VARIABLES) ; @@ -1945,23 +1881,42 @@ showFilter ; showGlobalInfoClause - : STORAGE? ENGINES | (MASTER | BINLOG) STATUS | PLUGINS (SONAME (STRING_LITERAL | showFilter) )? - | PRIVILEGES | FULL? PROCESSLIST | PROFILES | LOCALES - | (SLAVE | REPLICA) HOSTS | AUTHORS | CONTRIBUTORS | QUERY_RESPONSE_TIME + : STORAGE? ENGINES + | (MASTER | BINLOG) STATUS + | PLUGINS (SONAME (STRING_LITERAL | showFilter))? + | PRIVILEGES + | FULL? PROCESSLIST + | PROFILES + | LOCALES + | (SLAVE | REPLICA) HOSTS + | AUTHORS + | CONTRIBUTORS + | QUERY_RESPONSE_TIME | ALL (SLAVES | REPLICAS) STATUS - | WSREP_MEMBERSHIP | WSREP_STATUS | TABLE TYPES + | WSREP_MEMBERSHIP + | WSREP_STATUS + | TABLE TYPES ; showSchemaEntity - : EVENTS | TABLE STATUS | FULL? TABLES | TRIGGERS + : EVENTS + | TABLE STATUS + | FULL? TABLES + | TRIGGERS ; showProfileType - : ALL | BLOCK IO | CONTEXT SWITCHES | CPU | IPC | MEMORY - | PAGE FAULTS | SOURCE | SWAPS + : ALL + | BLOCK IO + | CONTEXT SWITCHES + | CPU + | IPC + | MEMORY + | PAGE FAULTS + | SOURCE + | SWAPS ; - // Other administrative statements binlogStatement @@ -1969,24 +1924,20 @@ binlogStatement ; cacheIndexStatement - : CACHE INDEX tableIndexes (',' tableIndexes)* - ( PARTITION '(' (uidList | ALL) ')' )? - IN schema=uid + : CACHE INDEX tableIndexes (',' tableIndexes)* (PARTITION '(' (uidList | ALL) ')')? IN schema = uid ; flushStatement - : FLUSH flushFormat=(NO_WRITE_TO_BINLOG | LOCAL)? - flushOption (',' flushOption)* + : FLUSH flushFormat = (NO_WRITE_TO_BINLOG | LOCAL)? flushOption (',' flushOption)* | FLUSH (USER_STATISTICS | CLIENT_STATISTICS | INDEX_STATISTICS | TABLE_STATISTICS) ; killStatement - : KILL connectionFormat=(CONNECTION | QUERY)? expression + : KILL connectionFormat = (CONNECTION | QUERY)? expression ; loadIndexIntoCache - : LOAD INDEX INTO CACHE - loadedTableIndexes (',' loadedTableIndexes)* + : LOAD INDEX INTO CACHE loadedTableIndexes (',' loadedTableIndexes)* ; // remark reset (maser | slave) describe in replication's @@ -2002,20 +1953,23 @@ shutdownStatement // details tableIndexes - : tableName ( indexFormat=(INDEX | KEY)? '(' uidList ')' )? + : tableName (indexFormat = (INDEX | KEY)? '(' uidList ')')? ; flushOption : ( - DES_KEY_FILE | HOSTS - | ( - BINARY | ENGINE | ERROR | GENERAL | RELAY | SLOW - )? LOGS - | OPTIMIZER_COSTS | PRIVILEGES | QUERY CACHE | STATUS - | USER_RESOURCES | TABLES (WITH READ LOCK)? - ) #simpleFlushOption - | RELAY LOGS channelOption? #channelFlushOption - | (TABLE | TABLES) tables? flushTableOption? #tableFlushOption + DES_KEY_FILE + | HOSTS + | ( BINARY | ENGINE | ERROR | GENERAL | RELAY | SLOW)? LOGS + | OPTIMIZER_COSTS + | PRIVILEGES + | QUERY CACHE + | STATUS + | USER_RESOURCES + | TABLES (WITH READ LOCK)? + ) # simpleFlushOption + | RELAY LOGS channelOption? # channelFlushOption + | (TABLE | TABLES) tables? flushTableOption? # tableFlushOption ; flushTableOption @@ -2024,35 +1978,25 @@ flushTableOption ; loadedTableIndexes - : tableName - ( PARTITION '(' (partitionList=uidList | ALL) ')' )? - ( indexFormat=(INDEX | KEY)? '(' indexList=uidList ')' )? - (IGNORE LEAVES)? + : tableName (PARTITION '(' (partitionList = uidList | ALL) ')')? ( + indexFormat = (INDEX | KEY)? '(' indexList = uidList ')' + )? (IGNORE LEAVES)? ; - // Utility Statements - simpleDescribeStatement - : command=(EXPLAIN | DESCRIBE | DESC) tableName - (column=uid | pattern=STRING_LITERAL)? + : command = (EXPLAIN | DESCRIBE | DESC) tableName (column = uid | pattern = STRING_LITERAL)? ; fullDescribeStatement - : command=(EXPLAIN | DESCRIBE | DESC) - ( - formatType=(EXTENDED | PARTITIONS | FORMAT ) - '=' - formatValue=(TRADITIONAL | JSON) - )? - describeObjectClause + : command = (EXPLAIN | DESCRIBE | DESC) ( + formatType = (EXTENDED | PARTITIONS | FORMAT) '=' formatValue = (TRADITIONAL | JSON) + )? describeObjectClause ; formatJsonStatement - : FORMAT - '=' - formatValue=JSON + : FORMAT '=' formatValue = JSON ; helpStatement @@ -2064,36 +2008,43 @@ useStatement ; signalStatement - : SIGNAL ( ( SQLSTATE VALUE? stringLiteral ) | ID | REVERSE_QUOTE_ID ) - ( SET signalConditionInformation ( ',' signalConditionInformation)* )? + : SIGNAL (( SQLSTATE VALUE? stringLiteral) | ID | REVERSE_QUOTE_ID) ( + SET signalConditionInformation ( ',' signalConditionInformation)* + )? ; resignalStatement - : RESIGNAL ( ( SQLSTATE VALUE? stringLiteral ) | ID | REVERSE_QUOTE_ID )? - ( SET signalConditionInformation ( ',' signalConditionInformation)* )? + : RESIGNAL (( SQLSTATE VALUE? stringLiteral) | ID | REVERSE_QUOTE_ID)? ( + SET signalConditionInformation ( ',' signalConditionInformation)* + )? ; signalConditionInformation - : ( CLASS_ORIGIN - | SUBCLASS_ORIGIN - | MESSAGE_TEXT - | MYSQL_ERRNO - | CONSTRAINT_CATALOG - | CONSTRAINT_SCHEMA - | CONSTRAINT_NAME - | CATALOG_NAME - | SCHEMA_NAME - | TABLE_NAME - | COLUMN_NAME - | CURSOR_NAME - ) '=' ( stringLiteral | DECIMAL_LITERAL | mysqlVariable | simpleId ) + : ( + CLASS_ORIGIN + | SUBCLASS_ORIGIN + | MESSAGE_TEXT + | MYSQL_ERRNO + | CONSTRAINT_CATALOG + | CONSTRAINT_SCHEMA + | CONSTRAINT_NAME + | CATALOG_NAME + | SCHEMA_NAME + | TABLE_NAME + | COLUMN_NAME + | CURSOR_NAME + ) '=' (stringLiteral | DECIMAL_LITERAL | mysqlVariable | simpleId) ; diagnosticsStatement - : GET ( CURRENT | STACKED )? DIAGNOSTICS ( - ( variableClause '=' ( NUMBER | ROW_COUNT ) ( ',' variableClause '=' ( NUMBER | ROW_COUNT ) )* ) - | ( CONDITION ( decimalLiteral | variableClause ) variableClause '=' diagnosticsConditionInformationName ( ',' variableClause '=' diagnosticsConditionInformationName )* ) - ) + : GET (CURRENT | STACKED)? DIAGNOSTICS ( + (variableClause '=' ( NUMBER | ROW_COUNT) ( ',' variableClause '=' ( NUMBER | ROW_COUNT))*) + | ( + CONDITION (decimalLiteral | variableClause) variableClause '=' diagnosticsConditionInformationName ( + ',' variableClause '=' diagnosticsConditionInformationName + )* + ) + ) ; diagnosticsConditionInformationName @@ -2115,14 +2066,10 @@ diagnosticsConditionInformationName // details describeObjectClause - : ( - selectStatement | deleteStatement | insertStatement - | replaceStatement | updateStatement - ) #describeStatements - | FOR CONNECTION uid #describeConnection + : (selectStatement | deleteStatement | insertStatement | replaceStatement | updateStatement) # describeStatements + | FOR CONNECTION uid # describeConnection ; - // Common Clauses // DB Objects @@ -2136,28 +2083,35 @@ tableName ; roleName - : userName | uid + : userName + | uid ; fullColumnName - : uid (dottedId dottedId? )? + : uid (dottedId dottedId?)? | . dottedId dottedId? ; indexColumnName - : ((uid | STRING_LITERAL) ('(' decimalLiteral ')')? | expression) sortType=(ASC | DESC)? + : ((uid | STRING_LITERAL) ('(' decimalLiteral ')')? | expression) sortType = (ASC | DESC)? ; simpleUserName : STRING_LITERAL | ID | ADMIN - | keywordsCanBeId; -hostName: (LOCAL_ID | HOST_IP_ADDRESS | '@' ); + | keywordsCanBeId + ; + +hostName + : (LOCAL_ID | HOST_IP_ADDRESS | '@') + ; + userName : simpleUserName | simpleUserName hostName - | currentUserExpression; + | currentUserExpression + ; mysqlVariable : LOCAL_ID @@ -2172,7 +2126,9 @@ charsetName ; collationName - : uid | STRING_LITERAL; + : uid + | STRING_LITERAL + ; engineName : engineNameBase @@ -2181,8 +2137,19 @@ engineName ; engineNameBase - : ARCHIVE | BLACKHOLE | CONNECT | CSV | FEDERATED | INNODB | MEMORY - | MRG_MYISAM | MYISAM | NDB | NDBCLUSTER | PERFORMANCE_SCHEMA | TOKUDB + : ARCHIVE + | BLACKHOLE + | CONNECT + | CSV + | FEDERATED + | INNODB + | MEMORY + | MRG_MYISAM + | MYISAM + | NDB + | NDBCLUSTER + | PERFORMANCE_SCHEMA + | TOKUDB ; // MariaDB @@ -2192,17 +2159,13 @@ encryptedLiteral ; uuidSet - : decimalLiteral '-' decimalLiteral '-' decimalLiteral - '-' decimalLiteral '-' decimalLiteral - (':' decimalLiteral '-' decimalLiteral)+ + : decimalLiteral '-' decimalLiteral '-' decimalLiteral '-' decimalLiteral '-' decimalLiteral ( + ':' decimalLiteral '-' decimalLiteral + )+ ; xid - : globalTableUid=xuidStringId - ( - ',' qualifier=xuidStringId - (',' idFormat=decimalLiteral)? - )? + : globalTableUid = xuidStringId (',' qualifier = xuidStringId (',' idFormat = decimalLiteral)?)? ; xuidStringId @@ -2212,7 +2175,8 @@ xuidStringId ; authPlugin - : uid | STRING_LITERAL + : uid + | STRING_LITERAL ; uid @@ -2240,95 +2204,106 @@ dottedId | '.' uid ; - // Literals decimalLiteral - : DECIMAL_LITERAL | ZERO_DECIMAL | ONE_DECIMAL | TWO_DECIMAL | REAL_LITERAL + : DECIMAL_LITERAL + | ZERO_DECIMAL + | ONE_DECIMAL + | TWO_DECIMAL + | REAL_LITERAL ; fileSizeLiteral - : FILESIZE_LITERAL | decimalLiteral; + : FILESIZE_LITERAL + | decimalLiteral + ; stringLiteral - : ( - STRING_CHARSET_NAME? STRING_LITERAL - | START_NATIONAL_STRING_LITERAL - ) STRING_LITERAL+ - | ( - STRING_CHARSET_NAME? STRING_LITERAL - | START_NATIONAL_STRING_LITERAL - ) (COLLATE collationName)? + : (STRING_CHARSET_NAME? STRING_LITERAL | START_NATIONAL_STRING_LITERAL) STRING_LITERAL+ + | (STRING_CHARSET_NAME? STRING_LITERAL | START_NATIONAL_STRING_LITERAL) (COLLATE collationName)? ; booleanLiteral - : TRUE | FALSE; + : TRUE + | FALSE + ; hexadecimalLiteral - : STRING_CHARSET_NAME? HEXADECIMAL_LITERAL; + : STRING_CHARSET_NAME? HEXADECIMAL_LITERAL + ; nullNotnull : NOT? (NULL_LITERAL | NULL_SPEC_LITERAL) ; constant - : stringLiteral | decimalLiteral + : stringLiteral + | decimalLiteral | '-' decimalLiteral - | hexadecimalLiteral | booleanLiteral - | REAL_LITERAL | BIT_STRING - | NOT? nullLiteral=(NULL_LITERAL | NULL_SPEC_LITERAL) + | hexadecimalLiteral + | booleanLiteral + | REAL_LITERAL + | BIT_STRING + | NOT? nullLiteral = (NULL_LITERAL | NULL_SPEC_LITERAL) ; - // Data Types dataType - : typeName=( - CHAR | CHARACTER | VARCHAR | TINYTEXT | TEXT | MEDIUMTEXT | LONGTEXT - | NCHAR | NVARCHAR | LONG - ) - VARYING? - lengthOneDimension? BINARY? - (charSet charsetName)? - (COLLATE collationName | BINARY)? #stringDataType - | NATIONAL typeName=(VARCHAR | CHARACTER) - lengthOneDimension? BINARY? #nationalStringDataType - | NCHAR typeName=VARCHAR - lengthOneDimension? BINARY? #nationalStringDataType - | NATIONAL typeName=(CHAR | CHARACTER) VARYING - lengthOneDimension? BINARY? #nationalVaryingStringDataType - | typeName=( - TINYINT | SMALLINT | MEDIUMINT | INT | INTEGER | BIGINT - | MIDDLEINT | INT1 | INT2 | INT3 | INT4 | INT8 - ) - lengthOneDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=REAL - lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=DOUBLE PRECISION? - lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=(DECIMAL | DEC | FIXED | NUMERIC | FLOAT | FLOAT4 | FLOAT8) - lengthTwoOptionalDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=( - DATE | TINYBLOB | MEDIUMBLOB | LONGBLOB - | BOOL | BOOLEAN | SERIAL - ) #simpleDataType - | typeName=( - BIT | TIME | TIMESTAMP | DATETIME | BINARY - | VARBINARY | BLOB | YEAR - ) - lengthOneDimension? #dimensionDataType - | typeName=(ENUM | SET) - collectionOptions BINARY? - (charSet charsetName)? #collectionDataType - | typeName=( - GEOMETRYCOLLECTION | GEOMCOLLECTION | LINESTRING | MULTILINESTRING - | MULTIPOINT | MULTIPOLYGON | POINT | POLYGON | JSON | GEOMETRY - ) #spatialDataType - | typeName=LONG VARCHAR? - BINARY? - (charSet charsetName)? - (COLLATE collationName)? #longVarcharDataType // LONG VARCHAR is the same as LONG - | LONG VARBINARY #longVarbinaryDataType + : typeName = ( + CHAR + | CHARACTER + | VARCHAR + | TINYTEXT + | TEXT + | MEDIUMTEXT + | LONGTEXT + | NCHAR + | NVARCHAR + | LONG + ) VARYING? lengthOneDimension? BINARY? (charSet charsetName)? (COLLATE collationName | BINARY)? # stringDataType + | NATIONAL typeName = (VARCHAR | CHARACTER) lengthOneDimension? BINARY? # nationalStringDataType + | NCHAR typeName = VARCHAR lengthOneDimension? BINARY? # nationalStringDataType + | NATIONAL typeName = (CHAR | CHARACTER) VARYING lengthOneDimension? BINARY? # nationalVaryingStringDataType + | typeName = ( + TINYINT + | SMALLINT + | MEDIUMINT + | INT + | INTEGER + | BIGINT + | MIDDLEINT + | INT1 + | INT2 + | INT3 + | INT4 + | INT8 + ) lengthOneDimension? (SIGNED | UNSIGNED | ZEROFILL)* # dimensionDataType + | typeName = REAL lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* # dimensionDataType + | typeName = DOUBLE PRECISION? lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* # dimensionDataType + | typeName = (DECIMAL | DEC | FIXED | NUMERIC | FLOAT | FLOAT4 | FLOAT8) lengthTwoOptionalDimension? ( + SIGNED + | UNSIGNED + | ZEROFILL + )* # dimensionDataType + | typeName = (DATE | TINYBLOB | MEDIUMBLOB | LONGBLOB | BOOL | BOOLEAN | SERIAL) # simpleDataType + | typeName = (BIT | TIME | TIMESTAMP | DATETIME | BINARY | VARBINARY | BLOB | YEAR) lengthOneDimension? # dimensionDataType + | typeName = (ENUM | SET) collectionOptions BINARY? (charSet charsetName)? # collectionDataType + | typeName = ( + GEOMETRYCOLLECTION + | GEOMCOLLECTION + | LINESTRING + | MULTILINESTRING + | MULTIPOINT + | MULTIPOLYGON + | POINT + | POLYGON + | JSON + | GEOMETRY + ) # spatialDataType + | typeName = LONG VARCHAR? BINARY? (charSet charsetName)? (COLLATE collationName)? # longVarcharDataType // LONG VARCHAR is the same as LONG + | LONG VARBINARY # longVarbinaryDataType ; collectionOptions @@ -2336,13 +2311,12 @@ collectionOptions ; convertedDataType - : - ( - typeName=(BINARY| NCHAR) lengthOneDimension? - | typeName=CHAR lengthOneDimension? (charSet charsetName)? - | typeName=(DATE | DATETIME | TIME | JSON | INT | INTEGER) - | typeName=DECIMAL lengthTwoOptionalDimension? - | (SIGNED | UNSIGNED) INTEGER? + : ( + typeName = (BINARY | NCHAR) lengthOneDimension? + | typeName = CHAR lengthOneDimension? (charSet charsetName)? + | typeName = (DATE | DATETIME | TIME | JSON | INT | INTEGER) + | typeName = DECIMAL lengthTwoOptionalDimension? + | (SIGNED | UNSIGNED) INTEGER? ) ARRAY? ; @@ -2358,7 +2332,6 @@ lengthTwoOptionalDimension : '(' decimalLiteral (',' decimalLiteral)? ')' ; - // Common Lists uidList @@ -2393,7 +2366,6 @@ userVariables : LOCAL_ID (',' LOCAL_ID)* ; - // Common Expressons defaultValue @@ -2404,21 +2376,20 @@ defaultValue | '(' expression ')' | (LASTVAL | NEXTVAL) '(' fullId ')' // MariaDB-specific | '(' (PREVIOUS | NEXT) VALUE FOR fullId ')' // MariaDB-specific - | expression // MariaDB + | expression // MariaDB ; currentTimestamp - : - ( - (CURRENT_TIMESTAMP | LOCALTIME | LOCALTIMESTAMP - | CURDATE | CURTIME) // MariaDB-specific - ('(' decimalLiteral? ')')? - | NOW '(' decimalLiteral? ')' + : ( + (CURRENT_TIMESTAMP | LOCALTIME | LOCALTIMESTAMP | CURDATE | CURTIME) // MariaDB-specific + ('(' decimalLiteral? ')')? + | NOW '(' decimalLiteral? ')' ) ; expressionOrDefault - : expression | DEFAULT + : expression + | DEFAULT ; ifExists @@ -2448,149 +2419,98 @@ lockOption // Functions functionCall - : specificFunction #specificFunctionCall - | aggregateWindowedFunction #aggregateFunctionCall - | nonAggregateWindowedFunction #nonAggregateFunctionCall - | scalarFunctionName '(' functionArgs? ')' #scalarFunctionCall - | fullId '(' functionArgs? ')' #udfFunctionCall - | passwordFunctionClause #passwordFunctionCall + : specificFunction # specificFunctionCall + | aggregateWindowedFunction # aggregateFunctionCall + | nonAggregateWindowedFunction # nonAggregateFunctionCall + | scalarFunctionName '(' functionArgs? ')' # scalarFunctionCall + | fullId '(' functionArgs? ')' # udfFunctionCall + | passwordFunctionClause # passwordFunctionCall ; specificFunction : ( - CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP - | CURDATE | CURTIME // MariaDB-specific only - | CURRENT_USER | LOCALTIME | UTC_TIMESTAMP | SCHEMA - ) ('(' ')')? #simpleFunctionCall - | CONVERT '(' expression separator=',' convertedDataType ')' #dataTypeFunctionCall - | CONVERT '(' expression USING charsetName ')' #dataTypeFunctionCall - | CAST '(' expression AS convertedDataType ')' #dataTypeFunctionCall - | VALUES '(' fullColumnName ')' #valuesFunctionCall - | CASE expression caseFuncAlternative+ - (ELSE elseArg=functionArg)? END #caseExpressionFunctionCall - | CASE caseFuncAlternative+ - (ELSE elseArg=functionArg)? END #caseFunctionCall - | CHAR '(' functionArgs (USING charsetName)? ')' #charFunctionCall - | POSITION - '(' - ( - positionString=stringLiteral - | positionExpression=expression - ) - IN - ( - inString=stringLiteral - | inExpression=expression - ) - ')' #positionFunctionCall - | (SUBSTR | SUBSTRING) - '(' - ( - sourceString=stringLiteral - | sourceExpression=expression - ) FROM - ( - fromDecimal=decimalLiteral - | fromExpression=expression - ) - ( - FOR - ( - forDecimal=decimalLiteral - | forExpression=expression - ) - )? - ')' #substrFunctionCall - | TRIM - '(' - positioinForm=(BOTH | LEADING | TRAILING) - ( - sourceString=stringLiteral - | sourceExpression=expression - )? - FROM - ( - fromString=stringLiteral - | fromExpression=expression - ) - ')' #trimFunctionCall - | TRIM - '(' - ( - sourceString=stringLiteral - | sourceExpression=expression - ) - FROM - ( - fromString=stringLiteral - | fromExpression=expression - ) - ')' #trimFunctionCall - | WEIGHT_STRING - '(' - (stringLiteral | expression) - (AS stringFormat=(CHAR | BINARY) - '(' decimalLiteral ')' )? levelsInWeightString? - ')' #weightFunctionCall - | EXTRACT - '(' - intervalType - FROM - ( - sourceString=stringLiteral - | sourceExpression=expression - ) - ')' #extractFunctionCall - | GET_FORMAT - '(' - datetimeFormat=(DATE | TIME | DATETIME) - ',' stringLiteral - ')' #getFormatFunctionCall - | JSON_VALUE - '(' expression - ',' expression - (RETURNING convertedDataType)? - jsonOnEmpty? - jsonOnError? - ')' #jsonValueFunctionCall + CURRENT_DATE + | CURRENT_TIME + | CURRENT_TIMESTAMP + | CURDATE + | CURTIME // MariaDB-specific only + | CURRENT_USER + | LOCALTIME + | UTC_TIMESTAMP + | SCHEMA + ) ('(' ')')? # simpleFunctionCall + | CONVERT '(' expression separator = ',' convertedDataType ')' # dataTypeFunctionCall + | CONVERT '(' expression USING charsetName ')' # dataTypeFunctionCall + | CAST '(' expression AS convertedDataType ')' # dataTypeFunctionCall + | VALUES '(' fullColumnName ')' # valuesFunctionCall + | CASE expression caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseExpressionFunctionCall + | CASE caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseFunctionCall + | CHAR '(' functionArgs (USING charsetName)? ')' # charFunctionCall + | POSITION '(' (positionString = stringLiteral | positionExpression = expression) IN ( + inString = stringLiteral + | inExpression = expression + ) ')' # positionFunctionCall + | (SUBSTR | SUBSTRING) '(' (sourceString = stringLiteral | sourceExpression = expression) FROM ( + fromDecimal = decimalLiteral + | fromExpression = expression + ) (FOR ( forDecimal = decimalLiteral | forExpression = expression))? ')' # substrFunctionCall + | TRIM '(' positioinForm = (BOTH | LEADING | TRAILING) ( + sourceString = stringLiteral + | sourceExpression = expression + )? FROM (fromString = stringLiteral | fromExpression = expression) ')' # trimFunctionCall + | TRIM '(' (sourceString = stringLiteral | sourceExpression = expression) FROM ( + fromString = stringLiteral + | fromExpression = expression + ) ')' # trimFunctionCall + | WEIGHT_STRING '(' (stringLiteral | expression) ( + AS stringFormat = (CHAR | BINARY) '(' decimalLiteral ')' + )? levelsInWeightString? ')' # weightFunctionCall + | EXTRACT '(' intervalType FROM (sourceString = stringLiteral | sourceExpression = expression) ')' # extractFunctionCall + | GET_FORMAT '(' datetimeFormat = (DATE | TIME | DATETIME) ',' stringLiteral ')' # getFormatFunctionCall + | JSON_VALUE '(' expression ',' expression (RETURNING convertedDataType)? jsonOnEmpty? jsonOnError? ')' # jsonValueFunctionCall ; caseFuncAlternative - : WHEN condition=functionArg - THEN consequent=functionArg + : WHEN condition = functionArg THEN consequent = functionArg ; levelsInWeightString - : LEVEL levelInWeightListElement - (',' levelInWeightListElement)* #levelWeightList - | LEVEL - firstLevel=decimalLiteral '-' lastLevel=decimalLiteral #levelWeightRange + : LEVEL levelInWeightListElement (',' levelInWeightListElement)* # levelWeightList + | LEVEL firstLevel = decimalLiteral '-' lastLevel = decimalLiteral # levelWeightRange ; levelInWeightListElement - : decimalLiteral orderType=(ASC | DESC | REVERSE)? + : decimalLiteral orderType = (ASC | DESC | REVERSE)? ; aggregateWindowedFunction - : (AVG | MAX | MIN | SUM) - '(' aggregator=(ALL | DISTINCT)? functionArg ')' overClause? - | COUNT '(' (starArg='*' | aggregator=ALL? functionArg | aggregator=DISTINCT functionArgs) ')' overClause? + : (AVG | MAX | MIN | SUM) '(' aggregator = (ALL | DISTINCT)? functionArg ')' overClause? + | COUNT '(' ( + starArg = '*' + | aggregator = ALL? functionArg + | aggregator = DISTINCT functionArgs + ) ')' overClause? | ( - BIT_AND | BIT_OR | BIT_XOR | STD | STDDEV | STDDEV_POP - | STDDEV_SAMP | VAR_POP | VAR_SAMP | VARIANCE - ) '(' aggregator=ALL? functionArg ')' overClause? - | GROUP_CONCAT '(' - aggregator=DISTINCT? functionArgs - (ORDER BY - orderByExpression (',' orderByExpression)* - )? (SEPARATOR separator=STRING_LITERAL)? - ')' + BIT_AND + | BIT_OR + | BIT_XOR + | STD + | STDDEV + | STDDEV_POP + | STDDEV_SAMP + | VAR_POP + | VAR_SAMP + | VARIANCE + ) '(' aggregator = ALL? functionArg ')' overClause? + | GROUP_CONCAT '(' aggregator = DISTINCT? functionArgs ( + ORDER BY orderByExpression (',' orderByExpression)* + )? (SEPARATOR separator = STRING_LITERAL)? ')' ; nonAggregateWindowedFunction : (LAG | LEAD) '(' expression (',' decimalLiteral)? (',' decimalLiteral)? ')' overClause | (FIRST_VALUE | LAST_VALUE) '(' expression ')' overClause - | (CUME_DIST | DENSE_RANK | PERCENT_RANK | RANK | ROW_NUMBER) '('')' overClause + | (CUME_DIST | DENSE_RANK | PERCENT_RANK | RANK | ROW_NUMBER) '(' ')' overClause | NTH_VALUE '(' expression ',' decimalLiteral ')' overClause | NTILE '(' decimalLiteral ')' overClause ; @@ -2637,291 +2557,1050 @@ partitionClause scalarFunctionName : functionNameBase - | ASCII | CURDATE | CURRENT_DATE | CURRENT_TIME - | CURRENT_TIMESTAMP | CURTIME | DATE_ADD | DATE_SUB - | IF | INSERT | LOCALTIME | LOCALTIMESTAMP | MID | NOW - | REPLACE | SUBSTR | SUBSTRING | SYSDATE | TRIM - | UTC_DATE | UTC_TIME | UTC_TIMESTAMP + | ASCII + | CURDATE + | CURRENT_DATE + | CURRENT_TIME + | CURRENT_TIMESTAMP + | CURTIME + | DATE_ADD + | DATE_SUB + | IF + | INSERT + | LOCALTIME + | LOCALTIMESTAMP + | MID + | NOW + | REPLACE + | SUBSTR + | SUBSTRING + | SYSDATE + | TRIM + | UTC_DATE + | UTC_TIME + | UTC_TIMESTAMP ; passwordFunctionClause - : functionName=(PASSWORD | OLD_PASSWORD) '(' functionArg ')' + : functionName = (PASSWORD | OLD_PASSWORD) '(' functionArg ')' ; functionArgs - : (constant | fullColumnName | functionCall | expression) - ( - ',' - (constant | fullColumnName | functionCall | expression) + : (constant | fullColumnName | functionCall | expression) ( + ',' (constant | fullColumnName | functionCall | expression) )* ; functionArg - : constant | fullColumnName | functionCall | expression + : constant + | fullColumnName + | functionCall + | expression ; - // Expressions, predicates // Simplified approach for expression expression - : notOperator=(NOT | '!') expression #notExpression - | expression logicalOperator expression #logicalExpression - | predicate IS NOT? testValue=(TRUE | FALSE | UNKNOWN) #isExpression - | predicate #predicateExpression + : notOperator = (NOT | '!') expression # notExpression + | expression logicalOperator expression # logicalExpression + | predicate IS NOT? testValue = (TRUE | FALSE | UNKNOWN) # isExpression + | predicate # predicateExpression ; predicate - : predicate NOT? IN '(' (selectStatement | expressions) ')' #inPredicate - | predicate IS nullNotnull #isNullPredicate - | left=predicate comparisonOperator right=predicate #binaryComparisonPredicate - | predicate comparisonOperator - quantifier=(ALL | ANY | SOME) '(' selectStatement ')' #subqueryComparisonPredicate - | predicate NOT? BETWEEN predicate AND predicate #betweenPredicate - | predicate SOUNDS LIKE predicate #soundsLikePredicate - | predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)? #likePredicate - | predicate NOT? regex=(REGEXP | RLIKE) predicate #regexpPredicate - | predicate MEMBER OF '(' predicate ')' #jsonMemberOfPredicate - | expressionAtom #expressionAtomPredicate + : predicate NOT? IN '(' (selectStatement | expressions) ')' # inPredicate + | predicate IS nullNotnull # isNullPredicate + | left = predicate comparisonOperator right = predicate # binaryComparisonPredicate + | predicate comparisonOperator quantifier = (ALL | ANY | SOME) '(' selectStatement ')' # subqueryComparisonPredicate + | predicate NOT? BETWEEN predicate AND predicate # betweenPredicate + | predicate SOUNDS LIKE predicate # soundsLikePredicate + | predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)? # likePredicate + | predicate NOT? regex = (REGEXP | RLIKE) predicate # regexpPredicate + | predicate MEMBER OF '(' predicate ')' # jsonMemberOfPredicate + | expressionAtom # expressionAtomPredicate ; - // Add in ASTVisitor nullNotnull in constant expressionAtom - : constant #constantExpressionAtom - | fullColumnName #fullColumnNameExpressionAtom - | functionCall #functionCallExpressionAtom - | expressionAtom COLLATE collationName #collateExpressionAtom - | mysqlVariable #mysqlVariableExpressionAtom - | unaryOperator expressionAtom #unaryExpressionAtom - | BINARY expressionAtom #binaryExpressionAtom - | LOCAL_ID VAR_ASSIGN expressionAtom #variableAssignExpressionAtom - | '(' expression (',' expression)* ')' #nestedExpressionAtom - | ROW '(' expression (',' expression)+ ')' #nestedRowExpressionAtom - | EXISTS '(' selectStatement ')' #existsExpressionAtom - | '(' selectStatement ')' #subqueryExpressionAtom - | INTERVAL expression intervalType #intervalExpressionAtom - | left=expressionAtom bitOperator right=expressionAtom #bitExpressionAtom - | left=expressionAtom mathOperator right=expressionAtom #mathExpressionAtom - | left=expressionAtom jsonOperator right=expressionAtom #jsonExpressionAtom + : constant # constantExpressionAtom + | fullColumnName # fullColumnNameExpressionAtom + | functionCall # functionCallExpressionAtom + | expressionAtom COLLATE collationName # collateExpressionAtom + | mysqlVariable # mysqlVariableExpressionAtom + | unaryOperator expressionAtom # unaryExpressionAtom + | BINARY expressionAtom # binaryExpressionAtom + | LOCAL_ID VAR_ASSIGN expressionAtom # variableAssignExpressionAtom + | '(' expression (',' expression)* ')' # nestedExpressionAtom + | ROW '(' expression (',' expression)+ ')' # nestedRowExpressionAtom + | EXISTS '(' selectStatement ')' # existsExpressionAtom + | '(' selectStatement ')' # subqueryExpressionAtom + | INTERVAL expression intervalType # intervalExpressionAtom + | left = expressionAtom bitOperator right = expressionAtom # bitExpressionAtom + | left = expressionAtom mathOperator right = expressionAtom # mathExpressionAtom + | left = expressionAtom jsonOperator right = expressionAtom # jsonExpressionAtom ; unaryOperator - : '!' | '~' | '+' | '-' | NOT + : '!' + | '~' + | '+' + | '-' + | NOT ; comparisonOperator - : '=' | '>' | '<' | '<' '=' | '>' '=' - | '<' '>' | '!' '=' | '<' '=' '>' + : '=' + | '>' + | '<' + | '<' '=' + | '>' '=' + | '<' '>' + | '!' '=' + | '<' '=' '>' ; logicalOperator - : AND | '&' '&' | XOR | OR | '|' '|' + : AND + | '&' '&' + | XOR + | OR + | '|' '|' ; bitOperator - : '<' '<' | '>' '>' | '&' | '^' | '|' + : '<' '<' + | '>' '>' + | '&' + | '^' + | '|' ; mathOperator - : '*' | '/' | '%' | DIV | MOD | '+' | '-' + : '*' + | '/' + | '%' + | DIV + | MOD + | '+' + | '-' ; jsonOperator - : '-' '>' | '-' '>' '>' + : '-' '>' + | '-' '>' '>' ; // Simple id sets // (that keyword, which can be id) charsetNameBase - : ARMSCII8 | ASCII | BIG5 | BINARY | CP1250 | CP1251 | CP1256 | CP1257 - | CP850 | CP852 | CP866 | CP932 | DEC8 | EUCJPMS | EUCKR - | GB18030 | GB2312 | GBK | GEOSTD8 | GREEK | HEBREW | HP8 | KEYBCS2 - | KOI8R | KOI8U | LATIN1 | LATIN2 | LATIN5 | LATIN7 | MACCE - | MACROMAN | SJIS | SWE7 | TIS620 | UCS2 | UJIS | UTF16 - | UTF16LE | UTF32 | UTF8 | UTF8MB3 | UTF8MB4 + : ARMSCII8 + | ASCII + | BIG5 + | BINARY + | CP1250 + | CP1251 + | CP1256 + | CP1257 + | CP850 + | CP852 + | CP866 + | CP932 + | DEC8 + | EUCJPMS + | EUCKR + | GB18030 + | GB2312 + | GBK + | GEOSTD8 + | GREEK + | HEBREW + | HP8 + | KEYBCS2 + | KOI8R + | KOI8U + | LATIN1 + | LATIN2 + | LATIN5 + | LATIN7 + | MACCE + | MACROMAN + | SJIS + | SWE7 + | TIS620 + | UCS2 + | UJIS + | UTF16 + | UTF16LE + | UTF32 + | UTF8 + | UTF8MB3 + | UTF8MB4 ; transactionLevelBase - : REPEATABLE | COMMITTED | UNCOMMITTED | SERIALIZABLE + : REPEATABLE + | COMMITTED + | UNCOMMITTED + | SERIALIZABLE ; privilegesBase - : TABLES | ROUTINE | EXECUTE | FILE | PROCESS - | RELOAD | SHUTDOWN | SUPER | PRIVILEGES + : TABLES + | ROUTINE + | EXECUTE + | FILE + | PROCESS + | RELOAD + | SHUTDOWN + | SUPER + | PRIVILEGES ; intervalTypeBase - : QUARTER | MONTH | DAY | HOUR - | MINUTE | WEEK | SECOND | MICROSECOND + : QUARTER + | MONTH + | DAY + | HOUR + | MINUTE + | WEEK + | SECOND + | MICROSECOND ; dataTypeBase - : DATE | TIME | TIMESTAMP | DATETIME | YEAR | ENUM | TEXT + : DATE + | TIME + | TIMESTAMP + | DATETIME + | YEAR + | ENUM + | TEXT ; keywordsCanBeId - : ACCOUNT | ACTION | ADMIN | AFTER | AGGREGATE | ALGORITHM | ANY - | AT | AUDIT_ADMIN | AUTHORS | AUTOCOMMIT | AUTOEXTEND_SIZE - | AUTO_INCREMENT | AVG | AVG_ROW_LENGTH | ATTRIBUTE | BACKUP_ADMIN | BEGIN | BINLOG | BINLOG_ADMIN | BINLOG_ENCRYPTION_ADMIN | BIT | BIT_AND | BIT_OR | BIT_XOR - | BLOCK | BODY | BOOL | BOOLEAN | BTREE | BUCKETS | CACHE | CASCADED | CHAIN | CHANGED - | CHANNEL | CHECKSUM | PAGE_CHECKSUM | CATALOG_NAME | CIPHER - | CLASS_ORIGIN | CLIENT | CLONE_ADMIN | CLOSE | CLUSTERING | COALESCE | CODE - | COLUMNS | COLUMN_FORMAT | COLUMN_NAME | COMMENT | COMMIT | COMPACT - | COMPLETION | COMPRESSED | COMPRESSION | CONCURRENT | CONDITION | CONNECT - | CONNECTION | CONNECTION_ADMIN | CONSISTENT | CONSTRAINT_CATALOG | CONSTRAINT_NAME - | CONSTRAINT_SCHEMA | CONTAINS | CONTEXT - | CONTRIBUTORS | COPY | COUNT | CPU | CURRENT | CURRENT_USER | CURSOR_NAME - | DATA | DATAFILE | DEALLOCATE - | DEFAULT | DEFAULT_AUTH | DEFINER | DELAY_KEY_WRITE | DES_KEY_FILE | DIAGNOSTICS | DIRECTORY - | DISABLE | DISCARD | DISK | DO | DUMPFILE | DUPLICATE - | DYNAMIC | EMPTY | ENABLE | ENCRYPTION | ENCRYPTION_KEY_ADMIN | END | ENDS | ENGINE | ENGINE_ATTRIBUTE | ENGINES - | ERROR | ERRORS | ESCAPE | EUR | EVEN | EVENT | EVENTS | EVERY | EXCEPT - | EXCHANGE | EXCLUSIVE | EXPIRE | EXPORT | EXTENDED | EXTENT_SIZE | FAILED_LOGIN_ATTEMPTS | FAST | FAULTS - | FIELDS | FILE_BLOCK_SIZE | FILTER | FIREWALL_ADMIN | FIREWALL_USER | FIRST | FIXED | FLUSH - | FOLLOWS | FOUND | FULL | FUNCTION | GENERAL | GLOBAL | GRANTS | GROUP | GROUP_CONCAT - | GROUP_REPLICATION | GROUP_REPLICATION_ADMIN | HANDLER | HASH | HELP | HISTORY | HOST | HOSTS | IDENTIFIED - | IGNORED | IGNORE_SERVER_IDS | IMPORT | INDEXES | INITIAL_SIZE | INNODB_REDO_LOG_ARCHIVE - | INPLACE | INSERT_METHOD | INSTALL | INSTANCE | INSTANT | INTERNAL | INVOKE | INVOKER | IO - | IO_THREAD | IPC | ISO | ISOLATION | ISSUER | JIS | JSON | KEY_BLOCK_SIZE - | LAMBDA | LANGUAGE | LAST | LATERAL | LEAVES | LESS | LEVEL | LIST | LOCAL | LOCALES - | LOGFILE | LOGS | MASTER | MASTER_AUTO_POSITION - | MASTER_CONNECT_RETRY | MASTER_DELAY - | MASTER_HEARTBEAT_PERIOD | MASTER_HOST | MASTER_LOG_FILE - | MASTER_LOG_POS | MASTER_PASSWORD | MASTER_PORT - | MASTER_RETRY_COUNT | MASTER_SSL | MASTER_SSL_CA - | MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CIPHER - | MASTER_SSL_CRL | MASTER_SSL_CRLPATH | MASTER_SSL_KEY - | MASTER_TLS_VERSION | MASTER_USER - | MAX_CONNECTIONS_PER_HOUR | MAX_QUERIES_PER_HOUR - | MAX | MAX_ROWS | MAX_SIZE | MAX_UPDATES_PER_HOUR - | MAX_USER_CONNECTIONS | MEDIUM | MEMBER | MEMORY | MERGE | MESSAGE_TEXT - | MID | MIGRATE - | MIN | MIN_ROWS | MODE | MODIFY | MUTEX | MYSQL | MYSQL_ERRNO | NAME | NAMES - | NCHAR | NDB_STORED_USER | NESTED | NEVER | NEXT | NO | NOCOPY | NODEGROUP | NONE | NOWAIT | NUMBER | ODBC | OFFLINE | OFFSET - | OF | OJ | OLD_PASSWORD | ONE | ONLINE | ONLY | OPEN | OPTIMIZER_COSTS - | OPTIONAL | OPTIONS | ORDER | ORDINALITY | OWNER | PACKAGE | PACK_KEYS | PAGE | PARSER | PARTIAL - | PARTITIONING | PARTITIONS | PASSWORD | PASSWORDLESS_USER_ADMIN | PASSWORD_LOCK_TIME | PATH | PERSIST_RO_VARIABLES_ADMIN | PHASE | PLUGINS - | PLUGIN_DIR | PLUGIN | PORT | PRECEDES | PREPARE | PRESERVE | PREV | PRIMARY - | PROCESSLIST | PROFILE | PROFILES | PROXY | QUERY | QUERY_RESPONSE_TIME | QUICK - | REBUILD | RECOVER | RECURSIVE | REDO_BUFFER_SIZE | REDUNDANT - | RELAY | RELAYLOG | RELAY_LOG_FILE | RELAY_LOG_POS | REMOVE - | REORGANIZE | REPAIR | REPLICAS | REPLICATE_DO_DB | REPLICATE_DO_TABLE - | REPLICATE_IGNORE_DB | REPLICATE_IGNORE_TABLE - | REPLICATE_REWRITE_DB | REPLICATE_WILD_DO_TABLE - | REPLICATE_WILD_IGNORE_TABLE | REPLICATION | REPLICATION_APPLIER | REPLICATION_SLAVE_ADMIN | RESET - | RESOURCE_GROUP_ADMIN | RESOURCE_GROUP_USER | RESUME - | RETURNED_SQLSTATE | RETURNS | REUSE | ROLE | ROLE_ADMIN | ROLLBACK | ROLLUP | ROTATE | ROW | ROWS - | ROW_FORMAT | RTREE | S3 | SAVEPOINT | SCHEDULE | SCHEMA_NAME | SECURITY | SECONDARY_ENGINE_ATTRIBUTE | SERIAL | SERVER - | SESSION | SESSION_VARIABLES_ADMIN | SET_USER_ID | SHARE | SHARED | SHOW_ROUTINE | SIGNED | SIMPLE | SLAVE | SLAVES - | SLOW | SNAPSHOT | SOCKET | SOME | SONAME | SOUNDS | SOURCE - | SQL_AFTER_GTIDS | SQL_AFTER_MTS_GAPS | SQL_BEFORE_GTIDS - | SQL_BUFFER_RESULT | SQL_CACHE | SQL_NO_CACHE | SQL_THREAD - | STACKED | START | STARTS | STATS_AUTO_RECALC | STATS_PERSISTENT - | STATS_SAMPLE_PAGES | STATUS | STD | STDDEV | STDDEV_POP | STDDEV_SAMP | STOP | STORAGE | STRING - | SUBCLASS_ORIGIN | SUBJECT | SUBPARTITION | SUBPARTITIONS | SUM | SUSPEND | SWAPS - | SWITCHES | SYSTEM_VARIABLES_ADMIN | TABLE_NAME | TABLESPACE | TABLE_ENCRYPTION_ADMIN | TABLE_TYPE - | TEMPORARY | TEMPTABLE | THAN | TRADITIONAL - | TRANSACTION | TRANSACTIONAL | TRIGGERS | TRUNCATE | TYPES | UNBOUNDED | UNDEFINED | UNDOFILE - | UNDO_BUFFER_SIZE | UNINSTALL | UNKNOWN | UNTIL | UPGRADE | USA | USER | USE_FRM | USER_RESOURCES - | VALIDATION | VALUE | VAR_POP | VAR_SAMP | VARIABLES | VARIANCE | VERSION_TOKEN_ADMIN | VIEW | VIRTUAL - | WAIT | WARNINGS | WITHOUT | WORK | WRAPPER | WSREP_MEMBERSHIP | WSREP_STATUS | X509 | XA | XA_RECOVER_ADMIN | XML + : ACCOUNT + | ACTION + | ADMIN + | AFTER + | AGGREGATE + | ALGORITHM + | ANY + | AT + | AUDIT_ADMIN + | AUTHORS + | AUTOCOMMIT + | AUTOEXTEND_SIZE + | AUTO_INCREMENT + | AVG + | AVG_ROW_LENGTH + | ATTRIBUTE + | BACKUP_ADMIN + | BEGIN + | BINLOG + | BINLOG_ADMIN + | BINLOG_ENCRYPTION_ADMIN + | BIT + | BIT_AND + | BIT_OR + | BIT_XOR + | BLOCK + | BODY + | BOOL + | BOOLEAN + | BTREE + | BUCKETS + | CACHE + | CASCADED + | CHAIN + | CHANGED + | CHANNEL + | CHECKSUM + | PAGE_CHECKSUM + | CATALOG_NAME + | CIPHER + | CLASS_ORIGIN + | CLIENT + | CLONE_ADMIN + | CLOSE + | CLUSTERING + | COALESCE + | CODE + | COLUMNS + | COLUMN_FORMAT + | COLUMN_NAME + | COMMENT + | COMMIT + | COMPACT + | COMPLETION + | COMPRESSED + | COMPRESSION + | CONCURRENT + | CONDITION + | CONNECT + | CONNECTION + | CONNECTION_ADMIN + | CONSISTENT + | CONSTRAINT_CATALOG + | CONSTRAINT_NAME + | CONSTRAINT_SCHEMA + | CONTAINS + | CONTEXT + | CONTRIBUTORS + | COPY + | COUNT + | CPU + | CURRENT + | CURRENT_USER + | CURSOR_NAME + | DATA + | DATAFILE + | DEALLOCATE + | DEFAULT + | DEFAULT_AUTH + | DEFINER + | DELAY_KEY_WRITE + | DES_KEY_FILE + | DIAGNOSTICS + | DIRECTORY + | DISABLE + | DISCARD + | DISK + | DO + | DUMPFILE + | DUPLICATE + | DYNAMIC + | EMPTY + | ENABLE + | ENCRYPTION + | ENCRYPTION_KEY_ADMIN + | END + | ENDS + | ENGINE + | ENGINE_ATTRIBUTE + | ENGINES + | ERROR + | ERRORS + | ESCAPE + | EUR + | EVEN + | EVENT + | EVENTS + | EVERY + | EXCEPT + | EXCHANGE + | EXCLUSIVE + | EXPIRE + | EXPORT + | EXTENDED + | EXTENT_SIZE + | FAILED_LOGIN_ATTEMPTS + | FAST + | FAULTS + | FIELDS + | FILE_BLOCK_SIZE + | FILTER + | FIREWALL_ADMIN + | FIREWALL_USER + | FIRST + | FIXED + | FLUSH + | FOLLOWS + | FOUND + | FULL + | FUNCTION + | GENERAL + | GLOBAL + | GRANTS + | GROUP + | GROUP_CONCAT + | GROUP_REPLICATION + | GROUP_REPLICATION_ADMIN + | HANDLER + | HASH + | HELP + | HISTORY + | HOST + | HOSTS + | IDENTIFIED + | IGNORED + | IGNORE_SERVER_IDS + | IMPORT + | INDEXES + | INITIAL_SIZE + | INNODB_REDO_LOG_ARCHIVE + | INPLACE + | INSERT_METHOD + | INSTALL + | INSTANCE + | INSTANT + | INTERNAL + | INVOKE + | INVOKER + | IO + | IO_THREAD + | IPC + | ISO + | ISOLATION + | ISSUER + | JIS + | JSON + | KEY_BLOCK_SIZE + | LAMBDA + | LANGUAGE + | LAST + | LATERAL + | LEAVES + | LESS + | LEVEL + | LIST + | LOCAL + | LOCALES + | LOGFILE + | LOGS + | MASTER + | MASTER_AUTO_POSITION + | MASTER_CONNECT_RETRY + | MASTER_DELAY + | MASTER_HEARTBEAT_PERIOD + | MASTER_HOST + | MASTER_LOG_FILE + | MASTER_LOG_POS + | MASTER_PASSWORD + | MASTER_PORT + | MASTER_RETRY_COUNT + | MASTER_SSL + | MASTER_SSL_CA + | MASTER_SSL_CAPATH + | MASTER_SSL_CERT + | MASTER_SSL_CIPHER + | MASTER_SSL_CRL + | MASTER_SSL_CRLPATH + | MASTER_SSL_KEY + | MASTER_TLS_VERSION + | MASTER_USER + | MAX_CONNECTIONS_PER_HOUR + | MAX_QUERIES_PER_HOUR + | MAX + | MAX_ROWS + | MAX_SIZE + | MAX_UPDATES_PER_HOUR + | MAX_USER_CONNECTIONS + | MEDIUM + | MEMBER + | MEMORY + | MERGE + | MESSAGE_TEXT + | MID + | MIGRATE + | MIN + | MIN_ROWS + | MODE + | MODIFY + | MUTEX + | MYSQL + | MYSQL_ERRNO + | NAME + | NAMES + | NCHAR + | NDB_STORED_USER + | NESTED + | NEVER + | NEXT + | NO + | NOCOPY + | NODEGROUP + | NONE + | NOWAIT + | NUMBER + | ODBC + | OFFLINE + | OFFSET + | OF + | OJ + | OLD_PASSWORD + | ONE + | ONLINE + | ONLY + | OPEN + | OPTIMIZER_COSTS + | OPTIONAL + | OPTIONS + | ORDER + | ORDINALITY + | OWNER + | PACKAGE + | PACK_KEYS + | PAGE + | PARSER + | PARTIAL + | PARTITIONING + | PARTITIONS + | PASSWORD + | PASSWORDLESS_USER_ADMIN + | PASSWORD_LOCK_TIME + | PATH + | PERSIST_RO_VARIABLES_ADMIN + | PHASE + | PLUGINS + | PLUGIN_DIR + | PLUGIN + | PORT + | PRECEDES + | PREPARE + | PRESERVE + | PREV + | PRIMARY + | PROCESSLIST + | PROFILE + | PROFILES + | PROXY + | QUERY + | QUERY_RESPONSE_TIME + | QUICK + | REBUILD + | RECOVER + | RECURSIVE + | REDO_BUFFER_SIZE + | REDUNDANT + | RELAY + | RELAYLOG + | RELAY_LOG_FILE + | RELAY_LOG_POS + | REMOVE + | REORGANIZE + | REPAIR + | REPLICAS + | REPLICATE_DO_DB + | REPLICATE_DO_TABLE + | REPLICATE_IGNORE_DB + | REPLICATE_IGNORE_TABLE + | REPLICATE_REWRITE_DB + | REPLICATE_WILD_DO_TABLE + | REPLICATE_WILD_IGNORE_TABLE + | REPLICATION + | REPLICATION_APPLIER + | REPLICATION_SLAVE_ADMIN + | RESET + | RESOURCE_GROUP_ADMIN + | RESOURCE_GROUP_USER + | RESUME + | RETURNED_SQLSTATE + | RETURNS + | REUSE + | ROLE + | ROLE_ADMIN + | ROLLBACK + | ROLLUP + | ROTATE + | ROW + | ROWS + | ROW_FORMAT + | RTREE + | S3 + | SAVEPOINT + | SCHEDULE + | SCHEMA_NAME + | SECURITY + | SECONDARY_ENGINE_ATTRIBUTE + | SERIAL + | SERVER + | SESSION + | SESSION_VARIABLES_ADMIN + | SET_USER_ID + | SHARE + | SHARED + | SHOW_ROUTINE + | SIGNED + | SIMPLE + | SLAVE + | SLAVES + | SLOW + | SNAPSHOT + | SOCKET + | SOME + | SONAME + | SOUNDS + | SOURCE + | SQL_AFTER_GTIDS + | SQL_AFTER_MTS_GAPS + | SQL_BEFORE_GTIDS + | SQL_BUFFER_RESULT + | SQL_CACHE + | SQL_NO_CACHE + | SQL_THREAD + | STACKED + | START + | STARTS + | STATS_AUTO_RECALC + | STATS_PERSISTENT + | STATS_SAMPLE_PAGES + | STATUS + | STD + | STDDEV + | STDDEV_POP + | STDDEV_SAMP + | STOP + | STORAGE + | STRING + | SUBCLASS_ORIGIN + | SUBJECT + | SUBPARTITION + | SUBPARTITIONS + | SUM + | SUSPEND + | SWAPS + | SWITCHES + | SYSTEM_VARIABLES_ADMIN + | TABLE_NAME + | TABLESPACE + | TABLE_ENCRYPTION_ADMIN + | TABLE_TYPE + | TEMPORARY + | TEMPTABLE + | THAN + | TRADITIONAL + | TRANSACTION + | TRANSACTIONAL + | TRIGGERS + | TRUNCATE + | TYPES + | UNBOUNDED + | UNDEFINED + | UNDOFILE + | UNDO_BUFFER_SIZE + | UNINSTALL + | UNKNOWN + | UNTIL + | UPGRADE + | USA + | USER + | USE_FRM + | USER_RESOURCES + | VALIDATION + | VALUE + | VAR_POP + | VAR_SAMP + | VARIABLES + | VARIANCE + | VERSION_TOKEN_ADMIN + | VIEW + | VIRTUAL + | WAIT + | WARNINGS + | WITHOUT + | WORK + | WRAPPER + | WSREP_MEMBERSHIP + | WSREP_STATUS + | X509 + | XA + | XA_RECOVER_ADMIN + | XML // MariaDB-specific only - | BINLOG_MONITOR | BINLOG_REPLAY | CURRENT_ROLE | CYCLE | ENCRYPTED | ENCRYPTION_KEY_ID | FEDERATED_ADMIN - | INCREMENT | LASTVAL | LOCKED | MAXVALUE | MINVALUE | NEXTVAL | NOCACHE | NOCYCLE | NOMAXVALUE | NOMINVALUE - | PERSISTENT | PREVIOUS | READ_ONLY_ADMIN | REPLICA | REPLICATION_MASTER_ADMIN | RESTART | SEQUENCE | SETVAL | SKIP_ | STATEMENT | VIA - | MONITOR | READ_ONLY| REPLAY | USER_STATISTICS | CLIENT_STATISTICS | INDEX_STATISTICS | TABLE_STATISTICS + | BINLOG_MONITOR + | BINLOG_REPLAY + | CURRENT_ROLE + | CYCLE + | ENCRYPTED + | ENCRYPTION_KEY_ID + | FEDERATED_ADMIN + | INCREMENT + | LASTVAL + | LOCKED + | MAXVALUE + | MINVALUE + | NEXTVAL + | NOCACHE + | NOCYCLE + | NOMAXVALUE + | NOMINVALUE + | PERSISTENT + | PREVIOUS + | READ_ONLY_ADMIN + | REPLICA + | REPLICATION_MASTER_ADMIN + | RESTART + | SEQUENCE + | SETVAL + | SKIP_ + | STATEMENT + | VIA + | MONITOR + | READ_ONLY + | REPLAY + | USER_STATISTICS + | CLIENT_STATISTICS + | INDEX_STATISTICS + | TABLE_STATISTICS ; functionNameBase - : ABS | ACOS | ADDDATE | ADDTIME | AES_DECRYPT | AES_ENCRYPT - | AREA | ASBINARY | ASIN | ASTEXT | ASWKB | ASWKT - | ASYMMETRIC_DECRYPT | ASYMMETRIC_DERIVE - | ASYMMETRIC_ENCRYPT | ASYMMETRIC_SIGN | ASYMMETRIC_VERIFY - | ATAN | ATAN2 | BENCHMARK | BIN | BIT_COUNT | BIT_LENGTH - | BUFFER | CEIL | CEILING | CENTROID | CHARACTER_LENGTH - | CHARSET | CHAR_LENGTH | COERCIBILITY | COLLATION - | COMPRESS | CONCAT | CONCAT_WS | CONNECTION_ID | CONV - | CONVERT_TZ | COS | COT | COUNT | CRC32 - | CREATE_ASYMMETRIC_PRIV_KEY | CREATE_ASYMMETRIC_PUB_KEY - | CREATE_DH_PARAMETERS | CREATE_DIGEST | CROSSES | CUME_DIST | DATABASE | DATE - | DATEDIFF | DATE_FORMAT | DAY | DAYNAME | DAYOFMONTH - | DAYOFWEEK | DAYOFYEAR | DECODE | DEGREES | DENSE_RANK | DES_DECRYPT - | DES_ENCRYPT | DIMENSION | DISJOINT | ELT | ENCODE - | ENCRYPT | ENDPOINT | ENVELOPE | EQUALS | EXP | EXPORT_SET - | EXTERIORRING | EXTRACTVALUE | FIELD | FIND_IN_SET | FIRST_VALUE | FLOOR - | FORMAT | FOUND_ROWS | FROM_BASE64 | FROM_DAYS - | FROM_UNIXTIME | GEOMCOLLFROMTEXT | GEOMCOLLFROMWKB - | GEOMETRYCOLLECTION | GEOMETRYCOLLECTIONFROMTEXT - | GEOMETRYCOLLECTIONFROMWKB | GEOMETRYFROMTEXT - | GEOMETRYFROMWKB | GEOMETRYN | GEOMETRYTYPE | GEOMFROMTEXT - | GEOMFROMWKB | GET_FORMAT | GET_LOCK | GLENGTH | GREATEST - | GTID_SUBSET | GTID_SUBTRACT | HEX | HOUR | IFNULL - | INET6_ATON | INET6_NTOA | INET_ATON | INET_NTOA | INSTR - | INTERIORRINGN | INTERSECTS | INVISIBLE - | ISCLOSED | ISEMPTY | ISNULL - | ISSIMPLE | IS_FREE_LOCK | IS_IPV4 | IS_IPV4_COMPAT - | IS_IPV4_MAPPED | IS_IPV6 | IS_USED_LOCK | LAG | LAST_INSERT_ID | LAST_VALUE - | LCASE | LEAD | LEAST | LEFT | LENGTH | LINEFROMTEXT | LINEFROMWKB - | LINESTRING | LINESTRINGFROMTEXT | LINESTRINGFROMWKB | LN - | LOAD_FILE | LOCATE | LOG | LOG10 | LOG2 | LOWER | LPAD - | LTRIM | MAKEDATE | MAKETIME | MAKE_SET | MASTER_POS_WAIT - | MBRCONTAINS | MBRDISJOINT | MBREQUAL | MBRINTERSECTS - | MBROVERLAPS | MBRTOUCHES | MBRWITHIN | MD5 | MICROSECOND - | MINUTE | MLINEFROMTEXT | MLINEFROMWKB | MOD| MONTH | MONTHNAME - | MPOINTFROMTEXT | MPOINTFROMWKB | MPOLYFROMTEXT - | MPOLYFROMWKB | MULTILINESTRING | MULTILINESTRINGFROMTEXT - | MULTILINESTRINGFROMWKB | MULTIPOINT | MULTIPOINTFROMTEXT - | MULTIPOINTFROMWKB | MULTIPOLYGON | MULTIPOLYGONFROMTEXT - | MULTIPOLYGONFROMWKB | NAME_CONST | NTH_VALUE | NTILE | NULLIF | NUMGEOMETRIES - | NUMINTERIORRINGS | NUMPOINTS | OCT | OCTET_LENGTH | ORD - | OVERLAPS | PERCENT_RANK | PERIOD_ADD | PERIOD_DIFF | PI | POINT - | POINTFROMTEXT | POINTFROMWKB | POINTN | POLYFROMTEXT - | POLYFROMWKB | POLYGON | POLYGONFROMTEXT | POLYGONFROMWKB - | POSITION | POW | POWER | QUARTER | QUOTE | RADIANS | RAND | RANK - | RANDOM_BYTES | RELEASE_LOCK | REVERSE | RIGHT | ROUND - | ROW_COUNT | ROW_NUMBER | RPAD | RTRIM | SCHEMA | SECOND | SEC_TO_TIME - | SESSION_USER | SESSION_VARIABLES_ADMIN - | SHA | SHA1 | SHA2 | SIGN | SIN | SLEEP - | SOUNDEX | SQL_THREAD_WAIT_AFTER_GTIDS | SQRT | SRID - | STARTPOINT | STRCMP | STR_TO_DATE | ST_AREA | ST_ASBINARY - | ST_ASTEXT | ST_ASWKB | ST_ASWKT | ST_BUFFER | ST_CENTROID - | ST_CONTAINS | ST_CROSSES | ST_DIFFERENCE | ST_DIMENSION - | ST_DISJOINT | ST_DISTANCE | ST_ENDPOINT | ST_ENVELOPE - | ST_EQUALS | ST_EXTERIORRING | ST_GEOMCOLLFROMTEXT - | ST_GEOMCOLLFROMTXT | ST_GEOMCOLLFROMWKB + : ABS + | ACOS + | ADDDATE + | ADDTIME + | AES_DECRYPT + | AES_ENCRYPT + | AREA + | ASBINARY + | ASIN + | ASTEXT + | ASWKB + | ASWKT + | ASYMMETRIC_DECRYPT + | ASYMMETRIC_DERIVE + | ASYMMETRIC_ENCRYPT + | ASYMMETRIC_SIGN + | ASYMMETRIC_VERIFY + | ATAN + | ATAN2 + | BENCHMARK + | BIN + | BIT_COUNT + | BIT_LENGTH + | BUFFER + | CEIL + | CEILING + | CENTROID + | CHARACTER_LENGTH + | CHARSET + | CHAR_LENGTH + | COERCIBILITY + | COLLATION + | COMPRESS + | CONCAT + | CONCAT_WS + | CONNECTION_ID + | CONV + | CONVERT_TZ + | COS + | COT + | COUNT + | CRC32 + | CREATE_ASYMMETRIC_PRIV_KEY + | CREATE_ASYMMETRIC_PUB_KEY + | CREATE_DH_PARAMETERS + | CREATE_DIGEST + | CROSSES + | CUME_DIST + | DATABASE + | DATE + | DATEDIFF + | DATE_FORMAT + | DAY + | DAYNAME + | DAYOFMONTH + | DAYOFWEEK + | DAYOFYEAR + | DECODE + | DEGREES + | DENSE_RANK + | DES_DECRYPT + | DES_ENCRYPT + | DIMENSION + | DISJOINT + | ELT + | ENCODE + | ENCRYPT + | ENDPOINT + | ENVELOPE + | EQUALS + | EXP + | EXPORT_SET + | EXTERIORRING + | EXTRACTVALUE + | FIELD + | FIND_IN_SET + | FIRST_VALUE + | FLOOR + | FORMAT + | FOUND_ROWS + | FROM_BASE64 + | FROM_DAYS + | FROM_UNIXTIME + | GEOMCOLLFROMTEXT + | GEOMCOLLFROMWKB + | GEOMETRYCOLLECTION + | GEOMETRYCOLLECTIONFROMTEXT + | GEOMETRYCOLLECTIONFROMWKB + | GEOMETRYFROMTEXT + | GEOMETRYFROMWKB + | GEOMETRYN + | GEOMETRYTYPE + | GEOMFROMTEXT + | GEOMFROMWKB + | GET_FORMAT + | GET_LOCK + | GLENGTH + | GREATEST + | GTID_SUBSET + | GTID_SUBTRACT + | HEX + | HOUR + | IFNULL + | INET6_ATON + | INET6_NTOA + | INET_ATON + | INET_NTOA + | INSTR + | INTERIORRINGN + | INTERSECTS + | INVISIBLE + | ISCLOSED + | ISEMPTY + | ISNULL + | ISSIMPLE + | IS_FREE_LOCK + | IS_IPV4 + | IS_IPV4_COMPAT + | IS_IPV4_MAPPED + | IS_IPV6 + | IS_USED_LOCK + | LAG + | LAST_INSERT_ID + | LAST_VALUE + | LCASE + | LEAD + | LEAST + | LEFT + | LENGTH + | LINEFROMTEXT + | LINEFROMWKB + | LINESTRING + | LINESTRINGFROMTEXT + | LINESTRINGFROMWKB + | LN + | LOAD_FILE + | LOCATE + | LOG + | LOG10 + | LOG2 + | LOWER + | LPAD + | LTRIM + | MAKEDATE + | MAKETIME + | MAKE_SET + | MASTER_POS_WAIT + | MBRCONTAINS + | MBRDISJOINT + | MBREQUAL + | MBRINTERSECTS + | MBROVERLAPS + | MBRTOUCHES + | MBRWITHIN + | MD5 + | MICROSECOND + | MINUTE + | MLINEFROMTEXT + | MLINEFROMWKB + | MOD + | MONTH + | MONTHNAME + | MPOINTFROMTEXT + | MPOINTFROMWKB + | MPOLYFROMTEXT + | MPOLYFROMWKB + | MULTILINESTRING + | MULTILINESTRINGFROMTEXT + | MULTILINESTRINGFROMWKB + | MULTIPOINT + | MULTIPOINTFROMTEXT + | MULTIPOINTFROMWKB + | MULTIPOLYGON + | MULTIPOLYGONFROMTEXT + | MULTIPOLYGONFROMWKB + | NAME_CONST + | NTH_VALUE + | NTILE + | NULLIF + | NUMGEOMETRIES + | NUMINTERIORRINGS + | NUMPOINTS + | OCT + | OCTET_LENGTH + | ORD + | OVERLAPS + | PERCENT_RANK + | PERIOD_ADD + | PERIOD_DIFF + | PI + | POINT + | POINTFROMTEXT + | POINTFROMWKB + | POINTN + | POLYFROMTEXT + | POLYFROMWKB + | POLYGON + | POLYGONFROMTEXT + | POLYGONFROMWKB + | POSITION + | POW + | POWER + | QUARTER + | QUOTE + | RADIANS + | RAND + | RANK + | RANDOM_BYTES + | RELEASE_LOCK + | REVERSE + | RIGHT + | ROUND + | ROW_COUNT + | ROW_NUMBER + | RPAD + | RTRIM + | SCHEMA + | SECOND + | SEC_TO_TIME + | SESSION_USER + | SESSION_VARIABLES_ADMIN + | SHA + | SHA1 + | SHA2 + | SIGN + | SIN + | SLEEP + | SOUNDEX + | SQL_THREAD_WAIT_AFTER_GTIDS + | SQRT + | SRID + | STARTPOINT + | STRCMP + | STR_TO_DATE + | ST_AREA + | ST_ASBINARY + | ST_ASTEXT + | ST_ASWKB + | ST_ASWKT + | ST_BUFFER + | ST_CENTROID + | ST_CONTAINS + | ST_CROSSES + | ST_DIFFERENCE + | ST_DIMENSION + | ST_DISJOINT + | ST_DISTANCE + | ST_ENDPOINT + | ST_ENVELOPE + | ST_EQUALS + | ST_EXTERIORRING + | ST_GEOMCOLLFROMTEXT + | ST_GEOMCOLLFROMTXT + | ST_GEOMCOLLFROMWKB | ST_GEOMETRYCOLLECTIONFROMTEXT - | ST_GEOMETRYCOLLECTIONFROMWKB | ST_GEOMETRYFROMTEXT - | ST_GEOMETRYFROMWKB | ST_GEOMETRYN | ST_GEOMETRYTYPE - | ST_GEOMFROMTEXT | ST_GEOMFROMWKB | ST_INTERIORRINGN - | ST_INTERSECTION | ST_INTERSECTS | ST_ISCLOSED | ST_ISEMPTY - | ST_ISSIMPLE | ST_LINEFROMTEXT | ST_LINEFROMWKB - | ST_LINESTRINGFROMTEXT | ST_LINESTRINGFROMWKB - | ST_NUMGEOMETRIES | ST_NUMINTERIORRING - | ST_NUMINTERIORRINGS | ST_NUMPOINTS | ST_OVERLAPS - | ST_POINTFROMTEXT | ST_POINTFROMWKB | ST_POINTN - | ST_POLYFROMTEXT | ST_POLYFROMWKB | ST_POLYGONFROMTEXT - | ST_POLYGONFROMWKB | ST_SRID | ST_STARTPOINT - | ST_SYMDIFFERENCE | ST_TOUCHES | ST_UNION | ST_WITHIN - | ST_X | ST_Y | SUBDATE | SUBSTRING_INDEX | SUBTIME - | SYSTEM_USER | TAN | TIME | TIMEDIFF | TIMESTAMP - | TIMESTAMPADD | TIMESTAMPDIFF | TIME_FORMAT | TIME_TO_SEC - | TOUCHES | TO_BASE64 | TO_DAYS | TO_SECONDS | UCASE - | UNCOMPRESS | UNCOMPRESSED_LENGTH | UNHEX | UNIX_TIMESTAMP - | UPDATEXML | UPPER | UUID | UUID_SHORT - | VALIDATE_PASSWORD_STRENGTH | VERSION | VISIBLE - | WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS | WEEK | WEEKDAY - | WEEKOFYEAR | WEIGHT_STRING | WITHIN | YEAR | YEARWEEK - | Y_FUNCTION | X_FUNCTION - | JSON_ARRAY | JSON_OBJECT | JSON_QUOTE | JSON_CONTAINS | JSON_CONTAINS_PATH - | JSON_EXTRACT | JSON_KEYS | JSON_OVERLAPS | JSON_SEARCH | JSON_VALUE - | JSON_ARRAY_APPEND | JSON_ARRAY_INSERT | JSON_INSERT | JSON_MERGE - | JSON_MERGE_PATCH | JSON_MERGE_PRESERVE | JSON_REMOVE | JSON_REPLACE - | JSON_SET | JSON_UNQUOTE | JSON_DEPTH | JSON_LENGTH | JSON_TYPE - | JSON_VALID | JSON_TABLE | JSON_SCHEMA_VALID | JSON_SCHEMA_VALIDATION_REPORT - | JSON_PRETTY | JSON_STORAGE_FREE | JSON_STORAGE_SIZE | JSON_ARRAYAGG + | ST_GEOMETRYCOLLECTIONFROMWKB + | ST_GEOMETRYFROMTEXT + | ST_GEOMETRYFROMWKB + | ST_GEOMETRYN + | ST_GEOMETRYTYPE + | ST_GEOMFROMTEXT + | ST_GEOMFROMWKB + | ST_INTERIORRINGN + | ST_INTERSECTION + | ST_INTERSECTS + | ST_ISCLOSED + | ST_ISEMPTY + | ST_ISSIMPLE + | ST_LINEFROMTEXT + | ST_LINEFROMWKB + | ST_LINESTRINGFROMTEXT + | ST_LINESTRINGFROMWKB + | ST_NUMGEOMETRIES + | ST_NUMINTERIORRING + | ST_NUMINTERIORRINGS + | ST_NUMPOINTS + | ST_OVERLAPS + | ST_POINTFROMTEXT + | ST_POINTFROMWKB + | ST_POINTN + | ST_POLYFROMTEXT + | ST_POLYFROMWKB + | ST_POLYGONFROMTEXT + | ST_POLYGONFROMWKB + | ST_SRID + | ST_STARTPOINT + | ST_SYMDIFFERENCE + | ST_TOUCHES + | ST_UNION + | ST_WITHIN + | ST_X + | ST_Y + | SUBDATE + | SUBSTRING_INDEX + | SUBTIME + | SYSTEM_USER + | TAN + | TIME + | TIMEDIFF + | TIMESTAMP + | TIMESTAMPADD + | TIMESTAMPDIFF + | TIME_FORMAT + | TIME_TO_SEC + | TOUCHES + | TO_BASE64 + | TO_DAYS + | TO_SECONDS + | UCASE + | UNCOMPRESS + | UNCOMPRESSED_LENGTH + | UNHEX + | UNIX_TIMESTAMP + | UPDATEXML + | UPPER + | UUID + | UUID_SHORT + | VALIDATE_PASSWORD_STRENGTH + | VERSION + | VISIBLE + | WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS + | WEEK + | WEEKDAY + | WEEKOFYEAR + | WEIGHT_STRING + | WITHIN + | YEAR + | YEARWEEK + | Y_FUNCTION + | X_FUNCTION + | JSON_ARRAY + | JSON_OBJECT + | JSON_QUOTE + | JSON_CONTAINS + | JSON_CONTAINS_PATH + | JSON_EXTRACT + | JSON_KEYS + | JSON_OVERLAPS + | JSON_SEARCH + | JSON_VALUE + | JSON_ARRAY_APPEND + | JSON_ARRAY_INSERT + | JSON_INSERT + | JSON_MERGE + | JSON_MERGE_PATCH + | JSON_MERGE_PRESERVE + | JSON_REMOVE + | JSON_REPLACE + | JSON_SET + | JSON_UNQUOTE + | JSON_DEPTH + | JSON_LENGTH + | JSON_TYPE + | JSON_VALID + | JSON_TABLE + | JSON_SCHEMA_VALID + | JSON_SCHEMA_VALIDATION_REPORT + | JSON_PRETTY + | JSON_STORAGE_FREE + | JSON_STORAGE_SIZE + | JSON_ARRAYAGG | JSON_OBJECTAGG // MariaDB-specific only - | LASTVAL | NEXTVAL | SETVAL - ; + | LASTVAL + | NEXTVAL + | SETVAL + ; \ No newline at end of file diff --git a/sql/mysql/Positive-Technologies/MySqlLexer.g4 b/sql/mysql/Positive-Technologies/MySqlLexer.g4 index b4b1409f56..30d41b30ca 100644 --- a/sql/mysql/Positive-Technologies/MySqlLexer.g4 +++ b/sql/mysql/Positive-Technologies/MySqlLexer.g4 @@ -23,1326 +23,1330 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar MySqlLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} -channels { MYSQLCOMMENT, ERRORCHANNEL } +channels { + MYSQLCOMMENT, + ERRORCHANNEL +} // SKIP -SPACE: [ \t\r\n]+ -> channel(HIDDEN); -SPEC_MYSQL_COMMENT: '/*!' .+? '*/' -> channel(MYSQLCOMMENT); -COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN); -LINE_COMMENT: ( - ('--' [ \t]* | '#') ~[\r\n]* ('\r'? '\n' | EOF) - | '--' ('\r'? '\n' | EOF) - ) -> channel(HIDDEN); - +SPACE : [ \t\r\n]+ -> channel(HIDDEN); +SPEC_MYSQL_COMMENT : '/*!' .+? '*/' -> channel(MYSQLCOMMENT); +COMMENT_INPUT : '/*' .*? '*/' -> channel(HIDDEN); +LINE_COMMENT: + (('--' [ \t]* | '#') ~[\r\n]* ('\r'? '\n' | EOF) | '--' ('\r'? '\n' | EOF)) -> channel(HIDDEN) +; // Keywords // Common Keywords -ADD: 'ADD'; -ALL: 'ALL'; -ALTER: 'ALTER'; -ALWAYS: 'ALWAYS'; -ANALYZE: 'ANALYZE'; -AND: 'AND'; -ARRAY: 'ARRAY'; -AS: 'AS'; -ASC: 'ASC'; -ATTRIBUTE: 'ATTRIBUTE'; -BEFORE: 'BEFORE'; -BETWEEN: 'BETWEEN'; -BOTH: 'BOTH'; -BUCKETS: 'BUCKETS'; -BY: 'BY'; -CALL: 'CALL'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CAST: 'CAST'; -CHANGE: 'CHANGE'; -CHARACTER: 'CHARACTER'; -CHECK: 'CHECK'; -COLLATE: 'COLLATE'; -COLUMN: 'COLUMN'; -CONDITION: 'CONDITION'; -CONSTRAINT: 'CONSTRAINT'; -CONTINUE: 'CONTINUE'; -CONVERT: 'CONVERT'; -CREATE: 'CREATE'; -CROSS: 'CROSS'; -CURRENT: 'CURRENT'; -CURRENT_ROLE: 'CURRENT_ROLE'; -CURRENT_USER: 'CURRENT_USER'; -CURSOR: 'CURSOR'; -DATABASE: 'DATABASE'; -DATABASES: 'DATABASES'; -DECLARE: 'DECLARE'; -DEFAULT: 'DEFAULT'; -DELAYED: 'DELAYED'; -DELETE: 'DELETE'; -DESC: 'DESC'; -DESCRIBE: 'DESCRIBE'; -DETERMINISTIC: 'DETERMINISTIC'; -DIAGNOSTICS: 'DIAGNOSTICS'; -DISTINCT: 'DISTINCT'; -DISTINCTROW: 'DISTINCTROW'; -DROP: 'DROP'; -EACH: 'EACH'; -ELSE: 'ELSE'; -ELSEIF: 'ELSEIF'; -EMPTY: 'EMPTY'; -ENCLOSED: 'ENCLOSED'; -ENFORCED: 'ENFORCED'; -ESCAPED: 'ESCAPED'; -EXCEPT: 'EXCEPT'; -EXISTS: 'EXISTS'; -EXIT: 'EXIT'; -EXPLAIN: 'EXPLAIN'; -FALSE: 'FALSE'; -FETCH: 'FETCH'; -FOR: 'FOR'; -FORCE: 'FORCE'; -FOREIGN: 'FOREIGN'; -FROM: 'FROM'; -FULLTEXT: 'FULLTEXT'; -GENERATED: 'GENERATED'; -GET: 'GET'; -GRANT: 'GRANT'; -GROUP: 'GROUP'; -HAVING: 'HAVING'; -HIGH_PRIORITY: 'HIGH_PRIORITY'; -HISTOGRAM: 'HISTOGRAM'; -IF: 'IF'; -IGNORE: 'IGNORE'; -IGNORED: 'IGNORED'; -IN: 'IN'; -INDEX: 'INDEX'; -INFILE: 'INFILE'; -INNER: 'INNER'; -INOUT: 'INOUT'; -INSERT: 'INSERT'; -INTERVAL: 'INTERVAL'; -INTO: 'INTO'; -IS: 'IS'; -ITERATE: 'ITERATE'; -JOIN: 'JOIN'; -KEY: 'KEY'; -KEYS: 'KEYS'; -KILL: 'KILL'; -LATERAL: 'LATERAL'; -LEADING: 'LEADING'; -LEAVE: 'LEAVE'; -LEFT: 'LEFT'; -LIKE: 'LIKE'; -LIMIT: 'LIMIT'; -LINEAR: 'LINEAR'; -LINES: 'LINES'; -LOAD: 'LOAD'; -LOCK: 'LOCK'; -LOCKED: 'LOCKED'; -LOOP: 'LOOP'; -LOW_PRIORITY: 'LOW_PRIORITY'; -MASTER_BIND: 'MASTER_BIND'; -MASTER_SSL_VERIFY_SERVER_CERT: 'MASTER_SSL_VERIFY_SERVER_CERT'; -MATCH: 'MATCH'; -MAXVALUE: 'MAXVALUE'; -MINVALUE: 'MINVALUE'; -MODIFIES: 'MODIFIES'; -NATURAL: 'NATURAL'; -NOT: 'NOT'; -NO_WRITE_TO_BINLOG: 'NO_WRITE_TO_BINLOG'; -NULL_LITERAL: 'NULL'; -NUMBER: 'NUMBER'; -ON: 'ON'; -OPTIMIZE: 'OPTIMIZE'; -OPTION: 'OPTION'; -OPTIONAL: 'OPTIONAL'; -OPTIONALLY: 'OPTIONALLY'; -OR: 'OR'; -ORDER: 'ORDER'; -OUT: 'OUT'; -OUTER: 'OUTER'; -OUTFILE: 'OUTFILE'; -OVER: 'OVER'; -PARTITION: 'PARTITION'; -PRIMARY: 'PRIMARY'; -PROCEDURE: 'PROCEDURE'; -PURGE: 'PURGE'; -RANGE: 'RANGE'; -READ: 'READ'; -READS: 'READS'; -REFERENCES: 'REFERENCES'; -REGEXP: 'REGEXP'; -RELEASE: 'RELEASE'; -RENAME: 'RENAME'; -REPEAT: 'REPEAT'; -REPLACE: 'REPLACE'; -REQUIRE: 'REQUIRE'; -RESIGNAL: 'RESIGNAL'; -RESTRICT: 'RESTRICT'; -RETAIN: 'RETAIN'; -RETURN: 'RETURN'; -REVOKE: 'REVOKE'; -RIGHT: 'RIGHT'; -RLIKE: 'RLIKE'; -SCHEMA: 'SCHEMA'; -SCHEMAS: 'SCHEMAS'; -SELECT: 'SELECT'; -SET: 'SET'; -SEPARATOR: 'SEPARATOR'; -SHOW: 'SHOW'; -SIGNAL: 'SIGNAL'; -SKIP_: 'SKIP'; -SKIP_QUERY_REWRITE: 'SKIP_QUERY_REWRITE'; -SPATIAL: 'SPATIAL'; -SQL: 'SQL'; -SQLEXCEPTION: 'SQLEXCEPTION'; -SQLSTATE: 'SQLSTATE'; -SQLWARNING: 'SQLWARNING'; -SQL_BIG_RESULT: 'SQL_BIG_RESULT'; -SQL_CALC_FOUND_ROWS: 'SQL_CALC_FOUND_ROWS'; -SQL_SMALL_RESULT: 'SQL_SMALL_RESULT'; -SSL: 'SSL'; -STACKED: 'STACKED'; -STARTING: 'STARTING'; -STATEMENT: 'STATEMENT'; -STRAIGHT_JOIN: 'STRAIGHT_JOIN'; -TABLE: 'TABLE'; -TERMINATED: 'TERMINATED'; -THEN: 'THEN'; -TO: 'TO'; -TRAILING: 'TRAILING'; -TRIGGER: 'TRIGGER'; -TRUE: 'TRUE'; -UNDO: 'UNDO'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; -UNLOCK: 'UNLOCK'; -UNSIGNED: 'UNSIGNED'; -UPDATE: 'UPDATE'; -USAGE: 'USAGE'; -USE: 'USE'; -USING: 'USING'; -VALUES: 'VALUES'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WHILE: 'WHILE'; -WITH: 'WITH'; -WRITE: 'WRITE'; -XOR: 'XOR'; -ZEROFILL: 'ZEROFILL'; +ADD : 'ADD'; +ALL : 'ALL'; +ALTER : 'ALTER'; +ALWAYS : 'ALWAYS'; +ANALYZE : 'ANALYZE'; +AND : 'AND'; +ARRAY : 'ARRAY'; +AS : 'AS'; +ASC : 'ASC'; +ATTRIBUTE : 'ATTRIBUTE'; +BEFORE : 'BEFORE'; +BETWEEN : 'BETWEEN'; +BOTH : 'BOTH'; +BUCKETS : 'BUCKETS'; +BY : 'BY'; +CALL : 'CALL'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CHANGE : 'CHANGE'; +CHARACTER : 'CHARACTER'; +CHECK : 'CHECK'; +COLLATE : 'COLLATE'; +COLUMN : 'COLUMN'; +CONDITION : 'CONDITION'; +CONSTRAINT : 'CONSTRAINT'; +CONTINUE : 'CONTINUE'; +CONVERT : 'CONVERT'; +CREATE : 'CREATE'; +CROSS : 'CROSS'; +CURRENT : 'CURRENT'; +CURRENT_ROLE : 'CURRENT_ROLE'; +CURRENT_USER : 'CURRENT_USER'; +CURSOR : 'CURSOR'; +DATABASE : 'DATABASE'; +DATABASES : 'DATABASES'; +DECLARE : 'DECLARE'; +DEFAULT : 'DEFAULT'; +DELAYED : 'DELAYED'; +DELETE : 'DELETE'; +DESC : 'DESC'; +DESCRIBE : 'DESCRIBE'; +DETERMINISTIC : 'DETERMINISTIC'; +DIAGNOSTICS : 'DIAGNOSTICS'; +DISTINCT : 'DISTINCT'; +DISTINCTROW : 'DISTINCTROW'; +DROP : 'DROP'; +EACH : 'EACH'; +ELSE : 'ELSE'; +ELSEIF : 'ELSEIF'; +EMPTY : 'EMPTY'; +ENCLOSED : 'ENCLOSED'; +ENFORCED : 'ENFORCED'; +ESCAPED : 'ESCAPED'; +EXCEPT : 'EXCEPT'; +EXISTS : 'EXISTS'; +EXIT : 'EXIT'; +EXPLAIN : 'EXPLAIN'; +FALSE : 'FALSE'; +FETCH : 'FETCH'; +FOR : 'FOR'; +FORCE : 'FORCE'; +FOREIGN : 'FOREIGN'; +FROM : 'FROM'; +FULLTEXT : 'FULLTEXT'; +GENERATED : 'GENERATED'; +GET : 'GET'; +GRANT : 'GRANT'; +GROUP : 'GROUP'; +HAVING : 'HAVING'; +HIGH_PRIORITY : 'HIGH_PRIORITY'; +HISTOGRAM : 'HISTOGRAM'; +IF : 'IF'; +IGNORE : 'IGNORE'; +IGNORED : 'IGNORED'; +IN : 'IN'; +INDEX : 'INDEX'; +INFILE : 'INFILE'; +INNER : 'INNER'; +INOUT : 'INOUT'; +INSERT : 'INSERT'; +INTERVAL : 'INTERVAL'; +INTO : 'INTO'; +IS : 'IS'; +ITERATE : 'ITERATE'; +JOIN : 'JOIN'; +KEY : 'KEY'; +KEYS : 'KEYS'; +KILL : 'KILL'; +LATERAL : 'LATERAL'; +LEADING : 'LEADING'; +LEAVE : 'LEAVE'; +LEFT : 'LEFT'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +LINEAR : 'LINEAR'; +LINES : 'LINES'; +LOAD : 'LOAD'; +LOCK : 'LOCK'; +LOCKED : 'LOCKED'; +LOOP : 'LOOP'; +LOW_PRIORITY : 'LOW_PRIORITY'; +MASTER_BIND : 'MASTER_BIND'; +MASTER_SSL_VERIFY_SERVER_CERT : 'MASTER_SSL_VERIFY_SERVER_CERT'; +MATCH : 'MATCH'; +MAXVALUE : 'MAXVALUE'; +MINVALUE : 'MINVALUE'; +MODIFIES : 'MODIFIES'; +NATURAL : 'NATURAL'; +NOT : 'NOT'; +NO_WRITE_TO_BINLOG : 'NO_WRITE_TO_BINLOG'; +NULL_LITERAL : 'NULL'; +NUMBER : 'NUMBER'; +ON : 'ON'; +OPTIMIZE : 'OPTIMIZE'; +OPTION : 'OPTION'; +OPTIONAL : 'OPTIONAL'; +OPTIONALLY : 'OPTIONALLY'; +OR : 'OR'; +ORDER : 'ORDER'; +OUT : 'OUT'; +OUTER : 'OUTER'; +OUTFILE : 'OUTFILE'; +OVER : 'OVER'; +PARTITION : 'PARTITION'; +PRIMARY : 'PRIMARY'; +PROCEDURE : 'PROCEDURE'; +PURGE : 'PURGE'; +RANGE : 'RANGE'; +READ : 'READ'; +READS : 'READS'; +REFERENCES : 'REFERENCES'; +REGEXP : 'REGEXP'; +RELEASE : 'RELEASE'; +RENAME : 'RENAME'; +REPEAT : 'REPEAT'; +REPLACE : 'REPLACE'; +REQUIRE : 'REQUIRE'; +RESIGNAL : 'RESIGNAL'; +RESTRICT : 'RESTRICT'; +RETAIN : 'RETAIN'; +RETURN : 'RETURN'; +REVOKE : 'REVOKE'; +RIGHT : 'RIGHT'; +RLIKE : 'RLIKE'; +SCHEMA : 'SCHEMA'; +SCHEMAS : 'SCHEMAS'; +SELECT : 'SELECT'; +SET : 'SET'; +SEPARATOR : 'SEPARATOR'; +SHOW : 'SHOW'; +SIGNAL : 'SIGNAL'; +SKIP_ : 'SKIP'; +SKIP_QUERY_REWRITE : 'SKIP_QUERY_REWRITE'; +SPATIAL : 'SPATIAL'; +SQL : 'SQL'; +SQLEXCEPTION : 'SQLEXCEPTION'; +SQLSTATE : 'SQLSTATE'; +SQLWARNING : 'SQLWARNING'; +SQL_BIG_RESULT : 'SQL_BIG_RESULT'; +SQL_CALC_FOUND_ROWS : 'SQL_CALC_FOUND_ROWS'; +SQL_SMALL_RESULT : 'SQL_SMALL_RESULT'; +SSL : 'SSL'; +STACKED : 'STACKED'; +STARTING : 'STARTING'; +STATEMENT : 'STATEMENT'; +STRAIGHT_JOIN : 'STRAIGHT_JOIN'; +TABLE : 'TABLE'; +TERMINATED : 'TERMINATED'; +THEN : 'THEN'; +TO : 'TO'; +TRAILING : 'TRAILING'; +TRIGGER : 'TRIGGER'; +TRUE : 'TRUE'; +UNDO : 'UNDO'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; +UNLOCK : 'UNLOCK'; +UNSIGNED : 'UNSIGNED'; +UPDATE : 'UPDATE'; +USAGE : 'USAGE'; +USE : 'USE'; +USING : 'USING'; +VALUES : 'VALUES'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WHILE : 'WHILE'; +WITH : 'WITH'; +WRITE : 'WRITE'; +XOR : 'XOR'; +ZEROFILL : 'ZEROFILL'; // DATA TYPE Keywords -TINYINT: 'TINYINT'; -SMALLINT: 'SMALLINT'; -MEDIUMINT: 'MEDIUMINT'; -MIDDLEINT: 'MIDDLEINT'; -INT: 'INT'; -INT1: 'INT1'; -INT2: 'INT2'; -INT3: 'INT3'; -INT4: 'INT4'; -INT8: 'INT8'; -INTEGER: 'INTEGER'; -BIGINT: 'BIGINT'; -REAL: 'REAL'; -DOUBLE: 'DOUBLE'; -PRECISION: 'PRECISION'; -FLOAT: 'FLOAT'; -FLOAT4: 'FLOAT4'; -FLOAT8: 'FLOAT8'; -DECIMAL: 'DECIMAL'; -DEC: 'DEC'; -NUMERIC: 'NUMERIC'; -DATE: 'DATE'; -TIME: 'TIME'; -TIMESTAMP: 'TIMESTAMP'; -DATETIME: 'DATETIME'; -YEAR: 'YEAR'; -CHAR: 'CHAR'; -VARCHAR: 'VARCHAR'; -NVARCHAR: 'NVARCHAR'; -NATIONAL: 'NATIONAL'; -BINARY: 'BINARY'; -VARBINARY: 'VARBINARY'; -TINYBLOB: 'TINYBLOB'; -BLOB: 'BLOB'; -MEDIUMBLOB: 'MEDIUMBLOB'; -LONG: 'LONG'; -LONGBLOB: 'LONGBLOB'; -TINYTEXT: 'TINYTEXT'; -TEXT: 'TEXT'; -MEDIUMTEXT: 'MEDIUMTEXT'; -LONGTEXT: 'LONGTEXT'; -ENUM: 'ENUM'; -VARYING: 'VARYING'; -SERIAL: 'SERIAL'; - +TINYINT : 'TINYINT'; +SMALLINT : 'SMALLINT'; +MEDIUMINT : 'MEDIUMINT'; +MIDDLEINT : 'MIDDLEINT'; +INT : 'INT'; +INT1 : 'INT1'; +INT2 : 'INT2'; +INT3 : 'INT3'; +INT4 : 'INT4'; +INT8 : 'INT8'; +INTEGER : 'INTEGER'; +BIGINT : 'BIGINT'; +REAL : 'REAL'; +DOUBLE : 'DOUBLE'; +PRECISION : 'PRECISION'; +FLOAT : 'FLOAT'; +FLOAT4 : 'FLOAT4'; +FLOAT8 : 'FLOAT8'; +DECIMAL : 'DECIMAL'; +DEC : 'DEC'; +NUMERIC : 'NUMERIC'; +DATE : 'DATE'; +TIME : 'TIME'; +TIMESTAMP : 'TIMESTAMP'; +DATETIME : 'DATETIME'; +YEAR : 'YEAR'; +CHAR : 'CHAR'; +VARCHAR : 'VARCHAR'; +NVARCHAR : 'NVARCHAR'; +NATIONAL : 'NATIONAL'; +BINARY : 'BINARY'; +VARBINARY : 'VARBINARY'; +TINYBLOB : 'TINYBLOB'; +BLOB : 'BLOB'; +MEDIUMBLOB : 'MEDIUMBLOB'; +LONG : 'LONG'; +LONGBLOB : 'LONGBLOB'; +TINYTEXT : 'TINYTEXT'; +TEXT : 'TEXT'; +MEDIUMTEXT : 'MEDIUMTEXT'; +LONGTEXT : 'LONGTEXT'; +ENUM : 'ENUM'; +VARYING : 'VARYING'; +SERIAL : 'SERIAL'; // Interval type Keywords -YEAR_MONTH: 'YEAR_MONTH'; -DAY_HOUR: 'DAY_HOUR'; -DAY_MINUTE: 'DAY_MINUTE'; -DAY_SECOND: 'DAY_SECOND'; -HOUR_MINUTE: 'HOUR_MINUTE'; -HOUR_SECOND: 'HOUR_SECOND'; -MINUTE_SECOND: 'MINUTE_SECOND'; -SECOND_MICROSECOND: 'SECOND_MICROSECOND'; -MINUTE_MICROSECOND: 'MINUTE_MICROSECOND'; -HOUR_MICROSECOND: 'HOUR_MICROSECOND'; -DAY_MICROSECOND: 'DAY_MICROSECOND'; +YEAR_MONTH : 'YEAR_MONTH'; +DAY_HOUR : 'DAY_HOUR'; +DAY_MINUTE : 'DAY_MINUTE'; +DAY_SECOND : 'DAY_SECOND'; +HOUR_MINUTE : 'HOUR_MINUTE'; +HOUR_SECOND : 'HOUR_SECOND'; +MINUTE_SECOND : 'MINUTE_SECOND'; +SECOND_MICROSECOND : 'SECOND_MICROSECOND'; +MINUTE_MICROSECOND : 'MINUTE_MICROSECOND'; +HOUR_MICROSECOND : 'HOUR_MICROSECOND'; +DAY_MICROSECOND : 'DAY_MICROSECOND'; // JSON keywords -JSON_ARRAY: 'JSON_ARRAY'; -JSON_ARRAYAGG: 'JSON_ARRAYAGG'; -JSON_ARRAY_APPEND: 'JSON_ARRAY_APPEND'; -JSON_ARRAY_INSERT: 'JSON_ARRAY_INSERT'; -JSON_CONTAINS: 'JSON_CONTAINS'; -JSON_CONTAINS_PATH: 'JSON_CONTAINS_PATH'; -JSON_DEPTH: 'JSON_DEPTH'; -JSON_EXTRACT: 'JSON_EXTRACT'; -JSON_INSERT: 'JSON_INSERT'; -JSON_KEYS: 'JSON_KEYS'; -JSON_LENGTH: 'JSON_LENGTH'; -JSON_MERGE: 'JSON_MERGE'; -JSON_MERGE_PATCH: 'JSON_MERGE_PATCH'; -JSON_MERGE_PRESERVE: 'JSON_MERGE_PRESERVE'; -JSON_OBJECT: 'JSON_OBJECT'; -JSON_OBJECTAGG: 'JSON_OBJECTAGG'; -JSON_OVERLAPS: 'JSON_OVERLAPS'; -JSON_PRETTY: 'JSON_PRETTY'; -JSON_QUOTE: 'JSON_QUOTE'; -JSON_REMOVE: 'JSON_REMOVE'; -JSON_REPLACE: 'JSON_REPLACE'; -JSON_SCHEMA_VALID: 'JSON_SCHEMA_VALID'; -JSON_SCHEMA_VALIDATION_REPORT: 'JSON_SCHEMA_VALIDATION_REPORT'; -JSON_SEARCH: 'JSON_SEARCH'; -JSON_SET: 'JSON_SET'; -JSON_STORAGE_FREE: 'JSON_STORAGE_FREE'; -JSON_STORAGE_SIZE: 'JSON_STORAGE_SIZE'; -JSON_TABLE: 'JSON_TABLE'; -JSON_TYPE: 'JSON_TYPE'; -JSON_UNQUOTE: 'JSON_UNQUOTE'; -JSON_VALID: 'JSON_VALID'; -JSON_VALUE: 'JSON_VALUE'; -NESTED: 'NESTED'; -ORDINALITY: 'ORDINALITY'; -PATH: 'PATH'; +JSON_ARRAY : 'JSON_ARRAY'; +JSON_ARRAYAGG : 'JSON_ARRAYAGG'; +JSON_ARRAY_APPEND : 'JSON_ARRAY_APPEND'; +JSON_ARRAY_INSERT : 'JSON_ARRAY_INSERT'; +JSON_CONTAINS : 'JSON_CONTAINS'; +JSON_CONTAINS_PATH : 'JSON_CONTAINS_PATH'; +JSON_DEPTH : 'JSON_DEPTH'; +JSON_EXTRACT : 'JSON_EXTRACT'; +JSON_INSERT : 'JSON_INSERT'; +JSON_KEYS : 'JSON_KEYS'; +JSON_LENGTH : 'JSON_LENGTH'; +JSON_MERGE : 'JSON_MERGE'; +JSON_MERGE_PATCH : 'JSON_MERGE_PATCH'; +JSON_MERGE_PRESERVE : 'JSON_MERGE_PRESERVE'; +JSON_OBJECT : 'JSON_OBJECT'; +JSON_OBJECTAGG : 'JSON_OBJECTAGG'; +JSON_OVERLAPS : 'JSON_OVERLAPS'; +JSON_PRETTY : 'JSON_PRETTY'; +JSON_QUOTE : 'JSON_QUOTE'; +JSON_REMOVE : 'JSON_REMOVE'; +JSON_REPLACE : 'JSON_REPLACE'; +JSON_SCHEMA_VALID : 'JSON_SCHEMA_VALID'; +JSON_SCHEMA_VALIDATION_REPORT : 'JSON_SCHEMA_VALIDATION_REPORT'; +JSON_SEARCH : 'JSON_SEARCH'; +JSON_SET : 'JSON_SET'; +JSON_STORAGE_FREE : 'JSON_STORAGE_FREE'; +JSON_STORAGE_SIZE : 'JSON_STORAGE_SIZE'; +JSON_TABLE : 'JSON_TABLE'; +JSON_TYPE : 'JSON_TYPE'; +JSON_UNQUOTE : 'JSON_UNQUOTE'; +JSON_VALID : 'JSON_VALID'; +JSON_VALUE : 'JSON_VALUE'; +NESTED : 'NESTED'; +ORDINALITY : 'ORDINALITY'; +PATH : 'PATH'; // Group function Keywords -AVG: 'AVG'; -BIT_AND: 'BIT_AND'; -BIT_OR: 'BIT_OR'; -BIT_XOR: 'BIT_XOR'; -COUNT: 'COUNT'; -CUME_DIST: 'CUME_DIST'; -DENSE_RANK: 'DENSE_RANK'; -FIRST_VALUE: 'FIRST_VALUE'; -GROUP_CONCAT: 'GROUP_CONCAT'; -LAG: 'LAG'; -LAST_VALUE: 'LAST_VALUE'; -LEAD: 'LEAD'; -MAX: 'MAX'; -MIN: 'MIN'; -NTILE: 'NTILE'; -NTH_VALUE: 'NTH_VALUE'; -PERCENT_RANK: 'PERCENT_RANK'; -RANK: 'RANK'; -ROW_NUMBER: 'ROW_NUMBER'; -STD: 'STD'; -STDDEV: 'STDDEV'; -STDDEV_POP: 'STDDEV_POP'; -STDDEV_SAMP: 'STDDEV_SAMP'; -SUM: 'SUM'; -VAR_POP: 'VAR_POP'; -VAR_SAMP: 'VAR_SAMP'; -VARIANCE: 'VARIANCE'; +AVG : 'AVG'; +BIT_AND : 'BIT_AND'; +BIT_OR : 'BIT_OR'; +BIT_XOR : 'BIT_XOR'; +COUNT : 'COUNT'; +CUME_DIST : 'CUME_DIST'; +DENSE_RANK : 'DENSE_RANK'; +FIRST_VALUE : 'FIRST_VALUE'; +GROUP_CONCAT : 'GROUP_CONCAT'; +LAG : 'LAG'; +LAST_VALUE : 'LAST_VALUE'; +LEAD : 'LEAD'; +MAX : 'MAX'; +MIN : 'MIN'; +NTILE : 'NTILE'; +NTH_VALUE : 'NTH_VALUE'; +PERCENT_RANK : 'PERCENT_RANK'; +RANK : 'RANK'; +ROW_NUMBER : 'ROW_NUMBER'; +STD : 'STD'; +STDDEV : 'STDDEV'; +STDDEV_POP : 'STDDEV_POP'; +STDDEV_SAMP : 'STDDEV_SAMP'; +SUM : 'SUM'; +VAR_POP : 'VAR_POP'; +VAR_SAMP : 'VAR_SAMP'; +VARIANCE : 'VARIANCE'; // Common function Keywords -CURRENT_DATE: 'CURRENT_DATE'; -CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -LOCALTIME: 'LOCALTIME'; -CURDATE: 'CURDATE'; -CURTIME: 'CURTIME'; -DATE_ADD: 'DATE_ADD'; -DATE_SUB: 'DATE_SUB'; -EXTRACT: 'EXTRACT'; -LOCALTIMESTAMP: 'LOCALTIMESTAMP'; -NOW: 'NOW'; -POSITION: 'POSITION'; -SUBSTR: 'SUBSTR'; -SUBSTRING: 'SUBSTRING'; -SYSDATE: 'SYSDATE'; -TRIM: 'TRIM'; -UTC_DATE: 'UTC_DATE'; -UTC_TIME: 'UTC_TIME'; -UTC_TIMESTAMP: 'UTC_TIMESTAMP'; +CURRENT_DATE : 'CURRENT_DATE'; +CURRENT_TIME : 'CURRENT_TIME'; +CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +LOCALTIME : 'LOCALTIME'; +CURDATE : 'CURDATE'; +CURTIME : 'CURTIME'; +DATE_ADD : 'DATE_ADD'; +DATE_SUB : 'DATE_SUB'; +EXTRACT : 'EXTRACT'; +LOCALTIMESTAMP : 'LOCALTIMESTAMP'; +NOW : 'NOW'; +POSITION : 'POSITION'; +SUBSTR : 'SUBSTR'; +SUBSTRING : 'SUBSTRING'; +SYSDATE : 'SYSDATE'; +TRIM : 'TRIM'; +UTC_DATE : 'UTC_DATE'; +UTC_TIME : 'UTC_TIME'; +UTC_TIMESTAMP : 'UTC_TIMESTAMP'; // Keywords, but can be ID // Common Keywords, but can be ID -ACCOUNT: 'ACCOUNT'; -ACTION: 'ACTION'; -AFTER: 'AFTER'; -AGGREGATE: 'AGGREGATE'; -ALGORITHM: 'ALGORITHM'; -ANY: 'ANY'; -AT: 'AT'; -AUTHORS: 'AUTHORS'; -AUTOCOMMIT: 'AUTOCOMMIT'; -AUTOEXTEND_SIZE: 'AUTOEXTEND_SIZE'; -AUTO_INCREMENT: 'AUTO_INCREMENT'; -AVG_ROW_LENGTH: 'AVG_ROW_LENGTH'; -BEGIN: 'BEGIN'; -BINLOG: 'BINLOG'; -BIT: 'BIT'; -BLOCK: 'BLOCK'; -BOOL: 'BOOL'; -BOOLEAN: 'BOOLEAN'; -BTREE: 'BTREE'; -CACHE: 'CACHE'; -CASCADED: 'CASCADED'; -CHAIN: 'CHAIN'; -CHANGED: 'CHANGED'; -CHANNEL: 'CHANNEL'; -CHECKSUM: 'CHECKSUM'; -PAGE_CHECKSUM: 'PAGE_CHECKSUM'; -CIPHER: 'CIPHER'; -CLASS_ORIGIN: 'CLASS_ORIGIN'; -CLIENT: 'CLIENT'; -CLOSE: 'CLOSE'; -CLUSTERING: 'CLUSTERING'; -COALESCE: 'COALESCE'; -CODE: 'CODE'; -COLUMNS: 'COLUMNS'; -COLUMN_FORMAT: 'COLUMN_FORMAT'; -COLUMN_NAME: 'COLUMN_NAME'; -COMMENT: 'COMMENT'; -COMMIT: 'COMMIT'; -COMPACT: 'COMPACT'; -COMPLETION: 'COMPLETION'; -COMPRESSED: 'COMPRESSED'; -COMPRESSION: 'COMPRESSION'; -CONCURRENT: 'CONCURRENT'; -CONNECT: 'CONNECT'; -CONNECTION: 'CONNECTION'; -CONSISTENT: 'CONSISTENT'; -CONSTRAINT_CATALOG: 'CONSTRAINT_CATALOG'; -CONSTRAINT_SCHEMA: 'CONSTRAINT_SCHEMA'; -CONSTRAINT_NAME: 'CONSTRAINT_NAME'; -CONTAINS: 'CONTAINS'; -CONTEXT: 'CONTEXT'; -CONTRIBUTORS: 'CONTRIBUTORS'; -COPY: 'COPY'; -CPU: 'CPU'; -CYCLE: 'CYCLE'; -CURSOR_NAME: 'CURSOR_NAME'; -DATA: 'DATA'; -DATAFILE: 'DATAFILE'; -DEALLOCATE: 'DEALLOCATE'; -DEFAULT_AUTH: 'DEFAULT_AUTH'; -DEFINER: 'DEFINER'; -DELAY_KEY_WRITE: 'DELAY_KEY_WRITE'; -DES_KEY_FILE: 'DES_KEY_FILE'; -DIRECTORY: 'DIRECTORY'; -DISABLE: 'DISABLE'; -DISCARD: 'DISCARD'; -DISK: 'DISK'; -DO: 'DO'; -DUMPFILE: 'DUMPFILE'; -DUPLICATE: 'DUPLICATE'; -DYNAMIC: 'DYNAMIC'; -ENABLE: 'ENABLE'; -ENCRYPTED: 'ENCRYPTED'; -ENCRYPTION: 'ENCRYPTION'; -ENCRYPTION_KEY_ID: 'ENCRYPTION_KEY_ID'; -END: 'END'; -ENDS: 'ENDS'; -ENGINE: 'ENGINE'; -ENGINES: 'ENGINES'; -ERROR: 'ERROR'; -ERRORS: 'ERRORS'; -ESCAPE: 'ESCAPE'; -EVEN: 'EVEN'; -EVENT: 'EVENT'; -EVENTS: 'EVENTS'; -EVERY: 'EVERY'; -EXCHANGE: 'EXCHANGE'; -EXCLUSIVE: 'EXCLUSIVE'; -EXPIRE: 'EXPIRE'; -EXPORT: 'EXPORT'; -EXTENDED: 'EXTENDED'; -EXTENT_SIZE: 'EXTENT_SIZE'; -FAILED_LOGIN_ATTEMPTS: 'FAILED_LOGIN_ATTEMPTS'; -FAST: 'FAST'; -FAULTS: 'FAULTS'; -FIELDS: 'FIELDS'; -FILE_BLOCK_SIZE: 'FILE_BLOCK_SIZE'; -FILTER: 'FILTER'; -FIRST: 'FIRST'; -FIXED: 'FIXED'; -FLUSH: 'FLUSH'; -FOLLOWING: 'FOLLOWING'; -FOLLOWS: 'FOLLOWS'; -FOUND: 'FOUND'; -FULL: 'FULL'; -FUNCTION: 'FUNCTION'; -GENERAL: 'GENERAL'; -GLOBAL: 'GLOBAL'; -GRANTS: 'GRANTS'; -GROUP_REPLICATION: 'GROUP_REPLICATION'; -HANDLER: 'HANDLER'; -HASH: 'HASH'; -HELP: 'HELP'; -HISTORY: 'HISTORY'; -HOST: 'HOST'; -HOSTS: 'HOSTS'; -IDENTIFIED: 'IDENTIFIED'; -IGNORE_SERVER_IDS: 'IGNORE_SERVER_IDS'; -IMPORT: 'IMPORT'; -INCREMENT: 'INCREMENT'; -INDEXES: 'INDEXES'; -INITIAL_SIZE: 'INITIAL_SIZE'; -INPLACE: 'INPLACE'; -INSERT_METHOD: 'INSERT_METHOD'; -INSTALL: 'INSTALL'; -INSTANCE: 'INSTANCE'; -INSTANT: 'INSTANT'; -INVISIBLE: 'INVISIBLE'; -INVOKER: 'INVOKER'; -IO: 'IO'; -IO_THREAD: 'IO_THREAD'; -IPC: 'IPC'; -ISOLATION: 'ISOLATION'; -ISSUER: 'ISSUER'; -JSON: 'JSON'; -KEY_BLOCK_SIZE: 'KEY_BLOCK_SIZE'; -LANGUAGE: 'LANGUAGE'; -LAST: 'LAST'; -LEAVES: 'LEAVES'; -LESS: 'LESS'; -LEVEL: 'LEVEL'; -LIST: 'LIST'; -LOCAL: 'LOCAL'; -LOGFILE: 'LOGFILE'; -LOGS: 'LOGS'; -MASTER: 'MASTER'; -MASTER_AUTO_POSITION: 'MASTER_AUTO_POSITION'; -MASTER_CONNECT_RETRY: 'MASTER_CONNECT_RETRY'; -MASTER_DELAY: 'MASTER_DELAY'; -MASTER_HEARTBEAT_PERIOD: 'MASTER_HEARTBEAT_PERIOD'; -MASTER_HOST: 'MASTER_HOST'; -MASTER_LOG_FILE: 'MASTER_LOG_FILE'; -MASTER_LOG_POS: 'MASTER_LOG_POS'; -MASTER_PASSWORD: 'MASTER_PASSWORD'; -MASTER_PORT: 'MASTER_PORT'; -MASTER_RETRY_COUNT: 'MASTER_RETRY_COUNT'; -MASTER_SSL: 'MASTER_SSL'; -MASTER_SSL_CA: 'MASTER_SSL_CA'; -MASTER_SSL_CAPATH: 'MASTER_SSL_CAPATH'; -MASTER_SSL_CERT: 'MASTER_SSL_CERT'; -MASTER_SSL_CIPHER: 'MASTER_SSL_CIPHER'; -MASTER_SSL_CRL: 'MASTER_SSL_CRL'; -MASTER_SSL_CRLPATH: 'MASTER_SSL_CRLPATH'; -MASTER_SSL_KEY: 'MASTER_SSL_KEY'; -MASTER_TLS_VERSION: 'MASTER_TLS_VERSION'; -MASTER_USER: 'MASTER_USER'; -MAX_CONNECTIONS_PER_HOUR: 'MAX_CONNECTIONS_PER_HOUR'; -MAX_QUERIES_PER_HOUR: 'MAX_QUERIES_PER_HOUR'; -MAX_ROWS: 'MAX_ROWS'; -MAX_SIZE: 'MAX_SIZE'; -MAX_UPDATES_PER_HOUR: 'MAX_UPDATES_PER_HOUR'; -MAX_USER_CONNECTIONS: 'MAX_USER_CONNECTIONS'; -MEDIUM: 'MEDIUM'; -MEMBER: 'MEMBER'; -MERGE: 'MERGE'; -MESSAGE_TEXT: 'MESSAGE_TEXT'; -MID: 'MID'; -MIGRATE: 'MIGRATE'; -MIN_ROWS: 'MIN_ROWS'; -MODE: 'MODE'; -MODIFY: 'MODIFY'; -MUTEX: 'MUTEX'; -MYSQL: 'MYSQL'; -MYSQL_ERRNO: 'MYSQL_ERRNO'; -NAME: 'NAME'; -NAMES: 'NAMES'; -NCHAR: 'NCHAR'; -NEVER: 'NEVER'; -NEXT: 'NEXT'; -NO: 'NO'; -NOCACHE: 'NOCACHE'; -NOCOPY: 'NOCOPY'; -NOCYCLE: 'NOCYCLE'; -NOMAXVALUE: 'NOMAXVALUE'; -NOMINVALUE: 'NOMINVALUE'; -NOWAIT: 'NOWAIT'; -NODEGROUP: 'NODEGROUP'; -NONE: 'NONE'; -ODBC: 'ODBC'; -OFFLINE: 'OFFLINE'; -OFFSET: 'OFFSET'; -OF: 'OF'; -OJ: 'OJ'; -OLD_PASSWORD: 'OLD_PASSWORD'; -ONE: 'ONE'; -ONLINE: 'ONLINE'; -ONLY: 'ONLY'; -OPEN: 'OPEN'; -OPTIMIZER_COSTS: 'OPTIMIZER_COSTS'; -OPTIONS: 'OPTIONS'; -OWNER: 'OWNER'; -PACK_KEYS: 'PACK_KEYS'; -PAGE: 'PAGE'; -PAGE_COMPRESSED: 'PAGE_COMPRESSED'; -PAGE_COMPRESSION_LEVEL: 'PAGE_COMPRESSION_LEVEL'; -PARSER: 'PARSER'; -PARTIAL: 'PARTIAL'; -PARTITIONING: 'PARTITIONING'; -PARTITIONS: 'PARTITIONS'; -PASSWORD: 'PASSWORD'; -PASSWORD_LOCK_TIME: 'PASSWORD_LOCK_TIME'; -PHASE: 'PHASE'; -PLUGIN: 'PLUGIN'; -PLUGIN_DIR: 'PLUGIN_DIR'; -PLUGINS: 'PLUGINS'; -PORT: 'PORT'; -PRECEDES: 'PRECEDES'; -PRECEDING: 'PRECEDING'; -PREPARE: 'PREPARE'; -PRESERVE: 'PRESERVE'; -PREV: 'PREV'; -PROCESSLIST: 'PROCESSLIST'; -PROFILE: 'PROFILE'; -PROFILES: 'PROFILES'; -PROXY: 'PROXY'; -QUERY: 'QUERY'; -QUICK: 'QUICK'; -REBUILD: 'REBUILD'; -RECOVER: 'RECOVER'; -RECURSIVE: 'RECURSIVE'; -REDO_BUFFER_SIZE: 'REDO_BUFFER_SIZE'; -REDUNDANT: 'REDUNDANT'; -RELAY: 'RELAY'; -RELAY_LOG_FILE: 'RELAY_LOG_FILE'; -RELAY_LOG_POS: 'RELAY_LOG_POS'; -RELAYLOG: 'RELAYLOG'; -REMOVE: 'REMOVE'; -REORGANIZE: 'REORGANIZE'; -REPAIR: 'REPAIR'; -REPLICATE_DO_DB: 'REPLICATE_DO_DB'; -REPLICATE_DO_TABLE: 'REPLICATE_DO_TABLE'; -REPLICATE_IGNORE_DB: 'REPLICATE_IGNORE_DB'; -REPLICATE_IGNORE_TABLE: 'REPLICATE_IGNORE_TABLE'; -REPLICATE_REWRITE_DB: 'REPLICATE_REWRITE_DB'; -REPLICATE_WILD_DO_TABLE: 'REPLICATE_WILD_DO_TABLE'; -REPLICATE_WILD_IGNORE_TABLE: 'REPLICATE_WILD_IGNORE_TABLE'; -REPLICATION: 'REPLICATION'; -RESET: 'RESET'; -RESTART: 'RESTART'; -RESUME: 'RESUME'; -RETURNED_SQLSTATE: 'RETURNED_SQLSTATE'; -RETURNING: 'RETURNING'; -RETURNS: 'RETURNS'; -REUSE: 'REUSE'; -ROLE: 'ROLE'; -ROLLBACK: 'ROLLBACK'; -ROLLUP: 'ROLLUP'; -ROTATE: 'ROTATE'; -ROW: 'ROW'; -ROWS: 'ROWS'; -ROW_FORMAT: 'ROW_FORMAT'; -RTREE: 'RTREE'; -SAVEPOINT: 'SAVEPOINT'; -SCHEDULE: 'SCHEDULE'; -SECURITY: 'SECURITY'; -SEQUENCE: 'SEQUENCE'; -SERVER: 'SERVER'; -SESSION: 'SESSION'; -SHARE: 'SHARE'; -SHARED: 'SHARED'; -SIGNED: 'SIGNED'; -SIMPLE: 'SIMPLE'; -SLAVE: 'SLAVE'; -SLOW: 'SLOW'; -SNAPSHOT: 'SNAPSHOT'; -SOCKET: 'SOCKET'; -SOME: 'SOME'; -SONAME: 'SONAME'; -SOUNDS: 'SOUNDS'; -SOURCE: 'SOURCE'; -SQL_AFTER_GTIDS: 'SQL_AFTER_GTIDS'; -SQL_AFTER_MTS_GAPS: 'SQL_AFTER_MTS_GAPS'; -SQL_BEFORE_GTIDS: 'SQL_BEFORE_GTIDS'; -SQL_BUFFER_RESULT: 'SQL_BUFFER_RESULT'; -SQL_CACHE: 'SQL_CACHE'; -SQL_NO_CACHE: 'SQL_NO_CACHE'; -SQL_THREAD: 'SQL_THREAD'; -START: 'START'; -STARTS: 'STARTS'; -STATS_AUTO_RECALC: 'STATS_AUTO_RECALC'; -STATS_PERSISTENT: 'STATS_PERSISTENT'; -STATS_SAMPLE_PAGES: 'STATS_SAMPLE_PAGES'; -STATUS: 'STATUS'; -STOP: 'STOP'; -STORAGE: 'STORAGE'; -STORED: 'STORED'; -STRING: 'STRING'; -SUBCLASS_ORIGIN: 'SUBCLASS_ORIGIN'; -SUBJECT: 'SUBJECT'; -SUBPARTITION: 'SUBPARTITION'; -SUBPARTITIONS: 'SUBPARTITIONS'; -SUSPEND: 'SUSPEND'; -SWAPS: 'SWAPS'; -SWITCHES: 'SWITCHES'; -TABLE_NAME: 'TABLE_NAME'; -TABLESPACE: 'TABLESPACE'; -TABLE_TYPE: 'TABLE_TYPE'; -TEMPORARY: 'TEMPORARY'; -TEMPTABLE: 'TEMPTABLE'; -THAN: 'THAN'; -TRADITIONAL: 'TRADITIONAL'; -TRANSACTION: 'TRANSACTION'; -TRANSACTIONAL: 'TRANSACTIONAL'; -TRIGGERS: 'TRIGGERS'; -TRUNCATE: 'TRUNCATE'; -UNBOUNDED: 'UNBOUNDED'; -UNDEFINED: 'UNDEFINED'; -UNDOFILE: 'UNDOFILE'; -UNDO_BUFFER_SIZE: 'UNDO_BUFFER_SIZE'; -UNINSTALL: 'UNINSTALL'; -UNKNOWN: 'UNKNOWN'; -UNTIL: 'UNTIL'; -UPGRADE: 'UPGRADE'; -USER: 'USER'; -USE_FRM: 'USE_FRM'; -USER_RESOURCES: 'USER_RESOURCES'; -VALIDATION: 'VALIDATION'; -VALUE: 'VALUE'; -VARIABLES: 'VARIABLES'; -VIEW: 'VIEW'; -VIRTUAL: 'VIRTUAL'; -VISIBLE: 'VISIBLE'; -WAIT: 'WAIT'; -WARNINGS: 'WARNINGS'; -WINDOW: 'WINDOW'; -WITHOUT: 'WITHOUT'; -WORK: 'WORK'; -WRAPPER: 'WRAPPER'; -X509: 'X509'; -XA: 'XA'; -XML: 'XML'; -YES: 'YES'; +ACCOUNT : 'ACCOUNT'; +ACTION : 'ACTION'; +AFTER : 'AFTER'; +AGGREGATE : 'AGGREGATE'; +ALGORITHM : 'ALGORITHM'; +ANY : 'ANY'; +AT : 'AT'; +AUTHORS : 'AUTHORS'; +AUTOCOMMIT : 'AUTOCOMMIT'; +AUTOEXTEND_SIZE : 'AUTOEXTEND_SIZE'; +AUTO_INCREMENT : 'AUTO_INCREMENT'; +AVG_ROW_LENGTH : 'AVG_ROW_LENGTH'; +BEGIN : 'BEGIN'; +BINLOG : 'BINLOG'; +BIT : 'BIT'; +BLOCK : 'BLOCK'; +BOOL : 'BOOL'; +BOOLEAN : 'BOOLEAN'; +BTREE : 'BTREE'; +CACHE : 'CACHE'; +CASCADED : 'CASCADED'; +CHAIN : 'CHAIN'; +CHANGED : 'CHANGED'; +CHANNEL : 'CHANNEL'; +CHECKSUM : 'CHECKSUM'; +PAGE_CHECKSUM : 'PAGE_CHECKSUM'; +CIPHER : 'CIPHER'; +CLASS_ORIGIN : 'CLASS_ORIGIN'; +CLIENT : 'CLIENT'; +CLOSE : 'CLOSE'; +CLUSTERING : 'CLUSTERING'; +COALESCE : 'COALESCE'; +CODE : 'CODE'; +COLUMNS : 'COLUMNS'; +COLUMN_FORMAT : 'COLUMN_FORMAT'; +COLUMN_NAME : 'COLUMN_NAME'; +COMMENT : 'COMMENT'; +COMMIT : 'COMMIT'; +COMPACT : 'COMPACT'; +COMPLETION : 'COMPLETION'; +COMPRESSED : 'COMPRESSED'; +COMPRESSION : 'COMPRESSION'; +CONCURRENT : 'CONCURRENT'; +CONNECT : 'CONNECT'; +CONNECTION : 'CONNECTION'; +CONSISTENT : 'CONSISTENT'; +CONSTRAINT_CATALOG : 'CONSTRAINT_CATALOG'; +CONSTRAINT_SCHEMA : 'CONSTRAINT_SCHEMA'; +CONSTRAINT_NAME : 'CONSTRAINT_NAME'; +CONTAINS : 'CONTAINS'; +CONTEXT : 'CONTEXT'; +CONTRIBUTORS : 'CONTRIBUTORS'; +COPY : 'COPY'; +CPU : 'CPU'; +CYCLE : 'CYCLE'; +CURSOR_NAME : 'CURSOR_NAME'; +DATA : 'DATA'; +DATAFILE : 'DATAFILE'; +DEALLOCATE : 'DEALLOCATE'; +DEFAULT_AUTH : 'DEFAULT_AUTH'; +DEFINER : 'DEFINER'; +DELAY_KEY_WRITE : 'DELAY_KEY_WRITE'; +DES_KEY_FILE : 'DES_KEY_FILE'; +DIRECTORY : 'DIRECTORY'; +DISABLE : 'DISABLE'; +DISCARD : 'DISCARD'; +DISK : 'DISK'; +DO : 'DO'; +DUMPFILE : 'DUMPFILE'; +DUPLICATE : 'DUPLICATE'; +DYNAMIC : 'DYNAMIC'; +ENABLE : 'ENABLE'; +ENCRYPTED : 'ENCRYPTED'; +ENCRYPTION : 'ENCRYPTION'; +ENCRYPTION_KEY_ID : 'ENCRYPTION_KEY_ID'; +END : 'END'; +ENDS : 'ENDS'; +ENGINE : 'ENGINE'; +ENGINES : 'ENGINES'; +ERROR : 'ERROR'; +ERRORS : 'ERRORS'; +ESCAPE : 'ESCAPE'; +EVEN : 'EVEN'; +EVENT : 'EVENT'; +EVENTS : 'EVENTS'; +EVERY : 'EVERY'; +EXCHANGE : 'EXCHANGE'; +EXCLUSIVE : 'EXCLUSIVE'; +EXPIRE : 'EXPIRE'; +EXPORT : 'EXPORT'; +EXTENDED : 'EXTENDED'; +EXTENT_SIZE : 'EXTENT_SIZE'; +FAILED_LOGIN_ATTEMPTS : 'FAILED_LOGIN_ATTEMPTS'; +FAST : 'FAST'; +FAULTS : 'FAULTS'; +FIELDS : 'FIELDS'; +FILE_BLOCK_SIZE : 'FILE_BLOCK_SIZE'; +FILTER : 'FILTER'; +FIRST : 'FIRST'; +FIXED : 'FIXED'; +FLUSH : 'FLUSH'; +FOLLOWING : 'FOLLOWING'; +FOLLOWS : 'FOLLOWS'; +FOUND : 'FOUND'; +FULL : 'FULL'; +FUNCTION : 'FUNCTION'; +GENERAL : 'GENERAL'; +GLOBAL : 'GLOBAL'; +GRANTS : 'GRANTS'; +GROUP_REPLICATION : 'GROUP_REPLICATION'; +HANDLER : 'HANDLER'; +HASH : 'HASH'; +HELP : 'HELP'; +HISTORY : 'HISTORY'; +HOST : 'HOST'; +HOSTS : 'HOSTS'; +IDENTIFIED : 'IDENTIFIED'; +IGNORE_SERVER_IDS : 'IGNORE_SERVER_IDS'; +IMPORT : 'IMPORT'; +INCREMENT : 'INCREMENT'; +INDEXES : 'INDEXES'; +INITIAL_SIZE : 'INITIAL_SIZE'; +INPLACE : 'INPLACE'; +INSERT_METHOD : 'INSERT_METHOD'; +INSTALL : 'INSTALL'; +INSTANCE : 'INSTANCE'; +INSTANT : 'INSTANT'; +INVISIBLE : 'INVISIBLE'; +INVOKER : 'INVOKER'; +IO : 'IO'; +IO_THREAD : 'IO_THREAD'; +IPC : 'IPC'; +ISOLATION : 'ISOLATION'; +ISSUER : 'ISSUER'; +JSON : 'JSON'; +KEY_BLOCK_SIZE : 'KEY_BLOCK_SIZE'; +LANGUAGE : 'LANGUAGE'; +LAST : 'LAST'; +LEAVES : 'LEAVES'; +LESS : 'LESS'; +LEVEL : 'LEVEL'; +LIST : 'LIST'; +LOCAL : 'LOCAL'; +LOGFILE : 'LOGFILE'; +LOGS : 'LOGS'; +MASTER : 'MASTER'; +MASTER_AUTO_POSITION : 'MASTER_AUTO_POSITION'; +MASTER_CONNECT_RETRY : 'MASTER_CONNECT_RETRY'; +MASTER_DELAY : 'MASTER_DELAY'; +MASTER_HEARTBEAT_PERIOD : 'MASTER_HEARTBEAT_PERIOD'; +MASTER_HOST : 'MASTER_HOST'; +MASTER_LOG_FILE : 'MASTER_LOG_FILE'; +MASTER_LOG_POS : 'MASTER_LOG_POS'; +MASTER_PASSWORD : 'MASTER_PASSWORD'; +MASTER_PORT : 'MASTER_PORT'; +MASTER_RETRY_COUNT : 'MASTER_RETRY_COUNT'; +MASTER_SSL : 'MASTER_SSL'; +MASTER_SSL_CA : 'MASTER_SSL_CA'; +MASTER_SSL_CAPATH : 'MASTER_SSL_CAPATH'; +MASTER_SSL_CERT : 'MASTER_SSL_CERT'; +MASTER_SSL_CIPHER : 'MASTER_SSL_CIPHER'; +MASTER_SSL_CRL : 'MASTER_SSL_CRL'; +MASTER_SSL_CRLPATH : 'MASTER_SSL_CRLPATH'; +MASTER_SSL_KEY : 'MASTER_SSL_KEY'; +MASTER_TLS_VERSION : 'MASTER_TLS_VERSION'; +MASTER_USER : 'MASTER_USER'; +MAX_CONNECTIONS_PER_HOUR : 'MAX_CONNECTIONS_PER_HOUR'; +MAX_QUERIES_PER_HOUR : 'MAX_QUERIES_PER_HOUR'; +MAX_ROWS : 'MAX_ROWS'; +MAX_SIZE : 'MAX_SIZE'; +MAX_UPDATES_PER_HOUR : 'MAX_UPDATES_PER_HOUR'; +MAX_USER_CONNECTIONS : 'MAX_USER_CONNECTIONS'; +MEDIUM : 'MEDIUM'; +MEMBER : 'MEMBER'; +MERGE : 'MERGE'; +MESSAGE_TEXT : 'MESSAGE_TEXT'; +MID : 'MID'; +MIGRATE : 'MIGRATE'; +MIN_ROWS : 'MIN_ROWS'; +MODE : 'MODE'; +MODIFY : 'MODIFY'; +MUTEX : 'MUTEX'; +MYSQL : 'MYSQL'; +MYSQL_ERRNO : 'MYSQL_ERRNO'; +NAME : 'NAME'; +NAMES : 'NAMES'; +NCHAR : 'NCHAR'; +NEVER : 'NEVER'; +NEXT : 'NEXT'; +NO : 'NO'; +NOCACHE : 'NOCACHE'; +NOCOPY : 'NOCOPY'; +NOCYCLE : 'NOCYCLE'; +NOMAXVALUE : 'NOMAXVALUE'; +NOMINVALUE : 'NOMINVALUE'; +NOWAIT : 'NOWAIT'; +NODEGROUP : 'NODEGROUP'; +NONE : 'NONE'; +ODBC : 'ODBC'; +OFFLINE : 'OFFLINE'; +OFFSET : 'OFFSET'; +OF : 'OF'; +OJ : 'OJ'; +OLD_PASSWORD : 'OLD_PASSWORD'; +ONE : 'ONE'; +ONLINE : 'ONLINE'; +ONLY : 'ONLY'; +OPEN : 'OPEN'; +OPTIMIZER_COSTS : 'OPTIMIZER_COSTS'; +OPTIONS : 'OPTIONS'; +OWNER : 'OWNER'; +PACK_KEYS : 'PACK_KEYS'; +PAGE : 'PAGE'; +PAGE_COMPRESSED : 'PAGE_COMPRESSED'; +PAGE_COMPRESSION_LEVEL : 'PAGE_COMPRESSION_LEVEL'; +PARSER : 'PARSER'; +PARTIAL : 'PARTIAL'; +PARTITIONING : 'PARTITIONING'; +PARTITIONS : 'PARTITIONS'; +PASSWORD : 'PASSWORD'; +PASSWORD_LOCK_TIME : 'PASSWORD_LOCK_TIME'; +PHASE : 'PHASE'; +PLUGIN : 'PLUGIN'; +PLUGIN_DIR : 'PLUGIN_DIR'; +PLUGINS : 'PLUGINS'; +PORT : 'PORT'; +PRECEDES : 'PRECEDES'; +PRECEDING : 'PRECEDING'; +PREPARE : 'PREPARE'; +PRESERVE : 'PRESERVE'; +PREV : 'PREV'; +PROCESSLIST : 'PROCESSLIST'; +PROFILE : 'PROFILE'; +PROFILES : 'PROFILES'; +PROXY : 'PROXY'; +QUERY : 'QUERY'; +QUICK : 'QUICK'; +REBUILD : 'REBUILD'; +RECOVER : 'RECOVER'; +RECURSIVE : 'RECURSIVE'; +REDO_BUFFER_SIZE : 'REDO_BUFFER_SIZE'; +REDUNDANT : 'REDUNDANT'; +RELAY : 'RELAY'; +RELAY_LOG_FILE : 'RELAY_LOG_FILE'; +RELAY_LOG_POS : 'RELAY_LOG_POS'; +RELAYLOG : 'RELAYLOG'; +REMOVE : 'REMOVE'; +REORGANIZE : 'REORGANIZE'; +REPAIR : 'REPAIR'; +REPLICATE_DO_DB : 'REPLICATE_DO_DB'; +REPLICATE_DO_TABLE : 'REPLICATE_DO_TABLE'; +REPLICATE_IGNORE_DB : 'REPLICATE_IGNORE_DB'; +REPLICATE_IGNORE_TABLE : 'REPLICATE_IGNORE_TABLE'; +REPLICATE_REWRITE_DB : 'REPLICATE_REWRITE_DB'; +REPLICATE_WILD_DO_TABLE : 'REPLICATE_WILD_DO_TABLE'; +REPLICATE_WILD_IGNORE_TABLE : 'REPLICATE_WILD_IGNORE_TABLE'; +REPLICATION : 'REPLICATION'; +RESET : 'RESET'; +RESTART : 'RESTART'; +RESUME : 'RESUME'; +RETURNED_SQLSTATE : 'RETURNED_SQLSTATE'; +RETURNING : 'RETURNING'; +RETURNS : 'RETURNS'; +REUSE : 'REUSE'; +ROLE : 'ROLE'; +ROLLBACK : 'ROLLBACK'; +ROLLUP : 'ROLLUP'; +ROTATE : 'ROTATE'; +ROW : 'ROW'; +ROWS : 'ROWS'; +ROW_FORMAT : 'ROW_FORMAT'; +RTREE : 'RTREE'; +SAVEPOINT : 'SAVEPOINT'; +SCHEDULE : 'SCHEDULE'; +SECURITY : 'SECURITY'; +SEQUENCE : 'SEQUENCE'; +SERVER : 'SERVER'; +SESSION : 'SESSION'; +SHARE : 'SHARE'; +SHARED : 'SHARED'; +SIGNED : 'SIGNED'; +SIMPLE : 'SIMPLE'; +SLAVE : 'SLAVE'; +SLOW : 'SLOW'; +SNAPSHOT : 'SNAPSHOT'; +SOCKET : 'SOCKET'; +SOME : 'SOME'; +SONAME : 'SONAME'; +SOUNDS : 'SOUNDS'; +SOURCE : 'SOURCE'; +SQL_AFTER_GTIDS : 'SQL_AFTER_GTIDS'; +SQL_AFTER_MTS_GAPS : 'SQL_AFTER_MTS_GAPS'; +SQL_BEFORE_GTIDS : 'SQL_BEFORE_GTIDS'; +SQL_BUFFER_RESULT : 'SQL_BUFFER_RESULT'; +SQL_CACHE : 'SQL_CACHE'; +SQL_NO_CACHE : 'SQL_NO_CACHE'; +SQL_THREAD : 'SQL_THREAD'; +START : 'START'; +STARTS : 'STARTS'; +STATS_AUTO_RECALC : 'STATS_AUTO_RECALC'; +STATS_PERSISTENT : 'STATS_PERSISTENT'; +STATS_SAMPLE_PAGES : 'STATS_SAMPLE_PAGES'; +STATUS : 'STATUS'; +STOP : 'STOP'; +STORAGE : 'STORAGE'; +STORED : 'STORED'; +STRING : 'STRING'; +SUBCLASS_ORIGIN : 'SUBCLASS_ORIGIN'; +SUBJECT : 'SUBJECT'; +SUBPARTITION : 'SUBPARTITION'; +SUBPARTITIONS : 'SUBPARTITIONS'; +SUSPEND : 'SUSPEND'; +SWAPS : 'SWAPS'; +SWITCHES : 'SWITCHES'; +TABLE_NAME : 'TABLE_NAME'; +TABLESPACE : 'TABLESPACE'; +TABLE_TYPE : 'TABLE_TYPE'; +TEMPORARY : 'TEMPORARY'; +TEMPTABLE : 'TEMPTABLE'; +THAN : 'THAN'; +TRADITIONAL : 'TRADITIONAL'; +TRANSACTION : 'TRANSACTION'; +TRANSACTIONAL : 'TRANSACTIONAL'; +TRIGGERS : 'TRIGGERS'; +TRUNCATE : 'TRUNCATE'; +UNBOUNDED : 'UNBOUNDED'; +UNDEFINED : 'UNDEFINED'; +UNDOFILE : 'UNDOFILE'; +UNDO_BUFFER_SIZE : 'UNDO_BUFFER_SIZE'; +UNINSTALL : 'UNINSTALL'; +UNKNOWN : 'UNKNOWN'; +UNTIL : 'UNTIL'; +UPGRADE : 'UPGRADE'; +USER : 'USER'; +USE_FRM : 'USE_FRM'; +USER_RESOURCES : 'USER_RESOURCES'; +VALIDATION : 'VALIDATION'; +VALUE : 'VALUE'; +VARIABLES : 'VARIABLES'; +VIEW : 'VIEW'; +VIRTUAL : 'VIRTUAL'; +VISIBLE : 'VISIBLE'; +WAIT : 'WAIT'; +WARNINGS : 'WARNINGS'; +WINDOW : 'WINDOW'; +WITHOUT : 'WITHOUT'; +WORK : 'WORK'; +WRAPPER : 'WRAPPER'; +X509 : 'X509'; +XA : 'XA'; +XML : 'XML'; +YES : 'YES'; // Date format Keywords -EUR: 'EUR'; -USA: 'USA'; -JIS: 'JIS'; -ISO: 'ISO'; -INTERNAL: 'INTERNAL'; - +EUR : 'EUR'; +USA : 'USA'; +JIS : 'JIS'; +ISO : 'ISO'; +INTERNAL : 'INTERNAL'; // Interval type Keywords -QUARTER: 'QUARTER'; -MONTH: 'MONTH'; -DAY: 'DAY'; -HOUR: 'HOUR'; -MINUTE: 'MINUTE'; -WEEK: 'WEEK'; -SECOND: 'SECOND'; -MICROSECOND: 'MICROSECOND'; - +QUARTER : 'QUARTER'; +MONTH : 'MONTH'; +DAY : 'DAY'; +HOUR : 'HOUR'; +MINUTE : 'MINUTE'; +WEEK : 'WEEK'; +SECOND : 'SECOND'; +MICROSECOND : 'MICROSECOND'; // PRIVILEGES -ADMIN: 'ADMIN'; -APPLICATION_PASSWORD_ADMIN: 'APPLICATION_PASSWORD_ADMIN'; -AUDIT_ABORT_EXEMPT: 'AUDIT_ABORT_EXEMPT'; -AUDIT_ADMIN: 'AUDIT_ADMIN'; -AUTHENTICATION_POLICY_ADMIN: 'AUTHENTICATION_POLICY_ADMIN'; -BACKUP_ADMIN: 'BACKUP_ADMIN'; -BINLOG_ADMIN: 'BINLOG_ADMIN'; -BINLOG_ENCRYPTION_ADMIN: 'BINLOG_ENCRYPTION_ADMIN'; -CLONE_ADMIN: 'CLONE_ADMIN'; -CONNECTION_ADMIN: 'CONNECTION_ADMIN'; -ENCRYPTION_KEY_ADMIN: 'ENCRYPTION_KEY_ADMIN'; -EXECUTE: 'EXECUTE'; -FILE: 'FILE'; -FIREWALL_ADMIN: 'FIREWALL_ADMIN'; -FIREWALL_EXEMPT: 'FIREWALL_EXEMPT'; -FIREWALL_USER: 'FIREWALL_USER'; -FLUSH_OPTIMIZER_COSTS: 'FLUSH_OPTIMIZER_COSTS'; -FLUSH_STATUS: 'FLUSH_STATUS'; -FLUSH_TABLES: 'FLUSH_TABLES'; -FLUSH_USER_RESOURCES: 'FLUSH_USER_RESOURCES'; -GROUP_REPLICATION_ADMIN: 'GROUP_REPLICATION_ADMIN'; -INNODB_REDO_LOG_ARCHIVE: 'INNODB_REDO_LOG_ARCHIVE'; -INNODB_REDO_LOG_ENABLE: 'INNODB_REDO_LOG_ENABLE'; -INVOKE: 'INVOKE'; -LAMBDA: 'LAMBDA'; -NDB_STORED_USER: 'NDB_STORED_USER'; -PASSWORDLESS_USER_ADMIN: 'PASSWORDLESS_USER_ADMIN'; -PERSIST_RO_VARIABLES_ADMIN: 'PERSIST_RO_VARIABLES_ADMIN'; -PRIVILEGES: 'PRIVILEGES'; -PROCESS: 'PROCESS'; -RELOAD: 'RELOAD'; -REPLICATION_APPLIER: 'REPLICATION_APPLIER'; -REPLICATION_SLAVE_ADMIN: 'REPLICATION_SLAVE_ADMIN'; -RESOURCE_GROUP_ADMIN: 'RESOURCE_GROUP_ADMIN'; -RESOURCE_GROUP_USER: 'RESOURCE_GROUP_USER'; -ROLE_ADMIN: 'ROLE_ADMIN'; -ROUTINE: 'ROUTINE'; -S3: 'S3'; -SERVICE_CONNECTION_ADMIN: 'SERVICE_CONNECTION_ADMIN'; -SESSION_VARIABLES_ADMIN: QUOTE_SYMB? 'SESSION_VARIABLES_ADMIN' QUOTE_SYMB?; -SET_USER_ID: 'SET_USER_ID'; -SHOW_ROUTINE: 'SHOW_ROUTINE'; -SHUTDOWN: 'SHUTDOWN'; -SUPER: 'SUPER'; -SYSTEM_VARIABLES_ADMIN: 'SYSTEM_VARIABLES_ADMIN'; -TABLES: 'TABLES'; -TABLE_ENCRYPTION_ADMIN: 'TABLE_ENCRYPTION_ADMIN'; -VERSION_TOKEN_ADMIN: 'VERSION_TOKEN_ADMIN'; -XA_RECOVER_ADMIN: 'XA_RECOVER_ADMIN'; - +ADMIN : 'ADMIN'; +APPLICATION_PASSWORD_ADMIN : 'APPLICATION_PASSWORD_ADMIN'; +AUDIT_ABORT_EXEMPT : 'AUDIT_ABORT_EXEMPT'; +AUDIT_ADMIN : 'AUDIT_ADMIN'; +AUTHENTICATION_POLICY_ADMIN : 'AUTHENTICATION_POLICY_ADMIN'; +BACKUP_ADMIN : 'BACKUP_ADMIN'; +BINLOG_ADMIN : 'BINLOG_ADMIN'; +BINLOG_ENCRYPTION_ADMIN : 'BINLOG_ENCRYPTION_ADMIN'; +CLONE_ADMIN : 'CLONE_ADMIN'; +CONNECTION_ADMIN : 'CONNECTION_ADMIN'; +ENCRYPTION_KEY_ADMIN : 'ENCRYPTION_KEY_ADMIN'; +EXECUTE : 'EXECUTE'; +FILE : 'FILE'; +FIREWALL_ADMIN : 'FIREWALL_ADMIN'; +FIREWALL_EXEMPT : 'FIREWALL_EXEMPT'; +FIREWALL_USER : 'FIREWALL_USER'; +FLUSH_OPTIMIZER_COSTS : 'FLUSH_OPTIMIZER_COSTS'; +FLUSH_STATUS : 'FLUSH_STATUS'; +FLUSH_TABLES : 'FLUSH_TABLES'; +FLUSH_USER_RESOURCES : 'FLUSH_USER_RESOURCES'; +GROUP_REPLICATION_ADMIN : 'GROUP_REPLICATION_ADMIN'; +INNODB_REDO_LOG_ARCHIVE : 'INNODB_REDO_LOG_ARCHIVE'; +INNODB_REDO_LOG_ENABLE : 'INNODB_REDO_LOG_ENABLE'; +INVOKE : 'INVOKE'; +LAMBDA : 'LAMBDA'; +NDB_STORED_USER : 'NDB_STORED_USER'; +PASSWORDLESS_USER_ADMIN : 'PASSWORDLESS_USER_ADMIN'; +PERSIST_RO_VARIABLES_ADMIN : 'PERSIST_RO_VARIABLES_ADMIN'; +PRIVILEGES : 'PRIVILEGES'; +PROCESS : 'PROCESS'; +RELOAD : 'RELOAD'; +REPLICATION_APPLIER : 'REPLICATION_APPLIER'; +REPLICATION_SLAVE_ADMIN : 'REPLICATION_SLAVE_ADMIN'; +RESOURCE_GROUP_ADMIN : 'RESOURCE_GROUP_ADMIN'; +RESOURCE_GROUP_USER : 'RESOURCE_GROUP_USER'; +ROLE_ADMIN : 'ROLE_ADMIN'; +ROUTINE : 'ROUTINE'; +S3 : 'S3'; +SERVICE_CONNECTION_ADMIN : 'SERVICE_CONNECTION_ADMIN'; +SESSION_VARIABLES_ADMIN : QUOTE_SYMB? 'SESSION_VARIABLES_ADMIN' QUOTE_SYMB?; +SET_USER_ID : 'SET_USER_ID'; +SHOW_ROUTINE : 'SHOW_ROUTINE'; +SHUTDOWN : 'SHUTDOWN'; +SUPER : 'SUPER'; +SYSTEM_VARIABLES_ADMIN : 'SYSTEM_VARIABLES_ADMIN'; +TABLES : 'TABLES'; +TABLE_ENCRYPTION_ADMIN : 'TABLE_ENCRYPTION_ADMIN'; +VERSION_TOKEN_ADMIN : 'VERSION_TOKEN_ADMIN'; +XA_RECOVER_ADMIN : 'XA_RECOVER_ADMIN'; // Charsets -ARMSCII8: 'ARMSCII8'; -ASCII: 'ASCII'; -BIG5: 'BIG5'; -CP1250: 'CP1250'; -CP1251: 'CP1251'; -CP1256: 'CP1256'; -CP1257: 'CP1257'; -CP850: 'CP850'; -CP852: 'CP852'; -CP866: 'CP866'; -CP932: 'CP932'; -DEC8: 'DEC8'; -EUCJPMS: 'EUCJPMS'; -EUCKR: 'EUCKR'; -GB18030: 'GB18030'; -GB2312: 'GB2312'; -GBK: 'GBK'; -GEOSTD8: 'GEOSTD8'; -GREEK: 'GREEK'; -HEBREW: 'HEBREW'; -HP8: 'HP8'; -KEYBCS2: 'KEYBCS2'; -KOI8R: 'KOI8R'; -KOI8U: 'KOI8U'; -LATIN1: 'LATIN1'; -LATIN2: 'LATIN2'; -LATIN5: 'LATIN5'; -LATIN7: 'LATIN7'; -MACCE: 'MACCE'; -MACROMAN: 'MACROMAN'; -SJIS: 'SJIS'; -SWE7: 'SWE7'; -TIS620: 'TIS620'; -UCS2: 'UCS2'; -UJIS: 'UJIS'; -UTF16: 'UTF16'; -UTF16LE: 'UTF16LE'; -UTF32: 'UTF32'; -UTF8: 'UTF8'; -UTF8MB3: 'UTF8MB3'; -UTF8MB4: 'UTF8MB4'; - +ARMSCII8 : 'ARMSCII8'; +ASCII : 'ASCII'; +BIG5 : 'BIG5'; +CP1250 : 'CP1250'; +CP1251 : 'CP1251'; +CP1256 : 'CP1256'; +CP1257 : 'CP1257'; +CP850 : 'CP850'; +CP852 : 'CP852'; +CP866 : 'CP866'; +CP932 : 'CP932'; +DEC8 : 'DEC8'; +EUCJPMS : 'EUCJPMS'; +EUCKR : 'EUCKR'; +GB18030 : 'GB18030'; +GB2312 : 'GB2312'; +GBK : 'GBK'; +GEOSTD8 : 'GEOSTD8'; +GREEK : 'GREEK'; +HEBREW : 'HEBREW'; +HP8 : 'HP8'; +KEYBCS2 : 'KEYBCS2'; +KOI8R : 'KOI8R'; +KOI8U : 'KOI8U'; +LATIN1 : 'LATIN1'; +LATIN2 : 'LATIN2'; +LATIN5 : 'LATIN5'; +LATIN7 : 'LATIN7'; +MACCE : 'MACCE'; +MACROMAN : 'MACROMAN'; +SJIS : 'SJIS'; +SWE7 : 'SWE7'; +TIS620 : 'TIS620'; +UCS2 : 'UCS2'; +UJIS : 'UJIS'; +UTF16 : 'UTF16'; +UTF16LE : 'UTF16LE'; +UTF32 : 'UTF32'; +UTF8 : 'UTF8'; +UTF8MB3 : 'UTF8MB3'; +UTF8MB4 : 'UTF8MB4'; // DB Engines -ARCHIVE: 'ARCHIVE'; -BLACKHOLE: 'BLACKHOLE'; -CSV: 'CSV'; -FEDERATED: 'FEDERATED'; -INNODB: 'INNODB'; -MEMORY: 'MEMORY'; -MRG_MYISAM: 'MRG_MYISAM'; -MYISAM: 'MYISAM'; -NDB: 'NDB'; -NDBCLUSTER: 'NDBCLUSTER'; -PERFORMANCE_SCHEMA: 'PERFORMANCE_SCHEMA'; -TOKUDB: 'TOKUDB'; - +ARCHIVE : 'ARCHIVE'; +BLACKHOLE : 'BLACKHOLE'; +CSV : 'CSV'; +FEDERATED : 'FEDERATED'; +INNODB : 'INNODB'; +MEMORY : 'MEMORY'; +MRG_MYISAM : 'MRG_MYISAM'; +MYISAM : 'MYISAM'; +NDB : 'NDB'; +NDBCLUSTER : 'NDBCLUSTER'; +PERFORMANCE_SCHEMA : 'PERFORMANCE_SCHEMA'; +TOKUDB : 'TOKUDB'; // Transaction Levels -REPEATABLE: 'REPEATABLE'; -COMMITTED: 'COMMITTED'; -UNCOMMITTED: 'UNCOMMITTED'; -SERIALIZABLE: 'SERIALIZABLE'; - +REPEATABLE : 'REPEATABLE'; +COMMITTED : 'COMMITTED'; +UNCOMMITTED : 'UNCOMMITTED'; +SERIALIZABLE : 'SERIALIZABLE'; // Spatial data types -GEOMETRYCOLLECTION: 'GEOMETRYCOLLECTION'; -GEOMCOLLECTION: 'GEOMCOLLECTION'; -GEOMETRY: 'GEOMETRY'; -LINESTRING: 'LINESTRING'; -MULTILINESTRING: 'MULTILINESTRING'; -MULTIPOINT: 'MULTIPOINT'; -MULTIPOLYGON: 'MULTIPOLYGON'; -POINT: 'POINT'; -POLYGON: 'POLYGON'; - +GEOMETRYCOLLECTION : 'GEOMETRYCOLLECTION'; +GEOMCOLLECTION : 'GEOMCOLLECTION'; +GEOMETRY : 'GEOMETRY'; +LINESTRING : 'LINESTRING'; +MULTILINESTRING : 'MULTILINESTRING'; +MULTIPOINT : 'MULTIPOINT'; +MULTIPOLYGON : 'MULTIPOLYGON'; +POINT : 'POINT'; +POLYGON : 'POLYGON'; // Common function names -ABS: 'ABS'; -ACOS: 'ACOS'; -ADDDATE: 'ADDDATE'; -ADDTIME: 'ADDTIME'; -AES_DECRYPT: 'AES_DECRYPT'; -AES_ENCRYPT: 'AES_ENCRYPT'; -AREA: 'AREA'; -ASBINARY: 'ASBINARY'; -ASIN: 'ASIN'; -ASTEXT: 'ASTEXT'; -ASWKB: 'ASWKB'; -ASWKT: 'ASWKT'; -ASYMMETRIC_DECRYPT: 'ASYMMETRIC_DECRYPT'; -ASYMMETRIC_DERIVE: 'ASYMMETRIC_DERIVE'; -ASYMMETRIC_ENCRYPT: 'ASYMMETRIC_ENCRYPT'; -ASYMMETRIC_SIGN: 'ASYMMETRIC_SIGN'; -ASYMMETRIC_VERIFY: 'ASYMMETRIC_VERIFY'; -ATAN: 'ATAN'; -ATAN2: 'ATAN2'; -BENCHMARK: 'BENCHMARK'; -BIN: 'BIN'; -BIT_COUNT: 'BIT_COUNT'; -BIT_LENGTH: 'BIT_LENGTH'; -BUFFER: 'BUFFER'; -CATALOG_NAME: 'CATALOG_NAME'; -CEIL: 'CEIL'; -CEILING: 'CEILING'; -CENTROID: 'CENTROID'; -CHARACTER_LENGTH: 'CHARACTER_LENGTH'; -CHARSET: 'CHARSET'; -CHAR_LENGTH: 'CHAR_LENGTH'; -COERCIBILITY: 'COERCIBILITY'; -COLLATION: 'COLLATION'; -COMPRESS: 'COMPRESS'; -CONCAT: 'CONCAT'; -CONCAT_WS: 'CONCAT_WS'; -CONNECTION_ID: 'CONNECTION_ID'; -CONV: 'CONV'; -CONVERT_TZ: 'CONVERT_TZ'; -COS: 'COS'; -COT: 'COT'; -CRC32: 'CRC32'; -CREATE_ASYMMETRIC_PRIV_KEY: 'CREATE_ASYMMETRIC_PRIV_KEY'; -CREATE_ASYMMETRIC_PUB_KEY: 'CREATE_ASYMMETRIC_PUB_KEY'; -CREATE_DH_PARAMETERS: 'CREATE_DH_PARAMETERS'; -CREATE_DIGEST: 'CREATE_DIGEST'; -CROSSES: 'CROSSES'; -DATEDIFF: 'DATEDIFF'; -DATE_FORMAT: 'DATE_FORMAT'; -DAYNAME: 'DAYNAME'; -DAYOFMONTH: 'DAYOFMONTH'; -DAYOFWEEK: 'DAYOFWEEK'; -DAYOFYEAR: 'DAYOFYEAR'; -DECODE: 'DECODE'; -DEGREES: 'DEGREES'; -DES_DECRYPT: 'DES_DECRYPT'; -DES_ENCRYPT: 'DES_ENCRYPT'; -DIMENSION: 'DIMENSION'; -DISJOINT: 'DISJOINT'; -ELT: 'ELT'; -ENCODE: 'ENCODE'; -ENCRYPT: 'ENCRYPT'; -ENDPOINT: 'ENDPOINT'; -ENGINE_ATTRIBUTE: 'ENGINE_ATTRIBUTE'; -ENVELOPE: 'ENVELOPE'; -EQUALS: 'EQUALS'; -EXP: 'EXP'; -EXPORT_SET: 'EXPORT_SET'; -EXTERIORRING: 'EXTERIORRING'; -EXTRACTVALUE: 'EXTRACTVALUE'; -FIELD: 'FIELD'; -FIND_IN_SET: 'FIND_IN_SET'; -FLOOR: 'FLOOR'; -FORMAT: 'FORMAT'; -FOUND_ROWS: 'FOUND_ROWS'; -FROM_BASE64: 'FROM_BASE64'; -FROM_DAYS: 'FROM_DAYS'; -FROM_UNIXTIME: 'FROM_UNIXTIME'; -GEOMCOLLFROMTEXT: 'GEOMCOLLFROMTEXT'; -GEOMCOLLFROMWKB: 'GEOMCOLLFROMWKB'; -GEOMETRYCOLLECTIONFROMTEXT: 'GEOMETRYCOLLECTIONFROMTEXT'; -GEOMETRYCOLLECTIONFROMWKB: 'GEOMETRYCOLLECTIONFROMWKB'; -GEOMETRYFROMTEXT: 'GEOMETRYFROMTEXT'; -GEOMETRYFROMWKB: 'GEOMETRYFROMWKB'; -GEOMETRYN: 'GEOMETRYN'; -GEOMETRYTYPE: 'GEOMETRYTYPE'; -GEOMFROMTEXT: 'GEOMFROMTEXT'; -GEOMFROMWKB: 'GEOMFROMWKB'; -GET_FORMAT: 'GET_FORMAT'; -GET_LOCK: 'GET_LOCK'; -GLENGTH: 'GLENGTH'; -GREATEST: 'GREATEST'; -GTID_SUBSET: 'GTID_SUBSET'; -GTID_SUBTRACT: 'GTID_SUBTRACT'; -HEX: 'HEX'; -IFNULL: 'IFNULL'; -INET6_ATON: 'INET6_ATON'; -INET6_NTOA: 'INET6_NTOA'; -INET_ATON: 'INET_ATON'; -INET_NTOA: 'INET_NTOA'; -INSTR: 'INSTR'; -INTERIORRINGN: 'INTERIORRINGN'; -INTERSECTS: 'INTERSECTS'; -ISCLOSED: 'ISCLOSED'; -ISEMPTY: 'ISEMPTY'; -ISNULL: 'ISNULL'; -ISSIMPLE: 'ISSIMPLE'; -IS_FREE_LOCK: 'IS_FREE_LOCK'; -IS_IPV4: 'IS_IPV4'; -IS_IPV4_COMPAT: 'IS_IPV4_COMPAT'; -IS_IPV4_MAPPED: 'IS_IPV4_MAPPED'; -IS_IPV6: 'IS_IPV6'; -IS_USED_LOCK: 'IS_USED_LOCK'; -LAST_INSERT_ID: 'LAST_INSERT_ID'; -LCASE: 'LCASE'; -LEAST: 'LEAST'; -LENGTH: 'LENGTH'; -LINEFROMTEXT: 'LINEFROMTEXT'; -LINEFROMWKB: 'LINEFROMWKB'; -LINESTRINGFROMTEXT: 'LINESTRINGFROMTEXT'; -LINESTRINGFROMWKB: 'LINESTRINGFROMWKB'; -LN: 'LN'; -LOAD_FILE: 'LOAD_FILE'; -LOCATE: 'LOCATE'; -LOG: 'LOG'; -LOG10: 'LOG10'; -LOG2: 'LOG2'; -LOWER: 'LOWER'; -LPAD: 'LPAD'; -LTRIM: 'LTRIM'; -MAKEDATE: 'MAKEDATE'; -MAKETIME: 'MAKETIME'; -MAKE_SET: 'MAKE_SET'; -MASTER_POS_WAIT: 'MASTER_POS_WAIT'; -MBRCONTAINS: 'MBRCONTAINS'; -MBRDISJOINT: 'MBRDISJOINT'; -MBREQUAL: 'MBREQUAL'; -MBRINTERSECTS: 'MBRINTERSECTS'; -MBROVERLAPS: 'MBROVERLAPS'; -MBRTOUCHES: 'MBRTOUCHES'; -MBRWITHIN: 'MBRWITHIN'; -MD5: 'MD5'; -MLINEFROMTEXT: 'MLINEFROMTEXT'; -MLINEFROMWKB: 'MLINEFROMWKB'; -MONTHNAME: 'MONTHNAME'; -MPOINTFROMTEXT: 'MPOINTFROMTEXT'; -MPOINTFROMWKB: 'MPOINTFROMWKB'; -MPOLYFROMTEXT: 'MPOLYFROMTEXT'; -MPOLYFROMWKB: 'MPOLYFROMWKB'; -MULTILINESTRINGFROMTEXT: 'MULTILINESTRINGFROMTEXT'; -MULTILINESTRINGFROMWKB: 'MULTILINESTRINGFROMWKB'; -MULTIPOINTFROMTEXT: 'MULTIPOINTFROMTEXT'; -MULTIPOINTFROMWKB: 'MULTIPOINTFROMWKB'; -MULTIPOLYGONFROMTEXT: 'MULTIPOLYGONFROMTEXT'; -MULTIPOLYGONFROMWKB: 'MULTIPOLYGONFROMWKB'; -NAME_CONST: 'NAME_CONST'; -NULLIF: 'NULLIF'; -NUMGEOMETRIES: 'NUMGEOMETRIES'; -NUMINTERIORRINGS: 'NUMINTERIORRINGS'; -NUMPOINTS: 'NUMPOINTS'; -OCT: 'OCT'; -OCTET_LENGTH: 'OCTET_LENGTH'; -ORD: 'ORD'; -OVERLAPS: 'OVERLAPS'; -PERIOD_ADD: 'PERIOD_ADD'; -PERIOD_DIFF: 'PERIOD_DIFF'; -PI: 'PI'; -POINTFROMTEXT: 'POINTFROMTEXT'; -POINTFROMWKB: 'POINTFROMWKB'; -POINTN: 'POINTN'; -POLYFROMTEXT: 'POLYFROMTEXT'; -POLYFROMWKB: 'POLYFROMWKB'; -POLYGONFROMTEXT: 'POLYGONFROMTEXT'; -POLYGONFROMWKB: 'POLYGONFROMWKB'; -POW: 'POW'; -POWER: 'POWER'; -QUOTE: 'QUOTE'; -RADIANS: 'RADIANS'; -RAND: 'RAND'; -RANDOM: 'RANDOM'; -RANDOM_BYTES: 'RANDOM_BYTES'; -RELEASE_LOCK: 'RELEASE_LOCK'; -REVERSE: 'REVERSE'; -ROUND: 'ROUND'; -ROW_COUNT: 'ROW_COUNT'; -RPAD: 'RPAD'; -RTRIM: 'RTRIM'; -SEC_TO_TIME: 'SEC_TO_TIME'; -SECONDARY_ENGINE_ATTRIBUTE: 'SECONDARY_ENGINE_ATTRIBUTE'; -SESSION_USER: 'SESSION_USER'; -SHA: 'SHA'; -SHA1: 'SHA1'; -SHA2: 'SHA2'; -SCHEMA_NAME: 'SCHEMA_NAME'; -SIGN: 'SIGN'; -SIN: 'SIN'; -SLEEP: 'SLEEP'; -SOUNDEX: 'SOUNDEX'; -SQL_THREAD_WAIT_AFTER_GTIDS: 'SQL_THREAD_WAIT_AFTER_GTIDS'; -SQRT: 'SQRT'; -SRID: 'SRID'; -STARTPOINT: 'STARTPOINT'; -STRCMP: 'STRCMP'; -STR_TO_DATE: 'STR_TO_DATE'; -ST_AREA: 'ST_AREA'; -ST_ASBINARY: 'ST_ASBINARY'; -ST_ASTEXT: 'ST_ASTEXT'; -ST_ASWKB: 'ST_ASWKB'; -ST_ASWKT: 'ST_ASWKT'; -ST_BUFFER: 'ST_BUFFER'; -ST_CENTROID: 'ST_CENTROID'; -ST_CONTAINS: 'ST_CONTAINS'; -ST_CROSSES: 'ST_CROSSES'; -ST_DIFFERENCE: 'ST_DIFFERENCE'; -ST_DIMENSION: 'ST_DIMENSION'; -ST_DISJOINT: 'ST_DISJOINT'; -ST_DISTANCE: 'ST_DISTANCE'; -ST_ENDPOINT: 'ST_ENDPOINT'; -ST_ENVELOPE: 'ST_ENVELOPE'; -ST_EQUALS: 'ST_EQUALS'; -ST_EXTERIORRING: 'ST_EXTERIORRING'; -ST_GEOMCOLLFROMTEXT: 'ST_GEOMCOLLFROMTEXT'; -ST_GEOMCOLLFROMTXT: 'ST_GEOMCOLLFROMTXT'; -ST_GEOMCOLLFROMWKB: 'ST_GEOMCOLLFROMWKB'; -ST_GEOMETRYCOLLECTIONFROMTEXT: 'ST_GEOMETRYCOLLECTIONFROMTEXT'; -ST_GEOMETRYCOLLECTIONFROMWKB: 'ST_GEOMETRYCOLLECTIONFROMWKB'; -ST_GEOMETRYFROMTEXT: 'ST_GEOMETRYFROMTEXT'; -ST_GEOMETRYFROMWKB: 'ST_GEOMETRYFROMWKB'; -ST_GEOMETRYN: 'ST_GEOMETRYN'; -ST_GEOMETRYTYPE: 'ST_GEOMETRYTYPE'; -ST_GEOMFROMTEXT: 'ST_GEOMFROMTEXT'; -ST_GEOMFROMWKB: 'ST_GEOMFROMWKB'; -ST_INTERIORRINGN: 'ST_INTERIORRINGN'; -ST_INTERSECTION: 'ST_INTERSECTION'; -ST_INTERSECTS: 'ST_INTERSECTS'; -ST_ISCLOSED: 'ST_ISCLOSED'; -ST_ISEMPTY: 'ST_ISEMPTY'; -ST_ISSIMPLE: 'ST_ISSIMPLE'; -ST_LINEFROMTEXT: 'ST_LINEFROMTEXT'; -ST_LINEFROMWKB: 'ST_LINEFROMWKB'; -ST_LINESTRINGFROMTEXT: 'ST_LINESTRINGFROMTEXT'; -ST_LINESTRINGFROMWKB: 'ST_LINESTRINGFROMWKB'; -ST_NUMGEOMETRIES: 'ST_NUMGEOMETRIES'; -ST_NUMINTERIORRING: 'ST_NUMINTERIORRING'; -ST_NUMINTERIORRINGS: 'ST_NUMINTERIORRINGS'; -ST_NUMPOINTS: 'ST_NUMPOINTS'; -ST_OVERLAPS: 'ST_OVERLAPS'; -ST_POINTFROMTEXT: 'ST_POINTFROMTEXT'; -ST_POINTFROMWKB: 'ST_POINTFROMWKB'; -ST_POINTN: 'ST_POINTN'; -ST_POLYFROMTEXT: 'ST_POLYFROMTEXT'; -ST_POLYFROMWKB: 'ST_POLYFROMWKB'; -ST_POLYGONFROMTEXT: 'ST_POLYGONFROMTEXT'; -ST_POLYGONFROMWKB: 'ST_POLYGONFROMWKB'; -ST_SRID: 'ST_SRID'; -ST_STARTPOINT: 'ST_STARTPOINT'; -ST_SYMDIFFERENCE: 'ST_SYMDIFFERENCE'; -ST_TOUCHES: 'ST_TOUCHES'; -ST_UNION: 'ST_UNION'; -ST_WITHIN: 'ST_WITHIN'; -ST_X: 'ST_X'; -ST_Y: 'ST_Y'; -SUBDATE: 'SUBDATE'; -SUBSTRING_INDEX: 'SUBSTRING_INDEX'; -SUBTIME: 'SUBTIME'; -SYSTEM_USER: 'SYSTEM_USER'; -TAN: 'TAN'; -TIMEDIFF: 'TIMEDIFF'; -TIMESTAMPADD: 'TIMESTAMPADD'; -TIMESTAMPDIFF: 'TIMESTAMPDIFF'; -TIME_FORMAT: 'TIME_FORMAT'; -TIME_TO_SEC: 'TIME_TO_SEC'; -TOUCHES: 'TOUCHES'; -TO_BASE64: 'TO_BASE64'; -TO_DAYS: 'TO_DAYS'; -TO_SECONDS: 'TO_SECONDS'; -TP_CONNECTION_ADMIN: 'TP_CONNECTION_ADMIN'; -UCASE: 'UCASE'; -UNCOMPRESS: 'UNCOMPRESS'; -UNCOMPRESSED_LENGTH: 'UNCOMPRESSED_LENGTH'; -UNHEX: 'UNHEX'; -UNIX_TIMESTAMP: 'UNIX_TIMESTAMP'; -UPDATEXML: 'UPDATEXML'; -UPPER: 'UPPER'; -UUID: 'UUID'; -UUID_SHORT: 'UUID_SHORT'; -VALIDATE_PASSWORD_STRENGTH: 'VALIDATE_PASSWORD_STRENGTH'; -VERSION: 'VERSION'; -WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS: 'WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS'; -WEEKDAY: 'WEEKDAY'; -WEEKOFYEAR: 'WEEKOFYEAR'; -WEIGHT_STRING: 'WEIGHT_STRING'; -WITHIN: 'WITHIN'; -YEARWEEK: 'YEARWEEK'; -Y_FUNCTION: 'Y'; -X_FUNCTION: 'X'; - - - +ABS : 'ABS'; +ACOS : 'ACOS'; +ADDDATE : 'ADDDATE'; +ADDTIME : 'ADDTIME'; +AES_DECRYPT : 'AES_DECRYPT'; +AES_ENCRYPT : 'AES_ENCRYPT'; +AREA : 'AREA'; +ASBINARY : 'ASBINARY'; +ASIN : 'ASIN'; +ASTEXT : 'ASTEXT'; +ASWKB : 'ASWKB'; +ASWKT : 'ASWKT'; +ASYMMETRIC_DECRYPT : 'ASYMMETRIC_DECRYPT'; +ASYMMETRIC_DERIVE : 'ASYMMETRIC_DERIVE'; +ASYMMETRIC_ENCRYPT : 'ASYMMETRIC_ENCRYPT'; +ASYMMETRIC_SIGN : 'ASYMMETRIC_SIGN'; +ASYMMETRIC_VERIFY : 'ASYMMETRIC_VERIFY'; +ATAN : 'ATAN'; +ATAN2 : 'ATAN2'; +BENCHMARK : 'BENCHMARK'; +BIN : 'BIN'; +BIT_COUNT : 'BIT_COUNT'; +BIT_LENGTH : 'BIT_LENGTH'; +BUFFER : 'BUFFER'; +CATALOG_NAME : 'CATALOG_NAME'; +CEIL : 'CEIL'; +CEILING : 'CEILING'; +CENTROID : 'CENTROID'; +CHARACTER_LENGTH : 'CHARACTER_LENGTH'; +CHARSET : 'CHARSET'; +CHAR_LENGTH : 'CHAR_LENGTH'; +COERCIBILITY : 'COERCIBILITY'; +COLLATION : 'COLLATION'; +COMPRESS : 'COMPRESS'; +CONCAT : 'CONCAT'; +CONCAT_WS : 'CONCAT_WS'; +CONNECTION_ID : 'CONNECTION_ID'; +CONV : 'CONV'; +CONVERT_TZ : 'CONVERT_TZ'; +COS : 'COS'; +COT : 'COT'; +CRC32 : 'CRC32'; +CREATE_ASYMMETRIC_PRIV_KEY : 'CREATE_ASYMMETRIC_PRIV_KEY'; +CREATE_ASYMMETRIC_PUB_KEY : 'CREATE_ASYMMETRIC_PUB_KEY'; +CREATE_DH_PARAMETERS : 'CREATE_DH_PARAMETERS'; +CREATE_DIGEST : 'CREATE_DIGEST'; +CROSSES : 'CROSSES'; +DATEDIFF : 'DATEDIFF'; +DATE_FORMAT : 'DATE_FORMAT'; +DAYNAME : 'DAYNAME'; +DAYOFMONTH : 'DAYOFMONTH'; +DAYOFWEEK : 'DAYOFWEEK'; +DAYOFYEAR : 'DAYOFYEAR'; +DECODE : 'DECODE'; +DEGREES : 'DEGREES'; +DES_DECRYPT : 'DES_DECRYPT'; +DES_ENCRYPT : 'DES_ENCRYPT'; +DIMENSION : 'DIMENSION'; +DISJOINT : 'DISJOINT'; +ELT : 'ELT'; +ENCODE : 'ENCODE'; +ENCRYPT : 'ENCRYPT'; +ENDPOINT : 'ENDPOINT'; +ENGINE_ATTRIBUTE : 'ENGINE_ATTRIBUTE'; +ENVELOPE : 'ENVELOPE'; +EQUALS : 'EQUALS'; +EXP : 'EXP'; +EXPORT_SET : 'EXPORT_SET'; +EXTERIORRING : 'EXTERIORRING'; +EXTRACTVALUE : 'EXTRACTVALUE'; +FIELD : 'FIELD'; +FIND_IN_SET : 'FIND_IN_SET'; +FLOOR : 'FLOOR'; +FORMAT : 'FORMAT'; +FOUND_ROWS : 'FOUND_ROWS'; +FROM_BASE64 : 'FROM_BASE64'; +FROM_DAYS : 'FROM_DAYS'; +FROM_UNIXTIME : 'FROM_UNIXTIME'; +GEOMCOLLFROMTEXT : 'GEOMCOLLFROMTEXT'; +GEOMCOLLFROMWKB : 'GEOMCOLLFROMWKB'; +GEOMETRYCOLLECTIONFROMTEXT : 'GEOMETRYCOLLECTIONFROMTEXT'; +GEOMETRYCOLLECTIONFROMWKB : 'GEOMETRYCOLLECTIONFROMWKB'; +GEOMETRYFROMTEXT : 'GEOMETRYFROMTEXT'; +GEOMETRYFROMWKB : 'GEOMETRYFROMWKB'; +GEOMETRYN : 'GEOMETRYN'; +GEOMETRYTYPE : 'GEOMETRYTYPE'; +GEOMFROMTEXT : 'GEOMFROMTEXT'; +GEOMFROMWKB : 'GEOMFROMWKB'; +GET_FORMAT : 'GET_FORMAT'; +GET_LOCK : 'GET_LOCK'; +GLENGTH : 'GLENGTH'; +GREATEST : 'GREATEST'; +GTID_SUBSET : 'GTID_SUBSET'; +GTID_SUBTRACT : 'GTID_SUBTRACT'; +HEX : 'HEX'; +IFNULL : 'IFNULL'; +INET6_ATON : 'INET6_ATON'; +INET6_NTOA : 'INET6_NTOA'; +INET_ATON : 'INET_ATON'; +INET_NTOA : 'INET_NTOA'; +INSTR : 'INSTR'; +INTERIORRINGN : 'INTERIORRINGN'; +INTERSECTS : 'INTERSECTS'; +ISCLOSED : 'ISCLOSED'; +ISEMPTY : 'ISEMPTY'; +ISNULL : 'ISNULL'; +ISSIMPLE : 'ISSIMPLE'; +IS_FREE_LOCK : 'IS_FREE_LOCK'; +IS_IPV4 : 'IS_IPV4'; +IS_IPV4_COMPAT : 'IS_IPV4_COMPAT'; +IS_IPV4_MAPPED : 'IS_IPV4_MAPPED'; +IS_IPV6 : 'IS_IPV6'; +IS_USED_LOCK : 'IS_USED_LOCK'; +LAST_INSERT_ID : 'LAST_INSERT_ID'; +LCASE : 'LCASE'; +LEAST : 'LEAST'; +LENGTH : 'LENGTH'; +LINEFROMTEXT : 'LINEFROMTEXT'; +LINEFROMWKB : 'LINEFROMWKB'; +LINESTRINGFROMTEXT : 'LINESTRINGFROMTEXT'; +LINESTRINGFROMWKB : 'LINESTRINGFROMWKB'; +LN : 'LN'; +LOAD_FILE : 'LOAD_FILE'; +LOCATE : 'LOCATE'; +LOG : 'LOG'; +LOG10 : 'LOG10'; +LOG2 : 'LOG2'; +LOWER : 'LOWER'; +LPAD : 'LPAD'; +LTRIM : 'LTRIM'; +MAKEDATE : 'MAKEDATE'; +MAKETIME : 'MAKETIME'; +MAKE_SET : 'MAKE_SET'; +MASTER_POS_WAIT : 'MASTER_POS_WAIT'; +MBRCONTAINS : 'MBRCONTAINS'; +MBRDISJOINT : 'MBRDISJOINT'; +MBREQUAL : 'MBREQUAL'; +MBRINTERSECTS : 'MBRINTERSECTS'; +MBROVERLAPS : 'MBROVERLAPS'; +MBRTOUCHES : 'MBRTOUCHES'; +MBRWITHIN : 'MBRWITHIN'; +MD5 : 'MD5'; +MLINEFROMTEXT : 'MLINEFROMTEXT'; +MLINEFROMWKB : 'MLINEFROMWKB'; +MONTHNAME : 'MONTHNAME'; +MPOINTFROMTEXT : 'MPOINTFROMTEXT'; +MPOINTFROMWKB : 'MPOINTFROMWKB'; +MPOLYFROMTEXT : 'MPOLYFROMTEXT'; +MPOLYFROMWKB : 'MPOLYFROMWKB'; +MULTILINESTRINGFROMTEXT : 'MULTILINESTRINGFROMTEXT'; +MULTILINESTRINGFROMWKB : 'MULTILINESTRINGFROMWKB'; +MULTIPOINTFROMTEXT : 'MULTIPOINTFROMTEXT'; +MULTIPOINTFROMWKB : 'MULTIPOINTFROMWKB'; +MULTIPOLYGONFROMTEXT : 'MULTIPOLYGONFROMTEXT'; +MULTIPOLYGONFROMWKB : 'MULTIPOLYGONFROMWKB'; +NAME_CONST : 'NAME_CONST'; +NULLIF : 'NULLIF'; +NUMGEOMETRIES : 'NUMGEOMETRIES'; +NUMINTERIORRINGS : 'NUMINTERIORRINGS'; +NUMPOINTS : 'NUMPOINTS'; +OCT : 'OCT'; +OCTET_LENGTH : 'OCTET_LENGTH'; +ORD : 'ORD'; +OVERLAPS : 'OVERLAPS'; +PERIOD_ADD : 'PERIOD_ADD'; +PERIOD_DIFF : 'PERIOD_DIFF'; +PI : 'PI'; +POINTFROMTEXT : 'POINTFROMTEXT'; +POINTFROMWKB : 'POINTFROMWKB'; +POINTN : 'POINTN'; +POLYFROMTEXT : 'POLYFROMTEXT'; +POLYFROMWKB : 'POLYFROMWKB'; +POLYGONFROMTEXT : 'POLYGONFROMTEXT'; +POLYGONFROMWKB : 'POLYGONFROMWKB'; +POW : 'POW'; +POWER : 'POWER'; +QUOTE : 'QUOTE'; +RADIANS : 'RADIANS'; +RAND : 'RAND'; +RANDOM : 'RANDOM'; +RANDOM_BYTES : 'RANDOM_BYTES'; +RELEASE_LOCK : 'RELEASE_LOCK'; +REVERSE : 'REVERSE'; +ROUND : 'ROUND'; +ROW_COUNT : 'ROW_COUNT'; +RPAD : 'RPAD'; +RTRIM : 'RTRIM'; +SEC_TO_TIME : 'SEC_TO_TIME'; +SECONDARY_ENGINE_ATTRIBUTE : 'SECONDARY_ENGINE_ATTRIBUTE'; +SESSION_USER : 'SESSION_USER'; +SHA : 'SHA'; +SHA1 : 'SHA1'; +SHA2 : 'SHA2'; +SCHEMA_NAME : 'SCHEMA_NAME'; +SIGN : 'SIGN'; +SIN : 'SIN'; +SLEEP : 'SLEEP'; +SOUNDEX : 'SOUNDEX'; +SQL_THREAD_WAIT_AFTER_GTIDS : 'SQL_THREAD_WAIT_AFTER_GTIDS'; +SQRT : 'SQRT'; +SRID : 'SRID'; +STARTPOINT : 'STARTPOINT'; +STRCMP : 'STRCMP'; +STR_TO_DATE : 'STR_TO_DATE'; +ST_AREA : 'ST_AREA'; +ST_ASBINARY : 'ST_ASBINARY'; +ST_ASTEXT : 'ST_ASTEXT'; +ST_ASWKB : 'ST_ASWKB'; +ST_ASWKT : 'ST_ASWKT'; +ST_BUFFER : 'ST_BUFFER'; +ST_CENTROID : 'ST_CENTROID'; +ST_CONTAINS : 'ST_CONTAINS'; +ST_CROSSES : 'ST_CROSSES'; +ST_DIFFERENCE : 'ST_DIFFERENCE'; +ST_DIMENSION : 'ST_DIMENSION'; +ST_DISJOINT : 'ST_DISJOINT'; +ST_DISTANCE : 'ST_DISTANCE'; +ST_ENDPOINT : 'ST_ENDPOINT'; +ST_ENVELOPE : 'ST_ENVELOPE'; +ST_EQUALS : 'ST_EQUALS'; +ST_EXTERIORRING : 'ST_EXTERIORRING'; +ST_GEOMCOLLFROMTEXT : 'ST_GEOMCOLLFROMTEXT'; +ST_GEOMCOLLFROMTXT : 'ST_GEOMCOLLFROMTXT'; +ST_GEOMCOLLFROMWKB : 'ST_GEOMCOLLFROMWKB'; +ST_GEOMETRYCOLLECTIONFROMTEXT : 'ST_GEOMETRYCOLLECTIONFROMTEXT'; +ST_GEOMETRYCOLLECTIONFROMWKB : 'ST_GEOMETRYCOLLECTIONFROMWKB'; +ST_GEOMETRYFROMTEXT : 'ST_GEOMETRYFROMTEXT'; +ST_GEOMETRYFROMWKB : 'ST_GEOMETRYFROMWKB'; +ST_GEOMETRYN : 'ST_GEOMETRYN'; +ST_GEOMETRYTYPE : 'ST_GEOMETRYTYPE'; +ST_GEOMFROMTEXT : 'ST_GEOMFROMTEXT'; +ST_GEOMFROMWKB : 'ST_GEOMFROMWKB'; +ST_INTERIORRINGN : 'ST_INTERIORRINGN'; +ST_INTERSECTION : 'ST_INTERSECTION'; +ST_INTERSECTS : 'ST_INTERSECTS'; +ST_ISCLOSED : 'ST_ISCLOSED'; +ST_ISEMPTY : 'ST_ISEMPTY'; +ST_ISSIMPLE : 'ST_ISSIMPLE'; +ST_LINEFROMTEXT : 'ST_LINEFROMTEXT'; +ST_LINEFROMWKB : 'ST_LINEFROMWKB'; +ST_LINESTRINGFROMTEXT : 'ST_LINESTRINGFROMTEXT'; +ST_LINESTRINGFROMWKB : 'ST_LINESTRINGFROMWKB'; +ST_NUMGEOMETRIES : 'ST_NUMGEOMETRIES'; +ST_NUMINTERIORRING : 'ST_NUMINTERIORRING'; +ST_NUMINTERIORRINGS : 'ST_NUMINTERIORRINGS'; +ST_NUMPOINTS : 'ST_NUMPOINTS'; +ST_OVERLAPS : 'ST_OVERLAPS'; +ST_POINTFROMTEXT : 'ST_POINTFROMTEXT'; +ST_POINTFROMWKB : 'ST_POINTFROMWKB'; +ST_POINTN : 'ST_POINTN'; +ST_POLYFROMTEXT : 'ST_POLYFROMTEXT'; +ST_POLYFROMWKB : 'ST_POLYFROMWKB'; +ST_POLYGONFROMTEXT : 'ST_POLYGONFROMTEXT'; +ST_POLYGONFROMWKB : 'ST_POLYGONFROMWKB'; +ST_SRID : 'ST_SRID'; +ST_STARTPOINT : 'ST_STARTPOINT'; +ST_SYMDIFFERENCE : 'ST_SYMDIFFERENCE'; +ST_TOUCHES : 'ST_TOUCHES'; +ST_UNION : 'ST_UNION'; +ST_WITHIN : 'ST_WITHIN'; +ST_X : 'ST_X'; +ST_Y : 'ST_Y'; +SUBDATE : 'SUBDATE'; +SUBSTRING_INDEX : 'SUBSTRING_INDEX'; +SUBTIME : 'SUBTIME'; +SYSTEM_USER : 'SYSTEM_USER'; +TAN : 'TAN'; +TIMEDIFF : 'TIMEDIFF'; +TIMESTAMPADD : 'TIMESTAMPADD'; +TIMESTAMPDIFF : 'TIMESTAMPDIFF'; +TIME_FORMAT : 'TIME_FORMAT'; +TIME_TO_SEC : 'TIME_TO_SEC'; +TOUCHES : 'TOUCHES'; +TO_BASE64 : 'TO_BASE64'; +TO_DAYS : 'TO_DAYS'; +TO_SECONDS : 'TO_SECONDS'; +TP_CONNECTION_ADMIN : 'TP_CONNECTION_ADMIN'; +UCASE : 'UCASE'; +UNCOMPRESS : 'UNCOMPRESS'; +UNCOMPRESSED_LENGTH : 'UNCOMPRESSED_LENGTH'; +UNHEX : 'UNHEX'; +UNIX_TIMESTAMP : 'UNIX_TIMESTAMP'; +UPDATEXML : 'UPDATEXML'; +UPPER : 'UPPER'; +UUID : 'UUID'; +UUID_SHORT : 'UUID_SHORT'; +VALIDATE_PASSWORD_STRENGTH : 'VALIDATE_PASSWORD_STRENGTH'; +VERSION : 'VERSION'; +WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS : 'WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS'; +WEEKDAY : 'WEEKDAY'; +WEEKOFYEAR : 'WEEKOFYEAR'; +WEIGHT_STRING : 'WEIGHT_STRING'; +WITHIN : 'WITHIN'; +YEARWEEK : 'YEARWEEK'; +Y_FUNCTION : 'Y'; +X_FUNCTION : 'X'; // Operators // Operators. Assigns -VAR_ASSIGN: ':='; -PLUS_ASSIGN: '+='; -MINUS_ASSIGN: '-='; -MULT_ASSIGN: '*='; -DIV_ASSIGN: '/='; -MOD_ASSIGN: '%='; -AND_ASSIGN: '&='; -XOR_ASSIGN: '^='; -OR_ASSIGN: '|='; - +VAR_ASSIGN : ':='; +PLUS_ASSIGN : '+='; +MINUS_ASSIGN : '-='; +MULT_ASSIGN : '*='; +DIV_ASSIGN : '/='; +MOD_ASSIGN : '%='; +AND_ASSIGN : '&='; +XOR_ASSIGN : '^='; +OR_ASSIGN : '|='; // Operators. Arithmetics -STAR: '*'; -DIVIDE: '/'; -MODULE: '%'; -PLUS: '+'; -MINUS: '-'; -DIV: 'DIV'; -MOD: 'MOD'; - +STAR : '*'; +DIVIDE : '/'; +MODULE : '%'; +PLUS : '+'; +MINUS : '-'; +DIV : 'DIV'; +MOD : 'MOD'; // Operators. Comparation -EQUAL_SYMBOL: '='; -GREATER_SYMBOL: '>'; -LESS_SYMBOL: '<'; -EXCLAMATION_SYMBOL: '!'; - +EQUAL_SYMBOL : '='; +GREATER_SYMBOL : '>'; +LESS_SYMBOL : '<'; +EXCLAMATION_SYMBOL : '!'; // Operators. Bit -BIT_NOT_OP: '~'; -BIT_OR_OP: '|'; -BIT_AND_OP: '&'; -BIT_XOR_OP: '^'; - +BIT_NOT_OP : '~'; +BIT_OR_OP : '|'; +BIT_AND_OP : '&'; +BIT_XOR_OP : '^'; // Constructors symbols -DOT: '.'; -LR_BRACKET: '('; -RR_BRACKET: ')'; -COMMA: ','; -SEMI: ';'; -AT_SIGN: '@'; -ZERO_DECIMAL: '0'; -ONE_DECIMAL: '1'; -TWO_DECIMAL: '2'; -SINGLE_QUOTE_SYMB: '\''; -DOUBLE_QUOTE_SYMB: '"'; -REVERSE_QUOTE_SYMB: '`'; -COLON_SYMB: ':'; - -fragment QUOTE_SYMB - : SINGLE_QUOTE_SYMB | DOUBLE_QUOTE_SYMB | REVERSE_QUOTE_SYMB - ; - - +DOT : '.'; +LR_BRACKET : '('; +RR_BRACKET : ')'; +COMMA : ','; +SEMI : ';'; +AT_SIGN : '@'; +ZERO_DECIMAL : '0'; +ONE_DECIMAL : '1'; +TWO_DECIMAL : '2'; +SINGLE_QUOTE_SYMB : '\''; +DOUBLE_QUOTE_SYMB : '"'; +REVERSE_QUOTE_SYMB : '`'; +COLON_SYMB : ':'; + +fragment QUOTE_SYMB: SINGLE_QUOTE_SYMB | DOUBLE_QUOTE_SYMB | REVERSE_QUOTE_SYMB; // Charsets -CHARSET_REVERSE_QOUTE_STRING: '`' CHARSET_NAME '`'; - - +CHARSET_REVERSE_QOUTE_STRING: '`' CHARSET_NAME '`'; // File's sizes - -FILESIZE_LITERAL: DEC_DIGIT+ ('K'|'M'|'G'|'T'); - - +FILESIZE_LITERAL: DEC_DIGIT+ ('K' | 'M' | 'G' | 'T'); // Literal Primitives - -START_NATIONAL_STRING_LITERAL: 'N' SQUOTA_STRING; -STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING; -DECIMAL_LITERAL: DEC_DIGIT+; -HEXADECIMAL_LITERAL: 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\'' - | '0X' HEX_DIGIT+; - -REAL_LITERAL: DEC_DIGIT* '.' DEC_DIGIT+ - | DEC_DIGIT+ '.' EXPONENT_NUM_PART - | DEC_DIGIT* '.' (DEC_DIGIT+ EXPONENT_NUM_PART) - | DEC_DIGIT+ EXPONENT_NUM_PART; -NULL_SPEC_LITERAL: '\\' 'N'; -BIT_STRING: BIT_STRING_L; -STRING_CHARSET_NAME: '_' CHARSET_NAME; - - - +START_NATIONAL_STRING_LITERAL : 'N' SQUOTA_STRING; +STRING_LITERAL : DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING; +DECIMAL_LITERAL : DEC_DIGIT+; +HEXADECIMAL_LITERAL : 'X' '\'' (HEX_DIGIT HEX_DIGIT)+ '\'' | '0X' HEX_DIGIT+; + +REAL_LITERAL: + DEC_DIGIT* '.' DEC_DIGIT+ + | DEC_DIGIT+ '.' EXPONENT_NUM_PART + | DEC_DIGIT* '.' (DEC_DIGIT+ EXPONENT_NUM_PART) + | DEC_DIGIT+ EXPONENT_NUM_PART +; +NULL_SPEC_LITERAL : '\\' 'N'; +BIT_STRING : BIT_STRING_L; +STRING_CHARSET_NAME : '_' CHARSET_NAME; // Hack for dotID // Prevent recognize string: .123somelatin AS ((.123), FLOAT_LITERAL), ((somelatin), ID) // it must recoginze: .123somelatin AS ((.), DOT), (123somelatin, ID) -DOT_ID: '.' ID_LITERAL; - - +DOT_ID: '.' ID_LITERAL; // Identifiers -ID: ID_LITERAL; +ID: ID_LITERAL; // DOUBLE_QUOTE_ID: '"' ~'"'+ '"'; -REVERSE_QUOTE_ID: BQUOTA_STRING; -HOST_IP_ADDRESS: (AT_SIGN IP_ADDRESS); -LOCAL_ID: AT_SIGN - ( - STRING_LITERAL | [A-Z0-9._$\u0080-\uFFFF]+ - ); -GLOBAL_ID: AT_SIGN AT_SIGN - ( - [A-Z0-9._$\u0080-\uFFFF]+ | BQUOTA_STRING - ); - +REVERSE_QUOTE_ID : BQUOTA_STRING; +HOST_IP_ADDRESS : (AT_SIGN IP_ADDRESS); +LOCAL_ID : AT_SIGN ( STRING_LITERAL | [A-Z0-9._$\u0080-\uFFFF]+); +GLOBAL_ID : AT_SIGN AT_SIGN ( [A-Z0-9._$\u0080-\uFFFF]+ | BQUOTA_STRING); // Fragments for Literal primitives -fragment CHARSET_NAME: ARMSCII8 | ASCII | BIG5 | BINARY | CP1250 - | CP1251 | CP1256 | CP1257 | CP850 - | CP852 | CP866 | CP932 | DEC8 | EUCJPMS - | EUCKR | GB2312 | GBK | GEOSTD8 | GREEK - | HEBREW | HP8 | KEYBCS2 | KOI8R | KOI8U - | LATIN1 | LATIN2 | LATIN5 | LATIN7 - | MACCE | MACROMAN | SJIS | SWE7 | TIS620 - | UCS2 | UJIS | UTF16 | UTF16LE | UTF32 - | UTF8 | UTF8MB3 | UTF8MB4; - -fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+; -fragment ID_LITERAL: [A-Z_$0-9\u0080-\uFFFF]*?[A-Z_$\u0080-\uFFFF]+?[A-Z_$0-9\u0080-\uFFFF]*; -fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'; -fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''; -fragment BQUOTA_STRING: '`' ( ~'`' | '``' )* '`'; -fragment HEX_DIGIT: [0-9A-F]; -fragment DEC_DIGIT: [0-9]; -fragment BIT_STRING_L: 'B' '\'' [01]+ '\''; -fragment IP_ADDRESS: [0-9]+ '.' [0-9.]+ | [0-9A-F]* ':' [0-9A-F]* ':' [0-9A-F:]+; - +fragment CHARSET_NAME: + ARMSCII8 + | ASCII + | BIG5 + | BINARY + | CP1250 + | CP1251 + | CP1256 + | CP1257 + | CP850 + | CP852 + | CP866 + | CP932 + | DEC8 + | EUCJPMS + | EUCKR + | GB2312 + | GBK + | GEOSTD8 + | GREEK + | HEBREW + | HP8 + | KEYBCS2 + | KOI8R + | KOI8U + | LATIN1 + | LATIN2 + | LATIN5 + | LATIN7 + | MACCE + | MACROMAN + | SJIS + | SWE7 + | TIS620 + | UCS2 + | UJIS + | UTF16 + | UTF16LE + | UTF32 + | UTF8 + | UTF8MB3 + | UTF8MB4 +; + +fragment EXPONENT_NUM_PART : 'E' [-+]? DEC_DIGIT+; +fragment ID_LITERAL : [A-Z_$0-9\u0080-\uFFFF]*? [A-Z_$\u0080-\uFFFF]+? [A-Z_$0-9\u0080-\uFFFF]*; +fragment DQUOTA_STRING : '"' ( '\\' . | '""' | ~('"' | '\\'))* '"'; +fragment SQUOTA_STRING : '\'' ('\\' . | '\'\'' | ~('\'' | '\\'))* '\''; +fragment BQUOTA_STRING : '`' ( ~'`' | '``')* '`'; +fragment HEX_DIGIT : [0-9A-F]; +fragment DEC_DIGIT : [0-9]; +fragment BIT_STRING_L : 'B' '\'' [01]+ '\''; +fragment IP_ADDRESS : [0-9]+ '.' [0-9.]+ | [0-9A-F]* ':' [0-9A-F]* ':' [0-9A-F:]+; // Last tokens must generate Errors -ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL); +ERROR_RECONGNIGION: . -> channel(ERRORCHANNEL); \ No newline at end of file diff --git a/sql/mysql/Positive-Technologies/MySqlParser.g4 b/sql/mysql/Positive-Technologies/MySqlParser.g4 index 14d406df70..e11bd181ca 100644 --- a/sql/mysql/Positive-Technologies/MySqlParser.g4 +++ b/sql/mysql/Positive-Technologies/MySqlParser.g4 @@ -23,10 +23,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -parser grammar MySqlParser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab=MySqlLexer; } +parser grammar MySqlParser; +options { + tokenVocab = MySqlLexer; +} // Top Level Description @@ -35,14 +39,20 @@ root ; sqlStatements - : (sqlStatement (MINUS MINUS)? SEMI? | emptyStatement_)* - (sqlStatement ((MINUS MINUS)? SEMI)? | emptyStatement_) + : (sqlStatement (MINUS MINUS)? SEMI? | emptyStatement_)* ( + sqlStatement ((MINUS MINUS)? SEMI)? + | emptyStatement_ + ) ; sqlStatement - : ddlStatement | dmlStatement | transactionStatement - | replicationStatement | preparedStatement - | administrationStatement | utilityStatement + : ddlStatement + | dmlStatement + | transactionStatement + | replicationStatement + | preparedStatement + | administrationStatement + | utilityStatement ; emptyStatement_ @@ -50,132 +60,189 @@ emptyStatement_ ; ddlStatement - : createDatabase | createEvent | createIndex - | createLogfileGroup | createProcedure | createFunction - | createServer | createTable | createTablespaceInnodb - | createTablespaceNdb | createTrigger | createView | createRole - | alterDatabase | alterEvent | alterFunction - | alterInstance | alterLogfileGroup | alterProcedure - | alterServer | alterTable | alterTablespace | alterView - | dropDatabase | dropEvent | dropIndex - | dropLogfileGroup | dropProcedure | dropFunction - | dropServer | dropTable | dropTablespace - | dropTrigger | dropView | dropRole | setRole - | renameTable | truncateTable + : createDatabase + | createEvent + | createIndex + | createLogfileGroup + | createProcedure + | createFunction + | createServer + | createTable + | createTablespaceInnodb + | createTablespaceNdb + | createTrigger + | createView + | createRole + | alterDatabase + | alterEvent + | alterFunction + | alterInstance + | alterLogfileGroup + | alterProcedure + | alterServer + | alterTable + | alterTablespace + | alterView + | dropDatabase + | dropEvent + | dropIndex + | dropLogfileGroup + | dropProcedure + | dropFunction + | dropServer + | dropTable + | dropTablespace + | dropTrigger + | dropView + | dropRole + | setRole + | renameTable + | truncateTable ; dmlStatement - : selectStatement | insertStatement | updateStatement - | deleteStatement | replaceStatement | callStatement - | loadDataStatement | loadXmlStatement | doStatement - | handlerStatement | valuesStatement | withStatement + : selectStatement + | insertStatement + | updateStatement + | deleteStatement + | replaceStatement + | callStatement + | loadDataStatement + | loadXmlStatement + | doStatement + | handlerStatement + | valuesStatement + | withStatement | tableStatement ; transactionStatement : startTransaction - | beginWork | commitWork | rollbackWork - | savepointStatement | rollbackStatement - | releaseStatement | lockTables | unlockTables + | beginWork + | commitWork + | rollbackWork + | savepointStatement + | rollbackStatement + | releaseStatement + | lockTables + | unlockTables ; replicationStatement - : changeMaster | changeReplicationFilter | purgeBinaryLogs - | resetMaster | resetSlave | startSlave | stopSlave - | startGroupReplication | stopGroupReplication - | xaStartTransaction | xaEndTransaction | xaPrepareStatement - | xaCommitWork | xaRollbackWork | xaRecoverWork + : changeMaster + | changeReplicationFilter + | purgeBinaryLogs + | resetMaster + | resetSlave + | startSlave + | stopSlave + | startGroupReplication + | stopGroupReplication + | xaStartTransaction + | xaEndTransaction + | xaPrepareStatement + | xaCommitWork + | xaRollbackWork + | xaRecoverWork ; preparedStatement - : prepareStatement | executeStatement | deallocatePrepare + : prepareStatement + | executeStatement + | deallocatePrepare ; // remark: NOT INCLUDED IN sqlStatement, but include in body // of routine's statements compoundStatement : blockStatement - | caseStatement | ifStatement | leaveStatement - | loopStatement | repeatStatement | whileStatement - | iterateStatement | returnStatement | cursorStatement + | caseStatement + | ifStatement + | leaveStatement + | loopStatement + | repeatStatement + | whileStatement + | iterateStatement + | returnStatement + | cursorStatement ; administrationStatement - : alterUser | createUser | dropUser | grantStatement - | grantProxy | renameUser | revokeStatement - | revokeProxy | analyzeTable | checkTable - | checksumTable | optimizeTable | repairTable - | createUdfunction | installPlugin | uninstallPlugin - | setStatement | showStatement | binlogStatement - | cacheIndexStatement | flushStatement | killStatement - | loadIndexIntoCache | resetStatement + : alterUser + | createUser + | dropUser + | grantStatement + | grantProxy + | renameUser + | revokeStatement + | revokeProxy + | analyzeTable + | checkTable + | checksumTable + | optimizeTable + | repairTable + | createUdfunction + | installPlugin + | uninstallPlugin + | setStatement + | showStatement + | binlogStatement + | cacheIndexStatement + | flushStatement + | killStatement + | loadIndexIntoCache + | resetStatement | shutdownStatement ; utilityStatement - : simpleDescribeStatement | fullDescribeStatement - | helpStatement | useStatement | signalStatement - | resignalStatement | diagnosticsStatement + : simpleDescribeStatement + | fullDescribeStatement + | helpStatement + | useStatement + | signalStatement + | resignalStatement + | diagnosticsStatement ; - // Data Definition Language // Create statements createDatabase - : CREATE dbFormat=(DATABASE | SCHEMA) - ifNotExists? uid createDatabaseOption* + : CREATE dbFormat = (DATABASE | SCHEMA) ifNotExists? uid createDatabaseOption* ; createEvent - : CREATE ownerStatement? EVENT ifNotExists? fullId - ON SCHEDULE scheduleExpression - (ON COMPLETION NOT? PRESERVE)? enableType? - (COMMENT STRING_LITERAL)? - DO routineBody + : CREATE ownerStatement? EVENT ifNotExists? fullId ON SCHEDULE scheduleExpression ( + ON COMPLETION NOT? PRESERVE + )? enableType? (COMMENT STRING_LITERAL)? DO routineBody ; createIndex - : CREATE - intimeAction=(ONLINE | OFFLINE)? - indexCategory=(UNIQUE | FULLTEXT | SPATIAL)? INDEX - uid indexType? - ON tableName indexColumnNames - indexOption* - ( - ALGORITHM EQUAL_SYMBOL? algType=(DEFAULT | INPLACE | COPY) - | LOCK EQUAL_SYMBOL? lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) - )* + : CREATE intimeAction = (ONLINE | OFFLINE)? indexCategory = (UNIQUE | FULLTEXT | SPATIAL)? INDEX uid indexType? ON tableName indexColumnNames + indexOption* ( + ALGORITHM EQUAL_SYMBOL? algType = (DEFAULT | INPLACE | COPY) + | LOCK EQUAL_SYMBOL? lockType = (DEFAULT | NONE | SHARED | EXCLUSIVE) + )* ; createLogfileGroup - : CREATE LOGFILE GROUP uid - ADD UNDOFILE undoFile=STRING_LITERAL - (INITIAL_SIZE '='? initSize=fileSizeLiteral)? - (UNDO_BUFFER_SIZE '='? undoSize=fileSizeLiteral)? - (REDO_BUFFER_SIZE '='? redoSize=fileSizeLiteral)? - (NODEGROUP '='? uid)? - WAIT? - (COMMENT '='? comment=STRING_LITERAL)? - ENGINE '='? engineName + : CREATE LOGFILE GROUP uid ADD UNDOFILE undoFile = STRING_LITERAL ( + INITIAL_SIZE '='? initSize = fileSizeLiteral + )? (UNDO_BUFFER_SIZE '='? undoSize = fileSizeLiteral)? ( + REDO_BUFFER_SIZE '='? redoSize = fileSizeLiteral + )? (NODEGROUP '='? uid)? WAIT? (COMMENT '='? comment = STRING_LITERAL)? ENGINE '='? engineName ; createProcedure - : CREATE ownerStatement? - PROCEDURE fullId - '(' procedureParameter? (',' procedureParameter)* ')' - routineOption* - routineBody + : CREATE ownerStatement? PROCEDURE fullId '(' procedureParameter? (',' procedureParameter)* ')' routineOption* routineBody ; createFunction - : CREATE ownerStatement? AGGREGATE? - FUNCTION ifNotExists? fullId - '(' functionParameter? (',' functionParameter)* ')' - RETURNS dataType - routineOption* - (routineBody | returnStatement) + : CREATE ownerStatement? AGGREGATE? FUNCTION ifNotExists? fullId '(' functionParameter? ( + ',' functionParameter + )* ')' RETURNS dataType routineOption* (routineBody | returnStatement) ; createRole @@ -183,58 +250,46 @@ createRole ; createServer - : CREATE SERVER uid - FOREIGN DATA WRAPPER wrapperName=(MYSQL | STRING_LITERAL) - OPTIONS '(' serverOption (',' serverOption)* ')' + : CREATE SERVER uid FOREIGN DATA WRAPPER wrapperName = (MYSQL | STRING_LITERAL) OPTIONS '(' serverOption ( + ',' serverOption + )* ')' ; createTable - : CREATE TEMPORARY? TABLE ifNotExists? - tableName - ( - LIKE tableName - | '(' LIKE parenthesisTable=tableName ')' - ) #copyCreateTable - | CREATE TEMPORARY? TABLE ifNotExists? - tableName createDefinitions? - ( tableOption (','? tableOption)* )? - partitionDefinitions? keyViolate=(IGNORE | REPLACE)? - AS? selectStatement #queryCreateTable - | CREATE TEMPORARY? TABLE ifNotExists? - tableName createDefinitions - ( tableOption (','? tableOption)* )? - partitionDefinitions? #columnCreateTable + : CREATE TEMPORARY? TABLE ifNotExists? tableName ( + LIKE tableName + | '(' LIKE parenthesisTable = tableName ')' + ) # copyCreateTable + | CREATE TEMPORARY? TABLE ifNotExists? tableName createDefinitions? ( + tableOption (','? tableOption)* + )? partitionDefinitions? keyViolate = (IGNORE | REPLACE)? AS? selectStatement # queryCreateTable + | CREATE TEMPORARY? TABLE ifNotExists? tableName createDefinitions ( + tableOption (','? tableOption)* + )? partitionDefinitions? # columnCreateTable ; createTablespaceInnodb - : CREATE TABLESPACE uid - ADD DATAFILE datafile=STRING_LITERAL - (FILE_BLOCK_SIZE '=' fileBlockSize=fileSizeLiteral)? - (ENGINE '='? engineName)? + : CREATE TABLESPACE uid ADD DATAFILE datafile = STRING_LITERAL ( + FILE_BLOCK_SIZE '=' fileBlockSize = fileSizeLiteral + )? (ENGINE '='? engineName)? ; createTablespaceNdb - : CREATE TABLESPACE uid - ADD DATAFILE datafile=STRING_LITERAL - USE LOGFILE GROUP uid - (EXTENT_SIZE '='? extentSize=fileSizeLiteral)? - (INITIAL_SIZE '='? initialSize=fileSizeLiteral)? - (AUTOEXTEND_SIZE '='? autoextendSize=fileSizeLiteral)? - (MAX_SIZE '='? maxSize=fileSizeLiteral)? - (NODEGROUP '='? uid)? - WAIT? - (COMMENT '='? comment=STRING_LITERAL)? - ENGINE '='? engineName + : CREATE TABLESPACE uid ADD DATAFILE datafile = STRING_LITERAL USE LOGFILE GROUP uid ( + EXTENT_SIZE '='? extentSize = fileSizeLiteral + )? (INITIAL_SIZE '='? initialSize = fileSizeLiteral)? ( + AUTOEXTEND_SIZE '='? autoextendSize = fileSizeLiteral + )? (MAX_SIZE '='? maxSize = fileSizeLiteral)? (NODEGROUP '='? uid)? WAIT? ( + COMMENT '='? comment = STRING_LITERAL + )? ENGINE '='? engineName ; createTrigger - : CREATE ownerStatement? - TRIGGER thisTrigger=fullId - triggerTime=(BEFORE | AFTER) - triggerEvent=(INSERT | UPDATE | DELETE) - ON tableName FOR EACH ROW - (triggerPlace=(FOLLOWS | PRECEDES) otherTrigger=fullId)? - routineBody + : CREATE ownerStatement? TRIGGER thisTrigger = fullId triggerTime = (BEFORE | AFTER) triggerEvent = ( + INSERT + | UPDATE + | DELETE + ) ON tableName FOR EACH ROW (triggerPlace = (FOLLOWS | PRECEDES) otherTrigger = fullId)? routineBody ; withClause @@ -242,8 +297,9 @@ withClause ; commonTableExpressions - : cteName ('(' cteColumnName (',' cteColumnName)* ')')? AS '(' dmlStatement ')' - (',' commonTableExpressions)? + : cteName ('(' cteColumnName (',' cteColumnName)* ')')? AS '(' dmlStatement ')' ( + ',' commonTableExpressions + )? ; cteName @@ -255,21 +311,14 @@ cteColumnName ; createView - : CREATE orReplace? - ( - ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE) - )? - ownerStatement? - (SQL SECURITY secContext=(DEFINER | INVOKER))? - VIEW fullId ('(' uidList ')')? AS - ( + : CREATE orReplace? (ALGORITHM '=' algType = (UNDEFINED | MERGE | TEMPTABLE))? ownerStatement? ( + SQL SECURITY secContext = (DEFINER | INVOKER) + )? VIEW fullId ('(' uidList ')')? AS ( '(' withClause? selectStatement ')' - | - withClause? selectStatement (WITH checkOption=(CASCADED | LOCAL)? CHECK OPTION)? - ) + | withClause? selectStatement (WITH checkOption = (CASCADED | LOCAL)? CHECK OPTION)? + ) ; - // details createDatabaseOption @@ -286,7 +335,7 @@ charSet ; currentUserExpression - : CURRENT_USER ( '(' ')')? + : CURRENT_USER ('(' ')')? ; ownerStatement @@ -294,16 +343,10 @@ ownerStatement ; scheduleExpression - : AT timestampValue intervalExpr* #preciseSchedule - | EVERY (decimalLiteral | expression) intervalType - ( - STARTS startTimestamp=timestampValue - (startIntervals+=intervalExpr)* - )? - ( - ENDS endTimestamp=timestampValue - (endIntervals+=intervalExpr)* - )? #intervalSchedule + : AT timestampValue intervalExpr* # preciseSchedule + | EVERY (decimalLiteral | expression) intervalType ( + STARTS startTimestamp = timestampValue (startIntervals += intervalExpr)* + )? (ENDS endTimestamp = timestampValue (endIntervals += intervalExpr)*)? # intervalSchedule ; timestampValue @@ -319,14 +362,24 @@ intervalExpr intervalType : intervalTypeBase - | YEAR | YEAR_MONTH | DAY_HOUR | DAY_MINUTE - | DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND - | SECOND_MICROSECOND | MINUTE_MICROSECOND - | HOUR_MICROSECOND | DAY_MICROSECOND + | YEAR + | YEAR_MONTH + | DAY_HOUR + | DAY_MINUTE + | DAY_SECOND + | HOUR_MINUTE + | HOUR_SECOND + | MINUTE_SECOND + | SECOND_MICROSECOND + | MINUTE_MICROSECOND + | HOUR_MICROSECOND + | DAY_MICROSECOND ; enableType - : ENABLE | DISABLE | DISABLE ON SLAVE + : ENABLE + | DISABLE + | DISABLE ON SLAVE ; indexType @@ -344,7 +397,7 @@ indexOption ; procedureParameter - : direction=(IN | OUT | INOUT)? uid dataType + : direction = (IN | OUT | INOUT)? uid dataType ; functionParameter @@ -352,14 +405,11 @@ functionParameter ; routineOption - : COMMENT STRING_LITERAL #routineComment - | LANGUAGE SQL #routineLanguage - | NOT? DETERMINISTIC #routineBehavior - | ( - CONTAINS SQL | NO SQL | READS SQL DATA - | MODIFIES SQL DATA - ) #routineData - | SQL SECURITY context=(DEFINER | INVOKER) #routineSecurity + : COMMENT STRING_LITERAL # routineComment + | LANGUAGE SQL # routineLanguage + | NOT? DETERMINISTIC # routineBehavior + | ( CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA) # routineData + | SQL SECURITY context = (DEFINER | INVOKER) # routineSecurity ; serverOption @@ -377,9 +427,9 @@ createDefinitions ; createDefinition - : fullColumnName columnDefinition #columnDeclaration - | tableConstraint NOT? ENFORCED? #constraintDeclaration - | indexColumnDefinition #indexDeclaration + : fullColumnName columnDefinition # columnDeclaration + | tableConstraint NOT? ENFORCED? # constraintDeclaration + | indexColumnDefinition # indexDeclaration ; columnDefinition @@ -387,111 +437,101 @@ columnDefinition ; columnConstraint - : nullNotnull #nullColumnConstraint - | DEFAULT defaultValue #defaultColumnConstraint - | VISIBLE #visibilityColumnConstraint - | INVISIBLE #invisibilityColumnConstraint - | (AUTO_INCREMENT | ON UPDATE currentTimestamp) #autoIncrementColumnConstraint - | PRIMARY? KEY #primaryKeyColumnConstraint - | UNIQUE KEY? #uniqueKeyColumnConstraint - | COMMENT STRING_LITERAL #commentColumnConstraint - | COLUMN_FORMAT colformat=(FIXED | DYNAMIC | DEFAULT) #formatColumnConstraint - | STORAGE storageval=(DISK | MEMORY | DEFAULT) #storageColumnConstraint - | referenceDefinition #referenceColumnConstraint - | COLLATE collationName #collateColumnConstraint - | (GENERATED ALWAYS)? AS '(' expression ')' (VIRTUAL | STORED)? #generatedColumnConstraint - | SERIAL DEFAULT VALUE #serialDefaultColumnConstraint - | (CONSTRAINT name=uid?)? - CHECK '(' expression ')' #checkColumnConstraint + : nullNotnull # nullColumnConstraint + | DEFAULT defaultValue # defaultColumnConstraint + | VISIBLE # visibilityColumnConstraint + | INVISIBLE # invisibilityColumnConstraint + | (AUTO_INCREMENT | ON UPDATE currentTimestamp) # autoIncrementColumnConstraint + | PRIMARY? KEY # primaryKeyColumnConstraint + | UNIQUE KEY? # uniqueKeyColumnConstraint + | COMMENT STRING_LITERAL # commentColumnConstraint + | COLUMN_FORMAT colformat = (FIXED | DYNAMIC | DEFAULT) # formatColumnConstraint + | STORAGE storageval = (DISK | MEMORY | DEFAULT) # storageColumnConstraint + | referenceDefinition # referenceColumnConstraint + | COLLATE collationName # collateColumnConstraint + | (GENERATED ALWAYS)? AS '(' expression ')' (VIRTUAL | STORED)? # generatedColumnConstraint + | SERIAL DEFAULT VALUE # serialDefaultColumnConstraint + | (CONSTRAINT name = uid?)? CHECK '(' expression ')' # checkColumnConstraint ; tableConstraint - : (CONSTRAINT name=uid?)? - PRIMARY KEY index=uid? indexType? - indexColumnNames indexOption* #primaryKeyTableConstraint - | (CONSTRAINT name=uid?)? - UNIQUE indexFormat=(INDEX | KEY)? index=uid? - indexType? indexColumnNames indexOption* #uniqueKeyTableConstraint - | (CONSTRAINT name=uid?)? - FOREIGN KEY index=uid? indexColumnNames - referenceDefinition #foreignKeyTableConstraint - | (CONSTRAINT name=uid?)? - CHECK '(' expression ')' #checkTableConstraint + : (CONSTRAINT name = uid?)? PRIMARY KEY index = uid? indexType? indexColumnNames indexOption* # primaryKeyTableConstraint + | (CONSTRAINT name = uid?)? UNIQUE indexFormat = (INDEX | KEY)? index = uid? indexType? indexColumnNames indexOption* # uniqueKeyTableConstraint + | (CONSTRAINT name = uid?)? FOREIGN KEY index = uid? indexColumnNames referenceDefinition # foreignKeyTableConstraint + | (CONSTRAINT name = uid?)? CHECK '(' expression ')' # checkTableConstraint ; referenceDefinition - : REFERENCES tableName indexColumnNames? - (MATCH matchType=(FULL | PARTIAL | SIMPLE))? - referenceAction? + : REFERENCES tableName indexColumnNames? (MATCH matchType = (FULL | PARTIAL | SIMPLE))? referenceAction? ; referenceAction - : ON DELETE onDelete=referenceControlType - ( - ON UPDATE onUpdate=referenceControlType - )? - | ON UPDATE onUpdate=referenceControlType - ( - ON DELETE onDelete=referenceControlType - )? + : ON DELETE onDelete = referenceControlType (ON UPDATE onUpdate = referenceControlType)? + | ON UPDATE onUpdate = referenceControlType (ON DELETE onDelete = referenceControlType)? ; referenceControlType - : RESTRICT | CASCADE | SET NULL_LITERAL | NO ACTION | SET DEFAULT + : RESTRICT + | CASCADE + | SET NULL_LITERAL + | NO ACTION + | SET DEFAULT ; indexColumnDefinition - : indexFormat=(INDEX | KEY) uid? indexType? - indexColumnNames indexOption* #simpleIndexDeclaration - | (FULLTEXT | SPATIAL) - indexFormat=(INDEX | KEY)? uid? - indexColumnNames indexOption* #specialIndexDeclaration + : indexFormat = (INDEX | KEY) uid? indexType? indexColumnNames indexOption* # simpleIndexDeclaration + | (FULLTEXT | SPATIAL) indexFormat = (INDEX | KEY)? uid? indexColumnNames indexOption* # specialIndexDeclaration ; tableOption - : ENGINE '='? engineName? #tableOptionEngine - | ENGINE_ATTRIBUTE '='? STRING_LITERAL #tableOptionEngineAttribute - | AUTOEXTEND_SIZE '='? decimalLiteral #tableOptionAutoextendSize - | AUTO_INCREMENT '='? decimalLiteral #tableOptionAutoIncrement - | AVG_ROW_LENGTH '='? decimalLiteral #tableOptionAverage - | DEFAULT? charSet '='? (charsetName|DEFAULT) #tableOptionCharset - | (CHECKSUM | PAGE_CHECKSUM) '='? boolValue=('0' | '1') #tableOptionChecksum - | DEFAULT? COLLATE '='? collationName #tableOptionCollate - | COMMENT '='? STRING_LITERAL #tableOptionComment - | COMPRESSION '='? (STRING_LITERAL | ID) #tableOptionCompression - | CONNECTION '='? STRING_LITERAL #tableOptionConnection - | (DATA | INDEX) DIRECTORY '='? STRING_LITERAL #tableOptionDataDirectory - | DELAY_KEY_WRITE '='? boolValue=('0' | '1') #tableOptionDelay - | ENCRYPTION '='? STRING_LITERAL #tableOptionEncryption - | (PAGE_COMPRESSED | STRING_LITERAL) '='? ('0' | '1') #tableOptionPageCompressed - | (PAGE_COMPRESSION_LEVEL | STRING_LITERAL) '='? decimalLiteral #tableOptionPageCompressionLevel - | ENCRYPTION_KEY_ID '='? decimalLiteral #tableOptionEncryptionKeyId - | INDEX DIRECTORY '='? STRING_LITERAL #tableOptionIndexDirectory - | INSERT_METHOD '='? insertMethod=(NO | FIRST | LAST) #tableOptionInsertMethod - | KEY_BLOCK_SIZE '='? fileSizeLiteral #tableOptionKeyBlockSize - | MAX_ROWS '='? decimalLiteral #tableOptionMaxRows - | MIN_ROWS '='? decimalLiteral #tableOptionMinRows - | PACK_KEYS '='? extBoolValue=('0' | '1' | DEFAULT) #tableOptionPackKeys - | PASSWORD '='? STRING_LITERAL #tableOptionPassword - | ROW_FORMAT '='? - rowFormat=( - DEFAULT | DYNAMIC | FIXED | COMPRESSED - | REDUNDANT | COMPACT | ID - ) #tableOptionRowFormat - | START TRANSACTION #tableOptionStartTransaction - | SECONDARY_ENGINE_ATTRIBUTE '='? STRING_LITERAL #tableOptionSecondaryEngineAttribute - | STATS_AUTO_RECALC '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionRecalculation - | STATS_PERSISTENT '='? extBoolValue=(DEFAULT | '0' | '1') #tableOptionPersistent - | STATS_SAMPLE_PAGES '='? (DEFAULT | decimalLiteral) #tableOptionSamplePage - | TABLESPACE uid tablespaceStorage? #tableOptionTablespace - | TABLE_TYPE '=' tableType #tableOptionTableType - | tablespaceStorage #tableOptionTablespace - | TRANSACTIONAL '='? ('0' | '1') #tableOptionTransactional - | UNION '='? '(' tables ')' #tableOptionUnion + : ENGINE '='? engineName? # tableOptionEngine + | ENGINE_ATTRIBUTE '='? STRING_LITERAL # tableOptionEngineAttribute + | AUTOEXTEND_SIZE '='? decimalLiteral # tableOptionAutoextendSize + | AUTO_INCREMENT '='? decimalLiteral # tableOptionAutoIncrement + | AVG_ROW_LENGTH '='? decimalLiteral # tableOptionAverage + | DEFAULT? charSet '='? (charsetName | DEFAULT) # tableOptionCharset + | (CHECKSUM | PAGE_CHECKSUM) '='? boolValue = ('0' | '1') # tableOptionChecksum + | DEFAULT? COLLATE '='? collationName # tableOptionCollate + | COMMENT '='? STRING_LITERAL # tableOptionComment + | COMPRESSION '='? (STRING_LITERAL | ID) # tableOptionCompression + | CONNECTION '='? STRING_LITERAL # tableOptionConnection + | (DATA | INDEX) DIRECTORY '='? STRING_LITERAL # tableOptionDataDirectory + | DELAY_KEY_WRITE '='? boolValue = ('0' | '1') # tableOptionDelay + | ENCRYPTION '='? STRING_LITERAL # tableOptionEncryption + | (PAGE_COMPRESSED | STRING_LITERAL) '='? ('0' | '1') # tableOptionPageCompressed + | (PAGE_COMPRESSION_LEVEL | STRING_LITERAL) '='? decimalLiteral # tableOptionPageCompressionLevel + | ENCRYPTION_KEY_ID '='? decimalLiteral # tableOptionEncryptionKeyId + | INDEX DIRECTORY '='? STRING_LITERAL # tableOptionIndexDirectory + | INSERT_METHOD '='? insertMethod = (NO | FIRST | LAST) # tableOptionInsertMethod + | KEY_BLOCK_SIZE '='? fileSizeLiteral # tableOptionKeyBlockSize + | MAX_ROWS '='? decimalLiteral # tableOptionMaxRows + | MIN_ROWS '='? decimalLiteral # tableOptionMinRows + | PACK_KEYS '='? extBoolValue = ('0' | '1' | DEFAULT) # tableOptionPackKeys + | PASSWORD '='? STRING_LITERAL # tableOptionPassword + | ROW_FORMAT '='? rowFormat = ( + DEFAULT + | DYNAMIC + | FIXED + | COMPRESSED + | REDUNDANT + | COMPACT + | ID + ) # tableOptionRowFormat + | START TRANSACTION # tableOptionStartTransaction + | SECONDARY_ENGINE_ATTRIBUTE '='? STRING_LITERAL # tableOptionSecondaryEngineAttribute + | STATS_AUTO_RECALC '='? extBoolValue = (DEFAULT | '0' | '1') # tableOptionRecalculation + | STATS_PERSISTENT '='? extBoolValue = (DEFAULT | '0' | '1') # tableOptionPersistent + | STATS_SAMPLE_PAGES '='? (DEFAULT | decimalLiteral) # tableOptionSamplePage + | TABLESPACE uid tablespaceStorage? # tableOptionTablespace + | TABLE_TYPE '=' tableType # tableOptionTableType + | tablespaceStorage # tableOptionTablespace + | TRANSACTIONAL '='? ('0' | '1') # tableOptionTransactional + | UNION '='? '(' tables ')' # tableOptionUnion ; tableType - : MYSQL | ODBC + : MYSQL + | ODBC ; tablespaceStorage @@ -499,57 +539,43 @@ tablespaceStorage ; partitionDefinitions - : PARTITION BY partitionFunctionDefinition - (PARTITIONS count=decimalLiteral)? - ( - SUBPARTITION BY subpartitionFunctionDefinition - (SUBPARTITIONS subCount=decimalLiteral)? - )? - ('(' partitionDefinition (',' partitionDefinition)* ')')? + : PARTITION BY partitionFunctionDefinition (PARTITIONS count = decimalLiteral)? ( + SUBPARTITION BY subpartitionFunctionDefinition (SUBPARTITIONS subCount = decimalLiteral)? + )? ('(' partitionDefinition (',' partitionDefinition)* ')')? ; partitionFunctionDefinition - : LINEAR? HASH '(' expression ')' #partitionFunctionHash - | LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))? - '(' uidList? ')' #partitionFunctionKey // Optional uidList for MySQL only - | RANGE ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionRange - | LIST ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionList + : LINEAR? HASH '(' expression ')' # partitionFunctionHash + | LINEAR? KEY (ALGORITHM '=' algType = ('1' | '2'))? '(' uidList? ')' # partitionFunctionKey // Optional uidList for MySQL only + | RANGE ('(' expression ')' | COLUMNS '(' uidList ')') # partitionFunctionRange + | LIST ('(' expression ')' | COLUMNS '(' uidList ')') # partitionFunctionList ; subpartitionFunctionDefinition - : LINEAR? HASH '(' expression ')' #subPartitionFunctionHash - | LINEAR? KEY (ALGORITHM '=' algType=('1' | '2'))? - '(' uidList ')' #subPartitionFunctionKey + : LINEAR? HASH '(' expression ')' # subPartitionFunctionHash + | LINEAR? KEY (ALGORITHM '=' algType = ('1' | '2'))? '(' uidList ')' # subPartitionFunctionKey ; partitionDefinition - : PARTITION uid VALUES LESS THAN - '(' - partitionDefinerAtom (',' partitionDefinerAtom)* - ')' - partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionComparison - | PARTITION uid VALUES LESS THAN - partitionDefinerAtom partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionComparison - | PARTITION uid VALUES IN - '(' - partitionDefinerAtom (',' partitionDefinerAtom)* - ')' - partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionListAtom - | PARTITION uid VALUES IN - '(' - partitionDefinerVector (',' partitionDefinerVector)* - ')' - partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionListVector - | PARTITION uid partitionOption* - ( '(' subpartitionDefinition (',' subpartitionDefinition)* ')' )? #partitionSimple + : PARTITION uid VALUES LESS THAN '(' partitionDefinerAtom (',' partitionDefinerAtom)* ')' partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionComparison + | PARTITION uid VALUES LESS THAN partitionDefinerAtom partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionComparison + | PARTITION uid VALUES IN '(' partitionDefinerAtom (',' partitionDefinerAtom)* ')' partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionListAtom + | PARTITION uid VALUES IN '(' partitionDefinerVector (',' partitionDefinerVector)* ')' partitionOption* ( + '(' subpartitionDefinition (',' subpartitionDefinition)* ')' + )? # partitionListVector + | PARTITION uid partitionOption* ('(' subpartitionDefinition (',' subpartitionDefinition)* ')')? # partitionSimple ; partitionDefinerAtom - : constant | expression | MAXVALUE + : constant + | expression + | MAXVALUE ; partitionDefinerVector @@ -561,33 +587,27 @@ subpartitionDefinition ; partitionOption - : DEFAULT? STORAGE? ENGINE '='? engineName #partitionOptionEngine - | COMMENT '='? comment=STRING_LITERAL #partitionOptionComment - | DATA DIRECTORY '='? dataDirectory=STRING_LITERAL #partitionOptionDataDirectory - | INDEX DIRECTORY '='? indexDirectory=STRING_LITERAL #partitionOptionIndexDirectory - | MAX_ROWS '='? maxRows=decimalLiteral #partitionOptionMaxRows - | MIN_ROWS '='? minRows=decimalLiteral #partitionOptionMinRows - | TABLESPACE '='? tablespace=uid #partitionOptionTablespace - | NODEGROUP '='? nodegroup=uid #partitionOptionNodeGroup + : DEFAULT? STORAGE? ENGINE '='? engineName # partitionOptionEngine + | COMMENT '='? comment = STRING_LITERAL # partitionOptionComment + | DATA DIRECTORY '='? dataDirectory = STRING_LITERAL # partitionOptionDataDirectory + | INDEX DIRECTORY '='? indexDirectory = STRING_LITERAL # partitionOptionIndexDirectory + | MAX_ROWS '='? maxRows = decimalLiteral # partitionOptionMaxRows + | MIN_ROWS '='? minRows = decimalLiteral # partitionOptionMinRows + | TABLESPACE '='? tablespace = uid # partitionOptionTablespace + | NODEGROUP '='? nodegroup = uid # partitionOptionNodeGroup ; // Alter statements alterDatabase - : ALTER dbFormat=(DATABASE | SCHEMA) uid? - createDatabaseOption+ #alterSimpleDatabase - | ALTER dbFormat=(DATABASE | SCHEMA) uid - UPGRADE DATA DIRECTORY NAME #alterUpgradeName + : ALTER dbFormat = (DATABASE | SCHEMA) uid? createDatabaseOption+ # alterSimpleDatabase + | ALTER dbFormat = (DATABASE | SCHEMA) uid UPGRADE DATA DIRECTORY NAME # alterUpgradeName ; alterEvent - : ALTER ownerStatement? - EVENT fullId - (ON SCHEDULE scheduleExpression)? - (ON COMPLETION NOT? PRESERVE)? - (RENAME TO fullId)? enableType? - (COMMENT STRING_LITERAL)? - (DO routineBody)? + : ALTER ownerStatement? EVENT fullId (ON SCHEDULE scheduleExpression)? ( + ON COMPLETION NOT? PRESERVE + )? (RENAME TO fullId)? enableType? (COMMENT STRING_LITERAL)? (DO routineBody)? ; alterFunction @@ -599,10 +619,7 @@ alterInstance ; alterLogfileGroup - : ALTER LOGFILE GROUP uid - ADD UNDOFILE STRING_LITERAL - (INITIAL_SIZE '='? fileSizeLiteral)? - WAIT? ENGINE '='? engineName + : ALTER LOGFILE GROUP uid ADD UNDOFILE STRING_LITERAL (INITIAL_SIZE '='? fileSizeLiteral)? WAIT? ENGINE '='? engineName ; alterProcedure @@ -610,125 +627,100 @@ alterProcedure ; alterServer - : ALTER SERVER uid OPTIONS - '(' serverOption (',' serverOption)* ')' + : ALTER SERVER uid OPTIONS '(' serverOption (',' serverOption)* ')' ; alterTable - : ALTER intimeAction=(ONLINE | OFFLINE)? - IGNORE? TABLE tableName waitNowaitClause? - (alterSpecification (',' alterSpecification)*)? - partitionDefinitions? + : ALTER intimeAction = (ONLINE | OFFLINE)? IGNORE? TABLE tableName waitNowaitClause? ( + alterSpecification (',' alterSpecification)* + )? partitionDefinitions? ; alterTablespace - : ALTER TABLESPACE uid - objectAction=(ADD | DROP) DATAFILE STRING_LITERAL - (INITIAL_SIZE '=' fileSizeLiteral)? - WAIT? - ENGINE '='? engineName + : ALTER TABLESPACE uid objectAction = (ADD | DROP) DATAFILE STRING_LITERAL ( + INITIAL_SIZE '=' fileSizeLiteral + )? WAIT? ENGINE '='? engineName ; alterView - : ALTER - ( - ALGORITHM '=' algType=(UNDEFINED | MERGE | TEMPTABLE) - )? - ownerStatement? - (SQL SECURITY secContext=(DEFINER | INVOKER))? - VIEW fullId ('(' uidList ')')? AS selectStatement - (WITH checkOpt=(CASCADED | LOCAL)? CHECK OPTION)? + : ALTER (ALGORITHM '=' algType = (UNDEFINED | MERGE | TEMPTABLE))? ownerStatement? ( + SQL SECURITY secContext = (DEFINER | INVOKER) + )? VIEW fullId ('(' uidList ')')? AS selectStatement ( + WITH checkOpt = (CASCADED | LOCAL)? CHECK OPTION + )? ; // details alterSpecification - : tableOption (','? tableOption)* #alterByTableOption - | ADD COLUMN? uid columnDefinition (FIRST | AFTER uid)? #alterByAddColumn - | ADD COLUMN? - '(' - uid columnDefinition ( ',' uid columnDefinition)* - ')' #alterByAddColumns - | ADD indexFormat=(INDEX | KEY) uid? indexType? - indexColumnNames indexOption* #alterByAddIndex - | ADD (CONSTRAINT name=uid?)? PRIMARY KEY index=uid? - indexType? indexColumnNames indexOption* #alterByAddPrimaryKey - | ADD (CONSTRAINT name=uid?)? UNIQUE - indexFormat=(INDEX | KEY)? indexName=uid? - indexType? indexColumnNames indexOption* #alterByAddUniqueKey - | ADD keyType=(FULLTEXT | SPATIAL) - indexFormat=(INDEX | KEY)? uid? - indexColumnNames indexOption* #alterByAddSpecialIndex - | ADD (CONSTRAINT name=uid?)? FOREIGN KEY - indexName=uid? indexColumnNames referenceDefinition #alterByAddForeignKey - | ADD (CONSTRAINT name=uid?)? CHECK ( uid | stringLiteral | '(' expression ')' ) - NOT? ENFORCED? #alterByAddCheckTableConstraint - | ALTER (CONSTRAINT name=uid?)? CHECK ( uid | stringLiteral | '(' expression ')' ) - NOT? ENFORCED? #alterByAlterCheckTableConstraint - | ADD (CONSTRAINT name=uid?)? CHECK '(' expression ')' #alterByAddCheckTableConstraint - | ALGORITHM '='? algType=(DEFAULT | INSTANT | INPLACE | COPY) #alterBySetAlgorithm - | ALTER COLUMN? uid - (SET DEFAULT defaultValue | DROP DEFAULT) #alterByChangeDefault - | CHANGE COLUMN? oldColumn=uid - newColumn=uid columnDefinition - (FIRST | AFTER afterColumn=uid)? #alterByChangeColumn - | RENAME COLUMN oldColumn=uid TO newColumn=uid #alterByRenameColumn - | LOCK '='? lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) #alterByLock - | MODIFY COLUMN? - uid columnDefinition (FIRST | AFTER uid)? #alterByModifyColumn - | DROP COLUMN? uid RESTRICT? #alterByDropColumn - | DROP (CONSTRAINT | CHECK) uid #alterByDropConstraintCheck - | DROP PRIMARY KEY #alterByDropPrimaryKey - | DROP indexFormat=(INDEX | KEY) uid #alterByDropIndex - | RENAME indexFormat=(INDEX | KEY) uid TO uid #alterByRenameIndex + : tableOption (','? tableOption)* # alterByTableOption + | ADD COLUMN? uid columnDefinition (FIRST | AFTER uid)? # alterByAddColumn + | ADD COLUMN? '(' uid columnDefinition (',' uid columnDefinition)* ')' # alterByAddColumns + | ADD indexFormat = (INDEX | KEY) uid? indexType? indexColumnNames indexOption* # alterByAddIndex + | ADD (CONSTRAINT name = uid?)? PRIMARY KEY index = uid? indexType? indexColumnNames indexOption* # alterByAddPrimaryKey + | ADD (CONSTRAINT name = uid?)? UNIQUE indexFormat = (INDEX | KEY)? indexName = uid? indexType? indexColumnNames indexOption* # alterByAddUniqueKey + | ADD keyType = (FULLTEXT | SPATIAL) indexFormat = (INDEX | KEY)? uid? indexColumnNames indexOption* # alterByAddSpecialIndex + | ADD (CONSTRAINT name = uid?)? FOREIGN KEY indexName = uid? indexColumnNames referenceDefinition # alterByAddForeignKey + | ADD (CONSTRAINT name = uid?)? CHECK (uid | stringLiteral | '(' expression ')') NOT? ENFORCED? # alterByAddCheckTableConstraint + | ALTER (CONSTRAINT name = uid?)? CHECK (uid | stringLiteral | '(' expression ')') NOT? ENFORCED? # alterByAlterCheckTableConstraint + | ADD (CONSTRAINT name = uid?)? CHECK '(' expression ')' # alterByAddCheckTableConstraint + | ALGORITHM '='? algType = (DEFAULT | INSTANT | INPLACE | COPY) # alterBySetAlgorithm + | ALTER COLUMN? uid (SET DEFAULT defaultValue | DROP DEFAULT) # alterByChangeDefault + | CHANGE COLUMN? oldColumn = uid newColumn = uid columnDefinition ( + FIRST + | AFTER afterColumn = uid + )? # alterByChangeColumn + | RENAME COLUMN oldColumn = uid TO newColumn = uid # alterByRenameColumn + | LOCK '='? lockType = (DEFAULT | NONE | SHARED | EXCLUSIVE) # alterByLock + | MODIFY COLUMN? uid columnDefinition (FIRST | AFTER uid)? # alterByModifyColumn + | DROP COLUMN? uid RESTRICT? # alterByDropColumn + | DROP (CONSTRAINT | CHECK) uid # alterByDropConstraintCheck + | DROP PRIMARY KEY # alterByDropPrimaryKey + | DROP indexFormat = (INDEX | KEY) uid # alterByDropIndex + | RENAME indexFormat = (INDEX | KEY) uid TO uid # alterByRenameIndex | ALTER COLUMN? uid ( - SET DEFAULT ( stringLiteral | '(' expression ')' ) + SET DEFAULT ( stringLiteral | '(' expression ')') | SET (VISIBLE | INVISIBLE) - | DROP DEFAULT) #alterByAlterColumnDefault - | ALTER INDEX uid (VISIBLE | INVISIBLE) #alterByAlterIndexVisibility - | DROP FOREIGN KEY uid #alterByDropForeignKey - | DISABLE KEYS #alterByDisableKeys - | ENABLE KEYS #alterByEnableKeys - | RENAME renameFormat=(TO | AS)? (uid | fullId) #alterByRename - | ORDER BY uidList #alterByOrder - | CONVERT TO (CHARSET | CHARACTER SET) charsetName - (COLLATE collationName)? #alterByConvertCharset - | DEFAULT? CHARACTER SET '=' charsetName - (COLLATE '=' collationName)? #alterByDefaultCharset - | DISCARD TABLESPACE #alterByDiscardTablespace - | IMPORT TABLESPACE #alterByImportTablespace - | FORCE #alterByForce - | validationFormat=(WITHOUT | WITH) VALIDATION #alterByValidate - | ADD COLUMN? - '(' createDefinition (',' createDefinition)* ')' #alterByAddDefinitions - | alterPartitionSpecification #alterPartition + | DROP DEFAULT + ) # alterByAlterColumnDefault + | ALTER INDEX uid (VISIBLE | INVISIBLE) # alterByAlterIndexVisibility + | DROP FOREIGN KEY uid # alterByDropForeignKey + | DISABLE KEYS # alterByDisableKeys + | ENABLE KEYS # alterByEnableKeys + | RENAME renameFormat = (TO | AS)? (uid | fullId) # alterByRename + | ORDER BY uidList # alterByOrder + | CONVERT TO (CHARSET | CHARACTER SET) charsetName (COLLATE collationName)? # alterByConvertCharset + | DEFAULT? CHARACTER SET '=' charsetName (COLLATE '=' collationName)? # alterByDefaultCharset + | DISCARD TABLESPACE # alterByDiscardTablespace + | IMPORT TABLESPACE # alterByImportTablespace + | FORCE # alterByForce + | validationFormat = (WITHOUT | WITH) VALIDATION # alterByValidate + | ADD COLUMN? '(' createDefinition (',' createDefinition)* ')' # alterByAddDefinitions + | alterPartitionSpecification # alterPartition ; alterPartitionSpecification - : ADD PARTITION - '(' partitionDefinition (',' partitionDefinition)* ')' #alterByAddPartition - | DROP PARTITION uidList #alterByDropPartition - | DISCARD PARTITION (uidList | ALL) TABLESPACE #alterByDiscardPartition - | IMPORT PARTITION (uidList | ALL) TABLESPACE #alterByImportPartition - | TRUNCATE PARTITION (uidList | ALL) #alterByTruncatePartition - | COALESCE PARTITION decimalLiteral #alterByCoalescePartition - | REORGANIZE PARTITION uidList - INTO '(' partitionDefinition (',' partitionDefinition)* ')' #alterByReorganizePartition - | EXCHANGE PARTITION uid WITH TABLE tableName - (validationFormat=(WITH | WITHOUT) VALIDATION)? #alterByExchangePartition - | ANALYZE PARTITION (uidList | ALL) #alterByAnalyzePartition - | CHECK PARTITION (uidList | ALL) #alterByCheckPartition - | OPTIMIZE PARTITION (uidList | ALL) #alterByOptimizePartition - | REBUILD PARTITION (uidList | ALL) #alterByRebuildPartition - | REPAIR PARTITION (uidList | ALL) #alterByRepairPartition - | REMOVE PARTITIONING #alterByRemovePartitioning - | UPGRADE PARTITIONING #alterByUpgradePartitioning + : ADD PARTITION '(' partitionDefinition (',' partitionDefinition)* ')' # alterByAddPartition + | DROP PARTITION uidList # alterByDropPartition + | DISCARD PARTITION (uidList | ALL) TABLESPACE # alterByDiscardPartition + | IMPORT PARTITION (uidList | ALL) TABLESPACE # alterByImportPartition + | TRUNCATE PARTITION (uidList | ALL) # alterByTruncatePartition + | COALESCE PARTITION decimalLiteral # alterByCoalescePartition + | REORGANIZE PARTITION uidList INTO '(' partitionDefinition (',' partitionDefinition)* ')' # alterByReorganizePartition + | EXCHANGE PARTITION uid WITH TABLE tableName (validationFormat = (WITH | WITHOUT) VALIDATION)? # alterByExchangePartition + | ANALYZE PARTITION (uidList | ALL) # alterByAnalyzePartition + | CHECK PARTITION (uidList | ALL) # alterByCheckPartition + | OPTIMIZE PARTITION (uidList | ALL) # alterByOptimizePartition + | REBUILD PARTITION (uidList | ALL) # alterByRebuildPartition + | REPAIR PARTITION (uidList | ALL) # alterByRepairPartition + | REMOVE PARTITIONING # alterByRemovePartitioning + | UPGRADE PARTITIONING # alterByUpgradePartitioning ; // Drop statements dropDatabase - : DROP dbFormat=(DATABASE | SCHEMA) ifExists? uid + : DROP dbFormat = (DATABASE | SCHEMA) ifExists? uid ; dropEvent @@ -736,13 +728,10 @@ dropEvent ; dropIndex - : DROP INDEX intimeAction=(ONLINE | OFFLINE)? - uid ON tableName - ( - ALGORITHM '='? algType=(DEFAULT | INPLACE | COPY) - | LOCK '='? - lockType=(DEFAULT | NONE | SHARED | EXCLUSIVE) - )* + : DROP INDEX intimeAction = (ONLINE | OFFLINE)? uid ON tableName ( + ALGORITHM '='? algType = (DEFAULT | INPLACE | COPY) + | LOCK '='? lockType = (DEFAULT | NONE | SHARED | EXCLUSIVE) + )* ; dropLogfileGroup @@ -762,8 +751,7 @@ dropServer ; dropTable - : DROP TEMPORARY? TABLE ifExists? - tables dropType=(RESTRICT | CASCADE)? + : DROP TEMPORARY? TABLE ifExists? tables dropType = (RESTRICT | CASCADE)? ; dropTablespace @@ -775,8 +763,7 @@ dropTrigger ; dropView - : DROP VIEW ifExists? - fullId (',' fullId)* dropType=(RESTRICT | CASCADE)? + : DROP VIEW ifExists? fullId (',' fullId)* dropType = (RESTRICT | CASCADE)? ; dropRole @@ -784,16 +771,16 @@ dropRole ; setRole - : SET DEFAULT ROLE (NONE | ALL | roleName (',' roleName)*) - TO (userName | uid) (',' (userName | uid))* + : SET DEFAULT ROLE (NONE | ALL | roleName (',' roleName)*) TO (userName | uid) ( + ',' (userName | uid) + )* | SET ROLE roleOption ; // Other DDL statements renameTable - : RENAME TABLE - renameTableClause (',' renameTableClause)* + : RENAME TABLE renameTableClause (',' renameTableClause)* ; renameTableClause @@ -804,21 +791,17 @@ truncateTable : TRUNCATE TABLE? tableName ; - // Data Manipulation Language // Primary DML Statements - callStatement - : CALL fullId - ( - '(' (constants | expressions)? ')' - )? + : CALL fullId ('(' (constants | expressions)? ')')? ; deleteStatement - : singleDeleteStatement | multipleDeleteStatement + : singleDeleteStatement + | multipleDeleteStatement ; doStatement @@ -833,108 +816,77 @@ handlerStatement ; insertStatement - : INSERT - priority=(LOW_PRIORITY | DELAYED | HIGH_PRIORITY)? - IGNORE? INTO? tableName - (PARTITION '(' partitions=uidList? ')' )? - ( - ('(' columns=fullColumnNameList? ')')? insertStatementValue (AS? uid)? - | SET - setFirst=updatedElement - (',' setElements+=updatedElement)* - ) - ( - ON DUPLICATE KEY UPDATE - duplicatedFirst=updatedElement - (',' duplicatedElements+=updatedElement)* - )? + : INSERT priority = (LOW_PRIORITY | DELAYED | HIGH_PRIORITY)? IGNORE? INTO? tableName ( + PARTITION '(' partitions = uidList? ')' + )? ( + ('(' columns = fullColumnNameList? ')')? insertStatementValue (AS? uid)? + | SET setFirst = updatedElement (',' setElements += updatedElement)* + ) ( + ON DUPLICATE KEY UPDATE duplicatedFirst = updatedElement ( + ',' duplicatedElements += updatedElement + )* + )? ; loadDataStatement - : LOAD DATA - priority=(LOW_PRIORITY | CONCURRENT)? - LOCAL? INFILE filename=STRING_LITERAL - violation=(REPLACE | IGNORE)? - INTO TABLE tableName - (PARTITION '(' uidList ')' )? - (CHARACTER SET charset=charsetName)? - ( - fieldsFormat=(FIELDS | COLUMNS) - selectFieldsInto+ - )? - ( - LINES - selectLinesInto+ - )? - ( - IGNORE decimalLiteral linesFormat=(LINES | ROWS) - )? - ( '(' assignmentField (',' assignmentField)* ')' )? - (SET updatedElement (',' updatedElement)*)? + : LOAD DATA priority = (LOW_PRIORITY | CONCURRENT)? LOCAL? INFILE filename = STRING_LITERAL violation = ( + REPLACE + | IGNORE + )? INTO TABLE tableName (PARTITION '(' uidList ')')? (CHARACTER SET charset = charsetName)? ( + fieldsFormat = (FIELDS | COLUMNS) selectFieldsInto+ + )? (LINES selectLinesInto+)? (IGNORE decimalLiteral linesFormat = (LINES | ROWS))? ( + '(' assignmentField (',' assignmentField)* ')' + )? (SET updatedElement (',' updatedElement)*)? ; loadXmlStatement - : LOAD XML - priority=(LOW_PRIORITY | CONCURRENT)? - LOCAL? INFILE filename=STRING_LITERAL - violation=(REPLACE | IGNORE)? - INTO TABLE tableName - (CHARACTER SET charset=charsetName)? - (ROWS IDENTIFIED BY '<' tag=STRING_LITERAL '>')? - ( IGNORE decimalLiteral linesFormat=(LINES | ROWS) )? - ( '(' assignmentField (',' assignmentField)* ')' )? - (SET updatedElement (',' updatedElement)*)? + : LOAD XML priority = (LOW_PRIORITY | CONCURRENT)? LOCAL? INFILE filename = STRING_LITERAL violation = ( + REPLACE + | IGNORE + )? INTO TABLE tableName (CHARACTER SET charset = charsetName)? ( + ROWS IDENTIFIED BY '<' tag = STRING_LITERAL '>' + )? (IGNORE decimalLiteral linesFormat = (LINES | ROWS))? ( + '(' assignmentField (',' assignmentField)* ')' + )? (SET updatedElement (',' updatedElement)*)? ; replaceStatement - : REPLACE priority=(LOW_PRIORITY | DELAYED)? - INTO? tableName - (PARTITION '(' partitions=uidList ')' )? - ( - ('(' columns=uidList ')')? insertStatementValue - | SET - setFirst=updatedElement - (',' setElements+=updatedElement)* - ) + : REPLACE priority = (LOW_PRIORITY | DELAYED)? INTO? tableName ( + PARTITION '(' partitions = uidList ')' + )? ( + ('(' columns = uidList ')')? insertStatementValue + | SET setFirst = updatedElement (',' setElements += updatedElement)* + ) ; selectStatement - : querySpecification lockClause? #simpleSelect - | queryExpression lockClause? #parenthesisSelect - | (querySpecificationNointo | queryExpressionNointo) - unionStatement+ - ( - UNION unionType=(ALL | DISTINCT)? - (querySpecification | queryExpression) - )? - orderByClause? limitClause? lockClause? #unionSelect - | queryExpressionNointo unionParenthesis+ - ( - UNION unionType=(ALL | DISTINCT)? - queryExpression - )? - orderByClause? limitClause? lockClause? #unionParenthesisSelect - | querySpecificationNointo (',' lateralStatement)+ #withLateralStatement + : querySpecification lockClause? # simpleSelect + | queryExpression lockClause? # parenthesisSelect + | (querySpecificationNointo | queryExpressionNointo) unionStatement+ ( + UNION unionType = (ALL | DISTINCT)? (querySpecification | queryExpression) + )? orderByClause? limitClause? lockClause? # unionSelect + | queryExpressionNointo unionParenthesis+ (UNION unionType = (ALL | DISTINCT)? queryExpression)? orderByClause? limitClause? lockClause? # + unionParenthesisSelect + | querySpecificationNointo (',' lateralStatement)+ # withLateralStatement ; updateStatement - : singleUpdateStatement | multipleUpdateStatement + : singleUpdateStatement + | multipleUpdateStatement ; // https://dev.mysql.com/doc/refman/8.0/en/values.html valuesStatement - : VALUES - '(' expressionsWithDefaults? ')' - (',' '(' expressionsWithDefaults? ')')* + : VALUES '(' expressionsWithDefaults? ')' (',' '(' expressionsWithDefaults? ')')* ; // details insertStatementValue : selectStatement - | insertFormat=(VALUES | VALUE) - '(' expressionsWithDefaults? ')' - (',' '(' expressionsWithDefaults? ')')* + | insertFormat = (VALUES | VALUE) '(' expressionsWithDefaults? ')' ( + ',' '(' expressionsWithDefaults? ')' + )* ; updatedElement @@ -942,33 +894,28 @@ updatedElement ; assignmentField - : uid | LOCAL_ID + : uid + | LOCAL_ID ; lockClause - : FOR UPDATE | LOCK IN SHARE MODE + : FOR UPDATE + | LOCK IN SHARE MODE ; // Detailed DML Statements singleDeleteStatement - : DELETE priority=LOW_PRIORITY? QUICK? IGNORE? - FROM tableName (AS? uid)? - (PARTITION '(' uidList ')' )? - (WHERE expression)? - orderByClause? (LIMIT limitClauseAtom)? + : DELETE priority = LOW_PRIORITY? QUICK? IGNORE? FROM tableName (AS? uid)? ( + PARTITION '(' uidList ')' + )? (WHERE expression)? orderByClause? (LIMIT limitClauseAtom)? ; multipleDeleteStatement - : DELETE priority=LOW_PRIORITY? QUICK? IGNORE? - ( - tableName ('.' '*')? ( ',' tableName ('.' '*')? )* - FROM tableSources - | FROM - tableName ('.' '*')? ( ',' tableName ('.' '*')? )* - USING tableSources - ) - (WHERE expression)? + : DELETE priority = LOW_PRIORITY? QUICK? IGNORE? ( + tableName ('.' '*')? ( ',' tableName ('.' '*')?)* FROM tableSources + | FROM tableName ('.' '*')? ( ',' tableName ('.' '*')?)* USING tableSources + ) (WHERE expression)? ; handlerOpenStatement @@ -976,17 +923,14 @@ handlerOpenStatement ; handlerReadIndexStatement - : HANDLER tableName READ index=uid - ( + : HANDLER tableName READ index = uid ( comparisonOperator '(' constants ')' - | moveOrder=(FIRST | NEXT | PREV | LAST) - ) - (WHERE expression)? (LIMIT limitClauseAtom)? + | moveOrder = (FIRST | NEXT | PREV | LAST) + ) (WHERE expression)? (LIMIT limitClauseAtom)? ; handlerReadStatement - : HANDLER tableName READ moveOrder=(FIRST | NEXT) - (WHERE expression)? (LIMIT limitClauseAtom)? + : HANDLER tableName READ moveOrder = (FIRST | NEXT) (WHERE expression)? (LIMIT limitClauseAtom)? ; handlerCloseStatement @@ -994,15 +938,15 @@ handlerCloseStatement ; singleUpdateStatement - : UPDATE priority=LOW_PRIORITY? IGNORE? tableName (AS? uid)? - SET updatedElement (',' updatedElement)* - (WHERE expression)? orderByClause? limitClause? + : UPDATE priority = LOW_PRIORITY? IGNORE? tableName (AS? uid)? SET updatedElement ( + ',' updatedElement + )* (WHERE expression)? orderByClause? limitClause? ; multipleUpdateStatement - : UPDATE priority=LOW_PRIORITY? IGNORE? tableSources - SET updatedElement (',' updatedElement)* - (WHERE expression)? + : UPDATE priority = LOW_PRIORITY? IGNORE? tableSources SET updatedElement (',' updatedElement)* ( + WHERE expression + )? ; // details @@ -1012,7 +956,7 @@ orderByClause ; orderByExpression - : expression order=(ASC | DESC)? + : expression order = (ASC | DESC)? ; tableSources @@ -1020,38 +964,32 @@ tableSources ; tableSource - : tableSourceItem joinPart* #tableSourceBase - | '(' tableSourceItem joinPart* ')' #tableSourceNested - | jsonTable #tableJson + : tableSourceItem joinPart* # tableSourceBase + | '(' tableSourceItem joinPart* ')' # tableSourceNested + | jsonTable # tableJson ; tableSourceItem - : tableName - (PARTITION '(' uidList ')' )? (AS? alias=uid)? - (indexHint (',' indexHint)* )? #atomTableItem - | ( - selectStatement - | '(' parenthesisSubquery=selectStatement ')' - ) - AS? alias=uid #subqueryTableItem - | '(' tableSources ')' #tableSourcesItem + : tableName (PARTITION '(' uidList ')')? (AS? alias = uid)? (indexHint (',' indexHint)*)? # atomTableItem + | (selectStatement | '(' parenthesisSubquery = selectStatement ')') AS? alias = uid # subqueryTableItem + | '(' tableSources ')' # tableSourcesItem ; indexHint - : indexHintAction=(USE | IGNORE | FORCE) - keyFormat=(INDEX|KEY) ( FOR indexHintType)? - '(' uidList ')' + : indexHintAction = (USE | IGNORE | FORCE) keyFormat = (INDEX | KEY) (FOR indexHintType)? '(' uidList ')' ; indexHintType - : JOIN | ORDER BY | GROUP BY + : JOIN + | ORDER BY + | GROUP BY ; joinPart - : (INNER | CROSS)? JOIN LATERAL? tableSourceItem joinSpec* #innerJoin - | STRAIGHT_JOIN tableSourceItem (ON expression)* #straightJoin - | (LEFT | RIGHT) OUTER? JOIN LATERAL? tableSourceItem joinSpec* #outerJoin - | NATURAL ((LEFT | RIGHT) OUTER?)? JOIN tableSourceItem #naturalJoin + : (INNER | CROSS)? JOIN LATERAL? tableSourceItem joinSpec* # innerJoin + | STRAIGHT_JOIN tableSourceItem (ON expression)* # straightJoin + | (LEFT | RIGHT) OUTER? JOIN LATERAL? tableSourceItem joinSpec* # outerJoin + | NATURAL ((LEFT | RIGHT) OUTER?)? JOIN tableSourceItem # naturalJoin ; joinSpec @@ -1072,42 +1010,35 @@ queryExpressionNointo ; querySpecification - : SELECT selectSpec* selectElements selectIntoExpression? - fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? - | SELECT selectSpec* selectElements - fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? selectIntoExpression? + : SELECT selectSpec* selectElements selectIntoExpression? fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? + | SELECT selectSpec* selectElements fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? selectIntoExpression? ; querySpecificationNointo - : SELECT selectSpec* selectElements - fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? + : SELECT selectSpec* selectElements fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? ; unionParenthesis - : UNION unionType=(ALL | DISTINCT)? queryExpressionNointo + : UNION unionType = (ALL | DISTINCT)? queryExpressionNointo ; unionStatement - : UNION unionType=(ALL | DISTINCT)? - (querySpecificationNointo | queryExpressionNointo) + : UNION unionType = (ALL | DISTINCT)? (querySpecificationNointo | queryExpressionNointo) ; lateralStatement - : LATERAL (querySpecificationNointo | - queryExpressionNointo | - ('(' (querySpecificationNointo | queryExpressionNointo) ')' (AS? uid)?) - ) + : LATERAL ( + querySpecificationNointo + | queryExpressionNointo + | ('(' (querySpecificationNointo | queryExpressionNointo) ')' (AS? uid)?) + ) ; // JSON // https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html jsonTable - : JSON_TABLE '(' - STRING_LITERAL ',' - STRING_LITERAL - COLUMNS '(' jsonColumnList ')' - ')' (AS? uid)? + : JSON_TABLE '(' STRING_LITERAL ',' STRING_LITERAL COLUMNS '(' jsonColumnList ')' ')' (AS? uid)? ; jsonColumnList @@ -1115,9 +1046,10 @@ jsonColumnList ; jsonColumn - : fullColumnName ( FOR ORDINALITY - | dataType ( PATH STRING_LITERAL jsonOnEmpty? jsonOnError? - | EXISTS PATH STRING_LITERAL ) ) + : fullColumnName ( + FOR ORDINALITY + | dataType (PATH STRING_LITERAL jsonOnEmpty? jsonOnError? | EXISTS PATH STRING_LITERAL) + ) | NESTED PATH? STRING_LITERAL COLUMNS '(' jsonColumnList ')' ; @@ -1133,90 +1065,84 @@ jsonOnError selectSpec : (ALL | DISTINCT | DISTINCTROW) - | HIGH_PRIORITY | STRAIGHT_JOIN | SQL_SMALL_RESULT - | SQL_BIG_RESULT | SQL_BUFFER_RESULT + | HIGH_PRIORITY + | STRAIGHT_JOIN + | SQL_SMALL_RESULT + | SQL_BIG_RESULT + | SQL_BUFFER_RESULT | (SQL_CACHE | SQL_NO_CACHE) | SQL_CALC_FOUND_ROWS ; selectElements - : (star='*' | selectElement ) (',' selectElement)* + : (star = '*' | selectElement) (',' selectElement)* ; selectElement - : fullId '.' '*' #selectStarElement - | fullColumnName (AS? uid)? #selectColumnElement - | functionCall (AS? uid)? #selectFunctionElement - | (LOCAL_ID VAR_ASSIGN)? expression (AS? uid)? #selectExpressionElement + : fullId '.' '*' # selectStarElement + | fullColumnName (AS? uid)? # selectColumnElement + | functionCall (AS? uid)? # selectFunctionElement + | (LOCAL_ID VAR_ASSIGN)? expression (AS? uid)? # selectExpressionElement ; selectIntoExpression - : INTO assignmentField (',' assignmentField )* #selectIntoVariables - | INTO DUMPFILE STRING_LITERAL #selectIntoDumpFile + : INTO assignmentField (',' assignmentField)* # selectIntoVariables + | INTO DUMPFILE STRING_LITERAL # selectIntoDumpFile | ( - INTO OUTFILE filename=STRING_LITERAL - (CHARACTER SET charset=charsetName)? - ( - fieldsFormat=(FIELDS | COLUMNS) - selectFieldsInto+ - )? - ( - LINES selectLinesInto+ - )? - ) #selectIntoTextFile + INTO OUTFILE filename = STRING_LITERAL (CHARACTER SET charset = charsetName)? ( + fieldsFormat = (FIELDS | COLUMNS) selectFieldsInto+ + )? (LINES selectLinesInto+)? + ) # selectIntoTextFile ; selectFieldsInto - : TERMINATED BY terminationField=STRING_LITERAL - | OPTIONALLY? ENCLOSED BY enclosion=STRING_LITERAL - | ESCAPED BY escaping=STRING_LITERAL + : TERMINATED BY terminationField = STRING_LITERAL + | OPTIONALLY? ENCLOSED BY enclosion = STRING_LITERAL + | ESCAPED BY escaping = STRING_LITERAL ; selectLinesInto - : STARTING BY starting=STRING_LITERAL - | TERMINATED BY terminationLine=STRING_LITERAL + : STARTING BY starting = STRING_LITERAL + | TERMINATED BY terminationLine = STRING_LITERAL ; fromClause - : (FROM tableSources)? - (WHERE whereExpr=expression)? + : (FROM tableSources)? (WHERE whereExpr = expression)? ; groupByClause - : GROUP BY - groupByItem (',' groupByItem)* - (WITH ROLLUP)? + : GROUP BY groupByItem (',' groupByItem)* (WITH ROLLUP)? ; havingClause - : HAVING havingExpr=expression + : HAVING havingExpr = expression ; windowClause - : WINDOW windowName AS '(' windowSpec ')' (',' windowName AS '(' windowSpec ')')* + : WINDOW windowName AS '(' windowSpec ')' (',' windowName AS '(' windowSpec ')')* ; groupByItem - : expression order=(ASC | DESC)? + : expression order = (ASC | DESC)? ; limitClause - : LIMIT - ( - (offset=limitClauseAtom ',')? limit=limitClauseAtom - | limit=limitClauseAtom OFFSET offset=limitClauseAtom + : LIMIT ( + (offset = limitClauseAtom ',')? limit = limitClauseAtom + | limit = limitClauseAtom OFFSET offset = limitClauseAtom ) ; limitClauseAtom - : decimalLiteral | mysqlVariable | simpleId - ; - + : decimalLiteral + | mysqlVariable + | simpleId + ; // Transaction's Statements startTransaction - : START TRANSACTION (transactionMode (',' transactionMode)* )? + : START TRANSACTION (transactionMode (',' transactionMode)*)? ; beginWork @@ -1224,15 +1150,11 @@ beginWork ; commitWork - : COMMIT WORK? - (AND nochain=NO? CHAIN)? - (norelease=NO? RELEASE)? + : COMMIT WORK? (AND nochain = NO? CHAIN)? (norelease = NO? RELEASE)? ; rollbackWork - : ROLLBACK WORK? - (AND nochain=NO? CHAIN)? - (norelease=NO? RELEASE)? + : ROLLBACK WORK? (AND nochain = NO? CHAIN)? (norelease = NO? RELEASE)? ; savepointStatement @@ -1255,16 +1177,16 @@ unlockTables : UNLOCK TABLES ; - // details setAutocommitStatement - : SET AUTOCOMMIT '=' autocommitValue=('0' | '1') + : SET AUTOCOMMIT '=' autocommitValue = ('0' | '1') ; setTransactionStatement - : SET transactionContext=(GLOBAL | SESSION)? TRANSACTION - transactionOption (',' transactionOption)* + : SET transactionContext = (GLOBAL | SESSION)? TRANSACTION transactionOption ( + ',' transactionOption + )* ; transactionMode @@ -1278,7 +1200,8 @@ lockTableElement ; lockAction - : READ LOCAL? | LOW_PRIORITY? WRITE + : READ LOCAL? + | LOW_PRIORITY? WRITE ; transactionOption @@ -1294,27 +1217,23 @@ transactionLevel | SERIALIZABLE ; - // Replication's Statements // Base Replication changeMaster - : CHANGE MASTER TO - masterOption (',' masterOption)* channelOption? + : CHANGE MASTER TO masterOption (',' masterOption)* channelOption? ; changeReplicationFilter - : CHANGE REPLICATION FILTER - replicationFilter (',' replicationFilter)* + : CHANGE REPLICATION FILTER replicationFilter (',' replicationFilter)* ; purgeBinaryLogs - : PURGE purgeFormat=(BINARY | MASTER) LOGS - ( - TO fileName=STRING_LITERAL - | BEFORE timeValue=STRING_LITERAL - ) + : PURGE purgeFormat = (BINARY | MASTER) LOGS ( + TO fileName = STRING_LITERAL + | BEFORE timeValue = STRING_LITERAL + ) ; resetMaster @@ -1326,9 +1245,7 @@ resetSlave ; startSlave - : START SLAVE (threadType (',' threadType)*)? - (UNTIL untilOption)? - connectionOption* channelOption? + : START SLAVE (threadType (',' threadType)*)? (UNTIL untilOption)? connectionOption* channelOption? ; stopSlave @@ -1346,27 +1263,42 @@ stopGroupReplication // details masterOption - : stringMasterOption '=' STRING_LITERAL #masterStringOption - | decimalMasterOption '=' decimalLiteral #masterDecimalOption - | boolMasterOption '=' boolVal=('0' | '1') #masterBoolOption - | MASTER_HEARTBEAT_PERIOD '=' REAL_LITERAL #masterRealOption - | IGNORE_SERVER_IDS '=' '(' (uid (',' uid)*)? ')' #masterUidListOption + : stringMasterOption '=' STRING_LITERAL # masterStringOption + | decimalMasterOption '=' decimalLiteral # masterDecimalOption + | boolMasterOption '=' boolVal = ('0' | '1') # masterBoolOption + | MASTER_HEARTBEAT_PERIOD '=' REAL_LITERAL # masterRealOption + | IGNORE_SERVER_IDS '=' '(' (uid (',' uid)*)? ')' # masterUidListOption ; stringMasterOption - : MASTER_BIND | MASTER_HOST | MASTER_USER | MASTER_PASSWORD - | MASTER_LOG_FILE | RELAY_LOG_FILE | MASTER_SSL_CA - | MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CRL - | MASTER_SSL_CRLPATH | MASTER_SSL_KEY | MASTER_SSL_CIPHER + : MASTER_BIND + | MASTER_HOST + | MASTER_USER + | MASTER_PASSWORD + | MASTER_LOG_FILE + | RELAY_LOG_FILE + | MASTER_SSL_CA + | MASTER_SSL_CAPATH + | MASTER_SSL_CERT + | MASTER_SSL_CRL + | MASTER_SSL_CRLPATH + | MASTER_SSL_KEY + | MASTER_SSL_CIPHER | MASTER_TLS_VERSION ; + decimalMasterOption - : MASTER_PORT | MASTER_CONNECT_RETRY | MASTER_RETRY_COUNT - | MASTER_DELAY | MASTER_LOG_POS | RELAY_LOG_POS + : MASTER_PORT + | MASTER_CONNECT_RETRY + | MASTER_RETRY_COUNT + | MASTER_DELAY + | MASTER_LOG_POS + | RELAY_LOG_POS ; boolMasterOption - : MASTER_AUTO_POSITION | MASTER_SSL + : MASTER_AUTO_POSITION + | MASTER_SSL | MASTER_SSL_VERIFY_SERVER_CERT ; @@ -1375,40 +1307,36 @@ channelOption ; replicationFilter - : REPLICATE_DO_DB '=' '(' uidList ')' #doDbReplication - | REPLICATE_IGNORE_DB '=' '(' uidList ')' #ignoreDbReplication - | REPLICATE_DO_TABLE '=' '(' tables ')' #doTableReplication - | REPLICATE_IGNORE_TABLE '=' '(' tables ')' #ignoreTableReplication - | REPLICATE_WILD_DO_TABLE '=' '(' simpleStrings ')' #wildDoTableReplication - | REPLICATE_WILD_IGNORE_TABLE - '=' '(' simpleStrings ')' #wildIgnoreTableReplication - | REPLICATE_REWRITE_DB '=' - '(' tablePair (',' tablePair)* ')' #rewriteDbReplication + : REPLICATE_DO_DB '=' '(' uidList ')' # doDbReplication + | REPLICATE_IGNORE_DB '=' '(' uidList ')' # ignoreDbReplication + | REPLICATE_DO_TABLE '=' '(' tables ')' # doTableReplication + | REPLICATE_IGNORE_TABLE '=' '(' tables ')' # ignoreTableReplication + | REPLICATE_WILD_DO_TABLE '=' '(' simpleStrings ')' # wildDoTableReplication + | REPLICATE_WILD_IGNORE_TABLE '=' '(' simpleStrings ')' # wildIgnoreTableReplication + | REPLICATE_REWRITE_DB '=' '(' tablePair (',' tablePair)* ')' # rewriteDbReplication ; tablePair - : '(' firstTable=tableName ',' secondTable=tableName ')' + : '(' firstTable = tableName ',' secondTable = tableName ')' ; threadType - : IO_THREAD | SQL_THREAD + : IO_THREAD + | SQL_THREAD ; untilOption - : gtids=(SQL_BEFORE_GTIDS | SQL_AFTER_GTIDS) - '=' gtuidSet #gtidsUntilOption - | MASTER_LOG_FILE '=' STRING_LITERAL - ',' MASTER_LOG_POS '=' decimalLiteral #masterLogUntilOption - | RELAY_LOG_FILE '=' STRING_LITERAL - ',' RELAY_LOG_POS '=' decimalLiteral #relayLogUntilOption - | SQL_AFTER_MTS_GAPS #sqlGapsUntilOption + : gtids = (SQL_BEFORE_GTIDS | SQL_AFTER_GTIDS) '=' gtuidSet # gtidsUntilOption + | MASTER_LOG_FILE '=' STRING_LITERAL ',' MASTER_LOG_POS '=' decimalLiteral # masterLogUntilOption + | RELAY_LOG_FILE '=' STRING_LITERAL ',' RELAY_LOG_POS '=' decimalLiteral # relayLogUntilOption + | SQL_AFTER_MTS_GAPS # sqlGapsUntilOption ; connectionOption - : USER '=' conOptUser=STRING_LITERAL #userConnectionOption - | PASSWORD '=' conOptPassword=STRING_LITERAL #passwordConnectionOption - | DEFAULT_AUTH '=' conOptDefAuth=STRING_LITERAL #defaultAuthConnectionOption - | PLUGIN_DIR '=' conOptPluginDir=STRING_LITERAL #pluginDirConnectionOption + : USER '=' conOptUser = STRING_LITERAL # userConnectionOption + | PASSWORD '=' conOptPassword = STRING_LITERAL # passwordConnectionOption + | DEFAULT_AUTH '=' conOptDefAuth = STRING_LITERAL # defaultAuthConnectionOption + | PLUGIN_DIR '=' conOptPluginDir = STRING_LITERAL # pluginDirConnectionOption ; gtuidSet @@ -1416,11 +1344,10 @@ gtuidSet | STRING_LITERAL ; - // XA Transactions xaStartTransaction - : XA xaStart=(START | BEGIN) xid xaAction=(JOIN | RESUME)? + : XA xaStart = (START | BEGIN) xid xaAction = (JOIN | RESUME)? ; xaEndTransaction @@ -1443,12 +1370,10 @@ xaRecoverWork : XA RECOVER (CONVERT xid)? ; - // Prepared Statements prepareStatement - : PREPARE uid FROM - (query=STRING_LITERAL | variable=LOCAL_ID) + : PREPARE uid FROM (query = STRING_LITERAL | variable = LOCAL_ID) ; executeStatement @@ -1456,40 +1381,32 @@ executeStatement ; deallocatePrepare - : dropFormat=(DEALLOCATE | DROP) PREPARE uid + : dropFormat = (DEALLOCATE | DROP) PREPARE uid ; - // Compound Statements routineBody - : blockStatement | sqlStatement + : blockStatement + | sqlStatement ; // details blockStatement - : (uid ':')? BEGIN - (declareVariable SEMI)* - (declareCondition SEMI)* - (declareCursor SEMI)* - (declareHandler SEMI)* - procedureSqlStatement* - END uid? + : (uid ':')? BEGIN (declareVariable SEMI)* (declareCondition SEMI)* (declareCursor SEMI)* ( + declareHandler SEMI + )* procedureSqlStatement* END uid? ; caseStatement - : CASE (uid | expression)? caseAlternative+ - (ELSE procedureSqlStatement+)? - END CASE + : CASE (uid | expression)? caseAlternative+ (ELSE procedureSqlStatement+)? END CASE ; ifStatement - : IF expression - THEN thenStatements+=procedureSqlStatement+ - elifAlternative* - (ELSE elseStatements+=procedureSqlStatement+ )? - END IF + : IF expression THEN thenStatements += procedureSqlStatement+ elifAlternative* ( + ELSE elseStatements += procedureSqlStatement+ + )? END IF ; iterateStatement @@ -1501,16 +1418,11 @@ leaveStatement ; loopStatement - : (uid ':')? - LOOP procedureSqlStatement+ - END LOOP uid? + : (uid ':')? LOOP procedureSqlStatement+ END LOOP uid? ; repeatStatement - : (uid ':')? - REPEAT procedureSqlStatement+ - UNTIL expression - END REPEAT uid? + : (uid ':')? REPEAT procedureSqlStatement+ UNTIL expression END REPEAT uid? ; returnStatement @@ -1518,16 +1430,13 @@ returnStatement ; whileStatement - : (uid ':')? - WHILE expression - DO procedureSqlStatement+ - END WHILE uid? + : (uid ':')? WHILE expression DO procedureSqlStatement+ END WHILE uid? ; cursorStatement - : CLOSE uid #CloseCursor - | FETCH (NEXT? FROM)? uid INTO uidList #FetchCursor - | OPEN uid #OpenCursor + : CLOSE uid # CloseCursor + | FETCH (NEXT? FROM)? uid INTO uidList # FetchCursor + | OPEN uid # OpenCursor ; // details @@ -1537,8 +1446,7 @@ declareVariable ; declareCondition - : DECLARE uid CONDITION FOR - ( decimalLiteral | SQLSTATE VALUE? STRING_LITERAL) + : DECLARE uid CONDITION FOR (decimalLiteral | SQLSTATE VALUE? STRING_LITERAL) ; declareCursor @@ -1546,19 +1454,18 @@ declareCursor ; declareHandler - : DECLARE handlerAction=(CONTINUE | EXIT | UNDO) - HANDLER FOR - handlerConditionValue (',' handlerConditionValue)* - routineBody + : DECLARE handlerAction = (CONTINUE | EXIT | UNDO) HANDLER FOR handlerConditionValue ( + ',' handlerConditionValue + )* routineBody ; handlerConditionValue - : decimalLiteral #handlerConditionCode - | SQLSTATE VALUE? STRING_LITERAL #handlerConditionState - | uid #handlerConditionName - | SQLWARNING #handlerConditionWarning - | NOT FOUND #handlerConditionNotfound - | SQLEXCEPTION #handlerConditionException + : decimalLiteral # handlerConditionCode + | SQLSTATE VALUE? STRING_LITERAL # handlerConditionState + | uid # handlerConditionName + | SQLWARNING # handlerConditionWarning + | NOT FOUND # handlerConditionNotfound + | SQLEXCEPTION # handlerConditionException ; procedureSqlStatement @@ -1566,13 +1473,11 @@ procedureSqlStatement ; caseAlternative - : WHEN (constant | expression) - THEN procedureSqlStatement+ + : WHEN (constant | expression) THEN procedureSqlStatement+ ; elifAlternative - : ELSEIF expression - THEN procedureSqlStatement+ + : ELSEIF expression THEN procedureSqlStatement+ ; // Administration Statements @@ -1580,33 +1485,24 @@ elifAlternative // Account management statements alterUser - : ALTER USER - userSpecification (',' userSpecification)* #alterUserMysqlV56 - | ALTER USER ifExists? - userAuthOption (',' userAuthOption)* - ( - REQUIRE - (tlsNone=NONE | tlsOption (AND? tlsOption)* ) - )? - (WITH userResourceOption+)? - (userPasswordOption | userLockOption)* - (COMMENT STRING_LITERAL | ATTRIBUTE STRING_LITERAL)? #alterUserMysqlV80 - | ALTER USER ifExists? - (userName | uid) DEFAULT ROLE roleOption #alterUserMysqlV80 + : ALTER USER userSpecification (',' userSpecification)* # alterUserMysqlV56 + | ALTER USER ifExists? userAuthOption (',' userAuthOption)* ( + REQUIRE (tlsNone = NONE | tlsOption (AND? tlsOption)*) + )? (WITH userResourceOption+)? (userPasswordOption | userLockOption)* ( + COMMENT STRING_LITERAL + | ATTRIBUTE STRING_LITERAL + )? # alterUserMysqlV80 + | ALTER USER ifExists? (userName | uid) DEFAULT ROLE roleOption # alterUserMysqlV80 ; createUser - : CREATE USER userAuthOption (',' userAuthOption)* #createUserMysqlV56 - | CREATE USER ifNotExists? - userAuthOption (',' userAuthOption)* - (DEFAULT ROLE roleOption)? - ( - REQUIRE - (tlsNone=NONE | tlsOption (AND? tlsOption)* ) - )? - (WITH userResourceOption+)? - (userPasswordOption | userLockOption)* - (COMMENT STRING_LITERAL | ATTRIBUTE STRING_LITERAL)? #createUserMysqlV80 + : CREATE USER userAuthOption (',' userAuthOption)* # createUserMysqlV56 + | CREATE USER ifNotExists? userAuthOption (',' userAuthOption)* (DEFAULT ROLE roleOption)? ( + REQUIRE (tlsNone = NONE | tlsOption (AND? tlsOption)*) + )? (WITH userResourceOption+)? (userPasswordOption | userLockOption)* ( + COMMENT STRING_LITERAL + | ATTRIBUTE STRING_LITERAL + )? # createUserMysqlV80 ; dropUser @@ -1614,20 +1510,16 @@ dropUser ; grantStatement - : GRANT privelegeClause (',' privelegeClause)* - ON - privilegeObject=(TABLE | FUNCTION | PROCEDURE)? - privilegeLevel - TO userAuthOption (',' userAuthOption)* - ( - REQUIRE - (tlsNone=NONE | tlsOption (AND? tlsOption)* ) - )? - (WITH (GRANT OPTION | userResourceOption)* )? - (AS userName WITH ROLE roleOption)? - | GRANT (userName | uid) (',' (userName | uid))* - TO (userName | uid) (',' (userName | uid))* - (WITH ADMIN OPTION)? + : GRANT privelegeClause (',' privelegeClause)* ON privilegeObject = ( + TABLE + | FUNCTION + | PROCEDURE + )? privilegeLevel TO userAuthOption (',' userAuthOption)* ( + REQUIRE (tlsNone = NONE | tlsOption (AND? tlsOption)*) + )? (WITH (GRANT OPTION | userResourceOption)*)? (AS userName WITH ROLE roleOption)? + | GRANT (userName | uid) (',' (userName | uid))* TO (userName | uid) (',' (userName | uid))* ( + WITH ADMIN OPTION + )? ; roleOption @@ -1638,36 +1530,31 @@ roleOption ; grantProxy - : GRANT PROXY ON fromFirst=userName - TO toFirst=userName (',' toOther+=userName)* - (WITH GRANT OPTION)? + : GRANT PROXY ON fromFirst = userName TO toFirst = userName (',' toOther += userName)* ( + WITH GRANT OPTION + )? ; renameUser - : RENAME USER - renameUserClause (',' renameUserClause)* + : RENAME USER renameUserClause (',' renameUserClause)* ; revokeStatement - : REVOKE privelegeClause (',' privelegeClause)* - ON - privilegeObject=(TABLE | FUNCTION | PROCEDURE)? - privilegeLevel - FROM userName (',' userName)* #detailRevoke - | REVOKE ALL PRIVILEGES? ',' GRANT OPTION - FROM userName (',' userName)* #shortRevoke - | REVOKE (userName | uid) (',' (userName | uid))* - FROM (userName | uid) (',' (userName | uid))* #roleRevoke + : REVOKE privelegeClause (',' privelegeClause)* ON privilegeObject = ( + TABLE + | FUNCTION + | PROCEDURE + )? privilegeLevel FROM userName (',' userName)* # detailRevoke + | REVOKE ALL PRIVILEGES? ',' GRANT OPTION FROM userName (',' userName)* # shortRevoke + | REVOKE (userName | uid) (',' (userName | uid))* FROM (userName | uid) (',' (userName | uid))* # roleRevoke ; revokeProxy - : REVOKE PROXY ON onUser=userName - FROM fromFirst=userName (',' fromOther+=userName)* + : REVOKE PROXY ON onUser = userName FROM fromFirst = userName (',' fromOther += userName)* ; setPasswordStatement - : SET PASSWORD (FOR userName)? - '=' ( passwordFunctionClause | STRING_LITERAL) + : SET PASSWORD (FOR userName)? '=' (passwordFunctionClause | STRING_LITERAL) ; // details @@ -1677,11 +1564,11 @@ userSpecification ; userAuthOption - : userName IDENTIFIED BY PASSWORD hashed=STRING_LITERAL #hashAuthOption - | userName IDENTIFIED BY RANDOM PASSWORD authOptionClause #randomAuthOption - | userName IDENTIFIED BY STRING_LITERAL authOptionClause #stringAuthOption - | userName IDENTIFIED WITH authenticationRule #moduleAuthOption - | userName #simpleAuthOption + : userName IDENTIFIED BY PASSWORD hashed = STRING_LITERAL # hashAuthOption + | userName IDENTIFIED BY RANDOM PASSWORD authOptionClause # randomAuthOption + | userName IDENTIFIED BY STRING_LITERAL authOptionClause # stringAuthOption + | userName IDENTIFIED WITH authenticationRule # moduleAuthOption + | userName # simpleAuthOption ; authOptionClause @@ -1689,11 +1576,8 @@ authOptionClause ; authenticationRule - : authPlugin - ((BY | USING | AS) (STRING_LITERAL | RANDOM PASSWORD) - authOptionClause)? #module - | authPlugin - USING passwordFunctionClause #passwordModuleOption + : authPlugin ((BY | USING | AS) (STRING_LITERAL | RANDOM PASSWORD) authOptionClause)? # module + | authPlugin USING passwordFunctionClause # passwordModuleOption ; tlsOption @@ -1712,11 +1596,11 @@ userResourceOption ; userPasswordOption - : PASSWORD EXPIRE - (expireType=DEFAULT - | expireType=NEVER - | expireType=INTERVAL decimalLiteral DAY - )? + : PASSWORD EXPIRE ( + expireType = DEFAULT + | expireType = NEVER + | expireType = INTERVAL decimalLiteral DAY + )? | PASSWORD HISTORY (DEFAULT | decimalLiteral) | PASSWORD REUSE INTERVAL (DEFAULT | decimalLiteral DAY) | PASSWORD REQUIRE CURRENT (OPTIONAL | DEFAULT)? @@ -1725,57 +1609,102 @@ userPasswordOption ; userLockOption - : ACCOUNT lockType=(LOCK | UNLOCK) + : ACCOUNT lockType = (LOCK | UNLOCK) ; privelegeClause - : privilege ( '(' uidList ')' )? + : privilege ('(' uidList ')')? ; privilege : ALL PRIVILEGES? | ALTER ROUTINE? - | CREATE - (TEMPORARY TABLES | ROUTINE | VIEW | USER | TABLESPACE | ROLE)? - | DELETE | DROP (ROLE)? | EVENT | EXECUTE | FILE | GRANT OPTION - | INDEX | INSERT | LOCK TABLES | PROCESS | PROXY - | REFERENCES | RELOAD + | CREATE (TEMPORARY TABLES | ROUTINE | VIEW | USER | TABLESPACE | ROLE)? + | DELETE + | DROP (ROLE)? + | EVENT + | EXECUTE + | FILE + | GRANT OPTION + | INDEX + | INSERT + | LOCK TABLES + | PROCESS + | PROXY + | REFERENCES + | RELOAD | REPLICATION (CLIENT | SLAVE) | SELECT | SHOW (VIEW | DATABASES) - | SHUTDOWN | SUPER | TRIGGER | UPDATE | USAGE - | APPLICATION_PASSWORD_ADMIN | AUDIT_ABORT_EXEMPT | AUDIT_ADMIN | AUTHENTICATION_POLICY_ADMIN | BACKUP_ADMIN | BINLOG_ADMIN | BINLOG_ENCRYPTION_ADMIN | CLONE_ADMIN - | CONNECTION_ADMIN | ENCRYPTION_KEY_ADMIN | FIREWALL_ADMIN | FIREWALL_EXEMPT | FIREWALL_USER | FLUSH_OPTIMIZER_COSTS - | FLUSH_STATUS | FLUSH_TABLES | FLUSH_USER_RESOURCES | GROUP_REPLICATION_ADMIN - | INNODB_REDO_LOG_ARCHIVE | INNODB_REDO_LOG_ENABLE | NDB_STORED_USER | PASSWORDLESS_USER_ADMIN | PERSIST_RO_VARIABLES_ADMIN | REPLICATION_APPLIER - | REPLICATION_SLAVE_ADMIN | RESOURCE_GROUP_ADMIN | RESOURCE_GROUP_USER | ROLE_ADMIN + | SHUTDOWN + | SUPER + | TRIGGER + | UPDATE + | USAGE + | APPLICATION_PASSWORD_ADMIN + | AUDIT_ABORT_EXEMPT + | AUDIT_ADMIN + | AUTHENTICATION_POLICY_ADMIN + | BACKUP_ADMIN + | BINLOG_ADMIN + | BINLOG_ENCRYPTION_ADMIN + | CLONE_ADMIN + | CONNECTION_ADMIN + | ENCRYPTION_KEY_ADMIN + | FIREWALL_ADMIN + | FIREWALL_EXEMPT + | FIREWALL_USER + | FLUSH_OPTIMIZER_COSTS + | FLUSH_STATUS + | FLUSH_TABLES + | FLUSH_USER_RESOURCES + | GROUP_REPLICATION_ADMIN + | INNODB_REDO_LOG_ARCHIVE + | INNODB_REDO_LOG_ENABLE + | NDB_STORED_USER + | PASSWORDLESS_USER_ADMIN + | PERSIST_RO_VARIABLES_ADMIN + | REPLICATION_APPLIER + | REPLICATION_SLAVE_ADMIN + | RESOURCE_GROUP_ADMIN + | RESOURCE_GROUP_USER + | ROLE_ADMIN | SERVICE_CONNECTION_ADMIN - | SESSION_VARIABLES_ADMIN | SET_USER_ID | SKIP_QUERY_REWRITE | SHOW_ROUTINE | SYSTEM_USER | SYSTEM_VARIABLES_ADMIN - | TABLE_ENCRYPTION_ADMIN | TP_CONNECTION_ADMIN | VERSION_TOKEN_ADMIN | XA_RECOVER_ADMIN + | SESSION_VARIABLES_ADMIN + | SET_USER_ID + | SKIP_QUERY_REWRITE + | SHOW_ROUTINE + | SYSTEM_USER + | SYSTEM_VARIABLES_ADMIN + | TABLE_ENCRYPTION_ADMIN + | TP_CONNECTION_ADMIN + | VERSION_TOKEN_ADMIN + | XA_RECOVER_ADMIN // MySQL on Amazon RDS - | LOAD FROM S3 | SELECT INTO S3 | INVOKE LAMBDA + | LOAD FROM S3 + | SELECT INTO S3 + | INVOKE LAMBDA ; privilegeLevel - : '*' #currentSchemaPriviLevel - | '*' '.' '*' #globalPrivLevel - | uid '.' '*' #definiteSchemaPrivLevel - | uid '.' uid #definiteFullTablePrivLevel - | uid dottedId #definiteFullTablePrivLevel2 - | uid #definiteTablePrivLevel + : '*' # currentSchemaPriviLevel + | '*' '.' '*' # globalPrivLevel + | uid '.' '*' # definiteSchemaPrivLevel + | uid '.' uid # definiteFullTablePrivLevel + | uid dottedId # definiteFullTablePrivLevel2 + | uid # definiteTablePrivLevel ; renameUserClause - : fromFirst=userName TO toFirst=userName + : fromFirst = userName TO toFirst = userName ; // Table maintenance statements analyzeTable - : ANALYZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)? - (TABLE | TABLES) tables - ( UPDATE HISTOGRAM ON fullColumnName (',' fullColumnName)* (WITH decimalLiteral BUCKETS)? )? - ( DROP HISTOGRAM ON fullColumnName (',' fullColumnName)* )? + : ANALYZE actionOption = (NO_WRITE_TO_BINLOG | LOCAL)? (TABLE | TABLES) tables ( + UPDATE HISTOGRAM ON fullColumnName (',' fullColumnName)* (WITH decimalLiteral BUCKETS)? + )? (DROP HISTOGRAM ON fullColumnName (',' fullColumnName)*)? ; checkTable @@ -1783,33 +1712,37 @@ checkTable ; checksumTable - : CHECKSUM TABLE tables actionOption=(QUICK | EXTENDED)? + : CHECKSUM TABLE tables actionOption = (QUICK | EXTENDED)? ; optimizeTable - : OPTIMIZE actionOption=(NO_WRITE_TO_BINLOG | LOCAL)? - (TABLE | TABLES) tables + : OPTIMIZE actionOption = (NO_WRITE_TO_BINLOG | LOCAL)? (TABLE | TABLES) tables ; repairTable - : REPAIR actionOption=(NO_WRITE_TO_BINLOG | LOCAL)? - TABLE tables - QUICK? EXTENDED? USE_FRM? + : REPAIR actionOption = (NO_WRITE_TO_BINLOG | LOCAL)? TABLE tables QUICK? EXTENDED? USE_FRM? ; // details checkTableOption - : FOR UPGRADE | QUICK | FAST | MEDIUM | EXTENDED | CHANGED + : FOR UPGRADE + | QUICK + | FAST + | MEDIUM + | EXTENDED + | CHANGED ; - // Plugin and udf statements createUdfunction - : CREATE AGGREGATE? FUNCTION ifNotExists? uid - RETURNS returnType=(STRING | INTEGER | REAL | DECIMAL) - SONAME STRING_LITERAL + : CREATE AGGREGATE? FUNCTION ifNotExists? uid RETURNS returnType = ( + STRING + | INTEGER + | REAL + | DECIMAL + ) SONAME STRING_LITERAL ; installPlugin @@ -1820,79 +1753,66 @@ uninstallPlugin : UNINSTALL PLUGIN uid ; - // Set and show statements setStatement - : SET variableClause ('=' | ':=') (expression | ON) - (',' variableClause ('=' | ':=') (expression | ON))* #setVariable - | SET charSet (charsetName | DEFAULT) #setCharset - | SET NAMES - (charsetName (COLLATE collationName)? | DEFAULT) #setNames - | setPasswordStatement #setPassword - | setTransactionStatement #setTransaction - | setAutocommitStatement #setAutocommit - | SET fullId ('=' | ':=') expression - (',' fullId ('=' | ':=') expression)* #setNewValueInsideTrigger + : SET variableClause ('=' | ':=') (expression | ON) ( + ',' variableClause ('=' | ':=') (expression | ON) + )* # setVariable + | SET charSet (charsetName | DEFAULT) # setCharset + | SET NAMES (charsetName (COLLATE collationName)? | DEFAULT) # setNames + | setPasswordStatement # setPassword + | setTransactionStatement # setTransaction + | setAutocommitStatement # setAutocommit + | SET fullId ('=' | ':=') expression (',' fullId ('=' | ':=') expression)* # setNewValueInsideTrigger ; showStatement - : SHOW logFormat=(BINARY | MASTER) LOGS #showMasterLogs - | SHOW logFormat=(BINLOG | RELAYLOG) - EVENTS (IN filename=STRING_LITERAL)? - (FROM fromPosition=decimalLiteral)? - (LIMIT - (offset=decimalLiteral ',')? - rowCount=decimalLiteral - )? #showLogEvents - | SHOW showCommonEntity showFilter? #showObjectFilter - | SHOW FULL? columnsFormat=(COLUMNS | FIELDS) - tableFormat=(FROM | IN) tableName - (schemaFormat=(FROM | IN) uid)? showFilter? #showColumns - | SHOW CREATE schemaFormat=(DATABASE | SCHEMA) - ifNotExists? uid #showCreateDb - | SHOW CREATE - namedEntity=( - EVENT | FUNCTION | PROCEDURE - | TABLE | TRIGGER | VIEW - ) - fullId #showCreateFullIdObject - | SHOW CREATE USER userName #showCreateUser - | SHOW ENGINE engineName engineOption=(STATUS | MUTEX) #showEngine - | SHOW showGlobalInfoClause #showGlobalInfo - | SHOW errorFormat=(ERRORS | WARNINGS) - (LIMIT - (offset=decimalLiteral ',')? - rowCount=decimalLiteral - )? #showErrors - | SHOW COUNT '(' '*' ')' errorFormat=(ERRORS | WARNINGS) #showCountErrors - | SHOW showSchemaEntity - (schemaFormat=(FROM | IN) uid)? showFilter? #showSchemaFilter - | SHOW routine=(FUNCTION | PROCEDURE) CODE fullId #showRoutine - | SHOW GRANTS (FOR userName)? #showGrants - | SHOW indexFormat=(INDEX | INDEXES | KEYS) - tableFormat=(FROM | IN) tableName - (schemaFormat=(FROM | IN) uid)? (WHERE expression)? #showIndexes - | SHOW OPEN TABLES ( schemaFormat=(FROM | IN) uid)? - showFilter? #showOpenTables - | SHOW PROFILE showProfileType (',' showProfileType)* - (FOR QUERY queryCount=decimalLiteral)? - (LIMIT - (offset=decimalLiteral ',')? - rowCount=decimalLiteral - ) #showProfile - | SHOW SLAVE STATUS (FOR CHANNEL STRING_LITERAL)? #showSlaveStatus + : SHOW logFormat = (BINARY | MASTER) LOGS # showMasterLogs + | SHOW logFormat = (BINLOG | RELAYLOG) EVENTS (IN filename = STRING_LITERAL)? ( + FROM fromPosition = decimalLiteral + )? (LIMIT (offset = decimalLiteral ',')? rowCount = decimalLiteral)? # showLogEvents + | SHOW showCommonEntity showFilter? # showObjectFilter + | SHOW FULL? columnsFormat = (COLUMNS | FIELDS) tableFormat = (FROM | IN) tableName ( + schemaFormat = (FROM | IN) uid + )? showFilter? # showColumns + | SHOW CREATE schemaFormat = (DATABASE | SCHEMA) ifNotExists? uid # showCreateDb + | SHOW CREATE namedEntity = (EVENT | FUNCTION | PROCEDURE | TABLE | TRIGGER | VIEW) fullId # showCreateFullIdObject + | SHOW CREATE USER userName # showCreateUser + | SHOW ENGINE engineName engineOption = (STATUS | MUTEX) # showEngine + | SHOW showGlobalInfoClause # showGlobalInfo + | SHOW errorFormat = (ERRORS | WARNINGS) ( + LIMIT (offset = decimalLiteral ',')? rowCount = decimalLiteral + )? # showErrors + | SHOW COUNT '(' '*' ')' errorFormat = (ERRORS | WARNINGS) # showCountErrors + | SHOW showSchemaEntity (schemaFormat = (FROM | IN) uid)? showFilter? # showSchemaFilter + | SHOW routine = (FUNCTION | PROCEDURE) CODE fullId # showRoutine + | SHOW GRANTS (FOR userName)? # showGrants + | SHOW indexFormat = (INDEX | INDEXES | KEYS) tableFormat = (FROM | IN) tableName ( + schemaFormat = (FROM | IN) uid + )? (WHERE expression)? # showIndexes + | SHOW OPEN TABLES (schemaFormat = (FROM | IN) uid)? showFilter? # showOpenTables + | SHOW PROFILE showProfileType (',' showProfileType)* (FOR QUERY queryCount = decimalLiteral)? ( + LIMIT (offset = decimalLiteral ',')? rowCount = decimalLiteral + ) # showProfile + | SHOW SLAVE STATUS (FOR CHANNEL STRING_LITERAL)? # showSlaveStatus ; // details variableClause - : LOCAL_ID | GLOBAL_ID | ( ('@' '@')? (GLOBAL | SESSION | LOCAL) )? uid + : LOCAL_ID + | GLOBAL_ID + | ( ('@' '@')? (GLOBAL | SESSION | LOCAL))? uid ; showCommonEntity - : CHARACTER SET | COLLATION | DATABASES | SCHEMAS - | FUNCTION STATUS | PROCEDURE STATUS + : CHARACTER SET + | COLLATION + | DATABASES + | SCHEMAS + | FUNCTION STATUS + | PROCEDURE STATUS | (GLOBAL | SESSION)? (STATUS | VARIABLES) ; @@ -1902,21 +1822,36 @@ showFilter ; showGlobalInfoClause - : STORAGE? ENGINES | MASTER STATUS | PLUGINS - | PRIVILEGES | FULL? PROCESSLIST | PROFILES - | SLAVE HOSTS | AUTHORS | CONTRIBUTORS + : STORAGE? ENGINES + | MASTER STATUS + | PLUGINS + | PRIVILEGES + | FULL? PROCESSLIST + | PROFILES + | SLAVE HOSTS + | AUTHORS + | CONTRIBUTORS ; showSchemaEntity - : EVENTS | TABLE STATUS | FULL? TABLES | TRIGGERS + : EVENTS + | TABLE STATUS + | FULL? TABLES + | TRIGGERS ; showProfileType - : ALL | BLOCK IO | CONTEXT SWITCHES | CPU | IPC | MEMORY - | PAGE FAULTS | SOURCE | SWAPS + : ALL + | BLOCK IO + | CONTEXT SWITCHES + | CPU + | IPC + | MEMORY + | PAGE FAULTS + | SOURCE + | SWAPS ; - // Other administrative statements binlogStatement @@ -1924,23 +1859,19 @@ binlogStatement ; cacheIndexStatement - : CACHE INDEX tableIndexes (',' tableIndexes)* - ( PARTITION '(' (uidList | ALL) ')' )? - IN schema=uid + : CACHE INDEX tableIndexes (',' tableIndexes)* (PARTITION '(' (uidList | ALL) ')')? IN schema = uid ; flushStatement - : FLUSH flushFormat=(NO_WRITE_TO_BINLOG | LOCAL)? - flushOption (',' flushOption)* + : FLUSH flushFormat = (NO_WRITE_TO_BINLOG | LOCAL)? flushOption (',' flushOption)* ; killStatement - : KILL connectionFormat=(CONNECTION | QUERY)? expression + : KILL connectionFormat = (CONNECTION | QUERY)? expression ; loadIndexIntoCache - : LOAD INDEX INTO CACHE - loadedTableIndexes (',' loadedTableIndexes)* + : LOAD INDEX INTO CACHE loadedTableIndexes (',' loadedTableIndexes)* ; // remark reset (maser | slave) describe in replication's @@ -1956,20 +1887,23 @@ shutdownStatement // details tableIndexes - : tableName ( indexFormat=(INDEX | KEY)? '(' uidList ')' )? + : tableName (indexFormat = (INDEX | KEY)? '(' uidList ')')? ; flushOption : ( - DES_KEY_FILE | HOSTS - | ( - BINARY | ENGINE | ERROR | GENERAL | RELAY | SLOW - )? LOGS - | OPTIMIZER_COSTS | PRIVILEGES | QUERY CACHE | STATUS - | USER_RESOURCES | TABLES (WITH READ LOCK)? - ) #simpleFlushOption - | RELAY LOGS channelOption? #channelFlushOption - | (TABLE | TABLES) tables? flushTableOption? #tableFlushOption + DES_KEY_FILE + | HOSTS + | ( BINARY | ENGINE | ERROR | GENERAL | RELAY | SLOW)? LOGS + | OPTIMIZER_COSTS + | PRIVILEGES + | QUERY CACHE + | STATUS + | USER_RESOURCES + | TABLES (WITH READ LOCK)? + ) # simpleFlushOption + | RELAY LOGS channelOption? # channelFlushOption + | (TABLE | TABLES) tables? flushTableOption? # tableFlushOption ; flushTableOption @@ -1978,29 +1912,21 @@ flushTableOption ; loadedTableIndexes - : tableName - ( PARTITION '(' (partitionList=uidList | ALL) ')' )? - ( indexFormat=(INDEX | KEY)? '(' indexList=uidList ')' )? - (IGNORE LEAVES)? + : tableName (PARTITION '(' (partitionList = uidList | ALL) ')')? ( + indexFormat = (INDEX | KEY)? '(' indexList = uidList ')' + )? (IGNORE LEAVES)? ; - // Utility Statements - simpleDescribeStatement - : command=(EXPLAIN | DESCRIBE | DESC) tableName - (column=uid | pattern=STRING_LITERAL)? + : command = (EXPLAIN | DESCRIBE | DESC) tableName (column = uid | pattern = STRING_LITERAL)? ; fullDescribeStatement - : command=(EXPLAIN | DESCRIBE | DESC) - ( - formatType=(EXTENDED | PARTITIONS | FORMAT ) - '=' - formatValue=(TRADITIONAL | JSON) - )? - describeObjectClause + : command = (EXPLAIN | DESCRIBE | DESC) ( + formatType = (EXTENDED | PARTITIONS | FORMAT) '=' formatValue = (TRADITIONAL | JSON) + )? describeObjectClause ; helpStatement @@ -2012,44 +1938,51 @@ useStatement ; signalStatement - : SIGNAL ( ( SQLSTATE VALUE? stringLiteral ) | ID | REVERSE_QUOTE_ID ) - ( SET signalConditionInformation ( ',' signalConditionInformation)* )? + : SIGNAL (( SQLSTATE VALUE? stringLiteral) | ID | REVERSE_QUOTE_ID) ( + SET signalConditionInformation ( ',' signalConditionInformation)* + )? ; resignalStatement - : RESIGNAL ( ( SQLSTATE VALUE? stringLiteral ) | ID | REVERSE_QUOTE_ID )? - ( SET signalConditionInformation ( ',' signalConditionInformation)* )? + : RESIGNAL (( SQLSTATE VALUE? stringLiteral) | ID | REVERSE_QUOTE_ID)? ( + SET signalConditionInformation ( ',' signalConditionInformation)* + )? ; signalConditionInformation - : ( CLASS_ORIGIN - | SUBCLASS_ORIGIN - | MESSAGE_TEXT - | MYSQL_ERRNO - | CONSTRAINT_CATALOG - | CONSTRAINT_SCHEMA - | CONSTRAINT_NAME - | CATALOG_NAME - | SCHEMA_NAME - | TABLE_NAME - | COLUMN_NAME - | CURSOR_NAME - ) '=' ( stringLiteral | DECIMAL_LITERAL | mysqlVariable | simpleId ) + : ( + CLASS_ORIGIN + | SUBCLASS_ORIGIN + | MESSAGE_TEXT + | MYSQL_ERRNO + | CONSTRAINT_CATALOG + | CONSTRAINT_SCHEMA + | CONSTRAINT_NAME + | CATALOG_NAME + | SCHEMA_NAME + | TABLE_NAME + | COLUMN_NAME + | CURSOR_NAME + ) '=' (stringLiteral | DECIMAL_LITERAL | mysqlVariable | simpleId) ; withStatement - : WITH RECURSIVE? commonTableExpressions (',' commonTableExpressions)* - ; + : WITH RECURSIVE? commonTableExpressions (',' commonTableExpressions)* + ; tableStatement - : TABLE tableName orderByClause? limitClause? - ; + : TABLE tableName orderByClause? limitClause? + ; diagnosticsStatement - : GET ( CURRENT | STACKED )? DIAGNOSTICS ( - ( variableClause '=' ( NUMBER | ROW_COUNT ) ( ',' variableClause '=' ( NUMBER | ROW_COUNT ) )* ) - | ( CONDITION ( decimalLiteral | variableClause ) variableClause '=' diagnosticsConditionInformationName ( ',' variableClause '=' diagnosticsConditionInformationName )* ) - ) + : GET (CURRENT | STACKED)? DIAGNOSTICS ( + (variableClause '=' ( NUMBER | ROW_COUNT) ( ',' variableClause '=' ( NUMBER | ROW_COUNT))*) + | ( + CONDITION (decimalLiteral | variableClause) variableClause '=' diagnosticsConditionInformationName ( + ',' variableClause '=' diagnosticsConditionInformationName + )* + ) + ) ; diagnosticsConditionInformationName @@ -2071,14 +2004,10 @@ diagnosticsConditionInformationName // details describeObjectClause - : ( - selectStatement | deleteStatement | insertStatement - | replaceStatement | updateStatement - ) #describeStatements - | FOR CONNECTION uid #describeConnection + : (selectStatement | deleteStatement | insertStatement | replaceStatement | updateStatement) # describeStatements + | FOR CONNECTION uid # describeConnection ; - // Common Clauses // DB Objects @@ -2092,28 +2021,35 @@ tableName ; roleName - : userName | uid + : userName + | uid ; fullColumnName - : uid (dottedId dottedId? )? + : uid (dottedId dottedId?)? | .? dottedId dottedId? ; indexColumnName - : ((uid | STRING_LITERAL) ('(' decimalLiteral ')')? | expression) sortType=(ASC | DESC)? + : ((uid | STRING_LITERAL) ('(' decimalLiteral ')')? | expression) sortType = (ASC | DESC)? ; simpleUserName : STRING_LITERAL | ID | ADMIN - | keywordsCanBeId; -hostName: (LOCAL_ID | HOST_IP_ADDRESS | '@' ); - userName + | keywordsCanBeId + ; + +hostName + : (LOCAL_ID | HOST_IP_ADDRESS | '@') + ; + +userName : simpleUserName | simpleUserName hostName - | currentUserExpression; + | currentUserExpression + ; mysqlVariable : LOCAL_ID @@ -2128,7 +2064,9 @@ charsetName ; collationName - : uid | STRING_LITERAL; + : uid + | STRING_LITERAL + ; engineName : engineNameBase @@ -2137,22 +2075,29 @@ engineName ; engineNameBase - : ARCHIVE | BLACKHOLE | CONNECT | CSV | FEDERATED | INNODB | MEMORY - | MRG_MYISAM | MYISAM | NDB | NDBCLUSTER | PERFORMANCE_SCHEMA | TOKUDB + : ARCHIVE + | BLACKHOLE + | CONNECT + | CSV + | FEDERATED + | INNODB + | MEMORY + | MRG_MYISAM + | MYISAM + | NDB + | NDBCLUSTER + | PERFORMANCE_SCHEMA + | TOKUDB ; uuidSet - : decimalLiteral '-' decimalLiteral '-' decimalLiteral - '-' decimalLiteral '-' decimalLiteral - (':' decimalLiteral '-' decimalLiteral)+ + : decimalLiteral '-' decimalLiteral '-' decimalLiteral '-' decimalLiteral '-' decimalLiteral ( + ':' decimalLiteral '-' decimalLiteral + )+ ; xid - : globalTableUid=xuidStringId - ( - ',' qualifier=xuidStringId - (',' idFormat=decimalLiteral)? - )? + : globalTableUid = xuidStringId (',' qualifier = xuidStringId (',' idFormat = decimalLiteral)?)? ; xuidStringId @@ -2162,7 +2107,8 @@ xuidStringId ; authPlugin - : uid | STRING_LITERAL + : uid + | STRING_LITERAL ; uid @@ -2190,95 +2136,106 @@ dottedId | '.' uid ; - // Literals decimalLiteral - : DECIMAL_LITERAL | ZERO_DECIMAL | ONE_DECIMAL | TWO_DECIMAL | REAL_LITERAL + : DECIMAL_LITERAL + | ZERO_DECIMAL + | ONE_DECIMAL + | TWO_DECIMAL + | REAL_LITERAL ; fileSizeLiteral - : FILESIZE_LITERAL | decimalLiteral; + : FILESIZE_LITERAL + | decimalLiteral + ; stringLiteral - : ( - STRING_CHARSET_NAME? STRING_LITERAL - | START_NATIONAL_STRING_LITERAL - ) STRING_LITERAL+ - | ( - STRING_CHARSET_NAME? STRING_LITERAL - | START_NATIONAL_STRING_LITERAL - ) (COLLATE collationName)? + : (STRING_CHARSET_NAME? STRING_LITERAL | START_NATIONAL_STRING_LITERAL) STRING_LITERAL+ + | (STRING_CHARSET_NAME? STRING_LITERAL | START_NATIONAL_STRING_LITERAL) (COLLATE collationName)? ; booleanLiteral - : TRUE | FALSE; + : TRUE + | FALSE + ; hexadecimalLiteral - : STRING_CHARSET_NAME? HEXADECIMAL_LITERAL; + : STRING_CHARSET_NAME? HEXADECIMAL_LITERAL + ; nullNotnull : NOT? (NULL_LITERAL | NULL_SPEC_LITERAL) ; constant - : stringLiteral | decimalLiteral + : stringLiteral + | decimalLiteral | '-' decimalLiteral - | hexadecimalLiteral | booleanLiteral - | REAL_LITERAL | BIT_STRING - | NOT? nullLiteral=(NULL_LITERAL | NULL_SPEC_LITERAL) + | hexadecimalLiteral + | booleanLiteral + | REAL_LITERAL + | BIT_STRING + | NOT? nullLiteral = (NULL_LITERAL | NULL_SPEC_LITERAL) ; - // Data Types dataType - : typeName=( - CHAR | CHARACTER | VARCHAR | TINYTEXT | TEXT | MEDIUMTEXT | LONGTEXT - | NCHAR | NVARCHAR | LONG - ) - VARYING? - lengthOneDimension? BINARY? - (charSet charsetName)? - (COLLATE collationName | BINARY)? #stringDataType - | NATIONAL typeName=(CHAR | CHARACTER) VARYING - lengthOneDimension? BINARY? #nationalVaryingStringDataType - | NATIONAL typeName=(VARCHAR | CHARACTER | CHAR) - lengthOneDimension? BINARY? #nationalStringDataType - | NCHAR typeName=VARCHAR - lengthOneDimension? BINARY? #nationalStringDataType - | typeName=( - TINYINT | SMALLINT | MEDIUMINT | INT | INTEGER | BIGINT - | MIDDLEINT | INT1 | INT2 | INT3 | INT4 | INT8 - ) - lengthOneDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=REAL - lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=DOUBLE PRECISION? - lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=(DECIMAL | DEC | FIXED | NUMERIC | FLOAT | FLOAT4 | FLOAT8) - lengthTwoOptionalDimension? (SIGNED | UNSIGNED | ZEROFILL)* #dimensionDataType - | typeName=( - DATE | TINYBLOB | MEDIUMBLOB | LONGBLOB - | BOOL | BOOLEAN | SERIAL - ) #simpleDataType - | typeName=( - BIT | TIME | TIMESTAMP | DATETIME | BINARY - | VARBINARY | BLOB | YEAR - ) - lengthOneDimension? #dimensionDataType - | typeName=(ENUM | SET) - collectionOptions BINARY? - (charSet charsetName)? #collectionDataType - | typeName=( - GEOMETRYCOLLECTION | GEOMCOLLECTION | LINESTRING | MULTILINESTRING - | MULTIPOINT | MULTIPOLYGON | POINT | POLYGON | JSON | GEOMETRY - ) (SRID decimalLiteral)? #spatialDataType - | typeName=LONG VARCHAR? - BINARY? - (charSet charsetName)? - (COLLATE collationName)? #longVarcharDataType // LONG VARCHAR is the same as LONG - | LONG VARBINARY #longVarbinaryDataType + : typeName = ( + CHAR + | CHARACTER + | VARCHAR + | TINYTEXT + | TEXT + | MEDIUMTEXT + | LONGTEXT + | NCHAR + | NVARCHAR + | LONG + ) VARYING? lengthOneDimension? BINARY? (charSet charsetName)? (COLLATE collationName | BINARY)? # stringDataType + | NATIONAL typeName = (CHAR | CHARACTER) VARYING lengthOneDimension? BINARY? # nationalVaryingStringDataType + | NATIONAL typeName = (VARCHAR | CHARACTER | CHAR) lengthOneDimension? BINARY? # nationalStringDataType + | NCHAR typeName = VARCHAR lengthOneDimension? BINARY? # nationalStringDataType + | typeName = ( + TINYINT + | SMALLINT + | MEDIUMINT + | INT + | INTEGER + | BIGINT + | MIDDLEINT + | INT1 + | INT2 + | INT3 + | INT4 + | INT8 + ) lengthOneDimension? (SIGNED | UNSIGNED | ZEROFILL)* # dimensionDataType + | typeName = REAL lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* # dimensionDataType + | typeName = DOUBLE PRECISION? lengthTwoDimension? (SIGNED | UNSIGNED | ZEROFILL)* # dimensionDataType + | typeName = (DECIMAL | DEC | FIXED | NUMERIC | FLOAT | FLOAT4 | FLOAT8) lengthTwoOptionalDimension? ( + SIGNED + | UNSIGNED + | ZEROFILL + )* # dimensionDataType + | typeName = (DATE | TINYBLOB | MEDIUMBLOB | LONGBLOB | BOOL | BOOLEAN | SERIAL) # simpleDataType + | typeName = (BIT | TIME | TIMESTAMP | DATETIME | BINARY | VARBINARY | BLOB | YEAR) lengthOneDimension? # dimensionDataType + | typeName = (ENUM | SET) collectionOptions BINARY? (charSet charsetName)? # collectionDataType + | typeName = ( + GEOMETRYCOLLECTION + | GEOMCOLLECTION + | LINESTRING + | MULTILINESTRING + | MULTIPOINT + | MULTIPOLYGON + | POINT + | POLYGON + | JSON + | GEOMETRY + ) (SRID decimalLiteral)? # spatialDataType + | typeName = LONG VARCHAR? BINARY? (charSet charsetName)? (COLLATE collationName)? # longVarcharDataType // LONG VARCHAR is the same as LONG + | LONG VARBINARY # longVarbinaryDataType ; collectionOptions @@ -2286,13 +2243,12 @@ collectionOptions ; convertedDataType - : - ( - typeName=(BINARY | NCHAR | FLOAT) lengthOneDimension? - | typeName=CHAR lengthOneDimension? (charSet charsetName)? - | typeName=(DATE | DATETIME | TIME | YEAR | JSON | INT | INTEGER | DOUBLE) - | typeName=(DECIMAL | DEC) lengthTwoOptionalDimension? - | (SIGNED | UNSIGNED) (INTEGER | INT)? + : ( + typeName = (BINARY | NCHAR | FLOAT) lengthOneDimension? + | typeName = CHAR lengthOneDimension? (charSet charsetName)? + | typeName = (DATE | DATETIME | TIME | YEAR | JSON | INT | INTEGER | DOUBLE) + | typeName = (DECIMAL | DEC) lengthTwoOptionalDimension? + | (SIGNED | UNSIGNED) (INTEGER | INT)? ) ARRAY? ; @@ -2308,7 +2264,6 @@ lengthTwoOptionalDimension : '(' decimalLiteral (',' decimalLiteral)? ')' ; - // Common Lists uidList @@ -2347,7 +2302,6 @@ userVariables : LOCAL_ID (',' LOCAL_ID)* ; - // Common Expressons defaultValue @@ -2360,23 +2314,21 @@ defaultValue ; currentTimestamp - : - ( - (CURRENT_TIMESTAMP | LOCALTIME | LOCALTIMESTAMP) - ('(' decimalLiteral? ')')? - | NOW '(' decimalLiteral? ')' + : ( + (CURRENT_TIMESTAMP | LOCALTIME | LOCALTIMESTAMP) ('(' decimalLiteral? ')')? + | NOW '(' decimalLiteral? ')' ) ; expressionOrDefault - : expression | DEFAULT + : expression + | DEFAULT ; ifExists : IF EXISTS ; - ifNotExists : IF NOT EXISTS ; @@ -2393,149 +2345,91 @@ waitNowaitClause // Functions functionCall - : specificFunction #specificFunctionCall - | aggregateWindowedFunction #aggregateFunctionCall - | nonAggregateWindowedFunction #nonAggregateFunctionCall - | scalarFunctionName '(' functionArgs? ')' #scalarFunctionCall - | fullId '(' functionArgs? ')' #udfFunctionCall - | passwordFunctionClause #passwordFunctionCall + : specificFunction # specificFunctionCall + | aggregateWindowedFunction # aggregateFunctionCall + | nonAggregateWindowedFunction # nonAggregateFunctionCall + | scalarFunctionName '(' functionArgs? ')' # scalarFunctionCall + | fullId '(' functionArgs? ')' # udfFunctionCall + | passwordFunctionClause # passwordFunctionCall ; specificFunction - : ( - CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP - | LOCALTIME | UTC_TIMESTAMP | SCHEMA - ) ('(' ')')? #simpleFunctionCall - | currentUserExpression #currentUser - | CONVERT '(' expression separator=',' convertedDataType ')' #dataTypeFunctionCall - | CONVERT '(' expression USING charsetName ')' #dataTypeFunctionCall - | CAST '(' expression AS convertedDataType ')' #dataTypeFunctionCall - | VALUES '(' fullColumnName ')' #valuesFunctionCall - | CASE expression caseFuncAlternative+ - (ELSE elseArg=functionArg)? END #caseExpressionFunctionCall - | CASE caseFuncAlternative+ - (ELSE elseArg=functionArg)? END #caseFunctionCall - | CHAR '(' functionArgs (USING charsetName)? ')' #charFunctionCall - | POSITION - '(' - ( - positionString=stringLiteral - | positionExpression=expression - ) - IN - ( - inString=stringLiteral - | inExpression=expression - ) - ')' #positionFunctionCall - | (SUBSTR | SUBSTRING) - '(' - ( - sourceString=stringLiteral - | sourceExpression=expression - ) FROM - ( - fromDecimal=decimalLiteral - | fromExpression=expression - ) - ( - FOR - ( - forDecimal=decimalLiteral - | forExpression=expression - ) - )? - ')' #substrFunctionCall - | TRIM - '(' - positioinForm=(BOTH | LEADING | TRAILING) - ( - sourceString=stringLiteral - | sourceExpression=expression - )? - FROM - ( - fromString=stringLiteral - | fromExpression=expression - ) - ')' #trimFunctionCall - | TRIM - '(' - ( - sourceString=stringLiteral - | sourceExpression=expression - ) - FROM - ( - fromString=stringLiteral - | fromExpression=expression - ) - ')' #trimFunctionCall - | WEIGHT_STRING - '(' - (stringLiteral | expression) - (AS stringFormat=(CHAR | BINARY) - '(' decimalLiteral ')' )? levelsInWeightString? - ')' #weightFunctionCall - | EXTRACT - '(' - intervalType - FROM - ( - sourceString=stringLiteral - | sourceExpression=expression - ) - ')' #extractFunctionCall - | GET_FORMAT - '(' - datetimeFormat=(DATE | TIME | DATETIME) - ',' stringLiteral - ')' #getFormatFunctionCall - | JSON_VALUE - '(' expression - ',' expression - (RETURNING convertedDataType)? - jsonOnEmpty? - jsonOnError? - ')' #jsonValueFunctionCall + : (CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | LOCALTIME | UTC_TIMESTAMP | SCHEMA) ( + '(' ')' + )? # simpleFunctionCall + | currentUserExpression # currentUser + | CONVERT '(' expression separator = ',' convertedDataType ')' # dataTypeFunctionCall + | CONVERT '(' expression USING charsetName ')' # dataTypeFunctionCall + | CAST '(' expression AS convertedDataType ')' # dataTypeFunctionCall + | VALUES '(' fullColumnName ')' # valuesFunctionCall + | CASE expression caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseExpressionFunctionCall + | CASE caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseFunctionCall + | CHAR '(' functionArgs (USING charsetName)? ')' # charFunctionCall + | POSITION '(' (positionString = stringLiteral | positionExpression = expression) IN ( + inString = stringLiteral + | inExpression = expression + ) ')' # positionFunctionCall + | (SUBSTR | SUBSTRING) '(' (sourceString = stringLiteral | sourceExpression = expression) FROM ( + fromDecimal = decimalLiteral + | fromExpression = expression + ) (FOR ( forDecimal = decimalLiteral | forExpression = expression))? ')' # substrFunctionCall + | TRIM '(' positioinForm = (BOTH | LEADING | TRAILING) ( + sourceString = stringLiteral + | sourceExpression = expression + )? FROM (fromString = stringLiteral | fromExpression = expression) ')' # trimFunctionCall + | TRIM '(' (sourceString = stringLiteral | sourceExpression = expression) FROM ( + fromString = stringLiteral + | fromExpression = expression + ) ')' # trimFunctionCall + | WEIGHT_STRING '(' (stringLiteral | expression) ( + AS stringFormat = (CHAR | BINARY) '(' decimalLiteral ')' + )? levelsInWeightString? ')' # weightFunctionCall + | EXTRACT '(' intervalType FROM (sourceString = stringLiteral | sourceExpression = expression) ')' # extractFunctionCall + | GET_FORMAT '(' datetimeFormat = (DATE | TIME | DATETIME) ',' stringLiteral ')' # getFormatFunctionCall + | JSON_VALUE '(' expression ',' expression (RETURNING convertedDataType)? jsonOnEmpty? jsonOnError? ')' # jsonValueFunctionCall ; caseFuncAlternative - : WHEN condition=functionArg - THEN consequent=functionArg + : WHEN condition = functionArg THEN consequent = functionArg ; levelsInWeightString - : LEVEL levelInWeightListElement - (',' levelInWeightListElement)* #levelWeightList - | LEVEL - firstLevel=decimalLiteral '-' lastLevel=decimalLiteral #levelWeightRange + : LEVEL levelInWeightListElement (',' levelInWeightListElement)* # levelWeightList + | LEVEL firstLevel = decimalLiteral '-' lastLevel = decimalLiteral # levelWeightRange ; levelInWeightListElement - : decimalLiteral orderType=(ASC | DESC | REVERSE)? + : decimalLiteral orderType = (ASC | DESC | REVERSE)? ; aggregateWindowedFunction - : (AVG | MAX | MIN | SUM) - '(' aggregator=(ALL | DISTINCT)? functionArg ')' overClause? - | COUNT '(' (starArg='*' | aggregator=ALL? functionArg | aggregator=DISTINCT functionArgs) ')' overClause? + : (AVG | MAX | MIN | SUM) '(' aggregator = (ALL | DISTINCT)? functionArg ')' overClause? + | COUNT '(' ( + starArg = '*' + | aggregator = ALL? functionArg + | aggregator = DISTINCT functionArgs + ) ')' overClause? | ( - BIT_AND | BIT_OR | BIT_XOR | STD | STDDEV | STDDEV_POP - | STDDEV_SAMP | VAR_POP | VAR_SAMP | VARIANCE - ) '(' aggregator=ALL? functionArg ')' overClause? - | GROUP_CONCAT '(' - aggregator=DISTINCT? functionArgs - (ORDER BY - orderByExpression (',' orderByExpression)* - )? (SEPARATOR separator=STRING_LITERAL)? - ')' + BIT_AND + | BIT_OR + | BIT_XOR + | STD + | STDDEV + | STDDEV_POP + | STDDEV_SAMP + | VAR_POP + | VAR_SAMP + | VARIANCE + ) '(' aggregator = ALL? functionArg ')' overClause? + | GROUP_CONCAT '(' aggregator = DISTINCT? functionArgs ( + ORDER BY orderByExpression (',' orderByExpression)* + )? (SEPARATOR separator = STRING_LITERAL)? ')' ; nonAggregateWindowedFunction : (LAG | LEAD) '(' expression (',' decimalLiteral)? (',' decimalLiteral)? ')' overClause | (FIRST_VALUE | LAST_VALUE) '(' expression ')' overClause - | (CUME_DIST | DENSE_RANK | PERCENT_RANK | RANK | ROW_NUMBER) '('')' overClause + | (CUME_DIST | DENSE_RANK | PERCENT_RANK | RANK | ROW_NUMBER) '(' ')' overClause | NTH_VALUE '(' expression ',' decimalLiteral ')' overClause | NTILE '(' decimalLiteral ')' overClause ; @@ -2582,290 +2476,1014 @@ partitionClause scalarFunctionName : functionNameBase - | ASCII | CURDATE | CURRENT_DATE | CURRENT_TIME - | CURRENT_TIMESTAMP | CURTIME | DATE_ADD | DATE_SUB - | IF | INSERT | LOCALTIME | LOCALTIMESTAMP | MID | NOW - | REPEAT | REPLACE | SUBSTR | SUBSTRING | SYSDATE | TRIM - | UTC_DATE | UTC_TIME | UTC_TIMESTAMP + | ASCII + | CURDATE + | CURRENT_DATE + | CURRENT_TIME + | CURRENT_TIMESTAMP + | CURTIME + | DATE_ADD + | DATE_SUB + | IF + | INSERT + | LOCALTIME + | LOCALTIMESTAMP + | MID + | NOW + | REPEAT + | REPLACE + | SUBSTR + | SUBSTRING + | SYSDATE + | TRIM + | UTC_DATE + | UTC_TIME + | UTC_TIMESTAMP ; passwordFunctionClause - : functionName=(PASSWORD | OLD_PASSWORD) '(' functionArg ')' + : functionName = (PASSWORD | OLD_PASSWORD) '(' functionArg ')' ; functionArgs - : (constant | fullColumnName | functionCall | expression) - ( - ',' - (constant | fullColumnName | functionCall | expression) + : (constant | fullColumnName | functionCall | expression) ( + ',' (constant | fullColumnName | functionCall | expression) )* ; functionArg - : constant | fullColumnName | functionCall | expression + : constant + | fullColumnName + | functionCall + | expression ; - // Expressions, predicates // Simplified approach for expression expression - : notOperator=(NOT | '!') expression #notExpression - | expression logicalOperator expression #logicalExpression - | predicate IS NOT? testValue=(TRUE | FALSE | UNKNOWN) #isExpression - | predicate #predicateExpression + : notOperator = (NOT | '!') expression # notExpression + | expression logicalOperator expression # logicalExpression + | predicate IS NOT? testValue = (TRUE | FALSE | UNKNOWN) # isExpression + | predicate # predicateExpression ; predicate - : predicate NOT? IN '(' (selectStatement | expressions) ')' #inPredicate - | predicate IS nullNotnull #isNullPredicate - | left=predicate comparisonOperator right=predicate #binaryComparisonPredicate - | predicate comparisonOperator - quantifier=(ALL | ANY | SOME) '(' selectStatement ')' #subqueryComparisonPredicate - | predicate NOT? BETWEEN predicate AND predicate #betweenPredicate - | predicate SOUNDS LIKE predicate #soundsLikePredicate - | predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)? #likePredicate - | predicate NOT? regex=(REGEXP | RLIKE) predicate #regexpPredicate - | predicate MEMBER OF '(' predicate ')' #jsonMemberOfPredicate - | expressionAtom #expressionAtomPredicate + : predicate NOT? IN '(' (selectStatement | expressions) ')' # inPredicate + | predicate IS nullNotnull # isNullPredicate + | left = predicate comparisonOperator right = predicate # binaryComparisonPredicate + | predicate comparisonOperator quantifier = (ALL | ANY | SOME) '(' selectStatement ')' # subqueryComparisonPredicate + | predicate NOT? BETWEEN predicate AND predicate # betweenPredicate + | predicate SOUNDS LIKE predicate # soundsLikePredicate + | predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)? # likePredicate + | predicate NOT? regex = (REGEXP | RLIKE) predicate # regexpPredicate + | predicate MEMBER OF '(' predicate ')' # jsonMemberOfPredicate + | expressionAtom # expressionAtomPredicate ; - // Add in ASTVisitor nullNotnull in constant expressionAtom - : constant #constantExpressionAtom - | fullColumnName #fullColumnNameExpressionAtom - | functionCall #functionCallExpressionAtom - | expressionAtom COLLATE collationName #collateExpressionAtom - | mysqlVariable #mysqlVariableExpressionAtom - | unaryOperator expressionAtom #unaryExpressionAtom - | BINARY expressionAtom #binaryExpressionAtom - | LOCAL_ID VAR_ASSIGN expressionAtom #variableAssignExpressionAtom - | '(' expression (',' expression)* ')' #nestedExpressionAtom - | ROW '(' expression (',' expression)+ ')' #nestedRowExpressionAtom - | EXISTS '(' selectStatement ')' #existsExpressionAtom - | '(' selectStatement ')' #subqueryExpressionAtom - | INTERVAL expression intervalType #intervalExpressionAtom - | left=expressionAtom bitOperator right=expressionAtom #bitExpressionAtom - | left=expressionAtom multOperator right=expressionAtom #mathExpressionAtom - | left=expressionAtom addOperator right=expressionAtom #mathExpressionAtom - | left=expressionAtom jsonOperator right=expressionAtom #jsonExpressionAtom + : constant # constantExpressionAtom + | fullColumnName # fullColumnNameExpressionAtom + | functionCall # functionCallExpressionAtom + | expressionAtom COLLATE collationName # collateExpressionAtom + | mysqlVariable # mysqlVariableExpressionAtom + | unaryOperator expressionAtom # unaryExpressionAtom + | BINARY expressionAtom # binaryExpressionAtom + | LOCAL_ID VAR_ASSIGN expressionAtom # variableAssignExpressionAtom + | '(' expression (',' expression)* ')' # nestedExpressionAtom + | ROW '(' expression (',' expression)+ ')' # nestedRowExpressionAtom + | EXISTS '(' selectStatement ')' # existsExpressionAtom + | '(' selectStatement ')' # subqueryExpressionAtom + | INTERVAL expression intervalType # intervalExpressionAtom + | left = expressionAtom bitOperator right = expressionAtom # bitExpressionAtom + | left = expressionAtom multOperator right = expressionAtom # mathExpressionAtom + | left = expressionAtom addOperator right = expressionAtom # mathExpressionAtom + | left = expressionAtom jsonOperator right = expressionAtom # jsonExpressionAtom ; unaryOperator - : '!' | '~' | '+' | '-' | NOT + : '!' + | '~' + | '+' + | '-' + | NOT ; comparisonOperator - : '=' | '>' | '<' | '<' '=' | '>' '=' - | '<' '>' | '!' '=' | '<' '=' '>' + : '=' + | '>' + | '<' + | '<' '=' + | '>' '=' + | '<' '>' + | '!' '=' + | '<' '=' '>' ; logicalOperator - : AND | '&' '&' | XOR | OR | '|' '|' + : AND + | '&' '&' + | XOR + | OR + | '|' '|' ; bitOperator - : '<' '<' | '>' '>' | '&' | '^' | '|' + : '<' '<' + | '>' '>' + | '&' + | '^' + | '|' ; multOperator - : '*' | '/' | '%' | DIV | MOD + : '*' + | '/' + | '%' + | DIV + | MOD ; addOperator - : '+' | '-' + : '+' + | '-' ; jsonOperator - : '-' '>' | '-' '>' '>' + : '-' '>' + | '-' '>' '>' ; // Simple id sets // (that keyword, which can be id) charsetNameBase - : ARMSCII8 | ASCII | BIG5 | BINARY | CP1250 | CP1251 | CP1256 | CP1257 - | CP850 | CP852 | CP866 | CP932 | DEC8 | EUCJPMS | EUCKR - | GB18030 | GB2312 | GBK | GEOSTD8 | GREEK | HEBREW | HP8 | KEYBCS2 - | KOI8R | KOI8U | LATIN1 | LATIN2 | LATIN5 | LATIN7 | MACCE - | MACROMAN | SJIS | SWE7 | TIS620 | UCS2 | UJIS | UTF16 - | UTF16LE | UTF32 | UTF8 | UTF8MB3 | UTF8MB4 + : ARMSCII8 + | ASCII + | BIG5 + | BINARY + | CP1250 + | CP1251 + | CP1256 + | CP1257 + | CP850 + | CP852 + | CP866 + | CP932 + | DEC8 + | EUCJPMS + | EUCKR + | GB18030 + | GB2312 + | GBK + | GEOSTD8 + | GREEK + | HEBREW + | HP8 + | KEYBCS2 + | KOI8R + | KOI8U + | LATIN1 + | LATIN2 + | LATIN5 + | LATIN7 + | MACCE + | MACROMAN + | SJIS + | SWE7 + | TIS620 + | UCS2 + | UJIS + | UTF16 + | UTF16LE + | UTF32 + | UTF8 + | UTF8MB3 + | UTF8MB4 ; transactionLevelBase - : REPEATABLE | COMMITTED | UNCOMMITTED | SERIALIZABLE + : REPEATABLE + | COMMITTED + | UNCOMMITTED + | SERIALIZABLE ; privilegesBase - : TABLES | ROUTINE | EXECUTE | FILE | PROCESS - | RELOAD | SHUTDOWN | SUPER | PRIVILEGES + : TABLES + | ROUTINE + | EXECUTE + | FILE + | PROCESS + | RELOAD + | SHUTDOWN + | SUPER + | PRIVILEGES ; intervalTypeBase - : QUARTER | MONTH | DAY | HOUR - | MINUTE | WEEK | SECOND | MICROSECOND + : QUARTER + | MONTH + | DAY + | HOUR + | MINUTE + | WEEK + | SECOND + | MICROSECOND ; dataTypeBase - : DATE | TIME | TIMESTAMP | DATETIME | YEAR | ENUM | TEXT + : DATE + | TIME + | TIMESTAMP + | DATETIME + | YEAR + | ENUM + | TEXT ; keywordsCanBeId - : ACCOUNT | ACTION | ADMIN | AFTER | AGGREGATE | ALGORITHM | ANY | ARRAY - | AT | AUDIT_ADMIN | AUDIT_ABORT_EXEMPT | AUTHORS | AUTOCOMMIT | AUTOEXTEND_SIZE - | AUTO_INCREMENT | AUTHENTICATION_POLICY_ADMIN | AVG | AVG_ROW_LENGTH | ATTRIBUTE - | BACKUP_ADMIN | BEGIN | BINLOG | BINLOG_ADMIN | BINLOG_ENCRYPTION_ADMIN | BIT | BIT_AND | BIT_OR | BIT_XOR - | BLOCK | BOOL | BOOLEAN | BTREE | BUCKETS | CACHE | CASCADED | CHAIN | CHANGED - | CHANNEL | CHECKSUM | PAGE_CHECKSUM | CATALOG_NAME | CIPHER - | CLASS_ORIGIN | CLIENT | CLONE_ADMIN | CLOSE | CLUSTERING | COALESCE | CODE - | COLUMNS | COLUMN_FORMAT | COLUMN_NAME | COMMENT | COMMIT | COMPACT - | COMPLETION | COMPRESSED | COMPRESSION | CONCURRENT | CONDITION | CONNECT - | CONNECTION | CONNECTION_ADMIN | CONSISTENT | CONSTRAINT_CATALOG | CONSTRAINT_NAME - | CONSTRAINT_SCHEMA | CONTAINS | CONTEXT - | CONTRIBUTORS | COPY | COUNT | CPU | CURRENT | CURRENT_USER | CURSOR_NAME - | DATA | DATAFILE | DEALLOCATE - | DEFAULT | DEFAULT_AUTH | DEFINER | DELAY_KEY_WRITE | DES_KEY_FILE | DIAGNOSTICS | DIRECTORY - | DISABLE | DISCARD | DISK | DO | DUMPFILE | DUPLICATE - | DYNAMIC | EMPTY | ENABLE | ENCRYPTION | ENCRYPTION_KEY_ADMIN | END | ENDS | ENGINE | ENGINE_ATTRIBUTE | ENGINES | ENFORCED - | ERROR | ERRORS | ESCAPE | EUR | EVEN | EVENT | EVENTS | EVERY | EXCEPT - | EXCHANGE | EXCLUSIVE | EXPIRE | EXPORT | EXTENDED | EXTENT_SIZE | FAILED_LOGIN_ATTEMPTS | FAST | FAULTS - | FIELDS | FILE_BLOCK_SIZE | FILTER | FIREWALL_ADMIN | FIREWALL_EXEMPT | FIREWALL_USER | FIRST | FIXED | FLUSH - | FOLLOWS | FOUND | FULL | FUNCTION | GENERAL | GLOBAL | GRANTS | GROUP | GROUP_CONCAT - | GROUP_REPLICATION | GROUP_REPLICATION_ADMIN | HANDLER | HASH | HELP | HISTORY | HOST | HOSTS | IDENTIFIED - | IGNORED | IGNORE_SERVER_IDS | IMPORT | INDEXES | INITIAL_SIZE | INNODB_REDO_LOG_ARCHIVE - | INPLACE | INSERT_METHOD | INSTALL | INSTANCE | INSTANT | INTERNAL | INVOKE | INVOKER | IO - | IO_THREAD | IPC | ISO | ISOLATION | ISSUER | JIS | JSON | KEY_BLOCK_SIZE - | LAMBDA | LANGUAGE | LAST | LATERAL | LEAVES | LESS | LEVEL | LIST | LOCAL - | LOGFILE | LOGS | MASTER | MASTER_AUTO_POSITION - | MASTER_CONNECT_RETRY | MASTER_DELAY - | MASTER_HEARTBEAT_PERIOD | MASTER_HOST | MASTER_LOG_FILE - | MASTER_LOG_POS | MASTER_PASSWORD | MASTER_PORT - | MASTER_RETRY_COUNT | MASTER_SSL | MASTER_SSL_CA - | MASTER_SSL_CAPATH | MASTER_SSL_CERT | MASTER_SSL_CIPHER - | MASTER_SSL_CRL | MASTER_SSL_CRLPATH | MASTER_SSL_KEY - | MASTER_TLS_VERSION | MASTER_USER - | MAX_CONNECTIONS_PER_HOUR | MAX_QUERIES_PER_HOUR - | MAX | MAX_ROWS | MAX_SIZE | MAX_UPDATES_PER_HOUR - | MAX_USER_CONNECTIONS | MEDIUM | MEMBER | MEMORY | MERGE | MESSAGE_TEXT - | MID | MIGRATE - | MIN | MIN_ROWS | MODE | MODIFY | MUTEX | MYSQL | MYSQL_ERRNO | NAME | NAMES - | NCHAR | NDB_STORED_USER | NESTED | NEVER | NEXT | NO | NOCOPY | NODEGROUP | NONE | NOWAIT | NUMBER | ODBC | OFFLINE | OFFSET - | OF | OJ | OLD_PASSWORD | ONE | ONLINE | ONLY | OPEN | OPTIMIZER_COSTS - | OPTIONAL | OPTIONS | ORDER | ORDINALITY | OWNER | PACK_KEYS | PAGE | PARSER | PARTIAL - | PARTITIONING | PARTITIONS | PASSWORD | PASSWORDLESS_USER_ADMIN | PASSWORD_LOCK_TIME | PATH | PERSIST_RO_VARIABLES_ADMIN | PHASE | PLUGINS - | PLUGIN_DIR | PLUGIN | PORT | PRECEDES | PREPARE | PRESERVE | PREV | PRIMARY - | PROCESSLIST | PROFILE | PROFILES | PROXY | QUERY | QUICK - | REBUILD | RECOVER | RECURSIVE | REDO_BUFFER_SIZE | REDUNDANT - | RELAY | RELAYLOG | RELAY_LOG_FILE | RELAY_LOG_POS | REMOVE - | REORGANIZE | REPAIR | REPLICATE_DO_DB | REPLICATE_DO_TABLE - | REPLICATE_IGNORE_DB | REPLICATE_IGNORE_TABLE - | REPLICATE_REWRITE_DB | REPLICATE_WILD_DO_TABLE - | REPLICATE_WILD_IGNORE_TABLE | REPLICATION | REPLICATION_APPLIER | REPLICATION_SLAVE_ADMIN | RESET - | RESOURCE_GROUP_ADMIN | RESOURCE_GROUP_USER | RESUME - | RETURNED_SQLSTATE | RETURNS | REUSE | ROLE | ROLE_ADMIN | ROLLBACK | ROLLUP | ROTATE | ROW | ROWS - | ROW_FORMAT | RTREE | S3 | SAVEPOINT | SCHEDULE | SCHEMA_NAME | SECURITY | SECONDARY_ENGINE_ATTRIBUTE | SERIAL | SERVER - | SESSION | SESSION_VARIABLES_ADMIN | SET_USER_ID | SHARE | SHARED | SHOW_ROUTINE | SIGNED | SIMPLE | SLAVE - | SLOW | SKIP_QUERY_REWRITE | SNAPSHOT | SOCKET | SOME | SONAME | SOUNDS | SOURCE - | SQL_AFTER_GTIDS | SQL_AFTER_MTS_GAPS | SQL_BEFORE_GTIDS - | SQL_BUFFER_RESULT | SQL_CACHE | SQL_NO_CACHE | SQL_THREAD - | STACKED | START | STARTS | STATS_AUTO_RECALC | STATS_PERSISTENT - | STATS_SAMPLE_PAGES | STATUS | STD | STDDEV | STDDEV_POP | STDDEV_SAMP | STOP | STORAGE | STRING - | SUBCLASS_ORIGIN | SUBJECT | SUBPARTITION | SUBPARTITIONS | SUM | SUSPEND | SWAPS - | SWITCHES | SYSTEM_VARIABLES_ADMIN | TABLE_NAME | TABLESPACE | TABLE_ENCRYPTION_ADMIN | TABLE_TYPE - | TEMPORARY | TEMPTABLE | THAN | TP_CONNECTION_ADMIN | TRADITIONAL - | TRANSACTION | TRANSACTIONAL | TRIGGERS | TRUNCATE | UNBOUNDED | UNDEFINED | UNDOFILE - | UNDO_BUFFER_SIZE | UNINSTALL | UNKNOWN | UNTIL | UPGRADE | USA | USER | USE_FRM | USER_RESOURCES - | VALIDATION | VALUE | VAR_POP | VAR_SAMP | VARIABLES | VARIANCE | VERSION_TOKEN_ADMIN | VIEW | VIRTUAL - | WAIT | WARNINGS | WITHOUT | WORK | WRAPPER | X509 | XA | XA_RECOVER_ADMIN | XML + : ACCOUNT + | ACTION + | ADMIN + | AFTER + | AGGREGATE + | ALGORITHM + | ANY + | ARRAY + | AT + | AUDIT_ADMIN + | AUDIT_ABORT_EXEMPT + | AUTHORS + | AUTOCOMMIT + | AUTOEXTEND_SIZE + | AUTO_INCREMENT + | AUTHENTICATION_POLICY_ADMIN + | AVG + | AVG_ROW_LENGTH + | ATTRIBUTE + | BACKUP_ADMIN + | BEGIN + | BINLOG + | BINLOG_ADMIN + | BINLOG_ENCRYPTION_ADMIN + | BIT + | BIT_AND + | BIT_OR + | BIT_XOR + | BLOCK + | BOOL + | BOOLEAN + | BTREE + | BUCKETS + | CACHE + | CASCADED + | CHAIN + | CHANGED + | CHANNEL + | CHECKSUM + | PAGE_CHECKSUM + | CATALOG_NAME + | CIPHER + | CLASS_ORIGIN + | CLIENT + | CLONE_ADMIN + | CLOSE + | CLUSTERING + | COALESCE + | CODE + | COLUMNS + | COLUMN_FORMAT + | COLUMN_NAME + | COMMENT + | COMMIT + | COMPACT + | COMPLETION + | COMPRESSED + | COMPRESSION + | CONCURRENT + | CONDITION + | CONNECT + | CONNECTION + | CONNECTION_ADMIN + | CONSISTENT + | CONSTRAINT_CATALOG + | CONSTRAINT_NAME + | CONSTRAINT_SCHEMA + | CONTAINS + | CONTEXT + | CONTRIBUTORS + | COPY + | COUNT + | CPU + | CURRENT + | CURRENT_USER + | CURSOR_NAME + | DATA + | DATAFILE + | DEALLOCATE + | DEFAULT + | DEFAULT_AUTH + | DEFINER + | DELAY_KEY_WRITE + | DES_KEY_FILE + | DIAGNOSTICS + | DIRECTORY + | DISABLE + | DISCARD + | DISK + | DO + | DUMPFILE + | DUPLICATE + | DYNAMIC + | EMPTY + | ENABLE + | ENCRYPTION + | ENCRYPTION_KEY_ADMIN + | END + | ENDS + | ENGINE + | ENGINE_ATTRIBUTE + | ENGINES + | ENFORCED + | ERROR + | ERRORS + | ESCAPE + | EUR + | EVEN + | EVENT + | EVENTS + | EVERY + | EXCEPT + | EXCHANGE + | EXCLUSIVE + | EXPIRE + | EXPORT + | EXTENDED + | EXTENT_SIZE + | FAILED_LOGIN_ATTEMPTS + | FAST + | FAULTS + | FIELDS + | FILE_BLOCK_SIZE + | FILTER + | FIREWALL_ADMIN + | FIREWALL_EXEMPT + | FIREWALL_USER + | FIRST + | FIXED + | FLUSH + | FOLLOWS + | FOUND + | FULL + | FUNCTION + | GENERAL + | GLOBAL + | GRANTS + | GROUP + | GROUP_CONCAT + | GROUP_REPLICATION + | GROUP_REPLICATION_ADMIN + | HANDLER + | HASH + | HELP + | HISTORY + | HOST + | HOSTS + | IDENTIFIED + | IGNORED + | IGNORE_SERVER_IDS + | IMPORT + | INDEXES + | INITIAL_SIZE + | INNODB_REDO_LOG_ARCHIVE + | INPLACE + | INSERT_METHOD + | INSTALL + | INSTANCE + | INSTANT + | INTERNAL + | INVOKE + | INVOKER + | IO + | IO_THREAD + | IPC + | ISO + | ISOLATION + | ISSUER + | JIS + | JSON + | KEY_BLOCK_SIZE + | LAMBDA + | LANGUAGE + | LAST + | LATERAL + | LEAVES + | LESS + | LEVEL + | LIST + | LOCAL + | LOGFILE + | LOGS + | MASTER + | MASTER_AUTO_POSITION + | MASTER_CONNECT_RETRY + | MASTER_DELAY + | MASTER_HEARTBEAT_PERIOD + | MASTER_HOST + | MASTER_LOG_FILE + | MASTER_LOG_POS + | MASTER_PASSWORD + | MASTER_PORT + | MASTER_RETRY_COUNT + | MASTER_SSL + | MASTER_SSL_CA + | MASTER_SSL_CAPATH + | MASTER_SSL_CERT + | MASTER_SSL_CIPHER + | MASTER_SSL_CRL + | MASTER_SSL_CRLPATH + | MASTER_SSL_KEY + | MASTER_TLS_VERSION + | MASTER_USER + | MAX_CONNECTIONS_PER_HOUR + | MAX_QUERIES_PER_HOUR + | MAX + | MAX_ROWS + | MAX_SIZE + | MAX_UPDATES_PER_HOUR + | MAX_USER_CONNECTIONS + | MEDIUM + | MEMBER + | MEMORY + | MERGE + | MESSAGE_TEXT + | MID + | MIGRATE + | MIN + | MIN_ROWS + | MODE + | MODIFY + | MUTEX + | MYSQL + | MYSQL_ERRNO + | NAME + | NAMES + | NCHAR + | NDB_STORED_USER + | NESTED + | NEVER + | NEXT + | NO + | NOCOPY + | NODEGROUP + | NONE + | NOWAIT + | NUMBER + | ODBC + | OFFLINE + | OFFSET + | OF + | OJ + | OLD_PASSWORD + | ONE + | ONLINE + | ONLY + | OPEN + | OPTIMIZER_COSTS + | OPTIONAL + | OPTIONS + | ORDER + | ORDINALITY + | OWNER + | PACK_KEYS + | PAGE + | PARSER + | PARTIAL + | PARTITIONING + | PARTITIONS + | PASSWORD + | PASSWORDLESS_USER_ADMIN + | PASSWORD_LOCK_TIME + | PATH + | PERSIST_RO_VARIABLES_ADMIN + | PHASE + | PLUGINS + | PLUGIN_DIR + | PLUGIN + | PORT + | PRECEDES + | PREPARE + | PRESERVE + | PREV + | PRIMARY + | PROCESSLIST + | PROFILE + | PROFILES + | PROXY + | QUERY + | QUICK + | REBUILD + | RECOVER + | RECURSIVE + | REDO_BUFFER_SIZE + | REDUNDANT + | RELAY + | RELAYLOG + | RELAY_LOG_FILE + | RELAY_LOG_POS + | REMOVE + | REORGANIZE + | REPAIR + | REPLICATE_DO_DB + | REPLICATE_DO_TABLE + | REPLICATE_IGNORE_DB + | REPLICATE_IGNORE_TABLE + | REPLICATE_REWRITE_DB + | REPLICATE_WILD_DO_TABLE + | REPLICATE_WILD_IGNORE_TABLE + | REPLICATION + | REPLICATION_APPLIER + | REPLICATION_SLAVE_ADMIN + | RESET + | RESOURCE_GROUP_ADMIN + | RESOURCE_GROUP_USER + | RESUME + | RETURNED_SQLSTATE + | RETURNS + | REUSE + | ROLE + | ROLE_ADMIN + | ROLLBACK + | ROLLUP + | ROTATE + | ROW + | ROWS + | ROW_FORMAT + | RTREE + | S3 + | SAVEPOINT + | SCHEDULE + | SCHEMA_NAME + | SECURITY + | SECONDARY_ENGINE_ATTRIBUTE + | SERIAL + | SERVER + | SESSION + | SESSION_VARIABLES_ADMIN + | SET_USER_ID + | SHARE + | SHARED + | SHOW_ROUTINE + | SIGNED + | SIMPLE + | SLAVE + | SLOW + | SKIP_QUERY_REWRITE + | SNAPSHOT + | SOCKET + | SOME + | SONAME + | SOUNDS + | SOURCE + | SQL_AFTER_GTIDS + | SQL_AFTER_MTS_GAPS + | SQL_BEFORE_GTIDS + | SQL_BUFFER_RESULT + | SQL_CACHE + | SQL_NO_CACHE + | SQL_THREAD + | STACKED + | START + | STARTS + | STATS_AUTO_RECALC + | STATS_PERSISTENT + | STATS_SAMPLE_PAGES + | STATUS + | STD + | STDDEV + | STDDEV_POP + | STDDEV_SAMP + | STOP + | STORAGE + | STRING + | SUBCLASS_ORIGIN + | SUBJECT + | SUBPARTITION + | SUBPARTITIONS + | SUM + | SUSPEND + | SWAPS + | SWITCHES + | SYSTEM_VARIABLES_ADMIN + | TABLE_NAME + | TABLESPACE + | TABLE_ENCRYPTION_ADMIN + | TABLE_TYPE + | TEMPORARY + | TEMPTABLE + | THAN + | TP_CONNECTION_ADMIN + | TRADITIONAL + | TRANSACTION + | TRANSACTIONAL + | TRIGGERS + | TRUNCATE + | UNBOUNDED + | UNDEFINED + | UNDOFILE + | UNDO_BUFFER_SIZE + | UNINSTALL + | UNKNOWN + | UNTIL + | UPGRADE + | USA + | USER + | USE_FRM + | USER_RESOURCES + | VALIDATION + | VALUE + | VAR_POP + | VAR_SAMP + | VARIABLES + | VARIANCE + | VERSION_TOKEN_ADMIN + | VIEW + | VIRTUAL + | WAIT + | WARNINGS + | WITHOUT + | WORK + | WRAPPER + | X509 + | XA + | XA_RECOVER_ADMIN + | XML ; functionNameBase - : ABS | ACOS | ADDDATE | ADDTIME | AES_DECRYPT | AES_ENCRYPT - | AREA | ASBINARY | ASIN | ASTEXT | ASWKB | ASWKT - | ASYMMETRIC_DECRYPT | ASYMMETRIC_DERIVE - | ASYMMETRIC_ENCRYPT | ASYMMETRIC_SIGN | ASYMMETRIC_VERIFY - | ATAN | ATAN2 | BENCHMARK | BIN | BIT_COUNT | BIT_LENGTH - | BUFFER | CEIL | CEILING | CENTROID | CHARACTER_LENGTH - | CHARSET | CHAR_LENGTH | COERCIBILITY | COLLATION - | COMPRESS | CONCAT | CONCAT_WS | CONNECTION_ID | CONV - | CONVERT_TZ | COS | COT | COUNT | CRC32 - | CREATE_ASYMMETRIC_PRIV_KEY | CREATE_ASYMMETRIC_PUB_KEY - | CREATE_DH_PARAMETERS | CREATE_DIGEST | CROSSES | CUME_DIST | DATABASE | DATE - | DATEDIFF | DATE_FORMAT | DAY | DAYNAME | DAYOFMONTH - | DAYOFWEEK | DAYOFYEAR | DECODE | DEGREES | DENSE_RANK | DES_DECRYPT - | DES_ENCRYPT | DIMENSION | DISJOINT | ELT | ENCODE - | ENCRYPT | ENDPOINT | ENVELOPE | EQUALS | EXP | EXPORT_SET - | EXTERIORRING | EXTRACTVALUE | FIELD | FIND_IN_SET | FIRST_VALUE | FLOOR - | FORMAT | FOUND_ROWS | FROM_BASE64 | FROM_DAYS - | FROM_UNIXTIME | GEOMCOLLFROMTEXT | GEOMCOLLFROMWKB - | GEOMETRYCOLLECTION | GEOMETRYCOLLECTIONFROMTEXT - | GEOMETRYCOLLECTIONFROMWKB | GEOMETRYFROMTEXT - | GEOMETRYFROMWKB | GEOMETRYN | GEOMETRYTYPE | GEOMFROMTEXT - | GEOMFROMWKB | GET_FORMAT | GET_LOCK | GLENGTH | GREATEST - | GTID_SUBSET | GTID_SUBTRACT | HEX | HOUR | IFNULL - | INET6_ATON | INET6_NTOA | INET_ATON | INET_NTOA | INSTR - | INTERIORRINGN | INTERSECTS | INVISIBLE - | ISCLOSED | ISEMPTY | ISNULL - | ISSIMPLE | IS_FREE_LOCK | IS_IPV4 | IS_IPV4_COMPAT - | IS_IPV4_MAPPED | IS_IPV6 | IS_USED_LOCK | LAG | LAST_INSERT_ID | LAST_VALUE - | LCASE | LEAD | LEAST | LEFT | LENGTH | LINEFROMTEXT | LINEFROMWKB - | LINESTRING | LINESTRINGFROMTEXT | LINESTRINGFROMWKB | LN - | LOAD_FILE | LOCATE | LOG | LOG10 | LOG2 | LOWER | LPAD - | LTRIM | MAKEDATE | MAKETIME | MAKE_SET | MASTER_POS_WAIT - | MBRCONTAINS | MBRDISJOINT | MBREQUAL | MBRINTERSECTS - | MBROVERLAPS | MBRTOUCHES | MBRWITHIN | MD5 | MICROSECOND - | MINUTE | MLINEFROMTEXT | MLINEFROMWKB | MOD| MONTH | MONTHNAME - | MPOINTFROMTEXT | MPOINTFROMWKB | MPOLYFROMTEXT - | MPOLYFROMWKB | MULTILINESTRING | MULTILINESTRINGFROMTEXT - | MULTILINESTRINGFROMWKB | MULTIPOINT | MULTIPOINTFROMTEXT - | MULTIPOINTFROMWKB | MULTIPOLYGON | MULTIPOLYGONFROMTEXT - | MULTIPOLYGONFROMWKB | NAME_CONST | NTH_VALUE | NTILE | NULLIF | NUMGEOMETRIES - | NUMINTERIORRINGS | NUMPOINTS | OCT | OCTET_LENGTH | ORD - | OVERLAPS | PERCENT_RANK | PERIOD_ADD | PERIOD_DIFF | PI | POINT - | POINTFROMTEXT | POINTFROMWKB | POINTN | POLYFROMTEXT - | POLYFROMWKB | POLYGON | POLYGONFROMTEXT | POLYGONFROMWKB - | POSITION | POW | POWER | QUARTER | QUOTE | RADIANS | RAND | RANDOM | RANK - | RANDOM_BYTES | RELEASE_LOCK | REVERSE | RIGHT | ROUND - | ROW_COUNT | ROW_NUMBER | RPAD | RTRIM | SCHEMA | SECOND | SEC_TO_TIME - | SESSION_USER | SESSION_VARIABLES_ADMIN - | SHA | SHA1 | SHA2 | SIGN | SIN | SLEEP - | SOUNDEX | SQL_THREAD_WAIT_AFTER_GTIDS | SQRT | SRID - | STARTPOINT | STRCMP | STR_TO_DATE | ST_AREA | ST_ASBINARY - | ST_ASTEXT | ST_ASWKB | ST_ASWKT | ST_BUFFER | ST_CENTROID - | ST_CONTAINS | ST_CROSSES | ST_DIFFERENCE | ST_DIMENSION - | ST_DISJOINT | ST_DISTANCE | ST_ENDPOINT | ST_ENVELOPE - | ST_EQUALS | ST_EXTERIORRING | ST_GEOMCOLLFROMTEXT - | ST_GEOMCOLLFROMTXT | ST_GEOMCOLLFROMWKB + : ABS + | ACOS + | ADDDATE + | ADDTIME + | AES_DECRYPT + | AES_ENCRYPT + | AREA + | ASBINARY + | ASIN + | ASTEXT + | ASWKB + | ASWKT + | ASYMMETRIC_DECRYPT + | ASYMMETRIC_DERIVE + | ASYMMETRIC_ENCRYPT + | ASYMMETRIC_SIGN + | ASYMMETRIC_VERIFY + | ATAN + | ATAN2 + | BENCHMARK + | BIN + | BIT_COUNT + | BIT_LENGTH + | BUFFER + | CEIL + | CEILING + | CENTROID + | CHARACTER_LENGTH + | CHARSET + | CHAR_LENGTH + | COERCIBILITY + | COLLATION + | COMPRESS + | CONCAT + | CONCAT_WS + | CONNECTION_ID + | CONV + | CONVERT_TZ + | COS + | COT + | COUNT + | CRC32 + | CREATE_ASYMMETRIC_PRIV_KEY + | CREATE_ASYMMETRIC_PUB_KEY + | CREATE_DH_PARAMETERS + | CREATE_DIGEST + | CROSSES + | CUME_DIST + | DATABASE + | DATE + | DATEDIFF + | DATE_FORMAT + | DAY + | DAYNAME + | DAYOFMONTH + | DAYOFWEEK + | DAYOFYEAR + | DECODE + | DEGREES + | DENSE_RANK + | DES_DECRYPT + | DES_ENCRYPT + | DIMENSION + | DISJOINT + | ELT + | ENCODE + | ENCRYPT + | ENDPOINT + | ENVELOPE + | EQUALS + | EXP + | EXPORT_SET + | EXTERIORRING + | EXTRACTVALUE + | FIELD + | FIND_IN_SET + | FIRST_VALUE + | FLOOR + | FORMAT + | FOUND_ROWS + | FROM_BASE64 + | FROM_DAYS + | FROM_UNIXTIME + | GEOMCOLLFROMTEXT + | GEOMCOLLFROMWKB + | GEOMETRYCOLLECTION + | GEOMETRYCOLLECTIONFROMTEXT + | GEOMETRYCOLLECTIONFROMWKB + | GEOMETRYFROMTEXT + | GEOMETRYFROMWKB + | GEOMETRYN + | GEOMETRYTYPE + | GEOMFROMTEXT + | GEOMFROMWKB + | GET_FORMAT + | GET_LOCK + | GLENGTH + | GREATEST + | GTID_SUBSET + | GTID_SUBTRACT + | HEX + | HOUR + | IFNULL + | INET6_ATON + | INET6_NTOA + | INET_ATON + | INET_NTOA + | INSTR + | INTERIORRINGN + | INTERSECTS + | INVISIBLE + | ISCLOSED + | ISEMPTY + | ISNULL + | ISSIMPLE + | IS_FREE_LOCK + | IS_IPV4 + | IS_IPV4_COMPAT + | IS_IPV4_MAPPED + | IS_IPV6 + | IS_USED_LOCK + | LAG + | LAST_INSERT_ID + | LAST_VALUE + | LCASE + | LEAD + | LEAST + | LEFT + | LENGTH + | LINEFROMTEXT + | LINEFROMWKB + | LINESTRING + | LINESTRINGFROMTEXT + | LINESTRINGFROMWKB + | LN + | LOAD_FILE + | LOCATE + | LOG + | LOG10 + | LOG2 + | LOWER + | LPAD + | LTRIM + | MAKEDATE + | MAKETIME + | MAKE_SET + | MASTER_POS_WAIT + | MBRCONTAINS + | MBRDISJOINT + | MBREQUAL + | MBRINTERSECTS + | MBROVERLAPS + | MBRTOUCHES + | MBRWITHIN + | MD5 + | MICROSECOND + | MINUTE + | MLINEFROMTEXT + | MLINEFROMWKB + | MOD + | MONTH + | MONTHNAME + | MPOINTFROMTEXT + | MPOINTFROMWKB + | MPOLYFROMTEXT + | MPOLYFROMWKB + | MULTILINESTRING + | MULTILINESTRINGFROMTEXT + | MULTILINESTRINGFROMWKB + | MULTIPOINT + | MULTIPOINTFROMTEXT + | MULTIPOINTFROMWKB + | MULTIPOLYGON + | MULTIPOLYGONFROMTEXT + | MULTIPOLYGONFROMWKB + | NAME_CONST + | NTH_VALUE + | NTILE + | NULLIF + | NUMGEOMETRIES + | NUMINTERIORRINGS + | NUMPOINTS + | OCT + | OCTET_LENGTH + | ORD + | OVERLAPS + | PERCENT_RANK + | PERIOD_ADD + | PERIOD_DIFF + | PI + | POINT + | POINTFROMTEXT + | POINTFROMWKB + | POINTN + | POLYFROMTEXT + | POLYFROMWKB + | POLYGON + | POLYGONFROMTEXT + | POLYGONFROMWKB + | POSITION + | POW + | POWER + | QUARTER + | QUOTE + | RADIANS + | RAND + | RANDOM + | RANK + | RANDOM_BYTES + | RELEASE_LOCK + | REVERSE + | RIGHT + | ROUND + | ROW_COUNT + | ROW_NUMBER + | RPAD + | RTRIM + | SCHEMA + | SECOND + | SEC_TO_TIME + | SESSION_USER + | SESSION_VARIABLES_ADMIN + | SHA + | SHA1 + | SHA2 + | SIGN + | SIN + | SLEEP + | SOUNDEX + | SQL_THREAD_WAIT_AFTER_GTIDS + | SQRT + | SRID + | STARTPOINT + | STRCMP + | STR_TO_DATE + | ST_AREA + | ST_ASBINARY + | ST_ASTEXT + | ST_ASWKB + | ST_ASWKT + | ST_BUFFER + | ST_CENTROID + | ST_CONTAINS + | ST_CROSSES + | ST_DIFFERENCE + | ST_DIMENSION + | ST_DISJOINT + | ST_DISTANCE + | ST_ENDPOINT + | ST_ENVELOPE + | ST_EQUALS + | ST_EXTERIORRING + | ST_GEOMCOLLFROMTEXT + | ST_GEOMCOLLFROMTXT + | ST_GEOMCOLLFROMWKB | ST_GEOMETRYCOLLECTIONFROMTEXT - | ST_GEOMETRYCOLLECTIONFROMWKB | ST_GEOMETRYFROMTEXT - | ST_GEOMETRYFROMWKB | ST_GEOMETRYN | ST_GEOMETRYTYPE - | ST_GEOMFROMTEXT | ST_GEOMFROMWKB | ST_INTERIORRINGN - | ST_INTERSECTION | ST_INTERSECTS | ST_ISCLOSED | ST_ISEMPTY - | ST_ISSIMPLE | ST_LINEFROMTEXT | ST_LINEFROMWKB - | ST_LINESTRINGFROMTEXT | ST_LINESTRINGFROMWKB - | ST_NUMGEOMETRIES | ST_NUMINTERIORRING - | ST_NUMINTERIORRINGS | ST_NUMPOINTS | ST_OVERLAPS - | ST_POINTFROMTEXT | ST_POINTFROMWKB | ST_POINTN - | ST_POLYFROMTEXT | ST_POLYFROMWKB | ST_POLYGONFROMTEXT - | ST_POLYGONFROMWKB | ST_SRID | ST_STARTPOINT - | ST_SYMDIFFERENCE | ST_TOUCHES | ST_UNION | ST_WITHIN - | ST_X | ST_Y | SUBDATE | SUBSTRING_INDEX | SUBTIME - | SYSTEM_USER | TAN | TIME | TIMEDIFF | TIMESTAMP - | TIMESTAMPADD | TIMESTAMPDIFF | TIME_FORMAT | TIME_TO_SEC - | TOUCHES | TO_BASE64 | TO_DAYS | TO_SECONDS | UCASE - | UNCOMPRESS | UNCOMPRESSED_LENGTH | UNHEX | UNIX_TIMESTAMP - | UPDATEXML | UPPER | UUID | UUID_SHORT - | VALIDATE_PASSWORD_STRENGTH | VERSION | VISIBLE - | WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS | WEEK | WEEKDAY - | WEEKOFYEAR | WEIGHT_STRING | WITHIN | YEAR | YEARWEEK - | Y_FUNCTION | X_FUNCTION - | JSON_ARRAY | JSON_OBJECT | JSON_QUOTE | JSON_CONTAINS | JSON_CONTAINS_PATH - | JSON_EXTRACT | JSON_KEYS | JSON_OVERLAPS | JSON_SEARCH | JSON_VALUE - | JSON_ARRAY_APPEND | JSON_ARRAY_INSERT | JSON_INSERT | JSON_MERGE - | JSON_MERGE_PATCH | JSON_MERGE_PRESERVE | JSON_REMOVE | JSON_REPLACE - | JSON_SET | JSON_UNQUOTE | JSON_DEPTH | JSON_LENGTH | JSON_TYPE - | JSON_VALID | JSON_TABLE | JSON_SCHEMA_VALID | JSON_SCHEMA_VALIDATION_REPORT - | JSON_PRETTY | JSON_STORAGE_FREE | JSON_STORAGE_SIZE | JSON_ARRAYAGG + | ST_GEOMETRYCOLLECTIONFROMWKB + | ST_GEOMETRYFROMTEXT + | ST_GEOMETRYFROMWKB + | ST_GEOMETRYN + | ST_GEOMETRYTYPE + | ST_GEOMFROMTEXT + | ST_GEOMFROMWKB + | ST_INTERIORRINGN + | ST_INTERSECTION + | ST_INTERSECTS + | ST_ISCLOSED + | ST_ISEMPTY + | ST_ISSIMPLE + | ST_LINEFROMTEXT + | ST_LINEFROMWKB + | ST_LINESTRINGFROMTEXT + | ST_LINESTRINGFROMWKB + | ST_NUMGEOMETRIES + | ST_NUMINTERIORRING + | ST_NUMINTERIORRINGS + | ST_NUMPOINTS + | ST_OVERLAPS + | ST_POINTFROMTEXT + | ST_POINTFROMWKB + | ST_POINTN + | ST_POLYFROMTEXT + | ST_POLYFROMWKB + | ST_POLYGONFROMTEXT + | ST_POLYGONFROMWKB + | ST_SRID + | ST_STARTPOINT + | ST_SYMDIFFERENCE + | ST_TOUCHES + | ST_UNION + | ST_WITHIN + | ST_X + | ST_Y + | SUBDATE + | SUBSTRING_INDEX + | SUBTIME + | SYSTEM_USER + | TAN + | TIME + | TIMEDIFF + | TIMESTAMP + | TIMESTAMPADD + | TIMESTAMPDIFF + | TIME_FORMAT + | TIME_TO_SEC + | TOUCHES + | TO_BASE64 + | TO_DAYS + | TO_SECONDS + | UCASE + | UNCOMPRESS + | UNCOMPRESSED_LENGTH + | UNHEX + | UNIX_TIMESTAMP + | UPDATEXML + | UPPER + | UUID + | UUID_SHORT + | VALIDATE_PASSWORD_STRENGTH + | VERSION + | VISIBLE + | WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS + | WEEK + | WEEKDAY + | WEEKOFYEAR + | WEIGHT_STRING + | WITHIN + | YEAR + | YEARWEEK + | Y_FUNCTION + | X_FUNCTION + | JSON_ARRAY + | JSON_OBJECT + | JSON_QUOTE + | JSON_CONTAINS + | JSON_CONTAINS_PATH + | JSON_EXTRACT + | JSON_KEYS + | JSON_OVERLAPS + | JSON_SEARCH + | JSON_VALUE + | JSON_ARRAY_APPEND + | JSON_ARRAY_INSERT + | JSON_INSERT + | JSON_MERGE + | JSON_MERGE_PATCH + | JSON_MERGE_PRESERVE + | JSON_REMOVE + | JSON_REPLACE + | JSON_SET + | JSON_UNQUOTE + | JSON_DEPTH + | JSON_LENGTH + | JSON_TYPE + | JSON_VALID + | JSON_TABLE + | JSON_SCHEMA_VALID + | JSON_SCHEMA_VALIDATION_REPORT + | JSON_PRETTY + | JSON_STORAGE_FREE + | JSON_STORAGE_SIZE + | JSON_ARRAYAGG | JSON_OBJECTAGG - ; + ; \ No newline at end of file diff --git a/sql/phoenix/PhoenixLexer.g4 b/sql/phoenix/PhoenixLexer.g4 index 85a6820391..e33b366c2b 100644 --- a/sql/phoenix/PhoenixLexer.g4 +++ b/sql/phoenix/PhoenixLexer.g4 @@ -21,219 +21,222 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -lexer grammar PhoenixLexer; - -options { caseInsensitive = true; } - -ADD: 'ADD'; -ALL: 'ALL'; -ALTER: 'ALTER'; -AND: 'AND'; -ANY: 'ANY'; -APPROX_COUNT_DISTINCT: 'APPROX_COUNT_DISTINCT'; -ARRAY: 'ARRAY'; -AS: 'AS'; -ASC: 'ASC'; -ASYNC: 'ASYNC'; -AVG: 'AVG'; -BETWEEN: 'BETWEEN'; -BIGINT: 'BIGINT'; -BINARY: 'BINARY'; -BY: 'BY'; -CACHE: 'CACHE'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CAST: 'CAST'; -CHAR: 'CHAR'; -CLOSE: 'CLOSE'; -COLUMN: 'COLUMN'; -CONSTANT: 'CONSTANT'; -CONSTRAINT: 'CONSTRAINT'; -COUNT: 'COUNT'; -CREATE: 'CREATE'; -CURRENT: 'CURRENT'; -CURSOR: 'CURSOR'; -CYCLE: 'CYCLE'; -DATE: 'DATE'; -DECIMAL: 'DECIMAL'; -DECLARE: 'DECLARE'; -DEFAULT: 'DEFAULT'; -DEFAULTVALUE: 'DEFAULTVALUE'; -DELETE: 'DELETE'; -DESC: 'DESC'; -DISABLE: 'DISABLE'; -DISTINCT: 'DISTINCT'; -DOUBLE: 'DOUBLE'; -DROP: 'DROP'; -DUPLICATE: 'DUPLICATE'; -ELSE: 'ELSE'; -END: 'END'; -EXISTS: 'EXISTS'; -EXPLAIN: 'EXPLAIN'; -FALSE: 'FALSE'; -FETCH: 'FETCH'; -FIRST: 'FIRST'; -FIRST_VALUE: 'FIRST_VALUE'; -FIRST_VALUES: 'FIRST_VALUES'; -FLOAT: 'FLOAT'; -FOR: 'FOR'; -FROM: 'FROM'; -FUNCTION: 'FUNCTION'; -GRANT: 'GRANT'; -GROUP: 'GROUP'; -HAVING: 'HAVING'; -IF: 'IF'; -IGNORE: 'IGNORE'; -ILIKE: 'ILIKE'; -IN: 'IN'; -INCLUDE: 'INCLUDE'; -INCREMENT: 'INCREMENT'; -INDEX: 'INDEX'; -INNER: 'INNER'; -INTEGER: 'INTEGER'; -INTO: 'INTO'; -IS: 'IS'; -JAR: 'JAR'; -JOIN: 'JOIN'; -KEY: 'KEY'; -LAST: 'LAST'; -LAST_VALUE: 'LAST_VALUE'; -LAST_VALUES: 'LAST_VALUES'; -LEFT: 'LEFT'; -LIKE: 'LIKE'; -LIMIT: 'LIMIT'; -LOCAL: 'LOCAL'; -MAX: 'MAX'; -MAXVALUE: 'MAXVALUE'; -MIN: 'MIN'; -MINVALUE: 'MINVALUE'; -NEXT: 'NEXT'; -NO_CACHE: 'NO_CACHE'; -NO_CHILD_PARENT_JOIN_OPTIMIZATION: 'NO_CHILD_PARENT_JOIN_OPTIMIZATION'; -NO_INDEX: 'NO_INDEX'; -NO_SEEK_TO_COLUMN: 'NO_SEEK_TO_COLUMN'; -NO_STAR_JOIN: 'NO_STAR_JOIN'; -NOT: 'NOT'; -NTH_VALUE: 'NTH_VALUE'; -NULL_: 'NULL'; -NULLS: 'NULLS'; -OFFSET: 'OFFSET'; -ON: 'ON'; -ONLY: 'ONLY'; -OPEN: 'OPEN'; -OR: 'OR'; -ORDER: 'ORDER'; -OUTER: 'OUTER'; -PERCENT_RANK: 'PERCENT_RANK'; -PERCENTILE_CONT: 'PERCENTILE_CONT'; -PERCENTILE_DISC: 'PERCENTILE_DISC'; -PRIMARY: 'PRIMARY'; -RANGE_SCAN: 'RANGE_SCAN'; -REBUILD: 'REBUILD'; -RETURNS: 'RETURNS'; -REVOKE: 'REVOKE'; -RIGHT: 'RIGHT'; -ROW: 'ROW'; -ROW_TIMESTAMP: 'ROW_TIMESTAMP'; -ROWS: 'ROWS'; -SCHEMA: 'SCHEMA'; -SEEK_TO_COLUMN: 'SEEK_TO_COLUMN'; -SELECT: 'SELECT'; -SEQUENCE: 'SEQUENCE'; -SERIAL: 'SERIAL'; -SET: 'SET'; -SKIP_SCAN: 'SKIP_SCAN'; -SMALL: 'SMALL'; -SMALLINT: 'SMALLINT'; -SPLIT: 'SPLIT'; -START: 'START'; -STATISTICS: 'STATISTICS'; -STDDEV_POP: 'STDDEV_POP'; -STDDEV_SAMP: 'STDDEV_SAMP'; -SUM: 'SUM'; -TABLE: 'TABLE'; -TABLESAMPLE: 'TABLESAMPLE'; -TEMPORARY: 'TEMPORARY'; -THEN: 'THEN'; -TIME: 'TIME'; -TIMESTAMP: 'TIMESTAMP'; -TINYINT: 'TINYINT'; -TO: 'TO'; -TRUE: 'TRUE'; -UNION: 'UNION'; -UNSIGNED_DATE: 'UNSIGNED_DATE'; -UNSIGNED_DOUBLE: 'UNSIGNED_DOUBLE'; -UNSIGNED_FLOAT: 'UNSIGNED_FLOAT'; -UNSIGNED_INT: 'UNSIGNED_INT'; -UNSIGNED_LONG: 'UNSIGNED_LONG'; -UNSIGNED_SMALLINT: 'UNSIGNED_SMALLINT'; -UNSIGNED_TIME: 'UNSIGNED_TIME'; -UNSIGNED_TIMESTAMP: 'UNSIGNED_TIMESTAMP'; -UNSIGNED_TINYINT: 'UNSIGNED_TINYINT'; -UNUSABLE: 'UNUSABLE'; -UPDATE: 'UPDATE'; -UPSERT: 'UPSERT'; -USABLE: 'USABLE'; -USE: 'USE'; -USE_DATA_OVER_INDEX_TABLE: 'USE_DATA_OVER_INDEX_TABLE'; -USE_INDEX_OVER_DATA_TABLE: 'USE_INDEX_OVER_DATA_TABLE'; -USE_SORT_MERGE_JOIN: 'USE_SORT_MERGE_JOIN'; -USING: 'USING'; -VALUE: 'VALUE'; -VALUES: 'VALUES'; -VARBINARY: 'VARBINARY'; -VARCHAR: 'VARCHAR'; -VIEW: 'VIEW'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WITH: 'WITH'; - - -SEMI: ';'; -COLON: ':'; -COMMA: ','; -DOT: '.'; -LP: '('; -RP: ')'; -STAR: '*'; -DIV: '/'; -MOD: '%'; -PLUS: '+'; -MINUS: '-'; -PIPEPIPE: '||'; -LSB: '['; -RSC: ']'; -EQ: '='; -NE: '<>'; -NE2: '!='; -GT: '>'; -GE: '>='; -LT: '<'; -LE: '<='; -QM: '?'; - - -WHITE_SPACE: [ \t\r\n]+ -> channel(HIDDEN); +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -SQL_COMMENT: '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); -LINE_COMMENT: '--' ~[\r\n]* -> channel(HIDDEN); -HINT_START: '/*+'; -HINT_END: '*/'; - -DOUBLE_QUOTE_ID: '"' ~'"'+ '"'; -SINGLE_QUOTE: '\''; - -ID: [A-Z_] [A-Z0-9_]*; - - -STRING_LITERAL: '\'' ~'\''* '\''; -DECIMAL_LITERAL: DEC_DIGIT+; -FLOAT_LITERAL: DEC_DOT_DEC; -REAL_LITERAL: (DECIMAL_LITERAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+); -CHAR_LITERAL: '\'' (~['\\\r\n]) '\''; - -fragment LETTER: [A-Z_]; - -fragment DEC_DOT_DEC: DEC_DIGIT+ '.' DEC_DIGIT* | '.' DEC_DIGIT+; +lexer grammar PhoenixLexer; -fragment DEC_DIGIT: [0-9]; +options { + caseInsensitive = true; +} + +ADD : 'ADD'; +ALL : 'ALL'; +ALTER : 'ALTER'; +AND : 'AND'; +ANY : 'ANY'; +APPROX_COUNT_DISTINCT : 'APPROX_COUNT_DISTINCT'; +ARRAY : 'ARRAY'; +AS : 'AS'; +ASC : 'ASC'; +ASYNC : 'ASYNC'; +AVG : 'AVG'; +BETWEEN : 'BETWEEN'; +BIGINT : 'BIGINT'; +BINARY : 'BINARY'; +BY : 'BY'; +CACHE : 'CACHE'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CHAR : 'CHAR'; +CLOSE : 'CLOSE'; +COLUMN : 'COLUMN'; +CONSTANT : 'CONSTANT'; +CONSTRAINT : 'CONSTRAINT'; +COUNT : 'COUNT'; +CREATE : 'CREATE'; +CURRENT : 'CURRENT'; +CURSOR : 'CURSOR'; +CYCLE : 'CYCLE'; +DATE : 'DATE'; +DECIMAL : 'DECIMAL'; +DECLARE : 'DECLARE'; +DEFAULT : 'DEFAULT'; +DEFAULTVALUE : 'DEFAULTVALUE'; +DELETE : 'DELETE'; +DESC : 'DESC'; +DISABLE : 'DISABLE'; +DISTINCT : 'DISTINCT'; +DOUBLE : 'DOUBLE'; +DROP : 'DROP'; +DUPLICATE : 'DUPLICATE'; +ELSE : 'ELSE'; +END : 'END'; +EXISTS : 'EXISTS'; +EXPLAIN : 'EXPLAIN'; +FALSE : 'FALSE'; +FETCH : 'FETCH'; +FIRST : 'FIRST'; +FIRST_VALUE : 'FIRST_VALUE'; +FIRST_VALUES : 'FIRST_VALUES'; +FLOAT : 'FLOAT'; +FOR : 'FOR'; +FROM : 'FROM'; +FUNCTION : 'FUNCTION'; +GRANT : 'GRANT'; +GROUP : 'GROUP'; +HAVING : 'HAVING'; +IF : 'IF'; +IGNORE : 'IGNORE'; +ILIKE : 'ILIKE'; +IN : 'IN'; +INCLUDE : 'INCLUDE'; +INCREMENT : 'INCREMENT'; +INDEX : 'INDEX'; +INNER : 'INNER'; +INTEGER : 'INTEGER'; +INTO : 'INTO'; +IS : 'IS'; +JAR : 'JAR'; +JOIN : 'JOIN'; +KEY : 'KEY'; +LAST : 'LAST'; +LAST_VALUE : 'LAST_VALUE'; +LAST_VALUES : 'LAST_VALUES'; +LEFT : 'LEFT'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +LOCAL : 'LOCAL'; +MAX : 'MAX'; +MAXVALUE : 'MAXVALUE'; +MIN : 'MIN'; +MINVALUE : 'MINVALUE'; +NEXT : 'NEXT'; +NO_CACHE : 'NO_CACHE'; +NO_CHILD_PARENT_JOIN_OPTIMIZATION : 'NO_CHILD_PARENT_JOIN_OPTIMIZATION'; +NO_INDEX : 'NO_INDEX'; +NO_SEEK_TO_COLUMN : 'NO_SEEK_TO_COLUMN'; +NO_STAR_JOIN : 'NO_STAR_JOIN'; +NOT : 'NOT'; +NTH_VALUE : 'NTH_VALUE'; +NULL_ : 'NULL'; +NULLS : 'NULLS'; +OFFSET : 'OFFSET'; +ON : 'ON'; +ONLY : 'ONLY'; +OPEN : 'OPEN'; +OR : 'OR'; +ORDER : 'ORDER'; +OUTER : 'OUTER'; +PERCENT_RANK : 'PERCENT_RANK'; +PERCENTILE_CONT : 'PERCENTILE_CONT'; +PERCENTILE_DISC : 'PERCENTILE_DISC'; +PRIMARY : 'PRIMARY'; +RANGE_SCAN : 'RANGE_SCAN'; +REBUILD : 'REBUILD'; +RETURNS : 'RETURNS'; +REVOKE : 'REVOKE'; +RIGHT : 'RIGHT'; +ROW : 'ROW'; +ROW_TIMESTAMP : 'ROW_TIMESTAMP'; +ROWS : 'ROWS'; +SCHEMA : 'SCHEMA'; +SEEK_TO_COLUMN : 'SEEK_TO_COLUMN'; +SELECT : 'SELECT'; +SEQUENCE : 'SEQUENCE'; +SERIAL : 'SERIAL'; +SET : 'SET'; +SKIP_SCAN : 'SKIP_SCAN'; +SMALL : 'SMALL'; +SMALLINT : 'SMALLINT'; +SPLIT : 'SPLIT'; +START : 'START'; +STATISTICS : 'STATISTICS'; +STDDEV_POP : 'STDDEV_POP'; +STDDEV_SAMP : 'STDDEV_SAMP'; +SUM : 'SUM'; +TABLE : 'TABLE'; +TABLESAMPLE : 'TABLESAMPLE'; +TEMPORARY : 'TEMPORARY'; +THEN : 'THEN'; +TIME : 'TIME'; +TIMESTAMP : 'TIMESTAMP'; +TINYINT : 'TINYINT'; +TO : 'TO'; +TRUE : 'TRUE'; +UNION : 'UNION'; +UNSIGNED_DATE : 'UNSIGNED_DATE'; +UNSIGNED_DOUBLE : 'UNSIGNED_DOUBLE'; +UNSIGNED_FLOAT : 'UNSIGNED_FLOAT'; +UNSIGNED_INT : 'UNSIGNED_INT'; +UNSIGNED_LONG : 'UNSIGNED_LONG'; +UNSIGNED_SMALLINT : 'UNSIGNED_SMALLINT'; +UNSIGNED_TIME : 'UNSIGNED_TIME'; +UNSIGNED_TIMESTAMP : 'UNSIGNED_TIMESTAMP'; +UNSIGNED_TINYINT : 'UNSIGNED_TINYINT'; +UNUSABLE : 'UNUSABLE'; +UPDATE : 'UPDATE'; +UPSERT : 'UPSERT'; +USABLE : 'USABLE'; +USE : 'USE'; +USE_DATA_OVER_INDEX_TABLE : 'USE_DATA_OVER_INDEX_TABLE'; +USE_INDEX_OVER_DATA_TABLE : 'USE_INDEX_OVER_DATA_TABLE'; +USE_SORT_MERGE_JOIN : 'USE_SORT_MERGE_JOIN'; +USING : 'USING'; +VALUE : 'VALUE'; +VALUES : 'VALUES'; +VARBINARY : 'VARBINARY'; +VARCHAR : 'VARCHAR'; +VIEW : 'VIEW'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WITH : 'WITH'; + +SEMI : ';'; +COLON : ':'; +COMMA : ','; +DOT : '.'; +LP : '('; +RP : ')'; +STAR : '*'; +DIV : '/'; +MOD : '%'; +PLUS : '+'; +MINUS : '-'; +PIPEPIPE : '||'; +LSB : '['; +RSC : ']'; +EQ : '='; +NE : '<>'; +NE2 : '!='; +GT : '>'; +GE : '>='; +LT : '<'; +LE : '<='; +QM : '?'; + +WHITE_SPACE: [ \t\r\n]+ -> channel(HIDDEN); + +SQL_COMMENT : '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); +HINT_START : '/*+'; +HINT_END : '*/'; + +DOUBLE_QUOTE_ID : '"' ~'"'+ '"'; +SINGLE_QUOTE : '\''; + +ID: [A-Z_] [A-Z0-9_]*; + +STRING_LITERAL : '\'' ~'\''* '\''; +DECIMAL_LITERAL : DEC_DIGIT+; +FLOAT_LITERAL : DEC_DOT_DEC; +REAL_LITERAL : (DECIMAL_LITERAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+); +CHAR_LITERAL : '\'' (~['\\\r\n]) '\''; + +fragment LETTER: [A-Z_]; + +fragment DEC_DOT_DEC: DEC_DIGIT+ '.' DEC_DIGIT* | '.' DEC_DIGIT+; + +fragment DEC_DIGIT: [0-9]; \ No newline at end of file diff --git a/sql/phoenix/PhoenixParser.g4 b/sql/phoenix/PhoenixParser.g4 index f42f1b77f9..c3e28f675f 100644 --- a/sql/phoenix/PhoenixParser.g4 +++ b/sql/phoenix/PhoenixParser.g4 @@ -21,9 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 PhoenixParser; -options { tokenVocab=PhoenixLexer; } +options { + tokenVocab = PhoenixLexer; +} phoenix_file : batch* EOF @@ -76,12 +81,11 @@ other_command ; alter_command - : ALTER (TABLE | VIEW)? table_ref - ( - ADD if_not_exists? column_def_list options_? + : ALTER (TABLE | VIEW)? table_ref ( + ADD if_not_exists? column_def_list options_? | DROP COLUMN if_exists? column_ref_list | SET options_ - ) + ) ; alter_index_command @@ -89,15 +93,15 @@ alter_index_command ; create_function_command - : CREATE TEMPORARY? FUNCTION func_name '(' func_argument_list ')' RETURNS data_type AS class_name (USING JAR jar_path)? + : CREATE TEMPORARY? FUNCTION func_name '(' func_argument_list ')' RETURNS data_type AS class_name ( + USING JAR jar_path + )? ; create_index_command - : CREATE LOCAL? INDEX if_not_exists? index_name ON table_ref '(' expression_asc_desc_list ')' - (INCLUDE '(' column_ref_list ')')? - ASYNC? - index_options? - (SPLIT ON split_point_list)? + : CREATE LOCAL? INDEX if_not_exists? index_name ON table_ref '(' expression_asc_desc_list ')' ( + INCLUDE '(' column_ref_list ')' + )? ASYNC? index_options? (SPLIT ON split_point_list)? ; create_schema_command @@ -105,25 +109,23 @@ create_schema_command ; create_sequence_command - : CREATE SEQUENCE if_not_exists? sequence_ref - (START WITH? bind_parameter_number)? - (INCREMENT BY? bind_parameter_number)? - (MINVALUE bind_parameter_number)? - (MAXVALUE bind_parameter_number)? - CYCLE? - (CACHE bind_parameter_number)? + : CREATE SEQUENCE if_not_exists? sequence_ref (START WITH? bind_parameter_number)? ( + INCREMENT BY? bind_parameter_number + )? (MINVALUE bind_parameter_number)? (MAXVALUE bind_parameter_number)? CYCLE? ( + CACHE bind_parameter_number + )? ; create_table_command - : CREATE TABLE if_not_exists? table_ref '(' column_def_list constraint? ')' - table_options? - (SPLIT ON '(' split_point_list ')')? + : CREATE TABLE if_not_exists? table_ref '(' column_def_list constraint? ')' table_options? ( + SPLIT ON '(' split_point_list ')' + )? ; create_view_command - : CREATE VIEW if_not_exists? new_table_ref ('(' column_def_list ')')? - (AS SELECT '*' FROM existing_table_ref (WHERE expression)? )? - table_options? + : CREATE VIEW if_not_exists? new_table_ref ('(' column_def_list ')')? ( + AS SELECT '*' FROM existing_table_ref (WHERE expression)? + )? table_options? ; constraint @@ -280,7 +282,7 @@ revoke_command ; on_schema_table - : ON (SCHEMA schema_name | table_ref ) + : ON (SCHEMA schema_name | table_ref) ; permission_string @@ -300,9 +302,9 @@ guide_post_options ; upsert_values_command - : UPSERT INTO table_name ('(' (column_ref_list | column_def_list) ')')? - VALUES '(' literal (',' literal)* ')' - (ON DUPLICATE KEY (IGNORE | UPDATE column_ref '=' expression))? + : UPSERT INTO table_name ('(' (column_ref_list | column_def_list) ')')? VALUES '(' literal ( + ',' literal + )* ')' (ON DUPLICATE KEY (IGNORE | UPDATE column_ref '=' expression))? ; column_ref_list @@ -319,9 +321,7 @@ upsert_select_command delete_command : DELETE hint? FROM table_name //TODO hint - where_clause? - order_by_clause? - limit_clause? + where_clause? order_by_clause? limit_clause? ; order_by_clause @@ -341,19 +341,16 @@ where_clause ; select_command - : select_statement union_list? - order_by_clause? - limit_clause? - (OFFSET bind_parameter_number row_rows?)? - (FETCH first_next bind_parameter_number row_rows? ONLY)? + : select_statement union_list? order_by_clause? limit_clause? ( + OFFSET bind_parameter_number row_rows? + )? (FETCH first_next bind_parameter_number row_rows? ONLY)? ; select_statement : SELECT hint? (DISTINCT | ALL)? select_expression (',' select_expression)* //TODO hint - FROM table_spec join_list? - where_clause? - (GROUP BY expression (',' expression)* )? - (HAVING expression)? + FROM table_spec join_list? where_clause? (GROUP BY expression (',' expression)*)? ( + HAVING expression + )? ; union_list @@ -483,11 +480,13 @@ name table_spec : aliased_table_ref - | '(' select_command')' (AS? table_alias)? + | '(' select_command ')' (AS? table_alias)? ; aliased_table_ref - : table_ref (AS? table_alias)? ('(' column_def (',' column_def)? ')')? (TABLESAMPLE '(' positive_decimal ')')? + : table_ref (AS? table_alias)? ('(' column_def (',' column_def)? ')')? ( + TABLESAMPLE '(' positive_decimal ')' + )? ; table_alias @@ -507,7 +506,7 @@ table_name ; column_def - : column_ref data_type (NOT? NULL_)? (DEFAULT literal)? (PRIMARY KEY asc_desc? ROW_TIMESTAMP? )? + : column_ref data_type (NOT? NULL_)? (DEFAULT literal)? (PRIMARY KEY asc_desc? ROW_TIMESTAMP?)? ; column_ref @@ -549,7 +548,7 @@ expression | expression comp_op any_all LP (select_command) RP | expression (LIKE | ILIKE) expression | expression IS NOT? NULL_ - | expression NOT? IN LP (select_command | expression_list ) RP + | expression NOT? IN LP (select_command | expression_list) RP | expression NOT? BETWEEN expression AND expression | NOT? EXISTS LP select_command RP | ID LP expression_list RP @@ -565,7 +564,13 @@ expression ; comp_op - : EQ | GT | GE | LT | LE | NE | NE2 + : EQ + | GT + | GE + | LT + | LE + | NE + | NE2 ; expression_list @@ -602,18 +607,13 @@ true_false ; case - : CASE expression - WHEN expression THEN expression - (WHEN expression THEN expression)* - (ELSE expression)? - END + : CASE expression WHEN expression THEN expression (WHEN expression THEN expression)* ( + ELSE expression + )? END ; case_when - : CASE WHEN expression THEN expression - (WHEN expression THEN expression)? - (ELSE expression)? - END + : CASE WHEN expression THEN expression (WHEN expression THEN expression)? (ELSE expression)? END ; row_value_constructor @@ -679,4 +679,4 @@ hbase_data_type | UNSIGNED_LONG | UNSIGNED_FLOAT | UNSIGNED_DOUBLE - ; + ; \ No newline at end of file diff --git a/sql/plsql/Dart/PlSqlLexer.g4 b/sql/plsql/Dart/PlSqlLexer.g4 index 6584360f09..7eb85c24ac 100644 --- a/sql/plsql/Dart/PlSqlLexer.g4 +++ b/sql/plsql/Dart/PlSqlLexer.g4 @@ -18,13 +18,17 @@ * limitations under the License. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PlSqlLexer; options { - superClass=PlSqlLexerBase; + superClass = PlSqlLexerBase; } -@lexer::header{ +@lexer::header { import 'PlSqlLexerBase.dart'; } @@ -32,2224 +36,2224 @@ options { #include } -ABORT: 'ABORT'; -ABS: 'ABS'; -ACCESS: 'ACCESS'; -ACCESSED: 'ACCESSED'; -ACCOUNT: 'ACCOUNT'; -ACL: 'ACL'; -ACOS: 'ACOS'; -ACTION: 'ACTION'; -ACTIONS: 'ACTIONS'; -ACTIVATE: 'ACTIVATE'; -ACTIVE: 'ACTIVE'; -ACTIVE_COMPONENT: 'ACTIVE_COMPONENT'; -ACTIVE_DATA: 'ACTIVE_DATA'; -ACTIVE_FUNCTION: 'ACTIVE_FUNCTION'; -ACTIVE_TAG: 'ACTIVE_TAG'; -ACTIVITY: 'ACTIVITY'; -ADAPTIVE_PLAN: 'ADAPTIVE_PLAN'; -ADD: 'ADD'; -ADD_COLUMN: 'ADD_COLUMN'; -ADD_GROUP: 'ADD_GROUP'; -ADD_MONTHS: 'ADD_MONTHS'; -ADJ_DATE: 'ADJ_DATE'; -ADMIN: 'ADMIN'; -ADMINISTER: 'ADMINISTER'; -ADMINISTRATOR: 'ADMINISTRATOR'; -ADVANCED: 'ADVANCED'; -ADVISE: 'ADVISE'; -ADVISOR: 'ADVISOR'; -AFD_DISKSTRING: 'AFD_DISKSTRING'; -AFTER: 'AFTER'; -AGENT: 'AGENT'; -AGGREGATE: 'AGGREGATE'; -A_LETTER: 'A'; -ALIAS: 'ALIAS'; -ALL: 'ALL'; -ALLOCATE: 'ALLOCATE'; -ALLOW: 'ALLOW'; -ALL_ROWS: 'ALL_ROWS'; -ALTER: 'ALTER'; -ALWAYS: 'ALWAYS'; -ANALYZE: 'ANALYZE'; -ANCILLARY: 'ANCILLARY'; -AND: 'AND'; -AND_EQUAL: 'AND_EQUAL'; -ANOMALY: 'ANOMALY'; -ANSI_REARCH: 'ANSI_REARCH'; -ANTIJOIN: 'ANTIJOIN'; -ANY: 'ANY'; -ANYSCHEMA: 'ANYSCHEMA'; -APPEND: 'APPEND'; -APPENDCHILDXML: 'APPENDCHILDXML'; -APPEND_VALUES: 'APPEND_VALUES'; -APPLICATION: 'APPLICATION'; -APPLY: 'APPLY'; -APPROX_COUNT_DISTINCT: 'APPROX_COUNT_DISTINCT'; -ARCHIVAL: 'ARCHIVAL'; -ARCHIVE: 'ARCHIVE'; -ARCHIVED: 'ARCHIVED'; -ARCHIVELOG: 'ARCHIVELOG'; -ARRAY: 'ARRAY'; -AS: 'AS'; -ASC: 'ASC'; -ASCII: 'ASCII'; -ASCIISTR: 'ASCIISTR'; -ASIN: 'ASIN'; -ASIS: 'ASIS'; -ASSEMBLY: 'ASSEMBLY'; -ASSIGN: 'ASSIGN'; -ASSOCIATE: 'ASSOCIATE'; -ASYNC: 'ASYNC'; -ASYNCHRONOUS: 'ASYNCHRONOUS'; -ATAN2: 'ATAN2'; -ATAN: 'ATAN'; -AT: 'AT'; -ATTRIBUTE: 'ATTRIBUTE'; -ATTRIBUTES: 'ATTRIBUTES'; -AUDIT: 'AUDIT'; -AUTHENTICATED: 'AUTHENTICATED'; -AUTHENTICATION: 'AUTHENTICATION'; -AUTHID: 'AUTHID'; -AUTHORIZATION: 'AUTHORIZATION'; -AUTOALLOCATE: 'AUTOALLOCATE'; -AUTO: 'AUTO'; -AUTOBACKUP: 'AUTOBACKUP'; -AUTOEXTEND: 'AUTOEXTEND'; -AUTO_LOGIN: 'AUTO_LOGIN'; -AUTOMATIC: 'AUTOMATIC'; -AUTONOMOUS_TRANSACTION: 'AUTONOMOUS_TRANSACTION'; -AUTO_REOPTIMIZE: 'AUTO_REOPTIMIZE'; -AVAILABILITY: 'AVAILABILITY'; -AVRO: 'AVRO'; -BACKGROUND: 'BACKGROUND'; -BACKUP: 'BACKUP'; -BACKUPSET: 'BACKUPSET'; -BASIC: 'BASIC'; -BASICFILE: 'BASICFILE'; -BATCH: 'BATCH'; -BATCHSIZE: 'BATCHSIZE'; -BATCH_TABLE_ACCESS_BY_ROWID: 'BATCH_TABLE_ACCESS_BY_ROWID'; -BECOME: 'BECOME'; -BEFORE: 'BEFORE'; -BEGIN: 'BEGIN'; -BEGINNING: 'BEGINNING'; -BEGIN_OUTLINE_DATA: 'BEGIN_OUTLINE_DATA'; -BEHALF: 'BEHALF'; -BEQUEATH: 'BEQUEATH'; -BETWEEN: 'BETWEEN'; -BFILE: 'BFILE'; -BFILENAME: 'BFILENAME'; -BIGFILE: 'BIGFILE'; -BINARY: 'BINARY'; -BINARY_DOUBLE: 'BINARY_DOUBLE'; -BINARY_DOUBLE_INFINITY: 'BINARY_DOUBLE_INFINITY'; -BINARY_DOUBLE_NAN: 'BINARY_DOUBLE_NAN'; -BINARY_FLOAT: 'BINARY_FLOAT'; -BINARY_FLOAT_INFINITY: 'BINARY_FLOAT_INFINITY'; -BINARY_FLOAT_NAN: 'BINARY_FLOAT_NAN'; -BINARY_INTEGER: 'BINARY_INTEGER'; -BIND_AWARE: 'BIND_AWARE'; -BINDING: 'BINDING'; -BIN_TO_NUM: 'BIN_TO_NUM'; -BITAND: 'BITAND'; -BITMAP_AND: 'BITMAP_AND'; -BITMAP: 'BITMAP'; -BITMAPS: 'BITMAPS'; -BITMAP_TREE: 'BITMAP_TREE'; -BITS: 'BITS'; -BLOB: 'BLOB'; -BLOCK: 'BLOCK'; -BLOCK_RANGE: 'BLOCK_RANGE'; -BLOCKS: 'BLOCKS'; -BLOCKSIZE: 'BLOCKSIZE'; -BODY: 'BODY'; -BOOLEAN: 'BOOLEAN'; -BOTH: 'BOTH'; -BOUND: 'BOUND'; -BRANCH: 'BRANCH'; -BREADTH: 'BREADTH'; -BROADCAST: 'BROADCAST'; -BSON: 'BSON'; -BUFFER: 'BUFFER'; -BUFFER_CACHE: 'BUFFER_CACHE'; -BUFFER_POOL: 'BUFFER_POOL'; -BUILD: 'BUILD'; -BULK: 'BULK'; -BY: 'BY'; -BYPASS_RECURSIVE_CHECK: 'BYPASS_RECURSIVE_CHECK'; -BYPASS_UJVC: 'BYPASS_UJVC'; -BYTE: 'BYTE'; -CACHE: 'CACHE'; -CACHE_CB: 'CACHE_CB'; -CACHE_INSTANCES: 'CACHE_INSTANCES'; -CACHE_TEMP_TABLE: 'CACHE_TEMP_TABLE'; -CACHING: 'CACHING'; -CALCULATED: 'CALCULATED'; -CALLBACK: 'CALLBACK'; -CALL: 'CALL'; -CANCEL: 'CANCEL'; -CANONICAL: 'CANONICAL'; -CAPACITY: 'CAPACITY'; -CARDINALITY: 'CARDINALITY'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CAST: 'CAST'; -CATEGORY: 'CATEGORY'; -CDBDEFAULT: 'CDB$DEFAULT'; -CEIL: 'CEIL'; -CELL_FLASH_CACHE: 'CELL_FLASH_CACHE'; -CERTIFICATE: 'CERTIFICATE'; -CFILE: 'CFILE'; -CHAINED: 'CHAINED'; -CHANGE: 'CHANGE'; -CHANGETRACKING: 'CHANGETRACKING'; -CHANGE_DUPKEY_ERROR_INDEX: 'CHANGE_DUPKEY_ERROR_INDEX'; -CHARACTER: 'CHARACTER'; -CHAR: 'CHAR'; -CHAR_CS: 'CHAR_CS'; -CHARTOROWID: 'CHARTOROWID'; -CHECK_ACL_REWRITE: 'CHECK_ACL_REWRITE'; -CHECK: 'CHECK'; -CHECKPOINT: 'CHECKPOINT'; -CHILD: 'CHILD'; -CHOOSE: 'CHOOSE'; -CHR: 'CHR'; -CHUNK: 'CHUNK'; -CLASS: 'CLASS'; -CLASSIFIER: 'CLASSIFIER'; -CLEANUP: 'CLEANUP'; -CLEAR: 'CLEAR'; -C_LETTER: 'C'; -CLIENT: 'CLIENT'; -CLOB: 'CLOB'; -CLONE: 'CLONE'; -CLOSE_CACHED_OPEN_CURSORS: 'CLOSE_CACHED_OPEN_CURSORS'; -CLOSE: 'CLOSE'; -CLUSTER_BY_ROWID: 'CLUSTER_BY_ROWID'; -CLUSTER: 'CLUSTER'; -CLUSTER_DETAILS: 'CLUSTER_DETAILS'; -CLUSTER_DISTANCE: 'CLUSTER_DISTANCE'; -CLUSTER_ID: 'CLUSTER_ID'; -CLUSTERING: 'CLUSTERING'; -CLUSTERING_FACTOR: 'CLUSTERING_FACTOR'; -CLUSTER_PROBABILITY: 'CLUSTER_PROBABILITY'; -CLUSTER_SET: 'CLUSTER_SET'; -COALESCE: 'COALESCE'; -COALESCE_SQ: 'COALESCE_SQ'; -COARSE: 'COARSE'; -CO_AUTH_IND: 'CO_AUTH_IND'; -COLD: 'COLD'; -COLLECT: 'COLLECT'; -COLUMNAR: 'COLUMNAR'; -COLUMN_AUTH_INDICATOR: 'COLUMN_AUTH_INDICATOR'; -COLUMN: 'COLUMN'; -COLUMNS: 'COLUMNS'; -COLUMN_STATS: 'COLUMN_STATS'; -COLUMN_VALUE: 'COLUMN_VALUE'; -COMMENT: 'COMMENT'; -COMMIT: 'COMMIT'; -COMMITTED: 'COMMITTED'; -COMMON_DATA: 'COMMON_DATA'; -COMPACT: 'COMPACT'; -COMPATIBILITY: 'COMPATIBILITY'; -COMPILE: 'COMPILE'; -COMPLETE: 'COMPLETE'; -COMPLIANCE: 'COMPLIANCE'; -COMPONENT: 'COMPONENT'; -COMPONENTS: 'COMPONENTS'; -COMPOSE: 'COMPOSE'; -COMPOSITE: 'COMPOSITE'; -COMPOSITE_LIMIT: 'COMPOSITE_LIMIT'; -COMPOUND: 'COMPOUND'; -COMPRESS: 'COMPRESS'; -COMPUTE: 'COMPUTE'; -CONCAT: 'CONCAT'; -CON_DBID_TO_ID: 'CON_DBID_TO_ID'; -CONDITIONAL: 'CONDITIONAL'; -CONDITION: 'CONDITION'; -CONFIRM: 'CONFIRM'; -CONFORMING: 'CONFORMING'; -CON_GUID_TO_ID: 'CON_GUID_TO_ID'; -CON_ID: 'CON_ID'; -CON_NAME_TO_ID: 'CON_NAME_TO_ID'; -CONNECT_BY_CB_WHR_ONLY: 'CONNECT_BY_CB_WHR_ONLY'; -CONNECT_BY_COMBINE_SW: 'CONNECT_BY_COMBINE_SW'; -CONNECT_BY_COST_BASED: 'CONNECT_BY_COST_BASED'; -CONNECT_BY_ELIM_DUPS: 'CONNECT_BY_ELIM_DUPS'; -CONNECT_BY_FILTERING: 'CONNECT_BY_FILTERING'; -CONNECT_BY_ISCYCLE: 'CONNECT_BY_ISCYCLE'; -CONNECT_BY_ISLEAF: 'CONNECT_BY_ISLEAF'; -CONNECT_BY_ROOT: 'CONNECT_BY_ROOT'; -CONNECT: 'CONNECT'; -CONNECT_TIME: 'CONNECT_TIME'; -CONSIDER: 'CONSIDER'; -CONSISTENT: 'CONSISTENT'; -CONSTANT: 'CONSTANT'; -CONST: 'CONST'; -CONSTRAINT: 'CONSTRAINT'; -CONSTRAINTS: 'CONSTRAINTS'; -CONSTRUCTOR: 'CONSTRUCTOR'; -CONTAINER: 'CONTAINER'; -CONTAINER_DATA: 'CONTAINER_DATA'; -CONTAINERS: 'CONTAINERS'; -CONTENT: 'CONTENT'; -CONTENTS: 'CONTENTS'; -CONTEXT: 'CONTEXT'; -CONTINUE: 'CONTINUE'; -CONTROLFILE: 'CONTROLFILE'; -CON_UID_TO_ID: 'CON_UID_TO_ID'; -CONVERT: 'CONVERT'; -COOKIE: 'COOKIE'; -COPY: 'COPY'; -CORR_K: 'CORR_K'; -CORR_S: 'CORR_S'; -CORRUPTION: 'CORRUPTION'; -CORRUPT_XID_ALL: 'CORRUPT_XID_ALL'; -CORRUPT_XID: 'CORRUPT_XID'; -COS: 'COS'; -COSH: 'COSH'; -COST: 'COST'; -COST_XML_QUERY_REWRITE: 'COST_XML_QUERY_REWRITE'; -COUNT: 'COUNT'; -COVAR_POP: 'COVAR_POP'; -COVAR_SAMP: 'COVAR_SAMP'; -CPU_COSTING: 'CPU_COSTING'; -CPU_PER_CALL: 'CPU_PER_CALL'; -CPU_PER_SESSION: 'CPU_PER_SESSION'; -CRASH: 'CRASH'; -CREATE: 'CREATE'; -CREATE_FILE_DEST: 'CREATE_FILE_DEST'; -CREATE_STORED_OUTLINES: 'CREATE_STORED_OUTLINES'; -CREATION: 'CREATION'; -CREDENTIAL: 'CREDENTIAL'; -CRITICAL: 'CRITICAL'; -CROSS: 'CROSS'; -CROSSEDITION: 'CROSSEDITION'; -CSCONVERT: 'CSCONVERT'; -CUBE_AJ: 'CUBE_AJ'; -CUBE: 'CUBE'; -CUBE_GB: 'CUBE_GB'; -CUBE_SJ: 'CUBE_SJ'; -CUME_DISTM: 'CUME_DISTM'; -CURRENT: 'CURRENT'; -CURRENT_DATE: 'CURRENT_DATE'; -CURRENT_SCHEMA: 'CURRENT_SCHEMA'; -CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -CURRENT_USER: 'CURRENT_USER'; -CURRENTV: 'CURRENTV'; -CURSOR: 'CURSOR'; -CURSOR_SHARING_EXACT: 'CURSOR_SHARING_EXACT'; -CURSOR_SPECIFIC_SEGMENT: 'CURSOR_SPECIFIC_SEGMENT'; -CUSTOMDATUM: 'CUSTOMDATUM'; -CV: 'CV'; -CYCLE: 'CYCLE'; -DANGLING: 'DANGLING'; -DATABASE: 'DATABASE'; -DATA: 'DATA'; -DATAFILE: 'DATAFILE'; -DATAFILES: 'DATAFILES'; -DATAGUARDCONFIG: 'DATAGUARDCONFIG'; -DATAMOVEMENT: 'DATAMOVEMENT'; -DATAOBJNO: 'DATAOBJNO'; -DATAOBJ_TO_MAT_PARTITION: 'DATAOBJ_TO_MAT_PARTITION'; -DATAOBJ_TO_PARTITION: 'DATAOBJ_TO_PARTITION'; -DATAPUMP: 'DATAPUMP'; -DATA_SECURITY_REWRITE_LIMIT: 'DATA_SECURITY_REWRITE_LIMIT'; -DATE: 'DATE'; -DATE_MODE: 'DATE_MODE'; -DAY: 'DAY'; -DAYS: 'DAYS'; -DBA: 'DBA'; -DBA_RECYCLEBIN: 'DBA_RECYCLEBIN'; -DBMS_STATS: 'DBMS_STATS'; -DB_ROLE_CHANGE: 'DB_ROLE_CHANGE'; -DBTIMEZONE: 'DBTIMEZONE'; -DB_UNIQUE_NAME: 'DB_UNIQUE_NAME'; -DB_VERSION: 'DB_VERSION'; -DDL: 'DDL'; -DEALLOCATE: 'DEALLOCATE'; -DEBUG: 'DEBUG'; -DEBUGGER: 'DEBUGGER'; -DEC: 'DEC'; -DECIMAL: 'DECIMAL'; -DECLARE: 'DECLARE'; -DECOMPOSE: 'DECOMPOSE'; -DECORRELATE: 'DECORRELATE'; -DECR: 'DECR'; -DECREMENT: 'DECREMENT'; -DECRYPT: 'DECRYPT'; -DEDUPLICATE: 'DEDUPLICATE'; -DEFAULT: 'DEFAULT'; -DEFAULTS: 'DEFAULTS'; -DEFERRABLE: 'DEFERRABLE'; -DEFERRED: 'DEFERRED'; -DEFINED: 'DEFINED'; -DEFINE: 'DEFINE'; -DEFINER: 'DEFINER'; -DEGREE: 'DEGREE'; -DELAY: 'DELAY'; -DELEGATE: 'DELEGATE'; -DELETE_ALL: 'DELETE_ALL'; -DELETE: 'DELETE'; -DELETEXML: 'DELETEXML'; -DEMAND: 'DEMAND'; -DENSE_RANKM: 'DENSE_RANKM'; -DEPENDENT: 'DEPENDENT'; -DEPTH: 'DEPTH'; -DEQUEUE: 'DEQUEUE'; -DEREF: 'DEREF'; -DEREF_NO_REWRITE: 'DEREF_NO_REWRITE'; -DESC: 'DESC'; -DESTROY: 'DESTROY'; -DETACHED: 'DETACHED'; -DETERMINES: 'DETERMINES'; -DETERMINISTIC: 'DETERMINISTIC'; -DICTIONARY: 'DICTIONARY'; -DIMENSION: 'DIMENSION'; -DIMENSIONS: 'DIMENSIONS'; -DIRECT_LOAD: 'DIRECT_LOAD'; -DIRECTORY: 'DIRECTORY'; -DIRECT_PATH: 'DIRECT_PATH'; -DISABLE_ALL: 'DISABLE_ALL'; -DISABLE: 'DISABLE'; -DISABLE_PARALLEL_DML: 'DISABLE_PARALLEL_DML'; -DISABLE_PRESET: 'DISABLE_PRESET'; -DISABLE_RPKE: 'DISABLE_RPKE'; -DISALLOW: 'DISALLOW'; -DISASSOCIATE: 'DISASSOCIATE'; -DISCARD: 'DISCARD'; -DISCONNECT: 'DISCONNECT'; -DISK: 'DISK'; -DISKGROUP: 'DISKGROUP'; -DISKGROUP_PLUS: '\'+ DISKGROUP'; -DISKS: 'DISKS'; -DISMOUNT: 'DISMOUNT'; -DISTINCT: 'DISTINCT'; -DISTINGUISHED: 'DISTINGUISHED'; -DISTRIBUTED: 'DISTRIBUTED'; -DISTRIBUTE: 'DISTRIBUTE'; -DML: 'DML'; -DML_UPDATE: 'DML_UPDATE'; -DOCFIDELITY: 'DOCFIDELITY'; -DOCUMENT: 'DOCUMENT'; -DOMAIN_INDEX_FILTER: 'DOMAIN_INDEX_FILTER'; -DOMAIN_INDEX_NO_SORT: 'DOMAIN_INDEX_NO_SORT'; -DOMAIN_INDEX_SORT: 'DOMAIN_INDEX_SORT'; -DOUBLE: 'DOUBLE'; -DOWNGRADE: 'DOWNGRADE'; -DRIVING_SITE: 'DRIVING_SITE'; -DROP_COLUMN: 'DROP_COLUMN'; -DROP: 'DROP'; -DROP_GROUP: 'DROP_GROUP'; -DSINTERVAL_UNCONSTRAINED: 'DSINTERVAL_UNCONSTRAINED'; -DST_UPGRADE_INSERT_CONV: 'DST_UPGRADE_INSERT_CONV'; -DUMP: 'DUMP'; -DUMPSET: 'DUMPSET'; -DUPLICATE: 'DUPLICATE'; -DV: 'DV'; -DYNAMIC: 'DYNAMIC'; -DYNAMIC_SAMPLING: 'DYNAMIC_SAMPLING'; -DYNAMIC_SAMPLING_EST_CDN: 'DYNAMIC_SAMPLING_EST_CDN'; -EACH: 'EACH'; -EDITIONABLE: 'EDITIONABLE'; -EDITION: 'EDITION'; -EDITIONING: 'EDITIONING'; -EDITIONS: 'EDITIONS'; -ELEMENT: 'ELEMENT'; -ELIM_GROUPBY: 'ELIM_GROUPBY'; -ELIMINATE_JOIN: 'ELIMINATE_JOIN'; -ELIMINATE_OBY: 'ELIMINATE_OBY'; -ELIMINATE_OUTER_JOIN: 'ELIMINATE_OUTER_JOIN'; -ELSE: 'ELSE'; -ELSIF: 'ELSIF'; -EM: 'EM'; -EMPTY_BLOB: 'EMPTY_BLOB'; -EMPTY_CLOB: 'EMPTY_CLOB'; -EMPTY: 'EMPTY'; -ENABLE_ALL: 'ENABLE_ALL'; -ENABLE: 'ENABLE'; -ENABLE_PARALLEL_DML: 'ENABLE_PARALLEL_DML'; -ENABLE_PRESET: 'ENABLE_PRESET'; -ENCODING: 'ENCODING'; -ENCRYPT: 'ENCRYPT'; -ENCRYPTION: 'ENCRYPTION'; -END: 'END'; -END_OUTLINE_DATA: 'END_OUTLINE_DATA'; -ENFORCED: 'ENFORCED'; -ENFORCE: 'ENFORCE'; -ENQUEUE: 'ENQUEUE'; -ENTERPRISE: 'ENTERPRISE'; -ENTITYESCAPING: 'ENTITYESCAPING'; -ENTRY: 'ENTRY'; -EQUIPART: 'EQUIPART'; -ERR: 'ERR'; -ERROR_ARGUMENT: 'ERROR_ARGUMENT'; -ERROR: 'ERROR'; -ERROR_ON_OVERLAP_TIME: 'ERROR_ON_OVERLAP_TIME'; -ERRORS: 'ERRORS'; -ESCAPE: 'ESCAPE'; -ESTIMATE: 'ESTIMATE'; -EVAL: 'EVAL'; -EVALNAME: 'EVALNAME'; -EVALUATE: 'EVALUATE'; -EVALUATION: 'EVALUATION'; -EVENTS: 'EVENTS'; -EVERY: 'EVERY'; -EXCEPT: 'EXCEPT'; -EXCEPTION: 'EXCEPTION'; -EXCEPTION_INIT: 'EXCEPTION_INIT'; -EXCEPTIONS: 'EXCEPTIONS'; -EXCHANGE: 'EXCHANGE'; -EXCLUDE: 'EXCLUDE'; -EXCLUDING: 'EXCLUDING'; -EXCLUSIVE: 'EXCLUSIVE'; -EXECUTE: 'EXECUTE'; -EXEMPT: 'EXEMPT'; -EXISTING: 'EXISTING'; -EXISTS: 'EXISTS'; -EXISTSNODE: 'EXISTSNODE'; -EXIT: 'EXIT'; -EXPAND_GSET_TO_UNION: 'EXPAND_GSET_TO_UNION'; -EXPAND_TABLE: 'EXPAND_TABLE'; -EXP: 'EXP'; -EXPIRE: 'EXPIRE'; -EXPLAIN: 'EXPLAIN'; -EXPLOSION: 'EXPLOSION'; -EXPORT: 'EXPORT'; -EXPR_CORR_CHECK: 'EXPR_CORR_CHECK'; -EXPRESS: 'EXPRESS'; -EXTENDS: 'EXTENDS'; -EXTENT: 'EXTENT'; -EXTENTS: 'EXTENTS'; -EXTERNAL: 'EXTERNAL'; -EXTERNALLY: 'EXTERNALLY'; -EXTRACTCLOBXML: 'EXTRACTCLOBXML'; -EXTRACT: 'EXTRACT'; -EXTRACTVALUE: 'EXTRACTVALUE'; -EXTRA: 'EXTRA'; -FACILITY: 'FACILITY'; -FACT: 'FACT'; -FACTOR: 'FACTOR'; -FACTORIZE_JOIN: 'FACTORIZE_JOIN'; -FAILED: 'FAILED'; -FAILED_LOGIN_ATTEMPTS: 'FAILED_LOGIN_ATTEMPTS'; -FAILGROUP: 'FAILGROUP'; -FAILOVER: 'FAILOVER'; -FAILURE: 'FAILURE'; -FALSE: 'FALSE'; -FAMILY: 'FAMILY'; -FAR: 'FAR'; -FAST: 'FAST'; -FASTSTART: 'FASTSTART'; -FBTSCAN: 'FBTSCAN'; -FEATURE_DETAILS: 'FEATURE_DETAILS'; -FEATURE_ID: 'FEATURE_ID'; -FEATURE_SET: 'FEATURE_SET'; -FEATURE_VALUE: 'FEATURE_VALUE'; -FETCH: 'FETCH'; -FILE: 'FILE'; -FILE_NAME_CONVERT: 'FILE_NAME_CONVERT'; -FILESYSTEM_LIKE_LOGGING: 'FILESYSTEM_LIKE_LOGGING'; -FILTER: 'FILTER'; -FINAL: 'FINAL'; -FINE: 'FINE'; -FINISH: 'FINISH'; -FIRST: 'FIRST'; -FIRSTM: 'FIRSTM'; -FIRST_ROWS: 'FIRST_ROWS'; -FIRST_VALUE: 'FIRST_VALUE'; -FIXED_VIEW_DATA: 'FIXED_VIEW_DATA'; -FLAGGER: 'FLAGGER'; -FLASHBACK: 'FLASHBACK'; -FLASH_CACHE: 'FLASH_CACHE'; -FLOAT: 'FLOAT'; -FLOB: 'FLOB'; -FLOOR: 'FLOOR'; -FLUSH: 'FLUSH'; -FOLDER: 'FOLDER'; -FOLLOWING: 'FOLLOWING'; -FOLLOWS: 'FOLLOWS'; -FORALL: 'FORALL'; -FORCE: 'FORCE'; -FORCE_XML_QUERY_REWRITE: 'FORCE_XML_QUERY_REWRITE'; -FOREIGN: 'FOREIGN'; -FOREVER: 'FOREVER'; -FOR: 'FOR'; -FORMAT: 'FORMAT'; -FORWARD: 'FORWARD'; -FRAGMENT_NUMBER: 'FRAGMENT_NUMBER'; -FREELIST: 'FREELIST'; -FREELISTS: 'FREELISTS'; -FREEPOOLS: 'FREEPOOLS'; -FRESH: 'FRESH'; -FROM: 'FROM'; -FROM_TZ: 'FROM_TZ'; -FULL: 'FULL'; -FULL_OUTER_JOIN_TO_OUTER: 'FULL_OUTER_JOIN_TO_OUTER'; -FUNCTION: 'FUNCTION'; -FUNCTIONS: 'FUNCTIONS'; -GATHER_OPTIMIZER_STATISTICS: 'GATHER_OPTIMIZER_STATISTICS'; -GATHER_PLAN_STATISTICS: 'GATHER_PLAN_STATISTICS'; -GBY_CONC_ROLLUP: 'GBY_CONC_ROLLUP'; -GBY_PUSHDOWN: 'GBY_PUSHDOWN'; -GENERATED: 'GENERATED'; -GET: 'GET'; -GLOBAL: 'GLOBAL'; -GLOBALLY: 'GLOBALLY'; -GLOBAL_NAME: 'GLOBAL_NAME'; -GLOBAL_TOPIC_ENABLED: 'GLOBAL_TOPIC_ENABLED'; -GOTO: 'GOTO'; -GRANT: 'GRANT'; -GROUP_BY: 'GROUP_BY'; -GROUP: 'GROUP'; -GROUP_ID: 'GROUP_ID'; -GROUPING: 'GROUPING'; -GROUPING_ID: 'GROUPING_ID'; -GROUPS: 'GROUPS'; -GUARANTEED: 'GUARANTEED'; -GUARANTEE: 'GUARANTEE'; -GUARD: 'GUARD'; -HASH_AJ: 'HASH_AJ'; -HASH: 'HASH'; -HASHKEYS: 'HASHKEYS'; -HASH_SJ: 'HASH_SJ'; -HAVING: 'HAVING'; -HEADER: 'HEADER'; -HEAP: 'HEAP'; -HELP: 'HELP'; -HEXTORAW: 'HEXTORAW'; -HEXTOREF: 'HEXTOREF'; -HIDDEN_KEYWORD: 'HIDDEN'; -HIDE: 'HIDE'; -HIERARCHY: 'HIERARCHY'; -HIGH: 'HIGH'; -HINTSET_BEGIN: 'HINTSET_BEGIN'; -HINTSET_END: 'HINTSET_END'; -HOT: 'HOT'; -HOUR: 'HOUR'; -HWM_BROKERED: 'HWM_BROKERED'; -HYBRID: 'HYBRID'; -IDENTIFIED: 'IDENTIFIED'; -IDENTIFIER: 'IDENTIFIER'; -IDENTITY: 'IDENTITY'; -IDGENERATORS: 'IDGENERATORS'; -ID: 'ID'; -IDLE_TIME: 'IDLE_TIME'; -IF: 'IF'; -IGNORE: 'IGNORE'; -IGNORE_OPTIM_EMBEDDED_HINTS: 'IGNORE_OPTIM_EMBEDDED_HINTS'; -IGNORE_ROW_ON_DUPKEY_INDEX: 'IGNORE_ROW_ON_DUPKEY_INDEX'; -IGNORE_WHERE_CLAUSE: 'IGNORE_WHERE_CLAUSE'; -ILM: 'ILM'; -IMMEDIATE: 'IMMEDIATE'; -IMPACT: 'IMPACT'; -IMPORT: 'IMPORT'; -INACTIVE: 'INACTIVE'; -INCLUDE: 'INCLUDE'; -INCLUDE_VERSION: 'INCLUDE_VERSION'; -INCLUDING: 'INCLUDING'; -INCREMENTAL: 'INCREMENTAL'; -INCREMENT: 'INCREMENT'; -INCR: 'INCR'; -INDENT: 'INDENT'; -INDEX_ASC: 'INDEX_ASC'; -INDEX_COMBINE: 'INDEX_COMBINE'; -INDEX_DESC: 'INDEX_DESC'; -INDEXED: 'INDEXED'; -INDEXES: 'INDEXES'; -INDEX_FFS: 'INDEX_FFS'; -INDEX_FILTER: 'INDEX_FILTER'; -INDEX: 'INDEX'; -INDEXING: 'INDEXING'; -INDEX_JOIN: 'INDEX_JOIN'; -INDEX_ROWS: 'INDEX_ROWS'; -INDEX_RRS: 'INDEX_RRS'; -INDEX_RS_ASC: 'INDEX_RS_ASC'; -INDEX_RS_DESC: 'INDEX_RS_DESC'; -INDEX_RS: 'INDEX_RS'; -INDEX_SCAN: 'INDEX_SCAN'; -INDEX_SKIP_SCAN: 'INDEX_SKIP_SCAN'; -INDEX_SS_ASC: 'INDEX_SS_ASC'; -INDEX_SS_DESC: 'INDEX_SS_DESC'; -INDEX_SS: 'INDEX_SS'; -INDEX_STATS: 'INDEX_STATS'; -INDEXTYPE: 'INDEXTYPE'; -INDEXTYPES: 'INDEXTYPES'; -INDICATOR: 'INDICATOR'; -INDICES: 'INDICES'; -INFINITE: 'INFINITE'; -INFORMATIONAL: 'INFORMATIONAL'; -INHERIT: 'INHERIT'; -IN: 'IN'; -INITCAP: 'INITCAP'; -INITIAL: 'INITIAL'; -INITIALIZED: 'INITIALIZED'; -INITIALLY: 'INITIALLY'; -INITRANS: 'INITRANS'; -INLINE: 'INLINE'; -INLINE_XMLTYPE_NT: 'INLINE_XMLTYPE_NT'; -INMEMORY: 'INMEMORY'; -IN_MEMORY_METADATA: 'IN_MEMORY_METADATA'; -INMEMORY_PRUNING: 'INMEMORY_PRUNING'; -INNER: 'INNER'; -INOUT: 'INOUT'; -INPLACE: 'INPLACE'; -INSERTCHILDXMLAFTER: 'INSERTCHILDXMLAFTER'; -INSERTCHILDXMLBEFORE: 'INSERTCHILDXMLBEFORE'; -INSERTCHILDXML: 'INSERTCHILDXML'; -INSERT: 'INSERT'; -INSERTXMLAFTER: 'INSERTXMLAFTER'; -INSERTXMLBEFORE: 'INSERTXMLBEFORE'; -INSTANCE: 'INSTANCE'; -INSTANCES: 'INSTANCES'; -INSTANTIABLE: 'INSTANTIABLE'; -INSTANTLY: 'INSTANTLY'; -INSTEAD: 'INSTEAD'; -INSTR2: 'INSTR2'; -INSTR4: 'INSTR4'; -INSTRB: 'INSTRB'; -INSTRC: 'INSTRC'; -INSTR: 'INSTR'; -INTEGER: 'INTEGER'; -INTERLEAVED: 'INTERLEAVED'; -INTERMEDIATE: 'INTERMEDIATE'; -INTERNAL_CONVERT: 'INTERNAL_CONVERT'; -INTERNAL_USE: 'INTERNAL_USE'; -INTERPRETED: 'INTERPRETED'; -INTERSECT: 'INTERSECT'; -INTERVAL: 'INTERVAL'; -INT: 'INT'; -INTO: 'INTO'; -INVALIDATE: 'INVALIDATE'; -INVISIBLE: 'INVISIBLE'; -IN_XQUERY: 'IN_XQUERY'; -IS: 'IS'; -ISOLATION: 'ISOLATION'; -ISOLATION_LEVEL: 'ISOLATION_LEVEL'; -ITERATE: 'ITERATE'; -ITERATION_NUMBER: 'ITERATION_NUMBER'; -JAVA: 'JAVA'; -JOB: 'JOB'; -JOIN: 'JOIN'; -JSON_ARRAYAGG: 'JSON_ARRAYAGG'; -JSON_ARRAY: 'JSON_ARRAY'; -JSON_EQUAL: 'JSON_EQUAL'; -JSON_EXISTS2: 'JSON_EXISTS2'; -JSON_EXISTS: 'JSON_EXISTS'; -JSONGET: 'JSONGET'; -JSON: 'JSON'; -JSON_OBJECTAGG: 'JSON_OBJECTAGG'; -JSON_OBJECT: 'JSON_OBJECT'; -JSONPARSE: 'JSONPARSE'; -JSON_QUERY: 'JSON_QUERY'; -JSON_SERIALIZE: 'JSON_SERIALIZE'; -JSON_TABLE: 'JSON_TABLE'; -JSON_TEXTCONTAINS2: 'JSON_TEXTCONTAINS2'; -JSON_TEXTCONTAINS: 'JSON_TEXTCONTAINS'; -JSON_VALUE: 'JSON_VALUE'; -KEEP_DUPLICATES: 'KEEP_DUPLICATES'; -KEEP: 'KEEP'; -KERBEROS: 'KERBEROS'; -KEY: 'KEY'; -KEY_LENGTH: 'KEY_LENGTH'; -KEYSIZE: 'KEYSIZE'; -KEYS: 'KEYS'; -KEYSTORE: 'KEYSTORE'; -KILL: 'KILL'; -LABEL: 'LABEL'; -LANGUAGE: 'LANGUAGE'; -LAST_DAY: 'LAST_DAY'; -LAST: 'LAST'; -LAST_VALUE: 'LAST_VALUE'; -LATERAL: 'LATERAL'; -LAX: 'LAX'; -LAYER: 'LAYER'; -LDAP_REGISTRATION_ENABLED: 'LDAP_REGISTRATION_ENABLED'; -LDAP_REGISTRATION: 'LDAP_REGISTRATION'; -LDAP_REG_SYNC_INTERVAL: 'LDAP_REG_SYNC_INTERVAL'; -LEADING: 'LEADING'; -LEFT: 'LEFT'; -LENGTH2: 'LENGTH2'; -LENGTH4: 'LENGTH4'; -LENGTHB: 'LENGTHB'; -LENGTHC: 'LENGTHC'; -LENGTH: 'LENGTH'; -LESS: 'LESS'; -LEVEL: 'LEVEL'; -LEVELS: 'LEVELS'; -LIBRARY: 'LIBRARY'; -LIFECYCLE: 'LIFECYCLE'; -LIFE: 'LIFE'; -LIFETIME: 'LIFETIME'; -LIKE2: 'LIKE2'; -LIKE4: 'LIKE4'; -LIKEC: 'LIKEC'; -LIKE_EXPAND: 'LIKE_EXPAND'; -LIKE: 'LIKE'; -LIMIT: 'LIMIT'; -LINEAR: 'LINEAR'; -LINK: 'LINK'; -LIST: 'LIST'; -LN: 'LN'; -LNNVL: 'LNNVL'; -LOAD: 'LOAD'; -LOB: 'LOB'; -LOBNVL: 'LOBNVL'; -LOBS: 'LOBS'; -LOCAL_INDEXES: 'LOCAL_INDEXES'; -LOCAL: 'LOCAL'; -LOCALTIME: 'LOCALTIME'; -LOCALTIMESTAMP: 'LOCALTIMESTAMP'; -LOCATION: 'LOCATION'; -LOCATOR: 'LOCATOR'; -LOCKED: 'LOCKED'; -LOCKING: 'LOCKING'; -LOCK: 'LOCK'; -LOGFILE: 'LOGFILE'; -LOGFILES: 'LOGFILES'; -LOGGING: 'LOGGING'; -LOGICAL: 'LOGICAL'; -LOGICAL_READS_PER_CALL: 'LOGICAL_READS_PER_CALL'; -LOGICAL_READS_PER_SESSION: 'LOGICAL_READS_PER_SESSION'; -LOG: 'LOG'; -LOGMINING: 'LOGMINING'; -LOGOFF: 'LOGOFF'; -LOGON: 'LOGON'; -LOG_READ_ONLY_VIOLATIONS: 'LOG_READ_ONLY_VIOLATIONS'; -LONG: 'LONG'; -LOOP: 'LOOP'; -LOWER: 'LOWER'; -LOW: 'LOW'; -LPAD: 'LPAD'; -LTRIM: 'LTRIM'; -MAIN: 'MAIN'; -MAKE_REF: 'MAKE_REF'; -MANAGED: 'MANAGED'; -MANAGE: 'MANAGE'; -MANAGEMENT: 'MANAGEMENT'; -MANAGER: 'MANAGER'; -MANUAL: 'MANUAL'; -MAP: 'MAP'; -MAPPING: 'MAPPING'; -MASTER: 'MASTER'; -MATCHED: 'MATCHED'; -MATCHES: 'MATCHES'; -MATCH: 'MATCH'; -MATCH_NUMBER: 'MATCH_NUMBER'; -MATCH_RECOGNIZE: 'MATCH_RECOGNIZE'; -MATERIALIZED: 'MATERIALIZED'; -MATERIALIZE: 'MATERIALIZE'; -MAXARCHLOGS: 'MAXARCHLOGS'; -MAXDATAFILES: 'MAXDATAFILES'; -MAXEXTENTS: 'MAXEXTENTS'; -MAXIMIZE: 'MAXIMIZE'; -MAXINSTANCES: 'MAXINSTANCES'; -MAXLOGFILES: 'MAXLOGFILES'; -MAXLOGHISTORY: 'MAXLOGHISTORY'; -MAXLOGMEMBERS: 'MAXLOGMEMBERS'; -MAX_SHARED_TEMP_SIZE: 'MAX_SHARED_TEMP_SIZE'; -MAXSIZE: 'MAXSIZE'; -MAXTRANS: 'MAXTRANS'; -MAXVALUE: 'MAXVALUE'; -MEASURE: 'MEASURE'; -MEASURES: 'MEASURES'; -MEDIUM: 'MEDIUM'; -MEMBER: 'MEMBER'; -MEMCOMPRESS: 'MEMCOMPRESS'; -MEMORY: 'MEMORY'; -MERGEACTIONS: 'MERGE$ACTIONS'; -MERGE_AJ: 'MERGE_AJ'; -MERGE_CONST_ON: 'MERGE_CONST_ON'; -MERGE: 'MERGE'; -MERGE_SJ: 'MERGE_SJ'; -METADATA: 'METADATA'; -METHOD: 'METHOD'; -MIGRATE: 'MIGRATE'; -MIGRATION: 'MIGRATION'; -MINEXTENTS: 'MINEXTENTS'; -MINIMIZE: 'MINIMIZE'; -MINIMUM: 'MINIMUM'; -MINING: 'MINING'; -MINUS: 'MINUS'; -MINUS_NULL: 'MINUS_NULL'; -MINUTE: 'MINUTE'; -MINVALUE: 'MINVALUE'; -MIRRORCOLD: 'MIRRORCOLD'; -MIRRORHOT: 'MIRRORHOT'; -MIRROR: 'MIRROR'; -MLSLABEL: 'MLSLABEL'; -MODEL_COMPILE_SUBQUERY: 'MODEL_COMPILE_SUBQUERY'; -MODEL_DONTVERIFY_UNIQUENESS: 'MODEL_DONTVERIFY_UNIQUENESS'; -MODEL_DYNAMIC_SUBQUERY: 'MODEL_DYNAMIC_SUBQUERY'; -MODEL_MIN_ANALYSIS: 'MODEL_MIN_ANALYSIS'; -MODEL: 'MODEL'; -MODEL_NB: 'MODEL_NB'; -MODEL_NO_ANALYSIS: 'MODEL_NO_ANALYSIS'; -MODEL_PBY: 'MODEL_PBY'; -MODEL_PUSH_REF: 'MODEL_PUSH_REF'; -MODEL_SV: 'MODEL_SV'; -MODE: 'MODE'; -MODIFICATION: 'MODIFICATION'; -MODIFY_COLUMN_TYPE: 'MODIFY_COLUMN_TYPE'; -MODIFY: 'MODIFY'; -MOD: 'MOD'; -MODULE: 'MODULE'; -MONITORING: 'MONITORING'; -MONITOR: 'MONITOR'; -MONTH: 'MONTH'; -MONTHS_BETWEEN: 'MONTHS_BETWEEN'; -MONTHS: 'MONTHS'; -MOUNT: 'MOUNT'; -MOUNTPATH: 'MOUNTPATH'; -MOVEMENT: 'MOVEMENT'; -MOVE: 'MOVE'; -MULTIDIMENSIONAL: 'MULTIDIMENSIONAL'; -MULTISET: 'MULTISET'; -MV_MERGE: 'MV_MERGE'; -NAMED: 'NAMED'; -NAME: 'NAME'; -NAMESPACE: 'NAMESPACE'; -NAN: 'NAN'; -NANVL: 'NANVL'; -NATIONAL: 'NATIONAL'; -NATIVE_FULL_OUTER_JOIN: 'NATIVE_FULL_OUTER_JOIN'; -NATIVE: 'NATIVE'; -NATURAL: 'NATURAL'; -NATURALN: 'NATURALN'; -NAV: 'NAV'; -NCHAR_CS: 'NCHAR_CS'; -NCHAR: 'NCHAR'; -NCHR: 'NCHR'; -NCLOB: 'NCLOB'; -NEEDED: 'NEEDED'; -NEG: 'NEG'; -NESTED: 'NESTED'; -NESTED_TABLE_FAST_INSERT: 'NESTED_TABLE_FAST_INSERT'; -NESTED_TABLE_GET_REFS: 'NESTED_TABLE_GET_REFS'; -NESTED_TABLE_ID: 'NESTED_TABLE_ID'; -NESTED_TABLE_SET_REFS: 'NESTED_TABLE_SET_REFS'; -NESTED_TABLE_SET_SETID: 'NESTED_TABLE_SET_SETID'; -NETWORK: 'NETWORK'; -NEVER: 'NEVER'; -NEW: 'NEW'; -NEW_TIME: 'NEW_TIME'; -NEXT_DAY: 'NEXT_DAY'; -NEXT: 'NEXT'; -NL_AJ: 'NL_AJ'; -NLJ_BATCHING: 'NLJ_BATCHING'; -NLJ_INDEX_FILTER: 'NLJ_INDEX_FILTER'; -NLJ_INDEX_SCAN: 'NLJ_INDEX_SCAN'; -NLJ_PREFETCH: 'NLJ_PREFETCH'; -NLS_CALENDAR: 'NLS_CALENDAR'; -NLS_CHARACTERSET: 'NLS_CHARACTERSET'; -NLS_CHARSET_DECL_LEN: 'NLS_CHARSET_DECL_LEN'; -NLS_CHARSET_ID: 'NLS_CHARSET_ID'; -NLS_CHARSET_NAME: 'NLS_CHARSET_NAME'; -NLS_COMP: 'NLS_COMP'; -NLS_CURRENCY: 'NLS_CURRENCY'; -NLS_DATE_FORMAT: 'NLS_DATE_FORMAT'; -NLS_DATE_LANGUAGE: 'NLS_DATE_LANGUAGE'; -NLS_INITCAP: 'NLS_INITCAP'; -NLS_ISO_CURRENCY: 'NLS_ISO_CURRENCY'; -NL_SJ: 'NL_SJ'; -NLS_LANG: 'NLS_LANG'; -NLS_LANGUAGE: 'NLS_LANGUAGE'; -NLS_LENGTH_SEMANTICS: 'NLS_LENGTH_SEMANTICS'; -NLS_LOWER: 'NLS_LOWER'; -NLS_NCHAR_CONV_EXCP: 'NLS_NCHAR_CONV_EXCP'; -NLS_NUMERIC_CHARACTERS: 'NLS_NUMERIC_CHARACTERS'; -NLS_SORT: 'NLS_SORT'; -NLSSORT: 'NLSSORT'; -NLS_SPECIAL_CHARS: 'NLS_SPECIAL_CHARS'; -NLS_TERRITORY: 'NLS_TERRITORY'; -NLS_UPPER: 'NLS_UPPER'; -NO_ACCESS: 'NO_ACCESS'; -NO_ADAPTIVE_PLAN: 'NO_ADAPTIVE_PLAN'; -NO_ANSI_REARCH: 'NO_ANSI_REARCH'; -NOAPPEND: 'NOAPPEND'; -NOARCHIVELOG: 'NOARCHIVELOG'; -NOAUDIT: 'NOAUDIT'; -NO_AUTO_REOPTIMIZE: 'NO_AUTO_REOPTIMIZE'; -NO_BASETABLE_MULTIMV_REWRITE: 'NO_BASETABLE_MULTIMV_REWRITE'; -NO_BATCH_TABLE_ACCESS_BY_ROWID: 'NO_BATCH_TABLE_ACCESS_BY_ROWID'; -NO_BIND_AWARE: 'NO_BIND_AWARE'; -NO_BUFFER: 'NO_BUFFER'; -NOCACHE: 'NOCACHE'; -NO_CARTESIAN: 'NO_CARTESIAN'; -NO_CHECK_ACL_REWRITE: 'NO_CHECK_ACL_REWRITE'; -NO_CLUSTER_BY_ROWID: 'NO_CLUSTER_BY_ROWID'; -NO_CLUSTERING: 'NO_CLUSTERING'; -NO_COALESCE_SQ: 'NO_COALESCE_SQ'; -NO_COMMON_DATA: 'NO_COMMON_DATA'; -NOCOMPRESS: 'NOCOMPRESS'; -NO_CONNECT_BY_CB_WHR_ONLY: 'NO_CONNECT_BY_CB_WHR_ONLY'; -NO_CONNECT_BY_COMBINE_SW: 'NO_CONNECT_BY_COMBINE_SW'; -NO_CONNECT_BY_COST_BASED: 'NO_CONNECT_BY_COST_BASED'; -NO_CONNECT_BY_ELIM_DUPS: 'NO_CONNECT_BY_ELIM_DUPS'; -NO_CONNECT_BY_FILTERING: 'NO_CONNECT_BY_FILTERING'; -NOCOPY: 'NOCOPY'; -NO_COST_XML_QUERY_REWRITE: 'NO_COST_XML_QUERY_REWRITE'; -NO_CPU_COSTING: 'NO_CPU_COSTING'; -NOCPU_COSTING: 'NOCPU_COSTING'; -NOCYCLE: 'NOCYCLE'; -NO_DATA_SECURITY_REWRITE: 'NO_DATA_SECURITY_REWRITE'; -NO_DECORRELATE: 'NO_DECORRELATE'; -NODELAY: 'NODELAY'; -NO_DOMAIN_INDEX_FILTER: 'NO_DOMAIN_INDEX_FILTER'; -NO_DST_UPGRADE_INSERT_CONV: 'NO_DST_UPGRADE_INSERT_CONV'; -NO_ELIM_GROUPBY: 'NO_ELIM_GROUPBY'; -NO_ELIMINATE_JOIN: 'NO_ELIMINATE_JOIN'; -NO_ELIMINATE_OBY: 'NO_ELIMINATE_OBY'; -NO_ELIMINATE_OUTER_JOIN: 'NO_ELIMINATE_OUTER_JOIN'; -NOENTITYESCAPING: 'NOENTITYESCAPING'; -NO_EXPAND_GSET_TO_UNION: 'NO_EXPAND_GSET_TO_UNION'; -NO_EXPAND: 'NO_EXPAND'; -NO_EXPAND_TABLE: 'NO_EXPAND_TABLE'; -NO_FACT: 'NO_FACT'; -NO_FACTORIZE_JOIN: 'NO_FACTORIZE_JOIN'; -NO_FILTERING: 'NO_FILTERING'; -NOFORCE: 'NOFORCE'; -NO_FULL_OUTER_JOIN_TO_OUTER: 'NO_FULL_OUTER_JOIN_TO_OUTER'; -NO_GATHER_OPTIMIZER_STATISTICS: 'NO_GATHER_OPTIMIZER_STATISTICS'; -NO_GBY_PUSHDOWN: 'NO_GBY_PUSHDOWN'; -NOGUARANTEE: 'NOGUARANTEE'; -NO_INDEX_FFS: 'NO_INDEX_FFS'; -NO_INDEX: 'NO_INDEX'; -NO_INDEX_SS: 'NO_INDEX_SS'; -NO_INMEMORY: 'NO_INMEMORY'; -NO_INMEMORY_PRUNING: 'NO_INMEMORY_PRUNING'; -NOKEEP: 'NOKEEP'; -NO_LOAD: 'NO_LOAD'; -NOLOCAL: 'NOLOCAL'; -NOLOGGING: 'NOLOGGING'; -NOMAPPING: 'NOMAPPING'; -NOMAXVALUE: 'NOMAXVALUE'; -NO_MERGE: 'NO_MERGE'; -NOMINIMIZE: 'NOMINIMIZE'; -NOMINVALUE: 'NOMINVALUE'; -NO_MODEL_PUSH_REF: 'NO_MODEL_PUSH_REF'; -NO_MONITORING: 'NO_MONITORING'; -NOMONITORING: 'NOMONITORING'; -NO_MONITOR: 'NO_MONITOR'; -NO_MULTIMV_REWRITE: 'NO_MULTIMV_REWRITE'; -NO_NATIVE_FULL_OUTER_JOIN: 'NO_NATIVE_FULL_OUTER_JOIN'; -NONBLOCKING: 'NONBLOCKING'; -NONEDITIONABLE: 'NONEDITIONABLE'; -NONE: 'NONE'; -NO_NLJ_BATCHING: 'NO_NLJ_BATCHING'; -NO_NLJ_PREFETCH: 'NO_NLJ_PREFETCH'; -NO: 'NO'; -NONSCHEMA: 'NONSCHEMA'; -NO_OBJECT_LINK: 'NO_OBJECT_LINK'; -NOORDER: 'NOORDER'; -NO_ORDER_ROLLUPS: 'NO_ORDER_ROLLUPS'; -NO_OUTER_JOIN_TO_ANTI: 'NO_OUTER_JOIN_TO_ANTI'; -NO_OUTER_JOIN_TO_INNER: 'NO_OUTER_JOIN_TO_INNER'; -NOOVERRIDE: 'NOOVERRIDE'; -NO_PARALLEL_INDEX: 'NO_PARALLEL_INDEX'; -NOPARALLEL_INDEX: 'NOPARALLEL_INDEX'; -NO_PARALLEL: 'NO_PARALLEL'; -NOPARALLEL: 'NOPARALLEL'; -NO_PARTIAL_COMMIT: 'NO_PARTIAL_COMMIT'; -NO_PARTIAL_JOIN: 'NO_PARTIAL_JOIN'; -NO_PARTIAL_ROLLUP_PUSHDOWN: 'NO_PARTIAL_ROLLUP_PUSHDOWN'; -NOPARTITION: 'NOPARTITION'; -NO_PLACE_DISTINCT: 'NO_PLACE_DISTINCT'; -NO_PLACE_GROUP_BY: 'NO_PLACE_GROUP_BY'; -NO_PQ_CONCURRENT_UNION: 'NO_PQ_CONCURRENT_UNION'; -NO_PQ_MAP: 'NO_PQ_MAP'; -NO_PQ_REPLICATE: 'NO_PQ_REPLICATE'; -NO_PQ_SKEW: 'NO_PQ_SKEW'; -NO_PRUNE_GSETS: 'NO_PRUNE_GSETS'; -NO_PULL_PRED: 'NO_PULL_PRED'; -NO_PUSH_PRED: 'NO_PUSH_PRED'; -NO_PUSH_SUBQ: 'NO_PUSH_SUBQ'; -NO_PX_FAULT_TOLERANCE: 'NO_PX_FAULT_TOLERANCE'; -NO_PX_JOIN_FILTER: 'NO_PX_JOIN_FILTER'; -NO_QKN_BUFF: 'NO_QKN_BUFF'; -NO_QUERY_TRANSFORMATION: 'NO_QUERY_TRANSFORMATION'; -NO_REF_CASCADE: 'NO_REF_CASCADE'; -NORELOCATE: 'NORELOCATE'; -NORELY: 'NORELY'; -NOREPAIR: 'NOREPAIR'; -NOREPLAY: 'NOREPLAY'; -NORESETLOGS: 'NORESETLOGS'; -NO_RESULT_CACHE: 'NO_RESULT_CACHE'; -NOREVERSE: 'NOREVERSE'; -NO_REWRITE: 'NO_REWRITE'; -NOREWRITE: 'NOREWRITE'; -NORMAL: 'NORMAL'; -NO_ROOT_SW_FOR_LOCAL: 'NO_ROOT_SW_FOR_LOCAL'; -NOROWDEPENDENCIES: 'NOROWDEPENDENCIES'; -NOSCHEMACHECK: 'NOSCHEMACHECK'; -NOSEGMENT: 'NOSEGMENT'; -NO_SEMIJOIN: 'NO_SEMIJOIN'; -NO_SEMI_TO_INNER: 'NO_SEMI_TO_INNER'; -NO_SET_TO_JOIN: 'NO_SET_TO_JOIN'; -NOSORT: 'NOSORT'; -NO_SQL_TRANSLATION: 'NO_SQL_TRANSLATION'; -NO_SQL_TUNE: 'NO_SQL_TUNE'; -NO_STAR_TRANSFORMATION: 'NO_STAR_TRANSFORMATION'; -NO_STATEMENT_QUEUING: 'NO_STATEMENT_QUEUING'; -NO_STATS_GSETS: 'NO_STATS_GSETS'; -NOSTRICT: 'NOSTRICT'; -NO_SUBQUERY_PRUNING: 'NO_SUBQUERY_PRUNING'; -NO_SUBSTRB_PAD: 'NO_SUBSTRB_PAD'; -NO_SWAP_JOIN_INPUTS: 'NO_SWAP_JOIN_INPUTS'; -NOSWITCH: 'NOSWITCH'; -NO_TABLE_LOOKUP_BY_NL: 'NO_TABLE_LOOKUP_BY_NL'; -NO_TEMP_TABLE: 'NO_TEMP_TABLE'; -NOTHING: 'NOTHING'; -NOTIFICATION: 'NOTIFICATION'; -NOT: 'NOT'; -NO_TRANSFORM_DISTINCT_AGG: 'NO_TRANSFORM_DISTINCT_AGG'; -NO_UNNEST: 'NO_UNNEST'; -NO_USE_CUBE: 'NO_USE_CUBE'; -NO_USE_HASH_AGGREGATION: 'NO_USE_HASH_AGGREGATION'; -NO_USE_HASH_GBY_FOR_PUSHDOWN: 'NO_USE_HASH_GBY_FOR_PUSHDOWN'; -NO_USE_HASH: 'NO_USE_HASH'; -NO_USE_INVISIBLE_INDEXES: 'NO_USE_INVISIBLE_INDEXES'; -NO_USE_MERGE: 'NO_USE_MERGE'; -NO_USE_NL: 'NO_USE_NL'; -NO_USE_VECTOR_AGGREGATION: 'NO_USE_VECTOR_AGGREGATION'; -NOVALIDATE: 'NOVALIDATE'; -NO_VECTOR_TRANSFORM_DIMS: 'NO_VECTOR_TRANSFORM_DIMS'; -NO_VECTOR_TRANSFORM_FACT: 'NO_VECTOR_TRANSFORM_FACT'; -NO_VECTOR_TRANSFORM: 'NO_VECTOR_TRANSFORM'; -NOWAIT: 'NOWAIT'; -NO_XDB_FASTPATH_INSERT: 'NO_XDB_FASTPATH_INSERT'; -NO_XML_DML_REWRITE: 'NO_XML_DML_REWRITE'; -NO_XMLINDEX_REWRITE_IN_SELECT: 'NO_XMLINDEX_REWRITE_IN_SELECT'; -NO_XMLINDEX_REWRITE: 'NO_XMLINDEX_REWRITE'; -NO_XML_QUERY_REWRITE: 'NO_XML_QUERY_REWRITE'; -NO_ZONEMAP: 'NO_ZONEMAP'; -NTH_VALUE: 'NTH_VALUE'; -NULLIF: 'NULLIF'; -NULL_: 'NULL'; -NULLS: 'NULLS'; -NUMBER: 'NUMBER'; -NUMERIC: 'NUMERIC'; -NUM_INDEX_KEYS: 'NUM_INDEX_KEYS'; -NUMTODSINTERVAL: 'NUMTODSINTERVAL'; -NUMTOYMINTERVAL: 'NUMTOYMINTERVAL'; -NVARCHAR2: 'NVARCHAR2'; -NVL2: 'NVL2'; -OBJECT2XML: 'OBJECT2XML'; -OBJECT: 'OBJECT'; -OBJ_ID: 'OBJ_ID'; -OBJNO: 'OBJNO'; -OBJNO_REUSE: 'OBJNO_REUSE'; -OCCURENCES: 'OCCURENCES'; -OFFLINE: 'OFFLINE'; -OFF: 'OFF'; -OFFSET: 'OFFSET'; -OF: 'OF'; -OIDINDEX: 'OIDINDEX'; -OID: 'OID'; -OLAP: 'OLAP'; -OLD: 'OLD'; -OLD_PUSH_PRED: 'OLD_PUSH_PRED'; -OLS: 'OLS'; -OLTP: 'OLTP'; -OMIT: 'OMIT'; -ONE: 'ONE'; -ONLINE: 'ONLINE'; -ONLINELOG: 'ONLINELOG'; -ONLY: 'ONLY'; -ON: 'ON'; -OPAQUE: 'OPAQUE'; -OPAQUE_TRANSFORM: 'OPAQUE_TRANSFORM'; -OPAQUE_XCANONICAL: 'OPAQUE_XCANONICAL'; -OPCODE: 'OPCODE'; -OPEN: 'OPEN'; -OPERATIONS: 'OPERATIONS'; -OPERATOR: 'OPERATOR'; -OPT_ESTIMATE: 'OPT_ESTIMATE'; -OPTIMAL: 'OPTIMAL'; -OPTIMIZE: 'OPTIMIZE'; -OPTIMIZER_FEATURES_ENABLE: 'OPTIMIZER_FEATURES_ENABLE'; -OPTIMIZER_GOAL: 'OPTIMIZER_GOAL'; -OPTION: 'OPTION'; -OPT_PARAM: 'OPT_PARAM'; -ORA_BRANCH: 'ORA_BRANCH'; -ORA_CHECK_ACL: 'ORA_CHECK_ACL'; -ORA_CHECK_PRIVILEGE: 'ORA_CHECK_PRIVILEGE'; -ORA_CLUSTERING: 'ORA_CLUSTERING'; -ORADATA: 'ORADATA'; -ORADEBUG: 'ORADEBUG'; -ORA_DST_AFFECTED: 'ORA_DST_AFFECTED'; -ORA_DST_CONVERT: 'ORA_DST_CONVERT'; -ORA_DST_ERROR: 'ORA_DST_ERROR'; -ORA_GET_ACLIDS: 'ORA_GET_ACLIDS'; -ORA_GET_PRIVILEGES: 'ORA_GET_PRIVILEGES'; -ORA_HASH: 'ORA_HASH'; -ORA_INVOKING_USERID: 'ORA_INVOKING_USERID'; -ORA_INVOKING_USER: 'ORA_INVOKING_USER'; -ORA_INVOKING_XS_USER_GUID: 'ORA_INVOKING_XS_USER_GUID'; -ORA_INVOKING_XS_USER: 'ORA_INVOKING_XS_USER'; -ORA_RAWCOMPARE: 'ORA_RAWCOMPARE'; -ORA_RAWCONCAT: 'ORA_RAWCONCAT'; -ORA_ROWSCN: 'ORA_ROWSCN'; -ORA_ROWSCN_RAW: 'ORA_ROWSCN_RAW'; -ORA_ROWVERSION: 'ORA_ROWVERSION'; -ORA_TABVERSION: 'ORA_TABVERSION'; -ORA_WRITE_TIME: 'ORA_WRITE_TIME'; -ORDERED: 'ORDERED'; -ORDERED_PREDICATES: 'ORDERED_PREDICATES'; -ORDER: 'ORDER'; -ORDINALITY: 'ORDINALITY'; -OR_EXPAND: 'OR_EXPAND'; -ORGANIZATION: 'ORGANIZATION'; -OR: 'OR'; -OR_PREDICATES: 'OR_PREDICATES'; -OSERROR: 'OSERROR'; -OTHER: 'OTHER'; -OUTER_JOIN_TO_ANTI: 'OUTER_JOIN_TO_ANTI'; -OUTER_JOIN_TO_INNER: 'OUTER_JOIN_TO_INNER'; -OUTER: 'OUTER'; -OUTLINE_LEAF: 'OUTLINE_LEAF'; -OUTLINE: 'OUTLINE'; -OUT_OF_LINE: 'OUT_OF_LINE'; -OUT: 'OUT'; -OVERFLOW_NOMOVE: 'OVERFLOW_NOMOVE'; -OVERFLOW: 'OVERFLOW'; -OVERLAPS: 'OVERLAPS'; -OVER: 'OVER'; -OVERRIDING: 'OVERRIDING'; -OWNER: 'OWNER'; -OWNERSHIP: 'OWNERSHIP'; -OWN: 'OWN'; -PACKAGE: 'PACKAGE'; -PACKAGES: 'PACKAGES'; -PARALLEL_ENABLE: 'PARALLEL_ENABLE'; -PARALLEL_INDEX: 'PARALLEL_INDEX'; -PARALLEL: 'PARALLEL'; -PARAMETERFILE: 'PARAMETERFILE'; -PARAMETERS: 'PARAMETERS'; -PARAM: 'PARAM'; -PARENT: 'PARENT'; -PARITY: 'PARITY'; -PARTIAL_JOIN: 'PARTIAL_JOIN'; -PARTIALLY: 'PARTIALLY'; -PARTIAL: 'PARTIAL'; -PARTIAL_ROLLUP_PUSHDOWN: 'PARTIAL_ROLLUP_PUSHDOWN'; -PARTITION_HASH: 'PARTITION_HASH'; -PARTITION_LIST: 'PARTITION_LIST'; -PARTITION: 'PARTITION'; -PARTITION_RANGE: 'PARTITION_RANGE'; -PARTITIONS: 'PARTITIONS'; -PARTNUMINST: 'PART$NUM$INST'; -PASSING: 'PASSING'; -PASSWORD_GRACE_TIME: 'PASSWORD_GRACE_TIME'; -PASSWORD_LIFE_TIME: 'PASSWORD_LIFE_TIME'; -PASSWORD_LOCK_TIME: 'PASSWORD_LOCK_TIME'; -PASSWORD: 'PASSWORD'; -PASSWORD_REUSE_MAX: 'PASSWORD_REUSE_MAX'; -PASSWORD_REUSE_TIME: 'PASSWORD_REUSE_TIME'; -PASSWORD_VERIFY_FUNCTION: 'PASSWORD_VERIFY_FUNCTION'; -PAST: 'PAST'; -PATCH: 'PATCH'; -PATH: 'PATH'; -PATH_PREFIX: 'PATH_PREFIX'; -PATHS: 'PATHS'; -PATTERN: 'PATTERN'; -PBL_HS_BEGIN: 'PBL_HS_BEGIN'; -PBL_HS_END: 'PBL_HS_END'; -PCTFREE: 'PCTFREE'; -PCTINCREASE: 'PCTINCREASE'; -PCTTHRESHOLD: 'PCTTHRESHOLD'; -PCTUSED: 'PCTUSED'; -PCTVERSION: 'PCTVERSION'; -PENDING: 'PENDING'; -PERCENT_FOUND: '%' SPACE* 'FOUND'; -PERCENT_ISOPEN: '%' SPACE* 'ISOPEN'; -PERCENT_NOTFOUND: '%' SPACE* 'NOTFOUND'; -PERCENT_KEYWORD: 'PERCENT'; -PERCENT_RANKM: 'PERCENT_RANKM'; -PERCENT_ROWCOUNT: '%' SPACE* 'ROWCOUNT'; -PERCENT_ROWTYPE: '%' SPACE* 'ROWTYPE'; -PERCENT_TYPE: '%' SPACE* 'TYPE'; -PERFORMANCE: 'PERFORMANCE'; -PERIOD_KEYWORD: 'PERIOD'; -PERMANENT: 'PERMANENT'; -PERMISSION: 'PERMISSION'; -PERMUTE: 'PERMUTE'; -PER: 'PER'; -PFILE: 'PFILE'; -PHYSICAL: 'PHYSICAL'; -PIKEY: 'PIKEY'; -PIPELINED: 'PIPELINED'; -PIPE: 'PIPE'; -PIV_GB: 'PIV_GB'; -PIVOT: 'PIVOT'; -PIV_SSF: 'PIV_SSF'; -PLACE_DISTINCT: 'PLACE_DISTINCT'; -PLACE_GROUP_BY: 'PLACE_GROUP_BY'; -PLAN: 'PLAN'; -PLSCOPE_SETTINGS: 'PLSCOPE_SETTINGS'; -PLS_INTEGER: 'PLS_INTEGER'; -PLSQL_CCFLAGS: 'PLSQL_CCFLAGS'; -PLSQL_CODE_TYPE: 'PLSQL_CODE_TYPE'; -PLSQL_DEBUG: 'PLSQL_DEBUG'; -PLSQL_OPTIMIZE_LEVEL: 'PLSQL_OPTIMIZE_LEVEL'; -PLSQL_WARNINGS: 'PLSQL_WARNINGS'; -PLUGGABLE: 'PLUGGABLE'; -POINT: 'POINT'; -POLICY: 'POLICY'; -POOL_16K: 'POOL_16K'; -POOL_2K: 'POOL_2K'; -POOL_32K: 'POOL_32K'; -POOL_4K: 'POOL_4K'; -POOL_8K: 'POOL_8K'; -POSITIVEN: 'POSITIVEN'; -POSITIVE: 'POSITIVE'; -POST_TRANSACTION: 'POST_TRANSACTION'; -POWERMULTISET_BY_CARDINALITY: 'POWERMULTISET_BY_CARDINALITY'; -POWERMULTISET: 'POWERMULTISET'; -POWER: 'POWER'; -PQ_CONCURRENT_UNION: 'PQ_CONCURRENT_UNION'; -PQ_DISTRIBUTE: 'PQ_DISTRIBUTE'; -PQ_DISTRIBUTE_WINDOW: 'PQ_DISTRIBUTE_WINDOW'; -PQ_FILTER: 'PQ_FILTER'; -PQ_MAP: 'PQ_MAP'; -PQ_NOMAP: 'PQ_NOMAP'; -PQ_REPLICATE: 'PQ_REPLICATE'; -PQ_SKEW: 'PQ_SKEW'; -PRAGMA: 'PRAGMA'; -PREBUILT: 'PREBUILT'; -PRECEDES: 'PRECEDES'; -PRECEDING: 'PRECEDING'; -PRECISION: 'PRECISION'; -PRECOMPUTE_SUBQUERY: 'PRECOMPUTE_SUBQUERY'; -PREDICATE_REORDERS: 'PREDICATE_REORDERS'; -PRELOAD: 'PRELOAD'; -PREPARE: 'PREPARE'; -PRESENTNNV: 'PRESENTNNV'; -PRESENT: 'PRESENT'; -PRESENTV: 'PRESENTV'; -PRESERVE_OID: 'PRESERVE_OID'; -PRESERVE: 'PRESERVE'; -PRETTY: 'PRETTY'; -PREVIOUS: 'PREVIOUS'; -PREV: 'PREV'; -PRIMARY: 'PRIMARY'; -PRINTBLOBTOCLOB: 'PRINTBLOBTOCLOB'; -PRIORITY: 'PRIORITY'; -PRIOR: 'PRIOR'; -PRIVATE: 'PRIVATE'; -PRIVATE_SGA: 'PRIVATE_SGA'; -PRIVILEGED: 'PRIVILEGED'; -PRIVILEGE: 'PRIVILEGE'; -PRIVILEGES: 'PRIVILEGES'; -PROCEDURAL: 'PROCEDURAL'; -PROCEDURE: 'PROCEDURE'; -PROCESS: 'PROCESS'; -PROFILE: 'PROFILE'; -PROGRAM: 'PROGRAM'; -PROJECT: 'PROJECT'; -PROPAGATE: 'PROPAGATE'; -PROTECTED: 'PROTECTED'; -PROTECTION: 'PROTECTION'; -PROXY: 'PROXY'; -PRUNING: 'PRUNING'; -PUBLIC: 'PUBLIC'; -PULL_PRED: 'PULL_PRED'; -PURGE: 'PURGE'; -PUSH_PRED: 'PUSH_PRED'; -PUSH_SUBQ: 'PUSH_SUBQ'; -PX_FAULT_TOLERANCE: 'PX_FAULT_TOLERANCE'; -PX_GRANULE: 'PX_GRANULE'; -PX_JOIN_FILTER: 'PX_JOIN_FILTER'; -QB_NAME: 'QB_NAME'; -QUERY_BLOCK: 'QUERY_BLOCK'; -QUERY: 'QUERY'; -QUEUE_CURR: 'QUEUE_CURR'; -QUEUE: 'QUEUE'; -QUEUE_ROWP: 'QUEUE_ROWP'; -QUIESCE: 'QUIESCE'; -QUORUM: 'QUORUM'; -QUOTA: 'QUOTA'; -RAISE: 'RAISE'; -RANDOM_LOCAL: 'RANDOM_LOCAL'; -RANDOM: 'RANDOM'; -RANGE: 'RANGE'; -RANKM: 'RANKM'; -RAPIDLY: 'RAPIDLY'; -RAW: 'RAW'; -RAWTOHEX: 'RAWTOHEX'; -RAWTONHEX: 'RAWTONHEX'; -RBA: 'RBA'; -RBO_OUTLINE: 'RBO_OUTLINE'; -RDBA: 'RDBA'; -READ: 'READ'; -READS: 'READS'; -REALM: 'REALM'; -REAL: 'REAL'; -REBALANCE: 'REBALANCE'; -REBUILD: 'REBUILD'; -RECORD: 'RECORD'; -RECORDS_PER_BLOCK: 'RECORDS_PER_BLOCK'; -RECOVERABLE: 'RECOVERABLE'; -RECOVER: 'RECOVER'; -RECOVERY: 'RECOVERY'; -RECYCLEBIN: 'RECYCLEBIN'; -RECYCLE: 'RECYCLE'; -REDACTION: 'REDACTION'; -REDEFINE: 'REDEFINE'; -REDO: 'REDO'; -REDUCED: 'REDUCED'; -REDUNDANCY: 'REDUNDANCY'; -REF_CASCADE_CURSOR: 'REF_CASCADE_CURSOR'; -REFERENCED: 'REFERENCED'; -REFERENCE: 'REFERENCE'; -REFERENCES: 'REFERENCES'; -REFERENCING: 'REFERENCING'; -REF: 'REF'; -REFRESH: 'REFRESH'; -REFTOHEX: 'REFTOHEX'; -REGEXP_COUNT: 'REGEXP_COUNT'; -REGEXP_INSTR: 'REGEXP_INSTR'; -REGEXP_LIKE: 'REGEXP_LIKE'; -REGEXP_REPLACE: 'REGEXP_REPLACE'; -REGEXP_SUBSTR: 'REGEXP_SUBSTR'; -REGISTER: 'REGISTER'; -REGR_AVGX: 'REGR_AVGX'; -REGR_AVGY: 'REGR_AVGY'; -REGR_COUNT: 'REGR_COUNT'; -REGR_INTERCEPT: 'REGR_INTERCEPT'; -REGR_R2: 'REGR_R2'; -REGR_SLOPE: 'REGR_SLOPE'; -REGR_SXX: 'REGR_SXX'; -REGR_SXY: 'REGR_SXY'; -REGR_SYY: 'REGR_SYY'; -REGULAR: 'REGULAR'; -REJECT: 'REJECT'; -REKEY: 'REKEY'; -RELATIONAL: 'RELATIONAL'; -RELIES_ON: 'RELIES_ON'; -RELOCATE: 'RELOCATE'; -RELY: 'RELY'; -REMAINDER: 'REMAINDER'; -REMOTE_MAPPED: 'REMOTE_MAPPED'; -REMOVE: 'REMOVE'; -RENAME: 'RENAME'; -REPAIR: 'REPAIR'; -REPEAT: 'REPEAT'; -REPLACE: 'REPLACE'; -REPLICATION: 'REPLICATION'; -REQUIRED: 'REQUIRED'; -RESETLOGS: 'RESETLOGS'; -RESET: 'RESET'; -RESIZE: 'RESIZE'; -RESOLVE: 'RESOLVE'; -RESOLVER: 'RESOLVER'; -RESOURCE: 'RESOURCE'; -RESPECT: 'RESPECT'; -RESTART: 'RESTART'; -RESTORE_AS_INTERVALS: 'RESTORE_AS_INTERVALS'; -RESTORE: 'RESTORE'; -RESTRICT_ALL_REF_CONS: 'RESTRICT_ALL_REF_CONS'; -RESTRICTED: 'RESTRICTED'; -RESTRICT_REFERENCES: 'RESTRICT_REFERENCES'; -RESTRICT: 'RESTRICT'; -RESULT_CACHE: 'RESULT_CACHE'; -RESULT: 'RESULT'; -RESUMABLE: 'RESUMABLE'; -RESUME: 'RESUME'; -RETENTION: 'RETENTION'; -RETRY_ON_ROW_CHANGE: 'RETRY_ON_ROW_CHANGE'; -RETURNING: 'RETURNING'; -RETURN: 'RETURN'; -REUSE: 'REUSE'; -REVERSE: 'REVERSE'; -REVOKE: 'REVOKE'; -REWRITE_OR_ERROR: 'REWRITE_OR_ERROR'; -REWRITE: 'REWRITE'; -RIGHT: 'RIGHT'; -ROLE: 'ROLE'; -ROLESET: 'ROLESET'; -ROLES: 'ROLES'; -ROLLBACK: 'ROLLBACK'; -ROLLING: 'ROLLING'; -ROLLUP: 'ROLLUP'; -ROWDEPENDENCIES: 'ROWDEPENDENCIES'; -ROWID_MAPPING_TABLE: 'ROWID_MAPPING_TABLE'; -ROWID: 'ROWID'; -ROWIDTOCHAR: 'ROWIDTOCHAR'; -ROWIDTONCHAR: 'ROWIDTONCHAR'; -ROW_LENGTH: 'ROW_LENGTH'; -ROWNUM: 'ROWNUM'; -ROW: 'ROW'; -ROWS: 'ROWS'; -RPAD: 'RPAD'; -RTRIM: 'RTRIM'; -RULE: 'RULE'; -RULES: 'RULES'; -RUNNING: 'RUNNING'; -SALT: 'SALT'; -SAMPLE: 'SAMPLE'; -SAVE_AS_INTERVALS: 'SAVE_AS_INTERVALS'; -SAVEPOINT: 'SAVEPOINT'; -SAVE: 'SAVE'; -SB4: 'SB4'; -SCALE_ROWS: 'SCALE_ROWS'; -SCALE: 'SCALE'; -SCAN_INSTANCES: 'SCAN_INSTANCES'; -SCAN: 'SCAN'; -SCHEDULER: 'SCHEDULER'; -SCHEMACHECK: 'SCHEMACHECK'; -SCHEMA: 'SCHEMA'; -SCN_ASCENDING: 'SCN_ASCENDING'; -SCN: 'SCN'; -SCOPE: 'SCOPE'; -SCRUB: 'SCRUB'; -SD_ALL: 'SD_ALL'; -SD_INHIBIT: 'SD_INHIBIT'; -SDO_GEOM_MBR: 'SDO_GEOM_MBR'; -SD_SHOW: 'SD_SHOW'; -SEARCH: 'SEARCH'; -SECOND: 'SECOND'; -SECRET: 'SECRET'; -SECUREFILE_DBA: 'SECUREFILE_DBA'; -SECUREFILE: 'SECUREFILE'; -SECURITY: 'SECURITY'; -SEED: 'SEED'; -SEG_BLOCK: 'SEG_BLOCK'; -SEG_FILE: 'SEG_FILE'; -SEGMENT: 'SEGMENT'; -SELECTIVITY: 'SELECTIVITY'; -SELECT: 'SELECT'; -SELF: 'SELF'; -SEMIJOIN_DRIVER: 'SEMIJOIN_DRIVER'; -SEMIJOIN: 'SEMIJOIN'; -SEMI_TO_INNER: 'SEMI_TO_INNER'; -SEQUENCED: 'SEQUENCED'; -SEQUENCE: 'SEQUENCE'; -SEQUENTIAL: 'SEQUENTIAL'; -SEQ: 'SEQ'; -SERIALIZABLE: 'SERIALIZABLE'; -SERIALLY_REUSABLE: 'SERIALLY_REUSABLE'; -SERIAL: 'SERIAL'; -SERVERERROR: 'SERVERERROR'; -SERVICE_NAME_CONVERT: 'SERVICE_NAME_CONVERT'; -SERVICES: 'SERVICES'; -SESSION_CACHED_CURSORS: 'SESSION_CACHED_CURSORS'; -SESSION: 'SESSION'; -SESSIONS_PER_USER: 'SESSIONS_PER_USER'; -SESSIONTIMEZONE: 'SESSIONTIMEZONE'; -SESSIONTZNAME: 'SESSIONTZNAME'; -SET: 'SET'; -SETS: 'SETS'; -SETTINGS: 'SETTINGS'; -SET_TO_JOIN: 'SET_TO_JOIN'; -SEVERE: 'SEVERE'; -SHARED_POOL: 'SHARED_POOL'; -SHARED: 'SHARED'; -SHARE: 'SHARE'; -SHARING: 'SHARING'; -SHELFLIFE: 'SHELFLIFE'; -SHOW: 'SHOW'; -SHRINK: 'SHRINK'; -SHUTDOWN: 'SHUTDOWN'; -SIBLINGS: 'SIBLINGS'; -SID: 'SID'; -SIGNAL_COMPONENT: 'SIGNAL_COMPONENT'; -SIGNAL_FUNCTION: 'SIGNAL_FUNCTION'; -SIGN: 'SIGN'; -SIGNTYPE: 'SIGNTYPE'; -SIMPLE_INTEGER: 'SIMPLE_INTEGER'; -SIMPLE: 'SIMPLE'; -SINGLE: 'SINGLE'; -SINGLETASK: 'SINGLETASK'; -SINH: 'SINH'; -SIN: 'SIN'; -SIZE: 'SIZE'; -SKIP_EXT_OPTIMIZER: 'SKIP_EXT_OPTIMIZER'; -SKIP_ : 'SKIP'; -SKIP_UNQ_UNUSABLE_IDX: 'SKIP_UNQ_UNUSABLE_IDX'; -SKIP_UNUSABLE_INDEXES: 'SKIP_UNUSABLE_INDEXES'; -SMALLFILE: 'SMALLFILE'; -SMALLINT: 'SMALLINT'; -SNAPSHOT: 'SNAPSHOT'; -SOME: 'SOME'; -SORT: 'SORT'; -SOUNDEX: 'SOUNDEX'; -SOURCE_FILE_DIRECTORY: 'SOURCE_FILE_DIRECTORY'; -SOURCE_FILE_NAME_CONVERT: 'SOURCE_FILE_NAME_CONVERT'; -SOURCE: 'SOURCE'; -SPACE_KEYWORD: 'SPACE'; -SPECIFICATION: 'SPECIFICATION'; -SPFILE: 'SPFILE'; -SPLIT: 'SPLIT'; -SPREADSHEET: 'SPREADSHEET'; -SQLDATA: 'SQLDATA'; -SQLERROR: 'SQLERROR'; -SQLLDR: 'SQLLDR'; -SQL: 'SQL'; -SQL_TRACE: 'SQL_TRACE'; -SQL_TRANSLATION_PROFILE: 'SQL_TRANSLATION_PROFILE'; -SQRT: 'SQRT'; -STALE: 'STALE'; -STANDALONE: 'STANDALONE'; -STANDARD_HASH: 'STANDARD_HASH'; -STANDBY_MAX_DATA_DELAY: 'STANDBY_MAX_DATA_DELAY'; -STANDBYS: 'STANDBYS'; -STANDBY: 'STANDBY'; -STAR: 'STAR'; -STAR_TRANSFORMATION: 'STAR_TRANSFORMATION'; -START: 'START'; -STARTUP: 'STARTUP'; -STATEMENT_ID: 'STATEMENT_ID'; -STATEMENT_QUEUING: 'STATEMENT_QUEUING'; -STATEMENTS: 'STATEMENTS'; -STATEMENT: 'STATEMENT'; -STATE: 'STATE'; -STATIC: 'STATIC'; -STATISTICS: 'STATISTICS'; -STATS_BINOMIAL_TEST: 'STATS_BINOMIAL_TEST'; -STATS_CROSSTAB: 'STATS_CROSSTAB'; -STATS_F_TEST: 'STATS_F_TEST'; -STATS_KS_TEST: 'STATS_KS_TEST'; -STATS_MODE: 'STATS_MODE'; -STATS_MW_TEST: 'STATS_MW_TEST'; -STATS_ONE_WAY_ANOVA: 'STATS_ONE_WAY_ANOVA'; -STATS_T_TEST_INDEP: 'STATS_T_TEST_INDEP'; -STATS_T_TEST_INDEPU: 'STATS_T_TEST_INDEPU'; -STATS_T_TEST_ONE: 'STATS_T_TEST_ONE'; -STATS_T_TEST_PAIRED: 'STATS_T_TEST_PAIRED'; -STATS_WSR_TEST: 'STATS_WSR_TEST'; -STDDEV_POP: 'STDDEV_POP'; -STDDEV_SAMP: 'STDDEV_SAMP'; -STOP: 'STOP'; -STORAGE: 'STORAGE'; -STORE: 'STORE'; -STREAMS: 'STREAMS'; -STREAM: 'STREAM'; -STRICT: 'STRICT'; -STRING: 'STRING'; -STRIPE_COLUMNS: 'STRIPE_COLUMNS'; -STRIPE_WIDTH: 'STRIPE_WIDTH'; -STRIP: 'STRIP'; -STRUCTURE: 'STRUCTURE'; -SUBMULTISET: 'SUBMULTISET'; -SUBPARTITION_REL: 'SUBPARTITION_REL'; -SUBPARTITIONS: 'SUBPARTITIONS'; -SUBPARTITION: 'SUBPARTITION'; -SUBQUERIES: 'SUBQUERIES'; -SUBQUERY_PRUNING: 'SUBQUERY_PRUNING'; -SUBSCRIBE: 'SUBSCRIBE'; -SUBSET: 'SUBSET'; -SUBSTITUTABLE: 'SUBSTITUTABLE'; -SUBSTR2: 'SUBSTR2'; -SUBSTR4: 'SUBSTR4'; -SUBSTRB: 'SUBSTRB'; -SUBSTRC: 'SUBSTRC'; -SUBTYPE: 'SUBTYPE'; -SUCCESSFUL: 'SUCCESSFUL'; -SUCCESS: 'SUCCESS'; -SUMMARY: 'SUMMARY'; -SUPPLEMENTAL: 'SUPPLEMENTAL'; -SUSPEND: 'SUSPEND'; -SWAP_JOIN_INPUTS: 'SWAP_JOIN_INPUTS'; -SWITCHOVER: 'SWITCHOVER'; -SWITCH: 'SWITCH'; -SYNCHRONOUS: 'SYNCHRONOUS'; -SYNC: 'SYNC'; -SYNONYM: 'SYNONYM'; -SYSASM: 'SYSASM'; -SYS_AUDIT: 'SYS_AUDIT'; -SYSAUX: 'SYSAUX'; -SYSBACKUP: 'SYSBACKUP'; -SYS_CHECKACL: 'SYS_CHECKACL'; -SYS_CHECK_PRIVILEGE: 'SYS_CHECK_PRIVILEGE'; -SYS_CONNECT_BY_PATH: 'SYS_CONNECT_BY_PATH'; -SYS_CONTEXT: 'SYS_CONTEXT'; -SYSDATE: 'SYSDATE'; -SYSDBA: 'SYSDBA'; -SYS_DBURIGEN: 'SYS_DBURIGEN'; -SYSDG: 'SYSDG'; -SYS_DL_CURSOR: 'SYS_DL_CURSOR'; -SYS_DM_RXFORM_CHR: 'SYS_DM_RXFORM_CHR'; -SYS_DM_RXFORM_NUM: 'SYS_DM_RXFORM_NUM'; -SYS_DOM_COMPARE: 'SYS_DOM_COMPARE'; -SYS_DST_PRIM2SEC: 'SYS_DST_PRIM2SEC'; -SYS_DST_SEC2PRIM: 'SYS_DST_SEC2PRIM'; -SYS_ET_BFILE_TO_RAW: 'SYS_ET_BFILE_TO_RAW'; -SYS_ET_BLOB_TO_IMAGE: 'SYS_ET_BLOB_TO_IMAGE'; -SYS_ET_IMAGE_TO_BLOB: 'SYS_ET_IMAGE_TO_BLOB'; -SYS_ET_RAW_TO_BFILE: 'SYS_ET_RAW_TO_BFILE'; -SYS_EXTPDTXT: 'SYS_EXTPDTXT'; -SYS_EXTRACT_UTC: 'SYS_EXTRACT_UTC'; -SYS_FBT_INSDEL: 'SYS_FBT_INSDEL'; -SYS_FILTER_ACLS: 'SYS_FILTER_ACLS'; -SYS_FNMATCHES: 'SYS_FNMATCHES'; -SYS_FNREPLACE: 'SYS_FNREPLACE'; -SYS_GET_ACLIDS: 'SYS_GET_ACLIDS'; -SYS_GET_COL_ACLIDS: 'SYS_GET_COL_ACLIDS'; -SYS_GET_PRIVILEGES: 'SYS_GET_PRIVILEGES'; -SYS_GETTOKENID: 'SYS_GETTOKENID'; -SYS_GETXTIVAL: 'SYS_GETXTIVAL'; -SYS_GUID: 'SYS_GUID'; -SYSGUID: 'SYSGUID'; -SYSKM: 'SYSKM'; -SYS_MAKE_XMLNODEID: 'SYS_MAKE_XMLNODEID'; -SYS_MAKEXML: 'SYS_MAKEXML'; -SYS_MKXMLATTR: 'SYS_MKXMLATTR'; -SYS_MKXTI: 'SYS_MKXTI'; -SYSOBJ: 'SYSOBJ'; -SYS_OP_ADT2BIN: 'SYS_OP_ADT2BIN'; -SYS_OP_ADTCONS: 'SYS_OP_ADTCONS'; -SYS_OP_ALSCRVAL: 'SYS_OP_ALSCRVAL'; -SYS_OP_ATG: 'SYS_OP_ATG'; -SYS_OP_BIN2ADT: 'SYS_OP_BIN2ADT'; -SYS_OP_BITVEC: 'SYS_OP_BITVEC'; -SYS_OP_BL2R: 'SYS_OP_BL2R'; -SYS_OP_BLOOM_FILTER_LIST: 'SYS_OP_BLOOM_FILTER_LIST'; -SYS_OP_BLOOM_FILTER: 'SYS_OP_BLOOM_FILTER'; -SYS_OP_C2C: 'SYS_OP_C2C'; -SYS_OP_CAST: 'SYS_OP_CAST'; -SYS_OP_CEG: 'SYS_OP_CEG'; -SYS_OP_CL2C: 'SYS_OP_CL2C'; -SYS_OP_COMBINED_HASH: 'SYS_OP_COMBINED_HASH'; -SYS_OP_COMP: 'SYS_OP_COMP'; -SYS_OP_CONVERT: 'SYS_OP_CONVERT'; -SYS_OP_COUNTCHG: 'SYS_OP_COUNTCHG'; -SYS_OP_CSCONV: 'SYS_OP_CSCONV'; -SYS_OP_CSCONVTEST: 'SYS_OP_CSCONVTEST'; -SYS_OP_CSR: 'SYS_OP_CSR'; -SYS_OP_CSX_PATCH: 'SYS_OP_CSX_PATCH'; -SYS_OP_CYCLED_SEQ: 'SYS_OP_CYCLED_SEQ'; -SYS_OP_DECOMP: 'SYS_OP_DECOMP'; -SYS_OP_DESCEND: 'SYS_OP_DESCEND'; -SYS_OP_DISTINCT: 'SYS_OP_DISTINCT'; -SYS_OP_DRA: 'SYS_OP_DRA'; -SYS_OP_DUMP: 'SYS_OP_DUMP'; -SYS_OP_DV_CHECK: 'SYS_OP_DV_CHECK'; -SYS_OP_ENFORCE_NOT_NULL: 'SYS_OP_ENFORCE_NOT_NULL$'; -SYSOPER: 'SYSOPER'; -SYS_OP_EXTRACT: 'SYS_OP_EXTRACT'; -SYS_OP_GROUPING: 'SYS_OP_GROUPING'; -SYS_OP_GUID: 'SYS_OP_GUID'; -SYS_OP_HASH: 'SYS_OP_HASH'; -SYS_OP_IIX: 'SYS_OP_IIX'; -SYS_OP_ITR: 'SYS_OP_ITR'; -SYS_OP_KEY_VECTOR_CREATE: 'SYS_OP_KEY_VECTOR_CREATE'; -SYS_OP_KEY_VECTOR_FILTER_LIST: 'SYS_OP_KEY_VECTOR_FILTER_LIST'; -SYS_OP_KEY_VECTOR_FILTER: 'SYS_OP_KEY_VECTOR_FILTER'; -SYS_OP_KEY_VECTOR_SUCCEEDED: 'SYS_OP_KEY_VECTOR_SUCCEEDED'; -SYS_OP_KEY_VECTOR_USE: 'SYS_OP_KEY_VECTOR_USE'; -SYS_OP_LBID: 'SYS_OP_LBID'; -SYS_OP_LOBLOC2BLOB: 'SYS_OP_LOBLOC2BLOB'; -SYS_OP_LOBLOC2CLOB: 'SYS_OP_LOBLOC2CLOB'; -SYS_OP_LOBLOC2ID: 'SYS_OP_LOBLOC2ID'; -SYS_OP_LOBLOC2NCLOB: 'SYS_OP_LOBLOC2NCLOB'; -SYS_OP_LOBLOC2TYP: 'SYS_OP_LOBLOC2TYP'; -SYS_OP_LSVI: 'SYS_OP_LSVI'; -SYS_OP_LVL: 'SYS_OP_LVL'; -SYS_OP_MAKEOID: 'SYS_OP_MAKEOID'; -SYS_OP_MAP_NONNULL: 'SYS_OP_MAP_NONNULL'; -SYS_OP_MSR: 'SYS_OP_MSR'; -SYS_OP_NICOMBINE: 'SYS_OP_NICOMBINE'; -SYS_OP_NIEXTRACT: 'SYS_OP_NIEXTRACT'; -SYS_OP_NII: 'SYS_OP_NII'; -SYS_OP_NIX: 'SYS_OP_NIX'; -SYS_OP_NOEXPAND: 'SYS_OP_NOEXPAND'; -SYS_OP_NTCIMG: 'SYS_OP_NTCIMG$'; -SYS_OP_NUMTORAW: 'SYS_OP_NUMTORAW'; -SYS_OP_OIDVALUE: 'SYS_OP_OIDVALUE'; -SYS_OP_OPNSIZE: 'SYS_OP_OPNSIZE'; -SYS_OP_PAR_1: 'SYS_OP_PAR_1'; -SYS_OP_PARGID_1: 'SYS_OP_PARGID_1'; -SYS_OP_PARGID: 'SYS_OP_PARGID'; -SYS_OP_PAR: 'SYS_OP_PAR'; -SYS_OP_PART_ID: 'SYS_OP_PART_ID'; -SYS_OP_PIVOT: 'SYS_OP_PIVOT'; -SYS_OP_R2O: 'SYS_OP_R2O'; -SYS_OP_RAWTONUM: 'SYS_OP_RAWTONUM'; -SYS_OP_RDTM: 'SYS_OP_RDTM'; -SYS_OP_REF: 'SYS_OP_REF'; -SYS_OP_RMTD: 'SYS_OP_RMTD'; -SYS_OP_ROWIDTOOBJ: 'SYS_OP_ROWIDTOOBJ'; -SYS_OP_RPB: 'SYS_OP_RPB'; -SYS_OPTLOBPRBSC: 'SYS_OPTLOBPRBSC'; -SYS_OP_TOSETID: 'SYS_OP_TOSETID'; -SYS_OP_TPR: 'SYS_OP_TPR'; -SYS_OP_TRTB: 'SYS_OP_TRTB'; -SYS_OPTXICMP: 'SYS_OPTXICMP'; -SYS_OPTXQCASTASNQ: 'SYS_OPTXQCASTASNQ'; -SYS_OP_UNDESCEND: 'SYS_OP_UNDESCEND'; -SYS_OP_VECAND: 'SYS_OP_VECAND'; -SYS_OP_VECBIT: 'SYS_OP_VECBIT'; -SYS_OP_VECOR: 'SYS_OP_VECOR'; -SYS_OP_VECXOR: 'SYS_OP_VECXOR'; -SYS_OP_VERSION: 'SYS_OP_VERSION'; -SYS_OP_VREF: 'SYS_OP_VREF'; -SYS_OP_VVD: 'SYS_OP_VVD'; -SYS_OP_XMLCONS_FOR_CSX: 'SYS_OP_XMLCONS_FOR_CSX'; -SYS_OP_XPTHATG: 'SYS_OP_XPTHATG'; -SYS_OP_XPTHIDX: 'SYS_OP_XPTHIDX'; -SYS_OP_XPTHOP: 'SYS_OP_XPTHOP'; -SYS_OP_XTXT2SQLT: 'SYS_OP_XTXT2SQLT'; -SYS_OP_ZONE_ID: 'SYS_OP_ZONE_ID'; -SYS_ORDERKEY_DEPTH: 'SYS_ORDERKEY_DEPTH'; -SYS_ORDERKEY_MAXCHILD: 'SYS_ORDERKEY_MAXCHILD'; -SYS_ORDERKEY_PARENT: 'SYS_ORDERKEY_PARENT'; -SYS_PARALLEL_TXN: 'SYS_PARALLEL_TXN'; -SYS_PATHID_IS_ATTR: 'SYS_PATHID_IS_ATTR'; -SYS_PATHID_IS_NMSPC: 'SYS_PATHID_IS_NMSPC'; -SYS_PATHID_LASTNAME: 'SYS_PATHID_LASTNAME'; -SYS_PATHID_LASTNMSPC: 'SYS_PATHID_LASTNMSPC'; -SYS_PATH_REVERSE: 'SYS_PATH_REVERSE'; -SYS_PXQEXTRACT: 'SYS_PXQEXTRACT'; -SYS_RAW_TO_XSID: 'SYS_RAW_TO_XSID'; -SYS_RID_ORDER: 'SYS_RID_ORDER'; -SYS_ROW_DELTA: 'SYS_ROW_DELTA'; -SYS_SC_2_XMLT: 'SYS_SC_2_XMLT'; -SYS_SYNRCIREDO: 'SYS_SYNRCIREDO'; -SYSTEM_DEFINED: 'SYSTEM_DEFINED'; -SYSTEM: 'SYSTEM'; -SYSTIMESTAMP: 'SYSTIMESTAMP'; -SYS_TYPEID: 'SYS_TYPEID'; -SYS_UMAKEXML: 'SYS_UMAKEXML'; -SYS_XMLANALYZE: 'SYS_XMLANALYZE'; -SYS_XMLCONTAINS: 'SYS_XMLCONTAINS'; -SYS_XMLCONV: 'SYS_XMLCONV'; -SYS_XMLEXNSURI: 'SYS_XMLEXNSURI'; -SYS_XMLGEN: 'SYS_XMLGEN'; -SYS_XMLI_LOC_ISNODE: 'SYS_XMLI_LOC_ISNODE'; -SYS_XMLI_LOC_ISTEXT: 'SYS_XMLI_LOC_ISTEXT'; -SYS_XMLINSTR: 'SYS_XMLINSTR'; -SYS_XMLLOCATOR_GETSVAL: 'SYS_XMLLOCATOR_GETSVAL'; -SYS_XMLNODEID_GETCID: 'SYS_XMLNODEID_GETCID'; -SYS_XMLNODEID_GETLOCATOR: 'SYS_XMLNODEID_GETLOCATOR'; -SYS_XMLNODEID_GETOKEY: 'SYS_XMLNODEID_GETOKEY'; -SYS_XMLNODEID_GETPATHID: 'SYS_XMLNODEID_GETPATHID'; -SYS_XMLNODEID_GETPTRID: 'SYS_XMLNODEID_GETPTRID'; -SYS_XMLNODEID_GETRID: 'SYS_XMLNODEID_GETRID'; -SYS_XMLNODEID_GETSVAL: 'SYS_XMLNODEID_GETSVAL'; -SYS_XMLNODEID_GETTID: 'SYS_XMLNODEID_GETTID'; -SYS_XMLNODEID: 'SYS_XMLNODEID'; -SYS_XMLT_2_SC: 'SYS_XMLT_2_SC'; -SYS_XMLTRANSLATE: 'SYS_XMLTRANSLATE'; -SYS_XMLTYPE2SQL: 'SYS_XMLTYPE2SQL'; -SYS_XQ_ASQLCNV: 'SYS_XQ_ASQLCNV'; -SYS_XQ_ATOMCNVCHK: 'SYS_XQ_ATOMCNVCHK'; -SYS_XQBASEURI: 'SYS_XQBASEURI'; -SYS_XQCASTABLEERRH: 'SYS_XQCASTABLEERRH'; -SYS_XQCODEP2STR: 'SYS_XQCODEP2STR'; -SYS_XQCODEPEQ: 'SYS_XQCODEPEQ'; -SYS_XQCON2SEQ: 'SYS_XQCON2SEQ'; -SYS_XQCONCAT: 'SYS_XQCONCAT'; -SYS_XQDELETE: 'SYS_XQDELETE'; -SYS_XQDFLTCOLATION: 'SYS_XQDFLTCOLATION'; -SYS_XQDOC: 'SYS_XQDOC'; -SYS_XQDOCURI: 'SYS_XQDOCURI'; -SYS_XQDURDIV: 'SYS_XQDURDIV'; -SYS_XQED4URI: 'SYS_XQED4URI'; -SYS_XQENDSWITH: 'SYS_XQENDSWITH'; -SYS_XQERRH: 'SYS_XQERRH'; -SYS_XQERR: 'SYS_XQERR'; -SYS_XQESHTMLURI: 'SYS_XQESHTMLURI'; -SYS_XQEXLOBVAL: 'SYS_XQEXLOBVAL'; -SYS_XQEXSTWRP: 'SYS_XQEXSTWRP'; -SYS_XQEXTRACT: 'SYS_XQEXTRACT'; -SYS_XQEXTRREF: 'SYS_XQEXTRREF'; -SYS_XQEXVAL: 'SYS_XQEXVAL'; -SYS_XQFB2STR: 'SYS_XQFB2STR'; -SYS_XQFNBOOL: 'SYS_XQFNBOOL'; -SYS_XQFNCMP: 'SYS_XQFNCMP'; -SYS_XQFNDATIM: 'SYS_XQFNDATIM'; -SYS_XQFNLNAME: 'SYS_XQFNLNAME'; -SYS_XQFNNM: 'SYS_XQFNNM'; -SYS_XQFNNSURI: 'SYS_XQFNNSURI'; -SYS_XQFNPREDTRUTH: 'SYS_XQFNPREDTRUTH'; -SYS_XQFNQNM: 'SYS_XQFNQNM'; -SYS_XQFNROOT: 'SYS_XQFNROOT'; -SYS_XQFORMATNUM: 'SYS_XQFORMATNUM'; -SYS_XQFTCONTAIN: 'SYS_XQFTCONTAIN'; -SYS_XQFUNCR: 'SYS_XQFUNCR'; -SYS_XQGETCONTENT: 'SYS_XQGETCONTENT'; -SYS_XQINDXOF: 'SYS_XQINDXOF'; -SYS_XQINSERT: 'SYS_XQINSERT'; -SYS_XQINSPFX: 'SYS_XQINSPFX'; -SYS_XQIRI2URI: 'SYS_XQIRI2URI'; -SYS_XQLANG: 'SYS_XQLANG'; -SYS_XQLLNMFRMQNM: 'SYS_XQLLNMFRMQNM'; -SYS_XQMKNODEREF: 'SYS_XQMKNODEREF'; -SYS_XQNILLED: 'SYS_XQNILLED'; -SYS_XQNODENAME: 'SYS_XQNODENAME'; -SYS_XQNORMSPACE: 'SYS_XQNORMSPACE'; -SYS_XQNORMUCODE: 'SYS_XQNORMUCODE'; -SYS_XQ_NRNG: 'SYS_XQ_NRNG'; -SYS_XQNSP4PFX: 'SYS_XQNSP4PFX'; -SYS_XQNSPFRMQNM: 'SYS_XQNSPFRMQNM'; -SYS_XQPFXFRMQNM: 'SYS_XQPFXFRMQNM'; -SYS_XQ_PKSQL2XML: 'SYS_XQ_PKSQL2XML'; -SYS_XQPOLYABS: 'SYS_XQPOLYABS'; -SYS_XQPOLYADD: 'SYS_XQPOLYADD'; -SYS_XQPOLYCEL: 'SYS_XQPOLYCEL'; -SYS_XQPOLYCSTBL: 'SYS_XQPOLYCSTBL'; -SYS_XQPOLYCST: 'SYS_XQPOLYCST'; -SYS_XQPOLYDIV: 'SYS_XQPOLYDIV'; -SYS_XQPOLYFLR: 'SYS_XQPOLYFLR'; -SYS_XQPOLYMOD: 'SYS_XQPOLYMOD'; -SYS_XQPOLYMUL: 'SYS_XQPOLYMUL'; -SYS_XQPOLYRND: 'SYS_XQPOLYRND'; -SYS_XQPOLYSQRT: 'SYS_XQPOLYSQRT'; -SYS_XQPOLYSUB: 'SYS_XQPOLYSUB'; -SYS_XQPOLYUMUS: 'SYS_XQPOLYUMUS'; -SYS_XQPOLYUPLS: 'SYS_XQPOLYUPLS'; -SYS_XQPOLYVEQ: 'SYS_XQPOLYVEQ'; -SYS_XQPOLYVGE: 'SYS_XQPOLYVGE'; -SYS_XQPOLYVGT: 'SYS_XQPOLYVGT'; -SYS_XQPOLYVLE: 'SYS_XQPOLYVLE'; -SYS_XQPOLYVLT: 'SYS_XQPOLYVLT'; -SYS_XQPOLYVNE: 'SYS_XQPOLYVNE'; -SYS_XQREF2VAL: 'SYS_XQREF2VAL'; -SYS_XQRENAME: 'SYS_XQRENAME'; -SYS_XQREPLACE: 'SYS_XQREPLACE'; -SYS_XQRESVURI: 'SYS_XQRESVURI'; -SYS_XQRNDHALF2EVN: 'SYS_XQRNDHALF2EVN'; -SYS_XQRSLVQNM: 'SYS_XQRSLVQNM'; -SYS_XQRYENVPGET: 'SYS_XQRYENVPGET'; -SYS_XQRYVARGET: 'SYS_XQRYVARGET'; -SYS_XQRYWRP: 'SYS_XQRYWRP'; -SYS_XQSEQ2CON4XC: 'SYS_XQSEQ2CON4XC'; -SYS_XQSEQ2CON: 'SYS_XQSEQ2CON'; -SYS_XQSEQDEEPEQ: 'SYS_XQSEQDEEPEQ'; -SYS_XQSEQINSB: 'SYS_XQSEQINSB'; -SYS_XQSEQRM: 'SYS_XQSEQRM'; -SYS_XQSEQRVS: 'SYS_XQSEQRVS'; -SYS_XQSEQSUB: 'SYS_XQSEQSUB'; -SYS_XQSEQTYPMATCH: 'SYS_XQSEQTYPMATCH'; -SYS_XQSTARTSWITH: 'SYS_XQSTARTSWITH'; -SYS_XQSTATBURI: 'SYS_XQSTATBURI'; -SYS_XQSTR2CODEP: 'SYS_XQSTR2CODEP'; -SYS_XQSTRJOIN: 'SYS_XQSTRJOIN'; -SYS_XQSUBSTRAFT: 'SYS_XQSUBSTRAFT'; -SYS_XQSUBSTRBEF: 'SYS_XQSUBSTRBEF'; -SYS_XQTOKENIZE: 'SYS_XQTOKENIZE'; -SYS_XQTREATAS: 'SYS_XQTREATAS'; -SYS_XQ_UPKXML2SQL: 'SYS_XQ_UPKXML2SQL'; -SYS_XQXFORM: 'SYS_XQXFORM'; -SYS_XSID_TO_RAW: 'SYS_XSID_TO_RAW'; -SYS_ZMAP_FILTER: 'SYS_ZMAP_FILTER'; -SYS_ZMAP_REFRESH: 'SYS_ZMAP_REFRESH'; -TABLE_LOOKUP_BY_NL: 'TABLE_LOOKUP_BY_NL'; -TABLESPACE_NO: 'TABLESPACE_NO'; -TABLESPACE: 'TABLESPACE'; -TABLES: 'TABLES'; -TABLE_STATS: 'TABLE_STATS'; -TABLE: 'TABLE'; -TABNO: 'TABNO'; -TAG: 'TAG'; -TANH: 'TANH'; -TAN: 'TAN'; -TBLORIDXPARTNUM: 'TBL$OR$IDX$PART$NUM'; -TEMPFILE: 'TEMPFILE'; -TEMPLATE: 'TEMPLATE'; -TEMPORARY: 'TEMPORARY'; -TEMP_TABLE: 'TEMP_TABLE'; -TEST: 'TEST'; -TEXT: 'TEXT'; -THAN: 'THAN'; -THEN: 'THEN'; -THE: 'THE'; -THREAD: 'THREAD'; -THROUGH: 'THROUGH'; -TIER: 'TIER'; -TIES: 'TIES'; -TIMEOUT: 'TIMEOUT'; -TIMESTAMP_LTZ_UNCONSTRAINED: 'TIMESTAMP_LTZ_UNCONSTRAINED'; -TIMESTAMP: 'TIMESTAMP'; -TIMESTAMP_TZ_UNCONSTRAINED: 'TIMESTAMP_TZ_UNCONSTRAINED'; -TIMESTAMP_UNCONSTRAINED: 'TIMESTAMP_UNCONSTRAINED'; -TIMES: 'TIMES'; -TIME: 'TIME'; -TIMEZONE: 'TIMEZONE'; -TIMEZONE_ABBR: 'TIMEZONE_ABBR'; -TIMEZONE_HOUR: 'TIMEZONE_HOUR'; -TIMEZONE_MINUTE: 'TIMEZONE_MINUTE'; -TIMEZONE_OFFSET: 'TIMEZONE_OFFSET'; -TIMEZONE_REGION: 'TIMEZONE_REGION'; -TIME_ZONE: 'TIME_ZONE'; -TIV_GB: 'TIV_GB'; -TIV_SSF: 'TIV_SSF'; -TO_ACLID: 'TO_ACLID'; -TO_BINARY_DOUBLE: 'TO_BINARY_DOUBLE'; -TO_BINARY_FLOAT: 'TO_BINARY_FLOAT'; -TO_BLOB: 'TO_BLOB'; -TO_CLOB: 'TO_CLOB'; -TO_DSINTERVAL: 'TO_DSINTERVAL'; -TO_LOB: 'TO_LOB'; -TO_MULTI_BYTE: 'TO_MULTI_BYTE'; -TO_NCHAR: 'TO_NCHAR'; -TO_NCLOB: 'TO_NCLOB'; -TO_NUMBER: 'TO_NUMBER'; -TOPLEVEL: 'TOPLEVEL'; -TO_SINGLE_BYTE: 'TO_SINGLE_BYTE'; -TO_TIMESTAMP: 'TO_TIMESTAMP'; -TO_TIMESTAMP_TZ: 'TO_TIMESTAMP_TZ'; -TO_TIME: 'TO_TIME'; -TO_TIME_TZ: 'TO_TIME_TZ'; -TO: 'TO'; -TO_YMINTERVAL: 'TO_YMINTERVAL'; -TRACE: 'TRACE'; -TRACING: 'TRACING'; -TRACKING: 'TRACKING'; -TRAILING: 'TRAILING'; -TRANSACTION: 'TRANSACTION'; -TRANSFORM_DISTINCT_AGG: 'TRANSFORM_DISTINCT_AGG'; -TRANSITIONAL: 'TRANSITIONAL'; -TRANSITION: 'TRANSITION'; -TRANSLATE: 'TRANSLATE'; -TRANSLATION: 'TRANSLATION'; -TREAT: 'TREAT'; -TRIGGERS: 'TRIGGERS'; -TRIGGER: 'TRIGGER'; -TRUE: 'TRUE'; -TRUNCATE: 'TRUNCATE'; -TRUNC: 'TRUNC'; -TRUSTED: 'TRUSTED'; -TRUST: 'TRUST'; -TUNING: 'TUNING'; -TX: 'TX'; -TYPES: 'TYPES'; -TYPE: 'TYPE'; -TZ_OFFSET: 'TZ_OFFSET'; -UB2: 'UB2'; -UBA: 'UBA'; -UCS2: 'UCS2'; -UID: 'UID'; -UNARCHIVED: 'UNARCHIVED'; -UNBOUNDED: 'UNBOUNDED'; -UNBOUND: 'UNBOUND'; -UNCONDITIONAL: 'UNCONDITIONAL'; -UNDER: 'UNDER'; -UNDO: 'UNDO'; -UNDROP: 'UNDROP'; -UNIFORM: 'UNIFORM'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; -UNISTR: 'UNISTR'; -UNLIMITED: 'UNLIMITED'; -UNLOAD: 'UNLOAD'; -UNLOCK: 'UNLOCK'; -UNMATCHED: 'UNMATCHED'; -UNNEST_INNERJ_DISTINCT_VIEW: 'UNNEST_INNERJ_DISTINCT_VIEW'; -UNNEST_NOSEMIJ_NODISTINCTVIEW: 'UNNEST_NOSEMIJ_NODISTINCTVIEW'; -UNNEST_SEMIJ_VIEW: 'UNNEST_SEMIJ_VIEW'; -UNNEST: 'UNNEST'; -UNPACKED: 'UNPACKED'; -UNPIVOT: 'UNPIVOT'; -UNPLUG: 'UNPLUG'; -UNPROTECTED: 'UNPROTECTED'; -UNQUIESCE: 'UNQUIESCE'; -UNRECOVERABLE: 'UNRECOVERABLE'; -UNRESTRICTED: 'UNRESTRICTED'; -UNSUBSCRIBE: 'UNSUBSCRIBE'; -UNTIL: 'UNTIL'; -UNUSABLE: 'UNUSABLE'; -UNUSED: 'UNUSED'; -UPDATABLE: 'UPDATABLE'; -UPDATED: 'UPDATED'; -UPDATE: 'UPDATE'; -UPDATEXML: 'UPDATEXML'; -UPD_INDEXES: 'UPD_INDEXES'; -UPD_JOININDEX: 'UPD_JOININDEX'; -UPGRADE: 'UPGRADE'; -UPPER: 'UPPER'; -UPSERT: 'UPSERT'; -UROWID: 'UROWID'; -USABLE: 'USABLE'; -USAGE: 'USAGE'; -USE_ANTI: 'USE_ANTI'; -USE_CONCAT: 'USE_CONCAT'; -USE_CUBE: 'USE_CUBE'; -USE_HASH_AGGREGATION: 'USE_HASH_AGGREGATION'; -USE_HASH_GBY_FOR_PUSHDOWN: 'USE_HASH_GBY_FOR_PUSHDOWN'; -USE_HASH: 'USE_HASH'; -USE_HIDDEN_PARTITIONS: 'USE_HIDDEN_PARTITIONS'; -USE_INVISIBLE_INDEXES: 'USE_INVISIBLE_INDEXES'; -USE_MERGE_CARTESIAN: 'USE_MERGE_CARTESIAN'; -USE_MERGE: 'USE_MERGE'; -USE_NL: 'USE_NL'; -USE_NL_WITH_INDEX: 'USE_NL_WITH_INDEX'; -USE_PRIVATE_OUTLINES: 'USE_PRIVATE_OUTLINES'; -USER_DATA: 'USER_DATA'; -USER_DEFINED: 'USER_DEFINED'; -USERENV: 'USERENV'; -USERGROUP: 'USERGROUP'; -USER_RECYCLEBIN: 'USER_RECYCLEBIN'; -USERS: 'USERS'; -USER_TABLESPACES: 'USER_TABLESPACES'; -USER: 'USER'; -USE_SEMI: 'USE_SEMI'; -USE_STORED_OUTLINES: 'USE_STORED_OUTLINES'; -USE_TTT_FOR_GSETS: 'USE_TTT_FOR_GSETS'; -USE: 'USE'; -USE_VECTOR_AGGREGATION: 'USE_VECTOR_AGGREGATION'; -USE_WEAK_NAME_RESL: 'USE_WEAK_NAME_RESL'; -USING_NO_EXPAND: 'USING_NO_EXPAND'; -USING: 'USING'; -UTF16BE: 'UTF16BE'; -UTF16LE: 'UTF16LE'; -UTF32: 'UTF32'; -UTF8: 'UTF8'; -V1: 'V1'; -V2: 'V2'; -VALIDATE: 'VALIDATE'; -VALIDATION: 'VALIDATION'; -VALID_TIME_END: 'VALID_TIME_END'; -VALUES: 'VALUES'; -VALUE: 'VALUE'; -VARCHAR2: 'VARCHAR2'; -VARCHAR: 'VARCHAR'; -VARIABLE: 'VARIABLE'; -VAR_POP: 'VAR_POP'; -VARRAYS: 'VARRAYS'; -VARRAY: 'VARRAY'; -VAR_SAMP: 'VAR_SAMP'; -VARYING: 'VARYING'; -VECTOR_READ_TRACE: 'VECTOR_READ_TRACE'; -VECTOR_READ: 'VECTOR_READ'; -VECTOR_TRANSFORM_DIMS: 'VECTOR_TRANSFORM_DIMS'; -VECTOR_TRANSFORM_FACT: 'VECTOR_TRANSFORM_FACT'; -VECTOR_TRANSFORM: 'VECTOR_TRANSFORM'; -VERIFIER: 'VERIFIER'; -VERIFY: 'VERIFY'; -VERSIONING: 'VERSIONING'; -VERSIONS_ENDSCN: 'VERSIONS_ENDSCN'; -VERSIONS_ENDTIME: 'VERSIONS_ENDTIME'; -VERSIONS_OPERATION: 'VERSIONS_OPERATION'; -VERSIONS_STARTSCN: 'VERSIONS_STARTSCN'; -VERSIONS_STARTTIME: 'VERSIONS_STARTTIME'; -VERSIONS: 'VERSIONS'; -VERSIONS_XID: 'VERSIONS_XID'; -VERSION: 'VERSION'; -VIEW: 'VIEW'; -VIOLATION: 'VIOLATION'; -VIRTUAL: 'VIRTUAL'; -VISIBILITY: 'VISIBILITY'; -VISIBLE: 'VISIBLE'; -VOLUME: 'VOLUME'; -VSIZE: 'VSIZE'; -WAIT: 'WAIT'; -WALLET: 'WALLET'; -WARNING: 'WARNING'; -WEEKS: 'WEEKS'; -WEEK: 'WEEK'; -WELLFORMED: 'WELLFORMED'; -WHENEVER: 'WHENEVER'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WHILE: 'WHILE'; -WHITESPACE: 'WHITESPACE'; -WIDTH_BUCKET: 'WIDTH_BUCKET'; -WITHIN: 'WITHIN'; -WITHOUT: 'WITHOUT'; -WITH_PLSQL: 'WITH_PLSQL'; -WITH: 'WITH'; -WORK: 'WORK'; -WRAPPED: 'WRAPPED'; -WRAPPER: 'WRAPPER'; -WRITE: 'WRITE'; -XDB_FASTPATH_INSERT: 'XDB_FASTPATH_INSERT'; -XDB: 'XDB'; -X_DYN_PRUNE: 'X_DYN_PRUNE'; -XID: 'XID'; -XML2OBJECT: 'XML2OBJECT'; -XMLAGG: 'XMLAGG'; -XMLATTRIBUTES: 'XMLATTRIBUTES'; -XMLCAST: 'XMLCAST'; -XMLCDATA: 'XMLCDATA'; -XMLCOLATTVAL: 'XMLCOLATTVAL'; -XMLCOMMENT: 'XMLCOMMENT'; -XMLCONCAT: 'XMLCONCAT'; -XMLDIFF: 'XMLDIFF'; -XML_DML_RWT_STMT: 'XML_DML_RWT_STMT'; -XMLELEMENT: 'XMLELEMENT'; -XMLEXISTS2: 'XMLEXISTS2'; -XMLEXISTS: 'XMLEXISTS'; -XMLFOREST: 'XMLFOREST'; -XMLINDEX: 'XMLINDEX'; -XMLINDEX_REWRITE_IN_SELECT: 'XMLINDEX_REWRITE_IN_SELECT'; -XMLINDEX_REWRITE: 'XMLINDEX_REWRITE'; -XMLINDEX_SEL_IDX_TBL: 'XMLINDEX_SEL_IDX_TBL'; -XMLISNODE: 'XMLISNODE'; -XMLISVALID: 'XMLISVALID'; -XMLNAMESPACES: 'XMLNAMESPACES'; -XMLPARSE: 'XMLPARSE'; -XMLPATCH: 'XMLPATCH'; -XMLPI: 'XMLPI'; -XMLQUERYVAL: 'XMLQUERYVAL'; -XMLQUERY: 'XMLQUERY'; -XMLROOT: 'XMLROOT'; -XMLSCHEMA: 'XMLSCHEMA'; -XMLSERIALIZE: 'XMLSERIALIZE'; -XMLTABLE: 'XMLTABLE'; -XMLTRANSFORMBLOB: 'XMLTRANSFORMBLOB'; -XMLTRANSFORM: 'XMLTRANSFORM'; -XMLTYPE: 'XMLTYPE'; -XML: 'XML'; -XPATHTABLE: 'XPATHTABLE'; -XS_SYS_CONTEXT: 'XS_SYS_CONTEXT'; -XS: 'XS'; -XTRANSPORT: 'XTRANSPORT'; -YEARS: 'YEARS'; -YEAR: 'YEAR'; -YES: 'YES'; -YMINTERVAL_UNCONSTRAINED: 'YMINTERVAL_UNCONSTRAINED'; -ZONEMAP: 'ZONEMAP'; -ZONE: 'ZONE'; -PREDICTION: 'PREDICTION'; -PREDICTION_BOUNDS: 'PREDICTION_BOUNDS'; -PREDICTION_COST: 'PREDICTION_COST'; -PREDICTION_DETAILS: 'PREDICTION_DETAILS'; -PREDICTION_PROBABILITY: 'PREDICTION_PROBABILITY'; -PREDICTION_SET: 'PREDICTION_SET'; +ABORT : 'ABORT'; +ABS : 'ABS'; +ACCESS : 'ACCESS'; +ACCESSED : 'ACCESSED'; +ACCOUNT : 'ACCOUNT'; +ACL : 'ACL'; +ACOS : 'ACOS'; +ACTION : 'ACTION'; +ACTIONS : 'ACTIONS'; +ACTIVATE : 'ACTIVATE'; +ACTIVE : 'ACTIVE'; +ACTIVE_COMPONENT : 'ACTIVE_COMPONENT'; +ACTIVE_DATA : 'ACTIVE_DATA'; +ACTIVE_FUNCTION : 'ACTIVE_FUNCTION'; +ACTIVE_TAG : 'ACTIVE_TAG'; +ACTIVITY : 'ACTIVITY'; +ADAPTIVE_PLAN : 'ADAPTIVE_PLAN'; +ADD : 'ADD'; +ADD_COLUMN : 'ADD_COLUMN'; +ADD_GROUP : 'ADD_GROUP'; +ADD_MONTHS : 'ADD_MONTHS'; +ADJ_DATE : 'ADJ_DATE'; +ADMIN : 'ADMIN'; +ADMINISTER : 'ADMINISTER'; +ADMINISTRATOR : 'ADMINISTRATOR'; +ADVANCED : 'ADVANCED'; +ADVISE : 'ADVISE'; +ADVISOR : 'ADVISOR'; +AFD_DISKSTRING : 'AFD_DISKSTRING'; +AFTER : 'AFTER'; +AGENT : 'AGENT'; +AGGREGATE : 'AGGREGATE'; +A_LETTER : 'A'; +ALIAS : 'ALIAS'; +ALL : 'ALL'; +ALLOCATE : 'ALLOCATE'; +ALLOW : 'ALLOW'; +ALL_ROWS : 'ALL_ROWS'; +ALTER : 'ALTER'; +ALWAYS : 'ALWAYS'; +ANALYZE : 'ANALYZE'; +ANCILLARY : 'ANCILLARY'; +AND : 'AND'; +AND_EQUAL : 'AND_EQUAL'; +ANOMALY : 'ANOMALY'; +ANSI_REARCH : 'ANSI_REARCH'; +ANTIJOIN : 'ANTIJOIN'; +ANY : 'ANY'; +ANYSCHEMA : 'ANYSCHEMA'; +APPEND : 'APPEND'; +APPENDCHILDXML : 'APPENDCHILDXML'; +APPEND_VALUES : 'APPEND_VALUES'; +APPLICATION : 'APPLICATION'; +APPLY : 'APPLY'; +APPROX_COUNT_DISTINCT : 'APPROX_COUNT_DISTINCT'; +ARCHIVAL : 'ARCHIVAL'; +ARCHIVE : 'ARCHIVE'; +ARCHIVED : 'ARCHIVED'; +ARCHIVELOG : 'ARCHIVELOG'; +ARRAY : 'ARRAY'; +AS : 'AS'; +ASC : 'ASC'; +ASCII : 'ASCII'; +ASCIISTR : 'ASCIISTR'; +ASIN : 'ASIN'; +ASIS : 'ASIS'; +ASSEMBLY : 'ASSEMBLY'; +ASSIGN : 'ASSIGN'; +ASSOCIATE : 'ASSOCIATE'; +ASYNC : 'ASYNC'; +ASYNCHRONOUS : 'ASYNCHRONOUS'; +ATAN2 : 'ATAN2'; +ATAN : 'ATAN'; +AT : 'AT'; +ATTRIBUTE : 'ATTRIBUTE'; +ATTRIBUTES : 'ATTRIBUTES'; +AUDIT : 'AUDIT'; +AUTHENTICATED : 'AUTHENTICATED'; +AUTHENTICATION : 'AUTHENTICATION'; +AUTHID : 'AUTHID'; +AUTHORIZATION : 'AUTHORIZATION'; +AUTOALLOCATE : 'AUTOALLOCATE'; +AUTO : 'AUTO'; +AUTOBACKUP : 'AUTOBACKUP'; +AUTOEXTEND : 'AUTOEXTEND'; +AUTO_LOGIN : 'AUTO_LOGIN'; +AUTOMATIC : 'AUTOMATIC'; +AUTONOMOUS_TRANSACTION : 'AUTONOMOUS_TRANSACTION'; +AUTO_REOPTIMIZE : 'AUTO_REOPTIMIZE'; +AVAILABILITY : 'AVAILABILITY'; +AVRO : 'AVRO'; +BACKGROUND : 'BACKGROUND'; +BACKUP : 'BACKUP'; +BACKUPSET : 'BACKUPSET'; +BASIC : 'BASIC'; +BASICFILE : 'BASICFILE'; +BATCH : 'BATCH'; +BATCHSIZE : 'BATCHSIZE'; +BATCH_TABLE_ACCESS_BY_ROWID : 'BATCH_TABLE_ACCESS_BY_ROWID'; +BECOME : 'BECOME'; +BEFORE : 'BEFORE'; +BEGIN : 'BEGIN'; +BEGINNING : 'BEGINNING'; +BEGIN_OUTLINE_DATA : 'BEGIN_OUTLINE_DATA'; +BEHALF : 'BEHALF'; +BEQUEATH : 'BEQUEATH'; +BETWEEN : 'BETWEEN'; +BFILE : 'BFILE'; +BFILENAME : 'BFILENAME'; +BIGFILE : 'BIGFILE'; +BINARY : 'BINARY'; +BINARY_DOUBLE : 'BINARY_DOUBLE'; +BINARY_DOUBLE_INFINITY : 'BINARY_DOUBLE_INFINITY'; +BINARY_DOUBLE_NAN : 'BINARY_DOUBLE_NAN'; +BINARY_FLOAT : 'BINARY_FLOAT'; +BINARY_FLOAT_INFINITY : 'BINARY_FLOAT_INFINITY'; +BINARY_FLOAT_NAN : 'BINARY_FLOAT_NAN'; +BINARY_INTEGER : 'BINARY_INTEGER'; +BIND_AWARE : 'BIND_AWARE'; +BINDING : 'BINDING'; +BIN_TO_NUM : 'BIN_TO_NUM'; +BITAND : 'BITAND'; +BITMAP_AND : 'BITMAP_AND'; +BITMAP : 'BITMAP'; +BITMAPS : 'BITMAPS'; +BITMAP_TREE : 'BITMAP_TREE'; +BITS : 'BITS'; +BLOB : 'BLOB'; +BLOCK : 'BLOCK'; +BLOCK_RANGE : 'BLOCK_RANGE'; +BLOCKS : 'BLOCKS'; +BLOCKSIZE : 'BLOCKSIZE'; +BODY : 'BODY'; +BOOLEAN : 'BOOLEAN'; +BOTH : 'BOTH'; +BOUND : 'BOUND'; +BRANCH : 'BRANCH'; +BREADTH : 'BREADTH'; +BROADCAST : 'BROADCAST'; +BSON : 'BSON'; +BUFFER : 'BUFFER'; +BUFFER_CACHE : 'BUFFER_CACHE'; +BUFFER_POOL : 'BUFFER_POOL'; +BUILD : 'BUILD'; +BULK : 'BULK'; +BY : 'BY'; +BYPASS_RECURSIVE_CHECK : 'BYPASS_RECURSIVE_CHECK'; +BYPASS_UJVC : 'BYPASS_UJVC'; +BYTE : 'BYTE'; +CACHE : 'CACHE'; +CACHE_CB : 'CACHE_CB'; +CACHE_INSTANCES : 'CACHE_INSTANCES'; +CACHE_TEMP_TABLE : 'CACHE_TEMP_TABLE'; +CACHING : 'CACHING'; +CALCULATED : 'CALCULATED'; +CALLBACK : 'CALLBACK'; +CALL : 'CALL'; +CANCEL : 'CANCEL'; +CANONICAL : 'CANONICAL'; +CAPACITY : 'CAPACITY'; +CARDINALITY : 'CARDINALITY'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CATEGORY : 'CATEGORY'; +CDBDEFAULT : 'CDB$DEFAULT'; +CEIL : 'CEIL'; +CELL_FLASH_CACHE : 'CELL_FLASH_CACHE'; +CERTIFICATE : 'CERTIFICATE'; +CFILE : 'CFILE'; +CHAINED : 'CHAINED'; +CHANGE : 'CHANGE'; +CHANGETRACKING : 'CHANGETRACKING'; +CHANGE_DUPKEY_ERROR_INDEX : 'CHANGE_DUPKEY_ERROR_INDEX'; +CHARACTER : 'CHARACTER'; +CHAR : 'CHAR'; +CHAR_CS : 'CHAR_CS'; +CHARTOROWID : 'CHARTOROWID'; +CHECK_ACL_REWRITE : 'CHECK_ACL_REWRITE'; +CHECK : 'CHECK'; +CHECKPOINT : 'CHECKPOINT'; +CHILD : 'CHILD'; +CHOOSE : 'CHOOSE'; +CHR : 'CHR'; +CHUNK : 'CHUNK'; +CLASS : 'CLASS'; +CLASSIFIER : 'CLASSIFIER'; +CLEANUP : 'CLEANUP'; +CLEAR : 'CLEAR'; +C_LETTER : 'C'; +CLIENT : 'CLIENT'; +CLOB : 'CLOB'; +CLONE : 'CLONE'; +CLOSE_CACHED_OPEN_CURSORS : 'CLOSE_CACHED_OPEN_CURSORS'; +CLOSE : 'CLOSE'; +CLUSTER_BY_ROWID : 'CLUSTER_BY_ROWID'; +CLUSTER : 'CLUSTER'; +CLUSTER_DETAILS : 'CLUSTER_DETAILS'; +CLUSTER_DISTANCE : 'CLUSTER_DISTANCE'; +CLUSTER_ID : 'CLUSTER_ID'; +CLUSTERING : 'CLUSTERING'; +CLUSTERING_FACTOR : 'CLUSTERING_FACTOR'; +CLUSTER_PROBABILITY : 'CLUSTER_PROBABILITY'; +CLUSTER_SET : 'CLUSTER_SET'; +COALESCE : 'COALESCE'; +COALESCE_SQ : 'COALESCE_SQ'; +COARSE : 'COARSE'; +CO_AUTH_IND : 'CO_AUTH_IND'; +COLD : 'COLD'; +COLLECT : 'COLLECT'; +COLUMNAR : 'COLUMNAR'; +COLUMN_AUTH_INDICATOR : 'COLUMN_AUTH_INDICATOR'; +COLUMN : 'COLUMN'; +COLUMNS : 'COLUMNS'; +COLUMN_STATS : 'COLUMN_STATS'; +COLUMN_VALUE : 'COLUMN_VALUE'; +COMMENT : 'COMMENT'; +COMMIT : 'COMMIT'; +COMMITTED : 'COMMITTED'; +COMMON_DATA : 'COMMON_DATA'; +COMPACT : 'COMPACT'; +COMPATIBILITY : 'COMPATIBILITY'; +COMPILE : 'COMPILE'; +COMPLETE : 'COMPLETE'; +COMPLIANCE : 'COMPLIANCE'; +COMPONENT : 'COMPONENT'; +COMPONENTS : 'COMPONENTS'; +COMPOSE : 'COMPOSE'; +COMPOSITE : 'COMPOSITE'; +COMPOSITE_LIMIT : 'COMPOSITE_LIMIT'; +COMPOUND : 'COMPOUND'; +COMPRESS : 'COMPRESS'; +COMPUTE : 'COMPUTE'; +CONCAT : 'CONCAT'; +CON_DBID_TO_ID : 'CON_DBID_TO_ID'; +CONDITIONAL : 'CONDITIONAL'; +CONDITION : 'CONDITION'; +CONFIRM : 'CONFIRM'; +CONFORMING : 'CONFORMING'; +CON_GUID_TO_ID : 'CON_GUID_TO_ID'; +CON_ID : 'CON_ID'; +CON_NAME_TO_ID : 'CON_NAME_TO_ID'; +CONNECT_BY_CB_WHR_ONLY : 'CONNECT_BY_CB_WHR_ONLY'; +CONNECT_BY_COMBINE_SW : 'CONNECT_BY_COMBINE_SW'; +CONNECT_BY_COST_BASED : 'CONNECT_BY_COST_BASED'; +CONNECT_BY_ELIM_DUPS : 'CONNECT_BY_ELIM_DUPS'; +CONNECT_BY_FILTERING : 'CONNECT_BY_FILTERING'; +CONNECT_BY_ISCYCLE : 'CONNECT_BY_ISCYCLE'; +CONNECT_BY_ISLEAF : 'CONNECT_BY_ISLEAF'; +CONNECT_BY_ROOT : 'CONNECT_BY_ROOT'; +CONNECT : 'CONNECT'; +CONNECT_TIME : 'CONNECT_TIME'; +CONSIDER : 'CONSIDER'; +CONSISTENT : 'CONSISTENT'; +CONSTANT : 'CONSTANT'; +CONST : 'CONST'; +CONSTRAINT : 'CONSTRAINT'; +CONSTRAINTS : 'CONSTRAINTS'; +CONSTRUCTOR : 'CONSTRUCTOR'; +CONTAINER : 'CONTAINER'; +CONTAINER_DATA : 'CONTAINER_DATA'; +CONTAINERS : 'CONTAINERS'; +CONTENT : 'CONTENT'; +CONTENTS : 'CONTENTS'; +CONTEXT : 'CONTEXT'; +CONTINUE : 'CONTINUE'; +CONTROLFILE : 'CONTROLFILE'; +CON_UID_TO_ID : 'CON_UID_TO_ID'; +CONVERT : 'CONVERT'; +COOKIE : 'COOKIE'; +COPY : 'COPY'; +CORR_K : 'CORR_K'; +CORR_S : 'CORR_S'; +CORRUPTION : 'CORRUPTION'; +CORRUPT_XID_ALL : 'CORRUPT_XID_ALL'; +CORRUPT_XID : 'CORRUPT_XID'; +COS : 'COS'; +COSH : 'COSH'; +COST : 'COST'; +COST_XML_QUERY_REWRITE : 'COST_XML_QUERY_REWRITE'; +COUNT : 'COUNT'; +COVAR_POP : 'COVAR_POP'; +COVAR_SAMP : 'COVAR_SAMP'; +CPU_COSTING : 'CPU_COSTING'; +CPU_PER_CALL : 'CPU_PER_CALL'; +CPU_PER_SESSION : 'CPU_PER_SESSION'; +CRASH : 'CRASH'; +CREATE : 'CREATE'; +CREATE_FILE_DEST : 'CREATE_FILE_DEST'; +CREATE_STORED_OUTLINES : 'CREATE_STORED_OUTLINES'; +CREATION : 'CREATION'; +CREDENTIAL : 'CREDENTIAL'; +CRITICAL : 'CRITICAL'; +CROSS : 'CROSS'; +CROSSEDITION : 'CROSSEDITION'; +CSCONVERT : 'CSCONVERT'; +CUBE_AJ : 'CUBE_AJ'; +CUBE : 'CUBE'; +CUBE_GB : 'CUBE_GB'; +CUBE_SJ : 'CUBE_SJ'; +CUME_DISTM : 'CUME_DISTM'; +CURRENT : 'CURRENT'; +CURRENT_DATE : 'CURRENT_DATE'; +CURRENT_SCHEMA : 'CURRENT_SCHEMA'; +CURRENT_TIME : 'CURRENT_TIME'; +CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +CURRENT_USER : 'CURRENT_USER'; +CURRENTV : 'CURRENTV'; +CURSOR : 'CURSOR'; +CURSOR_SHARING_EXACT : 'CURSOR_SHARING_EXACT'; +CURSOR_SPECIFIC_SEGMENT : 'CURSOR_SPECIFIC_SEGMENT'; +CUSTOMDATUM : 'CUSTOMDATUM'; +CV : 'CV'; +CYCLE : 'CYCLE'; +DANGLING : 'DANGLING'; +DATABASE : 'DATABASE'; +DATA : 'DATA'; +DATAFILE : 'DATAFILE'; +DATAFILES : 'DATAFILES'; +DATAGUARDCONFIG : 'DATAGUARDCONFIG'; +DATAMOVEMENT : 'DATAMOVEMENT'; +DATAOBJNO : 'DATAOBJNO'; +DATAOBJ_TO_MAT_PARTITION : 'DATAOBJ_TO_MAT_PARTITION'; +DATAOBJ_TO_PARTITION : 'DATAOBJ_TO_PARTITION'; +DATAPUMP : 'DATAPUMP'; +DATA_SECURITY_REWRITE_LIMIT : 'DATA_SECURITY_REWRITE_LIMIT'; +DATE : 'DATE'; +DATE_MODE : 'DATE_MODE'; +DAY : 'DAY'; +DAYS : 'DAYS'; +DBA : 'DBA'; +DBA_RECYCLEBIN : 'DBA_RECYCLEBIN'; +DBMS_STATS : 'DBMS_STATS'; +DB_ROLE_CHANGE : 'DB_ROLE_CHANGE'; +DBTIMEZONE : 'DBTIMEZONE'; +DB_UNIQUE_NAME : 'DB_UNIQUE_NAME'; +DB_VERSION : 'DB_VERSION'; +DDL : 'DDL'; +DEALLOCATE : 'DEALLOCATE'; +DEBUG : 'DEBUG'; +DEBUGGER : 'DEBUGGER'; +DEC : 'DEC'; +DECIMAL : 'DECIMAL'; +DECLARE : 'DECLARE'; +DECOMPOSE : 'DECOMPOSE'; +DECORRELATE : 'DECORRELATE'; +DECR : 'DECR'; +DECREMENT : 'DECREMENT'; +DECRYPT : 'DECRYPT'; +DEDUPLICATE : 'DEDUPLICATE'; +DEFAULT : 'DEFAULT'; +DEFAULTS : 'DEFAULTS'; +DEFERRABLE : 'DEFERRABLE'; +DEFERRED : 'DEFERRED'; +DEFINED : 'DEFINED'; +DEFINE : 'DEFINE'; +DEFINER : 'DEFINER'; +DEGREE : 'DEGREE'; +DELAY : 'DELAY'; +DELEGATE : 'DELEGATE'; +DELETE_ALL : 'DELETE_ALL'; +DELETE : 'DELETE'; +DELETEXML : 'DELETEXML'; +DEMAND : 'DEMAND'; +DENSE_RANKM : 'DENSE_RANKM'; +DEPENDENT : 'DEPENDENT'; +DEPTH : 'DEPTH'; +DEQUEUE : 'DEQUEUE'; +DEREF : 'DEREF'; +DEREF_NO_REWRITE : 'DEREF_NO_REWRITE'; +DESC : 'DESC'; +DESTROY : 'DESTROY'; +DETACHED : 'DETACHED'; +DETERMINES : 'DETERMINES'; +DETERMINISTIC : 'DETERMINISTIC'; +DICTIONARY : 'DICTIONARY'; +DIMENSION : 'DIMENSION'; +DIMENSIONS : 'DIMENSIONS'; +DIRECT_LOAD : 'DIRECT_LOAD'; +DIRECTORY : 'DIRECTORY'; +DIRECT_PATH : 'DIRECT_PATH'; +DISABLE_ALL : 'DISABLE_ALL'; +DISABLE : 'DISABLE'; +DISABLE_PARALLEL_DML : 'DISABLE_PARALLEL_DML'; +DISABLE_PRESET : 'DISABLE_PRESET'; +DISABLE_RPKE : 'DISABLE_RPKE'; +DISALLOW : 'DISALLOW'; +DISASSOCIATE : 'DISASSOCIATE'; +DISCARD : 'DISCARD'; +DISCONNECT : 'DISCONNECT'; +DISK : 'DISK'; +DISKGROUP : 'DISKGROUP'; +DISKGROUP_PLUS : '\'+ DISKGROUP'; +DISKS : 'DISKS'; +DISMOUNT : 'DISMOUNT'; +DISTINCT : 'DISTINCT'; +DISTINGUISHED : 'DISTINGUISHED'; +DISTRIBUTED : 'DISTRIBUTED'; +DISTRIBUTE : 'DISTRIBUTE'; +DML : 'DML'; +DML_UPDATE : 'DML_UPDATE'; +DOCFIDELITY : 'DOCFIDELITY'; +DOCUMENT : 'DOCUMENT'; +DOMAIN_INDEX_FILTER : 'DOMAIN_INDEX_FILTER'; +DOMAIN_INDEX_NO_SORT : 'DOMAIN_INDEX_NO_SORT'; +DOMAIN_INDEX_SORT : 'DOMAIN_INDEX_SORT'; +DOUBLE : 'DOUBLE'; +DOWNGRADE : 'DOWNGRADE'; +DRIVING_SITE : 'DRIVING_SITE'; +DROP_COLUMN : 'DROP_COLUMN'; +DROP : 'DROP'; +DROP_GROUP : 'DROP_GROUP'; +DSINTERVAL_UNCONSTRAINED : 'DSINTERVAL_UNCONSTRAINED'; +DST_UPGRADE_INSERT_CONV : 'DST_UPGRADE_INSERT_CONV'; +DUMP : 'DUMP'; +DUMPSET : 'DUMPSET'; +DUPLICATE : 'DUPLICATE'; +DV : 'DV'; +DYNAMIC : 'DYNAMIC'; +DYNAMIC_SAMPLING : 'DYNAMIC_SAMPLING'; +DYNAMIC_SAMPLING_EST_CDN : 'DYNAMIC_SAMPLING_EST_CDN'; +EACH : 'EACH'; +EDITIONABLE : 'EDITIONABLE'; +EDITION : 'EDITION'; +EDITIONING : 'EDITIONING'; +EDITIONS : 'EDITIONS'; +ELEMENT : 'ELEMENT'; +ELIM_GROUPBY : 'ELIM_GROUPBY'; +ELIMINATE_JOIN : 'ELIMINATE_JOIN'; +ELIMINATE_OBY : 'ELIMINATE_OBY'; +ELIMINATE_OUTER_JOIN : 'ELIMINATE_OUTER_JOIN'; +ELSE : 'ELSE'; +ELSIF : 'ELSIF'; +EM : 'EM'; +EMPTY_BLOB : 'EMPTY_BLOB'; +EMPTY_CLOB : 'EMPTY_CLOB'; +EMPTY : 'EMPTY'; +ENABLE_ALL : 'ENABLE_ALL'; +ENABLE : 'ENABLE'; +ENABLE_PARALLEL_DML : 'ENABLE_PARALLEL_DML'; +ENABLE_PRESET : 'ENABLE_PRESET'; +ENCODING : 'ENCODING'; +ENCRYPT : 'ENCRYPT'; +ENCRYPTION : 'ENCRYPTION'; +END : 'END'; +END_OUTLINE_DATA : 'END_OUTLINE_DATA'; +ENFORCED : 'ENFORCED'; +ENFORCE : 'ENFORCE'; +ENQUEUE : 'ENQUEUE'; +ENTERPRISE : 'ENTERPRISE'; +ENTITYESCAPING : 'ENTITYESCAPING'; +ENTRY : 'ENTRY'; +EQUIPART : 'EQUIPART'; +ERR : 'ERR'; +ERROR_ARGUMENT : 'ERROR_ARGUMENT'; +ERROR : 'ERROR'; +ERROR_ON_OVERLAP_TIME : 'ERROR_ON_OVERLAP_TIME'; +ERRORS : 'ERRORS'; +ESCAPE : 'ESCAPE'; +ESTIMATE : 'ESTIMATE'; +EVAL : 'EVAL'; +EVALNAME : 'EVALNAME'; +EVALUATE : 'EVALUATE'; +EVALUATION : 'EVALUATION'; +EVENTS : 'EVENTS'; +EVERY : 'EVERY'; +EXCEPT : 'EXCEPT'; +EXCEPTION : 'EXCEPTION'; +EXCEPTION_INIT : 'EXCEPTION_INIT'; +EXCEPTIONS : 'EXCEPTIONS'; +EXCHANGE : 'EXCHANGE'; +EXCLUDE : 'EXCLUDE'; +EXCLUDING : 'EXCLUDING'; +EXCLUSIVE : 'EXCLUSIVE'; +EXECUTE : 'EXECUTE'; +EXEMPT : 'EXEMPT'; +EXISTING : 'EXISTING'; +EXISTS : 'EXISTS'; +EXISTSNODE : 'EXISTSNODE'; +EXIT : 'EXIT'; +EXPAND_GSET_TO_UNION : 'EXPAND_GSET_TO_UNION'; +EXPAND_TABLE : 'EXPAND_TABLE'; +EXP : 'EXP'; +EXPIRE : 'EXPIRE'; +EXPLAIN : 'EXPLAIN'; +EXPLOSION : 'EXPLOSION'; +EXPORT : 'EXPORT'; +EXPR_CORR_CHECK : 'EXPR_CORR_CHECK'; +EXPRESS : 'EXPRESS'; +EXTENDS : 'EXTENDS'; +EXTENT : 'EXTENT'; +EXTENTS : 'EXTENTS'; +EXTERNAL : 'EXTERNAL'; +EXTERNALLY : 'EXTERNALLY'; +EXTRACTCLOBXML : 'EXTRACTCLOBXML'; +EXTRACT : 'EXTRACT'; +EXTRACTVALUE : 'EXTRACTVALUE'; +EXTRA : 'EXTRA'; +FACILITY : 'FACILITY'; +FACT : 'FACT'; +FACTOR : 'FACTOR'; +FACTORIZE_JOIN : 'FACTORIZE_JOIN'; +FAILED : 'FAILED'; +FAILED_LOGIN_ATTEMPTS : 'FAILED_LOGIN_ATTEMPTS'; +FAILGROUP : 'FAILGROUP'; +FAILOVER : 'FAILOVER'; +FAILURE : 'FAILURE'; +FALSE : 'FALSE'; +FAMILY : 'FAMILY'; +FAR : 'FAR'; +FAST : 'FAST'; +FASTSTART : 'FASTSTART'; +FBTSCAN : 'FBTSCAN'; +FEATURE_DETAILS : 'FEATURE_DETAILS'; +FEATURE_ID : 'FEATURE_ID'; +FEATURE_SET : 'FEATURE_SET'; +FEATURE_VALUE : 'FEATURE_VALUE'; +FETCH : 'FETCH'; +FILE : 'FILE'; +FILE_NAME_CONVERT : 'FILE_NAME_CONVERT'; +FILESYSTEM_LIKE_LOGGING : 'FILESYSTEM_LIKE_LOGGING'; +FILTER : 'FILTER'; +FINAL : 'FINAL'; +FINE : 'FINE'; +FINISH : 'FINISH'; +FIRST : 'FIRST'; +FIRSTM : 'FIRSTM'; +FIRST_ROWS : 'FIRST_ROWS'; +FIRST_VALUE : 'FIRST_VALUE'; +FIXED_VIEW_DATA : 'FIXED_VIEW_DATA'; +FLAGGER : 'FLAGGER'; +FLASHBACK : 'FLASHBACK'; +FLASH_CACHE : 'FLASH_CACHE'; +FLOAT : 'FLOAT'; +FLOB : 'FLOB'; +FLOOR : 'FLOOR'; +FLUSH : 'FLUSH'; +FOLDER : 'FOLDER'; +FOLLOWING : 'FOLLOWING'; +FOLLOWS : 'FOLLOWS'; +FORALL : 'FORALL'; +FORCE : 'FORCE'; +FORCE_XML_QUERY_REWRITE : 'FORCE_XML_QUERY_REWRITE'; +FOREIGN : 'FOREIGN'; +FOREVER : 'FOREVER'; +FOR : 'FOR'; +FORMAT : 'FORMAT'; +FORWARD : 'FORWARD'; +FRAGMENT_NUMBER : 'FRAGMENT_NUMBER'; +FREELIST : 'FREELIST'; +FREELISTS : 'FREELISTS'; +FREEPOOLS : 'FREEPOOLS'; +FRESH : 'FRESH'; +FROM : 'FROM'; +FROM_TZ : 'FROM_TZ'; +FULL : 'FULL'; +FULL_OUTER_JOIN_TO_OUTER : 'FULL_OUTER_JOIN_TO_OUTER'; +FUNCTION : 'FUNCTION'; +FUNCTIONS : 'FUNCTIONS'; +GATHER_OPTIMIZER_STATISTICS : 'GATHER_OPTIMIZER_STATISTICS'; +GATHER_PLAN_STATISTICS : 'GATHER_PLAN_STATISTICS'; +GBY_CONC_ROLLUP : 'GBY_CONC_ROLLUP'; +GBY_PUSHDOWN : 'GBY_PUSHDOWN'; +GENERATED : 'GENERATED'; +GET : 'GET'; +GLOBAL : 'GLOBAL'; +GLOBALLY : 'GLOBALLY'; +GLOBAL_NAME : 'GLOBAL_NAME'; +GLOBAL_TOPIC_ENABLED : 'GLOBAL_TOPIC_ENABLED'; +GOTO : 'GOTO'; +GRANT : 'GRANT'; +GROUP_BY : 'GROUP_BY'; +GROUP : 'GROUP'; +GROUP_ID : 'GROUP_ID'; +GROUPING : 'GROUPING'; +GROUPING_ID : 'GROUPING_ID'; +GROUPS : 'GROUPS'; +GUARANTEED : 'GUARANTEED'; +GUARANTEE : 'GUARANTEE'; +GUARD : 'GUARD'; +HASH_AJ : 'HASH_AJ'; +HASH : 'HASH'; +HASHKEYS : 'HASHKEYS'; +HASH_SJ : 'HASH_SJ'; +HAVING : 'HAVING'; +HEADER : 'HEADER'; +HEAP : 'HEAP'; +HELP : 'HELP'; +HEXTORAW : 'HEXTORAW'; +HEXTOREF : 'HEXTOREF'; +HIDDEN_KEYWORD : 'HIDDEN'; +HIDE : 'HIDE'; +HIERARCHY : 'HIERARCHY'; +HIGH : 'HIGH'; +HINTSET_BEGIN : 'HINTSET_BEGIN'; +HINTSET_END : 'HINTSET_END'; +HOT : 'HOT'; +HOUR : 'HOUR'; +HWM_BROKERED : 'HWM_BROKERED'; +HYBRID : 'HYBRID'; +IDENTIFIED : 'IDENTIFIED'; +IDENTIFIER : 'IDENTIFIER'; +IDENTITY : 'IDENTITY'; +IDGENERATORS : 'IDGENERATORS'; +ID : 'ID'; +IDLE_TIME : 'IDLE_TIME'; +IF : 'IF'; +IGNORE : 'IGNORE'; +IGNORE_OPTIM_EMBEDDED_HINTS : 'IGNORE_OPTIM_EMBEDDED_HINTS'; +IGNORE_ROW_ON_DUPKEY_INDEX : 'IGNORE_ROW_ON_DUPKEY_INDEX'; +IGNORE_WHERE_CLAUSE : 'IGNORE_WHERE_CLAUSE'; +ILM : 'ILM'; +IMMEDIATE : 'IMMEDIATE'; +IMPACT : 'IMPACT'; +IMPORT : 'IMPORT'; +INACTIVE : 'INACTIVE'; +INCLUDE : 'INCLUDE'; +INCLUDE_VERSION : 'INCLUDE_VERSION'; +INCLUDING : 'INCLUDING'; +INCREMENTAL : 'INCREMENTAL'; +INCREMENT : 'INCREMENT'; +INCR : 'INCR'; +INDENT : 'INDENT'; +INDEX_ASC : 'INDEX_ASC'; +INDEX_COMBINE : 'INDEX_COMBINE'; +INDEX_DESC : 'INDEX_DESC'; +INDEXED : 'INDEXED'; +INDEXES : 'INDEXES'; +INDEX_FFS : 'INDEX_FFS'; +INDEX_FILTER : 'INDEX_FILTER'; +INDEX : 'INDEX'; +INDEXING : 'INDEXING'; +INDEX_JOIN : 'INDEX_JOIN'; +INDEX_ROWS : 'INDEX_ROWS'; +INDEX_RRS : 'INDEX_RRS'; +INDEX_RS_ASC : 'INDEX_RS_ASC'; +INDEX_RS_DESC : 'INDEX_RS_DESC'; +INDEX_RS : 'INDEX_RS'; +INDEX_SCAN : 'INDEX_SCAN'; +INDEX_SKIP_SCAN : 'INDEX_SKIP_SCAN'; +INDEX_SS_ASC : 'INDEX_SS_ASC'; +INDEX_SS_DESC : 'INDEX_SS_DESC'; +INDEX_SS : 'INDEX_SS'; +INDEX_STATS : 'INDEX_STATS'; +INDEXTYPE : 'INDEXTYPE'; +INDEXTYPES : 'INDEXTYPES'; +INDICATOR : 'INDICATOR'; +INDICES : 'INDICES'; +INFINITE : 'INFINITE'; +INFORMATIONAL : 'INFORMATIONAL'; +INHERIT : 'INHERIT'; +IN : 'IN'; +INITCAP : 'INITCAP'; +INITIAL : 'INITIAL'; +INITIALIZED : 'INITIALIZED'; +INITIALLY : 'INITIALLY'; +INITRANS : 'INITRANS'; +INLINE : 'INLINE'; +INLINE_XMLTYPE_NT : 'INLINE_XMLTYPE_NT'; +INMEMORY : 'INMEMORY'; +IN_MEMORY_METADATA : 'IN_MEMORY_METADATA'; +INMEMORY_PRUNING : 'INMEMORY_PRUNING'; +INNER : 'INNER'; +INOUT : 'INOUT'; +INPLACE : 'INPLACE'; +INSERTCHILDXMLAFTER : 'INSERTCHILDXMLAFTER'; +INSERTCHILDXMLBEFORE : 'INSERTCHILDXMLBEFORE'; +INSERTCHILDXML : 'INSERTCHILDXML'; +INSERT : 'INSERT'; +INSERTXMLAFTER : 'INSERTXMLAFTER'; +INSERTXMLBEFORE : 'INSERTXMLBEFORE'; +INSTANCE : 'INSTANCE'; +INSTANCES : 'INSTANCES'; +INSTANTIABLE : 'INSTANTIABLE'; +INSTANTLY : 'INSTANTLY'; +INSTEAD : 'INSTEAD'; +INSTR2 : 'INSTR2'; +INSTR4 : 'INSTR4'; +INSTRB : 'INSTRB'; +INSTRC : 'INSTRC'; +INSTR : 'INSTR'; +INTEGER : 'INTEGER'; +INTERLEAVED : 'INTERLEAVED'; +INTERMEDIATE : 'INTERMEDIATE'; +INTERNAL_CONVERT : 'INTERNAL_CONVERT'; +INTERNAL_USE : 'INTERNAL_USE'; +INTERPRETED : 'INTERPRETED'; +INTERSECT : 'INTERSECT'; +INTERVAL : 'INTERVAL'; +INT : 'INT'; +INTO : 'INTO'; +INVALIDATE : 'INVALIDATE'; +INVISIBLE : 'INVISIBLE'; +IN_XQUERY : 'IN_XQUERY'; +IS : 'IS'; +ISOLATION : 'ISOLATION'; +ISOLATION_LEVEL : 'ISOLATION_LEVEL'; +ITERATE : 'ITERATE'; +ITERATION_NUMBER : 'ITERATION_NUMBER'; +JAVA : 'JAVA'; +JOB : 'JOB'; +JOIN : 'JOIN'; +JSON_ARRAYAGG : 'JSON_ARRAYAGG'; +JSON_ARRAY : 'JSON_ARRAY'; +JSON_EQUAL : 'JSON_EQUAL'; +JSON_EXISTS2 : 'JSON_EXISTS2'; +JSON_EXISTS : 'JSON_EXISTS'; +JSONGET : 'JSONGET'; +JSON : 'JSON'; +JSON_OBJECTAGG : 'JSON_OBJECTAGG'; +JSON_OBJECT : 'JSON_OBJECT'; +JSONPARSE : 'JSONPARSE'; +JSON_QUERY : 'JSON_QUERY'; +JSON_SERIALIZE : 'JSON_SERIALIZE'; +JSON_TABLE : 'JSON_TABLE'; +JSON_TEXTCONTAINS2 : 'JSON_TEXTCONTAINS2'; +JSON_TEXTCONTAINS : 'JSON_TEXTCONTAINS'; +JSON_VALUE : 'JSON_VALUE'; +KEEP_DUPLICATES : 'KEEP_DUPLICATES'; +KEEP : 'KEEP'; +KERBEROS : 'KERBEROS'; +KEY : 'KEY'; +KEY_LENGTH : 'KEY_LENGTH'; +KEYSIZE : 'KEYSIZE'; +KEYS : 'KEYS'; +KEYSTORE : 'KEYSTORE'; +KILL : 'KILL'; +LABEL : 'LABEL'; +LANGUAGE : 'LANGUAGE'; +LAST_DAY : 'LAST_DAY'; +LAST : 'LAST'; +LAST_VALUE : 'LAST_VALUE'; +LATERAL : 'LATERAL'; +LAX : 'LAX'; +LAYER : 'LAYER'; +LDAP_REGISTRATION_ENABLED : 'LDAP_REGISTRATION_ENABLED'; +LDAP_REGISTRATION : 'LDAP_REGISTRATION'; +LDAP_REG_SYNC_INTERVAL : 'LDAP_REG_SYNC_INTERVAL'; +LEADING : 'LEADING'; +LEFT : 'LEFT'; +LENGTH2 : 'LENGTH2'; +LENGTH4 : 'LENGTH4'; +LENGTHB : 'LENGTHB'; +LENGTHC : 'LENGTHC'; +LENGTH : 'LENGTH'; +LESS : 'LESS'; +LEVEL : 'LEVEL'; +LEVELS : 'LEVELS'; +LIBRARY : 'LIBRARY'; +LIFECYCLE : 'LIFECYCLE'; +LIFE : 'LIFE'; +LIFETIME : 'LIFETIME'; +LIKE2 : 'LIKE2'; +LIKE4 : 'LIKE4'; +LIKEC : 'LIKEC'; +LIKE_EXPAND : 'LIKE_EXPAND'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +LINEAR : 'LINEAR'; +LINK : 'LINK'; +LIST : 'LIST'; +LN : 'LN'; +LNNVL : 'LNNVL'; +LOAD : 'LOAD'; +LOB : 'LOB'; +LOBNVL : 'LOBNVL'; +LOBS : 'LOBS'; +LOCAL_INDEXES : 'LOCAL_INDEXES'; +LOCAL : 'LOCAL'; +LOCALTIME : 'LOCALTIME'; +LOCALTIMESTAMP : 'LOCALTIMESTAMP'; +LOCATION : 'LOCATION'; +LOCATOR : 'LOCATOR'; +LOCKED : 'LOCKED'; +LOCKING : 'LOCKING'; +LOCK : 'LOCK'; +LOGFILE : 'LOGFILE'; +LOGFILES : 'LOGFILES'; +LOGGING : 'LOGGING'; +LOGICAL : 'LOGICAL'; +LOGICAL_READS_PER_CALL : 'LOGICAL_READS_PER_CALL'; +LOGICAL_READS_PER_SESSION : 'LOGICAL_READS_PER_SESSION'; +LOG : 'LOG'; +LOGMINING : 'LOGMINING'; +LOGOFF : 'LOGOFF'; +LOGON : 'LOGON'; +LOG_READ_ONLY_VIOLATIONS : 'LOG_READ_ONLY_VIOLATIONS'; +LONG : 'LONG'; +LOOP : 'LOOP'; +LOWER : 'LOWER'; +LOW : 'LOW'; +LPAD : 'LPAD'; +LTRIM : 'LTRIM'; +MAIN : 'MAIN'; +MAKE_REF : 'MAKE_REF'; +MANAGED : 'MANAGED'; +MANAGE : 'MANAGE'; +MANAGEMENT : 'MANAGEMENT'; +MANAGER : 'MANAGER'; +MANUAL : 'MANUAL'; +MAP : 'MAP'; +MAPPING : 'MAPPING'; +MASTER : 'MASTER'; +MATCHED : 'MATCHED'; +MATCHES : 'MATCHES'; +MATCH : 'MATCH'; +MATCH_NUMBER : 'MATCH_NUMBER'; +MATCH_RECOGNIZE : 'MATCH_RECOGNIZE'; +MATERIALIZED : 'MATERIALIZED'; +MATERIALIZE : 'MATERIALIZE'; +MAXARCHLOGS : 'MAXARCHLOGS'; +MAXDATAFILES : 'MAXDATAFILES'; +MAXEXTENTS : 'MAXEXTENTS'; +MAXIMIZE : 'MAXIMIZE'; +MAXINSTANCES : 'MAXINSTANCES'; +MAXLOGFILES : 'MAXLOGFILES'; +MAXLOGHISTORY : 'MAXLOGHISTORY'; +MAXLOGMEMBERS : 'MAXLOGMEMBERS'; +MAX_SHARED_TEMP_SIZE : 'MAX_SHARED_TEMP_SIZE'; +MAXSIZE : 'MAXSIZE'; +MAXTRANS : 'MAXTRANS'; +MAXVALUE : 'MAXVALUE'; +MEASURE : 'MEASURE'; +MEASURES : 'MEASURES'; +MEDIUM : 'MEDIUM'; +MEMBER : 'MEMBER'; +MEMCOMPRESS : 'MEMCOMPRESS'; +MEMORY : 'MEMORY'; +MERGEACTIONS : 'MERGE$ACTIONS'; +MERGE_AJ : 'MERGE_AJ'; +MERGE_CONST_ON : 'MERGE_CONST_ON'; +MERGE : 'MERGE'; +MERGE_SJ : 'MERGE_SJ'; +METADATA : 'METADATA'; +METHOD : 'METHOD'; +MIGRATE : 'MIGRATE'; +MIGRATION : 'MIGRATION'; +MINEXTENTS : 'MINEXTENTS'; +MINIMIZE : 'MINIMIZE'; +MINIMUM : 'MINIMUM'; +MINING : 'MINING'; +MINUS : 'MINUS'; +MINUS_NULL : 'MINUS_NULL'; +MINUTE : 'MINUTE'; +MINVALUE : 'MINVALUE'; +MIRRORCOLD : 'MIRRORCOLD'; +MIRRORHOT : 'MIRRORHOT'; +MIRROR : 'MIRROR'; +MLSLABEL : 'MLSLABEL'; +MODEL_COMPILE_SUBQUERY : 'MODEL_COMPILE_SUBQUERY'; +MODEL_DONTVERIFY_UNIQUENESS : 'MODEL_DONTVERIFY_UNIQUENESS'; +MODEL_DYNAMIC_SUBQUERY : 'MODEL_DYNAMIC_SUBQUERY'; +MODEL_MIN_ANALYSIS : 'MODEL_MIN_ANALYSIS'; +MODEL : 'MODEL'; +MODEL_NB : 'MODEL_NB'; +MODEL_NO_ANALYSIS : 'MODEL_NO_ANALYSIS'; +MODEL_PBY : 'MODEL_PBY'; +MODEL_PUSH_REF : 'MODEL_PUSH_REF'; +MODEL_SV : 'MODEL_SV'; +MODE : 'MODE'; +MODIFICATION : 'MODIFICATION'; +MODIFY_COLUMN_TYPE : 'MODIFY_COLUMN_TYPE'; +MODIFY : 'MODIFY'; +MOD : 'MOD'; +MODULE : 'MODULE'; +MONITORING : 'MONITORING'; +MONITOR : 'MONITOR'; +MONTH : 'MONTH'; +MONTHS_BETWEEN : 'MONTHS_BETWEEN'; +MONTHS : 'MONTHS'; +MOUNT : 'MOUNT'; +MOUNTPATH : 'MOUNTPATH'; +MOVEMENT : 'MOVEMENT'; +MOVE : 'MOVE'; +MULTIDIMENSIONAL : 'MULTIDIMENSIONAL'; +MULTISET : 'MULTISET'; +MV_MERGE : 'MV_MERGE'; +NAMED : 'NAMED'; +NAME : 'NAME'; +NAMESPACE : 'NAMESPACE'; +NAN : 'NAN'; +NANVL : 'NANVL'; +NATIONAL : 'NATIONAL'; +NATIVE_FULL_OUTER_JOIN : 'NATIVE_FULL_OUTER_JOIN'; +NATIVE : 'NATIVE'; +NATURAL : 'NATURAL'; +NATURALN : 'NATURALN'; +NAV : 'NAV'; +NCHAR_CS : 'NCHAR_CS'; +NCHAR : 'NCHAR'; +NCHR : 'NCHR'; +NCLOB : 'NCLOB'; +NEEDED : 'NEEDED'; +NEG : 'NEG'; +NESTED : 'NESTED'; +NESTED_TABLE_FAST_INSERT : 'NESTED_TABLE_FAST_INSERT'; +NESTED_TABLE_GET_REFS : 'NESTED_TABLE_GET_REFS'; +NESTED_TABLE_ID : 'NESTED_TABLE_ID'; +NESTED_TABLE_SET_REFS : 'NESTED_TABLE_SET_REFS'; +NESTED_TABLE_SET_SETID : 'NESTED_TABLE_SET_SETID'; +NETWORK : 'NETWORK'; +NEVER : 'NEVER'; +NEW : 'NEW'; +NEW_TIME : 'NEW_TIME'; +NEXT_DAY : 'NEXT_DAY'; +NEXT : 'NEXT'; +NL_AJ : 'NL_AJ'; +NLJ_BATCHING : 'NLJ_BATCHING'; +NLJ_INDEX_FILTER : 'NLJ_INDEX_FILTER'; +NLJ_INDEX_SCAN : 'NLJ_INDEX_SCAN'; +NLJ_PREFETCH : 'NLJ_PREFETCH'; +NLS_CALENDAR : 'NLS_CALENDAR'; +NLS_CHARACTERSET : 'NLS_CHARACTERSET'; +NLS_CHARSET_DECL_LEN : 'NLS_CHARSET_DECL_LEN'; +NLS_CHARSET_ID : 'NLS_CHARSET_ID'; +NLS_CHARSET_NAME : 'NLS_CHARSET_NAME'; +NLS_COMP : 'NLS_COMP'; +NLS_CURRENCY : 'NLS_CURRENCY'; +NLS_DATE_FORMAT : 'NLS_DATE_FORMAT'; +NLS_DATE_LANGUAGE : 'NLS_DATE_LANGUAGE'; +NLS_INITCAP : 'NLS_INITCAP'; +NLS_ISO_CURRENCY : 'NLS_ISO_CURRENCY'; +NL_SJ : 'NL_SJ'; +NLS_LANG : 'NLS_LANG'; +NLS_LANGUAGE : 'NLS_LANGUAGE'; +NLS_LENGTH_SEMANTICS : 'NLS_LENGTH_SEMANTICS'; +NLS_LOWER : 'NLS_LOWER'; +NLS_NCHAR_CONV_EXCP : 'NLS_NCHAR_CONV_EXCP'; +NLS_NUMERIC_CHARACTERS : 'NLS_NUMERIC_CHARACTERS'; +NLS_SORT : 'NLS_SORT'; +NLSSORT : 'NLSSORT'; +NLS_SPECIAL_CHARS : 'NLS_SPECIAL_CHARS'; +NLS_TERRITORY : 'NLS_TERRITORY'; +NLS_UPPER : 'NLS_UPPER'; +NO_ACCESS : 'NO_ACCESS'; +NO_ADAPTIVE_PLAN : 'NO_ADAPTIVE_PLAN'; +NO_ANSI_REARCH : 'NO_ANSI_REARCH'; +NOAPPEND : 'NOAPPEND'; +NOARCHIVELOG : 'NOARCHIVELOG'; +NOAUDIT : 'NOAUDIT'; +NO_AUTO_REOPTIMIZE : 'NO_AUTO_REOPTIMIZE'; +NO_BASETABLE_MULTIMV_REWRITE : 'NO_BASETABLE_MULTIMV_REWRITE'; +NO_BATCH_TABLE_ACCESS_BY_ROWID : 'NO_BATCH_TABLE_ACCESS_BY_ROWID'; +NO_BIND_AWARE : 'NO_BIND_AWARE'; +NO_BUFFER : 'NO_BUFFER'; +NOCACHE : 'NOCACHE'; +NO_CARTESIAN : 'NO_CARTESIAN'; +NO_CHECK_ACL_REWRITE : 'NO_CHECK_ACL_REWRITE'; +NO_CLUSTER_BY_ROWID : 'NO_CLUSTER_BY_ROWID'; +NO_CLUSTERING : 'NO_CLUSTERING'; +NO_COALESCE_SQ : 'NO_COALESCE_SQ'; +NO_COMMON_DATA : 'NO_COMMON_DATA'; +NOCOMPRESS : 'NOCOMPRESS'; +NO_CONNECT_BY_CB_WHR_ONLY : 'NO_CONNECT_BY_CB_WHR_ONLY'; +NO_CONNECT_BY_COMBINE_SW : 'NO_CONNECT_BY_COMBINE_SW'; +NO_CONNECT_BY_COST_BASED : 'NO_CONNECT_BY_COST_BASED'; +NO_CONNECT_BY_ELIM_DUPS : 'NO_CONNECT_BY_ELIM_DUPS'; +NO_CONNECT_BY_FILTERING : 'NO_CONNECT_BY_FILTERING'; +NOCOPY : 'NOCOPY'; +NO_COST_XML_QUERY_REWRITE : 'NO_COST_XML_QUERY_REWRITE'; +NO_CPU_COSTING : 'NO_CPU_COSTING'; +NOCPU_COSTING : 'NOCPU_COSTING'; +NOCYCLE : 'NOCYCLE'; +NO_DATA_SECURITY_REWRITE : 'NO_DATA_SECURITY_REWRITE'; +NO_DECORRELATE : 'NO_DECORRELATE'; +NODELAY : 'NODELAY'; +NO_DOMAIN_INDEX_FILTER : 'NO_DOMAIN_INDEX_FILTER'; +NO_DST_UPGRADE_INSERT_CONV : 'NO_DST_UPGRADE_INSERT_CONV'; +NO_ELIM_GROUPBY : 'NO_ELIM_GROUPBY'; +NO_ELIMINATE_JOIN : 'NO_ELIMINATE_JOIN'; +NO_ELIMINATE_OBY : 'NO_ELIMINATE_OBY'; +NO_ELIMINATE_OUTER_JOIN : 'NO_ELIMINATE_OUTER_JOIN'; +NOENTITYESCAPING : 'NOENTITYESCAPING'; +NO_EXPAND_GSET_TO_UNION : 'NO_EXPAND_GSET_TO_UNION'; +NO_EXPAND : 'NO_EXPAND'; +NO_EXPAND_TABLE : 'NO_EXPAND_TABLE'; +NO_FACT : 'NO_FACT'; +NO_FACTORIZE_JOIN : 'NO_FACTORIZE_JOIN'; +NO_FILTERING : 'NO_FILTERING'; +NOFORCE : 'NOFORCE'; +NO_FULL_OUTER_JOIN_TO_OUTER : 'NO_FULL_OUTER_JOIN_TO_OUTER'; +NO_GATHER_OPTIMIZER_STATISTICS : 'NO_GATHER_OPTIMIZER_STATISTICS'; +NO_GBY_PUSHDOWN : 'NO_GBY_PUSHDOWN'; +NOGUARANTEE : 'NOGUARANTEE'; +NO_INDEX_FFS : 'NO_INDEX_FFS'; +NO_INDEX : 'NO_INDEX'; +NO_INDEX_SS : 'NO_INDEX_SS'; +NO_INMEMORY : 'NO_INMEMORY'; +NO_INMEMORY_PRUNING : 'NO_INMEMORY_PRUNING'; +NOKEEP : 'NOKEEP'; +NO_LOAD : 'NO_LOAD'; +NOLOCAL : 'NOLOCAL'; +NOLOGGING : 'NOLOGGING'; +NOMAPPING : 'NOMAPPING'; +NOMAXVALUE : 'NOMAXVALUE'; +NO_MERGE : 'NO_MERGE'; +NOMINIMIZE : 'NOMINIMIZE'; +NOMINVALUE : 'NOMINVALUE'; +NO_MODEL_PUSH_REF : 'NO_MODEL_PUSH_REF'; +NO_MONITORING : 'NO_MONITORING'; +NOMONITORING : 'NOMONITORING'; +NO_MONITOR : 'NO_MONITOR'; +NO_MULTIMV_REWRITE : 'NO_MULTIMV_REWRITE'; +NO_NATIVE_FULL_OUTER_JOIN : 'NO_NATIVE_FULL_OUTER_JOIN'; +NONBLOCKING : 'NONBLOCKING'; +NONEDITIONABLE : 'NONEDITIONABLE'; +NONE : 'NONE'; +NO_NLJ_BATCHING : 'NO_NLJ_BATCHING'; +NO_NLJ_PREFETCH : 'NO_NLJ_PREFETCH'; +NO : 'NO'; +NONSCHEMA : 'NONSCHEMA'; +NO_OBJECT_LINK : 'NO_OBJECT_LINK'; +NOORDER : 'NOORDER'; +NO_ORDER_ROLLUPS : 'NO_ORDER_ROLLUPS'; +NO_OUTER_JOIN_TO_ANTI : 'NO_OUTER_JOIN_TO_ANTI'; +NO_OUTER_JOIN_TO_INNER : 'NO_OUTER_JOIN_TO_INNER'; +NOOVERRIDE : 'NOOVERRIDE'; +NO_PARALLEL_INDEX : 'NO_PARALLEL_INDEX'; +NOPARALLEL_INDEX : 'NOPARALLEL_INDEX'; +NO_PARALLEL : 'NO_PARALLEL'; +NOPARALLEL : 'NOPARALLEL'; +NO_PARTIAL_COMMIT : 'NO_PARTIAL_COMMIT'; +NO_PARTIAL_JOIN : 'NO_PARTIAL_JOIN'; +NO_PARTIAL_ROLLUP_PUSHDOWN : 'NO_PARTIAL_ROLLUP_PUSHDOWN'; +NOPARTITION : 'NOPARTITION'; +NO_PLACE_DISTINCT : 'NO_PLACE_DISTINCT'; +NO_PLACE_GROUP_BY : 'NO_PLACE_GROUP_BY'; +NO_PQ_CONCURRENT_UNION : 'NO_PQ_CONCURRENT_UNION'; +NO_PQ_MAP : 'NO_PQ_MAP'; +NO_PQ_REPLICATE : 'NO_PQ_REPLICATE'; +NO_PQ_SKEW : 'NO_PQ_SKEW'; +NO_PRUNE_GSETS : 'NO_PRUNE_GSETS'; +NO_PULL_PRED : 'NO_PULL_PRED'; +NO_PUSH_PRED : 'NO_PUSH_PRED'; +NO_PUSH_SUBQ : 'NO_PUSH_SUBQ'; +NO_PX_FAULT_TOLERANCE : 'NO_PX_FAULT_TOLERANCE'; +NO_PX_JOIN_FILTER : 'NO_PX_JOIN_FILTER'; +NO_QKN_BUFF : 'NO_QKN_BUFF'; +NO_QUERY_TRANSFORMATION : 'NO_QUERY_TRANSFORMATION'; +NO_REF_CASCADE : 'NO_REF_CASCADE'; +NORELOCATE : 'NORELOCATE'; +NORELY : 'NORELY'; +NOREPAIR : 'NOREPAIR'; +NOREPLAY : 'NOREPLAY'; +NORESETLOGS : 'NORESETLOGS'; +NO_RESULT_CACHE : 'NO_RESULT_CACHE'; +NOREVERSE : 'NOREVERSE'; +NO_REWRITE : 'NO_REWRITE'; +NOREWRITE : 'NOREWRITE'; +NORMAL : 'NORMAL'; +NO_ROOT_SW_FOR_LOCAL : 'NO_ROOT_SW_FOR_LOCAL'; +NOROWDEPENDENCIES : 'NOROWDEPENDENCIES'; +NOSCHEMACHECK : 'NOSCHEMACHECK'; +NOSEGMENT : 'NOSEGMENT'; +NO_SEMIJOIN : 'NO_SEMIJOIN'; +NO_SEMI_TO_INNER : 'NO_SEMI_TO_INNER'; +NO_SET_TO_JOIN : 'NO_SET_TO_JOIN'; +NOSORT : 'NOSORT'; +NO_SQL_TRANSLATION : 'NO_SQL_TRANSLATION'; +NO_SQL_TUNE : 'NO_SQL_TUNE'; +NO_STAR_TRANSFORMATION : 'NO_STAR_TRANSFORMATION'; +NO_STATEMENT_QUEUING : 'NO_STATEMENT_QUEUING'; +NO_STATS_GSETS : 'NO_STATS_GSETS'; +NOSTRICT : 'NOSTRICT'; +NO_SUBQUERY_PRUNING : 'NO_SUBQUERY_PRUNING'; +NO_SUBSTRB_PAD : 'NO_SUBSTRB_PAD'; +NO_SWAP_JOIN_INPUTS : 'NO_SWAP_JOIN_INPUTS'; +NOSWITCH : 'NOSWITCH'; +NO_TABLE_LOOKUP_BY_NL : 'NO_TABLE_LOOKUP_BY_NL'; +NO_TEMP_TABLE : 'NO_TEMP_TABLE'; +NOTHING : 'NOTHING'; +NOTIFICATION : 'NOTIFICATION'; +NOT : 'NOT'; +NO_TRANSFORM_DISTINCT_AGG : 'NO_TRANSFORM_DISTINCT_AGG'; +NO_UNNEST : 'NO_UNNEST'; +NO_USE_CUBE : 'NO_USE_CUBE'; +NO_USE_HASH_AGGREGATION : 'NO_USE_HASH_AGGREGATION'; +NO_USE_HASH_GBY_FOR_PUSHDOWN : 'NO_USE_HASH_GBY_FOR_PUSHDOWN'; +NO_USE_HASH : 'NO_USE_HASH'; +NO_USE_INVISIBLE_INDEXES : 'NO_USE_INVISIBLE_INDEXES'; +NO_USE_MERGE : 'NO_USE_MERGE'; +NO_USE_NL : 'NO_USE_NL'; +NO_USE_VECTOR_AGGREGATION : 'NO_USE_VECTOR_AGGREGATION'; +NOVALIDATE : 'NOVALIDATE'; +NO_VECTOR_TRANSFORM_DIMS : 'NO_VECTOR_TRANSFORM_DIMS'; +NO_VECTOR_TRANSFORM_FACT : 'NO_VECTOR_TRANSFORM_FACT'; +NO_VECTOR_TRANSFORM : 'NO_VECTOR_TRANSFORM'; +NOWAIT : 'NOWAIT'; +NO_XDB_FASTPATH_INSERT : 'NO_XDB_FASTPATH_INSERT'; +NO_XML_DML_REWRITE : 'NO_XML_DML_REWRITE'; +NO_XMLINDEX_REWRITE_IN_SELECT : 'NO_XMLINDEX_REWRITE_IN_SELECT'; +NO_XMLINDEX_REWRITE : 'NO_XMLINDEX_REWRITE'; +NO_XML_QUERY_REWRITE : 'NO_XML_QUERY_REWRITE'; +NO_ZONEMAP : 'NO_ZONEMAP'; +NTH_VALUE : 'NTH_VALUE'; +NULLIF : 'NULLIF'; +NULL_ : 'NULL'; +NULLS : 'NULLS'; +NUMBER : 'NUMBER'; +NUMERIC : 'NUMERIC'; +NUM_INDEX_KEYS : 'NUM_INDEX_KEYS'; +NUMTODSINTERVAL : 'NUMTODSINTERVAL'; +NUMTOYMINTERVAL : 'NUMTOYMINTERVAL'; +NVARCHAR2 : 'NVARCHAR2'; +NVL2 : 'NVL2'; +OBJECT2XML : 'OBJECT2XML'; +OBJECT : 'OBJECT'; +OBJ_ID : 'OBJ_ID'; +OBJNO : 'OBJNO'; +OBJNO_REUSE : 'OBJNO_REUSE'; +OCCURENCES : 'OCCURENCES'; +OFFLINE : 'OFFLINE'; +OFF : 'OFF'; +OFFSET : 'OFFSET'; +OF : 'OF'; +OIDINDEX : 'OIDINDEX'; +OID : 'OID'; +OLAP : 'OLAP'; +OLD : 'OLD'; +OLD_PUSH_PRED : 'OLD_PUSH_PRED'; +OLS : 'OLS'; +OLTP : 'OLTP'; +OMIT : 'OMIT'; +ONE : 'ONE'; +ONLINE : 'ONLINE'; +ONLINELOG : 'ONLINELOG'; +ONLY : 'ONLY'; +ON : 'ON'; +OPAQUE : 'OPAQUE'; +OPAQUE_TRANSFORM : 'OPAQUE_TRANSFORM'; +OPAQUE_XCANONICAL : 'OPAQUE_XCANONICAL'; +OPCODE : 'OPCODE'; +OPEN : 'OPEN'; +OPERATIONS : 'OPERATIONS'; +OPERATOR : 'OPERATOR'; +OPT_ESTIMATE : 'OPT_ESTIMATE'; +OPTIMAL : 'OPTIMAL'; +OPTIMIZE : 'OPTIMIZE'; +OPTIMIZER_FEATURES_ENABLE : 'OPTIMIZER_FEATURES_ENABLE'; +OPTIMIZER_GOAL : 'OPTIMIZER_GOAL'; +OPTION : 'OPTION'; +OPT_PARAM : 'OPT_PARAM'; +ORA_BRANCH : 'ORA_BRANCH'; +ORA_CHECK_ACL : 'ORA_CHECK_ACL'; +ORA_CHECK_PRIVILEGE : 'ORA_CHECK_PRIVILEGE'; +ORA_CLUSTERING : 'ORA_CLUSTERING'; +ORADATA : 'ORADATA'; +ORADEBUG : 'ORADEBUG'; +ORA_DST_AFFECTED : 'ORA_DST_AFFECTED'; +ORA_DST_CONVERT : 'ORA_DST_CONVERT'; +ORA_DST_ERROR : 'ORA_DST_ERROR'; +ORA_GET_ACLIDS : 'ORA_GET_ACLIDS'; +ORA_GET_PRIVILEGES : 'ORA_GET_PRIVILEGES'; +ORA_HASH : 'ORA_HASH'; +ORA_INVOKING_USERID : 'ORA_INVOKING_USERID'; +ORA_INVOKING_USER : 'ORA_INVOKING_USER'; +ORA_INVOKING_XS_USER_GUID : 'ORA_INVOKING_XS_USER_GUID'; +ORA_INVOKING_XS_USER : 'ORA_INVOKING_XS_USER'; +ORA_RAWCOMPARE : 'ORA_RAWCOMPARE'; +ORA_RAWCONCAT : 'ORA_RAWCONCAT'; +ORA_ROWSCN : 'ORA_ROWSCN'; +ORA_ROWSCN_RAW : 'ORA_ROWSCN_RAW'; +ORA_ROWVERSION : 'ORA_ROWVERSION'; +ORA_TABVERSION : 'ORA_TABVERSION'; +ORA_WRITE_TIME : 'ORA_WRITE_TIME'; +ORDERED : 'ORDERED'; +ORDERED_PREDICATES : 'ORDERED_PREDICATES'; +ORDER : 'ORDER'; +ORDINALITY : 'ORDINALITY'; +OR_EXPAND : 'OR_EXPAND'; +ORGANIZATION : 'ORGANIZATION'; +OR : 'OR'; +OR_PREDICATES : 'OR_PREDICATES'; +OSERROR : 'OSERROR'; +OTHER : 'OTHER'; +OUTER_JOIN_TO_ANTI : 'OUTER_JOIN_TO_ANTI'; +OUTER_JOIN_TO_INNER : 'OUTER_JOIN_TO_INNER'; +OUTER : 'OUTER'; +OUTLINE_LEAF : 'OUTLINE_LEAF'; +OUTLINE : 'OUTLINE'; +OUT_OF_LINE : 'OUT_OF_LINE'; +OUT : 'OUT'; +OVERFLOW_NOMOVE : 'OVERFLOW_NOMOVE'; +OVERFLOW : 'OVERFLOW'; +OVERLAPS : 'OVERLAPS'; +OVER : 'OVER'; +OVERRIDING : 'OVERRIDING'; +OWNER : 'OWNER'; +OWNERSHIP : 'OWNERSHIP'; +OWN : 'OWN'; +PACKAGE : 'PACKAGE'; +PACKAGES : 'PACKAGES'; +PARALLEL_ENABLE : 'PARALLEL_ENABLE'; +PARALLEL_INDEX : 'PARALLEL_INDEX'; +PARALLEL : 'PARALLEL'; +PARAMETERFILE : 'PARAMETERFILE'; +PARAMETERS : 'PARAMETERS'; +PARAM : 'PARAM'; +PARENT : 'PARENT'; +PARITY : 'PARITY'; +PARTIAL_JOIN : 'PARTIAL_JOIN'; +PARTIALLY : 'PARTIALLY'; +PARTIAL : 'PARTIAL'; +PARTIAL_ROLLUP_PUSHDOWN : 'PARTIAL_ROLLUP_PUSHDOWN'; +PARTITION_HASH : 'PARTITION_HASH'; +PARTITION_LIST : 'PARTITION_LIST'; +PARTITION : 'PARTITION'; +PARTITION_RANGE : 'PARTITION_RANGE'; +PARTITIONS : 'PARTITIONS'; +PARTNUMINST : 'PART$NUM$INST'; +PASSING : 'PASSING'; +PASSWORD_GRACE_TIME : 'PASSWORD_GRACE_TIME'; +PASSWORD_LIFE_TIME : 'PASSWORD_LIFE_TIME'; +PASSWORD_LOCK_TIME : 'PASSWORD_LOCK_TIME'; +PASSWORD : 'PASSWORD'; +PASSWORD_REUSE_MAX : 'PASSWORD_REUSE_MAX'; +PASSWORD_REUSE_TIME : 'PASSWORD_REUSE_TIME'; +PASSWORD_VERIFY_FUNCTION : 'PASSWORD_VERIFY_FUNCTION'; +PAST : 'PAST'; +PATCH : 'PATCH'; +PATH : 'PATH'; +PATH_PREFIX : 'PATH_PREFIX'; +PATHS : 'PATHS'; +PATTERN : 'PATTERN'; +PBL_HS_BEGIN : 'PBL_HS_BEGIN'; +PBL_HS_END : 'PBL_HS_END'; +PCTFREE : 'PCTFREE'; +PCTINCREASE : 'PCTINCREASE'; +PCTTHRESHOLD : 'PCTTHRESHOLD'; +PCTUSED : 'PCTUSED'; +PCTVERSION : 'PCTVERSION'; +PENDING : 'PENDING'; +PERCENT_FOUND : '%' SPACE* 'FOUND'; +PERCENT_ISOPEN : '%' SPACE* 'ISOPEN'; +PERCENT_NOTFOUND : '%' SPACE* 'NOTFOUND'; +PERCENT_KEYWORD : 'PERCENT'; +PERCENT_RANKM : 'PERCENT_RANKM'; +PERCENT_ROWCOUNT : '%' SPACE* 'ROWCOUNT'; +PERCENT_ROWTYPE : '%' SPACE* 'ROWTYPE'; +PERCENT_TYPE : '%' SPACE* 'TYPE'; +PERFORMANCE : 'PERFORMANCE'; +PERIOD_KEYWORD : 'PERIOD'; +PERMANENT : 'PERMANENT'; +PERMISSION : 'PERMISSION'; +PERMUTE : 'PERMUTE'; +PER : 'PER'; +PFILE : 'PFILE'; +PHYSICAL : 'PHYSICAL'; +PIKEY : 'PIKEY'; +PIPELINED : 'PIPELINED'; +PIPE : 'PIPE'; +PIV_GB : 'PIV_GB'; +PIVOT : 'PIVOT'; +PIV_SSF : 'PIV_SSF'; +PLACE_DISTINCT : 'PLACE_DISTINCT'; +PLACE_GROUP_BY : 'PLACE_GROUP_BY'; +PLAN : 'PLAN'; +PLSCOPE_SETTINGS : 'PLSCOPE_SETTINGS'; +PLS_INTEGER : 'PLS_INTEGER'; +PLSQL_CCFLAGS : 'PLSQL_CCFLAGS'; +PLSQL_CODE_TYPE : 'PLSQL_CODE_TYPE'; +PLSQL_DEBUG : 'PLSQL_DEBUG'; +PLSQL_OPTIMIZE_LEVEL : 'PLSQL_OPTIMIZE_LEVEL'; +PLSQL_WARNINGS : 'PLSQL_WARNINGS'; +PLUGGABLE : 'PLUGGABLE'; +POINT : 'POINT'; +POLICY : 'POLICY'; +POOL_16K : 'POOL_16K'; +POOL_2K : 'POOL_2K'; +POOL_32K : 'POOL_32K'; +POOL_4K : 'POOL_4K'; +POOL_8K : 'POOL_8K'; +POSITIVEN : 'POSITIVEN'; +POSITIVE : 'POSITIVE'; +POST_TRANSACTION : 'POST_TRANSACTION'; +POWERMULTISET_BY_CARDINALITY : 'POWERMULTISET_BY_CARDINALITY'; +POWERMULTISET : 'POWERMULTISET'; +POWER : 'POWER'; +PQ_CONCURRENT_UNION : 'PQ_CONCURRENT_UNION'; +PQ_DISTRIBUTE : 'PQ_DISTRIBUTE'; +PQ_DISTRIBUTE_WINDOW : 'PQ_DISTRIBUTE_WINDOW'; +PQ_FILTER : 'PQ_FILTER'; +PQ_MAP : 'PQ_MAP'; +PQ_NOMAP : 'PQ_NOMAP'; +PQ_REPLICATE : 'PQ_REPLICATE'; +PQ_SKEW : 'PQ_SKEW'; +PRAGMA : 'PRAGMA'; +PREBUILT : 'PREBUILT'; +PRECEDES : 'PRECEDES'; +PRECEDING : 'PRECEDING'; +PRECISION : 'PRECISION'; +PRECOMPUTE_SUBQUERY : 'PRECOMPUTE_SUBQUERY'; +PREDICATE_REORDERS : 'PREDICATE_REORDERS'; +PRELOAD : 'PRELOAD'; +PREPARE : 'PREPARE'; +PRESENTNNV : 'PRESENTNNV'; +PRESENT : 'PRESENT'; +PRESENTV : 'PRESENTV'; +PRESERVE_OID : 'PRESERVE_OID'; +PRESERVE : 'PRESERVE'; +PRETTY : 'PRETTY'; +PREVIOUS : 'PREVIOUS'; +PREV : 'PREV'; +PRIMARY : 'PRIMARY'; +PRINTBLOBTOCLOB : 'PRINTBLOBTOCLOB'; +PRIORITY : 'PRIORITY'; +PRIOR : 'PRIOR'; +PRIVATE : 'PRIVATE'; +PRIVATE_SGA : 'PRIVATE_SGA'; +PRIVILEGED : 'PRIVILEGED'; +PRIVILEGE : 'PRIVILEGE'; +PRIVILEGES : 'PRIVILEGES'; +PROCEDURAL : 'PROCEDURAL'; +PROCEDURE : 'PROCEDURE'; +PROCESS : 'PROCESS'; +PROFILE : 'PROFILE'; +PROGRAM : 'PROGRAM'; +PROJECT : 'PROJECT'; +PROPAGATE : 'PROPAGATE'; +PROTECTED : 'PROTECTED'; +PROTECTION : 'PROTECTION'; +PROXY : 'PROXY'; +PRUNING : 'PRUNING'; +PUBLIC : 'PUBLIC'; +PULL_PRED : 'PULL_PRED'; +PURGE : 'PURGE'; +PUSH_PRED : 'PUSH_PRED'; +PUSH_SUBQ : 'PUSH_SUBQ'; +PX_FAULT_TOLERANCE : 'PX_FAULT_TOLERANCE'; +PX_GRANULE : 'PX_GRANULE'; +PX_JOIN_FILTER : 'PX_JOIN_FILTER'; +QB_NAME : 'QB_NAME'; +QUERY_BLOCK : 'QUERY_BLOCK'; +QUERY : 'QUERY'; +QUEUE_CURR : 'QUEUE_CURR'; +QUEUE : 'QUEUE'; +QUEUE_ROWP : 'QUEUE_ROWP'; +QUIESCE : 'QUIESCE'; +QUORUM : 'QUORUM'; +QUOTA : 'QUOTA'; +RAISE : 'RAISE'; +RANDOM_LOCAL : 'RANDOM_LOCAL'; +RANDOM : 'RANDOM'; +RANGE : 'RANGE'; +RANKM : 'RANKM'; +RAPIDLY : 'RAPIDLY'; +RAW : 'RAW'; +RAWTOHEX : 'RAWTOHEX'; +RAWTONHEX : 'RAWTONHEX'; +RBA : 'RBA'; +RBO_OUTLINE : 'RBO_OUTLINE'; +RDBA : 'RDBA'; +READ : 'READ'; +READS : 'READS'; +REALM : 'REALM'; +REAL : 'REAL'; +REBALANCE : 'REBALANCE'; +REBUILD : 'REBUILD'; +RECORD : 'RECORD'; +RECORDS_PER_BLOCK : 'RECORDS_PER_BLOCK'; +RECOVERABLE : 'RECOVERABLE'; +RECOVER : 'RECOVER'; +RECOVERY : 'RECOVERY'; +RECYCLEBIN : 'RECYCLEBIN'; +RECYCLE : 'RECYCLE'; +REDACTION : 'REDACTION'; +REDEFINE : 'REDEFINE'; +REDO : 'REDO'; +REDUCED : 'REDUCED'; +REDUNDANCY : 'REDUNDANCY'; +REF_CASCADE_CURSOR : 'REF_CASCADE_CURSOR'; +REFERENCED : 'REFERENCED'; +REFERENCE : 'REFERENCE'; +REFERENCES : 'REFERENCES'; +REFERENCING : 'REFERENCING'; +REF : 'REF'; +REFRESH : 'REFRESH'; +REFTOHEX : 'REFTOHEX'; +REGEXP_COUNT : 'REGEXP_COUNT'; +REGEXP_INSTR : 'REGEXP_INSTR'; +REGEXP_LIKE : 'REGEXP_LIKE'; +REGEXP_REPLACE : 'REGEXP_REPLACE'; +REGEXP_SUBSTR : 'REGEXP_SUBSTR'; +REGISTER : 'REGISTER'; +REGR_AVGX : 'REGR_AVGX'; +REGR_AVGY : 'REGR_AVGY'; +REGR_COUNT : 'REGR_COUNT'; +REGR_INTERCEPT : 'REGR_INTERCEPT'; +REGR_R2 : 'REGR_R2'; +REGR_SLOPE : 'REGR_SLOPE'; +REGR_SXX : 'REGR_SXX'; +REGR_SXY : 'REGR_SXY'; +REGR_SYY : 'REGR_SYY'; +REGULAR : 'REGULAR'; +REJECT : 'REJECT'; +REKEY : 'REKEY'; +RELATIONAL : 'RELATIONAL'; +RELIES_ON : 'RELIES_ON'; +RELOCATE : 'RELOCATE'; +RELY : 'RELY'; +REMAINDER : 'REMAINDER'; +REMOTE_MAPPED : 'REMOTE_MAPPED'; +REMOVE : 'REMOVE'; +RENAME : 'RENAME'; +REPAIR : 'REPAIR'; +REPEAT : 'REPEAT'; +REPLACE : 'REPLACE'; +REPLICATION : 'REPLICATION'; +REQUIRED : 'REQUIRED'; +RESETLOGS : 'RESETLOGS'; +RESET : 'RESET'; +RESIZE : 'RESIZE'; +RESOLVE : 'RESOLVE'; +RESOLVER : 'RESOLVER'; +RESOURCE : 'RESOURCE'; +RESPECT : 'RESPECT'; +RESTART : 'RESTART'; +RESTORE_AS_INTERVALS : 'RESTORE_AS_INTERVALS'; +RESTORE : 'RESTORE'; +RESTRICT_ALL_REF_CONS : 'RESTRICT_ALL_REF_CONS'; +RESTRICTED : 'RESTRICTED'; +RESTRICT_REFERENCES : 'RESTRICT_REFERENCES'; +RESTRICT : 'RESTRICT'; +RESULT_CACHE : 'RESULT_CACHE'; +RESULT : 'RESULT'; +RESUMABLE : 'RESUMABLE'; +RESUME : 'RESUME'; +RETENTION : 'RETENTION'; +RETRY_ON_ROW_CHANGE : 'RETRY_ON_ROW_CHANGE'; +RETURNING : 'RETURNING'; +RETURN : 'RETURN'; +REUSE : 'REUSE'; +REVERSE : 'REVERSE'; +REVOKE : 'REVOKE'; +REWRITE_OR_ERROR : 'REWRITE_OR_ERROR'; +REWRITE : 'REWRITE'; +RIGHT : 'RIGHT'; +ROLE : 'ROLE'; +ROLESET : 'ROLESET'; +ROLES : 'ROLES'; +ROLLBACK : 'ROLLBACK'; +ROLLING : 'ROLLING'; +ROLLUP : 'ROLLUP'; +ROWDEPENDENCIES : 'ROWDEPENDENCIES'; +ROWID_MAPPING_TABLE : 'ROWID_MAPPING_TABLE'; +ROWID : 'ROWID'; +ROWIDTOCHAR : 'ROWIDTOCHAR'; +ROWIDTONCHAR : 'ROWIDTONCHAR'; +ROW_LENGTH : 'ROW_LENGTH'; +ROWNUM : 'ROWNUM'; +ROW : 'ROW'; +ROWS : 'ROWS'; +RPAD : 'RPAD'; +RTRIM : 'RTRIM'; +RULE : 'RULE'; +RULES : 'RULES'; +RUNNING : 'RUNNING'; +SALT : 'SALT'; +SAMPLE : 'SAMPLE'; +SAVE_AS_INTERVALS : 'SAVE_AS_INTERVALS'; +SAVEPOINT : 'SAVEPOINT'; +SAVE : 'SAVE'; +SB4 : 'SB4'; +SCALE_ROWS : 'SCALE_ROWS'; +SCALE : 'SCALE'; +SCAN_INSTANCES : 'SCAN_INSTANCES'; +SCAN : 'SCAN'; +SCHEDULER : 'SCHEDULER'; +SCHEMACHECK : 'SCHEMACHECK'; +SCHEMA : 'SCHEMA'; +SCN_ASCENDING : 'SCN_ASCENDING'; +SCN : 'SCN'; +SCOPE : 'SCOPE'; +SCRUB : 'SCRUB'; +SD_ALL : 'SD_ALL'; +SD_INHIBIT : 'SD_INHIBIT'; +SDO_GEOM_MBR : 'SDO_GEOM_MBR'; +SD_SHOW : 'SD_SHOW'; +SEARCH : 'SEARCH'; +SECOND : 'SECOND'; +SECRET : 'SECRET'; +SECUREFILE_DBA : 'SECUREFILE_DBA'; +SECUREFILE : 'SECUREFILE'; +SECURITY : 'SECURITY'; +SEED : 'SEED'; +SEG_BLOCK : 'SEG_BLOCK'; +SEG_FILE : 'SEG_FILE'; +SEGMENT : 'SEGMENT'; +SELECTIVITY : 'SELECTIVITY'; +SELECT : 'SELECT'; +SELF : 'SELF'; +SEMIJOIN_DRIVER : 'SEMIJOIN_DRIVER'; +SEMIJOIN : 'SEMIJOIN'; +SEMI_TO_INNER : 'SEMI_TO_INNER'; +SEQUENCED : 'SEQUENCED'; +SEQUENCE : 'SEQUENCE'; +SEQUENTIAL : 'SEQUENTIAL'; +SEQ : 'SEQ'; +SERIALIZABLE : 'SERIALIZABLE'; +SERIALLY_REUSABLE : 'SERIALLY_REUSABLE'; +SERIAL : 'SERIAL'; +SERVERERROR : 'SERVERERROR'; +SERVICE_NAME_CONVERT : 'SERVICE_NAME_CONVERT'; +SERVICES : 'SERVICES'; +SESSION_CACHED_CURSORS : 'SESSION_CACHED_CURSORS'; +SESSION : 'SESSION'; +SESSIONS_PER_USER : 'SESSIONS_PER_USER'; +SESSIONTIMEZONE : 'SESSIONTIMEZONE'; +SESSIONTZNAME : 'SESSIONTZNAME'; +SET : 'SET'; +SETS : 'SETS'; +SETTINGS : 'SETTINGS'; +SET_TO_JOIN : 'SET_TO_JOIN'; +SEVERE : 'SEVERE'; +SHARED_POOL : 'SHARED_POOL'; +SHARED : 'SHARED'; +SHARE : 'SHARE'; +SHARING : 'SHARING'; +SHELFLIFE : 'SHELFLIFE'; +SHOW : 'SHOW'; +SHRINK : 'SHRINK'; +SHUTDOWN : 'SHUTDOWN'; +SIBLINGS : 'SIBLINGS'; +SID : 'SID'; +SIGNAL_COMPONENT : 'SIGNAL_COMPONENT'; +SIGNAL_FUNCTION : 'SIGNAL_FUNCTION'; +SIGN : 'SIGN'; +SIGNTYPE : 'SIGNTYPE'; +SIMPLE_INTEGER : 'SIMPLE_INTEGER'; +SIMPLE : 'SIMPLE'; +SINGLE : 'SINGLE'; +SINGLETASK : 'SINGLETASK'; +SINH : 'SINH'; +SIN : 'SIN'; +SIZE : 'SIZE'; +SKIP_EXT_OPTIMIZER : 'SKIP_EXT_OPTIMIZER'; +SKIP_ : 'SKIP'; +SKIP_UNQ_UNUSABLE_IDX : 'SKIP_UNQ_UNUSABLE_IDX'; +SKIP_UNUSABLE_INDEXES : 'SKIP_UNUSABLE_INDEXES'; +SMALLFILE : 'SMALLFILE'; +SMALLINT : 'SMALLINT'; +SNAPSHOT : 'SNAPSHOT'; +SOME : 'SOME'; +SORT : 'SORT'; +SOUNDEX : 'SOUNDEX'; +SOURCE_FILE_DIRECTORY : 'SOURCE_FILE_DIRECTORY'; +SOURCE_FILE_NAME_CONVERT : 'SOURCE_FILE_NAME_CONVERT'; +SOURCE : 'SOURCE'; +SPACE_KEYWORD : 'SPACE'; +SPECIFICATION : 'SPECIFICATION'; +SPFILE : 'SPFILE'; +SPLIT : 'SPLIT'; +SPREADSHEET : 'SPREADSHEET'; +SQLDATA : 'SQLDATA'; +SQLERROR : 'SQLERROR'; +SQLLDR : 'SQLLDR'; +SQL : 'SQL'; +SQL_TRACE : 'SQL_TRACE'; +SQL_TRANSLATION_PROFILE : 'SQL_TRANSLATION_PROFILE'; +SQRT : 'SQRT'; +STALE : 'STALE'; +STANDALONE : 'STANDALONE'; +STANDARD_HASH : 'STANDARD_HASH'; +STANDBY_MAX_DATA_DELAY : 'STANDBY_MAX_DATA_DELAY'; +STANDBYS : 'STANDBYS'; +STANDBY : 'STANDBY'; +STAR : 'STAR'; +STAR_TRANSFORMATION : 'STAR_TRANSFORMATION'; +START : 'START'; +STARTUP : 'STARTUP'; +STATEMENT_ID : 'STATEMENT_ID'; +STATEMENT_QUEUING : 'STATEMENT_QUEUING'; +STATEMENTS : 'STATEMENTS'; +STATEMENT : 'STATEMENT'; +STATE : 'STATE'; +STATIC : 'STATIC'; +STATISTICS : 'STATISTICS'; +STATS_BINOMIAL_TEST : 'STATS_BINOMIAL_TEST'; +STATS_CROSSTAB : 'STATS_CROSSTAB'; +STATS_F_TEST : 'STATS_F_TEST'; +STATS_KS_TEST : 'STATS_KS_TEST'; +STATS_MODE : 'STATS_MODE'; +STATS_MW_TEST : 'STATS_MW_TEST'; +STATS_ONE_WAY_ANOVA : 'STATS_ONE_WAY_ANOVA'; +STATS_T_TEST_INDEP : 'STATS_T_TEST_INDEP'; +STATS_T_TEST_INDEPU : 'STATS_T_TEST_INDEPU'; +STATS_T_TEST_ONE : 'STATS_T_TEST_ONE'; +STATS_T_TEST_PAIRED : 'STATS_T_TEST_PAIRED'; +STATS_WSR_TEST : 'STATS_WSR_TEST'; +STDDEV_POP : 'STDDEV_POP'; +STDDEV_SAMP : 'STDDEV_SAMP'; +STOP : 'STOP'; +STORAGE : 'STORAGE'; +STORE : 'STORE'; +STREAMS : 'STREAMS'; +STREAM : 'STREAM'; +STRICT : 'STRICT'; +STRING : 'STRING'; +STRIPE_COLUMNS : 'STRIPE_COLUMNS'; +STRIPE_WIDTH : 'STRIPE_WIDTH'; +STRIP : 'STRIP'; +STRUCTURE : 'STRUCTURE'; +SUBMULTISET : 'SUBMULTISET'; +SUBPARTITION_REL : 'SUBPARTITION_REL'; +SUBPARTITIONS : 'SUBPARTITIONS'; +SUBPARTITION : 'SUBPARTITION'; +SUBQUERIES : 'SUBQUERIES'; +SUBQUERY_PRUNING : 'SUBQUERY_PRUNING'; +SUBSCRIBE : 'SUBSCRIBE'; +SUBSET : 'SUBSET'; +SUBSTITUTABLE : 'SUBSTITUTABLE'; +SUBSTR2 : 'SUBSTR2'; +SUBSTR4 : 'SUBSTR4'; +SUBSTRB : 'SUBSTRB'; +SUBSTRC : 'SUBSTRC'; +SUBTYPE : 'SUBTYPE'; +SUCCESSFUL : 'SUCCESSFUL'; +SUCCESS : 'SUCCESS'; +SUMMARY : 'SUMMARY'; +SUPPLEMENTAL : 'SUPPLEMENTAL'; +SUSPEND : 'SUSPEND'; +SWAP_JOIN_INPUTS : 'SWAP_JOIN_INPUTS'; +SWITCHOVER : 'SWITCHOVER'; +SWITCH : 'SWITCH'; +SYNCHRONOUS : 'SYNCHRONOUS'; +SYNC : 'SYNC'; +SYNONYM : 'SYNONYM'; +SYSASM : 'SYSASM'; +SYS_AUDIT : 'SYS_AUDIT'; +SYSAUX : 'SYSAUX'; +SYSBACKUP : 'SYSBACKUP'; +SYS_CHECKACL : 'SYS_CHECKACL'; +SYS_CHECK_PRIVILEGE : 'SYS_CHECK_PRIVILEGE'; +SYS_CONNECT_BY_PATH : 'SYS_CONNECT_BY_PATH'; +SYS_CONTEXT : 'SYS_CONTEXT'; +SYSDATE : 'SYSDATE'; +SYSDBA : 'SYSDBA'; +SYS_DBURIGEN : 'SYS_DBURIGEN'; +SYSDG : 'SYSDG'; +SYS_DL_CURSOR : 'SYS_DL_CURSOR'; +SYS_DM_RXFORM_CHR : 'SYS_DM_RXFORM_CHR'; +SYS_DM_RXFORM_NUM : 'SYS_DM_RXFORM_NUM'; +SYS_DOM_COMPARE : 'SYS_DOM_COMPARE'; +SYS_DST_PRIM2SEC : 'SYS_DST_PRIM2SEC'; +SYS_DST_SEC2PRIM : 'SYS_DST_SEC2PRIM'; +SYS_ET_BFILE_TO_RAW : 'SYS_ET_BFILE_TO_RAW'; +SYS_ET_BLOB_TO_IMAGE : 'SYS_ET_BLOB_TO_IMAGE'; +SYS_ET_IMAGE_TO_BLOB : 'SYS_ET_IMAGE_TO_BLOB'; +SYS_ET_RAW_TO_BFILE : 'SYS_ET_RAW_TO_BFILE'; +SYS_EXTPDTXT : 'SYS_EXTPDTXT'; +SYS_EXTRACT_UTC : 'SYS_EXTRACT_UTC'; +SYS_FBT_INSDEL : 'SYS_FBT_INSDEL'; +SYS_FILTER_ACLS : 'SYS_FILTER_ACLS'; +SYS_FNMATCHES : 'SYS_FNMATCHES'; +SYS_FNREPLACE : 'SYS_FNREPLACE'; +SYS_GET_ACLIDS : 'SYS_GET_ACLIDS'; +SYS_GET_COL_ACLIDS : 'SYS_GET_COL_ACLIDS'; +SYS_GET_PRIVILEGES : 'SYS_GET_PRIVILEGES'; +SYS_GETTOKENID : 'SYS_GETTOKENID'; +SYS_GETXTIVAL : 'SYS_GETXTIVAL'; +SYS_GUID : 'SYS_GUID'; +SYSGUID : 'SYSGUID'; +SYSKM : 'SYSKM'; +SYS_MAKE_XMLNODEID : 'SYS_MAKE_XMLNODEID'; +SYS_MAKEXML : 'SYS_MAKEXML'; +SYS_MKXMLATTR : 'SYS_MKXMLATTR'; +SYS_MKXTI : 'SYS_MKXTI'; +SYSOBJ : 'SYSOBJ'; +SYS_OP_ADT2BIN : 'SYS_OP_ADT2BIN'; +SYS_OP_ADTCONS : 'SYS_OP_ADTCONS'; +SYS_OP_ALSCRVAL : 'SYS_OP_ALSCRVAL'; +SYS_OP_ATG : 'SYS_OP_ATG'; +SYS_OP_BIN2ADT : 'SYS_OP_BIN2ADT'; +SYS_OP_BITVEC : 'SYS_OP_BITVEC'; +SYS_OP_BL2R : 'SYS_OP_BL2R'; +SYS_OP_BLOOM_FILTER_LIST : 'SYS_OP_BLOOM_FILTER_LIST'; +SYS_OP_BLOOM_FILTER : 'SYS_OP_BLOOM_FILTER'; +SYS_OP_C2C : 'SYS_OP_C2C'; +SYS_OP_CAST : 'SYS_OP_CAST'; +SYS_OP_CEG : 'SYS_OP_CEG'; +SYS_OP_CL2C : 'SYS_OP_CL2C'; +SYS_OP_COMBINED_HASH : 'SYS_OP_COMBINED_HASH'; +SYS_OP_COMP : 'SYS_OP_COMP'; +SYS_OP_CONVERT : 'SYS_OP_CONVERT'; +SYS_OP_COUNTCHG : 'SYS_OP_COUNTCHG'; +SYS_OP_CSCONV : 'SYS_OP_CSCONV'; +SYS_OP_CSCONVTEST : 'SYS_OP_CSCONVTEST'; +SYS_OP_CSR : 'SYS_OP_CSR'; +SYS_OP_CSX_PATCH : 'SYS_OP_CSX_PATCH'; +SYS_OP_CYCLED_SEQ : 'SYS_OP_CYCLED_SEQ'; +SYS_OP_DECOMP : 'SYS_OP_DECOMP'; +SYS_OP_DESCEND : 'SYS_OP_DESCEND'; +SYS_OP_DISTINCT : 'SYS_OP_DISTINCT'; +SYS_OP_DRA : 'SYS_OP_DRA'; +SYS_OP_DUMP : 'SYS_OP_DUMP'; +SYS_OP_DV_CHECK : 'SYS_OP_DV_CHECK'; +SYS_OP_ENFORCE_NOT_NULL : 'SYS_OP_ENFORCE_NOT_NULL$'; +SYSOPER : 'SYSOPER'; +SYS_OP_EXTRACT : 'SYS_OP_EXTRACT'; +SYS_OP_GROUPING : 'SYS_OP_GROUPING'; +SYS_OP_GUID : 'SYS_OP_GUID'; +SYS_OP_HASH : 'SYS_OP_HASH'; +SYS_OP_IIX : 'SYS_OP_IIX'; +SYS_OP_ITR : 'SYS_OP_ITR'; +SYS_OP_KEY_VECTOR_CREATE : 'SYS_OP_KEY_VECTOR_CREATE'; +SYS_OP_KEY_VECTOR_FILTER_LIST : 'SYS_OP_KEY_VECTOR_FILTER_LIST'; +SYS_OP_KEY_VECTOR_FILTER : 'SYS_OP_KEY_VECTOR_FILTER'; +SYS_OP_KEY_VECTOR_SUCCEEDED : 'SYS_OP_KEY_VECTOR_SUCCEEDED'; +SYS_OP_KEY_VECTOR_USE : 'SYS_OP_KEY_VECTOR_USE'; +SYS_OP_LBID : 'SYS_OP_LBID'; +SYS_OP_LOBLOC2BLOB : 'SYS_OP_LOBLOC2BLOB'; +SYS_OP_LOBLOC2CLOB : 'SYS_OP_LOBLOC2CLOB'; +SYS_OP_LOBLOC2ID : 'SYS_OP_LOBLOC2ID'; +SYS_OP_LOBLOC2NCLOB : 'SYS_OP_LOBLOC2NCLOB'; +SYS_OP_LOBLOC2TYP : 'SYS_OP_LOBLOC2TYP'; +SYS_OP_LSVI : 'SYS_OP_LSVI'; +SYS_OP_LVL : 'SYS_OP_LVL'; +SYS_OP_MAKEOID : 'SYS_OP_MAKEOID'; +SYS_OP_MAP_NONNULL : 'SYS_OP_MAP_NONNULL'; +SYS_OP_MSR : 'SYS_OP_MSR'; +SYS_OP_NICOMBINE : 'SYS_OP_NICOMBINE'; +SYS_OP_NIEXTRACT : 'SYS_OP_NIEXTRACT'; +SYS_OP_NII : 'SYS_OP_NII'; +SYS_OP_NIX : 'SYS_OP_NIX'; +SYS_OP_NOEXPAND : 'SYS_OP_NOEXPAND'; +SYS_OP_NTCIMG : 'SYS_OP_NTCIMG$'; +SYS_OP_NUMTORAW : 'SYS_OP_NUMTORAW'; +SYS_OP_OIDVALUE : 'SYS_OP_OIDVALUE'; +SYS_OP_OPNSIZE : 'SYS_OP_OPNSIZE'; +SYS_OP_PAR_1 : 'SYS_OP_PAR_1'; +SYS_OP_PARGID_1 : 'SYS_OP_PARGID_1'; +SYS_OP_PARGID : 'SYS_OP_PARGID'; +SYS_OP_PAR : 'SYS_OP_PAR'; +SYS_OP_PART_ID : 'SYS_OP_PART_ID'; +SYS_OP_PIVOT : 'SYS_OP_PIVOT'; +SYS_OP_R2O : 'SYS_OP_R2O'; +SYS_OP_RAWTONUM : 'SYS_OP_RAWTONUM'; +SYS_OP_RDTM : 'SYS_OP_RDTM'; +SYS_OP_REF : 'SYS_OP_REF'; +SYS_OP_RMTD : 'SYS_OP_RMTD'; +SYS_OP_ROWIDTOOBJ : 'SYS_OP_ROWIDTOOBJ'; +SYS_OP_RPB : 'SYS_OP_RPB'; +SYS_OPTLOBPRBSC : 'SYS_OPTLOBPRBSC'; +SYS_OP_TOSETID : 'SYS_OP_TOSETID'; +SYS_OP_TPR : 'SYS_OP_TPR'; +SYS_OP_TRTB : 'SYS_OP_TRTB'; +SYS_OPTXICMP : 'SYS_OPTXICMP'; +SYS_OPTXQCASTASNQ : 'SYS_OPTXQCASTASNQ'; +SYS_OP_UNDESCEND : 'SYS_OP_UNDESCEND'; +SYS_OP_VECAND : 'SYS_OP_VECAND'; +SYS_OP_VECBIT : 'SYS_OP_VECBIT'; +SYS_OP_VECOR : 'SYS_OP_VECOR'; +SYS_OP_VECXOR : 'SYS_OP_VECXOR'; +SYS_OP_VERSION : 'SYS_OP_VERSION'; +SYS_OP_VREF : 'SYS_OP_VREF'; +SYS_OP_VVD : 'SYS_OP_VVD'; +SYS_OP_XMLCONS_FOR_CSX : 'SYS_OP_XMLCONS_FOR_CSX'; +SYS_OP_XPTHATG : 'SYS_OP_XPTHATG'; +SYS_OP_XPTHIDX : 'SYS_OP_XPTHIDX'; +SYS_OP_XPTHOP : 'SYS_OP_XPTHOP'; +SYS_OP_XTXT2SQLT : 'SYS_OP_XTXT2SQLT'; +SYS_OP_ZONE_ID : 'SYS_OP_ZONE_ID'; +SYS_ORDERKEY_DEPTH : 'SYS_ORDERKEY_DEPTH'; +SYS_ORDERKEY_MAXCHILD : 'SYS_ORDERKEY_MAXCHILD'; +SYS_ORDERKEY_PARENT : 'SYS_ORDERKEY_PARENT'; +SYS_PARALLEL_TXN : 'SYS_PARALLEL_TXN'; +SYS_PATHID_IS_ATTR : 'SYS_PATHID_IS_ATTR'; +SYS_PATHID_IS_NMSPC : 'SYS_PATHID_IS_NMSPC'; +SYS_PATHID_LASTNAME : 'SYS_PATHID_LASTNAME'; +SYS_PATHID_LASTNMSPC : 'SYS_PATHID_LASTNMSPC'; +SYS_PATH_REVERSE : 'SYS_PATH_REVERSE'; +SYS_PXQEXTRACT : 'SYS_PXQEXTRACT'; +SYS_RAW_TO_XSID : 'SYS_RAW_TO_XSID'; +SYS_RID_ORDER : 'SYS_RID_ORDER'; +SYS_ROW_DELTA : 'SYS_ROW_DELTA'; +SYS_SC_2_XMLT : 'SYS_SC_2_XMLT'; +SYS_SYNRCIREDO : 'SYS_SYNRCIREDO'; +SYSTEM_DEFINED : 'SYSTEM_DEFINED'; +SYSTEM : 'SYSTEM'; +SYSTIMESTAMP : 'SYSTIMESTAMP'; +SYS_TYPEID : 'SYS_TYPEID'; +SYS_UMAKEXML : 'SYS_UMAKEXML'; +SYS_XMLANALYZE : 'SYS_XMLANALYZE'; +SYS_XMLCONTAINS : 'SYS_XMLCONTAINS'; +SYS_XMLCONV : 'SYS_XMLCONV'; +SYS_XMLEXNSURI : 'SYS_XMLEXNSURI'; +SYS_XMLGEN : 'SYS_XMLGEN'; +SYS_XMLI_LOC_ISNODE : 'SYS_XMLI_LOC_ISNODE'; +SYS_XMLI_LOC_ISTEXT : 'SYS_XMLI_LOC_ISTEXT'; +SYS_XMLINSTR : 'SYS_XMLINSTR'; +SYS_XMLLOCATOR_GETSVAL : 'SYS_XMLLOCATOR_GETSVAL'; +SYS_XMLNODEID_GETCID : 'SYS_XMLNODEID_GETCID'; +SYS_XMLNODEID_GETLOCATOR : 'SYS_XMLNODEID_GETLOCATOR'; +SYS_XMLNODEID_GETOKEY : 'SYS_XMLNODEID_GETOKEY'; +SYS_XMLNODEID_GETPATHID : 'SYS_XMLNODEID_GETPATHID'; +SYS_XMLNODEID_GETPTRID : 'SYS_XMLNODEID_GETPTRID'; +SYS_XMLNODEID_GETRID : 'SYS_XMLNODEID_GETRID'; +SYS_XMLNODEID_GETSVAL : 'SYS_XMLNODEID_GETSVAL'; +SYS_XMLNODEID_GETTID : 'SYS_XMLNODEID_GETTID'; +SYS_XMLNODEID : 'SYS_XMLNODEID'; +SYS_XMLT_2_SC : 'SYS_XMLT_2_SC'; +SYS_XMLTRANSLATE : 'SYS_XMLTRANSLATE'; +SYS_XMLTYPE2SQL : 'SYS_XMLTYPE2SQL'; +SYS_XQ_ASQLCNV : 'SYS_XQ_ASQLCNV'; +SYS_XQ_ATOMCNVCHK : 'SYS_XQ_ATOMCNVCHK'; +SYS_XQBASEURI : 'SYS_XQBASEURI'; +SYS_XQCASTABLEERRH : 'SYS_XQCASTABLEERRH'; +SYS_XQCODEP2STR : 'SYS_XQCODEP2STR'; +SYS_XQCODEPEQ : 'SYS_XQCODEPEQ'; +SYS_XQCON2SEQ : 'SYS_XQCON2SEQ'; +SYS_XQCONCAT : 'SYS_XQCONCAT'; +SYS_XQDELETE : 'SYS_XQDELETE'; +SYS_XQDFLTCOLATION : 'SYS_XQDFLTCOLATION'; +SYS_XQDOC : 'SYS_XQDOC'; +SYS_XQDOCURI : 'SYS_XQDOCURI'; +SYS_XQDURDIV : 'SYS_XQDURDIV'; +SYS_XQED4URI : 'SYS_XQED4URI'; +SYS_XQENDSWITH : 'SYS_XQENDSWITH'; +SYS_XQERRH : 'SYS_XQERRH'; +SYS_XQERR : 'SYS_XQERR'; +SYS_XQESHTMLURI : 'SYS_XQESHTMLURI'; +SYS_XQEXLOBVAL : 'SYS_XQEXLOBVAL'; +SYS_XQEXSTWRP : 'SYS_XQEXSTWRP'; +SYS_XQEXTRACT : 'SYS_XQEXTRACT'; +SYS_XQEXTRREF : 'SYS_XQEXTRREF'; +SYS_XQEXVAL : 'SYS_XQEXVAL'; +SYS_XQFB2STR : 'SYS_XQFB2STR'; +SYS_XQFNBOOL : 'SYS_XQFNBOOL'; +SYS_XQFNCMP : 'SYS_XQFNCMP'; +SYS_XQFNDATIM : 'SYS_XQFNDATIM'; +SYS_XQFNLNAME : 'SYS_XQFNLNAME'; +SYS_XQFNNM : 'SYS_XQFNNM'; +SYS_XQFNNSURI : 'SYS_XQFNNSURI'; +SYS_XQFNPREDTRUTH : 'SYS_XQFNPREDTRUTH'; +SYS_XQFNQNM : 'SYS_XQFNQNM'; +SYS_XQFNROOT : 'SYS_XQFNROOT'; +SYS_XQFORMATNUM : 'SYS_XQFORMATNUM'; +SYS_XQFTCONTAIN : 'SYS_XQFTCONTAIN'; +SYS_XQFUNCR : 'SYS_XQFUNCR'; +SYS_XQGETCONTENT : 'SYS_XQGETCONTENT'; +SYS_XQINDXOF : 'SYS_XQINDXOF'; +SYS_XQINSERT : 'SYS_XQINSERT'; +SYS_XQINSPFX : 'SYS_XQINSPFX'; +SYS_XQIRI2URI : 'SYS_XQIRI2URI'; +SYS_XQLANG : 'SYS_XQLANG'; +SYS_XQLLNMFRMQNM : 'SYS_XQLLNMFRMQNM'; +SYS_XQMKNODEREF : 'SYS_XQMKNODEREF'; +SYS_XQNILLED : 'SYS_XQNILLED'; +SYS_XQNODENAME : 'SYS_XQNODENAME'; +SYS_XQNORMSPACE : 'SYS_XQNORMSPACE'; +SYS_XQNORMUCODE : 'SYS_XQNORMUCODE'; +SYS_XQ_NRNG : 'SYS_XQ_NRNG'; +SYS_XQNSP4PFX : 'SYS_XQNSP4PFX'; +SYS_XQNSPFRMQNM : 'SYS_XQNSPFRMQNM'; +SYS_XQPFXFRMQNM : 'SYS_XQPFXFRMQNM'; +SYS_XQ_PKSQL2XML : 'SYS_XQ_PKSQL2XML'; +SYS_XQPOLYABS : 'SYS_XQPOLYABS'; +SYS_XQPOLYADD : 'SYS_XQPOLYADD'; +SYS_XQPOLYCEL : 'SYS_XQPOLYCEL'; +SYS_XQPOLYCSTBL : 'SYS_XQPOLYCSTBL'; +SYS_XQPOLYCST : 'SYS_XQPOLYCST'; +SYS_XQPOLYDIV : 'SYS_XQPOLYDIV'; +SYS_XQPOLYFLR : 'SYS_XQPOLYFLR'; +SYS_XQPOLYMOD : 'SYS_XQPOLYMOD'; +SYS_XQPOLYMUL : 'SYS_XQPOLYMUL'; +SYS_XQPOLYRND : 'SYS_XQPOLYRND'; +SYS_XQPOLYSQRT : 'SYS_XQPOLYSQRT'; +SYS_XQPOLYSUB : 'SYS_XQPOLYSUB'; +SYS_XQPOLYUMUS : 'SYS_XQPOLYUMUS'; +SYS_XQPOLYUPLS : 'SYS_XQPOLYUPLS'; +SYS_XQPOLYVEQ : 'SYS_XQPOLYVEQ'; +SYS_XQPOLYVGE : 'SYS_XQPOLYVGE'; +SYS_XQPOLYVGT : 'SYS_XQPOLYVGT'; +SYS_XQPOLYVLE : 'SYS_XQPOLYVLE'; +SYS_XQPOLYVLT : 'SYS_XQPOLYVLT'; +SYS_XQPOLYVNE : 'SYS_XQPOLYVNE'; +SYS_XQREF2VAL : 'SYS_XQREF2VAL'; +SYS_XQRENAME : 'SYS_XQRENAME'; +SYS_XQREPLACE : 'SYS_XQREPLACE'; +SYS_XQRESVURI : 'SYS_XQRESVURI'; +SYS_XQRNDHALF2EVN : 'SYS_XQRNDHALF2EVN'; +SYS_XQRSLVQNM : 'SYS_XQRSLVQNM'; +SYS_XQRYENVPGET : 'SYS_XQRYENVPGET'; +SYS_XQRYVARGET : 'SYS_XQRYVARGET'; +SYS_XQRYWRP : 'SYS_XQRYWRP'; +SYS_XQSEQ2CON4XC : 'SYS_XQSEQ2CON4XC'; +SYS_XQSEQ2CON : 'SYS_XQSEQ2CON'; +SYS_XQSEQDEEPEQ : 'SYS_XQSEQDEEPEQ'; +SYS_XQSEQINSB : 'SYS_XQSEQINSB'; +SYS_XQSEQRM : 'SYS_XQSEQRM'; +SYS_XQSEQRVS : 'SYS_XQSEQRVS'; +SYS_XQSEQSUB : 'SYS_XQSEQSUB'; +SYS_XQSEQTYPMATCH : 'SYS_XQSEQTYPMATCH'; +SYS_XQSTARTSWITH : 'SYS_XQSTARTSWITH'; +SYS_XQSTATBURI : 'SYS_XQSTATBURI'; +SYS_XQSTR2CODEP : 'SYS_XQSTR2CODEP'; +SYS_XQSTRJOIN : 'SYS_XQSTRJOIN'; +SYS_XQSUBSTRAFT : 'SYS_XQSUBSTRAFT'; +SYS_XQSUBSTRBEF : 'SYS_XQSUBSTRBEF'; +SYS_XQTOKENIZE : 'SYS_XQTOKENIZE'; +SYS_XQTREATAS : 'SYS_XQTREATAS'; +SYS_XQ_UPKXML2SQL : 'SYS_XQ_UPKXML2SQL'; +SYS_XQXFORM : 'SYS_XQXFORM'; +SYS_XSID_TO_RAW : 'SYS_XSID_TO_RAW'; +SYS_ZMAP_FILTER : 'SYS_ZMAP_FILTER'; +SYS_ZMAP_REFRESH : 'SYS_ZMAP_REFRESH'; +TABLE_LOOKUP_BY_NL : 'TABLE_LOOKUP_BY_NL'; +TABLESPACE_NO : 'TABLESPACE_NO'; +TABLESPACE : 'TABLESPACE'; +TABLES : 'TABLES'; +TABLE_STATS : 'TABLE_STATS'; +TABLE : 'TABLE'; +TABNO : 'TABNO'; +TAG : 'TAG'; +TANH : 'TANH'; +TAN : 'TAN'; +TBLORIDXPARTNUM : 'TBL$OR$IDX$PART$NUM'; +TEMPFILE : 'TEMPFILE'; +TEMPLATE : 'TEMPLATE'; +TEMPORARY : 'TEMPORARY'; +TEMP_TABLE : 'TEMP_TABLE'; +TEST : 'TEST'; +TEXT : 'TEXT'; +THAN : 'THAN'; +THEN : 'THEN'; +THE : 'THE'; +THREAD : 'THREAD'; +THROUGH : 'THROUGH'; +TIER : 'TIER'; +TIES : 'TIES'; +TIMEOUT : 'TIMEOUT'; +TIMESTAMP_LTZ_UNCONSTRAINED : 'TIMESTAMP_LTZ_UNCONSTRAINED'; +TIMESTAMP : 'TIMESTAMP'; +TIMESTAMP_TZ_UNCONSTRAINED : 'TIMESTAMP_TZ_UNCONSTRAINED'; +TIMESTAMP_UNCONSTRAINED : 'TIMESTAMP_UNCONSTRAINED'; +TIMES : 'TIMES'; +TIME : 'TIME'; +TIMEZONE : 'TIMEZONE'; +TIMEZONE_ABBR : 'TIMEZONE_ABBR'; +TIMEZONE_HOUR : 'TIMEZONE_HOUR'; +TIMEZONE_MINUTE : 'TIMEZONE_MINUTE'; +TIMEZONE_OFFSET : 'TIMEZONE_OFFSET'; +TIMEZONE_REGION : 'TIMEZONE_REGION'; +TIME_ZONE : 'TIME_ZONE'; +TIV_GB : 'TIV_GB'; +TIV_SSF : 'TIV_SSF'; +TO_ACLID : 'TO_ACLID'; +TO_BINARY_DOUBLE : 'TO_BINARY_DOUBLE'; +TO_BINARY_FLOAT : 'TO_BINARY_FLOAT'; +TO_BLOB : 'TO_BLOB'; +TO_CLOB : 'TO_CLOB'; +TO_DSINTERVAL : 'TO_DSINTERVAL'; +TO_LOB : 'TO_LOB'; +TO_MULTI_BYTE : 'TO_MULTI_BYTE'; +TO_NCHAR : 'TO_NCHAR'; +TO_NCLOB : 'TO_NCLOB'; +TO_NUMBER : 'TO_NUMBER'; +TOPLEVEL : 'TOPLEVEL'; +TO_SINGLE_BYTE : 'TO_SINGLE_BYTE'; +TO_TIMESTAMP : 'TO_TIMESTAMP'; +TO_TIMESTAMP_TZ : 'TO_TIMESTAMP_TZ'; +TO_TIME : 'TO_TIME'; +TO_TIME_TZ : 'TO_TIME_TZ'; +TO : 'TO'; +TO_YMINTERVAL : 'TO_YMINTERVAL'; +TRACE : 'TRACE'; +TRACING : 'TRACING'; +TRACKING : 'TRACKING'; +TRAILING : 'TRAILING'; +TRANSACTION : 'TRANSACTION'; +TRANSFORM_DISTINCT_AGG : 'TRANSFORM_DISTINCT_AGG'; +TRANSITIONAL : 'TRANSITIONAL'; +TRANSITION : 'TRANSITION'; +TRANSLATE : 'TRANSLATE'; +TRANSLATION : 'TRANSLATION'; +TREAT : 'TREAT'; +TRIGGERS : 'TRIGGERS'; +TRIGGER : 'TRIGGER'; +TRUE : 'TRUE'; +TRUNCATE : 'TRUNCATE'; +TRUNC : 'TRUNC'; +TRUSTED : 'TRUSTED'; +TRUST : 'TRUST'; +TUNING : 'TUNING'; +TX : 'TX'; +TYPES : 'TYPES'; +TYPE : 'TYPE'; +TZ_OFFSET : 'TZ_OFFSET'; +UB2 : 'UB2'; +UBA : 'UBA'; +UCS2 : 'UCS2'; +UID : 'UID'; +UNARCHIVED : 'UNARCHIVED'; +UNBOUNDED : 'UNBOUNDED'; +UNBOUND : 'UNBOUND'; +UNCONDITIONAL : 'UNCONDITIONAL'; +UNDER : 'UNDER'; +UNDO : 'UNDO'; +UNDROP : 'UNDROP'; +UNIFORM : 'UNIFORM'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; +UNISTR : 'UNISTR'; +UNLIMITED : 'UNLIMITED'; +UNLOAD : 'UNLOAD'; +UNLOCK : 'UNLOCK'; +UNMATCHED : 'UNMATCHED'; +UNNEST_INNERJ_DISTINCT_VIEW : 'UNNEST_INNERJ_DISTINCT_VIEW'; +UNNEST_NOSEMIJ_NODISTINCTVIEW : 'UNNEST_NOSEMIJ_NODISTINCTVIEW'; +UNNEST_SEMIJ_VIEW : 'UNNEST_SEMIJ_VIEW'; +UNNEST : 'UNNEST'; +UNPACKED : 'UNPACKED'; +UNPIVOT : 'UNPIVOT'; +UNPLUG : 'UNPLUG'; +UNPROTECTED : 'UNPROTECTED'; +UNQUIESCE : 'UNQUIESCE'; +UNRECOVERABLE : 'UNRECOVERABLE'; +UNRESTRICTED : 'UNRESTRICTED'; +UNSUBSCRIBE : 'UNSUBSCRIBE'; +UNTIL : 'UNTIL'; +UNUSABLE : 'UNUSABLE'; +UNUSED : 'UNUSED'; +UPDATABLE : 'UPDATABLE'; +UPDATED : 'UPDATED'; +UPDATE : 'UPDATE'; +UPDATEXML : 'UPDATEXML'; +UPD_INDEXES : 'UPD_INDEXES'; +UPD_JOININDEX : 'UPD_JOININDEX'; +UPGRADE : 'UPGRADE'; +UPPER : 'UPPER'; +UPSERT : 'UPSERT'; +UROWID : 'UROWID'; +USABLE : 'USABLE'; +USAGE : 'USAGE'; +USE_ANTI : 'USE_ANTI'; +USE_CONCAT : 'USE_CONCAT'; +USE_CUBE : 'USE_CUBE'; +USE_HASH_AGGREGATION : 'USE_HASH_AGGREGATION'; +USE_HASH_GBY_FOR_PUSHDOWN : 'USE_HASH_GBY_FOR_PUSHDOWN'; +USE_HASH : 'USE_HASH'; +USE_HIDDEN_PARTITIONS : 'USE_HIDDEN_PARTITIONS'; +USE_INVISIBLE_INDEXES : 'USE_INVISIBLE_INDEXES'; +USE_MERGE_CARTESIAN : 'USE_MERGE_CARTESIAN'; +USE_MERGE : 'USE_MERGE'; +USE_NL : 'USE_NL'; +USE_NL_WITH_INDEX : 'USE_NL_WITH_INDEX'; +USE_PRIVATE_OUTLINES : 'USE_PRIVATE_OUTLINES'; +USER_DATA : 'USER_DATA'; +USER_DEFINED : 'USER_DEFINED'; +USERENV : 'USERENV'; +USERGROUP : 'USERGROUP'; +USER_RECYCLEBIN : 'USER_RECYCLEBIN'; +USERS : 'USERS'; +USER_TABLESPACES : 'USER_TABLESPACES'; +USER : 'USER'; +USE_SEMI : 'USE_SEMI'; +USE_STORED_OUTLINES : 'USE_STORED_OUTLINES'; +USE_TTT_FOR_GSETS : 'USE_TTT_FOR_GSETS'; +USE : 'USE'; +USE_VECTOR_AGGREGATION : 'USE_VECTOR_AGGREGATION'; +USE_WEAK_NAME_RESL : 'USE_WEAK_NAME_RESL'; +USING_NO_EXPAND : 'USING_NO_EXPAND'; +USING : 'USING'; +UTF16BE : 'UTF16BE'; +UTF16LE : 'UTF16LE'; +UTF32 : 'UTF32'; +UTF8 : 'UTF8'; +V1 : 'V1'; +V2 : 'V2'; +VALIDATE : 'VALIDATE'; +VALIDATION : 'VALIDATION'; +VALID_TIME_END : 'VALID_TIME_END'; +VALUES : 'VALUES'; +VALUE : 'VALUE'; +VARCHAR2 : 'VARCHAR2'; +VARCHAR : 'VARCHAR'; +VARIABLE : 'VARIABLE'; +VAR_POP : 'VAR_POP'; +VARRAYS : 'VARRAYS'; +VARRAY : 'VARRAY'; +VAR_SAMP : 'VAR_SAMP'; +VARYING : 'VARYING'; +VECTOR_READ_TRACE : 'VECTOR_READ_TRACE'; +VECTOR_READ : 'VECTOR_READ'; +VECTOR_TRANSFORM_DIMS : 'VECTOR_TRANSFORM_DIMS'; +VECTOR_TRANSFORM_FACT : 'VECTOR_TRANSFORM_FACT'; +VECTOR_TRANSFORM : 'VECTOR_TRANSFORM'; +VERIFIER : 'VERIFIER'; +VERIFY : 'VERIFY'; +VERSIONING : 'VERSIONING'; +VERSIONS_ENDSCN : 'VERSIONS_ENDSCN'; +VERSIONS_ENDTIME : 'VERSIONS_ENDTIME'; +VERSIONS_OPERATION : 'VERSIONS_OPERATION'; +VERSIONS_STARTSCN : 'VERSIONS_STARTSCN'; +VERSIONS_STARTTIME : 'VERSIONS_STARTTIME'; +VERSIONS : 'VERSIONS'; +VERSIONS_XID : 'VERSIONS_XID'; +VERSION : 'VERSION'; +VIEW : 'VIEW'; +VIOLATION : 'VIOLATION'; +VIRTUAL : 'VIRTUAL'; +VISIBILITY : 'VISIBILITY'; +VISIBLE : 'VISIBLE'; +VOLUME : 'VOLUME'; +VSIZE : 'VSIZE'; +WAIT : 'WAIT'; +WALLET : 'WALLET'; +WARNING : 'WARNING'; +WEEKS : 'WEEKS'; +WEEK : 'WEEK'; +WELLFORMED : 'WELLFORMED'; +WHENEVER : 'WHENEVER'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WHILE : 'WHILE'; +WHITESPACE : 'WHITESPACE'; +WIDTH_BUCKET : 'WIDTH_BUCKET'; +WITHIN : 'WITHIN'; +WITHOUT : 'WITHOUT'; +WITH_PLSQL : 'WITH_PLSQL'; +WITH : 'WITH'; +WORK : 'WORK'; +WRAPPED : 'WRAPPED'; +WRAPPER : 'WRAPPER'; +WRITE : 'WRITE'; +XDB_FASTPATH_INSERT : 'XDB_FASTPATH_INSERT'; +XDB : 'XDB'; +X_DYN_PRUNE : 'X_DYN_PRUNE'; +XID : 'XID'; +XML2OBJECT : 'XML2OBJECT'; +XMLAGG : 'XMLAGG'; +XMLATTRIBUTES : 'XMLATTRIBUTES'; +XMLCAST : 'XMLCAST'; +XMLCDATA : 'XMLCDATA'; +XMLCOLATTVAL : 'XMLCOLATTVAL'; +XMLCOMMENT : 'XMLCOMMENT'; +XMLCONCAT : 'XMLCONCAT'; +XMLDIFF : 'XMLDIFF'; +XML_DML_RWT_STMT : 'XML_DML_RWT_STMT'; +XMLELEMENT : 'XMLELEMENT'; +XMLEXISTS2 : 'XMLEXISTS2'; +XMLEXISTS : 'XMLEXISTS'; +XMLFOREST : 'XMLFOREST'; +XMLINDEX : 'XMLINDEX'; +XMLINDEX_REWRITE_IN_SELECT : 'XMLINDEX_REWRITE_IN_SELECT'; +XMLINDEX_REWRITE : 'XMLINDEX_REWRITE'; +XMLINDEX_SEL_IDX_TBL : 'XMLINDEX_SEL_IDX_TBL'; +XMLISNODE : 'XMLISNODE'; +XMLISVALID : 'XMLISVALID'; +XMLNAMESPACES : 'XMLNAMESPACES'; +XMLPARSE : 'XMLPARSE'; +XMLPATCH : 'XMLPATCH'; +XMLPI : 'XMLPI'; +XMLQUERYVAL : 'XMLQUERYVAL'; +XMLQUERY : 'XMLQUERY'; +XMLROOT : 'XMLROOT'; +XMLSCHEMA : 'XMLSCHEMA'; +XMLSERIALIZE : 'XMLSERIALIZE'; +XMLTABLE : 'XMLTABLE'; +XMLTRANSFORMBLOB : 'XMLTRANSFORMBLOB'; +XMLTRANSFORM : 'XMLTRANSFORM'; +XMLTYPE : 'XMLTYPE'; +XML : 'XML'; +XPATHTABLE : 'XPATHTABLE'; +XS_SYS_CONTEXT : 'XS_SYS_CONTEXT'; +XS : 'XS'; +XTRANSPORT : 'XTRANSPORT'; +YEARS : 'YEARS'; +YEAR : 'YEAR'; +YES : 'YES'; +YMINTERVAL_UNCONSTRAINED : 'YMINTERVAL_UNCONSTRAINED'; +ZONEMAP : 'ZONEMAP'; +ZONE : 'ZONE'; +PREDICTION : 'PREDICTION'; +PREDICTION_BOUNDS : 'PREDICTION_BOUNDS'; +PREDICTION_COST : 'PREDICTION_COST'; +PREDICTION_DETAILS : 'PREDICTION_DETAILS'; +PREDICTION_PROBABILITY : 'PREDICTION_PROBABILITY'; +PREDICTION_SET : 'PREDICTION_SET'; -CUME_DIST: 'CUME_DIST'; -DENSE_RANK: 'DENSE_RANK'; -LISTAGG: 'LISTAGG'; -PERCENT_RANK: 'PERCENT_RANK'; -PERCENTILE_CONT: 'PERCENTILE_CONT'; -PERCENTILE_DISC: 'PERCENTILE_DISC'; -RANK: 'RANK'; +CUME_DIST : 'CUME_DIST'; +DENSE_RANK : 'DENSE_RANK'; +LISTAGG : 'LISTAGG'; +PERCENT_RANK : 'PERCENT_RANK'; +PERCENTILE_CONT : 'PERCENTILE_CONT'; +PERCENTILE_DISC : 'PERCENTILE_DISC'; +RANK : 'RANK'; -AVG: 'AVG'; -CORR: 'CORR'; -COVAR_: 'COVAR_'; -DECODE: 'DECODE'; -LAG: 'LAG'; -LEAD: 'LEAD'; -MAX: 'MAX'; -MEDIAN: 'MEDIAN'; -MIN: 'MIN'; -NTILE: 'NTILE'; -NVL: 'NVL'; -RATIO_TO_REPORT: 'RATIO_TO_REPORT'; -REGR_: 'REGR_'; -ROUND: 'ROUND'; -ROW_NUMBER: 'ROW_NUMBER'; -SUBSTR: 'SUBSTR'; -TO_CHAR: 'TO_CHAR'; -TRIM: 'TRIM'; -SUM: 'SUM'; -STDDEV: 'STDDEV'; -VAR_: 'VAR_'; -VARIANCE: 'VARIANCE'; -LEAST: 'LEAST'; -GREATEST: 'GREATEST'; -TO_DATE: 'TO_DATE'; +AVG : 'AVG'; +CORR : 'CORR'; +COVAR_ : 'COVAR_'; +DECODE : 'DECODE'; +LAG : 'LAG'; +LEAD : 'LEAD'; +MAX : 'MAX'; +MEDIAN : 'MEDIAN'; +MIN : 'MIN'; +NTILE : 'NTILE'; +NVL : 'NVL'; +RATIO_TO_REPORT : 'RATIO_TO_REPORT'; +REGR_ : 'REGR_'; +ROUND : 'ROUND'; +ROW_NUMBER : 'ROW_NUMBER'; +SUBSTR : 'SUBSTR'; +TO_CHAR : 'TO_CHAR'; +TRIM : 'TRIM'; +SUM : 'SUM'; +STDDEV : 'STDDEV'; +VAR_ : 'VAR_'; +VARIANCE : 'VARIANCE'; +LEAST : 'LEAST'; +GREATEST : 'GREATEST'; +TO_DATE : 'TO_DATE'; // Rule #358 - subtoken typecast in , it also incorporates // Lowercase 'n' is a usual addition to the standard -NATIONAL_CHAR_STRING_LIT: 'N' '\'' (~('\'' | '\r' | '\n' ) | '\'' '\'' | NEWLINE)* '\''; +NATIONAL_CHAR_STRING_LIT: 'N' '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; // Rule #040 - subtoken typecast in // Lowercase 'b' is a usual addition to the standard @@ -2259,9 +2263,9 @@ BIT_STRING_LIT: 'B' ('\'' [01]* '\'')+; // Rule #284 - subtoken typecast in // Lowercase 'x' is a usual addition to the standard -HEX_STRING_LIT: 'X' ('\'' [A-F0-9]* '\'')+; -DOUBLE_PERIOD: '..'; -PERIOD: '.'; +HEX_STRING_LIT : 'X' ('\'' [A-F0-9]* '\'')+; +DOUBLE_PERIOD : '..'; +PERIOD : '.'; //{ Rule #238 // This rule is a bit tricky - it resolves the ambiguity with @@ -2279,85 +2283,93 @@ PERIOD: '.'; (D | F)? ;*/ -UNSIGNED_INTEGER: [0-9]+; -APPROXIMATE_NUM_LIT: FLOAT_FRAGMENT ('E' ('+'|'-')? (FLOAT_FRAGMENT | [0-9]+))? ('D' | 'F')?; +UNSIGNED_INTEGER : [0-9]+; +APPROXIMATE_NUM_LIT : FLOAT_FRAGMENT ('E' ('+' | '-')? (FLOAT_FRAGMENT | [0-9]+))? ('D' | 'F')?; // Rule #--- is a base for Rule #065 , it incorporates // and a superfluous subtoken typecasting of the "QUOTE" -CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; +CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; // See https://livesql.oracle.com/apex/livesql/file/content_CIREYU9EA54EOKQ7LAMZKRF6P.html // TODO: context sensitive string quotes (any characted after quote) -CHAR_STRING_PERL : 'Q' '\'' (QS_ANGLE | QS_BRACE | QS_BRACK | QS_PAREN | QS_EXCLAM | QS_SHARP | QS_QUOTE | QS_DQUOTE) '\'' -> type(CHAR_STRING); -fragment QS_ANGLE : '<' .*? '>'; -fragment QS_BRACE : '{' .*? '}'; -fragment QS_BRACK : '[' .*? ']'; -fragment QS_PAREN : '(' .*? ')'; -fragment QS_EXCLAM : '!' .*? '!'; -fragment QS_SHARP : '#' .*? '#'; -fragment QS_QUOTE : '\'' .*? '\''; -fragment QS_DQUOTE : '"' .*? '"'; +CHAR_STRING_PERL: + 'Q' '\'' ( + QS_ANGLE + | QS_BRACE + | QS_BRACK + | QS_PAREN + | QS_EXCLAM + | QS_SHARP + | QS_QUOTE + | QS_DQUOTE + ) '\'' -> type(CHAR_STRING) +; +fragment QS_ANGLE : '<' .*? '>'; +fragment QS_BRACE : '{' .*? '}'; +fragment QS_BRACK : '[' .*? ']'; +fragment QS_PAREN : '(' .*? ')'; +fragment QS_EXCLAM : '!' .*? '!'; +fragment QS_SHARP : '#' .*? '#'; +fragment QS_QUOTE : '\'' .*? '\''; +fragment QS_DQUOTE : '"' .*? '"'; -DELIMITED_ID: '"' (~('"' | '\r' | '\n') | '"' '"')+ '"' ; +DELIMITED_ID: '"' (~('"' | '\r' | '\n') | '"' '"')+ '"'; -PERCENT: '%'; -AMPERSAND: '&'; -LEFT_PAREN: '('; -RIGHT_PAREN: ')'; -DOUBLE_ASTERISK: '**'; -ASTERISK: '*'; -PLUS_SIGN: '+'; -MINUS_SIGN: '-'; -COMMA: ','; -SOLIDUS: '/'; -AT_SIGN: '@'; -ASSIGN_OP: ':='; +PERCENT : '%'; +AMPERSAND : '&'; +LEFT_PAREN : '('; +RIGHT_PAREN : ')'; +DOUBLE_ASTERISK : '**'; +ASTERISK : '*'; +PLUS_SIGN : '+'; +MINUS_SIGN : '-'; +COMMA : ','; +SOLIDUS : '/'; +AT_SIGN : '@'; +ASSIGN_OP : ':='; -BINDVAR - : ':' SIMPLE_LETTER (SIMPLE_LETTER | [0-9] | '_')* - | ':' DELIMITED_ID // not used in SQL but spotted in v$sqltext when using cursor_sharing +BINDVAR: + ':' SIMPLE_LETTER (SIMPLE_LETTER | [0-9] | '_')* + | ':' DELIMITED_ID // not used in SQL but spotted in v$sqltext when using cursor_sharing | ':' UNSIGNED_INTEGER | QUESTION_MARK // not in SQL, not in Oracle, not in OCI, use this for JDBC - ; +; -NOT_EQUAL_OP: '!=' - | '<>' - | '^=' - | '~=' - ; -CARRET_OPERATOR_PART: '^'; -TILDE_OPERATOR_PART: '~'; -EXCLAMATION_OPERATOR_PART: '!'; -GREATER_THAN_OP: '>'; -LESS_THAN_OP: '<'; -COLON: ':'; -SEMICOLON: ';'; +NOT_EQUAL_OP : '!=' | '<>' | '^=' | '~='; +CARRET_OPERATOR_PART : '^'; +TILDE_OPERATOR_PART : '~'; +EXCLAMATION_OPERATOR_PART : '!'; +GREATER_THAN_OP : '>'; +LESS_THAN_OP : '<'; +COLON : ':'; +SEMICOLON : ';'; -BAR: '|'; -EQUALS_OP: '='; +BAR : '|'; +EQUALS_OP : '='; -LEFT_BRACKET: '['; -RIGHT_BRACKET: ']'; +LEFT_BRACKET : '['; +RIGHT_BRACKET : ']'; INTRODUCER: '_'; // Comments https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm -SINGLE_LINE_COMMENT: '--' ~('\r' | '\n')* NEWLINE_EOF -> channel(HIDDEN); -MULTI_LINE_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); +SINGLE_LINE_COMMENT : '--' ~('\r' | '\n')* NEWLINE_EOF -> channel(HIDDEN); +MULTI_LINE_COMMENT : '/*' .*? '*/' -> channel(HIDDEN); // https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve034.htm#SQPUG054 -REMARK_COMMENT: 'REM' {self.IsNewlineAtPos(-4)}? 'ARK'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF -> channel(HIDDEN); +REMARK_COMMENT: + 'REM' {self.IsNewlineAtPos(-4)}? 'ARK'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF -> channel(HIDDEN) +; // https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve032.htm#SQPUG052 -PROMPT_MESSAGE: 'PRO' {self.IsNewlineAtPos(-4)}? 'MPT'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF; +PROMPT_MESSAGE: 'PRO' {self.IsNewlineAtPos(-4)}? 'MPT'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF; // TODO: should starts with newline START_CMD - //: 'STA' 'RT'? SPACE ~('\r' | '\n')* NEWLINE_EOF - // https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12002.htm - // https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12003.htm - : '@' {self.IsNewlineAtPos(-2)}? '@'? ~('\r' | '\n')* NEWLINE_EOF - ; +//: 'STA' 'RT'? SPACE ~('\r' | '\n')* NEWLINE_EOF +: // https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12003.htm + '@' {self.IsNewlineAtPos(-2)}? '@'? ~('\r' | '\n')* NEWLINE_EOF +; REGULAR_ID: SIMPLE_LETTER (SIMPLE_LETTER | '$' | '_' | '#' | [0-9])*; @@ -2370,4 +2382,4 @@ fragment QUESTION_MARK : '?'; fragment SIMPLE_LETTER : [A-Z]; fragment FLOAT_FRAGMENT : UNSIGNED_INTEGER* '.'? UNSIGNED_INTEGER+; fragment NEWLINE : '\r'? '\n'; -fragment SPACE : [ \t]; +fragment SPACE : [ \t]; \ No newline at end of file diff --git a/sql/plsql/Dart/PlSqlParser.g4 b/sql/plsql/Dart/PlSqlParser.g4 index f6e48444ab..fd1c00ddd6 100644 --- a/sql/plsql/Dart/PlSqlParser.g4 +++ b/sql/plsql/Dart/PlSqlParser.g4 @@ -1,4 +1,4 @@ - /** +/** * Oracle(c) PL/SQL 11g Parser * * Copyright (c) 2009-2011 Alexandre Porcelli @@ -18,14 +18,17 @@ * limitations under the License. */ +// $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 PlSqlParser; options { - tokenVocab=PlSqlLexer; - superClass=PlSqlParserBase; + tokenVocab = PlSqlLexer; + superClass = PlSqlParserBase; } -@parser::header{ +@parser::header { import 'PlSqlParserBase.dart'; } @@ -56,17 +59,14 @@ unit_statement | alter_materialized_view_log | alter_user | alter_view - | analyze | associate_statistics | audit_traditional | unified_auditing - | create_function_body | create_procedure_body | create_package | create_package_body - | create_index | create_table | create_tablespace @@ -77,12 +77,10 @@ unit_statement | create_materialized_view | create_materialized_view_log | create_user - | create_sequence | create_trigger | create_type | create_synonym - | drop_function | drop_package | drop_procedure @@ -94,16 +92,11 @@ unit_statement | drop_table | drop_view | drop_index - | rename_object - | comment_on_column | comment_on_table - | anonymous_block - | grant_statement - | procedure_call ; @@ -120,9 +113,15 @@ alter_function ; create_function_body - : CREATE (OR REPLACE)? FUNCTION function_name ('(' parameter (',' parameter)* ')')? - RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)* - ((PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name) ';' + : CREATE (OR REPLACE)? FUNCTION function_name ('(' parameter (',' parameter)* ')')? RETURN type_spec ( + invoker_rights_clause + | parallel_enable_clause + | result_cache_clause + | DETERMINISTIC + )* ( + (PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) + | (PIPELINED | AGGREGATE) USING implementation_type_name + ) ';' ; // Creation Function - Specific Clauses @@ -154,15 +153,22 @@ drop_package ; alter_package - : ALTER PACKAGE package_name COMPILE DEBUG? (PACKAGE | BODY | SPECIFICATION)? compiler_parameters_clause* (REUSE SETTINGS)? ';' + : ALTER PACKAGE package_name COMPILE DEBUG? (PACKAGE | BODY | SPECIFICATION)? compiler_parameters_clause* ( + REUSE SETTINGS + )? ';' ; create_package - : CREATE (OR REPLACE)? PACKAGE (schema_object_name '.')? package_name invoker_rights_clause? (IS | AS) package_obj_spec* END package_name? ';' + : CREATE (OR REPLACE)? PACKAGE (schema_object_name '.')? package_name invoker_rights_clause? ( + IS + | AS + ) package_obj_spec* END package_name? ';' ; create_package_body - : CREATE (OR REPLACE)? PACKAGE BODY (schema_object_name '.')? package_name (IS | AS) package_obj_body* (BEGIN seq_of_statements)? END package_name? ';' + : CREATE (OR REPLACE)? PACKAGE BODY (schema_object_name '.')? package_name (IS | AS) package_obj_body* ( + BEGIN seq_of_statements + )? END package_name? ';' ; // Create Package Specific Clauses @@ -179,12 +185,13 @@ package_obj_spec ; procedure_spec - : PROCEDURE identifier ('(' parameter ( ',' parameter )* ')')? ';' + : PROCEDURE identifier ('(' parameter ( ',' parameter)* ')')? ';' ; function_spec - : FUNCTION identifier ('(' parameter ( ',' parameter)* ')')? - RETURN type_spec PIPELINED? DETERMINISTIC? (RESULT_CACHE)? ';' + : FUNCTION identifier ('(' parameter ( ',' parameter)* ')')? RETURN type_spec PIPELINED? DETERMINISTIC? ( + RESULT_CACHE + )? ';' ; package_obj_body @@ -210,20 +217,30 @@ alter_procedure ; function_body - : FUNCTION identifier ('(' parameter (',' parameter)* ')')? - RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)* - ((PIPELINED? DETERMINISTIC? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name) ';' + : FUNCTION identifier ('(' parameter (',' parameter)* ')')? RETURN type_spec ( + invoker_rights_clause + | parallel_enable_clause + | result_cache_clause + | DETERMINISTIC + )* ( + (PIPELINED? DETERMINISTIC? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) + | (PIPELINED | AGGREGATE) USING implementation_type_name + ) ';' ; procedure_body - : PROCEDURE identifier ('(' parameter (',' parameter)* ')')? (IS | AS) - (DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';' + : PROCEDURE identifier ('(' parameter (',' parameter)* ')')? (IS | AS) ( + DECLARE? seq_of_declare_specs? body + | call_spec + | EXTERNAL + ) ';' ; create_procedure_body - : CREATE (OR REPLACE)? PROCEDURE procedure_name ('(' parameter (',' parameter)* ')')? - invoker_rights_clause? (IS | AS) - (DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';' + : CREATE (OR REPLACE)? PROCEDURE procedure_name ('(' parameter (',' parameter)* ')')? invoker_rights_clause? ( + IS + | AS + ) (DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';' ; // Trigger DDLs @@ -233,14 +250,19 @@ drop_trigger ; alter_trigger - : ALTER TRIGGER alter_trigger_name=trigger_name - ((ENABLE | DISABLE) | RENAME TO rename_trigger_name=trigger_name | COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)?) ';' + : ALTER TRIGGER alter_trigger_name = trigger_name ( + (ENABLE | DISABLE) + | RENAME TO rename_trigger_name = trigger_name + | COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)? + ) ';' ; create_trigger - : CREATE ( OR REPLACE )? TRIGGER trigger_name - (simple_dml_trigger | compound_dml_trigger | non_dml_trigger) - trigger_follows_clause? (ENABLE | DISABLE)? trigger_when_clause? trigger_body ';' + : CREATE (OR REPLACE)? TRIGGER trigger_name ( + simple_dml_trigger + | compound_dml_trigger + | non_dml_trigger + ) trigger_follows_clause? (ENABLE | DISABLE)? trigger_when_clause? trigger_body ';' ; trigger_follows_clause @@ -284,10 +306,10 @@ compound_trigger_block ; timing_point_section - : bk=BEFORE STATEMENT IS trigger_block BEFORE STATEMENT ';' - | bk=BEFORE EACH ROW IS trigger_block BEFORE EACH ROW ';' - | ak=AFTER STATEMENT IS trigger_block AFTER STATEMENT ';' - | ak=AFTER EACH ROW IS trigger_block AFTER EACH ROW ';' + : bk = BEFORE STATEMENT IS trigger_block BEFORE STATEMENT ';' + | bk = BEFORE EACH ROW IS trigger_block BEFORE EACH ROW ';' + | ak = AFTER STATEMENT IS trigger_block AFTER STATEMENT ';' + | ak = AFTER EACH ROW IS trigger_block AFTER EACH ROW ';' ; non_dml_event @@ -344,14 +366,14 @@ drop_type ; alter_type - : ALTER TYPE type_name - (compile_type_clause - | replace_type_clause - //TODO | {input.LT(2).getText().equalsIgnoreCase("attribute")}? alter_attribute_definition - | alter_method_spec - | alter_collection_clauses - | modifier_clause - | overriding_subprogram_spec + : ALTER TYPE type_name ( + compile_type_clause + | replace_type_clause + //TODO | {input.LT(2).getText().equalsIgnoreCase("attribute")}? alter_attribute_definition + | alter_method_spec + | alter_collection_clauses + | modifier_clause + | overriding_subprogram_spec ) dependent_handling_clause? ';' ; @@ -374,7 +396,10 @@ alter_method_element ; alter_attribute_definition - : (ADD | MODIFY | DROP) ATTRIBUTE (attribute_definition | '(' attribute_definition (',' attribute_definition)* ')') + : (ADD | MODIFY | DROP) ATTRIBUTE ( + attribute_definition + | '(' attribute_definition (',' attribute_definition)* ')' + ) ; attribute_definition @@ -405,8 +430,9 @@ type_definition ; object_type_def - : invoker_rights_clause? (object_as_part | object_under_part) sqlj_object_type? - ('(' object_member_spec (',' object_member_spec)* ')')? modifier_clause* + : invoker_rights_clause? (object_as_part | object_under_part) sqlj_object_type? ( + '(' object_member_spec (',' object_member_spec)* ')' + )? modifier_clause* ; object_as_part @@ -444,19 +470,23 @@ subprog_decl_in_type ; proc_decl_in_type - : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' - (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') + : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ( + IS + | AS + ) (call_spec | DECLARE? seq_of_declare_specs? body ';') ; func_decl_in_type - : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN type_spec (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') + : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? RETURN type_spec ( + IS + | AS + ) (call_spec | DECLARE? seq_of_declare_specs? body ';') ; constructor_declaration - : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec - ('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN SELF AS RESULT (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') + : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec ( + '(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')' + )? RETURN SELF AS RESULT (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') ; // Common Type Clauses @@ -494,24 +524,29 @@ overriding_subprogram_spec ; overriding_function_spec - : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN (type_spec | SELF AS RESULT) - (PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body))? ';'? + : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? RETURN ( + type_spec + | SELF AS RESULT + ) (PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body))? ';'? ; type_procedure_spec - : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ((IS | AS) call_spec)? + : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ( + (IS | AS) call_spec + )? ; type_function_spec - : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN (type_spec | SELF AS RESULT) ((IS | AS) call_spec | EXTERNAL VARIABLE? NAME expression)? + : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? RETURN ( + type_spec + | SELF AS RESULT + ) ((IS | AS) call_spec | EXTERNAL VARIABLE? NAME expression)? ; constructor_spec - : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION - type_spec ('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN SELF AS RESULT ((IS | AS) call_spec)? + : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec ( + '(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')' + )? RETURN SELF AS RESULT ((IS | AS) call_spec)? ; map_order_function_spec @@ -543,11 +578,13 @@ alter_sequence alter_session : ALTER SESSION ( - ADVISE ( COMMIT | ROLLBACK | NOTHING ) + ADVISE ( COMMIT | ROLLBACK | NOTHING) | CLOSE DATABASE LINK parameter_name | enable_or_disable COMMIT IN PROCEDURE | enable_or_disable GUARD - | (enable_or_disable | FORCE) PARALLEL (DML | DDL | QUERY) (PARALLEL (literal | parameter_name))? + | (enable_or_disable | FORCE) PARALLEL (DML | DDL | QUERY) ( + PARALLEL (literal | parameter_name) + )? | SET alter_session_set_clause ) ; @@ -581,10 +618,11 @@ sequence_start_clause ; create_index - : CREATE (UNIQUE | BITMAP)? INDEX index_name - ON (cluster_index_clause | table_index_clause | bitmap_join_index_clause) - UNUSABLE? - ';' + : CREATE (UNIQUE | BITMAP)? INDEX index_name ON ( + cluster_index_clause + | table_index_clause + | bitmap_join_index_clause + ) UNUSABLE? ';' ; cluster_index_clause @@ -596,13 +634,13 @@ cluster_name ; table_index_clause - : tableview_name table_alias? '(' index_expr (ASC | DESC)? (',' index_expr (ASC | DESC)? )* ')' - index_properties? + : tableview_name table_alias? '(' index_expr (ASC | DESC)? (',' index_expr (ASC | DESC)?)* ')' index_properties? ; + bitmap_join_index_clause - : tableview_name '(' (tableview_name | table_alias)? column_name (ASC | DESC)? (',' (tableview_name | table_alias)? column_name (ASC | DESC)? )* ')' - FROM tableview_name table_alias (',' tableview_name table_alias)* - where_clause local_partitioned_index? index_attributes? + : tableview_name '(' (tableview_name | table_alias)? column_name (ASC | DESC)? ( + ',' (tableview_name | table_alias)? column_name (ASC | DESC)? + )* ')' FROM tableview_name table_alias (',' tableview_name table_alias)* where_clause local_partitioned_index? index_attributes? ; index_expr @@ -616,43 +654,50 @@ index_properties ; domain_index_clause - : indextype local_domain_index_clause? parallel_clause? (PARAMETERS '(' odci_parameters ')' )? + : indextype local_domain_index_clause? parallel_clause? (PARAMETERS '(' odci_parameters ')')? ; local_domain_index_clause - : LOCAL ('(' PARTITION partition_name (PARAMETERS '(' odci_parameters ')' )? (',' PARTITION partition_name (PARAMETERS '(' odci_parameters ')' )? )* ')' )? + : LOCAL ( + '(' PARTITION partition_name (PARAMETERS '(' odci_parameters ')')? ( + ',' PARTITION partition_name (PARAMETERS '(' odci_parameters ')')? + )* ')' + )? ; xmlindex_clause - : (XDB '.')? XMLINDEX local_xmlindex_clause? - parallel_clause? //TODO xmlindex_parameters_clause? + : (XDB '.')? XMLINDEX local_xmlindex_clause? parallel_clause? //TODO xmlindex_parameters_clause? ; local_xmlindex_clause - : LOCAL ('(' PARTITION partition_name (',' PARTITION partition_name //TODO xmlindex_parameters_clause? - )* ')')? + : LOCAL ( + '(' PARTITION partition_name ( + ',' PARTITION partition_name //TODO xmlindex_parameters_clause? + )* ')' + )? ; global_partitioned_index - : GLOBAL PARTITION BY (RANGE '(' column_name (',' column_name)* ')' '(' index_partitioning_clause ')' - | HASH '(' column_name (',' column_name)* ')' - (individual_hash_partitions - | hash_partitions_by_quantity - ) - ) + : GLOBAL PARTITION BY ( + RANGE '(' column_name (',' column_name)* ')' '(' index_partitioning_clause ')' + | HASH '(' column_name (',' column_name)* ')' ( + individual_hash_partitions + | hash_partitions_by_quantity + ) + ) ; index_partitioning_clause - : PARTITION partition_name? VALUES LESS THAN '(' literal (',' literal)* ')' - segment_attributes_clause? + : PARTITION partition_name? VALUES LESS THAN '(' literal (',' literal)* ')' segment_attributes_clause? ; local_partitioned_index - : LOCAL (on_range_partitioned_table - | on_list_partitioned_table - | on_hash_partitioned_table - | on_comp_partitioned_table - )? + : LOCAL ( + on_range_partitioned_table + | on_list_partitioned_table + | on_hash_partitioned_table + | on_comp_partitioned_table + )? ; on_range_partitioned_table @@ -664,9 +709,7 @@ on_list_partitioned_table ; partitioned_table - : PARTITION partition_name? - (segment_attributes_clause | key_compression)* - UNUSABLE? + : PARTITION partition_name? (segment_attributes_clause | key_compression)* UNUSABLE? ; on_hash_partitioned_table @@ -675,18 +718,17 @@ on_hash_partitioned_table ; on_hash_partitioned_clause - : PARTITION partition_name? (TABLESPACE tablespace)? - key_compression? UNUSABLE? + : PARTITION partition_name? (TABLESPACE tablespace)? key_compression? UNUSABLE? ; + on_comp_partitioned_table - : (STORE IN '(' tablespace (',' tablespace)* ')' )? - '(' on_comp_partitioned_clause (',' on_comp_partitioned_clause)* ')' + : (STORE IN '(' tablespace (',' tablespace)* ')')? '(' on_comp_partitioned_clause ( + ',' on_comp_partitioned_clause + )* ')' ; on_comp_partitioned_clause - : PARTITION partition_name? - (segment_attributes_clause | key_compression)* - UNUSABLE index_subpartition_clause? + : PARTITION partition_name? (segment_attributes_clause | key_compression)* UNUSABLE index_subpartition_clause? ; index_subpartition_clause @@ -695,8 +737,7 @@ index_subpartition_clause ; index_subpartition_subclause - : SUBPARTITION subpartition_name? (TABLESPACE tablespace)? - key_compression? UNUSABLE? + : SUBPARTITION subpartition_name? (TABLESPACE tablespace)? key_compression? UNUSABLE? ; odci_parameters @@ -713,13 +754,14 @@ alter_index ; alter_index_ops_set1 - : ( deallocate_unused_clause - | allocate_extent_clause - | shrink_clause - | parallel_clause - | physical_attributes_clause - | logging_clause - )+ + : ( + deallocate_unused_clause + | allocate_extent_clause + | shrink_clause + | parallel_clause + | physical_attributes_clause + | logging_clause + )+ ; alter_index_ops_set2 @@ -747,20 +789,16 @@ monitoring_nomonitoring ; rebuild_clause - : REBUILD ( PARTITION partition_name - | SUBPARTITION subpartition_name - | REVERSE - | NOREVERSE - )? - ( parallel_clause - | TABLESPACE tablespace - | PARAMETERS '(' odci_parameters ')' -//TODO | xmlindex_parameters_clause - | ONLINE - | physical_attributes_clause - | key_compression - | logging_clause - )* + : REBUILD (PARTITION partition_name | SUBPARTITION subpartition_name | REVERSE | NOREVERSE)? ( + parallel_clause + | TABLESPACE tablespace + | PARAMETERS '(' odci_parameters ')' + //TODO | xmlindex_parameters_clause + | ONLINE + | physical_attributes_clause + | key_compression + | logging_clause + )* ; alter_index_partitioning @@ -775,16 +813,15 @@ alter_index_partitioning ; modify_index_default_attrs - : MODIFY DEFAULT ATTRIBUTES (FOR PARTITION partition_name)? - ( physical_attributes_clause - | TABLESPACE (tablespace | DEFAULT) - | logging_clause - ) + : MODIFY DEFAULT ATTRIBUTES (FOR PARTITION partition_name)? ( + physical_attributes_clause + | TABLESPACE (tablespace | DEFAULT) + | logging_clause + ) ; add_hash_index_partition - : ADD PARTITION partition_name? (TABLESPACE tablespace)? - key_compression? parallel_clause? + : ADD PARTITION partition_name? (TABLESPACE tablespace)? key_compression? parallel_clause? ; coalesce_index_partition @@ -792,13 +829,13 @@ coalesce_index_partition ; modify_index_partition - : MODIFY PARTITION partition_name - ( modify_index_partitions_ops+ + : MODIFY PARTITION partition_name ( + modify_index_partitions_ops+ | PARAMETERS '(' odci_parameters ')' | COALESCE | UPDATE BLOCK REFERENCES | UNUSABLE - ) + ) ; modify_index_partitions_ops @@ -810,8 +847,7 @@ modify_index_partitions_ops ; rename_index_partition - : RENAME (PARTITION partition_name | SUBPARTITION subpartition_name) - TO new_partition_name + : RENAME (PARTITION partition_name | SUBPARTITION subpartition_name) TO new_partition_name ; drop_index_partition @@ -819,23 +855,26 @@ drop_index_partition ; split_index_partition - : SPLIT PARTITION partition_name_old AT '(' literal (',' literal)* ')' - (INTO '(' index_partition_description ',' index_partition_description ')' ) ? parallel_clause? + : SPLIT PARTITION partition_name_old AT '(' literal (',' literal)* ')' ( + INTO '(' index_partition_description ',' index_partition_description ')' + )? parallel_clause? ; index_partition_description - : PARTITION (partition_name ( (segment_attributes_clause | key_compression)+ - | PARAMETERS '(' odci_parameters ')' - ) - UNUSABLE? - )? + : PARTITION ( + partition_name ( + (segment_attributes_clause | key_compression)+ + | PARAMETERS '(' odci_parameters ')' + ) UNUSABLE? + )? ; modify_index_subpartition - : MODIFY SUBPARTITION subpartition_name (UNUSABLE - | allocate_extent_clause - | deallocate_unused_clause - ) + : MODIFY SUBPARTITION subpartition_name ( + UNUSABLE + | allocate_extent_clause + | deallocate_unused_clause + ) ; partition_name_old @@ -851,26 +890,24 @@ new_index_name ; create_user - : CREATE USER - user_object_name - ( identified_by - | identified_other_clause - | user_tablespace_clause - | quota_clause - | profile_clause - | password_expire_clause - | user_lock_clause - | user_editions_clause - | container_clause - )+ ';' + : CREATE USER user_object_name ( + identified_by + | identified_other_clause + | user_tablespace_clause + | quota_clause + | profile_clause + | password_expire_clause + | user_lock_clause + | user_editions_clause + | container_clause + )+ ';' ; // The standard clauses only permit one user per statement. // The proxy clause allows multiple users for a proxy designation. alter_user - : ALTER USER - user_object_name - ( alter_identified_by + : ALTER USER user_object_name ( + alter_identified_by | identified_other_clause | user_tablespace_clause | quota_clause @@ -881,9 +918,8 @@ alter_user | alter_user_editions_clause | container_clause | container_data_clause - )+ - ';' - | user_object_name (',' user_object_name)* proxy_clause ';' + )+ ';' + | user_object_name (',' user_object_name)* proxy_clause ';' ; alter_identified_by @@ -937,13 +973,12 @@ alter_user_editions_clause proxy_clause : REVOKE CONNECT THROUGH (ENTERPRISE USERS | user_object_name) - | GRANT CONNECT THROUGH - ( ENTERPRISE USERS - | user_object_name - (WITH (NO ROLES | ROLE role_clause))? - (AUTHENTICATION REQUIRED)? - (AUTHENTICATED USING (PASSWORD | CERTIFICATE | DISTINGUISHED NAME))? - ) + | GRANT CONNECT THROUGH ( + ENTERPRISE USERS + | user_object_name (WITH (NO ROLES | ROLE role_clause))? (AUTHENTICATION REQUIRED)? ( + AUTHENTICATED USING (PASSWORD | CERTIFICATE | DISTINGUISHED NAME) + )? + ) ; container_names @@ -965,34 +1000,26 @@ container_data_clause // https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4005.htm#SQLRF01105 analyze - : ( ANALYZE (TABLE tableview_name | INDEX index_name) partition_extention_clause? - | ANALYZE CLUSTER cluster_name - ) - - ( validation_clauses - | LIST CHAINED ROWS into_clause1? - | DELETE SYSTEM? STATISTICS - ) - ';' + : ( + ANALYZE (TABLE tableview_name | INDEX index_name) partition_extention_clause? + | ANALYZE CLUSTER cluster_name + ) (validation_clauses | LIST CHAINED ROWS into_clause1? | DELETE SYSTEM? STATISTICS) ';' ; partition_extention_clause - : PARTITION ( '(' partition_name ')' - | FOR '(' partition_key_value (',' partition_key_value)* ')' - ) - | SUBPARTITION ( '(' subpartition_name ')' - | FOR '(' subpartition_key_value (',' subpartition_key_value)* ')' - ) + : PARTITION ( + '(' partition_name ')' + | FOR '(' partition_key_value (',' partition_key_value)* ')' + ) + | SUBPARTITION ( + '(' subpartition_name ')' + | FOR '(' subpartition_key_value (',' subpartition_key_value)* ')' + ) ; validation_clauses : VALIDATE REF UPDATE (SET DANGLING TO NULL_)? - | VALIDATE STRUCTURE - ( CASCADE FAST - | CASCADE online_or_offline? into_clause? - | CASCADE - )? - online_or_offline? into_clause? + | VALIDATE STRUCTURE (CASCADE FAST | CASCADE online_or_offline? into_clause? | CASCADE)? online_or_offline? into_clause? ; online_or_offline @@ -1015,10 +1042,7 @@ subpartition_key_value //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4006.htm#SQLRF01106 associate_statistics - : ASSOCIATE STATISTICS - WITH (column_association | function_association) - storage_table_clause? - ';' + : ASSOCIATE STATISTICS WITH (column_association | function_association) storage_table_clause? ';' ; column_association @@ -1026,24 +1050,23 @@ column_association ; function_association - : ( FUNCTIONS function_name (',' function_name)* - | PACKAGES package_name (',' package_name)* - | TYPES type_name (',' type_name)* - | INDEXES index_name (',' index_name)* - | INDEXTYPES indextype_name (',' indextype_name)* - ) - - ( using_statistics_type - | default_cost_clause (',' default_selectivity_clause)? - | default_selectivity_clause (',' default_cost_clause)? - ) + : ( + FUNCTIONS function_name (',' function_name)* + | PACKAGES package_name (',' package_name)* + | TYPES type_name (',' type_name)* + | INDEXES index_name (',' index_name)* + | INDEXTYPES indextype_name (',' indextype_name)* + ) ( + using_statistics_type + | default_cost_clause (',' default_selectivity_clause)? + | default_selectivity_clause (',' default_cost_clause)? + ) ; indextype_name : id_expression ; - using_statistics_type : USING (statistics_type_name | NULL_) ; @@ -1082,13 +1105,12 @@ storage_table_clause // https://docs.oracle.com/database/121/SQLRF/statements_4008.htm#SQLRF56110 unified_auditing - : {self.isVersion12()}? - AUDIT (POLICY policy_name ((BY | EXCEPT) audit_user (',' audit_user)* )? - (WHENEVER NOT? SUCCESSFUL)? - | CONTEXT NAMESPACE oracle_namespace - ATTRIBUTES attribute_name (',' attribute_name)* (BY audit_user (',' audit_user)*)? - ) - ';' + : {self.isVersion12()}? AUDIT ( + POLICY policy_name ((BY | EXCEPT) audit_user (',' audit_user)*)? (WHENEVER NOT? SUCCESSFUL)? + | CONTEXT NAMESPACE oracle_namespace ATTRIBUTES attribute_name (',' attribute_name)* ( + BY audit_user (',' audit_user)* + )? + ) ';' ; policy_name @@ -1099,14 +1121,12 @@ policy_name // https://docs.oracle.com/database/121/SQLRF/statements_4007.htm#SQLRF01107 audit_traditional - : AUDIT ( audit_operation_clause (auditing_by_clause | IN SESSION CURRENT)? - | audit_schema_object_clause - | NETWORK - | audit_direct_path - ) - (BY (SESSION | ACCESS) )? (WHENEVER NOT? SUCCESSFUL)? - audit_container_clause? - ';' + : AUDIT ( + audit_operation_clause (auditing_by_clause | IN SESSION CURRENT)? + | audit_schema_object_clause + | NETWORK + | audit_direct_path + ) (BY (SESSION | ACCESS))? (WHENEVER NOT? SUCCESSFUL)? audit_container_clause? ';' ; audit_direct_path @@ -1118,9 +1138,10 @@ audit_container_clause ; audit_operation_clause - : ( (sql_statement_shortcut | ALL STATEMENTS?) (',' (sql_statement_shortcut | ALL STATEMENTS?) )* - | (system_privilege | ALL PRIVILEGES) (',' (system_privilege | ALL PRIVILEGES) )* - ) + : ( + (sql_statement_shortcut | ALL STATEMENTS?) (',' (sql_statement_shortcut | ALL STATEMENTS?))* + | (system_privilege | ALL PRIVILEGES) (',' (system_privilege | ALL PRIVILEGES))* + ) ; auditing_by_clause @@ -1132,7 +1153,7 @@ audit_user ; audit_schema_object_clause - : ( sql_operation (',' sql_operation)* | ALL) auditing_on_clause + : (sql_operation (',' sql_operation)* | ALL) auditing_on_clause ; sql_operation @@ -1153,12 +1174,13 @@ sql_operation ; auditing_on_clause - : ON ( object_name - | DIRECTORY regular_id - | MINING MODEL model_name - | {self.isVersion12()}? SQL TRANSLATION PROFILE profile_name - | DEFAULT - ) + : ON ( + object_name + | DIRECTORY regular_id + | MINING MODEL model_name + | {self.isVersion12()}? SQL TRANSLATION PROFILE profile_name + | DEFAULT + ) ; model_name @@ -1228,19 +1250,11 @@ rename_object ; grant_statement - : GRANT - ( ','? - (role_name - | system_privilege - | object_privilege paren_column_list? - ) - )+ - (ON grant_object_name)? - TO (grantee_name | PUBLIC) (',' (grantee_name | PUBLIC) )* - (WITH (ADMIN | DELEGATE) OPTION)? - (WITH HIERARCHY OPTION)? - (WITH GRANT OPTION)? - container_clause? ';' + : GRANT (','? (role_name | system_privilege | object_privilege paren_column_list?))+ ( + ON grant_object_name + )? TO (grantee_name | PUBLIC) (',' (grantee_name | PUBLIC))* (WITH (ADMIN | DELEGATE) OPTION)? ( + WITH HIERARCHY OPTION + )? (WITH GRANT OPTION)? container_clause? ';' ; container_clause @@ -1248,8 +1262,7 @@ container_clause ; create_directory - : CREATE (OR REPLACE)? DIRECTORY directory_name AS directory_path - ';' + : CREATE (OR REPLACE)? DIRECTORY directory_name AS directory_path ';' ; directory_name @@ -1263,11 +1276,10 @@ directory_path // https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/alter_library.htm#LNPLS99946 // https://docs.oracle.com/database/121/LNPLS/alter_library.htm#LNPLS99946 alter_library - : ALTER LIBRARY library_name - ( COMPILE library_debug? compiler_parameters_clause* (REUSE SETTINGS)? - | library_editionable - ) - ';' + : ALTER LIBRARY library_name ( + COMPILE library_debug? compiler_parameters_clause* (REUSE SETTINGS)? + | library_editionable + ) ';' ; library_editionable @@ -1278,7 +1290,6 @@ library_debug : {self.isVersion12()}? DEBUG ; - compiler_parameters_clause : parameter_name EQUALS_OP parameter_value ; @@ -1294,18 +1305,18 @@ library_name // https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4004.htm#SQLRF01104 // https://docs.oracle.com/database/121/SQLRF/statements_4004.htm#SQLRF01104 alter_view - : ALTER VIEW tableview_name - ( ADD out_of_line_constraint - | MODIFY CONSTRAINT constraint_name (RELY | NORELY) - | DROP ( CONSTRAINT constraint_name - | PRIMARY KEY - | UNIQUE '(' column_name (',' column_name)* ')' - ) - | COMPILE - | READ (ONLY | WRITE) - | alter_view_editionable? - ) - ';' + : ALTER VIEW tableview_name ( + ADD out_of_line_constraint + | MODIFY CONSTRAINT constraint_name (RELY | NORELY) + | DROP ( + CONSTRAINT constraint_name + | PRIMARY KEY + | UNIQUE '(' column_name (',' column_name)* ')' + ) + | COMPILE + | READ (ONLY | WRITE) + | alter_view_editionable? + ) ';' ; alter_view_editionable @@ -1313,38 +1324,35 @@ alter_view_editionable ; create_view - : CREATE (OR REPLACE)? (OR? FORCE)? EDITIONABLE? EDITIONING? VIEW - tableview_name view_options? - AS select_only_statement subquery_restriction_clause? + : CREATE (OR REPLACE)? (OR? FORCE)? EDITIONABLE? EDITIONING? VIEW tableview_name view_options? AS select_only_statement + subquery_restriction_clause? ; view_options - : view_alias_constraint + : view_alias_constraint | object_view_clause -// | xmltype_view_clause //TODO + // | xmltype_view_clause //TODO ; view_alias_constraint - : '(' ( ','? (table_alias inline_constraint* | out_of_line_constraint) )+ ')' + : '(' (','? (table_alias inline_constraint* | out_of_line_constraint))+ ')' ; object_view_clause - : OF type_name - ( WITH OBJECT (IDENTIFIER|ID|OID) ( DEFAULT | '(' REGULAR_ID (',' REGULAR_ID)* ')' ) - | UNDER tableview_name - ) - ( '(' ( ','? (out_of_line_constraint | REGULAR_ID inline_constraint ) )+ ')' )* + : OF type_name ( + WITH OBJECT (IDENTIFIER | ID | OID) (DEFAULT | '(' REGULAR_ID (',' REGULAR_ID)* ')') + | UNDER tableview_name + ) ('(' ( ','? (out_of_line_constraint | REGULAR_ID inline_constraint))+ ')')* ; inline_constraint - : (CONSTRAINT constraint_name)? - ( NOT? NULL_ + : (CONSTRAINT constraint_name)? ( + NOT? NULL_ | UNIQUE | PRIMARY KEY | references_clause | check_constraint - ) - constraint_state? + ) constraint_state? ; inline_ref_constraint @@ -1354,50 +1362,50 @@ inline_ref_constraint ; out_of_line_ref_constraint - : SCOPE FOR '(' ref_col_or_attr=regular_id ')' IS tableview_name - | REF '(' ref_col_or_attr=regular_id ')' WITH ROWID - | (CONSTRAINT constraint_name)? FOREIGN KEY '(' ( ','? ref_col_or_attr=regular_id)+ ')' references_clause constraint_state? + : SCOPE FOR '(' ref_col_or_attr = regular_id ')' IS tableview_name + | REF '(' ref_col_or_attr = regular_id ')' WITH ROWID + | (CONSTRAINT constraint_name)? FOREIGN KEY '(' (','? ref_col_or_attr = regular_id)+ ')' references_clause constraint_state? ; out_of_line_constraint - : ( (CONSTRAINT constraint_name)? - ( UNIQUE '(' column_name (',' column_name)* ')' - | PRIMARY KEY '(' column_name (',' column_name)* ')' - | foreign_key_clause - | CHECK '(' expression ')' - ) - ) - constraint_state? + : ( + (CONSTRAINT constraint_name)? ( + UNIQUE '(' column_name (',' column_name)* ')' + | PRIMARY KEY '(' column_name (',' column_name)* ')' + | foreign_key_clause + | CHECK '(' expression ')' + ) + ) constraint_state? ; constraint_state - : ( NOT? DEFERRABLE - | INITIALLY (IMMEDIATE|DEFERRED) - | (RELY|NORELY) - | (ENABLE|DISABLE) - | (VALIDATE|NOVALIDATE) - | using_index_clause - )+ + : ( + NOT? DEFERRABLE + | INITIALLY (IMMEDIATE | DEFERRED) + | (RELY | NORELY) + | (ENABLE | DISABLE) + | (VALIDATE | NOVALIDATE) + | using_index_clause + )+ ; alter_tablespace - : ALTER TABLESPACE tablespace - ( DEFAULT table_compression? storage_clause? - | MINIMUM EXTENT size_clause - | RESIZE size_clause - | COALESCE - | SHRINK SPACE_KEYWORD (KEEP size_clause)? - | RENAME TO new_tablespace_name - | begin_or_end BACKUP - | datafile_tempfile_clauses - | tablespace_logging_clauses - | tablespace_group_clause - | tablespace_state_clauses - | autoextend_clause - | flashback_mode_clause - | tablespace_retention_clause - ) - ';' + : ALTER TABLESPACE tablespace ( + DEFAULT table_compression? storage_clause? + | MINIMUM EXTENT size_clause + | RESIZE size_clause + | COALESCE + | SHRINK SPACE_KEYWORD (KEEP size_clause)? + | RENAME TO new_tablespace_name + | begin_or_end BACKUP + | datafile_tempfile_clauses + | tablespace_logging_clauses + | tablespace_group_clause + | tablespace_state_clauses + | autoextend_clause + | flashback_mode_clause + | tablespace_retention_clause + ) ';' ; datafile_tempfile_clauses @@ -1438,17 +1446,16 @@ new_tablespace_name ; create_tablespace - : CREATE (BIGFILE | SMALLFILE)? - ( permanent_tablespace_clause + : CREATE (BIGFILE | SMALLFILE)? ( + permanent_tablespace_clause | temporary_tablespace_clause | undo_tablespace_clause - ) - ';' + ) ';' ; permanent_tablespace_clause - : TABLESPACE id_expression datafile_specification? - ( MINIMUM EXTENT size_clause + : TABLESPACE id_expression datafile_specification? ( + MINIMUM EXTENT size_clause | BLOCKSIZE size_clause | logging_clause | FORCE LOGGING @@ -1458,24 +1465,21 @@ permanent_tablespace_clause | extent_management_clause | segment_management_clause | flashback_mode_clause - )* + )* ; tablespace_encryption_spec - : USING encrypt_algorithm=CHAR_STRING + : USING encrypt_algorithm = CHAR_STRING ; logging_clause : LOGGING - | NOLOGGING - | FILESYSTEM_LIKE_LOGGING + | NOLOGGING + | FILESYSTEM_LIKE_LOGGING ; extent_management_clause - : EXTENT MANAGEMENT LOCAL - ( AUTOALLOCATE - | UNIFORM (SIZE size_clause)? - )? + : EXTENT MANAGEMENT LOCAL (AUTOALLOCATE | UNIFORM (SIZE size_clause)?)? ; segment_management_clause @@ -1483,15 +1487,11 @@ segment_management_clause ; temporary_tablespace_clause - : TEMPORARY TABLESPACE tablespace_name=id_expression - tempfile_specification? - tablespace_group_clause? extent_management_clause? + : TEMPORARY TABLESPACE tablespace_name = id_expression tempfile_specification? tablespace_group_clause? extent_management_clause? ; undo_tablespace_clause - : UNDO TABLESPACE tablespace_name=id_expression - datafile_specification? - extent_management_clause? tablespace_retention_clause? + : UNDO TABLESPACE tablespace_name = id_expression datafile_specification? extent_management_clause? tablespace_retention_clause? ; tablespace_retention_clause @@ -1501,31 +1501,25 @@ tablespace_retention_clause // asm_filename is just a charater string. Would need to parse the string // to find diskgroup... datafile_specification - : DATAFILE - (','? datafile_tempfile_spec) + : DATAFILE (','? datafile_tempfile_spec) ; tempfile_specification - : TEMPFILE - (','? datafile_tempfile_spec) + : TEMPFILE (','? datafile_tempfile_spec) ; datafile_tempfile_spec : (CHAR_STRING)? (SIZE size_clause)? REUSE? autoextend_clause? ; - redo_log_file_spec - : (DATAFILE CHAR_STRING - | '(' ( ','? CHAR_STRING )+ ')' - )? - (SIZE size_clause)? - (BLOCKSIZE size_clause)? - REUSE? + : (DATAFILE CHAR_STRING | '(' ( ','? CHAR_STRING)+ ')')? (SIZE size_clause)? ( + BLOCKSIZE size_clause + )? REUSE? ; autoextend_clause - : AUTOEXTEND (OFF | ON (NEXT size_clause)? maxsize_clause? ) + : AUTOEXTEND (OFF | ON (NEXT size_clause)? maxsize_clause?) ; maxsize_clause @@ -1538,50 +1532,47 @@ build_clause parallel_clause : NOPARALLEL - | PARALLEL parallel_count=UNSIGNED_INTEGER? + | PARALLEL parallel_count = UNSIGNED_INTEGER? ; alter_materialized_view - : ALTER MATERIALIZED VIEW tableview_name - ( physical_attributes_clause - | modify_mv_column_clause - | table_compression - | lob_storage_clause (',' lob_storage_clause)* - | modify_lob_storage_clause (',' modify_lob_storage_clause)* -//TODO | alter_table_partitioning - | parallel_clause - | logging_clause - | allocate_extent_clause - | deallocate_unused_clause - | shrink_clause - | (cache_or_nocache) - )? - alter_iot_clauses? - (USING INDEX physical_attributes_clause)? - alter_mv_option1? - ( enable_or_disable QUERY REWRITE - | COMPILE - | CONSIDER FRESH - )? - ';' + : ALTER MATERIALIZED VIEW tableview_name ( + physical_attributes_clause + | modify_mv_column_clause + | table_compression + | lob_storage_clause (',' lob_storage_clause)* + | modify_lob_storage_clause (',' modify_lob_storage_clause)* + //TODO | alter_table_partitioning + | parallel_clause + | logging_clause + | allocate_extent_clause + | deallocate_unused_clause + | shrink_clause + | (cache_or_nocache) + )? alter_iot_clauses? (USING INDEX physical_attributes_clause)? alter_mv_option1? ( + enable_or_disable QUERY REWRITE + | COMPILE + | CONSIDER FRESH + )? ';' ; alter_mv_option1 : alter_mv_refresh -//TODO | MODIFY scoped_table_ref_constraint + //TODO | MODIFY scoped_table_ref_constraint ; alter_mv_refresh - : REFRESH ( FAST - | COMPLETE - | FORCE - | ON (DEMAND | COMMIT) - | START WITH expression - | NEXT expression - | WITH PRIMARY KEY - | USING DEFAULT? MASTER ROLLBACK SEGMENT rollback_segment? - | USING (ENFORCED | TRUSTED) CONSTRAINTS - )+ + : REFRESH ( + FAST + | COMPLETE + | FORCE + | ON (DEMAND | COMMIT) + | START WITH expression + | NEXT expression + | WITH PRIMARY KEY + | USING DEFAULT? MASTER ROLLBACK SEGMENT rollback_segment? + | USING (ENFORCED | TRUSTED) CONSTRAINTS + )+ ; rollback_segment @@ -1593,20 +1584,19 @@ modify_mv_column_clause ; alter_materialized_view_log - : ALTER MATERIALIZED VIEW LOG FORCE? ON tableview_name - ( physical_attributes_clause - | add_mv_log_column_clause -//TODO | alter_table_partitioning - | parallel_clause - | logging_clause - | allocate_extent_clause - | shrink_clause - | move_mv_log_clause - | cache_or_nocache - )? - mv_log_augmentation? mv_log_purge_clause? - ';' + : ALTER MATERIALIZED VIEW LOG FORCE? ON tableview_name ( + physical_attributes_clause + | add_mv_log_column_clause + //TODO | alter_table_partitioning + | parallel_clause + | logging_clause + | allocate_extent_clause + | shrink_clause + | move_mv_log_clause + | cache_or_nocache + )? mv_log_augmentation? mv_log_purge_clause? ';' ; + add_mv_log_column_clause : ADD '(' column_name ')' ; @@ -1616,16 +1606,10 @@ move_mv_log_clause ; mv_log_augmentation - : ADD ( ( OBJECT ID - | PRIMARY KEY - | ROWID - | SEQUENCE - ) - ('(' column_name (',' column_name)* ')')? - - | '(' column_name (',' column_name)* ')' - ) - new_values_clause? + : ADD ( + (OBJECT ID | PRIMARY KEY | ROWID | SEQUENCE) ('(' column_name (',' column_name)* ')')? + | '(' column_name (',' column_name)* ')' + ) new_values_clause? ; // Should bound this to just date/time expr @@ -1648,81 +1632,68 @@ including_or_excluding | EXCLUDING ; - create_materialized_view_log - : CREATE MATERIALIZED VIEW LOG ON tableview_name - ( ( physical_attributes_clause - | TABLESPACE tablespace_name=id_expression - | logging_clause - | (CACHE | NOCACHE) - )+ - )? - parallel_clause? - // table_partitioning_clauses TODO - ( WITH - ( ','? - ( OBJECT ID - | PRIMARY KEY - | ROWID - | SEQUENCE - | COMMIT SCN - ) - )* - ('(' ( ','? regular_id )+ ')' new_values_clause? )? - mv_log_purge_clause? - )* + : CREATE MATERIALIZED VIEW LOG ON tableview_name ( + ( + physical_attributes_clause + | TABLESPACE tablespace_name = id_expression + | logging_clause + | (CACHE | NOCACHE) + )+ + )? parallel_clause? + // table_partitioning_clauses TODO + ( + WITH (','? ( OBJECT ID | PRIMARY KEY | ROWID | SEQUENCE | COMMIT SCN))* ( + '(' ( ','? regular_id)+ ')' new_values_clause? + )? mv_log_purge_clause? + )* ; new_values_clause - : (INCLUDING | EXCLUDING ) NEW VALUES + : (INCLUDING | EXCLUDING) NEW VALUES ; mv_log_purge_clause - : PURGE - ( IMMEDIATE (SYNCHRONOUS | ASYNCHRONOUS)? - // |START WITH CLAUSES TODO - ) + : PURGE ( + IMMEDIATE (SYNCHRONOUS | ASYNCHRONOUS)? + // |START WITH CLAUSES TODO + ) ; create_materialized_view - : CREATE MATERIALIZED VIEW tableview_name - (OF type_name )? -//scoped_table_ref and column alias goes here TODO - ( ON PREBUILT TABLE ( (WITH | WITHOUT) REDUCED PRECISION)? - | physical_properties? (CACHE | NOCACHE)? parallel_clause? build_clause? - ) - ( USING INDEX ( (physical_attributes_clause | TABLESPACE mv_tablespace=id_expression)+ )* + : CREATE MATERIALIZED VIEW tableview_name (OF type_name)? + //scoped_table_ref and column alias goes here TODO + ( + ON PREBUILT TABLE ( (WITH | WITHOUT) REDUCED PRECISION)? + | physical_properties? (CACHE | NOCACHE)? parallel_clause? build_clause? + ) ( + USING INDEX ((physical_attributes_clause | TABLESPACE mv_tablespace = id_expression)+)* | USING NO INDEX - )? - create_mv_refresh? - (FOR UPDATE)? - ( (DISABLE | ENABLE) QUERY REWRITE )? - AS select_only_statement - ';' + )? create_mv_refresh? (FOR UPDATE)? ((DISABLE | ENABLE) QUERY REWRITE)? AS select_only_statement ';' ; create_mv_refresh - : ( NEVER REFRESH - | REFRESH - ( (FAST | COMPLETE | FORCE) - | ON (DEMAND | COMMIT) - | (START WITH | NEXT) //date goes here TODO - | WITH (PRIMARY KEY | ROWID) - | USING - ( DEFAULT (MASTER | LOCAL)? ROLLBACK SEGMENT - | (MASTER | LOCAL)? ROLLBACK SEGMENT rb_segment=REGULAR_ID - ) - | USING (ENFORCED | TRUSTED) CONSTRAINTS - )+ - ) + : ( + NEVER REFRESH + | REFRESH ( + (FAST | COMPLETE | FORCE) + | ON (DEMAND | COMMIT) + | (START WITH | NEXT) //date goes here TODO + | WITH (PRIMARY KEY | ROWID) + | USING ( + DEFAULT (MASTER | LOCAL)? ROLLBACK SEGMENT + | (MASTER | LOCAL)? ROLLBACK SEGMENT rb_segment = REGULAR_ID + ) + | USING (ENFORCED | TRUSTED) CONSTRAINTS + )+ + ) ; create_context - : CREATE (OR REPLACE)? CONTEXT oracle_namespace USING (schema_object_name '.')? package_name - (INITIALIZED (EXTERNALLY | GLOBALLY) - | ACCESSED GLOBALLY - )? - ';' + : CREATE (OR REPLACE)? CONTEXT oracle_namespace USING (schema_object_name '.')? package_name ( + INITIALIZED (EXTERNALLY | GLOBALLY) + | ACCESSED GLOBALLY + )? ';' ; oracle_namespace @@ -1731,33 +1702,33 @@ oracle_namespace //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_5001.htm#SQLRF01201 create_cluster - : CREATE CLUSTER cluster_name '(' column_name datatype SORT? (',' column_name datatype SORT?)* ')' - ( physical_attributes_clause - | SIZE size_clause - | TABLESPACE tablespace - | INDEX - | (SINGLE TABLE)? HASHKEYS UNSIGNED_INTEGER (HASH IS expression)? - )* - parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? - (CACHE | NOCACHE)? - ';' + : CREATE CLUSTER cluster_name '(' column_name datatype SORT? (',' column_name datatype SORT?)* ')' ( + physical_attributes_clause + | SIZE size_clause + | TABLESPACE tablespace + | INDEX + | (SINGLE TABLE)? HASHKEYS UNSIGNED_INTEGER (HASH IS expression)? + )* parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? (CACHE | NOCACHE)? ';' ; create_table - : CREATE (GLOBAL TEMPORARY)? TABLE tableview_name - (relational_table | object_table | xmltype_table) (AS select_only_statement)? - ';' + : CREATE (GLOBAL TEMPORARY)? TABLE tableview_name ( + relational_table + | object_table + | xmltype_table + ) (AS select_only_statement)? ';' ; xmltype_table - : OF XMLTYPE ('(' object_properties ')')? - (XMLTYPE xmltype_storage)? xmlschema_spec? xmltype_virtual_columns? - (ON COMMIT (DELETE | PRESERVE) ROWS)? oid_clause? oid_index_clause? - physical_properties? column_properties? table_partitioning_clauses? - (CACHE | NOCACHE)? (RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')')? - parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? - (enable_disable_clause+)? row_movement_clause? - flashback_archive_clause? + : OF XMLTYPE ('(' object_properties ')')? (XMLTYPE xmltype_storage)? xmlschema_spec? xmltype_virtual_columns? ( + ON COMMIT (DELETE | PRESERVE) ROWS + )? oid_clause? oid_index_clause? physical_properties? column_properties? table_partitioning_clauses? ( + CACHE + | NOCACHE + )? (RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')')? parallel_clause? ( + ROWDEPENDENCIES + | NOROWDEPENDENCIES + )? (enable_disable_clause+)? row_movement_clause? flashback_archive_clause? ; xmltype_virtual_columns @@ -1769,26 +1740,32 @@ xmltype_column_properties ; xmltype_storage - : STORE AS (OBJECT RELATIONAL - | (SECUREFILE | BASICFILE)? (CLOB | BINARY XML) (lob_segname ('(' lob_parameters ')')? | '(' lob_parameters ')')? - ) + : STORE AS ( + OBJECT RELATIONAL + | (SECUREFILE | BASICFILE)? (CLOB | BINARY XML) ( + lob_segname ('(' lob_parameters ')')? + | '(' lob_parameters ')' + )? + ) | STORE VARRAYS AS (LOBS | TABLES) ; xmlschema_spec - : (XMLSCHEMA DELIMITED_ID)? ELEMENT DELIMITED_ID - (allow_or_disallow NONSCHEMA)? - (allow_or_disallow ANYSCHEMA)? + : (XMLSCHEMA DELIMITED_ID)? ELEMENT DELIMITED_ID (allow_or_disallow NONSCHEMA)? ( + allow_or_disallow ANYSCHEMA + )? ; object_table - : OF type_name object_table_substitution? - ('(' object_properties (',' object_properties)* ')')? - (ON COMMIT (DELETE | PRESERVE) ROWS)? oid_clause? oid_index_clause? - physical_properties? column_properties? table_partitioning_clauses? - (CACHE | NOCACHE)? (RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')')? - parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? - (enable_disable_clause+)? row_movement_clause? flashback_archive_clause? + : OF type_name object_table_substitution? ('(' object_properties (',' object_properties)* ')')? ( + ON COMMIT (DELETE | PRESERVE) ROWS + )? oid_clause? oid_index_clause? physical_properties? column_properties? table_partitioning_clauses? ( + CACHE + | NOCACHE + )? (RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')')? parallel_clause? ( + ROWDEPENDENCIES + | NOROWDEPENDENCIES + )? (enable_disable_clause+)? row_movement_clause? flashback_archive_clause? ; oid_index_clause @@ -1800,7 +1777,10 @@ oid_clause ; object_properties - : (column_name | attribute_name) (DEFAULT expression)? (inline_constraint (',' inline_constraint)* | inline_ref_constraint)? + : (column_name | attribute_name) (DEFAULT expression)? ( + inline_constraint (',' inline_constraint)* + | inline_ref_constraint + )? | out_of_line_constraint | out_of_line_ref_constraint | supplemental_logging_props @@ -1811,22 +1791,21 @@ object_table_substitution ; relational_table - : ('(' relational_property (',' relational_property)* ')')? - (ON COMMIT (DELETE | PRESERVE) ROWS)? - physical_properties? column_properties? table_partitioning_clauses? - (CACHE | NOCACHE)? (RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')')? - parallel_clause? - (ROWDEPENDENCIES | NOROWDEPENDENCIES)? - (enable_disable_clause+)? row_movement_clause? flashback_archive_clause? + : ('(' relational_property (',' relational_property)* ')')? ( + ON COMMIT (DELETE | PRESERVE) ROWS + )? physical_properties? column_properties? table_partitioning_clauses? (CACHE | NOCACHE)? ( + RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')' + )? parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? (enable_disable_clause+)? row_movement_clause? flashback_archive_clause? ; relational_property - : (column_definition + : ( + column_definition | virtual_column_definition | out_of_line_constraint | out_of_line_ref_constraint | supplemental_logging_props - ) + ) ; table_partitioning_clauses @@ -1841,30 +1820,37 @@ table_partitioning_clauses ; range_partitions - : PARTITION BY RANGE '(' column_name (',' column_name)* ')' - (INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')' )? )? - '(' PARTITION partition_name? range_values_clause table_partition_description (',' PARTITION partition_name? range_values_clause table_partition_description)* ')' + : PARTITION BY RANGE '(' column_name (',' column_name)* ')' ( + INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')')? + )? '(' PARTITION partition_name? range_values_clause table_partition_description ( + ',' PARTITION partition_name? range_values_clause table_partition_description + )* ')' ; list_partitions - : PARTITION BY LIST '(' column_name ')' - '(' PARTITION partition_name? list_values_clause table_partition_description (',' PARTITION partition_name? list_values_clause table_partition_description )* ')' + : PARTITION BY LIST '(' column_name ')' '(' PARTITION partition_name? list_values_clause table_partition_description ( + ',' PARTITION partition_name? list_values_clause table_partition_description + )* ')' ; hash_partitions - : PARTITION BY HASH '(' column_name (',' column_name)* ')' - (individual_hash_partitions | hash_partitions_by_quantity) + : PARTITION BY HASH '(' column_name (',' column_name)* ')' ( + individual_hash_partitions + | hash_partitions_by_quantity + ) ; individual_hash_partitions - : '(' PARTITION partition_name? partitioning_storage_clause? (',' PARTITION partition_name? partitioning_storage_clause?)* ')' + : '(' PARTITION partition_name? partitioning_storage_clause? ( + ',' PARTITION partition_name? partitioning_storage_clause? + )* ')' ; hash_partitions_by_quantity - : PARTITIONS hash_partition_quantity - (STORE IN '(' tablespace (',' tablespace)* ')')? - (table_compression | key_compression)? - (OVERFLOW STORE IN '(' tablespace (',' tablespace)* ')' )? + : PARTITIONS hash_partition_quantity (STORE IN '(' tablespace (',' tablespace)* ')')? ( + table_compression + | key_compression + )? (OVERFLOW STORE IN '(' tablespace (',' tablespace)* ')')? ; hash_partition_quantity @@ -1872,27 +1858,33 @@ hash_partition_quantity ; composite_range_partitions - : PARTITION BY RANGE '(' column_name (',' column_name)* ')' - (INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')' )? )? - (subpartition_by_range | subpartition_by_list | subpartition_by_hash) - '(' range_partition_desc (',' range_partition_desc)* ')' + : PARTITION BY RANGE '(' column_name (',' column_name)* ')' ( + INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')')? + )? (subpartition_by_range | subpartition_by_list | subpartition_by_hash) '(' range_partition_desc ( + ',' range_partition_desc + )* ')' ; composite_list_partitions - : PARTITION BY LIST '(' column_name ')' - (subpartition_by_range | subpartition_by_list | subpartition_by_hash) - '(' list_partition_desc (',' list_partition_desc)* ')' + : PARTITION BY LIST '(' column_name ')' ( + subpartition_by_range + | subpartition_by_list + | subpartition_by_hash + ) '(' list_partition_desc (',' list_partition_desc)* ')' ; composite_hash_partitions - : PARTITION BY HASH '(' (',' column_name)+ ')' - (subpartition_by_range | subpartition_by_list | subpartition_by_hash) - (individual_hash_partitions | hash_partitions_by_quantity) + : PARTITION BY HASH '(' (',' column_name)+ ')' ( + subpartition_by_range + | subpartition_by_list + | subpartition_by_hash + ) (individual_hash_partitions | hash_partitions_by_quantity) ; reference_partitioning - : PARTITION BY REFERENCE '(' regular_id ')' - ('(' reference_partition_desc (',' reference_partition_desc)* ')')? + : PARTITION BY REFERENCE '(' regular_id ')' ( + '(' reference_partition_desc (',' reference_partition_desc)* ')' + )? ; reference_partition_desc @@ -1900,44 +1892,49 @@ reference_partition_desc ; system_partitioning - : PARTITION BY SYSTEM - (PARTITIONS UNSIGNED_INTEGER | reference_partition_desc (',' reference_partition_desc)*)? + : PARTITION BY SYSTEM ( + PARTITIONS UNSIGNED_INTEGER + | reference_partition_desc (',' reference_partition_desc)* + )? ; range_partition_desc - : PARTITION partition_name? range_values_clause table_partition_description - ( ( '(' ( range_subpartition_desc (',' range_subpartition_desc)* + : PARTITION partition_name? range_values_clause table_partition_description ( + ( + '(' ( + range_subpartition_desc (',' range_subpartition_desc)* | list_subpartition_desc (',' list_subpartition_desc)* | individual_hash_subparts (',' individual_hash_subparts)* - ) - ')' - | hash_subparts_by_quantity - ) - )? + ) ')' + | hash_subparts_by_quantity + ) + )? ; list_partition_desc - : PARTITION partition_name? list_values_clause table_partition_description - ( ( '(' ( range_subpartition_desc (',' range_subpartition_desc)* + : PARTITION partition_name? list_values_clause table_partition_description ( + ( + '(' ( + range_subpartition_desc (',' range_subpartition_desc)* | list_subpartition_desc (',' list_subpartition_desc)* | individual_hash_subparts (',' individual_hash_subparts)* - ) - ')' - | hash_subparts_by_quantity - ) - )? + ) ')' + | hash_subparts_by_quantity + ) + )? ; subpartition_template - : SUBPARTITION TEMPLATE - ( ( '(' ( range_subpartition_desc (',' range_subpartition_desc)* + : SUBPARTITION TEMPLATE ( + ( + '(' ( + range_subpartition_desc (',' range_subpartition_desc)* | list_subpartition_desc (',' list_subpartition_desc)* | individual_hash_subparts (',' individual_hash_subparts)* - ) - ')' - | hash_subpartition_quantity - ) + ) ')' + | hash_subpartition_quantity ) + ) ; hash_subpartition_quantity @@ -1953,10 +1950,10 @@ subpartition_by_list ; subpartition_by_hash - : SUBPARTITION BY HASH '(' column_name (',' column_name)* ')' - (SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')' )? - | subpartition_template - )? + : SUBPARTITION BY HASH '(' column_name (',' column_name)* ')' ( + SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')')? + | subpartition_template + )? ; subpartition_name @@ -1976,7 +1973,7 @@ individual_hash_subparts ; hash_subparts_by_quantity - : SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')' )? + : SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')')? ; range_values_clause @@ -1988,35 +1985,34 @@ list_values_clause ; table_partition_description - : deferred_segment_creation? segment_attributes_clause? - (table_compression | key_compression)? - (OVERFLOW segment_attributes_clause? )? - (lob_storage_clause | varray_col_properties | nested_table_col_properties)? + : deferred_segment_creation? segment_attributes_clause? (table_compression | key_compression)? ( + OVERFLOW segment_attributes_clause? + )? (lob_storage_clause | varray_col_properties | nested_table_col_properties)? ; partitioning_storage_clause - : ( TABLESPACE tablespace - | OVERFLOW (TABLESPACE tablespace)? - | table_compression - | key_compression - | lob_partitioning_storage - | VARRAY varray_item STORE AS (BASICFILE | SECUREFILE)? LOB lob_segname - )+ + : ( + TABLESPACE tablespace + | OVERFLOW (TABLESPACE tablespace)? + | table_compression + | key_compression + | lob_partitioning_storage + | VARRAY varray_item STORE AS (BASICFILE | SECUREFILE)? LOB lob_segname + )+ ; lob_partitioning_storage - : LOB '(' lob_item ')' - STORE AS (BASICFILE | SECUREFILE)? - (lob_segname ('(' TABLESPACE tablespace ')' )? - | '(' TABLESPACE tablespace ')' - ) + : LOB '(' lob_item ')' STORE AS (BASICFILE | SECUREFILE)? ( + lob_segname ('(' TABLESPACE tablespace ')')? + | '(' TABLESPACE tablespace ')' + ) ; datatype_null_enable - : column_name datatype - SORT? (DEFAULT expression)? (ENCRYPT ( USING CHAR_STRING )? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? ( NO? SALT )? )? - (NOT NULL_)? (ENABLE | DISABLE)? - ; + : column_name datatype SORT? (DEFAULT expression)? ( + ENCRYPT (USING CHAR_STRING)? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? (NO? SALT)? + )? (NOT NULL_)? (ENABLE | DISABLE)? + ; //Technically, this should only allow 'K' | 'M' | 'G' | 'T' | 'P' | 'E' // but having issues with examples/numbers01.sql line 11 "sysdate -1m" @@ -2024,40 +2020,34 @@ size_clause : UNSIGNED_INTEGER REGULAR_ID? ; - table_compression - : COMPRESS - ( BASIC - | FOR ( OLTP - | (QUERY | ARCHIVE) (LOW | HIGH)? - ) - )? + : COMPRESS (BASIC | FOR ( OLTP | (QUERY | ARCHIVE) (LOW | HIGH)?))? | NOCOMPRESS ; physical_attributes_clause - : (PCTFREE pctfree=UNSIGNED_INTEGER - | PCTUSED pctused=UNSIGNED_INTEGER - | INITRANS inittrans=UNSIGNED_INTEGER - | storage_clause - )+ + : ( + PCTFREE pctfree = UNSIGNED_INTEGER + | PCTUSED pctused = UNSIGNED_INTEGER + | INITRANS inittrans = UNSIGNED_INTEGER + | storage_clause + )+ ; storage_clause - : STORAGE '(' - (INITIAL initial_size=size_clause - | NEXT next_size=size_clause - | MINEXTENTS minextents=(UNSIGNED_INTEGER | UNLIMITED) - | MAXEXTENTS minextents=(UNSIGNED_INTEGER | UNLIMITED) - | PCTINCREASE pctincrease=UNSIGNED_INTEGER - | FREELISTS freelists=UNSIGNED_INTEGER - | FREELIST GROUPS freelist_groups=UNSIGNED_INTEGER - | OPTIMAL (size_clause | NULL_ ) - | BUFFER_POOL (KEEP | RECYCLE | DEFAULT) - | FLASH_CACHE (KEEP | NONE | DEFAULT) - | ENCRYPT - )+ - ')' + : STORAGE '(' ( + INITIAL initial_size = size_clause + | NEXT next_size = size_clause + | MINEXTENTS minextents = (UNSIGNED_INTEGER | UNLIMITED) + | MAXEXTENTS minextents = (UNSIGNED_INTEGER | UNLIMITED) + | PCTINCREASE pctincrease = UNSIGNED_INTEGER + | FREELISTS freelists = UNSIGNED_INTEGER + | FREELIST GROUPS freelist_groups = UNSIGNED_INTEGER + | OPTIMAL (size_clause | NULL_) + | BUFFER_POOL (KEEP | RECYCLE | DEFAULT) + | FLASH_CACHE (KEEP | NONE | DEFAULT) + | ENCRYPT + )+ ')' ; deferred_segment_creation @@ -2065,14 +2055,11 @@ deferred_segment_creation ; segment_attributes_clause - : ( physical_attributes_clause - | TABLESPACE tablespace_name=id_expression - | logging_clause - )+ + : (physical_attributes_clause | TABLESPACE tablespace_name = id_expression | logging_clause)+ ; physical_properties - : deferred_segment_creation? segment_attributes_clause table_compression? + : deferred_segment_creation? segment_attributes_clause table_compression? ; row_movement_clause @@ -2080,7 +2067,7 @@ row_movement_clause ; flashback_archive_clause - : FLASHBACK ARCHIVE flashback_archive=REGULAR_ID + : FLASHBACK ARCHIVE flashback_archive = REGULAR_ID | NO FLASHBACK ARCHIVE ; @@ -2089,10 +2076,12 @@ log_grp ; supplemental_table_logging - : ADD SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) - (',' SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) )* - | DROP SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) - (',' SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) )* + : ADD SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) ( + ',' SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) + )* + | DROP SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) ( + ',' SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) + )* ; supplemental_log_grp_clause @@ -2100,24 +2089,17 @@ supplemental_log_grp_clause ; supplemental_id_key_clause - : DATA '('( ','? ( ALL - | PRIMARY KEY - | UNIQUE - | FOREIGN KEY - ) - )+ - ')' - COLUMNS + : DATA '(' (','? ( ALL | PRIMARY KEY | UNIQUE | FOREIGN KEY))+ ')' COLUMNS ; allocate_extent_clause - : ALLOCATE EXTENT - ( '(' ( SIZE size_clause - | DATAFILE datafile=CHAR_STRING - | INSTANCE inst_num=UNSIGNED_INTEGER - )+ - ')' - )? + : ALLOCATE EXTENT ( + '(' ( + SIZE size_clause + | DATAFILE datafile = CHAR_STRING + | INSTANCE inst_num = UNSIGNED_INTEGER + )+ ')' + )? ; deallocate_unused_clause @@ -2156,6 +2138,7 @@ enable_or_disable : ENABLE | DISABLE ; + allow_or_disallow : ALLOW | DISALLOW @@ -2164,9 +2147,13 @@ allow_or_disallow // Synonym DDL Clauses create_synonym - // Synonym's schema cannot be specified for public synonyms - : CREATE (OR REPLACE)? PUBLIC SYNONYM synonym_name FOR (schema_name PERIOD)? schema_object_name (AT_SIGN link_name)? - | CREATE (OR REPLACE)? SYNONYM (schema_name PERIOD)? synonym_name FOR (schema_name PERIOD)? schema_object_name (AT_SIGN link_name)? +// Synonym's schema cannot be specified for public synonyms + : CREATE (OR REPLACE)? PUBLIC SYNONYM synonym_name FOR (schema_name PERIOD)? schema_object_name ( + AT_SIGN link_name + )? + | CREATE (OR REPLACE)? SYNONYM (schema_name PERIOD)? synonym_name FOR (schema_name PERIOD)? schema_object_name ( + AT_SIGN link_name + )? ; comment_on_table @@ -2174,15 +2161,13 @@ comment_on_table ; alter_cluster - : ALTER CLUSTER cluster_name - ( physical_attributes_clause + : ALTER CLUSTER cluster_name ( + physical_attributes_clause | SIZE size_clause | allocate_extent_clause | deallocate_unused_clause | cache_or_nocache - )+ - parallel_clause? - ';' + )+ parallel_clause? ';' ; cache_or_nocache @@ -2195,18 +2180,17 @@ database_name ; alter_database - : ALTER DATABASE database_name? - ( startup_clauses - | recovery_clauses - | database_file_clauses - | logfile_clauses - | controlfile_clauses - | standby_database_clauses - | default_settings_clause - | instance_clauses - | security_clause - ) - ';' + : ALTER DATABASE database_name? ( + startup_clauses + | recovery_clauses + | database_file_clauses + | logfile_clauses + | controlfile_clauses + | standby_database_clauses + | default_settings_clause + | instance_clauses + | security_clause + ) ';' ; startup_clauses @@ -2237,57 +2221,62 @@ begin_or_end ; general_recovery - : RECOVER AUTOMATIC? (FROM CHAR_STRING)? - ( (full_database_recovery | partial_database_recovery | LOGFILE CHAR_STRING )? - ((TEST | ALLOW UNSIGNED_INTEGER CORRUPTION | parallel_clause)+ )? - | CONTINUE DEFAULT? - | CANCEL - ) + : RECOVER AUTOMATIC? (FROM CHAR_STRING)? ( + (full_database_recovery | partial_database_recovery | LOGFILE CHAR_STRING)? ( + (TEST | ALLOW UNSIGNED_INTEGER CORRUPTION | parallel_clause)+ + )? + | CONTINUE DEFAULT? + | CANCEL + ) ; //Need to come back to full_database_recovery - : STANDBY? DATABASE - ((UNTIL (CANCEL |TIME CHAR_STRING | CHANGE UNSIGNED_INTEGER | CONSISTENT) - | USING BACKUP CONTROLFILE - )+ - )? + : STANDBY? DATABASE ( + ( + UNTIL (CANCEL | TIME CHAR_STRING | CHANGE UNSIGNED_INTEGER | CONSISTENT) + | USING BACKUP CONTROLFILE + )+ + )? ; partial_database_recovery : TABLESPACE tablespace (',' tablespace)* - | DATAFILE CHAR_STRING | filenumber (',' CHAR_STRING | filenumber)* + | DATAFILE CHAR_STRING + | filenumber (',' CHAR_STRING | filenumber)* | partial_database_recovery_10g ; partial_database_recovery_10g - : {self.isVersion10()}? STANDBY - ( TABLESPACE tablespace (',' tablespace)* - | DATAFILE CHAR_STRING | filenumber (',' CHAR_STRING | filenumber)* - ) - UNTIL (CONSISTENT WITH)? CONTROLFILE + : {self.isVersion10()}? STANDBY ( + TABLESPACE tablespace (',' tablespace)* + | DATAFILE CHAR_STRING + | filenumber (',' CHAR_STRING | filenumber)* + ) UNTIL (CONSISTENT WITH)? CONTROLFILE ; - managed_standby_recovery - : RECOVER (MANAGED STANDBY DATABASE - ((USING CURRENT LOGFILE + : RECOVER ( + MANAGED STANDBY DATABASE ( + ( + USING CURRENT LOGFILE | DISCONNECT (FROM SESSION)? | NODELAY | UNTIL CHANGE UNSIGNED_INTEGER | UNTIL CONSISTENT | parallel_clause - )+ - | FINISH - | CANCEL - )? - | TO LOGICAL STANDBY (db_name | KEEP IDENTITY) - ) + )+ + | FINISH + | CANCEL + )? + | TO LOGICAL STANDBY (db_name | KEEP IDENTITY) + ) ; db_name : regular_id ; + database_file_clauses : RENAME FILE filename (',' filename)* TO filename | create_datafile_clause @@ -2296,36 +2285,41 @@ database_file_clauses ; create_datafile_clause - : CREATE DATAFILE (filename | filenumber) (',' (filename | filenumber) )* - (AS (//TODO (','? file_specification)+ | - NEW) )? + : CREATE DATAFILE (filename | filenumber) (',' (filename | filenumber))* ( + AS ( + //TODO (','? file_specification)+ | + NEW + ) + )? ; alter_datafile_clause - : DATAFILE (filename|filenumber) (',' (filename|filenumber) )* - ( ONLINE + : DATAFILE (filename | filenumber) (',' (filename | filenumber))* ( + ONLINE | OFFLINE (FOR DROP)? | RESIZE size_clause | autoextend_clause | END BACKUP - ) + ) ; alter_tempfile_clause - : TEMPFILE (filename | filenumber) (',' (filename | filenumber) )* - ( RESIZE size_clause + : TEMPFILE (filename | filenumber) (',' (filename | filenumber))* ( + RESIZE size_clause | autoextend_clause | DROP (INCLUDING DATAFILES) | ONLINE | OFFLINE - ) + ) ; logfile_clauses : (ARCHIVELOG MANUAL? | NOARCHIVELOG) | NO? FORCE LOGGING | RENAME FILE filename (',' filename)* TO filename - | CLEAR UNARCHIVED? LOGFILE logfile_descriptor (',' logfile_descriptor)* (UNRECOVERABLE DATAFILE)? + | CLEAR UNARCHIVED? LOGFILE logfile_descriptor (',' logfile_descriptor)* ( + UNRECOVERABLE DATAFILE + )? | add_logfile_clauses | drop_logfile_clauses | switch_logfile_clause @@ -2333,23 +2327,24 @@ logfile_clauses ; add_logfile_clauses - : ADD STANDBY? LOGFILE - ( -//TODO (INSTANCE CHAR_STRING | THREAD UNSIGNED_INTEGER)? - (log_file_group redo_log_file_spec)+ - | MEMBER filename REUSE? (',' filename REUSE?)* TO logfile_descriptor (',' logfile_descriptor)* - ) + : ADD STANDBY? LOGFILE ( + //TODO (INSTANCE CHAR_STRING | THREAD UNSIGNED_INTEGER)? + (log_file_group redo_log_file_spec)+ + | MEMBER filename REUSE? (',' filename REUSE?)* TO logfile_descriptor ( + ',' logfile_descriptor + )* + ) ; log_file_group - :(','? (THREAD UNSIGNED_INTEGER)? GROUP UNSIGNED_INTEGER) + : (','? (THREAD UNSIGNED_INTEGER)? GROUP UNSIGNED_INTEGER) ; drop_logfile_clauses - : DROP STANDBY? - LOGFILE (logfile_descriptor (',' logfile_descriptor)* - | MEMBER filename (',' filename)* - ) + : DROP STANDBY? LOGFILE ( + logfile_descriptor (',' logfile_descriptor)* + | MEMBER filename (',' filename)* + ) ; switch_logfile_clause @@ -2357,11 +2352,7 @@ switch_logfile_clause ; supplemental_db_logging - : add_or_drop - SUPPLEMENTAL LOG (DATA - | supplemental_id_key_clause - | supplemental_plsql_clause - ) + : add_or_drop SUPPLEMENTAL LOG (DATA | supplemental_id_key_clause | supplemental_plsql_clause) ; add_or_drop @@ -2385,19 +2376,19 @@ controlfile_clauses ; trace_file_clause - : TRACE (AS filename REUSE?)? (RESETLOGS|NORESETLOGS)? + : TRACE (AS filename REUSE?)? (RESETLOGS | NORESETLOGS)? ; standby_database_clauses - : ( activate_standby_db_clause - | maximize_standby_db_clause - | register_logfile_clause - | commit_switchover_clause - | start_standby_clause - | stop_standby_clause - | convert_database_clause - ) - parallel_clause? + : ( + activate_standby_db_clause + | maximize_standby_db_clause + | register_logfile_clause + | commit_switchover_clause + | start_standby_clause + | stop_standby_clause + | convert_database_clause + ) parallel_clause? ; activate_standby_db_clause @@ -2414,24 +2405,27 @@ register_logfile_clause ; commit_switchover_clause - : (PREPARE | COMMIT) TO SWITCHOVER - ((TO (((PHYSICAL | LOGICAL)? PRIMARY | PHYSICAL? STANDBY) - ((WITH | WITHOUT)? SESSION SHUTDOWN (WAIT | NOWAIT) )? - | LOGICAL STANDBY - ) - | LOGICAL STANDBY - ) + : (PREPARE | COMMIT) TO SWITCHOVER ( + ( + TO ( + ((PHYSICAL | LOGICAL)? PRIMARY | PHYSICAL? STANDBY) ( + (WITH | WITHOUT)? SESSION SHUTDOWN (WAIT | NOWAIT) + )? + | LOGICAL STANDBY + ) + | LOGICAL STANDBY + ) | CANCEL - )? + )? ; start_standby_clause - : START LOGICAL STANDBY APPLY IMMEDIATE? NODELAY? - ( NEW PRIMARY regular_id - | INITIAL scn_value=UNSIGNED_INTEGER? + : START LOGICAL STANDBY APPLY IMMEDIATE? NODELAY? ( + NEW PRIMARY regular_id + | INITIAL scn_value = UNSIGNED_INTEGER? | SKIP_ FAILED TRANSACTION | FINISH - )? + )? ; stop_standby_clause @@ -2487,17 +2481,14 @@ filename ; alter_table - : ALTER TABLE tableview_name - ( - | alter_table_properties - | constraint_clauses - | column_clauses -//TODO | alter_table_partitioning -//TODO | alter_external_table - | move_table_clause - ) - ((enable_disable_clause | enable_or_disable (TABLE LOCK | ALL TRIGGERS) )+)? - ';' + : ALTER TABLE tableview_name ( + | alter_table_properties + | constraint_clauses + | column_clauses + //TODO | alter_table_partitioning + //TODO | alter_external_table + | move_table_clause + ) ((enable_disable_clause | enable_or_disable (TABLE LOCK | ALL TRIGGERS))+)? ';' ; alter_table_properties @@ -2510,21 +2501,21 @@ alter_table_properties ; alter_table_properties_1 - : ( physical_attributes_clause - | logging_clause - | table_compression - | supplemental_table_logging - | allocate_extent_clause - | deallocate_unused_clause - | (CACHE | NOCACHE) - | RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')' - | upgrade_table_clause - | records_per_block_clause - | parallel_clause - | row_movement_clause - | flashback_archive_clause - )+ - alter_iot_clauses? + : ( + physical_attributes_clause + | logging_clause + | table_compression + | supplemental_table_logging + | allocate_extent_clause + | deallocate_unused_clause + | (CACHE | NOCACHE) + | RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')' + | upgrade_table_clause + | records_per_block_clause + | parallel_clause + | row_movement_clause + | flashback_archive_clause + )+ alter_iot_clauses? ; alter_iot_clauses @@ -2540,37 +2531,43 @@ alter_mapping_table_clause alter_overflow_clause : add_overflow_clause - | OVERFLOW (segment_attributes_clause | allocate_extent_clause | shrink_clause | deallocate_unused_clause)+ + | OVERFLOW ( + segment_attributes_clause + | allocate_extent_clause + | shrink_clause + | deallocate_unused_clause + )+ ; add_overflow_clause - : ADD OVERFLOW segment_attributes_clause? ('(' PARTITION segment_attributes_clause? (',' PARTITION segment_attributes_clause?)* ')' )? + : ADD OVERFLOW segment_attributes_clause? ( + '(' PARTITION segment_attributes_clause? (',' PARTITION segment_attributes_clause?)* ')' + )? ; - enable_disable_clause - : (ENABLE | DISABLE) (VALIDATE | NOVALIDATE)? - (UNIQUE '(' column_name (',' column_name)* ')' - | PRIMARY KEY - | CONSTRAINT constraint_name - ) using_index_clause? exceptions_clause? - CASCADE? ((KEEP | DROP) INDEX)? + : (ENABLE | DISABLE) (VALIDATE | NOVALIDATE)? ( + UNIQUE '(' column_name (',' column_name)* ')' + | PRIMARY KEY + | CONSTRAINT constraint_name + ) using_index_clause? exceptions_clause? CASCADE? ((KEEP | DROP) INDEX)? ; using_index_clause - : USING INDEX (index_name | '(' create_index ')' | index_attributes )? + : USING INDEX (index_name | '(' create_index ')' | index_attributes)? ; index_attributes - : ( physical_attributes_clause - | logging_clause - | TABLESPACE (tablespace | DEFAULT) - | key_compression - | sort_or_nosort - | REVERSE - | visible_or_invisible - | parallel_clause - )+ + : ( + physical_attributes_clause + | logging_clause + | TABLESPACE (tablespace | DEFAULT) + | key_compression + | sort_or_nosort + | REVERSE + | visible_or_invisible + | parallel_clause + )+ ; sort_or_nosort @@ -2583,7 +2580,9 @@ exceptions_clause ; move_table_clause - : MOVE ONLINE? segment_attributes_clause? table_compression? index_org_table_clause? ((lob_storage_clause | varray_col_properties)+)? parallel_clause? + : MOVE ONLINE? segment_attributes_clause? table_compression? index_org_table_clause? ( + (lob_storage_clause | varray_col_properties)+ + )? parallel_clause? ; index_org_table_clause @@ -2632,27 +2631,32 @@ new_column_name ; add_modify_drop_column_clauses - : (add_column_clause - |modify_column_clauses - |drop_column_clause - )+ + : (add_column_clause | modify_column_clauses | drop_column_clause)+ ; drop_column_clause - : SET UNUSED (COLUMN column_name| ('(' column_name (',' column_name)* ')' )) (CASCADE CONSTRAINTS | INVALIDATE)* - | DROP (COLUMN column_name | '(' column_name (',' column_name)* ')' ) (CASCADE CONSTRAINTS | INVALIDATE)* (CHECKPOINT UNSIGNED_INTEGER)? + : SET UNUSED (COLUMN column_name | ('(' column_name (',' column_name)* ')')) ( + CASCADE CONSTRAINTS + | INVALIDATE + )* + | DROP (COLUMN column_name | '(' column_name (',' column_name)* ')') ( + CASCADE CONSTRAINTS + | INVALIDATE + )* (CHECKPOINT UNSIGNED_INTEGER)? | DROP (UNUSED COLUMNS | COLUMNS CONTINUE) (CHECKPOINT UNSIGNED_INTEGER) ; modify_column_clauses - : MODIFY ('(' modify_col_properties (',' modify_col_properties)* ')' - | modify_col_properties - | modify_col_substitutable - ) + : MODIFY ( + '(' modify_col_properties (',' modify_col_properties)* ')' + | modify_col_properties + | modify_col_substitutable + ) ; modify_col_properties - : column_name datatype? (DEFAULT expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? //TODO alter_xmlschema_clause + : column_name datatype? (DEFAULT expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? + //TODO alter_xmlschema_clause ; modify_col_substitutable @@ -2660,13 +2664,13 @@ modify_col_substitutable ; add_column_clause - : ADD ('(' (column_definition | virtual_column_definition) (',' (column_definition - | virtual_column_definition) - )* - ')' - | ( column_definition | virtual_column_definition )) - column_properties? -//TODO (','? out_of_line_part_storage ) + : ADD ( + '(' (column_definition | virtual_column_definition) ( + ',' (column_definition | virtual_column_definition) + )* ')' + | ( column_definition | virtual_column_definition) + ) column_properties? + //TODO (','? out_of_line_part_storage ) ; alter_varray_col_properties @@ -2674,15 +2678,17 @@ alter_varray_col_properties ; varray_col_properties - : VARRAY varray_item ( substitutable_column_clause? varray_storage_clause - | substitutable_column_clause - ) + : VARRAY varray_item ( + substitutable_column_clause? varray_storage_clause + | substitutable_column_clause + ) ; varray_storage_clause - : STORE AS (SECUREFILE|BASICFILE)? LOB ( lob_segname? '(' lob_storage_parameters ')' - | lob_segname - ) + : STORE AS (SECUREFILE | BASICFILE)? LOB ( + lob_segname? '(' lob_storage_parameters ')' + | lob_segname + ) ; lob_segname @@ -2694,14 +2700,23 @@ lob_item ; lob_storage_parameters - : TABLESPACE tablespace | (lob_parameters storage_clause? ) - | storage_clause + : TABLESPACE tablespace + | (lob_parameters storage_clause?) + | storage_clause ; lob_storage_clause - : LOB ( '(' lob_item (',' lob_item)* ')' STORE AS ( (SECUREFILE|BASICFILE) | '(' lob_storage_parameters ')' )+ - | '(' lob_item ')' STORE AS ( (SECUREFILE | BASICFILE) | lob_segname | '(' lob_storage_parameters ')' )+ - ) + : LOB ( + '(' lob_item (',' lob_item)* ')' STORE AS ( + (SECUREFILE | BASICFILE) + | '(' lob_storage_parameters ')' + )+ + | '(' lob_item ')' STORE AS ( + (SECUREFILE | BASICFILE) + | lob_segname + | '(' lob_storage_parameters ')' + )+ + ) ; modify_lob_storage_clause @@ -2709,34 +2724,36 @@ modify_lob_storage_clause ; modify_lob_parameters - : ( storage_clause - | (PCTVERSION | FREEPOOLS) UNSIGNED_INTEGER - | REBUILD FREEPOOLS - | lob_retention_clause - | lob_deduplicate_clause - | lob_compression_clause - | ENCRYPT encryption_spec - | DECRYPT - | CACHE - | (CACHE | NOCACHE | CACHE READS) logging_clause? - | allocate_extent_clause - | shrink_clause - | deallocate_unused_clause - )+ + : ( + storage_clause + | (PCTVERSION | FREEPOOLS) UNSIGNED_INTEGER + | REBUILD FREEPOOLS + | lob_retention_clause + | lob_deduplicate_clause + | lob_compression_clause + | ENCRYPT encryption_spec + | DECRYPT + | CACHE + | (CACHE | NOCACHE | CACHE READS) logging_clause? + | allocate_extent_clause + | shrink_clause + | deallocate_unused_clause + )+ ; lob_parameters - : ( (ENABLE | DISABLE) STORAGE IN ROW - | CHUNK UNSIGNED_INTEGER - | PCTVERSION UNSIGNED_INTEGER - | FREEPOOLS UNSIGNED_INTEGER - | lob_retention_clause - | lob_deduplicate_clause - | lob_compression_clause - | ENCRYPT encryption_spec - | DECRYPT - | (CACHE | NOCACHE | CACHE READS) logging_clause? - )+ + : ( + (ENABLE | DISABLE) STORAGE IN ROW + | CHUNK UNSIGNED_INTEGER + | PCTVERSION UNSIGNED_INTEGER + | FREEPOOLS UNSIGNED_INTEGER + | lob_retention_clause + | lob_deduplicate_clause + | lob_compression_clause + | ENCRYPT encryption_spec + | DECRYPT + | (CACHE | NOCACHE | CACHE READS) logging_clause? + )+ ; lob_deduplicate_clause @@ -2754,8 +2771,9 @@ lob_retention_clause ; encryption_spec - : (USING CHAR_STRING)? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? (NO? SALT)? + : (USING CHAR_STRING)? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? (NO? SALT)? ; + tablespace : regular_id ; @@ -2772,8 +2790,7 @@ column_properties ; period_definition - : {self.isVersion12()}? PERIOD FOR column_name - ( '(' start_time_column ',' end_time_column ')' )? + : {self.isVersion12()}? PERIOD FOR column_name ('(' start_time_column ',' end_time_column ')')? ; start_time_column @@ -2785,17 +2802,19 @@ end_time_column ; column_definition - : column_name (datatype | type_name) - SORT? (DEFAULT expression)? (ENCRYPT (USING CHAR_STRING)? (IDENTIFIED BY regular_id)? CHAR_STRING? (NO? SALT)? )? (inline_constraint* | inline_ref_constraint) + : column_name (datatype | type_name) SORT? (DEFAULT expression)? ( + ENCRYPT (USING CHAR_STRING)? (IDENTIFIED BY regular_id)? CHAR_STRING? (NO? SALT)? + )? (inline_constraint* | inline_ref_constraint) ; virtual_column_definition - : column_name datatype? autogenerated_sequence_definition? - VIRTUAL? inline_constraint* + : column_name datatype? autogenerated_sequence_definition? VIRTUAL? inline_constraint* ; autogenerated_sequence_definition - : GENERATED (ALWAYS | BY DEFAULT (ON NULL_)?)? AS IDENTITY ( '(' (sequence_start_clause | sequence_spec)* ')' )? + : GENERATED (ALWAYS | BY DEFAULT (ON NULL_)?)? AS IDENTITY ( + '(' (sequence_start_clause | sequence_spec)* ')' + )? ; out_of_line_part_storage @@ -2803,15 +2822,10 @@ out_of_line_part_storage ; nested_table_col_properties - : NESTED TABLE (nested_item | COLUMN_VALUE) substitutable_column_clause? (LOCAL | GLOBAL)? - STORE AS tableview_name ( '(' ( '(' object_properties ')' - | physical_properties - | column_properties - )+ - ')' - )? - (RETURN AS? (LOCATOR | VALUE) )? - ; + : NESTED TABLE (nested_item | COLUMN_VALUE) substitutable_column_clause? (LOCAL | GLOBAL)? STORE AS tableview_name ( + '(' ('(' object_properties ')' | physical_properties | column_properties)+ ')' + )? (RETURN AS? (LOCATOR | VALUE))? + ; nested_item : regular_id @@ -2835,13 +2849,17 @@ column_or_attribute ; object_type_col_properties - : COLUMN column=regular_id substitutable_column_clause + : COLUMN column = regular_id substitutable_column_clause ; constraint_clauses : ADD '(' (out_of_line_constraint* | out_of_line_ref_constraint) ')' - | ADD (out_of_line_constraint* | out_of_line_ref_constraint) - | MODIFY (CONSTRAINT constraint_name | PRIMARY KEY | UNIQUE '(' column_name (',' column_name)* ')') constraint_state CASCADE? + | ADD (out_of_line_constraint* | out_of_line_ref_constraint) + | MODIFY ( + CONSTRAINT constraint_name + | PRIMARY KEY + | UNIQUE '(' column_name (',' column_name)* ')' + ) constraint_state CASCADE? | RENAME CONSTRAINT old_constraint_name TO new_constraint_name | drop_constraint_clause+ ; @@ -2855,7 +2873,7 @@ new_constraint_name ; drop_constraint_clause - : DROP drop_primary_key_or_unique_or_generic_clause + : DROP drop_primary_key_or_unique_or_generic_clause ; drop_primary_key_or_unique_or_generic_clause @@ -2864,15 +2882,17 @@ drop_primary_key_or_unique_or_generic_clause ; add_constraint - : ADD (CONSTRAINT constraint_name)? add_constraint_clause (',' (CONSTRAINT constraint_name)? add_constraint_clause)+ + : ADD (CONSTRAINT constraint_name)? add_constraint_clause ( + ',' (CONSTRAINT constraint_name)? add_constraint_clause + )+ ; add_constraint_clause : primary_key_clause - | foreign_key_clause - | unique_key_clause - | check_constraint - ; + | foreign_key_clause + | unique_key_clause + | check_constraint + ; check_constraint : CHECK '(' condition ')' DISABLE? @@ -2983,7 +3003,9 @@ subtype_declaration // cursor_declaration incorportates curscursor_body and cursor_spec cursor_declaration - : CURSOR identifier ('(' parameter_spec (',' parameter_spec)* ')' )? (RETURN type_spec)? (IS select_statement)? ';' + : CURSOR identifier ('(' parameter_spec (',' parameter_spec)* ')')? (RETURN type_spec)? ( + IS select_statement + )? ';' ; parameter_spec @@ -2995,11 +3017,13 @@ exception_declaration ; pragma_declaration - : PRAGMA (SERIALLY_REUSABLE - | AUTONOMOUS_TRANSACTION - | EXCEPTION_INIT '(' exception_name ',' numeric_negative ')' - | INLINE '(' id1=identifier ',' expression ')' - | RESTRICT_REFERENCES '(' (identifier | DEFAULT) (',' identifier)+ ')') ';' + : PRAGMA ( + SERIALLY_REUSABLE + | AUTONOMOUS_TRANSACTION + | EXCEPTION_INIT '(' exception_name ',' numeric_negative ')' + | INLINE '(' id1 = identifier ',' expression ')' + | RESTRICT_REFERENCES '(' (identifier | DEFAULT) (',' identifier)+ ')' + ) ';' ; // Record Declaration Specific Clauses @@ -3027,7 +3051,7 @@ table_type_def ; table_indexed_by_part - : (idx1=INDEXED | idx2=INDEX) BY type_spec + : (idx1 = INDEXED | idx2 = INDEX) BY type_spec ; varray_type_def @@ -3041,7 +3065,7 @@ seq_of_statements ; label_declaration - : ltp1= '<' '<' label_name '>' '>' + : ltp1 = '<' '<' label_name '>' '>' ; statement @@ -3103,7 +3127,7 @@ loop_statement // Loop Specific Clause cursor_loop_param - : index_name IN REVERSE? lower_bound range_separator='..' upper_bound + : index_name IN REVERSE? lower_bound range_separator = '..' upper_bound | record_name IN (cursor_name ('(' expressions_? ')')? | '(' select_statement ')') ; @@ -3150,7 +3174,8 @@ procedure_call ; pipe_row_statement - : PIPE ROW '(' expression ')'; + : PIPE ROW '(' expression ')' + ; body : BEGIN seq_of_statements (EXCEPTION exception_handler+)? END label_name? @@ -3180,7 +3205,11 @@ sql_statement ; execute_immediate - : EXECUTE IMMEDIATE expression (into_clause using_clause? | using_clause dynamic_returning_clause? | dynamic_returning_clause)? + : EXECUTE IMMEDIATE expression ( + into_clause using_clause? + | using_clause dynamic_returning_clause? + | dynamic_returning_clause + )? ; // Execute Immediate Specific Clause @@ -3219,7 +3248,10 @@ open_statement ; fetch_statement - : FETCH cursor_name (it1=INTO variable_name (',' variable_name)* | BULK COLLECT INTO variable_name (',' variable_name)* (LIMIT (numeric | variable_name))?) + : FETCH cursor_name ( + it1 = INTO variable_name (',' variable_name)* + | BULK COLLECT INTO variable_name (',' variable_name)* (LIMIT (numeric | variable_name))? + ) ; open_for_statement @@ -3237,19 +3269,25 @@ transaction_control_statements ; set_transaction_command - : SET TRANSACTION - (READ (ONLY | WRITE) | ISOLATION LEVEL (SERIALIZABLE | READ COMMITTED) | USE ROLLBACK SEGMENT rollback_segment_name)? - (NAME quoted_string)? + : SET TRANSACTION ( + READ (ONLY | WRITE) + | ISOLATION LEVEL (SERIALIZABLE | READ COMMITTED) + | USE ROLLBACK SEGMENT rollback_segment_name + )? (NAME quoted_string)? ; set_constraint_command - : SET (CONSTRAINT | CONSTRAINTS) (ALL | constraint_name (',' constraint_name)*) (IMMEDIATE | DEFERRED) + : SET (CONSTRAINT | CONSTRAINTS) (ALL | constraint_name (',' constraint_name)*) ( + IMMEDIATE + | DEFERRED + ) ; commit_statement - : COMMIT WORK? - (COMMENT expression | FORCE (CORRUPT_XID expression | CORRUPT_XID_ALL | expression (',' expression)?))? - write_clause? + : COMMIT WORK? ( + COMMENT expression + | FORCE (CORRUPT_XID expression | CORRUPT_XID_ALL | expression (',' expression)?) + )? write_clause? ; write_clause @@ -3286,8 +3324,13 @@ seq_of_statements */ explain_statement - : EXPLAIN PLAN (SET STATEMENT_ID '=' quoted_string)? (INTO tableview_name)? - FOR (select_statement | update_statement | delete_statement | insert_statement | merge_statement) + : EXPLAIN PLAN (SET STATEMENT_ID '=' quoted_string)? (INTO tableview_name)? FOR ( + select_statement + | update_statement + | delete_statement + | insert_statement + | merge_statement + ) ; select_only_statement @@ -3305,13 +3348,13 @@ subquery_factoring_clause ; factoring_element - : query_name paren_column_list? AS '(' subquery order_by_clause? ')' - search_clause? cycle_clause? + : query_name paren_column_list? AS '(' subquery order_by_clause? ')' search_clause? cycle_clause? ; search_clause - : SEARCH (DEPTH | BREADTH) FIRST BY column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)? - (',' column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)?)* SET column_name + : SEARCH (DEPTH | BREADTH) FIRST BY column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)? ( + ',' column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)? + )* SET column_name ; cycle_clause @@ -3332,8 +3375,8 @@ subquery_operation_part ; query_block - : SELECT (DISTINCT | UNIQUE | ALL)? selected_list - into_clause? from_clause where_clause? hierarchical_query_clause? group_by_clause? model_clause? order_by_clause? fetch_clause? + : SELECT (DISTINCT | UNIQUE | ALL)? selected_list into_clause? from_clause where_clause? hierarchical_query_clause? group_by_clause? model_clause? + order_by_clause? fetch_clause? ; selected_list @@ -3368,14 +3411,16 @@ table_ref_aux ; table_ref_aux_internal - : dml_table_expression_clause (pivot_clause | unpivot_clause)? # table_ref_aux_internal_one - | '(' table_ref subquery_operation_part* ')' (pivot_clause | unpivot_clause)? # table_ref_aux_internal_two - | ONLY '(' dml_table_expression_clause ')' # table_ref_aux_internal_three + : dml_table_expression_clause (pivot_clause | unpivot_clause)? # table_ref_aux_internal_one + | '(' table_ref subquery_operation_part* ')' (pivot_clause | unpivot_clause)? # table_ref_aux_internal_two + | ONLY '(' dml_table_expression_clause ')' # table_ref_aux_internal_three ; join_clause - : query_partition_clause? (CROSS | NATURAL)? (INNER | outer_join_type)? - JOIN table_ref_aux query_partition_clause? (join_on_part | join_using_part)* + : query_partition_clause? (CROSS | NATURAL)? (INNER | outer_join_type)? JOIN table_ref_aux query_partition_clause? ( + join_on_part + | join_using_part + )* ; join_on_part @@ -3425,8 +3470,7 @@ pivot_in_clause_elements ; unpivot_clause - : UNPIVOT ((INCLUDE | EXCLUDE) NULLS)? - '(' (column_name | paren_column_list) pivot_for_clause unpivot_in_clause ')' + : UNPIVOT ((INCLUDE | EXCLUDE) NULLS)? '(' (column_name | paren_column_list) pivot_for_clause unpivot_in_clause ')' ; unpivot_in_clause @@ -3434,8 +3478,7 @@ unpivot_in_clause ; unpivot_in_elements - : (column_name | paren_column_list) - (AS (constant | '(' constant (',' constant)* ')'))? + : (column_name | paren_column_list) (AS (constant | '(' constant (',' constant)* ')'))? ; hierarchical_query_clause @@ -3506,7 +3549,7 @@ model_column_partition_part ; model_column_list - : '(' model_column (',' model_column)* ')' + : '(' model_column (',' model_column)* ')' ; model_column @@ -3574,8 +3617,10 @@ update_statement // Update Specific Clauses update_set_clause - : SET - (column_based_update_set_clause (',' column_based_update_set_clause)* | VALUE '(' identifier ')' '=' expression) + : SET ( + column_based_update_set_clause (',' column_based_update_set_clause)* + | VALUE '(' identifier ')' '=' expression + ) ; column_based_update_set_clause @@ -3626,9 +3671,10 @@ values_clause ; merge_statement - : MERGE INTO tableview_name table_alias? USING selected_tableview ON '(' condition ')' - (merge_update_clause merge_insert_clause? | merge_insert_clause merge_update_clause?)? - error_logging_clause? + : MERGE INTO tableview_name table_alias? USING selected_tableview ON '(' condition ')' ( + merge_update_clause merge_insert_clause? + | merge_insert_clause merge_update_clause? + )? error_logging_clause? ; // Merge Specific Clauses @@ -3646,8 +3692,7 @@ merge_update_delete_part ; merge_insert_clause - : WHEN NOT MATCHED THEN INSERT paren_column_list? - values_clause where_clause? + : WHEN NOT MATCHED THEN INSERT paren_column_list? values_clause where_clause? ; selected_tableview @@ -3750,15 +3795,20 @@ unary_logical_expression : NOT? multiset_expression (IS NOT? logical_operation)* ; -logical_operation: - (NULL_ - | NAN | PRESENT - | INFINITE | A_LETTER SET | EMPTY - | OF TYPE? '(' ONLY? type_spec (',' type_spec)* ')') +logical_operation + : ( + NULL_ + | NAN + | PRESENT + | INFINITE + | A_LETTER SET + | EMPTY + | OF TYPE? '(' ONLY? type_spec (',' type_spec)* ')' + ) ; multiset_expression - : relational_expression (multiset_type=(MEMBER | SUBMULTISET) OF? concatenation)? + : relational_expression (multiset_type = (MEMBER | SUBMULTISET) OF? concatenation)? ; relational_expression @@ -3767,10 +3817,13 @@ relational_expression ; compound_expression - : concatenation - (NOT? ( IN in_elements + : concatenation ( + NOT? ( + IN in_elements | BETWEEN between_elements - | like_type=(LIKE | LIKEC | LIKE2 | LIKE4) concatenation (ESCAPE concatenation)?))? + | like_type = (LIKE | LIKEC | LIKE2 | LIKE4) concatenation (ESCAPE concatenation)? + ) + )? ; relational_operator @@ -3792,11 +3845,11 @@ between_elements ; concatenation - : model_expression - (AT (LOCAL | TIME ZONE concatenation) | interval_expression)? - (ON OVERFLOW (TRUNCATE | ERROR))? - | concatenation op=(ASTERISK | SOLIDUS) concatenation - | concatenation op=(PLUS_SIGN | MINUS_SIGN) concatenation + : model_expression (AT (LOCAL | TIME ZONE concatenation) | interval_expression)? ( + ON OVERFLOW (TRUNCATE | ERROR) + )? + | concatenation op = (ASTERISK | SOLIDUS) concatenation + | concatenation op = (PLUS_SIGN | MINUS_SIGN) concatenation | concatenation BAR BAR concatenation ; @@ -3816,15 +3869,17 @@ model_expression_element ; single_column_for_loop - : FOR column_name - ( IN '(' expressions_? ')' - | (LIKE expression)? FROM fromExpr=expression TO toExpr=expression - action_type=(INCREMENT | DECREMENT) action_expr=expression) + : FOR column_name ( + IN '(' expressions_? ')' + | (LIKE expression)? FROM fromExpr = expression TO toExpr = expression action_type = ( + INCREMENT + | DECREMENT + ) action_expr = expression + ) ; multi_column_for_loop - : FOR paren_column_list - IN '(' (subquery | '(' expressions_? ')') ')' + : FOR paren_column_list IN '(' (subquery | '(' expressions_? ')') ')' ; unary_expression @@ -3832,12 +3887,12 @@ unary_expression | PRIOR unary_expression | CONNECT_BY_ROOT unary_expression | /*TODO {input.LT(1).getText().equalsIgnoreCase("new") && !input.LT(2).getText().equals(".")}?*/ NEW unary_expression - | DISTINCT unary_expression - | ALL unary_expression - | /*TODO{(input.LA(1) == CASE || input.LA(2) == CASE)}?*/ case_statement/*[false]*/ - | quantified_expression - | standard_function - | atom + | DISTINCT unary_expression + | ALL unary_expression + | /*TODO{(input.LA(1) == CASE || input.LA(2) == CASE)}?*/ case_statement /*[false]*/ + | quantified_expression + | standard_function + | atom ; case_statement /*TODO [boolean isStatementParameter] @@ -3852,7 +3907,7 @@ TODO scope { // CASE simple_case_statement - : label_name? ck1=CASE expression simple_case_when_part+ case_else_part? END CASE? label_name? + : label_name? ck1 = CASE expression simple_case_when_part+ case_else_part? END CASE? label_name? ; simple_case_when_part @@ -3860,7 +3915,7 @@ simple_case_when_part ; searched_case_statement - : label_name? ck1=CASE searched_case_when_part+ case_else_part? END CASE? label_name? + : label_name? ck1 = CASE searched_case_when_part+ case_else_part? END CASE? label_name? ; searched_case_when_part @@ -3886,9 +3941,10 @@ quantified_expression string_function : SUBSTR '(' expression ',' expression (',' expression)? ')' - | TO_CHAR '(' (table_element | standard_function | expression) - (',' quoted_string)? (',' quoted_string)? ')' - | DECODE '(' expressions_ ')' + | TO_CHAR '(' (table_element | standard_function | expression) (',' quoted_string)? ( + ',' quoted_string + )? ')' + | DECODE '(' expressions_ ')' | CHR '(' concatenation USING NCHAR_CS ')' | NVL '(' expression ',' expression ')' | TRIM '(' ((LEADING | TRAILING | BOTH)? quoted_string? FROM)? concatenation ')' @@ -3913,51 +3969,51 @@ numeric_function_wrapper ; numeric_function - : SUM '(' (DISTINCT | ALL)? expression ')' - | COUNT '(' ( ASTERISK | ((DISTINCT | UNIQUE | ALL)? concatenation)? ) ')' over_clause? - | ROUND '(' expression (',' UNSIGNED_INTEGER)? ')' - | AVG '(' (DISTINCT | ALL)? expression ')' - | MAX '(' (DISTINCT | ALL)? expression ')' - | LEAST '(' expressions_ ')' - | GREATEST '(' expressions_ ')' - ; + : SUM '(' (DISTINCT | ALL)? expression ')' + | COUNT '(' (ASTERISK | ((DISTINCT | UNIQUE | ALL)? concatenation)?) ')' over_clause? + | ROUND '(' expression (',' UNSIGNED_INTEGER)? ')' + | AVG '(' (DISTINCT | ALL)? expression ')' + | MAX '(' (DISTINCT | ALL)? expression ')' + | LEAST '(' expressions_ ')' + | GREATEST '(' expressions_ ')' + ; other_function : over_clause_keyword function_argument_analytic over_clause? | /*TODO stantard_function_enabling_using*/ regular_id function_argument_modeling using_clause? - | COUNT '(' ( ASTERISK | (DISTINCT | UNIQUE | ALL)? concatenation) ')' over_clause? + | COUNT '(' (ASTERISK | (DISTINCT | UNIQUE | ALL)? concatenation) ')' over_clause? | (CAST | XMLCAST) '(' (MULTISET '(' subquery ')' | concatenation) AS type_spec ')' | COALESCE '(' table_element (',' (numeric | quoted_string))? ')' | COLLECT '(' (DISTINCT | UNIQUE)? concatenation collect_order_by_part? ')' | within_or_over_clause_keyword function_argument within_or_over_part+ - | cursor_name ( PERCENT_ISOPEN | PERCENT_FOUND | PERCENT_NOTFOUND | PERCENT_ROWCOUNT ) + | cursor_name (PERCENT_ISOPEN | PERCENT_FOUND | PERCENT_NOTFOUND | PERCENT_ROWCOUNT) | DECOMPOSE '(' concatenation (CANONICAL | COMPATIBILITY)? ')' | EXTRACT '(' regular_id FROM concatenation ')' | (FIRST_VALUE | LAST_VALUE) function_argument_analytic respect_or_ignore_nulls? over_clause - | standard_prediction_function_keyword - '(' expressions_ cost_matrix_clause? using_clause? ')' + | standard_prediction_function_keyword '(' expressions_ cost_matrix_clause? using_clause? ')' | TRANSLATE '(' expression (USING (CHAR_CS | NCHAR_CS))? (',' expression)* ')' | TREAT '(' expression AS REF? type_spec ')' | TRIM '(' ((LEADING | TRAILING | BOTH)? quoted_string? FROM)? concatenation ')' | XMLAGG '(' expression order_by_clause? ')' ('.' general_element_part)? - | (XMLCOLATTVAL | XMLFOREST) - '(' xml_multiuse_expression_element (',' xml_multiuse_expression_element)* ')' ('.' general_element_part)? - | XMLELEMENT - '(' (ENTITYESCAPING | NOENTITYESCAPING)? (NAME | EVALNAME)? expression - (/*TODO{input.LT(2).getText().equalsIgnoreCase("xmlattributes")}?*/ ',' xml_attributes_clause)? - (',' expression column_alias?)* ')' ('.' general_element_part)? + | (XMLCOLATTVAL | XMLFOREST) '(' xml_multiuse_expression_element ( + ',' xml_multiuse_expression_element + )* ')' ('.' general_element_part)? + | XMLELEMENT '(' (ENTITYESCAPING | NOENTITYESCAPING)? (NAME | EVALNAME)? expression ( + /*TODO{input.LT(2).getText().equalsIgnoreCase("xmlattributes")}?*/ ',' xml_attributes_clause + )? (',' expression column_alias?)* ')' ('.' general_element_part)? | XMLEXISTS '(' expression xml_passing_clause? ')' | XMLPARSE '(' (DOCUMENT | CONTENT) concatenation WELLFORMED? ')' ('.' general_element_part)? - | XMLPI - '(' (NAME identifier | EVALNAME concatenation) (',' concatenation)? ')' ('.' general_element_part)? - | XMLQUERY - '(' concatenation xml_passing_clause? RETURNING CONTENT (NULL_ ON EMPTY)? ')' ('.' general_element_part)? - | XMLROOT - '(' concatenation (',' xmlroot_param_version_part)? (',' xmlroot_param_standalone_part)? ')' ('.' general_element_part)? - | XMLSERIALIZE - '(' (DOCUMENT | CONTENT) concatenation (AS type_spec)? - xmlserialize_param_enconding_part? xmlserialize_param_version_part? xmlserialize_param_ident_part? ((HIDE | SHOW) DEFAULTS)? ')' - ('.' general_element_part)? + | XMLPI '(' (NAME identifier | EVALNAME concatenation) (',' concatenation)? ')' ( + '.' general_element_part + )? + | XMLQUERY '(' concatenation xml_passing_clause? RETURNING CONTENT (NULL_ ON EMPTY)? ')' ( + '.' general_element_part + )? + | XMLROOT '(' concatenation (',' xmlroot_param_version_part)? ( + ',' xmlroot_param_standalone_part + )? ')' ('.' general_element_part)? + | XMLSERIALIZE '(' (DOCUMENT | CONTENT) concatenation (AS type_spec)? xmlserialize_param_enconding_part? xmlserialize_param_version_part? + xmlserialize_param_ident_part? ((HIDE | SHOW) DEFAULTS)? ')' ('.' general_element_part)? | xmltable ; @@ -4004,8 +4060,7 @@ over_clause ; windowing_clause - : windowing_type - (BETWEEN windowing_elements AND windowing_elements | windowing_elements) + : windowing_type (BETWEEN windowing_elements AND windowing_elements | windowing_elements) ; windowing_type @@ -4037,7 +4092,10 @@ within_or_over_part ; cost_matrix_clause - : COST (MODEL AUTO? | '(' cost_class_name (',' cost_class_name)* ')' VALUES '(' expressions_? ')') + : COST ( + MODEL AUTO? + | '(' cost_class_name (',' cost_class_name)* ')' VALUES '(' expressions_? ')' + ) ; xml_passing_clause @@ -4045,19 +4103,17 @@ xml_passing_clause ; xml_attributes_clause - : XMLATTRIBUTES - '(' (ENTITYESCAPING | NOENTITYESCAPING)? (SCHEMACHECK | NOSCHEMACHECK)? - xml_multiuse_expression_element (',' xml_multiuse_expression_element)* ')' + : XMLATTRIBUTES '(' (ENTITYESCAPING | NOENTITYESCAPING)? (SCHEMACHECK | NOSCHEMACHECK)? xml_multiuse_expression_element ( + ',' xml_multiuse_expression_element + )* ')' ; xml_namespaces_clause - : XMLNAMESPACES - '(' (concatenation column_alias)? (',' concatenation column_alias)* xml_general_default_part? ')' + : XMLNAMESPACES '(' (concatenation column_alias)? (',' concatenation column_alias)* xml_general_default_part? ')' ; xml_table_column - : xml_column_name - (FOR ORDINALITY | type_spec (PATH concatenation)? xml_general_default_part?) + : xml_column_name (FOR ORDINALITY | type_spec (PATH concatenation)? xml_general_default_part?) ; xml_general_default_part @@ -4102,13 +4158,14 @@ sql_plus_command ; whenever_command - : WHENEVER (SQLERROR | OSERROR) - ( EXIT (SUCCESS | FAILURE | WARNING | variable_name) (COMMIT | ROLLBACK) - | CONTINUE (COMMIT | ROLLBACK | NONE)) + : WHENEVER (SQLERROR | OSERROR) ( + EXIT (SUCCESS | FAILURE | WARNING | variable_name) (COMMIT | ROLLBACK) + | CONTINUE (COMMIT | ROLLBACK | NONE) + ) ; set_command - : SET regular_id (CHAR_STRING | ON | OFF | /*EXACT_NUM_LIT*/numeric | regular_id) + : SET regular_id (CHAR_STRING | ON | OFF | /*EXACT_NUM_LIT*/ numeric | regular_id) ; // Common @@ -4275,13 +4332,17 @@ column_name ; tableview_name - : identifier ('.' id_expression)? - (AT_SIGN link_name (PERIOD link_name)? | /*TODO{!(input.LA(2) == BY)}?*/ partition_extension_clause)? + : identifier ('.' id_expression)? ( + AT_SIGN link_name (PERIOD link_name)? + | /*TODO{!(input.LA(2) == BY)}?*/ partition_extension_clause + )? | xmltable outer_join_sign? ; xmltable - : XMLTABLE '(' (xml_namespaces_clause ',')? concatenation xml_passing_clause? (COLUMNS xml_table_column (',' xml_table_column)*)? ')' ('.' general_element_part)? + : XMLTABLE '(' (xml_namespaces_clause ',')? concatenation xml_passing_clause? ( + COLUMNS xml_table_column (',' xml_table_column)* + )? ')' ('.' general_element_part)? ; char_set_name @@ -4341,9 +4402,11 @@ function_argument_analytic ; function_argument_modeling - : '(' column_name (',' (numeric | NULL_) (',' (numeric | NULL_))?)? - USING (tableview_name '.' ASTERISK | ASTERISK | expression column_alias? (',' expression column_alias?)*) - ')' keep_clause? + : '(' column_name (',' (numeric | NULL_) (',' (numeric | NULL_))?)? USING ( + tableview_name '.' ASTERISK + | ASTERISK + | expression column_alias? (',' expression column_alias?)* + ) ')' keep_clause? ; respect_or_ignore_nulls @@ -4427,9 +4490,8 @@ native_datatype_element bind_variable : (BINDVAR | ':' UNSIGNED_INTEGER) - // Pro*C/C++ indicator variables - (INDICATOR? (BINDVAR | ':' UNSIGNED_INTEGER))? - ('.' general_element_part)* + // Pro*C/C++ indicator variables + (INDICATOR? (BINDVAR | ':' UNSIGNED_INTEGER))? ('.' general_element_part)* ; general_element @@ -4521,7 +4583,7 @@ system_privilege | SET CONTAINER | CREATE ANY? PROCEDURE | (ALTER | DROP | EXECUTE) ANY PROCEDURE - | (CREATE | ALTER | DROP ) PROFILE + | (CREATE | ALTER | DROP) PROFILE | CREATE ROLE | (ALTER | DROP | GRANT) ANY ROLE | (CREATE | ALTER | DROP) ROLLBACK SEGMENT @@ -4571,10 +4633,16 @@ system_privilege constant : TIMESTAMP (quoted_string | bind_variable) (AT TIME ZONE quoted_string)? - | INTERVAL (quoted_string | bind_variable | general_element_part) - (YEAR | MONTH | DAY | HOUR | MINUTE | SECOND) - ('(' (UNSIGNED_INTEGER | bind_variable) (',' (UNSIGNED_INTEGER | bind_variable) )? ')')? - (TO ( DAY | HOUR | MINUTE | SECOND ('(' (UNSIGNED_INTEGER | bind_variable) ')')?))? + | INTERVAL (quoted_string | bind_variable | general_element_part) ( + YEAR + | MONTH + | DAY + | HOUR + | MINUTE + | SECOND + ) ('(' (UNSIGNED_INTEGER | bind_variable) (',' (UNSIGNED_INTEGER | bind_variable))? ')')? ( + TO (DAY | HOUR | MINUTE | SECOND ('(' (UNSIGNED_INTEGER | bind_variable) ')')?) + )? | numeric | DATE quoted_string | quoted_string @@ -6769,4 +6837,4 @@ numeric_function_name | NVL | ROUND | SUM - ; + ; \ No newline at end of file diff --git a/sql/plsql/PlSqlLexer.g4 b/sql/plsql/PlSqlLexer.g4 index 8b70741e02..9ee557c1ac 100644 --- a/sql/plsql/PlSqlLexer.g4 +++ b/sql/plsql/PlSqlLexer.g4 @@ -18,10 +18,14 @@ * limitations under the License. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PlSqlLexer; options { - superClass=PlSqlLexerBase; + superClass = PlSqlLexerBase; caseInsensitive = true; } @@ -29,2326 +33,2326 @@ options { #include } -ABORT: 'ABORT'; -ABS: 'ABS'; -ABSENT: 'ABSENT'; -ACCESS: 'ACCESS'; -ACCESSED: 'ACCESSED'; -ACCOUNT: 'ACCOUNT'; -ACL: 'ACL'; -ACOS: 'ACOS'; -ACROSS: 'ACROSS'; -ACTION: 'ACTION'; -ACTIONS: 'ACTIONS'; -ACTIVATE: 'ACTIVATE'; -ACTIVE: 'ACTIVE'; -ACTIVE_COMPONENT: 'ACTIVE_COMPONENT'; -ACTIVE_DATA: 'ACTIVE_DATA'; -ACTIVE_FUNCTION: 'ACTIVE_FUNCTION'; -ACTIVE_TAG: 'ACTIVE_TAG'; -ACTIVITY: 'ACTIVITY'; -ADAPTIVE_PLAN: 'ADAPTIVE_PLAN'; -ADD: 'ADD'; -ADD_COLUMN: 'ADD_COLUMN'; -ADD_GROUP: 'ADD_GROUP'; -ADD_MONTHS: 'ADD_MONTHS'; -ADJ_DATE: 'ADJ_DATE'; -ADMIN: 'ADMIN'; -ADMINISTER: 'ADMINISTER'; -ADMINISTRATOR: 'ADMINISTRATOR'; -ADVANCED: 'ADVANCED'; -ADVISE: 'ADVISE'; -ADVISOR: 'ADVISOR'; -AFD_DISKSTRING: 'AFD_DISKSTRING'; -AFTER: 'AFTER'; -AGENT: 'AGENT'; -AGGREGATE: 'AGGREGATE'; -A_LETTER: 'A'; -ALIAS: 'ALIAS'; -ALL: 'ALL'; -ALLOCATE: 'ALLOCATE'; -ALLOW: 'ALLOW'; -ALL_ROWS: 'ALL_ROWS'; -ALTER: 'ALTER'; -ALTERNATE: 'ALTERNATE'; -ALWAYS: 'ALWAYS'; -ANALYTIC: 'ANALYTIC'; -ANALYZE: 'ANALYZE'; -ANCESTOR: 'ANCESTOR'; -ANCILLARY: 'ANCILLARY'; -AND: 'AND'; -AND_EQUAL: 'AND_EQUAL'; -ANOMALY: 'ANOMALY'; -ANSI_REARCH: 'ANSI_REARCH'; -ANTIJOIN: 'ANTIJOIN'; -ANY: 'ANY'; -ANYSCHEMA: 'ANYSCHEMA'; -APPEND: 'APPEND'; -APPENDCHILDXML: 'APPENDCHILDXML'; -APPEND_VALUES: 'APPEND_VALUES'; -APPLICATION: 'APPLICATION'; -APPLY: 'APPLY'; -APPROX_COUNT_DISTINCT: 'APPROX_COUNT_DISTINCT'; -ARCHIVAL: 'ARCHIVAL'; -ARCHIVE: 'ARCHIVE'; -ARCHIVED: 'ARCHIVED'; -ARCHIVELOG: 'ARCHIVELOG'; -ARRAY: 'ARRAY'; -AS: 'AS'; -ASC: 'ASC'; -ASCII: 'ASCII'; -ASCIISTR: 'ASCIISTR'; -ASIN: 'ASIN'; -ASIS: 'ASIS'; -ASSEMBLY: 'ASSEMBLY'; -ASSIGN: 'ASSIGN'; -ASSOCIATE: 'ASSOCIATE'; -ASYNC: 'ASYNC'; -ASYNCHRONOUS: 'ASYNCHRONOUS'; -ATAN2: 'ATAN2'; -ATAN: 'ATAN'; -AT: 'AT'; -ATTRIBUTE: 'ATTRIBUTE'; -ATTRIBUTES: 'ATTRIBUTES'; -AUDIT: 'AUDIT'; -AUTHENTICATED: 'AUTHENTICATED'; -AUTHENTICATION: 'AUTHENTICATION'; -AUTHID: 'AUTHID'; -AUTHORIZATION: 'AUTHORIZATION'; -AUTOALLOCATE: 'AUTOALLOCATE'; -AUTO: 'AUTO'; -AUTOBACKUP: 'AUTOBACKUP'; -AUTOEXTEND: 'AUTOEXTEND'; -AUTO_LOGIN: 'AUTO_LOGIN'; -AUTOMATIC: 'AUTOMATIC'; -AUTONOMOUS_TRANSACTION: 'AUTONOMOUS_TRANSACTION'; -AUTO_REOPTIMIZE: 'AUTO_REOPTIMIZE'; -AVAILABILITY: 'AVAILABILITY'; -AVRO: 'AVRO'; -BACKGROUND: 'BACKGROUND'; -BACKINGFILE: 'BACKINGFILE'; -BACKUP: 'BACKUP'; -BACKUPS: 'BACKUPS'; -BACKUPSET: 'BACKUPSET'; -BASIC: 'BASIC'; -BASICFILE: 'BASICFILE'; -BATCH: 'BATCH'; -BATCHSIZE: 'BATCHSIZE'; -BATCH_TABLE_ACCESS_BY_ROWID: 'BATCH_TABLE_ACCESS_BY_ROWID'; -BECOME: 'BECOME'; -BEFORE: 'BEFORE'; -BEGIN: 'BEGIN'; -BEGINNING: 'BEGINNING'; -BEGIN_OUTLINE_DATA: 'BEGIN_OUTLINE_DATA'; -BEHALF: 'BEHALF'; -BEQUEATH: 'BEQUEATH'; -BETWEEN: 'BETWEEN'; -BFILE: 'BFILE'; -BFILENAME: 'BFILENAME'; -BIGFILE: 'BIGFILE'; -BINARY: 'BINARY'; -BINARY_DOUBLE: 'BINARY_DOUBLE'; -BINARY_DOUBLE_INFINITY: 'BINARY_DOUBLE_INFINITY'; -BINARY_DOUBLE_NAN: 'BINARY_DOUBLE_NAN'; -BINARY_FLOAT: 'BINARY_FLOAT'; -BINARY_FLOAT_INFINITY: 'BINARY_FLOAT_INFINITY'; -BINARY_FLOAT_NAN: 'BINARY_FLOAT_NAN'; -BINARY_INTEGER: 'BINARY_INTEGER'; -BIND_AWARE: 'BIND_AWARE'; -BINDING: 'BINDING'; -BIN_TO_NUM: 'BIN_TO_NUM'; -BITAND: 'BITAND'; -BITMAP_AND: 'BITMAP_AND'; -BITMAP: 'BITMAP'; -BITMAPS: 'BITMAPS'; -BITMAP_TREE: 'BITMAP_TREE'; -BITS: 'BITS'; -BLOB: 'BLOB'; -BLOCK: 'BLOCK'; -BLOCK_RANGE: 'BLOCK_RANGE'; -BLOCKS: 'BLOCKS'; -BLOCKSIZE: 'BLOCKSIZE'; -BODY: 'BODY'; -BOOLEAN: 'BOOLEAN'; -BOTH: 'BOTH'; -BOUND: 'BOUND'; -BRANCH: 'BRANCH'; -BREADTH: 'BREADTH'; -BROADCAST: 'BROADCAST'; -BSON: 'BSON'; -BUFFER: 'BUFFER'; -BUFFER_CACHE: 'BUFFER_CACHE'; -BUFFER_POOL: 'BUFFER_POOL'; -BUILD: 'BUILD'; -BULK: 'BULK'; -BY: 'BY'; -BYPASS_RECURSIVE_CHECK: 'BYPASS_RECURSIVE_CHECK'; -BYPASS_UJVC: 'BYPASS_UJVC'; -BYTE: 'BYTE'; -CACHE: 'CACHE'; -CACHE_CB: 'CACHE_CB'; -CACHE_INSTANCES: 'CACHE_INSTANCES'; -CACHE_TEMP_TABLE: 'CACHE_TEMP_TABLE'; -CACHING: 'CACHING'; -CALCULATED: 'CALCULATED'; -CALLBACK: 'CALLBACK'; -CALL: 'CALL'; -CANCEL: 'CANCEL'; -CANONICAL: 'CANONICAL'; -CAPACITY: 'CAPACITY'; -CAPTION: 'CAPTION'; -CARDINALITY: 'CARDINALITY'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CAST: 'CAST'; -CASESENSITIVE: 'CASE-SENSITIVE'; -CATEGORY: 'CATEGORY'; -CDBDEFAULT: 'CDB$DEFAULT'; -CEIL: 'CEIL'; -CELL_FLASH_CACHE: 'CELL_FLASH_CACHE'; -CERTIFICATE: 'CERTIFICATE'; -CFILE: 'CFILE'; -CHAINED: 'CHAINED'; -CHANGE: 'CHANGE'; -CHANGETRACKING: 'CHANGETRACKING'; -CHANGE_DUPKEY_ERROR_INDEX: 'CHANGE_DUPKEY_ERROR_INDEX'; -CHARACTER: 'CHARACTER'; -CHAR: 'CHAR'; -CHAR_CS: 'CHAR_CS'; -CHARTOROWID: 'CHARTOROWID'; -CHECK_ACL_REWRITE: 'CHECK_ACL_REWRITE'; -CHECK: 'CHECK'; -CHECKPOINT: 'CHECKPOINT'; -CHILD: 'CHILD'; -CHOOSE: 'CHOOSE'; -CHR: 'CHR'; -CHUNK: 'CHUNK'; -CLASS: 'CLASS'; -CLASSIFICATION: 'CLASSIFICATION'; -CLASSIFIER: 'CLASSIFIER'; -CLAUSE: 'CLAUSE'; -CLEAN: 'CLEAN'; -CLEANUP: 'CLEANUP'; -CLEAR: 'CLEAR'; -C_LETTER: 'C'; -CLIENT: 'CLIENT'; -CLOB: 'CLOB'; -CLONE: 'CLONE'; -CLOSE_CACHED_OPEN_CURSORS: 'CLOSE_CACHED_OPEN_CURSORS'; -CLOSE: 'CLOSE'; -CLUSTER_BY_ROWID: 'CLUSTER_BY_ROWID'; -CLUSTER: 'CLUSTER'; -CLUSTER_DETAILS: 'CLUSTER_DETAILS'; -CLUSTER_DISTANCE: 'CLUSTER_DISTANCE'; -CLUSTER_ID: 'CLUSTER_ID'; -CLUSTERING: 'CLUSTERING'; -CLUSTERING_FACTOR: 'CLUSTERING_FACTOR'; -CLUSTER_PROBABILITY: 'CLUSTER_PROBABILITY'; -CLUSTER_SET: 'CLUSTER_SET'; -COALESCE: 'COALESCE'; -COALESCE_SQ: 'COALESCE_SQ'; -COARSE: 'COARSE'; -CO_AUTH_IND: 'CO_AUTH_IND'; -COLD: 'COLD'; -COLLECT: 'COLLECT'; -COLUMNAR: 'COLUMNAR'; -COLUMN_AUTH_INDICATOR: 'COLUMN_AUTH_INDICATOR'; -COLUMN: 'COLUMN'; -COLUMNS: 'COLUMNS'; -COLUMN_STATS: 'COLUMN_STATS'; -COLUMN_VALUE: 'COLUMN_VALUE'; -COMMENT: 'COMMENT'; -COMMIT: 'COMMIT'; -COMMITTED: 'COMMITTED'; -COMMON: 'COMMON'; -COMMON_DATA: 'COMMON_DATA'; -COMPACT: 'COMPACT'; -COMPATIBILITY: 'COMPATIBILITY'; -COMPILE: 'COMPILE'; -COMPLETE: 'COMPLETE'; -COMPLIANCE: 'COMPLIANCE'; -COMPONENT: 'COMPONENT'; -COMPONENTS: 'COMPONENTS'; -COMPOSE: 'COMPOSE'; -COMPOSITE: 'COMPOSITE'; -COMPOSITE_LIMIT: 'COMPOSITE_LIMIT'; -COMPOUND: 'COMPOUND'; -COMPRESS: 'COMPRESS'; -COMPUTE: 'COMPUTE'; -CONCAT: 'CONCAT'; -CON_DBID_TO_ID: 'CON_DBID_TO_ID'; -CONDITIONAL: 'CONDITIONAL'; -CONDITION: 'CONDITION'; -CONFIRM: 'CONFIRM'; -CONFORMING: 'CONFORMING'; -CON_GUID_TO_ID: 'CON_GUID_TO_ID'; -CON_ID: 'CON_ID'; -CON_NAME_TO_ID: 'CON_NAME_TO_ID'; -CONNECT_BY_CB_WHR_ONLY: 'CONNECT_BY_CB_WHR_ONLY'; -CONNECT_BY_COMBINE_SW: 'CONNECT_BY_COMBINE_SW'; -CONNECT_BY_COST_BASED: 'CONNECT_BY_COST_BASED'; -CONNECT_BY_ELIM_DUPS: 'CONNECT_BY_ELIM_DUPS'; -CONNECT_BY_FILTERING: 'CONNECT_BY_FILTERING'; -CONNECT_BY_ISCYCLE: 'CONNECT_BY_ISCYCLE'; -CONNECT_BY_ISLEAF: 'CONNECT_BY_ISLEAF'; -CONNECT_BY_ROOT: 'CONNECT_BY_ROOT'; -CONNECT: 'CONNECT'; -CONNECT_TIME: 'CONNECT_TIME'; -CONSIDER: 'CONSIDER'; -CONSISTENT: 'CONSISTENT'; -CONSTANT: 'CONSTANT'; -CONST: 'CONST'; -CONSTRAINT: 'CONSTRAINT'; -CONSTRAINTS: 'CONSTRAINTS'; -CONSTRUCTOR: 'CONSTRUCTOR'; -CONTAINER: 'CONTAINER'; -CONTAINERS: 'CONTAINERS'; -CONTAINERS_DEFAULT: 'CONTAINERS_DEFAULT'; -CONTAINER_DATA: 'CONTAINER_DATA'; -CONTAINER_MAP: 'CONTAINER_MAP'; -CONTENT: 'CONTENT'; -CONTENTS: 'CONTENTS'; -CONTEXT: 'CONTEXT'; -CONTINUE: 'CONTINUE'; -CONTROLFILE: 'CONTROLFILE'; -CON_UID_TO_ID: 'CON_UID_TO_ID'; -CONVERT: 'CONVERT'; -CONVERSION: 'CONVERSION'; -COOKIE: 'COOKIE'; -COPY: 'COPY'; -CORR_K: 'CORR_K'; -CORR_S: 'CORR_S'; -CORRUPTION: 'CORRUPTION'; -CORRUPT_XID_ALL: 'CORRUPT_XID_ALL'; -CORRUPT_XID: 'CORRUPT_XID'; -COS: 'COS'; -COSH: 'COSH'; -COST: 'COST'; -COST_XML_QUERY_REWRITE: 'COST_XML_QUERY_REWRITE'; -COUNT: 'COUNT'; -COVAR_POP: 'COVAR_POP'; -COVAR_SAMP: 'COVAR_SAMP'; -CPU_COSTING: 'CPU_COSTING'; -CPU_PER_CALL: 'CPU_PER_CALL'; -CPU_PER_SESSION: 'CPU_PER_SESSION'; -CRASH: 'CRASH'; -CREATE: 'CREATE'; -CREATE_FILE_DEST: 'CREATE_FILE_DEST'; -CREATE_STORED_OUTLINES: 'CREATE_STORED_OUTLINES'; -CREATION: 'CREATION'; -CREDENTIAL: 'CREDENTIAL'; -CRITICAL: 'CRITICAL'; -CROSS: 'CROSS'; -CROSSEDITION: 'CROSSEDITION'; -CSCONVERT: 'CSCONVERT'; -CUBE_AJ: 'CUBE_AJ'; -CUBE: 'CUBE'; -CUBE_GB: 'CUBE_GB'; -CUBE_SJ: 'CUBE_SJ'; -CUME_DISTM: 'CUME_DISTM'; -CURRENT: 'CURRENT'; -CURRENT_DATE: 'CURRENT_DATE'; -CURRENT_SCHEMA: 'CURRENT_SCHEMA'; -CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -CURRENT_USER: 'CURRENT_USER'; -CURRENTV: 'CURRENTV'; -CURSOR: 'CURSOR'; -CURSOR_SHARING_EXACT: 'CURSOR_SHARING_EXACT'; -CURSOR_SPECIFIC_SEGMENT: 'CURSOR_SPECIFIC_SEGMENT'; -CUSTOMDATUM: 'CUSTOMDATUM'; -CV: 'CV'; -CYCLE: 'CYCLE'; -DANGLING: 'DANGLING'; -DATABASE: 'DATABASE'; -DATA: 'DATA'; -DATAFILE: 'DATAFILE'; -DATAFILES: 'DATAFILES'; -DATAGUARDCONFIG: 'DATAGUARDCONFIG'; -DATAMOVEMENT: 'DATAMOVEMENT'; -DATAOBJNO: 'DATAOBJNO'; -DATAOBJ_TO_MAT_PARTITION: 'DATAOBJ_TO_MAT_PARTITION'; -DATAOBJ_TO_PARTITION: 'DATAOBJ_TO_PARTITION'; -DATAPUMP: 'DATAPUMP'; -DATA_SECURITY_REWRITE_LIMIT: 'DATA_SECURITY_REWRITE_LIMIT'; -DATE: 'DATE'; -DATE_MODE: 'DATE_MODE'; -DAY: 'DAY'; -DAYS: 'DAYS'; -DBA: 'DBA'; -DBA_RECYCLEBIN: 'DBA_RECYCLEBIN'; -DBMS_STATS: 'DBMS_STATS'; -DB_ROLE_CHANGE: 'DB_ROLE_CHANGE'; -DBTIMEZONE: 'DBTIMEZONE'; -DB_UNIQUE_NAME: 'DB_UNIQUE_NAME'; -DB_VERSION: 'DB_VERSION'; -DDL: 'DDL'; -DEALLOCATE: 'DEALLOCATE'; -DEBUG: 'DEBUG'; -DEBUGGER: 'DEBUGGER'; -DEC: 'DEC'; -DECIMAL: 'DECIMAL'; -DECLARE: 'DECLARE'; -DECOMPOSE: 'DECOMPOSE'; -DECORRELATE: 'DECORRELATE'; -DECR: 'DECR'; -DECREMENT: 'DECREMENT'; -DECRYPT: 'DECRYPT'; -DEDUPLICATE: 'DEDUPLICATE'; -DEFAULT: 'DEFAULT'; -DEFAULTS: 'DEFAULTS'; -DEFAULT_COLLATION: 'DEFAULT_COLLATION'; -DEFAULT_CREDENTIAL: 'DEFAULT_CREDENTIAL'; -DEFERRABLE: 'DEFERRABLE'; -DEFERRED: 'DEFERRED'; -DEFINED: 'DEFINED'; -DEFINE: 'DEFINE'; -DEFINER: 'DEFINER'; -DEGREE: 'DEGREE'; -DELAY: 'DELAY'; -DELEGATE: 'DELEGATE'; -DELETE_ALL: 'DELETE_ALL'; -DELETE: 'DELETE'; -DELETEXML: 'DELETEXML'; -DEMAND: 'DEMAND'; -DENSE_RANKM: 'DENSE_RANKM'; -DEPENDENT: 'DEPENDENT'; -DEPTH: 'DEPTH'; -DEQUEUE: 'DEQUEUE'; -DEREF: 'DEREF'; -DEREF_NO_REWRITE: 'DEREF_NO_REWRITE'; -DESC: 'DESC'; -DESCRIPTION: 'DESCRIPTION'; -DESTROY: 'DESTROY'; -DETACHED: 'DETACHED'; -DETERMINES: 'DETERMINES'; -DETERMINISTIC: 'DETERMINISTIC'; -DICTIONARY: 'DICTIONARY'; -DIMENSION: 'DIMENSION'; -DIMENSIONS: 'DIMENSIONS'; -DIRECT_LOAD: 'DIRECT_LOAD'; -DIRECTORY: 'DIRECTORY'; -DIRECT_PATH: 'DIRECT_PATH'; -DISABLE_ALL: 'DISABLE_ALL'; -DISABLE: 'DISABLE'; -DISABLE_PARALLEL_DML: 'DISABLE_PARALLEL_DML'; -DISABLE_PRESET: 'DISABLE_PRESET'; -DISABLE_RPKE: 'DISABLE_RPKE'; -DISALLOW: 'DISALLOW'; -DISASSOCIATE: 'DISASSOCIATE'; -DISCARD: 'DISCARD'; -DISCONNECT: 'DISCONNECT'; -DISK: 'DISK'; -DISKGROUP: 'DISKGROUP'; -DISKGROUP_PLUS: '\'+ DISKGROUP'; -DISKS: 'DISKS'; -DISMOUNT: 'DISMOUNT'; -DISTINCT: 'DISTINCT'; -DISTINGUISHED: 'DISTINGUISHED'; -DISTRIBUTED: 'DISTRIBUTED'; -DISTRIBUTE: 'DISTRIBUTE'; -DML: 'DML'; -DML_UPDATE: 'DML_UPDATE'; -DOCFIDELITY: 'DOCFIDELITY'; -DOCUMENT: 'DOCUMENT'; -DOMAIN_INDEX_FILTER: 'DOMAIN_INDEX_FILTER'; -DOMAIN_INDEX_NO_SORT: 'DOMAIN_INDEX_NO_SORT'; -DOMAIN_INDEX_SORT: 'DOMAIN_INDEX_SORT'; -DOUBLE: 'DOUBLE'; -DOWNGRADE: 'DOWNGRADE'; -DRIVING_SITE: 'DRIVING_SITE'; -DROP_COLUMN: 'DROP_COLUMN'; -DROP: 'DROP'; -DROP_GROUP: 'DROP_GROUP'; -DSINTERVAL_UNCONSTRAINED: 'DSINTERVAL_UNCONSTRAINED'; -DST_UPGRADE_INSERT_CONV: 'DST_UPGRADE_INSERT_CONV'; -DUMP: 'DUMP'; -DUMPSET: 'DUMPSET'; -DUPLICATE: 'DUPLICATE'; -DV: 'DV'; -DYNAMIC: 'DYNAMIC'; -DYNAMIC_SAMPLING: 'DYNAMIC_SAMPLING'; -DYNAMIC_SAMPLING_EST_CDN: 'DYNAMIC_SAMPLING_EST_CDN'; -E_LETTER: 'E'; -EACH: 'EACH'; -EDITIONABLE: 'EDITIONABLE'; -EDITION: 'EDITION'; -EDITIONING: 'EDITIONING'; -EDITIONS: 'EDITIONS'; -ELEMENT: 'ELEMENT'; -ELIM_GROUPBY: 'ELIM_GROUPBY'; -ELIMINATE_JOIN: 'ELIMINATE_JOIN'; -ELIMINATE_OBY: 'ELIMINATE_OBY'; -ELIMINATE_OUTER_JOIN: 'ELIMINATE_OUTER_JOIN'; -ELSE: 'ELSE'; -ELSIF: 'ELSIF'; -EM: 'EM'; -EMPTY_BLOB: 'EMPTY_BLOB'; -EMPTY_CLOB: 'EMPTY_CLOB'; -EMPTY_: 'EMPTY'; -ENABLE_ALL: 'ENABLE_ALL'; -ENABLE: 'ENABLE'; -ENABLE_PARALLEL_DML: 'ENABLE_PARALLEL_DML'; -ENABLE_PRESET: 'ENABLE_PRESET'; -ENCODING: 'ENCODING'; -ENCRYPT: 'ENCRYPT'; -ENCRYPTION: 'ENCRYPTION'; -END: 'END'; -END_OUTLINE_DATA: 'END_OUTLINE_DATA'; -ENFORCED: 'ENFORCED'; -ENFORCE: 'ENFORCE'; -ENQUEUE: 'ENQUEUE'; -ENTERPRISE: 'ENTERPRISE'; -ENTITYESCAPING: 'ENTITYESCAPING'; -ENTRY: 'ENTRY'; -EQUIPART: 'EQUIPART'; -ERR: 'ERR'; -ERROR_ARGUMENT: 'ERROR_ARGUMENT'; -ERROR: 'ERROR'; -ERROR_ON_OVERLAP_TIME: 'ERROR_ON_OVERLAP_TIME'; -ERRORS: 'ERRORS'; -ESCAPE: 'ESCAPE'; -ESTIMATE: 'ESTIMATE'; -EVAL: 'EVAL'; -EVALNAME: 'EVALNAME'; -EVALUATE: 'EVALUATE'; -EVALUATION: 'EVALUATION'; -EVENTS: 'EVENTS'; -EVERY: 'EVERY'; -EXCEPT: 'EXCEPT'; -EXCEPTION: 'EXCEPTION'; -EXCEPTION_INIT: 'EXCEPTION_INIT'; -EXCEPTIONS: 'EXCEPTIONS'; -EXCHANGE: 'EXCHANGE'; -EXCLUDE: 'EXCLUDE'; -EXCLUDING: 'EXCLUDING'; -EXCLUSIVE: 'EXCLUSIVE'; -EXECUTE: 'EXECUTE'; -EXEMPT: 'EXEMPT'; -EXISTING: 'EXISTING'; -EXISTS: 'EXISTS'; -EXISTSNODE: 'EXISTSNODE'; -EXIT: 'EXIT'; -EXPAND_GSET_TO_UNION: 'EXPAND_GSET_TO_UNION'; -EXPAND_TABLE: 'EXPAND_TABLE'; -EXP: 'EXP'; -EXPIRE: 'EXPIRE'; -EXPLAIN: 'EXPLAIN'; -EXPLOSION: 'EXPLOSION'; -EXPORT: 'EXPORT'; -EXPR_CORR_CHECK: 'EXPR_CORR_CHECK'; -EXPRESS: 'EXPRESS'; -EXTENDS: 'EXTENDS'; -EXTENT: 'EXTENT'; -EXTENTS: 'EXTENTS'; -EXTERNAL: 'EXTERNAL'; -EXTERNALLY: 'EXTERNALLY'; -EXTRACTCLOBXML: 'EXTRACTCLOBXML'; -EXTRACT: 'EXTRACT'; -EXTRACTVALUE: 'EXTRACTVALUE'; -EXTRA: 'EXTRA'; -FACILITY: 'FACILITY'; -FACT: 'FACT'; -FACTOR: 'FACTOR'; -FACTORIZE_JOIN: 'FACTORIZE_JOIN'; -FAILED: 'FAILED'; -FAILED_LOGIN_ATTEMPTS: 'FAILED_LOGIN_ATTEMPTS'; -FAILGROUP: 'FAILGROUP'; -FAILOVER: 'FAILOVER'; -FAILURE: 'FAILURE'; -FALSE: 'FALSE'; -FAMILY: 'FAMILY'; -FAR: 'FAR'; -FAST: 'FAST'; -FASTSTART: 'FASTSTART'; -FBTSCAN: 'FBTSCAN'; -FEATURE: 'FEATURE'; -FEATURE_DETAILS: 'FEATURE_DETAILS'; -FEATURE_ID: 'FEATURE_ID'; -FEATURE_SET: 'FEATURE_SET'; -FEATURE_VALUE: 'FEATURE_VALUE'; -FETCH: 'FETCH'; -FILE: 'FILE'; -FILE_NAME_CONVERT: 'FILE_NAME_CONVERT'; -FILEGROUP: 'FILEGROUP'; -FILESTORE: 'FILESTORE'; -FILESYSTEM_LIKE_LOGGING: 'FILESYSTEM_LIKE_LOGGING'; -FILTER: 'FILTER'; -FINAL: 'FINAL'; -FINE: 'FINE'; -FINISH: 'FINISH'; -FIRST: 'FIRST'; -FIRSTM: 'FIRSTM'; -FIRST_ROWS: 'FIRST_ROWS'; -FIRST_VALUE: 'FIRST_VALUE'; -FIXED_VIEW_DATA: 'FIXED_VIEW_DATA'; -FLAGGER: 'FLAGGER'; -FLASHBACK: 'FLASHBACK'; -FLASH_CACHE: 'FLASH_CACHE'; -FLOAT: 'FLOAT'; -FLOB: 'FLOB'; -FLEX: 'FLEX'; -FLOOR: 'FLOOR'; -FLUSH: 'FLUSH'; -FOLDER: 'FOLDER'; -FOLLOWING: 'FOLLOWING'; -FOLLOWS: 'FOLLOWS'; -FORALL: 'FORALL'; -FORCE: 'FORCE'; -FORCE_XML_QUERY_REWRITE: 'FORCE_XML_QUERY_REWRITE'; -FOREIGN: 'FOREIGN'; -FOREVER: 'FOREVER'; -FOR: 'FOR'; -FORMAT: 'FORMAT'; -FORWARD: 'FORWARD'; -FRAGMENT_NUMBER: 'FRAGMENT_NUMBER'; -FREELIST: 'FREELIST'; -FREELISTS: 'FREELISTS'; -FREEPOOLS: 'FREEPOOLS'; -FRESH: 'FRESH'; -FROM: 'FROM'; -FROM_TZ: 'FROM_TZ'; -FULL: 'FULL'; -FULL_OUTER_JOIN_TO_OUTER: 'FULL_OUTER_JOIN_TO_OUTER'; -FUNCTION: 'FUNCTION'; -FUNCTIONS: 'FUNCTIONS'; -FTP: 'FTP'; -G_LETTER: 'G'; -GATHER_OPTIMIZER_STATISTICS: 'GATHER_OPTIMIZER_STATISTICS'; -GATHER_PLAN_STATISTICS: 'GATHER_PLAN_STATISTICS'; -GBY_CONC_ROLLUP: 'GBY_CONC_ROLLUP'; -GBY_PUSHDOWN: 'GBY_PUSHDOWN'; -GENERATED: 'GENERATED'; -GET: 'GET'; -GLOBAL: 'GLOBAL'; -GLOBALLY: 'GLOBALLY'; -GLOBAL_NAME: 'GLOBAL_NAME'; -GLOBAL_TOPIC_ENABLED: 'GLOBAL_TOPIC_ENABLED'; -GOTO: 'GOTO'; -GRANT: 'GRANT'; -GROUP_BY: 'GROUP_BY'; -GROUP: 'GROUP'; -GROUP_ID: 'GROUP_ID'; -GROUPING: 'GROUPING'; -GROUPING_ID: 'GROUPING_ID'; -GROUPS: 'GROUPS'; -GUARANTEED: 'GUARANTEED'; -GUARANTEE: 'GUARANTEE'; -GUARD: 'GUARD'; -HALF_YEARS: 'HALF_YEARS'; -HASH_AJ: 'HASH_AJ'; -HASH: 'HASH'; -HASHKEYS: 'HASHKEYS'; -HASH_SJ: 'HASH_SJ'; -HAVING: 'HAVING'; -HEADER: 'HEADER'; -HEAP: 'HEAP'; -HELP: 'HELP'; -HEXTORAW: 'HEXTORAW'; -HEXTOREF: 'HEXTOREF'; -HIDDEN_KEYWORD: 'HIDDEN'; -HIDE: 'HIDE'; -HIER_ORDER: 'HIER_ORDER'; -HIERARCHICAL: 'HIERARCHICAL'; -HIERARCHIES: 'HIERARCHIES'; -HIERARCHY: 'HIERARCHY'; -HIGH: 'HIGH'; -HINTSET_BEGIN: 'HINTSET_BEGIN'; -HINTSET_END: 'HINTSET_END'; -HOT: 'HOT'; -HOUR: 'HOUR'; -HOURS: 'HOURS'; -HTTP: 'HTTP'; -HWM_BROKERED: 'HWM_BROKERED'; -HYBRID: 'HYBRID'; -H_LETTER: 'H'; -IDENTIFIED: 'IDENTIFIED'; -IDENTIFIER: 'IDENTIFIER'; -IDENTITY: 'IDENTITY'; -IDGENERATORS: 'IDGENERATORS'; -ID: 'ID'; -IDLE_TIME: 'IDLE_TIME'; -IF: 'IF'; -IGNORE: 'IGNORE'; -IGNORE_OPTIM_EMBEDDED_HINTS: 'IGNORE_OPTIM_EMBEDDED_HINTS'; -IGNORE_ROW_ON_DUPKEY_INDEX: 'IGNORE_ROW_ON_DUPKEY_INDEX'; -IGNORE_WHERE_CLAUSE: 'IGNORE_WHERE_CLAUSE'; -ILM: 'ILM'; -IMMEDIATE: 'IMMEDIATE'; -IMPACT: 'IMPACT'; -IMPORT: 'IMPORT'; -INACTIVE: 'INACTIVE'; -INACTIVE_ACCOUNT_TIME: 'INACTIVE_ACCOUNT_TIME'; -INCLUDE: 'INCLUDE'; -INCLUDE_VERSION: 'INCLUDE_VERSION'; -INCLUDING: 'INCLUDING'; -INCREMENTAL: 'INCREMENTAL'; -INCREMENT: 'INCREMENT'; -INCR: 'INCR'; -INDENT: 'INDENT'; -INDEX_ASC: 'INDEX_ASC'; -INDEX_COMBINE: 'INDEX_COMBINE'; -INDEX_DESC: 'INDEX_DESC'; -INDEXED: 'INDEXED'; -INDEXES: 'INDEXES'; -INDEX_FFS: 'INDEX_FFS'; -INDEX_FILTER: 'INDEX_FILTER'; -INDEX: 'INDEX'; -INDEXING: 'INDEXING'; -INDEX_JOIN: 'INDEX_JOIN'; -INDEX_ROWS: 'INDEX_ROWS'; -INDEX_RRS: 'INDEX_RRS'; -INDEX_RS_ASC: 'INDEX_RS_ASC'; -INDEX_RS_DESC: 'INDEX_RS_DESC'; -INDEX_RS: 'INDEX_RS'; -INDEX_SCAN: 'INDEX_SCAN'; -INDEX_SKIP_SCAN: 'INDEX_SKIP_SCAN'; -INDEX_SS_ASC: 'INDEX_SS_ASC'; -INDEX_SS_DESC: 'INDEX_SS_DESC'; -INDEX_SS: 'INDEX_SS'; -INDEX_STATS: 'INDEX_STATS'; -INDEXTYPE: 'INDEXTYPE'; -INDEXTYPES: 'INDEXTYPES'; -INDICATOR: 'INDICATOR'; -INDICES: 'INDICES'; -INFINITE: 'INFINITE'; -INFORMATIONAL: 'INFORMATIONAL'; -INHERIT: 'INHERIT'; -IN: 'IN'; -INITCAP: 'INITCAP'; -INITIAL: 'INITIAL'; -INITIALIZED: 'INITIALIZED'; -INITIALLY: 'INITIALLY'; -INITRANS: 'INITRANS'; -INLINE: 'INLINE'; -INLINE_XMLTYPE_NT: 'INLINE_XMLTYPE_NT'; -INMEMORY: 'INMEMORY'; -IN_MEMORY_METADATA: 'IN_MEMORY_METADATA'; -INMEMORY_PRUNING: 'INMEMORY_PRUNING'; -INNER: 'INNER'; -INOUT: 'INOUT'; -INPLACE: 'INPLACE'; -INSERTCHILDXMLAFTER: 'INSERTCHILDXMLAFTER'; -INSERTCHILDXMLBEFORE: 'INSERTCHILDXMLBEFORE'; -INSERTCHILDXML: 'INSERTCHILDXML'; -INSERT: 'INSERT'; -INSERTXMLAFTER: 'INSERTXMLAFTER'; -INSERTXMLBEFORE: 'INSERTXMLBEFORE'; -INSTANCE: 'INSTANCE'; -INSTANCES: 'INSTANCES'; -INSTANTIABLE: 'INSTANTIABLE'; -INSTANTLY: 'INSTANTLY'; -INSTEAD: 'INSTEAD'; -INSTR2: 'INSTR2'; -INSTR4: 'INSTR4'; -INSTRB: 'INSTRB'; -INSTRC: 'INSTRC'; -INSTR: 'INSTR'; -INTEGER: 'INTEGER'; -INTERLEAVED: 'INTERLEAVED'; -INTERMEDIATE: 'INTERMEDIATE'; -INTERNAL_CONVERT: 'INTERNAL_CONVERT'; -INTERNAL_USE: 'INTERNAL_USE'; -INTERPRETED: 'INTERPRETED'; -INTERSECT: 'INTERSECT'; -INTERVAL: 'INTERVAL'; -INT: 'INT'; -INTO: 'INTO'; -INVALIDATE: 'INVALIDATE'; -INVISIBLE: 'INVISIBLE'; -IN_XQUERY: 'IN_XQUERY'; -IS: 'IS'; -IS_LEAF: 'IS_LEAF'; -ISOLATION: 'ISOLATION'; -ISOLATION_LEVEL: 'ISOLATION_LEVEL'; -ITERATE: 'ITERATE'; -ITERATION_NUMBER: 'ITERATION_NUMBER'; -JAVA: 'JAVA'; -JOB: 'JOB'; -JOIN: 'JOIN'; -JSON_ARRAYAGG: 'JSON_ARRAYAGG'; -JSON_ARRAY: 'JSON_ARRAY'; -JSON_EQUAL: 'JSON_EQUAL'; -JSON_EXISTS2: 'JSON_EXISTS2'; -JSON_EXISTS: 'JSON_EXISTS'; -JSONGET: 'JSONGET'; -JSON: 'JSON'; -JSON_OBJECTAGG: 'JSON_OBJECTAGG'; -JSON_OBJECT: 'JSON_OBJECT'; -JSONPARSE: 'JSONPARSE'; -JSON_QUERY: 'JSON_QUERY'; -JSON_SERIALIZE: 'JSON_SERIALIZE'; -JSON_TABLE: 'JSON_TABLE'; -JSON_TEXTCONTAINS2: 'JSON_TEXTCONTAINS2'; -JSON_TEXTCONTAINS: 'JSON_TEXTCONTAINS'; -JSON_TRANSFORM: 'JSON_TRANSFORM'; -JSON_VALUE: 'JSON_VALUE'; -K_LETTER: 'K'; -KEEP_DUPLICATES: 'KEEP_DUPLICATES'; -KEEP: 'KEEP'; -KERBEROS: 'KERBEROS'; -KEY: 'KEY'; -KEY_LENGTH: 'KEY_LENGTH'; -KEYSIZE: 'KEYSIZE'; -KEYS: 'KEYS'; -KEYSTORE: 'KEYSTORE'; -KILL: 'KILL'; -LABEL: 'LABEL'; -LANGUAGE: 'LANGUAGE'; -LAST_DAY: 'LAST_DAY'; -LAST: 'LAST'; -LAST_VALUE: 'LAST_VALUE'; -LATERAL: 'LATERAL'; -LAX: 'LAX'; -LAYER: 'LAYER'; -LDAP_REGISTRATION_ENABLED: 'LDAP_REGISTRATION_ENABLED'; -LDAP_REGISTRATION: 'LDAP_REGISTRATION'; -LDAP_REG_SYNC_INTERVAL: 'LDAP_REG_SYNC_INTERVAL'; -LEAF: 'LEAF'; -LEAD_CDB: 'LEAD_CDB'; -LEAD_CDB_URI: 'LEAD_CDB_URI'; -LEADING: 'LEADING'; -LEFT: 'LEFT'; -LENGTH2: 'LENGTH2'; -LENGTH4: 'LENGTH4'; -LENGTHB: 'LENGTHB'; -LENGTHC: 'LENGTHC'; -LENGTH: 'LENGTH'; -LESS: 'LESS'; -LEVEL: 'LEVEL'; -LEVEL_NAME: 'LEVEL_NAME'; -LEVELS: 'LEVELS'; -LIBRARY: 'LIBRARY'; -LIFECYCLE: 'LIFECYCLE'; -LIFE: 'LIFE'; -LIFETIME: 'LIFETIME'; -LIKE2: 'LIKE2'; -LIKE4: 'LIKE4'; -LIKEC: 'LIKEC'; -LIKE_EXPAND: 'LIKE_EXPAND'; -LIKE: 'LIKE'; -LIMIT: 'LIMIT'; -LINEAR: 'LINEAR'; -LINK: 'LINK'; -LIST: 'LIST'; -LN: 'LN'; -LNNVL: 'LNNVL'; -LOAD: 'LOAD'; -LOB: 'LOB'; -LOBNVL: 'LOBNVL'; -LOBS: 'LOBS'; -LOCAL_INDEXES: 'LOCAL_INDEXES'; -LOCAL: 'LOCAL'; -LOCALTIME: 'LOCALTIME'; -LOCALTIMESTAMP: 'LOCALTIMESTAMP'; -LOCATION: 'LOCATION'; -LOCATOR: 'LOCATOR'; -LOCKDOWN: 'LOCKDOWN'; -LOCKED: 'LOCKED'; -LOCKING: 'LOCKING'; -LOCK: 'LOCK'; -LOGFILE: 'LOGFILE'; -LOGFILES: 'LOGFILES'; -LOGGING: 'LOGGING'; -LOGICAL: 'LOGICAL'; -LOGICAL_READS_PER_CALL: 'LOGICAL_READS_PER_CALL'; -LOGICAL_READS_PER_SESSION: 'LOGICAL_READS_PER_SESSION'; -LOG: 'LOG'; -LOGMINING: 'LOGMINING'; -LOGOFF: 'LOGOFF'; -LOGON: 'LOGON'; -LOG_READ_ONLY_VIOLATIONS: 'LOG_READ_ONLY_VIOLATIONS'; -LONG: 'LONG'; -LOOP: 'LOOP'; -LOST: 'LOST'; -LOWER: 'LOWER'; -LOW: 'LOW'; -LPAD: 'LPAD'; -LTRIM: 'LTRIM'; -M_LETTER: 'M'; -MAIN: 'MAIN'; -MAKE_REF: 'MAKE_REF'; -MANAGED: 'MANAGED'; -MANAGE: 'MANAGE'; -MANAGEMENT: 'MANAGEMENT'; -MANAGER: 'MANAGER'; -MANDATORY: 'MANDATORY'; -MANUAL: 'MANUAL'; -MAP: 'MAP'; -MAPPING: 'MAPPING'; -MASTER: 'MASTER'; -MATCHED: 'MATCHED'; -MATCHES: 'MATCHES'; -MATCH: 'MATCH'; -MATCH_NUMBER: 'MATCH_NUMBER'; -MATCH_RECOGNIZE: 'MATCH_RECOGNIZE'; -MATERIALIZED: 'MATERIALIZED'; -MATERIALIZE: 'MATERIALIZE'; -MAXARCHLOGS: 'MAXARCHLOGS'; -MAXDATAFILES: 'MAXDATAFILES'; -MAXEXTENTS: 'MAXEXTENTS'; -MAXIMIZE: 'MAXIMIZE'; -MAXINSTANCES: 'MAXINSTANCES'; -MAXLOGFILES: 'MAXLOGFILES'; -MAXLOGHISTORY: 'MAXLOGHISTORY'; -MAXLOGMEMBERS: 'MAXLOGMEMBERS'; -MAX_SHARED_TEMP_SIZE: 'MAX_SHARED_TEMP_SIZE'; -MAXSIZE: 'MAXSIZE'; -MAXTRANS: 'MAXTRANS'; -MAXVALUE: 'MAXVALUE'; -MEASURE: 'MEASURE'; -MEASURES: 'MEASURES'; -MEDIUM: 'MEDIUM'; -MEMBER: 'MEMBER'; -MEMBER_CAPTION: 'MEMBER_CAPTION'; -MEMBER_DESCRIPTION: 'MEMBER_DESCRIPTION'; -MEMBER_NAME: 'MEMBER_NAME'; -MEMBER_UNIQUE_NAME: 'MEMBER_UNIQUE_NAME'; -MEMCOMPRESS: 'MEMCOMPRESS'; -MEMORY: 'MEMORY'; -MERGEACTIONS: 'MERGE$ACTIONS'; -MERGE_AJ: 'MERGE_AJ'; -MERGE_CONST_ON: 'MERGE_CONST_ON'; -MERGE: 'MERGE'; -MERGE_SJ: 'MERGE_SJ'; -METADATA: 'METADATA'; -METHOD: 'METHOD'; -MIGRATE: 'MIGRATE'; -MIGRATION: 'MIGRATION'; -MINEXTENTS: 'MINEXTENTS'; -MINIMIZE: 'MINIMIZE'; -MINIMUM: 'MINIMUM'; -MINING: 'MINING'; -MINUS: 'MINUS'; -MINUS_NULL: 'MINUS_NULL'; -MINUTE: 'MINUTE'; -MINUTES: 'MINUTES'; -MINVALUE: 'MINVALUE'; -MIRRORCOLD: 'MIRRORCOLD'; -MIRRORHOT: 'MIRRORHOT'; -MIRROR: 'MIRROR'; -MISSING: 'MISSING'; -MISMATCH: 'MISMATCH'; -MLSLABEL: 'MLSLABEL'; -MODEL_COMPILE_SUBQUERY: 'MODEL_COMPILE_SUBQUERY'; -MODEL_DONTVERIFY_UNIQUENESS: 'MODEL_DONTVERIFY_UNIQUENESS'; -MODEL_DYNAMIC_SUBQUERY: 'MODEL_DYNAMIC_SUBQUERY'; -MODEL_MIN_ANALYSIS: 'MODEL_MIN_ANALYSIS'; -MODEL: 'MODEL'; -MODEL_NB: 'MODEL_NB'; -MODEL_NO_ANALYSIS: 'MODEL_NO_ANALYSIS'; -MODEL_PBY: 'MODEL_PBY'; -MODEL_PUSH_REF: 'MODEL_PUSH_REF'; -MODEL_SV: 'MODEL_SV'; -MODE: 'MODE'; -MODIFICATION: 'MODIFICATION'; -MODIFY_COLUMN_TYPE: 'MODIFY_COLUMN_TYPE'; -MODIFY: 'MODIFY'; -MOD: 'MOD'; -MODULE: 'MODULE'; -MONITORING: 'MONITORING'; -MONITOR: 'MONITOR'; -MONTH: 'MONTH'; -MONTHS_BETWEEN: 'MONTHS_BETWEEN'; -MONTHS: 'MONTHS'; -MOUNT: 'MOUNT'; -MOUNTPATH: 'MOUNTPATH'; -MOUNTPOINT: 'MOUNTPOINT'; -MOVEMENT: 'MOVEMENT'; -MOVE: 'MOVE'; -MULTIDIMENSIONAL: 'MULTIDIMENSIONAL'; -MULTISET: 'MULTISET'; -MV_MERGE: 'MV_MERGE'; -NAMED: 'NAMED'; -NAME: 'NAME'; -NAMESPACE: 'NAMESPACE'; -NAN: 'NAN'; -NANVL: 'NANVL'; -NATIONAL: 'NATIONAL'; -NATIVE_FULL_OUTER_JOIN: 'NATIVE_FULL_OUTER_JOIN'; -NATIVE: 'NATIVE'; -NATURAL: 'NATURAL'; -NATURALN: 'NATURALN'; -NAV: 'NAV'; -NCHAR_CS: 'NCHAR_CS'; -NCHAR: 'NCHAR'; -NCHR: 'NCHR'; -NCLOB: 'NCLOB'; -NEEDED: 'NEEDED'; -NEG: 'NEG'; -NESTED: 'NESTED'; -NESTED_TABLE_FAST_INSERT: 'NESTED_TABLE_FAST_INSERT'; -NESTED_TABLE_GET_REFS: 'NESTED_TABLE_GET_REFS'; -NESTED_TABLE_ID: 'NESTED_TABLE_ID'; -NESTED_TABLE_SET_REFS: 'NESTED_TABLE_SET_REFS'; -NESTED_TABLE_SET_SETID: 'NESTED_TABLE_SET_SETID'; -NETWORK: 'NETWORK'; -NEVER: 'NEVER'; -NEW: 'NEW'; -NEW_TIME: 'NEW_TIME'; -NEXT_DAY: 'NEXT_DAY'; -NEXT: 'NEXT'; -NL_AJ: 'NL_AJ'; -NLJ_BATCHING: 'NLJ_BATCHING'; -NLJ_INDEX_FILTER: 'NLJ_INDEX_FILTER'; -NLJ_INDEX_SCAN: 'NLJ_INDEX_SCAN'; -NLJ_PREFETCH: 'NLJ_PREFETCH'; -NLS_CALENDAR: 'NLS_CALENDAR'; -NLS_CHARACTERSET: 'NLS_CHARACTERSET'; -NLS_CHARSET_DECL_LEN: 'NLS_CHARSET_DECL_LEN'; -NLS_CHARSET_ID: 'NLS_CHARSET_ID'; -NLS_CHARSET_NAME: 'NLS_CHARSET_NAME'; -NLS_COMP: 'NLS_COMP'; -NLS_CURRENCY: 'NLS_CURRENCY'; -NLS_DATE_FORMAT: 'NLS_DATE_FORMAT'; -NLS_DATE_LANGUAGE: 'NLS_DATE_LANGUAGE'; -NLS_INITCAP: 'NLS_INITCAP'; -NLS_ISO_CURRENCY: 'NLS_ISO_CURRENCY'; -NL_SJ: 'NL_SJ'; -NLS_LANG: 'NLS_LANG'; -NLS_LANGUAGE: 'NLS_LANGUAGE'; -NLS_LENGTH_SEMANTICS: 'NLS_LENGTH_SEMANTICS'; -NLS_LOWER: 'NLS_LOWER'; -NLS_NCHAR_CONV_EXCP: 'NLS_NCHAR_CONV_EXCP'; -NLS_NUMERIC_CHARACTERS: 'NLS_NUMERIC_CHARACTERS'; -NLS_SORT: 'NLS_SORT'; -NLSSORT: 'NLSSORT'; -NLS_SPECIAL_CHARS: 'NLS_SPECIAL_CHARS'; -NLS_TERRITORY: 'NLS_TERRITORY'; -NLS_UPPER: 'NLS_UPPER'; -NO_ACCESS: 'NO_ACCESS'; -NO_ADAPTIVE_PLAN: 'NO_ADAPTIVE_PLAN'; -NO_ANSI_REARCH: 'NO_ANSI_REARCH'; -NOAPPEND: 'NOAPPEND'; -NOARCHIVELOG: 'NOARCHIVELOG'; -NOAUDIT: 'NOAUDIT'; -NO_AUTO_REOPTIMIZE: 'NO_AUTO_REOPTIMIZE'; -NO_BASETABLE_MULTIMV_REWRITE: 'NO_BASETABLE_MULTIMV_REWRITE'; -NO_BATCH_TABLE_ACCESS_BY_ROWID: 'NO_BATCH_TABLE_ACCESS_BY_ROWID'; -NO_BIND_AWARE: 'NO_BIND_AWARE'; -NO_BUFFER: 'NO_BUFFER'; -NOCACHE: 'NOCACHE'; -NO_CARTESIAN: 'NO_CARTESIAN'; -NO_CHECK_ACL_REWRITE: 'NO_CHECK_ACL_REWRITE'; -NO_CLUSTER_BY_ROWID: 'NO_CLUSTER_BY_ROWID'; -NO_CLUSTERING: 'NO_CLUSTERING'; -NO_COALESCE_SQ: 'NO_COALESCE_SQ'; -NO_COMMON_DATA: 'NO_COMMON_DATA'; -NOCOMPRESS: 'NOCOMPRESS'; -NO_CONNECT_BY_CB_WHR_ONLY: 'NO_CONNECT_BY_CB_WHR_ONLY'; -NO_CONNECT_BY_COMBINE_SW: 'NO_CONNECT_BY_COMBINE_SW'; -NO_CONNECT_BY_COST_BASED: 'NO_CONNECT_BY_COST_BASED'; -NO_CONNECT_BY_ELIM_DUPS: 'NO_CONNECT_BY_ELIM_DUPS'; -NO_CONNECT_BY_FILTERING: 'NO_CONNECT_BY_FILTERING'; -NOCOPY: 'NOCOPY'; -NO_COST_XML_QUERY_REWRITE: 'NO_COST_XML_QUERY_REWRITE'; -NO_CPU_COSTING: 'NO_CPU_COSTING'; -NOCPU_COSTING: 'NOCPU_COSTING'; -NOCYCLE: 'NOCYCLE'; -NO_DATA_SECURITY_REWRITE: 'NO_DATA_SECURITY_REWRITE'; -NO_DECORRELATE: 'NO_DECORRELATE'; -NODELAY: 'NODELAY'; -NO_DOMAIN_INDEX_FILTER: 'NO_DOMAIN_INDEX_FILTER'; -NO_DST_UPGRADE_INSERT_CONV: 'NO_DST_UPGRADE_INSERT_CONV'; -NO_ELIM_GROUPBY: 'NO_ELIM_GROUPBY'; -NO_ELIMINATE_JOIN: 'NO_ELIMINATE_JOIN'; -NO_ELIMINATE_OBY: 'NO_ELIMINATE_OBY'; -NO_ELIMINATE_OUTER_JOIN: 'NO_ELIMINATE_OUTER_JOIN'; -NOENTITYESCAPING: 'NOENTITYESCAPING'; -NO_EXPAND_GSET_TO_UNION: 'NO_EXPAND_GSET_TO_UNION'; -NO_EXPAND: 'NO_EXPAND'; -NO_EXPAND_TABLE: 'NO_EXPAND_TABLE'; -NO_FACT: 'NO_FACT'; -NO_FACTORIZE_JOIN: 'NO_FACTORIZE_JOIN'; -NO_FILTERING: 'NO_FILTERING'; -NOFORCE: 'NOFORCE'; -NO_FULL_OUTER_JOIN_TO_OUTER: 'NO_FULL_OUTER_JOIN_TO_OUTER'; -NO_GATHER_OPTIMIZER_STATISTICS: 'NO_GATHER_OPTIMIZER_STATISTICS'; -NO_GBY_PUSHDOWN: 'NO_GBY_PUSHDOWN'; -NOGUARANTEE: 'NOGUARANTEE'; -NO_INDEX_FFS: 'NO_INDEX_FFS'; -NO_INDEX: 'NO_INDEX'; -NO_INDEX_SS: 'NO_INDEX_SS'; -NO_INMEMORY: 'NO_INMEMORY'; -NO_INMEMORY_PRUNING: 'NO_INMEMORY_PRUNING'; -NOKEEP: 'NOKEEP'; -NO_LOAD: 'NO_LOAD'; -NOLOCAL: 'NOLOCAL'; -NOLOGGING: 'NOLOGGING'; -NOMAPPING: 'NOMAPPING'; -NOMAXVALUE: 'NOMAXVALUE'; -NO_MERGE: 'NO_MERGE'; -NOMINIMIZE: 'NOMINIMIZE'; -NOMINVALUE: 'NOMINVALUE'; -NO_MODEL_PUSH_REF: 'NO_MODEL_PUSH_REF'; -NO_MONITORING: 'NO_MONITORING'; -NOMONITORING: 'NOMONITORING'; -NO_MONITOR: 'NO_MONITOR'; -NO_MULTIMV_REWRITE: 'NO_MULTIMV_REWRITE'; -NO_NATIVE_FULL_OUTER_JOIN: 'NO_NATIVE_FULL_OUTER_JOIN'; -NONBLOCKING: 'NONBLOCKING'; -NONEDITIONABLE: 'NONEDITIONABLE'; -NONE: 'NONE'; -NO_NLJ_BATCHING: 'NO_NLJ_BATCHING'; -NO_NLJ_PREFETCH: 'NO_NLJ_PREFETCH'; -NO: 'NO'; -NONSCHEMA: 'NONSCHEMA'; -NO_OBJECT_LINK: 'NO_OBJECT_LINK'; -NOORDER: 'NOORDER'; -NO_ORDER_ROLLUPS: 'NO_ORDER_ROLLUPS'; -NO_OUTER_JOIN_TO_ANTI: 'NO_OUTER_JOIN_TO_ANTI'; -NO_OUTER_JOIN_TO_INNER: 'NO_OUTER_JOIN_TO_INNER'; -NOOVERRIDE: 'NOOVERRIDE'; -NO_PARALLEL_INDEX: 'NO_PARALLEL_INDEX'; -NOPARALLEL_INDEX: 'NOPARALLEL_INDEX'; -NO_PARALLEL: 'NO_PARALLEL'; -NOPARALLEL: 'NOPARALLEL'; -NO_PARTIAL_COMMIT: 'NO_PARTIAL_COMMIT'; -NO_PARTIAL_JOIN: 'NO_PARTIAL_JOIN'; -NO_PARTIAL_ROLLUP_PUSHDOWN: 'NO_PARTIAL_ROLLUP_PUSHDOWN'; -NOPARTITION: 'NOPARTITION'; -NO_PLACE_DISTINCT: 'NO_PLACE_DISTINCT'; -NO_PLACE_GROUP_BY: 'NO_PLACE_GROUP_BY'; -NO_PQ_CONCURRENT_UNION: 'NO_PQ_CONCURRENT_UNION'; -NO_PQ_MAP: 'NO_PQ_MAP'; -NOPROMPT: 'NOPROMPT'; -NO_PQ_REPLICATE: 'NO_PQ_REPLICATE'; -NO_PQ_SKEW: 'NO_PQ_SKEW'; -NO_PRUNE_GSETS: 'NO_PRUNE_GSETS'; -NO_PULL_PRED: 'NO_PULL_PRED'; -NO_PUSH_PRED: 'NO_PUSH_PRED'; -NO_PUSH_SUBQ: 'NO_PUSH_SUBQ'; -NO_PX_FAULT_TOLERANCE: 'NO_PX_FAULT_TOLERANCE'; -NO_PX_JOIN_FILTER: 'NO_PX_JOIN_FILTER'; -NO_QKN_BUFF: 'NO_QKN_BUFF'; -NO_QUERY_TRANSFORMATION: 'NO_QUERY_TRANSFORMATION'; -NO_REF_CASCADE: 'NO_REF_CASCADE'; -NORELOCATE: 'NORELOCATE'; -NORELY: 'NORELY'; -NOREPAIR: 'NOREPAIR'; -NOREPLAY: 'NOREPLAY'; -NORESETLOGS: 'NORESETLOGS'; -NO_RESULT_CACHE: 'NO_RESULT_CACHE'; -NOREVERSE: 'NOREVERSE'; -NO_REWRITE: 'NO_REWRITE'; -NOREWRITE: 'NOREWRITE'; -NORMAL: 'NORMAL'; -NO_ROOT_SW_FOR_LOCAL: 'NO_ROOT_SW_FOR_LOCAL'; -NOROWDEPENDENCIES: 'NOROWDEPENDENCIES'; -NOSCHEMACHECK: 'NOSCHEMACHECK'; -NOSEGMENT: 'NOSEGMENT'; -NO_SEMIJOIN: 'NO_SEMIJOIN'; -NO_SEMI_TO_INNER: 'NO_SEMI_TO_INNER'; -NO_SET_TO_JOIN: 'NO_SET_TO_JOIN'; -NOSORT: 'NOSORT'; -NO_SQL_TRANSLATION: 'NO_SQL_TRANSLATION'; -NO_SQL_TUNE: 'NO_SQL_TUNE'; -NO_STAR_TRANSFORMATION: 'NO_STAR_TRANSFORMATION'; -NO_STATEMENT_QUEUING: 'NO_STATEMENT_QUEUING'; -NO_STATS_GSETS: 'NO_STATS_GSETS'; -NOSTRICT: 'NOSTRICT'; -NO_SUBQUERY_PRUNING: 'NO_SUBQUERY_PRUNING'; -NO_SUBSTRB_PAD: 'NO_SUBSTRB_PAD'; -NO_SWAP_JOIN_INPUTS: 'NO_SWAP_JOIN_INPUTS'; -NOSWITCH: 'NOSWITCH'; -NO_TABLE_LOOKUP_BY_NL: 'NO_TABLE_LOOKUP_BY_NL'; -NO_TEMP_TABLE: 'NO_TEMP_TABLE'; -NOTHING: 'NOTHING'; -NOTIFICATION: 'NOTIFICATION'; -NOT: 'NOT'; -NO_TRANSFORM_DISTINCT_AGG: 'NO_TRANSFORM_DISTINCT_AGG'; -NO_UNNEST: 'NO_UNNEST'; -NO_USE_CUBE: 'NO_USE_CUBE'; -NO_USE_HASH_AGGREGATION: 'NO_USE_HASH_AGGREGATION'; -NO_USE_HASH_GBY_FOR_PUSHDOWN: 'NO_USE_HASH_GBY_FOR_PUSHDOWN'; -NO_USE_HASH: 'NO_USE_HASH'; -NO_USE_INVISIBLE_INDEXES: 'NO_USE_INVISIBLE_INDEXES'; -NO_USE_MERGE: 'NO_USE_MERGE'; -NO_USE_NL: 'NO_USE_NL'; -NO_USE_VECTOR_AGGREGATION: 'NO_USE_VECTOR_AGGREGATION'; -NOVALIDATE: 'NOVALIDATE'; -NO_VECTOR_TRANSFORM_DIMS: 'NO_VECTOR_TRANSFORM_DIMS'; -NO_VECTOR_TRANSFORM_FACT: 'NO_VECTOR_TRANSFORM_FACT'; -NO_VECTOR_TRANSFORM: 'NO_VECTOR_TRANSFORM'; -NOWAIT: 'NOWAIT'; -NO_XDB_FASTPATH_INSERT: 'NO_XDB_FASTPATH_INSERT'; -NO_XML_DML_REWRITE: 'NO_XML_DML_REWRITE'; -NO_XMLINDEX_REWRITE_IN_SELECT: 'NO_XMLINDEX_REWRITE_IN_SELECT'; -NO_XMLINDEX_REWRITE: 'NO_XMLINDEX_REWRITE'; -NO_XML_QUERY_REWRITE: 'NO_XML_QUERY_REWRITE'; -NO_ZONEMAP: 'NO_ZONEMAP'; -NTH_VALUE: 'NTH_VALUE'; -NULLIF: 'NULLIF'; -NULL_: 'NULL'; -NULLS: 'NULLS'; -NUMBER: 'NUMBER'; -NUMERIC: 'NUMERIC'; -NUM_INDEX_KEYS: 'NUM_INDEX_KEYS'; -NUMTODSINTERVAL: 'NUMTODSINTERVAL'; -NUMTOYMINTERVAL: 'NUMTOYMINTERVAL'; -NVARCHAR2: 'NVARCHAR2'; -NVL2: 'NVL2'; -OBJECT2XML: 'OBJECT2XML'; -OBJECT: 'OBJECT'; -OBJ_ID: 'OBJ_ID'; -OBJNO: 'OBJNO'; -OBJNO_REUSE: 'OBJNO_REUSE'; -OCCURENCES: 'OCCURENCES'; -OFFLINE: 'OFFLINE'; -OFF: 'OFF'; -OFFSET: 'OFFSET'; -OF: 'OF'; -OIDINDEX: 'OIDINDEX'; -OID: 'OID'; -OLAP: 'OLAP'; -OLD: 'OLD'; -OLD_PUSH_PRED: 'OLD_PUSH_PRED'; -OLS: 'OLS'; -OLTP: 'OLTP'; -OMIT: 'OMIT'; -ONE: 'ONE'; -ONLINE: 'ONLINE'; -ONLINELOG: 'ONLINELOG'; -ONLY: 'ONLY'; -ON: 'ON'; -OPAQUE: 'OPAQUE'; -OPAQUE_TRANSFORM: 'OPAQUE_TRANSFORM'; -OPAQUE_XCANONICAL: 'OPAQUE_XCANONICAL'; -OPCODE: 'OPCODE'; -OPEN: 'OPEN'; -OPERATIONS: 'OPERATIONS'; -OPERATOR: 'OPERATOR'; -OPT_ESTIMATE: 'OPT_ESTIMATE'; -OPTIMAL: 'OPTIMAL'; -OPTIMIZE: 'OPTIMIZE'; -OPTIMIZER_FEATURES_ENABLE: 'OPTIMIZER_FEATURES_ENABLE'; -OPTIMIZER_GOAL: 'OPTIMIZER_GOAL'; -OPTION: 'OPTION'; -OPT_PARAM: 'OPT_PARAM'; -ORA_BRANCH: 'ORA_BRANCH'; -ORA_CHECK_ACL: 'ORA_CHECK_ACL'; -ORA_CHECK_PRIVILEGE: 'ORA_CHECK_PRIVILEGE'; -ORA_CLUSTERING: 'ORA_CLUSTERING'; -ORADATA: 'ORADATA'; -ORADEBUG: 'ORADEBUG'; -ORA_DST_AFFECTED: 'ORA_DST_AFFECTED'; -ORA_DST_CONVERT: 'ORA_DST_CONVERT'; -ORA_DST_ERROR: 'ORA_DST_ERROR'; -ORA_GET_ACLIDS: 'ORA_GET_ACLIDS'; -ORA_GET_PRIVILEGES: 'ORA_GET_PRIVILEGES'; -ORA_HASH: 'ORA_HASH'; -ORA_INVOKING_USERID: 'ORA_INVOKING_USERID'; -ORA_INVOKING_USER: 'ORA_INVOKING_USER'; -ORA_INVOKING_XS_USER_GUID: 'ORA_INVOKING_XS_USER_GUID'; -ORA_INVOKING_XS_USER: 'ORA_INVOKING_XS_USER'; -ORA_RAWCOMPARE: 'ORA_RAWCOMPARE'; -ORA_RAWCONCAT: 'ORA_RAWCONCAT'; -ORA_ROWSCN: 'ORA_ROWSCN'; -ORA_ROWSCN_RAW: 'ORA_ROWSCN_RAW'; -ORA_ROWVERSION: 'ORA_ROWVERSION'; -ORA_TABVERSION: 'ORA_TABVERSION'; -ORA_WRITE_TIME: 'ORA_WRITE_TIME'; -ORDERED: 'ORDERED'; -ORDERED_PREDICATES: 'ORDERED_PREDICATES'; -ORDER: 'ORDER'; -ORDINALITY: 'ORDINALITY'; -OR_EXPAND: 'OR_EXPAND'; -ORGANIZATION: 'ORGANIZATION'; -OR: 'OR'; -OR_PREDICATES: 'OR_PREDICATES'; -OSERROR: 'OSERROR'; -OTHER: 'OTHER'; -OUTER_JOIN_TO_ANTI: 'OUTER_JOIN_TO_ANTI'; -OUTER_JOIN_TO_INNER: 'OUTER_JOIN_TO_INNER'; -OUTER: 'OUTER'; -OUTLINE_LEAF: 'OUTLINE_LEAF'; -OUTLINE: 'OUTLINE'; -OUT_OF_LINE: 'OUT_OF_LINE'; -OUT: 'OUT'; -OVERFLOW_NOMOVE: 'OVERFLOW_NOMOVE'; -OVERFLOW: 'OVERFLOW'; -OVERLAPS: 'OVERLAPS'; -OVER: 'OVER'; -OVERRIDING: 'OVERRIDING'; -OWNER: 'OWNER'; -OWNERSHIP: 'OWNERSHIP'; -OWN: 'OWN'; -P_LETTER: 'P'; -PACKAGE: 'PACKAGE'; -PACKAGES: 'PACKAGES'; -PARALLEL_ENABLE: 'PARALLEL_ENABLE'; -PARALLEL_INDEX: 'PARALLEL_INDEX'; -PARALLEL: 'PARALLEL'; -PARAMETERFILE: 'PARAMETERFILE'; -PARAMETERS: 'PARAMETERS'; -PARAM: 'PARAM'; -PARENT: 'PARENT'; -PARENT_LEVEL_NAME: 'PARENT_LEVEL_NAME'; -PARENT_UNIQUE_NAME: 'PARENT_UNIQUE_NAME'; -PARITY: 'PARITY'; -PARTIAL_JOIN: 'PARTIAL_JOIN'; -PARTIALLY: 'PARTIALLY'; -PARTIAL: 'PARTIAL'; -PARTIAL_ROLLUP_PUSHDOWN: 'PARTIAL_ROLLUP_PUSHDOWN'; -PARTITION_HASH: 'PARTITION_HASH'; -PARTITION_LIST: 'PARTITION_LIST'; -PARTITION: 'PARTITION'; -PARTITION_RANGE: 'PARTITION_RANGE'; -PARTITIONS: 'PARTITIONS'; -PARTNUMINST: 'PART$NUM$INST'; -PASSING: 'PASSING'; -PASSWORD_GRACE_TIME: 'PASSWORD_GRACE_TIME'; -PASSWORD_LIFE_TIME: 'PASSWORD_LIFE_TIME'; -PASSWORD_LOCK_TIME: 'PASSWORD_LOCK_TIME'; -PASSWORD: 'PASSWORD'; -PASSWORD_REUSE_MAX: 'PASSWORD_REUSE_MAX'; -PASSWORD_REUSE_TIME: 'PASSWORD_REUSE_TIME'; -PASSWORD_ROLLOVER_TIME: 'PASSWORD_ROLLOVER_TIME'; -PASSWORD_VERIFY_FUNCTION: 'PASSWORD_VERIFY_FUNCTION'; -PAST: 'PAST'; -PATCH: 'PATCH'; -PATH: 'PATH'; -PATH_PREFIX: 'PATH_PREFIX'; -PATHS: 'PATHS'; -PATTERN: 'PATTERN'; -PBL_HS_BEGIN: 'PBL_HS_BEGIN'; -PBL_HS_END: 'PBL_HS_END'; -PCTFREE: 'PCTFREE'; -PCTINCREASE: 'PCTINCREASE'; -PCTTHRESHOLD: 'PCTTHRESHOLD'; -PCTUSED: 'PCTUSED'; -PCTVERSION: 'PCTVERSION'; -PENDING: 'PENDING'; -PERCENT_FOUND: '%' SPACE* 'FOUND'; -PERCENT_ISOPEN: '%' SPACE* 'ISOPEN'; -PERCENT_NOTFOUND: '%' SPACE* 'NOTFOUND'; -PERCENT_KEYWORD: 'PERCENT'; -PERCENT_RANKM: 'PERCENT_RANKM'; -PERCENT_ROWCOUNT: '%' SPACE* 'ROWCOUNT'; -PERCENT_ROWTYPE: '%' SPACE* 'ROWTYPE'; -PERCENT_TYPE: '%' SPACE* 'TYPE'; -PERFORMANCE: 'PERFORMANCE'; -PERIOD_KEYWORD: 'PERIOD'; -PERMANENT: 'PERMANENT'; -PERMISSION: 'PERMISSION'; -PERMUTE: 'PERMUTE'; -PER: 'PER'; -PFILE: 'PFILE'; -PHYSICAL: 'PHYSICAL'; -PIKEY: 'PIKEY'; -PIPELINED: 'PIPELINED'; -PIPE: 'PIPE'; -PIV_GB: 'PIV_GB'; -PIVOT: 'PIVOT'; -PIV_SSF: 'PIV_SSF'; -PLACE_DISTINCT: 'PLACE_DISTINCT'; -PLACE_GROUP_BY: 'PLACE_GROUP_BY'; -PLAN: 'PLAN'; -PLSCOPE_SETTINGS: 'PLSCOPE_SETTINGS'; -PLS_INTEGER: 'PLS_INTEGER'; -PLSQL_CCFLAGS: 'PLSQL_CCFLAGS'; -PLSQL_CODE_TYPE: 'PLSQL_CODE_TYPE'; -PLSQL_DEBUG: 'PLSQL_DEBUG'; -PLSQL_OPTIMIZE_LEVEL: 'PLSQL_OPTIMIZE_LEVEL'; -PLSQL_WARNINGS: 'PLSQL_WARNINGS'; -PLUGGABLE: 'PLUGGABLE'; -PMEM: 'PMEM'; -POINT: 'POINT'; -POLICY: 'POLICY'; -POOL_16K: 'POOL_16K'; -POOL_2K: 'POOL_2K'; -POOL_32K: 'POOL_32K'; -POOL_4K: 'POOL_4K'; -POOL_8K: 'POOL_8K'; -POSITIVEN: 'POSITIVEN'; -POSITIVE: 'POSITIVE'; -POST_TRANSACTION: 'POST_TRANSACTION'; -POWERMULTISET_BY_CARDINALITY: 'POWERMULTISET_BY_CARDINALITY'; -POWERMULTISET: 'POWERMULTISET'; -POWER: 'POWER'; -PQ_CONCURRENT_UNION: 'PQ_CONCURRENT_UNION'; -PQ_DISTRIBUTE: 'PQ_DISTRIBUTE'; -PQ_DISTRIBUTE_WINDOW: 'PQ_DISTRIBUTE_WINDOW'; -PQ_FILTER: 'PQ_FILTER'; -PQ_MAP: 'PQ_MAP'; -PQ_NOMAP: 'PQ_NOMAP'; -PQ_REPLICATE: 'PQ_REPLICATE'; -PQ_SKEW: 'PQ_SKEW'; -PRAGMA: 'PRAGMA'; -PREBUILT: 'PREBUILT'; -PRECEDES: 'PRECEDES'; -PRECEDING: 'PRECEDING'; -PRECISION: 'PRECISION'; -PRECOMPUTE_SUBQUERY: 'PRECOMPUTE_SUBQUERY'; -PREDICATE_REORDERS: 'PREDICATE_REORDERS'; -PRELOAD: 'PRELOAD'; -PREPARE: 'PREPARE'; -PRESENTNNV: 'PRESENTNNV'; -PRESENT: 'PRESENT'; -PRESENTV: 'PRESENTV'; -PRESERVE_OID: 'PRESERVE_OID'; -PRESERVE: 'PRESERVE'; -PRETTY: 'PRETTY'; -PREVIOUS: 'PREVIOUS'; -PREV: 'PREV'; -PRIMARY: 'PRIMARY'; -PRINTBLOBTOCLOB: 'PRINTBLOBTOCLOB'; -PRIORITY: 'PRIORITY'; -PRIOR: 'PRIOR'; -PRIVATE: 'PRIVATE'; -PRIVATE_SGA: 'PRIVATE_SGA'; -PRIVILEGED: 'PRIVILEGED'; -PRIVILEGE: 'PRIVILEGE'; -PRIVILEGES: 'PRIVILEGES'; -PROCEDURAL: 'PROCEDURAL'; -PROCEDURE: 'PROCEDURE'; -PROCESS: 'PROCESS'; -PROFILE: 'PROFILE'; -PROGRAM: 'PROGRAM'; -PROJECT: 'PROJECT'; -PROPAGATE: 'PROPAGATE'; -PROPERTY: 'PROPERTY'; -PROTECTED: 'PROTECTED'; -PROTECTION: 'PROTECTION'; -PROTOCOL: 'PROTOCOL'; -PROXY: 'PROXY'; -PRUNING: 'PRUNING'; -PUBLIC: 'PUBLIC'; -PULL_PRED: 'PULL_PRED'; -PURGE: 'PURGE'; -PUSH_PRED: 'PUSH_PRED'; -PUSH_SUBQ: 'PUSH_SUBQ'; -PX_FAULT_TOLERANCE: 'PX_FAULT_TOLERANCE'; -PX_GRANULE: 'PX_GRANULE'; -PX_JOIN_FILTER: 'PX_JOIN_FILTER'; -QB_NAME: 'QB_NAME'; -QUARTERS: 'QUARTERS'; -QUERY_BLOCK: 'QUERY_BLOCK'; -QUERY: 'QUERY'; -QUEUE_CURR: 'QUEUE_CURR'; -QUEUE: 'QUEUE'; -QUEUE_ROWP: 'QUEUE_ROWP'; -QUIESCE: 'QUIESCE'; -QUORUM: 'QUORUM'; -QUOTA: 'QUOTA'; -QUOTAGROUP: 'QUOTAGROUP'; -RAISE: 'RAISE'; -RANDOM_LOCAL: 'RANDOM_LOCAL'; -RANDOM: 'RANDOM'; -RANGE: 'RANGE'; -RANKM: 'RANKM'; -RAPIDLY: 'RAPIDLY'; -RAW: 'RAW'; -RAWTOHEX: 'RAWTOHEX'; -RAWTONHEX: 'RAWTONHEX'; -RBA: 'RBA'; -RBO_OUTLINE: 'RBO_OUTLINE'; -RDBA: 'RDBA'; -READ: 'READ'; -READS: 'READS'; -REALM: 'REALM'; -REAL: 'REAL'; -REBALANCE: 'REBALANCE'; -REBUILD: 'REBUILD'; -RECORD: 'RECORD'; -RECORDS_PER_BLOCK: 'RECORDS_PER_BLOCK'; -RECOVERABLE: 'RECOVERABLE'; -RECOVER: 'RECOVER'; -RECOVERY: 'RECOVERY'; -RECYCLEBIN: 'RECYCLEBIN'; -RECYCLE: 'RECYCLE'; -REDACTION: 'REDACTION'; -REDEFINE: 'REDEFINE'; -REDO: 'REDO'; -REDUCED: 'REDUCED'; -REDUNDANCY: 'REDUNDANCY'; -REF_CASCADE_CURSOR: 'REF_CASCADE_CURSOR'; -REFERENCED: 'REFERENCED'; -REFERENCE: 'REFERENCE'; -REFERENCES: 'REFERENCES'; -REFERENCING: 'REFERENCING'; -REF: 'REF'; -REFRESH: 'REFRESH'; -REFTOHEX: 'REFTOHEX'; -REGEXP_COUNT: 'REGEXP_COUNT'; -REGEXP_INSTR: 'REGEXP_INSTR'; -REGEXP_LIKE: 'REGEXP_LIKE'; -REGEXP_REPLACE: 'REGEXP_REPLACE'; -REGEXP_SUBSTR: 'REGEXP_SUBSTR'; -REGISTER: 'REGISTER'; -REGR_AVGX: 'REGR_AVGX'; -REGR_AVGY: 'REGR_AVGY'; -REGR_COUNT: 'REGR_COUNT'; -REGR_INTERCEPT: 'REGR_INTERCEPT'; -REGR_R2: 'REGR_R2'; -REGR_SLOPE: 'REGR_SLOPE'; -REGR_SXX: 'REGR_SXX'; -REGR_SXY: 'REGR_SXY'; -REGR_SYY: 'REGR_SYY'; -REGULAR: 'REGULAR'; -REJECT: 'REJECT'; -REKEY: 'REKEY'; -RELATIONAL: 'RELATIONAL'; -RELIES_ON: 'RELIES_ON'; -RELOCATE: 'RELOCATE'; -RELY: 'RELY'; -REMAINDER: 'REMAINDER'; -REMOTE: 'REMOTE'; -REMOTE_MAPPED: 'REMOTE_MAPPED'; -REMOVE: 'REMOVE'; -RENAME: 'RENAME'; -REPAIR: 'REPAIR'; -REPEAT: 'REPEAT'; -REPLACE: 'REPLACE'; -REPLICATION: 'REPLICATION'; -REQUIRED: 'REQUIRED'; -RESETLOGS: 'RESETLOGS'; -RESET: 'RESET'; -RESIZE: 'RESIZE'; -RESOLVE: 'RESOLVE'; -RESOLVER: 'RESOLVER'; -RESOURCE: 'RESOURCE'; -RESPECT: 'RESPECT'; -RESTART: 'RESTART'; -RESTORE_AS_INTERVALS: 'RESTORE_AS_INTERVALS'; -RESTORE: 'RESTORE'; -RESTRICT_ALL_REF_CONS: 'RESTRICT_ALL_REF_CONS'; -RESTRICTED: 'RESTRICTED'; -RESTRICT_REFERENCES: 'RESTRICT_REFERENCES'; -RESTRICT: 'RESTRICT'; -RESULT_CACHE: 'RESULT_CACHE'; -RESULT: 'RESULT'; -RESUMABLE: 'RESUMABLE'; -RESUME: 'RESUME'; -RETENTION: 'RETENTION'; -RETRY_ON_ROW_CHANGE: 'RETRY_ON_ROW_CHANGE'; -RETURNING: 'RETURNING'; -RETURN: 'RETURN'; -REUSE: 'REUSE'; -REVERSE: 'REVERSE'; -REVOKE: 'REVOKE'; -REWRITE_OR_ERROR: 'REWRITE_OR_ERROR'; -REWRITE: 'REWRITE'; -RIGHT: 'RIGHT'; -ROLE: 'ROLE'; -ROLESET: 'ROLESET'; -ROLES: 'ROLES'; -ROLLBACK: 'ROLLBACK'; -ROLLING: 'ROLLING'; -ROLLUP: 'ROLLUP'; -ROWDEPENDENCIES: 'ROWDEPENDENCIES'; -ROWID_MAPPING_TABLE: 'ROWID_MAPPING_TABLE'; -ROWID: 'ROWID'; -ROWIDTOCHAR: 'ROWIDTOCHAR'; -ROWIDTONCHAR: 'ROWIDTONCHAR'; -ROW_LENGTH: 'ROW_LENGTH'; -ROWNUM: 'ROWNUM'; -ROW: 'ROW'; -ROWS: 'ROWS'; -RPAD: 'RPAD'; -RTRIM: 'RTRIM'; -RULE: 'RULE'; -RULES: 'RULES'; -RUNNING: 'RUNNING'; -SALT: 'SALT'; -SAMPLE: 'SAMPLE'; -SAVE_AS_INTERVALS: 'SAVE_AS_INTERVALS'; -SAVEPOINT: 'SAVEPOINT'; -SAVE: 'SAVE'; -SB4: 'SB4'; -SCALE_ROWS: 'SCALE_ROWS'; -SCALE: 'SCALE'; -SCAN_INSTANCES: 'SCAN_INSTANCES'; -SCAN: 'SCAN'; -SCHEDULER: 'SCHEDULER'; -SCHEMACHECK: 'SCHEMACHECK'; -SCHEMA: 'SCHEMA'; -SCN_ASCENDING: 'SCN_ASCENDING'; -SCN: 'SCN'; -SCOPE: 'SCOPE'; -SCRUB: 'SCRUB'; -SD_ALL: 'SD_ALL'; -SD_INHIBIT: 'SD_INHIBIT'; -SDO_GEOM_MBR: 'SDO_GEOM_MBR'; -SDO_GEOMETRY: 'SDO_GEOMETRY'; -SD_SHOW: 'SD_SHOW'; -SEARCH: 'SEARCH'; -SECOND: 'SECOND'; -SECONDS: 'SECONDS'; -SECRET: 'SECRET'; -SECUREFILE_DBA: 'SECUREFILE_DBA'; -SECUREFILE: 'SECUREFILE'; -SECURITY: 'SECURITY'; -SEED: 'SEED'; -SEG_BLOCK: 'SEG_BLOCK'; -SEG_FILE: 'SEG_FILE'; -SEGMENT: 'SEGMENT'; -SELECTIVITY: 'SELECTIVITY'; -SELECT: 'SELECT'; -SELF: 'SELF'; -SEMIJOIN_DRIVER: 'SEMIJOIN_DRIVER'; -SEMIJOIN: 'SEMIJOIN'; -SEMI_TO_INNER: 'SEMI_TO_INNER'; -SEQUENCED: 'SEQUENCED'; -SEQUENCE: 'SEQUENCE'; -SEQUENTIAL: 'SEQUENTIAL'; -SEQ: 'SEQ'; -SERIALIZABLE: 'SERIALIZABLE'; -SERIALLY_REUSABLE: 'SERIALLY_REUSABLE'; -SERIAL: 'SERIAL'; -SERVERERROR: 'SERVERERROR'; -SERVICE_NAME_CONVERT: 'SERVICE_NAME_CONVERT'; -SERVICE: 'SERVICE'; -SERVICES: 'SERVICES'; -SESSION_CACHED_CURSORS: 'SESSION_CACHED_CURSORS'; -SESSION: 'SESSION'; -SESSIONS_PER_USER: 'SESSIONS_PER_USER'; -SESSIONTIMEZONE: 'SESSIONTIMEZONE'; -SESSIONTZNAME: 'SESSIONTZNAME'; -SET: 'SET'; -SETS: 'SETS'; -SETTINGS: 'SETTINGS'; -SET_TO_JOIN: 'SET_TO_JOIN'; -SEVERE: 'SEVERE'; -SHARDSPACE: 'SHARDSPACE'; -SHARED_POOL: 'SHARED_POOL'; -SHARED: 'SHARED'; -SHARE: 'SHARE'; -SHARING: 'SHARING'; -SHELFLIFE: 'SHELFLIFE'; -SHOW: 'SHOW'; -SHRINK: 'SHRINK'; -SHUTDOWN: 'SHUTDOWN'; -SIBLINGS: 'SIBLINGS'; -SID: 'SID'; -SITE: 'SITE'; -SIGNAL_COMPONENT: 'SIGNAL_COMPONENT'; -SIGNAL_FUNCTION: 'SIGNAL_FUNCTION'; -SIGN: 'SIGN'; -SIGNTYPE: 'SIGNTYPE'; -SIMPLE_INTEGER: 'SIMPLE_INTEGER'; -SIMPLE: 'SIMPLE'; -SINGLE: 'SINGLE'; -SINGLETASK: 'SINGLETASK'; -SINH: 'SINH'; -SIN: 'SIN'; -SIZE: 'SIZE'; -SKIP_EXT_OPTIMIZER: 'SKIP_EXT_OPTIMIZER'; -SKIP_ : 'SKIP'; -SKIP_UNQ_UNUSABLE_IDX: 'SKIP_UNQ_UNUSABLE_IDX'; -SKIP_UNUSABLE_INDEXES: 'SKIP_UNUSABLE_INDEXES'; -SMALLFILE: 'SMALLFILE'; -SMALLINT: 'SMALLINT'; -SNAPSHOT: 'SNAPSHOT'; -SOME: 'SOME'; -SORT: 'SORT'; -SOUNDEX: 'SOUNDEX'; -SOURCE_FILE_DIRECTORY: 'SOURCE_FILE_DIRECTORY'; -SOURCE_FILE_NAME_CONVERT: 'SOURCE_FILE_NAME_CONVERT'; -SOURCE: 'SOURCE'; -SPACE_KEYWORD: 'SPACE'; -SPECIFICATION: 'SPECIFICATION'; -SPFILE: 'SPFILE'; -SPLIT: 'SPLIT'; -SPREADSHEET: 'SPREADSHEET'; -SQLDATA: 'SQLDATA'; -SQLERROR: 'SQLERROR'; -SQLLDR: 'SQLLDR'; -SQL: 'SQL'; -FILE_EXT: 'PKB' | 'PKS'; -SQL_MACRO: 'SQL_MACRO'; -SQL_TRACE: 'SQL_TRACE'; -SQL_TRANSLATION_PROFILE: 'SQL_TRANSLATION_PROFILE'; -SQRT: 'SQRT'; -STALE: 'STALE'; -STANDALONE: 'STANDALONE'; -STANDARD: 'STANDARD'; -STANDARD_HASH: 'STANDARD_HASH'; -STANDBY_MAX_DATA_DELAY: 'STANDBY_MAX_DATA_DELAY'; -STANDBYS: 'STANDBYS'; -STANDBY: 'STANDBY'; -STAR: 'STAR'; -STAR_TRANSFORMATION: 'STAR_TRANSFORMATION'; -START: 'START'; -STARTUP: 'STARTUP'; -STATEMENT_ID: 'STATEMENT_ID'; -STATEMENT_QUEUING: 'STATEMENT_QUEUING'; -STATEMENTS: 'STATEMENTS'; -STATEMENT: 'STATEMENT'; -STATE: 'STATE'; -STATIC: 'STATIC'; -STATISTICS: 'STATISTICS'; -STATS_BINOMIAL_TEST: 'STATS_BINOMIAL_TEST'; -STATS_CROSSTAB: 'STATS_CROSSTAB'; -STATS_F_TEST: 'STATS_F_TEST'; -STATS_KS_TEST: 'STATS_KS_TEST'; -STATS_MODE: 'STATS_MODE'; -STATS_MW_TEST: 'STATS_MW_TEST'; -STATS_ONE_WAY_ANOVA: 'STATS_ONE_WAY_ANOVA'; -STATS_T_TEST_INDEP: 'STATS_T_TEST_INDEP'; -STATS_T_TEST_INDEPU: 'STATS_T_TEST_INDEPU'; -STATS_T_TEST_ONE: 'STATS_T_TEST_ONE'; -STATS_T_TEST_PAIRED: 'STATS_T_TEST_PAIRED'; -STATS_WSR_TEST: 'STATS_WSR_TEST'; -STDDEV_POP: 'STDDEV_POP'; -STDDEV_SAMP: 'STDDEV_SAMP'; -STOP: 'STOP'; -STORAGE: 'STORAGE'; -STORE: 'STORE'; -STREAMS: 'STREAMS'; -STREAM: 'STREAM'; -STRICT: 'STRICT'; -STRING: 'STRING'; -STRIPE_COLUMNS: 'STRIPE_COLUMNS'; -STRIPE_WIDTH: 'STRIPE_WIDTH'; -STRIP: 'STRIP'; -STRUCTURE: 'STRUCTURE'; -SUBMULTISET: 'SUBMULTISET'; -SUBPARTITION_REL: 'SUBPARTITION_REL'; -SUBPARTITIONS: 'SUBPARTITIONS'; -SUBPARTITION: 'SUBPARTITION'; -SUBQUERIES: 'SUBQUERIES'; -SUBQUERY_PRUNING: 'SUBQUERY_PRUNING'; -SUBSCRIBE: 'SUBSCRIBE'; -SUBSET: 'SUBSET'; -SUBSTITUTABLE: 'SUBSTITUTABLE'; -SUBSTR2: 'SUBSTR2'; -SUBSTR4: 'SUBSTR4'; -SUBSTRB: 'SUBSTRB'; -SUBSTRC: 'SUBSTRC'; -SUBTYPE: 'SUBTYPE'; -SUCCESSFUL: 'SUCCESSFUL'; -SUCCESS: 'SUCCESS'; -SUMMARY: 'SUMMARY'; -SUPPLEMENTAL: 'SUPPLEMENTAL'; -SUSPEND: 'SUSPEND'; -SWAP_JOIN_INPUTS: 'SWAP_JOIN_INPUTS'; -SWITCHOVER: 'SWITCHOVER'; -SWITCH: 'SWITCH'; -SYNCHRONOUS: 'SYNCHRONOUS'; -SYNC: 'SYNC'; -SYNONYM: 'SYNONYM'; -SYS: 'SYS'; -SYSASM: 'SYSASM'; -SYS_AUDIT: 'SYS_AUDIT'; -SYSAUX: 'SYSAUX'; -SYSBACKUP: 'SYSBACKUP'; -SYS_CHECKACL: 'SYS_CHECKACL'; -SYS_CHECK_PRIVILEGE: 'SYS_CHECK_PRIVILEGE'; -SYS_CONNECT_BY_PATH: 'SYS_CONNECT_BY_PATH'; -SYS_CONTEXT: 'SYS_CONTEXT'; -SYSDATE: 'SYSDATE'; -SYSDBA: 'SYSDBA'; -SYS_DBURIGEN: 'SYS_DBURIGEN'; -SYSDG: 'SYSDG'; -SYS_DL_CURSOR: 'SYS_DL_CURSOR'; -SYS_DM_RXFORM_CHR: 'SYS_DM_RXFORM_CHR'; -SYS_DM_RXFORM_NUM: 'SYS_DM_RXFORM_NUM'; -SYS_DOM_COMPARE: 'SYS_DOM_COMPARE'; -SYS_DST_PRIM2SEC: 'SYS_DST_PRIM2SEC'; -SYS_DST_SEC2PRIM: 'SYS_DST_SEC2PRIM'; -SYS_ET_BFILE_TO_RAW: 'SYS_ET_BFILE_TO_RAW'; -SYS_ET_BLOB_TO_IMAGE: 'SYS_ET_BLOB_TO_IMAGE'; -SYS_ET_IMAGE_TO_BLOB: 'SYS_ET_IMAGE_TO_BLOB'; -SYS_ET_RAW_TO_BFILE: 'SYS_ET_RAW_TO_BFILE'; -SYS_EXTPDTXT: 'SYS_EXTPDTXT'; -SYS_EXTRACT_UTC: 'SYS_EXTRACT_UTC'; -SYS_FBT_INSDEL: 'SYS_FBT_INSDEL'; -SYS_FILTER_ACLS: 'SYS_FILTER_ACLS'; -SYS_FNMATCHES: 'SYS_FNMATCHES'; -SYS_FNREPLACE: 'SYS_FNREPLACE'; -SYS_GET_ACLIDS: 'SYS_GET_ACLIDS'; -SYS_GET_COL_ACLIDS: 'SYS_GET_COL_ACLIDS'; -SYS_GET_PRIVILEGES: 'SYS_GET_PRIVILEGES'; -SYS_GETTOKENID: 'SYS_GETTOKENID'; -SYS_GETXTIVAL: 'SYS_GETXTIVAL'; -SYS_GUID: 'SYS_GUID'; -SYSGUID: 'SYSGUID'; -SYSKM: 'SYSKM'; -SYS_MAKE_XMLNODEID: 'SYS_MAKE_XMLNODEID'; -SYS_MAKEXML: 'SYS_MAKEXML'; -SYS_MKXMLATTR: 'SYS_MKXMLATTR'; -SYS_MKXTI: 'SYS_MKXTI'; -SYSOBJ: 'SYSOBJ'; -SYS_OP_ADT2BIN: 'SYS_OP_ADT2BIN'; -SYS_OP_ADTCONS: 'SYS_OP_ADTCONS'; -SYS_OP_ALSCRVAL: 'SYS_OP_ALSCRVAL'; -SYS_OP_ATG: 'SYS_OP_ATG'; -SYS_OP_BIN2ADT: 'SYS_OP_BIN2ADT'; -SYS_OP_BITVEC: 'SYS_OP_BITVEC'; -SYS_OP_BL2R: 'SYS_OP_BL2R'; -SYS_OP_BLOOM_FILTER_LIST: 'SYS_OP_BLOOM_FILTER_LIST'; -SYS_OP_BLOOM_FILTER: 'SYS_OP_BLOOM_FILTER'; -SYS_OP_C2C: 'SYS_OP_C2C'; -SYS_OP_CAST: 'SYS_OP_CAST'; -SYS_OP_CEG: 'SYS_OP_CEG'; -SYS_OP_CL2C: 'SYS_OP_CL2C'; -SYS_OP_COMBINED_HASH: 'SYS_OP_COMBINED_HASH'; -SYS_OP_COMP: 'SYS_OP_COMP'; -SYS_OP_CONVERT: 'SYS_OP_CONVERT'; -SYS_OP_COUNTCHG: 'SYS_OP_COUNTCHG'; -SYS_OP_CSCONV: 'SYS_OP_CSCONV'; -SYS_OP_CSCONVTEST: 'SYS_OP_CSCONVTEST'; -SYS_OP_CSR: 'SYS_OP_CSR'; -SYS_OP_CSX_PATCH: 'SYS_OP_CSX_PATCH'; -SYS_OP_CYCLED_SEQ: 'SYS_OP_CYCLED_SEQ'; -SYS_OP_DECOMP: 'SYS_OP_DECOMP'; -SYS_OP_DESCEND: 'SYS_OP_DESCEND'; -SYS_OP_DISTINCT: 'SYS_OP_DISTINCT'; -SYS_OP_DRA: 'SYS_OP_DRA'; -SYS_OP_DUMP: 'SYS_OP_DUMP'; -SYS_OP_DV_CHECK: 'SYS_OP_DV_CHECK'; -SYS_OP_ENFORCE_NOT_NULL: 'SYS_OP_ENFORCE_NOT_NULL$'; -SYSOPER: 'SYSOPER'; -SYS_OP_EXTRACT: 'SYS_OP_EXTRACT'; -SYS_OP_GROUPING: 'SYS_OP_GROUPING'; -SYS_OP_GUID: 'SYS_OP_GUID'; -SYS_OP_HASH: 'SYS_OP_HASH'; -SYS_OP_IIX: 'SYS_OP_IIX'; -SYS_OP_ITR: 'SYS_OP_ITR'; -SYS_OP_KEY_VECTOR_CREATE: 'SYS_OP_KEY_VECTOR_CREATE'; -SYS_OP_KEY_VECTOR_FILTER_LIST: 'SYS_OP_KEY_VECTOR_FILTER_LIST'; -SYS_OP_KEY_VECTOR_FILTER: 'SYS_OP_KEY_VECTOR_FILTER'; -SYS_OP_KEY_VECTOR_SUCCEEDED: 'SYS_OP_KEY_VECTOR_SUCCEEDED'; -SYS_OP_KEY_VECTOR_USE: 'SYS_OP_KEY_VECTOR_USE'; -SYS_OP_LBID: 'SYS_OP_LBID'; -SYS_OP_LOBLOC2BLOB: 'SYS_OP_LOBLOC2BLOB'; -SYS_OP_LOBLOC2CLOB: 'SYS_OP_LOBLOC2CLOB'; -SYS_OP_LOBLOC2ID: 'SYS_OP_LOBLOC2ID'; -SYS_OP_LOBLOC2NCLOB: 'SYS_OP_LOBLOC2NCLOB'; -SYS_OP_LOBLOC2TYP: 'SYS_OP_LOBLOC2TYP'; -SYS_OP_LSVI: 'SYS_OP_LSVI'; -SYS_OP_LVL: 'SYS_OP_LVL'; -SYS_OP_MAKEOID: 'SYS_OP_MAKEOID'; -SYS_OP_MAP_NONNULL: 'SYS_OP_MAP_NONNULL'; -SYS_OP_MSR: 'SYS_OP_MSR'; -SYS_OP_NICOMBINE: 'SYS_OP_NICOMBINE'; -SYS_OP_NIEXTRACT: 'SYS_OP_NIEXTRACT'; -SYS_OP_NII: 'SYS_OP_NII'; -SYS_OP_NIX: 'SYS_OP_NIX'; -SYS_OP_NOEXPAND: 'SYS_OP_NOEXPAND'; -SYS_OP_NTCIMG: 'SYS_OP_NTCIMG$'; -SYS_OP_NUMTORAW: 'SYS_OP_NUMTORAW'; -SYS_OP_OIDVALUE: 'SYS_OP_OIDVALUE'; -SYS_OP_OPNSIZE: 'SYS_OP_OPNSIZE'; -SYS_OP_PAR_1: 'SYS_OP_PAR_1'; -SYS_OP_PARGID_1: 'SYS_OP_PARGID_1'; -SYS_OP_PARGID: 'SYS_OP_PARGID'; -SYS_OP_PAR: 'SYS_OP_PAR'; -SYS_OP_PART_ID: 'SYS_OP_PART_ID'; -SYS_OP_PIVOT: 'SYS_OP_PIVOT'; -SYS_OP_R2O: 'SYS_OP_R2O'; -SYS_OP_RAWTONUM: 'SYS_OP_RAWTONUM'; -SYS_OP_RDTM: 'SYS_OP_RDTM'; -SYS_OP_REF: 'SYS_OP_REF'; -SYS_OP_RMTD: 'SYS_OP_RMTD'; -SYS_OP_ROWIDTOOBJ: 'SYS_OP_ROWIDTOOBJ'; -SYS_OP_RPB: 'SYS_OP_RPB'; -SYS_OPTLOBPRBSC: 'SYS_OPTLOBPRBSC'; -SYS_OP_TOSETID: 'SYS_OP_TOSETID'; -SYS_OP_TPR: 'SYS_OP_TPR'; -SYS_OP_TRTB: 'SYS_OP_TRTB'; -SYS_OPTXICMP: 'SYS_OPTXICMP'; -SYS_OPTXQCASTASNQ: 'SYS_OPTXQCASTASNQ'; -SYS_OP_UNDESCEND: 'SYS_OP_UNDESCEND'; -SYS_OP_VECAND: 'SYS_OP_VECAND'; -SYS_OP_VECBIT: 'SYS_OP_VECBIT'; -SYS_OP_VECOR: 'SYS_OP_VECOR'; -SYS_OP_VECXOR: 'SYS_OP_VECXOR'; -SYS_OP_VERSION: 'SYS_OP_VERSION'; -SYS_OP_VREF: 'SYS_OP_VREF'; -SYS_OP_VVD: 'SYS_OP_VVD'; -SYS_OP_XMLCONS_FOR_CSX: 'SYS_OP_XMLCONS_FOR_CSX'; -SYS_OP_XPTHATG: 'SYS_OP_XPTHATG'; -SYS_OP_XPTHIDX: 'SYS_OP_XPTHIDX'; -SYS_OP_XPTHOP: 'SYS_OP_XPTHOP'; -SYS_OP_XTXT2SQLT: 'SYS_OP_XTXT2SQLT'; -SYS_OP_ZONE_ID: 'SYS_OP_ZONE_ID'; -SYS_ORDERKEY_DEPTH: 'SYS_ORDERKEY_DEPTH'; -SYS_ORDERKEY_MAXCHILD: 'SYS_ORDERKEY_MAXCHILD'; -SYS_ORDERKEY_PARENT: 'SYS_ORDERKEY_PARENT'; -SYS_PARALLEL_TXN: 'SYS_PARALLEL_TXN'; -SYS_PATHID_IS_ATTR: 'SYS_PATHID_IS_ATTR'; -SYS_PATHID_IS_NMSPC: 'SYS_PATHID_IS_NMSPC'; -SYS_PATHID_LASTNAME: 'SYS_PATHID_LASTNAME'; -SYS_PATHID_LASTNMSPC: 'SYS_PATHID_LASTNMSPC'; -SYS_PATH_REVERSE: 'SYS_PATH_REVERSE'; -SYS_PXQEXTRACT: 'SYS_PXQEXTRACT'; -SYS_RAW_TO_XSID: 'SYS_RAW_TO_XSID'; -SYS_RID_ORDER: 'SYS_RID_ORDER'; -SYS_ROW_DELTA: 'SYS_ROW_DELTA'; -SYS_SC_2_XMLT: 'SYS_SC_2_XMLT'; -SYS_SYNRCIREDO: 'SYS_SYNRCIREDO'; -SYSTEM_DEFINED: 'SYSTEM_DEFINED'; -SYSTEM: 'SYSTEM'; -SYSTIMESTAMP: 'SYSTIMESTAMP'; -SYS_TYPEID: 'SYS_TYPEID'; -SYS_UMAKEXML: 'SYS_UMAKEXML'; -SYS_XMLANALYZE: 'SYS_XMLANALYZE'; -SYS_XMLCONTAINS: 'SYS_XMLCONTAINS'; -SYS_XMLCONV: 'SYS_XMLCONV'; -SYS_XMLEXNSURI: 'SYS_XMLEXNSURI'; -SYS_XMLGEN: 'SYS_XMLGEN'; -SYS_XMLI_LOC_ISNODE: 'SYS_XMLI_LOC_ISNODE'; -SYS_XMLI_LOC_ISTEXT: 'SYS_XMLI_LOC_ISTEXT'; -SYS_XMLINSTR: 'SYS_XMLINSTR'; -SYS_XMLLOCATOR_GETSVAL: 'SYS_XMLLOCATOR_GETSVAL'; -SYS_XMLNODEID_GETCID: 'SYS_XMLNODEID_GETCID'; -SYS_XMLNODEID_GETLOCATOR: 'SYS_XMLNODEID_GETLOCATOR'; -SYS_XMLNODEID_GETOKEY: 'SYS_XMLNODEID_GETOKEY'; -SYS_XMLNODEID_GETPATHID: 'SYS_XMLNODEID_GETPATHID'; -SYS_XMLNODEID_GETPTRID: 'SYS_XMLNODEID_GETPTRID'; -SYS_XMLNODEID_GETRID: 'SYS_XMLNODEID_GETRID'; -SYS_XMLNODEID_GETSVAL: 'SYS_XMLNODEID_GETSVAL'; -SYS_XMLNODEID_GETTID: 'SYS_XMLNODEID_GETTID'; -SYS_XMLNODEID: 'SYS_XMLNODEID'; -SYS_XMLT_2_SC: 'SYS_XMLT_2_SC'; -SYS_XMLTRANSLATE: 'SYS_XMLTRANSLATE'; -SYS_XMLTYPE2SQL: 'SYS_XMLTYPE2SQL'; -SYS_XQ_ASQLCNV: 'SYS_XQ_ASQLCNV'; -SYS_XQ_ATOMCNVCHK: 'SYS_XQ_ATOMCNVCHK'; -SYS_XQBASEURI: 'SYS_XQBASEURI'; -SYS_XQCASTABLEERRH: 'SYS_XQCASTABLEERRH'; -SYS_XQCODEP2STR: 'SYS_XQCODEP2STR'; -SYS_XQCODEPEQ: 'SYS_XQCODEPEQ'; -SYS_XQCON2SEQ: 'SYS_XQCON2SEQ'; -SYS_XQCONCAT: 'SYS_XQCONCAT'; -SYS_XQDELETE: 'SYS_XQDELETE'; -SYS_XQDFLTCOLATION: 'SYS_XQDFLTCOLATION'; -SYS_XQDOC: 'SYS_XQDOC'; -SYS_XQDOCURI: 'SYS_XQDOCURI'; -SYS_XQDURDIV: 'SYS_XQDURDIV'; -SYS_XQED4URI: 'SYS_XQED4URI'; -SYS_XQENDSWITH: 'SYS_XQENDSWITH'; -SYS_XQERRH: 'SYS_XQERRH'; -SYS_XQERR: 'SYS_XQERR'; -SYS_XQESHTMLURI: 'SYS_XQESHTMLURI'; -SYS_XQEXLOBVAL: 'SYS_XQEXLOBVAL'; -SYS_XQEXSTWRP: 'SYS_XQEXSTWRP'; -SYS_XQEXTRACT: 'SYS_XQEXTRACT'; -SYS_XQEXTRREF: 'SYS_XQEXTRREF'; -SYS_XQEXVAL: 'SYS_XQEXVAL'; -SYS_XQFB2STR: 'SYS_XQFB2STR'; -SYS_XQFNBOOL: 'SYS_XQFNBOOL'; -SYS_XQFNCMP: 'SYS_XQFNCMP'; -SYS_XQFNDATIM: 'SYS_XQFNDATIM'; -SYS_XQFNLNAME: 'SYS_XQFNLNAME'; -SYS_XQFNNM: 'SYS_XQFNNM'; -SYS_XQFNNSURI: 'SYS_XQFNNSURI'; -SYS_XQFNPREDTRUTH: 'SYS_XQFNPREDTRUTH'; -SYS_XQFNQNM: 'SYS_XQFNQNM'; -SYS_XQFNROOT: 'SYS_XQFNROOT'; -SYS_XQFORMATNUM: 'SYS_XQFORMATNUM'; -SYS_XQFTCONTAIN: 'SYS_XQFTCONTAIN'; -SYS_XQFUNCR: 'SYS_XQFUNCR'; -SYS_XQGETCONTENT: 'SYS_XQGETCONTENT'; -SYS_XQINDXOF: 'SYS_XQINDXOF'; -SYS_XQINSERT: 'SYS_XQINSERT'; -SYS_XQINSPFX: 'SYS_XQINSPFX'; -SYS_XQIRI2URI: 'SYS_XQIRI2URI'; -SYS_XQLANG: 'SYS_XQLANG'; -SYS_XQLLNMFRMQNM: 'SYS_XQLLNMFRMQNM'; -SYS_XQMKNODEREF: 'SYS_XQMKNODEREF'; -SYS_XQNILLED: 'SYS_XQNILLED'; -SYS_XQNODENAME: 'SYS_XQNODENAME'; -SYS_XQNORMSPACE: 'SYS_XQNORMSPACE'; -SYS_XQNORMUCODE: 'SYS_XQNORMUCODE'; -SYS_XQ_NRNG: 'SYS_XQ_NRNG'; -SYS_XQNSP4PFX: 'SYS_XQNSP4PFX'; -SYS_XQNSPFRMQNM: 'SYS_XQNSPFRMQNM'; -SYS_XQPFXFRMQNM: 'SYS_XQPFXFRMQNM'; -SYS_XQ_PKSQL2XML: 'SYS_XQ_PKSQL2XML'; -SYS_XQPOLYABS: 'SYS_XQPOLYABS'; -SYS_XQPOLYADD: 'SYS_XQPOLYADD'; -SYS_XQPOLYCEL: 'SYS_XQPOLYCEL'; -SYS_XQPOLYCSTBL: 'SYS_XQPOLYCSTBL'; -SYS_XQPOLYCST: 'SYS_XQPOLYCST'; -SYS_XQPOLYDIV: 'SYS_XQPOLYDIV'; -SYS_XQPOLYFLR: 'SYS_XQPOLYFLR'; -SYS_XQPOLYMOD: 'SYS_XQPOLYMOD'; -SYS_XQPOLYMUL: 'SYS_XQPOLYMUL'; -SYS_XQPOLYRND: 'SYS_XQPOLYRND'; -SYS_XQPOLYSQRT: 'SYS_XQPOLYSQRT'; -SYS_XQPOLYSUB: 'SYS_XQPOLYSUB'; -SYS_XQPOLYUMUS: 'SYS_XQPOLYUMUS'; -SYS_XQPOLYUPLS: 'SYS_XQPOLYUPLS'; -SYS_XQPOLYVEQ: 'SYS_XQPOLYVEQ'; -SYS_XQPOLYVGE: 'SYS_XQPOLYVGE'; -SYS_XQPOLYVGT: 'SYS_XQPOLYVGT'; -SYS_XQPOLYVLE: 'SYS_XQPOLYVLE'; -SYS_XQPOLYVLT: 'SYS_XQPOLYVLT'; -SYS_XQPOLYVNE: 'SYS_XQPOLYVNE'; -SYS_XQREF2VAL: 'SYS_XQREF2VAL'; -SYS_XQRENAME: 'SYS_XQRENAME'; -SYS_XQREPLACE: 'SYS_XQREPLACE'; -SYS_XQRESVURI: 'SYS_XQRESVURI'; -SYS_XQRNDHALF2EVN: 'SYS_XQRNDHALF2EVN'; -SYS_XQRSLVQNM: 'SYS_XQRSLVQNM'; -SYS_XQRYENVPGET: 'SYS_XQRYENVPGET'; -SYS_XQRYVARGET: 'SYS_XQRYVARGET'; -SYS_XQRYWRP: 'SYS_XQRYWRP'; -SYS_XQSEQ2CON4XC: 'SYS_XQSEQ2CON4XC'; -SYS_XQSEQ2CON: 'SYS_XQSEQ2CON'; -SYS_XQSEQDEEPEQ: 'SYS_XQSEQDEEPEQ'; -SYS_XQSEQINSB: 'SYS_XQSEQINSB'; -SYS_XQSEQRM: 'SYS_XQSEQRM'; -SYS_XQSEQRVS: 'SYS_XQSEQRVS'; -SYS_XQSEQSUB: 'SYS_XQSEQSUB'; -SYS_XQSEQTYPMATCH: 'SYS_XQSEQTYPMATCH'; -SYS_XQSTARTSWITH: 'SYS_XQSTARTSWITH'; -SYS_XQSTATBURI: 'SYS_XQSTATBURI'; -SYS_XQSTR2CODEP: 'SYS_XQSTR2CODEP'; -SYS_XQSTRJOIN: 'SYS_XQSTRJOIN'; -SYS_XQSUBSTRAFT: 'SYS_XQSUBSTRAFT'; -SYS_XQSUBSTRBEF: 'SYS_XQSUBSTRBEF'; -SYS_XQTOKENIZE: 'SYS_XQTOKENIZE'; -SYS_XQTREATAS: 'SYS_XQTREATAS'; -SYS_XQ_UPKXML2SQL: 'SYS_XQ_UPKXML2SQL'; -SYS_XQXFORM: 'SYS_XQXFORM'; -SYS_XSID_TO_RAW: 'SYS_XSID_TO_RAW'; -SYS_ZMAP_FILTER: 'SYS_ZMAP_FILTER'; -SYS_ZMAP_REFRESH: 'SYS_ZMAP_REFRESH'; -T_LETTER: 'T'; -TABLE_LOOKUP_BY_NL: 'TABLE_LOOKUP_BY_NL'; -TABLESPACE_NO: 'TABLESPACE_NO'; -TABLESPACE: 'TABLESPACE'; -TABLES: 'TABLES'; -TABLE_STATS: 'TABLE_STATS'; -TABLE: 'TABLE'; -TABNO: 'TABNO'; -TAG: 'TAG'; -TANH: 'TANH'; -TAN: 'TAN'; -TBLORIDXPARTNUM: 'TBL$OR$IDX$PART$NUM'; -TEMPFILE: 'TEMPFILE'; -TEMPLATE: 'TEMPLATE'; -TEMPORARY: 'TEMPORARY'; -TEMP_TABLE: 'TEMP_TABLE'; -TEST: 'TEST'; -TEXT: 'TEXT'; -THAN: 'THAN'; -THEN: 'THEN'; -THE: 'THE'; -THREAD: 'THREAD'; -THROUGH: 'THROUGH'; -TIER: 'TIER'; -TIES: 'TIES'; -TIMEOUT: 'TIMEOUT'; -TIMESTAMP_LTZ_UNCONSTRAINED: 'TIMESTAMP_LTZ_UNCONSTRAINED'; -TIMESTAMP: 'TIMESTAMP'; -TIMESTAMP_TZ_UNCONSTRAINED: 'TIMESTAMP_TZ_UNCONSTRAINED'; -TIMESTAMP_UNCONSTRAINED: 'TIMESTAMP_UNCONSTRAINED'; -TIMES: 'TIMES'; -TIME: 'TIME'; -TIMEZONE: 'TIMEZONE'; -TIMEZONE_ABBR: 'TIMEZONE_ABBR'; -TIMEZONE_HOUR: 'TIMEZONE_HOUR'; -TIMEZONE_MINUTE: 'TIMEZONE_MINUTE'; -TIMEZONE_OFFSET: 'TIMEZONE_OFFSET'; -TIMEZONE_REGION: 'TIMEZONE_REGION'; -TIME_ZONE: 'TIME_ZONE'; -TIMING: 'TIMING'; -TIV_GB: 'TIV_GB'; -TIV_SSF: 'TIV_SSF'; -TO_ACLID: 'TO_ACLID'; -TO_BINARY_DOUBLE: 'TO_BINARY_DOUBLE'; -TO_BINARY_FLOAT: 'TO_BINARY_FLOAT'; -TO_BLOB: 'TO_BLOB'; -TO_CLOB: 'TO_CLOB'; -TO_DSINTERVAL: 'TO_DSINTERVAL'; -TO_LOB: 'TO_LOB'; -TO_MULTI_BYTE: 'TO_MULTI_BYTE'; -TO_NCHAR: 'TO_NCHAR'; -TO_NCLOB: 'TO_NCLOB'; -TO_NUMBER: 'TO_NUMBER'; -TOPLEVEL: 'TOPLEVEL'; -TO_SINGLE_BYTE: 'TO_SINGLE_BYTE'; -TO_TIMESTAMP: 'TO_TIMESTAMP'; -TO_TIMESTAMP_TZ: 'TO_TIMESTAMP_TZ'; -TO_TIME: 'TO_TIME'; -TO_TIME_TZ: 'TO_TIME_TZ'; -TO: 'TO'; -TO_YMINTERVAL: 'TO_YMINTERVAL'; -TRACE: 'TRACE'; -TRACING: 'TRACING'; -TRACKING: 'TRACKING'; -TRAILING: 'TRAILING'; -TRANSACTION: 'TRANSACTION'; -TRANSFORM: 'TRANSFORM'; -TRANSFORM_DISTINCT_AGG: 'TRANSFORM_DISTINCT_AGG'; -TRANSITIONAL: 'TRANSITIONAL'; -TRANSITION: 'TRANSITION'; -TRANSLATE: 'TRANSLATE'; -TRANSLATION: 'TRANSLATION'; -TREAT: 'TREAT'; -TRIGGERS: 'TRIGGERS'; -TRIGGER: 'TRIGGER'; -TRUE: 'TRUE'; -TRUNCATE: 'TRUNCATE'; -TRUNC: 'TRUNC'; -TRUSTED: 'TRUSTED'; -TRUST: 'TRUST'; -TUNING: 'TUNING'; -TX: 'TX'; -TYPES: 'TYPES'; -TYPE: 'TYPE'; -TZ_OFFSET: 'TZ_OFFSET'; -UB2: 'UB2'; -UBA: 'UBA'; -UCS2: 'UCS2'; -UID: 'UID'; -UNARCHIVED: 'UNARCHIVED'; -UNBOUNDED: 'UNBOUNDED'; -UNBOUND: 'UNBOUND'; -UNCONDITIONAL: 'UNCONDITIONAL'; -UNDER: 'UNDER'; -UNDO: 'UNDO'; -UNDROP: 'UNDROP'; -UNIFORM: 'UNIFORM'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; -UNISTR: 'UNISTR'; -UNLIMITED: 'UNLIMITED'; -UNLOAD: 'UNLOAD'; -UNLOCK: 'UNLOCK'; -UNMATCHED: 'UNMATCHED'; -UNNEST_INNERJ_DISTINCT_VIEW: 'UNNEST_INNERJ_DISTINCT_VIEW'; -UNNEST_NOSEMIJ_NODISTINCTVIEW: 'UNNEST_NOSEMIJ_NODISTINCTVIEW'; -UNNEST_SEMIJ_VIEW: 'UNNEST_SEMIJ_VIEW'; -UNNEST: 'UNNEST'; -UNPACKED: 'UNPACKED'; -UNPIVOT: 'UNPIVOT'; -UNPLUG: 'UNPLUG'; -UNPROTECTED: 'UNPROTECTED'; -UNQUIESCE: 'UNQUIESCE'; -UNRECOVERABLE: 'UNRECOVERABLE'; -UNRESTRICTED: 'UNRESTRICTED'; -UNSUBSCRIBE: 'UNSUBSCRIBE'; -UNTIL: 'UNTIL'; -UNUSABLE: 'UNUSABLE'; -UNUSED: 'UNUSED'; -UPDATABLE: 'UPDATABLE'; -UPDATED: 'UPDATED'; -UPDATE: 'UPDATE'; -UPDATEXML: 'UPDATEXML'; -UPD_INDEXES: 'UPD_INDEXES'; -UPD_JOININDEX: 'UPD_JOININDEX'; -UPGRADE: 'UPGRADE'; -UPPER: 'UPPER'; -UPSERT: 'UPSERT'; -UROWID: 'UROWID'; -USABLE: 'USABLE'; -USAGE: 'USAGE'; -USE_ANTI: 'USE_ANTI'; -USE_CONCAT: 'USE_CONCAT'; -USE_CUBE: 'USE_CUBE'; -USE_HASH_AGGREGATION: 'USE_HASH_AGGREGATION'; -USE_HASH_GBY_FOR_PUSHDOWN: 'USE_HASH_GBY_FOR_PUSHDOWN'; -USE_HASH: 'USE_HASH'; -USE_HIDDEN_PARTITIONS: 'USE_HIDDEN_PARTITIONS'; -USE_INVISIBLE_INDEXES: 'USE_INVISIBLE_INDEXES'; -USE_MERGE_CARTESIAN: 'USE_MERGE_CARTESIAN'; -USE_MERGE: 'USE_MERGE'; -USE_NL: 'USE_NL'; -USE_NL_WITH_INDEX: 'USE_NL_WITH_INDEX'; -USE_PRIVATE_OUTLINES: 'USE_PRIVATE_OUTLINES'; -USER_DATA: 'USER_DATA'; -USER_DEFINED: 'USER_DEFINED'; -USERENV: 'USERENV'; -USERGROUP: 'USERGROUP'; -USER_RECYCLEBIN: 'USER_RECYCLEBIN'; -USERS: 'USERS'; -USER_TABLESPACES: 'USER_TABLESPACES'; -USER: 'USER'; -USE_SEMI: 'USE_SEMI'; -USE_STORED_OUTLINES: 'USE_STORED_OUTLINES'; -USE_TTT_FOR_GSETS: 'USE_TTT_FOR_GSETS'; -USE: 'USE'; -USE_VECTOR_AGGREGATION: 'USE_VECTOR_AGGREGATION'; -USE_WEAK_NAME_RESL: 'USE_WEAK_NAME_RESL'; -USING_NO_EXPAND: 'USING_NO_EXPAND'; -USING: 'USING'; -UTF16BE: 'UTF16BE'; -UTF16LE: 'UTF16LE'; -UTF32: 'UTF32'; -UTF8: 'UTF8'; -V1: 'V1'; -V2: 'V2'; -VALIDATE: 'VALIDATE'; -VALIDATE_CONVERSION: 'VALIDATE_CONVERSION'; -VALIDATION: 'VALIDATION'; -VALID_TIME_END: 'VALID_TIME_END'; -VALUES: 'VALUES'; -VALUE: 'VALUE'; -VARCHAR2: 'VARCHAR2'; -VARCHAR: 'VARCHAR'; -VARIABLE: 'VARIABLE'; -VAR_POP: 'VAR_POP'; -VARRAYS: 'VARRAYS'; -VARRAY: 'VARRAY'; -VAR_SAMP: 'VAR_SAMP'; -VARYING: 'VARYING'; -VECTOR_READ_TRACE: 'VECTOR_READ_TRACE'; -VECTOR_READ: 'VECTOR_READ'; -VECTOR_TRANSFORM_DIMS: 'VECTOR_TRANSFORM_DIMS'; -VECTOR_TRANSFORM_FACT: 'VECTOR_TRANSFORM_FACT'; -VECTOR_TRANSFORM: 'VECTOR_TRANSFORM'; -VERIFIER: 'VERIFIER'; -VERIFY: 'VERIFY'; -VERSIONING: 'VERSIONING'; -VERSIONS_ENDSCN: 'VERSIONS_ENDSCN'; -VERSIONS_ENDTIME: 'VERSIONS_ENDTIME'; -VERSIONS_OPERATION: 'VERSIONS_OPERATION'; -VERSIONS_STARTSCN: 'VERSIONS_STARTSCN'; -VERSIONS_STARTTIME: 'VERSIONS_STARTTIME'; -VERSIONS: 'VERSIONS'; -VERSIONS_XID: 'VERSIONS_XID'; -VERSION: 'VERSION'; -VIEW: 'VIEW'; -VIOLATION: 'VIOLATION'; -VIRTUAL: 'VIRTUAL'; -VISIBILITY: 'VISIBILITY'; -VISIBLE: 'VISIBLE'; -VOLUME: 'VOLUME'; -VSIZE: 'VSIZE'; -WAIT: 'WAIT'; -WALLET: 'WALLET'; -WARNING: 'WARNING'; -WEEKS: 'WEEKS'; -WEEK: 'WEEK'; -WELLFORMED: 'WELLFORMED'; -WHENEVER: 'WHENEVER'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WHILE: 'WHILE'; -WHITESPACE: 'WHITESPACE'; -WIDTH_BUCKET: 'WIDTH_BUCKET'; -WITHIN: 'WITHIN'; -WITHOUT: 'WITHOUT'; -WITH_PLSQL: 'WITH_PLSQL'; -WITH: 'WITH'; -WORK: 'WORK'; -WRAPPED: 'WRAPPED'; -WRAPPER: 'WRAPPER'; -WRITE: 'WRITE'; -XDB_FASTPATH_INSERT: 'XDB_FASTPATH_INSERT'; -XDB: 'XDB'; -X_DYN_PRUNE: 'X_DYN_PRUNE'; -XID: 'XID'; -XML2OBJECT: 'XML2OBJECT'; -XMLAGG: 'XMLAGG'; -XMLATTRIBUTES: 'XMLATTRIBUTES'; -XMLCAST: 'XMLCAST'; -XMLCDATA: 'XMLCDATA'; -XMLCOLATTVAL: 'XMLCOLATTVAL'; -XMLCOMMENT: 'XMLCOMMENT'; -XMLCONCAT: 'XMLCONCAT'; -XMLDIFF: 'XMLDIFF'; -XML_DML_RWT_STMT: 'XML_DML_RWT_STMT'; -XMLELEMENT: 'XMLELEMENT'; -XMLEXISTS2: 'XMLEXISTS2'; -XMLEXISTS: 'XMLEXISTS'; -XMLFOREST: 'XMLFOREST'; -XMLINDEX: 'XMLINDEX'; -XMLINDEX_REWRITE_IN_SELECT: 'XMLINDEX_REWRITE_IN_SELECT'; -XMLINDEX_REWRITE: 'XMLINDEX_REWRITE'; -XMLINDEX_SEL_IDX_TBL: 'XMLINDEX_SEL_IDX_TBL'; -XMLISNODE: 'XMLISNODE'; -XMLISVALID: 'XMLISVALID'; -XMLNAMESPACES: 'XMLNAMESPACES'; -XMLPARSE: 'XMLPARSE'; -XMLPATCH: 'XMLPATCH'; -XMLPI: 'XMLPI'; -XMLQUERYVAL: 'XMLQUERYVAL'; -XMLQUERY: 'XMLQUERY'; -XMLROOT: 'XMLROOT'; -XMLSCHEMA: 'XMLSCHEMA'; -XMLSERIALIZE: 'XMLSERIALIZE'; -XMLTABLE: 'XMLTABLE'; -XMLTRANSFORMBLOB: 'XMLTRANSFORMBLOB'; -XMLTRANSFORM: 'XMLTRANSFORM'; -XMLTYPE: 'XMLTYPE'; -XML: 'XML'; -XPATHTABLE: 'XPATHTABLE'; -XS_SYS_CONTEXT: 'XS_SYS_CONTEXT'; -XS: 'XS'; -XTRANSPORT: 'XTRANSPORT'; -YEARS: 'YEARS'; -YEAR: 'YEAR'; -YES: 'YES'; -YMINTERVAL_UNCONSTRAINED: 'YMINTERVAL_UNCONSTRAINED'; -ZONEMAP: 'ZONEMAP'; -ZONE: 'ZONE'; -PREDICTION: 'PREDICTION'; -PREDICTION_BOUNDS: 'PREDICTION_BOUNDS'; -PREDICTION_COST: 'PREDICTION_COST'; -PREDICTION_DETAILS: 'PREDICTION_DETAILS'; -PREDICTION_PROBABILITY: 'PREDICTION_PROBABILITY'; -PREDICTION_SET: 'PREDICTION_SET'; +ABORT : 'ABORT'; +ABS : 'ABS'; +ABSENT : 'ABSENT'; +ACCESS : 'ACCESS'; +ACCESSED : 'ACCESSED'; +ACCOUNT : 'ACCOUNT'; +ACL : 'ACL'; +ACOS : 'ACOS'; +ACROSS : 'ACROSS'; +ACTION : 'ACTION'; +ACTIONS : 'ACTIONS'; +ACTIVATE : 'ACTIVATE'; +ACTIVE : 'ACTIVE'; +ACTIVE_COMPONENT : 'ACTIVE_COMPONENT'; +ACTIVE_DATA : 'ACTIVE_DATA'; +ACTIVE_FUNCTION : 'ACTIVE_FUNCTION'; +ACTIVE_TAG : 'ACTIVE_TAG'; +ACTIVITY : 'ACTIVITY'; +ADAPTIVE_PLAN : 'ADAPTIVE_PLAN'; +ADD : 'ADD'; +ADD_COLUMN : 'ADD_COLUMN'; +ADD_GROUP : 'ADD_GROUP'; +ADD_MONTHS : 'ADD_MONTHS'; +ADJ_DATE : 'ADJ_DATE'; +ADMIN : 'ADMIN'; +ADMINISTER : 'ADMINISTER'; +ADMINISTRATOR : 'ADMINISTRATOR'; +ADVANCED : 'ADVANCED'; +ADVISE : 'ADVISE'; +ADVISOR : 'ADVISOR'; +AFD_DISKSTRING : 'AFD_DISKSTRING'; +AFTER : 'AFTER'; +AGENT : 'AGENT'; +AGGREGATE : 'AGGREGATE'; +A_LETTER : 'A'; +ALIAS : 'ALIAS'; +ALL : 'ALL'; +ALLOCATE : 'ALLOCATE'; +ALLOW : 'ALLOW'; +ALL_ROWS : 'ALL_ROWS'; +ALTER : 'ALTER'; +ALTERNATE : 'ALTERNATE'; +ALWAYS : 'ALWAYS'; +ANALYTIC : 'ANALYTIC'; +ANALYZE : 'ANALYZE'; +ANCESTOR : 'ANCESTOR'; +ANCILLARY : 'ANCILLARY'; +AND : 'AND'; +AND_EQUAL : 'AND_EQUAL'; +ANOMALY : 'ANOMALY'; +ANSI_REARCH : 'ANSI_REARCH'; +ANTIJOIN : 'ANTIJOIN'; +ANY : 'ANY'; +ANYSCHEMA : 'ANYSCHEMA'; +APPEND : 'APPEND'; +APPENDCHILDXML : 'APPENDCHILDXML'; +APPEND_VALUES : 'APPEND_VALUES'; +APPLICATION : 'APPLICATION'; +APPLY : 'APPLY'; +APPROX_COUNT_DISTINCT : 'APPROX_COUNT_DISTINCT'; +ARCHIVAL : 'ARCHIVAL'; +ARCHIVE : 'ARCHIVE'; +ARCHIVED : 'ARCHIVED'; +ARCHIVELOG : 'ARCHIVELOG'; +ARRAY : 'ARRAY'; +AS : 'AS'; +ASC : 'ASC'; +ASCII : 'ASCII'; +ASCIISTR : 'ASCIISTR'; +ASIN : 'ASIN'; +ASIS : 'ASIS'; +ASSEMBLY : 'ASSEMBLY'; +ASSIGN : 'ASSIGN'; +ASSOCIATE : 'ASSOCIATE'; +ASYNC : 'ASYNC'; +ASYNCHRONOUS : 'ASYNCHRONOUS'; +ATAN2 : 'ATAN2'; +ATAN : 'ATAN'; +AT : 'AT'; +ATTRIBUTE : 'ATTRIBUTE'; +ATTRIBUTES : 'ATTRIBUTES'; +AUDIT : 'AUDIT'; +AUTHENTICATED : 'AUTHENTICATED'; +AUTHENTICATION : 'AUTHENTICATION'; +AUTHID : 'AUTHID'; +AUTHORIZATION : 'AUTHORIZATION'; +AUTOALLOCATE : 'AUTOALLOCATE'; +AUTO : 'AUTO'; +AUTOBACKUP : 'AUTOBACKUP'; +AUTOEXTEND : 'AUTOEXTEND'; +AUTO_LOGIN : 'AUTO_LOGIN'; +AUTOMATIC : 'AUTOMATIC'; +AUTONOMOUS_TRANSACTION : 'AUTONOMOUS_TRANSACTION'; +AUTO_REOPTIMIZE : 'AUTO_REOPTIMIZE'; +AVAILABILITY : 'AVAILABILITY'; +AVRO : 'AVRO'; +BACKGROUND : 'BACKGROUND'; +BACKINGFILE : 'BACKINGFILE'; +BACKUP : 'BACKUP'; +BACKUPS : 'BACKUPS'; +BACKUPSET : 'BACKUPSET'; +BASIC : 'BASIC'; +BASICFILE : 'BASICFILE'; +BATCH : 'BATCH'; +BATCHSIZE : 'BATCHSIZE'; +BATCH_TABLE_ACCESS_BY_ROWID : 'BATCH_TABLE_ACCESS_BY_ROWID'; +BECOME : 'BECOME'; +BEFORE : 'BEFORE'; +BEGIN : 'BEGIN'; +BEGINNING : 'BEGINNING'; +BEGIN_OUTLINE_DATA : 'BEGIN_OUTLINE_DATA'; +BEHALF : 'BEHALF'; +BEQUEATH : 'BEQUEATH'; +BETWEEN : 'BETWEEN'; +BFILE : 'BFILE'; +BFILENAME : 'BFILENAME'; +BIGFILE : 'BIGFILE'; +BINARY : 'BINARY'; +BINARY_DOUBLE : 'BINARY_DOUBLE'; +BINARY_DOUBLE_INFINITY : 'BINARY_DOUBLE_INFINITY'; +BINARY_DOUBLE_NAN : 'BINARY_DOUBLE_NAN'; +BINARY_FLOAT : 'BINARY_FLOAT'; +BINARY_FLOAT_INFINITY : 'BINARY_FLOAT_INFINITY'; +BINARY_FLOAT_NAN : 'BINARY_FLOAT_NAN'; +BINARY_INTEGER : 'BINARY_INTEGER'; +BIND_AWARE : 'BIND_AWARE'; +BINDING : 'BINDING'; +BIN_TO_NUM : 'BIN_TO_NUM'; +BITAND : 'BITAND'; +BITMAP_AND : 'BITMAP_AND'; +BITMAP : 'BITMAP'; +BITMAPS : 'BITMAPS'; +BITMAP_TREE : 'BITMAP_TREE'; +BITS : 'BITS'; +BLOB : 'BLOB'; +BLOCK : 'BLOCK'; +BLOCK_RANGE : 'BLOCK_RANGE'; +BLOCKS : 'BLOCKS'; +BLOCKSIZE : 'BLOCKSIZE'; +BODY : 'BODY'; +BOOLEAN : 'BOOLEAN'; +BOTH : 'BOTH'; +BOUND : 'BOUND'; +BRANCH : 'BRANCH'; +BREADTH : 'BREADTH'; +BROADCAST : 'BROADCAST'; +BSON : 'BSON'; +BUFFER : 'BUFFER'; +BUFFER_CACHE : 'BUFFER_CACHE'; +BUFFER_POOL : 'BUFFER_POOL'; +BUILD : 'BUILD'; +BULK : 'BULK'; +BY : 'BY'; +BYPASS_RECURSIVE_CHECK : 'BYPASS_RECURSIVE_CHECK'; +BYPASS_UJVC : 'BYPASS_UJVC'; +BYTE : 'BYTE'; +CACHE : 'CACHE'; +CACHE_CB : 'CACHE_CB'; +CACHE_INSTANCES : 'CACHE_INSTANCES'; +CACHE_TEMP_TABLE : 'CACHE_TEMP_TABLE'; +CACHING : 'CACHING'; +CALCULATED : 'CALCULATED'; +CALLBACK : 'CALLBACK'; +CALL : 'CALL'; +CANCEL : 'CANCEL'; +CANONICAL : 'CANONICAL'; +CAPACITY : 'CAPACITY'; +CAPTION : 'CAPTION'; +CARDINALITY : 'CARDINALITY'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CASESENSITIVE : 'CASE-SENSITIVE'; +CATEGORY : 'CATEGORY'; +CDBDEFAULT : 'CDB$DEFAULT'; +CEIL : 'CEIL'; +CELL_FLASH_CACHE : 'CELL_FLASH_CACHE'; +CERTIFICATE : 'CERTIFICATE'; +CFILE : 'CFILE'; +CHAINED : 'CHAINED'; +CHANGE : 'CHANGE'; +CHANGETRACKING : 'CHANGETRACKING'; +CHANGE_DUPKEY_ERROR_INDEX : 'CHANGE_DUPKEY_ERROR_INDEX'; +CHARACTER : 'CHARACTER'; +CHAR : 'CHAR'; +CHAR_CS : 'CHAR_CS'; +CHARTOROWID : 'CHARTOROWID'; +CHECK_ACL_REWRITE : 'CHECK_ACL_REWRITE'; +CHECK : 'CHECK'; +CHECKPOINT : 'CHECKPOINT'; +CHILD : 'CHILD'; +CHOOSE : 'CHOOSE'; +CHR : 'CHR'; +CHUNK : 'CHUNK'; +CLASS : 'CLASS'; +CLASSIFICATION : 'CLASSIFICATION'; +CLASSIFIER : 'CLASSIFIER'; +CLAUSE : 'CLAUSE'; +CLEAN : 'CLEAN'; +CLEANUP : 'CLEANUP'; +CLEAR : 'CLEAR'; +C_LETTER : 'C'; +CLIENT : 'CLIENT'; +CLOB : 'CLOB'; +CLONE : 'CLONE'; +CLOSE_CACHED_OPEN_CURSORS : 'CLOSE_CACHED_OPEN_CURSORS'; +CLOSE : 'CLOSE'; +CLUSTER_BY_ROWID : 'CLUSTER_BY_ROWID'; +CLUSTER : 'CLUSTER'; +CLUSTER_DETAILS : 'CLUSTER_DETAILS'; +CLUSTER_DISTANCE : 'CLUSTER_DISTANCE'; +CLUSTER_ID : 'CLUSTER_ID'; +CLUSTERING : 'CLUSTERING'; +CLUSTERING_FACTOR : 'CLUSTERING_FACTOR'; +CLUSTER_PROBABILITY : 'CLUSTER_PROBABILITY'; +CLUSTER_SET : 'CLUSTER_SET'; +COALESCE : 'COALESCE'; +COALESCE_SQ : 'COALESCE_SQ'; +COARSE : 'COARSE'; +CO_AUTH_IND : 'CO_AUTH_IND'; +COLD : 'COLD'; +COLLECT : 'COLLECT'; +COLUMNAR : 'COLUMNAR'; +COLUMN_AUTH_INDICATOR : 'COLUMN_AUTH_INDICATOR'; +COLUMN : 'COLUMN'; +COLUMNS : 'COLUMNS'; +COLUMN_STATS : 'COLUMN_STATS'; +COLUMN_VALUE : 'COLUMN_VALUE'; +COMMENT : 'COMMENT'; +COMMIT : 'COMMIT'; +COMMITTED : 'COMMITTED'; +COMMON : 'COMMON'; +COMMON_DATA : 'COMMON_DATA'; +COMPACT : 'COMPACT'; +COMPATIBILITY : 'COMPATIBILITY'; +COMPILE : 'COMPILE'; +COMPLETE : 'COMPLETE'; +COMPLIANCE : 'COMPLIANCE'; +COMPONENT : 'COMPONENT'; +COMPONENTS : 'COMPONENTS'; +COMPOSE : 'COMPOSE'; +COMPOSITE : 'COMPOSITE'; +COMPOSITE_LIMIT : 'COMPOSITE_LIMIT'; +COMPOUND : 'COMPOUND'; +COMPRESS : 'COMPRESS'; +COMPUTE : 'COMPUTE'; +CONCAT : 'CONCAT'; +CON_DBID_TO_ID : 'CON_DBID_TO_ID'; +CONDITIONAL : 'CONDITIONAL'; +CONDITION : 'CONDITION'; +CONFIRM : 'CONFIRM'; +CONFORMING : 'CONFORMING'; +CON_GUID_TO_ID : 'CON_GUID_TO_ID'; +CON_ID : 'CON_ID'; +CON_NAME_TO_ID : 'CON_NAME_TO_ID'; +CONNECT_BY_CB_WHR_ONLY : 'CONNECT_BY_CB_WHR_ONLY'; +CONNECT_BY_COMBINE_SW : 'CONNECT_BY_COMBINE_SW'; +CONNECT_BY_COST_BASED : 'CONNECT_BY_COST_BASED'; +CONNECT_BY_ELIM_DUPS : 'CONNECT_BY_ELIM_DUPS'; +CONNECT_BY_FILTERING : 'CONNECT_BY_FILTERING'; +CONNECT_BY_ISCYCLE : 'CONNECT_BY_ISCYCLE'; +CONNECT_BY_ISLEAF : 'CONNECT_BY_ISLEAF'; +CONNECT_BY_ROOT : 'CONNECT_BY_ROOT'; +CONNECT : 'CONNECT'; +CONNECT_TIME : 'CONNECT_TIME'; +CONSIDER : 'CONSIDER'; +CONSISTENT : 'CONSISTENT'; +CONSTANT : 'CONSTANT'; +CONST : 'CONST'; +CONSTRAINT : 'CONSTRAINT'; +CONSTRAINTS : 'CONSTRAINTS'; +CONSTRUCTOR : 'CONSTRUCTOR'; +CONTAINER : 'CONTAINER'; +CONTAINERS : 'CONTAINERS'; +CONTAINERS_DEFAULT : 'CONTAINERS_DEFAULT'; +CONTAINER_DATA : 'CONTAINER_DATA'; +CONTAINER_MAP : 'CONTAINER_MAP'; +CONTENT : 'CONTENT'; +CONTENTS : 'CONTENTS'; +CONTEXT : 'CONTEXT'; +CONTINUE : 'CONTINUE'; +CONTROLFILE : 'CONTROLFILE'; +CON_UID_TO_ID : 'CON_UID_TO_ID'; +CONVERT : 'CONVERT'; +CONVERSION : 'CONVERSION'; +COOKIE : 'COOKIE'; +COPY : 'COPY'; +CORR_K : 'CORR_K'; +CORR_S : 'CORR_S'; +CORRUPTION : 'CORRUPTION'; +CORRUPT_XID_ALL : 'CORRUPT_XID_ALL'; +CORRUPT_XID : 'CORRUPT_XID'; +COS : 'COS'; +COSH : 'COSH'; +COST : 'COST'; +COST_XML_QUERY_REWRITE : 'COST_XML_QUERY_REWRITE'; +COUNT : 'COUNT'; +COVAR_POP : 'COVAR_POP'; +COVAR_SAMP : 'COVAR_SAMP'; +CPU_COSTING : 'CPU_COSTING'; +CPU_PER_CALL : 'CPU_PER_CALL'; +CPU_PER_SESSION : 'CPU_PER_SESSION'; +CRASH : 'CRASH'; +CREATE : 'CREATE'; +CREATE_FILE_DEST : 'CREATE_FILE_DEST'; +CREATE_STORED_OUTLINES : 'CREATE_STORED_OUTLINES'; +CREATION : 'CREATION'; +CREDENTIAL : 'CREDENTIAL'; +CRITICAL : 'CRITICAL'; +CROSS : 'CROSS'; +CROSSEDITION : 'CROSSEDITION'; +CSCONVERT : 'CSCONVERT'; +CUBE_AJ : 'CUBE_AJ'; +CUBE : 'CUBE'; +CUBE_GB : 'CUBE_GB'; +CUBE_SJ : 'CUBE_SJ'; +CUME_DISTM : 'CUME_DISTM'; +CURRENT : 'CURRENT'; +CURRENT_DATE : 'CURRENT_DATE'; +CURRENT_SCHEMA : 'CURRENT_SCHEMA'; +CURRENT_TIME : 'CURRENT_TIME'; +CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +CURRENT_USER : 'CURRENT_USER'; +CURRENTV : 'CURRENTV'; +CURSOR : 'CURSOR'; +CURSOR_SHARING_EXACT : 'CURSOR_SHARING_EXACT'; +CURSOR_SPECIFIC_SEGMENT : 'CURSOR_SPECIFIC_SEGMENT'; +CUSTOMDATUM : 'CUSTOMDATUM'; +CV : 'CV'; +CYCLE : 'CYCLE'; +DANGLING : 'DANGLING'; +DATABASE : 'DATABASE'; +DATA : 'DATA'; +DATAFILE : 'DATAFILE'; +DATAFILES : 'DATAFILES'; +DATAGUARDCONFIG : 'DATAGUARDCONFIG'; +DATAMOVEMENT : 'DATAMOVEMENT'; +DATAOBJNO : 'DATAOBJNO'; +DATAOBJ_TO_MAT_PARTITION : 'DATAOBJ_TO_MAT_PARTITION'; +DATAOBJ_TO_PARTITION : 'DATAOBJ_TO_PARTITION'; +DATAPUMP : 'DATAPUMP'; +DATA_SECURITY_REWRITE_LIMIT : 'DATA_SECURITY_REWRITE_LIMIT'; +DATE : 'DATE'; +DATE_MODE : 'DATE_MODE'; +DAY : 'DAY'; +DAYS : 'DAYS'; +DBA : 'DBA'; +DBA_RECYCLEBIN : 'DBA_RECYCLEBIN'; +DBMS_STATS : 'DBMS_STATS'; +DB_ROLE_CHANGE : 'DB_ROLE_CHANGE'; +DBTIMEZONE : 'DBTIMEZONE'; +DB_UNIQUE_NAME : 'DB_UNIQUE_NAME'; +DB_VERSION : 'DB_VERSION'; +DDL : 'DDL'; +DEALLOCATE : 'DEALLOCATE'; +DEBUG : 'DEBUG'; +DEBUGGER : 'DEBUGGER'; +DEC : 'DEC'; +DECIMAL : 'DECIMAL'; +DECLARE : 'DECLARE'; +DECOMPOSE : 'DECOMPOSE'; +DECORRELATE : 'DECORRELATE'; +DECR : 'DECR'; +DECREMENT : 'DECREMENT'; +DECRYPT : 'DECRYPT'; +DEDUPLICATE : 'DEDUPLICATE'; +DEFAULT : 'DEFAULT'; +DEFAULTS : 'DEFAULTS'; +DEFAULT_COLLATION : 'DEFAULT_COLLATION'; +DEFAULT_CREDENTIAL : 'DEFAULT_CREDENTIAL'; +DEFERRABLE : 'DEFERRABLE'; +DEFERRED : 'DEFERRED'; +DEFINED : 'DEFINED'; +DEFINE : 'DEFINE'; +DEFINER : 'DEFINER'; +DEGREE : 'DEGREE'; +DELAY : 'DELAY'; +DELEGATE : 'DELEGATE'; +DELETE_ALL : 'DELETE_ALL'; +DELETE : 'DELETE'; +DELETEXML : 'DELETEXML'; +DEMAND : 'DEMAND'; +DENSE_RANKM : 'DENSE_RANKM'; +DEPENDENT : 'DEPENDENT'; +DEPTH : 'DEPTH'; +DEQUEUE : 'DEQUEUE'; +DEREF : 'DEREF'; +DEREF_NO_REWRITE : 'DEREF_NO_REWRITE'; +DESC : 'DESC'; +DESCRIPTION : 'DESCRIPTION'; +DESTROY : 'DESTROY'; +DETACHED : 'DETACHED'; +DETERMINES : 'DETERMINES'; +DETERMINISTIC : 'DETERMINISTIC'; +DICTIONARY : 'DICTIONARY'; +DIMENSION : 'DIMENSION'; +DIMENSIONS : 'DIMENSIONS'; +DIRECT_LOAD : 'DIRECT_LOAD'; +DIRECTORY : 'DIRECTORY'; +DIRECT_PATH : 'DIRECT_PATH'; +DISABLE_ALL : 'DISABLE_ALL'; +DISABLE : 'DISABLE'; +DISABLE_PARALLEL_DML : 'DISABLE_PARALLEL_DML'; +DISABLE_PRESET : 'DISABLE_PRESET'; +DISABLE_RPKE : 'DISABLE_RPKE'; +DISALLOW : 'DISALLOW'; +DISASSOCIATE : 'DISASSOCIATE'; +DISCARD : 'DISCARD'; +DISCONNECT : 'DISCONNECT'; +DISK : 'DISK'; +DISKGROUP : 'DISKGROUP'; +DISKGROUP_PLUS : '\'+ DISKGROUP'; +DISKS : 'DISKS'; +DISMOUNT : 'DISMOUNT'; +DISTINCT : 'DISTINCT'; +DISTINGUISHED : 'DISTINGUISHED'; +DISTRIBUTED : 'DISTRIBUTED'; +DISTRIBUTE : 'DISTRIBUTE'; +DML : 'DML'; +DML_UPDATE : 'DML_UPDATE'; +DOCFIDELITY : 'DOCFIDELITY'; +DOCUMENT : 'DOCUMENT'; +DOMAIN_INDEX_FILTER : 'DOMAIN_INDEX_FILTER'; +DOMAIN_INDEX_NO_SORT : 'DOMAIN_INDEX_NO_SORT'; +DOMAIN_INDEX_SORT : 'DOMAIN_INDEX_SORT'; +DOUBLE : 'DOUBLE'; +DOWNGRADE : 'DOWNGRADE'; +DRIVING_SITE : 'DRIVING_SITE'; +DROP_COLUMN : 'DROP_COLUMN'; +DROP : 'DROP'; +DROP_GROUP : 'DROP_GROUP'; +DSINTERVAL_UNCONSTRAINED : 'DSINTERVAL_UNCONSTRAINED'; +DST_UPGRADE_INSERT_CONV : 'DST_UPGRADE_INSERT_CONV'; +DUMP : 'DUMP'; +DUMPSET : 'DUMPSET'; +DUPLICATE : 'DUPLICATE'; +DV : 'DV'; +DYNAMIC : 'DYNAMIC'; +DYNAMIC_SAMPLING : 'DYNAMIC_SAMPLING'; +DYNAMIC_SAMPLING_EST_CDN : 'DYNAMIC_SAMPLING_EST_CDN'; +E_LETTER : 'E'; +EACH : 'EACH'; +EDITIONABLE : 'EDITIONABLE'; +EDITION : 'EDITION'; +EDITIONING : 'EDITIONING'; +EDITIONS : 'EDITIONS'; +ELEMENT : 'ELEMENT'; +ELIM_GROUPBY : 'ELIM_GROUPBY'; +ELIMINATE_JOIN : 'ELIMINATE_JOIN'; +ELIMINATE_OBY : 'ELIMINATE_OBY'; +ELIMINATE_OUTER_JOIN : 'ELIMINATE_OUTER_JOIN'; +ELSE : 'ELSE'; +ELSIF : 'ELSIF'; +EM : 'EM'; +EMPTY_BLOB : 'EMPTY_BLOB'; +EMPTY_CLOB : 'EMPTY_CLOB'; +EMPTY_ : 'EMPTY'; +ENABLE_ALL : 'ENABLE_ALL'; +ENABLE : 'ENABLE'; +ENABLE_PARALLEL_DML : 'ENABLE_PARALLEL_DML'; +ENABLE_PRESET : 'ENABLE_PRESET'; +ENCODING : 'ENCODING'; +ENCRYPT : 'ENCRYPT'; +ENCRYPTION : 'ENCRYPTION'; +END : 'END'; +END_OUTLINE_DATA : 'END_OUTLINE_DATA'; +ENFORCED : 'ENFORCED'; +ENFORCE : 'ENFORCE'; +ENQUEUE : 'ENQUEUE'; +ENTERPRISE : 'ENTERPRISE'; +ENTITYESCAPING : 'ENTITYESCAPING'; +ENTRY : 'ENTRY'; +EQUIPART : 'EQUIPART'; +ERR : 'ERR'; +ERROR_ARGUMENT : 'ERROR_ARGUMENT'; +ERROR : 'ERROR'; +ERROR_ON_OVERLAP_TIME : 'ERROR_ON_OVERLAP_TIME'; +ERRORS : 'ERRORS'; +ESCAPE : 'ESCAPE'; +ESTIMATE : 'ESTIMATE'; +EVAL : 'EVAL'; +EVALNAME : 'EVALNAME'; +EVALUATE : 'EVALUATE'; +EVALUATION : 'EVALUATION'; +EVENTS : 'EVENTS'; +EVERY : 'EVERY'; +EXCEPT : 'EXCEPT'; +EXCEPTION : 'EXCEPTION'; +EXCEPTION_INIT : 'EXCEPTION_INIT'; +EXCEPTIONS : 'EXCEPTIONS'; +EXCHANGE : 'EXCHANGE'; +EXCLUDE : 'EXCLUDE'; +EXCLUDING : 'EXCLUDING'; +EXCLUSIVE : 'EXCLUSIVE'; +EXECUTE : 'EXECUTE'; +EXEMPT : 'EXEMPT'; +EXISTING : 'EXISTING'; +EXISTS : 'EXISTS'; +EXISTSNODE : 'EXISTSNODE'; +EXIT : 'EXIT'; +EXPAND_GSET_TO_UNION : 'EXPAND_GSET_TO_UNION'; +EXPAND_TABLE : 'EXPAND_TABLE'; +EXP : 'EXP'; +EXPIRE : 'EXPIRE'; +EXPLAIN : 'EXPLAIN'; +EXPLOSION : 'EXPLOSION'; +EXPORT : 'EXPORT'; +EXPR_CORR_CHECK : 'EXPR_CORR_CHECK'; +EXPRESS : 'EXPRESS'; +EXTENDS : 'EXTENDS'; +EXTENT : 'EXTENT'; +EXTENTS : 'EXTENTS'; +EXTERNAL : 'EXTERNAL'; +EXTERNALLY : 'EXTERNALLY'; +EXTRACTCLOBXML : 'EXTRACTCLOBXML'; +EXTRACT : 'EXTRACT'; +EXTRACTVALUE : 'EXTRACTVALUE'; +EXTRA : 'EXTRA'; +FACILITY : 'FACILITY'; +FACT : 'FACT'; +FACTOR : 'FACTOR'; +FACTORIZE_JOIN : 'FACTORIZE_JOIN'; +FAILED : 'FAILED'; +FAILED_LOGIN_ATTEMPTS : 'FAILED_LOGIN_ATTEMPTS'; +FAILGROUP : 'FAILGROUP'; +FAILOVER : 'FAILOVER'; +FAILURE : 'FAILURE'; +FALSE : 'FALSE'; +FAMILY : 'FAMILY'; +FAR : 'FAR'; +FAST : 'FAST'; +FASTSTART : 'FASTSTART'; +FBTSCAN : 'FBTSCAN'; +FEATURE : 'FEATURE'; +FEATURE_DETAILS : 'FEATURE_DETAILS'; +FEATURE_ID : 'FEATURE_ID'; +FEATURE_SET : 'FEATURE_SET'; +FEATURE_VALUE : 'FEATURE_VALUE'; +FETCH : 'FETCH'; +FILE : 'FILE'; +FILE_NAME_CONVERT : 'FILE_NAME_CONVERT'; +FILEGROUP : 'FILEGROUP'; +FILESTORE : 'FILESTORE'; +FILESYSTEM_LIKE_LOGGING : 'FILESYSTEM_LIKE_LOGGING'; +FILTER : 'FILTER'; +FINAL : 'FINAL'; +FINE : 'FINE'; +FINISH : 'FINISH'; +FIRST : 'FIRST'; +FIRSTM : 'FIRSTM'; +FIRST_ROWS : 'FIRST_ROWS'; +FIRST_VALUE : 'FIRST_VALUE'; +FIXED_VIEW_DATA : 'FIXED_VIEW_DATA'; +FLAGGER : 'FLAGGER'; +FLASHBACK : 'FLASHBACK'; +FLASH_CACHE : 'FLASH_CACHE'; +FLOAT : 'FLOAT'; +FLOB : 'FLOB'; +FLEX : 'FLEX'; +FLOOR : 'FLOOR'; +FLUSH : 'FLUSH'; +FOLDER : 'FOLDER'; +FOLLOWING : 'FOLLOWING'; +FOLLOWS : 'FOLLOWS'; +FORALL : 'FORALL'; +FORCE : 'FORCE'; +FORCE_XML_QUERY_REWRITE : 'FORCE_XML_QUERY_REWRITE'; +FOREIGN : 'FOREIGN'; +FOREVER : 'FOREVER'; +FOR : 'FOR'; +FORMAT : 'FORMAT'; +FORWARD : 'FORWARD'; +FRAGMENT_NUMBER : 'FRAGMENT_NUMBER'; +FREELIST : 'FREELIST'; +FREELISTS : 'FREELISTS'; +FREEPOOLS : 'FREEPOOLS'; +FRESH : 'FRESH'; +FROM : 'FROM'; +FROM_TZ : 'FROM_TZ'; +FULL : 'FULL'; +FULL_OUTER_JOIN_TO_OUTER : 'FULL_OUTER_JOIN_TO_OUTER'; +FUNCTION : 'FUNCTION'; +FUNCTIONS : 'FUNCTIONS'; +FTP : 'FTP'; +G_LETTER : 'G'; +GATHER_OPTIMIZER_STATISTICS : 'GATHER_OPTIMIZER_STATISTICS'; +GATHER_PLAN_STATISTICS : 'GATHER_PLAN_STATISTICS'; +GBY_CONC_ROLLUP : 'GBY_CONC_ROLLUP'; +GBY_PUSHDOWN : 'GBY_PUSHDOWN'; +GENERATED : 'GENERATED'; +GET : 'GET'; +GLOBAL : 'GLOBAL'; +GLOBALLY : 'GLOBALLY'; +GLOBAL_NAME : 'GLOBAL_NAME'; +GLOBAL_TOPIC_ENABLED : 'GLOBAL_TOPIC_ENABLED'; +GOTO : 'GOTO'; +GRANT : 'GRANT'; +GROUP_BY : 'GROUP_BY'; +GROUP : 'GROUP'; +GROUP_ID : 'GROUP_ID'; +GROUPING : 'GROUPING'; +GROUPING_ID : 'GROUPING_ID'; +GROUPS : 'GROUPS'; +GUARANTEED : 'GUARANTEED'; +GUARANTEE : 'GUARANTEE'; +GUARD : 'GUARD'; +HALF_YEARS : 'HALF_YEARS'; +HASH_AJ : 'HASH_AJ'; +HASH : 'HASH'; +HASHKEYS : 'HASHKEYS'; +HASH_SJ : 'HASH_SJ'; +HAVING : 'HAVING'; +HEADER : 'HEADER'; +HEAP : 'HEAP'; +HELP : 'HELP'; +HEXTORAW : 'HEXTORAW'; +HEXTOREF : 'HEXTOREF'; +HIDDEN_KEYWORD : 'HIDDEN'; +HIDE : 'HIDE'; +HIER_ORDER : 'HIER_ORDER'; +HIERARCHICAL : 'HIERARCHICAL'; +HIERARCHIES : 'HIERARCHIES'; +HIERARCHY : 'HIERARCHY'; +HIGH : 'HIGH'; +HINTSET_BEGIN : 'HINTSET_BEGIN'; +HINTSET_END : 'HINTSET_END'; +HOT : 'HOT'; +HOUR : 'HOUR'; +HOURS : 'HOURS'; +HTTP : 'HTTP'; +HWM_BROKERED : 'HWM_BROKERED'; +HYBRID : 'HYBRID'; +H_LETTER : 'H'; +IDENTIFIED : 'IDENTIFIED'; +IDENTIFIER : 'IDENTIFIER'; +IDENTITY : 'IDENTITY'; +IDGENERATORS : 'IDGENERATORS'; +ID : 'ID'; +IDLE_TIME : 'IDLE_TIME'; +IF : 'IF'; +IGNORE : 'IGNORE'; +IGNORE_OPTIM_EMBEDDED_HINTS : 'IGNORE_OPTIM_EMBEDDED_HINTS'; +IGNORE_ROW_ON_DUPKEY_INDEX : 'IGNORE_ROW_ON_DUPKEY_INDEX'; +IGNORE_WHERE_CLAUSE : 'IGNORE_WHERE_CLAUSE'; +ILM : 'ILM'; +IMMEDIATE : 'IMMEDIATE'; +IMPACT : 'IMPACT'; +IMPORT : 'IMPORT'; +INACTIVE : 'INACTIVE'; +INACTIVE_ACCOUNT_TIME : 'INACTIVE_ACCOUNT_TIME'; +INCLUDE : 'INCLUDE'; +INCLUDE_VERSION : 'INCLUDE_VERSION'; +INCLUDING : 'INCLUDING'; +INCREMENTAL : 'INCREMENTAL'; +INCREMENT : 'INCREMENT'; +INCR : 'INCR'; +INDENT : 'INDENT'; +INDEX_ASC : 'INDEX_ASC'; +INDEX_COMBINE : 'INDEX_COMBINE'; +INDEX_DESC : 'INDEX_DESC'; +INDEXED : 'INDEXED'; +INDEXES : 'INDEXES'; +INDEX_FFS : 'INDEX_FFS'; +INDEX_FILTER : 'INDEX_FILTER'; +INDEX : 'INDEX'; +INDEXING : 'INDEXING'; +INDEX_JOIN : 'INDEX_JOIN'; +INDEX_ROWS : 'INDEX_ROWS'; +INDEX_RRS : 'INDEX_RRS'; +INDEX_RS_ASC : 'INDEX_RS_ASC'; +INDEX_RS_DESC : 'INDEX_RS_DESC'; +INDEX_RS : 'INDEX_RS'; +INDEX_SCAN : 'INDEX_SCAN'; +INDEX_SKIP_SCAN : 'INDEX_SKIP_SCAN'; +INDEX_SS_ASC : 'INDEX_SS_ASC'; +INDEX_SS_DESC : 'INDEX_SS_DESC'; +INDEX_SS : 'INDEX_SS'; +INDEX_STATS : 'INDEX_STATS'; +INDEXTYPE : 'INDEXTYPE'; +INDEXTYPES : 'INDEXTYPES'; +INDICATOR : 'INDICATOR'; +INDICES : 'INDICES'; +INFINITE : 'INFINITE'; +INFORMATIONAL : 'INFORMATIONAL'; +INHERIT : 'INHERIT'; +IN : 'IN'; +INITCAP : 'INITCAP'; +INITIAL : 'INITIAL'; +INITIALIZED : 'INITIALIZED'; +INITIALLY : 'INITIALLY'; +INITRANS : 'INITRANS'; +INLINE : 'INLINE'; +INLINE_XMLTYPE_NT : 'INLINE_XMLTYPE_NT'; +INMEMORY : 'INMEMORY'; +IN_MEMORY_METADATA : 'IN_MEMORY_METADATA'; +INMEMORY_PRUNING : 'INMEMORY_PRUNING'; +INNER : 'INNER'; +INOUT : 'INOUT'; +INPLACE : 'INPLACE'; +INSERTCHILDXMLAFTER : 'INSERTCHILDXMLAFTER'; +INSERTCHILDXMLBEFORE : 'INSERTCHILDXMLBEFORE'; +INSERTCHILDXML : 'INSERTCHILDXML'; +INSERT : 'INSERT'; +INSERTXMLAFTER : 'INSERTXMLAFTER'; +INSERTXMLBEFORE : 'INSERTXMLBEFORE'; +INSTANCE : 'INSTANCE'; +INSTANCES : 'INSTANCES'; +INSTANTIABLE : 'INSTANTIABLE'; +INSTANTLY : 'INSTANTLY'; +INSTEAD : 'INSTEAD'; +INSTR2 : 'INSTR2'; +INSTR4 : 'INSTR4'; +INSTRB : 'INSTRB'; +INSTRC : 'INSTRC'; +INSTR : 'INSTR'; +INTEGER : 'INTEGER'; +INTERLEAVED : 'INTERLEAVED'; +INTERMEDIATE : 'INTERMEDIATE'; +INTERNAL_CONVERT : 'INTERNAL_CONVERT'; +INTERNAL_USE : 'INTERNAL_USE'; +INTERPRETED : 'INTERPRETED'; +INTERSECT : 'INTERSECT'; +INTERVAL : 'INTERVAL'; +INT : 'INT'; +INTO : 'INTO'; +INVALIDATE : 'INVALIDATE'; +INVISIBLE : 'INVISIBLE'; +IN_XQUERY : 'IN_XQUERY'; +IS : 'IS'; +IS_LEAF : 'IS_LEAF'; +ISOLATION : 'ISOLATION'; +ISOLATION_LEVEL : 'ISOLATION_LEVEL'; +ITERATE : 'ITERATE'; +ITERATION_NUMBER : 'ITERATION_NUMBER'; +JAVA : 'JAVA'; +JOB : 'JOB'; +JOIN : 'JOIN'; +JSON_ARRAYAGG : 'JSON_ARRAYAGG'; +JSON_ARRAY : 'JSON_ARRAY'; +JSON_EQUAL : 'JSON_EQUAL'; +JSON_EXISTS2 : 'JSON_EXISTS2'; +JSON_EXISTS : 'JSON_EXISTS'; +JSONGET : 'JSONGET'; +JSON : 'JSON'; +JSON_OBJECTAGG : 'JSON_OBJECTAGG'; +JSON_OBJECT : 'JSON_OBJECT'; +JSONPARSE : 'JSONPARSE'; +JSON_QUERY : 'JSON_QUERY'; +JSON_SERIALIZE : 'JSON_SERIALIZE'; +JSON_TABLE : 'JSON_TABLE'; +JSON_TEXTCONTAINS2 : 'JSON_TEXTCONTAINS2'; +JSON_TEXTCONTAINS : 'JSON_TEXTCONTAINS'; +JSON_TRANSFORM : 'JSON_TRANSFORM'; +JSON_VALUE : 'JSON_VALUE'; +K_LETTER : 'K'; +KEEP_DUPLICATES : 'KEEP_DUPLICATES'; +KEEP : 'KEEP'; +KERBEROS : 'KERBEROS'; +KEY : 'KEY'; +KEY_LENGTH : 'KEY_LENGTH'; +KEYSIZE : 'KEYSIZE'; +KEYS : 'KEYS'; +KEYSTORE : 'KEYSTORE'; +KILL : 'KILL'; +LABEL : 'LABEL'; +LANGUAGE : 'LANGUAGE'; +LAST_DAY : 'LAST_DAY'; +LAST : 'LAST'; +LAST_VALUE : 'LAST_VALUE'; +LATERAL : 'LATERAL'; +LAX : 'LAX'; +LAYER : 'LAYER'; +LDAP_REGISTRATION_ENABLED : 'LDAP_REGISTRATION_ENABLED'; +LDAP_REGISTRATION : 'LDAP_REGISTRATION'; +LDAP_REG_SYNC_INTERVAL : 'LDAP_REG_SYNC_INTERVAL'; +LEAF : 'LEAF'; +LEAD_CDB : 'LEAD_CDB'; +LEAD_CDB_URI : 'LEAD_CDB_URI'; +LEADING : 'LEADING'; +LEFT : 'LEFT'; +LENGTH2 : 'LENGTH2'; +LENGTH4 : 'LENGTH4'; +LENGTHB : 'LENGTHB'; +LENGTHC : 'LENGTHC'; +LENGTH : 'LENGTH'; +LESS : 'LESS'; +LEVEL : 'LEVEL'; +LEVEL_NAME : 'LEVEL_NAME'; +LEVELS : 'LEVELS'; +LIBRARY : 'LIBRARY'; +LIFECYCLE : 'LIFECYCLE'; +LIFE : 'LIFE'; +LIFETIME : 'LIFETIME'; +LIKE2 : 'LIKE2'; +LIKE4 : 'LIKE4'; +LIKEC : 'LIKEC'; +LIKE_EXPAND : 'LIKE_EXPAND'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; +LINEAR : 'LINEAR'; +LINK : 'LINK'; +LIST : 'LIST'; +LN : 'LN'; +LNNVL : 'LNNVL'; +LOAD : 'LOAD'; +LOB : 'LOB'; +LOBNVL : 'LOBNVL'; +LOBS : 'LOBS'; +LOCAL_INDEXES : 'LOCAL_INDEXES'; +LOCAL : 'LOCAL'; +LOCALTIME : 'LOCALTIME'; +LOCALTIMESTAMP : 'LOCALTIMESTAMP'; +LOCATION : 'LOCATION'; +LOCATOR : 'LOCATOR'; +LOCKDOWN : 'LOCKDOWN'; +LOCKED : 'LOCKED'; +LOCKING : 'LOCKING'; +LOCK : 'LOCK'; +LOGFILE : 'LOGFILE'; +LOGFILES : 'LOGFILES'; +LOGGING : 'LOGGING'; +LOGICAL : 'LOGICAL'; +LOGICAL_READS_PER_CALL : 'LOGICAL_READS_PER_CALL'; +LOGICAL_READS_PER_SESSION : 'LOGICAL_READS_PER_SESSION'; +LOG : 'LOG'; +LOGMINING : 'LOGMINING'; +LOGOFF : 'LOGOFF'; +LOGON : 'LOGON'; +LOG_READ_ONLY_VIOLATIONS : 'LOG_READ_ONLY_VIOLATIONS'; +LONG : 'LONG'; +LOOP : 'LOOP'; +LOST : 'LOST'; +LOWER : 'LOWER'; +LOW : 'LOW'; +LPAD : 'LPAD'; +LTRIM : 'LTRIM'; +M_LETTER : 'M'; +MAIN : 'MAIN'; +MAKE_REF : 'MAKE_REF'; +MANAGED : 'MANAGED'; +MANAGE : 'MANAGE'; +MANAGEMENT : 'MANAGEMENT'; +MANAGER : 'MANAGER'; +MANDATORY : 'MANDATORY'; +MANUAL : 'MANUAL'; +MAP : 'MAP'; +MAPPING : 'MAPPING'; +MASTER : 'MASTER'; +MATCHED : 'MATCHED'; +MATCHES : 'MATCHES'; +MATCH : 'MATCH'; +MATCH_NUMBER : 'MATCH_NUMBER'; +MATCH_RECOGNIZE : 'MATCH_RECOGNIZE'; +MATERIALIZED : 'MATERIALIZED'; +MATERIALIZE : 'MATERIALIZE'; +MAXARCHLOGS : 'MAXARCHLOGS'; +MAXDATAFILES : 'MAXDATAFILES'; +MAXEXTENTS : 'MAXEXTENTS'; +MAXIMIZE : 'MAXIMIZE'; +MAXINSTANCES : 'MAXINSTANCES'; +MAXLOGFILES : 'MAXLOGFILES'; +MAXLOGHISTORY : 'MAXLOGHISTORY'; +MAXLOGMEMBERS : 'MAXLOGMEMBERS'; +MAX_SHARED_TEMP_SIZE : 'MAX_SHARED_TEMP_SIZE'; +MAXSIZE : 'MAXSIZE'; +MAXTRANS : 'MAXTRANS'; +MAXVALUE : 'MAXVALUE'; +MEASURE : 'MEASURE'; +MEASURES : 'MEASURES'; +MEDIUM : 'MEDIUM'; +MEMBER : 'MEMBER'; +MEMBER_CAPTION : 'MEMBER_CAPTION'; +MEMBER_DESCRIPTION : 'MEMBER_DESCRIPTION'; +MEMBER_NAME : 'MEMBER_NAME'; +MEMBER_UNIQUE_NAME : 'MEMBER_UNIQUE_NAME'; +MEMCOMPRESS : 'MEMCOMPRESS'; +MEMORY : 'MEMORY'; +MERGEACTIONS : 'MERGE$ACTIONS'; +MERGE_AJ : 'MERGE_AJ'; +MERGE_CONST_ON : 'MERGE_CONST_ON'; +MERGE : 'MERGE'; +MERGE_SJ : 'MERGE_SJ'; +METADATA : 'METADATA'; +METHOD : 'METHOD'; +MIGRATE : 'MIGRATE'; +MIGRATION : 'MIGRATION'; +MINEXTENTS : 'MINEXTENTS'; +MINIMIZE : 'MINIMIZE'; +MINIMUM : 'MINIMUM'; +MINING : 'MINING'; +MINUS : 'MINUS'; +MINUS_NULL : 'MINUS_NULL'; +MINUTE : 'MINUTE'; +MINUTES : 'MINUTES'; +MINVALUE : 'MINVALUE'; +MIRRORCOLD : 'MIRRORCOLD'; +MIRRORHOT : 'MIRRORHOT'; +MIRROR : 'MIRROR'; +MISSING : 'MISSING'; +MISMATCH : 'MISMATCH'; +MLSLABEL : 'MLSLABEL'; +MODEL_COMPILE_SUBQUERY : 'MODEL_COMPILE_SUBQUERY'; +MODEL_DONTVERIFY_UNIQUENESS : 'MODEL_DONTVERIFY_UNIQUENESS'; +MODEL_DYNAMIC_SUBQUERY : 'MODEL_DYNAMIC_SUBQUERY'; +MODEL_MIN_ANALYSIS : 'MODEL_MIN_ANALYSIS'; +MODEL : 'MODEL'; +MODEL_NB : 'MODEL_NB'; +MODEL_NO_ANALYSIS : 'MODEL_NO_ANALYSIS'; +MODEL_PBY : 'MODEL_PBY'; +MODEL_PUSH_REF : 'MODEL_PUSH_REF'; +MODEL_SV : 'MODEL_SV'; +MODE : 'MODE'; +MODIFICATION : 'MODIFICATION'; +MODIFY_COLUMN_TYPE : 'MODIFY_COLUMN_TYPE'; +MODIFY : 'MODIFY'; +MOD : 'MOD'; +MODULE : 'MODULE'; +MONITORING : 'MONITORING'; +MONITOR : 'MONITOR'; +MONTH : 'MONTH'; +MONTHS_BETWEEN : 'MONTHS_BETWEEN'; +MONTHS : 'MONTHS'; +MOUNT : 'MOUNT'; +MOUNTPATH : 'MOUNTPATH'; +MOUNTPOINT : 'MOUNTPOINT'; +MOVEMENT : 'MOVEMENT'; +MOVE : 'MOVE'; +MULTIDIMENSIONAL : 'MULTIDIMENSIONAL'; +MULTISET : 'MULTISET'; +MV_MERGE : 'MV_MERGE'; +NAMED : 'NAMED'; +NAME : 'NAME'; +NAMESPACE : 'NAMESPACE'; +NAN : 'NAN'; +NANVL : 'NANVL'; +NATIONAL : 'NATIONAL'; +NATIVE_FULL_OUTER_JOIN : 'NATIVE_FULL_OUTER_JOIN'; +NATIVE : 'NATIVE'; +NATURAL : 'NATURAL'; +NATURALN : 'NATURALN'; +NAV : 'NAV'; +NCHAR_CS : 'NCHAR_CS'; +NCHAR : 'NCHAR'; +NCHR : 'NCHR'; +NCLOB : 'NCLOB'; +NEEDED : 'NEEDED'; +NEG : 'NEG'; +NESTED : 'NESTED'; +NESTED_TABLE_FAST_INSERT : 'NESTED_TABLE_FAST_INSERT'; +NESTED_TABLE_GET_REFS : 'NESTED_TABLE_GET_REFS'; +NESTED_TABLE_ID : 'NESTED_TABLE_ID'; +NESTED_TABLE_SET_REFS : 'NESTED_TABLE_SET_REFS'; +NESTED_TABLE_SET_SETID : 'NESTED_TABLE_SET_SETID'; +NETWORK : 'NETWORK'; +NEVER : 'NEVER'; +NEW : 'NEW'; +NEW_TIME : 'NEW_TIME'; +NEXT_DAY : 'NEXT_DAY'; +NEXT : 'NEXT'; +NL_AJ : 'NL_AJ'; +NLJ_BATCHING : 'NLJ_BATCHING'; +NLJ_INDEX_FILTER : 'NLJ_INDEX_FILTER'; +NLJ_INDEX_SCAN : 'NLJ_INDEX_SCAN'; +NLJ_PREFETCH : 'NLJ_PREFETCH'; +NLS_CALENDAR : 'NLS_CALENDAR'; +NLS_CHARACTERSET : 'NLS_CHARACTERSET'; +NLS_CHARSET_DECL_LEN : 'NLS_CHARSET_DECL_LEN'; +NLS_CHARSET_ID : 'NLS_CHARSET_ID'; +NLS_CHARSET_NAME : 'NLS_CHARSET_NAME'; +NLS_COMP : 'NLS_COMP'; +NLS_CURRENCY : 'NLS_CURRENCY'; +NLS_DATE_FORMAT : 'NLS_DATE_FORMAT'; +NLS_DATE_LANGUAGE : 'NLS_DATE_LANGUAGE'; +NLS_INITCAP : 'NLS_INITCAP'; +NLS_ISO_CURRENCY : 'NLS_ISO_CURRENCY'; +NL_SJ : 'NL_SJ'; +NLS_LANG : 'NLS_LANG'; +NLS_LANGUAGE : 'NLS_LANGUAGE'; +NLS_LENGTH_SEMANTICS : 'NLS_LENGTH_SEMANTICS'; +NLS_LOWER : 'NLS_LOWER'; +NLS_NCHAR_CONV_EXCP : 'NLS_NCHAR_CONV_EXCP'; +NLS_NUMERIC_CHARACTERS : 'NLS_NUMERIC_CHARACTERS'; +NLS_SORT : 'NLS_SORT'; +NLSSORT : 'NLSSORT'; +NLS_SPECIAL_CHARS : 'NLS_SPECIAL_CHARS'; +NLS_TERRITORY : 'NLS_TERRITORY'; +NLS_UPPER : 'NLS_UPPER'; +NO_ACCESS : 'NO_ACCESS'; +NO_ADAPTIVE_PLAN : 'NO_ADAPTIVE_PLAN'; +NO_ANSI_REARCH : 'NO_ANSI_REARCH'; +NOAPPEND : 'NOAPPEND'; +NOARCHIVELOG : 'NOARCHIVELOG'; +NOAUDIT : 'NOAUDIT'; +NO_AUTO_REOPTIMIZE : 'NO_AUTO_REOPTIMIZE'; +NO_BASETABLE_MULTIMV_REWRITE : 'NO_BASETABLE_MULTIMV_REWRITE'; +NO_BATCH_TABLE_ACCESS_BY_ROWID : 'NO_BATCH_TABLE_ACCESS_BY_ROWID'; +NO_BIND_AWARE : 'NO_BIND_AWARE'; +NO_BUFFER : 'NO_BUFFER'; +NOCACHE : 'NOCACHE'; +NO_CARTESIAN : 'NO_CARTESIAN'; +NO_CHECK_ACL_REWRITE : 'NO_CHECK_ACL_REWRITE'; +NO_CLUSTER_BY_ROWID : 'NO_CLUSTER_BY_ROWID'; +NO_CLUSTERING : 'NO_CLUSTERING'; +NO_COALESCE_SQ : 'NO_COALESCE_SQ'; +NO_COMMON_DATA : 'NO_COMMON_DATA'; +NOCOMPRESS : 'NOCOMPRESS'; +NO_CONNECT_BY_CB_WHR_ONLY : 'NO_CONNECT_BY_CB_WHR_ONLY'; +NO_CONNECT_BY_COMBINE_SW : 'NO_CONNECT_BY_COMBINE_SW'; +NO_CONNECT_BY_COST_BASED : 'NO_CONNECT_BY_COST_BASED'; +NO_CONNECT_BY_ELIM_DUPS : 'NO_CONNECT_BY_ELIM_DUPS'; +NO_CONNECT_BY_FILTERING : 'NO_CONNECT_BY_FILTERING'; +NOCOPY : 'NOCOPY'; +NO_COST_XML_QUERY_REWRITE : 'NO_COST_XML_QUERY_REWRITE'; +NO_CPU_COSTING : 'NO_CPU_COSTING'; +NOCPU_COSTING : 'NOCPU_COSTING'; +NOCYCLE : 'NOCYCLE'; +NO_DATA_SECURITY_REWRITE : 'NO_DATA_SECURITY_REWRITE'; +NO_DECORRELATE : 'NO_DECORRELATE'; +NODELAY : 'NODELAY'; +NO_DOMAIN_INDEX_FILTER : 'NO_DOMAIN_INDEX_FILTER'; +NO_DST_UPGRADE_INSERT_CONV : 'NO_DST_UPGRADE_INSERT_CONV'; +NO_ELIM_GROUPBY : 'NO_ELIM_GROUPBY'; +NO_ELIMINATE_JOIN : 'NO_ELIMINATE_JOIN'; +NO_ELIMINATE_OBY : 'NO_ELIMINATE_OBY'; +NO_ELIMINATE_OUTER_JOIN : 'NO_ELIMINATE_OUTER_JOIN'; +NOENTITYESCAPING : 'NOENTITYESCAPING'; +NO_EXPAND_GSET_TO_UNION : 'NO_EXPAND_GSET_TO_UNION'; +NO_EXPAND : 'NO_EXPAND'; +NO_EXPAND_TABLE : 'NO_EXPAND_TABLE'; +NO_FACT : 'NO_FACT'; +NO_FACTORIZE_JOIN : 'NO_FACTORIZE_JOIN'; +NO_FILTERING : 'NO_FILTERING'; +NOFORCE : 'NOFORCE'; +NO_FULL_OUTER_JOIN_TO_OUTER : 'NO_FULL_OUTER_JOIN_TO_OUTER'; +NO_GATHER_OPTIMIZER_STATISTICS : 'NO_GATHER_OPTIMIZER_STATISTICS'; +NO_GBY_PUSHDOWN : 'NO_GBY_PUSHDOWN'; +NOGUARANTEE : 'NOGUARANTEE'; +NO_INDEX_FFS : 'NO_INDEX_FFS'; +NO_INDEX : 'NO_INDEX'; +NO_INDEX_SS : 'NO_INDEX_SS'; +NO_INMEMORY : 'NO_INMEMORY'; +NO_INMEMORY_PRUNING : 'NO_INMEMORY_PRUNING'; +NOKEEP : 'NOKEEP'; +NO_LOAD : 'NO_LOAD'; +NOLOCAL : 'NOLOCAL'; +NOLOGGING : 'NOLOGGING'; +NOMAPPING : 'NOMAPPING'; +NOMAXVALUE : 'NOMAXVALUE'; +NO_MERGE : 'NO_MERGE'; +NOMINIMIZE : 'NOMINIMIZE'; +NOMINVALUE : 'NOMINVALUE'; +NO_MODEL_PUSH_REF : 'NO_MODEL_PUSH_REF'; +NO_MONITORING : 'NO_MONITORING'; +NOMONITORING : 'NOMONITORING'; +NO_MONITOR : 'NO_MONITOR'; +NO_MULTIMV_REWRITE : 'NO_MULTIMV_REWRITE'; +NO_NATIVE_FULL_OUTER_JOIN : 'NO_NATIVE_FULL_OUTER_JOIN'; +NONBLOCKING : 'NONBLOCKING'; +NONEDITIONABLE : 'NONEDITIONABLE'; +NONE : 'NONE'; +NO_NLJ_BATCHING : 'NO_NLJ_BATCHING'; +NO_NLJ_PREFETCH : 'NO_NLJ_PREFETCH'; +NO : 'NO'; +NONSCHEMA : 'NONSCHEMA'; +NO_OBJECT_LINK : 'NO_OBJECT_LINK'; +NOORDER : 'NOORDER'; +NO_ORDER_ROLLUPS : 'NO_ORDER_ROLLUPS'; +NO_OUTER_JOIN_TO_ANTI : 'NO_OUTER_JOIN_TO_ANTI'; +NO_OUTER_JOIN_TO_INNER : 'NO_OUTER_JOIN_TO_INNER'; +NOOVERRIDE : 'NOOVERRIDE'; +NO_PARALLEL_INDEX : 'NO_PARALLEL_INDEX'; +NOPARALLEL_INDEX : 'NOPARALLEL_INDEX'; +NO_PARALLEL : 'NO_PARALLEL'; +NOPARALLEL : 'NOPARALLEL'; +NO_PARTIAL_COMMIT : 'NO_PARTIAL_COMMIT'; +NO_PARTIAL_JOIN : 'NO_PARTIAL_JOIN'; +NO_PARTIAL_ROLLUP_PUSHDOWN : 'NO_PARTIAL_ROLLUP_PUSHDOWN'; +NOPARTITION : 'NOPARTITION'; +NO_PLACE_DISTINCT : 'NO_PLACE_DISTINCT'; +NO_PLACE_GROUP_BY : 'NO_PLACE_GROUP_BY'; +NO_PQ_CONCURRENT_UNION : 'NO_PQ_CONCURRENT_UNION'; +NO_PQ_MAP : 'NO_PQ_MAP'; +NOPROMPT : 'NOPROMPT'; +NO_PQ_REPLICATE : 'NO_PQ_REPLICATE'; +NO_PQ_SKEW : 'NO_PQ_SKEW'; +NO_PRUNE_GSETS : 'NO_PRUNE_GSETS'; +NO_PULL_PRED : 'NO_PULL_PRED'; +NO_PUSH_PRED : 'NO_PUSH_PRED'; +NO_PUSH_SUBQ : 'NO_PUSH_SUBQ'; +NO_PX_FAULT_TOLERANCE : 'NO_PX_FAULT_TOLERANCE'; +NO_PX_JOIN_FILTER : 'NO_PX_JOIN_FILTER'; +NO_QKN_BUFF : 'NO_QKN_BUFF'; +NO_QUERY_TRANSFORMATION : 'NO_QUERY_TRANSFORMATION'; +NO_REF_CASCADE : 'NO_REF_CASCADE'; +NORELOCATE : 'NORELOCATE'; +NORELY : 'NORELY'; +NOREPAIR : 'NOREPAIR'; +NOREPLAY : 'NOREPLAY'; +NORESETLOGS : 'NORESETLOGS'; +NO_RESULT_CACHE : 'NO_RESULT_CACHE'; +NOREVERSE : 'NOREVERSE'; +NO_REWRITE : 'NO_REWRITE'; +NOREWRITE : 'NOREWRITE'; +NORMAL : 'NORMAL'; +NO_ROOT_SW_FOR_LOCAL : 'NO_ROOT_SW_FOR_LOCAL'; +NOROWDEPENDENCIES : 'NOROWDEPENDENCIES'; +NOSCHEMACHECK : 'NOSCHEMACHECK'; +NOSEGMENT : 'NOSEGMENT'; +NO_SEMIJOIN : 'NO_SEMIJOIN'; +NO_SEMI_TO_INNER : 'NO_SEMI_TO_INNER'; +NO_SET_TO_JOIN : 'NO_SET_TO_JOIN'; +NOSORT : 'NOSORT'; +NO_SQL_TRANSLATION : 'NO_SQL_TRANSLATION'; +NO_SQL_TUNE : 'NO_SQL_TUNE'; +NO_STAR_TRANSFORMATION : 'NO_STAR_TRANSFORMATION'; +NO_STATEMENT_QUEUING : 'NO_STATEMENT_QUEUING'; +NO_STATS_GSETS : 'NO_STATS_GSETS'; +NOSTRICT : 'NOSTRICT'; +NO_SUBQUERY_PRUNING : 'NO_SUBQUERY_PRUNING'; +NO_SUBSTRB_PAD : 'NO_SUBSTRB_PAD'; +NO_SWAP_JOIN_INPUTS : 'NO_SWAP_JOIN_INPUTS'; +NOSWITCH : 'NOSWITCH'; +NO_TABLE_LOOKUP_BY_NL : 'NO_TABLE_LOOKUP_BY_NL'; +NO_TEMP_TABLE : 'NO_TEMP_TABLE'; +NOTHING : 'NOTHING'; +NOTIFICATION : 'NOTIFICATION'; +NOT : 'NOT'; +NO_TRANSFORM_DISTINCT_AGG : 'NO_TRANSFORM_DISTINCT_AGG'; +NO_UNNEST : 'NO_UNNEST'; +NO_USE_CUBE : 'NO_USE_CUBE'; +NO_USE_HASH_AGGREGATION : 'NO_USE_HASH_AGGREGATION'; +NO_USE_HASH_GBY_FOR_PUSHDOWN : 'NO_USE_HASH_GBY_FOR_PUSHDOWN'; +NO_USE_HASH : 'NO_USE_HASH'; +NO_USE_INVISIBLE_INDEXES : 'NO_USE_INVISIBLE_INDEXES'; +NO_USE_MERGE : 'NO_USE_MERGE'; +NO_USE_NL : 'NO_USE_NL'; +NO_USE_VECTOR_AGGREGATION : 'NO_USE_VECTOR_AGGREGATION'; +NOVALIDATE : 'NOVALIDATE'; +NO_VECTOR_TRANSFORM_DIMS : 'NO_VECTOR_TRANSFORM_DIMS'; +NO_VECTOR_TRANSFORM_FACT : 'NO_VECTOR_TRANSFORM_FACT'; +NO_VECTOR_TRANSFORM : 'NO_VECTOR_TRANSFORM'; +NOWAIT : 'NOWAIT'; +NO_XDB_FASTPATH_INSERT : 'NO_XDB_FASTPATH_INSERT'; +NO_XML_DML_REWRITE : 'NO_XML_DML_REWRITE'; +NO_XMLINDEX_REWRITE_IN_SELECT : 'NO_XMLINDEX_REWRITE_IN_SELECT'; +NO_XMLINDEX_REWRITE : 'NO_XMLINDEX_REWRITE'; +NO_XML_QUERY_REWRITE : 'NO_XML_QUERY_REWRITE'; +NO_ZONEMAP : 'NO_ZONEMAP'; +NTH_VALUE : 'NTH_VALUE'; +NULLIF : 'NULLIF'; +NULL_ : 'NULL'; +NULLS : 'NULLS'; +NUMBER : 'NUMBER'; +NUMERIC : 'NUMERIC'; +NUM_INDEX_KEYS : 'NUM_INDEX_KEYS'; +NUMTODSINTERVAL : 'NUMTODSINTERVAL'; +NUMTOYMINTERVAL : 'NUMTOYMINTERVAL'; +NVARCHAR2 : 'NVARCHAR2'; +NVL2 : 'NVL2'; +OBJECT2XML : 'OBJECT2XML'; +OBJECT : 'OBJECT'; +OBJ_ID : 'OBJ_ID'; +OBJNO : 'OBJNO'; +OBJNO_REUSE : 'OBJNO_REUSE'; +OCCURENCES : 'OCCURENCES'; +OFFLINE : 'OFFLINE'; +OFF : 'OFF'; +OFFSET : 'OFFSET'; +OF : 'OF'; +OIDINDEX : 'OIDINDEX'; +OID : 'OID'; +OLAP : 'OLAP'; +OLD : 'OLD'; +OLD_PUSH_PRED : 'OLD_PUSH_PRED'; +OLS : 'OLS'; +OLTP : 'OLTP'; +OMIT : 'OMIT'; +ONE : 'ONE'; +ONLINE : 'ONLINE'; +ONLINELOG : 'ONLINELOG'; +ONLY : 'ONLY'; +ON : 'ON'; +OPAQUE : 'OPAQUE'; +OPAQUE_TRANSFORM : 'OPAQUE_TRANSFORM'; +OPAQUE_XCANONICAL : 'OPAQUE_XCANONICAL'; +OPCODE : 'OPCODE'; +OPEN : 'OPEN'; +OPERATIONS : 'OPERATIONS'; +OPERATOR : 'OPERATOR'; +OPT_ESTIMATE : 'OPT_ESTIMATE'; +OPTIMAL : 'OPTIMAL'; +OPTIMIZE : 'OPTIMIZE'; +OPTIMIZER_FEATURES_ENABLE : 'OPTIMIZER_FEATURES_ENABLE'; +OPTIMIZER_GOAL : 'OPTIMIZER_GOAL'; +OPTION : 'OPTION'; +OPT_PARAM : 'OPT_PARAM'; +ORA_BRANCH : 'ORA_BRANCH'; +ORA_CHECK_ACL : 'ORA_CHECK_ACL'; +ORA_CHECK_PRIVILEGE : 'ORA_CHECK_PRIVILEGE'; +ORA_CLUSTERING : 'ORA_CLUSTERING'; +ORADATA : 'ORADATA'; +ORADEBUG : 'ORADEBUG'; +ORA_DST_AFFECTED : 'ORA_DST_AFFECTED'; +ORA_DST_CONVERT : 'ORA_DST_CONVERT'; +ORA_DST_ERROR : 'ORA_DST_ERROR'; +ORA_GET_ACLIDS : 'ORA_GET_ACLIDS'; +ORA_GET_PRIVILEGES : 'ORA_GET_PRIVILEGES'; +ORA_HASH : 'ORA_HASH'; +ORA_INVOKING_USERID : 'ORA_INVOKING_USERID'; +ORA_INVOKING_USER : 'ORA_INVOKING_USER'; +ORA_INVOKING_XS_USER_GUID : 'ORA_INVOKING_XS_USER_GUID'; +ORA_INVOKING_XS_USER : 'ORA_INVOKING_XS_USER'; +ORA_RAWCOMPARE : 'ORA_RAWCOMPARE'; +ORA_RAWCONCAT : 'ORA_RAWCONCAT'; +ORA_ROWSCN : 'ORA_ROWSCN'; +ORA_ROWSCN_RAW : 'ORA_ROWSCN_RAW'; +ORA_ROWVERSION : 'ORA_ROWVERSION'; +ORA_TABVERSION : 'ORA_TABVERSION'; +ORA_WRITE_TIME : 'ORA_WRITE_TIME'; +ORDERED : 'ORDERED'; +ORDERED_PREDICATES : 'ORDERED_PREDICATES'; +ORDER : 'ORDER'; +ORDINALITY : 'ORDINALITY'; +OR_EXPAND : 'OR_EXPAND'; +ORGANIZATION : 'ORGANIZATION'; +OR : 'OR'; +OR_PREDICATES : 'OR_PREDICATES'; +OSERROR : 'OSERROR'; +OTHER : 'OTHER'; +OUTER_JOIN_TO_ANTI : 'OUTER_JOIN_TO_ANTI'; +OUTER_JOIN_TO_INNER : 'OUTER_JOIN_TO_INNER'; +OUTER : 'OUTER'; +OUTLINE_LEAF : 'OUTLINE_LEAF'; +OUTLINE : 'OUTLINE'; +OUT_OF_LINE : 'OUT_OF_LINE'; +OUT : 'OUT'; +OVERFLOW_NOMOVE : 'OVERFLOW_NOMOVE'; +OVERFLOW : 'OVERFLOW'; +OVERLAPS : 'OVERLAPS'; +OVER : 'OVER'; +OVERRIDING : 'OVERRIDING'; +OWNER : 'OWNER'; +OWNERSHIP : 'OWNERSHIP'; +OWN : 'OWN'; +P_LETTER : 'P'; +PACKAGE : 'PACKAGE'; +PACKAGES : 'PACKAGES'; +PARALLEL_ENABLE : 'PARALLEL_ENABLE'; +PARALLEL_INDEX : 'PARALLEL_INDEX'; +PARALLEL : 'PARALLEL'; +PARAMETERFILE : 'PARAMETERFILE'; +PARAMETERS : 'PARAMETERS'; +PARAM : 'PARAM'; +PARENT : 'PARENT'; +PARENT_LEVEL_NAME : 'PARENT_LEVEL_NAME'; +PARENT_UNIQUE_NAME : 'PARENT_UNIQUE_NAME'; +PARITY : 'PARITY'; +PARTIAL_JOIN : 'PARTIAL_JOIN'; +PARTIALLY : 'PARTIALLY'; +PARTIAL : 'PARTIAL'; +PARTIAL_ROLLUP_PUSHDOWN : 'PARTIAL_ROLLUP_PUSHDOWN'; +PARTITION_HASH : 'PARTITION_HASH'; +PARTITION_LIST : 'PARTITION_LIST'; +PARTITION : 'PARTITION'; +PARTITION_RANGE : 'PARTITION_RANGE'; +PARTITIONS : 'PARTITIONS'; +PARTNUMINST : 'PART$NUM$INST'; +PASSING : 'PASSING'; +PASSWORD_GRACE_TIME : 'PASSWORD_GRACE_TIME'; +PASSWORD_LIFE_TIME : 'PASSWORD_LIFE_TIME'; +PASSWORD_LOCK_TIME : 'PASSWORD_LOCK_TIME'; +PASSWORD : 'PASSWORD'; +PASSWORD_REUSE_MAX : 'PASSWORD_REUSE_MAX'; +PASSWORD_REUSE_TIME : 'PASSWORD_REUSE_TIME'; +PASSWORD_ROLLOVER_TIME : 'PASSWORD_ROLLOVER_TIME'; +PASSWORD_VERIFY_FUNCTION : 'PASSWORD_VERIFY_FUNCTION'; +PAST : 'PAST'; +PATCH : 'PATCH'; +PATH : 'PATH'; +PATH_PREFIX : 'PATH_PREFIX'; +PATHS : 'PATHS'; +PATTERN : 'PATTERN'; +PBL_HS_BEGIN : 'PBL_HS_BEGIN'; +PBL_HS_END : 'PBL_HS_END'; +PCTFREE : 'PCTFREE'; +PCTINCREASE : 'PCTINCREASE'; +PCTTHRESHOLD : 'PCTTHRESHOLD'; +PCTUSED : 'PCTUSED'; +PCTVERSION : 'PCTVERSION'; +PENDING : 'PENDING'; +PERCENT_FOUND : '%' SPACE* 'FOUND'; +PERCENT_ISOPEN : '%' SPACE* 'ISOPEN'; +PERCENT_NOTFOUND : '%' SPACE* 'NOTFOUND'; +PERCENT_KEYWORD : 'PERCENT'; +PERCENT_RANKM : 'PERCENT_RANKM'; +PERCENT_ROWCOUNT : '%' SPACE* 'ROWCOUNT'; +PERCENT_ROWTYPE : '%' SPACE* 'ROWTYPE'; +PERCENT_TYPE : '%' SPACE* 'TYPE'; +PERFORMANCE : 'PERFORMANCE'; +PERIOD_KEYWORD : 'PERIOD'; +PERMANENT : 'PERMANENT'; +PERMISSION : 'PERMISSION'; +PERMUTE : 'PERMUTE'; +PER : 'PER'; +PFILE : 'PFILE'; +PHYSICAL : 'PHYSICAL'; +PIKEY : 'PIKEY'; +PIPELINED : 'PIPELINED'; +PIPE : 'PIPE'; +PIV_GB : 'PIV_GB'; +PIVOT : 'PIVOT'; +PIV_SSF : 'PIV_SSF'; +PLACE_DISTINCT : 'PLACE_DISTINCT'; +PLACE_GROUP_BY : 'PLACE_GROUP_BY'; +PLAN : 'PLAN'; +PLSCOPE_SETTINGS : 'PLSCOPE_SETTINGS'; +PLS_INTEGER : 'PLS_INTEGER'; +PLSQL_CCFLAGS : 'PLSQL_CCFLAGS'; +PLSQL_CODE_TYPE : 'PLSQL_CODE_TYPE'; +PLSQL_DEBUG : 'PLSQL_DEBUG'; +PLSQL_OPTIMIZE_LEVEL : 'PLSQL_OPTIMIZE_LEVEL'; +PLSQL_WARNINGS : 'PLSQL_WARNINGS'; +PLUGGABLE : 'PLUGGABLE'; +PMEM : 'PMEM'; +POINT : 'POINT'; +POLICY : 'POLICY'; +POOL_16K : 'POOL_16K'; +POOL_2K : 'POOL_2K'; +POOL_32K : 'POOL_32K'; +POOL_4K : 'POOL_4K'; +POOL_8K : 'POOL_8K'; +POSITIVEN : 'POSITIVEN'; +POSITIVE : 'POSITIVE'; +POST_TRANSACTION : 'POST_TRANSACTION'; +POWERMULTISET_BY_CARDINALITY : 'POWERMULTISET_BY_CARDINALITY'; +POWERMULTISET : 'POWERMULTISET'; +POWER : 'POWER'; +PQ_CONCURRENT_UNION : 'PQ_CONCURRENT_UNION'; +PQ_DISTRIBUTE : 'PQ_DISTRIBUTE'; +PQ_DISTRIBUTE_WINDOW : 'PQ_DISTRIBUTE_WINDOW'; +PQ_FILTER : 'PQ_FILTER'; +PQ_MAP : 'PQ_MAP'; +PQ_NOMAP : 'PQ_NOMAP'; +PQ_REPLICATE : 'PQ_REPLICATE'; +PQ_SKEW : 'PQ_SKEW'; +PRAGMA : 'PRAGMA'; +PREBUILT : 'PREBUILT'; +PRECEDES : 'PRECEDES'; +PRECEDING : 'PRECEDING'; +PRECISION : 'PRECISION'; +PRECOMPUTE_SUBQUERY : 'PRECOMPUTE_SUBQUERY'; +PREDICATE_REORDERS : 'PREDICATE_REORDERS'; +PRELOAD : 'PRELOAD'; +PREPARE : 'PREPARE'; +PRESENTNNV : 'PRESENTNNV'; +PRESENT : 'PRESENT'; +PRESENTV : 'PRESENTV'; +PRESERVE_OID : 'PRESERVE_OID'; +PRESERVE : 'PRESERVE'; +PRETTY : 'PRETTY'; +PREVIOUS : 'PREVIOUS'; +PREV : 'PREV'; +PRIMARY : 'PRIMARY'; +PRINTBLOBTOCLOB : 'PRINTBLOBTOCLOB'; +PRIORITY : 'PRIORITY'; +PRIOR : 'PRIOR'; +PRIVATE : 'PRIVATE'; +PRIVATE_SGA : 'PRIVATE_SGA'; +PRIVILEGED : 'PRIVILEGED'; +PRIVILEGE : 'PRIVILEGE'; +PRIVILEGES : 'PRIVILEGES'; +PROCEDURAL : 'PROCEDURAL'; +PROCEDURE : 'PROCEDURE'; +PROCESS : 'PROCESS'; +PROFILE : 'PROFILE'; +PROGRAM : 'PROGRAM'; +PROJECT : 'PROJECT'; +PROPAGATE : 'PROPAGATE'; +PROPERTY : 'PROPERTY'; +PROTECTED : 'PROTECTED'; +PROTECTION : 'PROTECTION'; +PROTOCOL : 'PROTOCOL'; +PROXY : 'PROXY'; +PRUNING : 'PRUNING'; +PUBLIC : 'PUBLIC'; +PULL_PRED : 'PULL_PRED'; +PURGE : 'PURGE'; +PUSH_PRED : 'PUSH_PRED'; +PUSH_SUBQ : 'PUSH_SUBQ'; +PX_FAULT_TOLERANCE : 'PX_FAULT_TOLERANCE'; +PX_GRANULE : 'PX_GRANULE'; +PX_JOIN_FILTER : 'PX_JOIN_FILTER'; +QB_NAME : 'QB_NAME'; +QUARTERS : 'QUARTERS'; +QUERY_BLOCK : 'QUERY_BLOCK'; +QUERY : 'QUERY'; +QUEUE_CURR : 'QUEUE_CURR'; +QUEUE : 'QUEUE'; +QUEUE_ROWP : 'QUEUE_ROWP'; +QUIESCE : 'QUIESCE'; +QUORUM : 'QUORUM'; +QUOTA : 'QUOTA'; +QUOTAGROUP : 'QUOTAGROUP'; +RAISE : 'RAISE'; +RANDOM_LOCAL : 'RANDOM_LOCAL'; +RANDOM : 'RANDOM'; +RANGE : 'RANGE'; +RANKM : 'RANKM'; +RAPIDLY : 'RAPIDLY'; +RAW : 'RAW'; +RAWTOHEX : 'RAWTOHEX'; +RAWTONHEX : 'RAWTONHEX'; +RBA : 'RBA'; +RBO_OUTLINE : 'RBO_OUTLINE'; +RDBA : 'RDBA'; +READ : 'READ'; +READS : 'READS'; +REALM : 'REALM'; +REAL : 'REAL'; +REBALANCE : 'REBALANCE'; +REBUILD : 'REBUILD'; +RECORD : 'RECORD'; +RECORDS_PER_BLOCK : 'RECORDS_PER_BLOCK'; +RECOVERABLE : 'RECOVERABLE'; +RECOVER : 'RECOVER'; +RECOVERY : 'RECOVERY'; +RECYCLEBIN : 'RECYCLEBIN'; +RECYCLE : 'RECYCLE'; +REDACTION : 'REDACTION'; +REDEFINE : 'REDEFINE'; +REDO : 'REDO'; +REDUCED : 'REDUCED'; +REDUNDANCY : 'REDUNDANCY'; +REF_CASCADE_CURSOR : 'REF_CASCADE_CURSOR'; +REFERENCED : 'REFERENCED'; +REFERENCE : 'REFERENCE'; +REFERENCES : 'REFERENCES'; +REFERENCING : 'REFERENCING'; +REF : 'REF'; +REFRESH : 'REFRESH'; +REFTOHEX : 'REFTOHEX'; +REGEXP_COUNT : 'REGEXP_COUNT'; +REGEXP_INSTR : 'REGEXP_INSTR'; +REGEXP_LIKE : 'REGEXP_LIKE'; +REGEXP_REPLACE : 'REGEXP_REPLACE'; +REGEXP_SUBSTR : 'REGEXP_SUBSTR'; +REGISTER : 'REGISTER'; +REGR_AVGX : 'REGR_AVGX'; +REGR_AVGY : 'REGR_AVGY'; +REGR_COUNT : 'REGR_COUNT'; +REGR_INTERCEPT : 'REGR_INTERCEPT'; +REGR_R2 : 'REGR_R2'; +REGR_SLOPE : 'REGR_SLOPE'; +REGR_SXX : 'REGR_SXX'; +REGR_SXY : 'REGR_SXY'; +REGR_SYY : 'REGR_SYY'; +REGULAR : 'REGULAR'; +REJECT : 'REJECT'; +REKEY : 'REKEY'; +RELATIONAL : 'RELATIONAL'; +RELIES_ON : 'RELIES_ON'; +RELOCATE : 'RELOCATE'; +RELY : 'RELY'; +REMAINDER : 'REMAINDER'; +REMOTE : 'REMOTE'; +REMOTE_MAPPED : 'REMOTE_MAPPED'; +REMOVE : 'REMOVE'; +RENAME : 'RENAME'; +REPAIR : 'REPAIR'; +REPEAT : 'REPEAT'; +REPLACE : 'REPLACE'; +REPLICATION : 'REPLICATION'; +REQUIRED : 'REQUIRED'; +RESETLOGS : 'RESETLOGS'; +RESET : 'RESET'; +RESIZE : 'RESIZE'; +RESOLVE : 'RESOLVE'; +RESOLVER : 'RESOLVER'; +RESOURCE : 'RESOURCE'; +RESPECT : 'RESPECT'; +RESTART : 'RESTART'; +RESTORE_AS_INTERVALS : 'RESTORE_AS_INTERVALS'; +RESTORE : 'RESTORE'; +RESTRICT_ALL_REF_CONS : 'RESTRICT_ALL_REF_CONS'; +RESTRICTED : 'RESTRICTED'; +RESTRICT_REFERENCES : 'RESTRICT_REFERENCES'; +RESTRICT : 'RESTRICT'; +RESULT_CACHE : 'RESULT_CACHE'; +RESULT : 'RESULT'; +RESUMABLE : 'RESUMABLE'; +RESUME : 'RESUME'; +RETENTION : 'RETENTION'; +RETRY_ON_ROW_CHANGE : 'RETRY_ON_ROW_CHANGE'; +RETURNING : 'RETURNING'; +RETURN : 'RETURN'; +REUSE : 'REUSE'; +REVERSE : 'REVERSE'; +REVOKE : 'REVOKE'; +REWRITE_OR_ERROR : 'REWRITE_OR_ERROR'; +REWRITE : 'REWRITE'; +RIGHT : 'RIGHT'; +ROLE : 'ROLE'; +ROLESET : 'ROLESET'; +ROLES : 'ROLES'; +ROLLBACK : 'ROLLBACK'; +ROLLING : 'ROLLING'; +ROLLUP : 'ROLLUP'; +ROWDEPENDENCIES : 'ROWDEPENDENCIES'; +ROWID_MAPPING_TABLE : 'ROWID_MAPPING_TABLE'; +ROWID : 'ROWID'; +ROWIDTOCHAR : 'ROWIDTOCHAR'; +ROWIDTONCHAR : 'ROWIDTONCHAR'; +ROW_LENGTH : 'ROW_LENGTH'; +ROWNUM : 'ROWNUM'; +ROW : 'ROW'; +ROWS : 'ROWS'; +RPAD : 'RPAD'; +RTRIM : 'RTRIM'; +RULE : 'RULE'; +RULES : 'RULES'; +RUNNING : 'RUNNING'; +SALT : 'SALT'; +SAMPLE : 'SAMPLE'; +SAVE_AS_INTERVALS : 'SAVE_AS_INTERVALS'; +SAVEPOINT : 'SAVEPOINT'; +SAVE : 'SAVE'; +SB4 : 'SB4'; +SCALE_ROWS : 'SCALE_ROWS'; +SCALE : 'SCALE'; +SCAN_INSTANCES : 'SCAN_INSTANCES'; +SCAN : 'SCAN'; +SCHEDULER : 'SCHEDULER'; +SCHEMACHECK : 'SCHEMACHECK'; +SCHEMA : 'SCHEMA'; +SCN_ASCENDING : 'SCN_ASCENDING'; +SCN : 'SCN'; +SCOPE : 'SCOPE'; +SCRUB : 'SCRUB'; +SD_ALL : 'SD_ALL'; +SD_INHIBIT : 'SD_INHIBIT'; +SDO_GEOM_MBR : 'SDO_GEOM_MBR'; +SDO_GEOMETRY : 'SDO_GEOMETRY'; +SD_SHOW : 'SD_SHOW'; +SEARCH : 'SEARCH'; +SECOND : 'SECOND'; +SECONDS : 'SECONDS'; +SECRET : 'SECRET'; +SECUREFILE_DBA : 'SECUREFILE_DBA'; +SECUREFILE : 'SECUREFILE'; +SECURITY : 'SECURITY'; +SEED : 'SEED'; +SEG_BLOCK : 'SEG_BLOCK'; +SEG_FILE : 'SEG_FILE'; +SEGMENT : 'SEGMENT'; +SELECTIVITY : 'SELECTIVITY'; +SELECT : 'SELECT'; +SELF : 'SELF'; +SEMIJOIN_DRIVER : 'SEMIJOIN_DRIVER'; +SEMIJOIN : 'SEMIJOIN'; +SEMI_TO_INNER : 'SEMI_TO_INNER'; +SEQUENCED : 'SEQUENCED'; +SEQUENCE : 'SEQUENCE'; +SEQUENTIAL : 'SEQUENTIAL'; +SEQ : 'SEQ'; +SERIALIZABLE : 'SERIALIZABLE'; +SERIALLY_REUSABLE : 'SERIALLY_REUSABLE'; +SERIAL : 'SERIAL'; +SERVERERROR : 'SERVERERROR'; +SERVICE_NAME_CONVERT : 'SERVICE_NAME_CONVERT'; +SERVICE : 'SERVICE'; +SERVICES : 'SERVICES'; +SESSION_CACHED_CURSORS : 'SESSION_CACHED_CURSORS'; +SESSION : 'SESSION'; +SESSIONS_PER_USER : 'SESSIONS_PER_USER'; +SESSIONTIMEZONE : 'SESSIONTIMEZONE'; +SESSIONTZNAME : 'SESSIONTZNAME'; +SET : 'SET'; +SETS : 'SETS'; +SETTINGS : 'SETTINGS'; +SET_TO_JOIN : 'SET_TO_JOIN'; +SEVERE : 'SEVERE'; +SHARDSPACE : 'SHARDSPACE'; +SHARED_POOL : 'SHARED_POOL'; +SHARED : 'SHARED'; +SHARE : 'SHARE'; +SHARING : 'SHARING'; +SHELFLIFE : 'SHELFLIFE'; +SHOW : 'SHOW'; +SHRINK : 'SHRINK'; +SHUTDOWN : 'SHUTDOWN'; +SIBLINGS : 'SIBLINGS'; +SID : 'SID'; +SITE : 'SITE'; +SIGNAL_COMPONENT : 'SIGNAL_COMPONENT'; +SIGNAL_FUNCTION : 'SIGNAL_FUNCTION'; +SIGN : 'SIGN'; +SIGNTYPE : 'SIGNTYPE'; +SIMPLE_INTEGER : 'SIMPLE_INTEGER'; +SIMPLE : 'SIMPLE'; +SINGLE : 'SINGLE'; +SINGLETASK : 'SINGLETASK'; +SINH : 'SINH'; +SIN : 'SIN'; +SIZE : 'SIZE'; +SKIP_EXT_OPTIMIZER : 'SKIP_EXT_OPTIMIZER'; +SKIP_ : 'SKIP'; +SKIP_UNQ_UNUSABLE_IDX : 'SKIP_UNQ_UNUSABLE_IDX'; +SKIP_UNUSABLE_INDEXES : 'SKIP_UNUSABLE_INDEXES'; +SMALLFILE : 'SMALLFILE'; +SMALLINT : 'SMALLINT'; +SNAPSHOT : 'SNAPSHOT'; +SOME : 'SOME'; +SORT : 'SORT'; +SOUNDEX : 'SOUNDEX'; +SOURCE_FILE_DIRECTORY : 'SOURCE_FILE_DIRECTORY'; +SOURCE_FILE_NAME_CONVERT : 'SOURCE_FILE_NAME_CONVERT'; +SOURCE : 'SOURCE'; +SPACE_KEYWORD : 'SPACE'; +SPECIFICATION : 'SPECIFICATION'; +SPFILE : 'SPFILE'; +SPLIT : 'SPLIT'; +SPREADSHEET : 'SPREADSHEET'; +SQLDATA : 'SQLDATA'; +SQLERROR : 'SQLERROR'; +SQLLDR : 'SQLLDR'; +SQL : 'SQL'; +FILE_EXT : 'PKB' | 'PKS'; +SQL_MACRO : 'SQL_MACRO'; +SQL_TRACE : 'SQL_TRACE'; +SQL_TRANSLATION_PROFILE : 'SQL_TRANSLATION_PROFILE'; +SQRT : 'SQRT'; +STALE : 'STALE'; +STANDALONE : 'STANDALONE'; +STANDARD : 'STANDARD'; +STANDARD_HASH : 'STANDARD_HASH'; +STANDBY_MAX_DATA_DELAY : 'STANDBY_MAX_DATA_DELAY'; +STANDBYS : 'STANDBYS'; +STANDBY : 'STANDBY'; +STAR : 'STAR'; +STAR_TRANSFORMATION : 'STAR_TRANSFORMATION'; +START : 'START'; +STARTUP : 'STARTUP'; +STATEMENT_ID : 'STATEMENT_ID'; +STATEMENT_QUEUING : 'STATEMENT_QUEUING'; +STATEMENTS : 'STATEMENTS'; +STATEMENT : 'STATEMENT'; +STATE : 'STATE'; +STATIC : 'STATIC'; +STATISTICS : 'STATISTICS'; +STATS_BINOMIAL_TEST : 'STATS_BINOMIAL_TEST'; +STATS_CROSSTAB : 'STATS_CROSSTAB'; +STATS_F_TEST : 'STATS_F_TEST'; +STATS_KS_TEST : 'STATS_KS_TEST'; +STATS_MODE : 'STATS_MODE'; +STATS_MW_TEST : 'STATS_MW_TEST'; +STATS_ONE_WAY_ANOVA : 'STATS_ONE_WAY_ANOVA'; +STATS_T_TEST_INDEP : 'STATS_T_TEST_INDEP'; +STATS_T_TEST_INDEPU : 'STATS_T_TEST_INDEPU'; +STATS_T_TEST_ONE : 'STATS_T_TEST_ONE'; +STATS_T_TEST_PAIRED : 'STATS_T_TEST_PAIRED'; +STATS_WSR_TEST : 'STATS_WSR_TEST'; +STDDEV_POP : 'STDDEV_POP'; +STDDEV_SAMP : 'STDDEV_SAMP'; +STOP : 'STOP'; +STORAGE : 'STORAGE'; +STORE : 'STORE'; +STREAMS : 'STREAMS'; +STREAM : 'STREAM'; +STRICT : 'STRICT'; +STRING : 'STRING'; +STRIPE_COLUMNS : 'STRIPE_COLUMNS'; +STRIPE_WIDTH : 'STRIPE_WIDTH'; +STRIP : 'STRIP'; +STRUCTURE : 'STRUCTURE'; +SUBMULTISET : 'SUBMULTISET'; +SUBPARTITION_REL : 'SUBPARTITION_REL'; +SUBPARTITIONS : 'SUBPARTITIONS'; +SUBPARTITION : 'SUBPARTITION'; +SUBQUERIES : 'SUBQUERIES'; +SUBQUERY_PRUNING : 'SUBQUERY_PRUNING'; +SUBSCRIBE : 'SUBSCRIBE'; +SUBSET : 'SUBSET'; +SUBSTITUTABLE : 'SUBSTITUTABLE'; +SUBSTR2 : 'SUBSTR2'; +SUBSTR4 : 'SUBSTR4'; +SUBSTRB : 'SUBSTRB'; +SUBSTRC : 'SUBSTRC'; +SUBTYPE : 'SUBTYPE'; +SUCCESSFUL : 'SUCCESSFUL'; +SUCCESS : 'SUCCESS'; +SUMMARY : 'SUMMARY'; +SUPPLEMENTAL : 'SUPPLEMENTAL'; +SUSPEND : 'SUSPEND'; +SWAP_JOIN_INPUTS : 'SWAP_JOIN_INPUTS'; +SWITCHOVER : 'SWITCHOVER'; +SWITCH : 'SWITCH'; +SYNCHRONOUS : 'SYNCHRONOUS'; +SYNC : 'SYNC'; +SYNONYM : 'SYNONYM'; +SYS : 'SYS'; +SYSASM : 'SYSASM'; +SYS_AUDIT : 'SYS_AUDIT'; +SYSAUX : 'SYSAUX'; +SYSBACKUP : 'SYSBACKUP'; +SYS_CHECKACL : 'SYS_CHECKACL'; +SYS_CHECK_PRIVILEGE : 'SYS_CHECK_PRIVILEGE'; +SYS_CONNECT_BY_PATH : 'SYS_CONNECT_BY_PATH'; +SYS_CONTEXT : 'SYS_CONTEXT'; +SYSDATE : 'SYSDATE'; +SYSDBA : 'SYSDBA'; +SYS_DBURIGEN : 'SYS_DBURIGEN'; +SYSDG : 'SYSDG'; +SYS_DL_CURSOR : 'SYS_DL_CURSOR'; +SYS_DM_RXFORM_CHR : 'SYS_DM_RXFORM_CHR'; +SYS_DM_RXFORM_NUM : 'SYS_DM_RXFORM_NUM'; +SYS_DOM_COMPARE : 'SYS_DOM_COMPARE'; +SYS_DST_PRIM2SEC : 'SYS_DST_PRIM2SEC'; +SYS_DST_SEC2PRIM : 'SYS_DST_SEC2PRIM'; +SYS_ET_BFILE_TO_RAW : 'SYS_ET_BFILE_TO_RAW'; +SYS_ET_BLOB_TO_IMAGE : 'SYS_ET_BLOB_TO_IMAGE'; +SYS_ET_IMAGE_TO_BLOB : 'SYS_ET_IMAGE_TO_BLOB'; +SYS_ET_RAW_TO_BFILE : 'SYS_ET_RAW_TO_BFILE'; +SYS_EXTPDTXT : 'SYS_EXTPDTXT'; +SYS_EXTRACT_UTC : 'SYS_EXTRACT_UTC'; +SYS_FBT_INSDEL : 'SYS_FBT_INSDEL'; +SYS_FILTER_ACLS : 'SYS_FILTER_ACLS'; +SYS_FNMATCHES : 'SYS_FNMATCHES'; +SYS_FNREPLACE : 'SYS_FNREPLACE'; +SYS_GET_ACLIDS : 'SYS_GET_ACLIDS'; +SYS_GET_COL_ACLIDS : 'SYS_GET_COL_ACLIDS'; +SYS_GET_PRIVILEGES : 'SYS_GET_PRIVILEGES'; +SYS_GETTOKENID : 'SYS_GETTOKENID'; +SYS_GETXTIVAL : 'SYS_GETXTIVAL'; +SYS_GUID : 'SYS_GUID'; +SYSGUID : 'SYSGUID'; +SYSKM : 'SYSKM'; +SYS_MAKE_XMLNODEID : 'SYS_MAKE_XMLNODEID'; +SYS_MAKEXML : 'SYS_MAKEXML'; +SYS_MKXMLATTR : 'SYS_MKXMLATTR'; +SYS_MKXTI : 'SYS_MKXTI'; +SYSOBJ : 'SYSOBJ'; +SYS_OP_ADT2BIN : 'SYS_OP_ADT2BIN'; +SYS_OP_ADTCONS : 'SYS_OP_ADTCONS'; +SYS_OP_ALSCRVAL : 'SYS_OP_ALSCRVAL'; +SYS_OP_ATG : 'SYS_OP_ATG'; +SYS_OP_BIN2ADT : 'SYS_OP_BIN2ADT'; +SYS_OP_BITVEC : 'SYS_OP_BITVEC'; +SYS_OP_BL2R : 'SYS_OP_BL2R'; +SYS_OP_BLOOM_FILTER_LIST : 'SYS_OP_BLOOM_FILTER_LIST'; +SYS_OP_BLOOM_FILTER : 'SYS_OP_BLOOM_FILTER'; +SYS_OP_C2C : 'SYS_OP_C2C'; +SYS_OP_CAST : 'SYS_OP_CAST'; +SYS_OP_CEG : 'SYS_OP_CEG'; +SYS_OP_CL2C : 'SYS_OP_CL2C'; +SYS_OP_COMBINED_HASH : 'SYS_OP_COMBINED_HASH'; +SYS_OP_COMP : 'SYS_OP_COMP'; +SYS_OP_CONVERT : 'SYS_OP_CONVERT'; +SYS_OP_COUNTCHG : 'SYS_OP_COUNTCHG'; +SYS_OP_CSCONV : 'SYS_OP_CSCONV'; +SYS_OP_CSCONVTEST : 'SYS_OP_CSCONVTEST'; +SYS_OP_CSR : 'SYS_OP_CSR'; +SYS_OP_CSX_PATCH : 'SYS_OP_CSX_PATCH'; +SYS_OP_CYCLED_SEQ : 'SYS_OP_CYCLED_SEQ'; +SYS_OP_DECOMP : 'SYS_OP_DECOMP'; +SYS_OP_DESCEND : 'SYS_OP_DESCEND'; +SYS_OP_DISTINCT : 'SYS_OP_DISTINCT'; +SYS_OP_DRA : 'SYS_OP_DRA'; +SYS_OP_DUMP : 'SYS_OP_DUMP'; +SYS_OP_DV_CHECK : 'SYS_OP_DV_CHECK'; +SYS_OP_ENFORCE_NOT_NULL : 'SYS_OP_ENFORCE_NOT_NULL$'; +SYSOPER : 'SYSOPER'; +SYS_OP_EXTRACT : 'SYS_OP_EXTRACT'; +SYS_OP_GROUPING : 'SYS_OP_GROUPING'; +SYS_OP_GUID : 'SYS_OP_GUID'; +SYS_OP_HASH : 'SYS_OP_HASH'; +SYS_OP_IIX : 'SYS_OP_IIX'; +SYS_OP_ITR : 'SYS_OP_ITR'; +SYS_OP_KEY_VECTOR_CREATE : 'SYS_OP_KEY_VECTOR_CREATE'; +SYS_OP_KEY_VECTOR_FILTER_LIST : 'SYS_OP_KEY_VECTOR_FILTER_LIST'; +SYS_OP_KEY_VECTOR_FILTER : 'SYS_OP_KEY_VECTOR_FILTER'; +SYS_OP_KEY_VECTOR_SUCCEEDED : 'SYS_OP_KEY_VECTOR_SUCCEEDED'; +SYS_OP_KEY_VECTOR_USE : 'SYS_OP_KEY_VECTOR_USE'; +SYS_OP_LBID : 'SYS_OP_LBID'; +SYS_OP_LOBLOC2BLOB : 'SYS_OP_LOBLOC2BLOB'; +SYS_OP_LOBLOC2CLOB : 'SYS_OP_LOBLOC2CLOB'; +SYS_OP_LOBLOC2ID : 'SYS_OP_LOBLOC2ID'; +SYS_OP_LOBLOC2NCLOB : 'SYS_OP_LOBLOC2NCLOB'; +SYS_OP_LOBLOC2TYP : 'SYS_OP_LOBLOC2TYP'; +SYS_OP_LSVI : 'SYS_OP_LSVI'; +SYS_OP_LVL : 'SYS_OP_LVL'; +SYS_OP_MAKEOID : 'SYS_OP_MAKEOID'; +SYS_OP_MAP_NONNULL : 'SYS_OP_MAP_NONNULL'; +SYS_OP_MSR : 'SYS_OP_MSR'; +SYS_OP_NICOMBINE : 'SYS_OP_NICOMBINE'; +SYS_OP_NIEXTRACT : 'SYS_OP_NIEXTRACT'; +SYS_OP_NII : 'SYS_OP_NII'; +SYS_OP_NIX : 'SYS_OP_NIX'; +SYS_OP_NOEXPAND : 'SYS_OP_NOEXPAND'; +SYS_OP_NTCIMG : 'SYS_OP_NTCIMG$'; +SYS_OP_NUMTORAW : 'SYS_OP_NUMTORAW'; +SYS_OP_OIDVALUE : 'SYS_OP_OIDVALUE'; +SYS_OP_OPNSIZE : 'SYS_OP_OPNSIZE'; +SYS_OP_PAR_1 : 'SYS_OP_PAR_1'; +SYS_OP_PARGID_1 : 'SYS_OP_PARGID_1'; +SYS_OP_PARGID : 'SYS_OP_PARGID'; +SYS_OP_PAR : 'SYS_OP_PAR'; +SYS_OP_PART_ID : 'SYS_OP_PART_ID'; +SYS_OP_PIVOT : 'SYS_OP_PIVOT'; +SYS_OP_R2O : 'SYS_OP_R2O'; +SYS_OP_RAWTONUM : 'SYS_OP_RAWTONUM'; +SYS_OP_RDTM : 'SYS_OP_RDTM'; +SYS_OP_REF : 'SYS_OP_REF'; +SYS_OP_RMTD : 'SYS_OP_RMTD'; +SYS_OP_ROWIDTOOBJ : 'SYS_OP_ROWIDTOOBJ'; +SYS_OP_RPB : 'SYS_OP_RPB'; +SYS_OPTLOBPRBSC : 'SYS_OPTLOBPRBSC'; +SYS_OP_TOSETID : 'SYS_OP_TOSETID'; +SYS_OP_TPR : 'SYS_OP_TPR'; +SYS_OP_TRTB : 'SYS_OP_TRTB'; +SYS_OPTXICMP : 'SYS_OPTXICMP'; +SYS_OPTXQCASTASNQ : 'SYS_OPTXQCASTASNQ'; +SYS_OP_UNDESCEND : 'SYS_OP_UNDESCEND'; +SYS_OP_VECAND : 'SYS_OP_VECAND'; +SYS_OP_VECBIT : 'SYS_OP_VECBIT'; +SYS_OP_VECOR : 'SYS_OP_VECOR'; +SYS_OP_VECXOR : 'SYS_OP_VECXOR'; +SYS_OP_VERSION : 'SYS_OP_VERSION'; +SYS_OP_VREF : 'SYS_OP_VREF'; +SYS_OP_VVD : 'SYS_OP_VVD'; +SYS_OP_XMLCONS_FOR_CSX : 'SYS_OP_XMLCONS_FOR_CSX'; +SYS_OP_XPTHATG : 'SYS_OP_XPTHATG'; +SYS_OP_XPTHIDX : 'SYS_OP_XPTHIDX'; +SYS_OP_XPTHOP : 'SYS_OP_XPTHOP'; +SYS_OP_XTXT2SQLT : 'SYS_OP_XTXT2SQLT'; +SYS_OP_ZONE_ID : 'SYS_OP_ZONE_ID'; +SYS_ORDERKEY_DEPTH : 'SYS_ORDERKEY_DEPTH'; +SYS_ORDERKEY_MAXCHILD : 'SYS_ORDERKEY_MAXCHILD'; +SYS_ORDERKEY_PARENT : 'SYS_ORDERKEY_PARENT'; +SYS_PARALLEL_TXN : 'SYS_PARALLEL_TXN'; +SYS_PATHID_IS_ATTR : 'SYS_PATHID_IS_ATTR'; +SYS_PATHID_IS_NMSPC : 'SYS_PATHID_IS_NMSPC'; +SYS_PATHID_LASTNAME : 'SYS_PATHID_LASTNAME'; +SYS_PATHID_LASTNMSPC : 'SYS_PATHID_LASTNMSPC'; +SYS_PATH_REVERSE : 'SYS_PATH_REVERSE'; +SYS_PXQEXTRACT : 'SYS_PXQEXTRACT'; +SYS_RAW_TO_XSID : 'SYS_RAW_TO_XSID'; +SYS_RID_ORDER : 'SYS_RID_ORDER'; +SYS_ROW_DELTA : 'SYS_ROW_DELTA'; +SYS_SC_2_XMLT : 'SYS_SC_2_XMLT'; +SYS_SYNRCIREDO : 'SYS_SYNRCIREDO'; +SYSTEM_DEFINED : 'SYSTEM_DEFINED'; +SYSTEM : 'SYSTEM'; +SYSTIMESTAMP : 'SYSTIMESTAMP'; +SYS_TYPEID : 'SYS_TYPEID'; +SYS_UMAKEXML : 'SYS_UMAKEXML'; +SYS_XMLANALYZE : 'SYS_XMLANALYZE'; +SYS_XMLCONTAINS : 'SYS_XMLCONTAINS'; +SYS_XMLCONV : 'SYS_XMLCONV'; +SYS_XMLEXNSURI : 'SYS_XMLEXNSURI'; +SYS_XMLGEN : 'SYS_XMLGEN'; +SYS_XMLI_LOC_ISNODE : 'SYS_XMLI_LOC_ISNODE'; +SYS_XMLI_LOC_ISTEXT : 'SYS_XMLI_LOC_ISTEXT'; +SYS_XMLINSTR : 'SYS_XMLINSTR'; +SYS_XMLLOCATOR_GETSVAL : 'SYS_XMLLOCATOR_GETSVAL'; +SYS_XMLNODEID_GETCID : 'SYS_XMLNODEID_GETCID'; +SYS_XMLNODEID_GETLOCATOR : 'SYS_XMLNODEID_GETLOCATOR'; +SYS_XMLNODEID_GETOKEY : 'SYS_XMLNODEID_GETOKEY'; +SYS_XMLNODEID_GETPATHID : 'SYS_XMLNODEID_GETPATHID'; +SYS_XMLNODEID_GETPTRID : 'SYS_XMLNODEID_GETPTRID'; +SYS_XMLNODEID_GETRID : 'SYS_XMLNODEID_GETRID'; +SYS_XMLNODEID_GETSVAL : 'SYS_XMLNODEID_GETSVAL'; +SYS_XMLNODEID_GETTID : 'SYS_XMLNODEID_GETTID'; +SYS_XMLNODEID : 'SYS_XMLNODEID'; +SYS_XMLT_2_SC : 'SYS_XMLT_2_SC'; +SYS_XMLTRANSLATE : 'SYS_XMLTRANSLATE'; +SYS_XMLTYPE2SQL : 'SYS_XMLTYPE2SQL'; +SYS_XQ_ASQLCNV : 'SYS_XQ_ASQLCNV'; +SYS_XQ_ATOMCNVCHK : 'SYS_XQ_ATOMCNVCHK'; +SYS_XQBASEURI : 'SYS_XQBASEURI'; +SYS_XQCASTABLEERRH : 'SYS_XQCASTABLEERRH'; +SYS_XQCODEP2STR : 'SYS_XQCODEP2STR'; +SYS_XQCODEPEQ : 'SYS_XQCODEPEQ'; +SYS_XQCON2SEQ : 'SYS_XQCON2SEQ'; +SYS_XQCONCAT : 'SYS_XQCONCAT'; +SYS_XQDELETE : 'SYS_XQDELETE'; +SYS_XQDFLTCOLATION : 'SYS_XQDFLTCOLATION'; +SYS_XQDOC : 'SYS_XQDOC'; +SYS_XQDOCURI : 'SYS_XQDOCURI'; +SYS_XQDURDIV : 'SYS_XQDURDIV'; +SYS_XQED4URI : 'SYS_XQED4URI'; +SYS_XQENDSWITH : 'SYS_XQENDSWITH'; +SYS_XQERRH : 'SYS_XQERRH'; +SYS_XQERR : 'SYS_XQERR'; +SYS_XQESHTMLURI : 'SYS_XQESHTMLURI'; +SYS_XQEXLOBVAL : 'SYS_XQEXLOBVAL'; +SYS_XQEXSTWRP : 'SYS_XQEXSTWRP'; +SYS_XQEXTRACT : 'SYS_XQEXTRACT'; +SYS_XQEXTRREF : 'SYS_XQEXTRREF'; +SYS_XQEXVAL : 'SYS_XQEXVAL'; +SYS_XQFB2STR : 'SYS_XQFB2STR'; +SYS_XQFNBOOL : 'SYS_XQFNBOOL'; +SYS_XQFNCMP : 'SYS_XQFNCMP'; +SYS_XQFNDATIM : 'SYS_XQFNDATIM'; +SYS_XQFNLNAME : 'SYS_XQFNLNAME'; +SYS_XQFNNM : 'SYS_XQFNNM'; +SYS_XQFNNSURI : 'SYS_XQFNNSURI'; +SYS_XQFNPREDTRUTH : 'SYS_XQFNPREDTRUTH'; +SYS_XQFNQNM : 'SYS_XQFNQNM'; +SYS_XQFNROOT : 'SYS_XQFNROOT'; +SYS_XQFORMATNUM : 'SYS_XQFORMATNUM'; +SYS_XQFTCONTAIN : 'SYS_XQFTCONTAIN'; +SYS_XQFUNCR : 'SYS_XQFUNCR'; +SYS_XQGETCONTENT : 'SYS_XQGETCONTENT'; +SYS_XQINDXOF : 'SYS_XQINDXOF'; +SYS_XQINSERT : 'SYS_XQINSERT'; +SYS_XQINSPFX : 'SYS_XQINSPFX'; +SYS_XQIRI2URI : 'SYS_XQIRI2URI'; +SYS_XQLANG : 'SYS_XQLANG'; +SYS_XQLLNMFRMQNM : 'SYS_XQLLNMFRMQNM'; +SYS_XQMKNODEREF : 'SYS_XQMKNODEREF'; +SYS_XQNILLED : 'SYS_XQNILLED'; +SYS_XQNODENAME : 'SYS_XQNODENAME'; +SYS_XQNORMSPACE : 'SYS_XQNORMSPACE'; +SYS_XQNORMUCODE : 'SYS_XQNORMUCODE'; +SYS_XQ_NRNG : 'SYS_XQ_NRNG'; +SYS_XQNSP4PFX : 'SYS_XQNSP4PFX'; +SYS_XQNSPFRMQNM : 'SYS_XQNSPFRMQNM'; +SYS_XQPFXFRMQNM : 'SYS_XQPFXFRMQNM'; +SYS_XQ_PKSQL2XML : 'SYS_XQ_PKSQL2XML'; +SYS_XQPOLYABS : 'SYS_XQPOLYABS'; +SYS_XQPOLYADD : 'SYS_XQPOLYADD'; +SYS_XQPOLYCEL : 'SYS_XQPOLYCEL'; +SYS_XQPOLYCSTBL : 'SYS_XQPOLYCSTBL'; +SYS_XQPOLYCST : 'SYS_XQPOLYCST'; +SYS_XQPOLYDIV : 'SYS_XQPOLYDIV'; +SYS_XQPOLYFLR : 'SYS_XQPOLYFLR'; +SYS_XQPOLYMOD : 'SYS_XQPOLYMOD'; +SYS_XQPOLYMUL : 'SYS_XQPOLYMUL'; +SYS_XQPOLYRND : 'SYS_XQPOLYRND'; +SYS_XQPOLYSQRT : 'SYS_XQPOLYSQRT'; +SYS_XQPOLYSUB : 'SYS_XQPOLYSUB'; +SYS_XQPOLYUMUS : 'SYS_XQPOLYUMUS'; +SYS_XQPOLYUPLS : 'SYS_XQPOLYUPLS'; +SYS_XQPOLYVEQ : 'SYS_XQPOLYVEQ'; +SYS_XQPOLYVGE : 'SYS_XQPOLYVGE'; +SYS_XQPOLYVGT : 'SYS_XQPOLYVGT'; +SYS_XQPOLYVLE : 'SYS_XQPOLYVLE'; +SYS_XQPOLYVLT : 'SYS_XQPOLYVLT'; +SYS_XQPOLYVNE : 'SYS_XQPOLYVNE'; +SYS_XQREF2VAL : 'SYS_XQREF2VAL'; +SYS_XQRENAME : 'SYS_XQRENAME'; +SYS_XQREPLACE : 'SYS_XQREPLACE'; +SYS_XQRESVURI : 'SYS_XQRESVURI'; +SYS_XQRNDHALF2EVN : 'SYS_XQRNDHALF2EVN'; +SYS_XQRSLVQNM : 'SYS_XQRSLVQNM'; +SYS_XQRYENVPGET : 'SYS_XQRYENVPGET'; +SYS_XQRYVARGET : 'SYS_XQRYVARGET'; +SYS_XQRYWRP : 'SYS_XQRYWRP'; +SYS_XQSEQ2CON4XC : 'SYS_XQSEQ2CON4XC'; +SYS_XQSEQ2CON : 'SYS_XQSEQ2CON'; +SYS_XQSEQDEEPEQ : 'SYS_XQSEQDEEPEQ'; +SYS_XQSEQINSB : 'SYS_XQSEQINSB'; +SYS_XQSEQRM : 'SYS_XQSEQRM'; +SYS_XQSEQRVS : 'SYS_XQSEQRVS'; +SYS_XQSEQSUB : 'SYS_XQSEQSUB'; +SYS_XQSEQTYPMATCH : 'SYS_XQSEQTYPMATCH'; +SYS_XQSTARTSWITH : 'SYS_XQSTARTSWITH'; +SYS_XQSTATBURI : 'SYS_XQSTATBURI'; +SYS_XQSTR2CODEP : 'SYS_XQSTR2CODEP'; +SYS_XQSTRJOIN : 'SYS_XQSTRJOIN'; +SYS_XQSUBSTRAFT : 'SYS_XQSUBSTRAFT'; +SYS_XQSUBSTRBEF : 'SYS_XQSUBSTRBEF'; +SYS_XQTOKENIZE : 'SYS_XQTOKENIZE'; +SYS_XQTREATAS : 'SYS_XQTREATAS'; +SYS_XQ_UPKXML2SQL : 'SYS_XQ_UPKXML2SQL'; +SYS_XQXFORM : 'SYS_XQXFORM'; +SYS_XSID_TO_RAW : 'SYS_XSID_TO_RAW'; +SYS_ZMAP_FILTER : 'SYS_ZMAP_FILTER'; +SYS_ZMAP_REFRESH : 'SYS_ZMAP_REFRESH'; +T_LETTER : 'T'; +TABLE_LOOKUP_BY_NL : 'TABLE_LOOKUP_BY_NL'; +TABLESPACE_NO : 'TABLESPACE_NO'; +TABLESPACE : 'TABLESPACE'; +TABLES : 'TABLES'; +TABLE_STATS : 'TABLE_STATS'; +TABLE : 'TABLE'; +TABNO : 'TABNO'; +TAG : 'TAG'; +TANH : 'TANH'; +TAN : 'TAN'; +TBLORIDXPARTNUM : 'TBL$OR$IDX$PART$NUM'; +TEMPFILE : 'TEMPFILE'; +TEMPLATE : 'TEMPLATE'; +TEMPORARY : 'TEMPORARY'; +TEMP_TABLE : 'TEMP_TABLE'; +TEST : 'TEST'; +TEXT : 'TEXT'; +THAN : 'THAN'; +THEN : 'THEN'; +THE : 'THE'; +THREAD : 'THREAD'; +THROUGH : 'THROUGH'; +TIER : 'TIER'; +TIES : 'TIES'; +TIMEOUT : 'TIMEOUT'; +TIMESTAMP_LTZ_UNCONSTRAINED : 'TIMESTAMP_LTZ_UNCONSTRAINED'; +TIMESTAMP : 'TIMESTAMP'; +TIMESTAMP_TZ_UNCONSTRAINED : 'TIMESTAMP_TZ_UNCONSTRAINED'; +TIMESTAMP_UNCONSTRAINED : 'TIMESTAMP_UNCONSTRAINED'; +TIMES : 'TIMES'; +TIME : 'TIME'; +TIMEZONE : 'TIMEZONE'; +TIMEZONE_ABBR : 'TIMEZONE_ABBR'; +TIMEZONE_HOUR : 'TIMEZONE_HOUR'; +TIMEZONE_MINUTE : 'TIMEZONE_MINUTE'; +TIMEZONE_OFFSET : 'TIMEZONE_OFFSET'; +TIMEZONE_REGION : 'TIMEZONE_REGION'; +TIME_ZONE : 'TIME_ZONE'; +TIMING : 'TIMING'; +TIV_GB : 'TIV_GB'; +TIV_SSF : 'TIV_SSF'; +TO_ACLID : 'TO_ACLID'; +TO_BINARY_DOUBLE : 'TO_BINARY_DOUBLE'; +TO_BINARY_FLOAT : 'TO_BINARY_FLOAT'; +TO_BLOB : 'TO_BLOB'; +TO_CLOB : 'TO_CLOB'; +TO_DSINTERVAL : 'TO_DSINTERVAL'; +TO_LOB : 'TO_LOB'; +TO_MULTI_BYTE : 'TO_MULTI_BYTE'; +TO_NCHAR : 'TO_NCHAR'; +TO_NCLOB : 'TO_NCLOB'; +TO_NUMBER : 'TO_NUMBER'; +TOPLEVEL : 'TOPLEVEL'; +TO_SINGLE_BYTE : 'TO_SINGLE_BYTE'; +TO_TIMESTAMP : 'TO_TIMESTAMP'; +TO_TIMESTAMP_TZ : 'TO_TIMESTAMP_TZ'; +TO_TIME : 'TO_TIME'; +TO_TIME_TZ : 'TO_TIME_TZ'; +TO : 'TO'; +TO_YMINTERVAL : 'TO_YMINTERVAL'; +TRACE : 'TRACE'; +TRACING : 'TRACING'; +TRACKING : 'TRACKING'; +TRAILING : 'TRAILING'; +TRANSACTION : 'TRANSACTION'; +TRANSFORM : 'TRANSFORM'; +TRANSFORM_DISTINCT_AGG : 'TRANSFORM_DISTINCT_AGG'; +TRANSITIONAL : 'TRANSITIONAL'; +TRANSITION : 'TRANSITION'; +TRANSLATE : 'TRANSLATE'; +TRANSLATION : 'TRANSLATION'; +TREAT : 'TREAT'; +TRIGGERS : 'TRIGGERS'; +TRIGGER : 'TRIGGER'; +TRUE : 'TRUE'; +TRUNCATE : 'TRUNCATE'; +TRUNC : 'TRUNC'; +TRUSTED : 'TRUSTED'; +TRUST : 'TRUST'; +TUNING : 'TUNING'; +TX : 'TX'; +TYPES : 'TYPES'; +TYPE : 'TYPE'; +TZ_OFFSET : 'TZ_OFFSET'; +UB2 : 'UB2'; +UBA : 'UBA'; +UCS2 : 'UCS2'; +UID : 'UID'; +UNARCHIVED : 'UNARCHIVED'; +UNBOUNDED : 'UNBOUNDED'; +UNBOUND : 'UNBOUND'; +UNCONDITIONAL : 'UNCONDITIONAL'; +UNDER : 'UNDER'; +UNDO : 'UNDO'; +UNDROP : 'UNDROP'; +UNIFORM : 'UNIFORM'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; +UNISTR : 'UNISTR'; +UNLIMITED : 'UNLIMITED'; +UNLOAD : 'UNLOAD'; +UNLOCK : 'UNLOCK'; +UNMATCHED : 'UNMATCHED'; +UNNEST_INNERJ_DISTINCT_VIEW : 'UNNEST_INNERJ_DISTINCT_VIEW'; +UNNEST_NOSEMIJ_NODISTINCTVIEW : 'UNNEST_NOSEMIJ_NODISTINCTVIEW'; +UNNEST_SEMIJ_VIEW : 'UNNEST_SEMIJ_VIEW'; +UNNEST : 'UNNEST'; +UNPACKED : 'UNPACKED'; +UNPIVOT : 'UNPIVOT'; +UNPLUG : 'UNPLUG'; +UNPROTECTED : 'UNPROTECTED'; +UNQUIESCE : 'UNQUIESCE'; +UNRECOVERABLE : 'UNRECOVERABLE'; +UNRESTRICTED : 'UNRESTRICTED'; +UNSUBSCRIBE : 'UNSUBSCRIBE'; +UNTIL : 'UNTIL'; +UNUSABLE : 'UNUSABLE'; +UNUSED : 'UNUSED'; +UPDATABLE : 'UPDATABLE'; +UPDATED : 'UPDATED'; +UPDATE : 'UPDATE'; +UPDATEXML : 'UPDATEXML'; +UPD_INDEXES : 'UPD_INDEXES'; +UPD_JOININDEX : 'UPD_JOININDEX'; +UPGRADE : 'UPGRADE'; +UPPER : 'UPPER'; +UPSERT : 'UPSERT'; +UROWID : 'UROWID'; +USABLE : 'USABLE'; +USAGE : 'USAGE'; +USE_ANTI : 'USE_ANTI'; +USE_CONCAT : 'USE_CONCAT'; +USE_CUBE : 'USE_CUBE'; +USE_HASH_AGGREGATION : 'USE_HASH_AGGREGATION'; +USE_HASH_GBY_FOR_PUSHDOWN : 'USE_HASH_GBY_FOR_PUSHDOWN'; +USE_HASH : 'USE_HASH'; +USE_HIDDEN_PARTITIONS : 'USE_HIDDEN_PARTITIONS'; +USE_INVISIBLE_INDEXES : 'USE_INVISIBLE_INDEXES'; +USE_MERGE_CARTESIAN : 'USE_MERGE_CARTESIAN'; +USE_MERGE : 'USE_MERGE'; +USE_NL : 'USE_NL'; +USE_NL_WITH_INDEX : 'USE_NL_WITH_INDEX'; +USE_PRIVATE_OUTLINES : 'USE_PRIVATE_OUTLINES'; +USER_DATA : 'USER_DATA'; +USER_DEFINED : 'USER_DEFINED'; +USERENV : 'USERENV'; +USERGROUP : 'USERGROUP'; +USER_RECYCLEBIN : 'USER_RECYCLEBIN'; +USERS : 'USERS'; +USER_TABLESPACES : 'USER_TABLESPACES'; +USER : 'USER'; +USE_SEMI : 'USE_SEMI'; +USE_STORED_OUTLINES : 'USE_STORED_OUTLINES'; +USE_TTT_FOR_GSETS : 'USE_TTT_FOR_GSETS'; +USE : 'USE'; +USE_VECTOR_AGGREGATION : 'USE_VECTOR_AGGREGATION'; +USE_WEAK_NAME_RESL : 'USE_WEAK_NAME_RESL'; +USING_NO_EXPAND : 'USING_NO_EXPAND'; +USING : 'USING'; +UTF16BE : 'UTF16BE'; +UTF16LE : 'UTF16LE'; +UTF32 : 'UTF32'; +UTF8 : 'UTF8'; +V1 : 'V1'; +V2 : 'V2'; +VALIDATE : 'VALIDATE'; +VALIDATE_CONVERSION : 'VALIDATE_CONVERSION'; +VALIDATION : 'VALIDATION'; +VALID_TIME_END : 'VALID_TIME_END'; +VALUES : 'VALUES'; +VALUE : 'VALUE'; +VARCHAR2 : 'VARCHAR2'; +VARCHAR : 'VARCHAR'; +VARIABLE : 'VARIABLE'; +VAR_POP : 'VAR_POP'; +VARRAYS : 'VARRAYS'; +VARRAY : 'VARRAY'; +VAR_SAMP : 'VAR_SAMP'; +VARYING : 'VARYING'; +VECTOR_READ_TRACE : 'VECTOR_READ_TRACE'; +VECTOR_READ : 'VECTOR_READ'; +VECTOR_TRANSFORM_DIMS : 'VECTOR_TRANSFORM_DIMS'; +VECTOR_TRANSFORM_FACT : 'VECTOR_TRANSFORM_FACT'; +VECTOR_TRANSFORM : 'VECTOR_TRANSFORM'; +VERIFIER : 'VERIFIER'; +VERIFY : 'VERIFY'; +VERSIONING : 'VERSIONING'; +VERSIONS_ENDSCN : 'VERSIONS_ENDSCN'; +VERSIONS_ENDTIME : 'VERSIONS_ENDTIME'; +VERSIONS_OPERATION : 'VERSIONS_OPERATION'; +VERSIONS_STARTSCN : 'VERSIONS_STARTSCN'; +VERSIONS_STARTTIME : 'VERSIONS_STARTTIME'; +VERSIONS : 'VERSIONS'; +VERSIONS_XID : 'VERSIONS_XID'; +VERSION : 'VERSION'; +VIEW : 'VIEW'; +VIOLATION : 'VIOLATION'; +VIRTUAL : 'VIRTUAL'; +VISIBILITY : 'VISIBILITY'; +VISIBLE : 'VISIBLE'; +VOLUME : 'VOLUME'; +VSIZE : 'VSIZE'; +WAIT : 'WAIT'; +WALLET : 'WALLET'; +WARNING : 'WARNING'; +WEEKS : 'WEEKS'; +WEEK : 'WEEK'; +WELLFORMED : 'WELLFORMED'; +WHENEVER : 'WHENEVER'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WHILE : 'WHILE'; +WHITESPACE : 'WHITESPACE'; +WIDTH_BUCKET : 'WIDTH_BUCKET'; +WITHIN : 'WITHIN'; +WITHOUT : 'WITHOUT'; +WITH_PLSQL : 'WITH_PLSQL'; +WITH : 'WITH'; +WORK : 'WORK'; +WRAPPED : 'WRAPPED'; +WRAPPER : 'WRAPPER'; +WRITE : 'WRITE'; +XDB_FASTPATH_INSERT : 'XDB_FASTPATH_INSERT'; +XDB : 'XDB'; +X_DYN_PRUNE : 'X_DYN_PRUNE'; +XID : 'XID'; +XML2OBJECT : 'XML2OBJECT'; +XMLAGG : 'XMLAGG'; +XMLATTRIBUTES : 'XMLATTRIBUTES'; +XMLCAST : 'XMLCAST'; +XMLCDATA : 'XMLCDATA'; +XMLCOLATTVAL : 'XMLCOLATTVAL'; +XMLCOMMENT : 'XMLCOMMENT'; +XMLCONCAT : 'XMLCONCAT'; +XMLDIFF : 'XMLDIFF'; +XML_DML_RWT_STMT : 'XML_DML_RWT_STMT'; +XMLELEMENT : 'XMLELEMENT'; +XMLEXISTS2 : 'XMLEXISTS2'; +XMLEXISTS : 'XMLEXISTS'; +XMLFOREST : 'XMLFOREST'; +XMLINDEX : 'XMLINDEX'; +XMLINDEX_REWRITE_IN_SELECT : 'XMLINDEX_REWRITE_IN_SELECT'; +XMLINDEX_REWRITE : 'XMLINDEX_REWRITE'; +XMLINDEX_SEL_IDX_TBL : 'XMLINDEX_SEL_IDX_TBL'; +XMLISNODE : 'XMLISNODE'; +XMLISVALID : 'XMLISVALID'; +XMLNAMESPACES : 'XMLNAMESPACES'; +XMLPARSE : 'XMLPARSE'; +XMLPATCH : 'XMLPATCH'; +XMLPI : 'XMLPI'; +XMLQUERYVAL : 'XMLQUERYVAL'; +XMLQUERY : 'XMLQUERY'; +XMLROOT : 'XMLROOT'; +XMLSCHEMA : 'XMLSCHEMA'; +XMLSERIALIZE : 'XMLSERIALIZE'; +XMLTABLE : 'XMLTABLE'; +XMLTRANSFORMBLOB : 'XMLTRANSFORMBLOB'; +XMLTRANSFORM : 'XMLTRANSFORM'; +XMLTYPE : 'XMLTYPE'; +XML : 'XML'; +XPATHTABLE : 'XPATHTABLE'; +XS_SYS_CONTEXT : 'XS_SYS_CONTEXT'; +XS : 'XS'; +XTRANSPORT : 'XTRANSPORT'; +YEARS : 'YEARS'; +YEAR : 'YEAR'; +YES : 'YES'; +YMINTERVAL_UNCONSTRAINED : 'YMINTERVAL_UNCONSTRAINED'; +ZONEMAP : 'ZONEMAP'; +ZONE : 'ZONE'; +PREDICTION : 'PREDICTION'; +PREDICTION_BOUNDS : 'PREDICTION_BOUNDS'; +PREDICTION_COST : 'PREDICTION_COST'; +PREDICTION_DETAILS : 'PREDICTION_DETAILS'; +PREDICTION_PROBABILITY : 'PREDICTION_PROBABILITY'; +PREDICTION_SET : 'PREDICTION_SET'; -BLOCKCHAIN: 'BLOCKCHAIN'; -COLLATE: 'COLLATE'; -COLLATION: 'COLLATION'; -DEFINITION: 'DEFINITION'; -DUPLICATED: 'DUPLICATED'; -EXTENDED: 'EXTENDED'; -HASHING: 'HASHING'; -IDLE: 'IDLE'; -IMMUTABLE: 'IMMUTABLE'; -ORACLE_DATAPUMP: 'ORACLE_DATAPUMP'; -ORACLE_HDFS: 'ORACLE_HDFS'; -ORACLE_HIVE: 'ORACLE_HIVE'; -ORACLE_LOADER: 'ORACLE_LOADER'; -SHA2_512_Q: '"SHA2_512"'; -SHARDED: 'SHARDED'; -V1_Q: '"V1"'; +BLOCKCHAIN : 'BLOCKCHAIN'; +COLLATE : 'COLLATE'; +COLLATION : 'COLLATION'; +DEFINITION : 'DEFINITION'; +DUPLICATED : 'DUPLICATED'; +EXTENDED : 'EXTENDED'; +HASHING : 'HASHING'; +IDLE : 'IDLE'; +IMMUTABLE : 'IMMUTABLE'; +ORACLE_DATAPUMP : 'ORACLE_DATAPUMP'; +ORACLE_HDFS : 'ORACLE_HDFS'; +ORACLE_HIVE : 'ORACLE_HIVE'; +ORACLE_LOADER : 'ORACLE_LOADER'; +SHA2_512_Q : '"SHA2_512"'; +SHARDED : 'SHARDED'; +V1_Q : '"V1"'; -ISOLATE: 'ISOLATE'; -ROOT: 'ROOT'; -UNITE: 'UNITE'; -ALGORITHM: 'ALGORITHM'; +ISOLATE : 'ISOLATE'; +ROOT : 'ROOT'; +UNITE : 'UNITE'; +ALGORITHM : 'ALGORITHM'; -CUME_DIST: 'CUME_DIST'; -DENSE_RANK: 'DENSE_RANK'; -LISTAGG: 'LISTAGG'; -PERCENT_RANK: 'PERCENT_RANK'; -PERCENTILE_CONT: 'PERCENTILE_CONT'; -PERCENTILE_DISC: 'PERCENTILE_DISC'; -RANK: 'RANK'; +CUME_DIST : 'CUME_DIST'; +DENSE_RANK : 'DENSE_RANK'; +LISTAGG : 'LISTAGG'; +PERCENT_RANK : 'PERCENT_RANK'; +PERCENTILE_CONT : 'PERCENTILE_CONT'; +PERCENTILE_DISC : 'PERCENTILE_DISC'; +RANK : 'RANK'; -AVG: 'AVG'; -CORR: 'CORR'; -COVAR_: 'COVAR_'; -DECODE: 'DECODE'; -LAG: 'LAG'; -LAG_DIFF: 'LAG_DIFF'; -LAG_DIFF_PERCENT: 'LAG_DIFF_PERCENT'; -LEAD: 'LEAD'; -MAX: 'MAX'; -MEDIAN: 'MEDIAN'; -MEMOPTIMIZE: 'MEMOPTIMIZE'; -MIN: 'MIN'; -NTILE: 'NTILE'; -NVL: 'NVL'; -RATIO_TO_REPORT: 'RATIO_TO_REPORT'; -REGR_: 'REGR_'; -ROUND: 'ROUND'; -ROW_NUMBER: 'ROW_NUMBER'; -SUBSTR: 'SUBSTR'; -TO_CHAR: 'TO_CHAR'; -TRIM: 'TRIM'; -SUM: 'SUM'; -STDDEV: 'STDDEV'; -VAR_: 'VAR_'; -VARIANCE: 'VARIANCE'; -LEAST: 'LEAST'; -GREATEST: 'GREATEST'; -TO_DATE: 'TO_DATE'; +AVG : 'AVG'; +CORR : 'CORR'; +COVAR_ : 'COVAR_'; +DECODE : 'DECODE'; +LAG : 'LAG'; +LAG_DIFF : 'LAG_DIFF'; +LAG_DIFF_PERCENT : 'LAG_DIFF_PERCENT'; +LEAD : 'LEAD'; +MAX : 'MAX'; +MEDIAN : 'MEDIAN'; +MEMOPTIMIZE : 'MEMOPTIMIZE'; +MIN : 'MIN'; +NTILE : 'NTILE'; +NVL : 'NVL'; +RATIO_TO_REPORT : 'RATIO_TO_REPORT'; +REGR_ : 'REGR_'; +ROUND : 'ROUND'; +ROW_NUMBER : 'ROW_NUMBER'; +SUBSTR : 'SUBSTR'; +TO_CHAR : 'TO_CHAR'; +TRIM : 'TRIM'; +SUM : 'SUM'; +STDDEV : 'STDDEV'; +VAR_ : 'VAR_'; +VARIANCE : 'VARIANCE'; +LEAST : 'LEAST'; +GREATEST : 'GREATEST'; +TO_DATE : 'TO_DATE'; // Rule #358 - subtoken typecast in , it also incorporates // Lowercase 'n' is a usual addition to the standard -NATIONAL_CHAR_STRING_LIT: 'N' '\'' (~('\'' | '\r' | '\n' ) | '\'' '\'' | NEWLINE)* '\''; +NATIONAL_CHAR_STRING_LIT: 'N' '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; // Rule #040 - subtoken typecast in // Lowercase 'b' is a usual addition to the standard @@ -2358,9 +2362,9 @@ BIT_STRING_LIT: 'B' ('\'' [01]* '\'')+; // Rule #284 - subtoken typecast in // Lowercase 'x' is a usual addition to the standard -HEX_STRING_LIT: 'X' ('\'' [A-F0-9]* '\'')+; -DOUBLE_PERIOD: '..'; -PERIOD: '.'; +HEX_STRING_LIT : 'X' ('\'' [A-F0-9]* '\'')+; +DOUBLE_PERIOD : '..'; +PERIOD : '.'; //{ Rule #238 // This rule is a bit tricky - it resolves the ambiguity with @@ -2378,89 +2382,96 @@ PERIOD: '.'; (D | F)? ;*/ -UNSIGNED_INTEGER: [0-9]+; -APPROXIMATE_NUM_LIT: FLOAT_FRAGMENT ('E' ('+'|'-')? (FLOAT_FRAGMENT | [0-9]+))? ('D' | 'F')?; - +UNSIGNED_INTEGER : [0-9]+; +APPROXIMATE_NUM_LIT : FLOAT_FRAGMENT ('E' ('+' | '-')? (FLOAT_FRAGMENT | [0-9]+))? ('D' | 'F')?; // Rule #--- is a base for Rule #065 , it incorporates // and a superfluous subtoken typecasting of the "QUOTE" -CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; +CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; // See https://livesql.oracle.com/apex/livesql/file/content_CIREYU9EA54EOKQ7LAMZKRF6P.html // TODO: context sensitive string quotes (any characted after quote) -CHAR_STRING_PERL : 'Q' '\'' (QS_ANGLE | QS_BRACE | QS_BRACK | QS_PAREN | QS_EXCLAM | QS_SHARP | QS_QUOTE | QS_DQUOTE) '\'' -> type(CHAR_STRING); -fragment QS_ANGLE : '<' .*? '>'; -fragment QS_BRACE : '{' .*? '}'; -fragment QS_BRACK : '[' .*? ']'; -fragment QS_PAREN : '(' .*? ')'; -fragment QS_EXCLAM : '!' .*? '!'; -fragment QS_SHARP : '#' .*? '#'; -fragment QS_QUOTE : '\'' .*? '\''; -fragment QS_DQUOTE : '"' .*? '"'; +CHAR_STRING_PERL: + 'Q' '\'' ( + QS_ANGLE + | QS_BRACE + | QS_BRACK + | QS_PAREN + | QS_EXCLAM + | QS_SHARP + | QS_QUOTE + | QS_DQUOTE + ) '\'' -> type(CHAR_STRING) +; +fragment QS_ANGLE : '<' .*? '>'; +fragment QS_BRACE : '{' .*? '}'; +fragment QS_BRACK : '[' .*? ']'; +fragment QS_PAREN : '(' .*? ')'; +fragment QS_EXCLAM : '!' .*? '!'; +fragment QS_SHARP : '#' .*? '#'; +fragment QS_QUOTE : '\'' .*? '\''; +fragment QS_DQUOTE : '"' .*? '"'; -DELIMITED_ID: '"' (~('"' | '\r' | '\n') | '"' '"')+ '"' ; +DELIMITED_ID: '"' (~('"' | '\r' | '\n') | '"' '"')+ '"'; -PERCENT: '%'; -AMPERSAND: '&'; -LEFT_PAREN: '('; -RIGHT_PAREN: ')'; -DOUBLE_ASTERISK: '**'; -ASTERISK: '*'; -PLUS_SIGN: '+'; -MINUS_SIGN: '-'; -COMMA: ','; -SOLIDUS: '/'; -AT_SIGN: '@'; -ASSIGN_OP: ':='; -HASH_OP: '#'; +PERCENT : '%'; +AMPERSAND : '&'; +LEFT_PAREN : '('; +RIGHT_PAREN : ')'; +DOUBLE_ASTERISK : '**'; +ASTERISK : '*'; +PLUS_SIGN : '+'; +MINUS_SIGN : '-'; +COMMA : ','; +SOLIDUS : '/'; +AT_SIGN : '@'; +ASSIGN_OP : ':='; +HASH_OP : '#'; -SQ: '\''; +SQ: '\''; -BINDVAR - : ':' SIMPLE_LETTER (SIMPLE_LETTER | [0-9] | '_')* - | ':' DELIMITED_ID // not used in SQL but spotted in v$sqltext when using cursor_sharing +BINDVAR: + ':' SIMPLE_LETTER (SIMPLE_LETTER | [0-9] | '_')* + | ':' DELIMITED_ID // not used in SQL but spotted in v$sqltext when using cursor_sharing | ':' UNSIGNED_INTEGER | QUESTION_MARK // not in SQL, not in Oracle, not in OCI, use this for JDBC - ; +; -NOT_EQUAL_OP: '!=' - | '<>' - | '^=' - | '~=' - ; -CARRET_OPERATOR_PART: '^'; -TILDE_OPERATOR_PART: '~'; -EXCLAMATION_OPERATOR_PART: '!'; -GREATER_THAN_OP: '>'; -LESS_THAN_OP: '<'; -COLON: ':'; -SEMICOLON: ';'; +NOT_EQUAL_OP : '!=' | '<>' | '^=' | '~='; +CARRET_OPERATOR_PART : '^'; +TILDE_OPERATOR_PART : '~'; +EXCLAMATION_OPERATOR_PART : '!'; +GREATER_THAN_OP : '>'; +LESS_THAN_OP : '<'; +COLON : ':'; +SEMICOLON : ';'; -BAR: '|'; -EQUALS_OP: '='; +BAR : '|'; +EQUALS_OP : '='; -LEFT_BRACKET: '['; -RIGHT_BRACKET: ']'; +LEFT_BRACKET : '['; +RIGHT_BRACKET : ']'; INTRODUCER: '_'; // Comments https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm -SINGLE_LINE_COMMENT: '--' ~('\r' | '\n')* NEWLINE_EOF -> channel(HIDDEN); -MULTI_LINE_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); +SINGLE_LINE_COMMENT : '--' ~('\r' | '\n')* NEWLINE_EOF -> channel(HIDDEN); +MULTI_LINE_COMMENT : '/*' .*? '*/' -> channel(HIDDEN); // https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve034.htm#SQPUG054 -REMARK_COMMENT: 'REM' {this.IsNewlineAtPos(-4)}? 'ARK'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF -> channel(HIDDEN); +REMARK_COMMENT: + 'REM' {this.IsNewlineAtPos(-4)}? 'ARK'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF -> channel(HIDDEN) +; // https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve032.htm#SQPUG052 -PROMPT_MESSAGE: 'PRO' {this.IsNewlineAtPos(-4)}? 'MPT'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF; +PROMPT_MESSAGE: 'PRO' {this.IsNewlineAtPos(-4)}? 'MPT'? (' ' ~('\r' | '\n')*)? NEWLINE_EOF; // TODO: should starts with newline START_CMD - //: 'STA' 'RT'? SPACE ~('\r' | '\n')* NEWLINE_EOF - // https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12002.htm - // https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12003.htm - : '@''@'? - ; +//: 'STA' 'RT'? SPACE ~('\r' | '\n')* NEWLINE_EOF +: // https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12002.htm + '@' '@'? +; // https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12003.htm REGULAR_ID: SIMPLE_LETTER (SIMPLE_LETTER | '$' | '_' | '#' | [0-9])*; @@ -2473,4 +2484,4 @@ fragment QUESTION_MARK : '?'; fragment SIMPLE_LETTER : [A-Z]; fragment FLOAT_FRAGMENT : UNSIGNED_INTEGER* '.'? UNSIGNED_INTEGER+; fragment NEWLINE : '\r'? '\n'; -fragment SPACE : [ \t]; +fragment SPACE : [ \t]; \ No newline at end of file diff --git a/sql/plsql/PlSqlParser.g4 b/sql/plsql/PlSqlParser.g4 index 53f61b5bcb..569c9aca18 100644 --- a/sql/plsql/PlSqlParser.g4 +++ b/sql/plsql/PlSqlParser.g4 @@ -1,4 +1,4 @@ - /** +/** * Oracle(c) PL/SQL 11g Parser * * Copyright (c) 2009-2011 Alexandre Porcelli @@ -18,11 +18,14 @@ * limitations under the License. */ +// $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 PlSqlParser; options { - tokenVocab=PlSqlLexer; - superClass=PlSqlParserBase; + tokenVocab = PlSqlLexer; + superClass = PlSqlParserBase; } @parser::postinclude { @@ -30,7 +33,9 @@ options { } sql_script - : sql_plus_command_no_semicolon? ((sql_plus_command | unit_statement) (SEMICOLON '/'? (sql_plus_command | unit_statement))* SEMICOLON? '/'?) EOF + : sql_plus_command_no_semicolon? ( + (sql_plus_command | unit_statement) (SEMICOLON '/'? (sql_plus_command | unit_statement))* SEMICOLON? '/'? + ) EOF ; unit_statement @@ -71,7 +76,6 @@ unit_statement | alter_type | alter_user | alter_view - | call_statement | create_analytic_view | create_attribute_dimension @@ -116,7 +120,6 @@ unit_statement | create_type | create_user | create_view - | drop_analytic_view | drop_attribute_dimension | drop_audit_policy @@ -155,7 +158,6 @@ unit_statement | drop_type | drop_user | drop_view - | administer_key_management | analyze | anonymous_block @@ -180,41 +182,55 @@ unit_statement // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-DISKGROUP.html alter_diskgroup - : ALTER DISKGROUP ( id_expression (((add_disk_clause | drop_disk_clause)+ | resize_disk_clause) rebalance_diskgroup_clause? - | ( replace_disk_clause - | rename_disk_clause - | disk_online_clause - | disk_offline_clause - | rebalance_diskgroup_clause - | check_diskgroup_clause - | diskgroup_template_clauses - | diskgroup_directory_clauses - | diskgroup_alias_clauses - | diskgroup_volume_clauses - | diskgroup_attributes - | drop_diskgroup_file_clause - | convert_redundancy_clause - | usergroup_clauses - | user_clauses - | file_permissions_clause - | file_owner_clause - | scrub_clause - | quotagroup_clauses - | filegroup_clauses - ) - ) - | (id_expression (',' id_expression)* | ALL) (undrop_disk_clause | diskgroup_availability | enable_disable_volume) - ) + : ALTER DISKGROUP ( + id_expression ( + ((add_disk_clause | drop_disk_clause)+ | resize_disk_clause) rebalance_diskgroup_clause? + | ( + replace_disk_clause + | rename_disk_clause + | disk_online_clause + | disk_offline_clause + | rebalance_diskgroup_clause + | check_diskgroup_clause + | diskgroup_template_clauses + | diskgroup_directory_clauses + | diskgroup_alias_clauses + | diskgroup_volume_clauses + | diskgroup_attributes + | drop_diskgroup_file_clause + | convert_redundancy_clause + | usergroup_clauses + | user_clauses + | file_permissions_clause + | file_owner_clause + | scrub_clause + | quotagroup_clauses + | filegroup_clauses + ) + ) + | (id_expression (',' id_expression)* | ALL) ( + undrop_disk_clause + | diskgroup_availability + | enable_disable_volume + ) + ) ; add_disk_clause - : ADD ( (SITE sn=id_expression)? quorum_regular? (FAILGROUP fgn=id_expression)? DISK qualified_disk_clause (',' qualified_disk_clause)*)+ + : ADD ( + (SITE sn = id_expression)? quorum_regular? (FAILGROUP fgn = id_expression)? DISK qualified_disk_clause ( + ',' qualified_disk_clause + )* + )+ ; drop_disk_clause - : DROP ( quorum_regular? DISK id_expression force_noforce? (',' id_expression force_noforce?)* - | DISKS IN quorum_regular? FAILGROUP id_expression force_noforce? (',' id_expression force_noforce?)* - ) + : DROP ( + quorum_regular? DISK id_expression force_noforce? (',' id_expression force_noforce?)* + | DISKS IN quorum_regular? FAILGROUP id_expression force_noforce? ( + ',' id_expression force_noforce? + )* + ) ; resize_disk_clause @@ -222,9 +238,9 @@ resize_disk_clause ; replace_disk_clause - : REPLACE DISK id_expression WITH CHAR_STRING force_noforce? (',' id_expression WITH CHAR_STRING force_noforce?)* - (POWER numeric)? - wait_nowait? + : REPLACE DISK id_expression WITH CHAR_STRING force_noforce? ( + ',' id_expression WITH CHAR_STRING force_noforce? + )* (POWER numeric)? wait_nowait? ; wait_nowait @@ -233,23 +249,27 @@ wait_nowait ; rename_disk_clause - : RENAME ( DISK id_expression TO id_expression (',' id_expression TO id_expression)* - | DISKS ALL - ) + : RENAME ( + DISK id_expression TO id_expression (',' id_expression TO id_expression)* + | DISKS ALL + ) ; disk_online_clause - : ONLINE ( (quorum_regular? DISK id_expression (',' id_expression)* | DISKS IN quorum_regular? FAILGROUP id_expression (',' id_expression)*)+ - | ALL - ) - (POWER numeric)? - wait_nowait? + : ONLINE ( + ( + quorum_regular? DISK id_expression (',' id_expression)* + | DISKS IN quorum_regular? FAILGROUP id_expression (',' id_expression)* + )+ + | ALL + ) (POWER numeric)? wait_nowait? ; disk_offline_clause - : OFFLINE ( quorum_regular? DISK id_expression (',' id_expression)* - | DISKS IN quorum_regular? FAILGROUP id_expression (',' id_expression)* - ) timeout_clause? + : OFFLINE ( + quorum_regular? DISK id_expression (',' id_expression)* + | DISKS IN quorum_regular? FAILGROUP id_expression (',' id_expression)* + ) timeout_clause? ; timeout_clause @@ -257,9 +277,10 @@ timeout_clause ; rebalance_diskgroup_clause - : REBALANCE ( ((WITH | WITHOUT) phase+)? (POWER numeric) (WAIT | NOWAIT)? - | MODIFY POWER numeric? - ) + : REBALANCE ( + ((WITH | WITHOUT) phase+)? (POWER numeric) (WAIT | NOWAIT)? + | MODIFY POWER numeric? + ) ; phase @@ -271,7 +292,9 @@ check_diskgroup_clause ; diskgroup_template_clauses - : (ADD | MODIFY) TEMPLATE id_expression qualified_template_clause (',' id_expression qualified_template_clause)* + : (ADD | MODIFY) TEMPLATE id_expression qualified_template_clause ( + ',' id_expression qualified_template_clause + )* | DROP TEMPLATE id_expression (',' id_expression)* ; @@ -299,7 +322,7 @@ force_noforce diskgroup_directory_clauses : ADD DIRECTORY filename (',' filename)* - | DROP DIRECTORY filename force_noforce? (','filename force_noforce?)* + | DROP DIRECTORY filename force_noforce? (',' filename force_noforce?)* | RENAME DIRECTORY dir_name TO dir_name (',' dir_name TO dir_name)* ; @@ -321,14 +344,13 @@ diskgroup_volume_clauses ; add_volume_clause - : ADD VOLUME id_expression SIZE size_clause redundancy_clause? - (STRIPE_WIDTH numeric (K_LETTER | M_LETTER))? - (STRIPE_COLUMNS numeric)? + : ADD VOLUME id_expression SIZE size_clause redundancy_clause? ( + STRIPE_WIDTH numeric (K_LETTER | M_LETTER) + )? (STRIPE_COLUMNS numeric)? ; modify_volume_clause - : MODIFY VOLUME id_expression (MOUNTPATH CHAR_STRING)? - (USAGE CHAR_STRING)? + : MODIFY VOLUME id_expression (MOUNTPATH CHAR_STRING)? (USAGE CHAR_STRING)? ; diskgroup_attributes @@ -336,7 +358,9 @@ diskgroup_attributes ; modify_diskgroup_file - : MODIFY FILE CHAR_STRING ATTRIBUTE '(' disk_region_clause ')' (',' CHAR_STRING ATTRIBUTE '(' disk_region_clause ')')* + : MODIFY FILE CHAR_STRING ATTRIBUTE '(' disk_region_clause ')' ( + ',' CHAR_STRING ATTRIBUTE '(' disk_region_clause ')' + )* ; disk_region_clause @@ -364,21 +388,21 @@ user_clauses ; file_permissions_clause - : SET PERMISSION (OWNER | GROUP | OTHER) '=' (NONE | READ (ONLY | WRITE)) (',' (OWNER | GROUP | OTHER) '=' (NONE | READ (ONLY | WRITE)))* - FOR FILE CHAR_STRING (',' CHAR_STRING)* + : SET PERMISSION (OWNER | GROUP | OTHER) '=' (NONE | READ (ONLY | WRITE)) ( + ',' (OWNER | GROUP | OTHER) '=' (NONE | READ (ONLY | WRITE)) + )* FOR FILE CHAR_STRING (',' CHAR_STRING)* ; file_owner_clause - : SET OWNERSHIP (OWNER | GROUP) '=' CHAR_STRING (',' (OWNER | GROUP) '=' CHAR_STRING)* FOR FILE CHAR_STRING (',' CHAR_STRING)* + : SET OWNERSHIP (OWNER | GROUP) '=' CHAR_STRING (',' (OWNER | GROUP) '=' CHAR_STRING)* FOR FILE CHAR_STRING ( + ',' CHAR_STRING + )* ; scrub_clause - : SCRUB (FILE CHAR_STRING | DISK id_expression)? - (REPAIR | NOREPAIR)? - (POWER (AUTO | LOW | HIGH | MAX))? - wait_nowait? - force_noforce? - STOP? + : SCRUB (FILE CHAR_STRING | DISK id_expression)? (REPAIR | NOREPAIR)? ( + POWER (AUTO | LOW | HIGH | MAX) + )? wait_nowait? force_noforce? STOP? ; quotagroup_clauses @@ -404,13 +428,13 @@ filegroup_clauses ; add_filegroup_clause - : ADD FILEGROUP id_expression ((DATABASE | CLUSTER | VOLUME) id_expression | TEMPLATE) (FROM TEMPLATE id_expression)? - (SET CHAR_STRING '=' CHAR_STRING)? + : ADD FILEGROUP id_expression ((DATABASE | CLUSTER | VOLUME) id_expression | TEMPLATE) ( + FROM TEMPLATE id_expression + )? (SET CHAR_STRING '=' CHAR_STRING)? ; modify_filegroup_clause - : MODIFY FILEGROUP id_expression - SET CHAR_STRING '=' CHAR_STRING + : MODIFY FILEGROUP id_expression SET CHAR_STRING '=' CHAR_STRING ; move_to_filegroup_clause @@ -421,7 +445,6 @@ drop_filegroup_clause : DROP FILEGROUP id_expression CASCADE? ; - quorum_regular : QUORUM | REGULAR @@ -437,7 +460,7 @@ diskgroup_availability ; enable_disable_volume - : (ENABLE | DISABLE) VOLUME ( id_expression (',' id_expression)* | ALL) + : (ENABLE | DISABLE) VOLUME (id_expression (',' id_expression)* | ALL) ; // DDL -> SQL Statements for Stored PL/SQL Units @@ -450,19 +473,22 @@ drop_function // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-FLASHBACK-ARCHIVE.html alter_flashback_archive - : ALTER FLASHBACK ARCHIVE fa=id_expression - ( SET DEFAULT - | (ADD | MODIFY) TABLESPACE ts=id_expression flashback_archive_quota? - | REMOVE TABLESPACE rts=id_expression + : ALTER FLASHBACK ARCHIVE fa = id_expression ( + SET DEFAULT + | (ADD | MODIFY) TABLESPACE ts = id_expression flashback_archive_quota? + | REMOVE TABLESPACE rts = id_expression | MODIFY /*RETENTION*/ flashback_archive_retention // inconsistent documentation | PURGE (ALL | BEFORE (SCN expression | TIMESTAMP expression)) | NO? OPTIMIZE DATA - ) + ) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-HIERARCHY.html alter_hierarchy - : ALTER HIERARCHY (schema_name '.')? hn=id_expression (RENAME TO nhn=id_expression | COMPILE) + : ALTER HIERARCHY (schema_name '.')? hn = id_expression ( + RENAME TO nhn = id_expression + | COMPILE + ) ; alter_function @@ -471,9 +497,9 @@ alter_function // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-JAVA.html alter_java - : ALTER JAVA (SOURCE | CLASS) (schema_name '.')? o=id_expression - (RESOLVER '(' ('(' match_string ','? (schema_name | '-') ')')+ ')')? - (COMPILE | RESOLVE | invoker_rights_clause) + : ALTER JAVA (SOURCE | CLASS) (schema_name '.')? o = id_expression ( + RESOLVER '(' ('(' match_string ','? (schema_name | '-') ')')+ ')' + )? (COMPILE | RESOLVE | invoker_rights_clause) ; match_string @@ -482,12 +508,18 @@ match_string ; create_function_body - : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? FUNCTION function_name ('(' parameter (',' parameter)* ')')? - RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)* - ((PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) + : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? FUNCTION function_name ( + '(' parameter (',' parameter)* ')' + )? RETURN type_spec ( + invoker_rights_clause + | parallel_enable_clause + | result_cache_clause + | DETERMINISTIC + )* ( + (PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name | sql_macro_body - ) ';' + ) ';' ; sql_macro_body @@ -518,55 +550,56 @@ streaming_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-OUTLINE.html alter_outline - : ALTER OUTLINE (PUBLIC | PRIVATE)? o=id_expression - outline_options+ + : ALTER OUTLINE (PUBLIC | PRIVATE)? o = id_expression outline_options+ ; outline_options : REBUILD - | RENAME TO non=id_expression - | CHANGE CATEGORY TO ncn=id_expression + | RENAME TO non = id_expression + | CHANGE CATEGORY TO ncn = id_expression | ENABLE | DISABLE ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-LOCKDOWN-PROFILE.html alter_lockdown_profile - : ALTER LOCKDOWN PROFILE id_expression (lockdown_feature | lockdown_options | lockdown_statements) - (USERS '=' (ALL | COMMON | LOCAL))? + : ALTER LOCKDOWN PROFILE id_expression ( + lockdown_feature + | lockdown_options + | lockdown_statements + ) (USERS '=' (ALL | COMMON | LOCAL))? ; lockdown_feature - : disable_enable FEATURE ( '=' '(' string_list ')' - | ALL (EXCEPT '=' '(' string_list ')')? - ) + : disable_enable FEATURE ('=' '(' string_list ')' | ALL (EXCEPT '=' '(' string_list ')')?) ; lockdown_options - : disable_enable OPTION ( '=' '(' string_list ')' - | ALL (EXCEPT '=' '(' string_list ')')? - ) + : disable_enable OPTION ('=' '(' string_list ')' | ALL (EXCEPT '=' '(' string_list ')')?) ; lockdown_statements - : disable_enable STATEMENT ( '=' '(' string_list ')' - | '=' '(' CHAR_STRING ')' statement_clauses - | ALL (EXCEPT '=' '(' string_list ')')? - ) + : disable_enable STATEMENT ( + '=' '(' string_list ')' + | '=' '(' CHAR_STRING ')' statement_clauses + | ALL (EXCEPT '=' '(' string_list ')')? + ) ; statement_clauses - : CLAUSE ( '=' '(' string_list ')' - | '=' '(' CHAR_STRING ')' clause_options - | ALL (EXCEPT '=' '(' string_list ')')? - ) + : CLAUSE ( + '=' '(' string_list ')' + | '=' '(' CHAR_STRING ')' clause_options + | ALL (EXCEPT '=' '(' string_list ')')? + ) ; clause_options - : OPTION ( '=' '(' string_list ')' - | '=' '(' CHAR_STRING ')' option_values+ - | ALL (EXCEPT '=' '(' string_list ')')? - ) + : OPTION ( + '=' '(' string_list ')' + | '=' '(' CHAR_STRING ')' option_values+ + | ALL (EXCEPT '=' '(' string_list ')')? + ) ; option_values @@ -585,7 +618,7 @@ disable_enable // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-LOCKDOWN-PROFILE.html drop_lockdown_profile - : DROP LOCKDOWN PROFILE p=id_expression + : DROP LOCKDOWN PROFILE p = id_expression ; // Package DDLs @@ -595,15 +628,23 @@ drop_package ; alter_package - : ALTER PACKAGE package_name COMPILE DEBUG? (PACKAGE | BODY | SPECIFICATION)? compiler_parameters_clause* (REUSE SETTINGS)? + : ALTER PACKAGE package_name COMPILE DEBUG? (PACKAGE | BODY | SPECIFICATION)? compiler_parameters_clause* ( + REUSE SETTINGS + )? ; create_package - : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? PACKAGE (schema_object_name '.')? package_name invoker_rights_clause? (IS | AS) package_obj_spec* END package_name? + : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? PACKAGE (schema_object_name '.')? package_name invoker_rights_clause? ( + IS + | AS + ) package_obj_spec* END package_name? ; create_package_body - : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? PACKAGE BODY (schema_object_name '.')? package_name (IS | AS) package_obj_body* (BEGIN seq_of_statements)? END package_name? + : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? PACKAGE BODY (schema_object_name '.')? package_name ( + IS + | AS + ) package_obj_body* (BEGIN seq_of_statements)? END package_name? ; // Create Package Specific Clauses @@ -620,12 +661,13 @@ package_obj_spec ; procedure_spec - : PROCEDURE identifier ('(' parameter ( ',' parameter )* ')')? ';' + : PROCEDURE identifier ('(' parameter ( ',' parameter)* ')')? ';' ; function_spec - : FUNCTION identifier ('(' parameter ( ',' parameter)* ')')? - RETURN type_spec PIPELINED? DETERMINISTIC? (RESULT_CACHE)? ';' + : FUNCTION identifier ('(' parameter ( ',' parameter)* ')')? RETURN type_spec PIPELINED? DETERMINISTIC? ( + RESULT_CACHE + )? ';' ; package_obj_body @@ -643,18 +685,17 @@ package_obj_body // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/alter-pmem-filestore.html alter_pmem_filestore - : ALTER PMEM FILESTORE fsn=id_expression - ( RESIZE size_clause + : ALTER PMEM FILESTORE fsn = id_expression ( + RESIZE size_clause | autoextend_clause | MOUNT (MOUNTPOINT file_path)? (BACKINGFILE filename)? FORCE? //inconsistent documentation | DISMOUNT - ) + ) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/drop-pmem-filestore.html drop_pmem_filestore - : DROP PMEM FILESTORE fsn=id_expression - ((FORCE? INCLUDING | EXCLUDING) CONTENTS)? + : DROP PMEM FILESTORE fsn = id_expression ((FORCE? INCLUDING | EXCLUDING) CONTENTS)? ; // Procedure DDLs @@ -668,42 +709,59 @@ alter_procedure ; function_body - : FUNCTION identifier ('(' parameter (',' parameter)* ')')? - RETURN type_spec (invoker_rights_clause | parallel_enable_clause | result_cache_clause | DETERMINISTIC)* - ((PIPELINED? DETERMINISTIC? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) | (PIPELINED | AGGREGATE) USING implementation_type_name) ';' + : FUNCTION identifier ('(' parameter (',' parameter)* ')')? RETURN type_spec ( + invoker_rights_clause + | parallel_enable_clause + | result_cache_clause + | DETERMINISTIC + )* ( + (PIPELINED? DETERMINISTIC? (IS | AS) (DECLARE? seq_of_declare_specs? body | call_spec)) + | (PIPELINED | AGGREGATE) USING implementation_type_name + ) ';' ; procedure_body - : PROCEDURE identifier ('(' parameter (',' parameter)* ')')? (IS | AS) - (DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';' + : PROCEDURE identifier ('(' parameter (',' parameter)* ')')? (IS | AS) ( + DECLARE? seq_of_declare_specs? body + | call_spec + | EXTERNAL + ) ';' ; create_procedure_body - : CREATE (OR REPLACE)? PROCEDURE procedure_name ('(' parameter (',' parameter)* ')')? - invoker_rights_clause? (IS | AS) - (DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';' + : CREATE (OR REPLACE)? PROCEDURE procedure_name ('(' parameter (',' parameter)* ')')? invoker_rights_clause? ( + IS + | AS + ) (DECLARE? seq_of_declare_specs? body | call_spec | EXTERNAL) ';' ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-RESOURCE-COST.html alter_resource_cost - : ALTER RESOURCE COST ((CPU_PER_SESSION | CONNECT_TIME | LOGICAL_READS_PER_SESSION | PRIVATE_SGA) UNSIGNED_INTEGER)+ + : ALTER RESOURCE COST ( + (CPU_PER_SESSION | CONNECT_TIME | LOGICAL_READS_PER_SESSION | PRIVATE_SGA) UNSIGNED_INTEGER + )+ ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-OUTLINE.html drop_outline - : DROP OUTLINE o=id_expression + : DROP OUTLINE o = id_expression ; // Rollback Segment DDLs //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_2011.htm#SQLRF00816 alter_rollback_segment - : ALTER ROLLBACK SEGMENT rollback_segment_name (ONLINE | OFFLINE | storage_clause | SHRINK (TO size_clause)?) + : ALTER ROLLBACK SEGMENT rollback_segment_name ( + ONLINE + | OFFLINE + | storage_clause + | SHRINK (TO size_clause)? + ) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-RESTORE-POINT.html drop_restore_point - : DROP RESTORE POINT rp=id_expression (FOR PLUGGABLE DATABASE pdb=id_expression)? + : DROP RESTORE POINT rp = id_expression (FOR PLUGGABLE DATABASE pdb = id_expression)? ; drop_rollback_segment @@ -716,8 +774,7 @@ drop_role // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/create-pmem-filestore.html create_pmem_filestore - : CREATE PMEM FILESTORE fsn=id_expression - pmem_filestore_options+ + : CREATE PMEM FILESTORE fsn = id_expression pmem_filestore_options+ ; pmem_filestore_options @@ -732,7 +789,10 @@ file_path ; create_rollback_segment - : CREATE PUBLIC? ROLLBACK SEGMENT rollback_segment_name (TABLESPACE tablespace | storage_clause)* + : CREATE PUBLIC? ROLLBACK SEGMENT rollback_segment_name ( + TABLESPACE tablespace + | storage_clause + )* ; // Trigger DDLs @@ -742,14 +802,19 @@ drop_trigger ; alter_trigger - : ALTER TRIGGER alter_trigger_name=trigger_name - ((ENABLE | DISABLE) | RENAME TO rename_trigger_name=trigger_name | COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)?) + : ALTER TRIGGER alter_trigger_name = trigger_name ( + (ENABLE | DISABLE) + | RENAME TO rename_trigger_name = trigger_name + | COMPILE DEBUG? compiler_parameters_clause* (REUSE SETTINGS)? + ) ; create_trigger - : CREATE ( OR REPLACE )? TRIGGER trigger_name - (simple_dml_trigger | compound_dml_trigger | non_dml_trigger) - trigger_follows_clause? (ENABLE | DISABLE)? trigger_when_clause? trigger_body + : CREATE (OR REPLACE)? TRIGGER trigger_name ( + simple_dml_trigger + | compound_dml_trigger + | non_dml_trigger + ) trigger_follows_clause? (ENABLE | DISABLE)? trigger_when_clause? trigger_body ; trigger_follows_clause @@ -793,10 +858,10 @@ compound_trigger_block ; timing_point_section - : bk=BEFORE STATEMENT IS BEGIN tps_body END BEFORE STATEMENT ';' - | bk=BEFORE EACH ROW IS BEGIN tps_body END BEFORE EACH ROW ';' - | ak=AFTER STATEMENT IS BEGIN tps_body END AFTER STATEMENT ';' - | ak=AFTER EACH ROW IS BEGIN tps_body END AFTER EACH ROW ';' + : bk = BEFORE STATEMENT IS BEGIN tps_body END BEFORE STATEMENT ';' + | bk = BEFORE EACH ROW IS BEGIN tps_body END BEFORE EACH ROW ';' + | ak = AFTER STATEMENT IS BEGIN tps_body END AFTER STATEMENT ';' + | ak = AFTER EACH ROW IS BEGIN tps_body END AFTER EACH ROW ';' ; non_dml_event @@ -853,14 +918,14 @@ drop_type ; alter_type - : ALTER TYPE type_name - (compile_type_clause - | replace_type_clause - //TODO | {input.LT(2).getText().equalsIgnoreCase("attribute")}? alter_attribute_definition - | alter_method_spec - | alter_collection_clauses - | modifier_clause - | overriding_subprogram_spec + : ALTER TYPE type_name ( + compile_type_clause + | replace_type_clause + //TODO | {input.LT(2).getText().equalsIgnoreCase("attribute")}? alter_attribute_definition + | alter_method_spec + | alter_collection_clauses + | modifier_clause + | overriding_subprogram_spec ) dependent_handling_clause? ; @@ -883,7 +948,10 @@ alter_method_element ; alter_attribute_definition - : (ADD | MODIFY | DROP) ATTRIBUTE (attribute_definition | '(' attribute_definition (',' attribute_definition)* ')') + : (ADD | MODIFY | DROP) ATTRIBUTE ( + attribute_definition + | '(' attribute_definition (',' attribute_definition)* ')' + ) ; attribute_definition @@ -914,8 +982,9 @@ type_definition ; object_type_def - : invoker_rights_clause? (object_as_part | object_under_part) sqlj_object_type? - ('(' object_member_spec (',' object_member_spec)* ')')? modifier_clause* + : invoker_rights_clause? (object_as_part | object_under_part) sqlj_object_type? ( + '(' object_member_spec (',' object_member_spec)* ')' + )? modifier_clause* ; object_as_part @@ -953,19 +1022,23 @@ subprog_decl_in_type ; proc_decl_in_type - : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' - (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') + : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ( + IS + | AS + ) (call_spec | DECLARE? seq_of_declare_specs? body ';') ; func_decl_in_type - : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN type_spec (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') + : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? RETURN type_spec ( + IS + | AS + ) (call_spec | DECLARE? seq_of_declare_specs? body ';') ; constructor_declaration - : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec - ('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN SELF AS RESULT (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') + : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec ( + '(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')' + )? RETURN SELF AS RESULT (IS | AS) (call_spec | DECLARE? seq_of_declare_specs? body ';') ; // Common Type Clauses @@ -1003,24 +1076,29 @@ overriding_subprogram_spec ; overriding_function_spec - : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN (type_spec | SELF AS RESULT) - (PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body))? ';'? + : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? RETURN ( + type_spec + | SELF AS RESULT + ) (PIPELINED? (IS | AS) (DECLARE? seq_of_declare_specs? body))? ';'? ; type_procedure_spec - : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ((IS | AS) call_spec)? + : PROCEDURE procedure_name '(' type_elements_parameter (',' type_elements_parameter)* ')' ( + (IS | AS) call_spec + )? ; type_function_spec - : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN (type_spec | SELF AS RESULT) ((IS | AS) call_spec | EXTERNAL VARIABLE? NAME expression)? + : FUNCTION function_name ('(' type_elements_parameter (',' type_elements_parameter)* ')')? RETURN ( + type_spec + | SELF AS RESULT + ) ((IS | AS) call_spec | EXTERNAL VARIABLE? NAME expression)? ; constructor_spec - : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION - type_spec ('(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')')? - RETURN SELF AS RESULT ((IS | AS) call_spec)? + : FINAL? INSTANTIABLE? CONSTRUCTOR FUNCTION type_spec ( + '(' (SELF IN OUT type_spec ',') type_elements_parameter (',' type_elements_parameter)* ')' + )? RETURN SELF AS RESULT ((IS | AS) call_spec)? ; map_order_function_spec @@ -1053,21 +1131,23 @@ alter_sequence // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-SESSION.html alter_session : ALTER SESSION ( - ADVISE ( COMMIT | ROLLBACK | NOTHING ) + ADVISE ( COMMIT | ROLLBACK | NOTHING) | CLOSE DATABASE LINK parameter_name | enable_or_disable COMMIT IN PROCEDURE | enable_or_disable GUARD - | (enable_or_disable | FORCE) PARALLEL (DML | DDL | QUERY) (PARALLEL (literal | parameter_name))? + | (enable_or_disable | FORCE) PARALLEL (DML | DDL | QUERY) ( + PARALLEL (literal | parameter_name) + )? | SET alter_session_set_clause ) ; alter_session_set_clause : (parameter_name '=' parameter_value)+ - | EDITION '=' en=id_expression - | CONTAINER '=' cn=id_expression (SERVICE '=' sn=id_expression)? + | EDITION '=' en = id_expression + | CONTAINER '=' cn = id_expression (SERVICE '=' sn = id_expression)? | ROW ARCHIVAL VISIBILITY '=' (ACTIVE | ALL) - | DEFAULT_COLLATION '=' (c=id_expression | NONE) + | DEFAULT_COLLATION '=' (c = id_expression | NONE) ; create_sequence @@ -1096,17 +1176,10 @@ sequence_start_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-ANALYTIC-VIEW.html create_analytic_view - : CREATE (OR REPLACE)? (NOFORCE | FORCE)? ANALYTIC VIEW av=id_expression - (SHARING '=' (METADATA | NONE))? - classification_clause* - cav_using_clause? - dim_by_clause? - measures_clause? - default_measure_clause? - default_aggregate_clause? - cache_clause? - fact_columns_clause? - qry_transform_clause? + : CREATE (OR REPLACE)? (NOFORCE | FORCE)? ANALYTIC VIEW av = id_expression ( + SHARING '=' (METADATA | NONE) + )? classification_clause* cav_using_clause? dim_by_clause? measures_clause? default_measure_clause? default_aggregate_clause? cache_clause? + fact_columns_clause? qry_transform_clause? ; classification_clause @@ -1117,24 +1190,24 @@ classification_clause ; caption_clause - : CAPTION c=quoted_string + : CAPTION c = quoted_string ; description_clause - : DESCRIPTION d=quoted_string + : DESCRIPTION d = quoted_string ; classification_item - : CLASSIFICATION cn=id_expression (VALUE cv=quoted_string)? (LANGUAGE language)? + : CLASSIFICATION cn = id_expression (VALUE cv = quoted_string)? (LANGUAGE language)? ; language : NULL_ - | nls=id_expression + | nls = id_expression ; cav_using_clause - : USING (schema_name '.')? t=id_expression REMOTE? (AS? ta=id_expression)? + : USING (schema_name '.')? t = id_expression REMOTE? (AS? ta = id_expression)? ; dim_by_clause @@ -1142,20 +1215,20 @@ dim_by_clause ; dim_key - : dim_ref classification_clause* - KEY ( '(' (a=id_expression '.')? f=column_name (',' (a=id_expression '.')? f=column_name)* ')' - | (a=id_expression '.')? f=column_name - ) - REFERENCES DISTINCT? ('(' attribute_name (',' attribute_name) ')' | attribute_name) - HIERARCHIES '(' hier_ref (',' hier_ref)* ')' + : dim_ref classification_clause* KEY ( + '(' (a = id_expression '.')? f = column_name (',' (a = id_expression '.')? f = column_name)* ')' + | (a = id_expression '.')? f = column_name + ) REFERENCES DISTINCT? ('(' attribute_name (',' attribute_name) ')' | attribute_name) HIERARCHIES '(' hier_ref ( + ',' hier_ref + )* ')' ; dim_ref - : (schema_name '.')? ad=id_expression (AS? da=id_expression)? + : (schema_name '.')? ad = id_expression (AS? da = id_expression)? ; hier_ref - : (schema_name '.')? h=id_expression (AS? ha=id_expression)? DEFAULT? + : (schema_name '.')? h = id_expression (AS? ha = id_expression)? DEFAULT? ; measures_clause @@ -1163,11 +1236,11 @@ measures_clause ; av_measure - : mn=id_expression (base_meas_clause | calc_meas_clause)? //classification_clause* + : mn = id_expression (base_meas_clause | calc_meas_clause)? //classification_clause* ; base_meas_clause - : FACT /*FOR MEASURE*/ bm=id_expression meas_aggregate_clause? //FIXME inconsistent documentation + : FACT /*FOR MEASURE*/ bm = id_expression meas_aggregate_clause? //FIXME inconsistent documentation ; meas_aggregate_clause @@ -1179,7 +1252,7 @@ calc_meas_clause ; default_measure_clause - : DEFAULT MEASURE m=id_expression + : DEFAULT MEASURE m = id_expression ; default_aggregate_clause @@ -1191,7 +1264,10 @@ cache_clause ; cache_specification - : MEASURE GROUP (ALL | '(' id_expression (',' id_expression)* ')' levels_clause (',' levels_clause)* ) + : MEASURE GROUP ( + ALL + | '(' id_expression (',' id_expression)* ')' levels_clause (',' levels_clause)* + ) ; levels_clause @@ -1199,16 +1275,16 @@ levels_clause ; level_specification - : '(' ((d=id_expression '.')? h=id_expression '.')? l=id_expression ')' + : '(' ((d = id_expression '.')? h = id_expression '.')? l = id_expression ')' ; level_group_type : DYNAMIC - | MATERIALIZED (USING (schema_name '.')? t=id_expression)? + | MATERIALIZED (USING (schema_name '.')? t = id_expression)? ; fact_columns_clause - : FACT COLUMN f=column_name (AS? fa=id_expression (',' AS? fa=id_expression)* )? + : FACT COLUMN f = column_name (AS? fa = id_expression (',' AS? fa = id_expression)*)? ; qry_transform_clause @@ -1217,14 +1293,9 @@ qry_transform_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html create_attribute_dimension - : CREATE (OR REPLACE)? (NOFORCE | FORCE)? ATTRIBUTE DIMENSION (schema_name '.')? ad=id_expression - (SHARING '=' (METADATA | NONE))? - classification_clause* - (DIMENSION TYPE (STANDARD | TIME))? - ad_using_clause - attributes_clause - ad_level_clause+ - all_clause? + : CREATE (OR REPLACE)? (NOFORCE | FORCE)? ATTRIBUTE DIMENSION (schema_name '.')? ad = id_expression ( + SHARING '=' (METADATA | NONE) + )? classification_clause* (DIMENSION TYPE (STANDARD | TIME))? ad_using_clause attributes_clause ad_level_clause+ all_clause? ; ad_using_clause @@ -1232,11 +1303,11 @@ ad_using_clause ; source_clause - : (schema_name '.')? ftov=id_expression REMOTE? (AS? a=id_expression)? + : (schema_name '.')? ftov = id_expression REMOTE? (AS? a = id_expression)? ; join_path_clause - : JOIN PATH jpn=id_expression ON join_condition + : JOIN PATH jpn = id_expression ON join_condition ; join_condition @@ -1244,7 +1315,7 @@ join_condition ; join_condition_item - : (a=id_expression '.')? column_name '=' (b=id_expression '.')? column_name + : (a = id_expression '.')? column_name '=' (b = id_expression '.')? column_name ; attributes_clause @@ -1252,25 +1323,33 @@ attributes_clause ; ad_attributes_clause - : (a=id_expression '.')? column_name (AS? an=id_expression)? - classification_clause* + : (a = id_expression '.')? column_name (AS? an = id_expression)? classification_clause* ; ad_level_clause - : LEVEL l=id_expression (NOT NULL_ | SKIP_ WHEN NULL_)? - (LEVEL TYPE (STANDARD | YEARS | HALF_YEARS | QUARTERS | MONTHS | WEEKS | DAYS | HOURS | MINUTES | SECONDS))? - classification_clause* //inconsistent documentation - LEVEL TYPE goes after the classification_clause rule - key_clause - alternate_key_clause? - (MEMBER NAME expression)? - (MEMBER CAPTION expression)? - (MEMBER DESCRIPTION expression)? - (ORDER BY (MIN | MAX)? dim_order_clause (',' (MIN | MAX)? dim_order_clause)*)? - (DETERMINES '(' id_expression (',' id_expression)* ')')? + : LEVEL l = id_expression (NOT NULL_ | SKIP_ WHEN NULL_)? ( + LEVEL TYPE ( + STANDARD + | YEARS + | HALF_YEARS + | QUARTERS + | MONTHS + | WEEKS + | DAYS + | HOURS + | MINUTES + | SECONDS + ) + )? classification_clause* //inconsistent documentation - LEVEL TYPE goes after the classification_clause rule + key_clause alternate_key_clause? (MEMBER NAME expression)? (MEMBER CAPTION expression)? ( + MEMBER DESCRIPTION expression + )? (ORDER BY (MIN | MAX)? dim_order_clause (',' (MIN | MAX)? dim_order_clause)*)? ( + DETERMINES '(' id_expression (',' id_expression)* ')' + )? ; key_clause - : KEY (a=id_expression | '(' id_expression (',' id_expression)* ')') + : KEY (a = id_expression | '(' id_expression (',' id_expression)* ')') ; alternate_key_clause @@ -1278,25 +1357,22 @@ alternate_key_clause ; dim_order_clause - : a=id_expression (ASC | DESC)? (NULLS (FIRST | LAST))? + : a = id_expression (ASC | DESC)? (NULLS (FIRST | LAST))? ; all_clause - : ALL MEMBER ( NAME expression (MEMBER CAPTION expression)? - | CAPTION expression (MEMBER DESCRIPTION expression)? - | DESCRIPTION expression - ) + : ALL MEMBER ( + NAME expression (MEMBER CAPTION expression)? + | CAPTION expression (MEMBER DESCRIPTION expression)? + | DESCRIPTION expression + ) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html create_audit_policy - : CREATE AUDIT POLICY p=id_expression - privilege_audit_clause? - action_audit_clause? - role_audit_clause? - (WHEN quoted_string EVALUATE PER (STATEMENT | SESSION | INSTANCE))? - (ONLY TOPLEVEL)? - container_clause? + : CREATE AUDIT POLICY p = id_expression privilege_audit_clause? action_audit_clause? role_audit_clause? ( + WHEN quoted_string EVALUATE PER (STATEMENT | SESSION | INSTANCE) + )? (ONLY TOPLEVEL)? container_clause? ; privilege_audit_clause @@ -1316,7 +1392,10 @@ standard_actions ; actions_clause - : (object_action | ALL) ON (DIRECTORY directory_name | (MINING MODEL)? (schema_name '.')? id_expression) + : (object_action | ALL) ON ( + DIRECTORY directory_name + | (MINING MODEL)? (schema_name '.')? id_expression + ) | (system_action | ALL) ; @@ -1345,10 +1424,11 @@ system_action ; component_actions - : ACTIONS COMPONENT '=' ( (DATAPUMP | DIRECT_LOAD | OLS | XS) component_action (',' component_action)* - | DV component_action ON id_expression (',' component_action ON id_expression)* - | PROTOCOL (FTP | HTTP | AUTHENTICATION) - ) + : ACTIONS COMPONENT '=' ( + (DATAPUMP | DIRECT_LOAD | OLS | XS) component_action (',' component_action)* + | DV component_action ON id_expression (',' component_action ON id_expression)* + | PROTOCOL (FTP | HTTP | AUTHENTICATION) + ) ; component_action @@ -1361,11 +1441,10 @@ role_audit_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-CONTROLFILE.html create_controlfile - : CREATE CONTROLFILE REUSE? SET? DATABASE d=id_expression - logfile_clause? (RESETLOGS | NORESETLOGS) - (DATAFILE file_specification (',' file_specification)*)? - controlfile_options* - character_set_clause? + : CREATE CONTROLFILE REUSE? SET? DATABASE d = id_expression logfile_clause? ( + RESETLOGS + | NORESETLOGS + ) (DATAFILE file_specification (',' file_specification)*)? controlfile_options* character_set_clause? ; controlfile_options @@ -1385,7 +1464,7 @@ logfile_clause ; character_set_clause - : CHARACTER SET cs=id_expression + : CHARACTER SET cs = id_expression ; file_specification @@ -1395,26 +1474,29 @@ file_specification // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-DISKGROUP.html create_diskgroup - : CREATE DISKGROUP id_expression ((HIGH | NORMAL | FLEX | EXTENDED (SITE sn=id_expression)? | EXTERNAL) REDUNDANCY)? - (quorum_regular? (FAILGROUP fg=id_expression)? DISK qualified_disk_clause (',' qualified_disk_clause)*)+ - (ATTRIBUTE an=CHAR_STRING '=' av=CHAR_STRING (',' CHAR_STRING '=' CHAR_STRING)*)? + : CREATE DISKGROUP id_expression ( + (HIGH | NORMAL | FLEX | EXTENDED (SITE sn = id_expression)? | EXTERNAL) REDUNDANCY + )? ( + quorum_regular? (FAILGROUP fg = id_expression)? DISK qualified_disk_clause ( + ',' qualified_disk_clause + )* + )+ (ATTRIBUTE an = CHAR_STRING '=' av = CHAR_STRING (',' CHAR_STRING '=' CHAR_STRING)*)? ; qualified_disk_clause - : ss=CHAR_STRING (NAME dn=id_expression)? (SIZE size_clause)? force_noforce? + : ss = CHAR_STRING (NAME dn = id_expression)? (SIZE size_clause)? force_noforce? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-EDITION.html create_edition - : CREATE EDITION e=id_expression (AS CHILD OF pe=id_expression)? + : CREATE EDITION e = id_expression (AS CHILD OF pe = id_expression)? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-FLASHBACK-ARCHIVE.html create_flashback_archive - : CREATE FLASHBACK ARCHIVE DEFAULT? fa=id_expression TABLESPACE ts=id_expression - flashback_archive_quota? - (NO? OPTIMIZE DATA)? - flashback_archive_retention + : CREATE FLASHBACK ARCHIVE DEFAULT? fa = id_expression TABLESPACE ts = id_expression flashback_archive_quota? ( + NO? OPTIMIZE DATA + )? flashback_archive_retention ; flashback_archive_quota @@ -1427,20 +1509,17 @@ flashback_archive_retention // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-HIERARCHY.html create_hierarchy - : CREATE (OR REPLACE)? (NO? FORCE)? HIERARCHY (schema_name '.')? h=id_expression - (SHARING '=' (METADATA | NONE))? - classification_clause* - hier_using_clause - level_hier_clause - hier_attrs_clause? + : CREATE (OR REPLACE)? (NO? FORCE)? HIERARCHY (schema_name '.')? h = id_expression ( + SHARING '=' (METADATA | NONE) + )? classification_clause* hier_using_clause level_hier_clause hier_attrs_clause? ; hier_using_clause - : USING (schema_name '.')? ad=id_expression + : USING (schema_name '.')? ad = id_expression ; level_hier_clause - : '(' (l=id_expression (CHILD OF)?)+ ')' + : '(' (l = id_expression (CHILD OF)?)+ ')' ; hier_attrs_clause @@ -1465,9 +1544,11 @@ hier_attr_name ; create_index - : CREATE (UNIQUE | BITMAP)? INDEX index_name - ON (cluster_index_clause | table_index_clause | bitmap_join_index_clause) - (USABLE | UNUSABLE)? + : CREATE (UNIQUE | BITMAP)? INDEX index_name ON ( + cluster_index_clause + | table_index_clause + | bitmap_join_index_clause + ) (USABLE | UNUSABLE)? ; cluster_index_clause @@ -1479,13 +1560,13 @@ cluster_name ; table_index_clause - : tableview_name table_alias? '(' index_expr (ASC | DESC)? (',' index_expr (ASC | DESC)? )* ')' - index_properties? + : tableview_name table_alias? '(' index_expr (ASC | DESC)? (',' index_expr (ASC | DESC)?)* ')' index_properties? ; + bitmap_join_index_clause - : tableview_name '(' (tableview_name | table_alias)? column_name (ASC | DESC)? (',' (tableview_name | table_alias)? column_name (ASC | DESC)? )* ')' - FROM tableview_name table_alias (',' tableview_name table_alias)* - where_clause local_partitioned_index? index_attributes? + : tableview_name '(' (tableview_name | table_alias)? column_name (ASC | DESC)? ( + ',' (tableview_name | table_alias)? column_name (ASC | DESC)? + )* ')' FROM tableview_name table_alias (',' tableview_name table_alias)* where_clause local_partitioned_index? index_attributes? ; index_expr @@ -1499,43 +1580,52 @@ index_properties ; domain_index_clause - : indextype local_domain_index_clause? parallel_clause? (PARAMETERS '(' odci_parameters ')' )? + : indextype local_domain_index_clause? parallel_clause? (PARAMETERS '(' odci_parameters ')')? ; local_domain_index_clause - : LOCAL ('(' PARTITION partition_name (PARAMETERS '(' odci_parameters ')' )? (',' PARTITION partition_name (PARAMETERS '(' odci_parameters ')' )? )* ')' )? + : LOCAL ( + '(' PARTITION partition_name (PARAMETERS '(' odci_parameters ')')? ( + ',' PARTITION partition_name (PARAMETERS '(' odci_parameters ')')? + )* ')' + )? ; xmlindex_clause - : (XDB '.')? XMLINDEX local_xmlindex_clause? - parallel_clause? //TODO xmlindex_parameters_clause? + : (XDB '.')? XMLINDEX local_xmlindex_clause? parallel_clause? //TODO xmlindex_parameters_clause? ; local_xmlindex_clause - : LOCAL ('(' PARTITION partition_name (',' PARTITION partition_name //TODO xmlindex_parameters_clause? - )* ')')? + : LOCAL ( + '(' PARTITION partition_name ( + ',' PARTITION partition_name //TODO xmlindex_parameters_clause? + )* ')' + )? ; global_partitioned_index - : GLOBAL PARTITION BY (RANGE '(' column_name (',' column_name)* ')' '(' index_partitioning_clause (',' index_partitioning_clause)* ')' - | HASH '(' column_name (',' column_name)* ')' - (individual_hash_partitions - | hash_partitions_by_quantity - ) - ) + : GLOBAL PARTITION BY ( + RANGE '(' column_name (',' column_name)* ')' '(' index_partitioning_clause ( + ',' index_partitioning_clause + )* ')' + | HASH '(' column_name (',' column_name)* ')' ( + individual_hash_partitions + | hash_partitions_by_quantity + ) + ) ; index_partitioning_clause - : PARTITION partition_name? VALUES LESS THAN '(' literal (',' literal)* ')' - segment_attributes_clause? + : PARTITION partition_name? VALUES LESS THAN '(' literal (',' literal)* ')' segment_attributes_clause? ; local_partitioned_index - : LOCAL (on_range_partitioned_table - | on_list_partitioned_table - | on_hash_partitioned_table - | on_comp_partitioned_table - )? + : LOCAL ( + on_range_partitioned_table + | on_list_partitioned_table + | on_hash_partitioned_table + | on_comp_partitioned_table + )? ; on_range_partitioned_table @@ -1547,9 +1637,7 @@ on_list_partitioned_table ; partitioned_table - : PARTITION partition_name? - (segment_attributes_clause | key_compression)* - UNUSABLE? + : PARTITION partition_name? (segment_attributes_clause | key_compression)* UNUSABLE? ; on_hash_partitioned_table @@ -1558,18 +1646,17 @@ on_hash_partitioned_table ; on_hash_partitioned_clause - : PARTITION partition_name? (TABLESPACE tablespace)? - key_compression? UNUSABLE? + : PARTITION partition_name? (TABLESPACE tablespace)? key_compression? UNUSABLE? ; + on_comp_partitioned_table - : (STORE IN '(' tablespace (',' tablespace)* ')' )? - '(' on_comp_partitioned_clause (',' on_comp_partitioned_clause)* ')' + : (STORE IN '(' tablespace (',' tablespace)* ')')? '(' on_comp_partitioned_clause ( + ',' on_comp_partitioned_clause + )* ')' ; on_comp_partitioned_clause - : PARTITION partition_name? - (segment_attributes_clause | key_compression)* - UNUSABLE index_subpartition_clause? + : PARTITION partition_name? (segment_attributes_clause | key_compression)* UNUSABLE index_subpartition_clause? ; index_subpartition_clause @@ -1578,8 +1665,7 @@ index_subpartition_clause ; index_subpartition_subclause - : SUBPARTITION subpartition_name? (TABLESPACE tablespace)? - key_compression? UNUSABLE? + : SUBPARTITION subpartition_name? (TABLESPACE tablespace)? key_compression? UNUSABLE? ; odci_parameters @@ -1596,13 +1682,14 @@ alter_index ; alter_index_ops_set1 - : ( deallocate_unused_clause - | allocate_extent_clause - | shrink_clause - | parallel_clause - | physical_attributes_clause - | logging_clause - )+ + : ( + deallocate_unused_clause + | allocate_extent_clause + | shrink_clause + | parallel_clause + | physical_attributes_clause + | logging_clause + )+ ; alter_index_ops_set2 @@ -1630,20 +1717,16 @@ monitoring_nomonitoring ; rebuild_clause - : REBUILD ( PARTITION partition_name - | SUBPARTITION subpartition_name - | REVERSE - | NOREVERSE - )? - ( parallel_clause - | TABLESPACE tablespace - | PARAMETERS '(' odci_parameters ')' -//TODO | xmlindex_parameters_clause - | ONLINE - | physical_attributes_clause - | key_compression - | logging_clause - )* + : REBUILD (PARTITION partition_name | SUBPARTITION subpartition_name | REVERSE | NOREVERSE)? ( + parallel_clause + | TABLESPACE tablespace + | PARAMETERS '(' odci_parameters ')' + //TODO | xmlindex_parameters_clause + | ONLINE + | physical_attributes_clause + | key_compression + | logging_clause + )* ; alter_index_partitioning @@ -1658,16 +1741,15 @@ alter_index_partitioning ; modify_index_default_attrs - : MODIFY DEFAULT ATTRIBUTES (FOR PARTITION partition_name)? - ( physical_attributes_clause - | TABLESPACE (tablespace | DEFAULT) - | logging_clause - ) + : MODIFY DEFAULT ATTRIBUTES (FOR PARTITION partition_name)? ( + physical_attributes_clause + | TABLESPACE (tablespace | DEFAULT) + | logging_clause + ) ; add_hash_index_partition - : ADD PARTITION partition_name? (TABLESPACE tablespace)? - key_compression? parallel_clause? + : ADD PARTITION partition_name? (TABLESPACE tablespace)? key_compression? parallel_clause? ; coalesce_index_partition @@ -1675,13 +1757,13 @@ coalesce_index_partition ; modify_index_partition - : MODIFY PARTITION partition_name - ( modify_index_partitions_ops+ + : MODIFY PARTITION partition_name ( + modify_index_partitions_ops+ | PARAMETERS '(' odci_parameters ')' | COALESCE | UPDATE BLOCK REFERENCES | UNUSABLE - ) + ) ; modify_index_partitions_ops @@ -1693,8 +1775,7 @@ modify_index_partitions_ops ; rename_index_partition - : RENAME (PARTITION partition_name | SUBPARTITION subpartition_name) - TO new_partition_name + : RENAME (PARTITION partition_name | SUBPARTITION subpartition_name) TO new_partition_name ; drop_index_partition @@ -1702,23 +1783,26 @@ drop_index_partition ; split_index_partition - : SPLIT PARTITION partition_name_old AT '(' literal (',' literal)* ')' - (INTO '(' index_partition_description ',' index_partition_description ')' ) ? parallel_clause? + : SPLIT PARTITION partition_name_old AT '(' literal (',' literal)* ')' ( + INTO '(' index_partition_description ',' index_partition_description ')' + )? parallel_clause? ; index_partition_description - : PARTITION (partition_name ( (segment_attributes_clause | key_compression)+ - | PARAMETERS '(' odci_parameters ')' - ) - UNUSABLE? - )? + : PARTITION ( + partition_name ( + (segment_attributes_clause | key_compression)+ + | PARAMETERS '(' odci_parameters ')' + ) UNUSABLE? + )? ; modify_index_subpartition - : MODIFY SUBPARTITION subpartition_name (UNUSABLE - | allocate_extent_clause - | deallocate_unused_clause - ) + : MODIFY SUBPARTITION subpartition_name ( + UNUSABLE + | allocate_extent_clause + | deallocate_unused_clause + ) ; partition_name_old @@ -1735,31 +1819,30 @@ new_index_name // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-INMEMORY-JOIN-GROUP.html alter_inmemory_join_group - : ALTER INMEMORY JOIN GROUP (schema_name '.')? jg=id_expression - (ADD | REMOVE) '(' (schema_name '.')? t=id_expression '(' c=id_expression ')' ')' + : ALTER INMEMORY JOIN GROUP (schema_name '.')? jg = id_expression (ADD | REMOVE) '(' ( + schema_name '.' + )? t = id_expression '(' c = id_expression ')' ')' ; create_user - : CREATE USER - user_object_name - ( identified_by - | identified_other_clause - | user_tablespace_clause - | quota_clause - | profile_clause - | password_expire_clause - | user_lock_clause - | user_editions_clause - | container_clause - )+ + : CREATE USER user_object_name ( + identified_by + | identified_other_clause + | user_tablespace_clause + | quota_clause + | profile_clause + | password_expire_clause + | user_lock_clause + | user_editions_clause + | container_clause + )+ ; // The standard clauses only permit one user per statement. // The proxy clause allows multiple users for a proxy designation. alter_user - : ALTER USER - user_object_name - ( alter_identified_by + : ALTER USER user_object_name ( + alter_identified_by | identified_other_clause | user_tablespace_clause | quota_clause @@ -1770,9 +1853,8 @@ alter_user | alter_user_editions_clause | container_clause | container_data_clause - )+ - - | user_object_name (',' user_object_name)* proxy_clause + )+ + | user_object_name (',' user_object_name)* proxy_clause ; drop_user @@ -1830,13 +1912,12 @@ alter_user_editions_clause proxy_clause : REVOKE CONNECT THROUGH (ENTERPRISE USERS | user_object_name) - | GRANT CONNECT THROUGH - ( ENTERPRISE USERS - | user_object_name - (WITH (NO ROLES | ROLE role_clause))? - (AUTHENTICATION REQUIRED)? - (AUTHENTICATED USING (PASSWORD | CERTIFICATE | DISTINGUISHED NAME))? - ) + | GRANT CONNECT THROUGH ( + ENTERPRISE USERS + | user_object_name (WITH (NO ROLES | ROLE role_clause))? (AUTHENTICATION REQUIRED)? ( + AUTHENTICATED USING (PASSWORD | CERTIFICATE | DISTINGUISHED NAME) + )? + ) ; container_names @@ -1858,11 +1939,12 @@ container_data_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ADMINISTER-KEY-MANAGEMENT.html administer_key_management - : ADMINISTER KEY MANAGEMENT ( keystore_management_clauses - | key_management_clauses - | secret_management_clauses - | zero_downtime_software_patching_clauses - ) + : ADMINISTER KEY MANAGEMENT ( + keystore_management_clauses + | key_management_clauses + | secret_management_clauses + | zero_downtime_software_patching_clauses + ) ; keystore_management_clauses @@ -1878,15 +1960,14 @@ keystore_management_clauses ; create_keystore - : CREATE ( KEYSTORE ksl=CHAR_STRING - | LOCAL? AUTO_LOGIN KEYSTORE FROM KEYSTORE ksl=CHAR_STRING - ) IDENTIFIED BY keystore_password + : CREATE ( + KEYSTORE ksl = CHAR_STRING + | LOCAL? AUTO_LOGIN KEYSTORE FROM KEYSTORE ksl = CHAR_STRING + ) IDENTIFIED BY keystore_password ; open_keystore - : SET KEYSTORE OPEN force_keystore? - identified_by_store - container_clause? + : SET KEYSTORE OPEN force_keystore? identified_by_store container_clause? ; force_keystore @@ -1894,45 +1975,35 @@ force_keystore ; close_keystore - : SET KEYSTORE CLOSE identified_by_store? - container_clause? + : SET KEYSTORE CLOSE identified_by_store? container_clause? ; backup_keystore - : BACKUP KEYSTORE (USING bi=CHAR_STRING)? force_keystore? - identified_by_store - (TO ksl=CHAR_STRING)? + : BACKUP KEYSTORE (USING bi = CHAR_STRING)? force_keystore? identified_by_store ( + TO ksl = CHAR_STRING + )? ; alter_keystore_password - : ALTER KEYSTORE PASSWORD force_keystore? IDENTIFIED BY o=keystore_password - SET n=keystore_password with_backup_clause? + : ALTER KEYSTORE PASSWORD force_keystore? IDENTIFIED BY o = keystore_password SET n = keystore_password with_backup_clause? ; merge_into_new_keystore - : MERGE KEYSTORE ksl1=CHAR_STRING identified_by_password_clause? - AND KEYSTORE ksl2=CHAR_STRING identified_by_password_clause? - INTO NEW KEYSTORE ksl2=CHAR_STRING identified_by_password_clause + : MERGE KEYSTORE ksl1 = CHAR_STRING identified_by_password_clause? AND KEYSTORE ksl2 = CHAR_STRING identified_by_password_clause? INTO NEW + KEYSTORE ksl2 = CHAR_STRING identified_by_password_clause ; merge_into_existing_keystore - : MERGE KEYSTORE ksl1=CHAR_STRING identified_by_password_clause? - INTO EXISTING KEYSTORE ksl2=CHAR_STRING identified_by_password_clause + : MERGE KEYSTORE ksl1 = CHAR_STRING identified_by_password_clause? INTO EXISTING KEYSTORE ksl2 = CHAR_STRING identified_by_password_clause with_backup_clause? ; isolate_keystore - : FORCE? ISOLATE KEYSTORE IDENTIFIED BY i=keystore_password FROM ROOT KEYSTORE - force_keystore? - identified_by_store - with_backup_clause? + : FORCE? ISOLATE KEYSTORE IDENTIFIED BY i = keystore_password FROM ROOT KEYSTORE force_keystore? identified_by_store with_backup_clause? ; unite_keystore - : UNITE KEYSTORE IDENTIFIED BY i=keystore_password WITH ROOT KEYSTORE - force_keystore? - identified_by_store - with_backup_clause? + : UNITE KEYSTORE IDENTIFIED BY i = keystore_password WITH ROOT KEYSTORE force_keystore? identified_by_store with_backup_clause? ; key_management_clauses @@ -1948,18 +2019,12 @@ key_management_clauses ; set_key - : SET ENCRYPTION? KEY ((mkid ':')? mk)? using_tag_clause? - using_algorithm_clause? force_keystore? - identified_by_store - with_backup_clause? + : SET ENCRYPTION? KEY ((mkid ':')? mk)? using_tag_clause? using_algorithm_clause? force_keystore? identified_by_store with_backup_clause? container_clause? ; create_key - : CREATE ENCRYPTION? KEY ((mkid ':')? mk)? using_tag_clause? - using_algorithm_clause? force_keystore? - identified_by_store - with_backup_clause? + : CREATE ENCRYPTION? KEY ((mkid ':')? mk)? using_tag_clause? using_algorithm_clause? force_keystore? identified_by_store with_backup_clause? container_clause? ; @@ -1972,48 +2037,34 @@ mk ; use_key - : USE ENCRYPTION? KEY k=CHAR_STRING using_tag_clause? force_keystore? - identified_by_store - with_backup_clause? + : USE ENCRYPTION? KEY k = CHAR_STRING using_tag_clause? force_keystore? identified_by_store with_backup_clause? ; set_key_tag - : SET TAG t=CHAR_STRING FOR k=CHAR_STRING force_keystore? - identified_by_store - with_backup_clause? + : SET TAG t = CHAR_STRING FOR k = CHAR_STRING force_keystore? identified_by_store with_backup_clause? ; export_keys - : EXPORT ENCRYPTION? KEYS WITH SECRET secret TO filename - force_keystore? identified_by_store - (WITH IDENTIFIER IN (CHAR_STRING (',' CHAR_STRING)* | '(' subquery ')'))? + : EXPORT ENCRYPTION? KEYS WITH SECRET secret TO filename force_keystore? identified_by_store ( + WITH IDENTIFIER IN (CHAR_STRING (',' CHAR_STRING)* | '(' subquery ')') + )? ; import_keys - : IMPORT ENCRYPTION? KEYS WITH SECRET secret FROM filename - force_keystore? - identified_by_store - with_backup_clause? + : IMPORT ENCRYPTION? KEYS WITH SECRET secret FROM filename force_keystore? identified_by_store with_backup_clause? ; migrate_keys - : SET ENCRYPTION? KEY IDENTIFIED BY hsm=secret - force_keystore? - MIGRATE USING keystore_password - with_backup_clause? + : SET ENCRYPTION? KEY IDENTIFIED BY hsm = secret force_keystore? MIGRATE USING keystore_password with_backup_clause? ; reverse_migrate_keys - : SET ENCRYPTION? KEY IDENTIFIED BY s=secret - force_keystore? - REVERSE MIGRATE USING hsm=secret + : SET ENCRYPTION? KEY IDENTIFIED BY s = secret force_keystore? REVERSE MIGRATE USING hsm = secret ; move_keys - : MOVE ENCRYPTION? KEYS TO NEW KEYSTORE ksl1=CHAR_STRING - IDENTIFIED BY ksp1=keystore_password FROM FORCE? KEYSTORE IDENTIFIED BY ksp=keystore_password - (WITH IDENTIFIER IN (CHAR_STRING (',' CHAR_STRING)* | subquery))? - with_backup_clause? + : MOVE ENCRYPTION? KEYS TO NEW KEYSTORE ksl1 = CHAR_STRING IDENTIFIED BY ksp1 = keystore_password FROM FORCE? KEYSTORE IDENTIFIED BY ksp = + keystore_password (WITH IDENTIFIER IN (CHAR_STRING (',' CHAR_STRING)* | subquery))? with_backup_clause? ; identified_by_store @@ -2021,11 +2072,11 @@ identified_by_store ; using_algorithm_clause - : USING ALGORITHM ea=CHAR_STRING + : USING ALGORITHM ea = CHAR_STRING ; using_tag_clause - : USING TAG t=CHAR_STRING + : USING TAG t = CHAR_STRING ; secret_management_clauses @@ -2036,29 +2087,19 @@ secret_management_clauses ; add_update_secret - : (ADD | UPDATE) SECRET s=CHAR_STRING FOR CLIENT ci=CHAR_STRING - using_tag_clause? - force_keystore? - identified_by_store? - with_backup_clause? + : (ADD | UPDATE) SECRET s = CHAR_STRING FOR CLIENT ci = CHAR_STRING using_tag_clause? force_keystore? identified_by_store? with_backup_clause? ; delete_secret - : DELETE SECRET FOR CLIENT ci=CHAR_STRING - force_keystore? - identified_by_store - with_backup_clause? + : DELETE SECRET FOR CLIENT ci = CHAR_STRING force_keystore? identified_by_store with_backup_clause? ; add_update_secret_seps - : (ADD | UPDATE) SECRET s=CHAR_STRING FOR CLIENT ci=CHAR_STRING - using_tag_clause? - TO LOCAL? AUTO_LOGIN KEYSTORE directory_path + : (ADD | UPDATE) SECRET s = CHAR_STRING FOR CLIENT ci = CHAR_STRING using_tag_clause? TO LOCAL? AUTO_LOGIN KEYSTORE directory_path ; delete_secret_seps - : DELETE SECRET s=CHAR_STRING SQ FOR CLIENT ci=CHAR_STRING - FROM LOCAL? AUTO_LOGIN KEYSTORE directory_path + : DELETE SECRET s = CHAR_STRING SQ FOR CLIENT ci = CHAR_STRING FROM LOCAL? AUTO_LOGIN KEYSTORE directory_path ; zero_downtime_software_patching_clauses @@ -2066,7 +2107,7 @@ zero_downtime_software_patching_clauses ; with_backup_clause - : WITH BACKUP (USING bi=CHAR_STRING)? + : WITH BACKUP (USING bi = CHAR_STRING)? ; identified_by_password_clause @@ -2087,44 +2128,38 @@ secret // https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4005.htm#SQLRF01105 analyze - : ( ANALYZE (TABLE tableview_name | INDEX index_name) partition_extention_clause? - | ANALYZE CLUSTER cluster_name - ) - - ( validation_clauses - | LIST CHAINED ROWS into_clause1? - | DELETE SYSTEM? STATISTICS - ) - + : ( + ANALYZE (TABLE tableview_name | INDEX index_name) partition_extention_clause? + | ANALYZE CLUSTER cluster_name + ) (validation_clauses | LIST CHAINED ROWS into_clause1? | DELETE SYSTEM? STATISTICS) ; partition_extention_clause - : PARTITION ( '(' partition_name ')' - | FOR '(' partition_key_value (',' partition_key_value)* ')' - ) - | SUBPARTITION ( '(' subpartition_name ')' - | FOR '(' subpartition_key_value (',' subpartition_key_value)* ')' - ) + : PARTITION ( + '(' partition_name ')' + | FOR '(' partition_key_value (',' partition_key_value)* ')' + ) + | SUBPARTITION ( + '(' subpartition_name ')' + | FOR '(' subpartition_key_value (',' subpartition_key_value)* ')' + ) ; validation_clauses : VALIDATE REF UPDATE (SET DANGLING TO NULL_)? - | VALIDATE STRUCTURE - ( CASCADE FAST - | CASCADE online_or_offline? into_clause? - | CASCADE - )? - online_or_offline? into_clause? + | VALIDATE STRUCTURE (CASCADE FAST | CASCADE online_or_offline? into_clause? | CASCADE)? online_or_offline? into_clause? ; compute_clauses : COMPUTE SYSTEM? STATISTICS for_clause? ; + for_clause - : FOR ( TABLE for_clause* - | ALL (INDEXED? COLUMNS (SIZE UNSIGNED_INTEGER)? for_clause* | LOCAL? INDEXES) - | COLUMNS (SIZE UNSIGNED_INTEGER)? (column_name SIZE UNSIGNED_INTEGER)+ for_clause* - ) + : FOR ( + TABLE for_clause* + | ALL (INDEXED? COLUMNS (SIZE UNSIGNED_INTEGER)? for_clause* | LOCAL? INDEXES) + | COLUMNS (SIZE UNSIGNED_INTEGER)? (column_name SIZE UNSIGNED_INTEGER)+ for_clause* + ) ; online_or_offline @@ -2149,10 +2184,7 @@ subpartition_key_value //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4006.htm#SQLRF01106 associate_statistics - : ASSOCIATE STATISTICS - WITH (column_association | function_association) - storage_table_clause? - + : ASSOCIATE STATISTICS WITH (column_association | function_association) storage_table_clause? ; column_association @@ -2160,24 +2192,23 @@ column_association ; function_association - : ( FUNCTIONS function_name (',' function_name)* - | PACKAGES package_name (',' package_name)* - | TYPES type_name (',' type_name)* - | INDEXES index_name (',' index_name)* - | INDEXTYPES indextype_name (',' indextype_name)* - ) - - ( using_statistics_type - | default_cost_clause (',' default_selectivity_clause)? - | default_selectivity_clause (',' default_cost_clause)? - ) + : ( + FUNCTIONS function_name (',' function_name)* + | PACKAGES package_name (',' package_name)* + | TYPES type_name (',' type_name)* + | INDEXES index_name (',' index_name)* + | INDEXTYPES indextype_name (',' indextype_name)* + ) ( + using_statistics_type + | default_cost_clause (',' default_selectivity_clause)? + | default_selectivity_clause (',' default_cost_clause)? + ) ; indextype_name : id_expression ; - using_statistics_type : USING (statistics_type_name | NULL_) ; @@ -2216,13 +2247,12 @@ storage_table_clause // https://docs.oracle.com/database/121/SQLRF/statements_4008.htm#SQLRF56110 unified_auditing - : {this.isVersion12()}? - AUDIT (POLICY policy_name ((BY | EXCEPT) audit_user (',' audit_user)* )? - (WHENEVER NOT? SUCCESSFUL)? - | CONTEXT NAMESPACE oracle_namespace - ATTRIBUTES attribute_name (',' attribute_name)* (BY audit_user (',' audit_user)*)? - ) - + : {this.isVersion12()}? AUDIT ( + POLICY policy_name ((BY | EXCEPT) audit_user (',' audit_user)*)? (WHENEVER NOT? SUCCESSFUL)? + | CONTEXT NAMESPACE oracle_namespace ATTRIBUTES attribute_name (',' attribute_name)* ( + BY audit_user (',' audit_user)* + )? + ) ; policy_name @@ -2233,14 +2263,12 @@ policy_name // https://docs.oracle.com/database/121/SQLRF/statements_4007.htm#SQLRF01107 audit_traditional - : AUDIT ( audit_operation_clause (auditing_by_clause | IN SESSION CURRENT)? - | audit_schema_object_clause - | NETWORK - | audit_direct_path - ) - (BY (SESSION | ACCESS) )? (WHENEVER NOT? SUCCESSFUL)? - audit_container_clause? - + : AUDIT ( + audit_operation_clause (auditing_by_clause | IN SESSION CURRENT)? + | audit_schema_object_clause + | NETWORK + | audit_direct_path + ) (BY (SESSION | ACCESS))? (WHENEVER NOT? SUCCESSFUL)? audit_container_clause? ; audit_direct_path @@ -2252,9 +2280,10 @@ audit_container_clause ; audit_operation_clause - : ( (sql_statement_shortcut | ALL STATEMENTS?) (',' (sql_statement_shortcut | ALL STATEMENTS?) )* - | (system_privilege | ALL PRIVILEGES) (',' (system_privilege | ALL PRIVILEGES) )* - ) + : ( + (sql_statement_shortcut | ALL STATEMENTS?) (',' (sql_statement_shortcut | ALL STATEMENTS?))* + | (system_privilege | ALL PRIVILEGES) (',' (system_privilege | ALL PRIVILEGES))* + ) ; auditing_by_clause @@ -2266,7 +2295,7 @@ audit_user ; audit_schema_object_clause - : ( sql_operation (',' sql_operation)* | ALL) auditing_on_clause + : (sql_operation (',' sql_operation)* | ALL) auditing_on_clause ; sql_operation @@ -2287,12 +2316,13 @@ sql_operation ; auditing_on_clause - : ON ( object_name - | DIRECTORY regular_id - | MINING MODEL model_name - | {this.isVersion12()}? SQL TRANSLATION PROFILE profile_name - | DEFAULT - ) + : ON ( + object_name + | DIRECTORY regular_id + | MINING MODEL model_name + | {this.isVersion12()}? SQL TRANSLATION PROFILE profile_name + | DEFAULT + ) ; model_name @@ -2359,32 +2389,39 @@ drop_index // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DISASSOCIATE-STATISTICS.html disassociate_statistics - : DISASSOCIATE STATISTICS FROM - ( COLUMNS (schema_name '.')? tb=id_expression '.' c=id_expression (',' (schema_name '.')? tb=id_expression '.' c=id_expression)* - | FUNCTIONS (schema_name '.')? fn=id_expression (',' (schema_name '.')? fn=id_expression)* - | PACKAGES (schema_name '.')? pkg=id_expression (',' (schema_name '.')? pkg=id_expression)* - | TYPES (schema_name '.')? t=id_expression (',' (schema_name '.')? t=id_expression)* - | INDEXES (schema_name '.')? ix=id_expression (',' (schema_name '.')? ix=id_expression)* - | INDEXTYPES (schema_name '.')? it=id_expression (',' (schema_name '.')? it=id_expression)* - ) - FORCE? + : DISASSOCIATE STATISTICS FROM ( + COLUMNS (schema_name '.')? tb = id_expression '.' c = id_expression ( + ',' (schema_name '.')? tb = id_expression '.' c = id_expression + )* + | FUNCTIONS (schema_name '.')? fn = id_expression ( + ',' (schema_name '.')? fn = id_expression + )* + | PACKAGES (schema_name '.')? pkg = id_expression ( + ',' (schema_name '.')? pkg = id_expression + )* + | TYPES (schema_name '.')? t = id_expression (',' (schema_name '.')? t = id_expression)* + | INDEXES (schema_name '.')? ix = id_expression (',' (schema_name '.')? ix = id_expression)* + | INDEXTYPES (schema_name '.')? it = id_expression ( + ',' (schema_name '.')? it = id_expression + )* + ) FORCE? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-INDEXTYPE.html drop_indextype - : DROP INDEXTYPE (schema_name '.')? it=id_expression FORCE? + : DROP INDEXTYPE (schema_name '.')? it = id_expression FORCE? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-INMEMORY-JOIN-GROUP.html drop_inmemory_join_group - : DROP INMEMORY JOIN GROUP (schema_name '.')? jg=id_expression + : DROP INMEMORY JOIN GROUP (schema_name '.')? jg = id_expression ; flashback_table - : FLASHBACK TABLE tableview_name (',' tableview_name)* TO - ( ((SCN | TIMESTAMP) expression | RESTORE POINT restore_point) ((ENABLE | DISABLE) TRIGGERS)? + : FLASHBACK TABLE tableview_name (',' tableview_name)* TO ( + ((SCN | TIMESTAMP) expression | RESTORE POINT restore_point) ((ENABLE | DISABLE) TRIGGERS)? | BEFORE DROP (RENAME TO tableview_name)? - ) + ) ; restore_point @@ -2393,23 +2430,22 @@ restore_point // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/PURGE.html purge_statement - : PURGE ( (TABLE | INDEX) id_expression - | TABLESPACE SET? ts=id_expression (USER u=id_expression)? - | RECYCLEBIN - | DBA_RECYCLEBIN - ) + : PURGE ( + (TABLE | INDEX) id_expression + | TABLESPACE SET? ts = id_expression (USER u = id_expression)? + | RECYCLEBIN + | DBA_RECYCLEBIN + ) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/NOAUDIT-Traditional-Auditing.html noaudit_statement - : NOAUDIT - ( audit_operation_clause auditing_by_clause? + : NOAUDIT ( + audit_operation_clause auditing_by_clause? | audit_schema_object_clause | NETWORK | DIRECT_PATH LOAD auditing_by_clause? - ) - (WHENEVER NOT? SUCCESSFUL)? - container_clause? + ) (WHENEVER NOT? SUCCESSFUL)? container_clause? ; rename_object @@ -2417,19 +2453,11 @@ rename_object ; grant_statement - : GRANT - ( ','? - (role_name - | system_privilege - | object_privilege paren_column_list? - ) - )+ - (ON grant_object_name)? - TO (grantee_name | PUBLIC) (',' (grantee_name | PUBLIC) )* - (WITH (ADMIN | DELEGATE) OPTION)? - (WITH HIERARCHY OPTION)? - (WITH GRANT OPTION)? - container_clause? + : GRANT (','? (role_name | system_privilege | object_privilege paren_column_list?))+ ( + ON grant_object_name + )? TO (grantee_name | PUBLIC) (',' (grantee_name | PUBLIC))* (WITH (ADMIN | DELEGATE) OPTION)? ( + WITH HIERARCHY OPTION + )? (WITH GRANT OPTION)? container_clause? ; container_clause @@ -2438,7 +2466,10 @@ container_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/REVOKE.html revoke_statement - : REVOKE ((revoke_system_privilege | revoke_object_privileges) container_clause? | revoke_roles_from_programs) + : REVOKE ( + (revoke_system_privilege | revoke_object_privileges) container_clause? + | revoke_roles_from_programs + ) ; revoke_system_privilege @@ -2450,19 +2481,22 @@ revokee_clause ; revoke_object_privileges - : (object_privilege | ALL PRIVILEGES?) (',' (object_privilege | ALL PRIVILEGES?))* on_object_clause - FROM revokee_clause (CASCADE CONSTRAINTS | FORCE)? + : (object_privilege | ALL PRIVILEGES?) (',' (object_privilege | ALL PRIVILEGES?))* on_object_clause FROM revokee_clause ( + CASCADE CONSTRAINTS + | FORCE + )? ; on_object_clause - : ON ( (schema_name '.')? o=id_expression - | USER id_expression (',' id_expression)* - | DIRECTORY directory_name - | EDITION edition_name - | MINING MODEL (schema_name '.')? mmn=id_expression - | JAVA (SOURCE | RESOURCE) (schema_name '.')? o2=id_expression - | SQL TRANSLATION PROFILE (schema_name '.')? p=id_expression - ) + : ON ( + (schema_name '.')? o = id_expression + | USER id_expression (',' id_expression)* + | DIRECTORY directory_name + | EDITION edition_name + | MINING MODEL (schema_name '.')? mmn = id_expression + | JAVA (SOURCE | RESOURCE) (schema_name '.')? o2 = id_expression + | SQL TRANSLATION PROFILE (schema_name '.')? p = id_expression + ) ; revoke_roles_from_programs @@ -2474,15 +2508,16 @@ program_unit ; create_dimension - : CREATE DIMENSION identifier level_clause+ (hierarchy_clause | attribute_clause | extended_attribute_clause)+ + : CREATE DIMENSION identifier level_clause+ ( + hierarchy_clause + | attribute_clause + | extended_attribute_clause + )+ ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-DIRECTORY.html create_directory - : CREATE (OR REPLACE)? DIRECTORY directory_name - (SHARING '=' (METADATA | NONE))? - AS directory_path - + : CREATE (OR REPLACE)? DIRECTORY directory_name (SHARING '=' (METADATA | NONE))? AS directory_path ; directory_name @@ -2495,23 +2530,23 @@ directory_path // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-INMEMORY-JOIN-GROUP.html create_inmemory_join_group - : CREATE INMEMORY JOIN GROUP (schema_name '.')? jg=id_expression - '(' (schema_name '.')? t=id_expression '(' c=id_expression ')' (',' (schema_name '.')? t=id_expression '(' c=id_expression ')')+ ')' + : CREATE INMEMORY JOIN GROUP (schema_name '.')? jg = id_expression '(' (schema_name '.')? t = id_expression '(' c = id_expression ')' ( + ',' (schema_name '.')? t = id_expression '(' c = id_expression ')' + )+ ')' ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-HIERARCHY.html drop_hierarchy - : DROP HIERARCHY (schema_name '.')? hn=id_expression + : DROP HIERARCHY (schema_name '.')? hn = id_expression ; // https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/alter_library.htm#LNPLS99946 // https://docs.oracle.com/database/121/LNPLS/alter_library.htm#LNPLS99946 alter_library - : ALTER LIBRARY library_name - ( COMPILE library_debug? compiler_parameters_clause* (REUSE SETTINGS)? - | library_editionable - ) - + : ALTER LIBRARY library_name ( + COMPILE library_debug? compiler_parameters_clause* (REUSE SETTINGS)? + | library_editionable + ) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-JAVA.html @@ -2525,16 +2560,19 @@ drop_library // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-JAVA.html create_java - : CREATE (OR REPLACE)? (AND (RESOLVE | COMPILE))? NOFORCE? - JAVA ( (SOURCE | RESOURCE) NAMED (schema_name '.')? pn=id_expression - | CLASS (SCHEMA id_expression)? - ) - (SHARING '=' (METADATA | NONE))? - invoker_rights_clause? - (RESOLVER '(' ('(' CHAR_STRING ','? (sn=id_expression | '-') ')')+ ')')? - ( USING (BFILE '(' d=id_expression ',' filename ')' | (CLOB | BLOB | BFILE) subquery | CHAR_STRING) - | AS CHAR_STRING + : CREATE (OR REPLACE)? (AND (RESOLVE | COMPILE))? NOFORCE? JAVA ( + (SOURCE | RESOURCE) NAMED (schema_name '.')? pn = id_expression + | CLASS (SCHEMA id_expression)? + ) (SHARING '=' (METADATA | NONE))? invoker_rights_clause? ( + RESOLVER '(' ('(' CHAR_STRING ','? (sn = id_expression | '-') ')')+ ')' + )? ( + USING ( + BFILE '(' d = id_expression ',' filename ')' + | (CLOB | BLOB | BFILE) subquery + | CHAR_STRING ) + | AS CHAR_STRING + ) ; create_library @@ -2542,8 +2580,9 @@ create_library ; plsql_library_source - : library_name (IS | AS) quoted_string (IN directory_name)? - (AGENT quoted_string)? (CREDENTIAL credential_name)? + : library_name (IS | AS) quoted_string (IN directory_name)? (AGENT quoted_string)? ( + CREDENTIAL credential_name + )? ; credential_name @@ -2558,7 +2597,6 @@ library_debug : {this.isVersion12()}? DEBUG ; - compiler_parameters_clause : parameter_name EQUALS_OP parameter_value ; @@ -2573,16 +2611,26 @@ library_name ; alter_dimension - : ALTER DIMENSION identifier - ( (ADD (level_clause | hierarchy_clause | attribute_clause | extended_attribute_clause))+ - | (DROP (LEVEL identifier (RESTRICT | CASCADE)? | HIERARCHY identifier | ATTRIBUTE identifier (LEVEL identifier (COLUMN column_name (',' COLUMN column_name)*)?)? ))+ - | COMPILE + : ALTER DIMENSION identifier ( + (ADD (level_clause | hierarchy_clause | attribute_clause | extended_attribute_clause))+ + | ( + DROP ( + LEVEL identifier (RESTRICT | CASCADE)? + | HIERARCHY identifier + | ATTRIBUTE identifier ( + LEVEL identifier (COLUMN column_name (',' COLUMN column_name)*)? + )? + ) + )+ + | COMPILE ) ; level_clause - : LEVEL identifier IS (table_name '.' column_name | '(' table_name '.' column_name (',' table_name '.' column_name)* ')') - (SKIP_ WHEN NULL_)? + : LEVEL identifier IS ( + table_name '.' column_name + | '(' table_name '.' column_name (',' table_name '.' column_name)* ')' + ) (SKIP_ WHEN NULL_)? ; hierarchy_clause @@ -2598,7 +2646,7 @@ attribute_clause ; extended_attribute_clause - : ATTRIBUTE identifier (LEVEL identifier DETERMINES column_one_or_more_sub_clause )+ + : ATTRIBUTE identifier (LEVEL identifier DETERMINES column_one_or_more_sub_clause)+ ; column_one_or_more_sub_clause @@ -2609,18 +2657,18 @@ column_one_or_more_sub_clause // https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4004.htm#SQLRF01104 // https://docs.oracle.com/database/121/SQLRF/statements_4004.htm#SQLRF01104 alter_view - : ALTER VIEW tableview_name - ( ADD out_of_line_constraint - | MODIFY CONSTRAINT constraint_name (RELY | NORELY) - | DROP ( CONSTRAINT constraint_name - | PRIMARY KEY - | UNIQUE '(' column_name (',' column_name)* ')' - ) - | COMPILE - | READ (ONLY | WRITE) - | alter_view_editionable? - ) - + : ALTER VIEW tableview_name ( + ADD out_of_line_constraint + | MODIFY CONSTRAINT constraint_name (RELY | NORELY) + | DROP ( + CONSTRAINT constraint_name + | PRIMARY KEY + | UNIQUE '(' column_name (',' column_name)* ')' + ) + | COMPILE + | READ (ONLY | WRITE) + | alter_view_editionable? + ) ; alter_view_editionable @@ -2629,13 +2677,10 @@ alter_view_editionable // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-VIEW.html create_view - : CREATE (OR REPLACE)? (NO? FORCE)? editioning_clause? VIEW (schema_name '.')? v=id_expression - (SHARING '=' (METADATA | EXTENDED? DATA | NONE))? - view_options? - (DEFAULT COLLATION cn=id_expression)? - (BEQUEATH (CURRENT_USER | DEFINER))? - AS select_only_statement subquery_restriction_clause? - (CONTAINER_MAP | CONTAINERS_DEFAULT)? + : CREATE (OR REPLACE)? (NO? FORCE)? editioning_clause? VIEW (schema_name '.')? v = id_expression ( + SHARING '=' (METADATA | EXTENDED? DATA | NONE) + )? view_options? (DEFAULT COLLATION cn = id_expression)? (BEQUEATH (CURRENT_USER | DEFINER))? AS select_only_statement subquery_restriction_clause + ? (CONTAINER_MAP | CONTAINERS_DEFAULT)? ; editioning_clause @@ -2651,26 +2696,24 @@ view_options ; view_alias_constraint - : '(' ( ','? (table_alias inline_constraint* | out_of_line_constraint) )+ ')' + : '(' (','? (table_alias inline_constraint* | out_of_line_constraint))+ ')' ; object_view_clause - : OF (schema_name '.')? tn=id_expression - ( WITH OBJECT (IDENTIFIER | ID) (DEFAULT | '(' REGULAR_ID (',' REGULAR_ID)* ')') - | UNDER (schema_name '.')? sv=id_expression - ) - ('(' (','? (out_of_line_constraint | REGULAR_ID inline_constraint))+ ')')* + : OF (schema_name '.')? tn = id_expression ( + WITH OBJECT (IDENTIFIER | ID) (DEFAULT | '(' REGULAR_ID (',' REGULAR_ID)* ')') + | UNDER (schema_name '.')? sv = id_expression + ) ('(' (','? (out_of_line_constraint | REGULAR_ID inline_constraint))+ ')')* ; inline_constraint - : (CONSTRAINT constraint_name)? - ( NOT? NULL_ + : (CONSTRAINT constraint_name)? ( + NOT? NULL_ | UNIQUE | PRIMARY KEY | references_clause | check_constraint - ) - constraint_state? + ) constraint_state? ; inline_ref_constraint @@ -2680,41 +2723,44 @@ inline_ref_constraint ; out_of_line_ref_constraint - : SCOPE FOR '(' ref_col_or_attr=regular_id ')' IS tableview_name - | REF '(' ref_col_or_attr=regular_id ')' WITH ROWID - | (CONSTRAINT constraint_name)? FOREIGN KEY '(' ( ','? ref_col_or_attr=regular_id)+ ')' references_clause constraint_state? + : SCOPE FOR '(' ref_col_or_attr = regular_id ')' IS tableview_name + | REF '(' ref_col_or_attr = regular_id ')' WITH ROWID + | (CONSTRAINT constraint_name)? FOREIGN KEY '(' (','? ref_col_or_attr = regular_id)+ ')' references_clause constraint_state? ; out_of_line_constraint - : ( (CONSTRAINT constraint_name)? - ( UNIQUE '(' column_name (',' column_name)* ')' - | PRIMARY KEY '(' column_name (',' column_name)* ')' - | foreign_key_clause - | CHECK '(' condition ')' - ) - ) - constraint_state? + : ( + (CONSTRAINT constraint_name)? ( + UNIQUE '(' column_name (',' column_name)* ')' + | PRIMARY KEY '(' column_name (',' column_name)* ')' + | foreign_key_clause + | CHECK '(' condition ')' + ) + ) constraint_state? ; constraint_state - : ( NOT? DEFERRABLE - | INITIALLY (IMMEDIATE | DEFERRED) - | (RELY | NORELY) - | (ENABLE | DISABLE) - | (VALIDATE | NOVALIDATE) - | using_index_clause - )+ + : ( + NOT? DEFERRABLE + | INITIALLY (IMMEDIATE | DEFERRED) + | (RELY | NORELY) + | (ENABLE | DISABLE) + | (VALIDATE | NOVALIDATE) + | using_index_clause + )+ ; xmltype_view_clause - : OF XMLTYPE xml_schema_spec? WITH OBJECT (IDENTIFIER | ID) (DEFAULT | '(' expression (',' expression)* ')') + : OF XMLTYPE xml_schema_spec? WITH OBJECT (IDENTIFIER | ID) ( + DEFAULT + | '(' expression (',' expression)* ')' + ) ; xml_schema_spec - : (XMLSCHEMA xml_schema_url)? ELEMENT (element | xml_schema_url '#' element) - (STORE ALL VARRAYS AS (LOBS | TABLES))? - (allow_or_disallow NONSCHEMA)? - (allow_or_disallow ANYSCHEMA)? + : (XMLSCHEMA xml_schema_url)? ELEMENT (element | xml_schema_url '#' element) ( + STORE ALL VARRAYS AS (LOBS | TABLES) + )? (allow_or_disallow NONSCHEMA)? (allow_or_disallow ANYSCHEMA)? ; xml_schema_url @@ -2726,23 +2772,22 @@ element ; alter_tablespace - : ALTER TABLESPACE tablespace - ( DEFAULT table_compression? storage_clause? - | MINIMUM EXTENT size_clause - | RESIZE size_clause - | COALESCE - | SHRINK SPACE_KEYWORD (KEEP size_clause)? - | RENAME TO new_tablespace_name - | begin_or_end BACKUP - | datafile_tempfile_clauses - | tablespace_logging_clauses - | tablespace_group_clause - | tablespace_state_clauses - | autoextend_clause - | flashback_mode_clause - | tablespace_retention_clause - ) - + : ALTER TABLESPACE tablespace ( + DEFAULT table_compression? storage_clause? + | MINIMUM EXTENT size_clause + | RESIZE size_clause + | COALESCE + | SHRINK SPACE_KEYWORD (KEEP size_clause)? + | RENAME TO new_tablespace_name + | begin_or_end BACKUP + | datafile_tempfile_clauses + | tablespace_logging_clauses + | tablespace_group_clause + | tablespace_state_clauses + | autoextend_clause + | flashback_mode_clause + | tablespace_retention_clause + ) ; datafile_tempfile_clauses @@ -2783,16 +2828,16 @@ new_tablespace_name ; create_tablespace - : CREATE (BIGFILE | SMALLFILE)? - ( permanent_tablespace_clause + : CREATE (BIGFILE | SMALLFILE)? ( + permanent_tablespace_clause | temporary_tablespace_clause | undo_tablespace_clause - ) + ) ; permanent_tablespace_clause - : TABLESPACE id_expression datafile_specification? - ( MINIMUM EXTENT size_clause + : TABLESPACE id_expression datafile_specification? ( + MINIMUM EXTENT size_clause | BLOCKSIZE size_clause | logging_clause | FORCE LOGGING @@ -2802,24 +2847,21 @@ permanent_tablespace_clause | extent_management_clause | segment_management_clause | flashback_mode_clause - )* + )* ; tablespace_encryption_spec - : USING encrypt_algorithm=CHAR_STRING + : USING encrypt_algorithm = CHAR_STRING ; logging_clause : LOGGING - | NOLOGGING - | FILESYSTEM_LIKE_LOGGING + | NOLOGGING + | FILESYSTEM_LIKE_LOGGING ; extent_management_clause - : EXTENT MANAGEMENT LOCAL - ( AUTOALLOCATE - | UNIFORM (SIZE size_clause)? - )? + : EXTENT MANAGEMENT LOCAL (AUTOALLOCATE | UNIFORM (SIZE size_clause)?)? ; segment_management_clause @@ -2827,15 +2869,11 @@ segment_management_clause ; temporary_tablespace_clause - : TEMPORARY TABLESPACE tablespace_name=id_expression - tempfile_specification? - tablespace_group_clause? extent_management_clause? + : TEMPORARY TABLESPACE tablespace_name = id_expression tempfile_specification? tablespace_group_clause? extent_management_clause? ; undo_tablespace_clause - : UNDO TABLESPACE tablespace_name=id_expression - datafile_specification? - extent_management_clause? tablespace_retention_clause? + : UNDO TABLESPACE tablespace_name = id_expression datafile_specification? extent_management_clause? tablespace_retention_clause? ; tablespace_retention_clause @@ -2844,8 +2882,9 @@ tablespace_retention_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-TABLESPACE-SET.html create_tablespace_set - : CREATE TABLESPACE SET tss=id_expression (IN SHARDSPACE ss=id_expression)? - (USING TEMPLATE '(' (DATAFILE file_specification (',' file_specification)*)? permanent_tablespace_attrs+ ')')? + : CREATE TABLESPACE SET tss = id_expression (IN SHARDSPACE ss = id_expression)? ( + USING TEMPLATE '(' (DATAFILE file_specification (',' file_specification)*)? permanent_tablespace_attrs+ ')' + )? ; permanent_tablespace_attrs @@ -2872,9 +2911,7 @@ default_tablespace_params ; default_table_compression - : TABLE ( COMPRESS FOR (OLTP | QUERY low_high | ARCHIVE low_high) - | NOCOMPRESS - ) + : TABLE (COMPRESS FOR (OLTP | QUERY low_high | ARCHIVE low_high) | NOCOMPRESS) ; low_high @@ -2887,20 +2924,23 @@ default_index_compression ; inmmemory_clause - : INMEMORY inmemory_attributes? (TEXT (column_name (',' column_name)* | column_name USING policy_name (',' column_name USING policy_name)*))? + : INMEMORY inmemory_attributes? ( + TEXT ( + column_name (',' column_name)* + | column_name USING policy_name (',' column_name USING policy_name)* + ) + )? | NO INMEMORY ; // asm_filename is just a charater string. Would need to parse the string // to find diskgroup... datafile_specification - : DATAFILE - (','? datafile_tempfile_spec) + : DATAFILE (','? datafile_tempfile_spec) ; tempfile_specification - : TEMPFILE - (','? datafile_tempfile_spec) + : TEMPFILE (','? datafile_tempfile_spec) ; datafile_tempfile_spec @@ -2908,16 +2948,11 @@ datafile_tempfile_spec ; redo_log_file_spec - : ( filename - | '(' filename (',' filename)* ')' - ) - (SIZE size_clause)? - (BLOCKSIZE size_clause)? - REUSE? + : (filename | '(' filename (',' filename)* ')') (SIZE size_clause)? (BLOCKSIZE size_clause)? REUSE? ; autoextend_clause - : AUTOEXTEND (OFF | ON (NEXT size_clause)? maxsize_clause? ) + : AUTOEXTEND (OFF | ON (NEXT size_clause)? maxsize_clause?) ; maxsize_clause @@ -2930,49 +2965,47 @@ build_clause parallel_clause : NOPARALLEL - | PARALLEL parallel_count=UNSIGNED_INTEGER? + | PARALLEL parallel_count = UNSIGNED_INTEGER? ; alter_materialized_view - : ALTER MATERIALIZED VIEW tableview_name - ( physical_attributes_clause - | modify_mv_column_clause - | table_compression - | lob_storage_clause (',' lob_storage_clause)* - | modify_lob_storage_clause (',' modify_lob_storage_clause)* -//TODO | alter_table_partitioning - | parallel_clause - | logging_clause - | allocate_extent_clause - | deallocate_unused_clause - | shrink_clause - | (cache_or_nocache) - )? - alter_iot_clauses? - (USING INDEX physical_attributes_clause)? - alter_mv_option1? - ( enable_or_disable QUERY REWRITE - | COMPILE - | CONSIDER FRESH - )? + : ALTER MATERIALIZED VIEW tableview_name ( + physical_attributes_clause + | modify_mv_column_clause + | table_compression + | lob_storage_clause (',' lob_storage_clause)* + | modify_lob_storage_clause (',' modify_lob_storage_clause)* + //TODO | alter_table_partitioning + | parallel_clause + | logging_clause + | allocate_extent_clause + | deallocate_unused_clause + | shrink_clause + | (cache_or_nocache) + )? alter_iot_clauses? (USING INDEX physical_attributes_clause)? alter_mv_option1? ( + enable_or_disable QUERY REWRITE + | COMPILE + | CONSIDER FRESH + )? ; alter_mv_option1 : alter_mv_refresh -//TODO | MODIFY scoped_table_ref_constraint + //TODO | MODIFY scoped_table_ref_constraint ; alter_mv_refresh - : REFRESH ( FAST - | COMPLETE - | FORCE - | ON (DEMAND | COMMIT) - | START WITH expression - | NEXT expression - | WITH PRIMARY KEY - | USING DEFAULT? MASTER ROLLBACK SEGMENT rollback_segment? - | USING (ENFORCED | TRUSTED) CONSTRAINTS - )+ + : REFRESH ( + FAST + | COMPLETE + | FORCE + | ON (DEMAND | COMMIT) + | START WITH expression + | NEXT expression + | WITH PRIMARY KEY + | USING DEFAULT? MASTER ROLLBACK SEGMENT rollback_segment? + | USING (ENFORCED | TRUSTED) CONSTRAINTS + )+ ; rollback_segment @@ -2984,20 +3017,19 @@ modify_mv_column_clause ; alter_materialized_view_log - : ALTER MATERIALIZED VIEW LOG FORCE? ON tableview_name - ( physical_attributes_clause - | add_mv_log_column_clause -//TODO | alter_table_partitioning - | parallel_clause - | logging_clause - | allocate_extent_clause - | shrink_clause - | move_mv_log_clause - | cache_or_nocache - )? - mv_log_augmentation? mv_log_purge_clause? - + : ALTER MATERIALIZED VIEW LOG FORCE? ON tableview_name ( + physical_attributes_clause + | add_mv_log_column_clause + //TODO | alter_table_partitioning + | parallel_clause + | logging_clause + | allocate_extent_clause + | shrink_clause + | move_mv_log_clause + | cache_or_nocache + )? mv_log_augmentation? mv_log_purge_clause? ; + add_mv_log_column_clause : ADD '(' column_name ')' ; @@ -3007,16 +3039,10 @@ move_mv_log_clause ; mv_log_augmentation - : ADD ( ( OBJECT ID - | PRIMARY KEY - | ROWID - | SEQUENCE - ) - ('(' column_name (',' column_name)* ')')? - - | '(' column_name (',' column_name)* ')' - ) - new_values_clause? + : ADD ( + (OBJECT ID | PRIMARY KEY | ROWID | SEQUENCE) ('(' column_name (',' column_name)* ')')? + | '(' column_name (',' column_name)* ')' + ) new_values_clause? ; // Should bound this to just date/time expr @@ -3039,51 +3065,49 @@ including_or_excluding | EXCLUDING ; - create_materialized_view_log - : CREATE MATERIALIZED VIEW LOG ON tableview_name - ( ( physical_attributes_clause - | TABLESPACE tablespace_name=id_expression - | logging_clause - | (CACHE | NOCACHE) - )+ - )? - parallel_clause? - // table_partitioning_clauses TODO - ( WITH - ( ','? - ( OBJECT ID - | PRIMARY KEY - | ROWID - | SEQUENCE - | COMMIT SCN - ) - )* - ('(' ( ','? regular_id )+ ')' new_values_clause? )? - mv_log_purge_clause? - )* + : CREATE MATERIALIZED VIEW LOG ON tableview_name ( + ( + physical_attributes_clause + | TABLESPACE tablespace_name = id_expression + | logging_clause + | (CACHE | NOCACHE) + )+ + )? parallel_clause? + // table_partitioning_clauses TODO + ( + WITH (','? ( OBJECT ID | PRIMARY KEY | ROWID | SEQUENCE | COMMIT SCN))* ( + '(' ( ','? regular_id)+ ')' new_values_clause? + )? mv_log_purge_clause? + )* ; new_values_clause - : (INCLUDING | EXCLUDING ) NEW VALUES + : (INCLUDING | EXCLUDING) NEW VALUES ; mv_log_purge_clause - : PURGE - ( IMMEDIATE (SYNCHRONOUS | ASYNCHRONOUS)? - // |START WITH CLAUSES TODO - ) + : PURGE ( + IMMEDIATE (SYNCHRONOUS | ASYNCHRONOUS)? + // |START WITH CLAUSES TODO + ) ; create_materialized_zonemap - : CREATE MATERIALIZED ZONEMAP zonemap_name (LEFT_PAREN column_list RIGHT_PAREN)? zonemap_attributes? zonemap_refresh_clause? - ((ENABLE | DISABLE) PRUNING)? (create_zonemap_on_table | create_zonemap_as_subquery) + : CREATE MATERIALIZED ZONEMAP zonemap_name (LEFT_PAREN column_list RIGHT_PAREN)? zonemap_attributes? zonemap_refresh_clause? ( + (ENABLE | DISABLE) PRUNING + )? (create_zonemap_on_table | create_zonemap_as_subquery) ; alter_materialized_zonemap - : ALTER MATERIALIZED ZONEMAP zonemap_name - ( zonemap_attributes | zonemap_refresh_clause| (ENABLE | DISABLE) PRUNING | COMPILE | REBUILD | UNUSABLE - ) + : ALTER MATERIALIZED ZONEMAP zonemap_name ( + zonemap_attributes + | zonemap_refresh_clause + | (ENABLE | DISABLE) PRUNING + | COMPILE + | REBUILD + | UNUSABLE + ) ; drop_materialized_zonemap @@ -3091,11 +3115,19 @@ drop_materialized_zonemap ; zonemap_refresh_clause - : REFRESH (FAST | COMPILE | FORCE)? (ON (DEMAND | COMMIT | LOAD | DATA MOVEMENT | LOAD DATA MOVEMENT))? + : REFRESH (FAST | COMPILE | FORCE)? ( + ON (DEMAND | COMMIT | LOAD | DATA MOVEMENT | LOAD DATA MOVEMENT) + )? ; zonemap_attributes - : (PCTFREE numeric | PCTUSED numeric | SCALE numeric | TABLESPACE tablespace | (CACHE | NOCACHE))+ + : ( + PCTFREE numeric + | PCTUSED numeric + | SCALE numeric + | TABLESPACE tablespace + | (CACHE | NOCACHE) + )+ ; zonemap_name @@ -3127,13 +3159,13 @@ drop_operator ; create_operator - : CREATE (OR REPLACE)? OPERATOR operator_name BINDING binding_clause (COMMA binding_clause)* - (SHARING '=' (METADATA | NONE))? + : CREATE (OR REPLACE)? OPERATOR operator_name BINDING binding_clause (COMMA binding_clause)* ( + SHARING '=' (METADATA | NONE) + )? ; binding_clause - : LEFT_PAREN datatype (COMMA datatype)* RIGHT_PAREN - RETURN LEFT_PAREN? datatype RIGHT_PAREN? implementation_clause? using_function_clause + : LEFT_PAREN datatype (COMMA datatype)* RIGHT_PAREN RETURN LEFT_PAREN? datatype RIGHT_PAREN? implementation_clause? using_function_clause ; add_binding_clause @@ -3154,8 +3186,9 @@ primary_operator_item ; operator_context_clause - : WITH INDEX CONTEXT COMMA SCAN CONTEXT implementation_type_name (COMPUTE ANCILLARY DATA)? - (WITH COLUMN CONTEXT)? + : WITH INDEX CONTEXT COMMA SCAN CONTEXT implementation_type_name (COMPUTE ANCILLARY DATA)? ( + WITH COLUMN CONTEXT + )? ; using_function_clause @@ -3167,24 +3200,21 @@ drop_binding_clause ; create_materialized_view - : CREATE MATERIALIZED VIEW tableview_name - (OF type_name )? - ( '(' (scoped_table_ref_constraint | mv_column_alias) (',' (scoped_table_ref_constraint | mv_column_alias))* ')' )? - ( ON PREBUILT TABLE ( (WITH | WITHOUT) REDUCED PRECISION)? - | physical_properties? (CACHE | NOCACHE)? parallel_clause? build_clause? - ) - ( USING INDEX ( (physical_attributes_clause | TABLESPACE mv_tablespace=id_expression)+ )* + : CREATE MATERIALIZED VIEW tableview_name (OF type_name)? ( + '(' (scoped_table_ref_constraint | mv_column_alias) ( + ',' (scoped_table_ref_constraint | mv_column_alias) + )* ')' + )? ( + ON PREBUILT TABLE ( (WITH | WITHOUT) REDUCED PRECISION)? + | physical_properties? (CACHE | NOCACHE)? parallel_clause? build_clause? + ) ( + USING INDEX ((physical_attributes_clause | TABLESPACE mv_tablespace = id_expression)+)* | USING NO INDEX - )? - create_mv_refresh? - (FOR UPDATE)? - ( (DISABLE | ENABLE) QUERY REWRITE )? - AS select_only_statement - + )? create_mv_refresh? (FOR UPDATE)? ((DISABLE | ENABLE) QUERY REWRITE)? AS select_only_statement ; scoped_table_ref_constraint - : SCOPE FOR '(' ref_column_or_attribute=identifier ')' IS (schema_name '.')? scope_table_name_or_c_alias=identifier + : SCOPE FOR '(' ref_column_or_attribute = identifier ')' IS (schema_name '.')? scope_table_name_or_c_alias = identifier ; mv_column_alias @@ -3192,19 +3222,20 @@ mv_column_alias ; create_mv_refresh - : ( NEVER REFRESH - | REFRESH - ( (FAST | COMPLETE | FORCE) - | ON (DEMAND | COMMIT) - | (START WITH | NEXT) //date goes here TODO - | WITH (PRIMARY KEY | ROWID) - | USING - ( DEFAULT (MASTER | LOCAL)? ROLLBACK SEGMENT - | (MASTER | LOCAL)? ROLLBACK SEGMENT rb_segment=REGULAR_ID - ) - | USING (ENFORCED | TRUSTED) CONSTRAINTS - )+ - ) + : ( + NEVER REFRESH + | REFRESH ( + (FAST | COMPLETE | FORCE) + | ON (DEMAND | COMMIT) + | (START WITH | NEXT) //date goes here TODO + | WITH (PRIMARY KEY | ROWID) + | USING ( + DEFAULT (MASTER | LOCAL)? ROLLBACK SEGMENT + | (MASTER | LOCAL)? ROLLBACK SEGMENT rb_segment = REGULAR_ID + ) + | USING (ENFORCED | TRUSTED) CONSTRAINTS + )+ + ) ; drop_materialized_view @@ -3212,11 +3243,10 @@ drop_materialized_view ; create_context - : CREATE (OR REPLACE)? CONTEXT oracle_namespace USING (schema_object_name '.')? package_name - (INITIALIZED (EXTERNALLY | GLOBALLY) - | ACCESSED GLOBALLY - )? - + : CREATE (OR REPLACE)? CONTEXT oracle_namespace USING (schema_object_name '.')? package_name ( + INITIALIZED (EXTERNALLY | GLOBALLY) + | ACCESSED GLOBALLY + )? ; oracle_namespace @@ -3225,49 +3255,46 @@ oracle_namespace //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_5001.htm#SQLRF01201 create_cluster - : CREATE CLUSTER cluster_name '(' column_name datatype SORT? (',' column_name datatype SORT?)* ')' - ( physical_attributes_clause - | SIZE size_clause - | TABLESPACE tablespace - | INDEX - | (SINGLE TABLE)? HASHKEYS UNSIGNED_INTEGER (HASH IS expression)? - )* - parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? - (CACHE | NOCACHE)? - + : CREATE CLUSTER cluster_name '(' column_name datatype SORT? (',' column_name datatype SORT?)* ')' ( + physical_attributes_clause + | SIZE size_clause + | TABLESPACE tablespace + | INDEX + | (SINGLE TABLE)? HASHKEYS UNSIGNED_INTEGER (HASH IS expression)? + )* parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? (CACHE | NOCACHE)? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-PROFILE.html create_profile - : CREATE MANDATORY? PROFILE p=id_expression - LIMIT (resource_parameters | password_parameters)+ - container_clause? + : CREATE MANDATORY? PROFILE p = id_expression LIMIT (resource_parameters | password_parameters)+ container_clause? ; resource_parameters - : ( SESSIONS_PER_USER - | CPU_PER_SESSION - | CPU_PER_CALL - | CONNECT_TIME - | IDLE_TIME - | LOGICAL_READS_PER_SESSION - | LOGICAL_READS_PER_CALL - | COMPOSITE_LIMIT - ) (UNSIGNED_INTEGER | UNLIMITED | DEFAULT) - | PRIVATE_SGA (size_clause | UNLIMITED | DEFAULT) + : ( + SESSIONS_PER_USER + | CPU_PER_SESSION + | CPU_PER_CALL + | CONNECT_TIME + | IDLE_TIME + | LOGICAL_READS_PER_SESSION + | LOGICAL_READS_PER_CALL + | COMPOSITE_LIMIT + ) (UNSIGNED_INTEGER | UNLIMITED | DEFAULT) + | PRIVATE_SGA (size_clause | UNLIMITED | DEFAULT) ; password_parameters - : ( FAILED_LOGIN_ATTEMPTS - | PASSWORD_LIFE_TIME - | PASSWORD_REUSE_TIME - | PASSWORD_REUSE_MAX - | PASSWORD_LOCK_TIME - | PASSWORD_GRACE_TIME - | INACTIVE_ACCOUNT_TIME - ) (expression | UNLIMITED | DEFAULT) - | PASSWORD_VERIFY_FUNCTION (function_name | NULL_ | DEFAULT) - | PASSWORD_ROLLOVER_TIME (expression | DEFAULT) + : ( + FAILED_LOGIN_ATTEMPTS + | PASSWORD_LIFE_TIME + | PASSWORD_REUSE_TIME + | PASSWORD_REUSE_MAX + | PASSWORD_LOCK_TIME + | PASSWORD_GRACE_TIME + | INACTIVE_ACCOUNT_TIME + ) (expression | UNLIMITED | DEFAULT) + | PASSWORD_VERIFY_FUNCTION (function_name | NULL_ | DEFAULT) + | PASSWORD_ROLLOVER_TIME (expression | DEFAULT) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-LOCKDOWN-PROFILE.html @@ -3276,26 +3303,25 @@ create_lockdown_profile ; static_base_profile - : FROM bp=id_expression + : FROM bp = id_expression ; dynamic_base_profile - : INCLUDING bp=id_expression + : INCLUDING bp = id_expression ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-OUTLINE.html create_outline - : CREATE (OR REPLACE)? (PUBLIC | PRIVATE)? OUTLINE (o=id_expression)? - (FROM (PUBLIC | PRIVATE)? so=id_expression)? - (FOR CATEGORY c=id_expression)? - (ON statement)? + : CREATE (OR REPLACE)? (PUBLIC | PRIVATE)? OUTLINE (o = id_expression)? ( + FROM (PUBLIC | PRIVATE)? so = id_expression + )? (FOR CATEGORY c = id_expression)? (ON statement)? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-RESTORE-POINT.html create_restore_point - : CREATE CLEAN? RESTORE POINT rp=id_expression (FOR PLUGGABLE DATABASE pdb=id_expression)? - (AS OF (TIMESTAMP | SCN) expression)? - (PRESERVE | GUARANTEE FLASHBACK DATABASE)? + : CREATE CLEAN? RESTORE POINT rp = id_expression (FOR PLUGGABLE DATABASE pdb = id_expression)? ( + AS OF (TIMESTAMP | SCN) expression + )? (PRESERVE | GUARANTEE FLASHBACK DATABASE)? ; create_role @@ -3303,31 +3329,23 @@ create_role ; create_table - : CREATE - ( (GLOBAL | PRIVATE) TEMPORARY - | SHARDED - | DUPLICATED - | IMMUTABLE? BLOCKCHAIN - | IMMUTABLE - )? - TABLE (schema_name '.')? table_name - (SHARING '=' (METADATA | EXTENDED? DATA | NONE))? - (relational_table | xmltype_table | object_table) - (MEMOPTIMIZE FOR READ)? - (MEMOPTIMIZE FOR WRITE)? - (PARENT tableview_name)? + : CREATE ( + (GLOBAL | PRIVATE) TEMPORARY + | SHARDED + | DUPLICATED + | IMMUTABLE? BLOCKCHAIN + | IMMUTABLE + )? TABLE (schema_name '.')? table_name (SHARING '=' (METADATA | EXTENDED? DATA | NONE))? ( + relational_table + | xmltype_table + | object_table + ) (MEMOPTIMIZE FOR READ)? (MEMOPTIMIZE FOR WRITE)? (PARENT tableview_name)? ; xmltype_table - : OF XMLTYPE ('(' object_properties ')')? - (XMLTYPE xmltype_storage)? - xmlschema_spec? - xmltype_virtual_columns? - (ON COMMIT (DELETE | PRESERVE) ROWS)? - oid_clause? - oid_index_clause? - physical_properties? - table_properties + : OF XMLTYPE ('(' object_properties ')')? (XMLTYPE xmltype_storage)? xmlschema_spec? xmltype_virtual_columns? ( + ON COMMIT (DELETE | PRESERVE) ROWS + )? oid_clause? oid_index_clause? physical_properties? table_properties ; xmltype_virtual_columns @@ -3339,27 +3357,26 @@ xmltype_column_properties ; xmltype_storage - : STORE AS ( OBJECT RELATIONAL - | (SECUREFILE | BASICFILE)? (CLOB | BINARY XML) (lob_segname ('(' lob_parameters ')')? | '(' lob_parameters ')')? - ) + : STORE AS ( + OBJECT RELATIONAL + | (SECUREFILE | BASICFILE)? (CLOB | BINARY XML) ( + lob_segname ('(' lob_parameters ')')? + | '(' lob_parameters ')' + )? + ) | STORE VARRAYS AS (LOBS | TABLES) ; xmlschema_spec - : (XMLSCHEMA DELIMITED_ID)? ELEMENT DELIMITED_ID - (allow_or_disallow NONSCHEMA)? - (allow_or_disallow ANYSCHEMA)? + : (XMLSCHEMA DELIMITED_ID)? ELEMENT DELIMITED_ID (allow_or_disallow NONSCHEMA)? ( + allow_or_disallow ANYSCHEMA + )? ; object_table - : OF (schema_name '.')? object_type - object_table_substitution? - ('(' object_properties (',' object_properties)* ')')? - (ON COMMIT (DELETE | PRESERVE) ROWS)? - oid_clause? - oid_index_clause? - physical_properties? - table_properties + : OF (schema_name '.')? object_type object_table_substitution? ( + '(' object_properties (',' object_properties)* ')' + )? (ON COMMIT (DELETE | PRESERVE) ROWS)? oid_clause? oid_index_clause? physical_properties? table_properties ; object_type @@ -3375,7 +3392,10 @@ oid_clause ; object_properties - : (column_name | attribute_name) (DEFAULT expression)? (inline_constraint (',' inline_constraint)* | inline_ref_constraint)? + : (column_name | attribute_name) (DEFAULT expression)? ( + inline_constraint (',' inline_constraint)* + | inline_ref_constraint + )? | out_of_line_constraint | out_of_line_ref_constraint | supplemental_logging_props @@ -3386,14 +3406,9 @@ object_table_substitution ; relational_table - : ('(' relational_property (',' relational_property)* ')')? - immutable_table_clauses - blockchain_table_clauses? - (DEFAULT COLLATION collation_name)? - (ON COMMIT (DROP | PRESERVE) DEFINITION)? - (ON COMMIT (DELETE | PRESERVE) ROWS)? - physical_properties? - table_properties + : ('(' relational_property (',' relational_property)* ')')? immutable_table_clauses blockchain_table_clauses? ( + DEFAULT COLLATION collation_name + )? (ON COMMIT (DROP | PRESERVE) DEFINITION)? (ON COMMIT (DELETE | PRESERVE) ROWS)? physical_properties? table_properties ; immutable_table_clauses @@ -3429,22 +3444,14 @@ collation_name ; table_properties - : column_properties? - read_only_clause? - indexing_clause? - table_partitioning_clauses? - attribute_clustering_clause? - (CACHE | NOCACHE)? - result_cache_clause? - parallel_clause? - (ROWDEPENDENCIES | NOROWDEPENDENCIES)? - enable_disable_clause* - row_movement_clause? - logical_replication_clause? - flashback_archive_clause? - physical_properties? - (ROW ARCHIVAL)? - (AS select_only_statement | FOR EXCHANGE WITH TABLE (schema_name '.')? table_name)? + : column_properties? read_only_clause? indexing_clause? table_partitioning_clauses? attribute_clustering_clause? ( + CACHE + | NOCACHE + )? result_cache_clause? parallel_clause? (ROWDEPENDENCIES | NOROWDEPENDENCIES)? enable_disable_clause* row_movement_clause? + logical_replication_clause? flashback_archive_clause? physical_properties? (ROW ARCHIVAL)? ( + AS select_only_statement + | FOR EXCHANGE WITH TABLE (schema_name '.')? table_name + )? ; read_only_clause @@ -3456,12 +3463,7 @@ indexing_clause ; attribute_clustering_clause - : CLUSTERING - clustering_join? - cluster_clause - (yes_no? ON LOAD)? - (yes_no? ON DATA MOVEMENT)? - zonemap_clause? + : CLUSTERING clustering_join? cluster_clause (yes_no? ON LOAD)? (yes_no? ON DATA MOVEMENT)? zonemap_clause? ; clustering_join @@ -3529,30 +3531,37 @@ table_partitioning_clauses ; range_partitions - : PARTITION BY RANGE '(' column_name (',' column_name)* ')' - (INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')' )? )? - '(' PARTITION partition_name? range_values_clause table_partition_description (',' PARTITION partition_name? range_values_clause table_partition_description)* ')' + : PARTITION BY RANGE '(' column_name (',' column_name)* ')' ( + INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')')? + )? '(' PARTITION partition_name? range_values_clause table_partition_description ( + ',' PARTITION partition_name? range_values_clause table_partition_description + )* ')' ; list_partitions - : PARTITION BY LIST '(' column_name ')' - '(' PARTITION partition_name? list_values_clause table_partition_description (',' PARTITION partition_name? list_values_clause table_partition_description )* ')' + : PARTITION BY LIST '(' column_name ')' '(' PARTITION partition_name? list_values_clause table_partition_description ( + ',' PARTITION partition_name? list_values_clause table_partition_description + )* ')' ; hash_partitions - : PARTITION BY HASH '(' column_name (',' column_name)* ')' - (individual_hash_partitions | hash_partitions_by_quantity) + : PARTITION BY HASH '(' column_name (',' column_name)* ')' ( + individual_hash_partitions + | hash_partitions_by_quantity + ) ; individual_hash_partitions - : '(' PARTITION partition_name? partitioning_storage_clause? (',' PARTITION partition_name? partitioning_storage_clause?)* ')' + : '(' PARTITION partition_name? partitioning_storage_clause? ( + ',' PARTITION partition_name? partitioning_storage_clause? + )* ')' ; hash_partitions_by_quantity - : PARTITIONS hash_partition_quantity - (STORE IN '(' tablespace (',' tablespace)* ')')? - (table_compression | key_compression)? - (OVERFLOW STORE IN '(' tablespace (',' tablespace)* ')' )? + : PARTITIONS hash_partition_quantity (STORE IN '(' tablespace (',' tablespace)* ')')? ( + table_compression + | key_compression + )? (OVERFLOW STORE IN '(' tablespace (',' tablespace)* ')')? ; hash_partition_quantity @@ -3560,27 +3569,33 @@ hash_partition_quantity ; composite_range_partitions - : PARTITION BY RANGE '(' column_name (',' column_name)* ')' - (INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')' )? )? - (subpartition_by_range | subpartition_by_list | subpartition_by_hash) - '(' range_partition_desc (',' range_partition_desc)* ')' + : PARTITION BY RANGE '(' column_name (',' column_name)* ')' ( + INTERVAL '(' expression ')' (STORE IN '(' tablespace (',' tablespace)* ')')? + )? (subpartition_by_range | subpartition_by_list | subpartition_by_hash) '(' range_partition_desc ( + ',' range_partition_desc + )* ')' ; composite_list_partitions - : PARTITION BY LIST '(' column_name ')' - (subpartition_by_range | subpartition_by_list | subpartition_by_hash) - '(' list_partition_desc (',' list_partition_desc)* ')' + : PARTITION BY LIST '(' column_name ')' ( + subpartition_by_range + | subpartition_by_list + | subpartition_by_hash + ) '(' list_partition_desc (',' list_partition_desc)* ')' ; composite_hash_partitions - : PARTITION BY HASH '(' (',' column_name)+ ')' - (subpartition_by_range | subpartition_by_list | subpartition_by_hash) - (individual_hash_partitions | hash_partitions_by_quantity) + : PARTITION BY HASH '(' (',' column_name)+ ')' ( + subpartition_by_range + | subpartition_by_list + | subpartition_by_hash + ) (individual_hash_partitions | hash_partitions_by_quantity) ; reference_partitioning - : PARTITION BY REFERENCE '(' regular_id ')' - ('(' reference_partition_desc (',' reference_partition_desc)* ')')? + : PARTITION BY REFERENCE '(' regular_id ')' ( + '(' reference_partition_desc (',' reference_partition_desc)* ')' + )? ; reference_partition_desc @@ -3588,44 +3603,49 @@ reference_partition_desc ; system_partitioning - : PARTITION BY SYSTEM - (PARTITIONS UNSIGNED_INTEGER | reference_partition_desc (',' reference_partition_desc)*)? + : PARTITION BY SYSTEM ( + PARTITIONS UNSIGNED_INTEGER + | reference_partition_desc (',' reference_partition_desc)* + )? ; range_partition_desc - : PARTITION partition_name? range_values_clause table_partition_description - ( ( '(' ( range_subpartition_desc (',' range_subpartition_desc)* + : PARTITION partition_name? range_values_clause table_partition_description ( + ( + '(' ( + range_subpartition_desc (',' range_subpartition_desc)* | list_subpartition_desc (',' list_subpartition_desc)* | individual_hash_subparts (',' individual_hash_subparts)* - ) - ')' - | hash_subparts_by_quantity - ) - )? + ) ')' + | hash_subparts_by_quantity + ) + )? ; list_partition_desc - : PARTITION partition_name? list_values_clause table_partition_description - ( ( '(' ( range_subpartition_desc (',' range_subpartition_desc)* + : PARTITION partition_name? list_values_clause table_partition_description ( + ( + '(' ( + range_subpartition_desc (',' range_subpartition_desc)* | list_subpartition_desc (',' list_subpartition_desc)* | individual_hash_subparts (',' individual_hash_subparts)* - ) - ')' - | hash_subparts_by_quantity - ) - )? + ) ')' + | hash_subparts_by_quantity + ) + )? ; subpartition_template - : SUBPARTITION TEMPLATE - ( ( '(' ( range_subpartition_desc (',' range_subpartition_desc)* + : SUBPARTITION TEMPLATE ( + ( + '(' ( + range_subpartition_desc (',' range_subpartition_desc)* | list_subpartition_desc (',' list_subpartition_desc)* | individual_hash_subparts (',' individual_hash_subparts)* - ) - ')' - | hash_subpartition_quantity - ) + ) ')' + | hash_subpartition_quantity ) + ) ; hash_subpartition_quantity @@ -3641,10 +3661,10 @@ subpartition_by_list ; subpartition_by_hash - : SUBPARTITION BY HASH '(' column_name (',' column_name)* ')' - (SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')' )? - | subpartition_template - )? + : SUBPARTITION BY HASH '(' column_name (',' column_name)* ')' ( + SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')')? + | subpartition_template + )? ; subpartition_name @@ -3664,7 +3684,7 @@ individual_hash_subparts ; hash_subparts_by_quantity - : SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')' )? + : SUBPARTITIONS UNSIGNED_INTEGER (STORE IN '(' tablespace (',' tablespace)* ')')? ; range_values_clause @@ -3676,35 +3696,34 @@ list_values_clause ; table_partition_description - : deferred_segment_creation? segment_attributes_clause? - (table_compression | key_compression)? - (OVERFLOW segment_attributes_clause? )? - (lob_storage_clause | varray_col_properties | nested_table_col_properties)* + : deferred_segment_creation? segment_attributes_clause? (table_compression | key_compression)? ( + OVERFLOW segment_attributes_clause? + )? (lob_storage_clause | varray_col_properties | nested_table_col_properties)* ; partitioning_storage_clause - : ( TABLESPACE tablespace - | OVERFLOW (TABLESPACE tablespace)? - | table_compression - | key_compression - | lob_partitioning_storage - | VARRAY varray_item STORE AS (BASICFILE | SECUREFILE)? LOB lob_segname - )+ + : ( + TABLESPACE tablespace + | OVERFLOW (TABLESPACE tablespace)? + | table_compression + | key_compression + | lob_partitioning_storage + | VARRAY varray_item STORE AS (BASICFILE | SECUREFILE)? LOB lob_segname + )+ ; lob_partitioning_storage - : LOB '(' lob_item ')' - STORE AS (BASICFILE | SECUREFILE)? - (lob_segname ('(' TABLESPACE tablespace ')' )? - | '(' TABLESPACE tablespace ')' - ) + : LOB '(' lob_item ')' STORE AS (BASICFILE | SECUREFILE)? ( + lob_segname ('(' TABLESPACE tablespace ')')? + | '(' TABLESPACE tablespace ')' + ) ; datatype_null_enable - : column_name datatype - SORT? (DEFAULT expression)? (ENCRYPT ( USING CHAR_STRING )? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? ( NO? SALT )? )? - (NOT NULL_)? (ENABLE | DISABLE)? - ; + : column_name datatype SORT? (DEFAULT expression)? ( + ENCRYPT (USING CHAR_STRING)? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? (NO? SALT)? + )? (NOT NULL_)? (ENABLE | DISABLE)? + ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/size_clause.html // Technically, this should only allow 'K' | 'M' | 'G' | 'T' | 'P' | 'E' @@ -3713,14 +3732,8 @@ size_clause : UNSIGNED_INTEGER (K_LETTER | M_LETTER | G_LETTER | T_LETTER | P_LETTER | E_LETTER)? ; - table_compression - : COMPRESS - ( BASIC - | FOR ( OLTP - | (QUERY | ARCHIVE) (LOW | HIGH)? - ) - )? + : COMPRESS (BASIC | FOR ( OLTP | (QUERY | ARCHIVE) (LOW | HIGH)?))? | NOCOMPRESS ; @@ -3748,9 +3761,9 @@ inmemory_priority ; inmemory_distribute - : DISTRIBUTE - (AUTO | BY (ROWID RANGE | PARTITION | SUBPARTITION))? - (FOR SERVICE (DEFAULT | ALL | identifier | NONE))? + : DISTRIBUTE (AUTO | BY (ROWID RANGE | PARTITION | SUBPARTITION))? ( + FOR SERVICE (DEFAULT | ALL | identifier | NONE) + )? ; inmemory_duplicate @@ -3763,32 +3776,32 @@ inmemory_column_clause ; physical_attributes_clause - : (PCTFREE pctfree=UNSIGNED_INTEGER - | PCTUSED pctused=UNSIGNED_INTEGER - | INITRANS inittrans=UNSIGNED_INTEGER - | MAXTRANS maxtrans=UNSIGNED_INTEGER - | COMPUTE STATISTICS - | storage_clause - | compute_clauses - )+ + : ( + PCTFREE pctfree = UNSIGNED_INTEGER + | PCTUSED pctused = UNSIGNED_INTEGER + | INITRANS inittrans = UNSIGNED_INTEGER + | MAXTRANS maxtrans = UNSIGNED_INTEGER + | COMPUTE STATISTICS + | storage_clause + | compute_clauses + )+ ; storage_clause - : STORAGE '(' - (INITIAL initial_size=size_clause - | NEXT next_size=size_clause - | MINEXTENTS minextents=(UNSIGNED_INTEGER | UNLIMITED) - | MAXEXTENTS minextents=(UNSIGNED_INTEGER | UNLIMITED) - | PCTINCREASE pctincrease=UNSIGNED_INTEGER - | FREELISTS freelists=UNSIGNED_INTEGER - | FREELIST GROUPS freelist_groups=UNSIGNED_INTEGER - | OPTIMAL (size_clause | NULL_ ) - | BUFFER_POOL (KEEP | RECYCLE | DEFAULT) - | FLASH_CACHE (KEEP | NONE | DEFAULT) - | CELL_FLASH_CACHE (KEEP | NONE | DEFAULT) - | ENCRYPT - )+ - ')' + : STORAGE '(' ( + INITIAL initial_size = size_clause + | NEXT next_size = size_clause + | MINEXTENTS minextents = (UNSIGNED_INTEGER | UNLIMITED) + | MAXEXTENTS minextents = (UNSIGNED_INTEGER | UNLIMITED) + | PCTINCREASE pctincrease = UNSIGNED_INTEGER + | FREELISTS freelists = UNSIGNED_INTEGER + | FREELIST GROUPS freelist_groups = UNSIGNED_INTEGER + | OPTIMAL (size_clause | NULL_) + | BUFFER_POOL (KEEP | RECYCLE | DEFAULT) + | FLASH_CACHE (KEEP | NONE | DEFAULT) + | CELL_FLASH_CACHE (KEEP | NONE | DEFAULT) + | ENCRYPT + )+ ')' ; deferred_segment_creation @@ -3796,31 +3809,35 @@ deferred_segment_creation ; segment_attributes_clause - : ( physical_attributes_clause - | TABLESPACE (tablespace_name=id_expression | SET? identifier) - | table_compression - | logging_clause - )+ + : ( + physical_attributes_clause + | TABLESPACE (tablespace_name = id_expression | SET? identifier) + | table_compression + | logging_clause + )+ ; physical_properties : deferred_segment_creation? segment_attributes_clause table_compression? inmemory_table_clause? ilm_clause? - | deferred_segment_creation? ( ORGANIZATION ( HEAP segment_attributes_clause? heap_org_table_clause - | INDEX segment_attributes_clause? index_org_table_clause - | EXTERNAL external_table_clause - ) - | EXTERNAL PARTITION ATTRIBUTES external_table_clause (REJECT LIMIT)? - ) + | deferred_segment_creation? ( + ORGANIZATION ( + HEAP segment_attributes_clause? heap_org_table_clause + | INDEX segment_attributes_clause? index_org_table_clause + | EXTERNAL external_table_clause + ) + | EXTERNAL PARTITION ATTRIBUTES external_table_clause (REJECT LIMIT)? + ) | CLUSTER cluster_name '(' column_name (',' column_name)* ')' ; ilm_clause - : ILM ( ADD POLICY ilm_policy_clause - | (DELETE | ENABLE | DISABLE) POLICY ilm_policy_clause - | DELETE_ALL - | ENABLE_ALL - | DISABLE_ALL - ) + : ILM ( + ADD POLICY ilm_policy_clause + | (DELETE | ENABLE | DISABLE) POLICY ilm_policy_clause + | DELETE_ALL + | ENABLE_ALL + | DISABLE_ALL + ) ; ilm_policy_clause @@ -3835,9 +3852,10 @@ ilm_compression_policy ; ilm_tiering_policy - : TIER TO tablespace ( segment_group? (ON function_name)? - | READ ONLY segment_group? ilm_after_on - ) + : TIER TO tablespace ( + segment_group? (ON function_name)? + | READ ONLY segment_group? ilm_after_on + ) ; ilm_after_on @@ -3851,20 +3869,11 @@ segment_group ; ilm_inmemory_policy - : ( SET INMEMORY inmemory_attributes? - | MODIFY INMEMORY inmemory_memcompress - | NO INMEMORY - ) SEGMENT? ilm_after_on + : (SET INMEMORY inmemory_attributes? | MODIFY INMEMORY inmemory_memcompress | NO INMEMORY) SEGMENT? ilm_after_on ; ilm_time_period - : numeric ( DAY - | DAYS - | MONTH - | MONTHS - | YEAR - | YEARS - ) + : numeric (DAY | DAYS | MONTH | MONTHS | YEAR | YEARS) ; heap_org_table_clause @@ -3872,7 +3881,9 @@ heap_org_table_clause ; external_table_clause - : '(' (TYPE access_driver_type)? external_table_data_props ')' (REJECT LIMIT (numeric | UNLIMITED))? inmemory_table_clause? + : '(' (TYPE access_driver_type)? external_table_data_props ')' ( + REJECT LIMIT (numeric | UNLIMITED) + )? inmemory_table_clause? ; access_driver_type @@ -3883,12 +3894,13 @@ access_driver_type ; external_table_data_props - : (DEFAULT DIRECTORY directory_name)? - (ACCESS PARAMETERS ( '(' CHAR_STRING ')' - | '(' opaque_format_spec ')' - | USING CLOB select_only_statement - ))? - (LOCATION '(' directory_name COLON CHAR_STRING (',' directory_name COLON CHAR_STRING)* ')' )? + : (DEFAULT DIRECTORY directory_name)? ( + ACCESS PARAMETERS ( + '(' CHAR_STRING ')' + | '(' opaque_format_spec ')' + | USING CLOB select_only_statement + ) + )? (LOCATION '(' directory_name COLON CHAR_STRING (',' directory_name COLON CHAR_STRING)* ')')? ; opaque_format_spec @@ -3900,7 +3912,7 @@ row_movement_clause ; flashback_archive_clause - : FLASHBACK ARCHIVE fa=id_expression? + : FLASHBACK ARCHIVE fa = id_expression? | NO FLASHBACK ARCHIVE ; @@ -3909,10 +3921,12 @@ log_grp ; supplemental_table_logging - : ADD SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) - (',' SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) )* - | DROP SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) - (',' SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) )* + : ADD SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) ( + ',' SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) + )* + | DROP SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) ( + ',' SUPPLEMENTAL LOG (supplemental_id_key_clause | GROUP log_grp) + )* ; supplemental_log_grp_clause @@ -3920,24 +3934,17 @@ supplemental_log_grp_clause ; supplemental_id_key_clause - : DATA '('( ','? ( ALL - | PRIMARY KEY - | UNIQUE - | FOREIGN KEY - ) - )+ - ')' - COLUMNS + : DATA '(' (','? ( ALL | PRIMARY KEY | UNIQUE | FOREIGN KEY))+ ')' COLUMNS ; allocate_extent_clause - : ALLOCATE EXTENT - ( '(' ( SIZE size_clause - | DATAFILE datafile=CHAR_STRING - | INSTANCE inst_num=UNSIGNED_INTEGER - )+ - ')' - )? + : ALLOCATE EXTENT ( + '(' ( + SIZE size_clause + | DATAFILE datafile = CHAR_STRING + | INSTANCE inst_num = UNSIGNED_INTEGER + )+ ')' + )? ; deallocate_unused_clause @@ -3966,14 +3973,12 @@ drop_table // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-TABLESPACE.html drop_tablespace - : DROP TABLESPACE ts=id_expression ((DROP | KEEP) QUOTA?)? - including_contents_clause? + : DROP TABLESPACE ts = id_expression ((DROP | KEEP) QUOTA?)? including_contents_clause? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-TABLESPACE-SET.html drop_tablespace_set - : DROP TABLESPACE SET tss=id_expression - including_contents_clause? + : DROP TABLESPACE SET tss = id_expression including_contents_clause? ; including_contents_clause @@ -3992,6 +3997,7 @@ enable_or_disable : ENABLE | DISABLE ; + allow_or_disallow : ALLOW | DISALLOW @@ -4000,13 +4006,21 @@ allow_or_disallow // Synonym DDL Clauses alter_synonym - : ALTER PUBLIC? SYNONYM (schema_name '.')? synonym_name (EDITIONABLE | NONEDITIONABLE | COMPILE) + : ALTER PUBLIC? SYNONYM (schema_name '.')? synonym_name ( + EDITIONABLE + | NONEDITIONABLE + | COMPILE + ) ; create_synonym - // Synonym's schema cannot be specified for public synonyms - : CREATE (OR REPLACE)? PUBLIC SYNONYM synonym_name FOR (schema_name PERIOD)? schema_object_name (AT_SIGN link_name)? - | CREATE (OR REPLACE)? SYNONYM (schema_name PERIOD)? synonym_name FOR (schema_name PERIOD)? schema_object_name (AT_SIGN (schema_name PERIOD)? link_name)? +// Synonym's schema cannot be specified for public synonyms + : CREATE (OR REPLACE)? PUBLIC SYNONYM synonym_name FOR (schema_name PERIOD)? schema_object_name ( + AT_SIGN link_name + )? + | CREATE (OR REPLACE)? SYNONYM (schema_name PERIOD)? synonym_name FOR (schema_name PERIOD)? schema_object_name ( + AT_SIGN (schema_name PERIOD)? link_name + )? ; drop_synonym @@ -4015,8 +4029,7 @@ drop_synonym // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-SPFILE.html create_spfile - : CREATE SPFILE ('=' spfile_name)? - FROM (PFILE ('=' pfile_name)? (AS COPY)? | MEMORY) + : CREATE SPFILE ('=' spfile_name)? FROM (PFILE ('=' pfile_name)? (AS COPY)? | MEMORY) ; spfile_name @@ -4036,21 +4049,22 @@ comment_on_materialized ; alter_analytic_view - : ALTER ANALYTIC VIEW (schema_name '.')? av=id_expression - ( RENAME TO id_expression + : ALTER ANALYTIC VIEW (schema_name '.')? av = id_expression ( + RENAME TO id_expression | COMPILE | alter_add_cache_clause | alter_drop_cache_clause - ) + ) ; alter_add_cache_clause - : ADD CACHE MEASURE GROUP '(' (ALL | measure_list)? ')' - LEVELS '(' levels_item (',' levels_item)* ')' + : ADD CACHE MEASURE GROUP '(' (ALL | measure_list)? ')' LEVELS '(' levels_item ( + ',' levels_item + )* ')' ; levels_item - : ((d=id_expression '.')? h=id_expression '.')? l=id_expression + : ((d = id_expression '.')? h = id_expression '.')? l = id_expression ; measure_list @@ -4058,55 +4072,56 @@ measure_list ; alter_drop_cache_clause - : DROP CACHE MEASURE GROUP '(' (ALL | measure_list)? ')' - LEVELS '(' levels_item (',' levels_item)* ')' + : DROP CACHE MEASURE GROUP '(' (ALL | measure_list)? ')' LEVELS '(' levels_item ( + ',' levels_item + )* ')' ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-ATTRIBUTE-DIMENSION.html alter_attribute_dimension - : ALTER ATTRIBUTE DIMENSION (schema_name '.')? ad=id_expression - (RENAME TO nad=id_expression | COMPILE) + : ALTER ATTRIBUTE DIMENSION (schema_name '.')? ad = id_expression ( + RENAME TO nad = id_expression + | COMPILE + ) ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html alter_audit_policy - : ALTER AUDIT POLICY p=id_expression - ADD? (privilege_audit_clause? action_audit_clause? role_audit_clause? | (ONLY TOPLEVEL)?) - DROP? (privilege_audit_clause? action_audit_clause? role_audit_clause? | (ONLY TOPLEVEL)?) - (CONDITION ( DROP - | CHAR_STRING EVALUATE PER (STATEMENT | SESSION | INSTANCE)) - )? + : ALTER AUDIT POLICY p = id_expression ADD? ( + privilege_audit_clause? action_audit_clause? role_audit_clause? + | (ONLY TOPLEVEL)? + ) DROP? (privilege_audit_clause? action_audit_clause? role_audit_clause? | (ONLY TOPLEVEL)?) ( + CONDITION (DROP | CHAR_STRING EVALUATE PER (STATEMENT | SESSION | INSTANCE)) + )? ; alter_cluster - : ALTER CLUSTER cluster_name - ( physical_attributes_clause + : ALTER CLUSTER cluster_name ( + physical_attributes_clause | SIZE size_clause | allocate_extent_clause | deallocate_unused_clause | cache_or_nocache - )+ - parallel_clause? - + )+ parallel_clause? ; drop_analytic_view - : DROP ANALYTIC VIEW (schema_name '.')? av=id_expression + : DROP ANALYTIC VIEW (schema_name '.')? av = id_expression ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-ATTRIBUTE-DIMENSION.html drop_attribute_dimension - : DROP ATTRIBUTE DIMENSION (schema_name '.')? ad=id_expression + : DROP ATTRIBUTE DIMENSION (schema_name '.')? ad = id_expression ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-AUDIT-POLICY-Unified-Auditing.html drop_audit_policy - : DROP AUDIT POLICY p=id_expression + : DROP AUDIT POLICY p = id_expression ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-FLASHBACK-ARCHIVE.html drop_flashback_archive - : DROP FLASHBACK ARCHIVE fa=id_expression + : DROP FLASHBACK ARCHIVE fa = id_expression ; drop_cluster @@ -4115,22 +4130,22 @@ drop_cluster // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-CONTEXT.html drop_context - : DROP CONTEXT ns=id_expression + : DROP CONTEXT ns = id_expression ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-DIRECTORY.html drop_directory - : DROP DIRECTORY dn=id_expression + : DROP DIRECTORY dn = id_expression ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-DISKGROUP.html drop_diskgroup - : DROP DISKGROUP dgn=id_expression ((FORCE? INCLUDING | EXCLUDING) CONTENTS)? + : DROP DISKGROUP dgn = id_expression ((FORCE? INCLUDING | EXCLUDING) CONTENTS)? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-EDITION.html drop_edition - : DROP EDITION e=id_expression CASCADE? + : DROP EDITION e = id_expression CASCADE? ; truncate_cluster @@ -4147,23 +4162,23 @@ database_name ; alter_database - : ALTER database_clause - ( startup_clauses - | recovery_clauses - | database_file_clauses - | logfile_clauses - | controlfile_clauses - | standby_database_clauses - | default_settings_clause - | instance_clauses - | security_clause - | prepare_clause - | drop_mirror_clause - | lost_write_protection - | cdb_fleet_clauses - | property_clauses - | replay_upgrade_clauses - ) + : ALTER database_clause ( + startup_clauses + | recovery_clauses + | database_file_clauses + | logfile_clauses + | controlfile_clauses + | standby_database_clauses + | default_settings_clause + | instance_clauses + | security_clause + | prepare_clause + | drop_mirror_clause + | lost_write_protection + | cdb_fleet_clauses + | property_clauses + | replay_upgrade_clauses + ) ; database_clause @@ -4198,58 +4213,63 @@ begin_or_end ; general_recovery - : RECOVER AUTOMATIC? (FROM CHAR_STRING)? - ( (full_database_recovery | partial_database_recovery | LOGFILE CHAR_STRING )? - ((TEST | ALLOW UNSIGNED_INTEGER CORRUPTION | parallel_clause)+ )? - | CONTINUE DEFAULT? - | CANCEL - ) + : RECOVER AUTOMATIC? (FROM CHAR_STRING)? ( + (full_database_recovery | partial_database_recovery | LOGFILE CHAR_STRING)? ( + (TEST | ALLOW UNSIGNED_INTEGER CORRUPTION | parallel_clause)+ + )? + | CONTINUE DEFAULT? + | CANCEL + ) ; //Need to come back to full_database_recovery - : STANDBY? DATABASE - ((UNTIL (CANCEL |TIME CHAR_STRING | CHANGE UNSIGNED_INTEGER | CONSISTENT) - | USING BACKUP CONTROLFILE - | SNAPSHOT TIME CHAR_STRING - )+ - )? + : STANDBY? DATABASE ( + ( + UNTIL (CANCEL | TIME CHAR_STRING | CHANGE UNSIGNED_INTEGER | CONSISTENT) + | USING BACKUP CONTROLFILE + | SNAPSHOT TIME CHAR_STRING + )+ + )? ; partial_database_recovery : TABLESPACE tablespace (',' tablespace)* - | DATAFILE CHAR_STRING | filenumber (',' CHAR_STRING | filenumber)* + | DATAFILE CHAR_STRING + | filenumber (',' CHAR_STRING | filenumber)* | partial_database_recovery_10g ; partial_database_recovery_10g - : {this.isVersion10()}? STANDBY - ( TABLESPACE tablespace (',' tablespace)* - | DATAFILE CHAR_STRING | filenumber (',' CHAR_STRING | filenumber)* - ) - UNTIL (CONSISTENT WITH)? CONTROLFILE + : {this.isVersion10()}? STANDBY ( + TABLESPACE tablespace (',' tablespace)* + | DATAFILE CHAR_STRING + | filenumber (',' CHAR_STRING | filenumber)* + ) UNTIL (CONSISTENT WITH)? CONTROLFILE ; - managed_standby_recovery - : RECOVER (MANAGED STANDBY DATABASE - ((USING CURRENT LOGFILE + : RECOVER ( + MANAGED STANDBY DATABASE ( + ( + USING CURRENT LOGFILE | DISCONNECT (FROM SESSION)? | NODELAY | UNTIL CHANGE UNSIGNED_INTEGER | UNTIL CONSISTENT | parallel_clause - )+ - | FINISH - | CANCEL - )? - | TO LOGICAL STANDBY (db_name | KEEP IDENTITY) - ) + )+ + | FINISH + | CANCEL + )? + | TO LOGICAL STANDBY (db_name | KEEP IDENTITY) + ) ; db_name : regular_id ; + database_file_clauses : RENAME FILE filename (',' filename)* TO filename | create_datafile_clause @@ -4259,34 +4279,36 @@ database_file_clauses ; create_datafile_clause - : CREATE DATAFILE (filename | filenumber) (',' (filename | filenumber) )* - (AS (//TODO (','? file_specification)+ | - NEW) )? + : CREATE DATAFILE (filename | filenumber) (',' (filename | filenumber))* ( + AS ( + //TODO (','? file_specification)+ | + NEW + ) + )? ; alter_datafile_clause - : DATAFILE (filename | filenumber) (',' (filename | filenumber) )* - ( ONLINE + : DATAFILE (filename | filenumber) (',' (filename | filenumber))* ( + ONLINE | OFFLINE (FOR DROP)? | RESIZE size_clause | autoextend_clause | END BACKUP - ) + ) ; alter_tempfile_clause - : TEMPFILE (filename | filenumber) (',' (filename | filenumber) )* - ( RESIZE size_clause + : TEMPFILE (filename | filenumber) (',' (filename | filenumber))* ( + RESIZE size_clause | autoextend_clause | DROP (INCLUDING DATAFILES) | ONLINE | OFFLINE - ) + ) ; move_datafile_clause - : MOVE DATAFILE (filename | filenumber) (',' (filename | filenumber) )* - (TO filename)? REUSE? KEEP? + : MOVE DATAFILE (filename | filenumber) (',' (filename | filenumber))* (TO filename)? REUSE? KEEP? ; logfile_clauses @@ -4294,7 +4316,9 @@ logfile_clauses | NO? FORCE LOGGING | SET STANDBY NOLOGGING FOR (DATA AVAILABILITY | LOAD PERFORMANCE) | RENAME FILE filename (',' filename)* TO filename - | CLEAR UNARCHIVED? LOGFILE logfile_descriptor (',' logfile_descriptor)* (UNRECOVERABLE DATAFILE)? + | CLEAR UNARCHIVED? LOGFILE logfile_descriptor (',' logfile_descriptor)* ( + UNRECOVERABLE DATAFILE + )? | add_logfile_clauses | drop_logfile_clauses | switch_logfile_clause @@ -4302,10 +4326,12 @@ logfile_clauses ; add_logfile_clauses - : ADD STANDBY? LOGFILE - ( (INSTANCE CHAR_STRING | THREAD UNSIGNED_INTEGER)? group_redo_logfile+ - | MEMBER filename REUSE? (',' filename REUSE?)* TO logfile_descriptor (',' logfile_descriptor)* - ) + : ADD STANDBY? LOGFILE ( + (INSTANCE CHAR_STRING | THREAD UNSIGNED_INTEGER)? group_redo_logfile+ + | MEMBER filename REUSE? (',' filename REUSE?)* TO logfile_descriptor ( + ',' logfile_descriptor + )* + ) ; group_redo_logfile @@ -4313,10 +4339,10 @@ group_redo_logfile ; drop_logfile_clauses - : DROP STANDBY? - LOGFILE (logfile_descriptor (',' logfile_descriptor)* - | MEMBER filename (',' filename)* - ) + : DROP STANDBY? LOGFILE ( + logfile_descriptor (',' logfile_descriptor)* + | MEMBER filename (',' filename)* + ) ; switch_logfile_clause @@ -4324,11 +4350,7 @@ switch_logfile_clause ; supplemental_db_logging - : add_or_drop - SUPPLEMENTAL LOG (DATA - | supplemental_id_key_clause - | supplemental_plsql_clause - ) + : add_or_drop SUPPLEMENTAL LOG (DATA | supplemental_id_key_clause | supplemental_plsql_clause) ; add_or_drop @@ -4352,19 +4374,19 @@ controlfile_clauses ; trace_file_clause - : TRACE (AS filename REUSE?)? (RESETLOGS|NORESETLOGS)? + : TRACE (AS filename REUSE?)? (RESETLOGS | NORESETLOGS)? ; standby_database_clauses - : ( activate_standby_db_clause - | maximize_standby_db_clause - | register_logfile_clause - | commit_switchover_clause - | start_standby_clause - | stop_standby_clause - | convert_database_clause - ) - parallel_clause? + : ( + activate_standby_db_clause + | maximize_standby_db_clause + | register_logfile_clause + | commit_switchover_clause + | start_standby_clause + | stop_standby_clause + | convert_database_clause + ) parallel_clause? ; activate_standby_db_clause @@ -4381,24 +4403,27 @@ register_logfile_clause ; commit_switchover_clause - : (PREPARE | COMMIT) TO SWITCHOVER - ((TO (((PHYSICAL | LOGICAL)? PRIMARY | PHYSICAL? STANDBY) - ((WITH | WITHOUT)? SESSION SHUTDOWN (WAIT | NOWAIT) )? - | LOGICAL STANDBY - ) - | LOGICAL STANDBY - ) + : (PREPARE | COMMIT) TO SWITCHOVER ( + ( + TO ( + ((PHYSICAL | LOGICAL)? PRIMARY | PHYSICAL? STANDBY) ( + (WITH | WITHOUT)? SESSION SHUTDOWN (WAIT | NOWAIT) + )? + | LOGICAL STANDBY + ) + | LOGICAL STANDBY + ) | CANCEL - )? + )? ; start_standby_clause - : START LOGICAL STANDBY APPLY IMMEDIATE? NODELAY? - ( NEW PRIMARY regular_id - | INITIAL scn_value=UNSIGNED_INTEGER? + : START LOGICAL STANDBY APPLY IMMEDIATE? NODELAY? ( + NEW PRIMARY regular_id + | INITIAL scn_value = UNSIGNED_INTEGER? | SKIP_ FAILED TRANSACTION | FINISH - )? + )? ; stop_standby_clause @@ -4454,12 +4479,13 @@ filename ; prepare_clause - : PREPARE MIRROR COPY c=id_expression (WITH (UNPROTECTED | MIRROR | HIGH) REDUNDANCY)? - (FOR DATABASE id_expression)? + : PREPARE MIRROR COPY c = id_expression (WITH (UNPROTECTED | MIRROR | HIGH) REDUNDANCY)? ( + FOR DATABASE id_expression + )? ; drop_mirror_clause - : DROP MIRROR COPY mn=id_expression + : DROP MIRROR COPY mn = id_expression ; lost_write_protection @@ -4480,7 +4506,7 @@ lead_cdb_uri_clause ; property_clauses - : PROPERTY (SET | REMOVE) DEFAULT_CREDENTIAL '=' qcn=id_expression + : PROPERTY (SET | REMOVE) DEFAULT_CREDENTIAL '=' qcn = id_expression ; replay_upgrade_clauses @@ -4488,7 +4514,10 @@ replay_upgrade_clauses ; alter_database_link - : ALTER SHARED? PUBLIC? DATABASE LINK link_name (CONNECT TO user_object_name IDENTIFIED BY password_value link_authentication? | link_authentication) + : ALTER SHARED? PUBLIC? DATABASE LINK link_name ( + CONNECT TO user_object_name IDENTIFIED BY password_value link_authentication? + | link_authentication + ) ; password_value @@ -4503,17 +4532,19 @@ link_authentication // added by zrh create_database - : CREATE DATABASE database_name - ( USER (SYS | SYSTEM) IDENTIFIED BY password_value - | CONTROLFILE REUSE - | (MAXDATAFILES | MAXINSTANCES) UNSIGNED_INTEGER - | NATIONAL? CHARACTER SET char_set_name - | SET DEFAULT (BIGFILE | SMALLFILE) TABLESPACE - | database_logging_clauses - | tablespace_clauses - | set_time_zone_clause - | (BIGFILE | SMALLFILE)? USER_DATA TABLESPACE tablespace_group_name DATAFILE datafile_tempfile_spec (',' datafile_tempfile_spec)* - | enable_pluggable_database + : CREATE DATABASE database_name ( + USER (SYS | SYSTEM) IDENTIFIED BY password_value + | CONTROLFILE REUSE + | (MAXDATAFILES | MAXINSTANCES) UNSIGNED_INTEGER + | NATIONAL? CHARACTER SET char_set_name + | SET DEFAULT (BIGFILE | SMALLFILE) TABLESPACE + | database_logging_clauses + | tablespace_clauses + | set_time_zone_clause + | (BIGFILE | SMALLFILE)? USER_DATA TABLESPACE tablespace_group_name DATAFILE datafile_tempfile_spec ( + ',' datafile_tempfile_spec + )* + | enable_pluggable_database )+ ; @@ -4538,11 +4569,18 @@ tablespace_clauses ; enable_pluggable_database - : ENABLE PLUGGABLE DATABASE (SEED file_name_convert? (SYSTEM tablespace_datafile_clauses)? (SYSAUX tablespace_datafile_clauses)? )? undo_mode_clause? + : ENABLE PLUGGABLE DATABASE ( + SEED file_name_convert? (SYSTEM tablespace_datafile_clauses)? ( + SYSAUX tablespace_datafile_clauses + )? + )? undo_mode_clause? ; file_name_convert - : FILE_NAME_CONVERT EQUALS_OP ( '(' filename_convert_sub_clause (',' filename_convert_sub_clause)* ')' | NONE) + : FILE_NAME_CONVERT EQUALS_OP ( + '(' filename_convert_sub_clause (',' filename_convert_sub_clause)* ')' + | NONE + ) ; filename_convert_sub_clause @@ -4562,12 +4600,16 @@ default_tablespace ; default_temp_tablespace - : (BIGFILE | SMALLFILE)? DEFAULT (TEMPORARY TABLESPACE | LOCAL TEMPORARY TABLESPACE FOR (ALL | LEAF)) tablespace - (TEMPFILE file_specification (',' file_specification)*)? extent_management_clause? + : (BIGFILE | SMALLFILE)? DEFAULT ( + TEMPORARY TABLESPACE + | LOCAL TEMPORARY TABLESPACE FOR (ALL | LEAF) + ) tablespace (TEMPFILE file_specification (',' file_specification)*)? extent_management_clause? ; undo_tablespace - : (BIGFILE | SMALLFILE)? UNDO TABLESPACE tablespace (DATAFILE file_specification (',' file_specification)*)? + : (BIGFILE | SMALLFILE)? UNDO TABLESPACE tablespace ( + DATAFILE file_specification (',' file_specification)* + )? ; // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-DATABASE.html @@ -4577,15 +4619,17 @@ drop_database // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-DATABASE-LINK.html create_database_link - : CREATE SHARED? PUBLIC? DATABASE LINK dblink ( CONNECT TO ( CURRENT_USER - | user_object_name IDENTIFIED BY password_value link_authentication? - ) - | link_authentication - )* (USING CHAR_STRING)? + : CREATE SHARED? PUBLIC? DATABASE LINK dblink ( + CONNECT TO ( + CURRENT_USER + | user_object_name IDENTIFIED BY password_value link_authentication? + ) + | link_authentication + )* (USING CHAR_STRING)? ; dblink - : database_name ('.' d=id_expression)* ('@' cq=id_expression)? + : database_name ('.' d = id_expression)* ('@' cq = id_expression)? ; drop_database_link @@ -4594,7 +4638,7 @@ drop_database_link // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-TABLESPACE-SET.html alter_tablespace_set - : ALTER TABLESPACE SET tss=id_expression alter_tablespace_attrs + : ALTER TABLESPACE SET tss = id_expression alter_tablespace_attrs ; alter_tablespace_attrs @@ -4603,7 +4647,7 @@ alter_tablespace_attrs | RESIZE size_clause | COALESCE | SHRINK SPACE_KEYWORD (KEEP size_clause)? - | RENAME TO nts=id_expression + | RENAME TO nts = id_expression | (BEGIN | END) BACKUP | datafile_tempfile_clauses | tablespace_logging_clauses @@ -4617,10 +4661,11 @@ alter_tablespace_attrs ; alter_tablespace_encryption - : ENCRYPTION ( OFFLINE (tablespace_encryption_spec? ENCRYPT | DECRYPT) - | ONLINE (tablespace_encryption_spec? (ENCRYPT | REKEY) | DECRYPT) ts_file_name_convert? - | FINISH (ENCRYPT | REKEY | DECRYPT) ts_file_name_convert? - ) + : ENCRYPTION ( + OFFLINE (tablespace_encryption_spec? ENCRYPT | DECRYPT) + | ONLINE (tablespace_encryption_spec? (ENCRYPT | REKEY) | DECRYPT) ts_file_name_convert? + | FINISH (ENCRYPT | REKEY | DECRYPT) ts_file_name_convert? + ) ; ts_file_name_convert @@ -4633,24 +4678,23 @@ alter_role role_identified_clause : NOT IDENTIFIED - | IDENTIFIED ( BY identifier - | USING identifier ('.' id_expression)? - | EXTERNALLY - | GLOBALLY (AS CHAR_STRING)? - ) + | IDENTIFIED ( + BY identifier + | USING identifier ('.' id_expression)? + | EXTERNALLY + | GLOBALLY (AS CHAR_STRING)? + ) ; alter_table - : ALTER TABLE tableview_name memoptimize_read_write_clause* - ( - | alter_table_properties - | constraint_clauses - | column_clauses - | alter_table_partitioning -//TODO | alter_external_table - | move_table_clause - ) - ((enable_disable_clause | enable_or_disable (TABLE LOCK | ALL TRIGGERS) )+)? + : ALTER TABLE tableview_name memoptimize_read_write_clause* ( + | alter_table_properties + | constraint_clauses + | column_clauses + | alter_table_partitioning + //TODO | alter_external_table + | move_table_clause + ) ((enable_disable_clause | enable_or_disable (TABLE LOCK | ALL TRIGGERS))+)? ; memoptimize_read_write_clause @@ -4678,16 +4722,18 @@ alter_table_partitioning | alter_interval_partition ; - add_table_partition - : ADD ( range_partition_desc - | list_partition_desc - | PARTITION partition_name? (TABLESPACE tablespace)? key_compression? UNUSABLE? - ) + : ADD ( + range_partition_desc + | list_partition_desc + | PARTITION partition_name? (TABLESPACE tablespace)? key_compression? UNUSABLE? + ) ; drop_table_partition - : DROP (partition_extended_names | subpartition_extended_names) (update_index_clauses parallel_clause?)? + : DROP (partition_extended_names | subpartition_extended_names) ( + update_index_clauses parallel_clause? + )? ; merge_table_partition @@ -4695,27 +4741,31 @@ merge_table_partition ; modify_table_partition - : MODIFY (PARTITION partition_name ((ADD | DROP) list_values_clause)? (ADD range_subpartition_desc)? (REBUILD? UNUSABLE LOCAL INDEXES)? - | range_partitions - ) + : MODIFY ( + PARTITION partition_name ((ADD | DROP) list_values_clause)? (ADD range_subpartition_desc)? ( + REBUILD? UNUSABLE LOCAL INDEXES + )? + | range_partitions + ) ; split_table_partition - : SPLIT PARTITION partition_name INTO '(' - (range_partition_desc (',' range_partition_desc)* - | list_partition_desc (',' list_partition_desc)* ) - ')' + : SPLIT PARTITION partition_name INTO '(' ( + range_partition_desc (',' range_partition_desc)* + | list_partition_desc (',' list_partition_desc)* + ) ')' ; truncate_table_partition - : TRUNCATE (partition_extended_names | subpartition_extended_names) - ((DROP ALL? | REUSE)? STORAGE)? CASCADE? (update_index_clauses parallel_clause?)? + : TRUNCATE (partition_extended_names | subpartition_extended_names) ( + (DROP ALL? | REUSE)? STORAGE + )? CASCADE? (update_index_clauses parallel_clause?)? ; exchange_table_partition - : EXCHANGE PARTITION partition_name WITH TABLE tableview_name - ((INCLUDING | EXCLUDING) INDEXES)? - ((WITH | WITHOUT) VALIDATION)? + : EXCHANGE PARTITION partition_name WITH TABLE tableview_name ((INCLUDING | EXCLUDING) INDEXES)? ( + (WITH | WITHOUT) VALIDATION + )? ; coalesce_table_partition @@ -4726,36 +4776,39 @@ alter_interval_partition : SET INTERVAL '(' (constant | expression)? ')' ; - partition_extended_names - : (PARTITION | PARTITIONS) ( partition_name (',' partition_name)* - | '(' partition_name (',' partition_name)* ')' - | FOR '('? partition_key_value (',' partition_key_value)* ')'? ) + : (PARTITION | PARTITIONS) ( + partition_name (',' partition_name)* + | '(' partition_name (',' partition_name)* ')' + | FOR '('? partition_key_value (',' partition_key_value)* ')'? + ) ; subpartition_extended_names - : (SUBPARTITION | SUBPARTITIONS) ( partition_name (UPDATE INDEXES)? - | '(' partition_name (',' partition_name)* ')' - | FOR '('? subpartition_key_value (',' subpartition_key_value)* ')'? ) + : (SUBPARTITION | SUBPARTITIONS) ( + partition_name (UPDATE INDEXES)? + | '(' partition_name (',' partition_name)* ')' + | FOR '('? subpartition_key_value (',' subpartition_key_value)* ')'? + ) ; alter_table_properties_1 - : ( physical_attributes_clause - | logging_clause - | table_compression - | inmemory_table_clause - | supplemental_table_logging - | allocate_extent_clause - | deallocate_unused_clause - | (CACHE | NOCACHE) - | RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')' - | upgrade_table_clause - | records_per_block_clause - | parallel_clause - | row_movement_clause - | flashback_archive_clause - )+ - alter_iot_clauses? + : ( + physical_attributes_clause + | logging_clause + | table_compression + | inmemory_table_clause + | supplemental_table_logging + | allocate_extent_clause + | deallocate_unused_clause + | (CACHE | NOCACHE) + | RESULT_CACHE '(' MODE (DEFAULT | FORCE) ')' + | upgrade_table_clause + | records_per_block_clause + | parallel_clause + | row_movement_clause + | flashback_archive_clause + )+ alter_iot_clauses? ; alter_iot_clauses @@ -4771,14 +4824,20 @@ alter_mapping_table_clause alter_overflow_clause : add_overflow_clause - | OVERFLOW (segment_attributes_clause | allocate_extent_clause | shrink_clause | deallocate_unused_clause)+ + | OVERFLOW ( + segment_attributes_clause + | allocate_extent_clause + | shrink_clause + | deallocate_unused_clause + )+ ; add_overflow_clause - : ADD OVERFLOW segment_attributes_clause? ('(' PARTITION segment_attributes_clause? (',' PARTITION segment_attributes_clause?)* ')' )? + : ADD OVERFLOW segment_attributes_clause? ( + '(' PARTITION segment_attributes_clause? (',' PARTITION segment_attributes_clause?)* ')' + )? ; - update_index_clauses : update_global_index_clause | update_all_indexes_clause @@ -4793,7 +4852,9 @@ update_all_indexes_clause ; update_all_indexes_index_clause - : index_name '(' (update_index_partition | update_index_subpartition) ')' (',' update_all_indexes_clause)* + : index_name '(' (update_index_partition | update_index_subpartition) ')' ( + ',' update_all_indexes_clause + )* ; update_index_partition @@ -4805,28 +4866,28 @@ update_index_subpartition ; enable_disable_clause - : (ENABLE | DISABLE) (VALIDATE | NOVALIDATE)? - (UNIQUE '(' column_name (',' column_name)* ')' - | PRIMARY KEY - | CONSTRAINT constraint_name - ) using_index_clause? exceptions_clause? - CASCADE? ((KEEP | DROP) INDEX)? + : (ENABLE | DISABLE) (VALIDATE | NOVALIDATE)? ( + UNIQUE '(' column_name (',' column_name)* ')' + | PRIMARY KEY + | CONSTRAINT constraint_name + ) using_index_clause? exceptions_clause? CASCADE? ((KEEP | DROP) INDEX)? ; using_index_clause - : USING INDEX (index_name | '(' create_index ')' | index_attributes )? + : USING INDEX (index_name | '(' create_index ')' | index_attributes)? ; index_attributes - : ( physical_attributes_clause - | logging_clause - | TABLESPACE (tablespace | DEFAULT) - | key_compression - | sort_or_nosort - | REVERSE - | visible_or_invisible - | parallel_clause - )+ + : ( + physical_attributes_clause + | logging_clause + | TABLESPACE (tablespace | DEFAULT) + | key_compression + | sort_or_nosort + | REVERSE + | visible_or_invisible + | parallel_clause + )+ ; sort_or_nosort @@ -4839,12 +4900,10 @@ exceptions_clause ; move_table_clause - : MOVE ONLINE? - segment_attributes_clause? - table_compression? - index_org_table_clause? - (lob_storage_clause | varray_col_properties)* - parallel_clause? + : MOVE ONLINE? segment_attributes_clause? table_compression? index_org_table_clause? ( + lob_storage_clause + | varray_col_properties + )* parallel_clause? ; index_org_table_clause @@ -4894,30 +4953,34 @@ new_column_name ; add_modify_drop_column_clauses - : (constraint_clauses - |add_column_clause - |modify_column_clauses - |drop_column_clause - )+ + : (constraint_clauses | add_column_clause | modify_column_clauses | drop_column_clause)+ ; drop_column_clause - : SET UNUSED (COLUMN column_name| ('(' column_name (',' column_name)* ')' )) (CASCADE CONSTRAINTS | INVALIDATE)* - | DROP (COLUMN column_name | '(' column_name (',' column_name)* ')' ) (CASCADE CONSTRAINTS | INVALIDATE)* (CHECKPOINT UNSIGNED_INTEGER)? + : SET UNUSED (COLUMN column_name | ('(' column_name (',' column_name)* ')')) ( + CASCADE CONSTRAINTS + | INVALIDATE + )* + | DROP (COLUMN column_name | '(' column_name (',' column_name)* ')') ( + CASCADE CONSTRAINTS + | INVALIDATE + )* (CHECKPOINT UNSIGNED_INTEGER)? | DROP (UNUSED COLUMNS | COLUMNS CONTINUE) (CHECKPOINT UNSIGNED_INTEGER) ; modify_column_clauses - : MODIFY ('(' modify_col_properties (',' modify_col_properties)* ')' - |'(' modify_col_visibility (',' modify_col_visibility)* ')' - | modify_col_properties - | modify_col_visibility - | modify_col_substitutable - ) + : MODIFY ( + '(' modify_col_properties (',' modify_col_properties)* ')' + | '(' modify_col_visibility (',' modify_col_visibility)* ')' + | modify_col_properties + | modify_col_visibility + | modify_col_substitutable + ) ; modify_col_properties - : column_name datatype? (DEFAULT expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? //TODO alter_xmlschema_clause + : column_name datatype? (DEFAULT expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? + //TODO alter_xmlschema_clause ; modify_col_visibility @@ -4929,13 +4992,13 @@ modify_col_substitutable ; add_column_clause - : ADD ('(' (column_definition | virtual_column_definition) (',' (column_definition - | virtual_column_definition) - )* - ')' - | ( column_definition | virtual_column_definition )) - column_properties? -//TODO (','? out_of_line_part_storage ) + : ADD ( + '(' (column_definition | virtual_column_definition) ( + ',' (column_definition | virtual_column_definition) + )* ')' + | ( column_definition | virtual_column_definition) + ) column_properties? + //TODO (','? out_of_line_part_storage ) ; alter_varray_col_properties @@ -4943,15 +5006,17 @@ alter_varray_col_properties ; varray_col_properties - : VARRAY varray_item ( substitutable_column_clause? varray_storage_clause - | substitutable_column_clause - ) + : VARRAY varray_item ( + substitutable_column_clause? varray_storage_clause + | substitutable_column_clause + ) ; varray_storage_clause - : STORE AS (SECUREFILE|BASICFILE)? LOB ( lob_segname? '(' lob_storage_parameters ')' - | lob_segname - ) + : STORE AS (SECUREFILE | BASICFILE)? LOB ( + lob_segname? '(' lob_storage_parameters ')' + | lob_segname + ) ; lob_segname @@ -4965,14 +5030,23 @@ lob_item ; lob_storage_parameters - : TABLESPACE tablespace_name=id_expression | (lob_parameters storage_clause? ) - | storage_clause + : TABLESPACE tablespace_name = id_expression + | (lob_parameters storage_clause?) + | storage_clause ; lob_storage_clause - : LOB ( '(' lob_item (',' lob_item)* ')' STORE AS ( (SECUREFILE|BASICFILE) | '(' lob_storage_parameters* ')' )+ - | '(' lob_item ')' STORE AS ( (SECUREFILE | BASICFILE) | lob_segname | '(' lob_storage_parameters* ')' )+ - ) + : LOB ( + '(' lob_item (',' lob_item)* ')' STORE AS ( + (SECUREFILE | BASICFILE) + | '(' lob_storage_parameters* ')' + )+ + | '(' lob_item ')' STORE AS ( + (SECUREFILE | BASICFILE) + | lob_segname + | '(' lob_storage_parameters* ')' + )+ + ) ; modify_lob_storage_clause @@ -4980,34 +5054,36 @@ modify_lob_storage_clause ; modify_lob_parameters - : ( storage_clause - | (PCTVERSION | FREEPOOLS) UNSIGNED_INTEGER - | REBUILD FREEPOOLS - | lob_retention_clause - | lob_deduplicate_clause - | lob_compression_clause - | ENCRYPT encryption_spec - | DECRYPT - | CACHE - | (CACHE | NOCACHE | CACHE READS) logging_clause? - | allocate_extent_clause - | shrink_clause - | deallocate_unused_clause - )+ + : ( + storage_clause + | (PCTVERSION | FREEPOOLS) UNSIGNED_INTEGER + | REBUILD FREEPOOLS + | lob_retention_clause + | lob_deduplicate_clause + | lob_compression_clause + | ENCRYPT encryption_spec + | DECRYPT + | CACHE + | (CACHE | NOCACHE | CACHE READS) logging_clause? + | allocate_extent_clause + | shrink_clause + | deallocate_unused_clause + )+ ; lob_parameters - : ( (ENABLE | DISABLE) STORAGE IN ROW - | CHUNK UNSIGNED_INTEGER - | PCTVERSION UNSIGNED_INTEGER - | FREEPOOLS UNSIGNED_INTEGER - | lob_retention_clause - | lob_deduplicate_clause - | lob_compression_clause - | ENCRYPT encryption_spec - | DECRYPT - | (CACHE | NOCACHE | CACHE READS) logging_clause? - )+ + : ( + (ENABLE | DISABLE) STORAGE IN ROW + | CHUNK UNSIGNED_INTEGER + | PCTVERSION UNSIGNED_INTEGER + | FREEPOOLS UNSIGNED_INTEGER + | lob_retention_clause + | lob_deduplicate_clause + | lob_compression_clause + | ENCRYPT encryption_spec + | DECRYPT + | (CACHE | NOCACHE | CACHE READS) logging_clause? + )+ ; lob_deduplicate_clause @@ -5025,10 +5101,9 @@ lob_retention_clause ; encryption_spec - : (USING CHAR_STRING)? - (IDENTIFIED BY REGULAR_ID)? - CHAR_STRING? (NO? SALT)? + : (USING CHAR_STRING)? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? (NO? SALT)? ; + tablespace : id_expression ; @@ -5038,21 +5113,32 @@ varray_item ; column_properties - : (object_type_col_properties - | nested_table_col_properties - | (varray_col_properties | lob_storage_clause) ('(' lob_partition_storage (',' lob_partition_storage)* ')')? //TODO '(' ( ','? lob_partition_storage)+ ')' - | xmltype_column_properties)+ + : ( + object_type_col_properties + | nested_table_col_properties + | (varray_col_properties | lob_storage_clause) ( + '(' lob_partition_storage (',' lob_partition_storage)* ')' + )? //TODO '(' ( ','? lob_partition_storage)+ ')' + | xmltype_column_properties + )+ ; lob_partition_storage - : LOB ('(' lob_item (',' lob_item) ')' STORE AS ((SECUREFILE | BASICFILE) | '(' lob_storage_parameters ')')+ - | '(' lob_item ')' STORE AS ((SECUREFILE | BASICFILE) | lob_segname | '(' lob_storage_parameters ')')+ - ) + : LOB ( + '(' lob_item (',' lob_item) ')' STORE AS ( + (SECUREFILE | BASICFILE) + | '(' lob_storage_parameters ')' + )+ + | '(' lob_item ')' STORE AS ( + (SECUREFILE | BASICFILE) + | lob_segname + | '(' lob_storage_parameters ')' + )+ + ) ; period_definition - : {this.isVersion12()}? PERIOD FOR column_name - ( '(' start_time_column ',' end_time_column ')' )? + : {this.isVersion12()}? PERIOD FOR column_name ('(' start_time_column ',' end_time_column ')')? ; start_time_column @@ -5064,13 +5150,13 @@ end_time_column ; column_definition - : column_name - ( (datatype | regular_id) (COLLATE column_collation_name)?)? - SORT? - (VISIBLE | INVISIBLE)? - (DEFAULT (ON NULL_)? expression | identity_clause)? - (ENCRYPT encryption_spec)? - (inline_constraint+ | inline_ref_constraint)? + : column_name ((datatype | regular_id) (COLLATE column_collation_name)?)? SORT? ( + VISIBLE + | INVISIBLE + )? (DEFAULT (ON NULL_)? expression | identity_clause)? (ENCRYPT encryption_spec)? ( + inline_constraint+ + | inline_ref_constraint + )? ; column_collation_name @@ -5107,18 +5193,16 @@ identity_options ; virtual_column_definition - : column_name (datatype COLLATE column_collation_name)? - (VISIBLE | INVISIBLE)? - autogenerated_sequence_definition? - VIRTUAL? - evaluation_edition_clause? - (UNUSABLE BEFORE (CURRENT EDITION | EDITION edition_name))? - (UNUSABLE BEGINNING WITH ((CURRENT | NULL_) EDITION | EDITION edition_name))? - inline_constraint* + : column_name (datatype COLLATE column_collation_name)? (VISIBLE | INVISIBLE)? autogenerated_sequence_definition? VIRTUAL? + evaluation_edition_clause? (UNUSABLE BEFORE (CURRENT EDITION | EDITION edition_name))? ( + UNUSABLE BEGINNING WITH ((CURRENT | NULL_) EDITION | EDITION edition_name) + )? inline_constraint* ; autogenerated_sequence_definition - : GENERATED (ALWAYS | BY DEFAULT (ON NULL_)?)? AS IDENTITY ( '(' (sequence_start_clause | sequence_spec)* ')' )? + : GENERATED (ALWAYS | BY DEFAULT (ON NULL_)?)? AS IDENTITY ( + '(' (sequence_start_clause | sequence_spec)* ')' + )? ; evaluation_edition_clause @@ -5130,15 +5214,10 @@ out_of_line_part_storage ; nested_table_col_properties - : NESTED TABLE (nested_item | COLUMN_VALUE) substitutable_column_clause? (LOCAL | GLOBAL)? - STORE AS tableview_name ( '(' ( '(' object_properties ')' - | physical_properties - | column_properties - )+ - ')' - )? - (RETURN AS? (LOCATOR | VALUE) )? - ; + : NESTED TABLE (nested_item | COLUMN_VALUE) substitutable_column_clause? (LOCAL | GLOBAL)? STORE AS tableview_name ( + '(' ('(' object_properties ')' | physical_properties | column_properties)+ ')' + )? (RETURN AS? (LOCATOR | VALUE))? + ; nested_item : regular_id @@ -5163,13 +5242,17 @@ column_or_attribute ; object_type_col_properties - : COLUMN column=regular_id substitutable_column_clause + : COLUMN column = regular_id substitutable_column_clause ; constraint_clauses : ADD '(' (out_of_line_constraint* | out_of_line_ref_constraint) ')' - | ADD (out_of_line_constraint* | out_of_line_ref_constraint) - | MODIFY (CONSTRAINT constraint_name | PRIMARY KEY | UNIQUE '(' column_name (',' column_name)* ')') constraint_state CASCADE? + | ADD (out_of_line_constraint* | out_of_line_ref_constraint) + | MODIFY ( + CONSTRAINT constraint_name + | PRIMARY KEY + | UNIQUE '(' column_name (',' column_name)* ')' + ) constraint_state CASCADE? | RENAME CONSTRAINT old_constraint_name TO new_constraint_name | drop_constraint_clause+ ; @@ -5183,22 +5266,25 @@ new_constraint_name ; drop_constraint_clause - : DROP ( PRIMARY KEY - | UNIQUE '(' column_name (',' column_name)* ')' - | CONSTRAINT constraint_name - ) CASCADE? ((KEY | DROP) INDEX)? ONLINE? + : DROP ( + PRIMARY KEY + | UNIQUE '(' column_name (',' column_name)* ')' + | CONSTRAINT constraint_name + ) CASCADE? ((KEY | DROP) INDEX)? ONLINE? ; add_constraint - : ADD (CONSTRAINT constraint_name)? add_constraint_clause (',' (CONSTRAINT constraint_name)? add_constraint_clause)+ + : ADD (CONSTRAINT constraint_name)? add_constraint_clause ( + ',' (CONSTRAINT constraint_name)? add_constraint_clause + )+ ; add_constraint_clause : primary_key_clause - | foreign_key_clause - | unique_key_clause - | check_constraint - ; + | foreign_key_clause + | unique_key_clause + | check_constraint + ; check_constraint : CHECK '(' condition ')' DISABLE? @@ -5309,7 +5395,9 @@ subtype_declaration // cursor_declaration incorportates curscursor_body and cursor_spec cursor_declaration - : CURSOR identifier ('(' parameter_spec (',' parameter_spec)* ')' )? (RETURN type_spec)? (IS select_statement)? ';' + : CURSOR identifier ('(' parameter_spec (',' parameter_spec)* ')')? (RETURN type_spec)? ( + IS select_statement + )? ';' ; parameter_spec @@ -5321,11 +5409,13 @@ exception_declaration ; pragma_declaration - : PRAGMA (SERIALLY_REUSABLE - | AUTONOMOUS_TRANSACTION - | EXCEPTION_INIT '(' exception_name ',' numeric_negative ')' - | INLINE '(' id1=identifier ',' expression ')' - | RESTRICT_REFERENCES '(' (identifier | DEFAULT) (',' identifier)+ ')') ';' + : PRAGMA ( + SERIALLY_REUSABLE + | AUTONOMOUS_TRANSACTION + | EXCEPTION_INIT '(' exception_name ',' numeric_negative ')' + | INLINE '(' id1 = identifier ',' expression ')' + | RESTRICT_REFERENCES '(' (identifier | DEFAULT) (',' identifier)+ ')' + ) ';' ; // Record Declaration Specific Clauses @@ -5353,7 +5443,7 @@ table_type_def ; table_indexed_by_part - : (idx1=INDEXED | idx2=INDEX) BY type_spec + : (idx1 = INDEXED | idx2 = INDEX) BY type_spec ; varray_type_def @@ -5367,7 +5457,7 @@ seq_of_statements ; label_declaration - : ltp1= '<' '<' label_name '>' '>' + : ltp1 = '<' '<' label_name '>' '>' ; statement @@ -5428,7 +5518,7 @@ loop_statement // Loop Specific Clause cursor_loop_param - : index_name IN REVERSE? lower_bound range_separator='..' upper_bound + : index_name IN REVERSE? lower_bound range_separator = '..' upper_bound | record_name IN (cursor_name ('(' expressions? ')')? | '(' select_statement ')') ; @@ -5467,11 +5557,14 @@ return_statement ; call_statement - : CALL? routine_name function_argument? ('.' routine_name function_argument?)* (INTO bind_variable)? + : CALL? routine_name function_argument? ('.' routine_name function_argument?)* ( + INTO bind_variable + )? ; pipe_row_statement - : PIPE ROW '(' expression ')'; + : PIPE ROW '(' expression ')' + ; body : BEGIN seq_of_statements (EXCEPTION exception_handler+)? END label_name? @@ -5505,7 +5598,11 @@ sql_statement ; execute_immediate - : EXECUTE IMMEDIATE expression (into_clause using_clause? | using_clause dynamic_returning_clause? | dynamic_returning_clause)? + : EXECUTE IMMEDIATE expression ( + into_clause using_clause? + | using_clause dynamic_returning_clause? + | dynamic_returning_clause + )? ; // Execute Immediate Specific Clause @@ -5544,7 +5641,10 @@ open_statement ; fetch_statement - : FETCH cursor_name (it1=INTO variable_name (',' variable_name)* | BULK COLLECT INTO variable_name (',' variable_name)* (LIMIT (numeric | variable_name))?) + : FETCH cursor_name ( + it1 = INTO variable_name (',' variable_name)* + | BULK COLLECT INTO variable_name (',' variable_name)* (LIMIT (numeric | variable_name))? + ) ; open_for_statement @@ -5562,25 +5662,27 @@ transaction_control_statements ; set_transaction_command - : SET TRANSACTION - (READ (ONLY | WRITE) | ISOLATION LEVEL (SERIALIZABLE | READ COMMITTED) | USE ROLLBACK SEGMENT rollback_segment_name)? - (NAME quoted_string)? + : SET TRANSACTION ( + READ (ONLY | WRITE) + | ISOLATION LEVEL (SERIALIZABLE | READ COMMITTED) + | USE ROLLBACK SEGMENT rollback_segment_name + )? (NAME quoted_string)? ; set_constraint_command - : SET (CONSTRAINT | CONSTRAINTS) (ALL | constraint_name (',' constraint_name)*) (IMMEDIATE | DEFERRED) + : SET (CONSTRAINT | CONSTRAINTS) (ALL | constraint_name (',' constraint_name)*) ( + IMMEDIATE + | DEFERRED + ) ; // https://docs.oracle.com/cd/E18283_01/server.112/e17118/statements_4010.htm#SQLRF01110 // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/COMMIT.html commit_statement - : COMMIT WORK? write_clause? - ( COMMENT CHAR_STRING write_clause? - | FORCE ( CHAR_STRING (',' numeric)? - | CORRUPT_XID CHAR_STRING - | CORRUPT_XID_ALL - ) - )? + : COMMIT WORK? write_clause? ( + COMMENT CHAR_STRING write_clause? + | FORCE (CHAR_STRING (',' numeric)? | CORRUPT_XID CHAR_STRING | CORRUPT_XID_ALL) + )? ; write_clause @@ -5617,8 +5719,13 @@ seq_of_statements */ explain_statement - : EXPLAIN PLAN (SET STATEMENT_ID '=' quoted_string)? (INTO tableview_name)? - FOR (select_statement | update_statement | delete_statement | insert_statement | merge_statement) + : EXPLAIN PLAN (SET STATEMENT_ID '=' quoted_string)? (INTO tableview_name)? FOR ( + select_statement + | update_statement + | delete_statement + | insert_statement + | merge_statement + ) ; select_only_statement @@ -5636,13 +5743,13 @@ subquery_factoring_clause ; factoring_element - : query_name paren_column_list? AS '(' subquery order_by_clause? ')' - search_clause? cycle_clause? + : query_name paren_column_list? AS '(' subquery order_by_clause? ')' search_clause? cycle_clause? ; search_clause - : SEARCH (DEPTH | BREADTH) FIRST BY column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)? - (',' column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)?)* SET column_name + : SEARCH (DEPTH | BREADTH) FIRST BY column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)? ( + ',' column_name ASC? DESC? (NULLS FIRST)? (NULLS LAST)? + )* SET column_name ; cycle_clause @@ -5663,8 +5770,8 @@ subquery_operation_part ; query_block - : SELECT (DISTINCT | UNIQUE | ALL)? selected_list - into_clause? from_clause where_clause? hierarchical_query_clause? group_by_clause? model_clause? order_by_clause? fetch_clause? + : SELECT (DISTINCT | UNIQUE | ALL)? selected_list into_clause? from_clause where_clause? hierarchical_query_clause? group_by_clause? model_clause? + order_by_clause? fetch_clause? ; selected_list @@ -5699,14 +5806,16 @@ table_ref_aux ; table_ref_aux_internal - : dml_table_expression_clause (pivot_clause | unpivot_clause)? # table_ref_aux_internal_one - | '(' table_ref subquery_operation_part* ')' (pivot_clause | unpivot_clause)? # table_ref_aux_internal_two - | ONLY '(' dml_table_expression_clause ')' # table_ref_aux_internal_three + : dml_table_expression_clause (pivot_clause | unpivot_clause)? # table_ref_aux_internal_one + | '(' table_ref subquery_operation_part* ')' (pivot_clause | unpivot_clause)? # table_ref_aux_internal_two + | ONLY '(' dml_table_expression_clause ')' # table_ref_aux_internal_three ; join_clause - : query_partition_clause? (CROSS | NATURAL)? (INNER | outer_join_type)? - JOIN table_ref_aux query_partition_clause? (join_on_part | join_using_part)* + : query_partition_clause? (CROSS | NATURAL)? (INNER | outer_join_type)? JOIN table_ref_aux query_partition_clause? ( + join_on_part + | join_using_part + )* ; join_on_part @@ -5756,8 +5865,7 @@ pivot_in_clause_elements ; unpivot_clause - : UNPIVOT ((INCLUDE | EXCLUDE) NULLS)? - '(' (column_name | paren_column_list) pivot_for_clause unpivot_in_clause ')' + : UNPIVOT ((INCLUDE | EXCLUDE) NULLS)? '(' (column_name | paren_column_list) pivot_for_clause unpivot_in_clause ')' ; unpivot_in_clause @@ -5765,8 +5873,7 @@ unpivot_in_clause ; unpivot_in_elements - : (column_name | paren_column_list) - (AS (constant | '(' constant (',' constant)* ')'))? + : (column_name | paren_column_list) (AS (constant | '(' constant (',' constant)* ')'))? ; hierarchical_query_clause @@ -5837,7 +5944,7 @@ model_column_partition_part ; model_column_list - : '(' model_column (',' model_column)* ')' + : '(' model_column (',' model_column)* ')' ; model_column @@ -5905,8 +6012,10 @@ update_statement // Update Specific Clauses update_set_clause - : SET - (column_based_update_set_clause (',' column_based_update_set_clause)* | VALUE '(' identifier ')' '=' expression) + : SET ( + column_based_update_set_clause (',' column_based_update_set_clause)* + | VALUE '(' identifier ')' '=' expression + ) ; column_based_update_set_clause @@ -5957,9 +6066,10 @@ values_clause ; merge_statement - : MERGE INTO tableview_name table_alias? USING selected_tableview ON '(' condition ')' - (merge_update_clause merge_insert_clause? | merge_insert_clause merge_update_clause?)? - error_logging_clause? + : MERGE INTO tableview_name table_alias? USING selected_tableview ON '(' condition ')' ( + merge_update_clause merge_insert_clause? + | merge_insert_clause merge_update_clause? + )? error_logging_clause? ; // Merge Specific Clauses @@ -5977,8 +6087,7 @@ merge_update_delete_part ; merge_insert_clause - : WHEN NOT MATCHED THEN INSERT paren_column_list? - values_clause where_clause? + : WHEN NOT MATCHED THEN INSERT paren_column_list? values_clause where_clause? ; selected_tableview @@ -6061,7 +6170,7 @@ condition ; json_condition - : column_name IS NOT? JSON (FORMAT JSON)? (STRICT|LAX)? ((WITH|WITHOUT) UNIQUE KEYS)? + : column_name IS NOT? JSON (FORMAT JSON)? (STRICT | LAX)? ((WITH | WITHOUT) UNIQUE KEYS)? | JSON_EQUAL '(' expressions ')' ; @@ -6092,16 +6201,20 @@ unary_logical_operation : IS NOT? logical_operation ; -logical_operation: - ( NULL_ - | NAN | PRESENT - | INFINITE | A_LETTER SET | EMPTY_ - | OF TYPE? '(' ONLY? type_spec (',' type_spec)* ')' +logical_operation + : ( + NULL_ + | NAN + | PRESENT + | INFINITE + | A_LETTER SET + | EMPTY_ + | OF TYPE? '(' ONLY? type_spec (',' type_spec)* ')' ) ; multiset_expression - : relational_expression (multiset_type=(MEMBER | SUBMULTISET) OF? concatenation)? + : relational_expression (multiset_type = (MEMBER | SUBMULTISET) OF? concatenation)? ; relational_expression @@ -6110,10 +6223,13 @@ relational_expression ; compound_expression - : concatenation - (NOT? ( IN in_elements + : concatenation ( + NOT? ( + IN in_elements | BETWEEN between_elements - | like_type=(LIKE | LIKEC | LIKE2 | LIKE4) concatenation (ESCAPE concatenation)?))? + | like_type = (LIKE | LIKEC | LIKE2 | LIKE4) concatenation (ESCAPE concatenation)? + ) + )? ; relational_operator @@ -6135,11 +6251,11 @@ between_elements ; concatenation - : model_expression - (AT (LOCAL | TIME ZONE concatenation) | interval_expression)? - (ON OVERFLOW (TRUNCATE | ERROR))? - | concatenation op=(ASTERISK | SOLIDUS) concatenation - | concatenation op=(PLUS_SIGN | MINUS_SIGN) concatenation + : model_expression (AT (LOCAL | TIME ZONE concatenation) | interval_expression)? ( + ON OVERFLOW (TRUNCATE | ERROR) + )? + | concatenation op = (ASTERISK | SOLIDUS) concatenation + | concatenation op = (PLUS_SIGN | MINUS_SIGN) concatenation | concatenation BAR BAR concatenation ; @@ -6160,15 +6276,17 @@ model_expression_element ; single_column_for_loop - : FOR column_name - ( IN '(' expressions? ')' - | (LIKE expression)? FROM fromExpr=expression TO toExpr=expression - action_type=(INCREMENT | DECREMENT) action_expr=expression) + : FOR column_name ( + IN '(' expressions? ')' + | (LIKE expression)? FROM fromExpr = expression TO toExpr = expression action_type = ( + INCREMENT + | DECREMENT + ) action_expr = expression + ) ; multi_column_for_loop - : FOR paren_column_list - IN '(' (subquery | '(' expressions? ')') ')' + : FOR paren_column_list IN '(' (subquery | '(' expressions? ')') ')' ; unary_expression @@ -6176,12 +6294,12 @@ unary_expression | PRIOR unary_expression | CONNECT_BY_ROOT unary_expression | /*TODO {input.LT(1).getText().equalsIgnoreCase("new") && !input.LT(2).getText().equals(".")}?*/ NEW unary_expression - | DISTINCT unary_expression - | ALL unary_expression - | /*TODO{(input.LA(1) == CASE || input.LA(2) == CASE)}?*/ case_statement/*[false]*/ - | quantified_expression - | standard_function - | atom + | DISTINCT unary_expression + | ALL unary_expression + | /*TODO{(input.LA(1) == CASE || input.LA(2) == CASE)}?*/ case_statement /*[false]*/ + | quantified_expression + | standard_function + | atom ; case_statement /*TODO [boolean isStatementParameter] @@ -6196,7 +6314,7 @@ TODO scope { // CASE simple_case_statement - : label_name? ck1=CASE expression simple_case_when_part+ case_else_part? END CASE? label_name? + : label_name? ck1 = CASE expression simple_case_when_part+ case_else_part? END CASE? label_name? ; simple_case_when_part @@ -6204,7 +6322,7 @@ simple_case_when_part ; searched_case_statement - : label_name? ck1=CASE searched_case_when_part+ case_else_part? END CASE? label_name? + : label_name? ck1 = CASE searched_case_when_part+ case_else_part? END CASE? label_name? ; searched_case_when_part @@ -6229,14 +6347,16 @@ quantified_expression string_function : SUBSTR '(' expression ',' expression (',' expression)? ')' - | TO_CHAR '(' (table_element | standard_function | expression) - (',' quoted_string)? (',' quoted_string)? ')' - | DECODE '(' expressions ')' + | TO_CHAR '(' (table_element | standard_function | expression) (',' quoted_string)? ( + ',' quoted_string + )? ')' + | DECODE '(' expressions ')' | CHR '(' concatenation USING NCHAR_CS ')' | NVL '(' expression ',' expression ')' | TRIM '(' ((LEADING | TRAILING | BOTH)? expression? FROM)? concatenation ')' - | TO_DATE '(' (table_element | standard_function | expression) - (DEFAULT concatenation ON CONVERSION ERROR)? (',' quoted_string (',' quoted_string)? )? ')' + | TO_DATE '(' (table_element | standard_function | expression) ( + DEFAULT concatenation ON CONVERSION ERROR + )? (',' quoted_string (',' quoted_string)?)? ')' ; standard_function @@ -6248,18 +6368,29 @@ standard_function //see as https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/JSON_ARRAY.html#GUID-46CDB3AF-5795-455B-85A8-764528CEC43B json_function - : JSON_ARRAY '(' json_array_element ( ',' json_array_element)* json_on_null_clause? json_return_clause? STRICT? ')' + : JSON_ARRAY '(' json_array_element (',' json_array_element)* json_on_null_clause? json_return_clause? STRICT? ')' | JSON_ARRAYAGG '(' expression (FORMAT JSON)? order_by_clause? json_on_null_clause? json_return_clause? STRICT? ')' | JSON_OBJECT '(' json_object_content ')' - | JSON_OBJECTAGG '(' KEY? expression VALUE expression ((NULL_ | ABSENT) ON NULL_)? (RETURNING ( VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR )? ')')? | CLOB | BLOB ))? STRICT? (WITH UNIQUE KEYS)?')' - | JSON_QUERY '(' expression (FORMAT JSON)? ',' CHAR_STRING json_query_returning_clause json_query_wrapper_clause? json_query_on_error_clause? json_query_on_empty_clause? ')' - | JSON_SERIALIZE '(' CHAR_STRING (RETURNING json_query_return_type)? PRETTY? ASCII? TRUNCATE? ((NULL_ | ERROR | EMPTY_ (ARRAY | OBJECT)) ON ERROR)? ')' + | JSON_OBJECTAGG '(' KEY? expression VALUE expression ((NULL_ | ABSENT) ON NULL_)? ( + RETURNING (VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR)? ')')? | CLOB | BLOB) + )? STRICT? (WITH UNIQUE KEYS)? ')' + | JSON_QUERY '(' expression (FORMAT JSON)? ',' CHAR_STRING json_query_returning_clause json_query_wrapper_clause? json_query_on_error_clause? + json_query_on_empty_clause? ')' + | JSON_SERIALIZE '(' CHAR_STRING (RETURNING json_query_return_type)? PRETTY? ASCII? TRUNCATE? ( + (NULL_ | ERROR | EMPTY_ (ARRAY | OBJECT)) ON ERROR + )? ')' | JSON_TRANSFORM '(' expression ',' json_transform_op (',' json_transform_op)* ')' - | JSON_VALUE '(' expression (FORMAT JSON)? (',' CHAR_STRING? json_value_return_clause? ((ERROR | NULL_ | DEFAULT literal)? ON ERROR)? ((ERROR | NULL_ | DEFAULT literal)? ON EMPTY_)? json_value_on_mismatch_clause?')')? + | JSON_VALUE '(' expression (FORMAT JSON)? ( + ',' CHAR_STRING? json_value_return_clause? ((ERROR | NULL_ | DEFAULT literal)? ON ERROR)? ( + (ERROR | NULL_ | DEFAULT literal)? ON EMPTY_ + )? json_value_on_mismatch_clause? ')' + )? ; json_object_content - : (json_object_entry (',' json_object_entry)* | '*') json_on_null_clause? json_return_clause? STRICT? (WITH UNIQUE KEYS)? + : (json_object_entry (',' json_object_entry)* | '*') json_on_null_clause? json_return_clause? STRICT? ( + WITH UNIQUE KEYS + )? ; json_object_entry @@ -6269,11 +6400,13 @@ json_object_entry ; json_table_clause - : JSON_TABLE '(' expression (FORMAT JSON)? (',' CHAR_STRING)? ((ERROR | NULL_) ON ERROR)? ((EMPTY_ | NULL_) ON EMPTY_)? json_column_clause? ')' + : JSON_TABLE '(' expression (FORMAT JSON)? (',' CHAR_STRING)? ((ERROR | NULL_) ON ERROR)? ( + (EMPTY_ | NULL_) ON EMPTY_ + )? json_column_clause? ')' ; json_array_element - : (expression | CHAR_STRING | NULL_ | UNSIGNED_INTEGER | json_function) (FORMAT JSON)? + : (expression | CHAR_STRING | NULL_ | UNSIGNED_INTEGER | json_function) (FORMAT JSON)? ; json_on_null_clause @@ -6281,16 +6414,24 @@ json_on_null_clause ; json_return_clause - : RETURNING ( VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR )? ')')? | CLOB | BLOB ) + : RETURNING (VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR)? ')')? | CLOB | BLOB) ; json_transform_op : REMOVE CHAR_STRING ((IGNORE | ERROR)? ON MISSING)? - | INSERT CHAR_STRING '=' CHAR_STRING ((REPLACE | IGNORE | ERROR) ON EXISTING)? ((NULL_ | IGNORE | ERROR | REMOVE)? ON NULL_)? - | REPLACE CHAR_STRING '=' CHAR_STRING ((CREATE | IGNORE | ERROR) ON MISSING)? ((NULL_ | IGNORE | ERROR)? ON NULL_)? + | INSERT CHAR_STRING '=' CHAR_STRING ((REPLACE | IGNORE | ERROR) ON EXISTING)? ( + (NULL_ | IGNORE | ERROR | REMOVE)? ON NULL_ + )? + | REPLACE CHAR_STRING '=' CHAR_STRING ((CREATE | IGNORE | ERROR) ON MISSING)? ( + (NULL_ | IGNORE | ERROR)? ON NULL_ + )? | expression (FORMAT JSON)? - | APPEND CHAR_STRING '=' CHAR_STRING ((CREATE | IGNORE | ERROR) ON MISSING)? ((NULL_ | IGNORE | ERROR)? ON NULL_)? - | SET CHAR_STRING '=' expression (FORMAT JSON)? ((REPLACE | IGNORE | ERROR) ON EXISTING)? ((CREATE | IGNORE | ERROR) ON MISSING)? ((NULL_ | IGNORE | ERROR)? ON NULL_)? + | APPEND CHAR_STRING '=' CHAR_STRING ((CREATE | IGNORE | ERROR) ON MISSING)? ( + (NULL_ | IGNORE | ERROR)? ON NULL_ + )? + | SET CHAR_STRING '=' expression (FORMAT JSON)? ((REPLACE | IGNORE | ERROR) ON EXISTING)? ( + (CREATE | IGNORE | ERROR) ON MISSING + )? ((NULL_ | IGNORE | ERROR)? ON NULL_)? ; json_column_clause @@ -6298,8 +6439,9 @@ json_column_clause ; json_column_definition - : expression json_value_return_type? (EXISTS? PATH CHAR_STRING | TRUNCATE (PATH CHAR_STRING)?)? json_query_on_error_clause? json_query_on_empty_clause? - | expression json_query_return_type? TRUNCATE? FORMAT JSON json_query_wrapper_clause? PATH CHAR_STRING + : expression json_value_return_type? (EXISTS? PATH CHAR_STRING | TRUNCATE (PATH CHAR_STRING)?)? json_query_on_error_clause? + json_query_on_empty_clause? + | expression json_query_return_type? TRUNCATE? FORMAT JSON json_query_wrapper_clause? PATH CHAR_STRING | NESTED PATH? expression ('[' ASTERISK ']')? json_column_clause | expression FOR ORDINALITY ; @@ -6309,11 +6451,14 @@ json_query_returning_clause ; json_query_return_type - : VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR )? ')')? | CLOB | BLOB + : VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR)? ')')? + | CLOB + | BLOB ; json_query_wrapper_clause - : (WITHOUT ARRAY? WRAPPER) | (WITH (UNCONDITIONAL | CONDITIONAL)? ARRAY? WRAPPER) + : (WITHOUT ARRAY? WRAPPER) + | (WITH (UNCONDITIONAL | CONDITIONAL)? ARRAY? WRAPPER) ; json_query_on_error_clause @@ -6329,7 +6474,7 @@ json_value_return_clause ; json_value_return_type - : VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR )? ')')? TRUNCATE? + : VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR)? ')')? TRUNCATE? | CLOB | DATE | NUMBER '(' INTEGER (',' INTEGER)? ')' @@ -6354,14 +6499,14 @@ numeric_function_wrapper ; numeric_function - : SUM '(' (DISTINCT | ALL)? expression ')' - | COUNT '(' ( ASTERISK | ((DISTINCT | UNIQUE | ALL)? concatenation)? ) ')' over_clause? - | ROUND '(' expression (',' UNSIGNED_INTEGER)? ')' - | AVG '(' (DISTINCT | ALL)? expression ')' - | MAX '(' (DISTINCT | ALL)? expression ')' - | LEAST '(' expressions ')' - | GREATEST '(' expressions ')' - ; + : SUM '(' (DISTINCT | ALL)? expression ')' + | COUNT '(' (ASTERISK | ((DISTINCT | UNIQUE | ALL)? concatenation)?) ')' over_clause? + | ROUND '(' expression (',' UNSIGNED_INTEGER)? ')' + | AVG '(' (DISTINCT | ALL)? expression ')' + | MAX '(' (DISTINCT | ALL)? expression ')' + | LEAST '(' expressions ')' + | GREATEST '(' expressions ')' + ; listagg_overflow_clause : ON OVERFLOW (ERROR | TRUNCATE) CHAR_STRING? ((WITH | WITHOUT) COUNT)? @@ -6370,46 +6515,49 @@ listagg_overflow_clause other_function : over_clause_keyword function_argument_analytic over_clause? | /*TODO stantard_function_enabling_using*/ regular_id function_argument_modeling using_clause? - | COUNT '(' ( ASTERISK | (DISTINCT | UNIQUE | ALL)? concatenation) ')' over_clause? - | (CAST | XMLCAST) '(' (MULTISET '(' subquery ')' | concatenation) AS type_spec - (DEFAULT concatenation ON CONVERSION ERROR)? (',' quoted_string (',' quoted_string)? )? ')' + | COUNT '(' (ASTERISK | (DISTINCT | UNIQUE | ALL)? concatenation) ')' over_clause? + | (CAST | XMLCAST) '(' (MULTISET '(' subquery ')' | concatenation) AS type_spec ( + DEFAULT concatenation ON CONVERSION ERROR + )? (',' quoted_string (',' quoted_string)?)? ')' | COALESCE '(' table_element (',' (numeric | quoted_string))? ')' | COLLECT '(' (DISTINCT | UNIQUE)? concatenation collect_order_by_part? ')' | within_or_over_clause_keyword function_argument within_or_over_part+ - | LISTAGG '(' (ALL | DISTINCT | UNIQUE)? argument (',' CHAR_STRING)? listagg_overflow_clause? ')' - (WITHIN GROUP '(' order_by_clause ')')? over_clause? - | cursor_name ( PERCENT_ISOPEN | PERCENT_FOUND | PERCENT_NOTFOUND | PERCENT_ROWCOUNT ) + | LISTAGG '(' (ALL | DISTINCT | UNIQUE)? argument (',' CHAR_STRING)? listagg_overflow_clause? ')' ( + WITHIN GROUP '(' order_by_clause ')' + )? over_clause? + | cursor_name (PERCENT_ISOPEN | PERCENT_FOUND | PERCENT_NOTFOUND | PERCENT_ROWCOUNT) | DECOMPOSE '(' concatenation (CANONICAL | COMPATIBILITY)? ')' | EXTRACT '(' regular_id FROM concatenation ')' | (FIRST_VALUE | LAST_VALUE) function_argument_analytic respect_or_ignore_nulls? over_clause - | standard_prediction_function_keyword - '(' expressions cost_matrix_clause? using_clause? ')' - | (TO_BINARY_DOUBLE | TO_BINARY_FLOAT | TO_NUMBER | TO_TIMESTAMP | TO_TIMESTAMP_TZ) - '(' concatenation (DEFAULT concatenation ON CONVERSION ERROR)? (',' quoted_string (',' quoted_string)? )? ')' + | standard_prediction_function_keyword '(' expressions cost_matrix_clause? using_clause? ')' + | (TO_BINARY_DOUBLE | TO_BINARY_FLOAT | TO_NUMBER | TO_TIMESTAMP | TO_TIMESTAMP_TZ) '(' concatenation ( + DEFAULT concatenation ON CONVERSION ERROR + )? (',' quoted_string (',' quoted_string)?)? ')' | (TO_DSINTERVAL | TO_YMINTERVAL) '(' concatenation (DEFAULT concatenation ON CONVERSION ERROR)? ')' | TRANSLATE '(' expression (USING (CHAR_CS | NCHAR_CS))? (',' expression)* ')' | TREAT '(' expression AS REF? type_spec ')' | TRIM '(' ((LEADING | TRAILING | BOTH)? quoted_string? FROM)? concatenation ')' - | VALIDATE_CONVERSION '(' concatenation AS type_spec (',' quoted_string (',' quoted_string)? )? ')' + | VALIDATE_CONVERSION '(' concatenation AS type_spec (',' quoted_string (',' quoted_string)?)? ')' | XMLAGG '(' expression order_by_clause? ')' ('.' general_element_part)* - | (XMLCOLATTVAL | XMLFOREST) - '(' xml_multiuse_expression_element (',' xml_multiuse_expression_element)* ')' ('.' general_element_part)* - | XMLELEMENT - '(' (ENTITYESCAPING | NOENTITYESCAPING)? (NAME | EVALNAME)? expression - (/*TODO{input.LT(2).getText().equalsIgnoreCase("xmlattributes")}?*/ ',' xml_attributes_clause)? - (',' expression column_alias?)* ')' ('.' general_element_part)* + | (XMLCOLATTVAL | XMLFOREST) '(' xml_multiuse_expression_element ( + ',' xml_multiuse_expression_element + )* ')' ('.' general_element_part)* + | XMLELEMENT '(' (ENTITYESCAPING | NOENTITYESCAPING)? (NAME | EVALNAME)? expression ( + /*TODO{input.LT(2).getText().equalsIgnoreCase("xmlattributes")}?*/ ',' xml_attributes_clause + )? (',' expression column_alias?)* ')' ('.' general_element_part)* | XMLEXISTS '(' expression xml_passing_clause? ')' | XMLPARSE '(' (DOCUMENT | CONTENT) concatenation WELLFORMED? ')' ('.' general_element_part)* - | XMLPI - '(' (NAME identifier | EVALNAME concatenation) (',' concatenation)? ')' ('.' general_element_part)* - | XMLQUERY - '(' concatenation xml_passing_clause? RETURNING CONTENT (NULL_ ON EMPTY_)? ')' ('.' general_element_part)* - | XMLROOT - '(' concatenation (',' xmlroot_param_version_part)? (',' xmlroot_param_standalone_part)? ')' ('.' general_element_part)* - | XMLSERIALIZE - '(' (DOCUMENT | CONTENT) concatenation (AS type_spec)? - xmlserialize_param_enconding_part? xmlserialize_param_version_part? xmlserialize_param_ident_part? ((HIDE | SHOW) DEFAULTS)? ')' - ('.' general_element_part)? + | XMLPI '(' (NAME identifier | EVALNAME concatenation) (',' concatenation)? ')' ( + '.' general_element_part + )* + | XMLQUERY '(' concatenation xml_passing_clause? RETURNING CONTENT (NULL_ ON EMPTY_)? ')' ( + '.' general_element_part + )* + | XMLROOT '(' concatenation (',' xmlroot_param_version_part)? ( + ',' xmlroot_param_standalone_part + )? ')' ('.' general_element_part)* + | XMLSERIALIZE '(' (DOCUMENT | CONTENT) concatenation (AS type_spec)? xmlserialize_param_enconding_part? xmlserialize_param_version_part? + xmlserialize_param_ident_part? ((HIDE | SHOW) DEFAULTS)? ')' ('.' general_element_part)? | TIME CHAR_STRING | xmltable ; @@ -6454,15 +6602,14 @@ standard_prediction_function_keyword ; over_clause - : OVER '(' ( query_partition_clause? (order_by_clause windowing_clause?)? - | HIERARCHY th=id_expression OFFSET numeric (ACROSS ANCESTOR AT LEVEL id_expression)? - ) - ')' + : OVER '(' ( + query_partition_clause? (order_by_clause windowing_clause?)? + | HIERARCHY th = id_expression OFFSET numeric (ACROSS ANCESTOR AT LEVEL id_expression)? + ) ')' ; windowing_clause - : windowing_type - (BETWEEN windowing_elements AND windowing_elements | windowing_elements) + : windowing_type (BETWEEN windowing_elements AND windowing_elements | windowing_elements) ; windowing_type @@ -6494,7 +6641,10 @@ within_or_over_part ; cost_matrix_clause - : COST (MODEL AUTO? | '(' cost_class_name (',' cost_class_name)* ')' VALUES '(' expressions? ')') + : COST ( + MODEL AUTO? + | '(' cost_class_name (',' cost_class_name)* ')' VALUES '(' expressions? ')' + ) ; xml_passing_clause @@ -6502,19 +6652,17 @@ xml_passing_clause ; xml_attributes_clause - : XMLATTRIBUTES - '(' (ENTITYESCAPING | NOENTITYESCAPING)? (SCHEMACHECK | NOSCHEMACHECK)? - xml_multiuse_expression_element (',' xml_multiuse_expression_element)* ')' + : XMLATTRIBUTES '(' (ENTITYESCAPING | NOENTITYESCAPING)? (SCHEMACHECK | NOSCHEMACHECK)? xml_multiuse_expression_element ( + ',' xml_multiuse_expression_element + )* ')' ; xml_namespaces_clause - : XMLNAMESPACES - '(' (concatenation column_alias)? (',' concatenation column_alias)* xml_general_default_part? ')' + : XMLNAMESPACES '(' (concatenation column_alias)? (',' concatenation column_alias)* xml_general_default_part? ')' ; xml_table_column - : xml_column_name - (FOR ORDINALITY | type_spec (PATH concatenation)? xml_general_default_part?) + : xml_column_name (FOR ORDINALITY | type_spec (PATH concatenation)? xml_general_default_part?) ; xml_general_default_part @@ -6551,6 +6699,7 @@ xmlserialize_param_ident_part sql_plus_command_no_semicolon : set_command ; + sql_plus_command : EXIT | PROMPT_MESSAGE @@ -6565,17 +6714,18 @@ start_command ; whenever_command - : WHENEVER (SQLERROR | OSERROR) - ( EXIT (SUCCESS | FAILURE | WARNING | variable_name | numeric) (COMMIT | ROLLBACK)? - | CONTINUE (COMMIT | ROLLBACK | NONE)?) + : WHENEVER (SQLERROR | OSERROR) ( + EXIT (SUCCESS | FAILURE | WARNING | variable_name | numeric) (COMMIT | ROLLBACK)? + | CONTINUE (COMMIT | ROLLBACK | NONE)? + ) ; set_command - : SET regular_id (CHAR_STRING | ON | OFF | /*EXACT_NUM_LIT*/numeric | regular_id) + : SET regular_id (CHAR_STRING | ON | OFF | /*EXACT_NUM_LIT*/ numeric | regular_id) ; timing_command - : TIMING (START timing_text=id_expression* | SHOW | STOP)? + : TIMING (START timing_text = id_expression* | SHOW | STOP)? ; // Common @@ -6603,7 +6753,9 @@ quantitative_where_stmt ; into_clause - : (BULK COLLECT)? INTO (general_element | bind_variable) (',' (general_element | bind_variable))* + : (BULK COLLECT)? INTO (general_element | bind_variable) ( + ',' (general_element | bind_variable) + )* ; // Common Named Elements @@ -6746,13 +6898,17 @@ column_name ; tableview_name - : identifier ('.' id_expression)? - (AT_SIGN link_name (PERIOD link_name)* | /*TODO{!(input.LA(2) == BY)}?*/ partition_extension_clause)? + : identifier ('.' id_expression)? ( + AT_SIGN link_name (PERIOD link_name)* + | /*TODO{!(input.LA(2) == BY)}?*/ partition_extension_clause + )? | xmltable outer_join_sign? ; xmltable - : XMLTABLE '(' (xml_namespaces_clause ',')? concatenation xml_passing_clause? (COLUMNS xml_table_column (',' xml_table_column)*)? ')' ('.' general_element_part)? + : XMLTABLE '(' (xml_namespaces_clause ',')? concatenation xml_passing_clause? ( + COLUMNS xml_table_column (',' xml_table_column)* + )? ')' ('.' general_element_part)? ; char_set_name @@ -6812,9 +6968,11 @@ function_argument_analytic ; function_argument_modeling - : '(' column_name (',' (numeric | NULL_) (',' (numeric | NULL_))?)? - USING (tableview_name '.' ASTERISK | ASTERISK | expression column_alias? (',' expression column_alias?)*) - ')' keep_clause? + : '(' column_name (',' (numeric | NULL_) (',' (numeric | NULL_))?)? USING ( + tableview_name '.' ASTERISK + | ASTERISK + | expression column_alias? (',' expression column_alias?)* + ) ')' keep_clause? ; respect_or_ignore_nulls @@ -6899,9 +7057,8 @@ native_datatype_element bind_variable : (BINDVAR | ':' UNSIGNED_INTEGER) - // Pro*C/C++ indicator variables - (INDICATOR? (BINDVAR | ':' UNSIGNED_INTEGER))? - ('.' general_element_part)* + // Pro*C/C++ indicator variables + (INDICATOR? (BINDVAR | ':' UNSIGNED_INTEGER))? ('.' general_element_part)* ; general_element @@ -6993,7 +7150,7 @@ system_privilege | SET CONTAINER | CREATE ANY? PROCEDURE | (ALTER | DROP | EXECUTE) ANY PROCEDURE - | (CREATE | ALTER | DROP ) PROFILE + | (CREATE | ALTER | DROP) PROFILE | CREATE ROLE | (ALTER | DROP | GRANT) ANY ROLE | (CREATE | ALTER | DROP) ROLLBACK SEGMENT @@ -7043,10 +7200,16 @@ system_privilege constant : TIMESTAMP (quoted_string | bind_variable) (AT TIME ZONE quoted_string)? - | INTERVAL (quoted_string | bind_variable | general_element_part) - (YEAR | MONTH | DAY | HOUR | MINUTE | SECOND) - ('(' (UNSIGNED_INTEGER | bind_variable) (',' (UNSIGNED_INTEGER | bind_variable) )? ')')? - (TO ( DAY | HOUR | MINUTE | SECOND ('(' (UNSIGNED_INTEGER | bind_variable) ')')?))? + | INTERVAL (quoted_string | bind_variable | general_element_part) ( + YEAR + | MONTH + | DAY + | HOUR + | MINUTE + | SECOND + ) ('(' (UNSIGNED_INTEGER | bind_variable) (',' (UNSIGNED_INTEGER | bind_variable))? ')')? ( + TO (DAY | HOUR | MINUTE | SECOND ('(' (UNSIGNED_INTEGER | bind_variable) ')')?) + )? | numeric | DATE quoted_string | quoted_string @@ -9339,4 +9502,4 @@ numeric_function_name | NVL | ROUND | SUM - ; + ; \ No newline at end of file diff --git a/sql/postgresql/PostgreSQLLexer.g4 b/sql/postgresql/PostgreSQLLexer.g4 index 6fa6733ee4..1c9d9ce21a 100644 --- a/sql/postgresql/PostgreSQLLexer.g4 +++ b/sql/postgresql/PostgreSQLLexer.g4 @@ -28,21 +28,24 @@ https://github.com/tunnelvisionlabs/antlr4-grammar-postgresql/blob/master/src/co * promote the sale, use or other dealings in this Software without prior * written authorization from Tunnel Vision Laboratories, LLC. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar PostgreSQLLexer; /* Reference: * http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html */ options { - superClass = PostgreSQLLexerBase; - caseInsensitive = true; + superClass = PostgreSQLLexerBase; + caseInsensitive = true; } -@ header -{ +@header { } -@ members -{ +@members { /* This field stores the tags which are used to detect the end of a dollar-quoted string literal. */ } @@ -56,138 +59,85 @@ options { // that are not expressions. -Dollar - : '$' - ; - -OPEN_PAREN - : '(' - ; - -CLOSE_PAREN - : ')' - ; +Dollar: '$'; -OPEN_BRACKET - : '[' - ; +OPEN_PAREN: '('; -CLOSE_BRACKET - : ']' - ; +CLOSE_PAREN: ')'; -COMMA - : ',' - ; +OPEN_BRACKET: '['; -SEMI - : ';' - ; +CLOSE_BRACKET: ']'; -COLON - : ':' - ; +COMMA: ','; -STAR - : '*' - ; +SEMI: ';'; -EQUAL - : '=' - ; +COLON: ':'; -DOT - : '.' - ; - //NamedArgument : ':='; +STAR: '*'; -PLUS - : '+' - ; +EQUAL: '='; -MINUS - : '-' - ; +DOT: '.'; +//NamedArgument : ':='; -SLASH - : '/' - ; +PLUS: '+'; -CARET - : '^' - ; +MINUS: '-'; -LT - : '<' - ; +SLASH: '/'; -GT - : '>' - ; +CARET: '^'; -LESS_LESS - : '<<' - ; +LT: '<'; -GREATER_GREATER - : '>>' - ; +GT: '>'; -COLON_EQUALS - : ':=' - ; +LESS_LESS: '<<'; -LESS_EQUALS - : '<=' - ; +GREATER_GREATER: '>>'; -EQUALS_GREATER - : '=>' - ; +COLON_EQUALS: ':='; -GREATER_EQUALS - : '>=' - ; +LESS_EQUALS: '<='; -DOT_DOT - : '..' - ; +EQUALS_GREATER: '=>'; -NOT_EQUALS - : '<>' - ; +GREATER_EQUALS: '>='; -TYPECAST - : '::' - ; +DOT_DOT: '..'; -PERCENT - : '%' - ; +NOT_EQUALS: '<>'; -PARAM - : '$' ([0-9])+ - ; - // +TYPECAST: '::'; - // OPERATORS (4.1.3) +PERCENT: '%'; - // +PARAM: '$' ([0-9])+; +// - // this rule does not allow + or - at the end of a multi-character operator +// OPERATORS (4.1.3) -Operator - : ((OperatorCharacter | ('+' | '-' - {checkLA('-')}?)+ (OperatorCharacter | '/' - {checkLA('*')}?) | '/' - {checkLA('*')}?)+ | // special handling for the single-character operators + and - - [+-]) - //TODO somehow rewrite this part without using Actions +// - { +// this rule does not allow + or - at the end of a multi-character operator + +Operator: + ( + ( + OperatorCharacter + | ('+' | '-' {checkLA('-')}?)+ (OperatorCharacter | '/' {checkLA('*')}?) + | '/' {checkLA('*')}? + )+ + | // special handling for the single-character operators + and - + [+-] + ) + //TODO somehow rewrite this part without using Actions + { HandleLessLessGreaterGreater(); } - ; +; /* This rule handles operators which end with + or -, and sets the token type to Operator. It is comprised of four * parts, in order: * @@ -199,2546 +149,1307 @@ Operator * 4. A suffix sequence of + and - characters. */ +OperatorEndingWithPlusMinus: + (OperatorCharacterNotAllowPlusMinusAtEnd | '-' {checkLA('-')}? | '/' {checkLA('*')}?)* OperatorCharacterAllowPlusMinusAtEnd Operator? ( + '+' + | '-' {checkLA('-')}? + )+ -> type (Operator) +; +// Each of the following fragment rules omits the +, -, and / characters, which must always be handled in a special way + +// by the operator rules above. + +fragment OperatorCharacter: [*<>=~!@%^&|`?#]; +// these are the operator characters that don't count towards one ending with + or - + +fragment OperatorCharacterNotAllowPlusMinusAtEnd: [*<>=+]; +// an operator may end with + or - if it contains one of these characters + +fragment OperatorCharacterAllowPlusMinusAtEnd: [~!@%^&|`?#]; +// + +// KEYWORDS (Appendix C) + +// + +// + +// reserved keywords + +// + +ALL: 'ALL'; -OperatorEndingWithPlusMinus - : (OperatorCharacterNotAllowPlusMinusAtEnd | '-' - {checkLA('-')}? | '/' - {checkLA('*')}?)* OperatorCharacterAllowPlusMinusAtEnd Operator? ('+' | '-' - {checkLA('-')}?)+ -> type (Operator) - ; - // Each of the following fragment rules omits the +, -, and / characters, which must always be handled in a special way +ANALYSE: 'ANALYSE'; - // by the operator rules above. +ANALYZE: 'ANALYZE'; -fragment OperatorCharacter - : [*<>=~!@%^&|`?#] - ; - // these are the operator characters that don't count towards one ending with + or - +AND: 'AND'; -fragment OperatorCharacterNotAllowPlusMinusAtEnd - : [*<>=+] - ; - // an operator may end with + or - if it contains one of these characters +ANY: 'ANY'; -fragment OperatorCharacterAllowPlusMinusAtEnd - : [~!@%^&|`?#] - ; - // +ARRAY: 'ARRAY'; - // KEYWORDS (Appendix C) +AS: 'AS'; - // +ASC: 'ASC'; - // +ASYMMETRIC: 'ASYMMETRIC'; - // reserved keywords +BOTH: 'BOTH'; - // +CASE: 'CASE'; -ALL - : 'ALL' - ; +CAST: 'CAST'; -ANALYSE - : 'ANALYSE' - ; +CHECK: 'CHECK'; -ANALYZE - : 'ANALYZE' - ; +COLLATE: 'COLLATE'; -AND - : 'AND' - ; +COLUMN: 'COLUMN'; -ANY - : 'ANY' - ; +CONSTRAINT: 'CONSTRAINT'; -ARRAY - : 'ARRAY' - ; +CREATE: 'CREATE'; -AS - : 'AS' - ; +CURRENT_CATALOG: 'CURRENT_CATALOG'; -ASC - : 'ASC' - ; +CURRENT_DATE: 'CURRENT_DATE'; -ASYMMETRIC - : 'ASYMMETRIC' - ; +CURRENT_ROLE: 'CURRENT_ROLE'; -BOTH - : 'BOTH' - ; +CURRENT_TIME: 'CURRENT_TIME'; -CASE - : 'CASE' - ; +CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -CAST - : 'CAST' - ; +CURRENT_USER: 'CURRENT_USER'; -CHECK - : 'CHECK' - ; +DEFAULT: 'DEFAULT'; -COLLATE - : 'COLLATE' - ; +DEFERRABLE: 'DEFERRABLE'; -COLUMN - : 'COLUMN' - ; +DESC: 'DESC'; -CONSTRAINT - : 'CONSTRAINT' - ; +DISTINCT: 'DISTINCT'; -CREATE - : 'CREATE' - ; +DO: 'DO'; -CURRENT_CATALOG - : 'CURRENT_CATALOG' - ; +ELSE: 'ELSE'; -CURRENT_DATE - : 'CURRENT_DATE' - ; +EXCEPT: 'EXCEPT'; -CURRENT_ROLE - : 'CURRENT_ROLE' - ; +FALSE_P: 'FALSE'; -CURRENT_TIME - : 'CURRENT_TIME' - ; +FETCH: 'FETCH'; -CURRENT_TIMESTAMP - : 'CURRENT_TIMESTAMP' - ; +FOR: 'FOR'; -CURRENT_USER - : 'CURRENT_USER' - ; +FOREIGN: 'FOREIGN'; -DEFAULT - : 'DEFAULT' - ; +FROM: 'FROM'; -DEFERRABLE - : 'DEFERRABLE' - ; +GRANT: 'GRANT'; -DESC - : 'DESC' - ; +GROUP_P: 'GROUP'; -DISTINCT - : 'DISTINCT' - ; +HAVING: 'HAVING'; -DO - : 'DO' - ; +IN_P: 'IN'; -ELSE - : 'ELSE' - ; +INITIALLY: 'INITIALLY'; -EXCEPT - : 'EXCEPT' - ; +INTERSECT: 'INTERSECT'; -FALSE_P - : 'FALSE' - ; +INTO: 'INTO'; -FETCH - : 'FETCH' - ; +LATERAL_P: 'LATERAL'; -FOR - : 'FOR' - ; +LEADING: 'LEADING'; -FOREIGN - : 'FOREIGN' - ; +LIMIT: 'LIMIT'; -FROM - : 'FROM' - ; +LOCALTIME: 'LOCALTIME'; -GRANT - : 'GRANT' - ; +LOCALTIMESTAMP: 'LOCALTIMESTAMP'; -GROUP_P - : 'GROUP' - ; +NOT: 'NOT'; -HAVING - : 'HAVING' - ; +NULL_P: 'NULL'; -IN_P - : 'IN' - ; +OFFSET: 'OFFSET'; -INITIALLY - : 'INITIALLY' - ; +ON: 'ON'; -INTERSECT - : 'INTERSECT' - ; +ONLY: 'ONLY'; -INTO - : 'INTO' - ; +OR: 'OR'; -LATERAL_P - : 'LATERAL' - ; +ORDER: 'ORDER'; -LEADING - : 'LEADING' - ; +PLACING: 'PLACING'; -LIMIT - : 'LIMIT' - ; +PRIMARY: 'PRIMARY'; -LOCALTIME - : 'LOCALTIME' - ; +REFERENCES: 'REFERENCES'; -LOCALTIMESTAMP - : 'LOCALTIMESTAMP' - ; +RETURNING: 'RETURNING'; -NOT - : 'NOT' - ; +SELECT: 'SELECT'; -NULL_P - : 'NULL' - ; +SESSION_USER: 'SESSION_USER'; -OFFSET - : 'OFFSET' - ; +SOME: 'SOME'; -ON - : 'ON' - ; +SYMMETRIC: 'SYMMETRIC'; -ONLY - : 'ONLY' - ; +TABLE: 'TABLE'; -OR - : 'OR' - ; +THEN: 'THEN'; -ORDER - : 'ORDER' - ; +TO: 'TO'; -PLACING - : 'PLACING' - ; +TRAILING: 'TRAILING'; -PRIMARY - : 'PRIMARY' - ; +TRUE_P: 'TRUE'; -REFERENCES - : 'REFERENCES' - ; +UNION: 'UNION'; -RETURNING - : 'RETURNING' - ; +UNIQUE: 'UNIQUE'; -SELECT - : 'SELECT' - ; +USER: 'USER'; -SESSION_USER - : 'SESSION_USER' - ; +USING: 'USING'; -SOME - : 'SOME' - ; +VARIADIC: 'VARIADIC'; -SYMMETRIC - : 'SYMMETRIC' - ; +WHEN: 'WHEN'; -TABLE - : 'TABLE' - ; +WHERE: 'WHERE'; + +WINDOW: 'WINDOW'; + +WITH: 'WITH'; + +// -THEN - : 'THEN' - ; +// reserved keywords (can be function or type) -TO - : 'TO' - ; +// -TRAILING - : 'TRAILING' - ; +AUTHORIZATION: 'AUTHORIZATION'; -TRUE_P - : 'TRUE' - ; +BINARY: 'BINARY'; -UNION - : 'UNION' - ; +COLLATION: 'COLLATION'; -UNIQUE - : 'UNIQUE' - ; +CONCURRENTLY: 'CONCURRENTLY'; -USER - : 'USER' - ; +CROSS: 'CROSS'; -USING - : 'USING' - ; +CURRENT_SCHEMA: 'CURRENT_SCHEMA'; -VARIADIC - : 'VARIADIC' - ; +FREEZE: 'FREEZE'; -WHEN - : 'WHEN' - ; +FULL: 'FULL'; -WHERE - : 'WHERE' - ; +ILIKE: 'ILIKE'; -WINDOW - : 'WINDOW' - ; +INNER_P: 'INNER'; -WITH - : 'WITH' - ; +IS: 'IS'; - // +ISNULL: 'ISNULL'; - // reserved keywords (can be function or type) +JOIN: 'JOIN'; - // +LEFT: 'LEFT'; -AUTHORIZATION - : 'AUTHORIZATION' - ; +LIKE: 'LIKE'; -BINARY - : 'BINARY' - ; +NATURAL: 'NATURAL'; -COLLATION - : 'COLLATION' - ; +NOTNULL: 'NOTNULL'; -CONCURRENTLY - : 'CONCURRENTLY' - ; +OUTER_P: 'OUTER'; -CROSS - : 'CROSS' - ; +OVER: 'OVER'; -CURRENT_SCHEMA - : 'CURRENT_SCHEMA' - ; +OVERLAPS: 'OVERLAPS'; -FREEZE - : 'FREEZE' - ; +RIGHT: 'RIGHT'; -FULL - : 'FULL' - ; +SIMILAR: 'SIMILAR'; -ILIKE - : 'ILIKE' - ; +VERBOSE: 'VERBOSE'; +// -INNER_P - : 'INNER' - ; +// non-reserved keywords -IS - : 'IS' - ; +// -ISNULL - : 'ISNULL' - ; +ABORT_P: 'ABORT'; -JOIN - : 'JOIN' - ; +ABSOLUTE_P: 'ABSOLUTE'; -LEFT - : 'LEFT' - ; +ACCESS: 'ACCESS'; -LIKE - : 'LIKE' - ; +ACTION: 'ACTION'; -NATURAL - : 'NATURAL' - ; +ADD_P: 'ADD'; -NOTNULL - : 'NOTNULL' - ; +ADMIN: 'ADMIN'; -OUTER_P - : 'OUTER' - ; +AFTER: 'AFTER'; -OVER - : 'OVER' - ; +AGGREGATE: 'AGGREGATE'; -OVERLAPS - : 'OVERLAPS' - ; +ALSO: 'ALSO'; -RIGHT - : 'RIGHT' - ; +ALTER: 'ALTER'; -SIMILAR - : 'SIMILAR' - ; +ALWAYS: 'ALWAYS'; -VERBOSE - : 'VERBOSE' - ; - // +ASSERTION: 'ASSERTION'; - // non-reserved keywords +ASSIGNMENT: 'ASSIGNMENT'; - // +AT: 'AT'; -ABORT_P - : 'ABORT' - ; +ATTRIBUTE: 'ATTRIBUTE'; -ABSOLUTE_P - : 'ABSOLUTE' - ; +BACKWARD: 'BACKWARD'; -ACCESS - : 'ACCESS' - ; +BEFORE: 'BEFORE'; -ACTION - : 'ACTION' - ; +BEGIN_P: 'BEGIN'; -ADD_P - : 'ADD' - ; +BY: 'BY'; -ADMIN - : 'ADMIN' - ; +CACHE: 'CACHE'; -AFTER - : 'AFTER' - ; +CALLED: 'CALLED'; -AGGREGATE - : 'AGGREGATE' - ; +CASCADE: 'CASCADE'; -ALSO - : 'ALSO' - ; +CASCADED: 'CASCADED'; -ALTER - : 'ALTER' - ; +CATALOG: 'CATALOG'; -ALWAYS - : 'ALWAYS' - ; +CHAIN: 'CHAIN'; -ASSERTION - : 'ASSERTION' - ; +CHARACTERISTICS: 'CHARACTERISTICS'; -ASSIGNMENT - : 'ASSIGNMENT' - ; +CHECKPOINT: 'CHECKPOINT'; -AT - : 'AT' - ; +CLASS: 'CLASS'; -ATTRIBUTE - : 'ATTRIBUTE' - ; +CLOSE: 'CLOSE'; -BACKWARD - : 'BACKWARD' - ; +CLUSTER: 'CLUSTER'; -BEFORE - : 'BEFORE' - ; +COMMENT: 'COMMENT'; -BEGIN_P - : 'BEGIN' - ; +COMMENTS: 'COMMENTS'; -BY - : 'BY' - ; +COMMIT: 'COMMIT'; -CACHE - : 'CACHE' - ; +COMMITTED: 'COMMITTED'; -CALLED - : 'CALLED' - ; +CONFIGURATION: 'CONFIGURATION'; -CASCADE - : 'CASCADE' - ; +CONNECTION: 'CONNECTION'; -CASCADED - : 'CASCADED' - ; +CONSTRAINTS: 'CONSTRAINTS'; -CATALOG - : 'CATALOG' - ; +CONTENT_P: 'CONTENT'; -CHAIN - : 'CHAIN' - ; +CONTINUE_P: 'CONTINUE'; -CHARACTERISTICS - : 'CHARACTERISTICS' - ; +CONVERSION_P: 'CONVERSION'; -CHECKPOINT - : 'CHECKPOINT' - ; +COPY: 'COPY'; -CLASS - : 'CLASS' - ; +COST: 'COST'; -CLOSE - : 'CLOSE' - ; +CSV: 'CSV'; -CLUSTER - : 'CLUSTER' - ; +CURSOR: 'CURSOR'; -COMMENT - : 'COMMENT' - ; +CYCLE: 'CYCLE'; -COMMENTS - : 'COMMENTS' - ; +DATA_P: 'DATA'; -COMMIT - : 'COMMIT' - ; +DATABASE: 'DATABASE'; -COMMITTED - : 'COMMITTED' - ; +DAY_P: 'DAY'; -CONFIGURATION - : 'CONFIGURATION' - ; +DEALLOCATE: 'DEALLOCATE'; -CONNECTION - : 'CONNECTION' - ; +DECLARE: 'DECLARE'; -CONSTRAINTS - : 'CONSTRAINTS' - ; +DEFAULTS: 'DEFAULTS'; -CONTENT_P - : 'CONTENT' - ; +DEFERRED: 'DEFERRED'; -CONTINUE_P - : 'CONTINUE' - ; +DEFINER: 'DEFINER'; -CONVERSION_P - : 'CONVERSION' - ; +DELETE_P: 'DELETE'; -COPY - : 'COPY' - ; +DELIMITER: 'DELIMITER'; -COST - : 'COST' - ; +DELIMITERS: 'DELIMITERS'; -CSV - : 'CSV' - ; +DICTIONARY: 'DICTIONARY'; -CURSOR - : 'CURSOR' - ; +DISABLE_P: 'DISABLE'; -CYCLE - : 'CYCLE' - ; +DISCARD: 'DISCARD'; -DATA_P - : 'DATA' - ; +DOCUMENT_P: 'DOCUMENT'; -DATABASE - : 'DATABASE' - ; +DOMAIN_P: 'DOMAIN'; -DAY_P - : 'DAY' - ; +DOUBLE_P: 'DOUBLE'; -DEALLOCATE - : 'DEALLOCATE' - ; +DROP: 'DROP'; -DECLARE - : 'DECLARE' - ; +EACH: 'EACH'; -DEFAULTS - : 'DEFAULTS' - ; +ENABLE_P: 'ENABLE'; -DEFERRED - : 'DEFERRED' - ; +ENCODING: 'ENCODING'; -DEFINER - : 'DEFINER' - ; +ENCRYPTED: 'ENCRYPTED'; -DELETE_P - : 'DELETE' - ; +ENUM_P: 'ENUM'; -DELIMITER - : 'DELIMITER' - ; +ESCAPE: 'ESCAPE'; -DELIMITERS - : 'DELIMITERS' - ; +EVENT: 'EVENT'; -DICTIONARY - : 'DICTIONARY' - ; +EXCLUDE: 'EXCLUDE'; -DISABLE_P - : 'DISABLE' - ; +EXCLUDING: 'EXCLUDING'; -DISCARD - : 'DISCARD' - ; +EXCLUSIVE: 'EXCLUSIVE'; -DOCUMENT_P - : 'DOCUMENT' - ; +EXECUTE: 'EXECUTE'; -DOMAIN_P - : 'DOMAIN' - ; +EXPLAIN: 'EXPLAIN'; -DOUBLE_P - : 'DOUBLE' - ; +EXTENSION: 'EXTENSION'; -DROP - : 'DROP' - ; +EXTERNAL: 'EXTERNAL'; -EACH - : 'EACH' - ; +FAMILY: 'FAMILY'; -ENABLE_P - : 'ENABLE' - ; +FIRST_P: 'FIRST'; -ENCODING - : 'ENCODING' - ; +FOLLOWING: 'FOLLOWING'; -ENCRYPTED - : 'ENCRYPTED' - ; +FORCE: 'FORCE'; -ENUM_P - : 'ENUM' - ; +FORWARD: 'FORWARD'; -ESCAPE - : 'ESCAPE' - ; +FUNCTION: 'FUNCTION'; -EVENT - : 'EVENT' - ; +FUNCTIONS: 'FUNCTIONS'; -EXCLUDE - : 'EXCLUDE' - ; +GLOBAL: 'GLOBAL'; -EXCLUDING - : 'EXCLUDING' - ; +GRANTED: 'GRANTED'; -EXCLUSIVE - : 'EXCLUSIVE' - ; +HANDLER: 'HANDLER'; -EXECUTE - : 'EXECUTE' - ; +HEADER_P: 'HEADER'; -EXPLAIN - : 'EXPLAIN' - ; +HOLD: 'HOLD'; -EXTENSION - : 'EXTENSION' - ; +HOUR_P: 'HOUR'; -EXTERNAL - : 'EXTERNAL' - ; +IDENTITY_P: 'IDENTITY'; -FAMILY - : 'FAMILY' - ; +IF_P: 'IF'; -FIRST_P - : 'FIRST' - ; +IMMEDIATE: 'IMMEDIATE'; -FOLLOWING - : 'FOLLOWING' - ; +IMMUTABLE: 'IMMUTABLE'; -FORCE - : 'FORCE' - ; +IMPLICIT_P: 'IMPLICIT'; -FORWARD - : 'FORWARD' - ; +INCLUDING: 'INCLUDING'; -FUNCTION - : 'FUNCTION' - ; +INCREMENT: 'INCREMENT'; -FUNCTIONS - : 'FUNCTIONS' - ; +INDEX: 'INDEX'; -GLOBAL - : 'GLOBAL' - ; +INDEXES: 'INDEXES'; -GRANTED - : 'GRANTED' - ; +INHERIT: 'INHERIT'; -HANDLER - : 'HANDLER' - ; +INHERITS: 'INHERITS'; -HEADER_P - : 'HEADER' - ; +INLINE_P: 'INLINE'; -HOLD - : 'HOLD' - ; +INSENSITIVE: 'INSENSITIVE'; -HOUR_P - : 'HOUR' - ; +INSERT: 'INSERT'; -IDENTITY_P - : 'IDENTITY' - ; +INSTEAD: 'INSTEAD'; -IF_P - : 'IF' - ; +INVOKER: 'INVOKER'; -IMMEDIATE - : 'IMMEDIATE' - ; +ISOLATION: 'ISOLATION'; -IMMUTABLE - : 'IMMUTABLE' - ; +KEY: 'KEY'; -IMPLICIT_P - : 'IMPLICIT' - ; +LABEL: 'LABEL'; -INCLUDING - : 'INCLUDING' - ; +LANGUAGE: 'LANGUAGE'; -INCREMENT - : 'INCREMENT' - ; +LARGE_P: 'LARGE'; -INDEX - : 'INDEX' - ; +LAST_P: 'LAST'; +//LC_COLLATE : 'LC'_'COLLATE; -INDEXES - : 'INDEXES' - ; +//LC_CTYPE : 'LC'_'CTYPE; -INHERIT - : 'INHERIT' - ; +LEAKPROOF: 'LEAKPROOF'; -INHERITS - : 'INHERITS' - ; +LEVEL: 'LEVEL'; -INLINE_P - : 'INLINE' - ; +LISTEN: 'LISTEN'; -INSENSITIVE - : 'INSENSITIVE' - ; +LOAD: 'LOAD'; -INSERT - : 'INSERT' - ; +LOCAL: 'LOCAL'; -INSTEAD - : 'INSTEAD' - ; +LOCATION: 'LOCATION'; -INVOKER - : 'INVOKER' - ; +LOCK_P: 'LOCK'; -ISOLATION - : 'ISOLATION' - ; +MAPPING: 'MAPPING'; -KEY - : 'KEY' - ; +MATCH: 'MATCH'; -LABEL - : 'LABEL' - ; +MATCHED: 'MATCHED'; -LANGUAGE - : 'LANGUAGE' - ; +MATERIALIZED: 'MATERIALIZED'; -LARGE_P - : 'LARGE' - ; +MAXVALUE: 'MAXVALUE'; -LAST_P - : 'LAST' - ; - //LC_COLLATE : 'LC'_'COLLATE; +MERGE: 'MERGE'; - //LC_CTYPE : 'LC'_'CTYPE; +MINUTE_P: 'MINUTE'; -LEAKPROOF - : 'LEAKPROOF' - ; +MINVALUE: 'MINVALUE'; -LEVEL - : 'LEVEL' - ; +MODE: 'MODE'; -LISTEN - : 'LISTEN' - ; +MONTH_P: 'MONTH'; -LOAD - : 'LOAD' - ; +MOVE: 'MOVE'; -LOCAL - : 'LOCAL' - ; +NAME_P: 'NAME'; -LOCATION - : 'LOCATION' - ; +NAMES: 'NAMES'; -LOCK_P - : 'LOCK' - ; +NEXT: 'NEXT'; -MAPPING - : 'MAPPING' - ; +NO: 'NO'; -MATCH - : 'MATCH' - ; +NOTHING: 'NOTHING'; -MATCHED - : 'MATCHED' - ; +NOTIFY: 'NOTIFY'; -MATERIALIZED - : 'MATERIALIZED' - ; +NOWAIT: 'NOWAIT'; -MAXVALUE - : 'MAXVALUE' - ; +NULLS_P: 'NULLS'; -MERGE - : 'MERGE' - ; +OBJECT_P: 'OBJECT'; -MINUTE_P - : 'MINUTE' - ; +OF: 'OF'; -MINVALUE - : 'MINVALUE' - ; +OFF: 'OFF'; -MODE - : 'MODE' - ; +OIDS: 'OIDS'; -MONTH_P - : 'MONTH' - ; +OPERATOR: 'OPERATOR'; -MOVE - : 'MOVE' - ; +OPTION: 'OPTION'; -NAME_P - : 'NAME' - ; +OPTIONS: 'OPTIONS'; -NAMES - : 'NAMES' - ; +OWNED: 'OWNED'; -NEXT - : 'NEXT' - ; +OWNER: 'OWNER'; -NO - : 'NO' - ; +PARSER: 'PARSER'; -NOTHING - : 'NOTHING' - ; +PARTIAL: 'PARTIAL'; -NOTIFY - : 'NOTIFY' - ; +PARTITION: 'PARTITION'; -NOWAIT - : 'NOWAIT' - ; +PASSING: 'PASSING'; -NULLS_P - : 'NULLS' - ; +PASSWORD: 'PASSWORD'; -OBJECT_P - : 'OBJECT' - ; +PLANS: 'PLANS'; -OF - : 'OF' - ; +PRECEDING: 'PRECEDING'; -OFF - : 'OFF' - ; +PREPARE: 'PREPARE'; -OIDS - : 'OIDS' - ; +PREPARED: 'PREPARED'; -OPERATOR - : 'OPERATOR' - ; +PRESERVE: 'PRESERVE'; -OPTION - : 'OPTION' - ; +PRIOR: 'PRIOR'; -OPTIONS - : 'OPTIONS' - ; +PRIVILEGES: 'PRIVILEGES'; -OWNED - : 'OWNED' - ; +PROCEDURAL: 'PROCEDURAL'; -OWNER - : 'OWNER' - ; +PROCEDURE: 'PROCEDURE'; -PARSER - : 'PARSER' - ; +PROGRAM: 'PROGRAM'; -PARTIAL - : 'PARTIAL' - ; +QUOTE: 'QUOTE'; -PARTITION - : 'PARTITION' - ; +RANGE: 'RANGE'; -PASSING - : 'PASSING' - ; +READ: 'READ'; -PASSWORD - : 'PASSWORD' - ; +REASSIGN: 'REASSIGN'; -PLANS - : 'PLANS' - ; +RECHECK: 'RECHECK'; -PRECEDING - : 'PRECEDING' - ; +RECURSIVE: 'RECURSIVE'; -PREPARE - : 'PREPARE' - ; +REF: 'REF'; -PREPARED - : 'PREPARED' - ; +REFRESH: 'REFRESH'; -PRESERVE - : 'PRESERVE' - ; +REINDEX: 'REINDEX'; -PRIOR - : 'PRIOR' - ; +RELATIVE_P: 'RELATIVE'; -PRIVILEGES - : 'PRIVILEGES' - ; +RELEASE: 'RELEASE'; -PROCEDURAL - : 'PROCEDURAL' - ; +RENAME: 'RENAME'; -PROCEDURE - : 'PROCEDURE' - ; +REPEATABLE: 'REPEATABLE'; -PROGRAM - : 'PROGRAM' - ; +REPLACE: 'REPLACE'; -QUOTE - : 'QUOTE' - ; +REPLICA: 'REPLICA'; -RANGE - : 'RANGE' - ; +RESET: 'RESET'; -READ - : 'READ' - ; +RESTART: 'RESTART'; -REASSIGN - : 'REASSIGN' - ; +RESTRICT: 'RESTRICT'; -RECHECK - : 'RECHECK' - ; +RETURNS: 'RETURNS'; -RECURSIVE - : 'RECURSIVE' - ; +REVOKE: 'REVOKE'; -REF - : 'REF' - ; +ROLE: 'ROLE'; -REFRESH - : 'REFRESH' - ; +ROLLBACK: 'ROLLBACK'; -REINDEX - : 'REINDEX' - ; +ROWS: 'ROWS'; -RELATIVE_P - : 'RELATIVE' - ; +RULE: 'RULE'; -RELEASE - : 'RELEASE' - ; +SAVEPOINT: 'SAVEPOINT'; -RENAME - : 'RENAME' - ; +SCHEMA: 'SCHEMA'; -REPEATABLE - : 'REPEATABLE' - ; +SCROLL: 'SCROLL'; -REPLACE - : 'REPLACE' - ; +SEARCH: 'SEARCH'; -REPLICA - : 'REPLICA' - ; +SECOND_P: 'SECOND'; -RESET - : 'RESET' - ; +SECURITY: 'SECURITY'; -RESTART - : 'RESTART' - ; +SEQUENCE: 'SEQUENCE'; -RESTRICT - : 'RESTRICT' - ; +SEQUENCES: 'SEQUENCES'; -RETURNS - : 'RETURNS' - ; +SERIALIZABLE: 'SERIALIZABLE'; -REVOKE - : 'REVOKE' - ; +SERVER: 'SERVER'; -ROLE - : 'ROLE' - ; +SESSION: 'SESSION'; -ROLLBACK - : 'ROLLBACK' - ; +SET: 'SET'; -ROWS - : 'ROWS' - ; +SHARE: 'SHARE'; -RULE - : 'RULE' - ; +SHOW: 'SHOW'; -SAVEPOINT - : 'SAVEPOINT' - ; +SIMPLE: 'SIMPLE'; -SCHEMA - : 'SCHEMA' - ; +SNAPSHOT: 'SNAPSHOT'; -SCROLL - : 'SCROLL' - ; +STABLE: 'STABLE'; -SEARCH - : 'SEARCH' - ; +STANDALONE_P: 'STANDALONE'; -SECOND_P - : 'SECOND' - ; +START: 'START'; -SECURITY - : 'SECURITY' - ; +STATEMENT: 'STATEMENT'; -SEQUENCE - : 'SEQUENCE' - ; +STATISTICS: 'STATISTICS'; -SEQUENCES - : 'SEQUENCES' - ; +STDIN: 'STDIN'; -SERIALIZABLE - : 'SERIALIZABLE' - ; +STDOUT: 'STDOUT'; -SERVER - : 'SERVER' - ; +STORAGE: 'STORAGE'; -SESSION - : 'SESSION' - ; +STRICT_P: 'STRICT'; -SET - : 'SET' - ; +STRIP_P: 'STRIP'; -SHARE - : 'SHARE' - ; +SYSID: 'SYSID'; -SHOW - : 'SHOW' - ; +SYSTEM_P: 'SYSTEM'; -SIMPLE - : 'SIMPLE' - ; +TABLES: 'TABLES'; -SNAPSHOT - : 'SNAPSHOT' - ; +TABLESPACE: 'TABLESPACE'; -STABLE - : 'STABLE' - ; +TEMP: 'TEMP'; -STANDALONE_P - : 'STANDALONE' - ; +TEMPLATE: 'TEMPLATE'; -START - : 'START' - ; +TEMPORARY: 'TEMPORARY'; -STATEMENT - : 'STATEMENT' - ; +TEXT_P: 'TEXT'; -STATISTICS - : 'STATISTICS' - ; +TRANSACTION: 'TRANSACTION'; -STDIN - : 'STDIN' - ; +TRIGGER: 'TRIGGER'; -STDOUT - : 'STDOUT' - ; +TRUNCATE: 'TRUNCATE'; -STORAGE - : 'STORAGE' - ; +TRUSTED: 'TRUSTED'; -STRICT_P - : 'STRICT' - ; +TYPE_P: 'TYPE'; -STRIP_P - : 'STRIP' - ; +TYPES_P: 'TYPES'; -SYSID - : 'SYSID' - ; +UNBOUNDED: 'UNBOUNDED'; -SYSTEM_P - : 'SYSTEM' - ; +UNCOMMITTED: 'UNCOMMITTED'; -TABLES - : 'TABLES' - ; +UNENCRYPTED: 'UNENCRYPTED'; -TABLESPACE - : 'TABLESPACE' - ; +UNKNOWN: 'UNKNOWN'; -TEMP - : 'TEMP' - ; +UNLISTEN: 'UNLISTEN'; -TEMPLATE - : 'TEMPLATE' - ; +UNLOGGED: 'UNLOGGED'; -TEMPORARY - : 'TEMPORARY' - ; +UNTIL: 'UNTIL'; -TEXT_P - : 'TEXT' - ; +UPDATE: 'UPDATE'; -TRANSACTION - : 'TRANSACTION' - ; +VACUUM: 'VACUUM'; -TRIGGER - : 'TRIGGER' - ; +VALID: 'VALID'; -TRUNCATE - : 'TRUNCATE' - ; +VALIDATE: 'VALIDATE'; -TRUSTED - : 'TRUSTED' - ; +VALIDATOR: 'VALIDATOR'; +//VALUE : 'VALUE; -TYPE_P - : 'TYPE' - ; +VARYING: 'VARYING'; -TYPES_P - : 'TYPES' - ; +VERSION_P: 'VERSION'; -UNBOUNDED - : 'UNBOUNDED' - ; +VIEW: 'VIEW'; -UNCOMMITTED - : 'UNCOMMITTED' - ; +VOLATILE: 'VOLATILE'; -UNENCRYPTED - : 'UNENCRYPTED' - ; +WHITESPACE_P: 'WHITESPACE'; -UNKNOWN - : 'UNKNOWN' - ; +WITHOUT: 'WITHOUT'; -UNLISTEN - : 'UNLISTEN' - ; +WORK: 'WORK'; -UNLOGGED - : 'UNLOGGED' - ; +WRAPPER: 'WRAPPER'; -UNTIL - : 'UNTIL' - ; +WRITE: 'WRITE'; -UPDATE - : 'UPDATE' - ; +XML_P: 'XML'; -VACUUM - : 'VACUUM' - ; +YEAR_P: 'YEAR'; -VALID - : 'VALID' - ; +YES_P: 'YES'; -VALIDATE - : 'VALIDATE' - ; +ZONE: 'ZONE'; +// -VALIDATOR - : 'VALIDATOR' - ; - //VALUE : 'VALUE; +// non-reserved keywords (can not be function or type) -VARYING - : 'VARYING' - ; +// -VERSION_P - : 'VERSION' - ; +BETWEEN: 'BETWEEN'; -VIEW - : 'VIEW' - ; +BIGINT: 'BIGINT'; -VOLATILE - : 'VOLATILE' - ; +BIT: 'BIT'; -WHITESPACE_P - : 'WHITESPACE' - ; +BOOLEAN_P: 'BOOLEAN'; -WITHOUT - : 'WITHOUT' - ; +CHAR_P: 'CHAR'; -WORK - : 'WORK' - ; +CHARACTER: 'CHARACTER'; -WRAPPER - : 'WRAPPER' - ; +COALESCE: 'COALESCE'; -WRITE - : 'WRITE' - ; +DEC: 'DEC'; -XML_P - : 'XML' - ; +DECIMAL_P: 'DECIMAL'; -YEAR_P - : 'YEAR' - ; +EXISTS: 'EXISTS'; -YES_P - : 'YES' - ; +EXTRACT: 'EXTRACT'; -ZONE - : 'ZONE' - ; - // +FLOAT_P: 'FLOAT'; - // non-reserved keywords (can not be function or type) +GREATEST: 'GREATEST'; - // +INOUT: 'INOUT'; -BETWEEN - : 'BETWEEN' - ; +INT_P: 'INT'; -BIGINT - : 'BIGINT' - ; +INTEGER: 'INTEGER'; -BIT - : 'BIT' - ; +INTERVAL: 'INTERVAL'; -BOOLEAN_P - : 'BOOLEAN' - ; +LEAST: 'LEAST'; -CHAR_P - : 'CHAR' - ; +NATIONAL: 'NATIONAL'; -CHARACTER - : 'CHARACTER' - ; +NCHAR: 'NCHAR'; -COALESCE - : 'COALESCE' - ; +NONE: 'NONE'; -DEC - : 'DEC' - ; +NULLIF: 'NULLIF'; -DECIMAL_P - : 'DECIMAL' - ; +NUMERIC: 'NUMERIC'; -EXISTS - : 'EXISTS' - ; +OVERLAY: 'OVERLAY'; -EXTRACT - : 'EXTRACT' - ; +POSITION: 'POSITION'; -FLOAT_P - : 'FLOAT' - ; +PRECISION: 'PRECISION'; -GREATEST - : 'GREATEST' - ; +REAL: 'REAL'; -INOUT - : 'INOUT' - ; +ROW: 'ROW'; -INT_P - : 'INT' - ; +SETOF: 'SETOF'; -INTEGER - : 'INTEGER' - ; +SMALLINT: 'SMALLINT'; -INTERVAL - : 'INTERVAL' - ; +SUBSTRING: 'SUBSTRING'; -LEAST - : 'LEAST' - ; +TIME: 'TIME'; -NATIONAL - : 'NATIONAL' - ; +TIMESTAMP: 'TIMESTAMP'; -NCHAR - : 'NCHAR' - ; +TREAT: 'TREAT'; -NONE - : 'NONE' - ; +TRIM: 'TRIM'; -NULLIF - : 'NULLIF' - ; +VALUES: 'VALUES'; -NUMERIC - : 'NUMERIC' - ; +VARCHAR: 'VARCHAR'; -OVERLAY - : 'OVERLAY' - ; +XMLATTRIBUTES: 'XMLATTRIBUTES'; -POSITION - : 'POSITION' - ; +XMLCOMMENT: 'XMLCOMMENT'; -PRECISION - : 'PRECISION' - ; +XMLAGG: 'XMLAGG'; -REAL - : 'REAL' - ; +XML_IS_WELL_FORMED: 'XML_IS_WELL_FORMED'; -ROW - : 'ROW' - ; +XML_IS_WELL_FORMED_DOCUMENT: 'XML_IS_WELL_FORMED_DOCUMENT'; -SETOF - : 'SETOF' - ; +XML_IS_WELL_FORMED_CONTENT: 'XML_IS_WELL_FORMED_CONTENT'; -SMALLINT - : 'SMALLINT' - ; +XPATH: 'XPATH'; -SUBSTRING - : 'SUBSTRING' - ; +XPATH_EXISTS: 'XPATH_EXISTS'; -TIME - : 'TIME' - ; +XMLCONCAT: 'XMLCONCAT'; -TIMESTAMP - : 'TIMESTAMP' - ; +XMLELEMENT: 'XMLELEMENT'; -TREAT - : 'TREAT' - ; +XMLEXISTS: 'XMLEXISTS'; -TRIM - : 'TRIM' - ; +XMLFOREST: 'XMLFOREST'; -VALUES - : 'VALUES' - ; +XMLPARSE: 'XMLPARSE'; -VARCHAR - : 'VARCHAR' - ; +XMLPI: 'XMLPI'; -XMLATTRIBUTES - : 'XMLATTRIBUTES' - ; +XMLROOT: 'XMLROOT'; -XMLCOMMENT - : 'XMLCOMMENT' - ; +XMLSERIALIZE: 'XMLSERIALIZE'; +//MISSED -XMLAGG - : 'XMLAGG' - ; +CALL: 'CALL'; -XML_IS_WELL_FORMED - : 'XML_IS_WELL_FORMED' - ; +CURRENT_P: 'CURRENT'; -XML_IS_WELL_FORMED_DOCUMENT - : 'XML_IS_WELL_FORMED_DOCUMENT' - ; +ATTACH: 'ATTACH'; -XML_IS_WELL_FORMED_CONTENT - : 'XML_IS_WELL_FORMED_CONTENT' - ; +DETACH: 'DETACH'; -XPATH - : 'XPATH' - ; +EXPRESSION: 'EXPRESSION'; -XPATH_EXISTS - : 'XPATH_EXISTS' - ; +GENERATED: 'GENERATED'; -XMLCONCAT - : 'XMLCONCAT' - ; +LOGGED: 'LOGGED'; -XMLELEMENT - : 'XMLELEMENT' - ; +STORED: 'STORED'; -XMLEXISTS - : 'XMLEXISTS' - ; +INCLUDE: 'INCLUDE'; -XMLFOREST - : 'XMLFOREST' - ; +ROUTINE: 'ROUTINE'; -XMLPARSE - : 'XMLPARSE' - ; +TRANSFORM: 'TRANSFORM'; -XMLPI - : 'XMLPI' - ; +IMPORT_P: 'IMPORT'; -XMLROOT - : 'XMLROOT' - ; +POLICY: 'POLICY'; -XMLSERIALIZE - : 'XMLSERIALIZE' - ; - //MISSED +METHOD: 'METHOD'; -CALL - : 'CALL' - ; +REFERENCING: 'REFERENCING'; -CURRENT_P - : 'CURRENT' - ; +NEW: 'NEW'; -ATTACH - : 'ATTACH' - ; +OLD: 'OLD'; -DETACH - : 'DETACH' - ; +VALUE_P: 'VALUE'; -EXPRESSION - : 'EXPRESSION' - ; +SUBSCRIPTION: 'SUBSCRIPTION'; -GENERATED - : 'GENERATED' - ; +PUBLICATION: 'PUBLICATION'; -LOGGED - : 'LOGGED' - ; +OUT_P: 'OUT'; -STORED - : 'STORED' - ; +END_P: 'END'; -INCLUDE - : 'INCLUDE' - ; +ROUTINES: 'ROUTINES'; -ROUTINE - : 'ROUTINE' - ; +SCHEMAS: 'SCHEMAS'; -TRANSFORM - : 'TRANSFORM' - ; +PROCEDURES: 'PROCEDURES'; -IMPORT_P - : 'IMPORT' - ; +INPUT_P: 'INPUT'; -POLICY - : 'POLICY' - ; +SUPPORT: 'SUPPORT'; -METHOD - : 'METHOD' - ; +PARALLEL: 'PARALLEL'; -REFERENCING - : 'REFERENCING' - ; +SQL_P: 'SQL'; -NEW - : 'NEW' - ; +DEPENDS: 'DEPENDS'; -OLD - : 'OLD' - ; +OVERRIDING: 'OVERRIDING'; -VALUE_P - : 'VALUE' - ; +CONFLICT: 'CONFLICT'; -SUBSCRIPTION - : 'SUBSCRIPTION' - ; +SKIP_P: 'SKIP'; -PUBLICATION - : 'PUBLICATION' - ; +LOCKED: 'LOCKED'; -OUT_P - : 'OUT' - ; +TIES: 'TIES'; -END_P - : 'END' - ; +ROLLUP: 'ROLLUP'; -ROUTINES - : 'ROUTINES' - ; +CUBE: 'CUBE'; -SCHEMAS - : 'SCHEMAS' - ; +GROUPING: 'GROUPING'; -PROCEDURES - : 'PROCEDURES' - ; +SETS: 'SETS'; -INPUT_P - : 'INPUT' - ; +TABLESAMPLE: 'TABLESAMPLE'; -SUPPORT - : 'SUPPORT' - ; +ORDINALITY: 'ORDINALITY'; -PARALLEL - : 'PARALLEL' - ; +XMLTABLE: 'XMLTABLE'; -SQL_P - : 'SQL' - ; +COLUMNS: 'COLUMNS'; -DEPENDS - : 'DEPENDS' - ; +XMLNAMESPACES: 'XMLNAMESPACES'; -OVERRIDING - : 'OVERRIDING' - ; +ROWTYPE: 'ROWTYPE'; -CONFLICT - : 'CONFLICT' - ; +NORMALIZED: 'NORMALIZED'; -SKIP_P - : 'SKIP' - ; +WITHIN: 'WITHIN'; -LOCKED - : 'LOCKED' - ; +FILTER: 'FILTER'; -TIES - : 'TIES' - ; +GROUPS: 'GROUPS'; -ROLLUP - : 'ROLLUP' - ; +OTHERS: 'OTHERS'; -CUBE - : 'CUBE' - ; +NFC: 'NFC'; -GROUPING - : 'GROUPING' - ; +NFD: 'NFD'; -SETS - : 'SETS' - ; +NFKC: 'NFKC'; -TABLESAMPLE - : 'TABLESAMPLE' - ; +NFKD: 'NFKD'; -ORDINALITY - : 'ORDINALITY' - ; +UESCAPE: 'UESCAPE'; -XMLTABLE - : 'XMLTABLE' - ; +VIEWS: 'VIEWS'; -COLUMNS - : 'COLUMNS' - ; +NORMALIZE: 'NORMALIZE'; -XMLNAMESPACES - : 'XMLNAMESPACES' - ; +DUMP: 'DUMP'; -ROWTYPE - : 'ROWTYPE' - ; +PRINT_STRICT_PARAMS: 'PRINT_STRICT_PARAMS'; -NORMALIZED - : 'NORMALIZED' - ; +VARIABLE_CONFLICT: 'VARIABLE_CONFLICT'; -WITHIN - : 'WITHIN' - ; +ERROR: 'ERROR'; -FILTER - : 'FILTER' - ; +USE_VARIABLE: 'USE_VARIABLE'; -GROUPS - : 'GROUPS' - ; +USE_COLUMN: 'USE_COLUMN'; -OTHERS - : 'OTHERS' - ; +ALIAS: 'ALIAS'; -NFC - : 'NFC' - ; +CONSTANT: 'CONSTANT'; -NFD - : 'NFD' - ; +PERFORM: 'PERFORM'; -NFKC - : 'NFKC' - ; +GET: 'GET'; -NFKD - : 'NFKD' - ; +DIAGNOSTICS: 'DIAGNOSTICS'; -UESCAPE - : 'UESCAPE' - ; +STACKED: 'STACKED'; -VIEWS - : 'VIEWS' - ; +ELSIF: 'ELSIF'; -NORMALIZE - : 'NORMALIZE' - ; +WHILE: 'WHILE'; -DUMP - : 'DUMP' - ; +REVERSE: 'REVERSE'; -PRINT_STRICT_PARAMS - : 'PRINT_STRICT_PARAMS' - ; +FOREACH: 'FOREACH'; -VARIABLE_CONFLICT - : 'VARIABLE_CONFLICT' - ; +SLICE: 'SLICE'; -ERROR - : 'ERROR' - ; +EXIT: 'EXIT'; -USE_VARIABLE - : 'USE_VARIABLE' - ; +RETURN: 'RETURN'; -USE_COLUMN - : 'USE_COLUMN' - ; +QUERY: 'QUERY'; -ALIAS - : 'ALIAS' - ; +RAISE: 'RAISE'; -CONSTANT - : 'CONSTANT' - ; +SQLSTATE: 'SQLSTATE'; -PERFORM - : 'PERFORM' - ; +DEBUG: 'DEBUG'; -GET - : 'GET' - ; +LOG: 'LOG'; -DIAGNOSTICS - : 'DIAGNOSTICS' - ; +INFO: 'INFO'; -STACKED - : 'STACKED' - ; +NOTICE: 'NOTICE'; -ELSIF - : 'ELSIF' - ; +WARNING: 'WARNING'; -WHILE - : 'WHILE' - ; +EXCEPTION: 'EXCEPTION'; -REVERSE - : 'REVERSE' - ; +ASSERT: 'ASSERT'; -FOREACH - : 'FOREACH' - ; +LOOP: 'LOOP'; -SLICE - : 'SLICE' - ; +OPEN: 'OPEN'; +// -EXIT - : 'EXIT' - ; +// IDENTIFIERS (4.1.1) -RETURN - : 'RETURN' - ; +// -QUERY - : 'QUERY' - ; +ABS: 'ABS'; -RAISE - : 'RAISE' - ; +CBRT: 'CBRT'; -SQLSTATE - : 'SQLSTATE' - ; +CEIL: 'CEIL'; -DEBUG - : 'DEBUG' - ; +CEILING: 'CEILING'; -LOG - : 'LOG' - ; +DEGREES: 'DEGREES'; -INFO - : 'INFO' - ; +DIV: 'DIV'; -NOTICE - : 'NOTICE' - ; +EXP: 'EXP'; -WARNING - : 'WARNING' - ; +FACTORIAL: 'FACTORIAL'; -EXCEPTION - : 'EXCEPTION' - ; +FLOOR: 'FLOOR'; -ASSERT - : 'ASSERT' - ; +GCD: 'GCD'; -LOOP - : 'LOOP' - ; +LCM: 'LCM'; -OPEN - : 'OPEN' - ; - // +LN: 'LN'; - // IDENTIFIERS (4.1.1) +LOG10: 'LOG10'; - // +MIN_SCALE: 'MIN_SCALE'; -ABS - : 'ABS' - ; +MOD: 'MOD'; -CBRT - : 'CBRT' - ; +PI: 'PI'; -CEIL - : 'CEIL' - ; +POWER: 'POWER'; -CEILING - : 'CEILING' - ; +RADIANS: 'RADIANS'; -DEGREES - : 'DEGREES' - ; +ROUND: 'ROUND'; -DIV - : 'DIV' - ; +SCALE: 'SCALE'; -EXP - : 'EXP' - ; +SIGN: 'SIGN'; -FACTORIAL - : 'FACTORIAL' - ; +SQRT: 'SQRT'; -FLOOR - : 'FLOOR' - ; +TRIM_SCALE: 'TRIM_SCALE'; -GCD - : 'GCD' - ; +TRUNC: 'TRUNC'; -LCM - : 'LCM' - ; +WIDTH_BUCKET: 'WIDTH_BUCKET'; -LN - : 'LN' - ; +RANDOM: 'RANDOM'; -LOG10 - : 'LOG10' - ; +SETSEED: 'SETSEED'; -MIN_SCALE - : 'MIN_SCALE' - ; +ACOS: 'ACOS'; -MOD - : 'MOD' - ; +ACOSD: 'ACOSD'; -PI - : 'PI' - ; +ASIN: 'ASIN'; -POWER - : 'POWER' - ; +ASIND: 'ASIND'; -RADIANS - : 'RADIANS' - ; +ATAN: 'ATAN'; -ROUND - : 'ROUND' - ; +ATAND: 'ATAND'; -SCALE - : 'SCALE' - ; +ATAN2: 'ATAN2'; -SIGN - : 'SIGN' - ; +ATAN2D: 'ATAN2D'; -SQRT - : 'SQRT' - ; +COS: 'COS'; -TRIM_SCALE - : 'TRIM_SCALE' - ; +COSD: 'COSD'; -TRUNC - : 'TRUNC' - ; +COT: 'COT'; -WIDTH_BUCKET - : 'WIDTH_BUCKET' - ; +COTD: 'COTD'; -RANDOM - : 'RANDOM' - ; +SIN: 'SIN'; -SETSEED - : 'SETSEED' - ; +SIND: 'SIND'; -ACOS - : 'ACOS' - ; +TAN: 'TAN'; -ACOSD - : 'ACOSD' - ; +TAND: 'TAND'; -ASIN - : 'ASIN' - ; +SINH: 'SINH'; -ASIND - : 'ASIND' - ; +COSH: 'COSH'; -ATAN - : 'ATAN' - ; +TANH: 'TANH'; -ATAND - : 'ATAND' - ; +ASINH: 'ASINH'; -ATAN2 - : 'ATAN2' - ; +ACOSH: 'ACOSH'; -ATAN2D - : 'ATAN2D' - ; +ATANH: 'ATANH'; -COS - : 'COS' - ; +BIT_LENGTH: 'BIT_LENGTH'; -COSD - : 'COSD' - ; +CHAR_LENGTH: 'CHAR_LENGTH'; -COT - : 'COT' - ; +CHARACTER_LENGTH: 'CHARACTER_LENGTH'; -COTD - : 'COTD' - ; +LOWER: 'LOWER'; -SIN - : 'SIN' - ; +OCTET_LENGTH: 'OCTET_LENGTH'; -SIND - : 'SIND' - ; +UPPER: 'UPPER'; -TAN - : 'TAN' - ; +ASCII: 'ASCII'; -TAND - : 'TAND' - ; +BTRIM: 'BTRIM'; -SINH - : 'SINH' - ; +CHR: 'CHR'; -COSH - : 'COSH' - ; +CONCAT: 'CONCAT'; -TANH - : 'TANH' - ; +CONCAT_WS: 'CONCAT_WS'; -ASINH - : 'ASINH' - ; +FORMAT: 'FORMAT'; -ACOSH - : 'ACOSH' - ; +INITCAP: 'INITCAP'; -ATANH - : 'ATANH' - ; +LENGTH: 'LENGTH'; -BIT_LENGTH - : 'BIT_LENGTH' - ; +LPAD: 'LPAD'; -CHAR_LENGTH - : 'CHAR_LENGTH' - ; +LTRIM: 'LTRIM'; -CHARACTER_LENGTH - : 'CHARACTER_LENGTH' - ; +MD5: 'MD5'; -LOWER - : 'LOWER' - ; +PARSE_IDENT: 'PARSE_IDENT'; -OCTET_LENGTH - : 'OCTET_LENGTH' - ; +PG_CLIENT_ENCODING: 'PG_CLIENT_ENCODING'; -UPPER - : 'UPPER' - ; +QUOTE_IDENT: 'QUOTE_IDENT'; -ASCII - : 'ASCII' - ; +QUOTE_LITERAL: 'QUOTE_LITERAL'; -BTRIM - : 'BTRIM' - ; +QUOTE_NULLABLE: 'QUOTE_NULLABLE'; -CHR - : 'CHR' - ; +REGEXP_COUNT: 'REGEXP_COUNT'; -CONCAT - : 'CONCAT' - ; +REGEXP_INSTR: 'REGEXP_INSTR'; -CONCAT_WS - : 'CONCAT_WS' - ; +REGEXP_LIKE: 'REGEXP_LIKE'; -FORMAT - : 'FORMAT' - ; +REGEXP_MATCH: 'REGEXP_MATCH'; -INITCAP - : 'INITCAP' - ; +REGEXP_MATCHES: 'REGEXP_MATCHES'; -LENGTH - : 'LENGTH' - ; +REGEXP_REPLACE: 'REGEXP_REPLACE'; -LPAD - : 'LPAD' - ; +REGEXP_SPLIT_TO_ARRAY: 'REGEXP_SPLIT_TO_ARRAY'; -LTRIM - : 'LTRIM' - ; +REGEXP_SPLIT_TO_TABLE: 'REGEXP_SPLIT_TO_TABLE'; -MD5 - : 'MD5' - ; +REGEXP_SUBSTR: 'REGEXP_SUBSTR'; -PARSE_IDENT - : 'PARSE_IDENT' - ; +REPEAT: 'REPEAT'; -PG_CLIENT_ENCODING - : 'PG_CLIENT_ENCODING' - ; +RPAD: 'RPAD'; -QUOTE_IDENT - : 'QUOTE_IDENT' - ; +RTRIM: 'RTRIM'; -QUOTE_LITERAL - : 'QUOTE_LITERAL' - ; +SPLIT_PART: 'SPLIT_PART'; -QUOTE_NULLABLE - : 'QUOTE_NULLABLE' - ; +STARTS_WITH: 'STARTS_WITH'; -REGEXP_COUNT - : 'REGEXP_COUNT' - ; +STRING_TO_ARRAY: 'STRING_TO_ARRAY'; -REGEXP_INSTR - : 'REGEXP_INSTR' - ; +STRING_TO_TABLE: 'STRING_TO_TABLE'; -REGEXP_LIKE - : 'REGEXP_LIKE' - ; +STRPOS: 'STRPOS'; -REGEXP_MATCH - : 'REGEXP_MATCH' - ; +SUBSTR: 'SUBSTR'; -REGEXP_MATCHES - : 'REGEXP_MATCHES' - ; +TO_ASCII: 'TO_ASCII'; -REGEXP_REPLACE - : 'REGEXP_REPLACE' - ; +TO_HEX: 'TO_HEX'; -REGEXP_SPLIT_TO_ARRAY - : 'REGEXP_SPLIT_TO_ARRAY' - ; +TRANSLATE: 'TRANSLATE'; -REGEXP_SPLIT_TO_TABLE - : 'REGEXP_SPLIT_TO_TABLE' - ; +UNISTR: 'UNISTR'; -REGEXP_SUBSTR - : 'REGEXP_SUBSTR' - ; +AGE: 'AGE'; -REPEAT - : 'REPEAT' - ; +CLOCK_TIMESTAMP: 'CLOCK_TIMESTAMP'; -RPAD - : 'RPAD' - ; +DATE_BIN: 'DATE_BIN'; -RTRIM - : 'RTRIM' - ; +DATE_PART: 'DATE_PART'; -SPLIT_PART - : 'SPLIT_PART' - ; +DATE_TRUNC: 'DATE_TRUNC'; -STARTS_WITH - : 'STARTS_WITH' - ; +ISFINITE: 'ISFINITE'; -STRING_TO_ARRAY - : 'STRING_TO_ARRAY' - ; +JUSTIFY_DAYS: 'JUSTIFY_DAYS'; -STRING_TO_TABLE - : 'STRING_TO_TABLE' - ; +JUSTIFY_HOURS: 'JUSTIFY_HOURS'; -STRPOS - : 'STRPOS' - ; +JUSTIFY_INTERVAL: 'JUSTIFY_INTERVAL'; -SUBSTR - : 'SUBSTR' - ; +MAKE_DATE: 'MAKE_DATE'; -TO_ASCII - : 'TO_ASCII' - ; +MAKE_INTERVAL: 'MAKE_INTERVAL'; -TO_HEX - : 'TO_HEX' - ; +MAKE_TIME: 'MAKE_TIME'; -TRANSLATE - : 'TRANSLATE' - ; +MAKE_TIMESTAMP: 'MAKE_TIMESTAMP'; -UNISTR - : 'UNISTR' - ; - -AGE - : 'AGE' - ; - -CLOCK_TIMESTAMP - : 'CLOCK_TIMESTAMP' - ; - -DATE_BIN - : 'DATE_BIN' - ; - -DATE_PART - : 'DATE_PART' - ; - -DATE_TRUNC - : 'DATE_TRUNC' - ; - -ISFINITE - : 'ISFINITE' - ; - -JUSTIFY_DAYS - : 'JUSTIFY_DAYS' - ; - -JUSTIFY_HOURS - : 'JUSTIFY_HOURS' - ; - -JUSTIFY_INTERVAL - : 'JUSTIFY_INTERVAL' - ; - -MAKE_DATE - : 'MAKE_DATE' - ; - -MAKE_INTERVAL - : 'MAKE_INTERVAL' - ; - -MAKE_TIME - : 'MAKE_TIME' - ; - -MAKE_TIMESTAMP - : 'MAKE_TIMESTAMP' - ; - -MAKE_TIMESTAMPTZ - : 'MAKE_TIMESTAMPTZ' - ; - -NOW - : 'NOW' - ; - -STATEMENT_TIMESTAMP - : 'STATEMENT_TIMESTAMP' - ; - -TIMEOFDAY - : 'TIMEOFDAY' - ; - -TRANSACTION_TIMESTAMP - : 'TRANSACTION_TIMESTAMP' - ; - -TO_TIMESTAMP - : 'TO_TIMESTAMP' - ; - -TO_CHAR - : 'TO_CHAR' - ; - -TO_DATE - : 'TO_DATE' - ; - -TO_NUMBER - : 'TO_NUMBER' - ; - -Identifier - : IdentifierStartChar IdentifierChar* - ; - -fragment IdentifierStartChar options { caseInsensitive=false; } - : // these are the valid identifier start characters below 0x7F - [a-zA-Z_] - | // these are the valid characters from 0x80 to 0xFF - [\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF] - | // these are the letters above 0xFF which only need a single UTF-16 code unit - [\u0100-\uD7FF\uE000-\uFFFF] - {charIsLetter()}? - | // letters which require multiple UTF-16 code units - [\uD800-\uDBFF] [\uDC00-\uDFFF] - { - CheckIfUtf32Letter() - }? +MAKE_TIMESTAMPTZ: 'MAKE_TIMESTAMPTZ'; - ; +NOW: 'NOW'; -fragment IdentifierChar - : StrictIdentifierChar - | '$' - ; +STATEMENT_TIMESTAMP: 'STATEMENT_TIMESTAMP'; -fragment StrictIdentifierChar - : IdentifierStartChar - | [0-9] - ; +TIMEOFDAY: 'TIMEOFDAY'; + +TRANSACTION_TIMESTAMP: 'TRANSACTION_TIMESTAMP'; + +TO_TIMESTAMP: 'TO_TIMESTAMP'; + +TO_CHAR: 'TO_CHAR'; + +TO_DATE: 'TO_DATE'; + +TO_NUMBER: 'TO_NUMBER'; + +Identifier: IdentifierStartChar IdentifierChar*; + +fragment IdentifierStartChar options { + caseInsensitive = false; +}: // these are the valid identifier start characters below 0x7F + [a-zA-Z_] + | // these are the valid characters from 0x80 to 0xFF + [\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF] + | // these are the letters above 0xFF which only need a single UTF-16 code unit + [\u0100-\uD7FF\uE000-\uFFFF] {charIsLetter()}? + | // letters which require multiple UTF-16 code units + [\uD800-\uDBFF] [\uDC00-\uDFFF] { + CheckIfUtf32Letter() + }?; + +fragment IdentifierChar: StrictIdentifierChar | '$'; + +fragment StrictIdentifierChar: IdentifierStartChar | [0-9]; /* Quoted Identifiers * * These are divided into four separate tokens, allowing distinction of valid quoted identifiers from invalid quoted * identifiers without sacrificing the ability of the lexer to reliably recover from lexical errors in the input. */ +QuotedIdentifier: UnterminatedQuotedIdentifier '"'; +// This is a quoted identifier which only contains valid characters but is not terminated -QuotedIdentifier - : UnterminatedQuotedIdentifier '"' - ; - // This is a quoted identifier which only contains valid characters but is not terminated +UnterminatedQuotedIdentifier: '"' ('""' | ~ [\u0000"])*; +// This is a quoted identifier which is terminated but contains a \u0000 character -UnterminatedQuotedIdentifier - : '"' ('""' | ~ [\u0000"])* - ; - // This is a quoted identifier which is terminated but contains a \u0000 character +InvalidQuotedIdentifier: InvalidUnterminatedQuotedIdentifier '"'; +// This is a quoted identifier which is unterminated and contains a \u0000 character -InvalidQuotedIdentifier - : InvalidUnterminatedQuotedIdentifier '"' - ; - // This is a quoted identifier which is unterminated and contains a \u0000 character - -InvalidUnterminatedQuotedIdentifier - : '"' ('""' | ~ '"')* - ; +InvalidUnterminatedQuotedIdentifier: '"' ('""' | ~ '"')*; /* Unicode Quoted Identifiers * * These are divided into four separate tokens, allowing distinction of valid Unicode quoted identifiers from invalid @@ -2749,291 +1460,222 @@ InvalidUnterminatedQuotedIdentifier * TODO: these rules assume "" is still a valid escape sequence within a Unicode quoted identifier. */ +UnicodeQuotedIdentifier: 'U' '&' QuotedIdentifier; +// This is a Unicode quoted identifier which only contains valid characters but is not terminated -UnicodeQuotedIdentifier - : 'U' '&' QuotedIdentifier - ; - // This is a Unicode quoted identifier which only contains valid characters but is not terminated - -UnterminatedUnicodeQuotedIdentifier - : 'U' '&' UnterminatedQuotedIdentifier - ; - // This is a Unicode quoted identifier which is terminated but contains a \u0000 character +UnterminatedUnicodeQuotedIdentifier: 'U' '&' UnterminatedQuotedIdentifier; +// This is a Unicode quoted identifier which is terminated but contains a \u0000 character -InvalidUnicodeQuotedIdentifier - : 'U' '&' InvalidQuotedIdentifier - ; - // This is a Unicode quoted identifier which is unterminated and contains a \u0000 character +InvalidUnicodeQuotedIdentifier: 'U' '&' InvalidQuotedIdentifier; +// This is a Unicode quoted identifier which is unterminated and contains a \u0000 character -InvalidUnterminatedUnicodeQuotedIdentifier - : 'U' '&' InvalidUnterminatedQuotedIdentifier - ; - // +InvalidUnterminatedUnicodeQuotedIdentifier: 'U' '&' InvalidUnterminatedQuotedIdentifier; +// - // CONSTANTS (4.1.2) +// CONSTANTS (4.1.2) - // +// - // String Constants (4.1.2.1) +// String Constants (4.1.2.1) -StringConstant - : UnterminatedStringConstant '\'' - ; +StringConstant: UnterminatedStringConstant '\''; -UnterminatedStringConstant - : '\'' ('\'\'' | ~ '\'')* - ; - // String Constants with C-style Escapes (4.1.2.2) +UnterminatedStringConstant: '\'' ('\'\'' | ~ '\'')*; +// String Constants with C-style Escapes (4.1.2.2) -BeginEscapeStringConstant - : 'E' '\'' -> more , pushMode (EscapeStringConstantMode) - ; - // String Constants with Unicode Escapes (4.1.2.3) +BeginEscapeStringConstant: 'E' '\'' -> more, pushMode (EscapeStringConstantMode); +// String Constants with Unicode Escapes (4.1.2.3) - // +// - // Note that escape sequences are never checked as part of this token due to the ability of users to change the escape +// Note that escape sequences are never checked as part of this token due to the ability of users to change the escape - // character with a UESCAPE clause following the Unicode string constant. +// character with a UESCAPE clause following the Unicode string constant. - // +// - // TODO: these rules assume '' is still a valid escape sequence within a Unicode string constant. +// TODO: these rules assume '' is still a valid escape sequence within a Unicode string constant. -UnicodeEscapeStringConstant - : UnterminatedUnicodeEscapeStringConstant '\'' - ; +UnicodeEscapeStringConstant: UnterminatedUnicodeEscapeStringConstant '\''; -UnterminatedUnicodeEscapeStringConstant - : 'U' '&' UnterminatedStringConstant - ; - // Dollar-quoted String Constants (4.1.2.4) +UnterminatedUnicodeEscapeStringConstant: 'U' '&' UnterminatedStringConstant; +// Dollar-quoted String Constants (4.1.2.4) -BeginDollarStringConstant - : '$' Tag? '$' - {pushTag();} -> pushMode (DollarQuotedStringMode) - ; +BeginDollarStringConstant: '$' Tag? '$' {pushTag();} -> pushMode (DollarQuotedStringMode); /* "The tag, if any, of a dollar-quoted string follows the same rules as an * unquoted identifier, except that it cannot contain a dollar sign." */ +fragment Tag: IdentifierStartChar StrictIdentifierChar*; +// Bit-strings Constants (4.1.2.5) -fragment Tag - : IdentifierStartChar StrictIdentifierChar* - ; - // Bit-strings Constants (4.1.2.5) +BinaryStringConstant: UnterminatedBinaryStringConstant '\''; -BinaryStringConstant - : UnterminatedBinaryStringConstant '\'' - ; +UnterminatedBinaryStringConstant: 'B' '\'' [01]*; -UnterminatedBinaryStringConstant - : 'B' '\'' [01]* - ; +InvalidBinaryStringConstant: InvalidUnterminatedBinaryStringConstant '\''; -InvalidBinaryStringConstant - : InvalidUnterminatedBinaryStringConstant '\'' - ; +InvalidUnterminatedBinaryStringConstant: 'B' UnterminatedStringConstant; -InvalidUnterminatedBinaryStringConstant - : 'B' UnterminatedStringConstant - ; +HexadecimalStringConstant: UnterminatedHexadecimalStringConstant '\''; -HexadecimalStringConstant - : UnterminatedHexadecimalStringConstant '\'' - ; +UnterminatedHexadecimalStringConstant: 'X' '\'' [0-9A-F]*; -UnterminatedHexadecimalStringConstant - : 'X' '\'' [0-9A-F]* - ; +InvalidHexadecimalStringConstant: InvalidUnterminatedHexadecimalStringConstant '\''; -InvalidHexadecimalStringConstant - : InvalidUnterminatedHexadecimalStringConstant '\'' - ; +InvalidUnterminatedHexadecimalStringConstant: 'X' UnterminatedStringConstant; +// Numeric Constants (4.1.2.6) -InvalidUnterminatedHexadecimalStringConstant - : 'X' UnterminatedStringConstant - ; - // Numeric Constants (4.1.2.6) +Integral: Digits; -Integral - : Digits - ; +NumericFail: Digits '..' {HandleNumericFail();}; -NumericFail - : Digits '..' - {HandleNumericFail();} - ; +Numeric: + Digits '.' Digits? /*? replaced with + to solve problem with DOT_DOT .. but this surely must be rewriten */ ( + 'E' [+-]? Digits + )? + | '.' Digits ('E' [+-]? Digits)? + | Digits 'E' [+-]? Digits +; -Numeric - : Digits '.' Digits? /*? replaced with + to solve problem with DOT_DOT .. but this surely must be rewriten */ +fragment Digits: [0-9]+; - ('E' [+-]? Digits)? - | '.' Digits ('E' [+-]? Digits)? - | Digits 'E' [+-]? Digits - ; +PLSQLVARIABLENAME: ':' [A-Z_] [A-Z_0-9$]*; -fragment Digits - : [0-9]+ - ; - -PLSQLVARIABLENAME - : ':' [A-Z_] [A-Z_0-9$]* - ; - -PLSQLIDENTIFIER - : ':"' ('\\' . | '""' | ~ ('"' | '\\'))* '"' - ; - // - - // WHITESPACE (4.1) - - // - -Whitespace - : [ \t]+ -> channel (HIDDEN) - ; +PLSQLIDENTIFIER: ':"' ('\\' . | '""' | ~ ('"' | '\\'))* '"'; +// -Newline - : ('\r' '\n'? | '\n') -> channel (HIDDEN) - ; - // +// WHITESPACE (4.1) - // COMMENTS (4.1.5) +// - // +Whitespace: [ \t]+ -> channel (HIDDEN); -LineComment - : '--' ~ [\r\n]* -> channel (HIDDEN) - ; +Newline: ('\r' '\n'? | '\n') -> channel (HIDDEN); +// -BlockComment - : ('/*' ('/'* BlockComment | ~ [/*] | '/'+ ~ [/*] | '*'+ ~ [/*])* '*'* '*/') -> channel (HIDDEN) - ; +// COMMENTS (4.1.5) -UnterminatedBlockComment - : '/*' ('/'* BlockComment | // these characters are not part of special sequences in a block comment - ~ [/*] | // handle / or * characters which are not part of /* or */ and do not appear at the end of the file - ('/'+ ~ [/*] | '*'+ ~ [/*]))* - // Handle the case of / or * characters at the end of the file, or a nested unterminated block comment - ('/'+ | '*'+ | '/'* UnterminatedBlockComment)? - // Optional assertion to make sure this rule is working as intended +// - { +LineComment: '--' ~ [\r\n]* -> channel (HIDDEN); + +BlockComment: + ('/*' ('/'* BlockComment | ~ [/*] | '/'+ ~ [/*] | '*'+ ~ [/*])* '*'* '*/') -> channel (HIDDEN) +; + +UnterminatedBlockComment: + '/*' ( + '/'* BlockComment + | // these characters are not part of special sequences in a block comment + ~ [/*] + | // handle / or * characters which are not part of /* or */ and do not appear at the end of the file + ('/'+ ~ [/*] | '*'+ ~ [/*]) + )* + // Handle the case of / or * characters at the end of the file, or a nested unterminated block comment + ('/'+ | '*'+ | '/'* UnterminatedBlockComment)? + // Optional assertion to make sure this rule is working as intended + { UnterminatedBlockCommentDebugAssert(); } - ; - // +; +// - // META-COMMANDS +// META-COMMANDS - // +// - // http://www.postgresql.org/docs/9.3/static/app-psql.html +// http://www.postgresql.org/docs/9.3/static/app-psql.html -MetaCommand - : '\\' (~ [\r\n\\"] | '"' ~ [\r\n"]* '"')* ('"' ~ [\r\n"]*)? - ; +MetaCommand: '\\' (~ [\r\n\\"] | '"' ~ [\r\n"]* '"')* ('"' ~ [\r\n"]*)?; -EndMetaCommand - : '\\\\' - ; - // +EndMetaCommand: '\\\\'; +// - // ERROR +// ERROR - // +// - // Any character which does not match one of the above rules will appear in the token stream as an ErrorCharacter token. +// Any character which does not match one of the above rules will appear in the token stream as an ErrorCharacter token. - // This ensures the lexer itself will never encounter a syntax error, so all error handling may be performed by the +// This ensures the lexer itself will never encounter a syntax error, so all error handling may be performed by the - // parser. +// parser. -ErrorCharacter - : . - ; +ErrorCharacter: .; mode EscapeStringConstantMode; -EscapeStringConstant - : EscapeStringText '\'' -> mode (AfterEscapeStringConstantMode) - ; - -UnterminatedEscapeStringConstant - : EscapeStringText - // Handle a final unmatched \ character appearing at the end of the file - '\\'? EOF - ; - -fragment EscapeStringText options { caseInsensitive=false; } - : ('\'\'' | '\\' ( // two-digit hex escapes are still valid when treated as single-digit escapes - 'x' [0-9a-fA-F] | - 'u' [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] | - 'U' [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] | // Any character other than the Unicode escapes can follow a backslash. Some have special meaning, - // but that doesn't affect the syntax. - ~ [xuU]) | ~ ['\\])* - ; - -InvalidEscapeStringConstant - : InvalidEscapeStringText '\'' -> mode (AfterEscapeStringConstantMode) - ; - -InvalidUnterminatedEscapeStringConstant - : InvalidEscapeStringText - // Handle a final unmatched \ character appearing at the end of the file - '\\'? EOF - ; - -fragment InvalidEscapeStringText - : ('\'\'' | '\\' . | ~ ['\\])* - ; +EscapeStringConstant: EscapeStringText '\'' -> mode (AfterEscapeStringConstantMode); + +UnterminatedEscapeStringConstant: + EscapeStringText + // Handle a final unmatched \ character appearing at the end of the file + '\\'? EOF +; + +fragment EscapeStringText options { + caseInsensitive = false; +}: + ( + '\'\'' + | '\\' ( + // two-digit hex escapes are still valid when treated as single-digit escapes + 'x' [0-9a-fA-F] + | 'u' [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] + | 'U' [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] + | // Any character other than the Unicode escapes can follow a backslash. Some have special meaning, + // but that doesn't affect the syntax. + ~ [xuU] + ) + | ~ ['\\] + )*; + +InvalidEscapeStringConstant: InvalidEscapeStringText '\'' -> mode (AfterEscapeStringConstantMode); + +InvalidUnterminatedEscapeStringConstant: + InvalidEscapeStringText + // Handle a final unmatched \ character appearing at the end of the file + '\\'? EOF +; + +fragment InvalidEscapeStringText: ('\'\'' | '\\' . | ~ ['\\])*; mode AfterEscapeStringConstantMode; -AfterEscapeStringConstantMode_Whitespace - : Whitespace -> type (Whitespace) , channel (HIDDEN) - ; +AfterEscapeStringConstantMode_Whitespace: Whitespace -> type (Whitespace), channel (HIDDEN); -AfterEscapeStringConstantMode_Newline - : Newline -> type (Newline) , channel (HIDDEN) , mode (AfterEscapeStringConstantWithNewlineMode) - ; +AfterEscapeStringConstantMode_Newline: + Newline -> type (Newline), channel (HIDDEN), mode (AfterEscapeStringConstantWithNewlineMode) +; -AfterEscapeStringConstantMode_NotContinued - : - {} // intentionally empty - -> skip , popMode - ; +AfterEscapeStringConstantMode_NotContinued: + {} // intentionally empty + -> skip, popMode +; mode AfterEscapeStringConstantWithNewlineMode; -AfterEscapeStringConstantWithNewlineMode_Whitespace - : Whitespace -> type (Whitespace) , channel (HIDDEN) - ; +AfterEscapeStringConstantWithNewlineMode_Whitespace: + Whitespace -> type (Whitespace), channel (HIDDEN) +; -AfterEscapeStringConstantWithNewlineMode_Newline - : Newline -> type (Newline) , channel (HIDDEN) - ; +AfterEscapeStringConstantWithNewlineMode_Newline: Newline -> type (Newline), channel (HIDDEN); -AfterEscapeStringConstantWithNewlineMode_Continued - : '\'' -> more , mode (EscapeStringConstantMode) - ; +AfterEscapeStringConstantWithNewlineMode_Continued: + '\'' -> more, mode (EscapeStringConstantMode) +; -AfterEscapeStringConstantWithNewlineMode_NotContinued - : - {} // intentionally empty - -> skip , popMode - ; +AfterEscapeStringConstantWithNewlineMode_NotContinued: + {} // intentionally empty + -> skip, popMode +; mode DollarQuotedStringMode; -DollarText - : ~ '$'+ - //| '$'([0-9])+ - | // this alternative improves the efficiency of handling $ characters within a dollar-quoted string which are - - // not part of the ending tag. - '$' ~ '$'* - ; - -EndDollarStringConstant - : ('$' Tag? '$') - {isTag()}? - {popTag();} -> popMode - ; +DollarText: + ~ '$'+ + //| '$'([0-9])+ + | // this alternative improves the efficiency of handling $ characters within a dollar-quoted string which are + + // not part of the ending tag. + '$' ~ '$'* +; + +EndDollarStringConstant: ('$' Tag? '$') {isTag()}? {popTag();} -> popMode; \ No newline at end of file diff --git a/sql/postgresql/PostgreSQLParser.g4 b/sql/postgresql/PostgreSQLParser.g4 index 2305db02d7..6c09493263 100644 --- a/sql/postgresql/PostgreSQLParser.g4 +++ b/sql/postgresql/PostgreSQLParser.g4 @@ -1,2886 +1,2922 @@ -parser grammar PostgreSQLParser; +// $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 PostgreSQLParser; -options { tokenVocab = PostgreSQLLexer; -superClass = PostgreSQLParserBase; +options { + tokenVocab = PostgreSQLLexer; + superClass = PostgreSQLParserBase; } - -@header -{ +@header { } -@members -{ + +@members { } + root - : stmtblock EOF - ; + : stmtblock EOF + ; plsqlroot - : pl_function - ; + : pl_function + ; stmtblock - : stmtmulti - ; + : stmtmulti + ; stmtmulti - : (stmt SEMI?)* - ; + : (stmt SEMI?)* + ; stmt - : altereventtrigstmt - | altercollationstmt - | alterdatabasestmt - | alterdatabasesetstmt - | alterdefaultprivilegesstmt - | alterdomainstmt - | alterenumstmt - | alterextensionstmt - | alterextensioncontentsstmt - | alterfdwstmt - | alterforeignserverstmt - | alterfunctionstmt - | altergroupstmt - | alterobjectdependsstmt - | alterobjectschemastmt - | alterownerstmt - | alteroperatorstmt - | altertypestmt - | alterpolicystmt - | alterseqstmt - | altersystemstmt - | altertablestmt - | altertblspcstmt - | altercompositetypestmt - | alterpublicationstmt - | alterrolesetstmt - | alterrolestmt - | altersubscriptionstmt - | alterstatsstmt - | altertsconfigurationstmt - | altertsdictionarystmt - | alterusermappingstmt - | analyzestmt - | callstmt - | checkpointstmt - | closeportalstmt - | clusterstmt - | commentstmt - | constraintssetstmt - | copystmt - | createamstmt - | createasstmt - | createassertionstmt - | createcaststmt - | createconversionstmt - | createdomainstmt - | createextensionstmt - | createfdwstmt - | createforeignserverstmt - | createforeigntablestmt - | createfunctionstmt - | creategroupstmt - | creatematviewstmt - | createopclassstmt - | createopfamilystmt - | createpublicationstmt - | alteropfamilystmt - | createpolicystmt - | createplangstmt - | createschemastmt - | createseqstmt - | createstmt - | createsubscriptionstmt - | createstatsstmt - | createtablespacestmt - | createtransformstmt - | createtrigstmt - | createeventtrigstmt - | createrolestmt - | createuserstmt - | createusermappingstmt - | createdbstmt - | deallocatestmt - | declarecursorstmt - | definestmt - | deletestmt - | discardstmt - | dostmt - | dropcaststmt - | dropopclassstmt - | dropopfamilystmt - | dropownedstmt - | dropstmt - | dropsubscriptionstmt - | droptablespacestmt - | droptransformstmt - | droprolestmt - | dropusermappingstmt - | dropdbstmt - | executestmt - | explainstmt - | fetchstmt - | grantstmt - | grantrolestmt - | importforeignschemastmt - | indexstmt - | insertstmt - | mergestmt - | listenstmt - | refreshmatviewstmt - | loadstmt - | lockstmt - | notifystmt - | preparestmt - | reassignownedstmt - | reindexstmt - | removeaggrstmt - | removefuncstmt - | removeoperstmt - | renamestmt - | revokestmt - | revokerolestmt - | rulestmt - | seclabelstmt - | selectstmt - | transactionstmt - | truncatestmt - | unlistenstmt - | updatestmt - | vacuumstmt - | variableresetstmt - | variablesetstmt - | variableshowstmt - | viewstmt - | plsqlconsolecommand - ; + : altereventtrigstmt + | altercollationstmt + | alterdatabasestmt + | alterdatabasesetstmt + | alterdefaultprivilegesstmt + | alterdomainstmt + | alterenumstmt + | alterextensionstmt + | alterextensioncontentsstmt + | alterfdwstmt + | alterforeignserverstmt + | alterfunctionstmt + | altergroupstmt + | alterobjectdependsstmt + | alterobjectschemastmt + | alterownerstmt + | alteroperatorstmt + | altertypestmt + | alterpolicystmt + | alterseqstmt + | altersystemstmt + | altertablestmt + | altertblspcstmt + | altercompositetypestmt + | alterpublicationstmt + | alterrolesetstmt + | alterrolestmt + | altersubscriptionstmt + | alterstatsstmt + | altertsconfigurationstmt + | altertsdictionarystmt + | alterusermappingstmt + | analyzestmt + | callstmt + | checkpointstmt + | closeportalstmt + | clusterstmt + | commentstmt + | constraintssetstmt + | copystmt + | createamstmt + | createasstmt + | createassertionstmt + | createcaststmt + | createconversionstmt + | createdomainstmt + | createextensionstmt + | createfdwstmt + | createforeignserverstmt + | createforeigntablestmt + | createfunctionstmt + | creategroupstmt + | creatematviewstmt + | createopclassstmt + | createopfamilystmt + | createpublicationstmt + | alteropfamilystmt + | createpolicystmt + | createplangstmt + | createschemastmt + | createseqstmt + | createstmt + | createsubscriptionstmt + | createstatsstmt + | createtablespacestmt + | createtransformstmt + | createtrigstmt + | createeventtrigstmt + | createrolestmt + | createuserstmt + | createusermappingstmt + | createdbstmt + | deallocatestmt + | declarecursorstmt + | definestmt + | deletestmt + | discardstmt + | dostmt + | dropcaststmt + | dropopclassstmt + | dropopfamilystmt + | dropownedstmt + | dropstmt + | dropsubscriptionstmt + | droptablespacestmt + | droptransformstmt + | droprolestmt + | dropusermappingstmt + | dropdbstmt + | executestmt + | explainstmt + | fetchstmt + | grantstmt + | grantrolestmt + | importforeignschemastmt + | indexstmt + | insertstmt + | mergestmt + | listenstmt + | refreshmatviewstmt + | loadstmt + | lockstmt + | notifystmt + | preparestmt + | reassignownedstmt + | reindexstmt + | removeaggrstmt + | removefuncstmt + | removeoperstmt + | renamestmt + | revokestmt + | revokerolestmt + | rulestmt + | seclabelstmt + | selectstmt + | transactionstmt + | truncatestmt + | unlistenstmt + | updatestmt + | vacuumstmt + | variableresetstmt + | variablesetstmt + | variableshowstmt + | viewstmt + | plsqlconsolecommand + ; plsqlconsolecommand - : MetaCommand EndMetaCommand? - ; + : MetaCommand EndMetaCommand? + ; callstmt - : CALL func_application - ; + : CALL func_application + ; createrolestmt - : CREATE ROLE roleid opt_with optrolelist - ; + : CREATE ROLE roleid opt_with optrolelist + ; opt_with - : WITH - //| WITH_LA - | - ; + : WITH + //| WITH_LA + | + ; optrolelist - : createoptroleelem* - ; + : createoptroleelem* + ; alteroptrolelist - : alteroptroleelem* - ; + : alteroptroleelem* + ; alteroptroleelem - : PASSWORD (sconst | NULL_P) - | (ENCRYPTED | UNENCRYPTED) PASSWORD sconst - | INHERIT - | CONNECTION LIMIT signediconst - | VALID UNTIL sconst - | USER role_list - | identifier - ; + : PASSWORD (sconst | NULL_P) + | (ENCRYPTED | UNENCRYPTED) PASSWORD sconst + | INHERIT + | CONNECTION LIMIT signediconst + | VALID UNTIL sconst + | USER role_list + | identifier + ; createoptroleelem - : alteroptroleelem - | SYSID iconst - | ADMIN role_list - | ROLE role_list - | IN_P (ROLE | GROUP_P) role_list - ; + : alteroptroleelem + | SYSID iconst + | ADMIN role_list + | ROLE role_list + | IN_P (ROLE | GROUP_P) role_list + ; createuserstmt - : CREATE USER roleid opt_with optrolelist - ; + : CREATE USER roleid opt_with optrolelist + ; alterrolestmt - : ALTER (ROLE | USER) rolespec opt_with alteroptrolelist - ; + : ALTER (ROLE | USER) rolespec opt_with alteroptrolelist + ; opt_in_database - : - | IN_P DATABASE name - ; + : + | IN_P DATABASE name + ; alterrolesetstmt - : ALTER (ROLE | USER) ALL? rolespec opt_in_database setresetclause - ; + : ALTER (ROLE | USER) ALL? rolespec opt_in_database setresetclause + ; droprolestmt - : DROP (ROLE | USER | GROUP_P) (IF_P EXISTS)? role_list - ; + : DROP (ROLE | USER | GROUP_P) (IF_P EXISTS)? role_list + ; creategroupstmt - : CREATE GROUP_P roleid opt_with optrolelist - ; + : CREATE GROUP_P roleid opt_with optrolelist + ; altergroupstmt - : ALTER GROUP_P rolespec add_drop USER role_list - ; + : ALTER GROUP_P rolespec add_drop USER role_list + ; add_drop - : ADD_P - | DROP - ; + : ADD_P + | DROP + ; createschemastmt - : CREATE SCHEMA (IF_P NOT EXISTS)? (optschemaname AUTHORIZATION rolespec | colid) optschemaeltlist - ; + : CREATE SCHEMA (IF_P NOT EXISTS)? (optschemaname AUTHORIZATION rolespec | colid) optschemaeltlist + ; optschemaname - : colid - | - ; + : colid + | + ; optschemaeltlist - : schema_stmt* - ; + : schema_stmt* + ; schema_stmt - : createstmt - | indexstmt - | createseqstmt - | createtrigstmt - | grantstmt - | viewstmt - ; + : createstmt + | indexstmt + | createseqstmt + | createtrigstmt + | grantstmt + | viewstmt + ; variablesetstmt - : SET (LOCAL | SESSION)? set_rest - ; + : SET (LOCAL | SESSION)? set_rest + ; set_rest - : TRANSACTION transaction_mode_list - | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list - | set_rest_more - ; + : TRANSACTION transaction_mode_list + | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list + | set_rest_more + ; generic_set - : var_name (TO | EQUAL) var_list - ; + : var_name (TO | EQUAL) var_list + ; set_rest_more - : generic_set - | var_name FROM CURRENT_P - | TIME ZONE zone_value - | CATALOG sconst - | SCHEMA sconst - | NAMES opt_encoding - | ROLE nonreservedword_or_sconst - | SESSION AUTHORIZATION nonreservedword_or_sconst - | XML_P OPTION document_or_content - | TRANSACTION SNAPSHOT sconst - ; + : generic_set + | var_name FROM CURRENT_P + | TIME ZONE zone_value + | CATALOG sconst + | SCHEMA sconst + | NAMES opt_encoding + | ROLE nonreservedword_or_sconst + | SESSION AUTHORIZATION nonreservedword_or_sconst + | XML_P OPTION document_or_content + | TRANSACTION SNAPSHOT sconst + ; var_name - : colid (DOT colid)* - ; + : colid (DOT colid)* + ; var_list - : var_value (COMMA var_value)* - ; + : var_value (COMMA var_value)* + ; var_value - : opt_boolean_or_string - | numericonly - ; + : opt_boolean_or_string + | numericonly + ; iso_level - : READ (UNCOMMITTED | COMMITTED) - | REPEATABLE READ - | SERIALIZABLE - ; + : READ (UNCOMMITTED | COMMITTED) + | REPEATABLE READ + | SERIALIZABLE + ; opt_boolean_or_string - : TRUE_P - | FALSE_P - | ON - | nonreservedword_or_sconst - ; + : TRUE_P + | FALSE_P + | ON + | nonreservedword_or_sconst + ; zone_value - : sconst - | identifier - | constinterval sconst opt_interval - | constinterval OPEN_PAREN iconst CLOSE_PAREN sconst - | numericonly - | DEFAULT - | LOCAL - ; + : sconst + | identifier + | constinterval sconst opt_interval + | constinterval OPEN_PAREN iconst CLOSE_PAREN sconst + | numericonly + | DEFAULT + | LOCAL + ; opt_encoding - : sconst - | DEFAULT - | - ; + : sconst + | DEFAULT + | + ; nonreservedword_or_sconst - : nonreservedword - | sconst - ; + : nonreservedword + | sconst + ; variableresetstmt - : RESET reset_rest - ; + : RESET reset_rest + ; reset_rest - : generic_reset - | TIME ZONE - | TRANSACTION ISOLATION LEVEL - | SESSION AUTHORIZATION - ; + : generic_reset + | TIME ZONE + | TRANSACTION ISOLATION LEVEL + | SESSION AUTHORIZATION + ; generic_reset - : var_name - | ALL - ; + : var_name + | ALL + ; setresetclause - : SET set_rest - | variableresetstmt - ; + : SET set_rest + | variableresetstmt + ; functionsetresetclause - : SET set_rest_more - | variableresetstmt - ; + : SET set_rest_more + | variableresetstmt + ; variableshowstmt - : SHOW (var_name | TIME ZONE | TRANSACTION ISOLATION LEVEL | SESSION AUTHORIZATION | ALL) - ; + : SHOW (var_name | TIME ZONE | TRANSACTION ISOLATION LEVEL | SESSION AUTHORIZATION | ALL) + ; constraintssetstmt - : SET CONSTRAINTS constraints_set_list constraints_set_mode - ; + : SET CONSTRAINTS constraints_set_list constraints_set_mode + ; constraints_set_list - : ALL - | qualified_name_list - ; + : ALL + | qualified_name_list + ; constraints_set_mode - : DEFERRED - | IMMEDIATE - ; + : DEFERRED + | IMMEDIATE + ; checkpointstmt - : CHECKPOINT - ; + : CHECKPOINT + ; discardstmt - : DISCARD (ALL | TEMP | TEMPORARY | PLANS | SEQUENCES) - ; + : DISCARD (ALL | TEMP | TEMPORARY | PLANS | SEQUENCES) + ; altertablestmt - : ALTER TABLE (IF_P EXISTS)? relation_expr (alter_table_cmds | partition_cmd) - | ALTER TABLE ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait - | ALTER INDEX (IF_P EXISTS)? qualified_name (alter_table_cmds | index_partition_cmd) - | ALTER INDEX ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait - | ALTER SEQUENCE (IF_P EXISTS)? qualified_name alter_table_cmds - | ALTER VIEW (IF_P EXISTS)? qualified_name alter_table_cmds - | ALTER MATERIALIZED VIEW (IF_P EXISTS)? qualified_name alter_table_cmds - | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait - | ALTER FOREIGN TABLE (IF_P EXISTS)? relation_expr alter_table_cmds - ; + : ALTER TABLE (IF_P EXISTS)? relation_expr (alter_table_cmds | partition_cmd) + | ALTER TABLE ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait + | ALTER INDEX (IF_P EXISTS)? qualified_name (alter_table_cmds | index_partition_cmd) + | ALTER INDEX ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait + | ALTER SEQUENCE (IF_P EXISTS)? qualified_name alter_table_cmds + | ALTER VIEW (IF_P EXISTS)? qualified_name alter_table_cmds + | ALTER MATERIALIZED VIEW (IF_P EXISTS)? qualified_name alter_table_cmds + | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait + | ALTER FOREIGN TABLE (IF_P EXISTS)? relation_expr alter_table_cmds + ; alter_table_cmds - : alter_table_cmd (COMMA alter_table_cmd)* - ; + : alter_table_cmd (COMMA alter_table_cmd)* + ; partition_cmd - : ATTACH PARTITION qualified_name partitionboundspec - | DETACH PARTITION qualified_name - ; + : ATTACH PARTITION qualified_name partitionboundspec + | DETACH PARTITION qualified_name + ; index_partition_cmd - : ATTACH PARTITION qualified_name - ; + : ATTACH PARTITION qualified_name + ; alter_table_cmd - : ADD_P columnDef - | ADD_P IF_P NOT EXISTS columnDef - | ADD_P COLUMN columnDef - | ADD_P COLUMN IF_P NOT EXISTS columnDef - | ALTER opt_column colid alter_column_default - | ALTER opt_column colid DROP NOT NULL_P - | ALTER opt_column colid SET NOT NULL_P - | ALTER opt_column colid DROP EXPRESSION - | ALTER opt_column colid DROP EXPRESSION IF_P EXISTS - | ALTER opt_column colid SET STATISTICS signediconst - | ALTER opt_column iconst SET STATISTICS signediconst - | ALTER opt_column colid SET reloptions - | ALTER opt_column colid RESET reloptions - | ALTER opt_column colid SET STORAGE colid - | ALTER opt_column colid ADD_P GENERATED generated_when AS IDENTITY_P optparenthesizedseqoptlist - | ALTER opt_column colid alter_identity_column_option_list - | ALTER opt_column colid DROP IDENTITY_P - | ALTER opt_column colid DROP IDENTITY_P IF_P EXISTS - | DROP opt_column IF_P EXISTS colid opt_drop_behavior - | DROP opt_column colid opt_drop_behavior - | ALTER opt_column colid opt_set_data TYPE_P typename opt_collate_clause alter_using - | ALTER opt_column colid alter_generic_options - | ADD_P tableconstraint - | ALTER CONSTRAINT name constraintattributespec - | VALIDATE CONSTRAINT name - | DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior - | DROP CONSTRAINT name opt_drop_behavior - | SET WITHOUT OIDS - | CLUSTER ON name - | SET WITHOUT CLUSTER - | SET LOGGED - | SET UNLOGGED - | ENABLE_P TRIGGER name - | ENABLE_P ALWAYS TRIGGER name - | ENABLE_P REPLICA TRIGGER name - | ENABLE_P TRIGGER ALL - | ENABLE_P TRIGGER USER - | DISABLE_P TRIGGER name - | DISABLE_P TRIGGER ALL - | DISABLE_P TRIGGER USER - | ENABLE_P RULE name - | ENABLE_P ALWAYS RULE name - | ENABLE_P REPLICA RULE name - | DISABLE_P RULE name - | INHERIT qualified_name - | NO INHERIT qualified_name - | OF any_name - | NOT OF - | OWNER TO rolespec - | SET TABLESPACE name - | SET reloptions - | RESET reloptions - | REPLICA IDENTITY_P replica_identity - | ENABLE_P ROW LEVEL SECURITY - | DISABLE_P ROW LEVEL SECURITY - | FORCE ROW LEVEL SECURITY - | NO FORCE ROW LEVEL SECURITY - | alter_generic_options - ; + : ADD_P columnDef + | ADD_P IF_P NOT EXISTS columnDef + | ADD_P COLUMN columnDef + | ADD_P COLUMN IF_P NOT EXISTS columnDef + | ALTER opt_column colid alter_column_default + | ALTER opt_column colid DROP NOT NULL_P + | ALTER opt_column colid SET NOT NULL_P + | ALTER opt_column colid DROP EXPRESSION + | ALTER opt_column colid DROP EXPRESSION IF_P EXISTS + | ALTER opt_column colid SET STATISTICS signediconst + | ALTER opt_column iconst SET STATISTICS signediconst + | ALTER opt_column colid SET reloptions + | ALTER opt_column colid RESET reloptions + | ALTER opt_column colid SET STORAGE colid + | ALTER opt_column colid ADD_P GENERATED generated_when AS IDENTITY_P optparenthesizedseqoptlist + | ALTER opt_column colid alter_identity_column_option_list + | ALTER opt_column colid DROP IDENTITY_P + | ALTER opt_column colid DROP IDENTITY_P IF_P EXISTS + | DROP opt_column IF_P EXISTS colid opt_drop_behavior + | DROP opt_column colid opt_drop_behavior + | ALTER opt_column colid opt_set_data TYPE_P typename opt_collate_clause alter_using + | ALTER opt_column colid alter_generic_options + | ADD_P tableconstraint + | ALTER CONSTRAINT name constraintattributespec + | VALIDATE CONSTRAINT name + | DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior + | DROP CONSTRAINT name opt_drop_behavior + | SET WITHOUT OIDS + | CLUSTER ON name + | SET WITHOUT CLUSTER + | SET LOGGED + | SET UNLOGGED + | ENABLE_P TRIGGER name + | ENABLE_P ALWAYS TRIGGER name + | ENABLE_P REPLICA TRIGGER name + | ENABLE_P TRIGGER ALL + | ENABLE_P TRIGGER USER + | DISABLE_P TRIGGER name + | DISABLE_P TRIGGER ALL + | DISABLE_P TRIGGER USER + | ENABLE_P RULE name + | ENABLE_P ALWAYS RULE name + | ENABLE_P REPLICA RULE name + | DISABLE_P RULE name + | INHERIT qualified_name + | NO INHERIT qualified_name + | OF any_name + | NOT OF + | OWNER TO rolespec + | SET TABLESPACE name + | SET reloptions + | RESET reloptions + | REPLICA IDENTITY_P replica_identity + | ENABLE_P ROW LEVEL SECURITY + | DISABLE_P ROW LEVEL SECURITY + | FORCE ROW LEVEL SECURITY + | NO FORCE ROW LEVEL SECURITY + | alter_generic_options + ; alter_column_default - : SET DEFAULT a_expr - | DROP DEFAULT - ; + : SET DEFAULT a_expr + | DROP DEFAULT + ; opt_drop_behavior - : CASCADE - | RESTRICT - | - ; + : CASCADE + | RESTRICT + | + ; opt_collate_clause - : COLLATE any_name - | - ; + : COLLATE any_name + | + ; alter_using - : USING a_expr - | - ; + : USING a_expr + | + ; replica_identity - : NOTHING - | FULL - | DEFAULT - | USING INDEX name - ; + : NOTHING + | FULL + | DEFAULT + | USING INDEX name + ; reloptions - : OPEN_PAREN reloption_list CLOSE_PAREN - ; + : OPEN_PAREN reloption_list CLOSE_PAREN + ; opt_reloptions - : WITH reloptions - | - ; + : WITH reloptions + | + ; reloption_list - : reloption_elem (COMMA reloption_elem)* - ; + : reloption_elem (COMMA reloption_elem)* + ; reloption_elem - : collabel (EQUAL def_arg | DOT collabel (EQUAL def_arg)?)? - ; + : collabel (EQUAL def_arg | DOT collabel (EQUAL def_arg)?)? + ; alter_identity_column_option_list - : alter_identity_column_option+ - ; + : alter_identity_column_option+ + ; alter_identity_column_option - : RESTART (opt_with numericonly)? - | SET (seqoptelem | GENERATED generated_when) - ; + : RESTART (opt_with numericonly)? + | SET (seqoptelem | GENERATED generated_when) + ; partitionboundspec - : FOR VALUES WITH OPEN_PAREN hash_partbound CLOSE_PAREN - | FOR VALUES IN_P OPEN_PAREN expr_list CLOSE_PAREN - | FOR VALUES FROM OPEN_PAREN expr_list CLOSE_PAREN TO OPEN_PAREN expr_list CLOSE_PAREN - | DEFAULT - ; + : FOR VALUES WITH OPEN_PAREN hash_partbound CLOSE_PAREN + | FOR VALUES IN_P OPEN_PAREN expr_list CLOSE_PAREN + | FOR VALUES FROM OPEN_PAREN expr_list CLOSE_PAREN TO OPEN_PAREN expr_list CLOSE_PAREN + | DEFAULT + ; hash_partbound_elem - : nonreservedword iconst - ; + : nonreservedword iconst + ; hash_partbound - : hash_partbound_elem (COMMA hash_partbound_elem)* - ; + : hash_partbound_elem (COMMA hash_partbound_elem)* + ; altercompositetypestmt - : ALTER TYPE_P any_name alter_type_cmds - ; + : ALTER TYPE_P any_name alter_type_cmds + ; alter_type_cmds - : alter_type_cmd (COMMA alter_type_cmd)* - ; + : alter_type_cmd (COMMA alter_type_cmd)* + ; alter_type_cmd - : ADD_P ATTRIBUTE tablefuncelement opt_drop_behavior - | DROP ATTRIBUTE (IF_P EXISTS)? colid opt_drop_behavior - | ALTER ATTRIBUTE colid opt_set_data TYPE_P typename opt_collate_clause opt_drop_behavior - ; + : ADD_P ATTRIBUTE tablefuncelement opt_drop_behavior + | DROP ATTRIBUTE (IF_P EXISTS)? colid opt_drop_behavior + | ALTER ATTRIBUTE colid opt_set_data TYPE_P typename opt_collate_clause opt_drop_behavior + ; closeportalstmt - : CLOSE (cursor_name | ALL) - ; + : CLOSE (cursor_name | ALL) + ; copystmt - : COPY opt_binary qualified_name opt_column_list copy_from opt_program copy_file_name copy_delimiter opt_with copy_options where_clause - | COPY OPEN_PAREN preparablestmt CLOSE_PAREN TO opt_program copy_file_name opt_with copy_options - ; + : COPY opt_binary qualified_name opt_column_list copy_from opt_program copy_file_name copy_delimiter opt_with copy_options where_clause + | COPY OPEN_PAREN preparablestmt CLOSE_PAREN TO opt_program copy_file_name opt_with copy_options + ; copy_from - : FROM - | TO - ; + : FROM + | TO + ; opt_program - : PROGRAM - | - ; + : PROGRAM + | + ; copy_file_name - : sconst - | STDIN - | STDOUT - ; + : sconst + | STDIN + | STDOUT + ; copy_options - : copy_opt_list - | OPEN_PAREN copy_generic_opt_list CLOSE_PAREN - ; + : copy_opt_list + | OPEN_PAREN copy_generic_opt_list CLOSE_PAREN + ; copy_opt_list - : copy_opt_item* - ; + : copy_opt_item* + ; copy_opt_item - : BINARY - | FREEZE - | DELIMITER opt_as sconst - | NULL_P opt_as sconst - | CSV - | HEADER_P - | QUOTE opt_as sconst - | ESCAPE opt_as sconst - | FORCE QUOTE columnlist - | FORCE QUOTE STAR - | FORCE NOT NULL_P columnlist - | FORCE NULL_P columnlist - | ENCODING sconst - ; + : BINARY + | FREEZE + | DELIMITER opt_as sconst + | NULL_P opt_as sconst + | CSV + | HEADER_P + | QUOTE opt_as sconst + | ESCAPE opt_as sconst + | FORCE QUOTE columnlist + | FORCE QUOTE STAR + | FORCE NOT NULL_P columnlist + | FORCE NULL_P columnlist + | ENCODING sconst + ; opt_binary - : BINARY - | - ; + : BINARY + | + ; copy_delimiter - : opt_using DELIMITERS sconst - | - ; + : opt_using DELIMITERS sconst + | + ; opt_using - : USING - | - ; + : USING + | + ; copy_generic_opt_list - : copy_generic_opt_elem (COMMA copy_generic_opt_elem)* - ; + : copy_generic_opt_elem (COMMA copy_generic_opt_elem)* + ; copy_generic_opt_elem - : collabel copy_generic_opt_arg - ; + : collabel copy_generic_opt_arg + ; copy_generic_opt_arg - : opt_boolean_or_string - | numericonly - | STAR - | OPEN_PAREN copy_generic_opt_arg_list CLOSE_PAREN - | - ; + : opt_boolean_or_string + | numericonly + | STAR + | OPEN_PAREN copy_generic_opt_arg_list CLOSE_PAREN + | + ; copy_generic_opt_arg_list - : copy_generic_opt_arg_list_item (COMMA copy_generic_opt_arg_list_item)* - ; + : copy_generic_opt_arg_list_item (COMMA copy_generic_opt_arg_list_item)* + ; copy_generic_opt_arg_list_item - : opt_boolean_or_string - ; + : opt_boolean_or_string + ; createstmt - : CREATE opttemp TABLE (IF_P NOT EXISTS)? qualified_name (OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit optpartitionspec table_access_method_clause optwith oncommitoption opttablespace | OF any_name opttypedtableelementlist optpartitionspec table_access_method_clause optwith oncommitoption opttablespace | PARTITION OF qualified_name opttypedtableelementlist partitionboundspec optpartitionspec table_access_method_clause optwith oncommitoption opttablespace) - ; + : CREATE opttemp TABLE (IF_P NOT EXISTS)? qualified_name ( + OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit optpartitionspec table_access_method_clause optwith oncommitoption opttablespace + | OF any_name opttypedtableelementlist optpartitionspec table_access_method_clause optwith oncommitoption opttablespace + | PARTITION OF qualified_name opttypedtableelementlist partitionboundspec optpartitionspec table_access_method_clause optwith oncommitoption + opttablespace + ) + ; opttemp - : TEMPORARY - | TEMP - | LOCAL (TEMPORARY | TEMP) - | GLOBAL (TEMPORARY | TEMP) - | UNLOGGED - | - ; + : TEMPORARY + | TEMP + | LOCAL (TEMPORARY | TEMP) + | GLOBAL (TEMPORARY | TEMP) + | UNLOGGED + | + ; opttableelementlist - : tableelementlist - | - ; + : tableelementlist + | + ; opttypedtableelementlist - : OPEN_PAREN typedtableelementlist CLOSE_PAREN - | - ; + : OPEN_PAREN typedtableelementlist CLOSE_PAREN + | + ; tableelementlist - : tableelement (COMMA tableelement)* - ; + : tableelement (COMMA tableelement)* + ; typedtableelementlist - : typedtableelement (COMMA typedtableelement)* - ; + : typedtableelement (COMMA typedtableelement)* + ; tableelement - : tableconstraint - | tablelikeclause - | columnDef - ; + : tableconstraint + | tablelikeclause + | columnDef + ; typedtableelement - : columnOptions - | tableconstraint - ; + : columnOptions + | tableconstraint + ; columnDef - : colid typename create_generic_options colquallist - ; + : colid typename create_generic_options colquallist + ; columnOptions - : colid (WITH OPTIONS)? colquallist - ; + : colid (WITH OPTIONS)? colquallist + ; colquallist - : colconstraint* - ; + : colconstraint* + ; colconstraint - : CONSTRAINT name colconstraintelem - | colconstraintelem - | constraintattr - | COLLATE any_name - ; + : CONSTRAINT name colconstraintelem + | colconstraintelem + | constraintattr + | COLLATE any_name + ; colconstraintelem - : NOT NULL_P - | NULL_P - | UNIQUE opt_definition optconstablespace - | PRIMARY KEY opt_definition optconstablespace - | CHECK OPEN_PAREN a_expr CLOSE_PAREN opt_no_inherit - | DEFAULT b_expr - | GENERATED generated_when AS (IDENTITY_P optparenthesizedseqoptlist | OPEN_PAREN a_expr CLOSE_PAREN STORED) - | REFERENCES qualified_name opt_column_list key_match key_actions - ; + : NOT NULL_P + | NULL_P + | UNIQUE opt_definition optconstablespace + | PRIMARY KEY opt_definition optconstablespace + | CHECK OPEN_PAREN a_expr CLOSE_PAREN opt_no_inherit + | DEFAULT b_expr + | GENERATED generated_when AS ( + IDENTITY_P optparenthesizedseqoptlist + | OPEN_PAREN a_expr CLOSE_PAREN STORED + ) + | REFERENCES qualified_name opt_column_list key_match key_actions + ; generated_when - : ALWAYS - | BY DEFAULT - ; + : ALWAYS + | BY DEFAULT + ; constraintattr - : DEFERRABLE - | NOT DEFERRABLE - | INITIALLY (DEFERRED | IMMEDIATE) - ; + : DEFERRABLE + | NOT DEFERRABLE + | INITIALLY (DEFERRED | IMMEDIATE) + ; tablelikeclause - : LIKE qualified_name tablelikeoptionlist - ; + : LIKE qualified_name tablelikeoptionlist + ; tablelikeoptionlist - : ((INCLUDING | EXCLUDING) tablelikeoption)* - ; + : ((INCLUDING | EXCLUDING) tablelikeoption)* + ; tablelikeoption - : COMMENTS - | CONSTRAINTS - | DEFAULTS - | IDENTITY_P - | GENERATED - | INDEXES - | STATISTICS - | STORAGE - | ALL - ; + : COMMENTS + | CONSTRAINTS + | DEFAULTS + | IDENTITY_P + | GENERATED + | INDEXES + | STATISTICS + | STORAGE + | ALL + ; tableconstraint - : CONSTRAINT name constraintelem - | constraintelem - ; + : CONSTRAINT name constraintelem + | constraintelem + ; constraintelem - : CHECK OPEN_PAREN a_expr CLOSE_PAREN constraintattributespec - | UNIQUE (OPEN_PAREN columnlist CLOSE_PAREN opt_c_include opt_definition optconstablespace constraintattributespec | existingindex constraintattributespec) - | PRIMARY KEY (OPEN_PAREN columnlist CLOSE_PAREN opt_c_include opt_definition optconstablespace constraintattributespec | existingindex constraintattributespec) - | EXCLUDE access_method_clause OPEN_PAREN exclusionconstraintlist CLOSE_PAREN opt_c_include opt_definition optconstablespace exclusionwhereclause constraintattributespec - | FOREIGN KEY OPEN_PAREN columnlist CLOSE_PAREN REFERENCES qualified_name opt_column_list key_match key_actions constraintattributespec - ; + : CHECK OPEN_PAREN a_expr CLOSE_PAREN constraintattributespec + | UNIQUE ( + OPEN_PAREN columnlist CLOSE_PAREN opt_c_include opt_definition optconstablespace constraintattributespec + | existingindex constraintattributespec + ) + | PRIMARY KEY ( + OPEN_PAREN columnlist CLOSE_PAREN opt_c_include opt_definition optconstablespace constraintattributespec + | existingindex constraintattributespec + ) + | EXCLUDE access_method_clause OPEN_PAREN exclusionconstraintlist CLOSE_PAREN opt_c_include opt_definition optconstablespace exclusionwhereclause + constraintattributespec + | FOREIGN KEY OPEN_PAREN columnlist CLOSE_PAREN REFERENCES qualified_name opt_column_list key_match key_actions constraintattributespec + ; opt_no_inherit - : NO INHERIT - | - ; + : NO INHERIT + | + ; opt_column_list - : OPEN_PAREN columnlist CLOSE_PAREN - | - ; + : OPEN_PAREN columnlist CLOSE_PAREN + | + ; columnlist - : columnElem (COMMA columnElem)* - ; + : columnElem (COMMA columnElem)* + ; columnElem - : colid - ; + : colid + ; opt_c_include - : INCLUDE OPEN_PAREN columnlist CLOSE_PAREN - | - ; + : INCLUDE OPEN_PAREN columnlist CLOSE_PAREN + | + ; key_match - : MATCH (FULL | PARTIAL | SIMPLE) - | - ; + : MATCH (FULL | PARTIAL | SIMPLE) + | + ; exclusionconstraintlist - : exclusionconstraintelem (COMMA exclusionconstraintelem)* - ; + : exclusionconstraintelem (COMMA exclusionconstraintelem)* + ; exclusionconstraintelem - : index_elem WITH (any_operator | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN) - ; + : index_elem WITH (any_operator | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN) + ; exclusionwhereclause - : WHERE OPEN_PAREN a_expr CLOSE_PAREN - | - ; + : WHERE OPEN_PAREN a_expr CLOSE_PAREN + | + ; key_actions - : key_update - | key_delete - | key_update key_delete - | key_delete key_update - | - ; + : key_update + | key_delete + | key_update key_delete + | key_delete key_update + | + ; key_update - : ON UPDATE key_action - ; + : ON UPDATE key_action + ; key_delete - : ON DELETE_P key_action - ; + : ON DELETE_P key_action + ; key_action - : NO ACTION - | RESTRICT - | CASCADE - | SET (NULL_P | DEFAULT) - ; + : NO ACTION + | RESTRICT + | CASCADE + | SET (NULL_P | DEFAULT) + ; optinherit - : INHERITS OPEN_PAREN qualified_name_list CLOSE_PAREN - | - ; + : INHERITS OPEN_PAREN qualified_name_list CLOSE_PAREN + | + ; optpartitionspec - : partitionspec - | - ; + : partitionspec + | + ; partitionspec - : PARTITION BY colid OPEN_PAREN part_params CLOSE_PAREN - ; + : PARTITION BY colid OPEN_PAREN part_params CLOSE_PAREN + ; part_params - : part_elem (COMMA part_elem)* - ; + : part_elem (COMMA part_elem)* + ; part_elem - : colid opt_collate opt_class - | func_expr_windowless opt_collate opt_class - | OPEN_PAREN a_expr CLOSE_PAREN opt_collate opt_class - ; + : colid opt_collate opt_class + | func_expr_windowless opt_collate opt_class + | OPEN_PAREN a_expr CLOSE_PAREN opt_collate opt_class + ; table_access_method_clause - : USING name - | - ; + : USING name + | + ; optwith - : WITH reloptions - | WITHOUT OIDS - | - ; + : WITH reloptions + | WITHOUT OIDS + | + ; oncommitoption - : ON COMMIT (DROP | DELETE_P ROWS | PRESERVE ROWS) - | - ; + : ON COMMIT (DROP | DELETE_P ROWS | PRESERVE ROWS) + | + ; opttablespace - : TABLESPACE name - | - ; + : TABLESPACE name + | + ; optconstablespace - : USING INDEX TABLESPACE name - | - ; + : USING INDEX TABLESPACE name + | + ; existingindex - : USING INDEX name - ; + : USING INDEX name + ; createstatsstmt - : CREATE STATISTICS (IF_P NOT EXISTS)? any_name opt_name_list ON expr_list FROM from_list - ; + : CREATE STATISTICS (IF_P NOT EXISTS)? any_name opt_name_list ON expr_list FROM from_list + ; alterstatsstmt - : ALTER STATISTICS (IF_P EXISTS)? any_name SET STATISTICS signediconst - ; + : ALTER STATISTICS (IF_P EXISTS)? any_name SET STATISTICS signediconst + ; createasstmt - : CREATE opttemp TABLE (IF_P NOT EXISTS)? create_as_target AS selectstmt opt_with_data - ; + : CREATE opttemp TABLE (IF_P NOT EXISTS)? create_as_target AS selectstmt opt_with_data + ; create_as_target - : qualified_name opt_column_list table_access_method_clause optwith oncommitoption opttablespace - ; + : qualified_name opt_column_list table_access_method_clause optwith oncommitoption opttablespace + ; opt_with_data - : WITH (DATA_P | NO DATA_P) - | - ; + : WITH (DATA_P | NO DATA_P) + | + ; creatematviewstmt - : CREATE optnolog MATERIALIZED VIEW (IF_P NOT EXISTS)? create_mv_target AS selectstmt opt_with_data - ; + : CREATE optnolog MATERIALIZED VIEW (IF_P NOT EXISTS)? create_mv_target AS selectstmt opt_with_data + ; create_mv_target - : qualified_name opt_column_list table_access_method_clause opt_reloptions opttablespace - ; + : qualified_name opt_column_list table_access_method_clause opt_reloptions opttablespace + ; optnolog - : UNLOGGED - | - ; + : UNLOGGED + | + ; refreshmatviewstmt - : REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data - ; + : REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data + ; createseqstmt - : CREATE opttemp SEQUENCE (IF_P NOT EXISTS)? qualified_name optseqoptlist - ; + : CREATE opttemp SEQUENCE (IF_P NOT EXISTS)? qualified_name optseqoptlist + ; alterseqstmt - : ALTER SEQUENCE (IF_P EXISTS)? qualified_name seqoptlist - ; + : ALTER SEQUENCE (IF_P EXISTS)? qualified_name seqoptlist + ; optseqoptlist - : seqoptlist - | - ; + : seqoptlist + | + ; optparenthesizedseqoptlist - : OPEN_PAREN seqoptlist CLOSE_PAREN - | - ; + : OPEN_PAREN seqoptlist CLOSE_PAREN + | + ; seqoptlist - : seqoptelem+ - ; + : seqoptelem+ + ; seqoptelem - : AS simpletypename - | CACHE numericonly - | CYCLE - | INCREMENT opt_by numericonly - | MAXVALUE numericonly - | MINVALUE numericonly - | NO (MAXVALUE | MINVALUE | CYCLE) - | OWNED BY any_name - | SEQUENCE NAME_P any_name - | START opt_with numericonly - | RESTART opt_with numericonly? - ; + : AS simpletypename + | CACHE numericonly + | CYCLE + | INCREMENT opt_by numericonly + | MAXVALUE numericonly + | MINVALUE numericonly + | NO (MAXVALUE | MINVALUE | CYCLE) + | OWNED BY any_name + | SEQUENCE NAME_P any_name + | START opt_with numericonly + | RESTART opt_with numericonly? + ; opt_by - : BY - | - ; + : BY + | + ; numericonly - : fconst - | PLUS fconst - | MINUS fconst - | signediconst - ; + : fconst + | PLUS fconst + | MINUS fconst + | signediconst + ; numericonly_list - : numericonly (COMMA numericonly)* - ; + : numericonly (COMMA numericonly)* + ; createplangstmt - : CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name (HANDLER handler_name opt_inline_handler opt_validator)? - ; + : CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name ( + HANDLER handler_name opt_inline_handler opt_validator + )? + ; opt_trusted - : TRUSTED - | - ; + : TRUSTED + | + ; handler_name - : name attrs? - ; + : name attrs? + ; opt_inline_handler - : INLINE_P handler_name - | - ; + : INLINE_P handler_name + | + ; validator_clause - : VALIDATOR handler_name - | NO VALIDATOR - ; + : VALIDATOR handler_name + | NO VALIDATOR + ; opt_validator - : validator_clause - | - ; + : validator_clause + | + ; opt_procedural - : PROCEDURAL - | - ; + : PROCEDURAL + | + ; createtablespacestmt - : CREATE TABLESPACE name opttablespaceowner LOCATION sconst opt_reloptions - ; + : CREATE TABLESPACE name opttablespaceowner LOCATION sconst opt_reloptions + ; opttablespaceowner - : OWNER rolespec - | - ; + : OWNER rolespec + | + ; droptablespacestmt - : DROP TABLESPACE (IF_P EXISTS)? name - ; + : DROP TABLESPACE (IF_P EXISTS)? name + ; createextensionstmt - : CREATE EXTENSION (IF_P NOT EXISTS)? name opt_with create_extension_opt_list - ; + : CREATE EXTENSION (IF_P NOT EXISTS)? name opt_with create_extension_opt_list + ; create_extension_opt_list - : create_extension_opt_item* - ; + : create_extension_opt_item* + ; create_extension_opt_item - : SCHEMA name - | VERSION_P nonreservedword_or_sconst - | FROM nonreservedword_or_sconst - | CASCADE - ; + : SCHEMA name + | VERSION_P nonreservedword_or_sconst + | FROM nonreservedword_or_sconst + | CASCADE + ; alterextensionstmt - : ALTER EXTENSION name UPDATE alter_extension_opt_list - ; + : ALTER EXTENSION name UPDATE alter_extension_opt_list + ; alter_extension_opt_list - : alter_extension_opt_item* - ; + : alter_extension_opt_item* + ; alter_extension_opt_item - : TO nonreservedword_or_sconst - ; + : TO nonreservedword_or_sconst + ; alterextensioncontentsstmt - : ALTER EXTENSION name add_drop object_type_name name - | ALTER EXTENSION name add_drop object_type_any_name any_name - | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes - | ALTER EXTENSION name add_drop CAST OPEN_PAREN typename AS typename CLOSE_PAREN - | ALTER EXTENSION name add_drop DOMAIN_P typename - | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes - | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes - | ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING name - | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING name - | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes - | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes - | ALTER EXTENSION name add_drop TRANSFORM FOR typename LANGUAGE name - | ALTER EXTENSION name add_drop TYPE_P typename - ; + : ALTER EXTENSION name add_drop object_type_name name + | ALTER EXTENSION name add_drop object_type_any_name any_name + | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes + | ALTER EXTENSION name add_drop CAST OPEN_PAREN typename AS typename CLOSE_PAREN + | ALTER EXTENSION name add_drop DOMAIN_P typename + | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes + | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes + | ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING name + | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING name + | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes + | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes + | ALTER EXTENSION name add_drop TRANSFORM FOR typename LANGUAGE name + | ALTER EXTENSION name add_drop TYPE_P typename + ; createfdwstmt - : CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options - ; + : CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options + ; fdw_option - : HANDLER handler_name - | NO HANDLER - | VALIDATOR handler_name - | NO VALIDATOR - ; + : HANDLER handler_name + | NO HANDLER + | VALIDATOR handler_name + | NO VALIDATOR + ; fdw_options - : fdw_option+ - ; + : fdw_option+ + ; opt_fdw_options - : fdw_options - | - ; + : fdw_options + | + ; alterfdwstmt - : ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options - | ALTER FOREIGN DATA_P WRAPPER name fdw_options - ; + : ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options + | ALTER FOREIGN DATA_P WRAPPER name fdw_options + ; create_generic_options - : OPTIONS OPEN_PAREN generic_option_list CLOSE_PAREN - | - ; + : OPTIONS OPEN_PAREN generic_option_list CLOSE_PAREN + | + ; generic_option_list - : generic_option_elem (COMMA generic_option_elem)* - ; + : generic_option_elem (COMMA generic_option_elem)* + ; alter_generic_options - : OPTIONS OPEN_PAREN alter_generic_option_list CLOSE_PAREN - ; + : OPTIONS OPEN_PAREN alter_generic_option_list CLOSE_PAREN + ; alter_generic_option_list - : alter_generic_option_elem (COMMA alter_generic_option_elem)* - ; + : alter_generic_option_elem (COMMA alter_generic_option_elem)* + ; alter_generic_option_elem - : generic_option_elem - | SET generic_option_elem - | ADD_P generic_option_elem - | DROP generic_option_name - ; + : generic_option_elem + | SET generic_option_elem + | ADD_P generic_option_elem + | DROP generic_option_name + ; generic_option_elem - : generic_option_name generic_option_arg - ; + : generic_option_name generic_option_arg + ; generic_option_name - : collabel - ; + : collabel + ; generic_option_arg - : sconst - ; + : sconst + ; createforeignserverstmt - : CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options - | CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options - ; + : CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options + | CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options + ; opt_type - : TYPE_P sconst - | - ; + : TYPE_P sconst + | + ; foreign_server_version - : VERSION_P (sconst | NULL_P) - ; + : VERSION_P (sconst | NULL_P) + ; opt_foreign_server_version - : foreign_server_version - | - ; + : foreign_server_version + | + ; alterforeignserverstmt - : ALTER SERVER name (alter_generic_options | foreign_server_version alter_generic_options?) - ; + : ALTER SERVER name (alter_generic_options | foreign_server_version alter_generic_options?) + ; createforeigntablestmt - : CREATE FOREIGN TABLE qualified_name OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit SERVER name create_generic_options - | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit SERVER name create_generic_options - | CREATE FOREIGN TABLE qualified_name PARTITION OF qualified_name opttypedtableelementlist partitionboundspec SERVER name create_generic_options - | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name opttypedtableelementlist partitionboundspec SERVER name create_generic_options - ; + : CREATE FOREIGN TABLE qualified_name OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit SERVER name create_generic_options + | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit SERVER name create_generic_options + | CREATE FOREIGN TABLE qualified_name PARTITION OF qualified_name opttypedtableelementlist partitionboundspec SERVER name create_generic_options + | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name opttypedtableelementlist partitionboundspec SERVER name + create_generic_options + ; importforeignschemastmt - : IMPORT_P FOREIGN SCHEMA name import_qualification FROM SERVER name INTO name create_generic_options - ; + : IMPORT_P FOREIGN SCHEMA name import_qualification FROM SERVER name INTO name create_generic_options + ; import_qualification_type - : LIMIT TO - | EXCEPT - ; + : LIMIT TO + | EXCEPT + ; import_qualification - : import_qualification_type OPEN_PAREN relation_expr_list CLOSE_PAREN - | - ; + : import_qualification_type OPEN_PAREN relation_expr_list CLOSE_PAREN + | + ; createusermappingstmt - : CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options - | CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options - ; + : CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options + | CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options + ; auth_ident - : rolespec - | USER - ; + : rolespec + | USER + ; dropusermappingstmt - : DROP USER MAPPING FOR auth_ident SERVER name - | DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name - ; + : DROP USER MAPPING FOR auth_ident SERVER name + | DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name + ; alterusermappingstmt - : ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options - ; + : ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options + ; createpolicystmt - : CREATE POLICY name ON qualified_name rowsecuritydefaultpermissive rowsecuritydefaultforcmd rowsecuritydefaulttorole rowsecurityoptionalexpr rowsecurityoptionalwithcheck - ; + : CREATE POLICY name ON qualified_name rowsecuritydefaultpermissive rowsecuritydefaultforcmd rowsecuritydefaulttorole rowsecurityoptionalexpr + rowsecurityoptionalwithcheck + ; alterpolicystmt - : ALTER POLICY name ON qualified_name rowsecurityoptionaltorole rowsecurityoptionalexpr rowsecurityoptionalwithcheck - ; + : ALTER POLICY name ON qualified_name rowsecurityoptionaltorole rowsecurityoptionalexpr rowsecurityoptionalwithcheck + ; rowsecurityoptionalexpr - : USING OPEN_PAREN a_expr CLOSE_PAREN - | - ; + : USING OPEN_PAREN a_expr CLOSE_PAREN + | + ; rowsecurityoptionalwithcheck - : WITH CHECK OPEN_PAREN a_expr CLOSE_PAREN - | - ; + : WITH CHECK OPEN_PAREN a_expr CLOSE_PAREN + | + ; rowsecuritydefaulttorole - : TO role_list - | - ; + : TO role_list + | + ; rowsecurityoptionaltorole - : TO role_list - | - ; + : TO role_list + | + ; rowsecuritydefaultpermissive - : AS identifier - | - ; + : AS identifier + | + ; rowsecuritydefaultforcmd - : FOR row_security_cmd - | - ; + : FOR row_security_cmd + | + ; row_security_cmd - : ALL - | SELECT - | INSERT - | UPDATE - | DELETE_P - ; + : ALL + | SELECT + | INSERT + | UPDATE + | DELETE_P + ; createamstmt - : CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name - ; + : CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name + ; am_type - : INDEX - | TABLE - ; + : INDEX + | TABLE + ; createtrigstmt - : CREATE TRIGGER name triggeractiontime triggerevents ON qualified_name triggerreferencing triggerforspec triggerwhen EXECUTE function_or_procedure func_name OPEN_PAREN triggerfuncargs CLOSE_PAREN - | CREATE CONSTRAINT TRIGGER name AFTER triggerevents ON qualified_name optconstrfromtable constraintattributespec FOR EACH ROW triggerwhen EXECUTE function_or_procedure func_name OPEN_PAREN triggerfuncargs CLOSE_PAREN - ; + : CREATE TRIGGER name triggeractiontime triggerevents ON qualified_name triggerreferencing triggerforspec triggerwhen EXECUTE + function_or_procedure func_name OPEN_PAREN triggerfuncargs CLOSE_PAREN + | CREATE CONSTRAINT TRIGGER name AFTER triggerevents ON qualified_name optconstrfromtable constraintattributespec FOR EACH ROW triggerwhen EXECUTE + function_or_procedure func_name OPEN_PAREN triggerfuncargs CLOSE_PAREN + ; triggeractiontime - : BEFORE - | AFTER - | INSTEAD OF - ; + : BEFORE + | AFTER + | INSTEAD OF + ; triggerevents - : triggeroneevent (OR triggeroneevent)* - ; + : triggeroneevent (OR triggeroneevent)* + ; triggeroneevent - : INSERT - | DELETE_P - | UPDATE - | UPDATE OF columnlist - | TRUNCATE - ; + : INSERT + | DELETE_P + | UPDATE + | UPDATE OF columnlist + | TRUNCATE + ; triggerreferencing - : REFERENCING triggertransitions - | - ; + : REFERENCING triggertransitions + | + ; triggertransitions - : triggertransition+ - ; + : triggertransition+ + ; triggertransition - : transitionoldornew transitionrowortable opt_as transitionrelname - ; + : transitionoldornew transitionrowortable opt_as transitionrelname + ; transitionoldornew - : NEW - | OLD - ; + : NEW + | OLD + ; transitionrowortable - : TABLE - | ROW - ; + : TABLE + | ROW + ; transitionrelname - : colid - ; + : colid + ; triggerforspec - : FOR triggerforopteach triggerfortype - | - ; + : FOR triggerforopteach triggerfortype + | + ; triggerforopteach - : EACH - | - ; + : EACH + | + ; triggerfortype - : ROW - | STATEMENT - ; + : ROW + | STATEMENT + ; triggerwhen - : WHEN OPEN_PAREN a_expr CLOSE_PAREN - | - ; + : WHEN OPEN_PAREN a_expr CLOSE_PAREN + | + ; function_or_procedure - : FUNCTION - | PROCEDURE - ; + : FUNCTION + | PROCEDURE + ; triggerfuncargs - : (triggerfuncarg |) (COMMA triggerfuncarg)* - ; + : (triggerfuncarg |) (COMMA triggerfuncarg)* + ; triggerfuncarg - : iconst - | fconst - | sconst - | collabel - ; + : iconst + | fconst + | sconst + | collabel + ; optconstrfromtable - : FROM qualified_name - | - ; + : FROM qualified_name + | + ; constraintattributespec - : constraintattributeElem* - ; + : constraintattributeElem* + ; constraintattributeElem - : NOT DEFERRABLE - | DEFERRABLE - | INITIALLY IMMEDIATE - | INITIALLY DEFERRED - | NOT VALID - | NO INHERIT - ; + : NOT DEFERRABLE + | DEFERRABLE + | INITIALLY IMMEDIATE + | INITIALLY DEFERRED + | NOT VALID + | NO INHERIT + ; createeventtrigstmt - : CREATE EVENT TRIGGER name ON collabel EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN - | CREATE EVENT TRIGGER name ON collabel WHEN event_trigger_when_list EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN - ; + : CREATE EVENT TRIGGER name ON collabel EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN + | CREATE EVENT TRIGGER name ON collabel WHEN event_trigger_when_list EXECUTE function_or_procedure func_name OPEN_PAREN CLOSE_PAREN + ; event_trigger_when_list - : event_trigger_when_item (AND event_trigger_when_item)* - ; + : event_trigger_when_item (AND event_trigger_when_item)* + ; event_trigger_when_item - : colid IN_P OPEN_PAREN event_trigger_value_list CLOSE_PAREN - ; + : colid IN_P OPEN_PAREN event_trigger_value_list CLOSE_PAREN + ; event_trigger_value_list - : sconst (COMMA sconst)* - ; + : sconst (COMMA sconst)* + ; altereventtrigstmt - : ALTER EVENT TRIGGER name enable_trigger - ; + : ALTER EVENT TRIGGER name enable_trigger + ; enable_trigger - : ENABLE_P - | ENABLE_P REPLICA - | ENABLE_P ALWAYS - | DISABLE_P - ; + : ENABLE_P + | ENABLE_P REPLICA + | ENABLE_P ALWAYS + | DISABLE_P + ; createassertionstmt - : CREATE ASSERTION any_name CHECK OPEN_PAREN a_expr CLOSE_PAREN constraintattributespec - ; + : CREATE ASSERTION any_name CHECK OPEN_PAREN a_expr CLOSE_PAREN constraintattributespec + ; definestmt - : CREATE opt_or_replace AGGREGATE func_name aggr_args definition - | CREATE opt_or_replace AGGREGATE func_name old_aggr_definition - | CREATE OPERATOR any_operator definition - | CREATE TYPE_P any_name definition - | CREATE TYPE_P any_name - | CREATE TYPE_P any_name AS OPEN_PAREN opttablefuncelementlist CLOSE_PAREN - | CREATE TYPE_P any_name AS ENUM_P OPEN_PAREN opt_enum_val_list CLOSE_PAREN - | CREATE TYPE_P any_name AS RANGE definition - | CREATE TEXT_P SEARCH PARSER any_name definition - | CREATE TEXT_P SEARCH DICTIONARY any_name definition - | CREATE TEXT_P SEARCH TEMPLATE any_name definition - | CREATE TEXT_P SEARCH CONFIGURATION any_name definition - | CREATE COLLATION any_name definition - | CREATE COLLATION IF_P NOT EXISTS any_name definition - | CREATE COLLATION any_name FROM any_name - | CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name - ; + : CREATE opt_or_replace AGGREGATE func_name aggr_args definition + | CREATE opt_or_replace AGGREGATE func_name old_aggr_definition + | CREATE OPERATOR any_operator definition + | CREATE TYPE_P any_name definition + | CREATE TYPE_P any_name + | CREATE TYPE_P any_name AS OPEN_PAREN opttablefuncelementlist CLOSE_PAREN + | CREATE TYPE_P any_name AS ENUM_P OPEN_PAREN opt_enum_val_list CLOSE_PAREN + | CREATE TYPE_P any_name AS RANGE definition + | CREATE TEXT_P SEARCH PARSER any_name definition + | CREATE TEXT_P SEARCH DICTIONARY any_name definition + | CREATE TEXT_P SEARCH TEMPLATE any_name definition + | CREATE TEXT_P SEARCH CONFIGURATION any_name definition + | CREATE COLLATION any_name definition + | CREATE COLLATION IF_P NOT EXISTS any_name definition + | CREATE COLLATION any_name FROM any_name + | CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name + ; definition - : OPEN_PAREN def_list CLOSE_PAREN - ; + : OPEN_PAREN def_list CLOSE_PAREN + ; def_list - : def_elem (COMMA def_elem)* - ; + : def_elem (COMMA def_elem)* + ; def_elem - : collabel (EQUAL def_arg)? - ; + : collabel (EQUAL def_arg)? + ; def_arg - : func_type - | reserved_keyword - | qual_all_op - | numericonly - | sconst - | NONE - ; + : func_type + | reserved_keyword + | qual_all_op + | numericonly + | sconst + | NONE + ; old_aggr_definition - : OPEN_PAREN old_aggr_list CLOSE_PAREN - ; + : OPEN_PAREN old_aggr_list CLOSE_PAREN + ; old_aggr_list - : old_aggr_elem (COMMA old_aggr_elem)* - ; + : old_aggr_elem (COMMA old_aggr_elem)* + ; old_aggr_elem - : identifier EQUAL def_arg - ; + : identifier EQUAL def_arg + ; opt_enum_val_list - : enum_val_list - | - ; + : enum_val_list + | + ; enum_val_list - : sconst (COMMA sconst)* - ; + : sconst (COMMA sconst)* + ; alterenumstmt - : ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists sconst - | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists sconst BEFORE sconst - | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists sconst AFTER sconst - | ALTER TYPE_P any_name RENAME VALUE_P sconst TO sconst - ; + : ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists sconst + | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists sconst BEFORE sconst + | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists sconst AFTER sconst + | ALTER TYPE_P any_name RENAME VALUE_P sconst TO sconst + ; opt_if_not_exists - : IF_P NOT EXISTS - | - ; + : IF_P NOT EXISTS + | + ; createopclassstmt - : CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P typename USING name opt_opfamily AS opclass_item_list - ; + : CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P typename USING name opt_opfamily AS opclass_item_list + ; opclass_item_list - : opclass_item (COMMA opclass_item)* - ; + : opclass_item (COMMA opclass_item)* + ; opclass_item - : OPERATOR iconst any_operator opclass_purpose opt_recheck - | OPERATOR iconst operator_with_argtypes opclass_purpose opt_recheck - | FUNCTION iconst function_with_argtypes - | FUNCTION iconst OPEN_PAREN type_list CLOSE_PAREN function_with_argtypes - | STORAGE typename - ; + : OPERATOR iconst any_operator opclass_purpose opt_recheck + | OPERATOR iconst operator_with_argtypes opclass_purpose opt_recheck + | FUNCTION iconst function_with_argtypes + | FUNCTION iconst OPEN_PAREN type_list CLOSE_PAREN function_with_argtypes + | STORAGE typename + ; opt_default - : DEFAULT - | - ; + : DEFAULT + | + ; opt_opfamily - : FAMILY any_name - | - ; + : FAMILY any_name + | + ; opclass_purpose - : FOR SEARCH - | FOR ORDER BY any_name - | - ; + : FOR SEARCH + | FOR ORDER BY any_name + | + ; opt_recheck - : RECHECK - | - ; + : RECHECK + | + ; createopfamilystmt - : CREATE OPERATOR FAMILY any_name USING name - ; + : CREATE OPERATOR FAMILY any_name USING name + ; alteropfamilystmt - : ALTER OPERATOR FAMILY any_name USING name ADD_P opclass_item_list - | ALTER OPERATOR FAMILY any_name USING name DROP opclass_drop_list - ; + : ALTER OPERATOR FAMILY any_name USING name ADD_P opclass_item_list + | ALTER OPERATOR FAMILY any_name USING name DROP opclass_drop_list + ; opclass_drop_list - : opclass_drop (COMMA opclass_drop)* - ; + : opclass_drop (COMMA opclass_drop)* + ; opclass_drop - : OPERATOR iconst OPEN_PAREN type_list CLOSE_PAREN - | FUNCTION iconst OPEN_PAREN type_list CLOSE_PAREN - ; + : OPERATOR iconst OPEN_PAREN type_list CLOSE_PAREN + | FUNCTION iconst OPEN_PAREN type_list CLOSE_PAREN + ; dropopclassstmt - : DROP OPERATOR CLASS any_name USING name opt_drop_behavior - | DROP OPERATOR CLASS IF_P EXISTS any_name USING name opt_drop_behavior - ; + : DROP OPERATOR CLASS any_name USING name opt_drop_behavior + | DROP OPERATOR CLASS IF_P EXISTS any_name USING name opt_drop_behavior + ; dropopfamilystmt - : DROP OPERATOR FAMILY any_name USING name opt_drop_behavior - | DROP OPERATOR FAMILY IF_P EXISTS any_name USING name opt_drop_behavior - ; + : DROP OPERATOR FAMILY any_name USING name opt_drop_behavior + | DROP OPERATOR FAMILY IF_P EXISTS any_name USING name opt_drop_behavior + ; dropownedstmt - : DROP OWNED BY role_list opt_drop_behavior - ; + : DROP OWNED BY role_list opt_drop_behavior + ; reassignownedstmt - : REASSIGN OWNED BY role_list TO rolespec - ; + : REASSIGN OWNED BY role_list TO rolespec + ; dropstmt - : DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior - | DROP object_type_any_name any_name_list opt_drop_behavior - | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior - | DROP drop_type_name name_list opt_drop_behavior - | DROP object_type_name_on_any_name name ON any_name opt_drop_behavior - | DROP object_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior - | DROP TYPE_P type_name_list opt_drop_behavior - | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior - | DROP DOMAIN_P type_name_list opt_drop_behavior - | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior - | DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior - | DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior - ; + : DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior + | DROP object_type_any_name any_name_list opt_drop_behavior + | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior + | DROP drop_type_name name_list opt_drop_behavior + | DROP object_type_name_on_any_name name ON any_name opt_drop_behavior + | DROP object_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior + | DROP TYPE_P type_name_list opt_drop_behavior + | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior + | DROP DOMAIN_P type_name_list opt_drop_behavior + | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior + | DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior + | DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior + ; object_type_any_name - : TABLE - | SEQUENCE - | VIEW - | MATERIALIZED VIEW - | INDEX - | FOREIGN TABLE - | COLLATION - | CONVERSION_P - | STATISTICS - | TEXT_P SEARCH PARSER - | TEXT_P SEARCH DICTIONARY - | TEXT_P SEARCH TEMPLATE - | TEXT_P SEARCH CONFIGURATION - ; + : TABLE + | SEQUENCE + | VIEW + | MATERIALIZED VIEW + | INDEX + | FOREIGN TABLE + | COLLATION + | CONVERSION_P + | STATISTICS + | TEXT_P SEARCH PARSER + | TEXT_P SEARCH DICTIONARY + | TEXT_P SEARCH TEMPLATE + | TEXT_P SEARCH CONFIGURATION + ; object_type_name - : drop_type_name - | DATABASE - | ROLE - | SUBSCRIPTION - | TABLESPACE - ; + : drop_type_name + | DATABASE + | ROLE + | SUBSCRIPTION + | TABLESPACE + ; drop_type_name - : ACCESS METHOD - | EVENT TRIGGER - | EXTENSION - | FOREIGN DATA_P WRAPPER - | opt_procedural LANGUAGE - | PUBLICATION - | SCHEMA - | SERVER - ; + : ACCESS METHOD + | EVENT TRIGGER + | EXTENSION + | FOREIGN DATA_P WRAPPER + | opt_procedural LANGUAGE + | PUBLICATION + | SCHEMA + | SERVER + ; object_type_name_on_any_name - : POLICY - | RULE - | TRIGGER - ; + : POLICY + | RULE + | TRIGGER + ; any_name_list - : any_name (COMMA any_name)* - ; + : any_name (COMMA any_name)* + ; any_name - : colid attrs? - ; + : colid attrs? + ; attrs - :(DOT attr_name)+ - ; + : (DOT attr_name)+ + ; type_name_list - : typename (COMMA typename)* - ; + : typename (COMMA typename)* + ; truncatestmt - : TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior - ; + : TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior + ; opt_restart_seqs - : CONTINUE_P IDENTITY_P - | RESTART IDENTITY_P - | - ; + : CONTINUE_P IDENTITY_P + | RESTART IDENTITY_P + | + ; commentstmt - : COMMENT ON object_type_any_name any_name IS comment_text - | COMMENT ON COLUMN any_name IS comment_text - | COMMENT ON object_type_name name IS comment_text - | COMMENT ON TYPE_P typename IS comment_text - | COMMENT ON DOMAIN_P typename IS comment_text - | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text - | COMMENT ON FUNCTION function_with_argtypes IS comment_text - | COMMENT ON OPERATOR operator_with_argtypes IS comment_text - | COMMENT ON CONSTRAINT name ON any_name IS comment_text - | COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text - | COMMENT ON object_type_name_on_any_name name ON any_name IS comment_text - | COMMENT ON PROCEDURE function_with_argtypes IS comment_text - | COMMENT ON ROUTINE function_with_argtypes IS comment_text - | COMMENT ON TRANSFORM FOR typename LANGUAGE name IS comment_text - | COMMENT ON OPERATOR CLASS any_name USING name IS comment_text - | COMMENT ON OPERATOR FAMILY any_name USING name IS comment_text - | COMMENT ON LARGE_P OBJECT_P numericonly IS comment_text - | COMMENT ON CAST OPEN_PAREN typename AS typename CLOSE_PAREN IS comment_text - ; + : COMMENT ON object_type_any_name any_name IS comment_text + | COMMENT ON COLUMN any_name IS comment_text + | COMMENT ON object_type_name name IS comment_text + | COMMENT ON TYPE_P typename IS comment_text + | COMMENT ON DOMAIN_P typename IS comment_text + | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text + | COMMENT ON FUNCTION function_with_argtypes IS comment_text + | COMMENT ON OPERATOR operator_with_argtypes IS comment_text + | COMMENT ON CONSTRAINT name ON any_name IS comment_text + | COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text + | COMMENT ON object_type_name_on_any_name name ON any_name IS comment_text + | COMMENT ON PROCEDURE function_with_argtypes IS comment_text + | COMMENT ON ROUTINE function_with_argtypes IS comment_text + | COMMENT ON TRANSFORM FOR typename LANGUAGE name IS comment_text + | COMMENT ON OPERATOR CLASS any_name USING name IS comment_text + | COMMENT ON OPERATOR FAMILY any_name USING name IS comment_text + | COMMENT ON LARGE_P OBJECT_P numericonly IS comment_text + | COMMENT ON CAST OPEN_PAREN typename AS typename CLOSE_PAREN IS comment_text + ; comment_text - : sconst - | NULL_P - ; + : sconst + | NULL_P + ; seclabelstmt - : SECURITY LABEL opt_provider ON object_type_any_name any_name IS security_label - | SECURITY LABEL opt_provider ON COLUMN any_name IS security_label - | SECURITY LABEL opt_provider ON object_type_name name IS security_label - | SECURITY LABEL opt_provider ON TYPE_P typename IS security_label - | SECURITY LABEL opt_provider ON DOMAIN_P typename IS security_label - | SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes IS security_label - | SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes IS security_label - | SECURITY LABEL opt_provider ON LARGE_P OBJECT_P numericonly IS security_label - | SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes IS security_label - | SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes IS security_label - ; + : SECURITY LABEL opt_provider ON object_type_any_name any_name IS security_label + | SECURITY LABEL opt_provider ON COLUMN any_name IS security_label + | SECURITY LABEL opt_provider ON object_type_name name IS security_label + | SECURITY LABEL opt_provider ON TYPE_P typename IS security_label + | SECURITY LABEL opt_provider ON DOMAIN_P typename IS security_label + | SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes IS security_label + | SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes IS security_label + | SECURITY LABEL opt_provider ON LARGE_P OBJECT_P numericonly IS security_label + | SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes IS security_label + | SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes IS security_label + ; opt_provider - : FOR nonreservedword_or_sconst - | - ; + : FOR nonreservedword_or_sconst + | + ; security_label - : sconst - | NULL_P - ; + : sconst + | NULL_P + ; fetchstmt - : FETCH fetch_args - | MOVE fetch_args - ; + : FETCH fetch_args + | MOVE fetch_args + ; fetch_args - : cursor_name - | from_in cursor_name - | NEXT opt_from_in cursor_name - | PRIOR opt_from_in cursor_name - | FIRST_P opt_from_in cursor_name - | LAST_P opt_from_in cursor_name - | ABSOLUTE_P signediconst opt_from_in cursor_name - | RELATIVE_P signediconst opt_from_in cursor_name - | signediconst opt_from_in cursor_name - | ALL opt_from_in cursor_name - | FORWARD opt_from_in cursor_name - | FORWARD signediconst opt_from_in cursor_name - | FORWARD ALL opt_from_in cursor_name - | BACKWARD opt_from_in cursor_name - | BACKWARD signediconst opt_from_in cursor_name - | BACKWARD ALL opt_from_in cursor_name - ; + : cursor_name + | from_in cursor_name + | NEXT opt_from_in cursor_name + | PRIOR opt_from_in cursor_name + | FIRST_P opt_from_in cursor_name + | LAST_P opt_from_in cursor_name + | ABSOLUTE_P signediconst opt_from_in cursor_name + | RELATIVE_P signediconst opt_from_in cursor_name + | signediconst opt_from_in cursor_name + | ALL opt_from_in cursor_name + | FORWARD opt_from_in cursor_name + | FORWARD signediconst opt_from_in cursor_name + | FORWARD ALL opt_from_in cursor_name + | BACKWARD opt_from_in cursor_name + | BACKWARD signediconst opt_from_in cursor_name + | BACKWARD ALL opt_from_in cursor_name + ; from_in - : FROM - | IN_P - ; + : FROM + | IN_P + ; opt_from_in - : from_in - | - ; + : from_in + | + ; grantstmt - : GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option - ; + : GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option + ; revokestmt - : REVOKE privileges ON privilege_target FROM grantee_list opt_drop_behavior - | REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_drop_behavior - ; + : REVOKE privileges ON privilege_target FROM grantee_list opt_drop_behavior + | REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_drop_behavior + ; privileges - : privilege_list - | ALL - | ALL PRIVILEGES - | ALL OPEN_PAREN columnlist CLOSE_PAREN - | ALL PRIVILEGES OPEN_PAREN columnlist CLOSE_PAREN - ; + : privilege_list + | ALL + | ALL PRIVILEGES + | ALL OPEN_PAREN columnlist CLOSE_PAREN + | ALL PRIVILEGES OPEN_PAREN columnlist CLOSE_PAREN + ; privilege_list - : privilege (COMMA privilege)* - ; + : privilege (COMMA privilege)* + ; privilege - : SELECT opt_column_list - | REFERENCES opt_column_list - | CREATE opt_column_list - | colid opt_column_list - ; + : SELECT opt_column_list + | REFERENCES opt_column_list + | CREATE opt_column_list + | colid opt_column_list + ; privilege_target - : qualified_name_list - | TABLE qualified_name_list - | SEQUENCE qualified_name_list - | FOREIGN DATA_P WRAPPER name_list - | FOREIGN SERVER name_list - | FUNCTION function_with_argtypes_list - | PROCEDURE function_with_argtypes_list - | ROUTINE function_with_argtypes_list - | DATABASE name_list - | DOMAIN_P any_name_list - | LANGUAGE name_list - | LARGE_P OBJECT_P numericonly_list - | SCHEMA name_list - | TABLESPACE name_list - | TYPE_P any_name_list - | ALL TABLES IN_P SCHEMA name_list - | ALL SEQUENCES IN_P SCHEMA name_list - | ALL FUNCTIONS IN_P SCHEMA name_list - | ALL PROCEDURES IN_P SCHEMA name_list - | ALL ROUTINES IN_P SCHEMA name_list - ; + : qualified_name_list + | TABLE qualified_name_list + | SEQUENCE qualified_name_list + | FOREIGN DATA_P WRAPPER name_list + | FOREIGN SERVER name_list + | FUNCTION function_with_argtypes_list + | PROCEDURE function_with_argtypes_list + | ROUTINE function_with_argtypes_list + | DATABASE name_list + | DOMAIN_P any_name_list + | LANGUAGE name_list + | LARGE_P OBJECT_P numericonly_list + | SCHEMA name_list + | TABLESPACE name_list + | TYPE_P any_name_list + | ALL TABLES IN_P SCHEMA name_list + | ALL SEQUENCES IN_P SCHEMA name_list + | ALL FUNCTIONS IN_P SCHEMA name_list + | ALL PROCEDURES IN_P SCHEMA name_list + | ALL ROUTINES IN_P SCHEMA name_list + ; grantee_list - : grantee (COMMA grantee)* - ; + : grantee (COMMA grantee)* + ; grantee - : rolespec - | GROUP_P rolespec - ; + : rolespec + | GROUP_P rolespec + ; opt_grant_grant_option - : WITH GRANT OPTION - | - ; + : WITH GRANT OPTION + | + ; grantrolestmt - : GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by - ; + : GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by + ; revokerolestmt - : REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior - | REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior - ; + : REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior + | REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior + ; opt_grant_admin_option - : WITH ADMIN OPTION - | - ; + : WITH ADMIN OPTION + | + ; opt_granted_by - : GRANTED BY rolespec - | - ; + : GRANTED BY rolespec + | + ; alterdefaultprivilegesstmt - : ALTER DEFAULT PRIVILEGES defacloptionlist defaclaction - ; + : ALTER DEFAULT PRIVILEGES defacloptionlist defaclaction + ; defacloptionlist - : defacloption* - ; + : defacloption* + ; defacloption - : IN_P SCHEMA name_list - | FOR ROLE role_list - | FOR USER role_list - ; + : IN_P SCHEMA name_list + | FOR ROLE role_list + | FOR USER role_list + ; defaclaction - : GRANT privileges ON defacl_privilege_target TO grantee_list opt_grant_grant_option - | REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior - | REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior - ; + : GRANT privileges ON defacl_privilege_target TO grantee_list opt_grant_grant_option + | REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior + | REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior + ; defacl_privilege_target - : TABLES - | FUNCTIONS - | ROUTINES - | SEQUENCES - | TYPES_P - | SCHEMAS - ; - //create index + : TABLES + | FUNCTIONS + | ROUTINES + | SEQUENCES + | TYPES_P + | SCHEMAS + ; + +//create index indexstmt - : CREATE opt_unique INDEX opt_concurrently opt_index_name ON relation_expr access_method_clause OPEN_PAREN index_params CLOSE_PAREN opt_include opt_reloptions opttablespace where_clause - | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS name ON relation_expr access_method_clause OPEN_PAREN index_params CLOSE_PAREN opt_include opt_reloptions opttablespace where_clause - ; + : CREATE opt_unique INDEX opt_concurrently opt_index_name ON relation_expr access_method_clause OPEN_PAREN index_params CLOSE_PAREN opt_include + opt_reloptions opttablespace where_clause + | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS name ON relation_expr access_method_clause OPEN_PAREN index_params CLOSE_PAREN + opt_include opt_reloptions opttablespace where_clause + ; opt_unique - : UNIQUE - | - ; + : UNIQUE + | + ; opt_concurrently - : CONCURRENTLY - | - ; + : CONCURRENTLY + | + ; opt_index_name - : name - | - ; + : name + | + ; access_method_clause - : USING name - | - ; + : USING name + | + ; index_params - : index_elem (COMMA index_elem)* - ; + : index_elem (COMMA index_elem)* + ; index_elem_options - : opt_collate opt_class opt_asc_desc opt_nulls_order - | opt_collate any_name reloptions opt_asc_desc opt_nulls_order - ; + : opt_collate opt_class opt_asc_desc opt_nulls_order + | opt_collate any_name reloptions opt_asc_desc opt_nulls_order + ; index_elem - : colid index_elem_options - | func_expr_windowless index_elem_options - | OPEN_PAREN a_expr CLOSE_PAREN index_elem_options - ; + : colid index_elem_options + | func_expr_windowless index_elem_options + | OPEN_PAREN a_expr CLOSE_PAREN index_elem_options + ; opt_include - : INCLUDE OPEN_PAREN index_including_params CLOSE_PAREN - | - ; + : INCLUDE OPEN_PAREN index_including_params CLOSE_PAREN + | + ; index_including_params - : index_elem (COMMA index_elem)* - ; + : index_elem (COMMA index_elem)* + ; opt_collate - : COLLATE any_name - | - ; + : COLLATE any_name + | + ; opt_class - : any_name - | - ; + : any_name + | + ; opt_asc_desc - : ASC - | DESC - | - ; - //TOD NULLS_LA was used + : ASC + | DESC + | + ; + +//TOD NULLS_LA was used opt_nulls_order - : NULLS_P FIRST_P - | NULLS_P LAST_P - | - ; + : NULLS_P FIRST_P + | NULLS_P LAST_P + | + ; createfunctionstmt - : CREATE opt_or_replace (FUNCTION | PROCEDURE) func_name func_args_with_defaults - ( + : CREATE opt_or_replace (FUNCTION | PROCEDURE) func_name func_args_with_defaults ( RETURNS (func_return | TABLE OPEN_PAREN table_func_column_list CLOSE_PAREN) - )? - createfunc_opt_list - ; + )? createfunc_opt_list + ; opt_or_replace - : OR REPLACE - | - ; + : OR REPLACE + | + ; func_args - : OPEN_PAREN func_args_list? CLOSE_PAREN - ; + : OPEN_PAREN func_args_list? CLOSE_PAREN + ; func_args_list - : func_arg (COMMA func_arg)* - ; + : func_arg (COMMA func_arg)* + ; function_with_argtypes_list - : function_with_argtypes (COMMA function_with_argtypes)* - ; + : function_with_argtypes (COMMA function_with_argtypes)* + ; function_with_argtypes - : func_name func_args - | type_func_name_keyword - | colid indirection? - ; + : func_name func_args + | type_func_name_keyword + | colid indirection? + ; func_args_with_defaults - : OPEN_PAREN func_args_with_defaults_list? CLOSE_PAREN - ; + : OPEN_PAREN func_args_with_defaults_list? CLOSE_PAREN + ; func_args_with_defaults_list - : func_arg_with_default (COMMA func_arg_with_default)* - ; + : func_arg_with_default (COMMA func_arg_with_default)* + ; func_arg - : arg_class param_name? func_type - | param_name arg_class? func_type - | func_type - ; + : arg_class param_name? func_type + | param_name arg_class? func_type + | func_type + ; arg_class - : IN_P OUT_P? - | OUT_P - | INOUT - | VARIADIC - ; + : IN_P OUT_P? + | OUT_P + | INOUT + | VARIADIC + ; param_name - : type_function_name - | builtin_function_name - | LEFT - | RIGHT - ; + : type_function_name + | builtin_function_name + | LEFT + | RIGHT + ; func_return - : func_type - ; + : func_type + ; func_type - : typename - | SETOF? (builtin_function_name | type_function_name | LEFT | RIGHT) attrs PERCENT TYPE_P - ; + : typename + | SETOF? (builtin_function_name | type_function_name | LEFT | RIGHT) attrs PERCENT TYPE_P + ; func_arg_with_default - : func_arg ((DEFAULT | EQUAL) a_expr)? - ; + : func_arg ((DEFAULT | EQUAL) a_expr)? + ; aggr_arg - : func_arg - ; + : func_arg + ; aggr_args - : OPEN_PAREN (STAR | aggr_args_list | ORDER BY aggr_args_list | aggr_args_list ORDER BY aggr_args_list) CLOSE_PAREN - ; + : OPEN_PAREN ( + STAR + | aggr_args_list + | ORDER BY aggr_args_list + | aggr_args_list ORDER BY aggr_args_list + ) CLOSE_PAREN + ; aggr_args_list - : aggr_arg (COMMA aggr_arg)* - ; + : aggr_arg (COMMA aggr_arg)* + ; aggregate_with_argtypes - : func_name aggr_args - ; + : func_name aggr_args + ; aggregate_with_argtypes_list - : aggregate_with_argtypes (COMMA aggregate_with_argtypes)* - ; + : aggregate_with_argtypes (COMMA aggregate_with_argtypes)* + ; createfunc_opt_list - : createfunc_opt_item+ - { + : createfunc_opt_item+ { ParseRoutineBody(_localctx); } - // | createfunc_opt_list createfunc_opt_item - - ; + // | createfunc_opt_list createfunc_opt_item + ; common_func_opt_item - : CALLED ON NULL_P INPUT_P - | RETURNS NULL_P ON NULL_P INPUT_P - | STRICT_P - | IMMUTABLE - | STABLE - | VOLATILE - | EXTERNAL SECURITY DEFINER - | EXTERNAL SECURITY INVOKER - | SECURITY DEFINER - | SECURITY INVOKER - | LEAKPROOF - | NOT LEAKPROOF - | COST numericonly - | ROWS numericonly - | SUPPORT any_name - | functionsetresetclause - | PARALLEL colid - ; + : CALLED ON NULL_P INPUT_P + | RETURNS NULL_P ON NULL_P INPUT_P + | STRICT_P + | IMMUTABLE + | STABLE + | VOLATILE + | EXTERNAL SECURITY DEFINER + | EXTERNAL SECURITY INVOKER + | SECURITY DEFINER + | SECURITY INVOKER + | LEAKPROOF + | NOT LEAKPROOF + | COST numericonly + | ROWS numericonly + | SUPPORT any_name + | functionsetresetclause + | PARALLEL colid + ; createfunc_opt_item - : AS func_as - | LANGUAGE nonreservedword_or_sconst - | TRANSFORM transform_type_list - | WINDOW - | common_func_opt_item - ; - //https://www.postgresql.org/docs/9.1/sql-createfunction.html - - // | AS 'definition' - - // | AS 'obj_file', 'link_symbol' - -func_as locals[ParserRuleContext Definition] - : - /* |AS 'definition'*/ - def = sconst - /*| AS 'obj_file', 'link_symbol'*/ - | sconst COMMA sconst - ; + : AS func_as + | LANGUAGE nonreservedword_or_sconst + | TRANSFORM transform_type_list + | WINDOW + | common_func_opt_item + ; + +//https://www.postgresql.org/docs/9.1/sql-createfunction.html + +// | AS 'definition' + +// | AS 'obj_file', 'link_symbol' + +func_as + locals[ParserRuleContext Definition] + : + /* |AS 'definition'*/ def = sconst + /*| AS 'obj_file', 'link_symbol'*/ + | sconst COMMA sconst + ; transform_type_list - :FOR TYPE_P typename (COMMA FOR TYPE_P typename)* - ; + : FOR TYPE_P typename (COMMA FOR TYPE_P typename)* + ; opt_definition - : WITH definition - | - ; + : WITH definition + | + ; table_func_column - : param_name func_type - ; + : param_name func_type + ; table_func_column_list - : table_func_column (COMMA table_func_column)* - ; + : table_func_column (COMMA table_func_column)* + ; alterfunctionstmt - : ALTER (FUNCTION | PROCEDURE | ROUTINE) function_with_argtypes alterfunc_opt_list opt_restrict - ; + : ALTER (FUNCTION | PROCEDURE | ROUTINE) function_with_argtypes alterfunc_opt_list opt_restrict + ; alterfunc_opt_list - : common_func_opt_item+ - ; + : common_func_opt_item+ + ; opt_restrict - : RESTRICT - | - ; + : RESTRICT + | + ; removefuncstmt - : DROP FUNCTION function_with_argtypes_list opt_drop_behavior - | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior - | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior - | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior - | DROP ROUTINE function_with_argtypes_list opt_drop_behavior - | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior - ; + : DROP FUNCTION function_with_argtypes_list opt_drop_behavior + | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior + | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior + | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior + | DROP ROUTINE function_with_argtypes_list opt_drop_behavior + | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior + ; removeaggrstmt - : DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior - | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior - ; + : DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior + | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior + ; removeoperstmt - : DROP OPERATOR operator_with_argtypes_list opt_drop_behavior - | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior - ; + : DROP OPERATOR operator_with_argtypes_list opt_drop_behavior + | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior + ; oper_argtypes - : OPEN_PAREN typename CLOSE_PAREN - | OPEN_PAREN typename COMMA typename CLOSE_PAREN - | OPEN_PAREN NONE COMMA typename CLOSE_PAREN - | OPEN_PAREN typename COMMA NONE CLOSE_PAREN - ; + : OPEN_PAREN typename CLOSE_PAREN + | OPEN_PAREN typename COMMA typename CLOSE_PAREN + | OPEN_PAREN NONE COMMA typename CLOSE_PAREN + | OPEN_PAREN typename COMMA NONE CLOSE_PAREN + ; any_operator - : (colid DOT)* all_op - ; + : (colid DOT)* all_op + ; operator_with_argtypes_list - : operator_with_argtypes (COMMA operator_with_argtypes)* - ; + : operator_with_argtypes (COMMA operator_with_argtypes)* + ; operator_with_argtypes - : any_operator oper_argtypes - ; + : any_operator oper_argtypes + ; dostmt - : DO dostmt_opt_list - ; + : DO dostmt_opt_list + ; dostmt_opt_list - : dostmt_opt_item+ - ; + : dostmt_opt_item+ + ; dostmt_opt_item - : sconst - | LANGUAGE nonreservedword_or_sconst - ; + : sconst + | LANGUAGE nonreservedword_or_sconst + ; createcaststmt - : CREATE CAST OPEN_PAREN typename AS typename CLOSE_PAREN WITH FUNCTION function_with_argtypes cast_context - | CREATE CAST OPEN_PAREN typename AS typename CLOSE_PAREN WITHOUT FUNCTION cast_context - | CREATE CAST OPEN_PAREN typename AS typename CLOSE_PAREN WITH INOUT cast_context - ; + : CREATE CAST OPEN_PAREN typename AS typename CLOSE_PAREN WITH FUNCTION function_with_argtypes cast_context + | CREATE CAST OPEN_PAREN typename AS typename CLOSE_PAREN WITHOUT FUNCTION cast_context + | CREATE CAST OPEN_PAREN typename AS typename CLOSE_PAREN WITH INOUT cast_context + ; cast_context - : AS IMPLICIT_P - | AS ASSIGNMENT - | - ; + : AS IMPLICIT_P + | AS ASSIGNMENT + | + ; dropcaststmt - : DROP CAST opt_if_exists OPEN_PAREN typename AS typename CLOSE_PAREN opt_drop_behavior - ; + : DROP CAST opt_if_exists OPEN_PAREN typename AS typename CLOSE_PAREN opt_drop_behavior + ; opt_if_exists - : IF_P EXISTS - | - ; + : IF_P EXISTS + | + ; createtransformstmt - : CREATE opt_or_replace TRANSFORM FOR typename LANGUAGE name OPEN_PAREN transform_element_list CLOSE_PAREN - ; + : CREATE opt_or_replace TRANSFORM FOR typename LANGUAGE name OPEN_PAREN transform_element_list CLOSE_PAREN + ; transform_element_list - : FROM SQL_P WITH FUNCTION function_with_argtypes COMMA TO SQL_P WITH FUNCTION function_with_argtypes - | TO SQL_P WITH FUNCTION function_with_argtypes COMMA FROM SQL_P WITH FUNCTION function_with_argtypes - | FROM SQL_P WITH FUNCTION function_with_argtypes - | TO SQL_P WITH FUNCTION function_with_argtypes - ; + : FROM SQL_P WITH FUNCTION function_with_argtypes COMMA TO SQL_P WITH FUNCTION function_with_argtypes + | TO SQL_P WITH FUNCTION function_with_argtypes COMMA FROM SQL_P WITH FUNCTION function_with_argtypes + | FROM SQL_P WITH FUNCTION function_with_argtypes + | TO SQL_P WITH FUNCTION function_with_argtypes + ; droptransformstmt - : DROP TRANSFORM opt_if_exists FOR typename LANGUAGE name opt_drop_behavior - ; + : DROP TRANSFORM opt_if_exists FOR typename LANGUAGE name opt_drop_behavior + ; reindexstmt - : REINDEX reindex_target_type opt_concurrently qualified_name - | REINDEX reindex_target_multitable opt_concurrently name - | REINDEX OPEN_PAREN reindex_option_list CLOSE_PAREN reindex_target_type opt_concurrently qualified_name - | REINDEX OPEN_PAREN reindex_option_list CLOSE_PAREN reindex_target_multitable opt_concurrently name - ; + : REINDEX reindex_target_type opt_concurrently qualified_name + | REINDEX reindex_target_multitable opt_concurrently name + | REINDEX OPEN_PAREN reindex_option_list CLOSE_PAREN reindex_target_type opt_concurrently qualified_name + | REINDEX OPEN_PAREN reindex_option_list CLOSE_PAREN reindex_target_multitable opt_concurrently name + ; reindex_target_type - : INDEX - | TABLE - | SCHEMA - | DATABASE - | SYSTEM_P - ; + : INDEX + | TABLE + | SCHEMA + | DATABASE + | SYSTEM_P + ; reindex_target_multitable - : SCHEMA - | SYSTEM_P - | DATABASE - ; + : SCHEMA + | SYSTEM_P + | DATABASE + ; reindex_option_list - : reindex_option_elem (COMMA reindex_option_elem)* - ; + : reindex_option_elem (COMMA reindex_option_elem)* + ; reindex_option_elem - : VERBOSE - | TABLESPACE - | CONCURRENTLY - ; + : VERBOSE + | TABLESPACE + | CONCURRENTLY + ; altertblspcstmt - : ALTER TABLESPACE name SET reloptions - | ALTER TABLESPACE name RESET reloptions - ; + : ALTER TABLESPACE name SET reloptions + | ALTER TABLESPACE name RESET reloptions + ; renamestmt - : ALTER AGGREGATE aggregate_with_argtypes RENAME TO name - | ALTER COLLATION any_name RENAME TO name - | ALTER CONVERSION_P any_name RENAME TO name - | ALTER DATABASE name RENAME TO name - | ALTER DOMAIN_P any_name RENAME TO name - | ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name - | ALTER FOREIGN DATA_P WRAPPER name RENAME TO name - | ALTER FUNCTION function_with_argtypes RENAME TO name - | ALTER GROUP_P roleid RENAME TO roleid - | ALTER opt_procedural LANGUAGE name RENAME TO name - | ALTER OPERATOR CLASS any_name USING name RENAME TO name - | ALTER OPERATOR FAMILY any_name USING name RENAME TO name - | ALTER POLICY name ON qualified_name RENAME TO name - | ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name - | ALTER PROCEDURE function_with_argtypes RENAME TO name - | ALTER PUBLICATION name RENAME TO name - | ALTER ROUTINE function_with_argtypes RENAME TO name - | ALTER SCHEMA name RENAME TO name - | ALTER SERVER name RENAME TO name - | ALTER SUBSCRIPTION name RENAME TO name - | ALTER TABLE relation_expr RENAME TO name - | ALTER TABLE IF_P EXISTS relation_expr RENAME TO name - | ALTER SEQUENCE qualified_name RENAME TO name - | ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name - | ALTER VIEW qualified_name RENAME TO name - | ALTER VIEW IF_P EXISTS qualified_name RENAME TO name - | ALTER MATERIALIZED VIEW qualified_name RENAME TO name - | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name - | ALTER INDEX qualified_name RENAME TO name - | ALTER INDEX IF_P EXISTS qualified_name RENAME TO name - | ALTER FOREIGN TABLE relation_expr RENAME TO name - | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name - | ALTER TABLE relation_expr RENAME opt_column name TO name - | ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name - | ALTER VIEW qualified_name RENAME opt_column name TO name - | ALTER VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name - | ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name - | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name - | ALTER TABLE relation_expr RENAME CONSTRAINT name TO name - | ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name - | ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name - | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name - | ALTER RULE name ON qualified_name RENAME TO name - | ALTER TRIGGER name ON qualified_name RENAME TO name - | ALTER EVENT TRIGGER name RENAME TO name - | ALTER ROLE roleid RENAME TO roleid - | ALTER USER roleid RENAME TO roleid - | ALTER TABLESPACE name RENAME TO name - | ALTER STATISTICS any_name RENAME TO name - | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name - | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name - | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name - | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name - | ALTER TYPE_P any_name RENAME TO name - | ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior - ; + : ALTER AGGREGATE aggregate_with_argtypes RENAME TO name + | ALTER COLLATION any_name RENAME TO name + | ALTER CONVERSION_P any_name RENAME TO name + | ALTER DATABASE name RENAME TO name + | ALTER DOMAIN_P any_name RENAME TO name + | ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name + | ALTER FOREIGN DATA_P WRAPPER name RENAME TO name + | ALTER FUNCTION function_with_argtypes RENAME TO name + | ALTER GROUP_P roleid RENAME TO roleid + | ALTER opt_procedural LANGUAGE name RENAME TO name + | ALTER OPERATOR CLASS any_name USING name RENAME TO name + | ALTER OPERATOR FAMILY any_name USING name RENAME TO name + | ALTER POLICY name ON qualified_name RENAME TO name + | ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name + | ALTER PROCEDURE function_with_argtypes RENAME TO name + | ALTER PUBLICATION name RENAME TO name + | ALTER ROUTINE function_with_argtypes RENAME TO name + | ALTER SCHEMA name RENAME TO name + | ALTER SERVER name RENAME TO name + | ALTER SUBSCRIPTION name RENAME TO name + | ALTER TABLE relation_expr RENAME TO name + | ALTER TABLE IF_P EXISTS relation_expr RENAME TO name + | ALTER SEQUENCE qualified_name RENAME TO name + | ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name + | ALTER VIEW qualified_name RENAME TO name + | ALTER VIEW IF_P EXISTS qualified_name RENAME TO name + | ALTER MATERIALIZED VIEW qualified_name RENAME TO name + | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name + | ALTER INDEX qualified_name RENAME TO name + | ALTER INDEX IF_P EXISTS qualified_name RENAME TO name + | ALTER FOREIGN TABLE relation_expr RENAME TO name + | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name + | ALTER TABLE relation_expr RENAME opt_column name TO name + | ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name + | ALTER VIEW qualified_name RENAME opt_column name TO name + | ALTER VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name + | ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name + | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name + | ALTER TABLE relation_expr RENAME CONSTRAINT name TO name + | ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name + | ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name + | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name + | ALTER RULE name ON qualified_name RENAME TO name + | ALTER TRIGGER name ON qualified_name RENAME TO name + | ALTER EVENT TRIGGER name RENAME TO name + | ALTER ROLE roleid RENAME TO roleid + | ALTER USER roleid RENAME TO roleid + | ALTER TABLESPACE name RENAME TO name + | ALTER STATISTICS any_name RENAME TO name + | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name + | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name + | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name + | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name + | ALTER TYPE_P any_name RENAME TO name + | ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior + ; opt_column - : COLUMN - | - ; + : COLUMN + | + ; opt_set_data - : SET DATA_P - | - ; + : SET DATA_P + | + ; alterobjectdependsstmt - : ALTER FUNCTION function_with_argtypes opt_no DEPENDS ON EXTENSION name - | ALTER PROCEDURE function_with_argtypes opt_no DEPENDS ON EXTENSION name - | ALTER ROUTINE function_with_argtypes opt_no DEPENDS ON EXTENSION name - | ALTER TRIGGER name ON qualified_name opt_no DEPENDS ON EXTENSION name - | ALTER MATERIALIZED VIEW qualified_name opt_no DEPENDS ON EXTENSION name - | ALTER INDEX qualified_name opt_no DEPENDS ON EXTENSION name - ; + : ALTER FUNCTION function_with_argtypes opt_no DEPENDS ON EXTENSION name + | ALTER PROCEDURE function_with_argtypes opt_no DEPENDS ON EXTENSION name + | ALTER ROUTINE function_with_argtypes opt_no DEPENDS ON EXTENSION name + | ALTER TRIGGER name ON qualified_name opt_no DEPENDS ON EXTENSION name + | ALTER MATERIALIZED VIEW qualified_name opt_no DEPENDS ON EXTENSION name + | ALTER INDEX qualified_name opt_no DEPENDS ON EXTENSION name + ; opt_no - : NO - | - ; + : NO + | + ; alterobjectschemastmt - : ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name - | ALTER COLLATION any_name SET SCHEMA name - | ALTER CONVERSION_P any_name SET SCHEMA name - | ALTER DOMAIN_P any_name SET SCHEMA name - | ALTER EXTENSION name SET SCHEMA name - | ALTER FUNCTION function_with_argtypes SET SCHEMA name - | ALTER OPERATOR operator_with_argtypes SET SCHEMA name - | ALTER OPERATOR CLASS any_name USING name SET SCHEMA name - | ALTER OPERATOR FAMILY any_name USING name SET SCHEMA name - | ALTER PROCEDURE function_with_argtypes SET SCHEMA name - | ALTER ROUTINE function_with_argtypes SET SCHEMA name - | ALTER TABLE relation_expr SET SCHEMA name - | ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name - | ALTER STATISTICS any_name SET SCHEMA name - | ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name - | ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name - | ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name - | ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name - | ALTER SEQUENCE qualified_name SET SCHEMA name - | ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name - | ALTER VIEW qualified_name SET SCHEMA name - | ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name - | ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name - | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name - | ALTER FOREIGN TABLE relation_expr SET SCHEMA name - | ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name - | ALTER TYPE_P any_name SET SCHEMA name - ; + : ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name + | ALTER COLLATION any_name SET SCHEMA name + | ALTER CONVERSION_P any_name SET SCHEMA name + | ALTER DOMAIN_P any_name SET SCHEMA name + | ALTER EXTENSION name SET SCHEMA name + | ALTER FUNCTION function_with_argtypes SET SCHEMA name + | ALTER OPERATOR operator_with_argtypes SET SCHEMA name + | ALTER OPERATOR CLASS any_name USING name SET SCHEMA name + | ALTER OPERATOR FAMILY any_name USING name SET SCHEMA name + | ALTER PROCEDURE function_with_argtypes SET SCHEMA name + | ALTER ROUTINE function_with_argtypes SET SCHEMA name + | ALTER TABLE relation_expr SET SCHEMA name + | ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name + | ALTER STATISTICS any_name SET SCHEMA name + | ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name + | ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name + | ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name + | ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name + | ALTER SEQUENCE qualified_name SET SCHEMA name + | ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name + | ALTER VIEW qualified_name SET SCHEMA name + | ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name + | ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name + | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name + | ALTER FOREIGN TABLE relation_expr SET SCHEMA name + | ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name + | ALTER TYPE_P any_name SET SCHEMA name + ; alteroperatorstmt - : ALTER OPERATOR operator_with_argtypes SET OPEN_PAREN operator_def_list CLOSE_PAREN - ; + : ALTER OPERATOR operator_with_argtypes SET OPEN_PAREN operator_def_list CLOSE_PAREN + ; operator_def_list - : operator_def_elem (COMMA operator_def_elem)* - ; + : operator_def_elem (COMMA operator_def_elem)* + ; operator_def_elem - : collabel EQUAL NONE - | collabel EQUAL operator_def_arg - ; + : collabel EQUAL NONE + | collabel EQUAL operator_def_arg + ; operator_def_arg - : func_type - | reserved_keyword - | qual_all_op - | numericonly - | sconst - ; + : func_type + | reserved_keyword + | qual_all_op + | numericonly + | sconst + ; altertypestmt - : ALTER TYPE_P any_name SET OPEN_PAREN operator_def_list CLOSE_PAREN - ; + : ALTER TYPE_P any_name SET OPEN_PAREN operator_def_list CLOSE_PAREN + ; alterownerstmt - : ALTER AGGREGATE aggregate_with_argtypes OWNER TO rolespec - | ALTER COLLATION any_name OWNER TO rolespec - | ALTER CONVERSION_P any_name OWNER TO rolespec - | ALTER DATABASE name OWNER TO rolespec - | ALTER DOMAIN_P any_name OWNER TO rolespec - | ALTER FUNCTION function_with_argtypes OWNER TO rolespec - | ALTER opt_procedural LANGUAGE name OWNER TO rolespec - | ALTER LARGE_P OBJECT_P numericonly OWNER TO rolespec - | ALTER OPERATOR operator_with_argtypes OWNER TO rolespec - | ALTER OPERATOR CLASS any_name USING name OWNER TO rolespec - | ALTER OPERATOR FAMILY any_name USING name OWNER TO rolespec - | ALTER PROCEDURE function_with_argtypes OWNER TO rolespec - | ALTER ROUTINE function_with_argtypes OWNER TO rolespec - | ALTER SCHEMA name OWNER TO rolespec - | ALTER TYPE_P any_name OWNER TO rolespec - | ALTER TABLESPACE name OWNER TO rolespec - | ALTER STATISTICS any_name OWNER TO rolespec - | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO rolespec - | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO rolespec - | ALTER FOREIGN DATA_P WRAPPER name OWNER TO rolespec - | ALTER SERVER name OWNER TO rolespec - | ALTER EVENT TRIGGER name OWNER TO rolespec - | ALTER PUBLICATION name OWNER TO rolespec - | ALTER SUBSCRIPTION name OWNER TO rolespec - ; + : ALTER AGGREGATE aggregate_with_argtypes OWNER TO rolespec + | ALTER COLLATION any_name OWNER TO rolespec + | ALTER CONVERSION_P any_name OWNER TO rolespec + | ALTER DATABASE name OWNER TO rolespec + | ALTER DOMAIN_P any_name OWNER TO rolespec + | ALTER FUNCTION function_with_argtypes OWNER TO rolespec + | ALTER opt_procedural LANGUAGE name OWNER TO rolespec + | ALTER LARGE_P OBJECT_P numericonly OWNER TO rolespec + | ALTER OPERATOR operator_with_argtypes OWNER TO rolespec + | ALTER OPERATOR CLASS any_name USING name OWNER TO rolespec + | ALTER OPERATOR FAMILY any_name USING name OWNER TO rolespec + | ALTER PROCEDURE function_with_argtypes OWNER TO rolespec + | ALTER ROUTINE function_with_argtypes OWNER TO rolespec + | ALTER SCHEMA name OWNER TO rolespec + | ALTER TYPE_P any_name OWNER TO rolespec + | ALTER TABLESPACE name OWNER TO rolespec + | ALTER STATISTICS any_name OWNER TO rolespec + | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO rolespec + | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO rolespec + | ALTER FOREIGN DATA_P WRAPPER name OWNER TO rolespec + | ALTER SERVER name OWNER TO rolespec + | ALTER EVENT TRIGGER name OWNER TO rolespec + | ALTER PUBLICATION name OWNER TO rolespec + | ALTER SUBSCRIPTION name OWNER TO rolespec + ; createpublicationstmt - : CREATE PUBLICATION name opt_publication_for_tables opt_definition - ; + : CREATE PUBLICATION name opt_publication_for_tables opt_definition + ; opt_publication_for_tables - : publication_for_tables - | - ; + : publication_for_tables + | + ; publication_for_tables - : FOR TABLE relation_expr_list - | FOR ALL TABLES - ; + : FOR TABLE relation_expr_list + | FOR ALL TABLES + ; alterpublicationstmt - : ALTER PUBLICATION name SET definition - | ALTER PUBLICATION name ADD_P TABLE relation_expr_list - | ALTER PUBLICATION name SET TABLE relation_expr_list - | ALTER PUBLICATION name DROP TABLE relation_expr_list - ; + : ALTER PUBLICATION name SET definition + | ALTER PUBLICATION name ADD_P TABLE relation_expr_list + | ALTER PUBLICATION name SET TABLE relation_expr_list + | ALTER PUBLICATION name DROP TABLE relation_expr_list + ; createsubscriptionstmt - : CREATE SUBSCRIPTION name CONNECTION sconst PUBLICATION publication_name_list opt_definition - ; + : CREATE SUBSCRIPTION name CONNECTION sconst PUBLICATION publication_name_list opt_definition + ; publication_name_list - : publication_name_item (COMMA publication_name_item)* - ; + : publication_name_item (COMMA publication_name_item)* + ; publication_name_item - : collabel - ; + : collabel + ; altersubscriptionstmt - : ALTER SUBSCRIPTION name SET definition - | ALTER SUBSCRIPTION name CONNECTION sconst - | ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition - | ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list opt_definition - | ALTER SUBSCRIPTION name ENABLE_P - | ALTER SUBSCRIPTION name DISABLE_P - ; + : ALTER SUBSCRIPTION name SET definition + | ALTER SUBSCRIPTION name CONNECTION sconst + | ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition + | ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list opt_definition + | ALTER SUBSCRIPTION name ENABLE_P + | ALTER SUBSCRIPTION name DISABLE_P + ; dropsubscriptionstmt - : DROP SUBSCRIPTION name opt_drop_behavior - | DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior - ; + : DROP SUBSCRIPTION name opt_drop_behavior + | DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior + ; rulestmt - : CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead ruleactionlist - ; + : CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead ruleactionlist + ; ruleactionlist - : NOTHING - | ruleactionstmt - | OPEN_PAREN ruleactionmulti CLOSE_PAREN - ; + : NOTHING + | ruleactionstmt + | OPEN_PAREN ruleactionmulti CLOSE_PAREN + ; ruleactionmulti - : ruleactionstmtOrEmpty (SEMI ruleactionstmtOrEmpty)* - ; + : ruleactionstmtOrEmpty (SEMI ruleactionstmtOrEmpty)* + ; ruleactionstmt - : selectstmt - | insertstmt - | updatestmt - | deletestmt - | notifystmt - ; + : selectstmt + | insertstmt + | updatestmt + | deletestmt + | notifystmt + ; ruleactionstmtOrEmpty - : ruleactionstmt - | - ; + : ruleactionstmt + | + ; event - : SELECT - | UPDATE - | DELETE_P - | INSERT - ; + : SELECT + | UPDATE + | DELETE_P + | INSERT + ; opt_instead - : INSTEAD - | ALSO - | - ; + : INSTEAD + | ALSO + | + ; notifystmt - : NOTIFY colid notify_payload - ; + : NOTIFY colid notify_payload + ; notify_payload - : COMMA sconst - | - ; + : COMMA sconst + | + ; listenstmt - : LISTEN colid - ; + : LISTEN colid + ; unlistenstmt - : UNLISTEN colid - | UNLISTEN STAR - ; + : UNLISTEN colid + | UNLISTEN STAR + ; transactionstmt - : ABORT_P opt_transaction opt_transaction_chain - | BEGIN_P opt_transaction transaction_mode_list_or_empty - | START TRANSACTION transaction_mode_list_or_empty - | COMMIT opt_transaction opt_transaction_chain - | END_P opt_transaction opt_transaction_chain - | ROLLBACK opt_transaction opt_transaction_chain - | SAVEPOINT colid - | RELEASE SAVEPOINT colid - | RELEASE colid - | ROLLBACK opt_transaction TO SAVEPOINT colid - | ROLLBACK opt_transaction TO colid - | PREPARE TRANSACTION sconst - | COMMIT PREPARED sconst - | ROLLBACK PREPARED sconst - ; + : ABORT_P opt_transaction opt_transaction_chain + | BEGIN_P opt_transaction transaction_mode_list_or_empty + | START TRANSACTION transaction_mode_list_or_empty + | COMMIT opt_transaction opt_transaction_chain + | END_P opt_transaction opt_transaction_chain + | ROLLBACK opt_transaction opt_transaction_chain + | SAVEPOINT colid + | RELEASE SAVEPOINT colid + | RELEASE colid + | ROLLBACK opt_transaction TO SAVEPOINT colid + | ROLLBACK opt_transaction TO colid + | PREPARE TRANSACTION sconst + | COMMIT PREPARED sconst + | ROLLBACK PREPARED sconst + ; opt_transaction - : WORK - | TRANSACTION - | - ; + : WORK + | TRANSACTION + | + ; transaction_mode_item - : ISOLATION LEVEL iso_level - | READ ONLY - | READ WRITE - | DEFERRABLE - | NOT DEFERRABLE - ; + : ISOLATION LEVEL iso_level + | READ ONLY + | READ WRITE + | DEFERRABLE + | NOT DEFERRABLE + ; transaction_mode_list - : transaction_mode_item (COMMA? transaction_mode_item)* - ; + : transaction_mode_item (COMMA? transaction_mode_item)* + ; transaction_mode_list_or_empty - : transaction_mode_list - | - ; + : transaction_mode_list + | + ; opt_transaction_chain - : AND NO? CHAIN - | - ; + : AND NO? CHAIN + | + ; viewstmt - : CREATE (OR REPLACE)? opttemp - ( - VIEW qualified_name opt_column_list opt_reloptions + : CREATE (OR REPLACE)? opttemp ( + VIEW qualified_name opt_column_list opt_reloptions | RECURSIVE VIEW qualified_name OPEN_PAREN columnlist CLOSE_PAREN opt_reloptions - ) - AS selectstmt opt_check_option - ; + ) AS selectstmt opt_check_option + ; opt_check_option - : WITH (CASCADED | LOCAL)? CHECK OPTION - | - ; + : WITH (CASCADED | LOCAL)? CHECK OPTION + | + ; loadstmt - : LOAD file_name - ; + : LOAD file_name + ; createdbstmt - : CREATE DATABASE name opt_with createdb_opt_list - ; + : CREATE DATABASE name opt_with createdb_opt_list + ; createdb_opt_list - : createdb_opt_items - | - ; + : createdb_opt_items + | + ; createdb_opt_items - : createdb_opt_item+ - ; + : createdb_opt_item+ + ; createdb_opt_item - : createdb_opt_name opt_equal (signediconst | opt_boolean_or_string | DEFAULT) - ; + : createdb_opt_name opt_equal (signediconst | opt_boolean_or_string | DEFAULT) + ; createdb_opt_name - : identifier - | CONNECTION LIMIT - | ENCODING - | LOCATION - | OWNER - | TABLESPACE - | TEMPLATE - ; + : identifier + | CONNECTION LIMIT + | ENCODING + | LOCATION + | OWNER + | TABLESPACE + | TEMPLATE + ; opt_equal - : EQUAL - | - ; + : EQUAL + | + ; alterdatabasestmt - : ALTER DATABASE name (WITH createdb_opt_list | createdb_opt_list | SET TABLESPACE name) - ; + : ALTER DATABASE name (WITH createdb_opt_list | createdb_opt_list | SET TABLESPACE name) + ; alterdatabasesetstmt - : ALTER DATABASE name setresetclause - ; + : ALTER DATABASE name setresetclause + ; dropdbstmt - : DROP DATABASE (IF_P EXISTS)? name (opt_with OPEN_PAREN drop_option_list CLOSE_PAREN)? - ; + : DROP DATABASE (IF_P EXISTS)? name (opt_with OPEN_PAREN drop_option_list CLOSE_PAREN)? + ; drop_option_list - : drop_option (COMMA drop_option)* - ; + : drop_option (COMMA drop_option)* + ; drop_option - : FORCE - ; + : FORCE + ; altercollationstmt - : ALTER COLLATION any_name REFRESH VERSION_P - ; + : ALTER COLLATION any_name REFRESH VERSION_P + ; altersystemstmt - : ALTER SYSTEM_P (SET | RESET) generic_set - ; + : ALTER SYSTEM_P (SET | RESET) generic_set + ; createdomainstmt - : CREATE DOMAIN_P any_name opt_as typename colquallist - ; + : CREATE DOMAIN_P any_name opt_as typename colquallist + ; alterdomainstmt - : ALTER DOMAIN_P any_name (alter_column_default | DROP NOT NULL_P | SET NOT NULL_P | ADD_P tableconstraint | DROP CONSTRAINT (IF_P EXISTS)? name opt_drop_behavior | VALIDATE CONSTRAINT name) - ; + : ALTER DOMAIN_P any_name ( + alter_column_default + | DROP NOT NULL_P + | SET NOT NULL_P + | ADD_P tableconstraint + | DROP CONSTRAINT (IF_P EXISTS)? name opt_drop_behavior + | VALIDATE CONSTRAINT name + ) + ; opt_as - : AS - | - ; + : AS + | + ; altertsdictionarystmt - : ALTER TEXT_P SEARCH DICTIONARY any_name definition - ; + : ALTER TEXT_P SEARCH DICTIONARY any_name definition + ; altertsconfigurationstmt - : ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list - | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list - | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name - | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name - | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list - | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list - ; + : ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list + | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list + | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name + | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name + | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list + | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list + ; any_with - : WITH - //TODO + : WITH + //TODO - // | WITH_LA - - ; + // | WITH_LA + ; createconversionstmt - : CREATE opt_default CONVERSION_P any_name FOR sconst TO sconst FROM any_name - ; + : CREATE opt_default CONVERSION_P any_name FOR sconst TO sconst FROM any_name + ; clusterstmt - : CLUSTER opt_verbose qualified_name cluster_index_specification - | CLUSTER opt_verbose - | CLUSTER opt_verbose name ON qualified_name - ; + : CLUSTER opt_verbose qualified_name cluster_index_specification + | CLUSTER opt_verbose + | CLUSTER opt_verbose name ON qualified_name + ; cluster_index_specification - : USING name - | - ; + : USING name + | + ; vacuumstmt - : VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list - | VACUUM OPEN_PAREN vac_analyze_option_list CLOSE_PAREN opt_vacuum_relation_list - ; + : VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list + | VACUUM OPEN_PAREN vac_analyze_option_list CLOSE_PAREN opt_vacuum_relation_list + ; analyzestmt - : analyze_keyword opt_verbose opt_vacuum_relation_list - | analyze_keyword OPEN_PAREN vac_analyze_option_list CLOSE_PAREN opt_vacuum_relation_list - ; + : analyze_keyword opt_verbose opt_vacuum_relation_list + | analyze_keyword OPEN_PAREN vac_analyze_option_list CLOSE_PAREN opt_vacuum_relation_list + ; vac_analyze_option_list - : vac_analyze_option_elem (COMMA vac_analyze_option_elem)* - ; + : vac_analyze_option_elem (COMMA vac_analyze_option_elem)* + ; analyze_keyword - : ANALYZE - | ANALYSE - ; + : ANALYZE + | ANALYSE + ; vac_analyze_option_elem - : vac_analyze_option_name vac_analyze_option_arg - ; + : vac_analyze_option_name vac_analyze_option_arg + ; vac_analyze_option_name - : nonreservedword - | analyze_keyword - ; + : nonreservedword + | analyze_keyword + ; vac_analyze_option_arg - : opt_boolean_or_string - | numericonly - | - ; + : opt_boolean_or_string + | numericonly + | + ; opt_analyze - : analyze_keyword - | - ; + : analyze_keyword + | + ; opt_verbose - : VERBOSE - | - ; + : VERBOSE + | + ; opt_full - : FULL - | - ; + : FULL + | + ; opt_freeze - : FREEZE - | - ; + : FREEZE + | + ; opt_name_list - : OPEN_PAREN name_list CLOSE_PAREN - | - ; + : OPEN_PAREN name_list CLOSE_PAREN + | + ; vacuum_relation - : qualified_name opt_name_list - ; + : qualified_name opt_name_list + ; vacuum_relation_list - : vacuum_relation (COMMA vacuum_relation)* - ; + : vacuum_relation (COMMA vacuum_relation)* + ; opt_vacuum_relation_list - : vacuum_relation_list - | - ; + : vacuum_relation_list + | + ; explainstmt - : EXPLAIN explainablestmt - | EXPLAIN analyze_keyword opt_verbose explainablestmt - | EXPLAIN VERBOSE explainablestmt - | EXPLAIN OPEN_PAREN explain_option_list CLOSE_PAREN explainablestmt - ; + : EXPLAIN explainablestmt + | EXPLAIN analyze_keyword opt_verbose explainablestmt + | EXPLAIN VERBOSE explainablestmt + | EXPLAIN OPEN_PAREN explain_option_list CLOSE_PAREN explainablestmt + ; explainablestmt - : selectstmt - | insertstmt - | updatestmt - | deletestmt - | declarecursorstmt - | createasstmt - | creatematviewstmt - | refreshmatviewstmt - | executestmt - ; + : selectstmt + | insertstmt + | updatestmt + | deletestmt + | declarecursorstmt + | createasstmt + | creatematviewstmt + | refreshmatviewstmt + | executestmt + ; explain_option_list - : explain_option_elem (COMMA explain_option_elem)* - ; + : explain_option_elem (COMMA explain_option_elem)* + ; explain_option_elem - : explain_option_name explain_option_arg - ; + : explain_option_name explain_option_arg + ; explain_option_name - : nonreservedword - | analyze_keyword - ; + : nonreservedword + | analyze_keyword + ; explain_option_arg - : opt_boolean_or_string - | numericonly - | - ; + : opt_boolean_or_string + | numericonly + | + ; preparestmt - : PREPARE name prep_type_clause AS preparablestmt - ; + : PREPARE name prep_type_clause AS preparablestmt + ; prep_type_clause - : OPEN_PAREN type_list CLOSE_PAREN - | - ; + : OPEN_PAREN type_list CLOSE_PAREN + | + ; preparablestmt - : selectstmt - | insertstmt - | updatestmt - | deletestmt - ; + : selectstmt + | insertstmt + | updatestmt + | deletestmt + ; executestmt - : EXECUTE name execute_param_clause - | CREATE opttemp TABLE create_as_target AS EXECUTE name execute_param_clause opt_with_data - | CREATE opttemp TABLE IF_P NOT EXISTS create_as_target AS EXECUTE name execute_param_clause opt_with_data - ; + : EXECUTE name execute_param_clause + | CREATE opttemp TABLE create_as_target AS EXECUTE name execute_param_clause opt_with_data + | CREATE opttemp TABLE IF_P NOT EXISTS create_as_target AS EXECUTE name execute_param_clause opt_with_data + ; execute_param_clause - : OPEN_PAREN expr_list CLOSE_PAREN - | - ; + : OPEN_PAREN expr_list CLOSE_PAREN + | + ; deallocatestmt - : DEALLOCATE name - | DEALLOCATE PREPARE name - | DEALLOCATE ALL - | DEALLOCATE PREPARE ALL - ; + : DEALLOCATE name + | DEALLOCATE PREPARE name + | DEALLOCATE ALL + | DEALLOCATE PREPARE ALL + ; insertstmt - : opt_with_clause INSERT INTO insert_target insert_rest opt_on_conflict returning_clause - ; + : opt_with_clause INSERT INTO insert_target insert_rest opt_on_conflict returning_clause + ; insert_target - : qualified_name (AS colid)? - ; + : qualified_name (AS colid)? + ; insert_rest - : selectstmt - | OVERRIDING override_kind VALUE_P selectstmt - | OPEN_PAREN insert_column_list CLOSE_PAREN (OVERRIDING override_kind VALUE_P)? selectstmt - | DEFAULT VALUES - ; + : selectstmt + | OVERRIDING override_kind VALUE_P selectstmt + | OPEN_PAREN insert_column_list CLOSE_PAREN (OVERRIDING override_kind VALUE_P)? selectstmt + | DEFAULT VALUES + ; override_kind - : USER - | SYSTEM_P - ; + : USER + | SYSTEM_P + ; insert_column_list - : insert_column_item (COMMA insert_column_item)* - ; + : insert_column_item (COMMA insert_column_item)* + ; insert_column_item - : colid opt_indirection - ; + : colid opt_indirection + ; opt_on_conflict - : ON CONFLICT opt_conf_expr DO (UPDATE SET set_clause_list where_clause | NOTHING) - | - ; + : ON CONFLICT opt_conf_expr DO (UPDATE SET set_clause_list where_clause | NOTHING) + | + ; opt_conf_expr - : OPEN_PAREN index_params CLOSE_PAREN where_clause - | ON CONSTRAINT name - | - ; + : OPEN_PAREN index_params CLOSE_PAREN where_clause + | ON CONSTRAINT name + | + ; returning_clause - : RETURNING target_list - | - ; + : RETURNING target_list + | + ; // https://www.postgresql.org/docs/current/sql-merge.html mergestmt - : MERGE INTO? qualified_name alias_clause? USING (select_with_parens|qualified_name) alias_clause? ON a_expr - (merge_insert_clause merge_update_clause? | merge_update_clause merge_insert_clause?) merge_delete_clause? - ; + : MERGE INTO? qualified_name alias_clause? USING (select_with_parens | qualified_name) alias_clause? ON a_expr ( + merge_insert_clause merge_update_clause? + | merge_update_clause merge_insert_clause? + ) merge_delete_clause? + ; merge_insert_clause - : WHEN NOT MATCHED (AND a_expr)? THEN? INSERT (OPEN_PAREN insert_column_list CLOSE_PAREN)? values_clause - ; + : WHEN NOT MATCHED (AND a_expr)? THEN? INSERT (OPEN_PAREN insert_column_list CLOSE_PAREN)? values_clause + ; merge_update_clause - : WHEN MATCHED (AND a_expr)? THEN? UPDATE SET set_clause_list - ; + : WHEN MATCHED (AND a_expr)? THEN? UPDATE SET set_clause_list + ; merge_delete_clause - : WHEN MATCHED THEN? DELETE_P - ; + : WHEN MATCHED THEN? DELETE_P + ; deletestmt - : opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause - ; + : opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause + ; using_clause - : USING from_list - | - ; + : USING from_list + | + ; lockstmt - : LOCK_P opt_table relation_expr_list opt_lock opt_nowait - ; + : LOCK_P opt_table relation_expr_list opt_lock opt_nowait + ; opt_lock - : IN_P lock_type MODE - | - ; + : IN_P lock_type MODE + | + ; lock_type - : ACCESS (SHARE | EXCLUSIVE) - | ROW (SHARE | EXCLUSIVE) - | SHARE (UPDATE EXCLUSIVE | ROW EXCLUSIVE)? - | EXCLUSIVE - ; + : ACCESS (SHARE | EXCLUSIVE) + | ROW (SHARE | EXCLUSIVE) + | SHARE (UPDATE EXCLUSIVE | ROW EXCLUSIVE)? + | EXCLUSIVE + ; opt_nowait - : NOWAIT - | - ; + : NOWAIT + | + ; opt_nowait_or_skip - : NOWAIT - | SKIP_P LOCKED - | - ; + : NOWAIT + | SKIP_P LOCKED + | + ; updatestmt - : opt_with_clause UPDATE relation_expr_opt_alias SET set_clause_list from_clause where_or_current_clause returning_clause - ; + : opt_with_clause UPDATE relation_expr_opt_alias SET set_clause_list from_clause where_or_current_clause returning_clause + ; set_clause_list - : set_clause (COMMA set_clause)* - ; + : set_clause (COMMA set_clause)* + ; set_clause - : set_target EQUAL a_expr - | OPEN_PAREN set_target_list CLOSE_PAREN EQUAL a_expr - ; + : set_target EQUAL a_expr + | OPEN_PAREN set_target_list CLOSE_PAREN EQUAL a_expr + ; set_target - : colid opt_indirection - ; + : colid opt_indirection + ; set_target_list - : set_target (COMMA set_target)* - ; + : set_target (COMMA set_target)* + ; declarecursorstmt - : DECLARE cursor_name cursor_options CURSOR opt_hold FOR selectstmt - ; + : DECLARE cursor_name cursor_options CURSOR opt_hold FOR selectstmt + ; cursor_name - : name - ; + : name + ; cursor_options - : (NO SCROLL | SCROLL | BINARY | INSENSITIVE)* - ; + : (NO SCROLL | SCROLL | BINARY | INSENSITIVE)* + ; opt_hold - : - | WITH HOLD - | WITHOUT HOLD - ; + : + | WITH HOLD + | WITHOUT HOLD + ; + /* TODO: why select_with_parens alternative is needed at all? i guess it because original byson grammar can choose selectstmt(2)->select_with_parens on only OPEN_PARENT/SELECT kewords at the begining of statement; @@ -2890,532 +2926,547 @@ instead of selectstmt(1)->select_no_parens(1)->select_clause(2)->selec all standard tests passed on both variants */ - selectstmt - : select_no_parens - | select_with_parens - ; + : select_no_parens + | select_with_parens + ; select_with_parens - : OPEN_PAREN select_no_parens CLOSE_PAREN - | OPEN_PAREN select_with_parens CLOSE_PAREN - ; + : OPEN_PAREN select_no_parens CLOSE_PAREN + | OPEN_PAREN select_with_parens CLOSE_PAREN + ; select_no_parens - : select_clause opt_sort_clause (for_locking_clause opt_select_limit | select_limit opt_for_locking_clause)? - | with_clause select_clause opt_sort_clause (for_locking_clause opt_select_limit | select_limit opt_for_locking_clause)? - ; + : select_clause opt_sort_clause ( + for_locking_clause opt_select_limit + | select_limit opt_for_locking_clause + )? + | with_clause select_clause opt_sort_clause ( + for_locking_clause opt_select_limit + | select_limit opt_for_locking_clause + )? + ; select_clause - : simple_select_intersect ((UNION | EXCEPT) all_or_distinct simple_select_intersect)* - ; + : simple_select_intersect ((UNION | EXCEPT) all_or_distinct simple_select_intersect)* + ; simple_select_intersect : simple_select_pramary (INTERSECT all_or_distinct simple_select_pramary)* ; simple_select_pramary - : ( SELECT (opt_all_clause into_clause opt_target_list | distinct_clause target_list) - into_clause - from_clause - where_clause - group_clause - having_clause - window_clause + : ( + SELECT (opt_all_clause into_clause opt_target_list | distinct_clause target_list) into_clause from_clause where_clause group_clause + having_clause window_clause ) - | values_clause - | TABLE relation_expr - | select_with_parens - ; + | values_clause + | TABLE relation_expr + | select_with_parens + ; with_clause - : WITH RECURSIVE? cte_list - ; + : WITH RECURSIVE? cte_list + ; cte_list - : common_table_expr (COMMA common_table_expr)* - ; + : common_table_expr (COMMA common_table_expr)* + ; common_table_expr - : name opt_name_list AS opt_materialized OPEN_PAREN preparablestmt CLOSE_PAREN - ; + : name opt_name_list AS opt_materialized OPEN_PAREN preparablestmt CLOSE_PAREN + ; opt_materialized - : MATERIALIZED - | NOT MATERIALIZED - | - ; + : MATERIALIZED + | NOT MATERIALIZED + | + ; opt_with_clause - : with_clause - | - ; + : with_clause + | + ; into_clause - : INTO (opt_strict opttempTableName | into_target) - | - ; + : INTO (opt_strict opttempTableName | into_target) + | + ; opt_strict - : - | STRICT_P - ; + : + | STRICT_P + ; opttempTableName - : (LOCAL|GLOBAL)? (TEMPORARY | TEMP) opt_table qualified_name - | UNLOGGED opt_table qualified_name - | TABLE qualified_name - | qualified_name - ; + : (LOCAL | GLOBAL)? (TEMPORARY | TEMP) opt_table qualified_name + | UNLOGGED opt_table qualified_name + | TABLE qualified_name + | qualified_name + ; opt_table - : TABLE - | - ; + : TABLE + | + ; all_or_distinct - : ALL - | DISTINCT - | - ; + : ALL + | DISTINCT + | + ; distinct_clause - : DISTINCT (ON OPEN_PAREN expr_list CLOSE_PAREN)? - ; + : DISTINCT (ON OPEN_PAREN expr_list CLOSE_PAREN)? + ; opt_all_clause - : ALL - | - ; + : ALL + | + ; opt_sort_clause - : sort_clause - | - ; + : sort_clause + | + ; sort_clause - : ORDER BY sortby_list - ; + : ORDER BY sortby_list + ; sortby_list - : sortby (COMMA sortby)* - ; + : sortby (COMMA sortby)* + ; sortby - : a_expr (USING qual_all_op | opt_asc_desc) opt_nulls_order - ; + : a_expr (USING qual_all_op | opt_asc_desc) opt_nulls_order + ; select_limit - : limit_clause offset_clause? - | offset_clause limit_clause? - ; + : limit_clause offset_clause? + | offset_clause limit_clause? + ; opt_select_limit - : select_limit - | - ; + : select_limit + | + ; limit_clause - : LIMIT select_limit_value (COMMA select_offset_value)? - | FETCH first_or_next (select_fetch_first_value row_or_rows (ONLY | WITH TIES) | row_or_rows (ONLY | WITH TIES)) - ; + : LIMIT select_limit_value (COMMA select_offset_value)? + | FETCH first_or_next ( + select_fetch_first_value row_or_rows (ONLY | WITH TIES) + | row_or_rows (ONLY | WITH TIES) + ) + ; offset_clause - : OFFSET (select_offset_value | select_fetch_first_value row_or_rows) - ; + : OFFSET (select_offset_value | select_fetch_first_value row_or_rows) + ; select_limit_value - : a_expr - | ALL - ; + : a_expr + | ALL + ; select_offset_value - : a_expr - ; + : a_expr + ; select_fetch_first_value - : c_expr - | PLUS i_or_f_const - | MINUS i_or_f_const - ; + : c_expr + | PLUS i_or_f_const + | MINUS i_or_f_const + ; i_or_f_const - : iconst - | fconst - ; + : iconst + | fconst + ; row_or_rows - : ROW - | ROWS - ; + : ROW + | ROWS + ; first_or_next - : FIRST_P - | NEXT - ; + : FIRST_P + | NEXT + ; group_clause - : GROUP_P BY group_by_list - | - ; + : GROUP_P BY group_by_list + | + ; group_by_list - : group_by_item (COMMA group_by_item)* - ; + : group_by_item (COMMA group_by_item)* + ; group_by_item - : a_expr - | empty_grouping_set - | cube_clause - | rollup_clause - | grouping_sets_clause - ; + : a_expr + | empty_grouping_set + | cube_clause + | rollup_clause + | grouping_sets_clause + ; empty_grouping_set - : OPEN_PAREN CLOSE_PAREN - ; + : OPEN_PAREN CLOSE_PAREN + ; rollup_clause - : ROLLUP OPEN_PAREN expr_list CLOSE_PAREN - ; + : ROLLUP OPEN_PAREN expr_list CLOSE_PAREN + ; cube_clause - : CUBE OPEN_PAREN expr_list CLOSE_PAREN - ; + : CUBE OPEN_PAREN expr_list CLOSE_PAREN + ; grouping_sets_clause - : GROUPING SETS OPEN_PAREN group_by_list CLOSE_PAREN - ; + : GROUPING SETS OPEN_PAREN group_by_list CLOSE_PAREN + ; having_clause - : HAVING a_expr - | - ; + : HAVING a_expr + | + ; for_locking_clause - : for_locking_items - | FOR READ ONLY - ; + : for_locking_items + | FOR READ ONLY + ; opt_for_locking_clause - : for_locking_clause - | - ; + : for_locking_clause + | + ; for_locking_items - : for_locking_item+ - ; + : for_locking_item+ + ; for_locking_item - : for_locking_strength locked_rels_list opt_nowait_or_skip - ; + : for_locking_strength locked_rels_list opt_nowait_or_skip + ; for_locking_strength - : FOR ((NO KEY)? UPDATE | KEY? SHARE) - ; + : FOR ((NO KEY)? UPDATE | KEY? SHARE) + ; locked_rels_list - : OF qualified_name_list - | - ; + : OF qualified_name_list + | + ; values_clause - : VALUES OPEN_PAREN expr_list CLOSE_PAREN (COMMA OPEN_PAREN expr_list CLOSE_PAREN)* - ; + : VALUES OPEN_PAREN expr_list CLOSE_PAREN (COMMA OPEN_PAREN expr_list CLOSE_PAREN)* + ; from_clause - : FROM from_list - | - ; + : FROM from_list + | + ; from_list - : non_ansi_join - | table_ref (COMMA table_ref)* - ; + : non_ansi_join + | table_ref (COMMA table_ref)* + ; non_ansi_join - : table_ref (COMMA table_ref)+ - ; + : table_ref (COMMA table_ref)+ + ; table_ref - : (relation_expr opt_alias_clause tablesample_clause? - | func_table func_alias_clause - | xmltable opt_alias_clause - | select_with_parens opt_alias_clause - | LATERAL_P ( - xmltable opt_alias_clause - | func_table func_alias_clause - | select_with_parens opt_alias_clause - ) - | OPEN_PAREN table_ref ( - CROSS JOIN table_ref - | NATURAL join_type? JOIN table_ref - | join_type? JOIN table_ref join_qual - )? CLOSE_PAREN opt_alias_clause - ) - (CROSS JOIN table_ref | NATURAL join_type? JOIN table_ref | join_type? JOIN table_ref join_qual)* - ; + : ( + relation_expr opt_alias_clause tablesample_clause? + | func_table func_alias_clause + | xmltable opt_alias_clause + | select_with_parens opt_alias_clause + | LATERAL_P ( + xmltable opt_alias_clause + | func_table func_alias_clause + | select_with_parens opt_alias_clause + ) + | OPEN_PAREN table_ref ( + CROSS JOIN table_ref + | NATURAL join_type? JOIN table_ref + | join_type? JOIN table_ref join_qual + )? CLOSE_PAREN opt_alias_clause + ) ( + CROSS JOIN table_ref + | NATURAL join_type? JOIN table_ref + | join_type? JOIN table_ref join_qual + )* + ; alias_clause - : AS? colid (OPEN_PAREN name_list CLOSE_PAREN)? - ; + : AS? colid (OPEN_PAREN name_list CLOSE_PAREN)? + ; opt_alias_clause - : table_alias_clause - | - ; + : table_alias_clause + | + ; table_alias_clause - : AS? table_alias (OPEN_PAREN name_list CLOSE_PAREN)? - ; + : AS? table_alias (OPEN_PAREN name_list CLOSE_PAREN)? + ; func_alias_clause - : alias_clause - | (AS colid? | colid) OPEN_PAREN tablefuncelementlist CLOSE_PAREN - | - ; + : alias_clause + | (AS colid? | colid) OPEN_PAREN tablefuncelementlist CLOSE_PAREN + | + ; join_type - : (FULL | LEFT | RIGHT | INNER_P) OUTER_P? - ; + : (FULL | LEFT | RIGHT | INNER_P) OUTER_P? + ; join_qual - : USING OPEN_PAREN name_list CLOSE_PAREN - | ON a_expr - ; + : USING OPEN_PAREN name_list CLOSE_PAREN + | ON a_expr + ; relation_expr - : qualified_name STAR? - | ONLY (qualified_name | OPEN_PAREN qualified_name CLOSE_PAREN) - ; + : qualified_name STAR? + | ONLY (qualified_name | OPEN_PAREN qualified_name CLOSE_PAREN) + ; relation_expr_list - : relation_expr (COMMA relation_expr)* - ; + : relation_expr (COMMA relation_expr)* + ; relation_expr_opt_alias - : relation_expr (AS? colid)? - ; + : relation_expr (AS? colid)? + ; tablesample_clause - : TABLESAMPLE func_name OPEN_PAREN expr_list CLOSE_PAREN opt_repeatable_clause - ; + : TABLESAMPLE func_name OPEN_PAREN expr_list CLOSE_PAREN opt_repeatable_clause + ; opt_repeatable_clause - : REPEATABLE OPEN_PAREN a_expr CLOSE_PAREN - | - ; + : REPEATABLE OPEN_PAREN a_expr CLOSE_PAREN + | + ; func_table - : func_expr_windowless opt_ordinality - | ROWS FROM OPEN_PAREN rowsfrom_list CLOSE_PAREN opt_ordinality - ; + : func_expr_windowless opt_ordinality + | ROWS FROM OPEN_PAREN rowsfrom_list CLOSE_PAREN opt_ordinality + ; rowsfrom_item - : func_expr_windowless opt_col_def_list - ; + : func_expr_windowless opt_col_def_list + ; rowsfrom_list - : rowsfrom_item (COMMA rowsfrom_item)* - ; + : rowsfrom_item (COMMA rowsfrom_item)* + ; opt_col_def_list - : AS OPEN_PAREN tablefuncelementlist CLOSE_PAREN - | - ; - //TODO WITH_LA was used + : AS OPEN_PAREN tablefuncelementlist CLOSE_PAREN + | + ; + +//TODO WITH_LA was used opt_ordinality - : WITH ORDINALITY - | - ; + : WITH ORDINALITY + | + ; where_clause - : WHERE a_expr - | - ; + : WHERE a_expr + | + ; where_or_current_clause - : WHERE (CURRENT_P OF cursor_name | a_expr) - | - ; + : WHERE (CURRENT_P OF cursor_name | a_expr) + | + ; opttablefuncelementlist - : tablefuncelementlist - | - ; + : tablefuncelementlist + | + ; tablefuncelementlist - : tablefuncelement (COMMA tablefuncelement)* - ; + : tablefuncelement (COMMA tablefuncelement)* + ; tablefuncelement - : colid typename opt_collate_clause - ; + : colid typename opt_collate_clause + ; xmltable - : XMLTABLE OPEN_PAREN (c_expr xmlexists_argument COLUMNS xmltable_column_list | XMLNAMESPACES OPEN_PAREN xml_namespace_list CLOSE_PAREN COMMA c_expr xmlexists_argument COLUMNS xmltable_column_list) CLOSE_PAREN - ; + : XMLTABLE OPEN_PAREN ( + c_expr xmlexists_argument COLUMNS xmltable_column_list + | XMLNAMESPACES OPEN_PAREN xml_namespace_list CLOSE_PAREN COMMA c_expr xmlexists_argument COLUMNS xmltable_column_list + ) CLOSE_PAREN + ; xmltable_column_list - : xmltable_column_el (COMMA xmltable_column_el)* - ; + : xmltable_column_el (COMMA xmltable_column_el)* + ; xmltable_column_el - : colid (typename xmltable_column_option_list? | FOR ORDINALITY) - ; + : colid (typename xmltable_column_option_list? | FOR ORDINALITY) + ; xmltable_column_option_list - : xmltable_column_option_el+ - ; + : xmltable_column_option_el+ + ; xmltable_column_option_el - : DEFAULT a_expr - | identifier a_expr - | NOT NULL_P - | NULL_P - ; + : DEFAULT a_expr + | identifier a_expr + | NOT NULL_P + | NULL_P + ; xml_namespace_list - : xml_namespace_el (COMMA xml_namespace_el)* - ; + : xml_namespace_el (COMMA xml_namespace_el)* + ; xml_namespace_el - : b_expr AS collabel - | DEFAULT b_expr - ; + : b_expr AS collabel + | DEFAULT b_expr + ; typename - : SETOF? simpletypename (opt_array_bounds | ARRAY (OPEN_BRACKET iconst CLOSE_BRACKET)?) - | qualified_name PERCENT (ROWTYPE | TYPE_P) - ; + : SETOF? simpletypename (opt_array_bounds | ARRAY (OPEN_BRACKET iconst CLOSE_BRACKET)?) + | qualified_name PERCENT (ROWTYPE | TYPE_P) + ; opt_array_bounds - : (OPEN_BRACKET iconst? CLOSE_BRACKET)* - ; + : (OPEN_BRACKET iconst? CLOSE_BRACKET)* + ; simpletypename - : generictype - | numeric - | bit - | character - | constdatetime - | constinterval (opt_interval | OPEN_PAREN iconst CLOSE_PAREN) - ; + : generictype + | numeric + | bit + | character + | constdatetime + | constinterval (opt_interval | OPEN_PAREN iconst CLOSE_PAREN) + ; consttypename - : numeric - | constbit - | constcharacter - | constdatetime - ; + : numeric + | constbit + | constcharacter + | constdatetime + ; generictype - : (builtin_function_name | type_function_name | LEFT | RIGHT) attrs? opt_type_modifiers - ; + : (builtin_function_name | type_function_name | LEFT | RIGHT) attrs? opt_type_modifiers + ; opt_type_modifiers - : OPEN_PAREN expr_list CLOSE_PAREN - | - ; + : OPEN_PAREN expr_list CLOSE_PAREN + | + ; numeric - : INT_P - | INTEGER - | SMALLINT - | BIGINT - | REAL - | FLOAT_P opt_float - | DOUBLE_P PRECISION - | DECIMAL_P opt_type_modifiers - | DEC opt_type_modifiers - | NUMERIC opt_type_modifiers - | BOOLEAN_P - ; + : INT_P + | INTEGER + | SMALLINT + | BIGINT + | REAL + | FLOAT_P opt_float + | DOUBLE_P PRECISION + | DECIMAL_P opt_type_modifiers + | DEC opt_type_modifiers + | NUMERIC opt_type_modifiers + | BOOLEAN_P + ; opt_float - : OPEN_PAREN iconst CLOSE_PAREN - | - ; - //todo: merge alts + : OPEN_PAREN iconst CLOSE_PAREN + | + ; + +//todo: merge alts bit - : bitwithlength - | bitwithoutlength - ; + : bitwithlength + | bitwithoutlength + ; constbit - : bitwithlength - | bitwithoutlength - ; + : bitwithlength + | bitwithoutlength + ; bitwithlength - : BIT opt_varying OPEN_PAREN expr_list CLOSE_PAREN - ; + : BIT opt_varying OPEN_PAREN expr_list CLOSE_PAREN + ; bitwithoutlength - : BIT opt_varying - ; + : BIT opt_varying + ; character - : character_c (OPEN_PAREN iconst CLOSE_PAREN)? - ; + : character_c (OPEN_PAREN iconst CLOSE_PAREN)? + ; constcharacter - : character_c (OPEN_PAREN iconst CLOSE_PAREN)? - ; + : character_c (OPEN_PAREN iconst CLOSE_PAREN)? + ; character_c - : (CHARACTER | CHAR_P | NCHAR) opt_varying - | VARCHAR - | NATIONAL (CHARACTER | CHAR_P) opt_varying - ; + : (CHARACTER | CHAR_P | NCHAR) opt_varying + | VARCHAR + | NATIONAL (CHARACTER | CHAR_P) opt_varying + ; opt_varying - : VARYING - | - ; + : VARYING + | + ; constdatetime - : (TIMESTAMP | TIME) (OPEN_PAREN iconst CLOSE_PAREN)? opt_timezone - ; + : (TIMESTAMP | TIME) (OPEN_PAREN iconst CLOSE_PAREN)? opt_timezone + ; constinterval - : INTERVAL - ; - //TODO with_la was used + : INTERVAL + ; + +//TODO with_la was used opt_timezone - : WITH TIME ZONE - | WITHOUT TIME ZONE - | - ; + : WITH TIME ZONE + | WITHOUT TIME ZONE + | + ; opt_interval - : YEAR_P - | MONTH_P - | DAY_P - | HOUR_P - | MINUTE_P - | interval_second - | YEAR_P TO MONTH_P - | DAY_P TO (HOUR_P | MINUTE_P | interval_second) - | HOUR_P TO (MINUTE_P | interval_second) - | MINUTE_P TO interval_second - | - ; + : YEAR_P + | MONTH_P + | DAY_P + | HOUR_P + | MINUTE_P + | interval_second + | YEAR_P TO MONTH_P + | DAY_P TO (HOUR_P | MINUTE_P | interval_second) + | HOUR_P TO (MINUTE_P | interval_second) + | MINUTE_P TO interval_second + | + ; interval_second - : SECOND_P (OPEN_PAREN iconst CLOSE_PAREN)? - ; + : SECOND_P (OPEN_PAREN iconst CLOSE_PAREN)? + ; opt_escape - : ESCAPE a_expr - | - ; - //precendence accroding to Table 4.2. Operator Precedence (highest to lowest) + : ESCAPE a_expr + | + ; + +//precendence accroding to Table 4.2. Operator Precedence (highest to lowest) - //https://www.postgresql.org/docs/12/sql-syntax-lexical.html#SQL-PRECEDENCE +//https://www.postgresql.org/docs/12/sql-syntax-lexical.html#SQL-PRECEDENCE /* original version of a_expr, for info @@ -3468,366 +3519,374 @@ original version of a_expr, for info ; */ - a_expr - : a_expr_qual - ; -/*23*/ + : a_expr_qual + ; +/*23*/ /*moved to c_expr*/ - /*22*/ - /*moved to c_expr*/ - /*19*/ - a_expr_qual - : a_expr_lessless qual_op? - ; -/*18*/ + : a_expr_lessless qual_op? + ; +/*18*/ a_expr_lessless - : a_expr_or ((LESS_LESS | GREATER_GREATER) a_expr_or)* - ; -/*17*/ + : a_expr_or ((LESS_LESS | GREATER_GREATER) a_expr_or)* + ; +/*17*/ a_expr_or - : a_expr_and (OR a_expr_and)* - ; + : a_expr_and (OR a_expr_and)* + ; + /*16*/ a_expr_and - : a_expr_between (AND a_expr_between)* - ; + : a_expr_between (AND a_expr_between)* + ; + /*21*/ a_expr_between - : a_expr_in (NOT? BETWEEN SYMMETRIC? a_expr_in AND a_expr_in)? - ; -/*20*/ + : a_expr_in (NOT? BETWEEN SYMMETRIC? a_expr_in AND a_expr_in)? + ; +/*20*/ a_expr_in - : a_expr_unary_not (NOT? IN_P in_expr)? - ; -/*15*/ + : a_expr_unary_not (NOT? IN_P in_expr)? + ; +/*15*/ a_expr_unary_not - : NOT? a_expr_isnull - ; -/*14*/ + : NOT? a_expr_isnull + ; +/*14*/ /*moved to c_expr*/ - /*13*/ - a_expr_isnull - : a_expr_is_not (ISNULL | NOTNULL)? - ; -/*12*/ + : a_expr_is_not (ISNULL | NOTNULL)? + ; +/*12*/ a_expr_is_not - : a_expr_compare (IS NOT? (NULL_P | TRUE_P | FALSE_P | UNKNOWN | DISTINCT FROM a_expr | OF OPEN_PAREN type_list CLOSE_PAREN | DOCUMENT_P | unicode_normal_form? NORMALIZED))? - ; -/*11*/ + : a_expr_compare ( + IS NOT? ( + NULL_P + | TRUE_P + | FALSE_P + | UNKNOWN + | DISTINCT FROM a_expr + | OF OPEN_PAREN type_list CLOSE_PAREN + | DOCUMENT_P + | unicode_normal_form? NORMALIZED + ) + )? + ; +/*11*/ a_expr_compare - : a_expr_like ((LT | GT | EQUAL | LESS_EQUALS | GREATER_EQUALS | NOT_EQUALS) a_expr_like |subquery_Op sub_type (select_with_parens | OPEN_PAREN a_expr CLOSE_PAREN) /*21*/ + : a_expr_like ( + (LT | GT | EQUAL | LESS_EQUALS | GREATER_EQUALS | NOT_EQUALS) a_expr_like + | subquery_Op sub_type (select_with_parens | OPEN_PAREN a_expr CLOSE_PAREN) /*21*/ + )? + ; - )? - ; /*10*/ - a_expr_like - : a_expr_qual_op (NOT? (LIKE | ILIKE | SIMILAR TO) a_expr_qual_op opt_escape)? - ; -/* 8*/ + : a_expr_qual_op (NOT? (LIKE | ILIKE | SIMILAR TO) a_expr_qual_op opt_escape)? + ; +/* 8*/ a_expr_qual_op - : a_expr_unary_qualop (qual_op a_expr_unary_qualop)* - ; -/* 9*/ + : a_expr_unary_qualop (qual_op a_expr_unary_qualop)* + ; +/* 9*/ a_expr_unary_qualop - : qual_op? a_expr_add - ; -/* 7*/ + : qual_op? a_expr_add + ; +/* 7*/ a_expr_add - : a_expr_mul ((MINUS | PLUS) a_expr_mul)* - ; -/* 6*/ + : a_expr_mul ((MINUS | PLUS) a_expr_mul)* + ; +/* 6*/ a_expr_mul - : a_expr_caret ((STAR | SLASH | PERCENT) a_expr_caret)* - ; -/* 5*/ + : a_expr_caret ((STAR | SLASH | PERCENT) a_expr_caret)* + ; +/* 5*/ a_expr_caret - : a_expr_unary_sign (CARET a_expr)? - ; -/* 4*/ + : a_expr_unary_sign (CARET a_expr)? + ; +/* 4*/ a_expr_unary_sign - : (MINUS | PLUS)? a_expr_at_time_zone /* */ - + : (MINUS | PLUS)? a_expr_at_time_zone /* */ + ; - ; /* 3*/ - a_expr_at_time_zone - : a_expr_collate (AT TIME ZONE a_expr)? - ; -/* 2*/ + : a_expr_collate (AT TIME ZONE a_expr)? + ; +/* 2*/ a_expr_collate - : a_expr_typecast (COLLATE any_name)? - ; -/* 1*/ + : a_expr_typecast (COLLATE any_name)? + ; +/* 1*/ a_expr_typecast - : c_expr (TYPECAST typename)* - ; + : c_expr (TYPECAST typename)* + ; b_expr - : c_expr - | b_expr TYPECAST typename - //right unary plus, unary minus - | (PLUS | MINUS) b_expr - //^ left exponentiation - | b_expr CARET b_expr - //* / % left multiplication, division, modulo - | b_expr (STAR | SLASH | PERCENT) b_expr - //+ - left addition, subtraction - | b_expr (PLUS | MINUS) b_expr - //(any other operator) left all other native and user-defined operators - | b_expr qual_op b_expr - //< > = <= >= <> comparison operators - | b_expr (LT | GT | EQUAL | LESS_EQUALS | GREATER_EQUALS | NOT_EQUALS) b_expr - | qual_op b_expr - | b_expr qual_op - //S ISNULL NOTNULL IS TRUE, IS FALSE, IS NULL, IS DISTINCT FROM, etc - | b_expr IS NOT? (DISTINCT FROM b_expr | OF OPEN_PAREN type_list CLOSE_PAREN | DOCUMENT_P) - ; + : c_expr + | b_expr TYPECAST typename + //right unary plus, unary minus + | (PLUS | MINUS) b_expr + //^ left exponentiation + | b_expr CARET b_expr + //* / % left multiplication, division, modulo + | b_expr (STAR | SLASH | PERCENT) b_expr + //+ - left addition, subtraction + | b_expr (PLUS | MINUS) b_expr + //(any other operator) left all other native and user-defined operators + | b_expr qual_op b_expr + //< > = <= >= <> comparison operators + | b_expr (LT | GT | EQUAL | LESS_EQUALS | GREATER_EQUALS | NOT_EQUALS) b_expr + | qual_op b_expr + | b_expr qual_op + //S ISNULL NOTNULL IS TRUE, IS FALSE, IS NULL, IS DISTINCT FROM, etc + | b_expr IS NOT? (DISTINCT FROM b_expr | OF OPEN_PAREN type_list CLOSE_PAREN | DOCUMENT_P) + ; c_expr - : EXISTS select_with_parens # c_expr_exists - | ARRAY (select_with_parens | array_expr) # c_expr_expr - | PARAM opt_indirection # c_expr_expr - | GROUPING OPEN_PAREN expr_list CLOSE_PAREN # c_expr_expr - | /*22*/ - - UNIQUE select_with_parens # c_expr_expr - | columnref # c_expr_expr - | aexprconst # c_expr_expr - | plsqlvariablename # c_expr_expr - | OPEN_PAREN a_expr_in_parens = a_expr CLOSE_PAREN opt_indirection # c_expr_expr - | case_expr # c_expr_case - | func_expr # c_expr_expr - | select_with_parens indirection? # c_expr_expr - | explicit_row # c_expr_expr - | implicit_row # c_expr_expr - | row OVERLAPS row /* 14*/ - - # c_expr_expr - ; + : EXISTS select_with_parens # c_expr_exists + | ARRAY (select_with_parens | array_expr) # c_expr_expr + | PARAM opt_indirection # c_expr_expr + | GROUPING OPEN_PAREN expr_list CLOSE_PAREN # c_expr_expr + | /*22*/ UNIQUE select_with_parens # c_expr_expr + | columnref # c_expr_expr + | aexprconst # c_expr_expr + | plsqlvariablename # c_expr_expr + | OPEN_PAREN a_expr_in_parens = a_expr CLOSE_PAREN opt_indirection # c_expr_expr + | case_expr # c_expr_case + | func_expr # c_expr_expr + | select_with_parens indirection? # c_expr_expr + | explicit_row # c_expr_expr + | implicit_row # c_expr_expr + | row OVERLAPS row /* 14*/ # c_expr_expr + ; plsqlvariablename - : PLSQLVARIABLENAME - ; + : PLSQLVARIABLENAME + ; func_application - : func_name OPEN_PAREN (func_arg_list (COMMA VARIADIC func_arg_expr)? opt_sort_clause | VARIADIC func_arg_expr opt_sort_clause | (ALL | DISTINCT) func_arg_list opt_sort_clause | STAR |) CLOSE_PAREN - ; + : func_name OPEN_PAREN ( + func_arg_list (COMMA VARIADIC func_arg_expr)? opt_sort_clause + | VARIADIC func_arg_expr opt_sort_clause + | (ALL | DISTINCT) func_arg_list opt_sort_clause + | STAR + | + ) CLOSE_PAREN + ; func_expr - : func_application within_group_clause filter_clause over_clause - | func_expr_common_subexpr - ; + : func_application within_group_clause filter_clause over_clause + | func_expr_common_subexpr + ; func_expr_windowless - : func_application - | func_expr_common_subexpr - ; + : func_application + | func_expr_common_subexpr + ; func_expr_common_subexpr - : COLLATION FOR OPEN_PAREN a_expr CLOSE_PAREN - | CURRENT_DATE - | CURRENT_TIME (OPEN_PAREN iconst CLOSE_PAREN)? - | CURRENT_TIMESTAMP (OPEN_PAREN iconst CLOSE_PAREN)? - | LOCALTIME (OPEN_PAREN iconst CLOSE_PAREN)? - | LOCALTIMESTAMP (OPEN_PAREN iconst CLOSE_PAREN)? - | CURRENT_ROLE - | CURRENT_USER - | SESSION_USER - | USER - | CURRENT_CATALOG - | CURRENT_SCHEMA - | CAST OPEN_PAREN a_expr AS typename CLOSE_PAREN - | EXTRACT OPEN_PAREN extract_list CLOSE_PAREN - | NORMALIZE OPEN_PAREN a_expr (COMMA unicode_normal_form)? CLOSE_PAREN - | OVERLAY OPEN_PAREN overlay_list CLOSE_PAREN - | POSITION OPEN_PAREN position_list CLOSE_PAREN - | SUBSTRING OPEN_PAREN substr_list CLOSE_PAREN - | TREAT OPEN_PAREN a_expr AS typename CLOSE_PAREN - | TRIM OPEN_PAREN (BOTH | LEADING | TRAILING)? trim_list CLOSE_PAREN - | NULLIF OPEN_PAREN a_expr COMMA a_expr CLOSE_PAREN - | COALESCE OPEN_PAREN expr_list CLOSE_PAREN - | GREATEST OPEN_PAREN expr_list CLOSE_PAREN - | LEAST OPEN_PAREN expr_list CLOSE_PAREN - | XMLCONCAT OPEN_PAREN expr_list CLOSE_PAREN - | XMLELEMENT OPEN_PAREN NAME_P collabel (COMMA (xml_attributes | expr_list))? CLOSE_PAREN - | XMLEXISTS OPEN_PAREN c_expr xmlexists_argument CLOSE_PAREN - | XMLFOREST OPEN_PAREN xml_attribute_list CLOSE_PAREN - | XMLPARSE OPEN_PAREN document_or_content a_expr xml_whitespace_option CLOSE_PAREN - | XMLPI OPEN_PAREN NAME_P collabel (COMMA a_expr)? CLOSE_PAREN - | XMLROOT OPEN_PAREN XML_P a_expr COMMA xml_root_version opt_xml_root_standalone CLOSE_PAREN - | XMLSERIALIZE OPEN_PAREN document_or_content a_expr AS simpletypename CLOSE_PAREN - ; + : COLLATION FOR OPEN_PAREN a_expr CLOSE_PAREN + | CURRENT_DATE + | CURRENT_TIME (OPEN_PAREN iconst CLOSE_PAREN)? + | CURRENT_TIMESTAMP (OPEN_PAREN iconst CLOSE_PAREN)? + | LOCALTIME (OPEN_PAREN iconst CLOSE_PAREN)? + | LOCALTIMESTAMP (OPEN_PAREN iconst CLOSE_PAREN)? + | CURRENT_ROLE + | CURRENT_USER + | SESSION_USER + | USER + | CURRENT_CATALOG + | CURRENT_SCHEMA + | CAST OPEN_PAREN a_expr AS typename CLOSE_PAREN + | EXTRACT OPEN_PAREN extract_list CLOSE_PAREN + | NORMALIZE OPEN_PAREN a_expr (COMMA unicode_normal_form)? CLOSE_PAREN + | OVERLAY OPEN_PAREN overlay_list CLOSE_PAREN + | POSITION OPEN_PAREN position_list CLOSE_PAREN + | SUBSTRING OPEN_PAREN substr_list CLOSE_PAREN + | TREAT OPEN_PAREN a_expr AS typename CLOSE_PAREN + | TRIM OPEN_PAREN (BOTH | LEADING | TRAILING)? trim_list CLOSE_PAREN + | NULLIF OPEN_PAREN a_expr COMMA a_expr CLOSE_PAREN + | COALESCE OPEN_PAREN expr_list CLOSE_PAREN + | GREATEST OPEN_PAREN expr_list CLOSE_PAREN + | LEAST OPEN_PAREN expr_list CLOSE_PAREN + | XMLCONCAT OPEN_PAREN expr_list CLOSE_PAREN + | XMLELEMENT OPEN_PAREN NAME_P collabel (COMMA (xml_attributes | expr_list))? CLOSE_PAREN + | XMLEXISTS OPEN_PAREN c_expr xmlexists_argument CLOSE_PAREN + | XMLFOREST OPEN_PAREN xml_attribute_list CLOSE_PAREN + | XMLPARSE OPEN_PAREN document_or_content a_expr xml_whitespace_option CLOSE_PAREN + | XMLPI OPEN_PAREN NAME_P collabel (COMMA a_expr)? CLOSE_PAREN + | XMLROOT OPEN_PAREN XML_P a_expr COMMA xml_root_version opt_xml_root_standalone CLOSE_PAREN + | XMLSERIALIZE OPEN_PAREN document_or_content a_expr AS simpletypename CLOSE_PAREN + ; xml_root_version - : VERSION_P a_expr - | VERSION_P NO VALUE_P - ; + : VERSION_P a_expr + | VERSION_P NO VALUE_P + ; opt_xml_root_standalone - : COMMA STANDALONE_P YES_P - | COMMA STANDALONE_P NO - | COMMA STANDALONE_P NO VALUE_P - | - ; + : COMMA STANDALONE_P YES_P + | COMMA STANDALONE_P NO + | COMMA STANDALONE_P NO VALUE_P + | + ; xml_attributes - : XMLATTRIBUTES OPEN_PAREN xml_attribute_list CLOSE_PAREN - ; + : XMLATTRIBUTES OPEN_PAREN xml_attribute_list CLOSE_PAREN + ; xml_attribute_list - : xml_attribute_el (COMMA xml_attribute_el)* - ; + : xml_attribute_el (COMMA xml_attribute_el)* + ; xml_attribute_el - : a_expr (AS collabel)? - ; + : a_expr (AS collabel)? + ; document_or_content - : DOCUMENT_P - | CONTENT_P - ; + : DOCUMENT_P + | CONTENT_P + ; xml_whitespace_option - : PRESERVE WHITESPACE_P - | STRIP_P WHITESPACE_P - | - ; + : PRESERVE WHITESPACE_P + | STRIP_P WHITESPACE_P + | + ; xmlexists_argument - : PASSING c_expr - | PASSING c_expr xml_passing_mech - | PASSING xml_passing_mech c_expr - | PASSING xml_passing_mech c_expr xml_passing_mech - ; + : PASSING c_expr + | PASSING c_expr xml_passing_mech + | PASSING xml_passing_mech c_expr + | PASSING xml_passing_mech c_expr xml_passing_mech + ; xml_passing_mech - : BY (REF | VALUE_P) - ; + : BY (REF | VALUE_P) + ; within_group_clause - : WITHIN GROUP_P OPEN_PAREN sort_clause CLOSE_PAREN - | - ; + : WITHIN GROUP_P OPEN_PAREN sort_clause CLOSE_PAREN + | + ; filter_clause - : FILTER OPEN_PAREN WHERE a_expr CLOSE_PAREN - | - ; + : FILTER OPEN_PAREN WHERE a_expr CLOSE_PAREN + | + ; window_clause - : WINDOW window_definition_list - | - ; + : WINDOW window_definition_list + | + ; window_definition_list - : window_definition (COMMA window_definition)* - ; + : window_definition (COMMA window_definition)* + ; window_definition - : colid AS window_specification - ; + : colid AS window_specification + ; over_clause - : OVER (window_specification | colid) - | - ; + : OVER (window_specification | colid) + | + ; window_specification - : OPEN_PAREN opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause CLOSE_PAREN - ; + : OPEN_PAREN opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause CLOSE_PAREN + ; opt_existing_window_name - : colid - | - ; + : colid + | + ; opt_partition_clause - : PARTITION BY expr_list - | - ; + : PARTITION BY expr_list + | + ; opt_frame_clause - : RANGE frame_extent opt_window_exclusion_clause - | ROWS frame_extent opt_window_exclusion_clause - | GROUPS frame_extent opt_window_exclusion_clause - | - ; + : RANGE frame_extent opt_window_exclusion_clause + | ROWS frame_extent opt_window_exclusion_clause + | GROUPS frame_extent opt_window_exclusion_clause + | + ; frame_extent - : frame_bound - | BETWEEN frame_bound AND frame_bound - ; + : frame_bound + | BETWEEN frame_bound AND frame_bound + ; frame_bound - : UNBOUNDED (PRECEDING | FOLLOWING) - | CURRENT_P ROW - | a_expr (PRECEDING | FOLLOWING) - ; + : UNBOUNDED (PRECEDING | FOLLOWING) + | CURRENT_P ROW + | a_expr (PRECEDING | FOLLOWING) + ; opt_window_exclusion_clause - : EXCLUDE (CURRENT_P ROW | GROUP_P | TIES | NO OTHERS) - | - ; + : EXCLUDE (CURRENT_P ROW | GROUP_P | TIES | NO OTHERS) + | + ; row - : ROW OPEN_PAREN expr_list? CLOSE_PAREN - | OPEN_PAREN expr_list COMMA a_expr CLOSE_PAREN - ; + : ROW OPEN_PAREN expr_list? CLOSE_PAREN + | OPEN_PAREN expr_list COMMA a_expr CLOSE_PAREN + ; explicit_row - : ROW OPEN_PAREN expr_list? CLOSE_PAREN - ; + : ROW OPEN_PAREN expr_list? CLOSE_PAREN + ; + /* TODO: for some reason v1 @@ -3838,1659 +3897,1667 @@ while looks like they are almost the same, except v2 requieres at least 2 items while v1 allows single item in list */ - implicit_row - : OPEN_PAREN expr_list COMMA a_expr CLOSE_PAREN - ; + : OPEN_PAREN expr_list COMMA a_expr CLOSE_PAREN + ; sub_type - : ANY - | SOME - | ALL - ; + : ANY + | SOME + | ALL + ; all_op - : Operator - | mathop - ; + : Operator + | mathop + ; mathop - : PLUS - | MINUS - | STAR - | SLASH - | PERCENT - | CARET - | LT - | GT - | EQUAL - | LESS_EQUALS - | GREATER_EQUALS - | NOT_EQUALS - ; + : PLUS + | MINUS + | STAR + | SLASH + | PERCENT + | CARET + | LT + | GT + | EQUAL + | LESS_EQUALS + | GREATER_EQUALS + | NOT_EQUALS + ; qual_op - : Operator - | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN - ; + : Operator + | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN + ; qual_all_op - : all_op - | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN - ; + : all_op + | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN + ; subquery_Op - : all_op - | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN - | LIKE - | NOT LIKE - | ILIKE - | NOT ILIKE - ; + : all_op + | OPERATOR OPEN_PAREN any_operator CLOSE_PAREN + | LIKE + | NOT LIKE + | ILIKE + | NOT ILIKE + ; expr_list - : a_expr (COMMA a_expr)* - ; + : a_expr (COMMA a_expr)* + ; func_arg_list - : func_arg_expr (COMMA func_arg_expr)* - ; + : func_arg_expr (COMMA func_arg_expr)* + ; func_arg_expr - : a_expr - | param_name (COLON_EQUALS | EQUALS_GREATER) a_expr - ; + : a_expr + | param_name (COLON_EQUALS | EQUALS_GREATER) a_expr + ; type_list - : typename (COMMA typename)* - ; + : typename (COMMA typename)* + ; array_expr - : OPEN_BRACKET (expr_list | array_expr_list)? CLOSE_BRACKET - ; + : OPEN_BRACKET (expr_list | array_expr_list)? CLOSE_BRACKET + ; array_expr_list - : array_expr (COMMA array_expr)* - ; + : array_expr (COMMA array_expr)* + ; extract_list - : extract_arg FROM a_expr - | - ; + : extract_arg FROM a_expr + | + ; extract_arg - : identifier - | YEAR_P - | MONTH_P - | DAY_P - | HOUR_P - | MINUTE_P - | SECOND_P - | sconst - ; + : identifier + | YEAR_P + | MONTH_P + | DAY_P + | HOUR_P + | MINUTE_P + | SECOND_P + | sconst + ; unicode_normal_form - : NFC - | NFD - | NFKC - | NFKD - ; + : NFC + | NFD + | NFKC + | NFKD + ; overlay_list - : a_expr PLACING a_expr FROM a_expr (FOR a_expr)? - ; + : a_expr PLACING a_expr FROM a_expr (FOR a_expr)? + ; position_list - : b_expr IN_P b_expr - | - ; + : b_expr IN_P b_expr + | + ; substr_list - : a_expr FROM a_expr FOR a_expr - | a_expr FOR a_expr FROM a_expr - | a_expr FROM a_expr - | a_expr FOR a_expr - | a_expr SIMILAR a_expr ESCAPE a_expr - | expr_list - ; + : a_expr FROM a_expr FOR a_expr + | a_expr FOR a_expr FROM a_expr + | a_expr FROM a_expr + | a_expr FOR a_expr + | a_expr SIMILAR a_expr ESCAPE a_expr + | expr_list + ; trim_list - : a_expr FROM expr_list - | FROM expr_list - | expr_list - ; + : a_expr FROM expr_list + | FROM expr_list + | expr_list + ; in_expr - : select_with_parens # in_expr_select - | OPEN_PAREN expr_list CLOSE_PAREN # in_expr_list - ; + : select_with_parens # in_expr_select + | OPEN_PAREN expr_list CLOSE_PAREN # in_expr_list + ; case_expr - : CASE case_arg when_clause_list case_default END_P - ; + : CASE case_arg when_clause_list case_default END_P + ; when_clause_list - : when_clause+ - ; + : when_clause+ + ; when_clause - : WHEN a_expr THEN a_expr - ; + : WHEN a_expr THEN a_expr + ; case_default - : ELSE a_expr - | - ; + : ELSE a_expr + | + ; case_arg - : a_expr - | - ; + : a_expr + | + ; columnref - : colid indirection? - ; + : colid indirection? + ; indirection_el - : DOT (attr_name | STAR) - | OPEN_BRACKET (a_expr | opt_slice_bound COLON opt_slice_bound) CLOSE_BRACKET - ; + : DOT (attr_name | STAR) + | OPEN_BRACKET (a_expr | opt_slice_bound COLON opt_slice_bound) CLOSE_BRACKET + ; opt_slice_bound - : a_expr - | - ; + : a_expr + | + ; indirection - : indirection_el+ - ; + : indirection_el+ + ; opt_indirection - : indirection_el* - ; + : indirection_el* + ; opt_target_list - : target_list - | - ; + : target_list + | + ; target_list - : target_el (COMMA target_el)* - ; + : target_el (COMMA target_el)* + ; target_el - : a_expr (AS collabel | identifier |) # target_label - | STAR # target_star - ; + : a_expr (AS collabel | identifier |) # target_label + | STAR # target_star + ; qualified_name_list - : qualified_name (COMMA qualified_name)* - ; + : qualified_name (COMMA qualified_name)* + ; qualified_name - : colid indirection? - ; + : colid indirection? + ; name_list - : name (COMMA name)* - ; + : name (COMMA name)* + ; name - : colid - ; + : colid + ; attr_name - : collabel - ; + : collabel + ; file_name - : sconst - ; + : sconst + ; func_name - : builtin_function_name - | type_function_name - | colid indirection - | LEFT - | RIGHT - ; + : builtin_function_name + | type_function_name + | colid indirection + | LEFT + | RIGHT + ; aexprconst - : iconst - | fconst - | sconst - | bconst - | xconst - | func_name (sconst | OPEN_PAREN func_arg_list opt_sort_clause CLOSE_PAREN sconst) - | consttypename sconst - | constinterval (sconst opt_interval | OPEN_PAREN iconst CLOSE_PAREN sconst) - | TRUE_P - | FALSE_P - | NULL_P - ; + : iconst + | fconst + | sconst + | bconst + | xconst + | func_name (sconst | OPEN_PAREN func_arg_list opt_sort_clause CLOSE_PAREN sconst) + | consttypename sconst + | constinterval (sconst opt_interval | OPEN_PAREN iconst CLOSE_PAREN sconst) + | TRUE_P + | FALSE_P + | NULL_P + ; xconst - : HexadecimalStringConstant - ; + : HexadecimalStringConstant + ; bconst - : BinaryStringConstant - ; + : BinaryStringConstant + ; fconst - : Numeric - ; + : Numeric + ; iconst - : Integral - ; + : Integral + ; sconst - : anysconst opt_uescape - ; + : anysconst opt_uescape + ; anysconst - : StringConstant - | UnicodeEscapeStringConstant - | BeginDollarStringConstant DollarText* EndDollarStringConstant - | EscapeStringConstant - ; + : StringConstant + | UnicodeEscapeStringConstant + | BeginDollarStringConstant DollarText* EndDollarStringConstant + | EscapeStringConstant + ; opt_uescape - : UESCAPE anysconst - | - ; + : UESCAPE anysconst + | + ; signediconst - : iconst - | PLUS iconst - | MINUS iconst - ; + : iconst + | PLUS iconst + | MINUS iconst + ; roleid - : rolespec - ; + : rolespec + ; rolespec - : nonreservedword - | CURRENT_USER - | SESSION_USER - ; + : nonreservedword + | CURRENT_USER + | SESSION_USER + ; role_list - : rolespec (COMMA rolespec)* - ; + : rolespec (COMMA rolespec)* + ; colid - : identifier - | unreserved_keyword - | col_name_keyword - | plsql_unreserved_keyword - | LEFT - | RIGHT - ; + : identifier + | unreserved_keyword + | col_name_keyword + | plsql_unreserved_keyword + | LEFT + | RIGHT + ; table_alias - : identifier - | unreserved_keyword - | col_name_keyword - | plsql_unreserved_keyword - ; - + : identifier + | unreserved_keyword + | col_name_keyword + | plsql_unreserved_keyword + ; type_function_name - : identifier - | unreserved_keyword - | plsql_unreserved_keyword - | type_func_name_keyword - ; + : identifier + | unreserved_keyword + | plsql_unreserved_keyword + | type_func_name_keyword + ; nonreservedword - : identifier - | unreserved_keyword - | col_name_keyword - | type_func_name_keyword - ; + : identifier + | unreserved_keyword + | col_name_keyword + | type_func_name_keyword + ; collabel - : identifier - | plsql_unreserved_keyword - | unreserved_keyword - | col_name_keyword - | type_func_name_keyword - | reserved_keyword - ; + : identifier + | plsql_unreserved_keyword + | unreserved_keyword + | col_name_keyword + | type_func_name_keyword + | reserved_keyword + ; identifier - : Identifier opt_uescape - | QuotedIdentifier - | UnicodeQuotedIdentifier - | plsqlvariablename - | plsqlidentifier - | plsql_unreserved_keyword - ; + : Identifier opt_uescape + | QuotedIdentifier + | UnicodeQuotedIdentifier + | plsqlvariablename + | plsqlidentifier + | plsql_unreserved_keyword + ; plsqlidentifier - : PLSQLIDENTIFIER - ; + : PLSQLIDENTIFIER + ; unreserved_keyword - : ABORT_P - | ABSOLUTE_P - | ACCESS - | ACTION - | ADD_P - | ADMIN - | AFTER - | AGGREGATE - | ALSO - | ALTER - | ALWAYS - | ASSERTION - | ASSIGNMENT - | AT - | ATTACH - | ATTRIBUTE - | BACKWARD - | BEFORE - | BEGIN_P - | BY - | CACHE - | CALL - | CALLED - | CASCADE - | CASCADED - | CATALOG - | CHAIN - | CHARACTERISTICS - | CHECKPOINT - | CLASS - | CLOSE - | CLUSTER - | COLUMNS - | COMMENT - | COMMENTS - | COMMIT - | COMMITTED - | CONFIGURATION - | CONFLICT - | CONNECTION - | CONSTRAINTS - | CONTENT_P - | CONTINUE_P - | CONVERSION_P - | COPY - | COST - | CSV - | CUBE - | CURRENT_P - | CURSOR - | CYCLE - | DATA_P - | DATABASE - | DAY_P - | DEALLOCATE - | DECLARE - | DEFAULTS - | DEFERRED - | DEFINER - | DELETE_P - | DELIMITER - | DELIMITERS - | DEPENDS - | DETACH - | DICTIONARY - | DISABLE_P - | DISCARD - | DOCUMENT_P - | DOMAIN_P - | DOUBLE_P - | DROP - | EACH - | ENABLE_P - | ENCODING - | ENCRYPTED - | ENUM_P - | ESCAPE - | EVENT - | EXCLUDE - | EXCLUDING - | EXCLUSIVE - | EXECUTE - | EXPLAIN - | EXPRESSION - | EXTENSION - | EXTERNAL - | FAMILY - | FILTER - | FIRST_P - | FOLLOWING - | FORCE - | FORWARD - | FUNCTION - | FUNCTIONS - | GENERATED - | GLOBAL - | GRANTED - | GROUPS - | HANDLER - | HEADER_P - | HOLD - | HOUR_P - | IDENTITY_P - | IF_P - | IMMEDIATE - | IMMUTABLE - | IMPLICIT_P - | IMPORT_P - | INCLUDE - | INCLUDING - | INCREMENT - | INDEX - | INDEXES - | INHERIT - | INHERITS - | INLINE_P - | INPUT_P - | INSENSITIVE - | INSERT - | INSTEAD - | INVOKER - | ISOLATION - | KEY - | LABEL - | LANGUAGE - | LARGE_P - | LAST_P - | LEAKPROOF - | LEVEL - | LISTEN - | LOAD - | LOCAL - | LOCATION - | LOCK_P - | LOCKED - | LOGGED - | MAPPING - | MATCH - | MATERIALIZED - | MAXVALUE - | METHOD - | MINUTE_P - | MINVALUE - | MODE - | MONTH_P - | MOVE - | NAME_P - | NAMES - | NEW - | NEXT - | NFC - | NFD - | NFKC - | NFKD - | NO - | NORMALIZED - | NOTHING - | NOTIFY - | NOWAIT - | NULLS_P - | OBJECT_P - | OF - | OFF - | OIDS - | OLD - | OPERATOR - | OPTION - | OPTIONS - | ORDINALITY - | OTHERS - | OVER - | OVERRIDING - | OWNED - | OWNER - | PARALLEL - | PARSER - | PARTIAL - | PARTITION - | PASSING - | PASSWORD - | PLANS - | POLICY - | PRECEDING - | PREPARE - | PREPARED - | PRESERVE - | PRIOR - | PRIVILEGES - | PROCEDURAL - | PROCEDURE - | PROCEDURES - | PROGRAM - | PUBLICATION - | QUOTE - | RANGE - | READ - | REASSIGN - | RECHECK - | RECURSIVE - | REF - | REFERENCING - | REFRESH - | REINDEX - | RELATIVE_P - | RELEASE - | RENAME - | REPEATABLE - | REPLICA - | RESET - | RESTART - | RESTRICT - | RETURNS - | REVOKE - | ROLE - | ROLLBACK - | ROLLUP - | ROUTINE - | ROUTINES - | ROWS - | RULE - | SAVEPOINT - | SCHEMA - | SCHEMAS - | SCROLL - | SEARCH - | SECOND_P - | SECURITY - | SEQUENCE - | SEQUENCES - | SERIALIZABLE - | SERVER - | SESSION - | SET - | SETS - | SHARE - | SHOW - | SIMPLE - | SKIP_P - | SNAPSHOT - | SQL_P - | STABLE - | STANDALONE_P - | START - | STATEMENT - | STATISTICS - | STDIN - | STDOUT - | STORAGE - | STORED - | STRICT_P - | STRIP_P - | SUBSCRIPTION - | SUPPORT - | SYSID - | SYSTEM_P - | TABLES - | TABLESPACE - | TEMP - | TEMPLATE - | TEMPORARY - | TEXT_P - | TIES - | TRANSACTION - | TRANSFORM - | TRIGGER - | TRUNCATE - | TRUSTED - | TYPE_P - | TYPES_P - | UESCAPE - | UNBOUNDED - | UNCOMMITTED - | UNENCRYPTED - | UNKNOWN - | UNLISTEN - | UNLOGGED - | UNTIL - | UPDATE - | VACUUM - | VALID - | VALIDATE - | VALIDATOR - | VALUE_P - | VARYING - | VERSION_P - | VIEW - | VIEWS - | VOLATILE - | WHITESPACE_P - | WITHIN - | WITHOUT - | WORK - | WRAPPER - | WRITE - | XML_P - | YEAR_P - | YES_P - | ZONE - ; + : ABORT_P + | ABSOLUTE_P + | ACCESS + | ACTION + | ADD_P + | ADMIN + | AFTER + | AGGREGATE + | ALSO + | ALTER + | ALWAYS + | ASSERTION + | ASSIGNMENT + | AT + | ATTACH + | ATTRIBUTE + | BACKWARD + | BEFORE + | BEGIN_P + | BY + | CACHE + | CALL + | CALLED + | CASCADE + | CASCADED + | CATALOG + | CHAIN + | CHARACTERISTICS + | CHECKPOINT + | CLASS + | CLOSE + | CLUSTER + | COLUMNS + | COMMENT + | COMMENTS + | COMMIT + | COMMITTED + | CONFIGURATION + | CONFLICT + | CONNECTION + | CONSTRAINTS + | CONTENT_P + | CONTINUE_P + | CONVERSION_P + | COPY + | COST + | CSV + | CUBE + | CURRENT_P + | CURSOR + | CYCLE + | DATA_P + | DATABASE + | DAY_P + | DEALLOCATE + | DECLARE + | DEFAULTS + | DEFERRED + | DEFINER + | DELETE_P + | DELIMITER + | DELIMITERS + | DEPENDS + | DETACH + | DICTIONARY + | DISABLE_P + | DISCARD + | DOCUMENT_P + | DOMAIN_P + | DOUBLE_P + | DROP + | EACH + | ENABLE_P + | ENCODING + | ENCRYPTED + | ENUM_P + | ESCAPE + | EVENT + | EXCLUDE + | EXCLUDING + | EXCLUSIVE + | EXECUTE + | EXPLAIN + | EXPRESSION + | EXTENSION + | EXTERNAL + | FAMILY + | FILTER + | FIRST_P + | FOLLOWING + | FORCE + | FORWARD + | FUNCTION + | FUNCTIONS + | GENERATED + | GLOBAL + | GRANTED + | GROUPS + | HANDLER + | HEADER_P + | HOLD + | HOUR_P + | IDENTITY_P + | IF_P + | IMMEDIATE + | IMMUTABLE + | IMPLICIT_P + | IMPORT_P + | INCLUDE + | INCLUDING + | INCREMENT + | INDEX + | INDEXES + | INHERIT + | INHERITS + | INLINE_P + | INPUT_P + | INSENSITIVE + | INSERT + | INSTEAD + | INVOKER + | ISOLATION + | KEY + | LABEL + | LANGUAGE + | LARGE_P + | LAST_P + | LEAKPROOF + | LEVEL + | LISTEN + | LOAD + | LOCAL + | LOCATION + | LOCK_P + | LOCKED + | LOGGED + | MAPPING + | MATCH + | MATERIALIZED + | MAXVALUE + | METHOD + | MINUTE_P + | MINVALUE + | MODE + | MONTH_P + | MOVE + | NAME_P + | NAMES + | NEW + | NEXT + | NFC + | NFD + | NFKC + | NFKD + | NO + | NORMALIZED + | NOTHING + | NOTIFY + | NOWAIT + | NULLS_P + | OBJECT_P + | OF + | OFF + | OIDS + | OLD + | OPERATOR + | OPTION + | OPTIONS + | ORDINALITY + | OTHERS + | OVER + | OVERRIDING + | OWNED + | OWNER + | PARALLEL + | PARSER + | PARTIAL + | PARTITION + | PASSING + | PASSWORD + | PLANS + | POLICY + | PRECEDING + | PREPARE + | PREPARED + | PRESERVE + | PRIOR + | PRIVILEGES + | PROCEDURAL + | PROCEDURE + | PROCEDURES + | PROGRAM + | PUBLICATION + | QUOTE + | RANGE + | READ + | REASSIGN + | RECHECK + | RECURSIVE + | REF + | REFERENCING + | REFRESH + | REINDEX + | RELATIVE_P + | RELEASE + | RENAME + | REPEATABLE + | REPLICA + | RESET + | RESTART + | RESTRICT + | RETURNS + | REVOKE + | ROLE + | ROLLBACK + | ROLLUP + | ROUTINE + | ROUTINES + | ROWS + | RULE + | SAVEPOINT + | SCHEMA + | SCHEMAS + | SCROLL + | SEARCH + | SECOND_P + | SECURITY + | SEQUENCE + | SEQUENCES + | SERIALIZABLE + | SERVER + | SESSION + | SET + | SETS + | SHARE + | SHOW + | SIMPLE + | SKIP_P + | SNAPSHOT + | SQL_P + | STABLE + | STANDALONE_P + | START + | STATEMENT + | STATISTICS + | STDIN + | STDOUT + | STORAGE + | STORED + | STRICT_P + | STRIP_P + | SUBSCRIPTION + | SUPPORT + | SYSID + | SYSTEM_P + | TABLES + | TABLESPACE + | TEMP + | TEMPLATE + | TEMPORARY + | TEXT_P + | TIES + | TRANSACTION + | TRANSFORM + | TRIGGER + | TRUNCATE + | TRUSTED + | TYPE_P + | TYPES_P + | UESCAPE + | UNBOUNDED + | UNCOMMITTED + | UNENCRYPTED + | UNKNOWN + | UNLISTEN + | UNLOGGED + | UNTIL + | UPDATE + | VACUUM + | VALID + | VALIDATE + | VALIDATOR + | VALUE_P + | VARYING + | VERSION_P + | VIEW + | VIEWS + | VOLATILE + | WHITESPACE_P + | WITHIN + | WITHOUT + | WORK + | WRAPPER + | WRITE + | XML_P + | YEAR_P + | YES_P + | ZONE + ; col_name_keyword - : BETWEEN - | BIGINT - | bit - | BOOLEAN_P - | CHAR_P - | character - | COALESCE - | DEC - | DECIMAL_P - | EXISTS - | EXTRACT - | FLOAT_P - | GREATEST - | GROUPING - | INOUT - | INT_P - | INTEGER - | INTERVAL - | LEAST - | NATIONAL - | NCHAR - | NONE - | NORMALIZE - | NULLIF - | numeric - | OUT_P - | OVERLAY - | POSITION - | PRECISION - | REAL - | ROW - | SETOF - | SMALLINT - | SUBSTRING - | TIME - | TIMESTAMP - | TREAT - | TRIM - | VALUES - | VARCHAR - | XMLATTRIBUTES - | XMLCONCAT - | XMLELEMENT - | XMLEXISTS - | XMLFOREST - | XMLNAMESPACES - | XMLPARSE - | XMLPI - | XMLROOT - | XMLSERIALIZE - | XMLTABLE - | builtin_function_name - ; + : BETWEEN + | BIGINT + | bit + | BOOLEAN_P + | CHAR_P + | character + | COALESCE + | DEC + | DECIMAL_P + | EXISTS + | EXTRACT + | FLOAT_P + | GREATEST + | GROUPING + | INOUT + | INT_P + | INTEGER + | INTERVAL + | LEAST + | NATIONAL + | NCHAR + | NONE + | NORMALIZE + | NULLIF + | numeric + | OUT_P + | OVERLAY + | POSITION + | PRECISION + | REAL + | ROW + | SETOF + | SMALLINT + | SUBSTRING + | TIME + | TIMESTAMP + | TREAT + | TRIM + | VALUES + | VARCHAR + | XMLATTRIBUTES + | XMLCONCAT + | XMLELEMENT + | XMLEXISTS + | XMLFOREST + | XMLNAMESPACES + | XMLPARSE + | XMLPI + | XMLROOT + | XMLSERIALIZE + | XMLTABLE + | builtin_function_name + ; type_func_name_keyword - : AUTHORIZATION - | BINARY - | COLLATION - | CONCURRENTLY - | CROSS - | CURRENT_SCHEMA - | FREEZE - | FULL - | ILIKE - | INNER_P - | IS - | ISNULL - | JOIN - | LIKE - | NATURAL - | NOTNULL - | OUTER_P - | OVERLAPS - | SIMILAR - | TABLESAMPLE - | VERBOSE - ; + : AUTHORIZATION + | BINARY + | COLLATION + | CONCURRENTLY + | CROSS + | CURRENT_SCHEMA + | FREEZE + | FULL + | ILIKE + | INNER_P + | IS + | ISNULL + | JOIN + | LIKE + | NATURAL + | NOTNULL + | OUTER_P + | OVERLAPS + | SIMILAR + | TABLESAMPLE + | VERBOSE + ; reserved_keyword - : ALL - | ANALYSE - | ANALYZE - | AND - | ANY - | ARRAY - | AS - | ASC - | ASYMMETRIC - | BOTH - | CASE - | CAST - | CHECK - | COLLATE - | COLUMN - | CONSTRAINT - | CREATE - | CURRENT_CATALOG - | CURRENT_DATE - | CURRENT_ROLE - | CURRENT_TIME - | CURRENT_TIMESTAMP - | CURRENT_USER - // | DEFAULT - | DEFERRABLE - | DESC - | DISTINCT - | DO - | ELSE - | END_P - | EXCEPT - | FALSE_P - | FETCH - | FOR - | FOREIGN - | FROM - | GRANT - | GROUP_P - | HAVING - | IN_P - | INITIALLY - | INTERSECT -/* + : ALL + | ANALYSE + | ANALYZE + | AND + | ANY + | ARRAY + | AS + | ASC + | ASYMMETRIC + | BOTH + | CASE + | CAST + | CHECK + | COLLATE + | COLUMN + | CONSTRAINT + | CREATE + | CURRENT_CATALOG + | CURRENT_DATE + | CURRENT_ROLE + | CURRENT_TIME + | CURRENT_TIMESTAMP + | CURRENT_USER + // | DEFAULT + | DEFERRABLE + | DESC + | DISTINCT + | DO + | ELSE + | END_P + | EXCEPT + | FALSE_P + | FETCH + | FOR + | FOREIGN + | FROM + | GRANT + | GROUP_P + | HAVING + | IN_P + | INITIALLY + | INTERSECT + /* from pl_gram.y, line ~2982 * Fortunately, INTO is a fully reserved word in the main grammar, so * at least we need not worry about it appearing as an identifier. */ - - // | INTO - | LATERAL_P - | LEADING - | LIMIT - | LOCALTIME - | LOCALTIMESTAMP - | NOT - | NULL_P - | OFFSET - | ON - | ONLY - | OR - | ORDER - | PLACING - | PRIMARY - | REFERENCES - | RETURNING - | SELECT - | SESSION_USER - | SOME - | SYMMETRIC - | TABLE - | THEN - | TO - | TRAILING - | TRUE_P - | UNION - | UNIQUE - | USER - | USING - | VARIADIC - | WHEN - | WHERE - | WINDOW - | WITH - ; + // | INTO + | LATERAL_P + | LEADING + | LIMIT + | LOCALTIME + | LOCALTIMESTAMP + | NOT + | NULL_P + | OFFSET + | ON + | ONLY + | OR + | ORDER + | PLACING + | PRIMARY + | REFERENCES + | RETURNING + | SELECT + | SESSION_USER + | SOME + | SYMMETRIC + | TABLE + | THEN + | TO + | TRAILING + | TRUE_P + | UNION + | UNIQUE + | USER + | USING + | VARIADIC + | WHEN + | WHERE + | WINDOW + | WITH + ; builtin_function_name - : XMLCOMMENT - | XML_IS_WELL_FORMED - | XML_IS_WELL_FORMED_DOCUMENT - | XML_IS_WELL_FORMED_CONTENT - | XMLAGG - | XPATH - | XPATH_EXISTS - | ABS - | CBRT - | CEIL - | CEILING - | DEGREES - | DIV - | EXP - | FACTORIAL - | FLOOR - | GCD - | LCM - | LN - | LOG - | LOG10 - | MIN_SCALE - | MOD - | PI - | POWER - | RADIANS - | ROUND - | SCALE - | SIGN - | SQRT - | TRIM_SCALE - | TRUNC - | WIDTH_BUCKET - | RANDOM - | SETSEED - | ACOS - | ACOSD - | ACOSH - | ASIN - | ASIND - | ASINH - | ATAN - | ATAND - | ATANH - | ATAN2 - | ATAN2D - | COS - | COSD - | COSH - | COT - | COTD - | SIN - | SIND - | SINH - | TAN - | TAND - | TANH - | BIT_LENGTH - | CHAR_LENGTH - | CHARACTER_LENGTH - | LOWER - | OCTET_LENGTH - | OCTET_LENGTH - | UPPER - | ASCII - | BTRIM - | CHR - | CONCAT - | CONCAT_WS - | FORMAT - | INITCAP - | LENGTH - | LPAD - | LTRIM - | MD5 - | PARSE_IDENT - | PG_CLIENT_ENCODING - | QUOTE_IDENT - | QUOTE_LITERAL - | QUOTE_NULLABLE - | REGEXP_COUNT - | REGEXP_INSTR - | REGEXP_LIKE - | REGEXP_MATCH - | REGEXP_MATCHES - | REGEXP_REPLACE - | REGEXP_SPLIT_TO_ARRAY - | REGEXP_SPLIT_TO_TABLE - | REGEXP_SUBSTR - | REPEAT - | REPLACE - | REVERSE - | RPAD - | RTRIM - | SPLIT_PART - | STARTS_WITH - | STRING_TO_ARRAY - | STRING_TO_TABLE - | STRPOS - | SUBSTR - | TO_ASCII - | TO_HEX - | TRANSLATE - | UNISTR - | AGE - | DATE_BIN - | DATE_PART - | DATE_TRUNC - | ISFINITE - | JUSTIFY_DAYS - | JUSTIFY_HOURS - | JUSTIFY_INTERVAL - | MAKE_DATE - | MAKE_INTERVAL - | MAKE_TIME - | MAKE_TIMESTAMP - | MAKE_TIMESTAMPTZ - | CLOCK_TIMESTAMP - | NOW - | STATEMENT_TIMESTAMP - | TIMEOFDAY - | TRANSACTION_TIMESTAMP - | TO_TIMESTAMP - | JUSTIFY_INTERVAL - | JUSTIFY_INTERVAL - | TO_CHAR - | TO_DATE - | TO_NUMBER - ; + : XMLCOMMENT + | XML_IS_WELL_FORMED + | XML_IS_WELL_FORMED_DOCUMENT + | XML_IS_WELL_FORMED_CONTENT + | XMLAGG + | XPATH + | XPATH_EXISTS + | ABS + | CBRT + | CEIL + | CEILING + | DEGREES + | DIV + | EXP + | FACTORIAL + | FLOOR + | GCD + | LCM + | LN + | LOG + | LOG10 + | MIN_SCALE + | MOD + | PI + | POWER + | RADIANS + | ROUND + | SCALE + | SIGN + | SQRT + | TRIM_SCALE + | TRUNC + | WIDTH_BUCKET + | RANDOM + | SETSEED + | ACOS + | ACOSD + | ACOSH + | ASIN + | ASIND + | ASINH + | ATAN + | ATAND + | ATANH + | ATAN2 + | ATAN2D + | COS + | COSD + | COSH + | COT + | COTD + | SIN + | SIND + | SINH + | TAN + | TAND + | TANH + | BIT_LENGTH + | CHAR_LENGTH + | CHARACTER_LENGTH + | LOWER + | OCTET_LENGTH + | OCTET_LENGTH + | UPPER + | ASCII + | BTRIM + | CHR + | CONCAT + | CONCAT_WS + | FORMAT + | INITCAP + | LENGTH + | LPAD + | LTRIM + | MD5 + | PARSE_IDENT + | PG_CLIENT_ENCODING + | QUOTE_IDENT + | QUOTE_LITERAL + | QUOTE_NULLABLE + | REGEXP_COUNT + | REGEXP_INSTR + | REGEXP_LIKE + | REGEXP_MATCH + | REGEXP_MATCHES + | REGEXP_REPLACE + | REGEXP_SPLIT_TO_ARRAY + | REGEXP_SPLIT_TO_TABLE + | REGEXP_SUBSTR + | REPEAT + | REPLACE + | REVERSE + | RPAD + | RTRIM + | SPLIT_PART + | STARTS_WITH + | STRING_TO_ARRAY + | STRING_TO_TABLE + | STRPOS + | SUBSTR + | TO_ASCII + | TO_HEX + | TRANSLATE + | UNISTR + | AGE + | DATE_BIN + | DATE_PART + | DATE_TRUNC + | ISFINITE + | JUSTIFY_DAYS + | JUSTIFY_HOURS + | JUSTIFY_INTERVAL + | MAKE_DATE + | MAKE_INTERVAL + | MAKE_TIME + | MAKE_TIMESTAMP + | MAKE_TIMESTAMPTZ + | CLOCK_TIMESTAMP + | NOW + | STATEMENT_TIMESTAMP + | TIMEOFDAY + | TRANSACTION_TIMESTAMP + | TO_TIMESTAMP + | JUSTIFY_INTERVAL + | JUSTIFY_INTERVAL + | TO_CHAR + | TO_DATE + | TO_NUMBER + ; /************************************************************************************************************************************************************/ /*PL/SQL GRAMMAR */ - /*PLSQL grammar */ - /************************************************************************************************************************************************************/ pl_function - : comp_options pl_block opt_semi - ; +/************************************************************************************************************************************************************/ +pl_function + : comp_options pl_block opt_semi + ; comp_options - : comp_option* - ; + : comp_option* + ; comp_option - : sharp OPTION DUMP - | sharp PRINT_STRICT_PARAMS option_value - | sharp VARIABLE_CONFLICT ERROR - | sharp VARIABLE_CONFLICT USE_VARIABLE - | sharp VARIABLE_CONFLICT USE_COLUMN - ; + : sharp OPTION DUMP + | sharp PRINT_STRICT_PARAMS option_value + | sharp VARIABLE_CONFLICT ERROR + | sharp VARIABLE_CONFLICT USE_VARIABLE + | sharp VARIABLE_CONFLICT USE_COLUMN + ; sharp - : Operator - ; + : Operator + ; option_value - : sconst - | reserved_keyword - | plsql_unreserved_keyword - | unreserved_keyword - ; + : sconst + | reserved_keyword + | plsql_unreserved_keyword + | unreserved_keyword + ; opt_semi - : - | SEMI - ; - // exception_sect means opt_exception_sect in original grammar, don't be confused! + : + | SEMI + ; + +// exception_sect means opt_exception_sect in original grammar, don't be confused! pl_block - : decl_sect BEGIN_P proc_sect exception_sect END_P opt_label - ; + : decl_sect BEGIN_P proc_sect exception_sect END_P opt_label + ; decl_sect - : opt_block_label (decl_start decl_stmts?)? - ; + : opt_block_label (decl_start decl_stmts?)? + ; decl_start - : DECLARE - ; + : DECLARE + ; decl_stmts - : decl_stmt+ - ; + : decl_stmt+ + ; label_decl - : LESS_LESS any_identifier GREATER_GREATER - ; + : LESS_LESS any_identifier GREATER_GREATER + ; decl_stmt - : decl_statement - | DECLARE - | label_decl - ; + : decl_statement + | DECLARE + | label_decl + ; decl_statement - : decl_varname - ( - ALIAS FOR decl_aliasitem + : decl_varname ( + ALIAS FOR decl_aliasitem | decl_const decl_datatype decl_collate decl_notnull decl_defval | opt_scrollable CURSOR decl_cursor_args decl_is_for decl_cursor_query - ) SEMI - ; + ) SEMI + ; opt_scrollable - : - | NO SCROLL - | SCROLL - ; + : + | NO SCROLL + | SCROLL + ; decl_cursor_query - : selectstmt - ; + : selectstmt + ; decl_cursor_args - : - | OPEN_PAREN decl_cursor_arglist CLOSE_PAREN - ; + : + | OPEN_PAREN decl_cursor_arglist CLOSE_PAREN + ; decl_cursor_arglist - : decl_cursor_arg (COMMA decl_cursor_arg)* - ; + : decl_cursor_arg (COMMA decl_cursor_arg)* + ; decl_cursor_arg - : decl_varname decl_datatype - ; + : decl_varname decl_datatype + ; decl_is_for - : IS - | FOR - ; + : IS + | FOR + ; decl_aliasitem - : PARAM - | colid - ; + : PARAM + | colid + ; decl_varname - : any_identifier - ; + : any_identifier + ; decl_const - : - | CONSTANT - ; + : + | CONSTANT + ; decl_datatype - : typename - ; //TODO: $$ = read_datatype(yychar); + : typename + ; //TODO: $$ = read_datatype(yychar); decl_collate - : - | COLLATE any_name - ; + : + | COLLATE any_name + ; decl_notnull - : - | NOT NULL_P - ; + : + | NOT NULL_P + ; decl_defval - : - | decl_defkey sql_expression - ; + : + | decl_defkey sql_expression + ; decl_defkey - : assign_operator - | DEFAULT - ; + : assign_operator + | DEFAULT + ; assign_operator - : EQUAL - | COLON_EQUALS - ; + : EQUAL + | COLON_EQUALS + ; proc_sect - : proc_stmt* - ; + : proc_stmt* + ; proc_stmt - : pl_block SEMI - | stmt_return - | stmt_raise - | stmt_assign - | stmt_if - | stmt_case - | stmt_loop - | stmt_while - | stmt_for - | stmt_foreach_a - | stmt_exit - | stmt_assert - | stmt_execsql - | stmt_dynexecute - | stmt_perform - | stmt_call - | stmt_getdiag - | stmt_open - | stmt_fetch - | stmt_move - | stmt_close - | stmt_null - | stmt_commit - | stmt_rollback - | stmt_set - ; + : pl_block SEMI + | stmt_return + | stmt_raise + | stmt_assign + | stmt_if + | stmt_case + | stmt_loop + | stmt_while + | stmt_for + | stmt_foreach_a + | stmt_exit + | stmt_assert + | stmt_execsql + | stmt_dynexecute + | stmt_perform + | stmt_call + | stmt_getdiag + | stmt_open + | stmt_fetch + | stmt_move + | stmt_close + | stmt_null + | stmt_commit + | stmt_rollback + | stmt_set + ; stmt_perform - : PERFORM expr_until_semi SEMI - ; + : PERFORM expr_until_semi SEMI + ; stmt_call - : CALL any_identifier OPEN_PAREN opt_expr_list CLOSE_PAREN SEMI - | DO any_identifier OPEN_PAREN opt_expr_list CLOSE_PAREN SEMI - ; + : CALL any_identifier OPEN_PAREN opt_expr_list CLOSE_PAREN SEMI + | DO any_identifier OPEN_PAREN opt_expr_list CLOSE_PAREN SEMI + ; opt_expr_list - : - | expr_list - ; + : + | expr_list + ; stmt_assign - : assign_var assign_operator sql_expression SEMI - ; + : assign_var assign_operator sql_expression SEMI + ; stmt_getdiag - : GET getdiag_area_opt DIAGNOSTICS getdiag_list SEMI - ; + : GET getdiag_area_opt DIAGNOSTICS getdiag_list SEMI + ; getdiag_area_opt - : - | CURRENT_P - | STACKED - ; + : + | CURRENT_P + | STACKED + ; getdiag_list - : getdiag_list_item (COMMA getdiag_list_item)* - ; + : getdiag_list_item (COMMA getdiag_list_item)* + ; getdiag_list_item - : getdiag_target assign_operator getdiag_item - ; + : getdiag_target assign_operator getdiag_item + ; getdiag_item - : colid - ; + : colid + ; getdiag_target - : assign_var - ; + : assign_var + ; assign_var - : (any_name | PARAM) (OPEN_BRACKET expr_until_rightbracket CLOSE_BRACKET)* - ; + : (any_name | PARAM) (OPEN_BRACKET expr_until_rightbracket CLOSE_BRACKET)* + ; stmt_if - : IF_P expr_until_then THEN proc_sect stmt_elsifs stmt_else END_P IF_P SEMI - ; + : IF_P expr_until_then THEN proc_sect stmt_elsifs stmt_else END_P IF_P SEMI + ; stmt_elsifs - : (ELSIF a_expr THEN proc_sect)* - ; + : (ELSIF a_expr THEN proc_sect)* + ; stmt_else - : - | ELSE proc_sect - ; + : + | ELSE proc_sect + ; stmt_case - : CASE opt_expr_until_when case_when_list opt_case_else END_P CASE SEMI - ; + : CASE opt_expr_until_when case_when_list opt_case_else END_P CASE SEMI + ; opt_expr_until_when - : - | sql_expression - ; + : + | sql_expression + ; case_when_list - : case_when+ - ; + : case_when+ + ; case_when - : WHEN expr_list THEN proc_sect - ; + : WHEN expr_list THEN proc_sect + ; opt_case_else - : - | ELSE proc_sect - ; + : + | ELSE proc_sect + ; stmt_loop - : opt_loop_label loop_body - ; + : opt_loop_label loop_body + ; stmt_while - : opt_loop_label WHILE expr_until_loop loop_body - ; + : opt_loop_label WHILE expr_until_loop loop_body + ; stmt_for - : opt_loop_label FOR for_control loop_body - ; - //TODO: rewrite using read_sql_expression logic? + : opt_loop_label FOR for_control loop_body + ; + +//TODO: rewrite using read_sql_expression logic? for_control - : for_variable IN_P - ( - cursor_name opt_cursor_parameters + : for_variable IN_P ( + cursor_name opt_cursor_parameters | selectstmt | explainstmt | EXECUTE a_expr opt_for_using_expression | opt_reverse a_expr DOT_DOT a_expr opt_by_expression - ) - ; + ) + ; opt_for_using_expression - : - | USING expr_list - ; + : + | USING expr_list + ; opt_cursor_parameters - : - | OPEN_PAREN a_expr (COMMA a_expr)* CLOSE_PAREN - ; + : + | OPEN_PAREN a_expr (COMMA a_expr)* CLOSE_PAREN + ; opt_reverse - : - | REVERSE - ; + : + | REVERSE + ; opt_by_expression - : - | BY a_expr - ; + : + | BY a_expr + ; for_variable - : any_name_list - ; + : any_name_list + ; stmt_foreach_a - : opt_loop_label FOREACH for_variable foreach_slice IN_P ARRAY a_expr loop_body - ; + : opt_loop_label FOREACH for_variable foreach_slice IN_P ARRAY a_expr loop_body + ; foreach_slice - : - | SLICE iconst - ; + : + | SLICE iconst + ; stmt_exit - : exit_type opt_label opt_exitcond SEMI - ; + : exit_type opt_label opt_exitcond SEMI + ; exit_type - : EXIT - | CONTINUE_P - ; - //todo implement RETURN statement according to initial grammar line 1754 + : EXIT + | CONTINUE_P + ; + +//todo implement RETURN statement according to initial grammar line 1754 stmt_return - : RETURN (NEXT sql_expression | QUERY (EXECUTE a_expr opt_for_using_expression | selectstmt) | opt_return_result) SEMI - ; + : RETURN ( + NEXT sql_expression + | QUERY (EXECUTE a_expr opt_for_using_expression | selectstmt) + | opt_return_result + ) SEMI + ; opt_return_result - : - | sql_expression - ; - //https://www.postgresql.org/docs/current/plpgsql-errors-and-messages.html + : + | sql_expression + ; + +//https://www.postgresql.org/docs/current/plpgsql-errors-and-messages.html - //RAISE [ level ] 'format' [, expression [, ... ]] [ USING option = expression [, ... ] ]; +//RAISE [ level ] 'format' [, expression [, ... ]] [ USING option = expression [, ... ] ]; - //RAISE [ level ] condition_name [ USING option = expression [, ... ] ]; +//RAISE [ level ] condition_name [ USING option = expression [, ... ] ]; - //RAISE [ level ] SQLSTATE 'sqlstate' [ USING option = expression [, ... ] ]; +//RAISE [ level ] SQLSTATE 'sqlstate' [ USING option = expression [, ... ] ]; - //RAISE [ level ] USING option = expression [, ... ]; +//RAISE [ level ] USING option = expression [, ... ]; - //RAISE ; +//RAISE ; stmt_raise - : RAISE opt_stmt_raise_level sconst opt_raise_list opt_raise_using SEMI - | RAISE opt_stmt_raise_level identifier opt_raise_using SEMI - | RAISE opt_stmt_raise_level SQLSTATE sconst opt_raise_using SEMI - | RAISE opt_stmt_raise_level opt_raise_using SEMI - | RAISE - ; + : RAISE opt_stmt_raise_level sconst opt_raise_list opt_raise_using SEMI + | RAISE opt_stmt_raise_level identifier opt_raise_using SEMI + | RAISE opt_stmt_raise_level SQLSTATE sconst opt_raise_using SEMI + | RAISE opt_stmt_raise_level opt_raise_using SEMI + | RAISE + ; opt_stmt_raise_level - : - | - | DEBUG - | LOG - | INFO - | NOTICE - | WARNING - | EXCEPTION - ; + : + | + | DEBUG + | LOG + | INFO + | NOTICE + | WARNING + | EXCEPTION + ; opt_raise_list - : - | (COMMA a_expr)+ - ; + : + | (COMMA a_expr)+ + ; opt_raise_using - : - | USING opt_raise_using_elem_list - ; + : + | USING opt_raise_using_elem_list + ; opt_raise_using_elem - : identifier EQUAL a_expr - ; + : identifier EQUAL a_expr + ; opt_raise_using_elem_list - : opt_raise_using_elem (COMMA opt_raise_using_elem)* - ; - //todo imnplement + : opt_raise_using_elem (COMMA opt_raise_using_elem)* + ; + +//todo imnplement stmt_assert - : ASSERT sql_expression opt_stmt_assert_message SEMI - ; + : ASSERT sql_expression opt_stmt_assert_message SEMI + ; opt_stmt_assert_message - : - | COMMA sql_expression - ; + : + | COMMA sql_expression + ; loop_body - : LOOP proc_sect END_P LOOP opt_label SEMI - ; - //TODO: looks like all other statements like INSERT/SELECT/UPDATE/DELETE are handled here; + : LOOP proc_sect END_P LOOP opt_label SEMI + ; - //pls take a look at original grammar +//TODO: looks like all other statements like INSERT/SELECT/UPDATE/DELETE are handled here; + +//pls take a look at original grammar stmt_execsql - : make_execsql_stmt SEMI -/*K_IMPORT + : make_execsql_stmt SEMI + /*K_IMPORT | K_INSERT | t_word | t_cword */ + ; +//https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-NORESULT - ; - //https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-NORESULT - - //EXECUTE command-string [ INTO [STRICT] target ] [ USING expression [, ... ] ]; +//EXECUTE command-string [ INTO [STRICT] target ] [ USING expression [, ... ] ]; stmt_dynexecute - : EXECUTE a_expr ( -/*this is silly, but i have to time to find nice way to code */ - - opt_execute_into opt_execute_using | opt_execute_using opt_execute_into |) SEMI - ; + : EXECUTE a_expr ( + /*this is silly, but i have to time to find nice way to code */ opt_execute_into opt_execute_using + | opt_execute_using opt_execute_into + | + ) SEMI + ; opt_execute_using - : - | USING opt_execute_using_list - ; + : + | USING opt_execute_using_list + ; opt_execute_using_list - : a_expr (COMMA a_expr)* - ; + : a_expr (COMMA a_expr)* + ; opt_execute_into - : - | INTO STRICT_P? into_target - ; - //https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING + : + | INTO STRICT_P? into_target + ; + +//https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING - //OPEN unbound_cursorvar [ [ NO ] SCROLL ] FOR query; +//OPEN unbound_cursorvar [ [ NO ] SCROLL ] FOR query; - //OPEN unbound_cursorvar [ [ NO ] SCROLL ] FOR EXECUTE query_string +//OPEN unbound_cursorvar [ [ NO ] SCROLL ] FOR EXECUTE query_string - // [ USING expression [, ... ] ]; +// [ USING expression [, ... ] ]; - //OPEN bound_cursorvar [ ( [ argument_name := ] argument_value [, ...] ) ]; +//OPEN bound_cursorvar [ ( [ argument_name := ] argument_value [, ...] ) ]; stmt_open - : OPEN - ( - cursor_variable opt_scroll_option FOR (selectstmt | EXECUTE sql_expression opt_open_using) + : OPEN ( + cursor_variable opt_scroll_option FOR (selectstmt | EXECUTE sql_expression opt_open_using) | colid (OPEN_PAREN opt_open_bound_list CLOSE_PAREN)? - ) SEMI - ; + ) SEMI + ; opt_open_bound_list_item - : colid COLON_EQUALS a_expr - | a_expr - ; + : colid COLON_EQUALS a_expr + | a_expr + ; opt_open_bound_list - : opt_open_bound_list_item (COMMA opt_open_bound_list_item)* - ; + : opt_open_bound_list_item (COMMA opt_open_bound_list_item)* + ; opt_open_using - : - | USING expr_list - ; + : + | USING expr_list + ; opt_scroll_option - : - | opt_scroll_option_no SCROLL - ; + : + | opt_scroll_option_no SCROLL + ; opt_scroll_option_no - : - | NO - ; - //https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING + : + | NO + ; - //FETCH [ direction { FROM | IN } ] cursor INTO target; +//https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING + +//FETCH [ direction { FROM | IN } ] cursor INTO target; stmt_fetch - : FETCH direction = opt_fetch_direction opt_cursor_from cursor_variable INTO into_target SEMI - ; + : FETCH direction = opt_fetch_direction opt_cursor_from cursor_variable INTO into_target SEMI + ; into_target - : expr_list - ; + : expr_list + ; opt_cursor_from - : - | FROM - | IN_P - ; + : + | FROM + | IN_P + ; opt_fetch_direction - : - | - | NEXT - | PRIOR - | FIRST_P - | LAST_P - | ABSOLUTE_P a_expr - | RELATIVE_P a_expr - | a_expr - | ALL - | (FORWARD | BACKWARD) (a_expr | ALL)? - ; - //https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING - - //MOVE [ direction { FROM | IN } ] cursor; + : + | + | NEXT + | PRIOR + | FIRST_P + | LAST_P + | ABSOLUTE_P a_expr + | RELATIVE_P a_expr + | a_expr + | ALL + | (FORWARD | BACKWARD) (a_expr | ALL)? + ; + +//https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING + +//MOVE [ direction { FROM | IN } ] cursor; stmt_move - : MOVE opt_fetch_direction cursor_variable SEMI - ; + : MOVE opt_fetch_direction cursor_variable SEMI + ; stmt_close - : CLOSE cursor_variable SEMI - ; + : CLOSE cursor_variable SEMI + ; stmt_null - : NULL_P SEMI - ; + : NULL_P SEMI + ; stmt_commit - : COMMIT plsql_opt_transaction_chain SEMI - ; + : COMMIT plsql_opt_transaction_chain SEMI + ; stmt_rollback - : ROLLBACK plsql_opt_transaction_chain SEMI - ; + : ROLLBACK plsql_opt_transaction_chain SEMI + ; plsql_opt_transaction_chain - : AND NO? CHAIN - | - ; + : AND NO? CHAIN + | + ; stmt_set - : SET any_name TO DEFAULT SEMI - | RESET (any_name | ALL) SEMI - ; + : SET any_name TO DEFAULT SEMI + | RESET (any_name | ALL) SEMI + ; cursor_variable - : colid - | PARAM - ; + : colid + | PARAM + ; exception_sect - : - | EXCEPTION proc_exceptions - ; + : + | EXCEPTION proc_exceptions + ; proc_exceptions - : proc_exception+ - ; + : proc_exception+ + ; proc_exception - : WHEN proc_conditions THEN proc_sect - ; + : WHEN proc_conditions THEN proc_sect + ; proc_conditions - : proc_condition (OR proc_condition)* - ; + : proc_condition (OR proc_condition)* + ; proc_condition - : any_identifier - | SQLSTATE sconst - ; - //expr_until_semi: + : any_identifier + | SQLSTATE sconst + ; + +//expr_until_semi: - //; +//; - //expr_until_rightbracket: +//expr_until_rightbracket: - //; +//; - //expr_until_loop: +//expr_until_loop: - //; +//; opt_block_label - : - | label_decl - ; + : + | label_decl + ; opt_loop_label - : - | label_decl - ; + : + | label_decl + ; opt_label - : - | any_identifier - ; + : + | any_identifier + ; opt_exitcond - : WHEN expr_until_semi - | - ; + : WHEN expr_until_semi + | + ; any_identifier - : colid - | plsql_unreserved_keyword - ; + : colid + | plsql_unreserved_keyword + ; plsql_unreserved_keyword - : ABSOLUTE_P - | ALIAS - | AND - | ARRAY - | ASSERT - | BACKWARD - | CALL - | CHAIN - | CLOSE - | COLLATE - | COLUMN - //| COLUMN_NAME - | COMMIT - | CONSTANT - | CONSTRAINT - //| CONSTRAINT_NAME - | CONTINUE_P - | CURRENT_P - | CURSOR - //| DATATYPE - | DEBUG - | DEFAULT - //| DETAIL - | DIAGNOSTICS - | DO - | DUMP - | ELSIF - //| ERRCODE - | ERROR - | EXCEPTION - | EXIT - | FETCH - | FIRST_P - | FORWARD - | GET - //| HINT - - //| IMPORT - | INFO - | INSERT - | IS - | LAST_P - //| MESSAGE - - //| MESSAGE_TEXT - | MOVE - | NEXT - | NO - | NOTICE - | OPEN - | OPTION - | PERFORM - //| PG_CONTEXT - - //| PG_DATATYPE_NAME - - //| PG_EXCEPTION_CONTEXT - - //| PG_EXCEPTION_DETAIL - - //| PG_EXCEPTION_HINT - | PRINT_STRICT_PARAMS - | PRIOR - | QUERY - | RAISE - | RELATIVE_P - | RESET - | RETURN - //| RETURNED_SQLSTATE - | ROLLBACK - //| ROW_COUNT - | ROWTYPE - | SCHEMA - //| SCHEMA_NAME - | SCROLL - | SET - | SLICE - | SQLSTATE - | STACKED - | TABLE - //| TABLE_NAME - | TYPE_P - | USE_COLUMN - | USE_VARIABLE - | VARIABLE_CONFLICT - | WARNING - | OUTER_P - ; + : ABSOLUTE_P + | ALIAS + | AND + | ARRAY + | ASSERT + | BACKWARD + | CALL + | CHAIN + | CLOSE + | COLLATE + | COLUMN + //| COLUMN_NAME + | COMMIT + | CONSTANT + | CONSTRAINT + //| CONSTRAINT_NAME + | CONTINUE_P + | CURRENT_P + | CURSOR + //| DATATYPE + | DEBUG + | DEFAULT + //| DETAIL + | DIAGNOSTICS + | DO + | DUMP + | ELSIF + //| ERRCODE + | ERROR + | EXCEPTION + | EXIT + | FETCH + | FIRST_P + | FORWARD + | GET + //| HINT + + //| IMPORT + | INFO + | INSERT + | IS + | LAST_P + //| MESSAGE + + //| MESSAGE_TEXT + | MOVE + | NEXT + | NO + | NOTICE + | OPEN + | OPTION + | PERFORM + //| PG_CONTEXT + + //| PG_DATATYPE_NAME + + //| PG_EXCEPTION_CONTEXT + + //| PG_EXCEPTION_DETAIL + + //| PG_EXCEPTION_HINT + | PRINT_STRICT_PARAMS + | PRIOR + | QUERY + | RAISE + | RELATIVE_P + | RESET + | RETURN + //| RETURNED_SQLSTATE + | ROLLBACK + //| ROW_COUNT + | ROWTYPE + | SCHEMA + //| SCHEMA_NAME + | SCROLL + | SET + | SLICE + | SQLSTATE + | STACKED + | TABLE + //| TABLE_NAME + | TYPE_P + | USE_COLUMN + | USE_VARIABLE + | VARIABLE_CONFLICT + | WARNING + | OUTER_P + ; sql_expression - : opt_target_list into_clause from_clause where_clause group_clause having_clause window_clause - ; + : opt_target_list into_clause from_clause where_clause group_clause having_clause window_clause + ; expr_until_then - : sql_expression - ; + : sql_expression + ; expr_until_semi - : sql_expression - ; + : sql_expression + ; expr_until_rightbracket - : a_expr - ; + : a_expr + ; expr_until_loop - : a_expr - ; + : a_expr + ; make_execsql_stmt - : stmt opt_returning_clause_into - ; + : stmt opt_returning_clause_into + ; opt_returning_clause_into - : INTO opt_strict into_target - | - ; + : INTO opt_strict into_target + | + ; \ No newline at end of file diff --git a/sql/snowflake/SnowflakeLexer.g4 b/sql/snowflake/SnowflakeLexer.g4 index 1761bd8812..213fa5a347 100644 --- a/sql/snowflake/SnowflakeLexer.g4 +++ b/sql/snowflake/SnowflakeLexer.g4 @@ -21,662 +21,672 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar SnowflakeLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} /* Commented tokens was initial but not yet used in rules. Uncomment then as needed or delete them if you're sure will be not used.*/ -AAD_PROVISIONER_Q: '\'AAD_PROVISIONER\''; -ABORT: 'ABORT'; +AAD_PROVISIONER_Q : '\'AAD_PROVISIONER\''; +ABORT : 'ABORT'; //ABORT_AFTER_WAIT: 'ABORT_AFTER_WAIT'; -ABORT_DETACHED_QUERY: 'ABORT_DETACHED_QUERY'; -ABORT_STATEMENT: 'ABORT_STATEMENT'; +ABORT_DETACHED_QUERY : 'ABORT_DETACHED_QUERY'; +ABORT_STATEMENT : 'ABORT_STATEMENT'; //ABSENT: 'ABSENT'; //ABSOLUTE: 'ABSOLUTE'; -ACCESS: 'ACCESS'; -ACCOUNT: 'ACCOUNT'; -ACCOUNTADMIN: 'ACCOUNTADMIN'; -ACCOUNTS: 'ACCOUNTS'; -ACTION: 'ACTION'; +ACCESS : 'ACCESS'; +ACCOUNT : 'ACCOUNT'; +ACCOUNTADMIN : 'ACCOUNTADMIN'; +ACCOUNTS : 'ACCOUNTS'; +ACTION : 'ACTION'; //ACTIVE: 'ACTIVE'; -ADD: 'ADD'; +ADD: 'ADD'; //ADMINISTER: 'ADMINISTER'; -ADMIN_NAME: 'ADMIN_NAME'; -ADMIN_PASSWORD: 'ADMIN_PASSWORD'; +ADMIN_NAME : 'ADMIN_NAME'; +ADMIN_PASSWORD : 'ADMIN_PASSWORD'; //AES: 'AES'; -AFTER: 'AFTER'; +AFTER: 'AFTER'; //AGGREGATE: 'AGGREGATE'; -ALERT: 'ALERT'; -ALERTS: 'ALERTS'; -ALL: 'ALL'; +ALERT : 'ALERT'; +ALERTS : 'ALERTS'; +ALL : 'ALL'; //ALLOWED: 'ALLOWED'; -ALLOWED_ACCOUNTS: 'ALLOWED_ACCOUNTS'; -ALLOWED_DATABASES: 'ALLOWED_DATABASES'; -ALLOWED_INTEGRATION_TYPES: 'ALLOWED_INTEGRATION_TYPES'; -ALLOWED_IP_LIST: 'ALLOWED_IP_LIST'; -ALLOWED_SHARES: 'ALLOWED_SHARES'; -ALLOWED_VALUES: 'ALLOWED_VALUES'; -ALLOW_CLIENT_MFA_CACHING: 'ALLOW_CLIENT_MFA_CACHING'; +ALLOWED_ACCOUNTS : 'ALLOWED_ACCOUNTS'; +ALLOWED_DATABASES : 'ALLOWED_DATABASES'; +ALLOWED_INTEGRATION_TYPES : 'ALLOWED_INTEGRATION_TYPES'; +ALLOWED_IP_LIST : 'ALLOWED_IP_LIST'; +ALLOWED_SHARES : 'ALLOWED_SHARES'; +ALLOWED_VALUES : 'ALLOWED_VALUES'; +ALLOW_CLIENT_MFA_CACHING : 'ALLOW_CLIENT_MFA_CACHING'; //ALLOW_CONNECTIONS: 'ALLOW_CONNECTIONS'; -ALLOW_DUPLICATE: 'ALLOW_DUPLICATE'; -ALLOW_ID_TOKEN: 'ALLOW_ID_TOKEN'; +ALLOW_DUPLICATE : 'ALLOW_DUPLICATE'; +ALLOW_ID_TOKEN : 'ALLOW_ID_TOKEN'; //ALLOW_MULTIPLE_EVENT_LOSS: 'ALLOW_MULTIPLE_EVENT_LOSS'; -ALLOW_OVERLAPPING_EXECUTION: 'ALLOW_OVERLAPPING_EXECUTION'; +ALLOW_OVERLAPPING_EXECUTION: 'ALLOW_OVERLAPPING_EXECUTION'; //ALLOW_SINGLE_EVENT_LOSS: 'ALLOW_SINGLE_EVENT_LOSS'; -ALTER: 'ALTER'; +ALTER: 'ALTER'; //ALWAYS: 'ALWAYS'; -AND: 'AND'; +AND: 'AND'; //ANONYMOUS: 'ANONYMOUS'; -ANY: 'ANY'; -API: 'API'; -API_ALLOWED_PREFIXES: 'API_ALLOWED_PREFIXES'; -API_AWS_ROLE_ARN: 'API_AWS_ROLE_ARN'; -API_BLOCKED_PREFIXES: 'API_BLOCKED_PREFIXES'; -API_INTEGRATION: 'API_INTEGRATION'; -API_KEY: 'API_KEY'; -API_PROVIDER: 'API_PROVIDER'; -APPEND: 'APPEND'; -APPEND_ONLY: 'APPEND_ONLY'; +ANY : 'ANY'; +API : 'API'; +API_ALLOWED_PREFIXES : 'API_ALLOWED_PREFIXES'; +API_AWS_ROLE_ARN : 'API_AWS_ROLE_ARN'; +API_BLOCKED_PREFIXES : 'API_BLOCKED_PREFIXES'; +API_INTEGRATION : 'API_INTEGRATION'; +API_KEY : 'API_KEY'; +API_PROVIDER : 'API_PROVIDER'; +APPEND : 'APPEND'; +APPEND_ONLY : 'APPEND_ONLY'; //APPLICATION: 'APPLICATION'; -APPLY: 'APPLY'; +APPLY: 'APPLY'; //APP_NAME: 'APP_NAME'; -ARRAY_AGG: 'ARRAY_AGG'; -AS: 'AS'; -ASC: 'ASC'; -ATTACH: 'ATTACH'; -AT_KEYWORD: 'AT'; -AUTHORIZATION: 'AUTHORIZATION'; -AUTHORIZATIONS: 'AUTHORIZATIONS'; -AUTO: 'AUTO'; -AUTO_Q: '\'AUTO\''; -AUTOCOMMIT: 'AUTOCOMMIT'; -AUTOCOMMIT_API_SUPPORTED: 'AUTOCOMMIT_API_SUPPORTED'; -AUTOINCREMENT: 'AUTOINCREMENT'; -AUTO_COMPRESS: 'AUTO_COMPRESS'; -AUTO_DETECT: 'AUTO_DETECT'; -AUTO_INGEST: 'AUTO_INGEST'; -AUTO_REFRESH: 'AUTO_REFRESH'; -AUTO_RESUME: 'AUTO_RESUME'; -AUTO_SUSPEND: 'AUTO_SUSPEND'; -AVG: 'AVG'; -AVRO: 'AVRO'; -AVRO_Q: '\'AVRO\''; -AWS_KEY_ID: 'AWS_KEY_ID'; -AWS_ROLE: 'AWS_ROLE'; -AWS_SECRET_KEY: 'AWS_SECRET_KEY'; -AWS_SNS: 'AWS_SNS'; -AWS_SNS_ROLE_ARN: 'AWS_SNS_ROLE_ARN'; -AWS_SNS_TOPIC: 'AWS_SNS_TOPIC'; -AWS_SNS_TOPIC_ARN: 'AWS_SNS_TOPIC_ARN'; -AWS_TOKEN: 'AWS_TOKEN'; -AZURE: 'AZURE'; -AZURE_AD_APPLICATION_ID: 'AZURE_AD_APPLICATION_ID'; -AZURE_CSE_Q: '\'AZURE_CSE\''; -AZURE_EVENT_GRID: 'AZURE_EVENT_GRID'; -AZURE_EVENT_GRID_TOPIC_ENDPOINT: 'AZURE_EVENT_GRID_TOPIC_ENDPOINT'; -AZURE_Q: '\'AZURE\''; -AZURE_SAS_TOKEN: 'AZURE_SAS_TOKEN'; -AZURE_STORAGE_QUEUE_PRIMARY_URI: 'AZURE_STORAGE_QUEUE_PRIMARY_URI'; -AZURE_TENANT_ID: 'AZURE_TENANT_ID'; -BASE64: 'BASE64'; -BEFORE: 'BEFORE'; -BEGIN: 'BEGIN'; -BERNOULLI: 'BERNOULLI'; -BETWEEN: 'BETWEEN'; -BINARY_AS_TEXT: 'BINARY_AS_TEXT'; +ARRAY_AGG : 'ARRAY_AGG'; +AS : 'AS'; +ASC : 'ASC'; +ATTACH : 'ATTACH'; +AT_KEYWORD : 'AT'; +AUTHORIZATION : 'AUTHORIZATION'; +AUTHORIZATIONS : 'AUTHORIZATIONS'; +AUTO : 'AUTO'; +AUTO_Q : '\'AUTO\''; +AUTOCOMMIT : 'AUTOCOMMIT'; +AUTOCOMMIT_API_SUPPORTED : 'AUTOCOMMIT_API_SUPPORTED'; +AUTOINCREMENT : 'AUTOINCREMENT'; +AUTO_COMPRESS : 'AUTO_COMPRESS'; +AUTO_DETECT : 'AUTO_DETECT'; +AUTO_INGEST : 'AUTO_INGEST'; +AUTO_REFRESH : 'AUTO_REFRESH'; +AUTO_RESUME : 'AUTO_RESUME'; +AUTO_SUSPEND : 'AUTO_SUSPEND'; +AVG : 'AVG'; +AVRO : 'AVRO'; +AVRO_Q : '\'AVRO\''; +AWS_KEY_ID : 'AWS_KEY_ID'; +AWS_ROLE : 'AWS_ROLE'; +AWS_SECRET_KEY : 'AWS_SECRET_KEY'; +AWS_SNS : 'AWS_SNS'; +AWS_SNS_ROLE_ARN : 'AWS_SNS_ROLE_ARN'; +AWS_SNS_TOPIC : 'AWS_SNS_TOPIC'; +AWS_SNS_TOPIC_ARN : 'AWS_SNS_TOPIC_ARN'; +AWS_TOKEN : 'AWS_TOKEN'; +AZURE : 'AZURE'; +AZURE_AD_APPLICATION_ID : 'AZURE_AD_APPLICATION_ID'; +AZURE_CSE_Q : '\'AZURE_CSE\''; +AZURE_EVENT_GRID : 'AZURE_EVENT_GRID'; +AZURE_EVENT_GRID_TOPIC_ENDPOINT : 'AZURE_EVENT_GRID_TOPIC_ENDPOINT'; +AZURE_Q : '\'AZURE\''; +AZURE_SAS_TOKEN : 'AZURE_SAS_TOKEN'; +AZURE_STORAGE_QUEUE_PRIMARY_URI : 'AZURE_STORAGE_QUEUE_PRIMARY_URI'; +AZURE_TENANT_ID : 'AZURE_TENANT_ID'; +BASE64 : 'BASE64'; +BEFORE : 'BEFORE'; +BEGIN : 'BEGIN'; +BERNOULLI : 'BERNOULLI'; +BETWEEN : 'BETWEEN'; +BINARY_AS_TEXT : 'BINARY_AS_TEXT'; //BINARY_CHECKSUM: 'BINARY_CHECKSUM'; -BINARY_FORMAT: 'BINARY_FORMAT'; -BINARY_INPUT_FORMAT: 'BINARY_INPUT_FORMAT'; -BINARY_OUTPUT_FORMAT: 'BINARY_OUTPUT_FORMAT'; +BINARY_FORMAT : 'BINARY_FORMAT'; +BINARY_INPUT_FORMAT : 'BINARY_INPUT_FORMAT'; +BINARY_OUTPUT_FORMAT : 'BINARY_OUTPUT_FORMAT'; //BINDING: 'BINDING'; -BLOCK: 'BLOCK'; -BLOCKED_IP_LIST: 'BLOCKED_IP_LIST'; -BLOCKED_ROLES_LIST: 'BLOCKED_ROLES_LIST'; -BODY: 'BODY'; -BOTH_Q: '\'BOTH\''; -BROTLI: 'BROTLI'; -BUSINESS_CRITICAL: 'BUSINESS_CRITICAL'; -BY: 'BY'; -BZ2: 'BZ2'; +BLOCK : 'BLOCK'; +BLOCKED_IP_LIST : 'BLOCKED_IP_LIST'; +BLOCKED_ROLES_LIST : 'BLOCKED_ROLES_LIST'; +BODY : 'BODY'; +BOTH_Q : '\'BOTH\''; +BROTLI : 'BROTLI'; +BUSINESS_CRITICAL : 'BUSINESS_CRITICAL'; +BY : 'BY'; +BZ2 : 'BZ2'; //CACHE: 'CACHE'; -CALL: 'CALL'; -CALLED: 'CALLED'; -CALLER: 'CALLER'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CASE_INSENSITIVE: 'CASE_INSENSITIVE'; -CASE_SENSITIVE: 'CASE_SENSITIVE'; -CAST: 'CAST'; +CALL : 'CALL'; +CALLED : 'CALLED'; +CALLER : 'CALLER'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CASE_INSENSITIVE : 'CASE_INSENSITIVE'; +CASE_SENSITIVE : 'CASE_SENSITIVE'; +CAST : 'CAST'; //CATCH: 'CATCH'; //CERTIFICATE: 'CERTIFICATE'; //CHANGE: 'CHANGE'; -CHANGES: 'CHANGES'; +CHANGES: 'CHANGES'; //CHANGETABLE: 'CHANGETABLE'; //CHANGE_RETENTION: 'CHANGE_RETENTION'; -CHANGE_TRACKING: 'CHANGE_TRACKING'; -CHANNELS: 'CHANNELS'; -CHAR: 'CHAR'; -CHARACTER: 'CHARACTER'; -CHARINDEX: 'CHARINDEX'; -CHECK: 'CHECK'; +CHANGE_TRACKING : 'CHANGE_TRACKING'; +CHANNELS : 'CHANNELS'; +CHAR : 'CHAR'; +CHARACTER : 'CHARACTER'; +CHARINDEX : 'CHARINDEX'; +CHECK : 'CHECK'; //CHECKSUM: 'CHECKSUM'; //CHECK_EXPIRATION: 'CHECK_EXPIRATION'; //CHECK_POLICY: 'CHECK_POLICY'; //CLASSIFIER_FUNCTION: 'CLASSIFIER_FUNCTION'; //CLEANUP: 'CLEANUP'; -CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS: 'CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS'; -CLIENT_ENCRYPTION_KEY_SIZE: 'CLIENT_ENCRYPTION_KEY_SIZE'; -CLIENT_MEMORY_LIMIT: 'CLIENT_MEMORY_LIMIT'; -CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX: 'CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX'; -CLIENT_METADATA_USE_SESSION_DATABASE: 'CLIENT_METADATA_USE_SESSION_DATABASE'; -CLIENT_PREFETCH_THREADS: 'CLIENT_PREFETCH_THREADS'; -CLIENT_RESULT_CHUNK_SIZE: 'CLIENT_RESULT_CHUNK_SIZE'; -CLIENT_RESULT_COLUMN_CASE_INSENSITIVE: 'CLIENT_RESULT_COLUMN_CASE_INSENSITIVE'; -CLIENT_SESSION_KEEP_ALIVE: 'CLIENT_SESSION_KEEP_ALIVE'; -CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY: 'CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY'; -CLIENT_TIMESTAMP_TYPE_MAPPING: 'CLIENT_TIMESTAMP_TYPE_MAPPING'; -CLONE: 'CLONE'; +CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS : 'CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS'; +CLIENT_ENCRYPTION_KEY_SIZE : 'CLIENT_ENCRYPTION_KEY_SIZE'; +CLIENT_MEMORY_LIMIT : 'CLIENT_MEMORY_LIMIT'; +CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX : 'CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX'; +CLIENT_METADATA_USE_SESSION_DATABASE : 'CLIENT_METADATA_USE_SESSION_DATABASE'; +CLIENT_PREFETCH_THREADS : 'CLIENT_PREFETCH_THREADS'; +CLIENT_RESULT_CHUNK_SIZE : 'CLIENT_RESULT_CHUNK_SIZE'; +CLIENT_RESULT_COLUMN_CASE_INSENSITIVE : 'CLIENT_RESULT_COLUMN_CASE_INSENSITIVE'; +CLIENT_SESSION_KEEP_ALIVE : 'CLIENT_SESSION_KEEP_ALIVE'; +CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY : 'CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY'; +CLIENT_TIMESTAMP_TYPE_MAPPING : 'CLIENT_TIMESTAMP_TYPE_MAPPING'; +CLONE : 'CLONE'; //CLOSE: 'CLOSE'; -CLUSTER: 'CLUSTER'; +CLUSTER: 'CLUSTER'; //CLUSTERED: 'CLUSTERED'; -CLUSTERING: 'CLUSTERING'; -COALESCE: 'COALESCE'; -COLLATE: 'COLLATE'; +CLUSTERING : 'CLUSTERING'; +COALESCE : 'COALESCE'; +COLLATE : 'COLLATE'; //COLLECTION: 'COLLECTION'; -COLUMN: 'COLUMN'; -COLUMNS: 'COLUMNS'; -COMMENT: 'COMMENT'; -COMMIT: 'COMMIT'; +COLUMN : 'COLUMN'; +COLUMNS : 'COLUMNS'; +COMMENT : 'COMMENT'; +COMMIT : 'COMMIT'; //COMMITTED: 'COMMITTED'; //COMPRESS: 'COMPRESS'; -COMPRESSION: 'COMPRESSION'; -CONCAT: 'CONCAT'; +COMPRESSION : 'COMPRESSION'; +CONCAT : 'CONCAT'; // CONCAT_NULL_YIELDS_NULL: 'CONCAT_NULL_YIELDS_NULL'; -CONCAT_WS: 'CONCAT_WS'; -CONDITION: 'CONDITION'; +CONCAT_WS : 'CONCAT_WS'; +CONDITION : 'CONDITION'; // CONFIGURATION: 'CONFIGURATION'; -CONNECT: 'CONNECT'; -CONNECTION: 'CONNECTION'; -CONNECTIONS: 'CONNECTIONS'; -CONSTRAINT: 'CONSTRAINT'; +CONNECT : 'CONNECT'; +CONNECTION : 'CONNECTION'; +CONNECTIONS : 'CONNECTIONS'; +CONSTRAINT : 'CONSTRAINT'; // CONTAINMENT: 'CONTAINMENT'; -CONTAINS: 'CONTAINS'; +CONTAINS: 'CONTAINS'; // CONTENT: 'CONTENT'; // CONTEXT: 'CONTEXT'; -CONTEXT_HEADERS: 'CONTEXT_HEADERS'; +CONTEXT_HEADERS: 'CONTEXT_HEADERS'; // CONTEXT_INFO: 'CONTEXT_INFO'; -CONTINUE: 'CONTINUE'; +CONTINUE: 'CONTINUE'; // CONTROL: 'CONTROL'; // CONVERSATION: 'CONVERSATION'; // COOKIE: 'COOKIE'; -COPY: 'COPY'; +COPY: 'COPY'; // COPY_ONLY: 'COPY_ONLY'; -COPY_OPTIONS_: 'COPY_OPTIONS'; -COUNT: 'COUNT'; -CREATE: 'CREATE'; -CREDENTIALS: 'CREDENTIALS'; -CREDIT_QUOTA: 'CREDIT_QUOTA'; -CROSS: 'CROSS'; -CSV: 'CSV'; -CSV_Q: '\'CSV\''; -CUBE: 'CUBE'; +COPY_OPTIONS_ : 'COPY_OPTIONS'; +COUNT : 'COUNT'; +CREATE : 'CREATE'; +CREDENTIALS : 'CREDENTIALS'; +CREDIT_QUOTA : 'CREDIT_QUOTA'; +CROSS : 'CROSS'; +CSV : 'CSV'; +CSV_Q : '\'CSV\''; +CUBE : 'CUBE'; // CUME_DIST: 'CUME_DIST'; -CURRENT: 'CURRENT'; -CURRENT_DATE: 'CURRENT_DATE'; +CURRENT : 'CURRENT'; +CURRENT_DATE : 'CURRENT_DATE'; // CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; +CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; // CURRENT_USER: 'CURRENT_USER'; // CURSOR: 'CURSOR'; -CUSTOM: 'CUSTOM'; -DAILY: 'DAILY'; -DATA: 'DATA'; -DATABASE: 'DATABASE'; -DATABASES: 'DATABASES'; -DATA_RETENTION_TIME_IN_DAYS: 'DATA_RETENTION_TIME_IN_DAYS'; -DATEADD: 'DATEADD'; -DATEDIFF: 'DATEDIFF'; +CUSTOM : 'CUSTOM'; +DAILY : 'DAILY'; +DATA : 'DATA'; +DATABASE : 'DATABASE'; +DATABASES : 'DATABASES'; +DATA_RETENTION_TIME_IN_DAYS : 'DATA_RETENTION_TIME_IN_DAYS'; +DATEADD : 'DATEADD'; +DATEDIFF : 'DATEDIFF'; // DATENAME: 'DATENAME'; // DATEPART: 'DATEPART'; -DATE_FORMAT: 'DATE_FORMAT'; -DATE_INPUT_FORMAT: 'DATE_INPUT_FORMAT'; -DATE_OUTPUT_FORMAT: 'DATE_OUTPUT_FORMAT'; -DATE_PART: 'DATE_PART'; +DATE_FORMAT : 'DATE_FORMAT'; +DATE_INPUT_FORMAT : 'DATE_INPUT_FORMAT'; +DATE_OUTPUT_FORMAT : 'DATE_OUTPUT_FORMAT'; +DATE_PART : 'DATE_PART'; // DAYS: 'DAYS'; -DAYS_TO_EXPIRY: 'DAYS_TO_EXPIRY'; +DAYS_TO_EXPIRY: 'DAYS_TO_EXPIRY'; // DECLARE: 'DECLARE'; -DEFAULT: 'DEFAULT'; -DEFAULT_DDL_COLLATION_: 'DEFAULT_DDL_COLLATION'; -DEFAULT_NAMESPACE: 'DEFAULT_NAMESPACE'; -DEFAULT_ROLE: 'DEFAULT_ROLE'; -DEFAULT_WAREHOUSE: 'DEFAULT_WAREHOUSE'; -DEFERRABLE: 'DEFERRABLE'; -DEFERRED: 'DEFERRED'; -DEFINE: 'DEFINE'; -DEFINITION: 'DEFINITION'; -DEFLATE: 'DEFLATE'; -DELEGATED: 'DELEGATED'; -DELETE: 'DELETE'; -DELTA: 'DELTA'; -DENSE_RANK: 'DENSE_RANK'; -DESC: 'DESC'; -DESCRIBE: 'DESCRIBE'; -DIRECTION: 'DIRECTION'; -DIRECTORY: 'DIRECTORY'; -DISABLE: 'DISABLE'; -DISABLED: 'DISABLED'; -DISABLE_AUTO_CONVERT: 'DISABLE_AUTO_CONVERT'; -DISABLE_SNOWFLAKE_DATA: 'DISABLE_SNOWFLAKE_DATA'; +DEFAULT : 'DEFAULT'; +DEFAULT_DDL_COLLATION_ : 'DEFAULT_DDL_COLLATION'; +DEFAULT_NAMESPACE : 'DEFAULT_NAMESPACE'; +DEFAULT_ROLE : 'DEFAULT_ROLE'; +DEFAULT_WAREHOUSE : 'DEFAULT_WAREHOUSE'; +DEFERRABLE : 'DEFERRABLE'; +DEFERRED : 'DEFERRED'; +DEFINE : 'DEFINE'; +DEFINITION : 'DEFINITION'; +DEFLATE : 'DEFLATE'; +DELEGATED : 'DELEGATED'; +DELETE : 'DELETE'; +DELTA : 'DELTA'; +DENSE_RANK : 'DENSE_RANK'; +DESC : 'DESC'; +DESCRIBE : 'DESCRIBE'; +DIRECTION : 'DIRECTION'; +DIRECTORY : 'DIRECTORY'; +DISABLE : 'DISABLE'; +DISABLED : 'DISABLED'; +DISABLE_AUTO_CONVERT : 'DISABLE_AUTO_CONVERT'; +DISABLE_SNOWFLAKE_DATA : 'DISABLE_SNOWFLAKE_DATA'; // DISK: 'DISK'; -DISPLAY_NAME: 'DISPLAY_NAME'; -DISTINCT: 'DISTINCT'; -DO: 'DO'; -DOWNSTREAM: 'DOWNSTREAM'; -DROP: 'DROP'; -DYNAMIC: 'DYNAMIC'; -ECONOMY: 'ECONOMY'; -EDITION: 'EDITION'; -ELSE: 'ELSE'; -EMAIL: 'EMAIL'; -EMPTY_: 'EMPTY'; -EMPTY_FIELD_AS_NULL: 'EMPTY_FIELD_AS_NULL'; -ENABLE: 'ENABLE'; -ENABLED: 'ENABLED'; -ENABLE_FOR_PRIVILEGE: 'ENABLE_FOR_PRIVILEGE'; -ENABLE_INTERNAL_STAGES_PRIVATELINK: 'ENABLE_INTERNAL_STAGES_PRIVATELINK'; -ENABLE_OCTAL: 'ENABLE_OCTAL'; -ENABLE_QUERY_ACCELERATION: 'ENABLE_QUERY_ACCELERATION'; -ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION: 'ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION'; -ENCODING: 'ENCODING'; -ENCRYPTION: 'ENCRYPTION'; -END: 'END'; +DISPLAY_NAME : 'DISPLAY_NAME'; +DISTINCT : 'DISTINCT'; +DO : 'DO'; +DOWNSTREAM : 'DOWNSTREAM'; +DROP : 'DROP'; +DYNAMIC : 'DYNAMIC'; +ECONOMY : 'ECONOMY'; +EDITION : 'EDITION'; +ELSE : 'ELSE'; +EMAIL : 'EMAIL'; +EMPTY_ : 'EMPTY'; +EMPTY_FIELD_AS_NULL : 'EMPTY_FIELD_AS_NULL'; +ENABLE : 'ENABLE'; +ENABLED : 'ENABLED'; +ENABLE_FOR_PRIVILEGE : 'ENABLE_FOR_PRIVILEGE'; +ENABLE_INTERNAL_STAGES_PRIVATELINK : 'ENABLE_INTERNAL_STAGES_PRIVATELINK'; +ENABLE_OCTAL : 'ENABLE_OCTAL'; +ENABLE_QUERY_ACCELERATION : 'ENABLE_QUERY_ACCELERATION'; +ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION : 'ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION'; +ENCODING : 'ENCODING'; +ENCRYPTION : 'ENCRYPTION'; +END : 'END'; // ENDPOINT: 'ENDPOINT'; -END_TIMESTAMP: 'END_TIMESTAMP'; -ENFORCED: 'ENFORCED'; -ENFORCE_LENGTH: 'ENFORCE_LENGTH'; -ENFORCE_SESSION_POLICY: 'ENFORCE_SESSION_POLICY'; -ENTERPRISE: 'ENTERPRISE'; -EQUAL_NULL: 'EQUAL_NULL'; -EQUALITY: 'EQUALITY'; -ERROR_INTEGRATION: 'ERROR_INTEGRATION'; -ERROR_ON_COLUMN_COUNT_MISMATCH: 'ERROR_ON_COLUMN_COUNT_MISMATCH'; -ERROR_ON_NONDETERMINISTIC_MERGE: 'ERROR_ON_NONDETERMINISTIC_MERGE'; -ERROR_ON_NONDETERMINISTIC_UPDATE: 'ERROR_ON_NONDETERMINISTIC_UPDATE'; -ESCAPE: 'ESCAPE'; -ESCAPE_UNENCLOSED_FIELD: 'ESCAPE_UNENCLOSED_FIELD'; -EVENT: 'EVENT'; -EXCEPT: 'EXCEPT'; -EXCHANGE: 'EXCHANGE'; -EXECUTE: 'EXEC' 'UTE'?; -EXECUTION: 'EXECUTION'; +END_TIMESTAMP : 'END_TIMESTAMP'; +ENFORCED : 'ENFORCED'; +ENFORCE_LENGTH : 'ENFORCE_LENGTH'; +ENFORCE_SESSION_POLICY : 'ENFORCE_SESSION_POLICY'; +ENTERPRISE : 'ENTERPRISE'; +EQUAL_NULL : 'EQUAL_NULL'; +EQUALITY : 'EQUALITY'; +ERROR_INTEGRATION : 'ERROR_INTEGRATION'; +ERROR_ON_COLUMN_COUNT_MISMATCH : 'ERROR_ON_COLUMN_COUNT_MISMATCH'; +ERROR_ON_NONDETERMINISTIC_MERGE : 'ERROR_ON_NONDETERMINISTIC_MERGE'; +ERROR_ON_NONDETERMINISTIC_UPDATE : 'ERROR_ON_NONDETERMINISTIC_UPDATE'; +ESCAPE : 'ESCAPE'; +ESCAPE_UNENCLOSED_FIELD : 'ESCAPE_UNENCLOSED_FIELD'; +EVENT : 'EVENT'; +EXCEPT : 'EXCEPT'; +EXCHANGE : 'EXCHANGE'; +EXECUTE : 'EXEC' 'UTE'?; +EXECUTION : 'EXECUTION'; // EXIST: 'EXIST'; -EXISTS: 'EXISTS'; +EXISTS: 'EXISTS'; // EXIT: 'EXIT'; // EXPAND: 'EXPAND'; // EXPIRY_DATE: 'EXPIRY_DATE'; -EXPLAIN: 'EXPLAIN'; +EXPLAIN: 'EXPLAIN'; // EXPLICIT: 'EXPLICIT'; -EXTERNAL: 'EXTERNAL'; -EXTERNAL_OAUTH: 'EXTERNAL_OAUTH'; -EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST: 'EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST'; -EXTERNAL_OAUTH_ALLOWED_ROLES_LIST: 'EXTERNAL_OAUTH_ALLOWED_ROLES_LIST'; -EXTERNAL_OAUTH_ANY_ROLE_MODE: 'EXTERNAL_OAUTH_ANY_ROLE_MODE'; -EXTERNAL_OAUTH_AUDIENCE_LIST: 'EXTERNAL_OAUTH_AUDIENCE_LIST'; -EXTERNAL_OAUTH_BLOCKED_ROLES_LIST: 'EXTERNAL_OAUTH_BLOCKED_ROLES_LIST'; -EXTERNAL_OAUTH_ISSUER: 'EXTERNAL_OAUTH_ISSUER'; -EXTERNAL_OAUTH_JWS_KEYS_URL: 'EXTERNAL_OAUTH_JWS_KEYS_URL'; -EXTERNAL_OAUTH_RSA_PUBLIC_KEY: 'EXTERNAL_OAUTH_RSA_PUBLIC_KEY'; -EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2: 'EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2'; -EXTERNAL_OAUTH_SCOPE_DELIMITER: 'EXTERNAL_OAUTH_SCOPE_DELIMITER'; -EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE: 'EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE'; -EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM: 'EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM'; -EXTERNAL_OAUTH_TYPE: 'EXTERNAL_OAUTH_TYPE'; -EXTERNAL_STAGE: 'EXTERNAL_STAGE'; -FAILOVER: 'FAILOVER'; +EXTERNAL : 'EXTERNAL'; +EXTERNAL_OAUTH : 'EXTERNAL_OAUTH'; +EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST: + 'EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST' +; +EXTERNAL_OAUTH_ALLOWED_ROLES_LIST : 'EXTERNAL_OAUTH_ALLOWED_ROLES_LIST'; +EXTERNAL_OAUTH_ANY_ROLE_MODE : 'EXTERNAL_OAUTH_ANY_ROLE_MODE'; +EXTERNAL_OAUTH_AUDIENCE_LIST : 'EXTERNAL_OAUTH_AUDIENCE_LIST'; +EXTERNAL_OAUTH_BLOCKED_ROLES_LIST : 'EXTERNAL_OAUTH_BLOCKED_ROLES_LIST'; +EXTERNAL_OAUTH_ISSUER : 'EXTERNAL_OAUTH_ISSUER'; +EXTERNAL_OAUTH_JWS_KEYS_URL : 'EXTERNAL_OAUTH_JWS_KEYS_URL'; +EXTERNAL_OAUTH_RSA_PUBLIC_KEY : 'EXTERNAL_OAUTH_RSA_PUBLIC_KEY'; +EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2 : 'EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2'; +EXTERNAL_OAUTH_SCOPE_DELIMITER : 'EXTERNAL_OAUTH_SCOPE_DELIMITER'; +EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE: + 'EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE' +; +EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM : 'EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM'; +EXTERNAL_OAUTH_TYPE : 'EXTERNAL_OAUTH_TYPE'; +EXTERNAL_STAGE : 'EXTERNAL_STAGE'; +FAILOVER : 'FAILOVER'; // FAILOVER_MODE: 'FAILOVER_MODE'; // FAIL_OPERATION: 'FAIL_OPERATION'; -FALSE: 'FALSE'; -FETCH: 'FETCH'; -FIELD_DELIMITER: 'FIELD_DELIMITER'; -FIELD_OPTIONALLY_ENCLOSED_BY: 'FIELD_OPTIONALLY_ENCLOSED_BY'; -FILE: 'FILE'; -FILES: 'FILES'; -FILE_EXTENSION: 'FILE_EXTENSION'; -FILE_FORMAT: 'FILE_FORMAT'; +FALSE : 'FALSE'; +FETCH : 'FETCH'; +FIELD_DELIMITER : 'FIELD_DELIMITER'; +FIELD_OPTIONALLY_ENCLOSED_BY : 'FIELD_OPTIONALLY_ENCLOSED_BY'; +FILE : 'FILE'; +FILES : 'FILES'; +FILE_EXTENSION : 'FILE_EXTENSION'; +FILE_FORMAT : 'FILE_FORMAT'; // FILTER: 'FILTER'; -FIRST: 'FIRST'; -FIRST_NAME: 'FIRST_NAME'; -FIRST_VALUE: 'FIRST_VALUE'; -FLATTEN: 'FLATTEN'; -FOR: 'FOR'; -FORCE: 'FORCE'; -FOREIGN: 'FOREIGN'; -FORMAT: 'FORMAT'; -FORMATS: 'FORMATS'; -FORMAT_NAME: 'FORMAT_NAME'; -FREQUENCY: 'FREQUENCY'; -FROM: 'FROM'; -FULL: 'FULL'; -FUNCTION: 'FUNCTION'; -FUNCTIONS: 'FUNCTIONS'; -FUTURE: 'FUTURE'; -GCP_PUBSUB: 'GCP_PUBSUB'; -GCP_PUBSUB_SUBSCRIPTION_NAME: 'GCP_PUBSUB_SUBSCRIPTION_NAME'; -GCP_PUBSUB_TOPIC_NAME: 'GCP_PUBSUB_TOPIC_NAME'; -GCS: 'GCS'; -GCS_SSE_KMS_Q: '\'GCS_SSE_KMS\''; -GENERIC_Q: '\'GENERIC\''; -GENERIC_SCIM_PROVISIONER_Q: '\'GENERIC_SCIM_PROVISIONER\''; -GEO: 'GEO'; -GEOGRAPHY_OUTPUT_FORMAT: 'GEOGRAPHY_OUTPUT_FORMAT'; -GEOMETRY_OUTPUT_FORMAT: 'GEOMETRY_OUTPUT_FORMAT'; -GET: 'GET'; +FIRST : 'FIRST'; +FIRST_NAME : 'FIRST_NAME'; +FIRST_VALUE : 'FIRST_VALUE'; +FLATTEN : 'FLATTEN'; +FOR : 'FOR'; +FORCE : 'FORCE'; +FOREIGN : 'FOREIGN'; +FORMAT : 'FORMAT'; +FORMATS : 'FORMATS'; +FORMAT_NAME : 'FORMAT_NAME'; +FREQUENCY : 'FREQUENCY'; +FROM : 'FROM'; +FULL : 'FULL'; +FUNCTION : 'FUNCTION'; +FUNCTIONS : 'FUNCTIONS'; +FUTURE : 'FUTURE'; +GCP_PUBSUB : 'GCP_PUBSUB'; +GCP_PUBSUB_SUBSCRIPTION_NAME : 'GCP_PUBSUB_SUBSCRIPTION_NAME'; +GCP_PUBSUB_TOPIC_NAME : 'GCP_PUBSUB_TOPIC_NAME'; +GCS : 'GCS'; +GCS_SSE_KMS_Q : '\'GCS_SSE_KMS\''; +GENERIC_Q : '\'GENERIC\''; +GENERIC_SCIM_PROVISIONER_Q : '\'GENERIC_SCIM_PROVISIONER\''; +GEO : 'GEO'; +GEOGRAPHY_OUTPUT_FORMAT : 'GEOGRAPHY_OUTPUT_FORMAT'; +GEOMETRY_OUTPUT_FORMAT : 'GEOMETRY_OUTPUT_FORMAT'; +GET : 'GET'; // GET_FILESTREAM_TRANSACTION_CONTEXT: 'GET_FILESTREAM_TRANSACTION_CONTEXT'; -GLOBAL: 'GLOBAL'; -GOOGLE_AUDIENCE: 'GOOGLE_AUDIENCE'; +GLOBAL : 'GLOBAL'; +GOOGLE_AUDIENCE : 'GOOGLE_AUDIENCE'; // GOTO: 'GOTO'; -GRANT: 'GRANT'; -GRANTS: 'GRANTS'; -GROUP: 'GROUP'; -GROUPING: 'GROUPING'; +GRANT : 'GRANT'; +GRANTS : 'GRANTS'; +GROUP : 'GROUP'; +GROUPING : 'GROUPING'; // GROUPING_ID: 'GROUPING_ID'; -GROUPS: 'GROUPS'; -GZIP: 'GZIP'; -HAVING: 'HAVING'; -HEADER: 'HEADER'; -HEADERS: 'HEADERS'; -HEX: 'HEX'; +GROUPS : 'GROUPS'; +GZIP : 'GZIP'; +HAVING : 'HAVING'; +HEADER : 'HEADER'; +HEADERS : 'HEADERS'; +HEX : 'HEX'; // HIERARCHYID: 'HIERARCHYID'; // HIGH: 'HIGH'; -HISTORY: 'HISTORY'; +HISTORY: 'HISTORY'; // HOURS: 'HOURS'; -IDENTIFIER: 'IDENTIFIER'; -IDENTITY: 'IDENTITY'; -IF: 'IF'; -IFF: 'IFF'; -IFNULL: 'IFNULL'; -IGNORE: 'IGNORE'; +IDENTIFIER : 'IDENTIFIER'; +IDENTITY : 'IDENTITY'; +IF : 'IF'; +IFF : 'IFF'; +IFNULL : 'IFNULL'; +IGNORE : 'IGNORE'; // IGNORE_CONSTRAINTS: 'IGNORE_CONSTRAINTS'; // IGNORE_DUP_KEY: 'IGNORE_DUP_KEY'; // IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX: 'IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX'; // IGNORE_TRIGGERS: 'IGNORE_TRIGGERS'; -IGNORE_UTF8_ERRORS: 'IGNORE_UTF8_ERRORS'; -ILIKE: 'ILIKE'; -IMMEDIATE: 'IMMEDIATE'; -IMMEDIATELY: 'IMMEDIATELY'; -IMMUTABLE: 'IMMUTABLE'; -IMPLICIT: 'IMPLICIT'; -IMPORT: 'IMPORT'; -IMPORTED: 'IMPORTED'; -IN: 'IN'; -INCREMENT: 'INCREMENT'; -INDEX: 'INDEX'; -INFORMATION: 'INFORMATION'; +IGNORE_UTF8_ERRORS : 'IGNORE_UTF8_ERRORS'; +ILIKE : 'ILIKE'; +IMMEDIATE : 'IMMEDIATE'; +IMMEDIATELY : 'IMMEDIATELY'; +IMMUTABLE : 'IMMUTABLE'; +IMPLICIT : 'IMPLICIT'; +IMPORT : 'IMPORT'; +IMPORTED : 'IMPORTED'; +IN : 'IN'; +INCREMENT : 'INCREMENT'; +INDEX : 'INDEX'; +INFORMATION : 'INFORMATION'; // INIT: 'INIT'; -INITIALLY: 'INITIALLY'; -INITIALLY_SUSPENDED: 'INITIALLY_SUSPENDED'; -INITIAL_REPLICATION_SIZE_LIMIT_IN_TB: 'INITIAL_REPLICATION_SIZE_LIMIT_IN_TB'; -INNER: 'INNER'; -INPUT: 'INPUT'; -INSERT: 'INSERT'; -INSERT_ONLY: 'INSERT_ONLY'; +INITIALLY : 'INITIALLY'; +INITIALLY_SUSPENDED : 'INITIALLY_SUSPENDED'; +INITIAL_REPLICATION_SIZE_LIMIT_IN_TB : 'INITIAL_REPLICATION_SIZE_LIMIT_IN_TB'; +INNER : 'INNER'; +INPUT : 'INPUT'; +INSERT : 'INSERT'; +INSERT_ONLY : 'INSERT_ONLY'; // INSTEAD: 'INSTEAD'; -INT: 'INT'; -INTEGRATION: 'INTEGRATION'; -INTEGRATIONS: 'INTEGRATIONS'; -INTERSECT: 'INTERSECT'; -INTO: 'INTO'; -IS: 'IS'; +INT : 'INT'; +INTEGRATION : 'INTEGRATION'; +INTEGRATIONS : 'INTEGRATIONS'; +INTERSECT : 'INTERSECT'; +INTO : 'INTO'; +IS : 'IS'; // ISNUMERIC: 'ISNUMERIC'; // ISOLATION: 'ISOLATION'; -JAVASCRIPT: 'JAVASCRIPT'; -JDBC_TREAT_DECIMAL_AS_INT: 'JDBC_TREAT_DECIMAL_AS_INT'; -JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC: 'JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC'; -JDBC_USE_SESSION_TIMEZONE: 'JDBC_USE_SESSION_TIMEZONE'; -JOIN: 'JOIN'; -JSON: 'JSON'; -JSON_Q: '\'JSON\''; -JSON_INDENT: 'JSON_INDENT'; -JS_TREAT_INTEGER_AS_BIGINT: 'JS_TREAT_INTEGER_AS_BIGINT'; +JAVASCRIPT : 'JAVASCRIPT'; +JDBC_TREAT_DECIMAL_AS_INT : 'JDBC_TREAT_DECIMAL_AS_INT'; +JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC : 'JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC'; +JDBC_USE_SESSION_TIMEZONE : 'JDBC_USE_SESSION_TIMEZONE'; +JOIN : 'JOIN'; +JSON : 'JSON'; +JSON_Q : '\'JSON\''; +JSON_INDENT : 'JSON_INDENT'; +JS_TREAT_INTEGER_AS_BIGINT : 'JS_TREAT_INTEGER_AS_BIGINT'; // KB: 'KB'; // KEEP: 'KEEP'; -KEY: 'KEY'; -KEYS: 'KEYS'; +KEY : 'KEY'; +KEYS : 'KEYS'; // KEYSET: 'KEYSET'; -KMS_KEY_ID: 'KMS_KEY_ID'; -LAG: 'LAG'; -LANGUAGE: 'LANGUAGE'; -LARGE: 'LARGE'; -LAST: 'LAST'; -LAST_NAME: 'LAST_NAME'; -LAST_QUERY_ID: 'LAST_QUERY_ID'; -LAST_VALUE: 'LAST_VALUE'; -LATERAL: 'LATERAL'; -LEAD: 'LEAD'; -LEFT: 'LEFT'; -LEN: 'LEN'; -LENGTH: 'LENGTH'; +KMS_KEY_ID : 'KMS_KEY_ID'; +LAG : 'LAG'; +LANGUAGE : 'LANGUAGE'; +LARGE : 'LARGE'; +LAST : 'LAST'; +LAST_NAME : 'LAST_NAME'; +LAST_QUERY_ID : 'LAST_QUERY_ID'; +LAST_VALUE : 'LAST_VALUE'; +LATERAL : 'LATERAL'; +LEAD : 'LEAD'; +LEFT : 'LEFT'; +LEN : 'LEN'; +LENGTH : 'LENGTH'; // LEVEL: 'LEVEL'; -LIKE: 'LIKE'; -LIMIT: 'LIMIT'; +LIKE : 'LIKE'; +LIMIT : 'LIMIT'; // LINENO: 'LINENO'; -LIST: 'LIST'; +LIST: 'LIST'; // LISTENER_IP: 'LISTENER_IP'; // LISTENER_PORT: 'LISTENER_PORT'; -LISTING: 'LISTING'; +LISTING: 'LISTING'; // LOAD: 'LOAD'; -LOCAL: 'LOCAL'; +LOCAL: 'LOCAL'; // LOCAL_SERVICE_NAME: 'LOCAL_SERVICE_NAME'; -LOCATION: 'LOCATION'; -LOCKS: 'LOCKS'; -LOCK_TIMEOUT: 'LOCK_TIMEOUT'; +LOCATION : 'LOCATION'; +LOCKS : 'LOCKS'; +LOCK_TIMEOUT : 'LOCK_TIMEOUT'; // LOG: 'LOG'; // LOGIN: 'LOGIN'; -LOGIN_NAME: 'LOGIN_NAME'; -LOOKER: 'LOOKER'; +LOGIN_NAME : 'LOGIN_NAME'; +LOOKER : 'LOOKER'; // LOW: 'LOW'; -LOWER: 'LOWER'; -LTRIM: 'LTRIM'; -LZO: 'LZO'; -MANAGE: 'MANAGE'; -MANAGED: 'MANAGED'; +LOWER : 'LOWER'; +LTRIM : 'LTRIM'; +LZO : 'LZO'; +MANAGE : 'MANAGE'; +MANAGED : 'MANAGED'; // MASK: 'MASK'; // MASKED: 'MASKED'; -MASKING: 'MASKING'; +MASKING: 'MASKING'; // MASTER: 'MASTER'; -MASTER_KEY: 'MASTER_KEY'; -MATCH: 'MATCH'; -MATCHED: 'MATCHED'; -MATCHES: 'MATCHES'; -MATCH_BY_COLUMN_NAME: 'MATCH_BY_COLUMN_NAME'; -MATCH_RECOGNIZE: 'MATCH_RECOGNIZE'; -MATERIALIZED: 'MATERIALIZED'; -MAX_BATCH_ROWS: 'MAX_BATCH_ROWS'; -MAX_CLUSTER_COUNT: 'MAX_CLUSTER_COUNT'; -MAX_CONCURRENCY_LEVEL: 'MAX_CONCURRENCY_LEVEL'; -MAX_DATA_EXTENSION_TIME_IN_DAYS: 'MAX_DATA_EXTENSION_TIME_IN_DAYS'; -MAX_SIZE: 'MAX_SIZE'; -MEASURES: 'MEASURES'; -MEDIUM: 'MEDIUM'; -MEMOIZABLE: 'MEMOIZABLE'; -MERGE: 'MERGE'; -MIDDLE_NAME: 'MIDDLE_NAME'; -MIN: 'MIN'; -MINS_TO_BYPASS_MFA: 'MINS_TO_BYPASS_MFA'; -MINS_TO_UNLOCK: 'MINS_TO_UNLOCK'; -MINUS_: 'MINUS'; +MASTER_KEY : 'MASTER_KEY'; +MATCH : 'MATCH'; +MATCHED : 'MATCHED'; +MATCHES : 'MATCHES'; +MATCH_BY_COLUMN_NAME : 'MATCH_BY_COLUMN_NAME'; +MATCH_RECOGNIZE : 'MATCH_RECOGNIZE'; +MATERIALIZED : 'MATERIALIZED'; +MAX_BATCH_ROWS : 'MAX_BATCH_ROWS'; +MAX_CLUSTER_COUNT : 'MAX_CLUSTER_COUNT'; +MAX_CONCURRENCY_LEVEL : 'MAX_CONCURRENCY_LEVEL'; +MAX_DATA_EXTENSION_TIME_IN_DAYS : 'MAX_DATA_EXTENSION_TIME_IN_DAYS'; +MAX_SIZE : 'MAX_SIZE'; +MEASURES : 'MEASURES'; +MEDIUM : 'MEDIUM'; +MEMOIZABLE : 'MEMOIZABLE'; +MERGE : 'MERGE'; +MIDDLE_NAME : 'MIDDLE_NAME'; +MIN : 'MIN'; +MINS_TO_BYPASS_MFA : 'MINS_TO_BYPASS_MFA'; +MINS_TO_UNLOCK : 'MINS_TO_UNLOCK'; +MINUS_ : 'MINUS'; // MINUTES: 'MINUTES'; -MIN_CLUSTER_COUNT: 'MIN_CLUSTER_COUNT'; -MIN_DATA_RETENTION_TIME_IN_DAYS: 'MIN_DATA_RETENTION_TIME_IN_DAYS'; -MODE: 'MODE'; -MODIFIED_AFTER: 'MODIFIED_AFTER'; -MODIFY: 'MODIFY'; -MONITOR: 'MONITOR'; -MONITORS: 'MONITORS'; -MONTHLY: 'MONTHLY'; -MOVE: 'MOVE'; -MULTI_STATEMENT_COUNT: 'MULTI_STATEMENT_COUNT'; +MIN_CLUSTER_COUNT : 'MIN_CLUSTER_COUNT'; +MIN_DATA_RETENTION_TIME_IN_DAYS : 'MIN_DATA_RETENTION_TIME_IN_DAYS'; +MODE : 'MODE'; +MODIFIED_AFTER : 'MODIFIED_AFTER'; +MODIFY : 'MODIFY'; +MONITOR : 'MONITOR'; +MONITORS : 'MONITORS'; +MONTHLY : 'MONTHLY'; +MOVE : 'MOVE'; +MULTI_STATEMENT_COUNT : 'MULTI_STATEMENT_COUNT'; // MULTI_USER: 'MULTI_USER'; // MUST_CHANGE: 'MUST_CHANGE'; -MUST_CHANGE_PASSWORD: 'MUST_CHANGE_PASSWORD'; -NAME: 'NAME'; -NATURAL: 'NATURAL'; +MUST_CHANGE_PASSWORD : 'MUST_CHANGE_PASSWORD'; +NAME : 'NAME'; +NATURAL : 'NATURAL'; // NESTED_TRIGGERS: 'NESTED_TRIGGERS'; -NETWORK: 'NETWORK'; -NETWORK_POLICY: 'NETWORK_POLICY'; -NEVER: 'NEVER'; +NETWORK : 'NETWORK'; +NETWORK_POLICY : 'NETWORK_POLICY'; +NEVER : 'NEVER'; // NEWID: 'NEWID'; // NEWNAME: 'NEWNAME'; // NEWSEQUENTIALID: 'NEWSEQUENTIALID'; // NEW_ACCOUNT: 'NEW_ACCOUNT'; // NEW_BROKER: 'NEW_BROKER'; // NEW_PASSWORD: 'NEW_PASSWORD'; -NEXT: 'NEXT'; -NEXTVAL: 'NEXTVAL'; -NO: 'NO'; -NONE: 'NONE'; -NONE_Q: '\'NONE\''; -NOORDER: 'NOORDER'; -NORELY: 'NORELY'; -NOT: 'NOT'; -NOTIFICATION: 'NOTIFICATION'; +NEXT : 'NEXT'; +NEXTVAL : 'NEXTVAL'; +NO : 'NO'; +NONE : 'NONE'; +NONE_Q : '\'NONE\''; +NOORDER : 'NOORDER'; +NORELY : 'NORELY'; +NOT : 'NOT'; +NOTIFICATION : 'NOTIFICATION'; // NOTIFICATIONS: 'NOTIFICATIONS'; -NOTIFICATION_INTEGRATION: 'NOTIFICATION_INTEGRATION'; -NOTIFICATION_PROVIDER: 'NOTIFICATION_PROVIDER'; -NOTIFY: 'NOTIFY'; -NOTIFY_USERS: 'NOTIFY_USERS'; -NOVALIDATE: 'NOVALIDATE'; -NTILE: 'NTILE'; -NULLIF: 'NULLIF'; -NULLS: 'NULLS'; -NULL_: 'NULL'; -NULL_IF: 'NULL_IF'; -NUMBER: 'NUMBER'; -NVL: 'NVL'; -NVL2: 'NVL2'; -OAUTH: 'OAUTH'; -OAUTH_ALLOW_NON_TLS_REDIRECT_URI: 'OAUTH_ALLOW_NON_TLS_REDIRECT_URI'; -OAUTH_CLIENT: 'OAUTH_CLIENT'; -OAUTH_CLIENT_RSA_PUBLIC_KEY: 'OAUTH_CLIENT_RSA_PUBLIC_KEY'; -OAUTH_CLIENT_RSA_PUBLIC_KEY_2: 'OAUTH_CLIENT_RSA_PUBLIC_KEY_2'; -OAUTH_ENFORCE_PKCE: 'OAUTH_ENFORCE_PKCE'; -OAUTH_ISSUE_REFRESH_TOKENS: 'OAUTH_ISSUE_REFRESH_TOKENS'; -OAUTH_REDIRECT_URI: 'OAUTH_REDIRECT_URI'; -OAUTH_REFRESH_TOKEN_VALIDITY: 'OAUTH_REFRESH_TOKEN_VALIDITY'; -OAUTH_USE_SECONDARY_ROLES: 'OAUTH_USE_SECONDARY_ROLES'; -OBJECT: 'OBJECT'; -OBJECT_Q: '\'OBJECT\''; -OBJECTS: 'OBJECTS'; -OBJECT_TYPES: 'OBJECT_TYPES'; -OF: 'OF'; +NOTIFICATION_INTEGRATION : 'NOTIFICATION_INTEGRATION'; +NOTIFICATION_PROVIDER : 'NOTIFICATION_PROVIDER'; +NOTIFY : 'NOTIFY'; +NOTIFY_USERS : 'NOTIFY_USERS'; +NOVALIDATE : 'NOVALIDATE'; +NTILE : 'NTILE'; +NULLIF : 'NULLIF'; +NULLS : 'NULLS'; +NULL_ : 'NULL'; +NULL_IF : 'NULL_IF'; +NUMBER : 'NUMBER'; +NVL : 'NVL'; +NVL2 : 'NVL2'; +OAUTH : 'OAUTH'; +OAUTH_ALLOW_NON_TLS_REDIRECT_URI : 'OAUTH_ALLOW_NON_TLS_REDIRECT_URI'; +OAUTH_CLIENT : 'OAUTH_CLIENT'; +OAUTH_CLIENT_RSA_PUBLIC_KEY : 'OAUTH_CLIENT_RSA_PUBLIC_KEY'; +OAUTH_CLIENT_RSA_PUBLIC_KEY_2 : 'OAUTH_CLIENT_RSA_PUBLIC_KEY_2'; +OAUTH_ENFORCE_PKCE : 'OAUTH_ENFORCE_PKCE'; +OAUTH_ISSUE_REFRESH_TOKENS : 'OAUTH_ISSUE_REFRESH_TOKENS'; +OAUTH_REDIRECT_URI : 'OAUTH_REDIRECT_URI'; +OAUTH_REFRESH_TOKEN_VALIDITY : 'OAUTH_REFRESH_TOKEN_VALIDITY'; +OAUTH_USE_SECONDARY_ROLES : 'OAUTH_USE_SECONDARY_ROLES'; +OBJECT : 'OBJECT'; +OBJECT_Q : '\'OBJECT\''; +OBJECTS : 'OBJECTS'; +OBJECT_TYPES : 'OBJECT_TYPES'; +OF : 'OF'; // OFF: 'OFF'; -OFFSET: 'OFFSET'; +OFFSET: 'OFFSET'; // OFFSETS: 'OFFSETS'; -OKTA: 'OKTA'; -OKTA_PROVISIONER_Q: '\'OKTA_PROVISIONER\''; -OKTA_Q: '\'OKTA\''; -OLD: 'OLD'; +OKTA : 'OKTA'; +OKTA_PROVISIONER_Q : '\'OKTA_PROVISIONER\''; +OKTA_Q : '\'OKTA\''; +OLD : 'OLD'; // OLD_ACCOUNT: 'OLD_ACCOUNT'; // OLD_PASSWORD: 'OLD_PASSWORD'; -OMIT: 'OMIT'; -ON: 'ON'; -ONE: 'ONE'; +OMIT : 'OMIT'; +ON : 'ON'; +ONE : 'ONE'; // ONLINE: 'ONLINE'; -ONLY: 'ONLY'; -ON_ERROR: 'ON_ERROR'; +ONLY : 'ONLY'; +ON_ERROR : 'ON_ERROR'; // ON_FAILURE: 'ON_FAILURE'; // OPEN: 'OPEN'; -OPERATE: 'OPERATE'; +OPERATE: 'OPERATE'; // OPERATIONS: 'OPERATIONS'; -OPTIMIZATION: 'OPTIMIZATION'; -OPTION: 'OPTION'; -OR: 'OR'; -ORC: 'ORC'; -ORC_Q: '\'ORC\''; -ORDER: 'ORDER'; -ORGADMIN: 'ORGADMIN'; -ORGANIZATION: 'ORGANIZATION'; -OUTBOUND: 'OUTBOUND'; -OUTER: 'OUTER'; -OVER: 'OVER'; -OVERRIDE: 'OVERRIDE'; -OVERWRITE: 'OVERWRITE'; -OWNER: 'OWNER'; -OWNERSHIP: 'OWNERSHIP'; +OPTIMIZATION : 'OPTIMIZATION'; +OPTION : 'OPTION'; +OR : 'OR'; +ORC : 'ORC'; +ORC_Q : '\'ORC\''; +ORDER : 'ORDER'; +ORGADMIN : 'ORGADMIN'; +ORGANIZATION : 'ORGANIZATION'; +OUTBOUND : 'OUTBOUND'; +OUTER : 'OUTER'; +OVER : 'OVER'; +OVERRIDE : 'OVERRIDE'; +OVERWRITE : 'OVERWRITE'; +OWNER : 'OWNER'; +OWNERSHIP : 'OWNERSHIP'; // PAGE: 'PAGE'; -PARALLEL: 'PARALLEL'; -PARAMETERS: 'PARAMETERS'; +PARALLEL : 'PARALLEL'; +PARAMETERS : 'PARAMETERS'; // PARAM_NODE: 'PARAM_NODE'; -PARQUET: 'PARQUET'; -PARQUET_Q: '\'PARQUET\''; -PARTIAL: 'PARTIAL'; -PARTITION: 'PARTITION'; +PARQUET : 'PARQUET'; +PARQUET_Q : '\'PARQUET\''; +PARTIAL : 'PARTIAL'; +PARTITION : 'PARTITION'; // PARTITIONS: 'PARTITIONS'; -PARTITION_TYPE: 'PARTITION_TYPE'; -PASSWORD: 'PASSWORD'; -PAST: 'PAST'; -PATH_: 'PATH'; -PATTERN: 'PATTERN'; -PER: 'PER'; -PERCENT: 'PERCENT'; +PARTITION_TYPE : 'PARTITION_TYPE'; +PASSWORD : 'PASSWORD'; +PAST : 'PAST'; +PATH_ : 'PATH'; +PATTERN : 'PATTERN'; +PER : 'PER'; +PERCENT : 'PERCENT'; // PERCENTILE_CONT: 'PERCENTILE_CONT'; // PERCENTILE_DISC: 'PERCENTILE_DISC'; // PERCENT_RANK: 'PERCENT_RANK'; -PERIODIC_DATA_REKEYING: 'PERIODIC_DATA_REKEYING'; +PERIODIC_DATA_REKEYING: 'PERIODIC_DATA_REKEYING'; // PERMISSION_SET: 'PERMISSION_SET'; // PERSISTED: 'PERSISTED'; // PERSIST_SAMPLE_PERCENT: 'PERSIST_SAMPLE_PERCENT'; -PING_FEDERATE: 'PING_FEDERATE'; -PIPE: 'PIPE'; -PIPES: 'PIPES'; -PIPE_EXECUTION_PAUSED: 'PIPE_EXECUTION_PAUSED'; -PIVOT: 'PIVOT'; +PING_FEDERATE : 'PING_FEDERATE'; +PIPE : 'PIPE'; +PIPES : 'PIPES'; +PIPE_EXECUTION_PAUSED : 'PIPE_EXECUTION_PAUSED'; +PIVOT : 'PIVOT'; // PLAN: 'PLAN'; // PLATFORM: 'PLATFORM'; -POLICIES: 'POLICIES'; -POLICY: 'POLICY'; +POLICIES : 'POLICIES'; +POLICY : 'POLICY'; // POOL: 'POOL'; // PORT: 'PORT'; // PRECEDING: 'PRECEDING'; // PREDICATE: 'PREDICATE'; -PREFIX: 'PREFIX'; -PRESERVE_SPACE: 'PRESERVE_SPACE'; -PREVENT_UNLOAD_TO_INLINE_URL: 'PREVENT_UNLOAD_TO_INLINE_URL'; -PREVENT_UNLOAD_TO_INTERNAL_STAGES: 'PREVENT_UNLOAD_TO_INTERNAL_STAGES'; -PRE_AUTHORIZED_ROLES_LIST: 'PRE_AUTHORIZED_ROLES_LIST'; -PRIMARY: 'PRIMARY'; +PREFIX : 'PREFIX'; +PRESERVE_SPACE : 'PRESERVE_SPACE'; +PREVENT_UNLOAD_TO_INLINE_URL : 'PREVENT_UNLOAD_TO_INLINE_URL'; +PREVENT_UNLOAD_TO_INTERNAL_STAGES : 'PREVENT_UNLOAD_TO_INTERNAL_STAGES'; +PRE_AUTHORIZED_ROLES_LIST : 'PRE_AUTHORIZED_ROLES_LIST'; +PRIMARY : 'PRIMARY'; // PRIMARY_ROLE: 'PRIMARY_ROLE'; -PRIOR: 'PRIOR'; +PRIOR: 'PRIOR'; // PRIORITY: 'PRIORITY'; // PRIORITY_LEVEL: 'PRIORITY_LEVEL'; // PRIVATE: 'PRIVATE'; // PRIVATE_KEY: 'PRIVATE_KEY'; -PRIVILEGES: 'PRIVILEGES'; +PRIVILEGES: 'PRIVILEGES'; // PROC: 'PROC'; -PROCEDURE: 'PROCEDURE'; -PROCEDURES: 'PROCEDURES'; -PROCEDURE_NAME: 'PROCEDURE_NAME'; +PROCEDURE : 'PROCEDURE'; +PROCEDURES : 'PROCEDURES'; +PROCEDURE_NAME : 'PROCEDURE_NAME'; // PROCESS: 'PROCESS'; // PROFILE: 'PROFILE'; // PROPERTY: 'PROPERTY'; // PROVIDER: 'PROVIDER'; // PROVIDER_KEY_NAME: 'PROVIDER_KEY_NAME'; -PUBLIC: 'PUBLIC'; -PURGE: 'PURGE'; -PUT: 'PUT'; +PUBLIC : 'PUBLIC'; +PURGE : 'PURGE'; +PUT : 'PUT'; // PYTHON: 'PYTHON'; -QUALIFY: 'QUALIFY'; -QUERIES: 'QUERIES'; +QUALIFY : 'QUALIFY'; +QUERIES : 'QUERIES'; // QUERY: 'QUERY'; -QUERY_ACCELERATION_MAX_SCALE_FACTOR: 'QUERY_ACCELERATION_MAX_SCALE_FACTOR'; -QUERY_TAG: 'QUERY_TAG'; -QUEUE: 'QUEUE'; -QUOTED_IDENTIFIERS_IGNORE_CASE: 'QUOTED_IDENTIFIERS_IGNORE_CASE'; +QUERY_ACCELERATION_MAX_SCALE_FACTOR : 'QUERY_ACCELERATION_MAX_SCALE_FACTOR'; +QUERY_TAG : 'QUERY_TAG'; +QUEUE : 'QUEUE'; +QUOTED_IDENTIFIERS_IGNORE_CASE : 'QUOTED_IDENTIFIERS_IGNORE_CASE'; // RANGE: 'RANGE'; -RANK: 'RANK'; -RAW_DEFLATE: 'RAW_DEFLATE'; -READ: 'READ'; -READER: 'READER'; +RANK : 'RANK'; +RAW_DEFLATE : 'RAW_DEFLATE'; +READ : 'READ'; +READER : 'READER'; // READONLY: 'READONLY'; // READPAST: 'READPAST'; // READTEXT: 'READTEXT'; @@ -687,182 +697,184 @@ READER: 'READER'; // READ_WRITE: 'READ_WRITE'; // REBUILD: 'REBUILD'; // RECEIVE: 'RECEIVE'; -RECLUSTER: 'RECLUSTER'; +RECLUSTER: 'RECLUSTER'; // RECOMPILE: 'RECOMPILE'; // RECONFIGURE: 'RECONFIGURE'; -RECORD_DELIMITER: 'RECORD_DELIMITER'; +RECORD_DELIMITER: 'RECORD_DELIMITER'; // RECOVERY: 'RECOVERY'; -RECURSIVE: 'RECURSIVE'; +RECURSIVE: 'RECURSIVE'; // RECURSIVE_TRIGGERS: 'RECURSIVE_TRIGGERS'; -REFERENCES: 'REFERENCES'; -REFERENCE_USAGE: 'REFERENCE_USAGE'; -REFRESH: 'REFRESH'; -REFRESH_ON_CREATE: 'REFRESH_ON_CREATE'; -REGION: 'REGION'; -REGIONS: 'REGIONS'; -REGION_GROUP: 'REGION_GROUP'; +REFERENCES : 'REFERENCES'; +REFERENCE_USAGE : 'REFERENCE_USAGE'; +REFRESH : 'REFRESH'; +REFRESH_ON_CREATE : 'REFRESH_ON_CREATE'; +REGION : 'REGION'; +REGIONS : 'REGIONS'; +REGION_GROUP : 'REGION_GROUP'; // RELATIVE: 'RELATIVE'; -RELY: 'RELY'; +RELY: 'RELY'; // REMOTE: 'REMOTE'; // REMOTE_PROC_TRANSACTIONS: 'REMOTE_PROC_TRANSACTIONS'; // REMOTE_SERVICE_NAME: 'REMOTE_SERVICE_NAME'; -REMOVE: 'REMOVE'; -RENAME: 'RENAME'; -REPEATABLE: 'REPEATABLE'; -REPLACE: 'REPLACE'; -REPLACE_INVALID_CHARACTERS: 'REPLACE_INVALID_CHARACTERS'; -REPLICA: 'REPLICA'; -REPLICATION: 'REPLICATION'; -REPLICATION_SCHEDULE: 'REPLICATION_SCHEDULE'; -REQUEST_TRANSLATOR: 'REQUEST_TRANSLATOR'; +REMOVE : 'REMOVE'; +RENAME : 'RENAME'; +REPEATABLE : 'REPEATABLE'; +REPLACE : 'REPLACE'; +REPLACE_INVALID_CHARACTERS : 'REPLACE_INVALID_CHARACTERS'; +REPLICA : 'REPLICA'; +REPLICATION : 'REPLICATION'; +REPLICATION_SCHEDULE : 'REPLICATION_SCHEDULE'; +REQUEST_TRANSLATOR : 'REQUEST_TRANSLATOR'; // REQUIRED: 'REQUIRED'; -REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION: 'REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION'; -REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION: 'REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION'; -RESET: 'RESET'; -RESOURCE: 'RESOURCE'; +REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION: 'REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION'; +REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION: + 'REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION' +; +RESET : 'RESET'; +RESOURCE : 'RESOURCE'; // RESOURCES: 'RESOURCES'; -RESOURCE_MONITOR: 'RESOURCE_MONITOR'; -RESPECT: 'RESPECT'; -RESPONSE_TRANSLATOR: 'RESPONSE_TRANSLATOR'; +RESOURCE_MONITOR : 'RESOURCE_MONITOR'; +RESPECT : 'RESPECT'; +RESPONSE_TRANSLATOR : 'RESPONSE_TRANSLATOR'; // RESTART: 'RESTART'; // RESTORE: 'RESTORE'; -RESTRICT: 'RESTRICT'; -RESTRICTIONS: 'RESTRICTIONS'; -RESULT: 'RESULT'; -RESUME: 'RESUME'; +RESTRICT : 'RESTRICT'; +RESTRICTIONS : 'RESTRICTIONS'; +RESULT : 'RESULT'; +RESUME : 'RESUME'; // RETAINDAYS: 'RETAINDAYS'; // RETURN: 'RETURN'; -RETURNS: 'RETURNS'; -RETURN_ALL_ERRORS: 'RETURN_ALL_ERRORS'; -RETURN_ERRORS: 'RETURN_ERRORS'; -RETURN_FAILED_ONLY: 'RETURN_FAILED_ONLY'; -RETURN_N_ROWS: 'RETURN_' DEC_DIGIT+ '_ROWS'; -RETURN_ROWS: 'RETURN_ROWS'; +RETURNS : 'RETURNS'; +RETURN_ALL_ERRORS : 'RETURN_ALL_ERRORS'; +RETURN_ERRORS : 'RETURN_ERRORS'; +RETURN_FAILED_ONLY : 'RETURN_FAILED_ONLY'; +RETURN_N_ROWS : 'RETURN_' DEC_DIGIT+ '_ROWS'; +RETURN_ROWS : 'RETURN_ROWS'; // REVERSE: 'REVERSE'; // REVERT: 'REVERT'; -REVOKE: 'REVOKE'; +REVOKE: 'REVOKE'; // REWIND: 'REWIND'; -RIGHT: 'RIGHT'; -RLIKE: 'RLIKE'; -ROLE: 'ROLE'; -ROLES: 'ROLES'; -ROLLBACK: 'ROLLBACK'; -ROLLUP: 'ROLLUP'; +RIGHT : 'RIGHT'; +RLIKE : 'RLIKE'; +ROLE : 'ROLE'; +ROLES : 'ROLES'; +ROLLBACK : 'ROLLBACK'; +ROLLUP : 'ROLLUP'; // ROOT: 'ROOT'; -ROW: 'ROW'; +ROW: 'ROW'; // ROWCOUNT: 'ROWCOUNT'; // ROWGUID: 'ROWGUID'; // ROWLOCK: 'ROWLOCK'; -ROWS: 'ROWS'; -ROWS_PER_RESULTSET: 'ROWS_PER_RESULTSET'; -ROW_NUMBER: 'ROW_NUMBER'; -RSA_PUBLIC_KEY: 'RSA_PUBLIC_KEY'; -RSA_PUBLIC_KEY_2: 'RSA_PUBLIC_KEY_2'; -RTRIM: 'RTRIM'; -RUN_AS_ROLE: 'RUN_AS_ROLE'; -S3: '\'S3\''; +ROWS : 'ROWS'; +ROWS_PER_RESULTSET : 'ROWS_PER_RESULTSET'; +ROW_NUMBER : 'ROW_NUMBER'; +RSA_PUBLIC_KEY : 'RSA_PUBLIC_KEY'; +RSA_PUBLIC_KEY_2 : 'RSA_PUBLIC_KEY_2'; +RTRIM : 'RTRIM'; +RUN_AS_ROLE : 'RUN_AS_ROLE'; +S3 : '\'S3\''; // SAFE: 'SAFE'; // SAFETY: 'SAFETY'; -SAML2: 'SAML2'; -SAML2_ENABLE_SP_INITIATED: 'SAML2_ENABLE_SP_INITIATED'; -SAML2_FORCE_AUTHN: 'SAML2_FORCE_AUTHN'; -SAML2_ISSUER: 'SAML2_ISSUER'; -SAML2_POST_LOGOUT_REDIRECT_URL: 'SAML2_POST_LOGOUT_REDIRECT_URL'; -SAML2_PROVIDER: 'SAML2_PROVIDER'; -SAML2_REQUESTED_NAMEID_FORMAT: 'SAML2_REQUESTED_NAMEID_FORMAT'; -SAML2_SIGN_REQUEST: 'SAML2_SIGN_REQUEST'; -SAML2_SNOWFLAKE_ACS_URL: 'SAML2_SNOWFLAKE_ACS_URL'; -SAML2_SNOWFLAKE_ISSUER_URL: 'SAML2_SNOWFLAKE_ISSUER_URL'; -SAML2_SNOWFLAKE_X509_CERT: 'SAML2_SNOWFLAKE_X509_CERT'; -SAML2_SP_INITIATED_LOGIN_PAGE_LABEL: 'SAML2_SP_INITIATED_LOGIN_PAGE_LABEL'; -SAML2_SSO_URL: 'SAML2_SSO_URL'; -SAML2_X509_CERT: 'SAML2_X509_CERT'; -SAML_IDENTITY_PROVIDER: 'SAML_IDENTITY_PROVIDER'; -SAMPLE: 'SAMPLE'; -SAVE_OLD_URL: 'SAVE_OLD_URL'; -SCALING_POLICY: 'SCALING_POLICY'; -SCHEDULE: 'SCHEDULE'; +SAML2 : 'SAML2'; +SAML2_ENABLE_SP_INITIATED : 'SAML2_ENABLE_SP_INITIATED'; +SAML2_FORCE_AUTHN : 'SAML2_FORCE_AUTHN'; +SAML2_ISSUER : 'SAML2_ISSUER'; +SAML2_POST_LOGOUT_REDIRECT_URL : 'SAML2_POST_LOGOUT_REDIRECT_URL'; +SAML2_PROVIDER : 'SAML2_PROVIDER'; +SAML2_REQUESTED_NAMEID_FORMAT : 'SAML2_REQUESTED_NAMEID_FORMAT'; +SAML2_SIGN_REQUEST : 'SAML2_SIGN_REQUEST'; +SAML2_SNOWFLAKE_ACS_URL : 'SAML2_SNOWFLAKE_ACS_URL'; +SAML2_SNOWFLAKE_ISSUER_URL : 'SAML2_SNOWFLAKE_ISSUER_URL'; +SAML2_SNOWFLAKE_X509_CERT : 'SAML2_SNOWFLAKE_X509_CERT'; +SAML2_SP_INITIATED_LOGIN_PAGE_LABEL : 'SAML2_SP_INITIATED_LOGIN_PAGE_LABEL'; +SAML2_SSO_URL : 'SAML2_SSO_URL'; +SAML2_X509_CERT : 'SAML2_X509_CERT'; +SAML_IDENTITY_PROVIDER : 'SAML_IDENTITY_PROVIDER'; +SAMPLE : 'SAMPLE'; +SAVE_OLD_URL : 'SAVE_OLD_URL'; +SCALING_POLICY : 'SCALING_POLICY'; +SCHEDULE : 'SCHEDULE'; // SCHEDULER: 'SCHEDULER'; -SCHEMA: 'SCHEMA'; -SCHEMAS: 'SCHEMAS'; +SCHEMA : 'SCHEMA'; +SCHEMAS : 'SCHEMAS'; // SCHEME: 'SCHEME'; -SCIM: 'SCIM'; -SCIM_CLIENT: 'SCIM_CLIENT'; +SCIM : 'SCIM'; +SCIM_CLIENT : 'SCIM_CLIENT'; // SCRIPT: 'SCRIPT'; -SEARCH: 'SEARCH'; -SECONDARY: 'SECONDARY'; +SEARCH : 'SEARCH'; +SECONDARY : 'SECONDARY'; // SECONDARY_ONLY: 'SECONDARY_ONLY'; // SECONDARY_ROLE: 'SECONDARY_ROLE'; // SECONDS: 'SECONDS'; // SECRET: 'SECRET'; -SECURE: 'SECURE'; -SECURITY: 'SECURITY'; -SECURITYADMIN: 'SECURITYADMIN'; -SEED: 'SEED'; -SELECT: 'SELECT'; +SECURE : 'SECURE'; +SECURITY : 'SECURITY'; +SECURITYADMIN : 'SECURITYADMIN'; +SEED : 'SEED'; +SELECT : 'SELECT'; // SELF: 'SELF'; -SEQUENCE: 'SEQUENCE'; -SEQUENCES: 'SEQUENCES'; +SEQUENCE : 'SEQUENCE'; +SEQUENCES : 'SEQUENCES'; // SERVER: 'SERVER'; // SERVICE: 'SERVICE'; -SESSION: 'SESSION'; -SESSION_IDLE_TIMEOUT_MINS: 'SESSION_IDLE_TIMEOUT_MINS'; -SESSION_POLICY: 'SESSION_POLICY'; -SESSION_UI_IDLE_TIMEOUT_MINS: 'SESSION_UI_IDLE_TIMEOUT_MINS'; -SET: 'SET'; -SETS: 'SETS'; +SESSION : 'SESSION'; +SESSION_IDLE_TIMEOUT_MINS : 'SESSION_IDLE_TIMEOUT_MINS'; +SESSION_POLICY : 'SESSION_POLICY'; +SESSION_UI_IDLE_TIMEOUT_MINS : 'SESSION_UI_IDLE_TIMEOUT_MINS'; +SET : 'SET'; +SETS : 'SETS'; // SETUSER: 'SETUSER'; -SHARE: 'SHARE'; +SHARE: 'SHARE'; // SHARED: 'SHARED'; -SHARES: 'SHARES'; -SHARE_RESTRICTIONS: 'SHARE_RESTRICTIONS'; -SHOW: 'SHOW'; -SHOW_INITIAL_ROWS: 'SHOW_INITIAL_ROWS'; +SHARES : 'SHARES'; +SHARE_RESTRICTIONS : 'SHARE_RESTRICTIONS'; +SHOW : 'SHOW'; +SHOW_INITIAL_ROWS : 'SHOW_INITIAL_ROWS'; // SIGNATURE: 'SIGNATURE'; -SIMPLE: 'SIMPLE'; -SIMULATED_DATA_SHARING_CONSUMER: 'SIMULATED_DATA_SHARING_CONSUMER'; +SIMPLE : 'SIMPLE'; +SIMULATED_DATA_SHARING_CONSUMER : 'SIMULATED_DATA_SHARING_CONSUMER'; // SINGLE_USER: 'SINGLE_USER'; // SIZE: 'SIZE'; -SIZE_LIMIT: 'SIZE_LIMIT'; -SKIP_: 'SKIP'; -SKIP_BLANK_LINES: 'SKIP_BLANK_LINES'; -SKIP_BYTE_ORDER_MARK: 'SKIP_BYTE_ORDER_MARK'; -SKIP_FILE: 'SKIP_FILE'; -SKIP_FILE_N: 'SKIP_FILE_' DEC_DIGIT+; -SKIP_HEADER: 'SKIP_HEADER'; -SMALL: 'SMALL'; -SNAPPY: 'SNAPPY'; -SNAPPY_COMPRESSION: 'SNAPPY_COMPRESSION'; -SNOWFLAKE_FULL: 'SNOWFLAKE_FULL'; -SNOWFLAKE_SSE: 'SNOWFLAKE_SSE'; -SNOWPARK_OPTIMIZED: '\'SNOWPARK-OPTIMIZED\''; -SOME: 'SOME'; +SIZE_LIMIT : 'SIZE_LIMIT'; +SKIP_ : 'SKIP'; +SKIP_BLANK_LINES : 'SKIP_BLANK_LINES'; +SKIP_BYTE_ORDER_MARK : 'SKIP_BYTE_ORDER_MARK'; +SKIP_FILE : 'SKIP_FILE'; +SKIP_FILE_N : 'SKIP_FILE_' DEC_DIGIT+; +SKIP_HEADER : 'SKIP_HEADER'; +SMALL : 'SMALL'; +SNAPPY : 'SNAPPY'; +SNAPPY_COMPRESSION : 'SNAPPY_COMPRESSION'; +SNOWFLAKE_FULL : 'SNOWFLAKE_FULL'; +SNOWFLAKE_SSE : 'SNOWFLAKE_SSE'; +SNOWPARK_OPTIMIZED : '\'SNOWPARK-OPTIMIZED\''; +SOME : 'SOME'; // SOUNDEX: 'SOUNDEX'; -SOURCE: 'SOURCE'; -SOURCE_COMPRESSION: 'SOURCE_COMPRESSION'; +SOURCE : 'SOURCE'; +SOURCE_COMPRESSION : 'SOURCE_COMPRESSION'; // SPACE_KEYWORD: 'SPACE'; // SPARSE: 'SPARSE'; // SPECIFICATION: 'SPECIFICATION'; -SPLIT: 'SPLIT'; -SPLIT_PART: 'SPLIT_PART'; -SPLIT_TO_TABLE: 'SPLIT_TO_TABLE'; -SQL: 'SQL'; -SSO_LOGIN_PAGE: 'SSO_LOGIN_PAGE'; -STAGE: 'STAGE'; -STAGES: 'STAGES'; -STAGE_COPY_OPTIONS: 'STAGE_COPY_OPTIONS'; -STAGE_FILE_FORMAT: 'STAGE_FILE_FORMAT'; -STANDARD: 'STANDARD'; +SPLIT : 'SPLIT'; +SPLIT_PART : 'SPLIT_PART'; +SPLIT_TO_TABLE : 'SPLIT_TO_TABLE'; +SQL : 'SQL'; +SSO_LOGIN_PAGE : 'SSO_LOGIN_PAGE'; +STAGE : 'STAGE'; +STAGES : 'STAGES'; +STAGE_COPY_OPTIONS : 'STAGE_COPY_OPTIONS'; +STAGE_FILE_FORMAT : 'STAGE_FILE_FORMAT'; +STANDARD : 'STANDARD'; // STANDBY: 'STANDBY'; -START: 'START'; +START: 'START'; // STARTED: 'STARTED'; -STARTS: 'STARTS'; +STARTS: 'STARTS'; // START_DATE: 'START_DATE'; -START_TIMESTAMP: 'START_TIMESTAMP'; -STATE: 'STATE'; -STATEMENT: 'STATEMENT'; -STATEMENT_QUEUED_TIMEOUT_IN_SECONDS: 'STATEMENT_QUEUED_TIMEOUT_IN_SECONDS'; -STATEMENT_TIMEOUT_IN_SECONDS: 'STATEMENT_TIMEOUT_IN_SECONDS'; +START_TIMESTAMP : 'START_TIMESTAMP'; +STATE : 'STATE'; +STATEMENT : 'STATEMENT'; +STATEMENT_QUEUED_TIMEOUT_IN_SECONDS : 'STATEMENT_QUEUED_TIMEOUT_IN_SECONDS'; +STATEMENT_TIMEOUT_IN_SECONDS : 'STATEMENT_TIMEOUT_IN_SECONDS'; // STATIC: 'STATIC'; // STATISTICS: 'STATISTICS'; // STATS: 'STATS'; @@ -875,109 +887,109 @@ STATEMENT_TIMEOUT_IN_SECONDS: 'STATEMENT_TIMEOUT_IN_SEC // STOP: 'STOP'; // STOPLIST: 'STOPLIST'; // STOPPED: 'STOPPED'; -STORAGE: 'STORAGE'; -STORAGE_ALLOWED_LOCATIONS: 'STORAGE_ALLOWED_LOCATIONS'; -STORAGE_AWS_OBJECT_ACL: 'STORAGE_AWS_OBJECT_ACL'; -STORAGE_AWS_ROLE_ARN: 'STORAGE_AWS_ROLE_ARN'; -STORAGE_BLOCKED_LOCATIONS: 'STORAGE_BLOCKED_LOCATIONS'; -STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'; -STORAGE_PROVIDER: 'STORAGE_PROVIDER'; +STORAGE : 'STORAGE'; +STORAGE_ALLOWED_LOCATIONS : 'STORAGE_ALLOWED_LOCATIONS'; +STORAGE_AWS_OBJECT_ACL : 'STORAGE_AWS_OBJECT_ACL'; +STORAGE_AWS_ROLE_ARN : 'STORAGE_AWS_ROLE_ARN'; +STORAGE_BLOCKED_LOCATIONS : 'STORAGE_BLOCKED_LOCATIONS'; +STORAGE_INTEGRATION : 'STORAGE_INTEGRATION'; +STORAGE_PROVIDER : 'STORAGE_PROVIDER'; // STR: 'STR'; -STREAM: 'STREAM'; -STREAMS: 'STREAMS'; -STRICT: 'STRICT'; -STRICT_JSON_OUTPUT: 'STRICT_JSON_OUTPUT'; +STREAM : 'STREAM'; +STREAMS : 'STREAMS'; +STRICT : 'STRICT'; +STRICT_JSON_OUTPUT : 'STRICT_JSON_OUTPUT'; // STRING_AGG: 'STRING_AGG'; // STRING_ESCAPE: 'STRING_ESCAPE'; -STRIP_NULL_VALUES: 'STRIP_NULL_VALUES'; -STRIP_OUTER_ARRAY: 'STRIP_OUTER_ARRAY'; -STRIP_OUTER_ELEMENT: 'STRIP_OUTER_ELEMENT'; -SUBSTR: 'SUBSTR'; -SUBSTRING: 'SUBSTRING'; -SUM: 'SUM'; +STRIP_NULL_VALUES : 'STRIP_NULL_VALUES'; +STRIP_OUTER_ARRAY : 'STRIP_OUTER_ARRAY'; +STRIP_OUTER_ELEMENT : 'STRIP_OUTER_ELEMENT'; +SUBSTR : 'SUBSTR'; +SUBSTRING : 'SUBSTRING'; +SUM : 'SUM'; // SUPPORTED: 'SUPPORTED'; -SUSPEND: 'SUSPEND'; -SUSPENDED: 'SUSPENDED'; -SUSPEND_IMMEDIATE: 'SUSPEND_IMMEDIATE'; -SUSPEND_TASK_AFTER_NUM_FAILURES: 'SUSPEND_TASK_AFTER_NUM_FAILURES'; -SWAP: 'SWAP'; +SUSPEND : 'SUSPEND'; +SUSPENDED : 'SUSPENDED'; +SUSPEND_IMMEDIATE : 'SUSPEND_IMMEDIATE'; +SUSPEND_TASK_AFTER_NUM_FAILURES : 'SUSPEND_TASK_AFTER_NUM_FAILURES'; +SWAP : 'SWAP'; // SWITCH: 'SWITCH'; -SYNC_PASSWORD: 'SYNC_PASSWORD'; -SYSADMIN: 'SYSADMIN'; -SYSTEM: 'SYSTEM'; +SYNC_PASSWORD : 'SYNC_PASSWORD'; +SYSADMIN : 'SYSADMIN'; +SYSTEM : 'SYSTEM'; // SYSTEM_USER: 'SYSTEM_USER'; -TABLE: 'TABLE'; -TABLEAU_DESKTOP: 'TABLEAU_DESKTOP'; -TABLEAU_SERVER: 'TABLEAU_SERVER'; -TABLES: 'TABLES'; -TABLESAMPLE: 'TABLESAMPLE'; -TABLE_FORMAT: 'TABLE_FORMAT'; -TABULAR: 'TABULAR'; -TAG: 'TAG'; -TAGS: 'TAGS'; +TABLE : 'TABLE'; +TABLEAU_DESKTOP : 'TABLEAU_DESKTOP'; +TABLEAU_SERVER : 'TABLEAU_SERVER'; +TABLES : 'TABLES'; +TABLESAMPLE : 'TABLESAMPLE'; +TABLE_FORMAT : 'TABLE_FORMAT'; +TABULAR : 'TABULAR'; +TAG : 'TAG'; +TAGS : 'TAGS'; // TARGET: 'TARGET'; -TARGET_LAG: 'TARGET_LAG'; -TASK: 'TASK'; -TASKS: 'TASKS'; -TEMP: 'TEMP'; -TEMPORARY: 'TEMPORARY'; -TERSE: 'TERSE'; +TARGET_LAG : 'TARGET_LAG'; +TASK : 'TASK'; +TASKS : 'TASKS'; +TEMP : 'TEMP'; +TEMPORARY : 'TEMPORARY'; +TERSE : 'TERSE'; // TEXTSIZE: 'TEXTSIZE'; -THEN: 'THEN'; +THEN: 'THEN'; // TIES: 'TIES'; -TIME: 'TIME'; -TIMEADD: 'TIMEADD'; -TIMEDIFF: 'TIMEDIFF'; +TIME : 'TIME'; +TIMEADD : 'TIMEADD'; +TIMEDIFF : 'TIMEDIFF'; // TIMEOUT: 'TIMEOUT'; // TIMER: 'TIMER'; -TIMESTAMP: 'TIMESTAMP'; -TIMESTAMP_DAY_IS_ALWAYS_24H: 'TIMESTAMP_DAY_IS_ALWAYS_24H'; -TIMESTAMP_FORMAT: 'TIMESTAMP_FORMAT'; -TIMESTAMP_INPUT_FORMAT: 'TIMESTAMP_INPUT_FORMAT'; -TIMESTAMP_LTZ: 'TIMESTAMP' '_'? 'LTZ'; -TIMESTAMP_LTZ_OUTPUT_FORMAT: 'TIMESTAMP_LTZ_OUTPUT_FORMAT'; -TIMESTAMP_NTZ: 'TIMESTAMP' '_'? 'NTZ'; -TIMESTAMP_NTZ_OUTPUT_FORMAT: 'TIMESTAMP_NTZ_OUTPUT_FORMAT'; -TIMESTAMP_OUTPUT_FORMAT: 'TIMESTAMP_OUTPUT_FORMAT'; -TIMESTAMP_TYPE_MAPPING: 'TIMESTAMP_TYPE_MAPPING'; -TIMESTAMP_TZ: 'TIMESTAMP' '_'? 'TZ'; -TIMESTAMP_TZ_OUTPUT_FORMAT: 'TIMESTAMP_TZ_OUTPUT_FORMAT'; -TIMESTAMPADD: 'TIMESTAMPADD'; -TIMESTAMPDIFF: 'TIMESTAMPDIFF'; -TIMEZONE: 'TIMEZONE'; -TIME_FORMAT: 'TIME_FORMAT'; -TIME_INPUT_FORMAT: 'TIME_INPUT_FORMAT'; -TIME_OUTPUT_FORMAT: 'TIME_OUTPUT_FORMAT'; -TO: 'TO'; -TO_BOOLEAN: 'TO_BOOLEAN'; -TO_DATE: 'TO_DATE'; -TOP: 'TOP'; +TIMESTAMP : 'TIMESTAMP'; +TIMESTAMP_DAY_IS_ALWAYS_24H : 'TIMESTAMP_DAY_IS_ALWAYS_24H'; +TIMESTAMP_FORMAT : 'TIMESTAMP_FORMAT'; +TIMESTAMP_INPUT_FORMAT : 'TIMESTAMP_INPUT_FORMAT'; +TIMESTAMP_LTZ : 'TIMESTAMP' '_'? 'LTZ'; +TIMESTAMP_LTZ_OUTPUT_FORMAT : 'TIMESTAMP_LTZ_OUTPUT_FORMAT'; +TIMESTAMP_NTZ : 'TIMESTAMP' '_'? 'NTZ'; +TIMESTAMP_NTZ_OUTPUT_FORMAT : 'TIMESTAMP_NTZ_OUTPUT_FORMAT'; +TIMESTAMP_OUTPUT_FORMAT : 'TIMESTAMP_OUTPUT_FORMAT'; +TIMESTAMP_TYPE_MAPPING : 'TIMESTAMP_TYPE_MAPPING'; +TIMESTAMP_TZ : 'TIMESTAMP' '_'? 'TZ'; +TIMESTAMP_TZ_OUTPUT_FORMAT : 'TIMESTAMP_TZ_OUTPUT_FORMAT'; +TIMESTAMPADD : 'TIMESTAMPADD'; +TIMESTAMPDIFF : 'TIMESTAMPDIFF'; +TIMEZONE : 'TIMEZONE'; +TIME_FORMAT : 'TIME_FORMAT'; +TIME_INPUT_FORMAT : 'TIME_INPUT_FORMAT'; +TIME_OUTPUT_FORMAT : 'TIME_OUTPUT_FORMAT'; +TO : 'TO'; +TO_BOOLEAN : 'TO_BOOLEAN'; +TO_DATE : 'TO_DATE'; +TOP : 'TOP'; // TRACKING: 'TRACKING'; // TRACK_CAUSALITY: 'TRACK_CAUSALITY'; // TRAN: 'TRAN'; -TRANSACTION: 'TRANSACTION'; -TRANSACTIONS: 'TRANSACTIONS'; -TRANSACTION_ABORT_ON_ERROR: 'TRANSACTION_ABORT_ON_ERROR'; -TRANSACTION_DEFAULT_ISOLATION_LEVEL: 'TRANSACTION_DEFAULT_ISOLATION_LEVEL'; +TRANSACTION : 'TRANSACTION'; +TRANSACTIONS : 'TRANSACTIONS'; +TRANSACTION_ABORT_ON_ERROR : 'TRANSACTION_ABORT_ON_ERROR'; +TRANSACTION_DEFAULT_ISOLATION_LEVEL : 'TRANSACTION_DEFAULT_ISOLATION_LEVEL'; // TRANSACTION_ID: 'TRANSACTION_ID'; // TRANSFORM_NOISE_WORDS: 'TRANSFORM_NOISE_WORDS'; -TRANSIENT: 'TRANSIENT'; +TRANSIENT: 'TRANSIENT'; // TRANSLATE: 'TRANSLATE'; // TRIGGER: 'TRIGGER'; -TRIGGERS: 'TRIGGERS'; -TRIM: 'TRIM'; -TRIM_SPACE: 'TRIM_SPACE'; +TRIGGERS : 'TRIGGERS'; +TRIM : 'TRIM'; +TRIM_SPACE : 'TRIM_SPACE'; // TRIPLE_DES: 'TRIPLE_DES'; // TRIPLE_DES_3KEY: 'TRIPLE_DES_3KEY'; -TRUE: 'TRUE'; -TRUNCATE: 'TRUNCATE'; -TRUNCATECOLUMNS: 'TRUNCATECOLUMNS'; +TRUE : 'TRUE'; +TRUNCATE : 'TRUNCATE'; +TRUNCATECOLUMNS : 'TRUNCATECOLUMNS'; // TRY: 'TRY'; -TRY_CAST: 'TRY_CAST'; +TRY_CAST: 'TRY_CAST'; // TSEQUAL: 'TSEQUAL'; -TWO_DIGIT_CENTURY_START: 'TWO_DIGIT_CENTURY_START'; +TWO_DIGIT_CENTURY_START: 'TWO_DIGIT_CENTURY_START'; // TWO_DIGIT_YEAR_CUTOFF: 'TWO_DIGIT_YEAR_CUTOFF'; -TYPE: 'TYPE'; +TYPE: 'TYPE'; // TYPEPROPERTY: 'TYPEPROPERTY'; // TYPE_ID: 'TYPE_ID'; // TYPE_NAME: 'TYPE_NAME'; @@ -986,208 +998,197 @@ TYPE: 'TYPE'; // UNBOUNDED: 'UNBOUNDED'; // UNCHECKED: 'UNCHECKED'; // UNCOMMITTED: 'UNCOMMITTED'; -UNDROP: 'UNDROP'; +UNDROP: 'UNDROP'; // UNICODE: 'UNICODE'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; // UNKNOWN: 'UNKNOWN'; // UNLIMITED: 'UNLIMITED'; // UNLOCK: 'UNLOCK'; // UNMASK: 'UNMASK'; -UNMATCHED: 'UNMATCHED'; -UNPIVOT: 'UNPIVOT'; +UNMATCHED : 'UNMATCHED'; +UNPIVOT : 'UNPIVOT'; // UNSAFE: 'UNSAFE'; -UNSET: 'UNSET'; -UNSUPPORTED_DDL_ACTION: 'UNSUPPORTED_DDL_ACTION'; +UNSET : 'UNSET'; +UNSUPPORTED_DDL_ACTION : 'UNSUPPORTED_DDL_ACTION'; // UOW: 'UOW'; -UPDATE: 'UPDATE'; +UPDATE: 'UPDATE'; // UPDLOCK: 'UPDLOCK'; -UPPER: 'UPPER'; -URL: 'URL'; -USAGE: 'USAGE'; -USE: 'USE'; +UPPER : 'UPPER'; +URL : 'URL'; +USAGE : 'USAGE'; +USE : 'USE'; // USED: 'USED'; -USER: 'USER'; -USERADMIN: 'USERADMIN'; -USERS: 'USERS'; -USER_SPECIFIED: 'USER_SPECIFIED'; -USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE: 'USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE'; -USER_TASK_TIMEOUT_MS: 'USER_TASK_TIMEOUT_MS'; -USE_ANY_ROLE: 'USE_ANY_ROLE'; -USE_CACHED_RESULT: 'USE_CACHED_RESULT'; -USING: 'USING'; -UTF8: 'UTF8'; -VALIDATE: 'VALIDATE'; +USER : 'USER'; +USERADMIN : 'USERADMIN'; +USERS : 'USERS'; +USER_SPECIFIED : 'USER_SPECIFIED'; +USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE : 'USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE'; +USER_TASK_TIMEOUT_MS : 'USER_TASK_TIMEOUT_MS'; +USE_ANY_ROLE : 'USE_ANY_ROLE'; +USE_CACHED_RESULT : 'USE_CACHED_RESULT'; +USING : 'USING'; +UTF8 : 'UTF8'; +VALIDATE : 'VALIDATE'; // VALIDATION: 'VALIDATION'; -VALIDATION_MODE: 'VALIDATION_MODE'; +VALIDATION_MODE: 'VALIDATION_MODE'; // VALID_XML: 'VALID_XML'; -VALUE: 'VALUE'; -VALUES: 'VALUES'; +VALUE : 'VALUE'; +VALUES : 'VALUES'; // VAR: 'VAR'; -VARIABLES: 'VARIABLES'; +VARIABLES: 'VARIABLES'; // VARP: 'VARP'; // VARYING: 'VARYING'; -VERSION: 'VERSION'; -VIEW: 'VIEW'; -VIEWS: 'VIEWS'; +VERSION : 'VERSION'; +VIEW : 'VIEW'; +VIEWS : 'VIEWS'; // VIEW_METADATA: 'VIEW_METADATA'; // VISIBILITY: 'VISIBILITY'; -VOLATILE: 'VOLATILE'; +VOLATILE: 'VOLATILE'; // WAIT: 'WAIT'; -WAREHOUSE: 'WAREHOUSE'; -WAREHOUSES: 'WAREHOUSES'; -WAREHOUSE_SIZE: 'WAREHOUSE_SIZE'; -WAREHOUSE_TYPE: 'WAREHOUSE_TYPE'; -WEEKLY: 'WEEKLY'; -WEEK_OF_YEAR_POLICY: 'WEEK_OF_YEAR_POLICY'; -WEEK_START: 'WEEK_START'; +WAREHOUSE : 'WAREHOUSE'; +WAREHOUSES : 'WAREHOUSES'; +WAREHOUSE_SIZE : 'WAREHOUSE_SIZE'; +WAREHOUSE_TYPE : 'WAREHOUSE_TYPE'; +WEEKLY : 'WEEKLY'; +WEEK_OF_YEAR_POLICY : 'WEEK_OF_YEAR_POLICY'; +WEEK_START : 'WEEK_START'; // WELL_FORMED_XML: 'WELL_FORMED_XML'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WITH: 'WITH'; -WITHIN: 'WITHIN'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WITH : 'WITH'; +WITHIN : 'WITHIN'; // WITHOUT: 'WITHOUT'; // WITHOUT_ARRAY_WRAPPER: 'WITHOUT_ARRAY_WRAPPER'; -WORK: 'WORK'; +WORK: 'WORK'; // WORKLOAD: 'WORKLOAD'; -WRITE: 'WRITE'; -X4LARGE: 'X4LARGE'; -X5LARGE: 'X5LARGE'; -X6LARGE: 'X6LARGE'; -XLARGE: 'XLARGE'; -XML: 'XML'; -XML_Q: '\'XML\''; -XSMALL: 'XSMALL'; -XXLARGE: 'XXLARGE'; -XXXLARGE: 'XXXLARGE'; -YEARLY: 'YEARLY'; -ZSTD: 'ZSTD'; - +WRITE : 'WRITE'; +X4LARGE : 'X4LARGE'; +X5LARGE : 'X5LARGE'; +X6LARGE : 'X6LARGE'; +XLARGE : 'XLARGE'; +XML : 'XML'; +XML_Q : '\'XML\''; +XSMALL : 'XSMALL'; +XXLARGE : 'XXLARGE'; +XXXLARGE : 'XXXLARGE'; +YEARLY : 'YEARLY'; +ZSTD : 'ZSTD'; -ARRAY: 'ARRAY'; -ARRAY_Q: '\'ARRAY\''; -BIGINT: 'BIGINT'; -BINARY: 'BINARY'; -BOOLEAN: 'BOOLEAN'; -BYTEINT: 'BYTEINT'; -CHAR_VARYING: 'CHAR VARYING'; -DATE: 'DATE'; -DATETIME: 'DATETIME'; -DECIMAL_: 'DECIMAL'; -DOUBLE: 'DOUBLE'; -DOUBLE_PRECISION: 'DOUBLE PRECISION'; -FLOAT4: 'FLOAT4'; -FLOAT8: 'FLOAT8'; -FLOAT_: 'FLOAT'; -GEOGRAPHY: 'GEOGRAPHY'; -GEOMETRY: 'GEOMETRY'; -INTEGER: 'INTEGER'; -NCHAR: 'NCHAR'; -NCHAR_VARYING: 'NCHAR VARYING'; -NUMERIC: 'NUMERIC'; -NVARCHAR2: 'NVARCHAR2'; -NVARCHAR: 'NVARCHAR'; -REAL_: 'REAL'; -SMALLINT: 'SMALLINT'; -STRING_: 'STRING'; -TEXT: 'TEXT'; -TINYINT: 'TINYINT'; -VARBINARY: 'VARBINARY'; -VARCHAR: 'VARCHAR'; -VARIANT: 'VARIANT'; +ARRAY : 'ARRAY'; +ARRAY_Q : '\'ARRAY\''; +BIGINT : 'BIGINT'; +BINARY : 'BINARY'; +BOOLEAN : 'BOOLEAN'; +BYTEINT : 'BYTEINT'; +CHAR_VARYING : 'CHAR VARYING'; +DATE : 'DATE'; +DATETIME : 'DATETIME'; +DECIMAL_ : 'DECIMAL'; +DOUBLE : 'DOUBLE'; +DOUBLE_PRECISION : 'DOUBLE PRECISION'; +FLOAT4 : 'FLOAT4'; +FLOAT8 : 'FLOAT8'; +FLOAT_ : 'FLOAT'; +GEOGRAPHY : 'GEOGRAPHY'; +GEOMETRY : 'GEOMETRY'; +INTEGER : 'INTEGER'; +NCHAR : 'NCHAR'; +NCHAR_VARYING : 'NCHAR VARYING'; +NUMERIC : 'NUMERIC'; +NVARCHAR2 : 'NVARCHAR2'; +NVARCHAR : 'NVARCHAR'; +REAL_ : 'REAL'; +SMALLINT : 'SMALLINT'; +STRING_ : 'STRING'; +TEXT : 'TEXT'; +TINYINT : 'TINYINT'; +VARBINARY : 'VARBINARY'; +VARCHAR : 'VARCHAR'; +VARIANT : 'VARIANT'; LISTAGG: 'LISTAGG'; DUMMY: 'DUMMY'; //Dummy is not a keyword but rules reference it. As to be cleaned. +SPACE: [ \t\r\n]+ -> channel(HIDDEN); -SPACE: [ \t\r\n]+ -> channel(HIDDEN); - -SQL_COMMENT: '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); -LINE_COMMENT: '--' ~[\r\n]* -> channel(HIDDEN); -LINE_COMMENT_2: '//' ~[\r\n]* -> channel(HIDDEN); +SQL_COMMENT : '/*' (SQL_COMMENT | .)*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); +LINE_COMMENT_2 : '//' ~[\r\n]* -> channel(HIDDEN); // TODO: ID can be not only Latin. -DOUBLE_QUOTE_ID: '"' ~'"'+ '"'; -DOUBLE_QUOTE_BLANK: '""'; -SINGLE_QUOTE: '\''; +DOUBLE_QUOTE_ID : '"' ~'"'+ '"'; +DOUBLE_QUOTE_BLANK : '""'; +SINGLE_QUOTE : '\''; -ID: [A-Z_] [A-Z0-9_@$]*; -ID2: DOLLAR [A-Z_] [A-Z0-9_]*; +ID : [A-Z_] [A-Z0-9_@$]*; +ID2 : DOLLAR [A-Z_] [A-Z0-9_]*; -S3_PATH: SINGLE_QUOTE 's3://' Uri SINGLE_QUOTE; -S3GOV_PATH: SINGLE_QUOTE 's3gov://' Uri SINGLE_QUOTE; -GCS_PATH: SINGLE_QUOTE 'gcs://' Uri SINGLE_QUOTE; -AZURE_PATH: SINGLE_QUOTE 'azure://' Uri SINGLE_QUOTE; -FILE_PATH: 'file://' ( DIVIDE Uri | WindowsPath ); //file:/// +S3_PATH : SINGLE_QUOTE 's3://' Uri SINGLE_QUOTE; +S3GOV_PATH : SINGLE_QUOTE 's3gov://' Uri SINGLE_QUOTE; +GCS_PATH : SINGLE_QUOTE 'gcs://' Uri SINGLE_QUOTE; +AZURE_PATH : SINGLE_QUOTE 'azure://' Uri SINGLE_QUOTE; +FILE_PATH : 'file://' ( DIVIDE Uri | WindowsPath); //file:/// -DBL_DOLLAR: '$$' (~'$' | '\\$' | '$' ~'$')*? '$$'; +DBL_DOLLAR: '$$' (~'$' | '\\$' | '$' ~'$')*? '$$'; -STRING: '\'' (~'\'' | '\'\'')* '\''; +STRING: '\'' (~'\'' | '\'\'')* '\''; -DECIMAL: DEC_DIGIT+; -FLOAT: DEC_DOT_DEC; -REAL: (DECIMAL | DEC_DOT_DEC) 'E' [+-]? DEC_DIGIT+; +DECIMAL : DEC_DIGIT+; +FLOAT : DEC_DOT_DEC; +REAL : (DECIMAL | DEC_DOT_DEC) 'E' [+-]? DEC_DIGIT+; -CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; +CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; -fragment EscapeSequence - : '\\' [btnfr"'\\] +fragment EscapeSequence: + '\\' [btnfr"'\\] | '\\' ([0-3]? [0-7])? [0-7] | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; +; -fragment HexDigit - : [0-9a-f] - ; +fragment HexDigit: [0-9a-f]; -fragment HexString - : [A-Z0-9|.] [A-Z0-9+\-|.]* - ; +fragment HexString: [A-Z0-9|.] [A-Z0-9+\-|.]*; -fragment Uri - : HexString (DIVIDE HexString)* DIVIDE? - ; +fragment Uri: HexString (DIVIDE HexString)* DIVIDE?; -fragment WindowsPath - : [A-Z] COLON '\\' HexString ('\\' HexString)* '\\'? - ; +fragment WindowsPath: [A-Z] COLON '\\' HexString ('\\' HexString)* '\\'?; -ARROW: '->'; -ASSOC: '=>'; +ARROW : '->'; +ASSOC : '=>'; -NE: '!='; -LTGT: '<>'; -EQ: '='; -GT: '>'; -GE: '>='; -LT: '<'; -LE: '<='; +NE : '!='; +LTGT : '<>'; +EQ : '='; +GT : '>'; +GE : '>='; +LT : '<'; +LE : '<='; // EXCLAMATION: '!'; - -PIPE_PIPE: '||'; -DOT: '.'; +PIPE_PIPE : '||'; +DOT : '.'; // UNDERLINE: '_'; -AT: '@'; -AT_Q: '\'@\''; +AT : '@'; +AT_Q : '\'@\''; //HASH: '#'; -DOLLAR: '$'; -LR_BRACKET: '('; -RR_BRACKET: ')'; -LSB: '['; -RSB: ']'; -LCB: '{'; -RCB: '}'; -COMMA: ','; -SEMI: ';'; -COLON: ':'; -COLON_COLON: '::'; -STAR: '*'; -DIVIDE: '/'; -MODULE: '%'; -PLUS: '+'; -MINUS: '-'; +DOLLAR : '$'; +LR_BRACKET : '('; +RR_BRACKET : ')'; +LSB : '['; +RSB : ']'; +LCB : '{'; +RCB : '}'; +COMMA : ','; +SEMI : ';'; +COLON : ':'; +COLON_COLON : '::'; +STAR : '*'; +DIVIDE : '/'; +MODULE : '%'; +PLUS : '+'; +MINUS : '-'; -fragment DEC_DOT_DEC: DEC_DIGIT+ DOT DEC_DIGIT+ | DEC_DIGIT+ DOT | DOT DEC_DIGIT+; -fragment DEC_DIGIT: [0-9]; +fragment DEC_DOT_DEC : DEC_DIGIT+ DOT DEC_DIGIT+ | DEC_DIGIT+ DOT | DOT DEC_DIGIT+; +fragment DEC_DIGIT : [0-9]; \ No newline at end of file diff --git a/sql/snowflake/SnowflakeParser.g4 b/sql/snowflake/SnowflakeParser.g4 index 7bcad6c189..47b76cff56 100644 --- a/sql/snowflake/SnowflakeParser.g4 +++ b/sql/snowflake/SnowflakeParser.g4 @@ -21,9 +21,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +// $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 SnowflakeParser; -options { tokenVocab=SnowflakeLexer; } +options { + tokenVocab = SnowflakeLexer; +} snowflake_file : batch? EOF @@ -59,20 +65,16 @@ dml_command ; insert_statement - : INSERT OVERWRITE? INTO object_name ( '(' column_list ')' )? - (values_builder | select_statement) + : INSERT OVERWRITE? INTO object_name ('(' column_list ')')? (values_builder | select_statement) ; insert_multi_table_statement : INSERT OVERWRITE? ALL into_clause2 - | INSERT OVERWRITE? (FIRST | ALL) - (WHEN predicate THEN into_clause2+)+ - (ELSE into_clause2)? - subquery + | INSERT OVERWRITE? (FIRST | ALL) (WHEN predicate THEN into_clause2+)+ (ELSE into_clause2)? subquery ; into_clause2 - : INTO object_name ( '(' column_list ')')? values_list? + : INTO object_name ('(' column_list ')')? values_list? ; values_list @@ -86,30 +88,28 @@ value_item ; merge_statement - : MERGE INTO object_name as_alias? - USING table_source ON search_condition - merge_matches + : MERGE INTO object_name as_alias? USING table_source ON search_condition merge_matches ; merge_matches - : (WHEN MATCHED (AND search_condition )? THEN merge_update_delete)+ - (WHEN NOT MATCHED (AND search_condition )? THEN merge_insert)? + : (WHEN MATCHED (AND search_condition)? THEN merge_update_delete)+ ( + WHEN NOT MATCHED (AND search_condition)? THEN merge_insert + )? ; merge_update_delete - : UPDATE SET column_name EQ expr (',' column_name EQ expr )* + : UPDATE SET column_name EQ expr (',' column_name EQ expr)* | DELETE ; merge_insert - : INSERT ( '(' column_list ')' )? VALUES '(' expr_list ')' + : INSERT ('(' column_list ')')? VALUES '(' expr_list ')' ; update_statement - : UPDATE object_name as_alias? - SET column_name EQ expr (COMMA column_name EQ expr)* - (FROM table_sources)? - (WHERE search_condition)? + : UPDATE object_name as_alias? SET column_name EQ expr (COMMA column_name EQ expr)* ( + FROM table_sources + )? (WHERE search_condition)? ; table_or_query @@ -118,13 +118,13 @@ table_or_query ; delete_statement - : DELETE FROM object_name as_alias? - (USING table_or_query (COMMA table_or_query)? )? - (WHERE search_condition)? + : DELETE FROM object_name as_alias? (USING table_or_query (COMMA table_or_query)?)? ( + WHERE search_condition + )? ; values_builder - : VALUES '(' expr_list ')' (COMMA '(' expr_list ')' )? + : VALUES '(' expr_list ')' (COMMA '(' expr_list ')')? ; other_command @@ -156,49 +156,42 @@ other_command ; begin_txn - : BEGIN ( WORK | TRANSACTION )? ( NAME id_ )? - | START TRANSACTION ( NAME id_ )? + : BEGIN (WORK | TRANSACTION)? (NAME id_)? + | START TRANSACTION ( NAME id_)? ; copy_into_table - : COPY INTO object_name - FROM ( internal_stage | external_stage | external_location ) - files? - pattern? - file_format? - copy_options* - ( VALIDATION_MODE EQ (RETURN_N_ROWS | RETURN_ERRORS | RETURN_ALL_ERRORS) )? -// + : COPY INTO object_name FROM (internal_stage | external_stage | external_location) files? pattern? file_format? copy_options* ( + VALIDATION_MODE EQ (RETURN_N_ROWS | RETURN_ERRORS | RETURN_ALL_ERRORS) + )? + // /* Data load with transformation */ - | COPY INTO object_name ( '(' column_list ')' )? -// FROM '(' SELECT expr_list -// FROM ( internal_stage | external_stage ) ')' - files? - pattern? - file_format? - copy_options* + | COPY INTO object_name ('(' column_list ')')? + // FROM '(' SELECT expr_list + // FROM ( internal_stage | external_stage ) ')' + files? pattern? file_format? copy_options* ; external_location - //(for Amazon S3) +//(for Amazon S3) : S3_PATH //'s3://[/]' -// ( ( STORAGE_INTEGRATION EQ id_ )? -// | ( CREDENTIALS EQ '(' ( AWS_KEY_ID EQ string AWS_SECRET_KEY EQ string ( AWS_TOKEN EQ string )? ) ')' )? -// )? -// [ ENCRYPTION = ( [ TYPE = 'AWS_CSE' ] [ MASTER_KEY = '' ] | -// [ TYPE = 'AWS_SSE_S3' ] | -// [ TYPE = 'AWS_SSE_KMS' [ KMS_KEY_ID = '' ] ] | -// [ TYPE = 'NONE' ] ) ] + // ( ( STORAGE_INTEGRATION EQ id_ )? + // | ( CREDENTIALS EQ '(' ( AWS_KEY_ID EQ string AWS_SECRET_KEY EQ string ( AWS_TOKEN EQ string )? ) ')' )? + // )? + // [ ENCRYPTION = ( [ TYPE = 'AWS_CSE' ] [ MASTER_KEY = '' ] | + // [ TYPE = 'AWS_SSE_S3' ] | + // [ TYPE = 'AWS_SSE_KMS' [ KMS_KEY_ID = '' ] ] | + // [ TYPE = 'NONE' ] ) ] // (for Google Cloud Storage) | GCS_PATH //'gcs://[/]' -// ( STORAGE_INTEGRATION EQ id_ )? - //[ ENCRYPTION = ( [ TYPE = 'GCS_SSE_KMS' ] [ KMS_KEY_ID = '' ] | [ TYPE = 'NONE' ] ) ] + // ( STORAGE_INTEGRATION EQ id_ )? + //[ ENCRYPTION = ( [ TYPE = 'GCS_SSE_KMS' ] [ KMS_KEY_ID = '' ] | [ TYPE = 'NONE' ] ) ] // (for Microsoft Azure) | AZURE_PATH //'azure://.blob.core.windows.net/[/]' -// ( ( STORAGE_INTEGRATION EQ id_ )? -// | ( CREDENTIALS EQ '(' ( AZURE_SAS_TOKEN EQ string ) ')' ) -// )? - //[ ENCRYPTION = ( [ TYPE = { 'AZURE_CSE' | 'NONE' } ] [ MASTER_KEY = '' ] ) ] + // ( ( STORAGE_INTEGRATION EQ id_ )? + // | ( CREDENTIALS EQ '(' ( AZURE_SAS_TOKEN EQ string ) ')' ) + // )? + //[ ENCRYPTION = ( [ TYPE = { 'AZURE_CSE' | 'NONE' } ] [ MASTER_KEY = '' ] ) ] ; files @@ -214,23 +207,19 @@ format_name ; format_type - : TYPE EQ ( CSV | JSON | AVRO | ORC | PARQUET | XML ) format_type_options* + : TYPE EQ (CSV | JSON | AVRO | ORC | PARQUET | XML) format_type_options* ; stage_file_format - : STAGE_FILE_FORMAT EQ '(' ( FORMAT_NAME EQ string ) - | (TYPE EQ ( CSV | JSON | AVRO | ORC | PARQUET | XML ) format_type_options+ ) - ')' + : STAGE_FILE_FORMAT EQ '(' (FORMAT_NAME EQ string) + | (TYPE EQ ( CSV | JSON | AVRO | ORC | PARQUET | XML) format_type_options+) ')' ; copy_into_location - : COPY INTO ( internal_stage | external_stage | external_location ) - FROM ( object_name | '(' query_statement ')' ) - partition_by? - file_format? - copy_options? - ( VALIDATION_MODE EQ RETURN_ROWS )? - HEADER? + : COPY INTO (internal_stage | external_stage | external_location) FROM ( + object_name + | '(' query_statement ')' + ) partition_by? file_format? copy_options? (VALIDATION_MODE EQ RETURN_ROWS)? HEADER? ; comment @@ -256,7 +245,7 @@ execute_task ; explain - : EXPLAIN ( USING (TABULAR | JSON | TEXT) )? sql_command + : EXPLAIN (USING (TABULAR | JSON | TEXT))? sql_command ; parallel @@ -264,29 +253,43 @@ parallel ; get_dml - : GET internal_stage FILE_PATH - parallel? - pattern? + : GET internal_stage FILE_PATH parallel? pattern? ; grant_ownership - : GRANT OWNERSHIP - ( ON ( object_type_name object_name | ALL object_type_plural IN ( DATABASE id_ | SCHEMA schema_name ) ) - | ON FUTURE object_type_plural IN ( DATABASE id_ | SCHEMA schema_name ) - ) - TO ROLE id_ ( ( REVOKE | COPY ) CURRENT GRANTS )? + : GRANT OWNERSHIP ( + ON ( + object_type_name object_name + | ALL object_type_plural IN ( DATABASE id_ | SCHEMA schema_name) + ) + | ON FUTURE object_type_plural IN ( DATABASE id_ | SCHEMA schema_name) + ) TO ROLE id_ (( REVOKE | COPY) CURRENT GRANTS)? ; grant_to_role : GRANT ( - ( global_privileges | ALL PRIVILEGES? ) ON ACCOUNT - | ( account_object_privileges | ALL PRIVILEGES? ) ON ( USER | RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION ) object_name - | ( schema_privileges | ALL PRIVILEGES? ) ON ( SCHEMA schema_name | ALL SCHEMAS IN DATABASE id_ ) - | ( schema_privileges | ALL PRIVILEGES? ) ON ( FUTURE SCHEMAS IN DATABASE id_ ) - | ( schema_object_privileges | ALL PRIVILEGES? ) ON ( object_type object_name | ALL object_type_plural IN ( DATABASE id_ | SCHEMA schema_name ) ) - | ( schema_object_privileges | ALL PRIVILEGES? ) ON FUTURE object_type_plural IN ( DATABASE id_ | SCHEMA schema_name ) + ( global_privileges | ALL PRIVILEGES?) ON ACCOUNT + | (account_object_privileges | ALL PRIVILEGES?) ON ( + USER + | RESOURCE MONITOR + | WAREHOUSE + | DATABASE + | INTEGRATION + ) object_name + | (schema_privileges | ALL PRIVILEGES?) ON ( + SCHEMA schema_name + | ALL SCHEMAS IN DATABASE id_ + ) + | ( schema_privileges | ALL PRIVILEGES?) ON ( FUTURE SCHEMAS IN DATABASE id_) + | (schema_object_privileges | ALL PRIVILEGES?) ON ( + object_type object_name + | ALL object_type_plural IN ( DATABASE id_ | SCHEMA schema_name) ) - TO ROLE? id_ (WITH GRANT OPTION)? + | (schema_object_privileges | ALL PRIVILEGES?) ON FUTURE object_type_plural IN ( + DATABASE id_ + | SCHEMA schema_name + ) + ) TO ROLE? id_ (WITH GRANT OPTION)? ; global_privileges @@ -294,25 +297,31 @@ global_privileges ; global_privilege - : CREATE ( ACCOUNT - | DATA EXCHANGE LISTING - | DATABASE - | INTEGRATION - | NETWORK POLICY - | ROLE - | SHARE - | USER - | WAREHOUSE ) - | ( APPLY MASKING POLICY - | APPLY ROW ACCESS POLICY - | APPLY SESSION POLICY - | APPLY TAG - | ATTACH POLICY ) - | ( EXECUTE TASK - | IMPORT SHARE - | MANAGE GRANTS - | MONITOR ( EXECUTION | USAGE ) - | OVERRIDE SHARE RESTRICTIONS ) + : CREATE ( + ACCOUNT + | DATA EXCHANGE LISTING + | DATABASE + | INTEGRATION + | NETWORK POLICY + | ROLE + | SHARE + | USER + | WAREHOUSE + ) + | ( + APPLY MASKING POLICY + | APPLY ROW ACCESS POLICY + | APPLY SESSION POLICY + | APPLY TAG + | ATTACH POLICY + ) + | ( + EXECUTE TASK + | IMPORT SHARE + | MANAGE GRANTS + | MONITOR ( EXECUTION | USAGE) + | OVERRIDE SHARE RESTRICTIONS + ) ; account_object_privileges @@ -337,22 +346,24 @@ schema_privilege : MODIFY | MONITOR | USAGE - | CREATE ( TABLE - | EXTERNAL TABLE - | VIEW - | MATERIALIZED VIEW - | MASKING POLICY - | ROW ACCESS POLICY - | SESSION POLICY - | TAG - | SEQUENCE - | FUNCTION - | PROCEDURE - | FILE FORMAT - | STAGE - | PIPE - | STREAM - | TASK ) + | CREATE ( + TABLE + | EXTERNAL TABLE + | VIEW + | MATERIALIZED VIEW + | MASKING POLICY + | ROW ACCESS POLICY + | SESSION POLICY + | TAG + | SEQUENCE + | FUNCTION + | PROCEDURE + | FILE FORMAT + | STAGE + | PIPE + | STREAM + | TASK + ) | ADD SEARCH OPTIMIZATION ; @@ -375,13 +386,13 @@ schema_object_privilege ; grant_to_share - : GRANT object_privilege ON - ( DATABASE id_ - | SCHEMA id_ - | FUNCTION id_ - | ( TABLE object_name | ALL TABLES IN SCHEMA schema_name ) - | VIEW id_ ) - TO SHARE id_ + : GRANT object_privilege ON ( + DATABASE id_ + | SCHEMA id_ + | FUNCTION id_ + | ( TABLE object_name | ALL TABLES IN SCHEMA schema_name) + | VIEW id_ + ) TO SHARE id_ ; object_privilege @@ -409,8 +420,7 @@ system_defined_role ; list - : LIST ( internal_stage | external_stage ) - pattern? + : LIST (internal_stage | external_stage) pattern? ; // @[.][/] @@ -426,38 +436,56 @@ external_stage ; put - : PUT FILE_PATH internal_stage - ( PARALLEL EQ num )? - ( AUTO_COMPRESS EQ true_false )? - ( SOURCE_COMPRESSION EQ (AUTO_DETECT | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE) )? - ( OVERWRITE EQ true_false )? + : PUT FILE_PATH internal_stage (PARALLEL EQ num)? (AUTO_COMPRESS EQ true_false)? ( + SOURCE_COMPRESSION EQ ( + AUTO_DETECT + | GZIP + | BZ2 + | BROTLI + | ZSTD + | DEFLATE + | RAW_DEFLATE + | NONE + ) + )? (OVERWRITE EQ true_false)? ; remove - : REMOVE ( internal_stage | external_stage ) - pattern? + : REMOVE (internal_stage | external_stage) pattern? ; revoke_from_role - : REVOKE (GRANT OPTION FOR)? - ( - ( global_privilege | ALL PRIVILEGES? ) ON ACCOUNT - | ( account_object_privileges | ALL PRIVILEGES? ) ON ( RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION ) object_name - | ( schema_privileges | ALL PRIVILEGES? ) ON ( SCHEMA schema_name | ALL SCHEMAS IN DATABASE id_ ) - | ( schema_privileges | ALL PRIVILEGES? ) ON ( FUTURE SCHEMAS IN DATABASE ) - | ( schema_object_privileges | ALL PRIVILEGES? ) ON ( object_type object_name | ALL object_type_plural IN SCHEMA schema_name ) - | ( schema_object_privileges | ALL PRIVILEGES? ) ON FUTURE object_type_plural IN ( DATABASE id_ | SCHEMA schema_name ) - ) - FROM ROLE? id_ cascade_restrict? + : REVOKE (GRANT OPTION FOR)? ( + ( global_privilege | ALL PRIVILEGES?) ON ACCOUNT + | (account_object_privileges | ALL PRIVILEGES?) ON ( + RESOURCE MONITOR + | WAREHOUSE + | DATABASE + | INTEGRATION + ) object_name + | (schema_privileges | ALL PRIVILEGES?) ON ( + SCHEMA schema_name + | ALL SCHEMAS IN DATABASE id_ + ) + | (schema_privileges | ALL PRIVILEGES?) ON (FUTURE SCHEMAS IN DATABASE ) + | (schema_object_privileges | ALL PRIVILEGES?) ON ( + object_type object_name + | ALL object_type_plural IN SCHEMA schema_name + ) + | (schema_object_privileges | ALL PRIVILEGES?) ON FUTURE object_type_plural IN ( + DATABASE id_ + | SCHEMA schema_name + ) + ) FROM ROLE? id_ cascade_restrict? ; revoke_from_share - : REVOKE object_privilege ON - ( DATABASE id_ - | SCHEMA schema_name - | ( TABLE object_name | ALL TABLES IN SCHEMA schema_name ) - | ( VIEW object_name | ALL VIEWS IN SCHEMA schema_name ) ) - FROM SHARE id_ + : REVOKE object_privilege ON ( + DATABASE id_ + | SCHEMA schema_name + | ( TABLE object_name | ALL TABLES IN SCHEMA schema_name) + | ( VIEW object_name | ALL VIEWS IN SCHEMA schema_name) + ) FROM SHARE id_ ; revoke_role @@ -470,7 +498,7 @@ rollback set : SET id_ EQ expr - | SET LR_BRACKET id_ ( COMMA id_ )* RR_BRACKET EQ LR_BRACKET expr ( COMMA expr )* RR_BRACKET + | SET LR_BRACKET id_ (COMMA id_)* RR_BRACKET EQ LR_BRACKET expr (COMMA expr)* RR_BRACKET ; truncate_materialized_view @@ -628,12 +656,13 @@ enabled_true_false ; alter_alert - : ALTER ALERT if_exists? id_ ( resume_suspend - | SET alert_set_clause+ - | UNSET alert_unset_clause+ - | MODIFY CONDITION EXISTS '(' alert_condition ')' - | MODIFY ACTION alert_action - ) + : ALTER ALERT if_exists? id_ ( + resume_suspend + | SET alert_set_clause+ + | UNSET alert_unset_clause+ + | MODIFY CONDITION EXISTS '(' alert_condition ')' + | MODIFY ACTION alert_action + ) ; resume_suspend @@ -654,18 +683,16 @@ alert_unset_clause ; alter_api_integration - : ALTER API? INTEGRATION if_exists? id_ SET - ( API_AWS_ROLE_ARN EQ string )? - ( AZURE_AD_APPLICATION_ID EQ string )? - ( API_KEY EQ string )? - enabled_true_false? - ( API_ALLOWED_PREFIXES EQ '(' string ')' )? - ( API_BLOCKED_PREFIXES EQ '(' string ')' )? - comment_clause? - - | ALTER API? INTEGRATION id_ set_tags - | ALTER API? INTEGRATION id_ unset_tags - | ALTER API? INTEGRATION if_exists? id_ UNSET api_integration_property (COMMA api_integration_property)* + : ALTER API? INTEGRATION if_exists? id_ SET (API_AWS_ROLE_ARN EQ string)? ( + AZURE_AD_APPLICATION_ID EQ string + )? (API_KEY EQ string)? enabled_true_false? (API_ALLOWED_PREFIXES EQ '(' string ')')? ( + API_BLOCKED_PREFIXES EQ '(' string ')' + )? comment_clause? + | ALTER API? INTEGRATION id_ set_tags + | ALTER API? INTEGRATION id_ unset_tags + | ALTER API? INTEGRATION if_exists? id_ UNSET api_integration_property ( + COMMA api_integration_property + )* ; api_integration_property @@ -682,19 +709,18 @@ alter_connection alter_database : ALTER DATABASE if_exists? id_ RENAME TO id_ | ALTER DATABASE if_exists? id_ SWAP WITH id_ - | ALTER DATABASE if_exists? id_ SET ( DATA_RETENTION_TIME_IN_DAYS EQ num )? - ( MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num )? - default_ddl_collation? - comment_clause? + | ALTER DATABASE if_exists? id_ SET (DATA_RETENTION_TIME_IN_DAYS EQ num)? ( + MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num + )? default_ddl_collation? comment_clause? | ALTER DATABASE id_ set_tags | ALTER DATABASE id_ unset_tags | ALTER DATABASE if_exists? id_ UNSET database_property (COMMA database_property)* | ALTER DATABASE id_ ENABLE REPLICATION TO ACCOUNTS account_id_list (IGNORE EDITION CHECK)? - | ALTER DATABASE id_ DISABLE REPLICATION ( TO ACCOUNTS account_id_list )? + | ALTER DATABASE id_ DISABLE REPLICATION ( TO ACCOUNTS account_id_list)? | ALTER DATABASE id_ REFRESH // Database Failover | ALTER DATABASE id_ ENABLE FAILOVER TO ACCOUNTS account_id_list - | ALTER DATABASE id_ DISABLE FAILOVER ( TO ACCOUNTS account_id_list )? + | ALTER DATABASE id_ DISABLE FAILOVER ( TO ACCOUNTS account_id_list)? | ALTER DATABASE id_ PRIMARY ; @@ -710,22 +736,19 @@ account_id_list ; alter_dynamic_table - : ALTER DYNAMIC TABLE id_ ( resume_suspend - | REFRESH - | SET WAREHOUSE EQ id_ - ) + : ALTER DYNAMIC TABLE id_ (resume_suspend | REFRESH | SET WAREHOUSE EQ id_) ; alter_external_table : ALTER EXTERNAL TABLE if_exists? object_name REFRESH string? | ALTER EXTERNAL TABLE if_exists? object_name ADD FILES '(' string_list ')' | ALTER EXTERNAL TABLE if_exists? object_name REMOVE FILES '(' string_list ')' - | ALTER EXTERNAL TABLE if_exists? object_name SET - ( AUTO_REFRESH EQ true_false )? - tag_decl_list? + | ALTER EXTERNAL TABLE if_exists? object_name SET (AUTO_REFRESH EQ true_false)? tag_decl_list? | ALTER EXTERNAL TABLE if_exists? object_name unset_tags - //Partitions added and removed manually - | ALTER EXTERNAL TABLE object_name if_exists? ADD PARTITION '(' column_name EQ string (COMMA column_name EQ string)* ')' LOCATION string + //Partitions added and removed manually + | ALTER EXTERNAL TABLE object_name if_exists? ADD PARTITION '(' column_name EQ string ( + COMMA column_name EQ string + )* ')' LOCATION string | ALTER EXTERNAL TABLE object_name if_exists? DROP PARTITION LOCATION string ; @@ -750,13 +773,12 @@ full_acct_list ; alter_failover_group - //Source Account +//Source Account : ALTER FAILOVER GROUP if_exists? id_ RENAME TO id_ - | ALTER FAILOVER GROUP if_exists? id_ SET ( OBJECT_TYPES EQ object_type_list )? replication_schedule? - | ALTER FAILOVER GROUP if_exists? id_ SET - OBJECT_TYPES EQ object_type_list -// ALLOWED_INTEGRATION_TYPES EQ [ , ... ] ] - replication_schedule? + | ALTER FAILOVER GROUP if_exists? id_ SET (OBJECT_TYPES EQ object_type_list)? replication_schedule? + | ALTER FAILOVER GROUP if_exists? id_ SET OBJECT_TYPES EQ object_type_list + // ALLOWED_INTEGRATION_TYPES EQ [ , ... ] ] + replication_schedule? | ALTER FAILOVER GROUP if_exists? id_ ADD db_name_list TO ALLOWED_DATABASES | ALTER FAILOVER GROUP if_exists? id_ MOVE DATABASES db_name_list TO FAILOVER GROUP id_ | ALTER FAILOVER GROUP if_exists? id_ REMOVE db_name_list FROM ALLOWED_DATABASES @@ -765,28 +787,37 @@ alter_failover_group | ALTER FAILOVER GROUP if_exists? id_ REMOVE share_name_list FROM ALLOWED_SHARES | ALTER FAILOVER GROUP if_exists? id_ ADD full_acct_list TO ALLOWED_ACCOUNTS ignore_edition_check? | ALTER FAILOVER GROUP if_exists? id_ REMOVE full_acct_list FROM ALLOWED_ACCOUNTS - //Target Account - | ALTER FAILOVER GROUP if_exists? id_ ( REFRESH | PRIMARY | SUSPEND | RESUME ) + //Target Account + | ALTER FAILOVER GROUP if_exists? id_ ( REFRESH | PRIMARY | SUSPEND | RESUME) ; alter_file_format : ALTER FILE FORMAT if_exists? id_ RENAME TO id_ - | ALTER FILE FORMAT if_exists? id_ SET ( format_type_options* comment_clause? ) + | ALTER FILE FORMAT if_exists? id_ SET (format_type_options* comment_clause?) ; alter_function : alter_function_signature RENAME TO id_ | alter_function_signature SET comment_clause | alter_function_signature SET SECURE - | alter_function_signature UNSET ( SECURE | COMMENT ) + | alter_function_signature UNSET (SECURE | COMMENT) // External Functions | alter_function_signature SET API_INTEGRATION EQ id_ | alter_function_signature SET HEADERS EQ '(' header_decl* ')' | alter_function_signature SET CONTEXT_HEADERS EQ '(' id_* ')' | alter_function_signature SET MAX_BATCH_ROWS EQ num | alter_function_signature SET COMPRESSION EQ compression_type - | alter_function_signature SET ( REQUEST_TRANSLATOR | RESPONSE_TRANSLATOR ) EQ id_ - | alter_function_signature UNSET ( COMMENT | HEADERS | CONTEXT_HEADERS | MAX_BATCH_ROWS | COMPRESSION | SECURE | REQUEST_TRANSLATOR | RESPONSE_TRANSLATOR ) + | alter_function_signature SET (REQUEST_TRANSLATOR | RESPONSE_TRANSLATOR) EQ id_ + | alter_function_signature UNSET ( + COMMENT + | HEADERS + | CONTEXT_HEADERS + | MAX_BATCH_ROWS + | COMPRESSION + | SECURE + | REQUEST_TRANSLATOR + | RESPONSE_TRANSLATOR + ) ; alter_function_signature @@ -809,13 +840,9 @@ alter_materialized_view | CLUSTER BY '(' expr_list ')' | DROP CLUSTERING KEY | resume_suspend RECLUSTER? - | SET ( - SECURE? - comment_clause? ) - | UNSET ( - SECURE - | COMMENT ) - ) + | SET ( SECURE? comment_clause?) + | UNSET ( SECURE | COMMENT) + ) ; alter_network_policy @@ -823,27 +850,21 @@ alter_network_policy ; alter_notification_integration - : ALTER NOTIFICATION? INTEGRATION if_exists? id_ SET - enabled_true_false? - cloud_provider_params_auto - comment_clause? + : ALTER NOTIFICATION? INTEGRATION if_exists? id_ SET enabled_true_false? cloud_provider_params_auto comment_clause? // Push notifications - | ALTER NOTIFICATION? INTEGRATION if_exists? id_ SET - enabled_true_false? - cloud_provider_params_push - comment_clause? + | ALTER NOTIFICATION? INTEGRATION if_exists? id_ SET enabled_true_false? cloud_provider_params_push comment_clause? | ALTER NOTIFICATION? INTEGRATION id_ set_tags | ALTER NOTIFICATION? INTEGRATION id_ unset_tags | ALTER NOTIFICATION? INTEGRATION if_exists id_ UNSET (ENABLED | COMMENT) ; alter_pipe - : ALTER PIPE if_exists? id_ SET ( object_properties? comment_clause? ) + : ALTER PIPE if_exists? id_ SET (object_properties? comment_clause?) | ALTER PIPE id_ set_tags | ALTER PIPE id_ unset_tags | ALTER PIPE if_exists? id_ UNSET PIPE_EXECUTION_PAUSED EQ true_false | ALTER PIPE if_exists? id_ UNSET COMMENT - | ALTER PIPE if_exists? id_ REFRESH ( PREFIX EQ string )? ( MODIFIED_AFTER EQ string )? + | ALTER PIPE if_exists? id_ REFRESH (PREFIX EQ string)? (MODIFIED_AFTER EQ string)? ; alter_procedure @@ -854,23 +875,21 @@ alter_procedure ; alter_replication_group - //Source Account +//Source Account : ALTER REPLICATION GROUP if_exists? id_ RENAME TO id_ - | ALTER REPLICATION GROUP if_exists? id_ SET - ( OBJECT_TYPES EQ object_type_list )? - ( REPLICATION_SCHEDULE EQ string )? - | ALTER REPLICATION GROUP if_exists? id_ SET - OBJECT_TYPES EQ object_type_list - ALLOWED_INTEGRATION_TYPES EQ integration_type_name (COMMA integration_type_name)* - ( REPLICATION_SCHEDULE EQ string )? + | ALTER REPLICATION GROUP if_exists? id_ SET (OBJECT_TYPES EQ object_type_list)? ( + REPLICATION_SCHEDULE EQ string + )? + | ALTER REPLICATION GROUP if_exists? id_ SET OBJECT_TYPES EQ object_type_list ALLOWED_INTEGRATION_TYPES EQ integration_type_name ( + COMMA integration_type_name + )* (REPLICATION_SCHEDULE EQ string)? | ALTER REPLICATION GROUP if_exists? id_ ADD db_name_list TO ALLOWED_DATABASES | ALTER REPLICATION GROUP if_exists? id_ MOVE DATABASES db_name_list TO REPLICATION GROUP id_ | ALTER REPLICATION GROUP if_exists? id_ REMOVE db_name_list FROM ALLOWED_DATABASES | ALTER REPLICATION GROUP if_exists? id_ ADD share_name_list TO ALLOWED_SHARES | ALTER REPLICATION GROUP if_exists? id_ MOVE SHARES share_name_list TO REPLICATION GROUP id_ | ALTER REPLICATION GROUP if_exists? id_ REMOVE share_name_list FROM ALLOWED_SHARES - | ALTER REPLICATION GROUP if_exists? id_ ADD account_id_list TO ALLOWED_ACCOUNTS - ignore_edition_check? + | ALTER REPLICATION GROUP if_exists? id_ ADD account_id_list TO ALLOWED_ACCOUNTS ignore_edition_check? | ALTER REPLICATION GROUP if_exists? id_ REMOVE account_id_list FROM ALLOWED_ACCOUNTS //Target Account | ALTER REPLICATION GROUP if_exists? id_ REFRESH @@ -883,7 +902,7 @@ credit_quota ; frequency - : FREQUENCY EQ ( MONTHLY | DAILY | WEEKLY | YEARLY | NEVER ) + : FREQUENCY EQ (MONTHLY | DAILY | WEEKLY | YEARLY | NEVER) ; notify_users @@ -891,22 +910,16 @@ notify_users ; triggerDefinition - : ON num PERCENT DO ( SUSPEND | SUSPEND_IMMEDIATE | NOTIFY ) + : ON num PERCENT DO (SUSPEND | SUSPEND_IMMEDIATE | NOTIFY) ; alter_resource_monitor - : ALTER RESOURCE MONITOR if_exists? id_ - ( - SET - credit_quota? - frequency? - ( START_TIMESTAMP EQ LR_BRACKET string | IMMEDIATELY RR_BRACKET )? - ( END_TIMESTAMP EQ string )? - )? - ( - notify_users - ( TRIGGERS triggerDefinition (COMMA triggerDefinition)* )? - )? + : ALTER RESOURCE MONITOR if_exists? id_ ( + SET credit_quota? frequency? ( + START_TIMESTAMP EQ LR_BRACKET string + | IMMEDIATELY RR_BRACKET + )? (END_TIMESTAMP EQ string)? + )? (notify_users ( TRIGGERS triggerDefinition (COMMA triggerDefinition)*)?)? ; alter_role @@ -927,11 +940,8 @@ alter_schema : ALTER SCHEMA if_exists? schema_name RENAME TO schema_name | ALTER SCHEMA if_exists? schema_name SWAP WITH schema_name | ALTER SCHEMA if_exists? schema_name SET ( - ( DATA_RETENTION_TIME_IN_DAYS EQ num )? - ( MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num )? - default_ddl_collation? - comment_clause? - ) + (DATA_RETENTION_TIME_IN_DAYS EQ num)? (MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num)? default_ddl_collation? comment_clause? + ) | ALTER SCHEMA if_exists? schema_name set_tags | ALTER SCHEMA if_exists? schema_name unset_tags | ALTER SCHEMA if_exists? schema_name UNSET schema_property (COMMA schema_property)* @@ -947,29 +957,30 @@ schema_property alter_sequence : ALTER SEQUENCE if_exists? object_name RENAME TO object_name - | ALTER SEQUENCE if_exists? object_name SET? ( INCREMENT BY? EQ? num )? - | ALTER SEQUENCE if_exists? object_name SET ( order_noorder? comment_clause | order_noorder ) + | ALTER SEQUENCE if_exists? object_name SET? ( INCREMENT BY? EQ? num)? + | ALTER SEQUENCE if_exists? object_name SET (order_noorder? comment_clause | order_noorder) | ALTER SEQUENCE if_exists? object_name UNSET COMMENT ; alter_security_integration_external_oauth - : ALTER SECURITY? INTEGRATION if_exists id_ SET - ( TYPE EQ EXTERNAL_OAUTH )? - ( ENABLED EQ true_false )? - ( EXTERNAL_OAUTH_TYPE EQ ( OKTA | AZURE | PING_FEDERATE | CUSTOM ) )? - ( EXTERNAL_OAUTH_ISSUER EQ string )? - ( EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM EQ (string | '(' string_list ')') )? - ( EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE EQ string )? - ( EXTERNAL_OAUTH_JWS_KEYS_URL EQ string )? // For OKTA | PING_FEDERATE | CUSTOM - ( EXTERNAL_OAUTH_JWS_KEYS_URL EQ (string | '(' string_list ')') )? // For Azure - ( EXTERNAL_OAUTH_RSA_PUBLIC_KEY EQ string )? - ( EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2 EQ string )? - ( EXTERNAL_OAUTH_BLOCKED_ROLES_LIST EQ '(' string_list ')' )? - ( EXTERNAL_OAUTH_ALLOWED_ROLES_LIST EQ '(' string_list ')' )? - ( EXTERNAL_OAUTH_AUDIENCE_LIST EQ '(' string ')' )? - ( EXTERNAL_OAUTH_ANY_ROLE_MODE EQ (DISABLE | ENABLE | ENABLE_FOR_PRIVILEGE) )? - ( EXTERNAL_OAUTH_ANY_ROLE_MODE EQ string )? // Only for EXTERNAL_OAUTH_TYPE EQ CUSTOM - | ALTER SECURITY? INTEGRATION if_exists? id_ UNSET security_integration_external_oauth_property (COMMA security_integration_external_oauth_property)* + : ALTER SECURITY? INTEGRATION if_exists id_ SET (TYPE EQ EXTERNAL_OAUTH)? ( + ENABLED EQ true_false + )? (EXTERNAL_OAUTH_TYPE EQ ( OKTA | AZURE | PING_FEDERATE | CUSTOM))? ( + EXTERNAL_OAUTH_ISSUER EQ string + )? (EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM EQ (string | '(' string_list ')'))? ( + EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE EQ string + )? (EXTERNAL_OAUTH_JWS_KEYS_URL EQ string)? // For OKTA | PING_FEDERATE | CUSTOM + (EXTERNAL_OAUTH_JWS_KEYS_URL EQ (string | '(' string_list ')'))? // For Azure + (EXTERNAL_OAUTH_RSA_PUBLIC_KEY EQ string)? (EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2 EQ string)? ( + EXTERNAL_OAUTH_BLOCKED_ROLES_LIST EQ '(' string_list ')' + )? (EXTERNAL_OAUTH_ALLOWED_ROLES_LIST EQ '(' string_list ')')? ( + EXTERNAL_OAUTH_AUDIENCE_LIST EQ '(' string ')' + )? (EXTERNAL_OAUTH_ANY_ROLE_MODE EQ (DISABLE | ENABLE | ENABLE_FOR_PRIVILEGE))? ( + EXTERNAL_OAUTH_ANY_ROLE_MODE EQ string + )? // Only for EXTERNAL_OAUTH_TYPE EQ CUSTOM + | ALTER SECURITY? INTEGRATION if_exists? id_ UNSET security_integration_external_oauth_property ( + COMMA security_integration_external_oauth_property + )* | ALTER SECURITY? INTEGRATION id_ set_tags | ALTER SECURITY? INTEGRATION id_ unset_tags ; @@ -984,23 +995,24 @@ security_integration_external_oauth_property ; alter_security_integration_snowflake_oauth - : ALTER SECURITY? INTEGRATION if_exists? id_ SET - ( TYPE EQ EXTERNAL_OAUTH )? - enabled_true_false? - ( EXTERNAL_OAUTH_TYPE EQ ( OKTA | AZURE | PING_FEDERATE | CUSTOM ) )? - ( EXTERNAL_OAUTH_ISSUER EQ string )? - ( EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM EQ (string | '(' string_list ')') )? - ( EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE EQ string )? - ( EXTERNAL_OAUTH_JWS_KEYS_URL EQ string )? // For OKTA | PING_FEDERATE | CUSTOM - ( EXTERNAL_OAUTH_JWS_KEYS_URL EQ ( string | '(' string_list ')' ) )? // For Azure - ( EXTERNAL_OAUTH_RSA_PUBLIC_KEY EQ string )? - ( EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2 EQ string )? - ( EXTERNAL_OAUTH_BLOCKED_ROLES_LIST EQ '(' string_list ')' )? - ( EXTERNAL_OAUTH_ALLOWED_ROLES_LIST EQ '(' string_list ')' )? - ( EXTERNAL_OAUTH_AUDIENCE_LIST EQ '(' string ')' )? - ( EXTERNAL_OAUTH_ANY_ROLE_MODE EQ DISABLE | ENABLE | ENABLE_FOR_PRIVILEGE )? - ( EXTERNAL_OAUTH_SCOPE_DELIMITER EQ string ) // Only for EXTERNAL_OAUTH_TYPE EQ CUSTOM - | ALTER SECURITY? INTEGRATION if_exists? id_ UNSET security_integration_snowflake_oauth_property (COMMA security_integration_snowflake_oauth_property)* + : ALTER SECURITY? INTEGRATION if_exists? id_ SET (TYPE EQ EXTERNAL_OAUTH)? enabled_true_false? ( + EXTERNAL_OAUTH_TYPE EQ ( OKTA | AZURE | PING_FEDERATE | CUSTOM) + )? (EXTERNAL_OAUTH_ISSUER EQ string)? ( + EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM EQ (string | '(' string_list ')') + )? (EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE EQ string)? ( + EXTERNAL_OAUTH_JWS_KEYS_URL EQ string + )? // For OKTA | PING_FEDERATE | CUSTOM + (EXTERNAL_OAUTH_JWS_KEYS_URL EQ ( string | '(' string_list ')'))? // For Azure + (EXTERNAL_OAUTH_RSA_PUBLIC_KEY EQ string)? (EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2 EQ string)? ( + EXTERNAL_OAUTH_BLOCKED_ROLES_LIST EQ '(' string_list ')' + )? (EXTERNAL_OAUTH_ALLOWED_ROLES_LIST EQ '(' string_list ')')? ( + EXTERNAL_OAUTH_AUDIENCE_LIST EQ '(' string ')' + )? (EXTERNAL_OAUTH_ANY_ROLE_MODE EQ DISABLE | ENABLE | ENABLE_FOR_PRIVILEGE)? ( + EXTERNAL_OAUTH_SCOPE_DELIMITER EQ string + ) // Only for EXTERNAL_OAUTH_TYPE EQ CUSTOM + | ALTER SECURITY? INTEGRATION if_exists? id_ UNSET security_integration_snowflake_oauth_property ( + COMMA security_integration_snowflake_oauth_property + )* | ALTER SECURITY? INTEGRATION id_ set_tags | ALTER SECURITY? INTEGRATION id_ unset_tags ; @@ -1011,33 +1023,27 @@ security_integration_snowflake_oauth_property ; alter_security_integration_saml2 - : ALTER SECURITY? INTEGRATION if_exists? id_ SET - ( TYPE EQ SAML2 )? - enabled_true_false? - ( SAML2_ISSUER EQ string )? - ( SAML2_SSO_URL EQ string )? - ( SAML2_PROVIDER EQ string )? - ( SAML2_X509_CERT EQ string )? - ( SAML2_SP_INITIATED_LOGIN_PAGE_LABEL EQ string )? - ( SAML2_ENABLE_SP_INITIATED EQ true_false )? - ( SAML2_SNOWFLAKE_X509_CERT EQ string )? - ( SAML2_SIGN_REQUEST EQ true_false )? - ( SAML2_REQUESTED_NAMEID_FORMAT EQ string )? - ( SAML2_POST_LOGOUT_REDIRECT_URL EQ string )? - ( SAML2_FORCE_AUTHN EQ true_false )? - ( SAML2_SNOWFLAKE_ISSUER_URL EQ string )? - ( SAML2_SNOWFLAKE_ACS_URL EQ string )? + : ALTER SECURITY? INTEGRATION if_exists? id_ SET (TYPE EQ SAML2)? enabled_true_false? ( + SAML2_ISSUER EQ string + )? (SAML2_SSO_URL EQ string)? (SAML2_PROVIDER EQ string)? (SAML2_X509_CERT EQ string)? ( + SAML2_SP_INITIATED_LOGIN_PAGE_LABEL EQ string + )? (SAML2_ENABLE_SP_INITIATED EQ true_false)? (SAML2_SNOWFLAKE_X509_CERT EQ string)? ( + SAML2_SIGN_REQUEST EQ true_false + )? (SAML2_REQUESTED_NAMEID_FORMAT EQ string)? (SAML2_POST_LOGOUT_REDIRECT_URL EQ string)? ( + SAML2_FORCE_AUTHN EQ true_false + )? (SAML2_SNOWFLAKE_ISSUER_URL EQ string)? (SAML2_SNOWFLAKE_ACS_URL EQ string)? | ALTER SECURITY? INTEGRATION if_exists? id_ UNSET ENABLED | ALTER SECURITY? INTEGRATION id_ set_tags | ALTER SECURITY? INTEGRATION id_ unset_tags ; alter_security_integration_scim - : ALTER SECURITY? INTEGRATION if_exists? id_ SET - ( NETWORK_POLICY EQ string )? - ( SYNC_PASSWORD EQ true_false )? - comment_clause? - | ALTER SECURITY? INTEGRATION if_exists? id_ UNSET security_integration_scim_property (COMMA security_integration_scim_property)* + : ALTER SECURITY? INTEGRATION if_exists? id_ SET (NETWORK_POLICY EQ string)? ( + SYNC_PASSWORD EQ true_false + )? comment_clause? + | ALTER SECURITY? INTEGRATION if_exists? id_ UNSET security_integration_scim_property ( + COMMA security_integration_scim_property + )* | ALTER SECURITY? INTEGRATION id_ set_tags | ALTER SECURITY? INTEGRATION id_ unset_tags ; @@ -1048,49 +1054,47 @@ security_integration_scim_property | COMMENT ; - alter_session : ALTER SESSION SET session_params | ALTER SESSION UNSET param_name (COMMA param_name)* ; alter_session_policy - : ALTER SESSION POLICY if_exists? id_ (UNSET | SET) ( SESSION_IDLE_TIMEOUT_MINS EQ num )? - ( SESSION_UI_IDLE_TIMEOUT_MINS EQ num )? - comment_clause? + : ALTER SESSION POLICY if_exists? id_ (UNSET | SET) (SESSION_IDLE_TIMEOUT_MINS EQ num)? ( + SESSION_UI_IDLE_TIMEOUT_MINS EQ num + )? comment_clause? | ALTER SESSION POLICY if_exists? id_ RENAME TO id_ ; alter_share - : ALTER SHARE if_exists? id_ ( ADD | REMOVE ) ACCOUNTS EQ id_ (COMMA id_)* ( SHARE_RESTRICTIONS EQ true_false )? - | ALTER SHARE if_exists? id_ ADD ACCOUNTS EQ id_ (COMMA id_)* ( SHARE_RESTRICTIONS EQ true_false )? - | ALTER SHARE if_exists? id_ SET (ACCOUNTS EQ id_ (COMMA id_)* )? comment_clause? + : ALTER SHARE if_exists? id_ (ADD | REMOVE) ACCOUNTS EQ id_ (COMMA id_)* ( + SHARE_RESTRICTIONS EQ true_false + )? + | ALTER SHARE if_exists? id_ ADD ACCOUNTS EQ id_ (COMMA id_)* ( + SHARE_RESTRICTIONS EQ true_false + )? + | ALTER SHARE if_exists? id_ SET (ACCOUNTS EQ id_ (COMMA id_)*)? comment_clause? | ALTER SHARE if_exists? id_ set_tags | ALTER SHARE id_ unset_tags | ALTER SHARE if_exists? id_ UNSET COMMENT ; alter_storage_integration - : ALTER STORAGE? INTEGRATION if_exists? id_ SET - cloud_provider_params2? - enabled_true_false? - ( STORAGE_ALLOWED_LOCATIONS EQ '(' string_list ')' )? - ( STORAGE_BLOCKED_LOCATIONS EQ '(' string_list ')' )? - comment_clause? + : ALTER STORAGE? INTEGRATION if_exists? id_ SET cloud_provider_params2? enabled_true_false? ( + STORAGE_ALLOWED_LOCATIONS EQ '(' string_list ')' + )? (STORAGE_BLOCKED_LOCATIONS EQ '(' string_list ')')? comment_clause? | ALTER STORAGE? INTEGRATION if_exists? id_ set_tags | ALTER STORAGE? INTEGRATION id_ unset_tags | ALTER STORAGE? INTEGRATION if_exists? id_ UNSET ( - ENABLED | - STORAGE_BLOCKED_LOCATIONS | - COMMENT - ) - //[ , ... ] + ENABLED + | STORAGE_BLOCKED_LOCATIONS + | COMMENT + ) + //[ , ... ] ; alter_stream - : ALTER STREAM if_exists? id_ SET - tag_decl_list? - comment_clause? + : ALTER STREAM if_exists? id_ SET tag_decl_list? comment_clause? | ALTER STREAM if_exists? id_ set_tags | ALTER STREAM id_ unset_tags | ALTER STREAM if_exists? id_ UNSET COMMENT @@ -1099,27 +1103,29 @@ alter_stream alter_table : ALTER TABLE if_exists? object_name RENAME TO object_name | ALTER TABLE if_exists? object_name SWAP WITH object_name - | ALTER TABLE if_exists? object_name ( clustering_action | table_column_action | constraint_action ) + | ALTER TABLE if_exists? object_name ( + clustering_action + | table_column_action + | constraint_action + ) | ALTER TABLE if_exists? object_name ext_table_column_action | ALTER TABLE if_exists? object_name search_optimization_action - | ALTER TABLE if_exists? object_name SET - stage_file_format? - ( STAGE_COPY_OPTIONS EQ '(' copy_options ')' )? - ( DATA_RETENTION_TIME_IN_DAYS EQ num )? - ( MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num )? - ( CHANGE_TRACKING EQ true_false )? - default_ddl_collation? - comment_clause? + | ALTER TABLE if_exists? object_name SET stage_file_format? ( + STAGE_COPY_OPTIONS EQ '(' copy_options ')' + )? (DATA_RETENTION_TIME_IN_DAYS EQ num)? (MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num)? ( + CHANGE_TRACKING EQ true_false + )? default_ddl_collation? comment_clause? | ALTER TABLE if_exists? object_name set_tags | ALTER TABLE if_exists? object_name unset_tags | ALTER TABLE if_exists? object_name UNSET ( - DATA_RETENTION_TIME_IN_DAYS | - MAX_DATA_EXTENSION_TIME_IN_DAYS | - CHANGE_TRACKING | - DEFAULT_DDL_COLLATION_ | - COMMENT | - ) - //[ , ... ] + DATA_RETENTION_TIME_IN_DAYS + | MAX_DATA_EXTENSION_TIME_IN_DAYS + | CHANGE_TRACKING + | DEFAULT_DDL_COLLATION_ + | COMMENT + | + ) + //[ , ... ] | ALTER TABLE if_exists? object_name ADD ROW ACCESS POLICY id_ ON column_list_in_parentheses | ALTER TABLE if_exists? object_name DROP ROW ACCESS POLICY id_ | ALTER TABLE if_exists? object_name DROP ROW ACCESS POLICY id_ COMMA ADD ROW ACCESS POLICY id_ ON column_list_in_parentheses @@ -1128,29 +1134,26 @@ alter_table clustering_action : CLUSTER BY '(' expr_list ')' - | RECLUSTER ( MAX_SIZE EQ num )? ( WHERE expr )? + | RECLUSTER ( MAX_SIZE EQ num)? ( WHERE expr)? | resume_suspend RECLUSTER | DROP CLUSTERING KEY ; table_column_action - : ADD COLUMN? if_not_exists? column_name data_type - default_value? - inline_constraint? - ( WITH? MASKING POLICY id_ ( USING '(' column_name COMMA column_list ')' )? )? + : ADD COLUMN? if_not_exists? column_name data_type default_value? inline_constraint? ( + WITH? MASKING POLICY id_ (USING '(' column_name COMMA column_list ')')? + )? | RENAME COLUMN column_name TO column_name - | alter_modify '('? - COLUMN? column_name DROP DEFAULT - COMMA COLUMN? column_name SET DEFAULT object_name DOT NEXTVAL - COMMA COLUMN? column_name ( SET? NOT NULL_ | DROP NOT NULL_ ) - COMMA COLUMN? column_name ( ( SET DATA )? TYPE )? data_type - COMMA COLUMN? column_name comment_clause - COMMA COLUMN? column_name UNSET COMMENT - // [ COMMA COLUMN? column_name ... ] - // [ , ... ] - ')'? - | alter_modify COLUMN column_name SET MASKING POLICY id_ ( USING '(' column_name COMMA column_list ')' )? - FORCE? + | alter_modify '('? COLUMN? column_name DROP DEFAULT COMMA COLUMN? column_name SET DEFAULT object_name DOT NEXTVAL COMMA COLUMN? column_name ( + SET? NOT NULL_ + | DROP NOT NULL_ + ) COMMA COLUMN? column_name (( SET DATA)? TYPE)? data_type COMMA COLUMN? column_name comment_clause COMMA COLUMN? column_name UNSET COMMENT + // [ COMMA COLUMN? column_name ... ] + // [ , ... ] + ')'? + | alter_modify COLUMN column_name SET MASKING POLICY id_ ( + USING '(' column_name COMMA column_list ')' + )? FORCE? | alter_modify COLUMN column_name UNSET MASKING POLICY | alter_modify column_set_tags (COMMA column_set_tags)* | alter_modify column_unset_tags (COMMA column_unset_tags)* @@ -1158,10 +1161,9 @@ table_column_action ; inline_constraint - : null_not_null? (CONSTRAINT id_)? - ( - ( UNIQUE | primary_key ) common_constraint_properties* - | foreign_key REFERENCES object_name ( LR_BRACKET column_name RR_BRACKET )? constraint_properties + : null_not_null? (CONSTRAINT id_)? ( + ( UNIQUE | primary_key) common_constraint_properties* + | foreign_key REFERENCES object_name (LR_BRACKET column_name RR_BRACKET)? constraint_properties ) ; @@ -1174,16 +1176,16 @@ deferrable_not_deferrable ; initially_deferred_or_immediate - : INITIALLY ( DEFERRED | IMMEDIATE ) + : INITIALLY (DEFERRED | IMMEDIATE) ; //TODO : Some properties are mutualy exclusive ie INITIALLY DEFERRED is not compatible with NOT DEFERRABLE // also VALIDATE | NOVALIDATE need to be after ENABLE or ENFORCED. Lot of case to handle :) common_constraint_properties - : enforced_not_enforced ( VALIDATE | NOVALIDATE )? + : enforced_not_enforced (VALIDATE | NOVALIDATE)? | deferrable_not_deferrable | initially_deferred_or_immediate - | ( ENABLE | DISABLE ) ( VALIDATE | NOVALIDATE )? + | ( ENABLE | DISABLE) ( VALIDATE | NOVALIDATE)? | RELY | NORELY ; @@ -1197,12 +1199,12 @@ on_delete ; foreign_key_match - : MATCH match_type=( FULL | PARTIAL | SIMPLE ) + : MATCH match_type = (FULL | PARTIAL | SIMPLE) ; on_action : CASCADE - | SET ( NULL_ | DEFAULT ) + | SET ( NULL_ | DEFAULT) | RESTRICT | NO ACTION ; @@ -1210,7 +1212,7 @@ on_action constraint_properties : common_constraint_properties* | foreign_key_match - | foreign_key_match? ( on_update on_delete? | on_delete on_update? ) + | foreign_key_match? ( on_update on_delete? | on_delete on_update?) ; ext_table_column_action @@ -1222,21 +1224,17 @@ ext_table_column_action constraint_action : ADD out_of_line_constraint | RENAME CONSTRAINT id_ TO id_ - | alter_modify ( CONSTRAINT id_ | primary_key | UNIQUE | foreign_key ) column_list_in_parentheses - enforced_not_enforced? ( VALIDATE | NOVALIDATE ) ( RELY | NORELY ) - | DROP ( CONSTRAINT id_ | primary_key | UNIQUE | foreign_key ) column_list_in_parentheses - cascade_restrict? + | alter_modify (CONSTRAINT id_ | primary_key | UNIQUE | foreign_key) column_list_in_parentheses enforced_not_enforced? ( + VALIDATE + | NOVALIDATE + ) (RELY | NORELY) + | DROP (CONSTRAINT id_ | primary_key | UNIQUE | foreign_key) column_list_in_parentheses cascade_restrict? | DROP PRIMARY KEY - ; search_optimization_action - : ADD SEARCH OPTIMIZATION ( - ON search_method_with_target (COMMA search_method_with_target )* - )? - | DROP SEARCH OPTIMIZATION ( - ON search_method_with_target (COMMA search_method_with_target )* - )? + : ADD SEARCH OPTIMIZATION (ON search_method_with_target (COMMA search_method_with_target)*)? + | DROP SEARCH OPTIMIZATION (ON search_method_with_target (COMMA search_method_with_target)*)? ; search_method_with_target @@ -1244,8 +1242,13 @@ search_method_with_target ; alter_table_alter_column - : ALTER TABLE object_name alter_modify ('(' alter_column_decl_list ')' | alter_column_decl_list ) - | ALTER TABLE object_name alter_modify COLUMN column_name SET MASKING POLICY id_ ( USING '(' column_name COMMA column_list ')' )? FORCE? + : ALTER TABLE object_name alter_modify ( + '(' alter_column_decl_list ')' + | alter_column_decl_list + ) + | ALTER TABLE object_name alter_modify COLUMN column_name SET MASKING POLICY id_ ( + USING '(' column_name COMMA column_list ')' + )? FORCE? | ALTER TABLE object_name alter_modify COLUMN column_name UNSET MASKING POLICY | ALTER TABLE object_name alter_modify column_set_tags (COMMA column_set_tags)* | ALTER TABLE object_name alter_modify column_unset_tags (COMMA column_unset_tags)* @@ -1262,8 +1265,8 @@ alter_column_decl alter_column_opts : DROP DEFAULT | SET DEFAULT object_name DOT NEXTVAL - | ( SET? NOT NULL_ | DROP NOT NULL_ ) - | ( (SET DATA)? TYPE )? data_type + | ( SET? NOT NULL_ | DROP NOT NULL_) + | ( (SET DATA)? TYPE)? data_type | comment_clause | UNSET COMMENT ; @@ -1282,26 +1285,14 @@ alter_tag alter_task : ALTER TASK if_exists? object_name resume_suspend - | ALTER TASK if_exists? object_name ( REMOVE | ADD ) AFTER string_list + | ALTER TASK if_exists? object_name ( REMOVE | ADD) AFTER string_list | ALTER TASK if_exists? object_name SET - // TODO : Check and review if element's order binded or not - ( WAREHOUSE EQ id_ )? - task_schedule? - task_overlap? - task_timeout? - task_suspend_after_failure_number? - comment_clause? - session_params_list? + // TODO : Check and review if element's order binded or not + (WAREHOUSE EQ id_)? task_schedule? task_overlap? task_timeout? task_suspend_after_failure_number? comment_clause? session_params_list? | ALTER TASK if_exists? object_name UNSET - // TODO : Check and review if element's order binded or not - WAREHOUSE? - SCHEDULE? - ALLOW_OVERLAPPING_EXECUTION? - USER_TASK_TIMEOUT_MS? - SUSPEND_TASK_AFTER_NUM_FAILURES? - COMMENT? - session_parameter_list? - //[ , ... ] + // TODO : Check and review if element's order binded or not + WAREHOUSE? SCHEDULE? ALLOW_OVERLAPPING_EXECUTION? USER_TASK_TIMEOUT_MS? SUSPEND_TASK_AFTER_NUM_FAILURES? COMMENT? session_parameter_list? + //[ , ... ] | ALTER TASK if_exists? object_name set_tags | ALTER TASK if_exists? object_name unset_tags | ALTER TASK if_exists? object_name MODIFY AS sql @@ -1324,15 +1315,17 @@ alter_view | ALTER VIEW if_exists? object_name DROP ROW ACCESS POLICY id_ | ALTER VIEW if_exists? object_name ADD ROW ACCESS POLICY id_ ON column_list_in_parentheses COMMA DROP ROW ACCESS POLICY id_ | ALTER VIEW if_exists? object_name DROP ALL ROW ACCESS POLICIES - | ALTER VIEW object_name alter_modify COLUMN? id_ SET MASKING POLICY id_ ( USING '(' column_name COMMA column_list ')' )? - FORCE? + | ALTER VIEW object_name alter_modify COLUMN? id_ SET MASKING POLICY id_ ( + USING '(' column_name COMMA column_list ')' + )? FORCE? | ALTER VIEW object_name alter_modify COLUMN? id_ UNSET MASKING POLICY | ALTER VIEW object_name alter_modify COLUMN? id_ set_tags | ALTER VIEW object_name alter_modify COLUMN id_ unset_tags ; alter_modify - : ALTER | MODIFY + : ALTER + | MODIFY ; alter_warehouse @@ -1340,8 +1333,8 @@ alter_warehouse ; alter_connection_opts - : id_ ENABLE FAILOVER TO ACCOUNTS id_ DOT id_ ( COMMA id_ DOT id_ )* ignore_edition_check? - | id_ DISABLE FAILOVER ( TO ACCOUNTS id_ DOT id_ (COMMA id_ DOT id_) )? + : id_ ENABLE FAILOVER TO ACCOUNTS id_ DOT id_ (COMMA id_ DOT id_)* ignore_edition_check? + | id_ DISABLE FAILOVER ( TO ACCOUNTS id_ DOT id_ (COMMA id_ DOT id_))? | id_ PRIMARY | if_exists? id_ SET comment_clause | if_exists? id_ UNSET COMMENT @@ -1352,16 +1345,16 @@ alter_user_opts | RESET PASSWORD | ABORT ALL QUERIES | ADD DELEGATED AUTHORIZATION OF ROLE id_ TO SECURITY INTEGRATION id_ - | REMOVE DELEGATED ( AUTHORIZATION OF ROLE id_ | AUTHORIZATIONS ) FROM SECURITY INTEGRATION id_ + | REMOVE DELEGATED (AUTHORIZATION OF ROLE id_ | AUTHORIZATIONS) FROM SECURITY INTEGRATION id_ | set_tags | unset_tags -// | SET object_properties? object_params? session_params? -// | UNSET (object_property_name | object_param_name | session_param_name) //[ , ... ] + // | SET object_properties? object_params? session_params? + // | UNSET (object_property_name | object_param_name | session_param_name) //[ , ... ] ; alter_tag_opts : RENAME TO object_name - | ( ADD | DROP ) tag_allowed_values + | ( ADD | DROP) tag_allowed_values | UNSET ALLOWED_VALUES | SET MASKING POLICY id_ (COMMA MASKING POLICY id_)* | UNSET MASKING POLICY id_ (COMMA MASKING POLICY id_)* @@ -1370,19 +1363,18 @@ alter_tag_opts ; alter_network_policy_opts - : if_exists? id_ SET - (ALLOWED_IP_LIST EQ '(' string_list ')' )? - (BLOCKED_IP_LIST EQ '(' string_list ')' )? - comment_clause? + : if_exists? id_ SET (ALLOWED_IP_LIST EQ '(' string_list ')')? ( + BLOCKED_IP_LIST EQ '(' string_list ')' + )? comment_clause? | if_exists? id_ UNSET COMMENT | id_ RENAME TO id_ ; alter_warehouse_opts - : id_fn? ( SUSPEND | RESUME if_suspended? ) + : id_fn? (SUSPEND | RESUME if_suspended?) | id_fn? ABORT ALL QUERIES | id_fn RENAME TO id_ -// | id_ SET [ objectProperties ] + // | id_ SET [ objectProperties ] | id_fn set_tags | id_fn unset_tags | id_fn UNSET id_ (COMMA id_)* @@ -1395,7 +1387,7 @@ alter_account_opts | SET RESOURCE_MONITOR EQ id_ | set_tags | unset_tags - | id_ RENAME TO id_ ( SAVE_OLD_URL EQ true_false )? + | id_ RENAME TO id_ ( SAVE_OLD_URL EQ true_false)? | id_ DROP OLD URL ; @@ -1404,7 +1396,7 @@ set_tags ; tag_decl_list - : TAG object_name EQ tag_value (COMMA object_name EQ tag_value )* + : TAG object_name EQ tag_value (COMMA object_name EQ tag_value)* ; unset_tags @@ -1461,25 +1453,17 @@ create_command ; create_account - : CREATE ACCOUNT id_ - ADMIN_NAME EQ id_ - ADMIN_PASSWORD EQ string - ( FIRST_NAME EQ id_ )? - ( LAST_NAME EQ id_ )? - EMAIL EQ string - ( MUST_CHANGE_PASSWORD EQ true_false )? - EDITION EQ ( STANDARD | ENTERPRISE | BUSINESS_CRITICAL ) - ( REGION_GROUP EQ region_group_id )? - ( REGION EQ snowflake_region_id )? - comment_clause? + : CREATE ACCOUNT id_ ADMIN_NAME EQ id_ ADMIN_PASSWORD EQ string (FIRST_NAME EQ id_)? ( + LAST_NAME EQ id_ + )? EMAIL EQ string (MUST_CHANGE_PASSWORD EQ true_false)? EDITION EQ ( + STANDARD + | ENTERPRISE + | BUSINESS_CRITICAL + ) (REGION_GROUP EQ region_group_id)? (REGION EQ snowflake_region_id)? comment_clause? ; create_alert - : CREATE or_replace? ALERT if_not_exists? id_ - WAREHOUSE EQ id_ - SCHEDULE EQ string - IF '(' EXISTS '(' alert_condition ')' ')' - THEN alert_action + : CREATE or_replace? ALERT if_not_exists? id_ WAREHOUSE EQ id_ SCHEDULE EQ string IF '(' EXISTS '(' alert_condition ')' ')' THEN alert_action ; alert_condition @@ -1493,60 +1477,48 @@ alert_action ; create_api_integration - : CREATE or_replace? API INTEGRATION if_not_exists? id_ - API_PROVIDER EQ ( id_ ) - API_AWS_ROLE_ARN EQ string - ( API_KEY EQ string )? - API_ALLOWED_PREFIXES EQ LR_BRACKET string RR_BRACKET - ( API_BLOCKED_PREFIXES EQ LR_BRACKET string RR_BRACKET )? - ENABLED EQ true_false - comment_clause? - | CREATE or_replace? API INTEGRATION if_not_exists? id_ - API_PROVIDER EQ id_ - AZURE_TENANT_ID EQ string - AZURE_AD_APPLICATION_ID EQ string - ( API_KEY EQ string )? - API_ALLOWED_PREFIXES EQ '(' string ')' - ( API_BLOCKED_PREFIXES EQ '(' string ')' )? - ENABLED EQ true_false - comment_clause? - | CREATE or_replace API INTEGRATION if_not_exists id_ - API_PROVIDER EQ id_ - GOOGLE_AUDIENCE EQ string - API_ALLOWED_PREFIXES EQ '(' string ')' - ( API_BLOCKED_PREFIXES EQ '(' string ')' )? - ENABLED EQ true_false - comment_clause? + : CREATE or_replace? API INTEGRATION if_not_exists? id_ API_PROVIDER EQ (id_) API_AWS_ROLE_ARN EQ string ( + API_KEY EQ string + )? API_ALLOWED_PREFIXES EQ LR_BRACKET string RR_BRACKET ( + API_BLOCKED_PREFIXES EQ LR_BRACKET string RR_BRACKET + )? ENABLED EQ true_false comment_clause? + | CREATE or_replace? API INTEGRATION if_not_exists? id_ API_PROVIDER EQ id_ AZURE_TENANT_ID EQ string AZURE_AD_APPLICATION_ID EQ string ( + API_KEY EQ string + )? API_ALLOWED_PREFIXES EQ '(' string ')' (API_BLOCKED_PREFIXES EQ '(' string ')')? ENABLED EQ true_false comment_clause? + | CREATE or_replace API INTEGRATION if_not_exists id_ API_PROVIDER EQ id_ GOOGLE_AUDIENCE EQ string API_ALLOWED_PREFIXES EQ '(' string ')' ( + API_BLOCKED_PREFIXES EQ '(' string ')' + )? ENABLED EQ true_false comment_clause? ; create_object_clone - : CREATE or_replace? ( DATABASE | SCHEMA | TABLE ) if_not_exists? id_ - CLONE object_name - ( at_before1 LR_BRACKET ( TIMESTAMP ASSOC string | OFFSET ASSOC string | STATEMENT ASSOC id_ ) RR_BRACKET )? - | CREATE or_replace? ( STAGE | FILE FORMAT | SEQUENCE | STREAM | TASK ) if_not_exists? object_name - CLONE object_name + : CREATE or_replace? (DATABASE | SCHEMA | TABLE) if_not_exists? id_ CLONE object_name ( + at_before1 LR_BRACKET (TIMESTAMP ASSOC string | OFFSET ASSOC string | STATEMENT ASSOC id_) RR_BRACKET + )? + | CREATE or_replace? (STAGE | FILE FORMAT | SEQUENCE | STREAM | TASK) if_not_exists? object_name CLONE object_name ; create_connection - : CREATE CONNECTION if_not_exists? id_ ( comment_clause? | (AS REPLICA OF id_ DOT id_ DOT id_ comment_clause?) ) + : CREATE CONNECTION if_not_exists? id_ ( + comment_clause? + | (AS REPLICA OF id_ DOT id_ DOT id_ comment_clause?) + ) ; create_database - : CREATE or_replace? TRANSIENT? DATABASE if_not_exists? id_ - clone_at_before? - ( DATA_RETENTION_TIME_IN_DAYS EQ num )? - ( MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num )? - default_ddl_collation? - with_tags? - comment_clause? + : CREATE or_replace? TRANSIENT? DATABASE if_not_exists? id_ clone_at_before? ( + DATA_RETENTION_TIME_IN_DAYS EQ num + )? (MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num)? default_ddl_collation? with_tags? comment_clause? ; clone_at_before - : CLONE id_ ( at_before1 LR_BRACKET ( TIMESTAMP ASSOC string | OFFSET ASSOC string | STATEMENT ASSOC id_ ) RR_BRACKET )? + : CLONE id_ ( + at_before1 LR_BRACKET (TIMESTAMP ASSOC string | OFFSET ASSOC string | STATEMENT ASSOC id_) RR_BRACKET + )? ; at_before1 - : AT_KEYWORD | BEFORE + : AT_KEYWORD + | BEFORE ; header_decl @@ -1565,83 +1537,44 @@ compression ; create_dynamic_table - : CREATE or_replace? DYNAMIC TABLE id_ - TARGET_LAG EQ (string | DOWNSTREAM) - WAREHOUSE EQ wh=id_ - AS query_statement + : CREATE or_replace? DYNAMIC TABLE id_ TARGET_LAG EQ (string | DOWNSTREAM) WAREHOUSE EQ wh = id_ AS query_statement ; create_event_table - : CREATE or_replace? EVENT TABLE if_not_exists? id_ - cluster_by? - (DATA_RETENTION_TIME_IN_DAYS EQ num)? - (MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num)? - change_tracking? - (DEFAULT_DDL_COLLATION_ EQ string)? - copy_grants? - with_row_access_policy? - with_tags? - (WITH? comment_clause)? + : CREATE or_replace? EVENT TABLE if_not_exists? id_ cluster_by? ( + DATA_RETENTION_TIME_IN_DAYS EQ num + )? (MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num)? change_tracking? ( + DEFAULT_DDL_COLLATION_ EQ string + )? copy_grants? with_row_access_policy? with_tags? (WITH? comment_clause)? ; create_external_function - : CREATE or_replace? SECURE? EXTERNAL FUNCTION object_name LR_BRACKET ( arg_name arg_data_type (COMMA arg_name arg_data_type)* )? RR_BRACKET - RETURNS data_type - null_not_null? - ( ( CALLED ON NULL_ INPUT) | ((RETURNS NULL_ ON NULL_ INPUT) | STRICT) )? - ( VOLATILE | IMMUTABLE )? - comment_clause? - API_INTEGRATION EQ id_ - ( HEADERS EQ LR_BRACKET header_decl (COMMA header_decl)* RR_BRACKET )? - ( CONTEXT_HEADERS EQ LR_BRACKET id_ (COMMA id_)* RR_BRACKET )? - ( MAX_BATCH_ROWS EQ num )? - compression? - ( REQUEST_TRANSLATOR EQ id_ )? - ( RESPONSE_TRANSLATOR EQ id_ )? - AS string + : CREATE or_replace? SECURE? EXTERNAL FUNCTION object_name LR_BRACKET ( + arg_name arg_data_type (COMMA arg_name arg_data_type)* + )? RR_BRACKET RETURNS data_type null_not_null? ( + ( CALLED ON NULL_ INPUT) + | ((RETURNS NULL_ ON NULL_ INPUT) | STRICT) + )? (VOLATILE | IMMUTABLE)? comment_clause? API_INTEGRATION EQ id_ ( + HEADERS EQ LR_BRACKET header_decl (COMMA header_decl)* RR_BRACKET + )? (CONTEXT_HEADERS EQ LR_BRACKET id_ (COMMA id_)* RR_BRACKET)? (MAX_BATCH_ROWS EQ num)? compression? ( + REQUEST_TRANSLATOR EQ id_ + )? (RESPONSE_TRANSLATOR EQ id_)? AS string ; create_external_table - // Partitions computed from expressions - : CREATE or_replace? EXTERNAL TABLE if_not_exists? - object_name '(' external_table_column_decl_list ')' - cloud_provider_params3? - partition_by? - WITH? LOCATION EQ external_stage - ( REFRESH_ON_CREATE EQ true_false )? - ( AUTO_REFRESH EQ true_false )? - pattern? - file_format - ( AWS_SNS_TOPIC EQ string )? - copy_grants? - with_row_access_policy? - with_tags? - comment_clause? +// Partitions computed from expressions + : CREATE or_replace? EXTERNAL TABLE if_not_exists? object_name '(' external_table_column_decl_list ')' cloud_provider_params3? partition_by? WITH? + LOCATION EQ external_stage (REFRESH_ON_CREATE EQ true_false)? (AUTO_REFRESH EQ true_false)? pattern? file_format ( + AWS_SNS_TOPIC EQ string + )? copy_grants? with_row_access_policy? with_tags? comment_clause? // Partitions added and removed manually - | CREATE or_replace? EXTERNAL TABLE if_not_exists? - object_name '(' external_table_column_decl_list ')' - cloud_provider_params3? - partition_by? - WITH? LOCATION EQ external_stage - PARTITION_TYPE EQ USER_SPECIFIED - file_format - copy_grants? - with_row_access_policy? - with_tags? - comment_clause? + | CREATE or_replace? EXTERNAL TABLE if_not_exists? object_name '(' external_table_column_decl_list ')' cloud_provider_params3? partition_by? WITH? + LOCATION EQ external_stage PARTITION_TYPE EQ USER_SPECIFIED file_format copy_grants? with_row_access_policy? with_tags? comment_clause? // Delta Lake - | CREATE or_replace? EXTERNAL TABLE if_not_exists? - object_name '(' external_table_column_decl_list ')' - cloud_provider_params3? - partition_by? - WITH? LOCATION EQ external_stage - PARTITION_TYPE EQ USER_SPECIFIED - file_format - ( TABLE_FORMAT EQ DELTA )? - copy_grants? - with_row_access_policy? - with_tags? - comment_clause? + | CREATE or_replace? EXTERNAL TABLE if_not_exists? object_name '(' external_table_column_decl_list ')' cloud_provider_params3? partition_by? WITH? + LOCATION EQ external_stage PARTITION_TYPE EQ USER_SPECIFIED file_format ( + TABLE_FORMAT EQ DELTA + )? copy_grants? with_row_access_policy? with_tags? comment_clause? ; external_table_column_decl @@ -1657,21 +1590,20 @@ full_acct ; integration_type_name - : SECURITY INTEGRATIONS | API INTEGRATIONS + : SECURITY INTEGRATIONS + | API INTEGRATIONS ; create_failover_group - : CREATE FAILOVER GROUP if_not_exists? id_ - OBJECT_TYPES EQ object_type (COMMA object_type )* - ( ALLOWED_DATABASES EQ id_ (COMMA id_ )* )? - ( ALLOWED_SHARES EQ id_ (COMMA id_)* )? - ( ALLOWED_INTEGRATION_TYPES EQ integration_type_name (COMMA integration_type_name)* )? - ALLOWED_ACCOUNTS EQ full_acct (COMMA full_acct)* - ( IGNORE EDITION CHECK )? - ( REPLICATION_SCHEDULE EQ string )? -// Secondary Replication Group - | CREATE FAILOVER GROUP if_not_exists? id_ - AS REPLICA OF id_ DOT id_ DOT id_ + : CREATE FAILOVER GROUP if_not_exists? id_ OBJECT_TYPES EQ object_type (COMMA object_type)* ( + ALLOWED_DATABASES EQ id_ (COMMA id_)* + )? (ALLOWED_SHARES EQ id_ (COMMA id_)*)? ( + ALLOWED_INTEGRATION_TYPES EQ integration_type_name (COMMA integration_type_name)* + )? ALLOWED_ACCOUNTS EQ full_acct (COMMA full_acct)* (IGNORE EDITION CHECK)? ( + REPLICATION_SCHEDULE EQ string + )? + // Secondary Replication Group + | CREATE FAILOVER GROUP if_not_exists? id_ AS REPLICA OF id_ DOT id_ DOT id_ ; type_fileformat @@ -1690,9 +1622,7 @@ type_fileformat ; create_file_format - : CREATE or_replace? FILE FORMAT if_not_exists? object_name - (TYPE EQ type_fileformat)? format_type_options* - comment_clause? + : CREATE or_replace? FILE FORMAT if_not_exists? object_name (TYPE EQ type_fileformat)? format_type_options* comment_clause? ; arg_decl @@ -1709,33 +1639,33 @@ function_definition ; create_function - : CREATE or_replace? SECURE? FUNCTION object_name LR_BRACKET ( arg_decl (COMMA arg_decl)* )? RR_BRACKET - RETURNS ( data_type | TABLE LR_BRACKET (col_decl (COMMA col_decl)* )? RR_BRACKET ) - null_not_null? - LANGUAGE JAVASCRIPT - ( CALLED ON NULL_ INPUT | RETURNS NULL_ ON NULL_ INPUT | STRICT )? - ( VOLATILE | IMMUTABLE )? - comment_clause? - AS function_definition - | CREATE or_replace? SECURE? FUNCTION object_name LR_BRACKET ( arg_decl (COMMA arg_decl)* )? RR_BRACKET - RETURNS ( data_type | TABLE LR_BRACKET (col_decl (COMMA col_decl)* )? RR_BRACKET ) - null_not_null? - ( CALLED ON NULL_ INPUT | RETURNS NULL_ ON NULL_ INPUT | STRICT )? - ( VOLATILE | IMMUTABLE )? - MEMOIZABLE? - comment_clause? - AS function_definition + : CREATE or_replace? SECURE? FUNCTION object_name LR_BRACKET (arg_decl (COMMA arg_decl)*)? RR_BRACKET RETURNS ( + data_type + | TABLE LR_BRACKET (col_decl (COMMA col_decl)*)? RR_BRACKET + ) null_not_null? LANGUAGE JAVASCRIPT ( + CALLED ON NULL_ INPUT + | RETURNS NULL_ ON NULL_ INPUT + | STRICT + )? (VOLATILE | IMMUTABLE)? comment_clause? AS function_definition + | CREATE or_replace? SECURE? FUNCTION object_name LR_BRACKET (arg_decl (COMMA arg_decl)*)? RR_BRACKET RETURNS ( + data_type + | TABLE LR_BRACKET (col_decl (COMMA col_decl)*)? RR_BRACKET + ) null_not_null? (CALLED ON NULL_ INPUT | RETURNS NULL_ ON NULL_ INPUT | STRICT)? ( + VOLATILE + | IMMUTABLE + )? MEMOIZABLE? comment_clause? AS function_definition ; create_managed_account - : CREATE MANAGED ACCOUNT id_ ADMIN_NAME EQ id_ COMMA ADMIN_PASSWORD EQ string COMMA TYPE EQ READER (COMMA comment_clause)? + : CREATE MANAGED ACCOUNT id_ ADMIN_NAME EQ id_ COMMA ADMIN_PASSWORD EQ string COMMA TYPE EQ READER ( + COMMA comment_clause + )? ; create_masking_policy - : CREATE or_replace? MASKING POLICY if_not_exists? object_name AS - '(' arg_name arg_data_type (COMMA arg_name arg_data_type)? ')' - RETURNS arg_data_type ARROW expr - comment_clause? + : CREATE or_replace? MASKING POLICY if_not_exists? object_name AS '(' arg_name arg_data_type ( + COMMA arg_name arg_data_type + )? ')' RETURNS arg_data_type ARROW expr comment_clause? ; tag_decl @@ -1747,71 +1677,49 @@ column_list_in_parentheses ; create_materialized_view - : CREATE or_replace? SECURE? MATERIALIZED VIEW if_not_exists? object_name - ( LR_BRACKET column_list_with_comment RR_BRACKET )? - view_col* - with_row_access_policy? - with_tags? - copy_grants? - comment_clause? - cluster_by? - AS select_statement //NOTA MATERIALIZED VIEW accept only simple select statement at this time + : CREATE or_replace? SECURE? MATERIALIZED VIEW if_not_exists? object_name ( + LR_BRACKET column_list_with_comment RR_BRACKET + )? view_col* with_row_access_policy? with_tags? copy_grants? comment_clause? cluster_by? AS select_statement + //NOTA MATERIALIZED VIEW accept only simple select statement at this time ; create_network_policy - : CREATE or_replace? NETWORK POLICY id_ - ALLOWED_IP_LIST EQ '(' string_list? ')' - ( BLOCKED_IP_LIST EQ '(' string_list? ')' )? - comment_clause? + : CREATE or_replace? NETWORK POLICY id_ ALLOWED_IP_LIST EQ '(' string_list? ')' ( + BLOCKED_IP_LIST EQ '(' string_list? ')' + )? comment_clause? ; cloud_provider_params_auto - //(for Google Cloud Storage) +//(for Google Cloud Storage) : NOTIFICATION_PROVIDER EQ GCP_PUBSUB GCP_PUBSUB_SUBSCRIPTION_NAME EQ string //(for Microsoft Azure Storage) | NOTIFICATION_PROVIDER EQ AZURE_EVENT_GRID AZURE_STORAGE_QUEUE_PRIMARY_URI EQ string AZURE_TENANT_ID EQ string ; cloud_provider_params_push - //(for Amazon SNS) - : NOTIFICATION_PROVIDER EQ AWS_SNS - AWS_SNS_TOPIC_ARN EQ string - AWS_SNS_ROLE_ARN EQ string +//(for Amazon SNS) + : NOTIFICATION_PROVIDER EQ AWS_SNS AWS_SNS_TOPIC_ARN EQ string AWS_SNS_ROLE_ARN EQ string //(for Google Pub/Sub) - | NOTIFICATION_PROVIDER EQ GCP_PUBSUB - GCP_PUBSUB_TOPIC_NAME EQ string + | NOTIFICATION_PROVIDER EQ GCP_PUBSUB GCP_PUBSUB_TOPIC_NAME EQ string //(for Microsoft Azure Event Grid) - | NOTIFICATION_PROVIDER EQ AZURE_EVENT_GRID - AZURE_EVENT_GRID_TOPIC_ENDPOINT EQ string - AZURE_TENANT_ID EQ string + | NOTIFICATION_PROVIDER EQ AZURE_EVENT_GRID AZURE_EVENT_GRID_TOPIC_ENDPOINT EQ string AZURE_TENANT_ID EQ string ; create_notification_integration - : CREATE or_replace? NOTIFICATION INTEGRATION if_not_exists? id_ - ENABLED EQ true_false - TYPE EQ QUEUE - cloud_provider_params_auto - comment_clause? - | CREATE or_replace? NOTIFICATION INTEGRATION if_not_exists? id_ - ENABLED EQ true_false - DIRECTION EQ OUTBOUND - TYPE EQ QUEUE - cloud_provider_params_push - comment_clause? + : CREATE or_replace? NOTIFICATION INTEGRATION if_not_exists? id_ ENABLED EQ true_false TYPE EQ QUEUE cloud_provider_params_auto comment_clause? + | CREATE or_replace? NOTIFICATION INTEGRATION if_not_exists? id_ ENABLED EQ true_false DIRECTION EQ OUTBOUND TYPE EQ QUEUE + cloud_provider_params_push comment_clause? ; create_pipe - : CREATE or_replace? PIPE if_not_exists? object_name - ( AUTO_INGEST EQ true_false )? - ( ERROR_INTEGRATION EQ id_ )? - ( AWS_SNS_TOPIC EQ string )? - ( INTEGRATION EQ string )? - comment_clause? - AS copy_into_table + : CREATE or_replace? PIPE if_not_exists? object_name (AUTO_INGEST EQ true_false)? ( + ERROR_INTEGRATION EQ id_ + )? (AWS_SNS_TOPIC EQ string)? (INTEGRATION EQ string)? comment_clause? AS copy_into_table ; caller_owner - : CALLER | OWNER + : CALLER + | OWNER ; executa_as @@ -1824,46 +1732,39 @@ procedure_definition ; create_procedure - : CREATE or_replace? PROCEDURE object_name LR_BRACKET ( arg_decl (COMMA arg_decl)* )? RR_BRACKET - RETURNS ( data_type | TABLE LR_BRACKET ( col_decl (COMMA col_decl)* )? RR_BRACKET ) - ( NOT NULL_ )? - LANGUAGE SQL - ( CALLED ON NULL_ INPUT | RETURNS NULL_ ON NULL_ INPUT | STRICT )? - ( VOLATILE | IMMUTABLE )? // Note: VOLATILE and IMMUTABLE are deprecated. - comment_clause? - executa_as? - AS procedure_definition - | CREATE or_replace? SECURE? PROCEDURE object_name LR_BRACKET ( arg_decl (COMMA arg_decl)* )? RR_BRACKET - RETURNS data_type ( NOT NULL_ )? - LANGUAGE JAVASCRIPT - ( CALLED ON NULL_ INPUT | RETURNS NULL_ ON NULL_ INPUT | STRICT )? - ( VOLATILE | IMMUTABLE )? // Note: VOLATILE and IMMUTABLE are deprecated. - comment_clause? - executa_as? - AS procedure_definition + : CREATE or_replace? PROCEDURE object_name LR_BRACKET (arg_decl (COMMA arg_decl)*)? RR_BRACKET RETURNS ( + data_type + | TABLE LR_BRACKET ( col_decl (COMMA col_decl)*)? RR_BRACKET + ) (NOT NULL_)? LANGUAGE SQL (CALLED ON NULL_ INPUT | RETURNS NULL_ ON NULL_ INPUT | STRICT)? ( + VOLATILE + | IMMUTABLE + )? // Note: VOLATILE and IMMUTABLE are deprecated. + comment_clause? executa_as? AS procedure_definition + | CREATE or_replace? SECURE? PROCEDURE object_name LR_BRACKET (arg_decl (COMMA arg_decl)*)? RR_BRACKET RETURNS data_type ( + NOT NULL_ + )? LANGUAGE JAVASCRIPT (CALLED ON NULL_ INPUT | RETURNS NULL_ ON NULL_ INPUT | STRICT)? ( + VOLATILE + | IMMUTABLE + )? // Note: VOLATILE and IMMUTABLE are deprecated. + comment_clause? executa_as? AS procedure_definition ; create_replication_group - : CREATE REPLICATION GROUP if_not_exists? id_ - OBJECT_TYPES EQ object_type ( COMMA object_type )* - ( ALLOWED_DATABASES EQ id_ (COMMA id_)* )? - ( ALLOWED_SHARES EQ id_ (COMMA id_ )* )? - ( ALLOWED_INTEGRATION_TYPES EQ integration_type_name (COMMA integration_type_name )* )? - ALLOWED_ACCOUNTS EQ full_acct (COMMA full_acct)* - ( IGNORE EDITION CHECK )? - ( REPLICATION_SCHEDULE EQ string )? + : CREATE REPLICATION GROUP if_not_exists? id_ OBJECT_TYPES EQ object_type (COMMA object_type)* ( + ALLOWED_DATABASES EQ id_ (COMMA id_)* + )? (ALLOWED_SHARES EQ id_ (COMMA id_)*)? ( + ALLOWED_INTEGRATION_TYPES EQ integration_type_name (COMMA integration_type_name)* + )? ALLOWED_ACCOUNTS EQ full_acct (COMMA full_acct)* (IGNORE EDITION CHECK)? ( + REPLICATION_SCHEDULE EQ string + )? //Secondary Replication Group | CREATE REPLICATION GROUP if_not_exists? id_ AS REPLICA OF id_ DOT id_ DOT id_ ; create_resource_monitor - : CREATE or_replace? RESOURCE MONITOR id_ WITH - credit_quota? - frequency? - ( START_TIMESTAMP EQ ( string | IMMEDIATELY ) )? - ( END_TIMESTAMP EQ string )? - notify_users? - ( TRIGGERS trigger_definition+ )? + : CREATE or_replace? RESOURCE MONITOR id_ WITH credit_quota? frequency? ( + START_TIMESTAMP EQ ( string | IMMEDIATELY) + )? (END_TIMESTAMP EQ string)? notify_users? (TRIGGERS trigger_definition+)? ; create_role @@ -1871,40 +1772,37 @@ create_role ; create_row_access_policy - : CREATE or_replace? ROW ACCESS POLICY if_not_exists? id_ AS - LR_BRACKET arg_decl (COMMA arg_decl)* RR_BRACKET - RETURNS BOOLEAN ARROW expr - comment_clause? + : CREATE or_replace? ROW ACCESS POLICY if_not_exists? id_ AS LR_BRACKET arg_decl ( + COMMA arg_decl + )* RR_BRACKET RETURNS BOOLEAN ARROW expr comment_clause? ; create_schema - : CREATE or_replace? TRANSIENT? SCHEMA if_not_exists? schema_name - clone_at_before? - ( WITH MANAGED ACCESS )? - ( DATA_RETENTION_TIME_IN_DAYS EQ num )? - ( MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num )? - default_ddl_collation? - with_tags? - comment_clause? + : CREATE or_replace? TRANSIENT? SCHEMA if_not_exists? schema_name clone_at_before? ( + WITH MANAGED ACCESS + )? (DATA_RETENTION_TIME_IN_DAYS EQ num)? (MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num)? default_ddl_collation? with_tags? comment_clause? ; create_security_integration_external_oauth - : CREATE or_replace? SECURITY INTEGRATION if_not_exists? id_ - TYPE EQ EXTERNAL_OAUTH - ENABLED EQ true_false - EXTERNAL_OAUTH_TYPE EQ ( OKTA | AZURE | PING_FEDERATE | CUSTOM ) - EXTERNAL_OAUTH_ISSUER EQ string - EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM EQ (string | '(' string_list ')' ) - EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE EQ string - ( EXTERNAL_OAUTH_JWS_KEYS_URL EQ string )? // For OKTA | PING_FEDERATE | CUSTOM - ( EXTERNAL_OAUTH_JWS_KEYS_URL EQ (string | '(' string_list ')') )? // For Azure - ( EXTERNAL_OAUTH_BLOCKED_ROLES_LIST EQ '(' string_list ')' )? - ( EXTERNAL_OAUTH_ALLOWED_ROLES_LIST EQ '(' string_list ')' )? - ( EXTERNAL_OAUTH_RSA_PUBLIC_KEY EQ string )? - ( EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2 EQ string )? - ( EXTERNAL_OAUTH_AUDIENCE_LIST EQ '(' string ')' )? - ( EXTERNAL_OAUTH_ANY_ROLE_MODE EQ (DISABLE | ENABLE | ENABLE_FOR_PRIVILEGE) )? - ( EXTERNAL_OAUTH_SCOPE_DELIMITER EQ string )? // Only for EXTERNAL_OAUTH_TYPE EQ CUSTOM + : CREATE or_replace? SECURITY INTEGRATION if_not_exists? id_ TYPE EQ EXTERNAL_OAUTH ENABLED EQ true_false EXTERNAL_OAUTH_TYPE EQ ( + OKTA + | AZURE + | PING_FEDERATE + | CUSTOM + ) EXTERNAL_OAUTH_ISSUER EQ string EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM EQ ( + string + | '(' string_list ')' + ) EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE EQ string ( + EXTERNAL_OAUTH_JWS_KEYS_URL EQ string + )? // For OKTA | PING_FEDERATE | CUSTOM + (EXTERNAL_OAUTH_JWS_KEYS_URL EQ (string | '(' string_list ')'))? // For Azure + (EXTERNAL_OAUTH_BLOCKED_ROLES_LIST EQ '(' string_list ')')? ( + EXTERNAL_OAUTH_ALLOWED_ROLES_LIST EQ '(' string_list ')' + )? (EXTERNAL_OAUTH_RSA_PUBLIC_KEY EQ string)? (EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2 EQ string)? ( + EXTERNAL_OAUTH_AUDIENCE_LIST EQ '(' string ')' + )? (EXTERNAL_OAUTH_ANY_ROLE_MODE EQ (DISABLE | ENABLE | ENABLE_FOR_PRIVILEGE))? ( + EXTERNAL_OAUTH_SCOPE_DELIMITER EQ string + )? // Only for EXTERNAL_OAUTH_TYPE EQ CUSTOM ; implicit_none @@ -1913,64 +1811,44 @@ implicit_none ; create_security_integration_snowflake_oauth - : CREATE or_replace? SECURITY INTEGRATION if_not_exists? id_ - TYPE EQ OAUTH - OAUTH_CLIENT EQ partner_application - OAUTH_REDIRECT_URI EQ string //Required when OAUTH_CLIENTEQLOOKER - enabled_true_false? - ( OAUTH_ISSUE_REFRESH_TOKENS EQ true_false )? - ( OAUTH_REFRESH_TOKEN_VALIDITY EQ num )? - ( OAUTH_USE_SECONDARY_ROLES EQ implicit_none )? - ( BLOCKED_ROLES_LIST EQ '(' string_list ')' )? - comment_clause? + : CREATE or_replace? SECURITY INTEGRATION if_not_exists? id_ TYPE EQ OAUTH OAUTH_CLIENT EQ partner_application OAUTH_REDIRECT_URI EQ string + //Required when OAUTH_CLIENTEQLOOKER + enabled_true_false? (OAUTH_ISSUE_REFRESH_TOKENS EQ true_false)? ( + OAUTH_REFRESH_TOKEN_VALIDITY EQ num + )? (OAUTH_USE_SECONDARY_ROLES EQ implicit_none)? (BLOCKED_ROLES_LIST EQ '(' string_list ')')? comment_clause? // Snowflake OAuth for custom clients - | CREATE or_replace? SECURITY INTEGRATION if_not_exists? id_ - TYPE EQ OAUTH - OAUTH_CLIENT EQ CUSTOM - //OAUTH_CLIENT_TYPE EQ 'CONFIDENTIAL' | 'PUBLIC' - OAUTH_REDIRECT_URI EQ string - enabled_true_false? - ( OAUTH_ALLOW_NON_TLS_REDIRECT_URI EQ true_false )? - ( OAUTH_ENFORCE_PKCE EQ true_false )? - ( OAUTH_USE_SECONDARY_ROLES EQ implicit_none )? - ( PRE_AUTHORIZED_ROLES_LIST EQ '(' string_list ')' )? - ( BLOCKED_ROLES_LIST EQ '(' string_list ')' )? - ( OAUTH_ISSUE_REFRESH_TOKENS EQ true_false )? - ( OAUTH_REFRESH_TOKEN_VALIDITY EQ num )? - network_policy? - ( OAUTH_CLIENT_RSA_PUBLIC_KEY EQ string )? - ( OAUTH_CLIENT_RSA_PUBLIC_KEY_2 EQ string )? - comment_clause? + | CREATE or_replace? SECURITY INTEGRATION if_not_exists? id_ TYPE EQ OAUTH OAUTH_CLIENT EQ CUSTOM + //OAUTH_CLIENT_TYPE EQ 'CONFIDENTIAL' | 'PUBLIC' + OAUTH_REDIRECT_URI EQ string enabled_true_false? ( + OAUTH_ALLOW_NON_TLS_REDIRECT_URI EQ true_false + )? (OAUTH_ENFORCE_PKCE EQ true_false)? (OAUTH_USE_SECONDARY_ROLES EQ implicit_none)? ( + PRE_AUTHORIZED_ROLES_LIST EQ '(' string_list ')' + )? (BLOCKED_ROLES_LIST EQ '(' string_list ')')? (OAUTH_ISSUE_REFRESH_TOKENS EQ true_false)? ( + OAUTH_REFRESH_TOKEN_VALIDITY EQ num + )? network_policy? (OAUTH_CLIENT_RSA_PUBLIC_KEY EQ string)? ( + OAUTH_CLIENT_RSA_PUBLIC_KEY_2 EQ string + )? comment_clause? ; create_security_integration_saml2 - : CREATE or_replace? SECURITY INTEGRATION if_not_exists? - TYPE EQ SAML2 - enabled_true_false - SAML2_ISSUER EQ string - SAML2_SSO_URL EQ string - SAML2_PROVIDER EQ string - SAML2_X509_CERT EQ string - ( SAML2_SP_INITIATED_LOGIN_PAGE_LABEL EQ string )? - ( SAML2_ENABLE_SP_INITIATED EQ true_false )? - ( SAML2_SNOWFLAKE_X509_CERT EQ string )? - ( SAML2_SIGN_REQUEST EQ true_false )? - ( SAML2_REQUESTED_NAMEID_FORMAT EQ string )? - ( SAML2_POST_LOGOUT_REDIRECT_URL EQ string )? - ( SAML2_FORCE_AUTHN EQ true_false )? - ( SAML2_SNOWFLAKE_ISSUER_URL EQ string )? - ( SAML2_SNOWFLAKE_ACS_URL EQ string )? + : CREATE or_replace? SECURITY INTEGRATION if_not_exists? TYPE EQ SAML2 enabled_true_false SAML2_ISSUER EQ string SAML2_SSO_URL EQ string + SAML2_PROVIDER EQ string SAML2_X509_CERT EQ string ( + SAML2_SP_INITIATED_LOGIN_PAGE_LABEL EQ string + )? (SAML2_ENABLE_SP_INITIATED EQ true_false)? (SAML2_SNOWFLAKE_X509_CERT EQ string)? ( + SAML2_SIGN_REQUEST EQ true_false + )? (SAML2_REQUESTED_NAMEID_FORMAT EQ string)? (SAML2_POST_LOGOUT_REDIRECT_URL EQ string)? ( + SAML2_FORCE_AUTHN EQ true_false + )? (SAML2_SNOWFLAKE_ISSUER_URL EQ string)? (SAML2_SNOWFLAKE_ACS_URL EQ string)? ; create_security_integration_scim - : CREATE or_replace? SECURITY INTEGRATION if_not_exists? - id_ - TYPE EQ SCIM - SCIM_CLIENT EQ (OKTA_Q | AZURE_Q | GENERIC_Q) - RUN_AS_ROLE EQ (OKTA_PROVISIONER_Q | AAD_PROVISIONER_Q | GENERIC_SCIM_PROVISIONER_Q) - network_policy? - ( SYNC_PASSWORD EQ true_false )? - comment_clause? + : CREATE or_replace? SECURITY INTEGRATION if_not_exists? id_ TYPE EQ SCIM SCIM_CLIENT EQ ( + OKTA_Q + | AZURE_Q + | GENERIC_Q + ) RUN_AS_ROLE EQ (OKTA_PROVISIONER_Q | AAD_PROVISIONER_Q | GENERIC_SCIM_PROVISIONER_Q) network_policy? ( + SYNC_PASSWORD EQ true_false + )? comment_clause? ; network_policy @@ -1992,24 +1870,17 @@ increment_by ; create_sequence - : CREATE or_replace? SEQUENCE if_not_exists? object_name - WITH? - start_with? - increment_by? - order_noorder? - comment_clause? + : CREATE or_replace? SEQUENCE if_not_exists? object_name WITH? start_with? increment_by? order_noorder? comment_clause? ; create_session_policy - : CREATE or_replace? SESSION POLICY if_exists? id_ - (SESSION_IDLE_TIMEOUT_MINS EQ num)? - (SESSION_UI_IDLE_TIMEOUT_MINS EQ num)? - comment_clause? + : CREATE or_replace? SESSION POLICY if_exists? id_ (SESSION_IDLE_TIMEOUT_MINS EQ num)? ( + SESSION_UI_IDLE_TIMEOUT_MINS EQ num + )? comment_clause? ; create_share - : CREATE or_replace? SHARE id_ - comment_clause? + : CREATE or_replace? SHARE id_ comment_clause? ; character @@ -2038,8 +1909,8 @@ character ; format_type_options - //-- If TYPE EQ CSV - : COMPRESSION EQ (AUTO | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE | AUTO_Q ) +//-- If TYPE EQ CSV + : COMPRESSION EQ (AUTO | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE | AUTO_Q) | RECORD_DELIMITER EQ ( string | NONE) | FIELD_DELIMITER EQ ( string | NONE) | FILE_EXTENSION EQ string @@ -2049,10 +1920,10 @@ format_type_options | TIME_FORMAT EQ (string | AUTO) | TIMESTAMP_FORMAT EQ (string | AUTO) | BINARY_FORMAT EQ (HEX | BASE64 | UTF8) - | ESCAPE EQ (character | NONE | NONE_Q ) - | ESCAPE_UNENCLOSED_FIELD EQ (string | NONE | NONE_Q ) + | ESCAPE EQ (character | NONE | NONE_Q) + | ESCAPE_UNENCLOSED_FIELD EQ (string | NONE | NONE_Q) | TRIM_SPACE EQ true_false - | FIELD_OPTIONALLY_ENCLOSED_BY EQ (string | NONE | NONE_Q | SINGLE_QUOTE ) + | FIELD_OPTIONALLY_ENCLOSED_BY EQ (string | NONE | NONE_Q | SINGLE_QUOTE) | NULL_IF EQ LR_BRACKET string_list RR_BRACKET | ERROR_ON_COLUMN_COUNT_MISMATCH EQ true_false | REPLACE_INVALID_CHARACTERS EQ true_false @@ -2061,56 +1932,68 @@ format_type_options | ENCODING EQ (string | UTF8) //by the way other encoding keyword are valid ie WINDOWS1252 //-- If TYPE EQ JSON //| COMPRESSION EQ (AUTO | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE) -// | DATE_FORMAT EQ string | AUTO -// | TIME_FORMAT EQ string | AUTO -// | TIMESTAMP_FORMAT EQ string | AUTO -// | BINARY_FORMAT EQ HEX | BASE64 | UTF8 -// | TRIM_SPACE EQ true_false -// | NULL_IF EQ LR_BRACKET string_list RR_BRACKET -// | FILE_EXTENSION EQ string + // | DATE_FORMAT EQ string | AUTO + // | TIME_FORMAT EQ string | AUTO + // | TIMESTAMP_FORMAT EQ string | AUTO + // | BINARY_FORMAT EQ HEX | BASE64 | UTF8 + // | TRIM_SPACE EQ true_false + // | NULL_IF EQ LR_BRACKET string_list RR_BRACKET + // | FILE_EXTENSION EQ string | ENABLE_OCTAL EQ true_false | ALLOW_DUPLICATE EQ true_false | STRIP_OUTER_ARRAY EQ true_false | STRIP_NULL_VALUES EQ true_false -// | REPLACE_INVALID_CHARACTERS EQ true_false + // | REPLACE_INVALID_CHARACTERS EQ true_false | IGNORE_UTF8_ERRORS EQ true_false -// | SKIP_BYTE_ORDER_MARK EQ true_false + // | SKIP_BYTE_ORDER_MARK EQ true_false //-- If TYPE EQ AVRO -// | COMPRESSION EQ AUTO | GZIP | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE -// | TRIM_SPACE EQ true_false -// | NULL_IF EQ LR_BRACKET string_list RR_BRACKET + // | COMPRESSION EQ AUTO | GZIP | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE + // | TRIM_SPACE EQ true_false + // | NULL_IF EQ LR_BRACKET string_list RR_BRACKET //-- If TYPE EQ ORC -// | TRIM_SPACE EQ true_false -// | NULL_IF EQ LR_BRACKET string_list RR_BRACKET + // | TRIM_SPACE EQ true_false + // | NULL_IF EQ LR_BRACKET string_list RR_BRACKET //-- If TYPE EQ PARQUET - | COMPRESSION EQ AUTO | LZO | SNAPPY | NONE + | COMPRESSION EQ AUTO + | LZO + | SNAPPY + | NONE | SNAPPY_COMPRESSION EQ true_false | BINARY_AS_TEXT EQ true_false -// | TRIM_SPACE EQ true_false -// | NULL_IF EQ LR_BRACKET string_list RR_BRACKET + // | TRIM_SPACE EQ true_false + // | NULL_IF EQ LR_BRACKET string_list RR_BRACKET //-- If TYPE EQ XML - | COMPRESSION EQ AUTO | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE -// | IGNORE_UTF8_ERRORS EQ true_false + | COMPRESSION EQ AUTO + | GZIP + | BZ2 + | BROTLI + | ZSTD + | DEFLATE + | RAW_DEFLATE + | NONE + // | IGNORE_UTF8_ERRORS EQ true_false | PRESERVE_SPACE EQ true_false | STRIP_OUTER_ELEMENT EQ true_false | DISABLE_SNOWFLAKE_DATA EQ true_false | DISABLE_AUTO_CONVERT EQ true_false -// | SKIP_BYTE_ORDER_MARK EQ true_false + // | SKIP_BYTE_ORDER_MARK EQ true_false ; copy_options - : ON_ERROR EQ ( CONTINUE | SKIP_FILE | SKIP_FILE_N | SKIP_FILE_N ABORT_STATEMENT ) + : ON_ERROR EQ (CONTINUE | SKIP_FILE | SKIP_FILE_N | SKIP_FILE_N ABORT_STATEMENT) | SIZE_LIMIT EQ num | PURGE EQ true_false | RETURN_FAILED_ONLY EQ true_false - | MATCH_BY_COLUMN_NAME EQ CASE_SENSITIVE | CASE_INSENSITIVE | NONE + | MATCH_BY_COLUMN_NAME EQ CASE_SENSITIVE + | CASE_INSENSITIVE + | NONE | ENFORCE_LENGTH EQ true_false | TRUNCATECOLUMNS EQ true_false | FORCE EQ true_false ; stage_encryption_opts_internal - : ENCRYPTION EQ LR_BRACKET TYPE EQ ( SNOWFLAKE_FULL | SNOWFLAKE_SSE ) RR_BRACKET + : ENCRYPTION EQ LR_BRACKET TYPE EQ (SNOWFLAKE_FULL | SNOWFLAKE_SSE) RR_BRACKET ; stage_type @@ -2126,11 +2009,7 @@ stage_kms_key ; stage_encryption_opts_aws - : ENCRYPTION EQ LR_BRACKET - ( stage_type? stage_master_key - | stage_type stage_kms_key? - ) - RR_BRACKET + : ENCRYPTION EQ LR_BRACKET (stage_type? stage_master_key | stage_type stage_kms_key?) RR_BRACKET ; aws_token @@ -2150,24 +2029,26 @@ aws_role ; azure_encryption_value - : ( TYPE EQ AZURE_CSE_Q )? MASTER_KEY EQ string + : (TYPE EQ AZURE_CSE_Q)? MASTER_KEY EQ string | MASTER_KEY EQ string TYPE EQ AZURE_CSE_Q | TYPE EQ NONE_Q ; + stage_encryption_opts_az : ENCRYPTION EQ LR_BRACKET azure_encryption_value RR_BRACKET ; + storage_integration_eq_id : STORAGE_INTEGRATION EQ id_ ; -az_credential_or_storage_integration: - storage_integration_eq_id - | CREDENTIALS EQ LR_BRACKET AZURE_SAS_TOKEN EQ string RR_BRACKET +az_credential_or_storage_integration + : storage_integration_eq_id + | CREDENTIALS EQ LR_BRACKET AZURE_SAS_TOKEN EQ string RR_BRACKET ; gcp_encryption_value - : ( TYPE EQ GCS_SSE_KMS_Q )? KMS_KEY_ID EQ string + : (TYPE EQ GCS_SSE_KMS_Q)? KMS_KEY_ID EQ string | KMS_KEY_ID EQ string TYPE EQ GCS_SSE_KMS_Q | TYPE EQ NONE_Q ; @@ -2176,21 +2057,27 @@ stage_encryption_opts_gcp : ENCRYPTION EQ LR_BRACKET gcp_encryption_value RR_BRACKET ; -aws_credential_or_storage_integration: - storage_integration_eq_id - | CREDENTIALS EQ LR_BRACKET ( aws_key_id aws_secret_key aws_token? | aws_role ) RR_BRACKET +aws_credential_or_storage_integration + : storage_integration_eq_id + | CREDENTIALS EQ LR_BRACKET (aws_key_id aws_secret_key aws_token? | aws_role) RR_BRACKET ; external_stage_params - //(for Amazon S3) - : URL EQ s3_url=( S3_PATH | S3GOV_PATH ) - ( aws_credential_or_storage_integration? stage_encryption_opts_aws | stage_encryption_opts_aws? aws_credential_or_storage_integration )? +//(for Amazon S3) + : URL EQ s3_url = (S3_PATH | S3GOV_PATH) ( + aws_credential_or_storage_integration? stage_encryption_opts_aws + | stage_encryption_opts_aws? aws_credential_or_storage_integration + )? //(for Google Cloud Storage) - | URL EQ gc_url=GCS_PATH - ( storage_integration_eq_id? stage_encryption_opts_gcp | stage_encryption_opts_gcp? storage_integration_eq_id )? + | URL EQ gc_url = GCS_PATH ( + storage_integration_eq_id? stage_encryption_opts_gcp + | stage_encryption_opts_gcp? storage_integration_eq_id + )? //(for Microsoft Azure) - | URL EQ azure_url=AZURE_PATH - ( az_credential_or_storage_integration? stage_encryption_opts_az | stage_encryption_opts_az? az_credential_or_storage_integration )? + | URL EQ azure_url = AZURE_PATH ( + az_credential_or_storage_integration? stage_encryption_opts_az + | stage_encryption_opts_az? az_credential_or_storage_integration + )? ; true_false @@ -2215,59 +2102,45 @@ notification_integration ; directory_table_internal_params - : DIRECTORY EQ LR_BRACKET - ( - enable refresh_on_create? - | REFRESH_ON_CREATE EQ FALSE - | refresh_on_create enable - ) - RR_BRACKET + : DIRECTORY EQ LR_BRACKET ( + enable refresh_on_create? + | REFRESH_ON_CREATE EQ FALSE + | refresh_on_create enable + ) RR_BRACKET ; directory_table_external_params // (for Amazon S3) - : DIRECTORY EQ LR_BRACKET enable - refresh_on_create? - auto_refresh? RR_BRACKET -// (for Google Cloud Storage) - | DIRECTORY EQ LR_BRACKET enable - auto_refresh? - refresh_on_create? - notification_integration? RR_BRACKET -// (for Microsoft Azure) - | DIRECTORY EQ LR_BRACKET enable - refresh_on_create? - auto_refresh? - notification_integration? RR_BRACKET + : DIRECTORY EQ LR_BRACKET enable refresh_on_create? auto_refresh? RR_BRACKET + // (for Google Cloud Storage) + | DIRECTORY EQ LR_BRACKET enable auto_refresh? refresh_on_create? notification_integration? RR_BRACKET + // (for Microsoft Azure) + | DIRECTORY EQ LR_BRACKET enable refresh_on_create? auto_refresh? notification_integration? RR_BRACKET ; /* =========== Stage DDL section =========== */ create_stage - : CREATE or_replace? temporary? STAGE if_not_exists? object_name_or_identifier - stage_encryption_opts_internal? - directory_table_internal_params? - ( FILE_FORMAT EQ LR_BRACKET ( FORMAT_NAME EQ string | TYPE EQ ( CSV | JSON | AVRO | ORC | PARQUET | XML ) format_type_options* ) RR_BRACKET )? - ( COPY_OPTIONS_ EQ LR_BRACKET copy_options RR_BRACKET )? - with_tags? - comment_clause? - | CREATE or_replace? temporary? STAGE if_not_exists? object_name_or_identifier - external_stage_params - directory_table_external_params? - ( FILE_FORMAT EQ LR_BRACKET ( FORMAT_NAME EQ string | TYPE EQ ( CSV | JSON | AVRO | ORC | PARQUET | XML ) format_type_options* ) RR_BRACKET )? - ( COPY_OPTIONS_ EQ LR_BRACKET copy_options RR_BRACKET )? - with_tags? - comment_clause? + : CREATE or_replace? temporary? STAGE if_not_exists? object_name_or_identifier stage_encryption_opts_internal? directory_table_internal_params? ( + FILE_FORMAT EQ LR_BRACKET ( + FORMAT_NAME EQ string + | TYPE EQ ( CSV | JSON | AVRO | ORC | PARQUET | XML) format_type_options* + ) RR_BRACKET + )? (COPY_OPTIONS_ EQ LR_BRACKET copy_options RR_BRACKET)? with_tags? comment_clause? + | CREATE or_replace? temporary? STAGE if_not_exists? object_name_or_identifier external_stage_params directory_table_external_params? ( + FILE_FORMAT EQ LR_BRACKET ( + FORMAT_NAME EQ string + | TYPE EQ ( CSV | JSON | AVRO | ORC | PARQUET | XML) format_type_options* + ) RR_BRACKET + )? (COPY_OPTIONS_ EQ LR_BRACKET copy_options RR_BRACKET)? with_tags? comment_clause? ; alter_stage : ALTER STAGE if_exists? object_name_or_identifier RENAME TO object_name_or_identifier | ALTER STAGE if_exists? object_name_or_identifier set_tags | ALTER STAGE if_exists? object_name_or_identifier unset_tags - | ALTER STAGE if_exists? object_name_or_identifier SET - external_stage_params? - file_format? - ( COPY_OPTIONS_ EQ LR_BRACKET copy_options RR_BRACKET )? - comment_clause? + | ALTER STAGE if_exists? object_name_or_identifier SET external_stage_params? file_format? ( + COPY_OPTIONS_ EQ LR_BRACKET copy_options RR_BRACKET + )? comment_clause? ; drop_stage @@ -2285,8 +2158,8 @@ show_stages /* =========== End of stage DDL section =========== */ cloud_provider_params - //(for Amazon S3) - : STORAGE_PROVIDER EQ S3 STORAGE_AWS_ROLE_ARN EQ string ( STORAGE_AWS_OBJECT_ACL EQ string )? +//(for Amazon S3) + : STORAGE_PROVIDER EQ S3 STORAGE_AWS_ROLE_ARN EQ string (STORAGE_AWS_OBJECT_ACL EQ string)? //(for Google Cloud Storage) | STORAGE_PROVIDER EQ GCS //(for Microsoft Azure) @@ -2294,8 +2167,8 @@ cloud_provider_params ; cloud_provider_params2 - //(for Amazon S3) - : STORAGE_AWS_ROLE_ARN EQ string ( STORAGE_AWS_OBJECT_ACL EQ string )? +//(for Amazon S3) + : STORAGE_AWS_ROLE_ARN EQ string (STORAGE_AWS_OBJECT_ACL EQ string)? //(for Microsoft Azure) | AZURE_TENANT_ID EQ string ; @@ -2305,13 +2178,10 @@ cloud_provider_params3 ; create_storage_integration - : CREATE or_replace? STORAGE INTEGRATION if_not_exists? id_ - TYPE EQ EXTERNAL_STAGE - cloud_provider_params - ENABLED EQ true_false - STORAGE_ALLOWED_LOCATIONS EQ LR_BRACKET string_list RR_BRACKET - ( STORAGE_BLOCKED_LOCATIONS EQ LR_BRACKET string_list RR_BRACKET )? - comment_clause? + : CREATE or_replace? STORAGE INTEGRATION if_not_exists? id_ TYPE EQ EXTERNAL_STAGE cloud_provider_params ENABLED EQ true_false + STORAGE_ALLOWED_LOCATIONS EQ LR_BRACKET string_list RR_BRACKET ( + STORAGE_BLOCKED_LOCATIONS EQ LR_BRACKET string_list RR_BRACKET + )? comment_clause? ; copy_grants @@ -2331,50 +2201,35 @@ show_initial_rows ; stream_time - : at_before1 LR_BRACKET ( TIMESTAMP ASSOC string | OFFSET ASSOC string | STATEMENT ASSOC id_ | STREAM ASSOC string ) RR_BRACKET + : at_before1 LR_BRACKET ( + TIMESTAMP ASSOC string + | OFFSET ASSOC string + | STATEMENT ASSOC id_ + | STREAM ASSOC string + ) RR_BRACKET ; create_stream - //-- table - : CREATE or_replace? STREAM if_not_exists? - object_name - copy_grants? - ON TABLE object_name - stream_time? - append_only? - show_initial_rows? +//-- table + : CREATE or_replace? STREAM if_not_exists? object_name copy_grants? ON TABLE object_name stream_time? append_only? show_initial_rows? comment_clause? //-- External table - | CREATE or_replace? STREAM if_not_exists? - object_name - copy_grants? - ON EXTERNAL TABLE object_name - stream_time? - insert_only? - comment_clause? + | CREATE or_replace? STREAM if_not_exists? object_name copy_grants? ON EXTERNAL TABLE object_name stream_time? insert_only? comment_clause? //-- Directory table - | CREATE or_replace? STREAM if_not_exists? - object_name - copy_grants? - ON STAGE object_name - comment_clause? + | CREATE or_replace? STREAM if_not_exists? object_name copy_grants? ON STAGE object_name comment_clause? //-- View - | CREATE or_replace? STREAM if_not_exists? - object_name - copy_grants? - ON VIEW object_name - stream_time? - append_only? - show_initial_rows? + | CREATE or_replace? STREAM if_not_exists? object_name copy_grants? ON VIEW object_name stream_time? append_only? show_initial_rows? comment_clause? ; temporary - : TEMP | TEMPORARY + : TEMP + | TEMPORARY ; table_type - : ( ( LOCAL | GLOBAL )? temporary | VOLATILE ) | TRANSIENT + : (( LOCAL | GLOBAL)? temporary | VOLATILE) + | TRANSIENT ; with_tags @@ -2394,7 +2249,7 @@ change_tracking ; with_masking_policy - : WITH? MASKING POLICY id_ ( USING column_list_in_parentheses )? + : WITH? MASKING POLICY id_ (USING column_list_in_parentheses)? ; collate @@ -2407,7 +2262,13 @@ order_noorder ; default_value - : DEFAULT expr | (AUTOINCREMENT | IDENTITY) ( LR_BRACKET num COMMA num RR_BRACKET | start_with | increment_by | start_with increment_by )? order_noorder? + : DEFAULT expr + | (AUTOINCREMENT | IDENTITY) ( + LR_BRACKET num COMMA num RR_BRACKET + | start_with + | increment_by + | start_with increment_by + )? order_noorder? ; foreign_key @@ -2419,25 +2280,16 @@ primary_key ; out_of_line_constraint - : (CONSTRAINT id_ )? - ( - (UNIQUE | primary_key) column_list_in_parentheses common_constraint_properties* - | foreign_key column_list_in_parentheses REFERENCES object_name column_list_in_parentheses constraint_properties - ) + : (CONSTRAINT id_)? ( + (UNIQUE | primary_key) column_list_in_parentheses common_constraint_properties* + | foreign_key column_list_in_parentheses REFERENCES object_name column_list_in_parentheses constraint_properties + ) ; - full_col_decl - : col_decl - ( - collate - | inline_constraint - | default_value - | null_not_null - )* - with_masking_policy? - with_tags? - (COMMENT string)? + : col_decl (collate | inline_constraint | default_value | null_not_null)* with_masking_policy? with_tags? ( + COMMENT string + )? ; column_decl_item @@ -2450,39 +2302,28 @@ column_decl_item_list ; create_table - : CREATE or_replace? table_type? TABLE (if_not_exists? object_name | object_name if_not_exists? ) - ((comment_clause? create_table_clause) | (create_table_clause comment_clause?)) + : CREATE or_replace? table_type? TABLE ( + if_not_exists? object_name + | object_name if_not_exists? + ) ((comment_clause? create_table_clause) | (create_table_clause comment_clause?)) ; create_table_clause - : '(' column_decl_item_list ')' - cluster_by? - stage_file_format? - ( STAGE_COPY_OPTIONS EQ LR_BRACKET copy_options RR_BRACKET )? - ( DATA_RETENTION_TIME_IN_DAYS EQ num )? - ( MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num )? - change_tracking? - default_ddl_collation? - copy_grants? - with_row_access_policy? - with_tags? + : '(' column_decl_item_list ')' cluster_by? stage_file_format? ( + STAGE_COPY_OPTIONS EQ LR_BRACKET copy_options RR_BRACKET + )? (DATA_RETENTION_TIME_IN_DAYS EQ num)? (MAX_DATA_EXTENSION_TIME_IN_DAYS EQ num)? change_tracking? default_ddl_collation? copy_grants? + with_row_access_policy? with_tags? ; create_table_as_select - : CREATE or_replace? table_type? TABLE (if_not_exists? object_name | object_name if_not_exists? ) - ('(' column_decl_item_list ')')? - cluster_by? - copy_grants? - with_row_access_policy? - with_tags? - comment_clause? - AS query_statement + : CREATE or_replace? table_type? TABLE ( + if_not_exists? object_name + | object_name if_not_exists? + ) ('(' column_decl_item_list ')')? cluster_by? copy_grants? with_row_access_policy? with_tags? comment_clause? AS query_statement ; create_table_like - : CREATE or_replace? TRANSIENT? TABLE object_name LIKE object_name - cluster_by? - copy_grants? + : CREATE or_replace? TRANSIENT? TABLE object_name LIKE object_name cluster_by? copy_grants? ; create_tag @@ -2583,14 +2424,9 @@ session_params_list ; create_task - : CREATE or_replace? TASK if_not_exists? object_name - task_parameters* - comment_clause? - copy_grants? - ( AFTER object_name (COMMA object_name)* )? - ( WHEN search_condition )? - AS - sql + : CREATE or_replace? TASK if_not_exists? object_name task_parameters* comment_clause? copy_grants? ( + AFTER object_name (COMMA object_name)* + )? (WHEN search_condition)? AS sql ; task_parameters @@ -2605,7 +2441,10 @@ task_parameters task_compute : WAREHOUSE EQ id_ - | USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE EQ ( wh_common_size | string ) //Snowflake allow quoted warehouse size but must be without quote. + | USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE EQ ( + wh_common_size + | string + ) //Snowflake allow quoted warehouse size but must be without quote. ; task_schedule @@ -2646,20 +2485,13 @@ view_col ; create_view - : CREATE or_replace? SECURE? RECURSIVE? VIEW if_not_exists? object_name - ( LR_BRACKET column_list_with_comment RR_BRACKET )? - view_col* - with_row_access_policy? - with_tags? - copy_grants? - comment_clause? - AS query_statement + : CREATE or_replace? SECURE? RECURSIVE? VIEW if_not_exists? object_name ( + LR_BRACKET column_list_with_comment RR_BRACKET + )? view_col* with_row_access_policy? with_tags? copy_grants? comment_clause? AS query_statement ; create_warehouse - : CREATE or_replace? WAREHOUSE if_not_exists? id_fn - ( WITH? wh_properties+ )? - wh_params* + : CREATE or_replace? WAREHOUSE if_not_exists? id_fn (WITH? wh_properties+)? wh_params* ; wh_common_size @@ -2670,6 +2502,7 @@ wh_common_size | XLARGE | XXLARGE ; + wh_extra_size : XXXLARGE | X4LARGE @@ -2678,7 +2511,7 @@ wh_extra_size ; wh_properties - : WAREHOUSE_SIZE EQ ( wh_common_size | wh_extra_size | ID2) + : WAREHOUSE_SIZE EQ (wh_common_size | wh_extra_size | ID2) | WAREHOUSE_TYPE EQ (STANDARD | SNOWPARK_OPTIMIZED) | MAX_CLUSTER_COUNT EQ num | MIN_CLUSTER_COUNT EQ num @@ -2696,12 +2529,11 @@ wh_properties wh_params : MAX_CONCURRENCY_LEVEL EQ num | STATEMENT_QUEUED_TIMEOUT_IN_SECONDS EQ num - | STATEMENT_TIMEOUT_IN_SECONDS EQ num - with_tags? + | STATEMENT_TIMEOUT_IN_SECONDS EQ num with_tags? ; trigger_definition - : ON num PERCENT DO ( SUSPEND | SUSPEND_IMMEDIATE | NOTIFY ) + : ON num PERCENT DO (SUSPEND | SUSPEND_IMMEDIATE | NOTIFY) ; object_type_name @@ -2816,7 +2648,7 @@ drop_function ; drop_integration - : DROP ( API | NOTIFICATION | SECURITY | STORAGE )? INTEGRATION if_exists? id_ + : DROP (API | NOTIFICATION | SECURITY | STORAGE)? INTEGRATION if_exists? id_ ; drop_managed_account @@ -2904,7 +2736,8 @@ drop_warehouse ; cascade_restrict - : CASCADE | RESTRICT + : CASCADE + | RESTRICT ; arg_types @@ -2913,7 +2746,7 @@ arg_types // undrop commands undrop_command - //: undrop_object +//: undrop_object : undrop_database | undrop_schema | undrop_table @@ -2958,7 +2791,7 @@ use_schema ; use_secondary_roles - : USE SECONDARY ROLES ( ALL | NONE ) + : USE SECONDARY ROLES (ALL | NONE) ; use_warehouse @@ -3040,7 +2873,7 @@ describe_event_table ; describe_external_table - : describe EXTERNAL? TABLE object_name ( TYPE EQ (COLUMNS | STAGE) )? + : describe EXTERNAL? TABLE object_name (TYPE EQ (COLUMNS | STAGE))? ; describe_file_format @@ -3052,7 +2885,7 @@ describe_function ; describe_integration - : describe ( API | NOTIFICATION | SECURITY | STORAGE )? INTEGRATION id_ + : describe (API | NOTIFICATION | SECURITY | STORAGE)? INTEGRATION id_ ; describe_masking_policy @@ -3076,7 +2909,7 @@ describe_procedure ; describe_result - : describe RESULT ( STRING | LAST_QUERY_ID LR_BRACKET RR_BRACKET ) + : describe RESULT (STRING | LAST_QUERY_ID LR_BRACKET RR_BRACKET) ; describe_row_access_policy @@ -3108,7 +2941,7 @@ describe_stream ; describe_table - : describe TABLE object_name ( TYPE EQ (COLUMNS | STAGE ) )? + : describe TABLE object_name (TYPE EQ (COLUMNS | STAGE))? ; describe_task @@ -3189,18 +3022,27 @@ show_command ; show_alerts - : SHOW TERSE? ALERTS like_pattern? - ( IN ( ACCOUNT | DATABASE id_? | SCHEMA schema_name? ) )? - starts_with? - limit_rows? + : SHOW TERSE? ALERTS like_pattern? (IN ( ACCOUNT | DATABASE id_? | SCHEMA schema_name?))? starts_with? limit_rows? ; show_channels - : SHOW CHANNELS like_pattern? ( IN ( ACCOUNT | DATABASE id_? | SCHEMA schema_name? | TABLE | TABLE? object_name) )? + : SHOW CHANNELS like_pattern? ( + IN (ACCOUNT | DATABASE id_? | SCHEMA schema_name? | TABLE | TABLE? object_name) + )? ; show_columns - : SHOW COLUMNS like_pattern? ( IN ( ACCOUNT | DATABASE id_? | SCHEMA schema_name? | TABLE | TABLE? object_name | VIEW | VIEW? object_name ) )? + : SHOW COLUMNS like_pattern? ( + IN ( + ACCOUNT + | DATABASE id_? + | SCHEMA schema_name? + | TABLE + | TABLE? object_name + | VIEW + | VIEW? object_name + ) + )? ; show_connections @@ -3212,13 +3054,11 @@ starts_with ; limit_rows - : LIMIT num ( FROM string )? + : LIMIT num (FROM string)? ; show_databases - : SHOW TERSE? DATABASES HISTORY? like_pattern? - starts_with? - limit_rows? + : SHOW TERSE? DATABASES HISTORY? like_pattern? starts_with? limit_rows? ; show_databases_in_failover_group @@ -3236,17 +3076,11 @@ show_delegated_authorizations ; show_dynamic_tables - : SHOW DYNAMIC TABLES like_pattern? - (IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name?))? - starts_with? - limit_rows? + : SHOW DYNAMIC TABLES like_pattern? (IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name?))? starts_with? limit_rows? ; show_event_tables - : SHOW TERSE? EVENT TABLES like_pattern? - ( IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name? ) )? - starts_with? - limit_rows? + : SHOW TERSE? EVENT TABLES like_pattern? (IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name?))? starts_with? limit_rows? ; show_external_functions @@ -3254,32 +3088,25 @@ show_external_functions ; show_external_tables - : SHOW TERSE? EXTERNAL TABLES like_pattern? - ( IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name? ) )? - starts_with? - limit_rows? + : SHOW TERSE? EXTERNAL TABLES like_pattern? ( + IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name?) + )? starts_with? limit_rows? ; show_failover_groups - : SHOW FAILOVER GROUPS ( IN ACCOUNT id_ )? + : SHOW FAILOVER GROUPS (IN ACCOUNT id_)? ; show_file_formats - : SHOW FILE FORMATS like_pattern? - ( IN - ( - ACCOUNT | - DATABASE | - DATABASE id_ | - SCHEMA | - SCHEMA schema_name | - schema_name - ) - )? + : SHOW FILE FORMATS like_pattern? ( + IN (ACCOUNT | DATABASE | DATABASE id_ | SCHEMA | SCHEMA schema_name | schema_name) + )? ; show_functions - : SHOW FUNCTIONS like_pattern? ( IN ( ACCOUNT | DATABASE | DATABASE id_ | SCHEMA | SCHEMA id_ | id_ ) )? + : SHOW FUNCTIONS like_pattern? ( + IN ( ACCOUNT | DATABASE | DATABASE id_ | SCHEMA | SCHEMA id_ | id_) + )? ; show_global_accounts @@ -3295,17 +3122,17 @@ show_grants show_grants_opts : ON ACCOUNT | ON object_type object_name - | TO (ROLE id_ | USER id_ | SHARE id_ ) + | TO (ROLE id_ | USER id_ | SHARE id_) | OF ROLE id_ | OF SHARE id_ ; show_integrations - : SHOW ( API | NOTIFICATION | SECURITY | STORAGE )? INTEGRATIONS like_pattern? + : SHOW (API | NOTIFICATION | SECURITY | STORAGE)? INTEGRATIONS like_pattern? ; show_locks - : SHOW LOCKS ( IN ACCOUNT )? + : SHOW LOCKS (IN ACCOUNT)? ; show_managed_accounts @@ -3313,26 +3140,15 @@ show_managed_accounts ; show_masking_policies - : SHOW MASKING POLICIES like_pattern? in_obj? + : SHOW MASKING POLICIES like_pattern? in_obj? ; in_obj - : IN ( ACCOUNT - | DATABASE - | DATABASE id_ - | SCHEMA - | SCHEMA schema_name - | schema_name - ) + : IN (ACCOUNT | DATABASE | DATABASE id_ | SCHEMA | SCHEMA schema_name | schema_name) ; in_obj_2 - : IN ( ACCOUNT - | DATABASE id_? - | SCHEMA schema_name? - | TABLE - | TABLE object_name - ) + : IN (ACCOUNT | DATABASE id_? | SCHEMA schema_name? | TABLE | TABLE object_name) ; show_materialized_views @@ -3352,12 +3168,20 @@ show_organization_accounts ; in_for - : IN | FOR + : IN + | FOR ; show_parameters - : SHOW PARAMETERS like_pattern? - ( in_for ( SESSION | ACCOUNT | USER id_? | ( WAREHOUSE | DATABASE | SCHEMA | TASK ) id_? | TABLE object_name ) )? + : SHOW PARAMETERS like_pattern? ( + in_for ( + SESSION + | ACCOUNT + | USER id_? + | ( WAREHOUSE | DATABASE | SCHEMA | TASK) id_? + | TABLE object_name + ) + )? ; show_pipes @@ -3381,11 +3205,11 @@ show_replication_accounts ; show_replication_databases - : SHOW REPLICATION DATABASES like_pattern? ( WITH PRIMARY account_identifier DOT id_ )? + : SHOW REPLICATION DATABASES like_pattern? (WITH PRIMARY account_identifier DOT id_)? ; show_replication_groups - : SHOW REPLICATION GROUPS (IN ACCOUNT id_ )? + : SHOW REPLICATION GROUPS (IN ACCOUNT id_)? ; show_resource_monitors @@ -3401,10 +3225,7 @@ show_row_access_policies ; show_schemas - : SHOW TERSE? SCHEMAS HISTORY? like_pattern? - ( IN ( ACCOUNT | DATABASE id_? ) )? - starts_with? - limit_rows? + : SHOW TERSE? SCHEMAS HISTORY? like_pattern? (IN ( ACCOUNT | DATABASE id_?))? starts_with? limit_rows? ; show_sequences @@ -3436,17 +3257,22 @@ show_tables ; show_tags - : SHOW TAGS like_pattern? ( IN ACCOUNT | DATABASE | DATABASE id_ | SCHEMA | SCHEMA schema_name | schema_name )? + : SHOW TAGS like_pattern? ( + IN ACCOUNT + | DATABASE + | DATABASE id_ + | SCHEMA + | SCHEMA schema_name + | schema_name + )? ; show_tasks - : SHOW TERSE? TASKS like_pattern? ( IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name? ) )? - starts_with? - limit_rows? + : SHOW TERSE? TASKS like_pattern? (IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name?))? starts_with? limit_rows? ; show_transactions - : SHOW TRANSACTIONS ( IN ACCOUNT )? + : SHOW TRANSACTIONS (IN ACCOUNT)? ; show_user_functions @@ -3454,10 +3280,7 @@ show_user_functions ; show_users - : SHOW TERSE? USERS like_pattern? - ( STARTS WITH string )? - ( LIMIT num )? - ( FROM string )? + : SHOW TERSE? USERS like_pattern? (STARTS WITH string)? (LIMIT num)? (FROM string)? ; show_variables @@ -3465,10 +3288,7 @@ show_variables ; show_views - : SHOW TERSE? VIEWS like_pattern? - ( IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name? ) )? - starts_with? - limit_rows? + : SHOW TERSE? VIEWS like_pattern? (IN ( ACCOUNT | DATABASE id_? | SCHEMA? schema_name?))? starts_with? limit_rows? ; show_warehouses @@ -3621,8 +3441,8 @@ non_reserved_words ; builtin_function - // If there is a lexer entry for a function we also need to add the token here - // as it otherwise will not be picked up by the id_ rule +// If there is a lexer entry for a function we also need to add the token here +// as it otherwise will not be picked up by the id_ rule : IFF | SUM | AVG @@ -3640,7 +3460,7 @@ builtin_function ; list_operator - // lexer entry which admit a list of comma separated expr +// lexer entry which admit a list of comma separated expr : CONCAT | CONCAT_WS | COALESCE @@ -3648,12 +3468,12 @@ list_operator ; binary_builtin_function - : ifnull=( IFNULL | NVL ) + : ifnull = (IFNULL | NVL) | GET | LEFT | RIGHT | DATE_PART - | to_date=( TO_DATE | DATE ) + | to_date = ( TO_DATE | DATE) | SPLIT | NULLIF | EQUAL_NULL @@ -3664,13 +3484,14 @@ binary_builtin_function binary_or_ternary_builtin_function : CHARINDEX | REPLACE - | substring=( SUBSTRING | SUBSTR ) - | LIKE | ILIKE + | substring = ( SUBSTRING | SUBSTR) + | LIKE + | ILIKE ; ternary_builtin_function - : dateadd=( DATEADD | TIMEADD | TIMESTAMPADD ) - | datefiff=( DATEDIFF | TIMEDIFF | TIMESTAMPDIFF ) + : dateadd = (DATEADD | TIMEADD | TIMESTAMPADD) + | datefiff = ( DATEDIFF | TIMEDIFF | TIMESTAMPDIFF) | SPLIT_PART | NVL2 ; @@ -3696,9 +3517,9 @@ column_list_with_comment ; object_name - : d=id_ DOT s=id_ DOT o=id_ - | s=id_ DOT o=id_ - | o=id_ + : d = id_ DOT s = id_ DOT o = id_ + | s = id_ DOT o = id_ + | o = id_ ; object_name_or_identifier @@ -3724,21 +3545,21 @@ expr | primitive_expression | function_call | expr LSB expr RSB //array access - | expr COLON expr //json access + | expr COLON expr //json access | expr DOT (VALUE | expr) | expr COLLATE string | case_expression | iff_expr | bracket_expression - | op=( PLUS | MINUS ) expr - | expr op=(STAR | DIVIDE | MODULE) expr - | expr op=(PLUS | MINUS | PIPE_PIPE) expr + | op = ( PLUS | MINUS) expr + | expr op = (STAR | DIVIDE | MODULE) expr + | expr op = (PLUS | MINUS | PIPE_PIPE) expr | expr comparison_operator expr - | op=NOT+ expr + | op = NOT+ expr | expr AND expr //bool operation - | expr OR expr //bool operation + | expr OR expr //bool operation | arr_literal -// | expr time_zone + // | expr time_zone | expr COLON_COLON data_type //cast | expr over_clause | cast_expr @@ -3751,9 +3572,9 @@ expr | trim_expression | expr IS null_not_null | expr NOT? IN LR_BRACKET (subquery | expr_list) RR_BRACKET - | expr NOT? ( LIKE | ILIKE ) expr (ESCAPE expr)? + | expr NOT? ( LIKE | ILIKE) expr (ESCAPE expr)? | expr NOT? RLIKE expr - | expr NOT? ( LIKE | ILIKE ) ANY LR_BRACKET expr (COMMA expr)* RR_BRACKET (ESCAPE expr)? + | expr NOT? (LIKE | ILIKE) ANY LR_BRACKET expr (COMMA expr)* RR_BRACKET (ESCAPE expr)? ; iff_expr @@ -3761,7 +3582,7 @@ iff_expr ; trim_expression - : ( TRIM | LTRIM | RTRIM ) LR_BRACKET expr (COMMA string)* RR_BRACKET + : (TRIM | LTRIM | RTRIM) LR_BRACKET expr (COMMA string)* RR_BRACKET ; try_cast_expr @@ -3778,7 +3599,7 @@ json_literal ; kv_pair - : key=STRING COLON value + : key = STRING COLON value ; value @@ -3795,9 +3616,9 @@ data_type_size ; data_type - : int_alias = ( INT | INTEGER | SMALLINT | TINYINT | BYTEINT | BIGINT ) - | number_alias = ( NUMBER | NUMERIC | DECIMAL_ ) ( LR_BRACKET num (COMMA num)? RR_BRACKET )? - | float_alias = ( FLOAT_ | FLOAT4 | FLOAT8 | DOUBLE | DOUBLE_PRECISION | REAL_ ) + : int_alias = (INT | INTEGER | SMALLINT | TINYINT | BYTEINT | BIGINT) + | number_alias = (NUMBER | NUMERIC | DECIMAL_) (LR_BRACKET num (COMMA num)? RR_BRACKET)? + | float_alias = (FLOAT_ | FLOAT4 | FLOAT8 | DOUBLE | DOUBLE_PRECISION | REAL_) | BOOLEAN | DATE | DATETIME data_type_size? @@ -3806,9 +3627,17 @@ data_type | TIMESTAMP_LTZ data_type_size? | TIMESTAMP_NTZ data_type_size? | TIMESTAMP_TZ data_type_size? - | char_alias = ( CHAR | NCHAR | CHARACTER ) data_type_size? - | varchar_alias = ( CHAR_VARYING | NCHAR_VARYING | NVARCHAR2 | NVARCHAR | STRING_ | TEXT | VARCHAR ) data_type_size? - | binary_alias = ( BINARY | VARBINARY ) data_type_size? + | char_alias = ( CHAR | NCHAR | CHARACTER) data_type_size? + | varchar_alias = ( + CHAR_VARYING + | NCHAR_VARYING + | NVARCHAR2 + | NVARCHAR + | STRING_ + | TEXT + | VARCHAR + ) data_type_size? + | binary_alias = ( BINARY | VARBINARY) data_type_size? | VARIANT | OBJECT | ARRAY @@ -3839,7 +3668,8 @@ order_by_expr // ; asc_desc - : ASC | DESC + : ASC + | DESC ; over_clause @@ -3850,29 +3680,31 @@ over_clause function_call : ranking_windowed_function | aggregate_function -// | aggregate_windowed_function + // | aggregate_windowed_function | object_name '(' expr_list? ')' | list_operator LR_BRACKET expr_list RR_BRACKET - | to_date=( TO_DATE | DATE ) LR_BRACKET expr RR_BRACKET - | length= ( LENGTH | LEN ) LR_BRACKET expr RR_BRACKET + | to_date = ( TO_DATE | DATE) LR_BRACKET expr RR_BRACKET + | length = ( LENGTH | LEN) LR_BRACKET expr RR_BRACKET | TO_BOOLEAN LR_BRACKET expr RR_BRACKET ; ignore_or_repect_nulls - : ( IGNORE | RESPECT ) NULLS + : (IGNORE | RESPECT) NULLS ; ranking_windowed_function : (RANK | DENSE_RANK | ROW_NUMBER) '(' ')' over_clause | NTILE '(' expr ')' over_clause - | ( LEAD | LAG ) LR_BRACKET expr ( COMMA expr COMMA expr)? RR_BRACKET ignore_or_repect_nulls? over_clause - | ( FIRST_VALUE | LAST_VALUE ) LR_BRACKET expr RR_BRACKET ignore_or_repect_nulls? over_clause + | (LEAD | LAG) LR_BRACKET expr (COMMA expr COMMA expr)? RR_BRACKET ignore_or_repect_nulls? over_clause + | (FIRST_VALUE | LAST_VALUE) LR_BRACKET expr RR_BRACKET ignore_or_repect_nulls? over_clause ; aggregate_function : id_ '(' DISTINCT? expr_list ')' | id_ '(' STAR ')' - | (LISTAGG | ARRAY_AGG) '(' DISTINCT? expr (COMMA string)? ')' (WITHIN GROUP '(' order_by_clause ')' )? + | (LISTAGG | ARRAY_AGG) '(' DISTINCT? expr (COMMA string)? ')' ( + WITHIN GROUP '(' order_by_clause ')' + )? ; //rows_range @@ -3909,10 +3741,10 @@ sign ; full_column_name - : db_name=id_? DOT schema=id_? DOT tab_name=id_? DOT col_name=id_ - | schema=id_? DOT tab_name=id_? DOT col_name=id_ - | tab_name=id_? DOT col_name=id_ - | col_name=id_ + : db_name = id_? DOT schema = id_? DOT tab_name = id_? DOT col_name = id_ + | schema = id_? DOT tab_name = id_? DOT col_name = id_ + | tab_name = id_? DOT col_name = id_ + | col_name = id_ ; bracket_expression @@ -3935,8 +3767,7 @@ switch_section // select query_statement - : with_expression? - select_statement set_operators* + : with_expression? select_statement set_operators* ; with_expression @@ -3944,7 +3775,7 @@ with_expression ; common_table_expression - : id_ ('(' columns=column_list ')')? AS '(' select_statement set_operators* ')' + : id_ ('(' columns = column_list ')')? AS '(' select_statement set_operators* ')' ; select_statement @@ -3958,12 +3789,7 @@ set_operators ; select_optional_clauses - : into_clause? - from_clause? - where_clause? - group_by_clause? - qualify_clause? - order_by_clause? + : into_clause? from_clause? where_clause? group_by_clause? qualify_clause? order_by_clause? ; select_clause @@ -3988,7 +3814,7 @@ select_list select_list_elem : column_elem -// | udt_elem + // | udt_elem | expression_elem ; @@ -4003,7 +3829,7 @@ as_alias ; expression_elem - : ( expr | predicate ) as_alias? + : (expr | predicate) as_alias? ; column_position @@ -4011,7 +3837,8 @@ column_position ; all_distinct - : ALL | DISTINCT + : ALL + | DISTINCT ; top_clause @@ -4023,7 +3850,8 @@ into_clause ; var_list - : var (COMMA var); + : var (COMMA var) + ; var : COLON id_ @@ -4048,27 +3876,12 @@ table_source_item_joined ; object_ref - : object_name - at_before? - changes? - match_recognize? - pivot_unpivot? - as_alias? - sample? - | object_name - START WITH predicate - CONNECT BY prior_list? - | TABLE '(' function_call ')' - pivot_unpivot? - as_alias? - sample? - | values_table - sample? - | LATERAL? '(' subquery ')' - pivot_unpivot? - as_alias? - | LATERAL ( flatten_table | splited_table ) - as_alias? + : object_name at_before? changes? match_recognize? pivot_unpivot? as_alias? sample? + | object_name START WITH predicate CONNECT BY prior_list? + | TABLE '(' function_call ')' pivot_unpivot? as_alias? sample? + | values_table sample? + | LATERAL? '(' subquery ')' pivot_unpivot? as_alias? + | LATERAL (flatten_table | splited_table) as_alias? //| AT id_ PATH? // ('(' FILE_FORMAT ASSOC id_ COMMA pattern_assoc ')')? // as_alias? @@ -4082,7 +3895,7 @@ flatten_table_option ; flatten_table - : FLATTEN LR_BRACKET ( INPUT ASSOC )? expr ( COMMA flatten_table_option )* RR_BRACKET + : FLATTEN LR_BRACKET (INPUT ASSOC)? expr (COMMA flatten_table_option)* RR_BRACKET ; splited_table @@ -4107,34 +3920,30 @@ join_type ; join_clause - : join_type? JOIN object_ref ( (ON search_condition)? | (USING '(' column_list ')')? ) + : join_type? JOIN object_ref ((ON search_condition)? | (USING '(' column_list ')')?) //| join_type? JOIN object_ref (USING '(' column_list ')')? | NATURAL outer_join? JOIN object_ref | CROSS JOIN object_ref ; at_before - : AT_KEYWORD - LR_BRACKET ( + : AT_KEYWORD LR_BRACKET ( TIMESTAMP ASSOC expr | OFFSET ASSOC expr | STATEMENT ASSOC string | STREAM ASSOC string - ) RR_BRACKET + ) RR_BRACKET | BEFORE LR_BRACKET STATEMENT ASSOC string RR_BRACKET ; end - : END '(' - TIMESTAMP ARROW string - | OFFSET ARROW string - | STATEMENT ARROW id_ - ')' + : END '(' TIMESTAMP ARROW string + | OFFSET ARROW string + | STATEMENT ARROW id_ ')' ; changes - : CHANGES '(' INFORMATION ASSOC default_append_only ')' - at_before end? + : CHANGES '(' INFORMATION ASSOC default_append_only ')' at_before end? ; default_append_only @@ -4159,7 +3968,9 @@ measures ; match_opts - : SHOW EMPTY_ MATCHES | OMIT EMPTY_ MATCHES | WITH UNMATCHED ROWS + : SHOW EMPTY_ MATCHES + | OMIT EMPTY_ MATCHES + | WITH UNMATCHED ROWS ; row_match @@ -4167,7 +3978,8 @@ row_match ; first_last - : FIRST |LAST + : FIRST + | LAST ; symbol @@ -4187,19 +3999,13 @@ define ; match_recognize - : MATCH_RECOGNIZE LR_BRACKET - partition_by? - order_by_clause? - measures? - row_match? - after_match? - pattern? - define? - RR_BRACKET + : MATCH_RECOGNIZE LR_BRACKET partition_by? order_by_clause? measures? row_match? after_match? pattern? define? RR_BRACKET ; pivot_unpivot - : PIVOT LR_BRACKET id_ LR_BRACKET id_ RR_BRACKET FOR id_ IN LR_BRACKET literal (COMMA literal)* RR_BRACKET RR_BRACKET ( as_alias column_alias_list_in_brackets? )? + : PIVOT LR_BRACKET id_ LR_BRACKET id_ RR_BRACKET FOR id_ IN LR_BRACKET literal (COMMA literal)* RR_BRACKET RR_BRACKET ( + as_alias column_alias_list_in_brackets? + )? | UNPIVOT LR_BRACKET id_ FOR column_name IN LR_BRACKET column_list RR_BRACKET RR_BRACKET ; @@ -4221,8 +4027,8 @@ values_table_body ; sample_method - : row_sampling = ( BERNOULLI | ROW ) - | block_sampling = ( SYSTEM | BLOCK ) + : row_sampling = (BERNOULLI | ROW) + | block_sampling = ( SYSTEM | BLOCK) ; repeatable_seed @@ -4244,7 +4050,13 @@ search_condition ; comparison_operator - : EQ | GT | LT | LE | GE | LTGT | NE + : EQ + | GT + | LT + | LE + | GE + | LTGT + | NE ; null_not_null @@ -4260,9 +4072,9 @@ predicate | expr comparison_operator (ALL | SOME | ANY) '(' subquery ')' | expr NOT? BETWEEN expr AND expr | expr NOT? IN '(' (subquery | expr_list) ')' - | expr NOT? ( LIKE | ILIKE ) expr (ESCAPE expr)? + | expr NOT? ( LIKE | ILIKE) expr (ESCAPE expr)? | expr NOT? RLIKE expr - | expr NOT? ( LIKE | ILIKE ) ANY LR_BRACKET expr (COMMA expr)* RR_BRACKET (ESCAPE expr)? + | expr NOT? (LIKE | ILIKE) ANY LR_BRACKET expr (COMMA expr)* RR_BRACKET (ESCAPE expr)? | expr IS null_not_null | expr ; @@ -4272,7 +4084,9 @@ where_clause ; group_item - : id_ | num | expr + : id_ + | num + | expr ; group_by_clause @@ -4290,7 +4104,7 @@ qualify_clause ; order_item - : ( id_ | num | expr ) (ASC | DESC)? ( NULLS ( FIRST | LAST ) )? + : (id_ | num | expr) (ASC | DESC)? (NULLS ( FIRST | LAST))? ; order_by_clause @@ -4298,14 +4112,16 @@ order_by_clause ; row_rows - : ROW | ROWS + : ROW + | ROWS ; first_next - : FIRST | NEXT + : FIRST + | NEXT ; limit_clause : LIMIT num (OFFSET num)? - | (OFFSET num )? row_rows? FETCH first_next? num row_rows? ONLY? - ; + | (OFFSET num)? row_rows? FETCH first_next? num row_rows? ONLY? + ; \ No newline at end of file diff --git a/sql/sqlite/SQLiteLexer.g4 b/sql/sqlite/SQLiteLexer.g4 index f247c32242..5cbbbada3a 100644 --- a/sql/sqlite/SQLiteLexer.g4 +++ b/sql/sqlite/SQLiteLexer.g4 @@ -27,194 +27,196 @@ lexer grammar SQLiteLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} -SCOL: ';'; -DOT: '.'; -OPEN_PAR: '('; -CLOSE_PAR: ')'; -COMMA: ','; -ASSIGN: '='; -STAR: '*'; -PLUS: '+'; -MINUS: '-'; -TILDE: '~'; -PIPE2: '||'; -DIV: '/'; -MOD: '%'; -LT2: '<<'; -GT2: '>>'; -AMP: '&'; -PIPE: '|'; -LT: '<'; -LT_EQ: '<='; -GT: '>'; -GT_EQ: '>='; -EQ: '=='; -NOT_EQ1: '!='; -NOT_EQ2: '<>'; +SCOL : ';'; +DOT : '.'; +OPEN_PAR : '('; +CLOSE_PAR : ')'; +COMMA : ','; +ASSIGN : '='; +STAR : '*'; +PLUS : '+'; +MINUS : '-'; +TILDE : '~'; +PIPE2 : '||'; +DIV : '/'; +MOD : '%'; +LT2 : '<<'; +GT2 : '>>'; +AMP : '&'; +PIPE : '|'; +LT : '<'; +LT_EQ : '<='; +GT : '>'; +GT_EQ : '>='; +EQ : '=='; +NOT_EQ1 : '!='; +NOT_EQ2 : '<>'; // http://www.sqlite.org/lang_keywords.html -ABORT_: 'ABORT'; -ACTION_: 'ACTION'; -ADD_: 'ADD'; -AFTER_: 'AFTER'; -ALL_: 'ALL'; -ALTER_: 'ALTER'; -ANALYZE_: 'ANALYZE'; -AND_: 'AND'; -AS_: 'AS'; -ASC_: 'ASC'; -ATTACH_: 'ATTACH'; -AUTOINCREMENT_: 'AUTOINCREMENT'; -BEFORE_: 'BEFORE'; -BEGIN_: 'BEGIN'; -BETWEEN_: 'BETWEEN'; -BY_: 'BY'; -CASCADE_: 'CASCADE'; -CASE_: 'CASE'; -CAST_: 'CAST'; -CHECK_: 'CHECK'; -COLLATE_: 'COLLATE'; -COLUMN_: 'COLUMN'; -COMMIT_: 'COMMIT'; -CONFLICT_: 'CONFLICT'; -CONSTRAINT_: 'CONSTRAINT'; -CREATE_: 'CREATE'; -CROSS_: 'CROSS'; -CURRENT_DATE_: 'CURRENT_DATE'; -CURRENT_TIME_: 'CURRENT_TIME'; -CURRENT_TIMESTAMP_: 'CURRENT_TIMESTAMP'; -DATABASE_: 'DATABASE'; -DEFAULT_: 'DEFAULT'; -DEFERRABLE_: 'DEFERRABLE'; -DEFERRED_: 'DEFERRED'; -DELETE_: 'DELETE'; -DESC_: 'DESC'; -DETACH_: 'DETACH'; -DISTINCT_: 'DISTINCT'; -DROP_: 'DROP'; -EACH_: 'EACH'; -ELSE_: 'ELSE'; -END_: 'END'; -ESCAPE_: 'ESCAPE'; -EXCEPT_: 'EXCEPT'; -EXCLUSIVE_: 'EXCLUSIVE'; -EXISTS_: 'EXISTS'; -EXPLAIN_: 'EXPLAIN'; -FAIL_: 'FAIL'; -FOR_: 'FOR'; -FOREIGN_: 'FOREIGN'; -FROM_: 'FROM'; -FULL_: 'FULL'; -GLOB_: 'GLOB'; -GROUP_: 'GROUP'; -HAVING_: 'HAVING'; -IF_: 'IF'; -IGNORE_: 'IGNORE'; -IMMEDIATE_: 'IMMEDIATE'; -IN_: 'IN'; -INDEX_: 'INDEX'; -INDEXED_: 'INDEXED'; -INITIALLY_: 'INITIALLY'; -INNER_: 'INNER'; -INSERT_: 'INSERT'; -INSTEAD_: 'INSTEAD'; -INTERSECT_: 'INTERSECT'; -INTO_: 'INTO'; -IS_: 'IS'; -ISNULL_: 'ISNULL'; -JOIN_: 'JOIN'; -KEY_: 'KEY'; -LEFT_: 'LEFT'; -LIKE_: 'LIKE'; -LIMIT_: 'LIMIT'; -MATCH_: 'MATCH'; -NATURAL_: 'NATURAL'; -NO_: 'NO'; -NOT_: 'NOT'; -NOTNULL_: 'NOTNULL'; -NULL_: 'NULL'; -OF_: 'OF'; -OFFSET_: 'OFFSET'; -ON_: 'ON'; -OR_: 'OR'; -ORDER_: 'ORDER'; -OUTER_: 'OUTER'; -PLAN_: 'PLAN'; -PRAGMA_: 'PRAGMA'; -PRIMARY_: 'PRIMARY'; -QUERY_: 'QUERY'; -RAISE_: 'RAISE'; -RECURSIVE_: 'RECURSIVE'; -REFERENCES_: 'REFERENCES'; -REGEXP_: 'REGEXP'; -REINDEX_: 'REINDEX'; -RELEASE_: 'RELEASE'; -RENAME_: 'RENAME'; -REPLACE_: 'REPLACE'; -RESTRICT_: 'RESTRICT'; -RETURNING_: 'RETURNING'; -RIGHT_: 'RIGHT'; -ROLLBACK_: 'ROLLBACK'; -ROW_: 'ROW'; -ROWS_: 'ROWS'; -SAVEPOINT_: 'SAVEPOINT'; -SELECT_: 'SELECT'; -SET_: 'SET'; -TABLE_: 'TABLE'; -TEMP_: 'TEMP'; -TEMPORARY_: 'TEMPORARY'; -THEN_: 'THEN'; -TO_: 'TO'; -TRANSACTION_: 'TRANSACTION'; -TRIGGER_: 'TRIGGER'; -UNION_: 'UNION'; -UNIQUE_: 'UNIQUE'; -UPDATE_: 'UPDATE'; -USING_: 'USING'; -VACUUM_: 'VACUUM'; -VALUES_: 'VALUES'; -VIEW_: 'VIEW'; -VIRTUAL_: 'VIRTUAL'; -WHEN_: 'WHEN'; -WHERE_: 'WHERE'; -WITH_: 'WITH'; -WITHOUT_: 'WITHOUT'; -FIRST_VALUE_: 'FIRST_VALUE'; -OVER_: 'OVER'; -PARTITION_: 'PARTITION'; -RANGE_: 'RANGE'; -PRECEDING_: 'PRECEDING'; -UNBOUNDED_: 'UNBOUNDED'; -CURRENT_: 'CURRENT'; -FOLLOWING_: 'FOLLOWING'; -CUME_DIST_: 'CUME_DIST'; -DENSE_RANK_: 'DENSE_RANK'; -LAG_: 'LAG'; -LAST_VALUE_: 'LAST_VALUE'; -LEAD_: 'LEAD'; -NTH_VALUE_: 'NTH_VALUE'; -NTILE_: 'NTILE'; -PERCENT_RANK_: 'PERCENT_RANK'; -RANK_: 'RANK'; -ROW_NUMBER_: 'ROW_NUMBER'; -GENERATED_: 'GENERATED'; -ALWAYS_: 'ALWAYS'; -STORED_: 'STORED'; -TRUE_: 'TRUE'; -FALSE_: 'FALSE'; -WINDOW_: 'WINDOW'; -NULLS_: 'NULLS'; -FIRST_: 'FIRST'; -LAST_: 'LAST'; -FILTER_: 'FILTER'; -GROUPS_: 'GROUPS'; -EXCLUDE_: 'EXCLUDE'; -TIES_: 'TIES'; -OTHERS_: 'OTHERS'; -DO_: 'DO'; -NOTHING_: 'NOTHING'; +ABORT_ : 'ABORT'; +ACTION_ : 'ACTION'; +ADD_ : 'ADD'; +AFTER_ : 'AFTER'; +ALL_ : 'ALL'; +ALTER_ : 'ALTER'; +ANALYZE_ : 'ANALYZE'; +AND_ : 'AND'; +AS_ : 'AS'; +ASC_ : 'ASC'; +ATTACH_ : 'ATTACH'; +AUTOINCREMENT_ : 'AUTOINCREMENT'; +BEFORE_ : 'BEFORE'; +BEGIN_ : 'BEGIN'; +BETWEEN_ : 'BETWEEN'; +BY_ : 'BY'; +CASCADE_ : 'CASCADE'; +CASE_ : 'CASE'; +CAST_ : 'CAST'; +CHECK_ : 'CHECK'; +COLLATE_ : 'COLLATE'; +COLUMN_ : 'COLUMN'; +COMMIT_ : 'COMMIT'; +CONFLICT_ : 'CONFLICT'; +CONSTRAINT_ : 'CONSTRAINT'; +CREATE_ : 'CREATE'; +CROSS_ : 'CROSS'; +CURRENT_DATE_ : 'CURRENT_DATE'; +CURRENT_TIME_ : 'CURRENT_TIME'; +CURRENT_TIMESTAMP_ : 'CURRENT_TIMESTAMP'; +DATABASE_ : 'DATABASE'; +DEFAULT_ : 'DEFAULT'; +DEFERRABLE_ : 'DEFERRABLE'; +DEFERRED_ : 'DEFERRED'; +DELETE_ : 'DELETE'; +DESC_ : 'DESC'; +DETACH_ : 'DETACH'; +DISTINCT_ : 'DISTINCT'; +DROP_ : 'DROP'; +EACH_ : 'EACH'; +ELSE_ : 'ELSE'; +END_ : 'END'; +ESCAPE_ : 'ESCAPE'; +EXCEPT_ : 'EXCEPT'; +EXCLUSIVE_ : 'EXCLUSIVE'; +EXISTS_ : 'EXISTS'; +EXPLAIN_ : 'EXPLAIN'; +FAIL_ : 'FAIL'; +FOR_ : 'FOR'; +FOREIGN_ : 'FOREIGN'; +FROM_ : 'FROM'; +FULL_ : 'FULL'; +GLOB_ : 'GLOB'; +GROUP_ : 'GROUP'; +HAVING_ : 'HAVING'; +IF_ : 'IF'; +IGNORE_ : 'IGNORE'; +IMMEDIATE_ : 'IMMEDIATE'; +IN_ : 'IN'; +INDEX_ : 'INDEX'; +INDEXED_ : 'INDEXED'; +INITIALLY_ : 'INITIALLY'; +INNER_ : 'INNER'; +INSERT_ : 'INSERT'; +INSTEAD_ : 'INSTEAD'; +INTERSECT_ : 'INTERSECT'; +INTO_ : 'INTO'; +IS_ : 'IS'; +ISNULL_ : 'ISNULL'; +JOIN_ : 'JOIN'; +KEY_ : 'KEY'; +LEFT_ : 'LEFT'; +LIKE_ : 'LIKE'; +LIMIT_ : 'LIMIT'; +MATCH_ : 'MATCH'; +NATURAL_ : 'NATURAL'; +NO_ : 'NO'; +NOT_ : 'NOT'; +NOTNULL_ : 'NOTNULL'; +NULL_ : 'NULL'; +OF_ : 'OF'; +OFFSET_ : 'OFFSET'; +ON_ : 'ON'; +OR_ : 'OR'; +ORDER_ : 'ORDER'; +OUTER_ : 'OUTER'; +PLAN_ : 'PLAN'; +PRAGMA_ : 'PRAGMA'; +PRIMARY_ : 'PRIMARY'; +QUERY_ : 'QUERY'; +RAISE_ : 'RAISE'; +RECURSIVE_ : 'RECURSIVE'; +REFERENCES_ : 'REFERENCES'; +REGEXP_ : 'REGEXP'; +REINDEX_ : 'REINDEX'; +RELEASE_ : 'RELEASE'; +RENAME_ : 'RENAME'; +REPLACE_ : 'REPLACE'; +RESTRICT_ : 'RESTRICT'; +RETURNING_ : 'RETURNING'; +RIGHT_ : 'RIGHT'; +ROLLBACK_ : 'ROLLBACK'; +ROW_ : 'ROW'; +ROWS_ : 'ROWS'; +SAVEPOINT_ : 'SAVEPOINT'; +SELECT_ : 'SELECT'; +SET_ : 'SET'; +TABLE_ : 'TABLE'; +TEMP_ : 'TEMP'; +TEMPORARY_ : 'TEMPORARY'; +THEN_ : 'THEN'; +TO_ : 'TO'; +TRANSACTION_ : 'TRANSACTION'; +TRIGGER_ : 'TRIGGER'; +UNION_ : 'UNION'; +UNIQUE_ : 'UNIQUE'; +UPDATE_ : 'UPDATE'; +USING_ : 'USING'; +VACUUM_ : 'VACUUM'; +VALUES_ : 'VALUES'; +VIEW_ : 'VIEW'; +VIRTUAL_ : 'VIRTUAL'; +WHEN_ : 'WHEN'; +WHERE_ : 'WHERE'; +WITH_ : 'WITH'; +WITHOUT_ : 'WITHOUT'; +FIRST_VALUE_ : 'FIRST_VALUE'; +OVER_ : 'OVER'; +PARTITION_ : 'PARTITION'; +RANGE_ : 'RANGE'; +PRECEDING_ : 'PRECEDING'; +UNBOUNDED_ : 'UNBOUNDED'; +CURRENT_ : 'CURRENT'; +FOLLOWING_ : 'FOLLOWING'; +CUME_DIST_ : 'CUME_DIST'; +DENSE_RANK_ : 'DENSE_RANK'; +LAG_ : 'LAG'; +LAST_VALUE_ : 'LAST_VALUE'; +LEAD_ : 'LEAD'; +NTH_VALUE_ : 'NTH_VALUE'; +NTILE_ : 'NTILE'; +PERCENT_RANK_ : 'PERCENT_RANK'; +RANK_ : 'RANK'; +ROW_NUMBER_ : 'ROW_NUMBER'; +GENERATED_ : 'GENERATED'; +ALWAYS_ : 'ALWAYS'; +STORED_ : 'STORED'; +TRUE_ : 'TRUE'; +FALSE_ : 'FALSE'; +WINDOW_ : 'WINDOW'; +NULLS_ : 'NULLS'; +FIRST_ : 'FIRST'; +LAST_ : 'LAST'; +FILTER_ : 'FILTER'; +GROUPS_ : 'GROUPS'; +EXCLUDE_ : 'EXCLUDE'; +TIES_ : 'TIES'; +OTHERS_ : 'OTHERS'; +DO_ : 'DO'; +NOTHING_ : 'NOTHING'; IDENTIFIER: '"' (~'"' | '""')* '"' @@ -239,5 +241,5 @@ SPACES: [ \u000B\t\r\n] -> channel(HIDDEN); UNEXPECTED_CHAR: .; -fragment HEX_DIGIT: [0-9A-F]; -fragment DIGIT: [0-9]; +fragment HEX_DIGIT : [0-9A-F]; +fragment DIGIT : [0-9]; \ No newline at end of file diff --git a/sql/sqlite/SQLiteParser.g4 b/sql/sqlite/SQLiteParser.g4 index dd762b5228..a7561b38c0 100644 --- a/sql/sqlite/SQLiteParser.g4 +++ b/sql/sqlite/SQLiteParser.g4 @@ -34,14 +34,16 @@ options { tokenVocab = SQLiteLexer; } -parse: (sql_stmt_list)* EOF +parse + : (sql_stmt_list)* EOF ; -sql_stmt_list: - SCOL* sql_stmt (SCOL+ sql_stmt)* SCOL* +sql_stmt_list + : SCOL* sql_stmt (SCOL+ sql_stmt)* SCOL* ; -sql_stmt: (EXPLAIN_ (QUERY_ PLAN_)?)? ( +sql_stmt + : (EXPLAIN_ (QUERY_ PLAN_)?)? ( alter_table_stmt | analyze_stmt | attach_stmt @@ -69,8 +71,8 @@ sql_stmt: (EXPLAIN_ (QUERY_ PLAN_)?)? ( ) ; -alter_table_stmt: - ALTER_ TABLE_ (schema_name DOT)? table_name ( +alter_table_stmt + : ALTER_ TABLE_ (schema_name DOT)? table_name ( RENAME_ ( TO_ new_table_name = table_name | COLUMN_? old_column_name = column_name TO_ new_column_name = column_name @@ -80,47 +82,46 @@ alter_table_stmt: ) ; -analyze_stmt: - ANALYZE_ (schema_name | (schema_name DOT)? table_or_index_name)? +analyze_stmt + : ANALYZE_ (schema_name | (schema_name DOT)? table_or_index_name)? ; -attach_stmt: - ATTACH_ DATABASE_? expr AS_ schema_name +attach_stmt + : ATTACH_ DATABASE_? expr AS_ schema_name ; -begin_stmt: - BEGIN_ (DEFERRED_ | IMMEDIATE_ | EXCLUSIVE_)? ( - TRANSACTION_ transaction_name? - )? +begin_stmt + : BEGIN_ (DEFERRED_ | IMMEDIATE_ | EXCLUSIVE_)? (TRANSACTION_ transaction_name?)? ; -commit_stmt: (COMMIT_ | END_) TRANSACTION_? +commit_stmt + : (COMMIT_ | END_) TRANSACTION_? ; -rollback_stmt: - ROLLBACK_ TRANSACTION_? (TO_ SAVEPOINT_? savepoint_name)? +rollback_stmt + : ROLLBACK_ TRANSACTION_? (TO_ SAVEPOINT_? savepoint_name)? ; -savepoint_stmt: - SAVEPOINT_ savepoint_name +savepoint_stmt + : SAVEPOINT_ savepoint_name ; -release_stmt: - RELEASE_ SAVEPOINT_? savepoint_name +release_stmt + : RELEASE_ SAVEPOINT_? savepoint_name ; -create_index_stmt: - CREATE_ UNIQUE_? INDEX_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? index_name ON_ table_name OPEN_PAR - indexed_column (COMMA indexed_column)* CLOSE_PAR (WHERE_ expr)? +create_index_stmt + : CREATE_ UNIQUE_? INDEX_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? index_name ON_ table_name OPEN_PAR indexed_column ( + COMMA indexed_column + )* CLOSE_PAR (WHERE_ expr)? ; -indexed_column: (column_name | expr) (COLLATE_ collation_name)? asc_desc? +indexed_column + : (column_name | expr) (COLLATE_ collation_name)? asc_desc? ; -create_table_stmt: - CREATE_ (TEMP_ | TEMPORARY_)? TABLE_ (IF_ NOT_ EXISTS_)? ( - schema_name DOT - )? table_name ( +create_table_stmt + : CREATE_ (TEMP_ | TEMPORARY_)? TABLE_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? table_name ( OPEN_PAR column_def (COMMA column_def)*? (COMMA table_constraint)* CLOSE_PAR ( WITHOUT_ row_ROW_ID = IDENTIFIER )? @@ -128,47 +129,43 @@ create_table_stmt: ) ; -column_def: - column_name type_name? column_constraint* +column_def + : column_name type_name? column_constraint* ; -type_name: - name+? ( +type_name + : name+? ( OPEN_PAR signed_number CLOSE_PAR | OPEN_PAR signed_number COMMA signed_number CLOSE_PAR )? ; -column_constraint: (CONSTRAINT_ name)? ( +column_constraint + : (CONSTRAINT_ name)? ( (PRIMARY_ KEY_ asc_desc? conflict_clause? AUTOINCREMENT_?) | (NOT_? NULL_ | UNIQUE_) conflict_clause? | CHECK_ OPEN_PAR expr CLOSE_PAR | DEFAULT_ (signed_number | literal_value | OPEN_PAR expr CLOSE_PAR) | COLLATE_ collation_name | foreign_key_clause - | (GENERATED_ ALWAYS_)? AS_ OPEN_PAR expr CLOSE_PAR ( - STORED_ - | VIRTUAL_ - )? + | (GENERATED_ ALWAYS_)? AS_ OPEN_PAR expr CLOSE_PAR (STORED_ | VIRTUAL_)? ) ; -signed_number: (PLUS | MINUS)? NUMERIC_LITERAL +signed_number + : (PLUS | MINUS)? NUMERIC_LITERAL ; -table_constraint: (CONSTRAINT_ name)? ( - (PRIMARY_ KEY_ | UNIQUE_) OPEN_PAR indexed_column ( - COMMA indexed_column - )* CLOSE_PAR conflict_clause? +table_constraint + : (CONSTRAINT_ name)? ( + (PRIMARY_ KEY_ | UNIQUE_) OPEN_PAR indexed_column (COMMA indexed_column)* CLOSE_PAR conflict_clause? | CHECK_ OPEN_PAR expr CLOSE_PAR | FOREIGN_ KEY_ OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR foreign_key_clause ) ; -foreign_key_clause: - REFERENCES_ foreign_table ( - OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR - )? ( +foreign_key_clause + : REFERENCES_ foreign_table (OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR)? ( ON_ (DELETE_ | UPDATE_) ( SET_ (NULL_ | DEFAULT_) | CASCADE_ @@ -179,76 +176,70 @@ foreign_key_clause: )* (NOT_? DEFERRABLE_ (INITIALLY_ (DEFERRED_ | IMMEDIATE_))?)? ; -conflict_clause: - ON_ CONFLICT_ ( - ROLLBACK_ - | ABORT_ - | FAIL_ - | IGNORE_ - | REPLACE_ - ) +conflict_clause + : ON_ CONFLICT_ (ROLLBACK_ | ABORT_ | FAIL_ | IGNORE_ | REPLACE_) ; -create_trigger_stmt: - CREATE_ (TEMP_ | TEMPORARY_)? TRIGGER_ (IF_ NOT_ EXISTS_)? ( - schema_name DOT - )? trigger_name (BEFORE_ | AFTER_ | INSTEAD_ OF_)? ( - DELETE_ - | INSERT_ - | UPDATE_ (OF_ column_name ( COMMA column_name)*)? - ) ON_ table_name (FOR_ EACH_ ROW_)? (WHEN_ expr)? BEGIN_ ( +create_trigger_stmt + : CREATE_ (TEMP_ | TEMPORARY_)? TRIGGER_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? trigger_name ( + BEFORE_ + | AFTER_ + | INSTEAD_ OF_ + )? (DELETE_ | INSERT_ | UPDATE_ (OF_ column_name ( COMMA column_name)*)?) ON_ table_name ( + FOR_ EACH_ ROW_ + )? (WHEN_ expr)? BEGIN_ ( (update_stmt | insert_stmt | delete_stmt | select_stmt) SCOL )+ END_ ; -create_view_stmt: - CREATE_ (TEMP_ | TEMPORARY_)? VIEW_ (IF_ NOT_ EXISTS_)? ( - schema_name DOT - )? view_name (OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR)? AS_ select_stmt +create_view_stmt + : CREATE_ (TEMP_ | TEMPORARY_)? VIEW_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? view_name ( + OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR + )? AS_ select_stmt ; -create_virtual_table_stmt: - CREATE_ VIRTUAL_ TABLE_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? table_name USING_ module_name ( +create_virtual_table_stmt + : CREATE_ VIRTUAL_ TABLE_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? table_name USING_ module_name ( OPEN_PAR module_argument (COMMA module_argument)* CLOSE_PAR )? ; -with_clause: - WITH_ RECURSIVE_? cte_table_name AS_ OPEN_PAR select_stmt CLOSE_PAR ( +with_clause + : WITH_ RECURSIVE_? cte_table_name AS_ OPEN_PAR select_stmt CLOSE_PAR ( COMMA cte_table_name AS_ OPEN_PAR select_stmt CLOSE_PAR )* ; -cte_table_name: - table_name (OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR)? +cte_table_name + : table_name (OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR)? ; -recursive_cte: - cte_table_name AS_ OPEN_PAR initial_select UNION_ ALL_? recursive_select CLOSE_PAR +recursive_cte + : cte_table_name AS_ OPEN_PAR initial_select UNION_ ALL_? recursive_select CLOSE_PAR ; -common_table_expression: - table_name (OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR)? AS_ OPEN_PAR select_stmt CLOSE_PAR +common_table_expression + : table_name (OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR)? AS_ OPEN_PAR select_stmt CLOSE_PAR ; -delete_stmt: - with_clause? DELETE_ FROM_ qualified_table_name (WHERE_ expr)? returning_clause? +delete_stmt + : with_clause? DELETE_ FROM_ qualified_table_name (WHERE_ expr)? returning_clause? ; -delete_stmt_limited: - with_clause? DELETE_ FROM_ qualified_table_name (WHERE_ expr)? returning_clause? ( +delete_stmt_limited + : with_clause? DELETE_ FROM_ qualified_table_name (WHERE_ expr)? returning_clause? ( order_by_stmt? limit_stmt )? ; -detach_stmt: - DETACH_ DATABASE_? schema_name +detach_stmt + : DETACH_ DATABASE_? schema_name ; -drop_stmt: - DROP_ object = (INDEX_ | TABLE_ | TRIGGER_ | VIEW_) ( - IF_ EXISTS_ - )? (schema_name DOT)? any_name +drop_stmt + : DROP_ object = (INDEX_ | TABLE_ | TRIGGER_ | VIEW_) (IF_ EXISTS_)? ( + schema_name DOT + )? any_name ; /* @@ -262,8 +253,8 @@ drop_stmt: AND OR */ -expr: - literal_value +expr + : literal_value | BIND_PARAMETER | ((schema_name DOT)? table_name DOT)? column_name | unary_operator expr @@ -291,9 +282,7 @@ expr: | OPEN_PAR expr (COMMA expr)* CLOSE_PAR | CAST_ OPEN_PAR expr AS_ type_name CLOSE_PAR | expr COLLATE_ collation_name - | expr NOT_? (LIKE_ | GLOB_ | REGEXP_ | MATCH_) expr ( - ESCAPE_ expr - )? + | expr NOT_? (LIKE_ | GLOB_ | REGEXP_ | MATCH_) expr (ESCAPE_ expr)? | expr ( ISNULL_ | NOTNULL_ | NOT_ NULL_) | expr IS_ NOT_? expr | expr NOT_? BETWEEN_ expr AND_ expr @@ -307,15 +296,12 @@ expr: | raise_function ; -raise_function: - RAISE_ OPEN_PAR ( - IGNORE_ - | (ROLLBACK_ | ABORT_ | FAIL_) COMMA error_message - ) CLOSE_PAR +raise_function + : RAISE_ OPEN_PAR (IGNORE_ | (ROLLBACK_ | ABORT_ | FAIL_) COMMA error_message) CLOSE_PAR ; -literal_value: - NUMERIC_LITERAL +literal_value + : NUMERIC_LITERAL | STRING_LITERAL | BLOB_LITERAL | NULL_ @@ -326,41 +312,30 @@ literal_value: | CURRENT_TIMESTAMP_ ; -value_row: - OPEN_PAR expr (COMMA expr)* CLOSE_PAR +value_row + : OPEN_PAR expr (COMMA expr)* CLOSE_PAR ; -values_clause: - VALUES_ value_row (COMMA value_row)* +values_clause + : VALUES_ value_row (COMMA value_row)* ; -insert_stmt: - with_clause? ( +insert_stmt + : with_clause? ( INSERT_ | REPLACE_ - | INSERT_ OR_ ( - REPLACE_ - | ROLLBACK_ - | ABORT_ - | FAIL_ - | IGNORE_ - ) + | INSERT_ OR_ ( REPLACE_ | ROLLBACK_ | ABORT_ | FAIL_ | IGNORE_) ) INTO_ (schema_name DOT)? table_name (AS_ table_alias)? ( OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR - )? ( - ( - ( values_clause | select_stmt ) upsert_clause? - ) - | DEFAULT_ VALUES_ - ) returning_clause? + )? (( ( values_clause | select_stmt) upsert_clause?) | DEFAULT_ VALUES_) returning_clause? ; -returning_clause: - RETURNING_ result_column (COMMA result_column)* +returning_clause + : RETURNING_ result_column (COMMA result_column)* ; -upsert_clause: - ON_ CONFLICT_ ( +upsert_clause + : ON_ CONFLICT_ ( OPEN_PAR indexed_column (COMMA indexed_column)* CLOSE_PAR (WHERE_ expr)? )? DO_ ( NOTHING_ @@ -372,62 +347,60 @@ upsert_clause: ) ; -pragma_stmt: - PRAGMA_ (schema_name DOT)? pragma_name ( +pragma_stmt + : PRAGMA_ (schema_name DOT)? pragma_name ( ASSIGN pragma_value | OPEN_PAR pragma_value CLOSE_PAR )? ; -pragma_value: - signed_number +pragma_value + : signed_number | name | STRING_LITERAL ; -reindex_stmt: - REINDEX_ (collation_name | (schema_name DOT)? (table_name | index_name))? +reindex_stmt + : REINDEX_ (collation_name | (schema_name DOT)? (table_name | index_name))? ; -select_stmt: - common_table_stmt? select_core (compound_operator select_core)* order_by_stmt? limit_stmt? +select_stmt + : common_table_stmt? select_core (compound_operator select_core)* order_by_stmt? limit_stmt? ; -join_clause: - table_or_subquery (join_operator table_or_subquery join_constraint?)* +join_clause + : table_or_subquery (join_operator table_or_subquery join_constraint?)* ; -select_core: - ( +select_core + : ( SELECT_ (DISTINCT_ | ALL_)? result_column (COMMA result_column)* ( FROM_ (table_or_subquery (COMMA table_or_subquery)* | join_clause) - )? (WHERE_ whereExpr=expr)? ( - GROUP_ BY_ groupByExpr+=expr (COMMA groupByExpr+=expr)* ( - HAVING_ havingExpr=expr - )?)? ( - WINDOW_ window_name AS_ window_defn ( - COMMA window_name AS_ window_defn - )* - )? + )? (WHERE_ whereExpr = expr)? ( + GROUP_ BY_ groupByExpr += expr (COMMA groupByExpr += expr)* ( + HAVING_ havingExpr = expr + )? + )? (WINDOW_ window_name AS_ window_defn ( COMMA window_name AS_ window_defn)*)? ) | values_clause ; -factored_select_stmt: - select_stmt +factored_select_stmt + : select_stmt ; -simple_select_stmt: - common_table_stmt? select_core order_by_stmt? limit_stmt? +simple_select_stmt + : common_table_stmt? select_core order_by_stmt? limit_stmt? ; -compound_select_stmt: - common_table_stmt? select_core ( +compound_select_stmt + : common_table_stmt? select_core ( (UNION_ ALL_? | INTERSECT_ | EXCEPT_) select_core )+ order_by_stmt? limit_stmt? ; -table_or_subquery: ( +table_or_subquery + : ( (schema_name DOT)? table_name (AS_? table_alias)? ( INDEXED_ BY_ index_name | NOT_ INDEXED_ @@ -440,72 +413,73 @@ table_or_subquery: ( | OPEN_PAR select_stmt CLOSE_PAR (AS_? table_alias)? ; -result_column: - STAR +result_column + : STAR | table_name DOT STAR | expr ( AS_? column_alias)? ; -join_operator: - COMMA +join_operator + : COMMA | NATURAL_? (LEFT_ OUTER_? | INNER_ | CROSS_)? JOIN_ ; -join_constraint: - ON_ expr +join_constraint + : ON_ expr | USING_ OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR ; -compound_operator: - UNION_ ALL_? +compound_operator + : UNION_ ALL_? | INTERSECT_ | EXCEPT_ ; -update_stmt: - with_clause? UPDATE_ ( - OR_ (ROLLBACK_ | ABORT_ | REPLACE_ | FAIL_ | IGNORE_) - )? qualified_table_name SET_ (column_name | column_name_list) ASSIGN expr ( - COMMA (column_name | column_name_list) ASSIGN expr - )* ( +update_stmt + : with_clause? UPDATE_ (OR_ (ROLLBACK_ | ABORT_ | REPLACE_ | FAIL_ | IGNORE_))? qualified_table_name SET_ ( + column_name + | column_name_list + ) ASSIGN expr (COMMA (column_name | column_name_list) ASSIGN expr)* ( FROM_ (table_or_subquery (COMMA table_or_subquery)* | join_clause) )? (WHERE_ expr)? returning_clause? ; -column_name_list: - OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR +column_name_list + : OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR ; -update_stmt_limited: - with_clause? UPDATE_ ( - OR_ (ROLLBACK_ | ABORT_ | REPLACE_ | FAIL_ | IGNORE_) - )? qualified_table_name SET_ (column_name | column_name_list) ASSIGN expr ( - COMMA (column_name | column_name_list) ASSIGN expr - )* (WHERE_ expr)? returning_clause? (order_by_stmt? limit_stmt)? +update_stmt_limited + : with_clause? UPDATE_ (OR_ (ROLLBACK_ | ABORT_ | REPLACE_ | FAIL_ | IGNORE_))? qualified_table_name SET_ ( + column_name + | column_name_list + ) ASSIGN expr (COMMA (column_name | column_name_list) ASSIGN expr)* (WHERE_ expr)? returning_clause? ( + order_by_stmt? limit_stmt + )? ; -qualified_table_name: (schema_name DOT)? table_name (AS_ alias)? ( +qualified_table_name + : (schema_name DOT)? table_name (AS_ alias)? ( INDEXED_ BY_ index_name | NOT_ INDEXED_ )? ; -vacuum_stmt: - VACUUM_ schema_name? (INTO_ filename)? +vacuum_stmt + : VACUUM_ schema_name? (INTO_ filename)? ; -filter_clause: - FILTER_ OPEN_PAR WHERE_ expr CLOSE_PAR +filter_clause + : FILTER_ OPEN_PAR WHERE_ expr CLOSE_PAR ; -window_defn: - OPEN_PAR base_window_name? (PARTITION_ BY_ expr (COMMA expr)*)? ( +window_defn + : OPEN_PAR base_window_name? (PARTITION_ BY_ expr (COMMA expr)*)? ( ORDER_ BY_ ordering_term (COMMA ordering_term)* ) frame_spec? CLOSE_PAR ; -over_clause: - OVER_ ( +over_clause + : OVER_ ( window_name | OPEN_PAR base_window_name? (PARTITION_ BY_ expr (COMMA expr)*)? ( ORDER_ BY_ ordering_term (COMMA ordering_term)* @@ -513,150 +487,144 @@ over_clause: ) ; -frame_spec: - frame_clause ( - EXCLUDE_ ( - NO_ OTHERS_ - | CURRENT_ ROW_ - | GROUP_ - | TIES_ - ) - )? +frame_spec + : frame_clause (EXCLUDE_ ( NO_ OTHERS_ | CURRENT_ ROW_ | GROUP_ | TIES_))? ; -frame_clause: (RANGE_ | ROWS_ | GROUPS_) ( +frame_clause + : (RANGE_ | ROWS_ | GROUPS_) ( frame_single | BETWEEN_ frame_left AND_ frame_right ) ; -simple_function_invocation: - simple_func OPEN_PAR (expr (COMMA expr)* | STAR) CLOSE_PAR +simple_function_invocation + : simple_func OPEN_PAR (expr (COMMA expr)* | STAR) CLOSE_PAR ; -aggregate_function_invocation: - aggregate_func OPEN_PAR (DISTINCT_? expr (COMMA expr)* | STAR)? CLOSE_PAR filter_clause? +aggregate_function_invocation + : aggregate_func OPEN_PAR (DISTINCT_? expr (COMMA expr)* | STAR)? CLOSE_PAR filter_clause? ; -window_function_invocation: - window_function OPEN_PAR (expr (COMMA expr)* | STAR)? CLOSE_PAR filter_clause? OVER_ ( +window_function_invocation + : window_function OPEN_PAR (expr (COMMA expr)* | STAR)? CLOSE_PAR filter_clause? OVER_ ( window_defn | window_name ) ; -common_table_stmt: //additional structures +common_table_stmt + : //additional structures WITH_ RECURSIVE_? common_table_expression (COMMA common_table_expression)* ; -order_by_stmt: - ORDER_ BY_ ordering_term (COMMA ordering_term)* +order_by_stmt + : ORDER_ BY_ ordering_term (COMMA ordering_term)* ; -limit_stmt: - LIMIT_ expr ((OFFSET_ | COMMA) expr)? +limit_stmt + : LIMIT_ expr ((OFFSET_ | COMMA) expr)? ; -ordering_term: - expr (COLLATE_ collation_name)? asc_desc? (NULLS_ (FIRST_ | LAST_))? +ordering_term + : expr (COLLATE_ collation_name)? asc_desc? (NULLS_ (FIRST_ | LAST_))? ; -asc_desc: - ASC_ +asc_desc + : ASC_ | DESC_ ; -frame_left: - expr PRECEDING_ +frame_left + : expr PRECEDING_ | expr FOLLOWING_ | CURRENT_ ROW_ | UNBOUNDED_ PRECEDING_ ; -frame_right: - expr PRECEDING_ +frame_right + : expr PRECEDING_ | expr FOLLOWING_ | CURRENT_ ROW_ | UNBOUNDED_ FOLLOWING_ ; -frame_single: - expr PRECEDING_ +frame_single + : expr PRECEDING_ | UNBOUNDED_ PRECEDING_ | CURRENT_ ROW_ ; // unknown -window_function: - (FIRST_VALUE_ | LAST_VALUE_) OPEN_PAR expr CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc frame_clause - ? CLOSE_PAR +window_function + : (FIRST_VALUE_ | LAST_VALUE_) OPEN_PAR expr CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc frame_clause? + CLOSE_PAR | (CUME_DIST_ | PERCENT_RANK_) OPEN_PAR CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr? CLOSE_PAR - | (DENSE_RANK_ | RANK_ | ROW_NUMBER_) OPEN_PAR CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc + | (DENSE_RANK_ | RANK_ | ROW_NUMBER_) OPEN_PAR CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc CLOSE_PAR + | (LAG_ | LEAD_) OPEN_PAR expr offset? default_value? CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc CLOSE_PAR + | NTH_VALUE_ OPEN_PAR expr COMMA signed_number CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc frame_clause? CLOSE_PAR - | (LAG_ | LEAD_) OPEN_PAR expr offset? default_value? CLOSE_PAR OVER_ OPEN_PAR partition_by? - order_by_expr_asc_desc CLOSE_PAR - | NTH_VALUE_ OPEN_PAR expr COMMA signed_number CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc - frame_clause? CLOSE_PAR | NTILE_ OPEN_PAR expr CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc CLOSE_PAR ; -offset: - COMMA signed_number +offset + : COMMA signed_number ; -default_value: - COMMA signed_number +default_value + : COMMA signed_number ; -partition_by: - PARTITION_ BY_ expr+ +partition_by + : PARTITION_ BY_ expr+ ; -order_by_expr: - ORDER_ BY_ expr+ +order_by_expr + : ORDER_ BY_ expr+ ; -order_by_expr_asc_desc: - ORDER_ BY_ expr_asc_desc +order_by_expr_asc_desc + : ORDER_ BY_ expr_asc_desc ; -expr_asc_desc: - expr asc_desc? (COMMA expr asc_desc?)* +expr_asc_desc + : expr asc_desc? (COMMA expr asc_desc?)* ; //TODO BOTH OF THESE HAVE TO BE REWORKED TO FOLLOW THE SPEC -initial_select: - select_stmt +initial_select + : select_stmt ; -recursive_select: - select_stmt +recursive_select + : select_stmt ; -unary_operator: - MINUS +unary_operator + : MINUS | PLUS | TILDE | NOT_ ; -error_message: - STRING_LITERAL +error_message + : STRING_LITERAL ; -module_argument: // TODO check what exactly is permitted here +module_argument + : // TODO check what exactly is permitted here expr | column_def ; -column_alias: - IDENTIFIER +column_alias + : IDENTIFIER | STRING_LITERAL ; -keyword: - ABORT_ +keyword + : ABORT_ | ACTION_ | ADD_ | AFTER_ @@ -815,101 +783,101 @@ keyword: // TODO: check all names below -name: - any_name +name + : any_name ; -function_name: - any_name +function_name + : any_name ; -schema_name: - any_name +schema_name + : any_name ; -table_name: - any_name +table_name + : any_name ; -table_or_index_name: - any_name +table_or_index_name + : any_name ; -column_name: - any_name +column_name + : any_name ; -collation_name: - any_name +collation_name + : any_name ; -foreign_table: - any_name +foreign_table + : any_name ; -index_name: - any_name +index_name + : any_name ; -trigger_name: - any_name +trigger_name + : any_name ; -view_name: - any_name +view_name + : any_name ; -module_name: - any_name +module_name + : any_name ; -pragma_name: - any_name +pragma_name + : any_name ; -savepoint_name: - any_name +savepoint_name + : any_name ; -table_alias: - any_name +table_alias + : any_name ; -transaction_name: - any_name +transaction_name + : any_name ; -window_name: - any_name +window_name + : any_name ; -alias: - any_name +alias + : any_name ; -filename: - any_name +filename + : any_name ; -base_window_name: - any_name +base_window_name + : any_name ; -simple_func: - any_name +simple_func + : any_name ; -aggregate_func: - any_name +aggregate_func + : any_name ; -table_function_name: - any_name +table_function_name + : any_name ; -any_name: - IDENTIFIER +any_name + : IDENTIFIER | keyword | STRING_LITERAL | OPEN_PAR any_name CLOSE_PAR -; +; \ No newline at end of file diff --git a/sql/trino/TrinoLexer.g4 b/sql/trino/TrinoLexer.g4 index 327ff17394..6c3a9a5ea0 100644 --- a/sql/trino/TrinoLexer.g4 +++ b/sql/trino/TrinoLexer.g4 @@ -12,396 +12,366 @@ * limitations under the License. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar TrinoLexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} -ABSENT_: 'ABSENT'; -ADD_: 'ADD'; -ADMIN_: 'ADMIN'; -AFTER_: 'AFTER'; -ALL_: 'ALL'; -ALTER_: 'ALTER'; -ANALYZE_: 'ANALYZE'; -AND_: 'AND'; -ANY_: 'ANY'; -ARRAY_: 'ARRAY'; -AS_: 'AS'; -ASC_: 'ASC'; -AT_: 'AT'; -AUTHORIZATION_: 'AUTHORIZATION'; -BERNOULLI_: 'BERNOULLI'; -BETWEEN_: 'BETWEEN'; -BOTH_: 'BOTH'; -BY_: 'BY'; -CALL_: 'CALL'; -CASCADE_: 'CASCADE'; -CASE_: 'CASE'; -CAST_: 'CAST'; -CATALOGS_: 'CATALOGS'; -COLUMN_: 'COLUMN'; -COLUMNS_: 'COLUMNS'; -COMMENT_: 'COMMENT'; -COMMIT_: 'COMMIT'; -COMMITTED_: 'COMMITTED'; -CONDITIONAL_: 'CONDITIONAL'; -CONSTRAINT_: 'CONSTRAINT'; -COUNT_: 'COUNT'; -COPARTITION_: 'COPARTITION'; -CREATE_: 'CREATE'; -CROSS_: 'CROSS'; -CUBE_: 'CUBE'; -CURRENT_: 'CURRENT'; -CURRENT_CATALOG_: 'CURRENT_CATALOG'; -CURRENT_DATE_: 'CURRENT_DATE'; -CURRENT_PATH_: 'CURRENT_PATH'; -CURRENT_ROLE_: 'CURRENT_ROLE'; -CURRENT_SCHEMA_: 'CURRENT_SCHEMA'; -CURRENT_TIME_: 'CURRENT_TIME'; -CURRENT_TIMESTAMP_: 'CURRENT_TIMESTAMP'; -CURRENT_USER_: 'CURRENT_USER'; -DATA_: 'DATA'; -DATE_: 'DATE'; -DAY_: 'DAY'; -DEALLOCATE_: 'DEALLOCATE'; -DEFAULT_: 'DEFAULT'; -DEFINER_: 'DEFINER'; -DELETE_: 'DELETE'; -DENY_: 'DENY'; -DESC_: 'DESC'; -DESCRIBE_: 'DESCRIBE'; -DESCRIPTOR_: 'DESCRIPTOR'; -DEFINE_: 'DEFINE'; -DISTINCT_: 'DISTINCT'; -DISTRIBUTED_: 'DISTRIBUTED'; -DOUBLE_: 'DOUBLE'; -DROP_: 'DROP'; -ELSE_: 'ELSE'; -EMPTY_: 'EMPTY'; -ENCODING_: 'ENCODING'; -END_: 'END'; -ERROR_: 'ERROR'; -ESCAPE_: 'ESCAPE'; -EXCEPT_: 'EXCEPT'; -EXCLUDING_: 'EXCLUDING'; -EXECUTE_: 'EXECUTE'; -EXISTS_: 'EXISTS'; -EXPLAIN_: 'EXPLAIN'; -EXTRACT_: 'EXTRACT'; -FALSE_: 'FALSE'; -FETCH_: 'FETCH'; -FILTER_: 'FILTER'; -FINAL_: 'FINAL'; -FIRST_: 'FIRST'; -FOLLOWING_: 'FOLLOWING'; -FOR_: 'FOR'; -FORMAT_: 'FORMAT'; -FROM_: 'FROM'; -FULL_: 'FULL'; -FUNCTIONS_: 'FUNCTIONS'; -GRACE_: 'GRACE'; -GRANT_: 'GRANT'; -GRANTED_: 'GRANTED'; -GRANTS_: 'GRANTS'; -GRAPHVIZ_: 'GRAPHVIZ'; -GROUP_: 'GROUP'; -GROUPING_: 'GROUPING'; -GROUPS_: 'GROUPS'; -HAVING_: 'HAVING'; -HOUR_: 'HOUR'; -IF_: 'IF'; -IGNORE_: 'IGNORE'; -IN_: 'IN'; -INCLUDING_: 'INCLUDING'; -INITIAL_: 'INITIAL'; -INNER_: 'INNER'; -INPUT_: 'INPUT'; -INSERT_: 'INSERT'; -INTERSECT_: 'INTERSECT'; -INTERVAL_: 'INTERVAL'; -INTO_: 'INTO'; -INVOKER_: 'INVOKER'; -IO_: 'IO'; -IS_: 'IS'; -ISOLATION_: 'ISOLATION'; -JOIN_: 'JOIN'; -JSON_: 'JSON'; -JSON_ARRAY_: 'JSON_ARRAY'; -JSON_EXISTS_: 'JSON_EXISTS'; -JSON_OBJECT_: 'JSON_OBJECT'; -JSON_QUERY_: 'JSON_QUERY'; -JSON_VALUE_: 'JSON_VALUE'; -KEEP_: 'KEEP'; -KEY_: 'KEY'; -KEYS_: 'KEYS'; -LAST_: 'LAST'; -LATERAL_: 'LATERAL'; -LEADING_: 'LEADING'; -LEFT_: 'LEFT'; -LEVEL_: 'LEVEL'; -LIKE_: 'LIKE'; -LIMIT_: 'LIMIT'; -LISTAGG_: 'LISTAGG'; -LOCAL_: 'LOCAL'; -LOCALTIME_: 'LOCALTIME'; -LOCALTIMESTAMP_: 'LOCALTIMESTAMP'; -LOGICAL_: 'LOGICAL'; -MAP_: 'MAP'; -MATCH_: 'MATCH'; -MATCHED_: 'MATCHED'; -MATCHES_: 'MATCHES'; -MATCH_RECOGNIZE_: 'MATCH_RECOGNIZE'; -MATERIALIZED_: 'MATERIALIZED'; -MEASURES_: 'MEASURES'; -MERGE_: 'MERGE'; -MINUTE_: 'MINUTE'; -MONTH_: 'MONTH'; -NATURAL_: 'NATURAL'; -NEXT_: 'NEXT'; -NFC_: 'NFC'; -NFD_: 'NFD'; -NFKC_: 'NFKC'; -NFKD_: 'NFKD'; -NO_: 'NO'; -NONE_: 'NONE'; -NORMALIZE_: 'NORMALIZE'; -NOT_: 'NOT'; -NULL_: 'NULL'; -NULLIF_: 'NULLIF'; -NULLS_: 'NULLS'; -OBJECT_: 'OBJECT'; -OFFSET_: 'OFFSET'; -OMIT_: 'OMIT'; -OF_: 'OF'; -ON_: 'ON'; -ONE_: 'ONE'; -ONLY_: 'ONLY'; -OPTION_: 'OPTION'; -OR_: 'OR'; -ORDER_: 'ORDER'; -ORDINALITY_: 'ORDINALITY'; -OUTER_: 'OUTER'; -OUTPUT_: 'OUTPUT'; -OVER_: 'OVER'; -OVERFLOW_: 'OVERFLOW'; -PARTITION_: 'PARTITION'; -PARTITIONS_: 'PARTITIONS'; -PASSING_: 'PASSING'; -PAST_: 'PAST'; -PATH_: 'PATH'; -PATTERN_: 'PATTERN'; -PER_: 'PER'; -PERIOD_: 'PERIOD'; -PERMUTE_: 'PERMUTE'; -POSITION_: 'POSITION'; -PRECEDING_: 'PRECEDING'; -PRECISION_: 'PRECISION'; -PREPARE_: 'PREPARE'; -PRIVILEGES_: 'PRIVILEGES'; -PROPERTIES_: 'PROPERTIES'; -PRUNE_: 'PRUNE'; -QUOTES_: 'QUOTES'; -RANGE_: 'RANGE'; -READ_: 'READ'; -RECURSIVE_: 'RECURSIVE'; -REFRESH_: 'REFRESH'; -RENAME_: 'RENAME'; -REPEATABLE_: 'REPEATABLE'; -REPLACE_: 'REPLACE'; -RESET_: 'RESET'; -RESPECT_: 'RESPECT'; -RESTRICT_: 'RESTRICT'; -RETURNING_: 'RETURNING'; -REVOKE_: 'REVOKE'; -RIGHT_: 'RIGHT'; -ROLE_: 'ROLE'; -ROLES_: 'ROLES'; -ROLLBACK_: 'ROLLBACK'; -ROLLUP_: 'ROLLUP'; -ROW_: 'ROW'; -ROWS_: 'ROWS'; -RUNNING_: 'RUNNING'; -SCALAR_: 'SCALAR'; -SCHEMA_: 'SCHEMA'; -SCHEMAS_: 'SCHEMAS'; -SECOND_: 'SECOND'; -SECURITY_: 'SECURITY'; -SEEK_: 'SEEK'; -SELECT_: 'SELECT'; -SERIALIZABLE_: 'SERIALIZABLE'; -SESSION_: 'SESSION'; -SET_: 'SET'; -SETS_: 'SETS'; -SHOW_: 'SHOW'; +ABSENT_ : 'ABSENT'; +ADD_ : 'ADD'; +ADMIN_ : 'ADMIN'; +AFTER_ : 'AFTER'; +ALL_ : 'ALL'; +ALTER_ : 'ALTER'; +ANALYZE_ : 'ANALYZE'; +AND_ : 'AND'; +ANY_ : 'ANY'; +ARRAY_ : 'ARRAY'; +AS_ : 'AS'; +ASC_ : 'ASC'; +AT_ : 'AT'; +AUTHORIZATION_ : 'AUTHORIZATION'; +BERNOULLI_ : 'BERNOULLI'; +BETWEEN_ : 'BETWEEN'; +BOTH_ : 'BOTH'; +BY_ : 'BY'; +CALL_ : 'CALL'; +CASCADE_ : 'CASCADE'; +CASE_ : 'CASE'; +CAST_ : 'CAST'; +CATALOGS_ : 'CATALOGS'; +COLUMN_ : 'COLUMN'; +COLUMNS_ : 'COLUMNS'; +COMMENT_ : 'COMMENT'; +COMMIT_ : 'COMMIT'; +COMMITTED_ : 'COMMITTED'; +CONDITIONAL_ : 'CONDITIONAL'; +CONSTRAINT_ : 'CONSTRAINT'; +COUNT_ : 'COUNT'; +COPARTITION_ : 'COPARTITION'; +CREATE_ : 'CREATE'; +CROSS_ : 'CROSS'; +CUBE_ : 'CUBE'; +CURRENT_ : 'CURRENT'; +CURRENT_CATALOG_ : 'CURRENT_CATALOG'; +CURRENT_DATE_ : 'CURRENT_DATE'; +CURRENT_PATH_ : 'CURRENT_PATH'; +CURRENT_ROLE_ : 'CURRENT_ROLE'; +CURRENT_SCHEMA_ : 'CURRENT_SCHEMA'; +CURRENT_TIME_ : 'CURRENT_TIME'; +CURRENT_TIMESTAMP_ : 'CURRENT_TIMESTAMP'; +CURRENT_USER_ : 'CURRENT_USER'; +DATA_ : 'DATA'; +DATE_ : 'DATE'; +DAY_ : 'DAY'; +DEALLOCATE_ : 'DEALLOCATE'; +DEFAULT_ : 'DEFAULT'; +DEFINER_ : 'DEFINER'; +DELETE_ : 'DELETE'; +DENY_ : 'DENY'; +DESC_ : 'DESC'; +DESCRIBE_ : 'DESCRIBE'; +DESCRIPTOR_ : 'DESCRIPTOR'; +DEFINE_ : 'DEFINE'; +DISTINCT_ : 'DISTINCT'; +DISTRIBUTED_ : 'DISTRIBUTED'; +DOUBLE_ : 'DOUBLE'; +DROP_ : 'DROP'; +ELSE_ : 'ELSE'; +EMPTY_ : 'EMPTY'; +ENCODING_ : 'ENCODING'; +END_ : 'END'; +ERROR_ : 'ERROR'; +ESCAPE_ : 'ESCAPE'; +EXCEPT_ : 'EXCEPT'; +EXCLUDING_ : 'EXCLUDING'; +EXECUTE_ : 'EXECUTE'; +EXISTS_ : 'EXISTS'; +EXPLAIN_ : 'EXPLAIN'; +EXTRACT_ : 'EXTRACT'; +FALSE_ : 'FALSE'; +FETCH_ : 'FETCH'; +FILTER_ : 'FILTER'; +FINAL_ : 'FINAL'; +FIRST_ : 'FIRST'; +FOLLOWING_ : 'FOLLOWING'; +FOR_ : 'FOR'; +FORMAT_ : 'FORMAT'; +FROM_ : 'FROM'; +FULL_ : 'FULL'; +FUNCTIONS_ : 'FUNCTIONS'; +GRACE_ : 'GRACE'; +GRANT_ : 'GRANT'; +GRANTED_ : 'GRANTED'; +GRANTS_ : 'GRANTS'; +GRAPHVIZ_ : 'GRAPHVIZ'; +GROUP_ : 'GROUP'; +GROUPING_ : 'GROUPING'; +GROUPS_ : 'GROUPS'; +HAVING_ : 'HAVING'; +HOUR_ : 'HOUR'; +IF_ : 'IF'; +IGNORE_ : 'IGNORE'; +IN_ : 'IN'; +INCLUDING_ : 'INCLUDING'; +INITIAL_ : 'INITIAL'; +INNER_ : 'INNER'; +INPUT_ : 'INPUT'; +INSERT_ : 'INSERT'; +INTERSECT_ : 'INTERSECT'; +INTERVAL_ : 'INTERVAL'; +INTO_ : 'INTO'; +INVOKER_ : 'INVOKER'; +IO_ : 'IO'; +IS_ : 'IS'; +ISOLATION_ : 'ISOLATION'; +JOIN_ : 'JOIN'; +JSON_ : 'JSON'; +JSON_ARRAY_ : 'JSON_ARRAY'; +JSON_EXISTS_ : 'JSON_EXISTS'; +JSON_OBJECT_ : 'JSON_OBJECT'; +JSON_QUERY_ : 'JSON_QUERY'; +JSON_VALUE_ : 'JSON_VALUE'; +KEEP_ : 'KEEP'; +KEY_ : 'KEY'; +KEYS_ : 'KEYS'; +LAST_ : 'LAST'; +LATERAL_ : 'LATERAL'; +LEADING_ : 'LEADING'; +LEFT_ : 'LEFT'; +LEVEL_ : 'LEVEL'; +LIKE_ : 'LIKE'; +LIMIT_ : 'LIMIT'; +LISTAGG_ : 'LISTAGG'; +LOCAL_ : 'LOCAL'; +LOCALTIME_ : 'LOCALTIME'; +LOCALTIMESTAMP_ : 'LOCALTIMESTAMP'; +LOGICAL_ : 'LOGICAL'; +MAP_ : 'MAP'; +MATCH_ : 'MATCH'; +MATCHED_ : 'MATCHED'; +MATCHES_ : 'MATCHES'; +MATCH_RECOGNIZE_ : 'MATCH_RECOGNIZE'; +MATERIALIZED_ : 'MATERIALIZED'; +MEASURES_ : 'MEASURES'; +MERGE_ : 'MERGE'; +MINUTE_ : 'MINUTE'; +MONTH_ : 'MONTH'; +NATURAL_ : 'NATURAL'; +NEXT_ : 'NEXT'; +NFC_ : 'NFC'; +NFD_ : 'NFD'; +NFKC_ : 'NFKC'; +NFKD_ : 'NFKD'; +NO_ : 'NO'; +NONE_ : 'NONE'; +NORMALIZE_ : 'NORMALIZE'; +NOT_ : 'NOT'; +NULL_ : 'NULL'; +NULLIF_ : 'NULLIF'; +NULLS_ : 'NULLS'; +OBJECT_ : 'OBJECT'; +OFFSET_ : 'OFFSET'; +OMIT_ : 'OMIT'; +OF_ : 'OF'; +ON_ : 'ON'; +ONE_ : 'ONE'; +ONLY_ : 'ONLY'; +OPTION_ : 'OPTION'; +OR_ : 'OR'; +ORDER_ : 'ORDER'; +ORDINALITY_ : 'ORDINALITY'; +OUTER_ : 'OUTER'; +OUTPUT_ : 'OUTPUT'; +OVER_ : 'OVER'; +OVERFLOW_ : 'OVERFLOW'; +PARTITION_ : 'PARTITION'; +PARTITIONS_ : 'PARTITIONS'; +PASSING_ : 'PASSING'; +PAST_ : 'PAST'; +PATH_ : 'PATH'; +PATTERN_ : 'PATTERN'; +PER_ : 'PER'; +PERIOD_ : 'PERIOD'; +PERMUTE_ : 'PERMUTE'; +POSITION_ : 'POSITION'; +PRECEDING_ : 'PRECEDING'; +PRECISION_ : 'PRECISION'; +PREPARE_ : 'PREPARE'; +PRIVILEGES_ : 'PRIVILEGES'; +PROPERTIES_ : 'PROPERTIES'; +PRUNE_ : 'PRUNE'; +QUOTES_ : 'QUOTES'; +RANGE_ : 'RANGE'; +READ_ : 'READ'; +RECURSIVE_ : 'RECURSIVE'; +REFRESH_ : 'REFRESH'; +RENAME_ : 'RENAME'; +REPEATABLE_ : 'REPEATABLE'; +REPLACE_ : 'REPLACE'; +RESET_ : 'RESET'; +RESPECT_ : 'RESPECT'; +RESTRICT_ : 'RESTRICT'; +RETURNING_ : 'RETURNING'; +REVOKE_ : 'REVOKE'; +RIGHT_ : 'RIGHT'; +ROLE_ : 'ROLE'; +ROLES_ : 'ROLES'; +ROLLBACK_ : 'ROLLBACK'; +ROLLUP_ : 'ROLLUP'; +ROW_ : 'ROW'; +ROWS_ : 'ROWS'; +RUNNING_ : 'RUNNING'; +SCALAR_ : 'SCALAR'; +SCHEMA_ : 'SCHEMA'; +SCHEMAS_ : 'SCHEMAS'; +SECOND_ : 'SECOND'; +SECURITY_ : 'SECURITY'; +SEEK_ : 'SEEK'; +SELECT_ : 'SELECT'; +SERIALIZABLE_ : 'SERIALIZABLE'; +SESSION_ : 'SESSION'; +SET_ : 'SET'; +SETS_ : 'SETS'; +SHOW_ : 'SHOW'; // Missing SKIP in official g4 -SKIP_: 'SKIP'; -SOME_: 'SOME'; -START_: 'START'; -STATS_: 'STATS'; -SUBSET_: 'SUBSET'; -SUBSTRING_: 'SUBSTRING'; -SYSTEM_: 'SYSTEM'; -TABLE_: 'TABLE'; -TABLES_: 'TABLES'; -TABLESAMPLE_: 'TABLESAMPLE'; -TEXT_: 'TEXT'; -TEXT_STRING_: 'STRING'; -THEN_: 'THEN'; -TIES_: 'TIES'; -TIME_: 'TIME'; -TIMESTAMP_: 'TIMESTAMP'; -TO_: 'TO'; -TRAILING_: 'TRAILING'; -TRANSACTION_: 'TRANSACTION'; -TRIM_: 'TRIM'; -TRUE_: 'TRUE'; -TRUNCATE_: 'TRUNCATE'; -TRY_CAST_: 'TRY_CAST'; -TYPE_: 'TYPE'; -UESCAPE_: 'UESCAPE'; -UNBOUNDED_: 'UNBOUNDED'; -UNCOMMITTED_: 'UNCOMMITTED'; -UNCONDITIONAL_: 'UNCONDITIONAL'; -UNION_: 'UNION'; -UNIQUE_: 'UNIQUE'; -UNKNOWN_: 'UNKNOWN'; -UNMATCHED_: 'UNMATCHED'; -UNNEST_: 'UNNEST'; -UPDATE_: 'UPDATE'; -USE_: 'USE'; -USER_: 'USER'; -USING_: 'USING'; -UTF16_: 'UTF16'; -UTF32_: 'UTF32'; -UTF8_: 'UTF8'; -VALIDATE_: 'VALIDATE'; -VALUE_: 'VALUE'; -VALUES_: 'VALUES'; -VERBOSE_: 'VERBOSE'; -VERSION_: 'VERSION'; -VIEW_: 'VIEW'; -WHEN_: 'WHEN'; -WHERE_: 'WHERE'; -WINDOW_: 'WINDOW'; -WITH_: 'WITH'; -WITHIN_: 'WITHIN'; -WITHOUT_: 'WITHOUT'; -WORK_: 'WORK'; -WRAPPER_: 'WRAPPER'; -WRITE_: 'WRITE'; -YEAR_: 'YEAR'; -ZONE_: 'ZONE'; +SKIP_ : 'SKIP'; +SOME_ : 'SOME'; +START_ : 'START'; +STATS_ : 'STATS'; +SUBSET_ : 'SUBSET'; +SUBSTRING_ : 'SUBSTRING'; +SYSTEM_ : 'SYSTEM'; +TABLE_ : 'TABLE'; +TABLES_ : 'TABLES'; +TABLESAMPLE_ : 'TABLESAMPLE'; +TEXT_ : 'TEXT'; +TEXT_STRING_ : 'STRING'; +THEN_ : 'THEN'; +TIES_ : 'TIES'; +TIME_ : 'TIME'; +TIMESTAMP_ : 'TIMESTAMP'; +TO_ : 'TO'; +TRAILING_ : 'TRAILING'; +TRANSACTION_ : 'TRANSACTION'; +TRIM_ : 'TRIM'; +TRUE_ : 'TRUE'; +TRUNCATE_ : 'TRUNCATE'; +TRY_CAST_ : 'TRY_CAST'; +TYPE_ : 'TYPE'; +UESCAPE_ : 'UESCAPE'; +UNBOUNDED_ : 'UNBOUNDED'; +UNCOMMITTED_ : 'UNCOMMITTED'; +UNCONDITIONAL_ : 'UNCONDITIONAL'; +UNION_ : 'UNION'; +UNIQUE_ : 'UNIQUE'; +UNKNOWN_ : 'UNKNOWN'; +UNMATCHED_ : 'UNMATCHED'; +UNNEST_ : 'UNNEST'; +UPDATE_ : 'UPDATE'; +USE_ : 'USE'; +USER_ : 'USER'; +USING_ : 'USING'; +UTF16_ : 'UTF16'; +UTF32_ : 'UTF32'; +UTF8_ : 'UTF8'; +VALIDATE_ : 'VALIDATE'; +VALUE_ : 'VALUE'; +VALUES_ : 'VALUES'; +VERBOSE_ : 'VERBOSE'; +VERSION_ : 'VERSION'; +VIEW_ : 'VIEW'; +WHEN_ : 'WHEN'; +WHERE_ : 'WHERE'; +WINDOW_ : 'WINDOW'; +WITH_ : 'WITH'; +WITHIN_ : 'WITHIN'; +WITHOUT_ : 'WITHOUT'; +WORK_ : 'WORK'; +WRAPPER_ : 'WRAPPER'; +WRITE_ : 'WRITE'; +YEAR_ : 'YEAR'; +ZONE_ : 'ZONE'; -EQ_: '='; -NEQ_: '<>' | '!='; -LT_: '<'; -LTE_: '<='; -GT_: '>'; -GTE_: '>='; +EQ_ : '='; +NEQ_ : '<>' | '!='; +LT_ : '<'; +LTE_ : '<='; +GT_ : '>'; +GTE_ : '>='; -PLUS_: '+'; -MINUS_: '-'; -ASTERISK_: '*'; -SLASH_: '/'; -PERCENT_: '%'; -CONCAT_: '||'; -QUESTION_MARK_: '?'; +PLUS_ : '+'; +MINUS_ : '-'; +ASTERISK_ : '*'; +SLASH_ : '/'; +PERCENT_ : '%'; +CONCAT_ : '||'; +QUESTION_MARK_ : '?'; // Punctuations not provided by official g4 file -DOT_: '.'; -COLON_: '_:' ; -COMMA_: ',' ; -SEMICOLON_: ';' ; +DOT_ : '.'; +COLON_ : '_:'; +COMMA_ : ','; +SEMICOLON_ : ';'; -LPAREN_: '(' ; -RPAREN_: ')' ; -LSQUARE_: '[' ; -RSQUARE_: ']' ; -LCURLY_: '{'; -RCURLY_: '}'; -LCURLYHYPHEN_: '{-'; -RCURLYHYPHEN_: '-}'; +LPAREN_ : '('; +RPAREN_ : ')'; +LSQUARE_ : '['; +RSQUARE_ : ']'; +LCURLY_ : '{'; +RCURLY_ : '}'; +LCURLYHYPHEN_ : '{-'; +RCURLYHYPHEN_ : '-}'; -LARROW_: '<-'; -RARROW_: '->'; -RDOUBLEARROW_: '=>'; +LARROW_ : '<-'; +RARROW_ : '->'; +RDOUBLEARROW_ : '=>'; -VBAR_: '|'; -DOLLAR_: '$'; -CARET_: '^'; +VBAR_ : '|'; +DOLLAR_ : '$'; +CARET_ : '^'; -STRING_ - : '\'' ( ~'\'' | '\'\'' )* '\'' - ; +STRING_: '\'' ( ~'\'' | '\'\'')* '\''; -UNICODE_STRING_ - : 'U&\'' ( ~'\'' | '\'\'' )* '\'' - ; +UNICODE_STRING_: 'U&\'' ( ~'\'' | '\'\'')* '\''; // Note_: we allow any character inside the binary literal and validate // its a correct literal when the AST is being constructed. This // allows us to provide more meaningful error messages to the user -BINARY_LITERAL_ - : 'X\'' ~'\''* '\'' - ; +BINARY_LITERAL_: 'X\'' ~'\''* '\''; -INTEGER_VALUE_ - : DIGIT_+ - ; +INTEGER_VALUE_: DIGIT_+; -DECIMAL_VALUE_ - : DIGIT_+ '.' DIGIT_* - | '.' DIGIT_+ - ; +DECIMAL_VALUE_: DIGIT_+ '.' DIGIT_* | '.' DIGIT_+; -DOUBLE_VALUE_ - : DIGIT_+ ('.' DIGIT_*)? EXPONENT_ - | '.' DIGIT_+ EXPONENT_ - ; +DOUBLE_VALUE_: DIGIT_+ ('.' DIGIT_*)? EXPONENT_ | '.' DIGIT_+ EXPONENT_; -IDENTIFIER_ - : (LETTER_ | '_') (LETTER_ | DIGIT_ | '_')* - ; +IDENTIFIER_: (LETTER_ | '_') (LETTER_ | DIGIT_ | '_')*; -DIGIT_IDENTIFIER_ - : DIGIT_ (LETTER_ | DIGIT_ | '_')+ - ; +DIGIT_IDENTIFIER_: DIGIT_ (LETTER_ | DIGIT_ | '_')+; -QUOTED_IDENTIFIER_ - : '"' ( ~'"' | '""' )* '"' - ; +QUOTED_IDENTIFIER_: '"' ( ~'"' | '""')* '"'; -BACKQUOTED_IDENTIFIER_ - : '`' ( ~'`' | '``' )* '`' - ; +BACKQUOTED_IDENTIFIER_: '`' ( ~'`' | '``')* '`'; -fragment EXPONENT_ - : 'E' [+-]? DIGIT_+ - ; +fragment EXPONENT_: 'E' [+-]? DIGIT_+; -fragment DIGIT_ - : [0-9] - ; +fragment DIGIT_: [0-9]; -fragment LETTER_ - : [A-Z] - ; +fragment LETTER_: [A-Z]; -SIMPLE_COMMENT_ - : '--' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN) - ; +SIMPLE_COMMENT_: '--' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN); -BRACKETED_COMMENT_ - : '/*' .*? '*/' -> channel(HIDDEN) - ; +BRACKETED_COMMENT_: '/*' .*? '*/' -> channel(HIDDEN); -WS_ - : [ \r\n\t]+ -> 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_ - : . - ; +UNRECOGNIZED_: .; \ No newline at end of file diff --git a/sql/trino/TrinoParser.g4 b/sql/trino/TrinoParser.g4 index d8311ce149..d8eb8cdd51 100644 --- a/sql/trino/TrinoParser.g4 +++ b/sql/trino/TrinoParser.g4 @@ -12,6 +12,9 @@ * limitations under the License. */ +// $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 TrinoParser; options { @@ -25,10 +28,10 @@ parse statements : singleStatement - |standaloneExpression - |standalonePathSpecification - |standaloneType - |standaloneRowPattern SEMICOLON_? + | standaloneExpression + | standalonePathSpecification + | standaloneType + | standaloneRowPattern SEMICOLON_? ; singleStatement @@ -52,145 +55,116 @@ standaloneRowPattern ; statement - : query #statementDefault - | USE_ schema=identifier #use - | USE_ catalog=identifier DOT_ schema=identifier #use - | CREATE_ SCHEMA_ (IF_ NOT_ EXISTS_)? qualifiedName - (AUTHORIZATION_ principal)? - (WITH_ properties)? #createSchema - | DROP_ SCHEMA_ (IF_ EXISTS_)? qualifiedName (CASCADE_ | RESTRICT_)? #dropSchema - | ALTER_ SCHEMA_ qualifiedName RENAME_ TO_ identifier #renameSchema - | ALTER_ SCHEMA_ qualifiedName SET_ AUTHORIZATION_ principal #setSchemaAuthorization - | CREATE_ TABLE_ (IF_ NOT_ EXISTS_)? qualifiedName columnAliases? - (COMMENT_ string_)? - (WITH_ properties)? AS_ (query | LPAREN_ query RPAREN_) - (WITH_ (NO_)? DATA_)? #createTableAsSelect - | CREATE_ TABLE_ (IF_ NOT_ EXISTS_)? qualifiedName - LPAREN_ tableElement (COMMA_ tableElement)* RPAREN_ - (COMMENT_ string_)? - (WITH_ properties)? #createTable - | DROP_ TABLE_ (IF_ EXISTS_)? qualifiedName #dropTable - | INSERT_ INTO_ qualifiedName columnAliases? query #insertInto - | DELETE_ FROM_ qualifiedName (WHERE_ booleanExpression)? #delete - | TRUNCATE_ TABLE_ qualifiedName #truncateTable - | COMMENT_ ON_ TABLE_ qualifiedName IS_ (string_ | NULL_) #commentTable - | COMMENT_ ON_ VIEW_ qualifiedName IS_ (string_ | NULL_) #commentView - | COMMENT_ ON_ COLUMN_ qualifiedName IS_ (string_ | NULL_) #commentColumn - | ALTER_ TABLE_ (IF_ EXISTS_)? from=qualifiedName - RENAME_ TO_ to=qualifiedName #renameTable - | ALTER_ TABLE_ (IF_ EXISTS_)? tableName=qualifiedName - ADD_ COLUMN_ (IF_ NOT_ EXISTS_)? column=columnDefinition #addColumn - | ALTER_ TABLE_ (IF_ EXISTS_)? tableName=qualifiedName - RENAME_ COLUMN_ (IF_ EXISTS_)? from=identifier TO_ to=identifier #renameColumn - | ALTER_ TABLE_ (IF_ EXISTS_)? tableName=qualifiedName - DROP_ COLUMN_ (IF_ EXISTS_)? column=qualifiedName #dropColumn - | ALTER_ TABLE_ (IF_ EXISTS_)? tableName=qualifiedName - ALTER_ COLUMN_ columnName=identifier SET_ DATA_ TYPE_ type #setColumnType - | ALTER_ TABLE_ tableName=qualifiedName SET_ AUTHORIZATION_ principal #setTableAuthorization - | ALTER_ TABLE_ tableName=qualifiedName - SET_ PROPERTIES_ propertyAssignments #setTableProperties - | ALTER_ TABLE_ tableName=qualifiedName - EXECUTE_ procedureName=identifier - (LPAREN_ (callArgument (COMMA_ callArgument)*)? RPAREN_)? - (WHERE_ where=booleanExpression)? #tableExecute - | ANALYZE_ qualifiedName (WITH_ properties)? #analyze - | CREATE_ (OR_ REPLACE_)? MATERIALIZED_ VIEW_ - (IF_ NOT_ EXISTS_)? qualifiedName - (GRACE_ PERIOD_ interval)? - (COMMENT_ string_)? - (WITH_ properties)? AS_ query #createMaterializedView - | CREATE_ (OR_ REPLACE_)? VIEW_ qualifiedName - (COMMENT_ string_)? - (SECURITY_ (DEFINER_ | INVOKER_))? AS_ query #createView - | REFRESH_ MATERIALIZED_ VIEW_ qualifiedName #refreshMaterializedView - | DROP_ MATERIALIZED_ VIEW_ (IF_ EXISTS_)? qualifiedName #dropMaterializedView - | ALTER_ MATERIALIZED_ VIEW_ (IF_ EXISTS_)? from=qualifiedName - RENAME_ TO_ to=qualifiedName #renameMaterializedView - | ALTER_ MATERIALIZED_ VIEW_ qualifiedName - SET_ PROPERTIES_ propertyAssignments #setMaterializedViewProperties - | DROP_ VIEW_ (IF_ EXISTS_)? qualifiedName #dropView - | ALTER_ VIEW_ from=qualifiedName RENAME_ TO_ to=qualifiedName #renameView - | ALTER_ VIEW_ from=qualifiedName SET_ AUTHORIZATION_ principal #setViewAuthorization - | CALL_ qualifiedName LPAREN_ (callArgument (COMMA_ callArgument)*)? RPAREN_ #call - | CREATE_ ROLE_ name=identifier - (WITH_ ADMIN_ grantor)? - (IN_ catalog=identifier)? #createRole - | DROP_ ROLE_ name=identifier (IN_ catalog=identifier)? #dropRole - | GRANT_ - roles - TO_ principal (COMMA_ principal)* - (WITH_ ADMIN_ OPTION_)? - (GRANTED_ BY_ grantor)? - (IN_ catalog=identifier)? #grantRoles - | REVOKE_ - (ADMIN_ OPTION_ FOR_)? - roles - FROM_ principal (COMMA_ principal)* - (GRANTED_ BY_ grantor)? - (IN_ catalog=identifier)? #revokeRoles - | SET_ ROLE_ (ALL_ | NONE_ | role=identifier) - (IN_ catalog=identifier)? #setRole - | GRANT_ - (privilege (COMMA_ privilege)* | ALL_ PRIVILEGES_) - ON_ (SCHEMA_ | TABLE_)? qualifiedName - TO_ grantee=principal - (WITH_ GRANT_ OPTION_)? #grant - | DENY_ - (privilege (COMMA_ privilege)* | ALL_ PRIVILEGES_) - ON_ (SCHEMA_ | TABLE_)? qualifiedName - TO_ grantee=principal #deny - | REVOKE_ - (GRANT_ OPTION_ FOR_)? - (privilege (COMMA_ privilege)* | ALL_ PRIVILEGES_) - ON_ (SCHEMA_ | TABLE_)? qualifiedName - FROM_ grantee=principal #revoke - | SHOW_ GRANTS_ (ON_ TABLE_? qualifiedName)? #showGrants - | EXPLAIN_ (LPAREN_ explainOption (COMMA_ explainOption)* RPAREN_)? statement #explain - | EXPLAIN_ ANALYZE_ VERBOSE_? statement #explainAnalyze - | SHOW_ CREATE_ TABLE_ qualifiedName #showCreateTable - | SHOW_ CREATE_ SCHEMA_ qualifiedName #showCreateSchema - | SHOW_ CREATE_ VIEW_ qualifiedName #showCreateView - | SHOW_ CREATE_ MATERIALIZED_ VIEW_ qualifiedName #showCreateMaterializedView - | SHOW_ TABLES_ ((FROM_ | IN_) qualifiedName)? - (LIKE_ pattern=string_ (ESCAPE_ escape=string_)?)? #showTables - | SHOW_ SCHEMAS_ ((FROM_ | IN_) identifier)? - (LIKE_ pattern=string_ (ESCAPE_ escape=string_)?)? #showSchemas - | SHOW_ CATALOGS_ - (LIKE_ pattern=string_ (ESCAPE_ escape=string_)?)? #showCatalogs - | SHOW_ COLUMNS_ (FROM_ | IN_) qualifiedName? - (LIKE_ pattern=string_ (ESCAPE_ escape=string_)?)? #showColumns - | SHOW_ STATS_ FOR_ qualifiedName #showStats - | SHOW_ STATS_ FOR_ LPAREN_ query RPAREN_ #showStatsForQuery - | SHOW_ CURRENT_? ROLES_ ((FROM_ | IN_) identifier)? #showRoles - | SHOW_ ROLE_ GRANTS_ ((FROM_ | IN_) identifier)? #showRoleGrants - | DESCRIBE_ qualifiedName #showColumns - | DESC_ qualifiedName #showColumns - | SHOW_ FUNCTIONS_ - (LIKE_ pattern=string_ (ESCAPE_ escape=string_)?)? #showFunctions - | SHOW_ SESSION_ - (LIKE_ pattern=string_ (ESCAPE_ escape=string_)?)? #showSession - | SET_ SESSION_ qualifiedName EQ_ expression #setSession - | RESET_ SESSION_ AUTHORIZATION_ #resetSessionAuthorization - | RESET_ SESSION_ qualifiedName #resetSession - | START_ TRANSACTION_ (transactionMode (COMMA_ transactionMode)*)? #startTransaction - | COMMIT_ WORK_? #commit - | ROLLBACK_ WORK_? #rollback - | PREPARE_ identifier FROM_ statement #prepare - | DEALLOCATE_ PREPARE_ identifier #deallocate - | EXECUTE_ identifier (USING_ expression (COMMA_ expression)*)? #execute - | DESCRIBE_ INPUT_ identifier #describeInput - | DESCRIBE_ OUTPUT_ identifier #describeOutput - | SET_ PATH_ pathSpecification #setPath - | SET_ TIME_ ZONE_ (LOCAL_ | expression) #setTimeZone - | UPDATE_ qualifiedName - SET_ updateAssignment (COMMA_ updateAssignment)* - (WHERE_ where=booleanExpression)? #update - | MERGE_ INTO_ qualifiedName (AS_? identifier)? - USING_ relation ON_ expression mergeCase+ #merge + : query # statementDefault + | USE_ schema = identifier # use + | USE_ catalog = identifier DOT_ schema = identifier # use + | CREATE_ SCHEMA_ (IF_ NOT_ EXISTS_)? qualifiedName (AUTHORIZATION_ principal)? ( + WITH_ properties + )? # createSchema + | DROP_ SCHEMA_ (IF_ EXISTS_)? qualifiedName (CASCADE_ | RESTRICT_)? # dropSchema + | ALTER_ SCHEMA_ qualifiedName RENAME_ TO_ identifier # renameSchema + | ALTER_ SCHEMA_ qualifiedName SET_ AUTHORIZATION_ principal # setSchemaAuthorization + | CREATE_ TABLE_ (IF_ NOT_ EXISTS_)? qualifiedName columnAliases? (COMMENT_ string_)? ( + WITH_ properties + )? AS_ (query | LPAREN_ query RPAREN_) (WITH_ (NO_)? DATA_)? # createTableAsSelect + | CREATE_ TABLE_ (IF_ NOT_ EXISTS_)? qualifiedName LPAREN_ tableElement (COMMA_ tableElement)* RPAREN_ ( + COMMENT_ string_ + )? (WITH_ properties)? # createTable + | DROP_ TABLE_ (IF_ EXISTS_)? qualifiedName # dropTable + | INSERT_ INTO_ qualifiedName columnAliases? query # insertInto + | DELETE_ FROM_ qualifiedName (WHERE_ booleanExpression)? # delete + | TRUNCATE_ TABLE_ qualifiedName # truncateTable + | COMMENT_ ON_ TABLE_ qualifiedName IS_ (string_ | NULL_) # commentTable + | COMMENT_ ON_ VIEW_ qualifiedName IS_ (string_ | NULL_) # commentView + | COMMENT_ ON_ COLUMN_ qualifiedName IS_ (string_ | NULL_) # commentColumn + | ALTER_ TABLE_ (IF_ EXISTS_)? from = qualifiedName RENAME_ TO_ to = qualifiedName # renameTable + | ALTER_ TABLE_ (IF_ EXISTS_)? tableName = qualifiedName ADD_ COLUMN_ (IF_ NOT_ EXISTS_)? column = columnDefinition # addColumn + | ALTER_ TABLE_ (IF_ EXISTS_)? tableName = qualifiedName RENAME_ COLUMN_ (IF_ EXISTS_)? from = identifier TO_ to = identifier # renameColumn + | ALTER_ TABLE_ (IF_ EXISTS_)? tableName = qualifiedName DROP_ COLUMN_ (IF_ EXISTS_)? column = qualifiedName # dropColumn + | ALTER_ TABLE_ (IF_ EXISTS_)? tableName = qualifiedName ALTER_ COLUMN_ columnName = identifier SET_ DATA_ TYPE_ type # setColumnType + | ALTER_ TABLE_ tableName = qualifiedName SET_ AUTHORIZATION_ principal # setTableAuthorization + | ALTER_ TABLE_ tableName = qualifiedName SET_ PROPERTIES_ propertyAssignments # setTableProperties + | ALTER_ TABLE_ tableName = qualifiedName EXECUTE_ procedureName = identifier ( + LPAREN_ (callArgument (COMMA_ callArgument)*)? RPAREN_ + )? (WHERE_ where = booleanExpression)? # tableExecute + | ANALYZE_ qualifiedName (WITH_ properties)? # analyze + | CREATE_ (OR_ REPLACE_)? MATERIALIZED_ VIEW_ (IF_ NOT_ EXISTS_)? qualifiedName ( + GRACE_ PERIOD_ interval + )? (COMMENT_ string_)? (WITH_ properties)? AS_ query # createMaterializedView + | CREATE_ (OR_ REPLACE_)? VIEW_ qualifiedName (COMMENT_ string_)? ( + SECURITY_ (DEFINER_ | INVOKER_) + )? AS_ query # createView + | REFRESH_ MATERIALIZED_ VIEW_ qualifiedName # refreshMaterializedView + | DROP_ MATERIALIZED_ VIEW_ (IF_ EXISTS_)? qualifiedName # dropMaterializedView + | ALTER_ MATERIALIZED_ VIEW_ (IF_ EXISTS_)? from = qualifiedName RENAME_ TO_ to = qualifiedName # renameMaterializedView + | ALTER_ MATERIALIZED_ VIEW_ qualifiedName SET_ PROPERTIES_ propertyAssignments # setMaterializedViewProperties + | DROP_ VIEW_ (IF_ EXISTS_)? qualifiedName # dropView + | ALTER_ VIEW_ from = qualifiedName RENAME_ TO_ to = qualifiedName # renameView + | ALTER_ VIEW_ from = qualifiedName SET_ AUTHORIZATION_ principal # setViewAuthorization + | CALL_ qualifiedName LPAREN_ (callArgument (COMMA_ callArgument)*)? RPAREN_ # call + | CREATE_ ROLE_ name = identifier (WITH_ ADMIN_ grantor)? (IN_ catalog = identifier)? # createRole + | DROP_ ROLE_ name = identifier (IN_ catalog = identifier)? # dropRole + | GRANT_ roles TO_ principal (COMMA_ principal)* (WITH_ ADMIN_ OPTION_)? (GRANTED_ BY_ grantor)? ( + IN_ catalog = identifier + )? # grantRoles + | REVOKE_ (ADMIN_ OPTION_ FOR_)? roles FROM_ principal (COMMA_ principal)* ( + GRANTED_ BY_ grantor + )? (IN_ catalog = identifier)? # revokeRoles + | SET_ ROLE_ (ALL_ | NONE_ | role = identifier) (IN_ catalog = identifier)? # setRole + | GRANT_ (privilege (COMMA_ privilege)* | ALL_ PRIVILEGES_) ON_ (SCHEMA_ | TABLE_)? qualifiedName TO_ grantee = principal ( + WITH_ GRANT_ OPTION_ + )? # grant + | DENY_ (privilege (COMMA_ privilege)* | ALL_ PRIVILEGES_) ON_ (SCHEMA_ | TABLE_)? qualifiedName TO_ grantee = principal # deny + | REVOKE_ (GRANT_ OPTION_ FOR_)? (privilege (COMMA_ privilege)* | ALL_ PRIVILEGES_) ON_ ( + SCHEMA_ + | TABLE_ + )? qualifiedName FROM_ grantee = principal # revoke + | SHOW_ GRANTS_ (ON_ TABLE_? qualifiedName)? # showGrants + | EXPLAIN_ (LPAREN_ explainOption (COMMA_ explainOption)* RPAREN_)? statement # explain + | EXPLAIN_ ANALYZE_ VERBOSE_? statement # explainAnalyze + | SHOW_ CREATE_ TABLE_ qualifiedName # showCreateTable + | SHOW_ CREATE_ SCHEMA_ qualifiedName # showCreateSchema + | SHOW_ CREATE_ VIEW_ qualifiedName # showCreateView + | SHOW_ CREATE_ MATERIALIZED_ VIEW_ qualifiedName # showCreateMaterializedView + | SHOW_ TABLES_ ((FROM_ | IN_) qualifiedName)? ( + LIKE_ pattern = string_ (ESCAPE_ escape = string_)? + )? # showTables + | SHOW_ SCHEMAS_ ((FROM_ | IN_) identifier)? ( + LIKE_ pattern = string_ (ESCAPE_ escape = string_)? + )? # showSchemas + | SHOW_ CATALOGS_ (LIKE_ pattern = string_ (ESCAPE_ escape = string_)?)? # showCatalogs + | SHOW_ COLUMNS_ (FROM_ | IN_) qualifiedName? ( + LIKE_ pattern = string_ (ESCAPE_ escape = string_)? + )? # showColumns + | SHOW_ STATS_ FOR_ qualifiedName # showStats + | SHOW_ STATS_ FOR_ LPAREN_ query RPAREN_ # showStatsForQuery + | SHOW_ CURRENT_? ROLES_ ((FROM_ | IN_) identifier)? # showRoles + | SHOW_ ROLE_ GRANTS_ ((FROM_ | IN_) identifier)? # showRoleGrants + | DESCRIBE_ qualifiedName # showColumns + | DESC_ qualifiedName # showColumns + | SHOW_ FUNCTIONS_ (LIKE_ pattern = string_ (ESCAPE_ escape = string_)?)? # showFunctions + | SHOW_ SESSION_ (LIKE_ pattern = string_ (ESCAPE_ escape = string_)?)? # showSession + | SET_ SESSION_ qualifiedName EQ_ expression # setSession + | RESET_ SESSION_ AUTHORIZATION_ # resetSessionAuthorization + | RESET_ SESSION_ qualifiedName # resetSession + | START_ TRANSACTION_ (transactionMode (COMMA_ transactionMode)*)? # startTransaction + | COMMIT_ WORK_? # commit + | ROLLBACK_ WORK_? # rollback + | PREPARE_ identifier FROM_ statement # prepare + | DEALLOCATE_ PREPARE_ identifier # deallocate + | EXECUTE_ identifier (USING_ expression (COMMA_ expression)*)? # execute + | DESCRIBE_ INPUT_ identifier # describeInput + | DESCRIBE_ OUTPUT_ identifier # describeOutput + | SET_ PATH_ pathSpecification # setPath + | SET_ TIME_ ZONE_ (LOCAL_ | expression) # setTimeZone + | UPDATE_ qualifiedName SET_ updateAssignment (COMMA_ updateAssignment)* ( + WHERE_ where = booleanExpression + )? # update + | MERGE_ INTO_ qualifiedName (AS_? identifier)? USING_ relation ON_ expression mergeCase+ # merge ; query - : with? queryNoWith + : with? queryNoWith ; with @@ -207,7 +181,7 @@ columnDefinition ; likeClause - : LIKE_ qualifiedName (optionType=(INCLUDING_ | EXCLUDING_) PROPERTIES_)? + : LIKE_ qualifiedName (optionType = (INCLUDING_ | EXCLUDING_) PROPERTIES_)? ; properties @@ -223,17 +197,17 @@ property ; propertyValue - : DEFAULT_ #defaultPropertyValue - | expression #nonDefaultPropertyValue + : DEFAULT_ # defaultPropertyValue + | expression # nonDefaultPropertyValue ; queryNoWith - : queryTerm - (ORDER_ BY_ sortItem (COMMA_ sortItem)*)? - (OFFSET_ offset=rowCount (ROW_ | ROWS_)?)? - ( LIMIT_ limit=limitRowCount - | FETCH_ (FIRST_ | NEXT_) (fetchFirst=rowCount)? (ROW_ | ROWS_) (ONLY_ | WITH_ TIES_) - )? + : queryTerm (ORDER_ BY_ sortItem (COMMA_ sortItem)*)? ( + OFFSET_ offset = rowCount (ROW_ | ROWS_)? + )? ( + LIMIT_ limit = limitRowCount + | FETCH_ (FIRST_ | NEXT_) (fetchFirst = rowCount)? (ROW_ | ROWS_) (ONLY_ | WITH_ TIES_) + )? ; limitRowCount @@ -247,29 +221,28 @@ rowCount ; queryTerm - : queryPrimary #queryTermDefault - | left=queryTerm operator=INTERSECT_ setQuantifier? right=queryTerm #setOperation - | left=queryTerm operator=(UNION_ | EXCEPT_) setQuantifier? right=queryTerm #setOperation + : queryPrimary # queryTermDefault + | left = queryTerm operator = INTERSECT_ setQuantifier? right = queryTerm # setOperation + | left = queryTerm operator = (UNION_ | EXCEPT_) setQuantifier? right = queryTerm # setOperation ; queryPrimary - : querySpecification #queryPrimaryDefault - | TABLE_ qualifiedName #table - | VALUES_ expression (COMMA_ expression)* #inlineTable - | LPAREN_ queryNoWith RPAREN_ #subquery + : querySpecification # queryPrimaryDefault + | TABLE_ qualifiedName # table + | VALUES_ expression (COMMA_ expression)* # inlineTable + | LPAREN_ queryNoWith RPAREN_ # subquery ; sortItem - : expression ordering=(ASC_ | DESC_)? (NULLS_ nullOrdering=(FIRST_ | LAST_))? + : expression ordering = (ASC_ | DESC_)? (NULLS_ nullOrdering = (FIRST_ | LAST_))? ; querySpecification - : SELECT_ setQuantifier? selectItem (COMMA_ selectItem)* - (FROM_ relation (COMMA_ relation)*)? - (WHERE_ where=booleanExpression)? - (GROUP_ BY_ groupBy)? - (HAVING_ having=booleanExpression)? - (WINDOW_ windowDefinition (COMMA_ windowDefinition)*)? + : SELECT_ setQuantifier? selectItem (COMMA_ selectItem)* (FROM_ relation (COMMA_ relation)*)? ( + WHERE_ where = booleanExpression + )? (GROUP_ BY_ groupBy)? (HAVING_ having = booleanExpression)? ( + WINDOW_ windowDefinition (COMMA_ windowDefinition)* + )? ; groupBy @@ -277,10 +250,10 @@ groupBy ; groupingElement - : groupingSet #singleGroupingSet - | ROLLUP_ LPAREN_ (expression (COMMA_ expression)*)? RPAREN_ #rollup - | CUBE_ LPAREN_ (expression (COMMA_ expression)*)? RPAREN_ #cube - | GROUPING_ SETS_ LPAREN_ groupingSet (COMMA_ groupingSet)* RPAREN_ #multipleGroupingSets + : groupingSet # singleGroupingSet + | ROLLUP_ LPAREN_ (expression (COMMA_ expression)*)? RPAREN_ # rollup + | CUBE_ LPAREN_ (expression (COMMA_ expression)*)? RPAREN_ # cube + | GROUPING_ SETS_ LPAREN_ groupingSet (COMMA_ groupingSet)* RPAREN_ # multipleGroupingSets ; groupingSet @@ -289,18 +262,17 @@ groupingSet ; windowDefinition - : name=identifier AS_ LPAREN_ windowSpecification RPAREN_ + : name = identifier AS_ LPAREN_ windowSpecification RPAREN_ ; windowSpecification - : (existingWindowName=identifier)? - (PARTITION_ BY_ partition+=expression (COMMA_ partition+=expression)*)? - (ORDER_ BY_ sortItem (COMMA_ sortItem)*)? - windowFrame? + : (existingWindowName = identifier)? ( + PARTITION_ BY_ partition += expression (COMMA_ partition += expression)* + )? (ORDER_ BY_ sortItem (COMMA_ sortItem)*)? windowFrame? ; namedQuery - : name=identifier (columnAliases)? AS_ LPAREN_ query RPAREN_ + : name = identifier (columnAliases)? AS_ LPAREN_ query RPAREN_ ; setQuantifier @@ -309,18 +281,18 @@ setQuantifier ; selectItem - : expression (AS_? identifier)? #selectSingle - | primaryExpression DOT_ ASTERISK_ (AS_ columnAliases)? #selectAll - | ASTERISK_ #selectAll + : expression (AS_? identifier)? # selectSingle + | primaryExpression DOT_ ASTERISK_ (AS_ columnAliases)? # selectAll + | ASTERISK_ # selectAll ; relation - : left=relation - ( CROSS_ JOIN_ right=sampledRelation - | joinType JOIN_ rightRelation=relation joinCriteria - | NATURAL_ joinType JOIN_ right=sampledRelation - ) #joinRelation - | sampledRelation #relationDefault + : left = relation ( + CROSS_ JOIN_ right = sampledRelation + | joinType JOIN_ rightRelation = relation joinCriteria + | NATURAL_ joinType JOIN_ right = sampledRelation + ) # joinRelation + | sampledRelation # relationDefault ; joinType @@ -334,9 +306,7 @@ joinCriteria ; sampledRelation - : patternRecognition ( - TABLESAMPLE_ sampleType LPAREN_ percentage=expression RPAREN_ - )? + : patternRecognition (TABLESAMPLE_ sampleType LPAREN_ percentage = expression RPAREN_)? ; sampleType @@ -361,19 +331,16 @@ listaggCountIndication patternRecognition : aliasedRelation ( - MATCH_RECOGNIZE_ LPAREN_ - (PARTITION_ BY_ partition+=expression (COMMA_ partition+=expression)*)? - (ORDER_ BY_ sortItem (COMMA_ sortItem)*)? - (MEASURES_ measureDefinition (COMMA_ measureDefinition)*)? - rowsPerMatch? - (AFTER_ MATCH_ skipTo)? - (INITIAL_ | SEEK_)? - PATTERN_ LPAREN_ rowPattern RPAREN_ - (SUBSET_ subsetDefinition (COMMA_ subsetDefinition)*)? - DEFINE_ variableDefinition (COMMA_ variableDefinition)* - RPAREN_ - (AS_? identifier columnAliases?)? - )? + MATCH_RECOGNIZE_ LPAREN_ ( + PARTITION_ BY_ partition += expression (COMMA_ partition += expression)* + )? (ORDER_ BY_ sortItem (COMMA_ sortItem)*)? ( + MEASURES_ measureDefinition (COMMA_ measureDefinition)* + )? rowsPerMatch? (AFTER_ MATCH_ skipTo)? (INITIAL_ | SEEK_)? PATTERN_ LPAREN_ rowPattern RPAREN_ ( + SUBSET_ subsetDefinition (COMMA_ subsetDefinition)* + )? DEFINE_ variableDefinition (COMMA_ variableDefinition)* RPAREN_ ( + AS_? identifier columnAliases? + )? + )? ; measureDefinition @@ -392,14 +359,11 @@ emptyMatchHandling ; skipTo - : SKIP_ - ( TO_ (NEXT_ ROW_ | (FIRST_ | LAST_)? identifier) - | PAST_ LAST_ ROW_ - ) + : SKIP_ (TO_ (NEXT_ ROW_ | (FIRST_ | LAST_)? identifier) | PAST_ LAST_ ROW_) ; subsetDefinition - : name=identifier EQ_ LPAREN_ union+=identifier (COMMA_ union+=identifier)* RPAREN_ + : name = identifier EQ_ LPAREN_ union += identifier (COMMA_ union += identifier)* RPAREN_ ; variableDefinition @@ -415,33 +379,39 @@ columnAliases ; relationPrimary - : qualifiedName queryPeriod? #tableName - | LPAREN_ query RPAREN_ #subqueryRelation - | UNNEST_ LPAREN_ expression (COMMA_ expression)* RPAREN_ (WITH_ ORDINALITY_)? #unnest - | LATERAL_ LPAREN_ query RPAREN_ #lateral - | TABLE_ LPAREN_ tableFunctionCall RPAREN_ #tableFunctionInvocation - | LPAREN_ relation RPAREN_ #parenthesizedRelation + : qualifiedName queryPeriod? # tableName + | LPAREN_ query RPAREN_ # subqueryRelation + | UNNEST_ LPAREN_ expression (COMMA_ expression)* RPAREN_ (WITH_ ORDINALITY_)? # unnest + | LATERAL_ LPAREN_ query RPAREN_ # lateral + | TABLE_ LPAREN_ tableFunctionCall RPAREN_ # tableFunctionInvocation + | LPAREN_ relation RPAREN_ # parenthesizedRelation ; tableFunctionCall - : qualifiedName LPAREN_ (tableFunctionArgument (COMMA_ tableFunctionArgument)*)? - (COPARTITION_ copartitionTables (COMMA_ copartitionTables)*)? RPAREN_ + : qualifiedName LPAREN_ (tableFunctionArgument (COMMA_ tableFunctionArgument)*)? ( + COPARTITION_ copartitionTables (COMMA_ copartitionTables)* + )? RPAREN_ ; tableFunctionArgument - : (identifier RDOUBLEARROW_)? (tableArgument | descriptorArgument | expression) // descriptor before expression to avoid parsing descriptor as a function call + : (identifier RDOUBLEARROW_)? ( + tableArgument + | descriptorArgument + | expression + ) // descriptor before expression to avoid parsing descriptor as a function call ; tableArgument - : tableArgumentRelation - (PARTITION_ BY_ (LPAREN_ (expression (COMMA_ expression)*)? RPAREN_ | expression))? - (PRUNE_ WHEN_ EMPTY_ | KEEP_ WHEN_ EMPTY_)? - (ORDER_ BY_ (LPAREN_ sortItem (COMMA_ sortItem)* RPAREN_ | sortItem))? + : tableArgumentRelation ( + PARTITION_ BY_ (LPAREN_ (expression (COMMA_ expression)*)? RPAREN_ | expression) + )? (PRUNE_ WHEN_ EMPTY_ | KEEP_ WHEN_ EMPTY_)? ( + ORDER_ BY_ (LPAREN_ sortItem (COMMA_ sortItem)* RPAREN_ | sortItem) + )? ; tableArgumentRelation - : TABLE_ LPAREN_ qualifiedName RPAREN_ (AS_? identifier columnAliases?)? #tableArgumentTable - | TABLE_ LPAREN_ query RPAREN_ (AS_? identifier columnAliases?)? #tableArgumentQuery + : TABLE_ LPAREN_ qualifiedName RPAREN_ (AS_? identifier columnAliases?)? # tableArgumentTable + | TABLE_ LPAREN_ query RPAREN_ (AS_? identifier columnAliases?)? # tableArgumentQuery ; descriptorArgument @@ -462,119 +432,105 @@ expression ; booleanExpression - : valueExpression predicate_? #predicated - | NOT_ booleanExpression #logicalNot - | booleanExpression AND_ booleanExpression #and - | booleanExpression OR_ booleanExpression #or + : valueExpression predicate_? # predicated + | NOT_ booleanExpression # logicalNot + | booleanExpression AND_ booleanExpression # and + | booleanExpression OR_ booleanExpression # or ; // workaround for https://github.com/antlr/antlr4/issues/780 predicate_ - : comparisonOperator right=valueExpression #comparison - | comparisonOperator comparisonQuantifier LPAREN_ query RPAREN_ #quantifiedComparison - | NOT_? BETWEEN_ lower=valueExpression AND_ upper=valueExpression #between - | NOT_? IN_ LPAREN_ expression (COMMA_ expression)* RPAREN_ #inList - | NOT_? IN_ LPAREN_ query RPAREN_ #inSubquery - | NOT_? LIKE_ pattern=valueExpression (ESCAPE_ escape=valueExpression)? #like - | IS_ NOT_? NULL_ #nullPredicate - | IS_ NOT_? DISTINCT_ FROM_ right=valueExpression #distinctFrom + : comparisonOperator right = valueExpression # comparison + | comparisonOperator comparisonQuantifier LPAREN_ query RPAREN_ # quantifiedComparison + | NOT_? BETWEEN_ lower = valueExpression AND_ upper = valueExpression # between + | NOT_? IN_ LPAREN_ expression (COMMA_ expression)* RPAREN_ # inList + | NOT_? IN_ LPAREN_ query RPAREN_ # inSubquery + | NOT_? LIKE_ pattern = valueExpression (ESCAPE_ escape = valueExpression)? # like + | IS_ NOT_? NULL_ # nullPredicate + | IS_ NOT_? DISTINCT_ FROM_ right = valueExpression # distinctFrom ; valueExpression - : primaryExpression #valueExpressionDefault - | valueExpression AT_ timeZoneSpecifier #atTimeZone - | operator=(MINUS_ | PLUS_) valueExpression #arithmeticUnary - | left=valueExpression operator=(ASTERISK_ | SLASH_ | PERCENT_) right=valueExpression #arithmeticBinary - | left=valueExpression operator=(PLUS_ | MINUS_) right=valueExpression #arithmeticBinary - | left=valueExpression CONCAT_ right=valueExpression #concatenation + : primaryExpression # valueExpressionDefault + | valueExpression AT_ timeZoneSpecifier # atTimeZone + | operator = (MINUS_ | PLUS_) valueExpression # arithmeticUnary + | left = valueExpression operator = (ASTERISK_ | SLASH_ | PERCENT_) right = valueExpression # arithmeticBinary + | left = valueExpression operator = (PLUS_ | MINUS_) right = valueExpression # arithmeticBinary + | left = valueExpression CONCAT_ right = valueExpression # concatenation ; primaryExpression - : NULL_ #nullLiteral - | interval #intervalLiteral - | identifier string_ #typeConstructor - | DOUBLE_ PRECISION_ string_ #typeConstructor - | number #numericLiteral - | booleanValue #booleanLiteral - | string_ #stringLiteral - | BINARY_LITERAL_ #binaryLiteral - | QUESTION_MARK_ #parameter - | POSITION_ LPAREN_ valueExpression IN_ valueExpression RPAREN_ #position - | LPAREN_ expression (COMMA_ expression)+ RPAREN_ #rowConstructor - | ROW_ LPAREN_ expression (COMMA_ expression)* RPAREN_ #rowConstructor - | name=LISTAGG_ LPAREN_ setQuantifier? expression (COMMA_ string_)? - (ON_ OVERFLOW_ listAggOverflowBehavior)? RPAREN_ - (WITHIN_ GROUP_ LPAREN_ ORDER_ BY_ sortItem (COMMA_ sortItem)* RPAREN_) #listagg - | processingMode? qualifiedName LPAREN_ (label=identifier DOT_)? ASTERISK_ RPAREN_ - filter? over? #functionCall - | processingMode? qualifiedName LPAREN_ (setQuantifier? expression (COMMA_ expression)*)? - (ORDER_ BY_ sortItem (COMMA_ sortItem)*)? RPAREN_ filter? (nullTreatment? over)? #functionCall - | identifier over #measure - | identifier RARROW_ expression #lambda - | LPAREN_ (identifier (COMMA_ identifier)*)? RPAREN_ RARROW_ expression #lambda - | LPAREN_ query RPAREN_ #subqueryExpression + : NULL_ # nullLiteral + | interval # intervalLiteral + | identifier string_ # typeConstructor + | DOUBLE_ PRECISION_ string_ # typeConstructor + | number # numericLiteral + | booleanValue # booleanLiteral + | string_ # stringLiteral + | BINARY_LITERAL_ # binaryLiteral + | QUESTION_MARK_ # parameter + | POSITION_ LPAREN_ valueExpression IN_ valueExpression RPAREN_ # position + | LPAREN_ expression (COMMA_ expression)+ RPAREN_ # rowConstructor + | ROW_ LPAREN_ expression (COMMA_ expression)* RPAREN_ # rowConstructor + | name = LISTAGG_ LPAREN_ setQuantifier? expression (COMMA_ string_)? ( + ON_ OVERFLOW_ listAggOverflowBehavior + )? RPAREN_ (WITHIN_ GROUP_ LPAREN_ ORDER_ BY_ sortItem (COMMA_ sortItem)* RPAREN_) # listagg + | processingMode? qualifiedName LPAREN_ (label = identifier DOT_)? ASTERISK_ RPAREN_ filter? over? # functionCall + | processingMode? qualifiedName LPAREN_ (setQuantifier? expression (COMMA_ expression)*)? ( + ORDER_ BY_ sortItem (COMMA_ sortItem)* + )? RPAREN_ filter? (nullTreatment? over)? # functionCall + | identifier over # measure + | identifier RARROW_ expression # lambda + | LPAREN_ (identifier (COMMA_ identifier)*)? RPAREN_ RARROW_ expression # lambda + | LPAREN_ query RPAREN_ # subqueryExpression // This is an extension to ANSI_ SQL, which considers EXISTS_ to be a - | EXISTS_ LPAREN_ query RPAREN_ #exists - | CASE_ operand=expression whenClause+ (ELSE_ elseExpression=expression)? END_ #simpleCase - | CASE_ whenClause+ (ELSE_ elseExpression=expression)? END_ #searchedCase - | CAST_ LPAREN_ expression AS_ type RPAREN_ #cast - | TRY_CAST_ LPAREN_ expression AS_ type RPAREN_ #cast - | ARRAY_ LSQUARE_ (expression (COMMA_ expression)*)? RSQUARE_ #arrayConstructor - | value=primaryExpression LSQUARE_ index=valueExpression RSQUARE_ #subscript - | identifier #columnReference - | base_=primaryExpression DOT_ fieldName=identifier #dereference - | name=CURRENT_DATE_ #specialDateTimeFunction - | name=CURRENT_TIME_ (LPAREN_ precision=INTEGER_VALUE_ RPAREN_)? #specialDateTimeFunction - | name=CURRENT_TIMESTAMP_ (LPAREN_ precision=INTEGER_VALUE_ RPAREN_)? #specialDateTimeFunction - | name=LOCALTIME_ (LPAREN_ precision=INTEGER_VALUE_ RPAREN_)? #specialDateTimeFunction - | name=LOCALTIMESTAMP_ (LPAREN_ precision=INTEGER_VALUE_ RPAREN_)? #specialDateTimeFunction - | name=CURRENT_USER_ #currentUser - | name=CURRENT_CATALOG_ #currentCatalog - | name=CURRENT_SCHEMA_ #currentSchema - | name=CURRENT_PATH_ #currentPath - | TRIM_ LPAREN_ (trimsSpecification? trimChar=valueExpression? FROM_)? - trimSource=valueExpression RPAREN_ #trim - | TRIM_ LPAREN_ trimSource=valueExpression COMMA_ trimChar=valueExpression RPAREN_ #trim - | SUBSTRING_ LPAREN_ valueExpression FROM_ valueExpression (FOR_ valueExpression)? RPAREN_ #substring - | NORMALIZE_ LPAREN_ valueExpression (COMMA_ normalForm)? RPAREN_ #normalize - | EXTRACT_ LPAREN_ identifier FROM_ valueExpression RPAREN_ #extract - | LPAREN_ expression RPAREN_ #parenthesizedExpression - | GROUPING_ LPAREN_ (qualifiedName (COMMA_ qualifiedName)*)? RPAREN_ #groupingOperation - | JSON_EXISTS_ LPAREN_ jsonPathInvocation (jsonExistsErrorBehavior ON_ ERROR_)? RPAREN_ #jsonExists - | JSON_VALUE_ LPAREN_ - jsonPathInvocation - (RETURNING_ type)? - (emptyBehavior=jsonValueBehavior ON_ EMPTY_)? - (errorBehavior=jsonValueBehavior ON_ ERROR_)? - RPAREN_ #jsonValue - | JSON_QUERY_ LPAREN_ - jsonPathInvocation - (RETURNING_ type (FORMAT_ jsonRepresentation)?)? - (jsonQueryWrapperBehavior WRAPPER_)? - ((KEEP_ | OMIT_) QUOTES_ (ON_ SCALAR_ TEXT_STRING_)?)? - (emptyBehavior=jsonQueryBehavior ON_ EMPTY_)? - (errorBehavior=jsonQueryBehavior ON_ ERROR_)? - RPAREN_ #jsonQuery - | JSON_OBJECT_ LPAREN_ - ( - jsonObjectMember (COMMA_ jsonObjectMember)* - (NULL_ ON_ NULL_ | ABSENT_ ON_ NULL_)? - (WITH_ UNIQUE_ KEYS_? | WITHOUT_ UNIQUE_ KEYS_?)? + | EXISTS_ LPAREN_ query RPAREN_ # exists + | CASE_ operand = expression whenClause+ (ELSE_ elseExpression = expression)? END_ # simpleCase + | CASE_ whenClause+ (ELSE_ elseExpression = expression)? END_ # searchedCase + | CAST_ LPAREN_ expression AS_ type RPAREN_ # cast + | TRY_CAST_ LPAREN_ expression AS_ type RPAREN_ # cast + | ARRAY_ LSQUARE_ (expression (COMMA_ expression)*)? RSQUARE_ # arrayConstructor + | value = primaryExpression LSQUARE_ index = valueExpression RSQUARE_ # subscript + | identifier # columnReference + | base_ = primaryExpression DOT_ fieldName = identifier # dereference + | name = CURRENT_DATE_ # specialDateTimeFunction + | name = CURRENT_TIME_ (LPAREN_ precision = INTEGER_VALUE_ RPAREN_)? # specialDateTimeFunction + | name = CURRENT_TIMESTAMP_ (LPAREN_ precision = INTEGER_VALUE_ RPAREN_)? # specialDateTimeFunction + | name = LOCALTIME_ (LPAREN_ precision = INTEGER_VALUE_ RPAREN_)? # specialDateTimeFunction + | name = LOCALTIMESTAMP_ (LPAREN_ precision = INTEGER_VALUE_ RPAREN_)? # specialDateTimeFunction + | name = CURRENT_USER_ # currentUser + | name = CURRENT_CATALOG_ # currentCatalog + | name = CURRENT_SCHEMA_ # currentSchema + | name = CURRENT_PATH_ # currentPath + | TRIM_ LPAREN_ (trimsSpecification? trimChar = valueExpression? FROM_)? trimSource = valueExpression RPAREN_ # trim + | TRIM_ LPAREN_ trimSource = valueExpression COMMA_ trimChar = valueExpression RPAREN_ # trim + | SUBSTRING_ LPAREN_ valueExpression FROM_ valueExpression (FOR_ valueExpression)? RPAREN_ # substring + | NORMALIZE_ LPAREN_ valueExpression (COMMA_ normalForm)? RPAREN_ # normalize + | EXTRACT_ LPAREN_ identifier FROM_ valueExpression RPAREN_ # extract + | LPAREN_ expression RPAREN_ # parenthesizedExpression + | GROUPING_ LPAREN_ (qualifiedName (COMMA_ qualifiedName)*)? RPAREN_ # groupingOperation + | JSON_EXISTS_ LPAREN_ jsonPathInvocation (jsonExistsErrorBehavior ON_ ERROR_)? RPAREN_ # jsonExists + | JSON_VALUE_ LPAREN_ jsonPathInvocation (RETURNING_ type)? ( + emptyBehavior = jsonValueBehavior ON_ EMPTY_ + )? (errorBehavior = jsonValueBehavior ON_ ERROR_)? RPAREN_ # jsonValue + | JSON_QUERY_ LPAREN_ jsonPathInvocation (RETURNING_ type (FORMAT_ jsonRepresentation)?)? ( + jsonQueryWrapperBehavior WRAPPER_ + )? ((KEEP_ | OMIT_) QUOTES_ (ON_ SCALAR_ TEXT_STRING_)?)? ( + emptyBehavior = jsonQueryBehavior ON_ EMPTY_ + )? (errorBehavior = jsonQueryBehavior ON_ ERROR_)? RPAREN_ # jsonQuery + | JSON_OBJECT_ LPAREN_ ( + jsonObjectMember (COMMA_ jsonObjectMember)* (NULL_ ON_ NULL_ | ABSENT_ ON_ NULL_)? ( + WITH_ UNIQUE_ KEYS_? + | WITHOUT_ UNIQUE_ KEYS_? )? - (RETURNING_ type (FORMAT_ jsonRepresentation)?)? - RPAREN_ #jsonObject - | JSON_ARRAY_ LPAREN_ - ( - jsonValueExpression (COMMA_ jsonValueExpression)* - (NULL_ ON_ NULL_ | ABSENT_ ON_ NULL_)? - )? - (RETURNING_ type (FORMAT_ jsonRepresentation)?)? - RPAREN_ #jsonArray + )? (RETURNING_ type (FORMAT_ jsonRepresentation)?)? RPAREN_ # jsonObject + | JSON_ARRAY_ LPAREN_ ( + jsonValueExpression (COMMA_ jsonValueExpression)* (NULL_ ON_ NULL_ | ABSENT_ ON_ NULL_)? + )? (RETURNING_ type (FORMAT_ jsonRepresentation)?)? RPAREN_ # jsonArray ; jsonPathInvocation - : jsonValueExpression COMMA_ path=string_ - (PASSING_ jsonArgument (COMMA_ jsonArgument)*)? + : jsonValueExpression COMMA_ path = string_ (PASSING_ jsonArgument (COMMA_ jsonArgument)*)? ; jsonValueExpression @@ -630,51 +586,67 @@ nullTreatment // renamed from "string" to avoid golang name conflict string_ - : STRING_ #basicStringLiteral - | UNICODE_STRING_ (UESCAPE_ STRING_)? #unicodeStringLiteral + : STRING_ # basicStringLiteral + | UNICODE_STRING_ (UESCAPE_ STRING_)? # unicodeStringLiteral ; timeZoneSpecifier - : TIME_ ZONE_ interval #timeZoneInterval - | TIME_ ZONE_ string_ #timeZoneString + : TIME_ ZONE_ interval # timeZoneInterval + | TIME_ ZONE_ string_ # timeZoneString ; comparisonOperator - : EQ_ | NEQ_ | LT_ | LTE_ | GT_ | GTE_ + : EQ_ + | NEQ_ + | LT_ + | LTE_ + | GT_ + | GTE_ ; comparisonQuantifier - : ALL_ | SOME_ | ANY_ + : ALL_ + | SOME_ + | ANY_ ; booleanValue - : TRUE_ | FALSE_ + : TRUE_ + | FALSE_ ; interval - : INTERVAL_ sign=(PLUS_ | MINUS_)? string_ from=intervalField (TO_ to=intervalField)? + : INTERVAL_ sign = (PLUS_ | MINUS_)? string_ from = intervalField (TO_ to = intervalField)? ; intervalField - : YEAR_ | MONTH_ | DAY_ | HOUR_ | MINUTE_ | SECOND_ + : YEAR_ + | MONTH_ + | DAY_ + | HOUR_ + | MINUTE_ + | SECOND_ ; normalForm - : NFD_ | NFC_ | NFKD_ | NFKC_ + : NFD_ + | NFC_ + | NFKD_ + | NFKC_ ; type - : ROW_ LPAREN_ rowField (COMMA_ rowField)* RPAREN_ #rowType - | INTERVAL_ from=intervalField (TO_ to=intervalField)? #intervalType - | base=TIMESTAMP_ (LPAREN_ precision = typeParameter RPAREN_)? (WITHOUT_ TIME_ ZONE_)? #dateTimeType - | base=TIMESTAMP_ (LPAREN_ precision = typeParameter RPAREN_)? WITH_ TIME_ ZONE_ #dateTimeType - | base=TIME_ (LPAREN_ precision = typeParameter RPAREN_)? (WITHOUT_ TIME_ ZONE_)? #dateTimeType - | base=TIME_ (LPAREN_ precision = typeParameter RPAREN_)? WITH_ TIME_ ZONE_ #dateTimeType - | DOUBLE_ PRECISION_ #doublePrecisionType - | ARRAY_ LT_ type GT_ #legacyArrayType - | MAP_ LT_ keyType=type COMMA_ valueType=type GT_ #legacyMapType - | type ARRAY_ (LSQUARE_ INTEGER_VALUE_ RSQUARE_)? #arrayType - | identifier (LPAREN_ typeParameter (COMMA_ typeParameter)* RPAREN_)? #genericType + : ROW_ LPAREN_ rowField (COMMA_ rowField)* RPAREN_ # rowType + | INTERVAL_ from = intervalField (TO_ to = intervalField)? # intervalType + | base = TIMESTAMP_ (LPAREN_ precision = typeParameter RPAREN_)? (WITHOUT_ TIME_ ZONE_)? # dateTimeType + | base = TIMESTAMP_ (LPAREN_ precision = typeParameter RPAREN_)? WITH_ TIME_ ZONE_ # dateTimeType + | base = TIME_ (LPAREN_ precision = typeParameter RPAREN_)? (WITHOUT_ TIME_ ZONE_)? # dateTimeType + | base = TIME_ (LPAREN_ precision = typeParameter RPAREN_)? WITH_ TIME_ ZONE_ # dateTimeType + | DOUBLE_ PRECISION_ # doublePrecisionType + | ARRAY_ LT_ type GT_ # legacyArrayType + | MAP_ LT_ keyType = type COMMA_ valueType = type GT_ # legacyMapType + | type ARRAY_ (LSQUARE_ INTEGER_VALUE_ RSQUARE_)? # arrayType + | identifier (LPAREN_ typeParameter (COMMA_ typeParameter)* RPAREN_)? # genericType ; rowField @@ -683,11 +655,12 @@ rowField ; typeParameter - : INTEGER_VALUE_ | type + : INTEGER_VALUE_ + | type ; whenClause - : WHEN_ condition=expression THEN_ result=expression + : WHEN_ condition = expression THEN_ result = expression ; filter @@ -695,68 +668,69 @@ filter ; mergeCase - : WHEN_ MATCHED_ (AND_ condition=expression)? THEN_ - UPDATE_ SET_ targets+=identifier EQ_ values+=expression - (COMMA_ targets+=identifier EQ_ values+=expression)* #mergeUpdate - | WHEN_ MATCHED_ (AND_ condition=expression)? THEN_ DELETE_ #mergeDelete - | WHEN_ NOT_ MATCHED_ (AND_ condition=expression)? THEN_ - INSERT_ (LPAREN_ targets+=identifier (COMMA_ targets+=identifier)* RPAREN_)? - VALUES_ LPAREN_ values+=expression (COMMA_ values+=expression)* RPAREN_ #mergeInsert + : WHEN_ MATCHED_ (AND_ condition = expression)? THEN_ UPDATE_ SET_ targets += identifier EQ_ values += expression ( + COMMA_ targets += identifier EQ_ values += expression + )* # mergeUpdate + | WHEN_ MATCHED_ (AND_ condition = expression)? THEN_ DELETE_ # mergeDelete + | WHEN_ NOT_ MATCHED_ (AND_ condition = expression)? THEN_ INSERT_ ( + LPAREN_ targets += identifier (COMMA_ targets += identifier)* RPAREN_ + )? VALUES_ LPAREN_ values += expression (COMMA_ values += expression)* RPAREN_ # mergeInsert ; over - : OVER_ (windowName=identifier | LPAREN_ windowSpecification RPAREN_) + : OVER_ (windowName = identifier | LPAREN_ windowSpecification RPAREN_) ; windowFrame - : (MEASURES_ measureDefinition (COMMA_ measureDefinition)*)? - frameExtent - (AFTER_ MATCH_ skipTo)? - (INITIAL_ | SEEK_)? - (PATTERN_ LPAREN_ rowPattern RPAREN_)? - (SUBSET_ subsetDefinition (COMMA_ subsetDefinition)*)? - (DEFINE_ variableDefinition (COMMA_ variableDefinition)*)? + : (MEASURES_ measureDefinition (COMMA_ measureDefinition)*)? frameExtent (AFTER_ MATCH_ skipTo)? ( + INITIAL_ + | SEEK_ + )? (PATTERN_ LPAREN_ rowPattern RPAREN_)? (SUBSET_ subsetDefinition (COMMA_ subsetDefinition)*)? ( + DEFINE_ variableDefinition (COMMA_ variableDefinition)* + )? ; // renamed start and stop to avoid Dart name conflict frameExtent - : frameType=RANGE_ start_=frameBound - | frameType=ROWS_ start_=frameBound - | frameType=GROUPS_ start_=frameBound - | frameType=RANGE_ BETWEEN_ start_=frameBound AND_ end_=frameBound - | frameType=ROWS_ BETWEEN_ start_=frameBound AND_ end_=frameBound - | frameType=GROUPS_ BETWEEN_ start_=frameBound AND_ end_=frameBound + : frameType = RANGE_ start_ = frameBound + | frameType = ROWS_ start_ = frameBound + | frameType = GROUPS_ start_ = frameBound + | frameType = RANGE_ BETWEEN_ start_ = frameBound AND_ end_ = frameBound + | frameType = ROWS_ BETWEEN_ start_ = frameBound AND_ end_ = frameBound + | frameType = GROUPS_ BETWEEN_ start_ = frameBound AND_ end_ = frameBound ; frameBound - : UNBOUNDED_ boundType=PRECEDING_ #unboundedFrame - | UNBOUNDED_ boundType=FOLLOWING_ #unboundedFrame - | CURRENT_ ROW_ #currentRowBound - | expression boundType=(PRECEDING_ | FOLLOWING_) #boundedFrame + : UNBOUNDED_ boundType = PRECEDING_ # unboundedFrame + | UNBOUNDED_ boundType = FOLLOWING_ # unboundedFrame + | CURRENT_ ROW_ # currentRowBound + | expression boundType = (PRECEDING_ | FOLLOWING_) # boundedFrame ; rowPattern - : patternPrimary patternQuantifier? #quantifiedPrimary - | rowPattern rowPattern #patternConcatenation - | rowPattern VBAR_ rowPattern #patternAlternation + : patternPrimary patternQuantifier? # quantifiedPrimary + | rowPattern rowPattern # patternConcatenation + | rowPattern VBAR_ rowPattern # patternAlternation ; patternPrimary - : identifier #patternVariable - | LPAREN_ RPAREN_ #emptyPattern - | PERMUTE_ LPAREN_ rowPattern (COMMA_ rowPattern)* RPAREN_ #patternPermutation - | LPAREN_ rowPattern RPAREN_ #groupedPattern - | CARET_ #partitionStartAnchor - | DOLLAR_ #partitionEndAnchor - | LCURLYHYPHEN_ rowPattern RCURLYHYPHEN_ #excludedPattern + : identifier # patternVariable + | LPAREN_ RPAREN_ # emptyPattern + | PERMUTE_ LPAREN_ rowPattern (COMMA_ rowPattern)* RPAREN_ # patternPermutation + | LPAREN_ rowPattern RPAREN_ # groupedPattern + | CARET_ # partitionStartAnchor + | DOLLAR_ # partitionEndAnchor + | LCURLYHYPHEN_ rowPattern RCURLYHYPHEN_ # excludedPattern ; patternQuantifier - : ASTERISK_ (reluctant=QUESTION_MARK_)? #zeroOrMoreQuantifier - | PLUS_ (reluctant=QUESTION_MARK_)? #oneOrMoreQuantifier - | QUESTION_MARK_ (reluctant=QUESTION_MARK_)? #zeroOrOneQuantifier - | LCURLY_ exactly=INTEGER_VALUE_ RCURLY_ (reluctant=QUESTION_MARK_)? #rangeQuantifier - | LCURLY_ (atLeast=INTEGER_VALUE_)? COMMA_ (atMost=INTEGER_VALUE_)? RCURLY_ (reluctant=QUESTION_MARK_)? #rangeQuantifier + : ASTERISK_ (reluctant = QUESTION_MARK_)? # zeroOrMoreQuantifier + | PLUS_ (reluctant = QUESTION_MARK_)? # oneOrMoreQuantifier + | QUESTION_MARK_ (reluctant = QUESTION_MARK_)? # zeroOrOneQuantifier + | LCURLY_ exactly = INTEGER_VALUE_ RCURLY_ (reluctant = QUESTION_MARK_)? # rangeQuantifier + | LCURLY_ (atLeast = INTEGER_VALUE_)? COMMA_ (atMost = INTEGER_VALUE_)? RCURLY_ ( + reluctant = QUESTION_MARK_ + )? # rangeQuantifier ; updateAssignment @@ -764,30 +738,30 @@ updateAssignment ; explainOption - : FORMAT_ value=(TEXT_ | GRAPHVIZ_ | JSON_) #explainFormat - | TYPE_ value=(LOGICAL_ | DISTRIBUTED_ | VALIDATE_ | IO_) #explainType + : FORMAT_ value = (TEXT_ | GRAPHVIZ_ | JSON_) # explainFormat + | TYPE_ value = (LOGICAL_ | DISTRIBUTED_ | VALIDATE_ | IO_) # explainType ; transactionMode - : ISOLATION_ LEVEL_ levelOfIsolation #isolationLevel - | READ_ accessMode=(ONLY_ | WRITE_) #transactionAccessMode + : ISOLATION_ LEVEL_ levelOfIsolation # isolationLevel + | READ_ accessMode = (ONLY_ | WRITE_) # transactionAccessMode ; levelOfIsolation - : READ_ UNCOMMITTED_ #readUncommitted - | READ_ COMMITTED_ #readCommitted - | REPEATABLE_ READ_ #repeatableRead - | SERIALIZABLE_ #serializable + : READ_ UNCOMMITTED_ # readUncommitted + | READ_ COMMITTED_ # readCommitted + | REPEATABLE_ READ_ # repeatableRead + | SERIALIZABLE_ # serializable ; callArgument - : expression #positionalArgument - | identifier RDOUBLEARROW_ expression #namedArgument + : expression # positionalArgument + | identifier RDOUBLEARROW_ expression # namedArgument ; pathElement - : identifier DOT_ identifier #qualifiedArgument - | identifier #unqualifiedArgument + : identifier DOT_ identifier # qualifiedArgument + | identifier # unqualifiedArgument ; pathSpecification @@ -795,7 +769,11 @@ pathSpecification ; privilege - : CREATE_ | SELECT_ | DELETE_ | INSERT_ | UPDATE_ + : CREATE_ + | SELECT_ + | DELETE_ + | INSERT_ + | UPDATE_ ; qualifiedName @@ -803,7 +781,7 @@ qualifiedName ; queryPeriod - : FOR_ rangeType AS_ OF_ end=valueExpression + : FOR_ rangeType AS_ OF_ end = valueExpression ; rangeType @@ -812,15 +790,15 @@ rangeType ; grantor - : principal #specifiedPrincipal - | CURRENT_USER_ #currentUserGrantor - | CURRENT_ROLE_ #currentRoleGrantor + : principal # specifiedPrincipal + | CURRENT_USER_ # currentUserGrantor + | CURRENT_ROLE_ # currentRoleGrantor ; principal - : identifier #unspecifiedPrincipal - | USER_ identifier #userPrincipal - | ROLE_ identifier #rolePrincipal + : identifier # unspecifiedPrincipal + | USER_ identifier # userPrincipal + | ROLE_ identifier # rolePrincipal ; roles @@ -828,45 +806,212 @@ roles ; identifier - : IDENTIFIER_ #unquotedIdentifier - | QUOTED_IDENTIFIER_ #quotedIdentifier - | nonReserved #unquotedIdentifier - | BACKQUOTED_IDENTIFIER_ #backQuotedIdentifier - | DIGIT_IDENTIFIER_ #digitIdentifier + : IDENTIFIER_ # unquotedIdentifier + | QUOTED_IDENTIFIER_ # quotedIdentifier + | nonReserved # unquotedIdentifier + | BACKQUOTED_IDENTIFIER_ # backQuotedIdentifier + | DIGIT_IDENTIFIER_ # digitIdentifier ; number - : MINUS_? DECIMAL_VALUE_ #decimalLiteral - | MINUS_? DOUBLE_VALUE_ #doubleLiteral - | MINUS_? INTEGER_VALUE_ #integerLiteral + : MINUS_? DECIMAL_VALUE_ # decimalLiteral + | MINUS_? DOUBLE_VALUE_ # doubleLiteral + | MINUS_? INTEGER_VALUE_ # integerLiteral ; nonReserved - // IMPORTANT: this rule must only contain tokens. Nested rules are not supported. See SqlParser.exitNonReserved - : ABSENT_ | ADD_ | ADMIN_ | AFTER_ | ALL_ | ANALYZE_ | ANY_ | ARRAY_ | ASC_ | AT_ | AUTHORIZATION_ - | BERNOULLI_ | BOTH_ - | CALL_ | CASCADE_ | CATALOGS_ | COLUMN_ | COLUMNS_ | COMMENT_ | COMMIT_ | COMMITTED_ | CONDITIONAL_ | COPARTITION_ | COUNT_ | CURRENT_ - | DATA_ | DATE_ | DAY_ | DEFAULT_ | DEFINE_ | DEFINER_ | DESC_ | DESCRIPTOR_ | DISTRIBUTED_ | DOUBLE_ - | EMPTY_ | ENCODING_ | ERROR_ | EXCLUDING_ | EXPLAIN_ - | FETCH_ | FILTER_ | FINAL_ | FIRST_ | FOLLOWING_ | FORMAT_ | FUNCTIONS_ - | GRACE_ | GRANT_ | DENY_ | GRANTED_ | GRANTS_ | GRAPHVIZ_ | GROUPS_ +// IMPORTANT: this rule must only contain tokens. Nested rules are not supported. See SqlParser.exitNonReserved + : ABSENT_ + | ADD_ + | ADMIN_ + | AFTER_ + | ALL_ + | ANALYZE_ + | ANY_ + | ARRAY_ + | ASC_ + | AT_ + | AUTHORIZATION_ + | BERNOULLI_ + | BOTH_ + | CALL_ + | CASCADE_ + | CATALOGS_ + | COLUMN_ + | COLUMNS_ + | COMMENT_ + | COMMIT_ + | COMMITTED_ + | CONDITIONAL_ + | COPARTITION_ + | COUNT_ + | CURRENT_ + | DATA_ + | DATE_ + | DAY_ + | DEFAULT_ + | DEFINE_ + | DEFINER_ + | DESC_ + | DESCRIPTOR_ + | DISTRIBUTED_ + | DOUBLE_ + | EMPTY_ + | ENCODING_ + | ERROR_ + | EXCLUDING_ + | EXPLAIN_ + | FETCH_ + | FILTER_ + | FINAL_ + | FIRST_ + | FOLLOWING_ + | FORMAT_ + | FUNCTIONS_ + | GRACE_ + | GRANT_ + | DENY_ + | GRANTED_ + | GRANTS_ + | GRAPHVIZ_ + | GROUPS_ | HOUR_ - | IF_ | IGNORE_ | INCLUDING_ | INITIAL_ | INPUT_ | INTERVAL_ | INVOKER_ | IO_ | ISOLATION_ + | IF_ + | IGNORE_ + | INCLUDING_ + | INITIAL_ + | INPUT_ + | INTERVAL_ + | INVOKER_ + | IO_ + | ISOLATION_ | JSON_ - | KEEP_ | KEY_ | KEYS_ - | LAST_ | LATERAL_ | LEADING_ | LEVEL_ | LIMIT_ | LOCAL_ | LOGICAL_ - | MAP_ | MATCH_ | MATCHED_ | MATCHES_ | MATCH_RECOGNIZE_ | MATERIALIZED_ | MEASURES_ | MERGE_ | MINUTE_ | MONTH_ - | NEXT_ | NFC_ | NFD_ | NFKC_ | NFKD_ | NO_ | NONE_ | NULLIF_ | NULLS_ - | OBJECT_ | OF_ | OFFSET_ | OMIT_ | ONE_ | ONLY_ | OPTION_ | ORDINALITY_ | OUTPUT_ | OVER_ | OVERFLOW_ - | PARTITION_ | PARTITIONS_ | PASSING_ | PAST_ | PATH_ | PATTERN_ | PER_ | PERIOD_ | PERMUTE_ | POSITION_ | PRECEDING_ | PRECISION_ | PRIVILEGES_ | PROPERTIES_ | PRUNE_ + | KEEP_ + | KEY_ + | KEYS_ + | LAST_ + | LATERAL_ + | LEADING_ + | LEVEL_ + | LIMIT_ + | LOCAL_ + | LOGICAL_ + | MAP_ + | MATCH_ + | MATCHED_ + | MATCHES_ + | MATCH_RECOGNIZE_ + | MATERIALIZED_ + | MEASURES_ + | MERGE_ + | MINUTE_ + | MONTH_ + | NEXT_ + | NFC_ + | NFD_ + | NFKC_ + | NFKD_ + | NO_ + | NONE_ + | NULLIF_ + | NULLS_ + | OBJECT_ + | OF_ + | OFFSET_ + | OMIT_ + | ONE_ + | ONLY_ + | OPTION_ + | ORDINALITY_ + | OUTPUT_ + | OVER_ + | OVERFLOW_ + | PARTITION_ + | PARTITIONS_ + | PASSING_ + | PAST_ + | PATH_ + | PATTERN_ + | PER_ + | PERIOD_ + | PERMUTE_ + | POSITION_ + | PRECEDING_ + | PRECISION_ + | PRIVILEGES_ + | PROPERTIES_ + | PRUNE_ | QUOTES_ - | RANGE_ | READ_ | REFRESH_ | RENAME_ | REPEATABLE_ | REPLACE_ | RESET_ | RESPECT_ | RESTRICT_ | RETURNING_ | REVOKE_ | ROLE_ | ROLES_ | ROLLBACK_ | ROW_ | ROWS_ | RUNNING_ - | SCALAR_ | SCHEMA_ | SCHEMAS_ | SECOND_ | SECURITY_ | SEEK_ | SERIALIZABLE_ | SESSION_ | SET_ | SETS_ - | SHOW_ | SOME_ | START_ | STATS_ | SUBSET_ | SUBSTRING_ | SYSTEM_ - | TABLES_ | TABLESAMPLE_ | TEXT_ | TEXT_STRING_ | TIES_ | TIME_ | TIMESTAMP_ | TO_ | TRAILING_ | TRANSACTION_ | TRUNCATE_ | TRY_CAST_ | TYPE_ - | UNBOUNDED_ | UNCOMMITTED_ | UNCONDITIONAL_ | UNIQUE_ | UNKNOWN_ | UNMATCHED_ | UPDATE_ | USE_ | USER_ | UTF16_ | UTF32_ | UTF8_ - | VALIDATE_ | VALUE_ | VERBOSE_ | VERSION_ | VIEW_ - | WINDOW_ | WITHIN_ | WITHOUT_ | WORK_ | WRAPPER_ | WRITE_ + | RANGE_ + | READ_ + | REFRESH_ + | RENAME_ + | REPEATABLE_ + | REPLACE_ + | RESET_ + | RESPECT_ + | RESTRICT_ + | RETURNING_ + | REVOKE_ + | ROLE_ + | ROLES_ + | ROLLBACK_ + | ROW_ + | ROWS_ + | RUNNING_ + | SCALAR_ + | SCHEMA_ + | SCHEMAS_ + | SECOND_ + | SECURITY_ + | SEEK_ + | SERIALIZABLE_ + | SESSION_ + | SET_ + | SETS_ + | SHOW_ + | SOME_ + | START_ + | STATS_ + | SUBSET_ + | SUBSTRING_ + | SYSTEM_ + | TABLES_ + | TABLESAMPLE_ + | TEXT_ + | TEXT_STRING_ + | TIES_ + | TIME_ + | TIMESTAMP_ + | TO_ + | TRAILING_ + | TRANSACTION_ + | TRUNCATE_ + | TRY_CAST_ + | TYPE_ + | UNBOUNDED_ + | UNCOMMITTED_ + | UNCONDITIONAL_ + | UNIQUE_ + | UNKNOWN_ + | UNMATCHED_ + | UPDATE_ + | USE_ + | USER_ + | UTF16_ + | UTF32_ + | UTF8_ + | VALIDATE_ + | VALUE_ + | VERBOSE_ + | VERSION_ + | VIEW_ + | WINDOW_ + | WITHIN_ + | WITHOUT_ + | WORK_ + | WRAPPER_ + | WRITE_ | YEAR_ | ZONE_ - ; + ; \ No newline at end of file diff --git a/sql/tsql/TSqlLexer.g4 b/sql/tsql/TSqlLexer.g4 index 8341eaf6cb..2cfcbd8162 100644 --- a/sql/tsql/TSqlLexer.g4 +++ b/sql/tsql/TSqlLexer.g4 @@ -23,1264 +23,1270 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar TSqlLexer; // Basic keywords (from https://msdn.microsoft.com/en-us/library/ms189822.aspx) -options { caseInsensitive = true; } - +options { + caseInsensitive = true; +} //Keywords that can exist in ID etc //More keywords that can also be used as IDs -ABORT: 'ABORT'; -ABORT_AFTER_WAIT: 'ABORT_AFTER_WAIT'; -ABSENT: 'ABSENT'; -ABSOLUTE: 'ABSOLUTE'; -ACCELERATED_DATABASE_RECOVERY: 'ACCELERATED_DATABASE_RECOVERY'; -ACCENT_SENSITIVITY: 'ACCENT_SENSITIVITY'; -ACCESS: 'ACCESS'; -ACTION: 'ACTION'; -ACTIVATION: 'ACTIVATION'; -ACTIVE: 'ACTIVE'; -ADD: 'ADD'; -ADDRESS: 'ADDRESS'; -ADMINISTER: 'ADMINISTER'; -AES: 'AES'; -AES_128: 'AES_128'; -AES_192: 'AES_192'; -AES_256: 'AES_256'; -AFFINITY: 'AFFINITY'; -AFTER: 'AFTER'; -AGGREGATE: 'AGGREGATE'; -ALGORITHM: 'ALGORITHM'; -ALL: 'ALL'; -ALLOWED: 'ALLOWED'; -ALLOW_CONNECTIONS: 'ALLOW_CONNECTIONS'; -ALLOW_ENCRYPTED_VALUE_MODIFICATIONS: 'ALLOW_ENCRYPTED_VALUE_MODIFICATIONS'; -ALLOW_MULTIPLE_EVENT_LOSS: 'ALLOW_MULTIPLE_EVENT_LOSS'; -ALLOW_PAGE_LOCKS: 'ALLOW_PAGE_LOCKS'; -ALLOW_ROW_LOCKS: 'ALLOW_ROW_LOCKS'; -ALLOW_SINGLE_EVENT_LOSS: 'ALLOW_SINGLE_EVENT_LOSS'; -ALLOW_SNAPSHOT_ISOLATION: 'ALLOW_SNAPSHOT_ISOLATION'; -ALL_CONSTRAINTS: 'ALL_CONSTRAINTS'; -ALL_ERRORMSGS: 'ALL_ERRORMSGS'; -ALL_INDEXES: 'ALL_INDEXES'; -ALL_LEVELS: 'ALL_LEVELS'; -ALTER: 'ALTER'; -ALWAYS: 'ALWAYS'; -AND: 'AND'; -ANONYMOUS: 'ANONYMOUS'; -ANSI_DEFAULTS: 'ANSI_DEFAULTS'; -ANSI_NULLS: 'ANSI_NULLS'; -ANSI_NULL_DEFAULT: 'ANSI_NULL_DEFAULT'; -ANSI_NULL_DFLT_OFF: 'ANSI_NULL_DFLT_OFF'; -ANSI_NULL_DFLT_ON: 'ANSI_NULL_DFLT_ON'; -ANSI_PADDING: 'ANSI_PADDING'; -ANSI_WARNINGS: 'ANSI_WARNINGS'; -ANY: 'ANY'; -APPEND: 'APPEND'; -APPLICATION: 'APPLICATION'; -APPLICATION_LOG: 'APPLICATION_LOG'; -APPLOCK_MODE: 'APPLOCK_MODE'; -APPLOCK_TEST: 'APPLOCK_TEST'; -APPLY: 'APPLY'; -APP_NAME: 'APP_NAME'; -ARITHABORT: 'ARITHABORT'; -ARITHIGNORE: 'ARITHIGNORE'; -AS: 'AS'; -ASC: 'ASC'; -ASCII: 'ASCII'; -ASSEMBLY: 'ASSEMBLY'; -ASSEMBLYPROPERTY: 'ASSEMBLYPROPERTY'; -ASYMMETRIC: 'ASYMMETRIC'; -ASYNCHRONOUS_COMMIT: 'ASYNCHRONOUS_COMMIT'; -AT_KEYWORD: 'AT'; -AUDIT: 'AUDIT'; -AUDIT_GUID: 'AUDIT_GUID'; -AUTHENTICATE: 'AUTHENTICATE'; -AUTHENTICATION: 'AUTHENTICATION'; -AUTHORIZATION: 'AUTHORIZATION'; -AUTO: 'AUTO'; -AUTOGROW_ALL_FILES: 'AUTOGROW_ALL_FILES'; -AUTOGROW_SINGLE_FILE: 'AUTOGROW_SINGLE_FILE'; -AUTOMATED_BACKUP_PREFERENCE: 'AUTOMATED_BACKUP_PREFERENCE'; -AUTOMATIC: 'AUTOMATIC'; -AUTO_CLEANUP: 'AUTO_CLEANUP'; -AUTO_CLOSE: 'AUTO_CLOSE'; -AUTO_CREATE_STATISTICS: 'AUTO_CREATE_STATISTICS'; -AUTO_DROP: 'AUTO_DROP'; -AUTO_SHRINK: 'AUTO_SHRINK'; -AUTO_UPDATE_STATISTICS: 'AUTO_UPDATE_STATISTICS'; -AUTO_UPDATE_STATISTICS_ASYNC: 'AUTO_UPDATE_STATISTICS_ASYNC'; -AVAILABILITY: 'AVAILABILITY'; -AVAILABILITY_MODE: 'AVAILABILITY_MODE'; -AVG: 'AVG'; -BACKSLASH: '\\'; -BACKUP: 'BACKUP'; -BACKUP_CLONEDB: 'BACKUP_CLONEDB'; -BACKUP_PRIORITY: 'BACKUP_PRIORITY'; -BASE64: 'BASE64'; -BEFORE: 'BEFORE'; -BEGIN: 'BEGIN'; -BEGIN_DIALOG: 'BEGIN_DIALOG'; -BETWEEN: 'BETWEEN'; -BIGINT: 'BIGINT'; -BINARY_CHECKSUM: 'BINARY_CHECKSUM'; -BINARY_KEYWORD: 'BINARY'; -BINDING: 'BINDING'; -BLOB_STORAGE: 'BLOB_STORAGE'; -BLOCK: 'BLOCK'; -BLOCKERS: 'BLOCKERS'; -BLOCKING_HIERARCHY: 'BLOCKING_HIERARCHY'; -BLOCKSIZE: 'BLOCKSIZE'; -BREAK: 'BREAK'; -BROKER: 'BROKER'; -BROKER_INSTANCE: 'BROKER_INSTANCE'; -BROWSE: 'BROWSE'; -BUFFER: 'BUFFER'; -BUFFERCOUNT: 'BUFFERCOUNT'; -BULK: 'BULK'; -BULK_LOGGED: 'BULK_LOGGED'; -BY: 'BY'; -CACHE: 'CACHE'; -CALLED: 'CALLED'; -CALLER: 'CALLER'; -CAP_CPU_PERCENT: 'CAP_CPU_PERCENT'; -CASCADE: 'CASCADE'; -CASE: 'CASE'; -CAST: 'CAST'; -CATALOG: 'CATALOG'; -CATCH: 'CATCH'; -CERTENCODED: 'CERTENCODED'; -CERTIFICATE: 'CERTIFICATE'; -CERTPRIVATEKEY: 'CERTPRIVATEKEY'; -CERT_ID: 'CERT_ID'; -CHANGE: 'CHANGE'; -CHANGES: 'CHANGES'; -CHANGETABLE: 'CHANGETABLE'; -CHANGE_RETENTION: 'CHANGE_RETENTION'; -CHANGE_TRACKING: 'CHANGE_TRACKING'; -CHAR: 'CHAR'; -CHARINDEX: 'CHARINDEX'; -CHECK: 'CHECK'; -CHECKALLOC: 'CHECKALLOC'; -CHECKCATALOG: 'CHECKCATALOG'; -CHECKCONSTRAINTS: 'CHECKCONSTRAINTS'; -CHECKDB: 'CHECKDB'; -CHECKFILEGROUP: 'CHECKFILEGROUP'; -CHECKPOINT: 'CHECKPOINT'; -CHECKSUM: 'CHECKSUM'; -CHECKSUM_AGG: 'CHECKSUM_AGG'; -CHECKTABLE: 'CHECKTABLE'; -CHECK_EXPIRATION: 'CHECK_EXPIRATION'; -CHECK_POLICY: 'CHECK_POLICY'; -CLASSIFIER_FUNCTION: 'CLASSIFIER_FUNCTION'; -CLEANTABLE: 'CLEANTABLE'; -CLEANUP: 'CLEANUP'; -CLONEDATABASE: 'CLONEDATABASE'; -CLOSE: 'CLOSE'; -CLUSTER: 'CLUSTER'; -CLUSTERED: 'CLUSTERED'; -COALESCE: 'COALESCE'; -COLLATE: 'COLLATE'; -COLLECTION: 'COLLECTION'; -COLUMN: 'COLUMN'; -COLUMNPROPERTY: 'COLUMNPROPERTY'; -COLUMNS: 'COLUMNS'; -COLUMNSTORE: 'COLUMNSTORE'; -COLUMNSTORE_ARCHIVE: 'COLUMNSTORE_ARCHIVE'; -COLUMN_ENCRYPTION_KEY: 'COLUMN_ENCRYPTION_KEY'; -COLUMN_MASTER_KEY: 'COLUMN_MASTER_KEY'; -COL_LENGTH: 'COL_LENGTH'; -COL_NAME: 'COL_NAME'; -COMMIT: 'COMMIT'; -COMMITTED: 'COMMITTED'; -COMPATIBILITY_LEVEL: 'COMPATIBILITY_LEVEL'; -COMPRESS: 'COMPRESS'; -COMPRESSION: 'COMPRESSION'; -COMPRESSION_DELAY: 'COMPRESSION_DELAY'; -COMPRESS_ALL_ROW_GROUPS: 'COMPRESS_ALL_ROW_GROUPS'; -COMPUTE: 'COMPUTE'; -CONCAT: 'CONCAT'; -CONCAT_NULL_YIELDS_NULL: 'CONCAT_NULL_YIELDS_NULL'; -CONCAT_WS: 'CONCAT_WS'; -CONFIGURATION: 'CONFIGURATION'; -CONNECT: 'CONNECT'; -CONNECTION: 'CONNECTION'; -CONNECTIONPROPERTY: 'CONNECTIONPROPERTY'; -CONSTRAINT: 'CONSTRAINT'; -CONTAINMENT: 'CONTAINMENT'; -CONTAINS: 'CONTAINS'; -CONTAINSTABLE: 'CONTAINSTABLE'; -CONTENT: 'CONTENT'; -CONTEXT: 'CONTEXT'; -CONTEXT_INFO: 'CONTEXT_INFO'; -CONTINUE: 'CONTINUE'; -CONTINUE_AFTER_ERROR: 'CONTINUE_AFTER_ERROR'; -CONTRACT: 'CONTRACT'; -CONTRACT_NAME: 'CONTRACT_NAME'; -CONTROL: 'CONTROL'; -CONVERSATION: 'CONVERSATION'; -CONVERT: 'TRY_'? 'CONVERT'; -COOKIE: 'COOKIE'; -COPY_ONLY: 'COPY_ONLY'; -COUNT: 'COUNT'; -COUNTER: 'COUNTER'; -COUNT_BIG: 'COUNT_BIG'; -CPU: 'CPU'; -CREATE: 'CREATE'; -CREATE_NEW: 'CREATE_NEW'; -CREATION_DISPOSITION: 'CREATION_DISPOSITION'; -CREDENTIAL: 'CREDENTIAL'; -CROSS: 'CROSS'; -CRYPTOGRAPHIC: 'CRYPTOGRAPHIC'; -CUME_DIST: 'CUME_DIST'; -CURRENT: 'CURRENT'; -CURRENT_DATE: 'CURRENT_DATE'; -CURRENT_REQUEST_ID: 'CURRENT_REQUEST_ID'; -CURRENT_TIME: 'CURRENT_TIME'; -CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; -CURRENT_TRANSACTION_ID: 'CURRENT_TRANSACTION_ID'; -CURRENT_USER: 'CURRENT_USER'; -CURSOR: 'CURSOR'; -CURSOR_CLOSE_ON_COMMIT: 'CURSOR_CLOSE_ON_COMMIT'; -CURSOR_DEFAULT: 'CURSOR_DEFAULT'; -CURSOR_STATUS: 'CURSOR_STATUS'; -CYCLE: 'CYCLE'; -DATA: 'DATA'; -DATABASE: 'DATABASE'; -DATABASEPROPERTYEX: 'DATABASEPROPERTYEX'; -DATABASE_MIRRORING: 'DATABASE_MIRRORING'; -DATABASE_PRINCIPAL_ID: 'DATABASE_PRINCIPAL_ID'; -DATALENGTH: 'DATALENGTH'; -DATASPACE: 'DATASPACE'; -DATA_COMPRESSION: 'DATA_COMPRESSION'; -DATA_PURITY: 'DATA_PURITY'; -DATA_SOURCE: 'DATA_SOURCE'; -DATEADD: 'DATEADD'; -DATEDIFF: 'DATEDIFF'; -DATENAME: 'DATENAME'; -DATEPART: 'DATEPART'; -DATE_CORRELATION_OPTIMIZATION: 'DATE_CORRELATION_OPTIMIZATION'; -DAYS: 'DAYS'; -DBCC: 'DBCC'; -DBREINDEX: 'DBREINDEX'; -DB_CHAINING: 'DB_CHAINING'; -DB_FAILOVER: 'DB_FAILOVER'; -DB_ID: 'DB_ID'; -DB_NAME: 'DB_NAME'; -DDL: 'DDL'; -DEALLOCATE: 'DEALLOCATE'; -DECLARE: 'DECLARE'; -DECOMPRESS: 'DECOMPRESS'; -DECRYPTION: 'DECRYPTION'; -DEFAULT: 'DEFAULT'; -DEFAULT_DATABASE: 'DEFAULT_DATABASE'; -DEFAULT_DOUBLE_QUOTE: ["]'DEFAULT'["]; -DEFAULT_FULLTEXT_LANGUAGE: 'DEFAULT_FULLTEXT_LANGUAGE'; -DEFAULT_LANGUAGE: 'DEFAULT_LANGUAGE'; -DEFAULT_SCHEMA: 'DEFAULT_SCHEMA'; -DEFINITION: 'DEFINITION'; -DELAY: 'DELAY'; -DELAYED_DURABILITY: 'DELAYED_DURABILITY'; -DELETE: 'DELETE'; -DELETED: 'DELETED'; -DENSE_RANK: 'DENSE_RANK'; -DENY: 'DENY'; -DEPENDENTS: 'DEPENDENTS'; -DES: 'DES'; -DESC: 'DESC'; -DESCRIPTION: 'DESCRIPTION'; -DESX: 'DESX'; -DETERMINISTIC: 'DETERMINISTIC'; -DHCP: 'DHCP'; -DIAGNOSTICS: 'DIAGNOSTICS'; -DIALOG: 'DIALOG'; -DIFFERENCE: 'DIFFERENCE'; -DIFFERENTIAL: 'DIFFERENTIAL'; -DIRECTORY_NAME: 'DIRECTORY_NAME'; -DISABLE: 'DISABLE'; -DISABLED: 'DISABLED'; -DISABLE_BROKER: 'DISABLE_BROKER'; -DISK: 'DISK'; -DISTINCT: 'DISTINCT'; -DISTRIBUTED: 'DISTRIBUTED'; -DISTRIBUTION: 'DISTRIBUTION'; -DOCUMENT: 'DOCUMENT'; -DOLLAR_PARTITION: '$PARTITION'; -DOUBLE: 'DOUBLE'; -DOUBLE_BACK_SLASH: '\\\\'; -DOUBLE_FORWARD_SLASH: '//'; -DROP: 'DROP'; -DROPCLEANBUFFERS: 'DROPCLEANBUFFERS'; -DROP_EXISTING: 'DROP_EXISTING'; -DTC_SUPPORT: 'DTC_SUPPORT'; -DUMP: 'DUMP'; -DYNAMIC: 'DYNAMIC'; -ELEMENTS: 'ELEMENTS'; -ELSE: 'ELSE'; -EMERGENCY: 'EMERGENCY'; -EMPTY: 'EMPTY'; -ENABLE: 'ENABLE'; -ENABLED: 'ENABLED'; -ENABLE_BROKER: 'ENABLE_BROKER'; -ENCRYPTED: 'ENCRYPTED'; -ENCRYPTED_VALUE: 'ENCRYPTED_VALUE'; -ENCRYPTION: 'ENCRYPTION'; -ENCRYPTION_TYPE: 'ENCRYPTION_TYPE'; -END: 'END'; -ENDPOINT: 'ENDPOINT'; -ENDPOINT_URL: 'ENDPOINT_URL'; -ERRLVL: 'ERRLVL'; -ERROR: 'ERROR'; -ERROR_BROKER_CONVERSATIONS: 'ERROR_BROKER_CONVERSATIONS'; -ERROR_LINE: 'ERROR_LINE'; -ERROR_MESSAGE: 'ERROR_MESSAGE'; -ERROR_NUMBER: 'ERROR_NUMBER'; -ERROR_PROCEDURE: 'ERROR_PROCEDURE'; -ERROR_SEVERITY: 'ERROR_SEVERITY'; -ERROR_STATE: 'ERROR_STATE'; -ESCAPE: 'ESCAPE'; -ESTIMATEONLY: 'ESTIMATEONLY'; -EVENT: 'EVENT'; -EVENTDATA: 'EVENTDATA'; -EVENT_RETENTION_MODE: 'EVENT_RETENTION_MODE'; -EXCEPT: 'EXCEPT'; -EXCLUSIVE: 'EXCLUSIVE'; -EXECUTABLE: 'EXECUTABLE'; -EXECUTABLE_FILE: 'EXECUTABLE_FILE'; -EXECUTE: 'EXEC' 'UTE'?; -EXIST: 'EXIST'; -EXISTS: 'EXISTS'; -EXIST_SQUARE_BRACKET: '[EXIST]'; -EXIT: 'EXIT'; -EXPAND: 'EXPAND'; -EXPIREDATE: 'EXPIREDATE'; -EXPIRY_DATE: 'EXPIRY_DATE'; -EXPLICIT: 'EXPLICIT'; -EXTENDED_LOGICAL_CHECKS: 'EXTENDED_LOGICAL_CHECKS'; -EXTENSION: 'EXTENSION'; -EXTERNAL: 'EXTERNAL'; -EXTERNAL_ACCESS: 'EXTERNAL_ACCESS'; -FAILOVER: 'FAILOVER'; -FAILOVER_MODE: 'FAILOVER_MODE'; -FAILURE: 'FAILURE'; -FAILURECONDITIONLEVEL: 'FAILURECONDITIONLEVEL'; -FAILURE_CONDITION_LEVEL: 'FAILURE_CONDITION_LEVEL'; -FAIL_OPERATION: 'FAIL_OPERATION'; -FAN_IN: 'FAN_IN'; -FAST: 'FAST'; -FAST_FORWARD: 'FAST_FORWARD'; -FETCH: 'FETCH'; -FILE: 'FILE'; -FILEGROUP: 'FILEGROUP'; -FILEGROUPPROPERTY: 'FILEGROUPPROPERTY'; -FILEGROUP_ID: 'FILEGROUP_ID'; -FILEGROUP_NAME: 'FILEGROUP_NAME'; -FILEGROWTH: 'FILEGROWTH'; -FILENAME: 'FILENAME'; -FILEPATH: 'FILEPATH'; -FILEPROPERTY: 'FILEPROPERTY'; -FILEPROPERTYEX: 'FILEPROPERTYEX'; -FILESTREAM: 'FILESTREAM'; -FILESTREAM_ON: 'FILESTREAM_ON'; -FILE_ID: 'FILE_ID'; -FILE_IDEX: 'FILE_IDEX'; -FILE_NAME: 'FILE_NAME'; -FILE_SNAPSHOT: 'FILE_SNAPSHOT'; -FILLFACTOR: 'FILLFACTOR'; -FILTER: 'FILTER'; -FIRST: 'FIRST'; -FIRST_VALUE: 'FIRST_VALUE'; -FMTONLY: 'FMTONLY'; -FOLLOWING: 'FOLLOWING'; -FOR: 'FOR'; -FORCE: 'FORCE'; -FORCED: 'FORCED'; -FORCEPLAN: 'FORCEPLAN'; -FORCESCAN: 'FORCESCAN'; -FORCESEEK: 'FORCESEEK'; -FORCE_FAILOVER_ALLOW_DATA_LOSS: 'FORCE_FAILOVER_ALLOW_DATA_LOSS'; -FORCE_SERVICE_ALLOW_DATA_LOSS: 'FORCE_SERVICE_ALLOW_DATA_LOSS'; -FOREIGN: 'FOREIGN'; -FORMAT: 'FORMAT'; -FORMATMESSAGE: 'FORMATMESSAGE'; -FORWARD_ONLY: 'FORWARD_ONLY'; -FREE: 'FREE'; -FREETEXT: 'FREETEXT'; -FREETEXTTABLE: 'FREETEXTTABLE'; -FROM: 'FROM'; -FULL: 'FULL'; -FULLSCAN: 'FULLSCAN'; -FULLTEXT: 'FULLTEXT'; -FULLTEXTCATALOGPROPERTY: 'FULLTEXTCATALOGPROPERTY'; -FULLTEXTSERVICEPROPERTY: 'FULLTEXTSERVICEPROPERTY'; -FUNCTION: 'FUNCTION'; -GB: 'GB'; -GENERATED: 'GENERATED'; -GET: 'GET'; -GETANCESTOR: 'GETANCESTOR'; -GETANSINULL: 'GETANSINULL'; -GETDATE: 'GETDATE'; -GETDESCENDANT: 'GETDESCENDANT'; -GETLEVEL: 'GETLEVEL'; -GETREPARENTEDVALUE: 'GETREPARENTEDVALUE'; -GETROOT: 'GETROOT'; -GETUTCDATE: 'GETUTCDATE'; -GET_FILESTREAM_TRANSACTION_CONTEXT: 'GET_FILESTREAM_TRANSACTION_CONTEXT'; -GLOBAL: 'GLOBAL'; -GO: 'GO'; -GOTO: 'GOTO'; -GOVERNOR: 'GOVERNOR'; -GRANT: 'GRANT'; -GREATEST: 'GREATEST'; -GROUP: 'GROUP'; -GROUPING: 'GROUPING'; -GROUPING_ID: 'GROUPING_ID'; -GROUP_MAX_REQUESTS: 'GROUP_MAX_REQUESTS'; -HADR: 'HADR'; -HASH: 'HASH'; -HASHED: 'HASHED'; -HAS_DBACCESS: 'HAS_DBACCESS'; -HAS_PERMS_BY_NAME: 'HAS_PERMS_BY_NAME'; -HAVING: 'HAVING'; -HEALTHCHECKTIMEOUT: 'HEALTHCHECKTIMEOUT'; -HEALTH_CHECK_TIMEOUT: 'HEALTH_CHECK_TIMEOUT'; -HEAP: 'HEAP'; -HIDDEN_KEYWORD: 'HIDDEN'; -HIERARCHYID: 'HIERARCHYID'; -HIGH: 'HIGH'; -HOLDLOCK: 'HOLDLOCK'; -HONOR_BROKER_PRIORITY: 'HONOR_BROKER_PRIORITY'; -HOST_ID: 'HOST_ID'; -HOST_NAME: 'HOST_NAME'; -HOURS: 'HOURS'; -IDENTITY: 'IDENTITY'; -IDENTITYCOL: 'IDENTITYCOL'; -IDENTITY_INSERT: 'IDENTITY_INSERT'; -IDENTITY_VALUE: 'IDENTITY_VALUE'; -IDENT_CURRENT: 'IDENT_CURRENT'; -IDENT_INCR: 'IDENT_INCR'; -IDENT_SEED: 'IDENT_SEED'; -IF: 'IF'; -IGNORE_CONSTRAINTS: 'IGNORE_CONSTRAINTS'; -IGNORE_DUP_KEY: 'IGNORE_DUP_KEY'; -IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX: 'IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX'; -IGNORE_REPLICATED_TABLE_CACHE: 'IGNORE_REPLICATED_TABLE_CACHE'; -IGNORE_TRIGGERS: 'IGNORE_TRIGGERS'; -IIF: 'IIF'; -IMMEDIATE: 'IMMEDIATE'; -IMPERSONATE: 'IMPERSONATE'; -IMPLICIT_TRANSACTIONS: 'IMPLICIT_TRANSACTIONS'; -IMPORTANCE: 'IMPORTANCE'; -IN: 'IN'; -INCLUDE: 'INCLUDE'; -INCLUDE_NULL_VALUES: 'INCLUDE_NULL_VALUES'; -INCREMENT: 'INCREMENT'; -INCREMENTAL: 'INCREMENTAL'; -INDEX: 'INDEX'; -INDEXKEY_PROPERTY: 'INDEXKEY_PROPERTY'; -INDEXPROPERTY: 'INDEXPROPERTY'; -INDEX_COL: 'INDEX_COL'; -INFINITE: 'INFINITE'; -INIT: 'INIT'; -INITIATOR: 'INITIATOR'; -INNER: 'INNER'; -INPUT: 'INPUT'; -INSENSITIVE: 'INSENSITIVE'; -INSERT: 'INSERT'; -INSERTED: 'INSERTED'; -INSTEAD: 'INSTEAD'; -INT: 'INT'; -INTERSECT: 'INTERSECT'; -INTO: 'INTO'; -IO: 'IO'; -IP: 'IP'; -IS: 'IS'; -ISDESCENDANTOF: 'ISDESCENDANTOF'; -ISJSON: 'ISJSON'; -ISNULL: 'ISNULL'; -ISNUMERIC: 'ISNUMERIC'; -ISOLATION: 'ISOLATION'; -IS_MEMBER: 'IS_MEMBER'; -IS_ROLEMEMBER: 'IS_ROLEMEMBER'; -IS_SRVROLEMEMBER: 'IS_SRVROLEMEMBER'; -JOB: 'JOB'; -JOIN: 'JOIN'; -JSON: 'JSON'; -JSON_ARRAY: 'JSON_ARRAY'; -JSON_MODIFY: 'JSON_MODIFY'; -JSON_OBJECT: 'JSON_OBJECT'; -JSON_PATH_EXISTS: 'JSON_PATH_EXISTS'; -JSON_QUERY: 'JSON_QUERY'; -JSON_VALUE: 'JSON_VALUE'; -KB: 'KB'; -KEEP: 'KEEP'; -KEEPDEFAULTS: 'KEEPDEFAULTS'; -KEEPFIXED: 'KEEPFIXED'; -KEEPIDENTITY: 'KEEPIDENTITY'; -KERBEROS: 'KERBEROS'; -KEY: 'KEY'; -KEYS: 'KEYS'; -KEYSET: 'KEYSET'; -KEY_PATH: 'KEY_PATH'; -KEY_SOURCE: 'KEY_SOURCE'; -KEY_STORE_PROVIDER_NAME: 'KEY_STORE_PROVIDER_NAME'; -KILL: 'KILL'; -LAG: 'LAG'; -LANGUAGE: 'LANGUAGE'; -LAST: 'LAST'; -LAST_VALUE: 'LAST_VALUE'; -LEAD: 'LEAD'; -LEAST: 'LEAST'; -LEFT: 'LEFT'; -LEN: 'LEN'; -LEVEL: 'LEVEL'; -LIBRARY: 'LIBRARY'; -LIFETIME: 'LIFETIME'; -LIKE: 'LIKE'; -LINENO: 'LINENO'; -LINKED: 'LINKED'; -LINUX: 'LINUX'; -LIST: 'LIST'; -LISTENER: 'LISTENER'; -LISTENER_IP: 'LISTENER_IP'; -LISTENER_PORT: 'LISTENER_PORT'; -LISTENER_URL: 'LISTENER_URL'; -LOAD: 'LOAD'; -LOB_COMPACTION: 'LOB_COMPACTION'; -LOCAL: 'LOCAL'; -LOCAL_SERVICE_NAME: 'LOCAL_SERVICE_NAME'; -LOCATION: 'LOCATION'; -LOCK: 'LOCK'; -LOCK_ESCALATION: 'LOCK_ESCALATION'; -LOG: 'LOG'; -LOGIN: 'LOGIN'; -LOGINPROPERTY: 'LOGINPROPERTY'; -LOOP: 'LOOP'; -LOW: 'LOW'; -LOWER: 'LOWER'; -LTRIM: 'LTRIM'; -MANUAL: 'MANUAL'; -MARK: 'MARK'; -MASK: 'MASK'; -MASKED: 'MASKED'; -MASTER: 'MASTER'; -MATCHED: 'MATCHED'; -MATERIALIZED: 'MATERIALIZED'; -MAX: 'MAX'; -MAXDOP: 'MAXDOP'; -MAXRECURSION: 'MAXRECURSION'; -MAXSIZE: 'MAXSIZE'; -MAXTRANSFER: 'MAXTRANSFER'; -MAXVALUE: 'MAXVALUE'; -MAX_CPU_PERCENT: 'MAX_CPU_PERCENT'; -MAX_DISPATCH_LATENCY: 'MAX_DISPATCH_LATENCY'; -MAX_DOP: 'MAX_DOP'; -MAX_DURATION: 'MAX_DURATION'; -MAX_EVENT_SIZE: 'MAX_EVENT_SIZE'; -MAX_FILES: 'MAX_FILES'; -MAX_IOPS_PER_VOLUME: 'MAX_IOPS_PER_VOLUME'; -MAX_MEMORY: 'MAX_MEMORY'; -MAX_MEMORY_PERCENT: 'MAX_MEMORY_PERCENT'; -MAX_OUTSTANDING_IO_PER_VOLUME: 'MAX_OUTSTANDING_IO_PER_VOLUME'; -MAX_PROCESSES: 'MAX_PROCESSES'; -MAX_QUEUE_READERS: 'MAX_QUEUE_READERS'; -MAX_ROLLOVER_FILES: 'MAX_ROLLOVER_FILES'; -MAX_SIZE: 'MAX_SIZE'; -MB: 'MB'; -MEDIADESCRIPTION: 'MEDIADESCRIPTION'; -MEDIANAME: 'MEDIANAME'; -MEDIUM: 'MEDIUM'; -MEMBER: 'MEMBER'; -MEMORY_OPTIMIZED_DATA: 'MEMORY_OPTIMIZED_DATA'; -MEMORY_PARTITION_MODE: 'MEMORY_PARTITION_MODE'; -MERGE: 'MERGE'; -MESSAGE: 'MESSAGE'; -MESSAGE_FORWARDING: 'MESSAGE_FORWARDING'; -MESSAGE_FORWARD_SIZE: 'MESSAGE_FORWARD_SIZE'; -MIN: 'MIN'; -MINUTES: 'MINUTES'; -MINVALUE: 'MINVALUE'; -MIN_ACTIVE_ROWVERSION: 'MIN_ACTIVE_ROWVERSION'; -MIN_CPU_PERCENT: 'MIN_CPU_PERCENT'; -MIN_IOPS_PER_VOLUME: 'MIN_IOPS_PER_VOLUME'; -MIN_MEMORY_PERCENT: 'MIN_MEMORY_PERCENT'; -MIRROR: 'MIRROR'; -MIRROR_ADDRESS: 'MIRROR_ADDRESS'; -MIXED_PAGE_ALLOCATION: 'MIXED_PAGE_ALLOCATION'; -MODE: 'MODE'; -MODIFY: 'MODIFY'; -MODIFY_SQUARE_BRACKET: '[MODIFY]'; -MOVE: 'MOVE'; -MULTI_USER: 'MULTI_USER'; -MUST_CHANGE: 'MUST_CHANGE'; -NAME: 'NAME'; -NATIONAL: 'NATIONAL'; -NCHAR: 'NCHAR'; -NEGOTIATE: 'NEGOTIATE'; -NESTED_TRIGGERS: 'NESTED_TRIGGERS'; -NEWID: 'NEWID'; -NEWNAME: 'NEWNAME'; -NEWSEQUENTIALID: 'NEWSEQUENTIALID'; -NEW_ACCOUNT: 'NEW_ACCOUNT'; -NEW_BROKER: 'NEW_BROKER'; -NEW_PASSWORD: 'NEW_PASSWORD'; -NEXT: 'NEXT'; -NO: 'NO'; -NOCHECK: 'NOCHECK'; -NOCOUNT: 'NOCOUNT'; -NODES: 'NODES'; -NOEXEC: 'NOEXEC'; -NOEXPAND: 'NOEXPAND'; -NOFORMAT: 'NOFORMAT'; -NOHOLDLOCK: 'NOHOLDLOCK'; -NOINDEX: 'NOINDEX'; -NOINIT: 'NOINIT'; -NOLOCK: 'NOLOCK'; -NONCLUSTERED: 'NONCLUSTERED'; -NONE: 'NONE'; -NON_TRANSACTED_ACCESS: 'NON_TRANSACTED_ACCESS'; -NORECOMPUTE: 'NORECOMPUTE'; -NORECOVERY: 'NORECOVERY'; -NOREWIND: 'NOREWIND'; -NOSKIP: 'NOSKIP'; -NOT: 'NOT'; -NOTIFICATION: 'NOTIFICATION'; -NOTIFICATIONS: 'NOTIFICATIONS'; -NOUNLOAD: 'NOUNLOAD'; -NOWAIT: 'NOWAIT'; -NO_CHECKSUM: 'NO_CHECKSUM'; -NO_COMPRESSION: 'NO_COMPRESSION'; -NO_EVENT_LOSS: 'NO_EVENT_LOSS'; -NO_INFOMSGS: 'NO_INFOMSGS'; -NO_QUERYSTORE: 'NO_QUERYSTORE'; -NO_STATISTICS: 'NO_STATISTICS'; -NO_TRUNCATE: 'NO_TRUNCATE'; -NO_WAIT: 'NO_WAIT'; -NTILE: 'NTILE'; -NTLM: 'NTLM'; -NULLIF: 'NULLIF'; -NULL_: 'NULL'; -NULL_DOUBLE_QUOTE: ["]'NULL'["]; -NUMANODE: 'NUMANODE'; -NUMBER: 'NUMBER'; -NUMERIC_ROUNDABORT: 'NUMERIC_ROUNDABORT'; -OBJECT: 'OBJECT'; -OBJECTPROPERTY: 'OBJECTPROPERTY'; -OBJECTPROPERTYEX: 'OBJECTPROPERTYEX'; -OBJECT_DEFINITION: 'OBJECT_DEFINITION'; -OBJECT_ID: 'OBJECT_ID'; -OBJECT_NAME: 'OBJECT_NAME'; -OBJECT_SCHEMA_NAME: 'OBJECT_SCHEMA_NAME'; -OF: 'OF'; -OFF: 'OFF'; -OFFLINE: 'OFFLINE'; -OFFSET: 'OFFSET'; -OFFSETS: 'OFFSETS'; -OLD_ACCOUNT: 'OLD_ACCOUNT'; -OLD_PASSWORD: 'OLD_PASSWORD'; -ON: 'ON'; -ONLINE: 'ONLINE'; -ONLY: 'ONLY'; -ON_FAILURE: 'ON_FAILURE'; -OPEN: 'OPEN'; -OPENDATASOURCE: 'OPENDATASOURCE'; -OPENJSON: 'OPENJSON'; -OPENQUERY: 'OPENQUERY'; -OPENROWSET: 'OPENROWSET'; -OPENXML: 'OPENXML'; -OPEN_EXISTING: 'OPEN_EXISTING'; -OPERATIONS: 'OPERATIONS'; -OPTIMISTIC: 'OPTIMISTIC'; -OPTIMIZE: 'OPTIMIZE'; -OPTIMIZE_FOR_SEQUENTIAL_KEY: 'OPTIMIZE_FOR_SEQUENTIAL_KEY'; -OPTION: 'OPTION'; -OR: 'OR'; -ORDER: 'ORDER'; -ORIGINAL_DB_NAME: 'ORIGINAL_DB_NAME'; -ORIGINAL_LOGIN: 'ORIGINAL_LOGIN'; -OUT: 'OUT'; -OUTER: 'OUTER'; -OUTPUT: 'OUTPUT'; -OVER: 'OVER'; -OVERRIDE: 'OVERRIDE'; -OWNER: 'OWNER'; -OWNERSHIP: 'OWNERSHIP'; -PAD_INDEX: 'PAD_INDEX'; -PAGE: 'PAGE'; -PAGECOUNT: 'PAGECOUNT'; -PAGE_VERIFY: 'PAGE_VERIFY'; -PAGLOCK: 'PAGLOCK'; -PARAMETERIZATION: 'PARAMETERIZATION'; -PARAM_NODE: 'PARAM_NODE'; -PARSE: 'TRY_'? 'PARSE'; -PARSENAME: 'PARSENAME'; -PARSEONLY: 'PARSEONLY'; -PARTIAL: 'PARTIAL'; -PARTITION: 'PARTITION'; -PARTITIONS: 'PARTITIONS'; -PARTNER: 'PARTNER'; -PASSWORD: 'PASSWORD'; -PATH: 'PATH'; -PATINDEX: 'PATINDEX'; -PAUSE: 'PAUSE'; -PDW_SHOWSPACEUSED: 'PDW_SHOWSPACEUSED'; -PERCENT: 'PERCENT'; -PERCENTILE_CONT: 'PERCENTILE_CONT'; -PERCENTILE_DISC: 'PERCENTILE_DISC'; -PERCENT_RANK: 'PERCENT_RANK'; -PERMISSIONS: 'PERMISSIONS'; -PERMISSION_SET: 'PERMISSION_SET'; -PERSISTED: 'PERSISTED'; -PERSIST_SAMPLE_PERCENT: 'PERSIST_SAMPLE_PERCENT'; -PER_CPU: 'PER_CPU'; -PER_DB: 'PER_DB'; -PER_NODE: 'PER_NODE'; -PHYSICAL_ONLY: 'PHYSICAL_ONLY'; -PIVOT: 'PIVOT'; -PLAN: 'PLAN'; -PLATFORM: 'PLATFORM'; -POISON_MESSAGE_HANDLING: 'POISON_MESSAGE_HANDLING'; -POLICY: 'POLICY'; -POOL: 'POOL'; -PORT: 'PORT'; -PRECEDING: 'PRECEDING'; -PRECISION: 'PRECISION'; -PREDICATE: 'PREDICATE'; -PRIMARY: 'PRIMARY'; -PRIMARY_ROLE: 'PRIMARY_ROLE'; -PRINT: 'PRINT'; -PRIOR: 'PRIOR'; -PRIORITY: 'PRIORITY'; -PRIORITY_LEVEL: 'PRIORITY_LEVEL'; -PRIVATE: 'PRIVATE'; -PRIVATE_KEY: 'PRIVATE_KEY'; -PRIVILEGES: 'PRIVILEGES'; -PROC: 'PROC'; -PROCCACHE: 'PROCCACHE'; -PROCEDURE: 'PROCEDURE'; -PROCEDURE_NAME: 'PROCEDURE_NAME'; -PROCESS: 'PROCESS'; -PROFILE: 'PROFILE'; -PROPERTY: 'PROPERTY'; -PROVIDER: 'PROVIDER'; -PROVIDER_KEY_NAME: 'PROVIDER_KEY_NAME'; -PUBLIC: 'PUBLIC'; -PWDCOMPARE: 'PWDCOMPARE'; -PWDENCRYPT: 'PWDENCRYPT'; -PYTHON: 'PYTHON'; -QUERY: 'QUERY'; -QUERY_SQUARE_BRACKET: '[QUERY]'; -QUEUE: 'QUEUE'; -QUEUE_DELAY: 'QUEUE_DELAY'; -QUOTED_IDENTIFIER: 'QUOTED_IDENTIFIER'; -QUOTENAME: 'QUOTENAME'; -R: 'R'; -RAISERROR: 'RAISERROR'; -RANDOMIZED: 'RANDOMIZED'; -RANGE: 'RANGE'; -RANK: 'RANK'; -RAW: 'RAW'; -RC2: 'RC2'; -RC4: 'RC4'; -RC4_128: 'RC4_128'; -READ: 'READ'; -READCOMMITTED: 'READCOMMITTED'; -READCOMMITTEDLOCK: 'READCOMMITTEDLOCK'; -READONLY: 'READONLY'; -READPAST: 'READPAST'; -READTEXT: 'READTEXT'; -READUNCOMMITTED: 'READUNCOMMITTED'; -READWRITE: 'READWRITE'; -READ_COMMITTED_SNAPSHOT: 'READ_COMMITTED_SNAPSHOT'; -READ_ONLY: 'READ_ONLY'; -READ_ONLY_ROUTING_LIST: 'READ_ONLY_ROUTING_LIST'; -READ_WRITE: 'READ_WRITE'; -READ_WRITE_FILEGROUPS: 'READ_WRITE_FILEGROUPS'; -REBUILD: 'REBUILD'; -RECEIVE: 'RECEIVE'; -RECOMPILE: 'RECOMPILE'; -RECONFIGURE: 'RECONFIGURE'; -RECOVERY: 'RECOVERY'; -RECURSIVE_TRIGGERS: 'RECURSIVE_TRIGGERS'; -REFERENCES: 'REFERENCES'; -REGENERATE: 'REGENERATE'; -RELATED_CONVERSATION: 'RELATED_CONVERSATION'; -RELATED_CONVERSATION_GROUP: 'RELATED_CONVERSATION_GROUP'; -RELATIVE: 'RELATIVE'; -REMOTE: 'REMOTE'; -REMOTE_PROC_TRANSACTIONS: 'REMOTE_PROC_TRANSACTIONS'; -REMOTE_SERVICE_NAME: 'REMOTE_SERVICE_NAME'; -REMOVE: 'REMOVE'; -REORGANIZE: 'REORGANIZE'; -REPAIR_ALLOW_DATA_LOSS: 'REPAIR_ALLOW_DATA_LOSS'; -REPAIR_FAST: 'REPAIR_FAST'; -REPAIR_REBUILD: 'REPAIR_REBUILD'; -REPEATABLE: 'REPEATABLE'; -REPEATABLEREAD: 'REPEATABLEREAD'; -REPLACE: 'REPLACE'; -REPLICA: 'REPLICA'; -REPLICATE: 'REPLICATE'; -REPLICATION: 'REPLICATION'; -REQUEST_MAX_CPU_TIME_SEC: 'REQUEST_MAX_CPU_TIME_SEC'; -REQUEST_MAX_MEMORY_GRANT_PERCENT: 'REQUEST_MAX_MEMORY_GRANT_PERCENT'; -REQUEST_MEMORY_GRANT_TIMEOUT_SEC: 'REQUEST_MEMORY_GRANT_TIMEOUT_SEC'; -REQUIRED: 'REQUIRED'; -REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT: 'REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT'; -RESAMPLE: 'RESAMPLE'; -RESERVE_DISK_SPACE: 'RESERVE_DISK_SPACE'; -RESET: 'RESET'; -RESOURCE: 'RESOURCE'; -RESOURCES: 'RESOURCES'; -RESOURCE_MANAGER_LOCATION: 'RESOURCE_MANAGER_LOCATION'; -RESTART: 'RESTART'; -RESTORE: 'RESTORE'; -RESTRICT: 'RESTRICT'; -RESTRICTED_USER: 'RESTRICTED_USER'; -RESUMABLE: 'RESUMABLE'; -RESUME: 'RESUME'; -RETAINDAYS: 'RETAINDAYS'; -RETENTION: 'RETENTION'; -RETURN: 'RETURN'; -RETURNS: 'RETURNS'; -REVERSE: 'REVERSE'; -REVERT: 'REVERT'; -REVOKE: 'REVOKE'; -REWIND: 'REWIND'; -RIGHT: 'RIGHT'; -ROBUST: 'ROBUST'; -ROLE: 'ROLE'; -ROLLBACK: 'ROLLBACK'; -ROOT: 'ROOT'; -ROUND_ROBIN: 'ROUND_ROBIN'; -ROUTE: 'ROUTE'; -ROW: 'ROW'; -ROWCOUNT: 'ROWCOUNT'; -ROWCOUNT_BIG: 'ROWCOUNT_BIG'; -ROWGUID: 'ROWGUID'; -ROWGUIDCOL: 'ROWGUIDCOL'; -ROWLOCK: 'ROWLOCK'; -ROWS: 'ROWS'; -ROW_NUMBER: 'ROW_NUMBER'; -RSA_1024: 'RSA_1024'; -RSA_2048: 'RSA_2048'; -RSA_3072: 'RSA_3072'; -RSA_4096: 'RSA_4096'; -RSA_512: 'RSA_512'; -RTRIM: 'RTRIM'; -RULE: 'RULE'; -SAFE: 'SAFE'; -SAFETY: 'SAFETY'; -SAMPLE: 'SAMPLE'; -SAVE: 'SAVE'; -SCHEDULER: 'SCHEDULER'; -SCHEMA: 'SCHEMA'; -SCHEMABINDING: 'SCHEMABINDING'; -SCHEMA_ID: 'SCHEMA_ID'; -SCHEMA_NAME: 'SCHEMA_NAME'; -SCHEME: 'SCHEME'; -SCOPED: 'SCOPED'; -SCOPE_IDENTITY: 'SCOPE_IDENTITY'; -SCRIPT: 'SCRIPT'; -SCROLL: 'SCROLL'; -SCROLL_LOCKS: 'SCROLL_LOCKS'; -SEARCH: 'SEARCH'; -SECONDARY: 'SECONDARY'; -SECONDARY_ONLY: 'SECONDARY_ONLY'; -SECONDARY_ROLE: 'SECONDARY_ROLE'; -SECONDS: 'SECONDS'; -SECRET: 'SECRET'; -SECURABLES: 'SECURABLES'; -SECURITY: 'SECURITY'; -SECURITYAUDIT: 'SECURITYAUDIT'; -SECURITY_LOG: 'SECURITY_LOG'; -SEEDING_MODE: 'SEEDING_MODE'; -SELECT: 'SELECT'; -SELF: 'SELF'; -SEMANTICKEYPHRASETABLE: 'SEMANTICKEYPHRASETABLE'; -SEMANTICSIMILARITYDETAILSTABLE: 'SEMANTICSIMILARITYDETAILSTABLE'; -SEMANTICSIMILARITYTABLE: 'SEMANTICSIMILARITYTABLE'; -SEMI_SENSITIVE: 'SEMI_SENSITIVE'; -SEND: 'SEND'; -SENT: 'SENT'; -SEQUENCE: 'SEQUENCE'; -SEQUENCE_NUMBER: 'SEQUENCE_NUMBER'; -SERIALIZABLE: 'SERIALIZABLE'; -SERVER: 'SERVER'; -SERVERPROPERTY: 'SERVERPROPERTY'; -SERVICE: 'SERVICE'; -SERVICEBROKER: 'SERVICEBROKER'; -SERVICE_BROKER: 'SERVICE_BROKER'; -SERVICE_NAME: 'SERVICE_NAME'; -SESSION: 'SESSION'; -SESSIONPROPERTY: 'SESSIONPROPERTY'; -SESSION_CONTEXT: 'SESSION_CONTEXT'; -SESSION_TIMEOUT: 'SESSION_TIMEOUT'; -SESSION_USER: 'SESSION_USER'; -SET: 'SET'; -SETERROR: 'SETERROR'; -SETS: 'SETS'; -SETTINGS: 'SETTINGS'; -SETUSER: 'SETUSER'; -SHARE: 'SHARE'; -SHARED: 'SHARED'; -SHOWCONTIG: 'SHOWCONTIG'; -SHOWPLAN: 'SHOWPLAN'; -SHOWPLAN_ALL: 'SHOWPLAN_ALL'; -SHOWPLAN_TEXT: 'SHOWPLAN_TEXT'; -SHOWPLAN_XML: 'SHOWPLAN_XML'; -SHRINKLOG: 'SHRINKLOG'; -SHUTDOWN: 'SHUTDOWN'; -SID: 'SID'; -SIGNATURE: 'SIGNATURE'; -SIMPLE: 'SIMPLE'; -SINGLE_USER: 'SINGLE_USER'; -SIZE: 'SIZE'; -SKIP_KEYWORD: 'SKIP'; -SMALLINT: 'SMALLINT'; -SNAPSHOT: 'SNAPSHOT'; -SOFTNUMA: 'SOFTNUMA'; -SOME: 'SOME'; -SORT_IN_TEMPDB: 'SORT_IN_TEMPDB'; -SOUNDEX: 'SOUNDEX'; -SOURCE: 'SOURCE'; -SPACE_KEYWORD: 'SPACE'; -SPARSE: 'SPARSE'; -SPATIAL_WINDOW_MAX_CELLS: 'SPATIAL_WINDOW_MAX_CELLS'; -SPECIFICATION: 'SPECIFICATION'; -SPLIT: 'SPLIT'; -SQL: 'SQL'; -SQLDUMPERFLAGS: 'SQLDUMPERFLAGS'; -SQLDUMPERPATH: 'SQLDUMPERPATH'; -SQLDUMPERTIMEOUT: 'SQLDUMPERTIMEOUT'; -SQL_VARIANT_PROPERTY: 'SQL_VARIANT_PROPERTY'; -STANDBY: 'STANDBY'; -START: 'START'; -STARTED: 'STARTED'; -STARTUP_STATE: 'STARTUP_STATE'; -START_DATE: 'START_DATE'; -STATE: 'STATE'; -STATIC: 'STATIC'; -STATISTICS: 'STATISTICS'; -STATISTICS_INCREMENTAL: 'STATISTICS_INCREMENTAL'; -STATISTICS_NORECOMPUTE: 'STATISTICS_NORECOMPUTE'; -STATS: 'STATS'; -STATS_DATE: 'STATS_DATE'; -STATS_STREAM: 'STATS_STREAM'; -STATUS: 'STATUS'; -STATUSONLY: 'STATUSONLY'; -STDEV: 'STDEV'; -STDEVP: 'STDEVP'; -STOP: 'STOP'; -STOPLIST: 'STOPLIST'; -STOPPED: 'STOPPED'; -STOP_ON_ERROR: 'STOP_ON_ERROR'; -STR: 'STR'; -STRING_AGG: 'STRING_AGG'; -STRING_ESCAPE: 'STRING_ESCAPE'; -STUFF: 'STUFF'; -SUBJECT: 'SUBJECT'; -SUBSCRIBE: 'SUBSCRIBE'; -SUBSCRIPTION: 'SUBSCRIPTION'; -SUBSTRING: 'SUBSTRING'; -SUM: 'SUM'; -SUPPORTED: 'SUPPORTED'; -SUSER_ID: 'SUSER_ID'; -SUSER_NAME: 'SUSER_NAME'; -SUSER_SID: 'SUSER_SID'; -SUSER_SNAME: 'SUSER_SNAME'; -SUSPEND: 'SUSPEND'; -SWITCH: 'SWITCH'; -SYMMETRIC: 'SYMMETRIC'; -SYNCHRONOUS_COMMIT: 'SYNCHRONOUS_COMMIT'; -SYNONYM: 'SYNONYM'; -SYSTEM: 'SYSTEM'; -SYSTEM_USER: 'SYSTEM_USER'; -TABLE: 'TABLE'; -TABLERESULTS: 'TABLERESULTS'; -TABLESAMPLE: 'TABLESAMPLE'; -TABLOCK: 'TABLOCK'; -TABLOCKX: 'TABLOCKX'; -TAKE: 'TAKE'; -TAPE: 'TAPE'; -TARGET: 'TARGET'; -TARGET_RECOVERY_TIME: 'TARGET_RECOVERY_TIME'; -TB: 'TB'; -TCP: 'TCP'; -TEXTIMAGE_ON: 'TEXTIMAGE_ON'; -TEXTSIZE: 'TEXTSIZE'; -THEN: 'THEN'; -THROW: 'THROW'; -TIES: 'TIES'; -TIME: 'TIME'; -TIMEOUT: 'TIMEOUT'; -TIMER: 'TIMER'; -TINYINT: 'TINYINT'; -TO: 'TO'; -TOP: 'TOP'; -TORN_PAGE_DETECTION: 'TORN_PAGE_DETECTION'; -TOSTRING: 'TOSTRING'; -TRACE: 'TRACE'; -TRACKING: 'TRACKING'; -TRACK_CAUSALITY: 'TRACK_CAUSALITY'; -TRAN: 'TRAN'; -TRANSACTION: 'TRANSACTION'; -TRANSACTION_ID: 'TRANSACTION_ID'; -TRANSFER: 'TRANSFER'; -TRANSFORM_NOISE_WORDS: 'TRANSFORM_NOISE_WORDS'; -TRANSLATE: 'TRANSLATE'; -TRIGGER: 'TRIGGER'; -TRIM: 'TRIM'; -TRIPLE_DES: 'TRIPLE_DES'; -TRIPLE_DES_3KEY: 'TRIPLE_DES_3KEY'; -TRUNCATE: 'TRUNCATE'; -TRUSTWORTHY: 'TRUSTWORTHY'; -TRY: 'TRY'; -TRY_CAST: 'TRY_CAST'; -TSEQUAL: 'TSEQUAL'; -TSQL: 'TSQL'; -TWO_DIGIT_YEAR_CUTOFF: 'TWO_DIGIT_YEAR_CUTOFF'; -TYPE: 'TYPE'; -TYPEPROPERTY: 'TYPEPROPERTY'; -TYPE_ID: 'TYPE_ID'; -TYPE_NAME: 'TYPE_NAME'; -TYPE_WARNING: 'TYPE_WARNING'; -UNBOUNDED: 'UNBOUNDED'; -UNCHECKED: 'UNCHECKED'; -UNCOMMITTED: 'UNCOMMITTED'; -UNICODE: 'UNICODE'; -UNION: 'UNION'; -UNIQUE: 'UNIQUE'; -UNKNOWN: 'UNKNOWN'; -UNLIMITED: 'UNLIMITED'; -UNLOCK: 'UNLOCK'; -UNMASK: 'UNMASK'; -UNPIVOT: 'UNPIVOT'; -UNSAFE: 'UNSAFE'; -UOW: 'UOW'; -UPDATE: 'UPDATE'; -UPDATETEXT: 'UPDATETEXT'; -UPDLOCK: 'UPDLOCK'; -UPPER: 'UPPER'; -URL: 'URL'; -USE: 'USE'; -USED: 'USED'; -USER: 'USER'; -USER_ID: 'USER_ID'; -USER_NAME: 'USER_NAME'; -USING: 'USING'; -VALIDATION: 'VALIDATION'; -VALID_XML: 'VALID_XML'; -VALUE: 'VALUE'; -VALUES: 'VALUES'; -VALUE_SQUARE_BRACKET: '[VALUE]'; -VAR: 'VAR'; -VARBINARY_KEYWORD: 'VARBINARY'; -VARP: 'VARP'; -VARYING: 'VARYING'; -VERBOSELOGGING: 'VERBOSELOGGING'; -VERIFY_CLONEDB: 'VERIFY_CLONEDB'; -VERSION: 'VERSION'; -VIEW: 'VIEW'; -VIEWS: 'VIEWS'; -VIEW_METADATA: 'VIEW_METADATA'; -VISIBILITY: 'VISIBILITY'; -WAIT: 'WAIT'; -WAITFOR: 'WAITFOR'; -WAIT_AT_LOW_PRIORITY: 'WAIT_AT_LOW_PRIORITY'; -WELL_FORMED_XML: 'WELL_FORMED_XML'; -WHEN: 'WHEN'; -WHERE: 'WHERE'; -WHILE: 'WHILE'; -WINDOWS: 'WINDOWS'; -WITH: 'WITH'; -WITHIN: 'WITHIN'; -WITHOUT: 'WITHOUT'; -WITHOUT_ARRAY_WRAPPER: 'WITHOUT_ARRAY_WRAPPER'; -WITNESS: 'WITNESS'; -WORK: 'WORK'; -WORKLOAD: 'WORKLOAD'; -WRITETEXT: 'WRITETEXT'; -XACT_ABORT: 'XACT_ABORT'; -XACT_STATE: 'XACT_STATE'; -XLOCK: 'XLOCK'; -XML: 'XML'; -XMLDATA: 'XMLDATA'; -XMLNAMESPACES: 'XMLNAMESPACES'; -XMLSCHEMA: 'XMLSCHEMA'; -XML_COMPRESSION: 'XML_COMPRESSION'; -XSINIL: 'XSINIL'; -ZONE: 'ZONE'; +ABORT : 'ABORT'; +ABORT_AFTER_WAIT : 'ABORT_AFTER_WAIT'; +ABSENT : 'ABSENT'; +ABSOLUTE : 'ABSOLUTE'; +ACCELERATED_DATABASE_RECOVERY : 'ACCELERATED_DATABASE_RECOVERY'; +ACCENT_SENSITIVITY : 'ACCENT_SENSITIVITY'; +ACCESS : 'ACCESS'; +ACTION : 'ACTION'; +ACTIVATION : 'ACTIVATION'; +ACTIVE : 'ACTIVE'; +ADD : 'ADD'; +ADDRESS : 'ADDRESS'; +ADMINISTER : 'ADMINISTER'; +AES : 'AES'; +AES_128 : 'AES_128'; +AES_192 : 'AES_192'; +AES_256 : 'AES_256'; +AFFINITY : 'AFFINITY'; +AFTER : 'AFTER'; +AGGREGATE : 'AGGREGATE'; +ALGORITHM : 'ALGORITHM'; +ALL : 'ALL'; +ALLOWED : 'ALLOWED'; +ALLOW_CONNECTIONS : 'ALLOW_CONNECTIONS'; +ALLOW_ENCRYPTED_VALUE_MODIFICATIONS : 'ALLOW_ENCRYPTED_VALUE_MODIFICATIONS'; +ALLOW_MULTIPLE_EVENT_LOSS : 'ALLOW_MULTIPLE_EVENT_LOSS'; +ALLOW_PAGE_LOCKS : 'ALLOW_PAGE_LOCKS'; +ALLOW_ROW_LOCKS : 'ALLOW_ROW_LOCKS'; +ALLOW_SINGLE_EVENT_LOSS : 'ALLOW_SINGLE_EVENT_LOSS'; +ALLOW_SNAPSHOT_ISOLATION : 'ALLOW_SNAPSHOT_ISOLATION'; +ALL_CONSTRAINTS : 'ALL_CONSTRAINTS'; +ALL_ERRORMSGS : 'ALL_ERRORMSGS'; +ALL_INDEXES : 'ALL_INDEXES'; +ALL_LEVELS : 'ALL_LEVELS'; +ALTER : 'ALTER'; +ALWAYS : 'ALWAYS'; +AND : 'AND'; +ANONYMOUS : 'ANONYMOUS'; +ANSI_DEFAULTS : 'ANSI_DEFAULTS'; +ANSI_NULLS : 'ANSI_NULLS'; +ANSI_NULL_DEFAULT : 'ANSI_NULL_DEFAULT'; +ANSI_NULL_DFLT_OFF : 'ANSI_NULL_DFLT_OFF'; +ANSI_NULL_DFLT_ON : 'ANSI_NULL_DFLT_ON'; +ANSI_PADDING : 'ANSI_PADDING'; +ANSI_WARNINGS : 'ANSI_WARNINGS'; +ANY : 'ANY'; +APPEND : 'APPEND'; +APPLICATION : 'APPLICATION'; +APPLICATION_LOG : 'APPLICATION_LOG'; +APPLOCK_MODE : 'APPLOCK_MODE'; +APPLOCK_TEST : 'APPLOCK_TEST'; +APPLY : 'APPLY'; +APP_NAME : 'APP_NAME'; +ARITHABORT : 'ARITHABORT'; +ARITHIGNORE : 'ARITHIGNORE'; +AS : 'AS'; +ASC : 'ASC'; +ASCII : 'ASCII'; +ASSEMBLY : 'ASSEMBLY'; +ASSEMBLYPROPERTY : 'ASSEMBLYPROPERTY'; +ASYMMETRIC : 'ASYMMETRIC'; +ASYNCHRONOUS_COMMIT : 'ASYNCHRONOUS_COMMIT'; +AT_KEYWORD : 'AT'; +AUDIT : 'AUDIT'; +AUDIT_GUID : 'AUDIT_GUID'; +AUTHENTICATE : 'AUTHENTICATE'; +AUTHENTICATION : 'AUTHENTICATION'; +AUTHORIZATION : 'AUTHORIZATION'; +AUTO : 'AUTO'; +AUTOGROW_ALL_FILES : 'AUTOGROW_ALL_FILES'; +AUTOGROW_SINGLE_FILE : 'AUTOGROW_SINGLE_FILE'; +AUTOMATED_BACKUP_PREFERENCE : 'AUTOMATED_BACKUP_PREFERENCE'; +AUTOMATIC : 'AUTOMATIC'; +AUTO_CLEANUP : 'AUTO_CLEANUP'; +AUTO_CLOSE : 'AUTO_CLOSE'; +AUTO_CREATE_STATISTICS : 'AUTO_CREATE_STATISTICS'; +AUTO_DROP : 'AUTO_DROP'; +AUTO_SHRINK : 'AUTO_SHRINK'; +AUTO_UPDATE_STATISTICS : 'AUTO_UPDATE_STATISTICS'; +AUTO_UPDATE_STATISTICS_ASYNC : 'AUTO_UPDATE_STATISTICS_ASYNC'; +AVAILABILITY : 'AVAILABILITY'; +AVAILABILITY_MODE : 'AVAILABILITY_MODE'; +AVG : 'AVG'; +BACKSLASH : '\\'; +BACKUP : 'BACKUP'; +BACKUP_CLONEDB : 'BACKUP_CLONEDB'; +BACKUP_PRIORITY : 'BACKUP_PRIORITY'; +BASE64 : 'BASE64'; +BEFORE : 'BEFORE'; +BEGIN : 'BEGIN'; +BEGIN_DIALOG : 'BEGIN_DIALOG'; +BETWEEN : 'BETWEEN'; +BIGINT : 'BIGINT'; +BINARY_CHECKSUM : 'BINARY_CHECKSUM'; +BINARY_KEYWORD : 'BINARY'; +BINDING : 'BINDING'; +BLOB_STORAGE : 'BLOB_STORAGE'; +BLOCK : 'BLOCK'; +BLOCKERS : 'BLOCKERS'; +BLOCKING_HIERARCHY : 'BLOCKING_HIERARCHY'; +BLOCKSIZE : 'BLOCKSIZE'; +BREAK : 'BREAK'; +BROKER : 'BROKER'; +BROKER_INSTANCE : 'BROKER_INSTANCE'; +BROWSE : 'BROWSE'; +BUFFER : 'BUFFER'; +BUFFERCOUNT : 'BUFFERCOUNT'; +BULK : 'BULK'; +BULK_LOGGED : 'BULK_LOGGED'; +BY : 'BY'; +CACHE : 'CACHE'; +CALLED : 'CALLED'; +CALLER : 'CALLER'; +CAP_CPU_PERCENT : 'CAP_CPU_PERCENT'; +CASCADE : 'CASCADE'; +CASE : 'CASE'; +CAST : 'CAST'; +CATALOG : 'CATALOG'; +CATCH : 'CATCH'; +CERTENCODED : 'CERTENCODED'; +CERTIFICATE : 'CERTIFICATE'; +CERTPRIVATEKEY : 'CERTPRIVATEKEY'; +CERT_ID : 'CERT_ID'; +CHANGE : 'CHANGE'; +CHANGES : 'CHANGES'; +CHANGETABLE : 'CHANGETABLE'; +CHANGE_RETENTION : 'CHANGE_RETENTION'; +CHANGE_TRACKING : 'CHANGE_TRACKING'; +CHAR : 'CHAR'; +CHARINDEX : 'CHARINDEX'; +CHECK : 'CHECK'; +CHECKALLOC : 'CHECKALLOC'; +CHECKCATALOG : 'CHECKCATALOG'; +CHECKCONSTRAINTS : 'CHECKCONSTRAINTS'; +CHECKDB : 'CHECKDB'; +CHECKFILEGROUP : 'CHECKFILEGROUP'; +CHECKPOINT : 'CHECKPOINT'; +CHECKSUM : 'CHECKSUM'; +CHECKSUM_AGG : 'CHECKSUM_AGG'; +CHECKTABLE : 'CHECKTABLE'; +CHECK_EXPIRATION : 'CHECK_EXPIRATION'; +CHECK_POLICY : 'CHECK_POLICY'; +CLASSIFIER_FUNCTION : 'CLASSIFIER_FUNCTION'; +CLEANTABLE : 'CLEANTABLE'; +CLEANUP : 'CLEANUP'; +CLONEDATABASE : 'CLONEDATABASE'; +CLOSE : 'CLOSE'; +CLUSTER : 'CLUSTER'; +CLUSTERED : 'CLUSTERED'; +COALESCE : 'COALESCE'; +COLLATE : 'COLLATE'; +COLLECTION : 'COLLECTION'; +COLUMN : 'COLUMN'; +COLUMNPROPERTY : 'COLUMNPROPERTY'; +COLUMNS : 'COLUMNS'; +COLUMNSTORE : 'COLUMNSTORE'; +COLUMNSTORE_ARCHIVE : 'COLUMNSTORE_ARCHIVE'; +COLUMN_ENCRYPTION_KEY : 'COLUMN_ENCRYPTION_KEY'; +COLUMN_MASTER_KEY : 'COLUMN_MASTER_KEY'; +COL_LENGTH : 'COL_LENGTH'; +COL_NAME : 'COL_NAME'; +COMMIT : 'COMMIT'; +COMMITTED : 'COMMITTED'; +COMPATIBILITY_LEVEL : 'COMPATIBILITY_LEVEL'; +COMPRESS : 'COMPRESS'; +COMPRESSION : 'COMPRESSION'; +COMPRESSION_DELAY : 'COMPRESSION_DELAY'; +COMPRESS_ALL_ROW_GROUPS : 'COMPRESS_ALL_ROW_GROUPS'; +COMPUTE : 'COMPUTE'; +CONCAT : 'CONCAT'; +CONCAT_NULL_YIELDS_NULL : 'CONCAT_NULL_YIELDS_NULL'; +CONCAT_WS : 'CONCAT_WS'; +CONFIGURATION : 'CONFIGURATION'; +CONNECT : 'CONNECT'; +CONNECTION : 'CONNECTION'; +CONNECTIONPROPERTY : 'CONNECTIONPROPERTY'; +CONSTRAINT : 'CONSTRAINT'; +CONTAINMENT : 'CONTAINMENT'; +CONTAINS : 'CONTAINS'; +CONTAINSTABLE : 'CONTAINSTABLE'; +CONTENT : 'CONTENT'; +CONTEXT : 'CONTEXT'; +CONTEXT_INFO : 'CONTEXT_INFO'; +CONTINUE : 'CONTINUE'; +CONTINUE_AFTER_ERROR : 'CONTINUE_AFTER_ERROR'; +CONTRACT : 'CONTRACT'; +CONTRACT_NAME : 'CONTRACT_NAME'; +CONTROL : 'CONTROL'; +CONVERSATION : 'CONVERSATION'; +CONVERT : 'TRY_'? 'CONVERT'; +COOKIE : 'COOKIE'; +COPY_ONLY : 'COPY_ONLY'; +COUNT : 'COUNT'; +COUNTER : 'COUNTER'; +COUNT_BIG : 'COUNT_BIG'; +CPU : 'CPU'; +CREATE : 'CREATE'; +CREATE_NEW : 'CREATE_NEW'; +CREATION_DISPOSITION : 'CREATION_DISPOSITION'; +CREDENTIAL : 'CREDENTIAL'; +CROSS : 'CROSS'; +CRYPTOGRAPHIC : 'CRYPTOGRAPHIC'; +CUME_DIST : 'CUME_DIST'; +CURRENT : 'CURRENT'; +CURRENT_DATE : 'CURRENT_DATE'; +CURRENT_REQUEST_ID : 'CURRENT_REQUEST_ID'; +CURRENT_TIME : 'CURRENT_TIME'; +CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP'; +CURRENT_TRANSACTION_ID : 'CURRENT_TRANSACTION_ID'; +CURRENT_USER : 'CURRENT_USER'; +CURSOR : 'CURSOR'; +CURSOR_CLOSE_ON_COMMIT : 'CURSOR_CLOSE_ON_COMMIT'; +CURSOR_DEFAULT : 'CURSOR_DEFAULT'; +CURSOR_STATUS : 'CURSOR_STATUS'; +CYCLE : 'CYCLE'; +DATA : 'DATA'; +DATABASE : 'DATABASE'; +DATABASEPROPERTYEX : 'DATABASEPROPERTYEX'; +DATABASE_MIRRORING : 'DATABASE_MIRRORING'; +DATABASE_PRINCIPAL_ID : 'DATABASE_PRINCIPAL_ID'; +DATALENGTH : 'DATALENGTH'; +DATASPACE : 'DATASPACE'; +DATA_COMPRESSION : 'DATA_COMPRESSION'; +DATA_PURITY : 'DATA_PURITY'; +DATA_SOURCE : 'DATA_SOURCE'; +DATEADD : 'DATEADD'; +DATEDIFF : 'DATEDIFF'; +DATENAME : 'DATENAME'; +DATEPART : 'DATEPART'; +DATE_CORRELATION_OPTIMIZATION : 'DATE_CORRELATION_OPTIMIZATION'; +DAYS : 'DAYS'; +DBCC : 'DBCC'; +DBREINDEX : 'DBREINDEX'; +DB_CHAINING : 'DB_CHAINING'; +DB_FAILOVER : 'DB_FAILOVER'; +DB_ID : 'DB_ID'; +DB_NAME : 'DB_NAME'; +DDL : 'DDL'; +DEALLOCATE : 'DEALLOCATE'; +DECLARE : 'DECLARE'; +DECOMPRESS : 'DECOMPRESS'; +DECRYPTION : 'DECRYPTION'; +DEFAULT : 'DEFAULT'; +DEFAULT_DATABASE : 'DEFAULT_DATABASE'; +DEFAULT_DOUBLE_QUOTE : ["]'DEFAULT' ["]; +DEFAULT_FULLTEXT_LANGUAGE : 'DEFAULT_FULLTEXT_LANGUAGE'; +DEFAULT_LANGUAGE : 'DEFAULT_LANGUAGE'; +DEFAULT_SCHEMA : 'DEFAULT_SCHEMA'; +DEFINITION : 'DEFINITION'; +DELAY : 'DELAY'; +DELAYED_DURABILITY : 'DELAYED_DURABILITY'; +DELETE : 'DELETE'; +DELETED : 'DELETED'; +DENSE_RANK : 'DENSE_RANK'; +DENY : 'DENY'; +DEPENDENTS : 'DEPENDENTS'; +DES : 'DES'; +DESC : 'DESC'; +DESCRIPTION : 'DESCRIPTION'; +DESX : 'DESX'; +DETERMINISTIC : 'DETERMINISTIC'; +DHCP : 'DHCP'; +DIAGNOSTICS : 'DIAGNOSTICS'; +DIALOG : 'DIALOG'; +DIFFERENCE : 'DIFFERENCE'; +DIFFERENTIAL : 'DIFFERENTIAL'; +DIRECTORY_NAME : 'DIRECTORY_NAME'; +DISABLE : 'DISABLE'; +DISABLED : 'DISABLED'; +DISABLE_BROKER : 'DISABLE_BROKER'; +DISK : 'DISK'; +DISTINCT : 'DISTINCT'; +DISTRIBUTED : 'DISTRIBUTED'; +DISTRIBUTION : 'DISTRIBUTION'; +DOCUMENT : 'DOCUMENT'; +DOLLAR_PARTITION : '$PARTITION'; +DOUBLE : 'DOUBLE'; +DOUBLE_BACK_SLASH : '\\\\'; +DOUBLE_FORWARD_SLASH : '//'; +DROP : 'DROP'; +DROPCLEANBUFFERS : 'DROPCLEANBUFFERS'; +DROP_EXISTING : 'DROP_EXISTING'; +DTC_SUPPORT : 'DTC_SUPPORT'; +DUMP : 'DUMP'; +DYNAMIC : 'DYNAMIC'; +ELEMENTS : 'ELEMENTS'; +ELSE : 'ELSE'; +EMERGENCY : 'EMERGENCY'; +EMPTY : 'EMPTY'; +ENABLE : 'ENABLE'; +ENABLED : 'ENABLED'; +ENABLE_BROKER : 'ENABLE_BROKER'; +ENCRYPTED : 'ENCRYPTED'; +ENCRYPTED_VALUE : 'ENCRYPTED_VALUE'; +ENCRYPTION : 'ENCRYPTION'; +ENCRYPTION_TYPE : 'ENCRYPTION_TYPE'; +END : 'END'; +ENDPOINT : 'ENDPOINT'; +ENDPOINT_URL : 'ENDPOINT_URL'; +ERRLVL : 'ERRLVL'; +ERROR : 'ERROR'; +ERROR_BROKER_CONVERSATIONS : 'ERROR_BROKER_CONVERSATIONS'; +ERROR_LINE : 'ERROR_LINE'; +ERROR_MESSAGE : 'ERROR_MESSAGE'; +ERROR_NUMBER : 'ERROR_NUMBER'; +ERROR_PROCEDURE : 'ERROR_PROCEDURE'; +ERROR_SEVERITY : 'ERROR_SEVERITY'; +ERROR_STATE : 'ERROR_STATE'; +ESCAPE : 'ESCAPE'; +ESTIMATEONLY : 'ESTIMATEONLY'; +EVENT : 'EVENT'; +EVENTDATA : 'EVENTDATA'; +EVENT_RETENTION_MODE : 'EVENT_RETENTION_MODE'; +EXCEPT : 'EXCEPT'; +EXCLUSIVE : 'EXCLUSIVE'; +EXECUTABLE : 'EXECUTABLE'; +EXECUTABLE_FILE : 'EXECUTABLE_FILE'; +EXECUTE : 'EXEC' 'UTE'?; +EXIST : 'EXIST'; +EXISTS : 'EXISTS'; +EXIST_SQUARE_BRACKET : '[EXIST]'; +EXIT : 'EXIT'; +EXPAND : 'EXPAND'; +EXPIREDATE : 'EXPIREDATE'; +EXPIRY_DATE : 'EXPIRY_DATE'; +EXPLICIT : 'EXPLICIT'; +EXTENDED_LOGICAL_CHECKS : 'EXTENDED_LOGICAL_CHECKS'; +EXTENSION : 'EXTENSION'; +EXTERNAL : 'EXTERNAL'; +EXTERNAL_ACCESS : 'EXTERNAL_ACCESS'; +FAILOVER : 'FAILOVER'; +FAILOVER_MODE : 'FAILOVER_MODE'; +FAILURE : 'FAILURE'; +FAILURECONDITIONLEVEL : 'FAILURECONDITIONLEVEL'; +FAILURE_CONDITION_LEVEL : 'FAILURE_CONDITION_LEVEL'; +FAIL_OPERATION : 'FAIL_OPERATION'; +FAN_IN : 'FAN_IN'; +FAST : 'FAST'; +FAST_FORWARD : 'FAST_FORWARD'; +FETCH : 'FETCH'; +FILE : 'FILE'; +FILEGROUP : 'FILEGROUP'; +FILEGROUPPROPERTY : 'FILEGROUPPROPERTY'; +FILEGROUP_ID : 'FILEGROUP_ID'; +FILEGROUP_NAME : 'FILEGROUP_NAME'; +FILEGROWTH : 'FILEGROWTH'; +FILENAME : 'FILENAME'; +FILEPATH : 'FILEPATH'; +FILEPROPERTY : 'FILEPROPERTY'; +FILEPROPERTYEX : 'FILEPROPERTYEX'; +FILESTREAM : 'FILESTREAM'; +FILESTREAM_ON : 'FILESTREAM_ON'; +FILE_ID : 'FILE_ID'; +FILE_IDEX : 'FILE_IDEX'; +FILE_NAME : 'FILE_NAME'; +FILE_SNAPSHOT : 'FILE_SNAPSHOT'; +FILLFACTOR : 'FILLFACTOR'; +FILTER : 'FILTER'; +FIRST : 'FIRST'; +FIRST_VALUE : 'FIRST_VALUE'; +FMTONLY : 'FMTONLY'; +FOLLOWING : 'FOLLOWING'; +FOR : 'FOR'; +FORCE : 'FORCE'; +FORCED : 'FORCED'; +FORCEPLAN : 'FORCEPLAN'; +FORCESCAN : 'FORCESCAN'; +FORCESEEK : 'FORCESEEK'; +FORCE_FAILOVER_ALLOW_DATA_LOSS : 'FORCE_FAILOVER_ALLOW_DATA_LOSS'; +FORCE_SERVICE_ALLOW_DATA_LOSS : 'FORCE_SERVICE_ALLOW_DATA_LOSS'; +FOREIGN : 'FOREIGN'; +FORMAT : 'FORMAT'; +FORMATMESSAGE : 'FORMATMESSAGE'; +FORWARD_ONLY : 'FORWARD_ONLY'; +FREE : 'FREE'; +FREETEXT : 'FREETEXT'; +FREETEXTTABLE : 'FREETEXTTABLE'; +FROM : 'FROM'; +FULL : 'FULL'; +FULLSCAN : 'FULLSCAN'; +FULLTEXT : 'FULLTEXT'; +FULLTEXTCATALOGPROPERTY : 'FULLTEXTCATALOGPROPERTY'; +FULLTEXTSERVICEPROPERTY : 'FULLTEXTSERVICEPROPERTY'; +FUNCTION : 'FUNCTION'; +GB : 'GB'; +GENERATED : 'GENERATED'; +GET : 'GET'; +GETANCESTOR : 'GETANCESTOR'; +GETANSINULL : 'GETANSINULL'; +GETDATE : 'GETDATE'; +GETDESCENDANT : 'GETDESCENDANT'; +GETLEVEL : 'GETLEVEL'; +GETREPARENTEDVALUE : 'GETREPARENTEDVALUE'; +GETROOT : 'GETROOT'; +GETUTCDATE : 'GETUTCDATE'; +GET_FILESTREAM_TRANSACTION_CONTEXT : 'GET_FILESTREAM_TRANSACTION_CONTEXT'; +GLOBAL : 'GLOBAL'; +GO : 'GO'; +GOTO : 'GOTO'; +GOVERNOR : 'GOVERNOR'; +GRANT : 'GRANT'; +GREATEST : 'GREATEST'; +GROUP : 'GROUP'; +GROUPING : 'GROUPING'; +GROUPING_ID : 'GROUPING_ID'; +GROUP_MAX_REQUESTS : 'GROUP_MAX_REQUESTS'; +HADR : 'HADR'; +HASH : 'HASH'; +HASHED : 'HASHED'; +HAS_DBACCESS : 'HAS_DBACCESS'; +HAS_PERMS_BY_NAME : 'HAS_PERMS_BY_NAME'; +HAVING : 'HAVING'; +HEALTHCHECKTIMEOUT : 'HEALTHCHECKTIMEOUT'; +HEALTH_CHECK_TIMEOUT : 'HEALTH_CHECK_TIMEOUT'; +HEAP : 'HEAP'; +HIDDEN_KEYWORD : 'HIDDEN'; +HIERARCHYID : 'HIERARCHYID'; +HIGH : 'HIGH'; +HOLDLOCK : 'HOLDLOCK'; +HONOR_BROKER_PRIORITY : 'HONOR_BROKER_PRIORITY'; +HOST_ID : 'HOST_ID'; +HOST_NAME : 'HOST_NAME'; +HOURS : 'HOURS'; +IDENTITY : 'IDENTITY'; +IDENTITYCOL : 'IDENTITYCOL'; +IDENTITY_INSERT : 'IDENTITY_INSERT'; +IDENTITY_VALUE : 'IDENTITY_VALUE'; +IDENT_CURRENT : 'IDENT_CURRENT'; +IDENT_INCR : 'IDENT_INCR'; +IDENT_SEED : 'IDENT_SEED'; +IF : 'IF'; +IGNORE_CONSTRAINTS : 'IGNORE_CONSTRAINTS'; +IGNORE_DUP_KEY : 'IGNORE_DUP_KEY'; +IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX : 'IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX'; +IGNORE_REPLICATED_TABLE_CACHE : 'IGNORE_REPLICATED_TABLE_CACHE'; +IGNORE_TRIGGERS : 'IGNORE_TRIGGERS'; +IIF : 'IIF'; +IMMEDIATE : 'IMMEDIATE'; +IMPERSONATE : 'IMPERSONATE'; +IMPLICIT_TRANSACTIONS : 'IMPLICIT_TRANSACTIONS'; +IMPORTANCE : 'IMPORTANCE'; +IN : 'IN'; +INCLUDE : 'INCLUDE'; +INCLUDE_NULL_VALUES : 'INCLUDE_NULL_VALUES'; +INCREMENT : 'INCREMENT'; +INCREMENTAL : 'INCREMENTAL'; +INDEX : 'INDEX'; +INDEXKEY_PROPERTY : 'INDEXKEY_PROPERTY'; +INDEXPROPERTY : 'INDEXPROPERTY'; +INDEX_COL : 'INDEX_COL'; +INFINITE : 'INFINITE'; +INIT : 'INIT'; +INITIATOR : 'INITIATOR'; +INNER : 'INNER'; +INPUT : 'INPUT'; +INSENSITIVE : 'INSENSITIVE'; +INSERT : 'INSERT'; +INSERTED : 'INSERTED'; +INSTEAD : 'INSTEAD'; +INT : 'INT'; +INTERSECT : 'INTERSECT'; +INTO : 'INTO'; +IO : 'IO'; +IP : 'IP'; +IS : 'IS'; +ISDESCENDANTOF : 'ISDESCENDANTOF'; +ISJSON : 'ISJSON'; +ISNULL : 'ISNULL'; +ISNUMERIC : 'ISNUMERIC'; +ISOLATION : 'ISOLATION'; +IS_MEMBER : 'IS_MEMBER'; +IS_ROLEMEMBER : 'IS_ROLEMEMBER'; +IS_SRVROLEMEMBER : 'IS_SRVROLEMEMBER'; +JOB : 'JOB'; +JOIN : 'JOIN'; +JSON : 'JSON'; +JSON_ARRAY : 'JSON_ARRAY'; +JSON_MODIFY : 'JSON_MODIFY'; +JSON_OBJECT : 'JSON_OBJECT'; +JSON_PATH_EXISTS : 'JSON_PATH_EXISTS'; +JSON_QUERY : 'JSON_QUERY'; +JSON_VALUE : 'JSON_VALUE'; +KB : 'KB'; +KEEP : 'KEEP'; +KEEPDEFAULTS : 'KEEPDEFAULTS'; +KEEPFIXED : 'KEEPFIXED'; +KEEPIDENTITY : 'KEEPIDENTITY'; +KERBEROS : 'KERBEROS'; +KEY : 'KEY'; +KEYS : 'KEYS'; +KEYSET : 'KEYSET'; +KEY_PATH : 'KEY_PATH'; +KEY_SOURCE : 'KEY_SOURCE'; +KEY_STORE_PROVIDER_NAME : 'KEY_STORE_PROVIDER_NAME'; +KILL : 'KILL'; +LAG : 'LAG'; +LANGUAGE : 'LANGUAGE'; +LAST : 'LAST'; +LAST_VALUE : 'LAST_VALUE'; +LEAD : 'LEAD'; +LEAST : 'LEAST'; +LEFT : 'LEFT'; +LEN : 'LEN'; +LEVEL : 'LEVEL'; +LIBRARY : 'LIBRARY'; +LIFETIME : 'LIFETIME'; +LIKE : 'LIKE'; +LINENO : 'LINENO'; +LINKED : 'LINKED'; +LINUX : 'LINUX'; +LIST : 'LIST'; +LISTENER : 'LISTENER'; +LISTENER_IP : 'LISTENER_IP'; +LISTENER_PORT : 'LISTENER_PORT'; +LISTENER_URL : 'LISTENER_URL'; +LOAD : 'LOAD'; +LOB_COMPACTION : 'LOB_COMPACTION'; +LOCAL : 'LOCAL'; +LOCAL_SERVICE_NAME : 'LOCAL_SERVICE_NAME'; +LOCATION : 'LOCATION'; +LOCK : 'LOCK'; +LOCK_ESCALATION : 'LOCK_ESCALATION'; +LOG : 'LOG'; +LOGIN : 'LOGIN'; +LOGINPROPERTY : 'LOGINPROPERTY'; +LOOP : 'LOOP'; +LOW : 'LOW'; +LOWER : 'LOWER'; +LTRIM : 'LTRIM'; +MANUAL : 'MANUAL'; +MARK : 'MARK'; +MASK : 'MASK'; +MASKED : 'MASKED'; +MASTER : 'MASTER'; +MATCHED : 'MATCHED'; +MATERIALIZED : 'MATERIALIZED'; +MAX : 'MAX'; +MAXDOP : 'MAXDOP'; +MAXRECURSION : 'MAXRECURSION'; +MAXSIZE : 'MAXSIZE'; +MAXTRANSFER : 'MAXTRANSFER'; +MAXVALUE : 'MAXVALUE'; +MAX_CPU_PERCENT : 'MAX_CPU_PERCENT'; +MAX_DISPATCH_LATENCY : 'MAX_DISPATCH_LATENCY'; +MAX_DOP : 'MAX_DOP'; +MAX_DURATION : 'MAX_DURATION'; +MAX_EVENT_SIZE : 'MAX_EVENT_SIZE'; +MAX_FILES : 'MAX_FILES'; +MAX_IOPS_PER_VOLUME : 'MAX_IOPS_PER_VOLUME'; +MAX_MEMORY : 'MAX_MEMORY'; +MAX_MEMORY_PERCENT : 'MAX_MEMORY_PERCENT'; +MAX_OUTSTANDING_IO_PER_VOLUME : 'MAX_OUTSTANDING_IO_PER_VOLUME'; +MAX_PROCESSES : 'MAX_PROCESSES'; +MAX_QUEUE_READERS : 'MAX_QUEUE_READERS'; +MAX_ROLLOVER_FILES : 'MAX_ROLLOVER_FILES'; +MAX_SIZE : 'MAX_SIZE'; +MB : 'MB'; +MEDIADESCRIPTION : 'MEDIADESCRIPTION'; +MEDIANAME : 'MEDIANAME'; +MEDIUM : 'MEDIUM'; +MEMBER : 'MEMBER'; +MEMORY_OPTIMIZED_DATA : 'MEMORY_OPTIMIZED_DATA'; +MEMORY_PARTITION_MODE : 'MEMORY_PARTITION_MODE'; +MERGE : 'MERGE'; +MESSAGE : 'MESSAGE'; +MESSAGE_FORWARDING : 'MESSAGE_FORWARDING'; +MESSAGE_FORWARD_SIZE : 'MESSAGE_FORWARD_SIZE'; +MIN : 'MIN'; +MINUTES : 'MINUTES'; +MINVALUE : 'MINVALUE'; +MIN_ACTIVE_ROWVERSION : 'MIN_ACTIVE_ROWVERSION'; +MIN_CPU_PERCENT : 'MIN_CPU_PERCENT'; +MIN_IOPS_PER_VOLUME : 'MIN_IOPS_PER_VOLUME'; +MIN_MEMORY_PERCENT : 'MIN_MEMORY_PERCENT'; +MIRROR : 'MIRROR'; +MIRROR_ADDRESS : 'MIRROR_ADDRESS'; +MIXED_PAGE_ALLOCATION : 'MIXED_PAGE_ALLOCATION'; +MODE : 'MODE'; +MODIFY : 'MODIFY'; +MODIFY_SQUARE_BRACKET : '[MODIFY]'; +MOVE : 'MOVE'; +MULTI_USER : 'MULTI_USER'; +MUST_CHANGE : 'MUST_CHANGE'; +NAME : 'NAME'; +NATIONAL : 'NATIONAL'; +NCHAR : 'NCHAR'; +NEGOTIATE : 'NEGOTIATE'; +NESTED_TRIGGERS : 'NESTED_TRIGGERS'; +NEWID : 'NEWID'; +NEWNAME : 'NEWNAME'; +NEWSEQUENTIALID : 'NEWSEQUENTIALID'; +NEW_ACCOUNT : 'NEW_ACCOUNT'; +NEW_BROKER : 'NEW_BROKER'; +NEW_PASSWORD : 'NEW_PASSWORD'; +NEXT : 'NEXT'; +NO : 'NO'; +NOCHECK : 'NOCHECK'; +NOCOUNT : 'NOCOUNT'; +NODES : 'NODES'; +NOEXEC : 'NOEXEC'; +NOEXPAND : 'NOEXPAND'; +NOFORMAT : 'NOFORMAT'; +NOHOLDLOCK : 'NOHOLDLOCK'; +NOINDEX : 'NOINDEX'; +NOINIT : 'NOINIT'; +NOLOCK : 'NOLOCK'; +NONCLUSTERED : 'NONCLUSTERED'; +NONE : 'NONE'; +NON_TRANSACTED_ACCESS : 'NON_TRANSACTED_ACCESS'; +NORECOMPUTE : 'NORECOMPUTE'; +NORECOVERY : 'NORECOVERY'; +NOREWIND : 'NOREWIND'; +NOSKIP : 'NOSKIP'; +NOT : 'NOT'; +NOTIFICATION : 'NOTIFICATION'; +NOTIFICATIONS : 'NOTIFICATIONS'; +NOUNLOAD : 'NOUNLOAD'; +NOWAIT : 'NOWAIT'; +NO_CHECKSUM : 'NO_CHECKSUM'; +NO_COMPRESSION : 'NO_COMPRESSION'; +NO_EVENT_LOSS : 'NO_EVENT_LOSS'; +NO_INFOMSGS : 'NO_INFOMSGS'; +NO_QUERYSTORE : 'NO_QUERYSTORE'; +NO_STATISTICS : 'NO_STATISTICS'; +NO_TRUNCATE : 'NO_TRUNCATE'; +NO_WAIT : 'NO_WAIT'; +NTILE : 'NTILE'; +NTLM : 'NTLM'; +NULLIF : 'NULLIF'; +NULL_ : 'NULL'; +NULL_DOUBLE_QUOTE : ["]'NULL' ["]; +NUMANODE : 'NUMANODE'; +NUMBER : 'NUMBER'; +NUMERIC_ROUNDABORT : 'NUMERIC_ROUNDABORT'; +OBJECT : 'OBJECT'; +OBJECTPROPERTY : 'OBJECTPROPERTY'; +OBJECTPROPERTYEX : 'OBJECTPROPERTYEX'; +OBJECT_DEFINITION : 'OBJECT_DEFINITION'; +OBJECT_ID : 'OBJECT_ID'; +OBJECT_NAME : 'OBJECT_NAME'; +OBJECT_SCHEMA_NAME : 'OBJECT_SCHEMA_NAME'; +OF : 'OF'; +OFF : 'OFF'; +OFFLINE : 'OFFLINE'; +OFFSET : 'OFFSET'; +OFFSETS : 'OFFSETS'; +OLD_ACCOUNT : 'OLD_ACCOUNT'; +OLD_PASSWORD : 'OLD_PASSWORD'; +ON : 'ON'; +ONLINE : 'ONLINE'; +ONLY : 'ONLY'; +ON_FAILURE : 'ON_FAILURE'; +OPEN : 'OPEN'; +OPENDATASOURCE : 'OPENDATASOURCE'; +OPENJSON : 'OPENJSON'; +OPENQUERY : 'OPENQUERY'; +OPENROWSET : 'OPENROWSET'; +OPENXML : 'OPENXML'; +OPEN_EXISTING : 'OPEN_EXISTING'; +OPERATIONS : 'OPERATIONS'; +OPTIMISTIC : 'OPTIMISTIC'; +OPTIMIZE : 'OPTIMIZE'; +OPTIMIZE_FOR_SEQUENTIAL_KEY : 'OPTIMIZE_FOR_SEQUENTIAL_KEY'; +OPTION : 'OPTION'; +OR : 'OR'; +ORDER : 'ORDER'; +ORIGINAL_DB_NAME : 'ORIGINAL_DB_NAME'; +ORIGINAL_LOGIN : 'ORIGINAL_LOGIN'; +OUT : 'OUT'; +OUTER : 'OUTER'; +OUTPUT : 'OUTPUT'; +OVER : 'OVER'; +OVERRIDE : 'OVERRIDE'; +OWNER : 'OWNER'; +OWNERSHIP : 'OWNERSHIP'; +PAD_INDEX : 'PAD_INDEX'; +PAGE : 'PAGE'; +PAGECOUNT : 'PAGECOUNT'; +PAGE_VERIFY : 'PAGE_VERIFY'; +PAGLOCK : 'PAGLOCK'; +PARAMETERIZATION : 'PARAMETERIZATION'; +PARAM_NODE : 'PARAM_NODE'; +PARSE : 'TRY_'? 'PARSE'; +PARSENAME : 'PARSENAME'; +PARSEONLY : 'PARSEONLY'; +PARTIAL : 'PARTIAL'; +PARTITION : 'PARTITION'; +PARTITIONS : 'PARTITIONS'; +PARTNER : 'PARTNER'; +PASSWORD : 'PASSWORD'; +PATH : 'PATH'; +PATINDEX : 'PATINDEX'; +PAUSE : 'PAUSE'; +PDW_SHOWSPACEUSED : 'PDW_SHOWSPACEUSED'; +PERCENT : 'PERCENT'; +PERCENTILE_CONT : 'PERCENTILE_CONT'; +PERCENTILE_DISC : 'PERCENTILE_DISC'; +PERCENT_RANK : 'PERCENT_RANK'; +PERMISSIONS : 'PERMISSIONS'; +PERMISSION_SET : 'PERMISSION_SET'; +PERSISTED : 'PERSISTED'; +PERSIST_SAMPLE_PERCENT : 'PERSIST_SAMPLE_PERCENT'; +PER_CPU : 'PER_CPU'; +PER_DB : 'PER_DB'; +PER_NODE : 'PER_NODE'; +PHYSICAL_ONLY : 'PHYSICAL_ONLY'; +PIVOT : 'PIVOT'; +PLAN : 'PLAN'; +PLATFORM : 'PLATFORM'; +POISON_MESSAGE_HANDLING : 'POISON_MESSAGE_HANDLING'; +POLICY : 'POLICY'; +POOL : 'POOL'; +PORT : 'PORT'; +PRECEDING : 'PRECEDING'; +PRECISION : 'PRECISION'; +PREDICATE : 'PREDICATE'; +PRIMARY : 'PRIMARY'; +PRIMARY_ROLE : 'PRIMARY_ROLE'; +PRINT : 'PRINT'; +PRIOR : 'PRIOR'; +PRIORITY : 'PRIORITY'; +PRIORITY_LEVEL : 'PRIORITY_LEVEL'; +PRIVATE : 'PRIVATE'; +PRIVATE_KEY : 'PRIVATE_KEY'; +PRIVILEGES : 'PRIVILEGES'; +PROC : 'PROC'; +PROCCACHE : 'PROCCACHE'; +PROCEDURE : 'PROCEDURE'; +PROCEDURE_NAME : 'PROCEDURE_NAME'; +PROCESS : 'PROCESS'; +PROFILE : 'PROFILE'; +PROPERTY : 'PROPERTY'; +PROVIDER : 'PROVIDER'; +PROVIDER_KEY_NAME : 'PROVIDER_KEY_NAME'; +PUBLIC : 'PUBLIC'; +PWDCOMPARE : 'PWDCOMPARE'; +PWDENCRYPT : 'PWDENCRYPT'; +PYTHON : 'PYTHON'; +QUERY : 'QUERY'; +QUERY_SQUARE_BRACKET : '[QUERY]'; +QUEUE : 'QUEUE'; +QUEUE_DELAY : 'QUEUE_DELAY'; +QUOTED_IDENTIFIER : 'QUOTED_IDENTIFIER'; +QUOTENAME : 'QUOTENAME'; +R : 'R'; +RAISERROR : 'RAISERROR'; +RANDOMIZED : 'RANDOMIZED'; +RANGE : 'RANGE'; +RANK : 'RANK'; +RAW : 'RAW'; +RC2 : 'RC2'; +RC4 : 'RC4'; +RC4_128 : 'RC4_128'; +READ : 'READ'; +READCOMMITTED : 'READCOMMITTED'; +READCOMMITTEDLOCK : 'READCOMMITTEDLOCK'; +READONLY : 'READONLY'; +READPAST : 'READPAST'; +READTEXT : 'READTEXT'; +READUNCOMMITTED : 'READUNCOMMITTED'; +READWRITE : 'READWRITE'; +READ_COMMITTED_SNAPSHOT : 'READ_COMMITTED_SNAPSHOT'; +READ_ONLY : 'READ_ONLY'; +READ_ONLY_ROUTING_LIST : 'READ_ONLY_ROUTING_LIST'; +READ_WRITE : 'READ_WRITE'; +READ_WRITE_FILEGROUPS : 'READ_WRITE_FILEGROUPS'; +REBUILD : 'REBUILD'; +RECEIVE : 'RECEIVE'; +RECOMPILE : 'RECOMPILE'; +RECONFIGURE : 'RECONFIGURE'; +RECOVERY : 'RECOVERY'; +RECURSIVE_TRIGGERS : 'RECURSIVE_TRIGGERS'; +REFERENCES : 'REFERENCES'; +REGENERATE : 'REGENERATE'; +RELATED_CONVERSATION : 'RELATED_CONVERSATION'; +RELATED_CONVERSATION_GROUP : 'RELATED_CONVERSATION_GROUP'; +RELATIVE : 'RELATIVE'; +REMOTE : 'REMOTE'; +REMOTE_PROC_TRANSACTIONS : 'REMOTE_PROC_TRANSACTIONS'; +REMOTE_SERVICE_NAME : 'REMOTE_SERVICE_NAME'; +REMOVE : 'REMOVE'; +REORGANIZE : 'REORGANIZE'; +REPAIR_ALLOW_DATA_LOSS : 'REPAIR_ALLOW_DATA_LOSS'; +REPAIR_FAST : 'REPAIR_FAST'; +REPAIR_REBUILD : 'REPAIR_REBUILD'; +REPEATABLE : 'REPEATABLE'; +REPEATABLEREAD : 'REPEATABLEREAD'; +REPLACE : 'REPLACE'; +REPLICA : 'REPLICA'; +REPLICATE : 'REPLICATE'; +REPLICATION : 'REPLICATION'; +REQUEST_MAX_CPU_TIME_SEC : 'REQUEST_MAX_CPU_TIME_SEC'; +REQUEST_MAX_MEMORY_GRANT_PERCENT : 'REQUEST_MAX_MEMORY_GRANT_PERCENT'; +REQUEST_MEMORY_GRANT_TIMEOUT_SEC : 'REQUEST_MEMORY_GRANT_TIMEOUT_SEC'; +REQUIRED : 'REQUIRED'; +REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT : 'REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT'; +RESAMPLE : 'RESAMPLE'; +RESERVE_DISK_SPACE : 'RESERVE_DISK_SPACE'; +RESET : 'RESET'; +RESOURCE : 'RESOURCE'; +RESOURCES : 'RESOURCES'; +RESOURCE_MANAGER_LOCATION : 'RESOURCE_MANAGER_LOCATION'; +RESTART : 'RESTART'; +RESTORE : 'RESTORE'; +RESTRICT : 'RESTRICT'; +RESTRICTED_USER : 'RESTRICTED_USER'; +RESUMABLE : 'RESUMABLE'; +RESUME : 'RESUME'; +RETAINDAYS : 'RETAINDAYS'; +RETENTION : 'RETENTION'; +RETURN : 'RETURN'; +RETURNS : 'RETURNS'; +REVERSE : 'REVERSE'; +REVERT : 'REVERT'; +REVOKE : 'REVOKE'; +REWIND : 'REWIND'; +RIGHT : 'RIGHT'; +ROBUST : 'ROBUST'; +ROLE : 'ROLE'; +ROLLBACK : 'ROLLBACK'; +ROOT : 'ROOT'; +ROUND_ROBIN : 'ROUND_ROBIN'; +ROUTE : 'ROUTE'; +ROW : 'ROW'; +ROWCOUNT : 'ROWCOUNT'; +ROWCOUNT_BIG : 'ROWCOUNT_BIG'; +ROWGUID : 'ROWGUID'; +ROWGUIDCOL : 'ROWGUIDCOL'; +ROWLOCK : 'ROWLOCK'; +ROWS : 'ROWS'; +ROW_NUMBER : 'ROW_NUMBER'; +RSA_1024 : 'RSA_1024'; +RSA_2048 : 'RSA_2048'; +RSA_3072 : 'RSA_3072'; +RSA_4096 : 'RSA_4096'; +RSA_512 : 'RSA_512'; +RTRIM : 'RTRIM'; +RULE : 'RULE'; +SAFE : 'SAFE'; +SAFETY : 'SAFETY'; +SAMPLE : 'SAMPLE'; +SAVE : 'SAVE'; +SCHEDULER : 'SCHEDULER'; +SCHEMA : 'SCHEMA'; +SCHEMABINDING : 'SCHEMABINDING'; +SCHEMA_ID : 'SCHEMA_ID'; +SCHEMA_NAME : 'SCHEMA_NAME'; +SCHEME : 'SCHEME'; +SCOPED : 'SCOPED'; +SCOPE_IDENTITY : 'SCOPE_IDENTITY'; +SCRIPT : 'SCRIPT'; +SCROLL : 'SCROLL'; +SCROLL_LOCKS : 'SCROLL_LOCKS'; +SEARCH : 'SEARCH'; +SECONDARY : 'SECONDARY'; +SECONDARY_ONLY : 'SECONDARY_ONLY'; +SECONDARY_ROLE : 'SECONDARY_ROLE'; +SECONDS : 'SECONDS'; +SECRET : 'SECRET'; +SECURABLES : 'SECURABLES'; +SECURITY : 'SECURITY'; +SECURITYAUDIT : 'SECURITYAUDIT'; +SECURITY_LOG : 'SECURITY_LOG'; +SEEDING_MODE : 'SEEDING_MODE'; +SELECT : 'SELECT'; +SELF : 'SELF'; +SEMANTICKEYPHRASETABLE : 'SEMANTICKEYPHRASETABLE'; +SEMANTICSIMILARITYDETAILSTABLE : 'SEMANTICSIMILARITYDETAILSTABLE'; +SEMANTICSIMILARITYTABLE : 'SEMANTICSIMILARITYTABLE'; +SEMI_SENSITIVE : 'SEMI_SENSITIVE'; +SEND : 'SEND'; +SENT : 'SENT'; +SEQUENCE : 'SEQUENCE'; +SEQUENCE_NUMBER : 'SEQUENCE_NUMBER'; +SERIALIZABLE : 'SERIALIZABLE'; +SERVER : 'SERVER'; +SERVERPROPERTY : 'SERVERPROPERTY'; +SERVICE : 'SERVICE'; +SERVICEBROKER : 'SERVICEBROKER'; +SERVICE_BROKER : 'SERVICE_BROKER'; +SERVICE_NAME : 'SERVICE_NAME'; +SESSION : 'SESSION'; +SESSIONPROPERTY : 'SESSIONPROPERTY'; +SESSION_CONTEXT : 'SESSION_CONTEXT'; +SESSION_TIMEOUT : 'SESSION_TIMEOUT'; +SESSION_USER : 'SESSION_USER'; +SET : 'SET'; +SETERROR : 'SETERROR'; +SETS : 'SETS'; +SETTINGS : 'SETTINGS'; +SETUSER : 'SETUSER'; +SHARE : 'SHARE'; +SHARED : 'SHARED'; +SHOWCONTIG : 'SHOWCONTIG'; +SHOWPLAN : 'SHOWPLAN'; +SHOWPLAN_ALL : 'SHOWPLAN_ALL'; +SHOWPLAN_TEXT : 'SHOWPLAN_TEXT'; +SHOWPLAN_XML : 'SHOWPLAN_XML'; +SHRINKLOG : 'SHRINKLOG'; +SHUTDOWN : 'SHUTDOWN'; +SID : 'SID'; +SIGNATURE : 'SIGNATURE'; +SIMPLE : 'SIMPLE'; +SINGLE_USER : 'SINGLE_USER'; +SIZE : 'SIZE'; +SKIP_KEYWORD : 'SKIP'; +SMALLINT : 'SMALLINT'; +SNAPSHOT : 'SNAPSHOT'; +SOFTNUMA : 'SOFTNUMA'; +SOME : 'SOME'; +SORT_IN_TEMPDB : 'SORT_IN_TEMPDB'; +SOUNDEX : 'SOUNDEX'; +SOURCE : 'SOURCE'; +SPACE_KEYWORD : 'SPACE'; +SPARSE : 'SPARSE'; +SPATIAL_WINDOW_MAX_CELLS : 'SPATIAL_WINDOW_MAX_CELLS'; +SPECIFICATION : 'SPECIFICATION'; +SPLIT : 'SPLIT'; +SQL : 'SQL'; +SQLDUMPERFLAGS : 'SQLDUMPERFLAGS'; +SQLDUMPERPATH : 'SQLDUMPERPATH'; +SQLDUMPERTIMEOUT : 'SQLDUMPERTIMEOUT'; +SQL_VARIANT_PROPERTY : 'SQL_VARIANT_PROPERTY'; +STANDBY : 'STANDBY'; +START : 'START'; +STARTED : 'STARTED'; +STARTUP_STATE : 'STARTUP_STATE'; +START_DATE : 'START_DATE'; +STATE : 'STATE'; +STATIC : 'STATIC'; +STATISTICS : 'STATISTICS'; +STATISTICS_INCREMENTAL : 'STATISTICS_INCREMENTAL'; +STATISTICS_NORECOMPUTE : 'STATISTICS_NORECOMPUTE'; +STATS : 'STATS'; +STATS_DATE : 'STATS_DATE'; +STATS_STREAM : 'STATS_STREAM'; +STATUS : 'STATUS'; +STATUSONLY : 'STATUSONLY'; +STDEV : 'STDEV'; +STDEVP : 'STDEVP'; +STOP : 'STOP'; +STOPLIST : 'STOPLIST'; +STOPPED : 'STOPPED'; +STOP_ON_ERROR : 'STOP_ON_ERROR'; +STR : 'STR'; +STRING_AGG : 'STRING_AGG'; +STRING_ESCAPE : 'STRING_ESCAPE'; +STUFF : 'STUFF'; +SUBJECT : 'SUBJECT'; +SUBSCRIBE : 'SUBSCRIBE'; +SUBSCRIPTION : 'SUBSCRIPTION'; +SUBSTRING : 'SUBSTRING'; +SUM : 'SUM'; +SUPPORTED : 'SUPPORTED'; +SUSER_ID : 'SUSER_ID'; +SUSER_NAME : 'SUSER_NAME'; +SUSER_SID : 'SUSER_SID'; +SUSER_SNAME : 'SUSER_SNAME'; +SUSPEND : 'SUSPEND'; +SWITCH : 'SWITCH'; +SYMMETRIC : 'SYMMETRIC'; +SYNCHRONOUS_COMMIT : 'SYNCHRONOUS_COMMIT'; +SYNONYM : 'SYNONYM'; +SYSTEM : 'SYSTEM'; +SYSTEM_USER : 'SYSTEM_USER'; +TABLE : 'TABLE'; +TABLERESULTS : 'TABLERESULTS'; +TABLESAMPLE : 'TABLESAMPLE'; +TABLOCK : 'TABLOCK'; +TABLOCKX : 'TABLOCKX'; +TAKE : 'TAKE'; +TAPE : 'TAPE'; +TARGET : 'TARGET'; +TARGET_RECOVERY_TIME : 'TARGET_RECOVERY_TIME'; +TB : 'TB'; +TCP : 'TCP'; +TEXTIMAGE_ON : 'TEXTIMAGE_ON'; +TEXTSIZE : 'TEXTSIZE'; +THEN : 'THEN'; +THROW : 'THROW'; +TIES : 'TIES'; +TIME : 'TIME'; +TIMEOUT : 'TIMEOUT'; +TIMER : 'TIMER'; +TINYINT : 'TINYINT'; +TO : 'TO'; +TOP : 'TOP'; +TORN_PAGE_DETECTION : 'TORN_PAGE_DETECTION'; +TOSTRING : 'TOSTRING'; +TRACE : 'TRACE'; +TRACKING : 'TRACKING'; +TRACK_CAUSALITY : 'TRACK_CAUSALITY'; +TRAN : 'TRAN'; +TRANSACTION : 'TRANSACTION'; +TRANSACTION_ID : 'TRANSACTION_ID'; +TRANSFER : 'TRANSFER'; +TRANSFORM_NOISE_WORDS : 'TRANSFORM_NOISE_WORDS'; +TRANSLATE : 'TRANSLATE'; +TRIGGER : 'TRIGGER'; +TRIM : 'TRIM'; +TRIPLE_DES : 'TRIPLE_DES'; +TRIPLE_DES_3KEY : 'TRIPLE_DES_3KEY'; +TRUNCATE : 'TRUNCATE'; +TRUSTWORTHY : 'TRUSTWORTHY'; +TRY : 'TRY'; +TRY_CAST : 'TRY_CAST'; +TSEQUAL : 'TSEQUAL'; +TSQL : 'TSQL'; +TWO_DIGIT_YEAR_CUTOFF : 'TWO_DIGIT_YEAR_CUTOFF'; +TYPE : 'TYPE'; +TYPEPROPERTY : 'TYPEPROPERTY'; +TYPE_ID : 'TYPE_ID'; +TYPE_NAME : 'TYPE_NAME'; +TYPE_WARNING : 'TYPE_WARNING'; +UNBOUNDED : 'UNBOUNDED'; +UNCHECKED : 'UNCHECKED'; +UNCOMMITTED : 'UNCOMMITTED'; +UNICODE : 'UNICODE'; +UNION : 'UNION'; +UNIQUE : 'UNIQUE'; +UNKNOWN : 'UNKNOWN'; +UNLIMITED : 'UNLIMITED'; +UNLOCK : 'UNLOCK'; +UNMASK : 'UNMASK'; +UNPIVOT : 'UNPIVOT'; +UNSAFE : 'UNSAFE'; +UOW : 'UOW'; +UPDATE : 'UPDATE'; +UPDATETEXT : 'UPDATETEXT'; +UPDLOCK : 'UPDLOCK'; +UPPER : 'UPPER'; +URL : 'URL'; +USE : 'USE'; +USED : 'USED'; +USER : 'USER'; +USER_ID : 'USER_ID'; +USER_NAME : 'USER_NAME'; +USING : 'USING'; +VALIDATION : 'VALIDATION'; +VALID_XML : 'VALID_XML'; +VALUE : 'VALUE'; +VALUES : 'VALUES'; +VALUE_SQUARE_BRACKET : '[VALUE]'; +VAR : 'VAR'; +VARBINARY_KEYWORD : 'VARBINARY'; +VARP : 'VARP'; +VARYING : 'VARYING'; +VERBOSELOGGING : 'VERBOSELOGGING'; +VERIFY_CLONEDB : 'VERIFY_CLONEDB'; +VERSION : 'VERSION'; +VIEW : 'VIEW'; +VIEWS : 'VIEWS'; +VIEW_METADATA : 'VIEW_METADATA'; +VISIBILITY : 'VISIBILITY'; +WAIT : 'WAIT'; +WAITFOR : 'WAITFOR'; +WAIT_AT_LOW_PRIORITY : 'WAIT_AT_LOW_PRIORITY'; +WELL_FORMED_XML : 'WELL_FORMED_XML'; +WHEN : 'WHEN'; +WHERE : 'WHERE'; +WHILE : 'WHILE'; +WINDOWS : 'WINDOWS'; +WITH : 'WITH'; +WITHIN : 'WITHIN'; +WITHOUT : 'WITHOUT'; +WITHOUT_ARRAY_WRAPPER : 'WITHOUT_ARRAY_WRAPPER'; +WITNESS : 'WITNESS'; +WORK : 'WORK'; +WORKLOAD : 'WORKLOAD'; +WRITETEXT : 'WRITETEXT'; +XACT_ABORT : 'XACT_ABORT'; +XACT_STATE : 'XACT_STATE'; +XLOCK : 'XLOCK'; +XML : 'XML'; +XMLDATA : 'XMLDATA'; +XMLNAMESPACES : 'XMLNAMESPACES'; +XMLSCHEMA : 'XMLSCHEMA'; +XML_COMPRESSION : 'XML_COMPRESSION'; +XSINIL : 'XSINIL'; +ZONE : 'ZONE'; -ABS: 'ABS'; -ACOS: 'ACOS'; -ASIN: 'ASIN'; -ATAN: 'ATAN'; -ATN2: 'ATN2'; -CEILING: 'CEILING'; -COS: 'COS'; -COT: 'COT'; -DEGREES: 'DEGREES'; -EXP: 'EXP'; -FLOOR: 'FLOOR'; -LOG10: 'LOG10'; -PI: 'PI'; -POWER: 'POWER'; -RADIANS: 'RADIANS'; -RAND: 'RAND'; -ROUND: 'ROUND'; -SIGN: 'SIGN'; -SIN: 'SIN'; -SQRT: 'SQRT'; -SQUARE: 'SQUARE'; -TAN: 'TAN'; +ABS : 'ABS'; +ACOS : 'ACOS'; +ASIN : 'ASIN'; +ATAN : 'ATAN'; +ATN2 : 'ATN2'; +CEILING : 'CEILING'; +COS : 'COS'; +COT : 'COT'; +DEGREES : 'DEGREES'; +EXP : 'EXP'; +FLOOR : 'FLOOR'; +LOG10 : 'LOG10'; +PI : 'PI'; +POWER : 'POWER'; +RADIANS : 'RADIANS'; +RAND : 'RAND'; +ROUND : 'ROUND'; +SIGN : 'SIGN'; +SIN : 'SIN'; +SQRT : 'SQRT'; +SQUARE : 'SQUARE'; +TAN : 'TAN'; -CURRENT_TIMEZONE: 'CURRENT_TIMEZONE'; -CURRENT_TIMEZONE_ID: 'CURRENT_TIMEZONE_ID'; -DATE_BUCKET: 'DATE_BUCKET'; -DATEDIFF_BIG: 'DATEDIFF_BIG'; -DATEFROMPARTS: 'DATEFROMPARTS'; -DATETIME2FROMPARTS: 'DATETIME2FROMPARTS'; -DATETIMEFROMPARTS: 'DATETIMEFROMPARTS'; -DATETIMEOFFSETFROMPARTS: 'DATETIMEOFFSETFROMPARTS'; -DATETRUNC: 'DATETRUNC'; -DAY: 'DAY'; -EOMONTH: 'EOMONTH'; -ISDATE: 'ISDATE'; -MONTH: 'MONTH'; -SMALLDATETIMEFROMPARTS: 'SMALLDATETIMEFROMPARTS'; -SWITCHOFFSET: 'SWITCHOFFSET'; -SYSDATETIME: 'SYSDATETIME'; -SYSDATETIMEOFFSET: 'SYSDATETIMEOFFSET'; -SYSUTCDATETIME: 'SYSUTCDATETIME'; -TIMEFROMPARTS: 'TIMEFROMPARTS'; -TODATETIMEOFFSET: 'TODATETIMEOFFSET'; -YEAR: 'YEAR'; +CURRENT_TIMEZONE : 'CURRENT_TIMEZONE'; +CURRENT_TIMEZONE_ID : 'CURRENT_TIMEZONE_ID'; +DATE_BUCKET : 'DATE_BUCKET'; +DATEDIFF_BIG : 'DATEDIFF_BIG'; +DATEFROMPARTS : 'DATEFROMPARTS'; +DATETIME2FROMPARTS : 'DATETIME2FROMPARTS'; +DATETIMEFROMPARTS : 'DATETIMEFROMPARTS'; +DATETIMEOFFSETFROMPARTS : 'DATETIMEOFFSETFROMPARTS'; +DATETRUNC : 'DATETRUNC'; +DAY : 'DAY'; +EOMONTH : 'EOMONTH'; +ISDATE : 'ISDATE'; +MONTH : 'MONTH'; +SMALLDATETIMEFROMPARTS : 'SMALLDATETIMEFROMPARTS'; +SWITCHOFFSET : 'SWITCHOFFSET'; +SYSDATETIME : 'SYSDATETIME'; +SYSDATETIMEOFFSET : 'SYSDATETIMEOFFSET'; +SYSUTCDATETIME : 'SYSUTCDATETIME'; +TIMEFROMPARTS : 'TIMEFROMPARTS'; +TODATETIMEOFFSET : 'TODATETIMEOFFSET'; +YEAR : 'YEAR'; -QUARTER: 'QUARTER'; -DAYOFYEAR: 'DAYOFYEAR'; -WEEK: 'WEEK'; -HOUR: 'HOUR'; -MINUTE: 'MINUTE'; -SECOND: 'SECOND'; -MILLISECOND: 'MILLISECOND'; -MICROSECOND: 'MICROSECOND'; -NANOSECOND: 'NANOSECOND'; -TZOFFSET: 'TZOFFSET'; -ISO_WEEK: 'ISO_WEEK'; -WEEKDAY: 'WEEKDAY'; +QUARTER : 'QUARTER'; +DAYOFYEAR : 'DAYOFYEAR'; +WEEK : 'WEEK'; +HOUR : 'HOUR'; +MINUTE : 'MINUTE'; +SECOND : 'SECOND'; +MILLISECOND : 'MILLISECOND'; +MICROSECOND : 'MICROSECOND'; +NANOSECOND : 'NANOSECOND'; +TZOFFSET : 'TZOFFSET'; +ISO_WEEK : 'ISO_WEEK'; +WEEKDAY : 'WEEKDAY'; -YEAR_ABBR: 'yy' | 'yyyy'; -QUARTER_ABBR: 'qq' | 'q'; -MONTH_ABBR: 'mm' | 'm'; -DAYOFYEAR_ABBR: 'dy' | 'y'; -DAY_ABBR: 'dd' | 'd'; -WEEK_ABBR: 'wk' | 'ww'; -HOUR_ABBR: 'hh'; -MINUTE_ABBR: 'mi' | 'n'; -SECOND_ABBR: 'ss' | 's'; -MILLISECOND_ABBR: 'ms'; -MICROSECOND_ABBR: 'mcs'; -NANOSECOND_ABBR: 'ns'; -TZOFFSET_ABBR: 'tz'; -ISO_WEEK_ABBR: 'isowk' | 'isoww'; -WEEKDAY_ABBR: 'dw'; +YEAR_ABBR : 'yy' | 'yyyy'; +QUARTER_ABBR : 'qq' | 'q'; +MONTH_ABBR : 'mm' | 'm'; +DAYOFYEAR_ABBR : 'dy' | 'y'; +DAY_ABBR : 'dd' | 'd'; +WEEK_ABBR : 'wk' | 'ww'; +HOUR_ABBR : 'hh'; +MINUTE_ABBR : 'mi' | 'n'; +SECOND_ABBR : 'ss' | 's'; +MILLISECOND_ABBR : 'ms'; +MICROSECOND_ABBR : 'mcs'; +NANOSECOND_ABBR : 'ns'; +TZOFFSET_ABBR : 'tz'; +ISO_WEEK_ABBR : 'isowk' | 'isoww'; +WEEKDAY_ABBR : 'dw'; -SP_EXECUTESQL: 'SP_EXECUTESQL'; +SP_EXECUTESQL: 'SP_EXECUTESQL'; //Build-ins: -VARCHAR: 'VARCHAR'; -NVARCHAR: 'NVARCHAR'; +VARCHAR : 'VARCHAR'; +NVARCHAR : 'NVARCHAR'; //Combinations that cannot be used as IDs -DISK_DRIVE: [A-Z][:]; -DOLLAR_ACTION: '$ACTION'; +DISK_DRIVE : [A-Z][:]; +DOLLAR_ACTION : '$ACTION'; // Functions starting with double at signs // https://learn.microsoft.com/en-us/sql/t-sql/language-elements/variables-transact-sql?view=sql-server-ver16 -CURSOR_ROWS: '@@CURSOR_ROWS'; -FETCH_STATUS: '@@FETCH_STATUS'; +CURSOR_ROWS : '@@CURSOR_ROWS'; +FETCH_STATUS : '@@FETCH_STATUS'; -IPV4_ADDR: DEC_DIGIT+ '.' DEC_DIGIT+ '.' DEC_DIGIT+ '.' DEC_DIGIT+; +IPV4_ADDR: DEC_DIGIT+ '.' DEC_DIGIT+ '.' DEC_DIGIT+ '.' DEC_DIGIT+; -SPACE: [ \t\r\n]+ -> skip; +SPACE: [ \t\r\n]+ -> skip; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/slash-star-comment-transact-sql -COMMENT: '/*' (COMMENT | .)*? '*/' -> channel(HIDDEN); -LINE_COMMENT: '--' ~[\r\n]* -> channel(HIDDEN); +COMMENT : '/*' (COMMENT | .)*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '--' ~[\r\n]* -> channel(HIDDEN); // TODO: ID can be not only Latin. -DOUBLE_QUOTE_ID: '"' ~'"'+ '"'; -DOUBLE_QUOTE_BLANK: '""'; -SINGLE_QUOTE: '\''; -SQUARE_BRACKET_ID: '[' (~']' | ']' ']')* ']'; -LOCAL_ID: '@' ([A-Z_$@#0-9] | FullWidthLetter)*; -TEMP_ID: '#' ([A-Z_$@#0-9] | FullWidthLetter)*; -DECIMAL: DEC_DIGIT+; -ID: ( [A-Z_#] | FullWidthLetter) ( [A-Z_#$@0-9] | FullWidthLetter )*; -STRING options { caseInsensitive=false; } : 'N'? '\'' (~'\'' | '\'\'')* '\''; -BINARY: '0' 'X' HEX_DIGIT*; -FLOAT: DEC_DOT_DEC; -REAL: (DECIMAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+); - -EQUAL: '='; +DOUBLE_QUOTE_ID : '"' ~'"'+ '"'; +DOUBLE_QUOTE_BLANK : '""'; +SINGLE_QUOTE : '\''; +SQUARE_BRACKET_ID : '[' (~']' | ']' ']')* ']'; +LOCAL_ID : '@' ([A-Z_$@#0-9] | FullWidthLetter)*; +TEMP_ID : '#' ([A-Z_$@#0-9] | FullWidthLetter)*; +DECIMAL : DEC_DIGIT+; +ID : ( [A-Z_#] | FullWidthLetter) ( [A-Z_#$@0-9] | FullWidthLetter)*; +STRING options { + caseInsensitive = false; +} : 'N'? '\'' (~'\'' | '\'\'')* '\''; +BINARY : '0' 'X' HEX_DIGIT*; +FLOAT : DEC_DOT_DEC; +REAL : (DECIMAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+); -GREATER: '>'; -LESS: '<'; -EXCLAMATION: '!'; +EQUAL: '='; -PLUS_ASSIGN: '+='; -MINUS_ASSIGN: '-='; -MULT_ASSIGN: '*='; -DIV_ASSIGN: '/='; -MOD_ASSIGN: '%='; -AND_ASSIGN: '&='; -XOR_ASSIGN: '^='; -OR_ASSIGN: '|='; +GREATER : '>'; +LESS : '<'; +EXCLAMATION : '!'; -DOUBLE_BAR: '||'; -DOT: '.'; -UNDERLINE: '_'; -AT: '@'; -SHARP: '#'; -DOLLAR: '$'; -LR_BRACKET: '('; -RR_BRACKET: ')'; -COMMA: ','; -SEMI: ';'; -COLON: ':'; -DOUBLE_COLON: '::'; -STAR: '*'; -DIVIDE: '/'; -MODULE: '%'; -PLUS: '+'; -MINUS: '-'; -BIT_NOT: '~'; -BIT_OR: '|'; -BIT_AND: '&'; -BIT_XOR: '^'; +PLUS_ASSIGN : '+='; +MINUS_ASSIGN : '-='; +MULT_ASSIGN : '*='; +DIV_ASSIGN : '/='; +MOD_ASSIGN : '%='; +AND_ASSIGN : '&='; +XOR_ASSIGN : '^='; +OR_ASSIGN : '|='; -PLACEHOLDER: '?'; +DOUBLE_BAR : '||'; +DOT : '.'; +UNDERLINE : '_'; +AT : '@'; +SHARP : '#'; +DOLLAR : '$'; +LR_BRACKET : '('; +RR_BRACKET : ')'; +COMMA : ','; +SEMI : ';'; +COLON : ':'; +DOUBLE_COLON : '::'; +STAR : '*'; +DIVIDE : '/'; +MODULE : '%'; +PLUS : '+'; +MINUS : '-'; +BIT_NOT : '~'; +BIT_OR : '|'; +BIT_AND : '&'; +BIT_XOR : '^'; -fragment LETTER: [A-Z_]; -fragment DEC_DOT_DEC: (DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+); -fragment HEX_DIGIT: [0-9A-F]; -fragment DEC_DIGIT: [0-9]; +PLACEHOLDER: '?'; +fragment LETTER : [A-Z_]; +fragment DEC_DOT_DEC : (DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+); +fragment HEX_DIGIT : [0-9A-F]; +fragment DEC_DIGIT : [0-9]; -fragment FullWidthLetter options { caseInsensitive=false; } - : '\u00c0'..'\u00d6' - | '\u00d8'..'\u00f6' - | '\u00f8'..'\u00ff' - | '\u0100'..'\u1fff' - | '\u2c00'..'\u2fff' - | '\u3040'..'\u318f' - | '\u3300'..'\u337f' - | '\u3400'..'\u3fff' - | '\u4e00'..'\u9fff' - | '\ua000'..'\ud7ff' - | '\uf900'..'\ufaff' - | '\uff00'..'\ufff0' - // | '\u10000'..'\u1F9FF' //not support four bytes chars - // | '\u20000'..'\u2FA1F' - ; +fragment FullWidthLetter options { + caseInsensitive = false; +}: + '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0100' ..'\u1fff' + | '\u2c00' ..'\u2fff' + | '\u3040' ..'\u318f' + | '\u3300' ..'\u337f' + | '\u3400' ..'\u3fff' + | '\u4e00' ..'\u9fff' + | '\ua000' ..'\ud7ff' + | '\uf900' ..'\ufaff' + | '\uff00' ..'\ufff0' + ; // | '\u20000'..'\u2FA1F' \ No newline at end of file diff --git a/sql/tsql/TSqlParser.g4 b/sql/tsql/TSqlParser.g4 index 0c8e980775..af1eff5d22 100644 --- a/sql/tsql/TSqlParser.g4 +++ b/sql/tsql/TSqlParser.g4 @@ -23,9 +23,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 TSqlParser; -options { tokenVocab=TSqlLexer; } +options { + tokenVocab = TSqlLexer; +} tsql_file : batch* EOF @@ -44,6 +49,7 @@ batch_level_statement | create_or_alter_trigger | create_view ; + sql_clauses : dml_clause SEMI? | cfl_statement SEMI? @@ -293,25 +299,28 @@ throw_statement ; throw_error_number - : DECIMAL | LOCAL_ID + : DECIMAL + | LOCAL_ID ; throw_message - : STRING | LOCAL_ID + : STRING + | LOCAL_ID ; throw_state - : DECIMAL | LOCAL_ID + : DECIMAL + | LOCAL_ID ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/try-catch-transact-sql try_catch_statement - : BEGIN TRY ';'? try_clauses=sql_clauses+ END TRY ';'? BEGIN CATCH ';'? catch_clauses=sql_clauses* END CATCH ';'? + : BEGIN TRY ';'? try_clauses = sql_clauses+ END TRY ';'? BEGIN CATCH ';'? catch_clauses = sql_clauses* END CATCH ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/waitfor-transact-sql waitfor_statement - : WAITFOR receive_statement? ','? ((DELAY | TIME | TIMEOUT) time)? expression? ';'? + : WAITFOR receive_statement? ','? ((DELAY | TIME | TIMEOUT) time)? expression? ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/while-transact-sql @@ -326,9 +335,12 @@ print_statement // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql raiseerror_statement - : RAISERROR '(' msg=(DECIMAL | STRING | LOCAL_ID) ',' severity=constant_LOCAL_ID ',' - state=constant_LOCAL_ID (',' (constant_LOCAL_ID | NULL_))* ')' (WITH (LOG | SETERROR | NOWAIT))? ';'? - | RAISERROR DECIMAL formatstring=(STRING | LOCAL_ID | DOUBLE_QUOTE_ID) (',' argument=(DECIMAL | STRING | LOCAL_ID))* + : RAISERROR '(' msg = (DECIMAL | STRING | LOCAL_ID) ',' severity = constant_LOCAL_ID ',' state = constant_LOCAL_ID ( + ',' (constant_LOCAL_ID | NULL_) + )* ')' (WITH (LOG | SETERROR | NOWAIT))? ';'? + | RAISERROR DECIMAL formatstring = (STRING | LOCAL_ID | DOUBLE_QUOTE_ID) ( + ',' argument = (DECIMAL | STRING | LOCAL_ID) + )* ; empty_statement @@ -357,7 +369,11 @@ another_statement // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-application-role-transact-sql alter_application_role - : ALTER APPLICATION ROLE appliction_role=id_ WITH (COMMA? NAME EQUAL new_application_role_name=id_)? (COMMA? PASSWORD EQUAL application_role_password=STRING)? (COMMA? DEFAULT_SCHEMA EQUAL app_role_default_schema=id_)? + : ALTER APPLICATION ROLE appliction_role = id_ WITH ( + COMMA? NAME EQUAL new_application_role_name = id_ + )? (COMMA? PASSWORD EQUAL application_role_password = STRING)? ( + COMMA? DEFAULT_SCHEMA EQUAL app_role_default_schema = id_ + )? ; // https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-xml-schema-collection-transact-sql?view=sql-server-ver16 @@ -366,26 +382,28 @@ alter_xml_schema_collection ; create_application_role - : CREATE APPLICATION ROLE appliction_role=id_ WITH (COMMA? PASSWORD EQUAL application_role_password=STRING)? (COMMA? DEFAULT_SCHEMA EQUAL app_role_default_schema=id_)? + : CREATE APPLICATION ROLE appliction_role = id_ WITH ( + COMMA? PASSWORD EQUAL application_role_password = STRING + )? (COMMA? DEFAULT_SCHEMA EQUAL app_role_default_schema = id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-aggregate-transact-sql drop_aggregate - : DROP AGGREGATE ( IF EXISTS )? ( schema_name=id_ DOT )? aggregate_name=id_ + : DROP AGGREGATE (IF EXISTS)? (schema_name = id_ DOT)? aggregate_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-application-role-transact-sql drop_application_role - : DROP APPLICATION ROLE rolename=id_ + : DROP APPLICATION ROLE rolename = id_ ; alter_assembly - : alter_assembly_start assembly_name=id_ alter_assembly_clause + : alter_assembly_start assembly_name = id_ alter_assembly_clause ; alter_assembly_start - : ALTER ASSEMBLY + : ALTER ASSEMBLY ; alter_assembly_clause @@ -393,7 +411,7 @@ alter_assembly_clause ; alter_assembly_from_clause - : alter_assembly_from_clause_start (client_assembly_specifier | alter_assembly_file_bits ) + : alter_assembly_from_clause_start (client_assembly_specifier | alter_assembly_file_bits) ; alter_assembly_from_clause_start @@ -423,7 +441,7 @@ alter_asssembly_add_clause_start // need to implement alter_assembly_client_file_clause - : alter_assembly_file_name (alter_assembly_as id_)? + : alter_assembly_file_name (alter_assembly_as id_)? ; alter_assembly_file_name @@ -454,7 +472,7 @@ client_assembly_specifier ; assembly_option - : PERMISSION_SET EQUAL (SAFE|EXTERNAL_ACCESS|UNSAFE) + : PERMISSION_SET EQUAL (SAFE | EXTERNAL_ACCESS | UNSAFE) | VISIBILITY EQUAL on_off | UNCHECKED DATA | assembly_option COMMA @@ -465,7 +483,7 @@ network_file_share ; network_computer - : computer_name=id_ + : computer_name = id_ ; network_file_start @@ -486,12 +504,11 @@ local_file ; local_drive - : - DISK_DRIVE + : DISK_DRIVE ; + multiple_local_files - : - multiple_local_file_start local_file SINGLE_QUOTE COMMA + : multiple_local_file_start local_file SINGLE_QUOTE COMMA | local_file ; @@ -501,21 +518,20 @@ multiple_local_file_start // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-assembly-transact-sql create_assembly - : CREATE ASSEMBLY assembly_name=id_ (AUTHORIZATION owner_name=id_)? - FROM (COMMA? (STRING|BINARY) )+ - (WITH PERMISSION_SET EQUAL (SAFE|EXTERNAL_ACCESS|UNSAFE) )? - + : CREATE ASSEMBLY assembly_name = id_ (AUTHORIZATION owner_name = id_)? FROM ( + COMMA? (STRING | BINARY) + )+ (WITH PERMISSION_SET EQUAL (SAFE | EXTERNAL_ACCESS | UNSAFE))? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-assembly-transact-sql drop_assembly - : DROP ASSEMBLY ( IF EXISTS )? (COMMA? assembly_name=id_)+ - ( WITH NO DEPENDENTS )? + : DROP ASSEMBLY (IF EXISTS)? (COMMA? assembly_name = id_)+ (WITH NO DEPENDENTS)? ; + // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-asymmetric-key-transact-sql alter_asymmetric_key - : alter_asymmetric_key_start Asym_Key_Name=id_ (asymmetric_key_option | REMOVE PRIVATE KEY ) + : alter_asymmetric_key_start Asym_Key_Name = id_ (asymmetric_key_option | REMOVE PRIVATE KEY) ; alter_asymmetric_key_start @@ -523,7 +539,9 @@ alter_asymmetric_key_start ; asymmetric_key_option - : asymmetric_key_option_start asymmetric_key_password_change_option ( COMMA asymmetric_key_password_change_option)? RR_BRACKET + : asymmetric_key_option_start asymmetric_key_password_change_option ( + COMMA asymmetric_key_password_change_option + )? RR_BRACKET ; asymmetric_key_option_start @@ -535,30 +553,38 @@ asymmetric_key_password_change_option | ENCRYPTION BY PASSWORD EQUAL STRING ; - //https://docs.microsoft.com/en-us/sql/t-sql/statements/create-asymmetric-key-transact-sql create_asymmetric_key - : CREATE ASYMMETRIC KEY Asym_Key_Nam=id_ - (AUTHORIZATION database_principal_name=id_)? - ( FROM (FILE EQUAL STRING |EXECUTABLE_FILE EQUAL STRING|ASSEMBLY Assembly_Name=id_ | PROVIDER Provider_Name=id_) )? - (WITH (ALGORITHM EQUAL ( RSA_4096 | RSA_3072 | RSA_2048 | RSA_1024 | RSA_512) |PROVIDER_KEY_NAME EQUAL provider_key_name=STRING | CREATION_DISPOSITION EQUAL (CREATE_NEW|OPEN_EXISTING) ) )? - (ENCRYPTION BY PASSWORD EQUAL asymmetric_key_password=STRING )? + : CREATE ASYMMETRIC KEY Asym_Key_Nam = id_ (AUTHORIZATION database_principal_name = id_)? ( + FROM ( + FILE EQUAL STRING + | EXECUTABLE_FILE EQUAL STRING + | ASSEMBLY Assembly_Name = id_ + | PROVIDER Provider_Name = id_ + ) + )? ( + WITH ( + ALGORITHM EQUAL (RSA_4096 | RSA_3072 | RSA_2048 | RSA_1024 | RSA_512) + | PROVIDER_KEY_NAME EQUAL provider_key_name = STRING + | CREATION_DISPOSITION EQUAL (CREATE_NEW | OPEN_EXISTING) + ) + )? (ENCRYPTION BY PASSWORD EQUAL asymmetric_key_password = STRING)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-asymmetric-key-transact-sql drop_asymmetric_key - : DROP ASYMMETRIC KEY key_name=id_ ( REMOVE PROVIDER KEY )? + : DROP ASYMMETRIC KEY key_name = id_ (REMOVE PROVIDER KEY)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-authorization-transact-sql alter_authorization - : alter_authorization_start (class_type colon_colon)? entity=entity_name entity_to authorization_grantee + : alter_authorization_start (class_type colon_colon)? entity = entity_name entity_to authorization_grantee ; authorization_grantee - : principal_name=id_ + : principal_name = id_ | SCHEMA OWNER ; @@ -575,18 +601,17 @@ alter_authorization_start ; alter_authorization_for_sql_database - : alter_authorization_start (class_type_for_sql_database colon_colon)? entity=entity_name entity_to authorization_grantee + : alter_authorization_start (class_type_for_sql_database colon_colon)? entity = entity_name entity_to authorization_grantee ; alter_authorization_for_azure_dw - : alter_authorization_start (class_type_for_azure_dw colon_colon)? entity=entity_name_for_azure_dw entity_to authorization_grantee + : alter_authorization_start (class_type_for_azure_dw colon_colon)? entity = entity_name_for_azure_dw entity_to authorization_grantee ; alter_authorization_for_parallel_dw - : alter_authorization_start (class_type_for_parallel_dw colon_colon)? entity=entity_name_for_parallel_dw entity_to authorization_grantee + : alter_authorization_start (class_type_for_parallel_dw colon_colon)? entity = entity_name_for_parallel_dw entity_to authorization_grantee ; - class_type : OBJECT | ASSEMBLY @@ -612,7 +637,7 @@ class_type ; class_type_for_sql_database - : OBJECT + : OBJECT | ASSEMBLY | ASYMMETRIC KEY | CERTIFICATE @@ -650,28 +675,20 @@ class_type_for_grant | AVAILABILITY GROUP | BROKER PRIORITY | CERTIFICATE - | COLUMN ( ENCRYPTION | MASTER ) KEY + | COLUMN ( ENCRYPTION | MASTER) KEY | CONTRACT | CREDENTIAL | CRYPTOGRAPHIC PROVIDER - | DATABASE ( AUDIT SPECIFICATION - | ENCRYPTION KEY - | EVENT SESSION - | SCOPED ( CONFIGURATION - | CREDENTIAL - | RESOURCE GOVERNOR ) - )? + | DATABASE ( + AUDIT SPECIFICATION + | ENCRYPTION KEY + | EVENT SESSION + | SCOPED ( CONFIGURATION | CREDENTIAL | RESOURCE GOVERNOR) + )? | ENDPOINT | EVENT SESSION | NOTIFICATION (DATABASE | OBJECT | SERVER) - | EXTERNAL ( DATA SOURCE - | FILE FORMAT - | LIBRARY - | RESOURCE POOL - | TABLE - | CATALOG - | STOPLIST - ) + | EXTERNAL (DATA SOURCE | FILE FORMAT | LIBRARY | RESOURCE POOL | TABLE | CATALOG | STOPLIST) | LOGIN | MASTER KEY | MESSAGE TYPE @@ -683,7 +700,7 @@ class_type_for_grant | ROUTE | SCHEMA | SEARCH PROPERTY LIST - | SERVER ( ( AUDIT SPECIFICATION? ) | ROLE )? + | SERVER ( ( AUDIT SPECIFICATION?) | ROLE)? | SERVICE | SQL LOGIN | SYMMETRIC KEY @@ -693,11 +710,9 @@ class_type_for_grant | XML SCHEMA COLLECTION ; - - // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-availability-group-transact-sql drop_availability_group - : DROP AVAILABILITY GROUP group_name=id_ + : DROP AVAILABILITY GROUP group_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-availability-group-transact-sql @@ -706,37 +721,97 @@ alter_availability_group ; alter_availability_group_start - : ALTER AVAILABILITY GROUP group_name=id_ + : ALTER AVAILABILITY GROUP group_name = id_ ; alter_availability_group_options - : SET LR_BRACKET ( ( AUTOMATED_BACKUP_PREFERENCE EQUAL ( PRIMARY | SECONDARY_ONLY| SECONDARY | NONE ) | FAILURE_CONDITION_LEVEL EQUAL DECIMAL | HEALTH_CHECK_TIMEOUT EQUAL milliseconds=DECIMAL | DB_FAILOVER EQUAL ( ON | OFF ) | REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT EQUAL DECIMAL ) RR_BRACKET ) - | ADD DATABASE database_name=id_ - | REMOVE DATABASE database_name=id_ - | ADD REPLICA ON server_instance=STRING (WITH LR_BRACKET ( (ENDPOINT_URL EQUAL STRING)? (COMMA? AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT| ASYNCHRONOUS_COMMIT))? (COMMA? FAILOVER_MODE EQUAL (AUTOMATIC|MANUAL) )? (COMMA? SEEDING_MODE EQUAL (AUTOMATIC|MANUAL) )? (COMMA? BACKUP_PRIORITY EQUAL DECIMAL)? ( COMMA? PRIMARY_ROLE LR_BRACKET ALLOW_CONNECTIONS EQUAL ( READ_WRITE | ALL ) RR_BRACKET)? ( COMMA? SECONDARY_ROLE LR_BRACKET ALLOW_CONNECTIONS EQUAL ( READ_ONLY ) RR_BRACKET )? ) -) RR_BRACKET - |SECONDARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( ( STRING) ) RR_BRACKET ) ) - |PRIMARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( (COMMA? STRING)*|NONE ) RR_BRACKET ) - | SESSION_TIMEOUT EQUAL session_timeout=DECIMAL -) - | MODIFY REPLICA ON server_instance=STRING (WITH LR_BRACKET (ENDPOINT_URL EQUAL STRING| AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT| ASYNCHRONOUS_COMMIT) | FAILOVER_MODE EQUAL (AUTOMATIC|MANUAL) | SEEDING_MODE EQUAL (AUTOMATIC|MANUAL) | BACKUP_PRIORITY EQUAL DECIMAL ) - |SECONDARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( ( STRING) ) RR_BRACKET ) ) - |PRIMARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( (COMMA? STRING)*|NONE ) RR_BRACKET ) - | SESSION_TIMEOUT EQUAL session_timeout=DECIMAL -) ) RR_BRACKET + : SET LR_BRACKET ( + ( + AUTOMATED_BACKUP_PREFERENCE EQUAL (PRIMARY | SECONDARY_ONLY | SECONDARY | NONE) + | FAILURE_CONDITION_LEVEL EQUAL DECIMAL + | HEALTH_CHECK_TIMEOUT EQUAL milliseconds = DECIMAL + | DB_FAILOVER EQUAL ( ON | OFF) + | REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT EQUAL DECIMAL + ) RR_BRACKET + ) + | ADD DATABASE database_name = id_ + | REMOVE DATABASE database_name = id_ + | ADD REPLICA ON server_instance = STRING ( + WITH LR_BRACKET ( + (ENDPOINT_URL EQUAL STRING)? ( + COMMA? AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT | ASYNCHRONOUS_COMMIT) + )? (COMMA? FAILOVER_MODE EQUAL (AUTOMATIC | MANUAL))? ( + COMMA? SEEDING_MODE EQUAL (AUTOMATIC | MANUAL) + )? (COMMA? BACKUP_PRIORITY EQUAL DECIMAL)? ( + COMMA? PRIMARY_ROLE LR_BRACKET ALLOW_CONNECTIONS EQUAL (READ_WRITE | ALL) RR_BRACKET + )? (COMMA? SECONDARY_ROLE LR_BRACKET ALLOW_CONNECTIONS EQUAL ( READ_ONLY) RR_BRACKET)? + ) + ) RR_BRACKET + | SECONDARY_ROLE LR_BRACKET ( + ALLOW_CONNECTIONS EQUAL (NO | READ_ONLY | ALL) + | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( ( STRING)) RR_BRACKET) + ) + | PRIMARY_ROLE LR_BRACKET ( + ALLOW_CONNECTIONS EQUAL (NO | READ_ONLY | ALL) + | READ_ONLY_ROUTING_LIST EQUAL (LR_BRACKET ( (COMMA? STRING)* | NONE) RR_BRACKET) + | SESSION_TIMEOUT EQUAL session_timeout = DECIMAL + ) + | MODIFY REPLICA ON server_instance = STRING ( + WITH LR_BRACKET ( + ENDPOINT_URL EQUAL STRING + | AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT | ASYNCHRONOUS_COMMIT) + | FAILOVER_MODE EQUAL (AUTOMATIC | MANUAL) + | SEEDING_MODE EQUAL (AUTOMATIC | MANUAL) + | BACKUP_PRIORITY EQUAL DECIMAL + ) + | SECONDARY_ROLE LR_BRACKET ( + ALLOW_CONNECTIONS EQUAL (NO | READ_ONLY | ALL) + | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( ( STRING)) RR_BRACKET) + ) + | PRIMARY_ROLE LR_BRACKET ( + ALLOW_CONNECTIONS EQUAL (NO | READ_ONLY | ALL) + | READ_ONLY_ROUTING_LIST EQUAL (LR_BRACKET ( (COMMA? STRING)* | NONE) RR_BRACKET) + | SESSION_TIMEOUT EQUAL session_timeout = DECIMAL + ) + ) RR_BRACKET | REMOVE REPLICA ON STRING | JOIN - | JOIN AVAILABILITY GROUP ON (COMMA? ag_name=STRING WITH LR_BRACKET ( LISTENER_URL EQUAL STRING COMMA AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT|ASYNCHRONOUS_COMMIT) COMMA FAILOVER_MODE EQUAL MANUAL COMMA SEEDING_MODE EQUAL (AUTOMATIC|MANUAL) RR_BRACKET ) )+ - | MODIFY AVAILABILITY GROUP ON (COMMA? ag_name_modified=STRING WITH LR_BRACKET (LISTENER_URL EQUAL STRING (COMMA? AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT|ASYNCHRONOUS_COMMIT) )? (COMMA? FAILOVER_MODE EQUAL MANUAL )? (COMMA? SEEDING_MODE EQUAL (AUTOMATIC|MANUAL))? RR_BRACKET ) )+ - |GRANT CREATE ANY DATABASE + | JOIN AVAILABILITY GROUP ON ( + COMMA? ag_name = STRING WITH LR_BRACKET ( + LISTENER_URL EQUAL STRING COMMA AVAILABILITY_MODE EQUAL ( + SYNCHRONOUS_COMMIT + | ASYNCHRONOUS_COMMIT + ) COMMA FAILOVER_MODE EQUAL MANUAL COMMA SEEDING_MODE EQUAL (AUTOMATIC | MANUAL) RR_BRACKET + ) + )+ + | MODIFY AVAILABILITY GROUP ON ( + COMMA? ag_name_modified = STRING WITH LR_BRACKET ( + LISTENER_URL EQUAL STRING ( + COMMA? AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT | ASYNCHRONOUS_COMMIT) + )? (COMMA? FAILOVER_MODE EQUAL MANUAL)? ( + COMMA? SEEDING_MODE EQUAL (AUTOMATIC | MANUAL) + )? RR_BRACKET + ) + )+ + | GRANT CREATE ANY DATABASE | DENY CREATE ANY DATABASE | FAILOVER | FORCE_FAILOVER_ALLOW_DATA_LOSS - | ADD LISTENER listener_name=STRING LR_BRACKET ( WITH DHCP (ON LR_BRACKET ip_v4_failover ip_v4_failover RR_BRACKET ) | WITH IP LR_BRACKET ( (COMMA? LR_BRACKET ( ip_v4_failover COMMA ip_v4_failover | ip_v6_failover ) RR_BRACKET)+ RR_BRACKET (COMMA PORT EQUAL DECIMAL)? ) ) RR_BRACKET - | MODIFY LISTENER (ADD IP LR_BRACKET (ip_v4_failover ip_v4_failover | ip_v6_failover) RR_BRACKET | PORT EQUAL DECIMAL ) - |RESTART LISTENER STRING - |REMOVE LISTENER STRING - |OFFLINE + | ADD LISTENER listener_name = STRING LR_BRACKET ( + WITH DHCP (ON LR_BRACKET ip_v4_failover ip_v4_failover RR_BRACKET) + | WITH IP LR_BRACKET ( + (COMMA? LR_BRACKET ( ip_v4_failover COMMA ip_v4_failover | ip_v6_failover) RR_BRACKET)+ RR_BRACKET ( + COMMA PORT EQUAL DECIMAL + )? + ) + ) RR_BRACKET + | MODIFY LISTENER ( + ADD IP LR_BRACKET (ip_v4_failover ip_v4_failover | ip_v6_failover) RR_BRACKET + | PORT EQUAL DECIMAL + ) + | RESTART LISTENER STRING + | REMOVE LISTENER STRING + | OFFLINE | WITH LR_BRACKET DTC_SUPPORT EQUAL PER_DB RR_BRACKET ; @@ -751,78 +826,84 @@ ip_v6_failover // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-broker-priority-transact-sql // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-broker-priority-transact-sql create_or_alter_broker_priority - : (CREATE | ALTER) BROKER PRIORITY ConversationPriorityName=id_ FOR CONVERSATION - SET LR_BRACKET - ( CONTRACT_NAME EQUAL ( ( id_) | ANY ) COMMA? )? - ( LOCAL_SERVICE_NAME EQUAL (DOUBLE_FORWARD_SLASH? id_ | ANY ) COMMA? )? - ( REMOTE_SERVICE_NAME EQUAL (RemoteServiceName=STRING | ANY ) COMMA? )? - ( PRIORITY_LEVEL EQUAL ( PriorityValue=DECIMAL | DEFAULT ) ) ? - RR_BRACKET + : (CREATE | ALTER) BROKER PRIORITY ConversationPriorityName = id_ FOR CONVERSATION SET LR_BRACKET ( + CONTRACT_NAME EQUAL ( ( id_) | ANY) COMMA? + )? (LOCAL_SERVICE_NAME EQUAL (DOUBLE_FORWARD_SLASH? id_ | ANY) COMMA?)? ( + REMOTE_SERVICE_NAME EQUAL (RemoteServiceName = STRING | ANY) COMMA? + )? (PRIORITY_LEVEL EQUAL ( PriorityValue = DECIMAL | DEFAULT))? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-broker-priority-transact-sql drop_broker_priority - : DROP BROKER PRIORITY ConversationPriorityName=id_ + : DROP BROKER PRIORITY ConversationPriorityName = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-certificate-transact-sql alter_certificate - : ALTER CERTIFICATE certificate_name=id_ (REMOVE PRIVATE_KEY | WITH PRIVATE KEY LR_BRACKET ( FILE EQUAL STRING COMMA? | DECRYPTION BY PASSWORD EQUAL STRING COMMA?| ENCRYPTION BY PASSWORD EQUAL STRING COMMA?)+ RR_BRACKET | WITH ACTIVE FOR BEGIN_DIALOG EQUAL ( ON | OFF ) ) + : ALTER CERTIFICATE certificate_name = id_ ( + REMOVE PRIVATE_KEY + | WITH PRIVATE KEY LR_BRACKET ( + FILE EQUAL STRING COMMA? + | DECRYPTION BY PASSWORD EQUAL STRING COMMA? + | ENCRYPTION BY PASSWORD EQUAL STRING COMMA? + )+ RR_BRACKET + | WITH ACTIVE FOR BEGIN_DIALOG EQUAL ( ON | OFF) + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-column-encryption-key-transact-sql alter_column_encryption_key - : ALTER COLUMN ENCRYPTION KEY column_encryption_key=id_ (ADD | DROP) VALUE LR_BRACKET COLUMN_MASTER_KEY EQUAL column_master_key_name=id_ ( COMMA ALGORITHM EQUAL algorithm_name=STRING COMMA ENCRYPTED_VALUE EQUAL BINARY)? RR_BRACKET + : ALTER COLUMN ENCRYPTION KEY column_encryption_key = id_ (ADD | DROP) VALUE LR_BRACKET COLUMN_MASTER_KEY EQUAL column_master_key_name = id_ ( + COMMA ALGORITHM EQUAL algorithm_name = STRING COMMA ENCRYPTED_VALUE EQUAL BINARY + )? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-column-encryption-key-transact-sql create_column_encryption_key - : CREATE COLUMN ENCRYPTION KEY column_encryption_key=id_ - WITH VALUES - (LR_BRACKET COMMA? COLUMN_MASTER_KEY EQUAL column_master_key_name=id_ COMMA - ALGORITHM EQUAL algorithm_name=STRING COMMA - ENCRYPTED_VALUE EQUAL encrypted_value=BINARY RR_BRACKET COMMA?)+ + : CREATE COLUMN ENCRYPTION KEY column_encryption_key = id_ WITH VALUES ( + LR_BRACKET COMMA? COLUMN_MASTER_KEY EQUAL column_master_key_name = id_ COMMA ALGORITHM EQUAL algorithm_name = STRING COMMA ENCRYPTED_VALUE + EQUAL encrypted_value = BINARY RR_BRACKET COMMA? + )+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-certificate-transact-sql drop_certificate - : DROP CERTIFICATE certificate_name=id_ + : DROP CERTIFICATE certificate_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-column-encryption-key-transact-sql drop_column_encryption_key - : DROP COLUMN ENCRYPTION KEY key_name=id_ + : DROP COLUMN ENCRYPTION KEY key_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-column-master-key-transact-sql drop_column_master_key - : DROP COLUMN MASTER KEY key_name=id_ + : DROP COLUMN MASTER KEY key_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-contract-transact-sql drop_contract - : DROP CONTRACT dropped_contract_name=id_ + : DROP CONTRACT dropped_contract_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-credential-transact-sql drop_credential - : DROP CREDENTIAL credential_name=id_ + : DROP CREDENTIAL credential_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-cryptographic-provider-transact-sql drop_cryptograhic_provider - : DROP CRYPTOGRAPHIC PROVIDER provider_name=id_ + : DROP CRYPTOGRAPHIC PROVIDER provider_name = id_ ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-transact-sql drop_database - : DROP DATABASE ( IF EXISTS )? (COMMA? database_name_or_database_snapshot_name=id_)+ + : DROP DATABASE (IF EXISTS)? (COMMA? database_name_or_database_snapshot_name = id_)+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-audit-specification-transact-sql drop_database_audit_specification - : DROP DATABASE AUDIT SPECIFICATION audit_specification_name=id_ + : DROP DATABASE AUDIT SPECIFICATION audit_specification_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-encryption-key-transact-sql?view=sql-server-ver15 @@ -832,75 +913,76 @@ drop_database_encryption_key // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-scoped-credential-transact-sql drop_database_scoped_credential - : DROP DATABASE SCOPED CREDENTIAL credential_name=id_ - ; + : DROP DATABASE SCOPED CREDENTIAL credential_name = id_ + ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-default-transact-sql drop_default - : DROP DEFAULT ( IF EXISTS )? (COMMA? (schema_name=id_ DOT)? default_name=id_) + : DROP DEFAULT (IF EXISTS)? (COMMA? (schema_name = id_ DOT)? default_name = id_) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-endpoint-transact-sql drop_endpoint - : DROP ENDPOINT endPointName=id_ + : DROP ENDPOINT endPointName = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-data-source-transact-sql drop_external_data_source - : DROP EXTERNAL DATA SOURCE external_data_source_name=id_ + : DROP EXTERNAL DATA SOURCE external_data_source_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-file-format-transact-sql drop_external_file_format - : DROP EXTERNAL FILE FORMAT external_file_format_name=id_ + : DROP EXTERNAL FILE FORMAT external_file_format_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-library-transact-sql drop_external_library - : DROP EXTERNAL LIBRARY library_name=id_ -( AUTHORIZATION owner_name=id_ )? + : DROP EXTERNAL LIBRARY library_name = id_ (AUTHORIZATION owner_name = id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-resource-pool-transact-sql drop_external_resource_pool - : DROP EXTERNAL RESOURCE POOL pool_name=id_ + : DROP EXTERNAL RESOURCE POOL pool_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-table-transact-sql drop_external_table - : DROP EXTERNAL TABLE (database_name=id_ DOT)? (schema_name=id_ DOT)? table=id_ + : DROP EXTERNAL TABLE (database_name = id_ DOT)? (schema_name = id_ DOT)? table = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-event-notification-transact-sql drop_event_notifications - : DROP EVENT NOTIFICATION (COMMA? notification_name=id_)+ - ON (SERVER|DATABASE|QUEUE queue_name=id_) + : DROP EVENT NOTIFICATION (COMMA? notification_name = id_)+ ON ( + SERVER + | DATABASE + | QUEUE queue_name = id_ + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-event-session-transact-sql drop_event_session - : DROP EVENT SESSION event_session_name=id_ - ON SERVER + : DROP EVENT SESSION event_session_name = id_ ON SERVER ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-fulltext-catalog-transact-sql drop_fulltext_catalog - : DROP FULLTEXT CATALOG catalog_name=id_ + : DROP FULLTEXT CATALOG catalog_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-fulltext-index-transact-sql drop_fulltext_index - : DROP FULLTEXT INDEX ON (schema=id_ DOT)? table=id_ + : DROP FULLTEXT INDEX ON (schema = id_ DOT)? table = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-fulltext-stoplist-transact-sql drop_fulltext_stoplist - : DROP FULLTEXT STOPLIST stoplist_name=id_ + : DROP FULLTEXT STOPLIST stoplist_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-login-transact-sql drop_login - : DROP LOGIN login_name=id_ + : DROP LOGIN login_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-master-key-transact-sql @@ -910,208 +992,204 @@ drop_master_key // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-message-type-transact-sql drop_message_type - : DROP MESSAGE TYPE message_type_name=id_ + : DROP MESSAGE TYPE message_type_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-partition-function-transact-sql drop_partition_function - : DROP PARTITION FUNCTION partition_function_name=id_ + : DROP PARTITION FUNCTION partition_function_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-partition-scheme-transact-sql drop_partition_scheme - : DROP PARTITION SCHEME partition_scheme_name=id_ + : DROP PARTITION SCHEME partition_scheme_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-queue-transact-sql drop_queue - : DROP QUEUE (database_name=id_ DOT)? (schema_name=id_ DOT)? queue_name=id_ + : DROP QUEUE (database_name = id_ DOT)? (schema_name = id_ DOT)? queue_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-remote-service-binding-transact-sql drop_remote_service_binding - : DROP REMOTE SERVICE BINDING binding_name=id_ + : DROP REMOTE SERVICE BINDING binding_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-resource-pool-transact-sql drop_resource_pool - : DROP RESOURCE POOL pool_name=id_ + : DROP RESOURCE POOL pool_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-role-transact-sql drop_db_role - : DROP ROLE ( IF EXISTS )? role_name=id_ + : DROP ROLE (IF EXISTS)? role_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-route-transact-sql drop_route - : DROP ROUTE route_name=id_ + : DROP ROUTE route_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-rule-transact-sql drop_rule - : DROP RULE ( IF EXISTS )? (COMMA? (schema_name=id_ DOT)? rule_name=id_)? + : DROP RULE (IF EXISTS)? (COMMA? (schema_name = id_ DOT)? rule_name = id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-schema-transact-sql drop_schema - : DROP SCHEMA ( IF EXISTS )? schema_name=id_ + : DROP SCHEMA (IF EXISTS)? schema_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-search-property-list-transact-sql drop_search_property_list - : DROP SEARCH PROPERTY LIST property_list_name=id_ + : DROP SEARCH PROPERTY LIST property_list_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-security-policy-transact-sql drop_security_policy - : DROP SECURITY POLICY ( IF EXISTS )? (schema_name=id_ DOT )? security_policy_name=id_ + : DROP SECURITY POLICY (IF EXISTS)? (schema_name = id_ DOT)? security_policy_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-sequence-transact-sql drop_sequence - : DROP SEQUENCE ( IF EXISTS )? ( COMMA? (database_name=id_ DOT)? (schema_name=id_ DOT)? sequence_name=id_ )? + : DROP SEQUENCE (IF EXISTS)? ( + COMMA? (database_name = id_ DOT)? (schema_name = id_ DOT)? sequence_name = id_ + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-server-audit-transact-sql drop_server_audit - : DROP SERVER AUDIT audit_name=id_ + : DROP SERVER AUDIT audit_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-server-audit-specification-transact-sql drop_server_audit_specification - : DROP SERVER AUDIT SPECIFICATION audit_specification_name=id_ + : DROP SERVER AUDIT SPECIFICATION audit_specification_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-server-role-transact-sql drop_server_role - : DROP SERVER ROLE role_name=id_ + : DROP SERVER ROLE role_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-service-transact-sql drop_service - : DROP SERVICE dropped_service_name=id_ + : DROP SERVICE dropped_service_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-signature-transact-sql drop_signature - : DROP ( COUNTER )? SIGNATURE FROM (schema_name=id_ DOT)? module_name=id_ - BY (COMMA? CERTIFICATE cert_name=id_ - | COMMA? ASYMMETRIC KEY Asym_key_name=id_ - )+ + : DROP (COUNTER)? SIGNATURE FROM (schema_name = id_ DOT)? module_name = id_ BY ( + COMMA? CERTIFICATE cert_name = id_ + | COMMA? ASYMMETRIC KEY Asym_key_name = id_ + )+ ; - drop_statistics_name_azure_dw_and_pdw - : DROP STATISTICS (schema_name=id_ DOT)? object_name=id_ DOT statistics_name=id_ + : DROP STATISTICS (schema_name = id_ DOT)? object_name = id_ DOT statistics_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-symmetric-key-transact-sql drop_symmetric_key - : DROP SYMMETRIC KEY symmetric_key_name=id_ (REMOVE PROVIDER KEY)? + : DROP SYMMETRIC KEY symmetric_key_name = id_ (REMOVE PROVIDER KEY)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-synonym-transact-sql drop_synonym - : DROP SYNONYM ( IF EXISTS )? ( schema=id_ DOT )? synonym_name=id_ + : DROP SYNONYM (IF EXISTS)? (schema = id_ DOT)? synonym_name = id_ ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-user-transact-sql drop_user - : DROP USER ( IF EXISTS )? user_name=id_ + : DROP USER (IF EXISTS)? user_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-workload-group-transact-sql drop_workload_group - : DROP WORKLOAD GROUP group_name=id_ + : DROP WORKLOAD GROUP group_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-xml-schema-collection-transact-sql drop_xml_schema_collection - : DROP XML SCHEMA COLLECTION ( relational_schema=id_ DOT )? sql_identifier=id_ + : DROP XML SCHEMA COLLECTION (relational_schema = id_ DOT)? sql_identifier = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/disable-trigger-transact-sql disable_trigger - : DISABLE TRIGGER ( ( COMMA? (schema_name=id_ DOT)? trigger_name=id_ )+ | ALL) ON ((schema_id=id_ DOT)? object_name=id_|DATABASE|ALL SERVER) + : DISABLE TRIGGER (( COMMA? (schema_name = id_ DOT)? trigger_name = id_)+ | ALL) ON ( + (schema_id = id_ DOT)? object_name = id_ + | DATABASE + | ALL SERVER + ) ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/enable-trigger-transact-sql enable_trigger - : ENABLE TRIGGER ( ( COMMA? (schema_name=id_ DOT)? trigger_name=id_ )+ | ALL) ON ( (schema_id=id_ DOT)? object_name=id_|DATABASE|ALL SERVER) + : ENABLE TRIGGER (( COMMA? (schema_name = id_ DOT)? trigger_name = id_)+ | ALL) ON ( + (schema_id = id_ DOT)? object_name = id_ + | DATABASE + | ALL SERVER + ) ; lock_table - : LOCK TABLE table_name IN (SHARE | EXCLUSIVE) MODE (WAIT seconds=DECIMAL | NOWAIT)? ';'? + : LOCK TABLE table_name IN (SHARE | EXCLUSIVE) MODE (WAIT seconds = DECIMAL | NOWAIT)? ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/truncate-table-transact-sql truncate_table - : TRUNCATE TABLE table_name - ( WITH LR_BRACKET - PARTITIONS LR_BRACKET - (COMMA? (DECIMAL|DECIMAL TO DECIMAL) )+ - RR_BRACKET - - RR_BRACKET - )? + : TRUNCATE TABLE table_name ( + WITH LR_BRACKET PARTITIONS LR_BRACKET (COMMA? (DECIMAL | DECIMAL TO DECIMAL))+ RR_BRACKET RR_BRACKET + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-column-master-key-transact-sql create_column_master_key - : CREATE COLUMN MASTER KEY key_name=id_ - WITH LR_BRACKET - KEY_STORE_PROVIDER_NAME EQUAL key_store_provider_name=STRING COMMA - KEY_PATH EQUAL key_path=STRING - RR_BRACKET + : CREATE COLUMN MASTER KEY key_name = id_ WITH LR_BRACKET KEY_STORE_PROVIDER_NAME EQUAL key_store_provider_name = STRING COMMA KEY_PATH EQUAL + key_path = STRING RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-credential-transact-sql alter_credential - : ALTER CREDENTIAL credential_name=id_ - WITH IDENTITY EQUAL identity_name=STRING - ( COMMA SECRET EQUAL secret=STRING )? + : ALTER CREDENTIAL credential_name = id_ WITH IDENTITY EQUAL identity_name = STRING ( + COMMA SECRET EQUAL secret = STRING + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-credential-transact-sql create_credential - : CREATE CREDENTIAL credential_name=id_ - WITH IDENTITY EQUAL identity_name=STRING - ( COMMA SECRET EQUAL secret=STRING )? - ( FOR CRYPTOGRAPHIC PROVIDER cryptographic_provider_name=id_ )? + : CREATE CREDENTIAL credential_name = id_ WITH IDENTITY EQUAL identity_name = STRING ( + COMMA SECRET EQUAL secret = STRING + )? (FOR CRYPTOGRAPHIC PROVIDER cryptographic_provider_name = id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-cryptographic-provider-transact-sql alter_cryptographic_provider - : ALTER CRYPTOGRAPHIC PROVIDER provider_name=id_ (FROM FILE EQUAL crypto_provider_ddl_file=STRING)? (ENABLE | DISABLE)? + : ALTER CRYPTOGRAPHIC PROVIDER provider_name = id_ ( + FROM FILE EQUAL crypto_provider_ddl_file = STRING + )? (ENABLE | DISABLE)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-cryptographic-provider-transact-sql create_cryptographic_provider - : CREATE CRYPTOGRAPHIC PROVIDER provider_name=id_ - FROM FILE EQUAL path_of_DLL=STRING + : CREATE CRYPTOGRAPHIC PROVIDER provider_name = id_ FROM FILE EQUAL path_of_DLL = STRING ; // https://learn.microsoft.com/en-us/sql/t-sql/statements/create-endpoint-transact-sql?view=sql-server-ver16 create_endpoint - : CREATE ENDPOINT endpointname=id_ (AUTHORIZATION login=id_)? - (STATE EQUAL state=(STARTED | STOPPED | DISABLED))? - AS TCP LR_BRACKET endpoint_listener_clause RR_BRACKET - ( FOR TSQL LR_BRACKET RR_BRACKET - | FOR SERVICE_BROKER LR_BRACKET - endpoint_authentication_clause - (COMMA? endpoint_encryption_alogorithm_clause)? - (COMMA? MESSAGE_FORWARDING EQUAL (ENABLED | DISABLED))? - (COMMA? MESSAGE_FORWARD_SIZE EQUAL DECIMAL)? - RR_BRACKET - | FOR DATABASE_MIRRORING LR_BRACKET - endpoint_authentication_clause - (COMMA? endpoint_encryption_alogorithm_clause)? - COMMA? ROLE EQUAL (WITNESS | PARTNER | ALL) - RR_BRACKET - ) + : CREATE ENDPOINT endpointname = id_ (AUTHORIZATION login = id_)? ( + STATE EQUAL state = (STARTED | STOPPED | DISABLED) + )? AS TCP LR_BRACKET endpoint_listener_clause RR_BRACKET ( + FOR TSQL LR_BRACKET RR_BRACKET + | FOR SERVICE_BROKER LR_BRACKET endpoint_authentication_clause ( + COMMA? endpoint_encryption_alogorithm_clause + )? (COMMA? MESSAGE_FORWARDING EQUAL (ENABLED | DISABLED))? ( + COMMA? MESSAGE_FORWARD_SIZE EQUAL DECIMAL + )? RR_BRACKET + | FOR DATABASE_MIRRORING LR_BRACKET endpoint_authentication_clause ( + COMMA? endpoint_encryption_alogorithm_clause + )? COMMA? ROLE EQUAL (WITNESS | PARTNER | ALL) RR_BRACKET + ) ; endpoint_encryption_alogorithm_clause @@ -1119,63 +1197,75 @@ endpoint_encryption_alogorithm_clause ; endpoint_authentication_clause - : AUTHENTICATION EQUAL - ( WINDOWS (NTLM | KERBEROS | NEGOTIATE)? (CERTIFICATE cert_name=id_)? - | CERTIFICATE cert_name=id_ WINDOWS? (NTLM | KERBEROS | NEGOTIATE)? - ) + : AUTHENTICATION EQUAL ( + WINDOWS (NTLM | KERBEROS | NEGOTIATE)? (CERTIFICATE cert_name = id_)? + | CERTIFICATE cert_name = id_ WINDOWS? (NTLM | KERBEROS | NEGOTIATE)? + ) ; endpoint_listener_clause - : LISTENER_PORT EQUAL port=DECIMAL - (COMMA LISTENER_IP EQUAL (ALL | '(' (ipv4=IPV4_ADDR | ipv6=STRING) ')'))? + : LISTENER_PORT EQUAL port = DECIMAL ( + COMMA LISTENER_IP EQUAL (ALL | '(' (ipv4 = IPV4_ADDR | ipv6 = STRING) ')') + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-event-notification-transact-sql create_event_notification - : CREATE EVENT NOTIFICATION event_notification_name=id_ - ON (SERVER|DATABASE|QUEUE queue_name=id_) - (WITH FAN_IN)? - FOR (COMMA? event_type_or_group=id_)+ - TO SERVICE broker_service=STRING COMMA - broker_service_specifier_or_current_database=STRING + : CREATE EVENT NOTIFICATION event_notification_name = id_ ON ( + SERVER + | DATABASE + | QUEUE queue_name = id_ + ) (WITH FAN_IN)? FOR (COMMA? event_type_or_group = id_)+ TO SERVICE broker_service = STRING COMMA broker_service_specifier_or_current_database = + STRING ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-event-session-transact-sql // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-event-session-transact-sql // todo: not implemented create_or_alter_event_session - : (CREATE | ALTER) EVENT SESSION event_session_name=id_ ON SERVER - (COMMA? ADD EVENT ( (event_module_guid=id_ DOT)? event_package_name=id_ DOT event_name=id_) - (LR_BRACKET - (SET ( COMMA? event_customizable_attributue=id_ EQUAL (DECIMAL|STRING) )* )? - ( ACTION LR_BRACKET (COMMA? (event_module_guid=id_ DOT)? event_package_name=id_ DOT action_name=id_)+ RR_BRACKET)+ - (WHERE event_session_predicate_expression)? - RR_BRACKET )* - )* - (COMMA? DROP EVENT (event_module_guid=id_ DOT)? event_package_name=id_ DOT event_name=id_ )* - - ( (ADD TARGET (event_module_guid=id_ DOT)? event_package_name=id_ DOT target_name=id_ ) ( LR_BRACKET SET (COMMA? target_parameter_name=id_ EQUAL (LR_BRACKET? DECIMAL RR_BRACKET? |STRING) )+ RR_BRACKET )* )* - (DROP TARGET (event_module_guid=id_ DOT)? event_package_name=id_ DOT target_name=id_ )* - - - (WITH - LR_BRACKET - (COMMA? MAX_MEMORY EQUAL max_memory=DECIMAL (KB|MB) )? - (COMMA? EVENT_RETENTION_MODE EQUAL (ALLOW_SINGLE_EVENT_LOSS | ALLOW_MULTIPLE_EVENT_LOSS | NO_EVENT_LOSS ) )? - (COMMA? MAX_DISPATCH_LATENCY EQUAL (max_dispatch_latency_seconds=DECIMAL SECONDS | INFINITE) )? - (COMMA? MAX_EVENT_SIZE EQUAL max_event_size=DECIMAL (KB|MB) )? - (COMMA? MEMORY_PARTITION_MODE EQUAL (NONE | PER_NODE | PER_CPU) )? - (COMMA? TRACK_CAUSALITY EQUAL (ON|OFF) )? - (COMMA? STARTUP_STATE EQUAL (ON|OFF) )? - RR_BRACKET - )? - (STATE EQUAL (START|STOP) )? - + : (CREATE | ALTER) EVENT SESSION event_session_name = id_ ON SERVER ( + COMMA? ADD EVENT ( + (event_module_guid = id_ DOT)? event_package_name = id_ DOT event_name = id_ + ) ( + LR_BRACKET (SET ( COMMA? event_customizable_attributue = id_ EQUAL (DECIMAL | STRING))*)? ( + ACTION LR_BRACKET ( + COMMA? (event_module_guid = id_ DOT)? event_package_name = id_ DOT action_name = id_ + )+ RR_BRACKET + )+ (WHERE event_session_predicate_expression)? RR_BRACKET + )* + )* ( + COMMA? DROP EVENT (event_module_guid = id_ DOT)? event_package_name = id_ DOT event_name = id_ + )* ( + (ADD TARGET (event_module_guid = id_ DOT)? event_package_name = id_ DOT target_name = id_) ( + LR_BRACKET SET ( + COMMA? target_parameter_name = id_ EQUAL (LR_BRACKET? DECIMAL RR_BRACKET? | STRING) + )+ RR_BRACKET + )* + )* (DROP TARGET (event_module_guid = id_ DOT)? event_package_name = id_ DOT target_name = id_)* ( + WITH LR_BRACKET (COMMA? MAX_MEMORY EQUAL max_memory = DECIMAL (KB | MB))? ( + COMMA? EVENT_RETENTION_MODE EQUAL ( + ALLOW_SINGLE_EVENT_LOSS + | ALLOW_MULTIPLE_EVENT_LOSS + | NO_EVENT_LOSS + ) + )? ( + COMMA? MAX_DISPATCH_LATENCY EQUAL ( + max_dispatch_latency_seconds = DECIMAL SECONDS + | INFINITE + ) + )? (COMMA? MAX_EVENT_SIZE EQUAL max_event_size = DECIMAL (KB | MB))? ( + COMMA? MEMORY_PARTITION_MODE EQUAL (NONE | PER_NODE | PER_CPU) + )? (COMMA? TRACK_CAUSALITY EQUAL (ON | OFF))? (COMMA? STARTUP_STATE EQUAL (ON | OFF))? RR_BRACKET + )? (STATE EQUAL (START | STOP))? ; event_session_predicate_expression - : ( COMMA? (AND|OR)? NOT? ( event_session_predicate_factor | LR_BRACKET event_session_predicate_expression RR_BRACKET) )+ + : ( + COMMA? (AND | OR)? NOT? ( + event_session_predicate_factor + | LR_BRACKET event_session_predicate_expression RR_BRACKET + ) + )+ ; event_session_predicate_factor @@ -1184,213 +1274,314 @@ event_session_predicate_factor ; event_session_predicate_leaf - : (event_field_name=id_ | (event_field_name=id_ |( (event_module_guid=id_ DOT)? event_package_name=id_ DOT predicate_source_name=id_ ) ) (EQUAL |(LESS GREATER) | (EXCLAMATION EQUAL) | GREATER | (GREATER EQUAL)| LESS | LESS EQUAL) (DECIMAL | STRING) ) - | (event_module_guid=id_ DOT)? event_package_name=id_ DOT predicate_compare_name=id_ LR_BRACKET (event_field_name=id_ |( (event_module_guid=id_ DOT)? event_package_name=id_ DOT predicate_source_name=id_ ) COMMA (DECIMAL | STRING) ) RR_BRACKET + : ( + event_field_name = id_ + | ( + event_field_name = id_ + | ( + (event_module_guid = id_ DOT)? event_package_name = id_ DOT predicate_source_name = id_ + ) + ) ( + EQUAL + | (LESS GREATER) + | (EXCLAMATION EQUAL) + | GREATER + | (GREATER EQUAL) + | LESS + | LESS EQUAL + ) (DECIMAL | STRING) + ) + | (event_module_guid = id_ DOT)? event_package_name = id_ DOT predicate_compare_name = id_ LR_BRACKET ( + event_field_name = id_ + | ((event_module_guid = id_ DOT)? event_package_name = id_ DOT predicate_source_name = id_) COMMA ( + DECIMAL + | STRING + ) + ) RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-external-data-source-transact-sql alter_external_data_source - : ALTER EXTERNAL DATA SOURCE data_source_name=id_ SET - ( LOCATION EQUAL location=STRING COMMA? | RESOURCE_MANAGER_LOCATION EQUAL resource_manager_location=STRING COMMA? | CREDENTIAL EQUAL credential_name=id_ )+ - | ALTER EXTERNAL DATA SOURCE data_source_name=id_ WITH LR_BRACKET TYPE EQUAL BLOB_STORAGE COMMA LOCATION EQUAL location=STRING (COMMA CREDENTIAL EQUAL credential_name=id_ )? RR_BRACKET + : ALTER EXTERNAL DATA SOURCE data_source_name = id_ SET ( + LOCATION EQUAL location = STRING COMMA? + | RESOURCE_MANAGER_LOCATION EQUAL resource_manager_location = STRING COMMA? + | CREDENTIAL EQUAL credential_name = id_ + )+ + | ALTER EXTERNAL DATA SOURCE data_source_name = id_ WITH LR_BRACKET TYPE EQUAL BLOB_STORAGE COMMA LOCATION EQUAL location = STRING ( + COMMA CREDENTIAL EQUAL credential_name = id_ + )? RR_BRACKET ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-external-library-transact-sql alter_external_library - : ALTER EXTERNAL LIBRARY library_name=id_ (AUTHORIZATION owner_name=id_)? - (SET|ADD) ( LR_BRACKET CONTENT EQUAL (client_library=STRING | BINARY | NONE) (COMMA PLATFORM EQUAL (WINDOWS|LINUX)? RR_BRACKET) WITH (COMMA? LANGUAGE EQUAL (R|PYTHON) | DATA_SOURCE EQUAL external_data_source_name=id_ )+ RR_BRACKET ) + : ALTER EXTERNAL LIBRARY library_name = id_ (AUTHORIZATION owner_name = id_)? (SET | ADD) ( + LR_BRACKET CONTENT EQUAL (client_library = STRING | BINARY | NONE) ( + COMMA PLATFORM EQUAL (WINDOWS | LINUX)? RR_BRACKET + ) WITH ( + COMMA? LANGUAGE EQUAL (R | PYTHON) + | DATA_SOURCE EQUAL external_data_source_name = id_ + )+ RR_BRACKET + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-library-transact-sql create_external_library - : CREATE EXTERNAL LIBRARY library_name=id_ (AUTHORIZATION owner_name=id_)? - FROM (COMMA? LR_BRACKET? (CONTENT EQUAL)? (client_library=STRING | BINARY | NONE) (COMMA PLATFORM EQUAL (WINDOWS|LINUX)? RR_BRACKET)? ) ( WITH (COMMA? LANGUAGE EQUAL (R|PYTHON) | DATA_SOURCE EQUAL external_data_source_name=id_ )+ RR_BRACKET )? + : CREATE EXTERNAL LIBRARY library_name = id_ (AUTHORIZATION owner_name = id_)? FROM ( + COMMA? LR_BRACKET? (CONTENT EQUAL)? (client_library = STRING | BINARY | NONE) ( + COMMA PLATFORM EQUAL (WINDOWS | LINUX)? RR_BRACKET + )? + ) ( + WITH ( + COMMA? LANGUAGE EQUAL (R | PYTHON) + | DATA_SOURCE EQUAL external_data_source_name = id_ + )+ RR_BRACKET + )? ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-external-resource-pool-transact-sql alter_external_resource_pool - : ALTER EXTERNAL RESOURCE POOL (pool_name=id_ | DEFAULT_DOUBLE_QUOTE) WITH LR_BRACKET MAX_CPU_PERCENT EQUAL max_cpu_percent=DECIMAL ( COMMA? AFFINITY CPU EQUAL (AUTO|(COMMA? DECIMAL TO DECIMAL |COMMA DECIMAL )+ ) | NUMANODE EQUAL (COMMA? DECIMAL TO DECIMAL| COMMA? DECIMAL )+ ) (COMMA? MAX_MEMORY_PERCENT EQUAL max_memory_percent=DECIMAL)? (COMMA? MAX_PROCESSES EQUAL max_processes=DECIMAL)? RR_BRACKET + : ALTER EXTERNAL RESOURCE POOL (pool_name = id_ | DEFAULT_DOUBLE_QUOTE) WITH LR_BRACKET MAX_CPU_PERCENT EQUAL max_cpu_percent = DECIMAL ( + COMMA? AFFINITY CPU EQUAL (AUTO | (COMMA? DECIMAL TO DECIMAL | COMMA DECIMAL)+) + | NUMANODE EQUAL (COMMA? DECIMAL TO DECIMAL | COMMA? DECIMAL)+ + ) (COMMA? MAX_MEMORY_PERCENT EQUAL max_memory_percent = DECIMAL)? ( + COMMA? MAX_PROCESSES EQUAL max_processes = DECIMAL + )? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-resource-pool-transact-sql create_external_resource_pool - : CREATE EXTERNAL RESOURCE POOL pool_name=id_ WITH LR_BRACKET MAX_CPU_PERCENT EQUAL max_cpu_percent=DECIMAL ( COMMA? AFFINITY CPU EQUAL (AUTO|(COMMA? DECIMAL TO DECIMAL |COMMA DECIMAL )+ ) | NUMANODE EQUAL (COMMA? DECIMAL TO DECIMAL| COMMA? DECIMAL )+ ) (COMMA? MAX_MEMORY_PERCENT EQUAL max_memory_percent=DECIMAL)? (COMMA? MAX_PROCESSES EQUAL max_processes=DECIMAL)? RR_BRACKET + : CREATE EXTERNAL RESOURCE POOL pool_name = id_ WITH LR_BRACKET MAX_CPU_PERCENT EQUAL max_cpu_percent = DECIMAL ( + COMMA? AFFINITY CPU EQUAL (AUTO | (COMMA? DECIMAL TO DECIMAL | COMMA DECIMAL)+) + | NUMANODE EQUAL (COMMA? DECIMAL TO DECIMAL | COMMA? DECIMAL)+ + ) (COMMA? MAX_MEMORY_PERCENT EQUAL max_memory_percent = DECIMAL)? ( + COMMA? MAX_PROCESSES EQUAL max_processes = DECIMAL + )? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-fulltext-catalog-transact-sql alter_fulltext_catalog - : ALTER FULLTEXT CATALOG catalog_name=id_ (REBUILD (WITH ACCENT_SENSITIVITY EQUAL (ON|OFF) )? | REORGANIZE | AS DEFAULT ) + : ALTER FULLTEXT CATALOG catalog_name = id_ ( + REBUILD (WITH ACCENT_SENSITIVITY EQUAL (ON | OFF))? + | REORGANIZE + | AS DEFAULT + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-fulltext-catalog-transact-sql create_fulltext_catalog - : CREATE FULLTEXT CATALOG catalog_name=id_ - (ON FILEGROUP filegroup=id_)? - (IN PATH rootpath=STRING)? - (WITH ACCENT_SENSITIVITY EQUAL (ON|OFF) )? - (AS DEFAULT)? - (AUTHORIZATION owner_name=id_)? + : CREATE FULLTEXT CATALOG catalog_name = id_ (ON FILEGROUP filegroup = id_)? ( + IN PATH rootpath = STRING + )? (WITH ACCENT_SENSITIVITY EQUAL (ON | OFF))? (AS DEFAULT)? (AUTHORIZATION owner_name = id_)? ; - - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-fulltext-stoplist-transact-sql alter_fulltext_stoplist - : ALTER FULLTEXT STOPLIST stoplist_name=id_ (ADD stopword=STRING LANGUAGE (STRING|DECIMAL|BINARY) | DROP ( stopword=STRING LANGUAGE (STRING|DECIMAL|BINARY) |ALL (STRING|DECIMAL|BINARY) | ALL ) ) + : ALTER FULLTEXT STOPLIST stoplist_name = id_ ( + ADD stopword = STRING LANGUAGE (STRING | DECIMAL | BINARY) + | DROP ( + stopword = STRING LANGUAGE (STRING | DECIMAL | BINARY) + | ALL (STRING | DECIMAL | BINARY) + | ALL + ) + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-fulltext-stoplist-transact-sql create_fulltext_stoplist - : CREATE FULLTEXT STOPLIST stoplist_name=id_ - (FROM ( (database_name=id_ DOT)? source_stoplist_name=id_ |SYSTEM STOPLIST ) )? - (AUTHORIZATION owner_name=id_)? + : CREATE FULLTEXT STOPLIST stoplist_name = id_ ( + FROM ((database_name = id_ DOT)? source_stoplist_name = id_ | SYSTEM STOPLIST) + )? (AUTHORIZATION owner_name = id_)? ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-login-transact-sql alter_login_sql_server - : ALTER LOGIN login_name=id_ - ( (ENABLE|DISABLE)? | WITH ( (PASSWORD EQUAL ( password=STRING | password_hash=BINARY HASHED ) ) (MUST_CHANGE|UNLOCK)* )? (OLD_PASSWORD EQUAL old_password=STRING (MUST_CHANGE|UNLOCK)* )? (DEFAULT_DATABASE EQUAL default_database=id_)? (DEFAULT_LANGUAGE EQUAL default_laguage=id_)? (NAME EQUAL login_name=id_)? (CHECK_POLICY EQUAL (ON|OFF) )? (CHECK_EXPIRATION EQUAL (ON|OFF) )? (CREDENTIAL EQUAL credential_name=id_)? (NO CREDENTIAL)? | (ADD|DROP) CREDENTIAL credential_name=id_ ) + : ALTER LOGIN login_name = id_ ( + (ENABLE | DISABLE)? + | WITH ( + (PASSWORD EQUAL ( password = STRING | password_hash = BINARY HASHED)) ( + MUST_CHANGE + | UNLOCK + )* + )? (OLD_PASSWORD EQUAL old_password = STRING (MUST_CHANGE | UNLOCK)*)? ( + DEFAULT_DATABASE EQUAL default_database = id_ + )? (DEFAULT_LANGUAGE EQUAL default_laguage = id_)? (NAME EQUAL login_name = id_)? ( + CHECK_POLICY EQUAL (ON | OFF) + )? (CHECK_EXPIRATION EQUAL (ON | OFF))? (CREDENTIAL EQUAL credential_name = id_)? ( + NO CREDENTIAL + )? + | (ADD | DROP) CREDENTIAL credential_name = id_ + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-login-transact-sql create_login_sql_server - : CREATE LOGIN login_name=id_ - ( WITH ( (PASSWORD EQUAL ( password=STRING | password_hash=BINARY HASHED ) ) (MUST_CHANGE|UNLOCK)* )? - (COMMA? SID EQUAL sid=BINARY)? - (COMMA? DEFAULT_DATABASE EQUAL default_database=id_)? - (COMMA? DEFAULT_LANGUAGE EQUAL default_laguage=id_)? - (COMMA? CHECK_EXPIRATION EQUAL (ON|OFF) )? - (COMMA? CHECK_POLICY EQUAL (ON|OFF) )? - (COMMA? CREDENTIAL EQUAL credential_name=id_)? - |(FROM - (WINDOWS - (WITH (COMMA? DEFAULT_DATABASE EQUAL default_database=id_)? (COMMA? DEFAULT_LANGUAGE EQUAL default_language=STRING)? ) - | CERTIFICATE certname=id_ - | ASYMMETRIC KEY asym_key_name=id_ + : CREATE LOGIN login_name = id_ ( + WITH ( + (PASSWORD EQUAL ( password = STRING | password_hash = BINARY HASHED)) ( + MUST_CHANGE + | UNLOCK + )* + )? (COMMA? SID EQUAL sid = BINARY)? (COMMA? DEFAULT_DATABASE EQUAL default_database = id_)? ( + COMMA? DEFAULT_LANGUAGE EQUAL default_laguage = id_ + )? (COMMA? CHECK_EXPIRATION EQUAL (ON | OFF))? (COMMA? CHECK_POLICY EQUAL (ON | OFF))? ( + COMMA? CREDENTIAL EQUAL credential_name = id_ + )? + | ( + FROM ( + WINDOWS ( + WITH (COMMA? DEFAULT_DATABASE EQUAL default_database = id_)? ( + COMMA? DEFAULT_LANGUAGE EQUAL default_language = STRING + )? ) + | CERTIFICATE certname = id_ + | ASYMMETRIC KEY asym_key_name = id_ + ) ) - ) + ) ; alter_login_azure_sql - : ALTER LOGIN login_name=id_ ( (ENABLE|DISABLE)? | WITH (PASSWORD EQUAL password=STRING (OLD_PASSWORD EQUAL old_password=STRING)? | NAME EQUAL login_name=id_ ) ) + : ALTER LOGIN login_name = id_ ( + (ENABLE | DISABLE)? + | WITH ( + PASSWORD EQUAL password = STRING (OLD_PASSWORD EQUAL old_password = STRING)? + | NAME EQUAL login_name = id_ + ) + ) ; create_login_azure_sql - : CREATE LOGIN login_name=id_ - WITH PASSWORD EQUAL STRING (SID EQUAL sid=BINARY)? + : CREATE LOGIN login_name = id_ WITH PASSWORD EQUAL STRING (SID EQUAL sid = BINARY)? ; alter_login_azure_sql_dw_and_pdw - : ALTER LOGIN login_name=id_ ( (ENABLE|DISABLE)? | WITH (PASSWORD EQUAL password=STRING (OLD_PASSWORD EQUAL old_password=STRING (MUST_CHANGE|UNLOCK)* )? | NAME EQUAL login_name=id_ ) ) + : ALTER LOGIN login_name = id_ ( + (ENABLE | DISABLE)? + | WITH ( + PASSWORD EQUAL password = STRING ( + OLD_PASSWORD EQUAL old_password = STRING (MUST_CHANGE | UNLOCK)* + )? + | NAME EQUAL login_name = id_ + ) + ) ; create_login_pdw - : CREATE LOGIN loginName=id_ - (WITH - ( PASSWORD EQUAL password=STRING (MUST_CHANGE)? - (CHECK_POLICY EQUAL (ON|OFF)? )? - ) + : CREATE LOGIN loginName = id_ ( + WITH (PASSWORD EQUAL password = STRING (MUST_CHANGE)? (CHECK_POLICY EQUAL (ON | OFF)?)?) | FROM WINDOWS - ) + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-master-key-transact-sql alter_master_key_sql_server - : ALTER MASTER KEY ( (FORCE)? REGENERATE WITH ENCRYPTION BY PASSWORD EQUAL password=STRING |(ADD|DROP) ENCRYPTION BY (SERVICE MASTER KEY | PASSWORD EQUAL encryption_password=STRING) ) + : ALTER MASTER KEY ( + (FORCE)? REGENERATE WITH ENCRYPTION BY PASSWORD EQUAL password = STRING + | (ADD | DROP) ENCRYPTION BY ( + SERVICE MASTER KEY + | PASSWORD EQUAL encryption_password = STRING + ) + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-master-key-transact-sql create_master_key_sql_server - : CREATE MASTER KEY ENCRYPTION BY PASSWORD EQUAL password=STRING + : CREATE MASTER KEY ENCRYPTION BY PASSWORD EQUAL password = STRING ; alter_master_key_azure_sql - : ALTER MASTER KEY ( (FORCE)? REGENERATE WITH ENCRYPTION BY PASSWORD EQUAL password=STRING |ADD ENCRYPTION BY (SERVICE MASTER KEY | PASSWORD EQUAL encryption_password=STRING) | DROP ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING ) + : ALTER MASTER KEY ( + (FORCE)? REGENERATE WITH ENCRYPTION BY PASSWORD EQUAL password = STRING + | ADD ENCRYPTION BY (SERVICE MASTER KEY | PASSWORD EQUAL encryption_password = STRING) + | DROP ENCRYPTION BY PASSWORD EQUAL encryption_password = STRING + ) ; create_master_key_azure_sql - : CREATE MASTER KEY (ENCRYPTION BY PASSWORD EQUAL password=STRING)? + : CREATE MASTER KEY (ENCRYPTION BY PASSWORD EQUAL password = STRING)? ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-message-type-transact-sql alter_message_type - : ALTER MESSAGE TYPE message_type_name=id_ VALIDATION EQUAL (NONE | EMPTY | WELL_FORMED_XML | VALID_XML WITH SCHEMA COLLECTION schema_collection_name=id_) + : ALTER MESSAGE TYPE message_type_name = id_ VALIDATION EQUAL ( + NONE + | EMPTY + | WELL_FORMED_XML + | VALID_XML WITH SCHEMA COLLECTION schema_collection_name = id_ + ) ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-partition-function-transact-sql alter_partition_function - : ALTER PARTITION FUNCTION partition_function_name=id_ LR_BRACKET RR_BRACKET (SPLIT|MERGE) RANGE LR_BRACKET DECIMAL RR_BRACKET + : ALTER PARTITION FUNCTION partition_function_name = id_ LR_BRACKET RR_BRACKET (SPLIT | MERGE) RANGE LR_BRACKET DECIMAL RR_BRACKET ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-partition-scheme-transact-sql alter_partition_scheme - : ALTER PARTITION SCHEME partition_scheme_name=id_ NEXT USED (file_group_name=id_)? + : ALTER PARTITION SCHEME partition_scheme_name = id_ NEXT USED (file_group_name = id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-remote-service-binding-transact-sql alter_remote_service_binding - : ALTER REMOTE SERVICE BINDING binding_name=id_ - WITH (USER EQUAL user_name=id_)? - (COMMA ANONYMOUS EQUAL (ON|OFF) )? + : ALTER REMOTE SERVICE BINDING binding_name = id_ WITH (USER EQUAL user_name = id_)? ( + COMMA ANONYMOUS EQUAL (ON | OFF) + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-remote-service-binding-transact-sql create_remote_service_binding - : CREATE REMOTE SERVICE BINDING binding_name=id_ - (AUTHORIZATION owner_name=id_)? - TO SERVICE remote_service_name=STRING - WITH (USER EQUAL user_name=id_)? - (COMMA ANONYMOUS EQUAL (ON|OFF) )? + : CREATE REMOTE SERVICE BINDING binding_name = id_ (AUTHORIZATION owner_name = id_)? TO SERVICE remote_service_name = STRING WITH ( + USER EQUAL user_name = id_ + )? (COMMA ANONYMOUS EQUAL (ON | OFF))? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-resource-pool-transact-sql create_resource_pool - : CREATE RESOURCE POOL pool_name=id_ - (WITH - LR_BRACKET - (COMMA? MIN_CPU_PERCENT EQUAL DECIMAL)? - (COMMA? MAX_CPU_PERCENT EQUAL DECIMAL)? - (COMMA? CAP_CPU_PERCENT EQUAL DECIMAL)? - (COMMA? AFFINITY SCHEDULER EQUAL - (AUTO - | LR_BRACKET (COMMA? (DECIMAL|DECIMAL TO DECIMAL) )+ RR_BRACKET - | NUMANODE EQUAL LR_BRACKET (COMMA? (DECIMAL|DECIMAL TO DECIMAL) )+ RR_BRACKET - ) - )? - (COMMA? MIN_MEMORY_PERCENT EQUAL DECIMAL)? - (COMMA? MAX_MEMORY_PERCENT EQUAL DECIMAL)? - (COMMA? MIN_IOPS_PER_VOLUME EQUAL DECIMAL)? - (COMMA? MAX_IOPS_PER_VOLUME EQUAL DECIMAL)? - RR_BRACKET - )? + : CREATE RESOURCE POOL pool_name = id_ ( + WITH LR_BRACKET (COMMA? MIN_CPU_PERCENT EQUAL DECIMAL)? ( + COMMA? MAX_CPU_PERCENT EQUAL DECIMAL + )? (COMMA? CAP_CPU_PERCENT EQUAL DECIMAL)? ( + COMMA? AFFINITY SCHEDULER EQUAL ( + AUTO + | LR_BRACKET (COMMA? (DECIMAL | DECIMAL TO DECIMAL))+ RR_BRACKET + | NUMANODE EQUAL LR_BRACKET (COMMA? (DECIMAL | DECIMAL TO DECIMAL))+ RR_BRACKET + ) + )? (COMMA? MIN_MEMORY_PERCENT EQUAL DECIMAL)? (COMMA? MAX_MEMORY_PERCENT EQUAL DECIMAL)? ( + COMMA? MIN_IOPS_PER_VOLUME EQUAL DECIMAL + )? (COMMA? MAX_IOPS_PER_VOLUME EQUAL DECIMAL)? RR_BRACKET + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-resource-governor-transact-sql alter_resource_governor - : ALTER RESOURCE GOVERNOR ( (DISABLE | RECONFIGURE) | WITH LR_BRACKET CLASSIFIER_FUNCTION EQUAL ( schema_name=id_ DOT function_name=id_ | NULL_ ) RR_BRACKET | RESET STATISTICS | WITH LR_BRACKET MAX_OUTSTANDING_IO_PER_VOLUME EQUAL max_outstanding_io_per_volume=DECIMAL RR_BRACKET ) + : ALTER RESOURCE GOVERNOR ( + (DISABLE | RECONFIGURE) + | WITH LR_BRACKET CLASSIFIER_FUNCTION EQUAL ( + schema_name = id_ DOT function_name = id_ + | NULL_ + ) RR_BRACKET + | RESET STATISTICS + | WITH LR_BRACKET MAX_OUTSTANDING_IO_PER_VOLUME EQUAL max_outstanding_io_per_volume = DECIMAL RR_BRACKET + ) ; // https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-database-audit-specification-transact-sql?view=sql-server-ver16 alter_database_audit_specification - : ALTER DATABASE AUDIT SPECIFICATION audit_specification_name=id_ - (FOR SERVER AUDIT audit_name=id_)? - (audit_action_spec_group (',' audit_action_spec_group)*)? - (WITH '(' STATE '=' (ON|OFF) ')')? + : ALTER DATABASE AUDIT SPECIFICATION audit_specification_name = id_ ( + FOR SERVER AUDIT audit_name = id_ + )? (audit_action_spec_group (',' audit_action_spec_group)*)? ( + WITH '(' STATE '=' (ON | OFF) ')' + )? ; audit_action_spec_group - : (ADD|DROP) '(' (audit_action_specification | audit_action_group_name=id_) ')' + : (ADD | DROP) '(' (audit_action_specification | audit_action_group_name = id_) ')' ; audit_action_specification - : action_specification (',' action_specification)* ON (audit_class_name '::')? audit_securable BY principal_id (',' principal_id)* + : action_specification (',' action_specification)* ON (audit_class_name '::')? audit_securable BY principal_id ( + ',' principal_id + )* ; action_specification @@ -1415,451 +1606,498 @@ audit_securable // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-role-transact-sql alter_db_role - : ALTER ROLE role_name=id_ - ( (ADD|DROP) MEMBER database_principal=id_ - | WITH NAME EQUAL new_role_name=id_ ) + : ALTER ROLE role_name = id_ ( + (ADD | DROP) MEMBER database_principal = id_ + | WITH NAME EQUAL new_role_name = id_ + ) ; // https://learn.microsoft.com/en-us/sql/t-sql/statements/create-database-audit-specification-transact-sql?view=sql-server-ver16 create_database_audit_specification - : CREATE DATABASE AUDIT SPECIFICATION audit_specification_name=id_ - (FOR SERVER AUDIT audit_name=id_)? - (audit_action_spec_group (',' audit_action_spec_group)*)? - (WITH '(' STATE '=' (ON|OFF) ')')? + : CREATE DATABASE AUDIT SPECIFICATION audit_specification_name = id_ ( + FOR SERVER AUDIT audit_name = id_ + )? (audit_action_spec_group (',' audit_action_spec_group)*)? ( + WITH '(' STATE '=' (ON | OFF) ')' + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-role-transact-sql create_db_role - : CREATE ROLE role_name=id_ (AUTHORIZATION owner_name = id_)? + : CREATE ROLE role_name = id_ (AUTHORIZATION owner_name = id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-route-transact-sql create_route - : CREATE ROUTE route_name=id_ - (AUTHORIZATION owner_name=id_)? - WITH - (COMMA? SERVICE_NAME EQUAL route_service_name=STRING)? - (COMMA? BROKER_INSTANCE EQUAL broker_instance_identifier=STRING)? - (COMMA? LIFETIME EQUAL DECIMAL)? - COMMA? ADDRESS EQUAL STRING - (COMMA MIRROR_ADDRESS EQUAL STRING )? + : CREATE ROUTE route_name = id_ (AUTHORIZATION owner_name = id_)? WITH ( + COMMA? SERVICE_NAME EQUAL route_service_name = STRING + )? (COMMA? BROKER_INSTANCE EQUAL broker_instance_identifier = STRING)? ( + COMMA? LIFETIME EQUAL DECIMAL + )? COMMA? ADDRESS EQUAL STRING (COMMA MIRROR_ADDRESS EQUAL STRING)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-rule-transact-sql create_rule - : CREATE RULE (schema_name=id_ DOT)? rule_name=id_ - AS search_condition + : CREATE RULE (schema_name = id_ DOT)? rule_name = id_ AS search_condition ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-schema-transact-sql alter_schema_sql - : ALTER SCHEMA schema_name=id_ TRANSFER ((OBJECT|TYPE|XML SCHEMA COLLECTION) DOUBLE_COLON )? id_ (DOT id_)? + : ALTER SCHEMA schema_name = id_ TRANSFER ( + (OBJECT | TYPE | XML SCHEMA COLLECTION) DOUBLE_COLON + )? id_ (DOT id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-schema-transact-sql create_schema - : CREATE SCHEMA - (schema_name=id_ - |AUTHORIZATION owner_name=id_ - | schema_name=id_ AUTHORIZATION owner_name=id_ - ) - (create_table - |create_view - | (GRANT|DENY) (SELECT|INSERT|DELETE|UPDATE) ON (SCHEMA DOUBLE_COLON)? object_name=id_ TO owner_name=id_ - | REVOKE (SELECT|INSERT|DELETE|UPDATE) ON (SCHEMA DOUBLE_COLON)? object_name=id_ FROM owner_name=id_ - )* + : CREATE SCHEMA ( + schema_name = id_ + | AUTHORIZATION owner_name = id_ + | schema_name = id_ AUTHORIZATION owner_name = id_ + ) ( + create_table + | create_view + | (GRANT | DENY) (SELECT | INSERT | DELETE | UPDATE) ON (SCHEMA DOUBLE_COLON)? object_name = id_ TO owner_name = id_ + | REVOKE (SELECT | INSERT | DELETE | UPDATE) ON (SCHEMA DOUBLE_COLON)? object_name = id_ FROM owner_name = id_ + )* ; create_schema_azure_sql_dw_and_pdw - : -CREATE SCHEMA schema_name=id_ (AUTHORIZATION owner_name=id_ )? + : CREATE SCHEMA schema_name = id_ (AUTHORIZATION owner_name = id_)? ; alter_schema_azure_sql_dw_and_pdw - : ALTER SCHEMA schema_name=id_ TRANSFER (OBJECT DOUBLE_COLON )? id_ (DOT ID)? + : ALTER SCHEMA schema_name = id_ TRANSFER (OBJECT DOUBLE_COLON)? id_ (DOT ID)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-search-property-list-transact-sql create_search_property_list - : CREATE SEARCH PROPERTY LIST new_list_name=id_ - (FROM (database_name=id_ DOT)? source_list_name=id_ )? - (AUTHORIZATION owner_name=id_)? + : CREATE SEARCH PROPERTY LIST new_list_name = id_ ( + FROM (database_name = id_ DOT)? source_list_name = id_ + )? (AUTHORIZATION owner_name = id_)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-security-policy-transact-sql create_security_policy - : CREATE SECURITY POLICY (schema_name=id_ DOT)? security_policy_name=id_ - (COMMA? ADD (FILTER|BLOCK)? PREDICATE tvf_schema_name=id_ DOT security_predicate_function_name=id_ - LR_BRACKET (COMMA? column_name_or_arguments=id_)+ RR_BRACKET - ON table_schema_name=id_ DOT name=id_ - (COMMA? AFTER (INSERT|UPDATE) - | COMMA? BEFORE (UPDATE|DELETE) - )* - )+ - (WITH LR_BRACKET - STATE EQUAL (ON|OFF) - (SCHEMABINDING (ON|OFF) )? - RR_BRACKET - )? - (NOT FOR REPLICATION)? + : CREATE SECURITY POLICY (schema_name = id_ DOT)? security_policy_name = id_ ( + COMMA? ADD (FILTER | BLOCK)? PREDICATE tvf_schema_name = id_ DOT security_predicate_function_name = id_ LR_BRACKET ( + COMMA? column_name_or_arguments = id_ + )+ RR_BRACKET ON table_schema_name = id_ DOT name = id_ ( + COMMA? AFTER (INSERT | UPDATE) + | COMMA? BEFORE (UPDATE | DELETE) + )* + )+ (WITH LR_BRACKET STATE EQUAL (ON | OFF) (SCHEMABINDING (ON | OFF))? RR_BRACKET)? ( + NOT FOR REPLICATION + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-sequence-transact-sql alter_sequence - : ALTER SEQUENCE (schema_name=id_ DOT)? sequence_name=id_ ( RESTART (WITH DECIMAL)? )? (INCREMENT BY sequnce_increment=DECIMAL )? ( MINVALUE DECIMAL| NO MINVALUE)? (MAXVALUE DECIMAL| NO MAXVALUE)? (CYCLE|NO CYCLE)? (CACHE DECIMAL | NO CACHE)? + : ALTER SEQUENCE (schema_name = id_ DOT)? sequence_name = id_ (RESTART (WITH DECIMAL)?)? ( + INCREMENT BY sequnce_increment = DECIMAL + )? (MINVALUE DECIMAL | NO MINVALUE)? (MAXVALUE DECIMAL | NO MAXVALUE)? (CYCLE | NO CYCLE)? ( + CACHE DECIMAL + | NO CACHE + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-sequence-transact-sql create_sequence - : CREATE SEQUENCE (schema_name=id_ DOT)? sequence_name=id_ - (AS data_type )? - (START WITH DECIMAL)? - (INCREMENT BY MINUS? DECIMAL)? - (MINVALUE (MINUS? DECIMAL)? | NO MINVALUE)? - (MAXVALUE (MINUS? DECIMAL)? | NO MAXVALUE)? - (CYCLE|NO CYCLE)? - (CACHE DECIMAL? | NO CACHE)? + : CREATE SEQUENCE (schema_name = id_ DOT)? sequence_name = id_ (AS data_type)? ( + START WITH DECIMAL + )? (INCREMENT BY MINUS? DECIMAL)? (MINVALUE (MINUS? DECIMAL)? | NO MINVALUE)? ( + MAXVALUE (MINUS? DECIMAL)? + | NO MAXVALUE + )? (CYCLE | NO CYCLE)? (CACHE DECIMAL? | NO CACHE)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-audit-transact-sql alter_server_audit - : ALTER SERVER AUDIT audit_name=id_ - ( ( TO - (FILE - ( LR_BRACKET - ( COMMA? FILEPATH EQUAL filepath=STRING - | COMMA? MAXSIZE EQUAL ( DECIMAL (MB|GB|TB) - | UNLIMITED - ) - | COMMA? MAX_ROLLOVER_FILES EQUAL max_rollover_files=(DECIMAL|UNLIMITED) - | COMMA? MAX_FILES EQUAL max_files=DECIMAL - | COMMA? RESERVE_DISK_SPACE EQUAL (ON|OFF) )* - RR_BRACKET ) + : ALTER SERVER AUDIT audit_name = id_ ( + ( + TO ( + FILE ( + LR_BRACKET ( + COMMA? FILEPATH EQUAL filepath = STRING + | COMMA? MAXSIZE EQUAL ( DECIMAL (MB | GB | TB) | UNLIMITED) + | COMMA? MAX_ROLLOVER_FILES EQUAL max_rollover_files = (DECIMAL | UNLIMITED) + | COMMA? MAX_FILES EQUAL max_files = DECIMAL + | COMMA? RESERVE_DISK_SPACE EQUAL (ON | OFF) + )* RR_BRACKET + ) | APPLICATION_LOG | SECURITY_LOG - ) )? - ( WITH LR_BRACKET - (COMMA? QUEUE_DELAY EQUAL queue_delay=DECIMAL - | COMMA? ON_FAILURE EQUAL (CONTINUE | SHUTDOWN|FAIL_OPERATION) - |COMMA? STATE EQUAL (ON|OFF) )* - RR_BRACKET - )? - ( WHERE ( COMMA? (NOT?) event_field_name=id_ - (EQUAL - |(LESS GREATER) - | (EXCLAMATION EQUAL) - | GREATER - | (GREATER EQUAL) - | LESS - | LESS EQUAL - ) - (DECIMAL | STRING) - | COMMA? (AND|OR) NOT? (EQUAL - |(LESS GREATER) - | (EXCLAMATION EQUAL) - | GREATER - | (GREATER EQUAL) - | LESS - | LESS EQUAL) - (DECIMAL | STRING) ) )? - |REMOVE WHERE - | MODIFY NAME EQUAL new_audit_name=id_ - ) + ) + )? ( + WITH LR_BRACKET ( + COMMA? QUEUE_DELAY EQUAL queue_delay = DECIMAL + | COMMA? ON_FAILURE EQUAL (CONTINUE | SHUTDOWN | FAIL_OPERATION) + | COMMA? STATE EQUAL (ON | OFF) + )* RR_BRACKET + )? ( + WHERE ( + COMMA? (NOT?) event_field_name = id_ ( + EQUAL + | (LESS GREATER) + | (EXCLAMATION EQUAL) + | GREATER + | (GREATER EQUAL) + | LESS + | LESS EQUAL + ) (DECIMAL | STRING) + | COMMA? (AND | OR) NOT? ( + EQUAL + | (LESS GREATER) + | (EXCLAMATION EQUAL) + | GREATER + | (GREATER EQUAL) + | LESS + | LESS EQUAL + ) (DECIMAL | STRING) + ) + )? + | REMOVE WHERE + | MODIFY NAME EQUAL new_audit_name = id_ + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-server-audit-transact-sql create_server_audit - : CREATE SERVER AUDIT audit_name=id_ - ( ( TO - (FILE - ( LR_BRACKET - ( COMMA? FILEPATH EQUAL filepath=STRING - | COMMA? MAXSIZE EQUAL ( DECIMAL (MB|GB|TB) - | UNLIMITED - ) - | COMMA? MAX_ROLLOVER_FILES EQUAL max_rollover_files=(DECIMAL|UNLIMITED) - | COMMA? MAX_FILES EQUAL max_files=DECIMAL - | COMMA? RESERVE_DISK_SPACE EQUAL (ON|OFF) )* - RR_BRACKET ) + : CREATE SERVER AUDIT audit_name = id_ ( + ( + TO ( + FILE ( + LR_BRACKET ( + COMMA? FILEPATH EQUAL filepath = STRING + | COMMA? MAXSIZE EQUAL ( DECIMAL (MB | GB | TB) | UNLIMITED) + | COMMA? MAX_ROLLOVER_FILES EQUAL max_rollover_files = (DECIMAL | UNLIMITED) + | COMMA? MAX_FILES EQUAL max_files = DECIMAL + | COMMA? RESERVE_DISK_SPACE EQUAL (ON | OFF) + )* RR_BRACKET + ) | APPLICATION_LOG | SECURITY_LOG - ) )? - ( WITH LR_BRACKET - (COMMA? QUEUE_DELAY EQUAL queue_delay=DECIMAL - | COMMA? ON_FAILURE EQUAL (CONTINUE | SHUTDOWN|FAIL_OPERATION) - |COMMA? STATE EQUAL (ON|OFF) - |COMMA? AUDIT_GUID EQUAL audit_guid=id_ - )* - - RR_BRACKET - )? - ( WHERE ( COMMA? (NOT?) event_field_name=id_ - (EQUAL - |(LESS GREATER) - | (EXCLAMATION EQUAL) - | GREATER - | (GREATER EQUAL) - | LESS - | LESS EQUAL - ) - (DECIMAL | STRING) - | COMMA? (AND|OR) NOT? (EQUAL - |(LESS GREATER) - | (EXCLAMATION EQUAL) - | GREATER - | (GREATER EQUAL) - | LESS - | LESS EQUAL) - (DECIMAL | STRING) ) )? - |REMOVE WHERE - | MODIFY NAME EQUAL new_audit_name=id_ - ) + ) + )? ( + WITH LR_BRACKET ( + COMMA? QUEUE_DELAY EQUAL queue_delay = DECIMAL + | COMMA? ON_FAILURE EQUAL (CONTINUE | SHUTDOWN | FAIL_OPERATION) + | COMMA? STATE EQUAL (ON | OFF) + | COMMA? AUDIT_GUID EQUAL audit_guid = id_ + )* RR_BRACKET + )? ( + WHERE ( + COMMA? (NOT?) event_field_name = id_ ( + EQUAL + | (LESS GREATER) + | (EXCLAMATION EQUAL) + | GREATER + | (GREATER EQUAL) + | LESS + | LESS EQUAL + ) (DECIMAL | STRING) + | COMMA? (AND | OR) NOT? ( + EQUAL + | (LESS GREATER) + | (EXCLAMATION EQUAL) + | GREATER + | (GREATER EQUAL) + | LESS + | LESS EQUAL + ) (DECIMAL | STRING) + ) + )? + | REMOVE WHERE + | MODIFY NAME EQUAL new_audit_name = id_ + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-audit-specification-transact-sql alter_server_audit_specification - : ALTER SERVER AUDIT SPECIFICATION audit_specification_name=id_ - (FOR SERVER AUDIT audit_name=id_)? - ( (ADD|DROP) LR_BRACKET audit_action_group_name=id_ RR_BRACKET )* - (WITH LR_BRACKET STATE EQUAL (ON|OFF) RR_BRACKET )? + : ALTER SERVER AUDIT SPECIFICATION audit_specification_name = id_ ( + FOR SERVER AUDIT audit_name = id_ + )? ((ADD | DROP) LR_BRACKET audit_action_group_name = id_ RR_BRACKET)* ( + WITH LR_BRACKET STATE EQUAL (ON | OFF) RR_BRACKET + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-server-audit-specification-transact-sql create_server_audit_specification - : CREATE SERVER AUDIT SPECIFICATION audit_specification_name=id_ - (FOR SERVER AUDIT audit_name=id_)? - ( ADD LR_BRACKET audit_action_group_name=id_ RR_BRACKET )* - (WITH LR_BRACKET STATE EQUAL (ON|OFF) RR_BRACKET )? + : CREATE SERVER AUDIT SPECIFICATION audit_specification_name = id_ ( + FOR SERVER AUDIT audit_name = id_ + )? (ADD LR_BRACKET audit_action_group_name = id_ RR_BRACKET)* ( + WITH LR_BRACKET STATE EQUAL (ON | OFF) RR_BRACKET + )? ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-configuration-transact-sql alter_server_configuration - : ALTER SERVER CONFIGURATION - SET ( (PROCESS AFFINITY (CPU EQUAL (AUTO | (COMMA? DECIMAL | COMMA? DECIMAL TO DECIMAL)+ ) | NUMANODE EQUAL ( COMMA? DECIMAL |COMMA? DECIMAL TO DECIMAL)+ ) | DIAGNOSTICS LOG (ON|OFF|PATH EQUAL (STRING | DEFAULT) |MAX_SIZE EQUAL (DECIMAL MB |DEFAULT)|MAX_FILES EQUAL (DECIMAL|DEFAULT) ) | FAILOVER CLUSTER PROPERTY (VERBOSELOGGING EQUAL (STRING|DEFAULT) |SQLDUMPERFLAGS EQUAL (STRING|DEFAULT) | SQLDUMPERPATH EQUAL (STRING|DEFAULT) | SQLDUMPERTIMEOUT (STRING|DEFAULT) | FAILURECONDITIONLEVEL EQUAL (STRING|DEFAULT) | HEALTHCHECKTIMEOUT EQUAL (DECIMAL|DEFAULT) ) | HADR CLUSTER CONTEXT EQUAL (STRING|LOCAL) | BUFFER POOL EXTENSION (ON LR_BRACKET FILENAME EQUAL STRING COMMA SIZE EQUAL DECIMAL (KB|MB|GB) RR_BRACKET | OFF ) | SET SOFTNUMA (ON|OFF) ) ) + : ALTER SERVER CONFIGURATION SET ( + ( + PROCESS AFFINITY ( + CPU EQUAL (AUTO | (COMMA? DECIMAL | COMMA? DECIMAL TO DECIMAL)+) + | NUMANODE EQUAL ( COMMA? DECIMAL | COMMA? DECIMAL TO DECIMAL)+ + ) + | DIAGNOSTICS LOG ( + ON + | OFF + | PATH EQUAL (STRING | DEFAULT) + | MAX_SIZE EQUAL (DECIMAL MB | DEFAULT) + | MAX_FILES EQUAL (DECIMAL | DEFAULT) + ) + | FAILOVER CLUSTER PROPERTY ( + VERBOSELOGGING EQUAL (STRING | DEFAULT) + | SQLDUMPERFLAGS EQUAL (STRING | DEFAULT) + | SQLDUMPERPATH EQUAL (STRING | DEFAULT) + | SQLDUMPERTIMEOUT (STRING | DEFAULT) + | FAILURECONDITIONLEVEL EQUAL (STRING | DEFAULT) + | HEALTHCHECKTIMEOUT EQUAL (DECIMAL | DEFAULT) + ) + | HADR CLUSTER CONTEXT EQUAL (STRING | LOCAL) + | BUFFER POOL EXTENSION ( + ON LR_BRACKET FILENAME EQUAL STRING COMMA SIZE EQUAL DECIMAL (KB | MB | GB) RR_BRACKET + | OFF + ) + | SET SOFTNUMA (ON | OFF) + ) + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-role-transact-sql alter_server_role - : ALTER SERVER ROLE server_role_name=id_ - ( (ADD|DROP) MEMBER server_principal=id_ - | WITH NAME EQUAL new_server_role_name=id_ - ) + : ALTER SERVER ROLE server_role_name = id_ ( + (ADD | DROP) MEMBER server_principal = id_ + | WITH NAME EQUAL new_server_role_name = id_ + ) ; + // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-server-role-transact-sql create_server_role - : CREATE SERVER ROLE server_role=id_ (AUTHORIZATION server_principal=id_)? + : CREATE SERVER ROLE server_role = id_ (AUTHORIZATION server_principal = id_)? ; alter_server_role_pdw - : ALTER SERVER ROLE server_role_name=id_ (ADD|DROP) MEMBER login=id_ + : ALTER SERVER ROLE server_role_name = id_ (ADD | DROP) MEMBER login = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-service-transact-sql alter_service - : ALTER SERVICE modified_service_name=id_ (ON QUEUE (schema_name=id_ DOT)? queue_name=id_)? ('(' opt_arg_clause (COMMA opt_arg_clause)* ')')? + : ALTER SERVICE modified_service_name = id_ ( + ON QUEUE (schema_name = id_ DOT)? queue_name = id_ + )? ('(' opt_arg_clause (COMMA opt_arg_clause)* ')')? ; opt_arg_clause - : (ADD|DROP) CONTRACT modified_contract_name=id_ + : (ADD | DROP) CONTRACT modified_contract_name = id_ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-service-transact-sql create_service - : CREATE SERVICE create_service_name=id_ - (AUTHORIZATION owner_name=id_)? - ON QUEUE (schema_name=id_ DOT)? queue_name=id_ - ( LR_BRACKET (COMMA? (id_|DEFAULT) )+ RR_BRACKET )? + : CREATE SERVICE create_service_name = id_ (AUTHORIZATION owner_name = id_)? ON QUEUE ( + schema_name = id_ DOT + )? queue_name = id_ (LR_BRACKET (COMMA? (id_ | DEFAULT))+ RR_BRACKET)? ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-service-master-key-transact-sql alter_service_master_key - : ALTER SERVICE MASTER KEY ( FORCE? REGENERATE | (WITH (OLD_ACCOUNT EQUAL acold_account_name=STRING COMMA OLD_PASSWORD EQUAL old_password=STRING | NEW_ACCOUNT EQUAL new_account_name=STRING COMMA NEW_PASSWORD EQUAL new_password=STRING)? ) ) + : ALTER SERVICE MASTER KEY ( + FORCE? REGENERATE + | ( + WITH ( + OLD_ACCOUNT EQUAL acold_account_name = STRING COMMA OLD_PASSWORD EQUAL old_password = STRING + | NEW_ACCOUNT EQUAL new_account_name = STRING COMMA NEW_PASSWORD EQUAL new_password = STRING + )? + ) + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-symmetric-key-transact-sql alter_symmetric_key - : ALTER SYMMETRIC KEY key_name=id_ ( (ADD|DROP) ENCRYPTION BY (CERTIFICATE certificate_name=id_ | PASSWORD EQUAL password=STRING | SYMMETRIC KEY symmetric_key_name=id_ | ASYMMETRIC KEY Asym_key_name=id_ ) ) + : ALTER SYMMETRIC KEY key_name = id_ ( + (ADD | DROP) ENCRYPTION BY ( + CERTIFICATE certificate_name = id_ + | PASSWORD EQUAL password = STRING + | SYMMETRIC KEY symmetric_key_name = id_ + | ASYMMETRIC KEY Asym_key_name = id_ + ) + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-synonym-transact-sql create_synonym - : CREATE SYNONYM (schema_name_1=id_ DOT )? synonym_name=id_ - FOR ( (server_name=id_ DOT )? (database_name=id_ DOT)? (schema_name_2=id_ DOT)? object_name=id_ - | (database_or_schema2=id_ DOT)? (schema_id_2_or_object_name=id_ DOT)? - ) + : CREATE SYNONYM (schema_name_1 = id_ DOT)? synonym_name = id_ FOR ( + (server_name = id_ DOT)? (database_name = id_ DOT)? (schema_name_2 = id_ DOT)? object_name = id_ + | (database_or_schema2 = id_ DOT)? (schema_id_2_or_object_name = id_ DOT)? + ) ; - // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-user-transact-sql alter_user - : ALTER USER username=id_ WITH (COMMA? NAME EQUAL newusername=id_ | COMMA? DEFAULT_SCHEMA EQUAL ( schema_name=id_ |NULL_ ) | COMMA? LOGIN EQUAL loginame=id_ | COMMA? PASSWORD EQUAL STRING (OLD_PASSWORD EQUAL STRING)+ | COMMA? DEFAULT_LANGUAGE EQUAL (NONE| lcid=DECIMAL| language_name_or_alias=id_) | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )+ + : ALTER USER username = id_ WITH ( + COMMA? NAME EQUAL newusername = id_ + | COMMA? DEFAULT_SCHEMA EQUAL ( schema_name = id_ | NULL_) + | COMMA? LOGIN EQUAL loginame = id_ + | COMMA? PASSWORD EQUAL STRING (OLD_PASSWORD EQUAL STRING)+ + | COMMA? DEFAULT_LANGUAGE EQUAL (NONE | lcid = DECIMAL | language_name_or_alias = id_) + | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON | OFF) + )+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-user-transact-sql create_user - : CREATE USER user_name=id_ - ( (FOR|FROM) LOGIN login_name=id_ )? - ( WITH (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id_ - |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) - )* - )? - | CREATE USER ( windows_principal=id_ - (WITH - (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id_ - |COMMA? DEFAULT_LANGUAGE EQUAL (NONE - |DECIMAL - |language_name_or_alias=id_ ) - |COMMA? SID EQUAL BINARY - |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) - )* - )? - | user_name=id_ WITH PASSWORD EQUAL password=STRING - (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id_ - |COMMA? DEFAULT_LANGUAGE EQUAL (NONE - |DECIMAL - |language_name_or_alias=id_ ) - |COMMA? SID EQUAL BINARY - |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) - )* - | Azure_Active_Directory_principal=id_ FROM EXTERNAL PROVIDER - ) - | CREATE USER user_name=id_ - ( WITHOUT LOGIN - (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id_ - |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) - )* - | (FOR|FROM) CERTIFICATE cert_name=id_ - | (FOR|FROM) ASYMMETRIC KEY asym_key_name=id_ - ) - | CREATE USER user_name=id_ + : CREATE USER user_name = id_ ((FOR | FROM) LOGIN login_name = id_)? ( + WITH ( + COMMA? DEFAULT_SCHEMA EQUAL schema_name = id_ + | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON | OFF) + )* + )? + | CREATE USER ( + windows_principal = id_ ( + WITH ( + COMMA? DEFAULT_SCHEMA EQUAL schema_name = id_ + | COMMA? DEFAULT_LANGUAGE EQUAL (NONE | DECIMAL | language_name_or_alias = id_) + | COMMA? SID EQUAL BINARY + | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON | OFF) + )* + )? + | user_name = id_ WITH PASSWORD EQUAL password = STRING ( + COMMA? DEFAULT_SCHEMA EQUAL schema_name = id_ + | COMMA? DEFAULT_LANGUAGE EQUAL (NONE | DECIMAL | language_name_or_alias = id_) + | COMMA? SID EQUAL BINARY + | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON | OFF) + )* + | Azure_Active_Directory_principal = id_ FROM EXTERNAL PROVIDER + ) + | CREATE USER user_name = id_ ( + WITHOUT LOGIN ( + COMMA? DEFAULT_SCHEMA EQUAL schema_name = id_ + | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON | OFF) + )* + | (FOR | FROM) CERTIFICATE cert_name = id_ + | (FOR | FROM) ASYMMETRIC KEY asym_key_name = id_ + ) + | CREATE USER user_name = id_ ; create_user_azure_sql_dw - : CREATE USER user_name=id_ - ( (FOR|FROM) LOGIN login_name=id_ - | WITHOUT LOGIN - )? - - ( WITH DEFAULT_SCHEMA EQUAL schema_name=id_)? - | CREATE USER Azure_Active_Directory_principal=id_ - FROM EXTERNAL PROVIDER - ( WITH DEFAULT_SCHEMA EQUAL schema_name=id_)? + : CREATE USER user_name = id_ ((FOR | FROM) LOGIN login_name = id_ | WITHOUT LOGIN)? ( + WITH DEFAULT_SCHEMA EQUAL schema_name = id_ + )? + | CREATE USER Azure_Active_Directory_principal = id_ FROM EXTERNAL PROVIDER ( + WITH DEFAULT_SCHEMA EQUAL schema_name = id_ + )? ; - alter_user_azure_sql - : ALTER USER username=id_ WITH (COMMA? NAME EQUAL newusername=id_ | COMMA? DEFAULT_SCHEMA EQUAL schema_name=id_ | COMMA? LOGIN EQUAL loginame=id_ | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )+ + : ALTER USER username = id_ WITH ( + COMMA? NAME EQUAL newusername = id_ + | COMMA? DEFAULT_SCHEMA EQUAL schema_name = id_ + | COMMA? LOGIN EQUAL loginame = id_ + | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON | OFF) + )+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-workload-group-transact-sql alter_workload_group - : ALTER WORKLOAD GROUP - (workload_group_group_name=id_ - |DEFAULT_DOUBLE_QUOTE - ) - (WITH LR_BRACKET - (IMPORTANCE EQUAL (LOW|MEDIUM|HIGH) - | COMMA? REQUEST_MAX_MEMORY_GRANT_PERCENT EQUAL request_max_memory_grant=DECIMAL - | COMMA? REQUEST_MAX_CPU_TIME_SEC EQUAL request_max_cpu_time_sec=DECIMAL - | REQUEST_MEMORY_GRANT_TIMEOUT_SEC EQUAL request_memory_grant_timeout_sec=DECIMAL - | MAX_DOP EQUAL max_dop=DECIMAL - | GROUP_MAX_REQUESTS EQUAL group_max_requests=DECIMAL)+ - RR_BRACKET )? - (USING (workload_group_pool_name=id_ | DEFAULT_DOUBLE_QUOTE) )? + : ALTER WORKLOAD GROUP (workload_group_group_name = id_ | DEFAULT_DOUBLE_QUOTE) ( + WITH LR_BRACKET ( + IMPORTANCE EQUAL (LOW | MEDIUM | HIGH) + | COMMA? REQUEST_MAX_MEMORY_GRANT_PERCENT EQUAL request_max_memory_grant = DECIMAL + | COMMA? REQUEST_MAX_CPU_TIME_SEC EQUAL request_max_cpu_time_sec = DECIMAL + | REQUEST_MEMORY_GRANT_TIMEOUT_SEC EQUAL request_memory_grant_timeout_sec = DECIMAL + | MAX_DOP EQUAL max_dop = DECIMAL + | GROUP_MAX_REQUESTS EQUAL group_max_requests = DECIMAL + )+ RR_BRACKET + )? (USING (workload_group_pool_name = id_ | DEFAULT_DOUBLE_QUOTE))? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-workload-group-transact-sql create_workload_group - : CREATE WORKLOAD GROUP workload_group_group_name=id_ - (WITH LR_BRACKET - (IMPORTANCE EQUAL (LOW|MEDIUM|HIGH) - | COMMA? REQUEST_MAX_MEMORY_GRANT_PERCENT EQUAL request_max_memory_grant=DECIMAL - | COMMA? REQUEST_MAX_CPU_TIME_SEC EQUAL request_max_cpu_time_sec=DECIMAL - | REQUEST_MEMORY_GRANT_TIMEOUT_SEC EQUAL request_memory_grant_timeout_sec=DECIMAL - | MAX_DOP EQUAL max_dop=DECIMAL - | GROUP_MAX_REQUESTS EQUAL group_max_requests=DECIMAL)+ - RR_BRACKET )? - (USING (workload_group_pool_name=id_ | DEFAULT_DOUBLE_QUOTE)? - (COMMA? EXTERNAL external_pool_name=id_ | DEFAULT_DOUBLE_QUOTE)? - )? + : CREATE WORKLOAD GROUP workload_group_group_name = id_ ( + WITH LR_BRACKET ( + IMPORTANCE EQUAL (LOW | MEDIUM | HIGH) + | COMMA? REQUEST_MAX_MEMORY_GRANT_PERCENT EQUAL request_max_memory_grant = DECIMAL + | COMMA? REQUEST_MAX_CPU_TIME_SEC EQUAL request_max_cpu_time_sec = DECIMAL + | REQUEST_MEMORY_GRANT_TIMEOUT_SEC EQUAL request_memory_grant_timeout_sec = DECIMAL + | MAX_DOP EQUAL max_dop = DECIMAL + | GROUP_MAX_REQUESTS EQUAL group_max_requests = DECIMAL + )+ RR_BRACKET + )? ( + USING (workload_group_pool_name = id_ | DEFAULT_DOUBLE_QUOTE)? ( + COMMA? EXTERNAL external_pool_name = id_ + | DEFAULT_DOUBLE_QUOTE + )? + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-xml-schema-collection-transact-sql create_xml_schema_collection - : CREATE XML SCHEMA COLLECTION (relational_schema=id_ DOT)? sql_identifier=id_ AS (STRING|id_|LOCAL_ID) + : CREATE XML SCHEMA COLLECTION (relational_schema = id_ DOT)? sql_identifier = id_ AS ( + STRING + | id_ + | LOCAL_ID + ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-partition-function-transact-sql?view=sql-server-ver15 create_partition_function - : CREATE PARTITION FUNCTION partition_function_name=id_ '(' input_parameter_type=data_type ')' - AS RANGE ( LEFT | RIGHT )? - FOR VALUES '(' boundary_values=expression_list_ ')' + : CREATE PARTITION FUNCTION partition_function_name = id_ '(' input_parameter_type = data_type ')' AS RANGE ( + LEFT + | RIGHT + )? FOR VALUES '(' boundary_values = expression_list_ ')' ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-partition-scheme-transact-sql?view=sql-server-ver15 create_partition_scheme - : CREATE PARTITION SCHEME partition_scheme_name=id_ - AS PARTITION partition_function_name=id_ - ALL? TO '(' file_group_names+=id_ (',' file_group_names+=id_)* ')' + : CREATE PARTITION SCHEME partition_scheme_name = id_ AS PARTITION partition_function_name = id_ ALL? TO '(' file_group_names += id_ ( + ',' file_group_names += id_ + )* ')' ; create_queue - : CREATE QUEUE (full_table_name | queue_name=id_) queue_settings? - (ON filegroup=id_ | DEFAULT)? + : CREATE QUEUE (full_table_name | queue_name = id_) queue_settings? ( + ON filegroup = id_ + | DEFAULT + )? ; - queue_settings - : WITH - (STATUS EQUAL on_off COMMA?)? - (RETENTION EQUAL on_off COMMA?)? - (ACTIVATION - LR_BRACKET - ( - ( - (STATUS EQUAL on_off COMMA? )? - (PROCEDURE_NAME EQUAL func_proc_name_database_schema COMMA?)? - (MAX_QUEUE_READERS EQUAL max_readers=DECIMAL COMMA?)? - (EXECUTE AS (SELF | user_name=STRING | OWNER) COMMA?)? - ) - | DROP - ) - RR_BRACKET COMMA? - )? - (POISON_MESSAGE_HANDLING - LR_BRACKET - (STATUS EQUAL on_off) - RR_BRACKET - )? + : WITH (STATUS EQUAL on_off COMMA?)? (RETENTION EQUAL on_off COMMA?)? ( + ACTIVATION LR_BRACKET ( + ( + (STATUS EQUAL on_off COMMA?)? ( + PROCEDURE_NAME EQUAL func_proc_name_database_schema COMMA? + )? (MAX_QUEUE_READERS EQUAL max_readers = DECIMAL COMMA?)? ( + EXECUTE AS (SELF | user_name = STRING | OWNER) COMMA? + )? + ) + | DROP + ) RR_BRACKET COMMA? + )? (POISON_MESSAGE_HANDLING LR_BRACKET (STATUS EQUAL on_off) RR_BRACKET)? ; alter_queue - : ALTER QUEUE (full_table_name | queue_name=id_) - (queue_settings | queue_action) + : ALTER QUEUE (full_table_name | queue_name = id_) (queue_settings | queue_action) ; queue_action - : REBUILD ( WITH LR_BRACKET queue_rebuild_options RR_BRACKET)? + : REBUILD (WITH LR_BRACKET queue_rebuild_options RR_BRACKET)? | REORGANIZE (WITH LOB_COMPACTION EQUAL on_off)? | MOVE TO (id_ | DEFAULT) ; + queue_rebuild_options : MAXDOP EQUAL DECIMAL ; create_contract - : CREATE CONTRACT contract_name - (AUTHORIZATION owner_name=id_)? - LR_BRACKET ((message_type_name=id_ | DEFAULT) - SENT BY (INITIATOR | TARGET | ANY ) COMMA?)+ - RR_BRACKET + : CREATE CONTRACT contract_name (AUTHORIZATION owner_name = id_)? LR_BRACKET ( + (message_type_name = id_ | DEFAULT) SENT BY (INITIATOR | TARGET | ANY) COMMA? + )+ RR_BRACKET ; conversation_statement @@ -1872,12 +2110,14 @@ conversation_statement ; message_statement - : CREATE MESSAGE TYPE message_type_name=id_ - (AUTHORIZATION owner_name=id_)? - (VALIDATION EQUAL (NONE - | EMPTY - | WELL_FORMED_XML - | VALID_XML WITH SCHEMA COLLECTION schema_collection_name=id_)) + : CREATE MESSAGE TYPE message_type_name = id_ (AUTHORIZATION owner_name = id_)? ( + VALIDATION EQUAL ( + NONE + | EMPTY + | WELL_FORMED_XML + | VALID_XML WITH SCHEMA COLLECTION schema_collection_name = id_ + ) + ) ; // DML @@ -1885,23 +2125,14 @@ message_statement // https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql // note that there's a limit on number of when_matches but it has to be done runtime due to different ordering of statements allowed merge_statement - : with_expression? - MERGE (TOP '(' expression ')' PERCENT?)? - INTO? ddl_object with_table_hints? as_table_alias? - USING table_sources - ON search_condition - when_matches+ - output_clause? - option_clause? ';' + : with_expression? MERGE (TOP '(' expression ')' PERCENT?)? INTO? ddl_object with_table_hints? as_table_alias? USING table_sources ON + search_condition when_matches+ output_clause? option_clause? ';' ; when_matches - : (WHEN MATCHED (AND search_condition)? - THEN merge_matched)+ - | (WHEN NOT MATCHED (BY TARGET)? (AND search_condition)? - THEN merge_not_matched) - | (WHEN NOT MATCHED BY SOURCE (AND search_condition)? - THEN merge_matched)+ + : (WHEN MATCHED (AND search_condition)? THEN merge_matched)+ + | (WHEN NOT MATCHED (BY TARGET)? (AND search_condition)? THEN merge_not_matched) + | (WHEN NOT MATCHED BY SOURCE (AND search_condition)? THEN merge_matched)+ ; merge_matched @@ -1910,38 +2141,28 @@ merge_matched ; merge_not_matched - : INSERT ('(' column_name_list ')')? - (table_value_constructor | DEFAULT VALUES) + : INSERT ('(' column_name_list ')')? (table_value_constructor | DEFAULT VALUES) ; // https://msdn.microsoft.com/en-us/library/ms189835.aspx delete_statement - : with_expression? - DELETE (TOP '(' expression ')' PERCENT? | TOP DECIMAL)? - FROM? delete_statement_from - with_table_hints? - output_clause? - (FROM table_sources)? - (WHERE (search_condition | CURRENT OF (GLOBAL? cursor_name | cursor_var=LOCAL_ID)))? - for_clause? option_clause? ';'? + : with_expression? DELETE (TOP '(' expression ')' PERCENT? | TOP DECIMAL)? FROM? delete_statement_from with_table_hints? output_clause? ( + FROM table_sources + )? (WHERE (search_condition | CURRENT OF (GLOBAL? cursor_name | cursor_var = LOCAL_ID)))? for_clause? option_clause? ';'? ; delete_statement_from : ddl_object | rowset_function_limited - | table_var=LOCAL_ID + | table_var = LOCAL_ID ; // https://msdn.microsoft.com/en-us/library/ms174335.aspx insert_statement - : with_expression? - INSERT (TOP '(' expression ')' PERCENT?)? - INTO? (ddl_object | rowset_function_limited) - with_table_hints? - ('(' insert_column_name_list ')')? - output_clause? - insert_statement_value - for_clause? option_clause? ';'? + : with_expression? INSERT (TOP '(' expression ')' PERCENT?)? INTO? ( + ddl_object + | rowset_function_limited + ) with_table_hints? ('(' insert_column_name_list ')')? output_clause? insert_statement_value for_clause? option_clause? ';'? ; insert_statement_value @@ -1951,11 +2172,10 @@ insert_statement_value | DEFAULT VALUES ; - receive_statement - : '('? RECEIVE (ALL | DISTINCT | top_clause | '*') - (LOCAL_ID '=' expression ','?)* FROM full_table_name - (INTO table_variable=id_ (WHERE where=search_condition))? ')'? + : '('? RECEIVE (ALL | DISTINCT | top_clause | '*') (LOCAL_ID '=' expression ','?)* FROM full_table_name ( + INTO table_variable = id_ (WHERE where = search_condition) + )? ')'? ; // https://msdn.microsoft.com/en-us/library/ms189499.aspx @@ -1973,21 +2193,19 @@ time // https://msdn.microsoft.com/en-us/library/ms177523.aspx update_statement - : with_expression? - UPDATE (TOP '(' expression ')' PERCENT?)? - (ddl_object | rowset_function_limited) - with_table_hints? - SET update_elem (',' update_elem)* - output_clause? - (FROM table_sources)? - (WHERE (search_condition | CURRENT OF (GLOBAL? cursor_name | cursor_var=LOCAL_ID)))? - for_clause? option_clause? ';'? + : with_expression? UPDATE (TOP '(' expression ')' PERCENT?)? ( + ddl_object + | rowset_function_limited + ) with_table_hints? SET update_elem (',' update_elem)* output_clause? (FROM table_sources)? ( + WHERE (search_condition | CURRENT OF (GLOBAL? cursor_name | cursor_var = LOCAL_ID)) + )? for_clause? option_clause? ';'? ; // https://msdn.microsoft.com/en-us/library/ms177564.aspx output_clause - : OUTPUT output_dml_list_elem (',' output_dml_list_elem)* - (INTO (LOCAL_ID | table_name) ('(' column_name_list ')')? )? + : OUTPUT output_dml_list_elem (',' output_dml_list_elem)* ( + INTO (LOCAL_ID | table_name) ('(' column_name_list ')')? + )? ; output_dml_list_elem @@ -1998,22 +2216,18 @@ output_dml_list_elem // https://msdn.microsoft.com/en-ie/library/ms176061.aspx create_database - : CREATE DATABASE (database=id_) - ( CONTAINMENT '=' ( NONE | PARTIAL ) )? - ( ON PRIMARY? database_file_spec ( ',' database_file_spec )* )? - ( LOG ON database_file_spec ( ',' database_file_spec )* )? - ( COLLATE collation_name = id_ )? - ( WITH create_database_option ( ',' create_database_option )* )? + : CREATE DATABASE (database = id_) (CONTAINMENT '=' ( NONE | PARTIAL))? ( + ON PRIMARY? database_file_spec ( ',' database_file_spec)* + )? (LOG ON database_file_spec ( ',' database_file_spec)*)? (COLLATE collation_name = id_)? ( + WITH create_database_option ( ',' create_database_option)* + )? ; // https://msdn.microsoft.com/en-us/library/ms188783.aspx create_index - : CREATE UNIQUE? clustered? INDEX id_ ON table_name '(' column_name_list_with_order ')' - (INCLUDE '(' column_name_list ')' )? - (WHERE where=search_condition)? - (create_index_options)? - (ON id_)? - ';'? + : CREATE UNIQUE? clustered? INDEX id_ ON table_name '(' column_name_list_with_order ')' ( + INCLUDE '(' column_name_list ')' + )? (WHERE where = search_condition)? (create_index_options)? (ON id_)? ';'? ; create_index_options @@ -2028,7 +2242,15 @@ relational_index_option // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-index-transact-sql alter_index - : ALTER INDEX (id_ | ALL) ON table_name (DISABLE | PAUSE | ABORT | RESUME resumable_index_options? | reorganize_partition | set_index_options | rebuild_partition) + : ALTER INDEX (id_ | ALL) ON table_name ( + DISABLE + | PAUSE + | ABORT + | RESUME resumable_index_options? + | reorganize_partition + | set_index_options + | rebuild_partition + ) ; resumable_index_options @@ -2036,8 +2258,8 @@ resumable_index_options ; resumable_index_option - : MAXDOP '=' max_degree_of_parallelism=DECIMAL - | MAX_DURATION '=' max_duration=DECIMAL MINUTES? + : MAXDOP '=' max_degree_of_parallelism = DECIMAL + | MAX_DURATION '=' max_duration = DECIMAL MINUTES? | low_priority_lock_wait ; @@ -2064,7 +2286,7 @@ set_index_option | OPTIMIZE_FOR_SEQUENTIAL_KEY '=' on_off | IGNORE_DUP_KEY '=' on_off | STATISTICS_NORECOMPUTE '=' on_off - | COMPRESSION_DELAY '=' delay=DECIMAL MINUTES? + | COMPRESSION_DELAY '=' delay = DECIMAL MINUTES? ; rebuild_partition @@ -2085,14 +2307,12 @@ rebuild_index_option | STATISTICS_INCREMENTAL '=' on_off | ONLINE '=' (ON ('(' low_priority_lock_wait ')')? | OFF) | RESUMABLE '=' on_off - | MAX_DURATION '=' times=DECIMAL MINUTES? + | MAX_DURATION '=' times = DECIMAL MINUTES? | ALLOW_ROW_LOCKS '=' on_off | ALLOW_PAGE_LOCKS '=' on_off - | MAXDOP '=' max_degree_of_parallelism=DECIMAL - | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) - on_partitions? - | XML_COMPRESSION '=' on_off - on_partitions? + | MAXDOP '=' max_degree_of_parallelism = DECIMAL + | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) on_partitions? + | XML_COMPRESSION '=' on_off on_partitions? ; single_partition_rebuild_index_options @@ -2101,28 +2321,24 @@ single_partition_rebuild_index_options single_partition_rebuild_index_option : SORT_IN_TEMPDB '=' on_off - | MAXDOP '=' max_degree_of_parallelism=DECIMAL + | MAXDOP '=' max_degree_of_parallelism = DECIMAL | RESUMABLE '=' on_off - | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) - on_partitions? - | XML_COMPRESSION '=' on_off - on_partitions? + | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) on_partitions? + | XML_COMPRESSION '=' on_off on_partitions? | ONLINE '=' (ON ('(' low_priority_lock_wait ')')? | OFF) ; on_partitions - : ON PARTITIONS '(' - partition_number=DECIMAL ( 'TO' to_partition_number=DECIMAL )? - ( ',' partition_number=DECIMAL ( 'TO' to_partition_number=DECIMAL )? )* - ')' + : ON PARTITIONS '(' partition_number = DECIMAL ('TO' to_partition_number = DECIMAL)? ( + ',' partition_number = DECIMAL ('TO' to_partition_number = DECIMAL)? + )* ')' ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-columnstore-index-transact-sql?view=sql-server-ver15 create_columnstore_index - : CREATE CLUSTERED COLUMNSTORE INDEX id_ ON table_name - create_columnstore_index_options? - (ON id_)? - ';'? + : CREATE CLUSTERED COLUMNSTORE INDEX id_ ON table_name create_columnstore_index_options? ( + ON id_ + )? ';'? ; create_columnstore_index_options @@ -2130,29 +2346,24 @@ create_columnstore_index_options ; columnstore_index_option - : - DROP_EXISTING '=' on_off - | MAXDOP '=' max_degree_of_parallelism=DECIMAL + : DROP_EXISTING '=' on_off + | MAXDOP '=' max_degree_of_parallelism = DECIMAL | ONLINE '=' on_off - | COMPRESSION_DELAY '=' delay=DECIMAL MINUTES? - | DATA_COMPRESSION '=' (COLUMNSTORE | COLUMNSTORE_ARCHIVE) - on_partitions? + | COMPRESSION_DELAY '=' delay = DECIMAL MINUTES? + | DATA_COMPRESSION '=' (COLUMNSTORE | COLUMNSTORE_ARCHIVE) on_partitions? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-columnstore-index-transact-sql?view=sql-server-ver15 create_nonclustered_columnstore_index - : CREATE NONCLUSTERED? COLUMNSTORE INDEX id_ ON table_name '(' column_name_list_with_order ')' - (WHERE search_condition)? - create_columnstore_index_options? - (ON id_)? - ';'? + : CREATE NONCLUSTERED? COLUMNSTORE INDEX id_ ON table_name '(' column_name_list_with_order ')' ( + WHERE search_condition + )? create_columnstore_index_options? (ON id_)? ';'? ; create_xml_index - : CREATE PRIMARY? XML INDEX id_ ON table_name '(' id_ ')' - (USING XML INDEX id_ (FOR (VALUE | PATH | PROPERTY)?)?)? - xml_index_options? - ';'? + : CREATE PRIMARY? XML INDEX id_ ON table_name '(' id_ ')' ( + USING XML INDEX id_ (FOR (VALUE | PATH | PROPERTY)?)? + )? xml_index_options? ';'? ; xml_index_options @@ -2168,17 +2379,17 @@ xml_index_option | ONLINE '=' (ON ('(' low_priority_lock_wait ')')? | OFF) | ALLOW_ROW_LOCKS '=' on_off | ALLOW_PAGE_LOCKS '=' on_off - | MAXDOP '=' max_degree_of_parallelism=DECIMAL + | MAXDOP '=' max_degree_of_parallelism = DECIMAL | XML_COMPRESSION '=' on_off ; - // https://msdn.microsoft.com/en-us/library/ms187926(v=sql.120).aspx create_or_alter_procedure - : ((CREATE (OR (ALTER | REPLACE))?) | ALTER) proc=(PROC | PROCEDURE) procName=func_proc_name_schema (';' DECIMAL)? - ('('? procedure_param (',' procedure_param)* ')'?)? - (WITH procedure_option (',' procedure_option)*)? - (FOR REPLICATION)? AS (as_external_name | sql_clauses*) + : ((CREATE (OR (ALTER | REPLACE))?) | ALTER) proc = (PROC | PROCEDURE) procName = func_proc_name_schema ( + ';' DECIMAL + )? ('('? procedure_param (',' procedure_param)* ')'?)? ( + WITH procedure_option (',' procedure_option)* + )? (FOR REPLICATION)? AS (as_external_name | sql_clauses*) ; as_external_name @@ -2192,14 +2403,11 @@ create_or_alter_trigger ; create_or_alter_dml_trigger - : (CREATE (OR (ALTER | REPLACE))? | ALTER) TRIGGER simple_name - ON table_name - (WITH dml_trigger_option (',' dml_trigger_option)* )? - (FOR | AFTER | INSTEAD OF) - dml_trigger_operation (',' dml_trigger_operation)* - (WITH APPEND)? - (NOT FOR REPLICATION)? - AS sql_clauses+ + : (CREATE (OR (ALTER | REPLACE))? | ALTER) TRIGGER simple_name ON table_name ( + WITH dml_trigger_option (',' dml_trigger_option)* + )? (FOR | AFTER | INSTEAD OF) dml_trigger_operation (',' dml_trigger_operation)* (WITH APPEND)? ( + NOT FOR REPLICATION + )? AS sql_clauses+ ; dml_trigger_option @@ -2212,11 +2420,9 @@ dml_trigger_operation ; create_or_alter_ddl_trigger - : (CREATE (OR (ALTER | REPLACE))? | ALTER) TRIGGER simple_name - ON (ALL SERVER | DATABASE) - (WITH dml_trigger_option (',' dml_trigger_option)* )? - (FOR | AFTER) ddl_trigger_operation (',' ddl_trigger_operation)* - AS sql_clauses+ + : (CREATE (OR (ALTER | REPLACE))? | ALTER) TRIGGER simple_name ON (ALL SERVER | DATABASE) ( + WITH dml_trigger_option (',' dml_trigger_option)* + )? (FOR | AFTER) ddl_trigger_operation (',' ddl_trigger_operation)* AS sql_clauses+ ; ddl_trigger_operation @@ -2225,35 +2431,32 @@ ddl_trigger_operation // https://msdn.microsoft.com/en-us/library/ms186755.aspx create_or_alter_function - : ((CREATE (OR ALTER)?) | ALTER) FUNCTION funcName=func_proc_name_schema - (('(' procedure_param (',' procedure_param)* ')') | '(' ')') //must have (), but can be empty - (func_body_returns_select | func_body_returns_table | func_body_returns_scalar) ';'? + : ((CREATE (OR ALTER)?) | ALTER) FUNCTION funcName = func_proc_name_schema ( + ('(' procedure_param (',' procedure_param)* ')') + | '(' ')' + ) //must have (), but can be empty + (func_body_returns_select | func_body_returns_table | func_body_returns_scalar) ';'? ; func_body_returns_select - : RETURNS TABLE - (WITH function_option (',' function_option)*)? - AS? (as_external_name | RETURN ('(' select_statement_standalone ')' | select_statement_standalone)) + : RETURNS TABLE (WITH function_option (',' function_option)*)? AS? ( + as_external_name + | RETURN ('(' select_statement_standalone ')' | select_statement_standalone) + ) ; func_body_returns_table - : RETURNS LOCAL_ID table_type_definition - (WITH function_option (',' function_option)*)? - AS? (as_external_name | - BEGIN - sql_clauses* - RETURN ';'? - END ';'?) + : RETURNS LOCAL_ID table_type_definition (WITH function_option (',' function_option)*)? AS? ( + as_external_name + | BEGIN sql_clauses* RETURN ';'? END ';'? + ) ; func_body_returns_scalar - : RETURNS data_type - (WITH function_option (',' function_option)*)? - AS? (as_external_name | - BEGIN - sql_clauses* - RETURN ret=expression ';'? - END) + : RETURNS data_type (WITH function_option (',' function_option)*)? AS? ( + as_external_name + | BEGIN sql_clauses* RETURN ret = expression ';'? END + ) ; procedure_param_default_value @@ -2264,7 +2467,9 @@ procedure_param_default_value ; procedure_param - : LOCAL_ID AS? (type_schema=id_ '.')? data_type VARYING? ('=' default_val=procedure_param_default_value)? (OUT | OUTPUT | READONLY)? + : LOCAL_ID AS? (type_schema = id_ '.')? data_type VARYING? ( + '=' default_val = procedure_param_default_value + )? (OUT | OUTPUT | READONLY)? ; procedure_option @@ -2283,15 +2488,15 @@ function_option // https://msdn.microsoft.com/en-us/library/ms188038.aspx create_statistics - : CREATE STATISTICS id_ ON table_name '(' column_name_list ')' - (WITH (FULLSCAN | SAMPLE DECIMAL (PERCENT | ROWS) | STATS_STREAM) - (',' NORECOMPUTE)? (',' INCREMENTAL EQUAL on_off)? )? ';'? + : CREATE STATISTICS id_ ON table_name '(' column_name_list ')' ( + WITH (FULLSCAN | SAMPLE DECIMAL (PERCENT | ROWS) | STATS_STREAM) (',' NORECOMPUTE)? ( + ',' INCREMENTAL EQUAL on_off + )? + )? ';'? ; update_statistics - : UPDATE STATISTICS full_table_name - ( id_ | '(' id_ ( ',' id_ )* ')' )? - update_statistics_options? + : UPDATE STATISTICS full_table_name (id_ | '(' id_ ( ',' id_)* ')')? update_statistics_options? ; update_statistics_options @@ -2299,11 +2504,10 @@ update_statistics_options ; update_statistics_option - : ( FULLSCAN (','? PERSIST_SAMPLE_PERCENT '=' on_off )? ) - | ( SAMPLE number=DECIMAL (PERCENT | ROWS) - (','? PERSIST_SAMPLE_PERCENT '=' on_off )? ) + : (FULLSCAN (','? PERSIST_SAMPLE_PERCENT '=' on_off)?) + | (SAMPLE number = DECIMAL (PERCENT | ROWS) (','? PERSIST_SAMPLE_PERCENT '=' on_off)?) | RESAMPLE on_partitions? - | STATS_STREAM '=' stats_stream_=expression + | STATS_STREAM '=' stats_stream_ = expression | ROWCOUNT '=' DECIMAL | PAGECOUNT '=' DECIMAL | ALL @@ -2311,21 +2515,23 @@ update_statistics_option | INDEX | NORECOMPUTE | INCREMENTAL '=' on_off - | MAXDOP '=' max_dregree_of_parallelism=DECIMAL + | MAXDOP '=' max_dregree_of_parallelism = DECIMAL | AUTO_DROP '=' on_off ; // https://msdn.microsoft.com/en-us/library/ms174979.aspx create_table - : CREATE TABLE table_name '(' column_def_table_constraints (','? table_indices)* ','? ')' (LOCK simple_id)? table_options* (ON id_ | DEFAULT | on_partition_or_filegroup)? (TEXTIMAGE_ON id_ | DEFAULT)?';'? + : CREATE TABLE table_name '(' column_def_table_constraints (','? table_indices)* ','? ')' ( + LOCK simple_id + )? table_options* (ON id_ | DEFAULT | on_partition_or_filegroup)? (TEXTIMAGE_ON id_ | DEFAULT)? ';'? ; table_indices - : INDEX id_ UNIQUE? clustered? '(' column_name_list_with_order ')' + : INDEX id_ UNIQUE? clustered? '(' column_name_list_with_order ')' | INDEX id_ CLUSTERED COLUMNSTORE - | INDEX id_ NONCLUSTERED? COLUMNSTORE '(' column_name_list ')' - create_table_index_options? - (ON id_)? + | INDEX id_ NONCLUSTERED? COLUMNSTORE '(' column_name_list ')' create_table_index_options? ( + ON id_ + )? ; table_options @@ -2334,17 +2540,17 @@ table_options table_option : (simple_id | keyword) '=' (simple_id | keyword | on_off | DECIMAL) - | CLUSTERED COLUMNSTORE INDEX | HEAP + | CLUSTERED COLUMNSTORE INDEX + | HEAP | FILLFACTOR '=' DECIMAL - | DISTRIBUTION '=' HASH '(' id_ ')' | CLUSTERED INDEX '(' id_ (ASC | DESC)? (',' id_ (ASC | DESC)?)* ')' - | DATA_COMPRESSION '=' (NONE | ROW | PAGE) - on_partitions? - | XML_COMPRESSION '=' on_off - on_partitions? + | DISTRIBUTION '=' HASH '(' id_ ')' + | CLUSTERED INDEX '(' id_ (ASC | DESC)? (',' id_ (ASC | DESC)?)* ')' + | DATA_COMPRESSION '=' (NONE | ROW | PAGE) on_partitions? + | XML_COMPRESSION '=' on_off on_partitions? ; create_table_index_options - : WITH '(' create_table_index_option ( ',' create_table_index_option)* ')' + : WITH '(' create_table_index_option (',' create_table_index_option)* ')' ; create_table_index_option @@ -2356,93 +2562,95 @@ create_table_index_option | ALLOW_ROW_LOCKS '=' on_off | ALLOW_PAGE_LOCKS '=' on_off | OPTIMIZE_FOR_SEQUENTIAL_KEY '=' on_off - | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) - on_partitions? - | XML_COMPRESSION '=' on_off - on_partitions? + | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) on_partitions? + | XML_COMPRESSION '=' on_off on_partitions? ; // https://msdn.microsoft.com/en-us/library/ms187956.aspx create_view - : (CREATE (OR (ALTER | REPLACE))? | ALTER) VIEW simple_name ('(' column_name_list ')')? - (WITH view_attribute (',' view_attribute)*)? - AS select_statement_standalone (WITH CHECK OPTION)? ';'? + : (CREATE (OR (ALTER | REPLACE))? | ALTER) VIEW simple_name ('(' column_name_list ')')? ( + WITH view_attribute (',' view_attribute)* + )? AS select_statement_standalone (WITH CHECK OPTION)? ';'? ; view_attribute - : ENCRYPTION | SCHEMABINDING | VIEW_METADATA + : ENCRYPTION + | SCHEMABINDING + | VIEW_METADATA ; // https://msdn.microsoft.com/en-us/library/ms190273.aspx alter_table - : ALTER TABLE table_name (SET '(' LOCK_ESCALATION '=' (AUTO | TABLE | DISABLE) ')' - | ADD column_def_table_constraints - | ALTER COLUMN (column_definition | column_modifier) - | DROP COLUMN id_ (',' id_)* - | DROP CONSTRAINT constraint=id_ - | WITH (CHECK | NOCHECK) ADD (CONSTRAINT constraint=id_)? - ( FOREIGN KEY '(' fk=column_name_list ')' REFERENCES table_name ('(' pk=column_name_list')')? (on_delete | on_update)* - | CHECK '(' search_condition ')' ) - | (NOCHECK | CHECK) CONSTRAINT constraint=id_ - | (ENABLE | DISABLE) TRIGGER id_? - | REBUILD table_options - | SWITCH switch_partition) - ';'? + : ALTER TABLE table_name ( + SET '(' LOCK_ESCALATION '=' (AUTO | TABLE | DISABLE) ')' + | ADD column_def_table_constraints + | ALTER COLUMN (column_definition | column_modifier) + | DROP COLUMN id_ (',' id_)* + | DROP CONSTRAINT constraint = id_ + | WITH (CHECK | NOCHECK) ADD (CONSTRAINT constraint = id_)? ( + FOREIGN KEY '(' fk = column_name_list ')' REFERENCES table_name ( + '(' pk = column_name_list ')' + )? (on_delete | on_update)* + | CHECK '(' search_condition ')' + ) + | (NOCHECK | CHECK) CONSTRAINT constraint = id_ + | (ENABLE | DISABLE) TRIGGER id_? + | REBUILD table_options + | SWITCH switch_partition + ) ';'? ; switch_partition - : (PARTITION? source_partition_number_expression=expression)? - TO target_table=table_name - (PARTITION target_partition_number_expression=expression)? - (WITH low_priority_lock_wait)? + : (PARTITION? source_partition_number_expression = expression)? TO target_table = table_name ( + PARTITION target_partition_number_expression = expression + )? (WITH low_priority_lock_wait)? ; low_priority_lock_wait - : WAIT_AT_LOW_PRIORITY '(' - MAX_DURATION '=' max_duration=time MINUTES? ',' - ABORT_AFTER_WAIT '=' abort_after_wait=(NONE | SELF | BLOCKERS) ')' + : WAIT_AT_LOW_PRIORITY '(' MAX_DURATION '=' max_duration = time MINUTES? ',' ABORT_AFTER_WAIT '=' abort_after_wait = ( + NONE + | SELF + | BLOCKERS + ) ')' ; // https://msdn.microsoft.com/en-us/library/ms174269.aspx alter_database - : ALTER DATABASE (database=id_ | CURRENT) - (MODIFY NAME '=' new_name=id_ - | COLLATE collation=id_ - | SET database_optionspec (WITH termination)? - | add_or_modify_files - | add_or_modify_filegroups - ) ';'? + : ALTER DATABASE (database = id_ | CURRENT) ( + MODIFY NAME '=' new_name = id_ + | COLLATE collation = id_ + | SET database_optionspec (WITH termination)? + | add_or_modify_files + | add_or_modify_filegroups + ) ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-file-and-filegroup-options?view=sql-server-ver15 add_or_modify_files - : ADD FILE filespec (',' filespec)* (TO FILEGROUP filegroup_name=id_)? + : ADD FILE filespec (',' filespec)* (TO FILEGROUP filegroup_name = id_)? | ADD LOG FILE filespec (',' filespec)* - | REMOVE FILE logical_file_name=id_ + | REMOVE FILE logical_file_name = id_ | MODIFY FILE filespec ; filespec - : '(' NAME '=' name=id_or_string - (',' NEWNAME '=' new_name=id_or_string )? - (',' FILENAME '=' file_name=STRING )? - (',' SIZE '=' size=file_size )? - (',' MAXSIZE '=' (max_size=file_size) | UNLIMITED )? - (',' FILEGROWTH '=' growth_increment=file_size )? - (',' OFFLINE )? - ')' + : '(' NAME '=' name = id_or_string (',' NEWNAME '=' new_name = id_or_string)? ( + ',' FILENAME '=' file_name = STRING + )? (',' SIZE '=' size = file_size)? (',' MAXSIZE '=' (max_size = file_size) | UNLIMITED)? ( + ',' FILEGROWTH '=' growth_increment = file_size + )? (',' OFFLINE)? ')' ; add_or_modify_filegroups - : ADD FILEGROUP filegroup_name=id_ (CONTAINS FILESTREAM | CONTAINS MEMORY_OPTIMIZED_DATA)? - | REMOVE FILEGROUP filegrou_name=id_ - | MODIFY FILEGROUP filegrou_name=id_ ( - filegroup_updatability_option + : ADD FILEGROUP filegroup_name = id_ (CONTAINS FILESTREAM | CONTAINS MEMORY_OPTIMIZED_DATA)? + | REMOVE FILEGROUP filegrou_name = id_ + | MODIFY FILEGROUP filegrou_name = id_ ( + filegroup_updatability_option | DEFAULT - | NAME '=' new_filegroup_name=id_ + | NAME '=' new_filegroup_name = id_ | AUTOGROW_SINGLE_FILE | AUTOGROW_ALL_FILES - ) + ) ; filegroup_updatability_option @@ -2471,9 +2679,9 @@ database_optionspec | hadr_options | mixed_page_allocation_option | parameterization_option -// | query_store_options + // | query_store_options | recovery_option -// | remote_data_archive_option + // | remote_data_archive_option | service_broker_option | snapshot_option | sql_option @@ -2483,48 +2691,49 @@ database_optionspec auto_option : AUTO_CLOSE on_off - | AUTO_CREATE_STATISTICS OFF | ON ( INCREMENTAL EQUAL ON | OFF ) - | AUTO_SHRINK on_off + | AUTO_CREATE_STATISTICS OFF + | ON ( INCREMENTAL EQUAL ON | OFF) + | AUTO_SHRINK on_off | AUTO_UPDATE_STATISTICS on_off - | AUTO_UPDATE_STATISTICS_ASYNC (ON | OFF ) + | AUTO_UPDATE_STATISTICS_ASYNC (ON | OFF) ; change_tracking_option - : CHANGE_TRACKING EQUAL ( OFF | ON '(' (change_tracking_option_list (',' change_tracking_option_list)*)* ')' ) + : CHANGE_TRACKING EQUAL ( + OFF + | ON '(' (change_tracking_option_list (',' change_tracking_option_list)*)* ')' + ) ; change_tracking_option_list : AUTO_CLEANUP EQUAL on_off - | CHANGE_RETENTION EQUAL DECIMAL ( DAYS | HOURS | MINUTES ) + | CHANGE_RETENTION EQUAL DECIMAL ( DAYS | HOURS | MINUTES) ; containment_option - : CONTAINMENT EQUAL ( NONE | PARTIAL ) + : CONTAINMENT EQUAL (NONE | PARTIAL) ; cursor_option : CURSOR_CLOSE_ON_COMMIT on_off - | CURSOR_DEFAULT ( LOCAL | GLOBAL ) + | CURSOR_DEFAULT ( LOCAL | GLOBAL) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-endpoint-transact-sql alter_endpoint - : ALTER ENDPOINT endpointname=id_ (AUTHORIZATION login=id_)? - (STATE EQUAL state=(STARTED | STOPPED | DISABLED))? - AS TCP LR_BRACKET endpoint_listener_clause RR_BRACKET - ( FOR TSQL LR_BRACKET RR_BRACKET - | FOR SERVICE_BROKER LR_BRACKET - endpoint_authentication_clause - (COMMA? endpoint_encryption_alogorithm_clause)? - (COMMA? MESSAGE_FORWARDING EQUAL (ENABLED | DISABLED))? - (COMMA? MESSAGE_FORWARD_SIZE EQUAL DECIMAL)? - RR_BRACKET - | FOR DATABASE_MIRRORING LR_BRACKET - endpoint_authentication_clause - (COMMA? endpoint_encryption_alogorithm_clause)? - COMMA? ROLE EQUAL (WITNESS | PARTNER | ALL) - RR_BRACKET - ) + : ALTER ENDPOINT endpointname = id_ (AUTHORIZATION login = id_)? ( + STATE EQUAL state = (STARTED | STOPPED | DISABLED) + )? AS TCP LR_BRACKET endpoint_listener_clause RR_BRACKET ( + FOR TSQL LR_BRACKET RR_BRACKET + | FOR SERVICE_BROKER LR_BRACKET endpoint_authentication_clause ( + COMMA? endpoint_encryption_alogorithm_clause + )? (COMMA? MESSAGE_FORWARDING EQUAL (ENABLED | DISABLED))? ( + COMMA? MESSAGE_FORWARD_SIZE EQUAL DECIMAL + )? RR_BRACKET + | FOR DATABASE_MIRRORING LR_BRACKET endpoint_authentication_clause ( + COMMA? endpoint_encryption_alogorithm_clause + )? COMMA? ROLE EQUAL (WITNESS | PARTNER | ALL) RR_BRACKET + ) ; /* Will visit later @@ -2534,9 +2743,10 @@ database_mirroring_option ; mirroring_set_option - : mirroring_partner partner_option - | mirroring_witness witness_option + : mirroring_partner partner_option + | mirroring_witness witness_option ; + mirroring_partner : PARTNER ; @@ -2549,14 +2759,13 @@ witness_partner_equal : EQUAL ; - partner_option : witness_partner_equal partner_server | FAILOVER | FORCE_SERVICE_ALLOW_DATA_LOSS | OFF | RESUME - | SAFETY (FULL | OFF ) + | SAFETY (FULL | OFF) | SUSPEND | TIMEOUT DECIMAL ; @@ -2581,13 +2790,14 @@ mirroring_host_port_seperator partner_server_tcp_prefix : TCP COLON DOUBLE_FORWARD_SLASH ; + port_number - : port=DECIMAL + : port = DECIMAL ; host : id_ DOT host - | (id_ DOT |id_) + | (id_ DOT | id_) ; date_correlation_optimization_option @@ -2597,62 +2807,67 @@ date_correlation_optimization_option db_encryption_option : ENCRYPTION on_off ; + db_state_option - : ( ONLINE | OFFLINE | EMERGENCY ) + : (ONLINE | OFFLINE | EMERGENCY) ; db_update_option - : READ_ONLY | READ_WRITE + : READ_ONLY + | READ_WRITE ; db_user_access_option - : SINGLE_USER | RESTRICTED_USER | MULTI_USER + : SINGLE_USER + | RESTRICTED_USER + | MULTI_USER ; + delayed_durability_option - : DELAYED_DURABILITY EQUAL ( DISABLED | ALLOWED | FORCED ) + : DELAYED_DURABILITY EQUAL (DISABLED | ALLOWED | FORCED) ; external_access_option : DB_CHAINING on_off | TRUSTWORTHY on_off - | DEFAULT_LANGUAGE EQUAL ( id_ | STRING ) - | DEFAULT_FULLTEXT_LANGUAGE EQUAL ( id_ | STRING ) - | NESTED_TRIGGERS EQUAL ( OFF | ON ) - | TRANSFORM_NOISE_WORDS EQUAL ( OFF | ON ) + | DEFAULT_LANGUAGE EQUAL ( id_ | STRING) + | DEFAULT_FULLTEXT_LANGUAGE EQUAL ( id_ | STRING) + | NESTED_TRIGGERS EQUAL ( OFF | ON) + | TRANSFORM_NOISE_WORDS EQUAL ( OFF | ON) | TWO_DIGIT_YEAR_CUTOFF EQUAL DECIMAL ; hadr_options - : HADR - ( ( AVAILABILITY GROUP EQUAL availability_group_name=id_ | OFF ) |(SUSPEND|RESUME) ) + : HADR (( AVAILABILITY GROUP EQUAL availability_group_name = id_ | OFF) | (SUSPEND | RESUME)) ; mixed_page_allocation_option - : MIXED_PAGE_ALLOCATION ( OFF | ON ) + : MIXED_PAGE_ALLOCATION (OFF | ON) ; parameterization_option - : PARAMETERIZATION ( SIMPLE | FORCED ) + : PARAMETERIZATION (SIMPLE | FORCED) ; recovery_option - : RECOVERY ( FULL | BULK_LOGGED | SIMPLE ) + : RECOVERY (FULL | BULK_LOGGED | SIMPLE) | TORN_PAGE_DETECTION on_off | ACCELERATED_DATABASE_RECOVERY '=' on_off - | PAGE_VERIFY ( CHECKSUM | TORN_PAGE_DETECTION | NONE ) + | PAGE_VERIFY ( CHECKSUM | TORN_PAGE_DETECTION | NONE) ; -service_broker_option: - ENABLE_BROKER +service_broker_option + : ENABLE_BROKER | DISABLE_BROKER | NEW_BROKER | ERROR_BROKER_CONVERSATIONS | HONOR_BROKER_PRIORITY on_off ; + snapshot_option : ALLOW_SNAPSHOT_ISOLATION on_off - | READ_COMMITTED_SNAPSHOT (ON | OFF ) - | MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = (ON | OFF ) + | READ_COMMITTED_SNAPSHOT (ON | OFF) + | MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = (ON | OFF) ; sql_option @@ -2669,7 +2884,7 @@ sql_option ; target_recovery_time_option - : TARGET_RECOVERY_TIME EQUAL DECIMAL ( SECONDS | MINUTES ) + : TARGET_RECOVERY_TIME EQUAL DECIMAL (SECONDS | MINUTES) ; termination @@ -2680,24 +2895,23 @@ termination // https://msdn.microsoft.com/en-us/library/ms176118.aspx drop_index - : DROP INDEX (IF EXISTS)? - ( drop_relational_or_xml_or_spatial_index (',' drop_relational_or_xml_or_spatial_index)* - | drop_backward_compatible_index (',' drop_backward_compatible_index)* - ) - ';'? + : DROP INDEX (IF EXISTS)? ( + drop_relational_or_xml_or_spatial_index (',' drop_relational_or_xml_or_spatial_index)* + | drop_backward_compatible_index (',' drop_backward_compatible_index)* + ) ';'? ; drop_relational_or_xml_or_spatial_index - : index_name=id_ ON full_table_name + : index_name = id_ ON full_table_name ; drop_backward_compatible_index - : (owner_name=id_ '.')? table_or_view_name=id_ '.' index_name=id_ + : (owner_name = id_ '.')? table_or_view_name = id_ '.' index_name = id_ ; // https://msdn.microsoft.com/en-us/library/ms174969.aspx drop_procedure - : DROP proc=(PROC | PROCEDURE) (IF EXISTS)? func_proc_name_schema (',' func_proc_name_schema)* ';'? + : DROP proc = (PROC | PROCEDURE) (IF EXISTS)? func_proc_name_schema (',' func_proc_name_schema)* ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-trigger-transact-sql @@ -2711,8 +2925,7 @@ drop_dml_trigger ; drop_ddl_trigger - : DROP TRIGGER (IF EXISTS)? simple_name (',' simple_name)* - ON (DATABASE | ALL SERVER) ';'? + : DROP TRIGGER (IF EXISTS)? simple_name (',' simple_name)* ON (DATABASE | ALL SERVER) ';'? ; // https://msdn.microsoft.com/en-us/library/ms190290.aspx @@ -2722,7 +2935,7 @@ drop_function // https://msdn.microsoft.com/en-us/library/ms175075.aspx drop_statistics - : DROP STATISTICS (COMMA? (table_name '.')? name=id_)+ ';' + : DROP STATISTICS (COMMA? (table_name '.')? name = id_)+ ';' ; // https://msdn.microsoft.com/en-us/library/ms173790.aspx @@ -2736,13 +2949,13 @@ drop_view ; create_type - : CREATE TYPE name = simple_name - (FROM data_type null_notnull?)? - (AS TABLE LR_BRACKET column_def_table_constraints RR_BRACKET)? + : CREATE TYPE name = simple_name (FROM data_type null_notnull?)? ( + AS TABLE LR_BRACKET column_def_table_constraints RR_BRACKET + )? ; -drop_type: - DROP TYPE ( IF EXISTS )? name = simple_name +drop_type + : DROP TYPE (IF EXISTS)? name = simple_name ; rowset_function_limited @@ -2752,13 +2965,14 @@ rowset_function_limited // https://msdn.microsoft.com/en-us/library/ms188427(v=sql.120).aspx openquery - : OPENQUERY '(' linked_server=id_ ',' query=STRING ')' + : OPENQUERY '(' linked_server = id_ ',' query = STRING ')' ; // https://msdn.microsoft.com/en-us/library/ms179856.aspx opendatasource - : OPENDATASOURCE '(' provider=STRING ',' init=STRING ')' - '.' (database=id_)? '.' (scheme=id_)? '.' (table=id_) + : OPENDATASOURCE '(' provider = STRING ',' init = STRING ')' '.' (database = id_)? '.' ( + scheme = id_ + )? '.' (table = id_) ; // Other statements. @@ -2766,19 +2980,19 @@ opendatasource // https://msdn.microsoft.com/en-us/library/ms188927.aspx declare_statement : DECLARE LOCAL_ID AS? (data_type | table_type_definition | table_name) - | DECLARE loc+=declare_local (',' loc+=declare_local)* + | DECLARE loc += declare_local (',' loc += declare_local)* | DECLARE LOCAL_ID AS? xml_type_definition - | WITH XMLNAMESPACES '(' xml_dec+=xml_declaration (',' xml_dec+=xml_declaration)* ')' + | WITH XMLNAMESPACES '(' xml_dec += xml_declaration (',' xml_dec += xml_declaration)* ')' ; xml_declaration - : xml_namespace_uri=STRING AS id_ + : xml_namespace_uri = STRING AS id_ | DEFAULT STRING ; // https://msdn.microsoft.com/en-us/library/ms181441(v=sql.120).aspx cursor_statement - // https://msdn.microsoft.com/en-us/library/ms175035(v=sql.120).aspx +// https://msdn.microsoft.com/en-us/library/ms175035(v=sql.120).aspx : CLOSE GLOBAL? cursor_name ';'? // https://msdn.microsoft.com/en-us/library/ms188782(v=sql.120).aspx | DEALLOCATE GLOBAL? CURSOR? cursor_name ';'? @@ -2789,132 +3003,119 @@ cursor_statement // https://msdn.microsoft.com/en-us/library/ms190500(v=sql.120).aspx | OPEN GLOBAL? cursor_name ';'? ; + // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql backup_database - : BACKUP DATABASE ( database_name=id_ ) - (READ_WRITE_FILEGROUPS (COMMA? (FILE|FILEGROUP) EQUAL file_or_filegroup=STRING)* )? - (COMMA? (FILE|FILEGROUP) EQUAL file_or_filegroup=STRING)* - ( TO ( COMMA? logical_device_name=id_)+ - | TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id_) )+ - ) - - ( (MIRROR TO ( COMMA? logical_device_name=id_)+ )+ - | ( MIRROR TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id_) )+ )+ - )? - - (WITH ( COMMA? DIFFERENTIAL - | COMMA? COPY_ONLY - | COMMA? (COMPRESSION|NO_COMPRESSION) - | COMMA? DESCRIPTION EQUAL (STRING|id_) - | COMMA? NAME EQUAL backup_set_name=id_ - | COMMA? CREDENTIAL - | COMMA? FILE_SNAPSHOT - | COMMA? (EXPIREDATE EQUAL (STRING|id_) | RETAINDAYS EQUAL (DECIMAL|id_) ) - | COMMA? (NOINIT|INIT) - | COMMA? (NOSKIP|SKIP_KEYWORD) - | COMMA? (NOFORMAT|FORMAT) - | COMMA? MEDIADESCRIPTION EQUAL (STRING|id_) - | COMMA? MEDIANAME EQUAL (medianame=STRING) - | COMMA? BLOCKSIZE EQUAL (DECIMAL|id_) - | COMMA? BUFFERCOUNT EQUAL (DECIMAL|id_) - | COMMA? MAXTRANSFER EQUAL (DECIMAL|id_) - | COMMA? (NO_CHECKSUM|CHECKSUM) - | COMMA? (STOP_ON_ERROR|CONTINUE_AFTER_ERROR) - | COMMA? RESTART - | COMMA? STATS (EQUAL stats_percent=DECIMAL)? - | COMMA? (REWIND|NOREWIND) - | COMMA? (LOAD|NOUNLOAD) - | COMMA? ENCRYPTION LR_BRACKET - ALGORITHM EQUAL - (AES_128 - | AES_192 - | AES_256 - | TRIPLE_DES_3KEY - ) - COMMA - SERVER CERTIFICATE EQUAL - (encryptor_name=id_ - | SERVER ASYMMETRIC KEY EQUAL encryptor_name=id_ - ) - )* - )? - + : BACKUP DATABASE (database_name = id_) ( + READ_WRITE_FILEGROUPS (COMMA? (FILE | FILEGROUP) EQUAL file_or_filegroup = STRING)* + )? (COMMA? (FILE | FILEGROUP) EQUAL file_or_filegroup = STRING)* ( + TO ( COMMA? logical_device_name = id_)+ + | TO ( COMMA? (DISK | TAPE | URL) EQUAL (STRING | id_))+ + ) ( + (MIRROR TO ( COMMA? logical_device_name = id_)+)+ + | ( MIRROR TO ( COMMA? (DISK | TAPE | URL) EQUAL (STRING | id_))+)+ + )? ( + WITH ( + COMMA? DIFFERENTIAL + | COMMA? COPY_ONLY + | COMMA? (COMPRESSION | NO_COMPRESSION) + | COMMA? DESCRIPTION EQUAL (STRING | id_) + | COMMA? NAME EQUAL backup_set_name = id_ + | COMMA? CREDENTIAL + | COMMA? FILE_SNAPSHOT + | COMMA? (EXPIREDATE EQUAL (STRING | id_) | RETAINDAYS EQUAL (DECIMAL | id_)) + | COMMA? (NOINIT | INIT) + | COMMA? (NOSKIP | SKIP_KEYWORD) + | COMMA? (NOFORMAT | FORMAT) + | COMMA? MEDIADESCRIPTION EQUAL (STRING | id_) + | COMMA? MEDIANAME EQUAL (medianame = STRING) + | COMMA? BLOCKSIZE EQUAL (DECIMAL | id_) + | COMMA? BUFFERCOUNT EQUAL (DECIMAL | id_) + | COMMA? MAXTRANSFER EQUAL (DECIMAL | id_) + | COMMA? (NO_CHECKSUM | CHECKSUM) + | COMMA? (STOP_ON_ERROR | CONTINUE_AFTER_ERROR) + | COMMA? RESTART + | COMMA? STATS (EQUAL stats_percent = DECIMAL)? + | COMMA? (REWIND | NOREWIND) + | COMMA? (LOAD | NOUNLOAD) + | COMMA? ENCRYPTION LR_BRACKET ALGORITHM EQUAL ( + AES_128 + | AES_192 + | AES_256 + | TRIPLE_DES_3KEY + ) COMMA SERVER CERTIFICATE EQUAL ( + encryptor_name = id_ + | SERVER ASYMMETRIC KEY EQUAL encryptor_name = id_ + ) + )* + )? ; backup_log - : BACKUP LOG ( database_name=id_ ) - ( TO ( COMMA? logical_device_name=id_)+ - | TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id_) )+ - ) - - ( (MIRROR TO ( COMMA? logical_device_name=id_)+ )+ - | ( MIRROR TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id_) )+ )+ - )? - - (WITH ( COMMA? DIFFERENTIAL - | COMMA? COPY_ONLY - | COMMA? (COMPRESSION|NO_COMPRESSION) - | COMMA? DESCRIPTION EQUAL (STRING|id_) - | COMMA? NAME EQUAL backup_set_name=id_ - | COMMA? CREDENTIAL - | COMMA? FILE_SNAPSHOT - | COMMA? (EXPIREDATE EQUAL (STRING|id_) | RETAINDAYS EQUAL (DECIMAL|id_) ) - | COMMA? (NOINIT|INIT) - | COMMA? (NOSKIP|SKIP_KEYWORD) - | COMMA? (NOFORMAT|FORMAT) - | COMMA? MEDIADESCRIPTION EQUAL (STRING|id_) - | COMMA? MEDIANAME EQUAL (medianame=STRING) - | COMMA? BLOCKSIZE EQUAL (DECIMAL|id_) - | COMMA? BUFFERCOUNT EQUAL (DECIMAL|id_) - | COMMA? MAXTRANSFER EQUAL (DECIMAL|id_) - | COMMA? (NO_CHECKSUM|CHECKSUM) - | COMMA? (STOP_ON_ERROR|CONTINUE_AFTER_ERROR) - | COMMA? RESTART - | COMMA? STATS (EQUAL stats_percent=DECIMAL)? - | COMMA? (REWIND|NOREWIND) - | COMMA? (LOAD|NOUNLOAD) - | COMMA? (NORECOVERY| STANDBY EQUAL undo_file_name=STRING) - | COMMA? NO_TRUNCATE - | COMMA? ENCRYPTION LR_BRACKET - ALGORITHM EQUAL - (AES_128 - | AES_192 - | AES_256 - | TRIPLE_DES_3KEY - ) - COMMA - SERVER CERTIFICATE EQUAL - (encryptor_name=id_ - | SERVER ASYMMETRIC KEY EQUAL encryptor_name=id_ - ) - )* - )? - + : BACKUP LOG (database_name = id_) ( + TO ( COMMA? logical_device_name = id_)+ + | TO ( COMMA? (DISK | TAPE | URL) EQUAL (STRING | id_))+ + ) ( + (MIRROR TO ( COMMA? logical_device_name = id_)+)+ + | ( MIRROR TO ( COMMA? (DISK | TAPE | URL) EQUAL (STRING | id_))+)+ + )? ( + WITH ( + COMMA? DIFFERENTIAL + | COMMA? COPY_ONLY + | COMMA? (COMPRESSION | NO_COMPRESSION) + | COMMA? DESCRIPTION EQUAL (STRING | id_) + | COMMA? NAME EQUAL backup_set_name = id_ + | COMMA? CREDENTIAL + | COMMA? FILE_SNAPSHOT + | COMMA? (EXPIREDATE EQUAL (STRING | id_) | RETAINDAYS EQUAL (DECIMAL | id_)) + | COMMA? (NOINIT | INIT) + | COMMA? (NOSKIP | SKIP_KEYWORD) + | COMMA? (NOFORMAT | FORMAT) + | COMMA? MEDIADESCRIPTION EQUAL (STRING | id_) + | COMMA? MEDIANAME EQUAL (medianame = STRING) + | COMMA? BLOCKSIZE EQUAL (DECIMAL | id_) + | COMMA? BUFFERCOUNT EQUAL (DECIMAL | id_) + | COMMA? MAXTRANSFER EQUAL (DECIMAL | id_) + | COMMA? (NO_CHECKSUM | CHECKSUM) + | COMMA? (STOP_ON_ERROR | CONTINUE_AFTER_ERROR) + | COMMA? RESTART + | COMMA? STATS (EQUAL stats_percent = DECIMAL)? + | COMMA? (REWIND | NOREWIND) + | COMMA? (LOAD | NOUNLOAD) + | COMMA? (NORECOVERY | STANDBY EQUAL undo_file_name = STRING) + | COMMA? NO_TRUNCATE + | COMMA? ENCRYPTION LR_BRACKET ALGORITHM EQUAL ( + AES_128 + | AES_192 + | AES_256 + | TRIPLE_DES_3KEY + ) COMMA SERVER CERTIFICATE EQUAL ( + encryptor_name = id_ + | SERVER ASYMMETRIC KEY EQUAL encryptor_name = id_ + ) + )* + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-certificate-transact-sql backup_certificate - : BACKUP CERTIFICATE certname=id_ TO FILE EQUAL cert_file=STRING - ( WITH PRIVATE KEY - LR_BRACKET - (COMMA? FILE EQUAL private_key_file=STRING - |COMMA? ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING - |COMMA? DECRYPTION BY PASSWORD EQUAL decryption_pasword=STRING - )+ - RR_BRACKET - )? + : BACKUP CERTIFICATE certname = id_ TO FILE EQUAL cert_file = STRING ( + WITH PRIVATE KEY LR_BRACKET ( + COMMA? FILE EQUAL private_key_file = STRING + | COMMA? ENCRYPTION BY PASSWORD EQUAL encryption_password = STRING + | COMMA? DECRYPTION BY PASSWORD EQUAL decryption_pasword = STRING + )+ RR_BRACKET + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-master-key-transact-sql backup_master_key - : BACKUP MASTER KEY TO FILE EQUAL master_key_backup_file=STRING - ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING + : BACKUP MASTER KEY TO FILE EQUAL master_key_backup_file = STRING ENCRYPTION BY PASSWORD EQUAL encryption_password = STRING ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-service-master-key-transact-sql backup_service_master_key - : BACKUP SERVICE MASTER KEY TO FILE EQUAL service_master_key_backup_file=STRING - ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING + : BACKUP SERVICE MASTER KEY TO FILE EQUAL service_master_key_backup_file = STRING ENCRYPTION BY PASSWORD EQUAL encryption_password = STRING ; kill_statement @@ -2923,17 +3124,17 @@ kill_statement // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/kill-transact-sql kill_process - : (session_id=(DECIMAL|STRING) | UOW) (WITH STATUSONLY)? + : (session_id = (DECIMAL | STRING) | UOW) (WITH STATUSONLY)? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/kill-query-notification-subscription-transact-sql kill_query_notification - : QUERY NOTIFICATION SUBSCRIPTION (ALL | subscription_id=DECIMAL) + : QUERY NOTIFICATION SUBSCRIPTION (ALL | subscription_id = DECIMAL) ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/kill-stats-job-transact-sql kill_stats_job - : STATS JOB job_id=DECIMAL + : STATS JOB job_id = DECIMAL ; // https://msdn.microsoft.com/en-us/library/ms188332.aspx @@ -2947,27 +3148,24 @@ execute_body_batch //https://docs.microsoft.com/it-it/sql/t-sql/language-elements/execute-transact-sql?view=sql-server-ver15 execute_body - : (return_status=LOCAL_ID '=')? (func_proc_name_server_database_schema | execute_var_string) execute_statement_arg? - | '(' execute_var_string (',' execute_var_string)* ')' (AS (LOGIN | USER) '=' STRING)? (AT_KEYWORD linkedServer=id_)? - | AS ( - (LOGIN | USER) '=' STRING - | CALLER - ) + : (return_status = LOCAL_ID '=')? (func_proc_name_server_database_schema | execute_var_string) execute_statement_arg? + | '(' execute_var_string (',' execute_var_string)* ')' (AS (LOGIN | USER) '=' STRING)? ( + AT_KEYWORD linkedServer = id_ + )? + | AS ( (LOGIN | USER) '=' STRING | CALLER) ; execute_statement_arg - : - execute_statement_arg_unnamed (',' execute_statement_arg) * //Unnamed params can continue unnamed - | - execute_statement_arg_named (',' execute_statement_arg_named)* //Named can only be continued by unnamed + : execute_statement_arg_unnamed (',' execute_statement_arg)* //Unnamed params can continue unnamed + | execute_statement_arg_named (',' execute_statement_arg_named)* //Named can only be continued by unnamed ; execute_statement_arg_named - : name=LOCAL_ID '=' value=execute_parameter + : name = LOCAL_ID '=' value = execute_parameter ; execute_statement_arg_unnamed - : value=execute_parameter + : value = execute_parameter ; execute_parameter @@ -2981,10 +3179,14 @@ execute_var_string // https://msdn.microsoft.com/en-us/library/ff848791.aspx security_statement - // https://msdn.microsoft.com/en-us/library/ms188354.aspx +// https://msdn.microsoft.com/en-us/library/ms188354.aspx : execute_clause ';'? // https://msdn.microsoft.com/en-us/library/ms187965.aspx - | GRANT (ALL PRIVILEGES? | grant_permission ('(' column_name_list ')')?) (ON (class_type_for_grant '::')? on_id=table_name)? TO to_principal+=principal_id (',' to_principal+=principal_id)* (WITH GRANT OPTION)? (AS as_principal=principal_id)? ';'? + | GRANT (ALL PRIVILEGES? | grant_permission ('(' column_name_list ')')?) ( + ON (class_type_for_grant '::')? on_id = table_name + )? TO to_principal += principal_id (',' to_principal += principal_id)* (WITH GRANT OPTION)? ( + AS as_principal = principal_id + )? ';'? // https://msdn.microsoft.com/en-us/library/ms178632.aspx | REVERT (WITH COOKIE '=' LOCAL_ID)? ';'? | open_key @@ -2999,23 +3201,27 @@ principal_id ; create_certificate - : CREATE CERTIFICATE certificate_name=id_ (AUTHORIZATION user_name=id_)? - (FROM existing_keys | generate_new_keys) - (ACTIVE FOR BEGIN DIALOG '=' on_off)? + : CREATE CERTIFICATE certificate_name = id_ (AUTHORIZATION user_name = id_)? ( + FROM existing_keys + | generate_new_keys + ) (ACTIVE FOR BEGIN DIALOG '=' on_off)? ; existing_keys - : ASSEMBLY assembly_name=id_ - | EXECUTABLE? FILE EQUAL path_to_file=STRING (WITH PRIVATE KEY '(' private_key_options ')')? + : ASSEMBLY assembly_name = id_ + | EXECUTABLE? FILE EQUAL path_to_file = STRING (WITH PRIVATE KEY '(' private_key_options ')')? ; private_key_options - : (FILE | BINARY) '=' path=STRING (',' (DECRYPTION | ENCRYPTION) BY PASSWORD '=' password=STRING)? + : (FILE | BINARY) '=' path = STRING ( + ',' (DECRYPTION | ENCRYPTION) BY PASSWORD '=' password = STRING + )? ; generate_new_keys - : (ENCRYPTION BY PASSWORD '=' password=STRING)? - WITH SUBJECT EQUAL certificate_subject_name=STRING (',' date_options)* + : (ENCRYPTION BY PASSWORD '=' password = STRING)? WITH SUBJECT EQUAL certificate_subject_name = STRING ( + ',' date_options + )* ; date_options @@ -3023,29 +3229,28 @@ date_options ; open_key - : OPEN SYMMETRIC KEY key_name=id_ DECRYPTION BY decryption_mechanism - | OPEN MASTER KEY DECRYPTION BY PASSWORD '=' password=STRING + : OPEN SYMMETRIC KEY key_name = id_ DECRYPTION BY decryption_mechanism + | OPEN MASTER KEY DECRYPTION BY PASSWORD '=' password = STRING ; close_key - : CLOSE SYMMETRIC KEY key_name=id_ + : CLOSE SYMMETRIC KEY key_name = id_ | CLOSE ALL SYMMETRIC KEYS | CLOSE MASTER KEY ; create_key - : CREATE MASTER KEY ENCRYPTION BY PASSWORD '=' password=STRING - | CREATE SYMMETRIC KEY key_name=id_ - (AUTHORIZATION user_name=id_)? - (FROM PROVIDER provider_name=id_)? - WITH ((key_options | ENCRYPTION BY encryption_mechanism)','?)+ + : CREATE MASTER KEY ENCRYPTION BY PASSWORD '=' password = STRING + | CREATE SYMMETRIC KEY key_name = id_ (AUTHORIZATION user_name = id_)? ( + FROM PROVIDER provider_name = id_ + )? WITH ((key_options | ENCRYPTION BY encryption_mechanism) ','?)+ ; key_options - : KEY_SOURCE EQUAL pass_phrase=STRING + : KEY_SOURCE EQUAL pass_phrase = STRING | ALGORITHM EQUAL algorithm - | IDENTITY_VALUE EQUAL identity_phrase=STRING - | PROVIDER_KEY_NAME EQUAL key_name_in_provider=STRING + | IDENTITY_VALUE EQUAL identity_phrase = STRING + | PROVIDER_KEY_NAME EQUAL key_name_in_provider = STRING | CREATION_DISPOSITION EQUAL (CREATE_NEW | OPEN_EXISTING) ; @@ -3063,16 +3268,16 @@ algorithm ; encryption_mechanism - : CERTIFICATE certificate_name=id_ - | ASYMMETRIC KEY asym_key_name=id_ - | SYMMETRIC KEY decrypting_Key_name=id_ + : CERTIFICATE certificate_name = id_ + | ASYMMETRIC KEY asym_key_name = id_ + | SYMMETRIC KEY decrypting_Key_name = id_ | PASSWORD '=' STRING ; decryption_mechanism - : CERTIFICATE certificate_name=id_ (WITH PASSWORD EQUAL STRING)? - | ASYMMETRIC KEY asym_key_name=id_ (WITH PASSWORD EQUAL STRING)? - | SYMMETRIC KEY decrypting_Key_name=id_ + : CERTIFICATE certificate_name = id_ (WITH PASSWORD EQUAL STRING)? + | ASYMMETRIC KEY asym_key_name = id_ (WITH PASSWORD EQUAL STRING)? + | SYMMETRIC KEY decrypting_Key_name = id_ | PASSWORD EQUAL STRING ; @@ -3081,92 +3286,96 @@ decryption_mechanism // FROM sys.fn_builtin_permissions (DEFAULT) // ORDER BY 1 grant_permission - : ADMINISTER ( BULK OPERATIONS | DATABASE BULK OPERATIONS) - | ALTER ( ANY ( APPLICATION ROLE - | ASSEMBLY - | ASYMMETRIC KEY - | AVAILABILITY GROUP - | CERTIFICATE - | COLUMN ( ENCRYPTION KEY | MASTER KEY ) - | CONNECTION - | CONTRACT - | CREDENTIAL - | DATABASE ( AUDIT - | DDL TRIGGER - | EVENT ( NOTIFICATION | SESSION ) - | SCOPED CONFIGURATION - )? - | DATASPACE - | ENDPOINT - | EVENT ( NOTIFICATION | SESSION ) - | EXTERNAL ( DATA SOURCE | FILE FORMAT | LIBRARY) - | FULLTEXT CATALOG - | LINKED SERVER - | LOGIN - | MASK - | MESSAGE TYPE - | REMOTE SERVICE BINDING - | ROLE - | ROUTE - | SCHEMA - | SECURITY POLICY - | SERVER ( AUDIT | ROLE ) - | SERVICE - | SYMMETRIC KEY - | USER - ) - | RESOURCES - | SERVER STATE - | SETTINGS - | TRACE + : ADMINISTER (BULK OPERATIONS | DATABASE BULK OPERATIONS) + | ALTER ( + ANY ( + APPLICATION ROLE + | ASSEMBLY + | ASYMMETRIC KEY + | AVAILABILITY GROUP + | CERTIFICATE + | COLUMN ( ENCRYPTION KEY | MASTER KEY) + | CONNECTION + | CONTRACT + | CREDENTIAL + | DATABASE ( + AUDIT + | DDL TRIGGER + | EVENT ( NOTIFICATION | SESSION) + | SCOPED CONFIGURATION )? + | DATASPACE + | ENDPOINT + | EVENT ( NOTIFICATION | SESSION) + | EXTERNAL ( DATA SOURCE | FILE FORMAT | LIBRARY) + | FULLTEXT CATALOG + | LINKED SERVER + | LOGIN + | MASK + | MESSAGE TYPE + | REMOTE SERVICE BINDING + | ROLE + | ROUTE + | SCHEMA + | SECURITY POLICY + | SERVER ( AUDIT | ROLE) + | SERVICE + | SYMMETRIC KEY + | USER + ) + | RESOURCES + | SERVER STATE + | SETTINGS + | TRACE + )? | AUTHENTICATE SERVER? - | BACKUP ( DATABASE | LOG ) + | BACKUP ( DATABASE | LOG) | CHECKPOINT - | CONNECT ( ANY DATABASE | REPLICATION | SQL )? + | CONNECT ( ANY DATABASE | REPLICATION | SQL)? | CONTROL SERVER? - | CREATE ( AGGREGATE - | ANY DATABASE - | ASSEMBLY - | ASYMMETRIC KEY - | AVAILABILITY GROUP - | CERTIFICATE - | CONTRACT - | DATABASE (DDL EVENT NOTIFICATION)? - | DDL EVENT NOTIFICATION - | DEFAULT - | ENDPOINT - | EXTERNAL LIBRARY - | FULLTEXT CATALOG - | FUNCTION - | MESSAGE TYPE - | PROCEDURE - | QUEUE - | REMOTE SERVICE BINDING - | ROLE - | ROUTE - | RULE - | SCHEMA - | SEQUENCE - | SERVER ROLE - | SERVICE - | SYMMETRIC KEY - | SYNONYM - | TABLE - | TRACE EVENT NOTIFICATION - | TYPE - | VIEW - | XML SCHEMA COLLECTION - ) + | CREATE ( + AGGREGATE + | ANY DATABASE + | ASSEMBLY + | ASYMMETRIC KEY + | AVAILABILITY GROUP + | CERTIFICATE + | CONTRACT + | DATABASE (DDL EVENT NOTIFICATION)? + | DDL EVENT NOTIFICATION + | DEFAULT + | ENDPOINT + | EXTERNAL LIBRARY + | FULLTEXT CATALOG + | FUNCTION + | MESSAGE TYPE + | PROCEDURE + | QUEUE + | REMOTE SERVICE BINDING + | ROLE + | ROUTE + | RULE + | SCHEMA + | SEQUENCE + | SERVER ROLE + | SERVICE + | SYMMETRIC KEY + | SYNONYM + | TABLE + | TRACE EVENT NOTIFICATION + | TYPE + | VIEW + | XML SCHEMA COLLECTION + ) | DELETE - | EXECUTE ( ANY EXTERNAL SCRIPT )? + | EXECUTE ( ANY EXTERNAL SCRIPT)? | EXTERNAL ACCESS ASSEMBLY - | IMPERSONATE ( ANY LOGIN )? + | IMPERSONATE ( ANY LOGIN)? | INSERT | KILL DATABASE CONNECTION | RECEIVE | REFERENCES - | SELECT ( ALL USER SECURABLES )? + | SELECT ( ALL USER SECURABLES)? | SEND | SHOWPLAN | SHUTDOWN @@ -3175,33 +3384,37 @@ grant_permission | UNMASK | UNSAFE ASSEMBLY | UPDATE - | VIEW ( ANY ( DATABASE | DEFINITION | COLUMN ( ENCRYPTION | MASTER ) KEY DEFINITION ) - | CHANGE TRACKING - | DATABASE STATE - | DEFINITION - | SERVER STATE - ) + | VIEW ( + ANY (DATABASE | DEFINITION | COLUMN ( ENCRYPTION | MASTER) KEY DEFINITION) + | CHANGE TRACKING + | DATABASE STATE + | DEFINITION + | SERVER STATE + ) ; // https://msdn.microsoft.com/en-us/library/ms190356.aspx // https://msdn.microsoft.com/en-us/library/ms189484.aspx set_statement - : SET LOCAL_ID ('.' member_name=id_)? '=' expression + : SET LOCAL_ID ('.' member_name = id_)? '=' expression | SET LOCAL_ID assignment_operator expression - | SET LOCAL_ID '=' - CURSOR declare_set_cursor_common (FOR (READ ONLY | UPDATE (OF column_name_list)?))? + | SET LOCAL_ID '=' CURSOR declare_set_cursor_common ( + FOR (READ ONLY | UPDATE (OF column_name_list)?) + )? // https://msdn.microsoft.com/en-us/library/ms189837.aspx | set_special ; // https://msdn.microsoft.com/en-us/library/ms174377.aspx transaction_statement - // https://msdn.microsoft.com/en-us/library/ms188386.aspx +// https://msdn.microsoft.com/en-us/library/ms188386.aspx : BEGIN DISTRIBUTED (TRAN | TRANSACTION) (id_ | LOCAL_ID)? // https://msdn.microsoft.com/en-us/library/ms188929.aspx | BEGIN (TRAN | TRANSACTION) ((id_ | LOCAL_ID) (WITH MARK STRING)?)? // https://msdn.microsoft.com/en-us/library/ms190295.aspx - | COMMIT (TRAN | TRANSACTION) ((id_ | LOCAL_ID) (WITH '(' DELAYED_DURABILITY EQUAL (OFF | ON) ')')?)? + | COMMIT (TRAN | TRANSACTION) ( + (id_ | LOCAL_ID) (WITH '(' DELAYED_DURABILITY EQUAL (OFF | ON) ')')? + )? // https://msdn.microsoft.com/en-us/library/ms178628.aspx | COMMIT WORK? | COMMIT id_ @@ -3216,16 +3429,16 @@ transaction_statement // https://msdn.microsoft.com/en-us/library/ms188037.aspx go_statement - : GO (count=DECIMAL)? + : GO (count = DECIMAL)? ; // https://msdn.microsoft.com/en-us/library/ms188366.aspx use_statement - : USE database=id_ + : USE database = id_ ; setuser_statement - : SETUSER user=STRING? + : SETUSER user = STRING? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reconfigure-transact-sql @@ -3239,7 +3452,7 @@ shutdown_statement ; checkpoint_statement - : CHECKPOINT (checkPointDuration=DECIMAL)? + : CHECKPOINT (checkPointDuration = DECIMAL)? ; dbcc_checkalloc_option @@ -3251,29 +3464,21 @@ dbcc_checkalloc_option // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkalloc-transact-sql?view=sql-server-ver16 dbcc_checkalloc - : name=CHECKALLOC - ( - '(' - ( database=id_ | databaseid=STRING | DECIMAL ) - ( ',' NOINDEX | ',' ( REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD ) )? - ')' - ( - WITH dbcc_option=dbcc_checkalloc_option ( ',' dbcc_option=dbcc_checkalloc_option )* - )? + : name = CHECKALLOC ( + '(' (database = id_ | databaseid = STRING | DECIMAL) ( + ',' NOINDEX + | ',' ( REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD) + )? ')' ( + WITH dbcc_option = dbcc_checkalloc_option (',' dbcc_option = dbcc_checkalloc_option)* )? + )? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkcatalog-transact-sql?view=sql-server-ver16 dbcc_checkcatalog - : name=CHECKCATALOG - ( - '(' - ( database=id_ | databasename=STRING | DECIMAL ) - ')' - )? - ( - WITH dbcc_option=NO_INFOMSGS - )? + : name = CHECKCATALOG ('(' ( database = id_ | databasename = STRING | DECIMAL) ')')? ( + WITH dbcc_option = NO_INFOMSGS + )? ; dbcc_checkconstraints_option @@ -3284,15 +3489,13 @@ dbcc_checkconstraints_option // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkconstraints-transact-sql?view=sql-server-ver16 dbcc_checkconstraints - : name=CHECKCONSTRAINTS - ( - '(' - ( table_or_constraint=id_ | table_or_constraint_name=STRING ) - ')' - )? - ( - WITH dbcc_option=dbcc_checkconstraints_option (',' dbcc_option=dbcc_checkconstraints_option)* - )? + : name = CHECKCONSTRAINTS ( + '(' (table_or_constraint = id_ | table_or_constraint_name = STRING) ')' + )? ( + WITH dbcc_option = dbcc_checkconstraints_option ( + ',' dbcc_option = dbcc_checkconstraints_option + )* + )? ; dbcc_checkdb_table_option @@ -3303,28 +3506,18 @@ dbcc_checkdb_table_option | ESTIMATEONLY | PHYSICAL_ONLY | DATA_PURITY - | MAXDOP '=' max_dregree_of_parallelism=DECIMAL + | MAXDOP '=' max_dregree_of_parallelism = DECIMAL ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkdb-transact-sql?view=sql-server-ver16 dbcc_checkdb - : name=CHECKDB - ( - '(' - ( database=id_ | databasename=STRING | DECIMAL ) - ( - ',' ( - NOINDEX - | REPAIR_ALLOW_DATA_LOSS - | REPAIR_FAST - | REPAIR_REBUILD - ) - )? - ')' - )? - ( - WITH dbcc_option=dbcc_checkdb_table_option (',' dbcc_option=dbcc_checkdb_table_option)* - )? + : name = CHECKDB ( + '(' (database = id_ | databasename = STRING | DECIMAL) ( + ',' (NOINDEX | REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD) + )? ')' + )? ( + WITH dbcc_option = dbcc_checkdb_table_option (',' dbcc_option = dbcc_checkdb_table_option)* + )? ; dbcc_checkfilegroup_option @@ -3333,59 +3526,44 @@ dbcc_checkfilegroup_option | TABLOCK | ESTIMATEONLY | PHYSICAL_ONLY - | MAXDOP '=' max_dregree_of_parallelism=DECIMAL + | MAXDOP '=' max_dregree_of_parallelism = DECIMAL ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkfilegroup-transact-sql?view=sql-server-ver16 // Additional parameters: https://dbtut.com/index.php/2019/01/01/dbcc-checkfilegroup-command-on-sql-server/ dbcc_checkfilegroup - : name=CHECKFILEGROUP - ( - '(' - ( filegroup_id=DECIMAL | filegroup_name=STRING ) - ( - ',' ( - NOINDEX - | REPAIR_ALLOW_DATA_LOSS - | REPAIR_FAST - | REPAIR_REBUILD - ) - )? - ')' - )? - ( - WITH dbcc_option=dbcc_checkfilegroup_option (',' dbcc_option=dbcc_checkfilegroup_option)* - )? + : name = CHECKFILEGROUP ( + '(' (filegroup_id = DECIMAL | filegroup_name = STRING) ( + ',' (NOINDEX | REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD) + )? ')' + )? ( + WITH dbcc_option = dbcc_checkfilegroup_option ( + ',' dbcc_option = dbcc_checkfilegroup_option + )* + )? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checktable-transact-sql?view=sql-server-ver16 dbcc_checktable - : name=CHECKTABLE - '(' - table_or_view_name=STRING - ( ',' ( - NOINDEX - | index_id=expression - | REPAIR_ALLOW_DATA_LOSS - | REPAIR_FAST - | REPAIR_REBUILD - ) - )? - ')' - ( - WITH dbcc_option=dbcc_checkdb_table_option (',' dbcc_option=dbcc_checkdb_table_option)* - )? + : name = CHECKTABLE '(' table_or_view_name = STRING ( + ',' ( + NOINDEX + | index_id = expression + | REPAIR_ALLOW_DATA_LOSS + | REPAIR_FAST + | REPAIR_REBUILD + ) + )? ')' ( + WITH dbcc_option = dbcc_checkdb_table_option (',' dbcc_option = dbcc_checkdb_table_option)* + )? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-cleantable-transact-sql?view=sql-server-ver16 dbcc_cleantable - : name=CLEANTABLE - '(' - ( database=id_ | databasename=STRING | DECIMAL ) - ',' ( table_or_view=id_ | table_or_view_name=STRING ) - ( ',' batch_size=DECIMAL )? - ')' - ( WITH dbcc_option=NO_INFOMSGS )? + : name = CLEANTABLE '(' (database = id_ | databasename = STRING | DECIMAL) ',' ( + table_or_view = id_ + | table_or_view_name = STRING + ) (',' batch_size = DECIMAL)? ')' (WITH dbcc_option = NO_INFOMSGS)? ; dbcc_clonedatabase_option @@ -3398,21 +3576,22 @@ dbcc_clonedatabase_option // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-clonedatabase-transact-sql?view=sql-server-ver16 dbcc_clonedatabase - : name=CLONEDATABASE - '(' - source_database=id_ - ',' target_database=id_ - ')' - ( WITH dbcc_option=dbcc_clonedatabase_option (',' dbcc_option=dbcc_clonedatabase_option)* )? + : name = CLONEDATABASE '(' source_database = id_ ',' target_database = id_ ')' ( + WITH dbcc_option = dbcc_clonedatabase_option (',' dbcc_option = dbcc_clonedatabase_option)* + )? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-pdw-showspaceused-transact-sql?view=aps-pdw-2016-au7 dbcc_pdw_showspaceused - : name=PDW_SHOWSPACEUSED ( '(' tablename=id_ ')' ) ? ( WITH dbcc_option=IGNORE_REPLICATED_TABLE_CACHE )? ; + : name = PDW_SHOWSPACEUSED ('(' tablename = id_ ')')? ( + WITH dbcc_option = IGNORE_REPLICATED_TABLE_CACHE + )? + ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-proccache-transact-sql?view=sql-server-ver16 dbcc_proccache - : name=PROCCACHE ( WITH dbcc_option=NO_INFOMSGS )? ; + : name = PROCCACHE (WITH dbcc_option = NO_INFOMSGS)? + ; dbcc_showcontig_option : ALL_INDEXES @@ -3424,57 +3603,33 @@ dbcc_showcontig_option // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-showcontig-transact-sql?view=sql-server-ver16 dbcc_showcontig - : name=SHOWCONTIG - ( - '(' - table_or_view=expression - ( - ',' index=expression - )? - ')' - )? - ( WITH dbcc_option=dbcc_showcontig_option (',' dbcc_showcontig_option)* )? + : name = SHOWCONTIG ('(' table_or_view = expression ( ',' index = expression)? ')')? ( + WITH dbcc_option = dbcc_showcontig_option (',' dbcc_showcontig_option)* + )? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinklog-azure-sql-data-warehouse?view=aps-pdw-2016-au7 dbcc_shrinklog - : name=SHRINKLOG - ('(' SIZE '=' ( (DECIMAL ( MB | GB | TB ) ) | DEFAULT ) ')')? - ( WITH dbcc_option=NO_INFOMSGS )? + : name = SHRINKLOG ('(' SIZE '=' ( (DECIMAL ( MB | GB | TB)) | DEFAULT) ')')? ( + WITH dbcc_option = NO_INFOMSGS + )? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-dbreindex-transact-sql?view=sql-server-ver16 dbcc_dbreindex - : name=DBREINDEX - '(' - table=id_or_string - ( ',' index_name=id_or_string ( ',' fillfactor=expression)? )? - ')' - ( - WITH dbcc_option=NO_INFOMSGS - )? + : name = DBREINDEX '(' table = id_or_string ( + ',' index_name = id_or_string ( ',' fillfactor = expression)? + )? ')' (WITH dbcc_option = NO_INFOMSGS)? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-dllname-free-transact-sql?view=sql-server-ver16 dbcc_dll_free - : dllname=id_ - '(' name=FREE ')' - ( - WITH dbcc_option=NO_INFOMSGS - )? + : dllname = id_ '(' name = FREE ')' (WITH dbcc_option = NO_INFOMSGS)? ; // https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-dropcleanbuffers-transact-sql?view=sql-server-ver16 dbcc_dropcleanbuffers - : name=DROPCLEANBUFFERS - ( - '(' - COMPUTE | ALL - ')' - )? - ( - WITH dbcc_option=NO_INFOMSGS - )? + : name = DROPCLEANBUFFERS ('(' COMPUTE | ALL ')')? (WITH dbcc_option = NO_INFOMSGS)? ; dbcc_clause @@ -3498,7 +3653,7 @@ dbcc_clause ; execute_clause - : EXECUTE AS clause=(CALLER | SELF | OWNER | STRING) + : EXECUTE AS clause = (CALLER | SELF | OWNER | STRING) ; declare_local @@ -3506,16 +3661,16 @@ declare_local ; table_type_definition - : TABLE '(' column_def_table_constraints (','? table_type_indices)* ')' + : TABLE '(' column_def_table_constraints (','? table_type_indices)* ')' ; table_type_indices - : (((PRIMARY KEY | INDEX id_) (CLUSTERED | NONCLUSTERED)?) | UNIQUE) '(' column_name_list_with_order ')' + : (((PRIMARY KEY | INDEX id_) (CLUSTERED | NONCLUSTERED)?) | UNIQUE) '(' column_name_list_with_order ')' | CHECK '(' search_condition ')' ; xml_type_definition - : XML '(' ( CONTENT | DOCUMENT )? xml_schema_collection ')' + : XML '(' (CONTENT | DOCUMENT)? xml_schema_collection ')' ; xml_schema_collection @@ -3536,38 +3691,36 @@ column_def_table_constraint // There is a documentation error: column definition elements can be given in // any order column_definition - : id_ (data_type | AS expression PERSISTED? ) - column_definition_element* - column_index? + : id_ (data_type | AS expression PERSISTED?) column_definition_element* column_index? ; column_definition_element : FILESTREAM - | COLLATE collation_name=id_ + | COLLATE collation_name = id_ | SPARSE - | MASKED WITH '(' FUNCTION '=' mask_function=STRING ')' - | (CONSTRAINT constraint=id_)? DEFAULT constant_expr=expression - | IDENTITY ('(' seed=DECIMAL ',' increment=DECIMAL ')')? + | MASKED WITH '(' FUNCTION '=' mask_function = STRING ')' + | (CONSTRAINT constraint = id_)? DEFAULT constant_expr = expression + | IDENTITY ('(' seed = DECIMAL ',' increment = DECIMAL ')')? | NOT FOR REPLICATION - | GENERATED ALWAYS AS ( ROW | TRANSACTION_ID | SEQUENCE_NUMBER ) ( START | END ) HIDDEN_KEYWORD? + | GENERATED ALWAYS AS (ROW | TRANSACTION_ID | SEQUENCE_NUMBER) (START | END) HIDDEN_KEYWORD? // NULL / NOT NULL is a constraint | ROWGUIDCOL - | ENCRYPTED WITH - '(' COLUMN_ENCRYPTION_KEY '=' key_name=STRING ',' - ENCRYPTION_TYPE '=' ( DETERMINISTIC | RANDOMIZED ) ',' - ALGORITHM '=' algo=STRING - ')' + | ENCRYPTED WITH '(' COLUMN_ENCRYPTION_KEY '=' key_name = STRING ',' ENCRYPTION_TYPE '=' ( + DETERMINISTIC + | RANDOMIZED + ) ',' ALGORITHM '=' algo = STRING ')' | column_constraint ; column_modifier : id_ (ADD | DROP) ( - ROWGUIDCOL - | PERSISTED - | NOT FOR REPLICATION - | SPARSE - | HIDDEN_KEYWORD - | MASKED (WITH (FUNCTION EQUAL STRING | LR_BRACKET FUNCTION EQUAL STRING RR_BRACKET))?) + ROWGUIDCOL + | PERSISTED + | NOT FOR REPLICATION + | SPARSE + | HIDDEN_KEYWORD + | MASKED (WITH (FUNCTION EQUAL STRING | LR_BRACKET FUNCTION EQUAL STRING RR_BRACKET))? + ) ; materialized_column_definition @@ -3578,90 +3731,55 @@ materialized_column_definition // There is a documentation error: NOT NULL is a constraint // and therefore can be given a name. column_constraint - : (CONSTRAINT constraint=id_)? - ( + : (CONSTRAINT constraint = id_)? ( null_notnull - | ( - (PRIMARY KEY | UNIQUE) - clustered? - primary_key_options - ) - | ( - (FOREIGN KEY)? - foreign_key_options - ) - | check_constraint - ) + | ( (PRIMARY KEY | UNIQUE) clustered? primary_key_options) + | ( (FOREIGN KEY)? foreign_key_options) + | check_constraint + ) ; column_index - : - INDEX index_name=id_ clustered? - create_table_index_options? - on_partition_or_filegroup? - ( FILESTREAM_ON ( filestream_filegroup_or_partition_schema_name=id_ | NULL_DOUBLE_QUOTE ) )? + : INDEX index_name = id_ clustered? create_table_index_options? on_partition_or_filegroup? ( + FILESTREAM_ON (filestream_filegroup_or_partition_schema_name = id_ | NULL_DOUBLE_QUOTE) + )? ; on_partition_or_filegroup - : - ON ( - (partition_scheme_name=id_ '(' partition_column_name=id_ ')') - | filegroup=id_ - | DEFAULT_DOUBLE_QUOTE - ) + : ON ( + (partition_scheme_name = id_ '(' partition_column_name = id_ ')') + | filegroup = id_ + | DEFAULT_DOUBLE_QUOTE + ) ; // https://msdn.microsoft.com/en-us/library/ms188066.aspx table_constraint - : (CONSTRAINT constraint=id_)? - ( - ( - (PRIMARY KEY | UNIQUE) - clustered? - '(' column_name_list_with_order ')' - primary_key_options - ) - | - ( - FOREIGN KEY - '(' fk = column_name_list ')' - foreign_key_options - ) - | - ( - CONNECTION - '(' connection_node ( ',' connection_node )* ')' - ) - | - ( - DEFAULT constant_expr=expression FOR column=id_ (WITH VALUES)? - ) - | check_constraint - ) + : (CONSTRAINT constraint = id_)? ( + ((PRIMARY KEY | UNIQUE) clustered? '(' column_name_list_with_order ')' primary_key_options) + | ( FOREIGN KEY '(' fk = column_name_list ')' foreign_key_options) + | ( CONNECTION '(' connection_node ( ',' connection_node)* ')') + | ( DEFAULT constant_expr = expression FOR column = id_ (WITH VALUES)?) + | check_constraint + ) ; connection_node - : - from_node_table=id_ TO to_node_table=id_ + : from_node_table = id_ TO to_node_table = id_ ; primary_key_options - : - (WITH FILLFACTOR '=' DECIMAL)? - alter_table_index_options? - on_partition_or_filegroup? + : (WITH FILLFACTOR '=' DECIMAL)? alter_table_index_options? on_partition_or_filegroup? ; foreign_key_options - : - REFERENCES table_name '(' pk = column_name_list')' - (on_delete | on_update)* - (NOT FOR REPLICATION)? + : REFERENCES table_name '(' pk = column_name_list ')' (on_delete | on_update)* ( + NOT FOR REPLICATION + )? ; check_constraint - : - CHECK (NOT FOR REPLICATION)? '(' search_condition ')' + : CHECK (NOT FOR REPLICATION)? '(' search_condition ')' ; on_delete @@ -3686,28 +3804,28 @@ alter_table_index_option | ALLOW_PAGE_LOCKS '=' on_off | OPTIMIZE_FOR_SEQUENTIAL_KEY '=' on_off | SORT_IN_TEMPDB '=' on_off - | MAXDOP '=' max_degree_of_parallelism=DECIMAL - | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) - on_partitions? - | XML_COMPRESSION '=' on_off - on_partitions? - | DISTRIBUTION '=' HASH '(' id_ ')' | CLUSTERED INDEX '(' id_ (ASC | DESC)? (',' id_ (ASC | DESC)?)* ')' + | MAXDOP '=' max_degree_of_parallelism = DECIMAL + | DATA_COMPRESSION '=' (NONE | ROW | PAGE | COLUMNSTORE | COLUMNSTORE_ARCHIVE) on_partitions? + | XML_COMPRESSION '=' on_off on_partitions? + | DISTRIBUTION '=' HASH '(' id_ ')' + | CLUSTERED INDEX '(' id_ (ASC | DESC)? (',' id_ (ASC | DESC)?)* ')' | ONLINE '=' (ON ('(' low_priority_lock_wait ')')? | OFF) | RESUMABLE '=' on_off - | MAX_DURATION '=' times=DECIMAL MINUTES? + | MAX_DURATION '=' times = DECIMAL MINUTES? ; // https://msdn.microsoft.com/en-us/library/ms180169.aspx declare_cursor - : DECLARE cursor_name - (CURSOR (declare_set_cursor_common (FOR UPDATE (OF column_name_list)?)?)? - | (SEMI_SENSITIVE | INSENSITIVE)? SCROLL? CURSOR FOR select_statement_standalone (FOR (READ ONLY | UPDATE | (OF column_name_list)))? - ) ';'? + : DECLARE cursor_name ( + CURSOR (declare_set_cursor_common (FOR UPDATE (OF column_name_list)?)?)? + | (SEMI_SENSITIVE | INSENSITIVE)? SCROLL? CURSOR FOR select_statement_standalone ( + FOR (READ ONLY | UPDATE | (OF column_name_list)) + )? + ) ';'? ; declare_set_cursor_common - : declare_set_cursor_common_partial* - FOR select_statement_standalone + : declare_set_cursor_common_partial* FOR select_statement_standalone ; declare_set_cursor_common_partial @@ -3719,8 +3837,9 @@ declare_set_cursor_common_partial ; fetch_cursor - : FETCH ((NEXT | PRIOR | FIRST | LAST | (ABSOLUTE | RELATIVE) expression)? FROM)? - GLOBAL? cursor_name (INTO LOCAL_ID (',' LOCAL_ID)*)? ';'? + : FETCH ((NEXT | PRIOR | FIRST | LAST | (ABSOLUTE | RELATIVE) expression)? FROM)? GLOBAL? cursor_name ( + INTO LOCAL_ID (',' LOCAL_ID)* + )? ';'? ; // https://msdn.microsoft.com/en-us/library/ms190356.aspx @@ -3731,8 +3850,14 @@ set_special | SET ROWCOUNT (LOCAL_ID | DECIMAL) ';'? | SET TEXTSIZE DECIMAL ';'? // https://msdn.microsoft.com/en-us/library/ms173763.aspx - | SET TRANSACTION ISOLATION LEVEL - (READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SNAPSHOT | SERIALIZABLE | DECIMAL) ';'? + | SET TRANSACTION ISOLATION LEVEL ( + READ UNCOMMITTED + | READ COMMITTED + | REPEATABLE READ + | SNAPSHOT + | SERIALIZABLE + | DECIMAL + ) ';'? // https://msdn.microsoft.com/en-us/library/ms188059.aspx | SET IDENTITY_INSERT table_name on_off ';'? | SET special_list (',' special_list)* on_off @@ -3784,37 +3909,42 @@ expression | full_column_name | bracket_expression | unary_operator_expression - | expression op=('*' | '/' | '%') expression - | expression op=('+' | '-' | '&' | '^' | '|' | '||') expression + | expression op = ('*' | '/' | '%') expression + | expression op = ('+' | '-' | '&' | '^' | '|' | '||') expression | expression time_zone | over_clause | DOLLAR_ACTION ; parameter - : PLACEHOLDER; + : PLACEHOLDER + ; time_zone : AT_KEYWORD TIME ZONE expression ; primitive_expression - : DEFAULT | NULL_ | LOCAL_ID | primitive_constant + : DEFAULT + | NULL_ + | LOCAL_ID + | primitive_constant ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql case_expression - : CASE caseExpr=expression switch_section+ (ELSE elseExpr=expression)? END - | CASE switch_search_condition_section+ (ELSE elseExpr=expression)? END + : CASE caseExpr = expression switch_section+ (ELSE elseExpr = expression)? END + | CASE switch_search_condition_section+ (ELSE elseExpr = expression)? END ; unary_operator_expression : '~' expression - | op=('+' | '-') expression + | op = ('+' | '-') expression ; bracket_expression - : '(' expression ')' | '(' subquery ')' + : '(' expression ')' + | '(' subquery ')' ; subquery @@ -3823,23 +3953,23 @@ subquery // https://msdn.microsoft.com/en-us/library/ms175972.aspx with_expression - : WITH ctes+=common_table_expression (',' ctes+=common_table_expression)* + : WITH ctes += common_table_expression (',' ctes += common_table_expression)* ; common_table_expression - : expression_name=id_ ('(' columns=column_name_list ')')? AS '(' cte_query=select_statement ')' + : expression_name = id_ ('(' columns = column_name_list ')')? AS '(' cte_query = select_statement ')' ; update_elem : LOCAL_ID '=' full_column_name ('=' | assignment_operator) expression //Combined variable and column update | (full_column_name | LOCAL_ID) ('=' | assignment_operator) expression - | udt_column_name=id_ '.' method_name=id_ '(' expression_list_ ')' + | udt_column_name = id_ '.' method_name = id_ '(' expression_list_ ')' //| full_column_name '.' WRITE (expression, ) ; update_elem_merge : (full_column_name | LOCAL_ID) ('=' | assignment_operator) expression - | udt_column_name=id_ '.' method_name=id_ '(' expression_list_ ')' + | udt_column_name = id_ '.' method_name = id_ '(' expression_list_ ')' //| full_column_name '.' WRITE (expression, ) ; @@ -3865,25 +3995,31 @@ predicate // Changed union rule to sql_union to avoid union construct with C++ target. Issue reported by person who generates into C++. This individual reports change causes generated code to work query_expression - : query_specification select_order_by_clause? unions+=sql_union* //if using top, order by can be on the "top" side of union :/ + : query_specification select_order_by_clause? unions += sql_union* //if using top, order by can be on the "top" side of union :/ | '(' query_expression ')' (UNION ALL? query_expression)? ; sql_union - : (UNION ALL? | EXCEPT | INTERSECT) (spec=query_specification | ('(' op=query_expression ')')) + : (UNION ALL? | EXCEPT | INTERSECT) ( + spec = query_specification + | ('(' op = query_expression ')') + ) ; // https://msdn.microsoft.com/en-us/library/ms176104.aspx query_specification - : SELECT allOrDistinct=(ALL | DISTINCT)? top=top_clause? - columns=select_list - // https://msdn.microsoft.com/en-us/library/ms188029.aspx - (INTO into=table_name)? - (FROM from=table_sources)? - (WHERE where=search_condition)? - // https://msdn.microsoft.com/en-us/library/ms177673.aspx - (GROUP BY ((groupByAll=ALL? groupBys+=group_by_item (',' groupBys+=group_by_item)*) | GROUPING SETS '(' groupSets+=grouping_sets_item (',' groupSets+=grouping_sets_item)* ')'))? - (HAVING having=search_condition)? + : SELECT allOrDistinct = (ALL | DISTINCT)? top = top_clause? columns = select_list + // https://msdn.microsoft.com/en-us/library/ms188029.aspx + (INTO into = table_name)? (FROM from = table_sources)? (WHERE where = search_condition)? + // https://msdn.microsoft.com/en-us/library/ms177673.aspx + ( + GROUP BY ( + (groupByAll = ALL? groupBys += group_by_item (',' groupBys += group_by_item)*) + | GROUPING SETS '(' groupSets += grouping_sets_item ( + ',' groupSets += grouping_sets_item + )* ')' + ) + )? (HAVING having = search_condition)? ; // https://msdn.microsoft.com/en-us/library/ms189463.aspx @@ -3892,43 +4028,40 @@ top_clause ; top_percent - : percent_constant=(REAL | FLOAT | DECIMAL) PERCENT - | '(' topper_expression=expression ')' PERCENT + : percent_constant = (REAL | FLOAT | DECIMAL) PERCENT + | '(' topper_expression = expression ')' PERCENT ; top_count - : count_constant=DECIMAL - | '(' topcount_expression=expression ')' + : count_constant = DECIMAL + | '(' topcount_expression = expression ')' ; // https://docs.microsoft.com/en-us/sql/t-sql/queries/select-over-clause-transact-sql?view=sql-server-ver16 order_by_clause - : ORDER BY order_bys+=order_by_expression (',' order_bys+=order_by_expression)* + : ORDER BY order_bys += order_by_expression (',' order_bys += order_by_expression)* ; // https://msdn.microsoft.com/en-us/library/ms188385.aspx select_order_by_clause - : order_by_clause - (OFFSET offset_exp=expression offset_rows=(ROW | ROWS) (FETCH fetch_offset=(FIRST | NEXT) fetch_exp=expression fetch_rows=(ROW | ROWS) ONLY)?)? + : order_by_clause ( + OFFSET offset_exp = expression offset_rows = (ROW | ROWS) ( + FETCH fetch_offset = (FIRST | NEXT) fetch_exp = expression fetch_rows = (ROW | ROWS) ONLY + )? + )? ; // https://docs.microsoft.com/en-us/sql/t-sql/queries/select-for-clause-transact-sql for_clause : FOR BROWSE - | FOR XML (RAW ('(' STRING ')')? | AUTO) xml_common_directives* - (COMMA (XMLDATA | XMLSCHEMA ('(' STRING ')')?))? - (COMMA ELEMENTS (XSINIL | ABSENT)?)? - | FOR XML EXPLICIT xml_common_directives* - (COMMA XMLDATA)? - | FOR XML PATH ('(' STRING ')')? xml_common_directives* - (COMMA ELEMENTS (XSINIL | ABSENT)?)? - | FOR JSON (AUTO | PATH) - ( COMMA - ( ROOT ('(' STRING ')') - | INCLUDE_NULL_VALUES - | WITHOUT_ARRAY_WRAPPER - ) - )* + | FOR XML (RAW ('(' STRING ')')? | AUTO) xml_common_directives* ( + COMMA (XMLDATA | XMLSCHEMA ('(' STRING ')')?) + )? (COMMA ELEMENTS (XSINIL | ABSENT)?)? + | FOR XML EXPLICIT xml_common_directives* (COMMA XMLDATA)? + | FOR XML PATH ('(' STRING ')')? xml_common_directives* (COMMA ELEMENTS (XSINIL | ABSENT)?)? + | FOR JSON (AUTO | PATH) ( + COMMA (ROOT ('(' STRING ')') | INCLUDE_NULL_VALUES | WITHOUT_ARRAY_WRAPPER) + )* ; xml_common_directives @@ -3936,12 +4069,12 @@ xml_common_directives ; order_by_expression - : order_by=expression (ascending=ASC | descending=DESC)? + : order_by = expression (ascending = ASC | descending = DESC)? ; // https://docs.microsoft.com/en-us/sql/t-sql/queries/select-group-by-transact-sql?view=sql-server-ver15 grouping_sets_item - : '('? groupSetItems+=group_by_item (',' groupSetItems+=group_by_item)* ')'? + : '('? groupSetItems += group_by_item (',' groupSetItems += group_by_item)* ')'? | '(' ')' ; @@ -3954,12 +4087,12 @@ group_by_item ; option_clause - // https://msdn.microsoft.com/en-us/library/ms181714.aspx +// https://msdn.microsoft.com/en-us/library/ms181714.aspx : OPTION '(' options_ += option (',' options_ += option)* ')' ; option - : FAST number_rows=DECIMAL + : FAST number_rows = DECIMAL | (HASH | ORDER) GROUP | (MERGE | HASH | CONCAT) UNION | (LOOP | MERGE | HASH) JOIN @@ -3968,8 +4101,8 @@ option | IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX | KEEP PLAN | KEEPFIXED PLAN - | MAXDOP number_of_processors=DECIMAL - | MAXRECURSION number_recursion=DECIMAL + | MAXDOP number_of_processors = DECIMAL + | MAXRECURSION number_recursion = DECIMAL | OPTIMIZE FOR '(' optimize_for_arg (',' optimize_for_arg)* ')' | OPTIMIZE FOR UNKNOWN | PARAMETERIZATION (SIMPLE | FORCED) @@ -3984,11 +4117,11 @@ optimize_for_arg // https://msdn.microsoft.com/en-us/library/ms176104.aspx select_list - : selectElement+=select_list_elem (',' selectElement+=select_list_elem)* + : selectElement += select_list_elem (',' selectElement += select_list_elem)* ; udt_method_arguments - : '(' argument+=execute_var_string (',' argument+=execute_var_string)* ')' + : '(' argument += execute_var_string (',' argument += execute_var_string)* ')' ; // https://docs.microsoft.com/ru-ru/sql/t-sql/queries/select-clause-transact-sql @@ -3998,13 +4131,13 @@ asterisk ; udt_elem - : udt_column_name=id_ '.' non_static_attr=id_ udt_method_arguments as_column_alias? - | udt_column_name=id_ DOUBLE_COLON static_attr=id_ udt_method_arguments? as_column_alias? + : udt_column_name = id_ '.' non_static_attr = id_ udt_method_arguments as_column_alias? + | udt_column_name = id_ DOUBLE_COLON static_attr = id_ udt_method_arguments? as_column_alias? ; expression_elem - : leftAlias=column_alias eq='=' leftAssignment=expression - | expressionAs=expression as_column_alias? + : leftAlias = column_alias eq = '=' leftAssignment = expression + | expressionAs = expression as_column_alias? ; select_list_elem @@ -4016,48 +4149,50 @@ select_list_elem table_sources : non_ansi_join - | source+=table_source (',' source+=table_source)* + | source += table_source (',' source += table_source)* ; // https://sqlenlight.com/support/help/sa0006/ non_ansi_join - : source+=table_source (',' source+=table_source)+ + : source += table_source (',' source += table_source)+ ; // https://docs.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql table_source - : table_source_item joins+=join_part* + : table_source_item joins += join_part* ; table_source_item - : full_table_name deprecated_table_hint as_table_alias // this is currently allowed - | full_table_name as_table_alias? (with_table_hints | deprecated_table_hint | sybase_legacy_hints)? - | rowset_function as_table_alias? - | '(' derived_table ')' (as_table_alias column_alias_list?)? - | change_table as_table_alias? - | nodes_method (as_table_alias column_alias_list?)? - | function_call (as_table_alias column_alias_list?)? - | loc_id=LOCAL_ID as_table_alias? - | loc_id_call=LOCAL_ID '.' loc_fcall=function_call (as_table_alias column_alias_list?)? + : full_table_name deprecated_table_hint as_table_alias // this is currently allowed + | full_table_name as_table_alias? ( + with_table_hints + | deprecated_table_hint + | sybase_legacy_hints + )? + | rowset_function as_table_alias? + | '(' derived_table ')' (as_table_alias column_alias_list?)? + | change_table as_table_alias? + | nodes_method (as_table_alias column_alias_list?)? + | function_call (as_table_alias column_alias_list?)? + | loc_id = LOCAL_ID as_table_alias? + | loc_id_call = LOCAL_ID '.' loc_fcall = function_call (as_table_alias column_alias_list?)? | open_xml | open_json - | DOUBLE_COLON oldstyle_fcall=function_call as_table_alias? // Build-in function (old syntax) + | DOUBLE_COLON oldstyle_fcall = function_call as_table_alias? // Build-in function (old syntax) | '(' table_source ')' ; // https://docs.microsoft.com/en-us/sql/t-sql/functions/openxml-transact-sql open_xml - : OPENXML '(' expression ',' expression (',' expression)? ')' - (WITH '(' schema_declaration ')' )? as_table_alias? + : OPENXML '(' expression ',' expression (',' expression)? ')' (WITH '(' schema_declaration ')')? as_table_alias? ; open_json - : OPENJSON '(' expression (',' expression)? ')' - (WITH '(' json_declaration ')' )? as_table_alias? + : OPENJSON '(' expression (',' expression)? ')' (WITH '(' json_declaration ')')? as_table_alias? ; json_declaration - : json_col+=json_column_declaration (',' json_col+=json_column_declaration)* + : json_col += json_column_declaration (',' json_col += json_column_declaration)* ; json_column_declaration @@ -4065,7 +4200,7 @@ json_column_declaration ; schema_declaration - : xml_col+=column_declaration (',' xml_col+=column_declaration)* + : xml_col += column_declaration (',' xml_col += column_declaration)* ; column_declaration @@ -4078,24 +4213,27 @@ change_table ; change_table_changes - : CHANGETABLE '(' CHANGES changetable=table_name ',' changesid=(NULL_ | DECIMAL | LOCAL_ID) ')' + : CHANGETABLE '(' CHANGES changetable = table_name ',' changesid = (NULL_ | DECIMAL | LOCAL_ID) ')' ; + change_table_version - : CHANGETABLE '(' VERSION versiontable=table_name ',' pk_columns=full_column_name_list ',' pk_values=select_list ')' + : CHANGETABLE '(' VERSION versiontable = table_name ',' pk_columns = full_column_name_list ',' pk_values = select_list ')' ; // https://msdn.microsoft.com/en-us/library/ms191472.aspx join_part - // https://msdn.microsoft.com/en-us/library/ms173815(v=sql.120).aspx +// https://msdn.microsoft.com/en-us/library/ms173815(v=sql.120).aspx : join_on | cross_join | apply_ | pivot | unpivot ; + join_on - : (inner=INNER? | join_type=(LEFT | RIGHT | FULL) outer=OUTER?) (join_hint=(LOOP | HASH | MERGE | REMOTE))? - JOIN source=table_source ON cond=search_condition + : (inner = INNER? | join_type = (LEFT | RIGHT | FULL) outer = OUTER?) ( + join_hint = (LOOP | HASH | MERGE | REMOTE) + )? JOIN source = table_source ON cond = search_condition ; cross_join @@ -4103,7 +4241,7 @@ cross_join ; apply_ - : apply_style=(CROSS | OUTER) APPLY source=table_source_item + : apply_style = (CROSS | OUTER) APPLY source = table_source_item ; pivot @@ -4119,24 +4257,24 @@ pivot_clause ; unpivot_clause - : '(' unpivot_exp=expression FOR full_column_name IN '(' full_column_name_list ')' ')' + : '(' unpivot_exp = expression FOR full_column_name IN '(' full_column_name_list ')' ')' ; full_column_name_list - : column+=full_column_name (',' column+=full_column_name)* + : column += full_column_name (',' column += full_column_name)* ; // https://msdn.microsoft.com/en-us/library/ms190312.aspx rowset_function - : ( + : ( OPENROWSET LR_BRACKET provider_name = STRING COMMA connectionString = STRING COMMA sql = STRING RR_BRACKET - ) - | ( OPENROWSET '(' BULK data_file=STRING ',' (bulk_option (',' bulk_option)* | id_)')' ) + ) + | (OPENROWSET '(' BULK data_file = STRING ',' (bulk_option (',' bulk_option)* | id_) ')') ; // runtime check. bulk_option - : id_ '=' bulk_option_value=(DECIMAL | STRING) + : id_ '=' bulk_option_value = (DECIMAL | STRING) ; derived_table @@ -4147,33 +4285,50 @@ derived_table ; function_call - : ranking_windowed_function #RANKING_WINDOWED_FUNC - | aggregate_windowed_function #AGGREGATE_WINDOWED_FUNC - | analytic_windowed_function #ANALYTIC_WINDOWED_FUNC - | built_in_functions #BUILT_IN_FUNC - | scalar_function_name '(' expression_list_? ')' #SCALAR_FUNCTION - | freetext_function #FREE_TEXT - | partition_function #PARTITION_FUNC - | hierarchyid_static_method #HIERARCHYID_METHOD + : ranking_windowed_function # RANKING_WINDOWED_FUNC + | aggregate_windowed_function # AGGREGATE_WINDOWED_FUNC + | analytic_windowed_function # ANALYTIC_WINDOWED_FUNC + | built_in_functions # BUILT_IN_FUNC + | scalar_function_name '(' expression_list_? ')' # SCALAR_FUNCTION + | freetext_function # FREE_TEXT + | partition_function # PARTITION_FUNC + | hierarchyid_static_method # HIERARCHYID_METHOD ; partition_function - : (database=id_ '.')? DOLLAR_PARTITION '.' func_name=id_ '(' expression ')' + : (database = id_ '.')? DOLLAR_PARTITION '.' func_name = id_ '(' expression ')' ; freetext_function - : (CONTAINSTABLE | FREETEXTTABLE) '(' table_name ',' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' ) ',' expression (',' LANGUAGE expression)? (',' expression)? ')' - | (SEMANTICSIMILARITYTABLE | SEMANTICKEYPHRASETABLE) '(' table_name ',' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' ) ',' expression ')' + : (CONTAINSTABLE | FREETEXTTABLE) '(' table_name ',' ( + full_column_name + | '(' full_column_name (',' full_column_name)* ')' + | '*' + ) ',' expression (',' LANGUAGE expression)? (',' expression)? ')' + | (SEMANTICSIMILARITYTABLE | SEMANTICKEYPHRASETABLE) '(' table_name ',' ( + full_column_name + | '(' full_column_name (',' full_column_name)* ')' + | '*' + ) ',' expression ')' | SEMANTICSIMILARITYDETAILSTABLE '(' table_name ',' full_column_name ',' expression ',' full_column_name ',' expression ')' ; freetext_predicate - : CONTAINS '(' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' | PROPERTY '(' full_column_name ',' expression ')') ',' expression ')' - | FREETEXT '(' table_name ',' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' ) ',' expression (',' LANGUAGE expression)? ')' + : CONTAINS '(' ( + full_column_name + | '(' full_column_name (',' full_column_name)* ')' + | '*' + | PROPERTY '(' full_column_name ',' expression ')' + ) ',' expression ')' + | FREETEXT '(' table_name ',' ( + full_column_name + | '(' full_column_name (',' full_column_name)* ')' + | '*' + ) ',' expression (',' LANGUAGE expression)? ')' ; json_key_value - : json_key_name=expression ':' value_expression=expression + : json_key_name = expression ':' value_expression = expression ; json_null_clause @@ -4181,421 +4336,450 @@ json_null_clause ; built_in_functions - // Metadata functions - // https://docs.microsoft.com/en-us/sql/t-sql/functions/app-name-transact-sql?view=sql-server-ver16 - : APP_NAME '(' ')' #APP_NAME +// Metadata functions +// https://docs.microsoft.com/en-us/sql/t-sql/functions/app-name-transact-sql?view=sql-server-ver16 + : APP_NAME '(' ')' # APP_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/applock-mode-transact-sql?view=sql-server-ver16 - | APPLOCK_MODE '(' database_principal=expression ',' resource_name=expression ',' lock_owner=expression ')' #APPLOCK_MODE + | APPLOCK_MODE '(' database_principal = expression ',' resource_name = expression ',' lock_owner = expression ')' # APPLOCK_MODE // https://docs.microsoft.com/en-us/sql/t-sql/functions/applock-test-transact-sql?view=sql-server-ver16 - | APPLOCK_TEST '(' database_principal=expression ',' resource_name=expression ',' lock_mode=expression ',' lock_owner=expression ')' #APPLOCK_TEST + | APPLOCK_TEST '(' database_principal = expression ',' resource_name = expression ',' lock_mode = expression ',' lock_owner = expression ')' # + APPLOCK_TEST // https://docs.microsoft.com/en-us/sql/t-sql/functions/assemblyproperty-transact-sql?view=sql-server-ver16 - | ASSEMBLYPROPERTY '(' assembly_name=expression ',' property_name=expression ')' #ASSEMBLYPROPERTY + | ASSEMBLYPROPERTY '(' assembly_name = expression ',' property_name = expression ')' # ASSEMBLYPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/col-length-transact-sql?view=sql-server-ver16 - | COL_LENGTH '(' table=expression ',' column=expression ')' #COL_LENGTH + | COL_LENGTH '(' table = expression ',' column = expression ')' # COL_LENGTH // https://docs.microsoft.com/en-us/sql/t-sql/functions/col-name-transact-sql?view=sql-server-ver16 - | COL_NAME '(' table_id=expression ',' column_id=expression ')' #COL_NAME + | COL_NAME '(' table_id = expression ',' column_id = expression ')' # COL_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/columnproperty-transact-sql?view=sql-server-ver16 - | COLUMNPROPERTY '(' id=expression ',' column=expression ',' property=expression ')' #COLUMNPROPERTY + | COLUMNPROPERTY '(' id = expression ',' column = expression ',' property = expression ')' # COLUMNPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/databasepropertyex-transact-sql?view=sql-server-ver16 - | DATABASEPROPERTYEX '(' database=expression ',' property=expression ')' #DATABASEPROPERTYEX + | DATABASEPROPERTYEX '(' database = expression ',' property = expression ')' # DATABASEPROPERTYEX // https://docs.microsoft.com/en-us/sql/t-sql/functions/db-id-transact-sql?view=sql-server-ver16 - | DB_ID '(' database_name=expression? ')' #DB_ID + | DB_ID '(' database_name = expression? ')' # DB_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/db-name-transact-sql?view=sql-server-ver16 - | DB_NAME '(' database_id=expression? ')' #DB_NAME + | DB_NAME '(' database_id = expression? ')' # DB_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/file-id-transact-sql?view=sql-server-ver16 - | FILE_ID '(' file_name=expression ')' #FILE_ID + | FILE_ID '(' file_name = expression ')' # FILE_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/file-idex-transact-sql?view=sql-server-ver16 - | FILE_IDEX '(' file_name=expression ')' #FILE_IDEX + | FILE_IDEX '(' file_name = expression ')' # FILE_IDEX // https://docs.microsoft.com/en-us/sql/t-sql/functions/file-name-transact-sql?view=sql-server-ver16 - | FILE_NAME '(' file_id=expression ')' #FILE_NAME + | FILE_NAME '(' file_id = expression ')' # FILE_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/filegroup-id-transact-sql?view=sql-server-ver16 - | FILEGROUP_ID '(' filegroup_name=expression ')' #FILEGROUP_ID + | FILEGROUP_ID '(' filegroup_name = expression ')' # FILEGROUP_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/filegroup-name-transact-sql?view=sql-server-ver16 - | FILEGROUP_NAME '(' filegroup_id=expression ')' #FILEGROUP_NAME + | FILEGROUP_NAME '(' filegroup_id = expression ')' # FILEGROUP_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/filegroupproperty-transact-sql?view=sql-server-ver16 - | FILEGROUPPROPERTY '(' filegroup_name=expression ',' property=expression ')' #FILEGROUPPROPERTY + | FILEGROUPPROPERTY '(' filegroup_name = expression ',' property = expression ')' # FILEGROUPPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/fileproperty-transact-sql?view=sql-server-ver16 - | FILEPROPERTY '(' file_name=expression ',' property=expression ')' #FILEPROPERTY + | FILEPROPERTY '(' file_name = expression ',' property = expression ')' # FILEPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/filepropertyex-transact-sql?view=sql-server-ver16 - | FILEPROPERTYEX '(' name=expression ',' property=expression ')' #FILEPROPERTYEX + | FILEPROPERTYEX '(' name = expression ',' property = expression ')' # FILEPROPERTYEX // https://docs.microsoft.com/en-us/sql/t-sql/functions/fulltextcatalogproperty-transact-sql?view=sql-server-ver16 - | FULLTEXTCATALOGPROPERTY '(' catalog_name=expression ',' property=expression ')' #FULLTEXTCATALOGPROPERTY + | FULLTEXTCATALOGPROPERTY '(' catalog_name = expression ',' property = expression ')' # FULLTEXTCATALOGPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/fulltextserviceproperty-transact-sql?view=sql-server-ver16 - | FULLTEXTSERVICEPROPERTY '(' property=expression ')' #FULLTEXTSERVICEPROPERTY + | FULLTEXTSERVICEPROPERTY '(' property = expression ')' # FULLTEXTSERVICEPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/index-col-transact-sql?view=sql-server-ver16 - | INDEX_COL '(' table_or_view_name=expression ',' index_id=expression ',' key_id=expression ')' #INDEX_COL + | INDEX_COL '(' table_or_view_name = expression ',' index_id = expression ',' key_id = expression ')' # INDEX_COL // https://docs.microsoft.com/en-us/sql/t-sql/functions/indexkey-property-transact-sql?view=sql-server-ver16 - | INDEXKEY_PROPERTY '(' object_id=expression ',' index_id=expression ',' key_id=expression ',' property=expression ')' #INDEXKEY_PROPERTY + | INDEXKEY_PROPERTY '(' object_id = expression ',' index_id = expression ',' key_id = expression ',' property = expression ')' # INDEXKEY_PROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/indexproperty-transact-sql?view=sql-server-ver16 - | INDEXPROPERTY '(' object_id=expression ',' index_or_statistics_name=expression ',' property=expression ')' #INDEXPROPERTY + | INDEXPROPERTY '(' object_id = expression ',' index_or_statistics_name = expression ',' property = expression ')' # INDEXPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/next-value-for-transact-sql?view=sql-server-ver16 - | NEXT VALUE FOR sequence_name=table_name ( OVER '(' order_by_clause ')' )? #NEXT_VALUE_FOR + | NEXT VALUE FOR sequence_name = table_name (OVER '(' order_by_clause ')')? # NEXT_VALUE_FOR // https://docs.microsoft.com/en-us/sql/t-sql/functions/object-definition-transact-sql?view=sql-server-ver16 - | OBJECT_DEFINITION '(' object_id=expression ')' #OBJECT_DEFINITION + | OBJECT_DEFINITION '(' object_id = expression ')' # OBJECT_DEFINITION // https://docs.microsoft.com/en-us/sql/t-sql/functions/object-id-transact-sql?view=sql-server-ver16 - | OBJECT_ID '(' object_name=expression ( ',' object_type=expression )? ')' #OBJECT_ID + | OBJECT_ID '(' object_name = expression (',' object_type = expression)? ')' # OBJECT_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/object-name-transact-sql?view=sql-server-ver16 - | OBJECT_NAME '(' object_id=expression ( ',' database_id=expression )? ')' #OBJECT_NAME + | OBJECT_NAME '(' object_id = expression (',' database_id = expression)? ')' # OBJECT_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/object-schema-name-transact-sql?view=sql-server-ver16 - | OBJECT_SCHEMA_NAME '(' object_id=expression ( ',' database_id=expression )? ')' #OBJECT_SCHEMA_NAME + | OBJECT_SCHEMA_NAME '(' object_id = expression (',' database_id = expression)? ')' # OBJECT_SCHEMA_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/objectproperty-transact-sql?view=sql-server-ver16 - | OBJECTPROPERTY '(' id=expression ',' property=expression ')' #OBJECTPROPERTY + | OBJECTPROPERTY '(' id = expression ',' property = expression ')' # OBJECTPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/objectpropertyex-transact-sql?view=sql-server-ver16 - | OBJECTPROPERTYEX '(' id=expression ',' property=expression ')' #OBJECTPROPERTYEX + | OBJECTPROPERTYEX '(' id = expression ',' property = expression ')' # OBJECTPROPERTYEX // https://docs.microsoft.com/en-us/sql/t-sql/functions/original-db-name-transact-sql?view=sql-server-ver16 - | ORIGINAL_DB_NAME '(' ')' #ORIGINAL_DB_NAME + | ORIGINAL_DB_NAME '(' ')' # ORIGINAL_DB_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/parsename-transact-sql?view=sql-server-ver16 - | PARSENAME '(' object_name=expression ',' object_piece=expression ')' #PARSENAME + | PARSENAME '(' object_name = expression ',' object_piece = expression ')' # PARSENAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/schema-id-transact-sql?view=sql-server-ver16 - | SCHEMA_ID '(' schema_name=expression? ')' #SCHEMA_ID + | SCHEMA_ID '(' schema_name = expression? ')' # SCHEMA_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/schema-name-transact-sql?view=sql-server-ver16 - | SCHEMA_NAME '(' schema_id=expression? ')' #SCHEMA_NAME + | SCHEMA_NAME '(' schema_id = expression? ')' # SCHEMA_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/scope-identity-transact-sql?view=sql-server-ver16 - | SCOPE_IDENTITY '(' ')' #SCOPE_IDENTITY + | SCOPE_IDENTITY '(' ')' # SCOPE_IDENTITY // https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver16 - | SERVERPROPERTY '(' property=expression ')' #SERVERPROPERTY + | SERVERPROPERTY '(' property = expression ')' # SERVERPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/stats-date-transact-sql?view=sql-server-ver16 - | STATS_DATE '(' object_id=expression ',' stats_id=expression ')' #STATS_DATE + | STATS_DATE '(' object_id = expression ',' stats_id = expression ')' # STATS_DATE // https://docs.microsoft.com/en-us/sql/t-sql/functions/type-id-transact-sql?view=sql-server-ver16 - | TYPE_ID '(' type_name=expression ')' #TYPE_ID + | TYPE_ID '(' type_name = expression ')' # TYPE_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/type-name-transact-sql?view=sql-server-ver16 - | TYPE_NAME '(' type_id=expression ')' #TYPE_NAME + | TYPE_NAME '(' type_id = expression ')' # TYPE_NAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/typeproperty-transact-sql?view=sql-server-ver16 - | TYPEPROPERTY '(' type=expression ',' property=expression ')' #TYPEPROPERTY + | TYPEPROPERTY '(' type = expression ',' property = expression ')' # TYPEPROPERTY // String functions // https://docs.microsoft.com/en-us/sql/t-sql/functions/ascii-transact-sql?view=sql-server-ver16 - | ASCII '(' character_expression=expression ')' #ASCII + | ASCII '(' character_expression = expression ')' # ASCII // https://docs.microsoft.com/en-us/sql/t-sql/functions/char-transact-sql?view=sql-server-ver16 - | CHAR '(' integer_expression=expression ')' #CHAR + | CHAR '(' integer_expression = expression ')' # CHAR // https://docs.microsoft.com/en-us/sql/t-sql/functions/charindex-transact-sql?view=sql-server-ver16 - | CHARINDEX '(' expressionToFind=expression ',' expressionToSearch=expression ( ',' start_location=expression )? ')' #CHARINDEX + | CHARINDEX '(' expressionToFind = expression ',' expressionToSearch = expression ( + ',' start_location = expression + )? ')' # CHARINDEX // https://docs.microsoft.com/en-us/sql/t-sql/functions/concat-transact-sql?view=sql-server-ver16 - | CONCAT '(' string_value_1=expression ',' string_value_2=expression ( ',' string_value_n+=expression )* ')' #CONCAT + | CONCAT '(' string_value_1 = expression ',' string_value_2 = expression ( + ',' string_value_n += expression + )* ')' # CONCAT // https://docs.microsoft.com/en-us/sql/t-sql/functions/concat-ws-transact-sql?view=sql-server-ver16 - | CONCAT_WS '(' separator=expression ',' argument_1=expression ',' argument_2=expression ( ',' argument_n+=expression )* ')' #CONCAT_WS + | CONCAT_WS '(' separator = expression ',' argument_1 = expression ',' argument_2 = expression ( + ',' argument_n += expression + )* ')' # CONCAT_WS // https://docs.microsoft.com/en-us/sql/t-sql/functions/difference-transact-sql?view=sql-server-ver16 - | DIFFERENCE '(' character_expression_1=expression ',' character_expression_2=expression ')' #DIFFERENCE + | DIFFERENCE '(' character_expression_1 = expression ',' character_expression_2 = expression ')' # DIFFERENCE // https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-ver16 - | FORMAT '(' value=expression ',' format=expression ( ',' culture=expression )? ')' #FORMAT + | FORMAT '(' value = expression ',' format = expression (',' culture = expression)? ')' # FORMAT // https://docs.microsoft.com/en-us/sql/t-sql/functions/left-transact-sql?view=sql-server-ver16 - | LEFT '(' character_expression=expression ',' integer_expression=expression ')' #LEFT + | LEFT '(' character_expression = expression ',' integer_expression = expression ')' # LEFT // https://docs.microsoft.com/en-us/sql/t-sql/functions/len-transact-sql?view=sql-server-ver16 - | LEN '(' string_expression=expression ')' #LEN + | LEN '(' string_expression = expression ')' # LEN // https://docs.microsoft.com/en-us/sql/t-sql/functions/lower-transact-sql?view=sql-server-ver16 - | LOWER '(' character_expression=expression ')' #LOWER + | LOWER '(' character_expression = expression ')' # LOWER // https://docs.microsoft.com/en-us/sql/t-sql/functions/ltrim-transact-sql?view=sql-server-ver16 - | LTRIM '(' character_expression=expression ')' #LTRIM + | LTRIM '(' character_expression = expression ')' # LTRIM // https://docs.microsoft.com/en-us/sql/t-sql/functions/nchar-transact-sql?view=sql-server-ver16 - | NCHAR '(' integer_expression=expression ')' #NCHAR + | NCHAR '(' integer_expression = expression ')' # NCHAR // https://docs.microsoft.com/en-us/sql/t-sql/functions/patindex-transact-sql?view=sql-server-ver16 - | PATINDEX '(' pattern=expression ',' string_expression=expression ')' #PATINDEX + | PATINDEX '(' pattern = expression ',' string_expression = expression ')' # PATINDEX // https://docs.microsoft.com/en-us/sql/t-sql/functions/quotename-transact-sql?view=sql-server-ver16 - | QUOTENAME '(' character_string=expression ( ',' quote_character=expression )? ')' #QUOTENAME + | QUOTENAME '(' character_string = expression (',' quote_character = expression)? ')' # QUOTENAME // https://docs.microsoft.com/en-us/sql/t-sql/functions/replace-transact-sql?view=sql-server-ver16 - | REPLACE '(' input=expression ',' replacing=expression ',' with=expression ')' #REPLACE + | REPLACE '(' input = expression ',' replacing = expression ',' with = expression ')' # REPLACE // https://docs.microsoft.com/en-us/sql/t-sql/functions/replicate-transact-sql?view=sql-server-ver16 - | REPLICATE '(' string_expression=expression ',' integer_expression=expression ')' #REPLICATE + | REPLICATE '(' string_expression = expression ',' integer_expression = expression ')' # REPLICATE // https://docs.microsoft.com/en-us/sql/t-sql/functions/reverse-transact-sql?view=sql-server-ver16 - | REVERSE '(' string_expression=expression ')' #REVERSE + | REVERSE '(' string_expression = expression ')' # REVERSE // https://docs.microsoft.com/en-us/sql/t-sql/functions/right-transact-sql?view=sql-server-ver16 - | RIGHT '(' character_expression=expression ',' integer_expression=expression ')' #RIGHT + | RIGHT '(' character_expression = expression ',' integer_expression = expression ')' # RIGHT // https://docs.microsoft.com/en-us/sql/t-sql/functions/rtrim-transact-sql?view=sql-server-ver16 - | RTRIM '(' character_expression=expression ')' #RTRIM + | RTRIM '(' character_expression = expression ')' # RTRIM // https://docs.microsoft.com/en-us/sql/t-sql/functions/soundex-transact-sql?view=sql-server-ver16 - | SOUNDEX '(' character_expression=expression ')' #SOUNDEX + | SOUNDEX '(' character_expression = expression ')' # SOUNDEX // https://docs.microsoft.com/en-us/sql/t-sql/functions/space-transact-sql?view=sql-server-ver16 - | SPACE_KEYWORD '(' integer_expression=expression ')' #SPACE + | SPACE_KEYWORD '(' integer_expression = expression ')' # SPACE // https://docs.microsoft.com/en-us/sql/t-sql/functions/str-transact-sql?view=sql-server-ver16 - | STR '(' float_expression=expression ( ',' length_expression=expression ( ',' decimal=expression )? )? ')' #STR + | STR '(' float_expression = expression ( + ',' length_expression = expression ( ',' decimal = expression)? + )? ')' # STR // https://docs.microsoft.com/en-us/sql/t-sql/functions/string-agg-transact-sql?view=sql-server-ver16 - | STRING_AGG '(' expr=expression ',' separator=expression ')' (WITHIN GROUP '(' order_by_clause ')')? #STRINGAGG + | STRING_AGG '(' expr = expression ',' separator = expression ')' ( + WITHIN GROUP '(' order_by_clause ')' + )? # STRINGAGG // https://docs.microsoft.com/en-us/sql/t-sql/functions/string-escape-transact-sql?view=sql-server-ver16 - | STRING_ESCAPE '(' text_=expression ',' type_=expression ')' #STRING_ESCAPE + | STRING_ESCAPE '(' text_ = expression ',' type_ = expression ')' # STRING_ESCAPE // https://msdn.microsoft.com/fr-fr/library/ms188043.aspx - | STUFF '(' str=expression ',' from=expression ',' to=expression ',' str_with=expression ')' #STUFF + | STUFF '(' str = expression ',' from = expression ',' to = expression ',' str_with = expression ')' # STUFF // https://docs.microsoft.com/en-us/sql/t-sql/functions/substring-transact-sql?view=sql-server-ver16 - | SUBSTRING '(' string_expression=expression ',' start_=expression ',' length=expression ')' #SUBSTRING + | SUBSTRING '(' string_expression = expression ',' start_ = expression ',' length = expression ')' # SUBSTRING // https://docs.microsoft.com/en-us/sql/t-sql/functions/translate-transact-sql?view=sql-server-ver16 - | TRANSLATE '(' inputString=expression ',' characters=expression ',' translations=expression ')' #TRANSLATE + | TRANSLATE '(' inputString = expression ',' characters = expression ',' translations = expression ')' # TRANSLATE // https://docs.microsoft.com/en-us/sql/t-sql/functions/trim-transact-sql?view=sql-server-ver16 - | TRIM '(' ( characters=expression FROM )? string_=expression ')' #TRIM + | TRIM '(' (characters = expression FROM)? string_ = expression ')' # TRIM // https://docs.microsoft.com/en-us/sql/t-sql/functions/unicode-transact-sql?view=sql-server-ver16 - | UNICODE '(' ncharacter_expression=expression ')' #UNICODE + | UNICODE '(' ncharacter_expression = expression ')' # UNICODE // https://docs.microsoft.com/en-us/sql/t-sql/functions/upper-transact-sql?view=sql-server-ver16 - | UPPER '(' character_expression=expression ')' #UPPER + | UPPER '(' character_expression = expression ')' # UPPER // System functions // https://msdn.microsoft.com/en-us/library/ms173784.aspx - | BINARY_CHECKSUM '(' ( star='*' | expression (',' expression)* ) ')' #BINARY_CHECKSUM + | BINARY_CHECKSUM '(' (star = '*' | expression (',' expression)*) ')' # BINARY_CHECKSUM // https://msdn.microsoft.com/en-us/library/ms189788.aspx - | CHECKSUM '(' ( star='*' | expression (',' expression)* ) ')' #CHECKSUM + | CHECKSUM '(' (star = '*' | expression (',' expression)*) ')' # CHECKSUM // https://docs.microsoft.com/en-us/sql/t-sql/functions/compress-transact-sql?view=sql-server-ver16 - | COMPRESS '(' expr=expression ')' #COMPRESS + | COMPRESS '(' expr = expression ')' # COMPRESS // https://docs.microsoft.com/en-us/sql/t-sql/functions/connectionproperty-transact-sql?view=sql-server-ver16 - | CONNECTIONPROPERTY '(' property=STRING ')' #CONNECTIONPROPERTY + | CONNECTIONPROPERTY '(' property = STRING ')' # CONNECTIONPROPERTY // https://docs.microsoft.com/en-us/sql/t-sql/functions/context-info-transact-sql?view=sql-server-ver16 - | CONTEXT_INFO '(' ')' #CONTEXT_INFO + | CONTEXT_INFO '(' ')' # CONTEXT_INFO // https://docs.microsoft.com/en-us/sql/t-sql/functions/current-request-id-transact-sql?view=sql-server-ver16 - | CURRENT_REQUEST_ID '(' ')' #CURRENT_REQUEST_ID + | CURRENT_REQUEST_ID '(' ')' # CURRENT_REQUEST_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/current-transaction-id-transact-sql?view=sql-server-ver16 - | CURRENT_TRANSACTION_ID '(' ')' #CURRENT_TRANSACTION_ID + | CURRENT_TRANSACTION_ID '(' ')' # CURRENT_TRANSACTION_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/decompress-transact-sql?view=sql-server-ver16 - | DECOMPRESS '(' expr=expression ')' #DECOMPRESS + | DECOMPRESS '(' expr = expression ')' # DECOMPRESS // https://docs.microsoft.com/en-us/sql/t-sql/functions/error-line-transact-sql?view=sql-server-ver16 - | ERROR_LINE '(' ')' #ERROR_LINE + | ERROR_LINE '(' ')' # ERROR_LINE // https://docs.microsoft.com/en-us/sql/t-sql/functions/error-message-transact-sql?view=sql-server-ver16 - | ERROR_MESSAGE '(' ')' #ERROR_MESSAGE + | ERROR_MESSAGE '(' ')' # ERROR_MESSAGE // https://docs.microsoft.com/en-us/sql/t-sql/functions/error-number-transact-sql?view=sql-server-ver16 - | ERROR_NUMBER '(' ')' #ERROR_NUMBER + | ERROR_NUMBER '(' ')' # ERROR_NUMBER // https://docs.microsoft.com/en-us/sql/t-sql/functions/error-procedure-transact-sql?view=sql-server-ver16 - | ERROR_PROCEDURE '(' ')' #ERROR_PROCEDURE + | ERROR_PROCEDURE '(' ')' # ERROR_PROCEDURE // https://docs.microsoft.com/en-us/sql/t-sql/functions/error-severity-transact-sql?view=sql-server-ver16 - | ERROR_SEVERITY '(' ')' #ERROR_SEVERITY + | ERROR_SEVERITY '(' ')' # ERROR_SEVERITY // https://docs.microsoft.com/en-us/sql/t-sql/functions/error-state-transact-sql?view=sql-server-ver16 - | ERROR_STATE '(' ')' #ERROR_STATE + | ERROR_STATE '(' ')' # ERROR_STATE // https://docs.microsoft.com/en-us/sql/t-sql/functions/formatmessage-transact-sql?view=sql-server-ver16 - | FORMATMESSAGE '(' (msg_number=DECIMAL | msg_string=STRING | msg_variable=LOCAL_ID) ',' expression (',' expression)* ')' #FORMATMESSAGE + | FORMATMESSAGE '(' (msg_number = DECIMAL | msg_string = STRING | msg_variable = LOCAL_ID) ',' expression ( + ',' expression + )* ')' # FORMATMESSAGE // https://docs.microsoft.com/en-us/sql/t-sql/functions/get-filestream-transaction-context-transact-sql?view=sql-server-ver16 - | GET_FILESTREAM_TRANSACTION_CONTEXT '(' ')' #GET_FILESTREAM_TRANSACTION_CONTEXT + | GET_FILESTREAM_TRANSACTION_CONTEXT '(' ')' # GET_FILESTREAM_TRANSACTION_CONTEXT // https://docs.microsoft.com/en-us/sql/t-sql/functions/getansinull-transact-sql?view=sql-server-ver16 - | GETANSINULL '(' (database=STRING)? ')' #GETANSINULL + | GETANSINULL '(' (database = STRING)? ')' # GETANSINULL // https://docs.microsoft.com/en-us/sql/t-sql/functions/host-id-transact-sql?view=sql-server-ver16 - | HOST_ID '(' ')' #HOST_ID + | HOST_ID '(' ')' # HOST_ID // https://docs.microsoft.com/en-us/sql/t-sql/functions/host-name-transact-sql?view=sql-server-ver16 - | HOST_NAME '(' ')' #HOST_NAME + | HOST_NAME '(' ')' # HOST_NAME // https://msdn.microsoft.com/en-us/library/ms184325.aspx - | ISNULL '(' left=expression ',' right=expression ')' #ISNULL + | ISNULL '(' left = expression ',' right = expression ')' # ISNULL // https://docs.microsoft.com/en-us/sql/t-sql/functions/isnumeric-transact-sql?view=sql-server-ver16 - | ISNUMERIC '(' expression ')' #ISNUMERIC + | ISNUMERIC '(' expression ')' # ISNUMERIC // https://docs.microsoft.com/en-us/sql/t-sql/functions/min-active-rowversion-transact-sql?view=sql-server-ver16 - | MIN_ACTIVE_ROWVERSION '(' ')' #MIN_ACTIVE_ROWVERSION + | MIN_ACTIVE_ROWVERSION '(' ')' # MIN_ACTIVE_ROWVERSION // https://docs.microsoft.com/en-us/sql/t-sql/functions/newid-transact-sql?view=sql-server-ver16 - | NEWID '(' ')' #NEWID + | NEWID '(' ')' # NEWID // https://docs.microsoft.com/en-us/sql/t-sql/functions/newsequentialid-transact-sql?view=sql-server-ver16 - | NEWSEQUENTIALID '(' ')' #NEWSEQUENTIALID + | NEWSEQUENTIALID '(' ')' # NEWSEQUENTIALID // https://docs.microsoft.com/en-us/sql/t-sql/functions/rowcount-big-transact-sql?view=sql-server-ver16 - | ROWCOUNT_BIG '(' ')' #ROWCOUNT_BIG + | ROWCOUNT_BIG '(' ')' # ROWCOUNT_BIG // https://docs.microsoft.com/en-us/sql/t-sql/functions/session-context-transact-sql?view=sql-server-ver16 - | SESSION_CONTEXT '(' key=STRING ')' #SESSION_CONTEXT + | SESSION_CONTEXT '(' key = STRING ')' # SESSION_CONTEXT // https://docs.microsoft.com/en-us/sql/t-sql/functions/xact-state-transact-sql?view=sql-server-ver16 - | XACT_STATE '(' ')' #XACT_STATE + | XACT_STATE '(' ')' # XACT_STATE // https://msdn.microsoft.com/en-us/library/hh231076.aspx // https://msdn.microsoft.com/en-us/library/ms187928.aspx - | CAST '(' expression AS data_type ')' #CAST - | TRY_CAST '(' expression AS data_type ')' #TRY_CAST - | CONVERT '(' convert_data_type=data_type ','convert_expression=expression (',' style=expression)? ')' #CONVERT + | CAST '(' expression AS data_type ')' # CAST + | TRY_CAST '(' expression AS data_type ')' # TRY_CAST + | CONVERT '(' convert_data_type = data_type ',' convert_expression = expression ( + ',' style = expression + )? ')' # CONVERT // https://msdn.microsoft.com/en-us/library/ms190349.aspx - | COALESCE '(' expression_list_ ')' #COALESCE + | COALESCE '(' expression_list_ ')' # COALESCE // Cursor functions // https://learn.microsoft.com/en-us/sql/t-sql/functions/cursor-rows-transact-sql?view=sql-server-ver16 - | CURSOR_ROWS #CURSOR_ROWS + | CURSOR_ROWS # CURSOR_ROWS // https://learn.microsoft.com/en-us/sql/t-sql/functions/cursor-rows-transact-sql?view=sql-server-ver16 - | FETCH_STATUS #FETCH_STATUS + | FETCH_STATUS # FETCH_STATUS // https://learn.microsoft.com/en-us/sql/t-sql/functions/cursor-status-transact-sql?view=sql-server-ver16 - | CURSOR_STATUS '(' scope=STRING ',' cursor=expression ')' #CURSOR_STATUS + | CURSOR_STATUS '(' scope = STRING ',' cursor = expression ')' # CURSOR_STATUS // Cryptographic functions // https://learn.microsoft.com/en-us/sql/t-sql/functions/cert-id-transact-sql?view=sql-server-ver16 - | CERT_ID '(' cert_name=expression ')' #CERT_ID + | CERT_ID '(' cert_name = expression ')' # CERT_ID // Data type functions // https://learn.microsoft.com/en-us/sql/t-sql/functions/datalength-transact-sql?view=sql-server-ver16 - | DATALENGTH '(' expression ')' #DATALENGTH + | DATALENGTH '(' expression ')' # DATALENGTH // https://learn.microsoft.com/en-us/sql/t-sql/functions/ident-current-transact-sql?view=sql-server-ver16 - | IDENT_CURRENT '(' table_or_view=expression ')' # IDENT_CURRENT + | IDENT_CURRENT '(' table_or_view = expression ')' # IDENT_CURRENT // https://learn.microsoft.com/en-us/sql/t-sql/functions/ident-incr-transact-sql?view=sql-server-ver16 - | IDENT_INCR '(' table_or_view=expression ')' # IDENT_INCR + | IDENT_INCR '(' table_or_view = expression ')' # IDENT_INCR // https://learn.microsoft.com/en-us/sql/t-sql/functions/ident-seed-transact-sql?view=sql-server-ver16 - | IDENT_SEED '(' table_or_view=expression ')' # IDENT_SEED + | IDENT_SEED '(' table_or_view = expression ')' # IDENT_SEED // https://learn.microsoft.com/en-us/sql/t-sql/functions/ident-seed-transact-sql?view=sql-server-ver16 - | IDENTITY '(' datatype=data_type (',' seed=DECIMAL ',' increment=DECIMAL)? ')' #IDENTITY + | IDENTITY '(' datatype = data_type (',' seed = DECIMAL ',' increment = DECIMAL)? ')' # IDENTITY // https://learn.microsoft.com/en-us/sql/t-sql/functions/ident-seed-transact-sql?view=sql-server-ver16 - | SQL_VARIANT_PROPERTY '(' expr=expression ',' property=STRING ')' #SQL_VARIANT_PROPERTY + | SQL_VARIANT_PROPERTY '(' expr = expression ',' property = STRING ')' # SQL_VARIANT_PROPERTY // Date functions //https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36271.1572/html/blocks/CJADIDHD.htm - | CURRENT_DATE '(' ')' #CURRENT_DATE + | CURRENT_DATE '(' ')' # CURRENT_DATE // https://msdn.microsoft.com/en-us/library/ms188751.aspx - | CURRENT_TIMESTAMP #CURRENT_TIMESTAMP + | CURRENT_TIMESTAMP # CURRENT_TIMESTAMP // https://learn.microsoft.com/en-us/sql/t-sql/functions/current-timezone-transact-sql?view=sql-server-ver16 - | CURRENT_TIMEZONE '(' ')' #CURRENT_TIMEZONE + | CURRENT_TIMEZONE '(' ')' # CURRENT_TIMEZONE // https://learn.microsoft.com/en-us/sql/t-sql/functions/current-timezone-id-transact-sql?view=sql-server-ver16 - | CURRENT_TIMEZONE_ID '(' ')' #CURRENT_TIMEZONE_ID + | CURRENT_TIMEZONE_ID '(' ')' # CURRENT_TIMEZONE_ID // https://learn.microsoft.com/en-us/sql/t-sql/functions/date-bucket-transact-sql?view=sql-server-ver16 - | DATE_BUCKET '(' datepart=dateparts_9 ',' number=expression ',' date=expression (',' origin=expression)? ')' #DATE_BUCKET + | DATE_BUCKET '(' datepart = dateparts_9 ',' number = expression ',' date = expression ( + ',' origin = expression + )? ')' # DATE_BUCKET // https://msdn.microsoft.com/en-us/library/ms186819.aspx - | DATEADD '(' datepart=dateparts_12 ',' number=expression ',' date=expression ')' #DATEADD + | DATEADD '(' datepart = dateparts_12 ',' number = expression ',' date = expression ')' # DATEADD // https://msdn.microsoft.com/en-us/library/ms189794.aspx - | DATEDIFF '(' datepart=dateparts_12 ',' date_first=expression ',' date_second=expression ')' #DATEDIFF + | DATEDIFF '(' datepart = dateparts_12 ',' date_first = expression ',' date_second = expression ')' # DATEDIFF // https://learn.microsoft.com/en-us/sql/t-sql/functions/datediff-big-transact-sql?view=sql-server-ver16 - | DATEDIFF_BIG '(' datepart=dateparts_12 ',' startdate=expression ',' enddate=expression ')' #DATEDIFF_BIG + | DATEDIFF_BIG '(' datepart = dateparts_12 ',' startdate = expression ',' enddate = expression ')' # DATEDIFF_BIG // https://learn.microsoft.com/en-us/sql/t-sql/functions/datefromparts-transact-sql?view=sql-server-ver16 - | DATEFROMPARTS '(' year=expression ',' month=expression ',' day=expression ')'#DATEFROMPARTS + | DATEFROMPARTS '(' year = expression ',' month = expression ',' day = expression ')' # DATEFROMPARTS // https://msdn.microsoft.com/en-us/library/ms174395.aspx - | DATENAME '(' datepart=dateparts_15 ',' date=expression ')' #DATENAME + | DATENAME '(' datepart = dateparts_15 ',' date = expression ')' # DATENAME // https://msdn.microsoft.com/en-us/library/ms174420.aspx - | DATEPART '(' datepart=dateparts_15 ',' date=expression ')' #DATEPART + | DATEPART '(' datepart = dateparts_15 ',' date = expression ')' # DATEPART // https://learn.microsoft.com/en-us/sql/t-sql/functions/datetime2fromparts-transact-sql?view=sql-server-ver16 - | DATETIME2FROMPARTS '(' year=expression ',' month=expression ',' day=expression ',' hour=expression ',' minute=expression ',' seconds=expression ',' fractions=expression ',' precision=expression ')' #DATETIME2FROMPARTS + | DATETIME2FROMPARTS '(' year = expression ',' month = expression ',' day = expression ',' hour = expression ',' minute = expression ',' seconds = + expression ',' fractions = expression ',' precision = expression ')' # DATETIME2FROMPARTS // https://learn.microsoft.com/en-us/sql/t-sql/functions/datetimefromparts-transact-sql?view=sql-server-ver16 - | DATETIMEFROMPARTS '(' year=expression ',' month=expression ',' day=expression ',' hour=expression ',' minute=expression ',' seconds=expression ',' milliseconds=expression ')' #DATETIMEFROMPARTS + | DATETIMEFROMPARTS '(' year = expression ',' month = expression ',' day = expression ',' hour = expression ',' minute = expression ',' seconds = + expression ',' milliseconds = expression ')' # DATETIMEFROMPARTS // https://learn.microsoft.com/en-us/sql/t-sql/functions/datetimeoffsetfromparts-transact-sql?view=sql-server-ver16 - | DATETIMEOFFSETFROMPARTS '(' year=expression ',' month=expression ',' day=expression ',' hour=expression ',' minute=expression ',' seconds=expression ',' fractions=expression ',' hour_offset=expression ',' minute_offset=expression ',' precision=DECIMAL ')' #DATETIMEOFFSETFROMPARTS + | DATETIMEOFFSETFROMPARTS '(' year = expression ',' month = expression ',' day = expression ',' hour = expression ',' minute = expression ',' + seconds = expression ',' fractions = expression ',' hour_offset = expression ',' minute_offset = expression ',' precision = DECIMAL ')' # + DATETIMEOFFSETFROMPARTS // https://learn.microsoft.com/en-us/sql/t-sql/functions/datetrunc-transact-sql?view=sql-server-ver16 - | DATETRUNC '(' datepart=dateparts_datetrunc ',' date=expression ')' #DATETRUNC + | DATETRUNC '(' datepart = dateparts_datetrunc ',' date = expression ')' # DATETRUNC // https://learn.microsoft.com/en-us/sql/t-sql/functions/day-transact-sql?view=sql-server-ver16 - | DAY '(' date=expression ')' #DAY + | DAY '(' date = expression ')' # DAY // https://learn.microsoft.com/en-us/sql/t-sql/functions/eomonth-transact-sql?view=sql-server-ver16 - | EOMONTH '(' start_date=expression (',' month_to_add=expression)? ')'#EOMONTH + | EOMONTH '(' start_date = expression (',' month_to_add = expression)? ')' # EOMONTH // https://docs.microsoft.com/en-us/sql/t-sql/functions/getdate-transact-sql - | GETDATE '(' ')' #GETDATE + | GETDATE '(' ')' # GETDATE // https://docs.microsoft.com/en-us/sql/t-sql/functions/getdate-transact-sql - | GETUTCDATE '(' ')' #GETUTCDATE + | GETUTCDATE '(' ')' # GETUTCDATE // https://learn.microsoft.com/en-us/sql/t-sql/functions/isdate-transact-sql?view=sql-server-ver16 - | ISDATE '(' expression ')' #ISDATE + | ISDATE '(' expression ')' # ISDATE // https://learn.microsoft.com/en-us/sql/t-sql/functions/month-transact-sql?view=sql-server-ver16 - | MONTH '(' date=expression ')' #MONTH + | MONTH '(' date = expression ')' # MONTH // https://learn.microsoft.com/en-us/sql/t-sql/functions/smalldatetimefromparts-transact-sql?view=sql-server-ver16 - | SMALLDATETIMEFROMPARTS '(' year=expression ',' month=expression ',' day=expression ',' hour=expression ',' minute=expression ')' #SMALLDATETIMEFROMPARTS + | SMALLDATETIMEFROMPARTS '(' year = expression ',' month = expression ',' day = expression ',' hour = expression ',' minute = expression ')' # + SMALLDATETIMEFROMPARTS // https://learn.microsoft.com/en-us/sql/t-sql/functions/switchoffset-transact-sql?view=sql-server-ver16 - | SWITCHOFFSET '(' datetimeoffset_expression=expression ',' timezoneoffset_expression=expression ')' #SWITCHOFFSET + | SWITCHOFFSET '(' datetimeoffset_expression = expression ',' timezoneoffset_expression = expression ')' # SWITCHOFFSET // https://learn.microsoft.com/en-us/sql/t-sql/functions/sysdatetime-transact-sql?view=sql-server-ver16 - | SYSDATETIME '(' ')' #SYSDATETIME + | SYSDATETIME '(' ')' # SYSDATETIME // https://learn.microsoft.com/en-us/sql/t-sql/functions/sysdatetimeoffset-transact-sql?view=sql-server-ver16 - | SYSDATETIMEOFFSET '(' ')' #SYSDATETIMEOFFSET + | SYSDATETIMEOFFSET '(' ')' # SYSDATETIMEOFFSET // https://learn.microsoft.com/en-us/sql/t-sql/functions/sysutcdatetime-transact-sql?view=sql-server-ver16 - | SYSUTCDATETIME '(' ')' #SYSUTCDATETIME + | SYSUTCDATETIME '(' ')' # SYSUTCDATETIME //https://learn.microsoft.com/en-us/sql/t-sql/functions/timefromparts-transact-sql?view=sql-server-ver16 - | TIMEFROMPARTS '(' hour=expression ',' minute=expression ',' seconds=expression ',' fractions=expression ',' precision=DECIMAL ')' #TIMEFROMPARTS + | TIMEFROMPARTS '(' hour = expression ',' minute = expression ',' seconds = expression ',' fractions = expression ',' precision = DECIMAL ')' # + TIMEFROMPARTS // https://learn.microsoft.com/en-us/sql/t-sql/functions/todatetimeoffset-transact-sql?view=sql-server-ver16 - | TODATETIMEOFFSET '(' datetime_expression=expression ',' timezoneoffset_expression=expression ')' #TODATETIMEOFFSET + | TODATETIMEOFFSET '(' datetime_expression = expression ',' timezoneoffset_expression = expression ')' # TODATETIMEOFFSET // https://learn.microsoft.com/en-us/sql/t-sql/functions/year-transact-sql?view=sql-server-ver16 - | YEAR '(' date=expression ')' #YEAR + | YEAR '(' date = expression ')' # YEAR // https://msdn.microsoft.com/en-us/library/ms189838.aspx - | IDENTITY '(' data_type (',' seed=DECIMAL)? (',' increment=DECIMAL)? ')' #IDENTITY + | IDENTITY '(' data_type (',' seed = DECIMAL)? (',' increment = DECIMAL)? ')' # IDENTITY // https://msdn.microsoft.com/en-us/library/bb839514.aspx - | MIN_ACTIVE_ROWVERSION '(' ')' #MIN_ACTIVE_ROWVERSION + | MIN_ACTIVE_ROWVERSION '(' ')' # MIN_ACTIVE_ROWVERSION // https://msdn.microsoft.com/en-us/library/ms177562.aspx - | NULLIF '(' left=expression ',' right=expression ')' #NULLIF + | NULLIF '(' left = expression ',' right = expression ')' # NULLIF // https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql // https://docs.microsoft.com/en-us/sql/t-sql/functions/try-parse-transact-sql - | PARSE '(' str=expression AS data_type ( USING culture=expression )? ')' #PARSE + | PARSE '(' str = expression AS data_type (USING culture = expression)? ')' # PARSE // https://docs.microsoft.com/en-us/sql/t-sql/xml/xml-data-type-methods - | xml_data_type_methods #XML_DATA_TYPE_FUNC + | xml_data_type_methods # XML_DATA_TYPE_FUNC // https://docs.microsoft.com/en-us/sql/t-sql/functions/logical-functions-iif-transact-sql - | IIF '(' cond=search_condition ',' left=expression ',' right=expression ')' #IIF + | IIF '(' cond = search_condition ',' left = expression ',' right = expression ')' # IIF // JSON functions // https://learn.microsoft.com/en-us/sql/t-sql/functions/isjson-transact-sql?view=azure-sqldw-latest - | ISJSON '(' json_expr=expression (',' json_type_constraint=expression)? ')' #ISJSON + | ISJSON '(' json_expr = expression (',' json_type_constraint = expression)? ')' # ISJSON // https://learn.microsoft.com/en-us/sql/t-sql/functions/json-object-transact-sql?view=azure-sqldw-latest - | JSON_OBJECT '(' (key_value=json_key_value (',' key_value=json_key_value)*)? json_null_clause? ')' #JSON_OBJECT + | JSON_OBJECT '(' (key_value = json_key_value (',' key_value = json_key_value)*)? json_null_clause? ')' # JSON_OBJECT // https://learn.microsoft.com/en-us/sql/t-sql/functions/json-array-transact-sql?view=azure-sqldw-latest - | JSON_ARRAY '(' expression_list_? json_null_clause? ')' #JSON_ARRAY + | JSON_ARRAY '(' expression_list_? json_null_clause? ')' # JSON_ARRAY // https://learn.microsoft.com/en-us/sql/t-sql/functions/json-value-transact-sql?view=azure-sqldw-latest - | JSON_VALUE '(' expr=expression ',' path=expression ')' #JSON_VALUE + | JSON_VALUE '(' expr = expression ',' path = expression ')' # JSON_VALUE // https://learn.microsoft.com/en-us/sql/t-sql/functions/json-query-transact-sql?view=azure-sqldw-latest - | JSON_QUERY '(' expr=expression (',' path=expression)? ')' #JSON_QUERY + | JSON_QUERY '(' expr = expression (',' path = expression)? ')' # JSON_QUERY // https://learn.microsoft.com/en-us/sql/t-sql/functions/json-modify-transact-sql?view=azure-sqldw-latest - | JSON_MODIFY '(' expr=expression ',' path=expression ',' new_value=expression ')' #JSON_MODIFY + | JSON_MODIFY '(' expr = expression ',' path = expression ',' new_value = expression ')' # JSON_MODIFY // https://learn.microsoft.com/en-us/sql/t-sql/functions/json-path-exists-transact-sql?view=azure-sqldw-latest - | JSON_PATH_EXISTS '(' value_expression=expression ',' sql_json_path=expression ')' #JSON_PATH_EXISTS + | JSON_PATH_EXISTS '(' value_expression = expression ',' sql_json_path = expression ')' # JSON_PATH_EXISTS // Math functions // https://learn.microsoft.com/en-us/sql/t-sql/functions/abs-transact-sql?view=sql-server-ver16 - | ABS '(' numeric_expression=expression ')' #ABS + | ABS '(' numeric_expression = expression ')' # ABS // https://learn.microsoft.com/en-us/sql/t-sql/functions/acos-transact-sql?view=sql-server-ver16 - | ACOS '(' float_expression=expression ')' #ACOS + | ACOS '(' float_expression = expression ')' # ACOS // https://learn.microsoft.com/en-us/sql/t-sql/functions/asin-transact-sql?view=sql-server-ver16 - | ASIN '(' float_expression=expression ')' #ASIN + | ASIN '(' float_expression = expression ')' # ASIN // https://learn.microsoft.com/en-us/sql/t-sql/functions/atan-transact-sql?view=sql-server-ver16 - | ATAN '(' float_expression=expression ')' #ATAN + | ATAN '(' float_expression = expression ')' # ATAN // https://learn.microsoft.com/en-us/sql/t-sql/functions/atn2-transact-sql?view=sql-server-ver16 - | ATN2 '(' float_expression=expression ',' float_expression=expression ')' #ATN2 + | ATN2 '(' float_expression = expression ',' float_expression = expression ')' # ATN2 // https://learn.microsoft.com/en-us/sql/t-sql/functions/ceiling-transact-sql?view=sql-server-ver16 - | CEILING '(' numeric_expression=expression ')' #CEILING + | CEILING '(' numeric_expression = expression ')' # CEILING // https://learn.microsoft.com/en-us/sql/t-sql/functions/cos-transact-sql?view=sql-server-ver16 - | COS '(' float_expression=expression ')' #COS + | COS '(' float_expression = expression ')' # COS // https://learn.microsoft.com/en-us/sql/t-sql/functions/cot-transact-sql?view=sql-server-ver16 - | COT '(' float_expression=expression ')' #COT + | COT '(' float_expression = expression ')' # COT // https://learn.microsoft.com/en-us/sql/t-sql/functions/degrees-transact-sql?view=sql-server-ver16 - | DEGREES '(' numeric_expression=expression ')' #DEGREES + | DEGREES '(' numeric_expression = expression ')' # DEGREES // https://learn.microsoft.com/en-us/sql/t-sql/functions/exp-transact-sql?view=sql-server-ver16 - | EXP '(' float_expression=expression ')' #EXP + | EXP '(' float_expression = expression ')' # EXP // https://learn.microsoft.com/en-us/sql/t-sql/functions/floor-transact-sql?view=sql-server-ver16 - | FLOOR '(' numeric_expression=expression ')' #FLOOR + | FLOOR '(' numeric_expression = expression ')' # FLOOR // https://learn.microsoft.com/en-us/sql/t-sql/functions/log-transact-sql?view=sql-server-ver16 - | LOG '(' float_expression=expression (',' base=expression)? ')' #LOG + | LOG '(' float_expression = expression (',' base = expression)? ')' # LOG // https://learn.microsoft.com/en-us/sql/t-sql/functions/log10-transact-sql?view=sql-server-ver16 - | LOG10 '(' float_expression=expression ')' #LOG10 + | LOG10 '(' float_expression = expression ')' # LOG10 // https://learn.microsoft.com/en-us/sql/t-sql/functions/pi-transact-sql?view=sql-server-ver16 - | PI '(' ')' #PI + | PI '(' ')' # PI // https://learn.microsoft.com/en-us/sql/t-sql/functions/power-transact-sql?view=sql-server-ver16 - | POWER '(' float_expression=expression ',' y=expression ')' #POWER + | POWER '(' float_expression = expression ',' y = expression ')' # POWER // https://learn.microsoft.com/en-us/sql/t-sql/functions/radians-transact-sql?view=sql-server-ver16 - | RADIANS '(' numeric_expression=expression ')' #RADIANS + | RADIANS '(' numeric_expression = expression ')' # RADIANS // https://learn.microsoft.com/en-us/sql/t-sql/functions/rand-transact-sql?view=sql-server-ver16 - | RAND '(' (seed=expression)? ')' #RAND + | RAND '(' (seed = expression)? ')' # RAND // https://learn.microsoft.com/en-us/sql/t-sql/functions/round-transact-sql?view=sql-server-ver16 - | ROUND '(' numeric_expression=expression ',' length=expression (',' function=expression)? ')' #ROUND + | ROUND '(' numeric_expression = expression ',' length = expression (',' function = expression)? ')' # ROUND // https://learn.microsoft.com/en-us/sql/t-sql/functions/sign-transact-sql?view=sql-server-ver16 - | SIGN '(' numeric_expression=expression ')' #MATH_SIGN + | SIGN '(' numeric_expression = expression ')' # MATH_SIGN // https://learn.microsoft.com/en-us/sql/t-sql/functions/sin-transact-sql?view=sql-server-ver16 - | SIN '(' float_expression=expression ')' #SIN + | SIN '(' float_expression = expression ')' # SIN // https://learn.microsoft.com/en-us/sql/t-sql/functions/sqrt-transact-sql?view=sql-server-ver16 - | SQRT '(' float_expression=expression ')' #SQRT + | SQRT '(' float_expression = expression ')' # SQRT // https://learn.microsoft.com/en-us/sql/t-sql/functions/square-transact-sql?view=sql-server-ver16 - | SQUARE '(' float_expression=expression ')' #SQUARE + | SQUARE '(' float_expression = expression ')' # SQUARE // https://learn.microsoft.com/en-us/sql/t-sql/functions/tan-transact-sql?view=sql-server-ver16 - | TAN '(' float_expression=expression ')' #TAN + | TAN '(' float_expression = expression ')' # TAN // Logical functions // https://learn.microsoft.com/en-us/sql/t-sql/functions/logical-functions-greatest-transact-sql?view=azure-sqldw-latest - | GREATEST '(' expression_list_ ')' #GREATEST + | GREATEST '(' expression_list_ ')' # GREATEST // https://learn.microsoft.com/en-us/sql/t-sql/functions/logical-functions-least-transact-sql?view=azure-sqldw-latest - | LEAST '(' expression_list_ ')' #LEAST + | LEAST '(' expression_list_ ')' # LEAST // Security functions // https://learn.microsoft.com/en-us/sql/t-sql/functions/certencoded-transact-sql?view=sql-server-ver16 - | CERTENCODED '(' certid=expression ')' #CERTENCODED + | CERTENCODED '(' certid = expression ')' # CERTENCODED // https://learn.microsoft.com/en-us/sql/t-sql/functions/certprivatekey-transact-sql?view=sql-server-ver16 - | CERTPRIVATEKEY '(' certid=expression ',' encryption_password=expression (',' decryption_pasword=expression)? ')' #CERTPRIVATEKEY + | CERTPRIVATEKEY '(' certid = expression ',' encryption_password = expression ( + ',' decryption_pasword = expression + )? ')' # CERTPRIVATEKEY // https://msdn.microsoft.com/en-us/library/ms176050.aspx - | CURRENT_USER #CURRENT_USER + | CURRENT_USER # CURRENT_USER // https://learn.microsoft.com/en-us/sql/t-sql/functions/database-principal-id-transact-sql?view=sql-server-ver16 - | DATABASE_PRINCIPAL_ID '(' (principal_name=expression)? ')' #DATABASE_PRINCIPAL_ID + | DATABASE_PRINCIPAL_ID '(' (principal_name = expression)? ')' # DATABASE_PRINCIPAL_ID // https://learn.microsoft.com/en-us/sql/t-sql/functions/has-dbaccess-transact-sql?view=sql-server-ver16 - | HAS_DBACCESS '(' database_name=expression ')' #HAS_DBACCESS + | HAS_DBACCESS '(' database_name = expression ')' # HAS_DBACCESS // https://learn.microsoft.com/en-us/sql/t-sql/functions/has-perms-by-name-transact-sql?view=sql-server-ver16 - | HAS_PERMS_BY_NAME '(' securable=expression ',' securable_class=expression ',' permission=expression ( ',' sub_securable=expression (',' sub_securable_class=expression )? )? ')' #HAS_PERMS_BY_NAME + | HAS_PERMS_BY_NAME '(' securable = expression ',' securable_class = expression ',' permission = expression ( + ',' sub_securable = expression (',' sub_securable_class = expression)? + )? ')' # HAS_PERMS_BY_NAME // https://learn.microsoft.com/en-us/sql/t-sql/functions/is-member-transact-sql?view=sql-server-ver16 - | IS_MEMBER '(' group_or_role=expression ')' #IS_MEMBER + | IS_MEMBER '(' group_or_role = expression ')' # IS_MEMBER // https://learn.microsoft.com/en-us/sql/t-sql/functions/is-rolemember-transact-sql?view=sql-server-ver16 - | IS_ROLEMEMBER '(' role=expression ( ',' database_principal=expression )? ')' #IS_ROLEMEMBER + | IS_ROLEMEMBER '(' role = expression (',' database_principal = expression)? ')' # IS_ROLEMEMBER // https://learn.microsoft.com/en-us/sql/t-sql/functions/is-srvrolemember-transact-sql?view=sql-server-ver16 - | IS_SRVROLEMEMBER '(' role=expression ( ',' login=expression )? ')' #IS_SRVROLEMEMBER + | IS_SRVROLEMEMBER '(' role = expression (',' login = expression)? ')' # IS_SRVROLEMEMBER // https://learn.microsoft.com/en-us/sql/t-sql/functions/loginproperty-transact-sql?view=sql-server-ver16 - | LOGINPROPERTY '(' login_name=expression ',' property_name=expression ')' #LOGINPROPERTY + | LOGINPROPERTY '(' login_name = expression ',' property_name = expression ')' # LOGINPROPERTY // https://learn.microsoft.com/en-us/sql/t-sql/functions/original-login-transact-sql?view=sql-server-ver16 - | ORIGINAL_LOGIN '(' ')' #ORIGINAL_LOGIN + | ORIGINAL_LOGIN '(' ')' # ORIGINAL_LOGIN // https://learn.microsoft.com/en-us/sql/t-sql/functions/permissions-transact-sql?view=sql-server-ver16 - | PERMISSIONS '(' ( object_id=expression (',' column=expression)? )? ')' #PERMISSIONS + | PERMISSIONS '(' (object_id = expression (',' column = expression)?)? ')' # PERMISSIONS // https://learn.microsoft.com/en-us/sql/t-sql/functions/pwdencrypt-transact-sql?view=sql-server-ver16 - | PWDENCRYPT '(' password=expression ')' #PWDENCRYPT + | PWDENCRYPT '(' password = expression ')' # PWDENCRYPT // https://learn.microsoft.com/en-us/sql/t-sql/functions/pwdcompare-transact-sql?view=sql-server-ver16 - | PWDCOMPARE '(' clear_text_password=expression ',' password_hash=expression (',' version=expression )?')' #PWDCOMPARE + | PWDCOMPARE '(' clear_text_password = expression ',' password_hash = expression ( + ',' version = expression + )? ')' # PWDCOMPARE // https://msdn.microsoft.com/en-us/library/ms177587.aspx - | SESSION_USER #SESSION_USER + | SESSION_USER # SESSION_USER // https://learn.microsoft.com/en-us/sql/t-sql/functions/sessionproperty-transact-sql?view=sql-server-ver16 - | SESSIONPROPERTY '(' option_name=expression ')' #SESSIONPROPERTY + | SESSIONPROPERTY '(' option_name = expression ')' # SESSIONPROPERTY // https://learn.microsoft.com/en-us/sql/t-sql/functions/suser-id-transact-sql?view=sql-server-ver16 - | SUSER_ID '(' (login=expression)? ')' #SUSER_ID + | SUSER_ID '(' (login = expression)? ')' # SUSER_ID // https://learn.microsoft.com/en-us/sql/t-sql/functions/suser-name-transact-sql?view=sql-server-ver16 - | SUSER_NAME '(' (server_user_sid=expression)? ')' #SUSER_SNAME + | SUSER_NAME '(' (server_user_sid = expression)? ')' # SUSER_SNAME // https://learn.microsoft.com/en-us/sql/t-sql/functions/suser-sid-transact-sql?view=sql-server-ver16 - | SUSER_SID '(' (login=expression (',' param2=expression)?)? ')' #SUSER_SID + | SUSER_SID '(' (login = expression (',' param2 = expression)?)? ')' # SUSER_SID // https://learn.microsoft.com/en-us/sql/t-sql/functions/suser-sname-transact-sql?view=sql-server-ver16 - | SUSER_SNAME '(' (server_user_sid=expression)? ')' #SUSER_SNAME + | SUSER_SNAME '(' (server_user_sid = expression)? ')' # SUSER_SNAME // https://msdn.microsoft.com/en-us/library/ms179930.aspx - | SYSTEM_USER #SYSTEM_USER + | SYSTEM_USER # SYSTEM_USER // https://learn.microsoft.com/en-us/sql/t-sql/functions/user-transact-sql?view=sql-server-ver16 - | USER #USER + | USER # USER // https://learn.microsoft.com/en-us/sql/t-sql/functions/user-id-transact-sql?view=sql-server-ver16 - | USER_ID '(' (user=expression)? ')' #USER_ID + | USER_ID '(' (user = expression)? ')' # USER_ID // https://learn.microsoft.com/en-us/sql/t-sql/functions/user-name-transact-sql?view=sql-server-ver16 - | USER_NAME '(' (id=expression)? ')' #USER_NAME + | USER_NAME '(' (id = expression)? ')' # USER_NAME ; xml_data_type_methods @@ -4607,91 +4791,114 @@ xml_data_type_methods // https://learn.microsoft.com/en-us/sql/t-sql/functions/date-bucket-transact-sql?view=sql-server-ver16 dateparts_9 - : YEAR | YEAR_ABBR - | QUARTER | QUARTER_ABBR - | MONTH | MONTH_ABBR - | DAY | DAY_ABBR - | WEEK | WEEK_ABBR - | HOUR | HOUR_ABBR - | MINUTE | MINUTE_ABBR - | SECOND | SECOND_ABBR - | MILLISECOND | MILLISECOND_ABBR + : YEAR + | YEAR_ABBR + | QUARTER + | QUARTER_ABBR + | MONTH + | MONTH_ABBR + | DAY + | DAY_ABBR + | WEEK + | WEEK_ABBR + | HOUR + | HOUR_ABBR + | MINUTE + | MINUTE_ABBR + | SECOND + | SECOND_ABBR + | MILLISECOND + | MILLISECOND_ABBR ; // https://learn.microsoft.com/en-us/sql/t-sql/functions/dateadd-transact-sql?view=sql-server-ver16 dateparts_12 : dateparts_9 - | DAYOFYEAR | DAYOFYEAR_ABBR - | MICROSECOND | MICROSECOND_ABBR - | NANOSECOND | NANOSECOND_ABBR + | DAYOFYEAR + | DAYOFYEAR_ABBR + | MICROSECOND + | MICROSECOND_ABBR + | NANOSECOND + | NANOSECOND_ABBR ; // https://learn.microsoft.com/en-us/sql/t-sql/functions/datename-transact-sql?view=sql-server-ver16 dateparts_15 : dateparts_12 - | WEEKDAY | WEEKDAY_ABBR - | TZOFFSET | TZOFFSET_ABBR - | ISO_WEEK | ISO_WEEK_ABBR + | WEEKDAY + | WEEKDAY_ABBR + | TZOFFSET + | TZOFFSET_ABBR + | ISO_WEEK + | ISO_WEEK_ABBR ; // https://learn.microsoft.com/en-us/sql/t-sql/functions/datetrunc-transact-sql?view=sql-server-ver16 dateparts_datetrunc : dateparts_9 - | DAYOFYEAR | DAYOFYEAR_ABBR - | MICROSECOND | MICROSECOND_ABBR - | ISO_WEEK | ISO_WEEK_ABBR + | DAYOFYEAR + | DAYOFYEAR_ABBR + | MICROSECOND + | MICROSECOND_ABBR + | ISO_WEEK + | ISO_WEEK_ABBR ; value_method - : (loc_id=LOCAL_ID | value_id=full_column_name | eventdata=EVENTDATA '(' ')' | query=query_method | '(' subquery ')') '.' call=value_call + : ( + loc_id = LOCAL_ID + | value_id = full_column_name + | eventdata = EVENTDATA '(' ')' + | query = query_method + | '(' subquery ')' + ) '.' call = value_call ; value_call - : (VALUE | VALUE_SQUARE_BRACKET) '(' xquery=STRING ',' sqltype=STRING ')' + : (VALUE | VALUE_SQUARE_BRACKET) '(' xquery = STRING ',' sqltype = STRING ')' ; query_method - : (loc_id=LOCAL_ID | value_id=full_column_name | '(' subquery ')' ) '.' call=query_call + : (loc_id = LOCAL_ID | value_id = full_column_name | '(' subquery ')') '.' call = query_call ; query_call - : (QUERY | QUERY_SQUARE_BRACKET) '(' xquery=STRING ')' + : (QUERY | QUERY_SQUARE_BRACKET) '(' xquery = STRING ')' ; exist_method - : (loc_id=LOCAL_ID | value_id=full_column_name | '(' subquery ')') '.' call=exist_call + : (loc_id = LOCAL_ID | value_id = full_column_name | '(' subquery ')') '.' call = exist_call ; exist_call - : (EXIST | EXIST_SQUARE_BRACKET) '(' xquery=STRING ')' + : (EXIST | EXIST_SQUARE_BRACKET) '(' xquery = STRING ')' ; modify_method - : (loc_id=LOCAL_ID | value_id=full_column_name | '(' subquery ')') '.' call=modify_call + : (loc_id = LOCAL_ID | value_id = full_column_name | '(' subquery ')') '.' call = modify_call ; modify_call - : (MODIFY | MODIFY_SQUARE_BRACKET) '(' xml_dml=STRING ')' + : (MODIFY | MODIFY_SQUARE_BRACKET) '(' xml_dml = STRING ')' ; hierarchyid_call - : GETANCESTOR '(' n=expression ')' - | GETDESCENDANT '(' child1=expression ',' child2=expression ')' + : GETANCESTOR '(' n = expression ')' + | GETDESCENDANT '(' child1 = expression ',' child2 = expression ')' | GETLEVEL '(' ')' - | ISDESCENDANTOF '(' parent_=expression ')' - | GETREPARENTEDVALUE '(' oldroot=expression ',' newroot=expression ')' + | ISDESCENDANTOF '(' parent_ = expression ')' + | GETREPARENTEDVALUE '(' oldroot = expression ',' newroot = expression ')' | TOSTRING '(' ')' ; hierarchyid_static_method - : HIERARCHYID DOUBLE_COLON (GETROOT '(' ')' | PARSE '(' input=expression ')') + : HIERARCHYID DOUBLE_COLON (GETROOT '(' ')' | PARSE '(' input = expression ')') ; nodes_method - : (loc_id=LOCAL_ID | value_id=full_column_name | '(' subquery ')') '.' NODES '(' xquery=STRING ')' + : (loc_id = LOCAL_ID | value_id = full_column_name | '(' subquery ')') '.' NODES '(' xquery = STRING ')' ; - switch_section : WHEN expression THEN expression ; @@ -4714,7 +4921,7 @@ table_alias // https://msdn.microsoft.com/en-us/library/ms187373.aspx with_table_hints - : WITH '(' hint+=table_hint (','? hint+=table_hint)* ')' + : WITH '(' hint += table_hint (','? hint += table_hint)* ')' ; deprecated_table_hint @@ -4742,11 +4949,11 @@ sybase_legacy_hint table_hint : NOEXPAND | INDEX ( - '(' index_value (',' index_value)* ')' - | '=' '(' index_value ')' - | '=' index_value // examples in the doc include this syntax - ) - | FORCESEEK ( '(' index_value '(' column_name_list ')' ')' )? + '(' index_value (',' index_value)* ')' + | '=' '(' index_value ')' + | '=' index_value // examples in the doc include this syntax + ) + | FORCESEEK ( '(' index_value '(' column_name_list ')' ')')? | FORCESCAN | HOLDLOCK | NOLOCK @@ -4772,11 +4979,12 @@ table_hint ; index_value - : id_ | DECIMAL + : id_ + | DECIMAL ; column_alias_list - : '(' alias+=column_alias (',' alias+=column_alias)* ')' + : '(' alias += column_alias (',' alias += column_alias)* ')' ; column_alias @@ -4785,11 +4993,11 @@ column_alias ; table_value_constructor - : VALUES '(' exps+=expression_list_ ')' (',' '(' exps+=expression_list_ ')')* + : VALUES '(' exps += expression_list_ ')' (',' '(' exps += expression_list_ ')')* ; expression_list_ - : exp+=expression (',' exp+=expression)* + : exp += expression (',' exp += expression)* ; // https://msdn.microsoft.com/en-us/library/ms189798.aspx @@ -4800,10 +5008,8 @@ ranking_windowed_function // https://msdn.microsoft.com/en-us/library/ms173454.aspx aggregate_windowed_function - : agg_func=(AVG | MAX | MIN | SUM | STDEV | STDEVP | VAR | VARP) - '(' all_distinct_expression ')' over_clause? - | cnt=(COUNT | COUNT_BIG) - '(' ('*' | all_distinct_expression) ')' over_clause? + : agg_func = (AVG | MAX | MIN | SUM | STDEV | STDEVP | VAR | VARP) '(' all_distinct_expression ')' over_clause? + | cnt = (COUNT | COUNT_BIG) '(' ('*' | all_distinct_expression) ')' over_clause? | CHECKSUM_AGG '(' all_distinct_expression ')' | GROUPING '(' expression ')' | GROUPING_ID '(' expression_list_ ')' @@ -4812,9 +5018,11 @@ aggregate_windowed_function // https://docs.microsoft.com/en-us/sql/t-sql/functions/analytic-functions-transact-sql analytic_windowed_function : (FIRST_VALUE | LAST_VALUE) '(' expression ')' over_clause - | (LAG | LEAD) '(' expression (',' expression (',' expression)? )? ')' over_clause + | (LAG | LEAD) '(' expression (',' expression (',' expression)?)? ')' over_clause | (CUME_DIST | PERCENT_RANK) '(' ')' OVER '(' (PARTITION BY expression_list_)? order_by_clause ')' - | (PERCENTILE_CONT | PERCENTILE_DISC) '(' expression ')' WITHIN GROUP '(' order_by_clause ')' OVER '(' (PARTITION BY expression_list_)? ')' + | (PERCENTILE_CONT | PERCENTILE_DISC) '(' expression ')' WITHIN GROUP '(' order_by_clause ')' OVER '(' ( + PARTITION BY expression_list_ + )? ')' ; all_distinct_expression @@ -4852,92 +5060,90 @@ window_frame_following ; create_database_option - : FILESTREAM ( database_filestream_option (',' database_filestream_option)* ) - | DEFAULT_LANGUAGE EQUAL ( id_ | STRING ) - | DEFAULT_FULLTEXT_LANGUAGE EQUAL ( id_ | STRING ) - | NESTED_TRIGGERS EQUAL ( OFF | ON ) - | TRANSFORM_NOISE_WORDS EQUAL ( OFF | ON ) + : FILESTREAM (database_filestream_option (',' database_filestream_option)*) + | DEFAULT_LANGUAGE EQUAL ( id_ | STRING) + | DEFAULT_FULLTEXT_LANGUAGE EQUAL ( id_ | STRING) + | NESTED_TRIGGERS EQUAL ( OFF | ON) + | TRANSFORM_NOISE_WORDS EQUAL ( OFF | ON) | TWO_DIGIT_YEAR_CUTOFF EQUAL DECIMAL - | DB_CHAINING ( OFF | ON ) - | TRUSTWORTHY ( OFF | ON ) + | DB_CHAINING ( OFF | ON) + | TRUSTWORTHY ( OFF | ON) ; database_filestream_option - : LR_BRACKET - ( - ( NON_TRANSACTED_ACCESS EQUAL ( OFF | READ_ONLY | FULL ) ) - | - ( DIRECTORY_NAME EQUAL STRING ) - ) - RR_BRACKET + : LR_BRACKET ( + ( NON_TRANSACTED_ACCESS EQUAL ( OFF | READ_ONLY | FULL)) + | ( DIRECTORY_NAME EQUAL STRING) + ) RR_BRACKET ; database_file_spec - : file_group | file_spec + : file_group + | file_spec ; file_group - : FILEGROUP id_ - ( CONTAINS FILESTREAM )? - ( DEFAULT )? - ( CONTAINS MEMORY_OPTIMIZED_DATA )? - file_spec ( ',' file_spec )* + : FILEGROUP id_ (CONTAINS FILESTREAM)? (DEFAULT)? (CONTAINS MEMORY_OPTIMIZED_DATA)? file_spec ( + ',' file_spec + )* ; + file_spec - : LR_BRACKET - NAME EQUAL ( id_ | STRING ) ','? - FILENAME EQUAL file = STRING ','? - ( SIZE EQUAL file_size ','? )? - ( MAXSIZE EQUAL (file_size | UNLIMITED )','? )? - ( FILEGROWTH EQUAL file_size ','? )? - RR_BRACKET + : LR_BRACKET NAME EQUAL (id_ | STRING) ','? FILENAME EQUAL file = STRING ','? ( + SIZE EQUAL file_size ','? + )? (MAXSIZE EQUAL (file_size | UNLIMITED) ','?)? (FILEGROWTH EQUAL file_size ','?)? RR_BRACKET ; - // Primitive. entity_name - : (server=id_ '.' database=id_ '.' schema=id_ '.' - | database=id_ '.' (schema=id_)? '.' - | schema=id_ '.')? table=id_ + : ( + server = id_ '.' database = id_ '.' schema = id_ '.' + | database = id_ '.' (schema = id_)? '.' + | schema = id_ '.' + )? table = id_ ; - entity_name_for_azure_dw - : schema=id_ - | schema=id_ '.' object_name=id_ + : schema = id_ + | schema = id_ '.' object_name = id_ ; entity_name_for_parallel_dw - : schema_database=id_ - | schema=id_ '.' object_name=id_ + : schema_database = id_ + | schema = id_ '.' object_name = id_ ; full_table_name - : (linkedServer=id_ '.' '.' schema=id_ '.' - | server=id_ '.' database=id_ '.' schema=id_ '.' - | database=id_ '.' schema=id_? '.' - | schema=id_ '.')? table=id_ + : ( + linkedServer = id_ '.' '.' schema = id_ '.' + | server = id_ '.' database = id_ '.' schema = id_ '.' + | database = id_ '.' schema = id_? '.' + | schema = id_ '.' + )? table = id_ ; table_name - : (database=id_ '.' schema=id_? '.' | schema=id_ '.')? (table=id_ | blocking_hierarchy=BLOCKING_HIERARCHY) + : (database = id_ '.' schema = id_? '.' | schema = id_ '.')? ( + table = id_ + | blocking_hierarchy = BLOCKING_HIERARCHY + ) ; simple_name - : (schema=id_ '.')? name=id_ + : (schema = id_ '.')? name = id_ ; func_proc_name_schema - : ((schema=id_) '.')? procedure=id_ + : ((schema = id_) '.')? procedure = id_ ; func_proc_name_database_schema - : database=id_? '.' schema=id_? '.' procedure=id_ + : database = id_? '.' schema = id_? '.' procedure = id_ | func_proc_name_schema ; func_proc_name_server_database_schema - : server=id_? '.' database=id_? '.' schema=id_? '.' procedure=id_ + : server = id_? '.' database = id_? '.' schema = id_? '.' procedure = id_ | func_proc_name_database_schema ; @@ -4947,7 +5153,10 @@ ddl_object ; full_column_name - : ((DELETED | INSERTED | full_table_name) '.')? (column_name=id_ | ('$' (IDENTITY | ROWGUID))) + : ((DELETED | INSERTED | full_table_name) '.')? ( + column_name = id_ + | ('$' (IDENTITY | ROWGUID)) + ) ; column_name_list_with_order @@ -4956,15 +5165,15 @@ column_name_list_with_order //For some reason, sql server allows any number of prefixes: Here, h is the column: a.b.c.d.e.f.g.h insert_column_name_list - : col+=insert_column_id (',' col+=insert_column_id)* + : col += insert_column_id (',' col += insert_column_id)* ; insert_column_id - : (ignore+=id_? '.' )* id_ + : (ignore += id_? '.')* id_ ; column_name_list - : col+=id_ (',' col+=id_)* + : col += id_ (',' col += id_)* ; cursor_name @@ -4999,15 +5208,12 @@ begin_conversation_timer ; begin_conversation_dialog - : BEGIN DIALOG (CONVERSATION)? dialog_handle=LOCAL_ID - FROM SERVICE initiator_service_name=service_name - TO SERVICE target_service_name=service_name (',' service_broker_guid=STRING)? - ON CONTRACT contract_name - (WITH - ((RELATED_CONVERSATION | RELATED_CONVERSATION_GROUP) '=' LOCAL_ID ','?)? - (LIFETIME '=' (DECIMAL | LOCAL_ID) ','?)? - (ENCRYPTION '=' on_off)? )? - ';'? + : BEGIN DIALOG (CONVERSATION)? dialog_handle = LOCAL_ID FROM SERVICE initiator_service_name = service_name TO SERVICE target_service_name = + service_name (',' service_broker_guid = STRING)? ON CONTRACT contract_name ( + WITH ((RELATED_CONVERSATION | RELATED_CONVERSATION_GROUP) '=' LOCAL_ID ','?)? ( + LIFETIME '=' (DECIMAL | LOCAL_ID) ','? + )? (ENCRYPTION '=' on_off)? + )? ';'? ; contract_name @@ -5019,48 +5225,53 @@ service_name ; end_conversation - : END CONVERSATION conversation_handle=LOCAL_ID ';'? - (WITH (ERROR '=' faliure_code=(LOCAL_ID | STRING) DESCRIPTION '=' failure_text=(LOCAL_ID | STRING))? CLEANUP? )? + : END CONVERSATION conversation_handle = LOCAL_ID ';'? ( + WITH ( + ERROR '=' faliure_code = (LOCAL_ID | STRING) DESCRIPTION '=' failure_text = ( + LOCAL_ID + | STRING + ) + )? CLEANUP? + )? ; waitfor_conversation - : WAITFOR? '(' get_conversation ')' (','? TIMEOUT timeout=time)? ';'? + : WAITFOR? '(' get_conversation ')' (','? TIMEOUT timeout = time)? ';'? ; get_conversation - :GET CONVERSATION GROUP conversation_group_id=(STRING | LOCAL_ID) FROM queue=queue_id ';'? + : GET CONVERSATION GROUP conversation_group_id = (STRING | LOCAL_ID) FROM queue = queue_id ';'? ; queue_id - : (database_name=id_ '.' schema_name=id_ '.' name=id_) + : (database_name = id_ '.' schema_name = id_ '.' name = id_) | id_ ; send_conversation - : SEND ON CONVERSATION conversation_handle=(STRING | LOCAL_ID) - MESSAGE TYPE message_type_name=expression - ('(' message_body_expression=(STRING | LOCAL_ID) ')' )? - ';'? + : SEND ON CONVERSATION conversation_handle = (STRING | LOCAL_ID) MESSAGE TYPE message_type_name = expression ( + '(' message_body_expression = (STRING | LOCAL_ID) ')' + )? ';'? ; // https://msdn.microsoft.com/en-us/library/ms187752.aspx // TODO: implement runtime check or add new tokens. data_type - : scaled=(VARCHAR | NVARCHAR | BINARY_KEYWORD | VARBINARY_KEYWORD | SQUARE_BRACKET_ID) '(' MAX ')' - | ext_type=id_ '(' scale=DECIMAL ',' prec=DECIMAL ')' - | ext_type=id_ '(' scale=DECIMAL ')' - | ext_type=id_ IDENTITY ('(' seed=DECIMAL ',' inc=DECIMAL ')')? - | double_prec=DOUBLE PRECISION? - | unscaled_type=id_ + : scaled = (VARCHAR | NVARCHAR | BINARY_KEYWORD | VARBINARY_KEYWORD | SQUARE_BRACKET_ID) '(' MAX ')' + | ext_type = id_ '(' scale = DECIMAL ',' prec = DECIMAL ')' + | ext_type = id_ '(' scale = DECIMAL ')' + | ext_type = id_ IDENTITY ('(' seed = DECIMAL ',' inc = DECIMAL ')')? + | double_prec = DOUBLE PRECISION? + | unscaled_type = id_ ; // https://msdn.microsoft.com/en-us/library/ms179899.aspx constant : STRING // string, datetime or uniqueidentifier | BINARY - | '-'? (DECIMAL | REAL | FLOAT) // float or decimal - | '-'? dollar='$' ('-'|'+')? (DECIMAL | FLOAT) // money + | '-'? (DECIMAL | REAL | FLOAT) // float or decimal + | '-'? dollar = '$' ('-' | '+')? (DECIMAL | FLOAT) // money | parameter ; @@ -5068,8 +5279,8 @@ constant primitive_constant : STRING // string, datetime or uniqueidentifier | BINARY - | (DECIMAL | REAL | FLOAT) // float or decimal - | dollar='$' ('-'|'+')? (DECIMAL | FLOAT) // money + | (DECIMAL | REAL | FLOAT) // float or decimal + | dollar = '$' ('-' | '+')? (DECIMAL | FLOAT) // money | parameter ; @@ -5081,7 +5292,7 @@ keyword | ACTION | ACTIVATION | ACTIVE - | ADD // ? + | ADD // ? | ADDRESS | AES_128 | AES_192 @@ -5715,7 +5926,7 @@ keyword | XMLSCHEMA | XSINIL | ZONE -//More keywords that can also be used as IDs + //More keywords that can also be used as IDs | ABORT_AFTER_WAIT | ABSENT | ADMINISTER @@ -6069,13 +6280,28 @@ id_or_string // https://msdn.microsoft.com/en-us/library/ms188074.aspx // Spaces are allowed for comparison operators. comparison_operator - : '=' | '>' | '<' | '<' '=' | '>' '=' | '<' '>' | '!' '=' | '!' '>' | '!' '<' + : '=' + | '>' + | '<' + | '<' '=' + | '>' '=' + | '<' '>' + | '!' '=' + | '!' '>' + | '!' '<' ; assignment_operator - : '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '^=' | '|=' + : '+=' + | '-=' + | '*=' + | '/=' + | '%=' + | '&=' + | '^=' + | '|=' ; file_size - : DECIMAL( KB | MB | GB | TB | '%' )? - ; + : DECIMAL (KB | MB | GB | TB | '%')? + ; \ No newline at end of file diff --git a/stacktrace/StackTrace.g4 b/stacktrace/StackTrace.g4 index 24af47b62e..1f3f2e8c5d 100644 --- a/stacktrace/StackTrace.g4 +++ b/stacktrace/StackTrace.g4 @@ -1,4 +1,3 @@ - /** A Java stacktrace text grammar for ANTLR v3 * see http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html * @@ -10,157 +9,144 @@ /* Ported to Antlr4 by Tom Everett */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar StackTrace; startRule - : stackTrace EOF - ; + : stackTrace EOF + ; stackTrace - : messageLine + stackTraceLine* causedByLine? - ; + : messageLine+ stackTraceLine* causedByLine? + ; stackTraceLine - : (atLine | ellipsisLine) - ; + : (atLine | ellipsisLine) + ; atLine - : AT qualifiedMethod '(' classFile (COLON Number)? ')' - ; + : AT qualifiedMethod '(' classFile (COLON Number)? ')' + ; causedByLine - : CAUSED_BY stackTrace - ; + : CAUSED_BY stackTrace + ; ellipsisLine - : ELLIPSIS Number MORE_ - ; + : ELLIPSIS Number MORE_ + ; messageLine - : (qualifiedClass message?) - ; + : (qualifiedClass message?) + ; qualifiedClass - : packagePath? className innerClassName* - ; + : packagePath? className innerClassName* + ; innerClassName - : ('$' className) - ; + : ('$' className) + ; classFile - : (identifier '.java' | NATIVE_METHOD | UNKNOWN_SOURCE) - ; + : (identifier '.java' | NATIVE_METHOD | UNKNOWN_SOURCE) + ; qualifiedMethod - : qualifiedClass DOT (methodName | constructor)? - ; + : qualifiedClass DOT (methodName | constructor)? + ; constructor - : INIT - ; + : INIT + ; methodName - : identifier - ; + : identifier + ; packagePath - : (identifier DOT) + - ; + : (identifier DOT)+ + ; className - : JavaWord - ; + : JavaWord + ; identifier - : JavaWord - ; + : JavaWord + ; message - : COLON (: .)*? - ; - - -Number - : Digit + - ; - - -JavaWord - : (JavaCharacter) + - ; - - -fragment JavaCharacter - : (CapitalLetter | NonCapitalLetter | Symbol | Digit) - ; - - -DOT - : '.' - ; - - -AT - : 'at' - ; - - -CAUSED_BY - : 'Caused by:' - ; - - -MORE_ - : 'more' - ; - - -ELLIPSIS - : '...' - ; - + : COLON (: .)*? + ; -COLON - : ':' - ; + Number + : Digit+ + ; + JavaWord + : (JavaCharacter)+ + ; -NATIVE_METHOD - : 'Native Method' - ; + fragment JavaCharacter + : (CapitalLetter | NonCapitalLetter | Symbol | Digit) + ; + DOT + : '.' + ; -UNKNOWN_SOURCE - : 'Unknown Source' - ; + AT + : 'at' + ; + CAUSED_BY + : 'Caused by:' + ; -INIT - : '' - ; + MORE_ + : 'more' + ; + ELLIPSIS + : '...' + ; -NonCapitalLetter - : 'a' .. 'z' - ; + COLON + : ':' + ; + NATIVE_METHOD + : 'Native Method' + ; -CapitalLetter - : 'A' .. 'Z' - ; + UNKNOWN_SOURCE + : 'Unknown Source' + ; + INIT + : '' + ; -Symbol - : '_' - ; + NonCapitalLetter + : 'a' .. 'z' + ; + CapitalLetter + : 'A' .. 'Z' + ; -Digit - : '0' .. '9' - ; + Symbol + : '_' + ; + Digit + : '0' .. '9' + ; -WS - : (' ' | '\r' | '\t' | '\u000C' | '\n') -> skip - ; + WS + : (' ' | '\r' | '\t' | '\u000C' | '\n') -> skip + ; \ No newline at end of file diff --git a/star/star.g4 b/star/star.g4 index a7dcd76919..8b735990a1 100644 --- a/star/star.g4 +++ b/star/star.g4 @@ -29,100 +29,103 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar star; star - : datablock_* EOF - ; + : datablock_* EOF + ; datablock_ - : DATA element_+ - ; + : DATA element_+ + ; element_ - : (keyval_ | saveframe_ | global_ | loop_)+ - ; + : (keyval_ | saveframe_ | global_ | loop_)+ + ; saveframe_ - : save_ (dataname_ | dataitem_ | loop_)+ - ; + : save_ (dataname_ | dataitem_ | loop_)+ + ; loop_ - : LOOP dataname_+ (dataitem_+ STOP?)+ - ; + : LOOP dataname_+ (dataitem_+ STOP?)+ + ; keyval_ - : dataname_ dataitem_ - ; + : dataname_ dataitem_ + ; dataitem_ - : string_ - | literal_ - | loop_ - ; + : string_ + | literal_ + | loop_ + ; string_ - : STRING1 - | STRING2 - ; + : STRING1 + | STRING2 + ; dataname_ - : DATANAME - ; + : DATANAME + ; save_ - : SAVE - ; + : SAVE + ; global_ - : GLOBAL - ; + : GLOBAL + ; literal_ - : LITERAL - ; + : LITERAL + ; STRING1 - : '\'' .*? '\'' - ; + : '\'' .*? '\'' + ; STRING2 - : '"' .*? '"' - ; + : '"' .*? '"' + ; LITERAL - : [a-zA-Z0-9()'.+-/*]+ - ; + : [a-zA-Z0-9()'.+-/*]+ + ; LOOP - : 'loop_' - ; + : 'loop_' + ; STOP - : 'stop_' - ; + : 'stop_' + ; GLOBAL - : 'global_' - ; + : 'global_' + ; SAVE - : 'save_' [a-zA-Z0-9_]+ - ; + : 'save_' [a-zA-Z0-9_]+ + ; DATA - : 'data_' [a-zA-Z0-9_]+ - ; + : 'data_' [a-zA-Z0-9_]+ + ; DATANAME - : '_' [a-zA-Z0-9_]+ - ; + : '_' [a-zA-Z0-9_]+ + ; COMMENT - : '#' ~ [\r\n]* -> skip - ; + : '#' ~ [\r\n]* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/stellaris/stellaris.g4 b/stellaris/stellaris.g4 index ad32287fd5..8b95840ffd 100644 --- a/stellaris/stellaris.g4 +++ b/stellaris/stellaris.g4 @@ -1,75 +1,84 @@ -grammar stellaris; - -content: - expr+ EOF - ; - -expr: - keyval+ - ; - -keyval: - key ('=' | '>' | '<')+ val - ; - -key: - id_ | attrib - ; - -val: - id_ | attrib | group - ; - -attrib: - id_ accessor (attrib| id_) - ; - -accessor: - '.'|'@'|':' - ; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -group: - '{' (expr* | id_) '}' - ; - -id_: - IDENTIFIER | STRING | INTEGER - ; - -IDENTIFIER: - IDENITIFIERHEAD IDENITIFIERBODY* - ; - -INTEGER: - [+-]? INTEGERFRAG - ; - -fragment INTEGERFRAG: - [0-9]+ - ; +grammar stellaris; -fragment IDENITIFIERHEAD: - [a-zA-Z] - ; +content + : expr+ EOF + ; + +expr + : keyval+ + ; + +keyval + : key ('=' | '>' | '<')+ val + ; + +key + : id_ + | attrib + ; + +val + : id_ + | attrib + | group + ; + +attrib + : id_ accessor (attrib | id_) + ; + +accessor + : '.' + | '@' + | ':' + ; + +group + : '{' (expr* | id_) '}' + ; + +id_ + : IDENTIFIER + | STRING + | INTEGER + ; + +IDENTIFIER + : IDENITIFIERHEAD IDENITIFIERBODY* + ; + +INTEGER + : [+-]? INTEGERFRAG + ; + +fragment INTEGERFRAG + : [0-9]+ + ; + +fragment IDENITIFIERHEAD + : [a-zA-Z] + ; fragment IDENITIFIERBODY - : IDENITIFIERHEAD | [0-9_] - ; - -STRING: - '"' ~["\r\n]* '"' - ; - -COMMENT: - '#' ~[\r\n]* -> channel(HIDDEN) - ; + : IDENITIFIERHEAD + | [0-9_] + ; -SPACE: - [ \t\f] -> channel(HIDDEN) - ; +STRING + : '"' ~["\r\n]* '"' + ; -NL: - [\r\n] -> channel(HIDDEN) - ; +COMMENT + : '#' ~[\r\n]* -> channel(HIDDEN) + ; +SPACE + : [ \t\f] -> channel(HIDDEN) + ; +NL + : [\r\n] -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/stl/STL.g4 b/stl/STL.g4 index ee6328a81b..590fb72561 100644 --- a/stl/STL.g4 +++ b/stl/STL.g4 @@ -1,24 +1,50 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar STL; -file_: header triangle* footer EOF; -triangle: - 'facet' 'normal' n = triple 'outer' 'loop' vertex vertex vertex 'endloop' 'endfacet'; -vertex: 'vertex' triple; -triple: i = FLOAT j = FLOAT k = FLOAT; + +file_ + : header triangle* footer EOF + ; + +triangle + : 'facet' 'normal' n = triple 'outer' 'loop' vertex vertex vertex 'endloop' 'endfacet' + ; + +vertex + : 'vertex' triple + ; + +triple + : i = FLOAT j = FLOAT k = FLOAT + ; + FLOAT - : FractionalConstant ExponentPart? - | [0-9]+ ExponentPart + : FractionalConstant ExponentPart? + | [0-9]+ ExponentPart ; -fragment -FractionalConstant - : [0-9]* '.' [0-9]+ - | [0-9]+ '.' + +fragment FractionalConstant + : [0-9]* '.' [0-9]+ + | [0-9]+ '.' ; -fragment -ExponentPart - : [eE] [+-]? [0-9]+ + +fragment ExponentPart + : [eE] [+-]? [0-9]+ + ; + +header + : 'solid' name = IDENTIFIER? + ; + +footer + : 'endsolid' name = IDENTIFIER + ; + +IDENTIFIER + : [a-zA-Z0-9]+ ; -header: 'solid' name = IDENTIFIER?; -footer: 'endsolid' name = IDENTIFIER; -IDENTIFIER: [a-zA-Z0-9]+; -WS: [\r\n\t ]+ -> skip; \ No newline at end of file +WS + : [\r\n\t ]+ -> skip + ; \ No newline at end of file diff --git a/stringtemplate/LexBasic.g4 b/stringtemplate/LexBasic.g4 index bcea964ef5..ac7326641e 100644 --- a/stringtemplate/LexBasic.g4 +++ b/stringtemplate/LexBasic.g4 @@ -34,252 +34,219 @@ * -- generalized for inclusion into the ANTLRv4 grammar distribution * */ - -lexer grammar LexBasic; -import LexUnicode; // Formal set of Unicode ranges +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +lexer grammar LexBasic; +import LexUnicode; +// Formal set of Unicode ranges // ====================================================== // Lexer fragments // - // ----------------------------------- // Whitespace & Comments -fragment Ws : Hws | Vws ; -fragment Hws : [ \t] ; -fragment Vws : [\r\n\f] ; - -fragment DocComment : '/**' .*? ('*/' | EOF) ; -fragment BlockComment : '/*' .*? ('*/' | EOF) ; +fragment Ws : Hws | Vws; +fragment Hws : [ \t]; +fragment Vws : [\r\n\f]; -fragment LineComment : '//' ~[\r\n]* ; -fragment LineCommentExt : '//' ~'\n'* ( '\n' Hws* '//' ~'\n'* )* ; +fragment DocComment : '/**' .*? ('*/' | EOF); +fragment BlockComment : '/*' .*? ('*/' | EOF); +fragment LineComment : '//' ~[\r\n]*; +fragment LineCommentExt : '//' ~'\n'* ( '\n' Hws* '//' ~'\n'*)*; // ----------------------------------- // Escapes // Any kind of escaped character that we can embed within ANTLR literal strings. -fragment EscSeq - : Esc - ( [btnfr"'\\] // The standard escaped character set such as tab, newline, etc. - | UnicodeEsc // A Unicode escape sequence - | . // Invalid escape character - | EOF // Incomplete at EOF - ) - ; - -fragment EscAny - : Esc . - ; - -fragment UnicodeEsc - : 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)? - ; - -fragment OctalEscape - : OctalDigit - | OctalDigit OctalDigit - | [0-3] OctalDigit OctalDigit - ; +fragment EscSeq: + Esc ( + [btnfr"'\\] // The standard escaped character set such as tab, newline, etc. + | UnicodeEsc // A Unicode escape sequence + | . // Invalid escape character + | EOF // Incomplete at EOF + ) +; + +fragment EscAny: Esc .; +fragment UnicodeEsc: 'u' (HexDigit (HexDigit (HexDigit HexDigit?)?)?)?; + +fragment OctalEscape: OctalDigit | OctalDigit OctalDigit | [0-3] OctalDigit OctalDigit; // ----------------------------------- // Numerals -fragment HexNumeral - : '0' [xX] HexDigits - ; - -fragment OctalNumeral - : '0' '_' OctalDigits - ; +fragment HexNumeral: '0' [xX] HexDigits; -fragment DecimalNumeral - : '0' - | [1-9] DecDigit* - ; +fragment OctalNumeral: '0' '_' OctalDigits; -fragment BinaryNumeral - : '0' [bB] BinaryDigits - ; +fragment DecimalNumeral: '0' | [1-9] DecDigit*; +fragment BinaryNumeral: '0' [bB] BinaryDigits; // ----------------------------------- // Digits -fragment HexDigits : HexDigit+ ; -fragment DecDigits : DecDigit+ ; -fragment OctalDigits : OctalDigit+ ; -fragment BinaryDigits : BinaryDigit+ ; - -fragment HexDigit : [0-9a-fA-F] ; -fragment DecDigit : [0-9] ; -fragment OctalDigit : [0-7] ; -fragment BinaryDigit : [01] ; +fragment HexDigits : HexDigit+; +fragment DecDigits : DecDigit+; +fragment OctalDigits : OctalDigit+; +fragment BinaryDigits : BinaryDigit+; +fragment HexDigit : [0-9a-fA-F]; +fragment DecDigit : [0-9]; +fragment OctalDigit : [0-7]; +fragment BinaryDigit : [01]; // ----------------------------------- // Literals -fragment BoolLiteral : True_ | False_ ; +fragment BoolLiteral: True_ | False_; -fragment CharLiteral : SQuote ( EscSeq | ~['\r\n\\] ) SQuote ; -fragment SQuoteLiteral : SQuote ( EscSeq | ~['\r\n\\] )* SQuote ; -fragment DQuoteLiteral : DQuote ( EscSeq | ~["\r\n\\] )* DQuote ; -fragment USQuoteLiteral : SQuote ( EscSeq | ~['\r\n\\] )* ; +fragment CharLiteral : SQuote ( EscSeq | ~['\r\n\\]) SQuote; +fragment SQuoteLiteral : SQuote ( EscSeq | ~['\r\n\\])* SQuote; +fragment DQuoteLiteral : DQuote ( EscSeq | ~["\r\n\\])* DQuote; +fragment USQuoteLiteral : SQuote ( EscSeq | ~['\r\n\\])*; -fragment DecimalFloatingPointLiteral - : DecDigits Dot DecDigits? ExponentPart? FloatTypeSuffix? - | Dot DecDigits ExponentPart? FloatTypeSuffix? - | DecDigits ExponentPart FloatTypeSuffix? - | DecDigits FloatTypeSuffix - ; +fragment DecimalFloatingPointLiteral: + DecDigits Dot DecDigits? ExponentPart? FloatTypeSuffix? + | Dot DecDigits ExponentPart? FloatTypeSuffix? + | DecDigits ExponentPart FloatTypeSuffix? + | DecDigits FloatTypeSuffix +; -fragment ExponentPart - : [eE] [+-]? DecDigits - ; +fragment ExponentPart: [eE] [+-]? DecDigits; -fragment FloatTypeSuffix - : [fFdD] - ; +fragment FloatTypeSuffix: [fFdD]; -fragment HexadecimalFloatingPointLiteral - : HexSignificand BinaryExponent FloatTypeSuffix? - ; +fragment HexadecimalFloatingPointLiteral: HexSignificand BinaryExponent FloatTypeSuffix?; -fragment HexSignificand - : HexNumeral Dot? - | '0' [xX] HexDigits? Dot HexDigits - ; - -fragment BinaryExponent - : [pP] [+-]? DecDigits - ; +fragment HexSignificand: HexNumeral Dot? | '0' [xX] HexDigits? Dot HexDigits; +fragment BinaryExponent: [pP] [+-]? DecDigits; // ----------------------------------- // Character ranges -fragment NameChar - : NameStartChar - | '0'..'9' - | Underscore - | '\u00B7' - | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; - -fragment NameStartChar - : 'A'..'Z' - | 'a'..'z' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - ; // ignores | ['\u10000-'\uEFFFF] ; - - -fragment JavaLetter - : [a-zA-Z$_] // "java letters" below 0xFF - | JavaUnicodeChars - ; - -fragment JavaLetterOrDigit - : [a-zA-Z0-9$_] // "java letters or digits" below 0xFF - | JavaUnicodeChars - ; +fragment NameChar: + NameStartChar + | '0' ..'9' + | Underscore + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' +; + +fragment NameStartChar: + 'A' ..'Z' + | 'a' ..'z' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00F6' + | '\u00F8' ..'\u02FF' + | '\u0370' ..'\u037D' + | '\u037F' ..'\u1FFF' + | '\u200C' ..'\u200D' + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' +; // ignores | ['\u10000-'\uEFFFF] ; + +fragment JavaLetter: + [a-zA-Z$_] // "java letters" below 0xFF + | JavaUnicodeChars +; + +fragment JavaLetterOrDigit: + [a-zA-Z0-9$_] // "java letters or digits" below 0xFF + | JavaUnicodeChars +; // covers all characters above 0xFF which are not a surrogate // and UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF -fragment JavaUnicodeChars - : ~[\u0000-\u00FF\uD800-\uDBFF] {Character.isJavaIdentifierPart(_input.LA(-1))}? - | [\uD800-\uDBFF] [\uDC00-\uDFFF] {Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? - ; - +fragment JavaUnicodeChars: + ~[\u0000-\u00FF\uD800-\uDBFF] {Character.isJavaIdentifierPart(_input.LA(-1))}? + | [\uD800-\uDBFF] [\uDC00-\uDFFF] {Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? +; // ----------------------------------- // Types -fragment Boolean : 'boolean' ; -fragment Byte : 'byte' ; -fragment Short : 'short' ; -fragment Int : 'int' ; -fragment Long : 'long' ; -fragment Char : 'char' ; -fragment Float : 'float' ; -fragment Double : 'double' ; - -fragment True_ : 'true' ; -fragment False_ : 'false' ; +fragment Boolean : 'boolean'; +fragment Byte : 'byte'; +fragment Short : 'short'; +fragment Int : 'int'; +fragment Long : 'long'; +fragment Char : 'char'; +fragment Float : 'float'; +fragment Double : 'double'; +fragment True_ : 'true'; +fragment False_ : 'false'; // ----------------------------------- // Symbols -fragment Esc : '\\' ; -fragment Colon : ':' ; -fragment DColon : '::' ; -fragment SQuote : '\'' ; -fragment DQuote : '"' ; -fragment BQuote : '`' ; -fragment LParen : '(' ; -fragment RParen : ')' ; -fragment LBrace : '{' ; -fragment RBrace : '}' ; -fragment LBrack : '[' ; -fragment RBrack : ']' ; -fragment RArrow : '->' ; -fragment Lt : '<' ; -fragment Gt : '>' ; -fragment Lte : '<=' ; -fragment Gte : '>=' ; -fragment Equal : '=' ; -fragment NotEqual : '!=' ; -fragment Question : '?' ; -fragment Bang : '!' ; -fragment Star : '*' ; -fragment Slash : '/' ; -fragment Percent : '%' ; -fragment Caret : '^' ; -fragment Plus : '+' ; -fragment Minus : '-' ; -fragment PlusAssign : '+=' ; -fragment MinusAssign : '-=' ; -fragment MulAssign : '*=' ; -fragment DivAssign : '/=' ; -fragment AndAssign : '&=' ; -fragment OrAssign : '|=' ; -fragment XOrAssign : '^=' ; -fragment ModAssign : '%=' ; -fragment LShiftAssign : '<<=' ; -fragment RShiftAssign : '>>=' ; -fragment URShiftAssign : '>>>='; -fragment Underscore : '_' ; -fragment Pipe : '|' ; -fragment Amp : '&' ; -fragment And : '&&' ; -fragment Or : '||' ; -fragment Inc : '++' ; -fragment Dec : '--' ; -fragment LShift : '<<' ; -fragment RShift : '>>' ; -fragment Dollar : '$' ; -fragment Comma : ',' ; -fragment Semi : ';' ; -fragment Dot : '.' ; -fragment Range : '..' ; -fragment Ellipsis : '...' ; -fragment At : '@' ; -fragment Pound : '#' ; -fragment Tilde : '~' ; +fragment Esc : '\\'; +fragment Colon : ':'; +fragment DColon : '::'; +fragment SQuote : '\''; +fragment DQuote : '"'; +fragment BQuote : '`'; +fragment LParen : '('; +fragment RParen : ')'; +fragment LBrace : '{'; +fragment RBrace : '}'; +fragment LBrack : '['; +fragment RBrack : ']'; +fragment RArrow : '->'; +fragment Lt : '<'; +fragment Gt : '>'; +fragment Lte : '<='; +fragment Gte : '>='; +fragment Equal : '='; +fragment NotEqual : '!='; +fragment Question : '?'; +fragment Bang : '!'; +fragment Star : '*'; +fragment Slash : '/'; +fragment Percent : '%'; +fragment Caret : '^'; +fragment Plus : '+'; +fragment Minus : '-'; +fragment PlusAssign : '+='; +fragment MinusAssign : '-='; +fragment MulAssign : '*='; +fragment DivAssign : '/='; +fragment AndAssign : '&='; +fragment OrAssign : '|='; +fragment XOrAssign : '^='; +fragment ModAssign : '%='; +fragment LShiftAssign : '<<='; +fragment RShiftAssign : '>>='; +fragment URShiftAssign : '>>>='; +fragment Underscore : '_'; +fragment Pipe : '|'; +fragment Amp : '&'; +fragment And : '&&'; +fragment Or : '||'; +fragment Inc : '++'; +fragment Dec : '--'; +fragment LShift : '<<'; +fragment RShift : '>>'; +fragment Dollar : '$'; +fragment Comma : ','; +fragment Semi : ';'; +fragment Dot : '.'; +fragment Range : '..'; +fragment Ellipsis : '...'; +fragment At : '@'; +fragment Pound : '#'; +fragment Tilde : '~'; \ No newline at end of file diff --git a/stringtemplate/LexUnicode.g4 b/stringtemplate/LexUnicode.g4 index 64ca211252..dbdc797a7d 100644 --- a/stringtemplate/LexUnicode.g4 +++ b/stringtemplate/LexUnicode.g4 @@ -35,609 +35,612 @@ * */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar LexUnicode; // ====================================================== // Lexer fragments // -fragment UnicodeLetter - : UnicodeClass_LU - | UnicodeClass_LL - | UnicodeClass_LT - | UnicodeClass_LM - | UnicodeClass_LO - ; +fragment UnicodeLetter: + UnicodeClass_LU + | UnicodeClass_LL + | UnicodeClass_LT + | UnicodeClass_LM + | UnicodeClass_LO +; -fragment UnicodeClass_LU - : '\u0041'..'\u005a' - | '\u00c0'..'\u00d6' - | '\u00d8'..'\u00de' - | '\u0100'..'\u0136' - | '\u0139'..'\u0147' - | '\u014a'..'\u0178' - | '\u0179'..'\u017d' - | '\u0181'..'\u0182' - | '\u0184'..'\u0186' - | '\u0187'..'\u0189' - | '\u018a'..'\u018b' - | '\u018e'..'\u0191' - | '\u0193'..'\u0194' - | '\u0196'..'\u0198' - | '\u019c'..'\u019d' - | '\u019f'..'\u01a0' - | '\u01a2'..'\u01a6' - | '\u01a7'..'\u01a9' - | '\u01ac'..'\u01ae' - | '\u01af'..'\u01b1' - | '\u01b2'..'\u01b3' - | '\u01b5'..'\u01b7' - | '\u01b8'..'\u01bc' - | '\u01c4'..'\u01cd' - | '\u01cf'..'\u01db' - | '\u01de'..'\u01ee' - | '\u01f1'..'\u01f4' - | '\u01f6'..'\u01f8' - | '\u01fa'..'\u0232' - | '\u023a'..'\u023b' - | '\u023d'..'\u023e' - | '\u0241'..'\u0243' - | '\u0244'..'\u0246' - | '\u0248'..'\u024e' - | '\u0370'..'\u0372' - | '\u0376'..'\u037f' - | '\u0386'..'\u0388' - | '\u0389'..'\u038a' - | '\u038c'..'\u038e' - | '\u038f'..'\u0391' - | '\u0392'..'\u03a1' - | '\u03a3'..'\u03ab' - | '\u03cf'..'\u03d2' - | '\u03d3'..'\u03d4' - | '\u03d8'..'\u03ee' - | '\u03f4'..'\u03f7' - | '\u03f9'..'\u03fa' - | '\u03fd'..'\u042f' - | '\u0460'..'\u0480' - | '\u048a'..'\u04c0' - | '\u04c1'..'\u04cd' - | '\u04d0'..'\u052e' - | '\u0531'..'\u0556' - | '\u10a0'..'\u10c5' - | '\u10c7'..'\u10cd' - | '\u1e00'..'\u1e94' - | '\u1e9e'..'\u1efe' - | '\u1f08'..'\u1f0f' - | '\u1f18'..'\u1f1d' - | '\u1f28'..'\u1f2f' - | '\u1f38'..'\u1f3f' - | '\u1f48'..'\u1f4d' - | '\u1f59'..'\u1f5f' - | '\u1f68'..'\u1f6f' - | '\u1fb8'..'\u1fbb' - | '\u1fc8'..'\u1fcb' - | '\u1fd8'..'\u1fdb' - | '\u1fe8'..'\u1fec' - | '\u1ff8'..'\u1ffb' - | '\u2102'..'\u2107' - | '\u210b'..'\u210d' - | '\u2110'..'\u2112' - | '\u2115'..'\u2119' - | '\u211a'..'\u211d' - | '\u2124'..'\u212a' - | '\u212b'..'\u212d' - | '\u2130'..'\u2133' - | '\u213e'..'\u213f' - | '\u2145'..'\u2183' - | '\u2c00'..'\u2c2e' - | '\u2c60'..'\u2c62' - | '\u2c63'..'\u2c64' - | '\u2c67'..'\u2c6d' - | '\u2c6e'..'\u2c70' - | '\u2c72'..'\u2c75' - | '\u2c7e'..'\u2c80' - | '\u2c82'..'\u2ce2' - | '\u2ceb'..'\u2ced' - | '\u2cf2'..'\ua640' - | '\ua642'..'\ua66c' - | '\ua680'..'\ua69a' - | '\ua722'..'\ua72e' - | '\ua732'..'\ua76e' - | '\ua779'..'\ua77d' - | '\ua77e'..'\ua786' - | '\ua78b'..'\ua78d' - | '\ua790'..'\ua792' - | '\ua796'..'\ua7aa' - | '\ua7ab'..'\ua7ad' - | '\ua7b0'..'\ua7b1' - | '\uff21'..'\uff3a' - ; +fragment UnicodeClass_LU: + '\u0041' ..'\u005a' + | '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00de' + | '\u0100' ..'\u0136' + | '\u0139' ..'\u0147' + | '\u014a' ..'\u0178' + | '\u0179' ..'\u017d' + | '\u0181' ..'\u0182' + | '\u0184' ..'\u0186' + | '\u0187' ..'\u0189' + | '\u018a' ..'\u018b' + | '\u018e' ..'\u0191' + | '\u0193' ..'\u0194' + | '\u0196' ..'\u0198' + | '\u019c' ..'\u019d' + | '\u019f' ..'\u01a0' + | '\u01a2' ..'\u01a6' + | '\u01a7' ..'\u01a9' + | '\u01ac' ..'\u01ae' + | '\u01af' ..'\u01b1' + | '\u01b2' ..'\u01b3' + | '\u01b5' ..'\u01b7' + | '\u01b8' ..'\u01bc' + | '\u01c4' ..'\u01cd' + | '\u01cf' ..'\u01db' + | '\u01de' ..'\u01ee' + | '\u01f1' ..'\u01f4' + | '\u01f6' ..'\u01f8' + | '\u01fa' ..'\u0232' + | '\u023a' ..'\u023b' + | '\u023d' ..'\u023e' + | '\u0241' ..'\u0243' + | '\u0244' ..'\u0246' + | '\u0248' ..'\u024e' + | '\u0370' ..'\u0372' + | '\u0376' ..'\u037f' + | '\u0386' ..'\u0388' + | '\u0389' ..'\u038a' + | '\u038c' ..'\u038e' + | '\u038f' ..'\u0391' + | '\u0392' ..'\u03a1' + | '\u03a3' ..'\u03ab' + | '\u03cf' ..'\u03d2' + | '\u03d3' ..'\u03d4' + | '\u03d8' ..'\u03ee' + | '\u03f4' ..'\u03f7' + | '\u03f9' ..'\u03fa' + | '\u03fd' ..'\u042f' + | '\u0460' ..'\u0480' + | '\u048a' ..'\u04c0' + | '\u04c1' ..'\u04cd' + | '\u04d0' ..'\u052e' + | '\u0531' ..'\u0556' + | '\u10a0' ..'\u10c5' + | '\u10c7' ..'\u10cd' + | '\u1e00' ..'\u1e94' + | '\u1e9e' ..'\u1efe' + | '\u1f08' ..'\u1f0f' + | '\u1f18' ..'\u1f1d' + | '\u1f28' ..'\u1f2f' + | '\u1f38' ..'\u1f3f' + | '\u1f48' ..'\u1f4d' + | '\u1f59' ..'\u1f5f' + | '\u1f68' ..'\u1f6f' + | '\u1fb8' ..'\u1fbb' + | '\u1fc8' ..'\u1fcb' + | '\u1fd8' ..'\u1fdb' + | '\u1fe8' ..'\u1fec' + | '\u1ff8' ..'\u1ffb' + | '\u2102' ..'\u2107' + | '\u210b' ..'\u210d' + | '\u2110' ..'\u2112' + | '\u2115' ..'\u2119' + | '\u211a' ..'\u211d' + | '\u2124' ..'\u212a' + | '\u212b' ..'\u212d' + | '\u2130' ..'\u2133' + | '\u213e' ..'\u213f' + | '\u2145' ..'\u2183' + | '\u2c00' ..'\u2c2e' + | '\u2c60' ..'\u2c62' + | '\u2c63' ..'\u2c64' + | '\u2c67' ..'\u2c6d' + | '\u2c6e' ..'\u2c70' + | '\u2c72' ..'\u2c75' + | '\u2c7e' ..'\u2c80' + | '\u2c82' ..'\u2ce2' + | '\u2ceb' ..'\u2ced' + | '\u2cf2' ..'\ua640' + | '\ua642' ..'\ua66c' + | '\ua680' ..'\ua69a' + | '\ua722' ..'\ua72e' + | '\ua732' ..'\ua76e' + | '\ua779' ..'\ua77d' + | '\ua77e' ..'\ua786' + | '\ua78b' ..'\ua78d' + | '\ua790' ..'\ua792' + | '\ua796' ..'\ua7aa' + | '\ua7ab' ..'\ua7ad' + | '\ua7b0' ..'\ua7b1' + | '\uff21' ..'\uff3a' +; -fragment UnicodeClass_LL - : '\u0061'..'\u007A' - | '\u00b5'..'\u00df' - | '\u00e0'..'\u00f6' - | '\u00f8'..'\u00ff' - | '\u0101'..'\u0137' - | '\u0138'..'\u0148' - | '\u0149'..'\u0177' - | '\u017a'..'\u017e' - | '\u017f'..'\u0180' - | '\u0183'..'\u0185' - | '\u0188'..'\u018c' - | '\u018d'..'\u0192' - | '\u0195'..'\u0199' - | '\u019a'..'\u019b' - | '\u019e'..'\u01a1' - | '\u01a3'..'\u01a5' - | '\u01a8'..'\u01aa' - | '\u01ab'..'\u01ad' - | '\u01b0'..'\u01b4' - | '\u01b6'..'\u01b9' - | '\u01ba'..'\u01bd' - | '\u01be'..'\u01bf' - | '\u01c6'..'\u01cc' - | '\u01ce'..'\u01dc' - | '\u01dd'..'\u01ef' - | '\u01f0'..'\u01f3' - | '\u01f5'..'\u01f9' - | '\u01fb'..'\u0233' - | '\u0234'..'\u0239' - | '\u023c'..'\u023f' - | '\u0240'..'\u0242' - | '\u0247'..'\u024f' - | '\u0250'..'\u0293' - | '\u0295'..'\u02af' - | '\u0371'..'\u0373' - | '\u0377'..'\u037b' - | '\u037c'..'\u037d' - | '\u0390'..'\u03ac' - | '\u03ad'..'\u03ce' - | '\u03d0'..'\u03d1' - | '\u03d5'..'\u03d7' - | '\u03d9'..'\u03ef' - | '\u03f0'..'\u03f3' - | '\u03f5'..'\u03fb' - | '\u03fc'..'\u0430' - | '\u0431'..'\u045f' - | '\u0461'..'\u0481' - | '\u048b'..'\u04bf' - | '\u04c2'..'\u04ce' - | '\u04cf'..'\u052f' - | '\u0561'..'\u0587' - | '\u1d00'..'\u1d2b' - | '\u1d6b'..'\u1d77' - | '\u1d79'..'\u1d9a' - | '\u1e01'..'\u1e95' - | '\u1e96'..'\u1e9d' - | '\u1e9f'..'\u1eff' - | '\u1f00'..'\u1f07' - | '\u1f10'..'\u1f15' - | '\u1f20'..'\u1f27' - | '\u1f30'..'\u1f37' - | '\u1f40'..'\u1f45' - | '\u1f50'..'\u1f57' - | '\u1f60'..'\u1f67' - | '\u1f70'..'\u1f7d' - | '\u1f80'..'\u1f87' - | '\u1f90'..'\u1f97' - | '\u1fa0'..'\u1fa7' - | '\u1fb0'..'\u1fb4' - | '\u1fb6'..'\u1fb7' - | '\u1fbe'..'\u1fc2' - | '\u1fc3'..'\u1fc4' - | '\u1fc6'..'\u1fc7' - | '\u1fd0'..'\u1fd3' - | '\u1fd6'..'\u1fd7' - | '\u1fe0'..'\u1fe7' - | '\u1ff2'..'\u1ff4' - | '\u1ff6'..'\u1ff7' - | '\u210a'..'\u210e' - | '\u210f'..'\u2113' - | '\u212f'..'\u2139' - | '\u213c'..'\u213d' - | '\u2146'..'\u2149' - | '\u214e'..'\u2184' - | '\u2c30'..'\u2c5e' - | '\u2c61'..'\u2c65' - | '\u2c66'..'\u2c6c' - | '\u2c71'..'\u2c73' - | '\u2c74'..'\u2c76' - | '\u2c77'..'\u2c7b' - | '\u2c81'..'\u2ce3' - | '\u2ce4'..'\u2cec' - | '\u2cee'..'\u2cf3' - | '\u2d00'..'\u2d25' - | '\u2d27'..'\u2d2d' - | '\ua641'..'\ua66d' - | '\ua681'..'\ua69b' - | '\ua723'..'\ua72f' - | '\ua730'..'\ua731' - | '\ua733'..'\ua771' - | '\ua772'..'\ua778' - | '\ua77a'..'\ua77c' - | '\ua77f'..'\ua787' - | '\ua78c'..'\ua78e' - | '\ua791'..'\ua793' - | '\ua794'..'\ua795' - | '\ua797'..'\ua7a9' - | '\ua7fa'..'\uab30' - | '\uab31'..'\uab5a' - | '\uab64'..'\uab65' - | '\ufb00'..'\ufb06' - | '\ufb13'..'\ufb17' - | '\uff41'..'\uff5a' - ; +fragment UnicodeClass_LL: + '\u0061' ..'\u007A' + | '\u00b5' ..'\u00df' + | '\u00e0' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0101' ..'\u0137' + | '\u0138' ..'\u0148' + | '\u0149' ..'\u0177' + | '\u017a' ..'\u017e' + | '\u017f' ..'\u0180' + | '\u0183' ..'\u0185' + | '\u0188' ..'\u018c' + | '\u018d' ..'\u0192' + | '\u0195' ..'\u0199' + | '\u019a' ..'\u019b' + | '\u019e' ..'\u01a1' + | '\u01a3' ..'\u01a5' + | '\u01a8' ..'\u01aa' + | '\u01ab' ..'\u01ad' + | '\u01b0' ..'\u01b4' + | '\u01b6' ..'\u01b9' + | '\u01ba' ..'\u01bd' + | '\u01be' ..'\u01bf' + | '\u01c6' ..'\u01cc' + | '\u01ce' ..'\u01dc' + | '\u01dd' ..'\u01ef' + | '\u01f0' ..'\u01f3' + | '\u01f5' ..'\u01f9' + | '\u01fb' ..'\u0233' + | '\u0234' ..'\u0239' + | '\u023c' ..'\u023f' + | '\u0240' ..'\u0242' + | '\u0247' ..'\u024f' + | '\u0250' ..'\u0293' + | '\u0295' ..'\u02af' + | '\u0371' ..'\u0373' + | '\u0377' ..'\u037b' + | '\u037c' ..'\u037d' + | '\u0390' ..'\u03ac' + | '\u03ad' ..'\u03ce' + | '\u03d0' ..'\u03d1' + | '\u03d5' ..'\u03d7' + | '\u03d9' ..'\u03ef' + | '\u03f0' ..'\u03f3' + | '\u03f5' ..'\u03fb' + | '\u03fc' ..'\u0430' + | '\u0431' ..'\u045f' + | '\u0461' ..'\u0481' + | '\u048b' ..'\u04bf' + | '\u04c2' ..'\u04ce' + | '\u04cf' ..'\u052f' + | '\u0561' ..'\u0587' + | '\u1d00' ..'\u1d2b' + | '\u1d6b' ..'\u1d77' + | '\u1d79' ..'\u1d9a' + | '\u1e01' ..'\u1e95' + | '\u1e96' ..'\u1e9d' + | '\u1e9f' ..'\u1eff' + | '\u1f00' ..'\u1f07' + | '\u1f10' ..'\u1f15' + | '\u1f20' ..'\u1f27' + | '\u1f30' ..'\u1f37' + | '\u1f40' ..'\u1f45' + | '\u1f50' ..'\u1f57' + | '\u1f60' ..'\u1f67' + | '\u1f70' ..'\u1f7d' + | '\u1f80' ..'\u1f87' + | '\u1f90' ..'\u1f97' + | '\u1fa0' ..'\u1fa7' + | '\u1fb0' ..'\u1fb4' + | '\u1fb6' ..'\u1fb7' + | '\u1fbe' ..'\u1fc2' + | '\u1fc3' ..'\u1fc4' + | '\u1fc6' ..'\u1fc7' + | '\u1fd0' ..'\u1fd3' + | '\u1fd6' ..'\u1fd7' + | '\u1fe0' ..'\u1fe7' + | '\u1ff2' ..'\u1ff4' + | '\u1ff6' ..'\u1ff7' + | '\u210a' ..'\u210e' + | '\u210f' ..'\u2113' + | '\u212f' ..'\u2139' + | '\u213c' ..'\u213d' + | '\u2146' ..'\u2149' + | '\u214e' ..'\u2184' + | '\u2c30' ..'\u2c5e' + | '\u2c61' ..'\u2c65' + | '\u2c66' ..'\u2c6c' + | '\u2c71' ..'\u2c73' + | '\u2c74' ..'\u2c76' + | '\u2c77' ..'\u2c7b' + | '\u2c81' ..'\u2ce3' + | '\u2ce4' ..'\u2cec' + | '\u2cee' ..'\u2cf3' + | '\u2d00' ..'\u2d25' + | '\u2d27' ..'\u2d2d' + | '\ua641' ..'\ua66d' + | '\ua681' ..'\ua69b' + | '\ua723' ..'\ua72f' + | '\ua730' ..'\ua731' + | '\ua733' ..'\ua771' + | '\ua772' ..'\ua778' + | '\ua77a' ..'\ua77c' + | '\ua77f' ..'\ua787' + | '\ua78c' ..'\ua78e' + | '\ua791' ..'\ua793' + | '\ua794' ..'\ua795' + | '\ua797' ..'\ua7a9' + | '\ua7fa' ..'\uab30' + | '\uab31' ..'\uab5a' + | '\uab64' ..'\uab65' + | '\ufb00' ..'\ufb06' + | '\ufb13' ..'\ufb17' + | '\uff41' ..'\uff5a' +; -fragment UnicodeClass_LT - : '\u01c5'..'\u01cb' - | '\u01f2'..'\u1f88' - | '\u1f89'..'\u1f8f' - | '\u1f98'..'\u1f9f' - | '\u1fa8'..'\u1faf' - | '\u1fbc'..'\u1fcc' - | '\u1ffc'..'\u1ffc' - ; +fragment UnicodeClass_LT: + '\u01c5' ..'\u01cb' + | '\u01f2' ..'\u1f88' + | '\u1f89' ..'\u1f8f' + | '\u1f98' ..'\u1f9f' + | '\u1fa8' ..'\u1faf' + | '\u1fbc' ..'\u1fcc' + | '\u1ffc' ..'\u1ffc' +; -fragment UnicodeClass_LM - : '\u02b0'..'\u02c1' - | '\u02c6'..'\u02d1' - | '\u02e0'..'\u02e4' - | '\u02ec'..'\u02ee' - | '\u0374'..'\u037a' - | '\u0559'..'\u0640' - | '\u06e5'..'\u06e6' - | '\u07f4'..'\u07f5' - | '\u07fa'..'\u081a' - | '\u0824'..'\u0828' - | '\u0971'..'\u0e46' - | '\u0ec6'..'\u10fc' - | '\u17d7'..'\u1843' - | '\u1aa7'..'\u1c78' - | '\u1c79'..'\u1c7d' - | '\u1d2c'..'\u1d6a' - | '\u1d78'..'\u1d9b' - | '\u1d9c'..'\u1dbf' - | '\u2071'..'\u207f' - | '\u2090'..'\u209c' - | '\u2c7c'..'\u2c7d' - | '\u2d6f'..'\u2e2f' - | '\u3005'..'\u3031' - | '\u3032'..'\u3035' - | '\u303b'..'\u309d' - | '\u309e'..'\u30fc' - | '\u30fd'..'\u30fe' - | '\ua015'..'\ua4f8' - | '\ua4f9'..'\ua4fd' - | '\ua60c'..'\ua67f' - | '\ua69c'..'\ua69d' - | '\ua717'..'\ua71f' - | '\ua770'..'\ua788' - | '\ua7f8'..'\ua7f9' - | '\ua9cf'..'\ua9e6' - | '\uaa70'..'\uaadd' - | '\uaaf3'..'\uaaf4' - | '\uab5c'..'\uab5f' - | '\uff70'..'\uff9e' - | '\uff9f'..'\uff9f' - ; +fragment UnicodeClass_LM: + '\u02b0' ..'\u02c1' + | '\u02c6' ..'\u02d1' + | '\u02e0' ..'\u02e4' + | '\u02ec' ..'\u02ee' + | '\u0374' ..'\u037a' + | '\u0559' ..'\u0640' + | '\u06e5' ..'\u06e6' + | '\u07f4' ..'\u07f5' + | '\u07fa' ..'\u081a' + | '\u0824' ..'\u0828' + | '\u0971' ..'\u0e46' + | '\u0ec6' ..'\u10fc' + | '\u17d7' ..'\u1843' + | '\u1aa7' ..'\u1c78' + | '\u1c79' ..'\u1c7d' + | '\u1d2c' ..'\u1d6a' + | '\u1d78' ..'\u1d9b' + | '\u1d9c' ..'\u1dbf' + | '\u2071' ..'\u207f' + | '\u2090' ..'\u209c' + | '\u2c7c' ..'\u2c7d' + | '\u2d6f' ..'\u2e2f' + | '\u3005' ..'\u3031' + | '\u3032' ..'\u3035' + | '\u303b' ..'\u309d' + | '\u309e' ..'\u30fc' + | '\u30fd' ..'\u30fe' + | '\ua015' ..'\ua4f8' + | '\ua4f9' ..'\ua4fd' + | '\ua60c' ..'\ua67f' + | '\ua69c' ..'\ua69d' + | '\ua717' ..'\ua71f' + | '\ua770' ..'\ua788' + | '\ua7f8' ..'\ua7f9' + | '\ua9cf' ..'\ua9e6' + | '\uaa70' ..'\uaadd' + | '\uaaf3' ..'\uaaf4' + | '\uab5c' ..'\uab5f' + | '\uff70' ..'\uff9e' + | '\uff9f' ..'\uff9f' +; -fragment UnicodeClass_LO - : '\u00aa'..'\u00ba' - | '\u01bb'..'\u01c0' - | '\u01c1'..'\u01c3' - | '\u0294'..'\u05d0' - | '\u05d1'..'\u05ea' - | '\u05f0'..'\u05f2' - | '\u0620'..'\u063f' - | '\u0641'..'\u064a' - | '\u066e'..'\u066f' - | '\u0671'..'\u06d3' - | '\u06d5'..'\u06ee' - | '\u06ef'..'\u06fa' - | '\u06fb'..'\u06fc' - | '\u06ff'..'\u0710' - | '\u0712'..'\u072f' - | '\u074d'..'\u07a5' - | '\u07b1'..'\u07ca' - | '\u07cb'..'\u07ea' - | '\u0800'..'\u0815' - | '\u0840'..'\u0858' - | '\u08a0'..'\u08b2' - | '\u0904'..'\u0939' - | '\u093d'..'\u0950' - | '\u0958'..'\u0961' - | '\u0972'..'\u0980' - | '\u0985'..'\u098c' - | '\u098f'..'\u0990' - | '\u0993'..'\u09a8' - | '\u09aa'..'\u09b0' - | '\u09b2'..'\u09b6' - | '\u09b7'..'\u09b9' - | '\u09bd'..'\u09ce' - | '\u09dc'..'\u09dd' - | '\u09df'..'\u09e1' - | '\u09f0'..'\u09f1' - | '\u0a05'..'\u0a0a' - | '\u0a0f'..'\u0a10' - | '\u0a13'..'\u0a28' - | '\u0a2a'..'\u0a30' - | '\u0a32'..'\u0a33' - | '\u0a35'..'\u0a36' - | '\u0a38'..'\u0a39' - | '\u0a59'..'\u0a5c' - | '\u0a5e'..'\u0a72' - | '\u0a73'..'\u0a74' - | '\u0a85'..'\u0a8d' - | '\u0a8f'..'\u0a91' - | '\u0a93'..'\u0aa8' - | '\u0aaa'..'\u0ab0' - | '\u0ab2'..'\u0ab3' - | '\u0ab5'..'\u0ab9' - | '\u0abd'..'\u0ad0' - | '\u0ae0'..'\u0ae1' - | '\u0b05'..'\u0b0c' - | '\u0b0f'..'\u0b10' - | '\u0b13'..'\u0b28' - | '\u0b2a'..'\u0b30' - | '\u0b32'..'\u0b33' - | '\u0b35'..'\u0b39' - | '\u0b3d'..'\u0b5c' - | '\u0b5d'..'\u0b5f' - | '\u0b60'..'\u0b61' - | '\u0b71'..'\u0b83' - | '\u0b85'..'\u0b8a' - | '\u0b8e'..'\u0b90' - | '\u0b92'..'\u0b95' - | '\u0b99'..'\u0b9a' - | '\u0b9c'..'\u0b9e' - | '\u0b9f'..'\u0ba3' - | '\u0ba4'..'\u0ba8' - | '\u0ba9'..'\u0baa' - | '\u0bae'..'\u0bb9' - | '\u0bd0'..'\u0c05' - | '\u0c06'..'\u0c0c' - | '\u0c0e'..'\u0c10' - | '\u0c12'..'\u0c28' - | '\u0c2a'..'\u0c39' - | '\u0c3d'..'\u0c58' - | '\u0c59'..'\u0c60' - | '\u0c61'..'\u0c85' - | '\u0c86'..'\u0c8c' - | '\u0c8e'..'\u0c90' - | '\u0c92'..'\u0ca8' - | '\u0caa'..'\u0cb3' - | '\u0cb5'..'\u0cb9' - | '\u0cbd'..'\u0cde' - | '\u0ce0'..'\u0ce1' - | '\u0cf1'..'\u0cf2' - | '\u0d05'..'\u0d0c' - | '\u0d0e'..'\u0d10' - | '\u0d12'..'\u0d3a' - | '\u0d3d'..'\u0d4e' - | '\u0d60'..'\u0d61' - | '\u0d7a'..'\u0d7f' - | '\u0d85'..'\u0d96' - | '\u0d9a'..'\u0db1' - | '\u0db3'..'\u0dbb' - | '\u0dbd'..'\u0dc0' - | '\u0dc1'..'\u0dc6' - | '\u0e01'..'\u0e30' - | '\u0e32'..'\u0e33' - | '\u0e40'..'\u0e45' - | '\u0e81'..'\u0e82' - | '\u0e84'..'\u0e87' - | '\u0e88'..'\u0e8a' - | '\u0e8d'..'\u0e94' - | '\u0e95'..'\u0e97' - | '\u0e99'..'\u0e9f' - | '\u0ea1'..'\u0ea3' - | '\u0ea5'..'\u0ea7' - | '\u0eaa'..'\u0eab' - | '\u0ead'..'\u0eb0' - | '\u0eb2'..'\u0eb3' - | '\u0ebd'..'\u0ec0' - | '\u0ec1'..'\u0ec4' - | '\u0edc'..'\u0edf' - | '\u0f00'..'\u0f40' - | '\u0f41'..'\u0f47' - | '\u0f49'..'\u0f6c' - | '\u0f88'..'\u0f8c' - | '\u1000'..'\u102a' - | '\u103f'..'\u1050' - | '\u1051'..'\u1055' - | '\u105a'..'\u105d' - | '\u1061'..'\u1065' - | '\u1066'..'\u106e' - | '\u106f'..'\u1070' - | '\u1075'..'\u1081' - | '\u108e'..'\u10d0' - | '\u10d1'..'\u10fa' - | '\u10fd'..'\u1248' - | '\u124a'..'\u124d' - | '\u1250'..'\u1256' - | '\u1258'..'\u125a' - | '\u125b'..'\u125d' - | '\u1260'..'\u1288' - | '\u128a'..'\u128d' - | '\u1290'..'\u12b0' - | '\u12b2'..'\u12b5' - | '\u12b8'..'\u12be' - | '\u12c0'..'\u12c2' - | '\u12c3'..'\u12c5' - | '\u12c8'..'\u12d6' - | '\u12d8'..'\u1310' - | '\u1312'..'\u1315' - | '\u1318'..'\u135a' - | '\u1380'..'\u138f' - | '\u13a0'..'\u13f4' - | '\u1401'..'\u166c' - | '\u166f'..'\u167f' - | '\u1681'..'\u169a' - | '\u16a0'..'\u16ea' - | '\u16f1'..'\u16f8' - | '\u1700'..'\u170c' - | '\u170e'..'\u1711' - | '\u1720'..'\u1731' - | '\u1740'..'\u1751' - | '\u1760'..'\u176c' - | '\u176e'..'\u1770' - | '\u1780'..'\u17b3' - | '\u17dc'..'\u1820' - | '\u1821'..'\u1842' - | '\u1844'..'\u1877' - | '\u1880'..'\u18a8' - | '\u18aa'..'\u18b0' - | '\u18b1'..'\u18f5' - | '\u1900'..'\u191e' - | '\u1950'..'\u196d' - | '\u1970'..'\u1974' - | '\u1980'..'\u19ab' - | '\u19c1'..'\u19c7' - | '\u1a00'..'\u1a16' - | '\u1a20'..'\u1a54' - | '\u1b05'..'\u1b33' - | '\u1b45'..'\u1b4b' - | '\u1b83'..'\u1ba0' - | '\u1bae'..'\u1baf' - | '\u1bba'..'\u1be5' - | '\u1c00'..'\u1c23' - | '\u1c4d'..'\u1c4f' - | '\u1c5a'..'\u1c77' - | '\u1ce9'..'\u1cec' - | '\u1cee'..'\u1cf1' - | '\u1cf5'..'\u1cf6' - | '\u2135'..'\u2138' - | '\u2d30'..'\u2d67' - | '\u2d80'..'\u2d96' - | '\u2da0'..'\u2da6' - | '\u2da8'..'\u2dae' - | '\u2db0'..'\u2db6' - | '\u2db8'..'\u2dbe' - | '\u2dc0'..'\u2dc6' - | '\u2dc8'..'\u2dce' - | '\u2dd0'..'\u2dd6' - | '\u2dd8'..'\u2dde' - | '\u3006'..'\u303c' - | '\u3041'..'\u3096' - | '\u309f'..'\u30a1' - | '\u30a2'..'\u30fa' - | '\u30ff'..'\u3105' - | '\u3106'..'\u312d' - | '\u3131'..'\u318e' - | '\u31a0'..'\u31ba' - | '\u31f0'..'\u31ff' - | '\u3400'..'\u4db5' - | '\u4e00'..'\u9fcc' - | '\ua000'..'\ua014' - | '\ua016'..'\ua48c' - | '\ua4d0'..'\ua4f7' - | '\ua500'..'\ua60b' - | '\ua610'..'\ua61f' - | '\ua62a'..'\ua62b' - | '\ua66e'..'\ua6a0' - | '\ua6a1'..'\ua6e5' - | '\ua7f7'..'\ua7fb' - | '\ua7fc'..'\ua801' - | '\ua803'..'\ua805' - | '\ua807'..'\ua80a' - | '\ua80c'..'\ua822' - | '\ua840'..'\ua873' - | '\ua882'..'\ua8b3' - | '\ua8f2'..'\ua8f7' - | '\ua8fb'..'\ua90a' - | '\ua90b'..'\ua925' - | '\ua930'..'\ua946' - | '\ua960'..'\ua97c' - | '\ua984'..'\ua9b2' - | '\ua9e0'..'\ua9e4' - | '\ua9e7'..'\ua9ef' - | '\ua9fa'..'\ua9fe' - | '\uaa00'..'\uaa28' - | '\uaa40'..'\uaa42' - | '\uaa44'..'\uaa4b' - | '\uaa60'..'\uaa6f' - | '\uaa71'..'\uaa76' - | '\uaa7a'..'\uaa7e' - | '\uaa7f'..'\uaaaf' - | '\uaab1'..'\uaab5' - | '\uaab6'..'\uaab9' - | '\uaaba'..'\uaabd' - | '\uaac0'..'\uaac2' - | '\uaadb'..'\uaadc' - | '\uaae0'..'\uaaea' - | '\uaaf2'..'\uab01' - | '\uab02'..'\uab06' - | '\uab09'..'\uab0e' - | '\uab11'..'\uab16' - | '\uab20'..'\uab26' - | '\uab28'..'\uab2e' - | '\uabc0'..'\uabe2' - | '\uac00'..'\ud7a3' - | '\ud7b0'..'\ud7c6' - | '\ud7cb'..'\ud7fb' - | '\uf900'..'\ufa6d' - | '\ufa70'..'\ufad9' - | '\ufb1d'..'\ufb1f' - | '\ufb20'..'\ufb28' - | '\ufb2a'..'\ufb36' - | '\ufb38'..'\ufb3c' - | '\ufb3e'..'\ufb40' - | '\ufb41'..'\ufb43' - | '\ufb44'..'\ufb46' - | '\ufb47'..'\ufbb1' - | '\ufbd3'..'\ufd3d' - | '\ufd50'..'\ufd8f' - | '\ufd92'..'\ufdc7' - | '\ufdf0'..'\ufdfb' - | '\ufe70'..'\ufe74' - | '\ufe76'..'\ufefc' - | '\uff66'..'\uff6f' - | '\uff71'..'\uff9d' - | '\uffa0'..'\uffbe' - | '\uffc2'..'\uffc7' - | '\uffca'..'\uffcf' - | '\uffd2'..'\uffd7' - | '\uffda'..'\uffdc' - ; +fragment UnicodeClass_LO: + '\u00aa' ..'\u00ba' + | '\u01bb' ..'\u01c0' + | '\u01c1' ..'\u01c3' + | '\u0294' ..'\u05d0' + | '\u05d1' ..'\u05ea' + | '\u05f0' ..'\u05f2' + | '\u0620' ..'\u063f' + | '\u0641' ..'\u064a' + | '\u066e' ..'\u066f' + | '\u0671' ..'\u06d3' + | '\u06d5' ..'\u06ee' + | '\u06ef' ..'\u06fa' + | '\u06fb' ..'\u06fc' + | '\u06ff' ..'\u0710' + | '\u0712' ..'\u072f' + | '\u074d' ..'\u07a5' + | '\u07b1' ..'\u07ca' + | '\u07cb' ..'\u07ea' + | '\u0800' ..'\u0815' + | '\u0840' ..'\u0858' + | '\u08a0' ..'\u08b2' + | '\u0904' ..'\u0939' + | '\u093d' ..'\u0950' + | '\u0958' ..'\u0961' + | '\u0972' ..'\u0980' + | '\u0985' ..'\u098c' + | '\u098f' ..'\u0990' + | '\u0993' ..'\u09a8' + | '\u09aa' ..'\u09b0' + | '\u09b2' ..'\u09b6' + | '\u09b7' ..'\u09b9' + | '\u09bd' ..'\u09ce' + | '\u09dc' ..'\u09dd' + | '\u09df' ..'\u09e1' + | '\u09f0' ..'\u09f1' + | '\u0a05' ..'\u0a0a' + | '\u0a0f' ..'\u0a10' + | '\u0a13' ..'\u0a28' + | '\u0a2a' ..'\u0a30' + | '\u0a32' ..'\u0a33' + | '\u0a35' ..'\u0a36' + | '\u0a38' ..'\u0a39' + | '\u0a59' ..'\u0a5c' + | '\u0a5e' ..'\u0a72' + | '\u0a73' ..'\u0a74' + | '\u0a85' ..'\u0a8d' + | '\u0a8f' ..'\u0a91' + | '\u0a93' ..'\u0aa8' + | '\u0aaa' ..'\u0ab0' + | '\u0ab2' ..'\u0ab3' + | '\u0ab5' ..'\u0ab9' + | '\u0abd' ..'\u0ad0' + | '\u0ae0' ..'\u0ae1' + | '\u0b05' ..'\u0b0c' + | '\u0b0f' ..'\u0b10' + | '\u0b13' ..'\u0b28' + | '\u0b2a' ..'\u0b30' + | '\u0b32' ..'\u0b33' + | '\u0b35' ..'\u0b39' + | '\u0b3d' ..'\u0b5c' + | '\u0b5d' ..'\u0b5f' + | '\u0b60' ..'\u0b61' + | '\u0b71' ..'\u0b83' + | '\u0b85' ..'\u0b8a' + | '\u0b8e' ..'\u0b90' + | '\u0b92' ..'\u0b95' + | '\u0b99' ..'\u0b9a' + | '\u0b9c' ..'\u0b9e' + | '\u0b9f' ..'\u0ba3' + | '\u0ba4' ..'\u0ba8' + | '\u0ba9' ..'\u0baa' + | '\u0bae' ..'\u0bb9' + | '\u0bd0' ..'\u0c05' + | '\u0c06' ..'\u0c0c' + | '\u0c0e' ..'\u0c10' + | '\u0c12' ..'\u0c28' + | '\u0c2a' ..'\u0c39' + | '\u0c3d' ..'\u0c58' + | '\u0c59' ..'\u0c60' + | '\u0c61' ..'\u0c85' + | '\u0c86' ..'\u0c8c' + | '\u0c8e' ..'\u0c90' + | '\u0c92' ..'\u0ca8' + | '\u0caa' ..'\u0cb3' + | '\u0cb5' ..'\u0cb9' + | '\u0cbd' ..'\u0cde' + | '\u0ce0' ..'\u0ce1' + | '\u0cf1' ..'\u0cf2' + | '\u0d05' ..'\u0d0c' + | '\u0d0e' ..'\u0d10' + | '\u0d12' ..'\u0d3a' + | '\u0d3d' ..'\u0d4e' + | '\u0d60' ..'\u0d61' + | '\u0d7a' ..'\u0d7f' + | '\u0d85' ..'\u0d96' + | '\u0d9a' ..'\u0db1' + | '\u0db3' ..'\u0dbb' + | '\u0dbd' ..'\u0dc0' + | '\u0dc1' ..'\u0dc6' + | '\u0e01' ..'\u0e30' + | '\u0e32' ..'\u0e33' + | '\u0e40' ..'\u0e45' + | '\u0e81' ..'\u0e82' + | '\u0e84' ..'\u0e87' + | '\u0e88' ..'\u0e8a' + | '\u0e8d' ..'\u0e94' + | '\u0e95' ..'\u0e97' + | '\u0e99' ..'\u0e9f' + | '\u0ea1' ..'\u0ea3' + | '\u0ea5' ..'\u0ea7' + | '\u0eaa' ..'\u0eab' + | '\u0ead' ..'\u0eb0' + | '\u0eb2' ..'\u0eb3' + | '\u0ebd' ..'\u0ec0' + | '\u0ec1' ..'\u0ec4' + | '\u0edc' ..'\u0edf' + | '\u0f00' ..'\u0f40' + | '\u0f41' ..'\u0f47' + | '\u0f49' ..'\u0f6c' + | '\u0f88' ..'\u0f8c' + | '\u1000' ..'\u102a' + | '\u103f' ..'\u1050' + | '\u1051' ..'\u1055' + | '\u105a' ..'\u105d' + | '\u1061' ..'\u1065' + | '\u1066' ..'\u106e' + | '\u106f' ..'\u1070' + | '\u1075' ..'\u1081' + | '\u108e' ..'\u10d0' + | '\u10d1' ..'\u10fa' + | '\u10fd' ..'\u1248' + | '\u124a' ..'\u124d' + | '\u1250' ..'\u1256' + | '\u1258' ..'\u125a' + | '\u125b' ..'\u125d' + | '\u1260' ..'\u1288' + | '\u128a' ..'\u128d' + | '\u1290' ..'\u12b0' + | '\u12b2' ..'\u12b5' + | '\u12b8' ..'\u12be' + | '\u12c0' ..'\u12c2' + | '\u12c3' ..'\u12c5' + | '\u12c8' ..'\u12d6' + | '\u12d8' ..'\u1310' + | '\u1312' ..'\u1315' + | '\u1318' ..'\u135a' + | '\u1380' ..'\u138f' + | '\u13a0' ..'\u13f4' + | '\u1401' ..'\u166c' + | '\u166f' ..'\u167f' + | '\u1681' ..'\u169a' + | '\u16a0' ..'\u16ea' + | '\u16f1' ..'\u16f8' + | '\u1700' ..'\u170c' + | '\u170e' ..'\u1711' + | '\u1720' ..'\u1731' + | '\u1740' ..'\u1751' + | '\u1760' ..'\u176c' + | '\u176e' ..'\u1770' + | '\u1780' ..'\u17b3' + | '\u17dc' ..'\u1820' + | '\u1821' ..'\u1842' + | '\u1844' ..'\u1877' + | '\u1880' ..'\u18a8' + | '\u18aa' ..'\u18b0' + | '\u18b1' ..'\u18f5' + | '\u1900' ..'\u191e' + | '\u1950' ..'\u196d' + | '\u1970' ..'\u1974' + | '\u1980' ..'\u19ab' + | '\u19c1' ..'\u19c7' + | '\u1a00' ..'\u1a16' + | '\u1a20' ..'\u1a54' + | '\u1b05' ..'\u1b33' + | '\u1b45' ..'\u1b4b' + | '\u1b83' ..'\u1ba0' + | '\u1bae' ..'\u1baf' + | '\u1bba' ..'\u1be5' + | '\u1c00' ..'\u1c23' + | '\u1c4d' ..'\u1c4f' + | '\u1c5a' ..'\u1c77' + | '\u1ce9' ..'\u1cec' + | '\u1cee' ..'\u1cf1' + | '\u1cf5' ..'\u1cf6' + | '\u2135' ..'\u2138' + | '\u2d30' ..'\u2d67' + | '\u2d80' ..'\u2d96' + | '\u2da0' ..'\u2da6' + | '\u2da8' ..'\u2dae' + | '\u2db0' ..'\u2db6' + | '\u2db8' ..'\u2dbe' + | '\u2dc0' ..'\u2dc6' + | '\u2dc8' ..'\u2dce' + | '\u2dd0' ..'\u2dd6' + | '\u2dd8' ..'\u2dde' + | '\u3006' ..'\u303c' + | '\u3041' ..'\u3096' + | '\u309f' ..'\u30a1' + | '\u30a2' ..'\u30fa' + | '\u30ff' ..'\u3105' + | '\u3106' ..'\u312d' + | '\u3131' ..'\u318e' + | '\u31a0' ..'\u31ba' + | '\u31f0' ..'\u31ff' + | '\u3400' ..'\u4db5' + | '\u4e00' ..'\u9fcc' + | '\ua000' ..'\ua014' + | '\ua016' ..'\ua48c' + | '\ua4d0' ..'\ua4f7' + | '\ua500' ..'\ua60b' + | '\ua610' ..'\ua61f' + | '\ua62a' ..'\ua62b' + | '\ua66e' ..'\ua6a0' + | '\ua6a1' ..'\ua6e5' + | '\ua7f7' ..'\ua7fb' + | '\ua7fc' ..'\ua801' + | '\ua803' ..'\ua805' + | '\ua807' ..'\ua80a' + | '\ua80c' ..'\ua822' + | '\ua840' ..'\ua873' + | '\ua882' ..'\ua8b3' + | '\ua8f2' ..'\ua8f7' + | '\ua8fb' ..'\ua90a' + | '\ua90b' ..'\ua925' + | '\ua930' ..'\ua946' + | '\ua960' ..'\ua97c' + | '\ua984' ..'\ua9b2' + | '\ua9e0' ..'\ua9e4' + | '\ua9e7' ..'\ua9ef' + | '\ua9fa' ..'\ua9fe' + | '\uaa00' ..'\uaa28' + | '\uaa40' ..'\uaa42' + | '\uaa44' ..'\uaa4b' + | '\uaa60' ..'\uaa6f' + | '\uaa71' ..'\uaa76' + | '\uaa7a' ..'\uaa7e' + | '\uaa7f' ..'\uaaaf' + | '\uaab1' ..'\uaab5' + | '\uaab6' ..'\uaab9' + | '\uaaba' ..'\uaabd' + | '\uaac0' ..'\uaac2' + | '\uaadb' ..'\uaadc' + | '\uaae0' ..'\uaaea' + | '\uaaf2' ..'\uab01' + | '\uab02' ..'\uab06' + | '\uab09' ..'\uab0e' + | '\uab11' ..'\uab16' + | '\uab20' ..'\uab26' + | '\uab28' ..'\uab2e' + | '\uabc0' ..'\uabe2' + | '\uac00' ..'\ud7a3' + | '\ud7b0' ..'\ud7c6' + | '\ud7cb' ..'\ud7fb' + | '\uf900' ..'\ufa6d' + | '\ufa70' ..'\ufad9' + | '\ufb1d' ..'\ufb1f' + | '\ufb20' ..'\ufb28' + | '\ufb2a' ..'\ufb36' + | '\ufb38' ..'\ufb3c' + | '\ufb3e' ..'\ufb40' + | '\ufb41' ..'\ufb43' + | '\ufb44' ..'\ufb46' + | '\ufb47' ..'\ufbb1' + | '\ufbd3' ..'\ufd3d' + | '\ufd50' ..'\ufd8f' + | '\ufd92' ..'\ufdc7' + | '\ufdf0' ..'\ufdfb' + | '\ufe70' ..'\ufe74' + | '\ufe76' ..'\ufefc' + | '\uff66' ..'\uff6f' + | '\uff71' ..'\uff9d' + | '\uffa0' ..'\uffbe' + | '\uffc2' ..'\uffc7' + | '\uffca' ..'\uffcf' + | '\uffd2' ..'\uffd7' + | '\uffda' ..'\uffdc' +; -fragment UnicodeDigit // UnicodeClass_ND - : '\u0030'..'\u0039' - | '\u0660'..'\u0669' - | '\u06f0'..'\u06f9' - | '\u07c0'..'\u07c9' - | '\u0966'..'\u096f' - | '\u09e6'..'\u09ef' - | '\u0a66'..'\u0a6f' - | '\u0ae6'..'\u0aef' - | '\u0b66'..'\u0b6f' - | '\u0be6'..'\u0bef' - | '\u0c66'..'\u0c6f' - | '\u0ce6'..'\u0cef' - | '\u0d66'..'\u0d6f' - | '\u0de6'..'\u0def' - | '\u0e50'..'\u0e59' - | '\u0ed0'..'\u0ed9' - | '\u0f20'..'\u0f29' - | '\u1040'..'\u1049' - | '\u1090'..'\u1099' - | '\u17e0'..'\u17e9' - | '\u1810'..'\u1819' - | '\u1946'..'\u194f' - | '\u19d0'..'\u19d9' - | '\u1a80'..'\u1a89' - | '\u1a90'..'\u1a99' - | '\u1b50'..'\u1b59' - | '\u1bb0'..'\u1bb9' - | '\u1c40'..'\u1c49' - | '\u1c50'..'\u1c59' - | '\ua620'..'\ua629' - | '\ua8d0'..'\ua8d9' - | '\ua900'..'\ua909' - | '\ua9d0'..'\ua9d9' - | '\ua9f0'..'\ua9f9' - | '\uaa50'..'\uaa59' - | '\uabf0'..'\uabf9' - | '\uff10'..'\uff19' - ; - \ No newline at end of file +fragment UnicodeDigit: // UnicodeClass_ND + '\u0030' ..'\u0039' + | '\u0660' ..'\u0669' + | '\u06f0' ..'\u06f9' + | '\u07c0' ..'\u07c9' + | '\u0966' ..'\u096f' + | '\u09e6' ..'\u09ef' + | '\u0a66' ..'\u0a6f' + | '\u0ae6' ..'\u0aef' + | '\u0b66' ..'\u0b6f' + | '\u0be6' ..'\u0bef' + | '\u0c66' ..'\u0c6f' + | '\u0ce6' ..'\u0cef' + | '\u0d66' ..'\u0d6f' + | '\u0de6' ..'\u0def' + | '\u0e50' ..'\u0e59' + | '\u0ed0' ..'\u0ed9' + | '\u0f20' ..'\u0f29' + | '\u1040' ..'\u1049' + | '\u1090' ..'\u1099' + | '\u17e0' ..'\u17e9' + | '\u1810' ..'\u1819' + | '\u1946' ..'\u194f' + | '\u19d0' ..'\u19d9' + | '\u1a80' ..'\u1a89' + | '\u1a90' ..'\u1a99' + | '\u1b50' ..'\u1b59' + | '\u1bb0' ..'\u1bb9' + | '\u1c40' ..'\u1c49' + | '\u1c50' ..'\u1c59' + | '\ua620' ..'\ua629' + | '\ua8d0' ..'\ua8d9' + | '\ua900' ..'\ua909' + | '\ua9d0' ..'\ua9d9' + | '\ua9f0' ..'\ua9f9' + | '\uaa50' ..'\uaa59' + | '\uabf0' ..'\uabf9' + | '\uff10' ..'\uff19' +; \ No newline at end of file diff --git a/stringtemplate/STGLexer.g4 b/stringtemplate/STGLexer.g4 index 892be043eb..934f81c55a 100644 --- a/stringtemplate/STGLexer.g4 +++ b/stringtemplate/STGLexer.g4 @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /** +/** * A grammar for StringTemplate v4 implemented using Antlr v4 syntax * * Modified 2015.06.16 gbr @@ -35,85 +35,87 @@ * -- use imported standard fragments */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar STGLexer; -import LexBasic; // Standard set of fragments +import LexBasic; +// Standard set of fragments channels { - OFF_CHANNEL // non-default channel for whitespace and comments + OFF_CHANNEL // non-default channel for whitespace and comments } // ------------------------------------------------------------------------------ // mode default -DOC_COMMENT : DocComment -> channel(OFF_CHANNEL) ; -BLOCK_COMMENT : BlockComment -> channel(OFF_CHANNEL) ; -LINE_COMMENT : LineComment -> channel(OFF_CHANNEL) ; - -TMPL_COMMENT : LBang .? RBang -> channel(OFF_CHANNEL) ; +DOC_COMMENT : DocComment -> channel(OFF_CHANNEL); +BLOCK_COMMENT : BlockComment -> channel(OFF_CHANNEL); +LINE_COMMENT : LineComment -> channel(OFF_CHANNEL); -HORZ_WS : Hws+ -> channel(OFF_CHANNEL) ; -VERT_WS : Vws+ -> channel(OFF_CHANNEL) ; +TMPL_COMMENT: LBang .? RBang -> channel(OFF_CHANNEL); -ID : NameStartChar NameChar* ; +HORZ_WS : Hws+ -> channel(OFF_CHANNEL); +VERT_WS : Vws+ -> channel(OFF_CHANNEL); -STRING : DQuoteLiteral ; -BIGSTRING : LDAngle .*? RDAngle ; -BIGSTRING_NO_NL : LPct .*? RPct ; -ANON_TEMPLATE : LBrace .*? RBrace ; +ID: NameStartChar NameChar*; +STRING : DQuoteLiteral; +BIGSTRING : LDAngle .*? RDAngle; +BIGSTRING_NO_NL : LPct .*? RPct; +ANON_TEMPLATE : LBrace .*? RBrace; // ----------------------------------- // Symbols -TMPL_ASSIGN : TmplAssign ; -ASSIGN : Equal ; - -DOT : Dot ; -COMMA : Comma ; -COLON : Colon ; -LPAREN : LParen ; -RPAREN : RParen ; -LBRACK : LBrack ; -RBRACK : RBrack ; -AT : At ; -TRUE : True_ ; -FALSE : False_ ; -ELLIPSIS : Ellipsis ; +TMPL_ASSIGN : TmplAssign; +ASSIGN : Equal; + +DOT : Dot; +COMMA : Comma; +COLON : Colon; +LPAREN : LParen; +RPAREN : RParen; +LBRACK : LBrack; +RBRACK : RBrack; +AT : At; +TRUE : True_; +FALSE : False_; +ELLIPSIS : Ellipsis; // ----------------------------------- // Key words -DELIMITERS : 'delimiters' ; -IMPORT : 'import' ; -DEFAULT : 'default' ; -KEY : 'key' ; -VALUE : 'value' ; - -FIRST : 'first' ; -LAST : 'last' ; -REST : 'rest' ; -TRUNC : 'trunc' ; -STRIP : 'strip' ; -TRIM : 'trim' ; -LENGTH : 'length' ; -STRLEN : 'strlen' ; -REVERSE : 'reverse' ; - -GROUP : 'group' ; // not used by parser? -WRAP : 'wrap' ; -ANCHOR : 'anchor' ; -SEPARATOR : 'separator' ; - +DELIMITERS : 'delimiters'; +IMPORT : 'import'; +DEFAULT : 'default'; +KEY : 'key'; +VALUE : 'value'; + +FIRST : 'first'; +LAST : 'last'; +REST : 'rest'; +TRUNC : 'trunc'; +STRIP : 'strip'; +TRIM : 'trim'; +LENGTH : 'length'; +STRLEN : 'strlen'; +REVERSE : 'reverse'; + +GROUP : 'group'; // not used by parser? +WRAP : 'wrap'; +ANCHOR : 'anchor'; +SEPARATOR : 'separator'; // ----------------------------------- // Grammar specific fragments -fragment TmplAssign : '::=' ; -fragment LBang : '' ; -fragment LPct : '<%' ; -fragment RPct : '%>' ; -fragment LDAngle : LShift ; -fragment RDAngle : RShift ; - +fragment TmplAssign : '::='; +fragment LBang : ''; +fragment LPct : '<%'; +fragment RPct : '%>'; +fragment LDAngle : LShift; +fragment RDAngle : RShift; \ No newline at end of file diff --git a/stringtemplate/STGParser.g4 b/stringtemplate/STGParser.g4 index 122f7abf82..f11c866f0b 100644 --- a/stringtemplate/STGParser.g4 +++ b/stringtemplate/STGParser.g4 @@ -34,72 +34,69 @@ * -- updated to use imported standard fragments */ +// $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 STGParser; options { - language=Java; - tokenVocab=STGLexer; + language = Java; + tokenVocab = STGLexer; } group - : delimiters? imports? - ( template_ | dict_ )+ - EOF - ; + : delimiters? imports? (template_ | dict_)+ EOF + ; delimiters - : DELIMITERS STRING COMMA STRING - ; + : DELIMITERS STRING COMMA STRING + ; imports - : ( IMPORT STRING )+ - ; + : (IMPORT STRING)+ + ; template_ - : ( AT ID DOT ID LPAREN RPAREN - | ID LPAREN formalArgs? RPAREN - ) - TMPL_ASSIGN - ( STRING // "..." - | BIGSTRING // <<...>> - | BIGSTRING_NO_NL // <%...%> - ) - | ID TMPL_ASSIGN ID // alias one template to another - ; + : (AT ID DOT ID LPAREN RPAREN | ID LPAREN formalArgs? RPAREN) TMPL_ASSIGN ( + STRING // "..." + | BIGSTRING // <<...>> + | BIGSTRING_NO_NL // <%...%> + ) + | ID TMPL_ASSIGN ID // alias one template to another + ; formalArgs - : formalArg ( COMMA formalArg )* - ; + : formalArg (COMMA formalArg)* + ; formalArg - : ID ( ASSIGN STRING - | ASSIGN ANON_TEMPLATE - | ASSIGN TRUE - | ASSIGN FALSE - | ASSIGN LBRACK RBRACK - )? - ; + : ID (ASSIGN STRING | ASSIGN ANON_TEMPLATE | ASSIGN TRUE | ASSIGN FALSE | ASSIGN LBRACK RBRACK)? + ; dict_ - : ID TMPL_ASSIGN LBRACK dictPairs RBRACK - ; + : ID TMPL_ASSIGN LBRACK dictPairs RBRACK + ; dictPairs - : keyValuePair ( COMMA keyValuePair )* ( COMMA defaultValuePair )? - | defaultValuePair - ; + : keyValuePair (COMMA keyValuePair)* (COMMA defaultValuePair)? + | defaultValuePair + ; -keyValuePair : STRING COLON keyValue ; -defaultValuePair : DEFAULT COLON keyValue ; +keyValuePair + : STRING COLON keyValue + ; -keyValue - : BIGSTRING - | BIGSTRING_NO_NL - | ANON_TEMPLATE - | STRING - | TRUE - | FALSE - | LBRACK RBRACK - | KEY - ; +defaultValuePair + : DEFAULT COLON keyValue + ; +keyValue + : BIGSTRING + | BIGSTRING_NO_NL + | ANON_TEMPLATE + | STRING + | TRUE + | FALSE + | LBRACK RBRACK + | KEY + ; \ No newline at end of file diff --git a/stringtemplate/STLexer.g4 b/stringtemplate/STLexer.g4 index 19a082fc25..f750adb866 100644 --- a/stringtemplate/STLexer.g4 +++ b/stringtemplate/STLexer.g4 @@ -33,97 +33,96 @@ * -- use imported standard fragments */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar STLexer; options { - superClass = LexerAdaptor ; + superClass = LexerAdaptor; } -import LexBasic; // Standard set of fragments +import LexBasic; +// Standard set of fragments channels { - OFF_CHANNEL // non-default channel for whitespace and comments + OFF_CHANNEL // non-default channel for whitespace and comments } // ----------------------------------- // default mode = Outside +DOC_COMMENT : DocComment -> channel(OFF_CHANNEL); +BLOCK_COMMENT : BlockComment -> channel(OFF_CHANNEL); +LINE_COMMENT : LineComment -> channel(OFF_CHANNEL); -DOC_COMMENT : DocComment -> channel(OFF_CHANNEL) ; -BLOCK_COMMENT : BlockComment -> channel(OFF_CHANNEL) ; -LINE_COMMENT : LineComment -> channel(OFF_CHANNEL) ; - -TMPL_COMMENT : TmplComment -> channel(OFF_CHANNEL) ; +TMPL_COMMENT: TmplComment -> channel(OFF_CHANNEL); -HORZ_WS : Hws+ -> channel(OFF_CHANNEL) ; -VERT_WS : Vws+ -> channel(OFF_CHANNEL) ; +HORZ_WS : Hws+ -> channel(OFF_CHANNEL); +VERT_WS : Vws+ -> channel(OFF_CHANNEL); -ESCAPE : . { isLDelim() }? EscSeq . { isRDelim() }? ; // self contained -LDELIM : . { isLDelim() }? -> mode(Inside) ; // switch mode to inside -RBRACE : RBrace { endsSubTemplate(); } ; // conditional switch to inside - -TEXT : . { adjText(); } ; // have to handle weird terminals +ESCAPE : . { isLDelim() }? EscSeq . { isRDelim() }?; // self contained +LDELIM : . { isLDelim() }? -> mode(Inside); // switch mode to inside +RBRACE : RBrace { endsSubTemplate(); }; // conditional switch to inside +TEXT: . { adjText(); }; // have to handle weird terminals // ----------------------------------- -mode Inside ; - -INS_HORZ_WS : Hws+ -> type(HORZ_WS), channel(OFF_CHANNEL) ; -INS_VERT_WS : Vws+ -> type(VERT_WS), channel(OFF_CHANNEL) ; - -LBRACE : LBrace { startsSubTemplate() }? -> mode(SubTemplate) ; -RDELIM : . { isRDelim() }? -> mode(DEFAULT_MODE) ; - -STRING : DQuoteLiteral ; - -IF : 'if' ; -ELSEIF : 'elseif' ; -ELSE : 'else' ; -ENDIF : 'endif' ; -SUPER : 'super' ; -END : '@end' ; - -TRUE : True_ ; -FALSE : False_ ; - -AT : At ; -ELLIPSIS : Ellipsis ; -DOT : Dot ; -COMMA : Comma ; -COLON : Colon ; -SEMI : Semi ; -AND : And ; -OR : Or ; -LPAREN : LParen ; -RPAREN : RParen ; -LBRACK : LBrack ; -RBRACK : RBrack ; -EQUALS : Equal ; -BANG : Bang ; - +mode Inside; + +INS_HORZ_WS : Hws+ -> type(HORZ_WS), channel(OFF_CHANNEL); +INS_VERT_WS : Vws+ -> type(VERT_WS), channel(OFF_CHANNEL); + +LBRACE : LBrace { startsSubTemplate() }? -> mode(SubTemplate); +RDELIM : . { isRDelim() }? -> mode(DEFAULT_MODE); + +STRING: DQuoteLiteral; + +IF : 'if'; +ELSEIF : 'elseif'; +ELSE : 'else'; +ENDIF : 'endif'; +SUPER : 'super'; +END : '@end'; + +TRUE : True_; +FALSE : False_; + +AT : At; +ELLIPSIS : Ellipsis; +DOT : Dot; +COMMA : Comma; +COLON : Colon; +SEMI : Semi; +AND : And; +OR : Or; +LPAREN : LParen; +RPAREN : RParen; +LBRACK : LBrack; +RBRACK : RBrack; +EQUALS : Equal; +BANG : Bang; // ----------------------------------- // Unknown content in mode Inside -ERR_CHAR : . -> skip ; - +ERR_CHAR: . -> skip; // ----------------------------------- -mode SubTemplate ; - -SUB_HORZ_WS : Hws+ -> type(HORZ_WS), channel(OFF_CHANNEL) ; -SUB_VERT_WS : Vws+ -> type(VERT_WS), channel(OFF_CHANNEL) ; +mode SubTemplate; -ID : NameStartChar NameChar* ; -SUB_COMMA : Comma -> type(COMMA) ; -PIPE : Pipe -> mode(DEFAULT_MODE) ; +SUB_HORZ_WS : Hws+ -> type(HORZ_WS), channel(OFF_CHANNEL); +SUB_VERT_WS : Vws+ -> type(VERT_WS), channel(OFF_CHANNEL); +ID : NameStartChar NameChar*; +SUB_COMMA : Comma -> type(COMMA); +PIPE : Pipe -> mode(DEFAULT_MODE); // ----------------------------------- // Grammar specific fragments -fragment TmplComment : LTmplMark .*? RTmplMark ; - -fragment LTmplMark : . { isLTmplComment() }? Bang ; -fragment RTmplMark : Bang . { isRTmplComment() }? ; +fragment TmplComment: LTmplMark .*? RTmplMark; +fragment LTmplMark : . { isLTmplComment() }? Bang; +fragment RTmplMark : Bang . { isRTmplComment() }?; \ No newline at end of file diff --git a/stringtemplate/STParser.g4 b/stringtemplate/STParser.g4 index c6feda1939..b94abe89bc 100644 --- a/stringtemplate/STParser.g4 +++ b/stringtemplate/STParser.g4 @@ -32,147 +32,141 @@ * -- use imported standard fragments */ +// $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 STParser; options { - language=Java; - tokenVocab=STLexer; + language = Java; + tokenVocab = STLexer; } template_ - : elements EOF - ; + : elements EOF + ; elements - : element* - ; + : element* + ; element - : singleElement - | compoundElement - ; + : singleElement + | compoundElement + ; singleElement - : exprTag - | TEXT+ - ; + : exprTag + | TEXT+ + ; compoundElement - : ifstat - | region - ; + : ifstat + | region + ; exprTag - : LDELIM mapExpr ( SEMI exprOptions )? RDELIM - ; + : LDELIM mapExpr (SEMI exprOptions)? RDELIM + ; region - : LDELIM AT ID RDELIM - elements - LDELIM END RDELIM - ; + : LDELIM AT ID RDELIM elements LDELIM END RDELIM + ; subtemplate - : LBRACE ( ID ( COMMA ID )* PIPE )? elements RBRACE - ; + : LBRACE (ID ( COMMA ID)* PIPE)? elements RBRACE + ; ifstat - : LDELIM IF LPAREN conditional RPAREN RDELIM - elements - ( LDELIM ELSEIF LPAREN conditional RPAREN RDELIM elements )* - ( LDELIM ELSE RDELIM elements )? - LDELIM ENDIF RDELIM - ; + : LDELIM IF LPAREN conditional RPAREN RDELIM elements ( + LDELIM ELSEIF LPAREN conditional RPAREN RDELIM elements + )* (LDELIM ELSE RDELIM elements)? LDELIM ENDIF RDELIM + ; conditional - : andConditional ( OR andConditional )* - ; + : andConditional (OR andConditional)* + ; andConditional - : notConditional ( AND notConditional )* - ; + : notConditional (AND notConditional)* + ; notConditional - : BANG notConditional - | memberExpr - ; + : BANG notConditional + | memberExpr + ; notConditionalExpr - : ID ( DOT ID - | DOT LPAREN mapExpr RPAREN - )* - ; + : ID (DOT ID | DOT LPAREN mapExpr RPAREN)* + ; exprOptions - : option ( COMMA option )* - ; + : option (COMMA option)* + ; option - : ID ( EQUALS expr )? - ; + : ID (EQUALS expr)? + ; expr - : memberExpr ( COLON mapTemplateRef )? - ; + : memberExpr (COLON mapTemplateRef)? + ; // more complicated than necessary to avoid backtracking, // which ruins error handling mapExpr - : memberExpr ( ( COMMA memberExpr )+ COLON mapTemplateRef )? - ( COLON mapTemplateRef ( COMMA mapTemplateRef )* )* - ; + : memberExpr (( COMMA memberExpr)+ COLON mapTemplateRef)? ( + COLON mapTemplateRef ( COMMA mapTemplateRef)* + )* + ; memberExpr - : includeExpr - ( DOT ID - | DOT LPAREN mapExpr RPAREN - )* - ; + : includeExpr (DOT ID | DOT LPAREN mapExpr RPAREN)* + ; // expr:template(args) apply template to expr // expr:{arg | ...} apply subtemplate to expr // expr:(e)(args) convert e to a string template name and apply to expr mapTemplateRef - : ID LPAREN args? RPAREN - | subtemplate - | LPAREN mapExpr RPAREN LPAREN argExprList? RPAREN - ; + : ID LPAREN args? RPAREN + | subtemplate + | LPAREN mapExpr RPAREN LPAREN argExprList? RPAREN + ; includeExpr - : ID LPAREN mapExpr? RPAREN - | SUPER DOT ID LPAREN args? RPAREN - | ID LPAREN args? RPAREN - | AT SUPER DOT ID LPAREN RPAREN - | AT ID LPAREN RPAREN - | primary - ; + : ID LPAREN mapExpr? RPAREN + | SUPER DOT ID LPAREN args? RPAREN + | ID LPAREN args? RPAREN + | AT SUPER DOT ID LPAREN RPAREN + | AT ID LPAREN RPAREN + | primary + ; primary - : ID - | STRING - | TRUE - | FALSE - | subtemplate - | list_ - | LPAREN conditional RPAREN - | LPAREN mapExpr RPAREN ( LPAREN argExprList? RPAREN )? - ; + : ID + | STRING + | TRUE + | FALSE + | subtemplate + | list_ + | LPAREN conditional RPAREN + | LPAREN mapExpr RPAREN ( LPAREN argExprList? RPAREN)? + ; list_ - : LBRACK argExprList? RBRACK - ; + : LBRACK argExprList? RBRACK + ; args - : argExprList - | namedArg ( COMMA namedArg )* ( COMMA ELLIPSIS )? - | ELLIPSIS - ; + : argExprList + | namedArg ( COMMA namedArg)* ( COMMA ELLIPSIS)? + | ELLIPSIS + ; argExprList - : expr ( COMMA expr )* - ; + : expr (COMMA expr)* + ; namedArg - : ID EQUALS expr - ; - + : ID EQUALS expr + ; \ No newline at end of file diff --git a/suokif/SUOKIF.g4 b/suokif/SUOKIF.g4 index a503ac2cd3..a5fe208473 100644 --- a/suokif/SUOKIF.g4 +++ b/suokif/SUOKIF.g4 @@ -1,4 +1,3 @@ - /* [The "BSD licence"] Copyright (c) 2014 Adam Taylor @@ -29,155 +28,158 @@ /* Derived from http://sigmakee.cvs.sourceforge.net/viewvc/sigmakee/sigma/suo-kif.pdf */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar SUOKIF; top_level - : sentence* EOF - ; + : sentence* EOF + ; term - : VARIABLE | WORD | STRING | funterm | NUMBER | sentence - ; + : VARIABLE + | WORD + | STRING + | funterm + | NUMBER + | sentence + ; argument - : sentence | term - ; + : sentence + | term + ; funterm - : '(' WORD argument+ ')' - ; + : '(' WORD argument+ ')' + ; sentence - : WORD | equation | relsent | logsent | quantsent | VARIABLE - ; + : WORD + | equation + | relsent + | logsent + | quantsent + | VARIABLE + ; equation - : '(' '=' term term ')' - ; + : '(' '=' term term ')' + ; relsent - : '(' ( WORD | VARIABLE ) argument+ ')' - ; + : '(' (WORD | VARIABLE) argument+ ')' + ; logsent - : '(' NOT sentence ')' | '(' AND sentence+ ')' | '(' OR sentence+ ')' | '(' '=' '>' sentence sentence ')' | '(' '<' '=' '>' sentence sentence ')' - ; + : '(' NOT sentence ')' + | '(' AND sentence+ ')' + | '(' OR sentence+ ')' + | '(' '=' '>' sentence sentence ')' + | '(' '<' '=' '>' sentence sentence ')' + ; quantsent - : '(' FORALL '(' VARIABLE+ ')' sentence ')' | '(' EXISTS '(' VARIABLE+ ')' sentence ')' - ; - + : '(' FORALL '(' VARIABLE+ ')' sentence ')' + | '(' EXISTS '(' VARIABLE+ ')' sentence ')' + ; NOT - : 'not' - ; - + : 'not' + ; AND - : 'and' - ; - + : 'and' + ; OR - : 'or' - ; - + : 'or' + ; FORALL - : 'forall' - ; - + : 'forall' + ; EXISTS - : 'exists' - ; - + : 'exists' + ; fragment UPPER - : [A-Z] - ; - + : [A-Z] + ; fragment LOWER - : [a-z] - ; - + : [a-z] + ; fragment DIGIT - : [0-9] - ; - + : [0-9] + ; fragment INITIALCHAR - : UPPER | LOWER - ; - + : UPPER + | LOWER + ; fragment WORDCHAR - : UPPER | LOWER | DIGIT | '-' | '_' - ; - + : UPPER + | LOWER + | DIGIT + | '-' + | '_' + ; WORD - : INITIALCHAR WORDCHAR* - ; - + : INITIALCHAR WORDCHAR* + ; STRING - : '"' ~ ["\\]* '"' - ; - + : '"' ~ ["\\]* '"' + ; VARIABLE - : '?' WORD | '@' WORD - ; - + : '?' WORD + | '@' WORD + ; NUMBER - : '-'? DIGIT+ ( '.' DIGIT+ )? EXPONENT? - ; - + : '-'? DIGIT+ ('.' DIGIT+)? EXPONENT? + ; fragment EXPONENT - : 'e' '-'? DIGIT+ - ; - + : 'e' '-'? DIGIT+ + ; WHITE - : [ \t\n\r\u000B] -> skip - ; - + : [ \t\n\r\u000B] -> skip + ; COMMENT - : ';' ~ [\r\n]* -> skip - ; - + : ';' ~ [\r\n]* -> skip + ; LPAREN - : '(' - ; - + : '(' + ; RPAREN - : ')' - ; - + : ')' + ; ASSIGN - : '=' - ; - + : '=' + ; GT - : '>' - ; - + : '>' + ; LT - : '<' - ; - + : '<' + ; QUESTION - : '?' - ; + : '?' + ; \ No newline at end of file diff --git a/swift-fin/SwiftFinLexer.g4 b/swift-fin/SwiftFinLexer.g4 index fca2d9b647..6e3ee787ec 100644 --- a/swift-fin/SwiftFinLexer.g4 +++ b/swift-fin/SwiftFinLexer.g4 @@ -21,60 +21,55 @@ 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. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar SwiftFinLexer; -BLOCK1 : LBrace '1' Colon -> pushMode(InsideValue) - ; +BLOCK1: LBrace '1' Colon -> pushMode(InsideValue); -BLOCK2 : LBrace '2' Colon -> pushMode(InsideValue) - ; +BLOCK2: LBrace '2' Colon -> pushMode(InsideValue); -BLOCK3 : LBrace '3' Colon -> pushMode(InsideMaps) - ; +BLOCK3: LBrace '3' Colon -> pushMode(InsideMaps); -fragment -Block4 : LBrace '4' Colon - ; +fragment Block4: LBrace '4' Colon; -BLOCK4_A : Block4 Crlf -> pushMode(InsideB4) - ; +BLOCK4_A: Block4 Crlf -> pushMode(InsideB4); -BLOCK4_B : Block4 -> pushMode(InsideMaps) - ; +BLOCK4_B: Block4 -> pushMode(InsideMaps); -BLOCK5 : LBrace '5' Colon -> pushMode(InsideMaps) - ; +BLOCK5: LBrace '5' Colon -> pushMode(InsideMaps); LBRACE : LBrace; RBRACE : RBrace; COLON : Colon; CRLF : Crlf; -fragment -Crlf : '\r'? '\n' - ; +fragment Crlf: '\r'? '\n'; -fragment LBrace : '{' ; -fragment RBrace : '}' ; -fragment Colon : ':' ; -fragment Minus : '-' ; -fragment Any : . ; +fragment LBrace : '{'; +fragment RBrace : '}'; +fragment Colon : ':'; +fragment Minus : '-'; +fragment Any : .; mode InsideMaps; M_LBRACE : LBrace -> type(LBRACE), pushMode(InsideMaps); M_RBRACE : RBrace -> type(RBRACE), popMode; -M_COLON : Colon ; -M_VALUE : ~[:] ; +M_COLON : Colon; +M_VALUE : ~[:]; mode InsideB4; -B4_END : Minus RBrace -> popMode; -B4_COLON : Colon ; -B4_CRLF : Crlf ; -B4_VALUE : ~[:] ; +B4_END : Minus RBrace -> popMode; +B4_COLON : Colon; +B4_CRLF : Crlf; +B4_VALUE : ~[:]; //SPECIALS : Any ; // every other token mode InsideValue; V_END : RBrace -> popMode; -V_VALUE : Any ; +V_VALUE : Any; \ No newline at end of file diff --git a/swift-fin/SwiftFinParser.g4 b/swift-fin/SwiftFinParser.g4 index 70ab9efb54..b88bdc4fda 100644 --- a/swift-fin/SwiftFinParser.g4 +++ b/swift-fin/SwiftFinParser.g4 @@ -21,56 +21,76 @@ 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. */ + +// $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 SwiftFinParser; options { - tokenVocab = SwiftFinLexer ; + tokenVocab = SwiftFinLexer; } -messages : message+ EOF - ; - -message : block1 block2? block3? block4? block5? - ; - -block1 : BLOCK1 value V_END - ; - -block2 : BLOCK2 value V_END - ; - -block3 : BLOCK3 map_ RBRACE - ; - -block4 : BLOCK4_A block4Item+ B4_END - | BLOCK4_B map_ RBRACE - ; - -block4Item : B4_COLON block4Field B4_COLON block4Line+ - ; - -block4Field : B4_VALUE+ - ; - -block4Line : B4_VALUE+ B4_CRLF - | B4_VALUE+ B4_COLON (B4_VALUE | B4_COLON)* B4_CRLF - | B4_COLON B4_COLON+ (B4_VALUE | B4_COLON)* B4_CRLF - | B4_COLON+ B4_VALUE+ B4_COLON* B4_CRLF - ; - -block5 : BLOCK5 map_ RBRACE - ; - -value : V_VALUE+ - ; - -map_ : keyValue+ ; - -keyValue : LBRACE mKey M_COLON mValue? RBRACE - ; - -mKey : M_VALUE+ - ; - -mValue : (M_VALUE | M_COLON)+ - ; +messages + : message+ EOF + ; + +message + : block1 block2? block3? block4? block5? + ; + +block1 + : BLOCK1 value V_END + ; + +block2 + : BLOCK2 value V_END + ; + +block3 + : BLOCK3 map_ RBRACE + ; + +block4 + : BLOCK4_A block4Item+ B4_END + | BLOCK4_B map_ RBRACE + ; + +block4Item + : B4_COLON block4Field B4_COLON block4Line+ + ; + +block4Field + : B4_VALUE+ + ; + +block4Line + : B4_VALUE+ B4_CRLF + | B4_VALUE+ B4_COLON (B4_VALUE | B4_COLON)* B4_CRLF + | B4_COLON B4_COLON+ (B4_VALUE | B4_COLON)* B4_CRLF + | B4_COLON+ B4_VALUE+ B4_COLON* B4_CRLF + ; + +block5 + : BLOCK5 map_ RBRACE + ; + +value + : V_VALUE+ + ; + +map_ + : keyValue+ + ; + +keyValue + : LBRACE mKey M_COLON mValue? RBRACE + ; + +mKey + : M_VALUE+ + ; + +mValue + : (M_VALUE | M_COLON)+ + ; \ No newline at end of file diff --git a/swift/swift2/Swift2.g4 b/swift/swift2/Swift2.g4 index cea8be7f6a..528cbf2a11 100644 --- a/swift/swift2/Swift2.g4 +++ b/swift/swift2/Swift2.g4 @@ -29,9 +29,17 @@ * Converted from Apple's doc, http://tinyurl.com/n8rkoue, to ANTLR's * meta-language. */ -grammar Swift2; // 2.2 -top_level : statement* EOF ; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar Swift2; + +// 2.2 + +top_level + : statement* EOF + ; // Statements @@ -39,18 +47,20 @@ top_level : statement* EOF ; statement // : assignment_statement ';'? - : expression ';'? - | declaration ';'? - | loop_statement ';'? - | branch_statement ';'? - | labeled_statement ';'? - | control_transfer_statement ';'? - | defer_statement ';'? - | do_statement ';'? - | compiler_control_statement - ; - -statements : statement+ ; + : expression ';'? + | declaration ';'? + | loop_statement ';'? + | branch_statement ';'? + | labeled_statement ';'? + | control_transfer_statement ';'? + | defer_statement ';'? + | do_statement ';'? + | compiler_control_statement + ; + +statements + : statement+ + ; /** A naked '=' op is not part of a valid expression so I'm making it a statement; * see comment on binary_expression. It also resolves ambiguity between @@ -62,220 +72,376 @@ assignment_statement // GRAMMAR OF A LOOP STATEMENT -loop_statement : for_statement - | for_in_statement - | while_statement - | repeat_while_statement - ; +loop_statement + : for_statement + | for_in_statement + | while_statement + | repeat_while_statement + ; // GRAMMAR OF A FOR STATEMENT for_statement - : 'for' for_init? ';' expression? ';' expression? code_block - | 'for' '(' for_init? ';' expression? ';' expression? ')' code_block - ; + : 'for' for_init? ';' expression? ';' expression? code_block + | 'for' '(' for_init? ';' expression? ';' expression? ')' code_block + ; -for_init : variable_declaration | expression_list ; +for_init + : variable_declaration + | expression_list + ; // GRAMMAR OF A FOR_IN STATEMENT -for_in_statement : 'for' 'case'? pattern 'in' expression where_clause? code_block ; +for_in_statement + : 'for' 'case'? pattern 'in' expression where_clause? code_block + ; // GRAMMAR OF A WHILE STATEMENT -while_statement : 'while' condition_clause code_block ; +while_statement + : 'while' condition_clause code_block + ; condition_clause - : expression - | expression ',' condition_list - | condition_list - | availability_condition ',' expression - ; + : expression + | expression ',' condition_list + | condition_list + | availability_condition ',' expression + ; + +condition_list + : condition (',' condition)* + ; -condition_list : condition (',' condition)* ; condition - : availability_condition - | case_condition - | optional_binding_condition - ; -case_condition : 'case' pattern initializer where_clause? ; + : availability_condition + | case_condition + | optional_binding_condition + ; + +case_condition + : 'case' pattern initializer where_clause? + ; + optional_binding_condition - : optional_binding_head optional_binding_continuation_list? where_clause? - ; -optional_binding_head : 'let' pattern initializer | 'var' pattern initializer ; + : optional_binding_head optional_binding_continuation_list? where_clause? + ; + +optional_binding_head + : 'let' pattern initializer + | 'var' pattern initializer + ; + optional_binding_continuation_list - : ',' optional_binding_continuation (',' optional_binding_continuation)* - ; -optional_binding_continuation - : pattern initializer - | optional_binding_head - ; + : ',' optional_binding_continuation (',' optional_binding_continuation)* + ; +optional_binding_continuation + : pattern initializer + | optional_binding_head + ; // GRAMMAR OF A REPEAT-WHILE STATEMENT -repeat_while_statement : 'repeat' code_block 'while' expression ; +repeat_while_statement + : 'repeat' code_block 'while' expression + ; // GRAMMAR OF A BRANCH STATEMENT -branch_statement : if_statement - | guard_statement - | switch_statement - ; +branch_statement + : if_statement + | guard_statement + | switch_statement + ; // GRAMMAR OF AN IF STATEMENT -if_statement : 'if' condition_clause code_block else_clause? ; -else_clause : 'else' code_block | 'else' if_statement ; +if_statement + : 'if' condition_clause code_block else_clause? + ; + +else_clause + : 'else' code_block + | 'else' if_statement + ; // GRAMMAR OF A GUARD STATEMENT -guard_statement : 'guard' condition_clause 'else' code_block ; +guard_statement + : 'guard' condition_clause 'else' code_block + ; // GRAMMAR OF A SWITCH STATEMENT -switch_statement : 'switch' expression '{' switch_cases? '}' ; -switch_cases : switch_case switch_cases? ; -switch_case : case_label statements | default_label statements ; -case_label : 'case' case_item_list ':' ; -case_item_list : pattern where_clause? | pattern where_clause? ',' case_item_list ; -default_label : 'default' ':' ; -where_clause : 'where' where_expression ; -where_expression : expression ; +switch_statement + : 'switch' expression '{' switch_cases? '}' + ; + +switch_cases + : switch_case switch_cases? + ; + +switch_case + : case_label statements + | default_label statements + ; + +case_label + : 'case' case_item_list ':' + ; + +case_item_list + : pattern where_clause? + | pattern where_clause? ',' case_item_list + ; + +default_label + : 'default' ':' + ; + +where_clause + : 'where' where_expression + ; + +where_expression + : expression + ; // GRAMMAR OF A LABELED STATEMENT -labeled_statement : statement_label loop_statement | statement_label if_statement | statement_label switch_statement ; -statement_label : label_name ':' ; -label_name : identifier ; +labeled_statement + : statement_label loop_statement + | statement_label if_statement + | statement_label switch_statement + ; + +statement_label + : label_name ':' + ; + +label_name + : identifier + ; // GRAMMAR OF A CONTROL TRANSFER STATEMENT -control_transfer_statement : break_statement - | continue_statement - | fallthrough_statement - | return_statement - | throw_statement - ; +control_transfer_statement + : break_statement + | continue_statement + | fallthrough_statement + | return_statement + | throw_statement + ; // GRAMMAR OF A BREAK STATEMENT -break_statement : 'break' label_name? ; +break_statement + : 'break' label_name? + ; // GRAMMAR OF A CONTINUE STATEMENT -continue_statement : 'continue' label_name? ; +continue_statement + : 'continue' label_name? + ; // GRAMMAR OF A FALLTHROUGH STATEMENT -fallthrough_statement : 'fallthrough' ; +fallthrough_statement + : 'fallthrough' + ; // GRAMMAR OF A RETURN STATEMENT -return_statement : 'return' expression? ; - +return_statement + : 'return' expression? + ; // GRAMMAR OF AN AVAILABILITY CONDITION -availability_condition : '#available' '(' availability_arguments ')' ; +availability_condition + : '#available' '(' availability_arguments ')' + ; -availability_arguments : availability_argument (',' availability_argument)* ; +availability_arguments + : availability_argument (',' availability_argument)* + ; -availability_argument : Platform | '*' ; +availability_argument + : Platform + | '*' + ; /** Must match as token so Platform_version doesn't look like a float literal */ -Platform : Platform_name WS? Platform_version ; - -fragment -Platform_name - : 'iOS' | 'iOSApplicationExtension' - | 'OSX' | 'OSXApplicationExtension' - | 'watchOS' - | 'tvOS' // ? - ; - -fragment -Platform_version - : Pure_decimal_digits - | Pure_decimal_digits '.' Pure_decimal_digits - | Pure_decimal_digits '.' Pure_decimal_digits '.' Pure_decimal_digits - ; +Platform + : Platform_name WS? Platform_version + ; + +fragment Platform_name + : 'iOS' + | 'iOSApplicationExtension' + | 'OSX' + | 'OSXApplicationExtension' + | 'watchOS' + | 'tvOS' // ? + ; + +fragment Platform_version + : Pure_decimal_digits + | Pure_decimal_digits '.' Pure_decimal_digits + | Pure_decimal_digits '.' Pure_decimal_digits '.' Pure_decimal_digits + ; // GRAMMAR OF A THROW STATEMENT -throw_statement : 'throw' expression ; +throw_statement + : 'throw' expression + ; // GRAMMAR OF A DEFER STATEMENT -defer_statement : 'defer' code_block ; +defer_statement + : 'defer' code_block + ; // GRAMMAR OF A DO STATEMENT -do_statement : 'do' code_block catch_clauses? ; -catch_clauses : catch_clause catch_clauses? ; -catch_clause : 'catch' pattern? where_clause? code_block ; +do_statement + : 'do' code_block catch_clauses? + ; -// GRAMMAR OF A COMPILER CONTROL STATEMENT +catch_clauses + : catch_clause catch_clauses? + ; -compiler_control_statement : build_configuration_statement - | line_control_statement - ; +catch_clause + : 'catch' pattern? where_clause? code_block + ; -// GRAMMAR OF A BUILD CONFIGURATION STATEMENT +// GRAMMAR OF A COMPILER CONTROL STATEMENT -build_configuration_statement: '#if' build_configuration statements? build_configuration_elseif_clauses? build_configuration_else_clause? '#endif' ; -build_configuration_elseif_clauses : build_configuration_elseif_clause build_configuration_elseif_clauses? ; -build_configuration_elseif_clause : '#elseif' build_configuration statements? ; -build_configuration_else_clause : '#else' statements? ; - -build_configuration : platform_testing_function - | identifier - | boolean_literal - | '(' build_configuration ')' - | '!' build_configuration - | build_configuration build_AND build_configuration - | build_configuration build_OR build_configuration - ; +compiler_control_statement + : build_configuration_statement + | line_control_statement + ; -platform_testing_function : 'os' '(' operating_system ')' - | 'arch' '(' architecture ')' - ; +// GRAMMAR OF A BUILD CONFIGURATION STATEMENT -operating_system : 'OSX' | 'iOS' | 'watchOS' | 'tvOS' ; -architecture : 'i386' | 'x86_64' | 'arm' | 'arm64' ; +build_configuration_statement + : '#if' build_configuration statements? build_configuration_elseif_clauses? build_configuration_else_clause? '#endif' + ; + +build_configuration_elseif_clauses + : build_configuration_elseif_clause build_configuration_elseif_clauses? + ; + +build_configuration_elseif_clause + : '#elseif' build_configuration statements? + ; + +build_configuration_else_clause + : '#else' statements? + ; + +build_configuration + : platform_testing_function + | identifier + | boolean_literal + | '(' build_configuration ')' + | '!' build_configuration + | build_configuration build_AND build_configuration + | build_configuration build_OR build_configuration + ; + +platform_testing_function + : 'os' '(' operating_system ')' + | 'arch' '(' architecture ')' + ; + +operating_system + : 'OSX' + | 'iOS' + | 'watchOS' + | 'tvOS' + ; + +architecture + : 'i386' + | 'x86_64' + | 'arm' + | 'arm64' + ; // GRAMMAR OF A LINE CONTROL STATEMENT -line_control_statement : '#line' - | '#line' line_number file_name - ; +line_control_statement + : '#line' + | '#line' line_number file_name + ; + +line_number + : integer_literal + ; -line_number : integer_literal ; -file_name : Static_string_literal ; +file_name + : Static_string_literal + ; // Generic Parameters and Arguments // GRAMMAR OF A GENERIC PARAMETER CLAUSE -generic_parameter_clause : '<' generic_parameter_list requirement_clause? '>' ; -generic_parameter_list : generic_parameter (',' generic_parameter)* ; -generic_parameter - : type_name - | type_name ':' type_identifier - | type_name ':' protocol_composition_type - ; +generic_parameter_clause + : '<' generic_parameter_list requirement_clause? '>' + ; -requirement_clause : 'where' requirement_list ; -requirement_list : requirement | requirement ',' requirement_list ; -requirement : conformance_requirement | same_type_requirement ; +generic_parameter_list + : generic_parameter (',' generic_parameter)* + ; -conformance_requirement : type_identifier ':' type_identifier | type_identifier ':' protocol_composition_type ; -same_type_requirement : type_identifier same_type_equals type_ ; +generic_parameter + : type_name + | type_name ':' type_identifier + | type_name ':' protocol_composition_type + ; + +requirement_clause + : 'where' requirement_list + ; + +requirement_list + : requirement + | requirement ',' requirement_list + ; + +requirement + : conformance_requirement + | same_type_requirement + ; + +conformance_requirement + : type_identifier ':' type_identifier + | type_identifier ':' protocol_composition_type + ; + +same_type_requirement + : type_identifier same_type_equals type_ + ; // GRAMMAR OF A GENERIC ARGUMENT CLAUSE -generic_argument_clause : '<' generic_argument_list '>' ; -generic_argument_list : generic_argument (',' generic_argument)* ; -generic_argument : type_ ; +generic_argument_clause + : '<' generic_argument_list '>' + ; + +generic_argument_list + : generic_argument (',' generic_argument)* + ; + +generic_argument + : type_ + ; // context-sensitive. Allow < as pre, post, or binary op //lt : {_input.LT(1).getText().equals("<")}? operator_ ; @@ -285,288 +451,576 @@ generic_argument : type_ ; // GRAMMAR OF A DECLARATION declaration - : import_declaration - | constant_declaration - | variable_declaration - | typealias_declaration - | function_declaration - | enum_declaration - | struct_declaration - | class_declaration - | protocol_declaration - | initializer_declaration - | deinitializer_declaration - | extension_declaration - | subscript_declaration - | operator_declaration - ; - -declarations : declaration+ ; - + : import_declaration + | constant_declaration + | variable_declaration + | typealias_declaration + | function_declaration + | enum_declaration + | struct_declaration + | class_declaration + | protocol_declaration + | initializer_declaration + | deinitializer_declaration + | extension_declaration + | subscript_declaration + | operator_declaration + ; + +declarations + : declaration+ + ; // GRAMMAR OF A TOP-LEVEL DECLARATION -top_level_declaration : statements? ; +top_level_declaration + : statements? + ; // GRAMMAR OF A CODE BLOCK -code_block : '{' statements? '}' ; +code_block + : '{' statements? '}' + ; // GRAMMAR OF AN IMPORT DECLARATION -import_declaration : attributes? 'import' import_kind? import_path ; -import_kind : 'typealias' | 'struct' | 'class' | 'enum' | 'protocol' | 'var' | 'func' ; -import_path : import_path_identifier | import_path_identifier '.' import_path ; -import_path_identifier : identifier | operator_ ; +import_declaration + : attributes? 'import' import_kind? import_path + ; + +import_kind + : 'typealias' + | 'struct' + | 'class' + | 'enum' + | 'protocol' + | 'var' + | 'func' + ; + +import_path + : import_path_identifier + | import_path_identifier '.' import_path + ; + +import_path_identifier + : identifier + | operator_ + ; // GRAMMAR OF A CONSTANT DECLARATION -constant_declaration : attributes? declaration_modifiers? 'let' pattern_initializer_list ; -pattern_initializer_list : pattern_initializer (',' pattern_initializer)* ; +constant_declaration + : attributes? declaration_modifiers? 'let' pattern_initializer_list + ; + +pattern_initializer_list + : pattern_initializer (',' pattern_initializer)* + ; /** rule is ambiguous. can match "var x = 1" with x as pattern * OR with x as expression_pattern. * ANTLR resolves in favor or first choice: pattern is x, 1 is initializer. */ -pattern_initializer : pattern initializer? ; -initializer : assignment_operator expression ; +pattern_initializer + : pattern initializer? + ; + +initializer + : assignment_operator expression + ; // GRAMMAR OF A VARIABLE DECLARATION variable_declaration - : variable_declaration_head pattern_initializer_list - | variable_declaration_head variable_name type_annotation code_block - | variable_declaration_head variable_name type_annotation getter_setter_block - | variable_declaration_head variable_name type_annotation getter_setter_keyword_block - | variable_declaration_head variable_name type_annotation initializer? willSet_didSet_block - | variable_declaration_head variable_name type_annotation type_annotation initializer? willSet_didSet_block - ; + : variable_declaration_head pattern_initializer_list + | variable_declaration_head variable_name type_annotation code_block + | variable_declaration_head variable_name type_annotation getter_setter_block + | variable_declaration_head variable_name type_annotation getter_setter_keyword_block + | variable_declaration_head variable_name type_annotation initializer? willSet_didSet_block + | variable_declaration_head variable_name type_annotation type_annotation initializer? willSet_didSet_block + ; + +variable_declaration_head + : attributes? declaration_modifiers? 'var' + ; + +variable_name + : identifier + ; + +getter_setter_block + : '{' getter_clause setter_clause? '}' + | '{' setter_clause getter_clause '}' + ; + +getter_clause + : attributes? 'get' code_block + ; + +setter_clause + : attributes? 'set' setter_name? code_block + ; + +setter_name + : '(' identifier ')' + ; + +getter_setter_keyword_block + : '{' getter_keyword_clause setter_keyword_clause? '}' + | '{' setter_keyword_clause getter_keyword_clause '}' + ; + +getter_keyword_clause + : attributes? 'get' + ; + +setter_keyword_clause + : attributes? 'set' + ; + +willSet_didSet_block + : '{' willSet_clause didSet_clause? '}' + | '{' didSet_clause willSet_clause '}' + ; + +willSet_clause + : attributes? 'willSet' setter_name? code_block + ; + +didSet_clause + : attributes? 'didSet' setter_name? code_block + ; -variable_declaration_head : attributes? declaration_modifiers? 'var' ; -variable_name : identifier ; - -getter_setter_block : '{' getter_clause setter_clause?'}' | '{' setter_clause getter_clause '}' ; -getter_clause : attributes? 'get' code_block ; -setter_clause : attributes? 'set' setter_name? code_block ; -setter_name : '(' identifier ')' ; +// GRAMMAR OF A TYPE ALIAS DECLARATION -getter_setter_keyword_block : '{' getter_keyword_clause setter_keyword_clause?'}' | '{' setter_keyword_clause getter_keyword_clause '}' ; -getter_keyword_clause : attributes? 'get' ; -setter_keyword_clause : attributes? 'set' ; +typealias_declaration + : typealias_head typealias_assignment + ; -willSet_didSet_block : '{' willSet_clause didSet_clause?'}' | '{' didSet_clause willSet_clause '}' ; -willSet_clause : attributes? 'willSet' setter_name? code_block ; -didSet_clause : attributes? 'didSet' setter_name? code_block ; +typealias_head + : attributes? access_level_modifier? 'typealias' typealias_name + ; -// GRAMMAR OF A TYPE ALIAS DECLARATION +typealias_name + : identifier + ; -typealias_declaration : typealias_head typealias_assignment ; -typealias_head : attributes? access_level_modifier? 'typealias' typealias_name ; -typealias_name : identifier ; -typealias_assignment : assignment_operator type_ ; +typealias_assignment + : assignment_operator type_ + ; // GRAMMAR OF A FUNCTION DECLARATION // NOTE: Swift Grammar Spec indicates that a function_body is optional function_declaration - : function_head function_name generic_parameter_clause? function_signature - function_body? - ; -function_head : attributes? declaration_modifiers? 'func' ; -function_name : identifier | operator_ ; + : function_head function_name generic_parameter_clause? function_signature function_body? + ; + +function_head + : attributes? declaration_modifiers? 'func' + ; + +function_name + : identifier + | operator_ + ; + function_signature - : parameter_clauses 'throws'? function_result? - | parameter_clauses 'rethrows' function_result? - ; -function_result : arrow_operator attributes? type_ ; -function_body : code_block ; -parameter_clauses : parameter_clause parameter_clauses? ; -parameter_clause : '(' ')' | '(' parameter_list ')' ; -parameter_list : parameter (',' parameter)* ; -parameter - : 'let'? external_parameter_name? local_parameter_name type_annotation? default_argument_clause? - | 'var' external_parameter_name? local_parameter_name type_annotation? default_argument_clause? - | 'inout' external_parameter_name? local_parameter_name type_annotation - | external_parameter_name? local_parameter_name type_annotation range_operator - ; -external_parameter_name : identifier | '_' ; -local_parameter_name : identifier | '_' ; -default_argument_clause : assignment_operator expression ; + : parameter_clauses 'throws'? function_result? + | parameter_clauses 'rethrows' function_result? + ; + +function_result + : arrow_operator attributes? type_ + ; + +function_body + : code_block + ; + +parameter_clauses + : parameter_clause parameter_clauses? + ; + +parameter_clause + : '(' ')' + | '(' parameter_list ')' + ; +parameter_list + : parameter (',' parameter)* + ; + +parameter + : 'let'? external_parameter_name? local_parameter_name type_annotation? default_argument_clause? + | 'var' external_parameter_name? local_parameter_name type_annotation? default_argument_clause? + | 'inout' external_parameter_name? local_parameter_name type_annotation + | external_parameter_name? local_parameter_name type_annotation range_operator + ; + +external_parameter_name + : identifier + | '_' + ; + +local_parameter_name + : identifier + | '_' + ; + +default_argument_clause + : assignment_operator expression + ; // GRAMMAR OF AN ENUMERATION DECLARATION -enum_declaration : attributes? access_level_modifier? union_style_enum | attributes? access_level_modifier? raw_value_style_enum ; -union_style_enum : 'indirect'? 'enum' enum_name generic_parameter_clause? type_inheritance_clause? '{' union_style_enum_members?'}' ; -union_style_enum_members : union_style_enum_member union_style_enum_members? ; -union_style_enum_member : declaration | union_style_enum_case_clause ; -union_style_enum_case_clause : attributes? 'indirect'? 'case' union_style_enum_case_list ; -union_style_enum_case_list : union_style_enum_case | union_style_enum_case ',' union_style_enum_case_list ; -union_style_enum_case : enum_case_name tuple_type? ; -enum_name : identifier ; -enum_case_name : identifier ; -raw_value_style_enum : 'enum' enum_name generic_parameter_clause? type_inheritance_clause '{' raw_value_style_enum_members '}' ; -raw_value_style_enum_members : raw_value_style_enum_member raw_value_style_enum_members? ; -raw_value_style_enum_member : declaration | raw_value_style_enum_case_clause ; -raw_value_style_enum_case_clause : attributes? 'case' raw_value_style_enum_case_list ; -raw_value_style_enum_case_list : raw_value_style_enum_case | raw_value_style_enum_case ',' raw_value_style_enum_case_list ; -raw_value_style_enum_case : enum_case_name raw_value_assignment? ; -raw_value_assignment : assignment_operator raw_value_literal ; -raw_value_literal : numeric_literal | Static_string_literal | boolean_literal ; +enum_declaration + : attributes? access_level_modifier? union_style_enum + | attributes? access_level_modifier? raw_value_style_enum + ; + +union_style_enum + : 'indirect'? 'enum' enum_name generic_parameter_clause? type_inheritance_clause? '{' union_style_enum_members? '}' + ; + +union_style_enum_members + : union_style_enum_member union_style_enum_members? + ; + +union_style_enum_member + : declaration + | union_style_enum_case_clause + ; + +union_style_enum_case_clause + : attributes? 'indirect'? 'case' union_style_enum_case_list + ; + +union_style_enum_case_list + : union_style_enum_case + | union_style_enum_case ',' union_style_enum_case_list + ; + +union_style_enum_case + : enum_case_name tuple_type? + ; + +enum_name + : identifier + ; + +enum_case_name + : identifier + ; + +raw_value_style_enum + : 'enum' enum_name generic_parameter_clause? type_inheritance_clause '{' raw_value_style_enum_members '}' + ; + +raw_value_style_enum_members + : raw_value_style_enum_member raw_value_style_enum_members? + ; + +raw_value_style_enum_member + : declaration + | raw_value_style_enum_case_clause + ; + +raw_value_style_enum_case_clause + : attributes? 'case' raw_value_style_enum_case_list + ; + +raw_value_style_enum_case_list + : raw_value_style_enum_case + | raw_value_style_enum_case ',' raw_value_style_enum_case_list + ; + +raw_value_style_enum_case + : enum_case_name raw_value_assignment? + ; + +raw_value_assignment + : assignment_operator raw_value_literal + ; + +raw_value_literal + : numeric_literal + | Static_string_literal + | boolean_literal + ; // GRAMMAR OF A STRUCTURE DECLARATION TODO did not update -struct_declaration : attributes? access_level_modifier? 'struct' struct_name generic_parameter_clause? type_inheritance_clause? struct_body ; -struct_name : identifier ; -struct_body : '{' declarations?'}' ; +struct_declaration + : attributes? access_level_modifier? 'struct' struct_name generic_parameter_clause? type_inheritance_clause? struct_body + ; + +struct_name + : identifier + ; + +struct_body + : '{' declarations? '}' + ; // GRAMMAR OF A CLASS DECLARATION class_declaration - : attributes? access_level_modifier? 'class' class_name - generic_parameter_clause? type_inheritance_clause? class_body - ; -class_name : identifier ; -class_body : '{' declarations? '}' ; + : attributes? access_level_modifier? 'class' class_name generic_parameter_clause? type_inheritance_clause? class_body + ; + +class_name + : identifier + ; + +class_body + : '{' declarations? '}' + ; // GRAMMAR OF A PROTOCOL DECLARATION -protocol_declaration : attributes? access_level_modifier? 'protocol' protocol_name type_inheritance_clause? protocol_body ; -protocol_name : identifier ; -protocol_body : '{' protocol_member_declarations? '}' ; +protocol_declaration + : attributes? access_level_modifier? 'protocol' protocol_name type_inheritance_clause? protocol_body + ; -protocol_member_declaration : protocol_property_declaration - | protocol_method_declaration - | protocol_initializer_declaration - | protocol_subscript_declaration - | protocol_associated_type_declaration - ; -protocol_member_declarations : protocol_member_declaration protocol_member_declarations? ; +protocol_name + : identifier + ; + +protocol_body + : '{' protocol_member_declarations? '}' + ; + +protocol_member_declaration + : protocol_property_declaration + | protocol_method_declaration + | protocol_initializer_declaration + | protocol_subscript_declaration + | protocol_associated_type_declaration + ; + +protocol_member_declarations + : protocol_member_declaration protocol_member_declarations? + ; // GRAMMAR OF A PROTOCOL PROPERTY DECLARATION -protocol_property_declaration : variable_declaration_head variable_name type_annotation getter_setter_keyword_block ; +protocol_property_declaration + : variable_declaration_head variable_name type_annotation getter_setter_keyword_block + ; // GRAMMAR OF A PROTOCOL METHOD DECLARATION -protocol_method_declaration : function_head function_name generic_parameter_clause? function_signature ; +protocol_method_declaration + : function_head function_name generic_parameter_clause? function_signature + ; // GRAMMAR OF A PROTOCOL INITIALIZER DECLARATION protocol_initializer_declaration - : initializer_head generic_parameter_clause? parameter_clause 'throws'? - | initializer_head generic_parameter_clause? parameter_clause 'rethrows' - ; + : initializer_head generic_parameter_clause? parameter_clause 'throws'? + | initializer_head generic_parameter_clause? parameter_clause 'rethrows' + ; // GRAMMAR OF A PROTOCOL SUBSCRIPT DECLARATION -protocol_subscript_declaration : subscript_head subscript_result getter_setter_keyword_block ; +protocol_subscript_declaration + : subscript_head subscript_result getter_setter_keyword_block + ; // GRAMMAR OF A PROTOCOL ASSOCIATED TYPE DECLARATION -protocol_associated_type_declaration : attributes? access_level_modifier? 'associatedtype' typealias_name type_inheritance_clause? typealias_assignment? ; +protocol_associated_type_declaration + : attributes? access_level_modifier? 'associatedtype' typealias_name type_inheritance_clause? typealias_assignment? + ; // GRAMMAR OF AN INITIALIZER DECLARATION initializer_declaration - : initializer_head generic_parameter_clause? parameter_clause 'throws'? initializer_body - | initializer_head generic_parameter_clause? parameter_clause 'rethrows' initializer_body - ; + : initializer_head generic_parameter_clause? parameter_clause 'throws'? initializer_body + | initializer_head generic_parameter_clause? parameter_clause 'rethrows' initializer_body + ; initializer_head - : attributes? declaration_modifiers? 'init' - | attributes? declaration_modifiers? 'init' '?' - | attributes? declaration_modifiers? 'init' '!' - ; + : attributes? declaration_modifiers? 'init' + | attributes? declaration_modifiers? 'init' '?' + | attributes? declaration_modifiers? 'init' '!' + ; -initializer_body : code_block ; +initializer_body + : code_block + ; // GRAMMAR OF A DEINITIALIZER DECLARATION -deinitializer_declaration : attributes? 'deinit' code_block ; +deinitializer_declaration + : attributes? 'deinit' code_block + ; // GRAMMAR OF AN EXTENSION DECLARATION -extension_declaration : access_level_modifier? 'extension' type_identifier type_inheritance_clause? extension_body ; -extension_body : '{' declarations?'}' ; +extension_declaration + : access_level_modifier? 'extension' type_identifier type_inheritance_clause? extension_body + ; + +extension_body + : '{' declarations? '}' + ; // GRAMMAR OF A SUBSCRIPT DECLARATION subscript_declaration - : subscript_head subscript_result code_block - | subscript_head subscript_result getter_setter_block - | subscript_head subscript_result getter_setter_keyword_block - ; + : subscript_head subscript_result code_block + | subscript_head subscript_result getter_setter_block + | subscript_head subscript_result getter_setter_keyword_block + ; + +subscript_head + : attributes? declaration_modifiers? 'subscript' parameter_clause + ; -subscript_head : attributes? declaration_modifiers? 'subscript' parameter_clause ; -subscript_result : arrow_operator attributes? type_ ; +subscript_result + : arrow_operator attributes? type_ + ; // GRAMMAR OF AN OPERATOR DECLARATION -operator_declaration : prefix_operator_declaration | postfix_operator_declaration | infix_operator_declaration ; -prefix_operator_declaration : 'prefix' 'operator' operator_ '{' '}' ; -postfix_operator_declaration : 'postfix' 'operator' operator_ '{' '}' ; -infix_operator_declaration : 'infix' 'operator' operator_ '{' infix_operator_attributes '}' ; // Note: infix_operator_attributes is optional by definition so no ? needed -infix_operator_attributes : precedence_clause? associativity_clause? ; -precedence_clause : 'precedence' precedence_level ; -precedence_level : integer_literal ; -associativity_clause : 'associativity' associativity_ ; -associativity_ : 'left' | 'right' | 'none' ; +operator_declaration + : prefix_operator_declaration + | postfix_operator_declaration + | infix_operator_declaration + ; + +prefix_operator_declaration + : 'prefix' 'operator' operator_ '{' '}' + ; + +postfix_operator_declaration + : 'postfix' 'operator' operator_ '{' '}' + ; + +infix_operator_declaration + : 'infix' 'operator' operator_ '{' infix_operator_attributes '}' + ; // Note: infix_operator_attributes is optional by definition so no ? needed + +infix_operator_attributes + : precedence_clause? associativity_clause? + ; + +precedence_clause + : 'precedence' precedence_level + ; + +precedence_level + : integer_literal + ; + +associativity_clause + : 'associativity' associativity_ + ; + +associativity_ + : 'left' + | 'right' + | 'none' + ; // GRAMMAR OF A DECLARATION MODIFIER declaration_modifier - : 'class' | 'convenience' | 'dynamic' | 'final' | 'infix' | 'lazy' | 'mutating' | 'nonmutating' | 'optional' | 'override' | 'postfix' | 'prefix' | 'required' | 'static' | 'unowned' | 'unowned' '(' 'safe' ')' | 'unowned' '(' 'unsafe' ')' | 'weak' - | access_level_modifier - ; -declaration_modifiers : declaration_modifier declaration_modifiers? ; + : 'class' + | 'convenience' + | 'dynamic' + | 'final' + | 'infix' + | 'lazy' + | 'mutating' + | 'nonmutating' + | 'optional' + | 'override' + | 'postfix' + | 'prefix' + | 'required' + | 'static' + | 'unowned' + | 'unowned' '(' 'safe' ')' + | 'unowned' '(' 'unsafe' ')' + | 'weak' + | access_level_modifier + ; + +declaration_modifiers + : declaration_modifier declaration_modifiers? + ; access_level_modifier - : 'internal' | 'internal' '(' 'set' ')' - | 'private' | 'private' '(' 'set' ')' - | 'public' | 'public' '(' 'set' ')' - ; + : 'internal' + | 'internal' '(' 'set' ')' + | 'private' + | 'private' '(' 'set' ')' + | 'public' + | 'public' '(' 'set' ')' + ; // Patterns // GRAMMAR OF A PATTERN pattern - : wildcard_pattern type_annotation? - | identifier_pattern type_annotation? - | value_binding_pattern - | tuple_pattern type_annotation? - | enum_case_pattern - | optional_pattern - | 'is' type_ - | pattern 'as' type_ - | expression_pattern - ; + : wildcard_pattern type_annotation? + | identifier_pattern type_annotation? + | value_binding_pattern + | tuple_pattern type_annotation? + | enum_case_pattern + | optional_pattern + | 'is' type_ + | pattern 'as' type_ + | expression_pattern + ; // GRAMMAR OF A WILDCARD PATTERN -wildcard_pattern : '_' ; +wildcard_pattern + : '_' + ; // GRAMMAR OF AN IDENTIFIER PATTERN -identifier_pattern : identifier ; +identifier_pattern + : identifier + ; // GRAMMAR OF A VALUE_BINDING PATTERN -value_binding_pattern : 'var' pattern | 'let' pattern ; +value_binding_pattern + : 'var' pattern + | 'let' pattern + ; // GRAMMAR OF A TUPLE PATTERN -tuple_pattern : '(' tuple_pattern_element_list? ')' ; +tuple_pattern + : '(' tuple_pattern_element_list? ')' + ; + tuple_pattern_element_list - : tuple_pattern_element (',' tuple_pattern_element)* - ; -tuple_pattern_element : pattern ; + : tuple_pattern_element (',' tuple_pattern_element)* + ; + +tuple_pattern_element + : pattern + ; // GRAMMAR OF AN ENUMERATION CASE PATTERN -enum_case_pattern : type_identifier? '.' enum_case_name tuple_pattern? ; +enum_case_pattern + : type_identifier? '.' enum_case_name tuple_pattern? + ; // GRAMMAR OF AN OPTIONAL PATTERN -optional_pattern : identifier_pattern '?' ; +optional_pattern + : identifier_pattern '?' + ; // GRAMMAR OF A TYPE CASTING PATTERN @@ -575,180 +1029,274 @@ optional_pattern : identifier_pattern '?' ; // GRAMMAR OF AN EXPRESSION PATTERN /** Doc says "Expression patterns appear only in switch statement case labels." */ -expression_pattern : expression ; +expression_pattern + : expression + ; // Attributes // GRAMMAR OF AN ATTRIBUTE -attribute : '@'? attribute_name attribute_argument_clause? ; -attribute_name : identifier ; -attribute_argument_clause : '(' balanced_tokens? ')' ; -attributes : attribute+ ; -balanced_tokens : balanced_token+ ; +attribute + : '@'? attribute_name attribute_argument_clause? + ; + +attribute_name + : identifier + ; + +attribute_argument_clause + : '(' balanced_tokens? ')' + ; + +attributes + : attribute+ + ; + +balanced_tokens + : balanced_token+ + ; + balanced_token - : '(' balanced_tokens? ')' - | '[' balanced_tokens? ']' - | '{' balanced_tokens? '}' - | identifier | expression | context_sensitive_keyword | literal | operator_ -// | Any punctuation except ( , ')' , '[' , ']' , { , or } TODO add? - ; + : '(' balanced_tokens? ')' + | '[' balanced_tokens? ']' + | '{' balanced_tokens? '}' + | identifier + | expression + | context_sensitive_keyword + | literal + | operator_ + // | Any punctuation except ( , ')' , '[' , ']' , { , or } TODO add? + ; // Expressions // GRAMMAR OF AN EXPRESSION -expression : try_operator? prefix_expression binary_expressions? ; +expression + : try_operator? prefix_expression binary_expressions? + ; -expression_list : expression (',' expression)* ; +expression_list + : expression (',' expression)* + ; // GRAMMAR OF A PREFIX EXPRESSION prefix_expression - : prefix_operator postfix_expression - | postfix_expression - | in_out_expression - ; + : prefix_operator postfix_expression + | postfix_expression + | in_out_expression + ; -in_out_expression : '&' identifier ; +in_out_expression + : '&' identifier + ; // GRAMMAR OF A TRY EXPRESSION -try_operator : 'try' '?' | 'try' '!' | 'try' ; +try_operator + : 'try' '?' + | 'try' '!' + | 'try' + ; // GRAMMAR OF A BINARY EXPRESSION - binary_expression - : binary_operator prefix_expression -// as far as I can tell, assignment is not a valid operator as it has no return type -// it is more properly a statement; commenting this next line out and moving to assignment_statement: -// | assignment_operator try_operator? prefix_expression - | conditional_operator try_operator? prefix_expression - | type_casting_operator - ; - -binary_expressions : binary_expression+ ; + : binary_operator prefix_expression + // as far as I can tell, assignment is not a valid operator as it has no return type + // it is more properly a statement; commenting this next line out and moving to assignment_statement: + // | assignment_operator try_operator? prefix_expression + | conditional_operator try_operator? prefix_expression + | type_casting_operator + ; + +binary_expressions + : binary_expression+ + ; // GRAMMAR OF A CONDITIONAL OPERATOR -conditional_operator : '?' try_operator? expression ':' ; +conditional_operator + : '?' try_operator? expression ':' + ; // GRAMMAR OF A TYPE_CASTING OPERATOR type_casting_operator - : 'is' type_ - | 'as' type_ - | 'as' '?' type_ - | 'as' '!' type_ - ; + : 'is' type_ + | 'as' type_ + | 'as' '?' type_ + | 'as' '!' type_ + ; // GRAMMAR OF A PRIMARY EXPRESSION primary_expression - : identifier generic_argument_clause? - | literal_expression - | self_expression - | superclass_expression - | closure_expression - | parenthesized_expression - | implicit_member_expression - | wildcard_expression - | selector_expression - ; - -implicit_member_expression : '.' identifier ; + : identifier generic_argument_clause? + | literal_expression + | self_expression + | superclass_expression + | closure_expression + | parenthesized_expression + | implicit_member_expression + | wildcard_expression + | selector_expression + ; + +implicit_member_expression + : '.' identifier + ; // GRAMMAR OF A LITERAL EXPRESSION literal_expression - : literal - | array_literal - | dictionary_literal - | '__FILE__' | '__LINE__' | '__COLUMN__' | '__FUNCTION__' - ; - -array_literal : '[' array_literal_items? ']' ; -array_literal_items : array_literal_item (',' array_literal_item)* ','? ; -array_literal_item : expression ; -dictionary_literal : '[' dictionary_literal_items ']' | '[' ':' ']' ; -dictionary_literal_items : dictionary_literal_item (',' dictionary_literal_item)* ','? ; -dictionary_literal_item : expression ':' expression ; + : literal + | array_literal + | dictionary_literal + | '__FILE__' + | '__LINE__' + | '__COLUMN__' + | '__FUNCTION__' + ; + +array_literal + : '[' array_literal_items? ']' + ; + +array_literal_items + : array_literal_item (',' array_literal_item)* ','? + ; + +array_literal_item + : expression + ; + +dictionary_literal + : '[' dictionary_literal_items ']' + | '[' ':' ']' + ; + +dictionary_literal_items + : dictionary_literal_item (',' dictionary_literal_item)* ','? + ; + +dictionary_literal_item + : expression ':' expression + ; // GRAMMAR OF A SELF EXPRESSION self_expression - : 'self' - | 'self' '.' identifier - | 'self' '[' expression_list ']' - | 'self' '.' 'init' - ; + : 'self' + | 'self' '.' identifier + | 'self' '[' expression_list ']' + | 'self' '.' 'init' + ; // GRAMMAR OF A SUPERCLASS EXPRESSION superclass_expression - : superclass_method_expression - | superclass_subscript_expression - | superclass_initializer_expression - ; + : superclass_method_expression + | superclass_subscript_expression + | superclass_initializer_expression + ; + +superclass_method_expression + : 'super' '.' identifier + ; + +superclass_subscript_expression + : 'super' '[' expression ']' + ; -superclass_method_expression : 'super' '.' identifier ; -superclass_subscript_expression : 'super' '[' expression ']' ; -superclass_initializer_expression : 'super' '.' 'init' ; +superclass_initializer_expression + : 'super' '.' 'init' + ; // GRAMMAR OF A CLOSURE EXPRESSION -closure_expression : '{' closure_signature? statements? '}' ; +closure_expression + : '{' closure_signature? statements? '}' + ; + closure_signature - : parameter_clause function_result? 'in' - | identifier_list function_result? 'in' - | capture_list parameter_clause function_result? 'in' - | capture_list identifier_list function_result? 'in' - | capture_list 'in' - ; + : parameter_clause function_result? 'in' + | identifier_list function_result? 'in' + | capture_list parameter_clause function_result? 'in' + | capture_list identifier_list function_result? 'in' + | capture_list 'in' + ; + +capture_list + : '[' capture_list_items ']' + ; + +capture_list_items + : capture_list_item (',' capture_list_item)* + ; + +capture_list_item + : capture_specifier? expression + ; + +capture_specifier + : 'weak' + | 'unowned' + | 'unowned(safe)' + | 'unowned(unsafe)' + ; -capture_list : '[' capture_list_items ']' ; -capture_list_items : capture_list_item (',' capture_list_item)* ; -capture_list_item : capture_specifier? expression ; +// GRAMMAR OF A PARENTHESIZED EXPRESSION -capture_specifier : 'weak' | 'unowned' | 'unowned(safe)' | 'unowned(unsafe)' ; +parenthesized_expression + : '(' expression_element_list? ')' + ; -// GRAMMAR OF A PARENTHESIZED EXPRESSION +expression_element_list + : expression_element (',' expression_element)* + ; -parenthesized_expression : '(' expression_element_list? ')' ; -expression_element_list : expression_element (',' expression_element)* ; -expression_element : expression | identifier ':' expression ; +expression_element + : expression + | identifier ':' expression + ; // GRAMMAR OF A WILDCARD EXPRESSION -wildcard_expression : '_' ; +wildcard_expression + : '_' + ; // GRAMMAR OF A SELECTOR EXPRESSION -selector_expression : '#selector' '(' expression ')' ; +selector_expression + : '#selector' '(' expression ')' + ; // GRAMMAR OF A POSTFIX EXPRESSION (inlined many rules from spec to avoid indirect left-recursion) postfix_expression - : primary_expression # primary - | postfix_expression postfix_operator # postfix_operation - | postfix_expression parenthesized_expression # function_call_expression - | postfix_expression parenthesized_expression? trailing_closure # function_call_with_closure_expression - | postfix_expression '.' 'init' # initializer_expression - | postfix_expression '.' 'init' '(' argument_names ')' # initializer_expression_with_args - | postfix_expression '.' Pure_decimal_digits # explicit_member_expression1 - | postfix_expression '.' identifier generic_argument_clause? # explicit_member_expression2 - | postfix_expression '.' identifier '(' argument_names ')' # explicit_member_expression3 -// This does't exist in the swift grammar, but this valid swift statement fails without it -// self.addTarget(self, action: #selector(nameOfAction(_:))) - | postfix_expression '(' argument_names ')' # explicit_member_expression4 - | postfix_expression '.' 'self' # postfix_self_expression - | postfix_expression '.' 'dynamicType' # dynamic_type_expression - | postfix_expression '[' expression_list ']' # subscript_expression -// ! is a postfix operator already -// | postfix_expression '!' # forced_value_expression -// ? is a postfix operator already -// | postfix_expression '?' # optional_chaining_expression - ; + : primary_expression # primary + | postfix_expression postfix_operator # postfix_operation + | postfix_expression parenthesized_expression # function_call_expression + | postfix_expression parenthesized_expression? trailing_closure # function_call_with_closure_expression + | postfix_expression '.' 'init' # initializer_expression + | postfix_expression '.' 'init' '(' argument_names ')' # initializer_expression_with_args + | postfix_expression '.' Pure_decimal_digits # explicit_member_expression1 + | postfix_expression '.' identifier generic_argument_clause? # explicit_member_expression2 + | postfix_expression '.' identifier '(' argument_names ')' # explicit_member_expression3 + // This does't exist in the swift grammar, but this valid swift statement fails without it + // self.addTarget(self, action: #selector(nameOfAction(_:))) + | postfix_expression '(' argument_names ')' # explicit_member_expression4 + | postfix_expression '.' 'self' # postfix_self_expression + | postfix_expression '.' 'dynamicType' # dynamic_type_expression + | postfix_expression '[' expression_list ']' # subscript_expression + // ! is a postfix operator already + // | postfix_expression '!' # forced_value_expression + // ? is a postfix operator already + // | postfix_expression '?' # optional_chaining_expression + ; /* This might be faster than above postfix_expression @@ -768,48 +1316,74 @@ postfix_expression ; */ -argument_names : argument_name argument_names? ; +argument_names + : argument_name argument_names? + ; -argument_name : identifier ':' ; +argument_name + : identifier ':' + ; -trailing_closure : closure_expression ; +trailing_closure + : closure_expression + ; // GRAMMAR OF A TYPE type_ - : '[' type_ ']' - | '[' type_ ':' type_ ']' - | type_ 'throws'? arrow_operator type_ - | type_ 'rethrows' arrow_operator type_ - | type_identifier - | tuple_type - | type_ '?' - | type_ '!' - | protocol_composition_type - | type_ '.' 'Type' - | type_ '.' 'Protocol' - ; + : '[' type_ ']' + | '[' type_ ':' type_ ']' + | type_ 'throws'? arrow_operator type_ + | type_ 'rethrows' arrow_operator type_ + | type_identifier + | tuple_type + | type_ '?' + | type_ '!' + | protocol_composition_type + | type_ '.' 'Type' + | type_ '.' 'Protocol' + ; // GRAMMAR OF A TYPE ANNOTATION -type_annotation : ':' attributes? type_ ; +type_annotation + : ':' attributes? type_ + ; // GRAMMAR OF A TYPE IDENTIFIER type_identifier - : type_name generic_argument_clause? - | type_name generic_argument_clause? '.' type_identifier - ; + : type_name generic_argument_clause? + | type_name generic_argument_clause? '.' type_identifier + ; -type_name : identifier ; +type_name + : identifier + ; // GRAMMAR OF A TUPLE TYPE -tuple_type : '(' tuple_type_body? ')' ; -tuple_type_body : tuple_type_element_list range_operator? ; -tuple_type_element_list : tuple_type_element | tuple_type_element ',' tuple_type_element_list ; -tuple_type_element : attributes? 'inout'? type_ | 'inout'? element_name type_annotation ; -element_name : identifier ; +tuple_type + : '(' tuple_type_body? ')' + ; + +tuple_type_body + : tuple_type_element_list range_operator? + ; + +tuple_type_element_list + : tuple_type_element + | tuple_type_element ',' tuple_type_element_list + ; + +tuple_type_element + : attributes? 'inout'? type_ + | 'inout'? element_name type_annotation + ; + +element_name + : identifier + ; // GRAMMAR OF A FUNCTION TYPE @@ -832,9 +1406,18 @@ element_name : identifier ; // GRAMMAR OF A PROTOCOL COMPOSITION TYPE -protocol_composition_type : 'protocol' '<' protocol_identifier_list? '>' ; -protocol_identifier_list : protocol_identifier | (',' protocol_identifier)+ ; -protocol_identifier : type_identifier ; +protocol_composition_type + : 'protocol' '<' protocol_identifier_list? '>' + ; + +protocol_identifier_list + : protocol_identifier + | (',' protocol_identifier)+ + ; + +protocol_identifier + : type_identifier + ; // GRAMMAR OF A METATYPE TYPE @@ -843,66 +1426,128 @@ protocol_identifier : type_identifier ; // GRAMMAR OF A TYPE INHERITANCE CLAUSE type_inheritance_clause - : ':' class_requirement ',' type_inheritance_list - | ':' class_requirement - | ':' type_inheritance_list - ; + : ':' class_requirement ',' type_inheritance_list + | ':' class_requirement + | ':' type_inheritance_list + ; type_inheritance_list - : type_identifier - | type_identifier ',' type_inheritance_list - ; + : type_identifier + | type_identifier ',' type_inheritance_list + ; -class_requirement : 'class' ; +class_requirement + : 'class' + ; // ---------- Lexical Structure ----------- // GRAMMAR OF AN IDENTIFIER -identifier : Identifier | context_sensitive_keyword ; +identifier + : Identifier + | context_sensitive_keyword + ; Identifier - : Identifier_head Identifier_characters? - | '`' Identifier_head Identifier_characters? '`' - | Implicit_parameter_name - ; - -identifier_list : identifier (',' identifier)* ; - -fragment Identifier_head : [a-zA-Z] - | '_' - | '\u00A8' | '\u00AA' | '\u00AD' | '\u00AF' | [\u00B2-\u00B5] | [\u00B7-\u00BA] - | [\u00BC-\u00BE] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u00FF] - | [\u0100-\u02FF] | [\u0370-\u167F] | [\u1681-\u180D] | [\u180F-\u1DBF] - | [\u1E00-\u1FFF] - | [\u200B-\u200D] | [\u202A-\u202E] | [\u203F-\u2040] | '\u2054' | [\u2060-\u206F] - | [\u2070-\u20CF] | [\u2100-\u218F] | [\u2460-\u24FF] | [\u2776-\u2793] - | [\u2C00-\u2DFF] | [\u2E80-\u2FFF] - | [\u3004-\u3007] | [\u3021-\u302F] | [\u3031-\u303F] | [\u3040-\uD7FF] - | [\uF900-\uFD3D] | [\uFD40-\uFDCF] | [\uFDF0-\uFE1F] | [\uFE30-\uFE44] - | [\uFE47-\uFFFD] -/* + : Identifier_head Identifier_characters? + | '`' Identifier_head Identifier_characters? '`' + | Implicit_parameter_name + ; + +identifier_list + : identifier (',' identifier)* + ; + +fragment Identifier_head + : [a-zA-Z] + | '_' + | '\u00A8' + | '\u00AA' + | '\u00AD' + | '\u00AF' + | [\u00B2-\u00B5] + | [\u00B7-\u00BA] + | [\u00BC-\u00BE] + | [\u00C0-\u00D6] + | [\u00D8-\u00F6] + | [\u00F8-\u00FF] + | [\u0100-\u02FF] + | [\u0370-\u167F] + | [\u1681-\u180D] + | [\u180F-\u1DBF] + | [\u1E00-\u1FFF] + | [\u200B-\u200D] + | [\u202A-\u202E] + | [\u203F-\u2040] + | '\u2054' + | [\u2060-\u206F] + | [\u2070-\u20CF] + | [\u2100-\u218F] + | [\u2460-\u24FF] + | [\u2776-\u2793] + | [\u2C00-\u2DFF] + | [\u2E80-\u2FFF] + | [\u3004-\u3007] + | [\u3021-\u302F] + | [\u3031-\u303F] + | [\u3040-\uD7FF] + | [\uF900-\uFD3D] + | [\uFD40-\uFDCF] + | [\uFDF0-\uFE1F] + | [\uFE30-\uFE44] + | [\uFE47-\uFFFD] + /* | U+10000-U+1FFFD | U+20000-U+2FFFD | U+30000-U+3FFFD | U+40000-U+4FFFD | U+50000-U+5FFFD | U+60000-U+6FFFD | U+70000-U+7FFFD | U+80000-U+8FFFD | U+90000-U+9FFFD | U+A0000-U+AFFFD | U+B0000-U+BFFFD | U+C0000-U+CFFFD | U+D0000-U+DFFFD or U+E0000-U+EFFFD */ - ; - -fragment Identifier_character : [0-9] - | [\u0300-\u036F] | [\u1DC0-\u1DFF] | [\u20D0-\u20FF] | [\uFE20-\uFE2F] - | Identifier_head - ; - -fragment Identifier_characters : Identifier_character+ ; - -context_sensitive_keyword : - 'associativity' | 'convenience' | 'dynamic' | 'didSet' | - 'final' | 'get' | 'infix' | 'indirect' | 'lazy' | 'left' | 'mutating' | 'none' | - 'nonmutating' | 'optional' | 'operator' | 'override' | - 'postfix' | 'precedence' | 'prefix' | 'Protocol' | 'required' | 'right' | - 'set' | 'Type' | 'unowned' | 'unowned' | 'weak' | 'willSet' - ; + ; + +fragment Identifier_character + : [0-9] + | [\u0300-\u036F] + | [\u1DC0-\u1DFF] + | [\u20D0-\u20FF] + | [\uFE20-\uFE2F] + | Identifier_head + ; + +fragment Identifier_characters + : Identifier_character+ + ; + +context_sensitive_keyword + : 'associativity' + | 'convenience' + | 'dynamic' + | 'didSet' + | 'final' + | 'get' + | 'infix' + | 'indirect' + | 'lazy' + | 'left' + | 'mutating' + | 'none' + | 'nonmutating' + | 'optional' + | 'operator' + | 'override' + | 'postfix' + | 'precedence' + | 'prefix' + | 'Protocol' + | 'required' + | 'right' + | 'set' + | 'Type' + | 'unowned' + | 'unowned' + | 'weak' + | 'willSet' + ; // GRAMMAR OF OPERATORS @@ -956,59 +1601,158 @@ From doc on operators: /* these following tokens are also a Binary_operator so much come first as special case */ -assignment_operator : {SwiftSupport.isBinaryOp(_input)}? '=' ; - -DOT : '.' ; -LCURLY : '{' ; -LPAREN : '(' ; -LBRACK : '[' ; -RCURLY : '}' ; -RPAREN : ')' ; -RBRACK : ']' ; -COMMA : ',' ; -COLON : ':' ; -SEMI : ';' ; -LT : '<' ; -GT : '>' ; -UNDERSCORE : '_' ; -BANG : '!' ; -QUESTION: '?' ; -AT : '@' ; -AND : '&' ; -SUB : '-' ; -EQUAL : '=' ; -OR : '|' ; -DIV : '/' ; -ADD : '+' ; -MUL : '*' ; -MOD : '%' ; -CARET : '^' ; -TILDE : '~' ; +assignment_operator + : {SwiftSupport.isBinaryOp(_input)}? '=' + ; + +DOT + : '.' + ; + +LCURLY + : '{' + ; + +LPAREN + : '(' + ; + +LBRACK + : '[' + ; + +RCURLY + : '}' + ; + +RPAREN + : ')' + ; + +RBRACK + : ']' + ; + +COMMA + : ',' + ; + +COLON + : ':' + ; + +SEMI + : ';' + ; + +LT + : '<' + ; + +GT + : '>' + ; + +UNDERSCORE + : '_' + ; + +BANG + : '!' + ; + +QUESTION + : '?' + ; + +AT + : '@' + ; + +AND + : '&' + ; + +SUB + : '-' + ; + +EQUAL + : '=' + ; + +OR + : '|' + ; + +DIV + : '/' + ; + +ADD + : '+' + ; + +MUL + : '*' + ; + +MOD + : '%' + ; + +CARET + : '^' + ; + +TILDE + : '~' + ; /** Need to separate this out from Prefix_operator as it's referenced in numeric_literal * as specifically a negation prefix op. */ -negate_prefix_operator : {SwiftSupport.isPrefixOp(_input)}? '-'; +negate_prefix_operator + : {SwiftSupport.isPrefixOp(_input)}? '-' + ; + +build_AND + : {SwiftSupport.isOperator(_input,"&&")}? '&' '&' + ; + +build_OR + : {SwiftSupport.isOperator(_input,"||")}? '|' '|' + ; -build_AND : {SwiftSupport.isOperator(_input,"&&")}? '&' '&' ; -build_OR : {SwiftSupport.isOperator(_input,"||")}? '|' '|' ; -arrow_operator : {SwiftSupport.isOperator(_input,"->")}? '-' '>' ; -range_operator : {SwiftSupport.isOperator(_input,"...")}? '.' '.' '.' ; -same_type_equals: {SwiftSupport.isOperator(_input,"==")}? '=' '=' ; +arrow_operator + : {SwiftSupport.isOperator(_input,"->")}? '-' '>' + ; + +range_operator + : {SwiftSupport.isOperator(_input,"...")}? '.' '.' '.' + ; + +same_type_equals + : {SwiftSupport.isOperator(_input,"==")}? '=' '=' + ; /** "If an operator has whitespace around both sides or around neither side, it is treated as a binary operator. As an example, the + operator in a+b and a + b is treated as a binary operator." */ -binary_operator : {SwiftSupport.isBinaryOp(_input)}? operator_ ; +binary_operator + : {SwiftSupport.isBinaryOp(_input)}? operator_ + ; /** "If an operator has whitespace on the left side only, it is treated as a prefix unary operator. As an example, the ++ operator in a ++b is treated as a prefix unary operator." */ -prefix_operator : {SwiftSupport.isPrefixOp(_input)}? operator_ ; +prefix_operator + : {SwiftSupport.isPrefixOp(_input)}? operator_ + ; /** "If an operator has whitespace on the right side only, it is treated as a @@ -1020,143 +1764,264 @@ prefix_operator : {SwiftSupport.isPrefixOp(_input)}? operator_ ; the ++ operator in a++.b is treated as a postfix unary operator (a++ .b rather than a ++ .b)." */ -postfix_operator : {SwiftSupport.isPostfixOp(_input)}? operator_ ; +postfix_operator + : {SwiftSupport.isPostfixOp(_input)}? operator_ + ; operator_ - : operator_head ({_input.get(_input.index()-1).getType()!=WS}? operator_character)* - | dot_operator_head ({_input.get(_input.index()-1).getType()!=WS}? dot_operator_character)* - ; + : operator_head ({_input.get(_input.index()-1).getType()!=WS}? operator_character)* + | dot_operator_head ({_input.get(_input.index()-1).getType()!=WS}? dot_operator_character)* + ; operator_character - : operator_head - | Operator_following_character - ; + : operator_head + | Operator_following_character + ; operator_head - : ('/' | '=' | '-' | '+' | '!' | '*' | '%' | '&' | '|' | '<' | '>' | '^' | '~' | '?') // wrapping in (..) makes it a fast set comparison - | Operator_head_other - ; + : ( + '/' + | '=' + | '-' + | '+' + | '!' + | '*' + | '%' + | '&' + | '|' + | '<' + | '>' + | '^' + | '~' + | '?' + ) // wrapping in (..) makes it a fast set comparison + | Operator_head_other + ; Operator_head_other // valid operator chars not used by Swift itself - : [\u00A1-\u00A7] - | [\u00A9\u00AB] - | [\u00AC\u00AE] - | [\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7] - | [\u2016-\u2017\u2020-\u2027] - | [\u2030-\u203E] - | [\u2041-\u2053] - | [\u2055-\u205E] - | [\u2190-\u23FF] - | [\u2500-\u2775] - | [\u2794-\u2BFF] - | [\u2E00-\u2E7F] - | [\u3001-\u3003] - | [\u3008-\u3030] - ; + : [\u00A1-\u00A7] + | [\u00A9\u00AB] + | [\u00AC\u00AE] + | [\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7] + | [\u2016-\u2017\u2020-\u2027] + | [\u2030-\u203E] + | [\u2041-\u2053] + | [\u2055-\u205E] + | [\u2190-\u23FF] + | [\u2500-\u2775] + | [\u2794-\u2BFF] + | [\u2E00-\u2E7F] + | [\u3001-\u3003] + | [\u3008-\u3030] + ; Operator_following_character - : [\u0300-\u036F] - | [\u1DC0-\u1DFF] - | [\u20D0-\u20FF] - | [\uFE00-\uFE0F] - | [\uFE20-\uFE2F] - //| [\uE0100-\uE01EF] ANTLR can't do >16bit char - ; - -dot_operator_head : '.' '.' ; // TODO: adjacent cols -dot_operator_character : '.' | operator_character ; - -Implicit_parameter_name : '$' Pure_decimal_digits ; + : [\u0300-\u036F] + | [\u1DC0-\u1DFF] + | [\u20D0-\u20FF] + | [\uFE00-\uFE0F] + | [\uFE20-\uFE2F] + //| [\uE0100-\uE01EF] ANTLR can't do >16bit char + ; + +dot_operator_head + : '.' '.' + ; // TODO: adjacent cols + +dot_operator_character + : '.' + | operator_character + ; + +Implicit_parameter_name + : '$' Pure_decimal_digits + ; // GRAMMAR OF A LITERAL -literal : numeric_literal | string_literal | boolean_literal | nil_literal ; +literal + : numeric_literal + | string_literal + | boolean_literal + | nil_literal + ; numeric_literal - : negate_prefix_operator? integer_literal - | negate_prefix_operator? Floating_point_literal - ; + : negate_prefix_operator? integer_literal + | negate_prefix_operator? Floating_point_literal + ; -boolean_literal : 'true' | 'false' ; +boolean_literal + : 'true' + | 'false' + ; -nil_literal : 'nil' ; +nil_literal + : 'nil' + ; // GRAMMAR OF AN INTEGER LITERAL integer_literal - : Binary_literal - | Octal_literal - | Decimal_literal - | Pure_decimal_digits - | Hexadecimal_literal - ; + : Binary_literal + | Octal_literal + | Decimal_literal + | Pure_decimal_digits + | Hexadecimal_literal + ; + +Binary_literal + : '0b' Binary_digit Binary_literal_characters? + ; + +fragment Binary_digit + : [01] + ; + +fragment Binary_literal_character + : Binary_digit + | '_' + ; + +fragment Binary_literal_characters + : Binary_literal_character+ + ; + +Octal_literal + : '0o' Octal_digit Octal_literal_characters? + ; + +fragment Octal_digit + : [0-7] + ; + +fragment Octal_literal_character + : Octal_digit + | '_' + ; + +fragment Octal_literal_characters + : Octal_literal_character+ + ; + +Decimal_literal + : [0-9] [0-9_]* + ; + +Pure_decimal_digits + : [0-9]+ + ; + +fragment Decimal_digit + : [0-9] + ; + +fragment Decimal_literal_character + : Decimal_digit + | '_' + ; + +fragment Decimal_literal_characters + : Decimal_literal_character+ + ; + +Hexadecimal_literal + : '0x' Hexadecimal_digit Hexadecimal_literal_characters? + ; + +fragment Hexadecimal_digit + : [0-9a-fA-F] + ; + +fragment Hexadecimal_literal_character + : Hexadecimal_digit + | '_' + ; + +fragment Hexadecimal_literal_characters + : Hexadecimal_literal_character+ + ; -Binary_literal : '0b' Binary_digit Binary_literal_characters? ; -fragment Binary_digit : [01] ; -fragment Binary_literal_character : Binary_digit | '_' ; -fragment Binary_literal_characters : Binary_literal_character+ ; +// GRAMMAR OF A FLOATING_POINT LITERAL -Octal_literal : '0o' Octal_digit Octal_literal_characters? ; -fragment Octal_digit : [0-7] ; -fragment Octal_literal_character : Octal_digit | '_' ; -fragment Octal_literal_characters : Octal_literal_character+ ; +Floating_point_literal + : Decimal_literal Decimal_fraction? Decimal_exponent? + | Hexadecimal_literal Hexadecimal_fraction? Hexadecimal_exponent + ; -Decimal_literal : [0-9] [0-9_]* ; -Pure_decimal_digits : [0-9]+ ; -fragment Decimal_digit : [0-9] ; -fragment Decimal_literal_character : Decimal_digit | '_' ; -fragment Decimal_literal_characters : Decimal_literal_character+ ; +fragment Decimal_fraction + : '.' Decimal_literal + ; -Hexadecimal_literal : '0x' Hexadecimal_digit Hexadecimal_literal_characters? ; -fragment Hexadecimal_digit : [0-9a-fA-F] ; -fragment Hexadecimal_literal_character : Hexadecimal_digit | '_' ; -fragment Hexadecimal_literal_characters : Hexadecimal_literal_character+ ; +fragment Decimal_exponent + : Floating_point_e Sign? Decimal_literal + ; -// GRAMMAR OF A FLOATING_POINT LITERAL +fragment Hexadecimal_fraction + : '.' Hexadecimal_digit Hexadecimal_literal_characters? + ; -Floating_point_literal - : Decimal_literal Decimal_fraction? Decimal_exponent? - | Hexadecimal_literal Hexadecimal_fraction? Hexadecimal_exponent - ; -fragment Decimal_fraction : '.' Decimal_literal ; -fragment Decimal_exponent : Floating_point_e Sign? Decimal_literal ; -fragment Hexadecimal_fraction : '.' Hexadecimal_digit Hexadecimal_literal_characters? ; -fragment Hexadecimal_exponent : Floating_point_p Sign? Decimal_literal ; -fragment Floating_point_e : [eE] ; -fragment Floating_point_p : [pP] ; -fragment Sign : [+\-] ; +fragment Hexadecimal_exponent + : Floating_point_p Sign? Decimal_literal + ; + +fragment Floating_point_e + : [eE] + ; + +fragment Floating_point_p + : [pP] + ; + +fragment Sign + : [+\-] + ; // GRAMMAR OF A STRING LITERAL string_literal - : Static_string_literal - | Interpolated_string_literal - ; + : Static_string_literal + | Interpolated_string_literal + ; + +Static_string_literal + : '"' Quoted_text? '"' + ; + +fragment Quoted_text + : Quoted_text_item+ + ; -Static_string_literal : '"' Quoted_text? '"' ; -fragment Quoted_text : Quoted_text_item+ ; fragment Quoted_text_item - : Escaped_character - | ~["\n\r\\] - ; - -fragment -Escaped_character - : '\\' [0\\tnr"'] - | '\\x' Hexadecimal_digit Hexadecimal_digit - | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit '}' - | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit '}' - ; - -Interpolated_string_literal : '"' Interpolated_text_item* '"' ; -fragment -Interpolated_text_item - : '\\(' (Interpolated_string_literal | Interpolated_text_item)+ ')' // nested strings allowed - | Quoted_text_item - ; - -WS : [ \n\r\t\u000B\u000C\u0000]+ -> channel(HIDDEN) ; - -Block_comment : '/*' (Block_comment|.)*? '*/' -> channel(HIDDEN) ; // nesting comments allowed - -Line_comment : '//' .*? ('\n'|EOF) -> channel(HIDDEN) ; + : Escaped_character + | ~["\n\r\\] + ; + +fragment Escaped_character + : '\\' [0\\tnr"'] + | '\\x' Hexadecimal_digit Hexadecimal_digit + | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit '}' + | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit + Hexadecimal_digit '}' + ; + +Interpolated_string_literal + : '"' Interpolated_text_item* '"' + ; + +fragment Interpolated_text_item + : '\\(' (Interpolated_string_literal | Interpolated_text_item)+ ')' // nested strings allowed + | Quoted_text_item + ; + +WS + : [ \n\r\t\u000B\u000C\u0000]+ -> channel(HIDDEN) + ; + +Block_comment + : '/*' (Block_comment | .)*? '*/' -> channel(HIDDEN) + ; // nesting comments allowed + +Line_comment + : '//' .*? ('\n' | EOF) -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/swift/swift3/Swift3.g4 b/swift/swift3/Swift3.g4 index f335b1b39f..4a657b8916 100644 --- a/swift/swift3/Swift3.g4 +++ b/swift/swift3/Swift3.g4 @@ -29,25 +29,32 @@ * Converted from Apple's doc, http://tinyurl.com/n8rkoue, to ANTLR's * meta-language. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Swift3; -top_level : statements? EOF; +top_level + : statements? EOF + ; // Statements // GRAMMAR OF A STATEMENT statement - : expression ';'? - | declaration ';'? - | loop_statement ';'? - | branch_statement ';'? - | labeled_statement ';'? - | control_transfer_statement ';'? - | defer_statement ';'? - | do_statement ';'? - | compiler_control_statement ';'? // proper logic with semicolons is not supported yet. compiler_control_statement should be separated with a newline, but not with a semicolon - ; + : expression ';'? + | declaration ';'? + | loop_statement ';'? + | branch_statement ';'? + | labeled_statement ';'? + | control_transfer_statement ';'? + | defer_statement ';'? + | do_statement ';'? + | compiler_control_statement ';'? + // proper logic with semicolons is not supported yet. compiler_control_statement should be separated with a newline, but not with a semicolon + ; // Quote: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/statements // A semicolon (;) can optionally appear after any statement and is used to separate multiple statements if they appear on the same line. @@ -61,9 +68,9 @@ statement statements : statements_impl[-1] ; - + statements_impl[int indexBefore] -locals [ + locals[ int indexAfter = -1 ] : {SwiftSupport.isSeparatedStatement(_input, $indexBefore)}? statement {$indexAfter = _input.index();} statements_impl[$indexAfter]? @@ -71,165 +78,264 @@ locals [ // GRAMMAR OF A LOOP STATEMENT -loop_statement : for_statement - | for_in_statement - | while_statement - | repeat_while_statement - ; +loop_statement + : for_statement + | for_in_statement + | while_statement + | repeat_while_statement + ; // GRAMMAR OF A FOR STATEMENT for_statement - : 'for' for_init? ';' expression? ';' expression? code_block - | 'for' '(' for_init? ';' expression? ';' expression? ')' code_block - ; + : 'for' for_init? ';' expression? ';' expression? code_block + | 'for' '(' for_init? ';' expression? ';' expression? ')' code_block + ; -for_init : variable_declaration | expression_list ; +for_init + : variable_declaration + | expression_list + ; // GRAMMAR OF A FOR_IN STATEMENT -for_in_statement : 'for' 'case'? pattern 'in' expression where_clause? code_block ; +for_in_statement + : 'for' 'case'? pattern 'in' expression where_clause? code_block + ; // GRAMMAR OF A WHILE STATEMENT -while_statement : 'while' condition_list code_block ; +while_statement + : 'while' condition_list code_block + ; -condition_list : condition (',' condition)* ; +condition_list + : condition (',' condition)* + ; condition - : expression - | availability_condition - | case_condition - | optional_binding_condition - ; - -case_condition : 'case' pattern initializer where_clause? ; + : expression + | availability_condition + | case_condition + | optional_binding_condition + ; + +case_condition + : 'case' pattern initializer where_clause? + ; optional_binding_condition - : 'let' pattern initializer - | 'var' pattern initializer - ; + : 'let' pattern initializer + | 'var' pattern initializer + ; // GRAMMAR OF A REPEAT-WHILE STATEMENT -repeat_while_statement : 'repeat' code_block 'while' expression ; +repeat_while_statement + : 'repeat' code_block 'while' expression + ; // GRAMMAR OF A BRANCH STATEMENT -branch_statement : if_statement - | guard_statement - | switch_statement - ; +branch_statement + : if_statement + | guard_statement + | switch_statement + ; // GRAMMAR OF AN IF STATEMENT -if_statement : 'if' condition_list code_block else_clause? ; -else_clause : 'else' code_block | 'else' if_statement ; +if_statement + : 'if' condition_list code_block else_clause? + ; + +else_clause + : 'else' code_block + | 'else' if_statement + ; // GRAMMAR OF A GUARD STATEMENT -guard_statement : 'guard' condition_list 'else' code_block ; +guard_statement + : 'guard' condition_list 'else' code_block + ; // GRAMMAR OF A SWITCH STATEMENT -switch_statement : 'switch' expression '{' switch_cases? '}' ; -switch_cases : switch_case switch_cases? ; -switch_case : case_label statements | default_label statements ; -case_label : 'case' case_item_list ':' ; -case_item_list : pattern where_clause? | pattern where_clause? ',' case_item_list ; -default_label : 'default' ':' ; -where_clause : 'where' where_expression ; -where_expression : expression ; +switch_statement + : 'switch' expression '{' switch_cases? '}' + ; + +switch_cases + : switch_case switch_cases? + ; + +switch_case + : case_label statements + | default_label statements + ; + +case_label + : 'case' case_item_list ':' + ; + +case_item_list + : pattern where_clause? + | pattern where_clause? ',' case_item_list + ; + +default_label + : 'default' ':' + ; + +where_clause + : 'where' where_expression + ; + +where_expression + : expression + ; // GRAMMAR OF A LABELED STATEMENT labeled_statement - : statement_label loop_statement - | statement_label if_statement - | statement_label switch_statement - | statement_label do_statement - ; - -statement_label : label_name ':' ; -label_name : declaration_identifier ; + : statement_label loop_statement + | statement_label if_statement + | statement_label switch_statement + | statement_label do_statement + ; + +statement_label + : label_name ':' + ; + +label_name + : declaration_identifier + ; // GRAMMAR OF A CONTROL TRANSFER STATEMENT -control_transfer_statement : break_statement - | continue_statement - | fallthrough_statement - | return_statement - | throw_statement - ; +control_transfer_statement + : break_statement + | continue_statement + | fallthrough_statement + | return_statement + | throw_statement + ; // GRAMMAR OF A BREAK STATEMENT -break_statement : 'break' label_name? ; +break_statement + : 'break' label_name? + ; // GRAMMAR OF A CONTINUE STATEMENT -continue_statement : 'continue' label_name? ; +continue_statement + : 'continue' label_name? + ; // GRAMMAR OF A FALLTHROUGH STATEMENT -fallthrough_statement : 'fallthrough' ; +fallthrough_statement + : 'fallthrough' + ; // GRAMMAR OF A RETURN STATEMENT -return_statement : 'return' expression? ; +return_statement + : 'return' expression? + ; // GRAMMAR OF A THROW STATEMENT -throw_statement : 'throw' expression ; +throw_statement + : 'throw' expression + ; // GRAMMAR OF A DEFER STATEMENT -defer_statement : 'defer' code_block ; +defer_statement + : 'defer' code_block + ; // GRAMMAR OF A DO STATEMENT -do_statement : 'do' code_block catch_clauses? ; -catch_clauses : catch_clause catch_clauses? ; -catch_clause : 'catch' pattern? where_clause? code_block ; +do_statement + : 'do' code_block catch_clauses? + ; + +catch_clauses + : catch_clause catch_clauses? + ; + +catch_clause + : 'catch' pattern? where_clause? code_block + ; // GRAMMAR OF A COMPILER CONTROL STATEMENT compiler_control_statement - : conditional_compilation_block - | line_control_statement - ; - + : conditional_compilation_block + | line_control_statement + ; + // GRAMMAR OF A CONDITIONAL COMPILATION BLOCK -conditional_compilation_block : if_directive_clause elseif_directive_clauses? else_directive_clause? endif_directive ; +conditional_compilation_block + : if_directive_clause elseif_directive_clauses? else_directive_clause? endif_directive + ; + +if_directive_clause + : if_directive compilation_condition statements? + ; + +elseif_directive_clauses + : (elseif_directive_clause)+ + ; + +elseif_directive_clause + : elseif_directive compilation_condition statements? + ; + +else_directive_clause + : else_directive statements? + ; + +if_directive + : '#if' + ; -if_directive_clause : if_directive compilation_condition statements? ; +elseif_directive + : '#elseif' + ; -elseif_directive_clauses : (elseif_directive_clause)+ ; -elseif_directive_clause : elseif_directive compilation_condition statements? ; -else_directive_clause : else_directive statements? ; +else_directive + : '#else' + ; -if_directive : '#if' ; -elseif_directive : '#elseif' ; -else_directive : '#else' ; -endif_directive : '#endif' ; +endif_directive + : '#endif' + ; compilation_condition - : platform_condition - | label_identifier - | boolean_literal - | '(' compilation_condition ')' - | '!' compilation_condition - | compilation_condition compilation_condition_AND compilation_condition - | compilation_condition compilation_condition_OR compilation_condition - ; - + : platform_condition + | label_identifier + | boolean_literal + | '(' compilation_condition ')' + | '!' compilation_condition + | compilation_condition compilation_condition_AND compilation_condition + | compilation_condition compilation_condition_OR compilation_condition + ; + platform_condition - : 'os' '(' operating_system ')' - | 'arch' '(' architecture ')' - | 'swift' '(' compilation_condition_GE swift_version ')' - ; - -swift_version : Pure_decimal_digits '.' Pure_decimal_digits ; + : 'os' '(' operating_system ')' + | 'arch' '(' architecture ')' + | 'swift' '(' compilation_condition_GE swift_version ')' + ; + +swift_version + : Pure_decimal_digits '.' Pure_decimal_digits + ; // Rule from docs: // operating-system → macOS­ | iOS­ | watchOS­ | tvOS @@ -240,8 +346,13 @@ swift_version : Pure_decimal_digits '.' Pure_decimal_digits ; // "#if os(Any)" gives error that Any is not an identifier. // So I decided to use declaration_identifier -operating_system : declaration_identifier ; -architecture : declaration_identifier ; +operating_system + : declaration_identifier + ; + +architecture + : declaration_identifier + ; // These rules don't work: // operating_system : 'macOS' | 'iOS' | 'watchOS' | 'tvOS' ; @@ -262,62 +373,105 @@ architecture : declaration_identifier ; // // Modified rule: line_control_statement - : '#sourceLocation' '(' 'file' ':' file_name ',' 'line' ':' line_number ')' - | '#sourceLocation' '(' ')' - ; + : '#sourceLocation' '(' 'file' ':' file_name ',' 'line' ':' line_number ')' + | '#sourceLocation' '(' ')' + ; -line_number : integer_literal ; // TODO: A decimal integer greater than zero -file_name : Static_string_literal ; +line_number + : integer_literal + ; // TODO: A decimal integer greater than zero + +file_name + : Static_string_literal + ; // GRAMMAR OF AN AVAILABILITY CONDITION -availability_condition : '#available' '(' availability_arguments ')' ; +availability_condition + : '#available' '(' availability_arguments ')' + ; -availability_arguments : availability_argument (',' availability_argument)* ; +availability_arguments + : availability_argument (',' availability_argument)* + ; -availability_argument: Platform_name_platform_version | '*' ; +availability_argument + : Platform_name_platform_version + | '*' + ; -Platform_name_platform_version : Platform_name WS Platform_version ; +Platform_name_platform_version + : Platform_name WS Platform_version + ; -fragment -Platform_name - : 'iOS' | 'iOSApplicationExtension' - | 'macOS' | 'macOSApplicationExtension' - | 'watchOS' - | 'tvOS' - ; +fragment Platform_name + : 'iOS' + | 'iOSApplicationExtension' + | 'macOS' + | 'macOSApplicationExtension' + | 'watchOS' + | 'tvOS' + ; -fragment -Platform_version - : Pure_decimal_digits - | Pure_decimal_digits '.' Pure_decimal_digits - | Pure_decimal_digits '.' Pure_decimal_digits '.' Pure_decimal_digits - ; +fragment Platform_version + : Pure_decimal_digits + | Pure_decimal_digits '.' Pure_decimal_digits + | Pure_decimal_digits '.' Pure_decimal_digits '.' Pure_decimal_digits + ; // Generic Parameters and Arguments // GRAMMAR OF A GENERIC PARAMETER CLAUSE -generic_parameter_clause : '<' generic_parameter_list '>' ; -generic_parameter_list : generic_parameter (',' generic_parameter)* ; +generic_parameter_clause + : '<' generic_parameter_list '>' + ; + +generic_parameter_list + : generic_parameter (',' generic_parameter)* + ; + generic_parameter - : type_name - | type_name ':' type_identifier - | type_name ':' protocol_composition_type - ; + : type_name + | type_name ':' type_identifier + | type_name ':' protocol_composition_type + ; + +generic_where_clause + : 'where' requirement_list + ; + +requirement_list + : requirement (',' requirement)* + ; + +requirement + : conformance_requirement + | same_type_requirement + ; -generic_where_clause : 'where' requirement_list ; -requirement_list : requirement (',' requirement)* ; -requirement : conformance_requirement | same_type_requirement ; +conformance_requirement + : type_identifier ':' type_identifier + | type_identifier ':' protocol_composition_type + ; -conformance_requirement : type_identifier ':' type_identifier | type_identifier ':' protocol_composition_type ; -same_type_requirement : type_identifier same_type_equals type_ ; +same_type_requirement + : type_identifier same_type_equals type_ + ; // GRAMMAR OF A GENERIC ARGUMENT CLAUSE -generic_argument_clause : '<' generic_argument_list '>' ; -generic_argument_list : generic_argument (',' generic_argument)* ; -generic_argument : type_ ; +generic_argument_clause + : '<' generic_argument_list '>' + ; + +generic_argument_list + : generic_argument (',' generic_argument)* + ; + +generic_argument + : type_ + ; // context-sensitive. Allow < as pre, post, or binary op //lt : {_input.LT(1).getText().equals("<")}? operator_ ; @@ -327,370 +481,617 @@ generic_argument : type_ ; // GRAMMAR OF A DECLARATION declaration - : import_declaration - | constant_declaration - | variable_declaration - | typealias_declaration - | function_declaration - | enum_declaration - | struct_declaration - | class_declaration - | protocol_declaration - | initializer_declaration - | deinitializer_declaration - | extension_declaration - | subscript_declaration - | operator_declaration - | operator_declaration - | precedence_group_declaration - ; - -declarations : declaration+ ; + : import_declaration + | constant_declaration + | variable_declaration + | typealias_declaration + | function_declaration + | enum_declaration + | struct_declaration + | class_declaration + | protocol_declaration + | initializer_declaration + | deinitializer_declaration + | extension_declaration + | subscript_declaration + | operator_declaration + | operator_declaration + | precedence_group_declaration + ; +declarations + : declaration+ + ; // GRAMMAR OF A TOP-LEVEL DECLARATION -top_level_declaration : statements? ; +top_level_declaration + : statements? + ; // GRAMMAR OF A CODE BLOCK -code_block : '{' statements? '}' ; +code_block + : '{' statements? '}' + ; // GRAMMAR OF AN IMPORT DECLARATION -import_declaration : attributes? 'import' import_kind? import_path ; -import_kind : 'typealias' | 'struct' | 'class' | 'enum' | 'protocol' | 'var' | 'func' ; -import_path : import_path_identifier ('.' import_path_identifier)* ; -import_path_identifier : declaration_identifier | operator_ ; +import_declaration + : attributes? 'import' import_kind? import_path + ; + +import_kind + : 'typealias' + | 'struct' + | 'class' + | 'enum' + | 'protocol' + | 'var' + | 'func' + ; + +import_path + : import_path_identifier ('.' import_path_identifier)* + ; + +import_path_identifier + : declaration_identifier + | operator_ + ; // GRAMMAR OF A CONSTANT DECLARATION -constant_declaration : attributes? declaration_modifiers? 'let' pattern_initializer_list ; -pattern_initializer_list : pattern_initializer (',' pattern_initializer)* ; +constant_declaration + : attributes? declaration_modifiers? 'let' pattern_initializer_list + ; + +pattern_initializer_list + : pattern_initializer (',' pattern_initializer)* + ; /** rule is ambiguous. can match "var x = 1" with x as pattern * OR with x as expression_pattern. * ANTLR resolves in favor or first choice: pattern is x, 1 is initializer. */ -pattern_initializer : pattern initializer? ; -initializer : assignment_operator expression ; +pattern_initializer + : pattern initializer? + ; + +initializer + : assignment_operator expression + ; // GRAMMAR OF A VARIABLE DECLARATION variable_declaration - : variable_declaration_head variable_name type_annotation code_block - | variable_declaration_head variable_name type_annotation getter_setter_block - | variable_declaration_head variable_name type_annotation getter_setter_keyword_block - | variable_declaration_head variable_name type_annotation initializer? willSet_didSet_block - | variable_declaration_head variable_name type_annotation type_annotation initializer? willSet_didSet_block - | variable_declaration_head pattern_initializer_list - ; - -variable_declaration_head : attributes? declaration_modifiers? 'var' ; -variable_name : declaration_identifier ; - -getter_setter_block : '{' getter_clause setter_clause?'}' | '{' setter_clause getter_clause '}' ; -getter_clause : attributes? mutation_modifier? 'get' code_block ; -setter_clause : attributes? mutation_modifier? 'set' setter_name? code_block ; -setter_name : '(' declaration_identifier ')' ; - -getter_setter_keyword_block : '{' getter_keyword_clause setter_keyword_clause?'}' | '{' setter_keyword_clause getter_keyword_clause '}' ; -getter_keyword_clause : attributes? mutation_modifier? 'get' ; -setter_keyword_clause : attributes? mutation_modifier? 'set' ; - -willSet_didSet_block : '{' willSet_clause didSet_clause?'}' | '{' didSet_clause willSet_clause '}' ; -willSet_clause : attributes? 'willSet' setter_name? code_block ; -didSet_clause : attributes? 'didSet' setter_name? code_block ; + : variable_declaration_head variable_name type_annotation code_block + | variable_declaration_head variable_name type_annotation getter_setter_block + | variable_declaration_head variable_name type_annotation getter_setter_keyword_block + | variable_declaration_head variable_name type_annotation initializer? willSet_didSet_block + | variable_declaration_head variable_name type_annotation type_annotation initializer? willSet_didSet_block + | variable_declaration_head pattern_initializer_list + ; + +variable_declaration_head + : attributes? declaration_modifiers? 'var' + ; + +variable_name + : declaration_identifier + ; + +getter_setter_block + : '{' getter_clause setter_clause? '}' + | '{' setter_clause getter_clause '}' + ; + +getter_clause + : attributes? mutation_modifier? 'get' code_block + ; + +setter_clause + : attributes? mutation_modifier? 'set' setter_name? code_block + ; + +setter_name + : '(' declaration_identifier ')' + ; + +getter_setter_keyword_block + : '{' getter_keyword_clause setter_keyword_clause? '}' + | '{' setter_keyword_clause getter_keyword_clause '}' + ; + +getter_keyword_clause + : attributes? mutation_modifier? 'get' + ; + +setter_keyword_clause + : attributes? mutation_modifier? 'set' + ; + +willSet_didSet_block + : '{' willSet_clause didSet_clause? '}' + | '{' didSet_clause willSet_clause '}' + ; + +willSet_clause + : attributes? 'willSet' setter_name? code_block + ; + +didSet_clause + : attributes? 'didSet' setter_name? code_block + ; // GRAMMAR OF A TYPE ALIAS DECLARATION -typealias_declaration : attributes? access_level_modifier? 'typealias' typealias_name generic_parameter_clause? typealias_assignment ; -typealias_name : declaration_identifier ; -typealias_assignment : assignment_operator type_ ; +typealias_declaration + : attributes? access_level_modifier? 'typealias' typealias_name generic_parameter_clause? typealias_assignment + ; + +typealias_name + : declaration_identifier + ; + +typealias_assignment + : assignment_operator type_ + ; // GRAMMAR OF A FUNCTION DECLARATION -function_declaration : function_head function_name generic_parameter_clause? function_signature generic_where_clause? function_body? ; - -function_head : attributes? declaration_modifiers? 'func' ; +function_declaration + : function_head function_name generic_parameter_clause? function_signature generic_where_clause? function_body? + ; -function_name : declaration_identifier | operator_ ; +function_head + : attributes? declaration_modifiers? 'func' + ; + +function_name + : declaration_identifier + | operator_ + ; function_signature - : parameter_clause 'throws'? function_result? - | parameter_clause 'rethrows' function_result? - ; - -function_result : arrow_operator attributes? type_ ; + : parameter_clause 'throws'? function_result? + | parameter_clause 'rethrows' function_result? + ; + +function_result + : arrow_operator attributes? type_ + ; + +function_body + : code_block + ; -function_body : code_block ; +parameter_clause + : '(' ')' + | '(' parameter_list ')' + ; -parameter_clause : '(' ')' | '(' parameter_list ')' ; -parameter_list : parameter (',' parameter)* ; +parameter_list + : parameter (',' parameter)* + ; parameter - : external_parameter_name? local_parameter_name type_annotation default_argument_clause? - | external_parameter_name? local_parameter_name type_annotation - | external_parameter_name? local_parameter_name type_annotation range_operator - ; -external_parameter_name : label_identifier ; // TODO: Check that deleting " | '_'" doesn't break anything -local_parameter_name : label_identifier ; // TODO: Check that deleting " | '_'" doesn't break anything -default_argument_clause : assignment_operator expression ; + : external_parameter_name? local_parameter_name type_annotation default_argument_clause? + | external_parameter_name? local_parameter_name type_annotation + | external_parameter_name? local_parameter_name type_annotation range_operator + ; + +external_parameter_name + : label_identifier + ; // TODO: Check that deleting " | '_'" doesn't break anything + +local_parameter_name + : label_identifier + ; // TODO: Check that deleting " | '_'" doesn't break anything + +default_argument_clause + : assignment_operator expression + ; // GRAMMAR OF AN ENUMERATION DECLARATION -enum_declaration : attributes? access_level_modifier? union_style_enum | attributes? access_level_modifier? raw_value_style_enum ; +enum_declaration + : attributes? access_level_modifier? union_style_enum + | attributes? access_level_modifier? raw_value_style_enum + ; -union_style_enum : 'indirect'? 'enum' enum_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? '{' union_style_enum_members?'}' ; +union_style_enum + : 'indirect'? 'enum' enum_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? '{' union_style_enum_members? '}' + ; -union_style_enum_members : union_style_enum_member union_style_enum_members? ; +union_style_enum_members + : union_style_enum_member union_style_enum_members? + ; union_style_enum_member - : declaration - | union_style_enum_case_clause - | compiler_control_statement - ; + : declaration + | union_style_enum_case_clause + | compiler_control_statement + ; -union_style_enum_case_clause : attributes? 'indirect'? 'case' union_style_enum_case_list ; +union_style_enum_case_clause + : attributes? 'indirect'? 'case' union_style_enum_case_list + ; -union_style_enum_case_list : union_style_enum_case | union_style_enum_case ',' union_style_enum_case_list ; +union_style_enum_case_list + : union_style_enum_case + | union_style_enum_case ',' union_style_enum_case_list + ; -union_style_enum_case : enum_case_name tuple_type? ; +union_style_enum_case + : enum_case_name tuple_type? + ; -enum_name : declaration_identifier ; +enum_name + : declaration_identifier + ; -enum_case_name : declaration_identifier ; +enum_case_name + : declaration_identifier + ; -raw_value_style_enum : 'enum' enum_name generic_parameter_clause? type_inheritance_clause generic_where_clause? '{' raw_value_style_enum_members '}' ; +raw_value_style_enum + : 'enum' enum_name generic_parameter_clause? type_inheritance_clause generic_where_clause? '{' raw_value_style_enum_members '}' + ; -raw_value_style_enum_members : raw_value_style_enum_member raw_value_style_enum_members? ; +raw_value_style_enum_members + : raw_value_style_enum_member raw_value_style_enum_members? + ; raw_value_style_enum_member - : declaration - | raw_value_style_enum_case_clause - | compiler_control_statement - ; + : declaration + | raw_value_style_enum_case_clause + | compiler_control_statement + ; -raw_value_style_enum_case_clause : attributes? 'case' raw_value_style_enum_case_list ; +raw_value_style_enum_case_clause + : attributes? 'case' raw_value_style_enum_case_list + ; -raw_value_style_enum_case_list : raw_value_style_enum_case | raw_value_style_enum_case ',' raw_value_style_enum_case_list ; +raw_value_style_enum_case_list + : raw_value_style_enum_case + | raw_value_style_enum_case ',' raw_value_style_enum_case_list + ; -raw_value_style_enum_case : enum_case_name raw_value_assignment? ; +raw_value_style_enum_case + : enum_case_name raw_value_assignment? + ; -raw_value_assignment : assignment_operator raw_value_literal ; +raw_value_assignment + : assignment_operator raw_value_literal + ; -raw_value_literal : numeric_literal | Static_string_literal | boolean_literal ; +raw_value_literal + : numeric_literal + | Static_string_literal + | boolean_literal + ; // GRAMMAR OF A STRUCTURE DECLARATION TODO did not update -struct_declaration : attributes? access_level_modifier? 'struct' struct_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? struct_body ; -struct_name : declaration_identifier ; -struct_body : '{' struct_member* '}' ; +struct_declaration + : attributes? access_level_modifier? 'struct' struct_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? struct_body + ; + +struct_name + : declaration_identifier + ; + +struct_body + : '{' struct_member* '}' + ; -struct_member : declaration | compiler_control_statement ; +struct_member + : declaration + | compiler_control_statement + ; // GRAMMAR OF A CLASS DECLARATION class_declaration - : attributes? access_level_modifier? 'final'? 'class' class_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? class_body - | attributes? access_level_modifier? 'final' access_level_modifier? 'class' class_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? class_body - ; -class_name : declaration_identifier ; -class_body : '{' class_member* '}' ; + : attributes? access_level_modifier? 'final'? 'class' class_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? + class_body + | attributes? access_level_modifier? 'final' access_level_modifier? 'class' class_name generic_parameter_clause? type_inheritance_clause? + generic_where_clause? class_body + ; + +class_name + : declaration_identifier + ; + +class_body + : '{' class_member* '}' + ; -class_member : declaration | compiler_control_statement ; +class_member + : declaration + | compiler_control_statement + ; // GRAMMAR OF A PROTOCOL DECLARATION -protocol_declaration : attributes? access_level_modifier? 'protocol' protocol_name type_inheritance_clause? protocol_body ; -protocol_name : declaration_identifier ; -protocol_body : '{' protocol_member* '}' ; +protocol_declaration + : attributes? access_level_modifier? 'protocol' protocol_name type_inheritance_clause? protocol_body + ; + +protocol_name + : declaration_identifier + ; + +protocol_body + : '{' protocol_member* '}' + ; protocol_member - : protocol_member_declaration - | compiler_control_statement - ; + : protocol_member_declaration + | compiler_control_statement + ; protocol_member_declaration - : protocol_property_declaration - | protocol_method_declaration - | protocol_initializer_declaration - | protocol_subscript_declaration - | protocol_associated_type_declaration - | typealias_declaration - ; + : protocol_property_declaration + | protocol_method_declaration + | protocol_initializer_declaration + | protocol_subscript_declaration + | protocol_associated_type_declaration + | typealias_declaration + ; // GRAMMAR OF A PROTOCOL PROPERTY DECLARATION -protocol_property_declaration : variable_declaration_head variable_name type_annotation getter_setter_keyword_block ; +protocol_property_declaration + : variable_declaration_head variable_name type_annotation getter_setter_keyword_block + ; // GRAMMAR OF A PROTOCOL METHOD DECLARATION -protocol_method_declaration : function_head function_name generic_parameter_clause? function_signature generic_where_clause? ; +protocol_method_declaration + : function_head function_name generic_parameter_clause? function_signature generic_where_clause? + ; // GRAMMAR OF A PROTOCOL INITIALIZER DECLARATION protocol_initializer_declaration - : initializer_head generic_parameter_clause? parameter_clause 'throws'? generic_where_clause? - | initializer_head generic_parameter_clause? parameter_clause 'rethrows' generic_where_clause? - ; + : initializer_head generic_parameter_clause? parameter_clause 'throws'? generic_where_clause? + | initializer_head generic_parameter_clause? parameter_clause 'rethrows' generic_where_clause? + ; // GRAMMAR OF A PROTOCOL SUBSCRIPT DECLARATION -protocol_subscript_declaration : subscript_head subscript_result getter_setter_keyword_block ; +protocol_subscript_declaration + : subscript_head subscript_result getter_setter_keyword_block + ; // GRAMMAR OF A PROTOCOL ASSOCIATED TYPE DECLARATION -protocol_associated_type_declaration : attributes? access_level_modifier? 'associatedtype' typealias_name type_inheritance_clause? typealias_assignment? ; +protocol_associated_type_declaration + : attributes? access_level_modifier? 'associatedtype' typealias_name type_inheritance_clause? typealias_assignment? + ; // GRAMMAR OF AN INITIALIZER DECLARATION initializer_declaration - : initializer_head generic_parameter_clause? parameter_clause 'throws'? generic_where_clause? initializer_body - | initializer_head generic_parameter_clause? parameter_clause 'rethrows' generic_where_clause? initializer_body - ; + : initializer_head generic_parameter_clause? parameter_clause 'throws'? generic_where_clause? initializer_body + | initializer_head generic_parameter_clause? parameter_clause 'rethrows' generic_where_clause? initializer_body + ; initializer_head - : attributes? declaration_modifiers? 'init' - | attributes? declaration_modifiers? 'init' '?' - | attributes? declaration_modifiers? 'init' '!' - ; + : attributes? declaration_modifiers? 'init' + | attributes? declaration_modifiers? 'init' '?' + | attributes? declaration_modifiers? 'init' '!' + ; -initializer_body : code_block ; +initializer_body + : code_block + ; // GRAMMAR OF A DEINITIALIZER DECLARATION -deinitializer_declaration : attributes? 'deinit' code_block ; +deinitializer_declaration + : attributes? 'deinit' code_block + ; // GRAMMAR OF AN EXTENSION DECLARATION extension_declaration - : attributes? access_level_modifier? 'extension' type_identifier type_inheritance_clause? extension_body - | attributes? access_level_modifier? 'extension' type_identifier generic_where_clause extension_body - ; -extension_body : '{' extension_member* '}' ; + : attributes? access_level_modifier? 'extension' type_identifier type_inheritance_clause? extension_body + | attributes? access_level_modifier? 'extension' type_identifier generic_where_clause extension_body + ; + +extension_body + : '{' extension_member* '}' + ; -extension_member : declaration | compiler_control_statement ; +extension_member + : declaration + | compiler_control_statement + ; // GRAMMAR OF A SUBSCRIPT DECLARATION subscript_declaration - : subscript_head subscript_result code_block - | subscript_head subscript_result getter_setter_block - | subscript_head subscript_result getter_setter_keyword_block - ; + : subscript_head subscript_result code_block + | subscript_head subscript_result getter_setter_block + | subscript_head subscript_result getter_setter_keyword_block + ; + +subscript_head + : attributes? declaration_modifiers? 'subscript' parameter_clause + ; -subscript_head : attributes? declaration_modifiers? 'subscript' parameter_clause ; -subscript_result : arrow_operator attributes? type_ ; +subscript_result + : arrow_operator attributes? type_ + ; // GRAMMAR OF AN OPERATOR DECLARATION -operator_declaration : prefix_operator_declaration | postfix_operator_declaration | infix_operator_declaration ; +operator_declaration + : prefix_operator_declaration + | postfix_operator_declaration + | infix_operator_declaration + ; + +prefix_operator_declaration + : 'prefix' 'operator' operator_ + ; + +postfix_operator_declaration + : 'postfix' 'operator' operator_ + ; -prefix_operator_declaration : 'prefix' 'operator' operator_ ; -postfix_operator_declaration : 'postfix' 'operator' operator_ ; -infix_operator_declaration : 'infix' 'operator' operator_ infix_operator_group? ; +infix_operator_declaration + : 'infix' 'operator' operator_ infix_operator_group? + ; -infix_operator_group : ':' precedence_group_name ; +infix_operator_group + : ':' precedence_group_name + ; // GRAMMAR OF A PRECEDENCE GROUP DECLARATION -precedence_group_declaration : 'precedencegroup' precedence_group_name '{' precedence_group_attribute* '}' ; +precedence_group_declaration + : 'precedencegroup' precedence_group_name '{' precedence_group_attribute* '}' + ; precedence_group_attribute - : precedence_group_relation - | precedence_group_assignment - | precedence_group_associativity - ; + : precedence_group_relation + | precedence_group_assignment + | precedence_group_associativity + ; precedence_group_relation - : 'higherThan' ':' precedence_group_names - | 'lowerThan' ':' precedence_group_names - ; - -precedence_group_assignment : 'assignment' ':' boolean_literal ; + : 'higherThan' ':' precedence_group_names + | 'lowerThan' ':' precedence_group_names + ; + +precedence_group_assignment + : 'assignment' ':' boolean_literal + ; -precedence_group_associativity : 'associativity' ':' associativity_ ; -associativity_ : 'left' | 'right' | 'none' ; +precedence_group_associativity + : 'associativity' ':' associativity_ + ; + +associativity_ + : 'left' + | 'right' + | 'none' + ; + +precedence_group_names + : precedence_group_name (',' precedence_group_name)* + ; -precedence_group_names : precedence_group_name (',' precedence_group_name)* ; -precedence_group_name : declaration_identifier ; +precedence_group_name + : declaration_identifier + ; // GRAMMAR OF A DECLARATION MODIFIER declaration_modifier - : 'class' - | 'convenience' - | 'dynamic' - | 'final' - | 'infix' - | 'lazy' - | 'optional' - | 'override' - | 'postfix' - | 'prefix' - | 'required' - | 'static' - | 'unowned' - | 'unowned' '(' 'safe' ')' - | 'unowned' '(' 'unsafe' ')' - | 'weak' - | access_level_modifier - | mutation_modifier - ; - -declaration_modifiers : declaration_modifier+ ; + : 'class' + | 'convenience' + | 'dynamic' + | 'final' + | 'infix' + | 'lazy' + | 'optional' + | 'override' + | 'postfix' + | 'prefix' + | 'required' + | 'static' + | 'unowned' + | 'unowned' '(' 'safe' ')' + | 'unowned' '(' 'unsafe' ')' + | 'weak' + | access_level_modifier + | mutation_modifier + ; + +declaration_modifiers + : declaration_modifier+ + ; access_level_modifier - : 'private' | 'private' '(' 'set' ')' - | 'fileprivate' | 'fileprivate' '(' 'set' ')' - | 'internal' | 'internal' '(' 'set' ')' - | 'public' | 'public' '(' 'set' ')' - | 'open' | 'open' '(' 'set' ')' - ; - -mutation_modifier : 'mutating' | 'nonmutating' ; + : 'private' + | 'private' '(' 'set' ')' + | 'fileprivate' + | 'fileprivate' '(' 'set' ')' + | 'internal' + | 'internal' '(' 'set' ')' + | 'public' + | 'public' '(' 'set' ')' + | 'open' + | 'open' '(' 'set' ')' + ; + +mutation_modifier + : 'mutating' + | 'nonmutating' + ; // Patterns // GRAMMAR OF A PATTERN pattern - : wildcard_pattern type_annotation? - | identifier_pattern type_annotation? - | value_binding_pattern - | tuple_pattern type_annotation? - | enum_case_pattern - | optional_pattern - | 'is' type_ - | pattern 'as' type_ - | expression_pattern - ; + : wildcard_pattern type_annotation? + | identifier_pattern type_annotation? + | value_binding_pattern + | tuple_pattern type_annotation? + | enum_case_pattern + | optional_pattern + | 'is' type_ + | pattern 'as' type_ + | expression_pattern + ; // GRAMMAR OF A WILDCARD PATTERN -wildcard_pattern : '_' ; +wildcard_pattern + : '_' + ; // GRAMMAR OF AN IDENTIFIER PATTERN -identifier_pattern : declaration_identifier ; +identifier_pattern + : declaration_identifier + ; // GRAMMAR OF A VALUE_BINDING PATTERN -value_binding_pattern : 'var' pattern | 'let' pattern ; +value_binding_pattern + : 'var' pattern + | 'let' pattern + ; // GRAMMAR OF A TUPLE PATTERN -tuple_pattern : '(' tuple_pattern_element_list? ')' ; +tuple_pattern + : '(' tuple_pattern_element_list? ')' + ; + tuple_pattern_element_list - : tuple_pattern_element (',' tuple_pattern_element)* - ; -tuple_pattern_element : pattern ; + : tuple_pattern_element (',' tuple_pattern_element)* + ; + +tuple_pattern_element + : pattern + ; // GRAMMAR OF AN ENUMERATION CASE PATTERN -enum_case_pattern : type_identifier? '.' enum_case_name tuple_pattern? ; +enum_case_pattern + : type_identifier? '.' enum_case_name tuple_pattern? + ; // GRAMMAR OF AN OPTIONAL PATTERN -optional_pattern : identifier_pattern '?' ; +optional_pattern + : identifier_pattern '?' + ; // GRAMMAR OF A TYPE CASTING PATTERN @@ -699,17 +1100,33 @@ optional_pattern : identifier_pattern '?' ; // GRAMMAR OF AN EXPRESSION PATTERN /** Doc says "Expression patterns appear only in switch statement case labels." */ -expression_pattern : expression ; +expression_pattern + : expression + ; // Attributes // GRAMMAR OF AN ATTRIBUTE -attribute : '@' attribute_name attribute_argument_clause? ; -attribute_name : declaration_identifier ; -attribute_argument_clause : '(' balanced_tokens ')' ; -attributes : attribute+ ; -balanced_tokens : balanced_token* ; +attribute + : '@' attribute_name attribute_argument_clause? + ; + +attribute_name + : declaration_identifier + ; + +attribute_argument_clause + : '(' balanced_tokens ')' + ; + +attributes + : attribute+ + ; + +balanced_tokens + : balanced_token* + ; // https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Attributes.html#//apple_ref/swift/grammar/attributes // @@ -723,21 +1140,21 @@ balanced_tokens : balanced_token* ; // Example: @available(*, deprecated, message: "it will be removed in Swift 4.0. Please use 'Collection' instead") // Apple doesn't provide proper grammar for attributes. It says "Any punctuation except (­, )­, [­, ]­, {­, or }­". balanced_token - : '(' balanced_tokens ')' - | '[' balanced_tokens ']' - | '{' balanced_tokens '}' - | label_identifier - | literal - | operator_ - | Platform_name_platform_version // there is a kludge, see Platform_name_platform_version; it is a token - | any_punctuation_for_balanced_token - ; + : '(' balanced_tokens ')' + | '[' balanced_tokens ']' + | '{' balanced_tokens '}' + | label_identifier + | literal + | operator_ + | Platform_name_platform_version // there is a kludge, see Platform_name_platform_version; it is a token + | any_punctuation_for_balanced_token + ; // https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/swift/grammar/identifier // Quote: // The following tokens are reserved as punctuation and can’t be used as custom operators: (, ), {, }, [, ], ., ,, :, ;, =, @, #, & (as a prefix operator), ->, `, ?, and ! (as a postfix operator). -any_punctuation_for_balanced_token : - ( '.' | ',' | ':' | ';' | '=' | '@' | '#' | '`' | '?' ) +any_punctuation_for_balanced_token + : ('.' | ',' | ':' | ';' | '=' | '@' | '#' | '`' | '?') | arrow_operator | {SwiftSupport.isPrefixOp(_input)}? '&' | {SwiftSupport.isPostfixOp(_input)}? '!' @@ -746,244 +1163,298 @@ any_punctuation_for_balanced_token : // Expressions // GRAMMAR OF AN EXPRESSION -expression : try_operator? prefix_expression binary_expressions? ; +expression + : try_operator? prefix_expression binary_expressions? + ; -expression_list : expression (',' expression)* ; +expression_list + : expression (',' expression)* + ; // GRAMMAR OF A PREFIX EXPRESSION prefix_expression - : prefix_operator postfix_expression - | postfix_expression - | in_out_expression - ; + : prefix_operator postfix_expression + | postfix_expression + | in_out_expression + ; -in_out_expression : '&' declaration_identifier ; +in_out_expression + : '&' declaration_identifier + ; // GRAMMAR OF A TRY EXPRESSION -try_operator : 'try' '?' | 'try' '!' | 'try' ; +try_operator + : 'try' '?' + | 'try' '!' + | 'try' + ; // GRAMMAR OF A BINARY EXPRESSION - binary_expression - : binary_operator prefix_expression - | assignment_operator try_operator? prefix_expression - | conditional_operator try_operator? prefix_expression - | type_casting_operator - ; + : binary_operator prefix_expression + | assignment_operator try_operator? prefix_expression + | conditional_operator try_operator? prefix_expression + | type_casting_operator + ; -binary_expressions : binary_expression+ ; +binary_expressions + : binary_expression+ + ; // GRAMMAR OF A CONDITIONAL OPERATOR -conditional_operator : '?' try_operator? expression ':' ; +conditional_operator + : '?' try_operator? expression ':' + ; // GRAMMAR OF A TYPE_CASTING OPERATOR type_casting_operator - : 'is' type_ - | 'as' type_ - | 'as' '?' type_ - | 'as' '!' type_ - ; + : 'is' type_ + | 'as' type_ + | 'as' '?' type_ + | 'as' '!' type_ + ; // GRAMMAR OF A PRIMARY EXPRESSION primary_expression - : declaration_identifier generic_argument_clause? - | literal_expression - | self_expression - | superclass_expression - | closure_expression - | parenthesized_expression - | tuple_expression - | implicit_member_expression - | wildcard_expression - | selector_expression - | key_path_expression - ; + : declaration_identifier generic_argument_clause? + | literal_expression + | self_expression + | superclass_expression + | closure_expression + | parenthesized_expression + | tuple_expression + | implicit_member_expression + | wildcard_expression + | selector_expression + | key_path_expression + ; // GRAMMAR OF A LITERAL EXPRESSION literal_expression - : literal - | array_literal - | dictionary_literal - | '#file' | '#line' | '#column' | '#function' - | '#dsohandle' // Private Apple stuff. Not in docs, but in compiler and in sources of swift. - ; + : literal + | array_literal + | dictionary_literal + | '#file' + | '#line' + | '#column' + | '#function' + | '#dsohandle' // Private Apple stuff. Not in docs, but in compiler and in sources of swift. + ; -array_literal : '[' array_literal_items? ']' ; +array_literal + : '[' array_literal_items? ']' + ; array_literal_items - : array_literal_item ','? - | array_literal_item ',' array_literal_items - ; - -array_literal_item : expression ; + : array_literal_item ','? + | array_literal_item ',' array_literal_items + ; + +array_literal_item + : expression + ; dictionary_literal - : '[' dictionary_literal_items ']' - | '[' ':' ']' - ; - + : '[' dictionary_literal_items ']' + | '[' ':' ']' + ; + dictionary_literal_items - : dictionary_literal_item ','? - | dictionary_literal_item ',' dictionary_literal_items ; - -dictionary_literal_item : expression ':' expression ; + : dictionary_literal_item ','? + | dictionary_literal_item ',' dictionary_literal_items + ; + +dictionary_literal_item + : expression ':' expression + ; playground_literal - : '#colorLiteral' '(' - 'red' ':' expression ',' - 'green' ':' expression ',' - 'blue' ':' expression ',' - 'alpha' ':' expression ')' - | '#fileLiteral' '(' 'resourceName' ':' expression ')' - | '#imageLiteral' '(' 'resourceName' ':' expression ')' - ; - + : '#colorLiteral' '(' 'red' ':' expression ',' 'green' ':' expression ',' 'blue' ':' expression ',' 'alpha' ':' expression ')' + | '#fileLiteral' '(' 'resourceName' ':' expression ')' + | '#imageLiteral' '(' 'resourceName' ':' expression ')' + ; + // GRAMMAR OF A SELF EXPRESSION self_expression - : 'self' - | 'self' '.' declaration_identifier - | 'self' '[' expression_list ']' - | 'self' '.' 'init' - - // From ParseExpr.cpp. self and Self parsed with same code: - // - // case tok::kw_self: // self - // case tok::kw_Self: // Self - // Result = makeParserResult(parseExprIdentifier()); - // - // However, later something happens and Self[1], Self - // - // Example code from SetAlgebra.swift: - // - // public var isEmpty: Bool { - // return self == Self() - // } - // - // Also a valid code: - // - // return self == Self() && self == Self.init() && Self.Other() == Self.Other() - // - // So this is undocumented: - // - | 'Self' // Self() - | 'Self' '.' declaration_identifier // Self.This() - | 'Self' '.' 'init' // Self.init() - ; + : 'self' + | 'self' '.' declaration_identifier + | 'self' '[' expression_list ']' + | 'self' '.' 'init' + + // From ParseExpr.cpp. self and Self parsed with same code: + // + // case tok::kw_self: // self + // case tok::kw_Self: // Self + // Result = makeParserResult(parseExprIdentifier()); + // + // However, later something happens and Self[1], Self + // + // Example code from SetAlgebra.swift: + // + // public var isEmpty: Bool { + // return self == Self() + // } + // + // Also a valid code: + // + // return self == Self() && self == Self.init() && Self.Other() == Self.Other() + // + // So this is undocumented: + // + | 'Self' // Self() + | 'Self' '.' declaration_identifier // Self.This() + | 'Self' '.' 'init' // Self.init() + ; // GRAMMAR OF A SUPERCLASS EXPRESSION superclass_expression - : superclass_method_expression - | superclass_subscript_expression - | superclass_initializer_expression - ; + : superclass_method_expression + | superclass_subscript_expression + | superclass_initializer_expression + ; + +superclass_method_expression + : 'super' '.' declaration_identifier + ; + +superclass_subscript_expression + : 'super' '[' expression ']' + ; -superclass_method_expression : 'super' '.' declaration_identifier ; -superclass_subscript_expression : 'super' '[' expression ']' ; -superclass_initializer_expression : 'super' '.' 'init' ; +superclass_initializer_expression + : 'super' '.' 'init' + ; // GRAMMAR OF A CLOSURE EXPRESSION -closure_expression : '{' closure_signature? statements? '}' ; +closure_expression + : '{' closure_signature? statements? '}' + ; closure_signature - : capture_list? closure_parameter_clause 'throws'? function_result? 'in' - | capture_list 'in' - ; + : capture_list? closure_parameter_clause 'throws'? function_result? 'in' + | capture_list 'in' + ; closure_parameter_clause - : '(' ')' - | '(' closure_parameter_list ')' - | closure_parameter_clause_identifier_list - ; + : '(' ')' + | '(' closure_parameter_list ')' + | closure_parameter_clause_identifier_list + ; // Renamed rule "identifier_list" -closure_parameter_clause_identifier_list : declaration_identifier (',' declaration_identifier)* ; +closure_parameter_clause_identifier_list + : declaration_identifier (',' declaration_identifier)* + ; -closure_parameter_list : closure_parameter (',' closure_parameter)* ; +closure_parameter_list + : closure_parameter (',' closure_parameter)* + ; closure_parameter - : closure_parameter_name type_annotation? - | closure_parameter_name type_annotation range_operator - ; + : closure_parameter_name type_annotation? + | closure_parameter_name type_annotation range_operator + ; -closure_parameter_name : label_identifier ; +closure_parameter_name + : label_identifier + ; -capture_list : '[' capture_list_items ']' ; +capture_list + : '[' capture_list_items ']' + ; -capture_list_items : capture_list_item (',' capture_list_item)* ; +capture_list_items + : capture_list_item (',' capture_list_item)* + ; -capture_list_item : capture_specifier? expression ; +capture_list_item + : capture_specifier? expression + ; -capture_specifier : 'weak' | 'unowned' | 'unowned(safe)' | 'unowned(unsafe)' ; +capture_specifier + : 'weak' + | 'unowned' + | 'unowned(safe)' + | 'unowned(unsafe)' + ; // GRAMMAR OF A IMPLICIT MEMBER EXPRESSION -implicit_member_expression : '.' label_identifier ; // let a: MyType = .default; static let `default` = MyType() +implicit_member_expression + : '.' label_identifier + ; // let a: MyType = .default; static let `default` = MyType() // GRAMMAR OF A PARENTHESIZED EXPRESSION -parenthesized_expression : '(' expression ')' ; +parenthesized_expression + : '(' expression ')' + ; // GRAMMAR OF A TUPLE EXPRESSION tuple_expression - : '(' ')' - | '(' tuple_element (',' tuple_element)+ ')' - ; - + : '(' ')' + | '(' tuple_element (',' tuple_element)+ ')' + ; + tuple_element - : expression - | label_identifier ':' expression - ; + : expression + | label_identifier ':' expression + ; // GRAMMAR OF A WILDCARD EXPRESSION -wildcard_expression : '_' ; +wildcard_expression + : '_' + ; // GRAMMAR OF A SELECTOR EXPRESSION selector_expression - : '#selector' '(' expression ')' - | '#selector' '(' 'getter:' expression ')' - | '#selector' '(' 'setter:' expression ')' - ; - + : '#selector' '(' expression ')' + | '#selector' '(' 'getter:' expression ')' + | '#selector' '(' 'setter:' expression ')' + ; + // GRAMMAR OF A KEY-PATH EXPRESSION -key_path_expression : '#keyPath' '(' expression ')' ; +key_path_expression + : '#keyPath' '(' expression ')' + ; // GRAMMAR OF A POSTFIX EXPRESSION (inlined many rules from spec to avoid indirect left-recursion) postfix_expression - : primary_expression # primary - | postfix_expression postfix_operator # postfix_operation - | postfix_expression function_call_argument_clause # function_call_expression - | postfix_expression function_call_argument_clause? trailing_closure # function_call_expression_with_closure - | postfix_expression '.' 'init' # initializer_expression - | postfix_expression '.' 'init' '(' argument_names ')' # initializer_expression_with_args - | postfix_expression '.' Pure_decimal_digits # explicit_member_expression1 - | postfix_expression '.' declaration_identifier generic_argument_clause? # explicit_member_expression2 - | postfix_expression '.' declaration_identifier '(' argument_names ')' # explicit_member_expression3 -// This does't exist in the swift grammar, but this valid swift statement fails without it -// self.addTarget(self, action: #selector(nameOfAction(_:))) - | postfix_expression '(' argument_names ')' # explicit_member_expression4 - | postfix_expression '.' 'self' # postfix_self_expression - | dynamic_type_expression # dynamic_type - | postfix_expression '[' expression_list ']' # subscript_expression -// ! is a postfix operator already -// | postfix_expression '!' # forced_value_expression -// ? is a postfix operator already -// | postfix_expression '?' # optional_chaining_expression - ; + : primary_expression # primary + | postfix_expression postfix_operator # postfix_operation + | postfix_expression function_call_argument_clause # function_call_expression + | postfix_expression function_call_argument_clause? trailing_closure # function_call_expression_with_closure + | postfix_expression '.' 'init' # initializer_expression + | postfix_expression '.' 'init' '(' argument_names ')' # initializer_expression_with_args + | postfix_expression '.' Pure_decimal_digits # explicit_member_expression1 + | postfix_expression '.' declaration_identifier generic_argument_clause? # explicit_member_expression2 + | postfix_expression '.' declaration_identifier '(' argument_names ')' # explicit_member_expression3 + // This does't exist in the swift grammar, but this valid swift statement fails without it + // self.addTarget(self, action: #selector(nameOfAction(_:))) + | postfix_expression '(' argument_names ')' # explicit_member_expression4 + | postfix_expression '.' 'self' # postfix_self_expression + | dynamic_type_expression # dynamic_type + | postfix_expression '[' expression_list ']' # subscript_expression + // ! is a postfix operator already + // | postfix_expression '!' # forced_value_expression + // ? is a postfix operator already + // | postfix_expression '?' # optional_chaining_expression + ; // GRAMMAR OF A FUNCTION CALL EXPRESSION @@ -993,95 +1464,131 @@ postfix_expression // function-call-expression → postfix-expression­ function-call-argument-clause­?­ trailing-closure function_call_argument_clause - : '(' ')' - | '(' function_call_argument_list ')' - ; - -function_call_argument_list : function_call_argument ( ',' function_call_argument )* ; + : '(' ')' + | '(' function_call_argument_list ')' + ; + +function_call_argument_list + : function_call_argument (',' function_call_argument)* + ; function_call_argument - : expression - | label_identifier ':' expression - | operator_ - | label_identifier ':' operator_ - ; + : expression + | label_identifier ':' expression + | operator_ + | label_identifier ':' operator_ + ; -trailing_closure : closure_expression ; +trailing_closure + : closure_expression + ; // GRAMMAR OF AN EXPLICIT MEMBER EXPRESSION -argument_names : argument_name (argument_name)* ; -argument_name : label_identifier ':' ; +argument_names + : argument_name (argument_name)* + ; + +argument_name + : label_identifier ':' + ; // GRAMMAR OF A DYNAMIC TYPE EXPRESSION -dynamic_type_expression : 'type' '(' 'of' ':' expression ')' ; +dynamic_type_expression + : 'type' '(' 'of' ':' expression ')' + ; // GRAMMAR OF A TYPE type_ - : array_type #the_array_type - | dictionary_type #the_dictionary_type - | function_type #the_function_type - | type_identifier #the_type_identifier - | tuple_type #the_tuple_type - | type_ '?' #the_optional_type - | type_ '!' #the_implicitly_unwrapped_optional_type - | protocol_composition_type #the_protocol_composition_type - | type_ '.' 'Type' #the_metatype_type_type - | type_ '.' 'Protocol' #the_metatype_protocol_type - | 'Any' #the_any_type - | 'Self' #the_self_type - ; + : array_type # the_array_type + | dictionary_type # the_dictionary_type + | function_type # the_function_type + | type_identifier # the_type_identifier + | tuple_type # the_tuple_type + | type_ '?' # the_optional_type + | type_ '!' # the_implicitly_unwrapped_optional_type + | protocol_composition_type # the_protocol_composition_type + | type_ '.' 'Type' # the_metatype_type_type + | type_ '.' 'Protocol' # the_metatype_protocol_type + | 'Any' # the_any_type + | 'Self' # the_self_type + ; // GRAMMAR OF A TYPE ANNOTATION -type_annotation : ':' attributes? 'inout'? type_ ; +type_annotation + : ':' attributes? 'inout'? type_ + ; // GRAMMAR OF A TYPE IDENTIFIER -type_identifier : type_name generic_argument_clause? ('.' type_identifier)? ; +type_identifier + : type_name generic_argument_clause? ('.' type_identifier)? + ; -type_name : declaration_identifier ; +type_name + : declaration_identifier + ; // GRAMMAR OF A TUPLE TYPE -tuple_type : '(' tuple_type_element_list? ')' ; -tuple_type_element_list : tuple_type_element | tuple_type_element ',' tuple_type_element_list ; -tuple_type_element : element_name type_annotation | type_ ; -element_name : label_identifier ; +tuple_type + : '(' tuple_type_element_list? ')' + ; + +tuple_type_element_list + : tuple_type_element + | tuple_type_element ',' tuple_type_element_list + ; + +tuple_type_element + : element_name type_annotation + | type_ + ; + +element_name + : label_identifier + ; // GRAMMAR OF A FUNCTION TYPE function_type - : attributes? function_type_argument_clause 'throws'? arrow_operator type_ - | attributes? function_type_argument_clause 'rethrows' arrow_operator type_ - ; - + : attributes? function_type_argument_clause 'throws'? arrow_operator type_ + | attributes? function_type_argument_clause 'rethrows' arrow_operator type_ + ; + function_type_argument_clause - : '(' ')' - | '(' function_type_argument_list range_operator? ')' - ; - + : '(' ')' + | '(' function_type_argument_list range_operator? ')' + ; + function_type_argument_list - : function_type_argument - | function_type_argument ',' function_type_argument_list - ; - + : function_type_argument + | function_type_argument ',' function_type_argument_list + ; + function_type_argument - : attributes? 'inout'? type_ - | argument_label type_annotation - ; + : attributes? 'inout'? type_ + | argument_label type_annotation + ; -argument_label : label_identifier ; +argument_label + : label_identifier + ; // GRAMMAR OF AN ARRAY TYPE -array_type : '[' type_ ']' ; +array_type + : '[' type_ ']' + ; // GRAMMAR OF A DICTIONARY TYPE -dictionary_type : '[' type_ ':' type_ ']' ; +dictionary_type + : '[' type_ ':' type_ ']' + ; // GRAMMAR OF AN OPTIONAL TYPE @@ -1095,8 +1602,13 @@ dictionary_type : '[' type_ ':' type_ ']' ; // GRAMMAR OF A PROTOCOL COMPOSITION TYPE -protocol_composition_type : protocol_identifier ('&' protocol_identifier)+ ; -protocol_identifier : type_identifier ; +protocol_composition_type + : protocol_identifier ('&' protocol_identifier)+ + ; + +protocol_identifier + : type_identifier + ; // GRAMMAR OF A METATYPE TYPE @@ -1109,17 +1621,19 @@ protocol_identifier : type_identifier ; // GRAMMAR OF A TYPE INHERITANCE CLAUSE type_inheritance_clause - : ':' class_requirement ',' type_inheritance_list - | ':' class_requirement - | ':' type_inheritance_list - ; + : ':' class_requirement ',' type_inheritance_list + | ':' class_requirement + | ':' type_inheritance_list + ; type_inheritance_list - : type_identifier - | type_identifier ',' type_inheritance_list - ; + : type_identifier + | type_identifier ',' type_inheritance_list + ; -class_requirement : 'class' ; +class_requirement + : 'class' + ; // ---------- Lexical Structure ----------- @@ -1131,53 +1645,85 @@ class_requirement : 'class' ; // var x = 1; funx x() {}; class x {} declaration_identifier - : Identifier - | keyword_as_identifier_in_declarations - ; + : Identifier + | keyword_as_identifier_in_declarations + ; // external, internal argument name label_identifier - : Identifier - | keyword_as_identifier_in_labels - ; + : Identifier + | keyword_as_identifier_in_labels + ; Identifier - : Identifier_head Identifier_characters? - | '`' Identifier_head Identifier_characters? '`' - | Implicit_parameter_name - ; + : Identifier_head Identifier_characters? + | '`' Identifier_head Identifier_characters? '`' + | Implicit_parameter_name + ; // identifier_list : identifier (',' identifier)* ; // // identifier is context sensitive // See: closure_parameter_clause_identifier_list -fragment Identifier_head : [a-zA-Z] - | '_' - | '\u00A8' | '\u00AA' | '\u00AD' | '\u00AF' | [\u00B2-\u00B5] | [\u00B7-\u00BA] - | [\u00BC-\u00BE] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u00FF] - | [\u0100-\u02FF] | [\u0370-\u167F] | [\u1681-\u180D] | [\u180F-\u1DBF] - | [\u1E00-\u1FFF] - | [\u200B-\u200D] | [\u202A-\u202E] | [\u203F-\u2040] | '\u2054' | [\u2060-\u206F] - | [\u2070-\u20CF] | [\u2100-\u218F] | [\u2460-\u24FF] | [\u2776-\u2793] - | [\u2C00-\u2DFF] | [\u2E80-\u2FFF] - | [\u3004-\u3007] | [\u3021-\u302F] | [\u3031-\u303F] | [\u3040-\uD7FF] - | [\uF900-\uFD3D] | [\uFD40-\uFDCF] | [\uFDF0-\uFE1F] | [\uFE30-\uFE44] - | [\uFE47-\uFFFD] -/* +fragment Identifier_head + : [a-zA-Z] + | '_' + | '\u00A8' + | '\u00AA' + | '\u00AD' + | '\u00AF' + | [\u00B2-\u00B5] + | [\u00B7-\u00BA] + | [\u00BC-\u00BE] + | [\u00C0-\u00D6] + | [\u00D8-\u00F6] + | [\u00F8-\u00FF] + | [\u0100-\u02FF] + | [\u0370-\u167F] + | [\u1681-\u180D] + | [\u180F-\u1DBF] + | [\u1E00-\u1FFF] + | [\u200B-\u200D] + | [\u202A-\u202E] + | [\u203F-\u2040] + | '\u2054' + | [\u2060-\u206F] + | [\u2070-\u20CF] + | [\u2100-\u218F] + | [\u2460-\u24FF] + | [\u2776-\u2793] + | [\u2C00-\u2DFF] + | [\u2E80-\u2FFF] + | [\u3004-\u3007] + | [\u3021-\u302F] + | [\u3031-\u303F] + | [\u3040-\uD7FF] + | [\uF900-\uFD3D] + | [\uFD40-\uFDCF] + | [\uFDF0-\uFE1F] + | [\uFE30-\uFE44] + | [\uFE47-\uFFFD] + /* | U+10000-U+1FFFD | U+20000-U+2FFFD | U+30000-U+3FFFD | U+40000-U+4FFFD | U+50000-U+5FFFD | U+60000-U+6FFFD | U+70000-U+7FFFD | U+80000-U+8FFFD | U+90000-U+9FFFD | U+A0000-U+AFFFD | U+B0000-U+BFFFD | U+C0000-U+CFFFD | U+D0000-U+DFFFD or U+E0000-U+EFFFD */ - ; + ; -fragment Identifier_character : [0-9] - | [\u0300-\u036F] | [\u1DC0-\u1DFF] | [\u20D0-\u20FF] | [\uFE20-\uFE2F] - | Identifier_head - ; +fragment Identifier_character + : [0-9] + | [\u0300-\u036F] + | [\u1DC0-\u1DFF] + | [\u20D0-\u20FF] + | [\uFE20-\uFE2F] + | Identifier_head + ; -fragment Identifier_characters : Identifier_character+ ; +fragment Identifier_characters + : Identifier_character+ + ; // Keywords reserved in particular contexts: associativity, convenience, dynamic, didSet, final, get, infix, indirect, lazy, left, mutating, none, nonmutating, optional, override, postfix, precedence, prefix, Protocol, required, right, set, Type, unowned, weak, and willSet. Outside the context in which they appear in the grammar, they can be used as identifiers. // context_sensitive_keyword : @@ -1190,179 +1736,179 @@ fragment Identifier_characters : Identifier_character+ ; // | 'weak' | 'willSet' // // ^- this does not work. "[10].index(of: 10)". "of" is a keyword. "type(of: self)" - - // Added by myself. - // Tested all alphanumeric tokens in playground. - // E.g. "let mutating = 1". - // E.g. "func mutating() {}". - // - // In source code of swift there are multiple cases of error diag::keyword_cant_be_identifier. - // Maybe it is not even a single error when keyword can't be identifier. - // + +// Added by myself. +// Tested all alphanumeric tokens in playground. +// E.g. "let mutating = 1". +// E.g. "func mutating() {}". +// +// In source code of swift there are multiple cases of error diag::keyword_cant_be_identifier. +// Maybe it is not even a single error when keyword can't be identifier. +// keyword_as_identifier_in_declarations -: 'Protocol' -| 'Type' -| 'alpha' -| 'arch' -| 'arm' -| 'arm64' -| 'assignment' -| 'associativity' -| 'blue' -| 'convenience' -| 'didSet' -| 'dynamic' -| 'file' -| 'final' -| 'get' -| 'green' -| 'higherThan' -| 'i386' -| 'iOS' -| 'iOSApplicationExtension' -| 'indirect' -| 'infix' -| 'lazy' -| 'left' -| 'line' -| 'lowerThan' -| 'macOS' -| 'macOSApplicationExtension' -| 'mutating' -| 'none' -| 'nonmutating' -| 'of' -| 'open' -| 'optional' -| 'os' -| 'override' -| 'postfix' -| 'precedence' -| 'prefix' -| 'red' -| 'required' -| 'resourceName' -| 'right' -| 'safe' -| 'set' -| 'swift' -| 'tvOS' -| 'type' -| 'unowned' -| 'unsafe' -| 'watchOS' -| 'weak' -| 'willSet' -| 'x86_64' -; + : 'Protocol' + | 'Type' + | 'alpha' + | 'arch' + | 'arm' + | 'arm64' + | 'assignment' + | 'associativity' + | 'blue' + | 'convenience' + | 'didSet' + | 'dynamic' + | 'file' + | 'final' + | 'get' + | 'green' + | 'higherThan' + | 'i386' + | 'iOS' + | 'iOSApplicationExtension' + | 'indirect' + | 'infix' + | 'lazy' + | 'left' + | 'line' + | 'lowerThan' + | 'macOS' + | 'macOSApplicationExtension' + | 'mutating' + | 'none' + | 'nonmutating' + | 'of' + | 'open' + | 'optional' + | 'os' + | 'override' + | 'postfix' + | 'precedence' + | 'prefix' + | 'red' + | 'required' + | 'resourceName' + | 'right' + | 'safe' + | 'set' + | 'swift' + | 'tvOS' + | 'type' + | 'unowned' + | 'unsafe' + | 'watchOS' + | 'weak' + | 'willSet' + | 'x86_64' + ; // func x(Any: Any) keyword_as_identifier_in_labels -: 'Any' -| 'Protocol' -| 'Self' -| 'Type' -| 'alpha' -| 'arch' -| 'arm' -| 'arm64' -| 'as' -| 'assignment' -| 'associatedtype' -| 'associativity' -| 'blue' -| 'break' -| 'case' -| 'catch' -| 'class' -| 'continue' -| 'convenience' -| 'default' -| 'defer' -| 'deinit' -| 'didSet' -| 'do' -| 'dynamic' -| 'else' -| 'enum' -| 'extension' -| 'fallthrough' -| 'false' -| 'file' -| 'fileprivate' -| 'final' -| 'for' -| 'func' -| 'get' -| 'green' -| 'guard' -| 'higherThan' -| 'i386' -| 'iOS' -| 'iOSApplicationExtension' -| 'if' -| 'import' -| 'in' -| 'indirect' -| 'infix' -| 'init' -| 'internal' -| 'is' -| 'lazy' -| 'left' -| 'line' -| 'lowerThan' -| 'macOS' -| 'macOSApplicationExtension' -| 'mutating' -| 'nil' -| 'none' -| 'nonmutating' -| 'of' -| 'open' -| 'operator' -| 'optional' -| 'os' -| 'override' -| 'postfix' -| 'precedence' -| 'precedencegroup' -| 'prefix' -| 'private' -| 'protocol' -| 'public' -| 'red' -| 'repeat' -| 'required' -| 'resourceName' -| 'rethrows' -| 'return' -| 'right' -| 'safe' -| 'self' -| 'set' -| 'static' -| 'struct' -| 'subscript' -| 'super' -| 'swift' -| 'switch' -| 'throw' -| 'throws' -| 'true' -| 'try' -| 'tvOS' -| 'type' -| 'typealias' -| 'unowned' -| 'unsafe' -| 'watchOS' -| 'weak' -| 'where' -| 'while' -| 'willSet' -| 'x86_64' - ; + : 'Any' + | 'Protocol' + | 'Self' + | 'Type' + | 'alpha' + | 'arch' + | 'arm' + | 'arm64' + | 'as' + | 'assignment' + | 'associatedtype' + | 'associativity' + | 'blue' + | 'break' + | 'case' + | 'catch' + | 'class' + | 'continue' + | 'convenience' + | 'default' + | 'defer' + | 'deinit' + | 'didSet' + | 'do' + | 'dynamic' + | 'else' + | 'enum' + | 'extension' + | 'fallthrough' + | 'false' + | 'file' + | 'fileprivate' + | 'final' + | 'for' + | 'func' + | 'get' + | 'green' + | 'guard' + | 'higherThan' + | 'i386' + | 'iOS' + | 'iOSApplicationExtension' + | 'if' + | 'import' + | 'in' + | 'indirect' + | 'infix' + | 'init' + | 'internal' + | 'is' + | 'lazy' + | 'left' + | 'line' + | 'lowerThan' + | 'macOS' + | 'macOSApplicationExtension' + | 'mutating' + | 'nil' + | 'none' + | 'nonmutating' + | 'of' + | 'open' + | 'operator' + | 'optional' + | 'os' + | 'override' + | 'postfix' + | 'precedence' + | 'precedencegroup' + | 'prefix' + | 'private' + | 'protocol' + | 'public' + | 'red' + | 'repeat' + | 'required' + | 'resourceName' + | 'rethrows' + | 'return' + | 'right' + | 'safe' + | 'self' + | 'set' + | 'static' + | 'struct' + | 'subscript' + | 'super' + | 'swift' + | 'switch' + | 'throw' + | 'throws' + | 'true' + | 'try' + | 'tvOS' + | 'type' + | 'typealias' + | 'unowned' + | 'unsafe' + | 'watchOS' + | 'weak' + | 'where' + | 'while' + | 'willSet' + | 'x86_64' + ; // GRAMMAR OF OPERATORS @@ -1416,60 +1962,162 @@ From doc on operators: /* these following tokens are also a Binary_operator so much come first as special case */ -assignment_operator : {SwiftSupport.isBinaryOp(_input)}? '=' ; - -DOT : '.' ; -LCURLY : '{' ; -LPAREN : '(' ; -LBRACK : '[' ; -RCURLY : '}' ; -RPAREN : ')' ; -RBRACK : ']' ; -COMMA : ',' ; -COLON : ':' ; -SEMI : ';' ; -LT : '<' ; -GT : '>' ; -UNDERSCORE : '_' ; -BANG : '!' ; -QUESTION: '?' ; -AT : '@' ; -AND : '&' ; -SUB : '-' ; -EQUAL : '=' ; -OR : '|' ; -DIV : '/' ; -ADD : '+' ; -MUL : '*' ; -MOD : '%' ; -CARET : '^' ; -TILDE : '~' ; +assignment_operator + : {SwiftSupport.isBinaryOp(_input)}? '=' + ; + +DOT + : '.' + ; + +LCURLY + : '{' + ; + +LPAREN + : '(' + ; + +LBRACK + : '[' + ; + +RCURLY + : '}' + ; + +RPAREN + : ')' + ; + +RBRACK + : ']' + ; + +COMMA + : ',' + ; + +COLON + : ':' + ; + +SEMI + : ';' + ; + +LT + : '<' + ; + +GT + : '>' + ; + +UNDERSCORE + : '_' + ; + +BANG + : '!' + ; + +QUESTION + : '?' + ; + +AT + : '@' + ; + +AND + : '&' + ; + +SUB + : '-' + ; + +EQUAL + : '=' + ; + +OR + : '|' + ; + +DIV + : '/' + ; + +ADD + : '+' + ; + +MUL + : '*' + ; + +MOD + : '%' + ; + +CARET + : '^' + ; + +TILDE + : '~' + ; /** Need to separate this out from Prefix_operator as it's referenced in numeric_literal * as specifically a negation prefix op. */ -negate_prefix_operator : {SwiftSupport.isPrefixOp(_input)}? '-'; +negate_prefix_operator + : {SwiftSupport.isPrefixOp(_input)}? '-' + ; + +compilation_condition_AND + : {SwiftSupport.isOperator(_input,"&&")}? '&' '&' + ; + +compilation_condition_OR + : {SwiftSupport.isOperator(_input,"||")}? '|' '|' + ; + +compilation_condition_GE + : {SwiftSupport.isOperator(_input,">=")}? '>' '=' + ; -compilation_condition_AND : {SwiftSupport.isOperator(_input,"&&")}? '&' '&' ; -compilation_condition_OR : {SwiftSupport.isOperator(_input,"||")}? '|' '|' ; -compilation_condition_GE : {SwiftSupport.isOperator(_input,">=")}? '>' '=' ; -arrow_operator : {SwiftSupport.isOperator(_input,"->")}? '-' '>' ; -range_operator : {SwiftSupport.isOperator(_input,"...")}? '.' '.' '.' ; -same_type_equals: {SwiftSupport.isOperator(_input,"==")}? '=' '=' ; +arrow_operator + : {SwiftSupport.isOperator(_input,"->")}? '-' '>' + ; + +range_operator + : {SwiftSupport.isOperator(_input,"...")}? '.' '.' '.' + ; + +same_type_equals + : {SwiftSupport.isOperator(_input,"==")}? '=' '=' + ; /** "If an operator has whitespace around both sides or around neither side, it is treated as a binary operator. As an example, the + operator in a+b and a + b is treated as a binary operator." */ -binary_operator : {SwiftSupport.isBinaryOp(_input)}? operator_ ; +binary_operator + : {SwiftSupport.isBinaryOp(_input)}? operator_ + ; /** "If an operator has whitespace on the left side only, it is treated as a prefix unary operator. As an example, the ++ operator in a ++b is treated as a prefix unary operator." */ -prefix_operator : {SwiftSupport.isPrefixOp(_input)}? operator_ ; +prefix_operator + : {SwiftSupport.isPrefixOp(_input)}? operator_ + ; /** "If an operator has whitespace on the right side only, it is treated as a @@ -1481,143 +2129,264 @@ prefix_operator : {SwiftSupport.isPrefixOp(_input)}? operator_ ; the ++ operator in a++.b is treated as a postfix unary operator (a++ .b rather than a ++ .b)." */ -postfix_operator : {SwiftSupport.isPostfixOp(_input)}? operator_ ; +postfix_operator + : {SwiftSupport.isPostfixOp(_input)}? operator_ + ; operator_ - : operator_head ({_input.get(_input.index()-1).getType()!=WS}? operator_character)* - | dot_operator_head ({_input.get(_input.index()-1).getType()!=WS}? dot_operator_character)* - ; + : operator_head ({_input.get(_input.index()-1).getType()!=WS}? operator_character)* + | dot_operator_head ({_input.get(_input.index()-1).getType()!=WS}? dot_operator_character)* + ; operator_character - : operator_head - | Operator_following_character - ; + : operator_head + | Operator_following_character + ; operator_head - : ('/' | '=' | '-' | '+' | '!' | '*' | '%' | '&' | '|' | '<' | '>' | '^' | '~' | '?') // wrapping in (..) makes it a fast set comparison - | Operator_head_other - ; + : ( + '/' + | '=' + | '-' + | '+' + | '!' + | '*' + | '%' + | '&' + | '|' + | '<' + | '>' + | '^' + | '~' + | '?' + ) // wrapping in (..) makes it a fast set comparison + | Operator_head_other + ; Operator_head_other // valid operator chars not used by Swift itself - : [\u00A1-\u00A7] - | [\u00A9\u00AB] - | [\u00AC\u00AE] - | [\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7] - | [\u2016-\u2017\u2020-\u2027] - | [\u2030-\u203E] - | [\u2041-\u2053] - | [\u2055-\u205E] - | [\u2190-\u23FF] - | [\u2500-\u2775] - | [\u2794-\u2BFF] - | [\u2E00-\u2E7F] - | [\u3001-\u3003] - | [\u3008-\u3030] - ; + : [\u00A1-\u00A7] + | [\u00A9\u00AB] + | [\u00AC\u00AE] + | [\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7] + | [\u2016-\u2017\u2020-\u2027] + | [\u2030-\u203E] + | [\u2041-\u2053] + | [\u2055-\u205E] + | [\u2190-\u23FF] + | [\u2500-\u2775] + | [\u2794-\u2BFF] + | [\u2E00-\u2E7F] + | [\u3001-\u3003] + | [\u3008-\u3030] + ; Operator_following_character - : [\u0300-\u036F] - | [\u1DC0-\u1DFF] - | [\u20D0-\u20FF] - | [\uFE00-\uFE0F] - | [\uFE20-\uFE2F] - //| [\uE0100-\uE01EF] ANTLR can't do >16bit char - ; + : [\u0300-\u036F] + | [\u1DC0-\u1DFF] + | [\u20D0-\u20FF] + | [\uFE00-\uFE0F] + | [\uFE20-\uFE2F] + //| [\uE0100-\uE01EF] ANTLR can't do >16bit char + ; + +dot_operator_head + : '.' + ; -dot_operator_head : '.' ; -dot_operator_character : '.' | operator_character ; +dot_operator_character + : '.' + | operator_character + ; -Implicit_parameter_name : '$' Pure_decimal_digits ; +Implicit_parameter_name + : '$' Pure_decimal_digits + ; // GRAMMAR OF A LITERAL -literal : numeric_literal | string_literal | boolean_literal | nil_literal ; +literal + : numeric_literal + | string_literal + | boolean_literal + | nil_literal + ; numeric_literal - : negate_prefix_operator? integer_literal - | negate_prefix_operator? Floating_point_literal - ; + : negate_prefix_operator? integer_literal + | negate_prefix_operator? Floating_point_literal + ; -boolean_literal : 'true' | 'false' ; +boolean_literal + : 'true' + | 'false' + ; -nil_literal : 'nil' ; +nil_literal + : 'nil' + ; // GRAMMAR OF AN INTEGER LITERAL integer_literal - : Binary_literal - | Octal_literal - | Decimal_literal - | Pure_decimal_digits - | Hexadecimal_literal - ; - -Binary_literal : '0b' Binary_digit Binary_literal_characters? ; -fragment Binary_digit : [01] ; -fragment Binary_literal_character : Binary_digit | '_' ; -fragment Binary_literal_characters : Binary_literal_character+ ; - -Octal_literal : '0o' Octal_digit Octal_literal_characters? ; -fragment Octal_digit : [0-7] ; -fragment Octal_literal_character : Octal_digit | '_' ; -fragment Octal_literal_characters : Octal_literal_character+ ; - -Decimal_literal : [0-9] [0-9_]* ; -Pure_decimal_digits : [0-9]+ ; -fragment Decimal_digit : [0-9] ; -fragment Decimal_literal_character : Decimal_digit | '_' ; -fragment Decimal_literal_characters : Decimal_literal_character+ ; - -Hexadecimal_literal : '0x' Hexadecimal_digit Hexadecimal_literal_characters? ; -fragment Hexadecimal_digit : [0-9a-fA-F] ; -fragment Hexadecimal_literal_character : Hexadecimal_digit | '_' ; -fragment Hexadecimal_literal_characters : Hexadecimal_literal_character+ ; + : Binary_literal + | Octal_literal + | Decimal_literal + | Pure_decimal_digits + | Hexadecimal_literal + ; + +Binary_literal + : '0b' Binary_digit Binary_literal_characters? + ; + +fragment Binary_digit + : [01] + ; + +fragment Binary_literal_character + : Binary_digit + | '_' + ; + +fragment Binary_literal_characters + : Binary_literal_character+ + ; + +Octal_literal + : '0o' Octal_digit Octal_literal_characters? + ; + +fragment Octal_digit + : [0-7] + ; + +fragment Octal_literal_character + : Octal_digit + | '_' + ; + +fragment Octal_literal_characters + : Octal_literal_character+ + ; + +Decimal_literal + : [0-9] [0-9_]* + ; + +Pure_decimal_digits + : [0-9]+ + ; + +fragment Decimal_digit + : [0-9] + ; + +fragment Decimal_literal_character + : Decimal_digit + | '_' + ; + +fragment Decimal_literal_characters + : Decimal_literal_character+ + ; + +Hexadecimal_literal + : '0x' Hexadecimal_digit Hexadecimal_literal_characters? + ; + +fragment Hexadecimal_digit + : [0-9a-fA-F] + ; + +fragment Hexadecimal_literal_character + : Hexadecimal_digit + | '_' + ; + +fragment Hexadecimal_literal_characters + : Hexadecimal_literal_character+ + ; // GRAMMAR OF A FLOATING_POINT LITERAL Floating_point_literal - : Decimal_literal Decimal_fraction? Decimal_exponent? - | Hexadecimal_literal Hexadecimal_fraction? Hexadecimal_exponent - ; -fragment Decimal_fraction : '.' Decimal_literal ; -fragment Decimal_exponent : Floating_point_e Sign? Decimal_literal ; -fragment Hexadecimal_fraction : '.' Hexadecimal_digit Hexadecimal_literal_characters? ; -fragment Hexadecimal_exponent : Floating_point_p Sign? Decimal_literal ; -fragment Floating_point_e : [eE] ; -fragment Floating_point_p : [pP] ; -fragment Sign : [+\-] ; + : Decimal_literal Decimal_fraction? Decimal_exponent? + | Hexadecimal_literal Hexadecimal_fraction? Hexadecimal_exponent + ; + +fragment Decimal_fraction + : '.' Decimal_literal + ; + +fragment Decimal_exponent + : Floating_point_e Sign? Decimal_literal + ; + +fragment Hexadecimal_fraction + : '.' Hexadecimal_digit Hexadecimal_literal_characters? + ; + +fragment Hexadecimal_exponent + : Floating_point_p Sign? Decimal_literal + ; + +fragment Floating_point_e + : [eE] + ; + +fragment Floating_point_p + : [pP] + ; + +fragment Sign + : [+\-] + ; // GRAMMAR OF A STRING LITERAL string_literal - : Static_string_literal - | Interpolated_string_literal - ; + : Static_string_literal + | Interpolated_string_literal + ; + +Static_string_literal + : '"' Quoted_text? '"' + ; + +fragment Quoted_text + : Quoted_text_item+ + ; -Static_string_literal : '"' Quoted_text? '"' ; -fragment Quoted_text : Quoted_text_item+ ; fragment Quoted_text_item - : Escaped_character - | ~["\n\r\\] - ; - -fragment -Escaped_character - : '\\' [0\\tnr"'] - | '\\x' Hexadecimal_digit Hexadecimal_digit - | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit '}' - | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit '}' - ; - -Interpolated_string_literal : '"' Interpolated_text_item* '"' ; -fragment -Interpolated_text_item - : '\\(' (Interpolated_string_literal | Interpolated_text_item)+ ')' // nested strings allowed - | Quoted_text_item - ; - -WS : [ \n\r\t\u000B\u000C\u0000]+ -> channel(HIDDEN) ; - -Block_comment : '/*' (Block_comment|.)*? '*/' -> channel(HIDDEN) ; // nesting comments allowed - -Line_comment : '//' .*? ('\n'|EOF) -> channel(HIDDEN) ; + : Escaped_character + | ~["\n\r\\] + ; + +fragment Escaped_character + : '\\' [0\\tnr"'] + | '\\x' Hexadecimal_digit Hexadecimal_digit + | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit '}' + | '\\u' '{' Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit Hexadecimal_digit + Hexadecimal_digit '}' + ; + +Interpolated_string_literal + : '"' Interpolated_text_item* '"' + ; + +fragment Interpolated_text_item + : '\\(' (Interpolated_string_literal | Interpolated_text_item)+ ')' // nested strings allowed + | Quoted_text_item + ; + +WS + : [ \n\r\t\u000B\u000C\u0000]+ -> channel(HIDDEN) + ; + +Block_comment + : '/*' (Block_comment | .)*? '*/' -> channel(HIDDEN) + ; // nesting comments allowed + +Line_comment + : '//' .*? ('\n' | EOF) -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/swift/swift5/Swift5Lexer.g4 b/swift/swift5/Swift5Lexer.g4 index e2ffad2d7e..a4622936ec 100644 --- a/swift/swift5/Swift5Lexer.g4 +++ b/swift/swift5/Swift5Lexer.g4 @@ -1,218 +1,224 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar Swift5Lexer; // Insert here @header for C++ lexer. options { - superClass = SwiftSupportLexer; + superClass = SwiftSupportLexer; } -AS: 'as'; -ALPHA: 'alpha'; -BREAK: 'break'; -CASE: 'case'; -CATCH: 'catch'; -CLASS: 'class'; -CONTINUE: 'continue'; -DEFAULT: 'default'; -DEFER: 'defer'; -DO: 'do'; -GUARD: 'guard'; -ELSE: 'else'; -ENUM: 'enum'; -FOR: 'for'; -FALLTHROUGH: 'fallthrough'; -FUNC: 'func'; -IN: 'in'; -IF: 'if'; -IMPORT: 'import'; -INTERNAL: 'internal'; -FINAL: 'final'; -OPEN: 'open'; -PRIVATE: 'private'; -PUBLIC: 'public'; -WHERE: 'where'; -WHILE: 'while'; -LET: 'let'; -VAR: 'var'; -PROTOCOL: 'protocol'; -GET: 'get'; -SET: 'set'; -WILL_SET: 'willSet'; -DID_SET: 'didSet'; -REPEAT: 'repeat'; -SWITCH: 'switch'; -STRUCT: 'struct'; -RETURN: 'return'; -THROW: 'throw'; -THROWS: 'throws'; -RETHROWS: 'rethrows'; -INDIRECT: 'indirect'; -INIT: 'init'; -DEINIT: 'deinit'; -ASSOCIATED_TYPE: 'associatedtype'; -EXTENSION: 'extension'; -SUBSCRIPT: 'subscript'; -PREFIX: 'prefix'; -INFIX: 'infix'; -LEFT: 'left'; -RIGHT: 'right'; -NONE: 'none'; -PRECEDENCE_GROUP: 'precedencegroup'; -HIGHER_THAN: 'higherThan'; -LOWER_THAN: 'lowerThan'; -ASSIGNMENT: 'assignment'; -ASSOCIATIVITY: 'associativity'; -POSTFIX: 'postfix'; -OPERATOR: 'operator'; -TYPEALIAS: 'typealias'; -OS: 'os'; -ARCH: 'arch'; -SWIFT: 'swift'; -COMPILER: 'compiler'; -CAN_IMPORT: 'canImport'; -TARGET_ENVIRONMENT: 'targetEnvironment'; -CONVENIENCE: 'convenience'; -DYNAMIC: 'dynamic'; -LAZY: 'lazy'; -OPTIONAL: 'optional'; -OVERRIDE: 'override'; -REQUIRED: 'required'; -STATIC: 'static'; -WEAK: 'weak'; -UNOWNED: 'unowned'; -SAFE: 'safe'; -UNSAFE: 'unsafe'; -MUTATING: 'mutating'; -NONMUTATING: 'nonmutating'; -FILE_PRIVATE: 'fileprivate'; -IS: 'is'; -TRY: 'try'; -SUPER: 'super'; -ANY: 'Any'; -FALSE: 'false'; -RED: 'red'; -BLUE: 'blue'; -GREEN: 'green'; -RESOURCE_NAME: 'resourceName'; -TRUE: 'true'; -NIL: 'nil'; -INOUT: 'inout'; -SOME: 'some'; -TYPE: 'Type'; -PRECEDENCE: 'precedence'; -SELF: 'self'; -SELF_BIG: 'Self'; - -MAC_OS: 'macOS'; -I_OS: 'iOS'; -OSX: 'OSX'; -WATCH_OS: 'watchOS'; -TV_OS: 'tvOS'; -LINUX: 'Linux'; -WINDOWS: 'Windows'; - -I386: 'i386'; -X86_64: 'x86_64'; -ARM: 'arm'; -ARM64: 'arm64'; - -SIMULATOR: 'simulator'; -MAC_CATALYST: 'macCatalyst'; - -I_OS_APPLICATION_EXTENSION: 'iOSApplicationExtension'; -MAC_CATALYST_APPLICATION_EXTENSION: - 'macCatalystApplicationExtension'; -MAC_OS_APPLICATION_EXTENSION: 'macOSApplicationExtension'; -SOURCE_LOCATION: '#sourceLocation'; - -FILE: 'file'; -LINE: 'line'; -ERROR: '#error'; -WARNING: '#warning'; -AVAILABLE: '#available'; - -HASH_IF: '#if'; -HASH_ELSEIF: '#elseif'; -HASH_ELSE: '#else'; -HASH_ENDIF: '#endif'; -HASH_FILE: '#file'; -HASH_FILE_ID: '#fileID'; -HASH_FILE_PATH: '#filePath'; -HASH_LINE: '#line'; -HASH_COLUMN: '#column'; -HASH_FUNCTION: '#function'; -HASH_DSO_HANDLE: '#dsohandle'; -HASH_SELECTOR: '#selector'; -HASH_KEYPATH: '#keyPath'; -HASH_COLOR_LITERAL: '#colorLiteral'; -HASH_FILE_LITERAL: '#fileLiteral'; -HASH_IMAGE_LITERAL: '#imageLiteral'; -GETTER: 'getter'; -SETTER: 'setter'; +AS : 'as'; +ALPHA : 'alpha'; +BREAK : 'break'; +CASE : 'case'; +CATCH : 'catch'; +CLASS : 'class'; +CONTINUE : 'continue'; +DEFAULT : 'default'; +DEFER : 'defer'; +DO : 'do'; +GUARD : 'guard'; +ELSE : 'else'; +ENUM : 'enum'; +FOR : 'for'; +FALLTHROUGH : 'fallthrough'; +FUNC : 'func'; +IN : 'in'; +IF : 'if'; +IMPORT : 'import'; +INTERNAL : 'internal'; +FINAL : 'final'; +OPEN : 'open'; +PRIVATE : 'private'; +PUBLIC : 'public'; +WHERE : 'where'; +WHILE : 'while'; +LET : 'let'; +VAR : 'var'; +PROTOCOL : 'protocol'; +GET : 'get'; +SET : 'set'; +WILL_SET : 'willSet'; +DID_SET : 'didSet'; +REPEAT : 'repeat'; +SWITCH : 'switch'; +STRUCT : 'struct'; +RETURN : 'return'; +THROW : 'throw'; +THROWS : 'throws'; +RETHROWS : 'rethrows'; +INDIRECT : 'indirect'; +INIT : 'init'; +DEINIT : 'deinit'; +ASSOCIATED_TYPE : 'associatedtype'; +EXTENSION : 'extension'; +SUBSCRIPT : 'subscript'; +PREFIX : 'prefix'; +INFIX : 'infix'; +LEFT : 'left'; +RIGHT : 'right'; +NONE : 'none'; +PRECEDENCE_GROUP : 'precedencegroup'; +HIGHER_THAN : 'higherThan'; +LOWER_THAN : 'lowerThan'; +ASSIGNMENT : 'assignment'; +ASSOCIATIVITY : 'associativity'; +POSTFIX : 'postfix'; +OPERATOR : 'operator'; +TYPEALIAS : 'typealias'; +OS : 'os'; +ARCH : 'arch'; +SWIFT : 'swift'; +COMPILER : 'compiler'; +CAN_IMPORT : 'canImport'; +TARGET_ENVIRONMENT : 'targetEnvironment'; +CONVENIENCE : 'convenience'; +DYNAMIC : 'dynamic'; +LAZY : 'lazy'; +OPTIONAL : 'optional'; +OVERRIDE : 'override'; +REQUIRED : 'required'; +STATIC : 'static'; +WEAK : 'weak'; +UNOWNED : 'unowned'; +SAFE : 'safe'; +UNSAFE : 'unsafe'; +MUTATING : 'mutating'; +NONMUTATING : 'nonmutating'; +FILE_PRIVATE : 'fileprivate'; +IS : 'is'; +TRY : 'try'; +SUPER : 'super'; +ANY : 'Any'; +FALSE : 'false'; +RED : 'red'; +BLUE : 'blue'; +GREEN : 'green'; +RESOURCE_NAME : 'resourceName'; +TRUE : 'true'; +NIL : 'nil'; +INOUT : 'inout'; +SOME : 'some'; +TYPE : 'Type'; +PRECEDENCE : 'precedence'; +SELF : 'self'; +SELF_BIG : 'Self'; + +MAC_OS : 'macOS'; +I_OS : 'iOS'; +OSX : 'OSX'; +WATCH_OS : 'watchOS'; +TV_OS : 'tvOS'; +LINUX : 'Linux'; +WINDOWS : 'Windows'; + +I386 : 'i386'; +X86_64 : 'x86_64'; +ARM : 'arm'; +ARM64 : 'arm64'; + +SIMULATOR : 'simulator'; +MAC_CATALYST : 'macCatalyst'; + +I_OS_APPLICATION_EXTENSION : 'iOSApplicationExtension'; +MAC_CATALYST_APPLICATION_EXTENSION : 'macCatalystApplicationExtension'; +MAC_OS_APPLICATION_EXTENSION : 'macOSApplicationExtension'; +SOURCE_LOCATION : '#sourceLocation'; + +FILE : 'file'; +LINE : 'line'; +ERROR : '#error'; +WARNING : '#warning'; +AVAILABLE : '#available'; + +HASH_IF : '#if'; +HASH_ELSEIF : '#elseif'; +HASH_ELSE : '#else'; +HASH_ENDIF : '#endif'; +HASH_FILE : '#file'; +HASH_FILE_ID : '#fileID'; +HASH_FILE_PATH : '#filePath'; +HASH_LINE : '#line'; +HASH_COLUMN : '#column'; +HASH_FUNCTION : '#function'; +HASH_DSO_HANDLE : '#dsohandle'; +HASH_SELECTOR : '#selector'; +HASH_KEYPATH : '#keyPath'; +HASH_COLOR_LITERAL : '#colorLiteral'; +HASH_FILE_LITERAL : '#fileLiteral'; +HASH_IMAGE_LITERAL : '#imageLiteral'; +GETTER : 'getter'; +SETTER : 'setter'; Identifier: - Identifier_head Identifier_characters? - | Implicit_parameter_name - | Property_wrapper_projection; + Identifier_head Identifier_characters? + | Implicit_parameter_name + | Property_wrapper_projection +; fragment Identifier_head: - [a-zA-Z] - | '_' - | '\u00A8' - | '\u00AA' - | '\u00AD' - | '\u00AF' - | [\u00B2-\u00B5] - | [\u00B7-\u00BA] - | [\u00BC-\u00BE] - | [\u00C0-\u00D6] - | [\u00D8-\u00F6] - | [\u00F8-\u00FF] - | [\u0100-\u02FF] - | [\u0370-\u167F] - | [\u1681-\u180D] - | [\u180F-\u1DBF] - | [\u1E00-\u1FFF] - | [\u200B-\u200D] - | [\u202A-\u202E] - | [\u203F-\u2040] - | '\u2054' - | [\u2060-\u206F] - | [\u2070-\u20CF] - | [\u2100-\u218F] - | [\u2460-\u24FF] - | [\u2776-\u2793] - | [\u2C00-\u2DFF] - | [\u2E80-\u2FFF] - | [\u3004-\u3007] - | [\u3021-\u302F] - | [\u3031-\u303F] - | [\u3040-\uD7FF] - | [\uF900-\uFD3D] - | [\uFD40-\uFDCF] - | [\uFDF0-\uFE1F] - | [\uFE30-\uFE44] - | [\uFE47-\uFFFD] - | [\u{10000}-\u{1FFFD}] - | [\u{20000}-\u{2FFFD}] - | [\u{30000}-\u{3FFFD}] - | [\u{40000}-\u{4FFFD}] - | [\u{50000}-\u{5FFFD}] - | [\u{60000}-\u{6FFFD}] - | [\u{70000}-\u{7FFFD}] - | [\u{80000}-\u{8FFFD}] - | [\u{90000}-\u{9FFFD}] - | [\u{A0000}-\u{AFFFD}] - | [\u{B0000}-\u{BFFFD}] - | [\u{C0000}-\u{CFFFD}] - | [\u{D0000}-\u{DFFFD}] - | [\u{E0000}-\u{EFFFD}]; + [a-zA-Z] + | '_' + | '\u00A8' + | '\u00AA' + | '\u00AD' + | '\u00AF' + | [\u00B2-\u00B5] + | [\u00B7-\u00BA] + | [\u00BC-\u00BE] + | [\u00C0-\u00D6] + | [\u00D8-\u00F6] + | [\u00F8-\u00FF] + | [\u0100-\u02FF] + | [\u0370-\u167F] + | [\u1681-\u180D] + | [\u180F-\u1DBF] + | [\u1E00-\u1FFF] + | [\u200B-\u200D] + | [\u202A-\u202E] + | [\u203F-\u2040] + | '\u2054' + | [\u2060-\u206F] + | [\u2070-\u20CF] + | [\u2100-\u218F] + | [\u2460-\u24FF] + | [\u2776-\u2793] + | [\u2C00-\u2DFF] + | [\u2E80-\u2FFF] + | [\u3004-\u3007] + | [\u3021-\u302F] + | [\u3031-\u303F] + | [\u3040-\uD7FF] + | [\uF900-\uFD3D] + | [\uFD40-\uFDCF] + | [\uFDF0-\uFE1F] + | [\uFE30-\uFE44] + | [\uFE47-\uFFFD] + | [\u{10000}-\u{1FFFD}] + | [\u{20000}-\u{2FFFD}] + | [\u{30000}-\u{3FFFD}] + | [\u{40000}-\u{4FFFD}] + | [\u{50000}-\u{5FFFD}] + | [\u{60000}-\u{6FFFD}] + | [\u{70000}-\u{7FFFD}] + | [\u{80000}-\u{8FFFD}] + | [\u{90000}-\u{9FFFD}] + | [\u{A0000}-\u{AFFFD}] + | [\u{B0000}-\u{BFFFD}] + | [\u{C0000}-\u{CFFFD}] + | [\u{D0000}-\u{DFFFD}] + | [\u{E0000}-\u{EFFFD}] +; fragment Identifier_character: - [0-9] - | [\u0300-\u036F] - | [\u1DC0-\u1DFF] - | [\u20D0-\u20FF] - | [\uFE20-\uFE2F] - | Identifier_head; + [0-9] + | [\u0300-\u036F] + | [\u1DC0-\u1DFF] + | [\u20D0-\u20FF] + | [\uFE20-\uFE2F] + | Identifier_head +; fragment Identifier_characters: Identifier_character+; @@ -220,14 +226,13 @@ fragment Implicit_parameter_name: '$' Decimal_digits; fragment Property_wrapper_projection: '$' Identifier_characters; -DOT: '.'; -LCURLY: '{'; -LPAREN: - '(' { if(!parenthesis.isEmpty()) parenthesis.push(parenthesis.pop()+1);}; -LBRACK: '['; -RCURLY: '}'; +DOT : '.'; +LCURLY : '{'; +LPAREN : '(' { if(!parenthesis.isEmpty()) parenthesis.push(parenthesis.pop()+1);}; +LBRACK : '['; +RCURLY : '}'; RPAREN: - ')' { if(!parenthesis.isEmpty()) + ')' { if(!parenthesis.isEmpty()) { parenthesis.push(parenthesis.pop()-1); if(parenthesis.peek() == 0) @@ -236,108 +241,104 @@ RPAREN: popMode(); } } - }; -RBRACK: ']'; -COMMA: ','; -COLON: ':'; -SEMI: ';'; -LT: '<'; -GT: '>'; -UNDERSCORE: '_'; -BANG: '!'; -QUESTION: '?'; -AT: '@'; -AND: '&'; -SUB: '-'; -EQUAL: '='; -OR: '|'; -DIV: '/'; -ADD: '+'; -MUL: '*'; -MOD: '%'; -CARET: '^'; -TILDE: '~'; -HASH: '#'; -BACKTICK: '`'; -DOLLAR: '$'; -BACKSLASH: '\\'; + } +; +RBRACK : ']'; +COMMA : ','; +COLON : ':'; +SEMI : ';'; +LT : '<'; +GT : '>'; +UNDERSCORE : '_'; +BANG : '!'; +QUESTION : '?'; +AT : '@'; +AND : '&'; +SUB : '-'; +EQUAL : '='; +OR : '|'; +DIV : '/'; +ADD : '+'; +MUL : '*'; +MOD : '%'; +CARET : '^'; +TILDE : '~'; +HASH : '#'; +BACKTICK : '`'; +DOLLAR : '$'; +BACKSLASH : '\\'; Operator_head_other: // valid operator chars not used by Swift itself - [\u00A1-\u00A7] - | [\u00A9\u00AB] - | [\u00AC\u00AE] - | [\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7] - | [\u2016-\u2017\u2020-\u2027] - | [\u2030-\u203E] - | [\u2041-\u2053] - | [\u2055-\u205E] - | [\u2190-\u23FF] - | [\u2500-\u2775] - | [\u2794-\u2BFF] - | [\u2E00-\u2E7F] - | [\u3001-\u3003] - | [\u3008-\u3020\u3030]; + [\u00A1-\u00A7] + | [\u00A9\u00AB] + | [\u00AC\u00AE] + | [\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7] + | [\u2016-\u2017\u2020-\u2027] + | [\u2030-\u203E] + | [\u2041-\u2053] + | [\u2055-\u205E] + | [\u2190-\u23FF] + | [\u2500-\u2775] + | [\u2794-\u2BFF] + | [\u2E00-\u2E7F] + | [\u3001-\u3003] + | [\u3008-\u3020\u3030] +; Operator_following_character: - [\u0300-\u036F] - | [\u1DC0-\u1DFF] - | [\u20D0-\u20FF] - | [\uFE00-\uFE0F] - | [\uFE20-\uFE2F] - | [\u{E0100}-\u{E01EF}]; - -Binary_literal: '0b' Binary_digit Binary_literal_characters?; -fragment Binary_digit: [01]; -fragment Binary_literal_character: Binary_digit | '_'; -fragment Binary_literal_characters: Binary_literal_character+; - -Octal_literal: '0o' Octal_digit Octal_literal_characters?; -fragment Octal_digit: [0-7]; -fragment Octal_literal_character: Octal_digit | '_'; -fragment Octal_literal_characters: Octal_literal_character+; - -Decimal_digits: Decimal_digit+; -Decimal_literal: Decimal_digit Decimal_literal_characters?; -fragment Decimal_digit: [0-9]; -fragment Decimal_literal_character: Decimal_digit | '_'; -fragment Decimal_literal_characters: Decimal_literal_character+; - -Hexadecimal_literal: - '0x' Hexadecimal_digit Hexadecimal_literal_characters?; -fragment Hexadecimal_digit: [0-9a-fA-F]; -fragment Hexadecimal_literal_character: Hexadecimal_digit | '_'; -fragment Hexadecimal_literal_characters: - Hexadecimal_literal_character+; + [\u0300-\u036F] + | [\u1DC0-\u1DFF] + | [\u20D0-\u20FF] + | [\uFE00-\uFE0F] + | [\uFE20-\uFE2F] + | [\u{E0100}-\u{E01EF}] +; + +Binary_literal : '0b' Binary_digit Binary_literal_characters?; +fragment Binary_digit : [01]; +fragment Binary_literal_character : Binary_digit | '_'; +fragment Binary_literal_characters : Binary_literal_character+; + +Octal_literal : '0o' Octal_digit Octal_literal_characters?; +fragment Octal_digit : [0-7]; +fragment Octal_literal_character : Octal_digit | '_'; +fragment Octal_literal_characters : Octal_literal_character+; + +Decimal_digits : Decimal_digit+; +Decimal_literal : Decimal_digit Decimal_literal_characters?; +fragment Decimal_digit : [0-9]; +fragment Decimal_literal_character : Decimal_digit | '_'; +fragment Decimal_literal_characters : Decimal_literal_character+; + +Hexadecimal_literal : '0x' Hexadecimal_digit Hexadecimal_literal_characters?; +fragment Hexadecimal_digit : [0-9a-fA-F]; +fragment Hexadecimal_literal_character : Hexadecimal_digit | '_'; +fragment Hexadecimal_literal_characters : Hexadecimal_literal_character+; // Floating-Point Literals Floating_point_literal: - Decimal_literal Decimal_fraction? Decimal_exponent? - | Hexadecimal_literal Hexadecimal_fraction? Hexadecimal_exponent; -fragment Decimal_fraction: '.' Decimal_literal; -fragment Decimal_exponent: - Floating_point_e Sign? Decimal_literal; -fragment Hexadecimal_fraction: - '.' Hexadecimal_digit Hexadecimal_literal_characters?; -fragment Hexadecimal_exponent: - Floating_point_p Sign? Decimal_literal; -fragment Floating_point_e: [eE]; -fragment Floating_point_p: [pP]; -fragment Sign: [+-]; + Decimal_literal Decimal_fraction? Decimal_exponent? + | Hexadecimal_literal Hexadecimal_fraction? Hexadecimal_exponent +; +fragment Decimal_fraction : '.' Decimal_literal; +fragment Decimal_exponent : Floating_point_e Sign? Decimal_literal; +fragment Hexadecimal_fraction : '.' Hexadecimal_digit Hexadecimal_literal_characters?; +fragment Hexadecimal_exponent : Floating_point_p Sign? Decimal_literal; +fragment Floating_point_e : [eE]; +fragment Floating_point_p : [pP]; +fragment Sign : [+-]; WS: [ \n\r\t\u000B\u000C\u0000]+ -> channel(HIDDEN); HASHBANG: '#!' .*? [\r\n]+ -> channel(HIDDEN); -Block_comment: - '/*' (Block_comment | .)*? '*/' -> channel(HIDDEN); +Block_comment: '/*' (Block_comment | .)*? '*/' -> channel(HIDDEN); Line_comment: '//' .*? ('\n' | EOF) -> channel(HIDDEN); -Multi_line_extended_string_open: - '#'+ '"""' -> pushMode(MultiLineExtended); +Multi_line_extended_string_open: '#'+ '"""' -> pushMode(MultiLineExtended); -Single_line_extended_string_open: - '#'+ '"' -> pushMode(SingleLineExtended); +Single_line_extended_string_open: '#'+ '"' -> pushMode(SingleLineExtended); Multi_line_string_open: '"""' -> pushMode(MultiLine); @@ -345,8 +346,7 @@ Single_line_string_open: '"' -> pushMode(SingleLine); mode SingleLine; -Interpolataion_single_line: - '\\(' { parenthesis.push(1);} -> pushMode(DEFAULT_MODE); +Interpolataion_single_line: '\\(' { parenthesis.push(1);} -> pushMode(DEFAULT_MODE); Single_line_string_close: '"' -> popMode; @@ -354,8 +354,7 @@ Quoted_single_line_text: Quoted_text; mode MultiLine; -Interpolataion_multi_line: - '\\(' {parenthesis.push(1); } -> pushMode(DEFAULT_MODE); +Interpolataion_multi_line: '\\(' {parenthesis.push(1); } -> pushMode(DEFAULT_MODE); Multi_line_string_close: '"""' -> popMode; @@ -377,28 +376,22 @@ fragment Quoted_text: Quoted_text_item+; fragment Quoted_text_item: Escaped_character | ~["\n\r\\]; -fragment Multiline_quoted_text: - Escaped_character - | ~[\\"]+ - | '"' '"'? - | Escaped_newline; +fragment Multiline_quoted_text: Escaped_character | ~[\\"]+ | '"' '"'? | Escaped_newline; fragment Escape_sequence: '\\' '#'*; fragment Escaped_character: - Escape_sequence ( - [0\\tnr"'\u201c] - | 'u' '{' Unicode_scalar_digits '}' - ); + Escape_sequence ([0\\tnr"'\u201c] | 'u' '{' Unicode_scalar_digits '}') +; //Between one and eight hexadecimal digits fragment Unicode_scalar_digits: - Hexadecimal_digit Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit? - Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit?; + Hexadecimal_digit Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit? Hexadecimal_digit? + Hexadecimal_digit? +; -fragment Escaped_newline: - Escape_sequence Inline_spaces? Line_break; +fragment Escaped_newline: Escape_sequence Inline_spaces? Line_break; fragment Inline_spaces: [\u0009\u0020]; -fragment Line_break: [\u000A\u000D]| '\u000D' '\u000A'; +fragment Line_break: [\u000A\u000D]| '\u000D' '\u000A'; \ No newline at end of file diff --git a/swift/swift5/Swift5Parser.g4 b/swift/swift5/Swift5Parser.g4 index 9f91fac080..9446f507bc 100644 --- a/swift/swift5/Swift5Parser.g4 +++ b/swift/swift5/Swift5Parser.g4 @@ -1,866 +1,1281 @@ +// $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 Swift5Parser; // Insert here @header for C++ parser. options { - superClass = SwiftSupport; - tokenVocab = Swift5Lexer; + superClass = SwiftSupport; + tokenVocab = Swift5Lexer; } -top_level: statements? EOF; +top_level + : statements? EOF + ; // Statements -statement: - ( - loop_statement - | declaration - | branch_statement - | labeled_statement - | control_transfer_statement - | defer_statement - | do_statement - | expression - ) SEMI? - | compiler_control_statement; +statement + : ( + loop_statement + | declaration + | branch_statement + | labeled_statement + | control_transfer_statement + | defer_statement + | do_statement + | expression + ) SEMI? + | compiler_control_statement + ; statements - locals[int indexBefore = -1]: ( - {this.isSeparatedStatement(_input, $indexBefore)}? statement {$indexBefore = _input.index(); + locals[int indexBefore = -1] + : ( + {this.isSeparatedStatement(_input, $indexBefore)}? statement {$indexBefore = _input.index(); } - )+; + )+ + ; // Loop Statements -loop_statement: - for_in_statement - | while_statement - | repeat_while_statement; +loop_statement + : for_in_statement + | while_statement + | repeat_while_statement + ; // For-In Statement -for_in_statement: - FOR CASE? pattern IN expression where_clause? code_block; +for_in_statement + : FOR CASE? pattern IN expression where_clause? code_block + ; // While Statement -while_statement: WHILE condition_list code_block; +while_statement + : WHILE condition_list code_block + ; -condition_list: condition (COMMA condition)*; +condition_list + : condition (COMMA condition)* + ; -condition: - availability_condition - | expression - | case_condition - | optional_binding_condition; +condition + : availability_condition + | expression + | case_condition + | optional_binding_condition + ; -case_condition: CASE pattern initializer; +case_condition + : CASE pattern initializer + ; -optional_binding_condition: (LET | VAR) pattern initializer; +optional_binding_condition + : (LET | VAR) pattern initializer + ; // Repeat-While Statement -repeat_while_statement: REPEAT code_block WHILE expression; +repeat_while_statement + : REPEAT code_block WHILE expression + ; // Branch Statements -branch_statement: - if_statement - | guard_statement - | switch_statement; +branch_statement + : if_statement + | guard_statement + | switch_statement + ; // If Statement -if_statement: IF condition_list code_block else_clause?; -else_clause: ELSE code_block | ELSE if_statement; +if_statement + : IF condition_list code_block else_clause? + ; + +else_clause + : ELSE code_block + | ELSE if_statement + ; // Guard Statement -guard_statement: GUARD condition_list ELSE code_block; +guard_statement + : GUARD condition_list ELSE code_block + ; // Switch Statement -switch_statement: SWITCH expression LCURLY switch_cases? RCURLY; -switch_cases: switch_case switch_cases?; -switch_case: (case_label | default_label) statements - | conditional_switch_case; -case_label: attributes? CASE case_item_list COLON; -case_item_list: - pattern where_clause? (COMMA pattern where_clause?)*; -default_label: attributes? DEFAULT COLON; -where_clause: WHERE where_expression; -where_expression: expression; -conditional_switch_case: - switch_if_directive_clause switch_elseif_directive_clauses? switch_else_directive_clause? - HASH_ENDIF; -switch_if_directive_clause: - HASH_IF compilation_condition switch_cases?; -switch_elseif_directive_clauses: - elseif_directive_clause switch_elseif_directive_clauses?; -switch_elseif_directive_clause: - HASH_ELSEIF compilation_condition switch_cases?; -switch_else_directive_clause: HASH_ELSE switch_cases?; +switch_statement + : SWITCH expression LCURLY switch_cases? RCURLY + ; + +switch_cases + : switch_case switch_cases? + ; + +switch_case + : (case_label | default_label) statements + | conditional_switch_case + ; + +case_label + : attributes? CASE case_item_list COLON + ; + +case_item_list + : pattern where_clause? (COMMA pattern where_clause?)* + ; + +default_label + : attributes? DEFAULT COLON + ; + +where_clause + : WHERE where_expression + ; + +where_expression + : expression + ; + +conditional_switch_case + : switch_if_directive_clause switch_elseif_directive_clauses? switch_else_directive_clause? HASH_ENDIF + ; + +switch_if_directive_clause + : HASH_IF compilation_condition switch_cases? + ; + +switch_elseif_directive_clauses + : elseif_directive_clause switch_elseif_directive_clauses? + ; + +switch_elseif_directive_clause + : HASH_ELSEIF compilation_condition switch_cases? + ; + +switch_else_directive_clause + : HASH_ELSE switch_cases? + ; // Labeled Statement -labeled_statement: - statement_label ( - loop_statement - | if_statement - | switch_statement - | do_statement - ); +labeled_statement + : statement_label (loop_statement | if_statement | switch_statement | do_statement) + ; -statement_label: label_name COLON; -label_name: identifier; +statement_label + : label_name COLON + ; + +label_name + : identifier + ; // Control Transfer Statements -control_transfer_statement: - break_statement - | continue_statement - | fallthrough_statement - | return_statement - | throw_statement; +control_transfer_statement + : break_statement + | continue_statement + | fallthrough_statement + | return_statement + | throw_statement + ; // Break Statement -break_statement: BREAK label_name?; +break_statement + : BREAK label_name? + ; // Continue Statement -continue_statement: CONTINUE label_name?; +continue_statement + : CONTINUE label_name? + ; // Fallthrough Statement -fallthrough_statement: FALLTHROUGH; +fallthrough_statement + : FALLTHROUGH + ; // Return Statement -return_statement: RETURN expression?; +return_statement + : RETURN expression? + ; // Throw Statement -throw_statement: THROW expression; +throw_statement + : THROW expression + ; // Defer Statement -defer_statement: DEFER code_block; +defer_statement + : DEFER code_block + ; // Do Statement -do_statement: DO code_block catch_clauses?; -catch_clauses: catch_clause+; -catch_clause: CATCH catch_pattern_list? code_block; -catch_pattern_list: - catch_pattern (catch_pattern COMMA catch_pattern)*; -catch_pattern: pattern where_clause?; +do_statement + : DO code_block catch_clauses? + ; + +catch_clauses + : catch_clause+ + ; + +catch_clause + : CATCH catch_pattern_list? code_block + ; + +catch_pattern_list + : catch_pattern (catch_pattern COMMA catch_pattern)* + ; + +catch_pattern + : pattern where_clause? + ; // Compiler Control Statements -compiler_control_statement: - conditional_compilation_block - | line_control_statement - | diagnostic_statement; +compiler_control_statement + : conditional_compilation_block + | line_control_statement + | diagnostic_statement + ; // Conditional Compilation Block -conditional_compilation_block: - if_directive_clause elseif_directive_clauses? else_directive_clause? HASH_ENDIF; - -if_directive_clause: HASH_IF compilation_condition statements?; - -elseif_directive_clauses: elseif_directive_clause+; -elseif_directive_clause: - HASH_ELSEIF compilation_condition statements?; -else_directive_clause: HASH_ELSE statements?; - -compilation_condition: - platform_condition - | identifier - | boolean_literal - | LPAREN compilation_condition RPAREN - | BANG compilation_condition - | compilation_condition ( - compilation_condition_AND - | compilation_condition_OR - ) compilation_condition; - -platform_condition: - OS LPAREN operating_system RPAREN - | ARCH LPAREN architecture RPAREN - | (SWIFT | COMPILER) LPAREN ( - compilation_condition_GE - | compilation_condition_L - ) swift_version RPAREN - | CAN_IMPORT LPAREN module_name RPAREN - | TARGET_ENVIRONMENT LPAREN environment RPAREN; - -swift_version: Decimal_digits swift_version_continuation?; -swift_version_continuation: - DOT Decimal_digits swift_version_continuation?; - -operating_system: - MAC_OS - | I_OS - | OSX - | WATCH_OS - | TV_OS - | LINUX - | WINDOWS; -architecture: I386 | X86_64 | ARM | ARM64; - -module_name: identifier (DOT identifier)*; -environment: SIMULATOR | MAC_CATALYST; +conditional_compilation_block + : if_directive_clause elseif_directive_clauses? else_directive_clause? HASH_ENDIF + ; + +if_directive_clause + : HASH_IF compilation_condition statements? + ; + +elseif_directive_clauses + : elseif_directive_clause+ + ; + +elseif_directive_clause + : HASH_ELSEIF compilation_condition statements? + ; + +else_directive_clause + : HASH_ELSE statements? + ; + +compilation_condition + : platform_condition + | identifier + | boolean_literal + | LPAREN compilation_condition RPAREN + | BANG compilation_condition + | compilation_condition (compilation_condition_AND | compilation_condition_OR) compilation_condition + ; + +platform_condition + : OS LPAREN operating_system RPAREN + | ARCH LPAREN architecture RPAREN + | (SWIFT | COMPILER) LPAREN (compilation_condition_GE | compilation_condition_L) swift_version RPAREN + | CAN_IMPORT LPAREN module_name RPAREN + | TARGET_ENVIRONMENT LPAREN environment RPAREN + ; + +swift_version + : Decimal_digits swift_version_continuation? + ; + +swift_version_continuation + : DOT Decimal_digits swift_version_continuation? + ; + +operating_system + : MAC_OS + | I_OS + | OSX + | WATCH_OS + | TV_OS + | LINUX + | WINDOWS + ; + +architecture + : I386 + | X86_64 + | ARM + | ARM64 + ; + +module_name + : identifier (DOT identifier)* + ; + +environment + : SIMULATOR + | MAC_CATALYST + ; // Line Control Statement -line_control_statement: - SOURCE_LOCATION LPAREN ( - FILE COLON file_name COMMA LINE COLON line_number - )? RPAREN; +line_control_statement + : SOURCE_LOCATION LPAREN (FILE COLON file_name COMMA LINE COLON line_number)? RPAREN + ; + +line_number + : Decimal_literal + ; // TODO: A decimal integer greater than zero -line_number: - Decimal_literal; // TODO: A decimal integer greater than zero -file_name: static_string_literal; +file_name + : static_string_literal + ; // Compile-Time Diagnostic Statement -diagnostic_statement: (ERROR | WARNING) LPAREN diagnostic_message RPAREN; +diagnostic_statement + : (ERROR | WARNING) LPAREN diagnostic_message RPAREN + ; -diagnostic_message: static_string_literal; +diagnostic_message + : static_string_literal + ; // Availability Condition -availability_condition: - AVAILABLE LPAREN availability_arguments RPAREN; - -availability_arguments: - availability_argument (COMMA availability_argument)*; - -availability_argument: platform_name platform_version | MUL; - -platform_name: - I_OS - | OSX - | I_OS_APPLICATION_EXTENSION - | MAC_OS - | MAC_OS_APPLICATION_EXTENSION - | MAC_CATALYST - | MAC_CATALYST_APPLICATION_EXTENSION - | WATCH_OS - | TV_OS; - -platform_version: - Decimal_literal - | Decimal_digits - | Floating_point_literal (DOT Decimal_digits)?; +availability_condition + : AVAILABLE LPAREN availability_arguments RPAREN + ; + +availability_arguments + : availability_argument (COMMA availability_argument)* + ; + +availability_argument + : platform_name platform_version + | MUL + ; + +platform_name + : I_OS + | OSX + | I_OS_APPLICATION_EXTENSION + | MAC_OS + | MAC_OS_APPLICATION_EXTENSION + | MAC_CATALYST + | MAC_CATALYST_APPLICATION_EXTENSION + | WATCH_OS + | TV_OS + ; + +platform_version + : Decimal_literal + | Decimal_digits + | Floating_point_literal (DOT Decimal_digits)? + ; // Generic Parameter Clause -generic_parameter_clause: LT generic_parameter_list GT; -generic_parameter_list: - generic_parameter (COMMA generic_parameter)*; -generic_parameter: - type_name ( - COLON (type_identifier | protocol_composition_type) - )?; - -generic_where_clause: WHERE requirement_list; -requirement_list: requirement (COMMA requirement)*; -requirement: conformance_requirement | same_type_requirement; - -conformance_requirement: - type_identifier COLON ( - type_identifier - | protocol_composition_type - ); -same_type_requirement: - type_identifier same_type_equals (type_identifier | type); +generic_parameter_clause + : LT generic_parameter_list GT + ; -// Generic Argument Clause -generic_argument_clause: LT generic_argument_list GT; -generic_argument_list: - generic_argument (COMMA generic_argument)*; -generic_argument: type; +generic_parameter_list + : generic_parameter (COMMA generic_parameter)* + ; -// Declarations -declaration: - ( - import_declaration - | constant_declaration - | variable_declaration - | typealias_declaration - | function_declaration - | enum_declaration - | struct_declaration - | class_declaration - | protocol_declaration - | initializer_declaration - | deinitializer_declaration - | extension_declaration - | subscript_declaration - | operator_declaration - | precedence_group_declaration - ) SEMI?; - -declarations: declaration+; +generic_parameter + : type_name (COLON (type_identifier | protocol_composition_type))? + ; -// Top-Level Code -top_level_declaration: statements?; +generic_where_clause + : WHERE requirement_list + ; -// Code Blocks -code_block: LCURLY statements? RCURLY; +requirement_list + : requirement (COMMA requirement)* + ; -// Import Declaration -import_declaration: attributes? IMPORT import_kind? import_path; -import_kind: - TYPEALIAS - | STRUCT - | CLASS - | ENUM - | PROTOCOL - | LET - | VAR - | FUNC; -import_path: - import_path_identifier (DOT import_path_identifier)*; -import_path_identifier: identifier | operator; +requirement + : conformance_requirement + | same_type_requirement + ; -// Constant Declaration -constant_declaration: - attributes? declaration_modifiers? LET pattern_initializer_list; -pattern_initializer_list: - pattern_initializer (COMMA pattern_initializer)*; -pattern_initializer: pattern initializer?; -initializer: EQUAL expression; +conformance_requirement + : type_identifier COLON (type_identifier | protocol_composition_type) + ; -// Variable Declaration -variable_declaration: - variable_declaration_head ( - variable_name ( - initializer willSet_didSet_block - | type_annotation ( - initializer? willSet_didSet_block - | getter_setter_block // contains code_block - | getter_setter_keyword_block - ) - ) - | pattern_initializer_list - ); - -variable_declaration_head: - attributes? declaration_modifiers? VAR; -variable_name: identifier; - -getter_setter_block: - LCURLY ( - getter_clause setter_clause? - | setter_clause getter_clause - ) RCURLY - | code_block; -getter_clause: attributes? mutation_modifier? GET code_block?; -setter_clause: - attributes? mutation_modifier? SET setter_name? code_block?; -setter_name: LPAREN identifier RPAREN; - -getter_setter_keyword_block: - LCURLY ( - getter_keyword_clause setter_keyword_clause? - | setter_keyword_clause getter_keyword_clause - ) RCURLY; -getter_keyword_clause: attributes? mutation_modifier? GET; -setter_keyword_clause: attributes? mutation_modifier? SET; - -willSet_didSet_block: - LCURLY ( - willSet_clause didSet_clause? - | didSet_clause willSet_clause? - ) RCURLY; -willSet_clause: attributes? WILL_SET setter_name? code_block; -didSet_clause: attributes? DID_SET setter_name? code_block; +same_type_requirement + : type_identifier same_type_equals (type_identifier | type) + ; -// Type Alias Declaration -typealias_declaration: - attributes? access_level_modifier? TYPEALIAS typealias_name generic_parameter_clause? - typealias_assignment; -typealias_name: identifier; -typealias_assignment: EQUAL type; - -// Function Declaration -function_declaration: - function_head function_name generic_parameter_clause? function_signature generic_where_clause? - function_body?; +// Generic Argument Clause +generic_argument_clause + : LT generic_argument_list GT + ; -function_head: attributes? declaration_modifiers? FUNC; +generic_argument_list + : generic_argument (COMMA generic_argument)* + ; -function_name: identifier | operator; +generic_argument + : type + ; -function_signature: - parameter_clause (THROWS? | RETHROWS) function_result?; +// Declarations +declaration + : ( + import_declaration + | constant_declaration + | variable_declaration + | typealias_declaration + | function_declaration + | enum_declaration + | struct_declaration + | class_declaration + | protocol_declaration + | initializer_declaration + | deinitializer_declaration + | extension_declaration + | subscript_declaration + | operator_declaration + | precedence_group_declaration + ) SEMI? + ; + +declarations + : declaration+ + ; -function_result: arrow_operator attributes? type; +// Top-Level Code +top_level_declaration + : statements? + ; -function_body: code_block; +// Code Blocks +code_block + : LCURLY statements? RCURLY + ; -parameter_clause: LPAREN parameter_list? RPAREN; -parameter_list: parameter (COMMA parameter)*; +// Import Declaration +import_declaration + : attributes? IMPORT import_kind? import_path + ; + +import_kind + : TYPEALIAS + | STRUCT + | CLASS + | ENUM + | PROTOCOL + | LET + | VAR + | FUNC + ; + +import_path + : import_path_identifier (DOT import_path_identifier)* + ; + +import_path_identifier + : identifier + | operator + ; -parameter: - attributes? external_parameter_name? local_parameter_name type_annotation ( - default_argument_clause? - | range_operator - ); -external_parameter_name: identifier; -local_parameter_name: identifier; -default_argument_clause: EQUAL expression; +// Constant Declaration +constant_declaration + : attributes? declaration_modifiers? LET pattern_initializer_list + ; -// Enumeration Declaration -enum_declaration: - attributes? access_level_modifier? ( - union_style_enum - | raw_value_style_enum - ); +pattern_initializer_list + : pattern_initializer (COMMA pattern_initializer)* + ; -union_style_enum: - INDIRECT? ENUM enum_name generic_parameter_clause? type_inheritance_clause? generic_where_clause - ? LCURLY union_style_enum_members? RCURLY; +pattern_initializer + : pattern initializer? + ; -union_style_enum_members: union_style_enum_member+; +initializer + : EQUAL expression + ; -union_style_enum_member: - declaration - | union_style_enum_case_clause - | compiler_control_statement; +// Variable Declaration +variable_declaration + : variable_declaration_head ( + variable_name ( + initializer willSet_didSet_block + | type_annotation ( + initializer? willSet_didSet_block + | getter_setter_block // contains code_block + | getter_setter_keyword_block + ) + ) + | pattern_initializer_list + ) + ; + +variable_declaration_head + : attributes? declaration_modifiers? VAR + ; + +variable_name + : identifier + ; + +getter_setter_block + : LCURLY (getter_clause setter_clause? | setter_clause getter_clause) RCURLY + | code_block + ; + +getter_clause + : attributes? mutation_modifier? GET code_block? + ; + +setter_clause + : attributes? mutation_modifier? SET setter_name? code_block? + ; + +setter_name + : LPAREN identifier RPAREN + ; + +getter_setter_keyword_block + : LCURLY ( + getter_keyword_clause setter_keyword_clause? + | setter_keyword_clause getter_keyword_clause + ) RCURLY + ; + +getter_keyword_clause + : attributes? mutation_modifier? GET + ; + +setter_keyword_clause + : attributes? mutation_modifier? SET + ; + +willSet_didSet_block + : LCURLY (willSet_clause didSet_clause? | didSet_clause willSet_clause?) RCURLY + ; + +willSet_clause + : attributes? WILL_SET setter_name? code_block + ; + +didSet_clause + : attributes? DID_SET setter_name? code_block + ; -union_style_enum_case_clause: - attributes? INDIRECT? CASE union_style_enum_case_list; +// Type Alias Declaration +typealias_declaration + : attributes? access_level_modifier? TYPEALIAS typealias_name generic_parameter_clause? typealias_assignment + ; -union_style_enum_case_list: - union_style_enum_case (COMMA union_style_enum_case)*; +typealias_name + : identifier + ; -union_style_enum_case: - opaque_type - | enum_case_name (tuple_type | LPAREN type RPAREN)?; +typealias_assignment + : EQUAL type + ; -enum_name: identifier; +// Function Declaration +function_declaration + : function_head function_name generic_parameter_clause? function_signature generic_where_clause? function_body? + ; + +function_head + : attributes? declaration_modifiers? FUNC + ; + +function_name + : identifier + | operator + ; + +function_signature + : parameter_clause (THROWS? | RETHROWS) function_result? + ; + +function_result + : arrow_operator attributes? type + ; + +function_body + : code_block + ; + +parameter_clause + : LPAREN parameter_list? RPAREN + ; + +parameter_list + : parameter (COMMA parameter)* + ; + +parameter + : attributes? external_parameter_name? local_parameter_name type_annotation ( + default_argument_clause? + | range_operator + ) + ; + +external_parameter_name + : identifier + ; + +local_parameter_name + : identifier + ; + +default_argument_clause + : EQUAL expression + ; -enum_case_name: identifier; +// Enumeration Declaration +enum_declaration + : attributes? access_level_modifier? (union_style_enum | raw_value_style_enum) + ; + +union_style_enum + : INDIRECT? ENUM enum_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? LCURLY union_style_enum_members? RCURLY + ; + +union_style_enum_members + : union_style_enum_member+ + ; + +union_style_enum_member + : declaration + | union_style_enum_case_clause + | compiler_control_statement + ; + +union_style_enum_case_clause + : attributes? INDIRECT? CASE union_style_enum_case_list + ; + +union_style_enum_case_list + : union_style_enum_case (COMMA union_style_enum_case)* + ; + +union_style_enum_case + : opaque_type + | enum_case_name (tuple_type | LPAREN type RPAREN)? + ; + +enum_name + : identifier + ; + +enum_case_name + : identifier + ; + +raw_value_style_enum + : ENUM enum_name generic_parameter_clause? type_inheritance_clause generic_where_clause? LCURLY raw_value_style_enum_members RCURLY + ; + +raw_value_style_enum_members + : raw_value_style_enum_member+ + ; + +raw_value_style_enum_member + : declaration + | raw_value_style_enum_case_clause + | compiler_control_statement + ; + +raw_value_style_enum_case_clause + : attributes? CASE raw_value_style_enum_case_list + ; + +raw_value_style_enum_case_list + : raw_value_style_enum_case (COMMA raw_value_style_enum_case)* + ; + +raw_value_style_enum_case + : enum_case_name raw_value_assignment? + ; + +raw_value_assignment + : EQUAL raw_value_literal + ; + +raw_value_literal + : numeric_literal + | static_string_literal + | boolean_literal + ; -raw_value_style_enum: - ENUM enum_name generic_parameter_clause? type_inheritance_clause generic_where_clause? LCURLY - raw_value_style_enum_members RCURLY; +// Structure Declaration +struct_declaration + : attributes? access_level_modifier? STRUCT struct_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? struct_body + ; -raw_value_style_enum_members: raw_value_style_enum_member+; +struct_name + : identifier + ; -raw_value_style_enum_member: - declaration - | raw_value_style_enum_case_clause - | compiler_control_statement; +struct_body + : LCURLY struct_members RCURLY + ; -raw_value_style_enum_case_clause: - attributes? CASE raw_value_style_enum_case_list; +struct_members + : struct_member* + ; -raw_value_style_enum_case_list: - raw_value_style_enum_case (COMMA raw_value_style_enum_case)*; +struct_member + : declaration + | compiler_control_statement + ; -raw_value_style_enum_case: enum_case_name raw_value_assignment?; +// Class Declaration +class_declaration + : attributes? (access_level_modifier? FINAL? | FINAL access_level_modifier?) CLASS class_name generic_parameter_clause? type_inheritance_clause? + generic_where_clause? class_body + ; -raw_value_assignment: EQUAL raw_value_literal; +class_name + : identifier + ; -raw_value_literal: - numeric_literal - | static_string_literal - | boolean_literal; +class_body + : LCURLY class_members RCURLY + ; -// Structure Declaration -struct_declaration: - attributes? access_level_modifier? STRUCT struct_name generic_parameter_clause? - type_inheritance_clause? generic_where_clause? struct_body; -struct_name: identifier; -struct_body: LCURLY struct_members RCURLY; -struct_members: struct_member*; -struct_member: declaration | compiler_control_statement; +class_members + : class_member* + ; -// Class Declaration -class_declaration: - attributes? ( - access_level_modifier? FINAL? - | FINAL access_level_modifier? - ) CLASS class_name generic_parameter_clause? type_inheritance_clause? generic_where_clause? - class_body; -class_name: identifier; -class_body: LCURLY class_members RCURLY; -class_members: class_member*; -class_member: declaration | compiler_control_statement; +class_member + : declaration + | compiler_control_statement + ; // Protocol Declaration -protocol_declaration: - attributes? access_level_modifier? PROTOCOL protocol_name ( - COLON CLASS - | type_inheritance_clause - )? generic_where_clause? protocol_body; -protocol_name: identifier; -protocol_body: LCURLY protocol_members RCURLY; -protocol_members: protocol_member*; - -protocol_member: - protocol_member_declaration - | compiler_control_statement; - -protocol_member_declaration: - protocol_property_declaration - | protocol_method_declaration - | protocol_initializer_declaration - | protocol_subscript_declaration - | protocol_associated_type_declaration - | typealias_declaration; +protocol_declaration + : attributes? access_level_modifier? PROTOCOL protocol_name ( + COLON CLASS + | type_inheritance_clause + )? generic_where_clause? protocol_body + ; + +protocol_name + : identifier + ; + +protocol_body + : LCURLY protocol_members RCURLY + ; + +protocol_members + : protocol_member* + ; + +protocol_member + : protocol_member_declaration + | compiler_control_statement + ; + +protocol_member_declaration + : protocol_property_declaration + | protocol_method_declaration + | protocol_initializer_declaration + | protocol_subscript_declaration + | protocol_associated_type_declaration + | typealias_declaration + ; // Protocol Property Declaration -protocol_property_declaration: - variable_declaration_head variable_name type_annotation getter_setter_keyword_block; +protocol_property_declaration + : variable_declaration_head variable_name type_annotation getter_setter_keyword_block + ; // Protocol Method Declaration -protocol_method_declaration: - function_head function_name generic_parameter_clause? function_signature generic_where_clause?; +protocol_method_declaration + : function_head function_name generic_parameter_clause? function_signature generic_where_clause? + ; // Protocol Initializer Declaration -protocol_initializer_declaration: - initializer_head generic_parameter_clause? parameter_clause ( - THROWS? - | RETHROWS - ) generic_where_clause?; +protocol_initializer_declaration + : initializer_head generic_parameter_clause? parameter_clause (THROWS? | RETHROWS) generic_where_clause? + ; // Protocol Subscript Declaration -protocol_subscript_declaration: - subscript_head subscript_result generic_where_clause? getter_setter_keyword_block; +protocol_subscript_declaration + : subscript_head subscript_result generic_where_clause? getter_setter_keyword_block + ; // Protocol Associated Type Declaration -protocol_associated_type_declaration: - attributes? access_level_modifier? ASSOCIATED_TYPE typealias_name type_inheritance_clause? - typealias_assignment? generic_where_clause?; +protocol_associated_type_declaration + : attributes? access_level_modifier? ASSOCIATED_TYPE typealias_name type_inheritance_clause? typealias_assignment? generic_where_clause? + ; // Initializer Declaration -initializer_declaration: - initializer_head generic_parameter_clause? parameter_clause ( - THROWS - | RETHROWS - )? generic_where_clause? initializer_body; +initializer_declaration + : initializer_head generic_parameter_clause? parameter_clause (THROWS | RETHROWS)? generic_where_clause? initializer_body + ; -initializer_head: - attributes? declaration_modifiers? INIT (QUESTION | BANG)?; +initializer_head + : attributes? declaration_modifiers? INIT (QUESTION | BANG)? + ; -initializer_body: code_block; +initializer_body + : code_block + ; // Deinitializer Declaration -deinitializer_declaration: attributes? DEINIT code_block; +deinitializer_declaration + : attributes? DEINIT code_block + ; // Extension Declaration -extension_declaration: - attributes? access_level_modifier? EXTENSION type_identifier type_inheritance_clause? - generic_where_clause? extension_body; -extension_body: LCURLY extension_members RCURLY; -extension_members: extension_member*; -extension_member: declaration | compiler_control_statement; +extension_declaration + : attributes? access_level_modifier? EXTENSION type_identifier type_inheritance_clause? generic_where_clause? extension_body + ; -// Subscript Declaration -subscript_declaration: - subscript_head subscript_result generic_where_clause? ( - code_block - | getter_setter_block - | getter_setter_keyword_block - ); +extension_body + : LCURLY extension_members RCURLY + ; + +extension_members + : extension_member* + ; -subscript_head: - attributes? declaration_modifiers? SUBSCRIPT generic_parameter_clause? parameter_clause; -subscript_result: arrow_operator attributes? type; +extension_member + : declaration + | compiler_control_statement + ; + +// Subscript Declaration +subscript_declaration + : subscript_head subscript_result generic_where_clause? ( + code_block + | getter_setter_block + | getter_setter_keyword_block + ) + ; + +subscript_head + : attributes? declaration_modifiers? SUBSCRIPT generic_parameter_clause? parameter_clause + ; + +subscript_result + : arrow_operator attributes? type + ; // Operator Declaration -operator_declaration: - prefix_operator_declaration - | postfix_operator_declaration - | infix_operator_declaration; +operator_declaration + : prefix_operator_declaration + | postfix_operator_declaration + | infix_operator_declaration + ; -prefix_operator_declaration: PREFIX OPERATOR operator; -postfix_operator_declaration: POSTFIX OPERATOR operator; -infix_operator_declaration: - INFIX OPERATOR operator infix_operator_group?; +prefix_operator_declaration + : PREFIX OPERATOR operator + ; -infix_operator_group: COLON precedence_group_name; +postfix_operator_declaration + : POSTFIX OPERATOR operator + ; + +infix_operator_declaration + : INFIX OPERATOR operator infix_operator_group? + ; + +infix_operator_group + : COLON precedence_group_name + ; // Precedence Group Declaration -precedence_group_declaration: - PRECEDENCE_GROUP precedence_group_name LCURLY precedence_group_attributes? RCURLY; -precedence_group_attributes: precedence_group_attribute+; +precedence_group_declaration + : PRECEDENCE_GROUP precedence_group_name LCURLY precedence_group_attributes? RCURLY + ; + +precedence_group_attributes + : precedence_group_attribute+ + ; + +precedence_group_attribute + : precedence_group_relation + | precedence_group_assignment + | precedence_group_associativity + ; -precedence_group_attribute: - precedence_group_relation - | precedence_group_assignment - | precedence_group_associativity; +precedence_group_relation + : (HIGHER_THAN | LOWER_THAN) COLON precedence_group_names + ; -precedence_group_relation: - (HIGHER_THAN | LOWER_THAN) COLON precedence_group_names; +precedence_group_assignment + : ASSIGNMENT COLON boolean_literal + ; -precedence_group_assignment: ASSIGNMENT COLON boolean_literal; +precedence_group_associativity + : ASSOCIATIVITY COLON (LEFT | RIGHT | NONE) + ; -precedence_group_associativity: - ASSOCIATIVITY COLON (LEFT | RIGHT | NONE); +precedence_group_names + : precedence_group_name (COMMA precedence_group_name)* + ; -precedence_group_names: - precedence_group_name (COMMA precedence_group_name)*; -precedence_group_name: identifier (DOT identifier)*; +precedence_group_name + : identifier (DOT identifier)* + ; // Declaration Modifiers -declaration_modifier: - CLASS - | CONVENIENCE - | DYNAMIC - | FINAL - | INFIX - | LAZY - | OPTIONAL - | OVERRIDE - | POSTFIX - | PREFIX - | REQUIRED - | STATIC - | UNOWNED (LPAREN (SAFE | UNSAFE) RPAREN)? - | WEAK - | access_level_modifier - | mutation_modifier; - -declaration_modifiers: declaration_modifier+; - -access_level_modifier: - (PRIVATE | FILE_PRIVATE | INTERNAL | PUBLIC | OPEN) ( - LPAREN SET RPAREN - )?; - -mutation_modifier: MUTATING | NONMUTATING; +declaration_modifier + : CLASS + | CONVENIENCE + | DYNAMIC + | FINAL + | INFIX + | LAZY + | OPTIONAL + | OVERRIDE + | POSTFIX + | PREFIX + | REQUIRED + | STATIC + | UNOWNED (LPAREN (SAFE | UNSAFE) RPAREN)? + | WEAK + | access_level_modifier + | mutation_modifier + ; + +declaration_modifiers + : declaration_modifier+ + ; + +access_level_modifier + : (PRIVATE | FILE_PRIVATE | INTERNAL | PUBLIC | OPEN) (LPAREN SET RPAREN)? + ; + +mutation_modifier + : MUTATING + | NONMUTATING + ; // Patterns //The following sets of rules are mutually left-recursive [pattern, Type-Casting], to avoid this they were integrated into the same rule. -pattern: - (wildcard_pattern | identifier_pattern | tuple_pattern) type_annotation? - | value_binding_pattern - | enum_case_pattern - | optional_pattern - | IS type - | pattern AS type - | expression_pattern; +pattern + : (wildcard_pattern | identifier_pattern | tuple_pattern) type_annotation? + | value_binding_pattern + | enum_case_pattern + | optional_pattern + | IS type + | pattern AS type + | expression_pattern + ; // Wildcard Pattern -wildcard_pattern: UNDERSCORE; +wildcard_pattern + : UNDERSCORE + ; // identifier Pattern -identifier_pattern: identifier; +identifier_pattern + : identifier + ; // Value-Binding Pattern -value_binding_pattern: VAR pattern | LET pattern; +value_binding_pattern + : VAR pattern + | LET pattern + ; // Tuple Pattern -tuple_pattern: LPAREN tuple_pattern_element_list? RPAREN; -tuple_pattern_element_list: - tuple_pattern_element (COMMA tuple_pattern_element)*; -tuple_pattern_element: (identifier COLON)? pattern; +tuple_pattern + : LPAREN tuple_pattern_element_list? RPAREN + ; + +tuple_pattern_element_list + : tuple_pattern_element (COMMA tuple_pattern_element)* + ; + +tuple_pattern_element + : (identifier COLON)? pattern + ; // Enumeration Case Pattern -enum_case_pattern: - type_identifier? DOT enum_case_name tuple_pattern?; +enum_case_pattern + : type_identifier? DOT enum_case_name tuple_pattern? + ; // Optional Pattern -optional_pattern: identifier_pattern QUESTION; +optional_pattern + : identifier_pattern QUESTION + ; // Expression Pattern -expression_pattern: expression; +expression_pattern + : expression + ; // Attributes -attribute: AT attribute_name attribute_argument_clause?; -attribute_name: identifier (DOT identifier)*; -attribute_argument_clause: LPAREN balanced_tokens? RPAREN; -attributes: attribute+; -balanced_tokens: balanced_token+; - -balanced_token: - LPAREN balanced_tokens? RPAREN - | LBRACK balanced_tokens? RBRACK - | LCURLY balanced_tokens? RCURLY - //Any identifier, keyword, literal, or operator Any punctuation except (, ), [, ], {, or } - | identifier - | keyword - | literal - | operator - | balanced_token_punctuation; - -balanced_token_punctuation: - ( - DOT - | COMMA - | COLON - | SEMI - | EQUAL - | AT - | HASH - | BACKTICK - | QUESTION - ) - | arrow_operator - | {this.isPrefixOp(_input)}? AND - | {this.isPostfixOp(_input)}? BANG; +attribute + : AT attribute_name attribute_argument_clause? + ; + +attribute_name + : identifier (DOT identifier)* + ; + +attribute_argument_clause + : LPAREN balanced_tokens? RPAREN + ; + +attributes + : attribute+ + ; + +balanced_tokens + : balanced_token+ + ; + +balanced_token + : LPAREN balanced_tokens? RPAREN + | LBRACK balanced_tokens? RBRACK + | LCURLY balanced_tokens? RCURLY + //Any identifier, keyword, literal, or operator Any punctuation except (, ), [, ], {, or } + | identifier + | keyword + | literal + | operator + | balanced_token_punctuation + ; + +balanced_token_punctuation + : (DOT | COMMA | COLON | SEMI | EQUAL | AT | HASH | BACKTICK | QUESTION) + | arrow_operator + | {this.isPrefixOp(_input)}? AND + | {this.isPostfixOp(_input)}? BANG + ; // Expressions -expression: try_operator? prefix_expression binary_expressions?; +expression + : try_operator? prefix_expression binary_expressions? + ; -expression_list: expression (COMMA expression)*; +expression_list + : expression (COMMA expression)* + ; // Prefix Expressions -prefix_expression: - prefix_operator? postfix_expression - | in_out_expression; +prefix_expression + : prefix_operator? postfix_expression + | in_out_expression + ; -in_out_expression: AND identifier; +in_out_expression + : AND identifier + ; // Try Operator -try_operator: TRY (QUESTION | BANG)?; +try_operator + : TRY (QUESTION | BANG)? + ; // Binary Expressions -binary_expression: - binary_operator prefix_expression - | (assignment_operator | conditional_operator) try_operator? prefix_expression - | type_casting_operator; +binary_expression + : binary_operator prefix_expression + | (assignment_operator | conditional_operator) try_operator? prefix_expression + | type_casting_operator + ; -binary_expressions: binary_expression+; +binary_expressions + : binary_expression+ + ; // Conditional Operator -conditional_operator: QUESTION expression COLON; +conditional_operator + : QUESTION expression COLON + ; // Ternary Conditional Operator -type_casting_operator: (IS | AS ( QUESTION | BANG)?) type; +type_casting_operator + : (IS | AS ( QUESTION | BANG)?) type + ; // Primary Expressions -primary_expression: - unqualified_name generic_argument_clause? - | array_type - | dictionary_type - | literal_expression - | self_expression - | superclass_expression - | closure_expression - | parenthesized_operator - | parenthesized_expression - | tuple_expression - | implicit_member_expression - | wildcard_expression - | key_path_expression - | selector_expression - | key_path_string_expression; - -unqualified_name: identifier (LPAREN argument_names RPAREN)?; +primary_expression + : unqualified_name generic_argument_clause? + | array_type + | dictionary_type + | literal_expression + | self_expression + | superclass_expression + | closure_expression + | parenthesized_operator + | parenthesized_expression + | tuple_expression + | implicit_member_expression + | wildcard_expression + | key_path_expression + | selector_expression + | key_path_string_expression + ; + +unqualified_name + : identifier (LPAREN argument_names RPAREN)? + ; // Literal Expression -literal_expression: - literal - | array_literal - | dictionary_literal - | playground_literal - | HASH_FILE - | HASH_FILE_ID - | HASH_FILE_PATH - | HASH_LINE - | HASH_COLUMN - | HASH_FUNCTION - | HASH_DSO_HANDLE; - -array_literal: LBRACK array_literal_items? RBRACK; - -array_literal_items: - array_literal_item (COMMA array_literal_item)* COMMA?; - -array_literal_item: expression; - -dictionary_literal: - LBRACK (dictionary_literal_items | COLON) RBRACK; - -dictionary_literal_items: - dictionary_literal_item (COMMA dictionary_literal_item)* COMMA?; - -dictionary_literal_item: expression COLON expression; - -playground_literal: - HASH_COLOR_LITERAL LPAREN RED COLON expression COMMA GREEN COLON expression COMMA BLUE COLON - expression COMMA ALPHA COLON expression RPAREN - | HASH_FILE_LITERAL LPAREN RESOURCE_NAME COLON expression RPAREN - | HASH_IMAGE_LITERAL LPAREN RESOURCE_NAME COLON expression RPAREN; +literal_expression + : literal + | array_literal + | dictionary_literal + | playground_literal + | HASH_FILE + | HASH_FILE_ID + | HASH_FILE_PATH + | HASH_LINE + | HASH_COLUMN + | HASH_FUNCTION + | HASH_DSO_HANDLE + ; + +array_literal + : LBRACK array_literal_items? RBRACK + ; + +array_literal_items + : array_literal_item (COMMA array_literal_item)* COMMA? + ; + +array_literal_item + : expression + ; + +dictionary_literal + : LBRACK (dictionary_literal_items | COLON) RBRACK + ; + +dictionary_literal_items + : dictionary_literal_item (COMMA dictionary_literal_item)* COMMA? + ; + +dictionary_literal_item + : expression COLON expression + ; + +playground_literal + : HASH_COLOR_LITERAL LPAREN RED COLON expression COMMA GREEN COLON expression COMMA BLUE COLON expression COMMA ALPHA COLON expression RPAREN + | HASH_FILE_LITERAL LPAREN RESOURCE_NAME COLON expression RPAREN + | HASH_IMAGE_LITERAL LPAREN RESOURCE_NAME COLON expression RPAREN + ; // Self Expression -self_expression: - SELF # self_pure_expression - | SELF DOT identifier # self_method_expression - | SELF LBRACK function_call_argument_list RBRACK # self_subscript_expression - | SELF DOT INIT # self_initializer_expression; +self_expression + : SELF # self_pure_expression + | SELF DOT identifier # self_method_expression + | SELF LBRACK function_call_argument_list RBRACK # self_subscript_expression + | SELF DOT INIT # self_initializer_expression + ; // Superclass Expression -superclass_expression: - SUPER DOT identifier # superclass_method_expression - | SUPER LBRACK function_call_argument_list RBRACK # superclass_subscript_expression - | SUPER DOT INIT # superclass_initializer_expression; +superclass_expression + : SUPER DOT identifier # superclass_method_expression + | SUPER LBRACK function_call_argument_list RBRACK # superclass_subscript_expression + | SUPER DOT INIT # superclass_initializer_expression + ; // Capture Lists -closure_expression: - LCURLY closure_signature? statements? RCURLY; +closure_expression + : LCURLY closure_signature? statements? RCURLY + ; -closure_signature: - capture_list? closure_parameter_clause THROWS? function_result? IN - | capture_list IN; +closure_signature + : capture_list? closure_parameter_clause THROWS? function_result? IN + | capture_list IN + ; -closure_parameter_clause: - LPAREN closure_parameter_list? RPAREN - | identifier_list; +closure_parameter_clause + : LPAREN closure_parameter_list? RPAREN + | identifier_list + ; -closure_parameter_list: - closure_parameter (COMMA closure_parameter)*; +closure_parameter_list + : closure_parameter (COMMA closure_parameter)* + ; -closure_parameter: - closure_parameter_name = identifier ( - type_annotation range_operator? - )?; +closure_parameter + : closure_parameter_name = identifier (type_annotation range_operator?)? + ; -capture_list: LBRACK capture_list_items RBRACK; +capture_list + : LBRACK capture_list_items RBRACK + ; -capture_list_items: - capture_list_item (COMMA capture_list_item)*; +capture_list_items + : capture_list_item (COMMA capture_list_item)* + ; -capture_list_item: - capture_specifier? ( - identifier EQUAL? expression - | self_expression - ); +capture_list_item + : capture_specifier? (identifier EQUAL? expression | self_expression) + ; -capture_specifier: - WEAK - | UNOWNED (LPAREN (SAFE | UNSAFE) RPAREN)?; +capture_specifier + : WEAK + | UNOWNED (LPAREN (SAFE | UNSAFE) RPAREN)? + ; // Implicit Member Expression -implicit_member_expression: - DOT (identifier | keyword) (DOT postfix_expression)?; +implicit_member_expression + : DOT (identifier | keyword) (DOT postfix_expression)? + ; + // let a: MyType = .default; static let `default` = MyType() // Parenthesized Expression -parenthesized_operator: LPAREN operator RPAREN; +parenthesized_operator + : LPAREN operator RPAREN + ; // Parenthesized Expression -parenthesized_expression: LPAREN expression RPAREN; +parenthesized_expression + : LPAREN expression RPAREN + ; // Tuple Expression -tuple_expression: - LPAREN RPAREN - | LPAREN tuple_element COMMA tuple_element_list RPAREN; +tuple_expression + : LPAREN RPAREN + | LPAREN tuple_element COMMA tuple_element_list RPAREN + ; -tuple_element_list: tuple_element (COMMA tuple_element)*; +tuple_element_list + : tuple_element (COMMA tuple_element)* + ; -tuple_element: (identifier COLON)? expression; +tuple_element + : (identifier COLON)? expression + ; // Wildcard Expression -wildcard_expression: UNDERSCORE; +wildcard_expression + : UNDERSCORE + ; // Key-Path Expression -key_path_expression: BACKSLASH type? DOT key_path_components; -key_path_components: - key_path_component (DOT key_path_component)*; -key_path_component: - identifier key_path_postfixes? - | key_path_postfixes; -key_path_postfixes: key_path_postfix+; -key_path_postfix: - QUESTION - | BANG - | SELF - | LBRACK function_call_argument_list RBRACK; +key_path_expression + : BACKSLASH type? DOT key_path_components + ; + +key_path_components + : key_path_component (DOT key_path_component)* + ; + +key_path_component + : identifier key_path_postfixes? + | key_path_postfixes + ; + +key_path_postfixes + : key_path_postfix+ + ; + +key_path_postfix + : QUESTION + | BANG + | SELF + | LBRACK function_call_argument_list RBRACK + ; // Selector Expression -selector_expression: - HASH_SELECTOR LPAREN ((GETTER | SETTER) COLON)? expression RPAREN; +selector_expression + : HASH_SELECTOR LPAREN ((GETTER | SETTER) COLON)? expression RPAREN + ; // Key-Path String Expression -key_path_string_expression: - HASH_KEYPATH LPAREN expression RPAREN; +key_path_string_expression + : HASH_KEYPATH LPAREN expression RPAREN + ; // Postfix Expressions @@ -873,435 +1288,532 @@ key_path_string_expression: explicit_member_expression | postfix_self_expression | subscript_expression | forced_value_expression | optional_chaining_expression | primary_expression ; */ -postfix_expression: - primary_expression ( - function_call_suffix - | initializer_suffix - | explicit_member_suffix - | postfix_self_suffix - | subscript_suffix - | forced_value_suffix - | optional_chaining_suffix - )* postfix_operator*?; - -function_call_suffix: - function_call_argument_clause? trailing_closures - | function_call_argument_clause; - -initializer_suffix: DOT INIT (LPAREN argument_names RPAREN)?; - -explicit_member_suffix: - DOT ( - Decimal_digits - | identifier ( - generic_argument_clause - | LPAREN argument_names RPAREN - )? - ); - -postfix_self_suffix: DOT SELF; - -subscript_suffix: LBRACK function_call_argument_list RBRACK; - -forced_value_suffix: {!this.isBinaryOp(_input)}? BANG; -optional_chaining_suffix: - {!this.isBinaryOp(_input)}? QUESTION; +postfix_expression + : primary_expression ( + function_call_suffix + | initializer_suffix + | explicit_member_suffix + | postfix_self_suffix + | subscript_suffix + | forced_value_suffix + | optional_chaining_suffix + )* postfix_operator*? + ; + +function_call_suffix + : function_call_argument_clause? trailing_closures + | function_call_argument_clause + ; + +initializer_suffix + : DOT INIT (LPAREN argument_names RPAREN)? + ; + +explicit_member_suffix + : DOT (Decimal_digits | identifier ( generic_argument_clause | LPAREN argument_names RPAREN)?) + ; + +postfix_self_suffix + : DOT SELF + ; + +subscript_suffix + : LBRACK function_call_argument_list RBRACK + ; + +forced_value_suffix + : {!this.isBinaryOp(_input)}? BANG + ; + +optional_chaining_suffix + : {!this.isBinaryOp(_input)}? QUESTION + ; // Function Call Expression -function_call_argument_clause: - LPAREN function_call_argument_list? RPAREN; +function_call_argument_clause + : LPAREN function_call_argument_list? RPAREN + ; + +function_call_argument_list + : function_call_argument (COMMA function_call_argument)* + ; -function_call_argument_list: - function_call_argument (COMMA function_call_argument)*; +function_call_argument + : argument_name? (identifier /*optimization */ | expression | operator) + ; -function_call_argument: - argument_name? ( - identifier /*optimization */ - | expression - | operator - ); +trailing_closures + : closure_expression labeled_trailing_closures? + ; -trailing_closures: - closure_expression labeled_trailing_closures?; +labeled_trailing_closures + : labeled_trailing_closure+ + ; -labeled_trailing_closures: labeled_trailing_closure+; +labeled_trailing_closure + : identifier COLON closure_expression + ; -labeled_trailing_closure: identifier COLON closure_expression; +argument_names + : argument_name+ + ; -argument_names: argument_name+; -argument_name: identifier COLON; +argument_name + : identifier COLON + ; // Types // The following sets of rules are mutually left-recursive [type, optional_type, implicitly_unwrapped_optional_type, metatype_type], to avoid this they were integrated into the same rule. -type: - function_type - | array_type - | dictionary_type - | protocol_composition_type - | type_identifier - | tuple_type - | opaque_type - | type ( - {!this.isBinaryOp(_input)}? QUESTION //optional_type - | {!this.isBinaryOp(_input)}? BANG //implicitly_unwrapped_optional_type - | DOT TYPE - | DOT PROTOCOL - ) //metatype_type - | any_type - | self_type - | LPAREN type RPAREN; +type + : function_type + | array_type + | dictionary_type + | protocol_composition_type + | type_identifier + | tuple_type + | opaque_type + | type ( + {!this.isBinaryOp(_input)}? QUESTION //optional_type + | {!this.isBinaryOp(_input)}? BANG //implicitly_unwrapped_optional_type + | DOT TYPE + | DOT PROTOCOL + ) //metatype_type + | any_type + | self_type + | LPAREN type RPAREN + ; // Type Annotation -type_annotation: COLON attributes? INOUT? type; +type_annotation + : COLON attributes? INOUT? type + ; // Type identifier -type_identifier: - type_name generic_argument_clause? (DOT type_identifier)?; +type_identifier + : type_name generic_argument_clause? (DOT type_identifier)? + ; -type_name: identifier; +type_name + : identifier + ; // Tuple Type -tuple_type: LPAREN tuple_type_element_list? RPAREN; -tuple_type_element_list: - tuple_type_element (COMMA tuple_type_element)*; -tuple_type_element: - (element_name type_annotation | type) (EQUAL expression)? /* assigning value */; -element_name: - identifier+; // TODO understand a specific thing - _ +tuple_type + : LPAREN tuple_type_element_list? RPAREN + ; + +tuple_type_element_list + : tuple_type_element (COMMA tuple_type_element)* + ; + +tuple_type_element + : (element_name type_annotation | type) (EQUAL expression)? /* assigning value */ + ; + +element_name + : identifier+ + ; // TODO understand a specific thing - _ // Function Type -function_type: - attributes? function_type_argument_clause THROWS? arrow_operator type; +function_type + : attributes? function_type_argument_clause THROWS? arrow_operator type + ; -function_type_argument_clause: - LPAREN (function_type_argument_list range_operator?)? RPAREN; +function_type_argument_clause + : LPAREN (function_type_argument_list range_operator?)? RPAREN + ; -function_type_argument_list: - function_type_argument (COMMA function_type_argument)*; +function_type_argument_list + : function_type_argument (COMMA function_type_argument)* + ; -function_type_argument: - attributes? INOUT? type - | argument_label type_annotation; +function_type_argument + : attributes? INOUT? type + | argument_label type_annotation + ; -argument_label: - identifier+; // TODO Understand a specific thing - _ +argument_label + : identifier+ + ; // TODO Understand a specific thing - _ // Array Type -array_type: LBRACK type RBRACK; +array_type + : LBRACK type RBRACK + ; // Dictionary Type -dictionary_type: LBRACK type COLON type RBRACK; +dictionary_type + : LBRACK type COLON type RBRACK + ; // Protocol Composition Type -protocol_composition_type: - type_identifier (AND type_identifier)* trailing_composition_and?; +protocol_composition_type + : type_identifier (AND type_identifier)* trailing_composition_and? + ; -trailing_composition_and: - {!this.isBinaryOp(_input)}? AND; +trailing_composition_and + : {!this.isBinaryOp(_input)}? AND + ; // Opaque Type -opaque_type: SOME type; +opaque_type + : SOME type + ; // Any Type -any_type: ANY; +any_type + : ANY + ; // Self Type -self_type: SELF_BIG; +self_type + : SELF_BIG + ; // Type Inheritance Clause -type_inheritance_clause: COLON type_inheritance_list; +type_inheritance_clause + : COLON type_inheritance_list + ; -type_inheritance_list: type_identifier (COMMA type_identifier)*; +type_inheritance_list + : type_identifier (COMMA type_identifier)* + ; // Identifiers -identifier: - ( - LINUX - | WINDOWS - | ALPHA - | ARCH - | ARM - | ARM64 - | ASSIGNMENT - | BLUE - | CAN_IMPORT - | COMPILER - | FILE - | GREEN - | HIGHER_THAN - | I386 - | I_OS - | OSX - | I_OS_APPLICATION_EXTENSION - | LINE - | LOWER_THAN - | MAC_CATALYST - | MAC_CATALYST_APPLICATION_EXTENSION - | MAC_OS - | MAC_OS_APPLICATION_EXTENSION - | OS - | PRECEDENCE_GROUP - | RED - | RESOURCE_NAME - | SAFE - | SIMULATOR - | SOME - | SWIFT - | TARGET_ENVIRONMENT - | TV_OS - | UNSAFE - | WATCH_OS - | X86_64 - - // Keywords reserved in particular contexts - | ASSOCIATIVITY - | CONVENIENCE - | DYNAMIC - | DID_SET - | FINAL - | GET - | INFIX - | INDIRECT - | LAZY - | LEFT - | MUTATING - | NONE - | NONMUTATING - | OPTIONAL - | OVERRIDE - | POSTFIX - | PRECEDENCE - | PREFIX - | PROTOCOL - | REQUIRED - | RIGHT - | SET - | TYPE - | UNOWNED - | WEAK - | WILL_SET - | IN - | FOR - | GUARD - | WHERE - | DEFAULT - | INTERNAL - | PRIVATE - | PUBLIC - | OPEN - | AS - | PREFIX - | POSTFIX - | WHILE - | SELF - | SELF_BIG - | SET - | CLASS - | GETTER - | SETTER - | OPERATOR - | DO - | CATCH - ) - | Identifier - | BACKTICK (keyword | Identifier | DOLLAR) BACKTICK; - -identifier_list: identifier (COMMA identifier)*; +identifier + : ( + LINUX + | WINDOWS + | ALPHA + | ARCH + | ARM + | ARM64 + | ASSIGNMENT + | BLUE + | CAN_IMPORT + | COMPILER + | FILE + | GREEN + | HIGHER_THAN + | I386 + | I_OS + | OSX + | I_OS_APPLICATION_EXTENSION + | LINE + | LOWER_THAN + | MAC_CATALYST + | MAC_CATALYST_APPLICATION_EXTENSION + | MAC_OS + | MAC_OS_APPLICATION_EXTENSION + | OS + | PRECEDENCE_GROUP + | RED + | RESOURCE_NAME + | SAFE + | SIMULATOR + | SOME + | SWIFT + | TARGET_ENVIRONMENT + | TV_OS + | UNSAFE + | WATCH_OS + | X86_64 + + // Keywords reserved in particular contexts + | ASSOCIATIVITY + | CONVENIENCE + | DYNAMIC + | DID_SET + | FINAL + | GET + | INFIX + | INDIRECT + | LAZY + | LEFT + | MUTATING + | NONE + | NONMUTATING + | OPTIONAL + | OVERRIDE + | POSTFIX + | PRECEDENCE + | PREFIX + | PROTOCOL + | REQUIRED + | RIGHT + | SET + | TYPE + | UNOWNED + | WEAK + | WILL_SET + | IN + | FOR + | GUARD + | WHERE + | DEFAULT + | INTERNAL + | PRIVATE + | PUBLIC + | OPEN + | AS + | PREFIX + | POSTFIX + | WHILE + | SELF + | SELF_BIG + | SET + | CLASS + | GETTER + | SETTER + | OPERATOR + | DO + | CATCH + ) + | Identifier + | BACKTICK (keyword | Identifier | DOLLAR) BACKTICK + ; + +identifier_list + : identifier (COMMA identifier)* + ; // Keywords and Punctuation -keyword: - // Keywords used in declarations - ASSOCIATED_TYPE - | CLASS - | DEINIT - | ENUM - | EXTENSION - | FILE_PRIVATE - | FUNC - | IMPORT - | INIT - | INOUT - | INTERNAL - | LET - | OPEN - | OPERATOR - | PRIVATE - | PROTOCOL - | PUBLIC - | RETHROWS - | STATIC - | STRUCT - | SUBSCRIPT - | TYPEALIAS - | VAR - // Keywords used in statements - | BREAK - | CASE - | CONTINUE - | DEFAULT - | DEFER - | DO - | ELSE - | FALLTHROUGH - | FOR - | GUARD - | IF - | IN - | REPEAT - | RETURN - | SWITCH - | WHERE - | WHILE - // Keywords used in expressions and types - | AS - | ANY - | CATCH - | FALSE - | IS - | NIL - | SUPER - | SELF - | SELF_BIG - | THROW - | THROWS - | TRUE - | TRY - // Keywords used in patterns - | UNDERSCORE - // Keywords that begin with a number sign (#) - | AVAILABLE - | HASH_COLOR_LITERAL - | HASH_COLUMN - | HASH_ELSE - | HASH_ELSEIF - | HASH_ENDIF - | ERROR - | HASH_FILE - | HASH_FILE_ID - | HASH_FILE_LITERAL - | HASH_FILE_PATH - | HASH_FUNCTION - | HASH_IF - | HASH_IMAGE_LITERAL - | HASH_LINE - | HASH_SELECTOR - | SOURCE_LOCATION - | WARNING; +keyword + : + // Keywords used in declarations + ASSOCIATED_TYPE + | CLASS + | DEINIT + | ENUM + | EXTENSION + | FILE_PRIVATE + | FUNC + | IMPORT + | INIT + | INOUT + | INTERNAL + | LET + | OPEN + | OPERATOR + | PRIVATE + | PROTOCOL + | PUBLIC + | RETHROWS + | STATIC + | STRUCT + | SUBSCRIPT + | TYPEALIAS + | VAR + // Keywords used in statements + | BREAK + | CASE + | CONTINUE + | DEFAULT + | DEFER + | DO + | ELSE + | FALLTHROUGH + | FOR + | GUARD + | IF + | IN + | REPEAT + | RETURN + | SWITCH + | WHERE + | WHILE + // Keywords used in expressions and types + | AS + | ANY + | CATCH + | FALSE + | IS + | NIL + | SUPER + | SELF + | SELF_BIG + | THROW + | THROWS + | TRUE + | TRY + // Keywords used in patterns + | UNDERSCORE + // Keywords that begin with a number sign (#) + | AVAILABLE + | HASH_COLOR_LITERAL + | HASH_COLUMN + | HASH_ELSE + | HASH_ELSEIF + | HASH_ENDIF + | ERROR + | HASH_FILE + | HASH_FILE_ID + | HASH_FILE_LITERAL + | HASH_FILE_PATH + | HASH_FUNCTION + | HASH_IF + | HASH_IMAGE_LITERAL + | HASH_LINE + | HASH_SELECTOR + | SOURCE_LOCATION + | WARNING + ; // Operators // Assignment Operator -assignment_operator: {this.isBinaryOp(_input)}? EQUAL; - -negate_prefix_operator: {this.isPrefixOp(_input)}? SUB; - -compilation_condition_AND: - {this.isOperator(_input,"&&")}? AND AND; -compilation_condition_OR: - {this.isOperator(_input,"||")}? OR OR; -compilation_condition_GE: - {this.isOperator(_input,">=")}? GT EQUAL; -compilation_condition_L: {this.isOperator(_input,"<")}? LT; -arrow_operator: {this.isOperator(_input,"->")}? SUB GT; -range_operator: {this.isOperator(_input,"...")}? DOT DOT DOT; -same_type_equals: - {this.isOperator(_input,"==")}? EQUAL EQUAL; - -binary_operator: {this.isBinaryOp(_input)}? operator; - -prefix_operator: {this.isPrefixOp(_input)}? operator; - -postfix_operator: {this.isPostfixOp(_input)}? operator; - -operator: - operator_head operator_characters? - | dot_operator_head dot_operator_characters; - -operator_head: ( - DIV - | EQUAL - | SUB - | ADD - | BANG - | MUL - | MOD - | AND - | OR - | LT - | GT - | CARET - | TILDE - | QUESTION - ) // wrapping in (..) makes it a fast set comparison - | Operator_head_other; - -operator_character: - operator_head - | Operator_following_character; - -operator_characters: ( - {_input.get(_input.index()-1).getType()!=WS}? operator_character - )+; - -dot_operator_head: DOT; -dot_operator_character: DOT | operator_character; -dot_operator_characters: ( - {_input.get(_input.index()-1).getType()!=WS}? dot_operator_character - )+; +assignment_operator + : {this.isBinaryOp(_input)}? EQUAL + ; + +negate_prefix_operator + : {this.isPrefixOp(_input)}? SUB + ; + +compilation_condition_AND + : {this.isOperator(_input,"&&")}? AND AND + ; + +compilation_condition_OR + : {this.isOperator(_input,"||")}? OR OR + ; + +compilation_condition_GE + : {this.isOperator(_input,">=")}? GT EQUAL + ; + +compilation_condition_L + : {this.isOperator(_input,"<")}? LT + ; + +arrow_operator + : {this.isOperator(_input,"->")}? SUB GT + ; + +range_operator + : {this.isOperator(_input,"...")}? DOT DOT DOT + ; + +same_type_equals + : {this.isOperator(_input,"==")}? EQUAL EQUAL + ; + +binary_operator + : {this.isBinaryOp(_input)}? operator + ; + +prefix_operator + : {this.isPrefixOp(_input)}? operator + ; + +postfix_operator + : {this.isPostfixOp(_input)}? operator + ; + +operator + : operator_head operator_characters? + | dot_operator_head dot_operator_characters + ; + +operator_head + : ( + DIV + | EQUAL + | SUB + | ADD + | BANG + | MUL + | MOD + | AND + | OR + | LT + | GT + | CARET + | TILDE + | QUESTION + ) // wrapping in (..) makes it a fast set comparison + | Operator_head_other + ; + +operator_character + : operator_head + | Operator_following_character + ; + +operator_characters + : ({_input.get(_input.index()-1).getType()!=WS}? operator_character)+ + ; + +dot_operator_head + : DOT + ; + +dot_operator_character + : DOT + | operator_character + ; + +dot_operator_characters + : ({_input.get(_input.index()-1).getType()!=WS}? dot_operator_character)+ + ; // Literals -literal: - numeric_literal - | string_literal - | boolean_literal - | nil_literal; - -numeric_literal: - negate_prefix_operator? integer_literal - | negate_prefix_operator? Floating_point_literal; - -boolean_literal: TRUE | FALSE; - -nil_literal: NIL; +literal + : numeric_literal + | string_literal + | boolean_literal + | nil_literal + ; + +numeric_literal + : negate_prefix_operator? integer_literal + | negate_prefix_operator? Floating_point_literal + ; + +boolean_literal + : TRUE + | FALSE + ; + +nil_literal + : NIL + ; // Integer Literals -integer_literal: - Decimal_digits - | Decimal_literal - | Binary_literal - | Octal_literal - | Hexadecimal_literal; +integer_literal + : Decimal_digits + | Decimal_literal + | Binary_literal + | Octal_literal + | Hexadecimal_literal + ; // String Literals -string_literal: - extended_string_literal - | interpolated_string_literal - | static_string_literal; - -extended_string_literal: - Multi_line_extended_string_open Quoted_multi_line_extended_text+ - Multi_line_extended_string_close - | Single_line_extended_string_open Quoted_single_line_extended_text+ - Single_line_extended_string_close; - -static_string_literal: - Single_line_string_open Quoted_single_line_text* Single_line_string_close - | Multi_line_string_open Quoted_multi_line_text* Multi_line_string_close; - -interpolated_string_literal: - Single_line_string_open ( - Quoted_single_line_text - | Interpolataion_single_line ( - expression - | tuple_element COMMA tuple_element_list - ) RPAREN - )* Single_line_string_close - | Multi_line_string_open ( - Quoted_multi_line_text - | Interpolataion_multi_line ( - expression - | tuple_element COMMA tuple_element_list - ) RPAREN - )* Multi_line_string_close; +string_literal + : extended_string_literal + | interpolated_string_literal + | static_string_literal + ; + +extended_string_literal + : Multi_line_extended_string_open Quoted_multi_line_extended_text+ Multi_line_extended_string_close + | Single_line_extended_string_open Quoted_single_line_extended_text+ Single_line_extended_string_close + ; + +static_string_literal + : Single_line_string_open Quoted_single_line_text* Single_line_string_close + | Multi_line_string_open Quoted_multi_line_text* Multi_line_string_close + ; + +interpolated_string_literal + : Single_line_string_open ( + Quoted_single_line_text + | Interpolataion_single_line (expression | tuple_element COMMA tuple_element_list) RPAREN + )* Single_line_string_close + | Multi_line_string_open ( + Quoted_multi_line_text + | Interpolataion_multi_line (expression | tuple_element COMMA tuple_element_list) RPAREN + )* Multi_line_string_close + ; \ No newline at end of file diff --git a/szf/szf.g4 b/szf/szf.g4 index 30f9e88aa0..213c0a363b 100644 --- a/szf/szf.g4 +++ b/szf/szf.g4 @@ -29,54 +29,57 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar szf; file_ - : header_* EOF - ; + : header_* EOF + ; header_ - : HEADER_START (keyvalue_ | region_)* - ; + : HEADER_START (keyvalue_ | region_)* + ; region_ - : REGION_START keyvalue_* - ; + : REGION_START keyvalue_* + ; keyvalue_ - : key_ '=' value_ - ; + : key_ '=' value_ + ; key_ - : ID - ; + : ID + ; value_ - : ID - | NUM - ; + : ID + | NUM + ; HEADER_START - : '' - ; + : '' + ; REGION_START - : '' - ; + : '' + ; ID - : [a-zA-Z] [a-zA-Z0-9._/#]* - ; + : [a-zA-Z] [a-zA-Z0-9._/#]* + ; NUM - : [0-9]+ ('.' [0-9]+)? - ; + : [0-9]+ ('.' [0-9]+)? + ; COMMENT - : '//' ~ [\r\n]* -> skip - ; + : '//' ~ [\r\n]* -> skip + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/tcpheader/tcp.g4 b/tcpheader/tcp.g4 index c59ccc4d6b..7e965aa70f 100644 --- a/tcpheader/tcp.g4 +++ b/tcpheader/tcp.g4 @@ -29,61 +29,64 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tcp; segmentheader - : sourceport destinationport sequencenumber acknumber flags windowsize checksum urgent - ; + : sourceport destinationport sequencenumber acknumber flags windowsize checksum urgent + ; sourceport - : word_ - ; + : word_ + ; destinationport - : word_ - ; + : word_ + ; sequencenumber - : dword_ - ; + : dword_ + ; acknumber - : dword_ - ; + : dword_ + ; flags - : word_ - ; + : word_ + ; windowsize - : word_ - ; + : word_ + ; checksum - : word_ - ; + : word_ + ; urgent - : word_ - ; + : word_ + ; dword_ - : BYTE BYTE BYTE BYTE - ; + : BYTE BYTE BYTE BYTE + ; word_ - : BYTE BYTE - ; + : BYTE BYTE + ; byte_ - : BYTE - ; + : BYTE + ; BYTE - : '\u0000' .. '\u00FF' - ; + : '\u0000' .. '\u00FF' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/teal/Teal.g4 b/teal/Teal.g4 index 0d257884bc..13db4771e6 100644 --- a/teal/Teal.g4 +++ b/teal/Teal.g4 @@ -1,4 +1,8 @@ // Project: https://github.com/teal-language/tl + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Teal; chunk @@ -10,26 +14,26 @@ block ; stat - : ';' # SemiStat - | varlist '=' explist # AssignStat - | functioncall # FuncCallStat - | label # LabelStat - | 'break' # BreakStat - | 'goto' NAME # GotoStat - | 'do' block 'end' # DoStat - | 'while' exp 'do' block 'end' # WhileStat - | 'repeat' block 'until' exp # RepeatStat - | 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end' # IfStat - | 'for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end' # ForStat - | 'for' namelist 'in' explist 'do' block 'end' # ForInStat - | 'function' funcname funcbody # FuncStat - | 'local' 'function' NAME funcbody # LocalFuncStat - | 'local' attnamelist (':' typelist)? ('=' explist)? # LocalAttrAssignStat - | 'local' NAME '=' newtype # LocalNewTypeStat - | 'global' 'function' NAME funcbody # GlobalFuncStat - | 'global' attnamelist ':' typelist # GlobalAttrStat - | 'global' attnamelist (':' typelist)? '=' explist # GlobalAttrAssignStat - | 'global' NAME '=' newtype # GlobalAssignStat + : ';' # SemiStat + | varlist '=' explist # AssignStat + | functioncall # FuncCallStat + | label # LabelStat + | 'break' # BreakStat + | 'goto' NAME # GotoStat + | 'do' block 'end' # DoStat + | 'while' exp 'do' block 'end' # WhileStat + | 'repeat' block 'until' exp # RepeatStat + | 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end' # IfStat + | 'for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end' # ForStat + | 'for' namelist 'in' explist 'do' block 'end' # ForInStat + | 'function' funcname funcbody # FuncStat + | 'local' 'function' NAME funcbody # LocalFuncStat + | 'local' attnamelist (':' typelist)? ('=' explist)? # LocalAttrAssignStat + | 'local' NAME '=' newtype # LocalNewTypeStat + | 'global' 'function' NAME funcbody # GlobalFuncStat + | 'global' attnamelist ':' typelist # GlobalAttrStat + | 'global' attnamelist (':' typelist)? '=' explist # GlobalAttrAssignStat + | 'global' NAME '=' newtype # GlobalAssignStat ; attnamelist @@ -47,8 +51,12 @@ typ ; basetype - : 'string' | 'boolean' | 'nil' | 'number' - | '{' typ '}' | '{' typ ':' typ '}' + : 'string' + | 'boolean' + | 'nil' + | 'number' + | '{' typ '}' + | '{' typ ':' typ '}' | 'function' functiontype | NAME typeargs? ; @@ -63,13 +71,13 @@ retlist ; typeargs - : '<' NAME (',' NAME )* '>' + : '<' NAME (',' NAME)* '>' ; newtype - : 'record' typeargs? ('{' typ '}')? (NAME '=' newtype)* (NAME ':' typ)* 'end' # RecordNewType - | 'enum' str* 'end' # EnumNewType - | 'functiontype' functiontype # FuncNewType + : 'record' typeargs? ('{' typ '}')? (NAME '=' newtype)* (NAME ':' typ)* 'end' # RecordNewType + | 'enum' str* 'end' # EnumNewType + | 'functiontype' functiontype # FuncNewType ; functiontype @@ -93,7 +101,7 @@ parname ; retstat - : 'return' explist? ';'? # ReturnStat + : 'return' explist? ';'? # ReturnStat ; label @@ -117,7 +125,9 @@ explist ; exp - : 'nil' | 'false' | 'true' + : 'nil' + | 'false' + | 'true' | number | str | '...' @@ -125,11 +135,11 @@ exp | prefixexp | tableconstructor | exp 'as' typ - | exp operatorPower exp + | exp operatorPower exp | operatorUnary exp | exp operatorMulDivMod exp | exp operatorAddSub exp - | exp operatorStrcat exp + | exp operatorStrcat exp | exp operatorComparison exp | NAME 'is' typ | exp operatorAnd exp @@ -146,7 +156,8 @@ functioncall ; varOrExp - : variable | '(' exp ')' + : variable + | '(' exp ')' ; // we rename `var` to `variable` because of keyword `var` @@ -163,7 +174,9 @@ nameAndArgs ; args - : '(' explist? ')' | tableconstructor | str + : '(' explist? ')' + | tableconstructor + | str ; functiondef @@ -175,8 +188,10 @@ funcbody ; parlist - : namelist (',' '...')? | '...' - | parnamelist (',' '...' (':' typ)?)? | '...' (':' typ)? + : namelist (',' '...')? + | '...' + | parnamelist (',' '...' (':' typ)?)? + | '...' (':' typ)? ; tableconstructor @@ -188,49 +203,80 @@ fieldlist ; field - : '[' exp ']' '=' exp # BracketAssginField - | NAME (':' typ)? '=' exp # AssignField - | NAME '=' newtype # AssignNewTypeField - | exp # ExprField + : '[' exp ']' '=' exp # BracketAssginField + | NAME (':' typ)? '=' exp # AssignField + | NAME '=' newtype # AssignNewTypeField + | exp # ExprField ; fieldsep - : ',' | ';' + : ',' + | ';' ; operatorOr - : 'or'; + : 'or' + ; operatorAnd - : 'and'; + : 'and' + ; operatorComparison - : '<' | '>' | '<=' | '>=' | '~=' | '=='; + : '<' + | '>' + | '<=' + | '>=' + | '~=' + | '==' + ; operatorStrcat - : '..'; + : '..' + ; operatorAddSub - : '+' | '-'; + : '+' + | '-' + ; operatorMulDivMod - : '*' | '/' | '%' | '//'; + : '*' + | '/' + | '%' + | '//' + ; operatorBitwise - : '&' | '|' | '~' | '<<' | '>>'; + : '&' + | '|' + | '~' + | '<<' + | '>>' + ; operatorUnary - : 'not' | '#' | '-' | '~'; + : 'not' + | '#' + | '-' + | '~' + ; operatorPower - : '^'; + : '^' + ; number - : INT | HEX | FLOAT | HEX_FLOAT + : INT + | HEX + | FLOAT + | HEX_FLOAT ; str - : NORMALSTRING | CHARSTRING | LONGSTRING + : NORMALSTRING + | CHARSTRING + | LONGSTRING ; // LEXER @@ -240,19 +286,18 @@ NAME ; NORMALSTRING - : '"' ( EscapeSequence | ~('\\'|'"') )* '"' + : '"' (EscapeSequence | ~('\\' | '"'))* '"' ; CHARSTRING - : '\'' ( EscapeSequence | ~('\''|'\\') )* '\'' + : '\'' (EscapeSequence | ~('\'' | '\\'))* '\'' ; LONGSTRING : '[' NESTED_STR ']' ; -fragment -NESTED_STR +fragment NESTED_STR : '=' NESTED_STR '=' | '[' .*? ']' ; @@ -277,18 +322,15 @@ HEX_FLOAT | '0' [xX] HexDigit+ HexExponentPart ; -fragment -ExponentPart +fragment ExponentPart : [eE] [+-]? Digit+ ; -fragment -HexExponentPart +fragment HexExponentPart : [pP] [+-]? Digit+ ; -fragment -EscapeSequence +fragment EscapeSequence : '\\' [abfnrtvz"'\\] | '\\' '\r'? '\n' | DecimalEscape @@ -296,30 +338,25 @@ EscapeSequence | UtfEscape ; -fragment -DecimalEscape +fragment DecimalEscape : '\\' Digit | '\\' Digit Digit | '\\' [0-2] Digit Digit ; -fragment -HexEscape +fragment HexEscape : '\\' 'x' HexDigit HexDigit ; -fragment -UtfEscape +fragment UtfEscape : '\\' 'u{' HexDigit+ '}' ; -fragment -Digit +fragment Digit : [0-9] ; -fragment -HexDigit +fragment HexDigit : [0-9a-fA-F] ; @@ -329,13 +366,12 @@ COMMENT ; LINE_COMMENT - : '--' - ( // -- - | '[' '='* // --[== - | '[' '='* ~('='|'['|'\r'|'\n') ~('\r'|'\n')* // --[==AA - | ~('['|'\r'|'\n') ~('\r'|'\n')* // --AAA - ) ('\r\n'|'\r'|'\n'|EOF) - -> channel(HIDDEN) + : '--' ( + // -- + | '[' '='* // --[== + | '[' '='* ~('=' | '[' | '\r' | '\n') ~('\r' | '\n')* // --[==AA + | ~('[' | '\r' | '\n') ~('\r' | '\n')* // --AAA + ) ('\r\n' | '\r' | '\n' | EOF) -> channel(HIDDEN) ; WS @@ -343,6 +379,5 @@ WS ; SHEBANG - : '#' '!' ~('\n'|'\r')* -> channel(HIDDEN) - ; - + : '#' '!' ~('\n' | '\r')* -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/telephone/telephone.g4 b/telephone/telephone.g4 index 771039ce1c..d624db3cbd 100644 --- a/telephone/telephone.g4 +++ b/telephone/telephone.g4 @@ -30,49 +30,52 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar telephone; test - : number EOF - ; + : number EOF + ; number - : '+1'? '+'? variation - ; + : '+1'? '+'? variation + ; variation - : nanp - | japan - ; + : nanp + | japan + ; // North American Numbering Plan nanp - : '011' areacode exchange subscriber - ; + : '011' areacode exchange subscriber + ; areacode - : DIGIT DIGIT DIGIT - ; + : DIGIT DIGIT DIGIT + ; // Exhange exchange - : DIGIT DIGIT DIGIT - ; + : DIGIT DIGIT DIGIT + ; // Subscriber subscriber - : DIGIT DIGIT DIGIT DIGIT - ; + : DIGIT DIGIT DIGIT DIGIT + ; // Japan japan - : '010' areacode exchange subscriber - ; + : '010' areacode exchange subscriber + ; DIGIT - : [0-9] - ; + : [0-9] + ; WS - : [ \r\n] + -> skip - ; + : [ \r\n]+ -> skip + ; \ No newline at end of file diff --git a/terraform/terraform.g4 b/terraform/terraform.g4 index fc2a756317..a626151c48 100644 --- a/terraform/terraform.g4 +++ b/terraform/terraform.g4 @@ -29,256 +29,260 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar terraform; file_ - : (local | module | output | provider | variable | data | resource | terraform)+ EOF - ; + : (local | module | output | provider | variable | data | resource | terraform)+ EOF + ; terraform - : 'terraform' blockbody - ; + : 'terraform' blockbody + ; resource - : 'resource' resourcetype name blockbody - ; + : 'resource' resourcetype name blockbody + ; data - : 'data' resourcetype name blockbody - ; + : 'data' resourcetype name blockbody + ; provider - : PROVIDER resourcetype blockbody - ; + : PROVIDER resourcetype blockbody + ; output - : 'output' name blockbody - ; + : 'output' name blockbody + ; local - : 'locals' blockbody - ; + : 'locals' blockbody + ; module - : 'module' name blockbody - ; + : 'module' name blockbody + ; variable - : VARIABLE name blockbody - ; + : VARIABLE name blockbody + ; block - : blocktype label* blockbody - ; + : blocktype label* blockbody + ; blocktype - : IDENTIFIER - ; + : IDENTIFIER + ; resourcetype - : STRING - ; + : STRING + ; name - : STRING - ; + : STRING + ; label - : STRING - ; + : STRING + ; blockbody - : LCURL (argument | block)* RCURL - ; + : LCURL (argument | block)* RCURL + ; argument - : identifier '=' expression - ; + : identifier '=' expression + ; identifier - : (('local' | 'data' | 'var' | 'module') DOT)? identifierchain - ; + : (('local' | 'data' | 'var' | 'module') DOT)? identifierchain + ; identifierchain - : (IDENTIFIER | IN | VARIABLE | PROVIDER) index? (DOT identifierchain)* - | STAR (DOT identifierchain)* - | inline_index (DOT identifierchain)* - ; + : (IDENTIFIER | IN | VARIABLE | PROVIDER) index? (DOT identifierchain)* + | STAR (DOT identifierchain)* + | inline_index (DOT identifierchain)* + ; inline_index - : NATURAL_NUMBER - ; + : NATURAL_NUMBER + ; expression - : section - | expression operator_ expression - | LPAREN expression RPAREN - | expression '?' expression ':' expression - | forloop - ; + : section + | expression operator_ expression + | LPAREN expression RPAREN + | expression '?' expression ':' expression + | forloop + ; forloop - : 'for' identifier IN expression ':' expression - ; + : 'for' identifier IN expression ':' expression + ; section - : list_ - | map_ - | val - ; + : list_ + | map_ + | val + ; val - : NULL_ - | signed_number - | string - | identifier - | BOOL - | DESCRIPTION - | filedecl - | functioncall - | EOF_ - ; + : NULL_ + | signed_number + | string + | identifier + | BOOL + | DESCRIPTION + | filedecl + | functioncall + | EOF_ + ; functioncall - : functionname LPAREN functionarguments RPAREN - | 'jsonencode' LPAREN (.)*? RPAREN - ; + : functionname LPAREN functionarguments RPAREN + | 'jsonencode' LPAREN (.)*? RPAREN + ; functionname - : IDENTIFIER - ; + : IDENTIFIER + ; functionarguments - : //no arguments - | expression (',' expression)* - ; + : //no arguments + | expression (',' expression)* + ; index - : '[' expression ']' - ; + : '[' expression ']' + ; filedecl - : 'file' '(' expression ')' - ; + : 'file' '(' expression ')' + ; list_ - : '[' (expression (',' expression)* ','?)? ']' - ; + : '[' (expression (',' expression)* ','?)? ']' + ; map_ - : LCURL (argument ','?)* RCURL - ; + : LCURL (argument ','?)* RCURL + ; string - : STRING - | MULTILINESTRING - ; + : STRING + | MULTILINESTRING + ; fragment DIGIT - : [0-9] - ; + : [0-9] + ; signed_number - : ('+' | '-')? number - ; + : ('+' | '-')? number + ; VARIABLE - : 'variable' - ; + : 'variable' + ; PROVIDER - : 'provider' - ; + : 'provider' + ; IN - : 'in' - ; + : 'in' + ; STAR - : '*' - ; + : '*' + ; DOT - : '.' - ; + : '.' + ; operator_ - : '/' - | STAR - | '%' - | '+' - | '-' - | '>' - | '>=' - | '<' - | '<=' - | '==' - | '!=' - | '&&' - | '||' - ; + : '/' + | STAR + | '%' + | '+' + | '-' + | '>' + | '>=' + | '<' + | '<=' + | '==' + | '!=' + | '&&' + | '||' + ; LCURL - : '{' - ; + : '{' + ; RCURL - : '}' - ; + : '}' + ; LPAREN - : '(' - ; + : '(' + ; RPAREN - : ')' - ; + : ')' + ; EOF_ - : '< channel(HIDDEN) - ; + : ('#' | '//') ~ [\r\n]* -> channel(HIDDEN) + ; BLOCKCOMMENT - : '/*' .*? '*/' -> channel(HIDDEN) - ; + : '/*' .*? '*/' -> channel(HIDDEN) + ; WS - : [ \r\n\t]+ -> skip - ; + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/thrift/Thrift.g4 b/thrift/Thrift.g4 index df2aee3fcc..9f3f065b61 100644 --- a/thrift/Thrift.g4 +++ b/thrift/Thrift.g4 @@ -1,3 +1,6 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Thrift; document @@ -5,7 +8,9 @@ document ; header - : include_ | namespace_ | cpp_include + : include_ + | namespace_ + | cpp_include ; include_ @@ -23,13 +28,19 @@ cpp_include : 'cpp_include' LITERAL ; - definition - : const_rule | typedef_ | enum_rule | senum | struct_ | union_ | exception | service + : const_rule + | typedef_ + | enum_rule + | senum + | struct_ + | union_ + | exception + | service ; const_rule - : 'const' field_type IDENTIFIER ( '=' const_value )? list_separator? + : 'const' field_type IDENTIFIER ('=' const_value)? list_separator? ; typedef_ @@ -94,7 +105,6 @@ throws_list : 'throws' '(' field* ')' ; - type_annotations : '(' type_annotation* ')' ; @@ -104,12 +114,14 @@ type_annotation ; annotation_value - : integer | LITERAL + : integer + | LITERAL ; - field_type - : base_type | IDENTIFIER | container_type + : base_type + | IDENTIFIER + | container_type ; base_type @@ -137,11 +149,17 @@ cpp_type ; const_value - : integer | DOUBLE | LITERAL | IDENTIFIER | const_list | const_map + : integer + | DOUBLE + | LITERAL + | IDENTIFIER + | const_list + | const_map ; integer - : INTEGER | HEX_INTEGER + : INTEGER + | HEX_INTEGER ; INTEGER @@ -153,7 +171,7 @@ HEX_INTEGER ; DOUBLE - : ('+' | '-')? ( DIGIT+ ('.' DIGIT+)? | '.' DIGIT+ ) (('E' | 'e') INTEGER)? + : ('+' | '-')? (DIGIT+ ('.' DIGIT+)? | '.' DIGIT+) (('E' | 'e') INTEGER)? ; const_list @@ -169,29 +187,61 @@ const_map ; list_separator - : COMMA | ';' + : COMMA + | ';' ; real_base_type - : TYPE_BOOL | TYPE_BYTE | TYPE_I16 | TYPE_I32 | TYPE_I64 | TYPE_DOUBLE | TYPE_STRING | TYPE_BINARY + : TYPE_BOOL + | TYPE_BYTE + | TYPE_I16 + | TYPE_I32 + | TYPE_I64 + | TYPE_DOUBLE + | TYPE_STRING + | TYPE_BINARY ; -TYPE_BOOL: 'bool'; -TYPE_BYTE: 'byte'; -TYPE_I16: 'i16'; -TYPE_I32: 'i32'; -TYPE_I64: 'i64'; -TYPE_DOUBLE: 'double'; -TYPE_STRING: 'string'; -TYPE_BINARY: 'binary'; +TYPE_BOOL + : 'bool' + ; -LITERAL - : '"' ( ESC_SEQ | ~[\\"] )* '"' - | '\'' ( ESC_SEQ | ~[\\'] )* '\'' +TYPE_BYTE + : 'byte' + ; + +TYPE_I16 + : 'i16' + ; + +TYPE_I32 + : 'i32' + ; + +TYPE_I64 + : 'i64' + ; + +TYPE_DOUBLE + : 'double' ; -fragment ESC_SEQ : '\\' [rnt"'\\] ; +TYPE_STRING + : 'string' + ; +TYPE_BINARY + : 'binary' + ; + +LITERAL + : '"' (ESC_SEQ | ~[\\"])* '"' + | '\'' ( ESC_SEQ | ~[\\'])* '\'' + ; + +fragment ESC_SEQ + : '\\' [rnt"'\\] + ; IDENTIFIER : (LETTER | '_') (LETTER | DIGIT | '.' | '_')* @@ -202,15 +252,18 @@ COMMA ; fragment LETTER - : 'A'..'Z' | 'a'..'z' + : 'A' ..'Z' + | 'a' ..'z' ; fragment DIGIT - : '0'..'9' + : '0' ..'9' ; fragment HEX_DIGIT - : DIGIT | 'A'..'F' | 'a'..'f' + : DIGIT + | 'A' ..'F' + | 'a' ..'f' ; WS @@ -223,4 +276,4 @@ SL_COMMENT ML_COMMENT : '/*' .*? '*/' -> channel(HIDDEN) - ; + ; \ No newline at end of file diff --git a/tiny/tiny.g4 b/tiny/tiny.g4 index 3c3bc392bb..071f0a5999 100644 --- a/tiny/tiny.g4 +++ b/tiny/tiny.g4 @@ -26,77 +26,79 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tiny; program - : 'BEGIN' stmt_list 'END' EOF - ; + : 'BEGIN' stmt_list 'END' EOF + ; stmt_list - : stmt_list stmt - | stmt - ; + : stmt_list stmt + | stmt + ; stmt - : assign_stmt - | read_stmt - | write_stmt - ; + : assign_stmt + | read_stmt + | write_stmt + ; assign_stmt - : ident ':=' expr - ; + : ident ':=' expr + ; read_stmt - : 'READ' id_list - ; + : 'READ' id_list + ; write_stmt - : 'WRITE' expr_list - ; + : 'WRITE' expr_list + ; id_list - : id_list ',' ident - | ident - ; + : id_list ',' ident + | ident + ; expr_list - : expr_list ',' expr - | expr - ; + : expr_list ',' expr + | expr + ; expr - : expr op factor - | factor - ; + : expr op factor + | factor + ; factor - : ident - | integer - ; + : ident + | integer + ; integer - : '-'? NUMBER - ; + : '-'? NUMBER + ; op - : '+' - | '-' - ; + : '+' + | '-' + ; ident - : ID - ; - + : ID + ; ID - : ('a' .. 'z' | 'A' .. 'Z')+ - ; + : ('a' .. 'z' | 'A' .. 'Z')+ + ; NUMBER - : ('0' .. '9')+ - ; + : ('0' .. '9')+ + ; WS - : [ \r\n] -> skip - ; + : [ \r\n] -> skip + ; \ No newline at end of file diff --git a/tinybasic/tinybasic.g4 b/tinybasic/tinybasic.g4 index 9011cf6e84..28367f1908 100644 --- a/tinybasic/tinybasic.g4 +++ b/tinybasic/tinybasic.g4 @@ -26,6 +26,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tinybasic; program @@ -33,45 +36,44 @@ program ; line - : number statement CR - | statement CR - ; + : number statement CR + | statement CR + ; statement - : 'PRINT' exprlist - | 'IF' expression relop expression 'THEN'? statement - | 'GOTO' number - | 'INPUT' varlist - | 'LET'? vara '=' expression - | 'GOSUB' expression - | 'RETURN' - | 'CLEAR' - | 'LIST' - | 'RUN' - | 'END' - ; + : 'PRINT' exprlist + | 'IF' expression relop expression 'THEN'? statement + | 'GOTO' number + | 'INPUT' varlist + | 'LET'? vara '=' expression + | 'GOSUB' expression + | 'RETURN' + | 'CLEAR' + | 'LIST' + | 'RUN' + | 'END' + ; exprlist - : (STRING | expression) (',' (STRING | expression))* - ; + : (STRING | expression) (',' (STRING | expression))* + ; varlist - : vara (',' vara)* - ; + : vara (',' vara)* + ; expression - : ('+' | '-' )? term (('+' | '-') term)* - ; + : ('+' | '-')? term (('+' | '-') term)* + ; term - : factor (('*' | '/') factor)* - ; + : factor (('*' | '/') factor)* + ; factor - : - vara - | number - ; + : vara + | number + ; vara : VAR @@ -79,36 +81,31 @@ vara ; number - : DIGIT + - ; + : DIGIT+ + ; relop - : ('<' ('>' | '=' )?) - | ('>' ('<' | '=' )?) - | '=' - ; - + : ('<' ('>' | '=')?) + | ('>' ('<' | '=')?) + | '=' + ; STRING - : '"' ~ ["\r\n]* '"' - ; - + : '"' ~ ["\r\n]* '"' + ; DIGIT - : '0' .. '9' - ; - + : '0' .. '9' + ; VAR - : 'A' .. 'Z' - ; - + : 'A' .. 'Z' + ; CR - : [\r\n]+ - ; - + : [\r\n]+ + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/tinyc/tinyc.g4 b/tinyc/tinyc.g4 index ffedc3febe..adcad1e965 100644 --- a/tinyc/tinyc.g4 +++ b/tinyc/tinyc.g4 @@ -30,11 +30,14 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tinyc; /* http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complements/tinyc.c -*//* +*/ /* * ::= * ::= "if" | * "if" "else" | @@ -52,63 +55,61 @@ grammar tinyc; * ::= */ program - : statement + EOF - ; + : statement+ EOF + ; statement - : 'if' paren_expr statement - | 'if' paren_expr statement 'else' statement - | 'while' paren_expr statement - | 'do' statement 'while' paren_expr ';' - | '{' statement* '}' - | expr ';' - | ';' - ; + : 'if' paren_expr statement + | 'if' paren_expr statement 'else' statement + | 'while' paren_expr statement + | 'do' statement 'while' paren_expr ';' + | '{' statement* '}' + | expr ';' + | ';' + ; paren_expr - : '(' expr ')' - ; + : '(' expr ')' + ; expr - : test - | id_ '=' expr - ; + : test + | id_ '=' expr + ; test - : sum_ - | sum_ '<' sum_ - ; + : sum_ + | sum_ '<' sum_ + ; sum_ - : term - | sum_ '+' term - | sum_ '-' term - ; + : term + | sum_ '+' term + | sum_ '-' term + ; term - : id_ - | integer - | paren_expr - ; + : id_ + | integer + | paren_expr + ; id_ - : STRING - ; + : STRING + ; integer - : INT - ; - + : INT + ; STRING - : [a-z]+ - ; - + : [a-z]+ + ; INT - : [0-9] + - ; + : [0-9]+ + ; WS - : [ \r\n\t] -> skip - ; + : [ \r\n\t] -> skip + ; \ No newline at end of file diff --git a/tinymud/tinymud.g4 b/tinymud/tinymud.g4 index 4930339f3c..edb855d51c 100644 --- a/tinymud/tinymud.g4 +++ b/tinymud/tinymud.g4 @@ -30,320 +30,319 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tinymud; prog - : line + EOL* EOF - ; + : line+ EOL* EOF + ; line - : (command | action) EOL - ; + : (command | action) EOL + ; command - : bootcommand - | chowncommand - | createcommand - | describecommand - | digcommand - | dumpcommand - | failcommand - | findcommand - | forcecommand - | linkcommand - | lockcommand - | namecommand - | newpassswordcommand - | ofailcommand - | opencommand - | osuccesscommand - | passwordcommand - | pcreatecommand - | setcommand - | shutdowncommand - | statscommand - | successcommand - | teleportcommand - | toadcommand - | unlinkcommand - | unlockcommand - | wallcommand - ; + : bootcommand + | chowncommand + | createcommand + | describecommand + | digcommand + | dumpcommand + | failcommand + | findcommand + | forcecommand + | linkcommand + | lockcommand + | namecommand + | newpassswordcommand + | ofailcommand + | opencommand + | osuccesscommand + | passwordcommand + | pcreatecommand + | setcommand + | shutdowncommand + | statscommand + | successcommand + | teleportcommand + | toadcommand + | unlinkcommand + | unlockcommand + | wallcommand + ; bootcommand - : '@boot' player - ; + : '@boot' player + ; chowncommand - : '@chown' object_ '=' player - ; + : '@chown' object_ '=' player + ; createcommand - : '@create' name ('=' cost)? - ; + : '@create' name ('=' cost)? + ; describecommand - : ('@describe' | '@desc') object_ ('=' description)? - ; + : ('@describe' | '@desc') object_ ('=' description)? + ; digcommand - : '@dig' name - ; + : '@dig' name + ; dumpcommand - : '@dump' - ; + : '@dump' + ; failcommand - : '@fail' name ('=' description)? - ; + : '@fail' name ('=' description)? + ; findcommand - : '@find' name? - ; + : '@find' name? + ; forcecommand - : '@force' player '=' command - ; + : '@force' player '=' command + ; linkcommand - : '@link' object_ '=' (number | dir_ | room) - ; + : '@link' object_ '=' (number | dir_ | room) + ; lockcommand - : '@lock' object_ '=' key - ; + : '@lock' object_ '=' key + ; namecommand - : '@name' object_ '=' name password? - ; + : '@name' object_ '=' name password? + ; newpassswordcommand - : '@newpassword' player ('=' password)? - ; + : '@newpassword' player ('=' password)? + ; ofailcommand - : '@ofail' object_ ('=' message)? - ; + : '@ofail' object_ ('=' message)? + ; opencommand - : '@open' dir_ (';' dir_)* ('=' number)? - ; + : '@open' dir_ (';' dir_)* ('=' number)? + ; osuccesscommand - : ('@osuccess' | '@osucc') object_ ('=' message)? - ; + : ('@osuccess' | '@osucc') object_ ('=' message)? + ; passwordcommand - : '@password' password '=' password - ; + : '@password' password '=' password + ; pcreatecommand - : '@pcreate' name - ; + : '@pcreate' name + ; setcommand - : '@set' object_ '=' '!'? flag - ; + : '@set' object_ '=' '!'? flag + ; shutdowncommand - : '@shutdown' - ; + : '@shutdown' + ; statscommand - : '@stats' player - ; + : '@stats' player + ; successcommand - : ('@success' | '@succ') object_ ('=' message)? - ; + : ('@success' | '@succ') object_ ('=' message)? + ; teleportcommand - : '@teleport' (object_ '=')? room - ; + : '@teleport' (object_ '=')? room + ; toadcommand - : '@toad' player - ; + : '@toad' player + ; unlinkcommand - : '@unlink' dir_ - ; + : '@unlink' dir_ + ; unlockcommand - : '@unlock' object_ - ; + : '@unlock' object_ + ; wallcommand - : '@wall' message - ; + : '@wall' message + ; action - : dropaction - | examineaction - | getaction - | giveaction - | gotoaction - | gripeaction - | helpaction - | inventoryaction - | killaction - | lookaction - | newsaction - | pageaction - | quitaction - | robaction - | sayaction - | scoreaction - | whisperaction - | whoaction - ; + : dropaction + | examineaction + | getaction + | giveaction + | gotoaction + | gripeaction + | helpaction + | inventoryaction + | killaction + | lookaction + | newsaction + | pageaction + | quitaction + | robaction + | sayaction + | scoreaction + | whisperaction + | whoaction + ; dropaction - : ('drop' | 'throw') object_ - ; + : ('drop' | 'throw') object_ + ; examineaction - : 'examine' object_ - ; + : 'examine' object_ + ; getaction - : ('get' | 'take') object_ - ; + : ('get' | 'take') object_ + ; giveaction - : 'give' player '=' pennies - ; + : 'give' player '=' pennies + ; gotoaction - : ('go' | 'goto' | 'move') direction - ; + : ('go' | 'goto' | 'move') direction + ; gripeaction - : 'gripe' message - ; + : 'gripe' message + ; helpaction - : 'help' - ; + : 'help' + ; inventoryaction - : 'inventory' - | 'inv' - ; + : 'inventory' + | 'inv' + ; killaction - : 'kill' player ('=' cost) - ; + : 'kill' player ('=' cost) + ; lookaction - : ('look' | 'read') object_ - ; + : ('look' | 'read') object_ + ; newsaction - : 'news' - ; + : 'news' + ; pageaction - : 'page' player ('=' message) - ; + : 'page' player ('=' message) + ; quitaction - : 'quit' - ; + : 'quit' + ; robaction - : 'rob' player - ; + : 'rob' player + ; sayaction - : 'say' message - ; + : 'say' message + ; scoreaction - : 'score' - ; + : 'score' + ; whisperaction - : 'whisper' player '=' message - ; + : 'whisper' player '=' message + ; whoaction - : 'who' player? - ; + : 'who' player? + ; object_ - : STRING - ; + : STRING + ; player - : STRING - ; + : STRING + ; name - : STRING - ; + : STRING + ; description - : STRING - ; + : STRING + ; cost - : NUMBER - ; + : NUMBER + ; key - : STRING - ; + : STRING + ; password - : STRING - ; + : STRING + ; message - : STRING - ; + : STRING + ; dir_ - : STRING - ; + : STRING + ; number - : NUMBER - ; + : NUMBER + ; room - : STRING - ; + : STRING + ; flag - : NUMBER - ; + : NUMBER + ; pennies - : NUMBER - ; + : NUMBER + ; direction - : STRING - ; - + : STRING + ; STRING - : [a-zA-Z] [a-zA-Z0-9_. %,']* - ; - + : [a-zA-Z] [a-zA-Z0-9_. %,']* + ; NUMBER - : [0-9] + - ; - + : [0-9]+ + ; EOL - : '\r'? '\n' - ; - + : '\r'? '\n' + ; WS - : [ \t] -> skip - ; + : [ \t] -> skip + ; \ No newline at end of file diff --git a/tinyos_nesc/TinyosLexer.g4 b/tinyos_nesc/TinyosLexer.g4 index c0bdb282fe..691259398c 100644 --- a/tinyos_nesc/TinyosLexer.g4 +++ b/tinyos_nesc/TinyosLexer.g4 @@ -16,6 +16,9 @@ Antlr4 TinyOS(nesC) by Hussein Marah, 2020. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true lexer grammar TinyosLexer; @@ -23,138 +26,114 @@ channels{ WHITESPACE } -ABSTRACT: 'abstract'; -AS: 'as'; -ASYNC: 'async'; -ATOMIC: 'atomic'; -BOOLEAN: 'boolean'; -BREAK: 'break'; -CALL: 'call'; -CASE: 'case'; -CHAR: 'char'; -COFIGURATION: 'configuration'; -COMMAND: 'command'; -COMPONENT: 'component'; -COMPONENTS: 'components'; -CONTINUE: 'continue'; -DO: 'do'; -DOUBLE: 'double'; -DEFINED: 'defined'; -DEFINE: 'define'; -DEFAULT: 'default'; -ELSE: 'else'; -ENUM: 'enum'; -EVENT: 'event'; -EXTENDS: 'extends'; -ELIF: 'elif'; -ENDIF: 'endif'; -ERROR: 'error'; -FALSE: 'false'; -FINAL: 'final'; -FOR: 'for'; -GENERIC: 'generic'; -IF: 'if'; -IMPLEMENTATION: 'implementation'; -INCLUDE: 'include'; -INCLUDES: 'includes'; -INTERFACE: 'interface'; -LOG: 'log'; -LONG: 'long'; -MODULE: 'module'; -NEW: 'new'; -POST: 'post'; -PROVIDES: 'provides'; -RETURN: 'return'; -SHORT: 'short'; -SIGNAL: 'signal'; -STATIC: 'static'; -SWITCH: 'switch'; -TASK: 'task'; -TRUE: 'true'; -USES: 'uses'; -VOID: 'void'; -WHILE: 'while'; -TYPEDEF: 'typedef'; - - - -OR : '||'; -AND : '&&'; -EQ : '=='; -NEQ : '!='; -GT : '>'; -LT : '<'; -GTEQ : '>='; -LTEQ : '<='; -PLUS : '+'; +ABSTRACT : 'abstract'; +AS : 'as'; +ASYNC : 'async'; +ATOMIC : 'atomic'; +BOOLEAN : 'boolean'; +BREAK : 'break'; +CALL : 'call'; +CASE : 'case'; +CHAR : 'char'; +COFIGURATION : 'configuration'; +COMMAND : 'command'; +COMPONENT : 'component'; +COMPONENTS : 'components'; +CONTINUE : 'continue'; +DO : 'do'; +DOUBLE : 'double'; +DEFINED : 'defined'; +DEFINE : 'define'; +DEFAULT : 'default'; +ELSE : 'else'; +ENUM : 'enum'; +EVENT : 'event'; +EXTENDS : 'extends'; +ELIF : 'elif'; +ENDIF : 'endif'; +ERROR : 'error'; +FALSE : 'false'; +FINAL : 'final'; +FOR : 'for'; +GENERIC : 'generic'; +IF : 'if'; +IMPLEMENTATION : 'implementation'; +INCLUDE : 'include'; +INCLUDES : 'includes'; +INTERFACE : 'interface'; +LOG : 'log'; +LONG : 'long'; +MODULE : 'module'; +NEW : 'new'; +POST : 'post'; +PROVIDES : 'provides'; +RETURN : 'return'; +SHORT : 'short'; +SIGNAL : 'signal'; +STATIC : 'static'; +SWITCH : 'switch'; +TASK : 'task'; +TRUE : 'true'; +USES : 'uses'; +VOID : 'void'; +WHILE : 'while'; +TYPEDEF : 'typedef'; + +OR : '||'; +AND : '&&'; +EQ : '=='; +NEQ : '!='; +GT : '>'; +LT : '<'; +GTEQ : '>='; +LTEQ : '<='; +PLUS : '+'; MINUS : '-'; -MULT : '*'; -DIV : '/'; -MOD : '%'; -POW : '^'; -NOT : '!'; - -ASSIGN: '='; -TILDE: '~'; -QUESTION: '?'; -COLON: ':'; -INC: '++'; -DEC: '--'; -BITAND: '&'; -BITOR: '|'; -HASHTAG: '#'; - - - - -SCOL: ';'; -OBRACK: '['; -CBRACK: ']'; -OPAR: '('; -CPAR: ')'; -OBRACE: '{'; -CBRACE: '}'; -FORWARDARROW: '->'; -BACKARROW: '<-'; -COLONCOLON: '::'; -AT: '@'; -COMMA: ','; -DOT: '.'; -UNDERSCORE: '_'; - -ID -: [a-zA-Z_] [a-zA-Z_0-9]* -; - -INT -: [0-9]+ -; - -FLOAT -: [0-9]+ '.' [0-9]* -| '.' [0-9]+ -; - -STRING -: '"' (~["\r\n] | '""')* '"' -; - -COMMENT -: '/*' .*? '*/' -> channel(HIDDEN) -; - -LINE_COMMENT -: '//' ~[\r\n]* -> channel(HIDDEN) -; - -SPACE -: (' ' | '\t' | '\r' | '\n')+ -> channel(WHITESPACE) -; - -OTHER -: . -; - -HEX -:'0x' ([a-fA-F0-9])+ -; \ No newline at end of file +MULT : '*'; +DIV : '/'; +MOD : '%'; +POW : '^'; +NOT : '!'; + +ASSIGN : '='; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +INC : '++'; +DEC : '--'; +BITAND : '&'; +BITOR : '|'; +HASHTAG : '#'; + +SCOL : ';'; +OBRACK : '['; +CBRACK : ']'; +OPAR : '('; +CPAR : ')'; +OBRACE : '{'; +CBRACE : '}'; +FORWARDARROW : '->'; +BACKARROW : '<-'; +COLONCOLON : '::'; +AT : '@'; +COMMA : ','; +DOT : '.'; +UNDERSCORE : '_'; + +ID: [a-zA-Z_] [a-zA-Z_0-9]*; + +INT: [0-9]+; + +FLOAT: [0-9]+ '.' [0-9]* | '.' [0-9]+; + +STRING: '"' (~["\r\n] | '""')* '"'; + +COMMENT: '/*' .*? '*/' -> channel(HIDDEN); + +LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); + +SPACE: (' ' | '\t' | '\r' | '\n')+ -> channel(WHITESPACE); + +OTHER: .; + +HEX: '0x' ([a-fA-F0-9])+; \ No newline at end of file diff --git a/tinyos_nesc/TinyosParser.g4 b/tinyos_nesc/TinyosParser.g4 index b79053a4de..87d4be6561 100644 --- a/tinyos_nesc/TinyosParser.g4 +++ b/tinyos_nesc/TinyosParser.g4 @@ -13,326 +13,436 @@ Antlr4 TinyOS(nesC) by Hussein Marah, 2020. */ +// $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 TinyosParser; options { - tokenVocab = TinyosLexer; - //superClass = MultiChannelBaseParser; + tokenVocab = TinyosLexer; + //superClass = MultiChannelBaseParser; } -compilationUnit: - includeDeclarationModule* componentDeclaration? includeDeclarationConfiguration* - componentDeclaration EOF; +compilationUnit + : includeDeclarationModule* componentDeclaration? includeDeclarationConfiguration* componentDeclaration EOF + ; -includeDeclarationModule: HASHTAG INCLUDE qualifiedName; +includeDeclarationModule + : HASHTAG INCLUDE qualifiedName + ; -includeDeclarationConfiguration: HASHTAG INCLUDE qualifiedName; +includeDeclarationConfiguration + : HASHTAG INCLUDE qualifiedName + ; -qualifiedName: singleLine; +qualifiedName + : singleLine + ; //Move the character '|' if you want to read in just single file -componentDeclaration: - moduleDeclaration - | configurationDeclaration; +componentDeclaration + : moduleDeclaration + | configurationDeclaration + ; //This part is for the module file -moduleDeclaration: moduleSignature moduleImplementation; -moduleSignature: - MODULE moduleName OPAR? CPAR? moduleSignatureBody; +moduleDeclaration + : moduleSignature moduleImplementation + ; -moduleName: singleLine; +moduleSignature + : MODULE moduleName OPAR? CPAR? moduleSignatureBody + ; -moduleSignatureBody: OBRACE usesOrProvides* CBRACE; +moduleName + : singleLine + ; -usesOrProvides: usesState | providesState; +moduleSignatureBody + : OBRACE usesOrProvides* CBRACE + ; -usesState: - USES INTERFACE usesInterfaceDescription* SCOL - | USES OBRACE (INTERFACE usesInterfaceDescription SCOL)* CBRACE; +usesOrProvides + : usesState + | providesState + ; -providesState: - PROVIDES INTERFACE providesInterfaceDescription* SCOL - | PROVIDES OBRACE ( - INTERFACE providesInterfaceDescription SCOL - )* CBRACE; +usesState + : USES INTERFACE usesInterfaceDescription* SCOL + | USES OBRACE (INTERFACE usesInterfaceDescription SCOL)* CBRACE + ; -usesInterfaceDescription: interfaceNameAs | interfaceName; +providesState + : PROVIDES INTERFACE providesInterfaceDescription* SCOL + | PROVIDES OBRACE ( INTERFACE providesInterfaceDescription SCOL)* CBRACE + ; -providesInterfaceDescription: interfaceNameAs | interfaceName; +usesInterfaceDescription + : interfaceNameAs + | interfaceName + ; -interfaceNameAs: interfaceName AS interfaceName; +providesInterfaceDescription + : interfaceNameAs + | interfaceName + ; -interfaceName: singleLine; +interfaceNameAs + : interfaceName AS interfaceName + ; -moduleImplementation: - IMPLEMENTATION OBRACE moduleImplementationBody CBRACE; +interfaceName + : singleLine + ; -moduleImplementationBody: block; +moduleImplementation + : IMPLEMENTATION OBRACE moduleImplementationBody CBRACE + ; -block: stat*; +moduleImplementationBody + : block + ; -stat: - statement - | event_stat - | task_stat - | static_stat - | if_stat - | enum_stat - | while_stat - | for_stat - | switch_stat - | other_stat - | atomic_stat - | define_stat - | call_stat - | packet_define - | OTHER {System.err.println("unknown char: " + $OTHER.text);}; +block + : stat* + ; -packet_define: - TYPEDEF common_name singleLine OBRACE statement* CBRACE statement; +stat + : statement + | event_stat + | task_stat + | static_stat + | if_stat + | enum_stat + | while_stat + | for_stat + | switch_stat + | other_stat + | atomic_stat + | define_stat + | call_stat + | packet_define + | OTHER {System.err.println("unknown char: " + $OTHER.text);} + ; -call_stat: CALL common_name call_condition_block SCOL?; +packet_define + : TYPEDEF common_name singleLine OBRACE statement* CBRACE statement + ; + +call_stat + : CALL common_name call_condition_block SCOL? + ; -call_condition_block: OPAR expr? CPAR; +call_condition_block + : OPAR expr? CPAR + ; -define_stat: - HASHTAG DEFINE common_name singleLine OBRACE statement CBRACE statement; +define_stat + : HASHTAG DEFINE common_name singleLine OBRACE statement CBRACE statement + ; -statement: anystatement SCOL? | expr SCOL; +statement + : anystatement SCOL? + | expr SCOL + ; -event_stat: - EVENT VOID? common_name event_condition_block event_stat_block? - | EVENT VOID? common_name event_condition_block event_stat_block? ( - stat - )* (EVENT VOID? common_name event_stat_block)?; +event_stat + : EVENT VOID? common_name event_condition_block event_stat_block? + | EVENT VOID? common_name event_condition_block event_stat_block? (stat)* ( + EVENT VOID? common_name event_stat_block + )? + ; -event_condition_block: OPAR expr? CPAR; +event_condition_block + : OPAR expr? CPAR + ; -event_stat_block: OBRACE block CBRACE; +event_stat_block + : OBRACE block CBRACE + ; -task_stat: - TASK VOID? common_name task_condition_block task_stat_block? - | TASK VOID? common_name task_condition_block task_stat_block? ( - stat - )* (TASK VOID? common_name task_stat_block)?; +task_stat + : TASK VOID? common_name task_condition_block task_stat_block? + | TASK VOID? common_name task_condition_block task_stat_block? (stat)* ( + TASK VOID? common_name task_stat_block + )? + ; -task_condition_block: OPAR expr? CPAR SCOL?; +task_condition_block + : OPAR expr? CPAR SCOL? + ; -task_stat_block: OBRACE block CBRACE; +task_stat_block + : OBRACE block CBRACE + ; -static_stat: - STATIC VOID? common_name static_condition_block static_stat_block? - | STATIC VOID? common_name static_condition_block static_stat_block? ( - stat - )* (STATIC VOID? common_name static_stat_block)?; +static_stat + : STATIC VOID? common_name static_condition_block static_stat_block? + | STATIC VOID? common_name static_condition_block static_stat_block? (stat)* ( + STATIC VOID? common_name static_stat_block + )? + ; -static_condition_block: OPAR expr? CPAR SCOL?; +static_condition_block + : OPAR expr? CPAR SCOL? + ; -static_stat_block: OBRACE block CBRACE; +static_stat_block + : OBRACE block CBRACE + ; -other_stat: - VOID? common_name other_condition_block other_stat_block? - | VOID? common_name other_condition_block other_stat_block? ( - stat - )* (VOID? common_name other_stat_block)?; +other_stat + : VOID? common_name other_condition_block other_stat_block? + | VOID? common_name other_condition_block other_stat_block? (stat)* ( + VOID? common_name other_stat_block + )? + ; -other_condition_block: OPAR expr? CPAR; +other_condition_block + : OPAR expr? CPAR + ; -other_stat_block: OBRACE block CBRACE; +other_stat_block + : OBRACE block CBRACE + ; -enum_stat: ENUM OBRACE ( expr COMMA?)* CBRACE SCOL; +enum_stat + : ENUM OBRACE (expr COMMA?)* CBRACE SCOL + ; -common_name: singleLine | name_or_reserved; +common_name + : singleLine + | name_or_reserved + ; -if_stat: - IF if_condition_block (ELSE IF if_condition_block)* ( - ELSE if_stat_block - )?; +if_stat + : IF if_condition_block (ELSE IF if_condition_block)* (ELSE if_stat_block)? + ; -if_condition_block: - OPAR (name_or_reserved* | expr*) CPAR if_stat_block +if_condition_block + : OPAR (name_or_reserved* | expr*) CPAR if_stat_block | OPAR CPAR if_stat_block - | OPAR expr CPAR if_stat_block - | OPAR symbol CPAR if_stat_block - ; - -if_stat_block: OBRACE block CBRACE | stat; - -while_stat: WHILE OPAR expr CPAR while_stat_block; - -while_stat_block: OBRACE block CBRACE | stat; - -for_stat: - FOR OPAR ((expr | anystatement) SCOL?)+ CPAR for_stat_block; - -for_stat_block: OBRACE block CBRACE | stat; - -switch_stat: - SWITCH switch_condition_block OBRACE (switch_stat_block)* CBRACE; - -switch_condition_block: OPAR expr CPAR | OPAR symbol CPAR; - -switch_stat_block: - CASE (expr | anystatement) COLON stat* BREAK SCOL - | DEFAULT COLON stat* BREAK SCOL; - -atomic_stat: ATOMIC atomic_stat_block; - -atomic_stat_block: - OBRACE (statement | if_stat | other_stat) CBRACE - | (statement | if_stat | other_stat); - -expr: - expr POW expr # powExpr - | MINUS expr # unaryMinusExpr - | NOT expr # notExpr - | expr op = (MULT | DIV | MOD) expr # multiplicationExpr - | expr op = (PLUS | MINUS | ASSIGN) expr # additiveExpr - | expr op = (LTEQ | GTEQ | LT | GT) expr # relationalExpr - | expr op = (EQ | NEQ) expr # equalityExpr - | expr AND expr # andExpr - | expr OR expr # orExpr - | atom (atom)* # atomExpr - | singleLine # singlelineExpr - | singleDoubleArray # singleDoubleArrayExpr; - -atom: - STRING # stringAtom - | ID # idAtom - | (INT | FLOAT) # numberAtom - | (TRUE | FALSE) # booleanAtom - | HEX # hexadecimalAtom; - -symbol: OTHER # otherchar; - -singleDoubleArray: OBRACE arrayElement* CBRACE; - -arrayElement: - atom COMMA? - | (OBRACE atom COMMA atom CBRACE) COMMA?; - -chars: ( - OPAR - | CPAR - | INC - | DEC - | FORWARDARROW - | BACKARROW - | COLONCOLON - | AT - | COMMA - | MULT - | GT - | LT - | DOT - | ASSIGN - | BITAND - | OBRACK - | CBRACK - ); - -chars_no_comma: ( - OPAR - | CPAR - | INC - | DEC - | FORWARDARROW - | BACKARROW - | COLONCOLON - | AT - | MULT - | GT - | LT - | DOT - | ASSIGN - | BITAND - | OBRACK - | CBRACK - ); - -reservedwords: ( - VOID - | RETURN - | AS - | POST - | ATOMIC - | ERROR - | ABSTRACT - | NEW - | CALL - | BREAK - ); - -singleLine: (atom | symbol | chars) ( - DOT? (atom | symbol | chars) - )* - | (atom | symbol | chars | reservedwords) ( - atom - | symbol - | chars - | reservedwords - )*; - -anystatement: (atom | symbol | chars) (atom | symbol | chars)*; - -name_or_reserved: (atom | symbol | chars | reservedwords) ( - atom - | symbol - | chars - | reservedwords - )*; - -name_with_char: (atom) (DOT? (chars | symbol | atom))*; - -configurationDeclaration: - configurationSignature configurationImplementation; - -configurationSignature: - COFIGURATION configurationName configurationSignatureBody; -configurationSignatureBody: OBRACE expr? CBRACE; - -configurationName: singleLine; + | OPAR expr CPAR if_stat_block + | OPAR symbol CPAR if_stat_block + ; + +if_stat_block + : OBRACE block CBRACE + | stat + ; + +while_stat + : WHILE OPAR expr CPAR while_stat_block + ; + +while_stat_block + : OBRACE block CBRACE + | stat + ; + +for_stat + : FOR OPAR ((expr | anystatement) SCOL?)+ CPAR for_stat_block + ; + +for_stat_block + : OBRACE block CBRACE + | stat + ; + +switch_stat + : SWITCH switch_condition_block OBRACE (switch_stat_block)* CBRACE + ; + +switch_condition_block + : OPAR expr CPAR + | OPAR symbol CPAR + ; + +switch_stat_block + : CASE (expr | anystatement) COLON stat* BREAK SCOL + | DEFAULT COLON stat* BREAK SCOL + ; + +atomic_stat + : ATOMIC atomic_stat_block + ; + +atomic_stat_block + : OBRACE (statement | if_stat | other_stat) CBRACE + | (statement | if_stat | other_stat) + ; + +expr + : expr POW expr # powExpr + | MINUS expr # unaryMinusExpr + | NOT expr # notExpr + | expr op = (MULT | DIV | MOD) expr # multiplicationExpr + | expr op = (PLUS | MINUS | ASSIGN) expr # additiveExpr + | expr op = (LTEQ | GTEQ | LT | GT) expr # relationalExpr + | expr op = (EQ | NEQ) expr # equalityExpr + | expr AND expr # andExpr + | expr OR expr # orExpr + | atom (atom)* # atomExpr + | singleLine # singlelineExpr + | singleDoubleArray # singleDoubleArrayExpr + ; + +atom + : STRING # stringAtom + | ID # idAtom + | (INT | FLOAT) # numberAtom + | (TRUE | FALSE) # booleanAtom + | HEX # hexadecimalAtom + ; + +symbol + : OTHER # otherchar + ; + +singleDoubleArray + : OBRACE arrayElement* CBRACE + ; + +arrayElement + : atom COMMA? + | (OBRACE atom COMMA atom CBRACE) COMMA? + ; + +chars + : ( + OPAR + | CPAR + | INC + | DEC + | FORWARDARROW + | BACKARROW + | COLONCOLON + | AT + | COMMA + | MULT + | GT + | LT + | DOT + | ASSIGN + | BITAND + | OBRACK + | CBRACK + ) + ; + +chars_no_comma + : ( + OPAR + | CPAR + | INC + | DEC + | FORWARDARROW + | BACKARROW + | COLONCOLON + | AT + | MULT + | GT + | LT + | DOT + | ASSIGN + | BITAND + | OBRACK + | CBRACK + ) + ; + +reservedwords + : (VOID | RETURN | AS | POST | ATOMIC | ERROR | ABSTRACT | NEW | CALL | BREAK) + ; + +singleLine + : (atom | symbol | chars) (DOT? (atom | symbol | chars))* + | (atom | symbol | chars | reservedwords) (atom | symbol | chars | reservedwords)* + ; + +anystatement + : (atom | symbol | chars) (atom | symbol | chars)* + ; + +name_or_reserved + : (atom | symbol | chars | reservedwords) (atom | symbol | chars | reservedwords)* + ; + +name_with_char + : (atom) (DOT? (chars | symbol | atom))* + ; + +configurationDeclaration + : configurationSignature configurationImplementation + ; + +configurationSignature + : COFIGURATION configurationName configurationSignatureBody + ; + +configurationSignatureBody + : OBRACE expr? CBRACE + ; + +configurationName + : singleLine + ; //This part is for the configuration file -configurationImplementation: - IMPLEMENTATION configurationImplementationBody; +configurationImplementation + : IMPLEMENTATION configurationImplementationBody + ; -configurationImplementationBody: - OBRACE configurationImplementationDescription CBRACE; +configurationImplementationBody + : OBRACE configurationImplementationDescription CBRACE + ; -configurationImplementationDescription: ( - componentsDefinition - | componentsWiring - | platformDefinition - )*; -platformDefinition: - HASHTAG IF platformDefinitionDescription* HASHTAG ENDIF; -platformDefinitionDescription: - DEFINED? singleLine componentsDefinition - | HASHTAG ELIF DEFINED? singleLine componentsDefinition - | HASHTAG ELSE HASHTAG ERROR singleLine; +configurationImplementationDescription + : (componentsDefinition | componentsWiring | platformDefinition)* + ; -componentsDefinition: - COMPONENTS componentsDefinitionDetails SCOL; +platformDefinition + : HASHTAG IF platformDefinitionDescription* HASHTAG ENDIF + ; -componentsDefinitionDetails: (componentsDefinitionName COMMA?)*; +platformDefinitionDescription + : DEFINED? singleLine componentsDefinition + | HASHTAG ELIF DEFINED? singleLine componentsDefinition + | HASHTAG ELSE HASHTAG ERROR singleLine + ; -componentsDefinitionName: componentsName; +componentsDefinition + : COMPONENTS componentsDefinitionDetails SCOL + ; -componentsWiring: wiring SCOL; +componentsDefinitionDetails + : (componentsDefinitionName COMMA?)* + ; -wiring: wiringName; +componentsDefinitionName + : componentsName + ; + +componentsWiring + : wiring SCOL + ; -wiringName: - componentsName (FORWARDARROW | BACKARROW) componentsName; +wiring + : wiringName + ; + +wiringName + : componentsName (FORWARDARROW | BACKARROW) componentsName + ; -componentsName: - atom - | name_with_char - | NEW atom - | NEW atom OPAR? atom? CPAR? - | NEW atom AS atom - | NEW? atom OPAR? atom? CPAR? AS atom; +componentsName + : atom + | name_with_char + | NEW atom + | NEW atom OPAR? atom? CPAR? + | NEW atom AS atom + | NEW? atom OPAR? atom? CPAR? AS atom + ; \ No newline at end of file diff --git a/tl/tl.g4 b/tl/tl.g4 index d5aa1b7f21..9b3ce3c85e 100644 --- a/tl/tl.g4 +++ b/tl/tl.g4 @@ -32,45 +32,49 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tl; -file_ : proposition EOF; +file_ + : proposition EOF + ; proposition - : - | TL_UPTACK - | ATOMIC - | TL_NOT proposition - | proposition TL_OR proposition - | (TL_ALWAYS | TL_WAS) proposition - | '(' proposition ')' - ; + : + | TL_UPTACK + | ATOMIC + | TL_NOT proposition + | proposition TL_OR proposition + | (TL_ALWAYS | TL_WAS) proposition + | '(' proposition ')' + ; ATOMIC - : [a-z]+ - ; + : [a-z]+ + ; TL_ALWAYS - : 'G' - ; + : 'G' + ; TL_WAS - : 'H' - ; + : 'H' + ; TL_OR - : '\u2228' - ; + : '\u2228' + ; TL_UPTACK - : '\u22a5' - ; + : '\u22a5' + ; TL_NOT - : '\u2310' - ; + : '\u2310' + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/tnsnames/tnsnamesLexer.g4 b/tnsnames/tnsnamesLexer.g4 index 90bda4d5c7..a68f91c138 100644 --- a/tnsnames/tnsnamesLexer.g4 +++ b/tnsnames/tnsnamesLexer.g4 @@ -22,7 +22,6 @@ // Add IP V6 lever rule. Currently only copes with IP V4. //-------------------------------------------------------------------- - //-------------------------------------------------------------------- // The MIT License (MIT) // @@ -53,7 +52,9 @@ // Developed by : Norman Dunbar, norman@dunbar-it.co.uk //-------------------------------------------------------------------- - +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true lexer grammar tnsnamesLexer; @@ -62,43 +63,43 @@ lexer grammar tnsnamesLexer; // around here. // --------------------------------------------------------------- -L_PAREN : '(' ; - -R_PAREN : ')' ; - -L_SQUARE : '[' ; - -R_SQUARE : ']' ; - -EQUAL : '=' ; - -DOT : '.' ; - -COMMA : ',' ; - -D_QUOTE : '"' ; - -S_QUOTE : '\'' ; - -CONNECT_DATA : C O N N E C T '_' D A T A ; - -DESCRIPTION_LIST : DESCRIPTION '_' LIST ; - -DESCRIPTION : D E S C R I P T I O N ; - -ADDRESS_LIST : ADDRESS '_' LIST ; - -ADDRESS : A D D R E S S ; - -PROTOCOL : P R O T O C O L ; - -TCP : T C P ; - -HOST : H O S T ; - -PORT : P O R T ; - -LOCAL : L O C A L ; +L_PAREN: '('; + +R_PAREN: ')'; + +L_SQUARE: '['; + +R_SQUARE: ']'; + +EQUAL: '='; + +DOT: '.'; + +COMMA: ','; + +D_QUOTE: '"'; + +S_QUOTE: '\''; + +CONNECT_DATA: C O N N E C T '_' D A T A; + +DESCRIPTION_LIST: DESCRIPTION '_' LIST; + +DESCRIPTION: D E S C R I P T I O N; + +ADDRESS_LIST: ADDRESS '_' LIST; + +ADDRESS: A D D R E S S; + +PROTOCOL: P R O T O C O L; + +TCP: T C P; + +HOST: H O S T; + +PORT: P O R T; + +LOCAL: L O C A L; // --------------------------------------------------------------- // Ok, I know this defines an IP version 4 address, but I haven't @@ -106,255 +107,212 @@ LOCAL : L O C A L ; // It seems that an IPv4 address that begins with a zero is octal. // With leading "0x" or "0X" it's hexadecimal. Sigh. // --------------------------------------------------------------- -IP : QUAD DOT QUAD DOT QUAD DOT QUAD+ ; - -YES_NO : Y E S | N O ; - -ON_OFF : O N | O F F ; - -TRUE_FALSE : T R U E | F A L S E ; - -COMMENT : '#' (.)*? '\n' -> skip ; - -INT : DIGIT+ ; - -OK : O K ; - -DEDICATED : D E D I C A T E D ; - -SHARED : S H A R E D ; - -POOLED : P O O L E D ; - -LOAD_BALANCE : L O A D '_' B A L A N C E ; - -FAILOVER : F A I L O V E R ; - -UR : U R ; - -UR_A : A ; - -ENABLE : E N A B L E ; - -BROKEN : B R O K E N ; - -SDU : S D U ; - -RECV_BUF : R E C V '_' BUF_SIZE ; - -SEND_BUF : S E N D '_' BUF_SIZE ; - -SOURCE_ROUTE : S O U R C E '_' R O U T E ; - -SERVICE : S E R V I C E ; - -SERVICE_TYPE : T Y P E '_' O F '_' SERVICE ; - -KEY : K E Y ; - -IPC : I P C ; - -SPX : S P X ; - -NMP : N M P ; - -BEQ : B E Q ; - -PIPE : P I P E ; - -PROGRAM : P R O G R A M ; - -ARGV0 : A R G V '0' ; - -ARGS : A R G S ; - -SECURITY : S E C U R I T Y ; - -SSL_CERT : S S L '_' SERVER '_' C E R T '_' D N ; - -CONN_TIMEOUT : C O N N E C T '_' T I M E O U T ; - -RETRY_COUNT : R E T R Y '_' C O U N T ; - -TCT : T R A N S P O R T '_' CONN_TIMEOUT ; +IP: QUAD DOT QUAD DOT QUAD DOT QUAD+; + +YES_NO: Y E S | N O; + +ON_OFF: O N | O F F; + +TRUE_FALSE: T R U E | F A L S E; + +COMMENT: '#' (.)*? '\n' -> skip; + +INT: DIGIT+; + +OK: O K; + +DEDICATED: D E D I C A T E D; + +SHARED: S H A R E D; + +POOLED: P O O L E D; + +LOAD_BALANCE: L O A D '_' B A L A N C E; + +FAILOVER: F A I L O V E R; + +UR: U R; + +UR_A: A; + +ENABLE: E N A B L E; + +BROKEN: B R O K E N; + +SDU: S D U; + +RECV_BUF: R E C V '_' BUF_SIZE; + +SEND_BUF: S E N D '_' BUF_SIZE; + +SOURCE_ROUTE: S O U R C E '_' R O U T E; + +SERVICE: S E R V I C E; + +SERVICE_TYPE: T Y P E '_' O F '_' SERVICE; + +KEY: K E Y; + +IPC: I P C; + +SPX: S P X; + +NMP: N M P; + +BEQ: B E Q; + +PIPE: P I P E; + +PROGRAM: P R O G R A M; + +ARGV0: A R G V '0'; + +ARGS: A R G S; + +SECURITY: S E C U R I T Y; + +SSL_CERT: S S L '_' SERVER '_' C E R T '_' D N; + +CONN_TIMEOUT: C O N N E C T '_' T I M E O U T; + +RETRY_COUNT: R E T R Y '_' C O U N T; + +TCT: T R A N S P O R T '_' CONN_TIMEOUT; //---------------------------------------------------------------------------- // Because IFILEs accept double, single or unquoted strings, we need // special processing or there is carnage. When we find an IFILE, change // to an IFILE processing mode - see the end of this file for the tokens etc. //---------------------------------------------------------------------------- -IFILE : I F I L E -> pushMode(IFILE_MODE); +IFILE: I F I L E -> pushMode(IFILE_MODE); - // --------------------------------------------------------------- // It seems I can't use D_QUOTE in the middle of the following // lexer rule. Compiling the grammar gives "rule reference D_QUOTE // is not currently supported in a set". // --------------------------------------------------------------- -DQ_STRING : D_QUOTE (~'"')* D_QUOTE ; +DQ_STRING: D_QUOTE (~'"')* D_QUOTE; - - //------------------------------------------------- // CONNECT_DATA parameters. //------------------------------------------------- -SERVICE_NAME : SERVICE '_' NAME ; - -SID : S I D ; - -INSTANCE_NAME : I N S T A N C E '_' NAME ; - -FAILOVER_MODE : FAILOVER '_' M O D E ; - -GLOBAL_NAME : G L O B A L '_' NAME ; - -HS : H S ; - -RDB_DATABASE : R D B '_' D A T A B A S E ; - -SERVER : S E R V E R ; - +SERVICE_NAME: SERVICE '_' NAME; + +SID: S I D; + +INSTANCE_NAME: I N S T A N C E '_' NAME; + +FAILOVER_MODE: FAILOVER '_' M O D E; + +GLOBAL_NAME: G L O B A L '_' NAME; + +HS: H S; + +RDB_DATABASE: R D B '_' D A T A B A S E; + +SERVER: S E R V E R; + //------------------------------------------------- // FAILOVER_MODE parameters. //------------------------------------------------- -BACKUP : B A C K U P ; - -TYPE : T Y P E ; - -SESSION : S E S S I O N ; - -SELECT : S E L E C T ; - -NONE : N O N E ; - -METHOD : M E T H O D ; - -BASIC : B A S I C ; - -PRECONNECT : P R E C O N N E C T ; - -RETRIES : R E T R I E S ; - -DELAY : D E L A Y ; +BACKUP: B A C K U P; + +TYPE: T Y P E; + +SESSION: S E S S I O N; + +SELECT: S E L E C T; +NONE: N O N E; +METHOD: M E T H O D; + +BASIC: B A S I C; + +PRECONNECT: P R E C O N N E C T; + +RETRIES: R E T R I E S; + +DELAY: D E L A Y; //------------------------------------------------- // IPv4 dotted Quads. For host IP addresses. //------------------------------------------------- -QUAD : '0'[xX] HEX_DIGIT+ - | '0' OCT_DIGIT+ - | INT - ; - +QUAD: '0' [xX] HEX_DIGIT+ | '0' OCT_DIGIT+ | INT; //------------------------------------------------- // Other lexer rules, and fragments. //------------------------------------------------- -ID : [A-Za-z0-9][A-Za-z0-9_\-.]* ; -WS : [ \t\r\n]+ -> skip ; - - +ID : [A-Za-z0-9][A-Za-z0-9_\-.]*; +WS : [ \t\r\n]+ -> skip; // ---------- // Fragments. // ---------- -fragment -A : [Aa] ; - -fragment -B : [Bb] ; - -fragment -C : [Cc] ; - -fragment -D : [Dd] ; - -fragment -E : [Ee] ; - -fragment -F : [Ff] ; - -fragment -G : [Gg] ; - -fragment -H : [Hh] ; - -fragment -I : [Ii] ; - -fragment -J : [Jj] ; - -fragment -K : [Kk] ; - -fragment -L : [Ll] ; - -fragment -M : [Mm] ; - -fragment -N : [Nn] ; - -fragment -O : [Oo] ; - -fragment -P : [Pp] ; - -fragment -Q : [Qq] ; - -fragment -R : [Rr] ; - -fragment -S : [Ss] ; - -fragment -T : [Tt] ; - -fragment -U : [Uu] ; - -fragment -V : [Vv] ; - -fragment -W : [Ww] ; - -fragment -X : [Xx] ; - -fragment -Y : [Yy] ; - -fragment -Z : [Zz] ; - -fragment -DIGIT : [0-9] ; - -fragment -OCT_DIGIT : [0-8] ; - -fragment -HEX_DIGIT : [0-9A-Fa-f] ; - -fragment -LIST : L I S T ; - -fragment -NAME : N A M E ; - -fragment -BUF_SIZE :B U F '_' S I Z E ; +fragment A: [Aa]; + +fragment B: [Bb]; + +fragment C: [Cc]; + +fragment D: [Dd]; + +fragment E: [Ee]; + +fragment F: [Ff]; + +fragment G: [Gg]; + +fragment H: [Hh]; + +fragment I: [Ii]; + +fragment J: [Jj]; + +fragment K: [Kk]; + +fragment L: [Ll]; + +fragment M: [Mm]; + +fragment N: [Nn]; + +fragment O: [Oo]; + +fragment P: [Pp]; + +fragment Q: [Qq]; + +fragment R: [Rr]; + +fragment S: [Ss]; + +fragment T: [Tt]; + +fragment U: [Uu]; + +fragment V: [Vv]; + +fragment W: [Ww]; + +fragment X: [Xx]; + +fragment Y: [Yy]; + +fragment Z: [Zz]; + +fragment DIGIT: [0-9]; + +fragment OCT_DIGIT: [0-8]; + +fragment HEX_DIGIT: [0-9A-Fa-f]; + +fragment LIST: L I S T; + +fragment NAME: N A M E; + +fragment BUF_SIZE: B U F '_' S I Z E; //---------------------------------------------------------------------------- // Everything from here on (unless we hit another 'mode' command, is related @@ -366,15 +324,14 @@ BUF_SIZE :B U F '_' S I Z E ; // We need I_WS and I_COMMENT rules here as there is/can be whitespace and // comments in the tnsnames.ora's IFILE parameters. (I think!) //---------------------------------------------------------------------------- -mode IFILE_MODE ; +mode IFILE_MODE; -I_EQUAL : '=' ; -I_STRING : (DQ_STRING | ISQ_STRING | IUQ_STRING) -> popMode ; -ISQ_STRING : S_QUOTE (~'\'')* S_QUOTE ; +I_EQUAL : '='; +I_STRING : (DQ_STRING | ISQ_STRING | IUQ_STRING) -> popMode; +ISQ_STRING : S_QUOTE (~'\'')* S_QUOTE; //IUQ_STRING : ~["'=\n\r]*? NL ; -IUQ_STRING : (~["'=])*? NL ; -I_WS : [ \t\r\n]+ -> skip ; -I_COMMENT : '#' (.)*? NL -> skip ; - -fragment NL : '\n' ; +IUQ_STRING : (~["'=])*? NL; +I_WS : [ \t\r\n]+ -> skip; +I_COMMENT : '#' (.)*? NL -> skip; +fragment NL: '\n'; \ No newline at end of file diff --git a/tnsnames/tnsnamesParser.g4 b/tnsnames/tnsnamesParser.g4 index bda5c02829..ec6d430fef 100644 --- a/tnsnames/tnsnamesParser.g4 +++ b/tnsnames/tnsnamesParser.g4 @@ -1,6 +1,11 @@ +// $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 tnsnamesParser; -options {tokenVocab=tnsnamesLexer;} +options { + tokenVocab = tnsnamesLexer; +} // ---------------------------------------------------------------- // Parser rules are lower case, or at least, an initial lower case. @@ -9,11 +14,17 @@ options {tokenVocab=tnsnamesLexer;} //----------------------------------------------------------------- // Top level rule. Start here with a complete tnsnames.ora file. //----------------------------------------------------------------- -tnsnames : (tns_entry | ifile | lsnr_entry)* EOF ; +tnsnames + : (tns_entry | ifile | lsnr_entry)* EOF + ; -tns_entry : alias_list EQUAL (description_list | description) ; +tns_entry + : alias_list EQUAL (description_list | description) + ; -ifile : IFILE I_EQUAL I_STRING ; +ifile + : IFILE I_EQUAL I_STRING + ; //----------------------------------------------------------------- // Listener only entries can be interesting. Here are a couple of @@ -25,9 +36,13 @@ ifile : IFILE I_EQUAL I_STRING ; // LSNR_WILMA = // (ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)) //----------------------------------------------------------------- -lsnr_entry : alias EQUAL (lsnr_description | address_list | (address)+) ; +lsnr_entry + : alias EQUAL (lsnr_description | address_list | (address)+) + ; -lsnr_description : L_PAREN DESCRIPTION EQUAL (address_list | (address)+) R_PAREN ; +lsnr_description + : L_PAREN DESCRIPTION EQUAL (address_list | (address)+) R_PAREN + ; //----------------------------------------------------------------- // Stuff related to alias names. These are weird, they can start @@ -35,11 +50,14 @@ lsnr_description : L_PAREN DESCRIPTION EQUAL (address_list | (address)+) R_PAREN // can also have domains attached - .world, for example. Pretty // much, anything goes! //----------------------------------------------------------------- -alias_list : alias (COMMA alias)* ; +alias_list + : alias (COMMA alias)* + ; -alias : ID - | ID (DOT ID)+ - ; +alias + : ID + | ID (DOT ID)+ + ; //----------------------------------------------------------------- // Stuff related to description lists. These seem to be optional in @@ -47,56 +65,88 @@ alias : ID // an enclosing description list. And parameters can go almost // anywhere. //----------------------------------------------------------------- -description_list : L_PAREN DESCRIPTION_LIST EQUAL (dl_params)? (description)+ (dl_params)? R_PAREN ; +description_list + : L_PAREN DESCRIPTION_LIST EQUAL (dl_params)? (description)+ (dl_params)? R_PAREN + ; -dl_params : dl_parameter+ ; +dl_params + : dl_parameter+ + ; -dl_parameter : al_failover - | al_load_balance - | al_source_route - ; +dl_parameter + : al_failover + | al_load_balance + | al_source_route + ; //----------------------------------------------------------------- // Description stuff. Lots of optional parameters scattered willy // nilly around the description. //----------------------------------------------------------------- -description : L_PAREN DESCRIPTION EQUAL (d_params)? (address_list | (address)+) (d_params)? connect_data (d_params)? R_PAREN ; - -d_params : d_parameter+ ; - -d_parameter : d_enable - | al_failover - | al_load_balance - | d_sdu - | d_recv_buf - | d_send_buf - | al_source_route - | d_service_type - | d_security - | d_conn_timeout - | d_retry_count - | d_tct - ; - -d_enable : L_PAREN ENABLE EQUAL BROKEN R_PAREN ; - -d_sdu : L_PAREN SDU EQUAL INT R_PAREN ; - -d_recv_buf : L_PAREN RECV_BUF EQUAL INT R_PAREN ; - -d_send_buf : L_PAREN SEND_BUF EQUAL INT R_PAREN ; - -d_service_type : L_PAREN SERVICE_TYPE EQUAL ID R_PAREN ; - -d_security : L_PAREN SECURITY EQUAL ds_parameter R_PAREN ; - -d_conn_timeout : L_PAREN CONN_TIMEOUT EQUAL INT R_PAREN ; - -d_retry_count : L_PAREN RETRY_COUNT EQUAL INT R_PAREN ; - -d_tct : L_PAREN TCT EQUAL INT R_PAREN ; - -ds_parameter : L_PAREN SSL_CERT EQUAL DQ_STRING R_PAREN ; +description + : L_PAREN DESCRIPTION EQUAL (d_params)? (address_list | (address)+) (d_params)? connect_data ( + d_params + )? R_PAREN + ; + +d_params + : d_parameter+ + ; + +d_parameter + : d_enable + | al_failover + | al_load_balance + | d_sdu + | d_recv_buf + | d_send_buf + | al_source_route + | d_service_type + | d_security + | d_conn_timeout + | d_retry_count + | d_tct + ; + +d_enable + : L_PAREN ENABLE EQUAL BROKEN R_PAREN + ; + +d_sdu + : L_PAREN SDU EQUAL INT R_PAREN + ; + +d_recv_buf + : L_PAREN RECV_BUF EQUAL INT R_PAREN + ; + +d_send_buf + : L_PAREN SEND_BUF EQUAL INT R_PAREN + ; + +d_service_type + : L_PAREN SERVICE_TYPE EQUAL ID R_PAREN + ; + +d_security + : L_PAREN SECURITY EQUAL ds_parameter R_PAREN + ; + +d_conn_timeout + : L_PAREN CONN_TIMEOUT EQUAL INT R_PAREN + ; + +d_retry_count + : L_PAREN RETRY_COUNT EQUAL INT R_PAREN + ; + +d_tct + : L_PAREN TCT EQUAL INT R_PAREN + ; + +ds_parameter + : L_PAREN SSL_CERT EQUAL DQ_STRING R_PAREN + ; //----------------------------------------------------------------- // Stuff related to address lists. These seem to be optional in @@ -104,123 +154,182 @@ ds_parameter : L_PAREN SSL_CERT EQUAL DQ_STRING R_PAREN ; // an enclosing address list. Specific parameters can go almost // anywhere. //----------------------------------------------------------------- -address_list : L_PAREN ADDRESS_LIST EQUAL (al_params)? (address)+ (al_params)? R_PAREN ; +address_list + : L_PAREN ADDRESS_LIST EQUAL (al_params)? (address)+ (al_params)? R_PAREN + ; -al_params : al_parameter+ ; +al_params + : al_parameter+ + ; -al_parameter : al_failover // More to come here .... - | al_load_balance - | al_source_route - ; +al_parameter + : al_failover // More to come here .... + | al_load_balance + | al_source_route + ; -al_failover : L_PAREN FAILOVER EQUAL (YES_NO | ON_OFF | TRUE_FALSE) R_PAREN ; +al_failover + : L_PAREN FAILOVER EQUAL (YES_NO | ON_OFF | TRUE_FALSE) R_PAREN + ; -al_load_balance : L_PAREN LOAD_BALANCE EQUAL (YES_NO | ON_OFF | TRUE_FALSE) R_PAREN ; +al_load_balance + : L_PAREN LOAD_BALANCE EQUAL (YES_NO | ON_OFF | TRUE_FALSE) R_PAREN + ; -al_source_route : L_PAREN SOURCE_ROUTE EQUAL (YES_NO | ON_OFF) R_PAREN ; +al_source_route + : L_PAREN SOURCE_ROUTE EQUAL (YES_NO | ON_OFF) R_PAREN + ; //----------------------------------------------------------------- // Address stuff. Not much happening here, but the send and receive // buffer parameters must go at the end, after the protocol stuff. //----------------------------------------------------------------- -address : L_PAREN ADDRESS EQUAL protocol_info (a_params)? R_PAREN ; +address + : L_PAREN ADDRESS EQUAL protocol_info (a_params)? R_PAREN + ; -a_params : a_parameter+ ; +a_params + : a_parameter+ + ; -a_parameter : d_send_buf - | d_recv_buf - ; +a_parameter + : d_send_buf + | d_recv_buf + ; //----------------------------------------------------------------- // Protocol stuff next. Currently, only TCP and IPC are defined as // these are the only ones I use at work. I can test those you see! //----------------------------------------------------------------- -protocol_info : tcp_protocol - | ipc_protocol - | spx_protocol - | nmp_protocol - | beq_protocol - ; // See http://www.toadworld.com/platforms/oracle/w/wiki/5484.defining-tnsname-addresses.aspx - // for examples etc. +protocol_info + : tcp_protocol + | ipc_protocol + | spx_protocol + | nmp_protocol + | beq_protocol + ; // See http://www.toadworld.com/platforms/oracle/w/wiki/5484.defining-tnsname-addresses.aspx + +// for examples etc. //----------------------------------------------------------------- // TCP Protocol rules. // (PROTOCOL = TCP)(HOST = hostname)(PORT = portnumber) //----------------------------------------------------------------- -tcp_protocol : tcp_params ; - -tcp_params : tcp_parameter+ ; - -tcp_parameter : tcp_host - | tcp_port - | tcp_tcp - ; - -tcp_host : L_PAREN HOST EQUAL host R_PAREN ; - -tcp_port : L_PAREN PORT EQUAL port R_PAREN ; - -tcp_tcp : L_PAREN PROTOCOL EQUAL TCP R_PAREN ; - -host : ID - | ID (DOT ID)+ - | IP - ; - -port : INT ; +tcp_protocol + : tcp_params + ; + +tcp_params + : tcp_parameter+ + ; + +tcp_parameter + : tcp_host + | tcp_port + | tcp_tcp + ; + +tcp_host + : L_PAREN HOST EQUAL host R_PAREN + ; + +tcp_port + : L_PAREN PORT EQUAL port R_PAREN + ; + +tcp_tcp + : L_PAREN PROTOCOL EQUAL TCP R_PAREN + ; + +host + : ID + | ID (DOT ID)+ + | IP + ; + +port + : INT + ; //----------------------------------------------------------------- // IPC Protocol rules. // (PROTOCOL = IPC)(KEY = something) //----------------------------------------------------------------- -ipc_protocol : ipc_params ; +ipc_protocol + : ipc_params + ; -ipc_params : ipc_parameter+ ; +ipc_params + : ipc_parameter+ + ; -ipc_parameter : ipc_ipc - | ipc_key - ; +ipc_parameter + : ipc_ipc + | ipc_key + ; -ipc_ipc : L_PAREN PROTOCOL EQUAL IPC R_PAREN ; - -ipc_key : L_PAREN KEY EQUAL ID R_PAREN ; +ipc_ipc + : L_PAREN PROTOCOL EQUAL IPC R_PAREN + ; +ipc_key + : L_PAREN KEY EQUAL ID R_PAREN + ; //----------------------------------------------------------------- // SPX Protocol rules. // (PROTOCOL = SPX)(SERVICE = spx_service_name) //----------------------------------------------------------------- -spx_protocol : spx_params ; - -spx_params : spx_parameter+ ; +spx_protocol + : spx_params + ; -spx_parameter : spx_spx - | spx_service ; +spx_params + : spx_parameter+ + ; -spx_spx : L_PAREN PROTOCOL EQUAL SPX R_PAREN ; +spx_parameter + : spx_spx + | spx_service + ; -spx_service : L_PAREN SERVICE EQUAL ID R_PAREN ; +spx_spx + : L_PAREN PROTOCOL EQUAL SPX R_PAREN + ; +spx_service + : L_PAREN SERVICE EQUAL ID R_PAREN + ; //----------------------------------------------------------------- // NMP Protocol rules (Named Pipes). // (PROTOCOL = NMP)(SERVER = server_name)(PIPE = pipe_name) //----------------------------------------------------------------- -nmp_protocol : nmp_params ; +nmp_protocol + : nmp_params + ; -nmp_params : nmp_parameter+ ; +nmp_params + : nmp_parameter+ + ; -nmp_parameter : nmp_nmp - | nmp_server - | nmp_pipe - ; +nmp_parameter + : nmp_nmp + | nmp_server + | nmp_pipe + ; -nmp_nmp : L_PAREN PROTOCOL EQUAL NMP R_PAREN ; +nmp_nmp + : L_PAREN PROTOCOL EQUAL NMP R_PAREN + ; -nmp_server : L_PAREN SERVER EQUAL ID R_PAREN ; - -nmp_pipe : L_PAREN PIPE EQUAL ID R_PAREN ; +nmp_server + : L_PAREN SERVER EQUAL ID R_PAREN + ; +nmp_pipe + : L_PAREN PIPE EQUAL ID R_PAREN + ; //----------------------------------------------------------------- // BEQ Protocol rules. @@ -228,70 +337,108 @@ nmp_pipe : L_PAREN PIPE EQUAL ID R_PAREN ; // (ARGS = '(DESCRIPTION=(LOCAL = YES)(ADDRESS = (PROTOCOL = BEQ)))' // ) //----------------------------------------------------------------- -beq_protocol : beq_params ; - -beq_params : beq_parameter+ ; - -beq_parameter : beq_beq - | beq_program - | beq_argv0 - | beq_args - ; - -beq_beq : L_PAREN PROTOCOL EQUAL BEQ R_PAREN ; - -beq_program : L_PAREN PROGRAM EQUAL ID R_PAREN ; - -beq_argv0 : L_PAREN ARGV0 EQUAL ID R_PAREN ; - -beq_args : L_PAREN ARGS EQUAL ba_parameter R_PAREN ; - -ba_parameter : S_QUOTE ba_description S_QUOTE ; - -ba_description : L_PAREN DESCRIPTION EQUAL bad_params R_PAREN ; - -bad_params : bad_parameter+ ; - -bad_parameter : bad_local - | bad_address - ; - -bad_local : L_PAREN LOCAL EQUAL YES_NO R_PAREN ; - -bad_address : L_PAREN ADDRESS EQUAL beq_beq R_PAREN ; - +beq_protocol + : beq_params + ; + +beq_params + : beq_parameter+ + ; + +beq_parameter + : beq_beq + | beq_program + | beq_argv0 + | beq_args + ; + +beq_beq + : L_PAREN PROTOCOL EQUAL BEQ R_PAREN + ; + +beq_program + : L_PAREN PROGRAM EQUAL ID R_PAREN + ; + +beq_argv0 + : L_PAREN ARGV0 EQUAL ID R_PAREN + ; + +beq_args + : L_PAREN ARGS EQUAL ba_parameter R_PAREN + ; + +ba_parameter + : S_QUOTE ba_description S_QUOTE + ; + +ba_description + : L_PAREN DESCRIPTION EQUAL bad_params R_PAREN + ; + +bad_params + : bad_parameter+ + ; + +bad_parameter + : bad_local + | bad_address + ; + +bad_local + : L_PAREN LOCAL EQUAL YES_NO R_PAREN + ; + +bad_address + : L_PAREN ADDRESS EQUAL beq_beq R_PAREN + ; //----------------------------------------------------------------- // Connect data rules. //----------------------------------------------------------------- -connect_data : L_PAREN CONNECT_DATA EQUAL cd_params R_PAREN ; - -cd_params : cd_parameter+ - ; - -cd_parameter : cd_service_name - | cd_sid - | cd_instance_name - | cd_failover_mode - | cd_global_name - | cd_hs - | cd_rdb_database - | cd_server - | cd_ur - ; - -cd_service_name : L_PAREN SERVICE_NAME EQUAL ID (DOT ID)* R_PAREN ; - -cd_sid : L_PAREN SID EQUAL ID R_PAREN ; - -cd_instance_name : L_PAREN INSTANCE_NAME EQUAL ID (DOT ID)* R_PAREN ; - - -cd_failover_mode : L_PAREN FAILOVER_MODE EQUAL fo_params R_PAREN ; - -cd_global_name : L_PAREN GLOBAL_NAME EQUAL ID (DOT ID)* R_PAREN ; - -cd_hs : L_PAREN HS EQUAL OK R_PAREN ; +connect_data + : L_PAREN CONNECT_DATA EQUAL cd_params R_PAREN + ; + +cd_params + : cd_parameter+ + ; + +cd_parameter + : cd_service_name + | cd_sid + | cd_instance_name + | cd_failover_mode + | cd_global_name + | cd_hs + | cd_rdb_database + | cd_server + | cd_ur + ; + +cd_service_name + : L_PAREN SERVICE_NAME EQUAL ID (DOT ID)* R_PAREN + ; + +cd_sid + : L_PAREN SID EQUAL ID R_PAREN + ; + +cd_instance_name + : L_PAREN INSTANCE_NAME EQUAL ID (DOT ID)* R_PAREN + ; + +cd_failover_mode + : L_PAREN FAILOVER_MODE EQUAL fo_params R_PAREN + ; + +cd_global_name + : L_PAREN GLOBAL_NAME EQUAL ID (DOT ID)* R_PAREN + ; + +cd_hs + : L_PAREN HS EQUAL OK R_PAREN + ; // --------------------------------------------------------------- // This rdb_database one is a tad strange. According to the docs @@ -299,28 +446,46 @@ cd_hs : L_PAREN HS EQUAL OK R_PAREN ; // I'm assuming that the [] bit is optional? I have no idea what // any of this means! ;-) // --------------------------------------------------------------- -cd_rdb_database : L_PAREN RDB_DATABASE EQUAL (L_SQUARE DOT ID R_SQUARE)? ID (DOT ID)* R_PAREN ; - -cd_server : L_PAREN SERVER EQUAL (DEDICATED | SHARED | POOLED) R_PAREN ; - -cd_ur : L_PAREN UR EQUAL UR_A R_PAREN ; - -fo_params : fo_parameter+ ; - -fo_parameter : fo_type - | fo_backup - | fo_method - | fo_retries - | fo_delay - ; - -fo_type : L_PAREN TYPE EQUAL (SESSION | SELECT | NONE) R_PAREN ; - -fo_backup : L_PAREN BACKUP EQUAL ID (DOT ID)* R_PAREN ; - -fo_method : L_PAREN METHOD EQUAL (BASIC | PRECONNECT) R_PAREN ; - -fo_retries : L_PAREN RETRIES EQUAL INT R_PAREN ; - -fo_delay : L_PAREN DELAY EQUAL INT R_PAREN ; - +cd_rdb_database + : L_PAREN RDB_DATABASE EQUAL (L_SQUARE DOT ID R_SQUARE)? ID (DOT ID)* R_PAREN + ; + +cd_server + : L_PAREN SERVER EQUAL (DEDICATED | SHARED | POOLED) R_PAREN + ; + +cd_ur + : L_PAREN UR EQUAL UR_A R_PAREN + ; + +fo_params + : fo_parameter+ + ; + +fo_parameter + : fo_type + | fo_backup + | fo_method + | fo_retries + | fo_delay + ; + +fo_type + : L_PAREN TYPE EQUAL (SESSION | SELECT | NONE) R_PAREN + ; + +fo_backup + : L_PAREN BACKUP EQUAL ID (DOT ID)* R_PAREN + ; + +fo_method + : L_PAREN METHOD EQUAL (BASIC | PRECONNECT) R_PAREN + ; + +fo_retries + : L_PAREN RETRIES EQUAL INT R_PAREN + ; + +fo_delay + : L_PAREN DELAY EQUAL INT R_PAREN + ; \ No newline at end of file diff --git a/tnt/tnt.g4 b/tnt/tnt.g4 index 62031b7fbf..a80f2d95b2 100644 --- a/tnt/tnt.g4 +++ b/tnt/tnt.g4 @@ -28,84 +28,87 @@ /** *

http://en.wikipedia.org/wiki/Typographical_Number_Theory

*/ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tnt; equation - : expression '=' expression EOF - ; + : expression '=' expression EOF + ; atom - : number - | variable - ; + : number + | variable + ; number - : SUCCESSOR* ZERO - ; + : SUCCESSOR* ZERO + ; variable - : SUCCESSOR* (A | B | C | D | E) PRIME* - ; + : SUCCESSOR* (A | B | C | D | E) PRIME* + ; expression - : atom - | expression '+' expression - | expression '*' expression - | '(' expression ')' - | '~' expression - | forevery expression - | exists expression - ; + : atom + | expression '+' expression + | expression '*' expression + | '(' expression ')' + | '~' expression + | forevery expression + | exists expression + ; forevery - : FOREVERY variable ':' - ; + : FOREVERY variable ':' + ; exists - : EXISTS variable ':' - ; + : EXISTS variable ':' + ; ZERO - : '0' - ; + : '0' + ; SUCCESSOR - : 'S' - ; + : 'S' + ; A - : 'a' - ; + : 'a' + ; B - : 'b' - ; + : 'b' + ; C - : 'c' - ; + : 'c' + ; D - : 'd' - ; + : 'd' + ; E - : 'e' - ; + : 'e' + ; PRIME - : '\'' - ; + : '\'' + ; FOREVERY - : 'A' - ; + : 'A' + ; EXISTS - : 'E' - ; + : 'E' + ; WS - : [ \r\t\n] -> skip - ; - + : [ \r\t\n] -> skip + ; \ No newline at end of file diff --git a/toml/TomlLexer.g4 b/toml/TomlLexer.g4 index f9d7fd75db..e4e088a753 100644 --- a/toml/TomlLexer.g4 +++ b/toml/TomlLexer.g4 @@ -17,128 +17,133 @@ with the License. You may obtain a copy of the License at under the License. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar TomlLexer; -WS : [ \t]+ -> skip ; -NL : ('\r'? '\n')+ ; -COMMENT : '#' (~[\n])* ; -L_BRACKET : '[' ; -DOUBLE_L_BRACKET : '[[' ; -R_BRACKET : ']' ; -DOUBLE_R_BRACKET : ']]' ; -EQUALS : '=' -> pushMode(SIMPLE_VALUE_MODE); -DOT : '.' ; -COMMA : ',' ; +WS : [ \t]+ -> skip; +NL : ('\r'? '\n')+; +COMMENT : '#' (~[\n])*; +L_BRACKET : '['; +DOUBLE_L_BRACKET : '[['; +R_BRACKET : ']'; +DOUBLE_R_BRACKET : ']]'; +EQUALS : '=' -> pushMode(SIMPLE_VALUE_MODE); +DOT : '.'; +COMMA : ','; -fragment DIGIT : [0-9] ; -fragment ALPHA : [A-Za-z] ; +fragment DIGIT : [0-9]; +fragment ALPHA : [A-Za-z]; // strings -fragment ESC : '\\' (["\\/bfnrt] | UNICODE | EX_UNICODE) ; -fragment UNICODE : 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ; -fragment EX_UNICODE : 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ; -BASIC_STRING : '"' (ESC | ~["\\\n])*? '"' ; -LITERAL_STRING : '\'' (~['\n])*? '\'' ; +fragment ESC : '\\' (["\\/bfnrt] | UNICODE | EX_UNICODE); +fragment UNICODE : 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT; +fragment EX_UNICODE: + 'U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT +; +BASIC_STRING : '"' (ESC | ~["\\\n])*? '"'; +LITERAL_STRING : '\'' (~['\n])*? '\''; // keys -UNQUOTED_KEY : (ALPHA | DIGIT | '-' | '_')+ ; - +UNQUOTED_KEY: (ALPHA | DIGIT | '-' | '_')+; mode SIMPLE_VALUE_MODE; -VALUE_WS: WS -> skip ; +VALUE_WS: WS -> skip; -L_BRACE : '{' -> mode(INLINE_TABLE_MODE) ; -ARRAY_START : L_BRACKET -> type(L_BRACKET), mode(ARRAY_MODE) ; +L_BRACE : '{' -> mode(INLINE_TABLE_MODE); +ARRAY_START : L_BRACKET -> type(L_BRACKET), mode(ARRAY_MODE); // booleans -BOOLEAN : ('true' | 'false') -> popMode ; +BOOLEAN: ('true' | 'false') -> popMode; // strings -fragment ML_ESC : '\\' '\r'? '\n' | ESC ; -VALUE_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING), popMode ; -ML_BASIC_STRING : '"""' (ML_ESC | ~["\\])*? '"""' -> popMode ; -VALUE_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING), popMode ; -ML_LITERAL_STRING : '\'\'\'' (.)*? '\'\'\'' -> popMode ; +fragment ML_ESC : '\\' '\r'? '\n' | ESC; +VALUE_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING), popMode; +ML_BASIC_STRING : '"""' (ML_ESC | ~["\\])*? '"""' -> popMode; +VALUE_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING), popMode; +ML_LITERAL_STRING : '\'\'\'' (.)*? '\'\'\'' -> popMode; // floating point numbers -fragment EXP : ('e' | 'E') [+-]? ZERO_PREFIXABLE_INT ; -fragment ZERO_PREFIXABLE_INT : DIGIT (DIGIT | '_' DIGIT)* ; -fragment FRAC : '.' ZERO_PREFIXABLE_INT ; -FLOAT : DEC_INT ( EXP | FRAC EXP?) -> popMode ; -INF : [+-]? 'inf' -> popMode ; -NAN : [+-]? 'nan' -> popMode ; +fragment EXP : ('e' | 'E') [+-]? ZERO_PREFIXABLE_INT; +fragment ZERO_PREFIXABLE_INT : DIGIT (DIGIT | '_' DIGIT)*; +fragment FRAC : '.' ZERO_PREFIXABLE_INT; +FLOAT : DEC_INT ( EXP | FRAC EXP?) -> popMode; +INF : [+-]? 'inf' -> popMode; +NAN : [+-]? 'nan' -> popMode; // integers -fragment HEX_DIGIT : [A-Fa-f] | DIGIT ; -fragment DIGIT_1_9 : [1-9] ; -fragment DIGIT_0_7 : [0-7] ; -fragment DIGIT_0_1 : [0-1] ; -DEC_INT : [+-]? (DIGIT | (DIGIT_1_9 (DIGIT | '_' DIGIT)+)) -> popMode ; -HEX_INT : '0x' HEX_DIGIT (HEX_DIGIT | '_' HEX_DIGIT)* -> popMode ; -OCT_INT : '0o' DIGIT_0_7 (DIGIT_0_7 | '_' DIGIT_0_7)* -> popMode ; -BIN_INT : '0b' DIGIT_0_1 (DIGIT_0_1 | '_' DIGIT_0_1)* -> popMode ; +fragment HEX_DIGIT : [A-Fa-f] | DIGIT; +fragment DIGIT_1_9 : [1-9]; +fragment DIGIT_0_7 : [0-7]; +fragment DIGIT_0_1 : [0-1]; +DEC_INT : [+-]? (DIGIT | (DIGIT_1_9 (DIGIT | '_' DIGIT)+)) -> popMode; +HEX_INT : '0x' HEX_DIGIT (HEX_DIGIT | '_' HEX_DIGIT)* -> popMode; +OCT_INT : '0o' DIGIT_0_7 (DIGIT_0_7 | '_' DIGIT_0_7)* -> popMode; +BIN_INT : '0b' DIGIT_0_1 (DIGIT_0_1 | '_' DIGIT_0_1)* -> popMode; // dates -fragment YEAR : DIGIT DIGIT DIGIT DIGIT ; -fragment MONTH : DIGIT DIGIT ; -fragment DAY : DIGIT DIGIT ; -fragment DELIM : 'T' | 't' | ' ' ; -fragment HOUR : DIGIT DIGIT ; -fragment MINUTE : DIGIT DIGIT ; -fragment SECOND : DIGIT DIGIT ; -fragment SECFRAC : '.' DIGIT+ ; -fragment NUMOFFSET : ('+' | '-') HOUR ':' MINUTE ; -fragment OFFSET : 'Z' | NUMOFFSET ; -fragment PARTIAL_TIME : HOUR ':' MINUTE ':' SECOND SECFRAC? ; -fragment FULL_DATE : YEAR '-' MONTH '-' DAY ; -fragment FULL_TIME : PARTIAL_TIME OFFSET ; -OFFSET_DATE_TIME : FULL_DATE DELIM FULL_TIME -> popMode ; -LOCAL_DATE_TIME : FULL_DATE DELIM PARTIAL_TIME -> popMode ; -LOCAL_DATE : FULL_DATE -> popMode ; -LOCAL_TIME : PARTIAL_TIME -> popMode ; +fragment YEAR : DIGIT DIGIT DIGIT DIGIT; +fragment MONTH : DIGIT DIGIT; +fragment DAY : DIGIT DIGIT; +fragment DELIM : 'T' | 't' | ' '; +fragment HOUR : DIGIT DIGIT; +fragment MINUTE : DIGIT DIGIT; +fragment SECOND : DIGIT DIGIT; +fragment SECFRAC : '.' DIGIT+; +fragment NUMOFFSET : ('+' | '-') HOUR ':' MINUTE; +fragment OFFSET : 'Z' | NUMOFFSET; +fragment PARTIAL_TIME : HOUR ':' MINUTE ':' SECOND SECFRAC?; +fragment FULL_DATE : YEAR '-' MONTH '-' DAY; +fragment FULL_TIME : PARTIAL_TIME OFFSET; +OFFSET_DATE_TIME : FULL_DATE DELIM FULL_TIME -> popMode; +LOCAL_DATE_TIME : FULL_DATE DELIM PARTIAL_TIME -> popMode; +LOCAL_DATE : FULL_DATE -> popMode; +LOCAL_TIME : PARTIAL_TIME -> popMode; mode INLINE_TABLE_MODE; -INLINE_TABLE_WS : WS -> skip ; -INLINE_TABLE_KEY_DOT : DOT -> type(DOT) ; -INLINE_TABLE_COMMA : COMMA -> type(COMMA) ; -R_BRACE : '}' -> popMode ; +INLINE_TABLE_WS : WS -> skip; +INLINE_TABLE_KEY_DOT : DOT -> type(DOT); +INLINE_TABLE_COMMA : COMMA -> type(COMMA); +R_BRACE : '}' -> popMode; -INLINE_TABLE_KEY_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING) ; -INLINE_TABLE_KEY_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING) ; -INLINE_TABLE_KEY_UNQUOTED: UNQUOTED_KEY -> type(UNQUOTED_KEY) ; +INLINE_TABLE_KEY_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING); +INLINE_TABLE_KEY_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING); +INLINE_TABLE_KEY_UNQUOTED : UNQUOTED_KEY -> type(UNQUOTED_KEY); -INLINE_TABLE_EQUALS : EQUALS -> type(EQUALS), pushMode(SIMPLE_VALUE_MODE) ; +INLINE_TABLE_EQUALS: EQUALS -> type(EQUALS), pushMode(SIMPLE_VALUE_MODE); mode ARRAY_MODE; -ARRAY_WS : WS -> skip ; -ARRAY_NL : NL -> type(NL) ; -ARRAY_COMMENT : COMMENT -> type(COMMENT) ; -ARRAY_COMMA : COMMA -> type(COMMA) ; +ARRAY_WS : WS -> skip; +ARRAY_NL : NL -> type(NL); +ARRAY_COMMENT : COMMENT -> type(COMMENT); +ARRAY_COMMA : COMMA -> type(COMMA); -ARRAY_INLINE_TABLE_START : L_BRACE -> type(L_BRACE), pushMode(INLINE_TABLE_MODE) ; -NESTED_ARRAY_START : L_BRACKET -> type(L_BRACKET), pushMode(ARRAY_MODE) ; -ARRAY_END : R_BRACKET -> type(R_BRACKET), popMode ; +ARRAY_INLINE_TABLE_START : L_BRACE -> type(L_BRACE), pushMode(INLINE_TABLE_MODE); +NESTED_ARRAY_START : L_BRACKET -> type(L_BRACKET), pushMode(ARRAY_MODE); +ARRAY_END : R_BRACKET -> type(R_BRACKET), popMode; -ARRAY_BOOLEAN : BOOLEAN -> type(BOOLEAN) ; +ARRAY_BOOLEAN: BOOLEAN -> type(BOOLEAN); -ARRAY_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING) ; -ARRAY_ML_BASIC_STRING : ML_BASIC_STRING -> type(ML_BASIC_STRING) ; -ARRAY_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING) ; -ARRAY_ML_LITERAL_STRING : ML_LITERAL_STRING -> type(ML_LITERAL_STRING) ; +ARRAY_BASIC_STRING : BASIC_STRING -> type(BASIC_STRING); +ARRAY_ML_BASIC_STRING : ML_BASIC_STRING -> type(ML_BASIC_STRING); +ARRAY_LITERAL_STRING : LITERAL_STRING -> type(LITERAL_STRING); +ARRAY_ML_LITERAL_STRING : ML_LITERAL_STRING -> type(ML_LITERAL_STRING); -ARRAY_FLOAT : FLOAT -> type(FLOAT) ; -ARRAY_INF : INF -> type(INF) ; -ARRAY_NAN : NAN -> type(NAN) ; +ARRAY_FLOAT : FLOAT -> type(FLOAT); +ARRAY_INF : INF -> type(INF); +ARRAY_NAN : NAN -> type(NAN); -ARRAY_DEC_INT : DEC_INT -> type(DEC_INT) ; -ARRAY_HEX_INT : HEX_INT -> type(HEX_INT) ; -ARRAY_OCT_INT : OCT_INT -> type(OCT_INT) ; -ARRAY_BIN_INT : BIN_INT -> type(BIN_INT) ; +ARRAY_DEC_INT : DEC_INT -> type(DEC_INT); +ARRAY_HEX_INT : HEX_INT -> type(HEX_INT); +ARRAY_OCT_INT : OCT_INT -> type(OCT_INT); +ARRAY_BIN_INT : BIN_INT -> type(BIN_INT); -ARRAY_OFFSET_DATE_TIME : OFFSET_DATE_TIME -> type(OFFSET_DATE_TIME) ; -ARRAY_LOCAL_DATE_TIME : LOCAL_DATE_TIME -> type(LOCAL_DATE_TIME) ; -ARRAY_LOCAL_DATE : LOCAL_DATE -> type(LOCAL_DATE) ; -ARRAY_LOCAL_TIME : LOCAL_TIME -> type(LOCAL_TIME) ; +ARRAY_OFFSET_DATE_TIME : OFFSET_DATE_TIME -> type(OFFSET_DATE_TIME); +ARRAY_LOCAL_DATE_TIME : LOCAL_DATE_TIME -> type(LOCAL_DATE_TIME); +ARRAY_LOCAL_DATE : LOCAL_DATE -> type(LOCAL_DATE); +ARRAY_LOCAL_TIME : LOCAL_TIME -> type(LOCAL_TIME); \ No newline at end of file diff --git a/toml/TomlParser.g4 b/toml/TomlParser.g4 index 92fdd9a290..c54b3da092 100644 --- a/toml/TomlParser.g4 +++ b/toml/TomlParser.g4 @@ -17,54 +17,135 @@ with the License. You may obtain a copy of the License at under the License. */ -parser grammar TomlParser; -options { tokenVocab = TomlLexer; } - -document : expression (NL expression)* EOF ; - -expression : key_value comment | table comment | comment ; - -comment: COMMENT? ; - -key_value : key EQUALS value ; - -key : simple_key | dotted_key ; - -simple_key : quoted_key | unquoted_key ; - -unquoted_key : UNQUOTED_KEY ; - -quoted_key : BASIC_STRING | LITERAL_STRING ; - -dotted_key : simple_key (DOT simple_key)+ ; - -value : string | integer | floating_point | bool_ | date_time | array_ | inline_table ; - -string : BASIC_STRING | ML_BASIC_STRING | LITERAL_STRING | ML_LITERAL_STRING ; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -integer : DEC_INT | HEX_INT | OCT_INT | BIN_INT ; - -floating_point : FLOAT | INF | NAN ; - -bool_ : BOOLEAN ; - -date_time : OFFSET_DATE_TIME | LOCAL_DATE_TIME | LOCAL_DATE | LOCAL_TIME ; - -array_ : L_BRACKET array_values? comment_or_nl R_BRACKET ; - -array_values : (comment_or_nl value nl_or_comment COMMA array_values comment_or_nl) | comment_or_nl value nl_or_comment COMMA? ; - -comment_or_nl : (COMMENT? NL)* ; -nl_or_comment : (NL COMMENT?)* ; - -table : standard_table | array_table ; - -standard_table : L_BRACKET key R_BRACKET ; - -inline_table : L_BRACE inline_table_keyvals R_BRACE ; - -inline_table_keyvals : inline_table_keyvals_non_empty? ; - -inline_table_keyvals_non_empty : key EQUALS value (COMMA inline_table_keyvals_non_empty)? ; +parser grammar TomlParser; -array_table : DOUBLE_L_BRACKET key DOUBLE_R_BRACKET ; +options { + tokenVocab = TomlLexer; +} + +document + : expression (NL expression)* EOF + ; + +expression + : key_value comment + | table comment + | comment + ; + +comment + : COMMENT? + ; + +key_value + : key EQUALS value + ; + +key + : simple_key + | dotted_key + ; + +simple_key + : quoted_key + | unquoted_key + ; + +unquoted_key + : UNQUOTED_KEY + ; + +quoted_key + : BASIC_STRING + | LITERAL_STRING + ; + +dotted_key + : simple_key (DOT simple_key)+ + ; + +value + : string + | integer + | floating_point + | bool_ + | date_time + | array_ + | inline_table + ; + +string + : BASIC_STRING + | ML_BASIC_STRING + | LITERAL_STRING + | ML_LITERAL_STRING + ; + +integer + : DEC_INT + | HEX_INT + | OCT_INT + | BIN_INT + ; + +floating_point + : FLOAT + | INF + | NAN + ; + +bool_ + : BOOLEAN + ; + +date_time + : OFFSET_DATE_TIME + | LOCAL_DATE_TIME + | LOCAL_DATE + | LOCAL_TIME + ; + +array_ + : L_BRACKET array_values? comment_or_nl R_BRACKET + ; + +array_values + : (comment_or_nl value nl_or_comment COMMA array_values comment_or_nl) + | comment_or_nl value nl_or_comment COMMA? + ; + +comment_or_nl + : (COMMENT? NL)* + ; + +nl_or_comment + : (NL COMMENT?)* + ; + +table + : standard_table + | array_table + ; + +standard_table + : L_BRACKET key R_BRACKET + ; + +inline_table + : L_BRACE inline_table_keyvals R_BRACE + ; + +inline_table_keyvals + : inline_table_keyvals_non_empty? + ; + +inline_table_keyvals_non_empty + : key EQUALS value (COMMA inline_table_keyvals_non_empty)? + ; + +array_table + : DOUBLE_L_BRACKET key DOUBLE_R_BRACKET + ; \ No newline at end of file diff --git a/trac/trac.g4 b/trac/trac.g4 index 1d72a9c40e..036646c97c 100644 --- a/trac/trac.g4 +++ b/trac/trac.g4 @@ -29,48 +29,51 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar trac; program - : macro* EOF? - ; + : macro* EOF? + ; macro - : active - | neutral - ; + : active + | neutral + ; active - : '#' '(' name (',' arglist)? ')' - ; + : '#' '(' name (',' arglist)? ')' + ; neutral - : '##' '(' name (',' arglist)? ')' - ; + : '##' '(' name (',' arglist)? ')' + ; arglist - : arg (',' arg)* - ; + : arg (',' arg)* + ; arg - : macro - | ('(' macro ')') - | string - ; + : macro + | ('(' macro ')') + | string + ; name - : string - ; + : string + ; string - : STRING - ; + : STRING + ; STRING - : [a-zA-Z ]+ - ; + : [a-zA-Z ]+ + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/tsv/tsv.g4 b/tsv/tsv.g4 index ba3667ed63..af2ea7c6b0 100644 --- a/tsv/tsv.g4 +++ b/tsv/tsv.g4 @@ -33,41 +33,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * grammar based on CSV grammar by Terence Parr */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar tsv; tsvFile - : hdr row* EOF - ; + : hdr row* EOF + ; hdr - : row - ; + : row + ; row - : field (TAB field)* EOL - ; + : field (TAB field)* EOL + ; field - : TEXT - | STRING - ; - + : TEXT + | STRING + ; TAB - : '\t' - ; - + : '\t' + ; EOL - : [\n\r] + - ; - + : [\n\r]+ + ; TEXT - : ~ [,\n\r"] + - ; - + : ~ [,\n\r"]+ + ; STRING - : '"' ('""' | ~ '"')* '"' - ; + : '"' ('""' | ~ '"')* '"' + ; \ No newline at end of file diff --git a/ttm/ttm.g4 b/ttm/ttm.g4 index a5b5f23a3a..c7d5a1878c 100644 --- a/ttm/ttm.g4 +++ b/ttm/ttm.g4 @@ -29,61 +29,64 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar ttm; program - : function_* EOF? - ; + : function_* EOF? + ; function_ - : active - | neutral - ; + : active + | neutral + ; active - : ACTIVE functionname (';' arglist)? '>' - ; + : ACTIVE functionname (';' arglist)? '>' + ; neutral - : NEUTRAL functionname (';' arglist)? '>' - ; + : NEUTRAL functionname (';' arglist)? '>' + ; arglist - : arg (';' arg)* - ; + : arg (';' arg)* + ; arg - : function_ - | ('<' function_ '>') - | string - ; + : function_ + | ('<' function_ '>') + | string + ; functionname - : string - ; + : string + ; string - : STRING - | ESCSTRING - ; + : STRING + | ESCSTRING + ; ACTIVE - : '#<' - ; + : '#<' + ; NEUTRAL - : '##<' - ; + : '##<' + ; ESCSTRING - : '<' [a-zA-Z]+ '>' - ; + : '<' [a-zA-Z]+ '>' + ; STRING - : [a-zA-Z0-9@!#+\-*&$%'?=".|_ ]+ - ; + : [a-zA-Z0-9@!#+\-*&$%'?=".|_ ]+ + ; WS - : [ \r\n\t]+ -> skip - ; - + : [ \r\n\t]+ -> skip + ; \ No newline at end of file diff --git a/turing/turing.g4 b/turing/turing.g4 index 57f51a31df..4582e16498 100644 --- a/turing/turing.g4 +++ b/turing/turing.g4 @@ -29,301 +29,312 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar turing; program - : declarationOrStatementInMainProgram+ EOF - ; + : declarationOrStatementInMainProgram+ EOF + ; declarationOrStatementInMainProgram - : declaration - | statement - | subprogramDeclaration - ; + : declaration + | statement + | subprogramDeclaration + ; declaration - : constantDeclaration - | variableDeclaration - | typeDeclaration - ; + : constantDeclaration + | variableDeclaration + | typeDeclaration + ; constantDeclaration - : ('const' id_ ':=' expn) - | ('const' id_ (':' typeSpec)? ':=' initializingValue) - ; + : ('const' id_ ':=' expn) + | ('const' id_ (':' typeSpec)? ':=' initializingValue) + ; initializingValue - : expn '(' 'init' (initializingValue (',' initializingValue)* ')') - ; + : expn '(' 'init' (initializingValue (',' initializingValue)* ')') + ; variableDeclaration - : ('var' id_ (',' id_)* ':=' expn) - | ('var' id_ (',' id_)* ':' typeSpec (':=' initializingValue)?) - ; + : ('var' id_ (',' id_)* ':=' expn) + | ('var' id_ (',' id_)* ':' typeSpec (':=' initializingValue)?) + ; typeDeclaration - : 'type' id_ ':' typeSpec - ; + : 'type' id_ ':' typeSpec + ; typeSpec - : standardType - | subrangeType - | arrayType - | recordType - | namedType - ; + : standardType + | subrangeType + | arrayType + | recordType + | namedType + ; standardType - : 'int' - | 'real' - | 'boolean' - | 'string' ('(' compileTimeExpn ')')? - ; + : 'int' + | 'real' + | 'boolean' + | 'string' ('(' compileTimeExpn ')')? + ; subrangeType - : compileTimeExpn '..' expn - ; + : compileTimeExpn '..' expn + ; arrayType - : 'array' indexType (',' indexType)* 'of' typeSpec - ; + : 'array' indexType (',' indexType)* 'of' typeSpec + ; indexType - : subrangeType - | namedType - ; + : subrangeType + | namedType + ; recordType - : 'record' id_ (',' id_)* ':' typeSpec (id_ (',' id_)* ':' typeSpec)* 'end' 'record' - ; + : 'record' id_ (',' id_)* ':' typeSpec (id_ (',' id_)* ':' typeSpec)* 'end' 'record' + ; namedType - : id_ - ; + : id_ + ; subprogramDeclaration - : subprogramHeader subprogramBody - ; + : subprogramHeader subprogramBody + ; subprogramHeader - : 'procedure' id_ ('(' parameterDeclaration (',' parameterDeclaration)* ')')? 'function' id_ ('(' parameterDeclaration (',' parameterDeclaration)* ')')? ':' typeSpec - ; + : 'procedure' id_ ('(' parameterDeclaration (',' parameterDeclaration)* ')')? 'function' id_ ( + '(' parameterDeclaration (',' parameterDeclaration)* ')' + )? ':' typeSpec + ; parameterDeclaration - : 'var'? id_ (',' id_)* ':' parameterType - ; + : 'var'? id_ (',' id_)* ':' parameterType + ; parameterType - : ':' typeSpec - | 'string' '(' '*' ')' - | 'array' compileTimeExpn '..' '*' (',' compileTimeExpn '..' '*')* 'of' typeSpec - | 'array' compileTimeExpn '..' '*' (',' compileTimeExpn '..' '*')* 'of' string '(' '*' ')' - ; + : ':' typeSpec + | 'string' '(' '*' ')' + | 'array' compileTimeExpn '..' '*' (',' compileTimeExpn '..' '*')* 'of' typeSpec + | 'array' compileTimeExpn '..' '*' (',' compileTimeExpn '..' '*')* 'of' string '(' '*' ')' + ; subprogramBody - : declarationsAndStatements 'end' id_ - ; + : declarationsAndStatements 'end' id_ + ; declarationsAndStatements - : declarationOrStatement* - ; + : declarationOrStatement* + ; declarationOrStatement - : declaration - | statement - ; + : declaration + | statement + ; statement - : (variableReference ':=' expn) - | procedureCall - | ('assert' booleanExpn) - | 'result' expn - | ifStatement - | loopStatement - | 'exit' ('when' booleanExpn)? - | caseStatement - | forStatement - | putStatement - | getStatement - | openStatement - | closeStatement - ; + : (variableReference ':=' expn) + | procedureCall + | ('assert' booleanExpn) + | 'result' expn + | ifStatement + | loopStatement + | 'exit' ('when' booleanExpn)? + | caseStatement + | forStatement + | putStatement + | getStatement + | openStatement + | closeStatement + ; procedureCall - : reference - ; + : reference + ; ifStatement - : 'if' booleanExpn 'then' declarationsAndStatements ('elsif' booleanExpn 'then' declarationsAndStatements)* ('else' declarationsAndStatements)? 'end' 'if' - ; + : 'if' booleanExpn 'then' declarationsAndStatements ( + 'elsif' booleanExpn 'then' declarationsAndStatements + )* ('else' declarationsAndStatements)? 'end' 'if' + ; loopStatement - : 'loop' declarationsAndStatements 'end' 'loop' - ; + : 'loop' declarationsAndStatements 'end' 'loop' + ; caseStatement - : 'case' expn 'of' 'label' compileTimeExpn (',' compileTimeExpn)* ':' declarationsAndStatements ('label' compileTimeExpn (',' compileTimeExpn)* ':' declarationsAndStatements)* ('label' ':' declarationsAndStatements)? 'end' 'case' - ; + : 'case' expn 'of' 'label' compileTimeExpn (',' compileTimeExpn)* ':' declarationsAndStatements ( + 'label' compileTimeExpn (',' compileTimeExpn)* ':' declarationsAndStatements + )* ('label' ':' declarationsAndStatements)? 'end' 'case' + ; forStatement - : ('for' id_ ':' expn '..' expn ('by' expn)? declarationsAndStatements 'end' 'for') - | ('for' 'decreasing' id_ ':' expn '..' expn ('by' expn)? declarationsAndStatements 'end' 'for') - ; + : ('for' id_ ':' expn '..' expn ('by' expn)? declarationsAndStatements 'end' 'for') + | ( + 'for' 'decreasing' id_ ':' expn '..' expn ('by' expn)? declarationsAndStatements 'end' 'for' + ) + ; putStatement - : 'put' (':' streamNumber ',')? putItem (',' putItem)* ('..')? - ; + : 'put' (':' streamNumber ',')? putItem (',' putItem)* ('..')? + ; putItem - : expn (':' widthExpn (':' fractionWidth (':' exponentWidth)?)?)? - | 'skip' - ; + : expn (':' widthExpn (':' fractionWidth (':' exponentWidth)?)?)? + | 'skip' + ; getStatement - : 'get' (':' streamNumber ',')? getItem (',' getItem)* - ; + : 'get' (':' streamNumber ',')? getItem (',' getItem)* + ; getItem - : variableReference - | 'skip' variableReference ':' '*' - | variableReference ':' widthExpn - ; + : variableReference + | 'skip' variableReference ':' '*' + | variableReference ':' widthExpn + ; openStatement - : 'open' ':' fileNumber ',' string ',' capability (',' capability)* - ; + : 'open' ':' fileNumber ',' string ',' capability (',' capability)* + ; capability - : 'get' - | 'put' - ; + : 'get' + | 'put' + ; closeStatement - : 'close' ':' fileNumber - ; + : 'close' ':' fileNumber + ; streamNumber - : expn - ; + : expn + ; widthExpn - : expn - ; + : expn + ; fractionWidth - : expn - ; + : expn + ; exponentWidth - : expn - ; + : expn + ; fileNumber - : expn - ; + : expn + ; variableReference - : reference - ; + : reference + ; reference - : id_ reference_2 - ; + : id_ reference_2 + ; reference_2 - : (componentSelector reference_2)? - ; + : (componentSelector reference_2)? + ; componentSelector - : '(' expn (',' expn)* ')' - | '.' id_ - ; + : '(' expn (',' expn)* ')' + | '.' id_ + ; booleanExpn - : expn - ; + : expn + ; compileTimeExpn - : expn - ; + : expn + ; expn - : reference - | explicitConstant - | substring - | expn infixOperator expn - | prefixOperator expn - | '(' expn ')' - ; + : reference + | explicitConstant + | substring + | expn infixOperator expn + | prefixOperator expn + | '(' expn ')' + ; string - : ExplicitStringConstant - ; + : ExplicitStringConstant + ; explicitConstant - : ExplicitUnsignedIntegerConstant - | ExplicitUnsignedRealConstant - | ExplicitStringConstant - | 'true' - | 'false' - ; + : ExplicitUnsignedIntegerConstant + | ExplicitUnsignedRealConstant + | ExplicitStringConstant + | 'true' + | 'false' + ; infixOperator - : '+' - | '–' - | '*' - | '/' 'div' - | 'mod' - | '**' - | '<' - | '>' - | '=' - | '<=' - | '>=' - | 'not=' - | 'and' - | 'or' - ; + : '+' + | '–' + | '*' + | '/' 'div' + | 'mod' + | '**' + | '<' + | '>' + | '=' + | '<=' + | '>=' + | 'not=' + | 'and' + | 'or' + ; prefixOperator - : '+' - | '–' - | 'not' - ; + : '+' + | '–' + | 'not' + ; substring - : reference '(' substringPosition ('..' substringPosition)? ')' - ; + : reference '(' substringPosition ('..' substringPosition)? ')' + ; substringPosition - : expn ('*' ('–' expn)) - ; + : expn ('*' ('–' expn)) + ; id_ - : IDENTIFIER - ; + : IDENTIFIER + ; ExplicitUnsignedIntegerConstant - : ('+' | '-')? [0-9]+ - ; + : ('+' | '-')? [0-9]+ + ; ExplicitUnsignedRealConstant - : ('+' | '-')? ([0-9]+ '.')? [0-9]+ ('e' [0-9]+) - ; + : ('+' | '-')? ([0-9]+ '.')? [0-9]+ ('e' [0-9]+) + ; ExplicitStringConstant - : '"' ~ '"'* '"' - ; + : '"' ~ '"'* '"' + ; IDENTIFIER - : [a-zA-Z] [a-zA-Z_0-9]* - ; + : [a-zA-Z] [a-zA-Z_0-9]* + ; COMMENT - : '%' ~ [\r\n]* -> channel (HIDDEN) - ; + : '%' ~ [\r\n]* -> channel (HIDDEN) + ; WS - : [ \r\n\t]+ -> channel (HIDDEN) - ; - + : [ \r\n\t]+ -> channel (HIDDEN) + ; \ No newline at end of file diff --git a/turtle-doc/turtle.g4 b/turtle-doc/turtle.g4 index e02649aae0..588b5f5d29 100644 --- a/turtle-doc/turtle.g4 +++ b/turtle-doc/turtle.g4 @@ -4,449 +4,414 @@ * and open the template in the editor. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar turtle; turtleDoc - : statement* EOF - ; + : statement* EOF + ; statement - : directive - | triples Dot - ; + : directive + | triples Dot + ; directive - : prefixID - | base - | sparqlPrefix - | sparqlBase - ; + : prefixID + | base + | sparqlPrefix + | sparqlBase + ; prefixID - : AtPrefixKeyword PNameNs IriRef Dot - ; + : AtPrefixKeyword PNameNs IriRef Dot + ; base - : AtBaseKeyword IriRef Dot - ; + : AtBaseKeyword IriRef Dot + ; sparqlBase - : BaseKeyword IriRef - ; + : BaseKeyword IriRef + ; sparqlPrefix - : PrefixKeyword PNameNs IriRef - ; + : PrefixKeyword PNameNs IriRef + ; triples - : subject predicateObjectList - | blankNodePropertyList predicateObjectList? - ; + : subject predicateObjectList + | blankNodePropertyList predicateObjectList? + ; predicateObjectList - : predicateObject (Semi predicateObject?)* - ; + : predicateObject (Semi predicateObject?)* + ; objectList - : object_ (Coma object_)* - ; + : object_ (Coma object_)* + ; predicateObject - : (predicate | LetterA) objectList - ; + : (predicate | LetterA) objectList + ; subject - : iri - | blankNode - | collection - ; + : iri + | blankNode + | collection + ; predicate - : iri - ; + : iri + ; object_ - : iri - | blankNode - | collection - | blankNodePropertyList - | literal - ; + : iri + | blankNode + | collection + | blankNodePropertyList + | literal + ; literal - : rDFLiteral - | numericLiteral - | bool_ - ; + : rDFLiteral + | numericLiteral + | bool_ + ; blankNodePropertyList - : LEnd predicateObjectList REnd - ; + : LEnd predicateObjectList REnd + ; collection - : LParen object_* RParen - ; + : LParen object_* RParen + ; numericLiteral - : Integer - | Decimal - | Double - ; + : Integer + | Decimal + | Double + ; rDFLiteral - : string (LangTag | ('^^' iri))? - ; + : string (LangTag | ('^^' iri))? + ; bool_ - : TrueKeyword - | FalseKeyword - ; + : TrueKeyword + | FalseKeyword + ; string - : StringLiteralQuote - | StringLiteralSingleQuote - | StringLiteralLongSingleQuote - | StringLiteralLongQuote - ; + : StringLiteralQuote + | StringLiteralSingleQuote + | StringLiteralLongSingleQuote + | StringLiteralLongQuote + ; iri - : IriRef - | PNameLn - | PNameNs - ; + : IriRef + | PNameLn + | PNameNs + ; blankNode - : BlankNodeLabel - | ANON - ; - + : BlankNodeLabel + | ANON + ; PNameLn - : PNameNs PNLocal - ; - + : PNameNs PNLocal + ; LetterA - : 'a' - ; - + : 'a' + ; Dot - : '.' - ; - + : '.' + ; Coma - : ',' - ; - + : ',' + ; LParen - : '(' - ; - + : '(' + ; RParen - : ')' - ; - + : ')' + ; LEnd - : '[' - ; - + : '[' + ; REnd - : ']' - ; - + : ']' + ; IriRef - : '<' ((~ [\u0000-\u0020<>"{}|^`\\]) | Uchar)* '>' - ; + : '<' ((~ [\u0000-\u0020<>"{}|^`\\]) | Uchar)* '>' + ; /* [\u0000]=NULL #01-[\u001F]=control codes [\u0020]=space */ PNameNs - : PN_Prefix? ':' - ; - + : PN_Prefix? ':' + ; BlankNodeLabel - : '_:' (PNCharsU | [0-9]) ((PN_CHARS | Dot)* PN_CHARS)? - ; - + : '_:' (PNCharsU | [0-9]) ((PN_CHARS | Dot)* PN_CHARS)? + ; Integer - : [+-]? [0-9] + - ; - + : [+-]? [0-9]+ + ; Decimal - : [+-]? [0-9]* Dot [0-9] + - ; - + : [+-]? [0-9]* Dot [0-9]+ + ; Double - : [+-]? ([0-9] + Dot [0-9]* Exponent | Dot [0-9] + Exponent | [0-9] + Exponent) - ; - + : [+-]? ([0-9]+ Dot [0-9]* Exponent | Dot [0-9]+ Exponent | [0-9]+ Exponent) + ; Exponent - : [eE] [+-]? [0-9] + - ; - + : [eE] [+-]? [0-9]+ + ; StringLiteralQuote - : '"' ((~ [\u0022\u005C\u000A\u000D]) | ECHAR | Uchar)* '"' - ; - + : '"' ((~ [\u0022\u005C\u000A\u000D]) | ECHAR | Uchar)* '"' + ; StringLiteralSingleQuote - : '\'' ((~ [\u0027\u005C\u000A\u000D]) | ECHAR | Uchar)* '\'' - ; - + : '\'' ((~ [\u0027\u005C\u000A\u000D]) | ECHAR | Uchar)* '\'' + ; StringLiteralLongSingleQuote - : '\'\'\'' (('\'' | '\'\'')? ((~ ['\\]) | ECHAR | Uchar))* '\'\'\'' - ; - + : '\'\'\'' (('\'' | '\'\'')? ((~ ['\\]) | ECHAR | Uchar))* '\'\'\'' + ; StringLiteralLongQuote - : '"""' (('\'' | '\'\'')? ((~ ['\\]) | ECHAR | Uchar))* '"""' - ; - + : '"""' (('\'' | '\'\'')? ((~ ['\\]) | ECHAR | Uchar))* '"""' + ; Uchar - : '\\u' HEX HEX? HEX? HEX? | '\\U' HEX HEX? HEX? HEX? HEX? HEX? HEX? HEX? - ; - + : '\\u' HEX HEX? HEX? HEX? + | '\\U' HEX HEX? HEX? HEX? HEX? HEX? HEX? HEX? + ; ECHAR - : '\\' [tbnrf"'\\] - ; - + : '\\' [tbnrf"'\\] + ; WS - : [\u0020\u0009\u000D\u000A] -> skip - ; - + : [\u0020\u0009\u000D\u000A] -> skip + ; ANON - : LEnd WS* REnd - ; - + : LEnd WS* REnd + ; PN_CHARS_BASE - : [A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u1000-\uEFFFF] - ; - + : + [A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u1000-\uEFFFF] + ; PNCharsU - : PN_CHARS_BASE | '_' - ; - + : PN_CHARS_BASE + | '_' + ; PN_CHARS - : PNCharsU | '-' | [0-9\u00B7\u0300-\u036F\u203F-\u2040] - ; - + : PNCharsU + | '-' + | [0-9\u00B7\u0300-\u036F\u203F-\u2040] + ; PN_Prefix - : PN_CHARS_BASE ((PN_CHARS | Dot)* PN_CHARS)? - ; - + : PN_CHARS_BASE ((PN_CHARS | Dot)* PN_CHARS)? + ; PNLocal - : (PNCharsU | ':' | [0-9] | PLX) ((PN_CHARS | Dot | ':' | PLX)* (PN_CHARS | ':' | PLX))? - ; - + : (PNCharsU | ':' | [0-9] | PLX) ((PN_CHARS | Dot | ':' | PLX)* (PN_CHARS | ':' | PLX))? + ; PLX - : PERCENT | PN_LOCAL_ESC - ; - + : PERCENT + | PN_LOCAL_ESC + ; PERCENT - : '%' HEX HEX - ; - + : '%' HEX HEX + ; HEX - : [0-9A-Fa-f] - ; - + : [0-9A-Fa-f] + ; PN_LOCAL_ESC - : '\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%') - ; - + : '\\' ( + '_' + | '~' + | '.' + | '-' + | '!' + | '$' + | '&' + | '\'' + | '(' + | ')' + | '*' + | '+' + | ',' + | ';' + | '=' + | '/' + | '?' + | '#' + | '@' + | '%' + ) + ; Semi - : ';' - ; - + : ';' + ; TrueKeyword - : T R U E - ; - + : T R U E + ; FalseKeyword - : F A L S E - ; - + : F A L S E + ; PrefixKeyword - : P R E F I X - ; - + : P R E F I X + ; BaseKeyword - : B A S E - ; - + : B A S E + ; AtPrefixKeyword - : [@] PrefixKeyword - ; - + : [@] PrefixKeyword + ; AtBaseKeyword - : [@] BaseKeyword - ; - + : [@] BaseKeyword + ; LangTag - : '@' [a-zA-Z] + ('-' [a-zA-Z0-9] +)* - ; - + : '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* + ; fragment A - : [aA] - ; - + : [aA] + ; fragment B - : [bB] - ; - + : [bB] + ; fragment C - : [cC] - ; - + : [cC] + ; fragment D - : [dD] - ; - + : [dD] + ; fragment E - : [eE] - ; - + : [eE] + ; fragment F - : [fF] - ; - + : [fF] + ; fragment G - : [gG] - ; - + : [gG] + ; fragment H - : [hH] - ; - + : [hH] + ; fragment I - : [iI] - ; - + : [iI] + ; fragment J - : [jJ] - ; - + : [jJ] + ; fragment K - : [kK] - ; - + : [kK] + ; fragment L - : [lL] - ; - + : [lL] + ; fragment M - : [mM] - ; - + : [mM] + ; fragment N - : [nN] - ; - + : [nN] + ; fragment O - : [oO] - ; - + : [oO] + ; fragment P - : [pP] - ; - + : [pP] + ; fragment Q - : [qQ] - ; - + : [qQ] + ; fragment R - : [rR] - ; - + : [rR] + ; fragment S - : [sS] - ; - + : [sS] + ; fragment T - : [tT] - ; - + : [tT] + ; fragment U - : [uU] - ; - + : [uU] + ; fragment V - : [vV] - ; - + : [vV] + ; fragment W - : [wW] - ; - + : [wW] + ; fragment X - : [xX] - ; - + : [xX] + ; fragment Y - : [yY] - ; - + : [yY] + ; fragment Z - : [zZ] - ; + : [zZ] + ; \ No newline at end of file diff --git a/turtle/TURTLE.g4 b/turtle/TURTLE.g4 index aef02a9750..893996c6d4 100644 --- a/turtle/TURTLE.g4 +++ b/turtle/TURTLE.g4 @@ -19,263 +19,288 @@ */ /* Derived from http://www.w3.org/TR/turtle/#sec-grammar-grammar */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar TURTLE; turtleDoc - : statement* EOF - ; + : statement* EOF + ; statement - : directive - | triples '.' - ; + : directive + | triples '.' + ; directive - : prefixID - | base - | sparqlPrefix - | sparqlBase - ; + : prefixID + | base + | sparqlPrefix + | sparqlBase + ; prefixID - : '@prefix' PNAME_NS IRIREF '.' - ; + : '@prefix' PNAME_NS IRIREF '.' + ; base - : '@base' IRIREF '.' - ; + : '@base' IRIREF '.' + ; sparqlBase - : 'BASE' IRIREF - ; + : 'BASE' IRIREF + ; sparqlPrefix - : 'PREFIX' PNAME_NS IRIREF - ; + : 'PREFIX' PNAME_NS IRIREF + ; triples - : subject predicateObjectList - | blankNodePropertyList predicateObjectList? - ; + : subject predicateObjectList + | blankNodePropertyList predicateObjectList? + ; predicateObjectList - : verb objectList (';' (verb objectList)?)* - ; + : verb objectList (';' (verb objectList)?)* + ; objectList - : object_ (',' object_)* - ; + : object_ (',' object_)* + ; verb - : predicate - | 'a' - ; + : predicate + | 'a' + ; subject - : iri - | BlankNode - | collection - ; + : iri + | BlankNode + | collection + ; predicate - : iri - ; + : iri + ; object_ - : iri - | BlankNode - | collection - | blankNodePropertyList - | literal - ; + : iri + | BlankNode + | collection + | blankNodePropertyList + | literal + ; literal - : rdfLiteral - | NumericLiteral - | BooleanLiteral - ; + : rdfLiteral + | NumericLiteral + | BooleanLiteral + ; blankNodePropertyList - : '[' predicateObjectList ']' - ; + : '[' predicateObjectList ']' + ; collection - : '(' object_* ')' - ; - + : '(' object_* ')' + ; NumericLiteral - : INTEGER | DECIMAL | DOUBLE - ; + : INTEGER + | DECIMAL + | DOUBLE + ; rdfLiteral - : String (LANGTAG | '^^' iri)? - ; - + : String (LANGTAG | '^^' iri)? + ; BooleanLiteral - : 'true' | 'false' - ; - + : 'true' + | 'false' + ; String - : STRING_LITERAL_QUOTE | STRING_LITERAL_SINGLE_QUOTE | STRING_LITERAL_LONG_SINGLE_QUOTE | STRING_LITERAL_LONG_QUOTE - ; + : STRING_LITERAL_QUOTE + | STRING_LITERAL_SINGLE_QUOTE + | STRING_LITERAL_LONG_SINGLE_QUOTE + | STRING_LITERAL_LONG_QUOTE + ; iri - : IRIREF - | PrefixedName - ; - + : IRIREF + | PrefixedName + ; BlankNode - : BLANK_NODE_LABEL | ANON - ; - + : BLANK_NODE_LABEL + | ANON + ; WS - : ([\t\r\n\u000C] | ' ') + -> skip - ; + : ([\t\r\n\u000C] | ' ')+ -> skip + ; // LEXER PN_PREFIX - : PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? - ; + : PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? + ; //IRIREF : '<' (~(['\u0000'..'\u0020']|'<'|'>'|'"'|'{'|'}'|'|'|'^'|'`'|'\\') | UCHAR)* '>'; /* \u00=NULL #01-\u1F=control codes \u20=space */ IRIREF - : '<' (PN_CHARS | '.' | ':' | '/' | '\\' | '#' | '@' | '%' | '&' | UCHAR)* '>' - ; - + : '<' (PN_CHARS | '.' | ':' | '/' | '\\' | '#' | '@' | '%' | '&' | UCHAR)* '>' + ; PNAME_NS - : PN_PREFIX? ':' - ; - + : PN_PREFIX? ':' + ; PrefixedName - : PNAME_LN | PNAME_NS - ; - + : PNAME_LN + | PNAME_NS + ; PNAME_LN - : PNAME_NS PN_LOCAL - ; - + : PNAME_NS PN_LOCAL + ; BLANK_NODE_LABEL - : '_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? - ; - + : '_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? + ; LANGTAG - : '@' [a-zA-Z] + ('-' [a-zA-Z0-9] +)* - ; - + : '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* + ; INTEGER - : [+-]? [0-9] + - ; - + : [+-]? [0-9]+ + ; DECIMAL - : [+-]? [0-9]* '.' [0-9] + - ; - + : [+-]? [0-9]* '.' [0-9]+ + ; DOUBLE - : [+-]? ([0-9] + '.' [0-9]* EXPONENT | '.' [0-9] + EXPONENT | [0-9] + EXPONENT) - ; - + : [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.' [0-9]+ EXPONENT | [0-9]+ EXPONENT) + ; EXPONENT - : [eE] [+-]? [0-9] + - ; - + : [eE] [+-]? [0-9]+ + ; STRING_LITERAL_LONG_SINGLE_QUOTE - : '\'\'\'' (('\'' | '\'\'')? ([^'\\] | ECHAR | UCHAR | '"'))* '\'\'\'' - ; - + : '\'\'\'' (('\'' | '\'\'')? ([^'\\] | ECHAR | UCHAR | '"'))* '\'\'\'' + ; STRING_LITERAL_LONG_QUOTE - : '"""' (('"' | '""')? (~ ["\\] | ECHAR | UCHAR | '\''))* '"""' - ; - + : '"""' (('"' | '""')? (~ ["\\] | ECHAR | UCHAR | '\''))* '"""' + ; STRING_LITERAL_QUOTE - : '"' (~ ["\\\r\n] | '\'' | '\\"')* '"' - ; - + : '"' (~ ["\\\r\n] | '\'' | '\\"')* '"' + ; STRING_LITERAL_SINGLE_QUOTE - : '\'' (~ [\u0027\u005C\u000A\u000D] | ECHAR | UCHAR | '"')* '\'' - ; - + : '\'' (~ [\u0027\u005C\u000A\u000D] | ECHAR | UCHAR | '"')* '\'' + ; UCHAR - : '\\u' HEX HEX HEX HEX | '\\U' HEX HEX HEX HEX HEX HEX HEX HEX - ; - + : '\\u' HEX HEX HEX HEX + | '\\U' HEX HEX HEX HEX HEX HEX HEX HEX + ; ECHAR - : '\\' [tbnrf"'\\] - ; - + : '\\' [tbnrf"'\\] + ; ANON_WS - : ' ' | '\t' | '\r' | '\n' - ; - + : ' ' + | '\t' + | '\r' + | '\n' + ; ANON - : '[' ANON_WS* ']' - ; - + : '[' ANON_WS* ']' + ; PN_CHARS_BASE - : 'A' .. 'Z' | 'a' .. 'z' | '\u00C0' .. '\u00D6' | '\u00D8' .. '\u00F6' | '\u00F8' .. '\u02FF' | '\u0370' .. '\u037D' | '\u037F' .. '\u1FFF' | '\u200C' .. '\u200D' | '\u2070' .. '\u218F' | '\u2C00' .. '\u2FEF' | '\u3001' .. '\uD7FF' | '\uF900' .. '\uFDCF' | '\uFDF0' .. '\uFFFD' - ; - + : 'A' .. 'Z' + | 'a' .. 'z' + | '\u00C0' .. '\u00D6' + | '\u00D8' .. '\u00F6' + | '\u00F8' .. '\u02FF' + | '\u0370' .. '\u037D' + | '\u037F' .. '\u1FFF' + | '\u200C' .. '\u200D' + | '\u2070' .. '\u218F' + | '\u2C00' .. '\u2FEF' + | '\u3001' .. '\uD7FF' + | '\uF900' .. '\uFDCF' + | '\uFDF0' .. '\uFFFD' + ; PN_CHARS_U - : PN_CHARS_BASE | '_' - ; - + : PN_CHARS_BASE + | '_' + ; PN_CHARS - : PN_CHARS_U | '-' | [0-9] | '\u00B7' | [\u0300-\u036F] | [\u203F-\u2040] - ; - + : PN_CHARS_U + | '-' + | [0-9] + | '\u00B7' + | [\u0300-\u036F] + | [\u203F-\u2040] + ; PN_LOCAL - : (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX))? - ; - + : (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX))? + ; PLX - : PERCENT | PN_LOCAL_ESC - ; - + : PERCENT + | PN_LOCAL_ESC + ; PERCENT - : '%' HEX HEX - ; - + : '%' HEX HEX + ; HEX - : [0-9] | [A-F] | [a-f] - ; - + : [0-9] + | [A-F] + | [a-f] + ; PN_LOCAL_ESC - : '\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%') - ; - + : '\\' ( + '_' + | '~' + | '.' + | '-' + | '!' + | '$' + | '&' + | '\'' + | '(' + | ')' + | '*' + | '+' + | ',' + | ';' + | '=' + | '/' + | '?' + | '#' + | '@' + | '%' + ) + ; LC - : '#' ~[\r\n]+ -> channel(HIDDEN) - ; - + : '#' ~[\r\n]+ -> channel(HIDDEN) + ; \ No newline at end of file diff --git a/unicode/graphemes/Graphemes.g4 b/unicode/graphemes/Graphemes.g4 index a04414efb1..69e5987c5f 100644 --- a/unicode/graphemes/Graphemes.g4 +++ b/unicode/graphemes/Graphemes.g4 @@ -1,64 +1,135 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Graphemes; -Extend: [\p{Grapheme_Cluster_Break=Extend}]; -ZWJ: '\u200D'; -SpacingMark: [\p{Grapheme_Cluster_Break=SpacingMark}]; -fragment VS15: '\uFE0E'; -fragment VS16: '\uFE0F'; -fragment NonspacingMark: [\p{Nonspacing_Mark}]; -fragment TextPresentationCharacter: [\p{EmojiPresentation=TextDefault}]; -fragment EmojiPresentationCharacter: [\p{EmojiPresentation=EmojiDefault}]; -fragment TextPresentationSequence: EmojiPresentationCharacter VS15; -fragment EmojiPresentationSequence: TextPresentationCharacter VS16; -fragment EmojiCharacter: [\p{Emoji}]; -fragment EmojiModifierSequence: - EmojiCharacter ('\u{1F3FB}' | '\u{1F3FC}' | '\u{1F3FD}' | '\u{1F3FE}' | '\u{1F3FF}'); -fragment EmojiFlagSequence: - [\p{Grapheme_Cluster_Break=Regional_Indicator}] [\p{Grapheme_Cluster_Break=Regional_Indicator}]; -fragment ExtendedPictographic: [\p{Extended_Pictographic}]; -fragment EnclosingMark: [\p{General_Category=Enclosing_Mark}]; -fragment EmojiCombiningSequence: - ( EmojiPresentationSequence - | TextPresentationSequence - | EmojiPresentationCharacter ) - EnclosingMark*; -EmojiCoreSequence: - EmojiModifierSequence - | EmojiCombiningSequence - | EmojiFlagSequence; -fragment EmojiZWJElement: - EmojiCharacter - | EmojiPresentationSequence - | EmojiModifierSequence; -EmojiZWJSequence: - EmojiZWJElement (ZWJ EmojiZWJElement)+; -fragment TagBase: - EmojiCharacter - | EmojiModifierSequence - | EmojiPresentationSequence; -fragment TagSpec: - [\u{E0020}-\u{E007E}]+; -fragment TagTerm: '\u{E007F}'; -fragment EmojiTagSequence: - TagBase TagSpec TagTerm; -emoji_sequence: - ( EmojiZWJSequence - | EmojiCoreSequence - | EmojiTagSequence ) - ( Extend | ZWJ | SpacingMark )*; - -Prepend: [\p{Grapheme_Cluster_Break=Prepend}]; -NonControl: [\P{Grapheme_Cluster_Break=Control}]; -CRLF: [\p{Grapheme_Cluster_Break=CR}][\p{Grapheme_Cluster_Break=LF}]; -HangulSyllable: - [\p{Grapheme_Cluster_Break=L}]* [\p{Grapheme_Cluster_Break=V}]+ [\p{Grapheme_Cluster_Break=T}]* - | [\p{Grapheme_Cluster_Break=L}]* [\p{Grapheme_Cluster_Break=LV}] [\p{Grapheme_Cluster_Break=V}]* [\p{Grapheme_Cluster_Break=T}]* - | [\p{Grapheme_Cluster_Break=L}]* [\p{Grapheme_Cluster_Break=LVT}] [\p{Grapheme_Cluster_Break=T}]* - | [\p{Grapheme_Cluster_Break=L}]+ - | [\p{Grapheme_Cluster_Break=T}]+; - -grapheme_cluster: - CRLF - | Prepend* ( emoji_sequence | HangulSyllable | NonControl ) ( Extend | ZWJ | SpacingMark )*; - -graphemes: grapheme_cluster* EOF; +Extend + : [\p{Grapheme_Cluster_Break=Extend}] + ; + +ZWJ + : '\u200D' + ; + +SpacingMark + : [\p{Grapheme_Cluster_Break=SpacingMark}] + ; + +fragment VS15 + : '\uFE0E' + ; + +fragment VS16 + : '\uFE0F' + ; + +fragment NonspacingMark + : [\p{Nonspacing_Mark}] + ; + +fragment TextPresentationCharacter + : [\p{EmojiPresentation=TextDefault}] + ; + +fragment EmojiPresentationCharacter + : [\p{EmojiPresentation=EmojiDefault}] + ; + +fragment TextPresentationSequence + : EmojiPresentationCharacter VS15 + ; + +fragment EmojiPresentationSequence + : TextPresentationCharacter VS16 + ; + +fragment EmojiCharacter + : [\p{Emoji}] + ; + +fragment EmojiModifierSequence + : EmojiCharacter ('\u{1F3FB}' | '\u{1F3FC}' | '\u{1F3FD}' | '\u{1F3FE}' | '\u{1F3FF}') + ; + +fragment EmojiFlagSequence + : [\p{Grapheme_Cluster_Break=Regional_Indicator}] [\p{Grapheme_Cluster_Break=Regional_Indicator}] + ; + +fragment ExtendedPictographic + : [\p{Extended_Pictographic}] + ; + +fragment EnclosingMark + : [\p{General_Category=Enclosing_Mark}] + ; + +fragment EmojiCombiningSequence + : (EmojiPresentationSequence | TextPresentationSequence | EmojiPresentationCharacter) EnclosingMark* + ; + +EmojiCoreSequence + : EmojiModifierSequence + | EmojiCombiningSequence + | EmojiFlagSequence + ; + +fragment EmojiZWJElement + : EmojiCharacter + | EmojiPresentationSequence + | EmojiModifierSequence + ; + +EmojiZWJSequence + : EmojiZWJElement (ZWJ EmojiZWJElement)+ + ; + +fragment TagBase + : EmojiCharacter + | EmojiModifierSequence + | EmojiPresentationSequence + ; + +fragment TagSpec + : [\u{E0020}-\u{E007E}]+ + ; + +fragment TagTerm + : '\u{E007F}' + ; + +fragment EmojiTagSequence + : TagBase TagSpec TagTerm + ; + +emoji_sequence + : (EmojiZWJSequence | EmojiCoreSequence | EmojiTagSequence) (Extend | ZWJ | SpacingMark)* + ; + +Prepend + : [\p{Grapheme_Cluster_Break=Prepend}] + ; + +NonControl + : [\P{Grapheme_Cluster_Break=Control}] + ; + +CRLF + : [\p{Grapheme_Cluster_Break=CR}][\p{Grapheme_Cluster_Break=LF}] + ; + +HangulSyllable + : [\p{Grapheme_Cluster_Break=L}]* [\p{Grapheme_Cluster_Break=V}]+ [\p{Grapheme_Cluster_Break=T}]* + | [\p{Grapheme_Cluster_Break=L}]* [\p{Grapheme_Cluster_Break=LV}] [\p{Grapheme_Cluster_Break=V}]* [\p{Grapheme_Cluster_Break=T}]* + | [\p{Grapheme_Cluster_Break=L}]* [\p{Grapheme_Cluster_Break=LVT}] [\p{Grapheme_Cluster_Break=T}]* + | [\p{Grapheme_Cluster_Break=L}]+ + | [\p{Grapheme_Cluster_Break=T}]+ + ; + +grapheme_cluster + : CRLF + | Prepend* (emoji_sequence | HangulSyllable | NonControl) (Extend | ZWJ | SpacingMark)* + ; + +graphemes + : grapheme_cluster* EOF + ; \ No newline at end of file diff --git a/unicode/unicode16/classify.g4 b/unicode/unicode16/classify.g4 index 5ce2f3ba3b..f47a773b32 100644 --- a/unicode/unicode16/classify.g4 +++ b/unicode/unicode16/classify.g4 @@ -19,3071 +19,3082 @@ acquired from */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar classify; -file_ : codepoint EOF; +file_ + : codepoint EOF + ; -codepoint: - CLASSIFY___ // Error - | CLASSIFY_Cc // Control - | CLASSIFY_Cf // Format - | CLASSIFY_Cn // Unassigned - | CLASSIFY_Co // Private_Use - | CLASSIFY_Cs // Surrogate - | CLASSIFY_Ll // Lowercase_Letter - | CLASSIFY_Lm // Modifier_Letter - | CLASSIFY_Lo // Other_Letter - | CLASSIFY_Lt // Titlecase_Letter - | CLASSIFY_Lu // Uppercase_Letter - | CLASSIFY_Mc // Spacing_Mark - | CLASSIFY_Me // Enclosing_Mark - | CLASSIFY_Mn // Nonspacing_Mark - | CLASSIFY_Nd // Decimal_Number - | CLASSIFY_Nl // Letter_Number - | CLASSIFY_No // Other_Number - | CLASSIFY_Pc // Connector_Punctuation - | CLASSIFY_Pd // Dash_Punctuation - | CLASSIFY_Pe // Close_Punctuation - | CLASSIFY_Pf // Final_Punctuation - | CLASSIFY_Pi // Initial_Punctuation - | CLASSIFY_Po // Other_Punctuation - | CLASSIFY_Ps // Open_Punctuation - | CLASSIFY_Sc // Currency_Symbol - | CLASSIFY_Sk // Modifier_Symbol - | CLASSIFY_Sm // Math_Symbol - | CLASSIFY_So // Other_Symbol - | CLASSIFY_Zl // Line_Separator - | CLASSIFY_Zp // Paragraph_Separator - | CLASSIFY_Zs // Space_Separator -; +codepoint + : CLASSIFY___ // Error + | CLASSIFY_Cc // Control + | CLASSIFY_Cf // Format + | CLASSIFY_Cn // Unassigned + | CLASSIFY_Co // Private_Use + | CLASSIFY_Cs // Surrogate + | CLASSIFY_Ll // Lowercase_Letter + | CLASSIFY_Lm // Modifier_Letter + | CLASSIFY_Lo // Other_Letter + | CLASSIFY_Lt // Titlecase_Letter + | CLASSIFY_Lu // Uppercase_Letter + | CLASSIFY_Mc // Spacing_Mark + | CLASSIFY_Me // Enclosing_Mark + | CLASSIFY_Mn // Nonspacing_Mark + | CLASSIFY_Nd // Decimal_Number + | CLASSIFY_Nl // Letter_Number + | CLASSIFY_No // Other_Number + | CLASSIFY_Pc // Connector_Punctuation + | CLASSIFY_Pd // Dash_Punctuation + | CLASSIFY_Pe // Close_Punctuation + | CLASSIFY_Pf // Final_Punctuation + | CLASSIFY_Pi // Initial_Punctuation + | CLASSIFY_Po // Other_Punctuation + | CLASSIFY_Ps // Open_Punctuation + | CLASSIFY_Sc // Currency_Symbol + | CLASSIFY_Sk // Modifier_Symbol + | CLASSIFY_Sm // Math_Symbol + | CLASSIFY_So // Other_Symbol + | CLASSIFY_Zl // Line_Separator + | CLASSIFY_Zp // Paragraph_Separator + | CLASSIFY_Zs // Space_Separator + ; -CLASSIFY___: - '\u0378'..'\u0379' // Greek_and_Coptic - | '\u0380'..'\u0383' // Greek_and_Coptic - | '\u038b' // Greek_and_Coptic - | '\u038d' // Greek_and_Coptic - | '\u03a2' // Greek_and_Coptic - | '\u0530' // Armenian - | '\u0557'..'\u0558' // Armenian - | '\u0560' // Armenian - | '\u0588' // Armenian - | '\u058b'..'\u058c' // Armenian - | '\u0590' // Hebrew - | '\u05c8'..'\u05cf' // Hebrew - | '\u05eb'..'\u05ef' // Hebrew - | '\u05f5'..'\u05ff' // Hebrew - | '\u061d' // Arabic - | '\u070e' // Syriac - | '\u074b'..'\u074c' // Syriac - | '\u07b2'..'\u07bf' // Thaana - | '\u07fb'..'\u07ff' // NKo - | '\u082e'..'\u082f' // Samaritan - | '\u083f' // (Absent from Blocks.txt) - | '\u085c'..'\u085d' // Mandaic - | '\u085f'..'\u089f' // (Absent from Blocks.txt) - | '\u08b5' // Arabic_Extended-A - | '\u08be'..'\u08d3' // Arabic_Extended-A - | '\u0984' // Bengali - | '\u098d'..'\u098e' // Bengali - | '\u0991'..'\u0992' // Bengali - | '\u09a9' // Bengali - | '\u09b1' // Bengali - | '\u09b3'..'\u09b5' // Bengali - | '\u09ba'..'\u09bb' // Bengali - | '\u09c5'..'\u09c6' // Bengali - | '\u09c9'..'\u09ca' // Bengali - | '\u09cf'..'\u09d6' // Bengali - | '\u09d8'..'\u09db' // Bengali - | '\u09de' // Bengali - | '\u09e4'..'\u09e5' // Bengali - | '\u09fc'..'\u0a00' // Bengali - | '\u0a04' // Gurmukhi - | '\u0a0b'..'\u0a0e' // Gurmukhi - | '\u0a11'..'\u0a12' // Gurmukhi - | '\u0a29' // Gurmukhi - | '\u0a31' // Gurmukhi - | '\u0a34' // Gurmukhi - | '\u0a37' // Gurmukhi - | '\u0a3a'..'\u0a3b' // Gurmukhi - | '\u0a3d' // Gurmukhi - | '\u0a43'..'\u0a46' // Gurmukhi - | '\u0a49'..'\u0a4a' // Gurmukhi - | '\u0a4e'..'\u0a50' // Gurmukhi - | '\u0a52'..'\u0a58' // Gurmukhi - | '\u0a5d' // Gurmukhi - | '\u0a5f'..'\u0a65' // Gurmukhi - | '\u0a76'..'\u0a80' // Gurmukhi - | '\u0a84' // Gujarati - | '\u0a8e' // Gujarati - | '\u0a92' // Gujarati - | '\u0aa9' // Gujarati - | '\u0ab1' // Gujarati - | '\u0ab4' // Gujarati - | '\u0aba'..'\u0abb' // Gujarati - | '\u0ac6' // Gujarati - | '\u0aca' // Gujarati - | '\u0ace'..'\u0acf' // Gujarati - | '\u0ad1'..'\u0adf' // Gujarati - | '\u0ae4'..'\u0ae5' // Gujarati - | '\u0af2'..'\u0af8' // Gujarati - | '\u0afa'..'\u0b00' // Gujarati - | '\u0b04' // Oriya - | '\u0b0d'..'\u0b0e' // Oriya - | '\u0b11'..'\u0b12' // Oriya - | '\u0b29' // Oriya - | '\u0b31' // Oriya - | '\u0b34' // Oriya - | '\u0b3a'..'\u0b3b' // Oriya - | '\u0b45'..'\u0b46' // Oriya - | '\u0b49'..'\u0b4a' // Oriya - | '\u0b4e'..'\u0b55' // Oriya - | '\u0b58'..'\u0b5b' // Oriya - | '\u0b5e' // Oriya - | '\u0b64'..'\u0b65' // Oriya - | '\u0b78'..'\u0b81' // Oriya - | '\u0b84' // Tamil - | '\u0b8b'..'\u0b8d' // Tamil - | '\u0b91' // Tamil - | '\u0b96'..'\u0b98' // Tamil - | '\u0b9b' // Tamil - | '\u0b9d' // Tamil - | '\u0ba0'..'\u0ba2' // Tamil - | '\u0ba5'..'\u0ba7' // Tamil - | '\u0bab'..'\u0bad' // Tamil - | '\u0bba'..'\u0bbd' // Tamil - | '\u0bc3'..'\u0bc5' // Tamil - | '\u0bc9' // Tamil - | '\u0bce'..'\u0bcf' // Tamil - | '\u0bd1'..'\u0bd6' // Tamil - | '\u0bd8'..'\u0be5' // Tamil - | '\u0bfb'..'\u0bff' // Tamil - | '\u0c04' // Telugu - | '\u0c0d' // Telugu - | '\u0c11' // Telugu - | '\u0c29' // Telugu - | '\u0c3a'..'\u0c3c' // Telugu - | '\u0c45' // Telugu - | '\u0c49' // Telugu - | '\u0c4e'..'\u0c54' // Telugu - | '\u0c57' // Telugu - | '\u0c5b'..'\u0c5f' // Telugu - | '\u0c64'..'\u0c65' // Telugu - | '\u0c70'..'\u0c77' // Telugu - | '\u0c84' // Kannada - | '\u0c8d' // Kannada - | '\u0c91' // Kannada - | '\u0ca9' // Kannada - | '\u0cb4' // Kannada - | '\u0cba'..'\u0cbb' // Kannada - | '\u0cc5' // Kannada - | '\u0cc9' // Kannada - | '\u0cce'..'\u0cd4' // Kannada - | '\u0cd7'..'\u0cdd' // Kannada - | '\u0cdf' // Kannada - | '\u0ce4'..'\u0ce5' // Kannada - | '\u0cf0' // Kannada - | '\u0cf3'..'\u0d00' // Kannada - | '\u0d04' // Malayalam - | '\u0d0d' // Malayalam - | '\u0d11' // Malayalam - | '\u0d3b'..'\u0d3c' // Malayalam - | '\u0d45' // Malayalam - | '\u0d49' // Malayalam - | '\u0d50'..'\u0d53' // Malayalam - | '\u0d64'..'\u0d65' // Malayalam - | '\u0d80'..'\u0d81' // Sinhala - | '\u0d84' // Sinhala - | '\u0d97'..'\u0d99' // Sinhala - | '\u0db2' // Sinhala - | '\u0dbc' // Sinhala - | '\u0dbe'..'\u0dbf' // Sinhala - | '\u0dc7'..'\u0dc9' // Sinhala - | '\u0dcb'..'\u0dce' // Sinhala - | '\u0dd5' // Sinhala - | '\u0dd7' // Sinhala - | '\u0de0'..'\u0de5' // Sinhala - | '\u0df0'..'\u0df1' // Sinhala - | '\u0df5'..'\u0e00' // Sinhala - | '\u0e3b'..'\u0e3e' // Thai - | '\u0e5c'..'\u0e80' // Thai - | '\u0e83' // Lao - | '\u0e85'..'\u0e86' // Lao - | '\u0e89' // Lao - | '\u0e8b'..'\u0e8c' // Lao - | '\u0e8e'..'\u0e93' // Lao - | '\u0e98' // Lao - | '\u0ea0' // Lao - | '\u0ea4' // Lao - | '\u0ea6' // Lao - | '\u0ea8'..'\u0ea9' // Lao - | '\u0eac' // Lao - | '\u0eba' // Lao - | '\u0ebe'..'\u0ebf' // Lao - | '\u0ec5' // Lao - | '\u0ec7' // Lao - | '\u0ece'..'\u0ecf' // Lao - | '\u0eda'..'\u0edb' // Lao - | '\u0ee0'..'\u0eff' // Lao - | '\u0f48' // Tibetan - | '\u0f6d'..'\u0f70' // Tibetan - | '\u0f98' // Tibetan - | '\u0fbd' // Tibetan - | '\u0fcd' // Tibetan - | '\u0fdb'..'\u0fff' // Tibetan - | '\u10c6' // Georgian - | '\u10c8'..'\u10cc' // Georgian - | '\u10ce'..'\u10cf' // Georgian - | '\u1249' // Ethiopic - | '\u124e'..'\u124f' // Ethiopic - | '\u1257' // Ethiopic - | '\u1259' // Ethiopic - | '\u125e'..'\u125f' // Ethiopic - | '\u1289' // Ethiopic - | '\u128e'..'\u128f' // Ethiopic - | '\u12b1' // Ethiopic - | '\u12b6'..'\u12b7' // Ethiopic - | '\u12bf' // Ethiopic - | '\u12c1' // Ethiopic - | '\u12c6'..'\u12c7' // Ethiopic - | '\u12d7' // Ethiopic - | '\u1311' // Ethiopic - | '\u1316'..'\u1317' // Ethiopic - | '\u135b'..'\u135c' // Ethiopic - | '\u137d'..'\u137f' // Ethiopic - | '\u139a'..'\u139f' // Ethiopic_Supplement - | '\u13f6'..'\u13f7' // Cherokee - | '\u13fe'..'\u13ff' // Cherokee - | '\u169d'..'\u169f' // Ogham - | '\u16f9'..'\u16ff' // Runic - | '\u170d' // Tagalog - | '\u1715'..'\u171f' // Tagalog - | '\u1737'..'\u173f' // Hanunoo - | '\u1754'..'\u175f' // Buhid - | '\u176d' // Tagbanwa - | '\u1771' // Tagbanwa - | '\u1774'..'\u177f' // Tagbanwa - | '\u17de'..'\u17df' // Khmer - | '\u17ea'..'\u17ef' // Khmer - | '\u17fa'..'\u17ff' // Khmer - | '\u180f' // Mongolian - | '\u181a'..'\u181f' // Mongolian - | '\u1878'..'\u187f' // Mongolian - | '\u18ab'..'\u18af' // Mongolian - | '\u18f6'..'\u18ff' // Unified_Canadian_Aboriginal_Syllabics_Extended - | '\u191f' // Limbu - | '\u192c'..'\u192f' // Limbu - | '\u193c'..'\u193f' // Limbu - | '\u1941'..'\u1943' // Limbu - | '\u196e'..'\u196f' // Tai_Le - | '\u1975'..'\u197f' // Tai_Le - | '\u19ac'..'\u19af' // New_Tai_Lue - | '\u19ca'..'\u19cf' // New_Tai_Lue - | '\u19db'..'\u19dd' // New_Tai_Lue - | '\u1a1c'..'\u1a1d' // Buginese - | '\u1a5f' // Tai_Tham - | '\u1a7d'..'\u1a7e' // Tai_Tham - | '\u1a8a'..'\u1a8f' // Tai_Tham - | '\u1a9a'..'\u1a9f' // Tai_Tham - | '\u1aae'..'\u1aaf' // Tai_Tham - | '\u1abf'..'\u1aff' // Combining_Diacritical_Marks_Extended - | '\u1b4c'..'\u1b4f' // Balinese - | '\u1b7d'..'\u1b7f' // Balinese - | '\u1bf4'..'\u1bfb' // Batak - | '\u1c38'..'\u1c3a' // Lepcha - | '\u1c4a'..'\u1c4c' // Lepcha - | '\u1c89'..'\u1cbf' // Cyrillic_Extended-C - | '\u1cc8'..'\u1ccf' // Sundanese_Supplement - | '\u1cf7' // Vedic_Extensions - | '\u1cfa'..'\u1cff' // Vedic_Extensions - | '\u1df6'..'\u1dfa' // Combining_Diacritical_Marks_Supplement - | '\u1f16'..'\u1f17' // Greek_Extended - | '\u1f1e'..'\u1f1f' // Greek_Extended - | '\u1f46'..'\u1f47' // Greek_Extended - | '\u1f4e'..'\u1f4f' // Greek_Extended - | '\u1f58' // Greek_Extended - | '\u1f5a' // Greek_Extended - | '\u1f5c' // Greek_Extended - | '\u1f5e' // Greek_Extended - | '\u1f7e'..'\u1f7f' // Greek_Extended - | '\u1fb5' // Greek_Extended - | '\u1fc5' // Greek_Extended - | '\u1fd4'..'\u1fd5' // Greek_Extended - | '\u1fdc' // Greek_Extended - | '\u1ff0'..'\u1ff1' // Greek_Extended - | '\u1ff5' // Greek_Extended - | '\u1fff' // (Absent from Blocks.txt) - | '\u2072'..'\u2073' // Superscripts_and_Subscripts - | '\u208f' // Superscripts_and_Subscripts - | '\u209d'..'\u209f' // Superscripts_and_Subscripts - | '\u20bf'..'\u20cf' // Currency_Symbols - | '\u20f1'..'\u20ff' // Combining_Diacritical_Marks_for_Symbols - | '\u218c'..'\u218f' // Number_Forms - | '\u2c2f' // Glagolitic - | '\u2c5f' // (Absent from Blocks.txt) - | '\u2cf4'..'\u2cf8' // Coptic - | '\u2d26' // Georgian_Supplement - | '\u2d28'..'\u2d2c' // Georgian_Supplement - | '\u2d2e'..'\u2d2f' // Georgian_Supplement - | '\u2d68'..'\u2d6e' // Tifinagh - | '\u2d71'..'\u2d7e' // Tifinagh - | '\u2d97'..'\u2d9f' // Ethiopic_Extended - | '\u2da7' // Ethiopic_Extended - | '\u2daf' // Ethiopic_Extended - | '\u2db7' // Ethiopic_Extended - | '\u2dbf' // Ethiopic_Extended - | '\u2dc7' // Ethiopic_Extended - | '\u2dcf' // Ethiopic_Extended - | '\u2dd7' // Ethiopic_Extended - | '\u2ddf' // (Absent from Blocks.txt) - | '\u2e9a' // CJK_Radicals_Supplement - | '\u2ef4'..'\u2eff' // CJK_Radicals_Supplement - | '\u2fd6'..'\u2fef' // Kangxi_Radicals - | '\u2ffc'..'\u2fff' // Ideographic_Description_Characters - | '\u3040' // Hiragana - | '\u3097'..'\u3098' // Hiragana - | '\u3100'..'\u3104' // Bopomofo - | '\u312e'..'\u3130' // Bopomofo - | '\u318f' // (Absent from Blocks.txt) - | '\u31bb'..'\u31bf' // Bopomofo_Extended - | '\u31e4'..'\u31ef' // CJK_Strokes - | '\u321f' // Enclosed_CJK_Letters_and_Months - | '\u32ff' // (Absent from Blocks.txt) - | '\u4db6'..'\u4dbf' // CJK_Unified_Ideographs_Extension_A - | '\u9fd6'..'\u9fff' // CJK_Unified_Ideographs - | '\ua48d'..'\ua48f' // Yi_Syllables - | '\ua4c7'..'\ua4cf' // Yi_Radicals - | '\ua62c'..'\ua63f' // Vai - | '\ua6f8'..'\ua6ff' // Bamum - | '\ua7af' // Latin_Extended-D - | '\ua7b8'..'\ua7f6' // Latin_Extended-D - | '\ua82c'..'\ua82f' // Syloti_Nagri - | '\ua83a'..'\ua83f' // Common_Indic_Number_Forms - | '\ua878'..'\ua87f' // Phags-pa - | '\ua8c6'..'\ua8cd' // Saurashtra - | '\ua8da'..'\ua8df' // Saurashtra - | '\ua8fe'..'\ua8ff' // Devanagari_Extended - | '\ua954'..'\ua95e' // Rejang - | '\ua97d'..'\ua97f' // Hangul_Jamo_Extended-A - | '\ua9ce' // Javanese - | '\ua9da'..'\ua9dd' // Javanese - | '\ua9ff' // (Absent from Blocks.txt) - | '\uaa37'..'\uaa3f' // Cham - | '\uaa4e'..'\uaa4f' // Cham - | '\uaa5a'..'\uaa5b' // Cham - | '\uaac3'..'\uaada' // Tai_Viet - | '\uaaf7'..'\uab00' // Meetei_Mayek_Extensions - | '\uab07'..'\uab08' // Ethiopic_Extended-A - | '\uab0f'..'\uab10' // Ethiopic_Extended-A - | '\uab17'..'\uab1f' // Ethiopic_Extended-A - | '\uab27' // Ethiopic_Extended-A - | '\uab2f' // (Absent from Blocks.txt) - | '\uab66'..'\uab6f' // Latin_Extended-E - | '\uabee'..'\uabef' // Meetei_Mayek - | '\uabfa'..'\uabff' // Meetei_Mayek - | '\uac01'..'\ud7a2' // Hangul_Syllables - | '\ud7a4'..'\ud7af' // Hangul_Syllables - | '\ud7c7'..'\ud7ca' // Hangul_Jamo_Extended-B - | '\ud7fc'..'\ud7ff' // Hangul_Jamo_Extended-B - | '\ud801'..'\udb7e' // High_Surrogates - | '\udb81'..'\udbfe' // High_Private_Use_Surrogates - | '\udc01'..'\udffe' // Low_Surrogates - | '\ue001'..'\uf8fe' // Private_Use_Area - | '\ufa6e'..'\ufa6f' // CJK_Compatibility_Ideographs - | '\ufada'..'\ufaff' // CJK_Compatibility_Ideographs - | '\ufb07'..'\ufb12' // Alphabetic_Presentation_Forms - | '\ufb18'..'\ufb1c' // Alphabetic_Presentation_Forms - | '\ufb37' // Alphabetic_Presentation_Forms - | '\ufb3d' // Alphabetic_Presentation_Forms - | '\ufb3f' // Alphabetic_Presentation_Forms - | '\ufb42' // Alphabetic_Presentation_Forms - | '\ufb45' // Alphabetic_Presentation_Forms - | '\ufbc2'..'\ufbd2' // Arabic_Presentation_Forms-A - | '\ufd40'..'\ufd4f' // Arabic_Presentation_Forms-A - | '\ufd90'..'\ufd91' // Arabic_Presentation_Forms-A - | '\ufdc8'..'\ufdcf' // Arabic_Presentation_Forms-A - | '\ufdfe'..'\ufdff' // Arabic_Presentation_Forms-A - | '\ufe1a'..'\ufe1f' // Vertical_Forms - | '\ufe53' // Small_Form_Variants - | '\ufe67' // Small_Form_Variants - | '\ufe6c'..'\ufe6f' // Small_Form_Variants - | '\ufe75' // Arabic_Presentation_Forms-B - | '\ufefd'..'\ufefe' // Arabic_Presentation_Forms-B - | '\uff00' // Halfwidth_and_Fullwidth_Forms - | '\uffbf'..'\uffc1' // Halfwidth_and_Fullwidth_Forms - | '\uffc8'..'\uffc9' // Halfwidth_and_Fullwidth_Forms - | '\uffd0'..'\uffd1' // Halfwidth_and_Fullwidth_Forms - | '\uffd8'..'\uffd9' // Halfwidth_and_Fullwidth_Forms - | '\uffdd'..'\uffdf' // Halfwidth_and_Fullwidth_Forms - | '\uffe7' // Halfwidth_and_Fullwidth_Forms - | '\uffef' // (Absent from Blocks.txt) -; +CLASSIFY___ + : '\u0378' ..'\u0379' // Greek_and_Coptic + | '\u0380' ..'\u0383' // Greek_and_Coptic + | '\u038b' // Greek_and_Coptic + | '\u038d' // Greek_and_Coptic + | '\u03a2' // Greek_and_Coptic + | '\u0530' // Armenian + | '\u0557' ..'\u0558' // Armenian + | '\u0560' // Armenian + | '\u0588' // Armenian + | '\u058b' ..'\u058c' // Armenian + | '\u0590' // Hebrew + | '\u05c8' ..'\u05cf' // Hebrew + | '\u05eb' ..'\u05ef' // Hebrew + | '\u05f5' ..'\u05ff' // Hebrew + | '\u061d' // Arabic + | '\u070e' // Syriac + | '\u074b' ..'\u074c' // Syriac + | '\u07b2' ..'\u07bf' // Thaana + | '\u07fb' ..'\u07ff' // NKo + | '\u082e' ..'\u082f' // Samaritan + | '\u083f' // (Absent from Blocks.txt) + | '\u085c' ..'\u085d' // Mandaic + | '\u085f' ..'\u089f' // (Absent from Blocks.txt) + | '\u08b5' // Arabic_Extended-A + | '\u08be' ..'\u08d3' // Arabic_Extended-A + | '\u0984' // Bengali + | '\u098d' ..'\u098e' // Bengali + | '\u0991' ..'\u0992' // Bengali + | '\u09a9' // Bengali + | '\u09b1' // Bengali + | '\u09b3' ..'\u09b5' // Bengali + | '\u09ba' ..'\u09bb' // Bengali + | '\u09c5' ..'\u09c6' // Bengali + | '\u09c9' ..'\u09ca' // Bengali + | '\u09cf' ..'\u09d6' // Bengali + | '\u09d8' ..'\u09db' // Bengali + | '\u09de' // Bengali + | '\u09e4' ..'\u09e5' // Bengali + | '\u09fc' ..'\u0a00' // Bengali + | '\u0a04' // Gurmukhi + | '\u0a0b' ..'\u0a0e' // Gurmukhi + | '\u0a11' ..'\u0a12' // Gurmukhi + | '\u0a29' // Gurmukhi + | '\u0a31' // Gurmukhi + | '\u0a34' // Gurmukhi + | '\u0a37' // Gurmukhi + | '\u0a3a' ..'\u0a3b' // Gurmukhi + | '\u0a3d' // Gurmukhi + | '\u0a43' ..'\u0a46' // Gurmukhi + | '\u0a49' ..'\u0a4a' // Gurmukhi + | '\u0a4e' ..'\u0a50' // Gurmukhi + | '\u0a52' ..'\u0a58' // Gurmukhi + | '\u0a5d' // Gurmukhi + | '\u0a5f' ..'\u0a65' // Gurmukhi + | '\u0a76' ..'\u0a80' // Gurmukhi + | '\u0a84' // Gujarati + | '\u0a8e' // Gujarati + | '\u0a92' // Gujarati + | '\u0aa9' // Gujarati + | '\u0ab1' // Gujarati + | '\u0ab4' // Gujarati + | '\u0aba' ..'\u0abb' // Gujarati + | '\u0ac6' // Gujarati + | '\u0aca' // Gujarati + | '\u0ace' ..'\u0acf' // Gujarati + | '\u0ad1' ..'\u0adf' // Gujarati + | '\u0ae4' ..'\u0ae5' // Gujarati + | '\u0af2' ..'\u0af8' // Gujarati + | '\u0afa' ..'\u0b00' // Gujarati + | '\u0b04' // Oriya + | '\u0b0d' ..'\u0b0e' // Oriya + | '\u0b11' ..'\u0b12' // Oriya + | '\u0b29' // Oriya + | '\u0b31' // Oriya + | '\u0b34' // Oriya + | '\u0b3a' ..'\u0b3b' // Oriya + | '\u0b45' ..'\u0b46' // Oriya + | '\u0b49' ..'\u0b4a' // Oriya + | '\u0b4e' ..'\u0b55' // Oriya + | '\u0b58' ..'\u0b5b' // Oriya + | '\u0b5e' // Oriya + | '\u0b64' ..'\u0b65' // Oriya + | '\u0b78' ..'\u0b81' // Oriya + | '\u0b84' // Tamil + | '\u0b8b' ..'\u0b8d' // Tamil + | '\u0b91' // Tamil + | '\u0b96' ..'\u0b98' // Tamil + | '\u0b9b' // Tamil + | '\u0b9d' // Tamil + | '\u0ba0' ..'\u0ba2' // Tamil + | '\u0ba5' ..'\u0ba7' // Tamil + | '\u0bab' ..'\u0bad' // Tamil + | '\u0bba' ..'\u0bbd' // Tamil + | '\u0bc3' ..'\u0bc5' // Tamil + | '\u0bc9' // Tamil + | '\u0bce' ..'\u0bcf' // Tamil + | '\u0bd1' ..'\u0bd6' // Tamil + | '\u0bd8' ..'\u0be5' // Tamil + | '\u0bfb' ..'\u0bff' // Tamil + | '\u0c04' // Telugu + | '\u0c0d' // Telugu + | '\u0c11' // Telugu + | '\u0c29' // Telugu + | '\u0c3a' ..'\u0c3c' // Telugu + | '\u0c45' // Telugu + | '\u0c49' // Telugu + | '\u0c4e' ..'\u0c54' // Telugu + | '\u0c57' // Telugu + | '\u0c5b' ..'\u0c5f' // Telugu + | '\u0c64' ..'\u0c65' // Telugu + | '\u0c70' ..'\u0c77' // Telugu + | '\u0c84' // Kannada + | '\u0c8d' // Kannada + | '\u0c91' // Kannada + | '\u0ca9' // Kannada + | '\u0cb4' // Kannada + | '\u0cba' ..'\u0cbb' // Kannada + | '\u0cc5' // Kannada + | '\u0cc9' // Kannada + | '\u0cce' ..'\u0cd4' // Kannada + | '\u0cd7' ..'\u0cdd' // Kannada + | '\u0cdf' // Kannada + | '\u0ce4' ..'\u0ce5' // Kannada + | '\u0cf0' // Kannada + | '\u0cf3' ..'\u0d00' // Kannada + | '\u0d04' // Malayalam + | '\u0d0d' // Malayalam + | '\u0d11' // Malayalam + | '\u0d3b' ..'\u0d3c' // Malayalam + | '\u0d45' // Malayalam + | '\u0d49' // Malayalam + | '\u0d50' ..'\u0d53' // Malayalam + | '\u0d64' ..'\u0d65' // Malayalam + | '\u0d80' ..'\u0d81' // Sinhala + | '\u0d84' // Sinhala + | '\u0d97' ..'\u0d99' // Sinhala + | '\u0db2' // Sinhala + | '\u0dbc' // Sinhala + | '\u0dbe' ..'\u0dbf' // Sinhala + | '\u0dc7' ..'\u0dc9' // Sinhala + | '\u0dcb' ..'\u0dce' // Sinhala + | '\u0dd5' // Sinhala + | '\u0dd7' // Sinhala + | '\u0de0' ..'\u0de5' // Sinhala + | '\u0df0' ..'\u0df1' // Sinhala + | '\u0df5' ..'\u0e00' // Sinhala + | '\u0e3b' ..'\u0e3e' // Thai + | '\u0e5c' ..'\u0e80' // Thai + | '\u0e83' // Lao + | '\u0e85' ..'\u0e86' // Lao + | '\u0e89' // Lao + | '\u0e8b' ..'\u0e8c' // Lao + | '\u0e8e' ..'\u0e93' // Lao + | '\u0e98' // Lao + | '\u0ea0' // Lao + | '\u0ea4' // Lao + | '\u0ea6' // Lao + | '\u0ea8' ..'\u0ea9' // Lao + | '\u0eac' // Lao + | '\u0eba' // Lao + | '\u0ebe' ..'\u0ebf' // Lao + | '\u0ec5' // Lao + | '\u0ec7' // Lao + | '\u0ece' ..'\u0ecf' // Lao + | '\u0eda' ..'\u0edb' // Lao + | '\u0ee0' ..'\u0eff' // Lao + | '\u0f48' // Tibetan + | '\u0f6d' ..'\u0f70' // Tibetan + | '\u0f98' // Tibetan + | '\u0fbd' // Tibetan + | '\u0fcd' // Tibetan + | '\u0fdb' ..'\u0fff' // Tibetan + | '\u10c6' // Georgian + | '\u10c8' ..'\u10cc' // Georgian + | '\u10ce' ..'\u10cf' // Georgian + | '\u1249' // Ethiopic + | '\u124e' ..'\u124f' // Ethiopic + | '\u1257' // Ethiopic + | '\u1259' // Ethiopic + | '\u125e' ..'\u125f' // Ethiopic + | '\u1289' // Ethiopic + | '\u128e' ..'\u128f' // Ethiopic + | '\u12b1' // Ethiopic + | '\u12b6' ..'\u12b7' // Ethiopic + | '\u12bf' // Ethiopic + | '\u12c1' // Ethiopic + | '\u12c6' ..'\u12c7' // Ethiopic + | '\u12d7' // Ethiopic + | '\u1311' // Ethiopic + | '\u1316' ..'\u1317' // Ethiopic + | '\u135b' ..'\u135c' // Ethiopic + | '\u137d' ..'\u137f' // Ethiopic + | '\u139a' ..'\u139f' // Ethiopic_Supplement + | '\u13f6' ..'\u13f7' // Cherokee + | '\u13fe' ..'\u13ff' // Cherokee + | '\u169d' ..'\u169f' // Ogham + | '\u16f9' ..'\u16ff' // Runic + | '\u170d' // Tagalog + | '\u1715' ..'\u171f' // Tagalog + | '\u1737' ..'\u173f' // Hanunoo + | '\u1754' ..'\u175f' // Buhid + | '\u176d' // Tagbanwa + | '\u1771' // Tagbanwa + | '\u1774' ..'\u177f' // Tagbanwa + | '\u17de' ..'\u17df' // Khmer + | '\u17ea' ..'\u17ef' // Khmer + | '\u17fa' ..'\u17ff' // Khmer + | '\u180f' // Mongolian + | '\u181a' ..'\u181f' // Mongolian + | '\u1878' ..'\u187f' // Mongolian + | '\u18ab' ..'\u18af' // Mongolian + | '\u18f6' ..'\u18ff' // Unified_Canadian_Aboriginal_Syllabics_Extended + | '\u191f' // Limbu + | '\u192c' ..'\u192f' // Limbu + | '\u193c' ..'\u193f' // Limbu + | '\u1941' ..'\u1943' // Limbu + | '\u196e' ..'\u196f' // Tai_Le + | '\u1975' ..'\u197f' // Tai_Le + | '\u19ac' ..'\u19af' // New_Tai_Lue + | '\u19ca' ..'\u19cf' // New_Tai_Lue + | '\u19db' ..'\u19dd' // New_Tai_Lue + | '\u1a1c' ..'\u1a1d' // Buginese + | '\u1a5f' // Tai_Tham + | '\u1a7d' ..'\u1a7e' // Tai_Tham + | '\u1a8a' ..'\u1a8f' // Tai_Tham + | '\u1a9a' ..'\u1a9f' // Tai_Tham + | '\u1aae' ..'\u1aaf' // Tai_Tham + | '\u1abf' ..'\u1aff' // Combining_Diacritical_Marks_Extended + | '\u1b4c' ..'\u1b4f' // Balinese + | '\u1b7d' ..'\u1b7f' // Balinese + | '\u1bf4' ..'\u1bfb' // Batak + | '\u1c38' ..'\u1c3a' // Lepcha + | '\u1c4a' ..'\u1c4c' // Lepcha + | '\u1c89' ..'\u1cbf' // Cyrillic_Extended-C + | '\u1cc8' ..'\u1ccf' // Sundanese_Supplement + | '\u1cf7' // Vedic_Extensions + | '\u1cfa' ..'\u1cff' // Vedic_Extensions + | '\u1df6' ..'\u1dfa' // Combining_Diacritical_Marks_Supplement + | '\u1f16' ..'\u1f17' // Greek_Extended + | '\u1f1e' ..'\u1f1f' // Greek_Extended + | '\u1f46' ..'\u1f47' // Greek_Extended + | '\u1f4e' ..'\u1f4f' // Greek_Extended + | '\u1f58' // Greek_Extended + | '\u1f5a' // Greek_Extended + | '\u1f5c' // Greek_Extended + | '\u1f5e' // Greek_Extended + | '\u1f7e' ..'\u1f7f' // Greek_Extended + | '\u1fb5' // Greek_Extended + | '\u1fc5' // Greek_Extended + | '\u1fd4' ..'\u1fd5' // Greek_Extended + | '\u1fdc' // Greek_Extended + | '\u1ff0' ..'\u1ff1' // Greek_Extended + | '\u1ff5' // Greek_Extended + | '\u1fff' // (Absent from Blocks.txt) + | '\u2072' ..'\u2073' // Superscripts_and_Subscripts + | '\u208f' // Superscripts_and_Subscripts + | '\u209d' ..'\u209f' // Superscripts_and_Subscripts + | '\u20bf' ..'\u20cf' // Currency_Symbols + | '\u20f1' ..'\u20ff' // Combining_Diacritical_Marks_for_Symbols + | '\u218c' ..'\u218f' // Number_Forms + | '\u2c2f' // Glagolitic + | '\u2c5f' // (Absent from Blocks.txt) + | '\u2cf4' ..'\u2cf8' // Coptic + | '\u2d26' // Georgian_Supplement + | '\u2d28' ..'\u2d2c' // Georgian_Supplement + | '\u2d2e' ..'\u2d2f' // Georgian_Supplement + | '\u2d68' ..'\u2d6e' // Tifinagh + | '\u2d71' ..'\u2d7e' // Tifinagh + | '\u2d97' ..'\u2d9f' // Ethiopic_Extended + | '\u2da7' // Ethiopic_Extended + | '\u2daf' // Ethiopic_Extended + | '\u2db7' // Ethiopic_Extended + | '\u2dbf' // Ethiopic_Extended + | '\u2dc7' // Ethiopic_Extended + | '\u2dcf' // Ethiopic_Extended + | '\u2dd7' // Ethiopic_Extended + | '\u2ddf' // (Absent from Blocks.txt) + | '\u2e9a' // CJK_Radicals_Supplement + | '\u2ef4' ..'\u2eff' // CJK_Radicals_Supplement + | '\u2fd6' ..'\u2fef' // Kangxi_Radicals + | '\u2ffc' ..'\u2fff' // Ideographic_Description_Characters + | '\u3040' // Hiragana + | '\u3097' ..'\u3098' // Hiragana + | '\u3100' ..'\u3104' // Bopomofo + | '\u312e' ..'\u3130' // Bopomofo + | '\u318f' // (Absent from Blocks.txt) + | '\u31bb' ..'\u31bf' // Bopomofo_Extended + | '\u31e4' ..'\u31ef' // CJK_Strokes + | '\u321f' // Enclosed_CJK_Letters_and_Months + | '\u32ff' // (Absent from Blocks.txt) + | '\u4db6' ..'\u4dbf' // CJK_Unified_Ideographs_Extension_A + | '\u9fd6' ..'\u9fff' // CJK_Unified_Ideographs + | '\ua48d' ..'\ua48f' // Yi_Syllables + | '\ua4c7' ..'\ua4cf' // Yi_Radicals + | '\ua62c' ..'\ua63f' // Vai + | '\ua6f8' ..'\ua6ff' // Bamum + | '\ua7af' // Latin_Extended-D + | '\ua7b8' ..'\ua7f6' // Latin_Extended-D + | '\ua82c' ..'\ua82f' // Syloti_Nagri + | '\ua83a' ..'\ua83f' // Common_Indic_Number_Forms + | '\ua878' ..'\ua87f' // Phags-pa + | '\ua8c6' ..'\ua8cd' // Saurashtra + | '\ua8da' ..'\ua8df' // Saurashtra + | '\ua8fe' ..'\ua8ff' // Devanagari_Extended + | '\ua954' ..'\ua95e' // Rejang + | '\ua97d' ..'\ua97f' // Hangul_Jamo_Extended-A + | '\ua9ce' // Javanese + | '\ua9da' ..'\ua9dd' // Javanese + | '\ua9ff' // (Absent from Blocks.txt) + | '\uaa37' ..'\uaa3f' // Cham + | '\uaa4e' ..'\uaa4f' // Cham + | '\uaa5a' ..'\uaa5b' // Cham + | '\uaac3' ..'\uaada' // Tai_Viet + | '\uaaf7' ..'\uab00' // Meetei_Mayek_Extensions + | '\uab07' ..'\uab08' // Ethiopic_Extended-A + | '\uab0f' ..'\uab10' // Ethiopic_Extended-A + | '\uab17' ..'\uab1f' // Ethiopic_Extended-A + | '\uab27' // Ethiopic_Extended-A + | '\uab2f' // (Absent from Blocks.txt) + | '\uab66' ..'\uab6f' // Latin_Extended-E + | '\uabee' ..'\uabef' // Meetei_Mayek + | '\uabfa' ..'\uabff' // Meetei_Mayek + | '\uac01' ..'\ud7a2' // Hangul_Syllables + | '\ud7a4' ..'\ud7af' // Hangul_Syllables + | '\ud7c7' ..'\ud7ca' // Hangul_Jamo_Extended-B + | '\ud7fc' ..'\ud7ff' // Hangul_Jamo_Extended-B + | '\ud801' ..'\udb7e' // High_Surrogates + | '\udb81' ..'\udbfe' // High_Private_Use_Surrogates + | '\udc01' ..'\udffe' // Low_Surrogates + | '\ue001' ..'\uf8fe' // Private_Use_Area + | '\ufa6e' ..'\ufa6f' // CJK_Compatibility_Ideographs + | '\ufada' ..'\ufaff' // CJK_Compatibility_Ideographs + | '\ufb07' ..'\ufb12' // Alphabetic_Presentation_Forms + | '\ufb18' ..'\ufb1c' // Alphabetic_Presentation_Forms + | '\ufb37' // Alphabetic_Presentation_Forms + | '\ufb3d' // Alphabetic_Presentation_Forms + | '\ufb3f' // Alphabetic_Presentation_Forms + | '\ufb42' // Alphabetic_Presentation_Forms + | '\ufb45' // Alphabetic_Presentation_Forms + | '\ufbc2' ..'\ufbd2' // Arabic_Presentation_Forms-A + | '\ufd40' ..'\ufd4f' // Arabic_Presentation_Forms-A + | '\ufd90' ..'\ufd91' // Arabic_Presentation_Forms-A + | '\ufdc8' ..'\ufdcf' // Arabic_Presentation_Forms-A + | '\ufdfe' ..'\ufdff' // Arabic_Presentation_Forms-A + | '\ufe1a' ..'\ufe1f' // Vertical_Forms + | '\ufe53' // Small_Form_Variants + | '\ufe67' // Small_Form_Variants + | '\ufe6c' ..'\ufe6f' // Small_Form_Variants + | '\ufe75' // Arabic_Presentation_Forms-B + | '\ufefd' ..'\ufefe' // Arabic_Presentation_Forms-B + | '\uff00' // Halfwidth_and_Fullwidth_Forms + | '\uffbf' ..'\uffc1' // Halfwidth_and_Fullwidth_Forms + | '\uffc8' ..'\uffc9' // Halfwidth_and_Fullwidth_Forms + | '\uffd0' ..'\uffd1' // Halfwidth_and_Fullwidth_Forms + | '\uffd8' ..'\uffd9' // Halfwidth_and_Fullwidth_Forms + | '\uffdd' ..'\uffdf' // Halfwidth_and_Fullwidth_Forms + | '\uffe7' // Halfwidth_and_Fullwidth_Forms + | '\uffef' // (Absent from Blocks.txt) + ; -CLASSIFY_Cc: - '\u0000'..'\u001f' // Basic_Latin - | '\u007f'..'\u009f' // (Absent from Blocks.txt) -; +CLASSIFY_Cc + : '\u0000' ..'\u001f' // Basic_Latin + | '\u007f' ..'\u009f' // (Absent from Blocks.txt) + ; -CLASSIFY_Cf: - '\u00ad' // Latin-1_Supplement - | '\u0600'..'\u0605' // Arabic - | '\u061c' // Arabic - | '\u06dd' // Arabic - | '\u070f' // Syriac - | '\u08e2' // Arabic_Extended-A - | '\u180e' // Mongolian - | '\u200b'..'\u200f' // General_Punctuation - | '\u202a'..'\u202e' // General_Punctuation - | '\u2060'..'\u2064' // General_Punctuation - | '\u2066'..'\u206f' // General_Punctuation - | '\ufeff' // (Absent from Blocks.txt) - | '\ufff9'..'\ufffb' // Specials -; +CLASSIFY_Cf + : '\u00ad' // Latin-1_Supplement + | '\u0600' ..'\u0605' // Arabic + | '\u061c' // Arabic + | '\u06dd' // Arabic + | '\u070f' // Syriac + | '\u08e2' // Arabic_Extended-A + | '\u180e' // Mongolian + | '\u200b' ..'\u200f' // General_Punctuation + | '\u202a' ..'\u202e' // General_Punctuation + | '\u2060' ..'\u2064' // General_Punctuation + | '\u2066' ..'\u206f' // General_Punctuation + | '\ufeff' // (Absent from Blocks.txt) + | '\ufff9' ..'\ufffb' // Specials + ; -CLASSIFY_Cn: - '\u2065' // General_Punctuation - | '\u23ff' // (Absent from Blocks.txt) - | '\u2427'..'\u243f' // Control_Pictures - | '\u244b'..'\u245f' // Optical_Character_Recognition - | '\u2b74'..'\u2b75' // Miscellaneous_Symbols_and_Arrows - | '\u2b96'..'\u2b97' // Miscellaneous_Symbols_and_Arrows - | '\u2bba'..'\u2bbc' // Miscellaneous_Symbols_and_Arrows - | '\u2bc9' // Miscellaneous_Symbols_and_Arrows - | '\u2bd2'..'\u2beb' // Miscellaneous_Symbols_and_Arrows - | '\u2bf0'..'\u2bff' // Miscellaneous_Symbols_and_Arrows - | '\u2e45'..'\u2e7f' // Supplemental_Punctuation - | '\ufdd0'..'\ufdef' // Arabic_Presentation_Forms-A - | '\ufff0'..'\ufff8' // Specials -; +CLASSIFY_Cn + : '\u2065' // General_Punctuation + | '\u23ff' // (Absent from Blocks.txt) + | '\u2427' ..'\u243f' // Control_Pictures + | '\u244b' ..'\u245f' // Optical_Character_Recognition + | '\u2b74' ..'\u2b75' // Miscellaneous_Symbols_and_Arrows + | '\u2b96' ..'\u2b97' // Miscellaneous_Symbols_and_Arrows + | '\u2bba' ..'\u2bbc' // Miscellaneous_Symbols_and_Arrows + | '\u2bc9' // Miscellaneous_Symbols_and_Arrows + | '\u2bd2' ..'\u2beb' // Miscellaneous_Symbols_and_Arrows + | '\u2bf0' ..'\u2bff' // Miscellaneous_Symbols_and_Arrows + | '\u2e45' ..'\u2e7f' // Supplemental_Punctuation + | '\ufdd0' ..'\ufdef' // Arabic_Presentation_Forms-A + | '\ufff0' ..'\ufff8' // Specials + ; -CLASSIFY_Co: - '\ue000' // Private_Use_Area - | '\uf8ff' // (Absent from Blocks.txt) -; +CLASSIFY_Co + : '\ue000' // Private_Use_Area + | '\uf8ff' // (Absent from Blocks.txt) + ; -CLASSIFY_Cs: - '\ud800' // High_Surrogates - | '\udb7f'..'\udb80' // (Absent from Blocks.txt) - | '\udbff'..'\udc00' // (Absent from Blocks.txt) - | '\udfff' // (Absent from Blocks.txt) -; +CLASSIFY_Cs + : '\ud800' // High_Surrogates + | '\udb7f' ..'\udb80' // (Absent from Blocks.txt) + | '\udbff' ..'\udc00' // (Absent from Blocks.txt) + | '\udfff' // (Absent from Blocks.txt) + ; -CLASSIFY_Ll: - '\u0061'..'\u007a' // Basic_Latin - | '\u00b5' // Latin-1_Supplement - | '\u00df'..'\u00f6' // Latin-1_Supplement - | '\u00f8'..'\u00ff' // Latin-1_Supplement - | '\u0101' // Latin_Extended-A - | '\u0103' // Latin_Extended-A - | '\u0105' // Latin_Extended-A - | '\u0107' // Latin_Extended-A - | '\u0109' // Latin_Extended-A - | '\u010b' // Latin_Extended-A - | '\u010d' // Latin_Extended-A - | '\u010f' // Latin_Extended-A - | '\u0111' // Latin_Extended-A - | '\u0113' // Latin_Extended-A - | '\u0115' // Latin_Extended-A - | '\u0117' // Latin_Extended-A - | '\u0119' // Latin_Extended-A - | '\u011b' // Latin_Extended-A - | '\u011d' // Latin_Extended-A - | '\u011f' // Latin_Extended-A - | '\u0121' // Latin_Extended-A - | '\u0123' // Latin_Extended-A - | '\u0125' // Latin_Extended-A - | '\u0127' // Latin_Extended-A - | '\u0129' // Latin_Extended-A - | '\u012b' // Latin_Extended-A - | '\u012d' // Latin_Extended-A - | '\u012f' // Latin_Extended-A - | '\u0131' // Latin_Extended-A - | '\u0133' // Latin_Extended-A - | '\u0135' // Latin_Extended-A - | '\u0137'..'\u0138' // Latin_Extended-A - | '\u013a' // Latin_Extended-A - | '\u013c' // Latin_Extended-A - | '\u013e' // Latin_Extended-A - | '\u0140' // Latin_Extended-A - | '\u0142' // Latin_Extended-A - | '\u0144' // Latin_Extended-A - | '\u0146' // Latin_Extended-A - | '\u0148'..'\u0149' // Latin_Extended-A - | '\u014b' // Latin_Extended-A - | '\u014d' // Latin_Extended-A - | '\u014f' // Latin_Extended-A - | '\u0151' // Latin_Extended-A - | '\u0153' // Latin_Extended-A - | '\u0155' // Latin_Extended-A - | '\u0157' // Latin_Extended-A - | '\u0159' // Latin_Extended-A - | '\u015b' // Latin_Extended-A - | '\u015d' // Latin_Extended-A - | '\u015f' // Latin_Extended-A - | '\u0161' // Latin_Extended-A - | '\u0163' // Latin_Extended-A - | '\u0165' // Latin_Extended-A - | '\u0167' // Latin_Extended-A - | '\u0169' // Latin_Extended-A - | '\u016b' // Latin_Extended-A - | '\u016d' // Latin_Extended-A - | '\u016f' // Latin_Extended-A - | '\u0171' // Latin_Extended-A - | '\u0173' // Latin_Extended-A - | '\u0175' // Latin_Extended-A - | '\u0177' // Latin_Extended-A - | '\u017a' // Latin_Extended-A - | '\u017c' // Latin_Extended-A - | '\u017e'..'\u0180' // Latin_Extended-A - | '\u0183' // Latin_Extended-B - | '\u0185' // Latin_Extended-B - | '\u0188' // Latin_Extended-B - | '\u018c'..'\u018d' // Latin_Extended-B - | '\u0192' // Latin_Extended-B - | '\u0195' // Latin_Extended-B - | '\u0199'..'\u019b' // Latin_Extended-B - | '\u019e' // Latin_Extended-B - | '\u01a1' // Latin_Extended-B - | '\u01a3' // Latin_Extended-B - | '\u01a5' // Latin_Extended-B - | '\u01a8' // Latin_Extended-B - | '\u01aa'..'\u01ab' // Latin_Extended-B - | '\u01ad' // Latin_Extended-B - | '\u01b0' // Latin_Extended-B - | '\u01b4' // Latin_Extended-B - | '\u01b6' // Latin_Extended-B - | '\u01b9'..'\u01ba' // Latin_Extended-B - | '\u01bd'..'\u01bf' // Latin_Extended-B - | '\u01c6' // Latin_Extended-B - | '\u01c9' // Latin_Extended-B - | '\u01cc' // Latin_Extended-B - | '\u01ce' // Latin_Extended-B - | '\u01d0' // Latin_Extended-B - | '\u01d2' // Latin_Extended-B - | '\u01d4' // Latin_Extended-B - | '\u01d6' // Latin_Extended-B - | '\u01d8' // Latin_Extended-B - | '\u01da' // Latin_Extended-B - | '\u01dc'..'\u01dd' // Latin_Extended-B - | '\u01df' // Latin_Extended-B - | '\u01e1' // Latin_Extended-B - | '\u01e3' // Latin_Extended-B - | '\u01e5' // Latin_Extended-B - | '\u01e7' // Latin_Extended-B - | '\u01e9' // Latin_Extended-B - | '\u01eb' // Latin_Extended-B - | '\u01ed' // Latin_Extended-B - | '\u01ef'..'\u01f0' // Latin_Extended-B - | '\u01f3' // Latin_Extended-B - | '\u01f5' // Latin_Extended-B - | '\u01f9' // Latin_Extended-B - | '\u01fb' // Latin_Extended-B - | '\u01fd' // Latin_Extended-B - | '\u01ff' // Latin_Extended-B - | '\u0201' // Latin_Extended-B - | '\u0203' // Latin_Extended-B - | '\u0205' // Latin_Extended-B - | '\u0207' // Latin_Extended-B - | '\u0209' // Latin_Extended-B - | '\u020b' // Latin_Extended-B - | '\u020d' // Latin_Extended-B - | '\u020f' // Latin_Extended-B - | '\u0211' // Latin_Extended-B - | '\u0213' // Latin_Extended-B - | '\u0215' // Latin_Extended-B - | '\u0217' // Latin_Extended-B - | '\u0219' // Latin_Extended-B - | '\u021b' // Latin_Extended-B - | '\u021d' // Latin_Extended-B - | '\u021f' // Latin_Extended-B - | '\u0221' // Latin_Extended-B - | '\u0223' // Latin_Extended-B - | '\u0225' // Latin_Extended-B - | '\u0227' // Latin_Extended-B - | '\u0229' // Latin_Extended-B - | '\u022b' // Latin_Extended-B - | '\u022d' // Latin_Extended-B - | '\u022f' // Latin_Extended-B - | '\u0231' // Latin_Extended-B - | '\u0233'..'\u0239' // Latin_Extended-B - | '\u023c' // Latin_Extended-B - | '\u023f'..'\u0240' // Latin_Extended-B - | '\u0242' // Latin_Extended-B - | '\u0247' // Latin_Extended-B - | '\u0249' // Latin_Extended-B - | '\u024b' // Latin_Extended-B - | '\u024d' // Latin_Extended-B - | '\u024f'..'\u0293' // (Absent from Blocks.txt) - | '\u0295'..'\u02af' // IPA_Extensions - | '\u0371' // Greek_and_Coptic - | '\u0373' // Greek_and_Coptic - | '\u0377' // Greek_and_Coptic - | '\u037b'..'\u037d' // Greek_and_Coptic - | '\u0390' // Greek_and_Coptic - | '\u03ac'..'\u03ce' // Greek_and_Coptic - | '\u03d0'..'\u03d1' // Greek_and_Coptic - | '\u03d5'..'\u03d7' // Greek_and_Coptic - | '\u03d9' // Greek_and_Coptic - | '\u03db' // Greek_and_Coptic - | '\u03dd' // Greek_and_Coptic - | '\u03df' // Greek_and_Coptic - | '\u03e1' // Greek_and_Coptic - | '\u03e3' // Greek_and_Coptic - | '\u03e5' // Greek_and_Coptic - | '\u03e7' // Greek_and_Coptic - | '\u03e9' // Greek_and_Coptic - | '\u03eb' // Greek_and_Coptic - | '\u03ed' // Greek_and_Coptic - | '\u03ef'..'\u03f3' // Greek_and_Coptic - | '\u03f5' // Greek_and_Coptic - | '\u03f8' // Greek_and_Coptic - | '\u03fb'..'\u03fc' // Greek_and_Coptic - | '\u0430'..'\u045f' // Cyrillic - | '\u0461' // Cyrillic - | '\u0463' // Cyrillic - | '\u0465' // Cyrillic - | '\u0467' // Cyrillic - | '\u0469' // Cyrillic - | '\u046b' // Cyrillic - | '\u046d' // Cyrillic - | '\u046f' // Cyrillic - | '\u0471' // Cyrillic - | '\u0473' // Cyrillic - | '\u0475' // Cyrillic - | '\u0477' // Cyrillic - | '\u0479' // Cyrillic - | '\u047b' // Cyrillic - | '\u047d' // Cyrillic - | '\u047f' // Cyrillic - | '\u0481' // Cyrillic - | '\u048b' // Cyrillic - | '\u048d' // Cyrillic - | '\u048f' // Cyrillic - | '\u0491' // Cyrillic - | '\u0493' // Cyrillic - | '\u0495' // Cyrillic - | '\u0497' // Cyrillic - | '\u0499' // Cyrillic - | '\u049b' // Cyrillic - | '\u049d' // Cyrillic - | '\u049f' // Cyrillic - | '\u04a1' // Cyrillic - | '\u04a3' // Cyrillic - | '\u04a5' // Cyrillic - | '\u04a7' // Cyrillic - | '\u04a9' // Cyrillic - | '\u04ab' // Cyrillic - | '\u04ad' // Cyrillic - | '\u04af' // Cyrillic - | '\u04b1' // Cyrillic - | '\u04b3' // Cyrillic - | '\u04b5' // Cyrillic - | '\u04b7' // Cyrillic - | '\u04b9' // Cyrillic - | '\u04bb' // Cyrillic - | '\u04bd' // Cyrillic - | '\u04bf' // Cyrillic - | '\u04c2' // Cyrillic - | '\u04c4' // Cyrillic - | '\u04c6' // Cyrillic - | '\u04c8' // Cyrillic - | '\u04ca' // Cyrillic - | '\u04cc' // Cyrillic - | '\u04ce'..'\u04cf' // Cyrillic - | '\u04d1' // Cyrillic - | '\u04d3' // Cyrillic - | '\u04d5' // Cyrillic - | '\u04d7' // Cyrillic - | '\u04d9' // Cyrillic - | '\u04db' // Cyrillic - | '\u04dd' // Cyrillic - | '\u04df' // Cyrillic - | '\u04e1' // Cyrillic - | '\u04e3' // Cyrillic - | '\u04e5' // Cyrillic - | '\u04e7' // Cyrillic - | '\u04e9' // Cyrillic - | '\u04eb' // Cyrillic - | '\u04ed' // Cyrillic - | '\u04ef' // Cyrillic - | '\u04f1' // Cyrillic - | '\u04f3' // Cyrillic - | '\u04f5' // Cyrillic - | '\u04f7' // Cyrillic - | '\u04f9' // Cyrillic - | '\u04fb' // Cyrillic - | '\u04fd' // Cyrillic - | '\u04ff' // (Absent from Blocks.txt) - | '\u0501' // Cyrillic_Supplement - | '\u0503' // Cyrillic_Supplement - | '\u0505' // Cyrillic_Supplement - | '\u0507' // Cyrillic_Supplement - | '\u0509' // Cyrillic_Supplement - | '\u050b' // Cyrillic_Supplement - | '\u050d' // Cyrillic_Supplement - | '\u050f' // Cyrillic_Supplement - | '\u0511' // Cyrillic_Supplement - | '\u0513' // Cyrillic_Supplement - | '\u0515' // Cyrillic_Supplement - | '\u0517' // Cyrillic_Supplement - | '\u0519' // Cyrillic_Supplement - | '\u051b' // Cyrillic_Supplement - | '\u051d' // Cyrillic_Supplement - | '\u051f' // Cyrillic_Supplement - | '\u0521' // Cyrillic_Supplement - | '\u0523' // Cyrillic_Supplement - | '\u0525' // Cyrillic_Supplement - | '\u0527' // Cyrillic_Supplement - | '\u0529' // Cyrillic_Supplement - | '\u052b' // Cyrillic_Supplement - | '\u052d' // Cyrillic_Supplement - | '\u052f' // (Absent from Blocks.txt) - | '\u0561'..'\u0587' // Armenian - | '\u13f8'..'\u13fd' // Cherokee - | '\u1c80'..'\u1c88' // Cyrillic_Extended-C - | '\u1d00'..'\u1d2b' // Phonetic_Extensions - | '\u1d6b'..'\u1d77' // Phonetic_Extensions - | '\u1d79'..'\u1d9a' // Phonetic_Extensions - | '\u1e01' // Latin_Extended_Additional - | '\u1e03' // Latin_Extended_Additional - | '\u1e05' // Latin_Extended_Additional - | '\u1e07' // Latin_Extended_Additional - | '\u1e09' // Latin_Extended_Additional - | '\u1e0b' // Latin_Extended_Additional - | '\u1e0d' // Latin_Extended_Additional - | '\u1e0f' // Latin_Extended_Additional - | '\u1e11' // Latin_Extended_Additional - | '\u1e13' // Latin_Extended_Additional - | '\u1e15' // Latin_Extended_Additional - | '\u1e17' // Latin_Extended_Additional - | '\u1e19' // Latin_Extended_Additional - | '\u1e1b' // Latin_Extended_Additional - | '\u1e1d' // Latin_Extended_Additional - | '\u1e1f' // Latin_Extended_Additional - | '\u1e21' // Latin_Extended_Additional - | '\u1e23' // Latin_Extended_Additional - | '\u1e25' // Latin_Extended_Additional - | '\u1e27' // Latin_Extended_Additional - | '\u1e29' // Latin_Extended_Additional - | '\u1e2b' // Latin_Extended_Additional - | '\u1e2d' // Latin_Extended_Additional - | '\u1e2f' // Latin_Extended_Additional - | '\u1e31' // Latin_Extended_Additional - | '\u1e33' // Latin_Extended_Additional - | '\u1e35' // Latin_Extended_Additional - | '\u1e37' // Latin_Extended_Additional - | '\u1e39' // Latin_Extended_Additional - | '\u1e3b' // Latin_Extended_Additional - | '\u1e3d' // Latin_Extended_Additional - | '\u1e3f' // Latin_Extended_Additional - | '\u1e41' // Latin_Extended_Additional - | '\u1e43' // Latin_Extended_Additional - | '\u1e45' // Latin_Extended_Additional - | '\u1e47' // Latin_Extended_Additional - | '\u1e49' // Latin_Extended_Additional - | '\u1e4b' // Latin_Extended_Additional - | '\u1e4d' // Latin_Extended_Additional - | '\u1e4f' // Latin_Extended_Additional - | '\u1e51' // Latin_Extended_Additional - | '\u1e53' // Latin_Extended_Additional - | '\u1e55' // Latin_Extended_Additional - | '\u1e57' // Latin_Extended_Additional - | '\u1e59' // Latin_Extended_Additional - | '\u1e5b' // Latin_Extended_Additional - | '\u1e5d' // Latin_Extended_Additional - | '\u1e5f' // Latin_Extended_Additional - | '\u1e61' // Latin_Extended_Additional - | '\u1e63' // Latin_Extended_Additional - | '\u1e65' // Latin_Extended_Additional - | '\u1e67' // Latin_Extended_Additional - | '\u1e69' // Latin_Extended_Additional - | '\u1e6b' // Latin_Extended_Additional - | '\u1e6d' // Latin_Extended_Additional - | '\u1e6f' // Latin_Extended_Additional - | '\u1e71' // Latin_Extended_Additional - | '\u1e73' // Latin_Extended_Additional - | '\u1e75' // Latin_Extended_Additional - | '\u1e77' // Latin_Extended_Additional - | '\u1e79' // Latin_Extended_Additional - | '\u1e7b' // Latin_Extended_Additional - | '\u1e7d' // Latin_Extended_Additional - | '\u1e7f' // Latin_Extended_Additional - | '\u1e81' // Latin_Extended_Additional - | '\u1e83' // Latin_Extended_Additional - | '\u1e85' // Latin_Extended_Additional - | '\u1e87' // Latin_Extended_Additional - | '\u1e89' // Latin_Extended_Additional - | '\u1e8b' // Latin_Extended_Additional - | '\u1e8d' // Latin_Extended_Additional - | '\u1e8f' // Latin_Extended_Additional - | '\u1e91' // Latin_Extended_Additional - | '\u1e93' // Latin_Extended_Additional - | '\u1e95'..'\u1e9d' // Latin_Extended_Additional - | '\u1e9f' // Latin_Extended_Additional - | '\u1ea1' // Latin_Extended_Additional - | '\u1ea3' // Latin_Extended_Additional - | '\u1ea5' // Latin_Extended_Additional - | '\u1ea7' // Latin_Extended_Additional - | '\u1ea9' // Latin_Extended_Additional - | '\u1eab' // Latin_Extended_Additional - | '\u1ead' // Latin_Extended_Additional - | '\u1eaf' // Latin_Extended_Additional - | '\u1eb1' // Latin_Extended_Additional - | '\u1eb3' // Latin_Extended_Additional - | '\u1eb5' // Latin_Extended_Additional - | '\u1eb7' // Latin_Extended_Additional - | '\u1eb9' // Latin_Extended_Additional - | '\u1ebb' // Latin_Extended_Additional - | '\u1ebd' // Latin_Extended_Additional - | '\u1ebf' // Latin_Extended_Additional - | '\u1ec1' // Latin_Extended_Additional - | '\u1ec3' // Latin_Extended_Additional - | '\u1ec5' // Latin_Extended_Additional - | '\u1ec7' // Latin_Extended_Additional - | '\u1ec9' // Latin_Extended_Additional - | '\u1ecb' // Latin_Extended_Additional - | '\u1ecd' // Latin_Extended_Additional - | '\u1ecf' // Latin_Extended_Additional - | '\u1ed1' // Latin_Extended_Additional - | '\u1ed3' // Latin_Extended_Additional - | '\u1ed5' // Latin_Extended_Additional - | '\u1ed7' // Latin_Extended_Additional - | '\u1ed9' // Latin_Extended_Additional - | '\u1edb' // Latin_Extended_Additional - | '\u1edd' // Latin_Extended_Additional - | '\u1edf' // Latin_Extended_Additional - | '\u1ee1' // Latin_Extended_Additional - | '\u1ee3' // Latin_Extended_Additional - | '\u1ee5' // Latin_Extended_Additional - | '\u1ee7' // Latin_Extended_Additional - | '\u1ee9' // Latin_Extended_Additional - | '\u1eeb' // Latin_Extended_Additional - | '\u1eed' // Latin_Extended_Additional - | '\u1eef' // Latin_Extended_Additional - | '\u1ef1' // Latin_Extended_Additional - | '\u1ef3' // Latin_Extended_Additional - | '\u1ef5' // Latin_Extended_Additional - | '\u1ef7' // Latin_Extended_Additional - | '\u1ef9' // Latin_Extended_Additional - | '\u1efb' // Latin_Extended_Additional - | '\u1efd' // Latin_Extended_Additional - | '\u1eff'..'\u1f07' // (Absent from Blocks.txt) - | '\u1f10'..'\u1f15' // Greek_Extended - | '\u1f20'..'\u1f27' // Greek_Extended - | '\u1f30'..'\u1f37' // Greek_Extended - | '\u1f40'..'\u1f45' // Greek_Extended - | '\u1f50'..'\u1f57' // Greek_Extended - | '\u1f60'..'\u1f67' // Greek_Extended - | '\u1f70'..'\u1f7d' // Greek_Extended - | '\u1f80'..'\u1f87' // Greek_Extended - | '\u1f90'..'\u1f97' // Greek_Extended - | '\u1fa0'..'\u1fa7' // Greek_Extended - | '\u1fb0'..'\u1fb4' // Greek_Extended - | '\u1fb6'..'\u1fb7' // Greek_Extended - | '\u1fbe' // Greek_Extended - | '\u1fc2'..'\u1fc4' // Greek_Extended - | '\u1fc6'..'\u1fc7' // Greek_Extended - | '\u1fd0'..'\u1fd3' // Greek_Extended - | '\u1fd6'..'\u1fd7' // Greek_Extended - | '\u1fe0'..'\u1fe7' // Greek_Extended - | '\u1ff2'..'\u1ff4' // Greek_Extended - | '\u1ff6'..'\u1ff7' // Greek_Extended - | '\u210a' // Letterlike_Symbols - | '\u210e'..'\u210f' // Letterlike_Symbols - | '\u2113' // Letterlike_Symbols - | '\u212f' // Letterlike_Symbols - | '\u2134' // Letterlike_Symbols - | '\u2139' // Letterlike_Symbols - | '\u213c'..'\u213d' // Letterlike_Symbols - | '\u2146'..'\u2149' // Letterlike_Symbols - | '\u214e' // Letterlike_Symbols - | '\u2184' // Number_Forms - | '\u2c30'..'\u2c5e' // Glagolitic - | '\u2c61' // Latin_Extended-C - | '\u2c65'..'\u2c66' // Latin_Extended-C - | '\u2c68' // Latin_Extended-C - | '\u2c6a' // Latin_Extended-C - | '\u2c6c' // Latin_Extended-C - | '\u2c71' // Latin_Extended-C - | '\u2c73'..'\u2c74' // Latin_Extended-C - | '\u2c76'..'\u2c7b' // Latin_Extended-C - | '\u2c81' // Coptic - | '\u2c83' // Coptic - | '\u2c85' // Coptic - | '\u2c87' // Coptic - | '\u2c89' // Coptic - | '\u2c8b' // Coptic - | '\u2c8d' // Coptic - | '\u2c8f' // Coptic - | '\u2c91' // Coptic - | '\u2c93' // Coptic - | '\u2c95' // Coptic - | '\u2c97' // Coptic - | '\u2c99' // Coptic - | '\u2c9b' // Coptic - | '\u2c9d' // Coptic - | '\u2c9f' // Coptic - | '\u2ca1' // Coptic - | '\u2ca3' // Coptic - | '\u2ca5' // Coptic - | '\u2ca7' // Coptic - | '\u2ca9' // Coptic - | '\u2cab' // Coptic - | '\u2cad' // Coptic - | '\u2caf' // Coptic - | '\u2cb1' // Coptic - | '\u2cb3' // Coptic - | '\u2cb5' // Coptic - | '\u2cb7' // Coptic - | '\u2cb9' // Coptic - | '\u2cbb' // Coptic - | '\u2cbd' // Coptic - | '\u2cbf' // Coptic - | '\u2cc1' // Coptic - | '\u2cc3' // Coptic - | '\u2cc5' // Coptic - | '\u2cc7' // Coptic - | '\u2cc9' // Coptic - | '\u2ccb' // Coptic - | '\u2ccd' // Coptic - | '\u2ccf' // Coptic - | '\u2cd1' // Coptic - | '\u2cd3' // Coptic - | '\u2cd5' // Coptic - | '\u2cd7' // Coptic - | '\u2cd9' // Coptic - | '\u2cdb' // Coptic - | '\u2cdd' // Coptic - | '\u2cdf' // Coptic - | '\u2ce1' // Coptic - | '\u2ce3'..'\u2ce4' // Coptic - | '\u2cec' // Coptic - | '\u2cee' // Coptic - | '\u2cf3' // Coptic - | '\u2d00'..'\u2d25' // Georgian_Supplement - | '\u2d27' // Georgian_Supplement - | '\u2d2d' // Georgian_Supplement - | '\ua641' // Cyrillic_Extended-B - | '\ua643' // Cyrillic_Extended-B - | '\ua645' // Cyrillic_Extended-B - | '\ua647' // Cyrillic_Extended-B - | '\ua649' // Cyrillic_Extended-B - | '\ua64b' // Cyrillic_Extended-B - | '\ua64d' // Cyrillic_Extended-B - | '\ua64f' // Cyrillic_Extended-B - | '\ua651' // Cyrillic_Extended-B - | '\ua653' // Cyrillic_Extended-B - | '\ua655' // Cyrillic_Extended-B - | '\ua657' // Cyrillic_Extended-B - | '\ua659' // Cyrillic_Extended-B - | '\ua65b' // Cyrillic_Extended-B - | '\ua65d' // Cyrillic_Extended-B - | '\ua65f' // Cyrillic_Extended-B - | '\ua661' // Cyrillic_Extended-B - | '\ua663' // Cyrillic_Extended-B - | '\ua665' // Cyrillic_Extended-B - | '\ua667' // Cyrillic_Extended-B - | '\ua669' // Cyrillic_Extended-B - | '\ua66b' // Cyrillic_Extended-B - | '\ua66d' // Cyrillic_Extended-B - | '\ua681' // Cyrillic_Extended-B - | '\ua683' // Cyrillic_Extended-B - | '\ua685' // Cyrillic_Extended-B - | '\ua687' // Cyrillic_Extended-B - | '\ua689' // Cyrillic_Extended-B - | '\ua68b' // Cyrillic_Extended-B - | '\ua68d' // Cyrillic_Extended-B - | '\ua68f' // Cyrillic_Extended-B - | '\ua691' // Cyrillic_Extended-B - | '\ua693' // Cyrillic_Extended-B - | '\ua695' // Cyrillic_Extended-B - | '\ua697' // Cyrillic_Extended-B - | '\ua699' // Cyrillic_Extended-B - | '\ua69b' // Cyrillic_Extended-B - | '\ua723' // Latin_Extended-D - | '\ua725' // Latin_Extended-D - | '\ua727' // Latin_Extended-D - | '\ua729' // Latin_Extended-D - | '\ua72b' // Latin_Extended-D - | '\ua72d' // Latin_Extended-D - | '\ua72f'..'\ua731' // Latin_Extended-D - | '\ua733' // Latin_Extended-D - | '\ua735' // Latin_Extended-D - | '\ua737' // Latin_Extended-D - | '\ua739' // Latin_Extended-D - | '\ua73b' // Latin_Extended-D - | '\ua73d' // Latin_Extended-D - | '\ua73f' // Latin_Extended-D - | '\ua741' // Latin_Extended-D - | '\ua743' // Latin_Extended-D - | '\ua745' // Latin_Extended-D - | '\ua747' // Latin_Extended-D - | '\ua749' // Latin_Extended-D - | '\ua74b' // Latin_Extended-D - | '\ua74d' // Latin_Extended-D - | '\ua74f' // Latin_Extended-D - | '\ua751' // Latin_Extended-D - | '\ua753' // Latin_Extended-D - | '\ua755' // Latin_Extended-D - | '\ua757' // Latin_Extended-D - | '\ua759' // Latin_Extended-D - | '\ua75b' // Latin_Extended-D - | '\ua75d' // Latin_Extended-D - | '\ua75f' // Latin_Extended-D - | '\ua761' // Latin_Extended-D - | '\ua763' // Latin_Extended-D - | '\ua765' // Latin_Extended-D - | '\ua767' // Latin_Extended-D - | '\ua769' // Latin_Extended-D - | '\ua76b' // Latin_Extended-D - | '\ua76d' // Latin_Extended-D - | '\ua76f' // Latin_Extended-D - | '\ua771'..'\ua778' // Latin_Extended-D - | '\ua77a' // Latin_Extended-D - | '\ua77c' // Latin_Extended-D - | '\ua77f' // Latin_Extended-D - | '\ua781' // Latin_Extended-D - | '\ua783' // Latin_Extended-D - | '\ua785' // Latin_Extended-D - | '\ua787' // Latin_Extended-D - | '\ua78c' // Latin_Extended-D - | '\ua78e' // Latin_Extended-D - | '\ua791' // Latin_Extended-D - | '\ua793'..'\ua795' // Latin_Extended-D - | '\ua797' // Latin_Extended-D - | '\ua799' // Latin_Extended-D - | '\ua79b' // Latin_Extended-D - | '\ua79d' // Latin_Extended-D - | '\ua79f' // Latin_Extended-D - | '\ua7a1' // Latin_Extended-D - | '\ua7a3' // Latin_Extended-D - | '\ua7a5' // Latin_Extended-D - | '\ua7a7' // Latin_Extended-D - | '\ua7a9' // Latin_Extended-D - | '\ua7b5' // Latin_Extended-D - | '\ua7b7' // Latin_Extended-D - | '\ua7fa' // Latin_Extended-D - | '\uab30'..'\uab5a' // Latin_Extended-E - | '\uab60'..'\uab65' // Latin_Extended-E - | '\uab70'..'\uabbf' // Cherokee_Supplement - | '\ufb00'..'\ufb06' // Alphabetic_Presentation_Forms - | '\ufb13'..'\ufb17' // Alphabetic_Presentation_Forms - | '\uff41'..'\uff5a' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Ll + : '\u0061' ..'\u007a' // Basic_Latin + | '\u00b5' // Latin-1_Supplement + | '\u00df' ..'\u00f6' // Latin-1_Supplement + | '\u00f8' ..'\u00ff' // Latin-1_Supplement + | '\u0101' // Latin_Extended-A + | '\u0103' // Latin_Extended-A + | '\u0105' // Latin_Extended-A + | '\u0107' // Latin_Extended-A + | '\u0109' // Latin_Extended-A + | '\u010b' // Latin_Extended-A + | '\u010d' // Latin_Extended-A + | '\u010f' // Latin_Extended-A + | '\u0111' // Latin_Extended-A + | '\u0113' // Latin_Extended-A + | '\u0115' // Latin_Extended-A + | '\u0117' // Latin_Extended-A + | '\u0119' // Latin_Extended-A + | '\u011b' // Latin_Extended-A + | '\u011d' // Latin_Extended-A + | '\u011f' // Latin_Extended-A + | '\u0121' // Latin_Extended-A + | '\u0123' // Latin_Extended-A + | '\u0125' // Latin_Extended-A + | '\u0127' // Latin_Extended-A + | '\u0129' // Latin_Extended-A + | '\u012b' // Latin_Extended-A + | '\u012d' // Latin_Extended-A + | '\u012f' // Latin_Extended-A + | '\u0131' // Latin_Extended-A + | '\u0133' // Latin_Extended-A + | '\u0135' // Latin_Extended-A + | '\u0137' ..'\u0138' // Latin_Extended-A + | '\u013a' // Latin_Extended-A + | '\u013c' // Latin_Extended-A + | '\u013e' // Latin_Extended-A + | '\u0140' // Latin_Extended-A + | '\u0142' // Latin_Extended-A + | '\u0144' // Latin_Extended-A + | '\u0146' // Latin_Extended-A + | '\u0148' ..'\u0149' // Latin_Extended-A + | '\u014b' // Latin_Extended-A + | '\u014d' // Latin_Extended-A + | '\u014f' // Latin_Extended-A + | '\u0151' // Latin_Extended-A + | '\u0153' // Latin_Extended-A + | '\u0155' // Latin_Extended-A + | '\u0157' // Latin_Extended-A + | '\u0159' // Latin_Extended-A + | '\u015b' // Latin_Extended-A + | '\u015d' // Latin_Extended-A + | '\u015f' // Latin_Extended-A + | '\u0161' // Latin_Extended-A + | '\u0163' // Latin_Extended-A + | '\u0165' // Latin_Extended-A + | '\u0167' // Latin_Extended-A + | '\u0169' // Latin_Extended-A + | '\u016b' // Latin_Extended-A + | '\u016d' // Latin_Extended-A + | '\u016f' // Latin_Extended-A + | '\u0171' // Latin_Extended-A + | '\u0173' // Latin_Extended-A + | '\u0175' // Latin_Extended-A + | '\u0177' // Latin_Extended-A + | '\u017a' // Latin_Extended-A + | '\u017c' // Latin_Extended-A + | '\u017e' ..'\u0180' // Latin_Extended-A + | '\u0183' // Latin_Extended-B + | '\u0185' // Latin_Extended-B + | '\u0188' // Latin_Extended-B + | '\u018c' ..'\u018d' // Latin_Extended-B + | '\u0192' // Latin_Extended-B + | '\u0195' // Latin_Extended-B + | '\u0199' ..'\u019b' // Latin_Extended-B + | '\u019e' // Latin_Extended-B + | '\u01a1' // Latin_Extended-B + | '\u01a3' // Latin_Extended-B + | '\u01a5' // Latin_Extended-B + | '\u01a8' // Latin_Extended-B + | '\u01aa' ..'\u01ab' // Latin_Extended-B + | '\u01ad' // Latin_Extended-B + | '\u01b0' // Latin_Extended-B + | '\u01b4' // Latin_Extended-B + | '\u01b6' // Latin_Extended-B + | '\u01b9' ..'\u01ba' // Latin_Extended-B + | '\u01bd' ..'\u01bf' // Latin_Extended-B + | '\u01c6' // Latin_Extended-B + | '\u01c9' // Latin_Extended-B + | '\u01cc' // Latin_Extended-B + | '\u01ce' // Latin_Extended-B + | '\u01d0' // Latin_Extended-B + | '\u01d2' // Latin_Extended-B + | '\u01d4' // Latin_Extended-B + | '\u01d6' // Latin_Extended-B + | '\u01d8' // Latin_Extended-B + | '\u01da' // Latin_Extended-B + | '\u01dc' ..'\u01dd' // Latin_Extended-B + | '\u01df' // Latin_Extended-B + | '\u01e1' // Latin_Extended-B + | '\u01e3' // Latin_Extended-B + | '\u01e5' // Latin_Extended-B + | '\u01e7' // Latin_Extended-B + | '\u01e9' // Latin_Extended-B + | '\u01eb' // Latin_Extended-B + | '\u01ed' // Latin_Extended-B + | '\u01ef' ..'\u01f0' // Latin_Extended-B + | '\u01f3' // Latin_Extended-B + | '\u01f5' // Latin_Extended-B + | '\u01f9' // Latin_Extended-B + | '\u01fb' // Latin_Extended-B + | '\u01fd' // Latin_Extended-B + | '\u01ff' // Latin_Extended-B + | '\u0201' // Latin_Extended-B + | '\u0203' // Latin_Extended-B + | '\u0205' // Latin_Extended-B + | '\u0207' // Latin_Extended-B + | '\u0209' // Latin_Extended-B + | '\u020b' // Latin_Extended-B + | '\u020d' // Latin_Extended-B + | '\u020f' // Latin_Extended-B + | '\u0211' // Latin_Extended-B + | '\u0213' // Latin_Extended-B + | '\u0215' // Latin_Extended-B + | '\u0217' // Latin_Extended-B + | '\u0219' // Latin_Extended-B + | '\u021b' // Latin_Extended-B + | '\u021d' // Latin_Extended-B + | '\u021f' // Latin_Extended-B + | '\u0221' // Latin_Extended-B + | '\u0223' // Latin_Extended-B + | '\u0225' // Latin_Extended-B + | '\u0227' // Latin_Extended-B + | '\u0229' // Latin_Extended-B + | '\u022b' // Latin_Extended-B + | '\u022d' // Latin_Extended-B + | '\u022f' // Latin_Extended-B + | '\u0231' // Latin_Extended-B + | '\u0233' ..'\u0239' // Latin_Extended-B + | '\u023c' // Latin_Extended-B + | '\u023f' ..'\u0240' // Latin_Extended-B + | '\u0242' // Latin_Extended-B + | '\u0247' // Latin_Extended-B + | '\u0249' // Latin_Extended-B + | '\u024b' // Latin_Extended-B + | '\u024d' // Latin_Extended-B + | '\u024f' ..'\u0293' // (Absent from Blocks.txt) + | '\u0295' ..'\u02af' // IPA_Extensions + | '\u0371' // Greek_and_Coptic + | '\u0373' // Greek_and_Coptic + | '\u0377' // Greek_and_Coptic + | '\u037b' ..'\u037d' // Greek_and_Coptic + | '\u0390' // Greek_and_Coptic + | '\u03ac' ..'\u03ce' // Greek_and_Coptic + | '\u03d0' ..'\u03d1' // Greek_and_Coptic + | '\u03d5' ..'\u03d7' // Greek_and_Coptic + | '\u03d9' // Greek_and_Coptic + | '\u03db' // Greek_and_Coptic + | '\u03dd' // Greek_and_Coptic + | '\u03df' // Greek_and_Coptic + | '\u03e1' // Greek_and_Coptic + | '\u03e3' // Greek_and_Coptic + | '\u03e5' // Greek_and_Coptic + | '\u03e7' // Greek_and_Coptic + | '\u03e9' // Greek_and_Coptic + | '\u03eb' // Greek_and_Coptic + | '\u03ed' // Greek_and_Coptic + | '\u03ef' ..'\u03f3' // Greek_and_Coptic + | '\u03f5' // Greek_and_Coptic + | '\u03f8' // Greek_and_Coptic + | '\u03fb' ..'\u03fc' // Greek_and_Coptic + | '\u0430' ..'\u045f' // Cyrillic + | '\u0461' // Cyrillic + | '\u0463' // Cyrillic + | '\u0465' // Cyrillic + | '\u0467' // Cyrillic + | '\u0469' // Cyrillic + | '\u046b' // Cyrillic + | '\u046d' // Cyrillic + | '\u046f' // Cyrillic + | '\u0471' // Cyrillic + | '\u0473' // Cyrillic + | '\u0475' // Cyrillic + | '\u0477' // Cyrillic + | '\u0479' // Cyrillic + | '\u047b' // Cyrillic + | '\u047d' // Cyrillic + | '\u047f' // Cyrillic + | '\u0481' // Cyrillic + | '\u048b' // Cyrillic + | '\u048d' // Cyrillic + | '\u048f' // Cyrillic + | '\u0491' // Cyrillic + | '\u0493' // Cyrillic + | '\u0495' // Cyrillic + | '\u0497' // Cyrillic + | '\u0499' // Cyrillic + | '\u049b' // Cyrillic + | '\u049d' // Cyrillic + | '\u049f' // Cyrillic + | '\u04a1' // Cyrillic + | '\u04a3' // Cyrillic + | '\u04a5' // Cyrillic + | '\u04a7' // Cyrillic + | '\u04a9' // Cyrillic + | '\u04ab' // Cyrillic + | '\u04ad' // Cyrillic + | '\u04af' // Cyrillic + | '\u04b1' // Cyrillic + | '\u04b3' // Cyrillic + | '\u04b5' // Cyrillic + | '\u04b7' // Cyrillic + | '\u04b9' // Cyrillic + | '\u04bb' // Cyrillic + | '\u04bd' // Cyrillic + | '\u04bf' // Cyrillic + | '\u04c2' // Cyrillic + | '\u04c4' // Cyrillic + | '\u04c6' // Cyrillic + | '\u04c8' // Cyrillic + | '\u04ca' // Cyrillic + | '\u04cc' // Cyrillic + | '\u04ce' ..'\u04cf' // Cyrillic + | '\u04d1' // Cyrillic + | '\u04d3' // Cyrillic + | '\u04d5' // Cyrillic + | '\u04d7' // Cyrillic + | '\u04d9' // Cyrillic + | '\u04db' // Cyrillic + | '\u04dd' // Cyrillic + | '\u04df' // Cyrillic + | '\u04e1' // Cyrillic + | '\u04e3' // Cyrillic + | '\u04e5' // Cyrillic + | '\u04e7' // Cyrillic + | '\u04e9' // Cyrillic + | '\u04eb' // Cyrillic + | '\u04ed' // Cyrillic + | '\u04ef' // Cyrillic + | '\u04f1' // Cyrillic + | '\u04f3' // Cyrillic + | '\u04f5' // Cyrillic + | '\u04f7' // Cyrillic + | '\u04f9' // Cyrillic + | '\u04fb' // Cyrillic + | '\u04fd' // Cyrillic + | '\u04ff' // (Absent from Blocks.txt) + | '\u0501' // Cyrillic_Supplement + | '\u0503' // Cyrillic_Supplement + | '\u0505' // Cyrillic_Supplement + | '\u0507' // Cyrillic_Supplement + | '\u0509' // Cyrillic_Supplement + | '\u050b' // Cyrillic_Supplement + | '\u050d' // Cyrillic_Supplement + | '\u050f' // Cyrillic_Supplement + | '\u0511' // Cyrillic_Supplement + | '\u0513' // Cyrillic_Supplement + | '\u0515' // Cyrillic_Supplement + | '\u0517' // Cyrillic_Supplement + | '\u0519' // Cyrillic_Supplement + | '\u051b' // Cyrillic_Supplement + | '\u051d' // Cyrillic_Supplement + | '\u051f' // Cyrillic_Supplement + | '\u0521' // Cyrillic_Supplement + | '\u0523' // Cyrillic_Supplement + | '\u0525' // Cyrillic_Supplement + | '\u0527' // Cyrillic_Supplement + | '\u0529' // Cyrillic_Supplement + | '\u052b' // Cyrillic_Supplement + | '\u052d' // Cyrillic_Supplement + | '\u052f' // (Absent from Blocks.txt) + | '\u0561' ..'\u0587' // Armenian + | '\u13f8' ..'\u13fd' // Cherokee + | '\u1c80' ..'\u1c88' // Cyrillic_Extended-C + | '\u1d00' ..'\u1d2b' // Phonetic_Extensions + | '\u1d6b' ..'\u1d77' // Phonetic_Extensions + | '\u1d79' ..'\u1d9a' // Phonetic_Extensions + | '\u1e01' // Latin_Extended_Additional + | '\u1e03' // Latin_Extended_Additional + | '\u1e05' // Latin_Extended_Additional + | '\u1e07' // Latin_Extended_Additional + | '\u1e09' // Latin_Extended_Additional + | '\u1e0b' // Latin_Extended_Additional + | '\u1e0d' // Latin_Extended_Additional + | '\u1e0f' // Latin_Extended_Additional + | '\u1e11' // Latin_Extended_Additional + | '\u1e13' // Latin_Extended_Additional + | '\u1e15' // Latin_Extended_Additional + | '\u1e17' // Latin_Extended_Additional + | '\u1e19' // Latin_Extended_Additional + | '\u1e1b' // Latin_Extended_Additional + | '\u1e1d' // Latin_Extended_Additional + | '\u1e1f' // Latin_Extended_Additional + | '\u1e21' // Latin_Extended_Additional + | '\u1e23' // Latin_Extended_Additional + | '\u1e25' // Latin_Extended_Additional + | '\u1e27' // Latin_Extended_Additional + | '\u1e29' // Latin_Extended_Additional + | '\u1e2b' // Latin_Extended_Additional + | '\u1e2d' // Latin_Extended_Additional + | '\u1e2f' // Latin_Extended_Additional + | '\u1e31' // Latin_Extended_Additional + | '\u1e33' // Latin_Extended_Additional + | '\u1e35' // Latin_Extended_Additional + | '\u1e37' // Latin_Extended_Additional + | '\u1e39' // Latin_Extended_Additional + | '\u1e3b' // Latin_Extended_Additional + | '\u1e3d' // Latin_Extended_Additional + | '\u1e3f' // Latin_Extended_Additional + | '\u1e41' // Latin_Extended_Additional + | '\u1e43' // Latin_Extended_Additional + | '\u1e45' // Latin_Extended_Additional + | '\u1e47' // Latin_Extended_Additional + | '\u1e49' // Latin_Extended_Additional + | '\u1e4b' // Latin_Extended_Additional + | '\u1e4d' // Latin_Extended_Additional + | '\u1e4f' // Latin_Extended_Additional + | '\u1e51' // Latin_Extended_Additional + | '\u1e53' // Latin_Extended_Additional + | '\u1e55' // Latin_Extended_Additional + | '\u1e57' // Latin_Extended_Additional + | '\u1e59' // Latin_Extended_Additional + | '\u1e5b' // Latin_Extended_Additional + | '\u1e5d' // Latin_Extended_Additional + | '\u1e5f' // Latin_Extended_Additional + | '\u1e61' // Latin_Extended_Additional + | '\u1e63' // Latin_Extended_Additional + | '\u1e65' // Latin_Extended_Additional + | '\u1e67' // Latin_Extended_Additional + | '\u1e69' // Latin_Extended_Additional + | '\u1e6b' // Latin_Extended_Additional + | '\u1e6d' // Latin_Extended_Additional + | '\u1e6f' // Latin_Extended_Additional + | '\u1e71' // Latin_Extended_Additional + | '\u1e73' // Latin_Extended_Additional + | '\u1e75' // Latin_Extended_Additional + | '\u1e77' // Latin_Extended_Additional + | '\u1e79' // Latin_Extended_Additional + | '\u1e7b' // Latin_Extended_Additional + | '\u1e7d' // Latin_Extended_Additional + | '\u1e7f' // Latin_Extended_Additional + | '\u1e81' // Latin_Extended_Additional + | '\u1e83' // Latin_Extended_Additional + | '\u1e85' // Latin_Extended_Additional + | '\u1e87' // Latin_Extended_Additional + | '\u1e89' // Latin_Extended_Additional + | '\u1e8b' // Latin_Extended_Additional + | '\u1e8d' // Latin_Extended_Additional + | '\u1e8f' // Latin_Extended_Additional + | '\u1e91' // Latin_Extended_Additional + | '\u1e93' // Latin_Extended_Additional + | '\u1e95' ..'\u1e9d' // Latin_Extended_Additional + | '\u1e9f' // Latin_Extended_Additional + | '\u1ea1' // Latin_Extended_Additional + | '\u1ea3' // Latin_Extended_Additional + | '\u1ea5' // Latin_Extended_Additional + | '\u1ea7' // Latin_Extended_Additional + | '\u1ea9' // Latin_Extended_Additional + | '\u1eab' // Latin_Extended_Additional + | '\u1ead' // Latin_Extended_Additional + | '\u1eaf' // Latin_Extended_Additional + | '\u1eb1' // Latin_Extended_Additional + | '\u1eb3' // Latin_Extended_Additional + | '\u1eb5' // Latin_Extended_Additional + | '\u1eb7' // Latin_Extended_Additional + | '\u1eb9' // Latin_Extended_Additional + | '\u1ebb' // Latin_Extended_Additional + | '\u1ebd' // Latin_Extended_Additional + | '\u1ebf' // Latin_Extended_Additional + | '\u1ec1' // Latin_Extended_Additional + | '\u1ec3' // Latin_Extended_Additional + | '\u1ec5' // Latin_Extended_Additional + | '\u1ec7' // Latin_Extended_Additional + | '\u1ec9' // Latin_Extended_Additional + | '\u1ecb' // Latin_Extended_Additional + | '\u1ecd' // Latin_Extended_Additional + | '\u1ecf' // Latin_Extended_Additional + | '\u1ed1' // Latin_Extended_Additional + | '\u1ed3' // Latin_Extended_Additional + | '\u1ed5' // Latin_Extended_Additional + | '\u1ed7' // Latin_Extended_Additional + | '\u1ed9' // Latin_Extended_Additional + | '\u1edb' // Latin_Extended_Additional + | '\u1edd' // Latin_Extended_Additional + | '\u1edf' // Latin_Extended_Additional + | '\u1ee1' // Latin_Extended_Additional + | '\u1ee3' // Latin_Extended_Additional + | '\u1ee5' // Latin_Extended_Additional + | '\u1ee7' // Latin_Extended_Additional + | '\u1ee9' // Latin_Extended_Additional + | '\u1eeb' // Latin_Extended_Additional + | '\u1eed' // Latin_Extended_Additional + | '\u1eef' // Latin_Extended_Additional + | '\u1ef1' // Latin_Extended_Additional + | '\u1ef3' // Latin_Extended_Additional + | '\u1ef5' // Latin_Extended_Additional + | '\u1ef7' // Latin_Extended_Additional + | '\u1ef9' // Latin_Extended_Additional + | '\u1efb' // Latin_Extended_Additional + | '\u1efd' // Latin_Extended_Additional + | '\u1eff' ..'\u1f07' // (Absent from Blocks.txt) + | '\u1f10' ..'\u1f15' // Greek_Extended + | '\u1f20' ..'\u1f27' // Greek_Extended + | '\u1f30' ..'\u1f37' // Greek_Extended + | '\u1f40' ..'\u1f45' // Greek_Extended + | '\u1f50' ..'\u1f57' // Greek_Extended + | '\u1f60' ..'\u1f67' // Greek_Extended + | '\u1f70' ..'\u1f7d' // Greek_Extended + | '\u1f80' ..'\u1f87' // Greek_Extended + | '\u1f90' ..'\u1f97' // Greek_Extended + | '\u1fa0' ..'\u1fa7' // Greek_Extended + | '\u1fb0' ..'\u1fb4' // Greek_Extended + | '\u1fb6' ..'\u1fb7' // Greek_Extended + | '\u1fbe' // Greek_Extended + | '\u1fc2' ..'\u1fc4' // Greek_Extended + | '\u1fc6' ..'\u1fc7' // Greek_Extended + | '\u1fd0' ..'\u1fd3' // Greek_Extended + | '\u1fd6' ..'\u1fd7' // Greek_Extended + | '\u1fe0' ..'\u1fe7' // Greek_Extended + | '\u1ff2' ..'\u1ff4' // Greek_Extended + | '\u1ff6' ..'\u1ff7' // Greek_Extended + | '\u210a' // Letterlike_Symbols + | '\u210e' ..'\u210f' // Letterlike_Symbols + | '\u2113' // Letterlike_Symbols + | '\u212f' // Letterlike_Symbols + | '\u2134' // Letterlike_Symbols + | '\u2139' // Letterlike_Symbols + | '\u213c' ..'\u213d' // Letterlike_Symbols + | '\u2146' ..'\u2149' // Letterlike_Symbols + | '\u214e' // Letterlike_Symbols + | '\u2184' // Number_Forms + | '\u2c30' ..'\u2c5e' // Glagolitic + | '\u2c61' // Latin_Extended-C + | '\u2c65' ..'\u2c66' // Latin_Extended-C + | '\u2c68' // Latin_Extended-C + | '\u2c6a' // Latin_Extended-C + | '\u2c6c' // Latin_Extended-C + | '\u2c71' // Latin_Extended-C + | '\u2c73' ..'\u2c74' // Latin_Extended-C + | '\u2c76' ..'\u2c7b' // Latin_Extended-C + | '\u2c81' // Coptic + | '\u2c83' // Coptic + | '\u2c85' // Coptic + | '\u2c87' // Coptic + | '\u2c89' // Coptic + | '\u2c8b' // Coptic + | '\u2c8d' // Coptic + | '\u2c8f' // Coptic + | '\u2c91' // Coptic + | '\u2c93' // Coptic + | '\u2c95' // Coptic + | '\u2c97' // Coptic + | '\u2c99' // Coptic + | '\u2c9b' // Coptic + | '\u2c9d' // Coptic + | '\u2c9f' // Coptic + | '\u2ca1' // Coptic + | '\u2ca3' // Coptic + | '\u2ca5' // Coptic + | '\u2ca7' // Coptic + | '\u2ca9' // Coptic + | '\u2cab' // Coptic + | '\u2cad' // Coptic + | '\u2caf' // Coptic + | '\u2cb1' // Coptic + | '\u2cb3' // Coptic + | '\u2cb5' // Coptic + | '\u2cb7' // Coptic + | '\u2cb9' // Coptic + | '\u2cbb' // Coptic + | '\u2cbd' // Coptic + | '\u2cbf' // Coptic + | '\u2cc1' // Coptic + | '\u2cc3' // Coptic + | '\u2cc5' // Coptic + | '\u2cc7' // Coptic + | '\u2cc9' // Coptic + | '\u2ccb' // Coptic + | '\u2ccd' // Coptic + | '\u2ccf' // Coptic + | '\u2cd1' // Coptic + | '\u2cd3' // Coptic + | '\u2cd5' // Coptic + | '\u2cd7' // Coptic + | '\u2cd9' // Coptic + | '\u2cdb' // Coptic + | '\u2cdd' // Coptic + | '\u2cdf' // Coptic + | '\u2ce1' // Coptic + | '\u2ce3' ..'\u2ce4' // Coptic + | '\u2cec' // Coptic + | '\u2cee' // Coptic + | '\u2cf3' // Coptic + | '\u2d00' ..'\u2d25' // Georgian_Supplement + | '\u2d27' // Georgian_Supplement + | '\u2d2d' // Georgian_Supplement + | '\ua641' // Cyrillic_Extended-B + | '\ua643' // Cyrillic_Extended-B + | '\ua645' // Cyrillic_Extended-B + | '\ua647' // Cyrillic_Extended-B + | '\ua649' // Cyrillic_Extended-B + | '\ua64b' // Cyrillic_Extended-B + | '\ua64d' // Cyrillic_Extended-B + | '\ua64f' // Cyrillic_Extended-B + | '\ua651' // Cyrillic_Extended-B + | '\ua653' // Cyrillic_Extended-B + | '\ua655' // Cyrillic_Extended-B + | '\ua657' // Cyrillic_Extended-B + | '\ua659' // Cyrillic_Extended-B + | '\ua65b' // Cyrillic_Extended-B + | '\ua65d' // Cyrillic_Extended-B + | '\ua65f' // Cyrillic_Extended-B + | '\ua661' // Cyrillic_Extended-B + | '\ua663' // Cyrillic_Extended-B + | '\ua665' // Cyrillic_Extended-B + | '\ua667' // Cyrillic_Extended-B + | '\ua669' // Cyrillic_Extended-B + | '\ua66b' // Cyrillic_Extended-B + | '\ua66d' // Cyrillic_Extended-B + | '\ua681' // Cyrillic_Extended-B + | '\ua683' // Cyrillic_Extended-B + | '\ua685' // Cyrillic_Extended-B + | '\ua687' // Cyrillic_Extended-B + | '\ua689' // Cyrillic_Extended-B + | '\ua68b' // Cyrillic_Extended-B + | '\ua68d' // Cyrillic_Extended-B + | '\ua68f' // Cyrillic_Extended-B + | '\ua691' // Cyrillic_Extended-B + | '\ua693' // Cyrillic_Extended-B + | '\ua695' // Cyrillic_Extended-B + | '\ua697' // Cyrillic_Extended-B + | '\ua699' // Cyrillic_Extended-B + | '\ua69b' // Cyrillic_Extended-B + | '\ua723' // Latin_Extended-D + | '\ua725' // Latin_Extended-D + | '\ua727' // Latin_Extended-D + | '\ua729' // Latin_Extended-D + | '\ua72b' // Latin_Extended-D + | '\ua72d' // Latin_Extended-D + | '\ua72f' ..'\ua731' // Latin_Extended-D + | '\ua733' // Latin_Extended-D + | '\ua735' // Latin_Extended-D + | '\ua737' // Latin_Extended-D + | '\ua739' // Latin_Extended-D + | '\ua73b' // Latin_Extended-D + | '\ua73d' // Latin_Extended-D + | '\ua73f' // Latin_Extended-D + | '\ua741' // Latin_Extended-D + | '\ua743' // Latin_Extended-D + | '\ua745' // Latin_Extended-D + | '\ua747' // Latin_Extended-D + | '\ua749' // Latin_Extended-D + | '\ua74b' // Latin_Extended-D + | '\ua74d' // Latin_Extended-D + | '\ua74f' // Latin_Extended-D + | '\ua751' // Latin_Extended-D + | '\ua753' // Latin_Extended-D + | '\ua755' // Latin_Extended-D + | '\ua757' // Latin_Extended-D + | '\ua759' // Latin_Extended-D + | '\ua75b' // Latin_Extended-D + | '\ua75d' // Latin_Extended-D + | '\ua75f' // Latin_Extended-D + | '\ua761' // Latin_Extended-D + | '\ua763' // Latin_Extended-D + | '\ua765' // Latin_Extended-D + | '\ua767' // Latin_Extended-D + | '\ua769' // Latin_Extended-D + | '\ua76b' // Latin_Extended-D + | '\ua76d' // Latin_Extended-D + | '\ua76f' // Latin_Extended-D + | '\ua771' ..'\ua778' // Latin_Extended-D + | '\ua77a' // Latin_Extended-D + | '\ua77c' // Latin_Extended-D + | '\ua77f' // Latin_Extended-D + | '\ua781' // Latin_Extended-D + | '\ua783' // Latin_Extended-D + | '\ua785' // Latin_Extended-D + | '\ua787' // Latin_Extended-D + | '\ua78c' // Latin_Extended-D + | '\ua78e' // Latin_Extended-D + | '\ua791' // Latin_Extended-D + | '\ua793' ..'\ua795' // Latin_Extended-D + | '\ua797' // Latin_Extended-D + | '\ua799' // Latin_Extended-D + | '\ua79b' // Latin_Extended-D + | '\ua79d' // Latin_Extended-D + | '\ua79f' // Latin_Extended-D + | '\ua7a1' // Latin_Extended-D + | '\ua7a3' // Latin_Extended-D + | '\ua7a5' // Latin_Extended-D + | '\ua7a7' // Latin_Extended-D + | '\ua7a9' // Latin_Extended-D + | '\ua7b5' // Latin_Extended-D + | '\ua7b7' // Latin_Extended-D + | '\ua7fa' // Latin_Extended-D + | '\uab30' ..'\uab5a' // Latin_Extended-E + | '\uab60' ..'\uab65' // Latin_Extended-E + | '\uab70' ..'\uabbf' // Cherokee_Supplement + | '\ufb00' ..'\ufb06' // Alphabetic_Presentation_Forms + | '\ufb13' ..'\ufb17' // Alphabetic_Presentation_Forms + | '\uff41' ..'\uff5a' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Lm: - '\u02b0'..'\u02c1' // Spacing_Modifier_Letters - | '\u02c6'..'\u02d1' // Spacing_Modifier_Letters - | '\u02e0'..'\u02e4' // Spacing_Modifier_Letters - | '\u02ec' // Spacing_Modifier_Letters - | '\u02ee' // Spacing_Modifier_Letters - | '\u0374' // Greek_and_Coptic - | '\u037a' // Greek_and_Coptic - | '\u0559' // Armenian - | '\u0640' // Arabic - | '\u06e5'..'\u06e6' // Arabic - | '\u07f4'..'\u07f5' // NKo - | '\u07fa' // NKo - | '\u081a' // Samaritan - | '\u0824' // Samaritan - | '\u0828' // Samaritan - | '\u0971' // Devanagari - | '\u0e46' // Thai - | '\u0ec6' // Lao - | '\u10fc' // Georgian - | '\u17d7' // Khmer - | '\u1843' // Mongolian - | '\u1aa7' // Tai_Tham - | '\u1c78'..'\u1c7d' // Ol_Chiki - | '\u1d2c'..'\u1d6a' // Phonetic_Extensions - | '\u1d78' // Phonetic_Extensions - | '\u1d9b'..'\u1dbf' // Phonetic_Extensions_Supplement - | '\u2071' // Superscripts_and_Subscripts - | '\u207f' // Superscripts_and_Subscripts - | '\u2090'..'\u209c' // Superscripts_and_Subscripts - | '\u2c7c'..'\u2c7d' // Latin_Extended-C - | '\u2d6f' // Tifinagh - | '\u2e2f' // Supplemental_Punctuation - | '\u3005' // CJK_Symbols_and_Punctuation - | '\u3031'..'\u3035' // CJK_Symbols_and_Punctuation - | '\u303b' // CJK_Symbols_and_Punctuation - | '\u309d'..'\u309e' // Hiragana - | '\u30fc'..'\u30fe' // Katakana - | '\ua015' // Yi_Syllables - | '\ua4f8'..'\ua4fd' // Lisu - | '\ua60c' // Vai - | '\ua67f' // Cyrillic_Extended-B - | '\ua69c'..'\ua69d' // Cyrillic_Extended-B - | '\ua717'..'\ua71f' // Modifier_Tone_Letters - | '\ua770' // Latin_Extended-D - | '\ua788' // Latin_Extended-D - | '\ua7f8'..'\ua7f9' // Latin_Extended-D - | '\ua9cf' // Javanese - | '\ua9e6' // Myanmar_Extended-B - | '\uaa70' // Myanmar_Extended-A - | '\uaadd' // Tai_Viet - | '\uaaf3'..'\uaaf4' // Meetei_Mayek_Extensions - | '\uab5c'..'\uab5f' // Latin_Extended-E - | '\uff70' // Halfwidth_and_Fullwidth_Forms - | '\uff9e'..'\uff9f' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Lm + : '\u02b0' ..'\u02c1' // Spacing_Modifier_Letters + | '\u02c6' ..'\u02d1' // Spacing_Modifier_Letters + | '\u02e0' ..'\u02e4' // Spacing_Modifier_Letters + | '\u02ec' // Spacing_Modifier_Letters + | '\u02ee' // Spacing_Modifier_Letters + | '\u0374' // Greek_and_Coptic + | '\u037a' // Greek_and_Coptic + | '\u0559' // Armenian + | '\u0640' // Arabic + | '\u06e5' ..'\u06e6' // Arabic + | '\u07f4' ..'\u07f5' // NKo + | '\u07fa' // NKo + | '\u081a' // Samaritan + | '\u0824' // Samaritan + | '\u0828' // Samaritan + | '\u0971' // Devanagari + | '\u0e46' // Thai + | '\u0ec6' // Lao + | '\u10fc' // Georgian + | '\u17d7' // Khmer + | '\u1843' // Mongolian + | '\u1aa7' // Tai_Tham + | '\u1c78' ..'\u1c7d' // Ol_Chiki + | '\u1d2c' ..'\u1d6a' // Phonetic_Extensions + | '\u1d78' // Phonetic_Extensions + | '\u1d9b' ..'\u1dbf' // Phonetic_Extensions_Supplement + | '\u2071' // Superscripts_and_Subscripts + | '\u207f' // Superscripts_and_Subscripts + | '\u2090' ..'\u209c' // Superscripts_and_Subscripts + | '\u2c7c' ..'\u2c7d' // Latin_Extended-C + | '\u2d6f' // Tifinagh + | '\u2e2f' // Supplemental_Punctuation + | '\u3005' // CJK_Symbols_and_Punctuation + | '\u3031' ..'\u3035' // CJK_Symbols_and_Punctuation + | '\u303b' // CJK_Symbols_and_Punctuation + | '\u309d' ..'\u309e' // Hiragana + | '\u30fc' ..'\u30fe' // Katakana + | '\ua015' // Yi_Syllables + | '\ua4f8' ..'\ua4fd' // Lisu + | '\ua60c' // Vai + | '\ua67f' // Cyrillic_Extended-B + | '\ua69c' ..'\ua69d' // Cyrillic_Extended-B + | '\ua717' ..'\ua71f' // Modifier_Tone_Letters + | '\ua770' // Latin_Extended-D + | '\ua788' // Latin_Extended-D + | '\ua7f8' ..'\ua7f9' // Latin_Extended-D + | '\ua9cf' // Javanese + | '\ua9e6' // Myanmar_Extended-B + | '\uaa70' // Myanmar_Extended-A + | '\uaadd' // Tai_Viet + | '\uaaf3' ..'\uaaf4' // Meetei_Mayek_Extensions + | '\uab5c' ..'\uab5f' // Latin_Extended-E + | '\uff70' // Halfwidth_and_Fullwidth_Forms + | '\uff9e' ..'\uff9f' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Lo: - '\u00aa' // Latin-1_Supplement - | '\u00ba' // Latin-1_Supplement - | '\u01bb' // Latin_Extended-B - | '\u01c0'..'\u01c3' // Latin_Extended-B - | '\u0294' // IPA_Extensions - | '\u05d0'..'\u05ea' // Hebrew - | '\u05f0'..'\u05f2' // Hebrew - | '\u0620'..'\u063f' // Arabic - | '\u0641'..'\u064a' // Arabic - | '\u066e'..'\u066f' // Arabic - | '\u0671'..'\u06d3' // Arabic - | '\u06d5' // Arabic - | '\u06ee'..'\u06ef' // Arabic - | '\u06fa'..'\u06fc' // Arabic - | '\u06ff' // (Absent from Blocks.txt) - | '\u0710' // Syriac - | '\u0712'..'\u072f' // Syriac - | '\u074d'..'\u07a5' // Syriac - | '\u07b1' // Thaana - | '\u07ca'..'\u07ea' // NKo - | '\u0800'..'\u0815' // Samaritan - | '\u0840'..'\u0858' // Mandaic - | '\u08a0'..'\u08b4' // Arabic_Extended-A - | '\u08b6'..'\u08bd' // Arabic_Extended-A - | '\u0904'..'\u0939' // Devanagari - | '\u093d' // Devanagari - | '\u0950' // Devanagari - | '\u0958'..'\u0961' // Devanagari - | '\u0972'..'\u0980' // Devanagari - | '\u0985'..'\u098c' // Bengali - | '\u098f'..'\u0990' // Bengali - | '\u0993'..'\u09a8' // Bengali - | '\u09aa'..'\u09b0' // Bengali - | '\u09b2' // Bengali - | '\u09b6'..'\u09b9' // Bengali - | '\u09bd' // Bengali - | '\u09ce' // Bengali - | '\u09dc'..'\u09dd' // Bengali - | '\u09df'..'\u09e1' // Bengali - | '\u09f0'..'\u09f1' // Bengali - | '\u0a05'..'\u0a0a' // Gurmukhi - | '\u0a0f'..'\u0a10' // Gurmukhi - | '\u0a13'..'\u0a28' // Gurmukhi - | '\u0a2a'..'\u0a30' // Gurmukhi - | '\u0a32'..'\u0a33' // Gurmukhi - | '\u0a35'..'\u0a36' // Gurmukhi - | '\u0a38'..'\u0a39' // Gurmukhi - | '\u0a59'..'\u0a5c' // Gurmukhi - | '\u0a5e' // Gurmukhi - | '\u0a72'..'\u0a74' // Gurmukhi - | '\u0a85'..'\u0a8d' // Gujarati - | '\u0a8f'..'\u0a91' // Gujarati - | '\u0a93'..'\u0aa8' // Gujarati - | '\u0aaa'..'\u0ab0' // Gujarati - | '\u0ab2'..'\u0ab3' // Gujarati - | '\u0ab5'..'\u0ab9' // Gujarati - | '\u0abd' // Gujarati - | '\u0ad0' // Gujarati - | '\u0ae0'..'\u0ae1' // Gujarati - | '\u0af9' // Gujarati - | '\u0b05'..'\u0b0c' // Oriya - | '\u0b0f'..'\u0b10' // Oriya - | '\u0b13'..'\u0b28' // Oriya - | '\u0b2a'..'\u0b30' // Oriya - | '\u0b32'..'\u0b33' // Oriya - | '\u0b35'..'\u0b39' // Oriya - | '\u0b3d' // Oriya - | '\u0b5c'..'\u0b5d' // Oriya - | '\u0b5f'..'\u0b61' // Oriya - | '\u0b71' // Oriya - | '\u0b83' // Tamil - | '\u0b85'..'\u0b8a' // Tamil - | '\u0b8e'..'\u0b90' // Tamil - | '\u0b92'..'\u0b95' // Tamil - | '\u0b99'..'\u0b9a' // Tamil - | '\u0b9c' // Tamil - | '\u0b9e'..'\u0b9f' // Tamil - | '\u0ba3'..'\u0ba4' // Tamil - | '\u0ba8'..'\u0baa' // Tamil - | '\u0bae'..'\u0bb9' // Tamil - | '\u0bd0' // Tamil - | '\u0c05'..'\u0c0c' // Telugu - | '\u0c0e'..'\u0c10' // Telugu - | '\u0c12'..'\u0c28' // Telugu - | '\u0c2a'..'\u0c39' // Telugu - | '\u0c3d' // Telugu - | '\u0c58'..'\u0c5a' // Telugu - | '\u0c60'..'\u0c61' // Telugu - | '\u0c80' // Kannada - | '\u0c85'..'\u0c8c' // Kannada - | '\u0c8e'..'\u0c90' // Kannada - | '\u0c92'..'\u0ca8' // Kannada - | '\u0caa'..'\u0cb3' // Kannada - | '\u0cb5'..'\u0cb9' // Kannada - | '\u0cbd' // Kannada - | '\u0cde' // Kannada - | '\u0ce0'..'\u0ce1' // Kannada - | '\u0cf1'..'\u0cf2' // Kannada - | '\u0d05'..'\u0d0c' // Malayalam - | '\u0d0e'..'\u0d10' // Malayalam - | '\u0d12'..'\u0d3a' // Malayalam - | '\u0d3d' // Malayalam - | '\u0d4e' // Malayalam - | '\u0d54'..'\u0d56' // Malayalam - | '\u0d5f'..'\u0d61' // Malayalam - | '\u0d7a'..'\u0d7f' // Malayalam - | '\u0d85'..'\u0d96' // Sinhala - | '\u0d9a'..'\u0db1' // Sinhala - | '\u0db3'..'\u0dbb' // Sinhala - | '\u0dbd' // Sinhala - | '\u0dc0'..'\u0dc6' // Sinhala - | '\u0e01'..'\u0e30' // Thai - | '\u0e32'..'\u0e33' // Thai - | '\u0e40'..'\u0e45' // Thai - | '\u0e81'..'\u0e82' // Lao - | '\u0e84' // Lao - | '\u0e87'..'\u0e88' // Lao - | '\u0e8a' // Lao - | '\u0e8d' // Lao - | '\u0e94'..'\u0e97' // Lao - | '\u0e99'..'\u0e9f' // Lao - | '\u0ea1'..'\u0ea3' // Lao - | '\u0ea5' // Lao - | '\u0ea7' // Lao - | '\u0eaa'..'\u0eab' // Lao - | '\u0ead'..'\u0eb0' // Lao - | '\u0eb2'..'\u0eb3' // Lao - | '\u0ebd' // Lao - | '\u0ec0'..'\u0ec4' // Lao - | '\u0edc'..'\u0edf' // Lao - | '\u0f00' // Tibetan - | '\u0f40'..'\u0f47' // Tibetan - | '\u0f49'..'\u0f6c' // Tibetan - | '\u0f88'..'\u0f8c' // Tibetan - | '\u1000'..'\u102a' // Myanmar - | '\u103f' // Myanmar - | '\u1050'..'\u1055' // Myanmar - | '\u105a'..'\u105d' // Myanmar - | '\u1061' // Myanmar - | '\u1065'..'\u1066' // Myanmar - | '\u106e'..'\u1070' // Myanmar - | '\u1075'..'\u1081' // Myanmar - | '\u108e' // Myanmar - | '\u10d0'..'\u10fa' // Georgian - | '\u10fd'..'\u1248' // Georgian - | '\u124a'..'\u124d' // Ethiopic - | '\u1250'..'\u1256' // Ethiopic - | '\u1258' // Ethiopic - | '\u125a'..'\u125d' // Ethiopic - | '\u1260'..'\u1288' // Ethiopic - | '\u128a'..'\u128d' // Ethiopic - | '\u1290'..'\u12b0' // Ethiopic - | '\u12b2'..'\u12b5' // Ethiopic - | '\u12b8'..'\u12be' // Ethiopic - | '\u12c0' // Ethiopic - | '\u12c2'..'\u12c5' // Ethiopic - | '\u12c8'..'\u12d6' // Ethiopic - | '\u12d8'..'\u1310' // Ethiopic - | '\u1312'..'\u1315' // Ethiopic - | '\u1318'..'\u135a' // Ethiopic - | '\u1380'..'\u138f' // Ethiopic_Supplement - | '\u1401'..'\u166c' // Unified_Canadian_Aboriginal_Syllabics - | '\u166f'..'\u167f' // Unified_Canadian_Aboriginal_Syllabics - | '\u1681'..'\u169a' // Ogham - | '\u16a0'..'\u16ea' // Runic - | '\u16f1'..'\u16f8' // Runic - | '\u1700'..'\u170c' // Tagalog - | '\u170e'..'\u1711' // Tagalog - | '\u1720'..'\u1731' // Hanunoo - | '\u1740'..'\u1751' // Buhid - | '\u1760'..'\u176c' // Tagbanwa - | '\u176e'..'\u1770' // Tagbanwa - | '\u1780'..'\u17b3' // Khmer - | '\u17dc' // Khmer - | '\u1820'..'\u1842' // Mongolian - | '\u1844'..'\u1877' // Mongolian - | '\u1880'..'\u1884' // Mongolian - | '\u1887'..'\u18a8' // Mongolian - | '\u18aa' // Mongolian - | '\u18b0'..'\u18f5' // Unified_Canadian_Aboriginal_Syllabics_Extended - | '\u1900'..'\u191e' // Limbu - | '\u1950'..'\u196d' // Tai_Le - | '\u1970'..'\u1974' // Tai_Le - | '\u1980'..'\u19ab' // New_Tai_Lue - | '\u19b0'..'\u19c9' // New_Tai_Lue - | '\u1a00'..'\u1a16' // Buginese - | '\u1a20'..'\u1a54' // Tai_Tham - | '\u1b05'..'\u1b33' // Balinese - | '\u1b45'..'\u1b4b' // Balinese - | '\u1b83'..'\u1ba0' // Sundanese - | '\u1bae'..'\u1baf' // Sundanese - | '\u1bba'..'\u1be5' // Sundanese - | '\u1c00'..'\u1c23' // Lepcha - | '\u1c4d'..'\u1c4f' // Lepcha - | '\u1c5a'..'\u1c77' // Ol_Chiki - | '\u1ce9'..'\u1cec' // Vedic_Extensions - | '\u1cee'..'\u1cf1' // Vedic_Extensions - | '\u1cf5'..'\u1cf6' // Vedic_Extensions - | '\u2135'..'\u2138' // Letterlike_Symbols - | '\u2d30'..'\u2d67' // Tifinagh - | '\u2d80'..'\u2d96' // Ethiopic_Extended - | '\u2da0'..'\u2da6' // Ethiopic_Extended - | '\u2da8'..'\u2dae' // Ethiopic_Extended - | '\u2db0'..'\u2db6' // Ethiopic_Extended - | '\u2db8'..'\u2dbe' // Ethiopic_Extended - | '\u2dc0'..'\u2dc6' // Ethiopic_Extended - | '\u2dc8'..'\u2dce' // Ethiopic_Extended - | '\u2dd0'..'\u2dd6' // Ethiopic_Extended - | '\u2dd8'..'\u2dde' // Ethiopic_Extended - | '\u3006' // CJK_Symbols_and_Punctuation - | '\u303c' // CJK_Symbols_and_Punctuation - | '\u3041'..'\u3096' // Hiragana - | '\u309f' // (Absent from Blocks.txt) - | '\u30a1'..'\u30fa' // Katakana - | '\u30ff' // (Absent from Blocks.txt) - | '\u3105'..'\u312d' // Bopomofo - | '\u3131'..'\u318e' // Hangul_Compatibility_Jamo - | '\u31a0'..'\u31ba' // Bopomofo_Extended - | '\u31f0'..'\u31ff' // Katakana_Phonetic_Extensions - | '\u3400'..'\u4db5' // CJK_Unified_Ideographs_Extension_A - | '\u4e00'..'\u9fd5' // CJK_Unified_Ideographs - | '\ua000'..'\ua014' // Yi_Syllables - | '\ua016'..'\ua48c' // Yi_Syllables - | '\ua4d0'..'\ua4f7' // Lisu - | '\ua500'..'\ua60b' // Vai - | '\ua610'..'\ua61f' // Vai - | '\ua62a'..'\ua62b' // Vai - | '\ua66e' // Cyrillic_Extended-B - | '\ua6a0'..'\ua6e5' // Bamum - | '\ua78f' // Latin_Extended-D - | '\ua7f7' // Latin_Extended-D - | '\ua7fb'..'\ua801' // Latin_Extended-D - | '\ua803'..'\ua805' // Syloti_Nagri - | '\ua807'..'\ua80a' // Syloti_Nagri - | '\ua80c'..'\ua822' // Syloti_Nagri - | '\ua840'..'\ua873' // Phags-pa - | '\ua882'..'\ua8b3' // Saurashtra - | '\ua8f2'..'\ua8f7' // Devanagari_Extended - | '\ua8fb' // Devanagari_Extended - | '\ua8fd' // Devanagari_Extended - | '\ua90a'..'\ua925' // Kayah_Li - | '\ua930'..'\ua946' // Rejang - | '\ua960'..'\ua97c' // Hangul_Jamo_Extended-A - | '\ua984'..'\ua9b2' // Javanese - | '\ua9e0'..'\ua9e4' // Myanmar_Extended-B - | '\ua9e7'..'\ua9ef' // Myanmar_Extended-B - | '\ua9fa'..'\ua9fe' // Myanmar_Extended-B - | '\uaa00'..'\uaa28' // Cham - | '\uaa40'..'\uaa42' // Cham - | '\uaa44'..'\uaa4b' // Cham - | '\uaa60'..'\uaa6f' // Myanmar_Extended-A - | '\uaa71'..'\uaa76' // Myanmar_Extended-A - | '\uaa7a' // Myanmar_Extended-A - | '\uaa7e'..'\uaaaf' // Myanmar_Extended-A - | '\uaab1' // Tai_Viet - | '\uaab5'..'\uaab6' // Tai_Viet - | '\uaab9'..'\uaabd' // Tai_Viet - | '\uaac0' // Tai_Viet - | '\uaac2' // Tai_Viet - | '\uaadb'..'\uaadc' // Tai_Viet - | '\uaae0'..'\uaaea' // Meetei_Mayek_Extensions - | '\uaaf2' // Meetei_Mayek_Extensions - | '\uab01'..'\uab06' // Ethiopic_Extended-A - | '\uab09'..'\uab0e' // Ethiopic_Extended-A - | '\uab11'..'\uab16' // Ethiopic_Extended-A - | '\uab20'..'\uab26' // Ethiopic_Extended-A - | '\uab28'..'\uab2e' // Ethiopic_Extended-A - | '\uabc0'..'\uabe2' // Meetei_Mayek - | '\uac00' // Hangul_Syllables - | '\ud7a3' // Hangul_Syllables - | '\ud7b0'..'\ud7c6' // Hangul_Jamo_Extended-B - | '\ud7cb'..'\ud7fb' // Hangul_Jamo_Extended-B - | '\uf900'..'\ufa6d' // CJK_Compatibility_Ideographs - | '\ufa70'..'\ufad9' // CJK_Compatibility_Ideographs - | '\ufb1d' // Alphabetic_Presentation_Forms - | '\ufb1f'..'\ufb28' // Alphabetic_Presentation_Forms - | '\ufb2a'..'\ufb36' // Alphabetic_Presentation_Forms - | '\ufb38'..'\ufb3c' // Alphabetic_Presentation_Forms - | '\ufb3e' // Alphabetic_Presentation_Forms - | '\ufb40'..'\ufb41' // Alphabetic_Presentation_Forms - | '\ufb43'..'\ufb44' // Alphabetic_Presentation_Forms - | '\ufb46'..'\ufbb1' // Alphabetic_Presentation_Forms - | '\ufbd3'..'\ufd3d' // Arabic_Presentation_Forms-A - | '\ufd50'..'\ufd8f' // Arabic_Presentation_Forms-A - | '\ufd92'..'\ufdc7' // Arabic_Presentation_Forms-A - | '\ufdf0'..'\ufdfb' // Arabic_Presentation_Forms-A - | '\ufe70'..'\ufe74' // Arabic_Presentation_Forms-B - | '\ufe76'..'\ufefc' // Arabic_Presentation_Forms-B - | '\uff66'..'\uff6f' // Halfwidth_and_Fullwidth_Forms - | '\uff71'..'\uff9d' // Halfwidth_and_Fullwidth_Forms - | '\uffa0'..'\uffbe' // Halfwidth_and_Fullwidth_Forms - | '\uffc2'..'\uffc7' // Halfwidth_and_Fullwidth_Forms - | '\uffca'..'\uffcf' // Halfwidth_and_Fullwidth_Forms - | '\uffd2'..'\uffd7' // Halfwidth_and_Fullwidth_Forms - | '\uffda'..'\uffdc' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Lo + : '\u00aa' // Latin-1_Supplement + | '\u00ba' // Latin-1_Supplement + | '\u01bb' // Latin_Extended-B + | '\u01c0' ..'\u01c3' // Latin_Extended-B + | '\u0294' // IPA_Extensions + | '\u05d0' ..'\u05ea' // Hebrew + | '\u05f0' ..'\u05f2' // Hebrew + | '\u0620' ..'\u063f' // Arabic + | '\u0641' ..'\u064a' // Arabic + | '\u066e' ..'\u066f' // Arabic + | '\u0671' ..'\u06d3' // Arabic + | '\u06d5' // Arabic + | '\u06ee' ..'\u06ef' // Arabic + | '\u06fa' ..'\u06fc' // Arabic + | '\u06ff' // (Absent from Blocks.txt) + | '\u0710' // Syriac + | '\u0712' ..'\u072f' // Syriac + | '\u074d' ..'\u07a5' // Syriac + | '\u07b1' // Thaana + | '\u07ca' ..'\u07ea' // NKo + | '\u0800' ..'\u0815' // Samaritan + | '\u0840' ..'\u0858' // Mandaic + | '\u08a0' ..'\u08b4' // Arabic_Extended-A + | '\u08b6' ..'\u08bd' // Arabic_Extended-A + | '\u0904' ..'\u0939' // Devanagari + | '\u093d' // Devanagari + | '\u0950' // Devanagari + | '\u0958' ..'\u0961' // Devanagari + | '\u0972' ..'\u0980' // Devanagari + | '\u0985' ..'\u098c' // Bengali + | '\u098f' ..'\u0990' // Bengali + | '\u0993' ..'\u09a8' // Bengali + | '\u09aa' ..'\u09b0' // Bengali + | '\u09b2' // Bengali + | '\u09b6' ..'\u09b9' // Bengali + | '\u09bd' // Bengali + | '\u09ce' // Bengali + | '\u09dc' ..'\u09dd' // Bengali + | '\u09df' ..'\u09e1' // Bengali + | '\u09f0' ..'\u09f1' // Bengali + | '\u0a05' ..'\u0a0a' // Gurmukhi + | '\u0a0f' ..'\u0a10' // Gurmukhi + | '\u0a13' ..'\u0a28' // Gurmukhi + | '\u0a2a' ..'\u0a30' // Gurmukhi + | '\u0a32' ..'\u0a33' // Gurmukhi + | '\u0a35' ..'\u0a36' // Gurmukhi + | '\u0a38' ..'\u0a39' // Gurmukhi + | '\u0a59' ..'\u0a5c' // Gurmukhi + | '\u0a5e' // Gurmukhi + | '\u0a72' ..'\u0a74' // Gurmukhi + | '\u0a85' ..'\u0a8d' // Gujarati + | '\u0a8f' ..'\u0a91' // Gujarati + | '\u0a93' ..'\u0aa8' // Gujarati + | '\u0aaa' ..'\u0ab0' // Gujarati + | '\u0ab2' ..'\u0ab3' // Gujarati + | '\u0ab5' ..'\u0ab9' // Gujarati + | '\u0abd' // Gujarati + | '\u0ad0' // Gujarati + | '\u0ae0' ..'\u0ae1' // Gujarati + | '\u0af9' // Gujarati + | '\u0b05' ..'\u0b0c' // Oriya + | '\u0b0f' ..'\u0b10' // Oriya + | '\u0b13' ..'\u0b28' // Oriya + | '\u0b2a' ..'\u0b30' // Oriya + | '\u0b32' ..'\u0b33' // Oriya + | '\u0b35' ..'\u0b39' // Oriya + | '\u0b3d' // Oriya + | '\u0b5c' ..'\u0b5d' // Oriya + | '\u0b5f' ..'\u0b61' // Oriya + | '\u0b71' // Oriya + | '\u0b83' // Tamil + | '\u0b85' ..'\u0b8a' // Tamil + | '\u0b8e' ..'\u0b90' // Tamil + | '\u0b92' ..'\u0b95' // Tamil + | '\u0b99' ..'\u0b9a' // Tamil + | '\u0b9c' // Tamil + | '\u0b9e' ..'\u0b9f' // Tamil + | '\u0ba3' ..'\u0ba4' // Tamil + | '\u0ba8' ..'\u0baa' // Tamil + | '\u0bae' ..'\u0bb9' // Tamil + | '\u0bd0' // Tamil + | '\u0c05' ..'\u0c0c' // Telugu + | '\u0c0e' ..'\u0c10' // Telugu + | '\u0c12' ..'\u0c28' // Telugu + | '\u0c2a' ..'\u0c39' // Telugu + | '\u0c3d' // Telugu + | '\u0c58' ..'\u0c5a' // Telugu + | '\u0c60' ..'\u0c61' // Telugu + | '\u0c80' // Kannada + | '\u0c85' ..'\u0c8c' // Kannada + | '\u0c8e' ..'\u0c90' // Kannada + | '\u0c92' ..'\u0ca8' // Kannada + | '\u0caa' ..'\u0cb3' // Kannada + | '\u0cb5' ..'\u0cb9' // Kannada + | '\u0cbd' // Kannada + | '\u0cde' // Kannada + | '\u0ce0' ..'\u0ce1' // Kannada + | '\u0cf1' ..'\u0cf2' // Kannada + | '\u0d05' ..'\u0d0c' // Malayalam + | '\u0d0e' ..'\u0d10' // Malayalam + | '\u0d12' ..'\u0d3a' // Malayalam + | '\u0d3d' // Malayalam + | '\u0d4e' // Malayalam + | '\u0d54' ..'\u0d56' // Malayalam + | '\u0d5f' ..'\u0d61' // Malayalam + | '\u0d7a' ..'\u0d7f' // Malayalam + | '\u0d85' ..'\u0d96' // Sinhala + | '\u0d9a' ..'\u0db1' // Sinhala + | '\u0db3' ..'\u0dbb' // Sinhala + | '\u0dbd' // Sinhala + | '\u0dc0' ..'\u0dc6' // Sinhala + | '\u0e01' ..'\u0e30' // Thai + | '\u0e32' ..'\u0e33' // Thai + | '\u0e40' ..'\u0e45' // Thai + | '\u0e81' ..'\u0e82' // Lao + | '\u0e84' // Lao + | '\u0e87' ..'\u0e88' // Lao + | '\u0e8a' // Lao + | '\u0e8d' // Lao + | '\u0e94' ..'\u0e97' // Lao + | '\u0e99' ..'\u0e9f' // Lao + | '\u0ea1' ..'\u0ea3' // Lao + | '\u0ea5' // Lao + | '\u0ea7' // Lao + | '\u0eaa' ..'\u0eab' // Lao + | '\u0ead' ..'\u0eb0' // Lao + | '\u0eb2' ..'\u0eb3' // Lao + | '\u0ebd' // Lao + | '\u0ec0' ..'\u0ec4' // Lao + | '\u0edc' ..'\u0edf' // Lao + | '\u0f00' // Tibetan + | '\u0f40' ..'\u0f47' // Tibetan + | '\u0f49' ..'\u0f6c' // Tibetan + | '\u0f88' ..'\u0f8c' // Tibetan + | '\u1000' ..'\u102a' // Myanmar + | '\u103f' // Myanmar + | '\u1050' ..'\u1055' // Myanmar + | '\u105a' ..'\u105d' // Myanmar + | '\u1061' // Myanmar + | '\u1065' ..'\u1066' // Myanmar + | '\u106e' ..'\u1070' // Myanmar + | '\u1075' ..'\u1081' // Myanmar + | '\u108e' // Myanmar + | '\u10d0' ..'\u10fa' // Georgian + | '\u10fd' ..'\u1248' // Georgian + | '\u124a' ..'\u124d' // Ethiopic + | '\u1250' ..'\u1256' // Ethiopic + | '\u1258' // Ethiopic + | '\u125a' ..'\u125d' // Ethiopic + | '\u1260' ..'\u1288' // Ethiopic + | '\u128a' ..'\u128d' // Ethiopic + | '\u1290' ..'\u12b0' // Ethiopic + | '\u12b2' ..'\u12b5' // Ethiopic + | '\u12b8' ..'\u12be' // Ethiopic + | '\u12c0' // Ethiopic + | '\u12c2' ..'\u12c5' // Ethiopic + | '\u12c8' ..'\u12d6' // Ethiopic + | '\u12d8' ..'\u1310' // Ethiopic + | '\u1312' ..'\u1315' // Ethiopic + | '\u1318' ..'\u135a' // Ethiopic + | '\u1380' ..'\u138f' // Ethiopic_Supplement + | '\u1401' ..'\u166c' // Unified_Canadian_Aboriginal_Syllabics + | '\u166f' ..'\u167f' // Unified_Canadian_Aboriginal_Syllabics + | '\u1681' ..'\u169a' // Ogham + | '\u16a0' ..'\u16ea' // Runic + | '\u16f1' ..'\u16f8' // Runic + | '\u1700' ..'\u170c' // Tagalog + | '\u170e' ..'\u1711' // Tagalog + | '\u1720' ..'\u1731' // Hanunoo + | '\u1740' ..'\u1751' // Buhid + | '\u1760' ..'\u176c' // Tagbanwa + | '\u176e' ..'\u1770' // Tagbanwa + | '\u1780' ..'\u17b3' // Khmer + | '\u17dc' // Khmer + | '\u1820' ..'\u1842' // Mongolian + | '\u1844' ..'\u1877' // Mongolian + | '\u1880' ..'\u1884' // Mongolian + | '\u1887' ..'\u18a8' // Mongolian + | '\u18aa' // Mongolian + | '\u18b0' ..'\u18f5' // Unified_Canadian_Aboriginal_Syllabics_Extended + | '\u1900' ..'\u191e' // Limbu + | '\u1950' ..'\u196d' // Tai_Le + | '\u1970' ..'\u1974' // Tai_Le + | '\u1980' ..'\u19ab' // New_Tai_Lue + | '\u19b0' ..'\u19c9' // New_Tai_Lue + | '\u1a00' ..'\u1a16' // Buginese + | '\u1a20' ..'\u1a54' // Tai_Tham + | '\u1b05' ..'\u1b33' // Balinese + | '\u1b45' ..'\u1b4b' // Balinese + | '\u1b83' ..'\u1ba0' // Sundanese + | '\u1bae' ..'\u1baf' // Sundanese + | '\u1bba' ..'\u1be5' // Sundanese + | '\u1c00' ..'\u1c23' // Lepcha + | '\u1c4d' ..'\u1c4f' // Lepcha + | '\u1c5a' ..'\u1c77' // Ol_Chiki + | '\u1ce9' ..'\u1cec' // Vedic_Extensions + | '\u1cee' ..'\u1cf1' // Vedic_Extensions + | '\u1cf5' ..'\u1cf6' // Vedic_Extensions + | '\u2135' ..'\u2138' // Letterlike_Symbols + | '\u2d30' ..'\u2d67' // Tifinagh + | '\u2d80' ..'\u2d96' // Ethiopic_Extended + | '\u2da0' ..'\u2da6' // Ethiopic_Extended + | '\u2da8' ..'\u2dae' // Ethiopic_Extended + | '\u2db0' ..'\u2db6' // Ethiopic_Extended + | '\u2db8' ..'\u2dbe' // Ethiopic_Extended + | '\u2dc0' ..'\u2dc6' // Ethiopic_Extended + | '\u2dc8' ..'\u2dce' // Ethiopic_Extended + | '\u2dd0' ..'\u2dd6' // Ethiopic_Extended + | '\u2dd8' ..'\u2dde' // Ethiopic_Extended + | '\u3006' // CJK_Symbols_and_Punctuation + | '\u303c' // CJK_Symbols_and_Punctuation + | '\u3041' ..'\u3096' // Hiragana + | '\u309f' // (Absent from Blocks.txt) + | '\u30a1' ..'\u30fa' // Katakana + | '\u30ff' // (Absent from Blocks.txt) + | '\u3105' ..'\u312d' // Bopomofo + | '\u3131' ..'\u318e' // Hangul_Compatibility_Jamo + | '\u31a0' ..'\u31ba' // Bopomofo_Extended + | '\u31f0' ..'\u31ff' // Katakana_Phonetic_Extensions + | '\u3400' ..'\u4db5' // CJK_Unified_Ideographs_Extension_A + | '\u4e00' ..'\u9fd5' // CJK_Unified_Ideographs + | '\ua000' ..'\ua014' // Yi_Syllables + | '\ua016' ..'\ua48c' // Yi_Syllables + | '\ua4d0' ..'\ua4f7' // Lisu + | '\ua500' ..'\ua60b' // Vai + | '\ua610' ..'\ua61f' // Vai + | '\ua62a' ..'\ua62b' // Vai + | '\ua66e' // Cyrillic_Extended-B + | '\ua6a0' ..'\ua6e5' // Bamum + | '\ua78f' // Latin_Extended-D + | '\ua7f7' // Latin_Extended-D + | '\ua7fb' ..'\ua801' // Latin_Extended-D + | '\ua803' ..'\ua805' // Syloti_Nagri + | '\ua807' ..'\ua80a' // Syloti_Nagri + | '\ua80c' ..'\ua822' // Syloti_Nagri + | '\ua840' ..'\ua873' // Phags-pa + | '\ua882' ..'\ua8b3' // Saurashtra + | '\ua8f2' ..'\ua8f7' // Devanagari_Extended + | '\ua8fb' // Devanagari_Extended + | '\ua8fd' // Devanagari_Extended + | '\ua90a' ..'\ua925' // Kayah_Li + | '\ua930' ..'\ua946' // Rejang + | '\ua960' ..'\ua97c' // Hangul_Jamo_Extended-A + | '\ua984' ..'\ua9b2' // Javanese + | '\ua9e0' ..'\ua9e4' // Myanmar_Extended-B + | '\ua9e7' ..'\ua9ef' // Myanmar_Extended-B + | '\ua9fa' ..'\ua9fe' // Myanmar_Extended-B + | '\uaa00' ..'\uaa28' // Cham + | '\uaa40' ..'\uaa42' // Cham + | '\uaa44' ..'\uaa4b' // Cham + | '\uaa60' ..'\uaa6f' // Myanmar_Extended-A + | '\uaa71' ..'\uaa76' // Myanmar_Extended-A + | '\uaa7a' // Myanmar_Extended-A + | '\uaa7e' ..'\uaaaf' // Myanmar_Extended-A + | '\uaab1' // Tai_Viet + | '\uaab5' ..'\uaab6' // Tai_Viet + | '\uaab9' ..'\uaabd' // Tai_Viet + | '\uaac0' // Tai_Viet + | '\uaac2' // Tai_Viet + | '\uaadb' ..'\uaadc' // Tai_Viet + | '\uaae0' ..'\uaaea' // Meetei_Mayek_Extensions + | '\uaaf2' // Meetei_Mayek_Extensions + | '\uab01' ..'\uab06' // Ethiopic_Extended-A + | '\uab09' ..'\uab0e' // Ethiopic_Extended-A + | '\uab11' ..'\uab16' // Ethiopic_Extended-A + | '\uab20' ..'\uab26' // Ethiopic_Extended-A + | '\uab28' ..'\uab2e' // Ethiopic_Extended-A + | '\uabc0' ..'\uabe2' // Meetei_Mayek + | '\uac00' // Hangul_Syllables + | '\ud7a3' // Hangul_Syllables + | '\ud7b0' ..'\ud7c6' // Hangul_Jamo_Extended-B + | '\ud7cb' ..'\ud7fb' // Hangul_Jamo_Extended-B + | '\uf900' ..'\ufa6d' // CJK_Compatibility_Ideographs + | '\ufa70' ..'\ufad9' // CJK_Compatibility_Ideographs + | '\ufb1d' // Alphabetic_Presentation_Forms + | '\ufb1f' ..'\ufb28' // Alphabetic_Presentation_Forms + | '\ufb2a' ..'\ufb36' // Alphabetic_Presentation_Forms + | '\ufb38' ..'\ufb3c' // Alphabetic_Presentation_Forms + | '\ufb3e' // Alphabetic_Presentation_Forms + | '\ufb40' ..'\ufb41' // Alphabetic_Presentation_Forms + | '\ufb43' ..'\ufb44' // Alphabetic_Presentation_Forms + | '\ufb46' ..'\ufbb1' // Alphabetic_Presentation_Forms + | '\ufbd3' ..'\ufd3d' // Arabic_Presentation_Forms-A + | '\ufd50' ..'\ufd8f' // Arabic_Presentation_Forms-A + | '\ufd92' ..'\ufdc7' // Arabic_Presentation_Forms-A + | '\ufdf0' ..'\ufdfb' // Arabic_Presentation_Forms-A + | '\ufe70' ..'\ufe74' // Arabic_Presentation_Forms-B + | '\ufe76' ..'\ufefc' // Arabic_Presentation_Forms-B + | '\uff66' ..'\uff6f' // Halfwidth_and_Fullwidth_Forms + | '\uff71' ..'\uff9d' // Halfwidth_and_Fullwidth_Forms + | '\uffa0' ..'\uffbe' // Halfwidth_and_Fullwidth_Forms + | '\uffc2' ..'\uffc7' // Halfwidth_and_Fullwidth_Forms + | '\uffca' ..'\uffcf' // Halfwidth_and_Fullwidth_Forms + | '\uffd2' ..'\uffd7' // Halfwidth_and_Fullwidth_Forms + | '\uffda' ..'\uffdc' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Lt: - '\u01c5' // Latin_Extended-B - | '\u01c8' // Latin_Extended-B - | '\u01cb' // Latin_Extended-B - | '\u01f2' // Latin_Extended-B - | '\u1f88'..'\u1f8f' // Greek_Extended - | '\u1f98'..'\u1f9f' // Greek_Extended - | '\u1fa8'..'\u1faf' // Greek_Extended - | '\u1fbc' // Greek_Extended - | '\u1fcc' // Greek_Extended - | '\u1ffc' // Greek_Extended -; +CLASSIFY_Lt + : '\u01c5' // Latin_Extended-B + | '\u01c8' // Latin_Extended-B + | '\u01cb' // Latin_Extended-B + | '\u01f2' // Latin_Extended-B + | '\u1f88' ..'\u1f8f' // Greek_Extended + | '\u1f98' ..'\u1f9f' // Greek_Extended + | '\u1fa8' ..'\u1faf' // Greek_Extended + | '\u1fbc' // Greek_Extended + | '\u1fcc' // Greek_Extended + | '\u1ffc' // Greek_Extended + ; -CLASSIFY_Lu: - '\u0041'..'\u005a' // Basic_Latin - | '\u00c0'..'\u00d6' // Latin-1_Supplement - | '\u00d8'..'\u00de' // Latin-1_Supplement - | '\u0100' // Latin_Extended-A - | '\u0102' // Latin_Extended-A - | '\u0104' // Latin_Extended-A - | '\u0106' // Latin_Extended-A - | '\u0108' // Latin_Extended-A - | '\u010a' // Latin_Extended-A - | '\u010c' // Latin_Extended-A - | '\u010e' // Latin_Extended-A - | '\u0110' // Latin_Extended-A - | '\u0112' // Latin_Extended-A - | '\u0114' // Latin_Extended-A - | '\u0116' // Latin_Extended-A - | '\u0118' // Latin_Extended-A - | '\u011a' // Latin_Extended-A - | '\u011c' // Latin_Extended-A - | '\u011e' // Latin_Extended-A - | '\u0120' // Latin_Extended-A - | '\u0122' // Latin_Extended-A - | '\u0124' // Latin_Extended-A - | '\u0126' // Latin_Extended-A - | '\u0128' // Latin_Extended-A - | '\u012a' // Latin_Extended-A - | '\u012c' // Latin_Extended-A - | '\u012e' // Latin_Extended-A - | '\u0130' // Latin_Extended-A - | '\u0132' // Latin_Extended-A - | '\u0134' // Latin_Extended-A - | '\u0136' // Latin_Extended-A - | '\u0139' // Latin_Extended-A - | '\u013b' // Latin_Extended-A - | '\u013d' // Latin_Extended-A - | '\u013f' // Latin_Extended-A - | '\u0141' // Latin_Extended-A - | '\u0143' // Latin_Extended-A - | '\u0145' // Latin_Extended-A - | '\u0147' // Latin_Extended-A - | '\u014a' // Latin_Extended-A - | '\u014c' // Latin_Extended-A - | '\u014e' // Latin_Extended-A - | '\u0150' // Latin_Extended-A - | '\u0152' // Latin_Extended-A - | '\u0154' // Latin_Extended-A - | '\u0156' // Latin_Extended-A - | '\u0158' // Latin_Extended-A - | '\u015a' // Latin_Extended-A - | '\u015c' // Latin_Extended-A - | '\u015e' // Latin_Extended-A - | '\u0160' // Latin_Extended-A - | '\u0162' // Latin_Extended-A - | '\u0164' // Latin_Extended-A - | '\u0166' // Latin_Extended-A - | '\u0168' // Latin_Extended-A - | '\u016a' // Latin_Extended-A - | '\u016c' // Latin_Extended-A - | '\u016e' // Latin_Extended-A - | '\u0170' // Latin_Extended-A - | '\u0172' // Latin_Extended-A - | '\u0174' // Latin_Extended-A - | '\u0176' // Latin_Extended-A - | '\u0178'..'\u0179' // Latin_Extended-A - | '\u017b' // Latin_Extended-A - | '\u017d' // Latin_Extended-A - | '\u0181'..'\u0182' // Latin_Extended-B - | '\u0184' // Latin_Extended-B - | '\u0186'..'\u0187' // Latin_Extended-B - | '\u0189'..'\u018b' // Latin_Extended-B - | '\u018e'..'\u0191' // Latin_Extended-B - | '\u0193'..'\u0194' // Latin_Extended-B - | '\u0196'..'\u0198' // Latin_Extended-B - | '\u019c'..'\u019d' // Latin_Extended-B - | '\u019f'..'\u01a0' // Latin_Extended-B - | '\u01a2' // Latin_Extended-B - | '\u01a4' // Latin_Extended-B - | '\u01a6'..'\u01a7' // Latin_Extended-B - | '\u01a9' // Latin_Extended-B - | '\u01ac' // Latin_Extended-B - | '\u01ae'..'\u01af' // Latin_Extended-B - | '\u01b1'..'\u01b3' // Latin_Extended-B - | '\u01b5' // Latin_Extended-B - | '\u01b7'..'\u01b8' // Latin_Extended-B - | '\u01bc' // Latin_Extended-B - | '\u01c4' // Latin_Extended-B - | '\u01c7' // Latin_Extended-B - | '\u01ca' // Latin_Extended-B - | '\u01cd' // Latin_Extended-B - | '\u01cf' // Latin_Extended-B - | '\u01d1' // Latin_Extended-B - | '\u01d3' // Latin_Extended-B - | '\u01d5' // Latin_Extended-B - | '\u01d7' // Latin_Extended-B - | '\u01d9' // Latin_Extended-B - | '\u01db' // Latin_Extended-B - | '\u01de' // Latin_Extended-B - | '\u01e0' // Latin_Extended-B - | '\u01e2' // Latin_Extended-B - | '\u01e4' // Latin_Extended-B - | '\u01e6' // Latin_Extended-B - | '\u01e8' // Latin_Extended-B - | '\u01ea' // Latin_Extended-B - | '\u01ec' // Latin_Extended-B - | '\u01ee' // Latin_Extended-B - | '\u01f1' // Latin_Extended-B - | '\u01f4' // Latin_Extended-B - | '\u01f6'..'\u01f8' // Latin_Extended-B - | '\u01fa' // Latin_Extended-B - | '\u01fc' // Latin_Extended-B - | '\u01fe' // Latin_Extended-B - | '\u0200' // Latin_Extended-B - | '\u0202' // Latin_Extended-B - | '\u0204' // Latin_Extended-B - | '\u0206' // Latin_Extended-B - | '\u0208' // Latin_Extended-B - | '\u020a' // Latin_Extended-B - | '\u020c' // Latin_Extended-B - | '\u020e' // Latin_Extended-B - | '\u0210' // Latin_Extended-B - | '\u0212' // Latin_Extended-B - | '\u0214' // Latin_Extended-B - | '\u0216' // Latin_Extended-B - | '\u0218' // Latin_Extended-B - | '\u021a' // Latin_Extended-B - | '\u021c' // Latin_Extended-B - | '\u021e' // Latin_Extended-B - | '\u0220' // Latin_Extended-B - | '\u0222' // Latin_Extended-B - | '\u0224' // Latin_Extended-B - | '\u0226' // Latin_Extended-B - | '\u0228' // Latin_Extended-B - | '\u022a' // Latin_Extended-B - | '\u022c' // Latin_Extended-B - | '\u022e' // Latin_Extended-B - | '\u0230' // Latin_Extended-B - | '\u0232' // Latin_Extended-B - | '\u023a'..'\u023b' // Latin_Extended-B - | '\u023d'..'\u023e' // Latin_Extended-B - | '\u0241' // Latin_Extended-B - | '\u0243'..'\u0246' // Latin_Extended-B - | '\u0248' // Latin_Extended-B - | '\u024a' // Latin_Extended-B - | '\u024c' // Latin_Extended-B - | '\u024e' // Latin_Extended-B - | '\u0370' // Greek_and_Coptic - | '\u0372' // Greek_and_Coptic - | '\u0376' // Greek_and_Coptic - | '\u037f' // Greek_and_Coptic - | '\u0386' // Greek_and_Coptic - | '\u0388'..'\u038a' // Greek_and_Coptic - | '\u038c' // Greek_and_Coptic - | '\u038e'..'\u038f' // Greek_and_Coptic - | '\u0391'..'\u03a1' // Greek_and_Coptic - | '\u03a3'..'\u03ab' // Greek_and_Coptic - | '\u03cf' // Greek_and_Coptic - | '\u03d2'..'\u03d4' // Greek_and_Coptic - | '\u03d8' // Greek_and_Coptic - | '\u03da' // Greek_and_Coptic - | '\u03dc' // Greek_and_Coptic - | '\u03de' // Greek_and_Coptic - | '\u03e0' // Greek_and_Coptic - | '\u03e2' // Greek_and_Coptic - | '\u03e4' // Greek_and_Coptic - | '\u03e6' // Greek_and_Coptic - | '\u03e8' // Greek_and_Coptic - | '\u03ea' // Greek_and_Coptic - | '\u03ec' // Greek_and_Coptic - | '\u03ee' // Greek_and_Coptic - | '\u03f4' // Greek_and_Coptic - | '\u03f7' // Greek_and_Coptic - | '\u03f9'..'\u03fa' // Greek_and_Coptic - | '\u03fd'..'\u042f' // Greek_and_Coptic - | '\u0460' // Cyrillic - | '\u0462' // Cyrillic - | '\u0464' // Cyrillic - | '\u0466' // Cyrillic - | '\u0468' // Cyrillic - | '\u046a' // Cyrillic - | '\u046c' // Cyrillic - | '\u046e' // Cyrillic - | '\u0470' // Cyrillic - | '\u0472' // Cyrillic - | '\u0474' // Cyrillic - | '\u0476' // Cyrillic - | '\u0478' // Cyrillic - | '\u047a' // Cyrillic - | '\u047c' // Cyrillic - | '\u047e' // Cyrillic - | '\u0480' // Cyrillic - | '\u048a' // Cyrillic - | '\u048c' // Cyrillic - | '\u048e' // Cyrillic - | '\u0490' // Cyrillic - | '\u0492' // Cyrillic - | '\u0494' // Cyrillic - | '\u0496' // Cyrillic - | '\u0498' // Cyrillic - | '\u049a' // Cyrillic - | '\u049c' // Cyrillic - | '\u049e' // Cyrillic - | '\u04a0' // Cyrillic - | '\u04a2' // Cyrillic - | '\u04a4' // Cyrillic - | '\u04a6' // Cyrillic - | '\u04a8' // Cyrillic - | '\u04aa' // Cyrillic - | '\u04ac' // Cyrillic - | '\u04ae' // Cyrillic - | '\u04b0' // Cyrillic - | '\u04b2' // Cyrillic - | '\u04b4' // Cyrillic - | '\u04b6' // Cyrillic - | '\u04b8' // Cyrillic - | '\u04ba' // Cyrillic - | '\u04bc' // Cyrillic - | '\u04be' // Cyrillic - | '\u04c0'..'\u04c1' // Cyrillic - | '\u04c3' // Cyrillic - | '\u04c5' // Cyrillic - | '\u04c7' // Cyrillic - | '\u04c9' // Cyrillic - | '\u04cb' // Cyrillic - | '\u04cd' // Cyrillic - | '\u04d0' // Cyrillic - | '\u04d2' // Cyrillic - | '\u04d4' // Cyrillic - | '\u04d6' // Cyrillic - | '\u04d8' // Cyrillic - | '\u04da' // Cyrillic - | '\u04dc' // Cyrillic - | '\u04de' // Cyrillic - | '\u04e0' // Cyrillic - | '\u04e2' // Cyrillic - | '\u04e4' // Cyrillic - | '\u04e6' // Cyrillic - | '\u04e8' // Cyrillic - | '\u04ea' // Cyrillic - | '\u04ec' // Cyrillic - | '\u04ee' // Cyrillic - | '\u04f0' // Cyrillic - | '\u04f2' // Cyrillic - | '\u04f4' // Cyrillic - | '\u04f6' // Cyrillic - | '\u04f8' // Cyrillic - | '\u04fa' // Cyrillic - | '\u04fc' // Cyrillic - | '\u04fe' // Cyrillic - | '\u0500' // Cyrillic_Supplement - | '\u0502' // Cyrillic_Supplement - | '\u0504' // Cyrillic_Supplement - | '\u0506' // Cyrillic_Supplement - | '\u0508' // Cyrillic_Supplement - | '\u050a' // Cyrillic_Supplement - | '\u050c' // Cyrillic_Supplement - | '\u050e' // Cyrillic_Supplement - | '\u0510' // Cyrillic_Supplement - | '\u0512' // Cyrillic_Supplement - | '\u0514' // Cyrillic_Supplement - | '\u0516' // Cyrillic_Supplement - | '\u0518' // Cyrillic_Supplement - | '\u051a' // Cyrillic_Supplement - | '\u051c' // Cyrillic_Supplement - | '\u051e' // Cyrillic_Supplement - | '\u0520' // Cyrillic_Supplement - | '\u0522' // Cyrillic_Supplement - | '\u0524' // Cyrillic_Supplement - | '\u0526' // Cyrillic_Supplement - | '\u0528' // Cyrillic_Supplement - | '\u052a' // Cyrillic_Supplement - | '\u052c' // Cyrillic_Supplement - | '\u052e' // Cyrillic_Supplement - | '\u0531'..'\u0556' // Armenian - | '\u10a0'..'\u10c5' // Georgian - | '\u10c7' // Georgian - | '\u10cd' // Georgian - | '\u13a0'..'\u13f5' // Cherokee - | '\u1e00' // Latin_Extended_Additional - | '\u1e02' // Latin_Extended_Additional - | '\u1e04' // Latin_Extended_Additional - | '\u1e06' // Latin_Extended_Additional - | '\u1e08' // Latin_Extended_Additional - | '\u1e0a' // Latin_Extended_Additional - | '\u1e0c' // Latin_Extended_Additional - | '\u1e0e' // Latin_Extended_Additional - | '\u1e10' // Latin_Extended_Additional - | '\u1e12' // Latin_Extended_Additional - | '\u1e14' // Latin_Extended_Additional - | '\u1e16' // Latin_Extended_Additional - | '\u1e18' // Latin_Extended_Additional - | '\u1e1a' // Latin_Extended_Additional - | '\u1e1c' // Latin_Extended_Additional - | '\u1e1e' // Latin_Extended_Additional - | '\u1e20' // Latin_Extended_Additional - | '\u1e22' // Latin_Extended_Additional - | '\u1e24' // Latin_Extended_Additional - | '\u1e26' // Latin_Extended_Additional - | '\u1e28' // Latin_Extended_Additional - | '\u1e2a' // Latin_Extended_Additional - | '\u1e2c' // Latin_Extended_Additional - | '\u1e2e' // Latin_Extended_Additional - | '\u1e30' // Latin_Extended_Additional - | '\u1e32' // Latin_Extended_Additional - | '\u1e34' // Latin_Extended_Additional - | '\u1e36' // Latin_Extended_Additional - | '\u1e38' // Latin_Extended_Additional - | '\u1e3a' // Latin_Extended_Additional - | '\u1e3c' // Latin_Extended_Additional - | '\u1e3e' // Latin_Extended_Additional - | '\u1e40' // Latin_Extended_Additional - | '\u1e42' // Latin_Extended_Additional - | '\u1e44' // Latin_Extended_Additional - | '\u1e46' // Latin_Extended_Additional - | '\u1e48' // Latin_Extended_Additional - | '\u1e4a' // Latin_Extended_Additional - | '\u1e4c' // Latin_Extended_Additional - | '\u1e4e' // Latin_Extended_Additional - | '\u1e50' // Latin_Extended_Additional - | '\u1e52' // Latin_Extended_Additional - | '\u1e54' // Latin_Extended_Additional - | '\u1e56' // Latin_Extended_Additional - | '\u1e58' // Latin_Extended_Additional - | '\u1e5a' // Latin_Extended_Additional - | '\u1e5c' // Latin_Extended_Additional - | '\u1e5e' // Latin_Extended_Additional - | '\u1e60' // Latin_Extended_Additional - | '\u1e62' // Latin_Extended_Additional - | '\u1e64' // Latin_Extended_Additional - | '\u1e66' // Latin_Extended_Additional - | '\u1e68' // Latin_Extended_Additional - | '\u1e6a' // Latin_Extended_Additional - | '\u1e6c' // Latin_Extended_Additional - | '\u1e6e' // Latin_Extended_Additional - | '\u1e70' // Latin_Extended_Additional - | '\u1e72' // Latin_Extended_Additional - | '\u1e74' // Latin_Extended_Additional - | '\u1e76' // Latin_Extended_Additional - | '\u1e78' // Latin_Extended_Additional - | '\u1e7a' // Latin_Extended_Additional - | '\u1e7c' // Latin_Extended_Additional - | '\u1e7e' // Latin_Extended_Additional - | '\u1e80' // Latin_Extended_Additional - | '\u1e82' // Latin_Extended_Additional - | '\u1e84' // Latin_Extended_Additional - | '\u1e86' // Latin_Extended_Additional - | '\u1e88' // Latin_Extended_Additional - | '\u1e8a' // Latin_Extended_Additional - | '\u1e8c' // Latin_Extended_Additional - | '\u1e8e' // Latin_Extended_Additional - | '\u1e90' // Latin_Extended_Additional - | '\u1e92' // Latin_Extended_Additional - | '\u1e94' // Latin_Extended_Additional - | '\u1e9e' // Latin_Extended_Additional - | '\u1ea0' // Latin_Extended_Additional - | '\u1ea2' // Latin_Extended_Additional - | '\u1ea4' // Latin_Extended_Additional - | '\u1ea6' // Latin_Extended_Additional - | '\u1ea8' // Latin_Extended_Additional - | '\u1eaa' // Latin_Extended_Additional - | '\u1eac' // Latin_Extended_Additional - | '\u1eae' // Latin_Extended_Additional - | '\u1eb0' // Latin_Extended_Additional - | '\u1eb2' // Latin_Extended_Additional - | '\u1eb4' // Latin_Extended_Additional - | '\u1eb6' // Latin_Extended_Additional - | '\u1eb8' // Latin_Extended_Additional - | '\u1eba' // Latin_Extended_Additional - | '\u1ebc' // Latin_Extended_Additional - | '\u1ebe' // Latin_Extended_Additional - | '\u1ec0' // Latin_Extended_Additional - | '\u1ec2' // Latin_Extended_Additional - | '\u1ec4' // Latin_Extended_Additional - | '\u1ec6' // Latin_Extended_Additional - | '\u1ec8' // Latin_Extended_Additional - | '\u1eca' // Latin_Extended_Additional - | '\u1ecc' // Latin_Extended_Additional - | '\u1ece' // Latin_Extended_Additional - | '\u1ed0' // Latin_Extended_Additional - | '\u1ed2' // Latin_Extended_Additional - | '\u1ed4' // Latin_Extended_Additional - | '\u1ed6' // Latin_Extended_Additional - | '\u1ed8' // Latin_Extended_Additional - | '\u1eda' // Latin_Extended_Additional - | '\u1edc' // Latin_Extended_Additional - | '\u1ede' // Latin_Extended_Additional - | '\u1ee0' // Latin_Extended_Additional - | '\u1ee2' // Latin_Extended_Additional - | '\u1ee4' // Latin_Extended_Additional - | '\u1ee6' // Latin_Extended_Additional - | '\u1ee8' // Latin_Extended_Additional - | '\u1eea' // Latin_Extended_Additional - | '\u1eec' // Latin_Extended_Additional - | '\u1eee' // Latin_Extended_Additional - | '\u1ef0' // Latin_Extended_Additional - | '\u1ef2' // Latin_Extended_Additional - | '\u1ef4' // Latin_Extended_Additional - | '\u1ef6' // Latin_Extended_Additional - | '\u1ef8' // Latin_Extended_Additional - | '\u1efa' // Latin_Extended_Additional - | '\u1efc' // Latin_Extended_Additional - | '\u1efe' // Latin_Extended_Additional - | '\u1f08'..'\u1f0f' // Greek_Extended - | '\u1f18'..'\u1f1d' // Greek_Extended - | '\u1f28'..'\u1f2f' // Greek_Extended - | '\u1f38'..'\u1f3f' // Greek_Extended - | '\u1f48'..'\u1f4d' // Greek_Extended - | '\u1f59' // Greek_Extended - | '\u1f5b' // Greek_Extended - | '\u1f5d' // Greek_Extended - | '\u1f5f' // Greek_Extended - | '\u1f68'..'\u1f6f' // Greek_Extended - | '\u1fb8'..'\u1fbb' // Greek_Extended - | '\u1fc8'..'\u1fcb' // Greek_Extended - | '\u1fd8'..'\u1fdb' // Greek_Extended - | '\u1fe8'..'\u1fec' // Greek_Extended - | '\u1ff8'..'\u1ffb' // Greek_Extended - | '\u2102' // Letterlike_Symbols - | '\u2107' // Letterlike_Symbols - | '\u210b'..'\u210d' // Letterlike_Symbols - | '\u2110'..'\u2112' // Letterlike_Symbols - | '\u2115' // Letterlike_Symbols - | '\u2119'..'\u211d' // Letterlike_Symbols - | '\u2124' // Letterlike_Symbols - | '\u2126' // Letterlike_Symbols - | '\u2128' // Letterlike_Symbols - | '\u212a'..'\u212d' // Letterlike_Symbols - | '\u2130'..'\u2133' // Letterlike_Symbols - | '\u213e'..'\u213f' // Letterlike_Symbols - | '\u2145' // Letterlike_Symbols - | '\u2183' // Number_Forms - | '\u2c00'..'\u2c2e' // Glagolitic - | '\u2c60' // Latin_Extended-C - | '\u2c62'..'\u2c64' // Latin_Extended-C - | '\u2c67' // Latin_Extended-C - | '\u2c69' // Latin_Extended-C - | '\u2c6b' // Latin_Extended-C - | '\u2c6d'..'\u2c70' // Latin_Extended-C - | '\u2c72' // Latin_Extended-C - | '\u2c75' // Latin_Extended-C - | '\u2c7e'..'\u2c80' // Latin_Extended-C - | '\u2c82' // Coptic - | '\u2c84' // Coptic - | '\u2c86' // Coptic - | '\u2c88' // Coptic - | '\u2c8a' // Coptic - | '\u2c8c' // Coptic - | '\u2c8e' // Coptic - | '\u2c90' // Coptic - | '\u2c92' // Coptic - | '\u2c94' // Coptic - | '\u2c96' // Coptic - | '\u2c98' // Coptic - | '\u2c9a' // Coptic - | '\u2c9c' // Coptic - | '\u2c9e' // Coptic - | '\u2ca0' // Coptic - | '\u2ca2' // Coptic - | '\u2ca4' // Coptic - | '\u2ca6' // Coptic - | '\u2ca8' // Coptic - | '\u2caa' // Coptic - | '\u2cac' // Coptic - | '\u2cae' // Coptic - | '\u2cb0' // Coptic - | '\u2cb2' // Coptic - | '\u2cb4' // Coptic - | '\u2cb6' // Coptic - | '\u2cb8' // Coptic - | '\u2cba' // Coptic - | '\u2cbc' // Coptic - | '\u2cbe' // Coptic - | '\u2cc0' // Coptic - | '\u2cc2' // Coptic - | '\u2cc4' // Coptic - | '\u2cc6' // Coptic - | '\u2cc8' // Coptic - | '\u2cca' // Coptic - | '\u2ccc' // Coptic - | '\u2cce' // Coptic - | '\u2cd0' // Coptic - | '\u2cd2' // Coptic - | '\u2cd4' // Coptic - | '\u2cd6' // Coptic - | '\u2cd8' // Coptic - | '\u2cda' // Coptic - | '\u2cdc' // Coptic - | '\u2cde' // Coptic - | '\u2ce0' // Coptic - | '\u2ce2' // Coptic - | '\u2ceb' // Coptic - | '\u2ced' // Coptic - | '\u2cf2' // Coptic - | '\ua640' // Cyrillic_Extended-B - | '\ua642' // Cyrillic_Extended-B - | '\ua644' // Cyrillic_Extended-B - | '\ua646' // Cyrillic_Extended-B - | '\ua648' // Cyrillic_Extended-B - | '\ua64a' // Cyrillic_Extended-B - | '\ua64c' // Cyrillic_Extended-B - | '\ua64e' // Cyrillic_Extended-B - | '\ua650' // Cyrillic_Extended-B - | '\ua652' // Cyrillic_Extended-B - | '\ua654' // Cyrillic_Extended-B - | '\ua656' // Cyrillic_Extended-B - | '\ua658' // Cyrillic_Extended-B - | '\ua65a' // Cyrillic_Extended-B - | '\ua65c' // Cyrillic_Extended-B - | '\ua65e' // Cyrillic_Extended-B - | '\ua660' // Cyrillic_Extended-B - | '\ua662' // Cyrillic_Extended-B - | '\ua664' // Cyrillic_Extended-B - | '\ua666' // Cyrillic_Extended-B - | '\ua668' // Cyrillic_Extended-B - | '\ua66a' // Cyrillic_Extended-B - | '\ua66c' // Cyrillic_Extended-B - | '\ua680' // Cyrillic_Extended-B - | '\ua682' // Cyrillic_Extended-B - | '\ua684' // Cyrillic_Extended-B - | '\ua686' // Cyrillic_Extended-B - | '\ua688' // Cyrillic_Extended-B - | '\ua68a' // Cyrillic_Extended-B - | '\ua68c' // Cyrillic_Extended-B - | '\ua68e' // Cyrillic_Extended-B - | '\ua690' // Cyrillic_Extended-B - | '\ua692' // Cyrillic_Extended-B - | '\ua694' // Cyrillic_Extended-B - | '\ua696' // Cyrillic_Extended-B - | '\ua698' // Cyrillic_Extended-B - | '\ua69a' // Cyrillic_Extended-B - | '\ua722' // Latin_Extended-D - | '\ua724' // Latin_Extended-D - | '\ua726' // Latin_Extended-D - | '\ua728' // Latin_Extended-D - | '\ua72a' // Latin_Extended-D - | '\ua72c' // Latin_Extended-D - | '\ua72e' // Latin_Extended-D - | '\ua732' // Latin_Extended-D - | '\ua734' // Latin_Extended-D - | '\ua736' // Latin_Extended-D - | '\ua738' // Latin_Extended-D - | '\ua73a' // Latin_Extended-D - | '\ua73c' // Latin_Extended-D - | '\ua73e' // Latin_Extended-D - | '\ua740' // Latin_Extended-D - | '\ua742' // Latin_Extended-D - | '\ua744' // Latin_Extended-D - | '\ua746' // Latin_Extended-D - | '\ua748' // Latin_Extended-D - | '\ua74a' // Latin_Extended-D - | '\ua74c' // Latin_Extended-D - | '\ua74e' // Latin_Extended-D - | '\ua750' // Latin_Extended-D - | '\ua752' // Latin_Extended-D - | '\ua754' // Latin_Extended-D - | '\ua756' // Latin_Extended-D - | '\ua758' // Latin_Extended-D - | '\ua75a' // Latin_Extended-D - | '\ua75c' // Latin_Extended-D - | '\ua75e' // Latin_Extended-D - | '\ua760' // Latin_Extended-D - | '\ua762' // Latin_Extended-D - | '\ua764' // Latin_Extended-D - | '\ua766' // Latin_Extended-D - | '\ua768' // Latin_Extended-D - | '\ua76a' // Latin_Extended-D - | '\ua76c' // Latin_Extended-D - | '\ua76e' // Latin_Extended-D - | '\ua779' // Latin_Extended-D - | '\ua77b' // Latin_Extended-D - | '\ua77d'..'\ua77e' // Latin_Extended-D - | '\ua780' // Latin_Extended-D - | '\ua782' // Latin_Extended-D - | '\ua784' // Latin_Extended-D - | '\ua786' // Latin_Extended-D - | '\ua78b' // Latin_Extended-D - | '\ua78d' // Latin_Extended-D - | '\ua790' // Latin_Extended-D - | '\ua792' // Latin_Extended-D - | '\ua796' // Latin_Extended-D - | '\ua798' // Latin_Extended-D - | '\ua79a' // Latin_Extended-D - | '\ua79c' // Latin_Extended-D - | '\ua79e' // Latin_Extended-D - | '\ua7a0' // Latin_Extended-D - | '\ua7a2' // Latin_Extended-D - | '\ua7a4' // Latin_Extended-D - | '\ua7a6' // Latin_Extended-D - | '\ua7a8' // Latin_Extended-D - | '\ua7aa'..'\ua7ae' // Latin_Extended-D - | '\ua7b0'..'\ua7b4' // Latin_Extended-D - | '\ua7b6' // Latin_Extended-D - | '\uff21'..'\uff3a' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Lu + : '\u0041' ..'\u005a' // Basic_Latin + | '\u00c0' ..'\u00d6' // Latin-1_Supplement + | '\u00d8' ..'\u00de' // Latin-1_Supplement + | '\u0100' // Latin_Extended-A + | '\u0102' // Latin_Extended-A + | '\u0104' // Latin_Extended-A + | '\u0106' // Latin_Extended-A + | '\u0108' // Latin_Extended-A + | '\u010a' // Latin_Extended-A + | '\u010c' // Latin_Extended-A + | '\u010e' // Latin_Extended-A + | '\u0110' // Latin_Extended-A + | '\u0112' // Latin_Extended-A + | '\u0114' // Latin_Extended-A + | '\u0116' // Latin_Extended-A + | '\u0118' // Latin_Extended-A + | '\u011a' // Latin_Extended-A + | '\u011c' // Latin_Extended-A + | '\u011e' // Latin_Extended-A + | '\u0120' // Latin_Extended-A + | '\u0122' // Latin_Extended-A + | '\u0124' // Latin_Extended-A + | '\u0126' // Latin_Extended-A + | '\u0128' // Latin_Extended-A + | '\u012a' // Latin_Extended-A + | '\u012c' // Latin_Extended-A + | '\u012e' // Latin_Extended-A + | '\u0130' // Latin_Extended-A + | '\u0132' // Latin_Extended-A + | '\u0134' // Latin_Extended-A + | '\u0136' // Latin_Extended-A + | '\u0139' // Latin_Extended-A + | '\u013b' // Latin_Extended-A + | '\u013d' // Latin_Extended-A + | '\u013f' // Latin_Extended-A + | '\u0141' // Latin_Extended-A + | '\u0143' // Latin_Extended-A + | '\u0145' // Latin_Extended-A + | '\u0147' // Latin_Extended-A + | '\u014a' // Latin_Extended-A + | '\u014c' // Latin_Extended-A + | '\u014e' // Latin_Extended-A + | '\u0150' // Latin_Extended-A + | '\u0152' // Latin_Extended-A + | '\u0154' // Latin_Extended-A + | '\u0156' // Latin_Extended-A + | '\u0158' // Latin_Extended-A + | '\u015a' // Latin_Extended-A + | '\u015c' // Latin_Extended-A + | '\u015e' // Latin_Extended-A + | '\u0160' // Latin_Extended-A + | '\u0162' // Latin_Extended-A + | '\u0164' // Latin_Extended-A + | '\u0166' // Latin_Extended-A + | '\u0168' // Latin_Extended-A + | '\u016a' // Latin_Extended-A + | '\u016c' // Latin_Extended-A + | '\u016e' // Latin_Extended-A + | '\u0170' // Latin_Extended-A + | '\u0172' // Latin_Extended-A + | '\u0174' // Latin_Extended-A + | '\u0176' // Latin_Extended-A + | '\u0178' ..'\u0179' // Latin_Extended-A + | '\u017b' // Latin_Extended-A + | '\u017d' // Latin_Extended-A + | '\u0181' ..'\u0182' // Latin_Extended-B + | '\u0184' // Latin_Extended-B + | '\u0186' ..'\u0187' // Latin_Extended-B + | '\u0189' ..'\u018b' // Latin_Extended-B + | '\u018e' ..'\u0191' // Latin_Extended-B + | '\u0193' ..'\u0194' // Latin_Extended-B + | '\u0196' ..'\u0198' // Latin_Extended-B + | '\u019c' ..'\u019d' // Latin_Extended-B + | '\u019f' ..'\u01a0' // Latin_Extended-B + | '\u01a2' // Latin_Extended-B + | '\u01a4' // Latin_Extended-B + | '\u01a6' ..'\u01a7' // Latin_Extended-B + | '\u01a9' // Latin_Extended-B + | '\u01ac' // Latin_Extended-B + | '\u01ae' ..'\u01af' // Latin_Extended-B + | '\u01b1' ..'\u01b3' // Latin_Extended-B + | '\u01b5' // Latin_Extended-B + | '\u01b7' ..'\u01b8' // Latin_Extended-B + | '\u01bc' // Latin_Extended-B + | '\u01c4' // Latin_Extended-B + | '\u01c7' // Latin_Extended-B + | '\u01ca' // Latin_Extended-B + | '\u01cd' // Latin_Extended-B + | '\u01cf' // Latin_Extended-B + | '\u01d1' // Latin_Extended-B + | '\u01d3' // Latin_Extended-B + | '\u01d5' // Latin_Extended-B + | '\u01d7' // Latin_Extended-B + | '\u01d9' // Latin_Extended-B + | '\u01db' // Latin_Extended-B + | '\u01de' // Latin_Extended-B + | '\u01e0' // Latin_Extended-B + | '\u01e2' // Latin_Extended-B + | '\u01e4' // Latin_Extended-B + | '\u01e6' // Latin_Extended-B + | '\u01e8' // Latin_Extended-B + | '\u01ea' // Latin_Extended-B + | '\u01ec' // Latin_Extended-B + | '\u01ee' // Latin_Extended-B + | '\u01f1' // Latin_Extended-B + | '\u01f4' // Latin_Extended-B + | '\u01f6' ..'\u01f8' // Latin_Extended-B + | '\u01fa' // Latin_Extended-B + | '\u01fc' // Latin_Extended-B + | '\u01fe' // Latin_Extended-B + | '\u0200' // Latin_Extended-B + | '\u0202' // Latin_Extended-B + | '\u0204' // Latin_Extended-B + | '\u0206' // Latin_Extended-B + | '\u0208' // Latin_Extended-B + | '\u020a' // Latin_Extended-B + | '\u020c' // Latin_Extended-B + | '\u020e' // Latin_Extended-B + | '\u0210' // Latin_Extended-B + | '\u0212' // Latin_Extended-B + | '\u0214' // Latin_Extended-B + | '\u0216' // Latin_Extended-B + | '\u0218' // Latin_Extended-B + | '\u021a' // Latin_Extended-B + | '\u021c' // Latin_Extended-B + | '\u021e' // Latin_Extended-B + | '\u0220' // Latin_Extended-B + | '\u0222' // Latin_Extended-B + | '\u0224' // Latin_Extended-B + | '\u0226' // Latin_Extended-B + | '\u0228' // Latin_Extended-B + | '\u022a' // Latin_Extended-B + | '\u022c' // Latin_Extended-B + | '\u022e' // Latin_Extended-B + | '\u0230' // Latin_Extended-B + | '\u0232' // Latin_Extended-B + | '\u023a' ..'\u023b' // Latin_Extended-B + | '\u023d' ..'\u023e' // Latin_Extended-B + | '\u0241' // Latin_Extended-B + | '\u0243' ..'\u0246' // Latin_Extended-B + | '\u0248' // Latin_Extended-B + | '\u024a' // Latin_Extended-B + | '\u024c' // Latin_Extended-B + | '\u024e' // Latin_Extended-B + | '\u0370' // Greek_and_Coptic + | '\u0372' // Greek_and_Coptic + | '\u0376' // Greek_and_Coptic + | '\u037f' // Greek_and_Coptic + | '\u0386' // Greek_and_Coptic + | '\u0388' ..'\u038a' // Greek_and_Coptic + | '\u038c' // Greek_and_Coptic + | '\u038e' ..'\u038f' // Greek_and_Coptic + | '\u0391' ..'\u03a1' // Greek_and_Coptic + | '\u03a3' ..'\u03ab' // Greek_and_Coptic + | '\u03cf' // Greek_and_Coptic + | '\u03d2' ..'\u03d4' // Greek_and_Coptic + | '\u03d8' // Greek_and_Coptic + | '\u03da' // Greek_and_Coptic + | '\u03dc' // Greek_and_Coptic + | '\u03de' // Greek_and_Coptic + | '\u03e0' // Greek_and_Coptic + | '\u03e2' // Greek_and_Coptic + | '\u03e4' // Greek_and_Coptic + | '\u03e6' // Greek_and_Coptic + | '\u03e8' // Greek_and_Coptic + | '\u03ea' // Greek_and_Coptic + | '\u03ec' // Greek_and_Coptic + | '\u03ee' // Greek_and_Coptic + | '\u03f4' // Greek_and_Coptic + | '\u03f7' // Greek_and_Coptic + | '\u03f9' ..'\u03fa' // Greek_and_Coptic + | '\u03fd' ..'\u042f' // Greek_and_Coptic + | '\u0460' // Cyrillic + | '\u0462' // Cyrillic + | '\u0464' // Cyrillic + | '\u0466' // Cyrillic + | '\u0468' // Cyrillic + | '\u046a' // Cyrillic + | '\u046c' // Cyrillic + | '\u046e' // Cyrillic + | '\u0470' // Cyrillic + | '\u0472' // Cyrillic + | '\u0474' // Cyrillic + | '\u0476' // Cyrillic + | '\u0478' // Cyrillic + | '\u047a' // Cyrillic + | '\u047c' // Cyrillic + | '\u047e' // Cyrillic + | '\u0480' // Cyrillic + | '\u048a' // Cyrillic + | '\u048c' // Cyrillic + | '\u048e' // Cyrillic + | '\u0490' // Cyrillic + | '\u0492' // Cyrillic + | '\u0494' // Cyrillic + | '\u0496' // Cyrillic + | '\u0498' // Cyrillic + | '\u049a' // Cyrillic + | '\u049c' // Cyrillic + | '\u049e' // Cyrillic + | '\u04a0' // Cyrillic + | '\u04a2' // Cyrillic + | '\u04a4' // Cyrillic + | '\u04a6' // Cyrillic + | '\u04a8' // Cyrillic + | '\u04aa' // Cyrillic + | '\u04ac' // Cyrillic + | '\u04ae' // Cyrillic + | '\u04b0' // Cyrillic + | '\u04b2' // Cyrillic + | '\u04b4' // Cyrillic + | '\u04b6' // Cyrillic + | '\u04b8' // Cyrillic + | '\u04ba' // Cyrillic + | '\u04bc' // Cyrillic + | '\u04be' // Cyrillic + | '\u04c0' ..'\u04c1' // Cyrillic + | '\u04c3' // Cyrillic + | '\u04c5' // Cyrillic + | '\u04c7' // Cyrillic + | '\u04c9' // Cyrillic + | '\u04cb' // Cyrillic + | '\u04cd' // Cyrillic + | '\u04d0' // Cyrillic + | '\u04d2' // Cyrillic + | '\u04d4' // Cyrillic + | '\u04d6' // Cyrillic + | '\u04d8' // Cyrillic + | '\u04da' // Cyrillic + | '\u04dc' // Cyrillic + | '\u04de' // Cyrillic + | '\u04e0' // Cyrillic + | '\u04e2' // Cyrillic + | '\u04e4' // Cyrillic + | '\u04e6' // Cyrillic + | '\u04e8' // Cyrillic + | '\u04ea' // Cyrillic + | '\u04ec' // Cyrillic + | '\u04ee' // Cyrillic + | '\u04f0' // Cyrillic + | '\u04f2' // Cyrillic + | '\u04f4' // Cyrillic + | '\u04f6' // Cyrillic + | '\u04f8' // Cyrillic + | '\u04fa' // Cyrillic + | '\u04fc' // Cyrillic + | '\u04fe' // Cyrillic + | '\u0500' // Cyrillic_Supplement + | '\u0502' // Cyrillic_Supplement + | '\u0504' // Cyrillic_Supplement + | '\u0506' // Cyrillic_Supplement + | '\u0508' // Cyrillic_Supplement + | '\u050a' // Cyrillic_Supplement + | '\u050c' // Cyrillic_Supplement + | '\u050e' // Cyrillic_Supplement + | '\u0510' // Cyrillic_Supplement + | '\u0512' // Cyrillic_Supplement + | '\u0514' // Cyrillic_Supplement + | '\u0516' // Cyrillic_Supplement + | '\u0518' // Cyrillic_Supplement + | '\u051a' // Cyrillic_Supplement + | '\u051c' // Cyrillic_Supplement + | '\u051e' // Cyrillic_Supplement + | '\u0520' // Cyrillic_Supplement + | '\u0522' // Cyrillic_Supplement + | '\u0524' // Cyrillic_Supplement + | '\u0526' // Cyrillic_Supplement + | '\u0528' // Cyrillic_Supplement + | '\u052a' // Cyrillic_Supplement + | '\u052c' // Cyrillic_Supplement + | '\u052e' // Cyrillic_Supplement + | '\u0531' ..'\u0556' // Armenian + | '\u10a0' ..'\u10c5' // Georgian + | '\u10c7' // Georgian + | '\u10cd' // Georgian + | '\u13a0' ..'\u13f5' // Cherokee + | '\u1e00' // Latin_Extended_Additional + | '\u1e02' // Latin_Extended_Additional + | '\u1e04' // Latin_Extended_Additional + | '\u1e06' // Latin_Extended_Additional + | '\u1e08' // Latin_Extended_Additional + | '\u1e0a' // Latin_Extended_Additional + | '\u1e0c' // Latin_Extended_Additional + | '\u1e0e' // Latin_Extended_Additional + | '\u1e10' // Latin_Extended_Additional + | '\u1e12' // Latin_Extended_Additional + | '\u1e14' // Latin_Extended_Additional + | '\u1e16' // Latin_Extended_Additional + | '\u1e18' // Latin_Extended_Additional + | '\u1e1a' // Latin_Extended_Additional + | '\u1e1c' // Latin_Extended_Additional + | '\u1e1e' // Latin_Extended_Additional + | '\u1e20' // Latin_Extended_Additional + | '\u1e22' // Latin_Extended_Additional + | '\u1e24' // Latin_Extended_Additional + | '\u1e26' // Latin_Extended_Additional + | '\u1e28' // Latin_Extended_Additional + | '\u1e2a' // Latin_Extended_Additional + | '\u1e2c' // Latin_Extended_Additional + | '\u1e2e' // Latin_Extended_Additional + | '\u1e30' // Latin_Extended_Additional + | '\u1e32' // Latin_Extended_Additional + | '\u1e34' // Latin_Extended_Additional + | '\u1e36' // Latin_Extended_Additional + | '\u1e38' // Latin_Extended_Additional + | '\u1e3a' // Latin_Extended_Additional + | '\u1e3c' // Latin_Extended_Additional + | '\u1e3e' // Latin_Extended_Additional + | '\u1e40' // Latin_Extended_Additional + | '\u1e42' // Latin_Extended_Additional + | '\u1e44' // Latin_Extended_Additional + | '\u1e46' // Latin_Extended_Additional + | '\u1e48' // Latin_Extended_Additional + | '\u1e4a' // Latin_Extended_Additional + | '\u1e4c' // Latin_Extended_Additional + | '\u1e4e' // Latin_Extended_Additional + | '\u1e50' // Latin_Extended_Additional + | '\u1e52' // Latin_Extended_Additional + | '\u1e54' // Latin_Extended_Additional + | '\u1e56' // Latin_Extended_Additional + | '\u1e58' // Latin_Extended_Additional + | '\u1e5a' // Latin_Extended_Additional + | '\u1e5c' // Latin_Extended_Additional + | '\u1e5e' // Latin_Extended_Additional + | '\u1e60' // Latin_Extended_Additional + | '\u1e62' // Latin_Extended_Additional + | '\u1e64' // Latin_Extended_Additional + | '\u1e66' // Latin_Extended_Additional + | '\u1e68' // Latin_Extended_Additional + | '\u1e6a' // Latin_Extended_Additional + | '\u1e6c' // Latin_Extended_Additional + | '\u1e6e' // Latin_Extended_Additional + | '\u1e70' // Latin_Extended_Additional + | '\u1e72' // Latin_Extended_Additional + | '\u1e74' // Latin_Extended_Additional + | '\u1e76' // Latin_Extended_Additional + | '\u1e78' // Latin_Extended_Additional + | '\u1e7a' // Latin_Extended_Additional + | '\u1e7c' // Latin_Extended_Additional + | '\u1e7e' // Latin_Extended_Additional + | '\u1e80' // Latin_Extended_Additional + | '\u1e82' // Latin_Extended_Additional + | '\u1e84' // Latin_Extended_Additional + | '\u1e86' // Latin_Extended_Additional + | '\u1e88' // Latin_Extended_Additional + | '\u1e8a' // Latin_Extended_Additional + | '\u1e8c' // Latin_Extended_Additional + | '\u1e8e' // Latin_Extended_Additional + | '\u1e90' // Latin_Extended_Additional + | '\u1e92' // Latin_Extended_Additional + | '\u1e94' // Latin_Extended_Additional + | '\u1e9e' // Latin_Extended_Additional + | '\u1ea0' // Latin_Extended_Additional + | '\u1ea2' // Latin_Extended_Additional + | '\u1ea4' // Latin_Extended_Additional + | '\u1ea6' // Latin_Extended_Additional + | '\u1ea8' // Latin_Extended_Additional + | '\u1eaa' // Latin_Extended_Additional + | '\u1eac' // Latin_Extended_Additional + | '\u1eae' // Latin_Extended_Additional + | '\u1eb0' // Latin_Extended_Additional + | '\u1eb2' // Latin_Extended_Additional + | '\u1eb4' // Latin_Extended_Additional + | '\u1eb6' // Latin_Extended_Additional + | '\u1eb8' // Latin_Extended_Additional + | '\u1eba' // Latin_Extended_Additional + | '\u1ebc' // Latin_Extended_Additional + | '\u1ebe' // Latin_Extended_Additional + | '\u1ec0' // Latin_Extended_Additional + | '\u1ec2' // Latin_Extended_Additional + | '\u1ec4' // Latin_Extended_Additional + | '\u1ec6' // Latin_Extended_Additional + | '\u1ec8' // Latin_Extended_Additional + | '\u1eca' // Latin_Extended_Additional + | '\u1ecc' // Latin_Extended_Additional + | '\u1ece' // Latin_Extended_Additional + | '\u1ed0' // Latin_Extended_Additional + | '\u1ed2' // Latin_Extended_Additional + | '\u1ed4' // Latin_Extended_Additional + | '\u1ed6' // Latin_Extended_Additional + | '\u1ed8' // Latin_Extended_Additional + | '\u1eda' // Latin_Extended_Additional + | '\u1edc' // Latin_Extended_Additional + | '\u1ede' // Latin_Extended_Additional + | '\u1ee0' // Latin_Extended_Additional + | '\u1ee2' // Latin_Extended_Additional + | '\u1ee4' // Latin_Extended_Additional + | '\u1ee6' // Latin_Extended_Additional + | '\u1ee8' // Latin_Extended_Additional + | '\u1eea' // Latin_Extended_Additional + | '\u1eec' // Latin_Extended_Additional + | '\u1eee' // Latin_Extended_Additional + | '\u1ef0' // Latin_Extended_Additional + | '\u1ef2' // Latin_Extended_Additional + | '\u1ef4' // Latin_Extended_Additional + | '\u1ef6' // Latin_Extended_Additional + | '\u1ef8' // Latin_Extended_Additional + | '\u1efa' // Latin_Extended_Additional + | '\u1efc' // Latin_Extended_Additional + | '\u1efe' // Latin_Extended_Additional + | '\u1f08' ..'\u1f0f' // Greek_Extended + | '\u1f18' ..'\u1f1d' // Greek_Extended + | '\u1f28' ..'\u1f2f' // Greek_Extended + | '\u1f38' ..'\u1f3f' // Greek_Extended + | '\u1f48' ..'\u1f4d' // Greek_Extended + | '\u1f59' // Greek_Extended + | '\u1f5b' // Greek_Extended + | '\u1f5d' // Greek_Extended + | '\u1f5f' // Greek_Extended + | '\u1f68' ..'\u1f6f' // Greek_Extended + | '\u1fb8' ..'\u1fbb' // Greek_Extended + | '\u1fc8' ..'\u1fcb' // Greek_Extended + | '\u1fd8' ..'\u1fdb' // Greek_Extended + | '\u1fe8' ..'\u1fec' // Greek_Extended + | '\u1ff8' ..'\u1ffb' // Greek_Extended + | '\u2102' // Letterlike_Symbols + | '\u2107' // Letterlike_Symbols + | '\u210b' ..'\u210d' // Letterlike_Symbols + | '\u2110' ..'\u2112' // Letterlike_Symbols + | '\u2115' // Letterlike_Symbols + | '\u2119' ..'\u211d' // Letterlike_Symbols + | '\u2124' // Letterlike_Symbols + | '\u2126' // Letterlike_Symbols + | '\u2128' // Letterlike_Symbols + | '\u212a' ..'\u212d' // Letterlike_Symbols + | '\u2130' ..'\u2133' // Letterlike_Symbols + | '\u213e' ..'\u213f' // Letterlike_Symbols + | '\u2145' // Letterlike_Symbols + | '\u2183' // Number_Forms + | '\u2c00' ..'\u2c2e' // Glagolitic + | '\u2c60' // Latin_Extended-C + | '\u2c62' ..'\u2c64' // Latin_Extended-C + | '\u2c67' // Latin_Extended-C + | '\u2c69' // Latin_Extended-C + | '\u2c6b' // Latin_Extended-C + | '\u2c6d' ..'\u2c70' // Latin_Extended-C + | '\u2c72' // Latin_Extended-C + | '\u2c75' // Latin_Extended-C + | '\u2c7e' ..'\u2c80' // Latin_Extended-C + | '\u2c82' // Coptic + | '\u2c84' // Coptic + | '\u2c86' // Coptic + | '\u2c88' // Coptic + | '\u2c8a' // Coptic + | '\u2c8c' // Coptic + | '\u2c8e' // Coptic + | '\u2c90' // Coptic + | '\u2c92' // Coptic + | '\u2c94' // Coptic + | '\u2c96' // Coptic + | '\u2c98' // Coptic + | '\u2c9a' // Coptic + | '\u2c9c' // Coptic + | '\u2c9e' // Coptic + | '\u2ca0' // Coptic + | '\u2ca2' // Coptic + | '\u2ca4' // Coptic + | '\u2ca6' // Coptic + | '\u2ca8' // Coptic + | '\u2caa' // Coptic + | '\u2cac' // Coptic + | '\u2cae' // Coptic + | '\u2cb0' // Coptic + | '\u2cb2' // Coptic + | '\u2cb4' // Coptic + | '\u2cb6' // Coptic + | '\u2cb8' // Coptic + | '\u2cba' // Coptic + | '\u2cbc' // Coptic + | '\u2cbe' // Coptic + | '\u2cc0' // Coptic + | '\u2cc2' // Coptic + | '\u2cc4' // Coptic + | '\u2cc6' // Coptic + | '\u2cc8' // Coptic + | '\u2cca' // Coptic + | '\u2ccc' // Coptic + | '\u2cce' // Coptic + | '\u2cd0' // Coptic + | '\u2cd2' // Coptic + | '\u2cd4' // Coptic + | '\u2cd6' // Coptic + | '\u2cd8' // Coptic + | '\u2cda' // Coptic + | '\u2cdc' // Coptic + | '\u2cde' // Coptic + | '\u2ce0' // Coptic + | '\u2ce2' // Coptic + | '\u2ceb' // Coptic + | '\u2ced' // Coptic + | '\u2cf2' // Coptic + | '\ua640' // Cyrillic_Extended-B + | '\ua642' // Cyrillic_Extended-B + | '\ua644' // Cyrillic_Extended-B + | '\ua646' // Cyrillic_Extended-B + | '\ua648' // Cyrillic_Extended-B + | '\ua64a' // Cyrillic_Extended-B + | '\ua64c' // Cyrillic_Extended-B + | '\ua64e' // Cyrillic_Extended-B + | '\ua650' // Cyrillic_Extended-B + | '\ua652' // Cyrillic_Extended-B + | '\ua654' // Cyrillic_Extended-B + | '\ua656' // Cyrillic_Extended-B + | '\ua658' // Cyrillic_Extended-B + | '\ua65a' // Cyrillic_Extended-B + | '\ua65c' // Cyrillic_Extended-B + | '\ua65e' // Cyrillic_Extended-B + | '\ua660' // Cyrillic_Extended-B + | '\ua662' // Cyrillic_Extended-B + | '\ua664' // Cyrillic_Extended-B + | '\ua666' // Cyrillic_Extended-B + | '\ua668' // Cyrillic_Extended-B + | '\ua66a' // Cyrillic_Extended-B + | '\ua66c' // Cyrillic_Extended-B + | '\ua680' // Cyrillic_Extended-B + | '\ua682' // Cyrillic_Extended-B + | '\ua684' // Cyrillic_Extended-B + | '\ua686' // Cyrillic_Extended-B + | '\ua688' // Cyrillic_Extended-B + | '\ua68a' // Cyrillic_Extended-B + | '\ua68c' // Cyrillic_Extended-B + | '\ua68e' // Cyrillic_Extended-B + | '\ua690' // Cyrillic_Extended-B + | '\ua692' // Cyrillic_Extended-B + | '\ua694' // Cyrillic_Extended-B + | '\ua696' // Cyrillic_Extended-B + | '\ua698' // Cyrillic_Extended-B + | '\ua69a' // Cyrillic_Extended-B + | '\ua722' // Latin_Extended-D + | '\ua724' // Latin_Extended-D + | '\ua726' // Latin_Extended-D + | '\ua728' // Latin_Extended-D + | '\ua72a' // Latin_Extended-D + | '\ua72c' // Latin_Extended-D + | '\ua72e' // Latin_Extended-D + | '\ua732' // Latin_Extended-D + | '\ua734' // Latin_Extended-D + | '\ua736' // Latin_Extended-D + | '\ua738' // Latin_Extended-D + | '\ua73a' // Latin_Extended-D + | '\ua73c' // Latin_Extended-D + | '\ua73e' // Latin_Extended-D + | '\ua740' // Latin_Extended-D + | '\ua742' // Latin_Extended-D + | '\ua744' // Latin_Extended-D + | '\ua746' // Latin_Extended-D + | '\ua748' // Latin_Extended-D + | '\ua74a' // Latin_Extended-D + | '\ua74c' // Latin_Extended-D + | '\ua74e' // Latin_Extended-D + | '\ua750' // Latin_Extended-D + | '\ua752' // Latin_Extended-D + | '\ua754' // Latin_Extended-D + | '\ua756' // Latin_Extended-D + | '\ua758' // Latin_Extended-D + | '\ua75a' // Latin_Extended-D + | '\ua75c' // Latin_Extended-D + | '\ua75e' // Latin_Extended-D + | '\ua760' // Latin_Extended-D + | '\ua762' // Latin_Extended-D + | '\ua764' // Latin_Extended-D + | '\ua766' // Latin_Extended-D + | '\ua768' // Latin_Extended-D + | '\ua76a' // Latin_Extended-D + | '\ua76c' // Latin_Extended-D + | '\ua76e' // Latin_Extended-D + | '\ua779' // Latin_Extended-D + | '\ua77b' // Latin_Extended-D + | '\ua77d' ..'\ua77e' // Latin_Extended-D + | '\ua780' // Latin_Extended-D + | '\ua782' // Latin_Extended-D + | '\ua784' // Latin_Extended-D + | '\ua786' // Latin_Extended-D + | '\ua78b' // Latin_Extended-D + | '\ua78d' // Latin_Extended-D + | '\ua790' // Latin_Extended-D + | '\ua792' // Latin_Extended-D + | '\ua796' // Latin_Extended-D + | '\ua798' // Latin_Extended-D + | '\ua79a' // Latin_Extended-D + | '\ua79c' // Latin_Extended-D + | '\ua79e' // Latin_Extended-D + | '\ua7a0' // Latin_Extended-D + | '\ua7a2' // Latin_Extended-D + | '\ua7a4' // Latin_Extended-D + | '\ua7a6' // Latin_Extended-D + | '\ua7a8' // Latin_Extended-D + | '\ua7aa' ..'\ua7ae' // Latin_Extended-D + | '\ua7b0' ..'\ua7b4' // Latin_Extended-D + | '\ua7b6' // Latin_Extended-D + | '\uff21' ..'\uff3a' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Mc: - '\u0903' // Devanagari - | '\u093b' // Devanagari - | '\u093e'..'\u0940' // Devanagari - | '\u0949'..'\u094c' // Devanagari - | '\u094e'..'\u094f' // Devanagari - | '\u0982'..'\u0983' // Bengali - | '\u09be'..'\u09c0' // Bengali - | '\u09c7'..'\u09c8' // Bengali - | '\u09cb'..'\u09cc' // Bengali - | '\u09d7' // Bengali - | '\u0a03' // Gurmukhi - | '\u0a3e'..'\u0a40' // Gurmukhi - | '\u0a83' // Gujarati - | '\u0abe'..'\u0ac0' // Gujarati - | '\u0ac9' // Gujarati - | '\u0acb'..'\u0acc' // Gujarati - | '\u0b02'..'\u0b03' // Oriya - | '\u0b3e' // Oriya - | '\u0b40' // Oriya - | '\u0b47'..'\u0b48' // Oriya - | '\u0b4b'..'\u0b4c' // Oriya - | '\u0b57' // Oriya - | '\u0bbe'..'\u0bbf' // Tamil - | '\u0bc1'..'\u0bc2' // Tamil - | '\u0bc6'..'\u0bc8' // Tamil - | '\u0bca'..'\u0bcc' // Tamil - | '\u0bd7' // Tamil - | '\u0c01'..'\u0c03' // Telugu - | '\u0c41'..'\u0c44' // Telugu - | '\u0c82'..'\u0c83' // Kannada - | '\u0cbe' // Kannada - | '\u0cc0'..'\u0cc4' // Kannada - | '\u0cc7'..'\u0cc8' // Kannada - | '\u0cca'..'\u0ccb' // Kannada - | '\u0cd5'..'\u0cd6' // Kannada - | '\u0d02'..'\u0d03' // Malayalam - | '\u0d3e'..'\u0d40' // Malayalam - | '\u0d46'..'\u0d48' // Malayalam - | '\u0d4a'..'\u0d4c' // Malayalam - | '\u0d57' // Malayalam - | '\u0d82'..'\u0d83' // Sinhala - | '\u0dcf'..'\u0dd1' // Sinhala - | '\u0dd8'..'\u0ddf' // Sinhala - | '\u0df2'..'\u0df3' // Sinhala - | '\u0f3e'..'\u0f3f' // Tibetan - | '\u0f7f' // Tibetan - | '\u102b'..'\u102c' // Myanmar - | '\u1031' // Myanmar - | '\u1038' // Myanmar - | '\u103b'..'\u103c' // Myanmar - | '\u1056'..'\u1057' // Myanmar - | '\u1062'..'\u1064' // Myanmar - | '\u1067'..'\u106d' // Myanmar - | '\u1083'..'\u1084' // Myanmar - | '\u1087'..'\u108c' // Myanmar - | '\u108f' // Myanmar - | '\u109a'..'\u109c' // Myanmar - | '\u17b6' // Khmer - | '\u17be'..'\u17c5' // Khmer - | '\u17c7'..'\u17c8' // Khmer - | '\u1923'..'\u1926' // Limbu - | '\u1929'..'\u192b' // Limbu - | '\u1930'..'\u1931' // Limbu - | '\u1933'..'\u1938' // Limbu - | '\u1a19'..'\u1a1a' // Buginese - | '\u1a55' // Tai_Tham - | '\u1a57' // Tai_Tham - | '\u1a61' // Tai_Tham - | '\u1a63'..'\u1a64' // Tai_Tham - | '\u1a6d'..'\u1a72' // Tai_Tham - | '\u1b04' // Balinese - | '\u1b35' // Balinese - | '\u1b3b' // Balinese - | '\u1b3d'..'\u1b41' // Balinese - | '\u1b43'..'\u1b44' // Balinese - | '\u1b82' // Sundanese - | '\u1ba1' // Sundanese - | '\u1ba6'..'\u1ba7' // Sundanese - | '\u1baa' // Sundanese - | '\u1be7' // Batak - | '\u1bea'..'\u1bec' // Batak - | '\u1bee' // Batak - | '\u1bf2'..'\u1bf3' // Batak - | '\u1c24'..'\u1c2b' // Lepcha - | '\u1c34'..'\u1c35' // Lepcha - | '\u1ce1' // Vedic_Extensions - | '\u1cf2'..'\u1cf3' // Vedic_Extensions - | '\u302e'..'\u302f' // CJK_Symbols_and_Punctuation - | '\ua823'..'\ua824' // Syloti_Nagri - | '\ua827' // Syloti_Nagri - | '\ua880'..'\ua881' // Saurashtra - | '\ua8b4'..'\ua8c3' // Saurashtra - | '\ua952'..'\ua953' // Rejang - | '\ua983' // Javanese - | '\ua9b4'..'\ua9b5' // Javanese - | '\ua9ba'..'\ua9bb' // Javanese - | '\ua9bd'..'\ua9c0' // Javanese - | '\uaa2f'..'\uaa30' // Cham - | '\uaa33'..'\uaa34' // Cham - | '\uaa4d' // Cham - | '\uaa7b' // Myanmar_Extended-A - | '\uaa7d' // Myanmar_Extended-A - | '\uaaeb' // Meetei_Mayek_Extensions - | '\uaaee'..'\uaaef' // Meetei_Mayek_Extensions - | '\uaaf5' // Meetei_Mayek_Extensions - | '\uabe3'..'\uabe4' // Meetei_Mayek - | '\uabe6'..'\uabe7' // Meetei_Mayek - | '\uabe9'..'\uabea' // Meetei_Mayek - | '\uabec' // Meetei_Mayek -; +CLASSIFY_Mc + : '\u0903' // Devanagari + | '\u093b' // Devanagari + | '\u093e' ..'\u0940' // Devanagari + | '\u0949' ..'\u094c' // Devanagari + | '\u094e' ..'\u094f' // Devanagari + | '\u0982' ..'\u0983' // Bengali + | '\u09be' ..'\u09c0' // Bengali + | '\u09c7' ..'\u09c8' // Bengali + | '\u09cb' ..'\u09cc' // Bengali + | '\u09d7' // Bengali + | '\u0a03' // Gurmukhi + | '\u0a3e' ..'\u0a40' // Gurmukhi + | '\u0a83' // Gujarati + | '\u0abe' ..'\u0ac0' // Gujarati + | '\u0ac9' // Gujarati + | '\u0acb' ..'\u0acc' // Gujarati + | '\u0b02' ..'\u0b03' // Oriya + | '\u0b3e' // Oriya + | '\u0b40' // Oriya + | '\u0b47' ..'\u0b48' // Oriya + | '\u0b4b' ..'\u0b4c' // Oriya + | '\u0b57' // Oriya + | '\u0bbe' ..'\u0bbf' // Tamil + | '\u0bc1' ..'\u0bc2' // Tamil + | '\u0bc6' ..'\u0bc8' // Tamil + | '\u0bca' ..'\u0bcc' // Tamil + | '\u0bd7' // Tamil + | '\u0c01' ..'\u0c03' // Telugu + | '\u0c41' ..'\u0c44' // Telugu + | '\u0c82' ..'\u0c83' // Kannada + | '\u0cbe' // Kannada + | '\u0cc0' ..'\u0cc4' // Kannada + | '\u0cc7' ..'\u0cc8' // Kannada + | '\u0cca' ..'\u0ccb' // Kannada + | '\u0cd5' ..'\u0cd6' // Kannada + | '\u0d02' ..'\u0d03' // Malayalam + | '\u0d3e' ..'\u0d40' // Malayalam + | '\u0d46' ..'\u0d48' // Malayalam + | '\u0d4a' ..'\u0d4c' // Malayalam + | '\u0d57' // Malayalam + | '\u0d82' ..'\u0d83' // Sinhala + | '\u0dcf' ..'\u0dd1' // Sinhala + | '\u0dd8' ..'\u0ddf' // Sinhala + | '\u0df2' ..'\u0df3' // Sinhala + | '\u0f3e' ..'\u0f3f' // Tibetan + | '\u0f7f' // Tibetan + | '\u102b' ..'\u102c' // Myanmar + | '\u1031' // Myanmar + | '\u1038' // Myanmar + | '\u103b' ..'\u103c' // Myanmar + | '\u1056' ..'\u1057' // Myanmar + | '\u1062' ..'\u1064' // Myanmar + | '\u1067' ..'\u106d' // Myanmar + | '\u1083' ..'\u1084' // Myanmar + | '\u1087' ..'\u108c' // Myanmar + | '\u108f' // Myanmar + | '\u109a' ..'\u109c' // Myanmar + | '\u17b6' // Khmer + | '\u17be' ..'\u17c5' // Khmer + | '\u17c7' ..'\u17c8' // Khmer + | '\u1923' ..'\u1926' // Limbu + | '\u1929' ..'\u192b' // Limbu + | '\u1930' ..'\u1931' // Limbu + | '\u1933' ..'\u1938' // Limbu + | '\u1a19' ..'\u1a1a' // Buginese + | '\u1a55' // Tai_Tham + | '\u1a57' // Tai_Tham + | '\u1a61' // Tai_Tham + | '\u1a63' ..'\u1a64' // Tai_Tham + | '\u1a6d' ..'\u1a72' // Tai_Tham + | '\u1b04' // Balinese + | '\u1b35' // Balinese + | '\u1b3b' // Balinese + | '\u1b3d' ..'\u1b41' // Balinese + | '\u1b43' ..'\u1b44' // Balinese + | '\u1b82' // Sundanese + | '\u1ba1' // Sundanese + | '\u1ba6' ..'\u1ba7' // Sundanese + | '\u1baa' // Sundanese + | '\u1be7' // Batak + | '\u1bea' ..'\u1bec' // Batak + | '\u1bee' // Batak + | '\u1bf2' ..'\u1bf3' // Batak + | '\u1c24' ..'\u1c2b' // Lepcha + | '\u1c34' ..'\u1c35' // Lepcha + | '\u1ce1' // Vedic_Extensions + | '\u1cf2' ..'\u1cf3' // Vedic_Extensions + | '\u302e' ..'\u302f' // CJK_Symbols_and_Punctuation + | '\ua823' ..'\ua824' // Syloti_Nagri + | '\ua827' // Syloti_Nagri + | '\ua880' ..'\ua881' // Saurashtra + | '\ua8b4' ..'\ua8c3' // Saurashtra + | '\ua952' ..'\ua953' // Rejang + | '\ua983' // Javanese + | '\ua9b4' ..'\ua9b5' // Javanese + | '\ua9ba' ..'\ua9bb' // Javanese + | '\ua9bd' ..'\ua9c0' // Javanese + | '\uaa2f' ..'\uaa30' // Cham + | '\uaa33' ..'\uaa34' // Cham + | '\uaa4d' // Cham + | '\uaa7b' // Myanmar_Extended-A + | '\uaa7d' // Myanmar_Extended-A + | '\uaaeb' // Meetei_Mayek_Extensions + | '\uaaee' ..'\uaaef' // Meetei_Mayek_Extensions + | '\uaaf5' // Meetei_Mayek_Extensions + | '\uabe3' ..'\uabe4' // Meetei_Mayek + | '\uabe6' ..'\uabe7' // Meetei_Mayek + | '\uabe9' ..'\uabea' // Meetei_Mayek + | '\uabec' // Meetei_Mayek + ; -CLASSIFY_Me: - '\u0488'..'\u0489' // Cyrillic - | '\u1abe' // Combining_Diacritical_Marks_Extended - | '\u20dd'..'\u20e0' // Combining_Diacritical_Marks_for_Symbols - | '\u20e2'..'\u20e4' // Combining_Diacritical_Marks_for_Symbols - | '\ua670'..'\ua672' // Cyrillic_Extended-B -; +CLASSIFY_Me + : '\u0488' ..'\u0489' // Cyrillic + | '\u1abe' // Combining_Diacritical_Marks_Extended + | '\u20dd' ..'\u20e0' // Combining_Diacritical_Marks_for_Symbols + | '\u20e2' ..'\u20e4' // Combining_Diacritical_Marks_for_Symbols + | '\ua670' ..'\ua672' // Cyrillic_Extended-B + ; -CLASSIFY_Mn: - '\u0300'..'\u036f' // Combining_Diacritical_Marks - | '\u0483'..'\u0487' // Cyrillic - | '\u0591'..'\u05bd' // Hebrew - | '\u05bf' // Hebrew - | '\u05c1'..'\u05c2' // Hebrew - | '\u05c4'..'\u05c5' // Hebrew - | '\u05c7' // Hebrew - | '\u0610'..'\u061a' // Arabic - | '\u064b'..'\u065f' // Arabic - | '\u0670' // Arabic - | '\u06d6'..'\u06dc' // Arabic - | '\u06df'..'\u06e4' // Arabic - | '\u06e7'..'\u06e8' // Arabic - | '\u06ea'..'\u06ed' // Arabic - | '\u0711' // Syriac - | '\u0730'..'\u074a' // Syriac - | '\u07a6'..'\u07b0' // Thaana - | '\u07eb'..'\u07f3' // NKo - | '\u0816'..'\u0819' // Samaritan - | '\u081b'..'\u0823' // Samaritan - | '\u0825'..'\u0827' // Samaritan - | '\u0829'..'\u082d' // Samaritan - | '\u0859'..'\u085b' // Mandaic - | '\u08d4'..'\u08e1' // Arabic_Extended-A - | '\u08e3'..'\u0902' // Arabic_Extended-A - | '\u093a' // Devanagari - | '\u093c' // Devanagari - | '\u0941'..'\u0948' // Devanagari - | '\u094d' // Devanagari - | '\u0951'..'\u0957' // Devanagari - | '\u0962'..'\u0963' // Devanagari - | '\u0981' // Bengali - | '\u09bc' // Bengali - | '\u09c1'..'\u09c4' // Bengali - | '\u09cd' // Bengali - | '\u09e2'..'\u09e3' // Bengali - | '\u0a01'..'\u0a02' // Gurmukhi - | '\u0a3c' // Gurmukhi - | '\u0a41'..'\u0a42' // Gurmukhi - | '\u0a47'..'\u0a48' // Gurmukhi - | '\u0a4b'..'\u0a4d' // Gurmukhi - | '\u0a51' // Gurmukhi - | '\u0a70'..'\u0a71' // Gurmukhi - | '\u0a75' // Gurmukhi - | '\u0a81'..'\u0a82' // Gujarati - | '\u0abc' // Gujarati - | '\u0ac1'..'\u0ac5' // Gujarati - | '\u0ac7'..'\u0ac8' // Gujarati - | '\u0acd' // Gujarati - | '\u0ae2'..'\u0ae3' // Gujarati - | '\u0b01' // Oriya - | '\u0b3c' // Oriya - | '\u0b3f' // Oriya - | '\u0b41'..'\u0b44' // Oriya - | '\u0b4d' // Oriya - | '\u0b56' // Oriya - | '\u0b62'..'\u0b63' // Oriya - | '\u0b82' // Tamil - | '\u0bc0' // Tamil - | '\u0bcd' // Tamil - | '\u0c00' // Telugu - | '\u0c3e'..'\u0c40' // Telugu - | '\u0c46'..'\u0c48' // Telugu - | '\u0c4a'..'\u0c4d' // Telugu - | '\u0c55'..'\u0c56' // Telugu - | '\u0c62'..'\u0c63' // Telugu - | '\u0c81' // Kannada - | '\u0cbc' // Kannada - | '\u0cbf' // Kannada - | '\u0cc6' // Kannada - | '\u0ccc'..'\u0ccd' // Kannada - | '\u0ce2'..'\u0ce3' // Kannada - | '\u0d01' // Malayalam - | '\u0d41'..'\u0d44' // Malayalam - | '\u0d4d' // Malayalam - | '\u0d62'..'\u0d63' // Malayalam - | '\u0dca' // Sinhala - | '\u0dd2'..'\u0dd4' // Sinhala - | '\u0dd6' // Sinhala - | '\u0e31' // Thai - | '\u0e34'..'\u0e3a' // Thai - | '\u0e47'..'\u0e4e' // Thai - | '\u0eb1' // Lao - | '\u0eb4'..'\u0eb9' // Lao - | '\u0ebb'..'\u0ebc' // Lao - | '\u0ec8'..'\u0ecd' // Lao - | '\u0f18'..'\u0f19' // Tibetan - | '\u0f35' // Tibetan - | '\u0f37' // Tibetan - | '\u0f39' // Tibetan - | '\u0f71'..'\u0f7e' // Tibetan - | '\u0f80'..'\u0f84' // Tibetan - | '\u0f86'..'\u0f87' // Tibetan - | '\u0f8d'..'\u0f97' // Tibetan - | '\u0f99'..'\u0fbc' // Tibetan - | '\u0fc6' // Tibetan - | '\u102d'..'\u1030' // Myanmar - | '\u1032'..'\u1037' // Myanmar - | '\u1039'..'\u103a' // Myanmar - | '\u103d'..'\u103e' // Myanmar - | '\u1058'..'\u1059' // Myanmar - | '\u105e'..'\u1060' // Myanmar - | '\u1071'..'\u1074' // Myanmar - | '\u1082' // Myanmar - | '\u1085'..'\u1086' // Myanmar - | '\u108d' // Myanmar - | '\u109d' // Myanmar - | '\u135d'..'\u135f' // Ethiopic - | '\u1712'..'\u1714' // Tagalog - | '\u1732'..'\u1734' // Hanunoo - | '\u1752'..'\u1753' // Buhid - | '\u1772'..'\u1773' // Tagbanwa - | '\u17b4'..'\u17b5' // Khmer - | '\u17b7'..'\u17bd' // Khmer - | '\u17c6' // Khmer - | '\u17c9'..'\u17d3' // Khmer - | '\u17dd' // Khmer - | '\u180b'..'\u180d' // Mongolian - | '\u1885'..'\u1886' // Mongolian - | '\u18a9' // Mongolian - | '\u1920'..'\u1922' // Limbu - | '\u1927'..'\u1928' // Limbu - | '\u1932' // Limbu - | '\u1939'..'\u193b' // Limbu - | '\u1a17'..'\u1a18' // Buginese - | '\u1a1b' // Buginese - | '\u1a56' // Tai_Tham - | '\u1a58'..'\u1a5e' // Tai_Tham - | '\u1a60' // Tai_Tham - | '\u1a62' // Tai_Tham - | '\u1a65'..'\u1a6c' // Tai_Tham - | '\u1a73'..'\u1a7c' // Tai_Tham - | '\u1a7f' // Tai_Tham - | '\u1ab0'..'\u1abd' // Combining_Diacritical_Marks_Extended - | '\u1b00'..'\u1b03' // Balinese - | '\u1b34' // Balinese - | '\u1b36'..'\u1b3a' // Balinese - | '\u1b3c' // Balinese - | '\u1b42' // Balinese - | '\u1b6b'..'\u1b73' // Balinese - | '\u1b80'..'\u1b81' // Sundanese - | '\u1ba2'..'\u1ba5' // Sundanese - | '\u1ba8'..'\u1ba9' // Sundanese - | '\u1bab'..'\u1bad' // Sundanese - | '\u1be6' // Batak - | '\u1be8'..'\u1be9' // Batak - | '\u1bed' // Batak - | '\u1bef'..'\u1bf1' // Batak - | '\u1c2c'..'\u1c33' // Lepcha - | '\u1c36'..'\u1c37' // Lepcha - | '\u1cd0'..'\u1cd2' // Vedic_Extensions - | '\u1cd4'..'\u1ce0' // Vedic_Extensions - | '\u1ce2'..'\u1ce8' // Vedic_Extensions - | '\u1ced' // Vedic_Extensions - | '\u1cf4' // Vedic_Extensions - | '\u1cf8'..'\u1cf9' // Vedic_Extensions - | '\u1dc0'..'\u1df5' // Combining_Diacritical_Marks_Supplement - | '\u1dfb'..'\u1dff' // Combining_Diacritical_Marks_Supplement - | '\u20d0'..'\u20dc' // Combining_Diacritical_Marks_for_Symbols - | '\u20e1' // Combining_Diacritical_Marks_for_Symbols - | '\u20e5'..'\u20f0' // Combining_Diacritical_Marks_for_Symbols - | '\u2cef'..'\u2cf1' // Coptic - | '\u2d7f' // (Absent from Blocks.txt) - | '\u2de0'..'\u2dff' // Cyrillic_Extended-A - | '\u302a'..'\u302d' // CJK_Symbols_and_Punctuation - | '\u3099'..'\u309a' // Hiragana - | '\ua66f' // Cyrillic_Extended-B - | '\ua674'..'\ua67d' // Cyrillic_Extended-B - | '\ua69e'..'\ua69f' // Cyrillic_Extended-B - | '\ua6f0'..'\ua6f1' // Bamum - | '\ua802' // Syloti_Nagri - | '\ua806' // Syloti_Nagri - | '\ua80b' // Syloti_Nagri - | '\ua825'..'\ua826' // Syloti_Nagri - | '\ua8c4'..'\ua8c5' // Saurashtra - | '\ua8e0'..'\ua8f1' // Devanagari_Extended - | '\ua926'..'\ua92d' // Kayah_Li - | '\ua947'..'\ua951' // Rejang - | '\ua980'..'\ua982' // Javanese - | '\ua9b3' // Javanese - | '\ua9b6'..'\ua9b9' // Javanese - | '\ua9bc' // Javanese - | '\ua9e5' // Myanmar_Extended-B - | '\uaa29'..'\uaa2e' // Cham - | '\uaa31'..'\uaa32' // Cham - | '\uaa35'..'\uaa36' // Cham - | '\uaa43' // Cham - | '\uaa4c' // Cham - | '\uaa7c' // Myanmar_Extended-A - | '\uaab0' // Tai_Viet - | '\uaab2'..'\uaab4' // Tai_Viet - | '\uaab7'..'\uaab8' // Tai_Viet - | '\uaabe'..'\uaabf' // Tai_Viet - | '\uaac1' // Tai_Viet - | '\uaaec'..'\uaaed' // Meetei_Mayek_Extensions - | '\uaaf6' // Meetei_Mayek_Extensions - | '\uabe5' // Meetei_Mayek - | '\uabe8' // Meetei_Mayek - | '\uabed' // Meetei_Mayek - | '\ufb1e' // Alphabetic_Presentation_Forms - | '\ufe00'..'\ufe0f' // Variation_Selectors - | '\ufe20'..'\ufe2f' // Combining_Half_Marks -; +CLASSIFY_Mn + : '\u0300' ..'\u036f' // Combining_Diacritical_Marks + | '\u0483' ..'\u0487' // Cyrillic + | '\u0591' ..'\u05bd' // Hebrew + | '\u05bf' // Hebrew + | '\u05c1' ..'\u05c2' // Hebrew + | '\u05c4' ..'\u05c5' // Hebrew + | '\u05c7' // Hebrew + | '\u0610' ..'\u061a' // Arabic + | '\u064b' ..'\u065f' // Arabic + | '\u0670' // Arabic + | '\u06d6' ..'\u06dc' // Arabic + | '\u06df' ..'\u06e4' // Arabic + | '\u06e7' ..'\u06e8' // Arabic + | '\u06ea' ..'\u06ed' // Arabic + | '\u0711' // Syriac + | '\u0730' ..'\u074a' // Syriac + | '\u07a6' ..'\u07b0' // Thaana + | '\u07eb' ..'\u07f3' // NKo + | '\u0816' ..'\u0819' // Samaritan + | '\u081b' ..'\u0823' // Samaritan + | '\u0825' ..'\u0827' // Samaritan + | '\u0829' ..'\u082d' // Samaritan + | '\u0859' ..'\u085b' // Mandaic + | '\u08d4' ..'\u08e1' // Arabic_Extended-A + | '\u08e3' ..'\u0902' // Arabic_Extended-A + | '\u093a' // Devanagari + | '\u093c' // Devanagari + | '\u0941' ..'\u0948' // Devanagari + | '\u094d' // Devanagari + | '\u0951' ..'\u0957' // Devanagari + | '\u0962' ..'\u0963' // Devanagari + | '\u0981' // Bengali + | '\u09bc' // Bengali + | '\u09c1' ..'\u09c4' // Bengali + | '\u09cd' // Bengali + | '\u09e2' ..'\u09e3' // Bengali + | '\u0a01' ..'\u0a02' // Gurmukhi + | '\u0a3c' // Gurmukhi + | '\u0a41' ..'\u0a42' // Gurmukhi + | '\u0a47' ..'\u0a48' // Gurmukhi + | '\u0a4b' ..'\u0a4d' // Gurmukhi + | '\u0a51' // Gurmukhi + | '\u0a70' ..'\u0a71' // Gurmukhi + | '\u0a75' // Gurmukhi + | '\u0a81' ..'\u0a82' // Gujarati + | '\u0abc' // Gujarati + | '\u0ac1' ..'\u0ac5' // Gujarati + | '\u0ac7' ..'\u0ac8' // Gujarati + | '\u0acd' // Gujarati + | '\u0ae2' ..'\u0ae3' // Gujarati + | '\u0b01' // Oriya + | '\u0b3c' // Oriya + | '\u0b3f' // Oriya + | '\u0b41' ..'\u0b44' // Oriya + | '\u0b4d' // Oriya + | '\u0b56' // Oriya + | '\u0b62' ..'\u0b63' // Oriya + | '\u0b82' // Tamil + | '\u0bc0' // Tamil + | '\u0bcd' // Tamil + | '\u0c00' // Telugu + | '\u0c3e' ..'\u0c40' // Telugu + | '\u0c46' ..'\u0c48' // Telugu + | '\u0c4a' ..'\u0c4d' // Telugu + | '\u0c55' ..'\u0c56' // Telugu + | '\u0c62' ..'\u0c63' // Telugu + | '\u0c81' // Kannada + | '\u0cbc' // Kannada + | '\u0cbf' // Kannada + | '\u0cc6' // Kannada + | '\u0ccc' ..'\u0ccd' // Kannada + | '\u0ce2' ..'\u0ce3' // Kannada + | '\u0d01' // Malayalam + | '\u0d41' ..'\u0d44' // Malayalam + | '\u0d4d' // Malayalam + | '\u0d62' ..'\u0d63' // Malayalam + | '\u0dca' // Sinhala + | '\u0dd2' ..'\u0dd4' // Sinhala + | '\u0dd6' // Sinhala + | '\u0e31' // Thai + | '\u0e34' ..'\u0e3a' // Thai + | '\u0e47' ..'\u0e4e' // Thai + | '\u0eb1' // Lao + | '\u0eb4' ..'\u0eb9' // Lao + | '\u0ebb' ..'\u0ebc' // Lao + | '\u0ec8' ..'\u0ecd' // Lao + | '\u0f18' ..'\u0f19' // Tibetan + | '\u0f35' // Tibetan + | '\u0f37' // Tibetan + | '\u0f39' // Tibetan + | '\u0f71' ..'\u0f7e' // Tibetan + | '\u0f80' ..'\u0f84' // Tibetan + | '\u0f86' ..'\u0f87' // Tibetan + | '\u0f8d' ..'\u0f97' // Tibetan + | '\u0f99' ..'\u0fbc' // Tibetan + | '\u0fc6' // Tibetan + | '\u102d' ..'\u1030' // Myanmar + | '\u1032' ..'\u1037' // Myanmar + | '\u1039' ..'\u103a' // Myanmar + | '\u103d' ..'\u103e' // Myanmar + | '\u1058' ..'\u1059' // Myanmar + | '\u105e' ..'\u1060' // Myanmar + | '\u1071' ..'\u1074' // Myanmar + | '\u1082' // Myanmar + | '\u1085' ..'\u1086' // Myanmar + | '\u108d' // Myanmar + | '\u109d' // Myanmar + | '\u135d' ..'\u135f' // Ethiopic + | '\u1712' ..'\u1714' // Tagalog + | '\u1732' ..'\u1734' // Hanunoo + | '\u1752' ..'\u1753' // Buhid + | '\u1772' ..'\u1773' // Tagbanwa + | '\u17b4' ..'\u17b5' // Khmer + | '\u17b7' ..'\u17bd' // Khmer + | '\u17c6' // Khmer + | '\u17c9' ..'\u17d3' // Khmer + | '\u17dd' // Khmer + | '\u180b' ..'\u180d' // Mongolian + | '\u1885' ..'\u1886' // Mongolian + | '\u18a9' // Mongolian + | '\u1920' ..'\u1922' // Limbu + | '\u1927' ..'\u1928' // Limbu + | '\u1932' // Limbu + | '\u1939' ..'\u193b' // Limbu + | '\u1a17' ..'\u1a18' // Buginese + | '\u1a1b' // Buginese + | '\u1a56' // Tai_Tham + | '\u1a58' ..'\u1a5e' // Tai_Tham + | '\u1a60' // Tai_Tham + | '\u1a62' // Tai_Tham + | '\u1a65' ..'\u1a6c' // Tai_Tham + | '\u1a73' ..'\u1a7c' // Tai_Tham + | '\u1a7f' // Tai_Tham + | '\u1ab0' ..'\u1abd' // Combining_Diacritical_Marks_Extended + | '\u1b00' ..'\u1b03' // Balinese + | '\u1b34' // Balinese + | '\u1b36' ..'\u1b3a' // Balinese + | '\u1b3c' // Balinese + | '\u1b42' // Balinese + | '\u1b6b' ..'\u1b73' // Balinese + | '\u1b80' ..'\u1b81' // Sundanese + | '\u1ba2' ..'\u1ba5' // Sundanese + | '\u1ba8' ..'\u1ba9' // Sundanese + | '\u1bab' ..'\u1bad' // Sundanese + | '\u1be6' // Batak + | '\u1be8' ..'\u1be9' // Batak + | '\u1bed' // Batak + | '\u1bef' ..'\u1bf1' // Batak + | '\u1c2c' ..'\u1c33' // Lepcha + | '\u1c36' ..'\u1c37' // Lepcha + | '\u1cd0' ..'\u1cd2' // Vedic_Extensions + | '\u1cd4' ..'\u1ce0' // Vedic_Extensions + | '\u1ce2' ..'\u1ce8' // Vedic_Extensions + | '\u1ced' // Vedic_Extensions + | '\u1cf4' // Vedic_Extensions + | '\u1cf8' ..'\u1cf9' // Vedic_Extensions + | '\u1dc0' ..'\u1df5' // Combining_Diacritical_Marks_Supplement + | '\u1dfb' ..'\u1dff' // Combining_Diacritical_Marks_Supplement + | '\u20d0' ..'\u20dc' // Combining_Diacritical_Marks_for_Symbols + | '\u20e1' // Combining_Diacritical_Marks_for_Symbols + | '\u20e5' ..'\u20f0' // Combining_Diacritical_Marks_for_Symbols + | '\u2cef' ..'\u2cf1' // Coptic + | '\u2d7f' // (Absent from Blocks.txt) + | '\u2de0' ..'\u2dff' // Cyrillic_Extended-A + | '\u302a' ..'\u302d' // CJK_Symbols_and_Punctuation + | '\u3099' ..'\u309a' // Hiragana + | '\ua66f' // Cyrillic_Extended-B + | '\ua674' ..'\ua67d' // Cyrillic_Extended-B + | '\ua69e' ..'\ua69f' // Cyrillic_Extended-B + | '\ua6f0' ..'\ua6f1' // Bamum + | '\ua802' // Syloti_Nagri + | '\ua806' // Syloti_Nagri + | '\ua80b' // Syloti_Nagri + | '\ua825' ..'\ua826' // Syloti_Nagri + | '\ua8c4' ..'\ua8c5' // Saurashtra + | '\ua8e0' ..'\ua8f1' // Devanagari_Extended + | '\ua926' ..'\ua92d' // Kayah_Li + | '\ua947' ..'\ua951' // Rejang + | '\ua980' ..'\ua982' // Javanese + | '\ua9b3' // Javanese + | '\ua9b6' ..'\ua9b9' // Javanese + | '\ua9bc' // Javanese + | '\ua9e5' // Myanmar_Extended-B + | '\uaa29' ..'\uaa2e' // Cham + | '\uaa31' ..'\uaa32' // Cham + | '\uaa35' ..'\uaa36' // Cham + | '\uaa43' // Cham + | '\uaa4c' // Cham + | '\uaa7c' // Myanmar_Extended-A + | '\uaab0' // Tai_Viet + | '\uaab2' ..'\uaab4' // Tai_Viet + | '\uaab7' ..'\uaab8' // Tai_Viet + | '\uaabe' ..'\uaabf' // Tai_Viet + | '\uaac1' // Tai_Viet + | '\uaaec' ..'\uaaed' // Meetei_Mayek_Extensions + | '\uaaf6' // Meetei_Mayek_Extensions + | '\uabe5' // Meetei_Mayek + | '\uabe8' // Meetei_Mayek + | '\uabed' // Meetei_Mayek + | '\ufb1e' // Alphabetic_Presentation_Forms + | '\ufe00' ..'\ufe0f' // Variation_Selectors + | '\ufe20' ..'\ufe2f' // Combining_Half_Marks + ; -CLASSIFY_Nd: - '\u0030'..'\u0039' // Basic_Latin - | '\u0660'..'\u0669' // Arabic - | '\u06f0'..'\u06f9' // Arabic - | '\u07c0'..'\u07c9' // NKo - | '\u0966'..'\u096f' // Devanagari - | '\u09e6'..'\u09ef' // Bengali - | '\u0a66'..'\u0a6f' // Gurmukhi - | '\u0ae6'..'\u0aef' // Gujarati - | '\u0b66'..'\u0b6f' // Oriya - | '\u0be6'..'\u0bef' // Tamil - | '\u0c66'..'\u0c6f' // Telugu - | '\u0ce6'..'\u0cef' // Kannada - | '\u0d66'..'\u0d6f' // Malayalam - | '\u0de6'..'\u0def' // Sinhala - | '\u0e50'..'\u0e59' // Thai - | '\u0ed0'..'\u0ed9' // Lao - | '\u0f20'..'\u0f29' // Tibetan - | '\u1040'..'\u1049' // Myanmar - | '\u1090'..'\u1099' // Myanmar - | '\u17e0'..'\u17e9' // Khmer - | '\u1810'..'\u1819' // Mongolian - | '\u1946'..'\u194f' // Limbu - | '\u19d0'..'\u19d9' // New_Tai_Lue - | '\u1a80'..'\u1a89' // Tai_Tham - | '\u1a90'..'\u1a99' // Tai_Tham - | '\u1b50'..'\u1b59' // Balinese - | '\u1bb0'..'\u1bb9' // Sundanese - | '\u1c40'..'\u1c49' // Lepcha - | '\u1c50'..'\u1c59' // Ol_Chiki - | '\ua620'..'\ua629' // Vai - | '\ua8d0'..'\ua8d9' // Saurashtra - | '\ua900'..'\ua909' // Kayah_Li - | '\ua9d0'..'\ua9d9' // Javanese - | '\ua9f0'..'\ua9f9' // Myanmar_Extended-B - | '\uaa50'..'\uaa59' // Cham - | '\uabf0'..'\uabf9' // Meetei_Mayek - | '\uff10'..'\uff19' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Nd + : '\u0030' ..'\u0039' // Basic_Latin + | '\u0660' ..'\u0669' // Arabic + | '\u06f0' ..'\u06f9' // Arabic + | '\u07c0' ..'\u07c9' // NKo + | '\u0966' ..'\u096f' // Devanagari + | '\u09e6' ..'\u09ef' // Bengali + | '\u0a66' ..'\u0a6f' // Gurmukhi + | '\u0ae6' ..'\u0aef' // Gujarati + | '\u0b66' ..'\u0b6f' // Oriya + | '\u0be6' ..'\u0bef' // Tamil + | '\u0c66' ..'\u0c6f' // Telugu + | '\u0ce6' ..'\u0cef' // Kannada + | '\u0d66' ..'\u0d6f' // Malayalam + | '\u0de6' ..'\u0def' // Sinhala + | '\u0e50' ..'\u0e59' // Thai + | '\u0ed0' ..'\u0ed9' // Lao + | '\u0f20' ..'\u0f29' // Tibetan + | '\u1040' ..'\u1049' // Myanmar + | '\u1090' ..'\u1099' // Myanmar + | '\u17e0' ..'\u17e9' // Khmer + | '\u1810' ..'\u1819' // Mongolian + | '\u1946' ..'\u194f' // Limbu + | '\u19d0' ..'\u19d9' // New_Tai_Lue + | '\u1a80' ..'\u1a89' // Tai_Tham + | '\u1a90' ..'\u1a99' // Tai_Tham + | '\u1b50' ..'\u1b59' // Balinese + | '\u1bb0' ..'\u1bb9' // Sundanese + | '\u1c40' ..'\u1c49' // Lepcha + | '\u1c50' ..'\u1c59' // Ol_Chiki + | '\ua620' ..'\ua629' // Vai + | '\ua8d0' ..'\ua8d9' // Saurashtra + | '\ua900' ..'\ua909' // Kayah_Li + | '\ua9d0' ..'\ua9d9' // Javanese + | '\ua9f0' ..'\ua9f9' // Myanmar_Extended-B + | '\uaa50' ..'\uaa59' // Cham + | '\uabf0' ..'\uabf9' // Meetei_Mayek + | '\uff10' ..'\uff19' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Nl: - '\u16ee'..'\u16f0' // Runic - | '\u2160'..'\u2182' // Number_Forms - | '\u2185'..'\u2188' // Number_Forms - | '\u3007' // CJK_Symbols_and_Punctuation - | '\u3021'..'\u3029' // CJK_Symbols_and_Punctuation - | '\u3038'..'\u303a' // CJK_Symbols_and_Punctuation - | '\ua6e6'..'\ua6ef' // Bamum -; +CLASSIFY_Nl + : '\u16ee' ..'\u16f0' // Runic + | '\u2160' ..'\u2182' // Number_Forms + | '\u2185' ..'\u2188' // Number_Forms + | '\u3007' // CJK_Symbols_and_Punctuation + | '\u3021' ..'\u3029' // CJK_Symbols_and_Punctuation + | '\u3038' ..'\u303a' // CJK_Symbols_and_Punctuation + | '\ua6e6' ..'\ua6ef' // Bamum + ; -CLASSIFY_No: - '\u00b2'..'\u00b3' // Latin-1_Supplement - | '\u00b9' // Latin-1_Supplement - | '\u00bc'..'\u00be' // Latin-1_Supplement - | '\u09f4'..'\u09f9' // Bengali - | '\u0b72'..'\u0b77' // Oriya - | '\u0bf0'..'\u0bf2' // Tamil - | '\u0c78'..'\u0c7e' // Telugu - | '\u0d58'..'\u0d5e' // Malayalam - | '\u0d70'..'\u0d78' // Malayalam - | '\u0f2a'..'\u0f33' // Tibetan - | '\u1369'..'\u137c' // Ethiopic - | '\u17f0'..'\u17f9' // Khmer - | '\u19da' // New_Tai_Lue - | '\u2070' // Superscripts_and_Subscripts - | '\u2074'..'\u2079' // Superscripts_and_Subscripts - | '\u2080'..'\u2089' // Superscripts_and_Subscripts - | '\u2150'..'\u215f' // Number_Forms - | '\u2189' // Number_Forms - | '\u2460'..'\u249b' // Enclosed_Alphanumerics - | '\u24ea'..'\u24ff' // Enclosed_Alphanumerics - | '\u2776'..'\u2793' // Dingbats - | '\u2cfd' // Coptic - | '\u3192'..'\u3195' // Kanbun - | '\u3220'..'\u3229' // Enclosed_CJK_Letters_and_Months - | '\u3248'..'\u324f' // Enclosed_CJK_Letters_and_Months - | '\u3251'..'\u325f' // Enclosed_CJK_Letters_and_Months - | '\u3280'..'\u3289' // Enclosed_CJK_Letters_and_Months - | '\u32b1'..'\u32bf' // Enclosed_CJK_Letters_and_Months - | '\ua830'..'\ua835' // Common_Indic_Number_Forms -; +CLASSIFY_No + : '\u00b2' ..'\u00b3' // Latin-1_Supplement + | '\u00b9' // Latin-1_Supplement + | '\u00bc' ..'\u00be' // Latin-1_Supplement + | '\u09f4' ..'\u09f9' // Bengali + | '\u0b72' ..'\u0b77' // Oriya + | '\u0bf0' ..'\u0bf2' // Tamil + | '\u0c78' ..'\u0c7e' // Telugu + | '\u0d58' ..'\u0d5e' // Malayalam + | '\u0d70' ..'\u0d78' // Malayalam + | '\u0f2a' ..'\u0f33' // Tibetan + | '\u1369' ..'\u137c' // Ethiopic + | '\u17f0' ..'\u17f9' // Khmer + | '\u19da' // New_Tai_Lue + | '\u2070' // Superscripts_and_Subscripts + | '\u2074' ..'\u2079' // Superscripts_and_Subscripts + | '\u2080' ..'\u2089' // Superscripts_and_Subscripts + | '\u2150' ..'\u215f' // Number_Forms + | '\u2189' // Number_Forms + | '\u2460' ..'\u249b' // Enclosed_Alphanumerics + | '\u24ea' ..'\u24ff' // Enclosed_Alphanumerics + | '\u2776' ..'\u2793' // Dingbats + | '\u2cfd' // Coptic + | '\u3192' ..'\u3195' // Kanbun + | '\u3220' ..'\u3229' // Enclosed_CJK_Letters_and_Months + | '\u3248' ..'\u324f' // Enclosed_CJK_Letters_and_Months + | '\u3251' ..'\u325f' // Enclosed_CJK_Letters_and_Months + | '\u3280' ..'\u3289' // Enclosed_CJK_Letters_and_Months + | '\u32b1' ..'\u32bf' // Enclosed_CJK_Letters_and_Months + | '\ua830' ..'\ua835' // Common_Indic_Number_Forms + ; -CLASSIFY_Pc: - '\u005f' // Basic_Latin - | '\u203f'..'\u2040' // General_Punctuation - | '\u2054' // General_Punctuation - | '\ufe33'..'\ufe34' // CJK_Compatibility_Forms - | '\ufe4d'..'\ufe4f' // CJK_Compatibility_Forms - | '\uff3f' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Pc + : '\u005f' // Basic_Latin + | '\u203f' ..'\u2040' // General_Punctuation + | '\u2054' // General_Punctuation + | '\ufe33' ..'\ufe34' // CJK_Compatibility_Forms + | '\ufe4d' ..'\ufe4f' // CJK_Compatibility_Forms + | '\uff3f' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Pd: - '\u002d' // Basic_Latin - | '\u058a' // Armenian - | '\u05be' // Hebrew - | '\u1400' // Unified_Canadian_Aboriginal_Syllabics - | '\u1806' // Mongolian - | '\u2010'..'\u2015' // General_Punctuation - | '\u2e17' // Supplemental_Punctuation - | '\u2e1a' // Supplemental_Punctuation - | '\u2e3a'..'\u2e3b' // Supplemental_Punctuation - | '\u2e40' // Supplemental_Punctuation - | '\u301c' // CJK_Symbols_and_Punctuation - | '\u3030' // CJK_Symbols_and_Punctuation - | '\u30a0' // Katakana - | '\ufe31'..'\ufe32' // CJK_Compatibility_Forms - | '\ufe58' // Small_Form_Variants - | '\ufe63' // Small_Form_Variants - | '\uff0d' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Pd + : '\u002d' // Basic_Latin + | '\u058a' // Armenian + | '\u05be' // Hebrew + | '\u1400' // Unified_Canadian_Aboriginal_Syllabics + | '\u1806' // Mongolian + | '\u2010' ..'\u2015' // General_Punctuation + | '\u2e17' // Supplemental_Punctuation + | '\u2e1a' // Supplemental_Punctuation + | '\u2e3a' ..'\u2e3b' // Supplemental_Punctuation + | '\u2e40' // Supplemental_Punctuation + | '\u301c' // CJK_Symbols_and_Punctuation + | '\u3030' // CJK_Symbols_and_Punctuation + | '\u30a0' // Katakana + | '\ufe31' ..'\ufe32' // CJK_Compatibility_Forms + | '\ufe58' // Small_Form_Variants + | '\ufe63' // Small_Form_Variants + | '\uff0d' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Pe: - '\u0029' // Basic_Latin - | '\u005d' // Basic_Latin - | '\u007d' // Basic_Latin - | '\u0f3b' // Tibetan - | '\u0f3d' // Tibetan - | '\u169c' // Ogham - | '\u2046' // General_Punctuation - | '\u207e' // Superscripts_and_Subscripts - | '\u208e' // Superscripts_and_Subscripts - | '\u2309' // Miscellaneous_Technical - | '\u230b' // Miscellaneous_Technical - | '\u232a' // Miscellaneous_Technical - | '\u2769' // Dingbats - | '\u276b' // Dingbats - | '\u276d' // Dingbats - | '\u276f' // Dingbats - | '\u2771' // Dingbats - | '\u2773' // Dingbats - | '\u2775' // Dingbats - | '\u27c6' // Miscellaneous_Mathematical_Symbols-A - | '\u27e7' // Miscellaneous_Mathematical_Symbols-A - | '\u27e9' // Miscellaneous_Mathematical_Symbols-A - | '\u27eb' // Miscellaneous_Mathematical_Symbols-A - | '\u27ed' // Miscellaneous_Mathematical_Symbols-A - | '\u27ef' // (Absent from Blocks.txt) - | '\u2984' // Miscellaneous_Mathematical_Symbols-B - | '\u2986' // Miscellaneous_Mathematical_Symbols-B - | '\u2988' // Miscellaneous_Mathematical_Symbols-B - | '\u298a' // Miscellaneous_Mathematical_Symbols-B - | '\u298c' // Miscellaneous_Mathematical_Symbols-B - | '\u298e' // Miscellaneous_Mathematical_Symbols-B - | '\u2990' // Miscellaneous_Mathematical_Symbols-B - | '\u2992' // Miscellaneous_Mathematical_Symbols-B - | '\u2994' // Miscellaneous_Mathematical_Symbols-B - | '\u2996' // Miscellaneous_Mathematical_Symbols-B - | '\u2998' // Miscellaneous_Mathematical_Symbols-B - | '\u29d9' // Miscellaneous_Mathematical_Symbols-B - | '\u29db' // Miscellaneous_Mathematical_Symbols-B - | '\u29fd' // Miscellaneous_Mathematical_Symbols-B - | '\u2e23' // Supplemental_Punctuation - | '\u2e25' // Supplemental_Punctuation - | '\u2e27' // Supplemental_Punctuation - | '\u2e29' // Supplemental_Punctuation - | '\u3009' // CJK_Symbols_and_Punctuation - | '\u300b' // CJK_Symbols_and_Punctuation - | '\u300d' // CJK_Symbols_and_Punctuation - | '\u300f' // CJK_Symbols_and_Punctuation - | '\u3011' // CJK_Symbols_and_Punctuation - | '\u3015' // CJK_Symbols_and_Punctuation - | '\u3017' // CJK_Symbols_and_Punctuation - | '\u3019' // CJK_Symbols_and_Punctuation - | '\u301b' // CJK_Symbols_and_Punctuation - | '\u301e'..'\u301f' // CJK_Symbols_and_Punctuation - | '\ufd3e' // Arabic_Presentation_Forms-A - | '\ufe18' // Vertical_Forms - | '\ufe36' // CJK_Compatibility_Forms - | '\ufe38' // CJK_Compatibility_Forms - | '\ufe3a' // CJK_Compatibility_Forms - | '\ufe3c' // CJK_Compatibility_Forms - | '\ufe3e' // CJK_Compatibility_Forms - | '\ufe40' // CJK_Compatibility_Forms - | '\ufe42' // CJK_Compatibility_Forms - | '\ufe44' // CJK_Compatibility_Forms - | '\ufe48' // CJK_Compatibility_Forms - | '\ufe5a' // Small_Form_Variants - | '\ufe5c' // Small_Form_Variants - | '\ufe5e' // Small_Form_Variants - | '\uff09' // Halfwidth_and_Fullwidth_Forms - | '\uff3d' // Halfwidth_and_Fullwidth_Forms - | '\uff5d' // Halfwidth_and_Fullwidth_Forms - | '\uff60' // Halfwidth_and_Fullwidth_Forms - | '\uff63' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Pe + : '\u0029' // Basic_Latin + | '\u005d' // Basic_Latin + | '\u007d' // Basic_Latin + | '\u0f3b' // Tibetan + | '\u0f3d' // Tibetan + | '\u169c' // Ogham + | '\u2046' // General_Punctuation + | '\u207e' // Superscripts_and_Subscripts + | '\u208e' // Superscripts_and_Subscripts + | '\u2309' // Miscellaneous_Technical + | '\u230b' // Miscellaneous_Technical + | '\u232a' // Miscellaneous_Technical + | '\u2769' // Dingbats + | '\u276b' // Dingbats + | '\u276d' // Dingbats + | '\u276f' // Dingbats + | '\u2771' // Dingbats + | '\u2773' // Dingbats + | '\u2775' // Dingbats + | '\u27c6' // Miscellaneous_Mathematical_Symbols-A + | '\u27e7' // Miscellaneous_Mathematical_Symbols-A + | '\u27e9' // Miscellaneous_Mathematical_Symbols-A + | '\u27eb' // Miscellaneous_Mathematical_Symbols-A + | '\u27ed' // Miscellaneous_Mathematical_Symbols-A + | '\u27ef' // (Absent from Blocks.txt) + | '\u2984' // Miscellaneous_Mathematical_Symbols-B + | '\u2986' // Miscellaneous_Mathematical_Symbols-B + | '\u2988' // Miscellaneous_Mathematical_Symbols-B + | '\u298a' // Miscellaneous_Mathematical_Symbols-B + | '\u298c' // Miscellaneous_Mathematical_Symbols-B + | '\u298e' // Miscellaneous_Mathematical_Symbols-B + | '\u2990' // Miscellaneous_Mathematical_Symbols-B + | '\u2992' // Miscellaneous_Mathematical_Symbols-B + | '\u2994' // Miscellaneous_Mathematical_Symbols-B + | '\u2996' // Miscellaneous_Mathematical_Symbols-B + | '\u2998' // Miscellaneous_Mathematical_Symbols-B + | '\u29d9' // Miscellaneous_Mathematical_Symbols-B + | '\u29db' // Miscellaneous_Mathematical_Symbols-B + | '\u29fd' // Miscellaneous_Mathematical_Symbols-B + | '\u2e23' // Supplemental_Punctuation + | '\u2e25' // Supplemental_Punctuation + | '\u2e27' // Supplemental_Punctuation + | '\u2e29' // Supplemental_Punctuation + | '\u3009' // CJK_Symbols_and_Punctuation + | '\u300b' // CJK_Symbols_and_Punctuation + | '\u300d' // CJK_Symbols_and_Punctuation + | '\u300f' // CJK_Symbols_and_Punctuation + | '\u3011' // CJK_Symbols_and_Punctuation + | '\u3015' // CJK_Symbols_and_Punctuation + | '\u3017' // CJK_Symbols_and_Punctuation + | '\u3019' // CJK_Symbols_and_Punctuation + | '\u301b' // CJK_Symbols_and_Punctuation + | '\u301e' ..'\u301f' // CJK_Symbols_and_Punctuation + | '\ufd3e' // Arabic_Presentation_Forms-A + | '\ufe18' // Vertical_Forms + | '\ufe36' // CJK_Compatibility_Forms + | '\ufe38' // CJK_Compatibility_Forms + | '\ufe3a' // CJK_Compatibility_Forms + | '\ufe3c' // CJK_Compatibility_Forms + | '\ufe3e' // CJK_Compatibility_Forms + | '\ufe40' // CJK_Compatibility_Forms + | '\ufe42' // CJK_Compatibility_Forms + | '\ufe44' // CJK_Compatibility_Forms + | '\ufe48' // CJK_Compatibility_Forms + | '\ufe5a' // Small_Form_Variants + | '\ufe5c' // Small_Form_Variants + | '\ufe5e' // Small_Form_Variants + | '\uff09' // Halfwidth_and_Fullwidth_Forms + | '\uff3d' // Halfwidth_and_Fullwidth_Forms + | '\uff5d' // Halfwidth_and_Fullwidth_Forms + | '\uff60' // Halfwidth_and_Fullwidth_Forms + | '\uff63' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Pf: - '\u00bb' // Latin-1_Supplement - | '\u2019' // General_Punctuation - | '\u201d' // General_Punctuation - | '\u203a' // General_Punctuation - | '\u2e03' // Supplemental_Punctuation - | '\u2e05' // Supplemental_Punctuation - | '\u2e0a' // Supplemental_Punctuation - | '\u2e0d' // Supplemental_Punctuation - | '\u2e1d' // Supplemental_Punctuation - | '\u2e21' // Supplemental_Punctuation -; +CLASSIFY_Pf + : '\u00bb' // Latin-1_Supplement + | '\u2019' // General_Punctuation + | '\u201d' // General_Punctuation + | '\u203a' // General_Punctuation + | '\u2e03' // Supplemental_Punctuation + | '\u2e05' // Supplemental_Punctuation + | '\u2e0a' // Supplemental_Punctuation + | '\u2e0d' // Supplemental_Punctuation + | '\u2e1d' // Supplemental_Punctuation + | '\u2e21' // Supplemental_Punctuation + ; -CLASSIFY_Pi: - '\u00ab' // Latin-1_Supplement - | '\u2018' // General_Punctuation - | '\u201b'..'\u201c' // General_Punctuation - | '\u201f' // General_Punctuation - | '\u2039' // General_Punctuation - | '\u2e02' // Supplemental_Punctuation - | '\u2e04' // Supplemental_Punctuation - | '\u2e09' // Supplemental_Punctuation - | '\u2e0c' // Supplemental_Punctuation - | '\u2e1c' // Supplemental_Punctuation - | '\u2e20' // Supplemental_Punctuation -; +CLASSIFY_Pi + : '\u00ab' // Latin-1_Supplement + | '\u2018' // General_Punctuation + | '\u201b' ..'\u201c' // General_Punctuation + | '\u201f' // General_Punctuation + | '\u2039' // General_Punctuation + | '\u2e02' // Supplemental_Punctuation + | '\u2e04' // Supplemental_Punctuation + | '\u2e09' // Supplemental_Punctuation + | '\u2e0c' // Supplemental_Punctuation + | '\u2e1c' // Supplemental_Punctuation + | '\u2e20' // Supplemental_Punctuation + ; -CLASSIFY_Po: - '\u0021'..'\u0023' // Basic_Latin - | '\u0025'..'\u0027' // Basic_Latin - | '\u002a' // Basic_Latin - | '\u002c' // Basic_Latin - | '\u002e'..'\u002f' // Basic_Latin - | '\u003a'..'\u003b' // Basic_Latin - | '\u003f'..'\u0040' // Basic_Latin - | '\u005c' // Basic_Latin - | '\u00a1' // Latin-1_Supplement - | '\u00a7' // Latin-1_Supplement - | '\u00b6'..'\u00b7' // Latin-1_Supplement - | '\u00bf' // Latin-1_Supplement - | '\u037e' // Greek_and_Coptic - | '\u0387' // Greek_and_Coptic - | '\u055a'..'\u055f' // Armenian - | '\u0589' // Armenian - | '\u05c0' // Hebrew - | '\u05c3' // Hebrew - | '\u05c6' // Hebrew - | '\u05f3'..'\u05f4' // Hebrew - | '\u0609'..'\u060a' // Arabic - | '\u060c'..'\u060d' // Arabic - | '\u061b' // Arabic - | '\u061e'..'\u061f' // Arabic - | '\u066a'..'\u066d' // Arabic - | '\u06d4' // Arabic - | '\u0700'..'\u070d' // Syriac - | '\u07f7'..'\u07f9' // NKo - | '\u0830'..'\u083e' // Samaritan - | '\u085e' // Mandaic - | '\u0964'..'\u0965' // Devanagari - | '\u0970' // Devanagari - | '\u0af0' // Gujarati - | '\u0df4' // Sinhala - | '\u0e4f' // Thai - | '\u0e5a'..'\u0e5b' // Thai - | '\u0f04'..'\u0f12' // Tibetan - | '\u0f14' // Tibetan - | '\u0f85' // Tibetan - | '\u0fd0'..'\u0fd4' // Tibetan - | '\u0fd9'..'\u0fda' // Tibetan - | '\u104a'..'\u104f' // Myanmar - | '\u10fb' // Georgian - | '\u1360'..'\u1368' // Ethiopic - | '\u166d'..'\u166e' // Unified_Canadian_Aboriginal_Syllabics - | '\u16eb'..'\u16ed' // Runic - | '\u1735'..'\u1736' // Hanunoo - | '\u17d4'..'\u17d6' // Khmer - | '\u17d8'..'\u17da' // Khmer - | '\u1800'..'\u1805' // Mongolian - | '\u1807'..'\u180a' // Mongolian - | '\u1944'..'\u1945' // Limbu - | '\u1a1e'..'\u1a1f' // Buginese - | '\u1aa0'..'\u1aa6' // Tai_Tham - | '\u1aa8'..'\u1aad' // Tai_Tham - | '\u1b5a'..'\u1b60' // Balinese - | '\u1bfc'..'\u1bff' // Batak - | '\u1c3b'..'\u1c3f' // Lepcha - | '\u1c7e'..'\u1c7f' // Ol_Chiki - | '\u1cc0'..'\u1cc7' // Sundanese_Supplement - | '\u1cd3' // Vedic_Extensions - | '\u2016'..'\u2017' // General_Punctuation - | '\u2020'..'\u2027' // General_Punctuation - | '\u2030'..'\u2038' // General_Punctuation - | '\u203b'..'\u203e' // General_Punctuation - | '\u2041'..'\u2043' // General_Punctuation - | '\u2047'..'\u2051' // General_Punctuation - | '\u2053' // General_Punctuation - | '\u2055'..'\u205e' // General_Punctuation - | '\u2cf9'..'\u2cfc' // Coptic - | '\u2cfe'..'\u2cff' // Coptic - | '\u2d70' // Tifinagh - | '\u2e00'..'\u2e01' // Supplemental_Punctuation - | '\u2e06'..'\u2e08' // Supplemental_Punctuation - | '\u2e0b' // Supplemental_Punctuation - | '\u2e0e'..'\u2e16' // Supplemental_Punctuation - | '\u2e18'..'\u2e19' // Supplemental_Punctuation - | '\u2e1b' // Supplemental_Punctuation - | '\u2e1e'..'\u2e1f' // Supplemental_Punctuation - | '\u2e2a'..'\u2e2e' // Supplemental_Punctuation - | '\u2e30'..'\u2e39' // Supplemental_Punctuation - | '\u2e3c'..'\u2e3f' // Supplemental_Punctuation - | '\u2e41' // Supplemental_Punctuation - | '\u2e43'..'\u2e44' // Supplemental_Punctuation - | '\u3001'..'\u3003' // CJK_Symbols_and_Punctuation - | '\u303d' // CJK_Symbols_and_Punctuation - | '\u30fb' // Katakana - | '\ua4fe'..'\ua4ff' // Lisu - | '\ua60d'..'\ua60f' // Vai - | '\ua673' // Cyrillic_Extended-B - | '\ua67e' // Cyrillic_Extended-B - | '\ua6f2'..'\ua6f7' // Bamum - | '\ua874'..'\ua877' // Phags-pa - | '\ua8ce'..'\ua8cf' // Saurashtra - | '\ua8f8'..'\ua8fa' // Devanagari_Extended - | '\ua8fc' // Devanagari_Extended - | '\ua92e'..'\ua92f' // Kayah_Li - | '\ua95f' // (Absent from Blocks.txt) - | '\ua9c1'..'\ua9cd' // Javanese - | '\ua9de'..'\ua9df' // Javanese - | '\uaa5c'..'\uaa5f' // Cham - | '\uaade'..'\uaadf' // Tai_Viet - | '\uaaf0'..'\uaaf1' // Meetei_Mayek_Extensions - | '\uabeb' // Meetei_Mayek - | '\ufe10'..'\ufe16' // Vertical_Forms - | '\ufe19' // Vertical_Forms - | '\ufe30' // CJK_Compatibility_Forms - | '\ufe45'..'\ufe46' // CJK_Compatibility_Forms - | '\ufe49'..'\ufe4c' // CJK_Compatibility_Forms - | '\ufe50'..'\ufe52' // Small_Form_Variants - | '\ufe54'..'\ufe57' // Small_Form_Variants - | '\ufe5f'..'\ufe61' // Small_Form_Variants - | '\ufe68' // Small_Form_Variants - | '\ufe6a'..'\ufe6b' // Small_Form_Variants - | '\uff01'..'\uff03' // Halfwidth_and_Fullwidth_Forms - | '\uff05'..'\uff07' // Halfwidth_and_Fullwidth_Forms - | '\uff0a' // Halfwidth_and_Fullwidth_Forms - | '\uff0c' // Halfwidth_and_Fullwidth_Forms - | '\uff0e'..'\uff0f' // Halfwidth_and_Fullwidth_Forms - | '\uff1a'..'\uff1b' // Halfwidth_and_Fullwidth_Forms - | '\uff1f'..'\uff20' // Halfwidth_and_Fullwidth_Forms - | '\uff3c' // Halfwidth_and_Fullwidth_Forms - | '\uff61' // Halfwidth_and_Fullwidth_Forms - | '\uff64'..'\uff65' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Po + : '\u0021' ..'\u0023' // Basic_Latin + | '\u0025' ..'\u0027' // Basic_Latin + | '\u002a' // Basic_Latin + | '\u002c' // Basic_Latin + | '\u002e' ..'\u002f' // Basic_Latin + | '\u003a' ..'\u003b' // Basic_Latin + | '\u003f' ..'\u0040' // Basic_Latin + | '\u005c' // Basic_Latin + | '\u00a1' // Latin-1_Supplement + | '\u00a7' // Latin-1_Supplement + | '\u00b6' ..'\u00b7' // Latin-1_Supplement + | '\u00bf' // Latin-1_Supplement + | '\u037e' // Greek_and_Coptic + | '\u0387' // Greek_and_Coptic + | '\u055a' ..'\u055f' // Armenian + | '\u0589' // Armenian + | '\u05c0' // Hebrew + | '\u05c3' // Hebrew + | '\u05c6' // Hebrew + | '\u05f3' ..'\u05f4' // Hebrew + | '\u0609' ..'\u060a' // Arabic + | '\u060c' ..'\u060d' // Arabic + | '\u061b' // Arabic + | '\u061e' ..'\u061f' // Arabic + | '\u066a' ..'\u066d' // Arabic + | '\u06d4' // Arabic + | '\u0700' ..'\u070d' // Syriac + | '\u07f7' ..'\u07f9' // NKo + | '\u0830' ..'\u083e' // Samaritan + | '\u085e' // Mandaic + | '\u0964' ..'\u0965' // Devanagari + | '\u0970' // Devanagari + | '\u0af0' // Gujarati + | '\u0df4' // Sinhala + | '\u0e4f' // Thai + | '\u0e5a' ..'\u0e5b' // Thai + | '\u0f04' ..'\u0f12' // Tibetan + | '\u0f14' // Tibetan + | '\u0f85' // Tibetan + | '\u0fd0' ..'\u0fd4' // Tibetan + | '\u0fd9' ..'\u0fda' // Tibetan + | '\u104a' ..'\u104f' // Myanmar + | '\u10fb' // Georgian + | '\u1360' ..'\u1368' // Ethiopic + | '\u166d' ..'\u166e' // Unified_Canadian_Aboriginal_Syllabics + | '\u16eb' ..'\u16ed' // Runic + | '\u1735' ..'\u1736' // Hanunoo + | '\u17d4' ..'\u17d6' // Khmer + | '\u17d8' ..'\u17da' // Khmer + | '\u1800' ..'\u1805' // Mongolian + | '\u1807' ..'\u180a' // Mongolian + | '\u1944' ..'\u1945' // Limbu + | '\u1a1e' ..'\u1a1f' // Buginese + | '\u1aa0' ..'\u1aa6' // Tai_Tham + | '\u1aa8' ..'\u1aad' // Tai_Tham + | '\u1b5a' ..'\u1b60' // Balinese + | '\u1bfc' ..'\u1bff' // Batak + | '\u1c3b' ..'\u1c3f' // Lepcha + | '\u1c7e' ..'\u1c7f' // Ol_Chiki + | '\u1cc0' ..'\u1cc7' // Sundanese_Supplement + | '\u1cd3' // Vedic_Extensions + | '\u2016' ..'\u2017' // General_Punctuation + | '\u2020' ..'\u2027' // General_Punctuation + | '\u2030' ..'\u2038' // General_Punctuation + | '\u203b' ..'\u203e' // General_Punctuation + | '\u2041' ..'\u2043' // General_Punctuation + | '\u2047' ..'\u2051' // General_Punctuation + | '\u2053' // General_Punctuation + | '\u2055' ..'\u205e' // General_Punctuation + | '\u2cf9' ..'\u2cfc' // Coptic + | '\u2cfe' ..'\u2cff' // Coptic + | '\u2d70' // Tifinagh + | '\u2e00' ..'\u2e01' // Supplemental_Punctuation + | '\u2e06' ..'\u2e08' // Supplemental_Punctuation + | '\u2e0b' // Supplemental_Punctuation + | '\u2e0e' ..'\u2e16' // Supplemental_Punctuation + | '\u2e18' ..'\u2e19' // Supplemental_Punctuation + | '\u2e1b' // Supplemental_Punctuation + | '\u2e1e' ..'\u2e1f' // Supplemental_Punctuation + | '\u2e2a' ..'\u2e2e' // Supplemental_Punctuation + | '\u2e30' ..'\u2e39' // Supplemental_Punctuation + | '\u2e3c' ..'\u2e3f' // Supplemental_Punctuation + | '\u2e41' // Supplemental_Punctuation + | '\u2e43' ..'\u2e44' // Supplemental_Punctuation + | '\u3001' ..'\u3003' // CJK_Symbols_and_Punctuation + | '\u303d' // CJK_Symbols_and_Punctuation + | '\u30fb' // Katakana + | '\ua4fe' ..'\ua4ff' // Lisu + | '\ua60d' ..'\ua60f' // Vai + | '\ua673' // Cyrillic_Extended-B + | '\ua67e' // Cyrillic_Extended-B + | '\ua6f2' ..'\ua6f7' // Bamum + | '\ua874' ..'\ua877' // Phags-pa + | '\ua8ce' ..'\ua8cf' // Saurashtra + | '\ua8f8' ..'\ua8fa' // Devanagari_Extended + | '\ua8fc' // Devanagari_Extended + | '\ua92e' ..'\ua92f' // Kayah_Li + | '\ua95f' // (Absent from Blocks.txt) + | '\ua9c1' ..'\ua9cd' // Javanese + | '\ua9de' ..'\ua9df' // Javanese + | '\uaa5c' ..'\uaa5f' // Cham + | '\uaade' ..'\uaadf' // Tai_Viet + | '\uaaf0' ..'\uaaf1' // Meetei_Mayek_Extensions + | '\uabeb' // Meetei_Mayek + | '\ufe10' ..'\ufe16' // Vertical_Forms + | '\ufe19' // Vertical_Forms + | '\ufe30' // CJK_Compatibility_Forms + | '\ufe45' ..'\ufe46' // CJK_Compatibility_Forms + | '\ufe49' ..'\ufe4c' // CJK_Compatibility_Forms + | '\ufe50' ..'\ufe52' // Small_Form_Variants + | '\ufe54' ..'\ufe57' // Small_Form_Variants + | '\ufe5f' ..'\ufe61' // Small_Form_Variants + | '\ufe68' // Small_Form_Variants + | '\ufe6a' ..'\ufe6b' // Small_Form_Variants + | '\uff01' ..'\uff03' // Halfwidth_and_Fullwidth_Forms + | '\uff05' ..'\uff07' // Halfwidth_and_Fullwidth_Forms + | '\uff0a' // Halfwidth_and_Fullwidth_Forms + | '\uff0c' // Halfwidth_and_Fullwidth_Forms + | '\uff0e' ..'\uff0f' // Halfwidth_and_Fullwidth_Forms + | '\uff1a' ..'\uff1b' // Halfwidth_and_Fullwidth_Forms + | '\uff1f' ..'\uff20' // Halfwidth_and_Fullwidth_Forms + | '\uff3c' // Halfwidth_and_Fullwidth_Forms + | '\uff61' // Halfwidth_and_Fullwidth_Forms + | '\uff64' ..'\uff65' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Ps: - '\u0028' // Basic_Latin - | '\u005b' // Basic_Latin - | '\u007b' // Basic_Latin - | '\u0f3a' // Tibetan - | '\u0f3c' // Tibetan - | '\u169b' // Ogham - | '\u201a' // General_Punctuation - | '\u201e' // General_Punctuation - | '\u2045' // General_Punctuation - | '\u207d' // Superscripts_and_Subscripts - | '\u208d' // Superscripts_and_Subscripts - | '\u2308' // Miscellaneous_Technical - | '\u230a' // Miscellaneous_Technical - | '\u2329' // Miscellaneous_Technical - | '\u2768' // Dingbats - | '\u276a' // Dingbats - | '\u276c' // Dingbats - | '\u276e' // Dingbats - | '\u2770' // Dingbats - | '\u2772' // Dingbats - | '\u2774' // Dingbats - | '\u27c5' // Miscellaneous_Mathematical_Symbols-A - | '\u27e6' // Miscellaneous_Mathematical_Symbols-A - | '\u27e8' // Miscellaneous_Mathematical_Symbols-A - | '\u27ea' // Miscellaneous_Mathematical_Symbols-A - | '\u27ec' // Miscellaneous_Mathematical_Symbols-A - | '\u27ee' // Miscellaneous_Mathematical_Symbols-A - | '\u2983' // Miscellaneous_Mathematical_Symbols-B - | '\u2985' // Miscellaneous_Mathematical_Symbols-B - | '\u2987' // Miscellaneous_Mathematical_Symbols-B - | '\u2989' // Miscellaneous_Mathematical_Symbols-B - | '\u298b' // Miscellaneous_Mathematical_Symbols-B - | '\u298d' // Miscellaneous_Mathematical_Symbols-B - | '\u298f' // Miscellaneous_Mathematical_Symbols-B - | '\u2991' // Miscellaneous_Mathematical_Symbols-B - | '\u2993' // Miscellaneous_Mathematical_Symbols-B - | '\u2995' // Miscellaneous_Mathematical_Symbols-B - | '\u2997' // Miscellaneous_Mathematical_Symbols-B - | '\u29d8' // Miscellaneous_Mathematical_Symbols-B - | '\u29da' // Miscellaneous_Mathematical_Symbols-B - | '\u29fc' // Miscellaneous_Mathematical_Symbols-B - | '\u2e22' // Supplemental_Punctuation - | '\u2e24' // Supplemental_Punctuation - | '\u2e26' // Supplemental_Punctuation - | '\u2e28' // Supplemental_Punctuation - | '\u2e42' // Supplemental_Punctuation - | '\u3008' // CJK_Symbols_and_Punctuation - | '\u300a' // CJK_Symbols_and_Punctuation - | '\u300c' // CJK_Symbols_and_Punctuation - | '\u300e' // CJK_Symbols_and_Punctuation - | '\u3010' // CJK_Symbols_and_Punctuation - | '\u3014' // CJK_Symbols_and_Punctuation - | '\u3016' // CJK_Symbols_and_Punctuation - | '\u3018' // CJK_Symbols_and_Punctuation - | '\u301a' // CJK_Symbols_and_Punctuation - | '\u301d' // CJK_Symbols_and_Punctuation - | '\ufd3f' // Arabic_Presentation_Forms-A - | '\ufe17' // Vertical_Forms - | '\ufe35' // CJK_Compatibility_Forms - | '\ufe37' // CJK_Compatibility_Forms - | '\ufe39' // CJK_Compatibility_Forms - | '\ufe3b' // CJK_Compatibility_Forms - | '\ufe3d' // CJK_Compatibility_Forms - | '\ufe3f' // CJK_Compatibility_Forms - | '\ufe41' // CJK_Compatibility_Forms - | '\ufe43' // CJK_Compatibility_Forms - | '\ufe47' // CJK_Compatibility_Forms - | '\ufe59' // Small_Form_Variants - | '\ufe5b' // Small_Form_Variants - | '\ufe5d' // Small_Form_Variants - | '\uff08' // Halfwidth_and_Fullwidth_Forms - | '\uff3b' // Halfwidth_and_Fullwidth_Forms - | '\uff5b' // Halfwidth_and_Fullwidth_Forms - | '\uff5f' // Halfwidth_and_Fullwidth_Forms - | '\uff62' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Ps + : '\u0028' // Basic_Latin + | '\u005b' // Basic_Latin + | '\u007b' // Basic_Latin + | '\u0f3a' // Tibetan + | '\u0f3c' // Tibetan + | '\u169b' // Ogham + | '\u201a' // General_Punctuation + | '\u201e' // General_Punctuation + | '\u2045' // General_Punctuation + | '\u207d' // Superscripts_and_Subscripts + | '\u208d' // Superscripts_and_Subscripts + | '\u2308' // Miscellaneous_Technical + | '\u230a' // Miscellaneous_Technical + | '\u2329' // Miscellaneous_Technical + | '\u2768' // Dingbats + | '\u276a' // Dingbats + | '\u276c' // Dingbats + | '\u276e' // Dingbats + | '\u2770' // Dingbats + | '\u2772' // Dingbats + | '\u2774' // Dingbats + | '\u27c5' // Miscellaneous_Mathematical_Symbols-A + | '\u27e6' // Miscellaneous_Mathematical_Symbols-A + | '\u27e8' // Miscellaneous_Mathematical_Symbols-A + | '\u27ea' // Miscellaneous_Mathematical_Symbols-A + | '\u27ec' // Miscellaneous_Mathematical_Symbols-A + | '\u27ee' // Miscellaneous_Mathematical_Symbols-A + | '\u2983' // Miscellaneous_Mathematical_Symbols-B + | '\u2985' // Miscellaneous_Mathematical_Symbols-B + | '\u2987' // Miscellaneous_Mathematical_Symbols-B + | '\u2989' // Miscellaneous_Mathematical_Symbols-B + | '\u298b' // Miscellaneous_Mathematical_Symbols-B + | '\u298d' // Miscellaneous_Mathematical_Symbols-B + | '\u298f' // Miscellaneous_Mathematical_Symbols-B + | '\u2991' // Miscellaneous_Mathematical_Symbols-B + | '\u2993' // Miscellaneous_Mathematical_Symbols-B + | '\u2995' // Miscellaneous_Mathematical_Symbols-B + | '\u2997' // Miscellaneous_Mathematical_Symbols-B + | '\u29d8' // Miscellaneous_Mathematical_Symbols-B + | '\u29da' // Miscellaneous_Mathematical_Symbols-B + | '\u29fc' // Miscellaneous_Mathematical_Symbols-B + | '\u2e22' // Supplemental_Punctuation + | '\u2e24' // Supplemental_Punctuation + | '\u2e26' // Supplemental_Punctuation + | '\u2e28' // Supplemental_Punctuation + | '\u2e42' // Supplemental_Punctuation + | '\u3008' // CJK_Symbols_and_Punctuation + | '\u300a' // CJK_Symbols_and_Punctuation + | '\u300c' // CJK_Symbols_and_Punctuation + | '\u300e' // CJK_Symbols_and_Punctuation + | '\u3010' // CJK_Symbols_and_Punctuation + | '\u3014' // CJK_Symbols_and_Punctuation + | '\u3016' // CJK_Symbols_and_Punctuation + | '\u3018' // CJK_Symbols_and_Punctuation + | '\u301a' // CJK_Symbols_and_Punctuation + | '\u301d' // CJK_Symbols_and_Punctuation + | '\ufd3f' // Arabic_Presentation_Forms-A + | '\ufe17' // Vertical_Forms + | '\ufe35' // CJK_Compatibility_Forms + | '\ufe37' // CJK_Compatibility_Forms + | '\ufe39' // CJK_Compatibility_Forms + | '\ufe3b' // CJK_Compatibility_Forms + | '\ufe3d' // CJK_Compatibility_Forms + | '\ufe3f' // CJK_Compatibility_Forms + | '\ufe41' // CJK_Compatibility_Forms + | '\ufe43' // CJK_Compatibility_Forms + | '\ufe47' // CJK_Compatibility_Forms + | '\ufe59' // Small_Form_Variants + | '\ufe5b' // Small_Form_Variants + | '\ufe5d' // Small_Form_Variants + | '\uff08' // Halfwidth_and_Fullwidth_Forms + | '\uff3b' // Halfwidth_and_Fullwidth_Forms + | '\uff5b' // Halfwidth_and_Fullwidth_Forms + | '\uff5f' // Halfwidth_and_Fullwidth_Forms + | '\uff62' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Sc: - '\u0024' // Basic_Latin - | '\u00a2'..'\u00a5' // Latin-1_Supplement - | '\u058f' // (Absent from Blocks.txt) - | '\u060b' // Arabic - | '\u09f2'..'\u09f3' // Bengali - | '\u09fb' // Bengali - | '\u0af1' // Gujarati - | '\u0bf9' // Tamil - | '\u0e3f' // Thai - | '\u17db' // Khmer - | '\u20a0'..'\u20be' // Currency_Symbols - | '\ua838' // Common_Indic_Number_Forms - | '\ufdfc' // Arabic_Presentation_Forms-A - | '\ufe69' // Small_Form_Variants - | '\uff04' // Halfwidth_and_Fullwidth_Forms - | '\uffe0'..'\uffe1' // Halfwidth_and_Fullwidth_Forms - | '\uffe5'..'\uffe6' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Sc + : '\u0024' // Basic_Latin + | '\u00a2' ..'\u00a5' // Latin-1_Supplement + | '\u058f' // (Absent from Blocks.txt) + | '\u060b' // Arabic + | '\u09f2' ..'\u09f3' // Bengali + | '\u09fb' // Bengali + | '\u0af1' // Gujarati + | '\u0bf9' // Tamil + | '\u0e3f' // Thai + | '\u17db' // Khmer + | '\u20a0' ..'\u20be' // Currency_Symbols + | '\ua838' // Common_Indic_Number_Forms + | '\ufdfc' // Arabic_Presentation_Forms-A + | '\ufe69' // Small_Form_Variants + | '\uff04' // Halfwidth_and_Fullwidth_Forms + | '\uffe0' ..'\uffe1' // Halfwidth_and_Fullwidth_Forms + | '\uffe5' ..'\uffe6' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Sk: - '\u005e' // Basic_Latin - | '\u0060' // Basic_Latin - | '\u00a8' // Latin-1_Supplement - | '\u00af' // Latin-1_Supplement - | '\u00b4' // Latin-1_Supplement - | '\u00b8' // Latin-1_Supplement - | '\u02c2'..'\u02c5' // Spacing_Modifier_Letters - | '\u02d2'..'\u02df' // Spacing_Modifier_Letters - | '\u02e5'..'\u02eb' // Spacing_Modifier_Letters - | '\u02ed' // Spacing_Modifier_Letters - | '\u02ef'..'\u02ff' // Spacing_Modifier_Letters - | '\u0375' // Greek_and_Coptic - | '\u0384'..'\u0385' // Greek_and_Coptic - | '\u1fbd' // Greek_Extended - | '\u1fbf'..'\u1fc1' // Greek_Extended - | '\u1fcd'..'\u1fcf' // Greek_Extended - | '\u1fdd'..'\u1fdf' // Greek_Extended - | '\u1fed'..'\u1fef' // Greek_Extended - | '\u1ffd'..'\u1ffe' // Greek_Extended - | '\u309b'..'\u309c' // Hiragana - | '\ua700'..'\ua716' // Modifier_Tone_Letters - | '\ua720'..'\ua721' // Latin_Extended-D - | '\ua789'..'\ua78a' // Latin_Extended-D - | '\uab5b' // Latin_Extended-E - | '\ufbb2'..'\ufbc1' // Arabic_Presentation_Forms-A - | '\uff3e' // Halfwidth_and_Fullwidth_Forms - | '\uff40' // Halfwidth_and_Fullwidth_Forms - | '\uffe3' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Sk + : '\u005e' // Basic_Latin + | '\u0060' // Basic_Latin + | '\u00a8' // Latin-1_Supplement + | '\u00af' // Latin-1_Supplement + | '\u00b4' // Latin-1_Supplement + | '\u00b8' // Latin-1_Supplement + | '\u02c2' ..'\u02c5' // Spacing_Modifier_Letters + | '\u02d2' ..'\u02df' // Spacing_Modifier_Letters + | '\u02e5' ..'\u02eb' // Spacing_Modifier_Letters + | '\u02ed' // Spacing_Modifier_Letters + | '\u02ef' ..'\u02ff' // Spacing_Modifier_Letters + | '\u0375' // Greek_and_Coptic + | '\u0384' ..'\u0385' // Greek_and_Coptic + | '\u1fbd' // Greek_Extended + | '\u1fbf' ..'\u1fc1' // Greek_Extended + | '\u1fcd' ..'\u1fcf' // Greek_Extended + | '\u1fdd' ..'\u1fdf' // Greek_Extended + | '\u1fed' ..'\u1fef' // Greek_Extended + | '\u1ffd' ..'\u1ffe' // Greek_Extended + | '\u309b' ..'\u309c' // Hiragana + | '\ua700' ..'\ua716' // Modifier_Tone_Letters + | '\ua720' ..'\ua721' // Latin_Extended-D + | '\ua789' ..'\ua78a' // Latin_Extended-D + | '\uab5b' // Latin_Extended-E + | '\ufbb2' ..'\ufbc1' // Arabic_Presentation_Forms-A + | '\uff3e' // Halfwidth_and_Fullwidth_Forms + | '\uff40' // Halfwidth_and_Fullwidth_Forms + | '\uffe3' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_Sm: - '\u002b' // Basic_Latin - | '\u003c'..'\u003e' // Basic_Latin - | '\u007c' // Basic_Latin - | '\u007e' // Basic_Latin - | '\u00ac' // Latin-1_Supplement - | '\u00b1' // Latin-1_Supplement - | '\u00d7' // Latin-1_Supplement - | '\u00f7' // Latin-1_Supplement - | '\u03f6' // Greek_and_Coptic - | '\u0606'..'\u0608' // Arabic - | '\u2044' // General_Punctuation - | '\u2052' // General_Punctuation - | '\u207a'..'\u207c' // Superscripts_and_Subscripts - | '\u208a'..'\u208c' // Superscripts_and_Subscripts - | '\u2118' // Letterlike_Symbols - | '\u2140'..'\u2144' // Letterlike_Symbols - | '\u214b' // Letterlike_Symbols - | '\u2190'..'\u2194' // Arrows - | '\u219a'..'\u219b' // Arrows - | '\u21a0' // Arrows - | '\u21a3' // Arrows - | '\u21a6' // Arrows - | '\u21ae' // Arrows - | '\u21ce'..'\u21cf' // Arrows - | '\u21d2' // Arrows - | '\u21d4' // Arrows - | '\u21f4'..'\u22ff' // Arrows - | '\u2320'..'\u2321' // Miscellaneous_Technical - | '\u237c' // Miscellaneous_Technical - | '\u239b'..'\u23b3' // Miscellaneous_Technical - | '\u23dc'..'\u23e1' // Miscellaneous_Technical - | '\u25b7' // Geometric_Shapes - | '\u25c1' // Geometric_Shapes - | '\u25f8'..'\u25ff' // Geometric_Shapes - | '\u266f' // Miscellaneous_Symbols - | '\u27c0'..'\u27c4' // Miscellaneous_Mathematical_Symbols-A - | '\u27c7'..'\u27e5' // Miscellaneous_Mathematical_Symbols-A - | '\u27f0'..'\u27ff' // Supplemental_Arrows-A - | '\u2900'..'\u2982' // Supplemental_Arrows-B - | '\u2999'..'\u29d7' // Miscellaneous_Mathematical_Symbols-B - | '\u29dc'..'\u29fb' // Miscellaneous_Mathematical_Symbols-B - | '\u29fe'..'\u2aff' // Miscellaneous_Mathematical_Symbols-B - | '\u2b30'..'\u2b44' // Miscellaneous_Symbols_and_Arrows - | '\u2b47'..'\u2b4c' // Miscellaneous_Symbols_and_Arrows - | '\ufb29' // Alphabetic_Presentation_Forms - | '\ufe62' // Small_Form_Variants - | '\ufe64'..'\ufe66' // Small_Form_Variants - | '\uff0b' // Halfwidth_and_Fullwidth_Forms - | '\uff1c'..'\uff1e' // Halfwidth_and_Fullwidth_Forms - | '\uff5c' // Halfwidth_and_Fullwidth_Forms - | '\uff5e' // Halfwidth_and_Fullwidth_Forms - | '\uffe2' // Halfwidth_and_Fullwidth_Forms - | '\uffe9'..'\uffec' // Halfwidth_and_Fullwidth_Forms -; +CLASSIFY_Sm + : '\u002b' // Basic_Latin + | '\u003c' ..'\u003e' // Basic_Latin + | '\u007c' // Basic_Latin + | '\u007e' // Basic_Latin + | '\u00ac' // Latin-1_Supplement + | '\u00b1' // Latin-1_Supplement + | '\u00d7' // Latin-1_Supplement + | '\u00f7' // Latin-1_Supplement + | '\u03f6' // Greek_and_Coptic + | '\u0606' ..'\u0608' // Arabic + | '\u2044' // General_Punctuation + | '\u2052' // General_Punctuation + | '\u207a' ..'\u207c' // Superscripts_and_Subscripts + | '\u208a' ..'\u208c' // Superscripts_and_Subscripts + | '\u2118' // Letterlike_Symbols + | '\u2140' ..'\u2144' // Letterlike_Symbols + | '\u214b' // Letterlike_Symbols + | '\u2190' ..'\u2194' // Arrows + | '\u219a' ..'\u219b' // Arrows + | '\u21a0' // Arrows + | '\u21a3' // Arrows + | '\u21a6' // Arrows + | '\u21ae' // Arrows + | '\u21ce' ..'\u21cf' // Arrows + | '\u21d2' // Arrows + | '\u21d4' // Arrows + | '\u21f4' ..'\u22ff' // Arrows + | '\u2320' ..'\u2321' // Miscellaneous_Technical + | '\u237c' // Miscellaneous_Technical + | '\u239b' ..'\u23b3' // Miscellaneous_Technical + | '\u23dc' ..'\u23e1' // Miscellaneous_Technical + | '\u25b7' // Geometric_Shapes + | '\u25c1' // Geometric_Shapes + | '\u25f8' ..'\u25ff' // Geometric_Shapes + | '\u266f' // Miscellaneous_Symbols + | '\u27c0' ..'\u27c4' // Miscellaneous_Mathematical_Symbols-A + | '\u27c7' ..'\u27e5' // Miscellaneous_Mathematical_Symbols-A + | '\u27f0' ..'\u27ff' // Supplemental_Arrows-A + | '\u2900' ..'\u2982' // Supplemental_Arrows-B + | '\u2999' ..'\u29d7' // Miscellaneous_Mathematical_Symbols-B + | '\u29dc' ..'\u29fb' // Miscellaneous_Mathematical_Symbols-B + | '\u29fe' ..'\u2aff' // Miscellaneous_Mathematical_Symbols-B + | '\u2b30' ..'\u2b44' // Miscellaneous_Symbols_and_Arrows + | '\u2b47' ..'\u2b4c' // Miscellaneous_Symbols_and_Arrows + | '\ufb29' // Alphabetic_Presentation_Forms + | '\ufe62' // Small_Form_Variants + | '\ufe64' ..'\ufe66' // Small_Form_Variants + | '\uff0b' // Halfwidth_and_Fullwidth_Forms + | '\uff1c' ..'\uff1e' // Halfwidth_and_Fullwidth_Forms + | '\uff5c' // Halfwidth_and_Fullwidth_Forms + | '\uff5e' // Halfwidth_and_Fullwidth_Forms + | '\uffe2' // Halfwidth_and_Fullwidth_Forms + | '\uffe9' ..'\uffec' // Halfwidth_and_Fullwidth_Forms + ; -CLASSIFY_So: - '\u00a6' // Latin-1_Supplement - | '\u00a9' // Latin-1_Supplement - | '\u00ae' // Latin-1_Supplement - | '\u00b0' // Latin-1_Supplement - | '\u0482' // Cyrillic - | '\u058d'..'\u058e' // Armenian - | '\u060e'..'\u060f' // Arabic - | '\u06de' // Arabic - | '\u06e9' // Arabic - | '\u06fd'..'\u06fe' // Arabic - | '\u07f6' // NKo - | '\u09fa' // Bengali - | '\u0b70' // Oriya - | '\u0bf3'..'\u0bf8' // Tamil - | '\u0bfa' // Tamil - | '\u0c7f' // (Absent from Blocks.txt) - | '\u0d4f' // Malayalam - | '\u0d79' // Malayalam - | '\u0f01'..'\u0f03' // Tibetan - | '\u0f13' // Tibetan - | '\u0f15'..'\u0f17' // Tibetan - | '\u0f1a'..'\u0f1f' // Tibetan - | '\u0f34' // Tibetan - | '\u0f36' // Tibetan - | '\u0f38' // Tibetan - | '\u0fbe'..'\u0fc5' // Tibetan - | '\u0fc7'..'\u0fcc' // Tibetan - | '\u0fce'..'\u0fcf' // Tibetan - | '\u0fd5'..'\u0fd8' // Tibetan - | '\u109e'..'\u109f' // Myanmar - | '\u1390'..'\u1399' // Ethiopic_Supplement - | '\u1940' // Limbu - | '\u19de'..'\u19ff' // New_Tai_Lue - | '\u1b61'..'\u1b6a' // Balinese - | '\u1b74'..'\u1b7c' // Balinese - | '\u2100'..'\u2101' // Letterlike_Symbols - | '\u2103'..'\u2106' // Letterlike_Symbols - | '\u2108'..'\u2109' // Letterlike_Symbols - | '\u2114' // Letterlike_Symbols - | '\u2116'..'\u2117' // Letterlike_Symbols - | '\u211e'..'\u2123' // Letterlike_Symbols - | '\u2125' // Letterlike_Symbols - | '\u2127' // Letterlike_Symbols - | '\u2129' // Letterlike_Symbols - | '\u212e' // Letterlike_Symbols - | '\u213a'..'\u213b' // Letterlike_Symbols - | '\u214a' // Letterlike_Symbols - | '\u214c'..'\u214d' // Letterlike_Symbols - | '\u214f' // (Absent from Blocks.txt) - | '\u218a'..'\u218b' // Number_Forms - | '\u2195'..'\u2199' // Arrows - | '\u219c'..'\u219f' // Arrows - | '\u21a1'..'\u21a2' // Arrows - | '\u21a4'..'\u21a5' // Arrows - | '\u21a7'..'\u21ad' // Arrows - | '\u21af'..'\u21cd' // Arrows - | '\u21d0'..'\u21d1' // Arrows - | '\u21d3' // Arrows - | '\u21d5'..'\u21f3' // Arrows - | '\u2300'..'\u2307' // Miscellaneous_Technical - | '\u230c'..'\u231f' // Miscellaneous_Technical - | '\u2322'..'\u2328' // Miscellaneous_Technical - | '\u232b'..'\u237b' // Miscellaneous_Technical - | '\u237d'..'\u239a' // Miscellaneous_Technical - | '\u23b4'..'\u23db' // Miscellaneous_Technical - | '\u23e2'..'\u23fe' // Miscellaneous_Technical - | '\u2400'..'\u2426' // Control_Pictures - | '\u2440'..'\u244a' // Optical_Character_Recognition - | '\u249c'..'\u24e9' // Enclosed_Alphanumerics - | '\u2500'..'\u25b6' // Box_Drawing - | '\u25b8'..'\u25c0' // Geometric_Shapes - | '\u25c2'..'\u25f7' // Geometric_Shapes - | '\u2600'..'\u266e' // Miscellaneous_Symbols - | '\u2670'..'\u2767' // Miscellaneous_Symbols - | '\u2794'..'\u27bf' // Dingbats - | '\u2800'..'\u28ff' // Braille_Patterns - | '\u2b00'..'\u2b2f' // Miscellaneous_Symbols_and_Arrows - | '\u2b45'..'\u2b46' // Miscellaneous_Symbols_and_Arrows - | '\u2b4d'..'\u2b73' // Miscellaneous_Symbols_and_Arrows - | '\u2b76'..'\u2b95' // Miscellaneous_Symbols_and_Arrows - | '\u2b98'..'\u2bb9' // Miscellaneous_Symbols_and_Arrows - | '\u2bbd'..'\u2bc8' // Miscellaneous_Symbols_and_Arrows - | '\u2bca'..'\u2bd1' // Miscellaneous_Symbols_and_Arrows - | '\u2bec'..'\u2bef' // Miscellaneous_Symbols_and_Arrows - | '\u2ce5'..'\u2cea' // Coptic - | '\u2e80'..'\u2e99' // CJK_Radicals_Supplement - | '\u2e9b'..'\u2ef3' // CJK_Radicals_Supplement - | '\u2f00'..'\u2fd5' // Kangxi_Radicals - | '\u2ff0'..'\u2ffb' // Ideographic_Description_Characters - | '\u3004' // CJK_Symbols_and_Punctuation - | '\u3012'..'\u3013' // CJK_Symbols_and_Punctuation - | '\u3020' // CJK_Symbols_and_Punctuation - | '\u3036'..'\u3037' // CJK_Symbols_and_Punctuation - | '\u303e'..'\u303f' // CJK_Symbols_and_Punctuation - | '\u3190'..'\u3191' // Kanbun - | '\u3196'..'\u319f' // Kanbun - | '\u31c0'..'\u31e3' // CJK_Strokes - | '\u3200'..'\u321e' // Enclosed_CJK_Letters_and_Months - | '\u322a'..'\u3247' // Enclosed_CJK_Letters_and_Months - | '\u3250' // Enclosed_CJK_Letters_and_Months - | '\u3260'..'\u327f' // Enclosed_CJK_Letters_and_Months - | '\u328a'..'\u32b0' // Enclosed_CJK_Letters_and_Months - | '\u32c0'..'\u32fe' // Enclosed_CJK_Letters_and_Months - | '\u3300'..'\u33ff' // CJK_Compatibility - | '\u4dc0'..'\u4dff' // Yijing_Hexagram_Symbols - | '\ua490'..'\ua4c6' // Yi_Radicals - | '\ua828'..'\ua82b' // Syloti_Nagri - | '\ua836'..'\ua837' // Common_Indic_Number_Forms - | '\ua839' // Common_Indic_Number_Forms - | '\uaa77'..'\uaa79' // Myanmar_Extended-A - | '\ufdfd' // Arabic_Presentation_Forms-A - | '\uffe4' // Halfwidth_and_Fullwidth_Forms - | '\uffe8' // Halfwidth_and_Fullwidth_Forms - | '\uffed'..'\uffee' // Halfwidth_and_Fullwidth_Forms - | '\ufffc'..'\ufffd' // Specials -; +CLASSIFY_So + : '\u00a6' // Latin-1_Supplement + | '\u00a9' // Latin-1_Supplement + | '\u00ae' // Latin-1_Supplement + | '\u00b0' // Latin-1_Supplement + | '\u0482' // Cyrillic + | '\u058d' ..'\u058e' // Armenian + | '\u060e' ..'\u060f' // Arabic + | '\u06de' // Arabic + | '\u06e9' // Arabic + | '\u06fd' ..'\u06fe' // Arabic + | '\u07f6' // NKo + | '\u09fa' // Bengali + | '\u0b70' // Oriya + | '\u0bf3' ..'\u0bf8' // Tamil + | '\u0bfa' // Tamil + | '\u0c7f' // (Absent from Blocks.txt) + | '\u0d4f' // Malayalam + | '\u0d79' // Malayalam + | '\u0f01' ..'\u0f03' // Tibetan + | '\u0f13' // Tibetan + | '\u0f15' ..'\u0f17' // Tibetan + | '\u0f1a' ..'\u0f1f' // Tibetan + | '\u0f34' // Tibetan + | '\u0f36' // Tibetan + | '\u0f38' // Tibetan + | '\u0fbe' ..'\u0fc5' // Tibetan + | '\u0fc7' ..'\u0fcc' // Tibetan + | '\u0fce' ..'\u0fcf' // Tibetan + | '\u0fd5' ..'\u0fd8' // Tibetan + | '\u109e' ..'\u109f' // Myanmar + | '\u1390' ..'\u1399' // Ethiopic_Supplement + | '\u1940' // Limbu + | '\u19de' ..'\u19ff' // New_Tai_Lue + | '\u1b61' ..'\u1b6a' // Balinese + | '\u1b74' ..'\u1b7c' // Balinese + | '\u2100' ..'\u2101' // Letterlike_Symbols + | '\u2103' ..'\u2106' // Letterlike_Symbols + | '\u2108' ..'\u2109' // Letterlike_Symbols + | '\u2114' // Letterlike_Symbols + | '\u2116' ..'\u2117' // Letterlike_Symbols + | '\u211e' ..'\u2123' // Letterlike_Symbols + | '\u2125' // Letterlike_Symbols + | '\u2127' // Letterlike_Symbols + | '\u2129' // Letterlike_Symbols + | '\u212e' // Letterlike_Symbols + | '\u213a' ..'\u213b' // Letterlike_Symbols + | '\u214a' // Letterlike_Symbols + | '\u214c' ..'\u214d' // Letterlike_Symbols + | '\u214f' // (Absent from Blocks.txt) + | '\u218a' ..'\u218b' // Number_Forms + | '\u2195' ..'\u2199' // Arrows + | '\u219c' ..'\u219f' // Arrows + | '\u21a1' ..'\u21a2' // Arrows + | '\u21a4' ..'\u21a5' // Arrows + | '\u21a7' ..'\u21ad' // Arrows + | '\u21af' ..'\u21cd' // Arrows + | '\u21d0' ..'\u21d1' // Arrows + | '\u21d3' // Arrows + | '\u21d5' ..'\u21f3' // Arrows + | '\u2300' ..'\u2307' // Miscellaneous_Technical + | '\u230c' ..'\u231f' // Miscellaneous_Technical + | '\u2322' ..'\u2328' // Miscellaneous_Technical + | '\u232b' ..'\u237b' // Miscellaneous_Technical + | '\u237d' ..'\u239a' // Miscellaneous_Technical + | '\u23b4' ..'\u23db' // Miscellaneous_Technical + | '\u23e2' ..'\u23fe' // Miscellaneous_Technical + | '\u2400' ..'\u2426' // Control_Pictures + | '\u2440' ..'\u244a' // Optical_Character_Recognition + | '\u249c' ..'\u24e9' // Enclosed_Alphanumerics + | '\u2500' ..'\u25b6' // Box_Drawing + | '\u25b8' ..'\u25c0' // Geometric_Shapes + | '\u25c2' ..'\u25f7' // Geometric_Shapes + | '\u2600' ..'\u266e' // Miscellaneous_Symbols + | '\u2670' ..'\u2767' // Miscellaneous_Symbols + | '\u2794' ..'\u27bf' // Dingbats + | '\u2800' ..'\u28ff' // Braille_Patterns + | '\u2b00' ..'\u2b2f' // Miscellaneous_Symbols_and_Arrows + | '\u2b45' ..'\u2b46' // Miscellaneous_Symbols_and_Arrows + | '\u2b4d' ..'\u2b73' // Miscellaneous_Symbols_and_Arrows + | '\u2b76' ..'\u2b95' // Miscellaneous_Symbols_and_Arrows + | '\u2b98' ..'\u2bb9' // Miscellaneous_Symbols_and_Arrows + | '\u2bbd' ..'\u2bc8' // Miscellaneous_Symbols_and_Arrows + | '\u2bca' ..'\u2bd1' // Miscellaneous_Symbols_and_Arrows + | '\u2bec' ..'\u2bef' // Miscellaneous_Symbols_and_Arrows + | '\u2ce5' ..'\u2cea' // Coptic + | '\u2e80' ..'\u2e99' // CJK_Radicals_Supplement + | '\u2e9b' ..'\u2ef3' // CJK_Radicals_Supplement + | '\u2f00' ..'\u2fd5' // Kangxi_Radicals + | '\u2ff0' ..'\u2ffb' // Ideographic_Description_Characters + | '\u3004' // CJK_Symbols_and_Punctuation + | '\u3012' ..'\u3013' // CJK_Symbols_and_Punctuation + | '\u3020' // CJK_Symbols_and_Punctuation + | '\u3036' ..'\u3037' // CJK_Symbols_and_Punctuation + | '\u303e' ..'\u303f' // CJK_Symbols_and_Punctuation + | '\u3190' ..'\u3191' // Kanbun + | '\u3196' ..'\u319f' // Kanbun + | '\u31c0' ..'\u31e3' // CJK_Strokes + | '\u3200' ..'\u321e' // Enclosed_CJK_Letters_and_Months + | '\u322a' ..'\u3247' // Enclosed_CJK_Letters_and_Months + | '\u3250' // Enclosed_CJK_Letters_and_Months + | '\u3260' ..'\u327f' // Enclosed_CJK_Letters_and_Months + | '\u328a' ..'\u32b0' // Enclosed_CJK_Letters_and_Months + | '\u32c0' ..'\u32fe' // Enclosed_CJK_Letters_and_Months + | '\u3300' ..'\u33ff' // CJK_Compatibility + | '\u4dc0' ..'\u4dff' // Yijing_Hexagram_Symbols + | '\ua490' ..'\ua4c6' // Yi_Radicals + | '\ua828' ..'\ua82b' // Syloti_Nagri + | '\ua836' ..'\ua837' // Common_Indic_Number_Forms + | '\ua839' // Common_Indic_Number_Forms + | '\uaa77' ..'\uaa79' // Myanmar_Extended-A + | '\ufdfd' // Arabic_Presentation_Forms-A + | '\uffe4' // Halfwidth_and_Fullwidth_Forms + | '\uffe8' // Halfwidth_and_Fullwidth_Forms + | '\uffed' ..'\uffee' // Halfwidth_and_Fullwidth_Forms + | '\ufffc' ..'\ufffd' // Specials + ; -CLASSIFY_Zl: - '\u2028' // General_Punctuation -; +CLASSIFY_Zl + : '\u2028' // General_Punctuation + ; -CLASSIFY_Zp: - '\u2029' // General_Punctuation -; +CLASSIFY_Zp + : '\u2029' // General_Punctuation + ; -CLASSIFY_Zs: - '\u0020' // Basic_Latin - | '\u00a0' // Latin-1_Supplement - | '\u1680' // Ogham - | '\u2000'..'\u200a' // General_Punctuation - | '\u202f' // General_Punctuation - | '\u205f' // General_Punctuation - | '\u3000' // CJK_Symbols_and_Punctuation -; -CLASSIFY_C : - CLASSIFY_Cc - | CLASSIFY_Cf - | CLASSIFY_Co - | CLASSIFY_Cs // from local/PropertyValueAliases.txt -; +CLASSIFY_Zs + : '\u0020' // Basic_Latin + | '\u00a0' // Latin-1_Supplement + | '\u1680' // Ogham + | '\u2000' ..'\u200a' // General_Punctuation + | '\u202f' // General_Punctuation + | '\u205f' // General_Punctuation + | '\u3000' // CJK_Symbols_and_Punctuation + ; -CLASSIFY_LC : - CLASSIFY_Ll - | CLASSIFY_Lt - | CLASSIFY_Lu // from local/PropertyValueAliases.txt -; +CLASSIFY_C + : CLASSIFY_Cc + | CLASSIFY_Cf + | CLASSIFY_Co + | CLASSIFY_Cs // from local/PropertyValueAliases.txt + ; -CLASSIFY_M : - CLASSIFY_Mc - | CLASSIFY_Me - | CLASSIFY_Mn // from local/PropertyValueAliases.txt -; +CLASSIFY_LC + : CLASSIFY_Ll + | CLASSIFY_Lt + | CLASSIFY_Lu // from local/PropertyValueAliases.txt + ; -CLASSIFY_L : - CLASSIFY_Ll - | CLASSIFY_Lm - | CLASSIFY_Lo - | CLASSIFY_Lt - | CLASSIFY_Lu // from local/PropertyValueAliases.txt -; +CLASSIFY_M + : CLASSIFY_Mc + | CLASSIFY_Me + | CLASSIFY_Mn // from local/PropertyValueAliases.txt + ; -CLASSIFY_N : - CLASSIFY_Nd - | CLASSIFY_Nl - | CLASSIFY_No // from local/PropertyValueAliases.txt -; +CLASSIFY_L + : CLASSIFY_Ll + | CLASSIFY_Lm + | CLASSIFY_Lo + | CLASSIFY_Lt + | CLASSIFY_Lu // from local/PropertyValueAliases.txt + ; -CLASSIFY_P : - CLASSIFY_Pc - | CLASSIFY_Pd - | CLASSIFY_Pe - | CLASSIFY_Pf - | CLASSIFY_Pi - | CLASSIFY_Po - | CLASSIFY_Ps // from local/PropertyValueAliases.txt -; +CLASSIFY_N + : CLASSIFY_Nd + | CLASSIFY_Nl + | CLASSIFY_No // from local/PropertyValueAliases.txt + ; -CLASSIFY_S : - CLASSIFY_Sc - | CLASSIFY_Sk - | CLASSIFY_Sm - | CLASSIFY_So // from local/PropertyValueAliases.txt -; +CLASSIFY_P + : CLASSIFY_Pc + | CLASSIFY_Pd + | CLASSIFY_Pe + | CLASSIFY_Pf + | CLASSIFY_Pi + | CLASSIFY_Po + | CLASSIFY_Ps // from local/PropertyValueAliases.txt + ; -CLASSIFY_Z : - CLASSIFY_Zl - | CLASSIFY_Zp - | CLASSIFY_Zs // from local/PropertyValueAliases.txt -; +CLASSIFY_S + : CLASSIFY_Sc + | CLASSIFY_Sk + | CLASSIFY_Sm + | CLASSIFY_So // from local/PropertyValueAliases.txt + ; +CLASSIFY_Z + : CLASSIFY_Zl + | CLASSIFY_Zp + | CLASSIFY_Zs // from local/PropertyValueAliases.txt + ; /* Unicode codepoint classification */ -CLASSIFY_WS : CLASSIFY_Z + // hand-written rule -; +CLASSIFY_WS + : CLASSIFY_Z+ // hand-written rule + ; -CLASSIFY_ID0 : CLASSIFY_L | '_' // hand-written rule -; +CLASSIFY_ID0 + : CLASSIFY_L + | '_' // hand-written rule + ; -CLASSIFY_ID1 : CLASSIFY_ID0 | CLASSIFY_N // hand-written rule -; +CLASSIFY_ID1 + : CLASSIFY_ID0 + | CLASSIFY_N // hand-written rule + ; -ID : CLASSIFY_ID0 CLASSIFY_ID1 * // hand-written rule -; +ID + : CLASSIFY_ID0 CLASSIFY_ID1* // hand-written rule + ; \ No newline at end of file diff --git a/unreal_angelscript/UnrealAngelscriptLexer.g4 b/unreal_angelscript/UnrealAngelscriptLexer.g4 index d67759f33a..af3388f5d4 100644 --- a/unreal_angelscript/UnrealAngelscriptLexer.g4 +++ b/unreal_angelscript/UnrealAngelscriptLexer.g4 @@ -3,32 +3,37 @@ Based on the C++ grammar made by Camilo Sanchez (Camiloasc1) and Martin Mirchev (Marti2203). See the parser file. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar UnrealAngelscriptLexer; IntegerLiteral: - DecimalLiteral Integersuffix? - | OctalLiteral Integersuffix? - | HexadecimalLiteral Integersuffix? - | BinaryLiteral Integersuffix?; + DecimalLiteral Integersuffix? + | OctalLiteral Integersuffix? + | HexadecimalLiteral Integersuffix? + | BinaryLiteral Integersuffix? +; CharacterLiteral: ('u' | 'U' | 'L')? '\'' Cchar+ '\''; FloatingLiteral: - Fractionalconstant Exponentpart? Floatingsuffix? - | Digitsequence Exponentpart Floatingsuffix?; + Fractionalconstant Exponentpart? Floatingsuffix? + | Digitsequence Exponentpart Floatingsuffix? +; StringLiteral: - '"""' .*? '"""' - | ('n' | 'f')? '"' ( - ~["\\\u0085\u2028\u2029] - | Escapesequence - )* '"'; + '"""' .*? '"""' + | ('n' | 'f')? '"' ( ~["\\\u0085\u2028\u2029] | Escapesequence)* '"' +; UserDefinedLiteral: - UserDefinedIntegerLiteral - | UserDefinedFloatingLiteral - | UserDefinedStringLiteral - | UserDefinedCharacterLiteral; + UserDefinedIntegerLiteral + | UserDefinedFloatingLiteral + | UserDefinedStringLiteral + | UserDefinedCharacterLiteral +; /*Angelscript*/ @@ -58,19 +63,19 @@ Check: 'check'; Mixin: 'mixin'; -Int: 'int'; -Int8: 'int8'; -Int16: 'int16'; -Int32: 'int32'; -Int64: 'int64'; -UInt: 'uint'; -UInt8: 'uint8'; -UInt16: 'uint16'; -UInt32: 'uint32'; -UInt64: 'uint64'; -Float: 'float'; -Double: 'double'; -Bool: 'bool'; +Int : 'int'; +Int8 : 'int8'; +Int16 : 'int16'; +Int32 : 'int32'; +Int64 : 'int64'; +UInt : 'uint'; +UInt8 : 'uint8'; +UInt16 : 'uint16'; +UInt32 : 'uint32'; +UInt64 : 'uint64'; +Float : 'float'; +Double : 'double'; +Bool : 'bool'; /*Keywords*/ @@ -231,10 +236,10 @@ Semi: ';'; Dot: '.'; Identifier: - /* + /* Identifiernondigit | Identifier Identifiernondigit | Identifier DIGIT - */ - Identifiernondigit (Identifiernondigit | DIGIT)*; + */ Identifiernondigit (Identifiernondigit | DIGIT)* +; fragment Identifiernondigit: NONDIGIT; @@ -246,9 +251,7 @@ DecimalLiteral: NONZERODIGIT ('\''? DIGIT)*; OctalLiteral: '0' ('\''? OCTALDIGIT)*; -HexadecimalLiteral: ('0x' | '0X') HEXADECIMALDIGIT ( - '\''? HEXADECIMALDIGIT - )*; +HexadecimalLiteral: ('0x' | '0X') HEXADECIMALDIGIT ( '\''? HEXADECIMALDIGIT)*; BinaryLiteral: ('0b' | '0B') BINARYDIGIT ('\''? BINARYDIGIT)*; @@ -261,10 +264,11 @@ fragment HEXADECIMALDIGIT: [0-9a-fA-F]; fragment BINARYDIGIT: [01]; Integersuffix: - Unsignedsuffix Longsuffix? - | Unsignedsuffix Longlongsuffix? - | Longsuffix Unsignedsuffix? - | Longlongsuffix Unsignedsuffix?; + Unsignedsuffix Longsuffix? + | Unsignedsuffix Longlongsuffix? + | Longsuffix Unsignedsuffix? + | Longlongsuffix Unsignedsuffix? +; fragment Unsignedsuffix: [uU]; @@ -274,39 +278,34 @@ fragment Longlongsuffix: 'll' | 'LL'; fragment Cchar: ~ ['\\\r\n] | Escapesequence; -fragment Escapesequence: - Simpleescapesequence - | Octalescapesequence - | Hexadecimalescapesequence; +fragment Escapesequence: Simpleescapesequence | Octalescapesequence | Hexadecimalescapesequence; fragment Simpleescapesequence: - '\\\'' - | '\\"' - | '\\?' - | '\\\\' - | '\\a' - | '\\b' - | '\\f' - | '\\n' - | '\\r' - | ('\\' ('\r' '\n'? | '\n')) - | '\\t' - | '\\v'; + '\\\'' + | '\\"' + | '\\?' + | '\\\\' + | '\\a' + | '\\b' + | '\\f' + | '\\n' + | '\\r' + | ('\\' ('\r' '\n'? | '\n')) + | '\\t' + | '\\v' +; fragment Octalescapesequence: - '\\' OCTALDIGIT - | '\\' OCTALDIGIT OCTALDIGIT - | '\\' OCTALDIGIT OCTALDIGIT OCTALDIGIT; + '\\' OCTALDIGIT + | '\\' OCTALDIGIT OCTALDIGIT + | '\\' OCTALDIGIT OCTALDIGIT OCTALDIGIT +; fragment Hexadecimalescapesequence: '\\x' HEXADECIMALDIGIT+; -fragment Fractionalconstant: - Digitsequence? '.' Digitsequence - | Digitsequence '.'; +fragment Fractionalconstant: Digitsequence? '.' Digitsequence | Digitsequence '.'; -fragment Exponentpart: - 'e' SIGN? Digitsequence - | 'E' SIGN? Digitsequence; +fragment Exponentpart: 'e' SIGN? Digitsequence | 'E' SIGN? Digitsequence; fragment SIGN: [+-]; @@ -317,14 +316,16 @@ fragment Floatingsuffix: [flFL]; fragment Encodingprefix: 'u8' | 'u' | 'U' | 'L'; UserDefinedIntegerLiteral: - DecimalLiteral Udsuffix - | OctalLiteral Udsuffix - | HexadecimalLiteral Udsuffix - | BinaryLiteral Udsuffix; + DecimalLiteral Udsuffix + | OctalLiteral Udsuffix + | HexadecimalLiteral Udsuffix + | BinaryLiteral Udsuffix +; UserDefinedFloatingLiteral: - Fractionalconstant Exponentpart? Udsuffix - | Digitsequence Exponentpart Udsuffix; + Fractionalconstant Exponentpart? Udsuffix + | Digitsequence Exponentpart Udsuffix +; UserDefinedStringLiteral: StringLiteral Udsuffix; @@ -334,8 +335,8 @@ fragment Udsuffix: Identifier; Whitespace: [ \t]+ -> skip; -Newline: ('\r' '\n'? | '\n') -> skip; -BlockComment: '/*' .*? '*/' -> skip; -LineComment: '//' ~ [\r\n]* -> skip; -PreprocessorBranchRemoval: '#else' .*? '#endif' -> skip; -Preprocessor: ('#if' | '#ifdef' | '#else' | '#endif') ~ [\r\n]* -> skip; \ No newline at end of file +Newline : ('\r' '\n'? | '\n') -> skip; +BlockComment : '/*' .*? '*/' -> skip; +LineComment : '//' ~ [\r\n]* -> skip; +PreprocessorBranchRemoval : '#else' .*? '#endif' -> skip; +Preprocessor : ('#if' | '#ifdef' | '#else' | '#endif') ~ [\r\n]* -> skip; \ No newline at end of file diff --git a/unreal_angelscript/UnrealAngelscriptParser.g4 b/unreal_angelscript/UnrealAngelscriptParser.g4 index 563ebf30d1..0df74ddf91 100644 --- a/unreal_angelscript/UnrealAngelscriptParser.g4 +++ b/unreal_angelscript/UnrealAngelscriptParser.g4 @@ -25,567 +25,755 @@ Based on the C++ grammar made by Camilo Sanchez (Camiloasc1) and Martin Mirchev (Marti2203). See the parser file. */ +// $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 UnrealAngelscriptParser; + options { - tokenVocab = UnrealAngelscriptLexer; + tokenVocab = UnrealAngelscriptLexer; } /*Basic concepts*/ -script: - declarationseq? EOF; +script + : declarationseq? EOF + ; /*Angelscript */ -annotationList: - annotation (Comma annotation)*; - -annotation: - Identifier (Assign expression)?; - -utype: - (UClass | UStruct) LeftParen annotationList? RightParen; - -uproperty: - UProperty LeftParen annotationList? RightParen; - -ufunction: - UFunction LeftParen annotationList? RightParen; - -moduleImport: - Import Identifier (Dot Identifier)* Semi - | Import declSpecifierSeq? declarator postFuncSpecifierSeq? From StringLiteral Semi - ; - -asGeneric: - Identifier Less simpleTypeSpecifierList Greater; - -simpleTypeSpecifierList: - declSpecifierSeq (Comma declSpecifierSeq)*; +annotationList + : annotation (Comma annotation)* + ; -booleanLiteral: False_ | True_; +annotation + : Identifier (Assign expression)? + ; -/*Expressions*/ - -primaryExpression: - literal+ - | This - | LeftParen expression RightParen - | idExpression - | lambdaExpression; - -idExpression: unqualifiedId | qualifiedId; - -unqualifiedId: - Identifier - | operatorFunctionId - | literalOperatorId - | Tilde (className | decltypeSpecifier); +utype + : (UClass | UStruct) LeftParen annotationList? RightParen + ; -qualifiedId: nestedNameSpecifier unqualifiedId; +uproperty + : UProperty LeftParen annotationList? RightParen + ; -nestedNameSpecifier: - (theTypeName | namespaceName | decltypeSpecifier)? Doublecolon - | nestedNameSpecifier Identifier Doublecolon; -lambdaExpression: - lambdaIntroducer lambdaDeclarator? compoundStatement; +ufunction + : UFunction LeftParen annotationList? RightParen + ; -lambdaIntroducer: LeftBracket lambdaCapture? RightBracket; +moduleImport + : Import Identifier (Dot Identifier)* Semi + | Import declSpecifierSeq? declarator postFuncSpecifierSeq? From StringLiteral Semi + ; -lambdaCapture: - captureList - | captureDefault (Comma captureList)?; +asGeneric + : Identifier Less simpleTypeSpecifierList Greater + ; -captureDefault: And | Assign; +simpleTypeSpecifierList + : declSpecifierSeq (Comma declSpecifierSeq)* + ; -captureList: capture (Comma capture)*; +booleanLiteral + : False_ + | True_ + ; -capture: simpleCapture | initcapture; - -simpleCapture: And? Identifier | This; - -initcapture: And? Identifier initializer; +/*Expressions*/ -lambdaDeclarator: LeftParen parameterDeclarationClause? RightParen; +primaryExpression + : literal+ + | This + | LeftParen expression RightParen + | idExpression + | lambdaExpression + ; + +idExpression + : unqualifiedId + | qualifiedId + ; + +unqualifiedId + : Identifier + | operatorFunctionId + | literalOperatorId + | Tilde (className | decltypeSpecifier) + ; + +qualifiedId + : nestedNameSpecifier unqualifiedId + ; + +nestedNameSpecifier + : (theTypeName | namespaceName | decltypeSpecifier)? Doublecolon + | nestedNameSpecifier Identifier Doublecolon + ; + +lambdaExpression + : lambdaIntroducer lambdaDeclarator? compoundStatement + ; + +lambdaIntroducer + : LeftBracket lambdaCapture? RightBracket + ; + +lambdaCapture + : captureList + | captureDefault (Comma captureList)? + ; + +captureDefault + : And + | Assign + ; + +captureList + : capture (Comma capture)* + ; + +capture + : simpleCapture + | initcapture + ; + +simpleCapture + : And? Identifier + | This + ; + +initcapture + : And? Identifier initializer + ; + +lambdaDeclarator + : LeftParen parameterDeclarationClause? RightParen + ; + +postfixExpression + : primaryExpression + | postfixExpression LeftBracket (expression | bracedInitList) RightBracket + | assertSpecifier LeftParen expressionList? RightParen + | postfixExpression LeftParen expressionList? RightParen + | simpleTypeSpecifier ( LeftParen expressionList? RightParen | bracedInitList) + | postfixExpression Dot ( idExpression | pseudoDestructorName) + | postfixExpression (PlusPlus | MinusMinus) + | Cast Less theTypeId Greater LeftParen expression RightParen + | LeftParen (expression | theTypeId) RightParen + ; -postfixExpression: - primaryExpression - | postfixExpression LeftBracket (expression | bracedInitList) RightBracket - | assertSpecifier LeftParen expressionList? RightParen - | postfixExpression LeftParen expressionList? RightParen - | simpleTypeSpecifier ( - LeftParen expressionList? RightParen - | bracedInitList - ) - | postfixExpression Dot ( - idExpression - | pseudoDestructorName - ) - | postfixExpression (PlusPlus | MinusMinus) - | Cast Less theTypeId Greater LeftParen expression RightParen - | LeftParen (expression | theTypeId) RightParen; /* add a middle layer to eliminate duplicated function declarations */ -expressionList: initializerList; - -pseudoDestructorName: - nestedNameSpecifier? (theTypeName Doublecolon)? Tilde theTypeName - | nestedNameSpecifier Doublecolon Tilde theTypeName - | Tilde decltypeSpecifier; - -unaryExpression: - postfixExpression - | (PlusPlus | MinusMinus | unaryOperator) unaryExpression - | LeftParen theTypeId RightParen; - -unaryOperator: Or | Star | And | Plus | Tilde | Minus | Not; - -newPlacement: LeftParen expressionList RightParen; - -newInitializer_: - LeftParen expressionList? RightParen - | bracedInitList; - -castExpression: - unaryExpression - | Cast Less theTypeId Greater LeftParen castExpression RightParen; - -multiplicativeExpression: - castExpression ( - (Star | Div | Mod) castExpression - )*; - -additiveExpression: - multiplicativeExpression ( - (Plus | Minus) multiplicativeExpression - )*; - -shiftExpression: - additiveExpression (shiftOperator additiveExpression)*; - -shiftOperator: Greater Greater | Less Less; - -relationalExpression: - shiftExpression ( - (Less | Greater | LessEqual | GreaterEqual) shiftExpression - )*; - -equalityExpression: - relationalExpression ( - (Equal | NotEqual) relationalExpression - )*; - -andExpression: equalityExpression (And equalityExpression)*; - -exclusiveOrExpression: andExpression (Xor andExpression)*; - -inclusiveOrExpression: - exclusiveOrExpression (Or exclusiveOrExpression)*; - -logicalAndExpression: - inclusiveOrExpression (AndAnd inclusiveOrExpression)*; +expressionList + : initializerList + ; + +pseudoDestructorName + : nestedNameSpecifier? (theTypeName Doublecolon)? Tilde theTypeName + | nestedNameSpecifier Doublecolon Tilde theTypeName + | Tilde decltypeSpecifier + ; + +unaryExpression + : postfixExpression + | (PlusPlus | MinusMinus | unaryOperator) unaryExpression + | LeftParen theTypeId RightParen + ; + +unaryOperator + : Or + | Star + | And + | Plus + | Tilde + | Minus + | Not + ; + +newPlacement + : LeftParen expressionList RightParen + ; + +newInitializer_ + : LeftParen expressionList? RightParen + | bracedInitList + ; + +castExpression + : unaryExpression + | Cast Less theTypeId Greater LeftParen castExpression RightParen + ; + +multiplicativeExpression + : castExpression ((Star | Div | Mod) castExpression)* + ; + +additiveExpression + : multiplicativeExpression ((Plus | Minus) multiplicativeExpression)* + ; + +shiftExpression + : additiveExpression (shiftOperator additiveExpression)* + ; + +shiftOperator + : Greater Greater + | Less Less + ; + +relationalExpression + : shiftExpression ((Less | Greater | LessEqual | GreaterEqual) shiftExpression)* + ; + +equalityExpression + : relationalExpression ((Equal | NotEqual) relationalExpression)* + ; + +andExpression + : equalityExpression (And equalityExpression)* + ; + +exclusiveOrExpression + : andExpression (Xor andExpression)* + ; + +inclusiveOrExpression + : exclusiveOrExpression (Or exclusiveOrExpression)* + ; + +logicalAndExpression + : inclusiveOrExpression (AndAnd inclusiveOrExpression)* + ; + +logicalOrExpression + : logicalAndExpression (OrOr logicalAndExpression)* + ; + +conditionalExpression + : logicalOrExpression (Question expression Colon assignmentExpression)? + ; + +assignmentExpression + : conditionalExpression + | logicalOrExpression assignmentOperator initializerClause + ; + +assignmentOperator + : Assign + | StarAssign + | DivAssign + | ModAssign + | PlusAssign + | MinusAssign + | RightShiftAssign + | LeftShiftAssign + | AndAssign + | XorAssign + | OrAssign + ; + +expression + : assignmentExpression (Comma assignmentExpression)* + ; + +constantExpression + : conditionalExpression + ; -logicalOrExpression: - logicalAndExpression (OrOr logicalAndExpression)*; - -conditionalExpression: - logicalOrExpression ( - Question expression Colon assignmentExpression - )?; - -assignmentExpression: - conditionalExpression - | logicalOrExpression assignmentOperator initializerClause; - -assignmentOperator: - Assign - | StarAssign - | DivAssign - | ModAssign - | PlusAssign - | MinusAssign - | RightShiftAssign - | LeftShiftAssign - | AndAssign - | XorAssign - | OrAssign; - -expression: assignmentExpression (Comma assignmentExpression)*; - -constantExpression: conditionalExpression; /*Statements*/ -statement: - labeledStatement - | declarationStatement - | (expressionStatement - | compoundStatement - | selectionStatement - | iterationStatement - | jumpStatement - ); - -labeledStatement: - (Identifier - | Case constantExpression - | Default - ) Colon statement; - -expressionStatement: expression? Semi; - -compoundStatement: LeftBrace statementSeq? RightBrace; - -statementSeq: statement+; - -selectionStatement: - If LeftParen condition RightParen statement (Else statement)? - | Switch LeftParen condition RightParen statement; - -condition: - expression - | declSpecifierSeq declarator ( - Assign initializerClause - | bracedInitList - ); - -iterationStatement: - While LeftParen condition RightParen statement - | Do statement While LeftParen expression RightParen Semi - | For LeftParen ( - forInitStatement condition? Semi expression? - | forRangeDeclaration Colon forRangeInitializer - ) RightParen statement; - -forInitStatement: expressionStatement | simpleDeclaration; - -forRangeDeclaration: - declSpecifierSeq Identifier; - -forRangeInitializer: expression | bracedInitList; - -jumpStatement: - ( - Break - | Continue - | Return (expression | bracedInitList)? - | Goto Identifier - ) Semi; - -declarationStatement: blockDeclaration; - - +statement + : labeledStatement + | declarationStatement + | ( + expressionStatement + | compoundStatement + | selectionStatement + | iterationStatement + | jumpStatement + ) + ; + +labeledStatement + : (Identifier | Case constantExpression | Default) Colon statement + ; + +expressionStatement + : expression? Semi + ; + +compoundStatement + : LeftBrace statementSeq? RightBrace + ; + +statementSeq + : statement+ + ; + +selectionStatement + : If LeftParen condition RightParen statement (Else statement)? + | Switch LeftParen condition RightParen statement + ; + +condition + : expression + | declSpecifierSeq declarator ( Assign initializerClause | bracedInitList) + ; + +iterationStatement + : While LeftParen condition RightParen statement + | Do statement While LeftParen expression RightParen Semi + | For LeftParen ( + forInitStatement condition? Semi expression? + | forRangeDeclaration Colon forRangeInitializer + ) RightParen statement + ; + +forInitStatement + : expressionStatement + | simpleDeclaration + ; + +forRangeDeclaration + : declSpecifierSeq Identifier + ; + +forRangeInitializer + : expression + | bracedInitList + ; + +jumpStatement + : (Break | Continue | Return (expression | bracedInitList)? | Goto Identifier) Semi + ; + +declarationStatement + : blockDeclaration + ; /*Declarations*/ -declarationseq: declaration+; - -declaration: - moduleImport - | blockDeclaration - | functionDefinition - | namespaceDefinition - | emptyDeclaration_; - -blockDeclaration: - simpleDeclaration - | namespaceAliasDefinition - | aliasDeclaration - | opaqueEnumDeclaration; - -aliasDeclaration: Identifier Assign theTypeId Semi; - -simpleDeclaration: - declSpecifierSeq? (initDeclaratorList | assignmentExpression)? Semi; - -emptyDeclaration_: Semi; - -declSpecifier: - typeSpecifier - | functionSpecifier; - -declSpecifierSeq: declSpecifier+?; - -functionSpecifier: Virtual; - -typedefName: Identifier; - -typeSpecifier: - trailingTypeSpecifier - | classSpecifier - | enumSpecifier; - -trailingTypeSpecifier: - simpleTypeSpecifier - | elaboratedTypeSpecifier - | Const - | And - | Out; - -typeSpecifierSeq: typeSpecifier+; - -trailingTypeSpecifierSeq: - trailingTypeSpecifier+; - -simpleTypeSpecifier: - nestedNameSpecifier? theTypeName - | asGeneric - | Int - | Int8 - | Int16 - | Int32 - | Int64 - | UInt - | UInt8 - | UInt16 - | UInt32 - | UInt64 - | Float - | Double - | Bool - | Void - | Auto - | decltypeSpecifier; - -assertSpecifier: - Ensure - | EnsureAlways - | Check; - -theTypeName: - className - | enumName - | typedefName; - -decltypeSpecifier: LeftParen (expression | Auto) RightParen; - -elaboratedTypeSpecifier: - classKey (nestedNameSpecifier? Identifier | nestedNameSpecifier) - | Enum nestedNameSpecifier? Identifier; - -enumName: Identifier; - -enumSpecifier: - enumHead LeftBrace (enumeratorList Comma?)? RightBrace; - -enumHead: - enumkey (nestedNameSpecifier? Identifier)? enumbase?; - -opaqueEnumDeclaration: - enumkey Identifier enumbase? Semi; - -enumkey: Enum; - -enumbase: Colon typeSpecifierSeq; - -enumeratorList: - enumeratorDefinition (Comma enumeratorDefinition)*; - -enumeratorDefinition: enumerator (Assign constantExpression)?; - -enumerator: Identifier; - -namespaceName: originalNamespaceName | namespaceAlias; - -originalNamespaceName: Identifier; - -namespaceDefinition: - Namespace (Identifier | originalNamespaceName)? LeftBrace namespaceBody = declarationseq - ? RightBrace; - -namespaceAlias: Identifier; - -namespaceAliasDefinition: Namespace Identifier Assign qualifiednamespacespecifier Semi; - -qualifiednamespacespecifier: nestedNameSpecifier? namespaceName; - -balancedTokenSeq: balancedtoken+; - -balancedtoken: - LeftParen balancedTokenSeq RightParen - | LeftBracket balancedTokenSeq RightBracket - | LeftBrace balancedTokenSeq RightBrace - | ~( - LeftParen - | RightParen - | LeftBrace - | RightBrace - | LeftBracket - | RightBracket - )+; - - +declarationseq + : declaration+ + ; + +declaration + : moduleImport + | blockDeclaration + | functionDefinition + | namespaceDefinition + | emptyDeclaration_ + ; + +blockDeclaration + : simpleDeclaration + | namespaceAliasDefinition + | aliasDeclaration + | opaqueEnumDeclaration + ; + +aliasDeclaration + : Identifier Assign theTypeId Semi + ; + +simpleDeclaration + : declSpecifierSeq? (initDeclaratorList | assignmentExpression)? Semi + ; + +emptyDeclaration_ + : Semi + ; + +declSpecifier + : typeSpecifier + | functionSpecifier + ; + +declSpecifierSeq + : declSpecifier+? + ; + +functionSpecifier + : Virtual + ; + +typedefName + : Identifier + ; + +typeSpecifier + : trailingTypeSpecifier + | classSpecifier + | enumSpecifier + ; + +trailingTypeSpecifier + : simpleTypeSpecifier + | elaboratedTypeSpecifier + | Const + | And + | Out + ; + +typeSpecifierSeq + : typeSpecifier+ + ; + +trailingTypeSpecifierSeq + : trailingTypeSpecifier+ + ; + +simpleTypeSpecifier + : nestedNameSpecifier? theTypeName + | asGeneric + | Int + | Int8 + | Int16 + | Int32 + | Int64 + | UInt + | UInt8 + | UInt16 + | UInt32 + | UInt64 + | Float + | Double + | Bool + | Void + | Auto + | decltypeSpecifier + ; + +assertSpecifier + : Ensure + | EnsureAlways + | Check + ; + +theTypeName + : className + | enumName + | typedefName + ; + +decltypeSpecifier + : LeftParen (expression | Auto) RightParen + ; + +elaboratedTypeSpecifier + : classKey (nestedNameSpecifier? Identifier | nestedNameSpecifier) + | Enum nestedNameSpecifier? Identifier + ; + +enumName + : Identifier + ; + +enumSpecifier + : enumHead LeftBrace (enumeratorList Comma?)? RightBrace + ; + +enumHead + : enumkey (nestedNameSpecifier? Identifier)? enumbase? + ; + +opaqueEnumDeclaration + : enumkey Identifier enumbase? Semi + ; + +enumkey + : Enum + ; + +enumbase + : Colon typeSpecifierSeq + ; + +enumeratorList + : enumeratorDefinition (Comma enumeratorDefinition)* + ; + +enumeratorDefinition + : enumerator (Assign constantExpression)? + ; + +enumerator + : Identifier + ; + +namespaceName + : originalNamespaceName + | namespaceAlias + ; + +originalNamespaceName + : Identifier + ; + +namespaceDefinition + : Namespace (Identifier | originalNamespaceName)? LeftBrace namespaceBody = declarationseq? RightBrace + ; + +namespaceAlias + : Identifier + ; + +namespaceAliasDefinition + : Namespace Identifier Assign qualifiednamespacespecifier Semi + ; + +qualifiednamespacespecifier + : nestedNameSpecifier? namespaceName + ; + +balancedTokenSeq + : balancedtoken+ + ; + +balancedtoken + : LeftParen balancedTokenSeq RightParen + | LeftBracket balancedTokenSeq RightBracket + | LeftBrace balancedTokenSeq RightBrace + | ~(LeftParen | RightParen | LeftBrace | RightBrace | LeftBracket | RightBracket)+ + ; /*Declarators*/ -initDeclaratorList: initDeclarator (Comma initDeclarator)*; - -initDeclarator: Identifier initializer?; - -declarator: declaratorDef parametersAndQualifiers; - -declaratorDef: - declaratorid | declaratorDef (parametersAndQualifiers | LeftBracket constantExpression? RightBracket); - -parametersAndQualifiers: - LeftParen parameterDeclarationClause? RightParen Const? refqualifier?; - -refqualifier: And | AndAnd; - -declaratorid: idExpression; - -theTypeId: typeSpecifierSeq; - -parameterDeclarationClause: parameterDeclarationList; - -parameterDeclarationList: - parameterDeclaration (Comma parameterDeclaration)*; - -parameterDeclaration: - declSpecifierSeq Identifier? (Assign initializerClause)?; - -functionDefinition: - ufunction? accessSpecifier? Mixin? declSpecifierSeq? declarator postFuncSpecifierSeq? functionBody; - -functionBody: - compoundStatement - | Assign Default Semi - | Semi; - -initializer: - braceOrEqualInitializer - | LeftParen expressionList RightParen; - -braceOrEqualInitializer: - Assign initializerClause - | bracedInitList; - -initializerClause: assignmentExpression | bracedInitList; - -initializerList: - initializerClause (Comma initializerClause)* Comma?; // I *really* don't like that trailing commas are a thing in AS... - -bracedInitList: (LeftBrace|LeftBracket) (initializerList Comma?)? (RightBrace|RightBracket); - - +initDeclaratorList + : initDeclarator (Comma initDeclarator)* + ; + +initDeclarator + : Identifier initializer? + ; + +declarator + : declaratorDef parametersAndQualifiers + ; + +declaratorDef + : declaratorid + | declaratorDef (parametersAndQualifiers | LeftBracket constantExpression? RightBracket) + ; + +parametersAndQualifiers + : LeftParen parameterDeclarationClause? RightParen Const? refqualifier? + ; + +refqualifier + : And + | AndAnd + ; + +declaratorid + : idExpression + ; + +theTypeId + : typeSpecifierSeq + ; + +parameterDeclarationClause + : parameterDeclarationList + ; + +parameterDeclarationList + : parameterDeclaration (Comma parameterDeclaration)* + ; + +parameterDeclaration + : declSpecifierSeq Identifier? (Assign initializerClause)? + ; + +functionDefinition + : ufunction? accessSpecifier? Mixin? declSpecifierSeq? declarator postFuncSpecifierSeq? functionBody + ; + +functionBody + : compoundStatement + | Assign Default Semi + | Semi + ; + +initializer + : braceOrEqualInitializer + | LeftParen expressionList RightParen + ; + +braceOrEqualInitializer + : Assign initializerClause + | bracedInitList + ; + +initializerClause + : assignmentExpression + | bracedInitList + ; + +initializerList + : initializerClause (Comma initializerClause)* Comma? + ; // I *really* don't like that trailing commas are a thing in AS... + +bracedInitList + : (LeftBrace | LeftBracket) (initializerList Comma?)? (RightBrace | RightBracket) + ; /*Classes*/ -className: Identifier; - -classSpecifier: - classHead LeftBrace memberSpecification? RightBrace; - -classHead: - utype? classKey (classHeadName classVirtSpecifier?)? baseClause?; - -classHeadName: nestedNameSpecifier? className; - -classVirtSpecifier: Final; - -classKey: Class | Struct; - -memberSpecification: - (memberdeclaration | accessSpecifier Colon)+; - -memberdeclaration: - propertyDefinition - | functionDefinition - | aliasDeclaration - | emptyDeclaration_; - -propertyDefinition: - uproperty? accessSpecifier? Default? declSpecifierSeq? (memberDeclaratorList | assignmentExpression)? Semi; - -memberDeclaratorList: - memberDeclarator (Comma memberDeclarator)*; - -memberDeclarator: - declarator ( - postFuncSpecifierSeq? - | braceOrEqualInitializer? - ) - | Identifier? Colon constantExpression - | Identifier; - -postFuncSpecifierSeq: virtualSpecifier+; - -virtualSpecifier: Override | Final | Property; +className + : Identifier + ; + +classSpecifier + : classHead LeftBrace memberSpecification? RightBrace + ; + +classHead + : utype? classKey (classHeadName classVirtSpecifier?)? baseClause? + ; + +classHeadName + : nestedNameSpecifier? className + ; + +classVirtSpecifier + : Final + ; + +classKey + : Class + | Struct + ; + +memberSpecification + : (memberdeclaration | accessSpecifier Colon)+ + ; + +memberdeclaration + : propertyDefinition + | functionDefinition + | aliasDeclaration + | emptyDeclaration_ + ; + +propertyDefinition + : uproperty? accessSpecifier? Default? declSpecifierSeq? ( + memberDeclaratorList + | assignmentExpression + )? Semi + ; + +memberDeclaratorList + : memberDeclarator (Comma memberDeclarator)* + ; + +memberDeclarator + : declarator (postFuncSpecifierSeq? | braceOrEqualInitializer?) + | Identifier? Colon constantExpression + | Identifier + ; + +postFuncSpecifierSeq + : virtualSpecifier+ + ; + +virtualSpecifier + : Override + | Final + | Property + ; /*Derived classes*/ -baseClause: Colon baseSpecifierList; - -baseSpecifierList: baseSpecifier (Comma baseSpecifier)*; - -baseSpecifier: - ( - baseTypeSpecifier - | Virtual accessSpecifier? baseTypeSpecifier - | accessSpecifier Virtual? baseTypeSpecifier - ); - -classOrDeclType: - nestedNameSpecifier? className - | decltypeSpecifier; - -baseTypeSpecifier: classOrDeclType; - -accessSpecifier: Private | Protected | Public; +baseClause + : Colon baseSpecifierList + ; + +baseSpecifierList + : baseSpecifier (Comma baseSpecifier)* + ; + +baseSpecifier + : ( + baseTypeSpecifier + | Virtual accessSpecifier? baseTypeSpecifier + | accessSpecifier Virtual? baseTypeSpecifier + ) + ; + +classOrDeclType + : nestedNameSpecifier? className + | decltypeSpecifier + ; + +baseTypeSpecifier + : classOrDeclType + ; + +accessSpecifier + : Private + | Protected + | Public + ; /*Overloading*/ -operatorFunctionId: Operator theOperator; +operatorFunctionId + : Operator theOperator + ; -literalOperatorId: - Operator ( - StringLiteral Identifier - | UserDefinedStringLiteral - ); +literalOperatorId + : Operator (StringLiteral Identifier | UserDefinedStringLiteral) + ; /*Lexer*/ -theOperator: - | Plus - | Minus - | Star - | Div - | Mod - | Xor - | And - | Or - | Tilde - | Not - | Assign - | Greater - | Less - | GreaterEqual - | PlusAssign - | MinusAssign - | StarAssign - | ModAssign - | XorAssign - | AndAssign - | OrAssign - | Less Less - | Greater Greater - | RightShiftAssign - | LeftShiftAssign - | Equal - | NotEqual - | LessEqual - | AndAnd - | OrOr - | PlusPlus - | MinusMinus - | Comma - | LeftParen RightParen - | LeftBracket RightBracket; - -literal: - IntegerLiteral - | CharacterLiteral - | FloatingLiteral - | StringLiteral - | booleanLiteral - | UserDefinedLiteral - | Nullptr; +theOperator + : + | Plus + | Minus + | Star + | Div + | Mod + | Xor + | And + | Or + | Tilde + | Not + | Assign + | Greater + | Less + | GreaterEqual + | PlusAssign + | MinusAssign + | StarAssign + | ModAssign + | XorAssign + | AndAssign + | OrAssign + | Less Less + | Greater Greater + | RightShiftAssign + | LeftShiftAssign + | Equal + | NotEqual + | LessEqual + | AndAnd + | OrOr + | PlusPlus + | MinusMinus + | Comma + | LeftParen RightParen + | LeftBracket RightBracket + ; + +literal + : IntegerLiteral + | CharacterLiteral + | FloatingLiteral + | StringLiteral + | booleanLiteral + | UserDefinedLiteral + | Nullptr + ; \ No newline at end of file diff --git a/upnp/Upnp.g4 b/upnp/Upnp.g4 index c8dab1a14c..e16ee6e7e6 100644 --- a/upnp/Upnp.g4 +++ b/upnp/Upnp.g4 @@ -26,60 +26,135 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar Upnp; + /* * Parser Rules */ - -searchCrit : (searchExp | ASTERISK) EOF; -searchExp : relExp | searchExp WCHAR+ LOGOP WCHAR+ searchExp | '(' WCHAR* searchExp WCHAR* ')' ; -relExp : PROPERTY WCHAR+ BINOP WCHAR+ quotedVal | PROPERTY WCHAR+ EXISTSOP WCHAR+ BOOLVAL ; -quotedVal : DQUOTE escapedQuote DQUOTE ; -escapedQuote : STRING_LITERAL* WCHAR* STRING_LITERAL*; - + +searchCrit + : (searchExp | ASTERISK) EOF + ; + +searchExp + : relExp + | searchExp WCHAR+ LOGOP WCHAR+ searchExp + | '(' WCHAR* searchExp WCHAR* ')' + ; + +relExp + : PROPERTY WCHAR+ BINOP WCHAR+ quotedVal + | PROPERTY WCHAR+ EXISTSOP WCHAR+ BOOLVAL + ; + +quotedVal + : DQUOTE escapedQuote DQUOTE + ; + +escapedQuote + : STRING_LITERAL* WCHAR* STRING_LITERAL* + ; + /* * Lexer Rules */ - -NUMBER : [0-9]+ ; - -WHITESPACE : [\r\t\n] -> skip ; - -LOGOP : 'and' | 'or' ; -BINOP : RELOP | STRINGOP ; -RELOP : '=' | '!=' | '<' | '<=' | '>' | '>=' ; -STRINGOP : 'contains' | 'doesnotcontain' | 'derivedfrom' ; -EXISTSOP : 'exists' ; -BOOLVAL : 'true' | 'false' ; -WCHAR : SPACE | HTAB ; -PROPERTY : 'res@resolution' - | 'res@duration' - | 'dc:title' - | 'dc:creator' - | 'upnp:actor' - | 'upnp:artist' - | 'upnp:genre' - | 'upnp:album' - | 'dc:date' - | 'upnp:class' - | '@id' - | '@refID' - | '@protocolInfo' - | 'upnp:author' - | 'dc:description' - | 'pv:avKeywords' - | 'pv:rating' - | 'upnp:seriesTitle' - | 'upnp:episodeNumber' - | 'upnp:director' - | 'upnp:rating' - | 'upnp:channelNr' - | 'upnp:channelName' - | 'upnp:longDescription' - | 'pv:capturedate' - | 'pv:custom' ; -HTAB : '\t' ; -SPACE : ' ' ; -DQUOTE : '"' ; -ASTERISK : '*' ; -STRING_LITERAL : [a-zA-Z.] | '\\"'; \ No newline at end of file + +NUMBER + : [0-9]+ + ; + +WHITESPACE + : [\r\t\n] -> skip + ; + +LOGOP + : 'and' + | 'or' + ; + +BINOP + : RELOP + | STRINGOP + ; + +RELOP + : '=' + | '!=' + | '<' + | '<=' + | '>' + | '>=' + ; + +STRINGOP + : 'contains' + | 'doesnotcontain' + | 'derivedfrom' + ; + +EXISTSOP + : 'exists' + ; + +BOOLVAL + : 'true' + | 'false' + ; + +WCHAR + : SPACE + | HTAB + ; + +PROPERTY + : 'res@resolution' + | 'res@duration' + | 'dc:title' + | 'dc:creator' + | 'upnp:actor' + | 'upnp:artist' + | 'upnp:genre' + | 'upnp:album' + | 'dc:date' + | 'upnp:class' + | '@id' + | '@refID' + | '@protocolInfo' + | 'upnp:author' + | 'dc:description' + | 'pv:avKeywords' + | 'pv:rating' + | 'upnp:seriesTitle' + | 'upnp:episodeNumber' + | 'upnp:director' + | 'upnp:rating' + | 'upnp:channelNr' + | 'upnp:channelName' + | 'upnp:longDescription' + | 'pv:capturedate' + | 'pv:custom' + ; + +HTAB + : '\t' + ; + +SPACE + : ' ' + ; + +DQUOTE + : '"' + ; + +ASTERISK + : '*' + ; + +STRING_LITERAL + : [a-zA-Z.] + | '\\"' + ; \ No newline at end of file diff --git a/url/url.g4 b/url/url.g4 index 5eb4b00c7b..112c4b2571 100644 --- a/url/url.g4 +++ b/url/url.g4 @@ -33,90 +33,90 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment] */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar url; url - : uri EOF - ; + : uri EOF + ; uri - : scheme '://' login? host (':' port)? ('/' path?)? query? frag? WS? - ; + : scheme '://' login? host (':' port)? ('/' path?)? query? frag? WS? + ; scheme - : string - ; + : string + ; host - : '/'? hostname - ; + : '/'? hostname + ; hostname - : string #DomainNameOrIPv4Host - | '[' v6host ']' #IPv6Host - ; + : string # DomainNameOrIPv4Host + | '[' v6host ']' # IPv6Host + ; v6host - : '::'? (string | DIGITS) ((':'|'::') (string | DIGITS))* - ; + : '::'? (string | DIGITS) ((':' | '::') (string | DIGITS))* + ; port - : DIGITS - ; + : DIGITS + ; path - : string ('/' string)* '/'? - ; + : string ('/' string)* '/'? + ; user - : string - ; + : string + ; login - : user (':' password)? '@' - ; + : user (':' password)? '@' + ; password - : string - ; + : string + ; frag - : '#' (string | DIGITS) - ; + : '#' (string | DIGITS) + ; query - : '?' search - ; + : '?' search + ; search - : searchparameter ('&' searchparameter)* - ; + : searchparameter ('&' searchparameter)* + ; searchparameter - : string ('=' (string | DIGITS | HEX))? - ; + : string ('=' (string | DIGITS | HEX))? + ; string - : STRING - | DIGITS - ; - + : STRING + | DIGITS + ; DIGITS - : [0-9] + - ; - + : [0-9]+ + ; HEX - : ('%' [a-fA-F0-9] [a-fA-F0-9]) + - ; - + : ('%' [a-fA-F0-9] [a-fA-F0-9])+ + ; STRING - : ([a-zA-Z~0-9] | HEX) ([a-zA-Z0-9.+-] | HEX)* - ; - + : ([a-zA-Z~0-9] | HEX) ([a-zA-Z0-9.+-] | HEX)* + ; WS - : [\r\n] + - ; + : [\r\n]+ + ; \ No newline at end of file diff --git a/useragent/useragent.g4 b/useragent/useragent.g4 index 94408ec8be..dbfbce7202 100644 --- a/useragent/useragent.g4 +++ b/useragent/useragent.g4 @@ -30,38 +30,39 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar useragent; prog - : (product comment?) + EOF - ; + : (product comment?)+ EOF + ; product - : name '/' version - ; + : name '/' version + ; name - : STRING - ; + : STRING + ; version - : STRING ('.' STRING)* - ; + : STRING ('.' STRING)* + ; comment - : COMMENT - ; - + : COMMENT + ; COMMENT - : '(' ~ ')'* ')' - ; - + : '(' ~ ')'* ')' + ; STRING - : [a-zA-Z0-9]+ - ; + : [a-zA-Z0-9]+ + ; WS - : [ \r\n] + -> skip - ; + : [ \r\n]+ -> skip + ; \ No newline at end of file diff --git a/v/V.g4 b/v/V.g4 index cf0cdda9b9..f11a139f0c 100644 --- a/v/V.g4 +++ b/v/V.g4 @@ -30,6 +30,10 @@ * https://golang.org/ref/spec * */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar V; @parser::members { @@ -164,7 +168,7 @@ grammar V; //SourceFile = ModuleClause ";" { ImportDecl ";" } { TopLevelDecl ";" } . sourceFile - : (moduleClause eos)? ( importDecl eos )* ( topLevelDecl eos )* EOF + : (moduleClause eos)? (importDecl eos)* (topLevelDecl eos)* EOF ; /* @@ -178,11 +182,11 @@ moduleClause ; importDecl - : 'import' ( importSpec ) + : 'import' (importSpec) ; importSpec - : ( '.' | IDENTIFIER )? importPath + : ('.' | IDENTIFIER)? importPath ; importPath @@ -202,36 +206,30 @@ declaration : constDecl | varDecl | structDecl -// | typeDecl + // | typeDecl ; - //ConstDecl = "const" ( ConstSpec | "(" { ConstSpec ";" } ")" ) . constDecl - : 'const' '(' ( constSpec eos )* ')' + : 'const' '(' (constSpec eos)* ')' ; //ConstSpec = IdentifierList [ [ Type ] "=" ExpressionList ] . constSpec - : IDENTIFIER '=' expression + : IDENTIFIER '=' expression ; // //IdentifierList = identifier { "," identifier } . identifierList - : IDENTIFIER ( ',' IDENTIFIER )* + : IDENTIFIER (',' IDENTIFIER)* ; //ExpressionList = Expression { "," Expression } . expressionList - : expression ( ',' expression )* + : expression (',' expression)* ; - - - - - ////TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) . //typeDecl // : 'type' ( typeSpec | '(' ( typeSpec eos )* ')' ) @@ -250,7 +248,7 @@ expressionList //Function = Signature FunctionBody . //FunctionBody = Block . functionDecl - : 'fn' IDENTIFIER ( function_ | signature ) + : 'fn' IDENTIFIER (function_ | signature) ; function_ @@ -260,7 +258,7 @@ function_ //MethodDecl = "fn" Receiver MethodName ( Function | Signature ) . //Receiver = Parameters . methodDecl - : 'fn' receiver IDENTIFIER ( function_ | signature ) + : 'fn' receiver IDENTIFIER (function_ | signature) ; receiver @@ -275,10 +273,11 @@ receiver //VarDecl = "mut"? ( noMutDecl ) //noMutDecl = IdentifierList (":=" ExpressionList ) noMutDecl - : identifierList ( ':=' expressionList ) + : identifierList (':=' expressionList) ; + varDecl - : 'mut'? ( noMutDecl ) + : 'mut'? (noMutDecl) ; //Block = "{" StatementList "}" . @@ -288,7 +287,7 @@ block //StatementList = { Statement ";" } . statementList - : ( statement eos )* + : (statement eos)* ; statement @@ -301,22 +300,22 @@ statement | ifStmt | switchStmt | forStmt -// | labeledStmt //TODO: V语言没有goto故也没有对应的label实现 -// | goStmt //TODO: V语言计划在之后引入go关键字, 以待之后添加 -// | gotoStmt //TODO: V语言目前没有 goto 关键字 -// | fallthroughStmt //TODO: V语言目前没有 fallthrough 关键字 -// | selectStmt //TODO: V语言目前没有 select 关键字 -// | deferStmt //TODO: V语言目前没有 defer 关键字, 但有待实现 - ; + // | labeledStmt //TODO: V语言没有goto故也没有对应的label实现 + // | goStmt //TODO: V语言计划在之后引入go关键字, 以待之后添加 + // | gotoStmt //TODO: V语言目前没有 goto 关键字 + // | fallthroughStmt //TODO: V语言目前没有 fallthrough 关键字 + // | selectStmt //TODO: V语言目前没有 select 关键字 + // | deferStmt //TODO: V语言目前没有 defer 关键字, 但有待实现 + ; //SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment . simpleStmt : expressionStmt | incDecStmt | assignment -// | noMutDecl // **: V语言在 for 循环有 C-like 式的 ;; 定义法,而第一个是 noMulDec 形式的定义 -// | emptyStmt //TODO: V语言目前不支持 ; 号结尾 -// | sendStmt //TODO: V语言目前没有类似Go的 send 机制 + // | noMutDecl // **: V语言在 for 循环有 C-like 式的 ;; 定义法,而第一个是 noMulDec 形式的定义 + // | emptyStmt //TODO: V语言目前不支持 ; 号结尾 + // | sendStmt //TODO: V语言目前没有类似Go的 send 机制 ; //ExpressionStmt = Expression . @@ -332,7 +331,7 @@ expressionStmt //IncDecStmt = Expression ( "++" | "--" ) . incDecStmt - : expression ( '++' | '--' ) + : expression ('++' | '--') ; //Assignment = ExpressionList assign_op ExpressionList . @@ -342,11 +341,10 @@ assignment //assign_op = [ add_op | mul_op ] "=" . assign_op - : ('+' | '-' | '|' | '^' | '*' | '/' | '%' | '<<' | '>>' | '&' )? '=' + : ('+' | '-' | '|' | '^' | '*' | '/' | '%' | '<<' | '>>' | '&')? '=' // TODO: V语言目前不支持 a &^= b 这样的运算 ; - //ShortVarDecl = IdentifierList ":=" ExpressionList . //shortVarDecl // : identifierList ':=' expressionList @@ -370,13 +368,13 @@ returnStmt //BreakStmt = "break" [ Label ] . breakStmt // : 'break' IDENTIFIER? - : 'break' //TODO: V语言目前不支持break到可以goto的label + : 'break' //TODO: V语言目前不支持break到可以goto的label ; //ContinueStmt = "continue" [ Label ] . continueStmt // : 'continue' IDENTIFIER? - : 'continue' //TODO: V语言目前不支持continue到可以goto的label + : 'continue' //TODO: V语言目前不支持continue到可以goto的label ; //GotoStmt = "goto" Label . @@ -396,20 +394,20 @@ continueStmt //IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] . ifStmt - : 'if' (simpleStmt ';')? expression block ( 'else' ( ifStmt | block ) )? + : 'if' (simpleStmt ';')? expression block ('else' ( ifStmt | block))? ; //SwitchStmt = ExprSwitchStmt | TypeSwitchStmt . switchStmt : exprSwitchStmt -// | typeSwitchStmt //TODO: V语言不支持type型 switch 语句 + // | typeSwitchStmt //TODO: V语言不支持type型 switch 语句 ; //ExprSwitchStmt = "switch" [ SimpleStmt ";" ] [ Expression ] "{" { ExprCaseClause } "}" . //ExprCaseClause = ExprSwitchCase ":" StatementList . //ExprSwitchCase = "case" ExpressionList | "default" . exprSwitchStmt - : 'switch' ( simpleStmt ';' )? expression? '{' exprCaseClause* '}' + : 'switch' (simpleStmt ';')? expression? '{' exprCaseClause* '}' ; exprCaseClause @@ -417,7 +415,8 @@ exprCaseClause ; exprSwitchCase - : 'case' expressionList | 'default' + : 'case' expressionList + | 'default' ; //TypeSwitchStmt = "switch" [ SimpleStmt ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" . @@ -463,7 +462,7 @@ exprSwitchCase //ForStmt = "for" [ Condition | ForClause | RangeClause ] Block . //Condition = Expression . forStmt - : 'for' ( expression | forClause | inClause )? block + : 'for' (expression | forClause | inClause)? block ; //ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] . @@ -488,19 +487,17 @@ inClause // : 'go' expression // ; - - //Type = TypeName | TypeLit . type_ : typeName | typeLit -// | '(' type ')' //TODO: V语言目前也不支持用类型名多重定义 + // | '(' type ')' //TODO: V语言目前也不支持用类型名多重定义 ; //TypeName = identifier | QualifiedIdent . typeName - : '&'? 'mut'? IDENTIFIER // 可能的自定义struct结构类型 及其引用 - | qualifiedIdent // 已经预定义了的复合类型 + : '&'? 'mut'? IDENTIFIER // 可能的自定义struct结构类型 及其引用 + | qualifiedIdent // 已经预定义了的复合类型 ; //TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType | MapType | . @@ -509,12 +506,11 @@ typeLit | functionType | interfaceType | mapType -// | sliceType // TODO: V语言目前没有切片类型 -// | channelType // TODO: V语言目前没有channel类型 -// | pointerType + // | sliceType // TODO: V语言目前没有切片类型 + // | channelType // TODO: V语言目前没有channel类型 + // | pointerType ; - arrayType : '[' arrayLength? ']' elementType ; @@ -538,7 +534,7 @@ elementType //MethodName = identifier . //InterfaceTypeName = TypeName . interfaceType - : 'interface' IDENTIFIER '{' ( methodSpec eos )* '}' + : 'interface' IDENTIFIER '{' (methodSpec eos)* '}' ; //MapType = "map" "[" KeyType "]" ElementType . @@ -563,7 +559,6 @@ methodSpec | IDENTIFIER parameters ; - //FunctionType = "fn" Signature . //Signature = Parameters [ Result ] . //Result = Parameters | Type . @@ -585,11 +580,11 @@ result ; parameters - : '(' ( parameterList ','? )? ')' + : '(' (parameterList ','?)? ')' ; parameterList - : parameterDecl ( ',' parameterDecl )* + : parameterDecl (',' parameterDecl)* ; parameterDecl @@ -622,13 +617,12 @@ arrayLit : '[' expression (',' expression)* ']' ; - basicLit : INT_LIT | FLOAT_LIT | RUNE_LIT | STRING_LIT -// | IMAGINARY_LIT + // | IMAGINARY_LIT ; operandName @@ -659,12 +653,12 @@ literalType : arrayType | mapType | typeName -// | '[' '...' ']' elementType -// | sliceType + // | '[' '...' ']' elementType + // | sliceType ; literalValue - : '{' ( elementList ','? )? '}' + : '{' (elementList ','?)? '}' ; elementList @@ -692,7 +686,7 @@ element //AnonymousField = [ "*" ] TypeName . //Tag = string_lit . structDecl - : 'struct' IDENTIFIER '{' ( fieldDecl eos )* '}' + : 'struct' IDENTIFIER '{' (fieldDecl eos)* '}' ; fieldDecl @@ -726,9 +720,9 @@ primaryExpr | conversion | primaryExpr selector | primaryExpr index - | primaryExpr arguments -// | primaryExpr typeAssertion //TODO: V语言暂未发现有 typeAssertion 机制 -// | primaryExpr slice //TODO: V语言并不支持数组切片 + | primaryExpr arguments + // | primaryExpr typeAssertion //TODO: V语言暂未发现有 typeAssertion 机制 + // | primaryExpr slice //TODO: V语言并不支持数组切片 ; selector @@ -748,7 +742,7 @@ index // ; arguments - : '(' ( ( expressionList | type_ ( ',' expressionList )? ) ','? )? ')' + : '(' (( expressionList | type_ ( ',' expressionList)?) ','?)? ')' ; //MethodExpr = ReceiverType "." MethodName . @@ -760,7 +754,7 @@ methodExpr receiverType : typeName | '(' receiverType ')' -// | '(' '*' typeName ')' //TODO: V语言不支持 * 指针操作符 + // | '(' '*' typeName ')' //TODO: V语言不支持 * 指针操作符 ; //Expression = UnaryExpr | Expression binary_op Expression . @@ -768,13 +762,33 @@ receiverType expression : unaryExpr -// | expression BINARY_OP expression - | expression ('||' | '&&' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '+' | '-' | '|' | '^' | '*' | '/' | '%' | '<<' | '>>' | '&' | '&^') expression + // | expression BINARY_OP expression + | expression ( + '||' + | '&&' + | '==' + | '!=' + | '<' + | '<=' + | '>' + | '>=' + | '+' + | '-' + | '|' + | '^' + | '*' + | '/' + | '%' + | '<<' + | '>>' + | '&' + | '&^' + ) expression ; unaryExpr : primaryExpr - | ('+'|'-'|'!'|'^'|'*'|'&') unaryExpr + | ('+' | '-' | '!' | '^' | '*' | '&') unaryExpr ; //Conversion = Type "(" Expression [ "," ] ")" . @@ -786,7 +800,7 @@ eos : EOF | {lineTerminatorAhead()}? | {_input.LT(1).getText().equals("}") }? -// | ';' //TODO: V语言目前不支持用分号结尾 + // | ';' //TODO: V语言目前不支持用分号结尾 ; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -794,48 +808,47 @@ eos //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // LEXER - // Identifiers //identifier = letter { letter | unicode_digit } . IDENTIFIER - : LETTER ( LETTER | UNICODE_DIGIT )* + : LETTER (LETTER | UNICODE_DIGIT)* ; // Keywords KEYWORD - :'break' - |'const' - |'continue' - |'defer' - |'else' - |'enum' - |'fn' - |'for' - |'go' - |'goto' - |'if' - |'import' - |'in' - |'interface' - |'match' - |'module' - |'mut' - |'or' - |'pub' - |'return' - |'struct' - |'type' - - - + : 'break' + | 'const' + | 'continue' + | 'defer' + | 'else' + | 'enum' + | 'fn' + | 'for' + | 'go' + | 'goto' + | 'if' + | 'import' + | 'in' + | 'interface' + | 'match' + | 'module' + | 'mut' + | 'or' + | 'pub' + | 'return' + | 'struct' + | 'type' ; - // Operators //binary_op = "||" | "&&" | rel_op | add_op | mul_op . BINARY_OP - : '||' | '&&' | REL_OP | ADD_OP | MUL_OP + : '||' + | '&&' + | REL_OP + | ADD_OP + | MUL_OP ; //rel_op = "==" | "!=" | "<" | "<=" | ">" | ">=" . @@ -875,7 +888,6 @@ fragment UNARY_OP | '&' ; - // Integer literals //int_lit = decimal_lit | octal_lit | hex_lit . @@ -897,10 +909,9 @@ fragment OCTAL_LIT //hex_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } . fragment HEX_LIT - : '0' ( 'x' | 'X' ) HEX_DIGIT+ + : '0' ('x' | 'X') HEX_DIGIT+ ; - // Floating-point literals //float_lit = decimals "." [ decimals ] [ exponent ] | @@ -919,7 +930,7 @@ fragment DECIMALS //exponent = ( "e" | "E" ) [ "+" | "-" ] decimals . fragment EXPONENT - : ( 'e' | 'E' ) ( '+' | '-' )? DECIMALS + : ('e' | 'E') ('+' | '-')? DECIMALS ; // Imaginary literals @@ -928,12 +939,11 @@ fragment EXPONENT // : (DECIMALS | FLOAT_LIT) 'i' // ; - // Rune literals //rune_lit = "'" ( unicode_value | byte_value ) "'" . RUNE_LIT - : '\'' ( UNICODE_VALUE | BYTE_VALUE ) '\'' + : '\'' (UNICODE_VALUE | BYTE_VALUE) '\'' ; //unicode_value = unicode_char | little_u_value | big_u_value | escaped_char . @@ -946,7 +956,8 @@ fragment UNICODE_VALUE //byte_value = octal_byte_value | hex_byte_value . fragment BYTE_VALUE - : OCTAL_BYTE_VALUE | HEX_BYTE_VALUE + : OCTAL_BYTE_VALUE + | HEX_BYTE_VALUE ; //octal_byte_value = `\` octal_digit octal_digit octal_digit . @@ -972,10 +983,9 @@ BIG_U_VALUE //escaped_char = `\` ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | `\` | "'" | `"` ) . fragment ESCAPED_CHAR - : '\\' ( 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '\'' | '"' ) + : '\\' ('a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '\'' | '"') ; - // String literals //string_lit = raw_string_lit | interpreted_string_lit . @@ -985,10 +995,9 @@ STRING_LIT //interpreted_string_lit = `\'` { unicode_value | byte_value } `\'` . fragment INTERPRETED_STRING_LIT - : '\'' ( UNICODE_VALUE | BYTE_VALUE )*? '\'' + : '\'' (UNICODE_VALUE | BYTE_VALUE)*? '\'' ; - // // Source code representation // @@ -1020,313 +1029,313 @@ fragment NEWLINE ; //unicode_char = /* an arbitrary Unicode code point except newline */ . -fragment UNICODE_CHAR : ~[\u000A] ; +fragment UNICODE_CHAR + : ~[\u000A] + ; //unicode_digit = /* a Unicode code point classified as "Number, decimal digit" */ . fragment UNICODE_DIGIT - : [\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] - ; + : [\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] + ; //unicode_letter = /* a Unicode code point classified as "Letter" */ . fragment UNICODE_LETTER - : [\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] - | [\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-\u4DB5] - | [\u4E00-\u9FA5] - | [\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] - ; + : [\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] + | [\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-\u4DB5] + | [\u4E00-\u9FA5] + | [\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] + ; // // Whitespace and comments // -WS : [ \t]+ -> channel(HIDDEN) +WS + : [ \t]+ -> channel(HIDDEN) ; COMMENT - : '/*' .*? '*/' -> channel(HIDDEN) + : '/*' .*? '*/' -> channel(HIDDEN) ; TERMINATOR - : [\r\n]+ -> channel(HIDDEN) - ; - - -LINE_COMMENT - : '//' ~[\r\n]* -> skip + : [\r\n]+ -> channel(HIDDEN) ; - +LINE_COMMENT + : '//' ~[\r\n]* -> skip + ; \ No newline at end of file diff --git a/vb6/VisualBasic6Lexer.g4 b/vb6/VisualBasic6Lexer.g4 index 28d06c4713..bdcc5769a3 100644 --- a/vb6/VisualBasic6Lexer.g4 +++ b/vb6/VisualBasic6Lexer.g4 @@ -1,6 +1,12 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar VisualBasic6Lexer; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} // keywords @@ -240,8 +246,7 @@ OPTION_EXPLICIT: 'OPTION EXPLICIT'; OPTION_COMPARE: 'OPTION COMPARE'; -OPTION_PRIVATE_MODULE: - 'OPTION PRIVATE MODULE'; +OPTION_PRIVATE_MODULE: 'OPTION PRIVATE MODULE'; OR: 'OR'; @@ -371,8 +376,8 @@ COLON: ':'; COMMA: ','; -IDIV: '\\' ; -DIV: '/'; +IDIV : '\\'; +DIV : '/'; DOLLAR: '$'; @@ -430,16 +435,11 @@ DATELITERAL: HASH (~ [#\r\n])* HASH; COLORLITERAL: '&H' [0-9A-F]+ AMPERSAND?; -INTEGERLITERAL: [0-9]+ ('E' INTEGERLITERAL)* ( - HASH - | AMPERSAND - | EXCLAMATIONMARK - | AT - )?; +INTEGERLITERAL: [0-9]+ ('E' INTEGERLITERAL)* ( HASH | AMPERSAND | EXCLAMATIONMARK | AT)?; -DOUBLELITERAL: [0-9]* DOT [0-9]+ ( - 'E' (PLUS | MINUS)? [0-9]+ - )* (HASH | AMPERSAND | EXCLAMATIONMARK | AT)?; +DOUBLELITERAL: + [0-9]* DOT [0-9]+ ('E' (PLUS | MINUS)? [0-9]+)* (HASH | AMPERSAND | EXCLAMATIONMARK | AT)? +; FILENUMBER: HASH LETTERORDIGIT+; @@ -448,8 +448,7 @@ OCTALLITERAL: '&O' [0-7]+ AMPERSAND?; // misc FRX_OFFSET: COLON [0-9A-F]+; -GUID: - LBRACE [0-9A-F]+ MINUS [0-9A-F]+ MINUS [0-9A-F]+ MINUS [0-9A-F]+ MINUS [0-9A-F]+ RBRACE; +GUID: LBRACE [0-9A-F]+ MINUS [0-9A-F]+ MINUS [0-9A-F]+ MINUS [0-9A-F]+ MINUS [0-9A-F]+ RBRACE; // identifier @@ -461,18 +460,12 @@ LINE_CONTINUATION: ' ' '_' '\r'? '\n' -> skip; NEWLINE: WS? ('\r'? '\n' | COLON ' ') WS?; -COMMENT: - WS? ('\'' | COLON? REM ' ') ( - LINE_CONTINUATION - | ~ ('\n' | '\r') - )* -> skip; +COMMENT: WS? ('\'' | COLON? REM ' ') ( LINE_CONTINUATION | ~ ('\n' | '\r'))* -> skip; WS: [ \t]+; // letters -fragment LETTER: - [A-Z_ÄÖÜÁÉÍÓÚÂÊÎÔÛÀÈÌÒÙÃẼĨÕŨÇ]; +fragment LETTER: [A-Z_ÄÖÜÁÉÍÓÚÂÊÎÔÛÀÈÌÒÙÃẼĨÕŨÇ]; -fragment LETTERORDIGIT: - [A-Z0-9_ÄÖÜÁÉÍÓÚÂÊÎÔÛÀÈÌÒÙÃẼĨÕŨÇ]; \ No newline at end of file +fragment LETTERORDIGIT: [A-Z0-9_ÄÖÜÁÉÍÓÚÂÊÎÔÛÀÈÌÒÙÃẼĨÕŨÇ]; \ No newline at end of file diff --git a/vb6/VisualBasic6Parser.g4 b/vb6/VisualBasic6Parser.g4 index 772ccce452..4328350081 100755 --- a/vb6/VisualBasic6Parser.g4 +++ b/vb6/VisualBasic6Parser.g4 @@ -16,850 +16,1015 @@ * VB6 statements as well as several Visual Basic 6.0 code repositories. */ +// $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 VisualBasic6Parser; + options { - tokenVocab = VisualBasic6Lexer; + tokenVocab = VisualBasic6Lexer; } + // module ---------------------------------- -startRule: module EOF - ; +startRule + : module EOF + ; -module: - WS? NEWLINE* (moduleHeader NEWLINE+)? moduleReferences? NEWLINE* controlProperties? NEWLINE* - moduleConfig? NEWLINE* moduleAttributes? NEWLINE* moduleOptions? NEWLINE* moduleBody? - NEWLINE* WS? - ; +module + : WS? NEWLINE* (moduleHeader NEWLINE+)? moduleReferences? NEWLINE* controlProperties? NEWLINE* moduleConfig? NEWLINE* moduleAttributes? NEWLINE* + moduleOptions? NEWLINE* moduleBody? NEWLINE* WS? + ; -moduleReferences: moduleReference+; +moduleReferences + : moduleReference+ + ; -moduleReference: - OBJECT WS? EQ WS? moduleReferenceValue ( - SEMICOLON WS? moduleReferenceComponent - )? NEWLINE* - ; +moduleReference + : OBJECT WS? EQ WS? moduleReferenceValue (SEMICOLON WS? moduleReferenceComponent)? NEWLINE* + ; -moduleReferenceValue: STRINGLITERAL; +moduleReferenceValue + : STRINGLITERAL + ; -moduleReferenceComponent: STRINGLITERAL; +moduleReferenceComponent + : STRINGLITERAL + ; -moduleHeader: VERSION WS doubleLiteral (WS CLASS)?; +moduleHeader + : VERSION WS doubleLiteral (WS CLASS)? + ; -moduleConfig: BEGIN NEWLINE+ moduleConfigElement+ END NEWLINE+; +moduleConfig + : BEGIN NEWLINE+ moduleConfigElement+ END NEWLINE+ + ; -moduleConfigElement: - ambiguousIdentifier WS? EQ WS? literal NEWLINE; +moduleConfigElement + : ambiguousIdentifier WS? EQ WS? literal NEWLINE + ; -moduleAttributes: (attributeStmt NEWLINE+)+; +moduleAttributes + : (attributeStmt NEWLINE+)+ + ; -moduleOptions: (moduleOption NEWLINE+)+; +moduleOptions + : (moduleOption NEWLINE+)+ + ; -moduleOption: - OPTION_BASE WS integerLiteral # optionBaseStmt - | OPTION_COMPARE WS (BINARY | TEXT) # optionCompareStmt - | OPTION_EXPLICIT # optionExplicitStmt - | OPTION_PRIVATE_MODULE # optionPrivateModuleStmt +moduleOption + : OPTION_BASE WS integerLiteral # optionBaseStmt + | OPTION_COMPARE WS (BINARY | TEXT) # optionCompareStmt + | OPTION_EXPLICIT # optionExplicitStmt + | OPTION_PRIVATE_MODULE # optionPrivateModuleStmt ; -moduleBody: moduleBodyElement (NEWLINE+ moduleBodyElement)*; +moduleBody + : moduleBodyElement (NEWLINE+ moduleBodyElement)* + ; -moduleBodyElement: - moduleBlock - | moduleOption - | declareStmt - | enumerationStmt - | eventStmt - | functionStmt - | macroIfThenElseStmt - | propertyGetStmt - | propertySetStmt - | propertyLetStmt - | subStmt - | typeStmt +moduleBodyElement + : moduleBlock + | moduleOption + | declareStmt + | enumerationStmt + | eventStmt + | functionStmt + | macroIfThenElseStmt + | propertyGetStmt + | propertySetStmt + | propertyLetStmt + | subStmt + | typeStmt ; // controls ---------------------------------- -controlProperties: - WS? BEGIN WS cp_ControlType WS cp_ControlIdentifier WS? NEWLINE+ cp_Properties+ END NEWLINE*; +controlProperties + : WS? BEGIN WS cp_ControlType WS cp_ControlIdentifier WS? NEWLINE+ cp_Properties+ END NEWLINE* + ; -cp_Properties: - cp_SingleProperty - | cp_NestedProperty - | controlProperties +cp_Properties + : cp_SingleProperty + | cp_NestedProperty + | controlProperties ; -cp_SingleProperty: - WS? implicitCallStmt_InStmt WS? EQ WS? '$'? cp_PropertyValue FRX_OFFSET? NEWLINE+; +cp_SingleProperty + : WS? implicitCallStmt_InStmt WS? EQ WS? '$'? cp_PropertyValue FRX_OFFSET? NEWLINE+ + ; -cp_PropertyName: (OBJECT DOT)? ambiguousIdentifier ( - LPAREN literal RPAREN - )? (DOT ambiguousIdentifier (LPAREN literal RPAREN)?)* +cp_PropertyName + : (OBJECT DOT)? ambiguousIdentifier (LPAREN literal RPAREN)? ( + DOT ambiguousIdentifier (LPAREN literal RPAREN)? + )* ; -cp_PropertyValue: - DOLLAR? ( - literal - | (LBRACE ambiguousIdentifier RBRACE) - | POW ambiguousIdentifier - ); +cp_PropertyValue + : DOLLAR? (literal | (LBRACE ambiguousIdentifier RBRACE) | POW ambiguousIdentifier) + ; -cp_NestedProperty: - WS? BEGINPROPERTY WS ambiguousIdentifier ( - LPAREN integerLiteral RPAREN - )? (WS GUID)? NEWLINE+ (cp_Properties+)? ENDPROPERTY NEWLINE+; +cp_NestedProperty + : WS? BEGINPROPERTY WS ambiguousIdentifier (LPAREN integerLiteral RPAREN)? (WS GUID)? NEWLINE+ ( + cp_Properties+ + )? ENDPROPERTY NEWLINE+ + ; -cp_ControlType: complexType; +cp_ControlType + : complexType + ; -cp_ControlIdentifier: ambiguousIdentifier; +cp_ControlIdentifier + : ambiguousIdentifier + ; // block ---------------------------------- -moduleBlock: block; - -attributeStmt: - ATTRIBUTE WS implicitCallStmt_InStmt WS? EQ WS? literal ( - WS? COMMA WS? literal - )*; - -block: blockStmt (NEWLINE+ WS? blockStmt)*; - -blockStmt: - appActivateStmt - | attributeStmt - | beepStmt - | chDirStmt - | chDriveStmt - | closeStmt - | constStmt - | dateStmt - | deleteSettingStmt - | deftypeStmt - | doLoopStmt - | endStmt - | eraseStmt - | errorStmt - | exitStmt - | explicitCallStmt - | filecopyStmt - | forEachStmt - | forNextStmt - | getStmt - | goSubStmt - | goToStmt - | ifThenElseStmt - | implementsStmt - | inputStmt - | killStmt - | letStmt - | lineInputStmt - | lineLabel - | loadStmt - | lockStmt - | lsetStmt - | macroIfThenElseStmt - | midStmt - | mkdirStmt - | nameStmt - | onErrorStmt - | onGoToStmt - | onGoSubStmt - | openStmt - | printStmt - | putStmt - | raiseEventStmt - | randomizeStmt - | redimStmt - | resetStmt - | resumeStmt - | returnStmt - | rmdirStmt - | rsetStmt - | savepictureStmt - | saveSettingStmt - | seekStmt - | selectCaseStmt - | sendkeysStmt - | setattrStmt - | setStmt - | stopStmt - | timeStmt - | unloadStmt - | unlockStmt - | variableStmt - | whileWendStmt - | widthStmt - | withStmt - | writeStmt - | implicitCallStmt_InBlock +moduleBlock + : block + ; + +attributeStmt + : ATTRIBUTE WS implicitCallStmt_InStmt WS? EQ WS? literal (WS? COMMA WS? literal)* + ; + +block + : blockStmt (NEWLINE+ WS? blockStmt)* + ; + +blockStmt + : appActivateStmt + | attributeStmt + | beepStmt + | chDirStmt + | chDriveStmt + | closeStmt + | constStmt + | dateStmt + | deleteSettingStmt + | deftypeStmt + | doLoopStmt + | endStmt + | eraseStmt + | errorStmt + | exitStmt + | explicitCallStmt + | filecopyStmt + | forEachStmt + | forNextStmt + | getStmt + | goSubStmt + | goToStmt + | ifThenElseStmt + | implementsStmt + | inputStmt + | killStmt + | letStmt + | lineInputStmt + | lineLabel + | loadStmt + | lockStmt + | lsetStmt + | macroIfThenElseStmt + | midStmt + | mkdirStmt + | nameStmt + | onErrorStmt + | onGoToStmt + | onGoSubStmt + | openStmt + | printStmt + | putStmt + | raiseEventStmt + | randomizeStmt + | redimStmt + | resetStmt + | resumeStmt + | returnStmt + | rmdirStmt + | rsetStmt + | savepictureStmt + | saveSettingStmt + | seekStmt + | selectCaseStmt + | sendkeysStmt + | setattrStmt + | setStmt + | stopStmt + | timeStmt + | unloadStmt + | unlockStmt + | variableStmt + | whileWendStmt + | widthStmt + | withStmt + | writeStmt + | implicitCallStmt_InBlock ; // statements ---------------------------------- -appActivateStmt: - APPACTIVATE WS valueStmt (WS? COMMA WS? valueStmt)?; +appActivateStmt + : APPACTIVATE WS valueStmt (WS? COMMA WS? valueStmt)? + ; -beepStmt: BEEP; +beepStmt + : BEEP + ; -chDirStmt: CHDIR WS valueStmt; +chDirStmt + : CHDIR WS valueStmt + ; -chDriveStmt: CHDRIVE WS valueStmt; +chDriveStmt + : CHDRIVE WS valueStmt + ; -closeStmt: CLOSE (WS valueStmt (WS? COMMA WS? valueStmt)*)?; +closeStmt + : CLOSE (WS valueStmt (WS? COMMA WS? valueStmt)*)? + ; -constStmt: (publicPrivateGlobalVisibility WS)? CONST WS constSubStmt ( - WS? COMMA WS? constSubStmt - )*; +constStmt + : (publicPrivateGlobalVisibility WS)? CONST WS constSubStmt (WS? COMMA WS? constSubStmt)* + ; -constSubStmt: - ambiguousIdentifier typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt; +constSubStmt + : ambiguousIdentifier typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt + ; -dateStmt: DATE WS? EQ WS? valueStmt; +dateStmt + : DATE WS? EQ WS? valueStmt + ; -declareStmt: (visibility WS)? DECLARE WS ( - FUNCTION typeHint? - | SUB - ) WS ambiguousIdentifier typeHint? WS LIB WS STRINGLITERAL ( - WS ALIAS WS STRINGLITERAL - )? (WS? argList)? (WS asTypeClause)?; +declareStmt + : (visibility WS)? DECLARE WS (FUNCTION typeHint? | SUB) WS ambiguousIdentifier typeHint? WS LIB WS STRINGLITERAL ( + WS ALIAS WS STRINGLITERAL + )? (WS? argList)? (WS asTypeClause)? + ; -deftypeStmt: ( - DEFBOOL - | DEFBYTE - | DEFINT - | DEFLNG - | DEFCUR - | DEFSNG - | DEFDBL - | DEFDEC - | DEFDATE - | DEFSTR - | DEFOBJ - | DEFVAR - ) WS letterrange (WS? COMMA WS? letterrange)* +deftypeStmt + : ( + DEFBOOL + | DEFBYTE + | DEFINT + | DEFLNG + | DEFCUR + | DEFSNG + | DEFDBL + | DEFDEC + | DEFDATE + | DEFSTR + | DEFOBJ + | DEFVAR + ) WS letterrange (WS? COMMA WS? letterrange)* ; -deleteSettingStmt: - DELETESETTING WS valueStmt WS? COMMA WS? valueStmt ( - WS? COMMA WS? valueStmt - )?; +deleteSettingStmt + : DELETESETTING WS valueStmt WS? COMMA WS? valueStmt (WS? COMMA WS? valueStmt)? + ; -doLoopStmt: - DO NEWLINE+ (block NEWLINE+)? LOOP - | DO WS (WHILE | UNTIL) WS valueStmt NEWLINE+ ( - block NEWLINE+ - )? LOOP - | DO NEWLINE+ (block NEWLINE+) LOOP WS (WHILE | UNTIL) WS valueStmt +doLoopStmt + : DO NEWLINE+ (block NEWLINE+)? LOOP + | DO WS (WHILE | UNTIL) WS valueStmt NEWLINE+ ( block NEWLINE+)? LOOP + | DO NEWLINE+ (block NEWLINE+) LOOP WS (WHILE | UNTIL) WS valueStmt ; -endStmt: END; +endStmt + : END + ; -enumerationStmt: (publicPrivateVisibility WS)? ENUM WS ambiguousIdentifier NEWLINE+ ( - enumerationStmt_Constant - )* END_ENUM; +enumerationStmt + : (publicPrivateVisibility WS)? ENUM WS ambiguousIdentifier NEWLINE+ (enumerationStmt_Constant)* END_ENUM + ; -enumerationStmt_Constant: - ambiguousIdentifier (WS? EQ WS? valueStmt)? NEWLINE+; +enumerationStmt_Constant + : ambiguousIdentifier (WS? EQ WS? valueStmt)? NEWLINE+ + ; -eraseStmt: ERASE WS valueStmt (WS? COMMA WS? valueStmt)*; +eraseStmt + : ERASE WS valueStmt (WS? COMMA WS? valueStmt)* + ; -errorStmt: ERROR WS valueStmt; +errorStmt + : ERROR WS valueStmt + ; -eventStmt: (visibility WS)? EVENT WS ambiguousIdentifier WS? argList; +eventStmt + : (visibility WS)? EVENT WS ambiguousIdentifier WS? argList + ; -exitStmt: - EXIT_DO - | EXIT_FOR - | EXIT_FUNCTION - | EXIT_PROPERTY - | EXIT_SUB +exitStmt + : EXIT_DO + | EXIT_FOR + | EXIT_FUNCTION + | EXIT_PROPERTY + | EXIT_SUB ; -filecopyStmt: FILECOPY WS valueStmt WS? COMMA WS? valueStmt; +filecopyStmt + : FILECOPY WS valueStmt WS? COMMA WS? valueStmt + ; -forEachStmt: - FOR WS EACH WS ambiguousIdentifier typeHint? WS IN WS valueStmt NEWLINE+ ( - block NEWLINE+ - )? NEXT (WS ambiguousIdentifier)?; +forEachStmt + : FOR WS EACH WS ambiguousIdentifier typeHint? WS IN WS valueStmt NEWLINE+ (block NEWLINE+)? NEXT ( + WS ambiguousIdentifier + )? + ; -forNextStmt: - FOR WS iCS_S_VariableOrProcedureCall typeHint? ( - WS asTypeClause - )? WS? EQ WS? valueStmt WS TO WS valueStmt ( - WS STEP WS valueStmt - )? NEWLINE+ (block NEWLINE+)? NEXT ( - WS ambiguousIdentifier typeHint? - )?; +forNextStmt + : FOR WS iCS_S_VariableOrProcedureCall typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt WS TO WS valueStmt ( + WS STEP WS valueStmt + )? NEWLINE+ (block NEWLINE+)? NEXT (WS ambiguousIdentifier typeHint?)? + ; -functionStmt: (visibility WS)? (STATIC WS)? FUNCTION WS ambiguousIdentifier ( - WS? argList - )? (WS asTypeClause)? NEWLINE+ (block NEWLINE+)? END_FUNCTION; +functionStmt + : (visibility WS)? (STATIC WS)? FUNCTION WS ambiguousIdentifier (WS? argList)? ( + WS asTypeClause + )? NEWLINE+ (block NEWLINE+)? END_FUNCTION + ; -getStmt: - GET WS valueStmt WS? COMMA WS? valueStmt? WS? COMMA WS? valueStmt; +getStmt + : GET WS valueStmt WS? COMMA WS? valueStmt? WS? COMMA WS? valueStmt + ; -goSubStmt: GOSUB WS valueStmt; +goSubStmt + : GOSUB WS valueStmt + ; -goToStmt: GOTO WS valueStmt; +goToStmt + : GOTO WS valueStmt + ; -ifThenElseStmt: - IF WS ifConditionStmt WS THEN WS blockStmt ( - WS ELSE WS blockStmt - )? # inlineIfThenElse - | ifBlockStmt ifElseIfBlockStmt* ifElseBlockStmt? END_IF # blockIfThenElse +ifThenElseStmt + : IF WS ifConditionStmt WS THEN WS blockStmt (WS ELSE WS blockStmt)? # inlineIfThenElse + | ifBlockStmt ifElseIfBlockStmt* ifElseBlockStmt? END_IF # blockIfThenElse ; -ifBlockStmt: - IF WS ifConditionStmt WS THEN NEWLINE+ (block NEWLINE+)?; +ifBlockStmt + : IF WS ifConditionStmt WS THEN NEWLINE+ (block NEWLINE+)? + ; -ifConditionStmt: valueStmt; +ifConditionStmt + : valueStmt + ; -ifElseIfBlockStmt: - ELSEIF WS ifConditionStmt WS THEN NEWLINE+ (block NEWLINE+)?; +ifElseIfBlockStmt + : ELSEIF WS ifConditionStmt WS THEN NEWLINE+ (block NEWLINE+)? + ; -ifElseBlockStmt: ELSE NEWLINE+ (block NEWLINE+)?; +ifElseBlockStmt + : ELSE NEWLINE+ (block NEWLINE+)? + ; -implementsStmt: IMPLEMENTS WS ambiguousIdentifier; +implementsStmt + : IMPLEMENTS WS ambiguousIdentifier + ; -inputStmt: INPUT WS valueStmt (WS? COMMA WS? valueStmt)+; +inputStmt + : INPUT WS valueStmt (WS? COMMA WS? valueStmt)+ + ; -killStmt: KILL WS valueStmt; +killStmt + : KILL WS valueStmt + ; -letStmt: (LET WS)? implicitCallStmt_InStmt WS? ( - EQ - | PLUS_EQ - | MINUS_EQ - ) WS? valueStmt; +letStmt + : (LET WS)? implicitCallStmt_InStmt WS? (EQ | PLUS_EQ | MINUS_EQ) WS? valueStmt + ; -lineInputStmt: LINE_INPUT WS valueStmt WS? COMMA WS? valueStmt; +lineInputStmt + : LINE_INPUT WS valueStmt WS? COMMA WS? valueStmt + ; -loadStmt: LOAD WS valueStmt; +loadStmt + : LOAD WS valueStmt + ; -lockStmt: - LOCK WS valueStmt ( - WS? COMMA WS? valueStmt (WS TO WS valueStmt)? - )?; +lockStmt + : LOCK WS valueStmt (WS? COMMA WS? valueStmt (WS TO WS valueStmt)?)? + ; -lsetStmt: LSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt; +lsetStmt + : LSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt + ; -macroIfThenElseStmt: - macroIfBlockStmt macroElseIfBlockStmt* macroElseBlockStmt? MACRO_END_IF; +macroIfThenElseStmt + : macroIfBlockStmt macroElseIfBlockStmt* macroElseBlockStmt? MACRO_END_IF + ; -macroIfBlockStmt: - MACRO_IF WS ifConditionStmt WS THEN NEWLINE+ ( - moduleBody NEWLINE+ - )?; +macroIfBlockStmt + : MACRO_IF WS ifConditionStmt WS THEN NEWLINE+ (moduleBody NEWLINE+)? + ; -macroElseIfBlockStmt: - MACRO_ELSEIF WS ifConditionStmt WS THEN NEWLINE+ ( - moduleBody NEWLINE+ - )?; +macroElseIfBlockStmt + : MACRO_ELSEIF WS ifConditionStmt WS THEN NEWLINE+ (moduleBody NEWLINE+)? + ; -macroElseBlockStmt: MACRO_ELSE NEWLINE+ (moduleBody NEWLINE+)?; +macroElseBlockStmt + : MACRO_ELSE NEWLINE+ (moduleBody NEWLINE+)? + ; -midStmt: MID WS? LPAREN WS? argsCall WS? RPAREN; +midStmt + : MID WS? LPAREN WS? argsCall WS? RPAREN + ; -mkdirStmt: MKDIR WS valueStmt; +mkdirStmt + : MKDIR WS valueStmt + ; -nameStmt: NAME WS valueStmt WS AS WS valueStmt; +nameStmt + : NAME WS valueStmt WS AS WS valueStmt + ; -onErrorStmt: (ON_ERROR | ON_LOCAL_ERROR) WS ( - GOTO WS valueStmt COLON? - | RESUME WS NEXT - ); +onErrorStmt + : (ON_ERROR | ON_LOCAL_ERROR) WS (GOTO WS valueStmt COLON? | RESUME WS NEXT) + ; -onGoToStmt: - ON WS valueStmt WS GOTO WS valueStmt ( - WS? COMMA WS? valueStmt - )*; +onGoToStmt + : ON WS valueStmt WS GOTO WS valueStmt (WS? COMMA WS? valueStmt)* + ; -onGoSubStmt: - ON WS valueStmt WS GOSUB WS valueStmt ( - WS? COMMA WS? valueStmt - )*; +onGoSubStmt + : ON WS valueStmt WS GOSUB WS valueStmt (WS? COMMA WS? valueStmt)* + ; -openStmt: - OPEN WS valueStmt WS FOR WS ( - APPEND - | BINARY - | INPUT - | OUTPUT - | RANDOM - ) (WS ACCESS WS (READ | WRITE | READ_WRITE))? ( - WS (SHARED | LOCK_READ | LOCK_WRITE | LOCK_READ_WRITE) - )? WS AS WS valueStmt (WS LEN WS? EQ WS? valueStmt)? +openStmt + : OPEN WS valueStmt WS FOR WS (APPEND | BINARY | INPUT | OUTPUT | RANDOM) ( + WS ACCESS WS (READ | WRITE | READ_WRITE) + )? (WS (SHARED | LOCK_READ | LOCK_WRITE | LOCK_READ_WRITE))? WS AS WS valueStmt ( + WS LEN WS? EQ WS? valueStmt + )? ; -outputList: - outputList_Expression ( - WS? (SEMICOLON | COMMA) WS? outputList_Expression? - )* - | outputList_Expression? ( - WS? (SEMICOLON | COMMA) WS? outputList_Expression? - )+; +outputList + : outputList_Expression (WS? (SEMICOLON | COMMA) WS? outputList_Expression?)* + | outputList_Expression? (WS? (SEMICOLON | COMMA) WS? outputList_Expression?)+ + ; -outputList_Expression: (SPC | TAB) ( - WS? LPAREN WS? argsCall WS? RPAREN - )? - | valueStmt +outputList_Expression + : (SPC | TAB) (WS? LPAREN WS? argsCall WS? RPAREN)? + | valueStmt ; -printStmt: PRINT WS valueStmt WS? COMMA (WS? outputList)?; +printStmt + : PRINT WS valueStmt WS? COMMA (WS? outputList)? + ; -propertyGetStmt: (visibility WS)? (STATIC WS)? PROPERTY_GET WS ambiguousIdentifier typeHint? ( - WS? argList - )? (WS asTypeClause)? NEWLINE+ (block NEWLINE+)? END_PROPERTY; +propertyGetStmt + : (visibility WS)? (STATIC WS)? PROPERTY_GET WS ambiguousIdentifier typeHint? (WS? argList)? ( + WS asTypeClause + )? NEWLINE+ (block NEWLINE+)? END_PROPERTY + ; -propertySetStmt: (visibility WS)? (STATIC WS)? PROPERTY_SET WS ambiguousIdentifier ( - WS? argList - )? NEWLINE+ (block NEWLINE+)? END_PROPERTY; +propertySetStmt + : (visibility WS)? (STATIC WS)? PROPERTY_SET WS ambiguousIdentifier (WS? argList)? NEWLINE+ ( + block NEWLINE+ + )? END_PROPERTY + ; -propertyLetStmt: (visibility WS)? (STATIC WS)? PROPERTY_LET WS ambiguousIdentifier ( - WS? argList - )? NEWLINE+ (block NEWLINE+)? END_PROPERTY; +propertyLetStmt + : (visibility WS)? (STATIC WS)? PROPERTY_LET WS ambiguousIdentifier (WS? argList)? NEWLINE+ ( + block NEWLINE+ + )? END_PROPERTY + ; -putStmt: - PUT WS valueStmt WS? COMMA WS? valueStmt? WS? COMMA WS? valueStmt; +putStmt + : PUT WS valueStmt WS? COMMA WS? valueStmt? WS? COMMA WS? valueStmt + ; -raiseEventStmt: - RAISEEVENT WS ambiguousIdentifier ( - WS? LPAREN WS? (argsCall WS?)? RPAREN - )?; +raiseEventStmt + : RAISEEVENT WS ambiguousIdentifier (WS? LPAREN WS? (argsCall WS?)? RPAREN)? + ; -randomizeStmt: RANDOMIZE (WS valueStmt)?; +randomizeStmt + : RANDOMIZE (WS valueStmt)? + ; -redimStmt: - REDIM WS (PRESERVE WS)? redimSubStmt ( - WS? COMMA WS? redimSubStmt - )*; +redimStmt + : REDIM WS (PRESERVE WS)? redimSubStmt (WS? COMMA WS? redimSubStmt)* + ; -redimSubStmt: - implicitCallStmt_InStmt WS? LPAREN WS? subscripts WS? RPAREN ( - WS asTypeClause - )?; +redimSubStmt + : implicitCallStmt_InStmt WS? LPAREN WS? subscripts WS? RPAREN (WS asTypeClause)? + ; -resetStmt: RESET; +resetStmt + : RESET + ; -resumeStmt: RESUME (WS (NEXT | ambiguousIdentifier))?; +resumeStmt + : RESUME (WS (NEXT | ambiguousIdentifier))? + ; -returnStmt: RETURN; +returnStmt + : RETURN + ; -rmdirStmt: RMDIR WS valueStmt; +rmdirStmt + : RMDIR WS valueStmt + ; -rsetStmt: RSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt; +rsetStmt + : RSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt + ; -savepictureStmt: - SAVEPICTURE WS valueStmt WS? COMMA WS? valueStmt; +savepictureStmt + : SAVEPICTURE WS valueStmt WS? COMMA WS? valueStmt + ; -saveSettingStmt: - SAVESETTING WS valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt - ; +saveSettingStmt + : SAVESETTING WS valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt + ; -seekStmt: SEEK WS valueStmt WS? COMMA WS? valueStmt; +seekStmt + : SEEK WS valueStmt WS? COMMA WS? valueStmt + ; -selectCaseStmt: - SELECT WS CASE WS valueStmt NEWLINE+ sC_Case* WS? END_SELECT; +selectCaseStmt + : SELECT WS CASE WS valueStmt NEWLINE+ sC_Case* WS? END_SELECT + ; -sC_Case: - CASE WS sC_Cond WS? (COLON? NEWLINE* | NEWLINE+) ( - block NEWLINE+ - )?; +sC_Case + : CASE WS sC_Cond WS? (COLON? NEWLINE* | NEWLINE+) (block NEWLINE+)? + ; // ELSE first, so that it is not interpreted as a variable call -sC_Cond: - ELSE # caseCondElse - | sC_CondExpr (WS? COMMA WS? sC_CondExpr)* # caseCondExpr +sC_Cond + : ELSE # caseCondElse + | sC_CondExpr (WS? COMMA WS? sC_CondExpr)* # caseCondExpr ; -sC_CondExpr: - IS WS? comparisonOperator WS? valueStmt # caseCondExprIs - | valueStmt # caseCondExprValue - | valueStmt WS TO WS valueStmt # caseCondExprTo +sC_CondExpr + : IS WS? comparisonOperator WS? valueStmt # caseCondExprIs + | valueStmt # caseCondExprValue + | valueStmt WS TO WS valueStmt # caseCondExprTo ; -sendkeysStmt: SENDKEYS WS valueStmt (WS? COMMA WS? valueStmt)?; +sendkeysStmt + : SENDKEYS WS valueStmt (WS? COMMA WS? valueStmt)? + ; -setattrStmt: SETATTR WS valueStmt WS? COMMA WS? valueStmt; +setattrStmt + : SETATTR WS valueStmt WS? COMMA WS? valueStmt + ; -setStmt: SET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt; +setStmt + : SET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt + ; -stopStmt: STOP; +stopStmt + : STOP + ; -subStmt: (visibility WS)? (STATIC WS)? SUB WS ambiguousIdentifier ( - WS? argList - )? NEWLINE+ (block NEWLINE+)? END_SUB; +subStmt + : (visibility WS)? (STATIC WS)? SUB WS ambiguousIdentifier (WS? argList)? NEWLINE+ ( + block NEWLINE+ + )? END_SUB + ; -timeStmt: TIME WS? EQ WS? valueStmt; +timeStmt + : TIME WS? EQ WS? valueStmt + ; -typeStmt: (visibility WS)? TYPE WS ambiguousIdentifier NEWLINE+ ( - typeStmt_Element - )* END_TYPE; +typeStmt + : (visibility WS)? TYPE WS ambiguousIdentifier NEWLINE+ (typeStmt_Element)* END_TYPE + ; -typeStmt_Element: - ambiguousIdentifier (WS? LPAREN (WS? subscripts)? WS? RPAREN)? ( - WS asTypeClause - )? NEWLINE+; +typeStmt_Element + : ambiguousIdentifier (WS? LPAREN (WS? subscripts)? WS? RPAREN)? (WS asTypeClause)? NEWLINE+ + ; -typeOfStmt: TYPEOF WS valueStmt (WS IS WS type_)?; +typeOfStmt + : TYPEOF WS valueStmt (WS IS WS type_)? + ; -unloadStmt: UNLOAD WS valueStmt; +unloadStmt + : UNLOAD WS valueStmt + ; -unlockStmt: - UNLOCK WS valueStmt ( - WS? COMMA WS? valueStmt (WS TO WS valueStmt)? - )?; +unlockStmt + : UNLOCK WS valueStmt (WS? COMMA WS? valueStmt (WS TO WS valueStmt)?)? + ; // operator precedence is represented by rule order valueStmt - : literal # vsLiteral - | LPAREN WS? valueStmt (WS? COMMA WS? valueStmt)* WS? RPAREN # vsStruct - | NEW WS valueStmt # vsNew - | typeOfStmt # vsTypeOf - | ADDRESSOF WS valueStmt # vsAddressOf - | implicitCallStmt_InStmt WS? ASSIGN WS? valueStmt # vsAssign - | valueStmt WS? POW WS? valueStmt # vsPow - | (PLUS | MINUS) WS? valueStmt # vsPlusMinus - | valueStmt WS? (MULT | DIV) WS? valueStmt # vsMultDiv - | valueStmt WS? (IDIV) WS? valueStmt # vsIDiv - | valueStmt WS? MOD WS? valueStmt # vsMod - | valueStmt WS? (PLUS | MINUS) WS? valueStmt # vsAddSub - | valueStmt WS? AMPERSAND WS? valueStmt # vsAmp + : literal # vsLiteral + | LPAREN WS? valueStmt (WS? COMMA WS? valueStmt)* WS? RPAREN # vsStruct + | NEW WS valueStmt # vsNew + | typeOfStmt # vsTypeOf + | ADDRESSOF WS valueStmt # vsAddressOf + | implicitCallStmt_InStmt WS? ASSIGN WS? valueStmt # vsAssign + | valueStmt WS? POW WS? valueStmt # vsPow + | (PLUS | MINUS) WS? valueStmt # vsPlusMinus + | valueStmt WS? (MULT | DIV) WS? valueStmt # vsMultDiv + | valueStmt WS? (IDIV) WS? valueStmt # vsIDiv + | valueStmt WS? MOD WS? valueStmt # vsMod + | valueStmt WS? (PLUS | MINUS) WS? valueStmt # vsAddSub + | valueStmt WS? AMPERSAND WS? valueStmt # vsAmp | valueStmt WS? (EQ | NEQ | LT | GT | LEQ | GEQ | LIKE | IS) WS? valueStmt # vsComp - | NOT (WS valueStmt | LPAREN WS? valueStmt WS? RPAREN) # vsNot - | valueStmt WS? AND WS? valueStmt # vsAnd - | valueStmt WS? OR WS? valueStmt # vsOr - | valueStmt WS? XOR WS? valueStmt # vsXor - | valueStmt WS? EQV WS? valueStmt # vsEqv - | valueStmt WS? IMP WS? valueStmt # vsImp - | implicitCallStmt_InStmt # vsICS - | midStmt # vsMid + | NOT (WS valueStmt | LPAREN WS? valueStmt WS? RPAREN) # vsNot + | valueStmt WS? AND WS? valueStmt # vsAnd + | valueStmt WS? OR WS? valueStmt # vsOr + | valueStmt WS? XOR WS? valueStmt # vsXor + | valueStmt WS? EQV WS? valueStmt # vsEqv + | valueStmt WS? IMP WS? valueStmt # vsImp + | implicitCallStmt_InStmt # vsICS + | midStmt # vsMid ; -variableStmt: (DIM | STATIC | visibility) WS (WITHEVENTS WS)? variableListStmt; -variableListStmt: - variableSubStmt (WS? COMMA WS? variableSubStmt)*; +variableStmt + : (DIM | STATIC | visibility) WS (WITHEVENTS WS)? variableListStmt + ; -variableSubStmt: - ambiguousIdentifier typeHint? ( - WS? LPAREN WS? (subscripts WS?)? RPAREN WS? - )? (WS asTypeClause)?; +variableListStmt + : variableSubStmt (WS? COMMA WS? variableSubStmt)* + ; -whileWendStmt: WHILE WS valueStmt NEWLINE+ block* NEWLINE* WEND; +variableSubStmt + : ambiguousIdentifier typeHint? (WS? LPAREN WS? (subscripts WS?)? RPAREN WS?)? ( + WS asTypeClause + )? + ; -widthStmt: WIDTH WS valueStmt WS? COMMA WS? valueStmt; +whileWendStmt + : WHILE WS valueStmt NEWLINE+ block* NEWLINE* WEND + ; -withStmt: - WITH WS (NEW WS)? implicitCallStmt_InStmt NEWLINE+ ( - block NEWLINE+ - )? END_WITH; +widthStmt + : WIDTH WS valueStmt WS? COMMA WS? valueStmt + ; -writeStmt: WRITE WS valueStmt WS? COMMA (WS? outputList)?; +withStmt + : WITH WS (NEW WS)? implicitCallStmt_InStmt NEWLINE+ (block NEWLINE+)? END_WITH + ; + +writeStmt + : WRITE WS valueStmt WS? COMMA (WS? outputList)? + ; // complex call statements ---------------------------------- -explicitCallStmt: eCS_ProcedureCall | eCS_MemberProcedureCall; +explicitCallStmt + : eCS_ProcedureCall + | eCS_MemberProcedureCall + ; // parantheses are required in case of args -> empty parantheses are removed -eCS_ProcedureCall: - CALL WS ambiguousIdentifier typeHint? ( - WS? LPAREN WS? argsCall WS? RPAREN - )?; +eCS_ProcedureCall + : CALL WS ambiguousIdentifier typeHint? (WS? LPAREN WS? argsCall WS? RPAREN)? + ; // parantheses are required in case of args -> empty parantheses are removed -eCS_MemberProcedureCall: - CALL WS implicitCallStmt_InStmt? DOT WS? ambiguousIdentifier typeHint? ( - WS? LPAREN WS? argsCall WS? RPAREN - )?; +eCS_MemberProcedureCall + : CALL WS implicitCallStmt_InStmt? DOT WS? ambiguousIdentifier typeHint? ( + WS? LPAREN WS? argsCall WS? RPAREN + )? + ; -implicitCallStmt_InBlock: - iCS_B_ProcedureCall - | iCS_B_MemberProcedureCall +implicitCallStmt_InBlock + : iCS_B_ProcedureCall + | iCS_B_MemberProcedureCall ; // parantheses are forbidden in case of args variables cannot be called in blocks certainIdentifier // instead of ambiguousIdentifier for preventing ambiguity with statement keywords -iCS_B_ProcedureCall: certainIdentifier (WS argsCall)?; +iCS_B_ProcedureCall + : certainIdentifier (WS argsCall)? + ; -iCS_B_MemberProcedureCall: - implicitCallStmt_InStmt? DOT ambiguousIdentifier typeHint? ( - WS argsCall - )? dictionaryCallStmt?; +iCS_B_MemberProcedureCall + : implicitCallStmt_InStmt? DOT ambiguousIdentifier typeHint? (WS argsCall)? dictionaryCallStmt? + ; // iCS_S_MembersCall first, so that member calls are not resolved as separate iCS_S_VariableOrProcedureCalls -implicitCallStmt_InStmt: - iCS_S_MembersCall - | iCS_S_VariableOrProcedureCall - | iCS_S_ProcedureOrArrayCall - | iCS_S_DictionaryCall; +implicitCallStmt_InStmt + : iCS_S_MembersCall + | iCS_S_VariableOrProcedureCall + | iCS_S_ProcedureOrArrayCall + | iCS_S_DictionaryCall + ; -iCS_S_VariableOrProcedureCall: - ambiguousIdentifier typeHint? dictionaryCallStmt?; +iCS_S_VariableOrProcedureCall + : ambiguousIdentifier typeHint? dictionaryCallStmt? + ; -iCS_S_ProcedureOrArrayCall: ( - ambiguousIdentifier - | baseType - | iCS_S_NestedProcedureCall - ) typeHint? WS? (LPAREN WS? (argsCall WS?)? RPAREN)+ dictionaryCallStmt?; +iCS_S_ProcedureOrArrayCall + : (ambiguousIdentifier | baseType | iCS_S_NestedProcedureCall) typeHint? WS? ( + LPAREN WS? (argsCall WS?)? RPAREN + )+ dictionaryCallStmt? + ; -iCS_S_NestedProcedureCall: - ambiguousIdentifier typeHint? WS? LPAREN WS? (argsCall WS?)? RPAREN; +iCS_S_NestedProcedureCall + : ambiguousIdentifier typeHint? WS? LPAREN WS? (argsCall WS?)? RPAREN + ; -iCS_S_MembersCall: ( - iCS_S_VariableOrProcedureCall - | iCS_S_ProcedureOrArrayCall - )? iCS_S_MemberCall+ dictionaryCallStmt?; +iCS_S_MembersCall + : (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall)? iCS_S_MemberCall+ dictionaryCallStmt? + ; -iCS_S_MemberCall: - WS? DOT ( - iCS_S_VariableOrProcedureCall - | iCS_S_ProcedureOrArrayCall - ); +iCS_S_MemberCall + : WS? DOT (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall) + ; -iCS_S_DictionaryCall: dictionaryCallStmt; +iCS_S_DictionaryCall + : dictionaryCallStmt + ; // atomic call statements ---------------------------------- -argsCall: (argCall? WS? (COMMA | SEMICOLON) WS?)* argCall ( - WS? (COMMA | SEMICOLON) WS? argCall? - )*; +argsCall + : (argCall? WS? (COMMA | SEMICOLON) WS?)* argCall (WS? (COMMA | SEMICOLON) WS? argCall?)* + ; -argCall: ((BYVAL | BYREF | PARAMARRAY) WS)? valueStmt; +argCall + : ((BYVAL | BYREF | PARAMARRAY) WS)? valueStmt + ; -dictionaryCallStmt: - EXCLAMATIONMARK ambiguousIdentifier typeHint?; +dictionaryCallStmt + : EXCLAMATIONMARK ambiguousIdentifier typeHint? + ; // atomic rules for statements -argList: LPAREN (WS? arg (WS? COMMA WS? arg)*)? WS? RPAREN; +argList + : LPAREN (WS? arg (WS? COMMA WS? arg)*)? WS? RPAREN + ; -arg: (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier typeHint? ( - WS? LPAREN WS? RPAREN - )? (WS asTypeClause)? (WS? argDefaultValue)?; +arg + : (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier typeHint? ( + WS? LPAREN WS? RPAREN + )? (WS asTypeClause)? (WS? argDefaultValue)? + ; -argDefaultValue: EQ WS? valueStmt; +argDefaultValue + : EQ WS? valueStmt + ; -subscripts: subscript_ (WS? COMMA WS? subscript_)*; +subscripts + : subscript_ (WS? COMMA WS? subscript_)* + ; -subscript_: (valueStmt WS TO WS)? valueStmt; +subscript_ + : (valueStmt WS TO WS)? valueStmt + ; // atomic rules ---------------------------------- -ambiguousIdentifier: (IDENTIFIER | ambiguousKeyword)+ - | L_SQUARE_BRACKET (IDENTIFIER | ambiguousKeyword)+ R_SQUARE_BRACKET; +ambiguousIdentifier + : (IDENTIFIER | ambiguousKeyword)+ + | L_SQUARE_BRACKET (IDENTIFIER | ambiguousKeyword)+ R_SQUARE_BRACKET + ; -asTypeClause: AS WS (NEW WS)? type_ (WS fieldLength)?; +asTypeClause + : AS WS (NEW WS)? type_ (WS fieldLength)? + ; -baseType: - BOOLEAN - | BYTE - | COLLECTION - | DATE - | DOUBLE - | INTEGER - | LONG - | OBJECT - | SINGLE - | STRING - | VARIANT +baseType + : BOOLEAN + | BYTE + | COLLECTION + | DATE + | DOUBLE + | INTEGER + | LONG + | OBJECT + | SINGLE + | STRING + | VARIANT ; -certainIdentifier: - IDENTIFIER (ambiguousKeyword | IDENTIFIER)* - | ambiguousKeyword (ambiguousKeyword | IDENTIFIER)+; +certainIdentifier + : IDENTIFIER (ambiguousKeyword | IDENTIFIER)* + | ambiguousKeyword (ambiguousKeyword | IDENTIFIER)+ + ; -comparisonOperator: LT | LEQ | GT | GEQ | EQ | NEQ | IS | LIKE; +comparisonOperator + : LT + | LEQ + | GT + | GEQ + | EQ + | NEQ + | IS + | LIKE + ; -complexType: ambiguousIdentifier (DOT ambiguousIdentifier)*; +complexType + : ambiguousIdentifier (DOT ambiguousIdentifier)* + ; -fieldLength: MULT WS? (integerLiteral | ambiguousIdentifier); +fieldLength + : MULT WS? (integerLiteral | ambiguousIdentifier) + ; -letterrange: - certainIdentifier (WS? MINUS WS? certainIdentifier)?; +letterrange + : certainIdentifier (WS? MINUS WS? certainIdentifier)? + ; -lineLabel: ambiguousIdentifier COLON; +lineLabel + : ambiguousIdentifier COLON + ; -literal: - COLORLITERAL - | DATELITERAL - | doubleLiteral - | FILENUMBER - | integerLiteral - | octalLiteral - | STRINGLITERAL - | TRUE - | FALSE - | NOTHING - | NULL_ +literal + : COLORLITERAL + | DATELITERAL + | doubleLiteral + | FILENUMBER + | integerLiteral + | octalLiteral + | STRINGLITERAL + | TRUE + | FALSE + | NOTHING + | NULL_ ; -publicPrivateVisibility: PRIVATE | PUBLIC; +publicPrivateVisibility + : PRIVATE + | PUBLIC + ; -publicPrivateGlobalVisibility: PRIVATE | PUBLIC | GLOBAL; +publicPrivateGlobalVisibility + : PRIVATE + | PUBLIC + | GLOBAL + ; -type_: (baseType | complexType) (WS? LPAREN WS? RPAREN)?; +type_ + : (baseType | complexType) (WS? LPAREN WS? RPAREN)? + ; -typeHint: - AMPERSAND - | AT - | DOLLAR - | EXCLAMATIONMARK - | HASH - | PERCENT +typeHint + : AMPERSAND + | AT + | DOLLAR + | EXCLAMATIONMARK + | HASH + | PERCENT ; -visibility: PRIVATE - | PUBLIC - | FRIEND - | GLOBAL - ; +visibility + : PRIVATE + | PUBLIC + | FRIEND + | GLOBAL + ; // ambiguous keywords -ambiguousKeyword: - ACCESS - | ADDRESSOF - | ALIAS - | AND - | ATTRIBUTE - | APPACTIVATE - | APPEND - | AS - | BEEP - | BEGIN - | BINARY - | BOOLEAN - | BYVAL - | BYREF - | BYTE - | CALL - | CASE - | CLASS - | CLOSE - | CHDIR - | CHDRIVE - | COLLECTION - | CONST - | DATE - | DECLARE - | DEFBOOL - | DEFBYTE - | DEFCUR - | DEFDBL - | DEFDATE - | DEFDEC - | DEFINT - | DEFLNG - | DEFOBJ - | DEFSNG - | DEFSTR - | DEFVAR - | DELETESETTING - | DIM - | DO - | DOUBLE - | EACH - | ELSE - | ELSEIF - | END - | ENUM - | EQV - | ERASE - | ERROR - | EVENT - | FALSE - | FILECOPY - | FRIEND - | FOR - | FUNCTION - | GET - | GLOBAL - | GOSUB - | GOTO - | IF - | IMP - | IMPLEMENTS - | IN - | INPUT - | IS - | INTEGER - | KILL - | LOAD - | LOCK - | LONG - | LOOP - | LEN - | LET - | LIB - | LIKE - | LSET - | ME - | MID - | MKDIR - | MOD - | NAME - | NEXT - | NEW - | NOT - | NOTHING - | NULL_ - | OBJECT - | ON - | OPEN - | OPTIONAL - | OR - | OUTPUT - | PARAMARRAY - | PRESERVE - | PRINT - | PRIVATE - | PUBLIC - | PUT - | RANDOM - | RANDOMIZE - | RAISEEVENT - | READ - | REDIM - | REM - | RESET - | RESUME - | RETURN - | RMDIR - | RSET - | SAVEPICTURE - | SAVESETTING - | SEEK - | SELECT - | SENDKEYS - | SET - | SETATTR - | SHARED - | SINGLE - | SPC - | STATIC - | STEP - | STOP - | STRING - | SUB - | TAB - | TEXT - | THEN - | TIME - | TO - | TRUE - | TYPE - | TYPEOF - | UNLOAD - | UNLOCK - | UNTIL - | VARIANT - | VERSION - | WEND - | WHILE - | WIDTH - | WITH - | WITHEVENTS - | WRITE - | XOR - ; - -integerLiteral : (PLUS | MINUS)* INTEGERLITERAL; -octalLiteral : (PLUS | MINUS)* OCTALLITERAL; -doubleLiteral : (PLUS | MINUS)* DOUBLELITERAL; +ambiguousKeyword + : ACCESS + | ADDRESSOF + | ALIAS + | AND + | ATTRIBUTE + | APPACTIVATE + | APPEND + | AS + | BEEP + | BEGIN + | BINARY + | BOOLEAN + | BYVAL + | BYREF + | BYTE + | CALL + | CASE + | CLASS + | CLOSE + | CHDIR + | CHDRIVE + | COLLECTION + | CONST + | DATE + | DECLARE + | DEFBOOL + | DEFBYTE + | DEFCUR + | DEFDBL + | DEFDATE + | DEFDEC + | DEFINT + | DEFLNG + | DEFOBJ + | DEFSNG + | DEFSTR + | DEFVAR + | DELETESETTING + | DIM + | DO + | DOUBLE + | EACH + | ELSE + | ELSEIF + | END + | ENUM + | EQV + | ERASE + | ERROR + | EVENT + | FALSE + | FILECOPY + | FRIEND + | FOR + | FUNCTION + | GET + | GLOBAL + | GOSUB + | GOTO + | IF + | IMP + | IMPLEMENTS + | IN + | INPUT + | IS + | INTEGER + | KILL + | LOAD + | LOCK + | LONG + | LOOP + | LEN + | LET + | LIB + | LIKE + | LSET + | ME + | MID + | MKDIR + | MOD + | NAME + | NEXT + | NEW + | NOT + | NOTHING + | NULL_ + | OBJECT + | ON + | OPEN + | OPTIONAL + | OR + | OUTPUT + | PARAMARRAY + | PRESERVE + | PRINT + | PRIVATE + | PUBLIC + | PUT + | RANDOM + | RANDOMIZE + | RAISEEVENT + | READ + | REDIM + | REM + | RESET + | RESUME + | RETURN + | RMDIR + | RSET + | SAVEPICTURE + | SAVESETTING + | SEEK + | SELECT + | SENDKEYS + | SET + | SETATTR + | SHARED + | SINGLE + | SPC + | STATIC + | STEP + | STOP + | STRING + | SUB + | TAB + | TEXT + | THEN + | TIME + | TO + | TRUE + | TYPE + | TYPEOF + | UNLOAD + | UNLOCK + | UNTIL + | VARIANT + | VERSION + | WEND + | WHILE + | WIDTH + | WITH + | WITHEVENTS + | WRITE + | XOR + ; + +integerLiteral + : (PLUS | MINUS)* INTEGERLITERAL + ; + +octalLiteral + : (PLUS | MINUS)* OCTALLITERAL + ; + +doubleLiteral + : (PLUS | MINUS)* DOUBLELITERAL + ; \ No newline at end of file diff --git a/vba/vba.g4 b/vba/vba.g4 index ad2736136d..0a6a60433b 100644 --- a/vba/vba.g4 +++ b/vba/vba.g4 @@ -91,865 +91,1911 @@ * v1.0 Initial revision */ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar vba; -options { caseInsensitive = true; } +options { + caseInsensitive = true; +} // module ---------------------------------- -startRule : module EOF; - -module : - WS? - endOfLine* - (moduleHeader endOfLine*)? - moduleConfig? endOfLine* - moduleAttributes? endOfLine* - moduleDeclarations? endOfLine* - moduleBody? endOfLine* - WS? -; - -moduleHeader : VERSION WS DOUBLELITERAL WS CLASS; - -moduleConfig : - BEGIN endOfLine* - moduleConfigElement+ - END -; - -moduleConfigElement : - ambiguousIdentifier WS? EQ WS? literal endOfLine* -; - -moduleAttributes : (attributeStmt endOfLine+)+; - -moduleDeclarations : moduleDeclarationsElement (endOfLine+ moduleDeclarationsElement)* endOfLine*; - -moduleOption : - OPTION_BASE WS SHORTLITERAL # optionBaseStmt - | OPTION_COMPARE WS (BINARY | TEXT | DATABASE) # optionCompareStmt - | OPTION_EXPLICIT # optionExplicitStmt - | OPTION_PRIVATE_MODULE # optionPrivateModuleStmt -; - -moduleDeclarationsElement : - comment - | declareStmt - | enumerationStmt - | eventStmt - | constStmt - | implementsStmt - | variableStmt - | moduleOption - | typeStmt +startRule + : module EOF + ; + +module + : WS? endOfLine* (moduleHeader endOfLine*)? moduleConfig? endOfLine* moduleAttributes? endOfLine* moduleDeclarations? endOfLine* moduleBody? + endOfLine* WS? + ; + +moduleHeader + : VERSION WS DOUBLELITERAL WS CLASS + ; + +moduleConfig + : BEGIN endOfLine* moduleConfigElement+ END + ; + +moduleConfigElement + : ambiguousIdentifier WS? EQ WS? literal endOfLine* + ; + +moduleAttributes + : (attributeStmt endOfLine+)+ + ; + +moduleDeclarations + : moduleDeclarationsElement (endOfLine+ moduleDeclarationsElement)* endOfLine* + ; + +moduleOption + : OPTION_BASE WS SHORTLITERAL # optionBaseStmt + | OPTION_COMPARE WS (BINARY | TEXT | DATABASE) # optionCompareStmt + | OPTION_EXPLICIT # optionExplicitStmt + | OPTION_PRIVATE_MODULE # optionPrivateModuleStmt + ; + +moduleDeclarationsElement + : comment + | declareStmt + | enumerationStmt + | eventStmt + | constStmt + | implementsStmt + | variableStmt + | moduleOption + | typeStmt | deftypeStmt - | macroStmt -; - -macroStmt : - macroConstStmt - | macroIfThenElseStmt; - -moduleBody : - moduleBodyElement (endOfLine+ moduleBodyElement)* endOfLine*; - -moduleBodyElement : - functionStmt - | propertyGetStmt - | propertySetStmt - | propertyLetStmt - | subStmt - | macroStmt -; - + | macroStmt + ; + +macroStmt + : macroConstStmt + | macroIfThenElseStmt + ; + +moduleBody + : moduleBodyElement (endOfLine+ moduleBodyElement)* endOfLine* + ; + +moduleBodyElement + : functionStmt + | propertyGetStmt + | propertySetStmt + | propertyLetStmt + | subStmt + | macroStmt + ; // block ---------------------------------- -attributeStmt : ATTRIBUTE WS implicitCallStmt_InStmt WS? EQ WS? literal (WS? ',' WS? literal)*; +attributeStmt + : ATTRIBUTE WS implicitCallStmt_InStmt WS? EQ WS? literal (WS? ',' WS? literal)* + ; -block : blockStmt (endOfStatement blockStmt)* endOfStatement; +block + : blockStmt (endOfStatement blockStmt)* endOfStatement + ; -blockStmt : - lineLabel +blockStmt + : lineLabel | appactivateStmt - | attributeStmt - | beepStmt - | chdirStmt - | chdriveStmt - | closeStmt - | constStmt - | dateStmt - | deleteSettingStmt - | doLoopStmt - | endStmt - | eraseStmt - | errorStmt - | exitStmt - | explicitCallStmt - | filecopyStmt - | forEachStmt - | forNextStmt - | getStmt - | goSubStmt - | goToStmt - | ifThenElseStmt - | implementsStmt - | inputStmt - | killStmt - | letStmt - | lineInputStmt + | attributeStmt + | beepStmt + | chdirStmt + | chdriveStmt + | closeStmt + | constStmt + | dateStmt + | deleteSettingStmt + | doLoopStmt + | endStmt + | eraseStmt + | errorStmt + | exitStmt + | explicitCallStmt + | filecopyStmt + | forEachStmt + | forNextStmt + | getStmt + | goSubStmt + | goToStmt + | ifThenElseStmt + | implementsStmt + | inputStmt + | killStmt + | letStmt + | lineInputStmt | lineNumber - | loadStmt - | lockStmt - | lsetStmt - | macroStmt - | midStmt - | mkdirStmt - | nameStmt - | onErrorStmt - | onGoToStmt - | onGoSubStmt - | openStmt - | printStmt - | putStmt - | raiseEventStmt - | randomizeStmt - | redimStmt - | resetStmt - | resumeStmt - | returnStmt - | rmdirStmt - | rsetStmt - | savepictureStmt - | saveSettingStmt - | seekStmt - | selectCaseStmt - | sendkeysStmt - | setattrStmt - | setStmt - | stopStmt - | timeStmt - | unloadStmt - | unlockStmt - | variableStmt - | whileWendStmt - | widthStmt - | withStmt - | writeStmt - | implicitCallStmt_InBlock + | loadStmt + | lockStmt + | lsetStmt + | macroStmt + | midStmt + | mkdirStmt + | nameStmt + | onErrorStmt + | onGoToStmt + | onGoSubStmt + | openStmt + | printStmt + | putStmt + | raiseEventStmt + | randomizeStmt + | redimStmt + | resetStmt + | resumeStmt + | returnStmt + | rmdirStmt + | rsetStmt + | savepictureStmt + | saveSettingStmt + | seekStmt + | selectCaseStmt + | sendkeysStmt + | setattrStmt + | setStmt + | stopStmt + | timeStmt + | unloadStmt + | unlockStmt + | variableStmt + | whileWendStmt + | widthStmt + | withStmt + | writeStmt + | implicitCallStmt_InBlock | implicitCallStmt_InStmt -; - + ; // statements ---------------------------------- -appactivateStmt : APPACTIVATE WS valueStmt (WS? ',' WS? valueStmt)?; +appactivateStmt + : APPACTIVATE WS valueStmt (WS? ',' WS? valueStmt)? + ; + +beepStmt + : BEEP + ; + +chdirStmt + : CHDIR WS valueStmt + ; + +chdriveStmt + : CHDRIVE WS valueStmt + ; + +closeStmt + : CLOSE (WS fileNumber (WS? ',' WS? fileNumber)*)? + ; + +constStmt + : (visibility WS)? CONST WS constSubStmt (WS? ',' WS? constSubStmt)* + ; + +constSubStmt + : ambiguousIdentifier typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt + ; + +dateStmt + : DATE WS? EQ WS? valueStmt + ; + +declareStmt + : (visibility WS)? DECLARE WS (PTRSAFE WS)? ((FUNCTION typeHint?) | SUB) WS ambiguousIdentifier typeHint? WS LIB WS STRINGLITERAL ( + WS ALIAS WS STRINGLITERAL + )? (WS? argList)? (WS asTypeClause)? + ; + +deftypeStmt + : ( + DEFBOOL + | DEFBYTE + | DEFINT + | DEFLNG + | DEFCUR + | DEFSNG + | DEFDBL + | DEFDEC + | DEFDATE + | DEFSTR + | DEFOBJ + | DEFVAR + ) WS letterrange (WS? ',' WS? letterrange)* + ; + +deleteSettingStmt + : DELETESETTING WS valueStmt WS? ',' WS? valueStmt (WS? ',' WS? valueStmt)? + ; + +doLoopStmt + : DO endOfStatement block? LOOP + | DO WS (WHILE | UNTIL) WS valueStmt endOfStatement block? LOOP + | DO endOfStatement block LOOP WS (WHILE | UNTIL) WS valueStmt + ; + +endStmt + : END + ; + +enumerationStmt + : (visibility WS)? ENUM WS ambiguousIdentifier endOfStatement enumerationStmt_Constant* END_ENUM + ; + +enumerationStmt_Constant + : ambiguousIdentifier (WS? EQ WS? valueStmt)? endOfStatement + ; + +eraseStmt + : ERASE WS valueStmt (',' WS? valueStmt)*? + ; + +errorStmt + : ERROR WS valueStmt + ; + +eventStmt + : (visibility WS)? EVENT WS ambiguousIdentifier WS? argList + ; + +exitStmt + : EXIT_DO + | EXIT_FOR + | EXIT_FUNCTION + | EXIT_PROPERTY + | EXIT_SUB + ; + +filecopyStmt + : FILECOPY WS valueStmt WS? ',' WS? valueStmt + ; + +forEachStmt + : FOR WS EACH WS ambiguousIdentifier typeHint? WS IN WS valueStmt endOfStatement block? NEXT ( + WS ambiguousIdentifier + )? + ; + +forNextStmt + : FOR WS ambiguousIdentifier typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt WS TO WS valueStmt ( + WS STEP WS valueStmt + )? endOfStatement block? NEXT (WS ambiguousIdentifier)? + ; + +functionStmt + : (visibility WS)? (STATIC WS)? FUNCTION WS? ambiguousIdentifier typeHint? (WS? argList)? ( + WS? asTypeClause + )? endOfStatement block? END_FUNCTION + ; + +getStmt + : GET WS fileNumber WS? ',' WS? valueStmt? WS? ',' WS? valueStmt + ; + +goSubStmt + : GOSUB WS valueStmt + ; + +goToStmt + : GOTO WS valueStmt + ; + +ifThenElseStmt + : IF WS ifConditionStmt WS THEN WS blockStmt (WS ELSE WS blockStmt)? # inlineIfThenElse + | ifBlockStmt ifElseIfBlockStmt* ifElseBlockStmt? END_IF # blockIfThenElse + ; + +ifBlockStmt + : IF WS ifConditionStmt WS THEN endOfStatement block? + ; + +ifConditionStmt + : valueStmt + ; + +ifElseIfBlockStmt + : ELSEIF WS ifConditionStmt WS THEN endOfStatement block? + ; + +ifElseBlockStmt + : ELSE endOfStatement block? + ; + +implementsStmt + : IMPLEMENTS WS ambiguousIdentifier + ; + +inputStmt + : INPUT WS fileNumber (WS? ',' WS? valueStmt)+ + ; + +killStmt + : KILL WS valueStmt + ; + +letStmt + : (LET WS)? implicitCallStmt_InStmt WS? (EQ | PLUS_EQ | MINUS_EQ) WS? valueStmt + ; + +lineInputStmt + : LINE_INPUT WS fileNumber WS? ',' WS? valueStmt + ; + +lineNumber + : (INTEGERLITERAL | SHORTLITERAL) NEWLINE? ':'? NEWLINE? WS? + ; + +loadStmt + : LOAD WS valueStmt + ; + +lockStmt + : LOCK WS valueStmt (WS? ',' WS? valueStmt (WS TO WS valueStmt)?)? + ; + +lsetStmt + : LSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt + ; + +macroConstStmt + : MACRO_CONST WS? ambiguousIdentifier WS? EQ WS? valueStmt + ; + +macroIfThenElseStmt + : macroIfBlockStmt macroElseIfBlockStmt* macroElseBlockStmt? MACRO_END_IF + ; + +macroIfBlockStmt + : MACRO_IF WS? ifConditionStmt WS THEN endOfStatement (moduleDeclarations | moduleBody | block)* + ; + +macroElseIfBlockStmt + : MACRO_ELSEIF WS? ifConditionStmt WS THEN endOfStatement ( + moduleDeclarations + | moduleBody + | block + )* + ; + +macroElseBlockStmt + : MACRO_ELSE endOfStatement (moduleDeclarations | moduleBody | block)* + ; + +midStmt + : MID WS? LPAREN WS? argsCall WS? RPAREN + ; + +mkdirStmt + : MKDIR WS valueStmt + ; + +nameStmt + : NAME WS valueStmt WS AS WS valueStmt + ; + +onErrorStmt + : (ON_ERROR | ON_LOCAL_ERROR) WS (GOTO WS valueStmt | RESUME WS NEXT) + ; + +onGoToStmt + : ON WS valueStmt WS GOTO WS valueStmt (WS? ',' WS? valueStmt)* + ; + +onGoSubStmt + : ON WS valueStmt WS GOSUB WS valueStmt (WS? ',' WS? valueStmt)* + ; + +openStmt + : OPEN WS valueStmt WS FOR WS (APPEND | BINARY | INPUT | OUTPUT | RANDOM) ( + WS ACCESS WS (READ | WRITE | READ_WRITE) + )? (WS (SHARED | LOCK_READ | LOCK_WRITE | LOCK_READ_WRITE))? WS AS WS fileNumber ( + WS LEN WS? EQ WS? valueStmt + )? + ; + +outputList + : outputList_Expression (WS? (';' | ',') WS? outputList_Expression?)* + | outputList_Expression? (WS? (';' | ',') WS? outputList_Expression?)+ + ; + +outputList_Expression + : valueStmt + | (SPC | TAB) (WS? LPAREN WS? argsCall WS? RPAREN)? + ; + +printStmt + : PRINT WS fileNumber WS? ',' (WS? outputList)? + ; + +propertyGetStmt + : (visibility WS)? (STATIC WS)? PROPERTY_GET WS ambiguousIdentifier typeHint? (WS? argList)? ( + WS asTypeClause + )? endOfStatement block? END_PROPERTY + ; + +propertySetStmt + : (visibility WS)? (STATIC WS)? PROPERTY_SET WS ambiguousIdentifier (WS? argList)? endOfStatement block? END_PROPERTY + ; + +propertyLetStmt + : (visibility WS)? (STATIC WS)? PROPERTY_LET WS ambiguousIdentifier (WS? argList)? endOfStatement block? END_PROPERTY + ; + +putStmt + : PUT WS fileNumber WS? ',' WS? valueStmt? WS? ',' WS? valueStmt + ; + +raiseEventStmt + : RAISEEVENT WS ambiguousIdentifier (WS? LPAREN WS? (argsCall WS?)? RPAREN)? + ; + +randomizeStmt + : RANDOMIZE (WS valueStmt)? + ; + +redimStmt + : REDIM WS (PRESERVE WS)? redimSubStmt (WS? ',' WS? redimSubStmt)* + ; + +redimSubStmt + : implicitCallStmt_InStmt WS? LPAREN WS? subscripts WS? RPAREN (WS asTypeClause)? + ; + +resetStmt + : RESET + ; + +resumeStmt + : RESUME (WS (NEXT | ambiguousIdentifier))? + ; + +returnStmt + : RETURN + ; + +rmdirStmt + : RMDIR WS valueStmt + ; + +rsetStmt + : RSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt + ; + +savepictureStmt + : SAVEPICTURE WS valueStmt WS? ',' WS? valueStmt + ; + +saveSettingStmt + : SAVESETTING WS valueStmt WS? ',' WS? valueStmt WS? ',' WS? valueStmt WS? ',' WS? valueStmt + ; + +seekStmt + : SEEK WS fileNumber WS? ',' WS? valueStmt + ; + +selectCaseStmt + : SELECT WS CASE WS valueStmt endOfStatement sC_Case* END_SELECT + ; + +sC_Selection + : IS WS? comparisonOperator WS? valueStmt # caseCondIs + | valueStmt WS TO WS valueStmt # caseCondTo + | valueStmt # caseCondValue + ; + +sC_Case + : CASE WS sC_Cond endOfStatement block? + ; -beepStmt : BEEP; +// ELSE first, so that it is not interpreted as a variable call +sC_Cond + : ELSE # caseCondElse + | sC_Selection (WS? ',' WS? sC_Selection)* # caseCondSelection + ; -chdirStmt : CHDIR WS valueStmt; +sendkeysStmt + : SENDKEYS WS valueStmt (WS? ',' WS? valueStmt)? + ; -chdriveStmt : CHDRIVE WS valueStmt; +setattrStmt + : SETATTR WS valueStmt WS? ',' WS? valueStmt + ; -closeStmt : CLOSE (WS fileNumber (WS? ',' WS? fileNumber)*)?; +setStmt + : SET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt + ; -constStmt : (visibility WS)? CONST WS constSubStmt (WS? ',' WS? constSubStmt)*; +stopStmt + : STOP + ; -constSubStmt : ambiguousIdentifier typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt; +subStmt + : (visibility WS)? (STATIC WS)? SUB WS? ambiguousIdentifier (WS? argList)? endOfStatement block? END_SUB + ; -dateStmt : DATE WS? EQ WS? valueStmt; +timeStmt + : TIME WS? EQ WS? valueStmt + ; -declareStmt : (visibility WS)? DECLARE WS (PTRSAFE WS)? ((FUNCTION typeHint?) | SUB) WS ambiguousIdentifier typeHint? WS LIB WS STRINGLITERAL (WS ALIAS WS STRINGLITERAL)? (WS? argList)? (WS asTypeClause)?; +typeStmt + : (visibility WS)? TYPE WS ambiguousIdentifier endOfStatement typeStmt_Element* END_TYPE + ; -deftypeStmt : - ( - DEFBOOL | DEFBYTE | DEFINT | DEFLNG | DEFCUR | - DEFSNG | DEFDBL | DEFDEC | DEFDATE | - DEFSTR | DEFOBJ | DEFVAR - ) WS - letterrange (WS? ',' WS? letterrange)* -; +typeStmt_Element + : ambiguousIdentifier (WS? LPAREN (WS? subscripts)? WS? RPAREN)? (WS asTypeClause)? endOfStatement + ; -deleteSettingStmt : DELETESETTING WS valueStmt WS? ',' WS? valueStmt (WS? ',' WS? valueStmt)?; +typeOfStmt + : TYPEOF WS valueStmt (WS IS WS type_)? + ; -doLoopStmt : - DO endOfStatement - block? - LOOP - | - DO WS (WHILE | UNTIL) WS valueStmt endOfStatement - block? - LOOP - | - DO endOfStatement - block - LOOP WS (WHILE | UNTIL) WS valueStmt -; +unloadStmt + : UNLOAD WS valueStmt + ; -endStmt : END; +unlockStmt + : UNLOCK WS fileNumber (WS? ',' WS? valueStmt (WS TO WS valueStmt)?)? + ; -enumerationStmt: - (visibility WS)? ENUM WS ambiguousIdentifier endOfStatement - enumerationStmt_Constant* - END_ENUM -; +// operator precedence is represented by rule order +valueStmt + : literal # vsLiteral + | implicitCallStmt_InStmt # vsICS + | LPAREN WS? valueStmt (WS? ',' WS? valueStmt)* RPAREN # vsStruct + | NEW WS? valueStmt # vsNew + | typeOfStmt # vsTypeOf + | midStmt # vsMid + | ADDRESSOF WS? valueStmt # vsAddressOf + | implicitCallStmt_InStmt WS? ASSIGN WS? valueStmt # vsAssign + | valueStmt WS? POW WS? valueStmt # vsPow + | MINUS WS? valueStmt # vsNegation + | PLUS WS? valueStmt # vsPlus + | valueStmt WS? (DIV | MULT) WS? valueStmt # vsDivMult + | valueStmt WS? MOD WS? valueStmt # vsMod + | valueStmt WS? (PLUS | MINUS) WS? valueStmt # vsAddMinus + | valueStmt WS? AMPERSAND WS? valueStmt # vsAmp + | valueStmt WS? (IS | LIKE | GEQ | LEQ | GT | LT | NEQ | EQ) WS? valueStmt # vsRelational + | NOT WS? valueStmt # vsNot + | valueStmt WS? AND WS? valueStmt # vsAnd + | valueStmt WS? OR WS? valueStmt # vsOr + | valueStmt WS? XOR WS? valueStmt # vsXor + | valueStmt WS? EQV WS? valueStmt # vsEqv + | valueStmt WS? IMP WS? valueStmt # vsImp + ; + +variableStmt + : (DIM | STATIC | visibility) WS (WITHEVENTS WS)? variableListStmt + ; + +variableListStmt + : variableSubStmt (WS? ',' WS? variableSubStmt)* + ; + +variableSubStmt + : ambiguousIdentifier (WS? LPAREN WS? (subscripts WS?)? RPAREN WS?)? typeHint? ( + WS asTypeClause + )? + ; + +whileWendStmt + : WHILE WS valueStmt endOfStatement block? WEND + ; + +widthStmt + : WIDTH WS fileNumber WS? ',' WS? valueStmt + ; + +withStmt + : WITH WS (implicitCallStmt_InStmt | (NEW WS type_)) endOfStatement block? END_WITH + ; + +writeStmt + : WRITE WS fileNumber WS? ',' (WS? outputList)? + ; + +fileNumber + : '#'? valueStmt + ; -enumerationStmt_Constant : ambiguousIdentifier (WS? EQ WS? valueStmt)? endOfStatement; +// complex call statements ---------------------------------- -eraseStmt : ERASE WS valueStmt (',' WS? valueStmt)*?; +explicitCallStmt + : eCS_ProcedureCall + | eCS_MemberProcedureCall + ; -errorStmt : ERROR WS valueStmt; +// parantheses are required in case of args -> empty parantheses are removed +eCS_ProcedureCall + : CALL WS ambiguousIdentifier typeHint? (WS? LPAREN WS? argsCall WS? RPAREN)? ( + WS? LPAREN subscripts RPAREN + )* + ; -eventStmt : (visibility WS)? EVENT WS ambiguousIdentifier WS? argList; +// parantheses are required in case of args -> empty parantheses are removed +eCS_MemberProcedureCall + : CALL WS implicitCallStmt_InStmt? '.' ambiguousIdentifier typeHint? ( + WS? LPAREN WS? argsCall WS? RPAREN + )? (WS? LPAREN subscripts RPAREN)* + ; + +implicitCallStmt_InBlock + : iCS_B_MemberProcedureCall + | iCS_B_ProcedureCall + ; + +iCS_B_MemberProcedureCall + : implicitCallStmt_InStmt? '.' ambiguousIdentifier typeHint? (WS argsCall)? dictionaryCallStmt? ( + WS? LPAREN subscripts RPAREN + )* + ; -exitStmt : EXIT_DO | EXIT_FOR | EXIT_FUNCTION | EXIT_PROPERTY | EXIT_SUB; +// parantheses are forbidden in case of args +// variables cannot be called in blocks +// certainIdentifier instead of ambiguousIdentifier for preventing ambiguity with statement keywords +iCS_B_ProcedureCall + : certainIdentifier (WS argsCall)? (WS? LPAREN subscripts RPAREN)* + ; -filecopyStmt : FILECOPY WS valueStmt WS? ',' WS? valueStmt; +// iCS_S_MembersCall first, so that member calls are not resolved as separate iCS_S_VariableOrProcedureCalls +implicitCallStmt_InStmt + : iCS_S_MembersCall + | iCS_S_VariableOrProcedureCall + | iCS_S_ProcedureOrArrayCall + | iCS_S_DictionaryCall + ; + +iCS_S_VariableOrProcedureCall + : ambiguousIdentifier typeHint? dictionaryCallStmt? (WS? LPAREN subscripts RPAREN)* + ; + +iCS_S_ProcedureOrArrayCall + : (ambiguousIdentifier | baseType) typeHint? WS? LPAREN WS? (argsCall WS?)? RPAREN dictionaryCallStmt? ( + WS? LPAREN subscripts RPAREN + )* + ; + +iCS_S_MembersCall + : (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall)? iCS_S_MemberCall+ dictionaryCallStmt? ( + WS? LPAREN subscripts RPAREN + )* + ; + +iCS_S_MemberCall + : LINE_CONTINUATION? ('.' | '!') LINE_CONTINUATION? ( + iCS_S_VariableOrProcedureCall + | iCS_S_ProcedureOrArrayCall + ) + ; + +iCS_S_DictionaryCall + : dictionaryCallStmt + ; -forEachStmt : - FOR WS EACH WS ambiguousIdentifier typeHint? WS IN WS valueStmt endOfStatement - block? - NEXT (WS ambiguousIdentifier)? -; +// atomic call statements ---------------------------------- -forNextStmt : - FOR WS ambiguousIdentifier typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt WS TO WS valueStmt (WS STEP WS valueStmt)? endOfStatement - block? - NEXT (WS ambiguousIdentifier)? -; +argsCall + : (argCall? WS? (',' | ';') WS?)* argCall (WS? (',' | ';') WS? argCall?)* + ; -functionStmt : - (visibility WS)? (STATIC WS)? FUNCTION WS? ambiguousIdentifier typeHint? (WS? argList)? (WS? asTypeClause)? endOfStatement - block? - END_FUNCTION -; +argCall + : LPAREN? ((BYVAL | BYREF | PARAMARRAY) WS)? RPAREN? valueStmt + ; -getStmt : GET WS fileNumber WS? ',' WS? valueStmt? WS? ',' WS? valueStmt; +dictionaryCallStmt + : '!' ambiguousIdentifier typeHint? + ; -goSubStmt : GOSUB WS valueStmt; +// atomic rules for statements -goToStmt : GOTO WS valueStmt; +argList + : LPAREN (WS? arg (WS? ',' WS? arg)*)? WS? RPAREN + ; -ifThenElseStmt : - IF WS ifConditionStmt WS THEN WS blockStmt (WS ELSE WS blockStmt)? # inlineIfThenElse - | ifBlockStmt ifElseIfBlockStmt* ifElseBlockStmt? END_IF # blockIfThenElse -; +arg + : (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier typeHint? ( + WS? LPAREN WS? RPAREN + )? (WS? asTypeClause)? (WS? argDefaultValue)? + ; -ifBlockStmt : - IF WS ifConditionStmt WS THEN endOfStatement - block? -; +argDefaultValue + : EQ WS? valueStmt + ; -ifConditionStmt : valueStmt; +subscripts + : subscript_ (WS? ',' WS? subscript_)* + ; -ifElseIfBlockStmt : - ELSEIF WS ifConditionStmt WS THEN endOfStatement - block? -; +subscript_ + : (valueStmt WS TO WS)? valueStmt + ; -ifElseBlockStmt : - ELSE endOfStatement - block? -; +// atomic rules ---------------------------------- -implementsStmt : IMPLEMENTS WS ambiguousIdentifier; +ambiguousIdentifier + : (IDENTIFIER | ambiguousKeyword)+ + ; + +asTypeClause + : AS WS? (NEW WS)? type_ (WS? fieldLength)? + ; + +baseType + : BOOLEAN + | BYTE + | COLLECTION + | DATE + | DOUBLE + | INTEGER + | LONG + | SINGLE + | STRING (WS? MULT WS? valueStmt)? + | VARIANT + ; + +certainIdentifier + : IDENTIFIER (ambiguousKeyword | IDENTIFIER)* + | ambiguousKeyword (ambiguousKeyword | IDENTIFIER)+ + ; + +comparisonOperator + : LT + | LEQ + | GT + | GEQ + | EQ + | NEQ + | IS + | LIKE + ; + +complexType + : ambiguousIdentifier (('.' | '!') ambiguousIdentifier)* + ; + +fieldLength + : MULT WS? (INTEGERLITERAL | ambiguousIdentifier) + ; + +letterrange + : certainIdentifier (WS? MINUS WS? certainIdentifier)? + ; + +lineLabel + : ambiguousIdentifier ':' + ; + +literal + : HEXLITERAL + | OCTLITERAL + | DATELITERAL + | DOUBLELITERAL + | INTEGERLITERAL + | SHORTLITERAL + | STRINGLITERAL + | TRUE + | FALSE + | NOTHING + | NULL_ + ; + +type_ + : (baseType | complexType) (WS? LPAREN WS? RPAREN)? + ; + +typeHint + : '&' + | '%' + | '#' + | '!' + | '@' + | '$' + ; + +visibility + : PRIVATE + | PUBLIC + | FRIEND + | GLOBAL + ; -inputStmt : INPUT WS fileNumber (WS? ',' WS? valueStmt)+; +// ambiguous keywords +ambiguousKeyword + : ACCESS + | ADDRESSOF + | ALIAS + | AND + | ATTRIBUTE + | APPACTIVATE + | APPEND + | AS + | BEEP + | BEGIN + | BINARY + | BOOLEAN + | BYVAL + | BYREF + | BYTE + | CALL + | CASE + | CLASS + | CLOSE + | CHDIR + | CHDRIVE + | COLLECTION + | CONST + | DATABASE + | DATE + | DECLARE + | DEFBOOL + | DEFBYTE + | DEFCUR + | DEFDBL + | DEFDATE + | DEFDEC + | DEFINT + | DEFLNG + | DEFOBJ + | DEFSNG + | DEFSTR + | DEFVAR + | DELETESETTING + | DIM + | DO + | DOUBLE + | EACH + | ELSE + | ELSEIF + | END + | ENUM + | EQV + | ERASE + | ERROR + | EVENT + | FALSE + | FILECOPY + | FRIEND + | FOR + | FUNCTION + | GET + | GLOBAL + | GOSUB + | GOTO + | IF + | IMP + | IMPLEMENTS + | IN + | INPUT + | IS + | INTEGER + | KILL + | LOAD + | LOCK + | LONG + | LOOP + | LEN + | LET + | LIB + | LIKE + | LSET + | ME + | MID + | MKDIR + | MOD + | NAME + | NEXT + | NEW + | NOT + | NOTHING + | NULL_ + | ON + | OPEN + | OPTIONAL + | OR + | OUTPUT + | PARAMARRAY + | PRESERVE + | PRINT + | PRIVATE + | PUBLIC + | PUT + | RANDOM + | RANDOMIZE + | RAISEEVENT + | READ + | REDIM + | REM + | RESET + | RESUME + | RETURN + | RMDIR + | RSET + | SAVEPICTURE + | SAVESETTING + | SEEK + | SELECT + | SENDKEYS + | SET + | SETATTR + | SHARED + | SINGLE + | SPC + | STATIC + | STEP + | STOP + | STRING + | SUB + | TAB + | TEXT + | THEN + | TIME + | TO + | TRUE + | TYPE + | TYPEOF + | UNLOAD + | UNLOCK + | UNTIL + | VARIANT + | VERSION + | WEND + | WHILE + | WIDTH + | WITH + | WITHEVENTS + | WRITE + | XOR + ; + +remComment + : REMCOMMENT + ; + +comment + : COMMENT + ; + +endOfLine + : WS? (NEWLINE | comment | remComment) WS? + ; + +endOfStatement + : (endOfLine | WS? COLON WS?)* + ; -killStmt : KILL WS valueStmt; +// lexer rules -------------------------------------------------------------------------------- -letStmt : (LET WS)? implicitCallStmt_InStmt WS? (EQ | PLUS_EQ | MINUS_EQ) WS? valueStmt; +// keywords +ACCESS + : 'ACCESS' + ; -lineInputStmt : LINE_INPUT WS fileNumber WS? ',' WS? valueStmt; +ADDRESSOF + : 'ADDRESSOF' + ; -lineNumber : (INTEGERLITERAL | SHORTLITERAL) NEWLINE? ':'? NEWLINE? WS?; +ALIAS + : 'ALIAS' + ; -loadStmt : LOAD WS valueStmt; +AND + : 'AND' + ; -lockStmt : LOCK WS valueStmt (WS? ',' WS? valueStmt (WS TO WS valueStmt)?)?; +ATTRIBUTE + : 'ATTRIBUTE' + ; -lsetStmt : LSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt; +APPACTIVATE + : 'APPACTIVATE' + ; -macroConstStmt : MACRO_CONST WS? ambiguousIdentifier WS? EQ WS? valueStmt; +APPEND + : 'APPEND' + ; -macroIfThenElseStmt : macroIfBlockStmt macroElseIfBlockStmt* macroElseBlockStmt? MACRO_END_IF; +AS + : 'AS' + ; -macroIfBlockStmt : - MACRO_IF WS? ifConditionStmt WS THEN endOfStatement - (moduleDeclarations | moduleBody | block)* -; +BEGIN + : 'BEGIN' + ; -macroElseIfBlockStmt : - MACRO_ELSEIF WS? ifConditionStmt WS THEN endOfStatement - (moduleDeclarations | moduleBody | block)* -; +BEEP + : 'BEEP' + ; -macroElseBlockStmt : - MACRO_ELSE endOfStatement - (moduleDeclarations | moduleBody | block)* -; +BINARY + : 'BINARY' + ; -midStmt : MID WS? LPAREN WS? argsCall WS? RPAREN; +BOOLEAN + : 'BOOLEAN' + ; -mkdirStmt : MKDIR WS valueStmt; +BYVAL + : 'BYVAL' + ; -nameStmt : NAME WS valueStmt WS AS WS valueStmt; +BYREF + : 'BYREF' + ; -onErrorStmt : (ON_ERROR | ON_LOCAL_ERROR) WS (GOTO WS valueStmt | RESUME WS NEXT); +BYTE + : 'BYTE' + ; -onGoToStmt : ON WS valueStmt WS GOTO WS valueStmt (WS? ',' WS? valueStmt)*; +CALL + : 'CALL' + ; -onGoSubStmt : ON WS valueStmt WS GOSUB WS valueStmt (WS? ',' WS? valueStmt)*; +CASE + : 'CASE' + ; -openStmt : - OPEN WS valueStmt WS FOR WS (APPEND | BINARY | INPUT | OUTPUT | RANDOM) - (WS ACCESS WS (READ | WRITE | READ_WRITE))? - (WS (SHARED | LOCK_READ | LOCK_WRITE | LOCK_READ_WRITE))? - WS AS WS fileNumber - (WS LEN WS? EQ WS? valueStmt)? -; +CHDIR + : 'CHDIR' + ; -outputList : - outputList_Expression (WS? (';' | ',') WS? outputList_Expression?)* - | outputList_Expression? (WS? (';' | ',') WS? outputList_Expression?)+ -; +CHDRIVE + : 'CHDRIVE' + ; -outputList_Expression : - valueStmt - | (SPC | TAB) (WS? LPAREN WS? argsCall WS? RPAREN)? -; +CLASS + : 'CLASS' + ; -printStmt : PRINT WS fileNumber WS? ',' (WS? outputList)?; +CLOSE + : 'CLOSE' + ; -propertyGetStmt : - (visibility WS)? (STATIC WS)? PROPERTY_GET WS ambiguousIdentifier typeHint? (WS? argList)? (WS asTypeClause)? endOfStatement - block? - END_PROPERTY -; +COLLECTION + : 'COLLECTION' + ; -propertySetStmt : - (visibility WS)? (STATIC WS)? PROPERTY_SET WS ambiguousIdentifier (WS? argList)? endOfStatement - block? - END_PROPERTY -; +CONST + : 'CONST' + ; -propertyLetStmt : - (visibility WS)? (STATIC WS)? PROPERTY_LET WS ambiguousIdentifier (WS? argList)? endOfStatement - block? - END_PROPERTY -; +DATABASE + : 'DATABASE' + ; -putStmt : PUT WS fileNumber WS? ',' WS? valueStmt? WS? ',' WS? valueStmt; +DATE + : 'DATE' + ; -raiseEventStmt : RAISEEVENT WS ambiguousIdentifier (WS? LPAREN WS? (argsCall WS?)? RPAREN)?; +DECLARE + : 'DECLARE' + ; -randomizeStmt : RANDOMIZE (WS valueStmt)?; +DEFBOOL + : 'DEFBOOL' + ; -redimStmt : REDIM WS (PRESERVE WS)? redimSubStmt (WS?',' WS? redimSubStmt)*; +DEFBYTE + : 'DEFBYTE' + ; -redimSubStmt : implicitCallStmt_InStmt WS? LPAREN WS? subscripts WS? RPAREN (WS asTypeClause)?; +DEFDATE + : 'DEFDATE' + ; -resetStmt : RESET; +DEFDBL + : 'DEFDBL' + ; -resumeStmt : RESUME (WS (NEXT | ambiguousIdentifier))?; +DEFDEC + : 'DEFDEC' + ; -returnStmt : RETURN; +DEFCUR + : 'DEFCUR' + ; -rmdirStmt : RMDIR WS valueStmt; +DEFINT + : 'DEFINT' + ; -rsetStmt : RSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt; +DEFLNG + : 'DEFLNG' + ; -savepictureStmt : SAVEPICTURE WS valueStmt WS? ',' WS? valueStmt; +DEFOBJ + : 'DEFOBJ' + ; -saveSettingStmt : SAVESETTING WS valueStmt WS? ',' WS? valueStmt WS? ',' WS? valueStmt WS? ',' WS? valueStmt; +DEFSNG + : 'DEFSNG' + ; -seekStmt : SEEK WS fileNumber WS? ',' WS? valueStmt; +DEFSTR + : 'DEFSTR' + ; -selectCaseStmt : - SELECT WS CASE WS valueStmt endOfStatement - sC_Case* - END_SELECT -; +DEFVAR + : 'DEFVAR' + ; -sC_Selection : - IS WS? comparisonOperator WS? valueStmt # caseCondIs - | valueStmt WS TO WS valueStmt # caseCondTo - | valueStmt # caseCondValue -; +DELETESETTING + : 'DELETESETTING' + ; -sC_Case : - CASE WS sC_Cond endOfStatement - block? -; +DIM + : 'DIM' + ; -// ELSE first, so that it is not interpreted as a variable call -sC_Cond : - ELSE # caseCondElse - | sC_Selection (WS? ',' WS? sC_Selection)* # caseCondSelection -; +DO + : 'DO' + ; -sendkeysStmt : SENDKEYS WS valueStmt (WS? ',' WS? valueStmt)?; +DOUBLE + : 'DOUBLE' + ; -setattrStmt : SETATTR WS valueStmt WS? ',' WS? valueStmt; +EACH + : 'EACH' + ; -setStmt : SET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt; +ELSE + : 'ELSE' + ; -stopStmt : STOP; +ELSEIF + : 'ELSEIF' + ; -subStmt : - (visibility WS)? (STATIC WS)? SUB WS? ambiguousIdentifier (WS? argList)? endOfStatement - block? - END_SUB -; +END_ENUM + : 'END' WS 'ENUM' + ; -timeStmt : TIME WS? EQ WS? valueStmt; +END_FUNCTION + : 'END' WS 'FUNCTION' + ; -typeStmt : - (visibility WS)? TYPE WS ambiguousIdentifier endOfStatement - typeStmt_Element* - END_TYPE -; +END_IF + : 'END' WS 'IF' + ; -typeStmt_Element : ambiguousIdentifier (WS? LPAREN (WS? subscripts)? WS? RPAREN)? (WS asTypeClause)? endOfStatement; +END_PROPERTY + : 'END' WS 'PROPERTY' + ; -typeOfStmt : TYPEOF WS valueStmt (WS IS WS type_)?; +END_SELECT + : 'END' WS 'SELECT' + ; -unloadStmt : UNLOAD WS valueStmt; +END_SUB + : 'END' WS 'SUB' + ; -unlockStmt : UNLOCK WS fileNumber (WS? ',' WS? valueStmt (WS TO WS valueStmt)?)?; +END_TYPE + : 'END' WS 'TYPE' + ; -// operator precedence is represented by rule order -valueStmt : - literal # vsLiteral - | implicitCallStmt_InStmt # vsICS - | LPAREN WS? valueStmt (WS? ',' WS? valueStmt)* RPAREN # vsStruct - | NEW WS? valueStmt # vsNew - | typeOfStmt # vsTypeOf - | midStmt # vsMid - | ADDRESSOF WS? valueStmt # vsAddressOf - | implicitCallStmt_InStmt WS? ASSIGN WS? valueStmt # vsAssign +END_WITH + : 'END' WS 'WITH' + ; - | valueStmt WS? POW WS? valueStmt # vsPow - | MINUS WS? valueStmt # vsNegation - | PLUS WS? valueStmt # vsPlus - | valueStmt WS? (DIV | MULT) WS? valueStmt # vsDivMult - | valueStmt WS? MOD WS? valueStmt # vsMod - | valueStmt WS? (PLUS | MINUS) WS? valueStmt # vsAddMinus - | valueStmt WS? AMPERSAND WS? valueStmt # vsAmp - - | valueStmt WS? (IS | LIKE | GEQ | LEQ | GT | LT | NEQ | EQ) WS? valueStmt #vsRelational +END + : 'END' + ; - | NOT WS? valueStmt # vsNot - | valueStmt WS? AND WS? valueStmt # vsAnd - | valueStmt WS? OR WS? valueStmt # vsOr - | valueStmt WS? XOR WS? valueStmt # vsXor - | valueStmt WS? EQV WS? valueStmt # vsEqv - | valueStmt WS? IMP WS? valueStmt # vsImp - -; +ENUM + : 'ENUM' + ; -variableStmt : (DIM | STATIC | visibility) WS (WITHEVENTS WS)? variableListStmt; +EQV + : 'EQV' + ; -variableListStmt : variableSubStmt (WS? ',' WS? variableSubStmt)*; +ERASE + : 'ERASE' + ; -variableSubStmt : ambiguousIdentifier (WS? LPAREN WS? (subscripts WS?)? RPAREN WS?)? typeHint? (WS asTypeClause)?; +ERROR + : 'ERROR' + ; -whileWendStmt : - WHILE WS valueStmt endOfStatement - block? - WEND -; +EVENT + : 'EVENT' + ; -widthStmt : WIDTH WS fileNumber WS? ',' WS? valueStmt; +EXIT_DO + : 'EXIT' WS 'DO' + ; -withStmt : - WITH WS (implicitCallStmt_InStmt | (NEW WS type_)) endOfStatement - block? - END_WITH -; +EXIT_FOR + : 'EXIT' WS 'FOR' + ; -writeStmt : WRITE WS fileNumber WS? ',' (WS? outputList)?; +EXIT_FUNCTION + : 'EXIT' WS 'FUNCTION' + ; +EXIT_PROPERTY + : 'EXIT' WS 'PROPERTY' + ; -fileNumber : '#'? valueStmt; +EXIT_SUB + : 'EXIT' WS 'SUB' + ; +FALSE + : 'FALSE' + ; -// complex call statements ---------------------------------- +FILECOPY + : 'FILECOPY' + ; -explicitCallStmt : - eCS_ProcedureCall - | eCS_MemberProcedureCall -; +FRIEND + : 'FRIEND' + ; -// parantheses are required in case of args -> empty parantheses are removed -eCS_ProcedureCall : CALL WS ambiguousIdentifier typeHint? (WS? LPAREN WS? argsCall WS? RPAREN)? (WS? LPAREN subscripts RPAREN)*; +FOR + : 'FOR' + ; +FUNCTION + : 'FUNCTION' + ; +GET + : 'GET' + ; -// parantheses are required in case of args -> empty parantheses are removed -eCS_MemberProcedureCall : CALL WS implicitCallStmt_InStmt? '.' ambiguousIdentifier typeHint? (WS? LPAREN WS? argsCall WS? RPAREN)? (WS? LPAREN subscripts RPAREN)*; +GLOBAL + : 'GLOBAL' + ; +GOSUB + : 'GOSUB' + ; -implicitCallStmt_InBlock : - iCS_B_MemberProcedureCall - | iCS_B_ProcedureCall -; +GOTO + : 'GOTO' + ; -iCS_B_MemberProcedureCall : implicitCallStmt_InStmt? '.' ambiguousIdentifier typeHint? (WS argsCall)? dictionaryCallStmt? (WS? LPAREN subscripts RPAREN)*; +IF + : 'IF' + ; -// parantheses are forbidden in case of args -// variables cannot be called in blocks -// certainIdentifier instead of ambiguousIdentifier for preventing ambiguity with statement keywords -iCS_B_ProcedureCall : certainIdentifier (WS argsCall)? (WS? LPAREN subscripts RPAREN)*; +IMP + : 'IMP' + ; +IMPLEMENTS + : 'IMPLEMENTS' + ; -// iCS_S_MembersCall first, so that member calls are not resolved as separate iCS_S_VariableOrProcedureCalls -implicitCallStmt_InStmt : - iCS_S_MembersCall - | iCS_S_VariableOrProcedureCall - | iCS_S_ProcedureOrArrayCall - | iCS_S_DictionaryCall -; +IN + : 'IN' + ; -iCS_S_VariableOrProcedureCall : ambiguousIdentifier typeHint? dictionaryCallStmt? (WS? LPAREN subscripts RPAREN)*; +INPUT + : 'INPUT' + ; -iCS_S_ProcedureOrArrayCall : (ambiguousIdentifier | baseType) typeHint? WS? LPAREN WS? (argsCall WS?)? RPAREN dictionaryCallStmt? (WS? LPAREN subscripts RPAREN)*; +IS + : 'IS' + ; -iCS_S_MembersCall : (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall)? iCS_S_MemberCall+ dictionaryCallStmt? (WS? LPAREN subscripts RPAREN)*; +INTEGER + : 'INTEGER' + ; -iCS_S_MemberCall : LINE_CONTINUATION? ('.' | '!') LINE_CONTINUATION? (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall); +KILL + : 'KILL' + ; -iCS_S_DictionaryCall : dictionaryCallStmt; +LOAD + : 'LOAD' + ; +LOCK + : 'LOCK' + ; -// atomic call statements ---------------------------------- +LONG + : 'LONG' + ; -argsCall : (argCall? WS? (',' | ';') WS?)* argCall (WS? (',' | ';') WS? argCall?)*; +LOOP + : 'LOOP' + ; -argCall : LPAREN? ((BYVAL | BYREF | PARAMARRAY) WS)? RPAREN? valueStmt; +LEN + : 'LEN' + ; -dictionaryCallStmt : '!' ambiguousIdentifier typeHint?; +LET + : 'LET' + ; +LIB + : 'LIB' + ; -// atomic rules for statements +LIKE + : 'LIKE' + ; -argList : LPAREN (WS? arg (WS? ',' WS? arg)*)? WS? RPAREN; +LINE_INPUT + : 'LINE' WS 'INPUT' + ; -arg : (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier typeHint? (WS? LPAREN WS? RPAREN)? (WS? asTypeClause)? (WS? argDefaultValue)?; +LOCK_READ + : 'LOCK' WS 'READ' + ; -argDefaultValue : EQ WS? valueStmt; +LOCK_WRITE + : 'LOCK' WS 'WRITE' + ; -subscripts : subscript_ (WS? ',' WS? subscript_)*; +LOCK_READ_WRITE + : 'LOCK' WS 'READ' WS 'WRITE' + ; -subscript_ : (valueStmt WS TO WS)? valueStmt; +LSET + : 'LSET' + ; +MACRO_CONST + : '#CONST' + ; -// atomic rules ---------------------------------- +MACRO_IF + : '#IF' + ; -ambiguousIdentifier : - (IDENTIFIER | ambiguousKeyword)+ -; +MACRO_ELSEIF + : '#ELSEIF' + ; -asTypeClause : AS WS? (NEW WS)? type_ (WS? fieldLength)?; +MACRO_ELSE + : '#ELSE' + ; -baseType : BOOLEAN | BYTE | COLLECTION | DATE | DOUBLE | INTEGER | LONG | SINGLE | STRING (WS? MULT WS? valueStmt)? | VARIANT; +MACRO_END_IF + : '#END' WS? 'IF' + ; -certainIdentifier : - IDENTIFIER (ambiguousKeyword | IDENTIFIER)* - | ambiguousKeyword (ambiguousKeyword | IDENTIFIER)+ -; +ME + : 'ME' + ; -comparisonOperator : LT | LEQ | GT | GEQ | EQ | NEQ | IS | LIKE; +MID + : 'MID' + ; -complexType : ambiguousIdentifier (('.' | '!') ambiguousIdentifier)*; +MKDIR + : 'MKDIR' + ; -fieldLength : MULT WS? (INTEGERLITERAL | ambiguousIdentifier); +MOD + : 'MOD' + ; -letterrange : certainIdentifier (WS? MINUS WS? certainIdentifier)?; +NAME + : 'NAME' + ; -lineLabel : ambiguousIdentifier ':'; +NEXT + : 'NEXT' + ; -literal : HEXLITERAL | OCTLITERAL | DATELITERAL | DOUBLELITERAL | INTEGERLITERAL | SHORTLITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL_; +NEW + : 'NEW' + ; -type_ : (baseType | complexType) (WS? LPAREN WS? RPAREN)?; +NOT + : 'NOT' + ; -typeHint : '&' | '%' | '#' | '!' | '@' | '$'; +NOTHING + : 'NOTHING' + ; -visibility : PRIVATE | PUBLIC | FRIEND | GLOBAL; +NULL_ + : 'NULL' + ; -// ambiguous keywords -ambiguousKeyword : - ACCESS | ADDRESSOF | ALIAS | AND | ATTRIBUTE | APPACTIVATE | APPEND | AS | - BEEP | BEGIN | BINARY | BOOLEAN | BYVAL | BYREF | BYTE | - CALL | CASE | CLASS | CLOSE | CHDIR | CHDRIVE | COLLECTION | CONST | - DATABASE | DATE | DECLARE | DEFBOOL | DEFBYTE | DEFCUR | DEFDBL | DEFDATE | DEFDEC | DEFINT | DEFLNG | DEFOBJ | DEFSNG | DEFSTR | DEFVAR | DELETESETTING | DIM | DO | DOUBLE | - EACH | ELSE | ELSEIF | END | ENUM | EQV | ERASE | ERROR | EVENT | - FALSE | FILECOPY | FRIEND | FOR | FUNCTION | - GET | GLOBAL | GOSUB | GOTO | - IF | IMP | IMPLEMENTS | IN | INPUT | IS | INTEGER | - KILL | - LOAD | LOCK | LONG | LOOP | LEN | LET | LIB | LIKE | LSET | - ME | MID | MKDIR | MOD | - NAME | NEXT | NEW | NOT | NOTHING | NULL_ | - ON | OPEN | OPTIONAL | OR | OUTPUT | - PARAMARRAY | PRESERVE | PRINT | PRIVATE | PUBLIC | PUT | - RANDOM | RANDOMIZE | RAISEEVENT | READ | REDIM | REM | RESET | RESUME | RETURN | RMDIR | RSET | - SAVEPICTURE | SAVESETTING | SEEK | SELECT | SENDKEYS | SET | SETATTR | SHARED | SINGLE | SPC | STATIC | STEP | STOP | STRING | SUB | - TAB | TEXT | THEN | TIME | TO | TRUE | TYPE | TYPEOF | - UNLOAD | UNLOCK | UNTIL | - VARIANT | VERSION | - WEND | WHILE | WIDTH | WITH | WITHEVENTS | WRITE | - XOR -; - -remComment : REMCOMMENT; - -comment : COMMENT; - -endOfLine : WS? (NEWLINE | comment | remComment) WS?; - -endOfStatement : (endOfLine | WS? COLON WS?)*; +ON + : 'ON' + ; +ON_ERROR + : 'ON' WS 'ERROR' + ; -// lexer rules -------------------------------------------------------------------------------- +ON_LOCAL_ERROR + : 'ON' WS 'LOCAL' WS 'ERROR' + ; +OPEN + : 'OPEN' + ; -// keywords -ACCESS: 'ACCESS'; -ADDRESSOF: 'ADDRESSOF'; -ALIAS: 'ALIAS'; -AND: 'AND'; -ATTRIBUTE: 'ATTRIBUTE'; -APPACTIVATE: 'APPACTIVATE'; -APPEND: 'APPEND'; -AS: 'AS'; -BEGIN: 'BEGIN'; -BEEP: 'BEEP'; -BINARY: 'BINARY'; -BOOLEAN: 'BOOLEAN'; -BYVAL: 'BYVAL'; -BYREF: 'BYREF'; -BYTE: 'BYTE'; -CALL: 'CALL'; -CASE: 'CASE'; -CHDIR: 'CHDIR'; -CHDRIVE: 'CHDRIVE'; -CLASS: 'CLASS'; -CLOSE: 'CLOSE'; -COLLECTION: 'COLLECTION'; -CONST: 'CONST'; -DATABASE: 'DATABASE'; -DATE: 'DATE'; -DECLARE: 'DECLARE'; -DEFBOOL: 'DEFBOOL'; -DEFBYTE: 'DEFBYTE'; -DEFDATE: 'DEFDATE'; -DEFDBL: 'DEFDBL'; -DEFDEC: 'DEFDEC'; -DEFCUR: 'DEFCUR'; -DEFINT: 'DEFINT'; -DEFLNG: 'DEFLNG'; -DEFOBJ: 'DEFOBJ'; -DEFSNG: 'DEFSNG'; -DEFSTR: 'DEFSTR'; -DEFVAR: 'DEFVAR'; -DELETESETTING: 'DELETESETTING'; -DIM: 'DIM'; -DO: 'DO'; -DOUBLE: 'DOUBLE'; -EACH: 'EACH'; -ELSE: 'ELSE'; -ELSEIF: 'ELSEIF'; -END_ENUM: 'END' WS 'ENUM'; -END_FUNCTION: 'END' WS 'FUNCTION'; -END_IF: 'END' WS 'IF'; -END_PROPERTY: 'END' WS 'PROPERTY'; -END_SELECT: 'END' WS 'SELECT'; -END_SUB: 'END' WS 'SUB'; -END_TYPE: 'END' WS 'TYPE'; -END_WITH: 'END' WS 'WITH'; -END: 'END'; -ENUM: 'ENUM'; -EQV: 'EQV'; -ERASE: 'ERASE'; -ERROR: 'ERROR'; -EVENT: 'EVENT'; -EXIT_DO: 'EXIT' WS 'DO'; -EXIT_FOR: 'EXIT' WS 'FOR'; -EXIT_FUNCTION: 'EXIT' WS 'FUNCTION'; -EXIT_PROPERTY: 'EXIT' WS 'PROPERTY'; -EXIT_SUB: 'EXIT' WS 'SUB'; -FALSE: 'FALSE'; -FILECOPY: 'FILECOPY'; -FRIEND: 'FRIEND'; -FOR: 'FOR'; -FUNCTION: 'FUNCTION'; -GET: 'GET'; -GLOBAL: 'GLOBAL'; -GOSUB: 'GOSUB'; -GOTO: 'GOTO'; -IF: 'IF'; -IMP: 'IMP'; -IMPLEMENTS: 'IMPLEMENTS'; -IN: 'IN'; -INPUT: 'INPUT'; -IS: 'IS'; -INTEGER: 'INTEGER'; -KILL: 'KILL'; -LOAD: 'LOAD'; -LOCK: 'LOCK'; -LONG: 'LONG'; -LOOP: 'LOOP'; -LEN: 'LEN'; -LET: 'LET'; -LIB: 'LIB'; -LIKE: 'LIKE'; -LINE_INPUT: 'LINE' WS 'INPUT'; -LOCK_READ: 'LOCK' WS 'READ'; -LOCK_WRITE: 'LOCK' WS 'WRITE'; -LOCK_READ_WRITE: 'LOCK' WS 'READ' WS 'WRITE'; -LSET: 'LSET'; -MACRO_CONST: '#CONST'; -MACRO_IF: '#IF'; -MACRO_ELSEIF: '#ELSEIF'; -MACRO_ELSE: '#ELSE'; -MACRO_END_IF: '#END' WS? 'IF'; -ME: 'ME'; -MID: 'MID'; -MKDIR: 'MKDIR'; -MOD: 'MOD'; -NAME: 'NAME'; -NEXT: 'NEXT'; -NEW: 'NEW'; -NOT: 'NOT'; -NOTHING: 'NOTHING'; -NULL_: 'NULL'; -ON: 'ON'; -ON_ERROR: 'ON' WS 'ERROR'; -ON_LOCAL_ERROR: 'ON' WS 'LOCAL' WS 'ERROR'; -OPEN: 'OPEN'; -OPTIONAL: 'OPTIONAL'; -OPTION_BASE: 'OPTION' WS 'BASE'; -OPTION_EXPLICIT: 'OPTION' WS 'EXPLICIT'; -OPTION_COMPARE: 'OPTION' WS 'COMPARE'; -OPTION_PRIVATE_MODULE: 'OPTION' WS 'PRIVATE' WS 'MODULE'; -OR: 'OR'; -OUTPUT: 'OUTPUT'; -PARAMARRAY: 'PARAMARRAY'; -PRESERVE: 'PRESERVE'; -PRINT: 'PRINT'; -PRIVATE: 'PRIVATE'; -PROPERTY_GET: 'PROPERTY' WS 'GET'; -PROPERTY_LET: 'PROPERTY' WS 'LET'; -PROPERTY_SET: 'PROPERTY' WS 'SET'; -PTRSAFE: 'PTRSAFE'; -PUBLIC: 'PUBLIC'; -PUT: 'PUT'; -RANDOM: 'RANDOM'; -RANDOMIZE: 'RANDOMIZE'; -RAISEEVENT: 'RAISEEVENT'; -READ: 'READ'; -READ_WRITE: 'READ' WS 'WRITE'; -REDIM: 'REDIM'; -REM: 'REM'; -RESET: 'RESET'; -RESUME: 'RESUME'; -RETURN: 'RETURN'; -RMDIR: 'RMDIR'; -RSET: 'RSET'; -SAVEPICTURE: 'SAVEPICTURE'; -SAVESETTING: 'SAVESETTING'; -SEEK: 'SEEK'; -SELECT: 'SELECT'; -SENDKEYS: 'SENDKEYS'; -SET: 'SET'; -SETATTR: 'SETATTR'; -SHARED: 'SHARED'; -SINGLE: 'SINGLE'; -SPC: 'SPC'; -STATIC: 'STATIC'; -STEP: 'STEP'; -STOP: 'STOP'; -STRING: 'STRING'; -SUB: 'SUB'; -TAB: 'TAB'; -TEXT: 'TEXT'; -THEN: 'THEN'; -TIME: 'TIME'; -TO: 'TO'; -TRUE: 'TRUE'; -TYPE: 'TYPE'; -TYPEOF: 'TYPEOF'; -UNLOAD: 'UNLOAD'; -UNLOCK: 'UNLOCK'; -UNTIL: 'UNTIL'; -VARIANT: 'VARIANT'; -VERSION: 'VERSION'; -WEND: 'WEND'; -WHILE: 'WHILE'; -WIDTH: 'WIDTH'; -WITH: 'WITH'; -WITHEVENTS: 'WITHEVENTS'; -WRITE: 'WRITE'; -XOR: 'XOR'; +OPTIONAL + : 'OPTIONAL' + ; + +OPTION_BASE + : 'OPTION' WS 'BASE' + ; + +OPTION_EXPLICIT + : 'OPTION' WS 'EXPLICIT' + ; + +OPTION_COMPARE + : 'OPTION' WS 'COMPARE' + ; + +OPTION_PRIVATE_MODULE + : 'OPTION' WS 'PRIVATE' WS 'MODULE' + ; + +OR + : 'OR' + ; + +OUTPUT + : 'OUTPUT' + ; + +PARAMARRAY + : 'PARAMARRAY' + ; + +PRESERVE + : 'PRESERVE' + ; + +PRINT + : 'PRINT' + ; + +PRIVATE + : 'PRIVATE' + ; + +PROPERTY_GET + : 'PROPERTY' WS 'GET' + ; + +PROPERTY_LET + : 'PROPERTY' WS 'LET' + ; + +PROPERTY_SET + : 'PROPERTY' WS 'SET' + ; + +PTRSAFE + : 'PTRSAFE' + ; + +PUBLIC + : 'PUBLIC' + ; + +PUT + : 'PUT' + ; + +RANDOM + : 'RANDOM' + ; + +RANDOMIZE + : 'RANDOMIZE' + ; + +RAISEEVENT + : 'RAISEEVENT' + ; + +READ + : 'READ' + ; + +READ_WRITE + : 'READ' WS 'WRITE' + ; + +REDIM + : 'REDIM' + ; + +REM + : 'REM' + ; + +RESET + : 'RESET' + ; + +RESUME + : 'RESUME' + ; + +RETURN + : 'RETURN' + ; +RMDIR + : 'RMDIR' + ; + +RSET + : 'RSET' + ; + +SAVEPICTURE + : 'SAVEPICTURE' + ; + +SAVESETTING + : 'SAVESETTING' + ; + +SEEK + : 'SEEK' + ; + +SELECT + : 'SELECT' + ; + +SENDKEYS + : 'SENDKEYS' + ; + +SET + : 'SET' + ; + +SETATTR + : 'SETATTR' + ; + +SHARED + : 'SHARED' + ; + +SINGLE + : 'SINGLE' + ; + +SPC + : 'SPC' + ; + +STATIC + : 'STATIC' + ; + +STEP + : 'STEP' + ; + +STOP + : 'STOP' + ; + +STRING + : 'STRING' + ; + +SUB + : 'SUB' + ; + +TAB + : 'TAB' + ; + +TEXT + : 'TEXT' + ; + +THEN + : 'THEN' + ; + +TIME + : 'TIME' + ; + +TO + : 'TO' + ; + +TRUE + : 'TRUE' + ; + +TYPE + : 'TYPE' + ; + +TYPEOF + : 'TYPEOF' + ; + +UNLOAD + : 'UNLOAD' + ; + +UNLOCK + : 'UNLOCK' + ; + +UNTIL + : 'UNTIL' + ; + +VARIANT + : 'VARIANT' + ; + +VERSION + : 'VERSION' + ; + +WEND + : 'WEND' + ; + +WHILE + : 'WHILE' + ; + +WIDTH + : 'WIDTH' + ; + +WITH + : 'WITH' + ; + +WITHEVENTS + : 'WITHEVENTS' + ; + +WRITE + : 'WRITE' + ; + +XOR + : 'XOR' + ; // symbols -AMPERSAND : '&'; -ASSIGN : ':='; -DIV : '\\' | '/'; -EQ : '='; -GEQ : '>='; -GT : '>'; -LEQ : '<='; -LPAREN : '('; -LT : '<'; -MINUS : '-'; -MINUS_EQ : '-='; -MULT : '*'; -NEQ : '<>'; -PLUS : '+'; -PLUS_EQ : '+='; -POW : '^'; -RPAREN : ')'; -L_SQUARE_BRACKET : '['; -R_SQUARE_BRACKET : ']'; +AMPERSAND + : '&' + ; + +ASSIGN + : ':=' + ; + +DIV + : '\\' + | '/' + ; + +EQ + : '=' + ; + +GEQ + : '>=' + ; + +GT + : '>' + ; + +LEQ + : '<=' + ; + +LPAREN + : '(' + ; + +LT + : '<' + ; + +MINUS + : '-' + ; + +MINUS_EQ + : '-=' + ; + +MULT + : '*' + ; +NEQ + : '<>' + ; + +PLUS + : '+' + ; + +PLUS_EQ + : '+=' + ; + +POW + : '^' + ; + +RPAREN + : ')' + ; + +L_SQUARE_BRACKET + : '[' + ; + +R_SQUARE_BRACKET + : ']' + ; // literals -STRINGLITERAL : '"' (~["\r\n] | '""')* '"'; -OCTLITERAL : '&O' [0-7]+ '&'?; -HEXLITERAL : '&H' [0-9A-F]+ '&'?; -SHORTLITERAL : (PLUS|MINUS)? DIGIT+ ('#' | '&' | '@')?; -INTEGERLITERAL : SHORTLITERAL ('E' SHORTLITERAL)?; -DOUBLELITERAL : (PLUS|MINUS)? DIGIT* '.' DIGIT+ ('E' SHORTLITERAL)?; -DATELITERAL : '#' DATEORTIME '#'; -fragment DATEORTIME : DATEVALUE WS? TIMEVALUE | DATEVALUE | TIMEVALUE; -fragment DATEVALUE : DATEVALUEPART DATESEPARATOR DATEVALUEPART (DATESEPARATOR DATEVALUEPART)?; -fragment DATEVALUEPART : DIGIT+ | MONTHNAME; -fragment DATESEPARATOR : WS? [/,-]? WS?; -fragment MONTHNAME : ENGLISHMONTHNAME | ENGLISHMONTHABBREVIATION; -fragment ENGLISHMONTHNAME: 'JANUARY' | 'FEBRUARY' | 'MARCH' | 'APRIL' | 'MAY' | 'JUNE | AUGUST' | 'SEPTEMBER' | 'OCTOBER' | 'NOVEMBER' | 'DECEMBER'; -fragment ENGLISHMONTHABBREVIATION: 'JAN' | 'FEB' | 'MAR' | 'APR' | 'JUN' | 'JUL' | 'AUG' | 'SEP' | 'OCT' | 'NOV' | 'DEC'; -fragment TIMEVALUE : DIGIT+ AMPM | DIGIT+ TIMESEPARATOR DIGIT+ (TIMESEPARATOR DIGIT+)? AMPM?; -fragment TIMESEPARATOR : WS? (':' | '.') WS?; -fragment AMPM : WS? ('AM' | 'PM' | 'A' | 'P'); +STRINGLITERAL + : '"' (~["\r\n] | '""')* '"' + ; + +OCTLITERAL + : '&O' [0-7]+ '&'? + ; + +HEXLITERAL + : '&H' [0-9A-F]+ '&'? + ; + +SHORTLITERAL + : (PLUS | MINUS)? DIGIT+ ('#' | '&' | '@')? + ; + +INTEGERLITERAL + : SHORTLITERAL ('E' SHORTLITERAL)? + ; + +DOUBLELITERAL + : (PLUS | MINUS)? DIGIT* '.' DIGIT+ ('E' SHORTLITERAL)? + ; + +DATELITERAL + : '#' DATEORTIME '#' + ; + +fragment DATEORTIME + : DATEVALUE WS? TIMEVALUE + | DATEVALUE + | TIMEVALUE + ; + +fragment DATEVALUE + : DATEVALUEPART DATESEPARATOR DATEVALUEPART (DATESEPARATOR DATEVALUEPART)? + ; + +fragment DATEVALUEPART + : DIGIT+ + | MONTHNAME + ; + +fragment DATESEPARATOR + : WS? [/,-]? WS? + ; + +fragment MONTHNAME + : ENGLISHMONTHNAME + | ENGLISHMONTHABBREVIATION + ; + +fragment ENGLISHMONTHNAME + : 'JANUARY' + | 'FEBRUARY' + | 'MARCH' + | 'APRIL' + | 'MAY' + | 'JUNE | AUGUST' + | 'SEPTEMBER' + | 'OCTOBER' + | 'NOVEMBER' + | 'DECEMBER' + ; + +fragment ENGLISHMONTHABBREVIATION + : 'JAN' + | 'FEB' + | 'MAR' + | 'APR' + | 'JUN' + | 'JUL' + | 'AUG' + | 'SEP' + | 'OCT' + | 'NOV' + | 'DEC' + ; + +fragment TIMEVALUE + : DIGIT+ AMPM + | DIGIT+ TIMESEPARATOR DIGIT+ (TIMESEPARATOR DIGIT+)? AMPM? + ; + +fragment TIMESEPARATOR + : WS? (':' | '.') WS? + ; + +fragment AMPM + : WS? ('AM' | 'PM' | 'A' | 'P') + ; // whitespace, line breaks, comments, ... -LINE_CONTINUATION : [ \t]+ UNDERSCORE '\r'? '\n' WS* -> skip; -NEWLINE : [\r\n\u2028\u2029]+; -REMCOMMENT : COLON? REM WS (LINE_CONTINUATION | ~[\r\n\u2028\u2029])*; -COMMENT : SINGLEQUOTE (LINE_CONTINUATION | ~[\r\n\u2028\u2029])*; -SINGLEQUOTE : '\''; -COLON : ':'; -UNDERSCORE : '_'; -WS : ([ \t] | LINE_CONTINUATION)+; +LINE_CONTINUATION + : [ \t]+ UNDERSCORE '\r'? '\n' WS* -> skip + ; + +NEWLINE + : [\r\n\u2028\u2029]+ + ; + +REMCOMMENT + : COLON? REM WS (LINE_CONTINUATION | ~[\r\n\u2028\u2029])* + ; + +COMMENT + : SINGLEQUOTE (LINE_CONTINUATION | ~[\r\n\u2028\u2029])* + ; + +SINGLEQUOTE + : '\'' + ; + +COLON + : ':' + ; + +UNDERSCORE + : '_' + ; + +WS + : ([ \t] | LINE_CONTINUATION)+ + ; // identifier -IDENTIFIER : ~[\]()\r\n\t.,'"|!@#$%^&*\-+:=; ]+ | L_SQUARE_BRACKET (~[!\]\r\n])+ R_SQUARE_BRACKET; +IDENTIFIER + : ~[\]()\r\n\t.,'"|!@#$%^&*\-+:=; ]+ + | L_SQUARE_BRACKET (~[!\]\r\n])+ R_SQUARE_BRACKET + ; // letters -fragment LETTER : [A-Z_\p{L}]; -fragment DIGIT : [0-9]; -fragment LETTERORDIGIT : [A-Z0-9_\p{L}]; +fragment LETTER + : [A-Z_\p{L}] + ; + +fragment DIGIT + : [0-9] + ; + +fragment LETTERORDIGIT + : [A-Z0-9_\p{L}] + ; \ No newline at end of file diff --git a/velocity/VTLLexer.g4 b/velocity/VTLLexer.g4 index 0acbfe6fde..fa5fcec372 100644 --- a/velocity/VTLLexer.g4 +++ b/velocity/VTLLexer.g4 @@ -1,402 +1,279 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar VTLLexer; tokens { - OPAR, CPAR, OBRACK, CBRACK, OBRACE, CBRACE, STRING, INTEGER, ID, REFERENCE, DOT, COMMA, ASSIGN, EQ, NE, AND, OR, - K_NULL, ADD, SUB, MUL, DIV, MOD, COLON, FLOAT, RANGE, LT, LE, GT, GE, EXCL, K_LT, K_LE, K_GT, K_GE, K_EQ, K_NE, - K_TRUE, K_FALSE, K_AND, K_OR, K_NOT, K_NULL, K_IN, IF, ELSEIF, ELSE, FOREACH, SET, END, BREAK, MACRO_ID, MACRO, - STOP, INCLUDE, EVALUATE, PARSE, DEFINE + OPAR, + CPAR, + OBRACK, + CBRACK, + OBRACE, + CBRACE, + STRING, + INTEGER, + ID, + REFERENCE, + DOT, + COMMA, + ASSIGN, + EQ, + NE, + AND, + OR, + K_NULL, + ADD, + SUB, + MUL, + DIV, + MOD, + COLON, + FLOAT, + RANGE, + LT, + LE, + GT, + GE, + EXCL, + K_LT, + K_LE, + K_GT, + K_GE, + K_EQ, + K_NE, + K_TRUE, + K_FALSE, + K_AND, + K_OR, + K_NOT, + K_NULL, + K_IN, + IF, + ELSEIF, + ELSE, + FOREACH, + SET, + END, + BREAK, + MACRO_ID, + MACRO, + STOP, + INCLUDE, + EVALUATE, + PARSE, + DEFINE } -ESCAPED_CHAR - : '\\' . - ; +ESCAPED_CHAR: '\\' .; -START_DIRECTIVE - : '#' -> skip, pushMode(DIR_) - ; +START_DIRECTIVE: '#' -> skip, pushMode(DIR_); -DOLLAR_EXCL_OBRACE - : '$' '\\'* '!{' -> pushMode(FRM_) - ; +DOLLAR_EXCL_OBRACE: '$' '\\'* '!{' -> pushMode(FRM_); -DOLLAR_OBRACE - : '$' '{' -> pushMode(FRM_) - ; +DOLLAR_OBRACE: '$' '{' -> pushMode(FRM_); -DOLLAR_EXCL - : '$' '\\'* '!' -> pushMode(VAR_) - ; +DOLLAR_EXCL: '$' '\\'* '!' -> pushMode(VAR_); -DOLLAR - : '$' -> pushMode(VAR_) - ; +DOLLAR: '$' -> pushMode(VAR_); -TEXT - : . - ; +TEXT: .; // Formal mode mode FRM_; -FRM_ID - : ID -> type(ID) - ; +FRM_ID: ID -> type(ID); -FRM_DOT - : '.' -> type(DOT) - ; +FRM_DOT: '.' -> type(DOT); -FRM_OBRACK - : '[' -> type(OBRACK), pushMode(IDX_) - ; +FRM_OBRACK: '[' -> type(OBRACK), pushMode(IDX_); -FRM_OPAR - : '(' -> type(OPAR), pushMode(CODE_) - ; +FRM_OPAR: '(' -> type(OPAR), pushMode(CODE_); -FRM_CBRACE - : '}' -> type(CBRACE), popMode - ; +FRM_CBRACE: '}' -> type(CBRACE), popMode; // Directive mode mode DIR_; -ESCAPED_BLOCK - : '[[' .*? ']]#' -> popMode - ; +ESCAPED_BLOCK: '[[' .*? ']]#' -> popMode; -SNGLE_LINE_COMMENT - : '#' ~[\r\n]* -> skip , popMode - ; +SNGLE_LINE_COMMENT: '#' ~[\r\n]* -> skip, popMode; -VTL_COMMENT_BLOCK - : '**' .*? '*#' -> channel(HIDDEN), popMode - ; +VTL_COMMENT_BLOCK: '**' .*? '*#' -> channel(HIDDEN), popMode; -MULTI_LINE_COMMENT - : '*' .*? '*#' -> skip, popMode - ; +MULTI_LINE_COMMENT: '*' .*? '*#' -> skip, popMode; -DIR_SET - : ( 'set' | '{set}' ) SPACES? '(' -> type(SET), popMode, pushMode(CODE_) - ; +DIR_SET: ( 'set' | '{set}') SPACES? '(' -> type(SET), popMode, pushMode(CODE_); -DIR_FOREACH - : ( 'foreach' | '{foreach}' ) SPACES? '(' -> type(FOREACH), popMode, pushMode(CODE_) - ; +DIR_FOREACH: ( 'foreach' | '{foreach}') SPACES? '(' -> type(FOREACH), popMode, pushMode(CODE_); -DIR_IF - : ( 'if' | '{if}' ) SPACES? '(' -> type(IF), popMode, pushMode(CODE_) - ; +DIR_IF: ( 'if' | '{if}') SPACES? '(' -> type(IF), popMode, pushMode(CODE_); -DIR_ELSEIF - : ( 'elseif' | '{elseif}' ) SPACES? '(' -> type(ELSEIF), popMode, pushMode(CODE_) - ; +DIR_ELSEIF: ( 'elseif' | '{elseif}') SPACES? '(' -> type(ELSEIF), popMode, pushMode(CODE_); -DIR_ELSE - : ( 'else' | '{else}' ) -> type(ELSE), popMode - ; +DIR_ELSE: ( 'else' | '{else}') -> type(ELSE), popMode; -DIR_INCLUDE - : ( 'include' | '{include}' ) SPACES? '(' -> type(INCLUDE), popMode, pushMode(CODE_) - ; +DIR_INCLUDE: ( 'include' | '{include}') SPACES? '(' -> type(INCLUDE), popMode, pushMode(CODE_); -DIR_PARSE - : ( 'parse' | '{parse}' ) SPACES? '(' -> type(PARSE), popMode, pushMode(CODE_) - ; +DIR_PARSE: ( 'parse' | '{parse}') SPACES? '(' -> type(PARSE), popMode, pushMode(CODE_); -DIR_EVALUATE - : ( 'evaluate' | '{evaluate}' ) SPACES? '(' -> type(EVALUATE), popMode, pushMode(CODE_) - ; +DIR_EVALUATE: + ('evaluate' | '{evaluate}') SPACES? '(' -> type(EVALUATE), popMode, pushMode(CODE_) +; -DIR_DEFINE - : ( 'define' | '{define}' ) SPACES? '(' -> type(DEFINE), popMode, pushMode(CODE_) - ; +DIR_DEFINE: ( 'define' | '{define}') SPACES? '(' -> type(DEFINE), popMode, pushMode(CODE_); -DIR_STOP - : ( 'stop' | '{stop}' ) -> type(STOP), popMode - ; +DIR_STOP: ( 'stop' | '{stop}') -> type(STOP), popMode; -DIR_BREAK - : ( 'break' | '{break}' ) -> type(BREAK), popMode - ; +DIR_BREAK: ( 'break' | '{break}') -> type(BREAK), popMode; -DIR_END - : ( 'end' | '{end}' ) -> type(END), popMode - ; +DIR_END: ( 'end' | '{end}') -> type(END), popMode; -DIR_MACRO - : ( 'macro' | '{macro}' ) SPACES? '(' -> type(MACRO), popMode, pushMode(CODE_) - ; +DIR_MACRO: ( 'macro' | '{macro}') SPACES? '(' -> type(MACRO), popMode, pushMode(CODE_); -DIR_MACRO_CALL - : '@' ID SPACES? '(' -> type(MACRO_ID), popMode, pushMode(CODE_) - ; +DIR_MACRO_CALL: '@' ID SPACES? '(' -> type(MACRO_ID), popMode, pushMode(CODE_); -DIR_CUSTOM_CODE - : ID SPACES? '(' -> type(ID), popMode, pushMode(CODE_) - ; +DIR_CUSTOM_CODE: ID SPACES? '(' -> type(ID), popMode, pushMode(CODE_); -DIR_CUSTOM - : ID -> type(ID), popMode - ; +DIR_CUSTOM: ID -> type(ID), popMode; // Variable mode mode VAR_; -VAR_DOLLAR - : '$' -> type(DOLLAR) - ; +VAR_DOLLAR: '$' -> type(DOLLAR); -VAR_DOLLAR_EXCL - : '$' '\\'* '!' -> type(DOLLAR_EXCL) - ; +VAR_DOLLAR_EXCL: '$' '\\'* '!' -> type(DOLLAR_EXCL); -VAR_DOLLAR_EXCL_OBRACE - : '$' '\\'* '!{' -> type(DOLLAR_EXCL_OBRACE), popMode, pushMode(FRM_) - ; +VAR_DOLLAR_EXCL_OBRACE: '$' '\\'* '!{' -> type(DOLLAR_EXCL_OBRACE), popMode, pushMode(FRM_); -VAR_DOLLAR_OBRACE - : '$' '{' -> type(DOLLAR_OBRACE), popMode, pushMode(FRM_) - ; +VAR_DOLLAR_OBRACE: '$' '{' -> type(DOLLAR_OBRACE), popMode, pushMode(FRM_); -VAR_HASH - : '#' -> skip, popMode, pushMode(DIR_) - ; +VAR_HASH: '#' -> skip, popMode, pushMode(DIR_); -VAR_ID - : ID -> type(ID) - ; +VAR_ID: ID -> type(ID); -VAR_DOT - : '.' -> type(DOT) - ; +VAR_DOT: '.' -> type(DOT); -VAR_OBRACK - : '[' -> type(OBRACK), pushMode(IDX_) - ; +VAR_OBRACK: '[' -> type(OBRACK), pushMode(IDX_); -VAR_OPAR - : '(' -> type(OPAR), pushMode(CODE_) - ; +VAR_OPAR: '(' -> type(OPAR), pushMode(CODE_); -VAR_TEXT - : . -> type(TEXT), popMode - ; +VAR_TEXT: . -> type(TEXT), popMode; // Code mode mode CODE_; -CODE_K_LT - : 'lt' -> type(K_LT) - ; +CODE_K_LT: 'lt' -> type(K_LT); -CODE_K_LE - : 'le' -> type(K_LE) - ; +CODE_K_LE: 'le' -> type(K_LE); -CODE_K_GT - : 'gt' -> type(K_GT) - ; +CODE_K_GT: 'gt' -> type(K_GT); -CODE_K_GE - : 'ge' -> type(K_GE) - ; +CODE_K_GE: 'ge' -> type(K_GE); -CODE_K_EQ - : 'eq' -> type(K_EQ) - ; +CODE_K_EQ: 'eq' -> type(K_EQ); -CODE_K_NE - : 'ne' -> type(K_NE) - ; +CODE_K_NE: 'ne' -> type(K_NE); -CODE_K_TRUE - : 'true' -> type(K_TRUE) - ; +CODE_K_TRUE: 'true' -> type(K_TRUE); -CODE_K_FALSE - : 'false' -> type(K_FALSE) - ; +CODE_K_FALSE: 'false' -> type(K_FALSE); -CODE_K_AND - : 'and' -> type(K_AND) - ; +CODE_K_AND: 'and' -> type(K_AND); -CODE_K_OR - : 'or' -> type(K_OR) - ; +CODE_K_OR: 'or' -> type(K_OR); -CODE_K_NOT - : 'not' -> type(K_NOT) - ; +CODE_K_NOT: 'not' -> type(K_NOT); -CODE_K_NULL - : 'null' -> type(K_NULL) - ; +CODE_K_NULL: 'null' -> type(K_NULL); -CODE_K_IN - : 'in' -> type(K_IN) - ; +CODE_K_IN: 'in' -> type(K_IN); -CODE_ID - : ID -> type(ID) - ; +CODE_ID: ID -> type(ID); -CODE_ADD - : '+' -> type(ADD) - ; +CODE_ADD: '+' -> type(ADD); -CODE_SUB - : '-' -> type(SUB) - ; +CODE_SUB: '-' -> type(SUB); -CODE_MUL - : '*' -> type(MUL) - ; +CODE_MUL: '*' -> type(MUL); -CODE_DIV - : '/' -> type(DIV) - ; +CODE_DIV: '/' -> type(DIV); -CODE_MOD - : '%' -> type(MOD) - ; +CODE_MOD: '%' -> type(MOD); -CODE_EXCL - : '!' -> type(EXCL) - ; +CODE_EXCL: '!' -> type(EXCL); -CODE_OR - : '||' -> type(OR) - ; +CODE_OR: '||' -> type(OR); -CODE_AND - : '&&' -> type(AND) - ; +CODE_AND: '&&' -> type(AND); -CODE_ASSIGN - : '=' -> type(ASSIGN) - ; +CODE_ASSIGN: '=' -> type(ASSIGN); -CODE_EQ - : '==' -> type(EQ) - ; +CODE_EQ: '==' -> type(EQ); -CODE_NEQ - : '!=' -> type(NE) - ; +CODE_NEQ: '!=' -> type(NE); -CODE_LT - : '<' -> type(LT) - ; +CODE_LT: '<' -> type(LT); -CODE_LE - : '<=' -> type(LE) - ; +CODE_LE: '<=' -> type(LE); -CODE_GT - : '>' -> type(GT) - ; +CODE_GT: '>' -> type(GT); -CODE_GE - : '>=' -> type(GE) - ; +CODE_GE: '>=' -> type(GE); -CODE_SPACES - : SPACES -> skip - ; +CODE_SPACES: SPACES -> skip; -CODE_REFERENCE - : '$' ID -> type(REFERENCE) - ; +CODE_REFERENCE: '$' ID -> type(REFERENCE); -CODE_OPAR - : '(' -> type(OPAR), pushMode(CODE_) - ; +CODE_OPAR: '(' -> type(OPAR), pushMode(CODE_); -CODE_CPAR - : ')' -> type(CPAR), popMode - ; +CODE_CPAR: ')' -> type(CPAR), popMode; -CODE_COLON - : ':' -> type(COLON) - ; +CODE_COLON: ':' -> type(COLON); -CODE_RANGE - : '..' -> type(RANGE) - ; +CODE_RANGE: '..' -> type(RANGE); -CODE_DOT - : '.' -> type(DOT) - ; +CODE_DOT: '.' -> type(DOT); -CODE_FLOAT - : FLOAT -> type(FLOAT) - ; +CODE_FLOAT: FLOAT -> type(FLOAT); -CODE_INTEGER - : INTEGER -> type(INTEGER) - ; +CODE_INTEGER: INTEGER -> type(INTEGER); -CODE_STRING - : STRING -> type(STRING) - ; +CODE_STRING: STRING -> type(STRING); -CODE_OBRACK - : '[' -> type(OBRACK) - ; +CODE_OBRACK: '[' -> type(OBRACK); -CODE_CBRACK - : ']' -> type(CBRACK) - ; +CODE_CBRACK: ']' -> type(CBRACK); -CODE_OBRACE - : '{' -> type(OBRACE) - ; +CODE_OBRACE: '{' -> type(OBRACE); -CODE_CBRACE - : '}' -> type(CBRACE) - ; +CODE_CBRACE: '}' -> type(CBRACE); -CODE_COMMA - : ',' -> type(COMMA) - ; +CODE_COMMA: ',' -> type(COMMA); // Index mode mode IDX_; -IDX_CBRACK - : ']' -> type(CBRACK), popMode - ; +IDX_CBRACK: ']' -> type(CBRACK), popMode; -IDX_REFERENCE - : '$' ID -> type(REFERENCE) - ; +IDX_REFERENCE: '$' ID -> type(REFERENCE); -IDX_STRING - : STRING -> type(STRING) - ; +IDX_STRING: STRING -> type(STRING); -IDX_INTEGER - : INTEGER -> type(INTEGER) - ; +IDX_INTEGER: INTEGER -> type(INTEGER); -fragment STRING - : STRING_DQ - | STRING_SQ - ; +fragment STRING: STRING_DQ | STRING_SQ; -fragment FLOAT - : DIGIT* '.' DIGIT+ EXPONENT? - | DIGIT+ '.' {this._input.LA(1) != '.'}? EXPONENT? - | DIGIT+ EXPONENT - ; +fragment FLOAT: + DIGIT* '.' DIGIT+ EXPONENT? + | DIGIT+ '.' {this._input.LA(1) != '.'}? EXPONENT? + | DIGIT+ EXPONENT +; fragment SPACES : [ \t\r\n]; fragment ID : [a-zA-Z] [a-zA-Z0-9_-]*; -fragment STRING_DQ : '"' ( ~["\r\n] | '""' )* '"'; -fragment STRING_SQ : '\'' ( ~['\r\n] | '\'\'' )* '\''; +fragment STRING_DQ : '"' ( ~["\r\n] | '""')* '"'; +fragment STRING_SQ : '\'' ( ~['\r\n] | '\'\'')* '\''; fragment INTEGER : DIGIT+; fragment DIGIT : [0-9]; -fragment EXPONENT : [eE] [+-]? DIGIT+; +fragment EXPONENT : [eE] [+-]? DIGIT+; \ No newline at end of file diff --git a/velocity/VTLParser.g4 b/velocity/VTLParser.g4 index d770c6ecd7..80b0f3081c 100644 --- a/velocity/VTLParser.g4 +++ b/velocity/VTLParser.g4 @@ -1,185 +1,188 @@ +// $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 VTLParser; options { - tokenVocab=VTLLexer; + tokenVocab = VTLLexer; } parse - : block EOF - ; + : block EOF + ; block - : atom* - ; + : atom* + ; atom - : TEXT - | ESCAPED_CHAR - | ESCAPED_BLOCK - | variable - | formal - | property_or_method - | directive - ; + : TEXT + | ESCAPED_CHAR + | ESCAPED_BLOCK + | variable + | formal + | property_or_method + | directive + ; formal - : DOLLAR_OBRACE formal_property_or_method CBRACE - | DOLLAR_EXCL_OBRACE formal_property_or_method CBRACE - | DOLLAR_OBRACE id CBRACE - | DOLLAR_EXCL_OBRACE id CBRACE - ; + : DOLLAR_OBRACE formal_property_or_method CBRACE + | DOLLAR_EXCL_OBRACE formal_property_or_method CBRACE + | DOLLAR_OBRACE id CBRACE + | DOLLAR_EXCL_OBRACE id CBRACE + ; variable - : DOLLAR id DOT? - | DOLLAR_EXCL id DOT? - | REFERENCE DOT? - ; + : DOLLAR id DOT? + | DOLLAR_EXCL id DOT? + | REFERENCE DOT? + ; property_or_method - : variable property_end+ - ; + : variable property_end+ + ; formal_property_or_method - : id property_end+ - ; + : id property_end+ + ; directive - : set_directive - | if_directive - | foreach_directive - | break_directive - | stop_directive - | macro_directive - | parse_directive - | define_directive - | include_directive - | evaluate_directive - | macro_call_directive - | custom_directive - ; + : set_directive + | if_directive + | foreach_directive + | break_directive + | stop_directive + | macro_directive + | parse_directive + | define_directive + | include_directive + | evaluate_directive + | macro_call_directive + | custom_directive + ; property_end - : DOT ID - | OBRACK expression CBRACK - | OPAR expressions? CPAR - ; + : DOT ID + | OBRACK expression CBRACK + | OPAR expressions? CPAR + ; expressions - : expression ( COMMA expression )* - ; + : expression (COMMA expression)* + ; set_directive - : SET expression ASSIGN expression CPAR - ; + : SET expression ASSIGN expression CPAR + ; if_directive - : IF expression CPAR block elseif_directive* else_directive? end - ; + : IF expression CPAR block elseif_directive* else_directive? end + ; elseif_directive - : ELSEIF expression CPAR block - ; + : ELSEIF expression CPAR block + ; else_directive - : ELSE block - ; + : ELSE block + ; foreach_directive - : FOREACH variable K_IN expression CPAR block end - ; + : FOREACH variable K_IN expression CPAR block end + ; break_directive - : BREAK - ; + : BREAK + ; stop_directive - : STOP - ; + : STOP + ; custom_directive - : ID ( expression* CPAR )? ( block end )? - ; + : ID (expression* CPAR)? (block end)? + ; macro_directive - : MACRO expression* CPAR block end - ; + : MACRO expression* CPAR block end + ; parse_directive - : PARSE expression CPAR - ; + : PARSE expression CPAR + ; define_directive - : DEFINE expression CPAR block end - ; + : DEFINE expression CPAR block end + ; include_directive - : INCLUDE expressions CPAR - ; + : INCLUDE expressions CPAR + ; evaluate_directive - : EVALUATE expression CPAR - ; + : EVALUATE expression CPAR + ; macro_call_directive - : MACRO_ID expression* CPAR block end - ; + : MACRO_ID expression* CPAR block end + ; end - : END - ; + : END + ; // Operator precedence is as v2.0 defined it: // https://velocity.apache.org/engine/2.0/upgrading.html expression - : ( EXCL | K_NOT ) expression - | SUB expression - | expression ( MUL | DIV | MOD ) expression - | expression ( ADD | SUB ) expression - | expression ( EQ | NE | K_EQ | K_NE ) expression - | expression ( LT | LE | GT | GE | K_LT | K_LE | K_GT | K_GE ) expression - | expression ( AND | K_AND ) expression - | expression ( OR | K_OR ) expression - | expression RANGE expression - | list - | map - | property_or_method - | variable - | id - | STRING - | INTEGER - | FLOAT - | K_NULL - ; + : (EXCL | K_NOT) expression + | SUB expression + | expression ( MUL | DIV | MOD) expression + | expression ( ADD | SUB) expression + | expression ( EQ | NE | K_EQ | K_NE) expression + | expression ( LT | LE | GT | GE | K_LT | K_LE | K_GT | K_GE) expression + | expression ( AND | K_AND) expression + | expression ( OR | K_OR) expression + | expression RANGE expression + | list + | map + | property_or_method + | variable + | id + | STRING + | INTEGER + | FLOAT + | K_NULL + ; list - : OBRACK expressions? CBRACK - ; + : OBRACK expressions? CBRACK + ; map - : OBRACE map_entries? CBRACE - ; + : OBRACE map_entries? CBRACE + ; map_entries - : map_entry ( COMMA map_entry )* - ; + : map_entry (COMMA map_entry)* + ; map_entry - : expression COLON expression - ; + : expression COLON expression + ; id - : ID - | K_LT - | K_LE - | K_GT - | K_GE - | K_EQ - | K_NE - | K_TRUE - | K_FALSE - | K_AND - | K_OR - | K_NOT - | K_NULL - | K_IN - ; + : ID + | K_LT + | K_LE + | K_GT + | K_GE + | K_EQ + | K_NE + | K_TRUE + | K_FALSE + | K_AND + | K_OR + | K_NOT + | K_NULL + | K_IN + ; \ No newline at end of file diff --git a/verilog/systemverilog/SystemVerilogLexer.g4 b/verilog/systemverilog/SystemVerilogLexer.g4 index 60a3eb0ed0..3223e5553b 100755 --- a/verilog/systemverilog/SystemVerilogLexer.g4 +++ b/verilog/systemverilog/SystemVerilogLexer.g4 @@ -22,572 +22,618 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar SystemVerilogLexer; -channels { COMMENTS, DIRECTIVES } - -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' ; -BUFIFONE : 'bufif1' ; -BUFIFZERO : 'bufif0' ; -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' ; -DLERROR : '$error' ; -DLFATAL : '$fatal' ; -DLFULLSKEW : '$fullskew' ; -DLHOLD : '$hold' ; -DLINFO : '$info' ; -DLNOCHANGE : '$nochange' ; -DLPERIOD : '$period' ; -DLRECOVERY : '$recovery' ; -DLRECREM : '$recrem' ; -DLREMOVAL : '$removal' ; -DLROOT : '$root' ; -DLSETUP : '$setup' ; -DLSETUPHOLD : '$setuphold' ; -DLSKEW : '$skew' ; -DLTIMESKEW : '$timeskew' ; -DLUNIT : '$unit' ; -DLWARNING : '$warning' ; -DLWIDTH : '$width' ; -DO : 'do' ; -DQDPIDQ : '"DPI"' ; -DQDPIMICDQ : '"DPI-C"' ; -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' ; -ENDPROPERTY : 'endproperty' ; -ENDSEQUENCE : 'endsequence' ; -ENDSPECIFY : 'endspecify' ; -ENDTABLE : 'endtable' ; -ENDTASK : 'endtask' ; -ENUM : 'enum' ; -EVENT : 'event' ; -EVENTUALLY : 'eventually' ; -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' ; -HIGHZONE : 'highz1' ; -HIGHZZERO : 'highz0' ; -IF : 'if' ; -IFF : 'iff' ; -IFNONE : 'ifnone' ; -IGNORE_BINS : 'ignore_bins' ; -ILLEGAL_BINS : 'illegal_bins' ; -IMPLEMENTS : 'implements' ; -IMPLIES : 'implies' ; -IMPORT : 'import' ; -INCLUDE : 'include' -> pushMode(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' -> pushMode(LIBRARY_MODE) ; -LOCAL : 'local' ; -LOCALPARAM : 'localparam' ; -LOGIC : 'logic' ; -LONGINT : 'longint' ; -MACROMODULE : 'macromodule' ; -MATCHES : 'matches' ; -MEDIUM : 'medium' ; -MIINCDIR : '-incdir' ; -MODPORT : 'modport' ; -MODULE : 'module' ; -NAND : 'nand' ; -NEGEDGE : 'negedge' ; -NETTYPE : 'nettype' ; -NEW : 'new' ; -NEXTTIME : 'nexttime' ; -NMOS : 'nmos' ; -NOR : 'nor' ; -NOSHOWCANCELLED : 'noshowcancelled' ; -NOT : 'not' ; -NOTIFONE : 'notif1' ; -NOTIFZERO : 'notif0' ; -NULL : 'null' ; -ONESTEP : '1step' ; -OPTION : 'option' ; -OR : 'or' ; -OUTPUT : 'output' ; -PACKAGE : 'package' ; -PACKED : 'packed' ; -PARAMETER : 'parameter' ; -PATHPULSEDL : 'PATHPULSE$' ; -PMOS : 'pmos' ; -POSEDGE : 'posedge' ; -PRIMITIVE : 'primitive' ; -PRIORITY : 'priority' ; -PROGRAM : 'program' ; -PROPERTY : 'property' ; -PROTECTED : 'protected' ; -PULLDOWN : 'pulldown' ; -PULLONE : 'pull1' ; -PULLUP : 'pullup' ; -PULLZERO : 'pull0' ; -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' ; -RTRANIFONE : 'rtranif1' ; -RTRANIFZERO : 'rtranif0' ; -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' ; -STRONGONE : 'strong1' ; -STRONGZERO : 'strong0' ; -STRUCT : 'struct' ; -SUPER : 'super' ; -SUPPLYONE : 'supply1' ; -SUPPLYZERO : 'supply0' ; -SYNC_ACCEPT_ON : 'sync_accept_on' ; -SYNC_REJECT_ON : 'sync_reject_on' ; -TABLE : 'table' -> pushMode(TABLE_MODE) ; -TAGGED : 'tagged' ; -TASK : 'task' ; -THIS : 'this' ; -THROUGHOUT : 'throughout' ; -TIME : 'time' ; -TIMEPRECISION : 'timeprecision' ; -TIMEUNIT : 'timeunit' ; -TRAN : 'tran' ; -TRANIFONE : 'tranif1' ; -TRANIFZERO : 'tranif0' ; -TRI : 'tri' ; -TRIAND : 'triand' ; -TRIONE : 'tri1' ; -TRIOR : 'trior' ; -TRIREG : 'trireg' ; -TRIZERO : 'tri0' ; -TYPE : 'type' ; -TYPE_OPTION : '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' ; -WEAKONE : 'weak1' ; -WEAKZERO : 'weak0' ; -WHILE : 'while' ; -WILDCARD : 'wildcard' ; -WIRE : 'wire' ; -WITH : 'with' ; -WITHIN : 'within' ; -WOR : 'wor' ; -XNOR : 'xnor' ; -XOR : 'xor' ; - -AM : '&' ; -AMAM : '&&' ; -AMAMAM : '&&&' ; -AMEQ : '&=' ; -AP : '\'' ; -AS : '*' ; -ASAS : '**' ; -ASEQ : '*=' ; -ASGT : '*>' ; -AT : '@' ; -ATAT : '@@' ; -CA : '^' ; -CAEQ : '^=' ; -CATI : '^~' ; -CL : ':' ; -CLCL : '::' ; -CLEQ : ':=' ; -CLSL : ':/' ; -CO : ',' ; -DL : '$' ; -DQ : '"' ; -DT : '.' ; -DTAS : '.*' ; -EM : '!' ; -EMEQ : '!=' ; -EMEQEQ : '!==' ; -EMEQQM : '!=?' ; -EQ : '=' ; -EQEQ : '==' ; -EQEQEQ : '===' ; -EQEQQM : '==?' ; -EQGT : '=>' ; -GA : '`' -> channel(DIRECTIVES), pushMode(DIRECTIVE_MODE) ; -GT : '>' ; -GTEQ : '>=' ; -GTGT : '>>' ; -GTGTEQ : '>>=' ; -GTGTGT : '>>>' ; -GTGTGTEQ : '>>>=' ; -HA : '#' ; -HAEQHA : '#=#' ; -HAHA : '##' ; -HAMIHA : '#-#' ; -LB : '[' ; -LC : '{' ; -LP : '(' ; -LT : '<' ; -LTEQ : '<=' ; -LTLT : '<<' ; -LTLTEQ : '<<=' ; -LTLTLT : '<<<' ; -LTLTLTEQ : '<<<=' ; -LTMIGT : '<->' ; -MI : '-' ; -MICL : '-:' ; -MIEQ : '-=' ; -MIGT : '->' ; -MIGTGT : '->>' ; -MIMI : '--' ; -MO : '%' ; -MOEQ : '%=' ; -PL : '+' ; -PLCL : '+:' ; -PLEQ : '+=' ; -PLPL : '++' ; -QM : '?' ; -RB : ']' ; -RC : '}' ; -RP : ')' ; -SC : ';' ; -SL : '/' ; -SLEQ : '/=' ; -TI : '~' ; -TIAM : '~&' ; -TICA : '~^' ; -TIVL : '~|' ; -VL : '|' ; -VLEQ : '|=' ; -VLEQGT : '|=>' ; -VLMIGT : '|->' ; -VLVL : '||' ; - -BINARY_BASE : '\'' [sS]? [bB] -> pushMode(BINARY_NUMBER_MODE) ; -BLOCK_COMMENT : '/*' ASCII_ANY*? '*/' -> channel(COMMENTS) ; -DECIMAL_BASE : '\'' [sS]? [dD] -> pushMode(DECIMAL_NUMBER_MODE) ; -ESCAPED_IDENTIFIER : '\\' ASCII_PRINTABLE_NO_SPACE* [ \t\r\n] ; -EXPONENTIAL_NUMBER : UNSIGNED_NUMBER ( '.' UNSIGNED_NUMBER )? [eE] [+\-]? UNSIGNED_NUMBER ; -FIXED_POINT_NUMBER : UNSIGNED_NUMBER '.' UNSIGNED_NUMBER ; -HEX_BASE : '\'' [sS]? [hH] -> pushMode(HEX_NUMBER_MODE) ; -LINE_COMMENT : '//' ASCII_NO_NEWLINE* -> channel(COMMENTS) ; -OCTAL_BASE : '\'' [sS]? [oO] -> pushMode(OCTAL_NUMBER_MODE) ; -SIMPLE_IDENTIFIER : [a-zA-Z_] [a-zA-Z0-9_$]* ; -STRING_LITERAL : '"' ( ASCII_NO_NEWLINE_QUOTE_BACKSLASH | ESC_NEWLINE | ESC_SPECIAL_CHAR )* '"' ; -SYSTEM_TF_IDENTIFIER : '$' [a-zA-Z0-9_$] [a-zA-Z0-9_$]* ; -TIME_LITERAL : UNSIGNED_NUMBER ( '.' UNSIGNED_NUMBER )? TIME_UNIT ; -UNBASED_UNSIZED_LITERAL : '\'0' | '\'1' | '\'' [xXzZ] ; -UNSIGNED_NUMBER : [0-9] [0-9_]* ; -WHITE_SPACE : [ \t\r\n]+ -> channel(HIDDEN) ; -ZERO_OR_ONE_X_OR_Z : [01] [xXzZ] ; +channels { + COMMENTS, + DIRECTIVES +} + +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'; +BUFIFONE : 'bufif1'; +BUFIFZERO : 'bufif0'; +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'; +DLERROR : '$error'; +DLFATAL : '$fatal'; +DLFULLSKEW : '$fullskew'; +DLHOLD : '$hold'; +DLINFO : '$info'; +DLNOCHANGE : '$nochange'; +DLPERIOD : '$period'; +DLRECOVERY : '$recovery'; +DLRECREM : '$recrem'; +DLREMOVAL : '$removal'; +DLROOT : '$root'; +DLSETUP : '$setup'; +DLSETUPHOLD : '$setuphold'; +DLSKEW : '$skew'; +DLTIMESKEW : '$timeskew'; +DLUNIT : '$unit'; +DLWARNING : '$warning'; +DLWIDTH : '$width'; +DO : 'do'; +DQDPIDQ : '"DPI"'; +DQDPIMICDQ : '"DPI-C"'; +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'; +ENDPROPERTY : 'endproperty'; +ENDSEQUENCE : 'endsequence'; +ENDSPECIFY : 'endspecify'; +ENDTABLE : 'endtable'; +ENDTASK : 'endtask'; +ENUM : 'enum'; +EVENT : 'event'; +EVENTUALLY : 'eventually'; +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'; +HIGHZONE : 'highz1'; +HIGHZZERO : 'highz0'; +IF : 'if'; +IFF : 'iff'; +IFNONE : 'ifnone'; +IGNORE_BINS : 'ignore_bins'; +ILLEGAL_BINS : 'illegal_bins'; +IMPLEMENTS : 'implements'; +IMPLIES : 'implies'; +IMPORT : 'import'; +INCLUDE : 'include' -> pushMode(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' -> pushMode(LIBRARY_MODE); +LOCAL : 'local'; +LOCALPARAM : 'localparam'; +LOGIC : 'logic'; +LONGINT : 'longint'; +MACROMODULE : 'macromodule'; +MATCHES : 'matches'; +MEDIUM : 'medium'; +MIINCDIR : '-incdir'; +MODPORT : 'modport'; +MODULE : 'module'; +NAND : 'nand'; +NEGEDGE : 'negedge'; +NETTYPE : 'nettype'; +NEW : 'new'; +NEXTTIME : 'nexttime'; +NMOS : 'nmos'; +NOR : 'nor'; +NOSHOWCANCELLED : 'noshowcancelled'; +NOT : 'not'; +NOTIFONE : 'notif1'; +NOTIFZERO : 'notif0'; +NULL : 'null'; +ONESTEP : '1step'; +OPTION : 'option'; +OR : 'or'; +OUTPUT : 'output'; +PACKAGE : 'package'; +PACKED : 'packed'; +PARAMETER : 'parameter'; +PATHPULSEDL : 'PATHPULSE$'; +PMOS : 'pmos'; +POSEDGE : 'posedge'; +PRIMITIVE : 'primitive'; +PRIORITY : 'priority'; +PROGRAM : 'program'; +PROPERTY : 'property'; +PROTECTED : 'protected'; +PULLDOWN : 'pulldown'; +PULLONE : 'pull1'; +PULLUP : 'pullup'; +PULLZERO : 'pull0'; +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'; +RTRANIFONE : 'rtranif1'; +RTRANIFZERO : 'rtranif0'; +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'; +STRONGONE : 'strong1'; +STRONGZERO : 'strong0'; +STRUCT : 'struct'; +SUPER : 'super'; +SUPPLYONE : 'supply1'; +SUPPLYZERO : 'supply0'; +SYNC_ACCEPT_ON : 'sync_accept_on'; +SYNC_REJECT_ON : 'sync_reject_on'; +TABLE : 'table' -> pushMode(TABLE_MODE); +TAGGED : 'tagged'; +TASK : 'task'; +THIS : 'this'; +THROUGHOUT : 'throughout'; +TIME : 'time'; +TIMEPRECISION : 'timeprecision'; +TIMEUNIT : 'timeunit'; +TRAN : 'tran'; +TRANIFONE : 'tranif1'; +TRANIFZERO : 'tranif0'; +TRI : 'tri'; +TRIAND : 'triand'; +TRIONE : 'tri1'; +TRIOR : 'trior'; +TRIREG : 'trireg'; +TRIZERO : 'tri0'; +TYPE : 'type'; +TYPE_OPTION : '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'; +WEAKONE : 'weak1'; +WEAKZERO : 'weak0'; +WHILE : 'while'; +WILDCARD : 'wildcard'; +WIRE : 'wire'; +WITH : 'with'; +WITHIN : 'within'; +WOR : 'wor'; +XNOR : 'xnor'; +XOR : 'xor'; + +AM : '&'; +AMAM : '&&'; +AMAMAM : '&&&'; +AMEQ : '&='; +AP : '\''; +AS : '*'; +ASAS : '**'; +ASEQ : '*='; +ASGT : '*>'; +AT : '@'; +ATAT : '@@'; +CA : '^'; +CAEQ : '^='; +CATI : '^~'; +CL : ':'; +CLCL : '::'; +CLEQ : ':='; +CLSL : ':/'; +CO : ','; +DL : '$'; +DQ : '"'; +DT : '.'; +DTAS : '.*'; +EM : '!'; +EMEQ : '!='; +EMEQEQ : '!=='; +EMEQQM : '!=?'; +EQ : '='; +EQEQ : '=='; +EQEQEQ : '==='; +EQEQQM : '==?'; +EQGT : '=>'; +GA : '`' -> channel(DIRECTIVES), pushMode(DIRECTIVE_MODE); +GT : '>'; +GTEQ : '>='; +GTGT : '>>'; +GTGTEQ : '>>='; +GTGTGT : '>>>'; +GTGTGTEQ : '>>>='; +HA : '#'; +HAEQHA : '#=#'; +HAHA : '##'; +HAMIHA : '#-#'; +LB : '['; +LC : '{'; +LP : '('; +LT : '<'; +LTEQ : '<='; +LTLT : '<<'; +LTLTEQ : '<<='; +LTLTLT : '<<<'; +LTLTLTEQ : '<<<='; +LTMIGT : '<->'; +MI : '-'; +MICL : '-:'; +MIEQ : '-='; +MIGT : '->'; +MIGTGT : '->>'; +MIMI : '--'; +MO : '%'; +MOEQ : '%='; +PL : '+'; +PLCL : '+:'; +PLEQ : '+='; +PLPL : '++'; +QM : '?'; +RB : ']'; +RC : '}'; +RP : ')'; +SC : ';'; +SL : '/'; +SLEQ : '/='; +TI : '~'; +TIAM : '~&'; +TICA : '~^'; +TIVL : '~|'; +VL : '|'; +VLEQ : '|='; +VLEQGT : '|=>'; +VLMIGT : '|->'; +VLVL : '||'; + +BINARY_BASE : '\'' [sS]? [bB] -> pushMode(BINARY_NUMBER_MODE); +BLOCK_COMMENT : '/*' ASCII_ANY*? '*/' -> channel(COMMENTS); +DECIMAL_BASE : '\'' [sS]? [dD] -> pushMode(DECIMAL_NUMBER_MODE); +ESCAPED_IDENTIFIER : '\\' ASCII_PRINTABLE_NO_SPACE* [ \t\r\n]; +EXPONENTIAL_NUMBER : UNSIGNED_NUMBER ( '.' UNSIGNED_NUMBER)? [eE] [+\-]? UNSIGNED_NUMBER; +FIXED_POINT_NUMBER : UNSIGNED_NUMBER '.' UNSIGNED_NUMBER; +HEX_BASE : '\'' [sS]? [hH] -> pushMode(HEX_NUMBER_MODE); +LINE_COMMENT : '//' ASCII_NO_NEWLINE* -> channel(COMMENTS); +OCTAL_BASE : '\'' [sS]? [oO] -> pushMode(OCTAL_NUMBER_MODE); +SIMPLE_IDENTIFIER : [a-zA-Z_] [a-zA-Z0-9_$]*; +STRING_LITERAL : '"' ( ASCII_NO_NEWLINE_QUOTE_BACKSLASH | ESC_NEWLINE | ESC_SPECIAL_CHAR)* '"'; +SYSTEM_TF_IDENTIFIER : '$' [a-zA-Z0-9_$] [a-zA-Z0-9_$]*; +TIME_LITERAL : UNSIGNED_NUMBER ( '.' UNSIGNED_NUMBER)? TIME_UNIT; +UNBASED_UNSIZED_LITERAL : '\'0' | '\'1' | '\'' [xXzZ]; +UNSIGNED_NUMBER : [0-9] [0-9_]*; +WHITE_SPACE : [ \t\r\n]+ -> channel(HIDDEN); +ZERO_OR_ONE_X_OR_Z : [01] [xXzZ]; mode BINARY_NUMBER_MODE; -BINARY_VALUE : [01xXzZ?] [01xXzZ?_]* -> popMode ; -WHITE_SPACE_0 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +BINARY_VALUE : [01xXzZ?] [01xXzZ?_]* -> popMode; +WHITE_SPACE_0 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode DECIMAL_NUMBER_MODE; -UNSIGNED_NUMBER_0 : UNSIGNED_NUMBER -> type(UNSIGNED_NUMBER), popMode ; -WHITE_SPACE_1 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; -X_OR_Z_UNDERSCORE : [xXzZ?] '_'* -> popMode ; +UNSIGNED_NUMBER_0 : UNSIGNED_NUMBER -> type(UNSIGNED_NUMBER), popMode; +WHITE_SPACE_1 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); +X_OR_Z_UNDERSCORE : [xXzZ?] '_'* -> popMode; mode HEX_NUMBER_MODE; -HEX_VALUE : [0-9a-fA-FxXzZ?] [0-9a-fA-FxXzZ?_]* -> popMode ; -WHITE_SPACE_2 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +HEX_VALUE : [0-9a-fA-FxXzZ?] [0-9a-fA-FxXzZ?_]* -> popMode; +WHITE_SPACE_2 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode LIBRARY_MODE; -BLOCK_COMMENT_0 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -CO_0 : CO -> type(CO) ; -ESCAPED_IDENTIFIER_0 : ESCAPED_IDENTIFIER -> type(ESCAPED_IDENTIFIER) ; -GA_0 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; -LINE_COMMENT_0 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT) ; -MIINCDIR_0 : MIINCDIR -> type(MIINCDIR) ; -SC_0 : SC -> type(SC), popMode ; -SIMPLE_IDENTIFIER_0 : SIMPLE_IDENTIFIER -> type(SIMPLE_IDENTIFIER) ; -WHITE_SPACE_3 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; -FILE_PATH_SPEC : ( [a-zA-Z0-9_./] | ESC_ASCII_PRINTABLE )+ | STRING_LITERAL ; +BLOCK_COMMENT_0 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +CO_0 : CO -> type(CO); +ESCAPED_IDENTIFIER_0 : ESCAPED_IDENTIFIER -> type(ESCAPED_IDENTIFIER); +GA_0 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE); +LINE_COMMENT_0 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT); +MIINCDIR_0 : MIINCDIR -> type(MIINCDIR); +SC_0 : SC -> type(SC), popMode; +SIMPLE_IDENTIFIER_0 : SIMPLE_IDENTIFIER -> type(SIMPLE_IDENTIFIER); +WHITE_SPACE_3 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); +FILE_PATH_SPEC : ( [a-zA-Z0-9_./] | ESC_ASCII_PRINTABLE)+ | STRING_LITERAL; mode OCTAL_NUMBER_MODE; -OCTAL_VALUE : [0-7xXzZ?] [0-7xXzZ?_]* -> popMode ; -WHITE_SPACE_4 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +OCTAL_VALUE : [0-7xXzZ?] [0-7xXzZ?_]* -> popMode; +WHITE_SPACE_4 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode TABLE_MODE; -BLOCK_COMMENT_1 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -CL_0 : CL -> type(CL) ; -EDGE_SYMBOL : [rRfFpPnN*] ; -ENDTABLE_0 : ENDTABLE -> type(ENDTABLE), popMode ; -GA_1 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; -LEVEL_ONLY_SYMBOL : [?bB] ; -LINE_COMMENT_1 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT) ; -LP_0 : LP -> type(LP) ; -MI_0 : MI -> type(MI) ; -OUTPUT_OR_LEVEL_SYMBOL : [01xX] ; -RP_0 : RP -> type(RP) ; -SC_1 : SC -> type(SC) ; -WHITE_SPACE_5 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +BLOCK_COMMENT_1 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +CL_0 : CL -> type(CL); +EDGE_SYMBOL : [rRfFpPnN*]; +ENDTABLE_0 : ENDTABLE -> type(ENDTABLE), popMode; +GA_1 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE); +LEVEL_ONLY_SYMBOL : [?bB]; +LINE_COMMENT_1 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT); +LP_0 : LP -> type(LP); +MI_0 : MI -> type(MI); +OUTPUT_OR_LEVEL_SYMBOL : [01xX]; +RP_0 : RP -> type(RP); +SC_1 : SC -> type(SC); +WHITE_SPACE_5 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode DIRECTIVE_MODE; -BEGIN_KEYWORDS_DIRECTIVE : 'begin_keywords' -> channel(DIRECTIVES), mode(BEGIN_KEYWORDS_DIRECTIVE_MODE) ; -CELLDEFINE_DIRECTIVE : 'celldefine' -> channel(DIRECTIVES), popMode ; -DEFAULT_NETTYPE_DIRECTIVE : 'default_nettype' -> channel(DIRECTIVES), mode(DEFAULT_NETTYPE_DIRECTIVE_MODE) ; -DEFINE_DIRECTIVE : 'define' -> channel(DIRECTIVES), mode(DEFINE_DIRECTIVE_MODE) ; -ELSE_DIRECTIVE : 'else' -> channel(DIRECTIVES), popMode, mode(ELSE_DIRECTIVE_MODE) ; -ELSIF_DIRECTIVE : 'elsif' -> channel(DIRECTIVES), popMode, mode(ELSIF_DIRECTIVE_MODE) ; -END_KEYWORDS_DIRECTIVE : 'end_keywords' -> channel(DIRECTIVES), popMode ; -ENDCELLDEFINE_DIRECTIVE : 'endcelldefine' -> channel(DIRECTIVES), popMode ; -ENDIF_DIRECTIVE : 'endif' -> channel(DIRECTIVES), popMode, popMode, popMode ; -FILE_DIRECTIVE : '__FILE__' -> channel(DIRECTIVES), 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(INCLUDE_DIRECTIVE_MODE) ; -LINE_DIRECTIVE : 'line' -> channel(DIRECTIVES), mode(LINE_DIRECTIVE_MODE) ; -LINE_DIRECTIVE_ : '__LINE__' -> channel(DIRECTIVES), popMode ; -NOUNCONNECTED_DRIVE_DIRECTIVE : 'nounconnected_drive' -> channel(DIRECTIVES), popMode ; -PRAGMA_DIRECTIVE : 'pragma' -> channel(DIRECTIVES), mode(PRAGMA_DIRECTIVE_MODE) ; -RESETALL_DIRECTIVE : 'resetall' -> channel(DIRECTIVES), popMode ; -TIMESCALE_DIRECTIVE : 'timescale' -> channel(DIRECTIVES), mode(TIMESCALE_DIRECTIVE_MODE) ; -UNCONNECTED_DRIVE_DIRECTIVE : 'unconnected_drive' -> channel(DIRECTIVES), mode(UNCONNECTED_DRIVE_DIRECTIVE_MODE) ; -UNDEF_DIRECTIVE : 'undef' -> channel(DIRECTIVES), mode(UNDEF_DIRECTIVE_MODE) ; -UNDEFINEALL_DIRECTIVE : 'undefineall' -> channel(DIRECTIVES), popMode ; -MACRO_USAGE : IDENTIFIER ( WHITE_SPACE? MACRO_ARGS )? -> channel(DIRECTIVES), popMode ; +BEGIN_KEYWORDS_DIRECTIVE: + 'begin_keywords' -> channel(DIRECTIVES), mode(BEGIN_KEYWORDS_DIRECTIVE_MODE) +; +CELLDEFINE_DIRECTIVE: 'celldefine' -> channel(DIRECTIVES), popMode; +DEFAULT_NETTYPE_DIRECTIVE: + 'default_nettype' -> channel(DIRECTIVES), mode(DEFAULT_NETTYPE_DIRECTIVE_MODE) +; +DEFINE_DIRECTIVE : 'define' -> channel(DIRECTIVES), mode(DEFINE_DIRECTIVE_MODE); +ELSE_DIRECTIVE : 'else' -> channel(DIRECTIVES), popMode, mode(ELSE_DIRECTIVE_MODE); +ELSIF_DIRECTIVE : 'elsif' -> channel(DIRECTIVES), popMode, mode(ELSIF_DIRECTIVE_MODE); +END_KEYWORDS_DIRECTIVE : 'end_keywords' -> channel(DIRECTIVES), popMode; +ENDCELLDEFINE_DIRECTIVE : 'endcelldefine' -> channel(DIRECTIVES), popMode; +ENDIF_DIRECTIVE : 'endif' -> channel(DIRECTIVES), popMode, popMode, popMode; +FILE_DIRECTIVE : '__FILE__' -> channel(DIRECTIVES), 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(INCLUDE_DIRECTIVE_MODE); +LINE_DIRECTIVE : 'line' -> channel(DIRECTIVES), mode(LINE_DIRECTIVE_MODE); +LINE_DIRECTIVE_ : '__LINE__' -> channel(DIRECTIVES), popMode; +NOUNCONNECTED_DRIVE_DIRECTIVE : 'nounconnected_drive' -> channel(DIRECTIVES), popMode; +PRAGMA_DIRECTIVE : 'pragma' -> channel(DIRECTIVES), mode(PRAGMA_DIRECTIVE_MODE); +RESETALL_DIRECTIVE : 'resetall' -> channel(DIRECTIVES), popMode; +TIMESCALE_DIRECTIVE : 'timescale' -> channel(DIRECTIVES), mode(TIMESCALE_DIRECTIVE_MODE); +UNCONNECTED_DRIVE_DIRECTIVE: + 'unconnected_drive' -> channel(DIRECTIVES), mode(UNCONNECTED_DRIVE_DIRECTIVE_MODE) +; +UNDEF_DIRECTIVE : 'undef' -> channel(DIRECTIVES), mode(UNDEF_DIRECTIVE_MODE); +UNDEFINEALL_DIRECTIVE : 'undefineall' -> channel(DIRECTIVES), popMode; +MACRO_USAGE : IDENTIFIER ( WHITE_SPACE? MACRO_ARGS)? -> channel(DIRECTIVES), popMode; mode BEGIN_KEYWORDS_DIRECTIVE_MODE; -BLOCK_COMMENT_2 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -DQ_0 : DQ -> channel(DIRECTIVES), type(DQ) ; -NEWLINE_0 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_0 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -VERSION_SPECIFIER : ( '1800-2017' | '1800-2012' | '1800-2009' | '1800-2005' | '1364-2005' | '1364-2001' | '1364-2001-noconfig' | '1364-1995' ) -> channel(DIRECTIVES) ; +BLOCK_COMMENT_2 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +DQ_0 : DQ -> channel(DIRECTIVES), type(DQ); +NEWLINE_0 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_0 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +VERSION_SPECIFIER: + ( + '1800-2017' + | '1800-2012' + | '1800-2009' + | '1800-2005' + | '1364-2005' + | '1364-2001' + | '1364-2001-noconfig' + | '1364-1995' + ) -> channel(DIRECTIVES) +; mode DEFAULT_NETTYPE_DIRECTIVE_MODE; -BLOCK_COMMENT_3 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -DEFAULT_NETTYPE_VALUE : ( 'wire' | 'tri' | 'tri0' | 'tri1' | 'wand' | 'triand' | 'wor' | 'trior' | 'trireg' | 'uwire' | 'none' ) -> channel(DIRECTIVES), popMode ; -NEWLINE_1 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_1 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +BLOCK_COMMENT_3: BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +DEFAULT_NETTYPE_VALUE: + ( + 'wire' + | 'tri' + | 'tri0' + | 'tri1' + | 'wand' + | 'triand' + | 'wor' + | 'trior' + | 'trireg' + | 'uwire' + | 'none' + ) -> channel(DIRECTIVES), popMode +; +NEWLINE_1 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_1 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode DEFINE_DIRECTIVE_MODE; -MACRO_NAME : IDENTIFIER MACRO_ARGS? -> channel(DIRECTIVES), mode(MACRO_TEXT_MODE) ; -NEWLINE_12 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_11 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +MACRO_NAME : IDENTIFIER MACRO_ARGS? -> channel(DIRECTIVES), mode(MACRO_TEXT_MODE); +NEWLINE_12 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_11 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode ELSE_DIRECTIVE_MODE; -NEWLINE_8 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE) ; -SPACE_TAB_7 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +NEWLINE_8 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE); +SPACE_TAB_7 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode ELSIF_DIRECTIVE_MODE; -IDENTIFIER_0 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER) ; -NEWLINE_9 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE) ; -SPACE_TAB_8 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +IDENTIFIER_0 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER); +NEWLINE_9 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE); +SPACE_TAB_8 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode FILENAME_MODE; -DQ_1 : DQ -> channel(DIRECTIVES), type(DQ), popMode ; -FILENAME : ( ASCII_PRINTABLE_NO_QUOTE_ANGLE_BRACKETS_BACKSLASH | ESC_ASCII_PRINTABLE )+ -> channel(DIRECTIVES) ; -GT_0 : GT -> channel(DIRECTIVES), type(GT), popMode ; +DQ_1: DQ -> channel(DIRECTIVES), type(DQ), popMode; +FILENAME: + (ASCII_PRINTABLE_NO_QUOTE_ANGLE_BRACKETS_BACKSLASH | ESC_ASCII_PRINTABLE)+ -> channel(DIRECTIVES) +; +GT_0: GT -> channel(DIRECTIVES), type(GT), popMode; mode IFDEF_DIRECTIVE_MODE; -IDENTIFIER_1 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER) ; -NEWLINE_10 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), pushMode(SOURCE_TEXT_MODE) ; -SPACE_TAB_9 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +IDENTIFIER_1 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER); +NEWLINE_10 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), pushMode(SOURCE_TEXT_MODE); +SPACE_TAB_9 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode INCLUDE_DIRECTIVE_MODE; -DQ_2 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE) ; -GA_2 : GA -> channel(DIRECTIVES), type(GA) ; -LT_0 : LT -> channel(DIRECTIVES), type(LT), pushMode(FILENAME_MODE) ; -MACRO_USAGE_0 : MACRO_USAGE -> channel(DIRECTIVES), type(MACRO_USAGE), popMode ; -NEWLINE_2 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_2 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +DQ_2 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE); +GA_2 : GA -> channel(DIRECTIVES), type(GA); +LT_0 : LT -> channel(DIRECTIVES), type(LT), pushMode(FILENAME_MODE); +MACRO_USAGE_0 : MACRO_USAGE -> channel(DIRECTIVES), type(MACRO_USAGE), popMode; +NEWLINE_2 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_2 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode LINE_DIRECTIVE_MODE; -DQ_3 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE) ; -NEWLINE_3 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_3 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -UNSIGNED_NUMBER_1 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER) ; +DQ_3 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE); +NEWLINE_3 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_3 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +UNSIGNED_NUMBER_1 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER); mode MACRO_TEXT_MODE; -BLOCK_COMMENT_5 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -GA_3 : GA -> channel(DIRECTIVES), type(MACRO_TEXT) ; -MACRO_DELIMITER : '``' -> channel(DIRECTIVES) ; -MACRO_ESC_NEWLINE : ESC_NEWLINE -> channel(DIRECTIVES) ; -MACRO_ESC_QUOTE : '`\\`"' -> channel(DIRECTIVES) ; -MACRO_ESC_SEQ : ESC_ASCII_NO_NEWLINE -> channel(DIRECTIVES), type(MACRO_TEXT) ; -MACRO_QUOTE : '`"' -> channel(DIRECTIVES) ; -MACRO_TEXT : ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES) ; -NEWLINE_4 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SL_2 : SL -> more ; -STRING_LITERAL_0 : STRING_LITERAL -> channel(DIRECTIVES), type(STRING_LITERAL) ; +BLOCK_COMMENT_5 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +GA_3 : GA -> channel(DIRECTIVES), type(MACRO_TEXT); +MACRO_DELIMITER : '``' -> channel(DIRECTIVES); +MACRO_ESC_NEWLINE : ESC_NEWLINE -> channel(DIRECTIVES); +MACRO_ESC_QUOTE : '`\\`"' -> channel(DIRECTIVES); +MACRO_ESC_SEQ : ESC_ASCII_NO_NEWLINE -> channel(DIRECTIVES), type(MACRO_TEXT); +MACRO_QUOTE : '`"' -> channel(DIRECTIVES); +MACRO_TEXT : ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES); +NEWLINE_4 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SL_2 : SL -> more; +STRING_LITERAL_0 : STRING_LITERAL -> channel(DIRECTIVES), type(STRING_LITERAL); mode PRAGMA_DIRECTIVE_MODE; -BLOCK_COMMENT_6 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -CO_1 : CO -> channel(DIRECTIVES), type(CO) ; -EQ_0 : EQ -> channel(DIRECTIVES), type(EQ) ; -LP_1 : LP -> channel(DIRECTIVES), type(LP) ; -NEWLINE_5 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -RP_1 : RP -> channel(DIRECTIVES), type(RP) ; -SIMPLE_IDENTIFIER_1 : SIMPLE_IDENTIFIER -> channel(DIRECTIVES), type(SIMPLE_IDENTIFIER) ; -SPACE_TAB_4 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -STRING_LITERAL_1 : STRING_LITERAL -> channel(DIRECTIVES), type(STRING_LITERAL) ; -UNSIGNED_NUMBER_2 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER) ; +BLOCK_COMMENT_6 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +CO_1 : CO -> channel(DIRECTIVES), type(CO); +EQ_0 : EQ -> channel(DIRECTIVES), type(EQ); +LP_1 : LP -> channel(DIRECTIVES), type(LP); +NEWLINE_5 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +RP_1 : RP -> channel(DIRECTIVES), type(RP); +SIMPLE_IDENTIFIER_1 : SIMPLE_IDENTIFIER -> channel(DIRECTIVES), type(SIMPLE_IDENTIFIER); +SPACE_TAB_4 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +STRING_LITERAL_1 : STRING_LITERAL -> channel(DIRECTIVES), type(STRING_LITERAL); +UNSIGNED_NUMBER_2 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER); mode SOURCE_TEXT_MODE; -BLOCK_COMMENT_7 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -GA_4 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; -LINE_COMMENT_2 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT) ; -SL_0 : SL -> more ; -SOURCE_TEXT : ASCII_NO_SLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES) ; +BLOCK_COMMENT_7 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +GA_4 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE); +LINE_COMMENT_2 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT); +SL_0 : SL -> more; +SOURCE_TEXT : ASCII_NO_SLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES); mode TIMESCALE_DIRECTIVE_MODE; -BLOCK_COMMENT_8 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -NEWLINE_6 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SL_1 : SL -> channel(DIRECTIVES), type(SL) ; -SPACE_TAB_5 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -TIME_UNIT : [munpf]? 's' -> channel(DIRECTIVES) ; -TIME_VALUE : ( '1' | '10' | '100' ) -> channel(DIRECTIVES) ; +BLOCK_COMMENT_8 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +NEWLINE_6 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SL_1 : SL -> channel(DIRECTIVES), type(SL); +SPACE_TAB_5 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +TIME_UNIT : [munpf]? 's' -> channel(DIRECTIVES); +TIME_VALUE : ( '1' | '10' | '100') -> channel(DIRECTIVES); mode UNCONNECTED_DRIVE_DIRECTIVE_MODE; -BLOCK_COMMENT_9 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -NEWLINE_7 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_6 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -UNCONNECTED_DRIVE_VALUE : ( 'pull0' | 'pull1' ) -> channel(DIRECTIVES), popMode ; +BLOCK_COMMENT_9 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +NEWLINE_7 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_6 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +UNCONNECTED_DRIVE_VALUE : ( 'pull0' | 'pull1') -> channel(DIRECTIVES), popMode; mode UNDEF_DIRECTIVE_MODE; -MACRO_IDENTIFIER : IDENTIFIER -> channel(DIRECTIVES) ; -NEWLINE_11 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_10 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; - -fragment ASCII_ANY : [\u0000-\u007f] ; -fragment ASCII_NO_NEWLINE : [\u0000-\u0009\u000b-\u000c\u000e-\u007f] ; -fragment ASCII_NO_NEWLINE_QUOTE_BACKSLASH : [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u005b\u005d-\u007f] ; -fragment ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT : [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u002e\u0030-\u005b\u005d-\u005f\u0061-\u007f] ; -fragment ASCII_NO_PARENTHESES : [\u0000-\u0027\u002a-\u007f] ; -fragment ASCII_NO_SLASH_GRAVE_ACCENT : [\u0000-\u002e\u0030-\u005f\u0061-\u007f] ; -fragment ASCII_PRINTABLE : [\u0020-\u007e] ; -fragment ASCII_PRINTABLE_NO_QUOTE_ANGLE_BRACKETS_BACKSLASH : [\u0020-\u0021\u0023-\u003b\u003d\u003f-\u005b\u005d-\u007e] ; -fragment ASCII_PRINTABLE_NO_SPACE : [\u0021-\u007e] ; -fragment CHAR_HEX : [0-9a-fA-F] [0-9a-fA-F]? ; -fragment CHAR_OCTAL : [0-7] [0-7]? [0-7]? ; -fragment ESC_ASCII_NO_NEWLINE : '\\' ASCII_NO_NEWLINE ; -fragment ESC_ASCII_PRINTABLE : '\\' ASCII_PRINTABLE ; -fragment ESC_NEWLINE : '\\' NEWLINE ; -fragment ESC_SPECIAL_CHAR : '\\' ( [nt\\"vfa] | CHAR_HEX | CHAR_OCTAL ) ; -fragment IDENTIFIER : ESCAPED_IDENTIFIER | SIMPLE_IDENTIFIER ; -fragment MACRO_ARGS : '(' ( MACRO_ARGS | ASCII_NO_PARENTHESES )* ')' ; -fragment NEWLINE : '\r'? '\n' ; -fragment SPACE_TAB : [ \t]+ ; +MACRO_IDENTIFIER : IDENTIFIER -> channel(DIRECTIVES); +NEWLINE_11 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_10 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); + +fragment ASCII_ANY : [\u0000-\u007f]; +fragment ASCII_NO_NEWLINE : [\u0000-\u0009\u000b-\u000c\u000e-\u007f]; +fragment ASCII_NO_NEWLINE_QUOTE_BACKSLASH: + [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u005b\u005d-\u007f] +; +fragment ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT: + [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u002e\u0030-\u005b\u005d-\u005f\u0061-\u007f] +; +fragment ASCII_NO_PARENTHESES : [\u0000-\u0027\u002a-\u007f]; +fragment ASCII_NO_SLASH_GRAVE_ACCENT : [\u0000-\u002e\u0030-\u005f\u0061-\u007f]; +fragment ASCII_PRINTABLE : [\u0020-\u007e]; +fragment ASCII_PRINTABLE_NO_QUOTE_ANGLE_BRACKETS_BACKSLASH: + [\u0020-\u0021\u0023-\u003b\u003d\u003f-\u005b\u005d-\u007e] +; +fragment ASCII_PRINTABLE_NO_SPACE : [\u0021-\u007e]; +fragment CHAR_HEX : [0-9a-fA-F] [0-9a-fA-F]?; +fragment CHAR_OCTAL : [0-7] [0-7]? [0-7]?; +fragment ESC_ASCII_NO_NEWLINE : '\\' ASCII_NO_NEWLINE; +fragment ESC_ASCII_PRINTABLE : '\\' ASCII_PRINTABLE; +fragment ESC_NEWLINE : '\\' NEWLINE; +fragment ESC_SPECIAL_CHAR : '\\' ( [nt\\"vfa] | CHAR_HEX | CHAR_OCTAL); +fragment IDENTIFIER : ESCAPED_IDENTIFIER | SIMPLE_IDENTIFIER; +fragment MACRO_ARGS : '(' ( MACRO_ARGS | ASCII_NO_PARENTHESES)* ')'; +fragment NEWLINE : '\r'? '\n'; +fragment SPACE_TAB : [ \t]+; \ No newline at end of file diff --git a/verilog/systemverilog/SystemVerilogParser.g4 b/verilog/systemverilog/SystemVerilogParser.g4 index c1946665c2..9e469e4ace 100644 --- a/verilog/systemverilog/SystemVerilogParser.g4 +++ b/verilog/systemverilog/SystemVerilogParser.g4 @@ -22,3126 +22,3935 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 SystemVerilogParser; -options { tokenVocab = SystemVerilogLexer; } + +options { + tokenVocab = SystemVerilogLexer; +} // A.1.1 Library source text library_text - : library_description* EOF - ; + : library_description* EOF + ; + library_description - : library_declaration - | include_statement - | config_declaration - | ';' - ; + : library_declaration + | include_statement + | config_declaration + | ';' + ; + library_declaration - : 'library' library_identifier file_path_spec ( ',' file_path_spec )* library_incdir? ';' - ; + : 'library' library_identifier file_path_spec (',' file_path_spec)* library_incdir? ';' + ; + library_incdir - : '-incdir' file_path_spec ( ',' file_path_spec )* - ; + : '-incdir' file_path_spec (',' file_path_spec)* + ; + include_statement - : 'include' file_path_spec ';' - ; + : 'include' file_path_spec ';' + ; + file_path_spec - : FILE_PATH_SPEC - ; + : FILE_PATH_SPEC + ; + // A.1.2 SystemVerilog source text source_text - : timeunits_declaration? description* EOF - ; + : timeunits_declaration? description* EOF + ; + description - : module_declaration - | udp_declaration - | interface_declaration - | program_declaration - | package_declaration - | attribute_instance* package_item - | attribute_instance* bind_directive - | config_declaration - ; + : module_declaration + | udp_declaration + | interface_declaration + | program_declaration + | package_declaration + | attribute_instance* package_item + | attribute_instance* bind_directive + | config_declaration + ; + module_header - : attribute_instance* module_keyword lifetime? module_identifier package_import_declaration* parameter_port_list? list_of_port_declarations? ';' - ; + : attribute_instance* module_keyword lifetime? module_identifier package_import_declaration* parameter_port_list? list_of_port_declarations? ';' + ; + module_declaration - : module_header timeunits_declaration? module_item* 'endmodule' module_name? - | attribute_instance* module_keyword lifetime? module_identifier '(' '.*' ')' ';' timeunits_declaration? module_item* 'endmodule' module_name? - | 'extern' module_header - ; + : module_header timeunits_declaration? module_item* 'endmodule' module_name? + | attribute_instance* module_keyword lifetime? module_identifier '(' '.*' ')' ';' timeunits_declaration? module_item* 'endmodule' module_name? + | 'extern' module_header + ; + module_name - : ':' module_identifier - ; + : ':' module_identifier + ; + module_keyword - : 'module' - | 'macromodule' - ; + : 'module' + | 'macromodule' + ; + interface_declaration - : interface_header timeunits_declaration? interface_item* 'endinterface' interface_name? - | attribute_instance* 'interface' interface_identifier '(' '.*' ')' ';' timeunits_declaration? interface_item* 'endinterface' interface_name? - | 'extern' interface_header - ; + : interface_header timeunits_declaration? interface_item* 'endinterface' interface_name? + | attribute_instance* 'interface' interface_identifier '(' '.*' ')' ';' timeunits_declaration? interface_item* 'endinterface' interface_name? + | 'extern' interface_header + ; + interface_name - : ':' interface_identifier - ; + : ':' interface_identifier + ; + interface_header - : attribute_instance* 'interface' lifetime? interface_identifier package_import_declaration* parameter_port_list? list_of_port_declarations? ';' - ; + : attribute_instance* 'interface' lifetime? interface_identifier package_import_declaration* parameter_port_list? list_of_port_declarations? ';' + ; + program_declaration - : program_header timeunits_declaration? program_item* 'endprogram' program_name? - | attribute_instance* 'program' program_identifier '(' '.*' ')' ';' timeunits_declaration? program_item* 'endprogram' program_name? - | 'extern' program_header - ; + : program_header timeunits_declaration? program_item* 'endprogram' program_name? + | attribute_instance* 'program' program_identifier '(' '.*' ')' ';' timeunits_declaration? program_item* 'endprogram' program_name? + | 'extern' program_header + ; + program_name - : ':' program_identifier - ; + : ':' program_identifier + ; + program_header - : attribute_instance* 'program' lifetime? program_identifier package_import_declaration* parameter_port_list? list_of_port_declarations? ';' - ; + : attribute_instance* 'program' lifetime? program_identifier package_import_declaration* parameter_port_list? list_of_port_declarations? ';' + ; + checker_declaration - : 'checker' checker_identifier checker_ports? ';' checker_decl_item* 'endchecker' checker_name? - ; + : 'checker' checker_identifier checker_ports? ';' checker_decl_item* 'endchecker' checker_name? + ; + checker_name - : ':' checker_identifier - ; + : ':' checker_identifier + ; + checker_ports - : '(' checker_port_list? ')' - ; + : '(' checker_port_list? ')' + ; + checker_decl_item - : attribute_instance* checker_item - ; + : attribute_instance* checker_item + ; + class_declaration - : 'virtual'? 'class' lifetime? class_identifier parameter_port_list? class_extension? class_implementation? ';' class_item* 'endclass' class_name? - ; + : 'virtual'? 'class' lifetime? class_identifier parameter_port_list? class_extension? class_implementation? ';' class_item* 'endclass' class_name? + ; + class_name - : ':' class_identifier - ; + : ':' class_identifier + ; + class_extension - : 'extends' class_type arg_list? - ; + : 'extends' class_type arg_list? + ; + class_implementation - : 'implements' interface_class_type ( ',' interface_class_type )* - ; + : 'implements' interface_class_type (',' interface_class_type)* + ; + interface_class_type - : ps_identifier parameter_value_assignment? - ; + : ps_identifier parameter_value_assignment? + ; + interface_class_declaration - : 'interface' 'class' class_identifier parameter_port_list? interface_class_extension? ';' interface_class_item* 'endclass' class_name? - ; + : 'interface' 'class' class_identifier parameter_port_list? interface_class_extension? ';' interface_class_item* 'endclass' class_name? + ; + interface_class_extension - : 'extends' interface_class_type ( ',' interface_class_type )* - ; + : 'extends' interface_class_type (',' interface_class_type)* + ; + interface_class_item - : type_declaration - | attribute_instance* interface_class_method - | local_parameter_declaration ';' - | parameter_declaration ';' - | ';' - ; + : type_declaration + | attribute_instance* interface_class_method + | local_parameter_declaration ';' + | parameter_declaration ';' + | ';' + ; + interface_class_method - : 'pure' 'virtual' method_prototype ';' - ; + : 'pure' 'virtual' method_prototype ';' + ; + package_declaration - : attribute_instance* 'package' lifetime? package_identifier ';' timeunits_declaration? pkg_decl_item* 'endpackage' package_name? - ; + : attribute_instance* 'package' lifetime? package_identifier ';' timeunits_declaration? pkg_decl_item* 'endpackage' package_name? + ; + package_name - : ':' package_identifier - ; + : ':' package_identifier + ; + pkg_decl_item - : attribute_instance* package_item - ; + : attribute_instance* package_item + ; + timeunits_declaration - : 'timeunit' time_literal ( '/' time_literal )? ';' - | 'timeprecision' time_literal ';' ( 'timeunit' time_literal ';' )? - | 'timeunit' time_literal ';' 'timeprecision' time_literal ';' - ; + : 'timeunit' time_literal ('/' time_literal)? ';' + | 'timeprecision' time_literal ';' ( 'timeunit' time_literal ';')? + | 'timeunit' time_literal ';' 'timeprecision' time_literal ';' + ; + // A.1.3 Module parameters and ports parameter_port_list - : '#' '(' list_of_param_assignments ( ',' parameter_port_declaration )* ')' - | '#' '(' parameter_port_declaration ( ',' parameter_port_declaration )* ')' - | '#' '(' ')' - ; + : '#' '(' list_of_param_assignments (',' parameter_port_declaration)* ')' + | '#' '(' parameter_port_declaration ( ',' parameter_port_declaration)* ')' + | '#' '(' ')' + ; + parameter_port_declaration - : parameter_declaration - | local_parameter_declaration - | data_type list_of_param_assignments - | 'type' list_of_type_assignments - ; + : parameter_declaration + | local_parameter_declaration + | data_type list_of_param_assignments + | 'type' list_of_type_assignments + ; + list_of_port_declarations - : '(' port_decl ( ',' port_decl )* ')' - | '(' port ( ',' port )+ ')' - | '(' port_implicit ')' - | '(' ')' - ; + : '(' port_decl (',' port_decl)* ')' + | '(' port ( ',' port)+ ')' + | '(' port_implicit ')' + | '(' ')' + ; + port_decl - : attribute_instance* ansi_port_declaration - ; + : attribute_instance* ansi_port_declaration + ; + port_declaration - : attribute_instance* inout_declaration - | attribute_instance* input_declaration - | attribute_instance* output_declaration - | attribute_instance* ref_declaration - | attribute_instance* interface_port_declaration - ; + : attribute_instance* inout_declaration + | attribute_instance* input_declaration + | attribute_instance* output_declaration + | attribute_instance* ref_declaration + | attribute_instance* interface_port_declaration + ; + port - : port_implicit? - ; + : port_implicit? + ; + port_implicit - : port_expression - ; + : port_expression + ; + port_expression - : port_identifier constant_bit_select? '[' constant_indexed_range ']' - | port_identifier const_member_select+ ( '[' constant_part_select_range ']' )? - | '{' port_reference ( ',' port_reference )* '}' - ; + : port_identifier constant_bit_select? '[' constant_indexed_range ']' + | port_identifier const_member_select+ ( '[' constant_part_select_range ']')? + | '{' port_reference ( ',' port_reference)* '}' + ; + port_reference - : port_identifier constant_select? - ; + : port_identifier constant_select? + ; + port_direction - : 'input' - | 'output' - | 'inout' - | 'ref' - ; + : 'input' + | 'output' + | 'inout' + | 'ref' + ; + ansi_port_declaration - : 'interface' ( '.' modport_identifier )? port_identifier unpacked_dimension* ( '=' constant_expression )? - | interface_identifier '.' modport_identifier port_identifier unpacked_dimension* ( '=' constant_expression )? - | port_direction? '.' port_identifier '(' expression? ')' - | port_direction? 'interconnect' implicit_data_type? port_identifier unpacked_dimension* ( '=' constant_expression )? - | port_direction? 'var' data_type_or_implicit? port_identifier variable_dimension* ( '=' constant_expression )? - | port_direction? data_type? port_identifier variable_dimension* ( '=' constant_expression )? - | port_direction? implicit_data_type port_identifier unpacked_dimension* ( '=' constant_expression )? - | port_direction? net_type data_type_or_implicit? port_identifier unpacked_dimension* ( '=' constant_expression )? - ; + : 'interface' ('.' modport_identifier)? port_identifier unpacked_dimension* ( + '=' constant_expression + )? + | interface_identifier '.' modport_identifier port_identifier unpacked_dimension* ( + '=' constant_expression + )? + | port_direction? '.' port_identifier '(' expression? ')' + | port_direction? 'interconnect' implicit_data_type? port_identifier unpacked_dimension* ( + '=' constant_expression + )? + | port_direction? 'var' data_type_or_implicit? port_identifier variable_dimension* ( + '=' constant_expression + )? + | port_direction? data_type? port_identifier variable_dimension* ('=' constant_expression)? + | port_direction? implicit_data_type port_identifier unpacked_dimension* ( + '=' constant_expression + )? + | port_direction? net_type data_type_or_implicit? port_identifier unpacked_dimension* ( + '=' constant_expression + )? + ; + // A.1.4 Module items elaboration_system_task - : '$fatal' fatal_arg_list? ';' - | '$error' arg_list? ';' - | '$warning' arg_list? ';' - | '$info' arg_list? ';' - ; + : '$fatal' fatal_arg_list? ';' + | '$error' arg_list? ';' + | '$warning' arg_list? ';' + | '$info' arg_list? ';' + ; + fatal_arg_list - : '(' finish_number ( ',' list_of_arguments )? ')' - ; + : '(' finish_number (',' list_of_arguments)? ')' + ; + finish_number - : unsigned_number - ; + : unsigned_number + ; + module_common_item - : module_item_declaration - | module_program_interface_instantiation - | assertion_item - | bind_directive - | continuous_assign - | net_alias - | initial_construct - | final_construct - | always_construct - | loop_generate_construct - | conditional_generate_construct - | elaboration_system_task - ; + : module_item_declaration + | module_program_interface_instantiation + | assertion_item + | bind_directive + | continuous_assign + | net_alias + | initial_construct + | final_construct + | always_construct + | loop_generate_construct + | conditional_generate_construct + | elaboration_system_task + ; + module_item - : port_declaration ';' - | generate_region - | attribute_instance* parameter_override - | attribute_instance* gate_instantiation - | attribute_instance* module_common_item - | attribute_instance* udp_instantiation - | specify_block - | attribute_instance* specparam_declaration - | program_declaration - | module_declaration - | interface_declaration - | timeunits_declaration - ; + : port_declaration ';' + | generate_region + | attribute_instance* parameter_override + | attribute_instance* gate_instantiation + | attribute_instance* module_common_item + | attribute_instance* udp_instantiation + | specify_block + | attribute_instance* specparam_declaration + | program_declaration + | module_declaration + | interface_declaration + | timeunits_declaration + ; + module_item_declaration - : package_item_declaration - | genvar_declaration - | clocking_declaration - | 'default' 'clocking' clocking_identifier ';' - | 'default' 'disable' 'iff' expression_or_dist ';' - ; + : package_item_declaration + | genvar_declaration + | clocking_declaration + | 'default' 'clocking' clocking_identifier ';' + | 'default' 'disable' 'iff' expression_or_dist ';' + ; + parameter_override - : 'defparam' list_of_defparam_assignments ';' - ; + : 'defparam' list_of_defparam_assignments ';' + ; + bind_directive - : 'bind' bind_target_scope ( ':' bind_target_instance_list )? bind_instantiation ';' - | 'bind' bind_target_instance bind_instantiation ';' - ; + : 'bind' bind_target_scope (':' bind_target_instance_list)? bind_instantiation ';' + | 'bind' bind_target_instance bind_instantiation ';' + ; + bind_target_scope - : module_identifier - | interface_identifier - ; + : module_identifier + | interface_identifier + ; + bind_target_instance - : hierarchical_identifier constant_bit_select? - ; + : hierarchical_identifier constant_bit_select? + ; + bind_target_instance_list - : bind_target_instance ( ',' bind_target_instance )* - ; + : bind_target_instance (',' bind_target_instance)* + ; + bind_instantiation - : module_program_interface_instantiation - | checker_instantiation - ; + : module_program_interface_instantiation + | checker_instantiation + ; + // A.1.5 Configuration source text config_declaration - : 'config' config_identifier ';' ( local_parameter_declaration ';' )* design_statement config_rule_statement* 'endconfig' config_name? - ; + : 'config' config_identifier ';' (local_parameter_declaration ';')* design_statement config_rule_statement* 'endconfig' config_name? + ; + config_name - : ':' config_identifier - ; + : ':' config_identifier + ; + design_statement - : 'design' design_statement_item* ';' - ; + : 'design' design_statement_item* ';' + ; + design_statement_item - : ( library_identifier '.' )? cell_identifier - ; + : (library_identifier '.')? cell_identifier + ; + config_rule_statement - : default_clause liblist_clause ';' - | inst_clause liblist_clause ';' - | inst_clause use_clause ';' - | cell_clause liblist_clause ';' - | cell_clause use_clause ';' - ; + : default_clause liblist_clause ';' + | inst_clause liblist_clause ';' + | inst_clause use_clause ';' + | cell_clause liblist_clause ';' + | cell_clause use_clause ';' + ; + default_clause - : 'default' - ; + : 'default' + ; + inst_clause - : 'instance' inst_name - ; + : 'instance' inst_name + ; + inst_name - : topmodule_identifier ( '.' instance_identifier )* - ; + : topmodule_identifier ('.' instance_identifier)* + ; + cell_clause - : 'cell' ( library_identifier '.' )? cell_identifier - ; + : 'cell' (library_identifier '.')? cell_identifier + ; + liblist_clause - : 'liblist' library_identifier* - ; + : 'liblist' library_identifier* + ; + use_clause - : 'use' ( library_identifier '.' )? cell_identifier ( ':' 'config' )? - | 'use' named_parameter_assignment ( ',' named_parameter_assignment )* ( ':' 'config' )? - | 'use' ( library_identifier '.' )? cell_identifier named_parameter_assignment ( ',' named_parameter_assignment )* ( ':' 'config' )? - ; + : 'use' (library_identifier '.')? cell_identifier (':' 'config')? + | 'use' named_parameter_assignment (',' named_parameter_assignment)* (':' 'config')? + | 'use' (library_identifier '.')? cell_identifier named_parameter_assignment ( + ',' named_parameter_assignment + )* (':' 'config')? + ; + // A.1.6 Interface items extern_tf_declaration - : 'extern' method_prototype ';' - | 'extern' 'forkjoin' task_prototype ';' - ; + : 'extern' method_prototype ';' + | 'extern' 'forkjoin' task_prototype ';' + ; + interface_item - : port_declaration ';' - | generate_region - | attribute_instance* module_common_item - | attribute_instance* extern_tf_declaration - | program_declaration - | modport_declaration - | interface_declaration - | timeunits_declaration - ; + : port_declaration ';' + | generate_region + | attribute_instance* module_common_item + | attribute_instance* extern_tf_declaration + | program_declaration + | modport_declaration + | interface_declaration + | timeunits_declaration + ; + // A.1.7 Program items program_item - : port_declaration ';' - | attribute_instance* continuous_assign - | attribute_instance* module_item_declaration - | attribute_instance* initial_construct - | attribute_instance* final_construct - | attribute_instance* concurrent_assertion_item - | timeunits_declaration - | loop_generate_construct - | conditional_generate_construct - | generate_region - | elaboration_system_task - ; + : port_declaration ';' + | attribute_instance* continuous_assign + | attribute_instance* module_item_declaration + | attribute_instance* initial_construct + | attribute_instance* final_construct + | attribute_instance* concurrent_assertion_item + | timeunits_declaration + | loop_generate_construct + | conditional_generate_construct + | generate_region + | elaboration_system_task + ; + // A.1.8 Checker items checker_port_list - : checker_port_item ( ',' checker_port_item )* - ; + : checker_port_item (',' checker_port_item)* + ; + checker_port_item - : attribute_instance* checker_port_direction? property_formal_type? formal_port_identifier variable_dimension* ( '=' property_actual_arg )? - ; + : attribute_instance* checker_port_direction? property_formal_type? formal_port_identifier variable_dimension* ( + '=' property_actual_arg + )? + ; + checker_port_direction - : 'input' - | 'output' - ; + : 'input' + | 'output' + ; + checker_item - : checker_item_declaration - | initial_construct - | always_construct - | final_construct - | assertion_item - | continuous_assign - | loop_generate_construct - | conditional_generate_construct - | generate_region - | elaboration_system_task - ; + : checker_item_declaration + | initial_construct + | always_construct + | final_construct + | assertion_item + | continuous_assign + | loop_generate_construct + | conditional_generate_construct + | generate_region + | elaboration_system_task + ; + checker_item_declaration - : 'rand'? data_declaration - | function_declaration - | checker_declaration - | assertion_item_declaration - | covergroup_declaration - | genvar_declaration - | clocking_declaration - | 'default' 'clocking' clocking_identifier ';' - | 'default' 'disable' 'iff' expression_or_dist ';' - | ';' - ; + : 'rand'? data_declaration + | function_declaration + | checker_declaration + | assertion_item_declaration + | covergroup_declaration + | genvar_declaration + | clocking_declaration + | 'default' 'clocking' clocking_identifier ';' + | 'default' 'disable' 'iff' expression_or_dist ';' + | ';' + ; + // A.1.9 Class items class_item - : attribute_instance* class_property - | attribute_instance* class_method - | attribute_instance* class_constraint - | attribute_instance* class_declaration - | attribute_instance* covergroup_declaration - | local_parameter_declaration ';' - | parameter_declaration ';' - | ';' - ; + : attribute_instance* class_property + | attribute_instance* class_method + | attribute_instance* class_constraint + | attribute_instance* class_declaration + | attribute_instance* covergroup_declaration + | local_parameter_declaration ';' + | parameter_declaration ';' + | ';' + ; + class_property - : 'const' ( 'protected' | 'local' | class_item_qualifier class_item_qualifier+ ) data_type const_identifier ( '=' constant_expression )? ';' - | property_qualifier* 'automatic'? data_type list_of_variable_decl_assignments ';' - | property_qualifier* 'const' lifetime? data_type list_of_variable_decl_assignments ';' - | property_qualifier* 'const'? 'var' lifetime? data_type_or_implicit? list_of_variable_decl_assignments ';' - | property_qualifier* net_type_declaration - | property_qualifier* package_import_declaration - | property_qualifier* type_declaration - ; + : 'const' ('protected' | 'local' | class_item_qualifier class_item_qualifier+) data_type const_identifier ( + '=' constant_expression + )? ';' + | property_qualifier* 'automatic'? data_type list_of_variable_decl_assignments ';' + | property_qualifier* 'const' lifetime? data_type list_of_variable_decl_assignments ';' + | property_qualifier* 'const'? 'var' lifetime? data_type_or_implicit? list_of_variable_decl_assignments ';' + | property_qualifier* net_type_declaration + | property_qualifier* package_import_declaration + | property_qualifier* type_declaration + ; + class_method - : method_qualifier* task_declaration - | method_qualifier* function_declaration - | 'pure' 'virtual' class_item_qualifier* method_prototype ';' - | 'extern' method_qualifier* method_prototype ';' - | method_qualifier* class_constructor_declaration - | 'extern' method_qualifier* class_constructor_prototype - ; + : method_qualifier* task_declaration + | method_qualifier* function_declaration + | 'pure' 'virtual' class_item_qualifier* method_prototype ';' + | 'extern' method_qualifier* method_prototype ';' + | method_qualifier* class_constructor_declaration + | 'extern' method_qualifier* class_constructor_prototype + ; + class_constructor_prototype - : 'function' 'new' port_list? ';' - ; + : 'function' 'new' port_list? ';' + ; + port_list - : '(' tf_port_list ')' - ; + : '(' tf_port_list ')' + ; + class_constraint - : constraint_prototype - | constraint_declaration - ; + : constraint_prototype + | constraint_declaration + ; + class_item_qualifier - : 'static' - | 'protected' - | 'local' - ; + : 'static' + | 'protected' + | 'local' + ; + property_qualifier - : random_qualifier - | class_item_qualifier - ; + : random_qualifier + | class_item_qualifier + ; + random_qualifier - : 'rand' - | 'randc' - ; + : 'rand' + | 'randc' + ; + method_qualifier - : 'pure'? 'virtual' - | class_item_qualifier - ; + : 'pure'? 'virtual' + | class_item_qualifier + ; + method_prototype - : task_prototype - | function_prototype - ; + : task_prototype + | function_prototype + ; + class_constructor_declaration - : 'function' class_scope? 'new' port_list? ';' block_item_declaration* super_class_constructor_call? function_statement_or_null* 'endfunction' ( ':' 'new' )? - ; + : 'function' class_scope? 'new' port_list? ';' block_item_declaration* super_class_constructor_call? function_statement_or_null* 'endfunction' ( + ':' 'new' + )? + ; + super_class_constructor_call - : 'super' '.' 'new' arg_list? ';' - ; + : 'super' '.' 'new' arg_list? ';' + ; + // A.1.10 Constraints constraint_declaration - : 'static'? 'constraint' constraint_identifier constraint_block - ; + : 'static'? 'constraint' constraint_identifier constraint_block + ; + constraint_block - : '{' constraint_block_item* '}' - ; + : '{' constraint_block_item* '}' + ; + constraint_block_item - : 'solve' solve_before_list 'before' solve_before_list ';' - | constraint_expression - ; + : 'solve' solve_before_list 'before' solve_before_list ';' + | constraint_expression + ; + solve_before_list - : constraint_primary ( ',' constraint_primary )* - ; + : constraint_primary (',' constraint_primary)* + ; + constraint_primary - : ( implicit_class_handle '.' | class_scope )? hierarchical_identifier select_? - ; + : (implicit_class_handle '.' | class_scope)? hierarchical_identifier select_? + ; + constraint_expression - : 'soft'? expression_or_dist ';' - | uniqueness_constraint ';' - | expression '->' constraint_set - | 'if' '(' expression ')' constraint_set ( 'else' constraint_set )? - | 'foreach' '(' ps_or_hierarchical_array_identifier '[' loop_variables ']' ')' constraint_set - | 'disable' 'soft' constraint_primary ';' - ; + : 'soft'? expression_or_dist ';' + | uniqueness_constraint ';' + | expression '->' constraint_set + | 'if' '(' expression ')' constraint_set ( 'else' constraint_set)? + | 'foreach' '(' ps_or_hierarchical_array_identifier '[' loop_variables ']' ')' constraint_set + | 'disable' 'soft' constraint_primary ';' + ; + uniqueness_constraint - : 'unique' '{' open_range_list '}' - ; + : 'unique' '{' open_range_list '}' + ; + constraint_set - : constraint_expression - | '{' constraint_expression* '}' - ; + : constraint_expression + | '{' constraint_expression* '}' + ; + dist_list - : dist_item ( ',' dist_item )* - ; + : dist_item (',' dist_item)* + ; + dist_item - : value_range dist_weight? - ; + : value_range dist_weight? + ; + dist_weight - : ':=' expression - | ':/' expression - ; + : ':=' expression + | ':/' expression + ; + constraint_prototype - : constraint_prototype_qualifier? 'static'? 'constraint' constraint_identifier ';' - ; + : constraint_prototype_qualifier? 'static'? 'constraint' constraint_identifier ';' + ; + constraint_prototype_qualifier - : 'extern' - | 'pure' - ; + : 'extern' + | 'pure' + ; + extern_constraint_declaration - : 'static'? 'constraint' class_scope constraint_identifier constraint_block - ; + : 'static'? 'constraint' class_scope constraint_identifier constraint_block + ; + identifier_list - : identifier ( ',' identifier )* - ; + : identifier (',' identifier)* + ; + // A.1.11 Package items package_item - : package_item_declaration - | anonymous_program - | package_export_declaration - | timeunits_declaration - ; + : package_item_declaration + | anonymous_program + | package_export_declaration + | timeunits_declaration + ; + package_item_declaration - : net_declaration - | data_declaration - | task_declaration - | function_declaration - | checker_declaration - | dpi_import_export - | extern_constraint_declaration - | class_declaration - | interface_class_declaration - | class_constructor_declaration - | local_parameter_declaration ';' - | parameter_declaration ';' - | covergroup_declaration - | assertion_item_declaration - | ';' - ; + : net_declaration + | data_declaration + | task_declaration + | function_declaration + | checker_declaration + | dpi_import_export + | extern_constraint_declaration + | class_declaration + | interface_class_declaration + | class_constructor_declaration + | local_parameter_declaration ';' + | parameter_declaration ';' + | covergroup_declaration + | assertion_item_declaration + | ';' + ; + anonymous_program - : 'program' ';' anonymous_program_item* 'endprogram' - ; + : 'program' ';' anonymous_program_item* 'endprogram' + ; + anonymous_program_item - : task_declaration - | function_declaration - | class_declaration - | interface_class_declaration - | covergroup_declaration - | class_constructor_declaration - | ';' - ; + : task_declaration + | function_declaration + | class_declaration + | interface_class_declaration + | covergroup_declaration + | class_constructor_declaration + | ';' + ; + // A.2.1.1 Module parameter declarations local_parameter_declaration - : 'localparam' data_type_or_implicit? list_of_param_assignments - | 'localparam' 'type' list_of_type_assignments - ; + : 'localparam' data_type_or_implicit? list_of_param_assignments + | 'localparam' 'type' list_of_type_assignments + ; + parameter_declaration - : 'parameter' data_type_or_implicit? list_of_param_assignments - | 'parameter' 'type' list_of_type_assignments - ; + : 'parameter' data_type_or_implicit? list_of_param_assignments + | 'parameter' 'type' list_of_type_assignments + ; + specparam_declaration - : 'specparam' packed_dimension? list_of_specparam_assignments ';' - ; + : 'specparam' packed_dimension? list_of_specparam_assignments ';' + ; + // A.2.1.2 Port declarations inout_declaration - : 'inout' net_port_type? list_of_port_identifiers - ; + : 'inout' net_port_type? list_of_port_identifiers + ; + input_declaration - : 'input' 'interconnect'? implicit_data_type? list_of_port_identifiers - | 'input' net_type data_type_or_implicit? list_of_port_identifiers - | 'input' 'var' data_type_or_implicit? list_of_variable_identifiers - | 'input' data_type list_of_variable_identifiers - ; + : 'input' 'interconnect'? implicit_data_type? list_of_port_identifiers + | 'input' net_type data_type_or_implicit? list_of_port_identifiers + | 'input' 'var' data_type_or_implicit? list_of_variable_identifiers + | 'input' data_type list_of_variable_identifiers + ; + output_declaration - : 'output' 'interconnect'? implicit_data_type? list_of_port_identifiers - | 'output' net_type data_type_or_implicit? list_of_port_identifiers - | 'output' 'var' data_type_or_implicit? list_of_variable_port_identifiers - | 'output' data_type list_of_variable_port_identifiers - ; + : 'output' 'interconnect'? implicit_data_type? list_of_port_identifiers + | 'output' net_type data_type_or_implicit? list_of_port_identifiers + | 'output' 'var' data_type_or_implicit? list_of_variable_port_identifiers + | 'output' data_type list_of_variable_port_identifiers + ; + interface_port_declaration - : interface_identifier ( '.' modport_identifier )? list_of_interface_identifiers - ; + : interface_identifier ('.' modport_identifier)? list_of_interface_identifiers + ; + ref_declaration - : 'ref' variable_port_type list_of_variable_identifiers - ; + : 'ref' variable_port_type list_of_variable_identifiers + ; + // A.2.1.3 Type declarations data_declaration - : 'const'? lifetime? data_type list_of_variable_decl_assignments ';' - | 'const'? 'var' lifetime? data_type_or_implicit? list_of_variable_decl_assignments ';' - | type_declaration - | package_import_declaration - | net_type_declaration - ; + : 'const'? lifetime? data_type list_of_variable_decl_assignments ';' + | 'const'? 'var' lifetime? data_type_or_implicit? list_of_variable_decl_assignments ';' + | type_declaration + | package_import_declaration + | net_type_declaration + ; + package_import_declaration - : 'import' package_import_item ( ',' package_import_item )* ';' - ; + : 'import' package_import_item (',' package_import_item)* ';' + ; + package_import_item - : package_identifier '::' identifier - | package_identifier '::' '*' - ; + : package_identifier '::' identifier + | package_identifier '::' '*' + ; + package_export_declaration - : 'export' '*' '::' '*' ';' - | 'export' package_import_item ( ',' package_import_item )* ';' - ; + : 'export' '*' '::' '*' ';' + | 'export' package_import_item ( ',' package_import_item)* ';' + ; + genvar_declaration - : 'genvar' list_of_genvar_identifiers ';' - ; + : 'genvar' list_of_genvar_identifiers ';' + ; + net_declaration - : net_type ( drive_strength | charge_strength )? ( 'vectored' | 'scalared' )? data_type_or_implicit? delay3? list_of_net_decl_assignments ';' - | net_type_identifier delay_control list_of_net_decl_assignments ';' - | 'interconnect' implicit_data_type? ( '#' delay_value )? net_id ( ',' net_id )? ';' - ; + : net_type (drive_strength | charge_strength)? ('vectored' | 'scalared')? data_type_or_implicit? delay3? list_of_net_decl_assignments ';' + | net_type_identifier delay_control list_of_net_decl_assignments ';' + | 'interconnect' implicit_data_type? ('#' delay_value)? net_id (',' net_id)? ';' + ; + net_id - : net_identifier unpacked_dimension* - ; + : net_identifier unpacked_dimension* + ; + type_declaration - : 'typedef' data_type type_identifier variable_dimension* ';' - | 'typedef' interface_instance_identifier constant_bit_select? '.' type_identifier type_identifier ';' - | 'typedef' ( 'enum' | 'struct' | 'union' | 'class' | 'interface' 'class' )? type_identifier ';' - ; + : 'typedef' data_type type_identifier variable_dimension* ';' + | 'typedef' interface_instance_identifier constant_bit_select? '.' type_identifier type_identifier ';' + | 'typedef' ('enum' | 'struct' | 'union' | 'class' | 'interface' 'class')? type_identifier ';' + ; + net_type_declaration - : 'nettype' data_type net_type_identifier net_type_decl_with? ';' - | 'nettype' package_or_class_scope? net_type_identifier net_type_identifier ';' - ; + : 'nettype' data_type net_type_identifier net_type_decl_with? ';' + | 'nettype' package_or_class_scope? net_type_identifier net_type_identifier ';' + ; + net_type_decl_with - : 'with' package_or_class_scope? tf_identifier - ; + : 'with' package_or_class_scope? tf_identifier + ; + lifetime - : 'static' - | 'automatic' - ; + : 'static' + | 'automatic' + ; + // A.2.2.1 Net and variable types data_type - : integer_vector_type signing? packed_dimension* - | integer_atom_type signing? - | non_integer_type - | struct_union ( 'packed' signing? )? '{' struct_union_member+ '}' packed_dimension* - | 'enum' enum_base_type? '{' enum_name_declaration ( ',' enum_name_declaration )* '}' packed_dimension* - | 'string' - | 'chandle' - | 'virtual' 'interface'? interface_identifier parameter_value_assignment? ( '.' modport_identifier )? - | type_identifier packed_dimension+ - | '$unit' '::' type_identifier packed_dimension* - | class_type ( '::' type_identifier packed_dimension* )? - | 'event' - | type_reference - ; + : integer_vector_type signing? packed_dimension* + | integer_atom_type signing? + | non_integer_type + | struct_union ('packed' signing?)? '{' struct_union_member+ '}' packed_dimension* + | 'enum' enum_base_type? '{' enum_name_declaration (',' enum_name_declaration)* '}' packed_dimension* + | 'string' + | 'chandle' + | 'virtual' 'interface'? interface_identifier parameter_value_assignment? ( + '.' modport_identifier + )? + | type_identifier packed_dimension+ + | '$unit' '::' type_identifier packed_dimension* + | class_type ( '::' type_identifier packed_dimension*)? + | 'event' + | type_reference + ; + data_type_or_implicit - : data_type - | implicit_data_type - ; + : data_type + | implicit_data_type + ; + implicit_data_type - : packed_dimension+ - | signing packed_dimension* - ; + : packed_dimension+ + | signing packed_dimension* + ; + enum_base_type - : integer_atom_type signing? - | integer_vector_type signing? packed_dimension? - | type_identifier packed_dimension? - ; + : integer_atom_type signing? + | integer_vector_type signing? packed_dimension? + | type_identifier packed_dimension? + ; + enum_name_declaration - : enum_identifier enum_name_suffix_range? ( '=' constant_expression )? - ; + : enum_identifier enum_name_suffix_range? ('=' constant_expression)? + ; + enum_name_suffix_range - : '[' integral_number ( ':' integral_number )? ']' - ; + : '[' integral_number (':' integral_number)? ']' + ; + class_scope - : class_type '::' - ; + : class_type '::' + ; + class_type - : ( '$unit' '::' )? class_ref ( '::' class_ref )* - ; + : ('$unit' '::')? class_ref ('::' class_ref)* + ; + class_ref - : class_identifier parameter_value_assignment? - ; + : class_identifier parameter_value_assignment? + ; + package_or_class_scope - : class_type '::' - | '$unit' '::' - ; + : class_type '::' + | '$unit' '::' + ; + integer_type - : integer_vector_type - | integer_atom_type - ; + : integer_vector_type + | integer_atom_type + ; + integer_atom_type - : 'byte' - | 'shortint' - | 'int' - | 'longint' - | 'integer' - | 'time' - ; + : 'byte' + | 'shortint' + | 'int' + | 'longint' + | 'integer' + | 'time' + ; + integer_vector_type - : 'bit' - | 'logic' - | 'reg' - ; + : 'bit' + | 'logic' + | 'reg' + ; + non_integer_type - : 'shortreal' - | 'real' - | 'realtime' - ; + : 'shortreal' + | 'real' + | 'realtime' + ; + net_type - : 'supply0' - | 'supply1' - | 'tri' - | 'triand' - | 'trior' - | 'trireg' - | 'tri0' - | 'tri1' - | 'uwire' - | 'wire' - | 'wand' - | 'wor' - ; + : 'supply0' + | 'supply1' + | 'tri' + | 'triand' + | 'trior' + | 'trireg' + | 'tri0' + | 'tri1' + | 'uwire' + | 'wire' + | 'wand' + | 'wor' + ; + net_port_type - : data_type_or_implicit - | net_type data_type_or_implicit? - | 'interconnect' implicit_data_type? - ; + : data_type_or_implicit + | net_type data_type_or_implicit? + | 'interconnect' implicit_data_type? + ; + variable_port_type - : var_data_type - ; + : var_data_type + ; + var_data_type - : data_type - | 'var' data_type_or_implicit? - ; + : data_type + | 'var' data_type_or_implicit? + ; + signing - : 'signed' - | 'unsigned' - ; + : 'signed' + | 'unsigned' + ; + simple_type - : integer_type - | non_integer_type - | ps_type_or_parameter_identifier - ; + : integer_type + | non_integer_type + | ps_type_or_parameter_identifier + ; + struct_union_member - : attribute_instance* random_qualifier? data_type_or_void list_of_variable_decl_assignments ';' - ; + : attribute_instance* random_qualifier? data_type_or_void list_of_variable_decl_assignments ';' + ; + data_type_or_void - : data_type - | 'void' - ; + : data_type + | 'void' + ; + struct_union - : 'struct' - | 'union' 'tagged'? - ; + : 'struct' + | 'union' 'tagged'? + ; + type_reference - : 'type' '(' expression ')' - | 'type' '(' data_type ')' - ; + : 'type' '(' expression ')' + | 'type' '(' data_type ')' + ; + // A.2.2.2 Strengths drive_strength - : '(' strength0 ',' strength1 ')' - | '(' strength1 ',' strength0 ')' - | '(' strength0 ',' 'highz1' ')' - | '(' strength1 ',' 'highz0' ')' - | '(' 'highz0' ',' strength1 ')' - | '(' 'highz1' ',' strength0 ')' - ; + : '(' strength0 ',' strength1 ')' + | '(' strength1 ',' strength0 ')' + | '(' strength0 ',' 'highz1' ')' + | '(' strength1 ',' 'highz0' ')' + | '(' 'highz0' ',' strength1 ')' + | '(' 'highz1' ',' strength0 ')' + ; + strength0 - : 'supply0' - | 'strong0' - | 'pull0' - | 'weak0' - ; + : 'supply0' + | 'strong0' + | 'pull0' + | 'weak0' + ; + strength1 - : 'supply1' - | 'strong1' - | 'pull1' - | 'weak1' - ; + : 'supply1' + | 'strong1' + | 'pull1' + | 'weak1' + ; + charge_strength - : '(' 'small' ')' - | '(' 'medium' ')' - | '(' 'large' ')' - ; + : '(' 'small' ')' + | '(' 'medium' ')' + | '(' 'large' ')' + ; + // A.2.2.3 Delays delay3 - : '#' delay_value - | '#' '(' mintypmax_expression ( ',' mintypmax_expression ( ',' mintypmax_expression )? )? ')' - ; + : '#' delay_value + | '#' '(' mintypmax_expression (',' mintypmax_expression ( ',' mintypmax_expression)?)? ')' + ; + delay2 - : '#' delay_value - | '#' '(' mintypmax_expression ( ',' mintypmax_expression )? ')' - ; + : '#' delay_value + | '#' '(' mintypmax_expression ( ',' mintypmax_expression)? ')' + ; + delay_value - : unsigned_number - | real_number - | ps_identifier - | time_literal - | '1step' - ; + : unsigned_number + | real_number + | ps_identifier + | time_literal + | '1step' + ; + // A.2.3 Declaration lists list_of_defparam_assignments - : defparam_assignment ( ',' defparam_assignment )* - ; + : defparam_assignment (',' defparam_assignment)* + ; + list_of_genvar_identifiers - : genvar_identifier ( ',' genvar_identifier )* - ; + : genvar_identifier (',' genvar_identifier)* + ; + list_of_interface_identifiers - : interface_id ( ',' interface_id )* - ; + : interface_id (',' interface_id)* + ; + interface_id - : interface_identifier unpacked_dimension* - ; + : interface_identifier unpacked_dimension* + ; + list_of_net_decl_assignments - : net_decl_assignment ( ',' net_decl_assignment )* - ; + : net_decl_assignment (',' net_decl_assignment)* + ; + list_of_param_assignments - : param_assignment ( ',' param_assignment )* - ; + : param_assignment (',' param_assignment)* + ; + list_of_port_identifiers - : port_id ( ',' port_id )* - ; + : port_id (',' port_id)* + ; + port_id - : port_identifier unpacked_dimension* - ; + : port_identifier unpacked_dimension* + ; + list_of_udp_port_identifiers - : port_identifier ( ',' port_identifier )* - ; + : port_identifier (',' port_identifier)* + ; + list_of_specparam_assignments - : specparam_assignment ( ',' specparam_assignment )* - ; + : specparam_assignment (',' specparam_assignment)* + ; + list_of_tf_variable_identifiers - : tf_var_id ( ',' tf_var_id )* - ; + : tf_var_id (',' tf_var_id)* + ; + tf_var_id - : port_identifier variable_dimension* ( '=' expression )? - ; + : port_identifier variable_dimension* ('=' expression)? + ; + list_of_type_assignments - : type_assignment ( ',' type_assignment )* - ; + : type_assignment (',' type_assignment)* + ; + list_of_variable_decl_assignments - : variable_decl_assignment ( ',' variable_decl_assignment )* - ; + : variable_decl_assignment (',' variable_decl_assignment)* + ; + list_of_variable_identifiers - : var_id ( ',' var_id )* - ; + : var_id (',' var_id)* + ; + var_id - : variable_identifier variable_dimension* - ; + : variable_identifier variable_dimension* + ; + list_of_variable_port_identifiers - : var_port_id ( ',' var_port_id )* - ; + : var_port_id (',' var_port_id)* + ; + var_port_id - : port_identifier variable_dimension* ( '=' constant_expression )? - ; + : port_identifier variable_dimension* ('=' constant_expression)? + ; + // A.2.4 Declaration assignments defparam_assignment - : hierarchical_identifier '=' constant_mintypmax_expression - ; + : hierarchical_identifier '=' constant_mintypmax_expression + ; + net_decl_assignment - : net_identifier unpacked_dimension* ( '=' expression )? - ; + : net_identifier unpacked_dimension* ('=' expression)? + ; + param_assignment - : parameter_identifier unpacked_dimension* ( '=' constant_param_expression )? - ; + : parameter_identifier unpacked_dimension* ('=' constant_param_expression)? + ; + specparam_assignment - : specparam_identifier '=' constant_mintypmax_expression - | pulse_control_specparam - ; + : specparam_identifier '=' constant_mintypmax_expression + | pulse_control_specparam + ; + type_assignment - : type_identifier ( '=' data_type )? - ; + : type_identifier ('=' data_type)? + ; + pulse_control_specparam - : 'PATHPULSE$' '=' '(' reject_limit_value ( ',' error_limit_value )? ')' - | 'PATHPULSE$' specify_input_terminal_descriptor '$' specify_output_terminal_descriptor '=' '(' reject_limit_value ( ',' error_limit_value )? ')' - ; + : 'PATHPULSE$' '=' '(' reject_limit_value (',' error_limit_value)? ')' + | 'PATHPULSE$' specify_input_terminal_descriptor '$' specify_output_terminal_descriptor '=' '(' reject_limit_value ( + ',' error_limit_value + )? ')' + ; + error_limit_value - : limit_value - ; + : limit_value + ; + reject_limit_value - : limit_value - ; + : limit_value + ; + limit_value - : constant_mintypmax_expression - ; + : constant_mintypmax_expression + ; + variable_decl_assignment - : variable_identifier variable_dimension* ( '=' expression )? - | dynamic_array_variable_identifier unsized_dimension variable_dimension* '=' dynamic_array_new - | class_variable_identifier '=' class_new - ; + : variable_identifier variable_dimension* ('=' expression)? + | dynamic_array_variable_identifier unsized_dimension variable_dimension* '=' dynamic_array_new + | class_variable_identifier '=' class_new + ; + class_new - : class_scope? 'new' arg_list? - | 'new' expression - ; + : class_scope? 'new' arg_list? + | 'new' expression + ; + dynamic_array_new - : 'new' '[' expression ']' ( '(' expression ')' )? - ; + : 'new' '[' expression ']' ('(' expression ')')? + ; + // A.2.5 Declaration ranges unpacked_dimension - : '[' constant_range ']' - | '[' constant_expression ']' - ; + : '[' constant_range ']' + | '[' constant_expression ']' + ; + packed_dimension - : '[' constant_range ']' - | unsized_dimension - ; + : '[' constant_range ']' + | unsized_dimension + ; + associative_dimension - : '[' data_type ']' - | '[' '*' ']' - ; + : '[' data_type ']' + | '[' '*' ']' + ; + variable_dimension - : unsized_dimension - | unpacked_dimension - | associative_dimension - | queue_dimension - ; + : unsized_dimension + | unpacked_dimension + | associative_dimension + | queue_dimension + ; + queue_dimension - : '[' '$' ( ':' constant_expression )? ']' - ; + : '[' '$' (':' constant_expression)? ']' + ; + unsized_dimension - : '[' ']' - ; + : '[' ']' + ; + // A.2.6 Function declarations function_data_type_or_implicit - : data_type_or_void - | implicit_data_type - ; + : data_type_or_void + | implicit_data_type + ; + function_declaration - : 'function' lifetime? function_body_declaration - ; + : 'function' lifetime? function_body_declaration + ; + function_body_declaration - : function_data_type_or_implicit? ( interface_identifier '.' | class_scope )? function_identifier ';' tf_item_declaration* function_statement_or_null* 'endfunction' function_name? - | function_data_type_or_implicit? ( interface_identifier '.' | class_scope )? function_identifier '(' tf_port_list ')' ';' block_item_declaration* function_statement_or_null* 'endfunction' function_name? - ; + : function_data_type_or_implicit? (interface_identifier '.' | class_scope)? function_identifier ';' tf_item_declaration* + function_statement_or_null* 'endfunction' function_name? + | function_data_type_or_implicit? (interface_identifier '.' | class_scope)? function_identifier '(' tf_port_list ')' ';' block_item_declaration* + function_statement_or_null* 'endfunction' function_name? + ; + function_name - : ':' function_identifier - ; + : ':' function_identifier + ; + function_prototype - : 'function' data_type_or_void function_identifier port_list? - ; + : 'function' data_type_or_void function_identifier port_list? + ; + dpi_import_export - : 'import' dpi_spec_string dpi_function_import_property? ( c_identifier '=' )? dpi_function_proto ';' - | 'import' dpi_spec_string dpi_task_import_property? ( c_identifier '=' )? dpi_task_proto ';' - | 'export' dpi_spec_string ( c_identifier '=' )? 'function' function_identifier ';' - | 'export' dpi_spec_string ( c_identifier '=' )? 'task' task_identifier ';' - ; + : 'import' dpi_spec_string dpi_function_import_property? (c_identifier '=')? dpi_function_proto ';' + | 'import' dpi_spec_string dpi_task_import_property? (c_identifier '=')? dpi_task_proto ';' + | 'export' dpi_spec_string (c_identifier '=')? 'function' function_identifier ';' + | 'export' dpi_spec_string ( c_identifier '=')? 'task' task_identifier ';' + ; + dpi_spec_string - : '"DPI-C"' - | '"DPI"' - ; + : '"DPI-C"' + | '"DPI"' + ; + dpi_function_import_property - : 'context' - | 'pure' - ; + : 'context' + | 'pure' + ; + dpi_task_import_property - : 'context' - ; + : 'context' + ; + dpi_function_proto - : function_prototype - ; + : function_prototype + ; + dpi_task_proto - : task_prototype - ; + : task_prototype + ; + // A.2.7 Task declarations task_declaration - : 'task' lifetime? task_body_declaration - ; + : 'task' lifetime? task_body_declaration + ; + task_body_declaration - : ( interface_identifier '.' | class_scope )? task_identifier ';' tf_item_declaration* statement_or_null* 'endtask' task_name? - | ( interface_identifier '.' | class_scope )? task_identifier '(' tf_port_list ')' ';' block_item_declaration* statement_or_null* 'endtask' task_name? - ; + : (interface_identifier '.' | class_scope)? task_identifier ';' tf_item_declaration* statement_or_null* 'endtask' task_name? + | (interface_identifier '.' | class_scope)? task_identifier '(' tf_port_list ')' ';' block_item_declaration* statement_or_null* 'endtask' + task_name? + ; + task_name - : ':' task_identifier - ; + : ':' task_identifier + ; + tf_item_declaration - : block_item_declaration - | tf_port_declaration - ; + : block_item_declaration + | tf_port_declaration + ; + tf_port_list - : tf_port_item ( ',' tf_port_item )* - ; + : tf_port_item (',' tf_port_item)* + ; + tf_port_item - : attribute_instance* tf_port_direction? 'var'? data_type_or_implicit? tf_port_id - | - ; + : attribute_instance* tf_port_direction? 'var'? data_type_or_implicit? tf_port_id + | + ; + tf_port_id - : port_identifier variable_dimension* ( '=' expression )? - ; + : port_identifier variable_dimension* ('=' expression)? + ; + tf_port_direction - : port_direction - | 'const' 'ref' - ; + : port_direction + | 'const' 'ref' + ; + tf_port_declaration - : attribute_instance* tf_port_direction 'var'? data_type_or_implicit? list_of_tf_variable_identifiers ';' - ; + : attribute_instance* tf_port_direction 'var'? data_type_or_implicit? list_of_tf_variable_identifiers ';' + ; + task_prototype - : 'task' task_identifier port_list? - ; + : 'task' task_identifier port_list? + ; + // A.2.8 Block item declarations block_item_declaration - : attribute_instance* data_declaration - | attribute_instance* local_parameter_declaration ';' - | attribute_instance* parameter_declaration ';' - | attribute_instance* let_declaration - ; + : attribute_instance* data_declaration + | attribute_instance* local_parameter_declaration ';' + | attribute_instance* parameter_declaration ';' + | attribute_instance* let_declaration + ; + // A.2.9 Interface declarations modport_declaration - : 'modport' modport_item ( ',' modport_item )* ';' - ; + : 'modport' modport_item (',' modport_item)* ';' + ; + modport_item - : modport_identifier '(' modport_ports_declaration ( ',' modport_ports_declaration )* ')' - ; + : modport_identifier '(' modport_ports_declaration (',' modport_ports_declaration)* ')' + ; + modport_ports_declaration - : attribute_instance* modport_simple_ports_declaration - | attribute_instance* modport_tf_ports_declaration - | attribute_instance* modport_clocking_declaration - ; + : attribute_instance* modport_simple_ports_declaration + | attribute_instance* modport_tf_ports_declaration + | attribute_instance* modport_clocking_declaration + ; + modport_clocking_declaration - : 'clocking' clocking_identifier - ; + : 'clocking' clocking_identifier + ; + modport_simple_ports_declaration - : port_direction modport_simple_port ( ',' modport_simple_port )* - ; + : port_direction modport_simple_port (',' modport_simple_port)* + ; + modport_simple_port - : port_identifier - | '.' port_identifier '(' expression? ')' - ; + : port_identifier + | '.' port_identifier '(' expression? ')' + ; + modport_tf_ports_declaration - : import_export modport_tf_port ( ',' modport_tf_port )* - ; + : import_export modport_tf_port (',' modport_tf_port)* + ; + modport_tf_port - : method_prototype - | tf_identifier - ; + : method_prototype + | tf_identifier + ; + import_export - : 'import' - | 'export' - ; + : 'import' + | 'export' + ; + // A.2.10 Assertion declarations concurrent_assertion_item - : block_label? concurrent_assertion_statement - | checker_instantiation - ; + : block_label? concurrent_assertion_statement + | checker_instantiation + ; + block_label - : block_identifier ':' - ; + : block_identifier ':' + ; + concurrent_assertion_statement - : assert_property_statement - | assume_property_statement - | cover_property_statement - | cover_sequence_statement - | restrict_property_statement - ; + : assert_property_statement + | assume_property_statement + | cover_property_statement + | cover_sequence_statement + | restrict_property_statement + ; + assert_property_statement - : 'assert' 'property' '(' property_spec ')' action_block - ; + : 'assert' 'property' '(' property_spec ')' action_block + ; + assume_property_statement - : 'assume' 'property' '(' property_spec ')' action_block - ; + : 'assume' 'property' '(' property_spec ')' action_block + ; + cover_property_statement - : 'cover' 'property' '(' property_spec ')' statement_or_null - ; + : 'cover' 'property' '(' property_spec ')' statement_or_null + ; + expect_property_statement - : 'expect' '(' property_spec ')' action_block - ; + : 'expect' '(' property_spec ')' action_block + ; + cover_sequence_statement - : 'cover' 'sequence' '(' clocking_event? ( 'disable' 'iff' '(' expression_or_dist ')' )? sequence_expr ')' statement_or_null - ; + : 'cover' 'sequence' '(' clocking_event? ('disable' 'iff' '(' expression_or_dist ')')? sequence_expr ')' statement_or_null + ; + restrict_property_statement - : 'restrict' 'property' '(' property_spec ')' ';' - ; + : 'restrict' 'property' '(' property_spec ')' ';' + ; + property_instance - : ps_or_hierarchical_identifier prop_arg_list? - ; + : ps_or_hierarchical_identifier prop_arg_list? + ; + prop_arg_list - : '(' property_list_of_arguments ')' - ; + : '(' property_list_of_arguments ')' + ; + property_list_of_arguments - : prop_ordered_arg ( ',' prop_ordered_arg )* ( ',' prop_named_arg )* - | prop_named_arg ( ',' prop_named_arg )* - ; + : prop_ordered_arg (',' prop_ordered_arg)* (',' prop_named_arg)* + | prop_named_arg ( ',' prop_named_arg)* + ; + prop_ordered_arg - : property_actual_arg? - ; + : property_actual_arg? + ; + prop_named_arg - : '.' identifier '(' property_actual_arg? ')' - ; + : '.' identifier '(' property_actual_arg? ')' + ; + property_actual_arg - : property_expr - | sequence_actual_arg - ; + : property_expr + | sequence_actual_arg + ; + assertion_item_declaration - : property_declaration - | sequence_declaration - | let_declaration - ; + : property_declaration + | sequence_declaration + | let_declaration + ; + property_declaration - : 'property' property_identifier prop_port_list? ';' assertion_variable_declaration* property_spec ';'? 'endproperty' property_name? - ; + : 'property' property_identifier prop_port_list? ';' assertion_variable_declaration* property_spec ';'? 'endproperty' property_name? + ; + property_name - : ':' property_identifier - ; + : ':' property_identifier + ; + prop_port_list - : '(' property_port_list? ')' - ; + : '(' property_port_list? ')' + ; + property_port_list - : property_port_item ( ',' property_port_item )* - ; + : property_port_item (',' property_port_item)* + ; + property_port_item - : attribute_instance* prop_port_item_local? property_formal_type? formal_port_identifier variable_dimension* ( '=' property_actual_arg )? - ; + : attribute_instance* prop_port_item_local? property_formal_type? formal_port_identifier variable_dimension* ( + '=' property_actual_arg + )? + ; + prop_port_item_local - : 'local' property_lvar_port_direction? - ; + : 'local' property_lvar_port_direction? + ; + property_lvar_port_direction - : 'input' - ; + : 'input' + ; + property_formal_type - : sequence_formal_type - | 'property' - ; + : sequence_formal_type + | 'property' + ; + property_spec - : clocking_event? ( 'disable' 'iff' '(' expression_or_dist ')' )? property_expr - ; + : clocking_event? ('disable' 'iff' '(' expression_or_dist ')')? property_expr + ; + property_expr - : sequence_expr - | 'strong' '(' sequence_expr ')' - | 'weak' '(' sequence_expr ')' - | '(' property_expr ')' - | 'not' property_expr - | property_expr 'or' property_expr - | property_expr 'and' property_expr - | sequence_expr '|->' property_expr - | sequence_expr '|=>' property_expr - | 'if' expression_or_dist property_expr ( 'else' property_expr )? - | 'case' expression_or_dist property_case_item+ 'endcase' - | sequence_expr '#-#' property_expr - | sequence_expr '#=#' property_expr - | 'nexttime' property_expr - | 'nexttime' '[' constant_expression ']' property_expr - | 's_nexttime' property_expr - | 's_nexttime' '[' constant_expression ']' property_expr - | 'always' property_expr - | 'always' '[' cycle_delay_const_range_expression ']' property_expr - | 's_always' '[' constant_range ']' property_expr - | 's_eventually' property_expr - | 'eventually' '[' constant_range ']' property_expr - | 's_eventually' '[' cycle_delay_const_range_expression ']' property_expr - | property_expr 'until' property_expr - | property_expr 's_until' property_expr - | property_expr 'until_with' property_expr - | property_expr 's_until_with' property_expr - | property_expr 'implies' property_expr - | property_expr 'iff' property_expr - | 'accept_on' '(' expression_or_dist ')' property_expr - | 'reject_on' '(' expression_or_dist ')' property_expr - | 'sync_accept_on' '(' expression_or_dist ')' property_expr - | 'sync_reject_on' '(' expression_or_dist ')' property_expr - | property_instance - | clocking_event property_expr - ; + : sequence_expr + | 'strong' '(' sequence_expr ')' + | 'weak' '(' sequence_expr ')' + | '(' property_expr ')' + | 'not' property_expr + | property_expr 'or' property_expr + | property_expr 'and' property_expr + | sequence_expr '|->' property_expr + | sequence_expr '|=>' property_expr + | 'if' expression_or_dist property_expr ( 'else' property_expr)? + | 'case' expression_or_dist property_case_item+ 'endcase' + | sequence_expr '#-#' property_expr + | sequence_expr '#=#' property_expr + | 'nexttime' property_expr + | 'nexttime' '[' constant_expression ']' property_expr + | 's_nexttime' property_expr + | 's_nexttime' '[' constant_expression ']' property_expr + | 'always' property_expr + | 'always' '[' cycle_delay_const_range_expression ']' property_expr + | 's_always' '[' constant_range ']' property_expr + | 's_eventually' property_expr + | 'eventually' '[' constant_range ']' property_expr + | 's_eventually' '[' cycle_delay_const_range_expression ']' property_expr + | property_expr 'until' property_expr + | property_expr 's_until' property_expr + | property_expr 'until_with' property_expr + | property_expr 's_until_with' property_expr + | property_expr 'implies' property_expr + | property_expr 'iff' property_expr + | 'accept_on' '(' expression_or_dist ')' property_expr + | 'reject_on' '(' expression_or_dist ')' property_expr + | 'sync_accept_on' '(' expression_or_dist ')' property_expr + | 'sync_reject_on' '(' expression_or_dist ')' property_expr + | property_instance + | clocking_event property_expr + ; + property_case_item - : expression_or_dist ( ',' expression_or_dist )* ':' property_expr ';' - | 'default' ':'? property_expr ';' - ; + : expression_or_dist (',' expression_or_dist)* ':' property_expr ';' + | 'default' ':'? property_expr ';' + ; + sequence_declaration - : 'sequence' sequence_identifier seq_port_list? ';' assertion_variable_declaration* sequence_expr ';'? 'endsequence' sequence_name? - ; + : 'sequence' sequence_identifier seq_port_list? ';' assertion_variable_declaration* sequence_expr ';'? 'endsequence' sequence_name? + ; + sequence_name - : ':' sequence_identifier - ; + : ':' sequence_identifier + ; + seq_port_list - : '(' sequence_port_list? ')' - ; + : '(' sequence_port_list? ')' + ; + sequence_port_list - : sequence_port_item ( ',' sequence_port_item )* - ; + : sequence_port_item (',' sequence_port_item)* + ; + sequence_port_item - : attribute_instance* seq_port_item_local? sequence_formal_type? formal_port_identifier variable_dimension* ( '=' sequence_actual_arg )? - ; + : attribute_instance* seq_port_item_local? sequence_formal_type? formal_port_identifier variable_dimension* ( + '=' sequence_actual_arg + )? + ; + seq_port_item_local - : 'local' sequence_lvar_port_direction? - ; + : 'local' sequence_lvar_port_direction? + ; + sequence_lvar_port_direction - : 'input' - | 'inout' - | 'output' - ; + : 'input' + | 'inout' + | 'output' + ; + sequence_formal_type - : data_type_or_implicit - | 'sequence' - | 'untyped' - ; + : data_type_or_implicit + | 'sequence' + | 'untyped' + ; + sequence_expr - : cycle_delay_range sequence_expr ( cycle_delay_range sequence_expr )* - | sequence_expr cycle_delay_range sequence_expr ( cycle_delay_range sequence_expr )* - | expression_or_dist boolean_abbrev? - | sequence_instance sequence_abbrev? - | '(' sequence_expr ( ',' sequence_match_item )* ')' sequence_abbrev? - | sequence_expr 'and' sequence_expr - | sequence_expr 'intersect' sequence_expr - | sequence_expr 'or' sequence_expr - | 'first_match' '(' sequence_expr ( ',' sequence_match_item )* ')' - | expression_or_dist 'throughout' sequence_expr - | sequence_expr 'within' sequence_expr - | clocking_event sequence_expr - ; + : cycle_delay_range sequence_expr (cycle_delay_range sequence_expr)* + | sequence_expr cycle_delay_range sequence_expr (cycle_delay_range sequence_expr)* + | expression_or_dist boolean_abbrev? + | sequence_instance sequence_abbrev? + | '(' sequence_expr ( ',' sequence_match_item)* ')' sequence_abbrev? + | sequence_expr 'and' sequence_expr + | sequence_expr 'intersect' sequence_expr + | sequence_expr 'or' sequence_expr + | 'first_match' '(' sequence_expr ( ',' sequence_match_item)* ')' + | expression_or_dist 'throughout' sequence_expr + | sequence_expr 'within' sequence_expr + | clocking_event sequence_expr + ; + cycle_delay_range - : '##' constant_primary - | '##' '[' cycle_delay_const_range_expression ']' - | '##' '[' '*' ']' - | '##' '[' '+' ']' - ; + : '##' constant_primary + | '##' '[' cycle_delay_const_range_expression ']' + | '##' '[' '*' ']' + | '##' '[' '+' ']' + ; + sequence_method_call - : ps_or_hierarchical_identifier seq_arg_list '.' method_identifier - ; + : ps_or_hierarchical_identifier seq_arg_list '.' method_identifier + ; + sequence_match_item - : operator_assignment - | inc_or_dec_expression - | subroutine_call - ; + : operator_assignment + | inc_or_dec_expression + | subroutine_call + ; + sequence_instance - : ps_or_hierarchical_identifier seq_arg_list? - ; + : ps_or_hierarchical_identifier seq_arg_list? + ; + seq_arg_list - : '(' sequence_list_of_arguments ')' - ; + : '(' sequence_list_of_arguments ')' + ; + sequence_list_of_arguments - : seq_ordered_arg ( ',' seq_ordered_arg )* ( ',' seq_named_arg )* - | seq_named_arg ( ',' seq_named_arg )* - ; + : seq_ordered_arg (',' seq_ordered_arg)* (',' seq_named_arg)* + | seq_named_arg ( ',' seq_named_arg)* + ; + seq_ordered_arg - : sequence_actual_arg? - ; + : sequence_actual_arg? + ; + seq_named_arg - : '.' identifier '(' sequence_actual_arg? ')' - ; + : '.' identifier '(' sequence_actual_arg? ')' + ; + sequence_actual_arg - : event_expression - | sequence_expr - ; + : event_expression + | sequence_expr + ; + boolean_abbrev - : consecutive_repetition - | non_consecutive_repetition - | goto_repetition - ; + : consecutive_repetition + | non_consecutive_repetition + | goto_repetition + ; + sequence_abbrev - : consecutive_repetition - ; + : consecutive_repetition + ; + consecutive_repetition - : '[' '*' const_or_range_expression ']' - | '[' '*' ']' - | '[' '+' ']' - ; + : '[' '*' const_or_range_expression ']' + | '[' '*' ']' + | '[' '+' ']' + ; + non_consecutive_repetition - : '[' '=' const_or_range_expression ']' - ; + : '[' '=' const_or_range_expression ']' + ; + goto_repetition - : '[' '->' const_or_range_expression ']' - ; + : '[' '->' const_or_range_expression ']' + ; + const_or_range_expression - : constant_expression - | cycle_delay_const_range_expression - ; + : constant_expression + | cycle_delay_const_range_expression + ; + cycle_delay_const_range_expression - : constant_expression ':' constant_expression - | constant_expression ':' '$' - ; + : constant_expression ':' constant_expression + | constant_expression ':' '$' + ; + expression_or_dist - : expression ( 'dist' '{' dist_list '}' )? - ; + : expression ('dist' '{' dist_list '}')? + ; + assertion_variable_declaration - : var_data_type list_of_variable_decl_assignments ';' - ; + : var_data_type list_of_variable_decl_assignments ';' + ; + // A.2.11 Covergroup declarations covergroup_declaration - : 'covergroup' covergroup_identifier port_list? coverage_event? ';' coverage_spec_or_option* 'endgroup' covergroup_name? - ; + : 'covergroup' covergroup_identifier port_list? coverage_event? ';' coverage_spec_or_option* 'endgroup' covergroup_name? + ; + covergroup_name - : ':' covergroup_identifier - ; + : ':' covergroup_identifier + ; + coverage_spec_or_option - : attribute_instance* coverage_spec - | attribute_instance* coverage_option ';' - ; + : attribute_instance* coverage_spec + | attribute_instance* coverage_option ';' + ; + coverage_option - : 'option' '.' member_identifier '=' expression - | 'type_option' '.' member_identifier '=' constant_expression - ; + : 'option' '.' member_identifier '=' expression + | 'type_option' '.' member_identifier '=' constant_expression + ; + coverage_spec - : cover_point - | cover_cross - ; + : cover_point + | cover_cross + ; + coverage_event - : clocking_event - | 'with' 'function' 'sample' '(' tf_port_list ')' - | '@@' '(' block_event_expression ')' - ; + : clocking_event + | 'with' 'function' 'sample' '(' tf_port_list ')' + | '@@' '(' block_event_expression ')' + ; + block_event_expression - : block_event_expression 'or' block_event_expression - | 'begin' hierarchical_btf_identifier - | 'end' hierarchical_btf_identifier - ; + : block_event_expression 'or' block_event_expression + | 'begin' hierarchical_btf_identifier + | 'end' hierarchical_btf_identifier + ; + hierarchical_btf_identifier - : class_scope? identifier - | hier_ref+ identifier - | '$root' '.' hier_ref* identifier - ; + : class_scope? identifier + | hier_ref+ identifier + | '$root' '.' hier_ref* identifier + ; + cover_point - : cover_point_label? 'coverpoint' expression ( 'iff' '(' expression ')' )? bins_or_empty - ; + : cover_point_label? 'coverpoint' expression ('iff' '(' expression ')')? bins_or_empty + ; + cover_point_label - : data_type_or_implicit? cover_point_identifier ':' - ; + : data_type_or_implicit? cover_point_identifier ':' + ; + bins_or_empty - : '{' attribute_instance* ( bins_or_options ';' )* '}' - | ';' - ; + : '{' attribute_instance* (bins_or_options ';')* '}' + | ';' + ; + bins_or_options - : coverage_option - | 'wildcard'? bins_keyword bin_identifier bin_array_size? '=' '{' covergroup_range_list '}' ( 'with' '(' with_covergroup_expression ')' )? ( 'iff' '(' expression ')' )? - | 'wildcard'? bins_keyword bin_identifier bin_array_size? '=' cover_point_identifier 'with' '(' with_covergroup_expression ')' ( 'iff' '(' expression ')' )? - | 'wildcard'? bins_keyword bin_identifier bin_array_size? '=' set_covergroup_expression ( 'iff' '(' expression ')' )? - | 'wildcard'? bins_keyword bin_identifier ( '[' ']' )? '=' trans_list ( 'iff' '(' expression ')' )? - | bins_keyword bin_identifier bin_array_size? '=' 'default' ( 'iff' '(' expression ')' )? - | bins_keyword bin_identifier '=' 'default' 'sequence' ( 'iff' '(' expression ')' )? - ; + : coverage_option + | 'wildcard'? bins_keyword bin_identifier bin_array_size? '=' '{' covergroup_range_list '}' ( + 'with' '(' with_covergroup_expression ')' + )? ('iff' '(' expression ')')? + | 'wildcard'? bins_keyword bin_identifier bin_array_size? '=' cover_point_identifier 'with' '(' with_covergroup_expression ')' ( + 'iff' '(' expression ')' + )? + | 'wildcard'? bins_keyword bin_identifier bin_array_size? '=' set_covergroup_expression ( + 'iff' '(' expression ')' + )? + | 'wildcard'? bins_keyword bin_identifier ('[' ']')? '=' trans_list ('iff' '(' expression ')')? + | bins_keyword bin_identifier bin_array_size? '=' 'default' ('iff' '(' expression ')')? + | bins_keyword bin_identifier '=' 'default' 'sequence' ('iff' '(' expression ')')? + ; + bin_array_size - : '[' covergroup_expression? ']' - ; + : '[' covergroup_expression? ']' + ; + bins_keyword - : 'bins' - | 'illegal_bins' - | 'ignore_bins' - ; + : 'bins' + | 'illegal_bins' + | 'ignore_bins' + ; + trans_list - : trans_set ( ',' trans_set )* - ; + : trans_set (',' trans_set)* + ; + trans_set - : '(' trans_range_list ( '=>' trans_range_list )* ')' - ; + : '(' trans_range_list ('=>' trans_range_list)* ')' + ; + trans_range_list - : trans_item - | trans_item '[' '*' repeat_range ']' - | trans_item '[' '->' repeat_range ']' - | trans_item '[' '=' repeat_range ']' - ; + : trans_item + | trans_item '[' '*' repeat_range ']' + | trans_item '[' '->' repeat_range ']' + | trans_item '[' '=' repeat_range ']' + ; + trans_item - : covergroup_range_list - ; + : covergroup_range_list + ; + repeat_range - : covergroup_expression ( ':' covergroup_expression )? - ; + : covergroup_expression (':' covergroup_expression)? + ; + cover_cross - : cross_label? 'cross' list_of_cross_items ( 'iff' '(' expression ')' )? cross_body - ; + : cross_label? 'cross' list_of_cross_items ('iff' '(' expression ')')? cross_body + ; + cross_label - : cross_identifier ':' - ; + : cross_identifier ':' + ; + list_of_cross_items - : cross_item ',' cross_item ( ',' cross_item )* - ; + : cross_item ',' cross_item (',' cross_item)* + ; + cross_item - : identifier - ; + : identifier + ; + cross_body - : '{' cross_body_item* '}' - | ';' - ; + : '{' cross_body_item* '}' + | ';' + ; + cross_body_item - : function_declaration - | bins_selection_or_option ';' - ; + : function_declaration + | bins_selection_or_option ';' + ; + bins_selection_or_option - : attribute_instance* coverage_option - | attribute_instance* bins_selection - ; + : attribute_instance* coverage_option + | attribute_instance* bins_selection + ; + bins_selection - : bins_keyword bin_identifier '=' select_expression ( 'iff' '(' expression ')' )? - ; + : bins_keyword bin_identifier '=' select_expression ('iff' '(' expression ')')? + ; + select_expression - : select_condition - | '!' select_condition - | select_expression '&&' select_expression - | select_expression '||' select_expression - | '(' select_expression ')' - | select_expression 'with' '(' with_covergroup_expression ')' ( 'matches' integer_covergroup_expression )? - | cross_identifier - | cross_set_expression ( 'matches' integer_covergroup_expression )? - ; + : select_condition + | '!' select_condition + | select_expression '&&' select_expression + | select_expression '||' select_expression + | '(' select_expression ')' + | select_expression 'with' '(' with_covergroup_expression ')' ( + 'matches' integer_covergroup_expression + )? + | cross_identifier + | cross_set_expression ( 'matches' integer_covergroup_expression)? + ; + select_condition - : 'binsof' '(' bins_expression ')' ( 'intersect' '{' covergroup_range_list '}' )? - ; + : 'binsof' '(' bins_expression ')' ('intersect' '{' covergroup_range_list '}')? + ; + bins_expression - : variable_identifier - | cover_point_identifier '.' bin_identifier - ; + : variable_identifier + | cover_point_identifier '.' bin_identifier + ; + covergroup_range_list - : covergroup_value_range ( ',' covergroup_value_range )* - ; + : covergroup_value_range (',' covergroup_value_range)* + ; + covergroup_value_range - : covergroup_expression - | '[' covergroup_expression ':' covergroup_expression ']' - ; + : covergroup_expression + | '[' covergroup_expression ':' covergroup_expression ']' + ; + with_covergroup_expression - : covergroup_expression - ; + : covergroup_expression + ; + set_covergroup_expression - : covergroup_expression - ; + : covergroup_expression + ; + integer_covergroup_expression - : covergroup_expression - ; + : covergroup_expression + ; + cross_set_expression - : covergroup_expression - ; + : covergroup_expression + ; + covergroup_expression - : expression - ; + : expression + ; + // A.2.12 Let declarations let_declaration - : 'let' let_identifier let_ports? '=' expression ';' - ; + : 'let' let_identifier let_ports? '=' expression ';' + ; + let_ports - : '(' let_port_list? ')' - ; + : '(' let_port_list? ')' + ; + let_identifier - : identifier - ; + : identifier + ; + let_port_list - : let_port_item ( ',' let_port_item )* - ; + : let_port_item (',' let_port_item)* + ; + let_port_item - : attribute_instance* let_formal_type? formal_port_identifier variable_dimension* ( '=' expression )? - ; + : attribute_instance* let_formal_type? formal_port_identifier variable_dimension* ( + '=' expression + )? + ; + let_formal_type - : data_type_or_implicit - | 'untyped' - ; + : data_type_or_implicit + | 'untyped' + ; + // A.3.1 Primitive instantiation and instances gate_instantiation - : cmos_switchtype delay3? cmos_switch_instance ( ',' cmos_switch_instance )* ';' - | enable_gatetype drive_strength? delay3? enable_gate_instance ( ',' enable_gate_instance )* ';' - | mos_switchtype delay3? mos_switch_instance ( ',' mos_switch_instance )* ';' - | n_input_gatetype drive_strength? delay2? n_input_gate_instance ( ',' n_input_gate_instance )* ';' - | n_output_gatetype drive_strength? delay2? n_output_gate_instance ( ',' n_output_gate_instance )* ';' - | pass_en_switchtype delay2? pass_enable_switch_instance ( ',' pass_enable_switch_instance )* ';' - | pass_switchtype pass_switch_instance ( ',' pass_switch_instance )* ';' - | 'pulldown' pulldown_strength? pull_gate_instance ( ',' pull_gate_instance )* ';' - | 'pullup' pullup_strength? pull_gate_instance ( ',' pull_gate_instance )* ';' - ; + : cmos_switchtype delay3? cmos_switch_instance (',' cmos_switch_instance)* ';' + | enable_gatetype drive_strength? delay3? enable_gate_instance (',' enable_gate_instance)* ';' + | mos_switchtype delay3? mos_switch_instance ( ',' mos_switch_instance)* ';' + | n_input_gatetype drive_strength? delay2? n_input_gate_instance (',' n_input_gate_instance)* ';' + | n_output_gatetype drive_strength? delay2? n_output_gate_instance (',' n_output_gate_instance)* ';' + | pass_en_switchtype delay2? pass_enable_switch_instance (',' pass_enable_switch_instance)* ';' + | pass_switchtype pass_switch_instance ( ',' pass_switch_instance)* ';' + | 'pulldown' pulldown_strength? pull_gate_instance (',' pull_gate_instance)* ';' + | 'pullup' pullup_strength? pull_gate_instance ( ',' pull_gate_instance)* ';' + ; + cmos_switch_instance - : name_of_instance? '(' output_terminal ',' input_terminal ',' ncontrol_terminal ',' pcontrol_terminal ')' - ; + : name_of_instance? '(' output_terminal ',' input_terminal ',' ncontrol_terminal ',' pcontrol_terminal ')' + ; + enable_gate_instance - : name_of_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' - ; + : name_of_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' + ; + mos_switch_instance - : name_of_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' - ; + : name_of_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' + ; + n_input_gate_instance - : name_of_instance? '(' output_terminal ',' input_terminal ( ',' input_terminal )* ')' - ; + : name_of_instance? '(' output_terminal ',' input_terminal (',' input_terminal)* ')' + ; + n_output_gate_instance - : name_of_instance? '(' output_terminal ( ',' output_terminal )* ',' input_terminal ')' - ; + : name_of_instance? '(' output_terminal (',' output_terminal)* ',' input_terminal ')' + ; + pass_switch_instance - : name_of_instance? '(' inout_terminal ',' inout_terminal ')' - ; + : name_of_instance? '(' inout_terminal ',' inout_terminal ')' + ; + pass_enable_switch_instance - : name_of_instance? '(' inout_terminal ',' inout_terminal ',' enable_terminal ')' - ; + : name_of_instance? '(' inout_terminal ',' inout_terminal ',' enable_terminal ')' + ; + pull_gate_instance - : name_of_instance? '(' output_terminal ')' - ; + : name_of_instance? '(' output_terminal ')' + ; + // A.3.2 Primitive strengths pulldown_strength - : '(' strength0 ',' strength1 ')' - | '(' strength1 ',' strength0 ')' - | '(' strength0 ')' - ; + : '(' strength0 ',' strength1 ')' + | '(' strength1 ',' strength0 ')' + | '(' strength0 ')' + ; + pullup_strength - : '(' strength0 ',' strength1 ')' - | '(' strength1 ',' strength0 ')' - | '(' strength1 ')' - ; + : '(' strength0 ',' strength1 ')' + | '(' strength1 ',' strength0 ')' + | '(' strength1 ')' + ; + // A.3.3 Primitive terminals enable_terminal - : expression - ; + : expression + ; + inout_terminal - : net_lvalue - ; + : net_lvalue + ; + input_terminal - : expression - ; + : expression + ; + ncontrol_terminal - : expression - ; + : expression + ; + output_terminal - : net_lvalue - ; + : net_lvalue + ; + pcontrol_terminal - : expression - ; + : expression + ; + // A.3.4 Primitive gate and switch types cmos_switchtype - : 'cmos' - | 'rcmos' - ; + : 'cmos' + | 'rcmos' + ; + enable_gatetype - : 'bufif0' - | 'bufif1' - | 'notif0' - | 'notif1' - ; + : 'bufif0' + | 'bufif1' + | 'notif0' + | 'notif1' + ; + mos_switchtype - : 'nmos' - | 'pmos' - | 'rnmos' - | 'rpmos' - ; + : 'nmos' + | 'pmos' + | 'rnmos' + | 'rpmos' + ; + n_input_gatetype - : 'and' - | 'nand' - | 'or' - | 'nor' - | 'xor' - | 'xnor' - ; + : 'and' + | 'nand' + | 'or' + | 'nor' + | 'xor' + | 'xnor' + ; + n_output_gatetype - : 'buf' - | 'not' - ; + : 'buf' + | 'not' + ; + pass_en_switchtype - : 'tranif0' - | 'tranif1' - | 'rtranif1' - | 'rtranif0' - ; + : 'tranif0' + | 'tranif1' + | 'rtranif1' + | 'rtranif0' + ; + pass_switchtype - : 'tran' - | 'rtran' - ; + : 'tran' + | 'rtran' + ; + // A.4.1.1 Module instantiation module_program_interface_instantiation - : instance_identifier parameter_value_assignment? hierarchical_instance ( ',' hierarchical_instance )* ';' - ; + : instance_identifier parameter_value_assignment? hierarchical_instance ( + ',' hierarchical_instance + )* ';' + ; + parameter_value_assignment - : '#' '(' list_of_parameter_assignments? ')' - ; + : '#' '(' list_of_parameter_assignments? ')' + ; + list_of_parameter_assignments - : ordered_parameter_assignment ( ',' ordered_parameter_assignment )* - | named_parameter_assignment ( ',' named_parameter_assignment )* - ; + : ordered_parameter_assignment (',' ordered_parameter_assignment)* + | named_parameter_assignment ( ',' named_parameter_assignment)* + ; + ordered_parameter_assignment - : param_expression - ; + : param_expression + ; + named_parameter_assignment - : '.' parameter_identifier '(' param_expression? ')' - ; + : '.' parameter_identifier '(' param_expression? ')' + ; + hierarchical_instance - : name_of_instance '(' list_of_port_connections ')' - ; + : name_of_instance '(' list_of_port_connections ')' + ; + name_of_instance - : instance_identifier unpacked_dimension* - ; + : instance_identifier unpacked_dimension* + ; + list_of_port_connections - : ordered_port_connection ( ',' ordered_port_connection )* - | named_port_connection ( ',' named_port_connection )* - ; + : ordered_port_connection (',' ordered_port_connection)* + | named_port_connection ( ',' named_port_connection)* + ; + ordered_port_connection - : attribute_instance* expression? - ; + : attribute_instance* expression? + ; + named_port_connection - : attribute_instance* '.' port_identifier port_assign? - | attribute_instance* '.*' - ; + : attribute_instance* '.' port_identifier port_assign? + | attribute_instance* '.*' + ; + port_assign - : '(' expression? ')' - ; + : '(' expression? ')' + ; + // A.4.1.4 Checker instantiation checker_instantiation - : ps_identifier name_of_instance '(' list_of_checker_port_connections ')' ';' - ; + : ps_identifier name_of_instance '(' list_of_checker_port_connections ')' ';' + ; + list_of_checker_port_connections - : ordered_checker_port_connection ( ',' ordered_checker_port_connection )* - | named_checker_port_connection ( ',' named_checker_port_connection )* - ; + : ordered_checker_port_connection (',' ordered_checker_port_connection)* + | named_checker_port_connection ( ',' named_checker_port_connection)* + ; + ordered_checker_port_connection - : attribute_instance* property_actual_arg? - ; + : attribute_instance* property_actual_arg? + ; + named_checker_port_connection - : attribute_instance* '.' formal_port_identifier checker_port_assign? - | attribute_instance* '.*' - ; + : attribute_instance* '.' formal_port_identifier checker_port_assign? + | attribute_instance* '.*' + ; + checker_port_assign - : '(' property_actual_arg? ')' - ; + : '(' property_actual_arg? ')' + ; + // A.4.2 Generated instantiation generate_region - : 'generate' generate_item* 'endgenerate' - ; + : 'generate' generate_item* 'endgenerate' + ; + loop_generate_construct - : 'for' '(' genvar_initialization ';' genvar_expression ';' genvar_iteration ')' generate_block - ; + : 'for' '(' genvar_initialization ';' genvar_expression ';' genvar_iteration ')' generate_block + ; + genvar_initialization - : 'genvar'? genvar_identifier '=' constant_expression - ; + : 'genvar'? genvar_identifier '=' constant_expression + ; + genvar_iteration - : genvar_identifier assignment_operator genvar_expression - | inc_or_dec_operator genvar_identifier - | genvar_identifier inc_or_dec_operator - ; + : genvar_identifier assignment_operator genvar_expression + | inc_or_dec_operator genvar_identifier + | genvar_identifier inc_or_dec_operator + ; + conditional_generate_construct - : if_generate_construct - | case_generate_construct - ; + : if_generate_construct + | case_generate_construct + ; + if_generate_construct - : 'if' '(' constant_expression ')' generate_block ( 'else' generate_block )? - ; + : 'if' '(' constant_expression ')' generate_block ('else' generate_block)? + ; + case_generate_construct - : 'case' '(' constant_expression ')' case_generate_item+ 'endcase' - ; + : 'case' '(' constant_expression ')' case_generate_item+ 'endcase' + ; + case_generate_item - : constant_expression ( ',' constant_expression )* ':' generate_block - | 'default' ':'? generate_block - ; + : constant_expression (',' constant_expression)* ':' generate_block + | 'default' ':'? generate_block + ; + generate_block - : generate_item - | generate_block_label? 'begin' generate_block_name? generate_item* 'end' generate_block_name? - ; + : generate_item + | generate_block_label? 'begin' generate_block_name? generate_item* 'end' generate_block_name? + ; + generate_block_label - : generate_block_identifier ':' - ; + : generate_block_identifier ':' + ; + generate_block_name - : ':' generate_block_identifier - ; + : ':' generate_block_identifier + ; + generate_item - : attribute_instance* parameter_override - | attribute_instance* gate_instantiation - | attribute_instance* net_declaration - | ( attribute_instance+ | 'rand' )? data_declaration - | attribute_instance* task_declaration - | attribute_instance* function_declaration - | attribute_instance* checker_declaration - | attribute_instance* dpi_import_export - | attribute_instance* extern_constraint_declaration - | attribute_instance* class_declaration - | attribute_instance* interface_class_declaration - | attribute_instance* class_constructor_declaration - | attribute_instance* local_parameter_declaration ';' - | attribute_instance* parameter_declaration ';' - | attribute_instance* covergroup_declaration - | attribute_instance* assertion_item_declaration - | attribute_instance* ';' - | attribute_instance* genvar_declaration - | attribute_instance* clocking_declaration - | attribute_instance* 'default' 'clocking' clocking_identifier ';' - | attribute_instance* 'default' 'disable' 'iff' expression_or_dist ';' - | attribute_instance* module_program_interface_instantiation - | attribute_instance* assertion_item - | attribute_instance* udp_instantiation - | attribute_instance* bind_directive - | attribute_instance* continuous_assign - | attribute_instance* net_alias - | attribute_instance* initial_construct - | attribute_instance* final_construct - | attribute_instance* always_construct - | attribute_instance* loop_generate_construct - | attribute_instance* conditional_generate_construct - | attribute_instance* elaboration_system_task - | attribute_instance* extern_tf_declaration - | generate_region - ; + : attribute_instance* parameter_override + | attribute_instance* gate_instantiation + | attribute_instance* net_declaration + | ( attribute_instance+ | 'rand')? data_declaration + | attribute_instance* task_declaration + | attribute_instance* function_declaration + | attribute_instance* checker_declaration + | attribute_instance* dpi_import_export + | attribute_instance* extern_constraint_declaration + | attribute_instance* class_declaration + | attribute_instance* interface_class_declaration + | attribute_instance* class_constructor_declaration + | attribute_instance* local_parameter_declaration ';' + | attribute_instance* parameter_declaration ';' + | attribute_instance* covergroup_declaration + | attribute_instance* assertion_item_declaration + | attribute_instance* ';' + | attribute_instance* genvar_declaration + | attribute_instance* clocking_declaration + | attribute_instance* 'default' 'clocking' clocking_identifier ';' + | attribute_instance* 'default' 'disable' 'iff' expression_or_dist ';' + | attribute_instance* module_program_interface_instantiation + | attribute_instance* assertion_item + | attribute_instance* udp_instantiation + | attribute_instance* bind_directive + | attribute_instance* continuous_assign + | attribute_instance* net_alias + | attribute_instance* initial_construct + | attribute_instance* final_construct + | attribute_instance* always_construct + | attribute_instance* loop_generate_construct + | attribute_instance* conditional_generate_construct + | attribute_instance* elaboration_system_task + | attribute_instance* extern_tf_declaration + | generate_region + ; + // A.5.1 UDP declaration udp_nonansi_declaration - : attribute_instance* 'primitive' udp_identifier '(' udp_port_list ')' ';' - ; + : attribute_instance* 'primitive' udp_identifier '(' udp_port_list ')' ';' + ; + udp_ansi_declaration - : attribute_instance* 'primitive' udp_identifier '(' udp_declaration_port_list ')' ';' - ; + : attribute_instance* 'primitive' udp_identifier '(' udp_declaration_port_list ')' ';' + ; + udp_declaration - : udp_nonansi_declaration udp_port_declaration+ udp_body 'endprimitive' udp_name? - | udp_ansi_declaration udp_body 'endprimitive' udp_name? - | 'extern' udp_nonansi_declaration - | 'extern' udp_ansi_declaration - | attribute_instance* 'primitive' udp_identifier '(' '.*' ')' ';' udp_port_declaration* udp_body 'endprimitive' udp_name? - ; + : udp_nonansi_declaration udp_port_declaration+ udp_body 'endprimitive' udp_name? + | udp_ansi_declaration udp_body 'endprimitive' udp_name? + | 'extern' udp_nonansi_declaration + | 'extern' udp_ansi_declaration + | attribute_instance* 'primitive' udp_identifier '(' '.*' ')' ';' udp_port_declaration* udp_body 'endprimitive' udp_name? + ; + udp_name - : ':' udp_identifier - ; + : ':' udp_identifier + ; + // A.5.2 UDP ports udp_port_list - : output_port_identifier ',' input_port_identifier ( ',' input_port_identifier )* - ; + : output_port_identifier ',' input_port_identifier (',' input_port_identifier)* + ; + udp_declaration_port_list - : udp_output_declaration ',' udp_input_declaration ( ',' udp_input_declaration )* - ; + : udp_output_declaration ',' udp_input_declaration (',' udp_input_declaration)* + ; + udp_port_declaration - : udp_output_declaration ';' - | udp_input_declaration ';' - | udp_reg_declaration ';' - ; + : udp_output_declaration ';' + | udp_input_declaration ';' + | udp_reg_declaration ';' + ; + udp_output_declaration - : attribute_instance* 'output' port_identifier - | attribute_instance* 'output' 'reg' port_identifier ( '=' constant_expression )? - ; + : attribute_instance* 'output' port_identifier + | attribute_instance* 'output' 'reg' port_identifier ('=' constant_expression)? + ; + udp_input_declaration - : attribute_instance* 'input' list_of_udp_port_identifiers - ; + : attribute_instance* 'input' list_of_udp_port_identifiers + ; + udp_reg_declaration - : attribute_instance* 'reg' variable_identifier - ; + : attribute_instance* 'reg' variable_identifier + ; + // A.5.3 UDP body udp_body - : combinational_body - | sequential_body - ; + : combinational_body + | sequential_body + ; + combinational_body - : 'table' combinational_entry+ 'endtable' - ; + : 'table' combinational_entry+ 'endtable' + ; + combinational_entry - : level_input_list ':' output_symbol ';' - ; + : level_input_list ':' output_symbol ';' + ; + sequential_body - : udp_initial_statement? 'table' sequential_entry+ 'endtable' - ; + : udp_initial_statement? 'table' sequential_entry+ 'endtable' + ; + udp_initial_statement - : 'initial' output_port_identifier '=' init_val ';' - ; + : 'initial' output_port_identifier '=' init_val ';' + ; + init_val - : binary_number - | unsigned_number - ; + : binary_number + | unsigned_number + ; + sequential_entry - : seq_input_list ':' current_state ':' next_state ';' - ; + : seq_input_list ':' current_state ':' next_state ';' + ; + seq_input_list - : level_input_list - | edge_input_list - ; + : level_input_list + | edge_input_list + ; + level_input_list - : level_symbol+ - ; + : level_symbol+ + ; + edge_input_list - : level_symbol* edge_indicator level_symbol* - ; + : level_symbol* edge_indicator level_symbol* + ; + edge_indicator - : '(' level_symbol level_symbol ')' - | edge_symbol - ; + : '(' level_symbol level_symbol ')' + | edge_symbol + ; + current_state - : level_symbol - ; + : level_symbol + ; + next_state - : output_symbol - | '-' - ; + : output_symbol + | '-' + ; + output_symbol - : OUTPUT_OR_LEVEL_SYMBOL - ; + : OUTPUT_OR_LEVEL_SYMBOL + ; + level_symbol - : LEVEL_ONLY_SYMBOL - | OUTPUT_OR_LEVEL_SYMBOL - ; + : LEVEL_ONLY_SYMBOL + | OUTPUT_OR_LEVEL_SYMBOL + ; + edge_symbol - : EDGE_SYMBOL - ; + : EDGE_SYMBOL + ; + // A.5.4 UDP instantiation udp_instantiation - : udp_identifier drive_strength? delay2? udp_instance ( ',' udp_instance )* ';' - ; + : udp_identifier drive_strength? delay2? udp_instance (',' udp_instance)* ';' + ; + udp_instance - : name_of_instance? '(' output_terminal ',' input_terminal ( ',' input_terminal )* ')' - ; + : name_of_instance? '(' output_terminal ',' input_terminal (',' input_terminal)* ')' + ; + // A.6.1 Continuous assignment and net alias statements continuous_assign - : 'assign' '#' '(' mintypmax_expression ',' mintypmax_expression ( ',' mintypmax_expression )? ')' list_of_net_assignments ';' - | 'assign' drive_strength delay3? list_of_net_assignments ';' - | 'assign' delay_control? list_of_variable_assignments ';' - ; + : 'assign' '#' '(' mintypmax_expression ',' mintypmax_expression (',' mintypmax_expression)? ')' list_of_net_assignments ';' + | 'assign' drive_strength delay3? list_of_net_assignments ';' + | 'assign' delay_control? list_of_variable_assignments ';' + ; + list_of_net_assignments - : net_assignment ( ',' net_assignment )* - ; + : net_assignment (',' net_assignment)* + ; + list_of_variable_assignments - : variable_assignment ( ',' variable_assignment )* - ; + : variable_assignment (',' variable_assignment)* + ; + net_alias - : 'alias' net_lvalue ( '=' net_lvalue )+ ';' - ; + : 'alias' net_lvalue ('=' net_lvalue)+ ';' + ; + net_assignment - : net_lvalue '=' expression - ; + : net_lvalue '=' expression + ; + // A.6.2 Procedural blocks and assignments initial_construct - : 'initial' statement_or_null - ; + : 'initial' statement_or_null + ; + always_construct - : always_keyword statement - ; + : always_keyword statement + ; + always_keyword - : 'always' - | 'always_comb' - | 'always_latch' - | 'always_ff' - ; + : 'always' + | 'always_comb' + | 'always_latch' + | 'always_ff' + ; + final_construct - : 'final' function_statement - ; + : 'final' function_statement + ; + blocking_assignment - : variable_lvalue '=' delay_or_event_control expression - | nonrange_variable_lvalue '=' dynamic_array_new - | ( implicit_class_handle '.' | package_or_class_scope )? hierarchical_identifier select_? '=' class_new - | operator_assignment - ; + : variable_lvalue '=' delay_or_event_control expression + | nonrange_variable_lvalue '=' dynamic_array_new + | (implicit_class_handle '.' | package_or_class_scope)? hierarchical_identifier select_? '=' class_new + | operator_assignment + ; + operator_assignment - : variable_lvalue assignment_operator expression - ; + : variable_lvalue assignment_operator expression + ; + assignment_operator - : '=' - | '+=' - | '-=' - | '*=' - | '/=' - | '%=' - | '&=' - | '|=' - | '^=' - | '<<=' - | '>>=' - | '<<<=' - | '>>>=' - ; + : '=' + | '+=' + | '-=' + | '*=' + | '/=' + | '%=' + | '&=' + | '|=' + | '^=' + | '<<=' + | '>>=' + | '<<<=' + | '>>>=' + ; + nonblocking_assignment - : variable_lvalue '<=' delay_or_event_control? expression - ; + : variable_lvalue '<=' delay_or_event_control? expression + ; + procedural_continuous_assignment - : 'assign' variable_assignment - | 'deassign' variable_lvalue - | 'force' variable_assignment - | 'release' variable_lvalue - ; + : 'assign' variable_assignment + | 'deassign' variable_lvalue + | 'force' variable_assignment + | 'release' variable_lvalue + ; + variable_assignment - : variable_lvalue '=' expression - ; + : variable_lvalue '=' expression + ; + // A.6.3 Parallel and sequential blocks action_block - : statement_or_null - | statement? 'else' statement_or_null - ; + : statement_or_null + | statement? 'else' statement_or_null + ; + seq_block - : 'begin' block_name? block_item_declaration* statement_or_null* 'end' block_name? - ; + : 'begin' block_name? block_item_declaration* statement_or_null* 'end' block_name? + ; + block_name - : ':' block_identifier - ; + : ':' block_identifier + ; + par_block - : 'fork' block_name? block_item_declaration* statement_or_null* join_keyword block_name? - ; + : 'fork' block_name? block_item_declaration* statement_or_null* join_keyword block_name? + ; + join_keyword - : 'join' - | 'join_any' - | 'join_none' - ; + : 'join' + | 'join_any' + | 'join_none' + ; + // A.6.4 Statements statement_or_null - : statement - | attribute_instance* ';' - ; + : statement + | attribute_instance* ';' + ; + statement - : block_label? attribute_instance* statement_item - ; + : block_label? attribute_instance* statement_item + ; + statement_item - : blocking_assignment ';' - | nonblocking_assignment ';' - | procedural_continuous_assignment ';' - | case_statement - | conditional_statement - | inc_or_dec_expression ';' - | subroutine_call_statement - | disable_statement - | event_trigger - | loop_statement - | jump_statement - | par_block - | procedural_timing_control_statement - | seq_block - | wait_statement - | procedural_assertion_statement - | clocking_drive ';' - | randsequence_statement - | randcase_statement - | expect_property_statement - ; + : blocking_assignment ';' + | nonblocking_assignment ';' + | procedural_continuous_assignment ';' + | case_statement + | conditional_statement + | inc_or_dec_expression ';' + | subroutine_call_statement + | disable_statement + | event_trigger + | loop_statement + | jump_statement + | par_block + | procedural_timing_control_statement + | seq_block + | wait_statement + | procedural_assertion_statement + | clocking_drive ';' + | randsequence_statement + | randcase_statement + | expect_property_statement + ; + function_statement - : statement - ; + : statement + ; + function_statement_or_null - : function_statement - | attribute_instance* ';' - ; + : function_statement + | attribute_instance* ';' + ; + variable_identifier_list - : variable_identifier ( ',' variable_identifier )* - ; + : variable_identifier (',' variable_identifier)* + ; + // A.6.5 Timing control statements procedural_timing_control_statement - : procedural_timing_control statement_or_null - ; + : procedural_timing_control statement_or_null + ; + delay_or_event_control - : delay_control - | event_control - | 'repeat' '(' expression ')' event_control - ; + : delay_control + | event_control + | 'repeat' '(' expression ')' event_control + ; + delay_control - : '#' delay_value - | '#' '(' mintypmax_expression ')' - ; + : '#' delay_value + | '#' '(' mintypmax_expression ')' + ; + event_control - : '@' '(' event_expression ')' - | '@' '*' - | '@' '(' '*' ')' - | '@' ps_or_hierarchical_identifier - ; + : '@' '(' event_expression ')' + | '@' '*' + | '@' '(' '*' ')' + | '@' ps_or_hierarchical_identifier + ; + event_expression - : edge_identifier? expression ( 'iff' expression )? - | sequence_instance ( 'iff' expression )? - | event_expression 'or' event_expression - | event_expression ',' event_expression - | '(' event_expression ')' - ; + : edge_identifier? expression ('iff' expression)? + | sequence_instance ( 'iff' expression)? + | event_expression 'or' event_expression + | event_expression ',' event_expression + | '(' event_expression ')' + ; + procedural_timing_control - : delay_control - | event_control - | cycle_delay - ; + : delay_control + | event_control + | cycle_delay + ; + jump_statement - : 'return' expression? ';' - | 'break' ';' - | 'continue' ';' - ; + : 'return' expression? ';' + | 'break' ';' + | 'continue' ';' + ; + wait_statement - : 'wait' '(' expression ')' statement_or_null - | 'wait' 'fork' ';' - | 'wait_order' '(' hierarchical_identifier ( ',' hierarchical_identifier )* ')' action_block - ; + : 'wait' '(' expression ')' statement_or_null + | 'wait' 'fork' ';' + | 'wait_order' '(' hierarchical_identifier (',' hierarchical_identifier)* ')' action_block + ; + event_trigger - : '->' hierarchical_identifier ';' - | '->>' delay_or_event_control? hierarchical_identifier ';' - ; + : '->' hierarchical_identifier ';' + | '->>' delay_or_event_control? hierarchical_identifier ';' + ; + disable_statement - : 'disable' hierarchical_identifier ';' - | 'disable' 'fork' ';' - ; + : 'disable' hierarchical_identifier ';' + | 'disable' 'fork' ';' + ; + // A.6.6 Conditional statements conditional_statement - : unique_priority? 'if' '(' cond_predicate ')' statement_or_null ( 'else' statement_or_null )? - ; + : unique_priority? 'if' '(' cond_predicate ')' statement_or_null ('else' statement_or_null)? + ; + unique_priority - : 'unique' - | 'unique0' - | 'priority' - ; + : 'unique' + | 'unique0' + | 'priority' + ; + cond_predicate - : expression_or_cond_pattern ( '&&&' expression_or_cond_pattern )* - ; + : expression_or_cond_pattern ('&&&' expression_or_cond_pattern)* + ; + expression_or_cond_pattern - : expression ( 'matches' pattern )? - ; + : expression ('matches' pattern)? + ; + // A.6.7 Case statements case_statement - : unique_priority? case_keyword '(' case_expression ')' case_item+ 'endcase' - | unique_priority? case_keyword '(' case_expression ')' 'matches' case_pattern_item+ 'endcase' - | unique_priority? 'case' '(' case_expression ')' 'inside' case_inside_item+ 'endcase' - ; + : unique_priority? case_keyword '(' case_expression ')' case_item+ 'endcase' + | unique_priority? case_keyword '(' case_expression ')' 'matches' case_pattern_item+ 'endcase' + | unique_priority? 'case' '(' case_expression ')' 'inside' case_inside_item+ 'endcase' + ; + case_keyword - : 'case' - | 'casez' - | 'casex' - ; + : 'case' + | 'casez' + | 'casex' + ; + case_expression - : expression - ; + : expression + ; + case_item - : case_item_expression ( ',' case_item_expression )* ':' statement_or_null - | 'default' ':'? statement_or_null - ; + : case_item_expression (',' case_item_expression)* ':' statement_or_null + | 'default' ':'? statement_or_null + ; + case_pattern_item - : pattern ( '&&&' expression )? ':' statement_or_null - | 'default' ':'? statement_or_null - ; + : pattern ('&&&' expression)? ':' statement_or_null + | 'default' ':'? statement_or_null + ; + case_inside_item - : open_range_list ':' statement_or_null - | 'default' ':'? statement_or_null - ; + : open_range_list ':' statement_or_null + | 'default' ':'? statement_or_null + ; + case_item_expression - : expression - ; + : expression + ; + randcase_statement - : 'randcase' randcase_item+ 'endcase' - ; + : 'randcase' randcase_item+ 'endcase' + ; + randcase_item - : expression ':' statement_or_null - ; + : expression ':' statement_or_null + ; + open_range_list - : open_value_range ( ',' open_value_range )* - ; + : open_value_range (',' open_value_range)* + ; + open_value_range - : value_range - ; + : value_range + ; + // A.6.7.1 Patterns pattern - : '.' variable_identifier - | '.*' - | constant_expression - | 'tagged' member_identifier pattern? - | '\'' '{' pattern ( ',' pattern )* '}' - | '\'' '{' member_pattern_pair ( ',' member_pattern_pair )* '}' - ; + : '.' variable_identifier + | '.*' + | constant_expression + | 'tagged' member_identifier pattern? + | '\'' '{' pattern ( ',' pattern)* '}' + | '\'' '{' member_pattern_pair ( ',' member_pattern_pair)* '}' + ; + member_pattern_pair - : member_identifier ':' pattern - ; + : member_identifier ':' pattern + ; + assignment_pattern - : '\'' '{' expression ( ',' expression )* '}' - | '\'' '{' array_key_val_pair ( ',' array_key_val_pair )* '}' - | '\'' '{' constant_expression '{' expression ( ',' expression )* '}' '}' - ; + : '\'' '{' expression (',' expression)* '}' + | '\'' '{' array_key_val_pair ( ',' array_key_val_pair)* '}' + | '\'' '{' constant_expression '{' expression ( ',' expression)* '}' '}' + ; + array_key_val_pair - : array_pattern_key ':' expression - ; + : array_pattern_key ':' expression + ; + array_pattern_key - : constant_expression - | assignment_pattern_key - ; + : constant_expression + | assignment_pattern_key + ; + assignment_pattern_key - : integer_type - | non_integer_type - | 'local' '::' identifier - | 'default' - ; + : integer_type + | non_integer_type + | 'local' '::' identifier + | 'default' + ; + assignment_pattern_expression - : assignment_pattern_expression_type? assignment_pattern - ; + : assignment_pattern_expression_type? assignment_pattern + ; + assignment_pattern_expression_type - : ps_type_or_parameter_identifier - | integer_atom_type - | type_reference - ; + : ps_type_or_parameter_identifier + | integer_atom_type + | type_reference + ; + constant_assignment_pattern_expression - : assignment_pattern_expression - ; + : assignment_pattern_expression + ; + assignment_pattern_net_lvalue - : '\'' '{' net_lvalue ( ',' net_lvalue )* '}' - ; + : '\'' '{' net_lvalue (',' net_lvalue)* '}' + ; + assignment_pattern_variable_lvalue - : '\'' '{' variable_lvalue ( ',' variable_lvalue )* '}' - ; + : '\'' '{' variable_lvalue (',' variable_lvalue)* '}' + ; + // A.6.8 Looping statements loop_statement - : 'forever' statement_or_null - | 'repeat' '(' expression ')' statement_or_null - | 'while' '(' expression ')' statement_or_null - | 'for' '(' for_initialization? ';' expression? ';' for_step? ')' statement_or_null - | 'do' statement_or_null 'while' '(' expression ')' ';' - | 'foreach' '(' ps_or_hierarchical_array_identifier '[' loop_variables ']' ')' statement - ; + : 'forever' statement_or_null + | 'repeat' '(' expression ')' statement_or_null + | 'while' '(' expression ')' statement_or_null + | 'for' '(' for_initialization? ';' expression? ';' for_step? ')' statement_or_null + | 'do' statement_or_null 'while' '(' expression ')' ';' + | 'foreach' '(' ps_or_hierarchical_array_identifier '[' loop_variables ']' ')' statement + ; + for_initialization - : list_of_variable_assignments - | for_variable_declaration ( ',' for_variable_declaration )* - ; + : list_of_variable_assignments + | for_variable_declaration ( ',' for_variable_declaration)* + ; + for_variable_declaration - : 'var'? data_type for_variable_assign ( ',' for_variable_assign )* - ; + : 'var'? data_type for_variable_assign (',' for_variable_assign)* + ; + for_variable_assign - : variable_identifier '=' expression - ; + : variable_identifier '=' expression + ; + for_step - : for_step_assignment ( ',' for_step_assignment )* - ; + : for_step_assignment (',' for_step_assignment)* + ; + for_step_assignment - : operator_assignment - | inc_or_dec_expression - | subroutine_call - ; + : operator_assignment + | inc_or_dec_expression + | subroutine_call + ; + loop_variables - : loop_var ( ',' loop_var )* - ; + : loop_var (',' loop_var)* + ; + loop_var - : index_variable_identifier? - ; + : index_variable_identifier? + ; + // A.6.9 Subroutine call statements subroutine_call_statement - : subroutine_call ';' - | 'void' '\'' '(' subroutine_call ')' ';' - ; + : subroutine_call ';' + | 'void' '\'' '(' subroutine_call ')' ';' + ; + // A.6.10 Assertion statements assertion_item - : concurrent_assertion_item - | deferred_immediate_assertion_item - ; + : concurrent_assertion_item + | deferred_immediate_assertion_item + ; + deferred_immediate_assertion_item - : block_label? deferred_immediate_assertion_statement - ; + : block_label? deferred_immediate_assertion_statement + ; + procedural_assertion_statement - : concurrent_assertion_statement - | immediate_assertion_statement - | checker_instantiation - ; + : concurrent_assertion_statement + | immediate_assertion_statement + | checker_instantiation + ; + immediate_assertion_statement - : simple_immediate_assertion_statement - | deferred_immediate_assertion_statement - ; + : simple_immediate_assertion_statement + | deferred_immediate_assertion_statement + ; + simple_immediate_assertion_statement - : simple_immediate_assert_statement - | simple_immediate_assume_statement - | simple_immediate_cover_statement - ; + : simple_immediate_assert_statement + | simple_immediate_assume_statement + | simple_immediate_cover_statement + ; + simple_immediate_assert_statement - : 'assert' '(' expression ')' action_block - ; + : 'assert' '(' expression ')' action_block + ; + simple_immediate_assume_statement - : 'assume' '(' expression ')' action_block - ; + : 'assume' '(' expression ')' action_block + ; + simple_immediate_cover_statement - : 'cover' '(' expression ')' statement_or_null - ; + : 'cover' '(' expression ')' statement_or_null + ; + deferred_immediate_assertion_statement - : deferred_immediate_assert_statement - | deferred_immediate_assume_statement - | deferred_immediate_cover_statement - ; + : deferred_immediate_assert_statement + | deferred_immediate_assume_statement + | deferred_immediate_cover_statement + ; + deferred_immediate_assert_statement - : 'assert' '#' unsigned_number '(' expression ')' action_block - | 'assert' 'final' '(' expression ')' action_block - ; + : 'assert' '#' unsigned_number '(' expression ')' action_block + | 'assert' 'final' '(' expression ')' action_block + ; + deferred_immediate_assume_statement - : 'assume' '#' unsigned_number '(' expression ')' action_block - | 'assume' 'final' '(' expression ')' action_block - ; + : 'assume' '#' unsigned_number '(' expression ')' action_block + | 'assume' 'final' '(' expression ')' action_block + ; + deferred_immediate_cover_statement - : 'cover' '#' unsigned_number '(' expression ')' statement_or_null - | 'cover' 'final' '(' expression ')' statement_or_null - ; + : 'cover' '#' unsigned_number '(' expression ')' statement_or_null + | 'cover' 'final' '(' expression ')' statement_or_null + ; + // A.6.11 Clocking block clocking_declaration - : 'default'? 'clocking' clocking_identifier? clocking_event ';' clocking_item* 'endclocking' clocking_name? - | 'global' 'clocking' clocking_identifier? clocking_event ';' 'endclocking' clocking_name? - ; + : 'default'? 'clocking' clocking_identifier? clocking_event ';' clocking_item* 'endclocking' clocking_name? + | 'global' 'clocking' clocking_identifier? clocking_event ';' 'endclocking' clocking_name? + ; + clocking_name - : ':' clocking_identifier - ; + : ':' clocking_identifier + ; + clocking_event - : '@' identifier - | '@' '(' event_expression ')' - ; + : '@' identifier + | '@' '(' event_expression ')' + ; + clocking_item - : 'default' default_skew ';' - | clocking_direction list_of_clocking_decl_assign ';' - | attribute_instance* assertion_item_declaration - ; + : 'default' default_skew ';' + | clocking_direction list_of_clocking_decl_assign ';' + | attribute_instance* assertion_item_declaration + ; + default_skew - : 'input' clocking_skew - | 'output' clocking_skew - | 'input' clocking_skew 'output' clocking_skew - ; + : 'input' clocking_skew + | 'output' clocking_skew + | 'input' clocking_skew 'output' clocking_skew + ; + clocking_direction - : 'input' clocking_skew? - | 'output' clocking_skew? - | 'input' clocking_skew? 'output' clocking_skew? - | 'inout' - ; + : 'input' clocking_skew? + | 'output' clocking_skew? + | 'input' clocking_skew? 'output' clocking_skew? + | 'inout' + ; + list_of_clocking_decl_assign - : clocking_decl_assign ( ',' clocking_decl_assign )* - ; + : clocking_decl_assign (',' clocking_decl_assign)* + ; + clocking_decl_assign - : signal_identifier ( '=' expression )? - ; + : signal_identifier ('=' expression)? + ; + clocking_skew - : edge_identifier delay_control? - | delay_control - ; + : edge_identifier delay_control? + | delay_control + ; + clocking_drive - : clockvar_expression '<=' cycle_delay expression - ; + : clockvar_expression '<=' cycle_delay expression + ; + cycle_delay - : '##' integral_number - | '##' identifier - | '##' '(' expression ')' - ; + : '##' integral_number + | '##' identifier + | '##' '(' expression ')' + ; + clockvar - : hierarchical_identifier - ; + : hierarchical_identifier + ; + clockvar_expression - : clockvar select_? - ; + : clockvar select_? + ; + // A.6.12 Randsequence randsequence_statement - : 'randsequence' '(' production_identifier? ')' production+ 'endsequence' - ; + : 'randsequence' '(' production_identifier? ')' production+ 'endsequence' + ; + production - : data_type_or_void? production_identifier port_list? ':' rs_rule ( '|' rs_rule )* ';' - ; + : data_type_or_void? production_identifier port_list? ':' rs_rule ('|' rs_rule)* ';' + ; + rs_rule - : rs_production_list weight_spec? - ; + : rs_production_list weight_spec? + ; + weight_spec - : ':=' weight_specification rs_code_block? - ; + : ':=' weight_specification rs_code_block? + ; + rs_production_list - : rs_prod+ - | 'rand' 'join' ( '(' expression ')' )? production_item+ - ; + : rs_prod+ + | 'rand' 'join' ( '(' expression ')')? production_item+ + ; + weight_specification - : integral_number - | ps_identifier - | '(' expression ')' - ; + : integral_number + | ps_identifier + | '(' expression ')' + ; + rs_code_block - : '{' data_declaration* statement_or_null* '}' - ; + : '{' data_declaration* statement_or_null* '}' + ; + rs_prod - : production_item - | rs_code_block - | rs_if_else - | rs_repeat - | rs_case - ; + : production_item + | rs_code_block + | rs_if_else + | rs_repeat + | rs_case + ; + production_item - : production_identifier arg_list? - ; + : production_identifier arg_list? + ; + rs_if_else - : 'if' '(' expression ')' production_item ( 'else' production_item )? - ; + : 'if' '(' expression ')' production_item ('else' production_item)? + ; + rs_repeat - : 'repeat' '(' expression ')' production_item - ; + : 'repeat' '(' expression ')' production_item + ; + rs_case - : 'case' '(' case_expression ')' rs_case_item+ 'endcase' - ; + : 'case' '(' case_expression ')' rs_case_item+ 'endcase' + ; + rs_case_item - : case_item_expression ( ',' case_item_expression )* ':' production_item ';' - | 'default' ':'? production_item ';' - ; + : case_item_expression (',' case_item_expression)* ':' production_item ';' + | 'default' ':'? production_item ';' + ; + // A.7.1 Specify block declaration specify_block - : 'specify' specify_item* 'endspecify' - ; + : 'specify' specify_item* 'endspecify' + ; + specify_item - : specparam_declaration - | pulsestyle_declaration - | showcancelled_declaration - | path_declaration - | system_timing_check - ; + : specparam_declaration + | pulsestyle_declaration + | showcancelled_declaration + | path_declaration + | system_timing_check + ; + pulsestyle_declaration - : 'pulsestyle_onevent' list_of_path_outputs ';' - | 'pulsestyle_ondetect' list_of_path_outputs ';' - ; + : 'pulsestyle_onevent' list_of_path_outputs ';' + | 'pulsestyle_ondetect' list_of_path_outputs ';' + ; + showcancelled_declaration - : 'showcancelled' list_of_path_outputs ';' - | 'noshowcancelled' list_of_path_outputs ';' - ; + : 'showcancelled' list_of_path_outputs ';' + | 'noshowcancelled' list_of_path_outputs ';' + ; + // A.7.2 Specify path declarations path_declaration - : simple_path_declaration ';' - | edge_sensitive_path_declaration ';' - | state_dependent_path_declaration ';' - ; + : simple_path_declaration ';' + | edge_sensitive_path_declaration ';' + | state_dependent_path_declaration ';' + ; + simple_path_declaration - : parallel_path_description '=' path_delay_value - | full_path_description '=' path_delay_value - ; + : parallel_path_description '=' path_delay_value + | full_path_description '=' path_delay_value + ; + parallel_path_description - : '(' specify_input_terminal_descriptor polarity_operator? '=>' specify_output_terminal_descriptor ')' - ; + : '(' specify_input_terminal_descriptor polarity_operator? '=>' specify_output_terminal_descriptor ')' + ; + full_path_description - : '(' list_of_path_inputs polarity_operator? '*>' list_of_path_outputs ')' - ; + : '(' list_of_path_inputs polarity_operator? '*>' list_of_path_outputs ')' + ; + list_of_path_inputs - : specify_input_terminal_descriptor ( ',' specify_input_terminal_descriptor )* - ; + : specify_input_terminal_descriptor (',' specify_input_terminal_descriptor)* + ; + list_of_path_outputs - : specify_output_terminal_descriptor ( ',' specify_output_terminal_descriptor )* - ; + : specify_output_terminal_descriptor (',' specify_output_terminal_descriptor)* + ; + // A.7.3 Specify block terminals specify_input_terminal_descriptor - : input_identifier ( '[' constant_range_expression ']' )? - ; + : input_identifier ('[' constant_range_expression ']')? + ; + specify_output_terminal_descriptor - : output_identifier ( '[' constant_range_expression ']' )? - ; + : output_identifier ('[' constant_range_expression ']')? + ; + input_identifier - : port_identifier - | interface_identifier '.' port_identifier - ; + : port_identifier + | interface_identifier '.' port_identifier + ; + output_identifier - : port_identifier - | interface_identifier '.' port_identifier - ; + : port_identifier + | interface_identifier '.' port_identifier + ; + // A.7.4 Specify path delays path_delay_value - : list_of_path_delay_expressions - | '(' list_of_path_delay_expressions ')' - ; + : list_of_path_delay_expressions + | '(' list_of_path_delay_expressions ')' + ; + list_of_path_delay_expressions - : t_path_delay_expression - | trise_path_delay_expression ',' tfall_path_delay_expression ( ',' tz_path_delay_expression )? - | t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ',' tz1_path_delay_expression ',' t1z_path_delay_expression ',' tz0_path_delay_expression ( ',' t0x_path_delay_expression ',' tx1_path_delay_expression ',' t1x_path_delay_expression ',' tx0_path_delay_expression ',' txz_path_delay_expression ',' tzx_path_delay_expression )? - ; + : t_path_delay_expression + | trise_path_delay_expression ',' tfall_path_delay_expression (',' tz_path_delay_expression)? + | t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ',' tz1_path_delay_expression ',' + t1z_path_delay_expression ',' tz0_path_delay_expression ( + ',' t0x_path_delay_expression ',' tx1_path_delay_expression ',' t1x_path_delay_expression ',' tx0_path_delay_expression ',' + txz_path_delay_expression ',' tzx_path_delay_expression + )? + ; + t_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + trise_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tfall_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tz_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t01_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t10_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t0z_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tz1_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t1z_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tz0_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t0x_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tx1_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t1x_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tx0_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + txz_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tzx_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + path_delay_expression - : constant_mintypmax_expression - ; + : constant_mintypmax_expression + ; + edge_sensitive_path_declaration - : parallel_edge_sensitive_path_description '=' path_delay_value - | full_edge_sensitive_path_description '=' path_delay_value - ; + : parallel_edge_sensitive_path_description '=' path_delay_value + | full_edge_sensitive_path_description '=' path_delay_value + ; + parallel_edge_sensitive_path_description - : '(' edge_identifier? specify_input_terminal_descriptor polarity_operator? '=>' '(' specify_output_terminal_descriptor polarity_operator? ':' data_source_expression ')' ')' - ; + : '(' edge_identifier? specify_input_terminal_descriptor polarity_operator? '=>' '(' specify_output_terminal_descriptor polarity_operator? ':' + data_source_expression ')' ')' + ; + full_edge_sensitive_path_description - : '(' edge_identifier? list_of_path_inputs polarity_operator? '*>' '(' list_of_path_outputs polarity_operator? ':' data_source_expression ')' ')' - ; + : '(' edge_identifier? list_of_path_inputs polarity_operator? '*>' '(' list_of_path_outputs polarity_operator? ':' data_source_expression ')' ')' + ; + data_source_expression - : expression - ; + : expression + ; + edge_identifier - : 'posedge' - | 'negedge' - | 'edge' - ; + : 'posedge' + | 'negedge' + | 'edge' + ; + state_dependent_path_declaration - : 'if' '(' module_path_expression ')' simple_path_declaration - | 'if' '(' module_path_expression ')' edge_sensitive_path_declaration - | 'ifnone' simple_path_declaration - ; + : 'if' '(' module_path_expression ')' simple_path_declaration + | 'if' '(' module_path_expression ')' edge_sensitive_path_declaration + | 'ifnone' simple_path_declaration + ; + polarity_operator - : '+' - | '-' - ; + : '+' + | '-' + ; + // A.7.5.1 System timing check commands system_timing_check - : setup_timing_check - | hold_timing_check - | setuphold_timing_check - | recovery_timing_check - | removal_timing_check - | recrem_timing_check - | skew_timing_check - | timeskew_timing_check - | fullskew_timing_check - | period_timing_check - | width_timing_check - | nochange_timing_check - ; + : setup_timing_check + | hold_timing_check + | setuphold_timing_check + | recovery_timing_check + | removal_timing_check + | recrem_timing_check + | skew_timing_check + | timeskew_timing_check + | fullskew_timing_check + | period_timing_check + | width_timing_check + | nochange_timing_check + ; + setup_timing_check - : '$setup' '(' data_event ',' reference_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$setup' '(' data_event ',' reference_event ',' timing_check_limit notifier_opt? ')' ';' + ; + notifier_opt - : ',' notifier? - ; + : ',' notifier? + ; + hold_timing_check - : '$hold' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$hold' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + setuphold_timing_check - : '$setuphold' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' - ; + : '$setuphold' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' + ; + timing_check_opt - : ',' notifier? timestamp_cond_opt? - ; + : ',' notifier? timestamp_cond_opt? + ; + timestamp_cond_opt - : ',' timestamp_condition? timecheck_cond_opt? - ; + : ',' timestamp_condition? timecheck_cond_opt? + ; + timecheck_cond_opt - : ',' timecheck_condition? delayed_ref_opt? - ; + : ',' timecheck_condition? delayed_ref_opt? + ; + delayed_ref_opt - : ',' delayed_reference? delayed_data_opt? - ; + : ',' delayed_reference? delayed_data_opt? + ; + delayed_data_opt - : ',' delayed_data? - ; + : ',' delayed_data? + ; + recovery_timing_check - : '$recovery' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$recovery' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + removal_timing_check - : '$removal' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$removal' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + recrem_timing_check - : '$recrem' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' - ; + : '$recrem' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' + ; + skew_timing_check - : '$skew' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$skew' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + timeskew_timing_check - : '$timeskew' '(' reference_event ',' data_event ',' timing_check_limit skew_timing_check_opt? ')' ';' - ; + : '$timeskew' '(' reference_event ',' data_event ',' timing_check_limit skew_timing_check_opt? ')' ';' + ; + skew_timing_check_opt - : ',' notifier? event_based_flag_opt? - ; + : ',' notifier? event_based_flag_opt? + ; + event_based_flag_opt - : ',' event_based_flag? remain_active_flag_opt? - ; + : ',' event_based_flag? remain_active_flag_opt? + ; + remain_active_flag_opt - : ',' remain_active_flag? - ; + : ',' remain_active_flag? + ; + fullskew_timing_check - : '$fullskew' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit skew_timing_check_opt? ')' ';' - ; + : '$fullskew' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit skew_timing_check_opt? ')' ';' + ; + period_timing_check - : '$period' '(' controlled_reference_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$period' '(' controlled_reference_event ',' timing_check_limit notifier_opt? ')' ';' + ; + width_timing_check - : '$width' '(' controlled_reference_event ',' timing_check_limit ',' threshold notifier_opt? ')' ';' - ; + : '$width' '(' controlled_reference_event ',' timing_check_limit ',' threshold notifier_opt? ')' ';' + ; + nochange_timing_check - : '$nochange' '(' reference_event ',' data_event ',' start_edge_offset ',' end_edge_offset notifier_opt? ')' ';' - ; + : '$nochange' '(' reference_event ',' data_event ',' start_edge_offset ',' end_edge_offset notifier_opt? ')' ';' + ; + // A.7.5.2 System timing check command arguments timecheck_condition - : mintypmax_expression - ; + : mintypmax_expression + ; + controlled_reference_event - : controlled_timing_check_event - ; + : controlled_timing_check_event + ; + data_event - : timing_check_event - ; + : timing_check_event + ; + delayed_data - : terminal_identifier ( '[' constant_mintypmax_expression ']' )? - ; + : terminal_identifier ('[' constant_mintypmax_expression ']')? + ; + delayed_reference - : terminal_identifier ( '[' constant_mintypmax_expression ']' )? - ; + : terminal_identifier ('[' constant_mintypmax_expression ']')? + ; + end_edge_offset - : mintypmax_expression - ; + : mintypmax_expression + ; + event_based_flag - : constant_expression - ; + : constant_expression + ; + notifier - : variable_identifier - ; + : variable_identifier + ; + reference_event - : timing_check_event - ; + : timing_check_event + ; + remain_active_flag - : constant_mintypmax_expression - ; + : constant_mintypmax_expression + ; + timestamp_condition - : mintypmax_expression - ; + : mintypmax_expression + ; + start_edge_offset - : mintypmax_expression - ; + : mintypmax_expression + ; + threshold - : constant_expression - ; + : constant_expression + ; + timing_check_limit - : expression - ; + : expression + ; + // A.7.5.3 System timing check event definitions timing_check_event - : timing_check_event_control? specify_terminal_descriptor ( '&&&' timing_check_condition )? - ; + : timing_check_event_control? specify_terminal_descriptor ('&&&' timing_check_condition)? + ; + controlled_timing_check_event - : timing_check_event_control specify_terminal_descriptor ( '&&&' timing_check_condition )? - ; + : timing_check_event_control specify_terminal_descriptor ('&&&' timing_check_condition)? + ; + timing_check_event_control - : 'posedge' - | 'negedge' - | 'edge' - | edge_control_specifier - ; + : 'posedge' + | 'negedge' + | 'edge' + | edge_control_specifier + ; + specify_terminal_descriptor - : ( interface_identifier '.' )? port_identifier ( '[' constant_range_expression ']' )? - ; + : (interface_identifier '.')? port_identifier ('[' constant_range_expression ']')? + ; + edge_control_specifier - : 'edge' '[' edge_descriptor ( ',' edge_descriptor )* ']' - ; + : 'edge' '[' edge_descriptor (',' edge_descriptor)* ']' + ; + edge_descriptor - : SIMPLE_IDENTIFIER - | UNSIGNED_NUMBER - | ZERO_OR_ONE_X_OR_Z - ; + : SIMPLE_IDENTIFIER + | UNSIGNED_NUMBER + | ZERO_OR_ONE_X_OR_Z + ; + timing_check_condition - : scalar_timing_check_condition - | '(' scalar_timing_check_condition ')' - ; + : scalar_timing_check_condition + | '(' scalar_timing_check_condition ')' + ; + scalar_timing_check_condition - : expression - | '~' expression - | expression '==' scalar_constant - | expression '===' scalar_constant - | expression '!=' scalar_constant - | expression '!==' scalar_constant - ; + : expression + | '~' expression + | expression '==' scalar_constant + | expression '===' scalar_constant + | expression '!=' scalar_constant + | expression '!==' scalar_constant + ; + scalar_constant - : binary_number - | unsigned_number - ; + : binary_number + | unsigned_number + ; + // A.8.1 Concatenations concatenation - : '{' expression ( ',' expression )* '}' - ; + : '{' expression (',' expression)* '}' + ; + constant_concatenation - : '{' constant_expression ( ',' constant_expression )* '}' - ; + : '{' constant_expression (',' constant_expression)* '}' + ; + constant_multiple_concatenation - : '{' constant_expression constant_concatenation '}' - ; + : '{' constant_expression constant_concatenation '}' + ; + module_path_concatenation - : '{' module_path_expression ( ',' module_path_expression )* '}' - ; + : '{' module_path_expression (',' module_path_expression)* '}' + ; + module_path_multiple_concatenation - : '{' constant_expression module_path_concatenation '}' - ; + : '{' constant_expression module_path_concatenation '}' + ; + multiple_concatenation - : '{' expression concatenation '}' - ; + : '{' expression concatenation '}' + ; + streaming_concatenation - : '{' stream_operator slice_size? stream_concatenation '}' - ; + : '{' stream_operator slice_size? stream_concatenation '}' + ; + stream_operator - : '>>' - | '<<' - ; + : '>>' + | '<<' + ; + slice_size - : simple_type - | constant_expression - ; + : simple_type + | constant_expression + ; + stream_concatenation - : '{' stream_expression ( ',' stream_expression )* '}' - ; + : '{' stream_expression (',' stream_expression)* '}' + ; + stream_expression - : expression ( 'with' '[' array_range_expression ']' )? - ; + : expression ('with' '[' array_range_expression ']')? + ; + array_range_expression - : expression - | expression ':' expression - | expression '+:' expression - | expression '-:' expression - ; + : expression + | expression ':' expression + | expression '+:' expression + | expression '-:' expression + ; + empty_unpacked_array_concatenation - : '{' '}' - ; + : '{' '}' + ; + // A.8.2 Subroutine calls system_tf_call - : system_tf_identifier arg_list? - | system_tf_identifier '(' data_type ( ',' expression )? ')' - | system_tf_identifier '(' expression ( ',' ordered_arg )* ',' clocking_event ')' - ; + : system_tf_identifier arg_list? + | system_tf_identifier '(' data_type ( ',' expression)? ')' + | system_tf_identifier '(' expression (',' ordered_arg)* ',' clocking_event ')' + ; + arg_list - : '(' list_of_arguments ')' - ; + : '(' list_of_arguments ')' + ; + subroutine_call - : ( package_scope | '$root' '.' )? identifier attribute_instance* arg_list? - | system_tf_call - | method_call_root '.' array_manipulation_call - | ( 'std' '::' | method_call_root '.' )? randomize_call - ; + : (package_scope | '$root' '.')? identifier attribute_instance* arg_list? + | system_tf_call + | method_call_root '.' array_manipulation_call + | ( 'std' '::' | method_call_root '.')? randomize_call + ; + list_of_arguments - : ordered_arg ( ',' ordered_arg )* ( ',' named_arg )* - | named_arg ( ',' named_arg )* - ; + : ordered_arg (',' ordered_arg)* (',' named_arg)* + | named_arg ( ',' named_arg)* + ; + ordered_arg - : expression? - ; + : expression? + ; + named_arg - : '.' identifier '(' expression? ')' - ; + : '.' identifier '(' expression? ')' + ; + array_manipulation_call - : array_method_name attribute_instance* arg_list? ( 'with' '(' expression ')' )? - ; + : array_method_name attribute_instance* arg_list? ('with' '(' expression ')')? + ; + randomize_call - : 'randomize' attribute_instance* rand_list? rand_with? - ; + : 'randomize' attribute_instance* rand_list? rand_with? + ; + rand_list - : '(' ( variable_identifier_list | 'null' )? ')' - ; + : '(' (variable_identifier_list | 'null')? ')' + ; + rand_with - : 'with' id_list? constraint_block - ; + : 'with' id_list? constraint_block + ; + id_list - : '(' identifier_list? ')' - ; + : '(' identifier_list? ')' + ; + method_call_root - : primary - | implicit_class_handle - ; + : primary + | implicit_class_handle + ; + array_method_name - : method_identifier - | 'unique' - | 'and' - | 'or' - | 'xor' - ; + : method_identifier + | 'unique' + | 'and' + | 'or' + | 'xor' + ; + // A.8.3 Expressions inc_or_dec_expression - : inc_or_dec_operator attribute_instance* variable_lvalue - | variable_lvalue attribute_instance* inc_or_dec_operator - ; + : inc_or_dec_operator attribute_instance* variable_lvalue + | variable_lvalue attribute_instance* inc_or_dec_operator + ; + constant_expression - : constant_primary - | unary_operator attribute_instance* constant_primary - | constant_expression '**' attribute_instance* constant_expression - | constant_expression ( '*' | '/' | '%' ) attribute_instance* constant_expression - | constant_expression ( '+' | '-' ) attribute_instance* constant_expression - | constant_expression ( '>>' | '<<' | '>>>' | '<<<' ) attribute_instance* constant_expression - | constant_expression ( '<' | '<=' | '>' | '>=' ) attribute_instance* constant_expression - | constant_expression ( '==' | '!=' | '===' | '!==' | '==?' | '!=?' ) attribute_instance* constant_expression - | constant_expression '&' attribute_instance* constant_expression - | constant_expression ( '^' | '^~' | '~^' ) attribute_instance* constant_expression - | constant_expression '|' attribute_instance* constant_expression - | constant_expression '&&' attribute_instance* constant_expression - | constant_expression '||' attribute_instance* constant_expression - | constant_expression '?' attribute_instance* constant_expression ':' constant_expression - | constant_expression ( '->' | '<->' ) attribute_instance* constant_expression - ; + : constant_primary + | unary_operator attribute_instance* constant_primary + | constant_expression '**' attribute_instance* constant_expression + | constant_expression ('*' | '/' | '%') attribute_instance* constant_expression + | constant_expression ( '+' | '-') attribute_instance* constant_expression + | constant_expression ('>>' | '<<' | '>>>' | '<<<') attribute_instance* constant_expression + | constant_expression ('<' | '<=' | '>' | '>=') attribute_instance* constant_expression + | constant_expression ('==' | '!=' | '===' | '!==' | '==?' | '!=?') attribute_instance* constant_expression + | constant_expression '&' attribute_instance* constant_expression + | constant_expression ('^' | '^~' | '~^') attribute_instance* constant_expression + | constant_expression '|' attribute_instance* constant_expression + | constant_expression '&&' attribute_instance* constant_expression + | constant_expression '||' attribute_instance* constant_expression + | constant_expression '?' attribute_instance* constant_expression ':' constant_expression + | constant_expression ('->' | '<->') attribute_instance* constant_expression + ; + constant_mintypmax_expression - : constant_expression ( ':' constant_expression ':' constant_expression )? - ; + : constant_expression (':' constant_expression ':' constant_expression)? + ; + constant_param_expression - : constant_mintypmax_expression - | data_type - | '$' - ; + : constant_mintypmax_expression + | data_type + | '$' + ; + param_expression - : mintypmax_expression - | data_type - | '$' - ; + : mintypmax_expression + | data_type + | '$' + ; + constant_range_expression - : constant_expression - | constant_part_select_range - ; + : constant_expression + | constant_part_select_range + ; + constant_part_select_range - : constant_range - | constant_indexed_range - ; + : constant_range + | constant_indexed_range + ; + constant_range - : constant_expression ':' constant_expression - ; + : constant_expression ':' constant_expression + ; + constant_indexed_range - : constant_expression '+:' constant_expression - | constant_expression '-:' constant_expression - ; + : constant_expression '+:' constant_expression + | constant_expression '-:' constant_expression + ; + expression - : primary - | '(' operator_assignment ')' - | unary_operator attribute_instance* primary - | inc_or_dec_expression - | tagged_union_expression - | expression '**' attribute_instance* expression - | expression ( '*' | '/' | '%' ) attribute_instance* expression - | expression ( '+' | '-' ) attribute_instance* expression - | expression ( '>>' | '<<' | '>>>' | '<<<' ) attribute_instance* expression - | expression ( ( '<' | '<=' | '>' | '>=' ) attribute_instance* expression | 'inside' '{' open_range_list '}' ) - | expression ( '==' | '!=' | '===' | '!==' | '==?' | '!=?' ) attribute_instance* expression - | expression '&' attribute_instance* expression - | expression ( '^' | '^~' | '~^' ) attribute_instance* expression - | expression '|' attribute_instance* expression - | expression '&&' attribute_instance* expression - | expression '||' attribute_instance* expression - | expression ( 'matches' pattern )? ( '&&&' expression_or_cond_pattern )* '?' attribute_instance* expression ':' expression - | expression ( '->' | '<->' ) attribute_instance* expression - ; + : primary + | '(' operator_assignment ')' + | unary_operator attribute_instance* primary + | inc_or_dec_expression + | tagged_union_expression + | expression '**' attribute_instance* expression + | expression ( '*' | '/' | '%') attribute_instance* expression + | expression ( '+' | '-') attribute_instance* expression + | expression ( '>>' | '<<' | '>>>' | '<<<') attribute_instance* expression + | expression ( + ( '<' | '<=' | '>' | '>=') attribute_instance* expression + | 'inside' '{' open_range_list '}' + ) + | expression ('==' | '!=' | '===' | '!==' | '==?' | '!=?') attribute_instance* expression + | expression '&' attribute_instance* expression + | expression ( '^' | '^~' | '~^') attribute_instance* expression + | expression '|' attribute_instance* expression + | expression '&&' attribute_instance* expression + | expression '||' attribute_instance* expression + | expression ('matches' pattern)? ('&&&' expression_or_cond_pattern)* '?' attribute_instance* expression ':' expression + | expression ( '->' | '<->') attribute_instance* expression + ; + tagged_union_expression - : 'tagged' member_identifier expression? - ; + : 'tagged' member_identifier expression? + ; + value_range - : expression - | '[' expression ':' expression ']' - ; + : expression + | '[' expression ':' expression ']' + ; + mintypmax_expression - : expression ( ':' expression ':' expression )? - ; + : expression (':' expression ':' expression)? + ; + module_path_expression - : module_path_primary - | unary_module_path_operator attribute_instance* module_path_primary - | module_path_expression ( '==' | '!=' ) attribute_instance* module_path_expression - | module_path_expression '&' attribute_instance* module_path_expression - | module_path_expression ( '^' | '^~' | '~^' ) attribute_instance* module_path_expression - | module_path_expression '|' attribute_instance* module_path_expression - | module_path_expression '&&' attribute_instance* module_path_expression - | module_path_expression '||' attribute_instance* module_path_expression - | module_path_expression '?' attribute_instance* module_path_expression ':' module_path_expression - ; + : module_path_primary + | unary_module_path_operator attribute_instance* module_path_primary + | module_path_expression ('==' | '!=') attribute_instance* module_path_expression + | module_path_expression '&' attribute_instance* module_path_expression + | module_path_expression ('^' | '^~' | '~^') attribute_instance* module_path_expression + | module_path_expression '|' attribute_instance* module_path_expression + | module_path_expression '&&' attribute_instance* module_path_expression + | module_path_expression '||' attribute_instance* module_path_expression + | module_path_expression '?' attribute_instance* module_path_expression ':' module_path_expression + ; + module_path_mintypmax_expression - : module_path_expression ( ':' module_path_expression ':' module_path_expression )? - ; + : module_path_expression (':' module_path_expression ':' module_path_expression)? + ; + part_select_range - : constant_range - | indexed_range - ; + : constant_range + | indexed_range + ; + indexed_range - : expression '+:' constant_expression - | expression '-:' constant_expression - ; + : expression '+:' constant_expression + | expression '-:' constant_expression + ; + genvar_expression - : constant_expression - ; + : constant_expression + ; + // A.8.4 Primaries constant_primary - : primary_literal - | ( package_or_class_scope | gen_ref+ )? identifier constant_select? - | constant_concatenation ( '[' constant_range_expression ']' )? - | constant_multiple_concatenation ( '[' constant_range_expression ']' )? - | package_scope? identifier ( attribute_instance+ | attribute_instance* arg_list ) - | '$root' '.' identifier attribute_instance* arg_list? - | system_tf_call - | method_call_root '.' array_manipulation_call - | ( 'std' '::' | method_call_root '.' )? randomize_call - | '(' constant_mintypmax_expression ')' - | constant_primary '\'' '(' constant_expression ')' - | ( simple_type | signing | 'string' | 'const' ) '\'' '(' constant_expression ')' - | constant_assignment_pattern_expression - | type_reference - | 'null' - ; + : primary_literal + | ( package_or_class_scope | gen_ref+)? identifier constant_select? + | constant_concatenation ( '[' constant_range_expression ']')? + | constant_multiple_concatenation ( '[' constant_range_expression ']')? + | package_scope? identifier (attribute_instance+ | attribute_instance* arg_list) + | '$root' '.' identifier attribute_instance* arg_list? + | system_tf_call + | method_call_root '.' array_manipulation_call + | ( 'std' '::' | method_call_root '.')? randomize_call + | '(' constant_mintypmax_expression ')' + | constant_primary '\'' '(' constant_expression ')' + | (simple_type | signing | 'string' | 'const') '\'' '(' constant_expression ')' + | constant_assignment_pattern_expression + | type_reference + | 'null' + ; + module_path_primary - : number - | module_path_concatenation - | module_path_multiple_concatenation - | ( package_scope | '$root' '.' )? identifier attribute_instance* arg_list? - | system_tf_call - | method_call_root '.' array_manipulation_call - | ( 'std' '::' | method_call_root '.' )? randomize_call - | '(' module_path_mintypmax_expression ')' - ; + : number + | module_path_concatenation + | module_path_multiple_concatenation + | ( package_scope | '$root' '.')? identifier attribute_instance* arg_list? + | system_tf_call + | method_call_root '.' array_manipulation_call + | ( 'std' '::' | method_call_root '.')? randomize_call + | '(' module_path_mintypmax_expression ')' + ; + primary - : primary_literal - | package_or_class_scope? hierarchical_identifier select_? - | implicit_class_handle '.' ( hier_ref+ identifier | '$root' '.' hier_ref* identifier | hierarchical_identifier select_ ) - | 'local' '::' ( implicit_class_handle '.' | class_scope )? hierarchical_identifier select_? - | empty_unpacked_array_concatenation - | concatenation ( '[' range_expression ']' )? - | multiple_concatenation ( '[' range_expression ']' )? - | ( package_scope | '$root' '.' )? identifier ( attribute_instance+ | attribute_instance* arg_list ) - | system_tf_call - | primary '.' ( array_manipulation_call | randomize_call ) - | ( 'this' '.' )? 'super' '.' ( array_manipulation_call | randomize_call ) - | ( 'std' '::' )? randomize_call - | '(' mintypmax_expression ')' - | primary '\'' '(' expression ')' - | ( integer_type | non_integer_type | signing | 'string' | 'const' ) '\'' '(' expression ')' - | assignment_pattern_expression - | streaming_concatenation - | sequence_method_call - | 'this' - | '$' - | 'null' - ; + : primary_literal + | package_or_class_scope? hierarchical_identifier select_? + | implicit_class_handle '.' ( + hier_ref+ identifier + | '$root' '.' hier_ref* identifier + | hierarchical_identifier select_ + ) + | 'local' '::' (implicit_class_handle '.' | class_scope)? hierarchical_identifier select_? + | empty_unpacked_array_concatenation + | concatenation ( '[' range_expression ']')? + | multiple_concatenation ( '[' range_expression ']')? + | (package_scope | '$root' '.')? identifier ( + attribute_instance+ + | attribute_instance* arg_list + ) + | system_tf_call + | primary '.' ( array_manipulation_call | randomize_call) + | ( 'this' '.')? 'super' '.' ( array_manipulation_call | randomize_call) + | ( 'std' '::')? randomize_call + | '(' mintypmax_expression ')' + | primary '\'' '(' expression ')' + | (integer_type | non_integer_type | signing | 'string' | 'const') '\'' '(' expression ')' + | assignment_pattern_expression + | streaming_concatenation + | sequence_method_call + | 'this' + | '$' + | 'null' + ; + range_expression - : expression - | part_select_range - ; + : expression + | part_select_range + ; + primary_literal - : number - | time_literal - | unbased_unsized_literal - | string_literal - ; + : number + | time_literal + | unbased_unsized_literal + | string_literal + ; + time_literal - : TIME_LITERAL - ; + : TIME_LITERAL + ; + implicit_class_handle - : 'this' ( '.' 'super' )? - | 'super' - ; + : 'this' ('.' 'super')? + | 'super' + ; + bit_select - : ( '[' expression ']' )+ - ; + : ('[' expression ']')+ + ; + select_ - : '[' part_select_range ']' - | bit_select ( '[' part_select_range ']' )? - | member_select+ ( '[' part_select_range ']' )? - ; + : '[' part_select_range ']' + | bit_select ( '[' part_select_range ']')? + | member_select+ ( '[' part_select_range ']')? + ; + nonrange_select - : bit_select - | member_select+ - ; + : bit_select + | member_select+ + ; + member_select - : '.' member_identifier bit_select? - ; + : '.' member_identifier bit_select? + ; + constant_bit_select - : ( '[' constant_expression ']' )+ - ; + : ('[' constant_expression ']')+ + ; + constant_select - : '[' constant_part_select_range ']' - | constant_bit_select ( '[' constant_part_select_range ']' )? - | const_member_select+ ( '[' constant_part_select_range ']' )? - ; + : '[' constant_part_select_range ']' + | constant_bit_select ( '[' constant_part_select_range ']')? + | const_member_select+ ( '[' constant_part_select_range ']')? + ; + const_member_select - : '.' member_identifier constant_bit_select? - ; + : '.' member_identifier constant_bit_select? + ; + // A.8.5 Expression left-side values net_lvalue - : ps_or_hierarchical_identifier constant_select? - | '{' net_lvalue ( ',' net_lvalue )* '}' - | assignment_pattern_expression_type? assignment_pattern_net_lvalue - ; + : ps_or_hierarchical_identifier constant_select? + | '{' net_lvalue ( ',' net_lvalue)* '}' + | assignment_pattern_expression_type? assignment_pattern_net_lvalue + ; + variable_lvalue - : ( implicit_class_handle '.' | package_scope )? hierarchical_identifier select_? - | '{' variable_lvalue ( ',' variable_lvalue )* '}' - | assignment_pattern_expression_type? assignment_pattern_variable_lvalue - | streaming_concatenation - ; + : (implicit_class_handle '.' | package_scope)? hierarchical_identifier select_? + | '{' variable_lvalue ( ',' variable_lvalue)* '}' + | assignment_pattern_expression_type? assignment_pattern_variable_lvalue + | streaming_concatenation + ; + nonrange_variable_lvalue - : ( implicit_class_handle '.' | package_scope )? hierarchical_identifier nonrange_select? - ; + : (implicit_class_handle '.' | package_scope)? hierarchical_identifier nonrange_select? + ; + // A.8.6 Operators unary_operator - : '+' - | '-' - | '!' - | '~' - | '&' - | '~&' - | '|' - | '~|' - | '^' - | '~^' - | '^~' - ; + : '+' + | '-' + | '!' + | '~' + | '&' + | '~&' + | '|' + | '~|' + | '^' + | '~^' + | '^~' + ; + inc_or_dec_operator - : '++' - | '--' - ; + : '++' + | '--' + ; + unary_module_path_operator - : '!' - | '~' - | '&' - | '~&' - | '|' - | '~|' - | '^' - | '~^' - | '^~' - ; + : '!' + | '~' + | '&' + | '~&' + | '|' + | '~|' + | '^' + | '~^' + | '^~' + ; + // A.8.7 Numbers number - : integral_number - | real_number - ; + : integral_number + | real_number + ; + integral_number - : decimal_number - | octal_number - | binary_number - | hex_number - ; + : decimal_number + | octal_number + | binary_number + | hex_number + ; + decimal_number - : unsigned_number - | size? decimal_base decimal_value - ; + : unsigned_number + | size? decimal_base decimal_value + ; + binary_number - : size? binary_base binary_value - ; + : size? binary_base binary_value + ; + octal_number - : size? octal_base octal_value - ; + : size? octal_base octal_value + ; + hex_number - : size? hex_base hex_value - ; + : size? hex_base hex_value + ; + size - : UNSIGNED_NUMBER - ; + : UNSIGNED_NUMBER + ; + real_number - : fixed_point_number - | exponential_number - ; + : fixed_point_number + | exponential_number + ; + fixed_point_number - : FIXED_POINT_NUMBER - ; + : FIXED_POINT_NUMBER + ; + exponential_number - : EXPONENTIAL_NUMBER - ; + : EXPONENTIAL_NUMBER + ; + unsigned_number - : UNSIGNED_NUMBER - ; + : UNSIGNED_NUMBER + ; + decimal_value - : UNSIGNED_NUMBER - | X_OR_Z_UNDERSCORE - ; + : UNSIGNED_NUMBER + | X_OR_Z_UNDERSCORE + ; + binary_value - : BINARY_VALUE - ; + : BINARY_VALUE + ; + octal_value - : OCTAL_VALUE - ; + : OCTAL_VALUE + ; + hex_value - : HEX_VALUE - ; + : HEX_VALUE + ; + decimal_base - : DECIMAL_BASE - ; + : DECIMAL_BASE + ; + binary_base - : BINARY_BASE - ; + : BINARY_BASE + ; + octal_base - : OCTAL_BASE - ; + : OCTAL_BASE + ; + hex_base - : HEX_BASE - ; + : HEX_BASE + ; + unbased_unsized_literal - : UNBASED_UNSIZED_LITERAL - ; + : UNBASED_UNSIZED_LITERAL + ; + // A.8.8 Strings string_literal - : STRING_LITERAL - ; + : STRING_LITERAL + ; + // A.9.1 Attributes attribute_instance - : '(' '*' attr_spec ( ',' attr_spec )* '*' ')' - ; + : '(' '*' attr_spec (',' attr_spec)* '*' ')' + ; + attr_spec - : attr_name ( '=' constant_expression )? - ; + : attr_name ('=' constant_expression)? + ; + attr_name - : identifier - ; + : identifier + ; + // A.9.3 Identifiers block_identifier - : identifier - ; + : identifier + ; + bin_identifier - : identifier - ; + : identifier + ; + c_identifier - : SIMPLE_IDENTIFIER - ; + : SIMPLE_IDENTIFIER + ; + cell_identifier - : identifier - ; + : identifier + ; + checker_identifier - : identifier - ; + : identifier + ; + class_identifier - : identifier - ; + : identifier + ; + class_variable_identifier - : identifier - ; + : identifier + ; + clocking_identifier - : identifier - ; + : identifier + ; + config_identifier - : identifier - ; + : identifier + ; + const_identifier - : identifier - ; + : identifier + ; + constraint_identifier - : identifier - ; + : identifier + ; + covergroup_identifier - : identifier - ; + : identifier + ; + cover_point_identifier - : identifier - ; + : identifier + ; + cross_identifier - : identifier - ; + : identifier + ; + dynamic_array_variable_identifier - : identifier - ; + : identifier + ; + enum_identifier - : identifier - ; + : identifier + ; + escaped_identifier - : ESCAPED_IDENTIFIER - ; + : ESCAPED_IDENTIFIER + ; + formal_port_identifier - : identifier - ; + : identifier + ; + function_identifier - : identifier - ; + : identifier + ; + generate_block_identifier - : identifier - ; + : identifier + ; + genvar_identifier - : identifier - ; + : identifier + ; + hierarchical_identifier - : ( '$root' '.' )? hier_ref* identifier - ; + : ('$root' '.')? hier_ref* identifier + ; + hier_ref - : identifier constant_bit_select? '.' - ; + : identifier constant_bit_select? '.' + ; + identifier - : simple_identifier - | escaped_identifier - ; + : simple_identifier + | escaped_identifier + ; + index_variable_identifier - : identifier - ; + : identifier + ; + interface_identifier - : identifier - ; + : identifier + ; + interface_instance_identifier - : identifier - ; + : identifier + ; + input_port_identifier - : identifier - ; + : identifier + ; + instance_identifier - : identifier - ; + : identifier + ; + library_identifier - : identifier - ; + : identifier + ; + member_identifier - : identifier - ; + : identifier + ; + method_identifier - : identifier - ; + : identifier + ; + modport_identifier - : identifier - ; + : identifier + ; + module_identifier - : identifier - ; + : identifier + ; + net_identifier - : identifier - ; + : identifier + ; + net_type_identifier - : identifier - ; + : identifier + ; + output_port_identifier - : identifier - ; + : identifier + ; + package_identifier - : identifier - ; + : identifier + ; + package_scope - : package_identifier '::' - | '$unit' '::' - ; + : package_identifier '::' + | '$unit' '::' + ; + parameter_identifier - : identifier - ; + : identifier + ; + port_identifier - : identifier - ; + : identifier + ; + production_identifier - : identifier - ; + : identifier + ; + program_identifier - : identifier - ; + : identifier + ; + property_identifier - : identifier - ; + : identifier + ; + ps_identifier - : package_scope? identifier - ; + : package_scope? identifier + ; + ps_or_hierarchical_array_identifier - : ( implicit_class_handle '.' | package_or_class_scope )? hierarchical_identifier - ; + : (implicit_class_handle '.' | package_or_class_scope)? hierarchical_identifier + ; + ps_or_hierarchical_identifier - : package_scope? identifier - | hier_ref+ identifier - | '$root' '.' hier_ref* identifier - ; + : package_scope? identifier + | hier_ref+ identifier + | '$root' '.' hier_ref* identifier + ; + ps_type_or_parameter_identifier - : ( 'local' '::' | package_or_class_scope | gen_ref+ )? identifier - ; + : ('local' '::' | package_or_class_scope | gen_ref+)? identifier + ; + gen_ref - : generate_block_identifier ( '[' constant_expression ']' )? '.' - ; + : generate_block_identifier ('[' constant_expression ']')? '.' + ; + sequence_identifier - : identifier - ; + : identifier + ; + signal_identifier - : identifier - ; + : identifier + ; + simple_identifier - : SIMPLE_IDENTIFIER - ; + : SIMPLE_IDENTIFIER + ; + specparam_identifier - : identifier - ; + : identifier + ; + system_tf_identifier - : SYSTEM_TF_IDENTIFIER - | '$error' - | '$fatal' - | '$info' - | '$warning' - ; + : SYSTEM_TF_IDENTIFIER + | '$error' + | '$fatal' + | '$info' + | '$warning' + ; + task_identifier - : identifier - ; + : identifier + ; + tf_identifier - : identifier - ; + : identifier + ; + terminal_identifier - : identifier - ; + : identifier + ; + topmodule_identifier - : identifier - ; + : identifier + ; + type_identifier - : identifier - ; + : identifier + ; + udp_identifier - : identifier - ; + : identifier + ; + variable_identifier - : identifier - ; + : identifier + ; \ No newline at end of file diff --git a/verilog/systemverilog/SystemVerilogPreParser.g4 b/verilog/systemverilog/SystemVerilogPreParser.g4 index f1f4f107f3..a9cf56d5cb 100755 --- a/verilog/systemverilog/SystemVerilogPreParser.g4 +++ b/verilog/systemverilog/SystemVerilogPreParser.g4 @@ -22,77 +22,240 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 SystemVerilogPreParser; -options { tokenVocab = SystemVerilogLexer; } -source_text : compiler_directive* ; +options { + tokenVocab = SystemVerilogLexer; +} + +source_text + : compiler_directive* + ; + compiler_directive - : begin_keywords_directive - | celldefine_directive - | default_nettype_directive - | end_keywords_directive - | endcelldefine_directive - | file_directive - | ifdef_directive - | ifndef_directive - | include_directive - | line_directive - | line_directive_ - | nounconnected_drive_directive - | pragma_directive - | resetall_directive - | text_macro_definition - | text_macro_usage - | timescale_directive - | unconnected_drive_directive - | undef_directive - | undefineall_directive - ; -begin_keywords_directive : GA BEGIN_KEYWORDS_DIRECTIVE DQ version_specifier DQ ; -celldefine_directive : GA CELLDEFINE_DIRECTIVE ; -default_nettype_directive : GA DEFAULT_NETTYPE_DIRECTIVE default_nettype_value ; -default_nettype_value : DEFAULT_NETTYPE_VALUE ; -else_directive : GA ELSE_DIRECTIVE group_of_lines ; -elsif_directive : GA ELSIF_DIRECTIVE macro_identifier group_of_lines ; -end_keywords_directive : GA END_KEYWORDS_DIRECTIVE ; -endcelldefine_directive : GA ENDCELLDEFINE_DIRECTIVE ; -endif_directive : GA ENDIF_DIRECTIVE ; -file_directive : GA FILE_DIRECTIVE ; -filename : FILENAME ; -group_of_lines : ( source_text_ | compiler_directive )* ; -identifier : SIMPLE_IDENTIFIER ; -ifdef_directive : GA IFDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive ; -ifndef_directive : GA IFNDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive ; -include_directive : GA INCLUDE_DIRECTIVE ( DQ filename DQ | LT filename GT | text_macro_usage ) ; -level : UNSIGNED_NUMBER ; -line_directive : GA LINE_DIRECTIVE number DQ filename DQ level ; -line_directive_ : GA LINE_DIRECTIVE_ ; -macro_delimiter : MACRO_DELIMITER ; -macro_esc_newline : MACRO_ESC_NEWLINE ; -macro_esc_quote : MACRO_ESC_QUOTE ; -macro_identifier : MACRO_IDENTIFIER ; -macro_name : MACRO_NAME ; -macro_quote : MACRO_QUOTE ; -macro_text : ( macro_text_ | macro_delimiter | macro_esc_newline | macro_esc_quote | macro_quote | string_literal )* ; -macro_text_ : MACRO_TEXT ; -macro_usage : MACRO_USAGE ; -nounconnected_drive_directive : GA NOUNCONNECTED_DRIVE_DIRECTIVE ; -number : UNSIGNED_NUMBER ; -pragma_directive : GA PRAGMA_DIRECTIVE pragma_name ( pragma_expression ( CO pragma_expression )* )? ; -pragma_expression : ( pragma_keyword EQ )? pragma_value ; -pragma_keyword : SIMPLE_IDENTIFIER ; -pragma_name : SIMPLE_IDENTIFIER ; -pragma_value : LP pragma_expression ( CO pragma_expression )* RP | number | string_literal | identifier ; -resetall_directive : GA RESETALL_DIRECTIVE ; -source_text_ : SOURCE_TEXT ; -string_literal : STRING_LITERAL ; -text_macro_definition : GA DEFINE_DIRECTIVE macro_name macro_text ; -text_macro_usage : GA macro_usage ; -time_precision : TIME_VALUE TIME_UNIT ; -time_unit : TIME_VALUE TIME_UNIT ; -timescale_directive : GA TIMESCALE_DIRECTIVE time_unit SL time_precision ; -unconnected_drive_directive : GA UNCONNECTED_DRIVE_DIRECTIVE unconnected_drive_value ; -unconnected_drive_value : UNCONNECTED_DRIVE_VALUE ; -undef_directive : GA UNDEF_DIRECTIVE macro_identifier ; -undefineall_directive : GA UNDEFINEALL_DIRECTIVE ; -version_specifier : VERSION_SPECIFIER ; + : begin_keywords_directive + | celldefine_directive + | default_nettype_directive + | end_keywords_directive + | endcelldefine_directive + | file_directive + | ifdef_directive + | ifndef_directive + | include_directive + | line_directive + | line_directive_ + | nounconnected_drive_directive + | pragma_directive + | resetall_directive + | text_macro_definition + | text_macro_usage + | timescale_directive + | unconnected_drive_directive + | undef_directive + | undefineall_directive + ; + +begin_keywords_directive + : GA BEGIN_KEYWORDS_DIRECTIVE DQ version_specifier DQ + ; + +celldefine_directive + : GA CELLDEFINE_DIRECTIVE + ; + +default_nettype_directive + : GA DEFAULT_NETTYPE_DIRECTIVE default_nettype_value + ; + +default_nettype_value + : DEFAULT_NETTYPE_VALUE + ; + +else_directive + : GA ELSE_DIRECTIVE group_of_lines + ; + +elsif_directive + : GA ELSIF_DIRECTIVE macro_identifier group_of_lines + ; + +end_keywords_directive + : GA END_KEYWORDS_DIRECTIVE + ; + +endcelldefine_directive + : GA ENDCELLDEFINE_DIRECTIVE + ; + +endif_directive + : GA ENDIF_DIRECTIVE + ; + +file_directive + : GA FILE_DIRECTIVE + ; + +filename + : FILENAME + ; + +group_of_lines + : (source_text_ | compiler_directive)* + ; + +identifier + : SIMPLE_IDENTIFIER + ; + +ifdef_directive + : GA IFDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive + ; + +ifndef_directive + : GA IFNDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive + ; + +include_directive + : GA INCLUDE_DIRECTIVE (DQ filename DQ | LT filename GT | text_macro_usage) + ; + +level + : UNSIGNED_NUMBER + ; + +line_directive + : GA LINE_DIRECTIVE number DQ filename DQ level + ; + +line_directive_ + : GA LINE_DIRECTIVE_ + ; + +macro_delimiter + : MACRO_DELIMITER + ; + +macro_esc_newline + : MACRO_ESC_NEWLINE + ; + +macro_esc_quote + : MACRO_ESC_QUOTE + ; + +macro_identifier + : MACRO_IDENTIFIER + ; + +macro_name + : MACRO_NAME + ; + +macro_quote + : MACRO_QUOTE + ; + +macro_text + : ( + macro_text_ + | macro_delimiter + | macro_esc_newline + | macro_esc_quote + | macro_quote + | string_literal + )* + ; + +macro_text_ + : MACRO_TEXT + ; + +macro_usage + : MACRO_USAGE + ; + +nounconnected_drive_directive + : GA NOUNCONNECTED_DRIVE_DIRECTIVE + ; + +number + : UNSIGNED_NUMBER + ; + +pragma_directive + : GA PRAGMA_DIRECTIVE pragma_name (pragma_expression ( CO pragma_expression)*)? + ; + +pragma_expression + : (pragma_keyword EQ)? pragma_value + ; + +pragma_keyword + : SIMPLE_IDENTIFIER + ; + +pragma_name + : SIMPLE_IDENTIFIER + ; + +pragma_value + : LP pragma_expression (CO pragma_expression)* RP + | number + | string_literal + | identifier + ; + +resetall_directive + : GA RESETALL_DIRECTIVE + ; + +source_text_ + : SOURCE_TEXT + ; + +string_literal + : STRING_LITERAL + ; + +text_macro_definition + : GA DEFINE_DIRECTIVE macro_name macro_text + ; + +text_macro_usage + : GA macro_usage + ; + +time_precision + : TIME_VALUE TIME_UNIT + ; + +time_unit + : TIME_VALUE TIME_UNIT + ; + +timescale_directive + : GA TIMESCALE_DIRECTIVE time_unit SL time_precision + ; + +unconnected_drive_directive + : GA UNCONNECTED_DRIVE_DIRECTIVE unconnected_drive_value + ; + +unconnected_drive_value + : UNCONNECTED_DRIVE_VALUE + ; + +undef_directive + : GA UNDEF_DIRECTIVE macro_identifier + ; + +undefineall_directive + : GA UNDEFINEALL_DIRECTIVE + ; + +version_specifier + : VERSION_SPECIFIER + ; \ No newline at end of file diff --git a/verilog/verilog/VerilogLexer.g4 b/verilog/verilog/VerilogLexer.g4 index efdbb4d532..0568be5ccd 100644 --- a/verilog/verilog/VerilogLexer.g4 +++ b/verilog/verilog/VerilogLexer.g4 @@ -22,403 +22,436 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar VerilogLexer; -channels { COMMENTS, DIRECTIVES } - -ALWAYS : 'always' ; -AND : 'and' ; -ASSIGN : 'assign' ; -AUTOMATIC : 'automatic' ; -BEGIN : 'begin' ; -BUF : 'buf' ; -BUFIFONE : 'bufif1' ; -BUFIFZERO : 'bufif0' ; -CASE : 'case' ; -CASEX : 'casex' ; -CASEZ : 'casez' ; -CELL : 'cell' ; -CMOS : 'cmos' ; -CONFIG : 'config' ; -DEASSIGN : 'deassign' ; -DEFAULT : 'default' ; -DEFPARAM : 'defparam' ; -DESIGN : 'design' ; -DISABLE : 'disable' ; -DLFULLSKEW : '$fullskew' ; -DLHOLD : '$hold' ; -DLNOCHANGE : '$nochange' ; -DLPERIOD : '$period' ; -DLRECOVERY : '$recovery' ; -DLRECREM : '$recrem' ; -DLREMOVAL : '$removal' ; -DLSETUP : '$setup' ; -DLSETUPHOLD : '$setuphold' ; -DLSKEW : '$skew' ; -DLTIMESKEW : '$timeskew' ; -DLWIDTH : '$width' ; -EDGE : 'edge' -> pushMode(EDGE_MODE) ; -ELSE : 'else' ; -END : 'end' ; -ENDCASE : 'endcase' ; -ENDCONFIG : 'endconfig' ; -ENDFUNCTION : 'endfunction' ; -ENDGENERATE : 'endgenerate' ; -ENDMODULE : 'endmodule' ; -ENDPRIMITIVE : 'endprimitive' ; -ENDSPECIFY : 'endspecify' ; -ENDTABLE : 'endtable' ; -ENDTASK : 'endtask' ; -EVENT : 'event' ; -FOR : 'for' ; -FORCE : 'force' ; -FOREVER : 'forever' ; -FORK : 'fork' ; -FUNCTION : 'function' ; -GENERATE : 'generate' ; -GENVAR : 'genvar' ; -HIGHZONE : 'highz1' ; -HIGHZZERO : 'highz0' ; -IF : 'if' ; -IFNONE : 'ifnone' ; -INCLUDE : 'include' -> pushMode(LIBRARY_MODE) ; -INITIAL : 'initial' ; -INOUT : 'inout' ; -INPUT : 'input' ; -INSTANCE : 'instance' ; -INTEGER : 'integer' ; -JOIN : 'join' ; -LARGE : 'large' ; -LIBLIST : 'liblist' ; -LIBRARY : 'library' -> pushMode(LIBRARY_MODE) ; -LOCALPARAM : 'localparam' ; -MACROMODULE : 'macromodule' ; -MEDIUM : 'medium' ; -MIINCDIR : '-incdir' ; -MODULE : 'module' ; -NAND : 'nand' ; -NEGEDGE : 'negedge' ; -NMOS : 'nmos' ; -NOR : 'nor' ; -NOSHOWCANCELLED : 'noshowcancelled' ; -NOT : 'not' ; -NOTIFONE : 'notif1' ; -NOTIFZERO : 'notif0' ; -OR : 'or' ; -OUTPUT : 'output' ; -PARAMETER : 'parameter' ; -PATHPULSEDL : 'PATHPULSE$' ; -PMOS : 'pmos' ; -POSEDGE : 'posedge' ; -PRIMITIVE : 'primitive' ; -PULLDOWN : 'pulldown' ; -PULLONE : 'pull1' ; -PULLUP : 'pullup' ; -PULLZERO : 'pull0' ; -PULSESTYLE_ONDETECT : 'pulsestyle_ondetect' ; -PULSESTYLE_ONEVENT : 'pulsestyle_onevent' ; -RCMOS : 'rcmos' ; -REAL : 'real' ; -REALTIME : 'realtime' ; -REG : 'reg' ; -RELEASE : 'release' ; -REPEAT : 'repeat' ; -RNMOS : 'rnmos' ; -RPMOS : 'rpmos' ; -RTRAN : 'rtran' ; -RTRANIFONE : 'rtranif1' ; -RTRANIFZERO : 'rtranif0' ; -SCALARED : 'scalared' ; -SHOWCANCELLED : 'showcancelled' ; -SIGNED : 'signed' ; -SMALL : 'small' ; -SPECIFY : 'specify' ; -SPECPARAM : 'specparam' ; -STRONGONE : 'strong1' ; -STRONGZERO : 'strong0' ; -SUPPLYONE : 'supply1' ; -SUPPLYZERO : 'supply0' ; -TABLE : 'table' -> pushMode(TABLE_MODE) ; -TASK : 'task' ; -TIME : 'time' ; -TRAN : 'tran' ; -TRANIFONE : 'tranif1' ; -TRANIFZERO : 'tranif0' ; -TRI : 'tri' ; -TRIAND : 'triand' ; -TRIONE : 'tri1' ; -TRIOR : 'trior' ; -TRIREG : 'trireg' ; -TRIZERO : 'tri0' ; -USE : 'use' ; -UWIRE : 'uwire' ; -VECTORED : 'vectored' ; -WAIT : 'wait' ; -WAND : 'wand' ; -WEAKONE : 'weak1' ; -WEAKZERO : 'weak0' ; -WHILE : 'while' ; -WIRE : 'wire' ; -WOR : 'wor' ; -XNOR : 'xnor' ; -XOR : 'xor' ; - -AM : '&' ; -AMAM : '&&' ; -AMAMAM : '&&&' ; -AS : '*' ; -ASAS : '**' ; -ASGT : '*>' ; -AT : '@' ; -CA : '^' ; -CATI : '^~' ; -CL : ':' ; -CO : ',' ; -DL : '$' ; -DQ : '"' ; -DT : '.' ; -EM : '!' ; -EMEQ : '!=' ; -EMEQEQ : '!==' ; -EQ : '=' ; -EQEQ : '==' ; -EQEQEQ : '===' ; -EQGT : '=>' ; -GA : '`' -> channel(DIRECTIVES), pushMode(DIRECTIVE_MODE) ; -GT : '>' ; -GTEQ : '>=' ; -GTGT : '>>' ; -GTGTGT : '>>>' ; -HA : '#' ; -LB : '[' ; -LC : '{' ; -LP : '(' ; -LT : '<' ; -LTEQ : '<=' ; -LTLT : '<<' ; -LTLTLT : '<<<' ; -MI : '-' ; -MICL : '-:' ; -MIGT : '->' ; -MO : '%' ; -PL : '+' ; -PLCL : '+:' ; -QM : '?' ; -RB : ']' ; -RC : '}' ; -RP : ')' ; -SC : ';' ; -SL : '/' ; -TI : '~' ; -TIAM : '~&' ; -TICA : '~^' ; -TIVL : '~|' ; -VL : '|' ; -VLVL : '||' ; - -BINARY_BASE : '\'' [sS]? [bB] -> pushMode(BINARY_NUMBER_MODE) ; -BLOCK_COMMENT : '/*' ASCII_ANY*? '*/' -> channel(COMMENTS) ; -DECIMAL_BASE : '\'' [sS]? [dD] -> pushMode(DECIMAL_NUMBER_MODE) ; -ESCAPED_IDENTIFIER : '\\' ASCII_PRINTABLE_NO_SPACE* [ \t\r\n] ; -EXPONENTIAL_NUMBER : UNSIGNED_NUMBER ( '.' UNSIGNED_NUMBER )? [eE] [+\-]? UNSIGNED_NUMBER ; -FIXED_POINT_NUMBER : UNSIGNED_NUMBER '.' UNSIGNED_NUMBER ; -HEX_BASE : '\'' [sS]? [hH] -> pushMode(HEX_NUMBER_MODE) ; -LINE_COMMENT : '//' ASCII_NO_NEWLINE* -> channel(COMMENTS) ; -OCTAL_BASE : '\'' [sS]? [oO] -> pushMode(OCTAL_NUMBER_MODE) ; -SIMPLE_IDENTIFIER : [a-zA-Z_] [a-zA-Z0-9_$]* ; -STRING : '"' ( ASCII_NO_NEWLINE_QUOTE_BACKSLASH | ESC_SPECIAL_CHAR )* '"' ; -SYSTEM_TF_IDENTIFIER : '$' [a-zA-Z0-9_$] [a-zA-Z0-9_$]* ; -UNSIGNED_NUMBER : [0-9] [0-9_]* ; -WHITE_SPACE : [ \t\r\n]+ -> channel(HIDDEN) ; +channels { + COMMENTS, + DIRECTIVES +} + +ALWAYS : 'always'; +AND : 'and'; +ASSIGN : 'assign'; +AUTOMATIC : 'automatic'; +BEGIN : 'begin'; +BUF : 'buf'; +BUFIFONE : 'bufif1'; +BUFIFZERO : 'bufif0'; +CASE : 'case'; +CASEX : 'casex'; +CASEZ : 'casez'; +CELL : 'cell'; +CMOS : 'cmos'; +CONFIG : 'config'; +DEASSIGN : 'deassign'; +DEFAULT : 'default'; +DEFPARAM : 'defparam'; +DESIGN : 'design'; +DISABLE : 'disable'; +DLFULLSKEW : '$fullskew'; +DLHOLD : '$hold'; +DLNOCHANGE : '$nochange'; +DLPERIOD : '$period'; +DLRECOVERY : '$recovery'; +DLRECREM : '$recrem'; +DLREMOVAL : '$removal'; +DLSETUP : '$setup'; +DLSETUPHOLD : '$setuphold'; +DLSKEW : '$skew'; +DLTIMESKEW : '$timeskew'; +DLWIDTH : '$width'; +EDGE : 'edge' -> pushMode(EDGE_MODE); +ELSE : 'else'; +END : 'end'; +ENDCASE : 'endcase'; +ENDCONFIG : 'endconfig'; +ENDFUNCTION : 'endfunction'; +ENDGENERATE : 'endgenerate'; +ENDMODULE : 'endmodule'; +ENDPRIMITIVE : 'endprimitive'; +ENDSPECIFY : 'endspecify'; +ENDTABLE : 'endtable'; +ENDTASK : 'endtask'; +EVENT : 'event'; +FOR : 'for'; +FORCE : 'force'; +FOREVER : 'forever'; +FORK : 'fork'; +FUNCTION : 'function'; +GENERATE : 'generate'; +GENVAR : 'genvar'; +HIGHZONE : 'highz1'; +HIGHZZERO : 'highz0'; +IF : 'if'; +IFNONE : 'ifnone'; +INCLUDE : 'include' -> pushMode(LIBRARY_MODE); +INITIAL : 'initial'; +INOUT : 'inout'; +INPUT : 'input'; +INSTANCE : 'instance'; +INTEGER : 'integer'; +JOIN : 'join'; +LARGE : 'large'; +LIBLIST : 'liblist'; +LIBRARY : 'library' -> pushMode(LIBRARY_MODE); +LOCALPARAM : 'localparam'; +MACROMODULE : 'macromodule'; +MEDIUM : 'medium'; +MIINCDIR : '-incdir'; +MODULE : 'module'; +NAND : 'nand'; +NEGEDGE : 'negedge'; +NMOS : 'nmos'; +NOR : 'nor'; +NOSHOWCANCELLED : 'noshowcancelled'; +NOT : 'not'; +NOTIFONE : 'notif1'; +NOTIFZERO : 'notif0'; +OR : 'or'; +OUTPUT : 'output'; +PARAMETER : 'parameter'; +PATHPULSEDL : 'PATHPULSE$'; +PMOS : 'pmos'; +POSEDGE : 'posedge'; +PRIMITIVE : 'primitive'; +PULLDOWN : 'pulldown'; +PULLONE : 'pull1'; +PULLUP : 'pullup'; +PULLZERO : 'pull0'; +PULSESTYLE_ONDETECT : 'pulsestyle_ondetect'; +PULSESTYLE_ONEVENT : 'pulsestyle_onevent'; +RCMOS : 'rcmos'; +REAL : 'real'; +REALTIME : 'realtime'; +REG : 'reg'; +RELEASE : 'release'; +REPEAT : 'repeat'; +RNMOS : 'rnmos'; +RPMOS : 'rpmos'; +RTRAN : 'rtran'; +RTRANIFONE : 'rtranif1'; +RTRANIFZERO : 'rtranif0'; +SCALARED : 'scalared'; +SHOWCANCELLED : 'showcancelled'; +SIGNED : 'signed'; +SMALL : 'small'; +SPECIFY : 'specify'; +SPECPARAM : 'specparam'; +STRONGONE : 'strong1'; +STRONGZERO : 'strong0'; +SUPPLYONE : 'supply1'; +SUPPLYZERO : 'supply0'; +TABLE : 'table' -> pushMode(TABLE_MODE); +TASK : 'task'; +TIME : 'time'; +TRAN : 'tran'; +TRANIFONE : 'tranif1'; +TRANIFZERO : 'tranif0'; +TRI : 'tri'; +TRIAND : 'triand'; +TRIONE : 'tri1'; +TRIOR : 'trior'; +TRIREG : 'trireg'; +TRIZERO : 'tri0'; +USE : 'use'; +UWIRE : 'uwire'; +VECTORED : 'vectored'; +WAIT : 'wait'; +WAND : 'wand'; +WEAKONE : 'weak1'; +WEAKZERO : 'weak0'; +WHILE : 'while'; +WIRE : 'wire'; +WOR : 'wor'; +XNOR : 'xnor'; +XOR : 'xor'; + +AM : '&'; +AMAM : '&&'; +AMAMAM : '&&&'; +AS : '*'; +ASAS : '**'; +ASGT : '*>'; +AT : '@'; +CA : '^'; +CATI : '^~'; +CL : ':'; +CO : ','; +DL : '$'; +DQ : '"'; +DT : '.'; +EM : '!'; +EMEQ : '!='; +EMEQEQ : '!=='; +EQ : '='; +EQEQ : '=='; +EQEQEQ : '==='; +EQGT : '=>'; +GA : '`' -> channel(DIRECTIVES), pushMode(DIRECTIVE_MODE); +GT : '>'; +GTEQ : '>='; +GTGT : '>>'; +GTGTGT : '>>>'; +HA : '#'; +LB : '['; +LC : '{'; +LP : '('; +LT : '<'; +LTEQ : '<='; +LTLT : '<<'; +LTLTLT : '<<<'; +MI : '-'; +MICL : '-:'; +MIGT : '->'; +MO : '%'; +PL : '+'; +PLCL : '+:'; +QM : '?'; +RB : ']'; +RC : '}'; +RP : ')'; +SC : ';'; +SL : '/'; +TI : '~'; +TIAM : '~&'; +TICA : '~^'; +TIVL : '~|'; +VL : '|'; +VLVL : '||'; + +BINARY_BASE : '\'' [sS]? [bB] -> pushMode(BINARY_NUMBER_MODE); +BLOCK_COMMENT : '/*' ASCII_ANY*? '*/' -> channel(COMMENTS); +DECIMAL_BASE : '\'' [sS]? [dD] -> pushMode(DECIMAL_NUMBER_MODE); +ESCAPED_IDENTIFIER : '\\' ASCII_PRINTABLE_NO_SPACE* [ \t\r\n]; +EXPONENTIAL_NUMBER : UNSIGNED_NUMBER ( '.' UNSIGNED_NUMBER)? [eE] [+\-]? UNSIGNED_NUMBER; +FIXED_POINT_NUMBER : UNSIGNED_NUMBER '.' UNSIGNED_NUMBER; +HEX_BASE : '\'' [sS]? [hH] -> pushMode(HEX_NUMBER_MODE); +LINE_COMMENT : '//' ASCII_NO_NEWLINE* -> channel(COMMENTS); +OCTAL_BASE : '\'' [sS]? [oO] -> pushMode(OCTAL_NUMBER_MODE); +SIMPLE_IDENTIFIER : [a-zA-Z_] [a-zA-Z0-9_$]*; +STRING : '"' ( ASCII_NO_NEWLINE_QUOTE_BACKSLASH | ESC_SPECIAL_CHAR)* '"'; +SYSTEM_TF_IDENTIFIER : '$' [a-zA-Z0-9_$] [a-zA-Z0-9_$]*; +UNSIGNED_NUMBER : [0-9] [0-9_]*; +WHITE_SPACE : [ \t\r\n]+ -> channel(HIDDEN); mode BINARY_NUMBER_MODE; -BINARY_VALUE : [01xXzZ?] [01xXzZ?_]* -> popMode ; -WHITE_SPACE_0 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +BINARY_VALUE : [01xXzZ?] [01xXzZ?_]* -> popMode; +WHITE_SPACE_0 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode DECIMAL_NUMBER_MODE; -UNSIGNED_NUMBER_0 : UNSIGNED_NUMBER -> type(UNSIGNED_NUMBER), popMode ; -WHITE_SPACE_1 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; -X_OR_Z_UNDERSCORE : [xXzZ?] '_'* -> popMode ; +UNSIGNED_NUMBER_0 : UNSIGNED_NUMBER -> type(UNSIGNED_NUMBER), popMode; +WHITE_SPACE_1 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); +X_OR_Z_UNDERSCORE : [xXzZ?] '_'* -> popMode; mode EDGE_MODE; -BLOCK_COMMENT_0 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -CO_0 : CO -> type(CO) ; -EDGE_DESCRIPTOR : '01' | '10' | [xXzZ] [01] | [01] [xXzZ] ; -GA_0 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; -LB_0 : LB -> type(LB) ; -LINE_COMMENT_0 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT) ; -RB_0 : RB -> type(RB), popMode ; -WHITE_SPACE_2 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +BLOCK_COMMENT_0 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +CO_0 : CO -> type(CO); +EDGE_DESCRIPTOR : '01' | '10' | [xXzZ] [01] | [01] [xXzZ]; +GA_0 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE); +LB_0 : LB -> type(LB); +LINE_COMMENT_0 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT); +RB_0 : RB -> type(RB), popMode; +WHITE_SPACE_2 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode HEX_NUMBER_MODE; -HEX_VALUE : [0-9a-fA-FxXzZ?] [0-9a-fA-FxXzZ?_]* -> popMode ; -WHITE_SPACE_3 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +HEX_VALUE : [0-9a-fA-FxXzZ?] [0-9a-fA-FxXzZ?_]* -> popMode; +WHITE_SPACE_3 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode LIBRARY_MODE; -BLOCK_COMMENT_1 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -CO_1 : CO -> type(CO) ; -ESCAPED_IDENTIFIER_0 : ESCAPED_IDENTIFIER -> type(ESCAPED_IDENTIFIER) ; -GA_1 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; -LINE_COMMENT_1 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT) ; -MIINCDIR_0 : MIINCDIR -> type(MIINCDIR) ; -SC_0 : SC -> type(SC), popMode ; -SIMPLE_IDENTIFIER_0 : SIMPLE_IDENTIFIER -> type(SIMPLE_IDENTIFIER) ; -WHITE_SPACE_4 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; -FILE_PATH_SPEC : ( [a-zA-Z0-9_./] | ESC_ASCII_PRINTABLE )+ | STRING ; +BLOCK_COMMENT_1 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +CO_1 : CO -> type(CO); +ESCAPED_IDENTIFIER_0 : ESCAPED_IDENTIFIER -> type(ESCAPED_IDENTIFIER); +GA_1 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE); +LINE_COMMENT_1 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT); +MIINCDIR_0 : MIINCDIR -> type(MIINCDIR); +SC_0 : SC -> type(SC), popMode; +SIMPLE_IDENTIFIER_0 : SIMPLE_IDENTIFIER -> type(SIMPLE_IDENTIFIER); +WHITE_SPACE_4 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); +FILE_PATH_SPEC : ( [a-zA-Z0-9_./] | ESC_ASCII_PRINTABLE)+ | STRING; mode OCTAL_NUMBER_MODE; -OCTAL_VALUE : [0-7xXzZ?] [0-7xXzZ?_]* -> popMode ; -WHITE_SPACE_5 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +OCTAL_VALUE : [0-7xXzZ?] [0-7xXzZ?_]* -> popMode; +WHITE_SPACE_5 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode TABLE_MODE; -BLOCK_COMMENT_2 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -CL_0 : CL -> type(CL) ; -EDGE_SYMBOL : [rRfFpPnN*] ; -ENDTABLE_0 : ENDTABLE -> type(ENDTABLE), popMode ; -GA_2 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; -LEVEL_ONLY_SYMBOL : [?bB] ; -LINE_COMMENT_2 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT) ; -LP_0 : LP -> type(LP) ; -MI_0 : MI -> type(MI) ; -OUTPUT_OR_LEVEL_SYMBOL : [01xX] ; -RP_0 : RP -> type(RP) ; -SC_1 : SC -> type(SC) ; -WHITE_SPACE_6 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE) ; +BLOCK_COMMENT_2 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +CL_0 : CL -> type(CL); +EDGE_SYMBOL : [rRfFpPnN*]; +ENDTABLE_0 : ENDTABLE -> type(ENDTABLE), popMode; +GA_2 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE); +LEVEL_ONLY_SYMBOL : [?bB]; +LINE_COMMENT_2 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT); +LP_0 : LP -> type(LP); +MI_0 : MI -> type(MI); +OUTPUT_OR_LEVEL_SYMBOL : [01xX]; +RP_0 : RP -> type(RP); +SC_1 : SC -> type(SC); +WHITE_SPACE_6 : WHITE_SPACE -> channel(HIDDEN), type(WHITE_SPACE); mode DIRECTIVE_MODE; -BEGIN_KEYWORDS_DIRECTIVE : 'begin_keywords' -> channel(DIRECTIVES), mode(BEGIN_KEYWORDS_DIRECTIVE_MODE) ; -CELLDEFINE_DIRECTIVE : 'celldefine' -> channel(DIRECTIVES), popMode ; -DEFAULT_NETTYPE_DIRECTIVE : 'default_nettype' -> channel(DIRECTIVES), mode(DEFAULT_NETTYPE_DIRECTIVE_MODE) ; -DEFINE_DIRECTIVE : 'define' -> channel(DIRECTIVES), mode(DEFINE_DIRECTIVE_MODE) ; -ELSE_DIRECTIVE : 'else' -> channel(DIRECTIVES), popMode, mode(ELSE_DIRECTIVE_MODE) ; -ELSIF_DIRECTIVE : 'elsif' -> channel(DIRECTIVES), popMode, mode(ELSIF_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(INCLUDE_DIRECTIVE_MODE) ; -LINE_DIRECTIVE : 'line' -> channel(DIRECTIVES), mode(LINE_DIRECTIVE_MODE) ; -NOUNCONNECTED_DRIVE_DIRECTIVE : 'nounconnected_drive' -> channel(DIRECTIVES), popMode ; -PRAGMA_DIRECTIVE : 'pragma' -> channel(DIRECTIVES), mode(PRAGMA_DIRECTIVE_MODE) ; -RESETALL_DIRECTIVE : 'resetall' -> channel(DIRECTIVES), popMode ; -TIMESCALE_DIRECTIVE : 'timescale' -> channel(DIRECTIVES), mode(TIMESCALE_DIRECTIVE_MODE) ; -UNCONNECTED_DRIVE_DIRECTIVE : 'unconnected_drive' -> channel(DIRECTIVES), mode(UNCONNECTED_DRIVE_DIRECTIVE_MODE) ; -UNDEF_DIRECTIVE : 'undef' -> channel(DIRECTIVES), mode(UNDEF_DIRECTIVE_MODE) ; -MACRO_USAGE : IDENTIFIER ( WHITE_SPACE? MACRO_ARGS )? -> channel(DIRECTIVES), popMode ; +BEGIN_KEYWORDS_DIRECTIVE: + 'begin_keywords' -> channel(DIRECTIVES), mode(BEGIN_KEYWORDS_DIRECTIVE_MODE) +; +CELLDEFINE_DIRECTIVE: 'celldefine' -> channel(DIRECTIVES), popMode; +DEFAULT_NETTYPE_DIRECTIVE: + 'default_nettype' -> channel(DIRECTIVES), mode(DEFAULT_NETTYPE_DIRECTIVE_MODE) +; +DEFINE_DIRECTIVE : 'define' -> channel(DIRECTIVES), mode(DEFINE_DIRECTIVE_MODE); +ELSE_DIRECTIVE : 'else' -> channel(DIRECTIVES), popMode, mode(ELSE_DIRECTIVE_MODE); +ELSIF_DIRECTIVE : 'elsif' -> channel(DIRECTIVES), popMode, mode(ELSIF_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(INCLUDE_DIRECTIVE_MODE); +LINE_DIRECTIVE : 'line' -> channel(DIRECTIVES), mode(LINE_DIRECTIVE_MODE); +NOUNCONNECTED_DRIVE_DIRECTIVE : 'nounconnected_drive' -> channel(DIRECTIVES), popMode; +PRAGMA_DIRECTIVE : 'pragma' -> channel(DIRECTIVES), mode(PRAGMA_DIRECTIVE_MODE); +RESETALL_DIRECTIVE : 'resetall' -> channel(DIRECTIVES), popMode; +TIMESCALE_DIRECTIVE : 'timescale' -> channel(DIRECTIVES), mode(TIMESCALE_DIRECTIVE_MODE); +UNCONNECTED_DRIVE_DIRECTIVE: + 'unconnected_drive' -> channel(DIRECTIVES), mode(UNCONNECTED_DRIVE_DIRECTIVE_MODE) +; +UNDEF_DIRECTIVE : 'undef' -> channel(DIRECTIVES), mode(UNDEF_DIRECTIVE_MODE); +MACRO_USAGE : IDENTIFIER ( WHITE_SPACE? MACRO_ARGS)? -> channel(DIRECTIVES), popMode; mode BEGIN_KEYWORDS_DIRECTIVE_MODE; -BLOCK_COMMENT_3 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -DQ_0 : DQ -> channel(DIRECTIVES), type(DQ) ; -NEWLINE_0 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_0 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -VERSION_SPECIFIER : ( '1364-2005' | '1364-2001' | '1364-2001-noconfig' | '1364-1995' ) -> channel(DIRECTIVES) ; +BLOCK_COMMENT_3 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +DQ_0 : DQ -> channel(DIRECTIVES), type(DQ); +NEWLINE_0 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_0 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +VERSION_SPECIFIER: + ('1364-2005' | '1364-2001' | '1364-2001-noconfig' | '1364-1995') -> channel(DIRECTIVES) +; mode DEFAULT_NETTYPE_DIRECTIVE_MODE; -BLOCK_COMMENT_4 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -DEFAULT_NETTYPE_VALUE : ( 'wire' | 'tri' | 'tri0' | 'tri1' | 'wand' | 'triand' | 'wor' | 'trior' | 'trireg' | 'uwire' | 'none' ) -> channel(DIRECTIVES), popMode ; -NEWLINE_1 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_1 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +BLOCK_COMMENT_4: BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +DEFAULT_NETTYPE_VALUE: + ( + 'wire' + | 'tri' + | 'tri0' + | 'tri1' + | 'wand' + | 'triand' + | 'wor' + | 'trior' + | 'trireg' + | 'uwire' + | 'none' + ) -> channel(DIRECTIVES), popMode +; +NEWLINE_1 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_1 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode DEFINE_DIRECTIVE_MODE; -MACRO_NAME : IDENTIFIER MACRO_ARGS? -> channel(DIRECTIVES), mode(MACRO_TEXT_MODE) ; -NEWLINE_12 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_11 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +MACRO_NAME : IDENTIFIER MACRO_ARGS? -> channel(DIRECTIVES), mode(MACRO_TEXT_MODE); +NEWLINE_12 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_11 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode ELSE_DIRECTIVE_MODE; -NEWLINE_8 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE) ; -SPACE_TAB_7 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +NEWLINE_8 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE); +SPACE_TAB_7 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode ELSIF_DIRECTIVE_MODE; -IDENTIFIER_0 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER) ; -NEWLINE_9 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE) ; -SPACE_TAB_8 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +IDENTIFIER_0 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER); +NEWLINE_9 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), mode(SOURCE_TEXT_MODE); +SPACE_TAB_8 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode FILENAME_MODE; -DQ_1 : DQ -> channel(DIRECTIVES), type(DQ), popMode ; -FILENAME : ( ASCII_PRINTABLE_NO_QUOTE_BACKSLASH | ESC_ASCII_PRINTABLE )+ -> channel(DIRECTIVES) ; +DQ_1 : DQ -> channel(DIRECTIVES), type(DQ), popMode; +FILENAME : ( ASCII_PRINTABLE_NO_QUOTE_BACKSLASH | ESC_ASCII_PRINTABLE)+ -> channel(DIRECTIVES); mode IFDEF_DIRECTIVE_MODE; -IDENTIFIER_1 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER) ; -NEWLINE_10 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), pushMode(SOURCE_TEXT_MODE) ; -SPACE_TAB_9 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +IDENTIFIER_1 : IDENTIFIER -> channel(DIRECTIVES), type(MACRO_IDENTIFIER); +NEWLINE_10 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), pushMode(SOURCE_TEXT_MODE); +SPACE_TAB_9 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode INCLUDE_DIRECTIVE_MODE; -DQ_2 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE) ; -NEWLINE_2 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_2 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; +DQ_2 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE); +NEWLINE_2 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_2 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); mode LINE_DIRECTIVE_MODE; -DQ_3 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE) ; -NEWLINE_3 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_3 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -UNSIGNED_NUMBER_1 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER) ; +DQ_3 : DQ -> channel(DIRECTIVES), type(DQ), pushMode(FILENAME_MODE); +NEWLINE_3 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_3 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +UNSIGNED_NUMBER_1 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER); mode MACRO_TEXT_MODE; -BLOCK_COMMENT_5 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -GA_3 : GA -> channel(DIRECTIVES), type(MACRO_TEXT) ; -MACRO_DELIMITER : '``' -> channel(DIRECTIVES) ; -MACRO_ESC_NEWLINE : ESC_NEWLINE -> channel(DIRECTIVES) ; -MACRO_ESC_QUOTE : '`\\`"' -> channel(DIRECTIVES) ; -MACRO_ESC_SEQ : ESC_ASCII_NO_NEWLINE -> channel(DIRECTIVES), type(MACRO_TEXT) ; -MACRO_QUOTE : '`"' -> channel(DIRECTIVES) ; -MACRO_TEXT : ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES) ; -NEWLINE_4 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SL_2 : SL -> more ; -STRING_0 : STRING -> channel(DIRECTIVES), type(STRING) ; +BLOCK_COMMENT_5 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +GA_3 : GA -> channel(DIRECTIVES), type(MACRO_TEXT); +MACRO_DELIMITER : '``' -> channel(DIRECTIVES); +MACRO_ESC_NEWLINE : ESC_NEWLINE -> channel(DIRECTIVES); +MACRO_ESC_QUOTE : '`\\`"' -> channel(DIRECTIVES); +MACRO_ESC_SEQ : ESC_ASCII_NO_NEWLINE -> channel(DIRECTIVES), type(MACRO_TEXT); +MACRO_QUOTE : '`"' -> channel(DIRECTIVES); +MACRO_TEXT : ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES); +NEWLINE_4 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SL_2 : SL -> more; +STRING_0 : STRING -> channel(DIRECTIVES), type(STRING); mode PRAGMA_DIRECTIVE_MODE; -BLOCK_COMMENT_6 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -CO_2 : CO -> channel(DIRECTIVES), type(CO) ; -EQ_0 : EQ -> channel(DIRECTIVES), type(EQ) ; -LP_1 : LP -> channel(DIRECTIVES), type(LP) ; -NEWLINE_5 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -RP_1 : RP -> channel(DIRECTIVES), type(RP) ; -SIMPLE_IDENTIFIER_1 : SIMPLE_IDENTIFIER -> channel(DIRECTIVES), type(SIMPLE_IDENTIFIER) ; -SPACE_TAB_4 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -STRING_1 : STRING -> channel(DIRECTIVES), type(STRING) ; -UNSIGNED_NUMBER_2 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER) ; +BLOCK_COMMENT_6 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +CO_2 : CO -> channel(DIRECTIVES), type(CO); +EQ_0 : EQ -> channel(DIRECTIVES), type(EQ); +LP_1 : LP -> channel(DIRECTIVES), type(LP); +NEWLINE_5 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +RP_1 : RP -> channel(DIRECTIVES), type(RP); +SIMPLE_IDENTIFIER_1 : SIMPLE_IDENTIFIER -> channel(DIRECTIVES), type(SIMPLE_IDENTIFIER); +SPACE_TAB_4 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +STRING_1 : STRING -> channel(DIRECTIVES), type(STRING); +UNSIGNED_NUMBER_2 : UNSIGNED_NUMBER -> channel(DIRECTIVES), type(UNSIGNED_NUMBER); mode SOURCE_TEXT_MODE; -BLOCK_COMMENT_7 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -GA_4 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE) ; -LINE_COMMENT_3 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT) ; -SL_0 : SL -> more ; -SOURCE_TEXT : ASCII_NO_SLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES) ; +BLOCK_COMMENT_7 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +GA_4 : GA -> channel(DIRECTIVES), type(GA), pushMode(DIRECTIVE_MODE); +LINE_COMMENT_3 : LINE_COMMENT -> channel(COMMENTS), type(LINE_COMMENT); +SL_0 : SL -> more; +SOURCE_TEXT : ASCII_NO_SLASH_GRAVE_ACCENT+ -> channel(DIRECTIVES); mode TIMESCALE_DIRECTIVE_MODE; -BLOCK_COMMENT_8 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -NEWLINE_6 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SL_1 : SL -> channel(DIRECTIVES), type(SL) ; -SPACE_TAB_5 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -TIME_UNIT : [munpf]? 's' -> channel(DIRECTIVES) ; -TIME_VALUE : ( '1' | '10' | '100' ) -> channel(DIRECTIVES) ; +BLOCK_COMMENT_8 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +NEWLINE_6 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SL_1 : SL -> channel(DIRECTIVES), type(SL); +SPACE_TAB_5 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +TIME_UNIT : [munpf]? 's' -> channel(DIRECTIVES); +TIME_VALUE : ( '1' | '10' | '100') -> channel(DIRECTIVES); mode UNCONNECTED_DRIVE_DIRECTIVE_MODE; -BLOCK_COMMENT_9 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT) ; -NEWLINE_7 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_6 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; -UNCONNECTED_DRIVE_VALUE : ( 'pull0' | 'pull1' ) -> channel(DIRECTIVES), popMode ; +BLOCK_COMMENT_9 : BLOCK_COMMENT -> channel(COMMENTS), type(BLOCK_COMMENT); +NEWLINE_7 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_6 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); +UNCONNECTED_DRIVE_VALUE : ( 'pull0' | 'pull1') -> channel(DIRECTIVES), popMode; mode UNDEF_DIRECTIVE_MODE; -MACRO_IDENTIFIER : IDENTIFIER -> channel(DIRECTIVES) ; -NEWLINE_11 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode ; -SPACE_TAB_10 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE) ; - -fragment ASCII_ANY : [\u0000-\u007f] ; -fragment ASCII_NO_NEWLINE : [\u0000-\u0009\u000b-\u000c\u000e-\u007f] ; -fragment ASCII_NO_NEWLINE_QUOTE_BACKSLASH : [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u005b\u005d-\u007f] ; -fragment ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT : [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u002e\u0030-\u005b\u005d-\u005f\u0061-\u007f] ; -fragment ASCII_NO_PARENTHESES : [\u0000-\u0027\u002a-\u007f] ; -fragment ASCII_NO_SLASH_GRAVE_ACCENT : [\u0000-\u002e\u0030-\u005f\u0061-\u007f] ; -fragment ASCII_PRINTABLE : [\u0020-\u007e] ; -fragment ASCII_PRINTABLE_NO_QUOTE_BACKSLASH : [\u0020-\u0021\u0023-\u005b\u005d-\u007e] ; -fragment ASCII_PRINTABLE_NO_SPACE : [\u0021-\u007e] ; -fragment CHAR_OCTAL : [0-7] [0-7]? [0-7]? ; -fragment ESC_ASCII_NO_NEWLINE : '\\' ASCII_NO_NEWLINE ; -fragment ESC_ASCII_PRINTABLE : '\\' ASCII_PRINTABLE ; -fragment ESC_NEWLINE : '\\' NEWLINE ; -fragment ESC_SPECIAL_CHAR : '\\' ( [nt\\"] | CHAR_OCTAL ) ; -fragment IDENTIFIER : ESCAPED_IDENTIFIER | SIMPLE_IDENTIFIER ; -fragment MACRO_ARGS : '(' ( MACRO_ARGS | ASCII_NO_PARENTHESES )* ')' ; -fragment NEWLINE : '\r'? '\n' ; -fragment SPACE_TAB : [ \t]+ ; +MACRO_IDENTIFIER : IDENTIFIER -> channel(DIRECTIVES); +NEWLINE_11 : NEWLINE -> channel(HIDDEN), type(WHITE_SPACE), popMode; +SPACE_TAB_10 : SPACE_TAB -> channel(HIDDEN), type(WHITE_SPACE); + +fragment ASCII_ANY : [\u0000-\u007f]; +fragment ASCII_NO_NEWLINE : [\u0000-\u0009\u000b-\u000c\u000e-\u007f]; +fragment ASCII_NO_NEWLINE_QUOTE_BACKSLASH: + [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u005b\u005d-\u007f] +; +fragment ASCII_NO_NEWLINE_QUOTE_SLASH_BACKSLASH_GRAVE_ACCENT: + [\u0000-\u0009\u000b-\u000c\u000e-\u0021\u0023-\u002e\u0030-\u005b\u005d-\u005f\u0061-\u007f] +; +fragment ASCII_NO_PARENTHESES : [\u0000-\u0027\u002a-\u007f]; +fragment ASCII_NO_SLASH_GRAVE_ACCENT : [\u0000-\u002e\u0030-\u005f\u0061-\u007f]; +fragment ASCII_PRINTABLE : [\u0020-\u007e]; +fragment ASCII_PRINTABLE_NO_QUOTE_BACKSLASH : [\u0020-\u0021\u0023-\u005b\u005d-\u007e]; +fragment ASCII_PRINTABLE_NO_SPACE : [\u0021-\u007e]; +fragment CHAR_OCTAL : [0-7] [0-7]? [0-7]?; +fragment ESC_ASCII_NO_NEWLINE : '\\' ASCII_NO_NEWLINE; +fragment ESC_ASCII_PRINTABLE : '\\' ASCII_PRINTABLE; +fragment ESC_NEWLINE : '\\' NEWLINE; +fragment ESC_SPECIAL_CHAR : '\\' ( [nt\\"] | CHAR_OCTAL); +fragment IDENTIFIER : ESCAPED_IDENTIFIER | SIMPLE_IDENTIFIER; +fragment MACRO_ARGS : '(' ( MACRO_ARGS | ASCII_NO_PARENTHESES)* ')'; +fragment NEWLINE : '\r'? '\n'; +fragment SPACE_TAB : [ \t]+; \ No newline at end of file diff --git a/verilog/verilog/VerilogParser.g4 b/verilog/verilog/VerilogParser.g4 index 9c30758ef4..d0fa90eb77 100644 --- a/verilog/verilog/VerilogParser.g4 +++ b/verilog/verilog/VerilogParser.g4 @@ -22,1523 +22,1918 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 VerilogParser; -options { tokenVocab = VerilogLexer; } + +options { + tokenVocab = VerilogLexer; +} // A.1.1 Library source text library_text - : library_description* EOF - ; + : library_description* EOF + ; + library_description - : library_declaration - | include_statement - | config_declaration - ; + : library_declaration + | include_statement + | config_declaration + ; + library_declaration - : 'library' library_identifier file_path_spec ( ',' file_path_spec )* library_incdir? ';' - ; + : 'library' library_identifier file_path_spec (',' file_path_spec)* library_incdir? ';' + ; + library_incdir - : '-incdir' file_path_spec ( ',' file_path_spec )* - ; + : '-incdir' file_path_spec (',' file_path_spec)* + ; + include_statement - : 'include' file_path_spec ';' - ; + : 'include' file_path_spec ';' + ; + file_path_spec - : FILE_PATH_SPEC - ; + : FILE_PATH_SPEC + ; + // A.1.2 Verilog source text source_text - : description* EOF - ; + : description* EOF + ; + description - : module_declaration - | udp_declaration - | config_declaration - ; + : module_declaration + | udp_declaration + | config_declaration + ; + module_declaration - : attribute_instance* module_keyword module_identifier module_parameter_port_list? list_of_port_declarations? ';' module_item* 'endmodule' - ; + : attribute_instance* module_keyword module_identifier module_parameter_port_list? list_of_port_declarations? ';' module_item* 'endmodule' + ; + module_keyword - : 'module' - | 'macromodule' - ; + : 'module' + | 'macromodule' + ; + // A.1.3 Module parameters and ports module_parameter_port_list - : '#' '(' parameter_declaration ( ',' parameter_declaration )* ')' - ; + : '#' '(' parameter_declaration (',' parameter_declaration)* ')' + ; + list_of_port_declarations - : '(' port_declaration ( ',' port_declaration )* ')' - | '(' port ( ',' port )+ ')' - | '(' port_implicit ')' - | '(' port_explicit ')' - | '(' ')' - ; + : '(' port_declaration (',' port_declaration)* ')' + | '(' port ( ',' port)+ ')' + | '(' port_implicit ')' + | '(' port_explicit ')' + | '(' ')' + ; + port - : port_implicit? - | port_explicit - ; + : port_implicit? + | port_explicit + ; + port_implicit - : port_expression - ; + : port_expression + ; + port_explicit - : '.' port_identifier '(' port_expression? ')' - ; + : '.' port_identifier '(' port_expression? ')' + ; + port_expression - : port_reference - | '{' port_reference ( ',' port_reference )* '}' - ; + : port_reference + | '{' port_reference ( ',' port_reference)* '}' + ; + port_reference - : port_identifier ( '[' constant_range_expression ']' )? - ; + : port_identifier ('[' constant_range_expression ']')? + ; + port_declaration - : attribute_instance* inout_declaration - | attribute_instance* input_declaration - | attribute_instance* output_declaration - ; + : attribute_instance* inout_declaration + | attribute_instance* input_declaration + | attribute_instance* output_declaration + ; + // A.1.4 Module items module_item - : port_declaration ';' - | module_or_generate_item - | generate_region - | specify_block - | attribute_instance* parameter_declaration ';' - | attribute_instance* specparam_declaration - ; + : port_declaration ';' + | module_or_generate_item + | generate_region + | specify_block + | attribute_instance* parameter_declaration ';' + | attribute_instance* specparam_declaration + ; + module_or_generate_item - : attribute_instance* module_or_generate_item_declaration - | attribute_instance* local_parameter_declaration ';' - | attribute_instance* parameter_override - | attribute_instance* continuous_assign - | attribute_instance* gate_instantiation - | attribute_instance* module_instantiation - | attribute_instance* udp_instantiation - | attribute_instance* initial_construct - | attribute_instance* always_construct - | attribute_instance* loop_generate_construct - | attribute_instance* conditional_generate_construct - ; + : attribute_instance* module_or_generate_item_declaration + | attribute_instance* local_parameter_declaration ';' + | attribute_instance* parameter_override + | attribute_instance* continuous_assign + | attribute_instance* gate_instantiation + | attribute_instance* module_instantiation + | attribute_instance* udp_instantiation + | attribute_instance* initial_construct + | attribute_instance* always_construct + | attribute_instance* loop_generate_construct + | attribute_instance* conditional_generate_construct + ; + module_or_generate_item_declaration - : net_declaration - | reg_declaration - | integer_declaration - | real_declaration - | time_declaration - | realtime_declaration - | event_declaration - | genvar_declaration - | task_declaration - | function_declaration - ; + : net_declaration + | reg_declaration + | integer_declaration + | real_declaration + | time_declaration + | realtime_declaration + | event_declaration + | genvar_declaration + | task_declaration + | function_declaration + ; + parameter_override - : 'defparam' list_of_defparam_assignments ';' - ; + : 'defparam' list_of_defparam_assignments ';' + ; + // A.1.5 Configuration source text config_declaration - : 'config' config_identifier ';' design_statement config_rule_statement* 'endconfig' - ; + : 'config' config_identifier ';' design_statement config_rule_statement* 'endconfig' + ; + design_statement - : 'design' design_statement_item* ';' - ; + : 'design' design_statement_item* ';' + ; + design_statement_item - : ( library_identifier '.' )? cell_identifier - ; + : (library_identifier '.')? cell_identifier + ; + config_rule_statement - : default_clause liblist_clause ';' - | inst_clause liblist_clause ';' - | inst_clause use_clause ';' - | cell_clause liblist_clause ';' - | cell_clause use_clause ';' - ; + : default_clause liblist_clause ';' + | inst_clause liblist_clause ';' + | inst_clause use_clause ';' + | cell_clause liblist_clause ';' + | cell_clause use_clause ';' + ; + default_clause - : 'default' - ; + : 'default' + ; + inst_clause - : 'instance' inst_name - ; + : 'instance' inst_name + ; + inst_name - : topmodule_identifier ( '.' instance_identifier )* - ; + : topmodule_identifier ('.' instance_identifier)* + ; + cell_clause - : 'cell' ( library_identifier '.' )? cell_identifier - ; + : 'cell' (library_identifier '.')? cell_identifier + ; + liblist_clause - : 'liblist' library_identifier* - ; + : 'liblist' library_identifier* + ; + use_clause - : 'use' ( library_identifier '.' )? cell_identifier ( ':' 'config' )? - ; + : 'use' (library_identifier '.')? cell_identifier (':' 'config')? + ; + // A.2.1.1 Module parameter declarations local_parameter_declaration - : 'localparam' 'signed'? range_? list_of_param_assignments - | 'localparam' parameter_type list_of_param_assignments - ; + : 'localparam' 'signed'? range_? list_of_param_assignments + | 'localparam' parameter_type list_of_param_assignments + ; + parameter_declaration - : 'parameter' 'signed'? range_? list_of_param_assignments - | 'parameter' parameter_type list_of_param_assignments - ; + : 'parameter' 'signed'? range_? list_of_param_assignments + | 'parameter' parameter_type list_of_param_assignments + ; + specparam_declaration - : 'specparam' range_? list_of_specparam_assignments ';' - ; + : 'specparam' range_? list_of_specparam_assignments ';' + ; + parameter_type - : 'integer' - | 'real' - | 'realtime' - | 'time' - ; + : 'integer' + | 'real' + | 'realtime' + | 'time' + ; + // A.2.1.2 Port declarations inout_declaration - : 'inout' net_type? 'signed'? range_? list_of_port_identifiers - ; + : 'inout' net_type? 'signed'? range_? list_of_port_identifiers + ; + input_declaration - : 'input' net_type? 'signed'? range_? list_of_port_identifiers - ; + : 'input' net_type? 'signed'? range_? list_of_port_identifiers + ; + output_declaration - : 'output' net_type? 'signed'? range_? list_of_port_identifiers - | 'output' 'reg' 'signed'? range_? list_of_variable_port_identifiers - | 'output' output_variable_type list_of_variable_port_identifiers - ; + : 'output' net_type? 'signed'? range_? list_of_port_identifiers + | 'output' 'reg' 'signed'? range_? list_of_variable_port_identifiers + | 'output' output_variable_type list_of_variable_port_identifiers + ; + // A.2.1.3 Type declarations event_declaration - : 'event' list_of_event_identifiers ';' - ; + : 'event' list_of_event_identifiers ';' + ; + integer_declaration - : 'integer' list_of_variable_identifiers ';' - ; + : 'integer' list_of_variable_identifiers ';' + ; + net_declaration - : net_type 'signed'? delay3? list_of_net_identifiers ';' - | net_type drive_strength? 'signed'? delay3? list_of_net_decl_assignments ';' - | net_type ( 'vectored' | 'scalared' )? 'signed'? range_ delay3? list_of_net_identifiers ';' - | net_type drive_strength? ( 'vectored' | 'scalared' )? 'signed'? range_ delay3? list_of_net_decl_assignments ';' - | 'trireg' charge_strength? 'signed'? delay3? list_of_net_identifiers ';' - | 'trireg' drive_strength? 'signed'? delay3? list_of_net_decl_assignments ';' - | 'trireg' charge_strength? ( 'vectored' | 'scalared' )? 'signed'? range_ delay3? list_of_net_identifiers ';' - | 'trireg' drive_strength? ( 'vectored' | 'scalared' )? 'signed'? range_ delay3? list_of_net_decl_assignments ';' - ; + : net_type 'signed'? delay3? list_of_net_identifiers ';' + | net_type drive_strength? 'signed'? delay3? list_of_net_decl_assignments ';' + | net_type ('vectored' | 'scalared')? 'signed'? range_ delay3? list_of_net_identifiers ';' + | net_type drive_strength? ('vectored' | 'scalared')? 'signed'? range_ delay3? list_of_net_decl_assignments ';' + | 'trireg' charge_strength? 'signed'? delay3? list_of_net_identifiers ';' + | 'trireg' drive_strength? 'signed'? delay3? list_of_net_decl_assignments ';' + | 'trireg' charge_strength? ('vectored' | 'scalared')? 'signed'? range_ delay3? list_of_net_identifiers ';' + | 'trireg' drive_strength? ('vectored' | 'scalared')? 'signed'? range_ delay3? list_of_net_decl_assignments ';' + ; + real_declaration - : 'real' list_of_real_identifiers ';' - ; + : 'real' list_of_real_identifiers ';' + ; + realtime_declaration - : 'realtime' list_of_real_identifiers ';' - ; + : 'realtime' list_of_real_identifiers ';' + ; + reg_declaration - : 'reg' 'signed'? range_? list_of_variable_identifiers ';' - ; + : 'reg' 'signed'? range_? list_of_variable_identifiers ';' + ; + time_declaration - : 'time' list_of_variable_identifiers ';' - ; + : 'time' list_of_variable_identifiers ';' + ; + // A.2.2.1 Net and variable types net_type - : 'supply0' - | 'supply1' - | 'tri' - | 'triand' - | 'trior' - | 'tri0' - | 'tri1' - | 'uwire' - | 'wire' - | 'wand' - | 'wor' - ; + : 'supply0' + | 'supply1' + | 'tri' + | 'triand' + | 'trior' + | 'tri0' + | 'tri1' + | 'uwire' + | 'wire' + | 'wand' + | 'wor' + ; + output_variable_type - : 'integer' - | 'time' - ; + : 'integer' + | 'time' + ; + real_type - : real_identifier dimension* - | real_identifier '=' constant_expression - ; + : real_identifier dimension* + | real_identifier '=' constant_expression + ; + variable_type - : variable_identifier dimension* - | variable_identifier '=' constant_expression - ; + : variable_identifier dimension* + | variable_identifier '=' constant_expression + ; + // A.2.2.2 Strengths drive_strength - : '(' strength0 ',' strength1 ')' - | '(' strength1 ',' strength0 ')' - | '(' strength0 ',' 'highz1' ')' - | '(' strength1 ',' 'highz0' ')' - | '(' 'highz0' ',' strength1 ')' - | '(' 'highz1' ',' strength0 ')' - ; + : '(' strength0 ',' strength1 ')' + | '(' strength1 ',' strength0 ')' + | '(' strength0 ',' 'highz1' ')' + | '(' strength1 ',' 'highz0' ')' + | '(' 'highz0' ',' strength1 ')' + | '(' 'highz1' ',' strength0 ')' + ; + strength0 - : 'supply0' - | 'strong0' - | 'pull0' - | 'weak0' - ; + : 'supply0' + | 'strong0' + | 'pull0' + | 'weak0' + ; + strength1 - : 'supply1' - | 'strong1' - | 'pull1' - | 'weak1' - ; + : 'supply1' + | 'strong1' + | 'pull1' + | 'weak1' + ; + charge_strength - : '(' 'small' ')' - | '(' 'medium' ')' - | '(' 'large' ')' - ; + : '(' 'small' ')' + | '(' 'medium' ')' + | '(' 'large' ')' + ; + // A.2.2.3 Delays delay3 - : '#' delay_value - | '#' '(' mintypmax_expression ( ',' mintypmax_expression ( ',' mintypmax_expression )? )? ')' - ; + : '#' delay_value + | '#' '(' mintypmax_expression (',' mintypmax_expression ( ',' mintypmax_expression)?)? ')' + ; + delay2 - : '#' delay_value - | '#' '(' mintypmax_expression ( ',' mintypmax_expression )? ')' - ; + : '#' delay_value + | '#' '(' mintypmax_expression ( ',' mintypmax_expression)? ')' + ; + delay_value - : unsigned_number - | real_number - | identifier - ; + : unsigned_number + | real_number + | identifier + ; + // A.2.3 Declaration lists list_of_defparam_assignments - : defparam_assignment ( ',' defparam_assignment )* - ; + : defparam_assignment (',' defparam_assignment)* + ; + list_of_event_identifiers - : event_id ( ',' event_id )* - ; + : event_id (',' event_id)* + ; + event_id - : event_identifier dimension* - ; + : event_identifier dimension* + ; + list_of_net_decl_assignments - : net_decl_assignment ( ',' net_decl_assignment )* - ; + : net_decl_assignment (',' net_decl_assignment)* + ; + list_of_net_identifiers - : net_id ( ',' net_id )* - ; + : net_id (',' net_id)* + ; + net_id - : net_identifier dimension* - ; + : net_identifier dimension* + ; + list_of_param_assignments - : param_assignment ( ',' param_assignment )* - ; + : param_assignment (',' param_assignment)* + ; + list_of_port_identifiers - : port_identifier ( ',' port_identifier )* - ; + : port_identifier (',' port_identifier)* + ; + list_of_real_identifiers - : real_type ( ',' real_type )* - ; + : real_type (',' real_type)* + ; + list_of_specparam_assignments - : specparam_assignment ( ',' specparam_assignment )* - ; + : specparam_assignment (',' specparam_assignment)* + ; + list_of_variable_identifiers - : variable_type ( ',' variable_type )* - ; + : variable_type (',' variable_type)* + ; + list_of_variable_port_identifiers - : var_port_id ( ',' var_port_id )* - ; + : var_port_id (',' var_port_id)* + ; + var_port_id - : port_identifier ( '=' constant_expression )? - ; + : port_identifier ('=' constant_expression)? + ; + // A.2.4 Declaration assignments defparam_assignment - : hierarchical_identifier '=' constant_mintypmax_expression - ; + : hierarchical_identifier '=' constant_mintypmax_expression + ; + net_decl_assignment - : net_identifier '=' expression - ; + : net_identifier '=' expression + ; + param_assignment - : parameter_identifier '=' constant_mintypmax_expression - ; + : parameter_identifier '=' constant_mintypmax_expression + ; + specparam_assignment - : specparam_identifier '=' constant_mintypmax_expression - | pulse_control_specparam - ; + : specparam_identifier '=' constant_mintypmax_expression + | pulse_control_specparam + ; + pulse_control_specparam - : 'PATHPULSE$' '=' '(' reject_limit_value ( ',' error_limit_value )? ')' - | 'PATHPULSE$' specify_input_terminal_descriptor '$' specify_output_terminal_descriptor '=' '(' reject_limit_value ( ',' error_limit_value )? ')' - ; + : 'PATHPULSE$' '=' '(' reject_limit_value (',' error_limit_value)? ')' + | 'PATHPULSE$' specify_input_terminal_descriptor '$' specify_output_terminal_descriptor '=' '(' reject_limit_value ( + ',' error_limit_value + )? ')' + ; + error_limit_value - : limit_value - ; + : limit_value + ; + reject_limit_value - : limit_value - ; + : limit_value + ; + limit_value - : constant_mintypmax_expression - ; + : constant_mintypmax_expression + ; + // A.2.5 Declaration ranges dimension - : '[' dimension_constant_expression ':' dimension_constant_expression ']' - ; + : '[' dimension_constant_expression ':' dimension_constant_expression ']' + ; + range_ - : '[' msb_constant_expression ':' lsb_constant_expression ']' - ; + : '[' msb_constant_expression ':' lsb_constant_expression ']' + ; + // A.2.6 Function declarations function_declaration - : 'function' 'automatic'? function_range_or_type? function_identifier ';' function_item_declaration+ function_statement 'endfunction' - | 'function' 'automatic'? function_range_or_type? function_identifier '(' function_port_list ')' ';' block_item_declaration* function_statement 'endfunction' - ; + : 'function' 'automatic'? function_range_or_type? function_identifier ';' function_item_declaration+ function_statement 'endfunction' + | 'function' 'automatic'? function_range_or_type? function_identifier '(' function_port_list ')' ';' block_item_declaration* function_statement + 'endfunction' + ; + function_item_declaration - : block_item_declaration - | attribute_instance* tf_input_declaration ';' - ; + : block_item_declaration + | attribute_instance* tf_input_declaration ';' + ; + function_port_list - : func_port_item ( ',' func_port_item )* - ; + : func_port_item (',' func_port_item)* + ; + func_port_item - : attribute_instance* tf_input_declaration - ; + : attribute_instance* tf_input_declaration + ; + function_range_or_type - : range_ - | 'signed' range_? - | 'integer' - | 'real' - | 'realtime' - | 'time' - ; + : range_ + | 'signed' range_? + | 'integer' + | 'real' + | 'realtime' + | 'time' + ; + // A.2.7 Task declarations task_declaration - : 'task' 'automatic'? task_identifier ';' task_item_declaration* statement_or_null 'endtask' - | 'task' 'automatic'? task_identifier '(' task_port_list? ')' ';' block_item_declaration* statement_or_null 'endtask' - ; + : 'task' 'automatic'? task_identifier ';' task_item_declaration* statement_or_null 'endtask' + | 'task' 'automatic'? task_identifier '(' task_port_list? ')' ';' block_item_declaration* statement_or_null 'endtask' + ; + task_item_declaration - : block_item_declaration - | attribute_instance* tf_input_declaration ';' - | attribute_instance* tf_output_declaration ';' - | attribute_instance* tf_inout_declaration ';' - ; + : block_item_declaration + | attribute_instance* tf_input_declaration ';' + | attribute_instance* tf_output_declaration ';' + | attribute_instance* tf_inout_declaration ';' + ; + task_port_list - : task_port_item ( ',' task_port_item )* - ; + : task_port_item (',' task_port_item)* + ; + task_port_item - : attribute_instance* tf_input_declaration - | attribute_instance* tf_output_declaration - | attribute_instance* tf_inout_declaration - ; + : attribute_instance* tf_input_declaration + | attribute_instance* tf_output_declaration + | attribute_instance* tf_inout_declaration + ; + tf_input_declaration - : 'input' 'reg'? 'signed'? range_? list_of_port_identifiers - | 'input' task_port_type list_of_port_identifiers - ; + : 'input' 'reg'? 'signed'? range_? list_of_port_identifiers + | 'input' task_port_type list_of_port_identifiers + ; + tf_output_declaration - : 'output' 'reg'? 'signed'? range_? list_of_port_identifiers - | 'output' task_port_type list_of_port_identifiers - ; + : 'output' 'reg'? 'signed'? range_? list_of_port_identifiers + | 'output' task_port_type list_of_port_identifiers + ; + tf_inout_declaration - : 'inout' 'reg'? 'signed'? range_? list_of_port_identifiers - | 'inout' task_port_type list_of_port_identifiers - ; + : 'inout' 'reg'? 'signed'? range_? list_of_port_identifiers + | 'inout' task_port_type list_of_port_identifiers + ; + task_port_type - : 'integer' - | 'real' - | 'realtime' - | 'time' - ; + : 'integer' + | 'real' + | 'realtime' + | 'time' + ; + // A.2.8 Block item declarations block_item_declaration - : attribute_instance* 'reg' 'signed'? range_? list_of_block_variable_identifiers ';' - | attribute_instance* 'integer' list_of_block_variable_identifiers ';' - | attribute_instance* 'time' list_of_block_variable_identifiers ';' - | attribute_instance* 'real' list_of_block_real_identifiers ';' - | attribute_instance* 'realtime' list_of_block_real_identifiers ';' - | attribute_instance* event_declaration - | attribute_instance* local_parameter_declaration ';' - | attribute_instance* parameter_declaration ';' - ; + : attribute_instance* 'reg' 'signed'? range_? list_of_block_variable_identifiers ';' + | attribute_instance* 'integer' list_of_block_variable_identifiers ';' + | attribute_instance* 'time' list_of_block_variable_identifiers ';' + | attribute_instance* 'real' list_of_block_real_identifiers ';' + | attribute_instance* 'realtime' list_of_block_real_identifiers ';' + | attribute_instance* event_declaration + | attribute_instance* local_parameter_declaration ';' + | attribute_instance* parameter_declaration ';' + ; + list_of_block_variable_identifiers - : block_variable_type ( ',' block_variable_type )* - ; + : block_variable_type (',' block_variable_type)* + ; + list_of_block_real_identifiers - : block_real_type ( ',' block_real_type )* - ; + : block_real_type (',' block_real_type)* + ; + block_variable_type - : variable_identifier dimension* - ; + : variable_identifier dimension* + ; + block_real_type - : real_identifier dimension* - ; + : real_identifier dimension* + ; + // A.3.1 Primitive instantiation and instances gate_instantiation - : cmos_switchtype delay3? cmos_switch_instance ( ',' cmos_switch_instance )* ';' - | enable_gatetype drive_strength? delay3? enable_gate_instance ( ',' enable_gate_instance )* ';' - | mos_switchtype delay3? mos_switch_instance ( ',' mos_switch_instance )* ';' - | n_input_gatetype drive_strength? delay2? n_input_gate_instance ( ',' n_input_gate_instance )* ';' - | n_output_gatetype drive_strength? delay2? n_output_gate_instance ( ',' n_output_gate_instance )* ';' - | pass_en_switchtype delay2? pass_enable_switch_instance ( ',' pass_enable_switch_instance )* ';' - | pass_switchtype pass_switch_instance ( ',' pass_switch_instance )* ';' - | 'pulldown' pulldown_strength? pull_gate_instance ( ',' pull_gate_instance )* ';' - | 'pullup' pullup_strength? pull_gate_instance ( ',' pull_gate_instance )* ';' - ; + : cmos_switchtype delay3? cmos_switch_instance (',' cmos_switch_instance)* ';' + | enable_gatetype drive_strength? delay3? enable_gate_instance (',' enable_gate_instance)* ';' + | mos_switchtype delay3? mos_switch_instance ( ',' mos_switch_instance)* ';' + | n_input_gatetype drive_strength? delay2? n_input_gate_instance (',' n_input_gate_instance)* ';' + | n_output_gatetype drive_strength? delay2? n_output_gate_instance (',' n_output_gate_instance)* ';' + | pass_en_switchtype delay2? pass_enable_switch_instance (',' pass_enable_switch_instance)* ';' + | pass_switchtype pass_switch_instance ( ',' pass_switch_instance)* ';' + | 'pulldown' pulldown_strength? pull_gate_instance (',' pull_gate_instance)* ';' + | 'pullup' pullup_strength? pull_gate_instance ( ',' pull_gate_instance)* ';' + ; + cmos_switch_instance - : name_of_gate_instance? '(' output_terminal ',' input_terminal ',' ncontrol_terminal ',' pcontrol_terminal ')' - ; + : name_of_gate_instance? '(' output_terminal ',' input_terminal ',' ncontrol_terminal ',' pcontrol_terminal ')' + ; + enable_gate_instance - : name_of_gate_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' - ; + : name_of_gate_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' + ; + mos_switch_instance - : name_of_gate_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' - ; + : name_of_gate_instance? '(' output_terminal ',' input_terminal ',' enable_terminal ')' + ; + n_input_gate_instance - : name_of_gate_instance? '(' output_terminal ',' input_terminal ( ',' input_terminal )* ')' - ; + : name_of_gate_instance? '(' output_terminal ',' input_terminal (',' input_terminal)* ')' + ; + n_output_gate_instance - : name_of_gate_instance? '(' output_terminal ( ',' output_terminal )* ',' input_terminal ')' - ; + : name_of_gate_instance? '(' output_terminal (',' output_terminal)* ',' input_terminal ')' + ; + pass_switch_instance - : name_of_gate_instance? '(' inout_terminal ',' inout_terminal ')' - ; + : name_of_gate_instance? '(' inout_terminal ',' inout_terminal ')' + ; + pass_enable_switch_instance - : name_of_gate_instance? '(' inout_terminal ',' inout_terminal ',' enable_terminal ')' - ; + : name_of_gate_instance? '(' inout_terminal ',' inout_terminal ',' enable_terminal ')' + ; + pull_gate_instance - : name_of_gate_instance? '(' output_terminal ')' - ; + : name_of_gate_instance? '(' output_terminal ')' + ; + name_of_gate_instance - : gate_instance_identifier range_? - ; + : gate_instance_identifier range_? + ; + // A.3.2 Primitive strengths pulldown_strength - : '(' strength0 ',' strength1 ')' - | '(' strength1 ',' strength0 ')' - | '(' strength0 ')' - ; + : '(' strength0 ',' strength1 ')' + | '(' strength1 ',' strength0 ')' + | '(' strength0 ')' + ; + pullup_strength - : '(' strength0 ',' strength1 ')' - | '(' strength1 ',' strength0 ')' - | '(' strength1 ')' - ; + : '(' strength0 ',' strength1 ')' + | '(' strength1 ',' strength0 ')' + | '(' strength1 ')' + ; + // A.3.3 Primitive terminals enable_terminal - : expression - ; + : expression + ; + inout_terminal - : net_lvalue - ; + : net_lvalue + ; + input_terminal - : expression - ; + : expression + ; + ncontrol_terminal - : expression - ; + : expression + ; + output_terminal - : net_lvalue - ; + : net_lvalue + ; + pcontrol_terminal - : expression - ; + : expression + ; + // A.3.4 Primitive gate and switch types cmos_switchtype - : 'cmos' - | 'rcmos' - ; + : 'cmos' + | 'rcmos' + ; + enable_gatetype - : 'bufif0' - | 'bufif1' - | 'notif0' - | 'notif1' - ; + : 'bufif0' + | 'bufif1' + | 'notif0' + | 'notif1' + ; + mos_switchtype - : 'nmos' - | 'pmos' - | 'rnmos' - | 'rpmos' - ; + : 'nmos' + | 'pmos' + | 'rnmos' + | 'rpmos' + ; + n_input_gatetype - : 'and' - | 'nand' - | 'or' - | 'nor' - | 'xor' - | 'xnor' - ; + : 'and' + | 'nand' + | 'or' + | 'nor' + | 'xor' + | 'xnor' + ; + n_output_gatetype - : 'buf' - | 'not' - ; + : 'buf' + | 'not' + ; + pass_en_switchtype - : 'tranif0' - | 'tranif1' - | 'rtranif1' - | 'rtranif0' - ; + : 'tranif0' + | 'tranif1' + | 'rtranif1' + | 'rtranif0' + ; + pass_switchtype - : 'tran' - | 'rtran' - ; + : 'tran' + | 'rtran' + ; + // A.4.1 Module instantiation module_instantiation - : module_identifier parameter_value_assignment? module_instance ( ',' module_instance )* ';' - ; + : module_identifier parameter_value_assignment? module_instance (',' module_instance)* ';' + ; + parameter_value_assignment - : '#' '(' list_of_parameter_assignments ')' - ; + : '#' '(' list_of_parameter_assignments ')' + ; + list_of_parameter_assignments - : ordered_parameter_assignment ( ',' ordered_parameter_assignment )* - | named_parameter_assignment ( ',' named_parameter_assignment )* - ; + : ordered_parameter_assignment (',' ordered_parameter_assignment)* + | named_parameter_assignment ( ',' named_parameter_assignment)* + ; + ordered_parameter_assignment - : expression - ; + : expression + ; + named_parameter_assignment - : '.' parameter_identifier '(' mintypmax_expression? ')' - ; + : '.' parameter_identifier '(' mintypmax_expression? ')' + ; + module_instance - : name_of_module_instance '(' list_of_port_connections ')' - ; + : name_of_module_instance '(' list_of_port_connections ')' + ; + name_of_module_instance - : module_instance_identifier range_? - ; + : module_instance_identifier range_? + ; + list_of_port_connections - : ordered_port_connection ( ',' ordered_port_connection )* - | named_port_connection ( ',' named_port_connection )* - ; + : ordered_port_connection (',' ordered_port_connection)* + | named_port_connection ( ',' named_port_connection)* + ; + ordered_port_connection - : attribute_instance* expression? - ; + : attribute_instance* expression? + ; + named_port_connection - : attribute_instance* '.' port_identifier '(' expression? ')' - ; + : attribute_instance* '.' port_identifier '(' expression? ')' + ; + // A.4.2 Generate construct generate_region - : 'generate' module_or_generate_item* 'endgenerate' - ; + : 'generate' module_or_generate_item* 'endgenerate' + ; + genvar_declaration - : 'genvar' list_of_genvar_identifiers ';' - ; + : 'genvar' list_of_genvar_identifiers ';' + ; + list_of_genvar_identifiers - : genvar_identifier ( ',' genvar_identifier )* - ; + : genvar_identifier (',' genvar_identifier)* + ; + loop_generate_construct - : 'for' '(' genvar_initialization ';' genvar_expression ';' genvar_iteration ')' generate_block - ; + : 'for' '(' genvar_initialization ';' genvar_expression ';' genvar_iteration ')' generate_block + ; + genvar_initialization - : genvar_identifier '=' constant_expression - ; + : genvar_identifier '=' constant_expression + ; + genvar_expression - : constant_expression - ; + : constant_expression + ; + genvar_iteration - : genvar_identifier '=' genvar_expression - ; + : genvar_identifier '=' genvar_expression + ; + conditional_generate_construct - : if_generate_construct - | case_generate_construct - ; + : if_generate_construct + | case_generate_construct + ; + if_generate_construct - : 'if' '(' constant_expression ')' generate_block_or_null ( 'else' generate_block_or_null )? - ; + : 'if' '(' constant_expression ')' generate_block_or_null ('else' generate_block_or_null)? + ; + case_generate_construct - : 'case' '(' constant_expression ')' case_generate_item+ 'endcase' - ; + : 'case' '(' constant_expression ')' case_generate_item+ 'endcase' + ; + case_generate_item - : constant_expression ( ',' constant_expression )* ':' generate_block_or_null - | 'default' ':'? generate_block_or_null - ; + : constant_expression (',' constant_expression)* ':' generate_block_or_null + | 'default' ':'? generate_block_or_null + ; + generate_block - : module_or_generate_item - | 'begin' generate_block_name? module_or_generate_item* 'end' - ; + : module_or_generate_item + | 'begin' generate_block_name? module_or_generate_item* 'end' + ; + generate_block_name - : ':' generate_block_identifier - ; + : ':' generate_block_identifier + ; + generate_block_or_null - : generate_block - | ';' - ; + : generate_block + | ';' + ; + // A.5.1 UDP declaration udp_declaration - : attribute_instance* 'primitive' udp_identifier '(' udp_port_list ')' ';' udp_port_declaration+ udp_body 'endprimitive' - | attribute_instance* 'primitive' udp_identifier '(' udp_declaration_port_list ')' ';' udp_body 'endprimitive' - ; + : attribute_instance* 'primitive' udp_identifier '(' udp_port_list ')' ';' udp_port_declaration+ udp_body 'endprimitive' + | attribute_instance* 'primitive' udp_identifier '(' udp_declaration_port_list ')' ';' udp_body 'endprimitive' + ; + // A.5.2 UDP ports udp_port_list - : output_port_identifier ',' input_port_identifier ( ',' input_port_identifier )* - ; + : output_port_identifier ',' input_port_identifier (',' input_port_identifier)* + ; + udp_declaration_port_list - : udp_output_declaration ',' udp_input_declaration ( ',' udp_input_declaration )* - ; + : udp_output_declaration ',' udp_input_declaration (',' udp_input_declaration)* + ; + udp_port_declaration - : udp_output_declaration ';' - | udp_input_declaration ';' - | udp_reg_declaration ';' - ; + : udp_output_declaration ';' + | udp_input_declaration ';' + | udp_reg_declaration ';' + ; + udp_output_declaration - : attribute_instance* 'output' port_identifier - | attribute_instance* 'output' 'reg' port_identifier ( '=' constant_expression )? - ; + : attribute_instance* 'output' port_identifier + | attribute_instance* 'output' 'reg' port_identifier ('=' constant_expression)? + ; + udp_input_declaration - : attribute_instance* 'input' list_of_port_identifiers - ; + : attribute_instance* 'input' list_of_port_identifiers + ; + udp_reg_declaration - : attribute_instance* 'reg' variable_identifier - ; + : attribute_instance* 'reg' variable_identifier + ; + // A.5.3 UDP body udp_body - : combinational_body - | sequential_body - ; + : combinational_body + | sequential_body + ; + combinational_body - : 'table' combinational_entry+ 'endtable' - ; + : 'table' combinational_entry+ 'endtable' + ; + combinational_entry - : level_input_list ':' output_symbol ';' - ; + : level_input_list ':' output_symbol ';' + ; + sequential_body - : udp_initial_statement? 'table' sequential_entry+ 'endtable' - ; + : udp_initial_statement? 'table' sequential_entry+ 'endtable' + ; + udp_initial_statement - : 'initial' output_port_identifier '=' init_val ';' - ; + : 'initial' output_port_identifier '=' init_val ';' + ; + init_val - : binary_number - | unsigned_number - ; + : binary_number + | unsigned_number + ; + sequential_entry - : seq_input_list ':' current_state ':' next_state ';' - ; + : seq_input_list ':' current_state ':' next_state ';' + ; + seq_input_list - : level_input_list - | edge_input_list - ; + : level_input_list + | edge_input_list + ; + level_input_list - : level_symbol+ - ; + : level_symbol+ + ; + edge_input_list - : level_symbol* edge_indicator level_symbol* - ; + : level_symbol* edge_indicator level_symbol* + ; + edge_indicator - : '(' level_symbol level_symbol ')' - | edge_symbol - ; + : '(' level_symbol level_symbol ')' + | edge_symbol + ; + current_state - : level_symbol - ; + : level_symbol + ; + next_state - : output_symbol - | '-' - ; + : output_symbol + | '-' + ; + output_symbol - : OUTPUT_OR_LEVEL_SYMBOL - ; + : OUTPUT_OR_LEVEL_SYMBOL + ; + level_symbol - : LEVEL_ONLY_SYMBOL - | OUTPUT_OR_LEVEL_SYMBOL - ; + : LEVEL_ONLY_SYMBOL + | OUTPUT_OR_LEVEL_SYMBOL + ; + edge_symbol - : EDGE_SYMBOL - ; + : EDGE_SYMBOL + ; + // A.5.4 UDP instantiation udp_instantiation - : udp_identifier drive_strength? delay2? udp_instance ( ',' udp_instance )* ';' - ; + : udp_identifier drive_strength? delay2? udp_instance (',' udp_instance)* ';' + ; + udp_instance - : name_of_udp_instance? '(' output_terminal ',' input_terminal ( ',' input_terminal )* ')' - ; + : name_of_udp_instance? '(' output_terminal ',' input_terminal (',' input_terminal)* ')' + ; + name_of_udp_instance - : udp_instance_identifier range_? - ; + : udp_instance_identifier range_? + ; + // A.6.1 Continuous assignment statements continuous_assign - : 'assign' drive_strength? delay3? list_of_net_assignments ';' - ; + : 'assign' drive_strength? delay3? list_of_net_assignments ';' + ; + list_of_net_assignments - : net_assignment ( ',' net_assignment )* - ; + : net_assignment (',' net_assignment)* + ; + net_assignment - : net_lvalue '=' expression - ; + : net_lvalue '=' expression + ; + // A.6.2 Procedural blocks and assignments initial_construct - : 'initial' statement - ; + : 'initial' statement + ; + always_construct - : 'always' statement - ; + : 'always' statement + ; + blocking_assignment - : variable_lvalue '=' delay_or_event_control? expression - ; + : variable_lvalue '=' delay_or_event_control? expression + ; + nonblocking_assignment - : variable_lvalue '<=' delay_or_event_control? expression - ; + : variable_lvalue '<=' delay_or_event_control? expression + ; + procedural_continuous_assignments - : 'assign' variable_assignment - | 'deassign' variable_lvalue - | 'force' variable_assignment - | 'release' variable_lvalue - ; + : 'assign' variable_assignment + | 'deassign' variable_lvalue + | 'force' variable_assignment + | 'release' variable_lvalue + ; + variable_assignment - : variable_lvalue '=' expression - ; + : variable_lvalue '=' expression + ; + // A.6.3 Parallel and sequential blocks par_block - : 'fork' ( block_name block_item_declaration* )? statement* 'join' - ; + : 'fork' (block_name block_item_declaration*)? statement* 'join' + ; + block_name - : ':' block_identifier - ; + : ':' block_identifier + ; + seq_block - : 'begin' ( block_name block_item_declaration* )? statement* 'end' - ; + : 'begin' (block_name block_item_declaration*)? statement* 'end' + ; + // A.6.4 Statements statement - : attribute_instance* blocking_assignment ';' - | attribute_instance* case_statement - | attribute_instance* conditional_statement - | attribute_instance* disable_statement - | attribute_instance* event_trigger - | attribute_instance* loop_statement - | attribute_instance* nonblocking_assignment ';' - | attribute_instance* par_block - | attribute_instance* procedural_continuous_assignments ';' - | attribute_instance* procedural_timing_control_statement - | attribute_instance* seq_block - | attribute_instance* system_task_enable - | attribute_instance* task_enable - | attribute_instance* wait_statement - ; + : attribute_instance* blocking_assignment ';' + | attribute_instance* case_statement + | attribute_instance* conditional_statement + | attribute_instance* disable_statement + | attribute_instance* event_trigger + | attribute_instance* loop_statement + | attribute_instance* nonblocking_assignment ';' + | attribute_instance* par_block + | attribute_instance* procedural_continuous_assignments ';' + | attribute_instance* procedural_timing_control_statement + | attribute_instance* seq_block + | attribute_instance* system_task_enable + | attribute_instance* task_enable + | attribute_instance* wait_statement + ; + statement_or_null - : statement - | attribute_instance* ';' - ; + : statement + | attribute_instance* ';' + ; + function_statement - : statement - ; + : statement + ; + // A.6.5 Timing control statements delay_control - : '#' delay_value - | '#' '(' mintypmax_expression ')' - ; + : '#' delay_value + | '#' '(' mintypmax_expression ')' + ; + delay_or_event_control - : delay_control - | event_control - | 'repeat' '(' expression ')' event_control - ; + : delay_control + | event_control + | 'repeat' '(' expression ')' event_control + ; + disable_statement - : 'disable' hierarchical_identifier ';' - ; + : 'disable' hierarchical_identifier ';' + ; + event_control - : '@' hierarchical_identifier - | '@' '(' event_expression ')' - | '@' '*' - | '@' '(' '*' ')' - ; + : '@' hierarchical_identifier + | '@' '(' event_expression ')' + | '@' '*' + | '@' '(' '*' ')' + ; + event_trigger - : '->' hierarchical_identifier bit_select? ';' - ; + : '->' hierarchical_identifier bit_select? ';' + ; + event_expression - : expression - | 'posedge' expression - | 'negedge' expression - | event_expression 'or' event_expression - | event_expression ',' event_expression - ; + : expression + | 'posedge' expression + | 'negedge' expression + | event_expression 'or' event_expression + | event_expression ',' event_expression + ; + procedural_timing_control - : delay_control - | event_control - ; + : delay_control + | event_control + ; + procedural_timing_control_statement - : procedural_timing_control statement_or_null - ; + : procedural_timing_control statement_or_null + ; + wait_statement - : 'wait' '(' expression ')' statement_or_null - ; + : 'wait' '(' expression ')' statement_or_null + ; + // A.6.6 Conditional statements conditional_statement - : 'if' '(' expression ')' statement_or_null ( 'else' statement_or_null )? - ; + : 'if' '(' expression ')' statement_or_null ('else' statement_or_null)? + ; + // A.6.7 Case statements case_statement - : 'case' '(' expression ')' case_item+ 'endcase' - | 'casez' '(' expression ')' case_item+ 'endcase' - | 'casex' '(' expression ')' case_item+ 'endcase' - ; + : 'case' '(' expression ')' case_item+ 'endcase' + | 'casez' '(' expression ')' case_item+ 'endcase' + | 'casex' '(' expression ')' case_item+ 'endcase' + ; + case_item - : expression ( ',' expression )* ':' statement_or_null - | 'default' ':'? statement_or_null - ; + : expression (',' expression)* ':' statement_or_null + | 'default' ':'? statement_or_null + ; + // A.6.8 Looping statements loop_statement - : 'forever' statement - | 'repeat' '(' expression ')' statement - | 'while' '(' expression ')' statement - | 'for' '(' variable_assignment ';' expression ';' variable_assignment ')' statement - ; + : 'forever' statement + | 'repeat' '(' expression ')' statement + | 'while' '(' expression ')' statement + | 'for' '(' variable_assignment ';' expression ';' variable_assignment ')' statement + ; + // A.6.9 Task enable statements system_task_enable - : system_task_identifier sys_task_en_port_list? ';' - ; + : system_task_identifier sys_task_en_port_list? ';' + ; + sys_task_en_port_list - : '(' sys_task_en_port_item ( ',' sys_task_en_port_item )* ')' - ; + : '(' sys_task_en_port_item (',' sys_task_en_port_item)* ')' + ; + sys_task_en_port_item - : expression? - ; + : expression? + ; + task_enable - : hierarchical_identifier task_en_port_list? ';' - ; + : hierarchical_identifier task_en_port_list? ';' + ; + task_en_port_list - : '(' expression ( ',' expression )* ')' - ; + : '(' expression (',' expression)* ')' + ; + // A.7.1 Specify block declaration specify_block - : 'specify' specify_item* 'endspecify' - ; + : 'specify' specify_item* 'endspecify' + ; + specify_item - : specparam_declaration - | pulsestyle_declaration - | showcancelled_declaration - | path_declaration - | system_timing_check - ; + : specparam_declaration + | pulsestyle_declaration + | showcancelled_declaration + | path_declaration + | system_timing_check + ; + pulsestyle_declaration - : 'pulsestyle_onevent' list_of_path_outputs ';' - | 'pulsestyle_ondetect' list_of_path_outputs ';' - ; + : 'pulsestyle_onevent' list_of_path_outputs ';' + | 'pulsestyle_ondetect' list_of_path_outputs ';' + ; + showcancelled_declaration - : 'showcancelled' list_of_path_outputs ';' - | 'noshowcancelled' list_of_path_outputs ';' - ; + : 'showcancelled' list_of_path_outputs ';' + | 'noshowcancelled' list_of_path_outputs ';' + ; + // A.7.2 Specify path declarations path_declaration - : simple_path_declaration ';' - | edge_sensitive_path_declaration ';' - | state_dependent_path_declaration ';' - ; + : simple_path_declaration ';' + | edge_sensitive_path_declaration ';' + | state_dependent_path_declaration ';' + ; + simple_path_declaration - : parallel_path_description '=' path_delay_value - | full_path_description '=' path_delay_value - ; + : parallel_path_description '=' path_delay_value + | full_path_description '=' path_delay_value + ; + parallel_path_description - : '(' specify_input_terminal_descriptor polarity_operator? '=>' specify_output_terminal_descriptor ')' - ; + : '(' specify_input_terminal_descriptor polarity_operator? '=>' specify_output_terminal_descriptor ')' + ; + full_path_description - : '(' list_of_path_inputs polarity_operator? '*>' list_of_path_outputs ')' - ; + : '(' list_of_path_inputs polarity_operator? '*>' list_of_path_outputs ')' + ; + list_of_path_inputs - : specify_input_terminal_descriptor ( ',' specify_input_terminal_descriptor )* - ; + : specify_input_terminal_descriptor (',' specify_input_terminal_descriptor)* + ; + list_of_path_outputs - : specify_output_terminal_descriptor ( ',' specify_output_terminal_descriptor )* - ; + : specify_output_terminal_descriptor (',' specify_output_terminal_descriptor)* + ; + // A.7.3 Specify block terminals specify_input_terminal_descriptor - : input_identifier ( '[' constant_range_expression ']' )? - ; + : input_identifier ('[' constant_range_expression ']')? + ; + specify_output_terminal_descriptor - : output_identifier ( '[' constant_range_expression ']' )? - ; + : output_identifier ('[' constant_range_expression ']')? + ; + input_identifier - : port_identifier - ; + : port_identifier + ; + output_identifier - : port_identifier - ; + : port_identifier + ; + // A.7.4 Specify path delays path_delay_value - : list_of_path_delay_expressions - | '(' list_of_path_delay_expressions ')' - ; + : list_of_path_delay_expressions + | '(' list_of_path_delay_expressions ')' + ; + list_of_path_delay_expressions - : t_path_delay_expression - | trise_path_delay_expression ',' tfall_path_delay_expression ( ',' tz_path_delay_expression )? - | t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ',' tz1_path_delay_expression ',' t1z_path_delay_expression ',' tz0_path_delay_expression ( ',' t0x_path_delay_expression ',' tx1_path_delay_expression ',' t1x_path_delay_expression ',' tx0_path_delay_expression ',' txz_path_delay_expression ',' tzx_path_delay_expression )? - ; + : t_path_delay_expression + | trise_path_delay_expression ',' tfall_path_delay_expression (',' tz_path_delay_expression)? + | t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ',' tz1_path_delay_expression ',' + t1z_path_delay_expression ',' tz0_path_delay_expression ( + ',' t0x_path_delay_expression ',' tx1_path_delay_expression ',' t1x_path_delay_expression ',' tx0_path_delay_expression ',' + txz_path_delay_expression ',' tzx_path_delay_expression + )? + ; + t_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + trise_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tfall_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tz_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t01_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t10_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t0z_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tz1_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t1z_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tz0_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t0x_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tx1_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + t1x_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tx0_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + txz_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + tzx_path_delay_expression - : path_delay_expression - ; + : path_delay_expression + ; + path_delay_expression - : constant_mintypmax_expression - ; + : constant_mintypmax_expression + ; + edge_sensitive_path_declaration - : parallel_edge_sensitive_path_description '=' path_delay_value - | full_edge_sensitive_path_description '=' path_delay_value - ; + : parallel_edge_sensitive_path_description '=' path_delay_value + | full_edge_sensitive_path_description '=' path_delay_value + ; + parallel_edge_sensitive_path_description - : '(' edge_identifier? specify_input_terminal_descriptor '=>' '(' specify_output_terminal_descriptor polarity_operator? ':' data_source_expression ')' ')' - ; + : '(' edge_identifier? specify_input_terminal_descriptor '=>' '(' specify_output_terminal_descriptor polarity_operator? ':' data_source_expression + ')' ')' + ; + full_edge_sensitive_path_description - : '(' edge_identifier? list_of_path_inputs '*>' '(' list_of_path_outputs polarity_operator? ':' data_source_expression ')' ')' - ; + : '(' edge_identifier? list_of_path_inputs '*>' '(' list_of_path_outputs polarity_operator? ':' data_source_expression ')' ')' + ; + data_source_expression - : expression - ; + : expression + ; + edge_identifier - : 'posedge' - | 'negedge' - ; + : 'posedge' + | 'negedge' + ; + state_dependent_path_declaration - : 'if' '(' module_path_expression ')' simple_path_declaration - | 'if' '(' module_path_expression ')' edge_sensitive_path_declaration - | 'ifnone' simple_path_declaration - ; + : 'if' '(' module_path_expression ')' simple_path_declaration + | 'if' '(' module_path_expression ')' edge_sensitive_path_declaration + | 'ifnone' simple_path_declaration + ; + polarity_operator - : '+' - | '-' - ; + : '+' + | '-' + ; + // A.7.5.1 System timing check commands system_timing_check - : setup_timing_check - | hold_timing_check - | setuphold_timing_check - | recovery_timing_check - | removal_timing_check - | recrem_timing_check - | skew_timing_check - | timeskew_timing_check - | fullskew_timing_check - | period_timing_check - | width_timing_check - | nochange_timing_check - ; + : setup_timing_check + | hold_timing_check + | setuphold_timing_check + | recovery_timing_check + | removal_timing_check + | recrem_timing_check + | skew_timing_check + | timeskew_timing_check + | fullskew_timing_check + | period_timing_check + | width_timing_check + | nochange_timing_check + ; + setup_timing_check - : '$setup' '(' data_event ',' reference_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$setup' '(' data_event ',' reference_event ',' timing_check_limit notifier_opt? ')' ';' + ; + notifier_opt - : ',' notifier? - ; + : ',' notifier? + ; + hold_timing_check - : '$hold' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$hold' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + setuphold_timing_check - : '$setuphold' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' - ; + : '$setuphold' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' + ; + timing_check_opt - : ',' notifier? stamptime_cond_opt? - ; + : ',' notifier? stamptime_cond_opt? + ; + stamptime_cond_opt - : ',' stamptime_condition? checktime_cond_opt? - ; + : ',' stamptime_condition? checktime_cond_opt? + ; + checktime_cond_opt - : ',' checktime_condition? delayed_ref_opt? - ; + : ',' checktime_condition? delayed_ref_opt? + ; + delayed_ref_opt - : ',' delayed_reference? delayed_data_opt? - ; + : ',' delayed_reference? delayed_data_opt? + ; + delayed_data_opt - : ',' delayed_data? - ; + : ',' delayed_data? + ; + recovery_timing_check - : '$recovery' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$recovery' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + removal_timing_check - : '$removal' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$removal' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + recrem_timing_check - : '$recrem' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' - ; + : '$recrem' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit timing_check_opt? ')' ';' + ; + skew_timing_check - : '$skew' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$skew' '(' reference_event ',' data_event ',' timing_check_limit notifier_opt? ')' ';' + ; + timeskew_timing_check - : '$timeskew' '(' reference_event ',' data_event ',' timing_check_limit skew_timing_check_opt? ')' ';' - ; + : '$timeskew' '(' reference_event ',' data_event ',' timing_check_limit skew_timing_check_opt? ')' ';' + ; + skew_timing_check_opt - : ',' notifier? event_based_flag_opt? - ; + : ',' notifier? event_based_flag_opt? + ; + event_based_flag_opt - : ',' event_based_flag? remain_active_flag_opt? - ; + : ',' event_based_flag? remain_active_flag_opt? + ; + remain_active_flag_opt - : ',' remain_active_flag? - ; + : ',' remain_active_flag? + ; + fullskew_timing_check - : '$fullskew' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit skew_timing_check_opt? ')' ';' - ; + : '$fullskew' '(' reference_event ',' data_event ',' timing_check_limit ',' timing_check_limit skew_timing_check_opt? ')' ';' + ; + period_timing_check - : '$period' '(' controlled_reference_event ',' timing_check_limit notifier_opt? ')' ';' - ; + : '$period' '(' controlled_reference_event ',' timing_check_limit notifier_opt? ')' ';' + ; + width_timing_check - : '$width' '(' controlled_reference_event ',' timing_check_limit threshold_opt? ')' ';' - ; + : '$width' '(' controlled_reference_event ',' timing_check_limit threshold_opt? ')' ';' + ; + threshold_opt - : ',' threshold ( ',' notifier )? - ; + : ',' threshold (',' notifier)? + ; + nochange_timing_check - : '$nochange' '(' reference_event ',' data_event ',' start_edge_offset ',' end_edge_offset notifier_opt? ')' ';' - ; + : '$nochange' '(' reference_event ',' data_event ',' start_edge_offset ',' end_edge_offset notifier_opt? ')' ';' + ; + // A.7.5.2 System timing check command arguments checktime_condition - : mintypmax_expression - ; + : mintypmax_expression + ; + controlled_reference_event - : controlled_timing_check_event - ; + : controlled_timing_check_event + ; + data_event - : timing_check_event - ; + : timing_check_event + ; + delayed_data - : terminal_identifier ( '[' constant_mintypmax_expression ']' )? - ; + : terminal_identifier ('[' constant_mintypmax_expression ']')? + ; + delayed_reference - : terminal_identifier ( '[' constant_mintypmax_expression ']' )? - ; + : terminal_identifier ('[' constant_mintypmax_expression ']')? + ; + end_edge_offset - : mintypmax_expression - ; + : mintypmax_expression + ; + event_based_flag - : constant_expression - ; + : constant_expression + ; + notifier - : variable_identifier - ; + : variable_identifier + ; + reference_event - : timing_check_event - ; + : timing_check_event + ; + remain_active_flag - : constant_expression - ; + : constant_expression + ; + stamptime_condition - : mintypmax_expression - ; + : mintypmax_expression + ; + start_edge_offset - : mintypmax_expression - ; + : mintypmax_expression + ; + threshold - : constant_expression - ; + : constant_expression + ; + timing_check_limit - : expression - ; + : expression + ; + // A.7.5.3 System timing check event definitions timing_check_event - : timing_check_event_control? specify_terminal_descriptor ( '&&&' timing_check_condition )? - ; + : timing_check_event_control? specify_terminal_descriptor ('&&&' timing_check_condition)? + ; + controlled_timing_check_event - : timing_check_event_control specify_terminal_descriptor ( '&&&' timing_check_condition )? - ; + : timing_check_event_control specify_terminal_descriptor ('&&&' timing_check_condition)? + ; + timing_check_event_control - : 'posedge' - | 'negedge' - | edge_control_specifier - ; + : 'posedge' + | 'negedge' + | edge_control_specifier + ; + specify_terminal_descriptor - : specify_input_terminal_descriptor - | specify_output_terminal_descriptor - ; + : specify_input_terminal_descriptor + | specify_output_terminal_descriptor + ; + edge_control_specifier - : 'edge' '[' edge_descriptor ( ',' edge_descriptor )* ']' - ; + : 'edge' '[' edge_descriptor (',' edge_descriptor)* ']' + ; + edge_descriptor - : EDGE_DESCRIPTOR - ; + : EDGE_DESCRIPTOR + ; + timing_check_condition - : scalar_timing_check_condition - | '(' scalar_timing_check_condition ')' - ; + : scalar_timing_check_condition + | '(' scalar_timing_check_condition ')' + ; + scalar_timing_check_condition - : expression - | '~' expression - | expression '==' scalar_constant - | expression '===' scalar_constant - | expression '!=' scalar_constant - | expression '!==' scalar_constant - ; + : expression + | '~' expression + | expression '==' scalar_constant + | expression '===' scalar_constant + | expression '!=' scalar_constant + | expression '!==' scalar_constant + ; + scalar_constant - : binary_number - | unsigned_number - ; + : binary_number + | unsigned_number + ; + // A.8.1 Concatenations concatenation - : '{' expression ( ',' expression )* '}' - ; + : '{' expression (',' expression)* '}' + ; + constant_concatenation - : '{' constant_expression ( ',' constant_expression )* '}' - ; + : '{' constant_expression (',' constant_expression)* '}' + ; + constant_multiple_concatenation - : '{' constant_expression constant_concatenation '}' - ; + : '{' constant_expression constant_concatenation '}' + ; + module_path_concatenation - : '{' module_path_expression ( ',' module_path_expression )* '}' - ; + : '{' module_path_expression (',' module_path_expression)* '}' + ; + module_path_multiple_concatenation - : '{' constant_expression module_path_concatenation '}' - ; + : '{' constant_expression module_path_concatenation '}' + ; + multiple_concatenation - : '{' constant_expression concatenation '}' - ; + : '{' constant_expression concatenation '}' + ; + // A.8.2 Function calls constant_function_call - : function_identifier attribute_instance* '(' constant_expression ( ',' constant_expression )* ')' - ; + : function_identifier attribute_instance* '(' constant_expression (',' constant_expression)* ')' + ; + constant_system_function_call - : system_function_identifier '(' constant_expression ( ',' constant_expression )* ')' - ; + : system_function_identifier '(' constant_expression (',' constant_expression)* ')' + ; + function_call - : hierarchical_identifier attribute_instance* '(' expression ( ',' expression )* ')' - ; + : hierarchical_identifier attribute_instance* '(' expression (',' expression)* ')' + ; + system_function_call - : system_function_identifier sys_func_call_port_list? - ; + : system_function_identifier sys_func_call_port_list? + ; + sys_func_call_port_list - : '(' expression ( ',' expression )* ')' - ; + : '(' expression (',' expression)* ')' + ; + // A.8.3 Expressions base_expression - : expression - ; + : expression + ; + constant_base_expression - : constant_expression - ; + : constant_expression + ; + constant_expression - : constant_primary - | unary_operator attribute_instance* constant_primary - | constant_expression '**' attribute_instance* constant_expression - | constant_expression ( '*' | '/' | '%' ) attribute_instance* constant_expression - | constant_expression ( '+' | '-' ) attribute_instance* constant_expression - | constant_expression ( '>>' | '<<' | '>>>' | '<<<' ) attribute_instance* constant_expression - | constant_expression ( '<' | '<=' | '>' | '>=' ) attribute_instance* constant_expression - | constant_expression ( '==' | '!=' | '===' | '!==' ) attribute_instance* constant_expression - | constant_expression '&' attribute_instance* constant_expression - | constant_expression ( '^' | '^~' | '~^' ) attribute_instance* constant_expression - | constant_expression '|' attribute_instance* constant_expression - | constant_expression '&&' attribute_instance* constant_expression - | constant_expression '||' attribute_instance* constant_expression - | constant_expression '?' attribute_instance* constant_expression ':' constant_expression - ; + : constant_primary + | unary_operator attribute_instance* constant_primary + | constant_expression '**' attribute_instance* constant_expression + | constant_expression ('*' | '/' | '%') attribute_instance* constant_expression + | constant_expression ( '+' | '-') attribute_instance* constant_expression + | constant_expression ('>>' | '<<' | '>>>' | '<<<') attribute_instance* constant_expression + | constant_expression ('<' | '<=' | '>' | '>=') attribute_instance* constant_expression + | constant_expression ('==' | '!=' | '===' | '!==') attribute_instance* constant_expression + | constant_expression '&' attribute_instance* constant_expression + | constant_expression ('^' | '^~' | '~^') attribute_instance* constant_expression + | constant_expression '|' attribute_instance* constant_expression + | constant_expression '&&' attribute_instance* constant_expression + | constant_expression '||' attribute_instance* constant_expression + | constant_expression '?' attribute_instance* constant_expression ':' constant_expression + ; + constant_mintypmax_expression - : constant_expression ( ':' constant_expression ':' constant_expression )? - ; + : constant_expression (':' constant_expression ':' constant_expression)? + ; + constant_range_expression - : constant_expression - | msb_constant_expression ':' lsb_constant_expression - | constant_base_expression '+:' width_constant_expression - | constant_base_expression '-:' width_constant_expression - ; + : constant_expression + | msb_constant_expression ':' lsb_constant_expression + | constant_base_expression '+:' width_constant_expression + | constant_base_expression '-:' width_constant_expression + ; + dimension_constant_expression - : constant_expression - ; + : constant_expression + ; + expression - : primary - | unary_operator attribute_instance* primary - | expression '**' attribute_instance* expression - | expression ( '*' | '/' | '%' ) attribute_instance* expression - | expression ( '+' | '-' ) attribute_instance* expression - | expression ( '>>' | '<<' | '>>>' | '<<<' ) attribute_instance* expression - | expression ( '<' | '<=' | '>' | '>=' ) attribute_instance* expression - | expression ( '==' | '!=' | '===' | '!==' ) attribute_instance* expression - | expression '&' attribute_instance* expression - | expression ( '^' | '^~' | '~^' ) attribute_instance* expression - | expression '|' attribute_instance* expression - | expression '&&' attribute_instance* expression - | expression '||' attribute_instance* expression - | expression '?' attribute_instance* expression ':' expression - ; + : primary + | unary_operator attribute_instance* primary + | expression '**' attribute_instance* expression + | expression ( '*' | '/' | '%') attribute_instance* expression + | expression ( '+' | '-') attribute_instance* expression + | expression ( '>>' | '<<' | '>>>' | '<<<') attribute_instance* expression + | expression ( '<' | '<=' | '>' | '>=') attribute_instance* expression + | expression ( '==' | '!=' | '===' | '!==') attribute_instance* expression + | expression '&' attribute_instance* expression + | expression ( '^' | '^~' | '~^') attribute_instance* expression + | expression '|' attribute_instance* expression + | expression '&&' attribute_instance* expression + | expression '||' attribute_instance* expression + | expression '?' attribute_instance* expression ':' expression + ; + lsb_constant_expression - : constant_expression - ; + : constant_expression + ; + mintypmax_expression - : expression ( ':' expression ':' expression )? - ; + : expression (':' expression ':' expression)? + ; + module_path_expression - : module_path_primary - | unary_module_path_operator attribute_instance* module_path_primary - | module_path_expression ( '==' | '!=' ) attribute_instance* module_path_expression - | module_path_expression '&' attribute_instance* module_path_expression - | module_path_expression ( '^' | '^~' | '~^' ) attribute_instance* module_path_expression - | module_path_expression '|' attribute_instance* module_path_expression - | module_path_expression '&&' attribute_instance* module_path_expression - | module_path_expression '||' attribute_instance* module_path_expression - | module_path_expression '?' attribute_instance* module_path_expression ':' module_path_expression - ; + : module_path_primary + | unary_module_path_operator attribute_instance* module_path_primary + | module_path_expression ('==' | '!=') attribute_instance* module_path_expression + | module_path_expression '&' attribute_instance* module_path_expression + | module_path_expression ('^' | '^~' | '~^') attribute_instance* module_path_expression + | module_path_expression '|' attribute_instance* module_path_expression + | module_path_expression '&&' attribute_instance* module_path_expression + | module_path_expression '||' attribute_instance* module_path_expression + | module_path_expression '?' attribute_instance* module_path_expression ':' module_path_expression + ; + module_path_mintypmax_expression - : module_path_expression ( ':' module_path_expression ':' module_path_expression )? - ; + : module_path_expression (':' module_path_expression ':' module_path_expression)? + ; + msb_constant_expression - : constant_expression - ; + : constant_expression + ; + range_expression - : expression - | msb_constant_expression ':' lsb_constant_expression - | base_expression '+:' width_constant_expression - | base_expression '-:' width_constant_expression - ; + : expression + | msb_constant_expression ':' lsb_constant_expression + | base_expression '+:' width_constant_expression + | base_expression '-:' width_constant_expression + ; + width_constant_expression - : constant_expression - ; + : constant_expression + ; + // A.8.4 Primaries constant_primary - : number - | identifier ( '[' constant_range_expression ']' )? - | constant_concatenation - | constant_multiple_concatenation - | constant_function_call - | constant_system_function_call - | '(' constant_mintypmax_expression ')' - | string_ - ; + : number + | identifier ( '[' constant_range_expression ']')? + | constant_concatenation + | constant_multiple_concatenation + | constant_function_call + | constant_system_function_call + | '(' constant_mintypmax_expression ')' + | string_ + ; + module_path_primary - : number - | identifier - | module_path_concatenation - | module_path_multiple_concatenation - | function_call - | system_function_call - | '(' module_path_mintypmax_expression ')' - ; + : number + | identifier + | module_path_concatenation + | module_path_multiple_concatenation + | function_call + | system_function_call + | '(' module_path_mintypmax_expression ')' + ; + primary - : number - | hierarchical_identifier select_? - | concatenation - | multiple_concatenation - | function_call - | system_function_call - | '(' mintypmax_expression ')' - | string_ - ; + : number + | hierarchical_identifier select_? + | concatenation + | multiple_concatenation + | function_call + | system_function_call + | '(' mintypmax_expression ')' + | string_ + ; + select_ - : bit_select? '[' range_expression ']' - ; + : bit_select? '[' range_expression ']' + ; + bit_select - : ( '[' expression ']' )+ - ; + : ('[' expression ']')+ + ; + // A.8.5 Expression left-side values net_lvalue - : hierarchical_identifier const_select? - | '{' net_lvalue ( ',' net_lvalue )* '}' - ; + : hierarchical_identifier const_select? + | '{' net_lvalue ( ',' net_lvalue)* '}' + ; + const_select - : const_bit_select? '[' constant_range_expression ']' - ; + : const_bit_select? '[' constant_range_expression ']' + ; + const_bit_select - : ( '[' constant_expression ']' )+ - ; + : ('[' constant_expression ']')+ + ; + variable_lvalue - : hierarchical_identifier select_? - | '{' variable_lvalue ( ',' variable_lvalue )* '}' - ; + : hierarchical_identifier select_? + | '{' variable_lvalue ( ',' variable_lvalue)* '}' + ; + // A.8.6 Operators unary_operator - : '+' - | '-' - | '!' - | '~' - | '&' - | '~&' - | '|' - | '~|' - | '^' - | '~^' - | '^~' - ; + : '+' + | '-' + | '!' + | '~' + | '&' + | '~&' + | '|' + | '~|' + | '^' + | '~^' + | '^~' + ; + unary_module_path_operator - : '!' - | '~' - | '&' - | '~&' - | '|' - | '~|' - | '^' - | '~^' - | '^~' - ; + : '!' + | '~' + | '&' + | '~&' + | '|' + | '~|' + | '^' + | '~^' + | '^~' + ; + // A.8.7 Numbers number - : decimal_number - | octal_number - | binary_number - | hex_number - | real_number - ; + : decimal_number + | octal_number + | binary_number + | hex_number + | real_number + ; + real_number - : fixed_point_number - | exponential_number - ; + : fixed_point_number + | exponential_number + ; + decimal_number - : unsigned_number - | size? decimal_base decimal_value - ; + : unsigned_number + | size? decimal_base decimal_value + ; + binary_number - : size? binary_base binary_value - ; + : size? binary_base binary_value + ; + octal_number - : size? octal_base octal_value - ; + : size? octal_base octal_value + ; + hex_number - : size? hex_base hex_value - ; + : size? hex_base hex_value + ; + size - : UNSIGNED_NUMBER - ; + : UNSIGNED_NUMBER + ; + fixed_point_number - : FIXED_POINT_NUMBER - ; + : FIXED_POINT_NUMBER + ; + exponential_number - : EXPONENTIAL_NUMBER - ; + : EXPONENTIAL_NUMBER + ; + unsigned_number - : UNSIGNED_NUMBER - ; + : UNSIGNED_NUMBER + ; + decimal_value - : UNSIGNED_NUMBER - | X_OR_Z_UNDERSCORE - ; + : UNSIGNED_NUMBER + | X_OR_Z_UNDERSCORE + ; + binary_value - : BINARY_VALUE - ; + : BINARY_VALUE + ; + octal_value - : OCTAL_VALUE - ; + : OCTAL_VALUE + ; + hex_value - : HEX_VALUE - ; + : HEX_VALUE + ; + decimal_base - : DECIMAL_BASE - ; + : DECIMAL_BASE + ; + binary_base - : BINARY_BASE - ; + : BINARY_BASE + ; + octal_base - : OCTAL_BASE - ; + : OCTAL_BASE + ; + hex_base - : HEX_BASE - ; + : HEX_BASE + ; + // A.8.8 Strings string_ - : STRING - ; + : STRING + ; + // A.9.1 Attributes attribute_instance - : '(' '*' attr_spec ( ',' attr_spec )* '*' ')' - ; + : '(' '*' attr_spec (',' attr_spec)* '*' ')' + ; + attr_spec - : attr_name ( '=' constant_expression )? - ; + : attr_name ('=' constant_expression)? + ; + attr_name - : identifier - ; + : identifier + ; + // A.9.3 Identifiers block_identifier - : identifier - ; + : identifier + ; + cell_identifier - : identifier - ; + : identifier + ; + config_identifier - : identifier - ; + : identifier + ; + escaped_identifier - : ESCAPED_IDENTIFIER - ; + : ESCAPED_IDENTIFIER + ; + event_identifier - : identifier - ; + : identifier + ; + function_identifier - : identifier - ; + : identifier + ; + gate_instance_identifier - : identifier - ; + : identifier + ; + generate_block_identifier - : identifier - ; + : identifier + ; + genvar_identifier - : identifier - ; + : identifier + ; + hierarchical_identifier - : hier_ref* identifier - ; + : hier_ref* identifier + ; + hier_ref - : identifier const_bit_select? '.' - ; + : identifier const_bit_select? '.' + ; + identifier - : escaped_identifier - | simple_identifier - ; + : escaped_identifier + | simple_identifier + ; + input_port_identifier - : identifier - ; + : identifier + ; + instance_identifier - : identifier - ; + : identifier + ; + library_identifier - : identifier - ; + : identifier + ; + module_identifier - : identifier - ; + : identifier + ; + module_instance_identifier - : identifier - ; + : identifier + ; + net_identifier - : identifier - ; + : identifier + ; + output_port_identifier - : identifier - ; + : identifier + ; + parameter_identifier - : identifier - ; + : identifier + ; + port_identifier - : identifier - ; + : identifier + ; + real_identifier - : identifier - ; + : identifier + ; + simple_identifier - : SIMPLE_IDENTIFIER - ; + : SIMPLE_IDENTIFIER + ; + specparam_identifier - : identifier - ; + : identifier + ; + system_function_identifier - : SYSTEM_TF_IDENTIFIER - ; + : SYSTEM_TF_IDENTIFIER + ; + system_task_identifier - : SYSTEM_TF_IDENTIFIER - ; + : SYSTEM_TF_IDENTIFIER + ; + task_identifier - : identifier - ; + : identifier + ; + terminal_identifier - : identifier - ; + : identifier + ; + topmodule_identifier - : identifier - ; + : identifier + ; + udp_identifier - : identifier - ; + : identifier + ; + udp_instance_identifier - : identifier - ; + : identifier + ; + variable_identifier - : identifier - ; + : identifier + ; \ No newline at end of file diff --git a/verilog/verilog/VerilogPreParser.g4 b/verilog/verilog/VerilogPreParser.g4 index 5f4ab9aac0..350b9f8d2b 100644 --- a/verilog/verilog/VerilogPreParser.g4 +++ b/verilog/verilog/VerilogPreParser.g4 @@ -22,71 +22,218 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 VerilogPreParser; -options { tokenVocab = VerilogLexer; } -source_text : compiler_directive* ; +options { + tokenVocab = VerilogLexer; +} + +source_text + : compiler_directive* + ; + compiler_directive - : begin_keywords_directive - | celldefine_directive - | default_nettype_directive - | end_keywords_directive - | endcelldefine_directive - | ifdef_directive - | ifndef_directive - | include_directive - | line_directive - | nounconnected_drive_directive - | pragma_directive - | resetall_directive - | text_macro_definition - | text_macro_usage - | timescale_directive - | unconnected_drive_directive - | undef_directive - ; -begin_keywords_directive : GA BEGIN_KEYWORDS_DIRECTIVE DQ version_specifier DQ ; -celldefine_directive : GA CELLDEFINE_DIRECTIVE ; -default_nettype_directive : GA DEFAULT_NETTYPE_DIRECTIVE default_nettype_value ; -default_nettype_value : DEFAULT_NETTYPE_VALUE ; -else_directive : GA ELSE_DIRECTIVE group_of_lines ; -elsif_directive : GA ELSIF_DIRECTIVE macro_identifier group_of_lines ; -end_keywords_directive : GA END_KEYWORDS_DIRECTIVE ; -endcelldefine_directive : GA ENDCELLDEFINE_DIRECTIVE ; -endif_directive : GA ENDIF_DIRECTIVE ; -filename : FILENAME ; -group_of_lines : ( source_text_ | compiler_directive )* ; -identifier : SIMPLE_IDENTIFIER ; -ifdef_directive : GA IFDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive ; -ifndef_directive : GA IFNDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive ; -include_directive : GA INCLUDE_DIRECTIVE DQ filename DQ ; -level : UNSIGNED_NUMBER ; -line_directive : GA LINE_DIRECTIVE number DQ filename DQ level ; -macro_delimiter : MACRO_DELIMITER ; -macro_esc_newline : MACRO_ESC_NEWLINE ; -macro_esc_quote : MACRO_ESC_QUOTE ; -macro_identifier : MACRO_IDENTIFIER ; -macro_name : MACRO_NAME ; -macro_quote : MACRO_QUOTE ; -macro_text : ( macro_text_ | macro_delimiter | macro_esc_newline | macro_esc_quote | macro_quote | string_ )* ; -macro_text_ : MACRO_TEXT ; -macro_usage : MACRO_USAGE ; -nounconnected_drive_directive : GA NOUNCONNECTED_DRIVE_DIRECTIVE ; -number : UNSIGNED_NUMBER ; -pragma_directive : GA PRAGMA_DIRECTIVE pragma_name ( pragma_expression ( CO pragma_expression )* )? ; -pragma_expression : ( pragma_keyword EQ )? pragma_value ; -pragma_keyword : SIMPLE_IDENTIFIER ; -pragma_name : SIMPLE_IDENTIFIER ; -pragma_value : LP pragma_expression ( CO pragma_expression )* RP | number | string_ | identifier ; -resetall_directive : GA RESETALL_DIRECTIVE ; -source_text_ : SOURCE_TEXT ; -string_ : STRING ; -text_macro_definition : GA DEFINE_DIRECTIVE macro_name macro_text ; -text_macro_usage : GA macro_usage ; -time_precision : TIME_VALUE TIME_UNIT ; -time_unit : TIME_VALUE TIME_UNIT ; -timescale_directive : GA TIMESCALE_DIRECTIVE time_unit SL time_precision ; -unconnected_drive_directive : GA UNCONNECTED_DRIVE_DIRECTIVE unconnected_drive_value ; -unconnected_drive_value : UNCONNECTED_DRIVE_VALUE ; -undef_directive : GA UNDEF_DIRECTIVE macro_identifier ; -version_specifier : VERSION_SPECIFIER ; + : begin_keywords_directive + | celldefine_directive + | default_nettype_directive + | end_keywords_directive + | endcelldefine_directive + | ifdef_directive + | ifndef_directive + | include_directive + | line_directive + | nounconnected_drive_directive + | pragma_directive + | resetall_directive + | text_macro_definition + | text_macro_usage + | timescale_directive + | unconnected_drive_directive + | undef_directive + ; + +begin_keywords_directive + : GA BEGIN_KEYWORDS_DIRECTIVE DQ version_specifier DQ + ; + +celldefine_directive + : GA CELLDEFINE_DIRECTIVE + ; + +default_nettype_directive + : GA DEFAULT_NETTYPE_DIRECTIVE default_nettype_value + ; + +default_nettype_value + : DEFAULT_NETTYPE_VALUE + ; + +else_directive + : GA ELSE_DIRECTIVE group_of_lines + ; + +elsif_directive + : GA ELSIF_DIRECTIVE macro_identifier group_of_lines + ; + +end_keywords_directive + : GA END_KEYWORDS_DIRECTIVE + ; + +endcelldefine_directive + : GA ENDCELLDEFINE_DIRECTIVE + ; + +endif_directive + : GA ENDIF_DIRECTIVE + ; + +filename + : FILENAME + ; + +group_of_lines + : (source_text_ | compiler_directive)* + ; + +identifier + : SIMPLE_IDENTIFIER + ; + +ifdef_directive + : GA IFDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive + ; + +ifndef_directive + : GA IFNDEF_DIRECTIVE macro_identifier group_of_lines elsif_directive* else_directive? endif_directive + ; + +include_directive + : GA INCLUDE_DIRECTIVE DQ filename DQ + ; + +level + : UNSIGNED_NUMBER + ; + +line_directive + : GA LINE_DIRECTIVE number DQ filename DQ level + ; + +macro_delimiter + : MACRO_DELIMITER + ; + +macro_esc_newline + : MACRO_ESC_NEWLINE + ; + +macro_esc_quote + : MACRO_ESC_QUOTE + ; + +macro_identifier + : MACRO_IDENTIFIER + ; + +macro_name + : MACRO_NAME + ; + +macro_quote + : MACRO_QUOTE + ; + +macro_text + : (macro_text_ | macro_delimiter | macro_esc_newline | macro_esc_quote | macro_quote | string_)* + ; + +macro_text_ + : MACRO_TEXT + ; + +macro_usage + : MACRO_USAGE + ; + +nounconnected_drive_directive + : GA NOUNCONNECTED_DRIVE_DIRECTIVE + ; + +number + : UNSIGNED_NUMBER + ; + +pragma_directive + : GA PRAGMA_DIRECTIVE pragma_name (pragma_expression ( CO pragma_expression)*)? + ; + +pragma_expression + : (pragma_keyword EQ)? pragma_value + ; + +pragma_keyword + : SIMPLE_IDENTIFIER + ; + +pragma_name + : SIMPLE_IDENTIFIER + ; + +pragma_value + : LP pragma_expression (CO pragma_expression)* RP + | number + | string_ + | identifier + ; + +resetall_directive + : GA RESETALL_DIRECTIVE + ; + +source_text_ + : SOURCE_TEXT + ; + +string_ + : STRING + ; + +text_macro_definition + : GA DEFINE_DIRECTIVE macro_name macro_text + ; + +text_macro_usage + : GA macro_usage + ; + +time_precision + : TIME_VALUE TIME_UNIT + ; + +time_unit + : TIME_VALUE TIME_UNIT + ; + +timescale_directive + : GA TIMESCALE_DIRECTIVE time_unit SL time_precision + ; + +unconnected_drive_directive + : GA UNCONNECTED_DRIVE_DIRECTIVE unconnected_drive_value + ; + +unconnected_drive_value + : UNCONNECTED_DRIVE_VALUE + ; + +undef_directive + : GA UNDEF_DIRECTIVE macro_identifier + ; + +version_specifier + : VERSION_SPECIFIER + ; \ No newline at end of file diff --git a/vhdl/vhdl.g4 b/vhdl/vhdl.g4 index 0a19e1bbfd..6e075e5bb8 100644 --- a/vhdl/vhdl.g4 +++ b/vhdl/vhdl.g4 @@ -15,1672 +15,2073 @@ // along with this program. If not, see . // +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar vhdl; -options { caseInsensitive = true; } - -ABS : 'ABS'; -ACCESS : 'ACCESS'; -ACROSS : 'ACROSS'; -AFTER : 'AFTER'; -ALIAS : 'ALIAS'; -ALL : 'ALL'; -AND : 'AND'; -ARCHITECTURE : 'ARCHITECTURE'; -ARRAY : 'ARRAY'; -ASSERT : 'ASSERT'; -ATTRIBUTE : 'ATTRIBUTE'; -BEGIN : 'BEGIN'; -BLOCK : 'BLOCK'; -BODY : 'BODY'; -BREAK : 'BREAK'; -BUFFER : 'BUFFER'; -BUS : 'BUS'; -CASE : 'CASE'; -COMPONENT : 'COMPONENT'; -CONFIGURATION : 'CONFIGURATION'; -CONSTANT : 'CONSTANT'; -DISCONNECT : 'DISCONNECT'; -DOWNTO : 'DOWNTO'; -END : 'END'; -ENTITY : 'ENTITY'; -ELSE : 'ELSE'; -ELSIF : 'ELSIF'; -EXIT : 'EXIT'; -FILE : 'FILE'; -FOR : 'FOR'; -FUNCTION : 'FUNCTION'; -GENERATE : 'GENERATE'; -GENERIC : 'GENERIC'; -GROUP : 'GROUP'; -GUARDED : 'GUARDED'; -IF : 'IF'; -IMPURE : 'IMPURE'; -IN : 'IN'; -INERTIAL : 'INERTIAL'; -INOUT : 'INOUT'; -IS : 'IS'; -LABEL : 'LABEL'; -LIBRARY : 'LIBRARY'; -LIMIT : 'LIMIT'; -LINKAGE : 'LINKAGE'; -LITERAL : 'LITERAL'; -LOOP : 'LOOP'; -MAP : 'MAP'; -MOD : 'MOD'; -NAND : 'NAND'; -NATURE : 'NATURE'; -NEW : 'NEW'; -NEXT : 'NEXT'; -NOISE : 'NOISE'; -NOR : 'NOR'; -NOT : 'NOT'; -NULL_ : 'NULL'; -OF : 'OF'; -ON : 'ON'; -OPEN : 'OPEN'; -OR : 'OR'; -OTHERS : 'OTHERS'; -OUT : 'OUT'; -PACKAGE : 'PACKAGE'; -PORT : 'PORT'; -POSTPONED : 'POSTPONED'; -PROCESS : 'PROCESS'; -PROCEDURE : 'PROCEDURE'; -PROCEDURAL : 'PROCEDURAL'; -PURE : 'PURE'; -QUANTITY : 'QUANTITY'; -RANGE : 'RANGE'; -REVERSE_RANGE : 'REVERSE_RANGE'; -REJECT : 'REJECT'; -REM : 'REM'; -RECORD : 'RECORD'; -REFERENCE : 'REFERENCE'; -REGISTER : 'REGISTER'; -REPORT : 'REPORT'; -RETURN : 'RETURN'; -ROL : 'ROL'; -ROR : 'ROR'; -SELECT : 'SELECT'; -SEVERITY : 'SEVERITY'; -SHARED : 'SHARED'; -SIGNAL : 'SIGNAL'; -SLA : 'SLA'; -SLL : 'SLL'; -SPECTRUM : 'SPECTRUM'; -SRA : 'SRA'; -SRL : 'SRL'; -SUBNATURE : 'SUBNATURE'; -SUBTYPE : 'SUBTYPE'; -TERMINAL : 'TERMINAL'; -THEN : 'THEN'; -THROUGH : 'THROUGH'; -TO : 'TO'; -TOLERANCE : 'TOLERANCE'; -TRANSPORT : 'TRANSPORT'; -TYPE : 'TYPE'; -UNAFFECTED : 'UNAFFECTED'; -UNITS : 'UNITS'; -UNTIL : 'UNTIL'; -USE : 'USE'; -VARIABLE : 'VARIABLE'; -WAIT : 'WAIT'; -WITH : 'WITH'; -WHEN : 'WHEN'; -WHILE : 'WHILE'; -XNOR : 'XNOR'; -XOR : 'XOR'; +options { + caseInsensitive = true; +} + +ABS + : 'ABS' + ; + +ACCESS + : 'ACCESS' + ; + +ACROSS + : 'ACROSS' + ; + +AFTER + : 'AFTER' + ; + +ALIAS + : 'ALIAS' + ; + +ALL + : 'ALL' + ; + +AND + : 'AND' + ; + +ARCHITECTURE + : 'ARCHITECTURE' + ; + +ARRAY + : 'ARRAY' + ; + +ASSERT + : 'ASSERT' + ; + +ATTRIBUTE + : 'ATTRIBUTE' + ; + +BEGIN + : 'BEGIN' + ; + +BLOCK + : 'BLOCK' + ; + +BODY + : 'BODY' + ; + +BREAK + : 'BREAK' + ; + +BUFFER + : 'BUFFER' + ; + +BUS + : 'BUS' + ; + +CASE + : 'CASE' + ; + +COMPONENT + : 'COMPONENT' + ; + +CONFIGURATION + : 'CONFIGURATION' + ; + +CONSTANT + : 'CONSTANT' + ; + +DISCONNECT + : 'DISCONNECT' + ; + +DOWNTO + : 'DOWNTO' + ; + +END + : 'END' + ; + +ENTITY + : 'ENTITY' + ; + +ELSE + : 'ELSE' + ; + +ELSIF + : 'ELSIF' + ; + +EXIT + : 'EXIT' + ; + +FILE + : 'FILE' + ; + +FOR + : 'FOR' + ; + +FUNCTION + : 'FUNCTION' + ; + +GENERATE + : 'GENERATE' + ; + +GENERIC + : 'GENERIC' + ; + +GROUP + : 'GROUP' + ; + +GUARDED + : 'GUARDED' + ; + +IF + : 'IF' + ; + +IMPURE + : 'IMPURE' + ; +IN + : 'IN' + ; + +INERTIAL + : 'INERTIAL' + ; + +INOUT + : 'INOUT' + ; +IS + : 'IS' + ; + +LABEL + : 'LABEL' + ; + +LIBRARY + : 'LIBRARY' + ; + +LIMIT + : 'LIMIT' + ; + +LINKAGE + : 'LINKAGE' + ; + +LITERAL + : 'LITERAL' + ; + +LOOP + : 'LOOP' + ; + +MAP + : 'MAP' + ; + +MOD + : 'MOD' + ; + +NAND + : 'NAND' + ; + +NATURE + : 'NATURE' + ; + +NEW + : 'NEW' + ; + +NEXT + : 'NEXT' + ; + +NOISE + : 'NOISE' + ; + +NOR + : 'NOR' + ; + +NOT + : 'NOT' + ; + +NULL_ + : 'NULL' + ; + +OF + : 'OF' + ; + +ON + : 'ON' + ; + +OPEN + : 'OPEN' + ; + +OR + : 'OR' + ; + +OTHERS + : 'OTHERS' + ; + +OUT + : 'OUT' + ; + +PACKAGE + : 'PACKAGE' + ; + +PORT + : 'PORT' + ; + +POSTPONED + : 'POSTPONED' + ; + +PROCESS + : 'PROCESS' + ; + +PROCEDURE + : 'PROCEDURE' + ; + +PROCEDURAL + : 'PROCEDURAL' + ; + +PURE + : 'PURE' + ; + +QUANTITY + : 'QUANTITY' + ; + +RANGE + : 'RANGE' + ; + +REVERSE_RANGE + : 'REVERSE_RANGE' + ; + +REJECT + : 'REJECT' + ; + +REM + : 'REM' + ; + +RECORD + : 'RECORD' + ; + +REFERENCE + : 'REFERENCE' + ; + +REGISTER + : 'REGISTER' + ; + +REPORT + : 'REPORT' + ; + +RETURN + : 'RETURN' + ; + +ROL + : 'ROL' + ; + +ROR + : 'ROR' + ; + +SELECT + : 'SELECT' + ; + +SEVERITY + : 'SEVERITY' + ; + +SHARED + : 'SHARED' + ; + +SIGNAL + : 'SIGNAL' + ; + +SLA + : 'SLA' + ; + +SLL + : 'SLL' + ; + +SPECTRUM + : 'SPECTRUM' + ; + +SRA + : 'SRA' + ; + +SRL + : 'SRL' + ; + +SUBNATURE + : 'SUBNATURE' + ; + +SUBTYPE + : 'SUBTYPE' + ; + +TERMINAL + : 'TERMINAL' + ; + +THEN + : 'THEN' + ; + +THROUGH + : 'THROUGH' + ; + +TO + : 'TO' + ; + +TOLERANCE + : 'TOLERANCE' + ; + +TRANSPORT + : 'TRANSPORT' + ; + +TYPE + : 'TYPE' + ; + +UNAFFECTED + : 'UNAFFECTED' + ; + +UNITS + : 'UNITS' + ; + +UNTIL + : 'UNTIL' + ; + +USE + : 'USE' + ; + +VARIABLE + : 'VARIABLE' + ; + +WAIT + : 'WAIT' + ; + +WITH + : 'WITH' + ; + +WHEN + : 'WHEN' + ; + +WHILE + : 'WHILE' + ; + +XNOR + : 'XNOR' + ; + +XOR + : 'XOR' + ; //------------------------------------------Parser---------------------------------------- abstract_literal - : INTEGER - | REAL_LITERAL - | BASE_LITERAL - ; + : INTEGER + | REAL_LITERAL + | BASE_LITERAL + ; access_type_definition - : ACCESS subtype_indication - ; + : ACCESS subtype_indication + ; across_aspect - : identifier_list ( tolerance_aspect )? ( VARASGN expression )? ACROSS - ; + : identifier_list (tolerance_aspect)? (VARASGN expression)? ACROSS + ; actual_designator - : expression - | OPEN - ; + : expression + | OPEN + ; actual_parameter_part - : association_list - ; + : association_list + ; actual_part - : name LPAREN actual_designator RPAREN - | actual_designator - ; + : name LPAREN actual_designator RPAREN + | actual_designator + ; adding_operator - : PLUS - | MINUS - | AMPERSAND - ; + : PLUS + | MINUS + | AMPERSAND + ; aggregate - : LPAREN element_association ( COMMA element_association )* RPAREN - ; + : LPAREN element_association (COMMA element_association)* RPAREN + ; alias_declaration - : ALIAS alias_designator ( COLON alias_indication )? IS - name ( signature )? SEMI - ; + : ALIAS alias_designator (COLON alias_indication)? IS name (signature)? SEMI + ; alias_designator - : identifier - | CHARACTER_LITERAL - | STRING_LITERAL - ; + : identifier + | CHARACTER_LITERAL + | STRING_LITERAL + ; alias_indication - : subnature_indication - | subtype_indication - ; + : subnature_indication + | subtype_indication + ; allocator - : NEW ( qualified_expression | subtype_indication ) - ; + : NEW (qualified_expression | subtype_indication) + ; architecture_body - : ARCHITECTURE identifier OF identifier IS - architecture_declarative_part - BEGIN - architecture_statement_part - END ( ARCHITECTURE )? ( identifier )? SEMI - ; + : ARCHITECTURE identifier OF identifier IS architecture_declarative_part BEGIN architecture_statement_part END ( + ARCHITECTURE + )? (identifier)? SEMI + ; architecture_declarative_part - : ( block_declarative_item )* - ; + : (block_declarative_item)* + ; architecture_statement - : block_statement - | process_statement - | ( label_colon )? concurrent_procedure_call_statement - | ( label_colon )? concurrent_assertion_statement - | ( label_colon )? ( POSTPONED )? concurrent_signal_assignment_statement - | component_instantiation_statement - | generate_statement - | concurrent_break_statement - | simultaneous_statement - ; + : block_statement + | process_statement + | ( label_colon)? concurrent_procedure_call_statement + | ( label_colon)? concurrent_assertion_statement + | ( label_colon)? ( POSTPONED)? concurrent_signal_assignment_statement + | component_instantiation_statement + | generate_statement + | concurrent_break_statement + | simultaneous_statement + ; architecture_statement_part - : ( architecture_statement )* - ; + : (architecture_statement)* + ; array_nature_definition - : unconstrained_nature_definition - | constrained_nature_definition - ; + : unconstrained_nature_definition + | constrained_nature_definition + ; array_type_definition - : unconstrained_array_definition - | constrained_array_definition - ; + : unconstrained_array_definition + | constrained_array_definition + ; assertion - : ASSERT condition ( REPORT expression )? ( SEVERITY expression )? - ; + : ASSERT condition (REPORT expression)? (SEVERITY expression)? + ; assertion_statement - : ( label_colon )? assertion SEMI - ; + : (label_colon)? assertion SEMI + ; association_element - : ( formal_part ARROW )? actual_part - ; + : (formal_part ARROW)? actual_part + ; association_list - : association_element ( COMMA association_element )* - ; + : association_element (COMMA association_element)* + ; attribute_declaration - : ATTRIBUTE label_colon name SEMI - ; + : ATTRIBUTE label_colon name SEMI + ; // Need to add several tokens here, for they are both, VHDLAMS reserved words // and attribute names. // (25.2.2004, e.f.) attribute_designator - : identifier - | RANGE - | REVERSE_RANGE - | ACROSS - | THROUGH - | REFERENCE - | TOLERANCE - ; + : identifier + | RANGE + | REVERSE_RANGE + | ACROSS + | THROUGH + | REFERENCE + | TOLERANCE + ; attribute_specification - : ATTRIBUTE attribute_designator OF entity_specification IS expression SEMI - ; + : ATTRIBUTE attribute_designator OF entity_specification IS expression SEMI + ; base_unit_declaration - : identifier SEMI - ; + : identifier SEMI + ; binding_indication - : ( USE entity_aspect )? ( generic_map_aspect )? ( port_map_aspect )? - ; + : (USE entity_aspect)? (generic_map_aspect)? (port_map_aspect)? + ; block_configuration - : FOR block_specification - ( use_clause )* - ( configuration_item )* - END FOR SEMI - ; + : FOR block_specification (use_clause)* (configuration_item)* END FOR SEMI + ; block_declarative_item - : subprogram_declaration - | subprogram_body - | type_declaration - | subtype_declaration - | constant_declaration - | signal_declaration - | variable_declaration - | file_declaration - | alias_declaration - | component_declaration - | attribute_declaration - | attribute_specification - | configuration_specification - | disconnection_specification - | step_limit_specification - | use_clause - | group_template_declaration - | group_declaration - | nature_declaration - | subnature_declaration - | quantity_declaration - | terminal_declaration - ; + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | signal_declaration + | variable_declaration + | file_declaration + | alias_declaration + | component_declaration + | attribute_declaration + | attribute_specification + | configuration_specification + | disconnection_specification + | step_limit_specification + | use_clause + | group_template_declaration + | group_declaration + | nature_declaration + | subnature_declaration + | quantity_declaration + | terminal_declaration + ; block_declarative_part - : ( block_declarative_item )* - ; + : (block_declarative_item)* + ; block_header - : ( generic_clause ( generic_map_aspect SEMI )? )? - ( port_clause ( port_map_aspect SEMI )? )? - ; + : (generic_clause ( generic_map_aspect SEMI)?)? (port_clause ( port_map_aspect SEMI)?)? + ; block_specification - : identifier ( LPAREN index_specification RPAREN )? - | name - ; + : identifier (LPAREN index_specification RPAREN)? + | name + ; block_statement - : label_colon BLOCK ( LPAREN expression RPAREN )? ( IS )? - block_header - block_declarative_part BEGIN - block_statement_part - END BLOCK ( identifier )? SEMI - ; + : label_colon BLOCK (LPAREN expression RPAREN)? (IS)? block_header block_declarative_part BEGIN block_statement_part END BLOCK ( + identifier + )? SEMI + ; block_statement_part - : ( architecture_statement )* - ; + : (architecture_statement)* + ; branch_quantity_declaration - : QUANTITY ( across_aspect )? - ( through_aspect )? terminal_aspect SEMI - ; + : QUANTITY (across_aspect)? (through_aspect)? terminal_aspect SEMI + ; break_element - : ( break_selector_clause )? name ARROW expression - ; + : (break_selector_clause)? name ARROW expression + ; break_list - : break_element ( COMMA break_element )* - ; + : break_element (COMMA break_element)* + ; break_selector_clause - : FOR name USE - ; + : FOR name USE + ; break_statement - : ( label_colon )? BREAK ( break_list )? ( WHEN condition )? SEMI - ; + : (label_colon)? BREAK (break_list)? (WHEN condition)? SEMI + ; case_statement - : ( label_colon )? CASE expression IS - ( case_statement_alternative )+ - END CASE ( identifier )? SEMI - ; + : (label_colon)? CASE expression IS (case_statement_alternative)+ END CASE (identifier)? SEMI + ; case_statement_alternative - : WHEN choices ARROW sequence_of_statements - ; + : WHEN choices ARROW sequence_of_statements + ; choice - : identifier - | discrete_range - | simple_expression - | OTHERS - ; + : identifier + | discrete_range + | simple_expression + | OTHERS + ; choices - : choice ( BAR choice )* - ; + : choice (BAR choice)* + ; component_configuration - : FOR component_specification - ( binding_indication SEMI )? - ( block_configuration )? - END FOR SEMI - ; + : FOR component_specification (binding_indication SEMI)? (block_configuration)? END FOR SEMI + ; component_declaration - : COMPONENT identifier ( IS )? - ( generic_clause )? - ( port_clause )? - END COMPONENT ( identifier )? SEMI - ; + : COMPONENT identifier (IS)? (generic_clause)? (port_clause)? END COMPONENT (identifier)? SEMI + ; component_instantiation_statement - : label_colon instantiated_unit - ( generic_map_aspect )? - ( port_map_aspect )? SEMI - ; + : label_colon instantiated_unit (generic_map_aspect)? (port_map_aspect)? SEMI + ; component_specification - : instantiation_list COLON name - ; + : instantiation_list COLON name + ; composite_nature_definition - : array_nature_definition - | record_nature_definition - ; + : array_nature_definition + | record_nature_definition + ; composite_type_definition - : array_type_definition - | record_type_definition - ; + : array_type_definition + | record_type_definition + ; concurrent_assertion_statement - : ( label_colon )? ( POSTPONED )? assertion SEMI - ; + : (label_colon)? (POSTPONED)? assertion SEMI + ; concurrent_break_statement - : ( label_colon )? BREAK ( break_list )? ( sensitivity_clause )? - ( WHEN condition )? SEMI - ; + : (label_colon)? BREAK (break_list)? (sensitivity_clause)? (WHEN condition)? SEMI + ; concurrent_procedure_call_statement - : ( label_colon )? ( POSTPONED )? procedure_call SEMI - ; + : (label_colon)? (POSTPONED)? procedure_call SEMI + ; concurrent_signal_assignment_statement - : ( label_colon )? ( POSTPONED )? - ( conditional_signal_assignment | selected_signal_assignment ) - ; + : (label_colon)? (POSTPONED)? (conditional_signal_assignment | selected_signal_assignment) + ; condition - : expression - ; + : expression + ; condition_clause - : UNTIL condition - ; + : UNTIL condition + ; conditional_signal_assignment - : target LE opts conditional_waveforms SEMI - ; + : target LE opts conditional_waveforms SEMI + ; conditional_waveforms - : waveform ( WHEN condition (ELSE conditional_waveforms)?)? - ; + : waveform (WHEN condition (ELSE conditional_waveforms)?)? + ; configuration_declaration - : CONFIGURATION identifier OF name IS - configuration_declarative_part - block_configuration - END ( CONFIGURATION )? ( identifier )? SEMI - ; + : CONFIGURATION identifier OF name IS configuration_declarative_part block_configuration END ( + CONFIGURATION + )? (identifier)? SEMI + ; configuration_declarative_item - : use_clause - | attribute_specification - | group_declaration - ; + : use_clause + | attribute_specification + | group_declaration + ; configuration_declarative_part - : ( configuration_declarative_item )* - ; + : (configuration_declarative_item)* + ; configuration_item - : block_configuration - | component_configuration - ; + : block_configuration + | component_configuration + ; configuration_specification - : FOR component_specification binding_indication SEMI - ; + : FOR component_specification binding_indication SEMI + ; constant_declaration - : CONSTANT identifier_list COLON subtype_indication - ( VARASGN expression )? SEMI - ; + : CONSTANT identifier_list COLON subtype_indication (VARASGN expression)? SEMI + ; constrained_array_definition - : ARRAY index_constraint OF subtype_indication - ; + : ARRAY index_constraint OF subtype_indication + ; constrained_nature_definition - : ARRAY index_constraint OF subnature_indication - ; + : ARRAY index_constraint OF subnature_indication + ; constraint - : range_constraint - | index_constraint - ; + : range_constraint + | index_constraint + ; context_clause - : ( context_item )* - ; + : (context_item)* + ; context_item - : library_clause - | use_clause - ; + : library_clause + | use_clause + ; delay_mechanism - : TRANSPORT - | ( REJECT expression )? INERTIAL - ; + : TRANSPORT + | ( REJECT expression)? INERTIAL + ; design_file - : ( design_unit )* EOF - ; + : (design_unit)* EOF + ; design_unit - : context_clause library_unit - ; + : context_clause library_unit + ; designator - : identifier - | STRING_LITERAL - ; + : identifier + | STRING_LITERAL + ; direction - : TO - | DOWNTO - ; + : TO + | DOWNTO + ; disconnection_specification - : DISCONNECT guarded_signal_specification AFTER expression SEMI - ; + : DISCONNECT guarded_signal_specification AFTER expression SEMI + ; discrete_range - : range_decl - | subtype_indication - ; + : range_decl + | subtype_indication + ; element_association - : ( choices ARROW )? expression - ; + : (choices ARROW)? expression + ; element_declaration - : identifier_list COLON element_subtype_definition SEMI - ; + : identifier_list COLON element_subtype_definition SEMI + ; element_subnature_definition - : subnature_indication - ; + : subnature_indication + ; element_subtype_definition - : subtype_indication - ; + : subtype_indication + ; entity_aspect - : ENTITY name ( LPAREN identifier RPAREN )? - | CONFIGURATION name - | OPEN - ; + : ENTITY name (LPAREN identifier RPAREN)? + | CONFIGURATION name + | OPEN + ; entity_class - : ENTITY - | ARCHITECTURE - | CONFIGURATION - | PROCEDURE - | FUNCTION - | PACKAGE - | TYPE - | SUBTYPE - | CONSTANT - | SIGNAL - | VARIABLE - | COMPONENT - | LABEL - | LITERAL - | UNITS - | GROUP - | FILE - | NATURE - | SUBNATURE - | QUANTITY - | TERMINAL - ; + : ENTITY + | ARCHITECTURE + | CONFIGURATION + | PROCEDURE + | FUNCTION + | PACKAGE + | TYPE + | SUBTYPE + | CONSTANT + | SIGNAL + | VARIABLE + | COMPONENT + | LABEL + | LITERAL + | UNITS + | GROUP + | FILE + | NATURE + | SUBNATURE + | QUANTITY + | TERMINAL + ; entity_class_entry - : entity_class ( BOX )? - ; + : entity_class (BOX)? + ; entity_class_entry_list - : entity_class_entry ( COMMA entity_class_entry )* - ; + : entity_class_entry (COMMA entity_class_entry)* + ; entity_declaration - : ENTITY identifier IS entity_header - entity_declarative_part - ( BEGIN entity_statement_part )? - END ( ENTITY )? ( identifier )? SEMI - ; + : ENTITY identifier IS entity_header entity_declarative_part (BEGIN entity_statement_part)? END ( + ENTITY + )? (identifier)? SEMI + ; entity_declarative_item - : subprogram_declaration - | subprogram_body - | type_declaration - | subtype_declaration - | constant_declaration - | signal_declaration - | variable_declaration - | file_declaration - | alias_declaration - | attribute_declaration - | attribute_specification - | disconnection_specification - | step_limit_specification - | use_clause - | group_template_declaration - | group_declaration - | nature_declaration - | subnature_declaration - | quantity_declaration - | terminal_declaration - ; + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | signal_declaration + | variable_declaration + | file_declaration + | alias_declaration + | attribute_declaration + | attribute_specification + | disconnection_specification + | step_limit_specification + | use_clause + | group_template_declaration + | group_declaration + | nature_declaration + | subnature_declaration + | quantity_declaration + | terminal_declaration + ; entity_declarative_part - : ( entity_declarative_item )* - ; + : (entity_declarative_item)* + ; entity_designator - : entity_tag ( signature )? - ; + : entity_tag (signature)? + ; entity_header - : ( generic_clause )? - ( port_clause )? - ; + : (generic_clause)? (port_clause)? + ; entity_name_list - : entity_designator ( COMMA entity_designator )* - | OTHERS - | ALL - ; + : entity_designator (COMMA entity_designator)* + | OTHERS + | ALL + ; entity_specification - : entity_name_list COLON entity_class - ; + : entity_name_list COLON entity_class + ; entity_statement - : concurrent_assertion_statement - | process_statement - | concurrent_procedure_call_statement - ; + : concurrent_assertion_statement + | process_statement + | concurrent_procedure_call_statement + ; entity_statement_part - : ( entity_statement )* - ; + : (entity_statement)* + ; entity_tag - : identifier - | CHARACTER_LITERAL - | STRING_LITERAL - ; + : identifier + | CHARACTER_LITERAL + | STRING_LITERAL + ; enumeration_literal - : identifier - | CHARACTER_LITERAL - ; + : identifier + | CHARACTER_LITERAL + ; enumeration_type_definition - : LPAREN enumeration_literal ( COMMA enumeration_literal )* RPAREN - ; + : LPAREN enumeration_literal (COMMA enumeration_literal)* RPAREN + ; exit_statement - : ( label_colon )? EXIT ( identifier )? ( WHEN condition )? SEMI - ; + : (label_colon)? EXIT (identifier)? (WHEN condition)? SEMI + ; // NOTE that NAND/NOR are in (...)* now (used to be in (...)?). // (21.1.2004, e.f.) expression - : relation ( : logical_operator relation )* - ; - -factor - : primary ( : DOUBLESTAR primary )? - | ABS primary - | NOT primary - ; - -file_declaration - : FILE identifier_list COLON subtype_indication - ( file_open_information )? SEMI - ; - -file_logical_name - : expression - ; - -file_open_information - : ( OPEN expression )? IS file_logical_name - ; - -file_type_definition - : FILE OF subtype_indication - ; - -formal_parameter_list - : interface_list - ; - -formal_part - : identifier - | identifier LPAREN explicit_range RPAREN - ; - -free_quantity_declaration - : QUANTITY identifier_list COLON subtype_indication - ( VARASGN expression )? SEMI - ; - -generate_statement - : label_colon generation_scheme - GENERATE - ( ( block_declarative_item )* BEGIN )? - ( architecture_statement )* - END GENERATE ( identifier )? SEMI - ; - -generation_scheme - : FOR parameter_specification - | IF condition - ; - -generic_clause - : GENERIC LPAREN generic_list RPAREN SEMI - ; - -generic_list - : interface_constant_declaration (SEMI interface_constant_declaration)* - ; - -generic_map_aspect - : GENERIC MAP LPAREN association_list RPAREN - ; - -group_constituent - : name - | CHARACTER_LITERAL - ; - -group_constituent_list - : group_constituent ( COMMA group_constituent )* - ; - -group_declaration - : GROUP label_colon name - LPAREN group_constituent_list RPAREN SEMI - ; - -group_template_declaration - : GROUP identifier IS LPAREN entity_class_entry_list RPAREN SEMI - ; - -guarded_signal_specification - : signal_list COLON name - ; - -identifier - : BASIC_IDENTIFIER - | EXTENDED_IDENTIFIER - ; - -identifier_list - : identifier ( COMMA identifier )* - ; - -if_statement - : ( label_colon )? IF condition THEN - sequence_of_statements - ( ELSIF condition THEN sequence_of_statements )* - ( ELSE sequence_of_statements )? - END IF ( identifier )? SEMI - ; - -index_constraint - : LPAREN discrete_range ( COMMA discrete_range )* RPAREN - ; - -index_specification - : discrete_range - | expression - ; - -index_subtype_definition - : name RANGE BOX - ; - -instantiated_unit - : ( COMPONENT )? name - | ENTITY name ( LPAREN identifier RPAREN )? - | CONFIGURATION name - ; - -instantiation_list - : identifier ( COMMA identifier )* - | OTHERS - | ALL - ; - -interface_constant_declaration - : ( CONSTANT )? identifier_list COLON ( IN )? subtype_indication - ( VARASGN expression )? - ; - -interface_declaration - : interface_constant_declaration - | interface_signal_declaration - | interface_variable_declaration - | interface_file_declaration - | interface_terminal_declaration - | interface_quantity_declaration - ; - -interface_element - : interface_declaration - ; - -interface_file_declaration - : FILE identifier_list COLON subtype_indication - ; - -interface_signal_list - : interface_signal_declaration ( SEMI interface_signal_declaration )* - ; - -interface_port_list - : interface_port_declaration ( SEMI interface_port_declaration )* - ; - -interface_list - : interface_element ( SEMI interface_element )* - ; - -interface_quantity_declaration - : QUANTITY identifier_list COLON ( IN | OUT )? subtype_indication - ( VARASGN expression )? - ; - -interface_port_declaration - : identifier_list COLON ( signal_mode )? subtype_indication - ( BUS )? ( VARASGN expression )? - ; - -interface_signal_declaration - : SIGNAL identifier_list COLON ( signal_mode )? subtype_indication - ( BUS )? ( VARASGN expression )? - ; - -interface_terminal_declaration - : TERMINAL identifier_list COLON subnature_indication - ; - -interface_variable_declaration - : ( VARIABLE )? identifier_list COLON - ( signal_mode )? subtype_indication ( VARASGN expression )? - ; - -iteration_scheme - : WHILE condition - | FOR parameter_specification - ; - -label_colon - : identifier COLON - ; - -library_clause - : LIBRARY logical_name_list SEMI - ; - -library_unit - : secondary_unit | primary_unit - ; - -literal - : NULL_ - | BIT_STRING_LITERAL - | STRING_LITERAL - | enumeration_literal - | numeric_literal - ; - -logical_name - : identifier - ; - -logical_name_list - : logical_name ( COMMA logical_name )* - ; - -logical_operator - : AND - | OR - | NAND - | NOR - | XOR - | XNOR - ; - -loop_statement - : ( label_colon )? ( iteration_scheme )? - LOOP - sequence_of_statements - END LOOP ( identifier )? SEMI - ; - -signal_mode - : IN - | OUT - | INOUT - | BUFFER - | LINKAGE - ; - -multiplying_operator - : MUL - | DIV - | MOD - | REM - ; - - -// was -// name -// : simple_name -// | operator_symbol -// | selected_name -// | indexed_name -// | slice_name -// | attribute_name -// ; -// changed to avoid left-recursion to name (from selected_name, indexed_name, -// slice_name, and attribute_name, respectively) -// (2.2.2004, e.f.) + (12.07.2017, o.p.) -name - : ( identifier | STRING_LITERAL ) ( name_part )* - ; - -name_part - : selected_name_part - | function_call_or_indexed_name_part - | slice_name_part - | attribute_name_part - ; - -selected_name - : identifier (DOT suffix)* - ; - -selected_name_part - : ( DOT suffix )+ - ; - -function_call_or_indexed_name_part - : LPAREN actual_parameter_part RPAREN - ; - -slice_name_part - : LPAREN discrete_range RPAREN - ; - -attribute_name_part - : ( signature )? APOSTROPHE attribute_designator ( LPAREN expression RPAREN )? - ; - -nature_declaration - : NATURE identifier IS nature_definition SEMI - ; - -nature_definition - : scalar_nature_definition - | composite_nature_definition - ; - -nature_element_declaration - : identifier_list COLON element_subnature_definition - ; - -next_statement - : ( label_colon )? NEXT ( identifier )? ( WHEN condition )? SEMI - ; - -numeric_literal - : abstract_literal - | physical_literal - ; - -object_declaration - : constant_declaration - | signal_declaration - | variable_declaration - | file_declaration - | terminal_declaration - | quantity_declaration - ; - -opts - : ( GUARDED )? ( delay_mechanism )? - ; - -package_body - : PACKAGE BODY identifier IS - package_body_declarative_part - END ( PACKAGE BODY )? ( identifier )? SEMI - ; - -package_body_declarative_item - : subprogram_declaration - | subprogram_body - | type_declaration - | subtype_declaration - | constant_declaration - | variable_declaration - | file_declaration - | alias_declaration - | use_clause - | group_template_declaration - | group_declaration - ; - -package_body_declarative_part - : ( package_body_declarative_item )* - ; - -package_declaration - : PACKAGE identifier IS - package_declarative_part - END ( PACKAGE )? ( identifier )? SEMI - ; - -package_declarative_item - : subprogram_declaration - | subprogram_body - | type_declaration - | subtype_declaration - | constant_declaration - | signal_declaration - | variable_declaration - | file_declaration - | alias_declaration - | component_declaration - | attribute_declaration - | attribute_specification - | disconnection_specification - | use_clause - | group_template_declaration - | group_declaration - | nature_declaration - | subnature_declaration - | terminal_declaration - ; - -package_declarative_part - : ( package_declarative_item )* - ; - -parameter_specification - : identifier IN discrete_range - ; - -physical_literal - : abstract_literal (: identifier) - ; - -physical_type_definition - : range_constraint UNITS base_unit_declaration - ( secondary_unit_declaration )* - END UNITS ( identifier )? - ; - -port_clause - : PORT LPAREN port_list RPAREN SEMI - ; - -port_list - : interface_port_list - ; - -port_map_aspect - : PORT MAP LPAREN association_list RPAREN - ; - -primary - : literal - | qualified_expression - | LPAREN expression RPAREN - | allocator - | aggregate - | name - ; - -primary_unit - : entity_declaration - | configuration_declaration - | package_declaration - ; - -procedural_declarative_item - : subprogram_declaration - | subprogram_body - | type_declaration - | subtype_declaration - | constant_declaration - | variable_declaration - | alias_declaration - | attribute_declaration - | attribute_specification - | use_clause - | group_template_declaration - | group_declaration - ; - -procedural_declarative_part - : ( procedural_declarative_item )* - ; - -procedural_statement_part - : ( sequential_statement )* - ; - -procedure_call - : selected_name ( LPAREN actual_parameter_part RPAREN )? - ; - -procedure_call_statement - : ( label_colon )? procedure_call SEMI - ; - -process_declarative_item - : subprogram_declaration - | subprogram_body - | type_declaration - | subtype_declaration - | constant_declaration - | variable_declaration - | file_declaration - | alias_declaration - | attribute_declaration - | attribute_specification - | use_clause - | group_template_declaration - | group_declaration - ; - -process_declarative_part - : ( process_declarative_item )* - ; - -process_statement - : ( label_colon )? ( POSTPONED )? PROCESS - ( LPAREN sensitivity_list RPAREN )? ( IS )? - process_declarative_part - BEGIN - process_statement_part - END ( POSTPONED )? PROCESS ( identifier )? SEMI - ; - -process_statement_part - : ( sequential_statement )* - ; - -qualified_expression - : subtype_indication APOSTROPHE ( aggregate | LPAREN expression RPAREN ) - ; - -quantity_declaration - : free_quantity_declaration - | branch_quantity_declaration - | source_quantity_declaration - ; - -quantity_list - : name ( COMMA name )* - | OTHERS - | ALL - ; - -quantity_specification - : quantity_list COLON name - ; - -range_decl - : explicit_range - | name - ; - -explicit_range - : simple_expression ( direction simple_expression )? - ; - -range_constraint - : RANGE range_decl - ; - -record_nature_definition - : RECORD ( nature_element_declaration )+ - END RECORD ( identifier )? - ; - -record_type_definition - : RECORD ( element_declaration )+ - END RECORD ( identifier )? - ; - -relation - : shift_expression - ( : relational_operator shift_expression )? - ; - -relational_operator - : EQ - | NEQ - | LOWERTHAN - | LE - | GREATERTHAN - | GE - ; - -report_statement - : ( label_colon )? REPORT expression ( SEVERITY expression )? SEMI - ; - -return_statement - : ( label_colon )? RETURN ( expression )? SEMI - ; - -scalar_nature_definition - : name ACROSS name THROUGH name REFERENCE - ; - -scalar_type_definition - : physical_type_definition - | enumeration_type_definition - | range_constraint - ; - -secondary_unit - : architecture_body - | package_body - ; - -secondary_unit_declaration - : identifier EQ physical_literal SEMI - ; - -selected_signal_assignment - : WITH expression SELECT target LE opts selected_waveforms SEMI - ; - -selected_waveforms - : waveform WHEN choices ( COMMA waveform WHEN choices )* - ; - -sensitivity_clause - : ON sensitivity_list - ; - -sensitivity_list - : name ( COMMA name )* - ; - -sequence_of_statements - : ( sequential_statement )* - ; - -sequential_statement - : wait_statement - | assertion_statement - | report_statement - | signal_assignment_statement - | variable_assignment_statement - | if_statement - | case_statement - | loop_statement - | next_statement - | exit_statement - | return_statement - | ( label_colon )? NULL_ SEMI - | break_statement - | procedure_call_statement - ; - -shift_expression - : simple_expression - ( : shift_operator simple_expression )? - ; - -shift_operator - : SLL - | SRL - | SLA - | SRA - | ROL - | ROR - ; - -signal_assignment_statement - : ( label_colon )? - target LE ( delay_mechanism )? waveform SEMI - ; - -signal_declaration - : SIGNAL identifier_list COLON - subtype_indication ( signal_kind )? ( VARASGN expression )? SEMI - ; - -signal_kind - : REGISTER - | BUS - ; - -signal_list - : name ( COMMA name )* - | OTHERS - | ALL - ; - -signature - : LBRACKET ( name ( COMMA name )* )? ( RETURN name )? RBRACKET - ; - -// NOTE that sign is applied to first operand only (LRM does not permit -// `a op -b' - use `a op (-b)' instead). -// (3.2.2004, e.f.) -simple_expression - : ( PLUS | MINUS )? term ( : adding_operator term )* - ; - -simple_simultaneous_statement - : ( label_colon )? - simple_expression ASSIGN simple_expression ( tolerance_aspect )? SEMI - ; - -simultaneous_alternative - : WHEN choices ARROW simultaneous_statement_part - ; - -simultaneous_case_statement - : ( label_colon )? CASE expression USE - ( simultaneous_alternative )+ - END CASE ( identifier )? SEMI - ; - -simultaneous_if_statement - : ( label_colon )? IF condition USE - simultaneous_statement_part - ( ELSIF condition USE simultaneous_statement_part )* - ( ELSE simultaneous_statement_part )? - END USE ( identifier )? SEMI - ; - -simultaneous_procedural_statement - : ( label_colon )? PROCEDURAL ( IS )? - procedural_declarative_part BEGIN - procedural_statement_part - END PROCEDURAL ( identifier )? SEMI - ; - -simultaneous_statement - : simple_simultaneous_statement - | simultaneous_if_statement - | simultaneous_case_statement - | simultaneous_procedural_statement - | ( label_colon )? NULL_ SEMI - ; - -simultaneous_statement_part - : ( simultaneous_statement )* - ; - -source_aspect - : SPECTRUM simple_expression COMMA simple_expression - | NOISE simple_expression - ; - -source_quantity_declaration - : QUANTITY identifier_list COLON subtype_indication source_aspect SEMI - ; - -step_limit_specification - : LIMIT quantity_specification WITH expression SEMI - ; - -subnature_declaration - : SUBNATURE identifier IS subnature_indication SEMI - ; - -subnature_indication - : name ( index_constraint )? - ( TOLERANCE expression ACROSS expression THROUGH )? - ; - -subprogram_body - : subprogram_specification IS - subprogram_declarative_part - BEGIN - subprogram_statement_part - END ( subprogram_kind )? ( designator )? SEMI - ; - -subprogram_declaration - : subprogram_specification SEMI - ; - -subprogram_declarative_item - : subprogram_declaration - | subprogram_body - | type_declaration - | subtype_declaration - | constant_declaration - | variable_declaration - | file_declaration - | alias_declaration - | attribute_declaration - | attribute_specification - | use_clause - | group_template_declaration - | group_declaration - ; - -subprogram_declarative_part - : ( subprogram_declarative_item )* - ; - -subprogram_kind - : PROCEDURE - | FUNCTION - ; - -subprogram_specification - : procedure_specification - | function_specification - ; - -procedure_specification - : PROCEDURE designator ( LPAREN formal_parameter_list RPAREN )? - ; - -function_specification - : ( PURE | IMPURE )? FUNCTION designator - ( LPAREN formal_parameter_list RPAREN )? RETURN subtype_indication - ; - -subprogram_statement_part - : ( sequential_statement )* - ; - -subtype_declaration - : SUBTYPE identifier IS subtype_indication SEMI - ; - -// VHDLAMS 1076.1-1999 declares first name as optional. Here, second name -// is made optional to prevent antlr nondeterminism. -// (9.2.2004, e.f.) -subtype_indication - : selected_name ( selected_name )? ( constraint )? ( tolerance_aspect )? - ; - -suffix - : identifier - | CHARACTER_LITERAL - | STRING_LITERAL - | ALL - ; - -target - : name - | aggregate - ; - -term - : factor ( : multiplying_operator factor )* - ; - -terminal_aspect - : name ( TO name )? - ; - -terminal_declaration - : TERMINAL identifier_list COLON subnature_indication SEMI - ; - -through_aspect - : identifier_list ( tolerance_aspect )? ( VARASGN expression )? THROUGH - ; - -timeout_clause - : FOR expression - ; - -tolerance_aspect - : TOLERANCE expression - ; - -type_declaration - : TYPE identifier ( IS type_definition )? SEMI - ; - -type_definition - : scalar_type_definition - | composite_type_definition - | access_type_definition - | file_type_definition - ; - -unconstrained_array_definition - : ARRAY LPAREN index_subtype_definition ( COMMA index_subtype_definition )* - RPAREN OF subtype_indication - ; - -unconstrained_nature_definition - : ARRAY LPAREN index_subtype_definition ( COMMA index_subtype_definition )* - RPAREN OF subnature_indication - ; - -use_clause - : USE selected_name ( COMMA selected_name )* SEMI - ; - -variable_assignment_statement - : ( label_colon )? target VARASGN expression SEMI - ; - -variable_declaration - : ( SHARED )? VARIABLE identifier_list COLON - subtype_indication ( VARASGN expression )? SEMI - ; - -wait_statement - : ( label_colon )? WAIT ( sensitivity_clause )? - ( condition_clause )? ( timeout_clause )? SEMI - ; - -waveform - : waveform_element ( COMMA waveform_element )* - | UNAFFECTED - ; - -waveform_element - : expression ( AFTER expression )? - ; - -//------------------------------------------Lexer----------------------------------------- -BASE_LITERAL -// INTEGER must be checked to be between and including 2 and 16 (included) i.e. -// INTEGER >=2 and INTEGER <=16 -// A Based integer (a number without a . such as 3) should not have a negative exponent -// A Based fractional number with a . i.e. 3.0 may have a negative exponent -// These should be checked in the Visitor/Listener whereby an appropriate error message -// should be given - : INTEGER '#' BASED_INTEGER ('.'BASED_INTEGER)? '#' (EXPONENT)? - ; - -BIT_STRING_LITERAL - : BIT_STRING_LITERAL_BINARY - | BIT_STRING_LITERAL_OCTAL - | BIT_STRING_LITERAL_HEX - ; - -BIT_STRING_LITERAL_BINARY - : 'B"' ('1' | '0' | '_')+ '"' - ; - -BIT_STRING_LITERAL_OCTAL - : 'O"' ('7' |'6' |'5' |'4' |'3' |'2' |'1' | '0' | '_')+ '"' - ; - -BIT_STRING_LITERAL_HEX - : 'X"' ( 'F' |'E' |'D' |'C' |'B' |'A' | '9' | '8' | '7' |'6' |'5' |'4' |'3' |'2' |'1' | '0' | '_')+ '"' - ; - -REAL_LITERAL - : INTEGER '.' INTEGER ( EXPONENT )?; - -BASIC_IDENTIFIER - : LETTER ( '_' ( LETTER | DIGIT ) | LETTER | DIGIT )* - ; - -EXTENDED_IDENTIFIER - : '\\' ( LETTER | '0'..'9' | '&' | '\'' | '(' | ')' - | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '|' - | ' ' | OTHER_SPECIAL_CHARACTER | '\\' - | '#' | '[' | ']' | '_' )+ '\\' - ; - -LETTER - : 'A'..'Z' - ; - -COMMENT - : '--' ( ~'\n' )* - -> skip - ; - -TAB - : ( '\t' )+ -> skip - ; - -SPACE - : ( ' ' )+ -> skip - ; - -NEWLINE - : '\n' -> skip - ; - -CR - : '\r' -> skip - ; - -CHARACTER_LITERAL - : APOSTROPHE . APOSTROPHE - ; - -STRING_LITERAL - : '"' (~('"'|'\n'|'\r') | '""')* '"' - ; - -OTHER_SPECIAL_CHARACTER - : '!' | '$' | '%' | '@' | '?' | '^' | '`' | '{' | '}' | '~' - | ' ' | '\u00A4' | '\u00A6' | '\u00A7' - | '\u00A9' | '\u00AB' | '\u00AC' | '\u00AD' | '\u00AE' - | '\u00B0' | '\u00B1' | '\u00B5' | '\u00B6' | '\u00B7' - | '\u2116' | '\u00BB' - | '\u0400'..'\u045E' - ; - - -DOUBLESTAR : '**' ; -ASSIGN : '==' ; -LE : '<=' ; -GE : '>=' ; -ARROW : '=>' ; -NEQ : '/=' ; -VARASGN : ':=' ; -BOX : '<>' ; -DBLQUOTE : '"' ; -SEMI : ';' ; -COMMA : ',' ; -AMPERSAND : '&' ; -LPAREN : '(' ; -RPAREN : ')' ; -LBRACKET : '[' ; -RBRACKET : ']' ; -COLON : ':' ; -MUL : '*' ; -DIV : '/' ; -PLUS : '+' ; -MINUS : '-' ; -LOWERTHAN : '<' ; -GREATERTHAN : '>' ; -EQ : '=' ; -BAR : '|' ; -DOT : '.' ; -BACKSLASH : '\\' ; - - -EXPONENT - : 'E' ( '+' | '-' )? INTEGER - ; - - -HEXDIGIT - : 'A'..'F' - ; - - -INTEGER - : DIGIT ( '_' | DIGIT )* - ; - -DIGIT - : '0'..'9' - ; - -BASED_INTEGER - : EXTENDED_DIGIT ('_' | EXTENDED_DIGIT)* - ; - -EXTENDED_DIGIT - : (DIGIT | LETTER) - ; - -APOSTROPHE - : '\'' - ; + : relation (: logical_operator relation)* + ; + + factor + : primary (: DOUBLESTAR primary)? + | ABS primary + | NOT primary + ; + + file_declaration + : FILE identifier_list COLON subtype_indication (file_open_information)? SEMI + ; + + file_logical_name + : expression + ; + + file_open_information + : (OPEN expression)? IS file_logical_name + ; + + file_type_definition + : FILE OF subtype_indication + ; + + formal_parameter_list + : interface_list + ; + + formal_part + : identifier + | identifier LPAREN explicit_range RPAREN + ; + + free_quantity_declaration + : QUANTITY identifier_list COLON subtype_indication (VARASGN expression)? SEMI + ; + + generate_statement + : label_colon generation_scheme GENERATE (( block_declarative_item)* BEGIN)? ( + architecture_statement + )* END GENERATE (identifier)? SEMI + ; + + generation_scheme + : FOR parameter_specification + | IF condition + ; + + generic_clause + : GENERIC LPAREN generic_list RPAREN SEMI + ; + + generic_list + : interface_constant_declaration (SEMI interface_constant_declaration)* + ; + + generic_map_aspect + : GENERIC MAP LPAREN association_list RPAREN + ; + + group_constituent + : name + | CHARACTER_LITERAL + ; + + group_constituent_list + : group_constituent (COMMA group_constituent)* + ; + + group_declaration + : GROUP label_colon name LPAREN group_constituent_list RPAREN SEMI + ; + + group_template_declaration + : GROUP identifier IS LPAREN entity_class_entry_list RPAREN SEMI + ; + + guarded_signal_specification + : signal_list COLON name + ; + + identifier + : BASIC_IDENTIFIER + | EXTENDED_IDENTIFIER + ; + + identifier_list + : identifier (COMMA identifier)* + ; + + if_statement + : (label_colon)? IF condition THEN sequence_of_statements ( + ELSIF condition THEN sequence_of_statements + )* (ELSE sequence_of_statements)? END IF (identifier)? SEMI + ; + + index_constraint + : LPAREN discrete_range (COMMA discrete_range)* RPAREN + ; + + index_specification + : discrete_range + | expression + ; + + index_subtype_definition + : name RANGE BOX + ; + + instantiated_unit + : (COMPONENT)? name + | ENTITY name ( LPAREN identifier RPAREN)? + | CONFIGURATION name + ; + + instantiation_list + : identifier (COMMA identifier)* + | OTHERS + | ALL + ; + + interface_constant_declaration + : (CONSTANT)? identifier_list COLON (IN)? subtype_indication (VARASGN expression)? + ; + + interface_declaration + : interface_constant_declaration + | interface_signal_declaration + | interface_variable_declaration + | interface_file_declaration + | interface_terminal_declaration + | interface_quantity_declaration + ; + + interface_element + : interface_declaration + ; + + interface_file_declaration + : FILE identifier_list COLON subtype_indication + ; + + interface_signal_list + : interface_signal_declaration (SEMI interface_signal_declaration)* + ; + + interface_port_list + : interface_port_declaration (SEMI interface_port_declaration)* + ; + + interface_list + : interface_element (SEMI interface_element)* + ; + + interface_quantity_declaration + : QUANTITY identifier_list COLON (IN | OUT)? subtype_indication (VARASGN expression)? + ; + + interface_port_declaration + : identifier_list COLON (signal_mode)? subtype_indication (BUS)? (VARASGN expression)? + ; + + interface_signal_declaration + : SIGNAL identifier_list COLON (signal_mode)? subtype_indication (BUS)? ( + VARASGN expression + )? + ; + + interface_terminal_declaration + : TERMINAL identifier_list COLON subnature_indication + ; + + interface_variable_declaration + : (VARIABLE)? identifier_list COLON (signal_mode)? subtype_indication ( + VARASGN expression + )? + ; + + iteration_scheme + : WHILE condition + | FOR parameter_specification + ; + + label_colon + : identifier COLON + ; + + library_clause + : LIBRARY logical_name_list SEMI + ; + + library_unit + : secondary_unit + | primary_unit + ; + + literal + : NULL_ + | BIT_STRING_LITERAL + | STRING_LITERAL + | enumeration_literal + | numeric_literal + ; + + logical_name + : identifier + ; + + logical_name_list + : logical_name (COMMA logical_name)* + ; + + logical_operator + : AND + | OR + | NAND + | NOR + | XOR + | XNOR + ; + + loop_statement + : (label_colon)? (iteration_scheme)? LOOP sequence_of_statements END LOOP (identifier)? SEMI + ; + + signal_mode + : IN + | OUT + | INOUT + | BUFFER + | LINKAGE + ; + + multiplying_operator + : MUL + | DIV + | MOD + | REM + ; + + // was + // name + // : simple_name + // | operator_symbol + // | selected_name + // | indexed_name + // | slice_name + // | attribute_name + // ; + // changed to avoid left-recursion to name (from selected_name, indexed_name, + // slice_name, and attribute_name, respectively) + // (2.2.2004, e.f.) + (12.07.2017, o.p.) + name + : (identifier | STRING_LITERAL) (name_part)* + ; + + name_part + : selected_name_part + | function_call_or_indexed_name_part + | slice_name_part + | attribute_name_part + ; + + selected_name + : identifier (DOT suffix)* + ; + + selected_name_part + : (DOT suffix)+ + ; + + function_call_or_indexed_name_part + : LPAREN actual_parameter_part RPAREN + ; + + slice_name_part + : LPAREN discrete_range RPAREN + ; + + attribute_name_part + : (signature)? APOSTROPHE attribute_designator (LPAREN expression RPAREN)? + ; + + nature_declaration + : NATURE identifier IS nature_definition SEMI + ; + + nature_definition + : scalar_nature_definition + | composite_nature_definition + ; + + nature_element_declaration + : identifier_list COLON element_subnature_definition + ; + + next_statement + : (label_colon)? NEXT (identifier)? (WHEN condition)? SEMI + ; + + numeric_literal + : abstract_literal + | physical_literal + ; + + object_declaration + : constant_declaration + | signal_declaration + | variable_declaration + | file_declaration + | terminal_declaration + | quantity_declaration + ; + + opts + : (GUARDED)? (delay_mechanism)? + ; + + package_body + : PACKAGE BODY identifier IS package_body_declarative_part END (PACKAGE BODY)? ( + identifier + )? SEMI + ; + + package_body_declarative_item + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | variable_declaration + | file_declaration + | alias_declaration + | use_clause + | group_template_declaration + | group_declaration + ; + + package_body_declarative_part + : (package_body_declarative_item)* + ; + + package_declaration + : PACKAGE identifier IS package_declarative_part END (PACKAGE)? (identifier)? SEMI + ; + + package_declarative_item + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | signal_declaration + | variable_declaration + | file_declaration + | alias_declaration + | component_declaration + | attribute_declaration + | attribute_specification + | disconnection_specification + | use_clause + | group_template_declaration + | group_declaration + | nature_declaration + | subnature_declaration + | terminal_declaration + ; + + package_declarative_part + : (package_declarative_item)* + ; + + parameter_specification + : identifier IN discrete_range + ; + + physical_literal + : abstract_literal (: identifier) + ; + + physical_type_definition + : range_constraint UNITS base_unit_declaration (secondary_unit_declaration)* END UNITS ( + identifier + )? + ; + + port_clause + : PORT LPAREN port_list RPAREN SEMI + ; + + port_list + : interface_port_list + ; + + port_map_aspect + : PORT MAP LPAREN association_list RPAREN + ; + + primary + : literal + | qualified_expression + | LPAREN expression RPAREN + | allocator + | aggregate + | name + ; + + primary_unit + : entity_declaration + | configuration_declaration + | package_declaration + ; + + procedural_declarative_item + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | variable_declaration + | alias_declaration + | attribute_declaration + | attribute_specification + | use_clause + | group_template_declaration + | group_declaration + ; + + procedural_declarative_part + : (procedural_declarative_item)* + ; + + procedural_statement_part + : (sequential_statement)* + ; + + procedure_call + : selected_name (LPAREN actual_parameter_part RPAREN)? + ; + + procedure_call_statement + : (label_colon)? procedure_call SEMI + ; + + process_declarative_item + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | variable_declaration + | file_declaration + | alias_declaration + | attribute_declaration + | attribute_specification + | use_clause + | group_template_declaration + | group_declaration + ; + + process_declarative_part + : (process_declarative_item)* + ; + + process_statement + : (label_colon)? (POSTPONED)? PROCESS (LPAREN sensitivity_list RPAREN)? (IS)? process_declarative_part BEGIN process_statement_part + END (POSTPONED)? PROCESS (identifier)? SEMI + ; + + process_statement_part + : (sequential_statement)* + ; + + qualified_expression + : subtype_indication APOSTROPHE (aggregate | LPAREN expression RPAREN) + ; + + quantity_declaration + : free_quantity_declaration + | branch_quantity_declaration + | source_quantity_declaration + ; + + quantity_list + : name (COMMA name)* + | OTHERS + | ALL + ; + + quantity_specification + : quantity_list COLON name + ; + + range_decl + : explicit_range + | name + ; + + explicit_range + : simple_expression (direction simple_expression)? + ; + + range_constraint + : RANGE range_decl + ; + + record_nature_definition + : RECORD (nature_element_declaration)+ END RECORD (identifier)? + ; + + record_type_definition + : RECORD (element_declaration)+ END RECORD (identifier)? + ; + + relation + : shift_expression (: relational_operator shift_expression)? + ; + + relational_operator + : EQ + | NEQ + | LOWERTHAN + | LE + | GREATERTHAN + | GE + ; + + report_statement + : (label_colon)? REPORT expression (SEVERITY expression)? SEMI + ; + + return_statement + : (label_colon)? RETURN (expression)? SEMI + ; + + scalar_nature_definition + : name ACROSS name THROUGH name REFERENCE + ; + + scalar_type_definition + : physical_type_definition + | enumeration_type_definition + | range_constraint + ; + + secondary_unit + : architecture_body + | package_body + ; + + secondary_unit_declaration + : identifier EQ physical_literal SEMI + ; + + selected_signal_assignment + : WITH expression SELECT target LE opts selected_waveforms SEMI + ; + + selected_waveforms + : waveform WHEN choices (COMMA waveform WHEN choices)* + ; + + sensitivity_clause + : ON sensitivity_list + ; + + sensitivity_list + : name (COMMA name)* + ; + + sequence_of_statements + : (sequential_statement)* + ; + + sequential_statement + : wait_statement + | assertion_statement + | report_statement + | signal_assignment_statement + | variable_assignment_statement + | if_statement + | case_statement + | loop_statement + | next_statement + | exit_statement + | return_statement + | ( label_colon)? NULL_ SEMI + | break_statement + | procedure_call_statement + ; + + shift_expression + : simple_expression (: shift_operator simple_expression)? + ; + + shift_operator + : SLL + | SRL + | SLA + | SRA + | ROL + | ROR + ; + + signal_assignment_statement + : (label_colon)? target LE (delay_mechanism)? waveform SEMI + ; + + signal_declaration + : SIGNAL identifier_list COLON subtype_indication (signal_kind)? ( + VARASGN expression + )? SEMI + ; + + signal_kind + : REGISTER + | BUS + ; + + signal_list + : name (COMMA name)* + | OTHERS + | ALL + ; + + signature + : LBRACKET (name ( COMMA name)*)? (RETURN name)? RBRACKET + ; + + // NOTE that sign is applied to first operand only (LRM does not permit + // `a op -b' - use `a op (-b)' instead). + // (3.2.2004, e.f.) + simple_expression + : (PLUS | MINUS)? term (: adding_operator term)* + ; + + simple_simultaneous_statement + : (label_colon)? simple_expression ASSIGN simple_expression ( + tolerance_aspect + )? SEMI + ; + + simultaneous_alternative + : WHEN choices ARROW simultaneous_statement_part + ; + + simultaneous_case_statement + : (label_colon)? CASE expression USE (simultaneous_alternative)+ END CASE ( + identifier + )? SEMI + ; + + simultaneous_if_statement + : (label_colon)? IF condition USE simultaneous_statement_part ( + ELSIF condition USE simultaneous_statement_part + )* (ELSE simultaneous_statement_part)? END USE (identifier)? SEMI + ; + + simultaneous_procedural_statement + : (label_colon)? PROCEDURAL (IS)? procedural_declarative_part BEGIN procedural_statement_part END PROCEDURAL ( + identifier + )? SEMI + ; + + simultaneous_statement + : simple_simultaneous_statement + | simultaneous_if_statement + | simultaneous_case_statement + | simultaneous_procedural_statement + | ( label_colon)? NULL_ SEMI + ; + + simultaneous_statement_part + : (simultaneous_statement)* + ; + + source_aspect + : SPECTRUM simple_expression COMMA simple_expression + | NOISE simple_expression + ; + + source_quantity_declaration + : QUANTITY identifier_list COLON subtype_indication source_aspect SEMI + ; + + step_limit_specification + : LIMIT quantity_specification WITH expression SEMI + ; + + subnature_declaration + : SUBNATURE identifier IS subnature_indication SEMI + ; + + subnature_indication + : name (index_constraint)? ( + TOLERANCE expression ACROSS expression THROUGH + )? + ; + + subprogram_body + : subprogram_specification IS subprogram_declarative_part BEGIN subprogram_statement_part END ( + subprogram_kind + )? (designator)? SEMI + ; + + subprogram_declaration + : subprogram_specification SEMI + ; + + subprogram_declarative_item + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | variable_declaration + | file_declaration + | alias_declaration + | attribute_declaration + | attribute_specification + | use_clause + | group_template_declaration + | group_declaration + ; + + subprogram_declarative_part + : (subprogram_declarative_item)* + ; + + subprogram_kind + : PROCEDURE + | FUNCTION + ; + + subprogram_specification + : procedure_specification + | function_specification + ; + + procedure_specification + : PROCEDURE designator (LPAREN formal_parameter_list RPAREN)? + ; + + function_specification + : (PURE | IMPURE)? FUNCTION designator ( + LPAREN formal_parameter_list RPAREN + )? RETURN subtype_indication + ; + + subprogram_statement_part + : (sequential_statement)* + ; + + subtype_declaration + : SUBTYPE identifier IS subtype_indication SEMI + ; + + // VHDLAMS 1076.1-1999 declares first name as optional. Here, second name + // is made optional to prevent antlr nondeterminism. + // (9.2.2004, e.f.) + subtype_indication + : selected_name (selected_name)? (constraint)? (tolerance_aspect)? + ; + + suffix + : identifier + | CHARACTER_LITERAL + | STRING_LITERAL + | ALL + ; + + target + : name + | aggregate + ; + + term + : factor (: multiplying_operator factor)* + ; + + terminal_aspect + : name (TO name)? + ; + + terminal_declaration + : TERMINAL identifier_list COLON subnature_indication SEMI + ; + + through_aspect + : identifier_list (tolerance_aspect)? (VARASGN expression)? THROUGH + ; + + timeout_clause + : FOR expression + ; + + tolerance_aspect + : TOLERANCE expression + ; + + type_declaration + : TYPE identifier (IS type_definition)? SEMI + ; + + type_definition + : scalar_type_definition + | composite_type_definition + | access_type_definition + | file_type_definition + ; + + unconstrained_array_definition + : ARRAY LPAREN index_subtype_definition ( + COMMA index_subtype_definition + )* RPAREN OF subtype_indication + ; + + unconstrained_nature_definition + : ARRAY LPAREN index_subtype_definition ( + COMMA index_subtype_definition + )* RPAREN OF subnature_indication + ; + + use_clause + : USE selected_name (COMMA selected_name)* SEMI + ; + + variable_assignment_statement + : (label_colon)? target VARASGN expression SEMI + ; + + variable_declaration + : (SHARED)? VARIABLE identifier_list COLON subtype_indication ( + VARASGN expression + )? SEMI + ; + + wait_statement + : (label_colon)? WAIT (sensitivity_clause)? (condition_clause)? ( + timeout_clause + )? SEMI + ; + + waveform + : waveform_element (COMMA waveform_element)* + | UNAFFECTED + ; + + waveform_element + : expression (AFTER expression)? + ; + + //------------------------------------------Lexer----------------------------------------- + BASE_LITERAL + // INTEGER must be checked to be between and including 2 and 16 (included) i.e. + // INTEGER >=2 and INTEGER <=16 + // A Based integer (a number without a . such as 3) should not have a negative exponent + // A Based fractional number with a . i.e. 3.0 may have a negative exponent + // These should be checked in the Visitor/Listener whereby an appropriate error message + // should be given + : INTEGER '#' BASED_INTEGER ('.' BASED_INTEGER)? '#' (EXPONENT)? + ; + + BIT_STRING_LITERAL + : BIT_STRING_LITERAL_BINARY + | BIT_STRING_LITERAL_OCTAL + | BIT_STRING_LITERAL_HEX + ; + + BIT_STRING_LITERAL_BINARY + : 'B"' ('1' | '0' | '_')+ '"' + ; + + BIT_STRING_LITERAL_OCTAL + : 'O"' ('7' | '6' | '5' | '4' | '3' | '2' | '1' | '0' | '_')+ '"' + ; + + BIT_STRING_LITERAL_HEX + : 'X"' ( + 'F' + | 'E' + | 'D' + | 'C' + | 'B' + | 'A' + | '9' + | '8' + | '7' + | '6' + | '5' + | '4' + | '3' + | '2' + | '1' + | '0' + | '_' + )+ '"' + ; + + REAL_LITERAL + : INTEGER '.' INTEGER (EXPONENT)? + ; + + BASIC_IDENTIFIER + : LETTER ('_' ( LETTER | DIGIT) | LETTER | DIGIT)* + ; + + EXTENDED_IDENTIFIER + : '\\' ( + LETTER + | '0' ..'9' + | '&' + | '\'' + | '(' + | ')' + | '+' + | ',' + | '-' + | '.' + | '/' + | ':' + | ';' + | '<' + | '=' + | '>' + | '|' + | ' ' + | OTHER_SPECIAL_CHARACTER + | '\\' + | '#' + | '[' + | ']' + | '_' + )+ '\\' + ; + + LETTER + : 'A' ..'Z' + ; + + COMMENT + : '--' (~'\n')* -> skip + ; + + TAB + : ('\t')+ -> skip + ; + + SPACE + : (' ')+ -> skip + ; + + NEWLINE + : '\n' -> skip + ; + + CR + : '\r' -> skip + ; + + CHARACTER_LITERAL + : APOSTROPHE . APOSTROPHE + ; + + STRING_LITERAL + : '"' (~('"' | '\n' | '\r') | '""')* '"' + ; + + OTHER_SPECIAL_CHARACTER + : '!' + | '$' + | '%' + | '@' + | '?' + | '^' + | '`' + | '{' + | '}' + | '~' + | ' ' + | '\u00A4' + | '\u00A6' + | '\u00A7' + | '\u00A9' + | '\u00AB' + | '\u00AC' + | '\u00AD' + | '\u00AE' + | '\u00B0' + | '\u00B1' + | '\u00B5' + | '\u00B6' + | '\u00B7' + | '\u2116' + | '\u00BB' + | '\u0400' ..'\u045E' + ; + + DOUBLESTAR + : '**' + ; + ASSIGN + : '==' + ; + LE + : '<=' + ; + GE + : '>=' + ; + ARROW + : '=>' + ; + NEQ + : '/=' + ; + VARASGN + : ':=' + ; + BOX + : '<>' + ; + DBLQUOTE + : '"' + ; + SEMI + : ';' + ; + COMMA + : ',' + ; + AMPERSAND + : '&' + ; + LPAREN + : '(' + ; + RPAREN + : ')' + ; + LBRACKET + : '[' + ; + RBRACKET + : ']' + ; + COLON + : ':' + ; + MUL + : '*' + ; + DIV + : '/' + ; + PLUS + : '+' + ; + MINUS + : '-' + ; + LOWERTHAN + : '<' + ; + GREATERTHAN + : '>' + ; + EQ + : '=' + ; + BAR + : '|' + ; + DOT + : '.' + ; + BACKSLASH + : '\\' + ; + + EXPONENT + : 'E' ('+' | '-')? INTEGER + ; + + HEXDIGIT + : 'A' ..'F' + ; + + INTEGER + : DIGIT ('_' | DIGIT)* + ; + + DIGIT + : '0' ..'9' + ; + + BASED_INTEGER + : EXTENDED_DIGIT ('_' | EXTENDED_DIGIT)* + ; + + EXTENDED_DIGIT + : (DIGIT | LETTER) + ; + + APOSTROPHE + : '\'' + ; \ No newline at end of file diff --git a/vmf/vmf.g4 b/vmf/vmf.g4 index a1b41e217b..a72becedb4 100644 --- a/vmf/vmf.g4 +++ b/vmf/vmf.g4 @@ -29,42 +29,45 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar vmf; vmf - : keyvalue+ EOF - ; + : keyvalue+ EOF + ; keyvalue - : key (atomicvalue+ | listvalue+) - ; + : key (atomicvalue+ | listvalue+) + ; key - : val - ; + : val + ; atomicvalue - : val - ; + : val + ; val - : QUOTEDSTTRING - | STRING - ; + : QUOTEDSTTRING + | STRING + ; listvalue - : '{' keyvalue* '}' - ; + : '{' keyvalue* '}' + ; QUOTEDSTTRING - : '"' (~ ('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"' - ; + : '"' (~ ('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"' + ; STRING - : [a-zA-Z0-9()_$@<>[\]\-/]+ - ; + : [a-zA-Z0-9()_$@<>[\]\-/]+ + ; WS - : [ \t\r\n] -> skip - ; - + : [ \t\r\n] -> skip + ; \ No newline at end of file diff --git a/wat/WatLexer.g4 b/wat/WatLexer.g4 index 27f5c7324b..c0c9155d52 100644 --- a/wat/WatLexer.g4 +++ b/wat/WatLexer.g4 @@ -28,253 +28,257 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar WatLexer; -LPAR : '(' ; -RPAR : ')' ; - -NAT : Nat ; -INT : Int ; -FLOAT : Float ; -STRING_ : String_ ; -VALUE_TYPE : NXX ; -CONST : NXX '.const' ; - -FUNCREF: 'funcref' ; -MUT: 'mut' ; - -NOP: 'nop' ; -UNREACHABLE: 'unreachable' ; -DROP: 'drop' ; -BLOCK: 'block' ; -LOOP: 'loop' ; -END: 'end' ; -BR: 'br' ; -BR_IF: 'br_if' ; -BR_TABLE: 'br_table' ; -RETURN: 'return' ; -IF: 'if' ; -THEN: 'then' ; -ELSE: 'else' ; -SELECT: 'select' ; -CALL: 'call' ; -CALL_INDIRECT: 'call_indirect' ; - -LOCAL_GET: 'local.get' ; -LOCAL_SET: 'local.set' ; -LOCAL_TEE: 'local.tee' ; -GLOBAL_GET: 'global.get' ; -GLOBAL_SET: 'global.set' ; - -LOAD : NXX '.load' (MEM_SIZE '_' SIGN)? ; -STORE : NXX '.store' (MEM_SIZE)? ; - -OFFSET_EQ_NAT : 'offset=' Nat ; -ALIGN_EQ_NAT : 'align=' Nat ; - -UNARY - : IXX '.clz' - | IXX '.ctz' - | IXX '.popcnt' - | FXX '.neg' - | FXX '.abs' - | FXX '.sqrt' - | FXX '.ceil' - | FXX '.floor' - | FXX '.trunc' - | FXX '.nearest' - ; - -BINARY - : IXX '.add' - | IXX '.sub' - | IXX '.mul' - | IXX '.div_s' - | IXX '.div_u' - | IXX '.rem_s' - | IXX '.rem_u' - | IXX '.and' - | IXX '.or' - | IXX '.xor' - | IXX '.shl' - | IXX '.shr_s' - | IXX '.shr_u' - | IXX '.rotl' - | IXX '.rotr' - | FXX '.add' - | FXX '.sub' - | FXX '.mul' - | FXX '.div' - | FXX '.min' - | FXX '.max' - | FXX '.copysign' - ; - -TEST - : IXX '.eqz' - ; - -COMPARE - : IXX '.eq' - | IXX '.ne' - | IXX '.lt_s' - | IXX '.lt_u' - | IXX '.le_s' - | IXX '.le_u' - | IXX '.gt_s' - | IXX '.gt_u' - | IXX '.ge_s' - | IXX '.ge_u' - | FXX '.eq' - | FXX '.ne' - | FXX '.lt' - | FXX '.le' - | FXX '.gt' - | FXX '.ge' - ; - -CONVERT - : 'i32.wrap_i64' - | 'i64.extend_i32_s' - | 'i64.extend_i32_u' - | 'f32.demote_f64' - | 'f64.promote_f32' - | IXX '.trunc_f32_s' - | IXX '.trunc_f32_u' - | IXX '.trunc_f64_s' - | IXX '.trunc_f64_u' - | FXX '.convert_i32_s' - | FXX '.convert_i32_u' - | FXX '.convert_i64_s' - | FXX '.convert_i64_u' - | 'f32.reinterpret_i32' - | 'f64.reinterpret_i64' - | 'i32.reinterpret_f32' - | 'i64.reinterpret_f64' - ; - -MEMORY_SIZE : 'memory.size' ; -MEMORY_GROW : 'memory.grow' ; - -TYPE: 'type' ; -FUNC: 'func' ; -START_: 'start' ; -PARAM: 'param' ; -RESULT: 'result' ; -LOCAL: 'local' ; -GLOBAL: 'global' ; -TABLE: 'table' ; -MEMORY: 'memory' ; -ELEM: 'elem' ; -DATA: 'data' ; -OFFSET: 'offset' ; -IMPORT: 'import' ; -EXPORT: 'export' ; - -MODULE : 'module' ; -BIN : 'binary' ; -QUOTE : 'quote' ; - -SCRIPT: 'script' ; -REGISTER: 'register' ; -INVOKE: 'invoke' ; -GET: 'get' ; -ASSERT_MALFORMED: 'assert_malformed' ; -ASSERT_INVALID: 'assert_invalid' ; -ASSERT_UNLINKABLE: 'assert_unlinkable' ; -ASSERT_RETURN: 'assert_return' ; -ASSERT_RETURN_CANONICAL_NAN: 'assert_return_canonical_nan' ; -ASSERT_RETURN_ARITHMETIC_NAN: 'assert_return_arithmetic_nan' ; -ASSERT_TRAP: 'assert_trap' ; -ASSERT_EXHAUSTION: 'assert_exhaustion' ; -INPUT: 'input' ; -OUTPUT: 'output' ; - -VAR : Name ; - -SPACE - : [ \t\r\n] -> skip - ; - -COMMENT - : ( '(;' .*? ';)' - | ';;' .*? '\n')-> skip - ; - -fragment Symbol - : '.' | '+' | '-' | '*' | '/' | '\\' | '^' | '~' | '=' | '<' | '>' | '!' | '?' | '@' | '#' | '$' | '%' | '&' | '|' | ':' | '\'' | '`' - ; - -fragment Num - : Digit ('_'? Digit)* - ; - -fragment HexNum - : HexDigit ('_'? HexDigit)* - ; - -fragment Sign - : '+' | '-' - ; - -fragment Digit - : [0-9] - ; - -fragment HexDigit - : [0-9a-fA-F] - ; - -fragment Letter - : [a-zA-Z] - ; - -fragment Nat : Num | ('0x' HexNum) ; -fragment Int : Sign Nat ; -fragment Frac : Num ; -fragment HexFrac : HexNum ; - -fragment Float - : Sign? Num '.' Frac? - | Sign? Num ('.' Frac?)? ('e' | 'E') Sign? Num - | Sign? '0x' HexNum '.' HexFrac? - | Sign? '0x' HexNum ('.' HexFrac?)? ('p' | 'P') Sign? Num - | Sign? 'inf' - | Sign? 'nan' - | Sign? 'nan:' '0x' HexNum - ; - -fragment String_ - : '"' ( Char | '\n' | '\t' | '\\' | '\'' | '\\' HexDigit HexDigit | '\\u{' HexDigit+ '}' )* '"' - ; - -fragment Name - : '$' (Letter | Digit | '_' | Symbol)+ - ; - -fragment Escape : [nrt'"\\] ; - -fragment IXX : 'i' ('32' | '64') ; -fragment FXX : 'f' ('32' | '64') ; -fragment NXX : IXX | FXX ; -fragment MIXX : 'i' ('8' | '16' | '32' | '64') ; -fragment MFXX : 'f' ('32' | '64') ; -fragment SIGN : 's' | 'u' ; -fragment MEM_SIZE : '8' | '16' | '32' ; - -fragment Char : ~["'\\\u0000-\u001f\u007f-\u00ff] ; -fragment Ascii : [\u0000-\u007f] ; -fragment Ascii_no_nl : [\u0000-\u0009\u000b-\u007f] ; -fragment Utf8Cont : [\u0080-\u00bf] ; -fragment Utf8 : Ascii | Utf8Enc ; -fragment Utf8_no_nl : Ascii_no_nl | Utf8Enc ; - -fragment Utf8Enc - : [\u00c2-\u00df] Utf8Cont - | [\u00e0] [\u00a0-\u00bf] Utf8Cont - | [\u00ed] [\u0080-\u009f] Utf8Cont - | [\u00e1-\u00ec\u00ee-\u00ef] Utf8Cont Utf8Cont - | [\u00f0] [\u0090-\u00bf] Utf8Cont Utf8Cont - | [\u00f4] [\u0080-\u008f] Utf8Cont Utf8Cont - | [\u00f1-\u00f3] Utf8Cont Utf8Cont Utf8Cont - ; +LPAR : '('; +RPAR : ')'; + +NAT : Nat; +INT : Int; +FLOAT : Float; +STRING_ : String_; +VALUE_TYPE : NXX; +CONST : NXX '.const'; + +FUNCREF : 'funcref'; +MUT : 'mut'; + +NOP : 'nop'; +UNREACHABLE : 'unreachable'; +DROP : 'drop'; +BLOCK : 'block'; +LOOP : 'loop'; +END : 'end'; +BR : 'br'; +BR_IF : 'br_if'; +BR_TABLE : 'br_table'; +RETURN : 'return'; +IF : 'if'; +THEN : 'then'; +ELSE : 'else'; +SELECT : 'select'; +CALL : 'call'; +CALL_INDIRECT : 'call_indirect'; + +LOCAL_GET : 'local.get'; +LOCAL_SET : 'local.set'; +LOCAL_TEE : 'local.tee'; +GLOBAL_GET : 'global.get'; +GLOBAL_SET : 'global.set'; + +LOAD : NXX '.load' (MEM_SIZE '_' SIGN)?; +STORE : NXX '.store' (MEM_SIZE)?; + +OFFSET_EQ_NAT : 'offset=' Nat; +ALIGN_EQ_NAT : 'align=' Nat; + +UNARY: + IXX '.clz' + | IXX '.ctz' + | IXX '.popcnt' + | FXX '.neg' + | FXX '.abs' + | FXX '.sqrt' + | FXX '.ceil' + | FXX '.floor' + | FXX '.trunc' + | FXX '.nearest' +; + +BINARY: + IXX '.add' + | IXX '.sub' + | IXX '.mul' + | IXX '.div_s' + | IXX '.div_u' + | IXX '.rem_s' + | IXX '.rem_u' + | IXX '.and' + | IXX '.or' + | IXX '.xor' + | IXX '.shl' + | IXX '.shr_s' + | IXX '.shr_u' + | IXX '.rotl' + | IXX '.rotr' + | FXX '.add' + | FXX '.sub' + | FXX '.mul' + | FXX '.div' + | FXX '.min' + | FXX '.max' + | FXX '.copysign' +; + +TEST: IXX '.eqz'; + +COMPARE: + IXX '.eq' + | IXX '.ne' + | IXX '.lt_s' + | IXX '.lt_u' + | IXX '.le_s' + | IXX '.le_u' + | IXX '.gt_s' + | IXX '.gt_u' + | IXX '.ge_s' + | IXX '.ge_u' + | FXX '.eq' + | FXX '.ne' + | FXX '.lt' + | FXX '.le' + | FXX '.gt' + | FXX '.ge' +; + +CONVERT: + 'i32.wrap_i64' + | 'i64.extend_i32_s' + | 'i64.extend_i32_u' + | 'f32.demote_f64' + | 'f64.promote_f32' + | IXX '.trunc_f32_s' + | IXX '.trunc_f32_u' + | IXX '.trunc_f64_s' + | IXX '.trunc_f64_u' + | FXX '.convert_i32_s' + | FXX '.convert_i32_u' + | FXX '.convert_i64_s' + | FXX '.convert_i64_u' + | 'f32.reinterpret_i32' + | 'f64.reinterpret_i64' + | 'i32.reinterpret_f32' + | 'i64.reinterpret_f64' +; + +MEMORY_SIZE : 'memory.size'; +MEMORY_GROW : 'memory.grow'; + +TYPE : 'type'; +FUNC : 'func'; +START_ : 'start'; +PARAM : 'param'; +RESULT : 'result'; +LOCAL : 'local'; +GLOBAL : 'global'; +TABLE : 'table'; +MEMORY : 'memory'; +ELEM : 'elem'; +DATA : 'data'; +OFFSET : 'offset'; +IMPORT : 'import'; +EXPORT : 'export'; + +MODULE : 'module'; +BIN : 'binary'; +QUOTE : 'quote'; + +SCRIPT : 'script'; +REGISTER : 'register'; +INVOKE : 'invoke'; +GET : 'get'; +ASSERT_MALFORMED : 'assert_malformed'; +ASSERT_INVALID : 'assert_invalid'; +ASSERT_UNLINKABLE : 'assert_unlinkable'; +ASSERT_RETURN : 'assert_return'; +ASSERT_RETURN_CANONICAL_NAN : 'assert_return_canonical_nan'; +ASSERT_RETURN_ARITHMETIC_NAN : 'assert_return_arithmetic_nan'; +ASSERT_TRAP : 'assert_trap'; +ASSERT_EXHAUSTION : 'assert_exhaustion'; +INPUT : 'input'; +OUTPUT : 'output'; + +VAR: Name; + +SPACE: [ \t\r\n] -> skip; + +COMMENT: ( '(;' .*? ';)' | ';;' .*? '\n') -> skip; + +fragment Symbol: + '.' + | '+' + | '-' + | '*' + | '/' + | '\\' + | '^' + | '~' + | '=' + | '<' + | '>' + | '!' + | '?' + | '@' + | '#' + | '$' + | '%' + | '&' + | '|' + | ':' + | '\'' + | '`' +; + +fragment Num: Digit ('_'? Digit)*; + +fragment HexNum: HexDigit ('_'? HexDigit)*; + +fragment Sign: '+' | '-'; + +fragment Digit: [0-9]; + +fragment HexDigit: [0-9a-fA-F]; + +fragment Letter: [a-zA-Z]; + +fragment Nat : Num | ('0x' HexNum); +fragment Int : Sign Nat; +fragment Frac : Num; +fragment HexFrac : HexNum; + +fragment Float: + Sign? Num '.' Frac? + | Sign? Num ('.' Frac?)? ('e' | 'E') Sign? Num + | Sign? '0x' HexNum '.' HexFrac? + | Sign? '0x' HexNum ('.' HexFrac?)? ('p' | 'P') Sign? Num + | Sign? 'inf' + | Sign? 'nan' + | Sign? 'nan:' '0x' HexNum +; + +fragment String_: + '"' (Char | '\n' | '\t' | '\\' | '\'' | '\\' HexDigit HexDigit | '\\u{' HexDigit+ '}')* '"' +; + +fragment Name: '$' (Letter | Digit | '_' | Symbol)+; + +fragment Escape: [nrt'"\\]; + +fragment IXX : 'i' ('32' | '64'); +fragment FXX : 'f' ('32' | '64'); +fragment NXX : IXX | FXX; +fragment MIXX : 'i' ('8' | '16' | '32' | '64'); +fragment MFXX : 'f' ('32' | '64'); +fragment SIGN : 's' | 'u'; +fragment MEM_SIZE : '8' | '16' | '32'; + +fragment Char : ~["'\\\u0000-\u001f\u007f-\u00ff]; +fragment Ascii : [\u0000-\u007f]; +fragment Ascii_no_nl : [\u0000-\u0009\u000b-\u007f]; +fragment Utf8Cont : [\u0080-\u00bf]; +fragment Utf8 : Ascii | Utf8Enc; +fragment Utf8_no_nl : Ascii_no_nl | Utf8Enc; + +fragment Utf8Enc: + [\u00c2-\u00df] Utf8Cont + | [\u00e0] [\u00a0-\u00bf] Utf8Cont + | [\u00ed] [\u0080-\u009f] Utf8Cont + | [\u00e1-\u00ec\u00ee-\u00ef] Utf8Cont Utf8Cont + | [\u00f0] [\u0090-\u00bf] Utf8Cont Utf8Cont + | [\u00f4] [\u0080-\u008f] Utf8Cont Utf8Cont + | [\u00f1-\u00f3] Utf8Cont Utf8Cont Utf8Cont +; \ No newline at end of file diff --git a/wat/WatParser.g4 b/wat/WatParser.g4 index 11059bd0be..a551340a3a 100644 --- a/wat/WatParser.g4 +++ b/wat/WatParser.g4 @@ -28,371 +28,380 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -parser grammar WatParser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab=WatLexer; } +parser grammar WatParser; +options { + tokenVocab = WatLexer; +} value - : INT | FLOAT - ; + : INT + | FLOAT + ; /* Auxiliaries */ name - : STRING_ - ; + : STRING_ + ; /* Types */ value_type - : VALUE_TYPE - ; + : VALUE_TYPE + ; elem_type - : FUNCREF - ; + : FUNCREF + ; global_type - : value_type | LPAR MUT value_type RPAR - ; + : value_type + | LPAR MUT value_type RPAR + ; def_type - : LPAR FUNC func_type RPAR - ; + : LPAR FUNC func_type RPAR + ; func_type - : (LPAR (RESULT value_type* | PARAM value_type* | PARAM bind_var value_type) RPAR)* - ; + : (LPAR (RESULT value_type* | PARAM value_type* | PARAM bind_var value_type) RPAR)* + ; table_type - : NAT NAT? elem_type - ; + : NAT NAT? elem_type + ; memory_type - : NAT NAT? - ; + : NAT NAT? + ; type_use - : LPAR TYPE var_ RPAR - ; + : LPAR TYPE var_ RPAR + ; /* Immediates */ literal - : NAT | INT | FLOAT - ; + : NAT + | INT + | FLOAT + ; var_ - : NAT | VAR - ; + : NAT + | VAR + ; bind_var - : VAR - ; + : VAR + ; /* Instructions & Expressions */ instr - : plain_instr - | call_instr_instr - | block_instr - | expr - ; + : plain_instr + | call_instr_instr + | block_instr + | expr + ; plain_instr - : UNREACHABLE - | NOP - | DROP - | SELECT - | BR var_ - | BR_IF var_ - | BR_TABLE var_+ - | RETURN - | CALL var_ - | LOCAL_GET var_ - | LOCAL_SET var_ - | LOCAL_TEE var_ - | GLOBAL_GET var_ - | GLOBAL_SET var_ - | LOAD OFFSET_EQ_NAT? ALIGN_EQ_NAT? - | STORE OFFSET_EQ_NAT? ALIGN_EQ_NAT? - | MEMORY_SIZE - | MEMORY_GROW - | CONST literal - | TEST - | COMPARE - | UNARY - | BINARY - | CONVERT - ; + : UNREACHABLE + | NOP + | DROP + | SELECT + | BR var_ + | BR_IF var_ + | BR_TABLE var_+ + | RETURN + | CALL var_ + | LOCAL_GET var_ + | LOCAL_SET var_ + | LOCAL_TEE var_ + | GLOBAL_GET var_ + | GLOBAL_SET var_ + | LOAD OFFSET_EQ_NAT? ALIGN_EQ_NAT? + | STORE OFFSET_EQ_NAT? ALIGN_EQ_NAT? + | MEMORY_SIZE + | MEMORY_GROW + | CONST literal + | TEST + | COMPARE + | UNARY + | BINARY + | CONVERT + ; call_instr - : CALL_INDIRECT type_use? call_instr_params - ; + : CALL_INDIRECT type_use? call_instr_params + ; call_instr_params - : (LPAR PARAM value_type* RPAR)* (LPAR RESULT value_type* RPAR)* - ; + : (LPAR PARAM value_type* RPAR)* (LPAR RESULT value_type* RPAR)* + ; call_instr_instr - : CALL_INDIRECT type_use? call_instr_params_instr - ; + : CALL_INDIRECT type_use? call_instr_params_instr + ; call_instr_params_instr - : (LPAR PARAM value_type* RPAR)* call_instr_results_instr - ; + : (LPAR PARAM value_type* RPAR)* call_instr_results_instr + ; call_instr_results_instr - : (LPAR RESULT value_type* RPAR)* instr - ; + : (LPAR RESULT value_type* RPAR)* instr + ; block_instr - : (BLOCK | LOOP) bind_var? block END bind_var? - | IF bind_var? block (ELSE bind_var? instr_list)? END bind_var? - ; + : (BLOCK | LOOP) bind_var? block END bind_var? + | IF bind_var? block (ELSE bind_var? instr_list)? END bind_var? + ; block_type - : LPAR RESULT value_type RPAR - ; + : LPAR RESULT value_type RPAR + ; block - : block_type? instr_list - ; + : block_type? instr_list + ; expr - : LPAR expr1 RPAR - ; + : LPAR expr1 RPAR + ; expr1 - : plain_instr expr* - | CALL_INDIRECT call_expr_type - | BLOCK bind_var? block - | LOOP bind_var? block - | IF bind_var? if_block - ; + : plain_instr expr* + | CALL_INDIRECT call_expr_type + | BLOCK bind_var? block + | LOOP bind_var? block + | IF bind_var? if_block + ; call_expr_type - : type_use? call_expr_params - ; + : type_use? call_expr_params + ; call_expr_params - : (LPAR PARAM value_type* RPAR)* call_expr_results - ; + : (LPAR PARAM value_type* RPAR)* call_expr_results + ; call_expr_results - : (LPAR RESULT value_type* RPAR)* expr* - ; + : (LPAR RESULT value_type* RPAR)* expr* + ; if_block - : block_type if_block - | expr* LPAR THEN instr_list RPAR (LPAR ELSE instr_list RPAR)? - ; + : block_type if_block + | expr* LPAR THEN instr_list RPAR (LPAR ELSE instr_list RPAR)? + ; instr_list - : instr* call_instr? - ; + : instr* call_instr? + ; const_expr - : instr_list - ; + : instr_list + ; /* Functions */ func_ - : LPAR FUNC bind_var? func_fields RPAR - ; + : LPAR FUNC bind_var? func_fields RPAR + ; func_fields - : type_use? func_fields_body - | inline_import type_use? func_fields_import - | inline_export func_fields - ; + : type_use? func_fields_body + | inline_import type_use? func_fields_import + | inline_export func_fields + ; func_fields_import - : (LPAR PARAM value_type* RPAR | LPAR PARAM bind_var value_type RPAR) func_fields_import_result - ; + : (LPAR PARAM value_type* RPAR | LPAR PARAM bind_var value_type RPAR) func_fields_import_result + ; func_fields_import_result - : (LPAR RESULT value_type* RPAR)* - ; + : (LPAR RESULT value_type* RPAR)* + ; func_fields_body - : (LPAR PARAM value_type* RPAR | LPAR PARAM bind_var value_type RPAR)* func_result_body - ; + : (LPAR PARAM value_type* RPAR | LPAR PARAM bind_var value_type RPAR)* func_result_body + ; func_result_body - : (LPAR RESULT value_type* RPAR)* func_body - ; + : (LPAR RESULT value_type* RPAR)* func_body + ; func_body - : (LPAR LOCAL value_type* RPAR | LPAR LOCAL bind_var value_type RPAR)* instr_list - ; + : (LPAR LOCAL value_type* RPAR | LPAR LOCAL bind_var value_type RPAR)* instr_list + ; /* Tables, Memories & Globals */ offset - : LPAR OFFSET const_expr RPAR - | expr - ; + : LPAR OFFSET const_expr RPAR + | expr + ; elem - : LPAR ELEM var_? offset var_* RPAR - ; + : LPAR ELEM var_? offset var_* RPAR + ; table - : LPAR TABLE bind_var? table_fields RPAR - ; + : LPAR TABLE bind_var? table_fields RPAR + ; table_fields - : table_type - | inline_import table_type - | inline_export table_fields - | elem_type LPAR ELEM var_* RPAR - ; + : table_type + | inline_import table_type + | inline_export table_fields + | elem_type LPAR ELEM var_* RPAR + ; data - : LPAR DATA var_? offset STRING_* RPAR - ; + : LPAR DATA var_? offset STRING_* RPAR + ; memory - : LPAR MEMORY bind_var? memory_fields RPAR - ; + : LPAR MEMORY bind_var? memory_fields RPAR + ; memory_fields - : memory_type - | inline_import memory_type - | inline_export memory_fields - | LPAR DATA STRING_* RPAR - ; + : memory_type + | inline_import memory_type + | inline_export memory_fields + | LPAR DATA STRING_* RPAR + ; sglobal - : LPAR GLOBAL bind_var? global_fields RPAR - ; + : LPAR GLOBAL bind_var? global_fields RPAR + ; global_fields - : global_type const_expr - | inline_import global_type - | inline_export global_fields - ; + : global_type const_expr + | inline_import global_type + | inline_export global_fields + ; /* Imports & Exports */ import_desc - : LPAR FUNC bind_var? type_use RPAR - | LPAR FUNC bind_var? func_type RPAR - | LPAR TABLE bind_var? table_type RPAR - | LPAR MEMORY bind_var? memory_type RPAR - | LPAR GLOBAL bind_var? global_type RPAR - ; + : LPAR FUNC bind_var? type_use RPAR + | LPAR FUNC bind_var? func_type RPAR + | LPAR TABLE bind_var? table_type RPAR + | LPAR MEMORY bind_var? memory_type RPAR + | LPAR GLOBAL bind_var? global_type RPAR + ; simport - : LPAR IMPORT name name import_desc RPAR - ; + : LPAR IMPORT name name import_desc RPAR + ; inline_import - : LPAR IMPORT name name RPAR - ; + : LPAR IMPORT name name RPAR + ; export_desc - : LPAR FUNC var_ RPAR - | LPAR TABLE var_ RPAR - | LPAR MEMORY var_ RPAR - | LPAR GLOBAL var_ RPAR - ; + : LPAR FUNC var_ RPAR + | LPAR TABLE var_ RPAR + | LPAR MEMORY var_ RPAR + | LPAR GLOBAL var_ RPAR + ; export_ - : LPAR EXPORT name export_desc RPAR - ; + : LPAR EXPORT name export_desc RPAR + ; inline_export - : LPAR EXPORT name RPAR - ; + : LPAR EXPORT name RPAR + ; /* Modules */ type_ - : def_type - ; + : def_type + ; type_def - : LPAR TYPE bind_var? type_ RPAR - ; + : LPAR TYPE bind_var? type_ RPAR + ; start_ - : LPAR START_ var_ RPAR - ; + : LPAR START_ var_ RPAR + ; module_field - : type_def - | sglobal - | table - | memory - | func_ - | elem - | data - | start_ - | simport - | export_ - ; + : type_def + | sglobal + | table + | memory + | func_ + | elem + | data + | start_ + | simport + | export_ + ; module_ - : LPAR MODULE VAR? module_field* RPAR - ; + : LPAR MODULE VAR? module_field* RPAR + ; /* Scripts */ script_module - : module_ - | LPAR MODULE VAR? (BIN | QUOTE) STRING_* RPAR - ; + : module_ + | LPAR MODULE VAR? (BIN | QUOTE) STRING_* RPAR + ; action_ - : LPAR INVOKE VAR? name const_list RPAR - | LPAR GET VAR? name RPAR - ; + : LPAR INVOKE VAR? name const_list RPAR + | LPAR GET VAR? name RPAR + ; assertion - : LPAR ASSERT_MALFORMED script_module STRING_ RPAR - | LPAR ASSERT_INVALID script_module STRING_ RPAR - | LPAR ASSERT_UNLINKABLE script_module STRING_ RPAR - | LPAR ASSERT_TRAP script_module STRING_ RPAR - | LPAR ASSERT_RETURN action_ const_list RPAR - | LPAR ASSERT_RETURN_CANONICAL_NAN action_ RPAR - | LPAR ASSERT_RETURN_ARITHMETIC_NAN action_ RPAR - | LPAR ASSERT_TRAP action_ STRING_ RPAR - | LPAR ASSERT_EXHAUSTION action_ STRING_ RPAR - ; + : LPAR ASSERT_MALFORMED script_module STRING_ RPAR + | LPAR ASSERT_INVALID script_module STRING_ RPAR + | LPAR ASSERT_UNLINKABLE script_module STRING_ RPAR + | LPAR ASSERT_TRAP script_module STRING_ RPAR + | LPAR ASSERT_RETURN action_ const_list RPAR + | LPAR ASSERT_RETURN_CANONICAL_NAN action_ RPAR + | LPAR ASSERT_RETURN_ARITHMETIC_NAN action_ RPAR + | LPAR ASSERT_TRAP action_ STRING_ RPAR + | LPAR ASSERT_EXHAUSTION action_ STRING_ RPAR + ; cmd - : action_ - | assertion - | script_module - | LPAR REGISTER name VAR? RPAR - | meta - ; + : action_ + | assertion + | script_module + | LPAR REGISTER name VAR? RPAR + | meta + ; meta - : LPAR SCRIPT VAR? cmd* RPAR - | LPAR INPUT VAR? STRING_ RPAR - | LPAR OUTPUT VAR? STRING_ RPAR - | LPAR OUTPUT VAR? RPAR - ; + : LPAR SCRIPT VAR? cmd* RPAR + | LPAR INPUT VAR? STRING_ RPAR + | LPAR OUTPUT VAR? STRING_ RPAR + | LPAR OUTPUT VAR? RPAR + ; wconst - : LPAR CONST literal RPAR - ; + : LPAR CONST literal RPAR + ; const_list - : wconst* - ; + : wconst* + ; script - : cmd* EOF - | module_field+ EOF - ; + : cmd* EOF + | module_field+ EOF + ; module - : module_ EOF - | module_field* EOF - ; + : module_ EOF + | module_field* EOF + ; \ No newline at end of file diff --git a/wavefront/WavefrontOBJ.g4 b/wavefront/WavefrontOBJ.g4 index 5c6999db07..734cb91084 100644 --- a/wavefront/WavefrontOBJ.g4 +++ b/wavefront/WavefrontOBJ.g4 @@ -1,9 +1,12 @@ - /* * Wavefront's Advanced Visualizer ASCII .OBJ file format grammer. * * Reference : http ://fegemo.github.io/cefet-cg/attachments/obj-spec.pdf */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar WavefrontOBJ; // PARSER RULES @@ -13,37 +16,61 @@ start_ ; statement - : call | csh - | vertex | vertex_normal | vertex_texture | vertex_parameter - | points | lines | faces - | curve_surface_type | degree | basis_matrix | step + : call + | csh + | vertex + | vertex_normal + | vertex_texture + | vertex_parameter + | points + | lines + | faces + | curve_surface_type + | degree + | basis_matrix + | step | free_form_surface | connectivity - | group | smoothing_group | merging_group | object_name - | bevel | color_interpolation | dissolve_interpolation | level_of_detail - | map_library | use_map | material_library | use_material - | shadow_object | trace_object - | curve_approximation_technique | surface_approximation_technique + | group + | smoothing_group + | merging_group + | object_name + | bevel + | color_interpolation + | dissolve_interpolation + | level_of_detail + | map_library + | use_map + | material_library + | use_material + | shadow_object + | trace_object + | curve_approximation_technique + | surface_approximation_technique ; - // General statement // ----------------- // Calls out to evaluate another .obj file -call : filename=FILENAME args=NON_WS*; +call + : filename = FILENAME args = NON_WS* + ; // Executes a UNIX command. // It is unclear whether the intent is for the output of the command to be treated as new input. -csh : command=FILENAME '-'? args=NON_WS*; - +csh + : command = FILENAME '-'? args = NON_WS* + ; // Vertex data // ----------- // Specifies a geometric vertex and its `x`, `y`, `z` coordinates. // The fourth value (`w`, or weight) defaults to 1.0. -vertex : 'v' x=decimal y=decimal z=decimal w=decimal?; +vertex + : 'v' x = decimal y = decimal z = decimal w = decimal? + ; // Specifies a point in the parameter space of a curve or surface. // - `u` is the point in the parameter space of a curve or the first @@ -51,18 +78,23 @@ vertex : 'v' x=decimal y=decimal z=decimal w=decimal?; // - `v` is the second coordinate in the parameter space of a surface // - `w` is the weight required for rational trimming curves. If you do // not specify a value for w, it defaults to 1.0. -vertex_parameter : 'vp' u=decimal v=decimal? w=decimal?; +vertex_parameter + : 'vp' u = decimal v = decimal? w = decimal? + ; // Specifies a normal vector with components i, j, and k. // (We'll still name them `x`, `y` and `z` because that is the modern convention.) -vertex_normal : 'vn' x=decimal y=decimal z=decimal; +vertex_normal + : 'vn' x = decimal y = decimal z = decimal + ; // Specifies a texture vertex and its coordinates. // - `u` is the value for the horizontal direction of the texture. // - `v` is the value for the vertical direction of the texture. The default is 0. // - `w` is a value for the depth of the texture. The default is 0. -vertex_texture : 'vt' u=decimal v=decimal? w=decimal?; - +vertex_texture + : 'vt' u = decimal v = decimal? w = decimal? + ; // Free-form curve/surface attributes // ---------------------------------- @@ -73,9 +105,13 @@ vertex_texture : 'vt' u=decimal v=decimal? w=decimal?; // not included, the curve or surface is non-rational. // type specifies the curve or surface type. curve_surface_type - : 'cstype' - rational='rat'? - cstype=( 'bmatrix' | 'bezier' | 'bspline' | 'cardinal' | 'taylor' ) + : 'cstype' rational = 'rat'? cstype = ( + 'bmatrix' + | 'bezier' + | 'bspline' + | 'cardinal' + | 'taylor' + ) ; // Sets the polynomial degree for curves and surfaces. @@ -85,7 +121,9 @@ curve_surface_type // For Bezier, B-spline, Taylor, and basis matrix. // For Cardinal, the degree is always 3. If some other value is given // for Cardinal, it will be ignored. -degree : 'deg' u=INTEGER v=INTEGER?; +degree + : 'deg' u = INTEGER v = INTEGER? + ; // Sets the basis matrices used for basis matrix curves and surfaces. // The u and v values must be specified in separate bmat statements. @@ -93,42 +131,49 @@ degree : 'deg' u=INTEGER v=INTEGER?; // and the size of the matrix must be appropriate for the degree: (deg+1) x (deg+1) // - `u` specifies that the basis matrix is applied in the u direction. // - `v` specifies that the basis matrix is applied in the v direction. -basis_matrix : 'bmat' ( 'u' | 'v' ) decimal+; +basis_matrix + : 'bmat' ('u' | 'v') decimal+ + ; // Sets the step size for curves and surfaces that use a basis matrix. // - `u` is the step size in the u direction. It is required for both // curves and surfaces that use a basis matrix. // - `v` is the step size in the v direction. It is required only for // surfaces that use a basis matrix. -step : 'step' u=INTEGER v=INTEGER?; - +step + : 'step' u = INTEGER v = INTEGER? + ; // Elements // -------- // Specifies a point element and its vertex. You can specify multiple // points with this statement. -points : 'p' v=INTEGER+; +points + : 'p' v = INTEGER+ + ; // Specifies a line and its vertex reference numbers. You can // optionally include the texture vertex reference numbers. // Should specify at least 2 points. -lines : 'l' v=( INTEGER | INTEGER_PAIR )+; +lines + : 'l' v = (INTEGER | INTEGER_PAIR)+ + ; // Specifies a face element and its vertex reference number. You can // optionally include the texture vertex and vertex normal reference // numbers. // Should specify at least 3 points. -faces : 'f' v=( INTEGER | INTEGER_PAIR | INTEGER_TRIPLET )+; +faces + : 'f' v = (INTEGER | INTEGER_PAIR | INTEGER_TRIPLET)+ + ; // Block defining a free-form surface free_form_surface - : ( curve | curve2d | surface ) NL+ - ( ( parameter | outer_trimming_loop | inner_trimming_loop | special_curve | special_point ) - NL+ - )* - end - ; + : (curve | curve2d | surface) NL+ ( + (parameter | outer_trimming_loop | inner_trimming_loop | special_curve | special_point) NL+ + )* end + ; // Specifies a curve, its parameter range, and its control vertices. // - `u0` is the starting parameter value for the curve. @@ -139,7 +184,9 @@ free_form_surface // For a non-rational curve, the control points must be 3D. For a // rational curve, the control points are 3D or 4D. The fourth // coordinate (weight) defaults to 1.0 if omitted. -curve : 'curv' u0=decimal u1=decimal v=INTEGER+; +curve + : 'curv' u0 = decimal u1 = decimal v = INTEGER+ + ; // Specifies a 2D curve on a surface and its control points. // A 2D curve is used as an outer or inner trimming curve, as a @@ -152,7 +199,9 @@ curve : 'curv' u0=decimal u1=decimal v=INTEGER+; // curve, the control vertices can be 2D. For a rational curve, the // control vertices can be 2D or 3D. The third coordinate (weight) // defaults to 1.0 if omitted. -curve2d : 'curv2' vp1=INTEGER vp2=INTEGER+; +curve2d + : 'curv2' vp1 = INTEGER vp2 = INTEGER+ + ; // Specifies a surface, its parameter range, and its control vertices. // The surface is evaluated within the global parameter range from @@ -166,13 +215,13 @@ curve2d : 'curv2' vp1=INTEGER vp2=INTEGER+; // rational surface the control vertices can be 3D or 4D. The fourth // coordinate (weight) defaults to 1.0 if omitted. surface - : 'surf' - s0=decimal s1=decimal - t0=decimal t1=decimal - v=( INTEGER | INTEGER_PAIR | INTEGER_TRIPLET )+ + : 'surf' s0 = decimal s1 = decimal t0 = decimal t1 = decimal v = ( + INTEGER + | INTEGER_PAIR + | INTEGER_TRIPLET + )+ ; - // Free-form curve/surface body statements // --------------------------------------- @@ -185,7 +234,9 @@ surface // values. A minimum of two parameter values are required. // Parameter values must increase monotonically. The type of // surface and the degree dictate the number of values required. -parameter : 'parm' ( 'u' | 'v' ) p=decimal+; +parameter + : 'parm' ('u' | 'v') p = decimal+ + ; // Specifies a sequence of curves to build a single outer trimming loop. // - `u0` is the starting parameter value for the trimming curve `curv2d`. @@ -193,7 +244,9 @@ parameter : 'parm' ( 'u' | 'v' ) p=decimal+; // - `curv2d` is the index of the trimming curve lying in the parameter // space of the surface. This curve must have been previously // defined with the curv2 statement. -outer_trimming_loop : 'trim' ( u0=decimal u1=decimal curv2d=INTEGER )+; +outer_trimming_loop + : 'trim' (u0 = decimal u1 = decimal curv2d = INTEGER)+ + ; // Specifies a sequence of curves to build a single inner trimming loop (hole). // - `u0` is the starting parameter value for the trimming curve `curv2d`. @@ -201,7 +254,9 @@ outer_trimming_loop : 'trim' ( u0=decimal u1=decimal curv2d=INTEGER )+; // - `curv2d` is the index of the trimming curve lying in the parameter // space of the surface. This curve must have been previously // defined with the curv2 statement. -inner_trimming_loop : 'hole' ( u0=decimal u1=decimal curv2d=INTEGER )+; +inner_trimming_loop + : 'hole' (u0 = decimal u1 = decimal curv2d = INTEGER)+ + ; // Specifies a sequence of curves which lie on the given surface to // build a single special curve. @@ -210,7 +265,9 @@ inner_trimming_loop : 'hole' ( u0=decimal u1=decimal curv2d=INTEGER )+; // - `curv2d` is the index of the special curve lying in the parameter // space of the surface. This curve must have been previously // defined with the curv2 statement. -special_curve : 'scrv' ( u0=decimal u1=decimal curv2d=INTEGER )+; +special_curve + : 'scrv' (u0 = decimal u1 = decimal curv2d = INTEGER)+ + ; // Specifies special geometric points to be associated with a curve or // surface. For space curves and trimming curves, the parameter @@ -218,12 +275,15 @@ special_curve : 'scrv' ( u0=decimal u1=decimal curv2d=INTEGER )+; // - `vp` is the reference number for the parameter vertex of a special // point to be associated with the parameter space point of the curve // or surface. -special_point : 'sp' vp=INTEGER+; +special_point + : 'sp' vp = INTEGER+ + ; // Specifies the end of a curve or surface body begun by a `curv`, `curv2`, // or `surf` statement. -end : 'end'; - +end + : 'end' + ; // Connectivity between free-form surfaces // --------------------------------------- @@ -240,9 +300,7 @@ end : 'end'; // - `curv2d_2` is the index of a curve on the second surface. This curve // must have been previously defined with the curv2 statement. connectivity - : 'con' - surf_1=INTEGER q0_1=decimal q1_1=decimal curv2d_1=INTEGER - surf_2=INTEGER q0_2=decimal q1_2=decimal curv2d_2=INTEGER + : 'con' surf_1 = INTEGER q0_1 = decimal q1_1 = decimal curv2d_1 = INTEGER surf_2 = INTEGER q0_2 = decimal q1_2 = decimal curv2d_2 = INTEGER ; // Grouping @@ -254,16 +312,15 @@ connectivity // - `group_name` is the name for the group. Letters, numbers, and // combinations of letters and numbers are accepted for group // names. The default group name is 'default'. -group : 'g' group_name=NAME+; +group + : 'g' group_name = NAME+ + ; // Sets the smoothing group for the elements that follow it. // If you do not want to use a smoothing group, specify off or a value of 0. // This is essentially a shortcut for providing smooth vertex normals. smoothing_group - : 's' - ( group_number=INTEGER - | 'off' - ) + : 's' (group_number = INTEGER | 'off') ; // Sets the merging group and merge resolution for the free-form @@ -280,16 +337,15 @@ smoothing_group // merged together. The resolution must be a value greater than 0. // This is a required argument only when using merging groups. merging_group - : 'mg' - ( group_number=INTEGER res=decimal - | 'off' - ) + : 'mg' (group_number = INTEGER res = decimal | 'off') ; // Specifies a user-defined object name for the elements // defined after this statement. // - object_name is the user-defined object name. -object_name : 'o' name=NAME; +object_name + : 'o' name = NAME + ; // Display/render attributes @@ -297,42 +353,49 @@ object_name : 'o' name=NAME; // Bevel interpolation uses normal vector interpolation to give an // illusion of roundness to a flat bevel. It does not affect the // smoothing of non-bevelled faces. -bevel : 'bevel' ( 'on' | 'off' ); +bevel + : 'bevel' ('on' | 'off') + ; // Sets color interpolation on or off. // Color interpolation creates a blend across the surface of a polygon // between the materials assigned to its vertices. // Color interpolation applies to the values for ambient (Ka), diffuse (Kd), // specular (Ks), and specular highlight (Ns) material properties. -color_interpolation : 'c_interp' ( 'on' | 'off' ); +color_interpolation + : 'c_interp' ('on' | 'off') + ; // Sets dissolve interpolation on or off. // Dissolve interpolation creates an interpolation or blend across a // polygon between the dissolve (d) values of the materials assigned // to its vertices. This feature is used to create effects exhibiting // varying degrees of apparent transparency, as in glass or clouds. -dissolve_interpolation : 'd_interp' ( 'on' | 'off' ); +dissolve_interpolation + : 'd_interp' ('on' | 'off') + ; // Specifies level of detail. Used only by PreView application // as a hint to which elements to hide for performance. -level_of_detail : 'lod' level=INTEGER; +level_of_detail + : 'lod' level = INTEGER + ; // Specifies the map library file for texture map definitions set with // `usemap`. You can specify multiple filenames. If multiple filenames are // specified, the first file listed is searched first for the map // definition, the second file is searched next, and so on. // - filename is the name of the library file where the texture maps are defined. -map_library : 'maplib' filename=FILENAME+; +map_library + : 'maplib' filename = FILENAME+ + ; // Specifies the texture map name for the element following it. // If you specify texture mapping for a face without texture vertices, // the texture map will be ignored. // - map_name is the name of the texture map. 'off' turns off texture mapping. use_map - : 'usemap' - ( map_name=NAME - | 'off' - ) + : 'usemap' (map_name = NAME | 'off') ; // Specifies the material library file for the material definitions set @@ -340,13 +403,17 @@ use_map // specified, the first file listed is searched first for the material definition, // the second file is searched next, and so on. // - filename is the name of the library file that defines the materials. -material_library : 'mtllib' filename=FILENAME; +material_library + : 'mtllib' filename = FILENAME + ; // Specifies the material name for the element following it. // Once a material is assigned, it cannot be turned off; it can only be changed. // material_name is the name of the material. If a material name is not // specified, a white material is used. -use_material : 'usemtl' NAME; +use_material + : 'usemtl' NAME + ; // Specifies the shadow object filename. This object is used to cast // shadows for the current object. @@ -361,8 +428,9 @@ use_material : 'usemtl' NAME; // given without an extension, an extension of .obj is assumed. // If more than one shadow object is specified, the last one specified // will be used. -shadow_object : 'shadow_obj' filename=FILENAME; - +shadow_object + : 'shadow_obj' filename = FILENAME + ; // Specifies the ray tracing object filename. // This object will be used in generating reflections of the current @@ -376,62 +444,89 @@ shadow_object : 'shadow_obj' filename=FILENAME; // without an extension, an extension of .obj is assumed. // If more than one trace object is specified, the last one specified // will be used. -trace_object : 'trace_obj' filename=FILENAME; +trace_object + : 'trace_obj' filename = FILENAME + ; // Specifies a curve approximation technique. The arguments // specify the technique and resolution for the curve. curve_approximation_technique - : 'ctech' - ( 'cparm' res=decimal - | 'cspace' maxlength=decimal - | 'curv' maxdist=decimal maxangle=decimal - ) + : 'ctech' ( + 'cparm' res = decimal + | 'cspace' maxlength = decimal + | 'curv' maxdist = decimal maxangle = decimal + ) ; // Specifies a surface approximation technique. The arguments // specify the technique and resolution for the surface. surface_approximation_technique - : 'stech' - ( 'cparma' ures=decimal vres=decimal - | 'cparmb' uvres=decimal - | 'cspace' maxlength=decimal - | 'curv' maxdist=decimal maxangle=decimal - ) + : 'stech' ( + 'cparma' ures = decimal vres = decimal + | 'cparmb' uvres = decimal + | 'cspace' maxlength = decimal + | 'curv' maxdist = decimal maxangle = decimal + ) ; - // Compound type of decimal or integer, because any decimal values can accept integers. -decimal: ( DECIMAL | INTEGER ); - +decimal + : (DECIMAL | INTEGER) + ; // LEXER RULES // Pair of vertex and texture index, separated by a slash. -INTEGER_PAIR : INTEGER '/' INTEGER; +INTEGER_PAIR + : INTEGER '/' INTEGER + ; // Triplet of vertex, texture, normal index, separated by slashes. // Texture index can be omitted from the middle. -INTEGER_TRIPLET : INTEGER '/' INTEGER? '/' INTEGER; +INTEGER_TRIPLET + : INTEGER '/' INTEGER? '/' INTEGER + ; -INTEGER : '-'? ( DIGIT )+; +INTEGER + : '-'? (DIGIT)+ + ; -DECIMAL : INTEGER ( '.' DIGIT* )?; +DECIMAL + : INTEGER ('.' DIGIT*)? + ; -fragment DIGIT : '0' .. '9'; +fragment DIGIT + : '0' .. '9' + ; -COMMENT : '#' NON_NL* (NL|EOF) -> skip; +COMMENT + : '#' NON_NL* (NL | EOF) -> skip + ; // Names of identifiers specified in this file format and other related formats. // Possibly more lenient than desired. Officially, for example, // "Letters, numbers, and combinations of letters and numbers are accepted for group names." -NAME : ( 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '-' | '_' | '~' | '(' | ')' )+; +NAME + : ('A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '-' | '_' | '~' | '(' | ')')+ + ; // While we could carefully ban all invalid filenames, the rules for this are complex. -FILENAME: ( ~[/ \t\r\n] )+; +FILENAME + : (~[/ \t\r\n])+ + ; -WS : ( ' ' | '\t' | '\\' NL )+ -> skip; -NL : ( '\r' '\n'? | '\n' ); -NON_NL : ~[\r\n]; -NON_WS : ( ~[ \t\r\n] )+; +WS + : (' ' | '\t' | '\\' NL)+ -> skip + ; +NL + : ('\r' '\n'? | '\n') + ; + +NON_NL + : ~[\r\n] + ; +NON_WS + : (~[ \t\r\n])+ + ; \ No newline at end of file diff --git a/webidl/WebIDL.g4 b/webidl/WebIDL.g4 index ee77c90b45..4cc23fafd6 100644 --- a/webidl/WebIDL.g4 +++ b/webidl/WebIDL.g4 @@ -37,6 +37,10 @@ Web IDL grammar derived from: Web IDL (Second Edition) Editor’s Draft, 3 May 2021 */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar WebIDL; /* Note: appended underscore to keywords for CPP compat: @@ -46,446 +50,445 @@ grammar WebIDL; // Note: Added "wrapper" rule webIDL with EOF token. webIDL - : definitions EOF -; - + : definitions EOF + ; definitions - : extendedAttributeList definition definitions - | /* empty */ -; + : extendedAttributeList definition definitions + | /* empty */ + ; definition - : callbackOrInterfaceOrMixin - | namespace_ - | partial - | dictionary - | enum_ - | typedef_ - | includesStatement -; + : callbackOrInterfaceOrMixin + | namespace_ + | partial + | dictionary + | enum_ + | typedef_ + | includesStatement + ; argumentNameKeyword - : 'async' - | 'attribute' - | 'callback' - | 'const' - | 'constructor' - | 'deleter' - | 'dictionary' - | 'enum' - | 'getter' - | 'includes' - | 'inherit' - | 'interface' - | 'iterable' - | 'maplike' - | 'mixin' - | 'namespace' - | 'partial' - | 'readonly' - | 'required' - | 'setlike' - | 'setter' - | 'static' - | 'stringifier' - | 'typedef' - | 'unrestricted' -; + : 'async' + | 'attribute' + | 'callback' + | 'const' + | 'constructor' + | 'deleter' + | 'dictionary' + | 'enum' + | 'getter' + | 'includes' + | 'inherit' + | 'interface' + | 'iterable' + | 'maplike' + | 'mixin' + | 'namespace' + | 'partial' + | 'readonly' + | 'required' + | 'setlike' + | 'setter' + | 'static' + | 'stringifier' + | 'typedef' + | 'unrestricted' + ; callbackOrInterfaceOrMixin - : 'callback' callbackRestOrInterface - | 'interface' interfaceOrMixin -; + : 'callback' callbackRestOrInterface + | 'interface' interfaceOrMixin + ; interfaceOrMixin : interfaceRest | mixinRest -; + ; interfaceRest - : IDENTIFIER_WEBIDL inheritance '{' interfaceMembers '}' ';' -; + : IDENTIFIER_WEBIDL inheritance '{' interfaceMembers '}' ';' + ; partial - : 'partial' partialDefinition -; + : 'partial' partialDefinition + ; partialDefinition - : 'interface' partialInterfaceOrPartialMixin - | partialDictionary - | namespace_ -; + : 'interface' partialInterfaceOrPartialMixin + | partialDictionary + | namespace_ + ; partialInterfaceOrPartialMixin : partialInterfaceRest | mixinRest -; + ; partialInterfaceRest - : IDENTIFIER_WEBIDL '{' partialInterfaceMembers '}' ';' -; + : IDENTIFIER_WEBIDL '{' partialInterfaceMembers '}' ';' + ; interfaceMembers - : extendedAttributeList interfaceMember interfaceMembers - | /* empty */ -; + : extendedAttributeList interfaceMember interfaceMembers + | /* empty */ + ; interfaceMember : partialInterfaceMember | constructor -; + ; partialInterfaceMembers : extendedAttributeList partialInterfaceMember partialInterfaceMembers | /* empty */ -; + ; partialInterfaceMember - : const_ - | operation - | stringifier - | staticMember - | iterable - | asyncIterable - | readonlyMember - | readWriteAttribute - | readWriteMaplike - | readWriteSetlike - | inheritAttribute -; + : const_ + | operation + | stringifier + | staticMember + | iterable + | asyncIterable + | readonlyMember + | readWriteAttribute + | readWriteMaplike + | readWriteSetlike + | inheritAttribute + ; inheritance - : ':' IDENTIFIER_WEBIDL - | /* empty */ -; + : ':' IDENTIFIER_WEBIDL + | /* empty */ + ; mixinRest : 'mixin' IDENTIFIER_WEBIDL '{' mixinMembers '}' ';' -; + ; mixinMembers : extendedAttributeList mixinMember mixinMembers | /* empty */ -; + ; mixinMember : const_ | regularOperation | stringifier | optionalReadOnly attributeRest -; + ; includesStatement - : IDENTIFIER_WEBIDL 'includes' IDENTIFIER_WEBIDL ';' -; + : IDENTIFIER_WEBIDL 'includes' IDENTIFIER_WEBIDL ';' + ; callbackRestOrInterface - : callbackRest - | 'interface' IDENTIFIER_WEBIDL '{' callbackInterfaceMembers '}' ';' -; + : callbackRest + | 'interface' IDENTIFIER_WEBIDL '{' callbackInterfaceMembers '}' ';' + ; callbackInterfaceMembers : extendedAttributeList callbackInterfaceMember callbackInterfaceMembers | /* empty */ -; + ; callbackInterfaceMember : const_ | regularOperation -; + ; const_ - : 'const' constType IDENTIFIER_WEBIDL '=' constValue ';' -; + : 'const' constType IDENTIFIER_WEBIDL '=' constValue ';' + ; constValue - : booleanLiteral - | floatLiteral - | INTEGER_WEBIDL -; + : booleanLiteral + | floatLiteral + | INTEGER_WEBIDL + ; booleanLiteral - : 'true' - | 'false' -; + : 'true' + | 'false' + ; floatLiteral - : DECIMAL_WEBIDL - | '-Infinity' - | 'Infinity' - | 'NaN' -; + : DECIMAL_WEBIDL + | '-Infinity' + | 'Infinity' + | 'NaN' + ; constType - : primitiveType - | IDENTIFIER_WEBIDL -; + : primitiveType + | IDENTIFIER_WEBIDL + ; readonlyMember - : 'readonly' readonlyMemberRest -; + : 'readonly' readonlyMemberRest + ; readonlyMemberRest - : attributeRest - | maplikeRest - | setlikeRest -; + : attributeRest + | maplikeRest + | setlikeRest + ; readWriteAttribute - : attributeRest -; + : attributeRest + ; inheritAttribute : 'inherit' attributeRest -; + ; attributeRest - : 'attribute' typeWithExtendedAttributes attributeName ';' -; + : 'attribute' typeWithExtendedAttributes attributeName ';' + ; attributeName - : attributeNameKeyword - | IDENTIFIER_WEBIDL -; + : attributeNameKeyword + | IDENTIFIER_WEBIDL + ; attributeNameKeyword - : 'async' - | 'required' -; + : 'async' + | 'required' + ; optionalReadOnly : 'readonly' | /* empty */ -; + ; defaultValue - : constValue - | STRING_WEBIDL - | '[' ']' - | '{' '}' - | 'null' -; + : constValue + | STRING_WEBIDL + | '[' ']' + | '{' '}' + | 'null' + ; operation - : regularOperation - | specialOperation -; + : regularOperation + | specialOperation + ; regularOperation : type_ operationRest -; + ; specialOperation - : special regularOperation -; + : special regularOperation + ; special - : 'getter' - | 'setter' - | 'deleter' -; + : 'getter' + | 'setter' + | 'deleter' + ; operationRest - : optionalOperationName '(' argumentList ')' ';' -; + : optionalOperationName '(' argumentList ')' ';' + ; optionalOperationName - : operationName - | /* empty */ -; + : operationName + | /* empty */ + ; operationName : operationNameKeyword | IDENTIFIER_WEBIDL -; + ; operationNameKeyword : 'includes' -; + ; argumentList - : argument arguments - | /* empty */ -; + : argument arguments + | /* empty */ + ; arguments - : ',' argument arguments - | /* empty */ -; + : ',' argument arguments + | /* empty */ + ; argument - : extendedAttributeList argumentRest -; + : extendedAttributeList argumentRest + ; argumentRest : 'optional' typeWithExtendedAttributes argumentName default_ | type_ ellipsis argumentName -; + ; argumentName - : argumentNameKeyword - | IDENTIFIER_WEBIDL -; + : argumentNameKeyword + | IDENTIFIER_WEBIDL + ; ellipsis - : '...' - | /* empty */ -; + : '...' + | /* empty */ + ; constructor : 'constructor' '(' argumentList ')' ';' -; + ; stringifier - : 'stringifier' stringifierRest -; + : 'stringifier' stringifierRest + ; stringifierRest - : optionalReadOnly attributeRest - | regularOperation - | ';' -; + : optionalReadOnly attributeRest + | regularOperation + | ';' + ; staticMember - : 'static' staticMemberRest -; + : 'static' staticMemberRest + ; staticMemberRest - : optionalReadOnly attributeRest - | regularOperation -; + : optionalReadOnly attributeRest + | regularOperation + ; iterable - : 'iterable' '<' typeWithExtendedAttributes optionalType '>' ';' -; + : 'iterable' '<' typeWithExtendedAttributes optionalType '>' ';' + ; optionalType - : ',' typeWithExtendedAttributes - | /* empty */ -; + : ',' typeWithExtendedAttributes + | /* empty */ + ; asyncIterable : 'async' 'iterable' '<' typeWithExtendedAttributes optionalType '>' optionalArgumentList ';' -; + ; optionalArgumentList : '(' argumentList ')' | /* empty */ -; + ; readWriteMaplike - : maplikeRest -; + : maplikeRest + ; maplikeRest - : 'maplike' '<' typeWithExtendedAttributes ',' typeWithExtendedAttributes '>' ';' -; + : 'maplike' '<' typeWithExtendedAttributes ',' typeWithExtendedAttributes '>' ';' + ; readWriteSetlike - : setlikeRest -; + : setlikeRest + ; setlikeRest - : 'setlike' '<' typeWithExtendedAttributes '>' ';' -; + : 'setlike' '<' typeWithExtendedAttributes '>' ';' + ; namespace_ : 'namespace' IDENTIFIER_WEBIDL '{' namespaceMembers '}' ';' -; + ; namespaceMembers : extendedAttributeList namespaceMember namespaceMembers | /* empty */ -; + ; namespaceMember : regularOperation | 'readonly' attributeRest | const_ -; + ; dictionary - : 'dictionary' IDENTIFIER_WEBIDL inheritance '{' dictionaryMembers '}' ';' -; + : 'dictionary' IDENTIFIER_WEBIDL inheritance '{' dictionaryMembers '}' ';' + ; dictionaryMembers - : dictionaryMember dictionaryMembers - | /* empty */ -; + : dictionaryMember dictionaryMembers + | /* empty */ + ; dictionaryMember - : extendedAttributeList dictionaryMemberRest -; + : extendedAttributeList dictionaryMemberRest + ; dictionaryMemberRest : 'required' typeWithExtendedAttributes IDENTIFIER_WEBIDL ';' | type_ IDENTIFIER_WEBIDL default_ ';' -; + ; partialDictionary - : 'dictionary' IDENTIFIER_WEBIDL '{' dictionaryMembers '}' ';' -; + : 'dictionary' IDENTIFIER_WEBIDL '{' dictionaryMembers '}' ';' + ; default_ - : '=' defaultValue - | /* empty */ -; + : '=' defaultValue + | /* empty */ + ; enum_ - : 'enum' IDENTIFIER_WEBIDL '{' enumValueList '}' ';' -; + : 'enum' IDENTIFIER_WEBIDL '{' enumValueList '}' ';' + ; enumValueList - : STRING_WEBIDL enumValueListComma -; + : STRING_WEBIDL enumValueListComma + ; enumValueListComma - : ',' enumValueListString - | /* empty */ -; + : ',' enumValueListString + | /* empty */ + ; enumValueListString - : STRING_WEBIDL enumValueListComma - | /* empty */ -; + : STRING_WEBIDL enumValueListComma + | /* empty */ + ; callbackRest - : IDENTIFIER_WEBIDL '=' type_ '(' argumentList ')' ';' -; + : IDENTIFIER_WEBIDL '=' type_ '(' argumentList ')' ';' + ; typedef_ - : 'typedef' typeWithExtendedAttributes IDENTIFIER_WEBIDL ';' -; + : 'typedef' typeWithExtendedAttributes IDENTIFIER_WEBIDL ';' + ; type_ - : singleType - | unionType null_ -; + : singleType + | unionType null_ + ; typeWithExtendedAttributes : extendedAttributeList type_ -; + ; singleType - : distinguishableType - | 'any' - | promiseType -; + : distinguishableType + | 'any' + | promiseType + ; unionType - : '(' unionMemberType 'or' unionMemberType unionMemberTypes ')' -; + : '(' unionMemberType 'or' unionMemberType unionMemberTypes ')' + ; unionMemberType - : extendedAttributeList distinguishableType - | unionType null_ -; + : extendedAttributeList distinguishableType + | unionType null_ + ; unionMemberTypes - : 'or' unionMemberType unionMemberTypes - | /* empty */ -; + : 'or' unionMemberType unionMemberTypes + | /* empty */ + ; distinguishableType : primitiveType null_ @@ -498,85 +501,85 @@ distinguishableType | 'FrozenArray' '<' typeWithExtendedAttributes '>' null_ | 'ObservableArray' '<' typeWithExtendedAttributes '>' null_ | recordType null_ -; + ; primitiveType - : unsignedIntegerType - | unrestrictedFloatType - | 'undefined' - | 'boolean' - | 'byte' - | 'octet' - | 'bigint' -; + : unsignedIntegerType + | unrestrictedFloatType + | 'undefined' + | 'boolean' + | 'byte' + | 'octet' + | 'bigint' + ; unrestrictedFloatType - : 'unrestricted' floatType - | floatType -; + : 'unrestricted' floatType + | floatType + ; floatType - : 'float' - | 'double' -; + : 'float' + | 'double' + ; unsignedIntegerType - : 'unsigned' integerType - | integerType -; + : 'unsigned' integerType + | integerType + ; integerType - : 'short' - | 'long' optionalLong -; + : 'short' + | 'long' optionalLong + ; optionalLong - : 'long' - | /* empty */ -; + : 'long' + | /* empty */ + ; stringType : 'ByteString' | 'DOMString' | 'USVString' -; + ; promiseType - : 'Promise' '<' type_ '>' -; + : 'Promise' '<' type_ '>' + ; recordType : 'record' '<' stringType ',' typeWithExtendedAttributes '>' -; + ; null_ - : '?' - | /* empty */ -; + : '?' + | /* empty */ + ; bufferRelatedType - : 'ArrayBuffer' - | 'DataView' - | 'Int8Array' - | 'Int16Array' - | 'Int32Array' - | 'Uint8Array' - | 'Uint16Array' - | 'Uint32Array' - | 'Uint8ClampedArray' - | 'Float32Array' - | 'Float64Array' -; + : 'ArrayBuffer' + | 'DataView' + | 'Int8Array' + | 'Int16Array' + | 'Int32Array' + | 'Uint8Array' + | 'Uint16Array' + | 'Uint32Array' + | 'Uint8ClampedArray' + | 'Float32Array' + | 'Float64Array' + ; extendedAttributeList - : '[' extendedAttribute extendedAttributes ']' - | /* empty */ -; + : '[' extendedAttribute extendedAttributes ']' + | /* empty */ + ; extendedAttributes - : ',' extendedAttribute extendedAttributes - | /* empty */ -; + : ',' extendedAttribute extendedAttributes + | /* empty */ + ; /* https://heycam.github.io/webidl/#idl-extended-attributes "The ExtendedAttribute grammar symbol matches nearly any sequence of tokens, @@ -593,7 +596,7 @@ extendedAttribute | extendedAttributeIdentList | extendedAttributeString | extendedAttributeStringList -; + ; /* Here is the extendedAttribute grammar as defined in the spec @@ -620,131 +623,134 @@ extendedAttributeInner */ other - : INTEGER_WEBIDL - | DECIMAL_WEBIDL - | IDENTIFIER_WEBIDL - | STRING_WEBIDL - | OTHER_WEBIDL - | '-' - | '-Infinity' - | '.' - | '...' - | ':' - | ';' - | '<' - | '=' - | '>' - | '?' - | 'ByteString' - | 'DOMString' - | 'FrozenArray' - | 'Infinity' - | 'NaN' - | 'ObservableArray' - | 'Promise' - | 'USVString' - | 'any' - | 'bigint' - | 'boolean' - | 'byte' - | 'double' - | 'false' - | 'float' - | 'long' - | 'null' - | 'object' - | 'octet' - | 'or' - | 'optional' - | 'record' - | 'sequence' - | 'short' - | 'symbol' - | 'true' - | 'unsigned' - | 'undefined' - | argumentNameKeyword - | bufferRelatedType -; + : INTEGER_WEBIDL + | DECIMAL_WEBIDL + | IDENTIFIER_WEBIDL + | STRING_WEBIDL + | OTHER_WEBIDL + | '-' + | '-Infinity' + | '.' + | '...' + | ':' + | ';' + | '<' + | '=' + | '>' + | '?' + | 'ByteString' + | 'DOMString' + | 'FrozenArray' + | 'Infinity' + | 'NaN' + | 'ObservableArray' + | 'Promise' + | 'USVString' + | 'any' + | 'bigint' + | 'boolean' + | 'byte' + | 'double' + | 'false' + | 'float' + | 'long' + | 'null' + | 'object' + | 'octet' + | 'or' + | 'optional' + | 'record' + | 'sequence' + | 'short' + | 'symbol' + | 'true' + | 'unsigned' + | 'undefined' + | argumentNameKeyword + | bufferRelatedType + ; otherOrComma - : other - | ',' -; + : other + | ',' + ; identifierList - : IDENTIFIER_WEBIDL identifiers -; + : IDENTIFIER_WEBIDL identifiers + ; identifiers - : ',' IDENTIFIER_WEBIDL identifiers - | /* empty */ -; + : ',' IDENTIFIER_WEBIDL identifiers + | /* empty */ + ; extendedAttributeNoArgs - : IDENTIFIER_WEBIDL -; + : IDENTIFIER_WEBIDL + ; extendedAttributeArgList - : IDENTIFIER_WEBIDL '(' argumentList ')' -; + : IDENTIFIER_WEBIDL '(' argumentList ')' + ; extendedAttributeIdent - : IDENTIFIER_WEBIDL '=' IDENTIFIER_WEBIDL -; + : IDENTIFIER_WEBIDL '=' IDENTIFIER_WEBIDL + ; extendedAttributeIdentList - : IDENTIFIER_WEBIDL '=' '(' identifierList ')' -; + : IDENTIFIER_WEBIDL '=' '(' identifierList ')' + ; extendedAttributeNamedArgList - : IDENTIFIER_WEBIDL '=' IDENTIFIER_WEBIDL '(' argumentList ')' -; + : IDENTIFIER_WEBIDL '=' IDENTIFIER_WEBIDL '(' argumentList ')' + ; /* Chromium IDL also allows string literals in extendedAttributes https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/bindings/IDLExtendedAttributes.md */ extendedAttributeString : IDENTIFIER_WEBIDL '=' STRING_WEBIDL -; + ; extendedAttributeStringList : IDENTIFIER_WEBIDL '=' '(' stringList ')' -; + ; stringList : STRING_WEBIDL strings -; + ; strings : ',' STRING_WEBIDL strings | /* empty */ -; + ; INTEGER_WEBIDL - : '-'?('0'([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*) -; + : '-'? ('0' ([Xx][0-9A-Fa-f]+ | [0-7]*) | [1-9][0-9]*) + ; DECIMAL_WEBIDL - : '-'?(([0-9]+'.'[0-9]*|[0-9]*'.'[0-9]+)([Ee][+\-]?[0-9]+)?|[0-9]+[Ee][+\-]?[0-9]+) -; + : '-'? ( + ([0-9]+ '.' [0-9]* | [0-9]* '.' [0-9]+) ([Ee][+\-]? [0-9]+)? + | [0-9]+ [Ee][+\-]? [0-9]+ + ) + ; IDENTIFIER_WEBIDL - : [_-]?[A-Z_a-z][0-9A-Z_a-z]* -; + : [_-]? [A-Z_a-z][0-9A-Z_a-z]* + ; STRING_WEBIDL - : '"' ~["]* '"' -; + : '"' ~["]* '"' + ; WHITESPACE_WEBIDL - : [\t\n\r ]+ -> channel(HIDDEN) -; + : [\t\n\r ]+ -> channel(HIDDEN) + ; COMMENT_WEBIDL - : ('//'~[\n\r]*|'/*'(.|'\n')*?'*/')+ -> channel(HIDDEN) -; // Note: '/''/'~[\n\r]* instead of '/''/'.* (non-greedy because of wildcard). + : ('//' ~[\n\r]* | '/*' (. | '\n')*? '*/')+ -> channel(HIDDEN) + ; // Note: '/''/'~[\n\r]* instead of '/''/'.* (non-greedy because of wildcard). OTHER_WEBIDL - : ~[\t\n\r 0-9A-Z_a-z] -; + : ~[\t\n\r 0-9A-Z_a-z] + ; \ No newline at end of file diff --git a/wkt-crs-v1/wktcrsv1.g4 b/wkt-crs-v1/wktcrsv1.g4 index e344d67f9d..5982698d66 100644 --- a/wkt-crs-v1/wktcrsv1.g4 +++ b/wkt-crs-v1/wktcrsv1.g4 @@ -14,35 +14,115 @@ /* * For parsing propeties file (like GeoTools epsg.properties), use starting rule "propsFile". For parsing single WKT CRS definition, use starting rule "wkt". */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar wktcrsv1; -propsFile: propRow* EOF; - -propRow: commentLine | epsgDefLine; -commentLine: COMMENT_LINE; -epsgDefLine: epsgCode EQ wkt; - -wkt: compdcs | projcs | geogcs | vertcs | geoccs | localcs; -compdcs: 'COMPD_CS' LPAR name COMMA (projcs | geogcs) COMMA vertcs COMMA authority RPAR; -projcs: 'PROJCS' LPAR name COMMA geogcs COMMA projection COMMA (parameter COMMA)+ unit COMMA (axis COMMA)* authority RPAR; -geoccs: 'GEOCCS' LPAR name COMMA datum COMMA primem COMMA unit COMMA (axis COMMA)+ authority RPAR; -geogcs: 'GEOGCS' LPAR name COMMA datum COMMA primem COMMA unit (COMMA axis)* (COMMA authority)? RPAR; -vertcs: 'VERT_CS' LPAR name COMMA vertdatum COMMA unit COMMA axis COMMA authority RPAR; -localcs: 'LOCAL_CS' LPAR name COMMA localdatum COMMA unit COMMA (axis COMMA)+ authority RPAR; -datum: 'DATUM' LPAR name COMMA spheroid (COMMA towgs84)? (COMMA authority)? RPAR; -vertdatum: 'VERT_DATUM' LPAR name COMMA type COMMA authority RPAR; -localdatum: 'LOCAL_DATUM' LPAR name COMMA type (COMMA authority)? RPAR; -spheroid: 'SPHEROID' LPAR name COMMA semiMajorAxis COMMA inverseFlattening (COMMA authority)? RPAR; -towgs84: 'TOWGS84' LPAR dx COMMA dy COMMA dz (COMMA ex COMMA ey COMMA ez (COMMA ppm)?)? RPAR; -authority: 'AUTHORITY' LPAR authorityName COMMA code RPAR; -primem: 'PRIMEM' LPAR name COMMA longitude (COMMA authority)? RPAR; -unit: 'UNIT' LPAR name COMMA conversionFactor (COMMA authority)? RPAR; -axis: 'AXIS' LPAR name COMMA axisOrient RPAR; -projection: 'PROJECTION' LPAR name (COMMA authority)? RPAR; -parameter: 'PARAMETER' LPAR name COMMA value RPAR; -authorityName: '"EPSG"' | '"ESRI"'; -axisOrient: - 'EAST' +propsFile + : propRow* EOF + ; + +propRow + : commentLine + | epsgDefLine + ; + +commentLine + : COMMENT_LINE + ; + +epsgDefLine + : epsgCode EQ wkt + ; + +wkt + : compdcs + | projcs + | geogcs + | vertcs + | geoccs + | localcs + ; + +compdcs + : 'COMPD_CS' LPAR name COMMA (projcs | geogcs) COMMA vertcs COMMA authority RPAR + ; + +projcs + : 'PROJCS' LPAR name COMMA geogcs COMMA projection COMMA (parameter COMMA)+ unit COMMA ( + axis COMMA + )* authority RPAR + ; + +geoccs + : 'GEOCCS' LPAR name COMMA datum COMMA primem COMMA unit COMMA (axis COMMA)+ authority RPAR + ; + +geogcs + : 'GEOGCS' LPAR name COMMA datum COMMA primem COMMA unit (COMMA axis)* (COMMA authority)? RPAR + ; + +vertcs + : 'VERT_CS' LPAR name COMMA vertdatum COMMA unit COMMA axis COMMA authority RPAR + ; + +localcs + : 'LOCAL_CS' LPAR name COMMA localdatum COMMA unit COMMA (axis COMMA)+ authority RPAR + ; + +datum + : 'DATUM' LPAR name COMMA spheroid (COMMA towgs84)? (COMMA authority)? RPAR + ; + +vertdatum + : 'VERT_DATUM' LPAR name COMMA type COMMA authority RPAR + ; + +localdatum + : 'LOCAL_DATUM' LPAR name COMMA type (COMMA authority)? RPAR + ; + +spheroid + : 'SPHEROID' LPAR name COMMA semiMajorAxis COMMA inverseFlattening (COMMA authority)? RPAR + ; + +towgs84 + : 'TOWGS84' LPAR dx COMMA dy COMMA dz (COMMA ex COMMA ey COMMA ez (COMMA ppm)?)? RPAR + ; + +authority + : 'AUTHORITY' LPAR authorityName COMMA code RPAR + ; + +primem + : 'PRIMEM' LPAR name COMMA longitude (COMMA authority)? RPAR + ; + +unit + : 'UNIT' LPAR name COMMA conversionFactor (COMMA authority)? RPAR + ; + +axis + : 'AXIS' LPAR name COMMA axisOrient RPAR + ; + +projection + : 'PROJECTION' LPAR name (COMMA authority)? RPAR + ; + +parameter + : 'PARAMETER' LPAR name COMMA value RPAR + ; + +authorityName + : '"EPSG"' + | '"ESRI"' + ; + +axisOrient + : 'EAST' | 'WEST' | 'NORTH' | 'SOUTH' @@ -53,37 +133,125 @@ axisOrient: | 'GEOCENTRIC_X' | 'GEOCENTRIC_Y' | 'GEOCENTRIC_Z' - | name; - -epsgCode: PKEY | NUMBER; -name: TEXT; -number: NUMBER; -type: NUMBER; -semiMajorAxis: NUMBER; -inverseFlattening: NUMBER; -dx: NUMBER; -dy: NUMBER; -dz: NUMBER; -ex: NUMBER; -ey: NUMBER; -ez: NUMBER; -ppm: NUMBER; -code: TEXT; -longitude: NUMBER; -conversionFactor: NUMBER; -value: NUMBER; - -NUMBER: PM? INT ('.' INT)? EXP?; -TEXT: '"' ('""' | ~'"')* '"'; -PKEY: [A-Z] [0-9A-Z]+; -COMMENT_LINE: '#' ~[\r\n]*; -WS: [ \r\n\t]+ -> skip; - -COMMA: ','; -LPAR: '[' | '('; -RPAR: ']' | ')'; -EQ: '='; - -fragment INT: [0-9]+; -fragment EXP: [Ee] PM? INT; -fragment PM: '+' | '-'; + | name + ; + +epsgCode + : PKEY + | NUMBER + ; + +name + : TEXT + ; + +number + : NUMBER + ; + +type + : NUMBER + ; + +semiMajorAxis + : NUMBER + ; + +inverseFlattening + : NUMBER + ; + +dx + : NUMBER + ; + +dy + : NUMBER + ; + +dz + : NUMBER + ; + +ex + : NUMBER + ; + +ey + : NUMBER + ; + +ez + : NUMBER + ; + +ppm + : NUMBER + ; + +code + : TEXT + ; + +longitude + : NUMBER + ; + +conversionFactor + : NUMBER + ; + +value + : NUMBER + ; + +NUMBER + : PM? INT ('.' INT)? EXP? + ; + +TEXT + : '"' ('""' | ~'"')* '"' + ; + +PKEY + : [A-Z] [0-9A-Z]+ + ; + +COMMENT_LINE + : '#' ~[\r\n]* + ; + +WS + : [ \r\n\t]+ -> skip + ; + +COMMA + : ',' + ; + +LPAR + : '[' + | '(' + ; + +RPAR + : ']' + | ')' + ; + +EQ + : '=' + ; + +fragment INT + : [0-9]+ + ; + +fragment EXP + : [Ee] PM? INT + ; + +fragment PM + : '+' + | '-' + ; \ No newline at end of file diff --git a/wkt/wkt.g4 b/wkt/wkt.g4 index 1e815b3070..f46405a5ef 100644 --- a/wkt/wkt.g4 +++ b/wkt/wkt.g4 @@ -1,352 +1,347 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging grammar wkt; -file_ : geometry* EOF ; +file_ + : geometry* EOF + ; geometryCollection - : GEOMETRYCOLLECTION ( LPAR geometry (COMMA geometry)* RPAR | EMPTY_) - ; + : GEOMETRYCOLLECTION (LPAR geometry (COMMA geometry)* RPAR | EMPTY_) + ; geometry - : (polygonGeometry | lineStringGeometry | pointGeometry | compoundCurveGeometry | curvePolygonGeometry | multiSurfaceGeometry | multiCurveGeometry | multiPointGeometry | multiLineStringGeometry | multiPolygonGeometry | circularStringGeometry | multiPolyhedralSurfaceGeometry | multiTinGeometry | geometryCollection) - ; + : ( + polygonGeometry + | lineStringGeometry + | pointGeometry + | compoundCurveGeometry + | curvePolygonGeometry + | multiSurfaceGeometry + | multiCurveGeometry + | multiPointGeometry + | multiLineStringGeometry + | multiPolygonGeometry + | circularStringGeometry + | multiPolyhedralSurfaceGeometry + | multiTinGeometry + | geometryCollection + ) + ; pointGeometry - : POINT ((name? LPAR point RPAR) | EMPTY_) - ; + : POINT ((name? LPAR point RPAR) | EMPTY_) + ; lineStringGeometry - : LINESTRING lineString - ; + : LINESTRING lineString + ; polygonGeometry - : POLYGON polygon - ; + : POLYGON polygon + ; multiCurveGeometry - : MULTICURVE ((LPAR (lineString | circularStringGeometry | compoundCurveGeometry) (COMMA (circularStringGeometry | lineString | compoundCurveGeometry))* RPAR) | EMPTY_) - ; + : MULTICURVE ( + ( + LPAR (lineString | circularStringGeometry | compoundCurveGeometry) ( + COMMA (circularStringGeometry | lineString | compoundCurveGeometry) + )* RPAR + ) + | EMPTY_ + ) + ; multiSurfaceGeometry - : MULTISURFACE ((LPAR (polygon | curvePolygonGeometry) (COMMA (polygon | curvePolygonGeometry))* RPAR) | EMPTY_) - ; + : MULTISURFACE ( + (LPAR (polygon | curvePolygonGeometry) (COMMA (polygon | curvePolygonGeometry))* RPAR) + | EMPTY_ + ) + ; curvePolygonGeometry - : CURVEPOLYGON ((LPAR (lineString | circularStringGeometry | compoundCurveGeometry) (COMMA (circularStringGeometry | lineString | compoundCurveGeometry))* RPAR) | EMPTY_) - ; + : CURVEPOLYGON ( + ( + LPAR (lineString | circularStringGeometry | compoundCurveGeometry) ( + COMMA (circularStringGeometry | lineString | compoundCurveGeometry) + )* RPAR + ) + | EMPTY_ + ) + ; compoundCurveGeometry - : COMPOUNDCURVE ((LPAR (lineString | circularStringGeometry) (COMMA (circularStringGeometry | lineString))* RPAR) | EMPTY_) - ; + : COMPOUNDCURVE ( + ( + LPAR (lineString | circularStringGeometry) ( + COMMA (circularStringGeometry | lineString) + )* RPAR + ) + | EMPTY_ + ) + ; multiPointGeometry - : MULTIPOINT ((LPAR pointOrClosedPoint (COMMA pointOrClosedPoint)* RPAR) | EMPTY_) - ; + : MULTIPOINT ((LPAR pointOrClosedPoint (COMMA pointOrClosedPoint)* RPAR) | EMPTY_) + ; multiLineStringGeometry - : MULTILINESTRING ((LPAR lineString (COMMA lineString)* RPAR) | EMPTY_) - ; + : MULTILINESTRING ((LPAR lineString (COMMA lineString)* RPAR) | EMPTY_) + ; multiPolygonGeometry - : MULTIPOLYGON ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY_) - ; + : MULTIPOLYGON ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY_) + ; multiPolyhedralSurfaceGeometry - : POLYHEDRALSURFACE ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY_) - ; + : POLYHEDRALSURFACE ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY_) + ; multiTinGeometry - : TIN ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY_) - ; + : TIN ((LPAR polygon (COMMA polygon)* RPAR) | EMPTY_) + ; circularStringGeometry - : CIRCULARSTRING LPAR point (COMMA point)* RPAR - ; + : CIRCULARSTRING LPAR point (COMMA point)* RPAR + ; pointOrClosedPoint - : point - | LPAR point RPAR - ; + : point + | LPAR point RPAR + ; polygon - : LPAR lineString (COMMA lineString)* RPAR | EMPTY_ - ; + : LPAR lineString (COMMA lineString)* RPAR + | EMPTY_ + ; lineString - : LPAR point (COMMA point)* RPAR | EMPTY_ - ; + : LPAR point (COMMA point)* RPAR + | EMPTY_ + ; point - : DECIMAL + - ; + : DECIMAL+ + ; name - : STRING - ; - + : STRING + ; DECIMAL - : '-'? INTEGERPART (DOT DECIMALPART)? - ; - + : '-'? INTEGERPART (DOT DECIMALPART)? + ; INTEGERPART - : '0' | NONZERODIGIT DIGIT* - ; - + : '0' + | NONZERODIGIT DIGIT* + ; DECIMALPART - : DIGIT + - ; - + : DIGIT+ + ; fragment DIGIT - : '0' | NONZERODIGIT - ; - + : '0' + | NONZERODIGIT + ; fragment NONZERODIGIT - : [1-9] - ; - + : [1-9] + ; fragment DOT - : '.' - ; - + : '.' + ; COMMA - : ',' - ; - + : ',' + ; LPAR - : '(' - ; - + : '(' + ; RPAR - : ')' - ; - + : ')' + ; /** * Case-insensitive geometry types */ POINT - : P O I N T - ; - + : P O I N T + ; LINESTRING - : L I N E S T R I N G - ; - + : L I N E S T R I N G + ; POLYGON - : P O L Y G O N - ; - + : P O L Y G O N + ; MULTIPOINT - : M U L T I P O I N T - ; - + : M U L T I P O I N T + ; MULTILINESTRING - : M U L T I L I N E S T R I N G - ; - + : M U L T I L I N E S T R I N G + ; MULTIPOLYGON - : M U L T I P O L Y G O N - ; - + : M U L T I P O L Y G O N + ; GEOMETRYCOLLECTION - : G E O M E T R Y C O L L E C T I O N - ; - + : G E O M E T R Y C O L L E C T I O N + ; EMPTY_ - : E M P T Y - ; - + : E M P T Y + ; CIRCULARSTRING - : C I R C U L A R S T R I N G - ; - + : C I R C U L A R S T R I N G + ; COMPOUNDCURVE - : C O M P O U N D C U R V E - ; + : C O M P O U N D C U R V E + ; MULTISURFACE - : M U L T I S U R F A C E - ; + : M U L T I S U R F A C E + ; CURVEPOLYGON - : C U R V E P O L Y G O N - ; - + : C U R V E P O L Y G O N + ; MULTICURVE - : M U L T I C U R V E - ; - + : M U L T I C U R V E + ; TRIANGLE - : T R I A N G L E - ; - + : T R I A N G L E + ; TIN - : T I N - ; - + : T I N + ; POLYHEDRALSURFACE - : P O L Y H E D R A L S U R F A C E - ; - + : P O L Y H E D R A L S U R F A C E + ; fragment A - : ('a' | 'A') - ; - + : ('a' | 'A') + ; fragment B - : ('b' | 'B') - ; - + : ('b' | 'B') + ; fragment C - : ('c' | 'C') - ; - + : ('c' | 'C') + ; fragment D - : ('d' | 'D') - ; - + : ('d' | 'D') + ; fragment E - : ('e' | 'E') - ; - + : ('e' | 'E') + ; fragment F - : ('f' | 'F') - ; - + : ('f' | 'F') + ; fragment G - : ('g' | 'G') - ; - + : ('g' | 'G') + ; fragment H - : ('h' | 'H') - ; - + : ('h' | 'H') + ; fragment I - : ('i' | 'I') - ; - + : ('i' | 'I') + ; fragment J - : ('j' | 'J') - ; - + : ('j' | 'J') + ; fragment K - : ('k' | 'K') - ; - + : ('k' | 'K') + ; fragment L - : ('l' | 'L') - ; - + : ('l' | 'L') + ; fragment M - : ('m' | 'M') - ; - + : ('m' | 'M') + ; fragment N - : ('n' | 'N') - ; - + : ('n' | 'N') + ; fragment O - : ('o' | 'O') - ; - + : ('o' | 'O') + ; fragment P - : ('p' | 'P') - ; - + : ('p' | 'P') + ; fragment Q - : ('q' | 'Q') - ; - + : ('q' | 'Q') + ; fragment R - : ('r' | 'R') - ; - + : ('r' | 'R') + ; fragment S - : ('s' | 'S') - ; - + : ('s' | 'S') + ; fragment T - : ('t' | 'T') - ; - + : ('t' | 'T') + ; fragment U - : ('u' | 'U') - ; - + : ('u' | 'U') + ; fragment V - : ('v' | 'V') - ; - + : ('v' | 'V') + ; fragment W - : ('w' | 'W') - ; - + : ('w' | 'W') + ; fragment X - : ('x' | 'X') - ; - + : ('x' | 'X') + ; fragment Y - : ('y' | 'Y') - ; - + : ('y' | 'Y') + ; fragment Z - : ('z' | 'Z') - ; - + : ('z' | 'Z') + ; STRING - : [a-zA-Z] + - ; - + : [a-zA-Z]+ + ; WS - : [ \t\r\n] + -> skip - ; - + : [ \t\r\n]+ -> skip + ; \ No newline at end of file diff --git a/wln/wln.g4 b/wln/wln.g4 index 6d30198aa4..e33352f333 100644 --- a/wln/wln.g4 +++ b/wln/wln.g4 @@ -25,143 +25,146 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar wln; wln - : group (SPACE group)* EOF - ; + : group (SPACE group)* EOF + ; group - : symbol+ - ; + : symbol+ + ; symbol - : BROMINE - | CHLORINE - | IODINE - | BENZENE - | DOUBLEBOND - | CARBONYL - | CARBONNON - | NITROGEN3PLUS - | CARBOSYCLIC - | IMINO - | NITROGEN4LESS - | OXYGEN - | HETEROCYCLIC - | DIOXO - | CARBON4 - | CARBON3 - | AMINO - | FLOURINE - | HYDROGEN - | HYDROXYL - | SULFER - | TRIPLE - | DIGIT - ; + : BROMINE + | CHLORINE + | IODINE + | BENZENE + | DOUBLEBOND + | CARBONYL + | CARBONNON + | NITROGEN3PLUS + | CARBOSYCLIC + | IMINO + | NITROGEN4LESS + | OXYGEN + | HETEROCYCLIC + | DIOXO + | CARBON4 + | CARBON3 + | AMINO + | FLOURINE + | HYDROGEN + | HYDROXYL + | SULFER + | TRIPLE + | DIGIT + ; BROMINE - : 'E' - ; + : 'E' + ; CHLORINE - : 'G' - ; + : 'G' + ; IODINE - : 'I' - ; + : 'I' + ; BENZENE - : 'R' - ; + : 'R' + ; DOUBLEBOND - : 'U' - ; + : 'U' + ; CARBONYL - : 'V' - ; + : 'V' + ; CARBONNON - : 'C' - ; + : 'C' + ; NITROGEN3PLUS - : 'K' - ; + : 'K' + ; CARBOSYCLIC - : 'L' - ; + : 'L' + ; IMINO - : 'M' - ; + : 'M' + ; NITROGEN4LESS - : 'N' - ; + : 'N' + ; OXYGEN - : 'O' - ; + : 'O' + ; HETEROCYCLIC - : 'T' - ; + : 'T' + ; DIOXO - : 'W' - ; + : 'W' + ; CARBON4 - : 'X' - ; + : 'X' + ; CARBON3 - : 'Y' - ; + : 'Y' + ; AMINO - : 'Z' - ; + : 'Z' + ; FLOURINE - : 'F' - ; + : 'F' + ; HYDROGEN - : 'H' - ; + : 'H' + ; HYDROXYL - : 'Q' - ; + : 'Q' + ; SULFER - : 'S' - ; + : 'S' + ; TRIPLE - : 'UU' - ; + : 'UU' + ; AMP - : '&' - ; + : '&' + ; DIGIT - : '1' .. '9' - ; + : '1' .. '9' + ; SPACE - : ' ' - ; + : ' ' + ; WS - : [\r\n]+ -> skip - ; - + : [\r\n]+ -> skip + ; \ No newline at end of file diff --git a/wren/WrenLexer.g4 b/wren/WrenLexer.g4 index bb18b178a2..192d018dd4 100644 --- a/wren/WrenLexer.g4 +++ b/wren/WrenLexer.g4 @@ -25,127 +25,123 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -lexer grammar WrenLexer; -AS: 'as'; -BREAK_T: 'break'; -CLASS_T: 'class'; -CONSTRUCT: 'construct'; -CONTINUE_T: 'continue'; -ELSE_T: 'else'; -FALSE_T: 'false'; -FOR_T: 'for'; -FOREIGN_T: 'foreign'; -IF_T: 'if'; -IMPORT_T: 'import'; -IN: 'in'; -IS: 'is'; -NULL_T: 'null'; -RETURN_T: 'return'; -STATIC_T: 'static'; -TRUE_T: 'true'; -VAR_T: 'var'; -WHILE_T: 'while'; - -LPAREN: '('; -RPAREN: ')'; -LBRACE: '{'; -RBRACE: '}'; -LBRACK: '['; -RBRACK: ']'; -SEMI: ';'; -COMMA: ','; -DOT: '.'; - -HASH: '#'; -GT: '>'; -LT: '<'; -BANG: '!'; -TILDE: '~'; -QUESTION: '?'; -COLON: ':'; -EQUAL: '=='; -LE: '<='; -GE: '>='; -NOTEQUAL: '!='; -AND: '&&'; -OR: '||'; -INC: '++'; -DEC: '--'; -ADD: '+'; -SUB: '-'; -MUL: '*'; -DIV: '/'; -BITAND: '&'; -BITOR: '|'; -CARET: '^'; -MOD: '%'; -ASSIGN: '='; -ADD_ASSIGN: '+='; -SUB_ASSIGN: '-='; -MUL_ASSIGN: '*='; -DIV_ASSIGN: '/='; -AND_ASSIGN: '&='; -OR_ASSIGN: '|='; -XOR_ASSIGN: '^='; -MOD_ASSIGN: '%='; -LSHIFT_ASSIGN: '<<='; -LSHIFT : '<<'; -RSHIFT : '>>'; -RSHIFT_ASSIGN: '>>='; -URSHIFT_ASSIGN: '>>>='; -ELLIPSIS_OUT: '...'; -ELLIPSIS_IN: '..'; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -IDENTIFIER: Letter LetterOrDigit*; +lexer grammar WrenLexer; -DECIMAL_LITERAL: SUB? ('0' | [1-9] (Digits? | '_'+ Digits)); -HEX_LITERAL: '0' [xX] [0-9a-fA-F] ([0-9a-fA-F_]* [0-9a-fA-F])?; -OCT_LITERAL: '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?; -BINARY_LITERAL: '0' [bB] [01] ([01_]* [01])? [lL]?; +AS : 'as'; +BREAK_T : 'break'; +CLASS_T : 'class'; +CONSTRUCT : 'construct'; +CONTINUE_T : 'continue'; +ELSE_T : 'else'; +FALSE_T : 'false'; +FOR_T : 'for'; +FOREIGN_T : 'foreign'; +IF_T : 'if'; +IMPORT_T : 'import'; +IN : 'in'; +IS : 'is'; +NULL_T : 'null'; +RETURN_T : 'return'; +STATIC_T : 'static'; +TRUE_T : 'true'; +VAR_T : 'var'; +WHILE_T : 'while'; + +LPAREN : '('; +RPAREN : ')'; +LBRACE : '{'; +RBRACE : '}'; +LBRACK : '['; +RBRACK : ']'; +SEMI : ';'; +COMMA : ','; +DOT : '.'; + +HASH : '#'; +GT : '>'; +LT : '<'; +BANG : '!'; +TILDE : '~'; +QUESTION : '?'; +COLON : ':'; +EQUAL : '=='; +LE : '<='; +GE : '>='; +NOTEQUAL : '!='; +AND : '&&'; +OR : '||'; +INC : '++'; +DEC : '--'; +ADD : '+'; +SUB : '-'; +MUL : '*'; +DIV : '/'; +BITAND : '&'; +BITOR : '|'; +CARET : '^'; +MOD : '%'; +ASSIGN : '='; +ADD_ASSIGN : '+='; +SUB_ASSIGN : '-='; +MUL_ASSIGN : '*='; +DIV_ASSIGN : '/='; +AND_ASSIGN : '&='; +OR_ASSIGN : '|='; +XOR_ASSIGN : '^='; +MOD_ASSIGN : '%='; +LSHIFT_ASSIGN : '<<='; +LSHIFT : '<<'; +RSHIFT : '>>'; +RSHIFT_ASSIGN : '>>='; +URSHIFT_ASSIGN : '>>>='; +ELLIPSIS_OUT : '...'; +ELLIPSIS_IN : '..'; -FLOAT_LITERAL: SUB? (Digits '.' Digits | '.' Digits) ExponentPart? [fFdD]? - | SUB? Digits (ExponentPart [fFdD]? | [fFdD]) - ; +IDENTIFIER: Letter LetterOrDigit*; -HEX_FLOAT_LITERAL: '0' [xX] (HexDigits '.'? | HexDigits? '.' HexDigits) [pP] [+-]? Digits [fFdD]?; +DECIMAL_LITERAL : SUB? ('0' | [1-9] (Digits? | '_'+ Digits)); +HEX_LITERAL : '0' [xX] [0-9a-fA-F] ([0-9a-fA-F_]* [0-9a-fA-F])?; +OCT_LITERAL : '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?; +BINARY_LITERAL : '0' [bB] [01] ([01_]* [01])? [lL]?; +FLOAT_LITERAL: + SUB? (Digits '.' Digits | '.' Digits) ExponentPart? [fFdD]? + | SUB? Digits (ExponentPart [fFdD]? | [fFdD]) +; +HEX_FLOAT_LITERAL: '0' [xX] (HexDigits '.'? | HexDigits? '.' HexDigits) [pP] [+-]? Digits [fFdD]?; -CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; +CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; -STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; -TEXT_BLOCK: '"""' [ \t]* [\r\n] (. | EscapeSequence)*? '"""'; +STRING_LITERAL : '"' (~["\\\r\n] | EscapeSequence)* '"'; +TEXT_BLOCK : '"""' [ \t]* [\r\n] (. | EscapeSequence)*? '"""'; -fragment EscapeSequence - : '\\' [btnfr"'\\] +fragment EscapeSequence: + '\\' [btnfr"'\\] | '\\' ([0-3]? [0-7])? [0-7] | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit - ; - +; -WS: [ \t\r\n\u000C]+ -> channel(HIDDEN); -COMMENT: '/*' .*? '*/' -> channel(2); -LINE_COMMENT: '//' ~[\r\n]* -> channel(2); -ERRCHAR: . -> channel(HIDDEN); +WS : [ \t\r\n\u000C]+ -> channel(HIDDEN); +COMMENT : '/*' .*? '*/' -> channel(2); +LINE_COMMENT : '//' ~[\r\n]* -> channel(2); +ERRCHAR : . -> channel(HIDDEN); -fragment ExponentPart - : [eE] [+-]? Digits - ; +fragment ExponentPart: [eE] [+-]? Digits; -fragment HexDigits - : HexDigit ((HexDigit | '_')* HexDigit)? - ; -fragment HexDigit - : [0-9a-fA-F] - ; -fragment Digits - : [0-9] ([0-9_]* [0-9])? - ; +fragment HexDigits : HexDigit ((HexDigit | '_')* HexDigit)?; +fragment HexDigit : [0-9a-fA-F]; +fragment Digits : [0-9] ([0-9_]* [0-9])?; fragment LetterOrDigit: Letter | [0-9]; fragment Letter: - [a-zA-Z_] - | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate - | [\uD800-\uDBFF] [\uDC00-\uDFFF]; // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF \ No newline at end of file + [a-zA-Z_] + | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate + | [\uD800-\uDBFF] [\uDC00-\uDFFF] +; // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF \ No newline at end of file diff --git a/wren/WrenParser.g4 b/wren/WrenParser.g4 index 1cbe442890..6d65d44594 100644 --- a/wren/WrenParser.g4 +++ b/wren/WrenParser.g4 @@ -25,11 +25,19 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $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 WrenParser; -options { tokenVocab=WrenLexer; } +options { + tokenVocab = WrenLexer; +} -script: fileAtom+ EOF; +script + : fileAtom+ EOF + ; fileAtom : classDefinition @@ -40,8 +48,14 @@ fileAtom ; // assignment -assignment: VAR_T? expression assignOp (expression | assignment+); -assignmentNull: VAR_T id; +assignment + : VAR_T? expression assignOp (expression | assignment+) + ; + +assignmentNull + : VAR_T id + ; + assignOp : ASSIGN | ADD_ASSIGN @@ -57,16 +71,30 @@ assignOp | URSHIFT_ASSIGN ; - // flow -ifSt: ifCond statement elseIf* elseSt?; -ifCond: IF_T LPAREN expression RPAREN; -elseIf: ELSE_T ifCond statement; -elseSt : ELSE_T statement; +ifSt + : ifCond statement elseIf* elseSt? + ; -whileSt: WHILE_T LPAREN (expression | assignment) RPAREN statement; -forSt: FOR_T LPAREN id IN expression RPAREN statement; +ifCond + : IF_T LPAREN expression RPAREN + ; +elseIf + : ELSE_T ifCond statement + ; + +elseSt + : ELSE_T statement + ; + +whileSt + : WHILE_T LPAREN (expression | assignment) RPAREN statement + ; + +forSt + : FOR_T LPAREN id IN expression RPAREN statement + ; // statements statement @@ -80,32 +108,61 @@ statement | returnSt ; -lambdaParameters: BITOR (id (COMMA id)*) BITOR; -block: LBRACE lambdaParameters? statement* RBRACE; -returnSt: RETURN_T expression; +lambdaParameters + : BITOR (id (COMMA id)*) BITOR + ; + +block + : LBRACE lambdaParameters? statement* RBRACE + ; + +returnSt + : RETURN_T expression + ; // class -classDefinition: attributes? FOREIGN_T? CLASS_T id inheritance? LBRACE classBody RBRACE; -inheritance: IS id ; +classDefinition + : attributes? FOREIGN_T? CLASS_T id inheritance? LBRACE classBody RBRACE + ; + +inheritance + : IS id + ; // class atributes attribute : simpleAttribute | groupAttribute ; -attributes: attribute+; -attributeValue: id (ASSIGN atomExpression)?; -simpleAttribute:HASH BANG? attributeValue ; -groupAttribute:HASH BANG? id LPAREN attributeValue (COMMA attributeValue)* RPAREN; + +attributes + : attribute+ + ; + +attributeValue + : id (ASSIGN atomExpression)? + ; + +simpleAttribute + : HASH BANG? attributeValue + ; + +groupAttribute + : HASH BANG? id LPAREN attributeValue (COMMA attributeValue)* RPAREN + ; // class body -classBody:(attributes? classBodyTpe? classStatement)*; +classBody + : (attributes? classBodyTpe? classStatement)* + ; + classBodyTpe : FOREIGN_T | STATIC_T | STATIC_T FOREIGN_T | FOREIGN_T STATIC_T ; + // class statement classStatement : function @@ -117,13 +174,17 @@ classStatement | classConstructor ; -classConstructor: CONSTRUCT id arguments block; +classConstructor + : CONSTRUCT id arguments block + ; + operatorGetter : SUB | TILDE | BANG | id ; + operatorSetter : SUB | MUL @@ -145,26 +206,68 @@ operatorSetter | NOTEQUAL | IS ; -classOpGetter: operatorGetter block?; -classOpSetter: operatorSetter oneArgument block; -oneArgument: LPAREN id RPAREN; -subscript: LBRACK enumeration RBRACK; -classSubscriptGet: subscript block; -classSubscriptSet: subscript ASSIGN oneArgument block; -classSetter: id assignmentSetter block; -assignmentSetter:ASSIGN oneArgument; -arguments: LPAREN (id (COMMA id)*)? RPAREN; -function: id arguments block?; +classOpGetter + : operatorGetter block? + ; + +classOpSetter + : operatorSetter oneArgument block + ; + +oneArgument + : LPAREN id RPAREN + ; + +subscript + : LBRACK enumeration RBRACK + ; + +classSubscriptGet + : subscript block + ; + +classSubscriptSet + : subscript ASSIGN oneArgument block + ; + +classSetter + : id assignmentSetter block + ; + +assignmentSetter + : ASSIGN oneArgument + ; + +arguments + : LPAREN (id (COMMA id)*)? RPAREN + ; + +function + : id arguments block? + ; // imports -importModule: IMPORT_T STRING_LITERAL importVariables?; -importVariable: id (AS id)?; -importVariables: FOR_T importVariable (COMMA importVariable); +importModule + : IMPORT_T STRING_LITERAL importVariables? + ; + +importVariable + : id (AS id)? + ; + +importVariables + : FOR_T importVariable (COMMA importVariable) + ; // call -call: id (callInvoke | block)? (DOT call)*; -callInvoke:(LPAREN enumeration? RPAREN) ; +call + : id (callInvoke | block)? (DOT call)* + ; + +callInvoke + : (LPAREN enumeration? RPAREN) + ; // expressions expression @@ -175,16 +278,16 @@ expression ; compoundExpression - : logic - | arithBit - | arithShift - | arithRange - | arithAdd - | arithMul - | DOT call - | IS expression - | elvis - ; + : logic + | arithBit + | arithShift + | arithRange + | arithAdd + | arithMul + | DOT call + | IS expression + | elvis + ; atomExpression : boolE @@ -202,26 +305,61 @@ atomExpression | importModule | SUB atomExpression ; -enumeration: (expression (COMMA expression)*); -pairEnumeration: (expression COLON expression (COMMA expression COLON expression)*); -range:rangeExpression (ELLIPSIS_IN | ELLIPSIS_OUT) rangeExpression; -listInit: LBRACK enumeration? RBRACK; -mapInit: LBRACE pairEnumeration? RBRACE; + +enumeration + : (expression (COMMA expression)*) + ; + +pairEnumeration + : (expression COLON expression (COMMA expression COLON expression)*) + ; + +range + : rangeExpression (ELLIPSIS_IN | ELLIPSIS_OUT) rangeExpression + ; + +listInit + : LBRACK enumeration? RBRACK + ; + +mapInit + : LBRACE pairEnumeration? RBRACE + ; + elem : call | stringE ; -collectionElem: elem listInit ; + +collectionElem + : elem listInit + ; + rangeExpression : call | numE ; + // arithmetic expressions -arithMul: (MUL | DIV | MOD) expression; -arithAdd: (SUB | ADD) (arithMul | expression); -arithRange:(ELLIPSIS_IN | ELLIPSIS_OUT) (arithAdd | expression); -arithShift:(LSHIFT | RSHIFT) (arithRange | expression); -arithBit: (BITAND | BITOR | CARET) (arithShift | expression); +arithMul + : (MUL | DIV | MOD) expression + ; + +arithAdd + : (SUB | ADD) (arithMul | expression) + ; + +arithRange + : (ELLIPSIS_IN | ELLIPSIS_OUT) (arithAdd | expression) + ; + +arithShift + : (LSHIFT | RSHIFT) (arithRange | expression) + ; + +arithBit + : (BITAND | BITOR | CARET) (arithShift | expression) + ; // logic expressions logicOp @@ -232,24 +370,50 @@ logicOp | GE | NOTEQUAL ; + atomLogic : logicOp expression | (AND | OR) expression ; -andLogic: atomLogic (AND expression atomLogic)*; -logic: andLogic (OR expression andLogic)*; -elvis: QUESTION expression COLON expression; +andLogic + : atomLogic (AND expression atomLogic)* + ; + +logic + : andLogic (OR expression andLogic)* + ; + +elvis + : QUESTION expression COLON expression + ; // primitives -id: IDENTIFIER; -boolE: TRUE_T | FALSE_T ; -charE: CHAR_LITERAL; -stringE: STRING_LITERAL | TEXT_BLOCK ; +id + : IDENTIFIER + ; + +boolE + : TRUE_T + | FALSE_T + ; + +charE + : CHAR_LITERAL + ; + +stringE + : STRING_LITERAL + | TEXT_BLOCK + ; + numE : DECIMAL_LITERAL | HEX_LITERAL | FLOAT_LITERAL | HEX_FLOAT_LITERAL ; -nullE: NULL_T; + +nullE + : NULL_T + ; \ No newline at end of file diff --git a/xml/XMLLexer.g4 b/xml/XMLLexer.g4 index 533b1e9dd1..d9b4555fe8 100644 --- a/xml/XMLLexer.g4 +++ b/xml/XMLLexer.g4 @@ -27,67 +27,67 @@ */ /** XML lexer derived from ANTLR v4 ref guide book example */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar XMLLexer; // Default "mode": Everything OUTSIDE of a tag -COMMENT : '' ; -CDATA : '' ; +COMMENT : ''; +CDATA : ''; /** Scarf all DTD stuff, Entity Declarations like , * and Notation Declarations */ -DTD : '' -> skip ; -EntityRef : '&' Name ';' ; -CharRef : '&#' DIGIT+ ';' - | '&#x' HEXDIGIT+ ';' - ; -SEA_WS : (' '|'\t'|'\r'? '\n')+ ; +DTD : '' -> skip; +EntityRef : '&' Name ';'; +CharRef : '&#' DIGIT+ ';' | '&#x' HEXDIGIT+ ';'; +SEA_WS : (' ' | '\t' | '\r'? '\n')+; -OPEN : '<' -> pushMode(INSIDE) ; -XMLDeclOpen : ' pushMode(INSIDE) ; -SPECIAL_OPEN: ' more, pushMode(PROC_INSTR) ; +OPEN : '<' -> pushMode(INSIDE); +XMLDeclOpen : ' pushMode(INSIDE); +SPECIAL_OPEN : ' more, pushMode(PROC_INSTR); -TEXT : ~[<&]+ ; // match any 16 bit char other than < and & +TEXT: ~[<&]+; // match any 16 bit char other than < and & // ----------------- Everything INSIDE of a tag --------------------- mode INSIDE; -CLOSE : '>' -> popMode ; -SPECIAL_CLOSE: '?>' -> popMode ; // close -SLASH_CLOSE : '/>' -> popMode ; -SLASH : '/' ; -EQUALS : '=' ; -STRING : '"' ~[<"]* '"' - | '\'' ~[<']* '\'' - ; -Name : NameStartChar NameChar* ; -S : [ \t\r\n] -> skip ; - -fragment -HEXDIGIT : [a-fA-F0-9] ; - -fragment -DIGIT : [0-9] ; - -fragment -NameChar : NameStartChar - | '-' | '.' | DIGIT - | '\u00B7' - | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; - -fragment -NameStartChar - : [_:a-zA-Z] - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - ; +CLOSE : '>' -> popMode; +SPECIAL_CLOSE : '?>' -> popMode; // close +SLASH_CLOSE : '/>' -> popMode; +SLASH : '/'; +EQUALS : '='; +STRING : '"' ~[<"]* '"' | '\'' ~[<']* '\''; +Name : NameStartChar NameChar*; +S : [ \t\r\n] -> skip; + +fragment HEXDIGIT: [a-fA-F0-9]; + +fragment DIGIT: [0-9]; + +fragment NameChar: + NameStartChar + | '-' + | '.' + | DIGIT + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' +; + +fragment NameStartChar: + [_:a-zA-Z] + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' +; // ----------------- Handle --------------------- mode PROC_INSTR; -PI : '?>' -> popMode ; // close -IGNORE : . -> more ; +PI : '?>' -> popMode; // close +IGNORE : . -> more; \ No newline at end of file diff --git a/xml/XMLParser.g4 b/xml/XMLParser.g4 index b4810b60d7..92527995db 100644 --- a/xml/XMLParser.g4 +++ b/xml/XMLParser.g4 @@ -27,28 +27,52 @@ */ /** XML parser derived from ANTLR v4 ref guide book example */ + +// $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 XMLParser; -options { tokenVocab=XMLLexer; } +options { + tokenVocab = XMLLexer; +} -document : prolog? misc* element misc* EOF ; +document + : prolog? misc* element misc* EOF + ; -prolog : XMLDeclOpen attribute* SPECIAL_CLOSE ; +prolog + : XMLDeclOpen attribute* SPECIAL_CLOSE + ; -content : chardata? - ((element | reference | CDATA | PI | COMMENT) chardata?)* ; +content + : chardata? ((element | reference | CDATA | PI | COMMENT) chardata?)* + ; -element : '<' Name attribute* '>' content '<' '/' Name '>' - | '<' Name attribute* '/>' - ; +element + : '<' Name attribute* '>' content '<' '/' Name '>' + | '<' Name attribute* '/>' + ; -reference : EntityRef | CharRef ; +reference + : EntityRef + | CharRef + ; -attribute : Name '=' STRING ; // Our STRING is AttValue in spec +attribute + : Name '=' STRING + ; // Our STRING is AttValue in spec /** ``All text that is not markup constitutes the character data of * the document.'' */ -chardata : TEXT | SEA_WS ; +chardata + : TEXT + | SEA_WS + ; -misc : COMMENT | PI | SEA_WS ; +misc + : COMMENT + | PI + | SEA_WS + ; \ No newline at end of file diff --git a/xpath/xpath1/xpath.g4 b/xpath/xpath1/xpath.g4 index e96654846c..493e40c58d 100644 --- a/xpath/xpath1/xpath.g4 +++ b/xpath/xpath1/xpath.g4 @@ -1,3 +1,6 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar xpath; /* @@ -51,254 +54,316 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +main + : expr EOF + ; -main : expr EOF - ; - -locationPath - : relativeLocationPath - | absoluteLocationPathNoroot - ; +locationPath + : relativeLocationPath + | absoluteLocationPathNoroot + ; absoluteLocationPathNoroot - : '/' relativeLocationPath - | '//' relativeLocationPath - ; + : '/' relativeLocationPath + | '//' relativeLocationPath + ; relativeLocationPath - : step (('/'|'//') step)* - ; + : step (('/' | '//') step)* + ; -step : axisSpecifier nodeTest predicate* - | abbreviatedStep - ; +step + : axisSpecifier nodeTest predicate* + | abbreviatedStep + ; axisSpecifier - : AxisName '::' - | AT? - ; + : AxisName '::' + | AT? + ; -nodeTest: nameTest - | NodeType '(' ')' - | 'processing-instruction' '(' Literal ')' - ; +nodeTest + : nameTest + | NodeType '(' ')' + | 'processing-instruction' '(' Literal ')' + ; predicate - : '[' expr ']' - ; + : '[' expr ']' + ; abbreviatedStep - : '.' - | '..' - ; + : '.' + | '..' + ; -expr : orExpr - ; +expr + : orExpr + ; primaryExpr - : variableReference - | '(' expr ')' - | Literal - | Number - | functionCall - ; + : variableReference + | '(' expr ')' + | Literal + | Number + | functionCall + ; functionCall - : functionName '(' ( expr ( ',' expr )* )? ')' - ; + : functionName '(' (expr ( ',' expr)*)? ')' + ; unionExprNoRoot - : pathExprNoRoot ('|' unionExprNoRoot)? - | '/' '|' unionExprNoRoot - ; + : pathExprNoRoot ('|' unionExprNoRoot)? + | '/' '|' unionExprNoRoot + ; pathExprNoRoot - : locationPath - | filterExpr (('/'|'//') relativeLocationPath)? - ; + : locationPath + | filterExpr (('/' | '//') relativeLocationPath)? + ; filterExpr - : primaryExpr predicate* - ; + : primaryExpr predicate* + ; -orExpr : andExpr (OR andExpr)* - ; +orExpr + : andExpr (OR andExpr)* + ; -andExpr : equalityExpr (AND equalityExpr)* - ; +andExpr + : equalityExpr (AND equalityExpr)* + ; equalityExpr - : relationalExpr (('='|'!=') relationalExpr)* - ; + : relationalExpr (('=' | '!=') relationalExpr)* + ; relationalExpr - : additiveExpr (('<'|'>'|'<='|'>=') additiveExpr)* - ; + : additiveExpr (('<' | '>' | '<=' | '>=') additiveExpr)* + ; additiveExpr - : multiplicativeExpr (('+'|'-') multiplicativeExpr)* - ; + : multiplicativeExpr (('+' | '-') multiplicativeExpr)* + ; multiplicativeExpr - : unaryExprNoRoot (('*'|DIV|MOD) multiplicativeExpr)? - | '/' ((DIV|MOD) multiplicativeExpr)? - ; + : unaryExprNoRoot (('*' | DIV | MOD) multiplicativeExpr)? + | '/' ((DIV | MOD) multiplicativeExpr)? + ; unaryExprNoRoot - : '-'* unionExprNoRoot - ; + : '-'* unionExprNoRoot + ; -qName : nCName (':' nCName)? - ; +qName + : nCName (':' nCName)? + ; // Does not match NodeType, as per spec. functionName - : nCName ':' nCName - | NCName - | AxisName - | AND - | OR - | DIV - | MOD - ; + : nCName ':' nCName + | NCName + | AxisName + | AND + | OR + | DIV + | MOD + ; variableReference - : '$' qName - ; - -nameTest: '*' - | nCName ':' '*' - | qName - ; - -nCName : NCName - | AxisName - | NodeType - | AND - | OR - | DIV - | MOD - ; - -NodeType: 'comment' - | 'text' - | 'processing-instruction' - | 'node' - ; - -Number : Digits ('.' Digits?)? - | '.' Digits - ; - -fragment -Digits : ('0'..'9')+ - ; - -AxisName: 'ancestor' - | 'ancestor-or-self' - | 'attribute' - | 'child' - | 'descendant' - | 'descendant-or-self' - | 'following' - | 'following-sibling' - | 'namespace' - | 'parent' - | 'preceding' - | 'preceding-sibling' - | 'self' - ; - - - PATHSEP - :'/'; - ABRPATH - : '//'; - LPAR - : '('; - RPAR - : ')'; - LBRAC - : '['; - RBRAC - : ']'; - MINUS - : '-'; - PLUS - : '+'; - DOT - : '.'; - MUL - : '*'; - DOTDOT - : '..'; - AT - : '@'; - COMMA - : ','; - PIPE - : '|'; - LESS - : '<'; - MORE_ - : '>'; - LE - : '<='; - GE - : '>='; - COLON - : ':'; - CC - : '::'; - APOS - : '\''; - QUOT - : '"'; - AND - : 'and'; - OR - : 'or'; - DIV - : 'div'; - MOD - : 'mod'; - - -Literal : '"' ~'"'* '"' - | '\'' ~'\''* '\'' - ; + : '$' qName + ; + +nameTest + : '*' + | nCName ':' '*' + | qName + ; + +nCName + : NCName + | AxisName + | NodeType + | AND + | OR + | DIV + | MOD + ; + +NodeType + : 'comment' + | 'text' + | 'processing-instruction' + | 'node' + ; + +Number + : Digits ('.' Digits?)? + | '.' Digits + ; + +fragment Digits + : ('0' ..'9')+ + ; + +AxisName + : 'ancestor' + | 'ancestor-or-self' + | 'attribute' + | 'child' + | 'descendant' + | 'descendant-or-self' + | 'following' + | 'following-sibling' + | 'namespace' + | 'parent' + | 'preceding' + | 'preceding-sibling' + | 'self' + ; + +PATHSEP + : '/' + ; + +ABRPATH + : '//' + ; + +LPAR + : '(' + ; + +RPAR + : ')' + ; + +LBRAC + : '[' + ; + +RBRAC + : ']' + ; + +MINUS + : '-' + ; + +PLUS + : '+' + ; + +DOT + : '.' + ; + +MUL + : '*' + ; + +DOTDOT + : '..' + ; + +AT + : '@' + ; + +COMMA + : ',' + ; + +PIPE + : '|' + ; + +LESS + : '<' + ; + +MORE_ + : '>' + ; + +LE + : '<=' + ; + +GE + : '>=' + ; + +COLON + : ':' + ; + +CC + : '::' + ; + +APOS + : '\'' + ; + +QUOT + : '"' + ; + +AND + : 'and' + ; + +OR + : 'or' + ; -Whitespace - : (' '|'\t'|'\n'|'\r')+ ->skip - ; - -NCName : NCNameStartChar NCNameChar* - ; - -fragment -NCNameStartChar - : 'A'..'Z' - | '_' - | 'a'..'z' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - | '\u{10000}'..'\u{EFFFF}' - ; - -fragment -NCNameChar - : NCNameStartChar | '-' | '.' | '0'..'9' - | '\u00B7' | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; +DIV + : 'div' + ; +MOD + : 'mod' + ; +Literal + : '"' ~'"'* '"' + | '\'' ~'\''* '\'' + ; + +Whitespace + : (' ' | '\t' | '\n' | '\r')+ -> skip + ; + +NCName + : NCNameStartChar NCNameChar* + ; + +fragment NCNameStartChar + : 'A' ..'Z' + | '_' + | 'a' ..'z' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00F6' + | '\u00F8' ..'\u02FF' + | '\u0370' ..'\u037D' + | '\u037F' ..'\u1FFF' + | '\u200C' ..'\u200D' + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' + | '\u{10000}' ..'\u{EFFFF}' + ; + +fragment NCNameChar + : NCNameStartChar + | '-' + | '.' + | '0' ..'9' + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' + ; \ No newline at end of file diff --git a/xpath/xpath20/XPath20Lexer.g4 b/xpath/xpath20/XPath20Lexer.g4 index 13b3ca0c7c..c5e1b8ec67 100644 --- a/xpath/xpath20/XPath20Lexer.g4 +++ b/xpath/xpath20/XPath20Lexer.g4 @@ -5,167 +5,178 @@ // This is a faithful implementation of the XPath version 2.0 grammar // from the spec at https://www.w3.org/TR/xpath20/ -lexer grammar XPath20Lexer; +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true -AT : '@' ; -BANG : '!' ; -CB : ']' ; -CC : '}' ; -CEQ : ':=' ; -COLON : ':' ; -COLONCOLON : '::' ; -COMMA : ',' ; -CP : ')' ; -CS : ':*' ; -D : '.' ; -DD : '..' ; -DOLLAR : '$' ; -EG : '=>' ; -EQ : '=' ; -GE : '>=' ; -GG : '>>' ; -GT : '>' ; -LE : '<=' ; -LL : '<<' ; -LT : '<' ; -MINUS : '-' ; -NE : '!=' ; -OB : '[' ; -OC : '{' ; -OP : '(' ; -P : '|' ; -PLUS : '+' ; -POUND : '#' ; -PP : '||' ; -QM : '?' ; -SC : '*:' ; -SLASH : '/' ; -SS : '//' ; -STAR : '*' ; +lexer grammar XPath20Lexer; + +AT : '@'; +BANG : '!'; +CB : ']'; +CC : '}'; +CEQ : ':='; +COLON : ':'; +COLONCOLON : '::'; +COMMA : ','; +CP : ')'; +CS : ':*'; +D : '.'; +DD : '..'; +DOLLAR : '$'; +EG : '=>'; +EQ : '='; +GE : '>='; +GG : '>>'; +GT : '>'; +LE : '<='; +LL : '<<'; +LT : '<'; +MINUS : '-'; +NE : '!='; +OB : '['; +OC : '{'; +OP : '('; +P : '|'; +PLUS : '+'; +POUND : '#'; +PP : '||'; +QM : '?'; +SC : '*:'; +SLASH : '/'; +SS : '//'; +STAR : '*'; // KEYWORDS -KW_ANCESTOR : 'ancestor' ; -KW_ANCESTOR_OR_SELF : 'ancestor-or-self' ; -KW_AND : 'and' ; -KW_ARRAY : 'array' ; -KW_AS : 'as' ; -KW_ATTRIBUTE : 'attribute' ; -KW_CAST : 'cast' ; -KW_CASTABLE : 'castable' ; -KW_CHILD : 'child' ; -KW_COMMENT : 'comment' ; -KW_DESCENDANT : 'descendant' ; -KW_DESCENDANT_OR_SELF : 'descendant-or-self' ; -KW_DIV : 'div' ; -KW_DOCUMENT_NODE : 'document-node' ; -KW_ELEMENT : 'element' ; -KW_ELSE : 'else' ; -KW_EMPTY_SEQUENCE : 'empty-sequence' ; -KW_EQ : 'eq' ; -KW_EVERY : 'every' ; -KW_EXCEPT : 'except' ; -KW_FOLLOWING : 'following' ; -KW_FOLLOWING_SIBLING : 'following-sibling' ; -KW_FOR : 'for' ; -KW_FUNCTION : 'function' ; -KW_GE : 'ge' ; -KW_GT : 'gt' ; -KW_IDIV : 'idiv' ; -KW_IF : 'if' ; -KW_IN : 'in' ; -KW_INSTANCE : 'instance' ; -KW_INTERSECT : 'intersect' ; -KW_IS : 'is' ; -KW_ITEM : 'item' ; -KW_LE : 'le' ; -KW_LET : 'let' ; -KW_LT : 'lt' ; -KW_MAP : 'map' ; -KW_MOD : 'mod' ; -KW_NAMESPACE : 'namespace' ; -KW_NAMESPACE_NODE : 'namespace-node' ; -KW_NE : 'ne' ; -KW_NODE : 'node' ; -KW_OF : 'of' ; -KW_OR : 'or' ; -KW_PARENT : 'parent' ; -KW_PRECEDING : 'preceding' ; -KW_PRECEDING_SIBLING : 'preceding-sibling' ; -KW_PROCESSING_INSTRUCTION : 'processing-instruction' ; -KW_RETURN : 'return' ; -KW_SATISFIES : 'satisfies' ; -KW_SCHEMA_ATTRIBUTE : 'schema-attribute' ; -KW_SCHEMA_ELEMENT : 'schema-element' ; -KW_SELF : 'self' ; -KW_SOME : 'some' ; -KW_TEXT : 'text' ; -KW_THEN : 'then' ; -KW_TO : 'to' ; -KW_TREAT : 'treat' ; -KW_UNION : 'union' ; +KW_ANCESTOR : 'ancestor'; +KW_ANCESTOR_OR_SELF : 'ancestor-or-self'; +KW_AND : 'and'; +KW_ARRAY : 'array'; +KW_AS : 'as'; +KW_ATTRIBUTE : 'attribute'; +KW_CAST : 'cast'; +KW_CASTABLE : 'castable'; +KW_CHILD : 'child'; +KW_COMMENT : 'comment'; +KW_DESCENDANT : 'descendant'; +KW_DESCENDANT_OR_SELF : 'descendant-or-self'; +KW_DIV : 'div'; +KW_DOCUMENT_NODE : 'document-node'; +KW_ELEMENT : 'element'; +KW_ELSE : 'else'; +KW_EMPTY_SEQUENCE : 'empty-sequence'; +KW_EQ : 'eq'; +KW_EVERY : 'every'; +KW_EXCEPT : 'except'; +KW_FOLLOWING : 'following'; +KW_FOLLOWING_SIBLING : 'following-sibling'; +KW_FOR : 'for'; +KW_FUNCTION : 'function'; +KW_GE : 'ge'; +KW_GT : 'gt'; +KW_IDIV : 'idiv'; +KW_IF : 'if'; +KW_IN : 'in'; +KW_INSTANCE : 'instance'; +KW_INTERSECT : 'intersect'; +KW_IS : 'is'; +KW_ITEM : 'item'; +KW_LE : 'le'; +KW_LET : 'let'; +KW_LT : 'lt'; +KW_MAP : 'map'; +KW_MOD : 'mod'; +KW_NAMESPACE : 'namespace'; +KW_NAMESPACE_NODE : 'namespace-node'; +KW_NE : 'ne'; +KW_NODE : 'node'; +KW_OF : 'of'; +KW_OR : 'or'; +KW_PARENT : 'parent'; +KW_PRECEDING : 'preceding'; +KW_PRECEDING_SIBLING : 'preceding-sibling'; +KW_PROCESSING_INSTRUCTION : 'processing-instruction'; +KW_RETURN : 'return'; +KW_SATISFIES : 'satisfies'; +KW_SCHEMA_ATTRIBUTE : 'schema-attribute'; +KW_SCHEMA_ELEMENT : 'schema-element'; +KW_SELF : 'self'; +KW_SOME : 'some'; +KW_TEXT : 'text'; +KW_THEN : 'then'; +KW_TO : 'to'; +KW_TREAT : 'treat'; +KW_UNION : 'union'; // A.2.1. TERMINAL SYMBOLS // This isn't a complete list of tokens in the language. // Keywords and symbols are terminals. -IntegerLiteral : FragDigits ; -DecimalLiteral : '.' FragDigits | FragDigits '.' [0-9]* ; -DoubleLiteral : ('.' FragDigits | FragDigits ('.' [0-9]*)?) [eE] [+-]? FragDigits ; -StringLiteral : '"' (~["] | FragEscapeQuot)* '"' | '\'' (~['] | FragEscapeApos)* '\'' ; -URIQualifiedName : BracedURILiteral NCName ; -BracedURILiteral : 'Q' '{' [^{}]* '}' ; +IntegerLiteral : FragDigits; +DecimalLiteral : '.' FragDigits | FragDigits '.' [0-9]*; +DoubleLiteral : ('.' FragDigits | FragDigits ('.' [0-9]*)?) [eE] [+-]? FragDigits; +StringLiteral : '"' (~["] | FragEscapeQuot)* '"' | '\'' (~['] | FragEscapeApos)* '\''; +URIQualifiedName : BracedURILiteral NCName; +BracedURILiteral : 'Q' '{' [^{}]* '}'; // Error in spec: EscapeQuot and EscapeApos are not terminals! -fragment FragEscapeQuot : '""' ; +fragment FragEscapeQuot : '""'; fragment FragEscapeApos : '\'\''; // Error in spec: Comment isn't really a terminal, but an off-channel object. -Comment : '(:' (Comment | CommentContents)*? ':)' -> skip ; -QName : FragQName ; -NCName : FragmentNCName ; +Comment : '(:' (Comment | CommentContents)*? ':)' -> skip; +QName : FragQName; +NCName : FragmentNCName; // Error in spec: Char is not a terminal! -fragment Char : FragChar ; -fragment FragDigits : [0-9]+ ; -fragment CommentContents : Char ; +fragment Char : FragChar; +fragment FragDigits : [0-9]+; +fragment CommentContents : Char; // https://www.w3.org/TR/REC-xml-names/#NT-QName -fragment FragQName : FragPrefixedName | FragUnprefixedName ; -fragment FragPrefixedName : FragPrefix ':' FragLocalPart ; -fragment FragUnprefixedName : FragLocalPart ; -fragment FragPrefix : FragmentNCName ; -fragment FragLocalPart : FragmentNCName ; -fragment FragNCNameStartChar - : 'A'..'Z' - | '_' - | 'a'..'z' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - | '\u{10000}'..'\u{EFFFF}' - ; -fragment FragNCNameChar - : FragNCNameStartChar | '-' | '.' | '0'..'9' - | '\u00B7' | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; -fragment FragmentNCName : FragNCNameStartChar FragNCNameChar* ; +fragment FragQName : FragPrefixedName | FragUnprefixedName; +fragment FragPrefixedName : FragPrefix ':' FragLocalPart; +fragment FragUnprefixedName : FragLocalPart; +fragment FragPrefix : FragmentNCName; +fragment FragLocalPart : FragmentNCName; +fragment FragNCNameStartChar: + 'A' ..'Z' + | '_' + | 'a' ..'z' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00F6' + | '\u00F8' ..'\u02FF' + | '\u0370' ..'\u037D' + | '\u037F' ..'\u1FFF' + | '\u200C' ..'\u200D' + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' + | '\u{10000}' ..'\u{EFFFF}' +; +fragment FragNCNameChar: + FragNCNameStartChar + | '-' + | '.' + | '0' ..'9' + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' +; +fragment FragmentNCName: FragNCNameStartChar FragNCNameChar*; // https://www.w3.org/TR/REC-xml/#NT-Char -fragment FragChar : '\u0009' | '\u000a' | '\u000d' - | '\u0020'..'\ud7ff' - | '\ue000'..'\ufffd' - | '\u{10000}'..'\u{10ffff}' - ; +fragment FragChar: + '\u0009' + | '\u000a' + | '\u000d' + | '\u0020' ..'\ud7ff' + | '\ue000' ..'\ufffd' + | '\u{10000}' ..'\u{10ffff}' +; // https://github.com/antlr/grammars-v4/blob/17d3db3fd6a8fc319a12176e0bb735b066ec0616/xpath/xpath31/XPath31.g4#L389 -Whitespace : ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip ; +Whitespace: ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip; // Not per spec. Specified for testing. -SEMI : ';' ; +SEMI: ';'; \ No newline at end of file diff --git a/xpath/xpath20/XPath20Parser.g4 b/xpath/xpath20/XPath20Parser.g4 index b1a9ec648c..cce736ea69 100644 --- a/xpath/xpath20/XPath20Parser.g4 +++ b/xpath/xpath20/XPath20Parser.g4 @@ -5,158 +5,433 @@ // This is a faithful implementation of the XPath version 2.0 grammar // from the spec at https://www.w3.org/TR/xpath20/ -parser grammar XPath20Parser; +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging -options { tokenVocab=XPath20Lexer; superClass=XPath20ParserBase; } +parser grammar XPath20Parser; + +options { + tokenVocab = XPath20Lexer; + superClass = XPath20ParserBase; +} // [1] -xpath : expr EOF ; -expr : exprsingle ( COMMA exprsingle)* ; -exprsingle : forexpr | quantifiedexpr | ifexpr | orexpr ; -forexpr : simpleforclause KW_RETURN exprsingle ; +xpath + : expr EOF + ; + +expr + : exprsingle (COMMA exprsingle)* + ; + +exprsingle + : forexpr + | quantifiedexpr + | ifexpr + | orexpr + ; + +forexpr + : simpleforclause KW_RETURN exprsingle + ; + // [5] -simpleforclause : KW_FOR DOLLAR varname KW_IN exprsingle ( COMMA DOLLAR varname KW_IN exprsingle )* ; -quantifiedexpr : ( KW_SOME | KW_EVERY) DOLLAR varname KW_IN exprsingle ( COMMA DOLLAR varname KW_IN exprsingle)* KW_SATISFIES exprsingle ; -ifexpr : KW_IF OP expr CP KW_THEN exprsingle KW_ELSE exprsingle ; -orexpr : andexpr ( KW_OR andexpr )* ; -andexpr : comparisonexpr ( KW_AND comparisonexpr )* ; +simpleforclause + : KW_FOR DOLLAR varname KW_IN exprsingle (COMMA DOLLAR varname KW_IN exprsingle)* + ; + +quantifiedexpr + : (KW_SOME | KW_EVERY) DOLLAR varname KW_IN exprsingle (COMMA DOLLAR varname KW_IN exprsingle)* KW_SATISFIES exprsingle + ; + +ifexpr + : KW_IF OP expr CP KW_THEN exprsingle KW_ELSE exprsingle + ; + +orexpr + : andexpr (KW_OR andexpr)* + ; + +andexpr + : comparisonexpr (KW_AND comparisonexpr)* + ; + // [10] -comparisonexpr : rangeexpr ( (valuecomp | generalcomp | nodecomp) rangeexpr )? ; -rangeexpr : additiveexpr ( KW_TO additiveexpr )? ; -additiveexpr : multiplicativeexpr ( (PLUS | MINUS) multiplicativeexpr )* ; -multiplicativeexpr : unionexpr ( (STAR | KW_DIV | KW_IDIV | KW_MOD) unionexpr )* ; -unionexpr : intersectexceptexpr ( (KW_UNION | P) intersectexceptexpr )* ; +comparisonexpr + : rangeexpr ((valuecomp | generalcomp | nodecomp) rangeexpr)? + ; + +rangeexpr + : additiveexpr (KW_TO additiveexpr)? + ; + +additiveexpr + : multiplicativeexpr ((PLUS | MINUS) multiplicativeexpr)* + ; + +multiplicativeexpr + : unionexpr ((STAR | KW_DIV | KW_IDIV | KW_MOD) unionexpr)* + ; + +unionexpr + : intersectexceptexpr ((KW_UNION | P) intersectexceptexpr)* + ; + // [15] -intersectexceptexpr : instanceofexpr ( ( KW_INTERSECT | KW_EXCEPT) instanceofexpr )* ; -instanceofexpr : treatexpr ( KW_INSTANCE KW_OF sequencetype )? ; -treatexpr : castableexpr ( KW_TREAT KW_AS sequencetype )? ; -castableexpr : castexpr ( KW_CASTABLE KW_AS singletype )? ; -castexpr : unaryexpr ( KW_CAST KW_AS singletype )? ; +intersectexceptexpr + : instanceofexpr (( KW_INTERSECT | KW_EXCEPT) instanceofexpr)* + ; + +instanceofexpr + : treatexpr (KW_INSTANCE KW_OF sequencetype)? + ; + +treatexpr + : castableexpr (KW_TREAT KW_AS sequencetype)? + ; + +castableexpr + : castexpr (KW_CASTABLE KW_AS singletype)? + ; + +castexpr + : unaryexpr (KW_CAST KW_AS singletype)? + ; + // [20] -unaryexpr : ( MINUS | PLUS)* valueexpr ; -valueexpr : pathexpr ; -generalcomp : EQ | NE | LT | LE | GT | GE ; -valuecomp : KW_EQ | KW_NE | KW_LT | KW_LE | KW_GT | KW_GE ; -nodecomp : KW_IS | LL | GG ; +unaryexpr + : (MINUS | PLUS)* valueexpr + ; + +valueexpr + : pathexpr + ; + +generalcomp + : EQ + | NE + | LT + | LE + | GT + | GE + ; + +valuecomp + : KW_EQ + | KW_NE + | KW_LT + | KW_LE + | KW_GT + | KW_GE + ; + +nodecomp + : KW_IS + | LL + | GG + ; + // [25] -pathexpr : SLASH relativepathexpr? | SS relativepathexpr | relativepathexpr ; -relativepathexpr : stepexpr (( SLASH | SS) stepexpr)* ; -stepexpr : filterexpr | axisstep ; -axisstep : (reversestep | forwardstep) predicatelist ; -forwardstep : forwardaxis nodetest | abbrevforwardstep ; +pathexpr + : SLASH relativepathexpr? + | SS relativepathexpr + | relativepathexpr + ; + +relativepathexpr + : stepexpr (( SLASH | SS) stepexpr)* + ; + +stepexpr + : filterexpr + | axisstep + ; + +axisstep + : (reversestep | forwardstep) predicatelist + ; + +forwardstep + : forwardaxis nodetest + | abbrevforwardstep + ; + // [30] -forwardaxis : KW_CHILD COLONCOLON | KW_DESCENDANT COLONCOLON | KW_ATTRIBUTE COLONCOLON | KW_SELF COLONCOLON | KW_DESCENDANT_OR_SELF COLONCOLON | KW_FOLLOWING_SIBLING COLONCOLON | KW_FOLLOWING COLONCOLON | KW_NAMESPACE COLONCOLON ; -abbrevforwardstep : AT? nodetest ; -reversestep : reverseaxis nodetest | abbrevreversestep ; -reverseaxis : KW_PARENT COLONCOLON | KW_ANCESTOR COLONCOLON | KW_PRECEDING_SIBLING COLONCOLON | KW_PRECEDING COLONCOLON | KW_ANCESTOR_OR_SELF COLONCOLON ; -abbrevreversestep : DD ; +forwardaxis + : KW_CHILD COLONCOLON + | KW_DESCENDANT COLONCOLON + | KW_ATTRIBUTE COLONCOLON + | KW_SELF COLONCOLON + | KW_DESCENDANT_OR_SELF COLONCOLON + | KW_FOLLOWING_SIBLING COLONCOLON + | KW_FOLLOWING COLONCOLON + | KW_NAMESPACE COLONCOLON + ; + +abbrevforwardstep + : AT? nodetest + ; + +reversestep + : reverseaxis nodetest + | abbrevreversestep + ; + +reverseaxis + : KW_PARENT COLONCOLON + | KW_ANCESTOR COLONCOLON + | KW_PRECEDING_SIBLING COLONCOLON + | KW_PRECEDING COLONCOLON + | KW_ANCESTOR_OR_SELF COLONCOLON + ; + +abbrevreversestep + : DD + ; + // [35] -nodetest : kindtest | nametest ; -nametest : qname | wildcard ; -wildcard : STAR | NCName CS | SC NCName ; -filterexpr : primaryexpr predicatelist ; -predicatelist : predicate* ; +nodetest + : kindtest + | nametest + ; + +nametest + : qname + | wildcard + ; + +wildcard + : STAR + | NCName CS + | SC NCName + ; + +filterexpr + : primaryexpr predicatelist + ; + +predicatelist + : predicate* + ; + // [40] -predicate : OB expr CB ; -primaryexpr : literal | varref | parenthesizedexpr | contextitemexpr | functioncall ; -literal : numericliteral | StringLiteral ; -numericliteral : IntegerLiteral | DecimalLiteral | DoubleLiteral ; -varref : DOLLAR varname ; +predicate + : OB expr CB + ; + +primaryexpr + : literal + | varref + | parenthesizedexpr + | contextitemexpr + | functioncall + ; + +literal + : numericliteral + | StringLiteral + ; + +numericliteral + : IntegerLiteral + | DecimalLiteral + | DoubleLiteral + ; + +varref + : DOLLAR varname + ; + // [45] -varname : qname ; -parenthesizedexpr : OP expr? CP ; -contextitemexpr : D ; -functioncall : { this.IsFuncCall() }? qname OP (exprsingle ( COMMA exprsingle)*)? CP ; -singletype : atomictype QM? ; +varname + : qname + ; + +parenthesizedexpr + : OP expr? CP + ; + +contextitemexpr + : D + ; + +functioncall + : { this.IsFuncCall() }? qname OP (exprsingle ( COMMA exprsingle)*)? CP + ; + +singletype + : atomictype QM? + ; + // [50] -sequencetype : KW_EMPTY_SEQUENCE OP CP | itemtype occurrenceindicator? ; -occurrenceindicator : QM | STAR | PLUS ; -itemtype : kindtest | KW_ITEM OP CP | atomictype ; -atomictype : qname ; -kindtest : documenttest | elementtest | attributetest | schemaelementtest | schemaattributetest | pitest | commenttest | texttest | anykindtest ; +sequencetype + : KW_EMPTY_SEQUENCE OP CP + | itemtype occurrenceindicator? + ; + +occurrenceindicator + : QM + | STAR + | PLUS + ; + +itemtype + : kindtest + | KW_ITEM OP CP + | atomictype + ; + +atomictype + : qname + ; + +kindtest + : documenttest + | elementtest + | attributetest + | schemaelementtest + | schemaattributetest + | pitest + | commenttest + | texttest + | anykindtest + ; + // [55] -anykindtest : KW_NODE OP CP ; -documenttest : KW_DOCUMENT_NODE OP (elementtest | schemaelementtest)? CP ; -texttest : KW_TEXT OP CP ; -commenttest : KW_COMMENT OP CP ; -pitest : KW_PROCESSING_INSTRUCTION OP (NCName | StringLiteral)? CP ; +anykindtest + : KW_NODE OP CP + ; + +documenttest + : KW_DOCUMENT_NODE OP (elementtest | schemaelementtest)? CP + ; + +texttest + : KW_TEXT OP CP + ; + +commenttest + : KW_COMMENT OP CP + ; + +pitest + : KW_PROCESSING_INSTRUCTION OP (NCName | StringLiteral)? CP + ; + // [60] -attributetest : KW_ATTRIBUTE OP (attribnameorwildcard ( COMMA typename_)?)? CP ; -attribnameorwildcard : attributename | STAR ; -schemaattributetest : KW_SCHEMA_ATTRIBUTE OP attributedeclaration CP ; -attributedeclaration : attributename ; -elementtest : KW_ELEMENT OP (elementnameorwildcard ( COMMA typename_ QM?)?)? CP ; +attributetest + : KW_ATTRIBUTE OP (attribnameorwildcard ( COMMA typename_)?)? CP + ; + +attribnameorwildcard + : attributename + | STAR + ; + +schemaattributetest + : KW_SCHEMA_ATTRIBUTE OP attributedeclaration CP + ; + +attributedeclaration + : attributename + ; + +elementtest + : KW_ELEMENT OP (elementnameorwildcard ( COMMA typename_ QM?)?)? CP + ; + // [65] -elementnameorwildcard : elementname | STAR ; -schemaelementtest : KW_SCHEMA_ELEMENT OP elementdeclaration CP ; -elementdeclaration : elementname ; -attributename : qname ; -elementname : qname ; -// [70] -typename_ : qname ; +elementnameorwildcard + : elementname + | STAR + ; + +schemaelementtest + : KW_SCHEMA_ELEMENT OP elementdeclaration CP + ; +elementdeclaration + : elementname + ; + +attributename + : qname + ; + +elementname + : qname + ; + +// [70] +typename_ + : qname + ; // Error in the spec. EQName also includes acceptable keywords. -qname : QName | URIQualifiedName - | KW_ANCESTOR - | KW_ANCESTOR_OR_SELF - | KW_AND - | KW_ARRAY - | KW_AS - | KW_ATTRIBUTE - | KW_CAST - | KW_CASTABLE - | KW_CHILD - | KW_COMMENT - | KW_DESCENDANT - | KW_DESCENDANT_OR_SELF - | KW_DIV - | KW_DOCUMENT_NODE - | KW_ELEMENT - | KW_ELSE - | KW_EMPTY_SEQUENCE - | KW_EQ - | KW_EVERY - | KW_EXCEPT - | KW_FOLLOWING - | KW_FOLLOWING_SIBLING - | KW_FOR - | KW_FUNCTION - | KW_GE - | KW_GT - | KW_IDIV - | KW_IF - | KW_IN - | KW_INSTANCE - | KW_INTERSECT - | KW_IS - | KW_ITEM - | KW_LE - | KW_LET - | KW_LT - | KW_MAP - | KW_MOD - | KW_NAMESPACE - | KW_NAMESPACE_NODE - | KW_NE - | KW_NODE - | KW_OF - | KW_OR - | KW_PARENT - | KW_PRECEDING - | KW_PRECEDING_SIBLING - | KW_PROCESSING_INSTRUCTION - | KW_RETURN - | KW_SATISFIES - | KW_SCHEMA_ATTRIBUTE - | KW_SCHEMA_ELEMENT - | KW_SELF - | KW_SOME - | KW_TEXT - | KW_THEN - | KW_TREAT - | KW_UNION - ; +qname + : QName + | URIQualifiedName + | KW_ANCESTOR + | KW_ANCESTOR_OR_SELF + | KW_AND + | KW_ARRAY + | KW_AS + | KW_ATTRIBUTE + | KW_CAST + | KW_CASTABLE + | KW_CHILD + | KW_COMMENT + | KW_DESCENDANT + | KW_DESCENDANT_OR_SELF + | KW_DIV + | KW_DOCUMENT_NODE + | KW_ELEMENT + | KW_ELSE + | KW_EMPTY_SEQUENCE + | KW_EQ + | KW_EVERY + | KW_EXCEPT + | KW_FOLLOWING + | KW_FOLLOWING_SIBLING + | KW_FOR + | KW_FUNCTION + | KW_GE + | KW_GT + | KW_IDIV + | KW_IF + | KW_IN + | KW_INSTANCE + | KW_INTERSECT + | KW_IS + | KW_ITEM + | KW_LE + | KW_LET + | KW_LT + | KW_MAP + | KW_MOD + | KW_NAMESPACE + | KW_NAMESPACE_NODE + | KW_NE + | KW_NODE + | KW_OF + | KW_OR + | KW_PARENT + | KW_PRECEDING + | KW_PRECEDING_SIBLING + | KW_PROCESSING_INSTRUCTION + | KW_RETURN + | KW_SATISFIES + | KW_SCHEMA_ATTRIBUTE + | KW_SCHEMA_ELEMENT + | KW_SELF + | KW_SOME + | KW_TEXT + | KW_THEN + | KW_TREAT + | KW_UNION + ; // Not per spec. Specified for testing. -auxilary : (expr SEMI )+ EOF; \ No newline at end of file +auxilary + : (expr SEMI)+ EOF + ; \ No newline at end of file diff --git a/xpath/xpath31/XPath31Lexer.g4 b/xpath/xpath31/XPath31Lexer.g4 index 3a510cd0a8..a20a3b844f 100644 --- a/xpath/xpath31/XPath31Lexer.g4 +++ b/xpath/xpath31/XPath31Lexer.g4 @@ -5,167 +5,178 @@ // This is a faithful implementation of the XPath version 3.1 grammar // from the spec at https://www.w3.org/TR/2017/REC-xpath-31-20170321/ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar XPath31Lexer; -AT : '@' ; -BANG : '!' ; -CB : ']' ; -CC : '}' ; -CEQ : ':=' ; -COLON : ':' ; -COLONCOLON : '::' ; -COMMA : ',' ; -CP : ')' ; -CS : ':*' ; -D : '.' ; -DD : '..' ; -DOLLAR : '$' ; -EG : '=>' ; -EQ : '=' ; -GE : '>=' ; -GG : '>>' ; -GT : '>' ; -LE : '<=' ; -LL : '<<' ; -LT : '<' ; -MINUS : '-' ; -NE : '!=' ; -OB : '[' ; -OC : '{' ; -OP : '(' ; -P : '|' ; -PLUS : '+' ; -POUND : '#' ; -PP : '||' ; -QM : '?' ; -SC : '*:' ; -SLASH : '/' ; -SS : '//' ; -STAR : '*' ; +AT : '@'; +BANG : '!'; +CB : ']'; +CC : '}'; +CEQ : ':='; +COLON : ':'; +COLONCOLON : '::'; +COMMA : ','; +CP : ')'; +CS : ':*'; +D : '.'; +DD : '..'; +DOLLAR : '$'; +EG : '=>'; +EQ : '='; +GE : '>='; +GG : '>>'; +GT : '>'; +LE : '<='; +LL : '<<'; +LT : '<'; +MINUS : '-'; +NE : '!='; +OB : '['; +OC : '{'; +OP : '('; +P : '|'; +PLUS : '+'; +POUND : '#'; +PP : '||'; +QM : '?'; +SC : '*:'; +SLASH : '/'; +SS : '//'; +STAR : '*'; // KEYWORDS -KW_ANCESTOR : 'ancestor' ; -KW_ANCESTOR_OR_SELF : 'ancestor-or-self' ; -KW_AND : 'and' ; -KW_ARRAY : 'array' ; -KW_AS : 'as' ; -KW_ATTRIBUTE : 'attribute' ; -KW_CAST : 'cast' ; -KW_CASTABLE : 'castable' ; -KW_CHILD : 'child' ; -KW_COMMENT : 'comment' ; -KW_DESCENDANT : 'descendant' ; -KW_DESCENDANT_OR_SELF : 'descendant-or-self' ; -KW_DIV : 'div' ; -KW_DOCUMENT_NODE : 'document-node' ; -KW_ELEMENT : 'element' ; -KW_ELSE : 'else' ; -KW_EMPTY_SEQUENCE : 'empty-sequence' ; -KW_EQ : 'eq' ; -KW_EVERY : 'every' ; -KW_EXCEPT : 'except' ; -KW_FOLLOWING : 'following' ; -KW_FOLLOWING_SIBLING : 'following-sibling' ; -KW_FOR : 'for' ; -KW_FUNCTION : 'function' ; -KW_GE : 'ge' ; -KW_GT : 'gt' ; -KW_IDIV : 'idiv' ; -KW_IF : 'if' ; -KW_IN : 'in' ; -KW_INSTANCE : 'instance' ; -KW_INTERSECT : 'intersect' ; -KW_IS : 'is' ; -KW_ITEM : 'item' ; -KW_LE : 'le' ; -KW_LET : 'let' ; -KW_LT : 'lt' ; -KW_MAP : 'map' ; -KW_MOD : 'mod' ; -KW_NAMESPACE : 'namespace' ; -KW_NAMESPACE_NODE : 'namespace-node' ; -KW_NE : 'ne' ; -KW_NODE : 'node' ; -KW_OF : 'of' ; -KW_OR : 'or' ; -KW_PARENT : 'parent' ; -KW_PRECEDING : 'preceding' ; -KW_PRECEDING_SIBLING : 'preceding-sibling' ; -KW_PROCESSING_INSTRUCTION : 'processing-instruction' ; -KW_RETURN : 'return' ; -KW_SATISFIES : 'satisfies' ; -KW_SCHEMA_ATTRIBUTE : 'schema-attribute' ; -KW_SCHEMA_ELEMENT : 'schema-element' ; -KW_SELF : 'self' ; -KW_SOME : 'some' ; -KW_TEXT : 'text' ; -KW_THEN : 'then' ; -KW_TO : 'to' ; -KW_TREAT : 'treat' ; -KW_UNION : 'union' ; +KW_ANCESTOR : 'ancestor'; +KW_ANCESTOR_OR_SELF : 'ancestor-or-self'; +KW_AND : 'and'; +KW_ARRAY : 'array'; +KW_AS : 'as'; +KW_ATTRIBUTE : 'attribute'; +KW_CAST : 'cast'; +KW_CASTABLE : 'castable'; +KW_CHILD : 'child'; +KW_COMMENT : 'comment'; +KW_DESCENDANT : 'descendant'; +KW_DESCENDANT_OR_SELF : 'descendant-or-self'; +KW_DIV : 'div'; +KW_DOCUMENT_NODE : 'document-node'; +KW_ELEMENT : 'element'; +KW_ELSE : 'else'; +KW_EMPTY_SEQUENCE : 'empty-sequence'; +KW_EQ : 'eq'; +KW_EVERY : 'every'; +KW_EXCEPT : 'except'; +KW_FOLLOWING : 'following'; +KW_FOLLOWING_SIBLING : 'following-sibling'; +KW_FOR : 'for'; +KW_FUNCTION : 'function'; +KW_GE : 'ge'; +KW_GT : 'gt'; +KW_IDIV : 'idiv'; +KW_IF : 'if'; +KW_IN : 'in'; +KW_INSTANCE : 'instance'; +KW_INTERSECT : 'intersect'; +KW_IS : 'is'; +KW_ITEM : 'item'; +KW_LE : 'le'; +KW_LET : 'let'; +KW_LT : 'lt'; +KW_MAP : 'map'; +KW_MOD : 'mod'; +KW_NAMESPACE : 'namespace'; +KW_NAMESPACE_NODE : 'namespace-node'; +KW_NE : 'ne'; +KW_NODE : 'node'; +KW_OF : 'of'; +KW_OR : 'or'; +KW_PARENT : 'parent'; +KW_PRECEDING : 'preceding'; +KW_PRECEDING_SIBLING : 'preceding-sibling'; +KW_PROCESSING_INSTRUCTION : 'processing-instruction'; +KW_RETURN : 'return'; +KW_SATISFIES : 'satisfies'; +KW_SCHEMA_ATTRIBUTE : 'schema-attribute'; +KW_SCHEMA_ELEMENT : 'schema-element'; +KW_SELF : 'self'; +KW_SOME : 'some'; +KW_TEXT : 'text'; +KW_THEN : 'then'; +KW_TO : 'to'; +KW_TREAT : 'treat'; +KW_UNION : 'union'; // A.2.1. TERMINAL SYMBOLS // This isn't a complete list of tokens in the language. // Keywords and symbols are terminals. -IntegerLiteral : FragDigits ; -DecimalLiteral : '.' FragDigits | FragDigits '.' [0-9]* ; -DoubleLiteral : ('.' FragDigits | FragDigits ('.' [0-9]*)?) [eE] [+-]? FragDigits ; -StringLiteral : '"' (~["] | FragEscapeQuot)* '"' | '\'' (~['] | FragEscapeApos)* '\'' ; -URIQualifiedName : BracedURILiteral NCName ; -BracedURILiteral : 'Q' '{' [^{}]* '}' ; +IntegerLiteral : FragDigits; +DecimalLiteral : '.' FragDigits | FragDigits '.' [0-9]*; +DoubleLiteral : ('.' FragDigits | FragDigits ('.' [0-9]*)?) [eE] [+-]? FragDigits; +StringLiteral : '"' (~["] | FragEscapeQuot)* '"' | '\'' (~['] | FragEscapeApos)* '\''; +URIQualifiedName : BracedURILiteral NCName; +BracedURILiteral : 'Q' '{' [^{}]* '}'; // Error in spec: EscapeQuot and EscapeApos are not terminals! -fragment FragEscapeQuot : '""' ; +fragment FragEscapeQuot : '""'; fragment FragEscapeApos : '\'\''; // Error in spec: Comment isn't really a terminal, but an off-channel object. -Comment : '(:' (Comment | CommentContents)*? ':)' -> skip ; -QName : FragQName ; -NCName : FragmentNCName ; +Comment : '(:' (Comment | CommentContents)*? ':)' -> skip; +QName : FragQName; +NCName : FragmentNCName; // Error in spec: Char is not a terminal! -fragment Char : FragChar ; -fragment FragDigits : [0-9]+ ; -fragment CommentContents : Char ; +fragment Char : FragChar; +fragment FragDigits : [0-9]+; +fragment CommentContents : Char; // https://www.w3.org/TR/REC-xml-names/#NT-QName -fragment FragQName : FragPrefixedName | FragUnprefixedName ; -fragment FragPrefixedName : FragPrefix ':' FragLocalPart ; -fragment FragUnprefixedName : FragLocalPart ; -fragment FragPrefix : FragmentNCName ; -fragment FragLocalPart : FragmentNCName ; -fragment FragNCNameStartChar - : 'A'..'Z' - | '_' - | 'a'..'z' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - | '\u{10000}'..'\u{EFFFF}' - ; -fragment FragNCNameChar - : FragNCNameStartChar | '-' | '.' | '0'..'9' - | '\u00B7' | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; -fragment FragmentNCName : FragNCNameStartChar FragNCNameChar* ; +fragment FragQName : FragPrefixedName | FragUnprefixedName; +fragment FragPrefixedName : FragPrefix ':' FragLocalPart; +fragment FragUnprefixedName : FragLocalPart; +fragment FragPrefix : FragmentNCName; +fragment FragLocalPart : FragmentNCName; +fragment FragNCNameStartChar: + 'A' ..'Z' + | '_' + | 'a' ..'z' + | '\u00C0' ..'\u00D6' + | '\u00D8' ..'\u00F6' + | '\u00F8' ..'\u02FF' + | '\u0370' ..'\u037D' + | '\u037F' ..'\u1FFF' + | '\u200C' ..'\u200D' + | '\u2070' ..'\u218F' + | '\u2C00' ..'\u2FEF' + | '\u3001' ..'\uD7FF' + | '\uF900' ..'\uFDCF' + | '\uFDF0' ..'\uFFFD' + | '\u{10000}' ..'\u{EFFFF}' +; +fragment FragNCNameChar: + FragNCNameStartChar + | '-' + | '.' + | '0' ..'9' + | '\u00B7' + | '\u0300' ..'\u036F' + | '\u203F' ..'\u2040' +; +fragment FragmentNCName: FragNCNameStartChar FragNCNameChar*; // https://www.w3.org/TR/REC-xml/#NT-Char -fragment FragChar : '\u0009' | '\u000a' | '\u000d' - | '\u0020'..'\ud7ff' - | '\ue000'..'\ufffd' - | '\u{10000}'..'\u{10ffff}' - ; +fragment FragChar: + '\u0009' + | '\u000a' + | '\u000d' + | '\u0020' ..'\ud7ff' + | '\ue000' ..'\ufffd' + | '\u{10000}' ..'\u{10ffff}' +; // https://github.com/antlr/grammars-v4/blob/17d3db3fd6a8fc319a12176e0bb735b066ec0616/xpath/xpath31/XPath31.g4#L389 -Whitespace : ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip ; +Whitespace: ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip; // Not per spec. Specified for testing. -SEMI : ';' ; +SEMI: ';'; \ No newline at end of file diff --git a/xpath/xpath31/XPath31Parser.g4 b/xpath/xpath31/XPath31Parser.g4 index 7fa04e34f5..742bc6b456 100644 --- a/xpath/xpath31/XPath31Parser.g4 +++ b/xpath/xpath31/XPath31Parser.g4 @@ -5,206 +5,627 @@ // This is a faithful implementation of the XPath version 3.1 grammar // from the spec at https://www.w3.org/TR/2017/REC-xpath-31-20170321/ +// $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 XPath31Parser; -options { tokenVocab=XPath31Lexer; superClass=XPath31ParserBase; } +options { + tokenVocab = XPath31Lexer; + superClass = XPath31ParserBase; +} // [1] -xpath : expr EOF ; -paramlist : param ( COMMA param)* ; -param : DOLLAR eqname typedeclaration? ; -functionbody : enclosedexpr ; +xpath + : expr EOF + ; + +paramlist + : param (COMMA param)* + ; + +param + : DOLLAR eqname typedeclaration? + ; + +functionbody + : enclosedexpr + ; + // [5] -enclosedexpr : OC expr? CC ; -expr : exprsingle ( COMMA exprsingle)* ; -exprsingle : forexpr | letexpr | quantifiedexpr | ifexpr | orexpr ; -forexpr : simpleforclause KW_RETURN exprsingle ; -simpleforclause : KW_FOR simpleforbinding ( COMMA simpleforbinding)* ; +enclosedexpr + : OC expr? CC + ; + +expr + : exprsingle (COMMA exprsingle)* + ; + +exprsingle + : forexpr + | letexpr + | quantifiedexpr + | ifexpr + | orexpr + ; + +forexpr + : simpleforclause KW_RETURN exprsingle + ; + +simpleforclause + : KW_FOR simpleforbinding (COMMA simpleforbinding)* + ; + // [10] -simpleforbinding : DOLLAR varname KW_IN exprsingle ; -letexpr : simpleletclause KW_RETURN exprsingle ; -simpleletclause : KW_LET simpleletbinding ( COMMA simpleletbinding)* ; -simpleletbinding : DOLLAR varname CEQ exprsingle ; -quantifiedexpr : ( KW_SOME | KW_EVERY) DOLLAR varname KW_IN exprsingle ( COMMA DOLLAR varname KW_IN exprsingle)* KW_SATISFIES exprsingle ; +simpleforbinding + : DOLLAR varname KW_IN exprsingle + ; + +letexpr + : simpleletclause KW_RETURN exprsingle + ; + +simpleletclause + : KW_LET simpleletbinding (COMMA simpleletbinding)* + ; + +simpleletbinding + : DOLLAR varname CEQ exprsingle + ; + +quantifiedexpr + : (KW_SOME | KW_EVERY) DOLLAR varname KW_IN exprsingle (COMMA DOLLAR varname KW_IN exprsingle)* KW_SATISFIES exprsingle + ; + // [15] -ifexpr : KW_IF OP expr CP KW_THEN exprsingle KW_ELSE exprsingle ; -orexpr : andexpr ( KW_OR andexpr )* ; -andexpr : comparisonexpr ( KW_AND comparisonexpr )* ; -comparisonexpr : stringconcatexpr ( (valuecomp | generalcomp | nodecomp) stringconcatexpr )? ; -stringconcatexpr : rangeexpr ( PP rangeexpr )* ; +ifexpr + : KW_IF OP expr CP KW_THEN exprsingle KW_ELSE exprsingle + ; + +orexpr + : andexpr (KW_OR andexpr)* + ; + +andexpr + : comparisonexpr (KW_AND comparisonexpr)* + ; + +comparisonexpr + : stringconcatexpr ((valuecomp | generalcomp | nodecomp) stringconcatexpr)? + ; + +stringconcatexpr + : rangeexpr (PP rangeexpr)* + ; + // [20] -rangeexpr : additiveexpr ( KW_TO additiveexpr )? ; -additiveexpr : multiplicativeexpr ( (PLUS | MINUS) multiplicativeexpr )* ; -multiplicativeexpr : unionexpr ( (STAR | KW_DIV | KW_IDIV | KW_MOD) unionexpr )* ; -unionexpr : intersectexceptexpr ( (KW_UNION | P) intersectexceptexpr )* ; -intersectexceptexpr : instanceofexpr ( ( KW_INTERSECT | KW_EXCEPT) instanceofexpr )* ; +rangeexpr + : additiveexpr (KW_TO additiveexpr)? + ; + +additiveexpr + : multiplicativeexpr ((PLUS | MINUS) multiplicativeexpr)* + ; + +multiplicativeexpr + : unionexpr ((STAR | KW_DIV | KW_IDIV | KW_MOD) unionexpr)* + ; + +unionexpr + : intersectexceptexpr ((KW_UNION | P) intersectexceptexpr)* + ; + +intersectexceptexpr + : instanceofexpr (( KW_INTERSECT | KW_EXCEPT) instanceofexpr)* + ; + // [25] -instanceofexpr : treatexpr ( KW_INSTANCE KW_OF sequencetype )? ; -treatexpr : castableexpr ( KW_TREAT KW_AS sequencetype )? ; -castableexpr : castexpr ( KW_CASTABLE KW_AS singletype )? ; -castexpr : arrowexpr ( KW_CAST KW_AS singletype )? ; -arrowexpr : unaryexpr ( EG arrowfunctionspecifier argumentlist )* ; +instanceofexpr + : treatexpr (KW_INSTANCE KW_OF sequencetype)? + ; + +treatexpr + : castableexpr (KW_TREAT KW_AS sequencetype)? + ; + +castableexpr + : castexpr (KW_CASTABLE KW_AS singletype)? + ; + +castexpr + : arrowexpr (KW_CAST KW_AS singletype)? + ; + +arrowexpr + : unaryexpr (EG arrowfunctionspecifier argumentlist)* + ; + // [30] -unaryexpr : ( MINUS | PLUS)* valueexpr ; -valueexpr : simplemapexpr ; -generalcomp : EQ | NE | LT | LE | GT | GE ; -valuecomp : KW_EQ | KW_NE | KW_LT | KW_LE | KW_GT | KW_GE ; -nodecomp : KW_IS | LL | GG ; +unaryexpr + : (MINUS | PLUS)* valueexpr + ; + +valueexpr + : simplemapexpr + ; + +generalcomp + : EQ + | NE + | LT + | LE + | GT + | GE + ; + +valuecomp + : KW_EQ + | KW_NE + | KW_LT + | KW_LE + | KW_GT + | KW_GE + ; + +nodecomp + : KW_IS + | LL + | GG + ; + // [35] -simplemapexpr : pathexpr ( BANG pathexpr)* ; -pathexpr : SLASH relativepathexpr? | SS relativepathexpr | relativepathexpr ; -relativepathexpr : stepexpr (( SLASH | SS) stepexpr)* ; -stepexpr : postfixexpr | axisstep ; -axisstep : (reversestep | forwardstep) predicatelist ; +simplemapexpr + : pathexpr (BANG pathexpr)* + ; + +pathexpr + : SLASH relativepathexpr? + | SS relativepathexpr + | relativepathexpr + ; + +relativepathexpr + : stepexpr (( SLASH | SS) stepexpr)* + ; + +stepexpr + : postfixexpr + | axisstep + ; + +axisstep + : (reversestep | forwardstep) predicatelist + ; + // [40] -forwardstep : forwardaxis nodetest | abbrevforwardstep ; -forwardaxis : KW_CHILD COLONCOLON | KW_DESCENDANT COLONCOLON | KW_ATTRIBUTE COLONCOLON | KW_SELF COLONCOLON | KW_DESCENDANT_OR_SELF COLONCOLON | KW_FOLLOWING_SIBLING COLONCOLON | KW_FOLLOWING COLONCOLON | KW_NAMESPACE COLONCOLON ; -abbrevforwardstep : AT? nodetest ; -reversestep : reverseaxis nodetest | abbrevreversestep ; -reverseaxis : KW_PARENT COLONCOLON | KW_ANCESTOR COLONCOLON | KW_PRECEDING_SIBLING COLONCOLON | KW_PRECEDING COLONCOLON | KW_ANCESTOR_OR_SELF COLONCOLON ; +forwardstep + : forwardaxis nodetest + | abbrevforwardstep + ; + +forwardaxis + : KW_CHILD COLONCOLON + | KW_DESCENDANT COLONCOLON + | KW_ATTRIBUTE COLONCOLON + | KW_SELF COLONCOLON + | KW_DESCENDANT_OR_SELF COLONCOLON + | KW_FOLLOWING_SIBLING COLONCOLON + | KW_FOLLOWING COLONCOLON + | KW_NAMESPACE COLONCOLON + ; + +abbrevforwardstep + : AT? nodetest + ; + +reversestep + : reverseaxis nodetest + | abbrevreversestep + ; + +reverseaxis + : KW_PARENT COLONCOLON + | KW_ANCESTOR COLONCOLON + | KW_PRECEDING_SIBLING COLONCOLON + | KW_PRECEDING COLONCOLON + | KW_ANCESTOR_OR_SELF COLONCOLON + ; + // [45] -abbrevreversestep : DD ; -nodetest : kindtest | nametest ; -nametest : eqname | wildcard ; -wildcard : STAR | NCName CS | SC NCName | BracedURILiteral STAR ; -postfixexpr : primaryexpr (predicate | argumentlist | lookup)* ; +abbrevreversestep + : DD + ; + +nodetest + : kindtest + | nametest + ; + +nametest + : eqname + | wildcard + ; + +wildcard + : STAR + | NCName CS + | SC NCName + | BracedURILiteral STAR + ; + +postfixexpr + : primaryexpr (predicate | argumentlist | lookup)* + ; + // [50] -argumentlist : OP (argument ( COMMA argument)*)? CP ; -predicatelist : predicate* ; -predicate : OB expr CB ; -lookup : QM keyspecifier ; -keyspecifier : NCName | IntegerLiteral | parenthesizedexpr | STAR ; +argumentlist + : OP (argument ( COMMA argument)*)? CP + ; + +predicatelist + : predicate* + ; + +predicate + : OB expr CB + ; + +lookup + : QM keyspecifier + ; + +keyspecifier + : NCName + | IntegerLiteral + | parenthesizedexpr + | STAR + ; + // [55] -arrowfunctionspecifier : eqname | varref | parenthesizedexpr ; -primaryexpr : literal | varref | parenthesizedexpr | contextitemexpr | functioncall | functionitemexpr | mapconstructor | arrayconstructor | unarylookup ; -literal : numericliteral | StringLiteral ; -numericliteral : IntegerLiteral | DecimalLiteral | DoubleLiteral ; -varref : DOLLAR varname ; +arrowfunctionspecifier + : eqname + | varref + | parenthesizedexpr + ; + +primaryexpr + : literal + | varref + | parenthesizedexpr + | contextitemexpr + | functioncall + | functionitemexpr + | mapconstructor + | arrayconstructor + | unarylookup + ; + +literal + : numericliteral + | StringLiteral + ; + +numericliteral + : IntegerLiteral + | DecimalLiteral + | DoubleLiteral + ; + +varref + : DOLLAR varname + ; + // [60] -varname : eqname ; -parenthesizedexpr : OP expr? CP ; -contextitemexpr : D ; -functioncall : { this.IsFuncCall() }? eqname argumentlist ; -argument : exprsingle | argumentplaceholder ; +varname + : eqname + ; + +parenthesizedexpr + : OP expr? CP + ; + +contextitemexpr + : D + ; + +functioncall + : { this.IsFuncCall() }? eqname argumentlist + ; + +argument + : exprsingle + | argumentplaceholder + ; + // [65] -argumentplaceholder : QM ; -functionitemexpr : namedfunctionref | inlinefunctionexpr ; -namedfunctionref : eqname POUND IntegerLiteral /* xgc: reserved-function-names */; -inlinefunctionexpr : KW_FUNCTION OP paramlist? CP ( KW_AS sequencetype)? functionbody ; -mapconstructor : KW_MAP OC (mapconstructorentry ( COMMA mapconstructorentry)*)? CC ; +argumentplaceholder + : QM + ; + +functionitemexpr + : namedfunctionref + | inlinefunctionexpr + ; + +namedfunctionref + : eqname POUND IntegerLiteral /* xgc: reserved-function-names */ + ; + +inlinefunctionexpr + : KW_FUNCTION OP paramlist? CP (KW_AS sequencetype)? functionbody + ; + +mapconstructor + : KW_MAP OC (mapconstructorentry ( COMMA mapconstructorentry)*)? CC + ; + // [70] -mapconstructorentry : mapkeyexpr COLON mapvalueexpr ; -mapkeyexpr : exprsingle ; -mapvalueexpr : exprsingle ; -arrayconstructor : squarearrayconstructor | curlyarrayconstructor ; -squarearrayconstructor : OB (exprsingle ( COMMA exprsingle)*)? CB ; +mapconstructorentry + : mapkeyexpr COLON mapvalueexpr + ; + +mapkeyexpr + : exprsingle + ; + +mapvalueexpr + : exprsingle + ; + +arrayconstructor + : squarearrayconstructor + | curlyarrayconstructor + ; + +squarearrayconstructor + : OB (exprsingle ( COMMA exprsingle)*)? CB + ; + // [75] -curlyarrayconstructor : KW_ARRAY enclosedexpr ; -unarylookup : QM keyspecifier ; -singletype : simpletypename QM? ; -typedeclaration : KW_AS sequencetype ; -sequencetype : KW_EMPTY_SEQUENCE OP CP | itemtype occurrenceindicator? ; +curlyarrayconstructor + : KW_ARRAY enclosedexpr + ; + +unarylookup + : QM keyspecifier + ; + +singletype + : simpletypename QM? + ; + +typedeclaration + : KW_AS sequencetype + ; + +sequencetype + : KW_EMPTY_SEQUENCE OP CP + | itemtype occurrenceindicator? + ; + // [80] -occurrenceindicator : QM | STAR | PLUS ; -itemtype : kindtest | KW_ITEM OP CP | functiontest | maptest | arraytest | atomicoruniontype | parenthesizeditemtype ; -atomicoruniontype : eqname ; -kindtest : documenttest | elementtest | attributetest | schemaelementtest | schemaattributetest | pitest | commenttest | texttest | namespacenodetest | anykindtest ; -anykindtest : KW_NODE OP CP ; +occurrenceindicator + : QM + | STAR + | PLUS + ; + +itemtype + : kindtest + | KW_ITEM OP CP + | functiontest + | maptest + | arraytest + | atomicoruniontype + | parenthesizeditemtype + ; + +atomicoruniontype + : eqname + ; + +kindtest + : documenttest + | elementtest + | attributetest + | schemaelementtest + | schemaattributetest + | pitest + | commenttest + | texttest + | namespacenodetest + | anykindtest + ; + +anykindtest + : KW_NODE OP CP + ; + // [85] -documenttest : KW_DOCUMENT_NODE OP (elementtest | schemaelementtest)? CP ; -texttest : KW_TEXT OP CP ; -commenttest : KW_COMMENT OP CP ; -namespacenodetest : KW_NAMESPACE_NODE OP CP ; -pitest : KW_PROCESSING_INSTRUCTION OP (NCName | StringLiteral)? CP ; +documenttest + : KW_DOCUMENT_NODE OP (elementtest | schemaelementtest)? CP + ; + +texttest + : KW_TEXT OP CP + ; + +commenttest + : KW_COMMENT OP CP + ; + +namespacenodetest + : KW_NAMESPACE_NODE OP CP + ; + +pitest + : KW_PROCESSING_INSTRUCTION OP (NCName | StringLiteral)? CP + ; + // [90] -attributetest : KW_ATTRIBUTE OP (attribnameorwildcard ( COMMA typename_)?)? CP ; -attribnameorwildcard : attributename | STAR ; -schemaattributetest : KW_SCHEMA_ATTRIBUTE OP attributedeclaration CP ; -attributedeclaration : attributename ; -elementtest : KW_ELEMENT OP (elementnameorwildcard ( COMMA typename_ QM?)?)? CP ; +attributetest + : KW_ATTRIBUTE OP (attribnameorwildcard ( COMMA typename_)?)? CP + ; + +attribnameorwildcard + : attributename + | STAR + ; + +schemaattributetest + : KW_SCHEMA_ATTRIBUTE OP attributedeclaration CP + ; + +attributedeclaration + : attributename + ; + +elementtest + : KW_ELEMENT OP (elementnameorwildcard ( COMMA typename_ QM?)?)? CP + ; + // [95] -elementnameorwildcard : elementname | STAR ; -schemaelementtest : KW_SCHEMA_ELEMENT OP elementdeclaration CP ; -elementdeclaration : elementname ; -attributename : eqname ; -elementname : eqname ; +elementnameorwildcard + : elementname + | STAR + ; + +schemaelementtest + : KW_SCHEMA_ELEMENT OP elementdeclaration CP + ; + +elementdeclaration + : elementname + ; + +attributename + : eqname + ; + +elementname + : eqname + ; + // [100] -simpletypename : typename_ ; -typename_ : eqname ; -functiontest : anyfunctiontest | typedfunctiontest ; -anyfunctiontest : KW_FUNCTION OP STAR CP ; -typedfunctiontest : KW_FUNCTION OP (sequencetype ( COMMA sequencetype)*)? CP KW_AS sequencetype ; +simpletypename + : typename_ + ; + +typename_ + : eqname + ; + +functiontest + : anyfunctiontest + | typedfunctiontest + ; + +anyfunctiontest + : KW_FUNCTION OP STAR CP + ; + +typedfunctiontest + : KW_FUNCTION OP (sequencetype ( COMMA sequencetype)*)? CP KW_AS sequencetype + ; + // [105] -maptest : anymaptest | typedmaptest ; -anymaptest : KW_MAP OP STAR CP ; -typedmaptest : KW_MAP OP atomicoruniontype COMMA sequencetype CP ; -arraytest : anyarraytest | typedarraytest ; -anyarraytest : KW_ARRAY OP STAR CP ; +maptest + : anymaptest + | typedmaptest + ; + +anymaptest + : KW_MAP OP STAR CP + ; + +typedmaptest + : KW_MAP OP atomicoruniontype COMMA sequencetype CP + ; + +arraytest + : anyarraytest + | typedarraytest + ; + +anyarraytest + : KW_ARRAY OP STAR CP + ; + // [110] -typedarraytest : KW_ARRAY OP sequencetype CP ; -parenthesizeditemtype : OP itemtype CP ; +typedarraytest + : KW_ARRAY OP sequencetype CP + ; + +parenthesizeditemtype + : OP itemtype CP + ; // Error in the spec. EQName also includes acceptable keywords. -eqname : QName | URIQualifiedName - | KW_ANCESTOR - | KW_ANCESTOR_OR_SELF - | KW_AND - | KW_ARRAY - | KW_AS - | KW_ATTRIBUTE - | KW_CAST - | KW_CASTABLE - | KW_CHILD - | KW_COMMENT - | KW_DESCENDANT - | KW_DESCENDANT_OR_SELF - | KW_DIV - | KW_DOCUMENT_NODE - | KW_ELEMENT - | KW_ELSE - | KW_EMPTY_SEQUENCE - | KW_EQ - | KW_EVERY - | KW_EXCEPT - | KW_FOLLOWING - | KW_FOLLOWING_SIBLING - | KW_FOR - | KW_FUNCTION - | KW_GE - | KW_GT - | KW_IDIV - | KW_IF - | KW_IN - | KW_INSTANCE - | KW_INTERSECT - | KW_IS - | KW_ITEM - | KW_LE - | KW_LET - | KW_LT - | KW_MAP - | KW_MOD - | KW_NAMESPACE - | KW_NAMESPACE_NODE - | KW_NE - | KW_NODE - | KW_OF - | KW_OR - | KW_PARENT - | KW_PRECEDING - | KW_PRECEDING_SIBLING - | KW_PROCESSING_INSTRUCTION - | KW_RETURN - | KW_SATISFIES - | KW_SCHEMA_ATTRIBUTE - | KW_SCHEMA_ELEMENT - | KW_SELF - | KW_SOME - | KW_TEXT - | KW_THEN - | KW_TREAT - | KW_UNION - ; +eqname + : QName + | URIQualifiedName + | KW_ANCESTOR + | KW_ANCESTOR_OR_SELF + | KW_AND + | KW_ARRAY + | KW_AS + | KW_ATTRIBUTE + | KW_CAST + | KW_CASTABLE + | KW_CHILD + | KW_COMMENT + | KW_DESCENDANT + | KW_DESCENDANT_OR_SELF + | KW_DIV + | KW_DOCUMENT_NODE + | KW_ELEMENT + | KW_ELSE + | KW_EMPTY_SEQUENCE + | KW_EQ + | KW_EVERY + | KW_EXCEPT + | KW_FOLLOWING + | KW_FOLLOWING_SIBLING + | KW_FOR + | KW_FUNCTION + | KW_GE + | KW_GT + | KW_IDIV + | KW_IF + | KW_IN + | KW_INSTANCE + | KW_INTERSECT + | KW_IS + | KW_ITEM + | KW_LE + | KW_LET + | KW_LT + | KW_MAP + | KW_MOD + | KW_NAMESPACE + | KW_NAMESPACE_NODE + | KW_NE + | KW_NODE + | KW_OF + | KW_OR + | KW_PARENT + | KW_PRECEDING + | KW_PRECEDING_SIBLING + | KW_PROCESSING_INSTRUCTION + | KW_RETURN + | KW_SATISFIES + | KW_SCHEMA_ATTRIBUTE + | KW_SCHEMA_ELEMENT + | KW_SELF + | KW_SOME + | KW_TEXT + | KW_THEN + | KW_TREAT + | KW_UNION + ; // Not per spec. Specified for testing. -auxilary : (expr SEMI )+ EOF; +auxilary + : (expr SEMI)+ EOF + ; \ No newline at end of file diff --git a/xsd-regex/regexLexer.g4 b/xsd-regex/regexLexer.g4 index bb00c74d0d..a968b7fb72 100644 --- a/xsd-regex/regexLexer.g4 +++ b/xsd-regex/regexLexer.g4 @@ -35,109 +35,72 @@ * - we use separate lexer tokens to disambiguate positive and negative character groups * - XmlCharIncDash is removed in favor of DASH token, which is handled in parser */ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar regexLexer; -LPAREN : '(' - ; -RPAREN : ')' - ; -PIPE : '|' - ; -PLUS : '+' - ; -QUESTION : '?' - ; -STAR : '*' - ; -WildcardEsc : '.' - ; -Char : ~('.' | '\\' | '?' | '*' | '+' | '(' | ')' | '|' | '[' | ']') - ; +LPAREN : '('; +RPAREN : ')'; +PIPE : '|'; +PLUS : '+'; +QUESTION : '?'; +STAR : '*'; +WildcardEsc : '.'; +Char : ~('.' | '\\' | '?' | '*' | '+' | '(' | ')' | '|' | '[' | ']'); // Quantifier's quantity rule support -StartQuantity : '{' -> pushMode(QUANTITY) - ; +StartQuantity: '{' -> pushMode(QUANTITY); // Single Character Escape -SingleCharEsc : SINGLE_ESC - ; +SingleCharEsc: SINGLE_ESC; // Multi-Character Escape -MultiCharEsc : MULTI_ESC - ; +MultiCharEsc: MULTI_ESC; // Category Escape -CatEsc : CAT_ESC -> pushMode(CATEGORY) - ; -ComplEsc : COMPL_ESC -> pushMode(CATEGORY) - ; +CatEsc : CAT_ESC -> pushMode(CATEGORY); +ComplEsc : COMPL_ESC -> pushMode(CATEGORY); // Positive/Negative Character Group -NegCharGroup : '[^' -> pushMode(CHARGROUP) - ; -PosCharGroup : '[' -> pushMode(CHARGROUP) - ; +NegCharGroup : '[^' -> pushMode(CHARGROUP); +PosCharGroup : '[' -> pushMode(CHARGROUP); mode QUANTITY; -EndQuantity : '}' -> popMode - ; -QuantExact : [0-9]+ - ; -COMMA : ',' - ; +EndQuantity : '}' -> popMode; +QuantExact : [0-9]+; +COMMA : ','; mode CATEGORY; -EndCategory : '}' -> popMode - ; +EndCategory: '}' -> popMode; // Categories -IsCategory : Letters | Marks | Numbers | Punctuation | Separators | Symbols | Others - ; -Letters : 'L' [ultmo]? - ; -Marks : 'M' [nce]? - ; -Numbers : 'N' [dlo]? - ; -Punctuation : 'P' [cdseifo]? - ; -Separators : 'Z' [slp]? - ; -Symbols : 'S' [mcko]? - ; -Others : 'C' [cfon]? - ; +IsCategory : Letters | Marks | Numbers | Punctuation | Separators | Symbols | Others; +Letters : 'L' [ultmo]?; +Marks : 'M' [nce]?; +Numbers : 'N' [dlo]?; +Punctuation : 'P' [cdseifo]?; +Separators : 'Z' [slp]?; +Symbols : 'S' [mcko]?; +Others : 'C' [cfon]?; // Block Escape -IsBlock : 'Is' ([a-z0-9A-Z] | '-')+ - ; +IsBlock: 'Is' ([a-z0-9A-Z] | '-')+; mode CHARGROUP; -NestedSingleCharEsc : SINGLE_ESC - ; -NestedMultiCharEsc : MULTI_ESC - ; -NestedCatEsc : CAT_ESC -> pushMode(CATEGORY) - ; -NestedComplEsc : COMPL_ESC -> pushMode(CATEGORY) - ; -NestedNegCharGroup : '[^' -> pushMode(CHARGROUP) - ; -NestedPosCharGroup : '[' -> pushMode(CHARGROUP) - ; -EndCharGroup : ']' -> popMode - ; -DASH : '-' - ; -XmlChar : ~('-' | '[' | ']') - ; - -fragment CAT_ESC : '\\p{' - ; -fragment COMPL_ESC : '\\P{' - ; -fragment MULTI_ESC : '\\' [sSiIcCdDwW] - ; -fragment SINGLE_ESC : '\\' [nrt\\|.?*+(){}\u002D\u005B\u005D\u005E] - ; +NestedSingleCharEsc : SINGLE_ESC; +NestedMultiCharEsc : MULTI_ESC; +NestedCatEsc : CAT_ESC -> pushMode(CATEGORY); +NestedComplEsc : COMPL_ESC -> pushMode(CATEGORY); +NestedNegCharGroup : '[^' -> pushMode(CHARGROUP); +NestedPosCharGroup : '[' -> pushMode(CHARGROUP); +EndCharGroup : ']' -> popMode; +DASH : '-'; +XmlChar : ~('-' | '[' | ']'); +fragment CAT_ESC : '\\p{'; +fragment COMPL_ESC : '\\P{'; +fragment MULTI_ESC : '\\' [sSiIcCdDwW]; +fragment SINGLE_ESC : '\\' [nrt\\|.?*+(){}\u002D\u005B\u005D\u005E]; \ No newline at end of file diff --git a/xsd-regex/regexParser.g4 b/xsd-regex/regexParser.g4 index dfa3e419ed..3c53483c32 100644 --- a/xsd-regex/regexParser.g4 +++ b/xsd-regex/regexParser.g4 @@ -35,45 +35,75 @@ * This allows us to simplify processing, eliminating one level of nesting. It * also makes this rule consistent with XSD 1.1 definition. */ + +// $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 regexParser; -options { tokenVocab = regexLexer; } + +options { + tokenVocab = regexLexer; +} // Parser root context, ensures all input is matched -root: regExp EOF +root + : regExp EOF ; // Regular Expression -regExp : branch (PIPE branch)* +regExp + : branch (PIPE branch)* ; // Branch -branch : piece* +branch + : piece* ; // Piece -piece : atom quantifier? +piece + : atom quantifier? ; // Quantifier -quantifier : QUESTION | STAR | PLUS | StartQuantity quantity EndQuantity +quantifier + : QUESTION + | STAR + | PLUS + | StartQuantity quantity EndQuantity ; -quantity : quantRange | quantMin | QuantExact + +quantity + : quantRange + | quantMin + | QuantExact ; -quantRange : QuantExact COMMA QuantExact + +quantRange + : QuantExact COMMA QuantExact ; -quantMin : QuantExact COMMA + +quantMin + : QuantExact COMMA ; // Atom -atom : Char | charClass | (LPAREN regExp RPAREN) +atom + : Char + | charClass + | (LPAREN regExp RPAREN) ; // Character Class -charClass : charClassEsc | charClassExpr | WildcardEsc +charClass + : charClassEsc + | charClassExpr + | WildcardEsc ; // Character Class Expression -charClassExpr : (NegCharGroup | NestedNegCharGroup | PosCharGroup | NestedPosCharGroup) charGroup EndCharGroup +charClassExpr + : (NegCharGroup | NestedNegCharGroup | PosCharGroup | NestedPosCharGroup) charGroup EndCharGroup ; // Character Group @@ -81,33 +111,53 @@ charClassExpr : (NegCharGroup | NestedNegCharGroup | PosCharGroup | NestedPosCha // tail, we explicitly handle it here. ANTLR will consider the subrules in order and they completely // disambiguate use [a--[f]], [a-[f]], [a-], [a]. We have borrowed some of the clarification from // https://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/ to make this work -charGroup : posCharGroup? DASH DASH charClassExpr +charGroup + : posCharGroup? DASH DASH charClassExpr | posCharGroup DASH charClassExpr | posCharGroup DASH? | DASH ; // Positive Character Group -posCharGroup : DASH? (charRange | charClassEsc)+ +posCharGroup + : DASH? (charRange | charClassEsc)+ ; // Character Range, sans the DASH possibility -charRange : seRange | XmlChar +charRange + : seRange + | XmlChar ; -seRange : charOrEsc DASH charOrEsc + +seRange + : charOrEsc DASH charOrEsc ; -charOrEsc : XmlChar | SingleCharEsc + +charOrEsc + : XmlChar + | SingleCharEsc ; // Character Class Escape -charClassEsc : SingleCharEsc | NestedSingleCharEsc | MultiCharEsc | NestedMultiCharEsc | catEsc | complEsc +charClassEsc + : SingleCharEsc + | NestedSingleCharEsc + | MultiCharEsc + | NestedMultiCharEsc + | catEsc + | complEsc ; // Category Escape -catEsc : (CatEsc | NestedCatEsc) charProp EndCategory +catEsc + : (CatEsc | NestedCatEsc) charProp EndCategory ; -complEsc : (ComplEsc | NestedComplEsc) charProp EndCategory - ; -charProp : IsCategory | IsBlock + +complEsc + : (ComplEsc | NestedComplEsc) charProp EndCategory ; +charProp + : IsCategory + | IsBlock + ; \ No newline at end of file diff --git a/xyz/xyz.g4 b/xyz/xyz.g4 index d77cae3485..b017082402 100644 --- a/xyz/xyz.g4 +++ b/xyz/xyz.g4 @@ -29,49 +29,52 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + grammar xyz; file_ - : header body EOF - ; + : header body EOF + ; header - : count desc EOL - ; + : count desc EOL + ; desc - : .*? - ; + : .*? + ; body - : atom+ - ; + : atom+ + ; count - : NUM EOL - ; + : NUM EOL + ; atom - : ATOMNAME NUM NUM NUM EOL - ; + : ATOMNAME NUM NUM NUM EOL + ; ATOMNAME - : [A-Za-z]+ - ; + : [A-Za-z]+ + ; NUM - : ('+' | '-')? DIGIT+ ('.' DIGIT+)? - ; + : ('+' | '-')? DIGIT+ ('.' DIGIT+)? + ; fragment DIGIT - : [0-9] - ; + : [0-9] + ; EOL - : [\r\n]+ - ; + : [\r\n]+ + ; WS - : [ \t]+ -> skip - ; - + : [ \t]+ -> skip + ; \ No newline at end of file diff --git a/yara/YaraLexer.g4 b/yara/YaraLexer.g4 index db60d99ecd..2da550d28a 100644 --- a/yara/YaraLexer.g4 +++ b/yara/YaraLexer.g4 @@ -21,182 +21,175 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + lexer grammar YaraLexer; -ALL : 'all'; -AND : 'and'; -ANY : 'any'; -AT : 'at'; -CONDITION : 'condition' -> mode(DEFAULT_MODE); -CONTAINS : 'contains'; -ENDSWITH : 'endswith'; -ENTRYPOINT : 'entrypoint'; -FALSE : 'false'; -FILESIZE : 'filesize'; -FOR : 'for'; -GLOBAL : 'global'; -IMPORT : 'import'; -ICONTAINS : 'icontains'; -IENDSWITH : 'iendswith'; -IEQUALS : 'iequals'; -IN : 'in'; -INCLUDE : 'include'; -INT16 : 'int16'; -INT16BE : 'int16be'; -INT32 : 'int32'; -INT32BE : 'int32be'; -INT8 : 'int8'; -INT8BE : 'int8be'; -ISTARTSWITH : 'istartswith'; -MATCHES : 'matches'; -META : 'meta' ; -NONE : 'none'; -NOT : 'not'; -OF : 'of'; -OR : 'or'; -PRIVATE : 'private'; -RULE : 'rule'; -STARTSWITH : 'startswith'; -STRINGS : 'strings' -> mode(STR); -THEM : 'them'; -TRUE : 'true'; -UINT16 : 'uint16'; -UINT16BE : 'uint16be'; -UINT32 : 'uint32'; -UINT32BE : 'uint32be'; -UINT8 : 'uint8'; -UINT8BE : 'uint8be'; -DEFINED : 'defined'; - -LP : '('; -RP : ')'; -LCB : '{'; -RCB : '}'; -LSB : '['; -RSB : ']'; -SLASH : '/'; -PIPE : '|'; -QM : '?'; -EM : '!'; -AT_ : '@'; -COLON : ':'; -ASSIGN : '='; -MINUS : '-'; -PLUS : '+'; -STAR : '*'; -DIV : '\\'; -MOD : '%'; -BITAND : '&'; -BITXOR : '^'; -BITNOT : '~'; -LT : '<'; -LE : '<='; -GT : '>'; -GE : '>='; -EQUAL : '=='; -NE : '!='; -DOT : '.'; -LSHIFT : '<<'; -RSHIFT : '>>'; -RANGE : '..'; -COMMA : ','; -DOLLAR : '$'; -HASH : '#'; - -WHITE_SPACE: [ \t\r\n]+ -> channel(HIDDEN); - -BLOCK_COMMENT: '/*' (BLOCK_COMMENT | .)*? '*/' -> channel(HIDDEN); -LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); - -DECIMAL_LITERAL : DEC_DIGIT+; -HEX_STR : BYTE_MASKED+; -HEX_LITERAL : '0x' HEX_DIGIT+; -STRING_ID : '$' ALPHA_NUM_UNDERSCORE*; -ID : [a-zA-Z_] [a-zA-Z0-9_]* '*'?; -STRING_WILD : '$' ALPHA_NUM_UNDERSCORE* '*'; - -DOUBLE_QUOTE_STR : '"' (~'"' | ESCAPE_SEQUENCE)+ '"'; -COUNT_REF : '#' ID; -OFFSET_REF : '@' ID; -LENGTH_REF : '!' ID; -SIZE_LITERAL : DEC_DIGIT+ ('MB' | 'KB')?; -BYTE_MASKED : HEX_DIGIT_MASKED HEX_DIGIT_MASKED; - -fragment ALPHA_NUM_UNDERSCORE - : [a-zA-Z0-9_] - ; - -fragment ESCAPE_SEQUENCE - : '\\' [tnr"\\] - | '\\' 'x' HEX_DIGIT HEX_DIGIT - ; - -fragment HEX_DIGIT - : [a-fA-F0-9] - ; - -fragment HEX_DIGIT_MASKED - : [a-fA-F0-9?] - ; - -fragment DEC_DIGIT - : [0-9] - ; +ALL : 'all'; +AND : 'and'; +ANY : 'any'; +AT : 'at'; +CONDITION : 'condition' -> mode(DEFAULT_MODE); +CONTAINS : 'contains'; +ENDSWITH : 'endswith'; +ENTRYPOINT : 'entrypoint'; +FALSE : 'false'; +FILESIZE : 'filesize'; +FOR : 'for'; +GLOBAL : 'global'; +IMPORT : 'import'; +ICONTAINS : 'icontains'; +IENDSWITH : 'iendswith'; +IEQUALS : 'iequals'; +IN : 'in'; +INCLUDE : 'include'; +INT16 : 'int16'; +INT16BE : 'int16be'; +INT32 : 'int32'; +INT32BE : 'int32be'; +INT8 : 'int8'; +INT8BE : 'int8be'; +ISTARTSWITH : 'istartswith'; +MATCHES : 'matches'; +META : 'meta'; +NONE : 'none'; +NOT : 'not'; +OF : 'of'; +OR : 'or'; +PRIVATE : 'private'; +RULE : 'rule'; +STARTSWITH : 'startswith'; +STRINGS : 'strings' -> mode(STR); +THEM : 'them'; +TRUE : 'true'; +UINT16 : 'uint16'; +UINT16BE : 'uint16be'; +UINT32 : 'uint32'; +UINT32BE : 'uint32be'; +UINT8 : 'uint8'; +UINT8BE : 'uint8be'; +DEFINED : 'defined'; + +LP : '('; +RP : ')'; +LCB : '{'; +RCB : '}'; +LSB : '['; +RSB : ']'; +SLASH : '/'; +PIPE : '|'; +QM : '?'; +EM : '!'; +AT_ : '@'; +COLON : ':'; +ASSIGN : '='; +MINUS : '-'; +PLUS : '+'; +STAR : '*'; +DIV : '\\'; +MOD : '%'; +BITAND : '&'; +BITXOR : '^'; +BITNOT : '~'; +LT : '<'; +LE : '<='; +GT : '>'; +GE : '>='; +EQUAL : '=='; +NE : '!='; +DOT : '.'; +LSHIFT : '<<'; +RSHIFT : '>>'; +RANGE : '..'; +COMMA : ','; +DOLLAR : '$'; +HASH : '#'; + +WHITE_SPACE: [ \t\r\n]+ -> channel(HIDDEN); + +BLOCK_COMMENT : '/*' (BLOCK_COMMENT | .)*? '*/' -> channel(HIDDEN); +LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN); + +DECIMAL_LITERAL : DEC_DIGIT+; +HEX_STR : BYTE_MASKED+; +HEX_LITERAL : '0x' HEX_DIGIT+; +STRING_ID : '$' ALPHA_NUM_UNDERSCORE*; +ID : [a-zA-Z_] [a-zA-Z0-9_]* '*'?; +STRING_WILD : '$' ALPHA_NUM_UNDERSCORE* '*'; + +DOUBLE_QUOTE_STR : '"' (~'"' | ESCAPE_SEQUENCE)+ '"'; +COUNT_REF : '#' ID; +OFFSET_REF : '@' ID; +LENGTH_REF : '!' ID; +SIZE_LITERAL : DEC_DIGIT+ ('MB' | 'KB')?; +BYTE_MASKED : HEX_DIGIT_MASKED HEX_DIGIT_MASKED; + +fragment ALPHA_NUM_UNDERSCORE: [a-zA-Z0-9_]; + +fragment ESCAPE_SEQUENCE: '\\' [tnr"\\] | '\\' 'x' HEX_DIGIT HEX_DIGIT; + +fragment HEX_DIGIT: [a-fA-F0-9]; + +fragment HEX_DIGIT_MASKED: [a-fA-F0-9?]; + +fragment DEC_DIGIT: [0-9]; mode STR; -WS_S : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); -BLOCK_COMMENT_S : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); -LINE_COMMENT_S : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); - -LP_S : LP -> type(LP); -RP_S : RP -> type(RP); - -ASCII : 'ascii'; -BASE64 : 'base64'; -BASE64WIDE : 'base64wide'; -FULLWORD : 'fullword'; -NOCASE : 'nocase'; -PRIVATE_S : PRIVATE -> type(PRIVATE); -WIDE : 'wide'; -XOR : 'xor'; - -COLON_S : COLON -> type(COLON); -ASSIGN_S : '='; -LCB_S : '{' -> mode(WILD); -STRING_ID_S : STRING_ID -> type(STRING_ID); -DOUBLE_QUOTE_STR_S : DOUBLE_QUOTE_STR -> type(DOUBLE_QUOTE_STR); -REGEX_STR : '/' (~'/' | '\\/')+ '/' 'i'? 's'?; -CONDITION_S : CONDITION -> type(CONDITION), mode(DEFAULT_MODE); +WS_S : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); +BLOCK_COMMENT_S : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); +LINE_COMMENT_S : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); + +LP_S : LP -> type(LP); +RP_S : RP -> type(RP); + +ASCII : 'ascii'; +BASE64 : 'base64'; +BASE64WIDE : 'base64wide'; +FULLWORD : 'fullword'; +NOCASE : 'nocase'; +PRIVATE_S : PRIVATE -> type(PRIVATE); +WIDE : 'wide'; +XOR : 'xor'; + +COLON_S : COLON -> type(COLON); +ASSIGN_S : '='; +LCB_S : '{' -> mode(WILD); +STRING_ID_S : STRING_ID -> type(STRING_ID); +DOUBLE_QUOTE_STR_S : DOUBLE_QUOTE_STR -> type(DOUBLE_QUOTE_STR); +REGEX_STR : '/' (~'/' | '\\/')+ '/' 'i'? 's'?; +CONDITION_S : CONDITION -> type(CONDITION), mode(DEFAULT_MODE); mode WILD; -WS_W : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); -BLOCK_COMMENT_W : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); -LINE_COMMENT_W : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); +WS_W : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); +BLOCK_COMMENT_W : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); +LINE_COMMENT_W : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); -DASH_W : MINUS -> type(MINUS); -HEX_W : HEX_STR -> type(HEX_STR); -LSB_W : LSB -> type(LSB), mode(JUMP); -LRB_W : LP -> type(LP), mode(ALT); -RCB_W : RCB -> type(RCB), mode(STR); +DASH_W : MINUS -> type(MINUS); +HEX_W : HEX_STR -> type(HEX_STR); +LSB_W : LSB -> type(LSB), mode(JUMP); +LRB_W : LP -> type(LP), mode(ALT); +RCB_W : RCB -> type(RCB), mode(STR); mode JUMP; -WS_J : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); -BLOCK_COMMENT_J : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); -LINE_COMMENT_J : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); +WS_J : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); +BLOCK_COMMENT_J : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); +LINE_COMMENT_J : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); -DEC : [0-9]+; -DASH_J : MINUS -> type(MINUS); -RSB_J : RSB -> type(RSB), mode(WILD); +DEC : [0-9]+; +DASH_J : MINUS -> type(MINUS); +RSB_J : RSB -> type(RSB), mode(WILD); mode ALT; -WS_A : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); -BLOCK_COMMENT_A : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); -LINE_COMMENT_A : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); +WS_A : WHITE_SPACE -> type(WHITE_SPACE), channel(HIDDEN); +BLOCK_COMMENT_A : BLOCK_COMMENT -> type(BLOCK_COMMENT), channel(HIDDEN); +LINE_COMMENT_A : LINE_COMMENT -> type(LINE_COMMENT), channel(HIDDEN); -HEX_A : HEX_STR -> type(HEX_STR); -PIPE_A : PIPE -> type(PIPE); -RRB_A : RP -> type(RP), mode(WILD); +HEX_A : HEX_STR -> type(HEX_STR); +PIPE_A : PIPE -> type(PIPE); +RRB_A : RP -> type(RP), mode(WILD); \ No newline at end of file diff --git a/yara/YaraParser.g4 b/yara/YaraParser.g4 index 2babd0dbc4..47544d3c6c 100644 --- a/yara/YaraParser.g4 +++ b/yara/YaraParser.g4 @@ -21,9 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +// $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 YaraParser; -options { tokenVocab=YaraLexer; } +options { + tokenVocab = YaraLexer; +} startRule : decl+ EOF @@ -44,12 +49,7 @@ include_decl ; rule_decl - : rule_modifier* RULE id_ tags? - LCB - meta_section? - strings_section? - condition_section - RCB + : rule_modifier* RULE id_ tags? LCB meta_section? strings_section? condition_section RCB ; rule_modifier @@ -84,15 +84,13 @@ bool_expr expr : expr LSB expr RSB | expr DOT expr - | ('-'|'~') expr + | ('-' | '~') expr | fn4 LP expr RP - - | expr ('*'|'\\'|'%') expr - | expr ('+'|'-') expr - | expr ('<<'|'>>') expr - | expr ('&'|'^'|'|') expr - | expr ('<'|'<='|'>'|'>='|'=='|'!=') expr - + | expr ('*' | '\\' | '%') expr + | expr ('+' | '-') expr + | expr ('<<' | '>>') expr + | expr ('&' | '^' | '|') expr + | expr ('<' | '<=' | '>' | '>=' | '==' | '!=') expr | (number | ALL | ANY | NONE) OF (string_set | LP ID RP | THEM) (IN range)? // number could be an expr | (COUNT_REF | STRING_ID) IN range | (number | ALL | ANY | NONE) id_? IN range @@ -105,7 +103,10 @@ expr | LP expr RP | literal | pos_fn - | '$' | '#' | '@' | '!' + | '$' + | '#' + | '@' + | '!' ; literal @@ -165,17 +166,16 @@ range ; true_false - : TRUE | FALSE + : TRUE + | FALSE ; strings_section - : STRINGS COLON - string_def+ + : STRINGS COLON string_def+ ; meta_section - : META COLON - meta_def+ + : META COLON meta_def+ ; string_def @@ -234,4 +234,4 @@ string number : DECIMAL_LITERAL - ; + ; \ No newline at end of file diff --git a/z/ZLexer.g4 b/z/ZLexer.g4 index aeb480fa4b..804604d2d3 100644 --- a/z/ZLexer.g4 +++ b/z/ZLexer.g4 @@ -26,6 +26,9 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true lexer grammar ZLexer; //import classify; @@ -62,217 +65,201 @@ lexer grammar ZLexer; // https://www.iso.org/obp/ui/#iso:std:iso-iec:13568:ed-1:v1:cor:1:v1:en // 6.4.4.4 Box characters -ZED: '\u2500' -> mode(Z); // In line 6, replace "| 0000 2028 LINE SEPARATOR" by "— 0000 2500 BOX DRAWINGS LIGHT HORIZONTAL". -SCH: '\u250C' -> mode(Z); // ┌ -AX: '\u2577' -> mode(Z); // ╷ -TEXT: ~[\u2500\u250C\u2577]+ -> channel(HIDDEN); +ZED: + '\u2500' -> mode(Z) +; // In line 6, replace "| 0000 2028 LINE SEPARATOR" by "— 0000 2500 BOX DRAWINGS LIGHT HORIZONTAL". +SCH : '\u250C' -> mode(Z); // ┌ +AX : '\u2577' -> mode(Z); // ╷ +TEXT : ~[\u2500\u250C\u2577]+ -> channel(HIDDEN); mode Z; // 7.5 Newlines -NUMERAL : DECIMAL+ ; -STROKE : (STROKECHAR | SOUTH_EAST_ARROW DECIMAL NORTH_WEST_ARROW); +NUMERAL : DECIMAL+; +STROKE : (STROKECHAR | SOUTH_EAST_ARROW DECIMAL NORTH_WEST_ARROW); // 6.4.4.3 Bracket characters -LEFT_PARENTHESIS: '\u0028'; // ( -RIGHT_PARENTHESIS: '\u0029'; // ) -LEFT_SQUARE_BRACKET: '\u005B'; // [ -RIGHT_SQUARE_BRACKET: '\u005D'; // ] -LEFT_CURLY_BRACKET: '\u007B'; // { -RIGHT_CURLY_BRACKET: '\u007D'; // } -LEFT_BINDING_BRACKET: '\u2989'; // ⦉ -RIGHT_BINDING_BRACKET: '\u298A'; // ⦊ -LEFT_DOUBLE_ANGLE_BRACKET: '\u27EA'; //《 In line 10, replace "0000 300A LEFT DOUBLE ANGLE BRACKET" by "0000 27EA MATHEMATICAL LEFT DOUBLE ANGLE BRACKET". -RIGHT_DOUBLE_ANGLE_BRACKET: '\u27EB'; // 》In line 11, replace "0000 300B RIGHT DOUBLE ANGLE BRACKET" by "0000 27EB MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET". +LEFT_PARENTHESIS : '\u0028'; // ( +RIGHT_PARENTHESIS : '\u0029'; // ) +LEFT_SQUARE_BRACKET : '\u005B'; // [ +RIGHT_SQUARE_BRACKET : '\u005D'; // ] +LEFT_CURLY_BRACKET : '\u007B'; // { +RIGHT_CURLY_BRACKET : '\u007D'; // } +LEFT_BINDING_BRACKET : '\u2989'; // ⦉ +RIGHT_BINDING_BRACKET : '\u298A'; // ⦊ +LEFT_DOUBLE_ANGLE_BRACKET: + '\u27EA' +; //《 In line 10, replace "0000 300A LEFT DOUBLE ANGLE BRACKET" by "0000 27EA MATHEMATICAL LEFT DOUBLE ANGLE BRACKET". +RIGHT_DOUBLE_ANGLE_BRACKET: + '\u27EB' +; // 》In line 11, replace "0000 300B RIGHT DOUBLE ANGLE BRACKET" by "0000 27EB MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET". // 6.4.4.4 Box characters GEN: '\u2550'; // ═ -END: '\u2514' -> mode(DEFAULT_MODE); // In line 10, replace "(new line) 0000 2029 PARAGRAPH SEPARATOR" by "| 0000 2514 BOX DRAWINGS LIGHT UP AND RIGHT". +END: + '\u2514' -> mode(DEFAULT_MODE) +; // In line 10, replace "(new line) 0000 2029 PARAGRAPH SEPARATOR" by "| 0000 2514 BOX DRAWINGS LIGHT UP AND RIGHT". // 6.4.4.5 Other SPECIAL characters -NLCHAR: '\u2028' -> type(NL); // In line 2, replace "0000 000A LINE FEED" by "0000 2028 LINE SEPARATOR". +NLCHAR: + '\u2028' -> type(NL) +; // In line 2, replace "0000 000A LINE FEED" by "0000 2028 LINE SEPARATOR". //SPACE: '\u0020'; // ' ' -WS: [\p{Zs}]+ -> skip; // All Unicode characters with General Category Zs shall be treated as SPACE. -NL: [\r\n]+ {shouldNL(_input.LA(1))}?; +WS: + [\p{Zs}]+ -> skip +; // All Unicode characters with General Category Zs shall be treated as SPACE. +NL: [\r\n]+ {shouldNL(_input.LA(1))}?; //NL: [\r\n]+ -> channel(HIDDEN); -IGNORE_NL: [\r\n]+ -> skip; - +IGNORE_NL: [\r\n]+ -> skip; // 7.4.2 Alphabetic keywords -ELSE: 'else'; -FALSE: 'false'; -FUNCTION: 'function'; -GENERIC : 'generic'; -IF : 'if'; -LEFTASSOC : 'leftassoc'; -LET : 'let'; -POWERSET : '\u2119'; // ℙ -PARENTS : 'parents'; -PRE_KEY : 'pre'; -RELATION : 'relation'; +ELSE : 'else'; +FALSE : 'false'; +FUNCTION : 'function'; +GENERIC : 'generic'; +IF : 'if'; +LEFTASSOC : 'leftassoc'; +LET : 'let'; +POWERSET : '\u2119'; // ℙ +PARENTS : 'parents'; +PRE_KEY : 'pre'; +RELATION : 'relation'; RIGHTASSOC : 'rightassoc'; -SECTION : 'section'; -THEN : 'then'; -TRUE : 'true'; +SECTION : 'section'; +THEN : 'then'; +TRUE : 'true'; // 7.4.3 Symbolic keywords -COLON : ':'; -DEFINE_EQUAL : '=='; -COMMA : ','; -FREE_EQUALS : '::='; -VERTICAL_LINE : '|'; -AMPERSAND : '\u0026'; // & +COLON : ':'; +DEFINE_EQUAL : '=='; +COMMA : ','; +FREE_EQUALS : '::='; +VERTICAL_LINE : '|'; +AMPERSAND : '\u0026'; // & REVERSE_SOLIDUS : '\u005C'; // \ -SOLIDUS: '/'; -FULL_STOP : '.'; // SELECT -SEMICOLON : ';'; -ARGUMENT: '_'; -LIST: ',,'; -EQUALS_SIGN: '='; - -CONJECTURE : '\u22A2' QUESTION_MARK; // ⊢? -FOR_ALL : '\u2200'; // ∀ -SPOT : '\u2981'; // ⦁ -THERE_EXISTS : '\u2203'; // ∃ -UNIQUE_EXISTS : THERE_EXISTS SOUTH_EAST_ARROW '1' NORTH_WEST_ARROW; // ∃0 -LEFT_RIGHT_DOUBLE_ARROW : '\u21D4'; // ⇔ -RIGHTWARDS_DOUBLE_ARROW : '\u21D2'; // ⇒ -LOGICAL_OR : '\u2228'; // ∨ -LOGICAL_AND : '\u2227'; // ∧ -NOT_SIGN : '\u00AC'; // ¬ -ELEMENT_OF : '\u2208'; // ∈ -SCHEMA_PROJECTION : '\u2A21'; // ⨡ -MULTIPLICATION_SIGN : '\u00D7'; // x -GREEK_SMALL_LETTER_THETA : '\u03B8'; // θ -GREEK_SMALL_LETTER_LAMBDA : '\u03BB'; // λ -GREEK_SMALL_LETTER_MU : '\u03BC'; // μ -SCHEMA_COMPOSITION : '\u2A1F'; // ⨟ -SCHEMA_PIPING : '\u2A20'; // ⨠ - -NAME - : WORD STROKE* - ; - +SOLIDUS : '/'; +FULL_STOP : '.'; // SELECT +SEMICOLON : ';'; +ARGUMENT : '_'; +LIST : ',,'; +EQUALS_SIGN : '='; + +CONJECTURE : '\u22A2' QUESTION_MARK; // ⊢? +FOR_ALL : '\u2200'; // ∀ +SPOT : '\u2981'; // ⦁ +THERE_EXISTS : '\u2203'; // ∃ +UNIQUE_EXISTS : THERE_EXISTS SOUTH_EAST_ARROW '1' NORTH_WEST_ARROW; // ∃0 +LEFT_RIGHT_DOUBLE_ARROW : '\u21D4'; // ⇔ +RIGHTWARDS_DOUBLE_ARROW : '\u21D2'; // ⇒ +LOGICAL_OR : '\u2228'; // ∨ +LOGICAL_AND : '\u2227'; // ∧ +NOT_SIGN : '\u00AC'; // ¬ +ELEMENT_OF : '\u2208'; // ∈ +SCHEMA_PROJECTION : '\u2A21'; // ⨡ +MULTIPLICATION_SIGN : '\u00D7'; // x +GREEK_SMALL_LETTER_THETA : '\u03B8'; // θ +GREEK_SMALL_LETTER_LAMBDA : '\u03BB'; // λ +GREEK_SMALL_LETTER_MU : '\u03BC'; // μ +SCHEMA_COMPOSITION : '\u2A1F'; // ⨟ +SCHEMA_PIPING : '\u2A20'; // ⨠ + +NAME: WORD STROKE*; + // 7.2 Formal definition of context free lexis // modified to fit section 7.4.1 -fragment -WORD - : WORDPART+ - | (LETTER | NONDECIMAL) ALPHASTR WORDPART* - | SYMBOL SYMBOLSTR WORDPART* - | PUNCT+ EQUALS_SIGN? - ; - +fragment WORD: + WORDPART+ + | (LETTER | NONDECIMAL) ALPHASTR WORDPART* + | SYMBOL SYMBOLSTR WORDPART* + | PUNCT+ EQUALS_SIGN? +; + fragment //WORDPART // : ALPHASTR // | SYMBOLSTR // | SOUTH_EAST_ARROW WORDPART*? NORTH_WEST_ARROW // nesting allowed (but should it be?) -// | NORTH_EAST_ARROW WORDPART*? SOUTH_WEST_ARROW // nesting allowed (but should it be?) -// ; - -WORDGLUE : SOUTH_EAST_ARROW | NORTH_WEST_ARROW | NORTH_EAST_ARROW | SOUTH_WEST_ARROW | '_'; -WORDPART : WORDGLUE (ALPHASTR | SYMBOLSTR); - -fragment -ALPHASTR - : (LETTER | DIGIT)* - ; - -fragment -SYMBOLSTR - : SYMBOL* - ; - -fragment -DIGIT - : DECIMAL - | NONDECIMAL // any other UCS characters with General Category N* except Nd - ; - -fragment -DECIMAL - : [\p{Nd}] // Decimal number - ; - -fragment -NONDECIMAL - : [\p{Nl}] // Letter number +WORDGLUE: // | NORTH_EAST_ARROW WORDPART*? SOUTH_WEST_ARROW // nesting allowed (but should it be?) + SOUTH_EAST_ARROW + | NORTH_WEST_ARROW + | NORTH_EAST_ARROW + | SOUTH_WEST_ARROW + | '_' +; // ; +WORDPART: WORDGLUE (ALPHASTR | SYMBOLSTR); + +fragment ALPHASTR: (LETTER | DIGIT)*; + +fragment SYMBOLSTR: SYMBOL*; + +fragment DIGIT: + DECIMAL + | NONDECIMAL // any other UCS characters with General Category N* except Nd +; + +fragment DECIMAL: + [\p{Nd}] // Decimal number +; + +fragment NONDECIMAL: + [\p{Nl}] // Letter number | [\p{No}] // Other number - ; - -fragment -LETTER - : LATIN - | GREEK - | OTHERLETTER - | OTHER_MATH_TOOLKIT_LETTERS // characters of the mathematical toolkit with General Category neither L* nor N* - | OTHER_UCS_LETTERS // any other UCS characters with General Category L* - ; - -fragment -OTHER_MATH_TOOLKIT_LETTERS - : MATHEMATICAL_DOUBLE_STRUCK_CAPITAL_F - | DOUBLE_STRUCK_CAPITAL_Z - ; - -fragment -OTHER_UCS_LETTERS - : [\p{L}] // Letter - ; +; + +fragment LETTER: + LATIN + | GREEK + | OTHERLETTER + | OTHER_MATH_TOOLKIT_LETTERS // characters of the mathematical toolkit with General Category neither L* nor N* + | OTHER_UCS_LETTERS // any other UCS characters with General Category L* +; + +fragment OTHER_MATH_TOOLKIT_LETTERS: + MATHEMATICAL_DOUBLE_STRUCK_CAPITAL_F + | DOUBLE_STRUCK_CAPITAL_Z +; + +fragment OTHER_UCS_LETTERS: + [\p{L}] // Letter +; + +fragment LATIN: [A-Za-z]; + +fragment GREEK: + GREEK_CAPITAL_LETTER_DELTA + | GREEK_CAPITAL_LETTER_XI + | GREEK_SMALL_LETTER_THETA + | GREEK_SMALL_LETTER_LAMBDA + | GREEK_SMALL_LETTER_MU +; -fragment -LATIN - : [A-Za-z] - ; - -fragment -GREEK - : GREEK_CAPITAL_LETTER_DELTA - | GREEK_CAPITAL_LETTER_XI - | GREEK_SMALL_LETTER_THETA - | GREEK_SMALL_LETTER_LAMBDA - | GREEK_SMALL_LETTER_MU - ; - // 6.4.3.2 Greek alphabet characters GREEK_CAPITAL_LETTER_DELTA : '\u0394'; // Δ -GREEK_CAPITAL_LETTER_XI : '\u039E'; // Ξ +GREEK_CAPITAL_LETTER_XI : '\u039E'; // Ξ // 6.4.3.3 Other Z core language letter characters MATHEMATICAL_DOUBLE_STRUCK_CAPITAL_A : '\uD835\uDD38'; // 𝔸 -DOUBLE_STRUCK_CAPITAL_N : '\u2115'; // ℕ - +DOUBLE_STRUCK_CAPITAL_N : '\u2115'; // ℕ -fragment -OTHERLETTER - : MATHEMATICAL_DOUBLE_STRUCK_CAPITAL_A - | DOUBLE_STRUCK_CAPITAL_N - | POWERSET - ; +fragment OTHERLETTER: MATHEMATICAL_DOUBLE_STRUCK_CAPITAL_A | DOUBLE_STRUCK_CAPITAL_N | POWERSET; -fragment -PUNCT - : COMMA - | SEMICOLON - | COLON - | FULL_STOP//SELECT - ; +fragment PUNCT: + COMMA + | SEMICOLON + | COLON + | FULL_STOP //SELECT +; + +fragment STROKECHAR: MODIFIER_LETTER_PRIME | EXCLAMATION_MARK | QUESTION_MARK; -fragment -STROKECHAR - : MODIFIER_LETTER_PRIME - | EXCLAMATION_MARK - | QUESTION_MARK - ; - // 6.4.4.1 Stroke characters -MODIFIER_LETTER_PRIME : '\u2032'; // ′ In line 2, replace "0000 02B9 MODIFIER LETTER PRIME" by "0000 2032 PRIME". +MODIFIER_LETTER_PRIME: + '\u2032' +; // ′ In line 2, replace "0000 02B9 MODIFIER LETTER PRIME" by "0000 2032 PRIME". EXCLAMATION_MARK : '\u0021'; // ! -QUESTION_MARK : '\u003F'; // ? +QUESTION_MARK : '\u003F'; // ? - // 6.4.4.2 Word glue characters NORTH_EAST_ARROW : '\u2197'; // ↗ SOUTH_WEST_ARROW : '\u2199'; // ↙ @@ -280,38 +267,37 @@ SOUTH_EAST_ARROW : '\u2198'; // ↘ NORTH_WEST_ARROW : '\u2196'; // ↖ //LOW_LINE : '\u005F'; // _ -fragment SYMBOL - : VERTICAL_LINE - | AMPERSAND - | RIGHT_TACK - | LOGICAL_AND - | LOGICAL_OR - | RIGHTWARDS_DOUBLE_ARROW - | LEFT_RIGHT_DOUBLE_ARROW - | NOT_SIGN - | FOR_ALL - | THERE_EXISTS - | MULTIPLICATION_SIGN - | SOLIDUS - | EQUALS_SIGN - | ELEMENT_OF - | SPOT - | BIG_REVERSE_SOLIDUS - | SCHEMA_PROJECTION - | SCHEMA_COMPOSITION - | SCHEMA_PIPING - | PLUS_SIGN - | MATHEMATICAL_TOOLKIT_SYMBOLS // characters of the mathematical toolkit with General Category neither L* nor N* - | OTHER_UCS_SYMBOLS // any other UCS characters with General Category S*, P* or M* and that are not in SPECIAL - ; - -fragment -OTHER_UCS_SYMBOLS - : [\p{S}] // Currency Symbol - | [\p{P}] // Connector Punctuation +fragment SYMBOL: + VERTICAL_LINE + | AMPERSAND + | RIGHT_TACK + | LOGICAL_AND + | LOGICAL_OR + | RIGHTWARDS_DOUBLE_ARROW + | LEFT_RIGHT_DOUBLE_ARROW + | NOT_SIGN + | FOR_ALL + | THERE_EXISTS + | MULTIPLICATION_SIGN + | SOLIDUS + | EQUALS_SIGN + | ELEMENT_OF + | SPOT + | BIG_REVERSE_SOLIDUS + | SCHEMA_PROJECTION + | SCHEMA_COMPOSITION + | SCHEMA_PIPING + | PLUS_SIGN + | MATHEMATICAL_TOOLKIT_SYMBOLS // characters of the mathematical toolkit with General Category neither L* nor N* + | OTHER_UCS_SYMBOLS // any other UCS characters with General Category S*, P* or M* and that are not in SPECIAL +; + +fragment OTHER_UCS_SYMBOLS: + [\p{S}] // Currency Symbol + | [\p{P}] // Connector Punctuation | [\p{Mc}] // Spacing mark - ; - +; + // Insert "6.4.4 Punctuation characters //COLON : '\u003A'; // : //SEMICOLON : '\u003B'; // ; @@ -321,7 +307,7 @@ OTHER_UCS_SYMBOLS // 6.4.5 Symbol characters except mathematical toolkit characters //VERTICAL_LINE: '\u007C'; // | //AMPERSAND : '\u0026'; // & -RIGHT_TACK : '\u22A2'; // ⊢ +RIGHT_TACK: '\u22A2'; // ⊢ //LOGICAL_AND : '\u2227'; // ∧ //LOGICAL_OR : '\u2228'; // ∨ //RIGHTWARDS_DOUBLE_ARROW : '\u21D2'; // ⇒ @@ -334,171 +320,169 @@ RIGHT_TACK : '\u22A2'; // ⊢ //EQUALS_SIGN : '\u003D'; // = //ELEMENT_OF : '\u2208'; // ∈ //SPOT : '\u2981'; // ⦁ -BIG_REVERSE_SOLIDUS : '\u29F9'; // ⧹ +BIG_REVERSE_SOLIDUS: '\u29F9'; // ⧹ //SCHEMA_PROJECTION : '\u2A21'; // ⨡ //SCHEMA_COMPOSITION : '\u2A1F'; // ⨟ //SCHEMA_PIPING : '\u2A20'; // ⨠ -PLUS_SIGN : '\u002B'; // + +PLUS_SIGN: '\u002B'; // + // 6.4.6 Mathematical toolkit characters //fragment -MATHEMATICAL_TOOLKIT_SYMBOLS - : SET_TOOLKIT - | RELATION_TOOLKIT - | FUNCTION_TOOLKIT - | NUMBER_TOOLKIT - | SEQUENCE_TOOLKIT - ; - +MATHEMATICAL_TOOLKIT_SYMBOLS: + SET_TOOLKIT + | RELATION_TOOLKIT + | FUNCTION_TOOLKIT + | NUMBER_TOOLKIT + | SEQUENCE_TOOLKIT +; + // 6.4.6.1 Section set toolkit -LEFT_RIGHT_ARROW : '\u2194'; // ↔ -RIGHTWARDS_ARROW : '\u2192'; // → -NOT_EQUAL_TO : '\u2260'; // ≠ -NOT_AN_ELEMENT_OF : '\u2209'; // ∉ -EMPTY_SET : '\u2205'; // ∅ -SUBSET_OF_OR_EQUAL_TO : '\u2286'; // ⊆ -SUBSET_OF : '\u2282'; // ⊂ -UNION : '\u222A'; // ∪ -INTERSECTION : '\u2229'; // ∩ -SET_MINUS : '\u2216'; // ∖ In line 11, replace "0000 005C REVERSE SOLIDUS" by "0000 2216 SET MINUS". -CIRCLED_MINUS : '\u2296'; // ⊖ -N_ARY_UNION : '\u22C3'; // ⋃ -N_ARY_INTERSECTION : '\u22C2'; // ⋂ +LEFT_RIGHT_ARROW : '\u2194'; // ↔ +RIGHTWARDS_ARROW : '\u2192'; // → +NOT_EQUAL_TO : '\u2260'; // ≠ +NOT_AN_ELEMENT_OF : '\u2209'; // ∉ +EMPTY_SET : '\u2205'; // ∅ +SUBSET_OF_OR_EQUAL_TO : '\u2286'; // ⊆ +SUBSET_OF : '\u2282'; // ⊂ +UNION : '\u222A'; // ∪ +INTERSECTION : '\u2229'; // ∩ +SET_MINUS : '\u2216'; // ∖ In line 11, replace "0000 005C REVERSE SOLIDUS" by "0000 2216 SET MINUS". +CIRCLED_MINUS : '\u2296'; // ⊖ +N_ARY_UNION : '\u22C3'; // ⋃ +N_ARY_INTERSECTION : '\u22C2'; // ⋂ MATHEMATICAL_DOUBLE_STRUCK_CAPITAL_F : '\uD835\uDD3D'; // 𝔽 -fragment -SET_TOOLKIT - : LEFT_RIGHT_ARROW - | RIGHTWARDS_ARROW - | NOT_EQUAL_TO - | NOT_AN_ELEMENT_OF - | EMPTY_SET - | SUBSET_OF_OR_EQUAL_TO - | SUBSET_OF - | UNION - | INTERSECTION - | REVERSE_SOLIDUS - | CIRCLED_MINUS - | N_ARY_UNION - | N_ARY_INTERSECTION - ; - +fragment SET_TOOLKIT: + LEFT_RIGHT_ARROW + | RIGHTWARDS_ARROW + | NOT_EQUAL_TO + | NOT_AN_ELEMENT_OF + | EMPTY_SET + | SUBSET_OF_OR_EQUAL_TO + | SUBSET_OF + | UNION + | INTERSECTION + | REVERSE_SOLIDUS + | CIRCLED_MINUS + | N_ARY_UNION + | N_ARY_INTERSECTION +; + // 6.4.6.2 Section relation toolkit -RIGHTWARDS_ARROW_FROM_BAR : '\u21A6'; // ↦ -RELATIONAL_COMPOSITION : '\u2A3E'; // ⨾ -RING_OPERATOR : '\u2218'; // ∘ -WHITE_LEFT_POINTING_TRIANGLE : '\u25C1'; // ◁ +RIGHTWARDS_ARROW_FROM_BAR : '\u21A6'; // ↦ +RELATIONAL_COMPOSITION : '\u2A3E'; // ⨾ +RING_OPERATOR : '\u2218'; // ∘ +WHITE_LEFT_POINTING_TRIANGLE : '\u25C1'; // ◁ WHITE_RIGHT_POINTING_TRIANGLE : '\u25B7'; // ▷ -DOMAIN_ANTIRESTRICTION : '\u2A64'; // ⩤ -RANGE_ANTIRESTRICTION : '\u2A65'; // ⩥ -TILDE_OPERATOR : '\u223C'; // ∼ -LEFT_IMAGE_BRACKET : '\u2987'; // ⦇ -RIGHT_IMAGE_BRACKET : '\u2988'; // ⦈ -CIRCLED_PLUS : '\u2295'; // ⊕ +DOMAIN_ANTIRESTRICTION : '\u2A64'; // ⩤ +RANGE_ANTIRESTRICTION : '\u2A65'; // ⩥ +TILDE_OPERATOR : '\u223C'; // ∼ +LEFT_IMAGE_BRACKET : '\u2987'; // ⦇ +RIGHT_IMAGE_BRACKET : '\u2988'; // ⦈ +CIRCLED_PLUS : '\u2295'; // ⊕ + +fragment RELATION_TOOLKIT: + RIGHTWARDS_ARROW_FROM_BAR + | RELATIONAL_COMPOSITION + | RING_OPERATOR + | WHITE_LEFT_POINTING_TRIANGLE + | WHITE_RIGHT_POINTING_TRIANGLE + | DOMAIN_ANTIRESTRICTION + | RANGE_ANTIRESTRICTION + | TILDE_OPERATOR + | LEFT_IMAGE_BRACKET + | RIGHT_IMAGE_BRACKET + | CIRCLED_PLUS +; -fragment -RELATION_TOOLKIT - : RIGHTWARDS_ARROW_FROM_BAR - | RELATIONAL_COMPOSITION - | RING_OPERATOR - | WHITE_LEFT_POINTING_TRIANGLE - | WHITE_RIGHT_POINTING_TRIANGLE - | DOMAIN_ANTIRESTRICTION - | RANGE_ANTIRESTRICTION - | TILDE_OPERATOR - | LEFT_IMAGE_BRACKET - | RIGHT_IMAGE_BRACKET - | CIRCLED_PLUS - ; - // 6.4.6.3 Section function toolkit -RIGHTWARDS_ARROW_WITH_VERTICAL_STROKE : '\u21F8'; // ⇸ -RIGHTWARDS_ARROW_WITH_TAIL_WITH_VERTICAL_STROKE : '\u2914'; // ⤔ -RIGHTWARDS_ARROW_WITH_TAIL : '\u21A3'; // ↣ -RIGHTWARDS_TWO_HEADED_ARROW_WITH_VERTICAL_STROKE : '\u2900'; // ⤀ -RIGHTWARDS_TWO_HEADED_ARROW : '\u21A0'; // ↠ -RIGHTWARDS_TWO_HEADED_ARROW_WITH_TAIL : '\u2916'; // ⤖ -RIGHTWARDS_ARROW_WITH_DOUBLE_VERTICAL_STROKE : '\u21FB'; // ⇻ +RIGHTWARDS_ARROW_WITH_VERTICAL_STROKE : '\u21F8'; // ⇸ +RIGHTWARDS_ARROW_WITH_TAIL_WITH_VERTICAL_STROKE : '\u2914'; // ⤔ +RIGHTWARDS_ARROW_WITH_TAIL : '\u21A3'; // ↣ +RIGHTWARDS_TWO_HEADED_ARROW_WITH_VERTICAL_STROKE : '\u2900'; // ⤀ +RIGHTWARDS_TWO_HEADED_ARROW : '\u21A0'; // ↠ +RIGHTWARDS_TWO_HEADED_ARROW_WITH_TAIL : '\u2916'; // ⤖ +RIGHTWARDS_ARROW_WITH_DOUBLE_VERTICAL_STROKE : '\u21FB'; // ⇻ RIGHTWARDS_ARROW_WITH_TAIL_WITH_DOUBLE_VERTICAL_STROKE : '\u2915'; // ⤕ -fragment -FUNCTION_TOOLKIT - : RIGHTWARDS_ARROW_WITH_VERTICAL_STROKE - | RIGHTWARDS_ARROW_WITH_TAIL_WITH_VERTICAL_STROKE - | RIGHTWARDS_ARROW_WITH_TAIL - | RIGHTWARDS_TWO_HEADED_ARROW_WITH_VERTICAL_STROKE - | RIGHTWARDS_TWO_HEADED_ARROW - | RIGHTWARDS_TWO_HEADED_ARROW_WITH_TAIL - | RIGHTWARDS_ARROW_WITH_DOUBLE_VERTICAL_STROKE - | RIGHTWARDS_ARROW_WITH_TAIL_WITH_DOUBLE_VERTICAL_STROKE - ; - +fragment FUNCTION_TOOLKIT: + RIGHTWARDS_ARROW_WITH_VERTICAL_STROKE + | RIGHTWARDS_ARROW_WITH_TAIL_WITH_VERTICAL_STROKE + | RIGHTWARDS_ARROW_WITH_TAIL + | RIGHTWARDS_TWO_HEADED_ARROW_WITH_VERTICAL_STROKE + | RIGHTWARDS_TWO_HEADED_ARROW + | RIGHTWARDS_TWO_HEADED_ARROW_WITH_TAIL + | RIGHTWARDS_ARROW_WITH_DOUBLE_VERTICAL_STROKE + | RIGHTWARDS_ARROW_WITH_TAIL_WITH_DOUBLE_VERTICAL_STROKE +; + // 6.4.6.4 Section number toolkit -DOUBLE_STRUCK_CAPITAL_Z : '\u2124'; // ℤ -HYPHEN_MINUS : '\u002D'; // - -MINUS_SIGN : '\u2212'; // − -LESS_THAN_OR_EQUAL_TO : '\u2264'; // ≤ -LESS_THAN_SIGN : '\u003C'; // < +DOUBLE_STRUCK_CAPITAL_Z : '\u2124'; // ℤ +HYPHEN_MINUS : '\u002D'; // - +MINUS_SIGN : '\u2212'; // − +LESS_THAN_OR_EQUAL_TO : '\u2264'; // ≤ +LESS_THAN_SIGN : '\u003C'; // < GREATER_THAN_OR_EQUAL_TO : '\u2265'; // ≥ -GREATER_THAN_SIGN : '\u003E'; // > -ASTERISK : '\u002A'; // * +GREATER_THAN_SIGN : '\u003E'; // > +ASTERISK : '\u002A'; // * // 6.4.6.4 Section number toolkit -fragment -NUMBER_TOOLKIT - : HYPHEN_MINUS - | MINUS_SIGN - | LESS_THAN_OR_EQUAL_TO - | LESS_THAN_SIGN - | GREATER_THAN_OR_EQUAL_TO - | GREATER_THAN_SIGN - | ASTERISK - ; - +fragment NUMBER_TOOLKIT: + HYPHEN_MINUS + | MINUS_SIGN + | LESS_THAN_OR_EQUAL_TO + | LESS_THAN_SIGN + | GREATER_THAN_OR_EQUAL_TO + | GREATER_THAN_SIGN + | ASTERISK +; + // 6.4.6.5 Section sequence toolkit -NUMBER_SIGN : '\u0023'; // # -CHARACTER_TIE : '\u2040'; // ⁀ -UPWARDS_HARPOON_WITH_BARB_LEFTWARDS : '\u21BF'; // ↿ +NUMBER_SIGN : '\u0023'; // # +CHARACTER_TIE : '\u2040'; // ⁀ +UPWARDS_HARPOON_WITH_BARB_LEFTWARDS : '\u21BF'; // ↿ UPWARDS_HARPOON_WITH_BARB_RIGHTWARDS : '\u21BE'; // ↾ -LEFT_ANGLE_BRACKET : '\u27E8'; // 〈 In line 3, replace "0000 3008 LEFT ANGLE BRACKET" by "0000 27E8 MATHEMATICAL LEFT ANGLE BRACKET". -RIGHT_ANGLE_BRACKET : '\u27E9'; // 〉In line 4, replace "0000 3009 RIGHT ANGLE BRACKET" by "0000 27E9 MATHEMATICAL RIGHT ANGLE BRACKET". +LEFT_ANGLE_BRACKET: + '\u27E8' +; // 〈 In line 3, replace "0000 3008 LEFT ANGLE BRACKET" by "0000 27E8 MATHEMATICAL LEFT ANGLE BRACKET". +RIGHT_ANGLE_BRACKET: + '\u27E9' +; // 〉In line 4, replace "0000 3009 RIGHT ANGLE BRACKET" by "0000 27E9 MATHEMATICAL RIGHT ANGLE BRACKET". -fragment -SEQUENCE_TOOLKIT - : NUMBER_SIGN - | LEFT_ANGLE_BRACKET - | RIGHT_ANGLE_BRACKET - | CHARACTER_TIE - | UPWARDS_HARPOON_WITH_BARB_LEFTWARDS - | UPWARDS_HARPOON_WITH_BARB_RIGHTWARDS - ; +fragment SEQUENCE_TOOLKIT: + NUMBER_SIGN + | LEFT_ANGLE_BRACKET + | RIGHT_ANGLE_BRACKET + | CHARACTER_TIE + | UPWARDS_HARPOON_WITH_BARB_LEFTWARDS + | UPWARDS_HARPOON_WITH_BARB_RIGHTWARDS +; -ID : ID0 ID1*; +ID: ID0 ID1*; fragment ID1 : ID0 | [\p{Nd}]; fragment ID0 : [\p{L}] | '_'; -PREP : NAME; -PRE : NAME; +PREP : NAME; +PRE : NAME; POSTP : NAME; -POST : NAME; -IP : NAME; -I : NAME; -LP : NAME; -L : NAME; -ELP : NAME; -EL : NAME; -ERP : NAME; -ER : NAME; -SRP : NAME; -SR : NAME; -EREP : NAME; -ERE : NAME; -SREP : NAME; -SRE : NAME; -ES : NAME; -SS : NAME; - -UNKNOWN : . ; - +POST : NAME; +IP : NAME; +I : NAME; +LP : NAME; +L : NAME; +ELP : NAME; +EL : NAME; +ERP : NAME; +ER : NAME; +SRP : NAME; +SR : NAME; +EREP : NAME; +ERE : NAME; +SREP : NAME; +SRE : NAME; +ES : NAME; +SS : NAME; + +UNKNOWN: .; \ No newline at end of file diff --git a/z/ZOperatorParser.g4 b/z/ZOperatorParser.g4 index fb43e55bff..8e76a4421e 100644 --- a/z/ZOperatorParser.g4 +++ b/z/ZOperatorParser.g4 @@ -26,107 +26,111 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 ZOperatorParser; -options { tokenVocab=ZLexer; } + +options { + tokenVocab = ZLexer; +} specification - : (TEXT | section | paragraph)* EOF - ; + : (TEXT | section | paragraph)* EOF + ; section - : ZED SECTION NAME PARENTS formals? END paragraph* #InheritingSection - | ZED SECTION NAME END paragraph* #BaseSection - ; - + : ZED SECTION NAME PARENTS formals? END paragraph* # InheritingSection + | ZED SECTION NAME END paragraph* # BaseSection + ; + paragraph - : ZED operatorTemplate END #OperatorTemplateParagraph - | AX .*? END #AxiomaticDescriptionParagraph - | SCH .*? END #SchemaDefinitionParagraph - | ZED .*? END #NONOperatorTemplateParagraph - ; + : ZED operatorTemplate END # OperatorTemplateParagraph + | AX .*? END # AxiomaticDescriptionParagraph + | SCH .*? END # SchemaDefinitionParagraph + | ZED .*? END # NONOperatorTemplateParagraph + ; formals - : NAME (COMMA NAME)* - ; + : NAME (COMMA NAME)* + ; operatorTemplate - : RELATION template_ #RelationOperatorTemplate - | FUNCTION categoryTemplate #FunctionOperatorTemplate - | GENERIC categoryTemplate #GenericOperatorTemplate - ; + : RELATION template_ # RelationOperatorTemplate + | FUNCTION categoryTemplate # FunctionOperatorTemplate + | GENERIC categoryTemplate # GenericOperatorTemplate + ; categoryTemplate - : prefixTemplate - | postfixTemplate - | prec assoc infixTemplate - | nofixTemplate - ; + : prefixTemplate + | postfixTemplate + | prec assoc infixTemplate + | nofixTemplate + ; prec - : NUMERAL - ; - + : NUMERAL + ; + assoc - : LEFTASSOC - | RIGHTASSOC - ; + : LEFTASSOC + | RIGHTASSOC + ; template_ - : prefixTemplate - | postfixTemplate - | infixTemplate - | nofixTemplate - ; + : prefixTemplate + | postfixTemplate + | infixTemplate + | nofixTemplate + ; prefixTemplate - : LEFT_PARENTHESIS (prefixName | POWERSET ARGUMENT) RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS (prefixName | POWERSET ARGUMENT) RIGHT_PARENTHESIS + ; postfixTemplate - : LEFT_PARENTHESIS postfixName RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS postfixName RIGHT_PARENTHESIS + ; infixTemplate - : LEFT_PARENTHESIS infixName RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS infixName RIGHT_PARENTHESIS + ; nofixTemplate - : LEFT_PARENTHESIS nofixName RIGHT_PARENTHESIS - ; - + : LEFT_PARENTHESIS nofixName RIGHT_PARENTHESIS + ; + optArgName - : ARGUMENT NAME - ; - + : ARGUMENT NAME + ; + optListName - : LIST NAME - ; - + : LIST NAME + ; + argName - : ARGUMENT NAME - ; - -listName - : LIST NAME - ; - -prefixName - : NAME ARGUMENT - | NAME (optArgName | optListName)* (argName | listName) ARGUMENT - ; - -postfixName - : ARGUMENT NAME - | ARGUMENT NAME (optArgName | optListName)* (argName | listName) - ; - -infixName - : ARGUMENT NAME ARGUMENT - | ARGUMENT NAME (optArgName | optListName)* (argName | listName) ARGUMENT - ; - -nofixName - : NAME (optArgName | optListName)* (argName | listName) - ; + : ARGUMENT NAME + ; +listName + : LIST NAME + ; + +prefixName + : NAME ARGUMENT + | NAME (optArgName | optListName)* (argName | listName) ARGUMENT + ; + +postfixName + : ARGUMENT NAME + | ARGUMENT NAME (optArgName | optListName)* (argName | listName) + ; + +infixName + : ARGUMENT NAME ARGUMENT + | ARGUMENT NAME (optArgName | optListName)* (argName | listName) ARGUMENT + ; + +nofixName + : NAME (optArgName | optListName)* (argName | listName) + ; \ No newline at end of file diff --git a/z/ZParser.g4 b/z/ZParser.g4 index b6e8134e99..2d1e3ba035 100644 --- a/z/ZParser.g4 +++ b/z/ZParser.g4 @@ -26,303 +26,311 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// $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 ZParser; -options { tokenVocab=ZLexer; } + +options { + tokenVocab = ZLexer; +} specification - : (TEXT | section | paragraph)* EOF - ; + : (TEXT | section | paragraph)* EOF + ; section - : ZED SECTION NAME PARENTS formals? END paragraph* #InheritingSection - | ZED SECTION NAME END paragraph* #BaseSection - ; - + : ZED SECTION NAME PARENTS formals? END paragraph* # InheritingSection + | ZED SECTION NAME END paragraph* # BaseSection + ; + paragraph - : ZED LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET NL? END #GivenTypesParagraph - | AX schemaText END #AxiomaticDescriptionParagraph - | SCH NAME NL? schemaText END #SchemaDefinitionParagraph - | AX GEN LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET NL? schemaText END #GenericAxiomaticDescriptionParagraph - | SCH GEN NAME LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET NL? schemaText END #GenericSchemaDefinitionParagraph - | ZED NL? declNameExpression END #HorizontalDefinitionParagraph - | ZED declName LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET DEFINE_EQUAL expression END #GenericHorizontalDefinitionParagraph - | ZED genName DEFINE_EQUAL expression END #GenericOperatorDefinitionParagraph - | ZED freetype (AMPERSAND freetype)* END #FreeTypesParagraph - | ZED CONJECTURE predicate END #ConjectureParagraph - | ZED LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET CONJECTURE predicate END #GenericConjectureParagraph - | ZED operatorTemplate END #OperatorTemplateParagraph - ; + : ZED LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET NL? END # GivenTypesParagraph + | AX schemaText END # AxiomaticDescriptionParagraph + | SCH NAME NL? schemaText END # SchemaDefinitionParagraph + | AX GEN LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET NL? schemaText END # GenericAxiomaticDescriptionParagraph + | SCH GEN NAME LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET NL? schemaText END # GenericSchemaDefinitionParagraph + | ZED NL? declNameExpression END # HorizontalDefinitionParagraph + | ZED declName LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET DEFINE_EQUAL expression END # GenericHorizontalDefinitionParagraph + | ZED genName DEFINE_EQUAL expression END # GenericOperatorDefinitionParagraph + | ZED freetype (AMPERSAND freetype)* END # FreeTypesParagraph + | ZED CONJECTURE predicate END # ConjectureParagraph + | ZED LEFT_SQUARE_BRACKET formals RIGHT_SQUARE_BRACKET CONJECTURE predicate END # GenericConjectureParagraph + | ZED operatorTemplate END # OperatorTemplateParagraph + ; freetype - : NAME FREE_EQUALS branch (VERTICAL_LINE branch)* - ; - + : NAME FREE_EQUALS branch (VERTICAL_LINE branch)* + ; + branch - : declName (LEFT_DOUBLE_ANGLE_BRACKET expression RIGHT_DOUBLE_ANGLE_BRACKET)? - ; + : declName (LEFT_DOUBLE_ANGLE_BRACKET expression RIGHT_DOUBLE_ANGLE_BRACKET)? + ; + formals - : NAME (COMMA NAME)* - ; + : NAME (COMMA NAME)* + ; predicate - : predicate NL predicate #NewlineConjunctionPredicate - | predicate SEMICOLON predicate #SemicolonConjunctionPredicate - | FOR_ALL schemaText SPOT predicate #UniversalQuantificationPredicate - | THERE_EXISTS schemaText SPOT predicate #ExistentialQuantificationPredicate - | UNIQUE_EXISTS schemaText SPOT predicate #UniqueExistentialQuantificationPredicate - | predicate LEFT_RIGHT_DOUBLE_ARROW predicate #EquivalencePredicate - | predicate RIGHTWARDS_DOUBLE_ARROW predicate #ImplicationPredicate - | predicate LOGICAL_OR predicate #DisjunctionPredicate - | predicate LOGICAL_AND predicate #ConjunctionPredicate - | NOT_SIGN predicate #NegationPredicate - | relation #RelationOperatorApplicationPredicate - | expression #SchemaPredicatePredicate - | TRUE #TruthPredicate - | FALSE #FalsityPredicate - | LEFT_PARENTHESIS predicate RIGHT_PARENTHESIS #ParenthesizedPredicate - ; + : predicate NL predicate # NewlineConjunctionPredicate + | predicate SEMICOLON predicate # SemicolonConjunctionPredicate + | FOR_ALL schemaText SPOT predicate # UniversalQuantificationPredicate + | THERE_EXISTS schemaText SPOT predicate # ExistentialQuantificationPredicate + | UNIQUE_EXISTS schemaText SPOT predicate # UniqueExistentialQuantificationPredicate + | predicate LEFT_RIGHT_DOUBLE_ARROW predicate # EquivalencePredicate + | predicate RIGHTWARDS_DOUBLE_ARROW predicate # ImplicationPredicate + | predicate LOGICAL_OR predicate # DisjunctionPredicate + | predicate LOGICAL_AND predicate # ConjunctionPredicate + | NOT_SIGN predicate # NegationPredicate + | relation # RelationOperatorApplicationPredicate + | expression # SchemaPredicatePredicate + | TRUE # TruthPredicate + | FALSE # FalsityPredicate + | LEFT_PARENTHESIS predicate RIGHT_PARENTHESIS # ParenthesizedPredicate + ; expression - : FOR_ALL schemaText SPOT expression #SchemaUniversalQuantificationExpression - | THERE_EXISTS schemaText SPOT expression #SchemaExistentialQuantificationExpression - | UNIQUE_EXISTS schemaText SPOT expression #SchemaUniqueExistentialQuantificationExpression - | GREEK_SMALL_LETTER_LAMBDA schemaText SPOT expression #FunctionConstructionExpression - | GREEK_SMALL_LETTER_MU schemaText SPOT expression #DefiniteDescriptionExpression - | LET declNameExpression (SEMICOLON declNameExpression)* SPOT expression #SubstitutionExpressionExpression - | expression LEFT_RIGHT_DOUBLE_ARROW expression #SchemaEquivalenceExpression - | expression RIGHTWARDS_DOUBLE_ARROW expression #SchemaImplicationExpression - | expression LOGICAL_OR expression #SchemaDisjunctionExpression - | expression LOGICAL_AND expression #SchemaConjunctionExpression - | NOT_SIGN expression #SchemaNegationExpression - | IF predicate THEN expression ELSE expression #ConditionalExpression - | expression SCHEMA_COMPOSITION expression #SchemaCompositionExpression - | expression SCHEMA_PIPING expression #SchemaPipingExpression - | expression REVERSE_SOLIDUS LEFT_PARENTHESIS declName (COMMA declName)* RIGHT_PARENTHESIS #SchemaHidingExpression - | expression SCHEMA_PROJECTION expression #SchemaProjectionExpression - | PRE_KEY expression #SchemaPreconditionExpression - | expression (MULTIPLICATION_SIGN expression)+ #CartesianProductExpression - | POWERSET expression #PowersetExpression - | PRE expression #PrefixApplicationExpression - | L expSep? (expression ERE | expressionList? SRE) expression #GenericPrefixApplicationExpression - | expression POST #PostfixApplicationExpression - | expression EL expSep? (expression ER | expressionList? SR) #GenericPostfixApplicationExpression - | expression {ZSupport.isLeftAssociative(_input)}? I expression #InfixLeftApplicationExpression - | expression I expression #InfixRightApplicationExpression - | expression EL expSep? (expression ERE | expressionList? SRE) expression #GenericInfixApplicationExpression - | L expSep? (expression ER | expressionList? SR) #NofixApplicationExpression - | expression expression #ApplicationExpression - | expression STROKE #SchemaDecorationExpression - | expression LEFT_SQUARE_BRACKET declName SOLIDUS declName (COMMA declName SOLIDUS declName)* RIGHT_SQUARE_BRACKET #SchemaRenamingExpression - | expression FULL_STOP refName #BindingSelectionExpression - | expression FULL_STOP NUMERAL #TupleSelectionExpression - | GREEK_SMALL_LETTER_THETA expression STROKE* #BindingConstructionExpression - | refName #ReferenceExpression - | refName LEFT_SQUARE_BRACKET expressionList? RIGHT_SQUARE_BRACKET #GenericInstantiationExpression - | NUMERAL #NumberLiteralExpression - | LEFT_CURLY_BRACKET expressionList? RIGHT_CURLY_BRACKET #SetExtensionExpression - | LEFT_CURLY_BRACKET schemaText SPOT expression RIGHT_CURLY_BRACKET #SetComprehensionExpression - | LEFT_CURLY_BRACKET schemaText RIGHT_CURLY_BRACKET #CharacteristicSetComprehensionExpression - | LEFT_SQUARE_BRACKET schemaText RIGHT_SQUARE_BRACKET #SchemaConstructionExpression - | LEFT_BINDING_BRACKET (declNameExpression (COMMA declNameExpression)* )? RIGHT_BINDING_BRACKET #BindingExtensionExpression - | LEFT_PARENTHESIS expression (COMMA expression)+ RIGHT_PARENTHESIS #TupleExtensionExpression - | LEFT_PARENTHESIS GREEK_SMALL_LETTER_MU schemaText RIGHT_PARENTHESIS #CharacteristicDefiniteDescriptionExpression - | LEFT_PARENTHESIS expression RIGHT_PARENTHESIS #ParenthesizedExpression - ; + : FOR_ALL schemaText SPOT expression # SchemaUniversalQuantificationExpression + | THERE_EXISTS schemaText SPOT expression # SchemaExistentialQuantificationExpression + | UNIQUE_EXISTS schemaText SPOT expression # SchemaUniqueExistentialQuantificationExpression + | GREEK_SMALL_LETTER_LAMBDA schemaText SPOT expression # FunctionConstructionExpression + | GREEK_SMALL_LETTER_MU schemaText SPOT expression # DefiniteDescriptionExpression + | LET declNameExpression (SEMICOLON declNameExpression)* SPOT expression # SubstitutionExpressionExpression + | expression LEFT_RIGHT_DOUBLE_ARROW expression # SchemaEquivalenceExpression + | expression RIGHTWARDS_DOUBLE_ARROW expression # SchemaImplicationExpression + | expression LOGICAL_OR expression # SchemaDisjunctionExpression + | expression LOGICAL_AND expression # SchemaConjunctionExpression + | NOT_SIGN expression # SchemaNegationExpression + | IF predicate THEN expression ELSE expression # ConditionalExpression + | expression SCHEMA_COMPOSITION expression # SchemaCompositionExpression + | expression SCHEMA_PIPING expression # SchemaPipingExpression + | expression REVERSE_SOLIDUS LEFT_PARENTHESIS declName (COMMA declName)* RIGHT_PARENTHESIS # SchemaHidingExpression + | expression SCHEMA_PROJECTION expression # SchemaProjectionExpression + | PRE_KEY expression # SchemaPreconditionExpression + | expression (MULTIPLICATION_SIGN expression)+ # CartesianProductExpression + | POWERSET expression # PowersetExpression + | PRE expression # PrefixApplicationExpression + | L expSep? (expression ERE | expressionList? SRE) expression # GenericPrefixApplicationExpression + | expression POST # PostfixApplicationExpression + | expression EL expSep? (expression ER | expressionList? SR) # GenericPostfixApplicationExpression + | expression {ZSupport.isLeftAssociative(_input)}? I expression # InfixLeftApplicationExpression + | expression I expression # InfixRightApplicationExpression + | expression EL expSep? (expression ERE | expressionList? SRE) expression # GenericInfixApplicationExpression + | L expSep? (expression ER | expressionList? SR) # NofixApplicationExpression + | expression expression # ApplicationExpression + | expression STROKE # SchemaDecorationExpression + | expression LEFT_SQUARE_BRACKET declName SOLIDUS declName (COMMA declName SOLIDUS declName)* RIGHT_SQUARE_BRACKET # SchemaRenamingExpression + | expression FULL_STOP refName # BindingSelectionExpression + | expression FULL_STOP NUMERAL # TupleSelectionExpression + | GREEK_SMALL_LETTER_THETA expression STROKE* # BindingConstructionExpression + | refName # ReferenceExpression + | refName LEFT_SQUARE_BRACKET expressionList? RIGHT_SQUARE_BRACKET # GenericInstantiationExpression + | NUMERAL # NumberLiteralExpression + | LEFT_CURLY_BRACKET expressionList? RIGHT_CURLY_BRACKET # SetExtensionExpression + | LEFT_CURLY_BRACKET schemaText SPOT expression RIGHT_CURLY_BRACKET # SetComprehensionExpression + | LEFT_CURLY_BRACKET schemaText RIGHT_CURLY_BRACKET # CharacteristicSetComprehensionExpression + | LEFT_SQUARE_BRACKET schemaText RIGHT_SQUARE_BRACKET # SchemaConstructionExpression + | LEFT_BINDING_BRACKET (declNameExpression (COMMA declNameExpression)*)? RIGHT_BINDING_BRACKET # BindingExtensionExpression + | LEFT_PARENTHESIS expression (COMMA expression)+ RIGHT_PARENTHESIS # TupleExtensionExpression + | LEFT_PARENTHESIS GREEK_SMALL_LETTER_MU schemaText RIGHT_PARENTHESIS # CharacteristicDefiniteDescriptionExpression + | LEFT_PARENTHESIS expression RIGHT_PARENTHESIS # ParenthesizedExpression + ; schemaText - : NL? declPart? NL? (VERTICAL_LINE NL? predicate NL?)? NL? - ; - + : NL? declPart? NL? (VERTICAL_LINE NL? predicate NL?)? NL? + ; + declPart - : declaration ((SEMICOLON | NL) declaration)* - ; - + : declaration ((SEMICOLON | NL) declaration)* + ; + declNameExpression - : declName DEFINE_EQUAL expression NL? - ; - + : declName DEFINE_EQUAL expression NL? + ; + declaration - : declName (COMMA declName)* COLON expression - | declNameExpression - | expression - ; - -operatorTemplate - : RELATION template_ - | FUNCTION categoryTemplate - | GENERIC categoryTemplate - ; + : declName (COMMA declName)* COLON expression + | declNameExpression + | expression + ; +operatorTemplate + : RELATION template_ + | FUNCTION categoryTemplate + | GENERIC categoryTemplate + ; categoryTemplate - : prefixTemplate - | postfixTemplate - | prec assoc infixTemplate - | nofixTemplate - ; + : prefixTemplate + | postfixTemplate + | prec assoc infixTemplate + | nofixTemplate + ; prec - : NUMERAL - ; - + : NUMERAL + ; + assoc - : LEFTASSOC - | RIGHTASSOC - ; + : LEFTASSOC + | RIGHTASSOC + ; template_ - : prefixTemplate - | postfixTemplate - | infixTemplate - | nofixTemplate - ; + : prefixTemplate + | postfixTemplate + | infixTemplate + | nofixTemplate + ; prefixTemplate - : LEFT_PARENTHESIS (prefixName | POWERSET ARGUMENT) RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS (prefixName | POWERSET ARGUMENT) RIGHT_PARENTHESIS + ; postfixTemplate - : LEFT_PARENTHESIS postfixName RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS postfixName RIGHT_PARENTHESIS + ; infixTemplate - : LEFT_PARENTHESIS infixName RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS infixName RIGHT_PARENTHESIS + ; nofixTemplate - : LEFT_PARENTHESIS nofixName RIGHT_PARENTHESIS - ; + : LEFT_PARENTHESIS nofixName RIGHT_PARENTHESIS + ; declName - : NAME - | opName - ; + : NAME + | opName + ; refName - : NAME - | LEFT_PARENTHESIS opName RIGHT_PARENTHESIS - ; + : NAME + | LEFT_PARENTHESIS opName RIGHT_PARENTHESIS + ; opName - : prefixName - | postfixName - | infixName - | nofixName - ; - -prefixName - : PRE ARGUMENT - | PREP ARGUMENT - | L (ARGUMENT ES | LIST SS)* (ARGUMENT ERE | LIST SRE) ARGUMENT - | LP (ARGUMENT ES | LIST SS)* (ARGUMENT EREP | LIST SREP) ARGUMENT - ; - -postfixName - : ARGUMENT POST - | ARGUMENT POSTP - | ARGUMENT EL (ARGUMENT ES | LIST SS)* (ARGUMENT ER | LIST SR) - | ARGUMENT ELP (ARGUMENT ES | LIST SS)* (ARGUMENT ERP | LIST SRP) - ; - -infixName - : ARGUMENT I ARGUMENT - | ARGUMENT IP ARGUMENT - | ARGUMENT EL (ARGUMENT ES | LIST SS)* (ARGUMENT ERE | LIST SRE) ARGUMENT - | ARGUMENT ELP (ARGUMENT ES | LIST SS)* (ARGUMENT EREP | LIST SREP) ARGUMENT - ; - -nofixName - : L (ARGUMENT ES | LIST SS)* (ARGUMENT ER | LIST SR) - | LP (ARGUMENT ES | LIST SS)* (ARGUMENT ERP | LIST SRP) - ; - -genName - : prefixGenName - | postfixGenName - | infixGenName - | nofixGenName - ; - + : prefixName + | postfixName + | infixName + | nofixName + ; + +prefixName + : PRE ARGUMENT + | PREP ARGUMENT + | L (ARGUMENT ES | LIST SS)* (ARGUMENT ERE | LIST SRE) ARGUMENT + | LP (ARGUMENT ES | LIST SS)* (ARGUMENT EREP | LIST SREP) ARGUMENT + ; + +postfixName + : ARGUMENT POST + | ARGUMENT POSTP + | ARGUMENT EL (ARGUMENT ES | LIST SS)* (ARGUMENT ER | LIST SR) + | ARGUMENT ELP (ARGUMENT ES | LIST SS)* (ARGUMENT ERP | LIST SRP) + ; + +infixName + : ARGUMENT I ARGUMENT + | ARGUMENT IP ARGUMENT + | ARGUMENT EL (ARGUMENT ES | LIST SS)* (ARGUMENT ERE | LIST SRE) ARGUMENT + | ARGUMENT ELP (ARGUMENT ES | LIST SS)* (ARGUMENT EREP | LIST SREP) ARGUMENT + ; + +nofixName + : L (ARGUMENT ES | LIST SS)* (ARGUMENT ER | LIST SR) + | LP (ARGUMENT ES | LIST SS)* (ARGUMENT ERP | LIST SRP) + ; + +genName + : prefixGenName + | postfixGenName + | infixGenName + | nofixGenName + ; + prefixGenName - : PRE NAME - | L (NAME (ES | SS))* NAME (ERE | SRE) NAME - ; - -postfixGenName - : NAME POST - | NAME EL (NAME (ES | SS))* NAME (ER | SR) - ; - + : PRE NAME + | L (NAME (ES | SS))* NAME (ERE | SRE) NAME + ; + +postfixGenName + : NAME POST + | NAME EL (NAME (ES | SS))* NAME (ER | SR) + ; + infixGenName - : NAME I NAME - | NAME EL (NAME (ES | SS))* NAME (ERE | SRE) NAME - ; - -nofixGenName - : L (NAME (ES | SS))* NAME (ER | SR) - ; - -relation - : prefixRel - | postfixRel - | infixRel - | nofixRel - ; - -prefixRel - : PREP expression - | LP expSep? (expression EREP | expressionList? SREP) expression - ; - + : NAME I NAME + | NAME EL (NAME (ES | SS))* NAME (ERE | SRE) NAME + ; + +nofixGenName + : L (NAME (ES | SS))* NAME (ER | SR) + ; + +relation + : prefixRel + | postfixRel + | infixRel + | nofixRel + ; + +prefixRel + : PREP expression + | LP expSep? (expression EREP | expressionList? SREP) expression + ; + postfixRel - : expression POSTP - | expression ELP expSep? (expression ERP | expressionList? SRP) - ; + : expression POSTP + | expression ELP expSep? (expression ERP | expressionList? SRP) + ; infixRel // : expression ((ELEMENT_OF | EQUALS_SIGN | IP) expression)+ // | expression ELP expSep? (expression EREP | expressionList? SREP) expression - : expression {ZSupport.isLeftAssociative(_input)}? ((ELEMENT_OF | EQUALS_SIGN | IP) expression)+ - | expression ((ELEMENT_OF | EQUALS_SIGN | IP) expression)+ - | expression {ZSupport.isLeftAssociative(_input)}? ELP expSep? (expression EREP | expressionList? SREP) expression - | expression ELP expSep? (expression EREP | expressionList? SREP) expression - ; - + : expression {ZSupport.isLeftAssociative(_input)}? ((ELEMENT_OF | EQUALS_SIGN | IP) expression)+ + | expression ((ELEMENT_OF | EQUALS_SIGN | IP) expression)+ + | expression {ZSupport.isLeftAssociative(_input)}? ELP expSep? ( + expression EREP + | expressionList? SREP + ) expression + | expression ELP expSep? (expression EREP | expressionList? SREP) expression + ; + nofixRel - : LP expSep? (expression ERP | expressionList? SRP) - ; - + : LP expSep? (expression ERP | expressionList? SRP) + ; + application - : prefixApp - | postfixApp - | infixApp - | nofixApp - ; - + : prefixApp + | postfixApp + | infixApp + | nofixApp + ; + prefixApp - : PRE expression - | L expSep? (expression ERE | expressionList? SRE) expression - ; + : PRE expression + | L expSep? (expression ERE | expressionList? SRE) expression + ; postfixApp - : expression POST - | expression EL expSep? (expression ER | expressionList? SR) - ; + : expression POST + | expression EL expSep? (expression ER | expressionList? SR) + ; infixApp - : expression I expression - | expression EL expSep? (expression ERE | expressionList? SRE) expression - ; + : expression I expression + | expression EL expSep? (expression ERE | expressionList? SRE) expression + ; nofixApp - : L expSep? (expression ER | expressionList? SR) - ; - + : L expSep? (expression ER | expressionList? SR) + ; + expSep - : (expression ES | expressionList? SS)+ - ; + : (expression ES | expressionList? SS)+ + ; -expressionList - : expression (COMMA expression)* - ; +expressionList + : expression (COMMA expression)* + ; \ No newline at end of file