From 5ed09735d8cc4b64ddcbfccdd1578ad620cfe850 Mon Sep 17 00:00:00 2001
From: Anders Nilsson <anders.nilsson@cs.lth.se>
Date: Thu, 5 Apr 2007 15:32:14 +0200
Subject: [PATCH] Synching

---
 CompilerGeneration.jrag          |  3 ++-
 siaras/Ontology.java             |  7 +++++--
 siaras/Rewrites.jrag             | 34 +++++++++++++++++++++++++++++++-
 siaras/SkillserverInterface.jrag | 19 +++++++++++++-----
 4 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag
index 65d5f65..72ee121 100644
--- a/CompilerGeneration.jrag
+++ b/CompilerGeneration.jrag
@@ -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);");
diff --git a/siaras/Ontology.java b/siaras/Ontology.java
index ddfadd7..7ecad7b 100644
--- a/siaras/Ontology.java
+++ b/siaras/Ontology.java
@@ -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);
+    }
 }
diff --git a/siaras/Rewrites.jrag b/siaras/Rewrites.jrag
index 661efe3..f9160ea 100644
--- a/siaras/Rewrites.jrag
+++ b/siaras/Rewrites.jrag
@@ -1,7 +1,7 @@
 /* -*-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;
+        }
+    }
 }
diff --git a/siaras/SkillserverInterface.jrag b/siaras/SkillserverInterface.jrag
index 0ccf0b0..8e6f8c8 100644
--- a/siaras/SkillserverInterface.jrag
+++ b/siaras/SkillserverInterface.jrag
@@ -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;
-- 
GitLab