Commit 6e9a5503 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Generated compiler can now run DumpTree on V08.owl

parent a52e3838
......@@ -180,17 +180,21 @@ aspect GenRewrites {
// crasch from NullPointerException. Children should be filled
// in from rewrites instead
Restrictions restr = getRestrictions();
pStream.println(ind(3)+"List l;");
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)+"if (getElement(i) instanceof "+r.name()+") {");
pStream.println(ind(5)+"l.add(getElement(i));");
pStream.println(ind(4)+"}");
pStream.println(ind(3)+"}");
if (r.allValuesFrom()) {
pStream.println(ind(3)+"node.set"+r.name()+"List(new List());");
// pStream.println(ind(3)+"node.set"+r.name().substring(0,1).toLowerCase()+
// r.name().substring(1)+"List(new List());");
pStream.println(ind(3)+"node.set"+r.name()+"List(l);");
// pStream.println(ind(3)+"node.set"+r.name()+"List(new List());");
} 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)+"node.set"+r.name().substring(0,1).toLowerCase()+
// r.name().substring(1)+"(c"+(ix++)+");");
}
}
pStream.println(ind(3)+"return node;");
......@@ -200,107 +204,6 @@ aspect GenRewrites {
}
// JavaCC grammar is not generated, but hand-written as general as is possible
// aspect JavaCCGen {
// public void ASTNode.genJavaCC(PrintStream pStream) {
// for (int i=0; i<getNumChild(); i++) {
// getChild(i).genAbsGrammar(pStream);
// }
// }
// public void Start.genJavaCC(PrintStream pStream) {
// genJavaCCHeader(pStream);
// pStream.println();
// genTokenDefs(pStream);
// pStream.println();
// genJavaCCLiterals(pStream);
// pStream.println();
// genJavaCCIdentifiers(pStream);
// pStream.println();
// genJavaCCSeparators(pStream);
// pStream.println();
// genJavaCCOperators(pStream);
// pStream.println();
// // OK, so now it's time to start generating some real grammar
// // productions.
// genJavaCCGrammar(pStream);
// }
// void ASTNode.genTokenDefs(PrintStream pStream) {
// for (int i=0; i<getNumChild(); i++) {
// getChild(i).genTokenDefs(pStream);
// }
// }
// void Start.genTokenDefs(PrintStream pStream) {
// pStream.println("<DEFAULT, BOUNDS> TOKEN : /* RESERVED WORDS */");
// pStream.println("{");
// pStream.println(" <XML \t : \"xml\" >");
// super.genTokenDefs(pStream);
// pStream.println("}");
// pStream.println();
// }
// void OwlClassDecl.genTokenDefs(PrintStream pStream) {
// pStream.println(" |<"+getId().toUpperCase()+" \t : \""+getId()+"\">");
// }
// void ASTNode.genJavaCCGrammar(PrintStream pStream) {
// for (int i=0; i<getNumChild(); i++) {
// getChild(i).genJavaCCGrammar(pStream);
// }
// }
// void Start.genJavaCCGrammar(PrintStream pStream) {
// pStream.println("Start Start() #Start : {}");
// pStream.println("{");
// pStream.println(" (Device())*");
// pStream.println(" { return jjtThis; }");
// pStream.println("}");
// pStream.println();
// super.genJavaCCGrammar(pStream);
// }
// void OwlClassDecl.genJavaCCGrammar(PrintStream pStream) {
// pStream.println("void "+getId()+"() : {}");
// pStream.println("{");
// if (getId().equals("Device")) {
// pStream.print(" \"<\"");
// // pStream.print("\"<\" ( <DEVICE> \">\"");
// // Restrictions restr = getRestrictions();
// // for (int i=0; i< getNumRestriction(); i++) {
// // OwlRestriction res = restr.getOwlRestriction(i);
// // pStream.print("("+res.getRestrictionClassId()+")"+
// // (res.allValuesFrom()?"*":"")+" ");
// // }
// // pStream.println(" #Device("+getNumRestriction()+"))");
// // // List all subclasses
// // Iterator subIter = getSubClasses().iterator();
// // while (subIter.hasNext()) {
// // OwlClassDecl subClass = (OwlClassDecl) subIter.next();
// // pStream.println("| "+subClass.getId()+"()");
// // }
// }
// pStream.print(" ( <"+getId().toUpperCase()+"> \">\"");
// Restrictions restr = getRestrictions();
// for (int i=0; i< getNumRestriction(); i++) {
// OwlRestriction res = restr.getOwlRestriction(i);
// pStream.print("("+res.getRestrictionClassId()+"())"+
// (res.allValuesFrom()?"*":"")+" ");
// }
// pStream.println(" #"+getId()+"("+getNumRestriction()+"))");
// // List all subclasses
// Iterator subIter = getSubClasses().iterator();
// while (subIter.hasNext()) {
// OwlClassDecl subClass = (OwlClassDecl) subIter.next();
// pStream.println(" | "+subClass.getId()+"()");
// }
// pStream.println("}");
// }
// }
aspect ParserGen {
public void Start.genParser(PrintStream pStream) {
......
......@@ -109,7 +109,9 @@ aspect Restrictions {
}
void OwlRestriction.collectRestrictions(List l) {
l.add(this);
if (allValuesFrom()) {
l.add(this);
}
}
syn int OwlClassDecl.getNumRestriction() = getRestrictions().getNumOwlRestriction();
......@@ -130,7 +132,9 @@ aspect Restrictions {
}
void OwlRestriction.collectOwnRestrictions(List l) {
l.add(this);
if (allValuesFrom()) {
l.add(this);
}
}
syn int OwlClassDecl.getNumOwnRestriction() =
......
......@@ -82,6 +82,6 @@ abstract OwlValuesFrom: ComplexElement;
Properties ::= Property:Element*;
Restrictions ::= OwlRestriction*;
//Restrictions ::= OwlRestriction*;
abstract OwlProperty : ComplexElement;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment