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

Can now generate abstract grammar for the small ontology. Must fix the...

Can now generate abstract grammar for the small ontology. Must fix the duplicated hasSkill attribute in the Device class though.
parent 7614c00f
Branches
No related tags found
No related merge requests found
......@@ -26,32 +26,33 @@ aspect AbsGrammarGeneration {
}
void OwlRestriction.genAbsGrammar(PrintStream pStream) {
pStream.print(getRestrictionProperty().getId());
pStream.print(getRestrictionPropertyId());
pStream.print(":");
pStream.print(getRestrictionClass().getId());
pStream.print(getRestrictionClassId());
if (allValuesFrom()) {
pStream.print("*");
}
}
OwlProperty OwlRestriction.getRestrictionProperty() {
String OwlRestriction.getRestrictionPropertyId() {
for (int i=0; i<getNumElement(); i++) {
Element e = getElement(i);
ComplexElement e = (ComplexElement) getElement(i);
if (e instanceof OwlOnProperty) {
return (OwlProperty) ((ComplexElement) e).getElement(0); // Ugly as hell!!
return e.getId();
}
}
return new OwlProperty();
return "_Unknown_";
}
OwlClassUse OwlRestriction.getRestrictionClass() {
String OwlRestriction.getRestrictionClassId() {
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!!
ComplexElement e = (ComplexElement) getElement(i);
if (e instanceof OwlAllValuesFrom ||
e instanceof OwlSomeValuesFrom) {
return e.getId(); // Ugly as hell!!
}
}
return new OwlClassUse();
return "_Unknown_";
}
syn lazy boolean OwlRestriction.allValuesFrom() {
......
......@@ -90,6 +90,64 @@ aspect MiscUtilities {
return "_Unknown_";
}
eq OwlValuesFrom.getId() {
if (hasRdfAbout()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfAbout) {
return getAttribute(i).trim();
}
}
} else if (hasRdfResource()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfResource) {
return getAttribute(i).trim();
}
}
} else {
for (int i=0; i<getNumElement(); i++) {
ComplexElement e = (ComplexElement) getElement(i);
if (e instanceof OClass) {
return e.getId();
}
}
}
// Fall through. Could not find Id, so let's return something
// well known
return "_Unknown_";
}
eq OwlProperty.getId() {
if (hasRdfId()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfId) {
return getAttribute(i).trim();
}
}
} else if (hasRdfAbout()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfAbout) {
return getAttribute(i).trim();
}
}
} else if (hasRdfResource()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfResource) {
return getAttribute(i).trim();
}
}
} else {
for (int i=0; i<getNumElement(); i++) {
ComplexElement e = (ComplexElement) getElement(i);
if (e instanceof OwlProperty) {
return e.getId();
}
}
}
// Fall through. Could not find Id, so let's return something
// well known
return "_Unknown_";
}
syn lazy String Element.type() = null;
eq RdfsRange.type() {
......
......@@ -18,7 +18,7 @@ RdfsSubClassOf : ComplexElement;
RdfsSubPropertyOf : ComplexElement;
OwlOntology : ComplexElement;
OwlAllDifferent : ComplexElement;
OwlAllValuesFrom : ComplexElement;
OwlAllValuesFrom : OwlValuesFrom;
OwlCardinality : ComplexElement;
OwlClass : ComplexElement;
OwlDataRange : ComplexElement;
......@@ -33,7 +33,7 @@ OwlMinCardinality : ComplexElement;
OwlObjectProperty : OwlProperty;
OwlOneOf : ComplexElement;
OwlOnProperty : OwlProperty;
OwlSomeValuesFrom : ComplexElement;
OwlSomeValuesFrom : OwlValuesFrom;
OwlRestriction : ComplexElement;
OwlUnionOf : ComplexElement;
......@@ -63,12 +63,15 @@ XmlnsOwl : Attribute;
Value ::= <STRING_LITERAL>;
// Types generated by rewrite rules
// Types used by rewrite rules
abstract OClass : ComplexElement;
OwlClassDecl : OClass ::= <Id:String> ;
OwlClassUse : OClass ::= <Id:String> ;
abstract OwlValuesFrom: ComplexElement;
Properties ::= Property:Element*;
Restrictions ::= OwlRestriction*;
OwlProperty : ComplexElement;
abstract OwlProperty : ComplexElement;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment