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
8598e4c4
Commit
8598e4c4
authored
Apr 15, 2008
by
Anders Nilsson
Browse files
Added new ontology, revised code.
parent
0bb74d2d
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
owl.ast
View file @
8598e4c4
...
...
@@ -43,8 +43,9 @@ OwlMaxCardinality : ComplexElement;
OwlObjectProperty : OwlProperty;
OwlOneOf : ComplexElement;
OwlOnProperty : OwlProperty;
OwlSomeValuesFrom : OwlValuesFrom;
OwlRestriction : ComplexElement;
OwlSomeValuesFrom : OwlValuesFrom;
OwlTransitiveProperty : ComplexElement;
OwlUnionOf : ComplexElement;
abstract SimpleElement : Element;
...
...
owl.jjt
View file @
8598e4c4
...
...
@@ -87,6 +87,7 @@ SPECIAL_TOKEN : /* COMMENTS */
|
<
OWL_ONTOLOGY
:
"owl:Ontology"
>
|
<
OWL_RESTRICTION
:
"owl:Restriction"
>
|
<
OWL_SOMEVALUESFROM
:
"owl:someValuesFrom"
>
|
<
OWL_TRANSITIVEPROPERTY
:
"owl:TransitiveProperty"
>
|
<
OWL_UNIONOF
:
"owl:unionOf"
>
|
<
RDF_RDF
:
"rdf:RDF"
>
|
<
RDF_ABOUT
:
"rdf:about"
>
...
...
@@ -424,8 +425,9 @@ void OwlElement() : {}
|
OwlObjectProperty
()
|
OwlOneOf
()
|
OwlOnProperty
()
|
OwlSomeValuesFrom
()
|
OwlRestriction
()
|
OwlSomeValuesFrom
()
|
OwlTransitiveProperty
()
|
OwlUnionOf
()
}
...
...
@@ -543,16 +545,22 @@ void OwlOnProperty () #OwlOnProperty : {}
(
">"
ElementList
()
"</"
<
OWL_ONPROPERTY
>
">"
|
ElementList
()
"/>"
)
}
void
OwlRestriction
()
#
OwlRestriction
:
{}
{
<
OWL_RESTRICTION
>
AttributeList
()
(
">"
ElementList
()
"</"
<
OWL_RESTRICTION
>
">"
|
ElementList
()
"/>"
)
}
void
OwlSomeValuesFrom
()
#
OwlSomeValuesFrom
:
{}
{
<
OWL_SOMEVALUESFROM
>
AttributeList
()
(
">"
ElementList
()
"</"
<
OWL_SOMEVALUESFROM
>
">"
|
ElementList
()
"/>"
)
}
void
Owl
Restriction
()
#
OwlRestriction
:
{}
void
Owl
TransitiveProperty
()
#
OwlTransitiveProperty
:
{}
{
<
OWL_
RESTRICTION
>
AttributeList
()
(
">"
ElementList
()
"</"
<
OWL_
RESTRICTION
>
">"
|
ElementList
()
"/>"
)
<
OWL_
TRANSITIVEPROPERTY
>
AttributeList
()
(
">"
ElementList
()
"</"
<
OWL_
TRANSITIVEPROPERTY
>
">"
|
ElementList
()
"/>"
)
}
void
OwlUnionOf
()
#
OwlUnionOf
:
{}
...
...
siaras/Geometry.jrag
View file @
8598e4c4
...
...
@@ -7,31 +7,31 @@
*/
aspect Geometry {
syn lazy String Thing.getGeometryRef() = "NotApplicable";
//
syn lazy String Thing.getGeometryRef() = "NotApplicable";
eq Product.getGeometryRef(){
//
eq Product.getGeometryRef(){
// // if (getNumAttribute() > 0) {
// // return getAttribute(0).name();
// // } else {
// // return "unknown_id";
// // }
for (int i=0; i<getNumElement(); i++) {
// System.out.println(" Checking "+getElement(i));
if (getElement(i).isGeometryRef()) {
System.out.println("Found Geometry ref");
// System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).getAttribute(0).name());
Geometry g = (Geometry) ((ClassUse) getElement(i)).decl();
// System.out.println(" "+((ComplexElement) ident.getElement(0)).name());
// return ident.value();
return g.getValue();
}
}
return "_No_GeometryRef_";
}
// //
//
if (getNumAttribute() > 0) {
// //
//
return getAttribute(0).name();
// //
//
} else {
// //
//
return "unknown_id";
// //
//
}
//
for (int i=0; i<getNumElement(); i++) {
//
// System.out.println(" Checking "+getElement(i));
//
if (getElement(i).isGeometryRef()) {
//
System.out.println("Found Geometry ref");
//
// System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).getAttribute(0).name());
//
Geometry g = (Geometry) ((ClassUse) getElement(i)).decl();
//
// System.out.println(" "+((ComplexElement) ident.getElement(0)).name());
//
// return ident.value();
//
return g.getValue();
//
}
//
}
//
return "_No_GeometryRef_";
//
}
syn boolean Element.isGeometryRef() = false;
eq ComplexElement.isGeometryRef() = name().equals("hasGeometry"); // Ugly hack!
eq Geometry.isGeometryRef() = true;
//
syn boolean Element.isGeometryRef() = false;
//
eq ComplexElement.isGeometryRef() = name().equals("hasGeometry"); // Ugly hack!
//
eq Geometry.isGeometryRef() = true;
}
\ No newline at end of file
siaras/GeometryDemo.java
View file @
8598e4c4
...
...
@@ -52,13 +52,13 @@ public class GeometryDemo extends Parser {
con
.
readLine
(
"\n\nFind the Teapot instance"
);
Product
p
=
(
Product
)
ast
.
getIndividual
(
"Teapot_1"
);
p
.
dumpTree
(
""
,
System
.
out
);
// p.prettyPrint("",System.out);
//
Product p = (Product) ast.getIndividual("Teapot_1");
//
p.dumpTree("",System.out);
//
// p.prettyPrint("",System.out);
con
.
readLine
(
"\n\nFind the geometry reference"
);
//
con.readLine("\n\nFind the geometry reference");
String
s
=
p
.
getGeometryRef
();
System
.
out
.
println
(
"Geometry model: "
+
s
);
//
String s = p.getGeometryRef();
//
System.out.println("Geometry model: "+s);
}
}
siaras/Siaras.jjt
View file @
8598e4c4
...
...
@@ -354,12 +354,12 @@ void StringElement() #StringElement : { Token t;String s; }
{
t
=
<
IDENTIFIER
>
{
s
=
t
.
image
;
s
=
t
.
image
+
" "
;
if
(
getToken
(
1
).
kind
!= START_TAG ) {
s
+=
getData
();
}
}
{
jjtThis
.
setLITERAL
(
s
);}
{
jjtThis
.
setLITERAL
(
s
.
trim
()
);}
}
JAVACODE
...
...
siaras/SkillserverInterface.jrag
View file @
8598e4c4
...
...
@@ -51,7 +51,7 @@ aspect SkillserverInterface {
public Thing Thing.getIndividual(String id) {
// System.out.println(" "+name());
// System.out.println("Looking for: "+id+" in: "+id()+" ("+name()+")");
//
System.out.println("Looking in: "+id()
+" "+" ("+name()+")"
);
// System.out.println("Looking in: "+id());
// if (id().contains(id) &&
// (this instanceof Device)) {
if (id.equals(id())) {
...
...
@@ -96,7 +96,6 @@ aspect SkillserverInterface {
* getPropertyValues(String name)
********************************/
public Collection Thing.getPropertyValues(String name) {
// System.out.println("Looking for property: "+name+" in "+id());
LinkedList l = new LinkedList();
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof ClassUse) {
...
...
@@ -114,6 +113,17 @@ aspect SkillserverInterface {
return l;
}
public Collection Device.getPropertyValues(String name) {
LinkedList l = new LinkedList();
for (int i=0; i<getNumProperty(); i++) {
ClassUse c = (ClassUse) getProperty(i);
if (c.name().equals(name)) {
l.add(c.decl());
}
}
return l;
}
/********************************
* Thing Thing.getDirectType()
********************************/
...
...
@@ -227,32 +237,32 @@ aspect Misc {
// } else {
// return "unknown_id";
// }
for (int i=0; i<getNumElement(); i++) {
//
for (int i=0; i<getNumElement(); i++) {
// System.out.println(" Checking "+getElement(i));
if (getElement(i).isIdentifier()) {
//
if (getElement(i).isIdentifier()) {
// System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).getAttribute(0).name());
Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl();
//
Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl();
// System.out.println(" "+((ComplexElement) ident.getElement(0)).name());
// return ident.value();
return ident.getValue();
}
}
//
return ident.getValue();
//
}
//
}
return "unknown_id";
}
syn boolean Element.isIdentifier() = false;
eq ComplexElement.isIdentifier() = name().equals("hasIdentifier"); // Ugly hack!
eq Identifier.isIdentifier() = true;
//
eq Identifier.isIdentifier() = true;
// eq ClassUse.isIdentifier() = decl().isIdentifier();
syn lazy String Identifier.value() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof StringElement) {
return ((StringElement) getElement(i)).getLITERAL();
}
}
return "#valueNotFound";
}
//
syn lazy String Identifier.value() {
//
for (int i=0; i<getNumElement(); i++) {
//
if (getElement(i) instanceof StringElement) {
//
return ((StringElement) getElement(i)).getLITERAL();
//
}
//
}
//
return "#valueNotFound";
//
}
}
...
...
siaras/Statistics.java
View file @
8598e4c4
...
...
@@ -21,6 +21,10 @@ public class Statistics extends Parser {
ast
.
getSensors
(
System
.
out
);
System
.
out
.
println
();
// System.out.println("Test");
// System.out.println(ast.getIndividual("Asentics_CR723-A073").id());
// System.out.println();
}
}
siaras/Statistics.jrag
View file @
8598e4c4
...
...
@@ -55,7 +55,8 @@ aspect Statistics {
}
public void Sensor.getSensors(PrintStream pStream) {
pStream.println(" "+getOwlIdentifier().getIDENTIFIER()+
" : "+getAttribute(0).getValue().getSTRING_LITERAL());
" : "+getAttribute(0).getValue().getSTRING_LITERAL()+
" ("+id()+")");
super.getSensors(pStream);
}
...
...
testontologies/ontology_v2.owl
0 → 100755
View file @
8598e4c4
This diff is collapsed.
Click to expand it.
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