JFlex

Class NFA


public final class NFA
extends java.lang.Object

NFA representation in JFlex. Contains algorithms RegExp -> NFA and NFA -> DFA.

Constructor Summary

NFA(int numInput, LexScan scanner, RegExps regExps, Macros macros, CharClasses classes)
Construct new NFA.
NFA(int numInput, int estSize)

Method Summary

void
addEpsilonTransition(int start, int dest)
void
addRegExp(int regExpNum)
Add a regexp to this NFA.
void
addStandaloneRule()
Add a standalone rule that has minimum priority, fires a transition on all single input characters and has a "print yytext" action.
void
addTransition(int start, int input, int dest)
String
dotFormat()
void
dumpTable()
DFA
getDFA()
Returns an DFA that accepts the same language as this NFA.
IntPair
insertNFA(RegExp regExp)
Constructs an NFA for regExp such that the NFA has exactly one start state, exactly one end state, no transitions leading out of the end state no transitions leading into the start state
int
numEntryStates()
String
toString()
void
writeDot(File file)

Constructor Details

NFA

public NFA(int numInput,
           LexScan scanner,
           RegExps regExps,
           Macros macros,
           CharClasses classes)
Construct new NFA. Assumes that lookahead cases and numbers are already resolved in RegExps.

NFA

public NFA(int numInput,
           int estSize)

Method Details

addEpsilonTransition

public void addEpsilonTransition(int start,
                                 int dest)

addRegExp

public void addRegExp(int regExpNum)
Add a regexp to this NFA.
Parameters:
regExpNum - the number of the regexp to add.

addStandaloneRule

public void addStandaloneRule()
Add a standalone rule that has minimum priority, fires a transition on all single input characters and has a "print yytext" action.

addTransition

public void addTransition(int start,
                          int input,
                          int dest)

dotFormat

public String dotFormat()

dumpTable

public void dumpTable()

getDFA

public DFA getDFA()
Returns an DFA that accepts the same language as this NFA. This DFA is usually not minimal.

insertNFA

public IntPair insertNFA(RegExp regExp)
Constructs an NFA for regExp such that the NFA has exactly one start state, exactly one end state, no transitions leading out of the end state no transitions leading into the start state
Parameters:
regExp - the regular expression to construct the NFA for
Returns:
a pair of integers denoting the index of start and end state of the NFA.

numEntryStates

public int numEntryStates()

toString

public String toString()

writeDot

public void writeDot(File file)