about summary refs log tree commit diff
path: root/src/libexpr/expr-to-xml.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-03-25T12·19+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-03-25T12·19+0000
commit8a10360c912bc344ea9ce7f8871a47a6e036552f (patch)
tree09ed76a3e11754ee09c48cd491782848df169063 /src/libexpr/expr-to-xml.cc
parent7482349fe8ba9f285f6c7e53d8573fc367ecff8b (diff)
* Simplify @-patterns: only `{attrs}@name' or `name@{attrs}' are now
  allowed.  So `name1@name2', `{attrs1}@{attrs2}' and so on are now no
  longer legal.  This is no big loss because they were not useful
  anyway.

  This also changes the output of builtins.toXML for @-patterns
  slightly.

Diffstat (limited to 'src/libexpr/expr-to-xml.cc')
-rw-r--r--src/libexpr/expr-to-xml.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/libexpr/expr-to-xml.cc b/src/libexpr/expr-to-xml.cc
index e401001ead..9b3062804e 100644
--- a/src/libexpr/expr-to-xml.cc
+++ b/src/libexpr/expr-to-xml.cc
@@ -44,23 +44,19 @@ static void printPatternAsXML(Pattern pat, XMLWriter & doc)
 {
     ATerm name;
     ATermList formals;
-    Pattern pat1, pat2;
     ATermBool ellipsis;
     if (matchVarPat(pat, name))
         doc.writeEmptyElement("varpat", singletonAttrs("name", aterm2String(name)));
-    else if (matchAttrsPat(pat, formals, ellipsis)) {
-        XMLOpenElement _(doc, "attrspat");
+    else if (matchAttrsPat(pat, formals, ellipsis, name)) {
+        XMLAttrs attrs;
+        if (name != sNoAlias) attrs["name"] = aterm2String(name);
+        if (ellipsis == eTrue) attrs["ellipsis"] = "1";
+        XMLOpenElement _(doc, "attrspat", attrs);
         for (ATermIterator i(formals); i; ++i) {
             Expr name; ATerm dummy;
             if (!matchFormal(*i, name, dummy)) abort();
             doc.writeEmptyElement("attr", singletonAttrs("name", aterm2String(name)));
         }
-        if (ellipsis == eTrue) doc.writeEmptyElement("ellipsis");
-    }
-    else if (matchAtPat(pat, pat1, pat2)) {
-        XMLOpenElement _(doc, "at");
-        printPatternAsXML(pat1, doc);
-        printPatternAsXML(pat2, doc);
     }
 }