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
ee6481dd
Commit
ee6481dd
authored
Jun 27, 2008
by
Anders Nilsson
Browse files
Some fixes
parent
50e4a10a
Changes
6
Hide whitespace changes
Inline
Side-by-side
CompilerGeneration.jrag
View file @
ee6481dd
...
...
@@ -27,10 +27,10 @@ aspect AbsGrammarGeneration {
pStream.println("ComplexElement : Element ::= OwlIdentifier Attribute* Element*;");
pStream.println("ValueElement : ComplexElement;");
pStream.println("RdfDeclaration : ComplexElement;");
pStream.println("abstract SimpleElement : Element;");
pStream.println("StringElement : SimpleElement ::=
<LITERAL>
;");
pStream.println("IntElement : SimpleElement ::=
<LITERAL>
;");
pStream.println("FloatElement : SimpleElement ::=
<LITERAL>
;");
pStream.println("abstract SimpleElement : Element
::= <LITERAL>
;");
pStream.println("StringElement : SimpleElement ::=;");
pStream.println("IntElement : SimpleElement ::=;");
pStream.println("FloatElement : SimpleElement ::=;");
pStream.println("ClassUse : Thing ::= /decl:Thing/;");
pStream.println("Attribute ::= Value;");
pStream.println("RdfDatatype : Attribute ::= ;");
...
...
@@ -39,8 +39,11 @@ aspect AbsGrammarGeneration {
pStream.println("XmlnsProtege : Attribute ::= ;");
pStream.println("XmlnsRdf : Attribute ::= ;");
pStream.println("XmlnsXsd : Attribute ::= ;");
pStream.println("XmlnsXsp : Attribute ::= ;");
pStream.println("XmlnsRdfs : Attribute ::= ;");
pStream.println("XmlnsOwl : Attribute ::= ;");
pStream.println("XmlnsSwrl : Attribute ::= ;");
pStream.println("XmlnsSwrlb : Attribute ::= ;");
pStream.println("XmlnsDaml : Attribute ::= ;");
pStream.println("XmlnsP1 : Attribute ::= ;");
pStream.println("XmlnsDc : Attribute ::= ;");
...
...
@@ -61,8 +64,29 @@ aspect AbsGrammarGeneration {
pStream.print(getId());
pStream.print(" : "+getSuperClass().getId());
pStream.print(" ::=");
getOwnRestrictions().genAbsGrammar(pStream);
// getOwnRestrictions().genAbsGrammar(pStream);
getProperties().genAbsGrammar(pStream);
pStream.println(";");
// Properties p = getProperties();
// System.out.println(getId());
// for (int i=0; i<p.getNumProperty(); i++) {
// System.out.println(" "+((ComplexElement) p.getProperty(i)).getId());
// }
}
void Properties.genAbsGrammar(PrintStream pStream) {
for (int i=0; i<getNumProperty(); i++) {
pStream.print(" ");
((OwlProperty) getProperty(i)).genAbsGrammarEntry(pStream);
}
}
void OwlProperty.genAbsGrammarEntry(PrintStream pStream) {
pStream.print(name());
pStream.print(":Thing");
// if (allValuesFrom()) {
pStream.print("*");
// }
}
void Restrictions.genAbsGrammar(PrintStream pStream) {
...
...
@@ -158,7 +182,10 @@ aspect GenPrettyPrinter {
pStream.println(" eq XmlnsProtege.id() = \"xmlns:protege\";");
pStream.println(" eq XmlnsRdf.id() = \"xmlns:rdf\";");
pStream.println(" eq XmlnsRdfs.id() = \"xmlns:rdfs\";");
pStream.println(" eq XmlnsSwrl.id() = \"xmlns:swrl\";");
pStream.println(" eq XmlnsSwrlb.id() = \"xmlns:swrlb\";");
pStream.println(" eq XmlnsXsd.id() = \"xmlns:xsd\";");
pStream.println(" eq XmlnsXsp.id() = \"xmlns:xsp\";");
pStream.println(" public void Attribute.prettyPrint(String indent, PrintStream pStream) {");
pStream.println(" System.out.print(\" \"+id()+\"=\"+getValue().getSTRING_LITERAL());");
pStream.println(" }\n");
...
...
@@ -411,7 +438,7 @@ aspect ParserGen {
pStream.println("import java.io.InputStreamReader;");
pStream.println("import java.io.Reader;");
pStream.println("");
pStream.println("import AST.
Siaras
Parser;");
pStream.println("import AST.
OWL
Parser;");
pStream.println("import AST.ParseException;");
pStream.println("import AST.Start;");
pStream.println("");
...
...
@@ -421,7 +448,7 @@ aspect ParserGen {
pStream.println(" Reader r = getReader(args);");
pStream.println(" Start ast = null;");
pStream.println(" try {");
pStream.println("
Siaras
Parser parser = new
Siaras
Parser(r);");
pStream.println("
OWL
Parser parser = new
OWL
Parser(r);");
pStream.println();
pStream.println(" ast = parser.Start();");
pStream.println(" } catch (ParseException e) {");
...
...
Dumper.java
View file @
ee6481dd
...
...
@@ -9,7 +9,7 @@ import AST.Start;
public
class
Dumper
extends
Parser
{
public
static
void
main
(
String
args
[])
{
Start
ast
=
parse
(
args
);
Start
ast
=
parse
(
args
[
0
]
);
// Dump the AST
ast
.
dumpTree
(
" "
,
System
.
out
);
...
...
Names.jrag
View file @
ee6481dd
...
...
@@ -8,5 +8,6 @@
aspect Names {
syn String OClass.name() = getId();
syn String OwlProperty.name() = getId();
syn String OwlRestriction.name() = getRestrictionClassId();
}
Types.jrag
View file @
ee6481dd
...
...
@@ -55,17 +55,19 @@ aspect Types {
syn lazy Properties OwlClassDecl.getProperties() {
List l = new List();
// getTopElement().collectProperties(l);
collectProperties(l);
return new Properties(l);
// Properties p = new Properties();
// for (int i=0; i<l.getNumChild(); i++) {
// OwlProperty op = (OwlProperty) l.getChild(i);
// if (op.domainIncludes(this)) {
// p.addProperty(op);
// }
// }
// return p;
getTopElement().collectProperties(l);
// collectProperties(l);
// return new Properties(l);
Properties p = new Properties();
for (int i=0; i<l.getNumChild(); i++) {
OwlProperty op = (OwlProperty) l.getChild(i);
if (op.domainIncludes(this)) {
p.addProperty(op);
} else {
// System.out.println(op);
}
}
return p;
}
syn lazy ArrayList OClass.getSubClasses();
...
...
@@ -172,6 +174,24 @@ aspect Properties {
return false;
}
boolean OwlFunctionalProperty.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsDomain) {
return ((RdfsDomain) getElement(i)).domainIncludes(clazz);
}
}
return false;
}
boolean OwlDatatypeProperty.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsDomain) {
return ((RdfsDomain) getElement(i)).domainIncludes(clazz);
}
}
return false;
}
boolean RdfsDomain.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).domainIncludes(clazz)) {
...
...
@@ -212,4 +232,20 @@ aspect Properties {
}
return null;
}
eq OwlFunctionalProperty.range() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsRange) {
return (RdfsRange) getElement(i);
}
}
return null;
}
eq OwlDatatypeProperty.range() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsRange) {
return (RdfsRange) getElement(i);
}
}
return null;
}
}
owl.ast
View file @
ee6481dd
...
...
@@ -17,6 +17,7 @@ abstract ComplexElement : Element ::= Attribute* Element*;
RdfDeclaration : ComplexElement;
RdfDescription : ComplexElement;
RdfFirst : ComplexElement;
RdfProperty : ComplexElement;
RdfRest : ComplexElement;
RdfType : ComplexElement;
RdfsComment : ComplexElement;
...
...
@@ -30,7 +31,7 @@ OwlAllValuesFrom : OwlValuesFrom;
OwlCardinality : ComplexElement;
OwlClass : ComplexElement;
OwlDataRange : ComplexElement;
OwlDatatypeProperty :
ComplexElement
;
OwlDatatypeProperty :
OwlProperty
;
OwlDisjointWith : ComplexElement;
OwlDistinctMembers: ComplexElement;
OwlEquivalentClass : ComplexElement;
...
...
owl.jjt
View file @
ee6481dd
...
...
@@ -95,6 +95,7 @@ SPECIAL_TOKEN : /* COMMENTS */
|
<
RDF_DESCRIPTION
:
"rdf:Description"
>
|
<
RDF_ID
:
"rdf:ID"
>
|
<
RDF_FIRST
:
"rdf:first"
>
|
<
RDF_PROPERTY
:
"rdf:Property"
>
|
<
RDF_REST
:
"rdf:rest"
>
|
<
RDF_PARSETYPE
:
"rdf:parseType"
>
|
<
RDF_RESOURCE
:
"rdf:resource"
>
...
...
@@ -204,6 +205,8 @@ SPECIAL_TOKEN : /* COMMENTS */
"+"
,
"-"
,
","
,
"["
,
"]"
,
"."
]
>
...
...
@@ -235,8 +238,8 @@ SPECIAL_TOKEN : /* COMMENTS */
//
|
<
RPAREN
:
")"
>
<
LBRACE
:
"{"
>
|
<
RBRACE
:
"}"
>
|
<
LBRACKET
:
"["
>
|
<
RBRACKET
:
"]"
>
//
|
<
LBRACKET
:
"["
>
//
|
<
RBRACKET
:
"]"
>
|
<
SEMICOLON
:
";"
>
|
<
QUOTE
:
"
\"
"
>
//
|
<
COMMA
:
","
>
...
...
@@ -577,6 +580,7 @@ void RdfElement() : {}
RdfType
()
|
RdfDescription
()
|
RdfFirst
()
|
RdfProperty
()
|
RdfRest
()
|
RdfsComment
()
|
RdfsDomain
()
...
...
@@ -603,6 +607,12 @@ void RdfFirst() #RdfFirst : {}
(
">"
ElementList
()
"</"
<
RDF_FIRST
>
">"
|
ElementList
()
"/>"
)
}
void
RdfProperty
()
#
RdfProperty
:
{}
{
<
RDF_PROPERTY
>
AttributeList
()
(
">"
ElementList
()
"</"
<
RDF_PROPERTY
>
">"
|
ElementList
()
"/>"
)
}
void
RdfRest
()
#
RdfRest
:
{}
{
<
RDF_REST
>
AttributeList
()
...
...
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