return true;
}
+ public void uninhibit(int p, Sequence s) {
+ if (s.hated!=null)
+ for(Sequence s2 : s.hated)
+ inhibited.remove(p, s2);
+ }
+
public void inhibit(Reduction r, int p) {
if (r.position.owner().hated == null) return;
// remember that dead states are still allowed to shift -- just not allowed to reduce
+ boolean reset = false;
for(Sequence seq : r.position.owner().hated) {
if (performed.contains(p,seq)) {
- inhibited.clear();
- inhibited.add(p, seq);
- resets++;
- throw new Reset();
+ uninhibit(p, seq);
+ //System.out.println("\nresetting due to " + r.position.owner() + " killing " + seq);
+ if (!reset) inhibited.add(p, seq);
+ reset = true;
}
- inhibited.add(p, seq);
+ if (!reset) inhibited.add(p, seq);
+ }
+ if (reset) {
+ resets++;
+ throw new Reset();
}
}
this.reduction = reduction;
}
public void perform() {
- System.out.println("performing: " + reduction.position);
+ //System.out.println("performing: " + reduction.position);
newNode(parent, pending, state, fromEmptyReduction, reduction);
}
}
q ::= [a-z]++ => "q"
}
-//testcase {
-//
-// input "
-//
-//
-// while x>0
-// while y>0
-// foo()
-// bar()
-//
-// while x>0
-// while y>0
-// foo()
-// bar()
-//
-//
-//";
-// output "smt:{while:{>:{{x} {0}} while:{>:{{y} {0}} sbb:{{f o o} {b a r}}}}}";
-// output "smt:{while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}}}";
-//
-//indent !::= ww
-//outdent !::= " " outdent " "
-// | " " (~[]*) "\n"
-//
-//any !::= ~[]*
-//s ::= any "\n\n" ww statement ww "\n\n" any => smt
-//ww !::= sp*
-//ws !::= sp**
-//sp ::= " "
-//
-//block ::= "\n" indent blockBody
-// &~ "\n" outdent ~[\ ] ~[]*
-//
-//blockBody ::= statement
-// > statement blockBody /ws => "sbb"
-//
-//statement ::= call
-// | ^"while" expr block /ws
-//
-//expr ::= ident
-// | call
-// | expr ^">" expr /ws
-// | num
-//
-//call ::= expr "()" /ws
-//
-//num ::= [0-9]++
-//
-//ident ::= [a-z]++ &~ keyword
-//keyword ::= "if" | "then" | "else" | "while"
-//
-//w ::= " " | "\n" | "\r"
-//ws ::= w*
-//
-//
-//}
+testcase {
+
+ input "
+
+
+
+ while x>0
+ while y>0
+ foo()
+ bar()
+
+ while x>0
+ while y>0
+ foo()
+ bar()
+
+
+
+";
+ output "smt:{while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}} while:{>:{{x} {0}} while:{>:{{y} {0}} sbb:{{f o o} {b a r}}}}}";
+ output "smt:{while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}} while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}}}";
+
+indent !::= ww
+outdent !::= " " outdent " "
+ | " " (~[]*) "\n"
+
+w !::= " " | "\n" | "\r"
+ws !::= w*
+ww !::= sp*
+sp !::= " "
+any !::= ~[]*
+
+s ::= ws statement ws statement ws => smt
+
+block ::= "\n" indent blockBody
+ &~ "\n" outdent ~[\ ] ~[]*
+
+blockBody ::= statement
+ | statement ws blockBody => "sbb"
+
+statement ::= call
+ | ^"while" expr block /ws
+
+expr ::= ident
+ | call
+ | expr ^">" expr /ws
+ | num
+
+call ::= expr "()" /ws
+
+num ::= [0-9]++
+
+ident ::= [a-z]++ &~ keyword
+keyword ::= "if" | "then" | "else" | "while"
+
+
+
+}