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

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

Synching

parent 683281f4
......@@ -321,7 +321,8 @@ aspect GenRewrites {
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));");
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.setElementList(new List());");
pStream.println(ind(3)+"getRdfDecl().addElement(this);");
......
......@@ -56,7 +56,10 @@ public class Ontology extends Parser {
// System.out.println("Could not create file: "+outfile);
// e.printStackTrace();
// }
}
public static void main(String[] args) {
Start ast = getAST(args[0]);
ast.getIndividual("CLOOS_R350").dumpTree("",System.out);
}
}
/* -*-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.
*/
......@@ -30,5 +30,37 @@ aspect Qualification {
getAttribute(0)));
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 {
aspect Misc {
public String Thing.id() {
for (int i=0; i<getNumElement(); i++) {
// System.out.println(" Checking "+getElement(i));
if (getElement(i).isIdentifier()) {
System.out.println(" Found identifier");
Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl();
return ((StringElement) ident.getElement(0)).getLITERAL();
}
......@@ -41,6 +43,7 @@ aspect Misc {
}
syn boolean Element.isIdentifier() = false;
eq ComplexElement.isIdentifier() = name().equals("hasIdentifier"); // Ugly hack!
eq Identifier.isIdentifier() = true;
eq ClassUse.isIdentifier() = decl().isIdentifier();
}
......@@ -49,6 +52,7 @@ aspect Misc {
aspect Decl {
syn lazy Thing ClassUse.decl() {
String id = getAttribute(0).getValue().getSTRING_LITERAL();
System.out.println("Find decl for: "+id);
return rootNode().findDecl(id);
}
......@@ -62,17 +66,20 @@ aspect Decl {
syn Thing Start.findDecl(String id) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).findDecl(id) != null) {
return (Thing) getElement(i);
Thing t = getElement(i).findDecl(id);
if (t != null) {
return t;
}
}
return null;
}
syn Thing Element.findDecl(String id) = null;
eq ComplexElement.findDecl(String id) {
// System.out.println(" "+name());
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).findDecl(id) != null) {
return (Thing) getElement(i);
Thing t = getElement(i).findDecl(id);
if (t != null) {
return t;
}
}
return null;
......@@ -80,6 +87,7 @@ aspect Decl {
eq Thing.findDecl(String id) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i).isEqualId(id)) {
System.out.println(" Found it: "+name());
return this;
}
}
......@@ -88,7 +96,8 @@ aspect Decl {
syn boolean Attribute.isEqualId(String id) = false;
eq RdfId.isEqualId(String id) {
if (getValue().getSTRING_LITERAL().equals(id)) {
System.out.println(" Checking: "+name());
if (name().equals(id)) {
return true;
}
return false;
......
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