From 1cec806b9bbc1976010a6914550dc39689cea1c3 Mon Sep 17 00:00:00 2001 From: Mike Lischke Date: Tue, 5 Dec 2023 14:39:40 +0100 Subject: [PATCH 1/2] Some grammars needed formatting fixes The formatter had a few bugs that have been fixed now. --- algol60/algol60.g4 | 9 +- css3/css3Parser.g4 | 12 +- dot/DOT.g4 | 16 +- json/JSON.g4 | 4 +- lpc/LPC.g4 | 2 +- pascal/pascal.g4 | 558 +++++----- pddl/Pddl.g4 | 30 +- promql/PromQLLexer.g4 | 3 +- smtlibv2/SMTLIBv2.g4 | 4 +- sparql/SparqlLexer.g4 | 3 +- stacktrace/StackTrace.g4 | 104 +- v/V.g4 | 4 +- vhdl/vhdl.g4 | 2217 +++++++++++++++++++------------------- z/ZLexer.g4 | 10 +- z/ZParser.g4 | 4 +- 15 files changed, 1500 insertions(+), 1480 deletions(-) diff --git a/algol60/algol60.g4 b/algol60/algol60.g4 index 99d8df6f41..d9bd5566f1 100644 --- a/algol60/algol60.g4 +++ b/algol60/algol60.g4 @@ -267,7 +267,8 @@ fragment Digit fragment ULCorner_f options { caseInsensitive = false; } - : '\u231C'; + : '\u231C' + ; ULCorner : ULCorner_f @@ -276,7 +277,8 @@ ULCorner fragment URCorner_f options { caseInsensitive = false; } - : '\u231D'; + : '\u231D' + ; URCorner : URCorner_f @@ -441,7 +443,8 @@ number fragment Proper_string options { caseInsensitive = false; } - : ~('\u231C' | '\u231D')*; + : ~('\u231C' | '\u231D')* + ; fragment Open_string : Proper_string diff --git a/css3/css3Parser.g4 b/css3/css3Parser.g4 index b84af2f6be..035289f649 100644 --- a/css3/css3Parser.g4 +++ b/css3/css3Parser.g4 @@ -125,10 +125,10 @@ attrib ; 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. */ + /* '::' 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) ; @@ -137,8 +137,8 @@ functionalPseudo ; expression -/* In CSS3, the expressions are identifiers, strings, */ -/* or of the form "an+b" */ + /* In CSS3, the expressions are identifiers, strings, */ + /* or of the form "an+b" */ : (( Plus | Minus | Dimension | UnknownDimension | Number | String_ | ident) ws)+ ; diff --git a/dot/DOT.g4 b/dot/DOT.g4 index f32d656655..42615527c8 100644 --- a/dot/DOT.g4 +++ b/dot/DOT.g4 @@ -100,7 +100,6 @@ id_ // "The keywords node, edge, graph, digraph, subgraph, and strict are // case-independent" - STRICT : [Ss] [Tt] [Rr] [Ii] [Cc] [Tt] ; @@ -125,7 +124,8 @@ SUBGRAPH : [Ss] [Uu] [Bb] [Gg] [Rr] [Aa] [Pp] [Hh] ; -/** "a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )" */ NUMBER +/** "a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )" */ +NUMBER : '-'? ('.' DIGIT+ | DIGIT+ ( '.' DIGIT*)?) ; @@ -133,13 +133,15 @@ fragment DIGIT : [0-9] ; -/** "any double-quoted string ("...") possibly containing escaped quotes" */ STRING +/** "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 + */ +ID : LETTER (LETTER | DIGIT)* ; @@ -149,7 +151,8 @@ fragment LETTER /** "HTML strings, angle brackets must occur in matched pairs, and * unescaped newlines are allowed." - */ HTML_STRING + */ +HTML_STRING : '<' (TAG | ~ [<>])* '>' ; @@ -167,7 +170,8 @@ LINE_COMMENT /** "a '#' character is considered a line output from a C preprocessor (e.g., * # 34 to indicate line 34 ) and discarded" - */ PREPROC + */ +PREPROC : '#' ~[\r\n]* -> skip ; diff --git a/json/JSON.g4 b/json/JSON.g4 index fa5fa09219..a175e43e3c 100644 --- a/json/JSON.g4 +++ b/json/JSON.g4 @@ -60,7 +60,7 @@ NUMBER ; fragment INT -// integer part forbis leading 0s (e.g. `01`) + // integer part forbis leading 0s (e.g. `01`) : '0' | [1-9] [0-9]* ; @@ -68,7 +68,7 @@ fragment INT // no leading zeros fragment EXP -// exponent number permits leading 0s (e.g. `1e01`) + // exponent number permits leading 0s (e.g. `1e01`) : [Ee] [+\-]? [0-9]+ ; diff --git a/lpc/LPC.g4 b/lpc/LPC.g4 index a4f0a51073..fd2a6ca431 100644 --- a/lpc/LPC.g4 +++ b/lpc/LPC.g4 @@ -77,7 +77,7 @@ NotEqual ; Compare -//: '<' + //: '<' : LessEqual | Great | GreatEqual diff --git a/pascal/pascal.g4 b/pascal/pascal.g4 index cecae30431..9abdf710bc 100644 --- a/pascal/pascal.g4 +++ b/pascal/pascal.g4 @@ -457,374 +457,374 @@ conditionalStatement ifStatement : IF expression THEN statement (: ELSE statement)? - ; + ; - caseStatement - : CASE expression OF caseListElement (SEMI caseListElement)* (SEMI ELSE statements)? END - ; +caseStatement + : CASE expression OF caseListElement (SEMI caseListElement)* (SEMI ELSE statements)? END + ; - caseListElement - : constList COLON statement - ; +caseListElement + : constList COLON statement + ; - repetetiveStatement - : whileStatement - | repeatStatement - | forStatement - ; +repetetiveStatement + : whileStatement + | repeatStatement + | forStatement + ; - whileStatement - : WHILE expression DO statement - ; +whileStatement + : WHILE expression DO statement + ; - repeatStatement - : REPEAT statements UNTIL expression - ; +repeatStatement + : REPEAT statements UNTIL expression + ; - forStatement - : FOR identifier ASSIGN forList DO statement - ; +forStatement + : FOR identifier ASSIGN forList DO statement + ; - forList - : initialValue (TO | DOWNTO) finalValue - ; +forList + : initialValue (TO | DOWNTO) finalValue + ; - initialValue - : expression - ; +initialValue + : expression + ; - finalValue - : expression - ; +finalValue + : expression + ; - withStatement - : WITH recordVariableList DO statement - ; +withStatement + : WITH recordVariableList DO statement + ; - recordVariableList - : variable (COMMA variable)* - ; +recordVariableList + : variable (COMMA variable)* + ; - AND - : 'AND' - ; +AND + : 'AND' + ; - ARRAY - : 'ARRAY' - ; +ARRAY + : 'ARRAY' + ; - BEGIN - : 'BEGIN' - ; +BEGIN + : 'BEGIN' + ; - BOOLEAN - : 'BOOLEAN' - ; +BOOLEAN + : 'BOOLEAN' + ; - CASE - : 'CASE' - ; +CASE + : 'CASE' + ; - CHAR - : 'CHAR' - ; +CHAR + : 'CHAR' + ; - CHR - : 'CHR' - ; +CHR + : 'CHR' + ; - CONST - : 'CONST' - ; +CONST + : 'CONST' + ; - DIV - : 'DIV' - ; +DIV + : 'DIV' + ; - DO - : 'DO' - ; +DO + : 'DO' + ; - DOWNTO - : 'DOWNTO' - ; +DOWNTO + : 'DOWNTO' + ; - ELSE - : 'ELSE' - ; +ELSE + : 'ELSE' + ; - END - : 'END' - ; +END + : 'END' + ; - FILE - : 'FILE' - ; +FILE + : 'FILE' + ; - FOR - : 'FOR' - ; +FOR + : 'FOR' + ; - FUNCTION - : 'FUNCTION' - ; +FUNCTION + : 'FUNCTION' + ; - GOTO - : 'GOTO' - ; +GOTO + : 'GOTO' + ; - IF - : 'IF' - ; +IF + : 'IF' + ; - IN - : 'IN' - ; +IN + : 'IN' + ; - INTEGER - : 'INTEGER' - ; +INTEGER + : 'INTEGER' + ; - LABEL - : 'LABEL' - ; +LABEL + : 'LABEL' + ; - MOD - : 'MOD' - ; +MOD + : 'MOD' + ; - NIL - : 'NIL' - ; +NIL + : 'NIL' + ; - NOT - : 'NOT' - ; +NOT + : 'NOT' + ; - OF - : 'OF' - ; +OF + : 'OF' + ; - OR - : 'OR' - ; +OR + : 'OR' + ; - PACKED - : 'PACKED' - ; +PACKED + : 'PACKED' + ; - PROCEDURE - : 'PROCEDURE' - ; +PROCEDURE + : 'PROCEDURE' + ; - PROGRAM - : 'PROGRAM' - ; +PROGRAM + : 'PROGRAM' + ; - REAL - : 'REAL' - ; +REAL + : 'REAL' + ; - RECORD - : 'RECORD' - ; +RECORD + : 'RECORD' + ; - REPEAT - : 'REPEAT' - ; +REPEAT + : 'REPEAT' + ; - SET - : 'SET' - ; +SET + : 'SET' + ; - THEN - : 'THEN' - ; +THEN + : 'THEN' + ; - TO - : 'TO' - ; +TO + : 'TO' + ; - TYPE - : 'TYPE' - ; +TYPE + : 'TYPE' + ; - UNTIL - : 'UNTIL' - ; +UNTIL + : 'UNTIL' + ; - VAR - : 'VAR' - ; +VAR + : 'VAR' + ; - WHILE - : 'WHILE' - ; +WHILE + : 'WHILE' + ; - WITH - : 'WITH' - ; +WITH + : 'WITH' + ; - PLUS - : '+' - ; +PLUS + : '+' + ; - MINUS - : '-' - ; +MINUS + : '-' + ; - STAR - : '*' - ; +STAR + : '*' + ; - SLASH - : '/' - ; +SLASH + : '/' + ; - ASSIGN - : ':=' - ; +ASSIGN + : ':=' + ; - COMMA - : ',' - ; +COMMA + : ',' + ; - SEMI - : ';' - ; +SEMI + : ';' + ; - COLON - : ':' - ; +COLON + : ':' + ; - EQUAL - : '=' - ; +EQUAL + : '=' + ; - NOT_EQUAL - : '<>' - ; +NOT_EQUAL + : '<>' + ; - LT - : '<' - ; +LT + : '<' + ; - LE - : '<=' - ; +LE + : '<=' + ; - GE - : '>=' - ; +GE + : '>=' + ; - GT - : '>' - ; +GT + : '>' + ; - LPAREN - : '(' - ; +LPAREN + : '(' + ; - RPAREN - : ')' - ; +RPAREN + : ')' + ; - LBRACK - : '[' - ; +LBRACK + : '[' + ; - LBRACK2 - : '(.' - ; +LBRACK2 + : '(.' + ; - RBRACK - : ']' - ; +RBRACK + : ']' + ; - RBRACK2 - : '.)' - ; +RBRACK2 + : '.)' + ; - POINTER - : '^' - ; +POINTER + : '^' + ; - AT - : '@' - ; +AT + : '@' + ; - DOT - : '.' - ; +DOT + : '.' + ; - DOTDOT - : '..' - ; +DOTDOT + : '..' + ; - LCURLY - : '{' - ; +LCURLY + : '{' + ; - RCURLY - : '}' - ; +RCURLY + : '}' + ; - UNIT - : 'UNIT' - ; +UNIT + : 'UNIT' + ; - INTERFACE - : 'INTERFACE' - ; +INTERFACE + : 'INTERFACE' + ; - USES - : 'USES' - ; +USES + : 'USES' + ; - STRING - : 'STRING' - ; +STRING + : 'STRING' + ; - IMPLEMENTATION - : 'IMPLEMENTATION' - ; +IMPLEMENTATION + : 'IMPLEMENTATION' + ; - TRUE - : 'TRUE' - ; +TRUE + : 'TRUE' + ; - FALSE - : 'FALSE' - ; +FALSE + : 'FALSE' + ; - WS - : [ \t\r\n] -> skip - ; +WS + : [ \t\r\n] -> skip + ; - COMMENT_1 - : '(*' .*? '*)' -> skip - ; +COMMENT_1 + : '(*' .*? '*)' -> skip + ; - COMMENT_2 - : '{' .*? '}' -> skip - ; +COMMENT_2 + : '{' .*? '}' -> skip + ; - IDENT - : ('A' .. 'Z') ('A' .. 'Z' | '0' .. '9' | '_')* - ; +IDENT + : ('A' .. 'Z') ('A' .. 'Z' | '0' .. '9' | '_')* + ; - STRING_LITERAL - : '\'' ('\'\'' | ~ ('\''))* '\'' - ; +STRING_LITERAL + : '\'' ('\'\'' | ~ ('\''))* '\'' + ; - NUM_INT - : ('0' .. '9')+ - ; +NUM_INT + : ('0' .. '9')+ + ; - NUM_REAL - : ('0' .. '9')+ (('.' ('0' .. '9')+ (EXPONENT)?)? | EXPONENT) - ; +NUM_REAL + : ('0' .. '9')+ (('.' ('0' .. '9')+ (EXPONENT)?)? | EXPONENT) + ; - fragment EXPONENT - : ('E') ('+' | '-')? ('0' .. '9')+ - ; \ No newline at end of file +fragment EXPONENT + : ('E') ('+' | '-')? ('0' .. '9')+ + ; \ No newline at end of file diff --git a/pddl/Pddl.g4 b/pddl/Pddl.g4 index 8c89525e91..c1c8831072 100644 --- a/pddl/Pddl.g4 +++ b/pddl/Pddl.g4 @@ -12,11 +12,13 @@ grammar Pddl; -/************* Start of grammar *******************/ pddlDoc +/************* Start of grammar *******************/ +pddlDoc : (domain | problem) EOF ; -/************* DOMAINS ****************************/ domain +/************* DOMAINS ****************************/ +domain : '(' 'define' domainName requireDef? typesDef? constantsDef? predicatesDef? functionsDef? constraints? structureDef* ')' ; @@ -106,7 +108,8 @@ structureDef | derivedDef ; -/************* ACTIONS ****************************/ actionDef +/************* ACTIONS ****************************/ +actionDef : '(' ':action' actionSymbol ':parameters' '(' typedVariableList ')' actionDefBody ')' ; @@ -155,7 +158,8 @@ term | VARIABLE ; -/************* DURATIVE ACTIONS ****************************/ durativeActionDef +/************* DURATIVE ACTIONS ****************************/ +durativeActionDef : '(' ':durative-action' actionSymbol ':parameters' '(' typedVariableList ')' daDefBody ')' ; @@ -190,11 +194,13 @@ interval : 'all' ; -/************* DERIVED DEFINITIONS ****************************/ derivedDef +/************* DERIVED DEFINITIONS ****************************/ +derivedDef : '(' ':derived' typedVariableList goalDesc ')' ; -/************* EXPRESSIONS ****************************/ fExp +/************* EXPRESSIONS ****************************/ +fExp : NUMBER | '(' binaryOp fExp fExp2 ')' | '(' '-' fExp ')' @@ -259,7 +265,8 @@ assignOp | 'decrease' ; -/************* DURATIONS ****************************/ durationConstraint +/************* DURATIONS ****************************/ +durationConstraint : '(' 'and' simpleDurationConstraint+ ')' | '(' ')' | simpleDurationConstraint @@ -305,7 +312,8 @@ fExpDA | fExp ; -/************* PROBLEMS ****************************/ problem +/************* PROBLEMS ****************************/ +problem : '(' 'define' problemDecl problemDomain requireDef? objectDecl? init_ goal probConstraints? metricSpec? ')' // lengthSpec? This is not defined anywhere in the BNF spec ')' ; @@ -380,7 +388,8 @@ metricFExp | '(' 'is-violated' NAME ')' ; -/************* CONSTRAINTS ****************************/ conGD +/************* CONSTRAINTS ****************************/ +conGD : '(' 'and' conGD* ')' | '(' 'forall' '(' typedVariableList ')' conGD ')' | '(' 'at' 'end' goalDesc ')' @@ -395,7 +404,8 @@ metricFExp | '(' 'hold-after' NUMBER goalDesc ')' ; -/************* LEXER ****************************/ REQUIRE_KEY +/************* LEXER ****************************/ +REQUIRE_KEY : ':strips' | ':typing' | ':negative-preconditions' diff --git a/promql/PromQLLexer.g4 b/promql/PromQLLexer.g4 index b273b6054b..c9f325ff32 100644 --- a/promql/PromQLLexer.g4 +++ b/promql/PromQLLexer.g4 @@ -179,7 +179,8 @@ FUNCTION options { | 'tanh' | 'deg' | 'pi' - | 'rad'; + | 'rad' +; LEFT_BRACE : '{'; RIGHT_BRACE : '}'; diff --git a/smtlibv2/SMTLIBv2.g4 b/smtlibv2/SMTLIBv2.g4 index 3d3f26ec2b..bad30b4631 100644 --- a/smtlibv2/SMTLIBv2.g4 +++ b/smtlibv2/SMTLIBv2.g4 @@ -891,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 ; @@ -912,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 ; diff --git a/sparql/SparqlLexer.g4 b/sparql/SparqlLexer.g4 index e7d05543ef..d350d296e3 100644 --- a/sparql/SparqlLexer.g4 +++ b/sparql/SparqlLexer.g4 @@ -168,7 +168,8 @@ fragment PN_CHARS_BASE options { | '\u2C00' ..'\u2FEF' | '\u3001' ..'\uD7FF' | '\uF900' ..'\uFDCF' - | '\uFDF0' ..'\uFFFD'; + | '\uFDF0' ..'\uFFFD' +; fragment DIGIT: '0' ..'9'; diff --git a/stacktrace/StackTrace.g4 b/stacktrace/StackTrace.g4 index 1f3f2e8c5d..4db73af554 100644 --- a/stacktrace/StackTrace.g4 +++ b/stacktrace/StackTrace.g4 @@ -81,72 +81,72 @@ identifier message : COLON (: .)*? - ; + ; - Number - : Digit+ - ; +Number + : Digit+ + ; - JavaWord - : (JavaCharacter)+ - ; +JavaWord + : (JavaCharacter)+ + ; - fragment JavaCharacter - : (CapitalLetter | NonCapitalLetter | Symbol | Digit) - ; +fragment JavaCharacter + : (CapitalLetter | NonCapitalLetter | Symbol | Digit) + ; - DOT - : '.' - ; +DOT + : '.' + ; - AT - : 'at' - ; +AT + : 'at' + ; - CAUSED_BY - : 'Caused by:' - ; +CAUSED_BY + : 'Caused by:' + ; - MORE_ - : 'more' - ; +MORE_ + : 'more' + ; - ELLIPSIS - : '...' - ; +ELLIPSIS + : '...' + ; - COLON - : ':' - ; +COLON + : ':' + ; - NATIVE_METHOD - : 'Native Method' - ; +NATIVE_METHOD + : 'Native Method' + ; - UNKNOWN_SOURCE - : 'Unknown Source' - ; +UNKNOWN_SOURCE + : 'Unknown Source' + ; - INIT - : '' - ; +INIT + : '' + ; - NonCapitalLetter - : 'a' .. 'z' - ; +NonCapitalLetter + : 'a' .. 'z' + ; - CapitalLetter - : 'A' .. 'Z' - ; +CapitalLetter + : 'A' .. 'Z' + ; - Symbol - : '_' - ; +Symbol + : '_' + ; - Digit - : '0' .. '9' - ; +Digit + : '0' .. '9' + ; - WS - : (' ' | '\r' | '\t' | '\u000C' | '\n') -> skip - ; \ No newline at end of file +WS + : (' ' | '\r' | '\t' | '\u000C' | '\n') -> skip + ; \ No newline at end of file diff --git a/v/V.g4 b/v/V.g4 index f11a139f0c..f747c66e72 100644 --- a/v/V.g4 +++ b/v/V.g4 @@ -367,13 +367,13 @@ returnStmt //BreakStmt = "break" [ Label ] . breakStmt -// : 'break' IDENTIFIER? + // : 'break' IDENTIFIER? : 'break' //TODO: V语言目前不支持break到可以goto的label ; //ContinueStmt = "continue" [ Label ] . continueStmt -// : 'continue' IDENTIFIER? + // : 'continue' IDENTIFIER? : 'continue' //TODO: V语言目前不支持continue到可以goto的label ; diff --git a/vhdl/vhdl.g4 b/vhdl/vhdl.g4 index 6e075e5bb8..d4fb5ee30a 100644 --- a/vhdl/vhdl.g4 +++ b/vhdl/vhdl.g4 @@ -978,1110 +978,1117 @@ exit_statement // (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 - ; + ; + +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 - : 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 + )? 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/z/ZLexer.g4 b/z/ZLexer.g4 index 804604d2d3..73bf16998d 100644 --- a/z/ZLexer.g4 +++ b/z/ZLexer.g4 @@ -31,7 +31,6 @@ // $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true lexer grammar ZLexer; -//import classify; @lexer::members { public static final Integer[] BOTH_VALUES = new Integer[] { ELSE, FUNCTION, GENERIC, LEFTASSOC, PARENTS, RELATION, RIGHTASSOC, SECTION, THEN, FREE_EQUALS, VERTICAL_LINE, LEFT_DOUBLE_ANGLE_BRACKET, RIGHT_DOUBLE_ANGLE_BRACKET, AMPERSAND, RIGHT_TACK, LIST, LOGICAL_AND, LOGICAL_OR, RIGHTWARDS_DOUBLE_ARROW, LEFT_RIGHT_DOUBLE_ARROW, MULTIPLICATION_SIGN, SOLIDUS, EQUALS_SIGN, ELEMENT_OF, DEFINE_EQUAL, COLON, SEMICOLON, COMMA, FULL_STOP, SPOT, BIG_REVERSE_SOLIDUS, SCHEMA_PROJECTION, SCHEMA_COMPOSITION, SCHEMA_PIPING }; @@ -175,18 +174,13 @@ fragment WORD: | PUNCT+ EQUALS_SIGN? ; -fragment -//WORDPART -// : ALPHASTR -// | SYMBOLSTR -// | SOUTH_EAST_ARROW WORDPART*? NORTH_WEST_ARROW // nesting allowed (but should it be?) -WORDGLUE: // | NORTH_EAST_ARROW WORDPART*? SOUTH_WEST_ARROW // nesting allowed (but should it be?) +fragment WORDGLUE: SOUTH_EAST_ARROW | NORTH_WEST_ARROW | NORTH_EAST_ARROW | SOUTH_WEST_ARROW | '_' -; // ; +; WORDPART: WORDGLUE (ALPHASTR | SYMBOLSTR); fragment ALPHASTR: (LETTER | DIGIT)*; diff --git a/z/ZParser.g4 b/z/ZParser.g4 index 2d1e3ba035..7924277fe6 100644 --- a/z/ZParser.g4 +++ b/z/ZParser.g4 @@ -286,8 +286,8 @@ postfixRel ; infixRel -// : expression ((ELEMENT_OF | EQUALS_SIGN | IP) expression)+ -// | expression ELP expSep? (expression EREP | expressionList? SREP) expression + // : 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? ( From 9ff9a99a46b642db3228d17c8a9ca102f0c0c6c6 Mon Sep 17 00:00:00 2001 From: Mike Lischke Date: Tue, 5 Dec 2023 14:39:40 +0100 Subject: [PATCH 2/2] Some grammars needed formatting fixes The formatter had a few bugs that have been fixed now. Closes #3863 additional issue with formatting --- php/PhpLexer.g4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php/PhpLexer.g4 b/php/PhpLexer.g4 index cad89a4f3f..a1cec7f379 100644 --- a/php/PhpLexer.g4 +++ b/php/PhpLexer.g4 @@ -382,7 +382,8 @@ fragment HtmlNameStartChar options { | '\u2C00' ..'\u2FEF' | '\u3001' ..'\uD7FF' | '\uF900' ..'\uFDCF' - | '\uFDF0' ..'\uFFFD'; + | '\uFDF0' ..'\uFFFD' +; fragment LNum : Digit+ ('_' Digit+)*; fragment ExponentPart : 'e' [+-]? LNum; fragment NonZeroDigit : [1-9];