Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OwlCompiler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Nilsson
OwlCompiler
Commits
849be243
Commit
849be243
authored
18 years ago
by
Anders Nilsson
Browse files
Options
Downloads
Patches
Plain Diff
Generalized JavaCC generation a bit
parent
dcb4a4c1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CompilerGeneration.jrag
+18
-6
18 additions, 6 deletions
CompilerGeneration.jrag
Types.jrag
+30
-1
30 additions, 1 deletion
Types.jrag
owl.ast
+3
-3
3 additions, 3 deletions
owl.ast
with
51 additions
and
10 deletions
CompilerGeneration.jrag
+
18
−
6
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("}");
}
...
...
This diff is collapsed.
Click to expand it.
Types.jrag
+
30
−
1
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;
...
...
@@ -73,11 +73,40 @@ aspect Restrictions {
}
}
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 {
...
...
This diff is collapsed.
Click to expand it.
owl.ast
+
3
−
3
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;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment