Package

Source Code of TestRTS

import lexer.RTS;
import lexer.DFA;

import java.util.*;

class TestRTS {
  public static void main(String args[]) throws Exception {
    RTS r = new RTS();
    if (!r.isEmpty()) {
      throw new Exception("RTS() error");
    }
    int stateNo = 10;
    int startState = 0;
    int finalState = 1;
    String strAlpha = "abc";
    Character symbols[] = { /*0*/ null,
                /*1*/ null,
                /*2*/ new Character('a'),
                /*3*/ null,
                /*4*/ new Character('b'),
                /*5*/ null,
                /*6*/ null,
                /*7*/ null,
                /*8*/ new Character('c'),
                /*9*/ null };
    Integer next1[] = /*0*/ new Integer(2),
              /*1*/ null,
              /*2*/ new Integer(3),
              /*3*/ new Integer(4),
              /*4*/ new Integer(5),
              /*5*/ new Integer(1),
              /*6*/ new Integer(8),
              /*7*/ new Integer(1),
              /*8*/ new Integer(9),
              /*9*/ new Integer(8)};
    Integer next2[] = /*0*/ new Integer(6),
              /*1*/ null,
              /*2*/ null,
              /*3*/ null,
              /*4*/ null,
              /*5*/ null,
              /*6*/ new Integer(7),
              /*7*/ null,
              /*8*/ null,
              /*9*/ new Integer(7)};
    r = new RTS(stateNo, startState, finalState, strAlpha, symbols, next1, next2);
    r.print();

    HashSet set = new HashSet();
    boolean b = r.lambda(0, set);
    System.out.print("lambda(0): "+set+" return: "+b);

    lexer.DFA d = new lexer.DFA(r);
    System.out.print("\nDFA: "+d);

    System.out.print("\nacceptsString(\"\"): "+d.acceptsString(""));
    System.out.print("\nacceptsString(\"ab\"): "+d.acceptsString("ab"));
    System.out.print("\nacceptsString(\"aa\"): "+d.acceptsString("aa"));
    System.out.print("\nacceptsString(\"c\"): "+d.acceptsString("c"));
    System.out.print("\nacceptsString(\"cccccc\"): "+d.acceptsString("cccccc"));
  }
}
TOP

Related Classes of TestRTS

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.