Commit 5ed09735 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Synching

parent 683281f4
...@@ -321,7 +321,8 @@ aspect GenRewrites { ...@@ -321,7 +321,8 @@ aspect GenRewrites {
pStream.println(ind(3)+"ClassUse use = new ClassUse();"); pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));"); pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));");
pStream.println(ind(3)+"String id = getAttribute(0).getValue().getSTRING_LITERAL();"); pStream.println(ind(3)+"String id = getAttribute(0).getValue().getSTRING_LITERAL();");
pStream.println(ind(3)+"Value val = new Value(\"\\\"#\"+id.substring(1,id.length()));"); // pStream.println(ind(3)+"Value val = new Value(\"\\\"#\"+id.substring(1,id.length()));");
pStream.println(ind(3)+"Value val = new Value(id);");
pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(val)));"); pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(val)));");
pStream.println(ind(3)+"use.setElementList(new List());"); pStream.println(ind(3)+"use.setElementList(new List());");
pStream.println(ind(3)+"getRdfDecl().addElement(this);"); pStream.println(ind(3)+"getRdfDecl().addElement(this);");
......
...@@ -56,7 +56,10 @@ public class Ontology extends Parser { ...@@ -56,7 +56,10 @@ public class Ontology extends Parser {
// System.out.println("Could not create file: "+outfile); // System.out.println("Could not create file: "+outfile);
// e.printStackTrace(); // e.printStackTrace();
// } // }
} }
public static void main(String[] args) {
Start ast = getAST(args[0]);
ast.getIndividual("CLOOS_R350").dumpTree("",System.out);
}
} }
/* -*-Java-*- */ /* -*-Java-*- */
/* /*
* Copyright (C) 2006 Anders Nilsson <anders.nilsson@cs.lth.se> * Copyright (C) 2006,2007 Anders Nilsson <anders.nilsson@cs.lth.se>
* *
* This file is part of OntologyCompiler. * This file is part of OntologyCompiler.
*/ */
...@@ -30,5 +30,37 @@ aspect Qualification { ...@@ -30,5 +30,37 @@ aspect Qualification {
getAttribute(0))); getAttribute(0)));
setElementList(new List()); setElementList(new List());
} }
when ((name().equals("hasProperty") ||
name().equals("hasIdentifier") ||
name().equals("hasSubskill") ||
name().equals("hasSkill") ||
name().equals("hasSubskill") ||
name().equals("hasEditable") ||
name().equals("isPropertyOf") ||
name().equals("isSubskillOf") ||
name().equals("isSkillOf")) &&
!(this instanceof ClassUse))
to ClassUse {
return new ClassUse(getOwlIdentifier(),getAttributeList(),getElementList());
}
} }
rewrite Attribute {
when (name().startsWith("\"")) to Attribute {
String name = name();
// System.out.println(" Fixing: "+name);
if (name.startsWith("\"")) {
getValue().setSTRING_LITERAL(name.substring(1,name.length()-1));
}
return this;
}
when (name().startsWith("#")) to Attribute {
String name = name();
// System.out.println(" Fixing: "+name);
if (name.startsWith("")) {
getValue().setSTRING_LITERAL(name.substring(1,name.length()));
}
return this;
}
}
} }
...@@ -32,7 +32,9 @@ aspect SkillserverInterface { ...@@ -32,7 +32,9 @@ aspect SkillserverInterface {
aspect Misc { aspect Misc {
public String Thing.id() { public String Thing.id() {
for (int i=0; i<getNumElement(); i++) { for (int i=0; i<getNumElement(); i++) {
// System.out.println(" Checking "+getElement(i));
if (getElement(i).isIdentifier()) { if (getElement(i).isIdentifier()) {
System.out.println(" Found identifier");
Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl(); Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl();
return ((StringElement) ident.getElement(0)).getLITERAL(); return ((StringElement) ident.getElement(0)).getLITERAL();
} }
...@@ -41,6 +43,7 @@ aspect Misc { ...@@ -41,6 +43,7 @@ aspect Misc {
} }
syn boolean Element.isIdentifier() = false; syn boolean Element.isIdentifier() = false;
eq ComplexElement.isIdentifier() = name().equals("hasIdentifier"); // Ugly hack!
eq Identifier.isIdentifier() = true; eq Identifier.isIdentifier() = true;
eq ClassUse.isIdentifier() = decl().isIdentifier(); eq ClassUse.isIdentifier() = decl().isIdentifier();
} }
...@@ -49,6 +52,7 @@ aspect Misc { ...@@ -49,6 +52,7 @@ aspect Misc {
aspect Decl { aspect Decl {
syn lazy Thing ClassUse.decl() { syn lazy Thing ClassUse.decl() {
String id = getAttribute(0).getValue().getSTRING_LITERAL(); String id = getAttribute(0).getValue().getSTRING_LITERAL();
System.out.println("Find decl for: "+id);
return rootNode().findDecl(id); return rootNode().findDecl(id);
} }
...@@ -62,17 +66,20 @@ aspect Decl { ...@@ -62,17 +66,20 @@ aspect Decl {
syn Thing Start.findDecl(String id) { syn Thing Start.findDecl(String id) {
for (int i=0; i<getNumElement(); i++) { for (int i=0; i<getNumElement(); i++) {
if (getElement(i).findDecl(id) != null) { Thing t = getElement(i).findDecl(id);
return (Thing) getElement(i); if (t != null) {
return t;
} }
} }
return null; return null;
} }
syn Thing Element.findDecl(String id) = null; syn Thing Element.findDecl(String id) = null;
eq ComplexElement.findDecl(String id) { eq ComplexElement.findDecl(String id) {
// System.out.println(" "+name());
for (int i=0; i<getNumElement(); i++) { for (int i=0; i<getNumElement(); i++) {
if (getElement(i).findDecl(id) != null) { Thing t = getElement(i).findDecl(id);
return (Thing) getElement(i); if (t != null) {
return t;
} }
} }
return null; return null;
...@@ -80,6 +87,7 @@ aspect Decl { ...@@ -80,6 +87,7 @@ aspect Decl {
eq Thing.findDecl(String id) { eq Thing.findDecl(String id) {
for (int i=0; i<getNumAttribute(); i++) { for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i).isEqualId(id)) { if (getAttribute(i).isEqualId(id)) {
System.out.println(" Found it: "+name());
return this; return this;
} }
} }
...@@ -88,7 +96,8 @@ aspect Decl { ...@@ -88,7 +96,8 @@ aspect Decl {
syn boolean Attribute.isEqualId(String id) = false; syn boolean Attribute.isEqualId(String id) = false;
eq RdfId.isEqualId(String id) { eq RdfId.isEqualId(String id) {
if (getValue().getSTRING_LITERAL().equals(id)) { System.out.println(" Checking: "+name());
if (name().equals(id)) {
return true; return true;
} }
return false; return false;
......
Supports Markdown
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