Commit 7614c00f authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Can almost generate abstract grammar for Siaras ontology. Crashes.

parent 72486b04
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import java.io.*; import java.io.*;
aspect CompilerGeneration { aspect AbsGrammarGeneration {
void ASTNode.genAbsGrammar(PrintStream pStream) { void ASTNode.genAbsGrammar(PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) { for (int i=0; i<getNumChild(); i++) {
getChild(i).genAbsGrammar(pStream); getChild(i).genAbsGrammar(pStream);
...@@ -14,19 +14,54 @@ aspect CompilerGeneration { ...@@ -14,19 +14,54 @@ aspect CompilerGeneration {
} }
void OwlClassDecl.genAbsGrammar(PrintStream pStream) { void OwlClassDecl.genAbsGrammar(PrintStream pStream) {
pStream.print("OwlClassDecl: ");
pStream.print(getId()); pStream.print(getId());
if (getSuperClass() != null) { pStream.print(" : "+getSuperClass().getId());
pStream.print(" extends "); pStream.print(" ::=");
pStream.println(getSuperClass().getId()); Restrictions restrs = getRestrictions();
for (int i=0; i<restrs.getNumOwlRestriction(); i++) {
pStream.print(" ");
restrs.getOwlRestriction(i).genAbsGrammar(pStream);
} }
super.genAbsGrammar(pStream); pStream.println(";");
} }
void OwlClassUse.genAbsGrammar(PrintStream pStream) { void OwlRestriction.genAbsGrammar(PrintStream pStream) {
// pStream.print("OwlClassUse: "); pStream.print(getRestrictionProperty().getId());
// pStream.println(getId()); pStream.print(":");
super.genAbsGrammar(pStream); pStream.print(getRestrictionClass().getId());
if (allValuesFrom()) {
pStream.print("*");
}
} }
OwlProperty OwlRestriction.getRestrictionProperty() {
for (int i=0; i<getNumElement(); i++) {
Element e = getElement(i);
if (e instanceof OwlOnProperty) {
return (OwlProperty) ((ComplexElement) e).getElement(0); // Ugly as hell!!
}
}
return new OwlProperty();
}
OwlClassUse OwlRestriction.getRestrictionClass() {
for (int i=0; i<getNumElement(); i++) {
Element e = getElement(i);
if (e instanceof OwlAllValuesFrom || e instanceof OwlSomeValuesFrom) {
return (OwlClassUse) ((ComplexElement) e).getElement(0); // Ugly as hell!!
}
}
return new OwlClassUse();
}
syn lazy boolean OwlRestriction.allValuesFrom() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof OwlAllValuesFrom) {
return true;
}
}
return false;
}
} }
...@@ -78,6 +78,12 @@ aspect MiscUtilities { ...@@ -78,6 +78,12 @@ aspect MiscUtilities {
return getAttribute(i).trim(); return getAttribute(i).trim();
} }
} }
} else if (hasRdfResource()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfResource) {
return getAttribute(i).trim();
}
}
} }
// Fall through. Could not find Id, so let's return something // Fall through. Could not find Id, so let's return something
// well known // well known
...@@ -176,4 +182,4 @@ aspect RewriteClasses { ...@@ -176,4 +182,4 @@ aspect RewriteClasses {
new List().add(oc)); new List().add(oc));
} }
} }
} }
\ No newline at end of file
This diff is collapsed.
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