From b3b1a3750d2316cfbfd2f1c5ee8d1b356c94c67b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 14 Oct 2012 11:57:34 -0500 Subject: [PATCH] Allow optionsSpec at the beginning of a lexer block --- tool/src/org/antlr/v4/parse/ANTLRParser.g | 13 +++++++++++-- tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tool/src/org/antlr/v4/parse/ANTLRParser.g b/tool/src/org/antlr/v4/parse/ANTLRParser.g index 401baba2c..23fa59af5 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRParser.g +++ b/tool/src/org/antlr/v4/parse/ANTLRParser.g @@ -595,8 +595,17 @@ labeledLexerElement ; lexerBlock - : LPAREN lexerAltList RPAREN - -> ^(BLOCK[$LPAREN,"BLOCK"] lexerAltList ) +@after { +GrammarAST options = (GrammarAST)$tree.getFirstChildWithType(ANTLRParser.OPTIONS); +if ( options!=null ) { + Grammar.setNodeOptions($tree, options); +} +} + : LPAREN + ( optionsSpec COLON )? + lexerAltList + RPAREN + -> ^(BLOCK[$LPAREN,"BLOCK"] optionsSpec? lexerAltList ) ; // channel=HIDDEN, skip, more, mode(INSIDE), push(INSIDE), pop diff --git a/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g b/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g index ba6f0982e..f41ac29e8 100644 --- a/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g +++ b/tool/src/org/antlr/v4/parse/GrammarTreeVisitor.g @@ -381,7 +381,7 @@ labeledLexerElement ; lexerBlock - : ^(BLOCK lexerAlternative+) + : ^(BLOCK optionsSpec? lexerAlternative+) ; lexerAtom