![]() |
Discovering more with an example |
// file "GettingStarted/SolarSystem0.sml":
1 class Planet {
2 double diameter;
3 double getDistanceToSun(int day, int month, int year);
4 }
5
6 class Earth : Planet {
7 string[] countryNames;
8 }
9
10 class SolarSystem {
11 aggregate Planet[] planets;
12 }
Tracing variable 'project':
a = "little"
b = "big"
End of variable's trace 'project'.
Tracing variable 'project':
a = "little"
b = "big"
classes = ""
classes["Planet", "Earth"]
End of variable's trace 'project'.
handling class 'Planet'...
handling class 'Earth'...
// file "GettingStarted/SimpleML-token-reading.cws":
1 declare function readType();
2
3 while skipEmptyCpp() {
4 if !readIfEqualToIdentifier("class") error("'class' expected");
5 skipEmptyCpp();
6 local sClassName = readIdentifier();
7 if !sClassName error("class name expected");
8 skipEmptyCpp();
9 if readIfEqualTo(":") {
10 skipEmptyCpp();
11 local sParentName = readIdentifier();
12 if !sParentName error("parent name expected for class '" + sClassName + "'");
13 skipEmptyCpp();
14 }
15 if !readIfEqualTo("{") error("'{' expected");
16 skipEmptyCpp();
17 while !readIfEqualTo("}") {
18 skipEmptyCpp();
19 readType();
20 skipEmptyCpp();
21 local sMemberName = readIdentifier();
22 if !sMemberName error("attribute or method name expected");
23 skipEmptyCpp();
24 if readIfEqualTo("(") {
25 skipEmptyCpp();
26 if !readIfEqualTo(")") {
27 do {
28 skipEmptyCpp();
29 local iPosition = getInputLocation();
30 local sMode = readIdentifier();
31 if !sMode error("parameter type or mode expected");
32 if (sMode != "in") && (sMode != "out") && (sMode != "inout") {
33 setInputLocation(iPosition);
34 set sMode = "";
35 }
36 skipEmptyCpp();
37 readType();
38 skipEmptyCpp();
39 local sParameterName = readIdentifier();
40 if !sParameterName error("parameter name expected");
41 skipEmptyCpp();
42 } while readIfEqualTo(",");
43 if !readIfEqualTo(")") error("')' expected");
44 }
45 skipEmptyCpp();
46 }
47 if !readIfEqualTo(";") {
48 error("';' expected to close an attribute, instead of '" + readChar() + "'");
49 }
50 skipEmptyCpp();
51 }
52 }
53 traceLine("the file has been read successfully");
54
55 function readType() {
56 local sType = readIdentifier();
57 if !sType error("type modifier or name expected, instead of '" + readChar() + "'");
58 if sType == "aggregate" {
59 skipEmptyCpp();
60 sType = readIdentifier();
61 if !sType error("aggregated class name expected");
62 }
63 skipEmptyCpp();
64 if readIfEqualTo("[") {
65 skipEmptyCpp();
66 if !readIfEqualTo("]") error("']' expected to close an array declaration");
67 }
68 }
parseFree("GettingStarted/SimpleML-token-reading.cws",
project, "GettingStarted/SolarSystem0.sml");
the file has been read successfully
// file "GettingStarted/SimpleML-token-parsing.cws":
1 declare function readType(myType : node);
2
3 while skipEmptyCpp() {
4 if !readIfEqualToIdentifier("class") error("'class' expected");
5 skipEmptyCpp();
6 local sClassName = readIdentifier();
7 if !sClassName error("class name expected");
8 insert project.listOfClasses[sClassName].name = sClassName;
9 skipEmptyCpp();
10 if readIfEqualTo(":") {
11 skipEmptyCpp();
12 local sParentName = readIdentifier();
13 if !sParentName error("parent name expected for class '" + sClassName + "'");
14 insert project.listOfClasses[sClassName].parent = sParentName;
15 skipEmptyCpp();
16 }
17 if !readIfEqualTo("{") error("'{' expected");
18 skipEmptyCpp();
19 local myClass;
20 ref myClass = project.listOfClasses[sClassName];
21 while !readIfEqualTo("}") {
22 skipEmptyCpp();
23 local myType;
24 readType(myType);
25 skipEmptyCpp();
26 local sMemberName = readIdentifier();
27 if !sMemberName error("attribute or method name expected");
28 skipEmptyCpp();
29 if readIfEqualTo("(") {
30 insert myClass.listOfMethods[sMemberName].name = sMemberName;
31 if myType.name != "void" {
32 setall myClass.listOfMethods[sMemberName].type = myType;
33 }
34 skipEmptyCpp();
35 if !readIfEqualTo(")") {
36 local myMethod;
37 ref myMethod = myClass.listOfMethods[sMemberName];
38 do {
39 skipEmptyCpp();
40 local iPosition = getInputLocation();
41 local sMode = readIdentifier();
42 if !sMode error("parameter type or mode expected");
43 if (sMode != "in") && (sMode != "out") && (sMode != "inout") {
44 setInputLocation(iPosition);
45 set sMode = "";
46 }
47 skipEmptyCpp();
48 local myParameterType;
49 readType(myParameterType);
50 skipEmptyCpp();
51 local sParameterName = readIdentifier();
52 if !sParameterName error("parameter name expected");
53 insert myMethod.listOfParameters[sParameterName].name = sParameterName;
54 setall myMethod.listOfParameters[sParameterName].type = myParameterType;
55 if sMode {
56 insert myMethod.listOfParameters[sParameterName].name = sMode;
57 }
58 skipEmptyCpp();
59 } while readIfEqualTo(",");
60 if !readIfEqualTo(")") error("')' expected");
61 }
62 skipEmptyCpp();
63 } else {
64 insert myClass.listOfAttributes[sMemberName].name = sMemberName;
65 setall myClass.listOfAttributes[sMemberName].type = myType;
66 }
67 if !readIfEqualTo(";") error("';' expected to close an attribute, instead of '" + readChar() + "'");
68 skipEmptyCpp();
69 }
70 }
71 traceLine("the file has been parsed successfully");
72
73 function readType(myType : node) {
74 local sType = readIdentifier();
75 if !sType error("type modifier or name expected, instead of '" + readChar() + "'");
76 if sType == "aggregate" {
77 insert myType.isAggregation = true;
78 skipEmptyCpp();
79 sType = readIdentifier();
80 if !sType error("aggregated class name expected");
81 }
82 insert myType.name = sType;
83 if (sType != "int") && (sType != "double") && (sType != "boolean") && (sType != "string") {
84 insert myType.isObject = true;
85 }
86 skipEmptyCpp();
87 if readIfEqualTo("[") {
88 skipEmptyCpp();
89 if !readIfEqualTo("]") error("']' expected to close an array declaration");
90 insert myType.isArray = true;
91 }
92 }
parseFree("GettingStarted/SimpleML-token-parsing.cws",
project, "GettingStarted/SolarSystem0.sml");
the file has been parsed successfully
// file "GettingStarted/SimpleML-reading.cwp":
1 // syntactical clauses:
2 world ::= #ignore(C++) [class_declaration]* #empty
3 => { traceLine("file read successfully"); };
4 class_declaration ::= IDENT:"class" IDENT [':' IDENT]? class_body;
5 class_body ::= '{' [attribute_decl | method_decl]* '}';
6 attribute_decl ::= type_specifier IDENT ';';
7 method_decl ::= [IDENT:"void" | type_specifier] IDENT
8 '(' [parameters_decl]? ')' ';';
9 parameters_decl ::= parameter [',' parameters_decl]*;
10 parameter ::= [parameter_mode]? type_specifier IDENT;
11 parameter_mode ::= IDENT:{"in", "inout", "out"};
12 type_specifier ::= basic_type ['[' ']']?;
13 basic_type ::= "int" | "boolean" | "double" | "string" | class_specifier;
14 class_specifier ::= ["aggregate"]? IDENT;
15
16 // lexical clauses:
17 IDENT ::= #!ignore ['a'..'z'|'A'..'Z'|'_']
18 ['a'..'z'|'A'..'Z'|'_'|'0'..'9']*;
parseAsBNF("GettingStarted/SimpleML-reading.cwp",
project, "GettingStarted/SolarSystem0.sml");
file read successfully
// file "GettingStarted/SimpleML-parsing.cwp":
1 // syntactical clauses:
2 world ::= #ignore(C++) [class_declaration]* #empty
3 => {
4 traceLine("file parsed successfully");
5 saveProject("Scripts/Tutorial/SolarSystem0.xml");
6 };
7 class_declaration ::= IDENT:"class" #continue
8 IDENT:sClassName
9 => insert project.listOfClasses[sClassName].name = sClassName;
10 [':' #continue IDENT:sParentName
11 => insert project.listOfClasses[sClassName].parent = sParentName;
12 ]?
13 class_body(project.listOfClasses[sClassName]);
14 class_body(myClass : node) ::= '{'
15 [attribute_decl(myClass) | method_decl(myClass)]* '}';
16 attribute_decl(myClass : node) ::=
17 => local myType;
18 type_specifier(myType) IDENT:sAttributeName ';'
19 => {
20 insert myClass.listOfAttributes[sAttributeName].name = sAttributeName;
21 setall myClass.listOfAttributes[sAttributeName].type = myType;
22 };
23 method_decl(myClass : node) ::=
24 => local myType;
25 [IDENT:"void" | type_specifier(myType)]
26 IDENT:sMethodName '('
27 #continue
28 => {
29 insert myClass.listOfMethods[sMethodName].name = sMethodName;
30 if myType.name
31 setall myClass.listOfMethods[sMethodName].type = myType;
32 }
33 [parameters_decl(myClass.listOfMethods[sMethodName])]? ')' ';';
34 parameters_decl(myMethod : node) ::=
35 parameter(myMethod)
36 [',' #continue parameters_decl(myMethod)]*;
37 parameter(myMethod : node) ::=
38 [parameter_mode]?:sMode
39 => local myType;
40 type_specifier(myType)
41 IDENT:sParameterName
42 => {
43 insert myMethod.listOfParameters[sParameterName].name = sParameterName;
44 setall myMethod.listOfParameters[sParameterName].type = myType;
45 if sMode {
46 insert myMethod.listOfParameters[sParameterName].name = sMode;
47 }
48 };
49 parameter_mode ::= IDENT:{"in", "inout", "out"};
50 type_specifier(myType : node) ::=
51 basic_type(myType)
52 ['[' #continue ']' => insert myType.isArray = true; ]?;
53 basic_type(myType : node) ::=
54 ["int" | "boolean" | "double" | "string"]:myType.name
55 |
56 class_specifier(myType);
57 class_specifier(myType : node) ::=
58 ["aggregate" => insert myType.isAggregation = true; ]?
59 IDENT:myType.name => {insert myType.isObject = true; };
60
61 IDENT ::= #!ignore ['a'..'z'|'A'..'Z'|'_']
62 ['a'..'z'|'A'..'Z'|'_'|'0'..'9']*;
parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
project, "GettingStarted/SolarSystem0.sml");
file parsed successfully
// file "GettingStarted/TreeDecoration.cws":
1 foreach myClass in project.listOfClasses {
2 if myClass.parent {
3 if !findElement(myClass.parent, project.listOfClasses)
4 error("class '" + myClass.parent + "' doesn't exist while class '"
5 + myClass.name + "intends to inherit from it");
6 ref myClass.parent = project.listOfClasses[myClass.parent];
7 }
8 foreach myAttribute in myClass.listOfAttributes {
9 local myType;
10 ref myType = myAttribute.type;
11 if myType.isObject {
12 if !findElement(myType.name, project.listOfClasses)
13 error("class '" + myType.name + "' doesn't exist while attribute '"
14 + myClass.name + "::" + myAttribute.name + "' refers to it");
15 ref myType.class = project.listOfClasses[myType.name];
16 }
17 }
18 foreach myMethod in myClass.listOfMethods {
19 if existVariable(myMethod.type) && myMethod.type.isObject {
20 localref myType = myMethod.type;
21 if !findElement(myType.name, project.listOfClasses)
22 error("class '" + myType.name + "' doesn't exist while method '"
23 + myClass.name + "::" + myMethod.name + "' refers to it");
24 ref myType.class = project.listOfClasses[myType.name];
25 }
26 foreach myParameter in myMethod.listOfParameters {
27 localref myType = myParameter.type;
28 if myType.isObject {
29 if !findElement(myType.name, project.listOfClasses)
30 error("class '" + myType.name
31 + "' doesn't exist while method '"
32 + myClass.name + "::" + myMethod.name
33 + "' refers to it");
34 ref myType.class = project.listOfClasses[myType.name];
35 }
36 }
37 }
38 }
// file "GettingStarted/LeaderScript0.cws":
1 if !getProperty("DESIGN_FILE")
2 error("'-define DESIGN_FILE=file' expected on the command line");
3 traceLine("'Simple Modeling' design file to parse = \""
4 + getProperty("DESIGN_FILE") + "\"");
5 parseAsBNF("SimpleML-parsing.cwp",
6 project, getProperty("DESIGN_FILE"));
7 #include "TreeDecoration.cws"
if doc_language == "C++" {
sType = getCppType(myParameterType);
} else if doc_language == "JAVA" {
sType = getJAVAType(myParameterType);
} else {
error("unrecognized language '" + doc_language + "'");
}
sType = getType<doc_language>(myParameterType);
...
function getType<"JAVA">(myType : node) {
... // implementation for returning a Java type
}
function getType<"C++">(myType : node) {
... // implementation for returning a C++ type
}
function getType<T>(myType : node) {
... // implementation for any unrecognized language
}
function f<1>() { return 1; }
function f<N>() { return $N*f<$N - 1$>()$; }
local f10 = f<10>();
if $f10 != 3628800$ error("10! should be worth 3628800");
traceLine("10! = " + f10);
10! = 3628800
// file "GettingStarted/SharedFunctions.cws":
1 function normalizeIdentifier(sName) {
2 if sName {
3 if startString(sName, "_")
4 return "_" + normalizeIdentifier(subString(sName, 1));
5 set sName = toUpperString(charAt(sName, 0))
6 + subString(sName, 1);
7 local iIndex = findFirstChar(sName, "_.");
8 if !isNegative(iIndex) {
9 local sNext = subString(sName, add(iIndex, 1));
10 return leftString(sName, iIndex)
11 + normalizeIdentifier(sNext);
12 }
13 }
14 return sName;
15 }
16
17 function getType<"C++">(myType : node) {
18 local sType;
19 if myType.isObject set sType = myType.name + "*";
20 else if myType.name == "boolean" set sType = "bool";
21 else if myType.name == "string" set sType = "std::string";
22 else set sType = myType.name;
23 if myType.isArray set sType = "std::vector<" + sType + ">";
24 return sType;
25 }
26
27 function getParameterType<"C++">(myType : node, sMode) {
28 local sType = getType<"C++">(myType);
29 if endString(sMode, "out") set sType += "&";
30 else if (sMode == "in") set sType = "const " + sType + "&";
31 return sType;
32 }
33
34 function getType<"JAVA">(myType : node) {
35 local sType;
36 if myType.name == "string" set sType = "String";
37 else set sType = myType.name;
38 if myType.isArray set sType = "java.util.ArrayList/*<" + sType + ">*/";
39 return sType;
40 }
41
42 function getParameterType<"JAVA">(myType : node, sMode) {
43 return getType<"JAVA">(myType);
44 }
45
46 function getVariableName(sName, myType : node) {
47 local sPrefix;
48 if myType.isArray set sPrefix = "t";
49 if myType.isObject set sPrefix += "p";
50 else {
51 switch(myType.name) {
52 case "int": set sPrefix += "i";break;
53 case "double": set sPrefix += "d";break;
54 case "boolean": set sPrefix += "b";break;
55 case "string": set sPrefix += "s";break;
56 }
57 }
58 return sPrefix + normalizeIdentifier(sName);
59 }
60
61 function getMethodID(myMethod : node) {
62 local sMethodID = myMethod.name;
63 foreach i in myMethod.listOfParameters {
64 set sMethodID += "." + i.type.name;
65 if i.type.isArray set sMethodID += "[]";
66 }
67 return sMethodID;
68 }
// file "GettingStarted/CppObjectHeader.cwt":
1 #ifndef _@this.name@_h_
2 #define _@this.name@_h_
3
4 @
5 newFloatingLocation("include files");
6 @
7 // this line separates the two insertion points, so as to distinguish them!
8 @
9 newFloatingLocation("class declarations");
10
11 function populateHeaderDeclarations(myType : node) {
12 if myType.isObject insertTextOnce(getFloatingLocation("class declarations"), "class " + myType.name + ";" + endl());
13 if myType.isArray insertTextOnce(getFloatingLocation("include files"), "#include <vector>" + endl());
14 if myType.name insertTextOnce(getFloatingLocation("include files"), "#include <string>" + endl());
15 }
16
17 @
18 class @this.name@ @
19 if existVariable(this.parent) {
20 insertTextOnce(getFloatingLocation("include files"), "#include \"" + this.parent.name +".h\"" + endl());
21 @: public @this.parent.name@ @
22 }
23 @{
24 private:
25 @
26 foreach i in this.listOfAttributes {
27 populateHeaderDeclarations(i.type);
28 @ @getType<"C++">(i.type)@ _@getVariableName(i.name, i.type)@;
29 @
30 }
31 @
32 public:
33 @this.name@();
34 ~@this.name@();
35
36 // accessors:
37 @
38 foreach i in this.listOfAttributes {
39 local sVariableName = getVariableName(i.name, i.type);
40 %> inline <%getType<"C++">(i.type)%> get<%normalizeIdentifier (i.name)%>() const { return _<%sVariableName%>; }
41 inline void set<%normalizeIdentifier(i.name)@(<%getType <"C++">(i.type)%> <%sVariableName@) { _<%sVariableName%> = <%sVariableName%>; }
42 @
43 }
44 @
45 // methods:
46 @
47 foreach i in this.listOfMethods {
48 @ virtual @
49 if existVariable(i.type) {
50 populateHeaderDeclarations(i.type);
51 @@getType<"C++">(i.type)@@
52 } else {
53 @void@
54 }
55 @ @i.name@(@
56 foreach j in i.listOfParameters {
57 if !first(j) {
58 @, @
59 }
60 populateHeaderDeclarations(j.type);
61 @@getParameterType<"C++">(j.type, j.mode)@ @getVariableName(j.name, j.type)@@
62 }
63 @);
64 @
65 }
66 @
67 private:
68 @this.name@(const @this.name@&);
69 @this.name@& operator =(const @this.name@&);
70 };
71
72 #endif
// file "GettingStarted/CppObjectBody.cwt":
1 #ifdef WIN32
2 #pragma warning(disable : 4786)
3 #endif
4
5 @
6 setProtectedArea("include files");
7 @
8 #include "@this.name@.h"
9
10 @this.name@::@this.name@()@
11 local bAtLeastOne = false;
12 foreach i in this.listOfAttributes {
13 if !i.type.isArray && (i.type.name != "string") {
14 if bAtLeastOne {
15 @, @
16 } else {
17 @ : @
18 set bAtLeastOne = true;
19 }
20 @_@getVariableName(i.name, i.type)@(@
21 if i.type.isObject {
22 @0L@
23 } else {
24 switch(i.type.name) {
25 case "int":
26 @0@
27 break;
28 case "double":
29 @0.0@
30 break;
31 case "boolean":
32 @false@
33 break;
34 }
35 }
36 @)@
37 }
38 }
39 @ {
40 }
41
42 @this.name@::~@this.name@() {
43 @
44 foreach i in this.listOfAttributes {
45 if i.type.isAggregation && i.type.isObject {
46 local sAttributeName = "_" + getVariableName(i.name, i.type);
47 local sIndex = "iterate" + normalizeIdentifier(i.name);
48 if i.type.isArray {
49 @ for (std::vector<@i.name@*>::const_iterator @sIndex@ = @sAttributeName@.begin(); @sIndex@ != @sAttributeName@.end(); ++@sIndex@) {
50 delete *@sIndex@;
51 }
52 @
53 } else {
54 @ delete @sAttributeName@;
55 @
56 }
57 }
58 }
59 @}
60
61 @
62 foreach i in this.listOfMethods {
63 if existVariable(i.type) {
64 @@getType<"C++">(i.type)@@
65 } else {
66 @void@
67 }
68 @ @this.name@::@i.name@(@
69 foreach j in i.listOfParameters {
70 if !first(j) {
71 @, @
72 }
73 @@getParameterType<"C++">(j.type, j.mode)@ @getVariableName(j.name, j.type)@@
74 }
75 @) {
76 @
77 setProtectedArea(getMethodID(i));
78 @}
79 @
80 }
// file "GettingStarted/LeaderScript1.cws":
1 if !getProperty("DESIGN_FILE")
2 error("'-define DESIGN_FILE=file' expected on the command line");
3 traceLine("'Simple Modeling' design file to parse = \""
4 + getProperty("DESIGN_FILE") + "\"");
5 parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
6 project, getProperty("DESIGN_FILE"));
7 #include "TreeDecoration.cws"
8
9 #include "SharedFunctions.cws"
10 foreach myClass in project.listOfClasses {
11 traceLine("generating class '" + myClass.name + "' ...");
12 generate("GettingStarted/CppObjectHeader.cwt", myClass,
13 getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/"
14 + myClass.name + ".h");
15 generate("GettingStarted/CppObjectBody.cwt", myClass,
16 getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/"
17 + myClass.name + ".cpp");
18 }
'Simple Modeling' design file to parse = "GettingStarted/SolarSystem0.sml"
file parsed successfully
generating class 'Planet' ...
generating class 'Earth' ...
generating class 'SolarSystem' ...
// file "GettingStarted/Cpp/SolarSystem.h":
#ifndef _SolarSystem_h_
#define _SolarSystem_h_
#include <vector>
#include <string>
// this line separates the two insertion points, so as to distinguish them!
class Planet;
class SolarSystem {
private:
std::vector<Planet*> _tpPlanets;
public:
SolarSystem();
~SolarSystem();
// accessors:
inline std::vector<Planet*> getPlanets() const { return _tpPlanets; }
inline void setPlanets(std::vector<Planet*> tpPlanets) { _tpPlanets = tpPlanets; }
// methods:
private:
SolarSystem(const SolarSystem&);
SolarSystem& operator =(const SolarSystem&);
};
#endif
// file "GettingStarted/Cpp/Planet.cpp":
1 #ifdef WIN32
2 #pragma warning(disable : 4786)
3 #endif
4
5 //##protect##"include files"
6 //##protect##"include files"
7
8 #include "Planet.h"
9
10 Planet::Planet() : _dDiameter(0.0) {
11 }
12
13 Planet::~Planet() {
14 }
15
16 double Planet::getDistanceToSun(int iDay, int iMonth, int iYear) {
17 //##protect##"getDistanceToSun.int.int.int"
18 //##protect##"getDistanceToSun.int.int.int"
19 }
// file "GettingStarted/JAVAObject.cwt":
1 package solarsystem;
2
3 public class @this.name@ @
4 if existVariable(this.parent) {
5 @extends @this.parent.name@ @
6 }
7 @{
8 @
9 foreach i in this.listOfAttributes {
10 @ private @getType<"JAVA">(i.type)@ _@getVariableName(i.name, i.type)@;
11 @
12 }
13 @
14 public @this.name@() {}
15
16 // accessors:
17 @
18 foreach i in this.listOfAttributes {
19 local sVariableName = getVariableName(i.name, i.type);
20 @ public @getType<"JAVA">(i.type)@ get@normalizeIdentifier(i.name)@() { return _@sVariableName@; }
21 public void set@normalizeIdentifier(i.name)@(@getType<"JAVA">(i.type)@ @sVariableName@) { _@sVariableName@ = @sVariableName@; }
22 @
23 }
24 @
25 // methods:
26 @
27 foreach i in this.listOfMethods {
28 @ public @
29 if existVariable(i.type) {
30 @@getType<"JAVA">(i.type)@@
31 } else {
32 @void@
33 }
34 @ @i.name@(@
35 foreach j in i.listOfParameters {
36 if !first(j) {
37 @, @
38 }
39 @@getParameterType<"JAVA">(j.type, j.mode)@ @getVariableName(j.name, j.type)@@
40 }
41 @) {
42 @
43 setProtectedArea(getMethodID(i));
44 @ }
45
46 @
47 }
48 @}
// file "GettingStarted/LeaderScript2.cws":
1 if !getProperty("DESIGN_FILE")
2 error("'-define DESIGN_FILE=file' expected on the command line");
3 traceLine("'Simple Modeling' design file to parse = \""
4 + getProperty("DESIGN_FILE") + "\"");
5 parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
6 project, getProperty("DESIGN_FILE"));
7 #include "TreeDecoration.cws"
8
9 #include "SharedFunctions.cws"
10 foreach myClass in project.listOfClasses {
11 traceLine("generating class '" + myClass.name + "' ...");
12 generate("GettingStarted/CppObjectHeader.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".h");
13 generate("GettingStarted/CppObjectBody.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".cpp");
14 generate("GettingStarted/JAVAObject.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/JAVA/solarsystem/" + myClass.name + ".java");
15 }
'Simple Modeling' design file to parse = "GettingStarted/SolarSystem0.sml"
file parsed successfully
generating class 'Planet' ...
generating class 'Earth' ...
generating class 'SolarSystem' ...
// file "GettingStarted/JAVA/solarsystem/SolarSystem.java":
package solarsystem;
public class SolarSystem {
private java.util.ArrayList/*<Planet>*/ _tpPlanets;
public SolarSystem() {}
// accessors:
public java.util.ArrayList/*<Planet>*/ getPlanets() { return _tpPlanets; }
public void setPlanets(java.util.ArrayList/*<Planet>*/ tpPlanets) { _tpPlanets = tpPlanets; }
// methods:
}
// file "GettingStarted/JAVA/solarsystem/Planet.java":
package solarsystem;
public class Planet {
private double _dDiameter;
public Planet() {}
// accessors:
public double getDiameter() { return _dDiameter; }
public void setDiameter(double dDiameter) { _dDiameter = dDiameter; }
// methods:
public double getDistanceToSun(int iDay, int iMonth, int iYear) {
//##protect##"getDistanceToSun.int.int.int"
//##protect##"getDistanceToSun.int.int.int"
}
}
// file "GettingStarted/defaultDocumentation.html":
<HTML>
<HEAD>
<TITLE>some title...</TITLE>
</HEAD>
<BODY>
<H1>some title...</H1>
some global documentation...
<!--##markup##"classes presentation"-->
</BODY>
</HTML>
// file "GettingStarted/HTMLDocumentation.cwt":
1 @
2 if getMarkupKey() == "classes presentation" {
3 foreach i in project.listOfClasses {
4 @
5 <H2><A href="#@i.name@">@i.name@</A></H2>
6 @
7 setProtectedArea(i.name + ":presentation");
8 if !isEmpty(i.listOfAttributes) {
9 @
10 <TABLE border="1" cellpadding="3" cellspacing="0" width="100%">
11 <TR BGCOLOR="#CCCCFF">
12 <TD><B>Type</B></TD>
13 <TD><B>Attribute name</B></TD>
14 <TD><B>Description</B></TD>
15 </TR>
16 @
17 foreach j in i.listOfAttributes {
18 @ <TR>
19 <TD>@composeHTMLLikeString(getType<this.language> (j.type))@</TD>
20 <TD>@j.name@</TD>
21 <TD>
22 @
23 setProtectedArea(i.name + "::" + j.name + ":description");
24 @
25 </TD>
26 </TR>
27 @
28 }
29 @ </TABLE>
30 @
31 }
32 if !isEmpty(i.listOfMethods) {
33 @
34 <UL>
35 @
36 foreach j in i.listOfMethods {
37 @ <LI>@
38 if existVariable(j.type) {
39 @function @composeHTMLLikeString(getType <this.language>(j.type))@ @
40 } else {
41 @procedure@
42 }
43 @<B>@j.name@</B>(@
44 foreach k in j.listOfParameters {
45 if !first(k) {
46 @, @
47 }
48 @@composeHTMLLikeString(getParameterType <this.language>(k.type, k.mode))@ <I>@getVariableName(k.name, k.type)@</I>@
49 }
50 @)
51 <BR>
52 @
53 setProtectedArea(i.name + "::" + getMethodID(j) + ":description");
54 @
55 </LI>
56 @
57 }
58 @ </UL>
59 @
60 }
61 }
62 }
// file "GettingStarted/LeaderScript3.cws":
1 if !getProperty("DESIGN_FILE")
2 error("'-define DESIGN_FILE=file' expected on the command line");
3 traceLine("'Simple Modeling' design file to parse = \""
4 + getProperty("DESIGN_FILE") + "\"");
5 parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
6 project, getProperty("DESIGN_FILE"));
7 #include "TreeDecoration.cws"
8
9 #include "SharedFunctions.cws"
10 foreach myClass in project.listOfClasses {
11 traceLine("generating class '" + myClass.name + "' ...");
12 generate("GettingStarted/CppObjectHeader.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".h");
13 generate("GettingStarted/CppObjectBody.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".cpp");
14 generate("GettingStarted/JAVAObject.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/JAVA/solarsystem/" + myClass.name + ".java");
15 }
16 if !existFile("Scripts/Tutorial/GettingStarted/SolarSystem0.html") {
17 copyFile("Scripts/Tutorial/GettingStarted/defaultDocumentation.html", "Scripts/Tutorial/GettingStarted/SolarSystem0.html");
18 }
19
20 local myDocumentationContext;
21 insert myDocumentationContext.language = "C++";
22 traceLine("generating the HTML documentation...");
23 setCommentBegin("<!--");
24 setCommentEnd("-->");
25 expand("GettingStarted/HTMLDocumentation.cwt",
26 myDocumentationContext, getWorkingPath()
27 + "Scripts/Tutorial/GettingStarted/SolarSystem0.html");
'Simple Modeling' design file to parse = "GettingStarted/SolarSystem0.sml"
file parsed successfully
generating class 'Planet' ...
generating class 'Earth' ...
generating class 'SolarSystem' ...
generating the HTML documentation...
// file "GettingStarted/SolarSystem0.html":
<HTML>
<HEAD>
<TITLE>some title...</TITLE>
</HEAD>
<BODY>
<H1>some title...</H1>
some global documentation...
<!--##markup##"classes presentation"--><!--##begin##"classes presentation"-->
<H2><A href="#Planet">Planet</A></H2>
<!--##protect##"Planet:presentation"--><!--##protect##"Planet:presentation"-->
<TABLE border="1" cellpadding="3" cellspacing="0" width="100%">
<TR BGCOLOR="#CCCCFF">
<TD><B>Type</B></TD>
<TD><B>Attribute name</B></TD>
<TD><B>Description</B></TD>
</TR>
<TR>
<TD>double</TD>
<TD>diameter</TD>
<TD>
<!--##protect##"Planet::diameter:description"--><!--##protect##"Planet::diameter:description"-->
</TD>
</TR>
</TABLE>
<UL>
<LI>function double <B>getDistanceToSun</B>(int <I>iDay</I>, int <I>iMonth</I>, int <I>iYear</I>)
<BR>
<!--##protect##"Planet::getDistanceToSun.int.int.int:description"--><!--##protect##"Planet::getDistanceToSun.int.int.int:description"-->
</LI>
</UL>
<H2><A href="#Earth">Earth</A></H2>
<!--##protect##"Earth:presentation"--><!--##protect##"Earth:presentation"-->
<TABLE border="1" cellpadding="3" cellspacing="0" width="100%">
<TR BGCOLOR="#CCCCFF">
<TD><B>Type</B></TD>
<TD><B>Attribute name</B></TD>
<TD><B>Description</B></TD>
</TR>
<TR>
<TD>std::vector<std::string></TD>
<TD>countryNames</TD>
<TD>
<!--##protect##"Earth::countryNames:description"--><!--##protect##"Earth::countryNames:description"-->
</TD>
</TR>
</TABLE>
<H2><A href="#SolarSystem">SolarSystem</A></H2>
<!--##protect##"SolarSystem:presentation"--><!--##protect##"SolarSystem:presentation"-->
<TABLE border="1" cellpadding="3" cellspacing="0" width="100%">
<TR BGCOLOR="#CCCCFF">
<TD><B>Type</B></TD>
<TD><B>Attribute name</B></TD>
<TD><B>Description</B></TD>
</TR>
<TR>
<TD>std::vector<Planet*></TD>
<TD>planets</TD>
<TD>
<!--##protect##"SolarSystem::planets:description"--><!--##protect##"SolarSystem::planets:description"-->
</TD>
</TR>
</TABLE>
<!--##end##"classes presentation"-->
</BODY>
</HTML>
// file "GettingStarted/HTML-parsing.cwp":
1 #noCase
2
3 HTML ::= #ignore(HTML) #continue '<' "HTML" '>' HTMLHeader HTMLBody '<' '/' "HTML" '>' #empty;
4 HTMLHeader ::= '<' #continue "HEAD" '>' [~['<' '/' "HEAD" '>']]* '<' '/' "HEAD" '>';
5 HTMLBody ::= '<' #continue "BODY" '>' HTMLText '<' '/' "BODY" '>';
6 HTMLText ::=
7 [
8 ~'<'
9 |
10 !['<' '/'] #continue '<'
11 #readIdentifier:sTag HTMLNextOfTag<sTag>
12 ]*;
13 HTMLNextOfTag<"H1"> ::= #continue '>' HTMLText '<' '/' "H1" '>';
14 HTMLNextOfTag<"H2"> ::= #continue '>' HTMLText '<' '/' "H2" '>';
15 HTMLNextOfTag<"A"> ::= [HTMLAttribute]* #continue '>' HTMLText '<' '/' 'A' '>';
16 HTMLNextOfTag<"TABLE"> ::= [HTMLAttribute]* #continue '>' [HTMLTag("TR")]* '<' '/' "TABLE" '>';
17 HTMLTag(sTag : value) ::= '<' #readText(sTag) #continue HTMLNextOfTag<sTag>;
18 HTMLNextOfTag<"TR"> ::= [HTMLAttribute]* #continue '>' [HTMLTag("TD")]* '<' '/' "TR" '>';
19 HTMLNextOfTag<"TD"> ::= [HTMLAttribute]* #continue '>' HTMLText '<' '/' "TD" '>';
20 HTMLNextOfTag<"UL"> ::= [HTMLAttribute]* #continue '>' [HTMLTag("LI")]* '<' '/' "UL" '>';
21 HTMLNextOfTag<"LI"> ::= [HTMLAttribute]* #continue '>' HTMLText '<' '/' "LI" '>';
22 HTMLNextOfTag<"B"> ::= #continue '>' HTMLText '<' '/' "B" '>';
23 HTMLNextOfTag<"I"> ::= #continue '>' HTMLText '<' '/' "I" '>';
24 HTMLNextOfTag<"FONT"> ::= [HTMLAttribute]* #continue '>' HTMLText '<' '/' "FONT" '>';
25 HTMLNextOfTag<"BR"> ::= ['/']? #continue '>';
26 HTMLAttribute ::= #readIdentifier ['=' #continue [STRING_LITERAL | WORD_LITERAL]]?;
27
28
29 STRING_LITERAL ::= #!ignore '\"' [~'\"']* '\"';
30 WORD_LITERAL ::= #!ignore [~['>' | '/' | ' ' | '\t']]+;
// file "GettingStarted/HTML2LaTeX.cwp":
1 #noCase
2
3 HTML2LaTeX ::= #ignore(HTML) #continue '<' "HTML" '>' HTMLHeader HTMLBody '<' '/' "HTML" '>' #empty;
4 HTMLHeader ::= '<' #continue "HEAD" '>' [~['<' '/' "HEAD" '>']]* '<' '/' "HEAD" '>';
5 HTMLBody ::= '<' #continue "BODY" '>' HTMLText '<' '/' "BODY" '>';
6 HTMLText ::= #!ignore
7 [
8 '&' #continue #readIdentifier:sEscape HTMLEscape<sEscape> ';'
9 |
10 ~'<':cChar => writeText(cChar);
11 |
12 !['<' blanks '/']
13 [
14 "<!--" #continue [~"-->"]* "-->"
15 |
16 '<' #continue #ignore(HTML) #readIdentifier:sTag HTMLNextOfTag<sTag>
17 ]
18 ]*;
19 HTMLEscape<"lt"> ::= => {@<@};
20 HTMLEscape<"gt"> ::= => {@>@};
21 HTMLTag(sTag : value) ::= '<' #readText(sTag) #continue HTMLNextOfTag<sTag>;
22 HTMLNextOfTag<"H1"> ::=
23 #continue '>' => {@\subsection{@}
24 HTMLText
25 '<' '/' "H1" '>' => {@}@};
26 HTMLNextOfTag<"H2"> ::=
27 #continue '>' => {@\subsubsection{@}
28 HTMLText
29 '<' '/' "H2" '>' => {@}@};
30 HTMLNextOfTag<"A"> ::= [HTMLAttribute]* #continue '>' HTMLText '<' '/' 'A' '>';
31 HTMLNextOfTag<"TABLE"> ::=
32 [HTMLAttribute]* #continue '>' => {
33 @\begin{table@
34 newFloatingLocation("table PDF suffix");
35 @}{@
36 newFloatingLocation("table columns");
37 @}{.5}@
38 }
39 => local sPDFTableSuffix;
40 HTMLTableTitle(sPDFTableSuffix)
41 [HTMLTableLine(sPDFTableSuffix)]*
42 '<' '/' "TABLE" '>' => {@\end{table@sPDFTableSuffix@}
43 @};
44 HTMLTableTitle(sPDFTableSuffix : node) ::=
45 '<' "TR" [HTMLAttribute]*
46 #continue '>'
47 [HTMLTableCol(sPDFTableSuffix)]*
48 '<' '/' "TR" '>' => {
49 insertText(getFloatingLocation("table PDF suffix"), sPDFTableSuffix);
50 writeText(endl());
51 };
52 HTMLTableCol(sPDFTableSuffix : node) ::=
53 '<' "TD" [HTMLAttribute]* #continue '>' => {
54 @{@
55 if !sPDFTableSuffix insertText(getFloatingLocation("table columns"), "l");
56 else insertText(getFloatingLocation("table columns"), "|l");
57 set sPDFTableSuffix += "i";
58 }
59 '<' 'B' '>' [#!ignore [~'<':cChar => writeText(cChar);]*] '<' '/' 'B' '>'
60 '<' '/' "TD" '>' => {@}@};
61 HTMLTableLine(sPDFTableSuffix : value) ::=
62 '<' "TR" [HTMLAttribute]* #continue '>' => {@\line@sPDFTableSuffix@@}
63 [HTMLTag("TD")]* '<' '/' "TR" '>' => {writeText(endl());};
64 HTMLNextOfTag<"TD"> ::=
65 [HTMLAttribute]* #continue '>' => {@{@}
66 HTMLCellText '<' '/' "TD" '>' => {@}@};
67 HTMLCellText ::= #!ignore
68 [
69 '&' #continue #readIdentifier:sEscape HTMLEscape<sEscape> ';'
70 |
71 ['\r']? ['\n'] => {@ @}
72 |
73 ~'<':cChar => writeText(cChar);
74 |
75 !['<' blanks '/']
76 [
77 "<!--" #continue [~"-->"]* "-->"
78 |
79 '<' #continue #ignore(HTML) #readIdentifier:sTag HTMLNextOfTag<sTag>
80 ]
81 ]*;
82 HTMLNextOfTag<"UL"> ::=
83 [HTMLAttribute]* #continue '>' => {@\begin{itemize}
84 @}
85 [HTMLTag("LI")]*
86 '<' '/' "UL" '>' => {@\end{itemize}
87 @};
88 HTMLNextOfTag<"LI"> ::=
89 [HTMLAttribute]* #continue '>' => {@\item @}
90 HTMLText
91 '<' '/' "LI" '>' => {writeText(endl());};
92 HTMLNextOfTag<"B"> ::=
93 #continue '>' => {@\textbf{@}
94 HTMLText
95 '<' '/' "B" '>' => {@}@};
96 HTMLNextOfTag<"I"> ::=
97 #continue '>' => {@\textbf{@}
98 HTMLText
99 '<' '/' "I" '>' => {@}@};
100 HTMLNextOfTag<"FONT"> ::= [HTMLAttribute]* #continue '>' HTMLText '<' '/' "FONT" '>';
101 HTMLNextOfTag<"BR"> ::= ['/']? #continue '>' => { writeText(endl());};
102 HTMLAttribute ::= #readIdentifier ['=' #continue [STRING_LITERAL | WORD_LITERAL]]?;
103
104
105 blanks ::= [' '| '\t' | '\r' | '\n']*;
106 STRING_LITERAL ::= #!ignore '\"' [~'\"']* '\"';
107 WORD_LITERAL ::= #!ignore [~['>' | '/' | ' ' | '\t']]+;
// file "GettingStarted/LeaderScript4.cws":
1 if !getProperty("DESIGN_FILE")
2 error("'-define DESIGN_FILE=file' expected on the command line");
3 traceLine("'Simple Modeling' design file to parse = \""
4 + getProperty("DESIGN_FILE") + "\"");
5 parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
6 project, getProperty("DESIGN_FILE"));
7 #include "TreeDecoration.cws"
8
9 #include "SharedFunctions.cws"
10 foreach myClass in project.listOfClasses {
11 traceLine("generating class '" + myClass.name + "' ...");
12 generate("GettingStarted/CppObjectHeader.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".h");
13 generate("GettingStarted/CppObjectBody.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".cpp");
14 generate("GettingStarted/JAVAObject.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/JAVA/solarsystem/" + myClass.name + ".java");
15 }
16
17 local myDocumentationContext;
18 insert myDocumentationContext.language = "C++";
19 traceLine("generating the HTML documentation...");
20 setCommentBegin("<!--");
21 setCommentEnd("-->");
22 expand("GettingStarted/HTMLDocumentation.cwt",
23 myDocumentationContext, getWorkingPath()
24 + "Scripts/Tutorial/GettingStarted/SolarSystem1.html");
25 translate("GettingStarted/HTML2LaTeX.cwp", project, "GettingStarted/SolarSystem1.html", getWorkingPath() + "Scripts/Tutorial/GettingStarted/SolarSystem.tex");
'Simple Modeling' design file to parse = "GettingStarted/SolarSystem0.sml"
file parsed successfully
generating class 'Planet' ...
generating class 'Earth' ...
generating class 'SolarSystem' ...
generating the HTML documentation...
| Type | Attribute name | Description |
| double | diameter | the average diameter of the planet |
| Type | Attribute name | Description |
| std::vector<std::string> | countryNames | the name of all countries are put into |
| Type | Attribute name | Description |
| std::vector<Planet*> | planets | the planets that compose the solar system. |
// file "GettingStarted/LeaderScript5.cws":
if !getProperty("DESIGN_FILE")
error("'-define DESIGN_FILE=file' expected on the command line");
traceLine("'Simple Modeling' design file to parse = \""
+ getProperty("DESIGN_FILE") + "\"");
parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
project, getProperty("DESIGN_FILE"));
#include "TreeDecoration.cws"
#include "SharedFunctions.cws"
foreach myClass in project.listOfClasses {
traceLine("generating class '" + myClass.name + "' ...");
generate("GettingStarted/CppObjectHeader.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".h");
generate("GettingStarted/CppObjectBody.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".cpp");
generate("GettingStarted/JAVAObject.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/JAVA/solarsystem/" + myClass.name + ".java");
}
local myDocumentationContext;
insert myDocumentationContext.language = "C++";
traceLine("generating the HTML documentation...");
setCommentBegin("<!--");
setCommentEnd("-->");
expand("GettingStarted/HTMLDocumentation.cwt",
myDocumentationContext, getWorkingPath()
+ "Scripts/Tutorial/GettingStarted/SolarSystem1.html");
translate("GettingStarted/HTML2LaTeX.cwp", project, "GettingStarted/SolarSystem1.html", getWorkingPath() + "Scripts/Tutorial/GettingStarted/SolarSystem.tex");
"LeaderScript5.cws" at 5: if !getProperty("DESIGN_FILE")
// The controlling sequence stops on the first statement of the leader script.
// We go the next instruction:
n
"LeaderScript5.cws" at 7: traceLine("'Simple Modeling' design file to parse = \""
// twice more:
n2
'Simple Modeling' design file to parse = "GettingStarted/SolarSystem0.sml"
"LeaderScript5.cws" at 11: parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
//let plunge into the BNF-driven script:
s
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":1,1
"SimpleML-parsing.cwp" at 6: world ::= #ignore(C++) [class_declaration]* #empty
//We are pointing to the beginning of the rule. Let execute '#ignore(C++)':
s
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":1,1
"SimpleML-parsing.cwp" at 6: world ::= #ignore(C++) [class_declaration]* #empty
//Let go to the unbounded expression '[class_declaration]*':
s
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":1,1
"SimpleML-parsing.cwp" at 6: world ::= #ignore(C++) [class_declaration]* #empty
//Now, we have a look to 'class_declaration':
s
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,1
"SimpleML-parsing.cwp" at 16: class_declaration ::= IDENT:"class" #continue
//We visit 'INDENT:"class"' and we step over immediatly. Into a BNF-driven script, tokens of a
//sequence are iterated step by step, and 'next' runs all the sequence in one shot:
s
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,1
"SimpleML-parsing.cwp" at 112: IDENT ::= #!ignore ['a'..'z'|'A'..'Z'|'_']
n
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,6
"SimpleML-parsing.cwp" at 21: IDENT:sClassName
//We visit 'INDENT:sClassName' and we step over immediatly:
s
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,7
"SimpleML-parsing.cwp" at 112: IDENT ::= #!ignore ['a'..'z'|'A'..'Z'|'_']
n
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,13
"SimpleML-parsing.cwp" at 25: => insert project.listOfClasses[sClassName].name = sClassName;
//What about all local variables available on the stack?
l
sClassName
//What is the value of 'sClassName'?
t sClassName
Planet
//Now, we are looking at a classical statement of the language, an 'insert' assignment. But
//it might be more convenient to see more source code:
d 4
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,13
21: IDENT:sClassName
22: //note: about parsing, classes are modeled into node
23: //note: \textbf{project.listOfClasses[}\textit{sClassName}\textbf{]}. Its attribute
24: //note: \samp{name} contains the value of \textit{sClassName}.
25: => insert project.listOfClasses[sClassName].name = sClassName;
26: //note: if the class inherits from a parent, \samp{\textbf{':'}} is necessary followed by
27: //note: an identifier (pattern \samp{\#continue}), and the identifier that matches with
28: //note: clause call \textit{IDENT} is assigned to the local variable \samp{sClassName},
29: [':' #continue IDENT:sParentName
//What about the call stack?
stack
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,13
"SimpleML-parsing.cwp" at 25: => insert project.listOfClasses[sClassName].name = sClassName;
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,13
"SimpleML-parsing.cwp" at 6: world ::= #ignore(C++) [class_declaration]* #empty
parsed file is "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SolarSystem0.sml":2,13
"LeaderScript5.cws" at 11: parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
//Exiting the debug session:
q
file parsed successfully
generating class 'Planet' ...
generating class 'Earth' ...
generating class 'SolarSystem' ...
generating the HTML documentation...
// file "GettingStarted/LeaderScript6.cws":
if !getProperty("DESIGN_FILE")
error("'-define DESIGN_FILE=file' expected on the command line");
traceLine("'Simple Modeling' design file to parse = \""
+ getProperty("DESIGN_FILE") + "\"");
parseAsBNF("GettingStarted/SimpleML-parsing.cwp",
project, getProperty("DESIGN_FILE"));
#include "TreeDecoration.cws"
#include "SharedFunctions.cws"
foreach myClass in project.listOfClasses {
traceLine("generating class '" + myClass.name + "' ...");
generate("GettingStarted/CppObjectHeader.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".h");
generate("GettingStarted/CppObjectBody.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/Cpp/" + myClass.name + ".cpp");
generate("GettingStarted/JAVAObject.cwt", myClass, getWorkingPath() + "Scripts/Tutorial/GettingStarted/JAVA/solarsystem/" + myClass.name + ".java");
}
local myDocumentationContext;
insert myDocumentationContext.language = "C++";
traceLine("generating the HTML documentation...");
setCommentBegin("<!--");
setCommentEnd("-->");
expand("GettingStarted/HTMLDocumentation.cwt",
myDocumentationContext, getWorkingPath()
+ "Scripts/Tutorial/GettingStarted/SolarSystem1.html");
translate("GettingStarted/HTML2LaTeX.cwp", project, "GettingStarted/SolarSystem1.html", getWorkingPath() + "Scripts/Tutorial/GettingStarted/SolarSystem.tex");
'Simple Modeling' design file to parse = "GettingStarted/SolarSystem0.sml"
file parsed successfully
generating class 'Planet' ...
generating class 'Earth' ...
generating class 'SolarSystem' ...
generating the HTML documentation...
-- quantify session --
quantify execution time = 427ms
User defined functions:
populateHeaderDeclarations(...) file "c:/Projects/generator/Scripts/Tutorial/GettingStarted/CppObjectHeader.cwt" at 29: 7 occurences in 0ms
getMethodID(...) file "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SharedFunctions.cws" at 98: 3 occurences in 0ms
getParameterType(...) file "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SharedFunctions.cws" at 44: 3 occurences in 0ms
getType(...) file "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SharedFunctions.cws" at 31: 13 occurences in 0ms
getVariableName(...) file "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SharedFunctions.cws" at 76: 26 occurences in 1ms
normalizeIdentifier(...) file "c:/Projects/generator/Scripts/Tutorial/GettingStarted/SharedFunctions.cws" at 5: 39 occurences in 0ms
Predefined functions:
charAt(...): 39 occurrences
composeHTMLLikeString(...): 7 occurrences
endString(...): 9 occurrences
endl(...): 19 occurrences
executeStringQuiet(...): 1 occurrences
existVariable(...): 11 occurrences
findElement(...): 2 occurrences
findFirstChar(...): 39 occurrences
first(...): 12 occurrences
getFloatingLocation(...): 23 occurrences
getMarkupKey(...): 1 occurrences
getProperty(...): 3 occurrences
getWorkingPath(...): 11 occurrences
isEmpty(...): 6 occurrences
isNegative(...): 39 occurrences
newFloatingLocation(...): 12 occurrences
not(...): 72 occurrences
startString(...): 39 occurrences
subString(...): 39 occurrences
toUpperString(...): 39 occurrences
Procedures:
__RAW_TEXT_TO_WRITE(...): 498 occurrences
clearVariable(...): 1 occurrences
expand(...): 1 occurrences
generate(...): 9 occurrences
insertTextOnce(...): 24 occurrences
parseAsBNF(...): 1 occurrences
setCommentBegin(...): 1 occurrences
setCommentEnd(...): 1 occurrences
setProtectedArea(...): 19 occurrences
traceLine(...): 5 occurrences
translate(...): 1 occurrences
writeText(...): 325 occurrences
Covered source code: 83%
-- end of quantify session --
compileToCpp("GettingStarted/LeaderScript6.cws",
"Scripts/Tutorial/GettingStarted/bin", ".");
Scripts/Tutorial/GettingStarted/bin/CGExternalHandling.h
Scripts/Tutorial/GettingStarted/bin/CGRuntime.h
Scripts/Tutorial/GettingStarted/bin/CppObjectBody_cwt.cpp
Scripts/Tutorial/GettingStarted/bin/CppObjectBody_cwt.h
Scripts/Tutorial/GettingStarted/bin/CppObjectHeader_cwt.cpp
Scripts/Tutorial/GettingStarted/bin/CppObjectHeader_cwt.h
Scripts/Tutorial/GettingStarted/bin/CppParsingTree.h
Scripts/Tutorial/GettingStarted/bin/DynPackage.h
Scripts/Tutorial/GettingStarted/bin/HTML2LaTeX_cwp.cpp
Scripts/Tutorial/GettingStarted/bin/HTML2LaTeX_cwp.h
Scripts/Tutorial/GettingStarted/bin/HTMLDocumentation_cwt.cpp
Scripts/Tutorial/GettingStarted/bin/HTMLDocumentation_cwt.h
Scripts/Tutorial/GettingStarted/bin/JAVAObject_cwt.cpp
Scripts/Tutorial/GettingStarted/bin/JAVAObject_cwt.h
Scripts/Tutorial/GettingStarted/bin/LeaderScript6.dsp
Scripts/Tutorial/GettingStarted/bin/LeaderScript6_cws.cpp
Scripts/Tutorial/GettingStarted/bin/LeaderScript6_cws.h
Scripts/Tutorial/GettingStarted/bin/Makefile
Scripts/Tutorial/GettingStarted/bin/SimpleML-parsing_cwp.cpp
Scripts/Tutorial/GettingStarted/bin/SimpleML-parsing_cwp.h
Scripts/Tutorial/GettingStarted/bin/UtlException.h