* added check for v3 backward incompatibilities:

** labels in lexer rules
This commit is contained in:
Terence Parr 2012-11-18 13:03:37 -08:00
parent fafc804fdf
commit ae111eddbd
3 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,7 @@ November 18, 2012
* added notion of one-off error * added notion of one-off error
* added check for v3 backward incompatibilities: * added check for v3 backward incompatibilities:
** tree grammars ** tree grammars
** labels in lexer rules
November 17, 2012 November 17, 2012

View File

@ -382,6 +382,15 @@ public class BasicSemanticChecks extends GrammarTreeVisitor {
} }
} }
@Override
protected void enterLabeledLexerElement(GrammarAST tree) {
Token label = ((GrammarAST)tree.getChild(0)).getToken();
g.tool.errMgr.grammarError(ErrorType.V3_LEXER_LABEL,
g.fileName,
label,
label.getText());
}
/** Check option is appropriate for grammar, rule, subrule */ /** Check option is appropriate for grammar, rule, subrule */
boolean checkOptions(GrammarAST parent, boolean checkOptions(GrammarAST parent,
Token optionID, Token optionID,

View File

@ -118,6 +118,9 @@ public enum ErrorType {
// Backward incompatibility errors // Backward incompatibility errors
V3_TREE_GRAMMAR(200, "tree grammars are not supported in ANTLR v4", ErrorSeverity.ERROR_ONE_OFF), V3_TREE_GRAMMAR(200, "tree grammars are not supported in ANTLR v4", ErrorSeverity.ERROR_ONE_OFF),
V3_LEXER_LABEL(201, "labels in lexer rules are not supported in ANTLR v4; " +
"actions cannot reference elements of lexical rules but you can use " +
"getText() to get the entire text matched for the rule", ErrorSeverity.ERROR_ONE_OFF),
// Dependency sorting errors // Dependency sorting errors