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

Commit 07e3cdab authored by Anders Nilsson's avatar Anders Nilsson

Modifying compiler generation to support new OWL format.

parent 10c97b29
......@@ -91,6 +91,14 @@ aspect AbsGrammarGeneration {
// }
}
void ClassDeclaration.genAbsGrammar(PrintStream pStream) {
pStream.print(name());
pStream.print(" : "+getSuperClass().name());
pStream.print(" ::=");
getProperties().genAbsGrammar(pStream);
pStream.println(";");
}
void Properties.genAbsGrammar(PrintStream pStream) {
for (int i=0; i<getNumProperty(); i++) {
pStream.print(" ");
......
......@@ -43,6 +43,7 @@ public class GenCompiler extends Parser {
}
Start ast = parse(owlFile);
ast.setGrammarName(name);
File siarasDir = new File(dirName);
if (!siarasDir.isDirectory()) {
......
......@@ -31,11 +31,11 @@ aspect JavaCCChunks {
pStream.println(" STATIC = false;");
pStream.println("} ");
pStream.println();
pStream.println("PARSER_BEGIN("+name()+"Parser)");
pStream.println("PARSER_BEGIN("+grammarName()+"Parser)");
pStream.println(" package AST;");
pStream.println(" public class "+name()+"Parser {");
pStream.println(" public class "+grammarName()+"Parser {");
pStream.println("}");
pStream.println("PARSER_END("+name()+"Parser)");
pStream.println("PARSER_END("+grammarName()+"Parser)");
pStream.println();
pStream.println("//----------------------------------------------//");
pStream.println("// LEXICAL TOKENS //");
......
......@@ -31,4 +31,16 @@ aspect Misc {
}
return s.toString();
}
syn Attribute Element.iri() = null;
eq ComplexElement.iri() {
for (int i=0; i<getNumAttribute(); i++) {
Attribute a = getAttribute(i);
if (a instanceof IRI) {
return a;
}
}
return null;
}
}
......@@ -20,7 +20,16 @@
*/
aspect Names {
syn String OClass.name() = getId();
syn String OwlProperty.name() = getId();
syn String OwlRestriction.name() = getRestrictionClassId();
syn String Element.name() = "";
eq OClass.name() = getId();
eq OwlProperty.name() = getId();
eq OwlRestriction.name() = getRestrictionClassId();
eq Declaration.name() = getElement(0).name();
eq Clazz.name() = iri().name();
eq NamedIndividual.name() = iri().trim();
static String ASTNode.gName = "owl";
public void ASTNode.setGrammarName(String s) {gName = s;}
public String ASTNode.grammarName() {return gName;}
}
......@@ -224,6 +224,20 @@ aspect MiscUtilities {
}
return (ComplexElement) e;
}
syn boolean Declaration.isClassDecl() = getElement(0).isClass();
eq ClassDeclaration.isClassDecl() = true;
eq IndividualDeclaration.isClassDecl() = false;
syn boolean Declaration.isIndividualDecl() = getElement(0).isIndividual();
eq IndividualDeclaration.isIndividualDecl() = true;
eq ClassDeclaration.isIndividualDecl() = false;
syn boolean Element.isClass() = false;
eq Clazz.isClass() = true;
syn boolean Element.isIndividual() = false;
eq NamedIndividual.isIndividual() = true;
}
aspect RewriteClasses {
......
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