Top Fields Constructors Methods
org.antlr.v4.codegen.model

public Class ElementFrequenciesVisitor

extends GrammarTreeVisitor
Class Inheritance
Imports
org.antlr.runtime.tree.TreeNodeStream, org.antlr.v4.misc.FrequencySet, .MutableInt, org.antlr.v4.parse.GrammarTreeVisitor, org.antlr.v4.tool.ErrorManager, org.antlr.v4.tool.ast.ActionAST, .AltAST, .GrammarAST, .TerminalAST, java.util.ArrayDeque, .Deque, .Map

Field Summary

Modifier and TypeField and Description
pack-priv final Deque<FrequencySet<String>>
private final Deque<FrequencySet<String>>
private static final FrequencySet<String>
SENTINEL

This special value means "no set", and is used by minFrequencies to ensure that combineMin doesn't merge an empty set (all zeros) with the results of the first alternative.

Inherited from org.antlr.v4.parse.GrammarTreeVisitor:
ACTIONACTION_CHAR_LITERALACTION_ESCACTION_STRING_LITERALALTARG_ACTIONARG_OR_CHARSETASSIGNATBLOCKCATCHCHANNELSCLOSURECOLONCOLONCOLONCOMBINEDCOMMACOMMENTcurrentModeNamecurrentOuterAltNumbercurrentOuterAltRootcurrentRuleASTcurrentRuleNamedfa38DOC_COMMENTDOLLARDOTELEMENT_OPTIONSEOFEPSILONERRCHARESC_SEQFINALLYFOLLOW_ACTION_in_action596FOLLOW_ACTION_in_actionElement1679FOLLOW_ACTION_in_actionElement1687FOLLOW_ACTION_in_block2430FOLLOW_ACTION_in_element1868FOLLOW_ACTION_in_element1897FOLLOW_ACTION_in_elementOption2733FOLLOW_ACTION_in_exceptionHandler998FOLLOW_ACTION_in_finallyClause1025FOLLOW_ACTION_in_lexerElement1468FOLLOW_ACTION_in_lexerElement1497FOLLOW_action_in_prequelConstruct234FOLLOW_ACTION_in_ruleAction1139FOLLOW_ALT_in_alternative1730FOLLOW_ALT_in_alternative1743FOLLOW_ALT_in_lexerElements1428FOLLOW_alternative_in_block2433FOLLOW_alternative_in_outerAlternative1362FOLLOW_ARG_ACTION_in_exceptionHandler996FOLLOW_ARG_ACTION_in_locals1055FOLLOW_ARG_ACTION_in_rule817FOLLOW_ARG_ACTION_in_ruleref2467FOLLOW_ARG_ACTION_in_ruleReturns1080FOLLOW_ASSIGN_in_delegateGrammar420FOLLOW_ASSIGN_in_elementOption2683FOLLOW_ASSIGN_in_elementOption2707FOLLOW_ASSIGN_in_elementOption2727FOLLOW_ASSIGN_in_elementOption2749FOLLOW_ASSIGN_in_option295FOLLOW_AT_in_action585FOLLOW_AT_in_ruleAction1135FOLLOW_atom_in_astOperand1959FOLLOW_atom_in_element1856FOLLOW_block_in_astOperand1976FOLLOW_BLOCK_in_block2422FOLLOW_block_in_element1937FOLLOW_BLOCK_in_lexerBlock1543FOLLOW_BLOCK_in_lexerRuleBlock1217FOLLOW_BLOCK_in_ruleBlock1281FOLLOW_block_in_subrule2034FOLLOW_block_in_subrule2041FOLLOW_blockSet_in_astOperand1967FOLLOW_blockSet_in_atom2225FOLLOW_blockSet_in_element1928FOLLOW_blockSet_in_lexerAtom1592FOLLOW_blockSet_in_lexerAtom1603FOLLOW_blockSuffix_in_lexerSubrule2066FOLLOW_blockSuffix_in_subrule2032FOLLOW_CATCH_in_exceptionHandler994FOLLOW_CHANNELS_in_channelsSpec532FOLLOW_channelSpec_in_channelsSpec534FOLLOW_channelsSpec_in_prequelConstruct224FOLLOW_delegateGrammar_in_delegateGrammars391FOLLOW_delegateGrammars_in_prequelConstruct204FOLLOW_DOT_in_atom2163FOLLOW_DOT_in_atom2174FOLLOW_ebnfSuffix_in_blockSuffix2102FOLLOW_element_in_alternative1735FOLLOW_element_in_labeledElement2007FOLLOW_ELEMENT_OPTIONS_in_elementOptions2630FOLLOW_elementOption_in_elementOptions2632FOLLOW_elementOptions_in_actionElement1689FOLLOW_elementOptions_in_actionElement1707FOLLOW_elementOptions_in_alternative1732FOLLOW_elementOptions_in_alternative1745FOLLOW_elementOptions_in_atom2190FOLLOW_elementOptions_in_element1899FOLLOW_elementOptions_in_element1912FOLLOW_elementOptions_in_lexerAtom1616FOLLOW_elementOptions_in_lexerElement1499FOLLOW_elementOptions_in_lexerElement1512FOLLOW_elementOptions_in_ruleref2470FOLLOW_elementOptions_in_setElement2288FOLLOW_elementOptions_in_setElement2302FOLLOW_elementOptions_in_terminal2543FOLLOW_elementOptions_in_terminal2582FOLLOW_EPSILON_in_alternative1748FOLLOW_EPSILON_in_lexerElement1520FOLLOW_exceptionGroup_in_rule918FOLLOW_exceptionHandler_in_exceptionGroup965FOLLOW_FINALLY_in_finallyClause1023FOLLOW_finallyClause_in_exceptionGroup968FOLLOW_FRAGMENT_in_lexerRule712FOLLOW_GRAMMAR_in_grammarSpec85FOLLOW_ID_in_action589FOLLOW_ID_in_action594FOLLOW_ID_in_atom2165FOLLOW_ID_in_atom2176FOLLOW_ID_in_channelSpec557FOLLOW_ID_in_delegateGrammar424FOLLOW_ID_in_delegateGrammar428FOLLOW_ID_in_delegateGrammar443FOLLOW_ID_in_elementOption2663FOLLOW_ID_in_elementOption2687FOLLOW_ID_in_elementOption2691FOLLOW_ID_in_elementOption2709FOLLOW_ID_in_elementOption2729FOLLOW_ID_in_elementOption2751FOLLOW_ID_in_grammarSpec87FOLLOW_ID_in_labeledElement2005FOLLOW_ID_in_lexerCommand1776FOLLOW_ID_in_lexerCommand1794FOLLOW_ID_in_mode664FOLLOW_ID_in_option297FOLLOW_ID_in_ruleAction1137FOLLOW_ID_in_throwsSpec1108FOLLOW_ID_in_tokenSpec502FOLLOW_IMPORT_in_delegateGrammars389FOLLOW_INT_in_elementOption2755FOLLOW_labeledElement_in_element1851FOLLOW_LEXER_ACTION_CALL_in_lexerCommand1774FOLLOW_LEXER_ALT_ACTION_in_lexerAlternative1384FOLLOW_LEXER_CHAR_SET_in_lexerAtom1635FOLLOW_LEXER_CHAR_SET_in_setElement2397FOLLOW_lexerAlternative_in_lexerBlock1548FOLLOW_lexerAlternative_in_lexerOuterAlternative1340FOLLOW_lexerAtom_in_lexerElement1456FOLLOW_lexerBlock_in_lexerSubrule2068FOLLOW_lexerBlock_in_lexerSubrule2075FOLLOW_lexerCommand_in_lexerAlternative1388FOLLOW_lexerCommandExpr_in_lexerCommand1778FOLLOW_lexerElement_in_lexerElements1430FOLLOW_lexerElements_in_lexerAlternative1386FOLLOW_lexerElements_in_lexerAlternative1400FOLLOW_lexerOuterAlternative_in_lexerRuleBlock1236FOLLOW_lexerRule_in_mode668FOLLOW_lexerRule_in_rules631FOLLOW_lexerRuleBlock_in_lexerRule745FOLLOW_lexerSubrule_in_lexerElement1461FOLLOW_LOCALS_in_locals1053FOLLOW_locals_in_rule856FOLLOW_mode_in_grammarSpec125FOLLOW_MODE_in_mode662FOLLOW_NOT_in_astOperand1965FOLLOW_NOT_in_astOperand1974FOLLOW_NOT_in_element1926FOLLOW_NOT_in_element1935FOLLOW_NOT_in_lexerAtom1590FOLLOW_option_in_optionsSpec261FOLLOW_OPTIONS_in_optionsSpec259FOLLOW_optionsSpec_in_block2424FOLLOW_optionsSpec_in_lexerBlock1545FOLLOW_optionsSpec_in_lexerRule724FOLLOW_optionsSpec_in_prequelConstruct194FOLLOW_optionsSpec_in_rule871FOLLOW_optionValue_in_option301FOLLOW_outerAlternative_in_ruleBlock1300FOLLOW_prequelConstruct_in_prequelConstructs167FOLLOW_prequelConstructs_in_grammarSpec106FOLLOW_range_in_element1920FOLLOW_range_in_lexerAtom1645FOLLOW_RANGE_in_range2507FOLLOW_RANGE_in_setElement2366FOLLOW_RETURNS_in_ruleReturns1078FOLLOW_RULE_in_lexerRule694FOLLOW_RULE_in_rule790FOLLOW_rule_in_rules629FOLLOW_RULE_REF_in_rule792FOLLOW_RULE_REF_in_ruleref2463FOLLOW_ruleAction_in_block2427FOLLOW_ruleAction_in_rule885FOLLOW_ruleBlock_in_rule916FOLLOW_ruleModifier_in_rule806FOLLOW_RULEMODIFIERS_in_lexerRule708FOLLOW_RULEMODIFIERS_in_rule801FOLLOW_ruleref_in_atom2178FOLLOW_ruleref_in_atom2235FOLLOW_ruleref_in_lexerAtom1655FOLLOW_ruleReturns_in_rule830FOLLOW_rules_in_grammarSpec123FOLLOW_RULES_in_rules624FOLLOW_SEMPRED_in_actionElement1697FOLLOW_SEMPRED_in_actionElement1705FOLLOW_SEMPRED_in_element1882FOLLOW_SEMPRED_in_element1910FOLLOW_SEMPRED_in_lexerElement1482FOLLOW_SEMPRED_in_lexerElement1510FOLLOW_SET_in_blockSet2260FOLLOW_set_in_labeledElement1999FOLLOW_setElement_in_blockSet2262FOLLOW_STRING_LITERAL_in_elementOption2713FOLLOW_STRING_LITERAL_in_range2509FOLLOW_STRING_LITERAL_in_range2511FOLLOW_STRING_LITERAL_in_setElement2286FOLLOW_STRING_LITERAL_in_setElement2312FOLLOW_STRING_LITERAL_in_setElement2370FOLLOW_STRING_LITERAL_in_setElement2374FOLLOW_STRING_LITERAL_in_terminal2541FOLLOW_STRING_LITERAL_in_terminal2566FOLLOW_subrule_in_element1861FOLLOW_terminal_in_atom2167FOLLOW_terminal_in_atom2217FOLLOW_terminal_in_lexerAtom1579FOLLOW_THROWS_in_throwsSpec1106FOLLOW_throwsSpec_in_rule843FOLLOW_TOKEN_REF_in_lexerRule696FOLLOW_TOKEN_REF_in_setElement2300FOLLOW_TOKEN_REF_in_setElement2337FOLLOW_TOKEN_REF_in_terminal2580FOLLOW_TOKEN_REF_in_terminal2593FOLLOW_TOKENS_SPEC_in_tokensSpec477FOLLOW_tokenSpec_in_tokensSpec479FOLLOW_tokensSpec_in_prequelConstruct214FOLLOW_WILDCARD_in_atom2188FOLLOW_WILDCARD_in_atom2201FOLLOW_WILDCARD_in_lexerAtom1614FOLLOW_WILDCARD_in_lexerAtom1627FRAGMENTGRAMMARgrammarNameGTHEX_DIGITIDIMPORTINTLEXERLEXER_ACTION_CALLLEXER_ALT_ACTIONLEXER_CHAR_SETLOCALSLPARENLTMODENameCharNameStartCharNESTED_ACTIONNLCHARSNOTOPTIONALOPTIONSORPARSERPLUSPLUS_ASSIGNPOSITIVE_CLOSUREPOUNDPRIVATEPROTECTEDPUBLICQUESTIONRANGERARROWRBRACERETURNSrewriteEBNFLevelRPARENRULERULE_REFRULEMODIFIERSRULESSEMISEMPREDSETSRCSTARSTRING_LITERALTHROWSTOKEN_REFtokenNamesTOKENS_SPECUNICODE_ESCUNICODE_EXTENDED_ESCUnicodeBOMWILDCARDWSWSCHARSWSNLCHARS

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected static FrequencySet<String>

Returns:

The sum of the two sets, with the individual elements clipped to the maximum value given by clip.
combineAndClip
(FrequencySet<String>
The first set.
a
,
FrequencySet<String>
The second set.
b
,
int
The maximum value to allow for any output.
clip
)

Generate a frequency set as the union of two input sets, with the values clipped to a specified maximum value.

protected static FrequencySet<String>

Returns:

The union of the two sets, with the maximum value chosen whenever both sets contain the same key.
combineMax
(FrequencySet<String>
The first set.
a
,
FrequencySet<String>
The second set.
b
)

Generate a frequency set as the union of two input sets.

protected static FrequencySet<String>

Returns:

The union of the two sets, with the minimum value chosen whenever both sets contain the same key.
combineMin
(FrequencySet<String>
The first set.
a
,
FrequencySet<String>
The second set. If this set is SENTINEL, it is treated as though no second set were provided.
b
)

Generate a frequency set as the union of two input sets.

protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
public ErrorManager
getErrorManager()

Overrides org.antlr.v4.parse.GrammarTreeVisitor.getErrorManager.

During code gen, we can assume tree is in good shape
pack-priv FrequencySet<String>
public void
public void
public void
Inherited from org.antlr.v4.parse.GrammarTreeVisitor:
actionactionElementactionInAltalternativeastOperandatomblockblockOptionblockSetblockSuffixchannelSpecchannelsSpecdefineChanneldefineTokendelegateGrammardelegateGrammarsdiscoverAltdiscoverGrammardiscoverLexerRulediscoverOuterAltdiscoverRulediscoverRulesebnfSuffixelementelementOptionelementOptionelementOptionsenterActionenterActionElemententerAstOperandenterAtomenterBlockenterBlockSuffixenterChannelSpecenterChannelsSpecenterDelegateGrammarenterDelegateGrammarsenterEbnfSuffixenterElementOptionenterElementOptionsenterExceptionGroupenterExceptionHandlerenterFinallyClauseenterGrammarSpecenterLabeledElemententerLexerAtomenterLexerBlockenterLexerCommandenterLexerCommandExprenterLexerElementsenterLexerOuterAlternativeenterLexerRuleenterLexerRuleBlockenterLexerSubruleenterLocalsenterModeenterOptionenterOptionsSpecenterOptionValueenterOuterAlternativeenterPrequelConstructenterPrequelConstructsenterRangeenterRuleenterRuleActionenterRuleBlockenterRuleModifierenterRulerefenterRuleReturnsenterRulesenterSetElemententerSubruleenterTerminalenterThrowsSpecenterTokenSpecenterTokensSpecexceptionGroupexceptionHandlerexitActionexitActionElementexitAstOperandexitAtomexitBlockexitBlockSuffixexitChannelSpecexitChannelsSpecexitDelegateGrammarexitDelegateGrammarsexitEbnfSuffixexitElementOptionexitElementOptionsexitExceptionGroupexitExceptionHandlerexitFinallyClauseexitGrammarSpecexitLabeledElementexitLexerAtomexitLexerBlockexitLexerCommandexitLexerCommandExprexitLexerElementsexitLexerOuterAlternativeexitLexerRuleexitLexerRuleBlockexitLocalsexitModeexitOptionexitOptionsSpecexitOptionValueexitOuterAlternativeexitPrequelConstructexitPrequelConstructsexitRangeexitRuleexitRuleActionexitRuleBlockexitRuleModifierexitRulerefexitRuleReturnsexitRulesexitSetElementexitTerminalexitThrowsSpecexitTokenSpecexitTokensSpecfinallyActionfinallyClausefinishAltfinishGrammarfinishLexerRulefinishOuterAltfinishPrequelsfinishRulefinishRulesgetDelegatesgetGrammarFileNamegetTokenNamesglobalNamedActiongrammarOptiongrammarSpecimportGrammarlabellabeledElementlexerAlternativelexerAtomlexerBlocklexerCallCommandlexerCommandlexerCommandlexerCommandExprlexerElementlexerElementslexerOuterAlternativelexerRulelexerRuleBlocklexerSubrulelocalsmodemodeDefoptionoptionsSpecoptionValueouterAlternativeprequelConstructprequelConstructsrangeruleruleActionruleBlockruleCatchruleModifierruleOptionrulerefruleReturnsrulessempredInAltsetElementsubruleterminalthrowsSpectokenSpectokensSpectraceIntraceOutvisitvisitGrammarwildcardRef

Field Detail

frequenciesback to summary
pack-priv final Deque<FrequencySet<String>> frequencies
minFrequenciesback to summary
private final Deque<FrequencySet<String>> minFrequencies
SENTINELback to summary
private static final FrequencySet<String> SENTINEL

This special value means "no set", and is used by minFrequencies to ensure that combineMin doesn't merge an empty set (all zeros) with the results of the first alternative.

Constructor Detail

ElementFrequenciesVisitorback to summary
public ElementFrequenciesVisitor(TreeNodeStream input)

Method Detail

combineAndClipback to summary
protected static FrequencySet<String> combineAndClip(FrequencySet<String> a, FrequencySet<String> b, int clip)

Generate a frequency set as the union of two input sets, with the values clipped to a specified maximum value. If an element is contained in both sets, the value for the output, prior to clipping, will be the sum of the two input values.

Parameters
a:FrequencySet<String>

The first set.

b:FrequencySet<String>

The second set.

clip:int

The maximum value to allow for any output.

Returns:FrequencySet<String>

The sum of the two sets, with the individual elements clipped to the maximum value given by clip.

combineMaxback to summary
protected static FrequencySet<String> combineMax(FrequencySet<String> a, FrequencySet<String> b)

Generate a frequency set as the union of two input sets. If an element is contained in both sets, the value for the output will be the maximum of the two input values.

Parameters
a:FrequencySet<String>

The first set.

b:FrequencySet<String>

The second set.

Returns:FrequencySet<String>

The union of the two sets, with the maximum value chosen whenever both sets contain the same key.

combineMinback to summary
protected static FrequencySet<String> combineMin(FrequencySet<String> a, FrequencySet<String> b)

Generate a frequency set as the union of two input sets. If an element is contained in both sets, the value for the output will be the minimum of the two input values.

Parameters
a:FrequencySet<String>

The first set.

b:FrequencySet<String>

The second set. If this set is SENTINEL, it is treated as though no second set were provided.

Returns:FrequencySet<String>

The union of the two sets, with the minimum value chosen whenever both sets contain the same key.

enterAlternativeback to summary
protected void enterAlternative(AltAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.enterAlternative.

Annotations
@Override
enterBlockSetback to summary
protected void enterBlockSet(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.enterBlockSet.

Annotations
@Override
enterElementback to summary
protected void enterElement(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.enterElement.

Annotations
@Override
enterLexerAlternativeback to summary
protected void enterLexerAlternative(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.enterLexerAlternative.

Annotations
@Override
enterLexerElementback to summary
protected void enterLexerElement(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.enterLexerElement.

Annotations
@Override
exitAlternativeback to summary
protected void exitAlternative(AltAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.exitAlternative.

Annotations
@Override
exitBlockSetback to summary
protected void exitBlockSet(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.exitBlockSet.

Annotations
@Override
exitElementback to summary
protected void exitElement(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.exitElement.

Annotations
@Override
exitLexerAlternativeback to summary
protected void exitLexerAlternative(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.exitLexerAlternative.

Annotations
@Override
exitLexerElementback to summary
protected void exitLexerElement(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.exitLexerElement.

Annotations
@Override
exitLexerSubruleback to summary
protected void exitLexerSubrule(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.exitLexerSubrule.

Annotations
@Override
exitSubruleback to summary
protected void exitSubrule(GrammarAST tree)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.exitSubrule.

Annotations
@Override
getErrorManagerback to summary
public ErrorManager getErrorManager()

Overrides org.antlr.v4.parse.GrammarTreeVisitor.getErrorManager.

During code gen, we can assume tree is in good shape

Annotations
@Override
getMinFrequenciesback to summary
pack-priv FrequencySet<String> getMinFrequencies()
ruleRefback to summary
public void ruleRef(GrammarAST ref, ActionAST arg)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.ruleRef.

Annotations
@Override
stringRefback to summary
public void stringRef(TerminalAST ref)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.stringRef.

Annotations
@Override
tokenRefback to summary
public void tokenRef(TerminalAST ref)

Overrides org.antlr.v4.parse.GrammarTreeVisitor.tokenRef.

Annotations
@Override