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>
actionToIndexMap
Maps from aLexerAction
object to the action index.org.stringtemplate.v4.STGroup
codegenTemplates
static Map<String,Integer>
COMMON_CONSTANTS
Provides a map of names of predefined constants which are likely to appear as the argument for lexer commands.protected Map<Integer,LexerAction>
indexToActionMap
Maps from an action index to aLexerAction
object.-
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 creatingLexerAction
instances that are usable by a lexer interpreter.
-
indexToActionMap
protected Map<Integer,LexerAction> indexToActionMap
Maps from an action index to aLexerAction
object.
-
actionToIndexMap
protected Map<LexerAction,Integer> actionToIndexMap
Maps from aLexerAction
object 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:
createATN
in interfaceATNFactory
- Overrides:
createATN
in classParserATNFactory
-
rule
public ATNFactory.Handle rule(GrammarAST ruleAST, String name, ATNFactory.Handle blk)
- Specified by:
rule
in interfaceATNFactory
- Overrides:
rule
in classParserATNFactory
-
action
public ATNFactory.Handle action(ActionAST action)
Description copied from class:ParserATNFactory
Build what amounts to an epsilon transition with an action. The action goes into ATN though it is ignored during prediction ifactionIndex
<0
.- Specified by:
action
in interfaceATNFactory
- Overrides:
action
in classParserATNFactory
-
getLexerActionIndex
protected int getLexerActionIndex(LexerAction lexerAction)
-
action
public ATNFactory.Handle action(String action)
- Specified by:
action
in interfaceATNFactory
- Overrides:
action
in classParserATNFactory
-
action
protected ATNFactory.Handle action(GrammarAST node, LexerAction lexerAction)
-
lexerAltCommands
public ATNFactory.Handle lexerAltCommands(ATNFactory.Handle alt, ATNFactory.Handle cmds)
- Specified by:
lexerAltCommands
in interfaceATNFactory
- Overrides:
lexerAltCommands
in classParserATNFactory
-
lexerCallCommand
public ATNFactory.Handle lexerCallCommand(GrammarAST ID, GrammarAST arg)
- Specified by:
lexerCallCommand
in interfaceATNFactory
- Overrides:
lexerCallCommand
in classParserATNFactory
-
lexerCommand
public ATNFactory.Handle lexerCommand(GrammarAST ID)
- Specified by:
lexerCommand
in interfaceATNFactory
- Overrides:
lexerCommand
in classParserATNFactory
-
range
public ATNFactory.Handle range(GrammarAST a, GrammarAST b)
Description copied from class:ParserATNFactory
Not valid for non-lexers.- Specified by:
range
in interfaceATNFactory
- Overrides:
range
in classParserATNFactory
-
set
public ATNFactory.Handle set(GrammarAST associatedAST, List<GrammarAST> alts, boolean invert)
Description copied from class:ParserATNFactory
From 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:
set
in interfaceATNFactory
- Overrides:
set
in 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:
stringLiteral
in interfaceATNFactory
- Overrides:
stringLiteral
in classParserATNFactory
-
charSetLiteral
public ATNFactory.Handle charSetLiteral(GrammarAST charSetAST)
[Aa\t ሴa-z\]\p{Letter}\-] char sets- Specified by:
charSetLiteral
in interfaceATNFactory
- Overrides:
charSetLiteral
in classParserATNFactory
-
getSetFromCharSetLiteral
public IntervalSet getSetFromCharSetLiteral(GrammarAST charSetAST)
-
tokenRef
public ATNFactory.Handle tokenRef(TerminalAST node)
Description copied from class:ParserATNFactory
From labelA
build grapho-A->o
.- Specified by:
tokenRef
in interfaceATNFactory
- Overrides:
tokenRef
in classParserATNFactory
-
-