From 85eb9240181c8a83996c0a140c0b2c683cc65a11 Mon Sep 17 00:00:00 2001
From: Anders Nilsson <anders.nilsson@cs.lth.se>
Date: Mon, 2 Apr 2007 16:51:36 +0200
Subject: [PATCH] Synching

---
 siaras/Ontology.java             | 15 ++++++-------
 siaras/SkillserverInterface.jrag | 38 +++++++++++++++++---------------
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/siaras/Ontology.java b/siaras/Ontology.java
index f476435..ddfadd7 100644
--- a/siaras/Ontology.java
+++ b/siaras/Ontology.java
@@ -9,7 +9,7 @@ import AST.Start;
 import AST.SiarasParser;
 import AST.ParseException;
 import java.io.*;
-import java.net.URL;
+import java.net.*;
 
 public class Ontology extends Parser {
 	public static Start getAST(String ontologyURL) {
@@ -25,20 +25,19 @@ public class Ontology extends Parser {
 // 			}
 // 		}
 		try {
-			Reader r = new StringReader((String)new URL(ontologyURL).getFile());
+			Reader r = new FileReader(new URL(ontologyURL).getFile());
 			SiarasParser parser = new SiarasParser(r);
 
 			ast = parser.Start();
-		}
-        catch (ParseException e) {
+		} catch (ParseException e) {
 			System.out.println(e.getMessage());
 		}
-// 		catch (FileNotFoundException e) {
-// 			System.err.println("file " + ontologyURL + " not found");
-// 		}
-		catch (IOException e) {
+		catch (MalformedURLException e) {
 			System.out.println(e.getMessage());
 		}
+		catch (FileNotFoundException e) {
+			System.err.println("file " + ontologyURL + " not found");
+		}
         return ast;
 
 // 		try {
diff --git a/siaras/SkillserverInterface.jrag b/siaras/SkillserverInterface.jrag
index 93afcdf..074d0ab 100644
--- a/siaras/SkillserverInterface.jrag
+++ b/siaras/SkillserverInterface.jrag
@@ -8,7 +8,7 @@
 
 aspect SkillserverInterface {
     public Thing ASTNode.getIndividual(String id) {
-        System.out.println("foo: "+this);
+//         System.out.println("foo: "+this);
         for (int i=0; i<getNumChild(); i++) {
             Thing t = getChild(i).getIndividual(id);
             if (t!=null) {
@@ -19,20 +19,9 @@ aspect SkillserverInterface {
         return null;
     }
 
-    public Thing Start.getIndividual(String id) {
-        for (int i=0; i<getNumElement(); i++) {
-            Thing t = getElement(i).getIndividual(id);
-            if (t!=null) {
-                System.out.println("Found: "+t);
-                return t;
-            }
-        }
-        return null;
-    }
-
     public Thing Thing.getIndividual(String id) {
-        System.out.println("Looking for: "+id+" in: "+name());
-        if (id.equals(name())) {
+        System.out.println("Looking for: "+id+" in: "+id());
+        if (id.equals(id())) {
             return this;
         } else {
             return super.getIndividual(id);
@@ -40,9 +29,22 @@ aspect SkillserverInterface {
     }
 }
 
-aspect PrettyPrinter {
-    public void Start.prettyPrint() {
-        System.out.println("PrettyPrinting");
-        prettyPrint("",System.out);
+aspect Misc {
+    public String Thing.id() {
+        for (int i=0; i<getNumElement(); i++) {
+            if (getElement(i).isIdentifier()) {
+                Identifier ident = ((ClassUse) getElement(i)).decl();
+                return ident.getElement(0).id();
+            }
+        }
+        return null;
+    }
+
+    public String ValueElement.id() {
+        return getElement(0).getLITERAL();
     }
+
+    syn boolean Element.isIdentifier() = false;
+    eq Identifier.isIdentifier() = true;
+    eq ClassUse.isIdentifier() = decl().isIdentifier();
 }
-- 
GitLab