Add $__loc__ (fix #740)

This commit is contained in:
Nicolas Williams committed 2015-03-30 22:36:04 -05:00
1 parent 1dcfc2f547
commit 24005287f4
10 files changed
+1178 -1152

No files matched your search

+5
View File
@@ -72,6 +72,7 @@ struct lexer_param;
%token CATCH "catch"
%token LABEL "label"
%token BREAK "break"
%token LOC "__loc__"
%token SETPIPE "|="
%token SETPLUS "+="
%token SETMINUS "-="
@@ -691,6 +692,10 @@ FORMAT {
else
$$ = BLOCK(gen_subexp(gen_const(jv_object())), $2, gen_op_simple(POP));
} |
'$' LOC {
$$ = gen_const(JV_OBJECT(jv_string("file"), jv_copy(locations->fname),
jv_string("line"), jv_number(locfile_get_line(locations, @$.start) + 1)));
} |
'$' IDENT {
$$ = gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($2)));
jv_free($2);