forked from jasder/antlr
Updated error messages and documentation
This commit is contained in:
parent
a972a4dc24
commit
f37d99bc92
|
@ -90,8 +90,8 @@ public enum ErrorType {
|
|||
RETVAL_CONFLICTS_WITH_ARG(76, "return value '<arg>' conflicts with parameter with same name", ErrorSeverity.ERROR),
|
||||
MISSING_RULE_ARGS(79, "missing arguments(s) on rule reference: <arg>", ErrorSeverity.ERROR),
|
||||
RULE_HAS_NO_ARGS(80, "rule '<arg>' has no defined parameters", ErrorSeverity.ERROR),
|
||||
ILLEGAL_OPTION(83, "illegal option '<arg>'", ErrorSeverity.WARNING),
|
||||
ILLEGAL_OPTION_VALUE(84, "illegal option value '<arg>=<arg2>'", ErrorSeverity.WARNING),
|
||||
ILLEGAL_OPTION(83, "unsupported option '<arg>'", ErrorSeverity.WARNING),
|
||||
ILLEGAL_OPTION_VALUE(84, "unsupported option value '<arg>=<arg2>'", ErrorSeverity.WARNING),
|
||||
ACTION_REDEFINITION(94, "redefinition of '<arg>' action", ErrorSeverity.ERROR),
|
||||
NO_RULES(99, "<if(arg2.implicitLexerOwner)>implicitly generated <endif>grammar '<arg>' has no rules", ErrorSeverity.ERROR),
|
||||
NO_SUCH_GRAMMAR_SCOPE(105, "reference to undefined grammar in rule reference: <arg>.<arg2>", ErrorSeverity.ERROR),
|
||||
|
@ -128,8 +128,48 @@ public enum ErrorType {
|
|||
LOCAL_CONFLICTS_WITH_RETVAL(143, "local '<arg>' conflicts with return value with same name", ErrorSeverity.ERROR),
|
||||
INVALID_LITERAL_IN_LEXER_SET(144, "multi-character literals are not allowed in lexer sets: <arg>", ErrorSeverity.ERROR),
|
||||
MODE_WITHOUT_RULES(145, "lexer mode '<arg>' must contain at least one non-fragment rule", ErrorSeverity.ERROR),
|
||||
/**
|
||||
* All non-fragment lexer rules must match at least one character.
|
||||
* <p/>
|
||||
* The following example shows this error.
|
||||
*
|
||||
* <pre>
|
||||
* Whitespace : [ \t]+; // ok
|
||||
* Whitespace : [ \t]; // ok
|
||||
*
|
||||
* fragment WS : [ \t]*; // ok
|
||||
*
|
||||
* Whitespace : [ \t]*; // error 146
|
||||
* </pre>
|
||||
*/
|
||||
EPSILON_TOKEN(146, "non-fragment lexer rule '<arg>' can match the empty string", ErrorSeverity.ERROR),
|
||||
/**
|
||||
* Left-recursive rules must contain at least one alternative which is not
|
||||
* left recursive.
|
||||
* <p/>
|
||||
* The following rule produces this error.
|
||||
*
|
||||
* <pre>
|
||||
* // error 147:
|
||||
* a : a ID
|
||||
* | a INT
|
||||
* ;
|
||||
* </pre>
|
||||
*/
|
||||
NO_NON_LR_ALTS(147, "left recursive rule '<arg>' must contain an alternative which is not left recursive", ErrorSeverity.ERROR),
|
||||
/**
|
||||
* In left-recursive rules, all left-recursive alternatives must match at
|
||||
* least one symbol following the recursive rule invocation.
|
||||
* <p/>
|
||||
* The following rule produces this error.
|
||||
*
|
||||
* <pre>
|
||||
* a : ID // ok (alternative is not left recursive)
|
||||
* | a INT // ok (a must be follow by INT)
|
||||
* | a ID? // error 148 (the ID following a is optional)
|
||||
* ;
|
||||
* </pre>
|
||||
*/
|
||||
EPSILON_LR_FOLLOW(148, "left recursive rule '<arg>' contains a left recursive alternative which can be followed by the empty string", ErrorSeverity.ERROR),
|
||||
|
||||
// Backward incompatibility errors
|
||||
|
|
|
@ -54,17 +54,17 @@ public class TestBasicSemanticErrors extends BaseTest {
|
|||
"b : ( options { ick=bar; greedy=true; } : ID )+ ;\n" +
|
||||
"c : ID<blue> ID<x=y> ;",
|
||||
// YIELDS
|
||||
"warning(83): U.g4:2:10: illegal option 'foo'\n" +
|
||||
"warning(83): U.g4:2:19: illegal option 'k'\n" +
|
||||
"warning(83): U.g4:2:10: unsupported option 'foo'\n" +
|
||||
"warning(83): U.g4:2:19: unsupported option 'k'\n" +
|
||||
"error(60): U.g4:5:8: token names must start with an uppercase letter: f\n" +
|
||||
"warning(83): U.g4:9:10: illegal option 'x'\n" +
|
||||
"warning(83): U.g4:9:10: unsupported option 'x'\n" +
|
||||
"error(54): U.g4:9:0: repeated grammar prequel spec (option, token, or import); please merge\n" +
|
||||
"error(54): U.g4:8:0: repeated grammar prequel spec (option, token, or import); please merge\n" +
|
||||
"warning(83): U.g4:12:10: illegal option 'blech'\n" +
|
||||
"warning(83): U.g4:12:21: illegal option 'greedy'\n" +
|
||||
"warning(83): U.g4:15:16: illegal option 'ick'\n" +
|
||||
"warning(83): U.g4:15:25: illegal option 'greedy'\n" +
|
||||
"warning(83): U.g4:16:16: illegal option 'x'\n",
|
||||
"warning(83): U.g4:12:10: unsupported option 'blech'\n" +
|
||||
"warning(83): U.g4:12:21: unsupported option 'greedy'\n" +
|
||||
"warning(83): U.g4:15:16: unsupported option 'ick'\n" +
|
||||
"warning(83): U.g4:15:25: unsupported option 'greedy'\n" +
|
||||
"warning(83): U.g4:16:16: unsupported option 'x'\n",
|
||||
};
|
||||
|
||||
@Test public void testU() { super.testErrors(U, false); }
|
||||
|
|
|
@ -56,8 +56,8 @@ public class TestSymbolIssues extends BaseTest {
|
|||
// YIELDS
|
||||
"error(94): A.g4:5:1: redefinition of 'members' action\n" +
|
||||
"error(94): A.g4:7:1: redefinition of 'header' action\n" +
|
||||
"warning(83): A.g4:2:10: illegal option 'opt'\n" +
|
||||
"warning(83): A.g4:2:21: illegal option 'k'\n" +
|
||||
"warning(83): A.g4:2:10: unsupported option 'opt'\n" +
|
||||
"warning(83): A.g4:2:21: unsupported option 'k'\n" +
|
||||
"error(94): A.g4:5:1: redefinition of 'members' action\n" +
|
||||
"warning(125): A.g4:9:27: implicit definition of token 'X' in parser\n" +
|
||||
"warning(125): A.g4:10:20: implicit definition of token 'Y' in parser\n" +
|
||||
|
|
Loading…
Reference in New Issue