ruby-changes:53007
From: yui-knk <ko1@a...>
Date: Sat, 20 Oct 2018 19:10:50 +0900 (JST)
Subject: [ruby-changes:53007] yui-knk:r65221 (trunk): Fix locations of NODE_LAMBDA.
yui-knk 2018-10-20 19:10:46 +0900 (Sat, 20 Oct 2018) New Revision: 65221 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65221 Log: Fix locations of NODE_LAMBDA. * node.h: Add `nd_first_loc` and `nd_set_first_loc` * parse.y: Fix to start with the beginning of `->` . e.g. The locations of the NODE_LAMBDA is fixed: ``` -> x { 1 + 2 } ``` * Before ``` NODE_LAMBDA (line: 1, location: (1,2)-(1,14)) ``` * After ``` NODE_LAMBDA (line: 1, location: (1,0)-(1,14)) ``` Modified files: trunk/node.h trunk/parse.y Index: node.h =================================================================== --- node.h (revision 65220) +++ node.h (revision 65221) @@ -192,6 +192,8 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L192 #define nd_set_first_column(n, v) ((n)->nd_loc.beg_pos.column = (v)) #define nd_first_lineno(n) ((int)((n)->nd_loc.beg_pos.lineno)) #define nd_set_first_lineno(n, v) ((n)->nd_loc.beg_pos.lineno = (v)) +#define nd_first_loc(n) ((n)->nd_loc.beg_pos) +#define nd_set_first_loc(n, v) (nd_first_loc(n) = (v)) #define nd_last_column(n) ((int)((n)->nd_loc.end_pos.column)) #define nd_set_last_column(n, v) ((n)->nd_loc.end_pos.column = (v)) Index: parse.y =================================================================== --- parse.y (revision 65220) +++ parse.y (revision 65221) @@ -2443,6 +2443,9 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2443 lambda { $$ = $3; + /*%%%*/ + nd_set_first_loc($$, @1.beg_pos); + /*% %*/ } | k_if expr_value then compstmt -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/