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

Can almost generate abstract grammar for Siaras ontology. Crashes.

parent 72486b04
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment