diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-18 20:14:54 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-18 20:16:02 +0100 |
commit | fc33fd86b7727365caab44c05a90d5b52209131b (patch) | |
tree | ba12d5e943e0e3b0d9aa5a9e25f1fa784dc369f0 /src/libexpr/parser.y | |
parent | 90b5e692846d9b7a951155c5ed4fc7cf72b08e31 (diff) | |
download | guix-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.y | 7 |
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. */ |