Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Nilsson
OwlCompiler
Commits
7614c00f
Commit
7614c00f
authored
Sep 22, 2006
by
Anders Nilsson
Browse files
Can almost generate abstract grammar for Siaras ontology. Crashes.
parent
72486b04
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
CompilerGeneration.jrag
View file @
7614c00f
...
...
@@ -2,7 +2,7 @@
import java.io.*;
aspect
Compile
rGeneration {
aspect
AbsGramma
rGeneration {
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;
}
}
Rewrites.jrag
View file @
7614c00f
...
...
@@ -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
}
testontologies/ontologyV07.owl
0 → 100644
View file @
7614c00f
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment