1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 23:11:16 +02:00

* 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.
This commit is contained in:
Eelco Dolstra 2010-03-25 12:19:41 +00:00
parent 7482349fe8
commit 8a10360c91
13 changed files with 83 additions and 173 deletions

View file

@ -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);
}
}