summary refs log tree commit diff
path: root/src/libexpr/parser.y
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-18 20:14:54 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-18 20:16:02 +0100
commitfc33fd86b7727365caab44c05a90d5b52209131b (patch)
treeba12d5e943e0e3b0d9aa5a9e25f1fa784dc369f0 /src/libexpr/parser.y
parent90b5e692846d9b7a951155c5ed4fc7cf72b08e31 (diff)
downloadguix-fc33fd86b7727365caab44c05a90d5b52209131b.tar.gz
Add a symbol __curPos that expands to the current source location
I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r--src/libexpr/parser.y7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index b4f72e599b..7699cf502b 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -355,7 +355,12 @@ expr_select
   ;
 
 expr_simple
-  : ID { $$ = new ExprVar(CUR_POS, data->symbols.create($1)); }
+  : ID {
+      if (strcmp($1, "__curPos") == 0)
+          $$ = new ExprPos(CUR_POS);
+      else
+          $$ = new ExprVar(CUR_POS, data->symbols.create($1));
+  }
   | INT { $$ = new ExprInt($1); }
   | '"' string_parts '"' {
       /* For efficiency, and to simplify parse trees a bit. */