Commit b3022c9e authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Synching. There's some problem with OtherTokens as parts of string elements.

parent 2b273a00
......@@ -22,6 +22,7 @@ aspect AbsGrammarGeneration {
pStream.println("abstract Thing : ComplexElement ::=;");
pStream.println("abstract Element;");
pStream.println("ComplexElement : Element ::= OwlIdentifier Attribute* Element*;");
pStream.println("ValueElement : ComplexElement;");
pStream.println("abstract SimpleElement : Element;");
pStream.println("StringElement : SimpleElement ::= OwlIdentifier;");
pStream.println("IntElement : SimpleElement ::= <INTEGER_LITERAL>;");
......@@ -184,6 +185,16 @@ aspect GenRewrites {
public void Start.genRewrites(PrintStream pStream) {
pStream.println();
pStream.println("aspect Rewrites {");
pStream.println(ind(1)+"rewrite ComplexElement {");
pStream.println(ind(2)+"when (getOwlIdentifier().getIDENTIFIER().equals(\"value\") && !(this instanceof ValueElement))");
pStream.println(ind(3)+"to ValueElement {");
pStream.println(ind(3)+"ValueElement node = new ValueElement();");
pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());");
pStream.println(ind(3)+"node.setAttributeList(getAttributeList());");
pStream.println(ind(3)+"node.setElementList(getElementList());");
pStream.println(ind(3)+"return node;");
pStream.println(ind(2)+"}");
pStream.println(ind(1)+"}");
super.genRewrites(pStream);
pStream.println("}");
}
......@@ -199,15 +210,16 @@ aspect GenRewrites {
pStream.println(ind(3)+name()+" node = new "+name()+"();");
pStream.println(ind(3)+"node.setOwlIdentifier(getOwlIdentifier());");
pStream.println(ind(3)+"node.setAttributeList(getAttributeList());");
pStream.println(ind(3)+"node.setElementList(getElementList());");
// pStream.println(ind(3)+"node.setElementList(getElementList());");
Restrictions restr = getRestrictions();
pStream.println(ind(3)+"List l;");
pStream.println(ind(3)+"List l, remain;");
pStream.println(ind(3)+"remain = new List();");
for (int i=0; i<restr.getNumOwlRestriction(); i++) {
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(3)+"ComplexElement e = (ComplexElement) getElement(i);");
pStream.println(ind(4)+"if (e.getNumElement() > 0 && e.getElement(0) instanceof "+r.name()+") {");
pStream.println(ind(4)+"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)+"}");
......@@ -218,6 +230,12 @@ aspect GenRewrites {
pStream.println(ind(3)+"node.set"+r.name()+"(c"+(ix++)+");");
}
}
pStream.println(ind(3)+"for (int i=0; i<getNumElement(); i++) {");
pStream.println(ind(4)+"if (getElement(i) instanceof ValueElement) {");
pStream.println(ind(5)+"remain.add(getElement(i));");
pStream.println(ind(4)+"}");
pStream.println(ind(3)+"}");
pStream.println(ind(3)+"node.setElementList(remain);");
pStream.println(ind(3)+"return node;");
pStream.println(ind(2)+"}");
pStream.println(ind(1)+"}");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment