I messed up the merge a bit in ErrorType. Made something into a grammar error not tool error. changed tool error back so it does not accept a token in the grammar.

This commit is contained in:
Terence Parr 2014-06-30 16:24:43 -07:00
parent d85ea0649a
commit 07b7a4b334
5 changed files with 177 additions and 169 deletions

View File

@ -131,7 +131,7 @@ public class LeftRecursiveRuleAnalyzer extends LeftRecursiveRuleWalker {
assoc = ASSOC.left;
}
else {
tool.errMgr.toolError(ErrorType.ILLEGAL_OPTION_VALUE, t.getOptionAST("assoc").getToken(), "assoc", assoc);
tool.errMgr.grammarError(ErrorType.ILLEGAL_OPTION_VALUE, t.g.fileName, t.getOptionAST("assoc").getToken(), "assoc", assoc);
}
}
}

View File

@ -218,9 +218,9 @@ public class LeftRecursiveRuleTransformer {
}
catch (Exception e) {
tool.errMgr.toolError(ErrorType.INTERNAL_ERROR,
e,
ruleStart,
"error parsing rule created during left-recursion detection: "+ruleText,
e);
"error parsing rule created during left-recursion detection: "+ruleText);
}
return null;
}

View File

@ -164,15 +164,11 @@ public class ErrorManager {
* @param args The arguments to pass to the StringTemplate
*/
public void toolError(ErrorType errorType, Object... args) {
toolError(errorType, null, Token.INVALID_TOKEN, args);
toolError(errorType, null, args);
}
public void toolError(ErrorType errorType, Token offendingToken, Object... args) {
toolError(errorType, null, offendingToken, args);
}
public void toolError(ErrorType errorType, Throwable e, Token offendingToken, Object... args) {
ToolMessage msg = new ToolMessage(errorType, e, offendingToken, args);
public void toolError(ErrorType errorType, Throwable e, Object... args) {
ToolMessage msg = new ToolMessage(errorType, e, args);
emit(errorType, msg);
}

View File

@ -50,27 +50,27 @@ public enum ErrorType {
/**
* Compiler Error 1.
*
* <p>cannot write file '<em>filename</em>': <em>reason</em></p>
* <p>cannot write file <em>filename</em>: <em>reason</em></p>
*/
CANNOT_WRITE_FILE(1, "cannot write file '<arg>': <arg2>", ErrorSeverity.ERROR),
CANNOT_WRITE_FILE(1, "cannot write file <arg>: <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 2.
*
* <p>unknown command-line option '<em>option</em>'</p>
* <p>unknown command-line option <em>option</em></p>
*/
INVALID_CMDLINE_ARG(2, "unknown command-line option '<arg>'", ErrorSeverity.ERROR),
INVALID_CMDLINE_ARG(2, "unknown command-line option <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 3.
*
* <p>cannot find tokens file '<em>filename</em>'</p>
* <p>cannot find tokens file <em>filename</em></p>
*/
CANNOT_FIND_TOKENS_FILE(3, "cannot find tokens file '<arg>'", ErrorSeverity.ERROR),
CANNOT_FIND_TOKENS_FILE_GIVEN_ON_CMDLINE(3, "cannot find tokens file <arg> given for <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 4.
*
* <p>cannot find tokens file '<em>filename</em>': <em>reason</em></p>
* <p>cannot find tokens file <em>filename</em>: <em>reason</em></p>
*/
ERROR_READING_TOKENS_FILE(4, "cannot find tokens file '<arg>': <arg2>", ErrorSeverity.ERROR),
ERROR_READING_TOKENS_FILE(4, "error reading tokens file <arg>: <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 5.
*
@ -93,21 +93,27 @@ public enum ErrorType {
* Compiler Error 8.
*
* <p>
* grammar name '<em>name</em>' and file name '<em>filename</em>' differ</p>
* grammar name <em>name</em> and file name <em>filename</em> differ</p>
*/
FILE_AND_GRAMMAR_NAME_DIFFER(8, "grammar name '<arg>' and file name '<arg2>' differ", ErrorSeverity.ERROR),
FILE_AND_GRAMMAR_NAME_DIFFER(8, "grammar name <arg> and file name <arg2> differ", ErrorSeverity.ERROR),
/**
* Compiler Error 9.
*
* <p>invalid {@code -Dname=value} syntax: '<em>syntax</em>'</p>
* <p>invalid {@code -Dname=value} syntax: <em>syntax</em></p>
*/
BAD_OPTION_SET_SYNTAX(9, "invalid -Dname=value syntax: '<arg>'", ErrorSeverity.ERROR),
BAD_OPTION_SET_SYNTAX(9, "invalid -Dname=value syntax: <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 10.
*
* <p>warning treated as error</p>
*/
WARNING_TREATED_AS_ERROR(10, "warning treated as error", ErrorSeverity.ERROR_ONE_OFF),
/**
* Compiler Error 11.
*
* <p>cannot find tokens file <em>filename</em>: <em>reason</em></p>
*/
ERROR_READING_IMPORTED_GRAMMAR(11, "error reading imported grammar <arg> referenced in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 20.
@ -144,31 +150,31 @@ public enum ErrorType {
* Compiler Error 31.
*
* <p>
* ANTLR cannot generate '<em>language</em>' code as of version
* ANTLR cannot generate <em>language</em> code as of version
* <em>version</em></p>
*/
CANNOT_CREATE_TARGET_GENERATOR(31, "ANTLR cannot generate <arg> code as of version "+ Tool.VERSION, ErrorSeverity.ERROR),
CANNOT_CREATE_TARGET_GENERATOR(31, "ANTLR cannot generate <arg> code as of version "+ Tool.VERSION, ErrorSeverity.ERROR_ONE_OFF),
/**
* Compiler Error 32.
*
* <p>
* code generation template '<em>template</em>' has missing, misnamed, or
* incomplete arg list; missing '<em>field</em>'</p>
* code generation template <em>template</em> has missing, misnamed, or
* incomplete arg list; missing <em>field</em></p>
*/
CODE_TEMPLATE_ARG_ISSUE(32, "code generation template '<arg>' has missing, misnamed, or incomplete arg list; missing '<arg2>'", ErrorSeverity.ERROR),
CODE_TEMPLATE_ARG_ISSUE(32, "code generation template <arg> has missing, misnamed, or incomplete arg list; missing <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 33.
*
* <p>missing code generation template '<em>template</em>'</p>
* <p>missing code generation template <em>template</em></p>
*/
CODE_GEN_TEMPLATES_INCOMPLETE(33, "missing code generation template '<arg>'", ErrorSeverity.ERROR),
CODE_GEN_TEMPLATES_INCOMPLETE(33, "missing code generation template <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 34.
*
* <p>
* no mapping to template name for output model class '<em>class</em>'</p>
* no mapping to template name for output model class <em>class</em></p>
*/
NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class '<arg>'", ErrorSeverity.ERROR),
NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 35.
*
@ -189,21 +195,21 @@ public enum ErrorType {
/**
* Compiler Error 51.
*
* <p>rule '<em>rule</em>' redefinition; previous at line <em>line</em></p>
* <p>rule <em>rule</em> redefinition; previous at line <em>line</em></p>
*/
RULE_REDEFINITION(51, "rule '<arg>' redefinition; previous at line <arg2>", ErrorSeverity.ERROR),
RULE_REDEFINITION(51, "rule <arg> redefinition; previous at line <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 52.
*
* <p>lexer rule '<em>rule</em>' not allowed in parser</p>
* <p>lexer rule <em>rule</em> not allowed in parser</p>
*/
LEXER_RULES_NOT_ALLOWED(52, "lexer rule '<arg>' not allowed in parser", ErrorSeverity.ERROR),
LEXER_RULES_NOT_ALLOWED(52, "lexer rule <arg> not allowed in parser", ErrorSeverity.ERROR),
/**
* Compiler Error 53.
*
* <p>parser rule '<em>rule</em>' not allowed in lexer</p>
* <p>parser rule <em>rule</em> not allowed in lexer</p>
*/
PARSER_RULES_NOT_ALLOWED(53, "parser rule '<arg>' not allowed in lexer", ErrorSeverity.ERROR),
PARSER_RULES_NOT_ALLOWED(53, "parser rule <arg> not allowed in lexer", ErrorSeverity.ERROR),
/**
* Compiler Error 54.
*
@ -222,10 +228,10 @@ public enum ErrorType {
* Compiler Error 57.
*
* <p>
* reference to undefined rule '<em>rule</em>' in non-local ref
* '<em>reference</em>'</p>
* reference to undefined rule <em>rule</em> in non-local ref
* <em>reference</em></p>
*/
UNDEFINED_RULE_IN_NONLOCAL_REF(57, "reference to undefined rule '<arg>' in non-local ref '<arg3>'", ErrorSeverity.ERROR),
UNDEFINED_RULE_IN_NONLOCAL_REF(57, "reference to undefined rule <arg> in non-local ref <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 60.
*
@ -236,87 +242,87 @@ public enum ErrorType {
* Compiler Error 63.
*
* <p>
* unknown attribute reference '<em>attribute</em>' in
* '<em>expression</em>'</p>
* unknown attribute reference <em>attribute</em> in
* <em>expression</em></p>
*/
UNKNOWN_SIMPLE_ATTRIBUTE(63, "unknown attribute reference '<arg>' in '<arg2>'", ErrorSeverity.ERROR),
UNKNOWN_SIMPLE_ATTRIBUTE(63, "unknown attribute reference <arg> in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 64.
*
* <p>
* parameter '<em>parameter</em>' of rule '<em>rule</em>' is not accessible
* parameter <em>parameter</em> of rule <em>rule</em> is not accessible
* in this scope: <em>expression</em></p>
*/
INVALID_RULE_PARAMETER_REF(64, "parameter '<arg>' of rule '<arg2>' is not accessible in this scope: <arg3>", ErrorSeverity.ERROR),
INVALID_RULE_PARAMETER_REF(64, "parameter <arg> of rule <arg2> is not accessible in this scope: <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 65.
*
* <p>
* unknown attribute '<em>attribute</em>' for rule '<em>rule</em>' in
* '<em>expression</em>'</p>
* unknown attribute <em>attribute</em> for rule <em>rule</em> in
* <em>expression</em></p>
*/
UNKNOWN_RULE_ATTRIBUTE(65, "unknown attribute '<arg>' for rule '<arg2>' in '<arg3>'", ErrorSeverity.ERROR),
UNKNOWN_RULE_ATTRIBUTE(65, "unknown attribute <arg> for rule <arg2> in <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 66.
*
* <p>
* attribute '<em>attribute</em>' isn't a valid property in
* '<em>expression</em>'</p>
* attribute <em>attribute</em> isn't a valid property in
* <em>expression</em></p>
*/
UNKNOWN_ATTRIBUTE_IN_SCOPE(66, "attribute '<arg>' isn't a valid property in '<arg2>'", ErrorSeverity.ERROR),
UNKNOWN_ATTRIBUTE_IN_SCOPE(66, "attribute <arg> isn't a valid property in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 67.
*
* <p>
* missing attribute access on rule reference '<em>rule</em>' in
* '<em>expression</em>'</p>
* missing attribute access on rule reference <em>rule</em> in
* <em>expression</em></p>
*/
ISOLATED_RULE_REF(67, "missing attribute access on rule reference '<arg>' in '<arg2>'", ErrorSeverity.ERROR),
ISOLATED_RULE_REF(67, "missing attribute access on rule reference <arg> in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 69.
*
* <p>label '<em>label</em>' conflicts with rule with same name</p>
* <p>label <em>label</em> conflicts with rule with same name</p>
*/
LABEL_CONFLICTS_WITH_RULE(69, "label '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_RULE(69, "label <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 70.
*
* <p>label '<em>label</em>' conflicts with token with same name</p>
* <p>label <em>label</em> conflicts with token with same name</p>
*/
LABEL_CONFLICTS_WITH_TOKEN(70, "label '<arg>' conflicts with token with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_TOKEN(70, "label <arg> conflicts with token with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 72.
*
* <p>label '<em>label</em>' conflicts with parameter with same name</p>
* <p>label <em>label</em> conflicts with parameter with same name</p>
*/
LABEL_CONFLICTS_WITH_ARG(72, "label '<arg>' conflicts with parameter with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_ARG(72, "label <arg> conflicts with parameter with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 73.
*
* <p>label '<em>label</em>' conflicts with return value with same name</p>
* <p>label <em>label</em> conflicts with return value with same name</p>
*/
LABEL_CONFLICTS_WITH_RETVAL(73, "label '<arg>' conflicts with return value with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_RETVAL(73, "label <arg> conflicts with return value with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 74.
*
* <p>label '<em>label</em>' conflicts with local with same name</p>
* <p>label <em>label</em> conflicts with local with same name</p>
*/
LABEL_CONFLICTS_WITH_LOCAL(74, "label '<arg>' conflicts with local with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_LOCAL(74, "label <arg> conflicts with local with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 75.
*
* <p>
* label '<em>label</em>' type mismatch with previous definition:
* label <em>label</em> type mismatch with previous definition:
* <em>message</em></p>
*/
LABEL_TYPE_CONFLICT(75, "label '<arg>' type mismatch with previous definition: <arg2>", ErrorSeverity.ERROR),
LABEL_TYPE_CONFLICT(75, "label <arg> type mismatch with previous definition: <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 76.
*
* <p>
* return value '<em>name</em>' conflicts with parameter with same name</p>
* return value <em>name</em> conflicts with parameter with same name</p>
*/
RETVAL_CONFLICTS_WITH_ARG(76, "return value '<arg>' conflicts with parameter with same name", ErrorSeverity.ERROR),
RETVAL_CONFLICTS_WITH_ARG(76, "return value <arg> conflicts with parameter with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 79.
*
@ -326,38 +332,38 @@ public enum ErrorType {
/**
* Compiler Error 80.
*
* <p>rule '<em>rule</em>' has no defined parameters</p>
* <p>rule <em>rule</em> has no defined parameters</p>
*/
RULE_HAS_NO_ARGS(80, "rule '<arg>' has no defined parameters", ErrorSeverity.ERROR),
RULE_HAS_NO_ARGS(80, "rule <arg> has no defined parameters", ErrorSeverity.ERROR),
/**
* Compiler Warning 83.
*
* <p>unsupported option '<em>option</em>'</p>
* <p>unsupported option <em>option</em></p>
*/
ILLEGAL_OPTION(83, "unsupported option '<arg>'", ErrorSeverity.WARNING),
ILLEGAL_OPTION(83, "unsupported option <arg>", ErrorSeverity.WARNING),
/**
* Compiler Warning 84.
*
* <p>unsupported option value '<em>name</em>=<em>value</em>'</p>
* <p>unsupported option value <em>name</em>=<em>value</em></p>
*/
ILLEGAL_OPTION_VALUE(84, "unsupported option value '<arg>=<arg2>'", ErrorSeverity.WARNING),
ILLEGAL_OPTION_VALUE(84, "unsupported option value <arg>=<arg2>", ErrorSeverity.WARNING),
/**
* Compiler Error 94.
*
* <p>redefinition of '<em>action</em>' action</p>
* <p>redefinition of <em>action</em> action</p>
*/
ACTION_REDEFINITION(94, "redefinition of '<arg>' action", ErrorSeverity.ERROR),
ACTION_REDEFINITION(94, "redefinition of <arg> action", ErrorSeverity.ERROR),
/**
* Compiler Error 99.
*
* <p>This error may take any of the following forms.</p>
*
* <ul>
* <li>grammar '<em>grammar</em>' has no rules</li>
* <li>implicitly generated grammar '<em>grammar</em>' has no rules</li>
* <li>grammar <em>grammar</em> has no rules</li>
* <li>implicitly generated grammar <em>grammar</em> has no rules</li>
* </ul>
*/
NO_RULES(99, "<if(arg2.implicitLexerOwner)>implicitly generated <endif>grammar '<arg>' has no rules", ErrorSeverity.ERROR),
NO_RULES(99, "<if(arg2.implicitLexerOwner)>implicitly generated <endif>grammar <arg> has no rules", ErrorSeverity.ERROR),
/**
* Compiler Error 105.
*
@ -369,54 +375,60 @@ public enum ErrorType {
/**
* Compiler Error 106.
*
* <p>rule '<em>rule</em>' is not defined in grammar '<em>grammar</em>'</p>
* <p>rule <em>rule</em> is not defined in grammar <em>grammar</em></p>
*/
NO_SUCH_RULE_IN_SCOPE(106, "rule '<arg2>' is not defined in grammar '<arg>'", ErrorSeverity.ERROR),
NO_SUCH_RULE_IN_SCOPE(106, "rule <arg2> is not defined in grammar <arg>", ErrorSeverity.ERROR),
/**
* Compiler Warning 108.
*
* <p>token name '<em>Token</em>' is already defined</p>
* <p>token name <em>Token</em> is already defined</p>
*/
TOKEN_NAME_REASSIGNMENT(108, "token name '<arg>' is already defined", ErrorSeverity.WARNING),
TOKEN_NAME_REASSIGNMENT(108, "token name <arg> is already defined", ErrorSeverity.WARNING),
/**
* Compiler Warning 109.
*
* <p>options ignored in imported grammar '<em>grammar</em>'</p>
* <p>options ignored in imported grammar <em>grammar</em></p>
*/
OPTIONS_IN_DELEGATE(109, "options ignored in imported grammar '<arg>'", ErrorSeverity.WARNING),
OPTIONS_IN_DELEGATE(109, "options ignored in imported grammar <arg>", ErrorSeverity.WARNING),
/**
* Compiler Error 110.
*
* <p>
* can't find or load grammar '<em>grammar</em>' from
* '<em>filename</em>'</p>
* can't find or load grammar <em>grammar</em> from
* <em>filename</em></p>
*/
CANNOT_FIND_IMPORTED_GRAMMAR(110, "can't find or load grammar '<arg>' from '<arg2>'", ErrorSeverity.ERROR),
CANNOT_FIND_IMPORTED_GRAMMAR(110, "can't find or load grammar <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 111.
*
* <p>
* <em>grammartype</em> grammar '<em>grammar1</em>' cannot import
* <em>grammartype</em> grammar '<em>grammar2</em>'</p>
* <em>grammartype</em> grammar <em>grammar1</em> cannot import
* <em>grammartype</em> grammar <em>grammar2</em></p>
*/
INVALID_IMPORT(111, "<arg.typeString> grammar '<arg.name>' cannot import <arg2.typeString> grammar '<arg2.name>'", ErrorSeverity.ERROR),
INVALID_IMPORT(111, "<arg.typeString> grammar <arg.name> cannot import <arg2.typeString> grammar <arg2.name>", ErrorSeverity.ERROR),
/**
* Compiler Error 113.
*
* <p>
* <em>grammartype</em> grammar '<em>grammar1</em>' and imported
* <em>grammartype</em> grammar '<em>grammar2</em>' both generate
* '<em>recognizer</em>'</p>
* <em>grammartype</em> grammar <em>grammar1</em> and imported
* <em>grammartype</em> grammar <em>grammar2</em> both generate
* <em>recognizer</em></p>
*/
IMPORT_NAME_CLASH(113, "<arg.typeString> grammar '<arg.name>' and imported <arg2.typeString> grammar '<arg2.name>' both generate '<arg2.recognizerName>'", ErrorSeverity.ERROR),
IMPORT_NAME_CLASH(113, "<arg.typeString> grammar <arg.name> and imported <arg2.typeString> grammar <arg2.name> both generate <arg2.recognizerName>", ErrorSeverity.ERROR),
/**
* Compiler Error 160.
*
* <p>cannot find tokens file <em>filename</em></p>
*/
CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR(160, "cannot find tokens file <arg>", ErrorSeverity.ERROR),
/**
* Compiler Warning 118.
*
* <p>
* all operators of alt '<em>alt</em>' of left-recursive rule must have same
* all operators of alt <em>alt</em> of left-recursive rule must have same
* associativity</p>
*/
ALL_OPS_NEED_SAME_ASSOC(118, "all operators of alt '<arg>' of left-recursive rule must have same associativity", ErrorSeverity.WARNING),
ALL_OPS_NEED_SAME_ASSOC(118, "all operators of alt <arg> of left-recursive rule must have same associativity", ErrorSeverity.WARNING),
/**
* Compiler Error 119.
*
@ -440,30 +452,30 @@ public enum ErrorType {
/**
* Compiler Error 122.
*
* <p>rule '<em>rule</em>': must label all alternatives or none</p>
* <p>rule <em>rule</em>: must label all alternatives or none</p>
*/
RULE_WITH_TOO_FEW_ALT_LABELS(122, "rule '<arg>': must label all alternatives or none", ErrorSeverity.ERROR),
RULE_WITH_TOO_FEW_ALT_LABELS(122, "rule <arg>: must label all alternatives or none", ErrorSeverity.ERROR),
/**
* Compiler Error 123.
*
* <p>
* rule alt label '<em>label</em>' redefined in rule '<em>rule1</em>',
* originally in rule '<em>rule2</em>'</p>
* rule alt label <em>label</em> redefined in rule <em>rule1</em>,
* originally in rule <em>rule2</em></p>
*/
ALT_LABEL_REDEF(123, "rule alt label '<arg>' redefined in rule '<arg2>', originally in rule '<arg3>'", ErrorSeverity.ERROR),
ALT_LABEL_REDEF(123, "rule alt label <arg> redefined in rule <arg2>, originally in rule <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 124.
*
* <p>
* rule alt label '<em>label</em>' conflicts with rule '<em>rule</em>'</p>
* rule alt label <em>label</em> conflicts with rule <em>rule</em></p>
*/
ALT_LABEL_CONFLICTS_WITH_RULE(124, "rule alt label '<arg>' conflicts with rule '<arg2>'", ErrorSeverity.ERROR),
ALT_LABEL_CONFLICTS_WITH_RULE(124, "rule alt label <arg> conflicts with rule <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Warning 125.
*
* <p>implicit definition of token '<em>Token</em>' in parser</p>
* <p>implicit definition of token <em>Token</em> in parser</p>
*/
IMPLICIT_TOKEN_DEFINITION(125, "implicit definition of token '<arg>' in parser", ErrorSeverity.WARNING),
IMPLICIT_TOKEN_DEFINITION(125, "implicit definition of token <arg> in parser", ErrorSeverity.WARNING),
/**
* Compiler Error 126.
*
@ -483,9 +495,9 @@ public enum ErrorType {
/**
* Compiler Error 130.
*
* <p>label '<em>label</em>' assigned to a block which is not a set</p>
* <p>label <em>label</em> assigned to a block which is not a set</p>
*/
LABEL_BLOCK_NOT_A_SET(130, "label '<arg>' assigned to a block which is not a set", ErrorSeverity.ERROR),
LABEL_BLOCK_NOT_A_SET(130, "label <arg> assigned to a block which is not a set", ErrorSeverity.ERROR),
/**
* Compiler Warning 131.
*
@ -501,97 +513,97 @@ public enum ErrorType {
* Compiler Error 132.
*
* <p>
* action in lexer rule '<em>rule</em>' must be last element of single
* action in lexer rule <em>rule</em> must be last element of single
* outermost alt</p>
*
* @deprecated This error is no longer issued by ANTLR 4.2.
*/
@Deprecated
LEXER_ACTION_PLACEMENT_ISSUE(132, "action in lexer rule '<arg>' must be last element of single outermost alt", ErrorSeverity.ERROR),
LEXER_ACTION_PLACEMENT_ISSUE(132, "action in lexer rule <arg> must be last element of single outermost alt", ErrorSeverity.ERROR),
/**
* Compiler Error 133.
*
* <p>
* {@code ->command} in lexer rule '<em>rule</em>' must be last element of
* {@code ->command} in lexer rule <em>rule</em> must be last element of
* single outermost alt</p>
*/
LEXER_COMMAND_PLACEMENT_ISSUE(133, "->command in lexer rule '<arg>' must be last element of single outermost alt", ErrorSeverity.ERROR),
LEXER_COMMAND_PLACEMENT_ISSUE(133, "->command in lexer rule <arg> must be last element of single outermost alt", ErrorSeverity.ERROR),
/**
* Compiler Error 134.
*
* <p>
* symbol '<em>symbol</em>' conflicts with generated code in target language
* symbol <em>symbol</em> conflicts with generated code in target language
* or runtime</p>
*
* <p>
* Note: This error has the same number as the unrelated error
* {@link #UNSUPPORTED_REFERENCE_IN_LEXER_SET}.</p>
*/
USE_OF_BAD_WORD(134, "symbol '<arg>' conflicts with generated code in target language or runtime", ErrorSeverity.ERROR),
USE_OF_BAD_WORD(134, "symbol <arg> conflicts with generated code in target language or runtime", ErrorSeverity.ERROR),
/**
* Compiler Error 134.
*
* <p>rule reference '<em>rule</em>' is not currently supported in a set</p>
* <p>rule reference <em>rule</em> is not currently supported in a set</p>
*
* <p>
* Note: This error has the same number as the unrelated error
* {@link #USE_OF_BAD_WORD}.</p>
*/
UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference '<arg>' is not currently supported in a set", ErrorSeverity.ERROR),
UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference <arg> is not currently supported in a set", ErrorSeverity.ERROR),
/**
* Compiler Error 135.
*
* <p>cannot assign a value to list label '<em>label</em>'</p>
* <p>cannot assign a value to list label <em>label</em></p>
*/
ASSIGNMENT_TO_LIST_LABEL(135, "cannot assign a value to list label '<arg>'", ErrorSeverity.ERROR),
ASSIGNMENT_TO_LIST_LABEL(135, "cannot assign a value to list label <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 136.
*
* <p>return value '<em>name</em>' conflicts with rule with same name</p>
* <p>return value <em>name</em> conflicts with rule with same name</p>
*/
RETVAL_CONFLICTS_WITH_RULE(136, "return value '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
RETVAL_CONFLICTS_WITH_RULE(136, "return value <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 137.
*
* <p>return value '<em>name</em>' conflicts with token with same name</p>
* <p>return value <em>name</em> conflicts with token with same name</p>
*/
RETVAL_CONFLICTS_WITH_TOKEN(137, "return value '<arg>' conflicts with token with same name", ErrorSeverity.ERROR),
RETVAL_CONFLICTS_WITH_TOKEN(137, "return value <arg> conflicts with token with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 138.
*
* <p>parameter '<em>parameter</em>' conflicts with rule with same name</p>
* <p>parameter <em>parameter</em> conflicts with rule with same name</p>
*/
ARG_CONFLICTS_WITH_RULE(138, "parameter '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
ARG_CONFLICTS_WITH_RULE(138, "parameter <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 139.
*
* <p>parameter '<em>parameter</em>' conflicts with token with same name</p>
* <p>parameter <em>parameter</em> conflicts with token with same name</p>
*/
ARG_CONFLICTS_WITH_TOKEN(139, "parameter '<arg>' conflicts with token with same name", ErrorSeverity.ERROR),
ARG_CONFLICTS_WITH_TOKEN(139, "parameter <arg> conflicts with token with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 140.
*
* <p>local '<em>local</em>' conflicts with rule with same name</p>
* <p>local <em>local</em> conflicts with rule with same name</p>
*/
LOCAL_CONFLICTS_WITH_RULE(140, "local '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_RULE(140, "local <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 141.
*
* <p>local '<em>local</em>' conflicts with rule token same name</p>
* <p>local <em>local</em> conflicts with rule token same name</p>
*/
LOCAL_CONFLICTS_WITH_TOKEN(141, "local '<arg>' conflicts with rule token same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_TOKEN(141, "local <arg> conflicts with rule token same name", ErrorSeverity.ERROR),
/**
* Compiler Error 142.
*
* <p>local '<em>local</em>' conflicts with parameter with same name</p>
* <p>local <em>local</em> conflicts with parameter with same name</p>
*/
LOCAL_CONFLICTS_WITH_ARG(142, "local '<arg>' conflicts with parameter with same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_ARG(142, "local <arg> conflicts with parameter with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 143.
*
* <p>local '<em>local</em>' conflicts with return value with same name</p>
* <p>local <em>local</em> conflicts with return value with same name</p>
*/
LOCAL_CONFLICTS_WITH_RETVAL(143, "local '<arg>' conflicts with return value with same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_RETVAL(143, "local <arg> conflicts with return value with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 144.
*
@ -604,18 +616,18 @@ public enum ErrorType {
* Compiler Error 145.
*
* <p>
* lexer mode '<em>mode</em>' must contain at least one non-fragment
* lexer mode <em>mode</em> must contain at least one non-fragment
* rule</p>
*
* <p>
* Every lexer mode must contain at least one rule which is not declared
* with the {@code fragment} modifier.</p>
*/
MODE_WITHOUT_RULES(145, "lexer mode '<arg>' must contain at least one non-fragment rule", ErrorSeverity.ERROR),
MODE_WITHOUT_RULES(145, "lexer mode <arg> must contain at least one non-fragment rule", ErrorSeverity.ERROR),
/**
* Compiler Warning 146.
*
* <p>non-fragment lexer rule '<em>rule</em>' can match the empty string</p>
* <p>non-fragment lexer rule <em>rule</em> can match the empty string</p>
*
* <p>All non-fragment lexer rules must match at least one character.</p>
*
@ -630,12 +642,12 @@ public enum ErrorType {
* Whitespace : [ \t]*; // error 146
* </pre>
*/
EPSILON_TOKEN(146, "non-fragment lexer rule '<arg>' can match the empty string", ErrorSeverity.WARNING),
EPSILON_TOKEN(146, "non-fragment lexer rule <arg> can match the empty string", ErrorSeverity.WARNING),
/**
* Compiler Error 147.
*
* <p>
* left recursive rule '<em>rule</em>' must contain an alternative which is
* left recursive rule <em>rule</em> must contain an alternative which is
* not left recursive</p>
*
* <p>Left-recursive rules must contain at least one alternative which is not
@ -650,12 +662,12 @@ public enum ErrorType {
* ;
* </pre>
*/
NO_NON_LR_ALTS(147, "left recursive rule '<arg>' must contain an alternative which is not left recursive", ErrorSeverity.ERROR),
NO_NON_LR_ALTS(147, "left recursive rule <arg> must contain an alternative which is not left recursive", ErrorSeverity.ERROR),
/**
* Compiler Error 148.
*
* <p>
* left recursive rule '<em>rule</em>' contains a left recursive alternative
* left recursive rule <em>rule</em> contains a left recursive alternative
* which can be followed by the empty string</p>
*
* <p>In left-recursive rules, all left-recursive alternatives must match at
@ -670,12 +682,12 @@ public enum ErrorType {
* ;
* </pre>
*/
EPSILON_LR_FOLLOW(148, "left recursive rule '<arg>' contains a left recursive alternative which can be followed by the empty string", ErrorSeverity.ERROR),
EPSILON_LR_FOLLOW(148, "left recursive rule <arg> contains a left recursive alternative which can be followed by the empty string", ErrorSeverity.ERROR),
/**
* Compiler Error 149.
*
* <p>
* lexer command '<em>command</em>' does not exist or is not supported by
* lexer command <em>command</em> does not exist or is not supported by
* the current target</p>
*
* <p>Each lexer command requires an explicit implementation in the target
@ -691,11 +703,11 @@ public enum ErrorType {
*
* @since 4.1
*/
INVALID_LEXER_COMMAND(149, "lexer command '<arg>' does not exist or is not supported by the current target", ErrorSeverity.ERROR),
INVALID_LEXER_COMMAND(149, "lexer command <arg> does not exist or is not supported by the current target", ErrorSeverity.ERROR),
/**
* Compiler Error 150.
*
* <p>missing argument for lexer command '<em>command</em>'</p>
* <p>missing argument for lexer command <em>command</em></p>
*
* <p>Some lexer commands require an argument.</p>
*
@ -708,11 +720,11 @@ public enum ErrorType {
*
* @since 4.1
*/
MISSING_LEXER_COMMAND_ARGUMENT(150, "missing argument for lexer command '<arg>'", ErrorSeverity.ERROR),
MISSING_LEXER_COMMAND_ARGUMENT(150, "missing argument for lexer command <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 151.
*
* <p>lexer command '<em>command</em>' does not take any arguments</p>
* <p>lexer command <em>command</em> does not take any arguments</p>
*
* <p>A lexer command which does not take parameters was invoked with an
* argument.</p>
@ -726,7 +738,7 @@ public enum ErrorType {
*
* @since 4.1
*/
UNWANTED_LEXER_COMMAND_ARGUMENT(151, "lexer command '<arg>' does not take any arguments", ErrorSeverity.ERROR),
UNWANTED_LEXER_COMMAND_ARGUMENT(151, "lexer command <arg> does not take any arguments", ErrorSeverity.ERROR),
/**
* Compiler Error 152.
*
@ -738,7 +750,7 @@ public enum ErrorType {
*
* <pre>
* x : 'x'; // ok
* y : 'y; // error 152
* y : 'y'; // error 152
* </pre>
*
* @since 4.1
@ -748,7 +760,7 @@ public enum ErrorType {
* Compiler Error 153.
*
* <p>
* rule '<em>rule</em>' contains a closure with at least one alternative
* rule <em>rule</em> contains a closure with at least one alternative
* that can match an empty string</p>
*
* <p>A rule contains a closure ({@code (...)*}) or positive closure
@ -765,12 +777,12 @@ public enum ErrorType {
*
* @since 4.1
*/
EPSILON_CLOSURE(153, "rule '<arg>' contains a closure with at least one alternative that can match an empty string", ErrorSeverity.ERROR),
EPSILON_CLOSURE(153, "rule <arg> contains a closure with at least one alternative that can match an empty string", ErrorSeverity.ERROR),
/**
* Compiler Warning 154.
*
* <p>
* rule '<em>rule</em>' contains an optional block with at least one
* rule <em>rule</em> contains an optional block with at least one
* alternative that can match an empty string</p>
*
* <p>A rule contains an optional block ({@code (...)?}) around an empty
@ -787,12 +799,12 @@ public enum ErrorType {
*
* @since 4.1
*/
EPSILON_OPTIONAL(154, "rule '<arg>' contains an optional block with at least one alternative that can match an empty string", ErrorSeverity.WARNING),
EPSILON_OPTIONAL(154, "rule <arg> contains an optional block with at least one alternative that can match an empty string", ErrorSeverity.WARNING),
/**
* Compiler Warning 155.
*
* <p>
* rule '<em>rule</em>' contains a lexer command with an unrecognized
* rule <em>rule</em> contains a lexer command with an unrecognized
* constant value; lexer interpreters may produce incorrect output</p>
*
* <p>A lexer rule contains a standard lexer command, but the constant value
@ -814,7 +826,7 @@ public enum ErrorType {
*
* @since 4.2
*/
UNKNOWN_LEXER_CONSTANT(155, "rule '<arg>' contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output", ErrorSeverity.WARNING),
UNKNOWN_LEXER_CONSTANT(155, "rule <arg> contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output", ErrorSeverity.WARNING),
/**
* Compiler Error 156.
*
@ -835,7 +847,7 @@ public enum ErrorType {
/**
* Compiler Warning 157.
*
* <p>rule '<em>rule</em>' contains an 'assoc' element option in an
* <p>rule <em>rule</em> contains an assoc element option in an
* unrecognized location</p>
*
* <p>
@ -851,17 +863,17 @@ public enum ErrorType {
* <pre>
* x : 'x'
* | x '+'&lt;assoc=right&gt; x // warning 157
* |&lt;assoc=right&gt; x '*' x // ok
* |&lt;assoc=right&gt; x * x // ok
* ;
* </pre>
*
* @since 4.2.1
*/
UNRECOGNIZED_ASSOC_OPTION(157, "rule '<arg>' contains an 'assoc' terminal option in an unrecognized location", ErrorSeverity.WARNING),
UNRECOGNIZED_ASSOC_OPTION(157, "rule <arg> contains an assoc terminal option in an unrecognized location", ErrorSeverity.WARNING),
/**
* Compiler Warning 158.
*
* <p>fragment rule '<em>rule</em>' contains an action or command which can
* <p>fragment rule <em>rule</em> contains an action or command which can
* never be executed</p>
*
* <p>A lexer rule which is marked with the {@code fragment} modifier
@ -888,24 +900,24 @@ public enum ErrorType {
*
* @since 4.2.1
*/
FRAGMENT_ACTION_IGNORED(158, "fragment rule '<arg>' contains an action or command which can never be executed", ErrorSeverity.WARNING),
FRAGMENT_ACTION_IGNORED(158, "fragment rule <arg> contains an action or command which can never be executed", ErrorSeverity.WARNING),
/**
* Compiler Error 159.
*
* <p>cannot declare a rule with reserved name '<em>rule</em>'</p>
* <p>cannot declare a rule with reserved name <em>rule</em></p>
*
* <p>A rule was declared with a reserved name.</p>
*
* <p>The following rule produces this error.</p>
*
* <pre>
* EOF : ' ' // error 159 (EOF is a reserved name)
* EOF : ' ' // error 159 (EOF is a reserved name)
* ;
* </pre>
*
* @since 4.2.1
*/
RESERVED_RULE_NAME(159, "cannot declare a rule with reserved name '<arg>'", ErrorSeverity.ERROR),
RESERVED_RULE_NAME(159, "cannot declare a rule with reserved name <arg>", ErrorSeverity.ERROR),
/*
* Backward incompatibility errors
@ -944,7 +956,7 @@ public enum ErrorType {
* Compiler Warning 202.
*
* <p>
* '{@code tokens {A; B;}}' syntax is now '{@code tokens {A, B}}' in ANTLR
* {@code tokens {A; B;}} syntax is now {@code tokens {A, B}} in ANTLR
* 4</p>
*
* <p>
@ -956,13 +968,13 @@ public enum ErrorType {
* <strong>NOTE:</strong> ANTLR 4 does not allow a trailing comma to appear following the
* last token declared in the {@code tokens{}} block.</p>
*/
V3_TOKENS_SYNTAX(202, "'tokens {A; B;}' syntax is now 'tokens {A, B}' in ANTLR 4", ErrorSeverity.WARNING),
V3_TOKENS_SYNTAX(202, "tokens {A; B;} syntax is now tokens {A, B} in ANTLR 4", ErrorSeverity.WARNING),
/**
* Compiler Error 203.
*
* <p>
* assignments in {@code tokens{}} are not supported in ANTLR 4; use lexical
* rule '<em>TokenName</em> : <em>LiteralValue</em>;' instead</p>
* rule <em>TokenName</em> : <em>LiteralValue</em>; instead</p>
*
* <p>
* ANTLR 3 allowed literal tokens to be declared and assigned a value within
@ -971,7 +983,7 @@ public enum ErrorType {
* value declared in the {@code tokens{}} block should be converted to
* standard lexer rules.</p>
*/
V3_ASSIGN_IN_TOKENS(203, "assignments in tokens{} are not supported in ANTLR 4; use lexical rule '<arg> : <arg2>;' instead", ErrorSeverity.ERROR),
V3_ASSIGN_IN_TOKENS(203, "assignments in tokens{} are not supported in ANTLR 4; use lexical rule <arg> : <arg2>; instead", ErrorSeverity.ERROR),
/**
* Compiler Warning 204.
*

View File

@ -538,7 +538,7 @@ public class TestToolSyntaxErrors extends BaseTest {
"start : 'T' EOF;\n" +
"Something : 'something' -> channel(CUSTOM);";
String expected =
"error(" + ErrorType.CANNOT_CREATE_TARGET_GENERATOR.code + "): ANTLR cannot generate 'Foo' code as of version " + Tool.VERSION + "\n";
"error(" + ErrorType.CANNOT_CREATE_TARGET_GENERATOR.code + "): ANTLR cannot generate Foo code as of version " + Tool.VERSION + "\n";
String[] pair = new String[] {
grammar,
expected
@ -558,7 +558,7 @@ public class TestToolSyntaxErrors extends BaseTest {
"options { language=Foo; }\n" +
"start : 'T' EOF;\n";
String expected =
"error(" + ErrorType.CANNOT_CREATE_TARGET_GENERATOR.code + "): ANTLR cannot generate 'Foo' code as of version " + Tool.VERSION + "\n";
"error(" + ErrorType.CANNOT_CREATE_TARGET_GENERATOR.code + "): ANTLR cannot generate Foo code as of version " + Tool.VERSION + "\n";
String[] pair = new String[] {
grammar,