Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Nilsson
OwlCompiler
Commits
849be243
Commit
849be243
authored
Nov 10, 2006
by
Anders Nilsson
Browse files
Generalized JavaCC generation a bit
parent
dcb4a4c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
CompilerGeneration.jrag
View file @
849be243
...
...
@@ -19,7 +19,7 @@ aspect AbsGrammarGeneration {
pStream.print(getId());
pStream.print(" : "+getSuperClass().getId());
pStream.print(" ::=");
Restrictions restrs = getRestrictions();
Restrictions restrs = get
Own
Restrictions();
for (int i=0; i<restrs.getNumOwlRestriction(); i++) {
pStream.print(" ");
restrs.getOwlRestriction(i).genAbsGrammar(pStream);
...
...
@@ -138,13 +138,25 @@ aspect JavaCCGen {
pStream.println("void "+getId()+"() : {}");
pStream.println("{");
if (getId().equals("Device")) {
pStream.print("\"<\" <DEVICE> \">\"");
pStream.print("(Property())* (Skill())* MainFunction() #");
pStream.println("Device("+getNumRestriction()+")");
pStream.print("\"<\" ( <DEVICE> \">\"");
Restrictions restr = getRestrictions();
for (int i=0; i< getNumRestriction(); i++) {
OwlRestriction res = restr.getOwlRestriction(i);
pStream.print("("+res.getRestrictionClassId()+")"+
(res.allValuesFrom()?"*":"")+" ");
}
pStream.println(" #Device("+getNumRestriction()+")");
// List all subclasses
pStream.println(")");
} else {
pStream.print(" <"+getId().toUpperCase()+"> \">\"");
pStream.print("(Property())* (Skill())* MainFunction() #");
pStream.println(getId()+"("+getNumRestriction()+")");
Restrictions restr = getRestrictions();
for (int i=0; i< getNumRestriction(); i++) {
OwlRestriction res = restr.getOwlRestriction(i);
pStream.print("("+res.getRestrictionClassId()+")"+
(res.allValuesFrom()?"*":"")+" ");
}
pStream.println(" #"+getId()+"("+getNumRestriction()+")");
}
pStream.println("}");
}
...
...
Types.jrag
View file @
849be243
...
...
@@ -56,12 +56,12 @@ aspect Types {
aspect Restrictions {
Restrictions OwlClassDecl.restrictions;
Restrictions OwlClassDecl.ownRestrictions;
syn lazy Restrictions OwlClassDecl.getRestrictions() {
if (restrictions == null) {
List l = new List();
collectRestrictions(l);
getSuperClass().decl().collectRestrictions(l);
restrictions = new Restrictions(l);
}
return restrictions;
...
...
@@ -72,12 +72,41 @@ aspect Restrictions {
getChild(i).collectRestrictions(l);
}
}
void OwlClassDecl.collectRestrictions(List l) {
if (!getSuperClass().getId().equals("Thing")) {
getSuperClass().decl().collectRestrictions(l);
}
super.collectRestrictions(l);
}
void OwlRestriction.collectRestrictions(List l) {
l.add(this);
}
syn int OwlClassDecl.getNumRestriction() = getRestrictions().getNumOwlRestriction();
syn lazy Restrictions OwlClassDecl.getOwnRestrictions() {
if (ownRestrictions == null) {
List l = new List();
collectOwnRestrictions(l);
ownRestrictions = new Restrictions(l);
}
return ownRestrictions;
}
void ASTNode.collectOwnRestrictions(List l) {
for (int i=0; i<getNumChild(); i++) {
getChild(i).collectOwnRestrictions(l);
}
}
void OwlRestriction.collectOwnRestrictions(List l) {
l.add(this);
}
syn int OwlClassDecl.getNumOwnRestriction() =
getOwnRestrictions().getNumOwlRestriction();
}
aspect Properties {
...
...
owl.ast
View file @
849be243
...
...
@@ -64,9 +64,9 @@ Value ::= <STRING_LITERAL>;
// Types used by rewrite rules
abstract OClass : ComplexElement;
OwlClassDecl : OClass
::= <Id:String>
;
OwlClassUse : OClass
::= <Id:String>
;
abstract OClass : ComplexElement
::= <Id:String>
;
OwlClassDecl : OClass;
OwlClassUse : OClass;
abstract OwlValuesFrom: ComplexElement;
...
...
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