X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=2fc0691e3dc4d307060b74a81fefd528d91c97e2;hp=5f6e2526d80d4aeffe7daa5890225a92ce2be1d6;hb=6f1b2b1cba77222aeed1594d878b8c1250e31c1f;hpb=61566402d83d5c06d57fb850e60ca0f82c27b9a2 diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 5f6e252..2fc0691 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -8,7 +8,7 @@ import java.io.*; import java.util.*; /** a parser which translates an Input<Token> into a Forest<NodeType> */ -public abstract class Parser { +public abstract class Parser implements Serializable { final Table pt; @@ -106,7 +106,7 @@ public abstract class Parser { // Table ////////////////////////////////////////////////////////////////////////////// /** an SLR(1) parse table which may contain conflicts */ - class Table extends Grammar implements Serializable { + class Table implements Serializable { /** the start state */ final State start; @@ -273,8 +273,8 @@ public abstract class Parser { HashMap> gotoSetNonTerminals = new HashMap>(); private transient TopologicalBag> gotoSetTerminals = new TopologicalBag>(); - private TopologicalBag reductions = new TopologicalBag(); - private HashSet eofReductions = new HashSet(); + TopologicalBag reductions = new TopologicalBag(); + HashSet eofReductions = new HashSet(); private TopologicalBag> shifts = new TopologicalBag>(); private boolean accept = false; @@ -290,16 +290,16 @@ public abstract class Parser { Iterable positions() { return hs; } boolean canShift(Token t) { return oshifts!=null && oshifts.contains(t); } - void invokeShifts(Token t, GSS.Phase phase, Result r) { oshifts.invoke(t, phase, r); } + void invokeShifts(Token t, GSS.Phase phase, Node pred, Forest f) { oshifts.invoke(t, phase, pred, f); } boolean canReduce(Token t) { return oreductions != null && (t==null ? eofReductions.size()>0 : oreductions.contains(t)); } void invokeEpsilonReductions(Token t, Node node) { - if (t==null) for(Pos r : eofReductions) node.invoke(r, null); - else oreductions.invoke(t, node, null); + if (t==null) for(Pos r : eofReductions) node.invoke(r, null, null); + else oreductions.invoke(t, node, null, null); } void invokeReductions(Token t, Node node, Result b) { - if (t==null) for(Pos r : eofReductions) node.invoke(r, b); - else oreductions.invoke(t, node, b); + if (t==null) for(Pos r : eofReductions) node.invoke(r, b, null); + else oreductions.invoke(t, node, b, null); } // Constructor //////////////////////////////////////////////////////////////////////////////