Packageorg.antlr.runtime
Classpublic class DFA

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.



Public Properties
 PropertyDefined by
  description : String
[read-only]
DFA
  error : Function
A hook for debugging interface
DFA
  specialStateTransition : Function
DFA
Protected Properties
 PropertyDefined by
  accept : Array
DFA
  decisionNumber : int
DFA
  eof : Array
DFA
  eot : Array
DFA
  max : Array
DFA
  min : Array
DFA
  recognizer : BaseRecognizer
Which recognizer encloses this DFA? Needed to check backtracking
DFA
  special : Array
DFA
  transition : Array
DFA
Public Methods
 MethodDefined by
  
DFA(recognizer:BaseRecognizer, decisionNumber:int, description:String, eot:Array, eof:Array, min:Array, max:Array, accept:Array, special:Array, transition:Array, specialStateTransitionFunction:Function = null, errorFunction:Function = null)
DFA
  
predict(input:IntStream):int
From the input stream, predict what alternative will succeed using this DFA (representing the covering regular approximation to the underlying CFL).
DFA
  
unpackEncodedString(encodedString:String, unsigned:Boolean = false):Array
[static] 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}.
DFA
Protected Methods
 MethodDefined by
  
noViableAlt(s:int, input:IntStream):void
DFA
Public Constants
 ConstantDefined by
  debug : Boolean = false
[static]
DFA
Property detail
acceptproperty
protected var accept:Array
decisionNumberproperty 
protected var decisionNumber:int
descriptionproperty 
description:String  [read-only]Implementation
    public function get description():String
eofproperty 
protected var eof:Array
eotproperty 
protected var eot:Array
errorproperty 
public var error:Function

A hook for debugging interface

maxproperty 
protected var max:Array
minproperty 
protected var min:Array
recognizerproperty 
protected var recognizer:BaseRecognizer

Which recognizer encloses this DFA? Needed to check backtracking

specialproperty 
protected var special:Array
specialStateTransitionproperty 
public var specialStateTransition:Function
transitionproperty 
protected var transition:Array
Constructor detail
DFA()constructor
public function DFA(recognizer:BaseRecognizer, decisionNumber:int, description:String, eot:Array, eof:Array, min:Array, max:Array, accept:Array, special:Array, transition:Array, specialStateTransitionFunction:Function = null, errorFunction:Function = null)Parameters
recognizer:BaseRecognizer
 
decisionNumber:int
 
description:String
 
eot:Array
 
eof:Array
 
min:Array
 
max:Array
 
accept:Array
 
special:Array
 
transition:Array
 
specialStateTransitionFunction:Function (default = null)
 
errorFunction:Function (default = null)
Method detail
noViableAlt()method
protected function noViableAlt(s:int, input:IntStream):voidParameters
s:int
 
input:IntStream
predict()method 
public function predict(input:IntStream):int

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.

Parameters
input:IntStream

Returns
int
unpackEncodedString()method 
public static function unpackEncodedString(encodedString:String, unsigned:Boolean = false):Array

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. :(

Parameters
encodedString:String
 
unsigned:Boolean (default = false)

Returns
Array
Constant detail
debugconstant
public static const debug:Boolean = false