JFlex
Class NFA

java.lang.Object
  extended byJFlex.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)
           
NFA(int numInput, LexScan scanner, RegExps regExps, Macros macros, CharClasses classes)
           
 
Method Summary
 void addEpsilonTransition(int start, int dest)
           
 void addRegExp(int regExpNum)
           
 void addStandaloneRule()
           
 void addTransition(int start, int input, int dest)
           
 JFlex.IntPair complement(JFlex.IntPair nfa)
          Constructs an NFA accepting the complement of the language of a given NFA.
 java.lang.String dotFormat()
           
 void dumpTable()
           
 DFA getDFA()
          Returns an DFA that accepts the same language as this NFA.
 JFlex.IntPair insertClassNFA(java.util.Vector intervalls)
           
 JFlex.IntPair insertLetterNFA(char letter)
           
 JFlex.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
 JFlex.IntPair insertNotClassNFA(java.util.Vector intervalls)
           
 JFlex.IntPair insertStringNFA(java.lang.String letters)
           
 java.lang.String toString()
           
 void writeDot(java.io.File file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NFA

public NFA(int numInput)

NFA

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

addStandaloneRule

public void addStandaloneRule()

addRegExp

public void addRegExp(int regExpNum)

addTransition

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

addEpsilonTransition

public void addEpsilonTransition(int start,
                                 int dest)

getDFA

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


dumpTable

public void dumpTable()

toString

public java.lang.String toString()

writeDot

public void writeDot(java.io.File file)

dotFormat

public java.lang.String dotFormat()

insertLetterNFA

public JFlex.IntPair insertLetterNFA(char letter)

insertStringNFA

public JFlex.IntPair insertStringNFA(java.lang.String letters)

insertClassNFA

public JFlex.IntPair insertClassNFA(java.util.Vector intervalls)

insertNotClassNFA

public JFlex.IntPair insertNotClassNFA(java.util.Vector intervalls)

complement

public JFlex.IntPair complement(JFlex.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.

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

insertNFA

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