rename Node->StateNode
[sbp.git] / src / edu / berkeley / sbp / ParseFailed.java
index 8000712..872ffac 100644 (file)
@@ -1,10 +1,11 @@
-// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
+// Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license
 
 package edu.berkeley.sbp;
 import edu.berkeley.sbp.*;
-import edu.berkeley.sbp.Sequence.Position;
+import edu.berkeley.sbp.Sequence.Pos;
+import edu.berkeley.sbp.Sequence.Pos;
 import edu.berkeley.sbp.GSS.Phase;
-import edu.berkeley.sbp.Node;
+import edu.berkeley.sbp.StateNode;
 import edu.berkeley.sbp.util.*;
 import java.io.*;
 import java.util.*;
@@ -34,7 +35,7 @@ public class ParseFailed extends Exception {
         return ret.toString();
     }
 
-    private static boolean important(Position p) {
+    private static boolean important(Pos p) {
         if (p.isLast()) return false;
         if (p.element() == null) return false;
         if (!(p.element() instanceof Union)) return false;
@@ -46,28 +47,29 @@ public class ParseFailed extends Exception {
         return (c >= 'A' && c <= 'Z');
     }
 
-    static <Tok> void barf(HashMap<Element,Input.Location> sb, Node n, int indent, boolean skip, int count, Input.Location loc) {
+    static <Tok> void barf(HashMap<Element,Input.Location> sb, StateNode n, int indent, boolean skip, int count, Input.Location loc) {
         if (count <= 0) {
             barf(sb, n, indent, skip, loc);
         } else {
             /*
               FIXME: removed
-            for(Node nn : (Iterable<Node>)n.parents())
+            for(StateNode nn : (Iterable<StateNode>)n.parents())
                 barf(sb, nn, indent, skip, count-1, n.phase().getLocation());
             */
         }
     }
-    static <Tok> void barf(HashMap<Element,Input.Location> sb, Node n, int indent, boolean skip, Input.Location loc) {
+    static <Tok> void barf(HashMap<Element,Input.Location> sb, StateNode n, int indent, boolean skip, Input.Location loc) {
         if (touched.contains(n)) return;
         touched.add(n);
         String s = "";
         for(int i=0; i< indent; i++) s += " ";
-        Node parent = n;
+        StateNode parent = n;
         boolean done = false;
         boolean alldone = false;
         boolean go = false;
         boolean force = false;
-        for(Position p : (Iterable<Position>)parent.state()) {
+        for(Pos pp : (Iterable<Pos>)parent.state().positions()) {
+            Pos p = (Pos)pp;
             if (skip) p = p.next();
             int raise = 0;
             done = false;
@@ -100,17 +102,17 @@ public class ParseFailed extends Exception {
 
 
     // FIXME
-    private static HashSet<Node> touched = new HashSet<Node>();
-    static <Tok> void complain(Node n, HashMap<String,HashSet<String>> errors, boolean force, int indent) {
+    private static HashSet<StateNode> touched = new HashSet<StateNode>();
+    static <Tok> void complain(StateNode n, HashMap<String,HashSet<String>> errors, boolean force, int indent) {
         if (touched.contains(n)) return;
         touched.add(n);
-        for(Position p : (Iterable<Position>)n.state()) {
+        for(Pos p : (Iterable<Pos>)n.state()) {
             //if (!p.isLast() && !p.next().isLast()) continue;
             if (((p.isFirst() || p.isLast()) && !force)/* || p.owner().name==null*/ ||
                 !important(p)) {
             /*
               FIXME: removed
-                for(Node n2 : n.parents())
+                for(StateNode n2 : n.parents())
                     complain(n2, errors, force
                     //| p.isFirst()
                 , indent);
@@ -148,7 +150,7 @@ public class ParseFailed extends Exception {
     }
     private static void error(String message,
                               Object token,
-                              Iterable<Node> nodes,
+                              Iterable<StateNode> nodes,
                               Input.Region region,
                               Input input,
                               GSS gss) throws ParseFailed{
@@ -182,7 +184,7 @@ public class ParseFailed extends Exception {
             */
         }
         HashMap<Element,Input.Location> hm = new HashMap<Element,Input.Location>();
-        for(Node no : nodes)
+        for(StateNode no : nodes)
             barf(hm, no, 0, false, region.getStart());
         ret.append("\n expected: ");
         Set<Element> hs = hm.keySet();
@@ -205,7 +207,7 @@ public class ParseFailed extends Exception {
         /*
         ret.append("\n  The author of SBP apologizes for the these nearly-useless error messages:\n\n");
         HashMap<String,HashSet<String>> errors = new HashMap<String,HashSet<String>>();
-        for(Node n : nodes) {
+        for(StateNode n : nodes) {
             //System.out.println(n.state);
             complain(n, errors, false, 0);
         }