From 5369a3291bb7828a68e20c82675791fc3e05e504 Mon Sep 17 00:00:00 2001 From: scmcduffee Date: Mon, 21 Dec 2009 10:46:18 -0500 Subject: [PATCH] every works (for a basic case anyway) --- parser/STGrammarRulesTestCase.java | 18 +++++++++++++++++- parser/celluloid.java.stg | 14 ++++++++++++-- parser/tests/helloCh4.cld | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 parser/tests/helloCh4.cld diff --git a/parser/STGrammarRulesTestCase.java b/parser/STGrammarRulesTestCase.java index 891f1b5..741deb3 100644 --- a/parser/STGrammarRulesTestCase.java +++ b/parser/STGrammarRulesTestCase.java @@ -36,9 +36,10 @@ public STGrammarRulesTestCase() { public void runAllTests() throws IOException, RecognitionException { //this.shouldThrowOnUndefinedInput(); //this.shouldThrowOnUndefinedFunction(); - this.shouldGenerateHelloCh1(); + // this.shouldGenerateHelloCh1(); //this.shouldGenerateHelloCh2(); //this.shouldGenerateHelloCh3(); + this.shouldGenerateHelloCh4(); //this.shouldGenerateHelloEvents(); //this.shouldGenerateHelloWorld(); //this.shouldGenerateEventDefinition(); @@ -105,6 +106,21 @@ public StringTemplate getTemplate(celluloidWalker walker) throws RecognitionExce testRunner.RunTest(); } + public void shouldGenerateHelloCh4() throws IOException, RecognitionException { + STTestRunner testRunner = new STTestRunner(this.testPath + "helloCh4.cld", this.templatePath) { + public CommonTree getTree(celluloidParser parser) throws RecognitionException { + return (CommonTree)parser.program().getTree(); + } + + public StringTemplate getTemplate(celluloidWalker walker) throws RecognitionException { + celluloidWalker.program_return r = walker.program(); + return (StringTemplate)r.getTemplate(); + } + }; + + testRunner.RunTest(); + } + public void shouldGenerateHelloEvents() throws IOException, RecognitionException { STTestRunner testRunner = new STTestRunner(this.testPath + "helloEvents.cld", this.templatePath) { public CommonTree getTree(celluloidParser parser) throws RecognitionException { diff --git a/parser/celluloid.java.stg b/parser/celluloid.java.stg index d0c8652..9f8aae0 100644 --- a/parser/celluloid.java.stg +++ b/parser/celluloid.java.stg @@ -128,8 +128,10 @@ whenStatement(with, name, event, lblock) ::= everyStatement(with, name, event, time, lblock) ::= << -.addEveryStatement( - new EveryFunction(new ReactiveNumber(