diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java index 19b3f9a79..95ffec4bc 100644 --- a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java +++ b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java @@ -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); } } } diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java index 60b060c4d..2e713f78d 100644 --- a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java +++ b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleTransformer.java @@ -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; } diff --git a/tool/src/org/antlr/v4/tool/ErrorManager.java b/tool/src/org/antlr/v4/tool/ErrorManager.java index 2439c1d91..01bf74bb2 100644 --- a/tool/src/org/antlr/v4/tool/ErrorManager.java +++ b/tool/src/org/antlr/v4/tool/ErrorManager.java @@ -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); } diff --git a/tool/src/org/antlr/v4/tool/ErrorType.java b/tool/src/org/antlr/v4/tool/ErrorType.java index de4dec200..2f2a1953c 100644 --- a/tool/src/org/antlr/v4/tool/ErrorType.java +++ b/tool/src/org/antlr/v4/tool/ErrorType.java @@ -50,27 +50,27 @@ public enum ErrorType { /** * Compiler Error 1. * - *

cannot write file 'filename': reason

+ *

cannot write file filename: reason

*/ - CANNOT_WRITE_FILE(1, "cannot write file '': ", ErrorSeverity.ERROR), + CANNOT_WRITE_FILE(1, "cannot write file : ", ErrorSeverity.ERROR), /** * Compiler Error 2. * - *

unknown command-line option 'option'

+ *

unknown command-line option option

*/ - INVALID_CMDLINE_ARG(2, "unknown command-line option ''", ErrorSeverity.ERROR), + INVALID_CMDLINE_ARG(2, "unknown command-line option ", ErrorSeverity.ERROR), /** * Compiler Error 3. * - *

cannot find tokens file 'filename'

+ *

cannot find tokens file filename

*/ - CANNOT_FIND_TOKENS_FILE(3, "cannot find tokens file ''", ErrorSeverity.ERROR), + CANNOT_FIND_TOKENS_FILE_GIVEN_ON_CMDLINE(3, "cannot find tokens file given for ", ErrorSeverity.ERROR), /** * Compiler Error 4. * - *

cannot find tokens file 'filename': reason

+ *

cannot find tokens file filename: reason

*/ - ERROR_READING_TOKENS_FILE(4, "cannot find tokens file '': ", ErrorSeverity.ERROR), + ERROR_READING_TOKENS_FILE(4, "error reading tokens file : ", ErrorSeverity.ERROR), /** * Compiler Error 5. * @@ -93,21 +93,27 @@ public enum ErrorType { * Compiler Error 8. * *

- * grammar name 'name' and file name 'filename' differ

+ * grammar name name and file name filename differ

*/ - FILE_AND_GRAMMAR_NAME_DIFFER(8, "grammar name '' and file name '' differ", ErrorSeverity.ERROR), + FILE_AND_GRAMMAR_NAME_DIFFER(8, "grammar name and file name differ", ErrorSeverity.ERROR), /** * Compiler Error 9. * - *

invalid {@code -Dname=value} syntax: 'syntax'

+ *

invalid {@code -Dname=value} syntax: syntax

*/ - BAD_OPTION_SET_SYNTAX(9, "invalid -Dname=value syntax: ''", ErrorSeverity.ERROR), + BAD_OPTION_SET_SYNTAX(9, "invalid -Dname=value syntax: ", ErrorSeverity.ERROR), /** * Compiler Error 10. * *

warning treated as error

*/ WARNING_TREATED_AS_ERROR(10, "warning treated as error", ErrorSeverity.ERROR_ONE_OFF), + /** + * Compiler Error 11. + * + *

cannot find tokens file filename: reason

+ */ + ERROR_READING_IMPORTED_GRAMMAR(11, "error reading imported grammar referenced in ", ErrorSeverity.ERROR), /** * Compiler Error 20. @@ -144,31 +150,31 @@ public enum ErrorType { * Compiler Error 31. * *

- * ANTLR cannot generate 'language' code as of version + * ANTLR cannot generate language code as of version * version

*/ - CANNOT_CREATE_TARGET_GENERATOR(31, "ANTLR cannot generate code as of version "+ Tool.VERSION, ErrorSeverity.ERROR), + CANNOT_CREATE_TARGET_GENERATOR(31, "ANTLR cannot generate code as of version "+ Tool.VERSION, ErrorSeverity.ERROR_ONE_OFF), /** * Compiler Error 32. * *

- * code generation template 'template' has missing, misnamed, or - * incomplete arg list; missing 'field'

+ * code generation template template has missing, misnamed, or + * incomplete arg list; missing field

*/ - CODE_TEMPLATE_ARG_ISSUE(32, "code generation template '' has missing, misnamed, or incomplete arg list; missing ''", ErrorSeverity.ERROR), + CODE_TEMPLATE_ARG_ISSUE(32, "code generation template has missing, misnamed, or incomplete arg list; missing ", ErrorSeverity.ERROR), /** * Compiler Error 33. * - *

missing code generation template 'template'

+ *

missing code generation template template

*/ - CODE_GEN_TEMPLATES_INCOMPLETE(33, "missing code generation template ''", ErrorSeverity.ERROR), + CODE_GEN_TEMPLATES_INCOMPLETE(33, "missing code generation template ", ErrorSeverity.ERROR), /** * Compiler Error 34. * *

- * no mapping to template name for output model class 'class'

+ * no mapping to template name for output model class class

*/ - NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class ''", ErrorSeverity.ERROR), + NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class ", ErrorSeverity.ERROR), /** * Compiler Error 35. * @@ -189,21 +195,21 @@ public enum ErrorType { /** * Compiler Error 51. * - *

rule 'rule' redefinition; previous at line line

+ *

rule rule redefinition; previous at line line

*/ - RULE_REDEFINITION(51, "rule '' redefinition; previous at line ", ErrorSeverity.ERROR), + RULE_REDEFINITION(51, "rule redefinition; previous at line ", ErrorSeverity.ERROR), /** * Compiler Error 52. * - *

lexer rule 'rule' not allowed in parser

+ *

lexer rule rule not allowed in parser

*/ - LEXER_RULES_NOT_ALLOWED(52, "lexer rule '' not allowed in parser", ErrorSeverity.ERROR), + LEXER_RULES_NOT_ALLOWED(52, "lexer rule not allowed in parser", ErrorSeverity.ERROR), /** * Compiler Error 53. * - *

parser rule 'rule' not allowed in lexer

+ *

parser rule rule not allowed in lexer

*/ - PARSER_RULES_NOT_ALLOWED(53, "parser rule '' not allowed in lexer", ErrorSeverity.ERROR), + PARSER_RULES_NOT_ALLOWED(53, "parser rule not allowed in lexer", ErrorSeverity.ERROR), /** * Compiler Error 54. * @@ -222,10 +228,10 @@ public enum ErrorType { * Compiler Error 57. * *

- * reference to undefined rule 'rule' in non-local ref - * 'reference'

+ * reference to undefined rule rule in non-local ref + * reference

*/ - UNDEFINED_RULE_IN_NONLOCAL_REF(57, "reference to undefined rule '' in non-local ref ''", ErrorSeverity.ERROR), + UNDEFINED_RULE_IN_NONLOCAL_REF(57, "reference to undefined rule in non-local ref ", ErrorSeverity.ERROR), /** * Compiler Error 60. * @@ -236,87 +242,87 @@ public enum ErrorType { * Compiler Error 63. * *

- * unknown attribute reference 'attribute' in - * 'expression'

+ * unknown attribute reference attribute in + * expression

*/ - UNKNOWN_SIMPLE_ATTRIBUTE(63, "unknown attribute reference '' in ''", ErrorSeverity.ERROR), + UNKNOWN_SIMPLE_ATTRIBUTE(63, "unknown attribute reference in ", ErrorSeverity.ERROR), /** * Compiler Error 64. * *

- * parameter 'parameter' of rule 'rule' is not accessible + * parameter parameter of rule rule is not accessible * in this scope: expression

*/ - INVALID_RULE_PARAMETER_REF(64, "parameter '' of rule '' is not accessible in this scope: ", ErrorSeverity.ERROR), + INVALID_RULE_PARAMETER_REF(64, "parameter of rule is not accessible in this scope: ", ErrorSeverity.ERROR), /** * Compiler Error 65. * *

- * unknown attribute 'attribute' for rule 'rule' in - * 'expression'

+ * unknown attribute attribute for rule rule in + * expression

*/ - UNKNOWN_RULE_ATTRIBUTE(65, "unknown attribute '' for rule '' in ''", ErrorSeverity.ERROR), + UNKNOWN_RULE_ATTRIBUTE(65, "unknown attribute for rule in ", ErrorSeverity.ERROR), /** * Compiler Error 66. * *

- * attribute 'attribute' isn't a valid property in - * 'expression'

+ * attribute attribute isn't a valid property in + * expression

*/ - UNKNOWN_ATTRIBUTE_IN_SCOPE(66, "attribute '' isn't a valid property in ''", ErrorSeverity.ERROR), + UNKNOWN_ATTRIBUTE_IN_SCOPE(66, "attribute isn't a valid property in ", ErrorSeverity.ERROR), /** * Compiler Error 67. * *

- * missing attribute access on rule reference 'rule' in - * 'expression'

+ * missing attribute access on rule reference rule in + * expression

*/ - ISOLATED_RULE_REF(67, "missing attribute access on rule reference '' in ''", ErrorSeverity.ERROR), + ISOLATED_RULE_REF(67, "missing attribute access on rule reference in ", ErrorSeverity.ERROR), /** * Compiler Error 69. * - *

label 'label' conflicts with rule with same name

+ *

label label conflicts with rule with same name

*/ - LABEL_CONFLICTS_WITH_RULE(69, "label '' conflicts with rule with same name", ErrorSeverity.ERROR), + LABEL_CONFLICTS_WITH_RULE(69, "label conflicts with rule with same name", ErrorSeverity.ERROR), /** * Compiler Error 70. * - *

label 'label' conflicts with token with same name

+ *

label label conflicts with token with same name

*/ - LABEL_CONFLICTS_WITH_TOKEN(70, "label '' conflicts with token with same name", ErrorSeverity.ERROR), + LABEL_CONFLICTS_WITH_TOKEN(70, "label conflicts with token with same name", ErrorSeverity.ERROR), /** * Compiler Error 72. * - *

label 'label' conflicts with parameter with same name

+ *

label label conflicts with parameter with same name

*/ - LABEL_CONFLICTS_WITH_ARG(72, "label '' conflicts with parameter with same name", ErrorSeverity.ERROR), + LABEL_CONFLICTS_WITH_ARG(72, "label conflicts with parameter with same name", ErrorSeverity.ERROR), /** * Compiler Error 73. * - *

label 'label' conflicts with return value with same name

+ *

label label conflicts with return value with same name

*/ - LABEL_CONFLICTS_WITH_RETVAL(73, "label '' conflicts with return value with same name", ErrorSeverity.ERROR), + LABEL_CONFLICTS_WITH_RETVAL(73, "label conflicts with return value with same name", ErrorSeverity.ERROR), /** * Compiler Error 74. * - *

label 'label' conflicts with local with same name

+ *

label label conflicts with local with same name

*/ - LABEL_CONFLICTS_WITH_LOCAL(74, "label '' conflicts with local with same name", ErrorSeverity.ERROR), + LABEL_CONFLICTS_WITH_LOCAL(74, "label conflicts with local with same name", ErrorSeverity.ERROR), /** * Compiler Error 75. * *

- * label 'label' type mismatch with previous definition: + * label label type mismatch with previous definition: * message

*/ - LABEL_TYPE_CONFLICT(75, "label '' type mismatch with previous definition: ", ErrorSeverity.ERROR), + LABEL_TYPE_CONFLICT(75, "label type mismatch with previous definition: ", ErrorSeverity.ERROR), /** * Compiler Error 76. * *

- * return value 'name' conflicts with parameter with same name

+ * return value name conflicts with parameter with same name

*/ - RETVAL_CONFLICTS_WITH_ARG(76, "return value '' conflicts with parameter with same name", ErrorSeverity.ERROR), + RETVAL_CONFLICTS_WITH_ARG(76, "return value conflicts with parameter with same name", ErrorSeverity.ERROR), /** * Compiler Error 79. * @@ -326,38 +332,38 @@ public enum ErrorType { /** * Compiler Error 80. * - *

rule 'rule' has no defined parameters

+ *

rule rule has no defined parameters

*/ - RULE_HAS_NO_ARGS(80, "rule '' has no defined parameters", ErrorSeverity.ERROR), + RULE_HAS_NO_ARGS(80, "rule has no defined parameters", ErrorSeverity.ERROR), /** * Compiler Warning 83. * - *

unsupported option 'option'

+ *

unsupported option option

*/ - ILLEGAL_OPTION(83, "unsupported option ''", ErrorSeverity.WARNING), + ILLEGAL_OPTION(83, "unsupported option ", ErrorSeverity.WARNING), /** * Compiler Warning 84. * - *

unsupported option value 'name=value'

+ *

unsupported option value name=value

*/ - ILLEGAL_OPTION_VALUE(84, "unsupported option value '='", ErrorSeverity.WARNING), + ILLEGAL_OPTION_VALUE(84, "unsupported option value =", ErrorSeverity.WARNING), /** * Compiler Error 94. * - *

redefinition of 'action' action

+ *

redefinition of action action

*/ - ACTION_REDEFINITION(94, "redefinition of '' action", ErrorSeverity.ERROR), + ACTION_REDEFINITION(94, "redefinition of action", ErrorSeverity.ERROR), /** * Compiler Error 99. * *

This error may take any of the following forms.

* *
    - *
  • grammar 'grammar' has no rules
  • - *
  • implicitly generated grammar 'grammar' has no rules
  • + *
  • grammar grammar has no rules
  • + *
  • implicitly generated grammar grammar has no rules
  • *
*/ - NO_RULES(99, "implicitly generated grammar '' has no rules", ErrorSeverity.ERROR), + NO_RULES(99, "implicitly generated grammar has no rules", ErrorSeverity.ERROR), /** * Compiler Error 105. * @@ -369,54 +375,60 @@ public enum ErrorType { /** * Compiler Error 106. * - *

rule 'rule' is not defined in grammar 'grammar'

+ *

rule rule is not defined in grammar grammar

*/ - NO_SUCH_RULE_IN_SCOPE(106, "rule '' is not defined in grammar ''", ErrorSeverity.ERROR), + NO_SUCH_RULE_IN_SCOPE(106, "rule is not defined in grammar ", ErrorSeverity.ERROR), /** * Compiler Warning 108. * - *

token name 'Token' is already defined

+ *

token name Token is already defined

*/ - TOKEN_NAME_REASSIGNMENT(108, "token name '' is already defined", ErrorSeverity.WARNING), + TOKEN_NAME_REASSIGNMENT(108, "token name is already defined", ErrorSeverity.WARNING), /** * Compiler Warning 109. * - *

options ignored in imported grammar 'grammar'

+ *

options ignored in imported grammar grammar

*/ - OPTIONS_IN_DELEGATE(109, "options ignored in imported grammar ''", ErrorSeverity.WARNING), + OPTIONS_IN_DELEGATE(109, "options ignored in imported grammar ", ErrorSeverity.WARNING), /** * Compiler Error 110. * *

- * can't find or load grammar 'grammar' from - * 'filename'

+ * can't find or load grammar grammar from + * filename

*/ - CANNOT_FIND_IMPORTED_GRAMMAR(110, "can't find or load grammar '' from ''", ErrorSeverity.ERROR), + CANNOT_FIND_IMPORTED_GRAMMAR(110, "can't find or load grammar ", ErrorSeverity.ERROR), /** * Compiler Error 111. * *

- * grammartype grammar 'grammar1' cannot import - * grammartype grammar 'grammar2'

+ * grammartype grammar grammar1 cannot import + * grammartype grammar grammar2

*/ - INVALID_IMPORT(111, " grammar '' cannot import grammar ''", ErrorSeverity.ERROR), + INVALID_IMPORT(111, " grammar cannot import grammar ", ErrorSeverity.ERROR), /** * Compiler Error 113. * *

- * grammartype grammar 'grammar1' and imported - * grammartype grammar 'grammar2' both generate - * 'recognizer'

+ * grammartype grammar grammar1 and imported + * grammartype grammar grammar2 both generate + * recognizer

*/ - IMPORT_NAME_CLASH(113, " grammar '' and imported grammar '' both generate ''", ErrorSeverity.ERROR), + IMPORT_NAME_CLASH(113, " grammar and imported grammar both generate ", ErrorSeverity.ERROR), + /** + * Compiler Error 160. + * + *

cannot find tokens file filename

+ */ + CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR(160, "cannot find tokens file ", ErrorSeverity.ERROR), /** * Compiler Warning 118. * *

- * all operators of alt 'alt' of left-recursive rule must have same + * all operators of alt alt of left-recursive rule must have same * associativity

*/ - ALL_OPS_NEED_SAME_ASSOC(118, "all operators of alt '' of left-recursive rule must have same associativity", ErrorSeverity.WARNING), + ALL_OPS_NEED_SAME_ASSOC(118, "all operators of alt of left-recursive rule must have same associativity", ErrorSeverity.WARNING), /** * Compiler Error 119. * @@ -440,30 +452,30 @@ public enum ErrorType { /** * Compiler Error 122. * - *

rule 'rule': must label all alternatives or none

+ *

rule rule: must label all alternatives or none

*/ - RULE_WITH_TOO_FEW_ALT_LABELS(122, "rule '': must label all alternatives or none", ErrorSeverity.ERROR), + RULE_WITH_TOO_FEW_ALT_LABELS(122, "rule : must label all alternatives or none", ErrorSeverity.ERROR), /** * Compiler Error 123. * *

- * rule alt label 'label' redefined in rule 'rule1', - * originally in rule 'rule2'

+ * rule alt label label redefined in rule rule1, + * originally in rule rule2

*/ - ALT_LABEL_REDEF(123, "rule alt label '' redefined in rule '', originally in rule ''", ErrorSeverity.ERROR), + ALT_LABEL_REDEF(123, "rule alt label redefined in rule , originally in rule ", ErrorSeverity.ERROR), /** * Compiler Error 124. * *

- * rule alt label 'label' conflicts with rule 'rule'

+ * rule alt label label conflicts with rule rule

*/ - ALT_LABEL_CONFLICTS_WITH_RULE(124, "rule alt label '' conflicts with rule ''", ErrorSeverity.ERROR), + ALT_LABEL_CONFLICTS_WITH_RULE(124, "rule alt label conflicts with rule ", ErrorSeverity.ERROR), /** * Compiler Warning 125. * - *

implicit definition of token 'Token' in parser

+ *

implicit definition of token Token in parser

*/ - IMPLICIT_TOKEN_DEFINITION(125, "implicit definition of token '' in parser", ErrorSeverity.WARNING), + IMPLICIT_TOKEN_DEFINITION(125, "implicit definition of token in parser", ErrorSeverity.WARNING), /** * Compiler Error 126. * @@ -483,9 +495,9 @@ public enum ErrorType { /** * Compiler Error 130. * - *

label 'label' assigned to a block which is not a set

+ *

label label assigned to a block which is not a set

*/ - LABEL_BLOCK_NOT_A_SET(130, "label '' assigned to a block which is not a set", ErrorSeverity.ERROR), + LABEL_BLOCK_NOT_A_SET(130, "label assigned to a block which is not a set", ErrorSeverity.ERROR), /** * Compiler Warning 131. * @@ -501,97 +513,97 @@ public enum ErrorType { * Compiler Error 132. * *

- * action in lexer rule 'rule' must be last element of single + * action in lexer rule rule must be last element of single * outermost alt

* * @deprecated This error is no longer issued by ANTLR 4.2. */ @Deprecated - LEXER_ACTION_PLACEMENT_ISSUE(132, "action in lexer rule '' must be last element of single outermost alt", ErrorSeverity.ERROR), + LEXER_ACTION_PLACEMENT_ISSUE(132, "action in lexer rule must be last element of single outermost alt", ErrorSeverity.ERROR), /** * Compiler Error 133. * *

- * {@code ->command} in lexer rule 'rule' must be last element of + * {@code ->command} in lexer rule rule must be last element of * single outermost alt

*/ - LEXER_COMMAND_PLACEMENT_ISSUE(133, "->command in lexer rule '' must be last element of single outermost alt", ErrorSeverity.ERROR), + LEXER_COMMAND_PLACEMENT_ISSUE(133, "->command in lexer rule must be last element of single outermost alt", ErrorSeverity.ERROR), /** * Compiler Error 134. * *

- * symbol 'symbol' conflicts with generated code in target language + * symbol symbol conflicts with generated code in target language * or runtime

* *

* Note: This error has the same number as the unrelated error * {@link #UNSUPPORTED_REFERENCE_IN_LEXER_SET}.

*/ - USE_OF_BAD_WORD(134, "symbol '' conflicts with generated code in target language or runtime", ErrorSeverity.ERROR), + USE_OF_BAD_WORD(134, "symbol conflicts with generated code in target language or runtime", ErrorSeverity.ERROR), /** * Compiler Error 134. * - *

rule reference 'rule' is not currently supported in a set

+ *

rule reference rule is not currently supported in a set

* *

* Note: This error has the same number as the unrelated error * {@link #USE_OF_BAD_WORD}.

*/ - UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference '' is not currently supported in a set", ErrorSeverity.ERROR), + UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference is not currently supported in a set", ErrorSeverity.ERROR), /** * Compiler Error 135. * - *

cannot assign a value to list label 'label'

+ *

cannot assign a value to list label label

*/ - ASSIGNMENT_TO_LIST_LABEL(135, "cannot assign a value to list label ''", ErrorSeverity.ERROR), + ASSIGNMENT_TO_LIST_LABEL(135, "cannot assign a value to list label ", ErrorSeverity.ERROR), /** * Compiler Error 136. * - *

return value 'name' conflicts with rule with same name

+ *

return value name conflicts with rule with same name

*/ - RETVAL_CONFLICTS_WITH_RULE(136, "return value '' conflicts with rule with same name", ErrorSeverity.ERROR), + RETVAL_CONFLICTS_WITH_RULE(136, "return value conflicts with rule with same name", ErrorSeverity.ERROR), /** * Compiler Error 137. * - *

return value 'name' conflicts with token with same name

+ *

return value name conflicts with token with same name

*/ - RETVAL_CONFLICTS_WITH_TOKEN(137, "return value '' conflicts with token with same name", ErrorSeverity.ERROR), + RETVAL_CONFLICTS_WITH_TOKEN(137, "return value conflicts with token with same name", ErrorSeverity.ERROR), /** * Compiler Error 138. * - *

parameter 'parameter' conflicts with rule with same name

+ *

parameter parameter conflicts with rule with same name

*/ - ARG_CONFLICTS_WITH_RULE(138, "parameter '' conflicts with rule with same name", ErrorSeverity.ERROR), + ARG_CONFLICTS_WITH_RULE(138, "parameter conflicts with rule with same name", ErrorSeverity.ERROR), /** * Compiler Error 139. * - *

parameter 'parameter' conflicts with token with same name

+ *

parameter parameter conflicts with token with same name

*/ - ARG_CONFLICTS_WITH_TOKEN(139, "parameter '' conflicts with token with same name", ErrorSeverity.ERROR), + ARG_CONFLICTS_WITH_TOKEN(139, "parameter conflicts with token with same name", ErrorSeverity.ERROR), /** * Compiler Error 140. * - *

local 'local' conflicts with rule with same name

+ *

local local conflicts with rule with same name

*/ - LOCAL_CONFLICTS_WITH_RULE(140, "local '' conflicts with rule with same name", ErrorSeverity.ERROR), + LOCAL_CONFLICTS_WITH_RULE(140, "local conflicts with rule with same name", ErrorSeverity.ERROR), /** * Compiler Error 141. * - *

local 'local' conflicts with rule token same name

+ *

local local conflicts with rule token same name

*/ - LOCAL_CONFLICTS_WITH_TOKEN(141, "local '' conflicts with rule token same name", ErrorSeverity.ERROR), + LOCAL_CONFLICTS_WITH_TOKEN(141, "local conflicts with rule token same name", ErrorSeverity.ERROR), /** * Compiler Error 142. * - *

local 'local' conflicts with parameter with same name

+ *

local local conflicts with parameter with same name

*/ - LOCAL_CONFLICTS_WITH_ARG(142, "local '' conflicts with parameter with same name", ErrorSeverity.ERROR), + LOCAL_CONFLICTS_WITH_ARG(142, "local conflicts with parameter with same name", ErrorSeverity.ERROR), /** * Compiler Error 143. * - *

local 'local' conflicts with return value with same name

+ *

local local conflicts with return value with same name

*/ - LOCAL_CONFLICTS_WITH_RETVAL(143, "local '' conflicts with return value with same name", ErrorSeverity.ERROR), + LOCAL_CONFLICTS_WITH_RETVAL(143, "local conflicts with return value with same name", ErrorSeverity.ERROR), /** * Compiler Error 144. * @@ -604,18 +616,18 @@ public enum ErrorType { * Compiler Error 145. * *

- * lexer mode 'mode' must contain at least one non-fragment + * lexer mode mode must contain at least one non-fragment * rule

* *

* Every lexer mode must contain at least one rule which is not declared * with the {@code fragment} modifier.

*/ - MODE_WITHOUT_RULES(145, "lexer mode '' must contain at least one non-fragment rule", ErrorSeverity.ERROR), + MODE_WITHOUT_RULES(145, "lexer mode must contain at least one non-fragment rule", ErrorSeverity.ERROR), /** * Compiler Warning 146. * - *

non-fragment lexer rule 'rule' can match the empty string

+ *

non-fragment lexer rule rule can match the empty string

* *

All non-fragment lexer rules must match at least one character.

* @@ -630,12 +642,12 @@ public enum ErrorType { * Whitespace : [ \t]*; // error 146 * */ - EPSILON_TOKEN(146, "non-fragment lexer rule '' can match the empty string", ErrorSeverity.WARNING), + EPSILON_TOKEN(146, "non-fragment lexer rule can match the empty string", ErrorSeverity.WARNING), /** * Compiler Error 147. * *

- * left recursive rule 'rule' must contain an alternative which is + * left recursive rule rule must contain an alternative which is * not left recursive

* *

Left-recursive rules must contain at least one alternative which is not @@ -650,12 +662,12 @@ public enum ErrorType { * ; * */ - NO_NON_LR_ALTS(147, "left recursive rule '' must contain an alternative which is not left recursive", ErrorSeverity.ERROR), + NO_NON_LR_ALTS(147, "left recursive rule must contain an alternative which is not left recursive", ErrorSeverity.ERROR), /** * Compiler Error 148. * *

- * left recursive rule 'rule' contains a left recursive alternative + * left recursive rule rule contains a left recursive alternative * which can be followed by the empty string

* *

In left-recursive rules, all left-recursive alternatives must match at @@ -670,12 +682,12 @@ public enum ErrorType { * ; * */ - EPSILON_LR_FOLLOW(148, "left recursive rule '' contains a left recursive alternative which can be followed by the empty string", ErrorSeverity.ERROR), + EPSILON_LR_FOLLOW(148, "left recursive rule contains a left recursive alternative which can be followed by the empty string", ErrorSeverity.ERROR), /** * Compiler Error 149. * *

- * lexer command 'command' does not exist or is not supported by + * lexer command command does not exist or is not supported by * the current target

* *

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 '' does not exist or is not supported by the current target", ErrorSeverity.ERROR), + INVALID_LEXER_COMMAND(149, "lexer command does not exist or is not supported by the current target", ErrorSeverity.ERROR), /** * Compiler Error 150. * - *

missing argument for lexer command 'command'

+ *

missing argument for lexer command command

* *

Some lexer commands require an argument.

* @@ -708,11 +720,11 @@ public enum ErrorType { * * @since 4.1 */ - MISSING_LEXER_COMMAND_ARGUMENT(150, "missing argument for lexer command ''", ErrorSeverity.ERROR), + MISSING_LEXER_COMMAND_ARGUMENT(150, "missing argument for lexer command ", ErrorSeverity.ERROR), /** * Compiler Error 151. * - *

lexer command 'command' does not take any arguments

+ *

lexer command command does not take any arguments

* *

A lexer command which does not take parameters was invoked with an * argument.

@@ -726,7 +738,7 @@ public enum ErrorType { * * @since 4.1 */ - UNWANTED_LEXER_COMMAND_ARGUMENT(151, "lexer command '' does not take any arguments", ErrorSeverity.ERROR), + UNWANTED_LEXER_COMMAND_ARGUMENT(151, "lexer command does not take any arguments", ErrorSeverity.ERROR), /** * Compiler Error 152. * @@ -738,7 +750,7 @@ public enum ErrorType { * *
 	 * x : 'x'; // ok
-	 * y : 'y;  // error 152
+	 * y : 'y';  // error 152
 	 * 
* * @since 4.1 @@ -748,7 +760,7 @@ public enum ErrorType { * Compiler Error 153. * *

- * rule 'rule' contains a closure with at least one alternative + * rule rule contains a closure with at least one alternative * that can match an empty string

* *

A rule contains a closure ({@code (...)*}) or positive closure @@ -765,12 +777,12 @@ public enum ErrorType { * * @since 4.1 */ - EPSILON_CLOSURE(153, "rule '' contains a closure with at least one alternative that can match an empty string", ErrorSeverity.ERROR), + EPSILON_CLOSURE(153, "rule contains a closure with at least one alternative that can match an empty string", ErrorSeverity.ERROR), /** * Compiler Warning 154. * *

- * rule 'rule' contains an optional block with at least one + * rule rule contains an optional block with at least one * alternative that can match an empty string

* *

A rule contains an optional block ({@code (...)?}) around an empty @@ -787,12 +799,12 @@ public enum ErrorType { * * @since 4.1 */ - EPSILON_OPTIONAL(154, "rule '' contains an optional block with at least one alternative that can match an empty string", ErrorSeverity.WARNING), + EPSILON_OPTIONAL(154, "rule contains an optional block with at least one alternative that can match an empty string", ErrorSeverity.WARNING), /** * Compiler Warning 155. * *

- * rule 'rule' contains a lexer command with an unrecognized + * rule rule contains a lexer command with an unrecognized * constant value; lexer interpreters may produce incorrect output

* *

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 '' contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output", ErrorSeverity.WARNING), + UNKNOWN_LEXER_CONSTANT(155, "rule 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. * - *

rule 'rule' contains an 'assoc' element option in an + *

rule rule contains an assoc element option in an * unrecognized location

* *

@@ -851,17 +863,17 @@ public enum ErrorType { *

 	 * x : 'x'
 	 *   | x '+'<assoc=right> x   // warning 157
-	 *   |<assoc=right> x '*' x   // ok
+	 *   |<assoc=right> x * x   // ok
 	 *   ;
 	 * 
* * @since 4.2.1 */ - UNRECOGNIZED_ASSOC_OPTION(157, "rule '' contains an 'assoc' terminal option in an unrecognized location", ErrorSeverity.WARNING), + UNRECOGNIZED_ASSOC_OPTION(157, "rule contains an assoc terminal option in an unrecognized location", ErrorSeverity.WARNING), /** * Compiler Warning 158. * - *

fragment rule 'rule' contains an action or command which can + *

fragment rule rule contains an action or command which can * never be executed

* *

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 '' contains an action or command which can never be executed", ErrorSeverity.WARNING), + FRAGMENT_ACTION_IGNORED(158, "fragment rule contains an action or command which can never be executed", ErrorSeverity.WARNING), /** * Compiler Error 159. * - *

cannot declare a rule with reserved name 'rule'

+ *

cannot declare a rule with reserved name rule

* *

A rule was declared with a reserved name.

* *

The following rule produces this error.

* *
-	 * EOF : ' '   // error 159 (EOF is a reserved name)
+	 * EOF :  ' '   // error 159 (EOF is a reserved name)
 	 *     ;
 	 * 
* * @since 4.2.1 */ - RESERVED_RULE_NAME(159, "cannot declare a rule with reserved name ''", ErrorSeverity.ERROR), + RESERVED_RULE_NAME(159, "cannot declare a rule with reserved name ", ErrorSeverity.ERROR), /* * Backward incompatibility errors @@ -944,7 +956,7 @@ public enum ErrorType { * Compiler Warning 202. * *

- * '{@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

* *

@@ -956,13 +968,13 @@ public enum ErrorType { * NOTE: ANTLR 4 does not allow a trailing comma to appear following the * last token declared in the {@code tokens{}} block.

*/ - 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. * *

* assignments in {@code tokens{}} are not supported in ANTLR 4; use lexical - * rule 'TokenName : LiteralValue;' instead

+ * rule TokenName : LiteralValue; instead

* *

* 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.

*/ - V3_ASSIGN_IN_TOKENS(203, "assignments in tokens{} are not supported in ANTLR 4; use lexical rule ' : ;' instead", ErrorSeverity.ERROR), + V3_ASSIGN_IN_TOKENS(203, "assignments in tokens{} are not supported in ANTLR 4; use lexical rule : ; instead", ErrorSeverity.ERROR), /** * Compiler Warning 204. * diff --git a/tool/test/org/antlr/v4/test/TestToolSyntaxErrors.java b/tool/test/org/antlr/v4/test/TestToolSyntaxErrors.java index 35cbd1353..a793a788c 100644 --- a/tool/test/org/antlr/v4/test/TestToolSyntaxErrors.java +++ b/tool/test/org/antlr/v4/test/TestToolSyntaxErrors.java @@ -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,