Package org.antlr.v4.automata
Class LexerATNFactory
- java.lang.Object
-
- org.antlr.v4.automata.ParserATNFactory
-
- org.antlr.v4.automata.LexerATNFactory
-
- All Implemented Interfaces:
ATNFactory
public class LexerATNFactory extends ParserATNFactory
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.antlr.v4.automata.ATNFactory
ATNFactory.Handle
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<LexerAction,Integer>actionToIndexMapMaps from aLexerActionobject to the action index.org.stringtemplate.v4.STGroupcodegenTemplatesstatic Map<String,Integer>COMMON_CONSTANTSProvides a map of names of predefined constants which are likely to appear as the argument for lexer commands.protected Map<Integer,LexerAction>indexToActionMapMaps from an action index to aLexerActionobject.-
Fields inherited from class org.antlr.v4.automata.ParserATNFactory
atn, currentOuterAlt, currentRule, g, preventEpsilonClosureBlocks, preventEpsilonOptionalBlocks
-
-
Constructor Summary
Constructors Constructor Description LexerATNFactory(LexerGrammar g)LexerATNFactory(LexerGrammar g, CodeGenerator codeGenerator)
-
Method Summary
-
Methods inherited from class org.antlr.v4.automata.ParserATNFactory
_createATN, _ruleRef, addEOFTransitionToStartRules, addFollowLink, addRuleFollowLinks, alt, block, blockHasWildcardAlt, checkEpsilonClosure, elemList, epsilon, epsilon, epsilon, expectNonGreedy, getTokenType, label, listLabel, makeBlock, newState, newState, newState, optional, plus, ruleRef, sempred, setCurrentOuterAlt, setCurrentRuleName, star, wildcard
-
-
-
-
Field Detail
-
codegenTemplates
public org.stringtemplate.v4.STGroup codegenTemplates
-
COMMON_CONSTANTS
public static final Map<String,Integer> COMMON_CONSTANTS
Provides a map of names of predefined constants which are likely to appear as the argument for lexer commands. These names would be resolved by the Java compiler for lexer commands that are translated to embedded actions, but are required during code generation for creatingLexerActioninstances that are usable by a lexer interpreter.
-
indexToActionMap
protected Map<Integer,LexerAction> indexToActionMap
Maps from an action index to aLexerActionobject.
-
actionToIndexMap
protected Map<LexerAction,Integer> actionToIndexMap
Maps from aLexerActionobject to the action index.
-
-
Constructor Detail
-
LexerATNFactory
public LexerATNFactory(LexerGrammar g)
-
LexerATNFactory
public LexerATNFactory(LexerGrammar g, CodeGenerator codeGenerator)
-
-
Method Detail
-
createATN
public ATN createATN()
- Specified by:
createATNin interfaceATNFactory- Overrides:
createATNin classParserATNFactory
-
rule
public ATNFactory.Handle rule(GrammarAST ruleAST, String name, ATNFactory.Handle blk)
- Specified by:
rulein interfaceATNFactory- Overrides:
rulein classParserATNFactory
-
action
public ATNFactory.Handle action(ActionAST action)
Description copied from class:ParserATNFactoryBuild what amounts to an epsilon transition with an action. The action goes into ATN though it is ignored during prediction ifactionIndex<0.- Specified by:
actionin interfaceATNFactory- Overrides:
actionin classParserATNFactory
-
getLexerActionIndex
protected int getLexerActionIndex(LexerAction lexerAction)
-
action
public ATNFactory.Handle action(String action)
- Specified by:
actionin interfaceATNFactory- Overrides:
actionin classParserATNFactory
-
action
protected ATNFactory.Handle action(GrammarAST node, LexerAction lexerAction)
-
lexerAltCommands
public ATNFactory.Handle lexerAltCommands(ATNFactory.Handle alt, ATNFactory.Handle cmds)
- Specified by:
lexerAltCommandsin interfaceATNFactory- Overrides:
lexerAltCommandsin classParserATNFactory
-
lexerCallCommand
public ATNFactory.Handle lexerCallCommand(GrammarAST ID, GrammarAST arg)
- Specified by:
lexerCallCommandin interfaceATNFactory- Overrides:
lexerCallCommandin classParserATNFactory
-
lexerCommand
public ATNFactory.Handle lexerCommand(GrammarAST ID)
- Specified by:
lexerCommandin interfaceATNFactory- Overrides:
lexerCommandin classParserATNFactory
-
range
public ATNFactory.Handle range(GrammarAST a, GrammarAST b)
Description copied from class:ParserATNFactoryNot valid for non-lexers.- Specified by:
rangein interfaceATNFactory- Overrides:
rangein classParserATNFactory
-
set
public ATNFactory.Handle set(GrammarAST associatedAST, List<GrammarAST> alts, boolean invert)
Description copied from class:ParserATNFactoryFrom set build single edge grapho->o-set->o. To conform to what an alt block looks like, must have extra state on left. This also handles~A, converted to~{A}set.- Specified by:
setin interfaceATNFactory- Overrides:
setin classParserATNFactory
-
checkRange
protected boolean checkRange(GrammarAST leftNode, GrammarAST rightNode, int leftValue, int rightValue)
-
stringLiteral
public ATNFactory.Handle stringLiteral(TerminalAST stringLiteralAST)
For a lexer, a string is a sequence of char to match. That is, "fog" is treated as 'f' 'o' 'g' not as a single transition in the DFA. Machine== o-'f'->o-'o'->o-'g'->o and has n+1 states for n characters. if "caseInsensitive" option is enabled, "fog" will be treated as o-('f'|'F') -> o-('o'|'O') -> o-('g'|'G')- Specified by:
stringLiteralin interfaceATNFactory- Overrides:
stringLiteralin classParserATNFactory
-
charSetLiteral
public ATNFactory.Handle charSetLiteral(GrammarAST charSetAST)
[Aa\t ሴa-z\]\p{Letter}\-] char sets- Specified by:
charSetLiteralin interfaceATNFactory- Overrides:
charSetLiteralin classParserATNFactory
-
getSetFromCharSetLiteral
public IntervalSet getSetFromCharSetLiteral(GrammarAST charSetAST)
-
tokenRef
public ATNFactory.Handle tokenRef(TerminalAST node)
Description copied from class:ParserATNFactoryFrom labelAbuild grapho-A->o.- Specified by:
tokenRefin interfaceATNFactory- Overrides:
tokenRefin classParserATNFactory
-
-