*/@
#include "TrafficLight-sharedC++.cws"
if !startString(getMarkupKey(), "DSL: ") error("DSL code expansion expected!");
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 {
@class @strategy.name@ : public TrafficLightStrategy {
public:
inline @strategy.name@() {}
virtual ~@strategy.name@() {}
virtual bool @strategy.name@::start() const {
return @strategy.start@;
}
virtual int @strategy.name@::executeRules() {
int iTriggeredRules = 0;
if (bActive_) {
@
incrementIndentLevel();
incrementIndentLevel();
foreach i in strategy.rules {
@ if (executeRule@i.key()@()) ++iTriggeredRules;
@
}
@ }
return iTriggeredRules;
}
@
foreach i in strategy.rules {
@virtual bool @strategy.name@::executeRule@i.key()@() {
if (@convertAntecedent2Cpp(i.condition)@ == false) {
return false;
}
@
foreach j in i.actions {
writeAction<j>(j);
}
@ return true;
}
@
}
decrementIndentLevel();
decrementIndentLevel();
@};
@
}
@/*

Generated by CodeWorker v3.10.3 from CWscript2HTML.cwp.