1// iterate all strategy file having the extension ".tlc" 2forfile strategyFile in "*.tlc" { 3 // The BNF parse script "TrafficLight.cwp" applies on the strategy file 4 // and populates the global variable 'project'. 5 parseAsBNF("TrafficLight.cwp", project, strategyFile); 6 7 // Iterate all strategies and generates a C++ header and body but also 8 // a picture for each. 9 // The template-based script applies on a sub node of the parse tree, 10 // corresponding to the specification of the current strategy, and generates 11 // a C++ file or a Graphviz input file. 12 foreach i in project.strategies { 13 generate("TrafficLight-headerC++.cwt", i, "output/" + i.name + ".h"); 14 generate("TrafficLight-bodyC++.cwt", i, "output/" + i.name + ".cpp"); 15 // Generate the input file for Graphviz, which will build a PNG picture 16 generate("TrafficLight-Graphviz.cwt", i, i.name + ".grz"); 17 system("../../../bin/dot.exe -Tpng -o " + i.name + ".png " + i.name + ".grz"); 18 } 19 20 21 // The translation script "TrafficLight2OpenOffice20.cwp" applies on the 22 // strategy file and generates the content of an Open Office 2.0 text 23 // document. We didn't put here the zip compression of the generated file 24 // with some others and its renaming to a ".odt" extension. 25 translate("TrafficLight2OpenOffice20.cwp", project, strategyFile, "OpenOffice2.0/content.xml"); 26} 27 28// strategies for test are injected directly into the Java simulator 29expand("TrafficLight-embeddedJava.cwt", project, "TrafficLightSimulator.java"); 30 31// Save the parse tree to a XML file, just for showing the structure of the tree 32saveProject("strategies.xml"); 33 34//-------------------------------------------------------------------------------- 35 36forfile i in "*.cw*" { 37 local theOptions; 38 insert theOptions.docURL = "http://www.codeworker.org/"; 39 translate("../../repository/CWScript2HTML.cwp", theOptions, i, "highlighting/" + i + ".html"); 40} 41 42setCommentBegin("<!--"); 43setCommentEnd("-->"); 44project.clearVariable(); 45translate("../../../Generation/CWcode2Codeworker.cwp", project, "tutorialSite.txt", "tutorial.html"); 46translate("utils/DevCom2CW.cwp", project, "tutorial.html", "tutorial.html"); 47//translate("../../../Generation/CWcode2Freshmeat.cwp", project, "tutorial.txt", "tutorial.html"); 48//translate("utils/jeffcovey.cwp", project, "tutorial.html", "tutorial.html"); 49setCommentBegin("//"); 50setCommentEnd("\n"); 51 52