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 @@
import java.io.*;
aspect CompilerGeneration {
aspect AbsGrammarGeneration {
void ASTNode.genAbsGrammar(PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) {
getChild(i).genAbsGrammar(pStream);
......@@ -14,19 +14,54 @@ aspect CompilerGeneration {
}
void OwlClassDecl.genAbsGrammar(PrintStream pStream) {
pStream.print("OwlClassDecl: ");
pStream.print(getId());
if (getSuperClass() != null) {
pStream.print(" extends ");
pStream.println(getSuperClass().getId());
pStream.print(" : "+getSuperClass().getId());
pStream.print(" ::=");
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) {
// pStream.print("OwlClassUse: ");
// pStream.println(getId());
super.genAbsGrammar(pStream);
void OwlRestriction.genAbsGrammar(PrintStream pStream) {
pStream.print(getRestrictionProperty().getId());
pStream.print(":");
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 {
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
// well known
......@@ -176,4 +182,4 @@ aspect RewriteClasses {
new List().add(oc));
}
}
}
\ No newline at end of file
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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