diff --git a/.bzrignore b/.bzrignore index 5ac132850c6fbaf2b53d8da7273c3d0f945be3d8..651c63ffd4cccf22c86a5afe8434488e72ccff40 100644 --- a/.bzrignore +++ b/.bzrignore @@ -9,3 +9,4 @@ siaras/Parser.java siaras/Siaras.ast siaras/PrettyPrinter.jrag siaras/Rewrites.jrag +siaras/log.tmp diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag index 23cd2f5ca589bd8de7c889457504f5152d76dd89..839a5cf24e20cbb3f3593bf14377fd300e411dba 100644 --- a/CompilerGeneration.jrag +++ b/CompilerGeneration.jrag @@ -62,7 +62,6 @@ aspect AbsGrammarGeneration { } void OwlRestriction.genAbsGrammar(PrintStream pStream) { -// pStream.print(getRestrictionPropertyId()); pStream.print(getRestrictionClassId().substring(0,1).toLowerCase()+ getRestrictionClassId().substring(1)); pStream.print(":"); @@ -159,22 +158,37 @@ aspect GenRewrites { pStream.println("}"); } -// public void OwlClassDecl.genRewrites(PrintStream pStream) { -// String ind = " "; -// int ix = 0; -// pStream.println(ind(1)+"rewrite ComplexElement {"); -// pStream.println(ind(2)+"when (getOwlIdentifier().getIDENTIFIER().equals(\""+ -// name()+"\") && !(this instanceof Thing))"); -// pStream.println(ind(3)+"to "+name()+" {"); + public void OwlClassDecl.genRewrites(PrintStream pStream) { + String ind = " "; + int ix = 0; + pStream.println(ind(1)+"rewrite ComplexElement {"); + pStream.println(ind(2)+"when (getOwlIdentifier().getIDENTIFIER().equals(\""+ + name()+"\") && !(this instanceof Thing))"); + pStream.println(ind(3)+"to "+name()+" {"); // pStream.println(ind(3)+"System.out.println(\"rewriting: \"+getOwlIdentifier().getIDENTIFIER());"); -// 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());"); -// pStream.println(ind(3)+"return node;"); -// pStream.println(ind(2)+"}"); -// pStream.println(ind(1)+"}"); -// } + 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());"); + // Very temporary solution just so that DumpTree will not + // crasch from NullPointerException. Children should be filled + // 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)+"}"); + } } diff --git a/siaras/Statistics.java b/siaras/Statistics.java new file mode 100644 index 0000000000000000000000000000000000000000..ab028b7429eb2c53500b1caed78ea0c98d6c8dc3 --- /dev/null +++ b/siaras/Statistics.java @@ -0,0 +1,13 @@ + +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); + + + } +} diff --git a/siaras/Statistics.jrag b/siaras/Statistics.jrag new file mode 100644 index 0000000000000000000000000000000000000000..1f6cc6ed8386c8fc089020d9d0c3c7ab97a9e758 --- /dev/null +++ b/siaras/Statistics.jrag @@ -0,0 +1,22 @@ + +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); + } +}