X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=18bec5a0aebfa2c5179116f1c92617f1162dd04b;hp=f6428781bed46d6511d7df89f8cbda848891a466;hb=21da21b94e794fa4d7c7207327764895d92ea528;hpb=8a9fc9f2357e54052374cf2ef003630a486a6c0a diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index f642878..18bec5a 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -91,7 +91,7 @@ public abstract class Parser { if (start0.contains(p.owner()) && p.next()==null) state.accept = true; - if (p.isRightNullable(cache)) { + if (isRightNullable(p)) { Walk.Follow wf = new Walk.Follow(top.empty(), p.owner(), all_elements, cache); Reduction red = new Reduction(p); @@ -121,6 +121,12 @@ public abstract class Parser { } } + private boolean isRightNullable(Position p) { + if (p.isLast()) return true; + if (!p.element().possiblyEpsilon(this)) return false; + return isRightNullable(p.next()); + } + /** a single state in the LR table and the transitions possible from it */ public class State implements Comparable, IntegerMappable, Iterable {