All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.antlr.v4.tool.ErrorType Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show newest version
/*
 * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
 * Use of this file is governed by the BSD 3-clause license that
 * can be found in the LICENSE.txt file in the project root.
 */
package org.antlr.v4.tool;

import org.antlr.v4.Tool;
import org.antlr.v4.runtime.Lexer;

/**
 * A complex enumeration of all the error messages that the tool can issue.
 * 

* When adding error messages, also add a description of the message to the * Wiki with a location under the Wiki page * Errors Reported by the ANTLR Tool. * * @author Jim Idle <[email protected]>, Terence Parr * @since 4.0 */ public enum ErrorType { /* * Tool errors */ /** * Compiler Error 1. * *

cannot write file filename: reason

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

unknown command-line option option

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

cannot find tokens file filename

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

*/ ERROR_READING_TOKENS_FILE(4, "error reading tokens file : ", ErrorSeverity.ERROR), /** * Compiler Error 5. * *

directory not found: directory

*/ DIR_NOT_FOUND(5, "directory not found: ", ErrorSeverity.ERROR), /** * Compiler Error 6. * *

output directory is a file: filename

*/ OUTPUT_DIR_IS_FILE(6, "output directory is a file: ", ErrorSeverity.ERROR), /** * Compiler Error 7. * *

cannot find or open file: filename

*/ CANNOT_OPEN_FILE(7, "cannot find or open file: ; reason: ", ErrorSeverity.ERROR), /** * Compiler Error 8. * *

* grammar name name and file name filename differ

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

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

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

internal error: message

*/ INTERNAL_ERROR(20, "internal error: : " + "", ErrorSeverity.ERROR), /** * Compiler Error 21. * *

.tokens file syntax error filename: message

*/ TOKENS_FILE_SYNTAX_ERROR(21, ".tokens file syntax error :", ErrorSeverity.ERROR), /** * Compiler Warning 22. * *

template error: message

*/ STRING_TEMPLATE_WARNING(22, "template error: : " + "", ErrorSeverity.WARNING), /* * Code generation errors */ /** * Compiler Error 30. * *

can't find code generation templates: group

*/ MISSING_CODE_GEN_TEMPLATES(30, "can't find code generation templates: ", ErrorSeverity.ERROR), /** * Compiler Error 31. * *

* 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_ONE_OFF), /** * Compiler Error 32. * *

* 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), /** * Compiler Error 33. * *

missing code generation template template

*/ 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_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class ", ErrorSeverity.ERROR), /** * Compiler Error 35. * *

templates/target and tool aren't compatible

*/ INCOMPATIBLE_TOOL_AND_TEMPLATES(35, " code generation target requires ANTLR ; it can't be loaded by the current ANTLR ", ErrorSeverity.ERROR), /* * Grammar errors */ /** * Compiler Error 50. * *

syntax error: message

*/ SYNTAX_ERROR(50, "syntax error: ", ErrorSeverity.ERROR), /** * Compiler Error 51. * *

rule rule redefinition; previous at line line

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

lexer rule rule not allowed in parser

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

parser rule rule not allowed in lexer

*/ PARSER_RULES_NOT_ALLOWED(53, "parser rule not allowed in lexer", ErrorSeverity.ERROR), /** * Compiler Error 54. * *

* repeated grammar prequel spec ({@code options}, {@code tokens}, or * {@code import}); please merge

*/ REPEATED_PREQUEL(54, "repeated grammar prequel spec (options, tokens, or import); please merge", ErrorSeverity.ERROR), /** * Compiler Error 56. * *

reference to undefined rule: rule

* * @see #PARSER_RULE_REF_IN_LEXER_RULE */ UNDEFINED_RULE_REF(56, "reference to undefined rule: ", ErrorSeverity.ERROR), /** * Compiler Error 57. * *

* 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), /** * Compiler Error 60. * *

token names must start with an uppercase letter: name

*/ TOKEN_NAMES_MUST_START_UPPER(60, "token names must start with an uppercase letter: ", ErrorSeverity.ERROR), /** * Compiler Error 63. * *

* unknown attribute reference attribute in * expression

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

* 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), /** * Compiler Error 65. * *

* unknown attribute attribute for rule rule in * expression

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

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

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

*/ 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_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_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_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_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_CONFLICTS_WITH_LOCAL(74, "label conflicts with local with same name", ErrorSeverity.ERROR), /** * Compiler Error 75. * *

* label label type mismatch with previous definition: * message

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

* return value name conflicts with parameter with same name

*/ RETVAL_CONFLICTS_WITH_ARG(76, "return value conflicts with parameter with same name", ErrorSeverity.ERROR), /** * Compiler Error 79. * *

missing argument(s) on rule reference: rule

*/ MISSING_RULE_ARGS(79, "missing argument(s) on rule reference: ", ErrorSeverity.ERROR), /** * Compiler Error 80. * *

rule rule has no defined parameters

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

unsupported option option

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

unsupported option value name=value

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

redefinition of action action

*/ 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
  • *
*/ NO_RULES(99, "implicitly generated grammar has no rules", ErrorSeverity.ERROR), /** * Compiler Error 105. * *

* reference to undefined grammar in rule reference: * grammar.rule

*/ NO_SUCH_GRAMMAR_SCOPE(105, "reference to undefined grammar in rule reference: .", ErrorSeverity.ERROR), /** * Compiler Error 106. * *

rule rule is not defined in grammar grammar

*/ 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_REASSIGNMENT(108, "token name is already defined", ErrorSeverity.WARNING), /** * Compiler Warning 109. * *

options ignored in imported grammar grammar

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

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

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

* grammartype grammar grammar1 cannot import * grammartype grammar grammar2

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

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

*/ IMPORT_NAME_CLASH(113, " grammar and imported grammar both generate ", ErrorSeverity.ERROR), /** * Compiler Error 114. * *

cannot find tokens file filename

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

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

* * @deprecated This warning is no longer applicable with the current syntax for specifying associativity. */ @Deprecated ALL_OPS_NEED_SAME_ASSOC(118, "all operators of alt of left-recursive rule must have same associativity", ErrorSeverity.WARNING), /** * Compiler Error 119. * *

* The following sets of rules are mutually left-recursive * [rules]

*/ LEFT_RECURSION_CYCLES(119, "The following sets of rules are mutually left-recursive }; separator=\", \">]}; separator=\" and \">", ErrorSeverity.ERROR), /** * Compiler Error 120. * *

lexical modes are only allowed in lexer grammars

*/ MODE_NOT_IN_LEXER(120, "lexical modes are only allowed in lexer grammars", ErrorSeverity.ERROR), /** * Compiler Error 121. * *

cannot find an attribute name in attribute declaration

*/ CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL(121, "cannot find an attribute name in attribute declaration", ErrorSeverity.ERROR), /** * Compiler Error 122. * *

rule rule: must label all alternatives or none

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

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

*/ 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_TOKEN_DEFINITION(125, "implicit definition of token in parser", ErrorSeverity.WARNING), /** * Compiler Error 126. * *

* cannot create implicit token for string literal in non-combined grammar: * literal

*/ IMPLICIT_STRING_DEFINITION(126, "cannot create implicit token for string literal in non-combined grammar: ", ErrorSeverity.ERROR), /** * Compiler Error 128. * *

* attribute references not allowed in lexer actions: * expression

*/ ATTRIBUTE_IN_LEXER_ACTION(128, "attribute references not allowed in lexer actions: $", ErrorSeverity.ERROR), /** * Compiler Error 130. * *

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), /** * Compiler Warning 131. * *

This warning may take any of the following forms.

* *
    *
  • greedy block {@code ()*} contains wildcard; the non-greedy syntax {@code ()*?} may be preferred
  • *
  • greedy block {@code ()+} contains wildcard; the non-greedy syntax {@code ()+?} may be preferred
  • *
*/ EXPECTED_NON_GREEDY_WILDCARD_BLOCK(131, "greedy block () contains wildcard; the non-greedy syntax ()? may be preferred", ErrorSeverity.WARNING), /** * Compiler Error 132. * *

* 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), /** * Compiler Error 133. * *

* {@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), /** * Compiler Error 134. * *

* 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), /** * Compiler Error 183. * *

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(183, "rule reference is not currently supported in a set", ErrorSeverity.ERROR), /** * Compiler Error 135. * *

cannot assign a value to list label label

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

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

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

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

*/ 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_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_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_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_CONFLICTS_WITH_RETVAL(143, "local conflicts with return value with same name", ErrorSeverity.ERROR), /** * Compiler Error 144. * *

* multi-character literals are not allowed in lexer sets: * literal

*/ INVALID_LITERAL_IN_LEXER_SET(144, "multi-character literals are not allowed in lexer sets: ", ErrorSeverity.ERROR), /** * Compiler Error 145. * *

* 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), /** * Compiler Warning 146. * *

non-fragment lexer rule rule can match the empty string

* *

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

* *

The following example shows this error.

* *
	 * Whitespace : [ \t]+;  // ok
	 * Whitespace : [ \t];   // ok
	 *
	 * fragment WS : [ \t]*; // ok
	 *
	 * Whitespace : [ \t]*;  // error 146
	 * 
*/ 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 * not left recursive

* *

Left-recursive rules must contain at least one alternative which is not * left recursive.

* *

The following rule produces this error.

* *
	 * // error 147:
	 * a : a ID
	 *   | a INT
	 *   ;
	 * 
*/ 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 * which can be followed by the empty string

* *

In left-recursive rules, all left-recursive alternatives must match at * least one symbol following the recursive rule invocation.

* *

The following rule produces this error.

* *
	 * 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)
	 *   ;
	 * 
*/ 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 * the current target

* *

Each lexer command requires an explicit implementation in the target * templates. This error indicates that the command was incorrectly written * or is not supported by the current target.

* *

The following rule produces this error.

* *
	 * X : 'foo' -> type(Foo);  // ok
	 * Y : 'foo' -> token(Foo); // error 149 (token is not a supported lexer command)
	 * 
* * @since 4.1 */ 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

* *

Some lexer commands require an argument.

* *

The following rule produces this error.

* *
	 * X : 'foo' -> type(Foo); // ok
	 * Y : 'foo' -> type;      // error 150 (the type command requires an argument)
	 * 
* * @since 4.1 */ MISSING_LEXER_COMMAND_ARGUMENT(150, "missing argument for lexer command ", ErrorSeverity.ERROR), /** * Compiler Error 151. * *

lexer command command does not take any arguments

* *

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

* *

The following rule produces this error.

* *
	 * X : 'foo' -> popMode;    // ok
	 * Y : 'foo' -> popMode(A); // error 151 (the popMode command does not take an argument)
	 * 
* * @since 4.1 */ UNWANTED_LEXER_COMMAND_ARGUMENT(151, "lexer command does not take any arguments", ErrorSeverity.ERROR), /** * Compiler Error 152. * *

unterminated string literal

* *

The grammar contains an unterminated string literal.

* *

The following rule produces this error.

* *
	 * x : 'x'; // ok
	 * y : 'y';  // error 152
	 * 
* * @since 4.1 */ UNTERMINATED_STRING_LITERAL(152, "unterminated string literal", ErrorSeverity.ERROR), /** * Compiler Error 153. * *

* 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 * ({@code (...)+}) around an empty alternative.

* *

The following rule produces this error.

* *
	 * x  : ;
	 * y  : x+;                                // error 153
	 * z1 : ('foo' | 'bar'? 'bar2'?)*;         // error 153
	 * z2 : ('foo' | 'bar' 'bar2'? | 'bar2')*; // ok
	 * 
* * @since 4.1 */ 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 * alternative that can match an empty string

* *

A rule contains an optional block ({@code (...)?}) around an empty * alternative.

* *

The following rule produces this warning.

* *
	 * x  : ;
	 * y  : x?;                                // warning 154
	 * z1 : ('foo' | 'bar'? 'bar2'?)?;         // warning 154
	 * z2 : ('foo' | 'bar' 'bar2'? | 'bar2')?; // ok
	 * 
* * @since 4.1 */ 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 * constant value; lexer interpreters may produce incorrect output

* *

A lexer rule contains a standard lexer command, but the constant value * argument for the command is an unrecognized string. As a result, the * lexer command will be translated as a custom lexer action, preventing the * command from executing in some interpreted modes. The output of the lexer * interpreter may not match the output of the generated lexer.

* *

The following rule produces this warning.

* *
	 * @members {
	 * public static final int CUSTOM = HIDDEN + 1;
	 * }
	 *
	 * X : 'foo' -> channel(HIDDEN);           // ok
	 * Y : 'bar' -> channel(CUSTOM);           // warning 155
	 * 
* * @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), /** * Compiler Error 156. * *

invalid escape sequence

* *

The grammar contains a string literal with an invalid escape sequence.

* *

The following rule produces this error.

* *
	 * x : 'x';  // ok
	 * y : '\u005Cu'; // error 156
	 * 
* * @since 4.2.1 */ INVALID_ESCAPE_SEQUENCE(156, "invalid escape sequence ", ErrorSeverity.WARNING), /** * Compiler Warning 157. * *

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

* *

* In ANTLR 4.2, the position of the {@code assoc} element option was moved * from the operator terminal(s) to the alternative itself. This warning is * reported when an {@code assoc} element option is specified on a grammar * element that is not recognized by the current version of ANTLR, and as a * result will simply be ignored. *

* *

The following rule produces this warning.

* *
	 * x : 'x'
	 *   | x '+'<assoc=right> x   // warning 157
	 *   |<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), /** * Compiler Warning 158. * *

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

* *

A lexer rule which is marked with the {@code fragment} modifier * contains an embedded action or lexer command. ANTLR lexers only execute * commands and embedded actions located in the top-level matched rule. * Since fragment rules can never be the top-level rule matched by a lexer, * actions or commands placed in these rules can never be executed during * the lexing process.

* *

The following rule produces this warning.

* *
	 * X1 : 'x' -> more    // ok
	 *    ;
	 * Y1 : 'x' {more();}  // ok
	 *    ;
	 * fragment
	 * X2 : 'x' -> more    // warning 158
	 *    ;
	 * fragment
	 * Y2 : 'x' {more();}  // warning 158
	 *    ;
	 * 
* * @since 4.2.1 */ 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

* *

A rule was declared with a reserved name.

* *

The following rule produces this error.

* *
	 * 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), /** * Compiler Error 160. * *

reference to parser rule rule in lexer rule name

* * @see #UNDEFINED_RULE_REF */ PARSER_RULE_REF_IN_LEXER_RULE(160, "reference to parser rule in lexer rule ", ErrorSeverity.ERROR), /** * Compiler Error 161. * *

channel name conflicts with token with same name

*/ CHANNEL_CONFLICTS_WITH_TOKEN(161, "channel conflicts with token with same name", ErrorSeverity.ERROR), /** * Compiler Error 162. * *

channel name conflicts with mode with same name

*/ CHANNEL_CONFLICTS_WITH_MODE(162, "channel conflicts with mode with same name", ErrorSeverity.ERROR), /** * Compiler Error 163. * *

custom channels are not supported in parser grammars

*/ CHANNELS_BLOCK_IN_PARSER_GRAMMAR(163, "custom channels are not supported in parser grammars", ErrorSeverity.ERROR), /** * Compiler Error 164. * *

custom channels are not supported in combined grammars

*/ CHANNELS_BLOCK_IN_COMBINED_GRAMMAR(164, "custom channels are not supported in combined grammars", ErrorSeverity.ERROR), NONCONFORMING_LR_RULE(169, "rule is left recursive but doesn't conform to a pattern ANTLR can handle", ErrorSeverity.ERROR), /** * Compiler Error 170. * *
	 * mode M1;
	 * A1: 'a'; // ok
	 * mode M2;
	 * A2: 'a'; // ok
	 * M1: 'b'; // error 170
	 * 
* *

mode name conflicts with token with same name

*/ MODE_CONFLICTS_WITH_TOKEN(170, "mode conflicts with token with same name", ErrorSeverity.ERROR), /** * Compiler Error 171. * *

can not use or declare token with reserved name

* *

Reserved names: HIDDEN, DEFAULT_TOKEN_CHANNEL, SKIP, MORE, MAX_CHAR_VALUE, MIN_CHAR_VALUE. * *

Can be used but cannot be declared: EOF

*/ TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS(171, "cannot use or declare token with reserved name ", ErrorSeverity.ERROR), /** * Compiler Error 172. * *

can not use or declare channel with reserved name

* *

Reserved names: DEFAULT_MODE, SKIP, MORE, EOF, MAX_CHAR_VALUE, MIN_CHAR_VALUE. * *

Can be used but cannot be declared: HIDDEN, DEFAULT_TOKEN_CHANNEL

*/ CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS(172, "cannot use or declare channel with reserved name ", ErrorSeverity.ERROR), /** * Compiler Error 173. * *

can not use or declare mode with reserved name

* *

Reserved names: HIDDEN, DEFAULT_TOKEN_CHANNEL, SKIP, MORE, MAX_CHAR_VALUE, MIN_CHAR_VALUE. * *

Can be used and cannot declared: DEFAULT_MODE

*/ MODE_CONFLICTS_WITH_COMMON_CONSTANTS(173, "cannot use or declare mode with reserved name ", ErrorSeverity.ERROR), /** * Compiler Error 174. * *

empty strings not allowed

* *
	 * A: '''test''';
	 * B: '';
	 * C: 'test' '';
	 * D: [];
	 * E: [f-a];
	 * 
*/ EMPTY_STRINGS_AND_SETS_NOT_ALLOWED(174, "string literals and sets cannot be empty: ", ErrorSeverity.ERROR), /** * Compiler Error 175. * *

name is not a recognized token name

* *
TOKEN: 'a' -> type(CHANNEL1); // error 175
*/ CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_TOKEN_NAME(175, " is not a recognized token name", ErrorSeverity.ERROR), /** * Compiler Error 176. * *

nameis not a recognized mode name

* *
TOKEN: 'a' -> mode(MODE1); // error 176
*/ CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_MODE_NAME(176, " is not a recognized mode name", ErrorSeverity.ERROR), /** * Compiler Error 177. * *

name is not a recognized channel name

* *
TOKEN: 'a' -> channel(TOKEN1); // error 177
*/ CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME(177, " is not a recognized channel name", ErrorSeverity.ERROR), /* * Compiler Warning 178. * *

lexer rule has a duplicated commands

* *

TOKEN: 'asdf' -> mode(MODE1), mode(MODE2);

* */ DUPLICATED_COMMAND(178, "duplicated command ", ErrorSeverity.WARNING), /* * Compiler Waring 179. * *

incompatible commands command1 and command2

* *

T00: 'a00' -> skip, more;

*/ INCOMPATIBLE_COMMANDS(179, "incompatible commands and ", ErrorSeverity.WARNING), /** * Compiler Warning 180. * *

chars "a-f" used multiple times in set [a-fc-m]

* *
	 * A:    [aa-z];   // warning
	 * B:    [a-fc-m]; // warning
	 * 
* * TODO: Does not work with fragment rules. */ CHARACTERS_COLLISION_IN_SET(180, "chars used multiple times in set ", ErrorSeverity.WARNING), /** * Compiler Warning 181 * *

The token range operator makes no sense in the parser as token types * are not ordered (except in implementation). *

* *
	 * grammar T;
	 * a : 'A'..'Z' ;
	 * 
* */ TOKEN_RANGE_IN_PARSER(181, "token ranges not allowed in parser: ..", ErrorSeverity.ERROR), /** * Compiler Error 182. * *

Unicode properties cannot be part of a lexer charset range

* *
	 * A: [\\p{Letter}-\\p{Number}];
	 * 
*/ UNICODE_PROPERTY_NOT_ALLOWED_IN_RANGE( 182, "unicode property escapes not allowed in lexer charset range: ", ErrorSeverity.ERROR), /** * Compiler Warning 184. * *

The token value overlapped by another token or self

* *
	 * TOKEN1: 'value';
	 * TOKEN2: 'value'; // warning
	 * 
*/ TOKEN_UNREACHABLE( 184, "One of the token values unreachable. is always overlapped by token ", ErrorSeverity.WARNING), /* * Backward incompatibility errors */ /** * Compiler Error 200. * *

tree grammars are not supported in ANTLR 4

* *

* This error message is provided as a compatibility notice for users * migrating from ANTLR 3. ANTLR 4 does not support tree grammars, but * instead offers automatically generated parse tree listeners and visitors * as a more maintainable alternative.

*/ V3_TREE_GRAMMAR(200, "tree grammars are not supported in ANTLR 4", ErrorSeverity.ERROR), /** * Compiler Warning 201. * *

* labels in lexer rules are not supported in ANTLR 4; actions cannot * reference elements of lexical rules but you can use * {@link Lexer#getText()} to get the entire text matched for the rule

* *

* ANTLR 4 uses a DFA for recognition of entire tokens, resulting in faster * and smaller lexers than ANTLR 3 produced. As a result, sub-rules * referenced within lexer rules are not tracked independently, and cannot * be assigned to labels.

*/ V3_LEXER_LABEL(201, "labels in lexer rules are not supported in ANTLR 4; " + "actions cannot reference elements of lexical rules but you can use " + "getText() to get the entire text matched for the rule", ErrorSeverity.WARNING), /** * Compiler Warning 202. * *

* {@code tokens {A; B;}} syntax is now {@code tokens {A, B}} in ANTLR * 4

* *

* ANTLR 4 uses comma-separated token declarations in the {@code tokens{}} * block. This warning appears when the tokens block is written using the * ANTLR 3 syntax of semicolon-terminated token declarations.

* *

* 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), /** * Compiler Error 203. * *

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

* *

* ANTLR 3 allowed literal tokens to be declared and assigned a value within * the {@code tokens{}} block. ANTLR 4 no longer offers this syntax. When * migrating a grammar from ANTLR 3 to ANTLR 4, any tokens with a literal * 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), /** * Compiler Warning 204. * *

* {@code {...}?=>} explicitly gated semantic predicates are deprecated in * ANTLR 4; use {@code {...}?} instead

* *

* ANTLR 4 treats semantic predicates consistently in a manner similar to * gated semantic predicates in ANTLR 3. When migrating a grammar from ANTLR * 3 to ANTLR 4, all uses of the gated semantic predicate syntax can be * safely converted to the standard semantic predicated syntax, which is the * only form used by ANTLR 4.

*/ V3_GATED_SEMPRED(204, "{...}?=> explicitly gated semantic predicates are deprecated in ANTLR 4; use {...}? instead", ErrorSeverity.WARNING), /** * Compiler Error 205. * *

{@code (...)=>} syntactic predicates are not supported in ANTLR 4

* *

* ANTLR 4's improved lookahead algorithms do not require the use of * syntactic predicates to disambiguate long lookahead sequences. The * syntactic predicates should be removed when migrating a grammar from * ANTLR 3 to ANTLR 4.

*/ V3_SYNPRED(205, "(...)=> syntactic predicates are not supported in ANTLR 4", ErrorSeverity.ERROR), // Dependency sorting errors /** t1.g4 -> t2.g4 -> t3.g4 ->t1.g4 */ //CIRCULAR_DEPENDENCY(200, "your grammars contain a circular dependency and cannot be sorted into a valid build order", ErrorSeverity.ERROR), ; /** * The error or warning message, in StringTemplate 4 format using {@code <} * and {@code >} as the delimiters. Arguments for the message may be * referenced using the following names: * *
    *
  • {@code arg}: The first template argument
  • *
  • {@code arg2}: The second template argument
  • *
  • {@code arg3}: The third template argument
  • *
  • {@code verbose}: {@code true} if verbose messages were requested; otherwise, {@code false}
  • *
  • {@code exception}: The exception which resulted in the error, if any.
  • *
  • {@code stackTrace}: The stack trace for the exception, when available.
  • *
*/ public final String msg; /** * The error or warning number. * *

The code should be unique, and following its * use in a release should not be altered or reassigned.

*/ public final int code; /** * The error severity. */ public final ErrorSeverity severity; /** * Constructs a new {@link ErrorType} with the specified code, message, and * severity. * * @param code The unique error number. * @param msg The error message template. * @param severity The error severity. */ ErrorType(int code, String msg, ErrorSeverity severity) { this.code = code; this.msg = msg; this.severity = severity; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy