@
#include "TrafficLight-sharedFunctions.cws"
function generateJavaClass(strategy : node) {
@class @strategy.name@ extends TrafficLightStrategy {
public @strategy.name@() {}
public bool start() {
return @strategy.start@;
}
public int executeRules() {
int iTriggeredRules = 0;
if (bActive_) {
@
incrementIndentLevel();
foreach i in strategy.rules {
@ if (executeRule@i.key()@()) ++iTriggeredRules;
@
}
@ }
return iTriggeredRules;
}
@
foreach i in strategy.rules {
@private bool executeRule@i.key()@() {
if (@convertAntecedent2Cpp(i.condition)@ == false) {
return false;
}
@
foreach j in i.actions {
writeAction<j>(j, "Java");
}
@ return true;
}
@
}
decrementIndentLevel();
@}
@
}
if getMarkupKey() == "strategies" {
foreach strategy in this.strategies {
generateJavaClass(strategy);
}
} else if startString(getMarkupKey(), "DSL: ") {
if subString(getMarkupKey(), 5) != "TrafficLight" {
error("only one DSL recognized for the moment: 'TrafficLight'!");
}
local theParseTree;
parseStringAsBNF("TrafficLight.cwp", theParseTree, getMarkupValue());
@*/
@
foreach strategy in theParseTree.strategies {
generateJavaClass(strategy);
}
@/*
@
}
Generated by CodeWorker v3.11.0.1 from CWscript2HTML.cwp.