
Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: meta/syntax/antlr/antlr4/zaytsev/extracted
Source used for this grammar: Vadim Zaytsev, GrammarLab, grammarlab::extract::ANTLR4, 13 October 2014
OptionsSpec, SetElement, LexerCommand, LexerCommands, EbnfSuffix, LexerAlt, LexerAtom, Range, Element, OptionValue, ModeSpec, RuleBlock, Atom, DelegateGrammars, ElementOption, ExceptionGroup, LexerElement, RuleModifier, RuleAction, RulePrequel, Ebnf, BlockSet, Option, TokensSpec, RuleSpec, Action, ParserRuleSpec, LabeledAlt, ActionScopeName, LabeledElement, PrequelConstruct, ThrowsSpec, LexerRule, Alternative, Block, GrammarType, LexerBlock, ANTLR4Grammar, LocalsSpec, LabeledLexerElement, DelegateGrammar, ElementOptions, RuleReturns, AltList), 1 root (ANTLR4Grammar), 0 top (—), 6 bottom (ARG_ACTION 5, ACTION 7, STRING_LITERAL 7, Id 25, INT 2, LEXER_CHAR_SET).OptionsSpec ::= "options" "{" Option ";" "}"
SetElement ::= Range
SetElement ::=
STRING_LITERAL ElementOptionsSetElement ::=
Id ElementOptionsLexerCommand ::= Id"mode" "(" IdINT ")"
LexerCommands ::= "->" LexerCommand ","
EbnfSuffix ::= "+""*""?" "?"
LexerAlt ::= LexerElement LexerCommands
LexerAtom ::= Range
LexerAtom ::= LEXER_CHAR_SET
LexerAtom ::= "." ElementOptions
LexerAtom ::= "~" SetElementBlockSet
LexerAtom ::= IdSTRING_LITERAL ElementOptions
Range ::=
STRING_LITERAL ".." STRING_LITERALElement ::=
LabeledElement EbnfSuffixElement ::= ACTION "?"
Element ::=
Atom EbnfSuffixElement ::= Ebnf
OptionValue ::= Id "." Id
OptionValue ::= INT
OptionValue ::= ACTION
OptionValue ::= STRING_LITERAL
ModeSpec ::= "mode" Id ";" LexerRule
RuleBlock ::= LabeledAlt "|"
Atom ::= "." ElementOptions
Atom ::= Id ARG_ACTION ElementOptions
Atom ::= Range
Atom ::= "~" SetElementBlockSet
Atom ::= IdSTRING_LITERAL ElementOptions
DelegateGrammars ::= "import" DelegateGrammar "," ";"
ElementOption ::= Id "=" IdSTRING_LITERAL
ExceptionGroup ::= "catch" ARG_ACTION ACTION "finally" ACTION
LexerElement ::=
LabeledLexerElement EbnfSuffixLexerElement ::=
LexerBlock EbnfSuffixLexerElement ::=
LexerAtom EbnfSuffixLexerElement ::= ACTION "?"
RuleModifier ::=
"private"RuleModifier ::=
"fragment"RuleModifier ::=
"public"RuleModifier ::=
"protected"RuleAction ::=
"@" Id ACTIONRulePrequel ::= RuleAction
RulePrequel ::= OptionsSpec
Ebnf ::=
Block EbnfSuffixBlockSet ::= "(" SetElement "|" ")"
Option ::=
Id "=" OptionValueTokensSpec ::= "tokens" "{" Id "," "}"
RuleSpec ::= LexerRule
RuleSpec ::= ParserRuleSpec
Action ::= "@" ActionScopeName "::" Id ACTION
ParserRuleSpec ::= RuleModifier Id ARG_ACTION RuleReturns ThrowsSpec LocalsSpec RulePrequel ":" RuleBlock ";" ExceptionGroup
LabeledAlt ::= Alternative "#" Id
ActionScopeName ::=
"parser"ActionScopeName ::=
"lexer"ActionScopeName ::= Id
LabeledElement ::= Id "=""+=" AtomBlock
PrequelConstruct ::= OptionsSpec
PrequelConstruct ::= Action
PrequelConstruct ::= DelegateGrammars
PrequelConstruct ::= TokensSpec
ThrowsSpec ::= "throws" Id ","
LexerRule ::= "fragment" Id ":" LexerAlt "|" ";"
Alternative ::= ElementOptions Element
Block ::= "(" OptionsSpec RuleAction ":" AltList ")"
GrammarType ::= "lexer""parser" "grammar"
LexerBlock ::= "(" LexerAlt "|" ")"
ANTLR4Grammar ::= GrammarType Id ";" PrequelConstruct RuleSpec ModeSpec
LocalsSpec ::=
"locals" ARG_ACTIONLabeledLexerElement ::= Id "=""+=" LexerAtomBlock
DelegateGrammar ::= Id "=" Id
ElementOptions ::= "<" ElementOption "," ">"
RuleReturns ::=
"returns" ARG_ACTIONAltList ::= Alternative "|"