diff --git a/siaras/Ontology.java b/siaras/Ontology.java index f476435d0031ab46a44db1b99e5badf17f4ba9c4..ddfadd70150b64d1fbffb3e2601524c8390c626a 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 93afcdfeebea0afbc8fd5e124bd30e87cb22f2f8..074d0ab036baa7f6b5d488e3ec44f99cd3227dde 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(); }