Class ThompsonCompiler

java.lang.Object
  extended byThompsonCompiler
All Implemented Interfaces:
ExpressionCompiler

public class ThompsonCompiler
extends java.lang.Object
implements ExpressionCompiler

Compiles a rational expression into an automaton of the class NFA by Thompson's algorithm. Uses a top-down analysis for the grammar
E -> E+T | T ,
T -> TF | F ,
F -> G | G* ,
G -> (E) | char .


Constructor Summary
ThompsonCompiler()
           
 
Method Summary
 void advance()
          Implements the function Advance() of Section 1.6.1.
 char current()
          Implements the function Current() of Section 1.6.1.
 LinkedNFA evalExp()
          Implements the function EvalExp() of Section 1.6.1.
 LinkedNFA evalFact()
          Implements the function EvalFact() of Section 1.6.1.
 LinkedNFA evalTerm()
          Implements the function EvalTerm() of Section 1.6.1.
 LinkedNFA toLinkedNFA()
           
 NFA toNFA(java.lang.String s)
          Compiles the expression into a nondeterministic finite automaton.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThompsonCompiler

public ThompsonCompiler()
Method Detail

current

public char current()
Implements the function Current() of Section 1.6.1. Returns the current character of the input expression.


advance

public void advance()
Implements the function Advance() of Section 1.6.1. Advances to the next character in the input expression.


evalExp

public LinkedNFA evalExp()
Implements the function EvalExp() of Section 1.6.1. Returns a LinkedNFA recognizing the expression.


evalTerm

public LinkedNFA evalTerm()
Implements the function EvalTerm() of Section 1.6.1.


evalFact

public LinkedNFA evalFact()
Implements the function EvalFact() of Section 1.6.1.


toLinkedNFA

public LinkedNFA toLinkedNFA()

toNFA

public NFA toNFA(java.lang.String s)
Compiles the expression into a nondeterministic finite automaton. Internally, the function computes an automaton of the class LinkedNFA and then converts it into an NFA.

Specified by:
toNFA in interface ExpressionCompiler