Top Inners Fields Constructors Methods
org.antlr.v4.automata

public Class LexerATNFactory

extends ParserATNFactory
Class Inheritance
Imports
org.antlr.runtime.CommonToken, .Token, org.antlr.runtime.tree.CommonTree, org.antlr.v4.codegen.CodeGenerator, org.antlr.v4.misc.CharSupport, .EscapeSequenceParsing, org.antlr.v4.parse.ANTLRParser, org.antlr.v4.runtime.IntStream, .Lexer, org.antlr.v4.runtime.atn.*, org.antlr.v4.runtime.misc.Interval, .IntervalSet, org.antlr.v4.tool.ErrorType, .LexerGrammar, .Rule, org.antlr.v4.tool.ast.ActionAST, .GrammarAST, .RangeAST, .TerminalAST, org.stringtemplate.v4.ST, .STGroup, java.util.ArrayList, .HashMap, .List, .Map, .Objects, .Set

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
protected Map<LexerAction, Integer>
actionToIndexMap

Maps from a LexerAction object to the action index.

public STGroup
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.

protected Map<Integer, LexerAction>
indexToActionMap

Maps from an action index to a LexerAction object.

private final List<String>
Inherited from org.antlr.v4.automata.ParserATNFactory:
atncurrentOuterAltcurrentRulegpreventEpsilonClosureBlockspreventEpsilonOptionalBlocks

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public ATNFactory.Handle
action(ActionAST action)

Overrides org.antlr.v4.automata.ParserATNFactory.action.

Implements org.antlr.v4.automata.ATNFactory.action.

Build what amounts to an epsilon transition with an action.
public ATNFactory.Handle
protected ATNFactory.Handle
action(GrammarAST node, LexerAction lexerAction)

private void
private LexerATNFactory.CharSetParseState
private LexerATNFactory.CharSetParseState
public ATNFactory.Handle
private void
private void
checkCommands(String command, Token commandToken)

protected boolean
checkRange(GrammarAST leftNode, GrammarAST rightNode, int leftValue, int rightValue)

private void
checkRangeAndAddToSet(GrammarAST mainAst, IntervalSet set, int a, int b)

private CharactersDataCheckStatus
checkRangeAndAddToSet(GrammarAST rootAst, GrammarAST ast, IntervalSet set, int a, int b, boolean caseInsensitive, CharactersDataCheckStatus previousStatus)

public ATN
private LexerAction
private Transition
createTransition(ATNState target, int from, int to, CommonTree tree)

private Integer
getChannelConstantValue(String channelName, Token token)

public static Set<String>
protected int
private Integer
public IntervalSet
private Integer
public ATNFactory.Handle
public ATNFactory.Handle
private ATNFactory.Handle
public ATNFactory.Handle
public ATNFactory.Handle
public ATNFactory.Handle
public ATNFactory.Handle
set(GrammarAST associatedAST, List<GrammarAST> alts, boolean invert)

Overrides org.antlr.v4.automata.ParserATNFactory.set.

Implements org.antlr.v4.automata.ATNFactory.set.

From set build single edge graph o->o-set->o.
public ATNFactory.Handle
stringLiteral(TerminalAST stringLiteralAST)

Overrides org.antlr.v4.automata.ParserATNFactory.stringLiteral.

Implements org.antlr.v4.automata.ATNFactory.stringLiteral.

For a lexer, a string is a sequence of char to match.
public ATNFactory.Handle
Inherited from org.antlr.v4.automata.ParserATNFactory:
_createATN_ruleRefaddEOFTransitionToStartRulesaddFollowLinkaddRuleFollowLinksaltblockblockHasWildcardAltcheckEpsilonClosurecreateRuleStartAndStopATNStateselemListepsilonepsilonepsilonexpectNonGreedygetTokenTypelabellistLabelmakeBlocknewStatenewStatenewStateoptionalplusruleRefsempredsetCurrentOuterAltsetCurrentRuleNamestarwildcard

Field Detail

actionToIndexMapback to summary
protected Map<LexerAction, Integer> actionToIndexMap

Maps from a LexerAction object to the action index.

codegenTemplatesback to summary
public STGroup codegenTemplates
COMMON_CONSTANTSback to summary
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 creating LexerAction instances that are usable by a lexer interpreter.

indexToActionMapback to summary
protected Map<Integer, LexerAction> indexToActionMap

Maps from an action index to a LexerAction object.

ruleCommandsback to summary
private final List<String> ruleCommands

Constructor Detail

LexerATNFactoryback to summary
public LexerATNFactory(LexerGrammar g)
LexerATNFactoryback to summary
public LexerATNFactory(LexerGrammar g, CodeGenerator codeGenerator)

Method Detail

actionback to summary
public ATNFactory.Handle action(ActionAST action)

Overrides org.antlr.v4.automata.ParserATNFactory.action.

Implements org.antlr.v4.automata.ATNFactory.action.

Doc from org.antlr.v4.automata.ParserATNFactory.action.

Build what amounts to an epsilon transition with an action. The action goes into ATN though it is ignored during prediction if actionIndex<0.

Annotations
@Override
actionback to summary
public ATNFactory.Handle action(String action)

Overrides org.antlr.v4.automata.ParserATNFactory.action.

Implements org.antlr.v4.automata.ATNFactory.action.

Annotations
@Override
actionback to summary
protected ATNFactory.Handle action(GrammarAST node, LexerAction lexerAction)
applyPrevStateback to summary
private void applyPrevState(GrammarAST charSetAST, IntervalSet set, LexerATNFactory.CharSetParseState state)
applyPrevStateAndMoveToCodePointback to summary
private LexerATNFactory.CharSetParseState applyPrevStateAndMoveToCodePoint(GrammarAST charSetAST, IntervalSet set, LexerATNFactory.CharSetParseState state, int codePoint)
applyPrevStateAndMoveToPropertyback to summary
private LexerATNFactory.CharSetParseState applyPrevStateAndMoveToProperty(GrammarAST charSetAST, IntervalSet set, LexerATNFactory.CharSetParseState state, IntervalSet property)
charSetLiteralback to summary
public ATNFactory.Handle charSetLiteral(GrammarAST charSetAST)

Overrides org.antlr.v4.automata.ParserATNFactory.charSetLiteral.

Implements org.antlr.v4.automata.ATNFactory.charSetLiteral.

[Aa\t ሴa-z\]\p{Letter}\-] char sets

Annotations
@Override
checkCharAndAddToSetback to summary
private void checkCharAndAddToSet(GrammarAST ast, IntervalSet set, int c)
checkCommandsback to summary
private void checkCommands(String command, Token commandToken)
checkRangeback to summary
protected boolean checkRange(GrammarAST leftNode, GrammarAST rightNode, int leftValue, int rightValue)
checkRangeAndAddToSetback to summary
private void checkRangeAndAddToSet(GrammarAST mainAst, IntervalSet set, int a, int b)
checkRangeAndAddToSetback to summary
private CharactersDataCheckStatus checkRangeAndAddToSet(GrammarAST rootAst, GrammarAST ast, IntervalSet set, int a, int b, boolean caseInsensitive, CharactersDataCheckStatus previousStatus)
createATNback to summary
public ATN createATN()

Overrides org.antlr.v4.automata.ParserATNFactory.createATN.

Implements org.antlr.v4.automata.ATNFactory.createATN.

Annotations
@Override
createLexerActionback to summary
private LexerAction createLexerAction(GrammarAST ID, GrammarAST arg)
createTransitionback to summary
private Transition createTransition(ATNState target, int from, int to, CommonTree tree)
getChannelConstantValueback to summary
private Integer getChannelConstantValue(String channelName, Token token)
getCommonConstantsback to summary
public static Set<String> getCommonConstants()
getLexerActionIndexback to summary
protected int getLexerActionIndex(LexerAction lexerAction)
getModeConstantValueback to summary
private Integer getModeConstantValue(String modeName, Token token)
getSetFromCharSetLiteralback to summary
public IntervalSet getSetFromCharSetLiteral(GrammarAST charSetAST)
getTokenConstantValueback to summary
private Integer getTokenConstantValue(String tokenName, Token token)
lexerAltCommandsback to summary
public ATNFactory.Handle lexerAltCommands(ATNFactory.Handle alt, ATNFactory.Handle cmds)

Overrides org.antlr.v4.automata.ParserATNFactory.lexerAltCommands.

Implements org.antlr.v4.automata.ATNFactory.lexerAltCommands.

Annotations
@Override
lexerCallCommandback to summary
public ATNFactory.Handle lexerCallCommand(GrammarAST ID, GrammarAST arg)

Overrides org.antlr.v4.automata.ParserATNFactory.lexerCallCommand.

Implements org.antlr.v4.automata.ATNFactory.lexerCallCommand.

Annotations
@Override
lexerCallCommandOrCommandback to summary
private ATNFactory.Handle lexerCallCommandOrCommand(GrammarAST ID, GrammarAST arg)
lexerCommandback to summary
public ATNFactory.Handle lexerCommand(GrammarAST ID)

Overrides org.antlr.v4.automata.ParserATNFactory.lexerCommand.

Implements org.antlr.v4.automata.ATNFactory.lexerCommand.

Annotations
@Override
rangeback to summary
public ATNFactory.Handle range(GrammarAST a, GrammarAST b)

Overrides org.antlr.v4.automata.ParserATNFactory.range.

Implements org.antlr.v4.automata.ATNFactory.range.

Doc from org.antlr.v4.automata.ParserATNFactory.range.

Not valid for non-lexers.

Annotations
@Override
ruleback to summary
public ATNFactory.Handle rule(GrammarAST ruleAST, String name, ATNFactory.Handle blk)

Overrides org.antlr.v4.automata.ParserATNFactory.rule.

Implements org.antlr.v4.automata.ATNFactory.rule.

Annotations
@Override
setback to summary
public ATNFactory.Handle set(GrammarAST associatedAST, List<GrammarAST> alts, boolean invert)

Overrides org.antlr.v4.automata.ParserATNFactory.set.

Implements org.antlr.v4.automata.ATNFactory.set.

Doc from org.antlr.v4.automata.ParserATNFactory.set.

From set build single edge graph o->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.

Annotations
@Override
stringLiteralback to summary
public ATNFactory.Handle stringLiteral(TerminalAST stringLiteralAST)

Overrides org.antlr.v4.automata.ParserATNFactory.stringLiteral.

Implements org.antlr.v4.automata.ATNFactory.stringLiteral.

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')

Annotations
@Override
tokenRefback to summary
public ATNFactory.Handle tokenRef(TerminalAST node)

Overrides org.antlr.v4.automata.ParserATNFactory.tokenRef.

Implements org.antlr.v4.automata.ATNFactory.tokenRef.

Doc from org.antlr.v4.automata.ParserATNFactory.tokenRef.

From label A build graph o-A->o.

Annotations
@Override
org.antlr.v4.automata back to summary

private Class LexerATNFactory.CharSetParseState

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
public static final LexerATNFactory.CharSetParseState
public final boolean
public final LexerATNFactory.CharSetParseState.Mode
public static final LexerATNFactory.CharSetParseState
public final int
public final IntervalSet

Constructor Summary

AccessConstructor and Description
public
CharSetParseState(LexerATNFactory.CharSetParseState.Mode mode, boolean inRange, int prevCodePoint, IntervalSet prevProperty)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ERRORback to summary
public static final LexerATNFactory.CharSetParseState ERROR
inRangeback to summary
public final boolean inRange
modeback to summary
public final LexerATNFactory.CharSetParseState.Mode mode
NONEback to summary
public static final LexerATNFactory.CharSetParseState NONE
prevCodePointback to summary
public final int prevCodePoint
prevPropertyback to summary
public final IntervalSet prevProperty

Constructor Detail

CharSetParseStateback to summary
public CharSetParseState(LexerATNFactory.CharSetParseState.Mode mode, boolean inRange, int prevCodePoint, IntervalSet prevProperty)

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
org.antlr.v4.automata back to summary

pack-priv final Enum LexerATNFactory.CharSetParseState.Mode

extends Enum<LexerATNFactory.CharSetParseState.Mode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final LexerATNFactory.CharSetParseState.Mode
public static final LexerATNFactory.CharSetParseState.Mode
public static final LexerATNFactory.CharSetParseState.Mode
public static final LexerATNFactory.CharSetParseState.Mode

Constructor Summary

AccessConstructor and Description
private
Mode()

Field Detail

ERRORback to summary
public static final LexerATNFactory.CharSetParseState.Mode ERROR
NONEback to summary
public static final LexerATNFactory.CharSetParseState.Mode NONE
PREV_CODE_POINTback to summary
public static final LexerATNFactory.CharSetParseState.Mode PREV_CODE_POINT
PREV_PROPERTYback to summary
public static final LexerATNFactory.CharSetParseState.Mode PREV_PROPERTY

Constructor Detail

Modeback to summary
private Mode()

Method Detail

valueOfback to summary
public static LexerATNFactory.CharSetParseState.Mode valueOf(String name)
valuesback to summary
public static LexerATNFactory.CharSetParseState.Mode[] values()