X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=f239fe5edddf7c30cb61ab22b3bcc5efb3494dfd;hp=10768f66e35d1228f3c2db4c7ae6a22923a0d431;hb=9e202722669e70d83e3e09d926bfb40f80a1e9cb;hpb=e84029a8b861075d6d0ed5040f919b2e4da4c98f diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 10768f6..f239fe5 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -9,7 +9,6 @@ import java.util.*; /** a parser which translates an Input<Token> into a Forest<NodeType> */ public abstract class Parser { - protected final Table pt; /** create a parser to parse the grammar with start symbol u */ @@ -38,16 +37,18 @@ public abstract class Parser { loc = input.getLocation(); Token nextToken = input.next(); GSS.Phase next = gss.new Phase(current, current, nextToken, loc, input.getLocation(), forest); - if (!helpgc) { - FileOutputStream fos = new FileOutputStream("out-"+idx+".dot"); - PrintWriter p = new PrintWriter(new OutputStreamWriter(fos)); - GraphViz gv = new GraphViz(); - for(Object n : next) - ((Node)n).toGraphViz(gv); - gv.dump(p); - p.flush(); - p.close(); - } + + /* + FileOutputStream fos = new FileOutputStream("out-"+idx+".dot"); + PrintWriter p = new PrintWriter(new OutputStreamWriter(fos)); + GraphViz gv = new GraphViz(); + for(Object n : current) + ((Node)n).toGraphViz(gv); + gv.dump(p); + p.flush(); + p.close(); + */ + count = next.size(); if (current.isDone()) return (Forest)gss.finalResult; current = next; @@ -75,6 +76,8 @@ public abstract class Parser { sb.append(" reduce \""+ new edu.berkeley.sbp.chr.CharTopology((IntegerTopology)t)+"\" => " + state.reductions.getAll(t) + "\n"); + for(Sequence s : state.gotoSetNonTerminals.keySet()) + sb.append(" goto "+state.gotoSetNonTerminals.get(s)+" from " + s + "\n"); } return sb.toString(); } @@ -122,6 +125,8 @@ public abstract class Parser { walk(start0, all_elements); for(SequenceOrElement e : all_elements) cache.ys.addAll(e, new Walk.YieldSet(e, cache).walk()); + for(SequenceOrElement e : all_elements) + cache.ys2.addAll(e, new Walk.YieldSet2(e, cache).walk()); HashSet hp = new HashSet(); reachable(start0, hp); @@ -289,7 +294,8 @@ public abstract class Parser { for(Position p : hs) { Element e = p.element(); if (e==null) continue; - for(SequenceOrElement y : cache.ys.getAll(e)) { + for(SequenceOrElement y : cache.ys2.getAll(e)) { + //System.out.println(e + " yields " + y); HashSet hp = new HashSet(); reachable(p.next(), hp); move.addAll(y, hp);