JFlex

Class NFA

public final class NFA extends Object

NFA representation in JFlex. Contains algorithms RegExp -> NFA and NFA -> DFA.
Constructor Summary
NFA(int numInput)
NFA(int numInput, LexScan scanner, RegExps regExps, Macros macros, CharClasses classes)
Method Summary
voidaddEpsilonTransition(int start, int dest)
voidaddRegExp(int regExpNum)
voidaddStandaloneRule()
voidaddTransition(int start, int input, int dest)
IntPaircomplement(IntPair nfa)
Constructs an NFA accepting the complement of the language of a given NFA.
StringdotFormat()
voiddumpTable()
DFAgetDFA()
Returns an DFA that accepts the same language as this NFA.
IntPairinsertClassNFA(Vector intervalls)
IntPairinsertLetterNFA(char letter)
IntPairinsertNFA(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
IntPairinsertNotClassNFA(Vector intervalls)
IntPairinsertStringNFA(String letters)
StringtoString()
voidwriteDot(File file)

Constructor Detail

NFA

public NFA(int numInput)

NFA

public NFA(int numInput, LexScan scanner, RegExps regExps, Macros macros, CharClasses classes)

Method Detail

addEpsilonTransition

public void addEpsilonTransition(int start, int dest)

addRegExp

public void addRegExp(int regExpNum)

addStandaloneRule

public void addStandaloneRule()

addTransition

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

complement

public IntPair complement(IntPair nfa)
Constructs an NFA accepting the complement of the language of a given NFA. Converts the NFA into a DFA, then negates that DFA. Exponential state blowup possible and common.

Parameters: the NFA to construct the complement for.

Returns: a pair of integers denoting the index of start and end state of the complement NFA.

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 usualy not minimal.

insertClassNFA

public IntPair insertClassNFA(Vector intervalls)

insertLetterNFA

public IntPair insertLetterNFA(char letter)

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.

insertNotClassNFA

public IntPair insertNotClassNFA(Vector intervalls)

insertStringNFA

public IntPair insertStringNFA(String letters)

toString

public String toString()

writeDot

public void writeDot(File file)