about summary refs log tree commit diff
path: root/src/nix-instantiate
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-instantiate')
-rw-r--r--src/nix-instantiate/help.txt2
-rw-r--r--src/nix-instantiate/nix-instantiate.cc15
2 files changed, 11 insertions, 6 deletions
diff --git a/src/nix-instantiate/help.txt b/src/nix-instantiate/help.txt
index fa0a4590ee92..21822132aece 100644
--- a/src/nix-instantiate/help.txt
+++ b/src/nix-instantiate/help.txt
@@ -22,6 +22,8 @@ Options:
 For --eval-only / --parse-only:
 
   --xml: print an XML representation of the abstract syntax tree
+  --no-location: don't provide source location information in the
+    output XML tree
 
 For --eval-only:
 
diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc
index d8b39eca2694..03fb35ada18e 100644
--- a/src/nix-instantiate/nix-instantiate.cc
+++ b/src/nix-instantiate/nix-instantiate.cc
@@ -39,13 +39,13 @@ static bool indirectRoot = false;
 
 
 static void printResult(EvalState & state, Expr e,
-    bool evalOnly, bool xmlOutput, const ATermMap & autoArgs)
+    bool evalOnly, bool xmlOutput, bool location, const ATermMap & autoArgs)
 {
     PathSet context;
     
     if (evalOnly)
         if (xmlOutput)
-            printTermAsXML(e, std::cout, context);
+            printTermAsXML(e, std::cout, context, location);
         else
             std::cout << format("%1%\n") % canonicaliseExpr(e);
     
@@ -68,7 +68,7 @@ static void printResult(EvalState & state, Expr e,
 
 void processExpr(EvalState & state, const Strings & attrPaths,
     bool parseOnly, bool strict, const ATermMap & autoArgs,
-    bool evalOnly, bool xmlOutput, Expr e)
+    bool evalOnly, bool xmlOutput, bool location, Expr e)
 {
     for (Strings::const_iterator i = attrPaths.begin(); i != attrPaths.end(); ++i) {
         Expr e2 = findAlongAttrPath(state, *i, autoArgs, e);
@@ -77,7 +77,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
                 e2 = strictEvalExpr(state, e2);
             else
                 e2 = evalExpr(state, e2);
-        printResult(state, e2, evalOnly, xmlOutput, autoArgs);
+        printResult(state, e2, evalOnly, xmlOutput, location, autoArgs);
     }
 }
 
@@ -90,6 +90,7 @@ void run(Strings args)
     bool evalOnly = false;
     bool parseOnly = false;
     bool xmlOutput = false;
+    bool xmlOutputSourceLocation = true;
     bool strict = false;
     Strings attrPaths;
     ATermMap autoArgs(128);
@@ -125,6 +126,8 @@ void run(Strings args)
             indirectRoot = true;
         else if (arg == "--xml")
             xmlOutput = true;
+        else if (arg == "--no-location")
+            xmlOutputSourceLocation = false;
         else if (arg == "--strict")
             strict = true;
         else if (arg[0] == '-')
@@ -140,7 +143,7 @@ void run(Strings args)
     if (readStdin) {
         Expr e = parseStdin(state);
         processExpr(state, attrPaths, parseOnly, strict, autoArgs,
-            evalOnly, xmlOutput, e);
+            evalOnly, xmlOutput, xmlOutputSourceLocation, e);
     }
 
     for (Strings::iterator i = files.begin();
@@ -149,7 +152,7 @@ void run(Strings args)
         Path path = absPath(*i);
         Expr e = parseExprFromFile(state, path);
         processExpr(state, attrPaths, parseOnly, strict, autoArgs,
-            evalOnly, xmlOutput, e);
+            evalOnly, xmlOutput, xmlOutputSourceLocation, e);
     }
 
     printEvalStats(state);