Skip to content
Snippets Groups Projects
Commit 9d9e1a0a authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Added small hand-written aspect Statistics.jrag to visualize how one can...

Added small hand-written aspect Statistics.jrag to visualize how one can easily get information from the AST
parent a930ea26
No related branches found
No related tags found
No related merge requests found
...@@ -9,3 +9,4 @@ siaras/Parser.java ...@@ -9,3 +9,4 @@ siaras/Parser.java
siaras/Siaras.ast siaras/Siaras.ast
siaras/PrettyPrinter.jrag siaras/PrettyPrinter.jrag
siaras/Rewrites.jrag siaras/Rewrites.jrag
siaras/log.tmp
...@@ -62,7 +62,6 @@ aspect AbsGrammarGeneration { ...@@ -62,7 +62,6 @@ aspect AbsGrammarGeneration {
} }
void OwlRestriction.genAbsGrammar(PrintStream pStream) { void OwlRestriction.genAbsGrammar(PrintStream pStream) {
// pStream.print(getRestrictionPropertyId());
pStream.print(getRestrictionClassId().substring(0,1).toLowerCase()+ pStream.print(getRestrictionClassId().substring(0,1).toLowerCase()+
getRestrictionClassId().substring(1)); getRestrictionClassId().substring(1));
pStream.print(":"); pStream.print(":");
...@@ -159,22 +158,37 @@ aspect GenRewrites { ...@@ -159,22 +158,37 @@ aspect GenRewrites {
pStream.println("}"); pStream.println("}");
} }
// public void OwlClassDecl.genRewrites(PrintStream pStream) { public void OwlClassDecl.genRewrites(PrintStream pStream) {
// String ind = " "; String ind = " ";
// int ix = 0; int ix = 0;
// pStream.println(ind(1)+"rewrite ComplexElement {"); pStream.println(ind(1)+"rewrite ComplexElement {");
// pStream.println(ind(2)+"when (getOwlIdentifier().getIDENTIFIER().equals(\""+ pStream.println(ind(2)+"when (getOwlIdentifier().getIDENTIFIER().equals(\""+
// name()+"\") && !(this instanceof Thing))"); name()+"\") && !(this instanceof Thing))");
// pStream.println(ind(3)+"to "+name()+" {"); pStream.println(ind(3)+"to "+name()+" {");
// pStream.println(ind(3)+"System.out.println(\"rewriting: \"+getOwlIdentifier().getIDENTIFIER());"); // pStream.println(ind(3)+"System.out.println(\"rewriting: \"+getOwlIdentifier().getIDENTIFIER());");
// pStream.println(ind(3)+name()+" node = new "+name()+"();"); pStream.println(ind(3)+name()+" node = new "+name()+"();");
// pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());"); pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());");
// pStream.println(ind(3)+"node.setAttributeList(getAttributeList());"); pStream.println(ind(3)+"node.setAttributeList(getAttributeList());");
// pStream.println(ind(3)+"node.setElementList(getElementList());"); pStream.println(ind(3)+"node.setElementList(getElementList());");
// pStream.println(ind(3)+"return node;"); // Very temporary solution just so that DumpTree will not
// pStream.println(ind(2)+"}"); // crasch from NullPointerException. Children should be filled
// pStream.println(ind(1)+"}"); // in from rewrites instead
// } Restrictions restr = getRestrictions();
for (int i=0; i<restr.getNumOwlRestriction(); i++) {
OwlRestriction r = restr.getOwlRestriction(i);
if (r.allValuesFrom()) {
pStream.println(ind(3)+"node.set"+r.name().substring(0,1).toLowerCase()+
r.name().substring(1)+"List(new List());");
} else {
pStream.println(ind(3)+r.name()+" c"+ix+" = new "+r.name()+"();");
pStream.println(ind(3)+"node.set"+r.name().substring(0,1).toLowerCase()+
r.name().substring(1)+"(c"+(ix++)+");");
}
}
pStream.println(ind(3)+"return node;");
pStream.println(ind(2)+"}");
pStream.println(ind(1)+"}");
}
} }
......
import AST.Start;
public class Statistics extends Parser {
public static void main(String args[]) {
Start ast = parse(args);
// PrettyPrint all OWL instances found in input
ast.getManipulationDevices(System.out);
}
}
import java.io.PrintStream;
aspect Statistics {
public void ASTNode.getManipulationDevices(PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) {
getChild(i).getManipulationDevices(pStream);
}
}
public void Thing.getManipulationDevices(PrintStream pStream) {
for (int i=0; i<getNumElement(); i++) {
getElement(i).getManipulationDevices(pStream);
}
}
public void ManipulationAndHandling.getManipulationDevices(PrintStream pStream) {
pStream.println(getOwlIdentifier().getIDENTIFIER()+
" : "+getAttribute(0).getValue().getSTRING_LITERAL());
super.getManipulationDevices(pStream);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment