| java.lang.Object org.antlr.tool.ErrorManager
ErrorManager | public class ErrorManager (Code) | | Defines all the errors ANTLR can generator for both the tool and for
issues with a grammar.
Here is a list of language names:
http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt
Here is a list of country names:
http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
I use constants not strings to identify messages as the compiler will
find any errors/mismatches rather than leaving a mistyped string in
the code to be found randomly in the future. Further, Intellij can
do field name expansion to save me some typing. I have to map
int constants to template names, however, which could introduce a mismatch.
Someone could provide a .stg file that had a template name wrong. When
I load the group, then, I must verify that all messages are there.
This is essentially the functionality of the resource bundle stuff Java
has, but I don't want to load a property file--I want to load a template
group file and this is so simple, why mess with their junk.
I use the default Locale as defined by java to compute a group file name
in the org/antlr/tool/templates/messages dir called en_US.stg and so on.
Normally we want to use the default locale, but often a message file will
not exist for it so we must fall back on the US local.
During initialization of this class, all errors go straight to System.err.
There is no way around this. If I have not set up the error system, how
can I do errors properly? For example, if the string template group file
full of messages has an error, how could I print to anything but System.err?
TODO: how to map locale to a file encoding for the stringtemplate group file?
StringTemplate knows how to pay attention to the default encoding so it
should probably just work unless a GUI sets the local to some chinese
variation but System.getProperty("file.encoding") is US. Hmm...
TODO: get antlr.g etc.. parsing errors to come here.
|
Inner Class :static class ErrorState | |
Method Summary | |
public static void | analysisAborted(DecisionProbe probe) | public static void | assertTrue(boolean condition, String message) | public static void | danglingState(DecisionProbe probe, DFAState d) | public static boolean | doNotAttemptAnalysis() | public static boolean | doNotAttemptCodeGen() | public static void | error(int msgID) | public static void | error(int msgID, Throwable e) | public static void | error(int msgID, Object arg) | public static void | error(int msgID, Object arg, Object arg2) | public static void | error(int msgID, Object arg, Throwable e) | public static boolean | formatWantsSingleLineMessage() | public static ANTLRErrorListener | getErrorListener() | public static ErrorState | getErrorState() | public static StringTemplate | getLocationFormat() Return a StringTemplate that refers to the current format used for
emitting messages. | public static StringTemplate | getMessage(int msgID) Given a message ID, return a StringTemplate that somebody can fill
with data. | public static StringTemplate | getMessageFormat() | public static String | getMessageType(int msgID) | public static StringTemplate | getReportFormat() | public static StringTemplateErrorListener | getStringTemplateErrorListener() | public static void | grammarError(int msgID, Grammar g, Token token, Object arg, Object arg2) | public static void | grammarError(int msgID, Grammar g, Token token, Object arg) | public static void | grammarError(int msgID, Grammar g, Token token) | public static void | grammarWarning(int msgID, Grammar g, Token token, Object arg, Object arg2) | public static void | grammarWarning(int msgID, Grammar g, Token token, Object arg) | public static void | grammarWarning(int msgID, Grammar g, Token token) | public static void | info(String msg) | protected static boolean | initIdToMessageNameMapping() | public static void | insufficientPredicates(DecisionProbe probe, List alts) | public static void | internalError(Object error, Throwable e) | public static void | internalError(Object error) | public static void | leftRecursionCycles(Collection cycles) | public static void | nonLLStarDecision(DecisionProbe probe) | public static void | nondeterminism(DecisionProbe probe, DFAState d) | public static void | panic() I *think* this will allow Tool subclasses to exit gracefully
for GUIs etc... | static void | rawError(String msg) If there are errors during ErrorManager init, we have no choice
but to go to System.err. | static void | rawError(String msg, Throwable e) | public static void | recursionOverflow(DecisionProbe probe, DFAState sampleBadState, int alt, Collection targetRules, Collection callSiteStates) | public static void | resetErrorState() | public static void | setErrorListener(ANTLRErrorListener listener) In general, you'll want all errors to go to a single spot.
However, in a GUI, you might have two frames up with two
different grammars. | public static void | setFormat(String formatName) The format gets reset either from the Tool if the user supplied a command line option to that effect
Otherwise we just use the default "antlr". | public static void | setLocale(Locale locale) We really only need a single locale for entire running ANTLR code
in a single VM. | public static void | setTool(Tool tool) | public static void | syntaxError(int msgID, Grammar grammar, Token token, Object arg, antlr.RecognitionException re) | public static void | unreachableAlts(DecisionProbe probe, List alts) | protected static boolean | verifyFormat() | protected static boolean | verifyMessages() Use reflection to find list of MSG_ fields and then verify a
template exists for each one from the locale's group. | public static void | warning(int msgID, Object arg) |
ERRORS_FORCING_NO_ANALYSIS | final public static BitSet ERRORS_FORCING_NO_ANALYSIS(Code) | | Do not do perform analysis and code gen if one of these happens
|
ERRORS_FORCING_NO_CODEGEN | final public static BitSet ERRORS_FORCING_NO_CODEGEN(Code) | | Do not do perform analysis and code gen if one of these happens
|
MAX_MESSAGE_NUMBER | final public static int MAX_MESSAGE_NUMBER(Code) | | |
MSG_ACTION_REDEFINITION | final public static int MSG_ACTION_REDEFINITION(Code) | | |
MSG_AMBIGUOUS_RULE_SCOPE | final public static int MSG_AMBIGUOUS_RULE_SCOPE(Code) | | |
MSG_ANALYSIS_ABORTED | final public static int MSG_ANALYSIS_ABORTED(Code) | | |
MSG_ARGS_ON_TOKEN_REF | final public static int MSG_ARGS_ON_TOKEN_REF(Code) | | |
MSG_ARG_INIT_VALUES_ILLEGAL | final public static int MSG_ARG_INIT_VALUES_ILLEGAL(Code) | | |
MSG_ARG_RETVAL_CONFLICT | final public static int MSG_ARG_RETVAL_CONFLICT(Code) | | |
MSG_ATTRIBUTE_CONFLICTS_WITH_RULE | final public static int MSG_ATTRIBUTE_CONFLICTS_WITH_RULE(Code) | | |
MSG_ATTRIBUTE_CONFLICTS_WITH_RULE_ARG_RETVAL | final public static int MSG_ATTRIBUTE_CONFLICTS_WITH_RULE_ARG_RETVAL(Code) | | |
MSG_ATTRIBUTE_REF_NOT_IN_RULE | final public static int MSG_ATTRIBUTE_REF_NOT_IN_RULE(Code) | | |
MSG_BAD_ACTION_AST_STRUCTURE | final public static int MSG_BAD_ACTION_AST_STRUCTURE(Code) | | |
MSG_BAD_AST_STRUCTURE | final public static int MSG_BAD_AST_STRUCTURE(Code) | | |
MSG_CANNOT_ALIAS_TOKENS_IN_LEXER | final public static int MSG_CANNOT_ALIAS_TOKENS_IN_LEXER(Code) | | |
MSG_CANNOT_CLOSE_FILE | final public static int MSG_CANNOT_CLOSE_FILE(Code) | | |
MSG_CANNOT_CREATE_TARGET_GENERATOR | final public static int MSG_CANNOT_CREATE_TARGET_GENERATOR(Code) | | |
MSG_CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL | final public static int MSG_CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL(Code) | | |
MSG_CANNOT_FIND_TOKENS_FILE | final public static int MSG_CANNOT_FIND_TOKENS_FILE(Code) | | |
MSG_CANNOT_GEN_DOT_FILE | final public static int MSG_CANNOT_GEN_DOT_FILE(Code) | | |
MSG_CANNOT_OPEN_FILE | final public static int MSG_CANNOT_OPEN_FILE(Code) | | |
MSG_CANNOT_WRITE_FILE | final public static int MSG_CANNOT_WRITE_FILE(Code) | | |
MSG_CODE_GEN_TEMPLATES_INCOMPLETE | final public static int MSG_CODE_GEN_TEMPLATES_INCOMPLETE(Code) | | |
MSG_DANGLING_STATE | final public static int MSG_DANGLING_STATE(Code) | | |
MSG_DIR_NOT_FOUND | final public static int MSG_DIR_NOT_FOUND(Code) | | |
MSG_DOUBLE_QUOTES_ILLEGAL | final public static int MSG_DOUBLE_QUOTES_ILLEGAL(Code) | | |
MSG_DUPLICATE_SET_ENTRY | final public static int MSG_DUPLICATE_SET_ENTRY(Code) | | |
MSG_EMPTY_COMPLEMENT | final public static int MSG_EMPTY_COMPLEMENT(Code) | | |
MSG_ERROR_CREATING_ARTIFICIAL_RULE | final public static int MSG_ERROR_CREATING_ARTIFICIAL_RULE(Code) | | |
MSG_ERROR_READING_TOKENS_FILE | final public static int MSG_ERROR_READING_TOKENS_FILE(Code) | | |
MSG_FILENAME_EXTENSION_ERROR | final public static int MSG_FILENAME_EXTENSION_ERROR(Code) | | |
MSG_FILE_AND_GRAMMAR_NAME_DIFFER | final public static int MSG_FILE_AND_GRAMMAR_NAME_DIFFER(Code) | | |
MSG_FORWARD_ELEMENT_REF | final public static int MSG_FORWARD_ELEMENT_REF(Code) | | |
MSG_GRAMMAR_NONDETERMINISM | final public static int MSG_GRAMMAR_NONDETERMINISM(Code) | | |
MSG_ILLEGAL_OPTION | final public static int MSG_ILLEGAL_OPTION(Code) | | |
MSG_INSUFFICIENT_PREDICATES | final public static int MSG_INSUFFICIENT_PREDICATES(Code) | | |
MSG_INTERNAL_ERROR | final public static int MSG_INTERNAL_ERROR(Code) | | |
MSG_INTERNAL_WARNING | final public static int MSG_INTERNAL_WARNING(Code) | | |
MSG_INVALID_ACTION_SCOPE | final public static int MSG_INVALID_ACTION_SCOPE(Code) | | |
MSG_INVALID_RULE_PARAMETER_REF | final public static int MSG_INVALID_RULE_PARAMETER_REF(Code) | | |
MSG_INVALID_RULE_SCOPE_ATTRIBUTE_REF | final public static int MSG_INVALID_RULE_SCOPE_ATTRIBUTE_REF(Code) | | |
MSG_INVALID_TEMPLATE_ACTION | final public static int MSG_INVALID_TEMPLATE_ACTION(Code) | | |
MSG_ISOLATED_RULE_ATTRIBUTE | final public static int MSG_ISOLATED_RULE_ATTRIBUTE(Code) | | |
MSG_ISOLATED_RULE_SCOPE | final public static int MSG_ISOLATED_RULE_SCOPE(Code) | | |
MSG_LABEL_CONFLICTS_WITH_RULE | final public static int MSG_LABEL_CONFLICTS_WITH_RULE(Code) | | |
MSG_LABEL_CONFLICTS_WITH_RULE_ARG_RETVAL | final public static int MSG_LABEL_CONFLICTS_WITH_RULE_ARG_RETVAL(Code) | | |
MSG_LABEL_CONFLICTS_WITH_RULE_SCOPE_ATTRIBUTE | final public static int MSG_LABEL_CONFLICTS_WITH_RULE_SCOPE_ATTRIBUTE(Code) | | |
MSG_LABEL_CONFLICTS_WITH_TOKEN | final public static int MSG_LABEL_CONFLICTS_WITH_TOKEN(Code) | | |
MSG_LABEL_TYPE_CONFLICT | final public static int MSG_LABEL_TYPE_CONFLICT(Code) | | |
MSG_LEFT_RECURSION | final public static int MSG_LEFT_RECURSION(Code) | | |
MSG_LEFT_RECURSION_CYCLES | final public static int MSG_LEFT_RECURSION_CYCLES(Code) | | |
MSG_LEXER_RULES_NOT_ALLOWED | final public static int MSG_LEXER_RULES_NOT_ALLOWED(Code) | | |
MSG_LIST_LABEL_INVALID_UNLESS_RETVAL_STRUCT | final public static int MSG_LIST_LABEL_INVALID_UNLESS_RETVAL_STRUCT(Code) | | |
MSG_LITERAL_NOT_ASSOCIATED_WITH_LEXER_RULE | final public static int MSG_LITERAL_NOT_ASSOCIATED_WITH_LEXER_RULE(Code) | | |
MSG_MISSING_AST_TYPE_IN_TREE_GRAMMAR | final public static int MSG_MISSING_AST_TYPE_IN_TREE_GRAMMAR(Code) | | |
MSG_MISSING_ATTRIBUTE_NAME | final public static int MSG_MISSING_ATTRIBUTE_NAME(Code) | | |
MSG_MISSING_CODE_GEN_TEMPLATES | final public static int MSG_MISSING_CODE_GEN_TEMPLATES(Code) | | |
MSG_MISSING_CYCLIC_DFA_CODE_GEN_TEMPLATES | final public static int MSG_MISSING_CYCLIC_DFA_CODE_GEN_TEMPLATES(Code) | | |
MSG_MISSING_RULE_ARGS | final public static int MSG_MISSING_RULE_ARGS(Code) | | |
MSG_NONREGULAR_DECISION | final public static int MSG_NONREGULAR_DECISION(Code) | | |
MSG_NONUNIQUE_REF | final public static int MSG_NONUNIQUE_REF(Code) | | |
MSG_NO_GRAMMAR_START_RULE | final public static int MSG_NO_GRAMMAR_START_RULE(Code) | | |
MSG_NO_RULES | final public static int MSG_NO_RULES(Code) | | |
MSG_NO_TOKEN_DEFINITION | final public static int MSG_NO_TOKEN_DEFINITION(Code) | | |
MSG_OUTPUT_DIR_IS_FILE | final public static int MSG_OUTPUT_DIR_IS_FILE(Code) | | |
MSG_PARSER_RULES_NOT_ALLOWED | final public static int MSG_PARSER_RULES_NOT_ALLOWED(Code) | | |
MSG_RECURSION_OVERLOW | final public static int MSG_RECURSION_OVERLOW(Code) | | |
MSG_REWRITE_ELEMENT_NOT_PRESENT_ON_LHS | final public static int MSG_REWRITE_ELEMENT_NOT_PRESENT_ON_LHS(Code) | | |
MSG_REWRITE_FOR_MULTI_ELEMENT_ALT | final public static int MSG_REWRITE_FOR_MULTI_ELEMENT_ALT(Code) | | |
MSG_REWRITE_OR_OP_WITH_NO_OUTPUT_OPTION | final public static int MSG_REWRITE_OR_OP_WITH_NO_OUTPUT_OPTION(Code) | | |
MSG_RULE_HAS_NO_ARGS | final public static int MSG_RULE_HAS_NO_ARGS(Code) | | |
MSG_RULE_INVALID_SET | final public static int MSG_RULE_INVALID_SET(Code) | | |
MSG_RULE_REDEFINITION | final public static int MSG_RULE_REDEFINITION(Code) | | |
MSG_SYMBOL_CONFLICTS_WITH_GLOBAL_SCOPE | final public static int MSG_SYMBOL_CONFLICTS_WITH_GLOBAL_SCOPE(Code) | | |
MSG_SYNTAX_ERROR | final public static int MSG_SYNTAX_ERROR(Code) | | |
MSG_TOKENS_FILE_SYNTAX_ERROR | final public static int MSG_TOKENS_FILE_SYNTAX_ERROR(Code) | | |
MSG_TOKEN_NONDETERMINISM | final public static int MSG_TOKEN_NONDETERMINISM(Code) | | |
MSG_UNDEFINED_LABEL_REF_IN_REWRITE | final public static int MSG_UNDEFINED_LABEL_REF_IN_REWRITE(Code) | | |
MSG_UNDEFINED_RULE_REF | final public static int MSG_UNDEFINED_RULE_REF(Code) | | |
MSG_UNDEFINED_TOKEN_REF_IN_REWRITE | final public static int MSG_UNDEFINED_TOKEN_REF_IN_REWRITE(Code) | | |
MSG_UNKNOWN_ATTRIBUTE_IN_SCOPE | final public static int MSG_UNKNOWN_ATTRIBUTE_IN_SCOPE(Code) | | |
MSG_UNKNOWN_DYNAMIC_SCOPE | final public static int MSG_UNKNOWN_DYNAMIC_SCOPE(Code) | | |
MSG_UNKNOWN_DYNAMIC_SCOPE_ATTRIBUTE | final public static int MSG_UNKNOWN_DYNAMIC_SCOPE_ATTRIBUTE(Code) | | |
MSG_UNKNOWN_RULE_ATTRIBUTE | final public static int MSG_UNKNOWN_RULE_ATTRIBUTE(Code) | | |
MSG_UNKNOWN_SIMPLE_ATTRIBUTE | final public static int MSG_UNKNOWN_SIMPLE_ATTRIBUTE(Code) | | |
MSG_UNREACHABLE_ALTS | final public static int MSG_UNREACHABLE_ALTS(Code) | | |
MSG_UNREACHABLE_TOKENS | final public static int MSG_UNREACHABLE_TOKENS(Code) | | |
MSG_WRITE_TO_READONLY_ATTR | final public static int MSG_WRITE_TO_READONLY_ATTR(Code) | | |
blankSTListener | static StringTemplateErrorListener blankSTListener(Code) | | During verification of the messages group file, don't gen errors.
I'll handle them here. This is used only after file has loaded ok
and only for the messages STG.
|
emitSingleError | final public static Map emitSingleError(Code) | | Only one error can be emitted for any entry in this table.
Map where the key is a method name like danglingState.
The set is whatever that method accepts or derives like a DFA.
|
initSTListener | static StringTemplateErrorListener initSTListener(Code) | | Handle all ST error listeners here (code gen, Grammar, and this class
use templates.
|
theDefaultSTListener | static StringTemplateErrorListener theDefaultSTListener(Code) | | Errors during initialization related to ST must all go to System.err.
|
assertTrue | public static void assertTrue(boolean condition, String message)(Code) | | |
doNotAttemptAnalysis | public static boolean doNotAttemptAnalysis()(Code) | | |
doNotAttemptCodeGen | public static boolean doNotAttemptCodeGen()(Code) | | |
error | public static void error(int msgID)(Code) | | |
formatWantsSingleLineMessage | public static boolean formatWantsSingleLineMessage()(Code) | | |
getErrorState | public static ErrorState getErrorState()(Code) | | |
getLocationFormat | public static StringTemplate getLocationFormat()(Code) | | Return a StringTemplate that refers to the current format used for
emitting messages.
|
getMessage | public static StringTemplate getMessage(int msgID)(Code) | | Given a message ID, return a StringTemplate that somebody can fill
with data. We need to convert the int ID to the name of a template
in the messages ST group.
|
getMessageFormat | public static StringTemplate getMessageFormat()(Code) | | |
getMessageType | public static String getMessageType(int msgID)(Code) | | |
getReportFormat | public static StringTemplate getReportFormat()(Code) | | |
getStringTemplateErrorListener | public static StringTemplateErrorListener getStringTemplateErrorListener()(Code) | | |
grammarError | public static void grammarError(int msgID, Grammar g, Token token, Object arg)(Code) | | |
grammarError | public static void grammarError(int msgID, Grammar g, Token token)(Code) | | |
grammarWarning | public static void grammarWarning(int msgID, Grammar g, Token token, Object arg)(Code) | | |
grammarWarning | public static void grammarWarning(int msgID, Grammar g, Token token)(Code) | | |
initIdToMessageNameMapping | protected static boolean initIdToMessageNameMapping()(Code) | | |
internalError | public static void internalError(Object error)(Code) | | |
leftRecursionCycles | public static void leftRecursionCycles(Collection cycles)(Code) | | |
panic | public static void panic()(Code) | | I *think* this will allow Tool subclasses to exit gracefully
for GUIs etc...
|
rawError | static void rawError(String msg)(Code) | | If there are errors during ErrorManager init, we have no choice
but to go to System.err.
|
resetErrorState | public static void resetErrorState()(Code) | | |
setErrorListener | public static void setErrorListener(ANTLRErrorListener listener)(Code) | | In general, you'll want all errors to go to a single spot.
However, in a GUI, you might have two frames up with two
different grammars. Two threads might launch to process the
grammars--you would want errors to go to different objects
depending on the thread. I store a single listener per
thread.
|
setFormat | public static void setFormat(String formatName)(Code) | | The format gets reset either from the Tool if the user supplied a command line option to that effect
Otherwise we just use the default "antlr".
|
setLocale | public static void setLocale(Locale locale)(Code) | | We really only need a single locale for entire running ANTLR code
in a single VM. Only pay attention to the language, not the country
so that French Canadians and French Frenchies all get the same
template file, fr.stg. Just easier this way.
|
setTool | public static void setTool(Tool tool)(Code) | | |
syntaxError | public static void syntaxError(int msgID, Grammar grammar, Token token, Object arg, antlr.RecognitionException re)(Code) | | |
verifyFormat | protected static boolean verifyFormat()(Code) | | Verify the message format template group
|
verifyMessages | protected static boolean verifyMessages()(Code) | | Use reflection to find list of MSG_ fields and then verify a
template exists for each one from the locale's group.
|
warning | public static void warning(int msgID, Object arg)(Code) | | |
|
|