Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Anders Nilsson
OwlCompiler
Commits
5ed09735
Commit
5ed09735
authored
Apr 05, 2007
by
Anders Nilsson
Browse files
Synching
parent
683281f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
CompilerGeneration.jrag
View file @
5ed09735
...
...
@@ -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);");
...
...
siaras/Ontology.java
View file @
5ed09735
...
...
@@ -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
);
}
}
siaras/Rewrites.jrag
View file @
5ed09735
/* -*-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;
}
}
}
siaras/SkillserverInterface.jrag
View file @
5ed09735
...
...
@@ -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;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment