Top Description Fields Constructors Methods
org.antlr.runtime

public Class DFA

extends Object
Class Inheritance

A DFA implemented as a set of transition tables. Any state that has a semantic predicate edge is special; those states are generated with if-then-else structures in a specialStateTransition() which is generated by cyclicDFA template. There are at most 32767 states (16-bit signed short). Could get away with byte sometimes but would have to generate different types and the simulation code too. For a point of reference, the Java lexer's Tokens rule DFA has 326 states roughly.

Field Summary

Modifier and TypeField and Description
protected short[]
public static final boolean
protected int
protected short[]
protected short[]
protected char[]
protected char[]
protected BaseRecognizer
recognizer

Which recognizer encloses this DFA?

protected short[]
protected short[][]

Constructor Summary

AccessConstructor and Description
public
DFA()

Method Summary

Modifier and TypeMethod and Description
protected void
error(NoViableAltException nvae)

A hook for debugging interface

public String
protected void
noViableAlt(int s, IntStream input)

public int
predict(IntStream input)

From the input stream, predict what alternative will succeed using this DFA (representing the covering regular approximation to the underlying CFL).

public int
public static short[]
unpackEncodedString(String encodedString)

Given a String that has a run-length-encoding of some unsigned shorts like "\1\2\3\9", convert to short[] {2,9,9,9}.

public static char[]
unpackEncodedStringToUnsignedChars(String encodedString)

Hideous duplication of code, but I need different typed arrays out :(

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

acceptback to summary
protected short[] accept
debugback to summary
public static final boolean debug
decisionNumberback to summary
protected int decisionNumber
eofback to summary
protected short[] eof
eotback to summary
protected short[] eot
maxback to summary
protected char[] max
minback to summary
protected char[] min
recognizerback to summary
protected BaseRecognizer recognizer

Which recognizer encloses this DFA? Needed to check backtracking

specialback to summary
protected short[] special
transitionback to summary
protected short[][] transition

Constructor Detail

DFAback to summary
public DFA()

Method Detail

errorback to summary
protected void error(NoViableAltException nvae)

A hook for debugging interface

getDescriptionback to summary
public String getDescription()
noViableAltback to summary
protected void noViableAlt(int s, IntStream input) throws NoViableAltException
predictback to summary
public int predict(IntStream input) throws RecognitionException

From the input stream, predict what alternative will succeed using this DFA (representing the covering regular approximation to the underlying CFL). Return an alternative number 1..n. Throw an exception upon error.

specialStateTransitionback to summary
public int specialStateTransition(int s, IntStream input) throws NoViableAltException
unpackEncodedStringback to summary
public static short[] unpackEncodedString(String encodedString)

Given a String that has a run-length-encoding of some unsigned shorts like "\1\2\3\9", convert to short[] {2,9,9,9}. We do this to avoid static short[] which generates so much init code that the class won't compile. :(

unpackEncodedStringToUnsignedCharsback to summary
public static char[] unpackEncodedStringToUnsignedChars(String encodedString)

Hideous duplication of code, but I need different typed arrays out :(