summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2017-12-05parse.y: nd_line of call_uni_opnobu
* parse.y (call_uni_op): set nd_line to the unary operator location, same as non-operator method calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05parse.y: nd_line of logopnobu
* parse.y (logop): set nd_line to the logical operator location, same as non-operator method calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05parse.y: nd_line of match_opnobu
* parse.y (match_op): set nd_line to the match operator location, same as non-operator method calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05parse.y: nd_line of call_bin_opnobu
* parse.y (call_bin_op): set nd_line to the binary operator location, same as non-operator method calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04parse.y: Fix locations of NODE_*ASGN and NODE_ERRINFOyui-knk
* parse.y: Fix to only include a range of exc_var. e.g. The locations of the NODE_DASGN_CURR and NODE_ERRINFO are fixed: ``` begin 1 rescue => e 2 end ``` * Before ``` NODE_DASGN_CURR (line: 3, first_lineno: 3, first_column: 0, last_lineno: 5, last_column: 3) NODE_ERRINFO (line: 5, first_lineno: 3, first_column: 0, last_lineno: 5, last_column: 3) ``` * After ``` NODE_DASGN_CURR (line: 3, first_lineno: 3, first_column: 7, last_lineno: 3, last_column: 11) NODE_ERRINFO (line: 5, first_lineno: 3, first_column: 7, last_lineno: 3, last_column: 11) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04parse.y: Fix a location of NODE_BLOCK_PASSyui-knk
* parse.y (arg_append_gen): Update the last location of NODE_BLOCK_PASS when NODE is appended to nd_head. e.g. The locations of the NODE_BLOCK_PASS is fixed: ``` o[1, &bl] = :c ``` * Before ``` NODE_BLOCK_PASS (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 8) ``` * After ``` NODE_BLOCK_PASS (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 14) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04parse.y: Fix a location of NODE_ARGSCATyui-knk
* parse.y (arg_append_gen): Update the last location of NODE_ARGSCAT when NODE is appended to nd_body. e.g. The locations of the NODE_ARGSCAT is fixed: ``` m(*a, :b, :c) ``` * Before ``` NODE_ARGSCAT (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 8) ``` * After ``` NODE_ARGSCAT (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 12) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04parse.y: Fix a location of NODE_ARRAY in NODE_ARGSCATyui-knk
* parse.y: Fix the first location to be equal to the location of the first element of NODE_ARRAY. e.g. The locations of the NODE_ARRAY is fixed: ``` m(*a, :b, :c) ``` * Before ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 12) ``` * After ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 6, last_lineno: 1, last_column: 12) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03parse.y: Fix a location of NODE_ZARRAYyui-knk
* parse.y: Fix to only include a range of opt_call_args. e.g. The locations of the NODE_ZARRAY is fixed: ``` a[] ||= 1 ``` * Before ``` NODE_ZARRAY (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 9) ``` * After ``` NODE_ZARRAY (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 3) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03parse.y (new_args_gen): Set the location of NODE_ARGSyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03parse.y: Fix a location of NODE_DVAR in rb_args_infoyui-knk
* parse.y (new_args_tail_gen): Set only a location of NODE_DVAR. e.g. The locations of the NODE_DVAR is fixed: ``` def a(k: 1, **kws) end ``` * Before ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 6, last_lineno: 1, last_column: 18) ``` * After ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 12, last_lineno: 1, last_column: 17) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03parse.y: Set a location of NODE_NIL in `not()`yui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03parse.y: location of BEGINnobu
* parse.y (top_stmt): wrap BEGIN statement to store the whole location for each block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03parse.y: Fix locations of NODEs generated by cond0yui-knk
* parse.y: Fix to only include a range of the first argument of cond. e.g. The locations of the NODE_MATCH2 and NODE_GVAR are fixed: ``` 1 while /#{:a}/ ``` * Before ``` NODE_MATCH2 (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 15) NODE_GVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 15) ``` * After ``` NODE_MATCH2 (line: 1, first_lineno: 1, first_column: 8, last_lineno: 1, last_column: 15) NODE_GVAR (line: 1, first_lineno: 1, first_column: 8, last_lineno: 1, last_column: 15) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01parse.y: Fix locations of NODEs related to for statementyui-knk
* parse.y: Fix to only include a range of for_var. e.g. The locations of the NODE_ARGS and NODE_DVAR are fixed: ``` for a in m do n end ``` * Before ``` NODE_ARGS (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 19) NODE_DVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 19) ``` * After ``` NODE_ARGS (line: 1, first_lineno: 1, first_column: 4, last_lineno: 1, last_column: 5) NODE_DVAR (line: 1, first_lineno: 1, first_column: 4, last_lineno: 1, last_column: 5) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01parse.y: Fix a location of NODE_HASHyui-knk
* parse.y: Fix to only include a range of assocs. e.g. The locations of the NODE_HASH is fixed: ``` a(1, b: 10, &block) ``` * Before ``` NODE_HASH (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 18) ``` * After ``` NODE_HASH (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 10) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01parse.y: Fix a location of hash keysyui-knk
* parse.y: Use @1 to only include a range of tLABEL. e.g. The locations of the NODE_LIT(:b) is fixed: ``` a(1, b: 10) ``` * Before ``` NODE_LIT (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 10) ``` * After ``` NODE_LIT (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-28Fix typosyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-26parse.y: Fix the last location of NODE_KW_ARGyui-knk
* parse.y (kwd_append): Update the last location of NODE_KW_ARG when NODE is appended to the last. e.g. The locations of the first NODE_KW_ARG is fixed: ``` def a(b: 1, c: 2); end ``` * Before ``` NODE_KW_ARG (line: 1, first_lineno: 1, first_column: 6, last_lineno: 1, last_column: 10) ``` * After ``` NODE_KW_ARG (line: 1, first_lineno: 1, first_column: 6, last_lineno: 1, last_column: 16) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-26parse.y: Fix the last location of NODE_OPT_ARGyui-knk
* parse.y (opt_arg_append): Update the last location of NODE_OPT_ARG when NODE is appended to the last. e.g. The locations of the first NODE_OPT_ARG is fixed: ``` def a(b = 1, c = 2); end ``` * Before ``` NODE_OPT_ARG (line: 1, first_lineno: 1, first_column: 6, last_lineno: 1, last_column: 11) ``` * After ``` NODE_OPT_ARG (line: 1, first_lineno: 1, first_column: 6, last_lineno: 1, last_column: 18) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-25parse.y: opt_arg_appendyui-knk
* parse.y (opt_arg_append): extract optional arguments append. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-25parse.y: Fix a location of assignable nodesyui-knk
* parse.y (new_op_assign_gen): Update the location of lhs when NODE_OP_ASGN_OR/NODE_OP_ASGN_AND are generated. When NODE_OP_ASGN_OR/NODE_OP_ASGN_AND are generated a nd_value of lhs is set, so it is needed to update a location of lhs to include a location of rhs (same as node_assign_gen). e.g. The locations of NODE_DASGN_CURR is fixed: ``` a ||= 1 ``` * Before ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 1) ``` * After ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24parse.y: make_arraynobu
* parse.y (make_array): turn NULL node into zero length array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24parse.y: refactor list literalsnobu
* parse.y (words, symbols, qwords, qsymbols): unify empty list and non-empty list. * parse.y (parser_parse_string): always dispatch a word separator at the beginning of list literals. [ruby-core:83871] [Bug #14126] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-23parse.y: Fix a location of serial NODE_AND/NODE_ORyui-knk
* parse.y (logop_gen): Update the last location of NODE_AND/NODE_OR when NODE is appended to the last. e.g. The locations of NODE_AND is fixed: ``` a && b && c ``` * Before ``` NODE_AND (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) ``` * After ``` NODE_AND (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 11) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-23ripper.y: fix word list eventsnobu
* parse.y (parser_skip_words_sep): QWORDS_BEG should not include the first separators in ripper. * parse.y (parser_parse_string): WORDS_SEP should not include the closing parentheses of a word list in ripper, should include spaces at beginning of lines. [ruby-core:83864] [Bug #14126] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-22parse.y: Fix the locations of NODE_BLOCK_PASSyui-knk
* parse.y (arg_blk_pass): Update the first location of NODE_BLOCK_PASS if nd_head is assigned. e.g. The locations of NODE_BLOCK_PASS is fixed: ``` a(1, &:to_s) ``` * Before ``` NODE_BLOCK_PASS (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 11) ``` * After ``` NODE_BLOCK_PASS (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 11) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-21parse.y: Fix the locations of NODE in percent stringsyui-knk
* parse.y (parser_yylex): token_flush before calling parse_string. Without token_flush the first locations of NODE in percent strings are set to the location of %. e.g. The locations of NODE_STR is fixed: ``` %w[a b] ``` * Before ``` NODE_STR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 4) ("a") NODE_STR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) ("b") ``` * After ``` NODE_STR (line: 1, first_lineno: 1, first_column: 3, last_lineno: 1, last_column: 4) ("a") NODE_STR (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 6) ("b") ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20parse.y: Fix the last location of NODE_STR in %wyui-knk
* parse.y: Use @2 to only include a range of tSTRING_CONTENT. e.g. The locations of NODE_STR is fixed: ``` %w[a] ``` * Before ``` NODE_STR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 5) ``` * After ``` NODE_STR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 4) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20parse.y: Set the last location of NODE_ARRAY in %wyui-knk
* parse.y: list_append uses the locations of the second argument. So we should set the locations of $2 before pass it to list_append. e.g. The locations of NODE_ARRAY is fixed: ``` %w[a b] ``` * Before ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 0, last_lineno: 0, last_column: -1) ``` * After ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20parse.y: Fix the last location of NODE_LIT in %iyui-knk
* parse.y: Use @2 to not include a range of ' '. e.g. The locations of NODE_LIT is fixed: ``` %i[a] ``` * Before ``` NODE_LIT (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 5) ``` * After ``` NODE_LIT (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 4) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20parse.y: Set the last location of NODE_ARRAY in %iyui-knk
* parse.y: list_append uses the locations of the second argument. So we should set the locations of $2 before pass it to list_append. e.g. The locations of NODE_ARRAY is fixed: ``` %i[a b] ``` * Before ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 0, last_lineno: 0, last_column: -1) ``` * After ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20parse.y: Fix the locations of NODE_FCALLyui-knk
* parse.y: Update the locations of NODE_FCALL when nd_args is determined. e.g. The locations of NODE_FCALL is fixed: ``` a 1 ``` * Before ``` NODE_FCALL (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 1) ``` * After ``` NODE_FCALL (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 3) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-19Update the last location of NODE_BLOCKyui-knk
* parse.y (block_append_gen): Update the last location of NODE_BLOCK when a tail is appended. e.g. The locations of NODE_BLOCK is fixed: ``` a; b; c ``` * Before ``` NODE_BLOCK (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 4) ``` * After ``` NODE_BLOCK (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18parse.y: Fix the locations of NODE_ITERyui-knk
* parse.y: Update the locations of NODE_ITER when nd_iter is determined. e.g. The locations of NODE_ITER is fixed: ``` a {b} ``` * Before ``` NODE_ITER (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 5) ``` * After ``` NODE_ITER (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 5) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18parse.y: Fix the locations of NODE_DVAR and NODE_LVARyui-knk
* parse.y: Fix the locations of NODE_DVAR and NODE_LVAR when it's a multiple assignment method parameter. e.g. The locations of NODE_DVAR is fixed: ``` a {|(b, c)| d} ``` * Before ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 4, last_lineno: 1, last_column: 10) ``` * After ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 9) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18parse.y: Use node_assignyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18Update the last location of NODE_ARRAYyui-knk
* parse.y (list_append_gen, list_concat): Update the last location of NODE_ARRAY when an item is appended or concatenated with another NODE_ARRAY. e.g. The locations of NODE_ARRAY is fixed: ``` a(1,2,3) ``` * Before ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 3) ``` * After ``` NODE_ARRAY (line: 1, first_lineno: 1, first_column: 2, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17parse.y: RUBY_SET_YYLLOC to rb_parser_set_locationnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17parse.y: RUBY_SET_YYLLOCnobu
* parse.y (RUBY_SET_YYLLOC): extract setting locations from the source line. * parse.y (yylex): use RUBY_SET_YYLLOC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17NODE_CALL is not passed to node_assign_genyui-knk
* parse.y (node_assign_gen): NODE_CALL is not passed to node_assign_gen. NODE_CALL is not assignable. Assignable method call (array set and attr set) is represented by NODE_ATTRASGN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17Fix location of assignable nodesyui-knk
* parse.y (node_assign_gen): NODE_ATTRASGN is created before rhs is created. It is needed to set location after rhs is created to rhs range be included to the location of NODE_ATTRASGN. e.g. The locations of NODE_ATTRASGN is fixed: ``` a[1] = 2 ``` * Before ``` NODE_ATTRASGN (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 4) ``` * After ``` NODE_ATTRASGN (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 8) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17Fix location of assignable nodesyui-knk
* parse.y (node_assign_gen): In some case assignable nodes are created before rhs is created. In this case it is needed to set location after rhs is shifted to rhs range be included to assignable nodes. e.g. The locations of NODE_DASGN_CURR is fixed: ``` a = 10 ``` * Before ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 1) ``` * After ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16Fix location of NODEs generated by new_op_assign_genyui-knk
* parse.y (new_op_assign_gen): Use a location of lhs when call gettable, bacause gettable creates a variable node. Use a location of rhs when call new_list, because item of new_list is rhs. The locations of NODE_DVAR(nd_vid: :a) and NODE_ARRAY are fixed: ``` a -= 1 ``` * Before ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) NODE_ARRAY (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) ``` * After ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 1) NODE_ARRAY (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 6) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16parse.y: no return in classnobu
* parse.y (k_return): prohibit return in class/module body except for singleton class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16parse.y: Fix location of asgn nodeyui-knk
* parse.y (new_op_assign_gen): Fix location of asgn node. Assignable node (e.g. NODE_LASGN) is generated before rhs is generated, so we reset the location when nd_value of asgn is fixed. e.g. : ``` a -= 10 ``` * Before ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 1) ``` * After ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16parse.y: Preserve previous line and restore it when read '\n'yui-knk
* parse.y (parser_params): Add prevline to store previous line. * parse.y (yycompile0): Initialize prevline with 0. * parse.y (parser_nextline): Store previous line on prevline. * parse.y (parser_nextc): Check parser is on EOF or has nextline. Now parser_yylex does not always set lex_p as lex_pend, we should check EOF flag and nextline is set. * parse.y (parser_yylex): Restore previous line, set lex_p and tokp on '\n'. Before this commit, tokp is on the head of next line of '\n' and lex_p is on the tail of next line when next token is '\n'. By this behavior, in some case the last column of NODE_CALL (or NODE_QCALL) is set to the last column of next line. NODE_CALL can be generated via `primary_value call_op operation2 {} opt_paren_args` and opt_paren_args can be none. If none is generated with next token '\n', the last column of none is set to the last column of next line. e.g. : ``` a.b cd.ef ``` The location of NODE_CALL of first line is set to, * Before ``` NODE_CALL (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) ``` * After ``` NODE_CALL (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 3) ``` * parse.y (parser_mark): GC mark prevline. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-14parse.y: zero codepointsnobu
* parse.y (parser_tokadd_utf8): relax restriction to allow zero or more codepoints. fixup r59417. https://github.com/ruby/ruby/commit/7e8b910#commitcomment-25602670 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-13Initialize last column with -1 and lineno with 0yui-knk
* parse.y (node_newnode): Initialize last column of nodes with -1 and lineno with 0 to make it easy to detect nodes which we forget to set a column number or lineno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-13Store last location of a node on RNodeyui-knk
* node.c (rb_node_init): Initialize last location with 0. * node.h (struct rb_code_range_struct): Define a structure which contains first location and last location of a node. * node.h (struct RNode): Use rb_code_range_t to store last location of a node. * node.h (nd_column, nd_set_column, nd_lineno, nd_set_lineno): Follow-up the change of struct RNode. * node.h (nd_last_column, nd_set_last_column, nd_last_lineno, nd_set_last_lineno): Define getter/setter macros for last location of RNode. * parse.y : Set last location of tokens. Thanks to Yusuke Endoh (mame) for design of data structures. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e