Fix BasicSemanticCheck to check for token names that do not start with an uppercase letter
This commit is contained in:
parent
adee7ffd8f
commit
01f8716ec4
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue