Gitlab service upgraded. Please report any problems to dl_gitadmin@cs.lth.se

Commit ee6481dd authored by Anders Nilsson's avatar Anders Nilsson

Some fixes

parent 50e4a10a
......@@ -27,10 +27,10 @@ aspect AbsGrammarGeneration {
pStream.println("ComplexElement : Element ::= OwlIdentifier Attribute* Element*;");
pStream.println("ValueElement : ComplexElement;");
pStream.println("RdfDeclaration : ComplexElement;");
pStream.println("abstract SimpleElement : Element;");
pStream.println("StringElement : SimpleElement ::= <LITERAL>;");
pStream.println("IntElement : SimpleElement ::= <LITERAL>;");
pStream.println("FloatElement : SimpleElement ::= <LITERAL>;");
pStream.println("abstract SimpleElement : Element ::= <LITERAL>;");
pStream.println("StringElement : SimpleElement ::=;");
pStream.println("IntElement : SimpleElement ::=;");
pStream.println("FloatElement : SimpleElement ::=;");
pStream.println("ClassUse : Thing ::= /decl:Thing/;");
pStream.println("Attribute ::= Value;");
pStream.println("RdfDatatype : Attribute ::= ;");
......@@ -39,8 +39,11 @@ aspect AbsGrammarGeneration {
pStream.println("XmlnsProtege : Attribute ::= ;");
pStream.println("XmlnsRdf : Attribute ::= ;");
pStream.println("XmlnsXsd : Attribute ::= ;");
pStream.println("XmlnsXsp : Attribute ::= ;");
pStream.println("XmlnsRdfs : Attribute ::= ;");
pStream.println("XmlnsOwl : Attribute ::= ;");
pStream.println("XmlnsSwrl : Attribute ::= ;");
pStream.println("XmlnsSwrlb : Attribute ::= ;");
pStream.println("XmlnsDaml : Attribute ::= ;");
pStream.println("XmlnsP1 : Attribute ::= ;");
pStream.println("XmlnsDc : Attribute ::= ;");
......@@ -61,8 +64,29 @@ aspect AbsGrammarGeneration {
pStream.print(getId());
pStream.print(" : "+getSuperClass().getId());
pStream.print(" ::=");
getOwnRestrictions().genAbsGrammar(pStream);
// getOwnRestrictions().genAbsGrammar(pStream);
getProperties().genAbsGrammar(pStream);
pStream.println(";");
// Properties p = getProperties();
// System.out.println(getId());
// for (int i=0; i<p.getNumProperty(); i++) {
// System.out.println(" "+((ComplexElement) p.getProperty(i)).getId());
// }
}
void Properties.genAbsGrammar(PrintStream pStream) {
for (int i=0; i<getNumProperty(); i++) {
pStream.print(" ");
((OwlProperty) getProperty(i)).genAbsGrammarEntry(pStream);
}
}
void OwlProperty.genAbsGrammarEntry(PrintStream pStream) {
pStream.print(name());
pStream.print(":Thing");
// if (allValuesFrom()) {
pStream.print("*");
// }
}
void Restrictions.genAbsGrammar(PrintStream pStream) {
......@@ -158,7 +182,10 @@ aspect GenPrettyPrinter {
pStream.println(" eq XmlnsProtege.id() = \"xmlns:protege\";");
pStream.println(" eq XmlnsRdf.id() = \"xmlns:rdf\";");
pStream.println(" eq XmlnsRdfs.id() = \"xmlns:rdfs\";");
pStream.println(" eq XmlnsSwrl.id() = \"xmlns:swrl\";");
pStream.println(" eq XmlnsSwrlb.id() = \"xmlns:swrlb\";");
pStream.println(" eq XmlnsXsd.id() = \"xmlns:xsd\";");
pStream.println(" eq XmlnsXsp.id() = \"xmlns:xsp\";");
pStream.println(" public void Attribute.prettyPrint(String indent, PrintStream pStream) {");
pStream.println(" System.out.print(\" \"+id()+\"=\"+getValue().getSTRING_LITERAL());");
pStream.println(" }\n");
......@@ -411,7 +438,7 @@ aspect ParserGen {
pStream.println("import java.io.InputStreamReader;");
pStream.println("import java.io.Reader;");
pStream.println("");
pStream.println("import AST.SiarasParser;");
pStream.println("import AST.OWLParser;");
pStream.println("import AST.ParseException;");
pStream.println("import AST.Start;");
pStream.println("");
......@@ -421,7 +448,7 @@ aspect ParserGen {
pStream.println(" Reader r = getReader(args);");
pStream.println(" Start ast = null;");
pStream.println(" try {");
pStream.println(" SiarasParser parser = new SiarasParser(r);");
pStream.println(" OWLParser parser = new OWLParser(r);");
pStream.println();
pStream.println(" ast = parser.Start();");
pStream.println(" } catch (ParseException e) {");
......
......@@ -9,7 +9,7 @@ import AST.Start;
public class Dumper extends Parser {
public static void main(String args[]) {
Start ast = parse(args);
Start ast = parse(args[0]);
// Dump the AST
ast.dumpTree(" ", System.out);
......
......@@ -8,5 +8,6 @@
aspect Names {
syn String OClass.name() = getId();
syn String OwlProperty.name() = getId();
syn String OwlRestriction.name() = getRestrictionClassId();
}
......@@ -55,17 +55,19 @@ aspect Types {
syn lazy Properties OwlClassDecl.getProperties() {
List l = new List();
// getTopElement().collectProperties(l);
collectProperties(l);
return new Properties(l);
// Properties p = new Properties();
// for (int i=0; i<l.getNumChild(); i++) {
// OwlProperty op = (OwlProperty) l.getChild(i);
// if (op.domainIncludes(this)) {
// p.addProperty(op);
// }
// }
// return p;
getTopElement().collectProperties(l);
// collectProperties(l);
// return new Properties(l);
Properties p = new Properties();
for (int i=0; i<l.getNumChild(); i++) {
OwlProperty op = (OwlProperty) l.getChild(i);
if (op.domainIncludes(this)) {
p.addProperty(op);
} else {
// System.out.println(op);
}
}
return p;
}
syn lazy ArrayList OClass.getSubClasses();
......@@ -172,6 +174,24 @@ aspect Properties {
return false;
}
boolean OwlFunctionalProperty.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsDomain) {
return ((RdfsDomain) getElement(i)).domainIncludes(clazz);
}
}
return false;
}
boolean OwlDatatypeProperty.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsDomain) {
return ((RdfsDomain) getElement(i)).domainIncludes(clazz);
}
}
return false;
}
boolean RdfsDomain.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).domainIncludes(clazz)) {
......@@ -212,4 +232,20 @@ aspect Properties {
}
return null;
}
eq OwlFunctionalProperty.range() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsRange) {
return (RdfsRange) getElement(i);
}
}
return null;
}
eq OwlDatatypeProperty.range() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsRange) {
return (RdfsRange) getElement(i);
}
}
return null;
}
}
......@@ -17,6 +17,7 @@ abstract ComplexElement : Element ::= Attribute* Element*;
RdfDeclaration : ComplexElement;
RdfDescription : ComplexElement;
RdfFirst : ComplexElement;
RdfProperty : ComplexElement;
RdfRest : ComplexElement;
RdfType : ComplexElement;
RdfsComment : ComplexElement;
......@@ -30,7 +31,7 @@ OwlAllValuesFrom : OwlValuesFrom;
OwlCardinality : ComplexElement;
OwlClass : ComplexElement;
OwlDataRange : ComplexElement;
OwlDatatypeProperty : ComplexElement;
OwlDatatypeProperty : OwlProperty;
OwlDisjointWith : ComplexElement;
OwlDistinctMembers: ComplexElement;
OwlEquivalentClass : ComplexElement;
......
......@@ -95,6 +95,7 @@ SPECIAL_TOKEN : /* COMMENTS */
| < RDF_DESCRIPTION : "rdf:Description" >
| < RDF_ID : "rdf:ID" >
| < RDF_FIRST : "rdf:first" >
| < RDF_PROPERTY : "rdf:Property" >
| < RDF_REST : "rdf:rest" >
| < RDF_PARSETYPE : "rdf:parseType" >
| < RDF_RESOURCE : "rdf:resource" >
......@@ -204,6 +205,8 @@ SPECIAL_TOKEN : /* COMMENTS */
"+",
"-",
",",
"[",
"]",
"."
]
>
......@@ -235,8 +238,8 @@ SPECIAL_TOKEN : /* COMMENTS */
// | < RPAREN : ")" >
< LBRACE : "{" >
| < RBRACE : "}" >
| < LBRACKET : "[" >
| < RBRACKET : "]" >
// | < LBRACKET : "[" >
// | < RBRACKET : "]" >
| < SEMICOLON : ";" >
| < QUOTE : "\"" >
// | < COMMA : "," >
......@@ -577,6 +580,7 @@ void RdfElement() : {}
RdfType()
| RdfDescription()
| RdfFirst()
| RdfProperty()
| RdfRest()
| RdfsComment()
| RdfsDomain()
......@@ -603,6 +607,12 @@ void RdfFirst() #RdfFirst : {}
(">" ElementList() "</" <RDF_FIRST> ">" | ElementList() "/>")
}
void RdfProperty() #RdfProperty : {}
{
<RDF_PROPERTY> AttributeList()
(">" ElementList() "</" <RDF_PROPERTY> ">" | ElementList() "/>")
}
void RdfRest() #RdfRest : {}
{
<RDF_REST> AttributeList()
......
Markdown is supported
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