Gitlab service upgraded. Please report any problems to dl_gitadmin@cs.lth.se

Commit ef61c135 authored by Anders Nilsson's avatar Anders Nilsson

Working on generating rewrites for class specialization. Synching

parent 719e248a
......@@ -8,3 +8,4 @@ testontologies/ontologyV06_Jambalaya.properties
siaras/Parser.java
siaras/Siaras.ast
siaras/PrettyPrinter.jrag
siaras/Rewrites.jrag
......@@ -105,25 +105,64 @@ aspect AbsGrammarGeneration {
}
aspect GenPrettyPrinter {
public void ASTNode.genPrettyPrinter(PrintStream pStream) {
public void ASTNode.genPrettyPrinter(String ind, PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) {
getChild(i).genPrettyPrinter(pStream);
getChild(i).genPrettyPrinter(ind, pStream);
}
}
public void Start.genPrettyPrinter(PrintStream pStream) {
pStream.println("");
public void Start.genPrettyPrinter(String ind, PrintStream pStream) {
pStream.println();
pStream.println("import java.io.PrintStream;");
pStream.println("");
pStream.println();
pStream.println("aspect PrettyPrinter {");
pStream.println(" public void ASTNode.prettyPrint(String indent, PrintStream pStream) {");
pStream.println(" String childIndent = indent + \" \";");
pStream.println(" for (int i=0; i<getNumChild(); i++) {");
pStream.println(" getChild(i).prettyPrint(childIndent,pStream);");
pStream.println(" }");
pStream.println(" }");
pStream.println(" }\n");
super.genPrettyPrinter(ind,pStream);
pStream.println("}\n");
}
public void OwlClassDecl.genPrettyPrinter(String ind, PrintStream pStream) {
pStream.print(" public void "+name());
pStream.println(".prettyPrint(String indent, PrintStream pStream) {");
pStream.print(" System.out.print(indent+\"<"+name());
for (int i=0; i<getNumAttribute(); i++) {
getAttribute(i).genPrettyPrinter(ind,pStream);
}
pStream.println(" >\");");
for (int i=0; i<getNumElement(); i++) {
getElement(i).genPrettyPrinter(ind,pStream);
}
pStream.println(" System.out.print(indent+\"</"+name()+">\");");
pStream.println("}\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("import java.io.PrintStream;");
pStream.println();
pStream.println("aspect Rewrites {");
super.genRewrites(pStream);
pStream.println("}");
}
public void OwlClassDecl.genRewrites(PrintStream pStream) {
String ind = " ";
}
}
// JavaCC grammar is not generated, but hand-written as general as is possible
......
......@@ -34,10 +34,15 @@ public class GenCompiler extends Parser {
pStream = new PrintStream(new File(fileName));
ast.genParser(pStream);
// Generate Rewrites
fileName = "siaras/Rewrites.jrag";
pStream = new PrintStream(new File(fileName));
ast.genRewrites(pStream);
// Generate PrettyPrinter
fileName = "siaras/PrettyPrinter.jrag";
pStream = new PrintStream(new File(fileName));
ast.genPrettyPrinter(pStream);
ast.genPrettyPrinter("",pStream);
} catch (java.io.FileNotFoundException e) {
System.out.println("Could not create file: "+fileName);
e.printStackTrace();
......
/* -*-Java-*- */
aspect Names {
syn String OClass.name() = getId();
}
Markdown is supported
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