Various test fixes

This commit is contained in:
Peter Boyer 2016-01-19 10:44:16 -05:00
parent 86d65cf719
commit 92b8f9f891
5 changed files with 11 additions and 8 deletions

View File

@ -183,7 +183,7 @@ SetMember(n,v) ::= <%<n> = <v>;%>
AddMember(n,v) ::= <%<n> += <v>;%>
PlusMember(v,n) ::= <%<v> + <n>%>
PlusMember(v,n) ::= <%<v> + fmt.Sprint(<n>)%>
MemberEquals(n,v) ::= <%<n> == <v>%>
@ -432,9 +432,10 @@ func (this *LeafListener) ExitInt(ctx *IntContext) {
DeclareContextListGettersFunction() ::= <<
func foo() {
SContext s = null;
List\<? extends AContext> a = s.a();
List\<? extends BContext> b = s.b();
//TODO
//SContext s = null;
//List\<? extends AContext> a = s.A();
//List\<? extends BContext> b = s.B();
}
>>
@ -453,7 +454,7 @@ func pred(v bool) bool {
}
>>
Invoke_pred(v) ::= <<p.pred(<v>)>>
Invoke_pred(v) ::= <<pred(<v>)>>
IgnoredTests ::= [
default: false

View File

@ -599,11 +599,11 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(247);
StringBuilder grammarBuilder = new StringBuilder(259);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; }\n");
grammarBuilder.append("s : ({i += 1;\n");
grammarBuilder.append("fmt.Println(\"i=\" + i)} a)+ ;\n");
grammarBuilder.append("fmt.Println(\"i=\" + fmt.Sprint(i))} a)+ ;\n");
grammarBuilder.append("a : {i % 2 == 0}? ID {fmt.Println(\"alt 1\")}\n");
grammarBuilder.append(" | {i % 2 != 0}? ID {fmt.Println(\"alt 2\")}\n");
grammarBuilder.append(" ;\n");

View File

@ -954,6 +954,7 @@ func (this *ParserATNSimulator) evalSemanticContext(predPredictions []*PredPredi
}
continue
}
fmt.Println(predPredictions)
var predicateEvaluationResult = pair.pred.evaluate(this.parser, outerContext)
if ParserATNSimulatorDebug || ParserATNSimulatorDFADebug {
fmt.Println("eval pred " + pair.String() + "=" + fmt.Sprint(predicateEvaluationResult))

View File

@ -382,6 +382,7 @@ func (this *OR) Hash() string {
// unordered.</p>
//
func (this *OR) evaluate(parser Recognizer, outerContext RuleContext) bool {
fmt.Println("HI")
for i := 0; i < len(this.opnds); i++ {
if this.opnds[i].evaluate(parser, outerContext) {
return true

View File

@ -600,7 +600,7 @@ TokenPropertyRef_int(t) ::= "(func() int { if <ctx(t)>.Get<t.label; format={cap}
RulePropertyRef_start(r) ::= "(func() antlr4.Token { if <ctx(r)>.Get<r.label;format={cap}>() == nil { return nil } else { return <ctx(r)>.Get<r.label;format={cap}>().GetStart() }}())"
RulePropertyRef_stop(r) ::= "(func() antlr4.Token { if <ctx(r)>.Get<r.label;format={cap}>() == nil { return nil } else { return <ctx(r)>.Get<r.label;format={cap}>().GetStop() }}())"
RulePropertyRef_text(r) ::= "(func() string { if <ctx(r)>.Get<r.label;format={cap}>() == nil { return \"\" } else { return p.GetTokenStream().GetTextFromTokens( <ctx(r)>.Get<r.label;format={cap}>().GetStart(),<ctx(r)>.<r.label>.GetStop())) }}())"
RulePropertyRef_text(r) ::= "(func() string { if <ctx(r)>.Get<r.label;format={cap}>() == nil { return \"\" } else { return p.GetTokenStream().GetTextFromTokens( <ctx(r)>.Get<r.label;format={cap}>().GetStart(),<ctx(r)>.<r.label>.GetStop()) }}())"
RulePropertyRef_ctx(r) ::= "<ctx(r)>.Get<r.label;format={cap}>()"
RulePropertyRef_parser(r) ::= "p"