Package org.antlr.tool
Class LeftRecursiveRuleAnalyzer
- java.lang.Object
-
- org.antlr.runtime.BaseRecognizer
-
- org.antlr.runtime.tree.TreeParser
-
- org.antlr.grammar.v3.LeftRecursiveRuleWalker
-
- org.antlr.tool.LeftRecursiveRuleAnalyzer
-
public class LeftRecursiveRuleAnalyzer extends LeftRecursiveRuleWalker
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LeftRecursiveRuleAnalyzer.ASSOC
-
Nested classes/interfaces inherited from class org.antlr.grammar.v3.LeftRecursiveRuleWalker
LeftRecursiveRuleWalker.outerAlternative_return, LeftRecursiveRuleWalker.ruleBlock_return
-
-
Field Summary
Fields Modifier and Type Field Description java.util.Map<java.lang.Integer,LeftRecursiveRuleAnalyzer.ASSOC>
altAssociativity
java.util.LinkedHashMap<java.lang.Integer,java.lang.String>
binaryAlts
Grammar
g
CodeGenerator
generator
java.lang.String
language
java.util.List<java.lang.String>
otherAlts
java.util.List<java.lang.String>
prefixAlts
org.stringtemplate.v4.STGroup
recRuleTemplates
GrammarAST
retvals
java.lang.String
ruleName
java.util.LinkedHashMap<java.lang.Integer,java.lang.String>
suffixAlts
java.util.LinkedHashMap<java.lang.Integer,java.lang.String>
ternaryAlts
-
Fields inherited from class org.antlr.grammar.v3.LeftRecursiveRuleWalker
ACTION, ACTION_CHAR_LITERAL, ACTION_ESC, ACTION_STRING_LITERAL, ALT, AMPERSAND, ARG, ARG_ACTION, ARGLIST, ASSIGN, BACKTRACK_SEMPRED, BANG, BLOCK, CATCH, CHAR_LITERAL, CHAR_RANGE, CLOSE_ELEMENT_OPTION, CLOSURE, COLON, COMBINED_GRAMMAR, COMMA, COMMENT, DIGIT, DOC_COMMENT, DOLLAR, DOT, DOUBLE_ANGLE_STRING_LITERAL, DOUBLE_QUOTE_STRING_LITERAL, EOA, EOB, EOF, EOR, EPSILON, ESC, ETC, FINALLY, FOLLOW_ACTION_in_element1365, FOLLOW_ACTION_in_exceptionHandler1200, FOLLOW_ACTION_in_finallyClause1215, FOLLOW_ACTION_in_rewrite1254, FOLLOW_ACTION_in_ruleScopeSpec288, FOLLOW_ALT_in_binary814, FOLLOW_ALT_in_binaryMultipleOp851, FOLLOW_ALT_in_binaryMultipleOp873, FOLLOW_ALT_in_block413, FOLLOW_ALT_in_outerAlternative760, FOLLOW_ALT_in_prefix949, FOLLOW_ALT_in_rewrite1241, FOLLOW_ALT_in_suffix985, FOLLOW_ALT_in_ternary909, FOLLOW_AMPERSAND_in_rec_rule215, FOLLOW_ARG_ACTION_in_atom1487, FOLLOW_ARG_ACTION_in_atom1497, FOLLOW_ARG_ACTION_in_exceptionHandler1198, FOLLOW_ARG_ACTION_in_rec_rule184, FOLLOW_ARG_ACTION_in_rec_rule194, FOLLOW_ARG_in_rec_rule182, FOLLOW_ASSIGN_in_element1319, FOLLOW_ASSIGN_in_option73, FOLLOW_ASSIGN_in_recurse1018, FOLLOW_ASSIGN_in_token1068, FOLLOW_atom_in_atom1524, FOLLOW_atom_in_element1293, FOLLOW_atom_in_element1310, FOLLOW_atom_in_element1312, FOLLOW_BACKTRACK_SEMPRED_in_binary818, FOLLOW_BACKTRACK_SEMPRED_in_binaryMultipleOp855, FOLLOW_BACKTRACK_SEMPRED_in_element1380, FOLLOW_BACKTRACK_SEMPRED_in_prefix953, FOLLOW_BACKTRACK_SEMPRED_in_suffix989, FOLLOW_BACKTRACK_SEMPRED_in_ternary913, FOLLOW_BANG_in_element1285, FOLLOW_BANG_in_token1111, FOLLOW_binary_in_outerAlternative544, FOLLOW_binary_in_synpred2_LeftRecursiveRuleWalker530, FOLLOW_binaryMultipleOp_in_outerAlternative488, FOLLOW_binaryMultipleOp_in_synpred1_LeftRecursiveRuleWalker484, FOLLOW_BLOCK_in_binaryMultipleOp867, FOLLOW_BLOCK_in_block381, FOLLOW_block_in_ebnf1402, FOLLOW_block_in_ebnf1416, FOLLOW_block_in_ebnf1433, FOLLOW_block_in_ebnf1451, FOLLOW_block_in_element1353, FOLLOW_BLOCK_in_ruleBlock315, FOLLOW_CATCH_in_exceptionHandler1196, FOLLOW_CHAR_LITERAL_in_atom1504, FOLLOW_CHAR_LITERAL_in_charSetElement115, FOLLOW_CHAR_LITERAL_in_charSetElement123, FOLLOW_CHAR_LITERAL_in_charSetElement125, FOLLOW_CHAR_LITERAL_in_charSetElement134, FOLLOW_CHAR_LITERAL_in_charSetElement136, FOLLOW_CHAR_LITERAL_in_token1125, FOLLOW_CLOSURE_in_ebnf1431, FOLLOW_DOT_in_atom1520, FOLLOW_ebnf_in_element1340, FOLLOW_element_in_block415, FOLLOW_element_in_element1278, FOLLOW_element_in_element1287, FOLLOW_element_in_element1301, FOLLOW_element_in_element1323, FOLLOW_element_in_element1334, FOLLOW_element_in_outerAlternative762, FOLLOW_element_in_prefix966, FOLLOW_element_in_suffix1001, FOLLOW_element_in_tree_1471, FOLLOW_EOA_in_binary834, FOLLOW_EOA_in_binaryMultipleOp879, FOLLOW_EOA_in_binaryMultipleOp894, FOLLOW_EOA_in_block418, FOLLOW_EOA_in_outerAlternative765, FOLLOW_EOA_in_prefix972, FOLLOW_EOA_in_suffix1005, FOLLOW_EOA_in_ternary933, FOLLOW_EOB_in_binaryMultipleOp888, FOLLOW_EOB_in_block439, FOLLOW_EOB_in_ruleBlock358, FOLLOW_EOR_in_rec_rule239, FOLLOW_EPSILON_in_element1390, FOLLOW_ETC_in_rewrite1256, FOLLOW_exceptionGroup_in_rec_rule233, FOLLOW_exceptionHandler_in_exceptionGroup1172, FOLLOW_FINALLY_in_finallyClause1213, FOLLOW_finallyClause_in_exceptionGroup1175, FOLLOW_finallyClause_in_exceptionGroup1181, FOLLOW_FORCED_ACTION_in_element1360, FOLLOW_GATED_SEMPRED_in_element1385, FOLLOW_ID_in_atom1522, FOLLOW_ID_in_element1321, FOLLOW_ID_in_element1332, FOLLOW_ID_in_option75, FOLLOW_ID_in_rec_rule168, FOLLOW_ID_in_recurse1020, FOLLOW_ID_in_recurse1031, FOLLOW_ID_in_ruleScopeSpec291, FOLLOW_ID_in_token1070, FOLLOW_ID_in_token1085, FOLLOW_modifier_in_rec_rule175, FOLLOW_NOT_in_element1299, FOLLOW_option_in_optionsSpec59, FOLLOW_OPTIONAL_in_ebnf1414, FOLLOW_OPTIONS_in_optionsSpec57, FOLLOW_optionsSpec_in_block395, FOLLOW_optionsSpec_in_rec_rule201, FOLLOW_optionsSpec_in_ruleBlock320, FOLLOW_optionValue_in_option77, FOLLOW_OR_in_charSetElement121, FOLLOW_outerAlternative_in_ruleBlock328, FOLLOW_PLUS_ASSIGN_in_element1330, FOLLOW_PLUS_ASSIGN_in_recurse1029, FOLLOW_PLUS_ASSIGN_in_token1083, FOLLOW_POSITIVE_CLOSURE_in_ebnf1449, FOLLOW_prefix_in_outerAlternative662, FOLLOW_prefix_in_synpred4_LeftRecursiveRuleWalker648, FOLLOW_RANGE_in_charSetElement132, FOLLOW_RANGE_in_element1308, FOLLOW_recurse_in_binary832, FOLLOW_recurse_in_binaryMultipleOp892, FOLLOW_recurse_in_prefix970, FOLLOW_recurse_in_ternary927, FOLLOW_recurse_in_ternary931, FOLLOW_recurseNoLabel_in_binary826, FOLLOW_recurseNoLabel_in_binaryMultipleOp863, FOLLOW_recurseNoLabel_in_recurse1022, FOLLOW_recurseNoLabel_in_recurse1033, FOLLOW_recurseNoLabel_in_recurse1039, FOLLOW_recurseNoLabel_in_suffix997, FOLLOW_recurseNoLabel_in_ternary921, FOLLOW_RET_in_rec_rule192, FOLLOW_rewrite_in_block421, FOLLOW_REWRITE_in_rewrite1234, FOLLOW_rewrite_in_ruleBlock340, FOLLOW_REWRITES_in_rewrite1228, FOLLOW_ROOT_in_element1276, FOLLOW_ROOT_in_token1098, FOLLOW_RULE_in_rec_rule164, FOLLOW_RULE_REF_in_atom1485, FOLLOW_RULE_REF_in_recurseNoLabel1051, FOLLOW_ruleBlock_in_rec_rule226, FOLLOW_ruleScopeSpec_in_rec_rule207, FOLLOW_SCOPE_in_ruleScopeSpec286, FOLLOW_SEMPRED_in_element1370, FOLLOW_SEMPRED_in_rewrite1236, FOLLOW_STRING_LITERAL_in_atom1509, FOLLOW_STRING_LITERAL_in_token1139, FOLLOW_suffix_in_outerAlternative718, FOLLOW_suffix_in_synpred5_LeftRecursiveRuleWalker704, FOLLOW_SYN_SEMPRED_in_element1375, FOLLOW_SYNPRED_in_element1351, FOLLOW_TEMPLATE_in_rewrite1248, FOLLOW_ternary_in_outerAlternative606, FOLLOW_ternary_in_synpred3_LeftRecursiveRuleWalker593, FOLLOW_token_in_binary830, FOLLOW_token_in_binaryMultipleOp877, FOLLOW_token_in_ternary925, FOLLOW_token_in_ternary929, FOLLOW_token_in_token1074, FOLLOW_token_in_token1089, FOLLOW_token_in_token1102, FOLLOW_token_in_token1115, FOLLOW_TOKEN_REF_in_atom1495, FOLLOW_TOKEN_REF_in_token1151, FOLLOW_tree__in_element1345, FOLLOW_TREE_BEGIN_in_tree_1469, FOLLOW_WILDCARD_in_atom1514, FORCED_ACTION, FRAGMENT, GATED_SEMPRED, grammar, GRAMMAR, ID, IMPLIES, IMPORT, INITACTION, INT, LABEL, LEXER, LEXER_GRAMMAR, LPAREN, ML_COMMENT, NESTED_ACTION, NESTED_ARG_ACTION, NOT, numAlts, OPEN_ELEMENT_OPTION, OPTIONAL, OPTIONS, OR, PARSER, PARSER_GRAMMAR, PLUS, PLUS_ASSIGN, POSITIVE_CLOSURE, PREC_RULE, PRIVATE, PROTECTED, PUBLIC, QUESTION, RANGE, RCURLY, RECURSIVE_RULE_REF, RET, RETURNS, REWRITE, REWRITES, ROOT, RPAREN, RULE, RULE_REF, SCOPE, SEMI, SEMPRED, SL_COMMENT, SRC, STAR, STRAY_BRACKET, STRING_LITERAL, SYN_SEMPRED, SYNPRED, TEMPLATE, THROWS, TOKEN_REF, tokenNames, TOKENS, TREE, TREE_BEGIN, TREE_GRAMMAR, WILDCARD, WS, WS_LOOP, WS_OPT, XDIGIT
-
-
Constructor Summary
Constructors Constructor Description LeftRecursiveRuleAnalyzer(org.antlr.runtime.tree.TreeNodeStream input, Grammar g, java.lang.String ruleName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
binaryAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
void
fillRetValAssignments(org.stringtemplate.v4.ST ruleST, java.lang.String srcName)
java.lang.String
getArtificialOpPrecRule()
java.lang.String
getArtificialPrecStartRule()
java.lang.String
getArtificialPrimaryRule()
java.util.Collection<java.lang.String>
getNamesFromArgAction(org.antlr.runtime.Token t)
static boolean
hasImmediateRecursiveRuleRefs(GrammarAST t, java.lang.String ruleName)
void
loadPrecRuleTemplates()
int
nextPrecedence(int alt)
void
otherAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
int
precedence(int alt)
void
prefixAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
GrammarAST
replaceLastRuleRef(GrammarAST t, java.lang.String name)
GrammarAST
replaceRuleRefs(GrammarAST t, java.lang.String name)
void
setReturnValues(GrammarAST t)
void
setTokenPrec(GrammarAST t, int alt)
void
stripLeftRecursion(GrammarAST altAST)
void
stripSynPred(GrammarAST altAST)
void
suffixAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
void
ternaryAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
Convert e ? e : e → ? e : e_[nextPrec]java.lang.String
text(GrammarAST t)
java.lang.String
toString()
-
Methods inherited from class org.antlr.grammar.v3.LeftRecursiveRuleWalker
ast_suffix, atom, binary, binaryMultipleOp, block, charSetElement, ebnf, element, exceptionGroup, exceptionHandler, finallyClause, getDelegates, getGrammarFileName, getTokenNames, modifier, option, optionsSpec, optionValue, outerAlternative, prefix, rec_rule, recurse, recurseNoLabel, reportError, rewrite, ruleBlock, ruleScopeSpec, suffix, synpred1_LeftRecursiveRuleWalker, synpred1_LeftRecursiveRuleWalker_fragment, synpred2_LeftRecursiveRuleWalker, synpred2_LeftRecursiveRuleWalker_fragment, synpred3_LeftRecursiveRuleWalker, synpred3_LeftRecursiveRuleWalker_fragment, synpred4_LeftRecursiveRuleWalker, synpred4_LeftRecursiveRuleWalker_fragment, synpred5_LeftRecursiveRuleWalker, synpred5_LeftRecursiveRuleWalker_fragment, ternary, token, tree_
-
Methods inherited from class org.antlr.runtime.tree.TreeParser
getAncestor, getCurrentInputSymbol, getErrorHeader, getErrorMessage, getMissingSymbol, getSourceName, getTreeNodeStream, inContext, inContext, matchAny, recoverFromMismatchedToken, reset, setTreeNodeStream, traceIn, traceOut
-
Methods inherited from class org.antlr.runtime.BaseRecognizer
alreadyParsedRule, beginResync, combineFollows, computeContextSensitiveRuleFOLLOW, computeErrorRecoverySet, consumeUntil, consumeUntil, displayRecognitionError, emitErrorMessage, endResync, failed, getBacktrackingLevel, getNumberOfSyntaxErrors, getRuleInvocationStack, getRuleInvocationStack, getRuleMemoization, getRuleMemoizationCacheSize, getTokenErrorDisplay, match, memoize, mismatchIsMissingToken, mismatchIsUnwantedToken, pushFollow, recover, recoverFromMismatchedSet, setBacktrackingLevel, toStrings, traceIn, traceOut
-
-
-
-
Field Detail
-
g
public Grammar g
-
generator
public CodeGenerator generator
-
ruleName
public java.lang.String ruleName
-
binaryAlts
public java.util.LinkedHashMap<java.lang.Integer,java.lang.String> binaryAlts
-
ternaryAlts
public java.util.LinkedHashMap<java.lang.Integer,java.lang.String> ternaryAlts
-
suffixAlts
public java.util.LinkedHashMap<java.lang.Integer,java.lang.String> suffixAlts
-
prefixAlts
public java.util.List<java.lang.String> prefixAlts
-
otherAlts
public java.util.List<java.lang.String> otherAlts
-
retvals
public GrammarAST retvals
-
recRuleTemplates
public org.stringtemplate.v4.STGroup recRuleTemplates
-
language
public java.lang.String language
-
altAssociativity
public java.util.Map<java.lang.Integer,LeftRecursiveRuleAnalyzer.ASSOC> altAssociativity
-
-
Constructor Detail
-
LeftRecursiveRuleAnalyzer
public LeftRecursiveRuleAnalyzer(org.antlr.runtime.tree.TreeNodeStream input, Grammar g, java.lang.String ruleName)
-
-
Method Detail
-
loadPrecRuleTemplates
public void loadPrecRuleTemplates()
-
setReturnValues
public void setReturnValues(GrammarAST t)
- Overrides:
setReturnValues
in classLeftRecursiveRuleWalker
-
setTokenPrec
public void setTokenPrec(GrammarAST t, int alt)
- Overrides:
setTokenPrec
in classLeftRecursiveRuleWalker
-
binaryAlt
public void binaryAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
- Overrides:
binaryAlt
in classLeftRecursiveRuleWalker
-
ternaryAlt
public void ternaryAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
Convert e ? e : e → ? e : e_[nextPrec]- Overrides:
ternaryAlt
in classLeftRecursiveRuleWalker
-
prefixAlt
public void prefixAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
- Overrides:
prefixAlt
in classLeftRecursiveRuleWalker
-
suffixAlt
public void suffixAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
- Overrides:
suffixAlt
in classLeftRecursiveRuleWalker
-
otherAlt
public void otherAlt(GrammarAST altTree, GrammarAST rewriteTree, int alt)
- Overrides:
otherAlt
in classLeftRecursiveRuleWalker
-
getArtificialPrecStartRule
public java.lang.String getArtificialPrecStartRule()
-
getArtificialOpPrecRule
public java.lang.String getArtificialOpPrecRule()
-
getArtificialPrimaryRule
public java.lang.String getArtificialPrimaryRule()
-
replaceRuleRefs
public GrammarAST replaceRuleRefs(GrammarAST t, java.lang.String name)
-
hasImmediateRecursiveRuleRefs
public static boolean hasImmediateRecursiveRuleRefs(GrammarAST t, java.lang.String ruleName)
-
replaceLastRuleRef
public GrammarAST replaceLastRuleRef(GrammarAST t, java.lang.String name)
-
stripSynPred
public void stripSynPred(GrammarAST altAST)
-
stripLeftRecursion
public void stripLeftRecursion(GrammarAST altAST)
-
text
public java.lang.String text(GrammarAST t)
-
precedence
public int precedence(int alt)
-
nextPrecedence
public int nextPrecedence(int alt)
-
fillRetValAssignments
public void fillRetValAssignments(org.stringtemplate.v4.ST ruleST, java.lang.String srcName)
-
getNamesFromArgAction
public java.util.Collection<java.lang.String> getNamesFromArgAction(org.antlr.runtime.Token t)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-