Loading CompilerGeneration.jrag +9 −2 Original line number Diff line number Diff line Loading @@ -95,14 +95,14 @@ aspect AbsGrammarGeneration { pStream.print(name()); pStream.print(" : "+getSuperClass().name()); pStream.print(" ::="); // getProperties().genAbsGrammar(pStream); getProperties().genAbsGrammar(pStream); pStream.println(";"); } void Properties.genAbsGrammar(PrintStream pStream) { for (int i=0; i<getNumProperty(); i++) { pStream.print(" "); ((OwlProperty) getProperty(i)).genAbsGrammarEntry(pStream); getProperty(i).genAbsGrammarEntry(pStream); } } Loading @@ -114,6 +114,13 @@ aspect AbsGrammarGeneration { // } } void Element.genAbsGrammarEntry(PrintStream pStream) {} void ObjectPropertyDomain.genAbsGrammarEntry(PrintStream pStream) { pStream.print(objectProperty().name()); pStream.print(":Thing*"); } void Restrictions.genAbsGrammar(PrintStream pStream) { for (int i=0; i<getNumOwlRestriction(); i++) { pStream.print(" "); Loading Names.jrag +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ aspect Names { eq Declaration.name() = getElement(0).name(); eq Clazz.name() = iri().trim(); eq NamedIndividual.name() = iri().trim(); eq ObjectProperty.name() = iri().trim(); static String ASTNode.gName = "owl"; Loading Types.jrag +60 −9 Original line number Diff line number Diff line Loading @@ -22,6 +22,17 @@ import java.util.ArrayList; aspect Types { syn Clazz Element.clazz() = null; eq ComplexElement.clazz() { for (Element e: getElements()) { if (e.clazz() != null) { return e.clazz(); } } return null; } eq Clazz.clazz() = this; syn lazy Declaration Declaration.getSuperClass() = null; eq ClassDeclaration.getSuperClass() { return goStart().getSuperClass(name()); Loading Loading @@ -80,7 +91,7 @@ aspect Types { return null; } syn lazy OClass OClass.getSuperClass(); syn lazy Declaration OClass.getSuperClass(); eq OwlClassDecl.getSuperClass() { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsSubClassOf) { Loading @@ -97,7 +108,7 @@ aspect Types { return decl().getSuperClass(); } syn lazy OwlClassDecl OClass.decl(); syn lazy OwlClassDecl Declaration.decl() = null; eq OwlClassDecl.decl() = this; eq OwlClassUse.decl() { ComplexElement top = getTopElement(); Loading Loading @@ -140,6 +151,22 @@ aspect Types { } return p; } syn lazy Properties ClassDeclaration.getProperties() { List l = new List(); goStart().collectProperties(l); // collectProperties(l); // return new Properties(l); Properties p = new Properties(); for (int i=0; i<l.getNumChild(); i++) { ObjectPropertyDomain op = (ObjectPropertyDomain) l.getChild(i); if (op.domainIncludes(this)) { p.addProperty(op); } else { // System.out.println(op); } } return p; } syn lazy ArrayList OClass.getSubClasses(); eq OwlClassUse.getSubClasses() = decl().getSubClasses(); Loading Loading @@ -232,11 +259,11 @@ aspect Properties { l.add(this); } boolean ASTNode.domainIncludes(OClass clazz) { boolean ASTNode.domainIncludes(Declaration clazz) { return false; } boolean OwlObjectProperty.domainIncludes(OClass clazz) { boolean OwlObjectProperty.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsDomain) { return ((RdfsDomain) getElement(i)).domainIncludes(clazz); Loading @@ -245,7 +272,7 @@ aspect Properties { return false; } boolean OwlFunctionalProperty.domainIncludes(OClass clazz) { boolean OwlFunctionalProperty.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsDomain) { return ((RdfsDomain) getElement(i)).domainIncludes(clazz); Loading @@ -254,7 +281,7 @@ aspect Properties { return false; } boolean OwlDatatypeProperty.domainIncludes(OClass clazz) { boolean OwlDatatypeProperty.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsDomain) { return ((RdfsDomain) getElement(i)).domainIncludes(clazz); Loading @@ -263,7 +290,7 @@ aspect Properties { return false; } boolean RdfsDomain.domainIncludes(OClass clazz) { boolean RdfsDomain.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i).domainIncludes(clazz)) { return true; Loading @@ -272,7 +299,7 @@ aspect Properties { return false; } boolean OwlUnionOf.domainIncludes(OClass clazz) { boolean OwlUnionOf.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i).domainIncludes(clazz)) { return true; Loading @@ -281,7 +308,7 @@ aspect Properties { return false; } boolean OClass.domainIncludes(OClass clazz) { boolean Declaration.domainIncludes(Declaration clazz) { if (!getId().equals("_Unknown_")) { return getId().equals(clazz.getId()); } Loading @@ -293,6 +320,16 @@ aspect Properties { return false; } boolean ObjectPropertyDomain.domainIncludes(Declaration clazz) { while (!clazz.name().equals("Thing")) { if (clazz().name().equals(clazz.name())) { return true; } clazz = clazz.getSuperClass(); } return false; } syn lazy RdfsRange Element.range() = null; eq OwlObjectProperty.range() { Loading @@ -319,4 +356,18 @@ aspect Properties { } return null; } syn ObjectProperty ObjectPropertyDomain.objectProperty() { for (Element e : getElements()) { if (e.isObjectProperty()) { return (ObjectProperty) e; } } System.err.println("ObjectPropertyDomain.objectProperty(): not found"); return null; } syn boolean Element.isObjectProperty() = false; eq ObjectProperty.isObjectProperty() = true; } owl.ast +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ ObjectMinCardinality : ComplexElement; ObjectSomeValuesFrom : ComplexElement; ObjectProperty : ComplexElement; ObjectPropertyAssertion : ComplexElement; ObjectPropertyDomain : ComplexElement; ObjectPropertyDomain : OwlProperty; Ontology : OntoDeclaration; Prefix : ComplexElement; SubClassOf : ComplexElement; Loading Loading @@ -174,7 +174,7 @@ Value ::= <STRING_LITERAL>; Identifier ::= <IDENTIFIER>; // Types used by rewrite rules abstract OClass : ComplexElement ::= <Id:String>; abstract OClass : Declaration ::= <Id:String>; OwlClassDecl : OClass; OwlClassUse : OClass; Loading Loading
CompilerGeneration.jrag +9 −2 Original line number Diff line number Diff line Loading @@ -95,14 +95,14 @@ aspect AbsGrammarGeneration { pStream.print(name()); pStream.print(" : "+getSuperClass().name()); pStream.print(" ::="); // getProperties().genAbsGrammar(pStream); getProperties().genAbsGrammar(pStream); pStream.println(";"); } void Properties.genAbsGrammar(PrintStream pStream) { for (int i=0; i<getNumProperty(); i++) { pStream.print(" "); ((OwlProperty) getProperty(i)).genAbsGrammarEntry(pStream); getProperty(i).genAbsGrammarEntry(pStream); } } Loading @@ -114,6 +114,13 @@ aspect AbsGrammarGeneration { // } } void Element.genAbsGrammarEntry(PrintStream pStream) {} void ObjectPropertyDomain.genAbsGrammarEntry(PrintStream pStream) { pStream.print(objectProperty().name()); pStream.print(":Thing*"); } void Restrictions.genAbsGrammar(PrintStream pStream) { for (int i=0; i<getNumOwlRestriction(); i++) { pStream.print(" "); Loading
Names.jrag +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ aspect Names { eq Declaration.name() = getElement(0).name(); eq Clazz.name() = iri().trim(); eq NamedIndividual.name() = iri().trim(); eq ObjectProperty.name() = iri().trim(); static String ASTNode.gName = "owl"; Loading
Types.jrag +60 −9 Original line number Diff line number Diff line Loading @@ -22,6 +22,17 @@ import java.util.ArrayList; aspect Types { syn Clazz Element.clazz() = null; eq ComplexElement.clazz() { for (Element e: getElements()) { if (e.clazz() != null) { return e.clazz(); } } return null; } eq Clazz.clazz() = this; syn lazy Declaration Declaration.getSuperClass() = null; eq ClassDeclaration.getSuperClass() { return goStart().getSuperClass(name()); Loading Loading @@ -80,7 +91,7 @@ aspect Types { return null; } syn lazy OClass OClass.getSuperClass(); syn lazy Declaration OClass.getSuperClass(); eq OwlClassDecl.getSuperClass() { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsSubClassOf) { Loading @@ -97,7 +108,7 @@ aspect Types { return decl().getSuperClass(); } syn lazy OwlClassDecl OClass.decl(); syn lazy OwlClassDecl Declaration.decl() = null; eq OwlClassDecl.decl() = this; eq OwlClassUse.decl() { ComplexElement top = getTopElement(); Loading Loading @@ -140,6 +151,22 @@ aspect Types { } return p; } syn lazy Properties ClassDeclaration.getProperties() { List l = new List(); goStart().collectProperties(l); // collectProperties(l); // return new Properties(l); Properties p = new Properties(); for (int i=0; i<l.getNumChild(); i++) { ObjectPropertyDomain op = (ObjectPropertyDomain) l.getChild(i); if (op.domainIncludes(this)) { p.addProperty(op); } else { // System.out.println(op); } } return p; } syn lazy ArrayList OClass.getSubClasses(); eq OwlClassUse.getSubClasses() = decl().getSubClasses(); Loading Loading @@ -232,11 +259,11 @@ aspect Properties { l.add(this); } boolean ASTNode.domainIncludes(OClass clazz) { boolean ASTNode.domainIncludes(Declaration clazz) { return false; } boolean OwlObjectProperty.domainIncludes(OClass clazz) { boolean OwlObjectProperty.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsDomain) { return ((RdfsDomain) getElement(i)).domainIncludes(clazz); Loading @@ -245,7 +272,7 @@ aspect Properties { return false; } boolean OwlFunctionalProperty.domainIncludes(OClass clazz) { boolean OwlFunctionalProperty.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsDomain) { return ((RdfsDomain) getElement(i)).domainIncludes(clazz); Loading @@ -254,7 +281,7 @@ aspect Properties { return false; } boolean OwlDatatypeProperty.domainIncludes(OClass clazz) { boolean OwlDatatypeProperty.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i) instanceof RdfsDomain) { return ((RdfsDomain) getElement(i)).domainIncludes(clazz); Loading @@ -263,7 +290,7 @@ aspect Properties { return false; } boolean RdfsDomain.domainIncludes(OClass clazz) { boolean RdfsDomain.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i).domainIncludes(clazz)) { return true; Loading @@ -272,7 +299,7 @@ aspect Properties { return false; } boolean OwlUnionOf.domainIncludes(OClass clazz) { boolean OwlUnionOf.domainIncludes(Declaration clazz) { for (int i=0; i<getNumElement(); i++) { if (getElement(i).domainIncludes(clazz)) { return true; Loading @@ -281,7 +308,7 @@ aspect Properties { return false; } boolean OClass.domainIncludes(OClass clazz) { boolean Declaration.domainIncludes(Declaration clazz) { if (!getId().equals("_Unknown_")) { return getId().equals(clazz.getId()); } Loading @@ -293,6 +320,16 @@ aspect Properties { return false; } boolean ObjectPropertyDomain.domainIncludes(Declaration clazz) { while (!clazz.name().equals("Thing")) { if (clazz().name().equals(clazz.name())) { return true; } clazz = clazz.getSuperClass(); } return false; } syn lazy RdfsRange Element.range() = null; eq OwlObjectProperty.range() { Loading @@ -319,4 +356,18 @@ aspect Properties { } return null; } syn ObjectProperty ObjectPropertyDomain.objectProperty() { for (Element e : getElements()) { if (e.isObjectProperty()) { return (ObjectProperty) e; } } System.err.println("ObjectPropertyDomain.objectProperty(): not found"); return null; } syn boolean Element.isObjectProperty() = false; eq ObjectProperty.isObjectProperty() = true; }
owl.ast +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ ObjectMinCardinality : ComplexElement; ObjectSomeValuesFrom : ComplexElement; ObjectProperty : ComplexElement; ObjectPropertyAssertion : ComplexElement; ObjectPropertyDomain : ComplexElement; ObjectPropertyDomain : OwlProperty; Ontology : OntoDeclaration; Prefix : ComplexElement; SubClassOf : ComplexElement; Loading Loading @@ -174,7 +174,7 @@ Value ::= <STRING_LITERAL>; Identifier ::= <IDENTIFIER>; // Types used by rewrite rules abstract OClass : ComplexElement ::= <Id:String>; abstract OClass : Declaration ::= <Id:String>; OwlClassDecl : OClass; OwlClassUse : OClass; Loading