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
e83e90c0
Commit
e83e90c0
authored
Dec 11, 2006
by
Anders Nilsson
Browse files
Synching. Class decls. are moved to top level list but it currently fails to replace with ClassUse
parent
1da31eb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
CompilerGeneration.jrag
View file @
e83e90c0
...
@@ -27,7 +27,7 @@ aspect AbsGrammarGeneration {
...
@@ -27,7 +27,7 @@ aspect AbsGrammarGeneration {
pStream.println("StringElement : SimpleElement ::= <IDENTIFIER>;");
pStream.println("StringElement : SimpleElement ::= <IDENTIFIER>;");
pStream.println("IntElement : SimpleElement ::= <INTEGER_LITERAL>;");
pStream.println("IntElement : SimpleElement ::= <INTEGER_LITERAL>;");
pStream.println("FloatElement : SimpleElement ::= <FLOAT_LITERAL>;");
pStream.println("FloatElement : SimpleElement ::= <FLOAT_LITERAL>;");
pStream.println("
abstract
ClassUse :
ComplexElement
::= /decl:Thing/;");
pStream.println("ClassUse :
Thing
::= /decl:Thing/;");
pStream.println("Attribute ::= Value;");
pStream.println("Attribute ::= Value;");
pStream.println("RdfDatatype : Attribute ::= ;");
pStream.println("RdfDatatype : Attribute ::= ;");
pStream.println("RdfId : Attribute ::= ;");
pStream.println("RdfId : Attribute ::= ;");
...
@@ -59,9 +59,6 @@ aspect AbsGrammarGeneration {
...
@@ -59,9 +59,6 @@ aspect AbsGrammarGeneration {
pStream.print(" ::=");
pStream.print(" ::=");
getOwnRestrictions().genAbsGrammar(pStream);
getOwnRestrictions().genAbsGrammar(pStream);
pStream.println(";");
pStream.println(";");
pStream.print(getId()+"Use");
pStream.print(" : ClassUse");
pStream.println(";");
}
}
void Restrictions.genAbsGrammar(PrintStream pStream) {
void Restrictions.genAbsGrammar(PrintStream pStream) {
...
@@ -73,6 +70,7 @@ aspect AbsGrammarGeneration {
...
@@ -73,6 +70,7 @@ aspect AbsGrammarGeneration {
void OwlRestriction.genAbsGrammar(PrintStream pStream) {
void OwlRestriction.genAbsGrammar(PrintStream pStream) {
pStream.print(name());
pStream.print(name());
pStream.print(":Thing");
if (allValuesFrom()) {
if (allValuesFrom()) {
pStream.print("*");
pStream.print("*");
}
}
...
@@ -156,11 +154,20 @@ aspect GenPrettyPrinter {
...
@@ -156,11 +154,20 @@ aspect GenPrettyPrinter {
pStream.println(ind(2)+"System.out.println(indent+\" \"+value());");
pStream.println(ind(2)+"System.out.println(indent+\" \"+value());");
pStream.println(ind(2)+"System.out.println(indent+\"</value>\");");
pStream.println(ind(2)+"System.out.println(indent+\"</value>\");");
pStream.println(ind(1)+"}\n");
pStream.println(ind(1)+"}\n");
// Generate prettyprinter for ClassUse
pStream.println(ind(1)+"public void ClassUse.prettyPrint(String indent, PrintStream pStream) {");
pStream.println(ind(2)+"System.out.print(indent+\"<\"+name());");
pStream.println(ind(2)+"for (int i=0; i<getNumAttribute(); i++) {");
pStream.println(ind(3)+"getAttribute(i).prettyPrint(indent,pStream);");
pStream.println(ind(2)+"}");
pStream.println(ind(2)+"System.out.println(\"/>\");");
pStream.println(ind(1)+"}\n");
super.genPrettyPrinter(pStream);
super.genPrettyPrinter(pStream);
pStream.println("}\n");
pStream.println("}\n");
}
}
public void OwlClassDecl.genPrettyPrinter(PrintStream pStream) {
public void OwlClassDecl.genPrettyPrinter(PrintStream pStream) {
// Generate prettyprinter for class declaration
pStream.print(ind(1)+"public void "+name());
pStream.print(ind(1)+"public void "+name());
pStream.println(".prettyPrint(String indent, PrintStream pStream) {");
pStream.println(".prettyPrint(String indent, PrintStream pStream) {");
pStream.println(ind(2)+"System.out.print(indent+\"<"+name()+"\");");
pStream.println(ind(2)+"System.out.print(indent+\"<"+name()+"\");");
...
@@ -201,7 +208,7 @@ aspect GenRewrites {
...
@@ -201,7 +208,7 @@ aspect GenRewrites {
pStream.println();
pStream.println();
pStream.println("aspect Rewrites {");
pStream.println("aspect Rewrites {");
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(2)+"when (getOwlIdentifier().getIDENTIFIER().equals(\"value\") && !(this instanceof ValueElement))");
pStream.println(ind(2)+"when (
!(this instanceof ClassUse) &&
getOwlIdentifier().getIDENTIFIER().equals(\"value\") && !(this instanceof ValueElement))");
pStream.println(ind(3)+"to ValueElement {");
pStream.println(ind(3)+"to ValueElement {");
pStream.println(ind(3)+"ValueElement node = new ValueElement();");
pStream.println(ind(3)+"ValueElement node = new ValueElement();");
pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());");
pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());");
...
@@ -219,7 +226,7 @@ aspect GenRewrites {
...
@@ -219,7 +226,7 @@ aspect GenRewrites {
int ix = 0;
int ix = 0;
// Specialize ComplexElements to the actual class in the ontology
// Specialize ComplexElements to the actual class in the ontology
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(2)+"when (getOwlIdentifier().getIDENTIFIER().equals(\""+
pStream.println(ind(2)+"when (
!(this instanceof ClassUse) &&
getOwlIdentifier().getIDENTIFIER().equals(\""+
name()+"\") && !(this instanceof Thing))");
name()+"\") && !(this instanceof Thing))");
pStream.println(ind(3)+"to "+name()+" {");
pStream.println(ind(3)+"to "+name()+" {");
...
@@ -260,9 +267,13 @@ aspect GenRewrites {
...
@@ -260,9 +267,13 @@ aspect GenRewrites {
// current diagonal style from Protege
// current diagonal style from Protege
pStream.println(ind(1)+"rewrite "+name()+" {");
pStream.println(ind(1)+"rewrite "+name()+" {");
pStream.println(ind(2)+"when (!isTopElement())");
pStream.println(ind(2)+"when (!isTopElement())");
pStream.println(ind(2)+"to "+name()+"Use {");
pStream.println(ind(2)+"to ClassUse {");
pStream.println(ind(3)+"ClassUse use = new ClassUse();");
pStream.println(ind(3)+"use.setOwlIdentifier(new OwlIdentifier(\""+name()+"\"));");
pStream.println(ind(3)+"use.setAttributeList(new List().add(new RdfResource(getAttribute(0).getValue())));");
pStream.println(ind(3)+"use.setElementList(new List());");
pStream.println(ind(3)+"getStart().addElement(this);");
pStream.println(ind(3)+"getStart().addElement(this);");
pStream.println(ind(3)+"return
new "+name()+"Use()
;");
pStream.println(ind(3)+"return
use
;");
pStream.println(ind(2)+"}");
pStream.println(ind(2)+"}");
pStream.println(ind(1)+"}");
pStream.println(ind(1)+"}");
}
}
...
@@ -306,6 +317,10 @@ aspect GenMisc {
...
@@ -306,6 +317,10 @@ aspect GenMisc {
pStream.println(ind(2)+"return this;");
pStream.println(ind(2)+"return this;");
pStream.println(ind(1)+"}");
pStream.println(ind(1)+"}");
pStream.println(ind(1)+"String ComplexElement.name() {");
pStream.println(ind(2)+"return getOwlIdentifier().getIDENTIFIER();");
pStream.println(ind(1)+"}");
super.genMisc(pStream);
super.genMisc(pStream);
pStream.println("}");
pStream.println("}");
...
...
siaras/Statistics.jrag
View file @
e83e90c0
/* -*-Java-*- */
/*
/*
* Copyright (C) 2006 Anders Nilsson <anders.nilsson@cs.lth.se>
* Copyright (C) 2006 Anders Nilsson <anders.nilsson@cs.lth.se>
...
@@ -9,15 +10,23 @@ import java.io.PrintStream;
...
@@ -9,15 +10,23 @@ import java.io.PrintStream;
aspect Statistics {
aspect Statistics {
public void ASTNode.getManipulationDevices(PrintStream pStream) {
public void ASTNode.getManipulationDevices(PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) {
// for (int i=0; i<getNumChild(); i++) {
getChild(i).getManipulationDevices(pStream);
// getChild(i).getManipulationDevices(pStream);
// }
}
public void Start.getManipulationDevices(PrintStream pStream) {
for (int i=0; i<getNumElement(); i++) {
getElement(i).getManipulationDevices(pStream);
}
}
}
}
public void Thing.getManipulationDevices(PrintStream pStream) {
public void Thing.getManipulationDevices(PrintStream pStream) {
for (int i=0; i<getNumElement(); i++) {
for (int i=0; i<getNumElement(); i++) {
getElement(i).getManipulationDevices(pStream);
getElement(i).getManipulationDevices(pStream);
}
}
}
}
public void ManipulationAndHandling.getManipulationDevices(PrintStream pStream) {
public void ManipulationAndHandling.getManipulationDevices(PrintStream pStream) {
pStream.println(" "+getOwlIdentifier().getIDENTIFIER()+
pStream.println(" "+getOwlIdentifier().getIDENTIFIER()+
" : "+getAttribute(0).getValue().getSTRING_LITERAL());
" : "+getAttribute(0).getValue().getSTRING_LITERAL());
...
@@ -26,10 +35,17 @@ aspect Statistics {
...
@@ -26,10 +35,17 @@ aspect Statistics {
public void ASTNode.getSensors(PrintStream pStream) {
public void ASTNode.getSensors(PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) {
// for (int i=0; i<getNumChild(); i++) {
getChild(i).getSensors(pStream);
// getChild(i).getSensors(pStream);
// }
}
public void Start.getSensors(PrintStream pStream) {
for (int i=0; i<getNumElement(); i++) {
getElement(i).getSensors(pStream);
}
}
}
}
public void Thing.getSensors(PrintStream pStream) {
public void Thing.getSensors(PrintStream pStream) {
for (int i=0; i<getNumElement(); i++) {
for (int i=0; i<getNumElement(); i++) {
getElement(i).getSensors(pStream);
getElement(i).getSensors(pStream);
...
...
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