Skip to content
Snippets Groups Projects
Commit f9dc4449 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Rewrites to ClassDecl and ClassUse. Dump class decls.

parent fdd72990
No related branches found
No related tags found
No related merge requests found
......@@ -9,15 +9,20 @@ aspect CompilerGeneration {
}
}
public void Start.genAbsGrammar(PrintStream p) {
super.genAbsGrammar(p);
public void Start.genAbsGrammar(PrintStream pStream) {
super.genAbsGrammar(pStream);
}
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
/* -*-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
......@@ -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> ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment