From: adam Date: Sun, 8 Jan 2006 03:50:43 +0000 (-0500) Subject: intermediate checkpoint X-Git-Tag: tag_for_25-Mar~419 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=ceca07b4020b5dd051e0d01767a35842dec2ca74;ds=sidebyside intermediate checkpoint darcs-hash:20060108035043-5007d-c8ccd495e43468587e836f51d74992f86834aa10.gz --- diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java index 2b8be3b..9ab6587 100644 --- a/src/edu/berkeley/sbp/GSS.java +++ b/src/edu/berkeley/sbp/GSS.java @@ -230,17 +230,28 @@ class GSS { 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(); } } @@ -321,7 +332,7 @@ class GSS { this.reduction = reduction; } public void perform() { - System.out.println("performing: " + reduction.position); + //System.out.println("performing: " + reduction.position); newNode(parent, pending, state, fromEmptyReduction, reduction); } } diff --git a/tests/regression.tc b/tests/regression.tc index 025500a..37a302e 100644 --- a/tests/regression.tc +++ b/tests/regression.tc @@ -255,59 +255,61 @@ testcase { 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" + + + +}