diff --git a/Parser.java b/Parser.java index 0f7c6f9092bb1dab06ef3b2f24571636368c234c..c13cfd49b95209d931970a9670f7f175599fb746 100644 --- a/Parser.java +++ b/Parser.java @@ -15,32 +15,32 @@ import AST.ParseException; import AST.Start; public class Parser { - - protected static Start parse(String args[]) { - Reader r = getReader(args); - Start ast = null; - try { - SchemaParser parser = new SchemaParser(r); - - ast = parser.Start(); - } catch (ParseException e) { - System.out.println(e.getMessage()); - } - return ast; + + protected static Start parse(String args[]) { + Reader r = getReader(args); + Start ast = null; + try { + SchemaParser parser = new SchemaParser(r); + + ast = parser.Start(); + } catch (ParseException e) { + System.out.println(e.getMessage()); } - - private static Reader getReader(String[] args) { - Reader r = null; - if (args.length != 1) { - r = new InputStreamReader(System.in); - } else { - try { - r = new FileReader(args[0]); - } catch (FileNotFoundException e1) { - System.err.println("Dumper: file " + args[0] + " not found"); - } - } - return r; + return ast; + } + + private static Reader getReader(String[] args) { + Reader r = null; + if (args.length != 1) { + r = new InputStreamReader(System.in); + } else { + try { + r = new FileReader(args[0]); + } catch (FileNotFoundException e1) { + System.err.println("Dumper: file " + args[0] + " not found"); + } } + return r; + } } diff --git a/build.xml b/build.xml index 8cc048bc34bf1aceea555f3a836fb6b4ead5e9e8..fa76eeff33e18382cfeddb2462be29c9c07cbc85 100644 --- a/build.xml +++ b/build.xml @@ -27,7 +27,7 @@ <!-- compile sources --> <target name="build" depends="gen"> - <javac compiler="jikes" debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="tools/** examples/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/> + <javac debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="tools/** examples/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/> </target> <!-- generate compiler source files --> diff --git a/examples/scxml.xsd b/examples/scxml.xsd new file mode 100644 index 0000000000000000000000000000000000000000..f398102f7b28b70fb4293fed0bda8423de7d5097 --- /dev/null +++ b/examples/scxml.xsd @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2005/SCXML" xmlns:scxml="http://www.w3.org/2005/SCXML"> + <!-- Here is our top level rule --> + <xs:element name="scxml"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:state"/> + </xs:sequence> + <xs:attribute name="version" use="required"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="1.0"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="initialstate" type="xs:IDREF"/> + </xs:complexType> + </xs:element> + <xs:element name="state"> + <xs:complexType> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="scxml:initial"/> + <xs:element ref="scxml:onentry"/> + <xs:element ref="scxml:onexit"/> + <xs:element ref="scxml:transition"/> + <xs:element ref="scxml:state"/> + <xs:element ref="scxml:parallel"/> + <xs:element ref="scxml:history"/> + <xs:element ref="scxml:sync"/> + <xs:element ref="scxml:join"/> + </xs:choice> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="final" default="false" type="xs:boolean"/> + <xs:attribute name="src" type="xs:anyURI"/> + </xs:complexType> + </xs:element> + <xs:element name="parallel"> + <xs:complexType> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="scxml:onentry"/> + <xs:element ref="scxml:onexit"/> + <xs:element ref="scxml:state"/> + <xs:element ref="scxml:sync"/> + <xs:element ref="scxml:join"/> + </xs:choice> + <xs:attribute name="id" type="xs:ID"/> + </xs:complexType> + </xs:element> + <xs:element name="initial"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:transition"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="src" type="xs:anyURI"/> + </xs:complexType> + </xs:element> + <xs:element name="history"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:transition"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="type" default="shallow"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="shallow"/> + <xs:enumeration value="deep"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="src" type="xs:anyURI"/> + </xs:complexType> + </xs:element> + <xs:element name="join"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:transition"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + </xs:complexType> + </xs:element> + <xs:element name="sync"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:transition"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="bound" default="0" type="xs:integer"/> + </xs:complexType> + </xs:element> + <xs:element name="transition"> + <xs:complexType> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:choice> + <xs:element ref="scxml:target"/> + <xs:element ref="scxml:exit"/> + </xs:choice> + <xs:choice> + <xs:element ref="scxml:assign"/> + <xs:element ref="scxml:var"/> + <xs:element ref="scxml:log"/> + <xs:element ref="scxml:send"/> + <xs:element ref="scxml:if"/> + <xs:group ref="scxml:anyOtherNSElement"/> + </xs:choice> + </xs:choice> + <xs:attribute name="event"/> + <xs:attribute name="cond"/> + <xs:attribute name="name"/> + </xs:complexType> + </xs:element> + <xs:element name="target"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" ref="scxml:state"/> + </xs:sequence> + <xs:attribute name="next" type="xs:IDREF"/> + <xs:attribute name="cond"/> + </xs:complexType> + </xs:element> + <xs:element name="onentry"> + <xs:complexType> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="scxml:ExecutableContent"/> + </xs:complexType> + </xs:element> + <xs:element name="onexit"> + <xs:complexType> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="scxml:ExecutableContent"/> + </xs:complexType> + </xs:element> + <xs:element name="log"> + <xs:complexType> + <xs:attribute name="expr"/> + <xs:attribute name="label"/> + </xs:complexType> + </xs:element> + <xs:element name="if"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:elseif"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:else"/> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="scxml:ExecutableContent"/> + </xs:sequence> + <xs:attribute name="cond"/> + </xs:complexType> + </xs:element> + <xs:element name="elseif"> + <xs:complexType> + <xs:attribute name="cond"/> + </xs:complexType> + </xs:element> + <xs:element name="else"> + <xs:complexType/> + </xs:element> + <xs:element name="assign"> + <xs:complexType> + <xs:attribute name="expr" use="required"/> + <xs:attribute name="name" use="required"/> + </xs:complexType> + </xs:element> + <xs:element name="var"> + <xs:complexType> + <xs:attribute name="expr"/> + <xs:attribute name="name" use="required"/> + </xs:complexType> + </xs:element> + <xs:element name="exit"> + <xs:complexType> + <xs:attribute name="expr"/> + <xs:attribute name="namelist"/> + </xs:complexType> + </xs:element> + <xs:element name="send"> + <xs:complexType> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="scxml:anyOtherNSElement"/> + <xs:attribute name="target"/> + <xs:attribute name="targettype" default="scxml"/> + <xs:attribute name="sendid"/> + <xs:attribute name="delay" default="'0s'"/> + <xs:attribute name="event"/> + <xs:attribute name="hints"/> + <xs:attribute name="namelist"/> + </xs:complexType> + </xs:element> + <xs:group name="anyOtherNSElement"> + <xs:choice> + <xs:any namespace="##other" processContents="skip"/> + <xs:any namespace="##local" processContents="skip"/> + </xs:choice> + </xs:group> + <xs:group name="ExecutableContent"> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:assign"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:var"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:log"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:send"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="scxml:if"/> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="scxml:anyOtherNSElement"/> + </xs:sequence> + </xs:group> +</xs:schema>