浏览代码

Rename python src dirs to match installed names (can set to 'src' dir so you don't have to re-install after every change). Updated SCCD schema to accept all existing tests. Added XML namespace to tests. Compiler checks input file against SCCD schema. New compiler dependency 'lxml' (largely compatible with xml.etree) for dealing with XML namespaces and schemas.

Joeri Exelmans 5 年之前
父节点
当前提交
e92f44ba01
共有 100 个文件被更改,包括 1288 次插入222 次删除
  1. 1 0
      .gitignore
  2. 13 2
      bsml_features/bsml.cfr
  3. 0 153
      sccd.xsd
  4. 0 2
      schema.xml
  5. 0 0
      src/javascript_runtime/libs/HackTimer.js
  6. 0 0
      src/javascript_runtime/libs/HackTimerWorker.js
  7. 0 0
      src/javascript_runtime/libs/svg.js
  8. 0 0
      src/javascript_runtime/libs/ui.js
  9. 0 0
      src/javascript_runtime/libs/utils.js
  10. 0 0
      src/javascript_runtime/statecharts_core.js
  11. 0 0
      src/python_sccd/runtime/__init__.py
  12. 0 0
      src/sccd/__init__.py
  13. 0 0
      src/sccd/compiler/__init__.py
  14. 3 0
      src/python_sccd/compiler/compiler_exceptions.py
  15. 7 4
      src/python_sccd/compiler/generic_generator.py
  16. 0 0
      src/sccd/compiler/generic_language_constructs.py
  17. 0 0
      src/sccd/compiler/javascript_writer.py
  18. 0 0
      src/sccd/compiler/lexer.py
  19. 0 0
      src/sccd/compiler/path_calculator.py
  20. 1 1
      src/python_sccd/compiler/python_writer.py
  21. 352 0
      src/sccd/compiler/sccd.xsd
  22. 56 50
      src/python_sccd/compiler/sccd_constructs.py
  23. 16 9
      src/python_sccd/compiler/sccdc.py
  24. 0 0
      src/sccd/compiler/state_linker.py
  25. 0 0
      src/sccd/compiler/stateful_writer.py
  26. 0 0
      src/sccd/compiler/super_class_linker.py
  27. 0 0
      src/sccd/compiler/utils.py
  28. 0 0
      src/sccd/compiler/visitor.py
  29. 0 0
      src/sccd/runtime/__init__.py
  30. 0 0
      src/sccd/runtime/accurate_time.py
  31. 0 0
      src/sccd/runtime/event_queue.py
  32. 0 0
      src/sccd/runtime/infinity.py
  33. 0 0
      src/sccd/runtime/libs/__init__.py
  34. 0 0
      src/sccd/runtime/libs/drawing.py
  35. 0 0
      src/sccd/runtime/libs/ordered_set.py
  36. 0 0
      src/sccd/runtime/libs/ui.py
  37. 0 0
      src/sccd/runtime/libs/utils.py
  38. 0 0
      src/sccd/runtime/socket2event.py
  39. 0 0
      src/sccd/runtime/statecharts_core.py
  40. 0 0
      src/sccd/runtime/tkinter_eventloop.py
  41. 1 1
      src/setup.py
  42. 425 0
      test/scxml/schemas/scxml-core-strict.xsd
  43. 157 0
      test/scxml/schemas/scxml-data-strict.xsd
  44. 168 0
      test/scxml/schemas/scxml-external-strict.xsd
  45. 88 0
      test/scxml/schemas/scxml-strict.xsd
  46. 0 0
      test/scxml/tests/test144.txml
  47. 0 0
      test/scxml/tests/test147.txml
  48. 0 0
      test/scxml/tests/test148.txml
  49. 0 0
      test/scxml/tests/test149.txml
  50. 0 0
      test/scxml/tests/test150.txml
  51. 0 0
      test/scxml/tests/test151.txml
  52. 0 0
      test/scxml/tests/test152.txml
  53. 0 0
      test/scxml/tests/test153.txml
  54. 0 0
      test/scxml/tests/test155.txml
  55. 0 0
      test/scxml/tests/test156.txml
  56. 0 0
      test/scxml/tests/test158.txml
  57. 0 0
      test/scxml/tests/test159.txml
  58. 0 0
      test/scxml/tests/test172.txml
  59. 0 0
      test/scxml/tests/test173.txml
  60. 0 0
      test/scxml/tests/test174.txml
  61. 0 0
      test/scxml/tests/test175.txml
  62. 0 0
      test/scxml/tests/test176.txml
  63. 0 0
      test/scxml/tests/test178.txml
  64. 0 0
      test/scxml/tests/test179.txml
  65. 0 0
      test/scxml/tests/test183.txml
  66. 0 0
      test/scxml/tests/test185.txml
  67. 0 0
      test/scxml/tests/test186.txml
  68. 0 0
      test/scxml/tests/test187.txml
  69. 0 0
      test/scxml/tests/test189.txml
  70. 0 0
      test/scxml/tests/test190.txml
  71. 0 0
      test/scxml/tests/test191.txml
  72. 0 0
      test/scxml/tests/test192.txml
  73. 0 0
      test/scxml/tests/test193.txml
  74. 0 0
      test/scxml/tests/test194.txml
  75. 0 0
      test/scxml/tests/test198.txml
  76. 0 0
      test/scxml/tests/test199.txml
  77. 0 0
      test/scxml/tests/test200.txml
  78. 0 0
      test/scxml/tests/test201.txml
  79. 0 0
      test/scxml/tests/test205.txml
  80. 0 0
      test/scxml/tests/test207.txml
  81. 0 0
      test/scxml/tests/test208.txml
  82. 0 0
      test/scxml/tests/test210.txml
  83. 0 0
      test/scxml/tests/test215.txml
  84. 0 0
      test/scxml/tests/test216.txml
  85. 0 0
      test/scxml/tests/test220.txml
  86. 0 0
      test/scxml/tests/test223.txml
  87. 0 0
      test/scxml/tests/test224.txml
  88. 0 0
      test/scxml/tests/test225.txml
  89. 0 0
      test/scxml/tests/test226.txml
  90. 0 0
      test/scxml/tests/test228.txml
  91. 0 0
      test/scxml/tests/test229.txml
  92. 0 0
      test/scxml/tests/test230.txml
  93. 0 0
      test/scxml/tests/test232.txml
  94. 0 0
      test/scxml/tests/test233.txml
  95. 0 0
      test/scxml/tests/test234.txml
  96. 0 0
      test/scxml/tests/test235.txml
  97. 0 0
      test/scxml/tests/test236.txml
  98. 0 0
      test/scxml/tests/test237.txml
  99. 0 0
      test/scxml/tests/test239.txml
  100. 0 0
      test/scxml_test_suite/test240.txml

+ 1 - 0
.gitignore

@@ -17,3 +17,4 @@ doc/_build
 .project
 .pydevproject
 src/MANIFEST
+__pycache__/

+ 13 - 2
bsml_features/bsml.cfr

@@ -29,7 +29,7 @@ abstract BSML
 					[Syntax.Events.EventTriggers.InterfaceEvents]
 
 		Variables?
-			VariableOperators?
+			VariableOperators // in Day & Atlee, this is an optional feature, but it may not have to be optional because all its nested clafers are optional too.
 				new?
 					[Semantics.OrderOfSmallSteps.Dataflow]
 					[Semantics.EnablednessMemoryProtocol.InternalVariablesInGC.GCBigStep ||
@@ -163,7 +163,18 @@ abstract BSML
 				 Syntax.Events.EventTriggers.InterfaceEvents.NegatedInterfaceEvents ||
 				 Syntax.Events.EventTriggers.EnvironmentalInputEvents.NegatedEnvironmentalnputEvents]
 
-aBSML : BSML
+
+// Let's say in SCCD, we always have a minimum of syntactic features
+SCCD : BSML
+	[Syntax.Events]
+	[Syntax.ControlStates.Hierarchical.And]
+	[Syntax.Variables.VariableAssignments]
+	[Syntax.Variables.GuardConditions]
+
+currentlySupported : SCCD
+	[PresentInNextSmallStep || PresentInNextComboStep]
+	[SyntacticInputEvents]
+	[SyntacticOutputEvents]
 
 // validConfiguration : BSML
 // 	[PresentInSame]

+ 0 - 153
sccd.xsd

@@ -1,153 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema
-  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-  xmlns:sccd="msdl.uantwerpen.be/sccd"
-  targetNamespace="msdl.uantwerpen.be/sccd"
-  elementFormDefault="qualified"
-  attributeFormDefault="unqualified">
-
-  <!-- First, some type declarations... -->
-
-  <xsd:simpleType name="identifier">
-    <xsd:restriction base="xsd:string">
-      <xsd:pattern value="([A-Za-z0-9]|_)+"/>
-    </xsd:restriction>
-  </xsd:simpleType>
-
-  <xsd:simpleType name="stateId">
-    <xsd:restriction base="sccd:identifier"/>
-  </xsd:simpleType>
-
-  <xsd:simpleType name="portName">
-    <xsd:restriction base="sccd:identifier"/>
-  </xsd:simpleType>
-
-  <xsd:simpleType name="className">
-    <xsd:restriction base="sccd:identifier"/>
-  </xsd:simpleType>
-
-  <!-- Used for 'onentry', 'onexit' and 'transition' -->
-  <xsd:complexType name="hasActions">
-    <xsd:choice minOccurs="0" maxOccurs="unbounded">
-      <xsd:element name="raise">
-        <xsd:complexType>
-          <xsd:attribute name="event" type="xsd:string" use="required"/>
-          <xsd:attribute name="port" type="sccd:portName"/>
-        </xsd:complexType>
-      </xsd:element>
-      <xsd:element name="script" type="xsd:string"/>
-    </xsd:choice>
-  </xsd:complexType>
-
-  <!--
-       Recursive type.
-
-       Basically all the common stuff of basic/or/and states.
-       An element of this type does not have an 'id' attribute, but all its children
-       states do.
-       The reason we don't include state id's at the highest level is because
-       the root of a diagram is also a state (an or-state, to be specific),
-       but it has no id.
-  -->
-  <xsd:complexType name="commonState" abstract="true">
-    <xsd:sequence>
-      <xsd:element name="onentry" minOccurs="0" type="sccd:hasActions"/>
-      <xsd:element name="onexit" minOccurs="0" type="sccd:hasActions"/>
-      <xsd:choice minOccurs="0" maxOccurs="unbounded">
-        <!-- Every state can have any number of <state> and <parallel> elements in it.
-             These elements always have an 'id' attribute. -->
-        <xsd:element name="state">
-          <xsd:complexType>
-            <xsd:complexContent>
-              <xsd:extension base="sccd:orState">
-                <xsd:attribute name="id" type="sccd:stateId" use="required"/>
-              </xsd:extension>
-            </xsd:complexContent>
-          </xsd:complexType>
-        </xsd:element>
-        <xsd:element name="parallel">
-          <xsd:complexType>
-            <xsd:complexContent>
-              <xsd:extension base="sccd:commonState">
-                <xsd:attribute name="id" type="sccd:stateId" use="required"/>
-              </xsd:extension>
-            </xsd:complexContent>
-          </xsd:complexType>
-        </xsd:element>
-        <xsd:element name="transition">
-          <xsd:complexType>
-            <xsd:complexContent>
-              <xsd:extension base="sccd:hasActions">
-                <xsd:attribute name="target" type="xsd:string" use="required"/>
-                <xsd:attribute name="after" type="xsd:decimal"/>
-                <xsd:attribute name="cond" type="xsd:string"/>
-              </xsd:extension>
-            </xsd:complexContent>
-          </xsd:complexType>
-        </xsd:element>
-      </xsd:choice>
-    </xsd:sequence>
-  </xsd:complexType>
-
-  <!-- Just like commonState, also without 'id' attribute -->
-  <xsd:complexType name="orState">
-    <xsd:complexContent>
-      <xsd:extension base="sccd:commonState">
-        <xsd:attribute name="initial" type="xsd:string"/>
-      </xsd:extension>
-    </xsd:complexContent>
-  </xsd:complexType>
-
-  <xsd:attributeGroup name="semanticOptions">
-    <xsd:attribute name="big_step_maximality">
-      <xsd:simpleType>
-        <xsd:restriction base="xsd:string">
-          <xsd:enumeration value="take_one"/>
-          <xsd:enumeration value="take_many"/>
-        </xsd:restriction>
-      </xsd:simpleType>
-    </xsd:attribute>
-  </xsd:attributeGroup>
-
-  <xsd:complexType name="portDecl">
-    <xsd:attribute name="name" type="sccd:portName"/>
-  </xsd:complexType>
-
-  <!-- Root element -->
-  <xsd:element name="diagram">
-    <xsd:complexType>
-      <xsd:sequence>
-        <xsd:element name="description" type="xsd:string" minOccurs="0"/>
-        <xsd:element name="inport" minOccurs="0" maxOccurs="unbounded" type="sccd:portDecl"/>
-        <xsd:element name="outport" minOccurs="0" maxOccurs="unbounded" type="sccd:portDecl"/>
-        <xsd:element name="class" maxOccurs="unbounded">
-          <xsd:complexType>
-            <xsd:sequence>
-              <xsd:element name="scxml" minOccurs="0">
-                <xsd:complexType>
-                  <xsd:complexContent>
-                    <xsd:extension base="sccd:orState">
-                      <xsd:attributeGroup ref="sccd:semanticOptions"/>
-                    </xsd:extension>
-                  </xsd:complexContent>
-                </xsd:complexType>
-              </xsd:element>
-            </xsd:sequence>
-            <xsd:attribute name="name" type="sccd:className" use="required"/>
-            <xsd:attribute name="default" type="xsd:boolean"/>
-          </xsd:complexType>
-        </xsd:element>
-        <xsd:element name="test" minOccurs="0">
-          <xsd:complexType>
-            <xsd:sequence>
-              <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
-            </xsd:sequence>
-          </xsd:complexType>
-        </xsd:element>
-      </xsd:sequence>
-      <xsd:attribute name="author" type="xsd:string"/>
-      <xsd:attribute name="name" type="xsd:string"/>
-    </xsd:complexType>
-  </xsd:element>
-
-</xsd:schema>

+ 0 - 2
schema.xml

@@ -56,5 +56,3 @@
         </xsd:complexType>
     </xsd:element>
 </xsd:schema>
-
-

src/javascript_sccd_runtime/libs/HackTimer.js → src/javascript_runtime/libs/HackTimer.js


src/javascript_sccd_runtime/libs/HackTimerWorker.js → src/javascript_runtime/libs/HackTimerWorker.js


src/javascript_sccd_runtime/libs/svg.js → src/javascript_runtime/libs/svg.js


src/javascript_sccd_runtime/libs/ui.js → src/javascript_runtime/libs/ui.js


src/javascript_sccd_runtime/libs/utils.js → src/javascript_runtime/libs/utils.js


src/javascript_sccd_runtime/statecharts_core.js → src/javascript_runtime/statecharts_core.js


+ 0 - 0
src/python_sccd/runtime/__init__.py


__init__.py → src/sccd/__init__.py


src/python_sccd/__init__.py → src/sccd/compiler/__init__.py


+ 3 - 0
src/python_sccd/compiler/compiler_exceptions.py

@@ -12,3 +12,6 @@ class UnprocessedException(CompilerException):
 
 class CodeBlockException(CompilerException):
 	pass
+
+class TargetLanguageException(CompilerException):
+  pass

+ 7 - 4
src/python_sccd/compiler/generic_generator.py

@@ -13,7 +13,10 @@ from sccd.compiler.sccd_constructs import FormalParameter
 from sccd.compiler.stateful_writer import StatefulWriter
 import sccd.compiler.generic_language_constructs as GLC
 
-Platforms = Enum("Threads","GameLoop","EventLoop") 
+Platforms = Enum("Threads","GameLoop","EventLoop")
+
+def compiled_class_name(sccd_class_name):
+    return "SCCDClass_"+sccd_class_name
 
 class GenericGenerator(Visitor):
     
@@ -73,7 +76,7 @@ class GenericGenerator(Visitor):
                 # cannot instantiate abstract class
                 self.writer.add(GLC.ThrowExceptionStatement(GLC.String("Cannot instantiate abstract class \"" + c.name + "\" with unimplemented methods \"" + "\", \"".join(c.abstract_method_names) + "\".")))
             else:
-                new_expr = GLC.NewExpression(c.name, [GLC.SelfProperty("controller")])
+                new_expr = GLC.NewExpression(compiled_class_name(c.name), [GLC.SelfProperty("controller")])
                 param_count = 0
                 for p in c.constructors[0].parameters:
                     new_expr.getActualParameters().add(GLC.ArrayIndexedExpression("construct_params", str(param_count)))
@@ -224,7 +227,7 @@ class GenericGenerator(Visitor):
             for super_class in class_node.super_classes:
                 super_classes.append(super_class)
 
-        self.writer.beginClass(class_node.name, super_classes)
+        self.writer.beginClass(compiled_class_name(class_node.name), super_classes)
 
         # visit constructor
         class_node.constructors[0].accept(self)
@@ -342,7 +345,7 @@ class GenericGenerator(Visitor):
 
         self.writer.addVSpace()
         self.writer.addComment("call user defined constructor")
-        self.writer.beginSuperClassMethodCall(constructor.parent_class.name, "user_defined_constructor")
+        self.writer.beginSuperClassMethodCall(compiled_class_name( constructor.parent_class.name ), "user_defined_constructor")
         for p in constructor.getParams():
             # we can't do p.accept(self) here because 'p' is a FormalParameter
             # and we want to write it as an actual parameter

src/python_sccd/compiler/generic_language_constructs.py → src/sccd/compiler/generic_language_constructs.py


src/python_sccd/compiler/javascript_writer.py → src/sccd/compiler/javascript_writer.py


src/python_sccd/compiler/lexer.py → src/sccd/compiler/lexer.py


src/python_sccd/compiler/path_calculator.py → src/sccd/compiler/path_calculator.py


+ 1 - 1
src/python_sccd/compiler/python_writer.py

@@ -196,7 +196,7 @@ class PythonWriter(GenericWriterBase):
 			init_value.accept(self)
 
 	def visit_LogStatement(self, l):
-		self.out.write("print \"" + l.getMessage() + "\"")
+		self.out.write("print(\"" + l.getMessage() + "\")")
 
 	def visit_MapExpression(self, m):
 		elements = m.getElements()

+ 352 - 0
src/sccd/compiler/sccd.xsd

@@ -0,0 +1,352 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:sccd="msdl.uantwerpen.be/sccd"
+  targetNamespace="msdl.uantwerpen.be/sccd"
+  elementFormDefault="qualified"
+  attributeFormDefault="unqualified">
+
+  <!-- First, some type declarations... -->
+
+  <xsd:simpleType name="identifier">
+    <xsd:restriction base="xsd:string">
+      <xsd:pattern value="([A-Za-z0-9]|_)+"/>
+    </xsd:restriction>
+  </xsd:simpleType>
+
+  <xsd:simpleType name="stateId">
+    <xsd:restriction base="sccd:identifier"/>
+  </xsd:simpleType>
+
+  <xsd:simpleType name="portName">
+    <xsd:restriction base="sccd:identifier"/>
+  </xsd:simpleType>
+
+  <xsd:simpleType name="className">
+    <xsd:restriction base="sccd:identifier"/>
+  </xsd:simpleType>
+
+  <xsd:simpleType name="eventName">
+    <xsd:restriction base="sccd:identifier"/>
+  </xsd:simpleType>
+
+  <xsd:simpleType name="type">
+    <xsd:restriction base="xsd:string">
+      <xsd:enumeration value="string"/>
+      <xsd:enumeration value="int"/>
+    </xsd:restriction>
+  </xsd:simpleType>
+
+  <xsd:simpleType name="expression">
+    <xsd:restriction base="xsd:string">
+      <!-- todo -->
+    </xsd:restriction>
+  </xsd:simpleType>
+
+  <!-- maybe use xsd:duration or some other type that supports units in the future -->
+  <xsd:simpleType name="duration">
+    <xsd:restriction base="xsd:float"/>
+  </xsd:simpleType>
+
+  <xsd:complexType name="method">
+    <xsd:sequence>
+      <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+        <xsd:complexType>
+          <xsd:attribute name="name" type="sccd:identifier"/>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:element name="body" type="xsd:string"/>
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <!-- Used for 'onentry', 'onexit' and 'transition' -->
+  <xsd:group name="action">
+    <xsd:choice>
+      <xsd:element name="raise">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+              <xsd:complexType>
+                <xsd:attribute name="expr" type="sccd:expression"/>
+              </xsd:complexType>
+            </xsd:element>
+          </xsd:sequence>
+          <xsd:attribute name="event" type="sccd:eventName" use="required"/>
+          <xsd:attribute name="target" type="sccd:expression"/>
+          <xsd:attribute name="port" type="sccd:portName"/>
+          <xsd:attribute name="scope">
+            <xsd:simpleType>
+              <xsd:restriction base="xsd:string">
+                <xsd:enumeration value="cd"/>
+                <xsd:enumeration value="narrow"/>
+                <xsd:enumeration value="broad"/>
+              </xsd:restriction>
+            </xsd:simpleType>
+          </xsd:attribute>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:element name="assign">
+        <xsd:complexType>
+          <xsd:attribute name="ident" type="sccd:expression"/>
+          <xsd:attribute name="expr" type="sccd:expression"/>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:element name="script" type="xsd:string"/>
+      <xsd:element name="log" type="xsd:string"/>
+    </xsd:choice>
+  </xsd:group>
+
+  <!--
+       Recursive type.
+
+       Basically all the common stuff of basic/or/and states.
+       An element of this type does not have an 'id' attribute, but all its children
+       states do.
+       The reason we don't include state id's at the highest level is because
+       the root element <scxml> is also a state (an or-state, to be specific),
+       but it has no id.
+  -->
+  <xsd:complexType name="commonState" abstract="true">
+    <xsd:sequence>
+      <xsd:element name="onentry" minOccurs="0">
+        <xsd:complexType>
+          <xsd:group ref="sccd:action" maxOccurs="unbounded"/>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:element name="onexit" minOccurs="0">
+        <xsd:complexType>
+          <xsd:group ref="sccd:action" maxOccurs="unbounded"/>
+        </xsd:complexType>
+      </xsd:element>
+      <xsd:choice minOccurs="0" maxOccurs="unbounded">
+        <!-- Every state can have any number of <state> and <parallel> elements in it.
+             These elements always have an 'id' attribute. -->
+        <xsd:element name="state">
+          <xsd:complexType>
+            <xsd:complexContent>
+              <xsd:extension base="sccd:orState">
+                <xsd:attribute name="id" type="sccd:stateId" use="required"/>
+              </xsd:extension>
+            </xsd:complexContent>
+          </xsd:complexType>
+        </xsd:element>
+        <xsd:element name="parallel">
+          <xsd:complexType>
+            <xsd:complexContent>
+              <xsd:extension base="sccd:commonState">
+                <xsd:attribute name="id" type="sccd:stateId" use="required"/>
+              </xsd:extension>
+            </xsd:complexContent>
+          </xsd:complexType>
+        </xsd:element>
+        <xsd:element name="history">
+          <xsd:complexType>
+            <xsd:complexContent>
+              <xsd:extension base="sccd:commonState">
+                <xsd:attribute name="id" type="sccd:stateId" use="required"/>
+                <xsd:attribute name="type">
+                  <xsd:simpleType>
+                    <xsd:restriction base="xsd:string">
+                      <xsd:enumeration value="shallow"/>
+                      <xsd:enumeration value="deep"/>
+                    </xsd:restriction>
+                  </xsd:simpleType>
+                </xsd:attribute>
+              </xsd:extension>
+            </xsd:complexContent>
+          </xsd:complexType>
+        </xsd:element>
+        <xsd:element name="transition">
+          <xsd:complexType>
+            <xsd:sequence>
+              <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                  <xsd:attribute name="name" type="sccd:identifier"/>
+                  <xsd:attribute name="type" type="sccd:type"/>
+                </xsd:complexType>
+              </xsd:element>
+              <xsd:group ref="sccd:action" minOccurs="0" maxOccurs="unbounded"/>
+            </xsd:sequence>
+            <xsd:attribute name="target" type="xsd:string" use="required"/>
+            <xsd:attribute name="event" type="sccd:eventName"/>
+            <xsd:attribute name="after" type="sccd:duration"/>
+            <xsd:attribute name="cond" type="sccd:expression"/>
+            <xsd:attribute name="port" type="sccd:portName"/>
+          </xsd:complexType>
+        </xsd:element>
+      </xsd:choice>
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <!-- Just like commonState, also without 'id' attribute -->
+  <xsd:complexType name="orState">
+    <xsd:complexContent>
+      <xsd:extension base="sccd:commonState">
+        <xsd:attribute name="initial" type="xsd:string"/>
+      </xsd:extension>
+    </xsd:complexContent>
+  </xsd:complexType>
+
+  <xsd:attributeGroup name="semanticOptions">
+    <xsd:attribute name="big_step_maximality">
+      <xsd:simpleType>
+        <xsd:restriction base="xsd:string">
+          <xsd:enumeration value="take_one"/>
+          <xsd:enumeration value="take_many"/>
+        </xsd:restriction>
+      </xsd:simpleType>
+    </xsd:attribute>
+    <xsd:attribute name="priority">
+      <xsd:simpleType>
+        <xsd:restriction base="xsd:string">
+          <xsd:enumeration value="source_parent"/>
+          <xsd:enumeration value="source_child"/>
+        </xsd:restriction>
+      </xsd:simpleType>
+    </xsd:attribute>
+    <xsd:attribute name="internal_event_lifeline">
+      <xsd:simpleType>
+        <xsd:restriction base="xsd:string">
+          <xsd:enumeration value="next_small_step"/>
+          <xsd:enumeration value="next_combo_step"/>
+          <xsd:enumeration value="queue"/>
+        </xsd:restriction>
+      </xsd:simpleType>
+    </xsd:attribute>
+    <xsd:attribute name="input_event_lifeline">
+      <xsd:simpleType>
+        <xsd:restriction base="xsd:string">
+          <xsd:enumeration value="whole"/>
+          <xsd:enumeration value="first_small_step"/>
+          <xsd:enumeration value="first_combo_step"/>
+        </xsd:restriction>
+      </xsd:simpleType>
+    </xsd:attribute>
+    <xsd:attribute name="concurrency">
+      <xsd:simpleType>
+        <xsd:restriction base="xsd:string">
+          <xsd:enumeration value="single"/>
+          <xsd:enumeration value="many"/>
+        </xsd:restriction>
+      </xsd:simpleType>
+    </xsd:attribute>
+  </xsd:attributeGroup>
+
+  <xsd:complexType name="portDecl">
+    <xsd:attribute name="name" type="sccd:portName"/>
+  </xsd:complexType>
+
+  <!-- Root element -->
+  <xsd:element name="diagram">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element name="description" type="xsd:string" minOccurs="0"/>
+        <xsd:element name="inport" minOccurs="0" maxOccurs="unbounded" type="sccd:portDecl"/>
+        <xsd:element name="outport" minOccurs="0" maxOccurs="unbounded" type="sccd:portDecl"/>
+
+        <xsd:element name="class" maxOccurs="unbounded">
+          <xsd:complexType>
+            <xsd:sequence>
+              <xsd:element name="relationships" minOccurs="0">
+                <xsd:complexType>
+                  <xsd:choice maxOccurs="unbounded">
+                    <xsd:element name="inheritance">
+                      <xsd:complexType>
+                        <xsd:attribute name="class" type="sccd:className" use="required"/>
+                      </xsd:complexType>
+                    </xsd:element>
+                    <xsd:element name="association">
+                      <xsd:complexType>
+                        <xsd:attribute name="class" type="sccd:className" use="required"/>
+                        <xsd:attribute name="name" type="sccd:identifier" use="required"/>
+                        <xsd:attribute name="min" type="xsd:integer"/>
+                        <xsd:attribute name="max" type="xsd:integer"/>
+                      </xsd:complexType>
+                    </xsd:element>
+                  </xsd:choice>
+                </xsd:complexType>
+              </xsd:element>
+              <xsd:element name="attribute" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                  <xsd:attribute name="name" type="sccd:identifier" use="required"/>
+                  <xsd:attribute name="type" type="sccd:type"/>
+                  <xsd:attribute name="init-value" type="sccd:expression"/>
+                </xsd:complexType>
+              </xsd:element>
+              <xsd:element name="constructor" minOccurs="0" type="sccd:method"/>
+              <xsd:element name="scxml" minOccurs="0">
+                <xsd:complexType>
+                  <xsd:complexContent>
+                    <xsd:extension base="sccd:orState">
+                      <xsd:attributeGroup ref="sccd:semanticOptions"/>
+                    </xsd:extension>
+                  </xsd:complexContent>
+                </xsd:complexType>
+              </xsd:element>
+            </xsd:sequence>
+            <xsd:attribute name="name" type="sccd:className" use="required"/>
+            <xsd:attribute name="default" type="xsd:boolean"/>
+          </xsd:complexType>
+        </xsd:element>
+
+        <xsd:element name="test" minOccurs="0">
+          <xsd:complexType>
+            <xsd:sequence>
+              <xsd:element name="input" minOccurs="0">
+                <xsd:complexType>
+                  <xsd:sequence>
+                    <xsd:element name="event" minOccurs="0" maxOccurs="unbounded">
+                      <xsd:complexType>
+                        <xsd:attribute name="name" type="sccd:eventName"/>
+                        <xsd:attribute name="port" type="sccd:portName"/>
+                        <xsd:attribute name="time" type="sccd:duration"/>
+                      </xsd:complexType>
+                    </xsd:element>
+                  </xsd:sequence>
+                </xsd:complexType>
+              </xsd:element>
+              <xsd:element name="expected" minOccurs="0">
+                <xsd:complexType>
+                  <xsd:sequence>
+                    <xsd:element name="slot" minOccurs="0" maxOccurs="unbounded">
+                      <xsd:complexType>
+                        <xsd:sequence>
+                          <xsd:element name="event" minOccurs="0" maxOccurs="unbounded">
+                            <xsd:complexType>
+                              <xsd:sequence>
+                                <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+                                  <xsd:complexType>
+                                    <xsd:attribute name="value" type="sccd:expression"/>
+                                  </xsd:complexType>
+                                </xsd:element>
+                              </xsd:sequence>
+                              <xsd:attribute name="name" type="sccd:eventName"/>
+                              <xsd:attribute name="port" type="sccd:portName"/>
+                            </xsd:complexType>
+                          </xsd:element>
+                        </xsd:sequence>
+                      </xsd:complexType>
+                    </xsd:element>
+                  </xsd:sequence>
+                </xsd:complexType>
+              </xsd:element>
+              <!-- <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/> -->
+            </xsd:sequence>
+          </xsd:complexType>
+        </xsd:element>
+      </xsd:sequence>
+
+      <xsd:attribute name="author" type="xsd:string"/>
+      <xsd:attribute name="name" type="xsd:string"/>
+      <xsd:attribute name="language">
+        <xsd:simpleType>
+          <xsd:restriction base="xsd:string">
+            <xsd:enumeration value="python"/>
+            <xsd:enumeration value="javascript"/>
+          </xsd:restriction>
+        </xsd:simpleType>
+      </xsd:attribute>
+    </xsd:complexType>
+  </xsd:element>
+
+</xsd:schema>

+ 56 - 50
src/python_sccd/compiler/sccd_constructs.py

@@ -1,6 +1,5 @@
 import abc
 import re
-import xml.etree.ElementTree as ET
 import os.path
 
 from sccd.compiler.utils import Logger
@@ -8,6 +7,8 @@ from sccd.compiler.visitor import Visitable
 from sccd.compiler.compiler_exceptions import CompilerException, TransitionException, UnprocessedException
 from sccd.compiler.lexer import Lexer, Token, TokenType
 
+import lxml.etree as ET
+
 # http://docs.python.org/2/library/xml.etree.elementtree.html
 
 # list of reserved words
@@ -171,7 +172,7 @@ class TriggerEvent:
             return
             
         self.params = []
-        parameters = xml_element.findall('parameter')    
+        parameters = xml_element.findall('parameter', xml_element.nsmap)
         for p in parameters :
             name = p.get("name","")
             if not name :
@@ -215,10 +216,10 @@ class SubAction(Visitable):
     @classmethod
     def create(cls, xml_element):
         for subcls in cls.__subclasses__():
-            tag = xml_element.tag.lower()
-            if subcls.check(tag):
+            tag = ET.QName(xml_element)
+            if subcls.check(tag.localname):
                 return subcls(xml_element)
-        raise CompilerException("Invalid subaction: " + str(xml_element.tag.lower()))
+        raise CompilerException("Line " + str(xml_element.sourceline) + ": Invalid subaction: " + str(tag.localname))
     
 ##################################
 """
@@ -279,7 +280,7 @@ class RaiseEvent(SubAction):
             self.target = ""
                 
         self.params = []
-        parameters = xml_element.findall('parameter')    
+        parameters = xml_element.findall('parameter', xml_element.nsmap)    
         for p in parameters :
             value = p.get("expr","")
             if not value :
@@ -356,9 +357,11 @@ class Assign(SubAction):
 class Action(Visitable):
     def __init__(self, xml_element):
         self.sub_actions = []
-        for subaction in list(xml_element) :
-            if subaction.tag not in ["parameter"] :      
-                self.sub_actions.append(SubAction.create(subaction))
+        for subaction in xml_element:
+            if isinstance(subaction.tag, str):
+                # subaction.tag
+                if ET.QName(subaction).localname not in ["parameter"] :      
+                    self.sub_actions.append(SubAction.create(subaction))
             
     def accept(self, visitor):
         for subaction in self.sub_actions :
@@ -455,22 +458,24 @@ class StateChartNode(Visitable):
         self.save_state_on_exit = False
         self.has_timers = False
         self.initial = None
+
+        tag = ET.QName(xml_element)
             
-        if xml_element.tag == "scxml" : 
+        if tag.localname == "scxml" : 
             self.is_root = True
             self.is_composite = True
-        elif xml_element.tag == "parallel" : 
+        elif tag.localname == "parallel" : 
             self.is_composite = True
             self.is_parallel_state = True
-        elif xml_element.tag == "state" :
-            if len(xml_element.findall("state")) > 0 or (len(xml_element.findall("parallel")) > 0) :
+        elif tag.localname == "state" :
+            if len(xml_element.findall("state", xml_element.nsmap)) > 0 or (len(xml_element.findall("parallel", xml_element.nsmap)) > 0) :
                 self.is_composite = True
             else :
                 self.is_basic = True
             if  self.parent.is_parallel_state :
                 if (self.is_basic) :
                     raise CompilerException("Orthogonal nodes (nodes that are immediate children of parallel nodes) can't be basic.")
-        elif xml_element.tag == "history" :
+        elif tag.localname == "history" :
             history_type = xml_element.get("type","shallow")
             if history_type == "deep" :
                 self.is_history_deep = True
@@ -484,11 +489,11 @@ class StateChartNode(Visitable):
         #self.parseConflictAttribute(xml_element)
         self.parseEnterActions(xml_element)
         self.parseExitActions(xml_element)
-        
+
         #transitions
         self.transitions = []
         self.else_transitions = []
-        for transition_xml in xml_element.findall("transition"):
+        for transition_xml in xml_element.findall("transition", xml_element.nsmap):
             transition = StateChartTransition(transition_xml, self)
             if isinstance(transition.guard, ElseGuard):
                 self.else_transitions.append(transition)
@@ -534,7 +539,7 @@ class StateChartNode(Visitable):
     """
                 
     def parseEnterActions(self, xml):
-        on_entries = xml.findall("onentry")
+        on_entries = xml.findall("onentry", xml.nsmap)
         if on_entries :
             if len(on_entries) > 1:
                 raise CompilerException("Multiple <onentry> tags detected for "+ self.full_name + ", only 1 allowed.")
@@ -543,7 +548,7 @@ class StateChartNode(Visitable):
             self.enter_action = EnterAction(self)
             
     def parseExitActions(self, xml):
-        on_exits = xml.findall("onexit")
+        on_exits = xml.findall("onexit", xml.nsmap)
         if on_exits :
             if len(on_exits) > 1:
                 raise CompilerException("Multiple <onexit> tags detected for "+ self.full_name + ", only 1 allowed.")
@@ -747,11 +752,11 @@ class Method(Visitable):
     def __init__(self, xml, parent_class):
         self.name = xml.get("name", "")
         self.access = xml.get("access", "public")
-        parameters = xml.findall("parameter")
+        parameters = xml.findall("parameter", xml.nsmap)
         self.parameters = []
         for p in parameters:
             self.parameters.append(XMLFormalParameter(p))
-        bodies = xml.findall("body")
+        bodies = xml.findall("body", xml.nsmap)
         if len(bodies) > 1 : 
             raise CompilerException("Method can have at most one body.")
         elif len(bodies) == 1:
@@ -781,11 +786,11 @@ class Constructor(Method):
             self.parameters = []
         else :
             Method.__init__(self, xml, parent_class)      
-            super_class_parameters = xml.findall("super")
+            super_class_parameters = xml.findall("super", xml.nsmap)
             for s in super_class_parameters:
                 class_name = s.get("class")
                 self.super_class_parameters[class_name] = []
-                params = s.findall("parameter")
+                params = s.findall("parameter", s.nsmap)
                 for p in params:
                     self.super_class_parameters[class_name].append(p.get("expr"))
         
@@ -931,14 +936,14 @@ class Class(Visitable):
     
 
     def process(self):
-        inports = self.xml.findall("inport")
+        inports = self.xml.findall("inport", self.xml.nsmap)
         for i in inports:
             name = i.get("name")
             if name in self.inports:
                 raise CompilerException("Found 2 inports with the same name : " + name + ".")
             self.inports.append(name)
 
-        outports = self.xml.findall("outport")
+        outports = self.xml.findall("outport", self.xml.nsmap)
         for i in outports:
             name = i.get("name")
             if name in self.outports:
@@ -947,27 +952,27 @@ class Class(Visitable):
 
         associations = []
         inheritances = []
-        relationships = self.xml.findall("relationships")
+        relationships = self.xml.findall("relationships", self.xml.nsmap)
         for relationship_wrapper in relationships :
-            associations.extend(relationship_wrapper.findall("association"))
-            inheritances.extend(relationship_wrapper.findall("inheritance"))
+            associations.extend(relationship_wrapper.findall("association", relationship_wrapper.nsmap))
+            inheritances.extend(relationship_wrapper.findall("inheritance", relationship_wrapper.nsmap))
             
         self.processAssociations(associations)
         self.processInheritances(inheritances)
 
-        attributes = self.xml.findall("attribute")
+        attributes = self.xml.findall("attribute", self.xml.nsmap)
         for a in attributes:
             self.processAttribute(a)
 
-        methods = self.xml.findall("method")
+        methods = self.xml.findall("method", self.xml.nsmap)
         for m in methods:
             self.processMethod(m)
 
-        constructors = self.xml.findall("constructor")
+        constructors = self.xml.findall("constructor", self.xml.nsmap)
         for c in constructors:
             self.constructors.append(Constructor(c, self))
 
-        destructors = self.xml.findall("destructor")
+        destructors = self.xml.findall("destructor", self.xml.nsmap)
         for d in destructors:
             self.destructors.append(Destructor(d, self))
         
@@ -985,7 +990,7 @@ class Class(Visitable):
             # add a default destructor
             self.destructors.append(Destructor(None,self))
 
-        statecharts = self.xml.findall("scxml")
+        statecharts = self.xml.findall("scxml", self.xml.nsmap)
         if len(statecharts) > 1 :
             raise CompilerException("Multiple statecharts found in class <" + self.name + ">.")
         if len(statecharts) == 1 :
@@ -993,20 +998,20 @@ class Class(Visitable):
             
 ###################################
 class ClassDiagram(Visitable):
-    def __init__(self, input_file):
-        diagram_dir = os.path.dirname(input_file)
-        tree = ET.parse(input_file)
+    def __init__(self, tree):
+        # diagram_dir = os.path.dirname(input_file)
+        # tree = ET.parse(input_file)
         self.root = tree.getroot()
         self.name = self.root.get("name", "")
         self.author = self.root.get("author", "")
-        descriptions = self.root.findall("description")
+        descriptions = self.root.findall("description", self.root.nsmap)
         self.language = self.root.get("language", "")
         if descriptions : 
             self.description = descriptions[0].text
         else :
             self.description = ""
 
-        xml_classes = self.root.findall("class")
+        xml_classes = self.root.findall("class", self.root.nsmap)
         # make sure at least one class is given
         if not xml_classes :
             raise CompilerException("Found no classes to compile.")
@@ -1020,9 +1025,10 @@ class ClassDiagram(Visitable):
             class_src = xml_class.get("src", "")
             class_default = xml_class.get("default", "")
             if class_src != "":
-                if not os.path.isabs(class_src):
-                    class_src = os.path.join(diagram_dir, class_src)
-                substituted_xml_class = ET.parse(class_src).getroot()
+                # if not os.path.isabs(class_src):
+                #     class_src = os.path.join(diagram_dir, class_src)
+                # substituted_xml_class = ET.parse(class_src).getroot()
+                raise CompilerException("class_src currently not supported")
             else:
                 substituted_xml_class = xml_class
 
@@ -1038,7 +1044,7 @@ class ClassDiagram(Visitable):
             substituted_xml_classes.append(substituted_xml_class)
     
         # process in and output ports
-        inports = self.root.findall("inport")
+        inports = self.root.findall("inport", self.root.nsmap)
         names = []
         for xml_inport in inports :
             name = xml_inport.get("name", "")
@@ -1047,7 +1053,7 @@ class ClassDiagram(Visitable):
             names.append(name)
         self.inports = names
         
-        outports = self.root.findall("outport")
+        outports = self.root.findall("outport", self.root.nsmap)
         names = []
         for xml_outport in outports :
             name = xml_outport.get("name", "")
@@ -1058,7 +1064,7 @@ class ClassDiagram(Visitable):
             
         
         # any inital import code that has to come at the top of the generate file
-        tops = self.root.findall("top")
+        tops = self.root.findall("top", self.root.nsmap)
         self.includes = []
         if len(tops) == 1 :
             self.top = tops[0].text
@@ -1096,18 +1102,18 @@ class ClassDiagram(Visitable):
 
         # check if there's a test
         self.test = None
-        test_nodes = self.root.findall("test")
+        test_nodes = self.root.findall("test", self.root.nsmap)
         if test_nodes:
             test_node = test_nodes[0]
 
-            input_nodes = test_node.findall("input")
+            input_nodes = test_node.findall("input", test_node.nsmap)
             if input_nodes:
                 input_node = input_nodes[0]
                 test_input = DiagramTestInput(input_node)
             else:
                 test_input = None
 
-            expected_nodes = test_node.findall("expected")
+            expected_nodes = test_node.findall("expected", test_node.nsmap)
             if expected_nodes:
                 expected_node = expected_nodes[0]
                 test_expected = DiagramTestExpected(expected_node)
@@ -1127,7 +1133,7 @@ class DiagramTestEvent(Visitable):
         self.name = xml.get("name")
         self.port = xml.get("port")
         self.parameters = []
-        parameter_nodes = xml.findall("parameter")
+        parameter_nodes = xml.findall("parameter", xml.nsmap)
         for parameter_node in parameter_nodes:
             val = parameter_node.get("value")
             expr = parameter_node.get("expr")
@@ -1146,7 +1152,7 @@ class DiagramTestInputEvent(DiagramTestEvent):
 class DiagramTestInput(Visitable):
     def __init__(self, xml):
         self.input_events = []
-        event_nodes = xml.findall("event")
+        event_nodes = xml.findall("event", xml.nsmap)
         for event_node in event_nodes:
             e = DiagramTestInputEvent(event_node)
             self.input_events.append(e)
@@ -1154,7 +1160,7 @@ class DiagramTestInput(Visitable):
 class DiagramTestExpectedSlot(Visitable):
     def __init__(self, xml):
         self.expected_events = []
-        event_nodes = xml.findall("event")
+        event_nodes = xml.findall("event", xml.nsmap)
         for event_node in event_nodes:
             e = DiagramTestEvent(event_node)
             self.expected_events.append(e)
@@ -1162,7 +1168,7 @@ class DiagramTestExpectedSlot(Visitable):
 class DiagramTestExpected(Visitable):
     def __init__(self, xml):
         self.slots = []
-        slot_nodes = xml.findall("slot")
+        slot_nodes = xml.findall("slot", xml.nsmap)
         for slot_node in slot_nodes:
             s = DiagramTestExpectedSlot(slot_node)
             self.slots.append(s)

+ 16 - 9
src/python_sccd/compiler/sccdc.py

@@ -1,6 +1,7 @@
 import argparse
 import os
 import sys
+import lxml.etree as ET
 
 from sccd.compiler.generic_generator import GenericGenerator, Platforms
 from sccd.compiler.utils import Enum, Logger, FileWriter
@@ -9,33 +10,39 @@ from sccd.compiler.state_linker import StateLinker
 from sccd.compiler.path_calculator import PathCalculator
 from sccd.compiler.sccd_constructs import ClassDiagram
 from sccd.compiler.generic_language_constructs import GenericConstruct
-from sccd.compiler.compiler_exceptions import CompilerException
+from sccd.compiler.compiler_exceptions import CompilerException, TargetLanguageException
 
 from sccd.compiler.javascript_writer import JavascriptWriter
 from sccd.compiler.python_writer import PythonWriter
 
-def generate(input_file, output_file, target_language, platform):
+COMPILER_SRC_DIR = os.path.dirname(os.path.abspath(__file__))
 
-	sccd = xmlToSccd(input_file)
+def generate(input_file, output_file, target_language, platform):
 
+	schema = ET.XMLSchema(ET.parse(os.path.join(COMPILER_SRC_DIR, "sccd.xsd")))
+	tree = ET.parse(input_file)
+	schema.assertValid(tree)
+	
+	language = tree.getroot().get("language")
 	if not target_language:
-		if sccd.language:
-			target_language = sccd.language
+		if language:
+			target_language = language
 		else:
 			target_language = "python" # default
-	elif sccd.language and target_language != sccd.language:
-		raise CompilerException("Diagram specifies target language as \"" + sccd.language + "\", but language option of compiler has been set to \"" + target_language + "\". No output has been generated.")
+	elif language and target_language != language:
+		raise TargetLanguageException("Diagram specifies target language as \"" + language + "\", but language option of compiler has been set to \"" + target_language + "\". No output has been generated.")
 
 	if target_language == "python" and not output_file.endswith(".py") :
 		output_file += ".py"
 	elif target_language == "javascript" and not output_file.endswith(".js") :
 		output_file += ".js"
 
+	sccd = xmlToSccd(tree)
 	generic = sccdToGeneric(sccd, platform)
 	genericToTarget(generic, target_language, output_file)
 
-def xmlToSccd(xml_file):
-	cd = ClassDiagram(xml_file) # create AST
+def xmlToSccd(tree):
+	cd = ClassDiagram(tree) # create AST
 	cd.accept(SuperClassLinker())
 	# SuperClassLinker().visit(cd) # visitor linking super classs references
 	StateLinker().visit(cd) # visitor fixing state references

src/python_sccd/compiler/state_linker.py → src/sccd/compiler/state_linker.py


src/python_sccd/compiler/stateful_writer.py → src/sccd/compiler/stateful_writer.py


src/python_sccd/compiler/super_class_linker.py → src/sccd/compiler/super_class_linker.py


src/python_sccd/compiler/utils.py → src/sccd/compiler/utils.py


src/python_sccd/compiler/visitor.py → src/sccd/compiler/visitor.py


src/python_sccd/compiler/__init__.py → src/sccd/runtime/__init__.py


src/python_sccd/runtime/accurate_time.py → src/sccd/runtime/accurate_time.py


src/python_sccd/runtime/event_queue.py → src/sccd/runtime/event_queue.py


src/python_sccd/runtime/infinity.py → src/sccd/runtime/infinity.py


src/python_sccd/runtime/libs/__init__.py → src/sccd/runtime/libs/__init__.py


src/python_sccd/runtime/libs/drawing.py → src/sccd/runtime/libs/drawing.py


src/python_sccd/runtime/libs/ordered_set.py → src/sccd/runtime/libs/ordered_set.py


src/python_sccd/runtime/libs/ui.py → src/sccd/runtime/libs/ui.py


src/python_sccd/runtime/libs/utils.py → src/sccd/runtime/libs/utils.py


src/python_sccd/runtime/socket2event.py → src/sccd/runtime/socket2event.py


src/python_sccd/runtime/statecharts_core.py → src/sccd/runtime/statecharts_core.py


src/python_sccd/runtime/tkinter_eventloop.py → src/sccd/runtime/tkinter_eventloop.py


+ 1 - 1
src/setup.py

@@ -7,5 +7,5 @@ setup(name="sccd",
       author_email="Simon.VanMierlo@uantwerpen.be",
       url="http://msdl.cs.mcgill.ca/people/simonvm",
       packages=['sccd', 'sccd.runtime', 'sccd.runtime.libs', 'sccd.compiler'],
-      package_dir={'sccd': 'python_sccd', 'sccd.runtime': 'python_sccd/runtime', 'sccd.runtime.libs': 'python_sccd/runtime/libs', 'sccd.compiler': 'python_sccd/compiler'}
+      package_dir={'sccd': 'sccd', 'sccd.runtime': 'sccd/runtime', 'sccd.runtime.libs': 'sccd/runtime/libs', 'sccd.compiler': 'sccd/compiler'}
 )

+ 425 - 0
test/scxml/schemas/scxml-core-strict.xsd

@@ -0,0 +1,425 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://www.w3.org/2005/07/scxml"
+    xmlns="http://www.w3.org/2005/07/scxml"
+    elementFormDefault="qualified">
+	<xsd:annotation>
+		<xsd:documentation>
+        This is the XML Schema core module for SCXML
+        * scxml
+        * state 
+        * initial 
+        * onexit
+        * onentry 
+        * transition
+        * parallel
+        * final 
+        * history 
+        * donedata
+        * if
+        * elsif
+        * else
+        * foreach
+        * raise
+        * log
+        The core module defines these elements and the
+        attributes.
+        </xsd:documentation>
+		<xsd:documentation source="scxml-copyright.xsd"/>
+	</xsd:annotation>
+
+	<xsd:include schemaLocation="scxml-datatypes.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+            Includes common SCXML datatypes
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-attribs.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+            Includes common SCXML attributes
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-contentmodels.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+            This module defines Common content model extensions  for SCXML
+            </xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+	
+
+	<!-- scxml -->
+	<xsd:attributeGroup name="scxml.scxml.attlist">
+		<xsd:attribute name="initial" type="xsd:IDREFS"/>
+		<xsd:attribute name="name" type="xsd:NMTOKEN"/>
+		<xsd:attribute name="version" type="xsd:decimal" use="required" fixed="1.0"/>
+		<xsd:attribute name="datamodel" type="xsd:NMTOKEN" default="null" use="optional"/>
+		<xsd:attribute name="binding" type="Binding.datatype"/>
+		<xsd:attribute name="exmode" type="Exmode.datatype"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.scxml.mix">
+		<xsd:choice>
+			<xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="final" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="datamodel" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="script" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.scxml.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.scxml.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.scxml.type">
+		<xsd:group ref="scxml.scxml.content"/>
+		<xsd:attributeGroup ref="scxml.scxml.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="scxml" type="scxml.scxml.type"/>
+
+	<!-- state -->
+	<xsd:attributeGroup name="scxml.state.attlist">
+		<xsd:attribute name="id" type="xsd:ID"/>
+		<xsd:attribute name="initial" type="xsd:IDREFS"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.state.mix">
+		<xsd:choice>
+			<xsd:element ref="onentry" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="onexit" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="initial" minOccurs="0" maxOccurs="1"/>
+			<xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="final" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="history" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="datamodel" minOccurs="0" maxOccurs="1"/>
+			<xsd:element ref="invoke" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.state.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.state.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.state.type">
+		<xsd:sequence>
+			<xsd:group ref="scxml.state.content"/>
+		</xsd:sequence>
+		<xsd:attributeGroup ref="scxml.state.attlist"/>
+		<xsd:assert test="not(@initial and initial)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="if(@initial or initial) then (state | parallel) else true()" xpathDefaultNamespace="##targetNamespace"/>
+    <xsd:assert test="every $init in @initial satisfies (some $state in (.//state | .//parallel) satisfies ($state/@id = $init))" xpathDefaultNamespace="##targetNamespace"/> 
+    <xsd:assert test="if (initial) then (every $targ in initial/transition/@target satisfies (some $state in (.//state | .//parallel) satisfies ($state/@id = $targ))) else true()" xpathDefaultNamespace="##targetNamespace"/> 
+		<xsd:assert test="if(history/@type='shallow') then (every $targ in history/transition/@target satisfies 
+			(some $state in (state |parallel) satisfies ($state/@id = $targ)))
+			else if (history/@type='deep') then (every $targ in history/transition/@target satisfies 
+			(some $state in (.//state | .//parallel) satisfies ($state/@id = $targ)))
+			else true()" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="state" type="scxml.state.type"/>
+
+	<!-- initial -->
+	<xsd:attributeGroup name="scxml.initial.attlist">
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.initial.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="transition" minOccurs="1" maxOccurs="1"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.initial.type">
+		<xsd:group ref="scxml.initial.content"/>
+		<xsd:attributeGroup ref="scxml.initial.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="initial" type="scxml.initial.type"/>
+
+	<!-- onentry -->
+	<xsd:attributeGroup name="scxml.onentry.attlist">
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.onentry.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.onentry.type">
+		<xsd:group ref="scxml.onentry.content"/>
+		<xsd:attributeGroup ref="scxml.onentry.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="onentry" type="scxml.onentry.type"/>
+
+	<!-- onexit -->
+	<xsd:attributeGroup name="scxml.onexit.attlist">
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.onexit.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.onexit.type">
+		<xsd:group ref="scxml.onexit.content"/>
+		<xsd:attributeGroup ref="scxml.onexit.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="onexit" type="scxml.onexit.type"/>
+
+	<!-- transition -->
+	<xsd:attributeGroup name="scxml.transition.attlist">
+		<xsd:attribute name="event" type="EventTypes.datatype"/>
+		<xsd:attribute name="cond" type="CondLang.datatype"/>
+		<xsd:attribute name="target" type="xsd:IDREFS"/>
+		<xsd:attribute name="type" type="TransitionType.datatype"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.transition.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.transition.type">
+		<xsd:group ref="scxml.transition.content"/>
+		<xsd:attributeGroup ref="scxml.transition.attlist"/>
+		<xsd:assert test="(@event or @cond or @target)" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="transition" type="scxml.transition.type"/>
+
+	<!-- parallel -->
+	<xsd:attributeGroup name="scxml.parallel.attlist">
+		<xsd:attribute name="id" type="xsd:ID"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.parallel.mix">
+		<xsd:choice>
+			<xsd:element ref="onentry" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="onexit" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="history" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="datamodel" minOccurs="0" maxOccurs="1"/>
+			<xsd:element ref="invoke" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.parallel.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.parallel.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.parallel.type">
+		<xsd:group ref="scxml.parallel.content"/>
+		<xsd:attributeGroup ref="scxml.parallel.attlist"/>
+		<xsd:assert test="if(history/@type='shallow') then (every $targ in history/transition/@target satisfies 
+			(some $state in (state |parallel) satisfies ($state/@id = $targ)))
+			else if (history/@type='deep') then (every $targ in history/transition/@target satisfies 
+			(some $state in (.//state | .//parallel) satisfies ($state/@id = $targ)))
+			else true()" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="parallel" type="scxml.parallel.type"/>
+
+	<!-- final -->
+	<xsd:attributeGroup name="scxml.final.attlist">
+		<xsd:attribute name="id" type="xsd:ID"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.final.mix">
+		<xsd:choice>
+			<xsd:element ref="onentry" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="onexit" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="donedata" minOccurs="0" maxOccurs="1"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.final.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.final.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.final.type">
+		<xsd:group ref="scxml.final.content"/>
+		<xsd:attributeGroup ref="scxml.final.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="final" type="scxml.final.type"/>
+
+	<!-- history -->
+	<xsd:attributeGroup name="scxml.history.attlist">
+		<xsd:attribute name="id" type="xsd:ID"/>
+		<xsd:attribute name="type" type="HistoryType.datatype"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.history.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="transition" minOccurs="1" maxOccurs="1"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.history.type">
+		<xsd:group ref="scxml.history.content"/>
+		<xsd:attributeGroup ref="scxml.history.attlist"/>
+		<xsd:assert test="not(transition/@cond or transition/@event)" xpathDefaultNamespace="##targetNamespace"/>
+
+	</xsd:complexType>
+	<xsd:element name="history" type="scxml.history.type"/>
+
+	
+
+	<!-- donedata -->
+	<xsd:attributeGroup name="scxml.donedata.attlist">
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.donedata.content">
+		<xsd:sequence>
+			<xsd:choice>
+			<xsd:element ref="content" minOccurs="1" maxOccurs="1"/>
+			<xsd:element ref="param" minOccurs="1" maxOccurs="unbounded"/>
+			</xsd:choice>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+	 </xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.donedata.type">
+		<xsd:group ref="scxml.donedata.content"/>
+		<xsd:attributeGroup ref="scxml.donedata.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="donedata" type="scxml.donedata.type"/>
+	
+		<!-- if -->
+	<xsd:attributeGroup name="scxml.if.attlist">
+		<xsd:attribute name="cond" type="CondLang.datatype" use="required"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.if.elseif.mix">
+		<xsd:sequence>
+			<xsd:element ref="elseif" />
+			<xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:group name="scxml.if.else.mix">
+		<xsd:sequence>
+			<xsd:element ref="else" />
+			<xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:group name="scxml.if.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:group ref="scxml.if.elseif.mix" minOccurs="0" maxOccurs="1"/>
+			<xsd:group ref="scxml.if.else.mix" minOccurs="0" maxOccurs="1"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.if.type">
+		<xsd:group ref="scxml.if.content"/>
+		<xsd:attributeGroup ref="scxml.if.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="if" type="scxml.if.type"/>
+
+	<!-- elseif -->
+	<xsd:attributeGroup name="scxml.elseif.attlist">
+		<xsd:attribute name="cond" type="CondLang.datatype" use="required"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.elseif.mix">
+		<xsd:choice>
+			<!-- No content for this element -->
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.elseif.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.elseif.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.elseif.type">
+		<xsd:group ref="scxml.elseif.content"/>
+		<xsd:attributeGroup ref="scxml.elseif.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="elseif" type="scxml.elseif.type"/>
+
+	<!-- else -->
+	<xsd:attributeGroup name="scxml.else.attlist">
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.else.mix">
+		<xsd:choice>
+			<!-- No content for this element -->
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.else.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.else.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.else.type">
+		<xsd:group ref="scxml.else.content"/>
+		<xsd:attributeGroup ref="scxml.else.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="else" type="scxml.else.type"/>
+
+	<!-- foreach -->
+	<xsd:attributeGroup name="scxml.foreach.attlist">
+		<xsd:attribute name="array" type="ValueLang.datatype" use="required"/>
+		<xsd:attribute name="item" type="xsd:string" use="required"/>
+		<xsd:attribute name="index" type="xsd:string"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.foreach.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.foreach.type">
+		<xsd:group ref="scxml.foreach.content"/>
+		<xsd:attributeGroup ref="scxml.foreach.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="foreach" type="scxml.foreach.type"/>
+
+	<!-- raise -->
+	<xsd:attributeGroup name="scxml.raise.attlist">
+		<xsd:attribute name="event" type="xsd:NMTOKEN" use="required"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.raise.mix">
+		<xsd:choice>
+				<!-- No content for this element -->
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.raise.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.raise.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.raise.type">
+		<xsd:group ref="scxml.raise.content"/>
+		<xsd:attributeGroup ref="scxml.raise.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="raise" type="scxml.raise.type"/>
+
+	<!-- log -->
+	<xsd:attributeGroup name="scxml.log.attlist">
+		<xsd:attribute name="label" type="xsd:string"/>
+		<xsd:attribute name="expr" type="ValueLang.datatype"/>
+	 <xsd:attributeGroup ref="scxml.extra.attribs"/> 
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.log.content">
+		<xsd:sequence>
+		<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> 
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.log.type">
+		<xsd:group ref="scxml.log.content"/>
+		<xsd:attributeGroup ref="scxml.log.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="log" type="scxml.log.type"/>
+
+	
+</xsd:schema>

+ 157 - 0
test/scxml/schemas/scxml-data-strict.xsd

@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://www.w3.org/2005/07/scxml"
+    xmlns="http://www.w3.org/2005/07/scxml"
+    elementFormDefault="qualified">
+	<xsd:annotation>
+		<xsd:documentation>
+            This is the XML Schema data module for SCXML
+            * datamodel 
+            * data
+            * assign
+            * param
+            * script
+            * content
+            The data module defines these elements and their
+            attributes.
+        </xsd:documentation>
+		<xsd:documentation source="scxml-copyright.xsd"/>
+	</xsd:annotation>
+
+	<xsd:include schemaLocation="scxml-datatypes.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+                This module defines SCXML Attribute DataTypes
+            </xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-attribs.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+                This module defines Common attributes for SCXML
+            </xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-contentmodels.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+                This module defines Common content model extensions  for SCXML
+            </xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<!-- datamodel -->
+	<xsd:attributeGroup name="scxml.datamodel.attlist">	
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.datamodel.content">
+		<xsd:sequence>
+			<xsd:element ref="data" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.datamodel.type">
+		<xsd:group ref="scxml.datamodel.content"/>
+		<xsd:attributeGroup ref="scxml.datamodel.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="datamodel" type="scxml.datamodel.type"/>
+
+	<!-- data -->
+	<xsd:attributeGroup name="scxml.data.attlist">
+		<xsd:attribute name="id" type="xsd:ID" use="required"/>
+		<xsd:attribute name="src" type="URI.datatype"/>
+		<xsd:attribute name="expr" type="ValueLang.datatype"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.data.content">
+		<xsd:sequence>
+			<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.data.type" mixed="true">
+		<xsd:group ref="scxml.data.content"/>
+		<xsd:attributeGroup ref="scxml.data.attlist"/>
+		<xsd:assert test="not(@src and @expr)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="if(@src or @expr) then (not(text() | *)) else true()" xpathDefaultNamespace="##targetNamespace"/>
+			</xsd:complexType>
+	<xsd:element name="data" type="scxml.data.type"/>
+
+	
+
+	<!-- param -->
+	<xsd:attributeGroup name="scxml.param.attlist">
+		<xsd:attribute name="name" type="xsd:NMTOKEN" use="required"/>
+		<xsd:attribute name="expr" type="ValueLang.datatype"/>
+		<xsd:attribute name="location" type="LocLang.datatype"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.param.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.param.type">
+		<xsd:group ref="scxml.param.content"/>
+		<xsd:attributeGroup ref="scxml.param.attlist"/>
+		<xsd:assert test="(@expr or @location) and not(@expr and @location)" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="param" type="scxml.param.type"/>
+
+<!--  assign  -->
+	<xsd:attributeGroup name="scxml.assign.attlist">
+		<xsd:attribute name="location" type="LocLang.datatype" use="required"/>
+		<xsd:attribute name="expr" type="ValueLang.datatype"/>
+		<xsd:attribute name="type" type="AssignType.datatype" default="replacechildren"/>
+		<xsd:attribute name="attr" type="xsd:NMTOKEN"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.assign.content">
+		<xsd:sequence>
+			<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.assign.type" mixed="true">
+		<xsd:group ref="scxml.assign.content"/>
+		<xsd:attributeGroup ref="scxml.assign.attlist"/>
+	<xsd:assert test="(@expr or text() or *)" xpathDefaultNamespace="##targetNamespace"/>
+<xsd:assert test="not(@expr and (text() | *))" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="assign" type="scxml.assign.type"/>
+
+	
+<!-- script -->	
+	<xsd:attributeGroup name="scxml.script.attlist">
+		<xsd:attribute name="src" type="URI.datatype"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.script.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.script.type" mixed="true">
+		<xsd:group ref="scxml.script.content"/>
+		<xsd:attributeGroup ref="scxml.script.attlist"/>
+	</xsd:complexType>
+	<xsd:element name="script" type="scxml.script.type"/>
+
+	<!-- content -->
+	<xsd:attributeGroup name="scxml.content.attlist">
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+		<xsd:attribute name="expr" type="ValueLang.datatype"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.content.content">
+		<xsd:sequence>
+		<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.content.type" mixed="true">
+		<xsd:group ref="scxml.content.content"/>
+		<xsd:attributeGroup ref="scxml.content.attlist"/>
+		<xsd:assert test="not(@expr and (text() or *))" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="content" type="scxml.content.type"/>
+	
+</xsd:schema>

+ 168 - 0
test/scxml/schemas/scxml-external-strict.xsd

@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="http://www.w3.org/2005/07/scxml"
+	xmlns="http://www.w3.org/2005/07/scxml"
+	elementFormDefault="qualified">
+	<xsd:annotation>
+		<xsd:documentation>
+			This is the XML Schema external module for SCXML
+			* send 
+			* cancel
+			* invoke
+			* finalize 
+			The external module defines these elements and their
+			attributes.
+		</xsd:documentation>
+		<xsd:documentation source="scxml-copyright.xsd"/>
+	</xsd:annotation>
+
+	<xsd:include schemaLocation="scxml-datatypes.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+				This module defines SCXML Attribute DataTypes
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-attribs.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+				This module defines Common attributes for SCXML
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-contentmodels.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+				This module defines Common content model extensions  for SCXML
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<!-- send -->
+	<xsd:attributeGroup name="scxml.send.attlist">
+		<xsd:attribute name="event" type="EventType.datatype"/>
+		<xsd:attribute name="eventexpr" type="ValueLang.datatype"/>
+		<xsd:attribute name="target" type="URI.datatype"/>
+		<xsd:attribute name="targetexpr" type="ValueLang.datatype"/>
+		<xsd:attribute name="type" type="xsd:string" default="scxml"/>
+		<xsd:attribute name="typeexpr" type="ValueLang.datatype"/>
+		<xsd:attribute name="id" type="xsd:ID"/>
+		<xsd:attribute name="idlocation" type="LocLang.datatype"/>
+		<xsd:attribute name="delay" type="Duration.datatype" default="0s"/>
+		<xsd:attribute name="delayexpr" type="ValueLang.datatype"/>
+		<xsd:attribute name="namelist" type="xsd:string"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.send.mix">
+		<xsd:choice>
+			<xsd:element ref="content" minOccurs="0" maxOccurs="1"/>
+			<xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:choice>
+	</xsd:group>
+	<xsd:group name="scxml.send.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.send.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.send.type">
+		<xsd:group ref="scxml.send.content"/>
+		<xsd:attributeGroup ref="scxml.send.attlist"/>
+		<xsd:assert test="(@event or @eventexpr or content) and not(@expr and @eventexpr)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="not(@namelist and (param | content))" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="not(@target and @targetexpr)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="not(@id and @idlocation)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="not(@type and @typeexpr)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="not(@delay and @delayexpr)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test="if(@delay or @delayexpr) then (not(@target eq '_internal')) else true()" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="send" type="scxml.send.type"/>
+
+	<!-- cancel -->
+	<xsd:attributeGroup name="scxml.cancel.attlist">
+		<xsd:attribute name="sendid" type="xsd:IDREF"/>
+		<xsd:attribute name="sendidexpr" type="ValueLang.datatype"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.cancel.mix">
+		<xsd:sequence>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:group name="scxml.cancel.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.cancel.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.cancel.type">
+		<xsd:group ref="scxml.cancel.content"/>
+		<xsd:attributeGroup ref="scxml.cancel.attlist"/>
+		<xsd:assert test="(@sendid or @sendidexpr) and not(@sendid and @sendidexpr)" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="cancel" type="scxml.cancel.type"/>
+
+
+
+	<!-- invoke -->
+	<xsd:attributeGroup name="scxml.invoke.attlist">
+		<xsd:attribute name="type" type="xsd:string" default="scxml"/>
+		<xsd:attribute name="typeexpr" type="ValueLang.datatype"/>
+		<xsd:attribute name="src" type="URI.datatype"/>
+		<xsd:attribute name="srcexpr" type="ValueLang.datatype"/>
+		<xsd:attribute name="id" type="xsd:ID"/>
+		<xsd:attribute name="idlocation" type="LocLang.datatype"/>
+		<xsd:attribute name="namelist" type="xsd:string"/>
+		<xsd:attribute name="autoforward" type="Boolean.datatype" use="optional" default="false"/>
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.invoke.mix">
+		<xsd:sequence>
+			<xsd:element ref="content" minOccurs="0" maxOccurs="1"/>
+			<xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
+			<xsd:element ref="finalize" minOccurs="0" maxOccurs="1"/>
+			<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:group name="scxml.invoke.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.invoke.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.invoke.type">
+		<xsd:group ref="scxml.invoke.content"/>
+		<xsd:attributeGroup ref="scxml.invoke.attlist"/>
+		<xsd:assert test=" not(@type and @typeexpr)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test=" not(@src and @srcexpr)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test=" not((@src or @srcexpr) and (content | param))" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test=" not(@id and @idlocation)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test=" not(@namelist and param)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test=" not(param and content)" xpathDefaultNamespace="##targetNamespace"/>
+		<xsd:assert test=" not(content[2])" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="invoke" type="scxml.invoke.type"/>
+
+	<!-- finalize -->
+	<xsd:attributeGroup name="scxml.finalize.attlist">
+		<xsd:attributeGroup ref="scxml.extra.attribs"/>
+	</xsd:attributeGroup>
+	<xsd:group name="scxml.finalize.mix">
+		<xsd:sequence>
+			<xsd:group ref="scxml.core.executablecontent"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:group name="scxml.finalize.content">
+		<xsd:sequence>
+			<xsd:group ref="scxml.finalize.mix" minOccurs="0" maxOccurs="unbounded"/>
+		</xsd:sequence>
+	</xsd:group>
+	<xsd:complexType name="scxml.finalize.type">
+		<xsd:group ref="scxml.finalize.content"/>
+		<xsd:attributeGroup ref="scxml.finalize.attlist"/>
+		<xsd:assert test=" not(send | raise)" xpathDefaultNamespace="##targetNamespace"/>
+	</xsd:complexType>
+	<xsd:element name="finalize" type="scxml.finalize.type"/>
+
+
+</xsd:schema>

+ 88 - 0
test/scxml/schemas/scxml-strict.xsd

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="http://www.w3.org/2005/07/scxml"
+	xmlns="http://www.w3.org/2005/07/scxml"
+	elementFormDefault="qualified">
+
+	<xsd:annotation>
+		<xsd:documentation>
+			This is the XML Schema driver for SCXML 1.0.
+			Please use this namespace for SCXML 1.0 elements:
+
+			"http://www.w3.org/2005/07/scxml"
+
+		</xsd:documentation>
+		<xsd:documentation source="scxml-copyright.xsd"/>
+	</xsd:annotation>
+	<xsd:annotation>
+		<xsd:documentation>
+			This is the XML Schema driver file for SCXML 1.0.
+
+			This schema:
+			+ sets the namespace for SCXML 1.0
+			+ imports external schemas (xml.xsd)
+			+ imports SCXML common datatypes, attributes and content models
+			+ imports modular schemas
+
+			SCXML 1.0 includes:
+			+ SCXML core constructs
+			+ SCXML executable content
+			+ SCXML data model and manipulation
+			+ SCXML external communications
+
+			This schema is permissive such that it accomodates all
+			datamodels, but validating documents may contain markup that
+			is ignored in certain datamodels.
+		</xsd:documentation>
+	</xsd:annotation>
+
+	<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+				This import brings in the XML namespace attributes
+				The XML attributes are used by various modules.
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:import>
+
+	<xsd:include schemaLocation="scxml-core-strict.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+				This imports the core elements for SCXML.
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-data-strict.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+				This imports the data modelelements for SCXML.
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+	<xsd:include schemaLocation="scxml-external-strict.xsd">
+		<xsd:annotation>
+			<xsd:documentation>
+				This imports the external communications elements for SCXML. 
+			</xsd:documentation>
+		</xsd:annotation>
+	</xsd:include>
+
+<!-- the various elements of executable content are defined in the relevant modules. 
+This gathers them up into a single type -->
+<xsd:group name="scxml.core.executablecontent">
+	<xsd:choice>
+		<xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> 
+		<xsd:element ref="raise"/> 
+		<xsd:element ref="if"/> 
+		<xsd:element ref="foreach"/> 
+		<xsd:element ref="send"/>
+		<xsd:element ref="script"/>
+		<xsd:element ref="assign"/> 
+		<xsd:element ref="log"/>
+		<xsd:element ref="cancel"/>
+	</xsd:choice>
+</xsd:group>
+
+</xsd:schema>

test/scxml_test_suite/test144.txml → test/scxml/tests/test144.txml


test/scxml_test_suite/test147.txml → test/scxml/tests/test147.txml


test/scxml_test_suite/test148.txml → test/scxml/tests/test148.txml


test/scxml_test_suite/test149.txml → test/scxml/tests/test149.txml


test/scxml_test_suite/test150.txml → test/scxml/tests/test150.txml


test/scxml_test_suite/test151.txml → test/scxml/tests/test151.txml


test/scxml_test_suite/test152.txml → test/scxml/tests/test152.txml


test/scxml_test_suite/test153.txml → test/scxml/tests/test153.txml


test/scxml_test_suite/test155.txml → test/scxml/tests/test155.txml


test/scxml_test_suite/test156.txml → test/scxml/tests/test156.txml


test/scxml_test_suite/test158.txml → test/scxml/tests/test158.txml


test/scxml_test_suite/test159.txml → test/scxml/tests/test159.txml


test/scxml_test_suite/test172.txml → test/scxml/tests/test172.txml


test/scxml_test_suite/test173.txml → test/scxml/tests/test173.txml


test/scxml_test_suite/test174.txml → test/scxml/tests/test174.txml


test/scxml_test_suite/test175.txml → test/scxml/tests/test175.txml


test/scxml_test_suite/test176.txml → test/scxml/tests/test176.txml


test/scxml_test_suite/test178.txml → test/scxml/tests/test178.txml


test/scxml_test_suite/test179.txml → test/scxml/tests/test179.txml


test/scxml_test_suite/test183.txml → test/scxml/tests/test183.txml


test/scxml_test_suite/test185.txml → test/scxml/tests/test185.txml


test/scxml_test_suite/test186.txml → test/scxml/tests/test186.txml


test/scxml_test_suite/test187.txml → test/scxml/tests/test187.txml


test/scxml_test_suite/test189.txml → test/scxml/tests/test189.txml


test/scxml_test_suite/test190.txml → test/scxml/tests/test190.txml


test/scxml_test_suite/test191.txml → test/scxml/tests/test191.txml


test/scxml_test_suite/test192.txml → test/scxml/tests/test192.txml


test/scxml_test_suite/test193.txml → test/scxml/tests/test193.txml


test/scxml_test_suite/test194.txml → test/scxml/tests/test194.txml


test/scxml_test_suite/test198.txml → test/scxml/tests/test198.txml


test/scxml_test_suite/test199.txml → test/scxml/tests/test199.txml


test/scxml_test_suite/test200.txml → test/scxml/tests/test200.txml


test/scxml_test_suite/test201.txml → test/scxml/tests/test201.txml


test/scxml_test_suite/test205.txml → test/scxml/tests/test205.txml


test/scxml_test_suite/test207.txml → test/scxml/tests/test207.txml


test/scxml_test_suite/test208.txml → test/scxml/tests/test208.txml


test/scxml_test_suite/test210.txml → test/scxml/tests/test210.txml


test/scxml_test_suite/test215.txml → test/scxml/tests/test215.txml


test/scxml_test_suite/test216.txml → test/scxml/tests/test216.txml


test/scxml_test_suite/test220.txml → test/scxml/tests/test220.txml


test/scxml_test_suite/test223.txml → test/scxml/tests/test223.txml


test/scxml_test_suite/test224.txml → test/scxml/tests/test224.txml


test/scxml_test_suite/test225.txml → test/scxml/tests/test225.txml


test/scxml_test_suite/test226.txml → test/scxml/tests/test226.txml


test/scxml_test_suite/test228.txml → test/scxml/tests/test228.txml


test/scxml_test_suite/test229.txml → test/scxml/tests/test229.txml


test/scxml_test_suite/test230.txml → test/scxml/tests/test230.txml


test/scxml_test_suite/test232.txml → test/scxml/tests/test232.txml


test/scxml_test_suite/test233.txml → test/scxml/tests/test233.txml


test/scxml_test_suite/test234.txml → test/scxml/tests/test234.txml


test/scxml_test_suite/test235.txml → test/scxml/tests/test235.txml


test/scxml_test_suite/test236.txml → test/scxml/tests/test236.txml


test/scxml_test_suite/test237.txml → test/scxml/tests/test237.txml


test/scxml_test_suite/test239.txml → test/scxml/tests/test239.txml


+ 0 - 0
test/scxml_test_suite/test240.txml


部分文件因为文件数量过多而无法显示