forked from jasder/antlr
Fix detection of unsupported block options
This commit is contained in:
parent
850fe5b9c2
commit
65793adfc8
|
@ -338,14 +338,14 @@ public class BasicSemanticChecks extends GrammarTreeVisitor {
|
||||||
{
|
{
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
if ( parent.getType()==ANTLRParser.BLOCK ) {
|
if ( parent.getType()==ANTLRParser.BLOCK ) {
|
||||||
if ( g.isLexer() && Grammar.LexerSubruleOptions.contains(optionID.getText()) ) { // block
|
if ( g.isLexer() && !Grammar.LexerBlockOptions.contains(optionID.getText()) ) { // block
|
||||||
g.tool.errMgr.grammarError(ErrorType.ILLEGAL_OPTION,
|
g.tool.errMgr.grammarError(ErrorType.ILLEGAL_OPTION,
|
||||||
g.fileName,
|
g.fileName,
|
||||||
optionID,
|
optionID,
|
||||||
optionID.getText());
|
optionID.getText());
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
if ( !g.isLexer() && Grammar.ParserSubruleOptions.contains(optionID.getText()) ) { // block
|
if ( !g.isLexer() && !Grammar.ParserBlockOptions.contains(optionID.getText()) ) { // block
|
||||||
g.tool.errMgr.grammarError(ErrorType.ILLEGAL_OPTION,
|
g.tool.errMgr.grammarError(ErrorType.ILLEGAL_OPTION,
|
||||||
g.fileName,
|
g.fileName,
|
||||||
optionID,
|
optionID,
|
||||||
|
|
|
@ -82,10 +82,10 @@ public class Grammar implements AttributeResolver {
|
||||||
public static final Set<String> ruleOptions = new HashSet<String>() {{
|
public static final Set<String> ruleOptions = new HashSet<String>() {{
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public static final Set<String> ParserSubruleOptions = new HashSet<String>() {{
|
public static final Set<String> ParserBlockOptions = new HashSet<String>() {{
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public static final Set<String> LexerSubruleOptions = new HashSet<String>() {{
|
public static final Set<String> LexerBlockOptions = new HashSet<String>() {{
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/** Legal options for terminal refs like ID<assoc=right> */
|
/** Legal options for terminal refs like ID<assoc=right> */
|
||||||
|
|
Loading…
Reference in New Issue