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
f9dc4449
Commit
f9dc4449
authored
19 years ago
by
Anders Nilsson
Browse files
Options
Downloads
Patches
Plain Diff
Rewrites to ClassDecl and ClassUse. Dump class decls.
parent
fdd72990
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CompilerGeneration.jrag
+12
-7
12 additions, 7 deletions
CompilerGeneration.jrag
Rewrites.jrag
+68
-6
68 additions, 6 deletions
Rewrites.jrag
owl.ast
+1
-1
1 addition, 1 deletion
owl.ast
with
81 additions
and
14 deletions
CompilerGeneration.jrag
+
12
−
7
View file @
f9dc4449
...
...
@@ -9,15 +9,20 @@ aspect CompilerGeneration {
}
}
public void Start.genAbsGrammar(PrintStream p) {
super.genAbsGrammar(p);
public void Start.genAbsGrammar(PrintStream p
Stream
) {
super.genAbsGrammar(p
Stream
);
}
void OwlClass.genAbsGrammar(PrintStream pStream) {
pStream.println(getAttribute(0).getValue().getSTRING_LITERAL());
void OwlClassDecl.genAbsGrammar(PrintStream pStream) {
pStream.print("OwlClassDecl: ");
pStream.println(getId());
super.genAbsGrammar(pStream);
}
void OwlClassUse.genAbsGrammar(PrintStream pStream) {
// pStream.print("OwlClassUse: ");
// pStream.println(getId());
super.genAbsGrammar(pStream);
}
}
aspect Name {
// syn String Element
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Rewrites.jrag
+
68
−
6
View file @
f9dc4449
/* -*-Java-*- */
aspect MiscUtilities {
boolean Element.isTopLevel() {
if ( getParent() != null ) {
return getParent().getParent() instanceof RdfDeclaration;
} else {
return false;
}
}
String Element.trim(Attribute a) {
String s = a.getValue().getSTRING_LITERAL();
if (s.indexOf('"') == 0) {
s = s.substring(1,s.length()-1).trim();
}
if (s.indexOf('#') == 0) {
s = s.substring(1,s.length()).trim();
}
return s.trim();
}
boolean ComplexElement.hasRdfId() {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfId) {
return true;
}
}
return false;
}
boolean ComplexElement.hasRdfAbout() {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfAbout) {
return true;
}
}
return false;
}
String ComplexElement.getId() {
if (hasRdfId()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfId) {
return trim(getAttribute(i));
}
}
} else if (hasRdfAbout()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfAbout) {
return trim(getAttribute(i));
}
}
}
// Fall through. Could not find Id, so let's return something
// well known
return "_Unknown_";
}
}
aspect RewriteClasses {
// rewrite OwlClass {
// when (isTopLevel())
// to OwlClassDecl {
// }
// }
rewrite OwlClass {
when (isTopLevel())
to OwlClassDecl {
return new OwlClassDecl(new List(), getElementList(), getId());
}
when (!isTopLevel())
to OwlClassUse {
return new OwlClassUse(new List(), getElementList(), getId());
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
owl.ast
+
1
−
1
View file @
f9dc4449
...
...
@@ -52,6 +52,6 @@ Value ::= <STRING_LITERAL>;
// Types generated by rewrite rules
abstract Class;
abstract Class
: ComplexElement
;
OwlClassDecl : Class ::= <Id:String> ;
OwlClassUse : Class ::= <Id:String> ;
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