Add unit test for antlr/antlr4#25 (currently fails because the underlying problem hasn't been fixed)
This commit is contained in:
parent
73c6ce5c7e
commit
5a5f56e91c
|
@ -150,6 +150,7 @@ public enum ErrorType {
|
|||
// ALIAS_REASSIGNMENT(127, "token literal <arg> aliased to new token name <arg2>", ErrorSeverity.WARNING),
|
||||
ATTRIBUTE_IN_LEXER_ACTION(128, "attribute references not allowed in lexer actions: $<arg>", ErrorSeverity.ERROR),
|
||||
WILDCARD_IN_PARSER(129, "wildcard '.' not allowed in parsers", ErrorSeverity.ERROR),
|
||||
LABEL_BLOCK_NOT_A_SET(130, "label <arg> assigned to a block which is not a set", ErrorSeverity.ERROR),
|
||||
|
||||
/** Documentation comment is unterminated */
|
||||
//UNTERMINATED_DOC_COMMENT(, "", ErrorSeverity.ERROR),
|
||||
|
|
|
@ -66,4 +66,23 @@ public class TestBasicSemanticErrors extends BaseTest {
|
|||
};
|
||||
|
||||
@Test public void testU() { super.testErrors(U, false); }
|
||||
|
||||
/**
|
||||
* Regression test for #25 "Don't allow labels on not token set subrules".
|
||||
* https://github.com/antlr/antlr4/issues/25
|
||||
*/
|
||||
@Test
|
||||
public void testIllegalNonSetLabel() throws Exception {
|
||||
String grammar =
|
||||
"grammar T;\n" +
|
||||
"ss : op=('=' | '+=' | expr) EOF;\n" +
|
||||
"expr : '=' '=';\n" +
|
||||
"";
|
||||
|
||||
String expected =
|
||||
"error(130): T.g4:2:5: label op assigned to a block which is not a set\n";
|
||||
|
||||
testErrors(new String[] { grammar, expected }, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue