diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java index 25722cb18..846c33fa2 100644 --- a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java +++ b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java @@ -191,6 +191,11 @@ public class BasicSemanticChecks extends GrammarTreeVisitor { //if ( ok ) g.ast.setOption(ID.getText(), value); } + @Override + public void defineToken(GrammarAST ID) { + checkTokenDefinition(ID.token); + } + @Override public void elementOption(GrammarASTWithOptions elem, GrammarAST ID, GrammarAST valueAST) { String v = null; @@ -315,20 +320,14 @@ public class BasicSemanticChecks extends GrammarTreeVisitor { } } - void checkTokenAlias(Token tokenID) { + void checkTokenDefinition(Token tokenID) { String fileName = tokenID.getInputStream().getSourceName(); - if ( Character.isLowerCase(tokenID.getText().charAt(0)) ) { + if ( !Character.isUpperCase(tokenID.getText().charAt(0)) ) { g.tool.errMgr.grammarError(ErrorType.TOKEN_NAMES_MUST_START_UPPER, fileName, tokenID, tokenID.getText()); } - if ( !g.isCombined() ) { - g.tool.errMgr.grammarError(ErrorType.CANNOT_ALIAS_TOKENS, - fileName, - tokenID, - tokenID.getText()); - } } /** Check option is appropriate for grammar, rule, subrule */