public enum ErrorType extends Enum<ErrorType>
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.
Modifier and Type | Field and Description |
---|---|
int |
code
The error or warning number.
|
String |
msg
The error or warning message, in StringTemplate 4 format using
<
and > as the delimiters. |
ErrorSeverity |
severity
The error severity.
|
Modifier and Type | Method and Description |
---|---|
static ErrorType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ErrorType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ErrorType CANNOT_WRITE_FILE
cannot write file filename: reason
public static final ErrorType INVALID_CMDLINE_ARG
unknown command-line option option
public static final ErrorType CANNOT_FIND_TOKENS_FILE_GIVEN_ON_CMDLINE
cannot find tokens file filename
public static final ErrorType ERROR_READING_TOKENS_FILE
cannot find tokens file filename: reason
public static final ErrorType DIR_NOT_FOUND
directory not found: directory
public static final ErrorType OUTPUT_DIR_IS_FILE
output directory is a file: filename
public static final ErrorType CANNOT_OPEN_FILE
cannot find or open file: filename
public static final ErrorType FILE_AND_GRAMMAR_NAME_DIFFER
grammar name name and file name filename differ
public static final ErrorType BAD_OPTION_SET_SYNTAX
invalid -Dname=value
syntax: syntax
public static final ErrorType WARNING_TREATED_AS_ERROR
warning treated as error
public static final ErrorType ERROR_READING_IMPORTED_GRAMMAR
cannot find tokens file filename: reason
public static final ErrorType INTERNAL_ERROR
internal error: message
public static final ErrorType TOKENS_FILE_SYNTAX_ERROR
.tokens file syntax error filename: message
public static final ErrorType STRING_TEMPLATE_WARNING
template error: message
public static final ErrorType MISSING_CODE_GEN_TEMPLATES
can't find code generation templates: group
public static final ErrorType CANNOT_CREATE_TARGET_GENERATOR
ANTLR cannot generate language code as of version version
public static final ErrorType CODE_TEMPLATE_ARG_ISSUE
code generation template template has missing, misnamed, or incomplete arg list; missing field
public static final ErrorType CODE_GEN_TEMPLATES_INCOMPLETE
missing code generation template template
public static final ErrorType NO_MODEL_TO_TEMPLATE_MAPPING
no mapping to template name for output model class class
public static final ErrorType INCOMPATIBLE_TOOL_AND_TEMPLATES
templates/target and tool aren't compatible
public static final ErrorType SYNTAX_ERROR
syntax error: message
public static final ErrorType RULE_REDEFINITION
rule rule redefinition; previous at line line
public static final ErrorType LEXER_RULES_NOT_ALLOWED
lexer rule rule not allowed in parser
public static final ErrorType PARSER_RULES_NOT_ALLOWED
parser rule rule not allowed in lexer
public static final ErrorType REPEATED_PREQUEL
repeated grammar prequel spec (options
, tokens
, or
import
); please merge
public static final ErrorType UNDEFINED_RULE_REF
reference to undefined rule: rule
PARSER_RULE_REF_IN_LEXER_RULE
public static final ErrorType UNDEFINED_RULE_IN_NONLOCAL_REF
reference to undefined rule rule in non-local ref reference
public static final ErrorType TOKEN_NAMES_MUST_START_UPPER
token names must start with an uppercase letter: name
public static final ErrorType UNKNOWN_SIMPLE_ATTRIBUTE
unknown attribute reference attribute in expression
public static final ErrorType INVALID_RULE_PARAMETER_REF
parameter parameter of rule rule is not accessible in this scope: expression
public static final ErrorType UNKNOWN_RULE_ATTRIBUTE
unknown attribute attribute for rule rule in expression
public static final ErrorType UNKNOWN_ATTRIBUTE_IN_SCOPE
attribute attribute isn't a valid property in expression
public static final ErrorType ISOLATED_RULE_REF
missing attribute access on rule reference rule in expression
public static final ErrorType LABEL_CONFLICTS_WITH_RULE
label label conflicts with rule with same name
public static final ErrorType LABEL_CONFLICTS_WITH_TOKEN
label label conflicts with token with same name
public static final ErrorType LABEL_CONFLICTS_WITH_ARG
label label conflicts with parameter with same name
public static final ErrorType LABEL_CONFLICTS_WITH_RETVAL
label label conflicts with return value with same name
public static final ErrorType LABEL_CONFLICTS_WITH_LOCAL
label label conflicts with local with same name
public static final ErrorType LABEL_TYPE_CONFLICT
label label type mismatch with previous definition: message
public static final ErrorType RETVAL_CONFLICTS_WITH_ARG
return value name conflicts with parameter with same name
public static final ErrorType MISSING_RULE_ARGS
missing argument(s) on rule reference: rule
public static final ErrorType RULE_HAS_NO_ARGS
rule rule has no defined parameters
public static final ErrorType ILLEGAL_OPTION
unsupported option option
public static final ErrorType ILLEGAL_OPTION_VALUE
unsupported option value name=value
public static final ErrorType ACTION_REDEFINITION
redefinition of action action
public static final ErrorType NO_RULES
This error may take any of the following forms.
public static final ErrorType NO_SUCH_GRAMMAR_SCOPE
reference to undefined grammar in rule reference: grammar.rule
public static final ErrorType NO_SUCH_RULE_IN_SCOPE
rule rule is not defined in grammar grammar
public static final ErrorType TOKEN_NAME_REASSIGNMENT
token name Token is already defined
public static final ErrorType OPTIONS_IN_DELEGATE
options ignored in imported grammar grammar
public static final ErrorType CANNOT_FIND_IMPORTED_GRAMMAR
can't find or load grammar grammar from filename
public static final ErrorType INVALID_IMPORT
grammartype grammar grammar1 cannot import grammartype grammar grammar2
public static final ErrorType IMPORT_NAME_CLASH
grammartype grammar grammar1 and imported grammartype grammar grammar2 both generate recognizer
public static final ErrorType CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR
cannot find tokens file filename
@Deprecated public static final ErrorType ALL_OPS_NEED_SAME_ASSOC
all operators of alt alt of left-recursive rule must have same associativity
public static final ErrorType LEFT_RECURSION_CYCLES
The following sets of rules are mutually left-recursive [rules]
public static final ErrorType MODE_NOT_IN_LEXER
lexical modes are only allowed in lexer grammars
public static final ErrorType CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL
cannot find an attribute name in attribute declaration
public static final ErrorType RULE_WITH_TOO_FEW_ALT_LABELS
rule rule: must label all alternatives or none
public static final ErrorType ALT_LABEL_REDEF
rule alt label label redefined in rule rule1, originally in rule rule2
public static final ErrorType ALT_LABEL_CONFLICTS_WITH_RULE
rule alt label label conflicts with rule rule
public static final ErrorType IMPLICIT_TOKEN_DEFINITION
implicit definition of token Token in parser
public static final ErrorType IMPLICIT_STRING_DEFINITION
cannot create implicit token for string literal in non-combined grammar: literal
public static final ErrorType ATTRIBUTE_IN_LEXER_ACTION
attribute references not allowed in lexer actions: expression
public static final ErrorType LABEL_BLOCK_NOT_A_SET
label label assigned to a block which is not a set
public static final ErrorType EXPECTED_NON_GREEDY_WILDCARD_BLOCK
This warning may take any of the following forms.
()*
contains wildcard; the non-greedy syntax ()*?
may be preferred()+
contains wildcard; the non-greedy syntax ()+?
may be preferred@Deprecated public static final ErrorType LEXER_ACTION_PLACEMENT_ISSUE
action in lexer rule rule must be last element of single outermost alt
public static final ErrorType LEXER_COMMAND_PLACEMENT_ISSUE
->command
in lexer rule rule must be last element of
single outermost alt
public static final ErrorType USE_OF_BAD_WORD
symbol symbol conflicts with generated code in target language or runtime
Note: This error has the same number as the unrelated error
UNSUPPORTED_REFERENCE_IN_LEXER_SET
.
public static final ErrorType UNSUPPORTED_REFERENCE_IN_LEXER_SET
rule reference rule is not currently supported in a set
Note: This error has the same number as the unrelated error
USE_OF_BAD_WORD
.
public static final ErrorType ASSIGNMENT_TO_LIST_LABEL
cannot assign a value to list label label
public static final ErrorType RETVAL_CONFLICTS_WITH_RULE
return value name conflicts with rule with same name
public static final ErrorType RETVAL_CONFLICTS_WITH_TOKEN
return value name conflicts with token with same name
public static final ErrorType ARG_CONFLICTS_WITH_RULE
parameter parameter conflicts with rule with same name
public static final ErrorType ARG_CONFLICTS_WITH_TOKEN
parameter parameter conflicts with token with same name
public static final ErrorType LOCAL_CONFLICTS_WITH_RULE
local local conflicts with rule with same name
public static final ErrorType LOCAL_CONFLICTS_WITH_TOKEN
local local conflicts with rule token same name
public static final ErrorType LOCAL_CONFLICTS_WITH_ARG
local local conflicts with parameter with same name
public static final ErrorType LOCAL_CONFLICTS_WITH_RETVAL
local local conflicts with return value with same name
public static final ErrorType INVALID_LITERAL_IN_LEXER_SET
multi-character literals are not allowed in lexer sets: literal
public static final ErrorType MODE_WITHOUT_RULES
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 fragment
modifier.
public static final ErrorType EPSILON_TOKEN
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
public static final ErrorType NO_NON_LR_ALTS
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 ;
public static final ErrorType EPSILON_LR_FOLLOW
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) ;
public static final ErrorType INVALID_LEXER_COMMAND
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)
public static final ErrorType MISSING_LEXER_COMMAND_ARGUMENT
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)
public static final ErrorType UNWANTED_LEXER_COMMAND_ARGUMENT
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)
public static final ErrorType UNTERMINATED_STRING_LITERAL
unterminated string literal
The grammar contains an unterminated string literal.
The following rule produces this error.
x : 'x'; // ok y : 'y'; // error 152
public static final ErrorType EPSILON_CLOSURE
rule rule contains a closure with at least one alternative that can match an empty string
A rule contains a closure ((...)*
) or positive closure
((...)+
) 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
public static final ErrorType EPSILON_OPTIONAL
rule rule contains an optional block with at least one alternative that can match an empty string
A rule contains an optional block ((...)?
) 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
public static final ErrorType UNKNOWN_LEXER_CONSTANT
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
public static final ErrorType INVALID_ESCAPE_SEQUENCE
invalid escape sequence
The grammar contains a string literal with an invalid escape sequence.
The following rule produces this error.
x : 'x'; // ok y : '\u'; // error 156
public static final ErrorType UNRECOGNIZED_ASSOC_OPTION
rule rule contains an assoc element option in an unrecognized location
In ANTLR 4.2, the position of the assoc
element option was moved
from the operator terminal(s) to the alternative itself. This warning is
reported when an 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 ;
public static final ErrorType FRAGMENT_ACTION_IGNORED
fragment rule rule contains an action or command which can never be executed
A lexer rule which is marked with the 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 ;
public static final ErrorType RESERVED_RULE_NAME
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) ;
public static final ErrorType PARSER_RULE_REF_IN_LEXER_RULE
reference to parser rule rule in lexer rule name
UNDEFINED_RULE_REF
public static final ErrorType CHANNEL_CONFLICTS_WITH_TOKEN
channel name conflicts with token with same name
public static final ErrorType CHANNEL_CONFLICTS_WITH_MODE
channel name conflicts with mode with same name
public static final ErrorType CHANNELS_BLOCK_IN_PARSER_GRAMMAR
custom channels are not supported in parser grammars
public static final ErrorType CHANNELS_BLOCK_IN_COMBINED_GRAMMAR
custom channels are not supported in combined grammars
public static final ErrorType NONCONFORMING_LR_RULE
public static final ErrorType MODE_CONFLICTS_WITH_TOKEN
mode M1; A1: 'a'; // ok mode M2; A2: 'a'; // ok M1: 'b'; // error 170
mode name conflicts with token with same name
public static final ErrorType TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS
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
public static final ErrorType CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS
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
public static final ErrorType MODE_CONFLICTS_WITH_COMMON_CONSTANTS
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
public static final ErrorType EMPTY_STRINGS_AND_SETS_NOT_ALLOWED
empty strings not allowed
A: '''test'''; B: ''; C: 'test' ''; D: []; E: [f-a];
public static final ErrorType CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_TOKEN_NAME
name is not a recognized token name
TOKEN: 'a' -> type(CHANNEL1); // error 175
public static final ErrorType CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_MODE_NAME
nameis not a recognized mode name
TOKEN: 'a' -> mode(MODE1); // error 176
public static final ErrorType CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME
name is not a recognized channel name
TOKEN: 'a' -> channel(TOKEN1); // error 177
public static final ErrorType DUPLICATED_COMMAND
public static final ErrorType INCOMPATIBLE_COMMANDS
public static final ErrorType CHARACTERS_COLLISION_IN_SET
chars "a-f" used multiple times in set [a-fc-m]
A: [aa-z]; // warning B: [a-fc-m]; // warningTODO: Does not work with fragment rules.
public static final ErrorType TOKEN_RANGE_IN_PARSER
The token range operator makes no sense in the parser as token types are not ordered (except in implementation).
grammar T; a : 'A'..'Z' ;
public static final ErrorType UNICODE_PROPERTY_NOT_ALLOWED_IN_RANGE
Unicode properties cannot be part of a lexer charset range
A: [\\p{Letter}-\\p{Number}];
public static final ErrorType TOKEN_UNREACHABLE
The token value overlapped by another token or self
TOKEN1: 'value'; TOKEN2: 'value'; // warning
public static final ErrorType V3_TREE_GRAMMAR
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.
public static final ErrorType V3_LEXER_LABEL
labels in lexer rules are not supported in ANTLR 4; actions cannot
reference elements of lexical rules but you can use
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.
public static final ErrorType V3_TOKENS_SYNTAX
tokens {A; B;}
syntax is now tokens {A, B}
in ANTLR
4
ANTLR 4 uses comma-separated token declarations in the 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 tokens{}
block.
public static final ErrorType V3_ASSIGN_IN_TOKENS
assignments in 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 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 tokens{}
block should be converted to
standard lexer rules.
public static final ErrorType V3_GATED_SEMPRED
{...}?=>
explicitly gated semantic predicates are deprecated in
ANTLR 4; use {...}?
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.
public static final ErrorType V3_SYNPRED
(...)=>
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.
public final String msg
<
and >
as the delimiters. Arguments for the message may be
referenced using the following names:
arg
: The first template argumentarg2
: The second template argumentarg3
: The third template argumentverbose
: true
if verbose messages were requested; otherwise, false
exception
: The exception which resulted in the error, if any.stackTrace
: The stack trace for the exception, when available.public final int code
The code should be unique, and following its use in a release should not be altered or reassigned.
public final ErrorSeverity severity
public static ErrorType[] values()
for (ErrorType c : ErrorType.values()) System.out.println(c);
public static ErrorType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullCopyright © 1992–2020 ANTLR. All rights reserved.