Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Jouault2015-03-27 03:08:12 -0400
committerFrédéric Jouault2015-03-27 03:08:12 -0400
commita9aef2ddf017bc9bea5b29c5e401f51977628c0c (patch)
tree5c55e62dd644a5c28e6d3a0006c2725efd84155b
parent39defe8e8d3da658d041e792024872630f5e1972 (diff)
downloadorg.eclipse.atl.tcs-a9aef2ddf017bc9bea5b29c5e401f51977628c0c.tar.gz
org.eclipse.atl.tcs-a9aef2ddf017bc9bea5b29c5e401f51977628c0c.tar.xz
org.eclipse.atl.tcs-a9aef2ddf017bc9bea5b29c5e401f51977628c0c.zip
added support for multiple root templates, alternative serialization, and char (un)escaping in escaped identifiers
-rw-r--r--plugins/org.eclipse.gmt.tcs.extractor/src/org/eclipse/gmt/tcs/extractor/PrettyPrinter.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/plugins/org.eclipse.gmt.tcs.extractor/src/org/eclipse/gmt/tcs/extractor/PrettyPrinter.java b/plugins/org.eclipse.gmt.tcs.extractor/src/org/eclipse/gmt/tcs/extractor/PrettyPrinter.java
index 3afb7be..0581800 100644
--- a/plugins/org.eclipse.gmt.tcs.extractor/src/org/eclipse/gmt/tcs/extractor/PrettyPrinter.java
+++ b/plugins/org.eclipse.gmt.tcs.extractor/src/org/eclipse/gmt/tcs/extractor/PrettyPrinter.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Stack;
@@ -99,8 +100,7 @@ public class PrettyPrinter {
standardSeparator = newStandardSeparator;
Object format = arguments.get("format");
- String rootName = null;
- Object rootTemplate = null;
+ List rootTemplates = new ArrayList();;
for(Iterator i = modelAdapter.getElementsByType(format, "Template").iterator() ; i.hasNext() ; ) {
Object ame = i.next();
String name = this.modelAdapter.getString(ame, "name");
@@ -109,8 +109,7 @@ public class PrettyPrinter {
isMain = this.modelAdapter.getBool(ame, "isMain");
}
if(isMain) {
- rootName = name;
- rootTemplate = ame;
+ rootTemplates.add(ame);
}
if(this.modelAdapter.getTypeName(ame).equals("EnumerationTemplate")) {
@@ -171,8 +170,15 @@ public class PrettyPrinter {
symbols.put(value, new Integer(type));
}
- Iterator possibleRoots = this.modelAdapter.getElementsByType(source, rootName).iterator();
- boolean isMulti = this.modelAdapter.getBool(rootTemplate, "isMulti");
+ List pr = new ArrayList();
+ boolean isMulti = false;
+ for(Iterator i = rootTemplates.iterator() ; i.hasNext() ;) {
+ Object rootTemplate = i.next();
+ String rootName = this.modelAdapter.getString(rootTemplate, "name");
+ pr.addAll(this.modelAdapter.getElementsByType(source, rootName));
+ isMulti |= this.modelAdapter.getBool(rootTemplate, "isMulti");
+ }
+ Iterator possibleRoots = pr.iterator();
boolean first = true;
while(possibleRoots.hasNext()) {
Object root = possibleRoots.next();
@@ -497,6 +503,10 @@ if(debugws) out.debug("</block>");
if(eseq != null) printWSBlockNoDup();
serializeSeq(element, eseq);
}
+ } else if(tn.equals("Alternative")) {
+ warning("alternatives are serialized following their first branch");
+ Object seq = this.modelAdapter.getCol(seqElem, "sequences").next();
+ serializeSeq(element, seq);
} else {
error("unsupported: " + tn);
}
@@ -656,12 +666,18 @@ if(debugws) out.debug("</block>");
// System.out.println(val.matches(regex));
Object start = this.modelAdapter.getME(pattern, "start");
Object end = this.modelAdapter.getME(pattern, "end");
+ Object esc = this.modelAdapter.getME(pattern, "esc");
if(
this.modelAdapter.getTypeName(start).equals("StringPattern")
&&
this.modelAdapter.getTypeName(end).equals("StringPattern")
) {
printDisambiguationWS();
+ if(esc != null && this.modelAdapter.getTypeName(esc).equals("StringPattern")) {
+ if("\\".equals(this.modelAdapter.getString(esc, "name"))) {
+ value = cString((String)value);
+ }
+ }
out.printEscapedIdentifier(this.modelAdapter.getString(start, "name"), (String)value, this.modelAdapter.getString(end, "name"));
typeLast = TYPE_IDENT;
doDefault = false;
@@ -911,7 +927,7 @@ if(debugws) out.debug("</block>");
if(simpleIdent) {
out.printIdentifier(ident);
} else {
- out.printEscapedIdentifier(identEscStart, ident, identEscEnd);
+ out.printEscapedIdentifier(identEscStart, cString(ident), identEscEnd);
}
typeLast = TYPE_IDENT;
}
@@ -987,4 +1003,8 @@ if(debugws) out.debug("</block>");
private void error(String msg) {
System.out.println("ERROR: " + msg);
}
+
+ private void warning(String msg) {
+ System.out.println("WARNING: " + msg);
+ }
}

Back to the top