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
2c2fb5ee
Commit
2c2fb5ee
authored
Dec 04, 2006
by
Anders Nilsson
Browse files
Synching, improving PrettyPrinter generation
parent
c354bac0
Changes
2
Hide whitespace changes
Inline
Side-by-side
CompilerGeneration.jrag
View file @
2c2fb5ee
...
...
@@ -111,18 +111,18 @@ aspect GenAspects {
pStream.println("import java.io.PrintStream;");
pStream.println();
genRewrites(pStream);
genPrettyPrinter(
" ",
pStream);
genPrettyPrinter(pStream);
}
}
aspect GenPrettyPrinter {
public void ASTNode.genPrettyPrinter(
String ind,
PrintStream pStream) {
public void ASTNode.genPrettyPrinter(PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) {
getChild(i).genPrettyPrinter(
ind,
pStream);
getChild(i).genPrettyPrinter(pStream);
}
}
public void Start.genPrettyPrinter(
String ind,
PrintStream pStream) {
public void Start.genPrettyPrinter(PrintStream pStream) {
pStream.println();
pStream.println("aspect PrettyPrinter {");
pStream.println(" public void ASTNode.prettyPrint(String indent, PrintStream pStream) {");
...
...
@@ -135,28 +135,36 @@ aspect GenPrettyPrinter {
pStream.println(" getElement(i).prettyPrint(indent,pStream);");
pStream.println(" }");
pStream.println(" }\n");
super.genPrettyPrinter(
ind,
pStream);
super.genPrettyPrinter(pStream);
pStream.println("}\n");
}
public void OwlClassDecl.genPrettyPrinter(
String ind,
PrintStream pStream) {
pStream.print(
"
public void "+name());
public void OwlClassDecl.genPrettyPrinter(PrintStream pStream) {
pStream.print(
ind(1)+"
public void "+name());
pStream.println(".prettyPrint(String indent, PrintStream pStream) {");
pStream.print
("
System.out.print
ln
(indent+\"<"+name());
//
for (int i=0; i<getNumAttribute(); i++) {
//
getAttribute(i).
genP
rettyPrint
er
(ind,pStream);
// }
pStream.println(">\");");
pStream.println(
"
String childIndent = indent + \" \";");
pStream.print
ln(ind(2)+"
System.out.print(indent+\"<"+name()
+"\");"
);
pStream.println(ind(2)+"
for (int i=0; i<getNumAttribute(); i++) {
");
pStream.println(ind(3)+"
getAttribute(i).
p
rettyPrint(ind
ent
,pStream);
");
pStream.println(ind(2)+"}");
pStream.println("
System.out.println(\"
>\");");
pStream.println(
ind(2)+"
String childIndent = indent + \" \";");
Restrictions restr = getRestrictions();
for (int i=0; i<restr.getNumOwlRestriction(); i++) {
OwlRestriction r = restr.getOwlRestriction(i);
pStream.println(ind(2)+"System.out.println(childIndent+\"<has"+
r.name()+">\");");
pStream.println(ind(2)+"for (int i=0; i<getNum"+r.name()+"(); i++) {");
pStream.println(ind(3)+"get"+r.name()+
"(i).prettyPrint(childIndent+\" \",pStream);");
pStream.println(ind(2)+"}");
pStream.println(ind(2)+"System.out.println(childIndent+\"</has"+
r.name()+">\");");
}
pStream.println(" for (int i=0; i<getNumElement(); i++) {");
pStream.println(" getElement(i).prettyPrint(childIndent,pStream);");
pStream.println(" }");
pStream.println(
"
System.out.println(indent+\"</"+name()+">\");");
pStream.println("}\n");
//
pStream.println(
ind(1)+
" for (int i=0; i<getNumElement(); i++) {");
//
pStream.println(
ind(1)+
" getElement(i).prettyPrint(childIndent,pStream);");
//
pStream.println(
ind(1)+
" }");
pStream.println(
ind(1)+"
System.out.println(indent+\"</"+name()+">\");");
pStream.println(
ind(1)+
"}\n");
}
}
...
...
@@ -193,8 +201,9 @@ aspect GenRewrites {
OwlRestriction r = restr.getOwlRestriction(i);
pStream.println(ind(3)+"l = new List();");
pStream.println(ind(3)+"for (int i=0; i<getNumElement(); i++) {");
pStream.println(ind(4)+"if (getElement(i) instanceof "+r.name()+") {");
pStream.println(ind(5)+"l.add(getElement(i));");
pStream.println(ind(3)+"ComplexElement e = (ComplexElement) getElement(i);");
pStream.println(ind(4)+"if (e.getNumElement() > 0 && e.getElement(0) instanceof "+r.name()+") {");
pStream.println(ind(5)+"l.add(e.getElement(0));");
pStream.println(ind(4)+"}");
pStream.println(ind(3)+"}");
if (r.allValuesFrom()) {
...
...
testontologies/small_v08.owl
0 → 100644
View file @
2c2fb5ee
<VacuumGripper rdf:ID="Schmalz_FSGPL_200_NBR-55_G1-2-IG">
<hasProperty>
<DiameterOfGripper rdf:ID="DiameterOfGripper_200">
<isPropertyOf rdf:resource="#Schmalz_FSGPL_200_NBR-55_G1-2-IG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>200.0</value>
</DiameterOfGripper>
</hasProperty>
<hasProperty>
<Worm rdf:ID="Worm_Inside">
<isPropertyOf rdf:resource="#Schmalz_FSGPL_200_NBR-55_G1-2-IG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Inside</value>
</Worm>
</hasProperty>
<hasSkill>
<AdjustVacuumToGrip rdf:ID="AdjustVacuumToGrip_16">
<isSkillOf rdf:resource="#Schmalz_FSGPL_200_NBR-55_G1-2-IG"/>
<isSkillOf>
<VacuumGripper rdf:ID="Schmalz_FSGA_20_SI-55_M5-AG">
<hasSkill rdf:resource="#AdjustVacuumToGrip_16"/>
<hasProperty>
<WormDiameter rdf:ID="WormDiameter_M5">
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>M5</value>
<isPropertyOf rdf:resource="#Schmalz_FSGA_20_SI-55_M5-AG"/>
</WormDiameter>
</hasProperty>
<hasProperty>
<Worm rdf:ID="Worm_Outside">
<isPropertyOf rdf:resource="#Schmalz_FSGA_20_SI-55_M5-AG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Outside</value>
</Worm>
</hasProperty>
<hasProperty>
<DiameterOfGripper rdf:ID="DiameterOfGripper_20">
<isPropertyOf rdf:resource="#Schmalz_FSGA_20_SI-55_M5-AG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>20.0</value>
</DiameterOfGripper>
</hasProperty>
<hasProperty>
<Material rdf:ID="Material_Silikon">
<isPropertyOf rdf:resource="#Schmalz_FSGA_20_SI-55_M5-AG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Silikon SI 55+-5</value>
</Material>
</hasProperty>
<hasSkill>
<AdjustVacuumToRelease rdf:ID="AdjustVacuumToRelease_1">
<isSkillOf rdf:resource="#Schmalz_FSGA_20_SI-55_M5-AG"/>
<isSkillOf rdf:resource="#Schmalz_FSGPL_200_NBR-55_G1-2-IG"/>
</AdjustVacuumToRelease>
</hasSkill>
<hasProperty>
<MaxForce rdf:ID="MaximumForce_4.7">
<isPropertyOf rdf:resource="#Schmalz_FSGA_20_SI-55_M5-AG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>4.7</value>
</MaxForce>
</hasProperty>
</VacuumGripper>
</isSkillOf>
</AdjustVacuumToGrip>
</hasSkill>
<hasProperty>
<Material rdf:ID="Material_Perbunan">
<isPropertyOf rdf:resource="#Schmalz_FSGPL_200_NBR-55_G1-2-IG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Perbunan NBR 55+-5</value>
</Material>
</hasProperty>
<hasProperty>
<MaxForce rdf:ID="MaximumForce_850">
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>850.0</value>
<isPropertyOf rdf:resource="#Schmalz_FSGPL_200_NBR-55_G1-2-IG"/>
</MaxForce>
</hasProperty>
<hasProperty>
<WormDiameter rdf:ID="WormDiameter_G1-2">
<isPropertyOf rdf:resource="#Schmalz_FSGPL_200_NBR-55_G1-2-IG"/>
<value rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>G1/2</value>
</WormDiameter>
</hasProperty>
<hasSkill rdf:resource="#AdjustVacuumToRelease_1"/>
</VacuumGripper>
<!-- Created with Protege (with OWL Plugin 2.2, Build 311) http://protege.stanford.edu -->
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