alter test so it works with all targets

This commit is contained in:
parrt 2016-11-07 15:02:57 -08:00
parent da342af01e
commit 7f16fe6201
8 changed files with 23 additions and 15 deletions

View File

@ -33,7 +33,8 @@ grammar(grammarName) ::= <<
grammar <grammarName>;
@parser::members {<InitIntMember("i","0")>}
s : ({<AddMember("i","1")>
<PlusMember("\"i=\"","i"):writeln()>} a)+ ;
<write("\"i=\"")>
<writeln(GetMember("i"))>} a)+ ;
a : {<ModMemberEquals("i","2","0")>}? ID {<writeln("\"alt 1\"")>}
| {<ModMemberNotEquals("i","2","0")>}? ID {<writeln("\"alt 2\"")>}
;

View File

@ -670,11 +670,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(277);
StringBuilder grammarBuilder = new StringBuilder(289);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@parser::members {int i = 0;}\n");
grammarBuilder.append("s : ({i += 1;\n");
grammarBuilder.append("std::cout << \"i=\" + i << std::endl;} a)+ ;\n");
grammarBuilder.append("std::cout << \"i=\";\n");
grammarBuilder.append("std::cout << i << std::endl;} a)+ ;\n");
grammarBuilder.append("a : {i % 2 == 0}? ID {std::cout << \"alt 1\" << std::endl;}\n");
grammarBuilder.append(" | {i % 2 != 0}? ID {std::cout << \"alt 2\" << std::endl;}\n");
grammarBuilder.append(" ;\n");

View File

@ -551,11 +551,12 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(276);
StringBuilder grammarBuilder = new StringBuilder(290);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@parser::members {int i = 0;}\n");
grammarBuilder.append("s : ({this.i += 1;\n");
grammarBuilder.append("Console.WriteLine(\"i=\" + this.i);} a)+ ;\n");
grammarBuilder.append("Console.Write(\"i=\");\n");
grammarBuilder.append("Console.WriteLine(this.i);} a)+ ;\n");
grammarBuilder.append("a : {this.i % 2 == 0}? ID {Console.WriteLine(\"alt 1\");}\n");
grammarBuilder.append(" | {this.i % 2 != 0}? ID {Console.WriteLine(\"alt 2\");}\n");
grammarBuilder.append(" ;\n");

View File

@ -579,11 +579,12 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(267);
StringBuilder grammarBuilder = new StringBuilder(264);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@parser::members {var i int = 0; var _ int = i; }\n");
grammarBuilder.append("s : ({i += 1;\n");
grammarBuilder.append("fmt.Println(\"i=\" + fmt.Sprint(i))} a)+ ;\n");
grammarBuilder.append("fmt.Print(\"i=\")\n");
grammarBuilder.append("fmt.Println(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

@ -646,11 +646,12 @@ public class TestSemPredEvalParser extends BaseTest {
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(279);
StringBuilder grammarBuilder = new StringBuilder(296);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@parser::members {int i = 0;}\n");
grammarBuilder.append("s : ({this.i += 1;\n");
grammarBuilder.append("System.out.println(\"i=\" + this.i);} a)+ ;\n");
grammarBuilder.append("System.out.print(\"i=\");\n");
grammarBuilder.append("System.out.println(this.i);} a)+ ;\n");
grammarBuilder.append("a : {this.i % 2 == 0}? ID {System.out.println(\"alt 1\");}\n");
grammarBuilder.append(" | {this.i % 2 != 0}? ID {System.out.println(\"alt 2\");}\n");
grammarBuilder.append(" ;\n");

View File

@ -600,11 +600,12 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(260);
StringBuilder grammarBuilder = new StringBuilder(281);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@parser::members {this.i = 0;}\n");
grammarBuilder.append("s : ({this.i += 1;\n");
grammarBuilder.append("console.log(\"i=\" + this.i);} a)+ ;\n");
grammarBuilder.append("process.stdout.write(\"i=\");\n");
grammarBuilder.append("console.log(this.i);} a)+ ;\n");
grammarBuilder.append("a : {this.i % 2 === 0}? ID {console.log(\"alt 1\");}\n");
grammarBuilder.append(" | {this.i % 2 != 0}? ID {console.log(\"alt 2\");}\n");
grammarBuilder.append(" ;\n");

View File

@ -670,11 +670,12 @@ public class TestSemPredEvalParser extends BasePython2Test {
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(236);
StringBuilder grammarBuilder = new StringBuilder(243);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@parser::members {i = 0}\n");
grammarBuilder.append("s : ({self.i += 1\n");
grammarBuilder.append("print(\"i=\" + str(self.i))} a)+ ;\n");
grammarBuilder.append("print(\"i=\",end='')\n");
grammarBuilder.append("print(self.i)} a)+ ;\n");
grammarBuilder.append("a : {self.i % 2 == 0}? ID {print(\"alt 1\")}\n");
grammarBuilder.append(" | {self.i % 2 != 0}? ID {print(\"alt 2\")}\n");
grammarBuilder.append(" ;\n");

View File

@ -670,11 +670,12 @@ public class TestSemPredEvalParser extends BasePython3Test {
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(236);
StringBuilder grammarBuilder = new StringBuilder(243);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@parser::members {i = 0}\n");
grammarBuilder.append("s : ({self.i += 1\n");
grammarBuilder.append("print(\"i=\" + str(self.i))} a)+ ;\n");
grammarBuilder.append("print(\"i=\",end='')\n");
grammarBuilder.append("print(self.i)} a)+ ;\n");
grammarBuilder.append("a : {self.i % 2 == 0}? ID {print(\"alt 1\")}\n");
grammarBuilder.append(" | {self.i % 2 != 0}? ID {print(\"alt 2\")}\n");
grammarBuilder.append(" ;\n");