* Print attributes in sorted order, rather than the arbitrary order
produced by ATermMap. Necessary for testing. * `--strict' should also work on stdin.
This commit is contained in:
parent
22ba63df16
commit
24e234a2fa
1 changed files with 22 additions and 9 deletions
|
@ -75,9 +75,12 @@ static void printTermAsXML(Expr e, XMLWriter & doc)
|
||||||
XMLOpenElement _(doc, "attrs");
|
XMLOpenElement _(doc, "attrs");
|
||||||
ATermMap attrs(128);
|
ATermMap attrs(128);
|
||||||
queryAllAttrs(e, attrs);
|
queryAllAttrs(e, attrs);
|
||||||
for (ATermMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
|
StringSet names;
|
||||||
XMLOpenElement _(doc, "attr", singletonAttrs("name", aterm2String(i->key)));
|
for (ATermMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i)
|
||||||
printTermAsXML(i->value, doc);
|
names.insert(aterm2String(i->key));
|
||||||
|
for (StringSet::iterator i = names.begin(); i != names.end(); ++i) {
|
||||||
|
XMLOpenElement _(doc, "attr", singletonAttrs("name", *i));
|
||||||
|
printTermAsXML(attrs.get(toATerm(*i)), doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +178,18 @@ Expr strictEval(EvalState & state, Expr e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Expr doEval(EvalState & state, string attrPath, bool parseOnly, bool strict, Expr e)
|
||||||
|
{
|
||||||
|
e = findAlongAttrPath(state, attrPath, e);
|
||||||
|
if (!parseOnly)
|
||||||
|
if (strict)
|
||||||
|
e = strictEval(state, e);
|
||||||
|
else
|
||||||
|
e = evalExpr(state, e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void run(Strings args)
|
void run(Strings args)
|
||||||
{
|
{
|
||||||
EvalState state;
|
EvalState state;
|
||||||
|
@ -236,8 +251,8 @@ void run(Strings args)
|
||||||
openDB();
|
openDB();
|
||||||
|
|
||||||
if (readStdin) {
|
if (readStdin) {
|
||||||
Expr e = findAlongAttrPath(state, attrPath, parseStdin(state));
|
Expr e = parseStdin(state);
|
||||||
if (!parseOnly) e = evalExpr(state, e);
|
e = doEval(state, attrPath, parseOnly, strict, e);
|
||||||
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,10 +260,8 @@ void run(Strings args)
|
||||||
i != files.end(); i++)
|
i != files.end(); i++)
|
||||||
{
|
{
|
||||||
Path path = absPath(*i);
|
Path path = absPath(*i);
|
||||||
Expr e = findAlongAttrPath(state, attrPath,
|
Expr e = parseExprFromFile(state, path);
|
||||||
parseExprFromFile(state, path));
|
e = doEval(state, attrPath, parseOnly, strict, e);
|
||||||
if (!parseOnly) e = evalExpr(state, e);
|
|
||||||
if (strict) e = strictEval(state, e);
|
|
||||||
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue