diff --git a/.bzrignore b/.bzrignore index 1227e82ec94c64ea756f784d468e09729d49d86c..9b23f913cd3a2cae9a85ca0a043292b8486e834b 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,3 +1,7 @@ AST *.class semantic.cache +x3d/GeneratedAspects.jrag +x3d/Parser.java +x3d/x3d.ast +x3d/x3d.jjt diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag new file mode 100644 index 0000000000000000000000000000000000000000..ec60320fafa02226179f5707f9834286dfb49306 --- /dev/null +++ b/CompilerGeneration.jrag @@ -0,0 +1,354 @@ +/* -*-Java-*- */ + +/* + * Copyright (C) 2007 Anders Nilsson <anders.nilsson@cs.lth.se> + * + * This file is part of XmlSchemaCompiler. + */ + +import java.io.*; +import java.util.*; + +aspect AbsGrammarGeneration { + void ASTNode.genAbsGrammar(PrintStream pStream) { + for (int i=0; i<getNumChild(); i++) { + getChild(i).genAbsGrammar(pStream); + } + } + + public void Start.genAbsGrammar(PrintStream pStream) { + pStream.println("// Predefined types"); + pStream.println("Start ::= Element*;"); + pStream.println("abstract Thing : ComplexElement ::=;"); + pStream.println("abstract Element;"); + pStream.println("ComplexElement : Element ::= OwlIdentifier Attribute* Element*;"); + pStream.println("ValueElement : ComplexElement;"); + pStream.println("abstract SimpleElement : Element;"); + pStream.println("StringElement : SimpleElement ::= <IDENTIFIER>;"); + pStream.println("IntElement : SimpleElement ::= <INTEGER_LITERAL>;"); + pStream.println("FloatElement : SimpleElement ::= <FLOAT_LITERAL>;"); + pStream.println("ClassUse : Thing ::= /decl:Thing/;"); + pStream.println("Attribute ::= Value;"); + pStream.println("RdfDatatype : Attribute ::= ;"); + pStream.println("RdfId : Attribute ::= ;"); + pStream.println("Xmlns : Attribute ::= ;"); + pStream.println("XmlnsProtege : Attribute ::= ;"); + pStream.println("XmlnsRdf : Attribute ::= ;"); + pStream.println("XmlnsXsd : Attribute ::= ;"); + pStream.println("XmlnsRdfs : Attribute ::= ;"); + pStream.println("XmlnsOwl : Attribute ::= ;"); + pStream.println("XmlnsDaml : Attribute ::= ;"); + pStream.println("XmlnsP1 : Attribute ::= ;"); + pStream.println("XmlnsDc : Attribute ::= ;"); + pStream.println("XmlBase : Attribute ::= ;"); + pStream.println("RdfResource : Attribute ::= ;"); + pStream.println("RdfAbout : Attribute ::= ;"); + pStream.println("RdfParseType : Attribute ::= ;"); + pStream.println("Version : Attribute ::= ;"); + pStream.println("Value ::= <STRING_LITERAL>;"); + pStream.println("OwlIdentifier ::= <IDENTIFIER>;"); + pStream.println("AttrValue ::= <STRING_LITERAL>;"); + pStream.println(); + pStream.println("// Generated types"); + super.genAbsGrammar(pStream); + } + + +} + +aspect GenJavaCC { + void ASTNode.genJavaCC(PrintStream pStream) { + for (int i=0; i<getNumChild(); i++) { + getChild(i).genJavaCC(pStream); + } + } + + public void Start.genJavaCC(PrintStream pStream) { + + } +} + +// aspect GenAspects { +// public void Start.genAspects(PrintStream pStream) { +// pStream.println(); +// pStream.println("import java.io.PrintStream;"); +// pStream.println(); +// genRewrites(pStream); +// genMisc(pStream); +// genPrettyPrinter(pStream); +// } +// } + +// aspect GenPrettyPrinter { +// public void ASTNode.genPrettyPrinter(PrintStream pStream) { +// for (int i=0; i<getNumChild(); i++) { +// getChild(i).genPrettyPrinter(pStream); +// } +// } + +// public void Start.genPrettyPrinter(PrintStream pStream) { +// pStream.println(); +// pStream.println("aspect PrettyPrinter {"); +// pStream.println(" public void ASTNode.prettyPrint(String indent, PrintStream pStream) {"); +// pStream.println(" for (int i=0; i<getNumChild(); i++) {"); +// pStream.println(" getChild(i).prettyPrint(indent,pStream);"); +// pStream.println(" }"); +// pStream.println(" }\n"); +// pStream.println(" public void Start.prettyPrint(String indent, PrintStream pStream) {"); +// pStream.println(" for (int i=0; i<getNumElement(); i++) {"); +// pStream.println(" getElement(i).prettyPrint(indent,pStream);"); +// pStream.println(" }"); +// pStream.println(" }\n"); +// pStream.println(" syn String Attribute.id() = \"\";"); +// pStream.println(" eq RdfId.id() = \"Rdf:ID\";"); +// pStream.println(" eq RdfDatatype.id() = \"Rdf:datatype\";"); +// pStream.println(" eq RdfResource.id() = \"Rdf:resource\";"); +// pStream.println(" public void Attribute.prettyPrint(String indent, PrintStream pStream) {"); +// pStream.println(" System.out.print(\" \"+id()+\"=\"+getValue().getSTRING_LITERAL());"); +// pStream.println(" }\n"); +// pStream.println(ind(1)+"public void ValueElement.prettyPrint(String indent, PrintStream pStream) {"); +// pStream.println(ind(2)+"System.out.print(indent+\"<value \");"); +// pStream.println(ind(2)+"for (int i=0; i<getNumAttribute(); i++) {"); +// pStream.println(ind(3)+"getAttribute(i).prettyPrint(indent,pStream);"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(2)+"System.out.println(\">\");"); +// pStream.println(ind(2)+"System.out.println(indent+\" \"+value());"); +// pStream.println(ind(2)+"System.out.println(indent+\"</value>\");"); +// pStream.println(ind(1)+"}\n"); +// // Generate prettyprinter for ClassUse +// pStream.println(ind(1)+"public void ClassUse.prettyPrint(String indent, PrintStream pStream) {"); +// pStream.println(ind(2)+"System.out.print(indent+\"<\"+name());"); +// pStream.println(ind(2)+"for (int i=0; i<getNumAttribute(); i++) {"); +// pStream.println(ind(3)+"getAttribute(i).prettyPrint(indent,pStream);"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(2)+"System.out.println(\"/>\");"); +// pStream.println(ind(1)+"}\n"); +// super.genPrettyPrinter(pStream); +// pStream.println("}\n"); +// } + +// public void OwlClassDecl.genPrettyPrinter(PrintStream pStream) { +// // Generate prettyprinter for class declaration +// pStream.print(ind(1)+"public void "+name()); +// pStream.println(".prettyPrint(String indent, PrintStream pStream) {"); +// pStream.println(ind(2)+"System.out.print(indent+\"<"+name()+"\");"); +// pStream.println(ind(2)+"for (int i=0; i<getNumAttribute(); i++) {"); +// pStream.println(ind(3)+"getAttribute(i).prettyPrint(indent,pStream);"); +// pStream.println(ind(2)+"}"); +// pStream.println("System.out.println(\">\");"); +// pStream.println(ind(2)+"String childIndent = indent + \" \";"); +// // Restrictions restr = getRestrictions(); +// // for (int i=0; i<restr.getNumOwlRestriction(); i++) { +// // OwlRestriction r = restr.getOwlRestriction(i); +// // pStream.println(ind(2)+"System.out.println(childIndent+\"<has"+ +// // r.name()+">\");"); +// // pStream.println(ind(2)+"for (int i=0; i<getNum"+r.name()+"(); i++) {"); +// // pStream.println(ind(3)+"get"+r.name()+ +// // "(i).prettyPrint(childIndent+\" \",pStream);"); +// // pStream.println(ind(2)+"}"); +// // pStream.println(ind(2)+"System.out.println(childIndent+\"</has"+ +// // r.name()+">\");"); +// // } +// pStream.println(ind(2)+"for (int i=0; i<getNumElement(); i++) {"); +// pStream.println(ind(3)+"getElement(i).prettyPrint(childIndent,pStream);"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(1)+"System.out.println(indent+\"</"+name()+">\");"); +// pStream.println(ind(1)+"}\n"); +// } +// } + +// aspect GenRewrites { + +// public void ASTNode.genRewrites(PrintStream pStream) { +// for (int i=0; i<getNumChild(); i++) { +// getChild(i).genRewrites(pStream); +// } +// } + +// public void Start.genRewrites(PrintStream pStream) { +// pStream.println(); +// pStream.println("aspect Rewrites {"); +// pStream.println(ind(1)+"rewrite ComplexElement {"); +// pStream.println(ind(2)+"when (!(this instanceof ClassUse) && getOwlIdentifier().getIDENTIFIER().equals(\"value\") && !(this instanceof ValueElement))"); +// pStream.println(ind(3)+"to ValueElement {"); +// pStream.println(ind(3)+"ValueElement node = new ValueElement();"); +// pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());"); +// pStream.println(ind(3)+"node.setAttributeList(getAttributeList());"); +// pStream.println(ind(3)+"node.setElementList(getElementList());"); +// pStream.println(ind(3)+"return node;"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(1)+"}"); + +// // TEMPORARY!!!!! +// // Rewrite isSkillOf/hasSkill/hasProperty/isPropertyOf to ClassUse +// pStream.println(ind(1)+"rewrite ComplexElement {"); +// pStream.println(ind(2)+"when ((name().equals(\"hasSkill\")"); +// pStream.println(ind(2)+"|| name().equals(\"isSkillOf\"))"); +// pStream.println("&& getNumAttribute() > 0 && getAttribute(0) instanceof RdfResource)"); +// pStream.println(ind(2)+"to ClassUse {"); +// pStream.println(ind(3)+"ClassUse use = new ClassUse();"); +// pStream.println(ind(3)+"String att = getAttribute(0).name();"); +// pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(att.substring(att.indexOf('#')+1,att.indexOf('_'))));"); +// pStream.println(ind(3)+"use.setAttributeList(getAttributeList());"); +// pStream.println(ind(3)+"use.setElementList(new List());"); +// pStream.println(ind(3)+"return use;"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(1)+"}"); + + +// super.genRewrites(pStream); +// pStream.println("}"); +// } + +// public void OwlClassDecl.genRewrites(PrintStream pStream) { +// String ind = " "; +// int ix = 0; +// // Specialize ComplexElements to the actual class in the ontology +// pStream.println(ind(1)+"rewrite ComplexElement {"); +// pStream.println(ind(2)+"when (!(this instanceof ClassUse) && getOwlIdentifier().getIDENTIFIER().equals(\""+ +// name()+"\") && !(this instanceof Thing))"); +// pStream.println(ind(3)+"to "+name()+" {"); + +// pStream.println(ind(3)+name()+" node = new "+name()+"();"); +// pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());"); +// pStream.println(ind(3)+"node.setAttributeList(getAttributeList());"); +// pStream.println(ind(3)+"node.setElementList(getElementList());"); +// // Restrictions restr = getRestrictions(); +// // pStream.println(ind(3)+"List l, remain;"); +// // pStream.println(ind(3)+"remain = new List();"); +// // for (int i=0; i<restr.getNumOwlRestriction(); i++) { +// // OwlRestriction r = restr.getOwlRestriction(i); +// // pStream.println(ind(3)+"l = new List();"); +// // pStream.println(ind(3)+"for (int i=0; i<getNumElement(); i++) {"); +// // pStream.println(ind(4)+"ComplexElement e = (ComplexElement) getElement(i);"); +// // pStream.println(ind(4)+"if (e.getNumElement() > 0 && e.getElement(0) instanceof "+r.name()+" ) {"); +// // pStream.println(ind(5)+"l.add(e.getElement(0));"); +// // pStream.println(ind(4)+"}"); +// // pStream.println(ind(3)+"}"); +// // if (r.allValuesFrom()) { +// // pStream.println(ind(3)+"node.set"+r.name()+"List(l);"); +// // } else { +// // pStream.println(ind(3)+r.name()+" c"+ix+" = new "+r.name()+"();"); +// // pStream.println(ind(3)+"node.set"+r.name()+"(c"+(ix++)+");"); +// // } +// // } +// // pStream.println(ind(3)+"for (int i=0; i<getNumElement(); i++) {"); +// // pStream.println(ind(4)+"if (getElement(i) instanceof ValueElement) {"); +// // pStream.println(ind(5)+"remain.add(getElement(i));"); +// // pStream.println(ind(4)+"}"); +// // pStream.println(ind(3)+"}"); +// // pStream.println(ind(3)+"node.setElementList(remain);"); +// pStream.println(ind(3)+"return node;"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(1)+"}"); +// pStream.println(); +// // Rearrange device nodes on the AST to get away from the +// // current diagonal style from Protege +// pStream.println(ind(1)+"rewrite "+name()+" {"); +// pStream.println(ind(2)+"when (!isTopElement())"); +// pStream.println(ind(2)+"to ClassUse {"); +// pStream.println(ind(3)+"ClassUse use = new ClassUse();"); +// pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));"); +// pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(getAttribute(0).getValue())));"); +// pStream.println(ind(3)+"use.setElementList(new List());"); +// pStream.println(ind(3)+"getStart().addElement(this);"); +// pStream.println(ind(3)+"return use;"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(1)+"}"); +// } + +// } + +// aspect GenMisc { + +// public void ASTNode.genMisc(PrintStream pStream) { +// for (int i=0; i<getNumChild(); i++) { +// getChild(i).genMisc(pStream); +// } +// } + +// public void Start.genMisc(PrintStream pStream) { +// pStream.println(); +// pStream.println("aspect Misc {"); +// pStream.println(); +// pStream.println(ind(1)+"String ValueElement.value() {"); +// pStream.println(ind(2)+"StringBuffer b = new StringBuffer();"); +// pStream.println(ind(2)+"for (int i=0; i<getNumElement(); i++) {"); +// pStream.println(ind(3)+"b.append(((SimpleElement) getElement(i)).value());"); +// pStream.println(ind(3)+"b.append(\" \");"); +// pStream.println(ind(2)+"}"); +// pStream.println(ind(2)+"return b.toString().trim();"); +// pStream.println(ind(1)+"}"); +// pStream.println(); +// pStream.println(ind(1)+"syn String SimpleElement.value() = \"\";"); +// pStream.println(ind(1)+"eq StringElement.value() = getIDENTIFIER();"); +// pStream.println(ind(1)+"eq IntElement.value() = getINTEGER_LITERAL();"); +// pStream.println(ind(1)+"eq FloatElement.value() = getFLOAT_LITERAL();"); + +// pStream.println(ind(1)+"boolean Thing.isTopElement() {"); +// pStream.println(ind(2)+"return getParent().getParent() instanceof Start;"); +// pStream.println(ind(1)+"}"); + +// pStream.println(ind(1)+"Start ASTNode.getStart() {"); +// pStream.println(ind(2)+"return getParent().getStart();"); +// pStream.println(ind(1)+"}"); +// pStream.println(ind(1)+"Start Start.getStart() {"); +// pStream.println(ind(2)+"return this;"); +// pStream.println(ind(1)+"}"); + +// pStream.println(ind(1)+"String ComplexElement.name() {"); +// pStream.println(ind(2)+"return getOwlIdentifier().getIDENTIFIER();"); +// pStream.println(ind(1)+"}"); +// pStream.println(ind(1)+"String Attribute.name() {"); +// pStream.println(ind(2)+"return getValue().getSTRING_LITERAL();"); +// pStream.println(ind(1)+"}"); + + +// super.genMisc(pStream); +// pStream.println("}"); +// } + +// } + +aspect ParserGen { + public void Start.genParser(PrintStream pStream) { + pStream.println("import java.io.FileNotFoundException;"); + pStream.println("import java.io.FileReader;"); + pStream.println("import java.io.InputStreamReader;"); + pStream.println("import java.io.Reader;"); + pStream.println(""); + pStream.println("import AST.X3dParser;"); + pStream.println("import AST.ParseException;"); + pStream.println("import AST.Start;"); + pStream.println(""); + pStream.println("public class Parser {"); + pStream.println(); + pStream.println(" protected static Start parse(String args[]) {"); + pStream.println(" Reader r = getReader(args);"); + pStream.println(" Start ast = null;"); + pStream.println(" try {"); + pStream.println(" SiarasParser parser = new SiarasParser(r);"); + pStream.println(); + pStream.println(" ast = parser.Start();"); + pStream.println(" } catch (ParseException e) {"); + pStream.println(" System.out.println(e.getMessage());"); + pStream.println(" }"); + pStream.println(" return ast;"); + pStream.println(" }"); + pStream.println(); + pStream.println(" private static Reader getReader(String[] args) {"); + pStream.println(" Reader r = null;"); + pStream.println(" if (args.length != 1) {"); + pStream.println(" r = new InputStreamReader(System.in);"); + pStream.println(" } else {"); + pStream.println(" try {"); + pStream.println(" r = new FileReader(args[0]);"); + pStream.println(" } catch (FileNotFoundException e1) {"); + pStream.println(" System.err.println(\"Dumper: file \" + args[0] + \" not found\");"); + pStream.println(" }"); + pStream.println(" }"); + pStream.println(" return r;"); + pStream.println(" }"); + pStream.println("}"); + } +} diff --git a/GenCompiler.java b/GenCompiler.java index 2a0b43d87aa89be747a7e2adb6452b7a5e6a08c0..784ab5f774567ae079e532b94686cf1ecb6fffcc 100644 --- a/GenCompiler.java +++ b/GenCompiler.java @@ -1,9 +1,9 @@ // package programs; /* - * Copyright (C) 2006 Anders Nilsson <anders.nilsson@cs.lth.se> + * Copyright (C) 2007 Anders Nilsson <anders.nilsson@cs.lth.se> * - * This file is part of OntologyCompiler. + * This file is part of XmlSchemaCompiler. */ import AST.Start; @@ -14,31 +14,36 @@ public class GenCompiler extends Parser { public static void main(String args[]) { Start ast = parse(args); -// File siarasDir = new File("siaras"); -// if (!siarasDir.isDirectory()) { -// siarasDir.mkdir(); -// } + File siarasDir = new File("x3d"); + if (!siarasDir.isDirectory()) { + siarasDir.mkdir(); + } -// String fileName = null; -// try { -// // Generate JastAdd abstract grammar -// fileName = "siaras/Siaras.ast"; -// PrintStream pStream = new PrintStream(new File(fileName)); -// ast.genAbsGrammar(pStream); - -// // Generate Parser.java -// fileName = "siaras/Parser.java"; -// pStream = new PrintStream(new File(fileName)); -// ast.genParser(pStream); + String fileName = null; + try { + // Generate JastAdd abstract grammar + fileName = "x3d/x3d.ast"; + PrintStream pStream = new PrintStream(new File(fileName)); + ast.genAbsGrammar(pStream); + + // Generate JavaCC input + fileName = "x3d/x3d.jjt"; + pStream = new PrintStream(new File(fileName)); + ast.genJavaCC(pStream); + + // Generate Parser.java + fileName = "x3d/Parser.java"; + pStream = new PrintStream(new File(fileName)); + ast.genParser(pStream); // // Generate aspects -// fileName = "siaras/GeneratedAspects.jrag"; +// fileName = "x3d/GeneratedAspects.jrag"; // pStream = new PrintStream(new File(fileName)); // ast.genAspects(pStream); -// } catch (java.io.FileNotFoundException e) { -// System.out.println("Could not create file: "+fileName); -// e.printStackTrace(); -// } + } catch (java.io.FileNotFoundException e) { + System.out.println("Could not create file: "+fileName); + e.printStackTrace(); + } } } diff --git a/JavaCCChunks.jrag b/JavaCCChunks.jrag new file mode 100644 index 0000000000000000000000000000000000000000..1031131a7b007f1f23420d4a4e7b291ec137ed00 --- /dev/null +++ b/JavaCCChunks.jrag @@ -0,0 +1,176 @@ +/* -*-Java-*- */ + +/* + * Copyright (C) 2007 Anders Nilsson <anders.nilsson@cs.lth.se> + * + * This file is part of XmlSchemaCompiler. + */ + +aspect JavaCCChunks { + void Start.genJavaCCHeader(PrintStream pStream) { + pStream.println("options {"); + pStream.println(" MULTI = true;"); + pStream.println(" VISITOR = true;"); + pStream.println(" NODE_DEFAULT_VOID = true;"); + pStream.println(" NODE_SCOPE_HOOK = false;"); + pStream.println(" NODE_PREFIX = \"\";"); + pStream.println(" JAVA_UNICODE_ESCAPE = true;"); + pStream.println(" STATIC = false;"); + pStream.println("} "); + pStream.println(); + pStream.println("PARSER_BEGIN(SiarasParser)"); + pStream.println(" package AST;"); + pStream.println(" public class SiarasParser {"); + pStream.println("}"); + pStream.println("PARSER_END(SiarasParser)"); + pStream.println(); + pStream.println("//----------------------------------------------//"); + pStream.println("// LEXICAL TOKENS //"); + pStream.println("//----------------------------------------------//"); + pStream.println("<DEFAULT, BOUNDS> SKIP : /* WHITE SPACE */"); + pStream.println("{"); + pStream.println(" \" \""); + pStream.println(" |"); + pStream.println(" \"\\t\""); + pStream.println(" |"); + pStream.println(" \"\\n\""); + pStream.println(" |"); + pStream.println(" \"\\r\""); + pStream.println(" |"); + pStream.println(" \"\\f\""); + pStream.println("}// WHITE SPACE"); + pStream.println(); + pStream.println("SPECIAL_TOKEN : /* COMMENTS */ "); + pStream.println("{"); + pStream.println(" < \"<!--\" ( ~[\"-\"] | ( \"-\" ~[\"-\"] ) )* \"-->\">"); + pStream.println(" | < \"<rdfs:comment\" ( ~[\"<\"] | ( \"<\" ~[\"/\"] ) )* \"</rdfs:comment>\" >"); + pStream.println("}// COMMENTS"); + pStream.println(); + } + + void Start.genJavaCCLiterals(PrintStream pStream) { + pStream.println("<DEFAULT, BOUNDS> TOKEN : /* LITERALS */"); + pStream.println("{"); + pStream.println(" < INTEGER_LITERAL:"); + pStream.println(" <DECIMAL_LITERAL> ([\"l\",\"L\"])?"); + pStream.println(" |"); + pStream.println(" <HEX_LITERAL> ([\"l\",\"L\"])?"); + pStream.println(" |"); + pStream.println(" <OCTAL_LITERAL> ([\"l\",\"L\"])?"); + pStream.println(" >"); + pStream.println(" |"); + pStream.println(" < #DECIMAL_LITERAL: [\"1\"-\"9\"] ([\"0\"-\"9\"])* >"); + pStream.println(" |"); + pStream.println(" < #HEX_LITERAL: \"0\" [\"x\",\"X\"] ([\"0\"-\"9\",\"a\"-\"f\",\"A\"-\"F\"])+ >"); + pStream.println(" |"); + pStream.println(" < #OCTAL_LITERAL: \"0\" ([\"0\"-\"7\"])* >"); + pStream.println(" |"); + pStream.println(" < FLOAT_LITERAL:"); + pStream.println(" ([\"0\"-\"9\"])+ \".\" ([\"0\"-\"9\"])* (<EXPONENT>)? ([\"f\",\"F\",\"d\",\"D\"])?"); + pStream.println(" |"); + pStream.println(" \".\" ([\"0\"-\"9\"])+ (<EXPONENT>)? ([\"f\",\"F\",\"d\",\"D\"])?"); + pStream.println(" |"); + pStream.println(" ([\"0\"-\"9\"])+ <EXPONENT> ([\"f\",\"F\",\"d\",\"D\"])?"); + pStream.println(" |"); + pStream.println(" ([\"0\"-\"9\"])+ (<EXPONENT>)? [\"f\",\"F\",\"d\",\"D\"]"); + pStream.println(" >"); + pStream.println(" |"); + pStream.println(" < #EXPONENT: [\"e\",\"E\"] ([\"+\",\"-\"])? ([\"0\"-\"9\"])+ >"); + pStream.println(" |"); + pStream.println(" < CHARACTER_LITERAL:"); + pStream.println(" \"\'\""); + pStream.println(" ( (~[\"\'\",\"\\\\\",\"\\n\",\"\\r\"])"); + pStream.println(" |"); + pStream.println(" (\"\\\\\""); + pStream.println(" ( [\"n\",\"t\",\"b\",\"r\",\"f\",\"\\\\\",\"'\",\"\\\"\"]"); + pStream.println(" |"); + pStream.println(" [\"0\"-\"7\"] ( [\"0\"-\"7\"] )?"); + pStream.println(" |"); + pStream.println(" [\"0\"-\"3\"] [\"0\"-\"7\"] [\"0\"-\"7\"]"); + pStream.println(" )"); + pStream.println(" )"); + pStream.println(" )"); + pStream.println(" \"'\""); + pStream.println(" >"); + pStream.println(" |"); + pStream.println(" < STRING_LITERAL:"); + pStream.println(" \"\\\"\""); + pStream.println(" ( (~[\"\\\"\",\"\\\\\",\"\\n\",\"\\r\"])"); + pStream.println(" |"); + pStream.println(" (\"\\\\\""); + pStream.println(" ( [\"n\",\"t\",\"b\",\"r\",\"f\",\"\\\\\",\"'\",\"\\\"\"]"); + pStream.println(" |"); + pStream.println(" [\"0\"-\"7\"] ( [\"0\"-\"7\"] )?"); + pStream.println(" |"); + pStream.println(" [\"0\"-\"3\"] [\"0\"-\"7\"] [\"0\"-\"7\"]"); + pStream.println(" )"); + pStream.println(" )"); + pStream.println(" )*"); + pStream.println(" \"\\\"\""); + pStream.println(" >"); + pStream.println("}// LITERALS"); + } + + void Start.genJavaCCIdentifiers(PrintStream pStream) { + pStream.println("<DEFAULT, BOUNDS> TOKEN : /* IDENTIFIERS */"); + pStream.println("{"); + pStream.println(" < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>|\"-\")* >"); + pStream.println(" |"); + pStream.println(" < #LETTER:"); + pStream.println(" ["); + pStream.println(" \"\\u0024\","); + pStream.println(" \"\\u0041\"-\"\\u005a\","); + pStream.println(" \"\\u005f\","); + pStream.println(" \"\\u0061\"-\"\\u007a\","); + pStream.println(" \"\\u00c0\"-\"\\u00d6\","); + pStream.println(" \"\\u00d8\"-\"\\u00f6\","); + pStream.println(" \"\\u00f8\"-\"\\u00ff\","); + pStream.println(" \"\\u0100\"-\"\\u1fff\","); + pStream.println(" \"\\u3040\"-\"\\u318f\","); + pStream.println(" \"\\u3300\"-\"\\u337f\","); + pStream.println(" \"\\u3400\"-\"\\u3d2d\","); + pStream.println(" \"\\u4e00\"-\"\\u9fff\","); + pStream.println(" \"\\uf900\"-\"\\ufaff\""); + pStream.println(" ]"); + pStream.println(" >"); + pStream.println(" |"); + pStream.println(" < #DIGIT:"); + pStream.println(" ["); + pStream.println(" \"\\u0030\"-\"\\u0039\","); + pStream.println(" \"\\u0660\"-\"\\u0669\","); + pStream.println(" \"\\u06f0\"-\"\\u06f9\","); + pStream.println(" \"\\u0966\"-\"\\u096f\","); + pStream.println(" \"\\u09e6\"-\"\\u09ef\","); + pStream.println(" \"\\u0a66\"-\"\\u0a6f\","); + pStream.println(" \"\\u0ae6\"-\"\\u0aef\","); + pStream.println(" \"\\u0b66\"-\"\\u0b6f\","); + pStream.println(" \"\\u0be7\"-\"\\u0bef\","); + pStream.println(" \"\\u0c66\"-\"\\u0c6f\","); + pStream.println(" \"\\u0ce6\"-\"\\u0cef\","); + pStream.println(" \"\\u0d66\"-\"\\u0d6f\","); + pStream.println(" \"\\u0e50\"-\"\\u0e59\","); + pStream.println(" \"\\u0ed0\"-\"\\u0ed9\","); + pStream.println(" \"\\u1040\"-\"\\u1049\""); + pStream.println(" ]"); + pStream.println(" >"); + pStream.println("}// IDENTIFIERS"); + } + + void Start.genJavaCCSeparators(PrintStream pStream) { + pStream.println("<DEFAULT,BOUNDS> TOKEN : /* SEPARATORS */"); + pStream.println("{"); + pStream.println(" < LBRACE : \"{\" >"); + pStream.println(" | < RBRACE : \"}\" >"); + pStream.println(" | < LBRACKET : \"[\" >"); + pStream.println(" | < RBRACKET : \"]\" >"); + pStream.println(" | < SEMICOLON : \";\" >"); + pStream.println("}// SEPARATORS"); + } + + void Start.genJavaCCOperators(PrintStream pStream) { + pStream.println("<DEFAULT,BOUNDS> TOKEN : /* OPERATORS */"); + pStream.println("{"); + pStream.println(" < ASSIGN : \"=\" >"); + pStream.println("}// OPERATORS"); + } +} diff --git a/build.xml b/build.xml index d8c53004ddc857012177576a3dbe38593a7f9d22..85a679e7d63c1de217e2d882fcae7d164fde9edf 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/** siaras/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/> + <javac compiler="jikes" debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="tools/** x3d/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/> </target> <!-- generate compiler source files -->