Package wyautl_old.lang.Automaton

Examples of wyautl_old.lang.Automaton.State


      for (int i = visited.nextSetBit(0); i >= 0; i = visited
          .nextSetBit(i + 1)) {
        nchildren[j++] = i;
      }
    }
    return new State(node.kind,node.data,node.deterministic,nchildren);
  }
View Full Code Here


    return new State(node.kind,node.data,node.deterministic,nchildren);
  }

  public static void main(String[] args) {
    State[] states = new State[3];
    states[0] = new State(0,false,new int[]{1});
    states[1] = new State(0,false,new int[]{1,2});
    states[2] = new State(0,false,new int[]{});
    Automaton a = new Automaton(states);
    System.out.println("GOT: " + a);
    a = minimise(a);
    System.out.println("NOW: " + a);
  }
View Full Code Here

      return false; // no change
    }
  }

  public boolean isRelated(int fromIndex, int toIndex) {
    State s1 = from.states[fromIndex];
    State s2 = to.states[toIndex];

    if(s1.kind == s2.kind && s1.deterministic == s2.deterministic) {
      boolean deterministic = s1.deterministic;

      if(deterministic) {
View Full Code Here

    private Record(Automaton automaton) {
      super(automaton);
    }

    public boolean isOpen() {
      State state = (State) automaton.states[0].data;
      return state.isOpen;
    }
View Full Code Here

     * extracted).
     *
     * @return
     */
    public HashSet<String> keys() {
      State fields = (State) automaton.states[0].data;
      HashSet<String> r = new HashSet<String>();
      for(String f : fields) {
        r.add(f);
      }
      return r;
View Full Code Here

      }
      return r;
    }

    public Type field(String field) {
      State fields = (State) automaton.states[0].data;
      int index = Collections.binarySearch(fields, field);
      if (index < 0) {
        return null; // not found
      } else {
        int[] children = automaton.states[0].children;
View Full Code Here

     * Return a mapping from field names to their types.
     *
     * @return
     */
    public HashMap<String, Type> fields() {
      State fields = (State) automaton.states[0].data;
      int[] children = automaton.states[0].children;
      HashMap<String, Type> r = new HashMap<String, Type>();
      for (int i = 0; i != children.length; ++i) {
        r.put(fields.get(i),
            construct(Automata.extract(automaton, children[i])));
      }
      return r;
    }
View Full Code Here

        this.isOpen = isOpen;
      }

      public boolean equals(Object o) {
        if (o instanceof State) {
          State s = (State) o;
          return isOpen == s.isOpen && super.equals(s);
        }
        return false;
      }
View Full Code Here

      // node already visited
      return headers[index];
    } else if(headers[index] != null) {
      visited.set(index);
    }
    State state = automaton.states[index];
    String middle;
    switch (state.kind) {
    case K_VOID:
      return "void";
    case K_ANY:
View Full Code Here

    if (visited.get(index)) {
      // node already visited
      return headers[index];
    }
    String middle = toString(index,visited,headers,automaton);
    State state = automaton.states[index];
    switch(state.kind) {
      case K_UNION:
      case K_FUNCTION:
      case K_METHOD:
        return "(" + middle + ")";
View Full Code Here

TOP

Related Classes of wyautl_old.lang.Automaton.State

Copyright © 2018 www.massapicom. 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.