Skip to content

Commit

Permalink
every works (for a basic case anyway)
Browse files Browse the repository at this point in the history
  • Loading branch information
scmcduffee committed Dec 21, 2009
1 parent ddfe76e commit 5369a32
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
18 changes: 17 additions & 1 deletion parser/STGrammarRulesTestCase.java
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 12 additions & 2 deletions parser/celluloid.java.stg
Expand Up @@ -128,8 +128,10 @@ whenStatement(with, name, event, lblock) ::=

everyStatement(with, name, event, time, lblock) ::=
<<
<with>.addEveryStatement(
new EveryFunction(new ReactiveNumber(<time>),
<with>.addEveryFunction(
new EveryFunction(new ReactiveNumber(<time>), <lblock>

)

>>

Expand All @@ -156,6 +158,14 @@ new EventFunction(<name>) {
}
>>

everyFunctionCall(function, name, type, target) ::=
<< <target>, <name>) {
public void execute() {
if(evals[0].isPlaying())
((<type>) input).<function>();
}
>>

outputConstraintFunctionCall(
with, target,
type, function,
Expand Down
14 changes: 14 additions & 0 deletions parser/tests/helloCh4.cld
@@ -0,0 +1,14 @@
timeline timeline1

input video1 = new VideoFile("*some video 1")
input video2 = new VideoFile("*some video 2")

output output1 = new Video("*some display*")

in timeline1 do
every @10s video1 PLAYING do
play video2
end
end


0 comments on commit 5369a32

Please sign in to comment.