Граф коммитов

1858 Коммитов

Автор SHA1 Сообщение Дата
mame 69c8feb253 parse.y: disentangle the lexer handling of ')', ']', and '}'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 13:42:18 +00:00
mame f2bffa1686 parse.y: simplify and add a comment for paren_nest and lpar_beg
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 13:42:15 +00:00
mame f41b4b1bfb parse.y: add a simple comment for COND_* and CMDARG_*
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 04:25:33 +00:00
mame 5ab288f53b parse.y (local_push_gen): Rewrite the condition of "unused var" warning
It was unnecessarily too complex, IMO.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 03:23:50 +00:00
mame 0ea778d812 parse.y: insane syntax too (class definition in cond)
This change partially reverts r61724 and take another approach:
exploiting struct local_vars to backup the cond_stack state.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 13:04:24 +00:00
kazu 82e986c286 Fix indent [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 12:35:54 +00:00
nobu 9c2c2f77ba parse.y: insane syntax
* parse.y (primary): save/restore COND and CMDARG stacks at method
  definition, to distinguish do_block and do_cond properly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 12:33:38 +00:00
mame 4928900814 Rename code_range to code_location
Because the name "code_range" is ambiguous with encoding's.
Abbreviations ("crange", and "cr") are also renamed to "loc".

The traditional "code_location" (a pair of lineno and column) is
renamed to "code_position".  Abbreviations are also renamed
(first_loc to beg_pos, and last_loc to end_pos).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 08:45:35 +00:00
mame 3cfa84d562 Allow `-> do rescue; end` as well as `proc do rescue; end`
https://twitter.com/takiuchi/status/950593389963051008

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 05:19:18 +00:00
mame 3a38b3c5d1 parse.y: Remove redefinition of malloc
Because the purpose is now unsure (maybe, to support very old bison?).
If an issue occurs, it should be resurrected with explicit comment.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 05:03:03 +00:00
mame 0d1630314b parse.y: PARSER_DEBUG is no longer used
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 04:27:26 +00:00
mame 461390970f parse.y: Remove meaningless ifndef guards
Because the part of the code is already within `#ifndef RIPPER`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 03:48:26 +00:00
nobu 3644cddb19 parse.y: set ID to yylval ID instead of token
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 01:56:05 +00:00
mame da4067bab8 parse.y: Remove special handling of tOROP and tANDOP
The complexity is no longer considered necessary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 01:49:40 +00:00
nobu 1e395da1f5 parse.y: use change_shortcut_operator_id
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 01:10:15 +00:00
yui-knk 473aea5636 parse.y: Remove duplicated nd_line set
* parse.y: These nodes are created with `@$` locations.
  Start position of `@$` is same as start position of `@1`.
  And NEW_XXX macros set first_loc.lineno of a passed
  code range to nd_line. So these nd_set_line are not needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 00:19:51 +00:00
mame 52057336b7 parse.y: Make consistent with the terms about code ranges and locations
"loc" was ambiguous; it might refer both a location and a code range.
This change uses "loc" for a location, and "crange" or "cr" for a code
range.

A location (abbr. loc) is a point in a program and consists of line
number and column number.  A code range (abbr. crange and cr) is a range
within a program and consists of a pair of locations which is the first
and the last.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 12:56:58 +00:00
yui-knk 991c45c56e parse.y (remove_duplicate_keys): Remove a not used argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 12:39:58 +00:00
mame 47cf2fd7ec parse.y: Factor out code fragments that merges two code ranges
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 12:30:35 +00:00
yui-knk dab956b7e6 parse.y (block_append_gen): Remove a not used argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 12:23:56 +00:00
yui-knk fe1575faa4 parse.y: Use nd_loc of head and tail
* parse.y (block_append_gen): Use nd_loc of
  head(tail) when create NEW_BLOCK of head(tail).

  e.g. The locations of the NODE_BLOCK is fixed:

  ```
  BEGIN {
    :a
  }

  BEGIN {
    :b
  }
  ```

  * Before

  ```
  NODE_BLOCK (line: 5, code_range: (5,0)-(7,1))
  ```

  * After

  ```
  NODE_BLOCK (line: 1, code_range: (1,0)-(7,1))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 12:23:53 +00:00
yui-knk a7d49457df parse.y: Fix the lineno of nd_set_line
* parse.y: Follow up of r61676. r61676 removed
  ruby_sourceline from some actions. When stop to
  use lineno of "n th" symbol, it's better to
  use last location's lineno of "n-1 th" symbol.

  e.g.

  ```
  primary : k_begin {} bodystmt k_end
  ```

  Before r61676 we use lineno of `@2` (ruby_sourceline).
  In this case, last location's lineno of `k_begin` (`@1`)
  is suitable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 11:50:35 +00:00
mame ec01271cae parse.y: Remove dispose_string
I think that recycling the delimiter string objects doesn't pay its
complexity.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 09:39:01 +00:00
mame 80768abe69 parse.y: Use last_loc.lineno instead of ruby_sourceline
State-less way is better.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 06:54:55 +00:00
mame 33b2ac9fb6 parse.y: Remove `$<num>$ = ruby_sourceline` hacks
Instead, use bison's lineno.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 06:30:53 +00:00
nobu 51e6e26016 parse.y: constified NULL_LOC
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 05:17:08 +00:00
mame fbb5a9d967 parse.y: Factor out special handling of a short-cut operator id
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 03:22:13 +00:00
yui-knk 8ef39549c2 parse.y: Remove duplicated nd_loc set
* parse.y: nd_loc is set by NEW_CASE2/NEW_WHEN

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 02:38:21 +00:00
mame 81cc61d53e parse.y: Embed simple wrapper functions for NEW_NODEs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 02:36:12 +00:00
yui-knk 6e6a253928 parse.y: Make NULL_LOC to be internal
* parse.y (NULL_LOC): We will create NODEs only
  inside of parse.y, so make NULL_LOC to be internal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 02:24:18 +00:00
mame 7fdbced2b7 parse.y: Remove unneeded wrapper functions for NEW_NODEs
Just refactoring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 02:19:47 +00:00
mame 4db3b9ebe0 parse.y: set bison's first_loc.lineno to nd_line by default
This change initializes nd_line, lineno of each node, by default, by
using the first line number of code range that bison tracks, instead of
extracting from lexer state.
The lexer state basically provides only the last line number of code
range, so many hacks are used to approximate the first line number.  The
hacks have been introduced on demand, or very ad-hocly.  I think this
change will make it possible to remove most of the hacks.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 01:49:00 +00:00
mame 413d862f23 parse.y: make all NEW_NODE macros receive location
This looks a big change, but just for refactoring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 01:29:35 +00:00
nobu f3aa3cd825 parse.y: do not overwrite case_body position
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 11:51:30 +00:00
nobu e1ac09dbe9 parse.y: set case_body line position to args
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 11:51:29 +00:00
nobu 057c88bc00 parse.y: removed unused macro new_command_call
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 09:44:34 +00:00
nobu f423f7c29f parse.y: nd_line of new_qcall
* parse.y (new_qcall): set nd_line to the method name location.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 09:36:48 +00:00
mame 1d3d8d89fc parse.y: Use nd_set_loc instead of direct modification to nd_loc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 16:04:02 +00:00
mame 8d06762c27 parse.y: Remove unneeded code
Because block_append sets prelude->nd_loc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 16:04:00 +00:00
mame 5fe35fee8f parse.y: make method_add_block accept location
Also, use method_add_block instead of direct modification to nd_iter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 15:44:03 +00:00
mame c515395561 node_h (NEW_DEFN): remove unused argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 15:16:42 +00:00
mame 38c62063c0 node.h: remove NODE_PRELUDE
NODE_PRELUDE contains a `BEGIN` node, a main node, and compile_option.
This node is assumed that it must be located immediately under the root
NODE_SCOPE, but this strange assumption is not so good, IMO.

This change removes the assumtion; it integrates the former two nodes by
block_append, and moves compile_option into rb_ast_body_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 08:59:23 +00:00
mame 503b858cef node.h: define rb_ast_body_t and restructure rb_ast_t
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 08:59:20 +00:00
mame db81395da8 parse.y: refactor out ast generation code of two rb_parser_compile_*
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 05:27:25 +00:00
mame 0947c2ba63 node.h: add NODE_ONCE instead of reuse of NODE_SCOPE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04 12:47:22 +00:00
nobu 035db929d1 parse.y: fix typo
* parse.y (singleton): fix typo, show the expression.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 04:24:32 +00:00
nobu 6e2ceaf0ed parse.y: code end position
* parse.y (parser_yyerror): use the given location as the end of
  erred code, instead of the current position.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 03:00:13 +00:00
nobu d4764ef6e4 parse.y: highlight yyerror
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-01 01:04:50 +00:00
nobu 5ceb137091 parse.y: yyerror1
* parse.y (yyerror1): pass location to parser_yyerror.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31 15:05:26 +00:00
nobu 862189c79e parse.y: yylloc at yyerror
* parse.y (parser_yyerror): consider the case first_loc and
  last_loc point different lines.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31 15:00:23 +00:00
nobu 457521574c parse.y: assignable_error
* parse.y (assignable_gen): should return valid NODE always even
  on errors.  [ruby-core:84565] [Bug #14261]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31 11:25:38 +00:00
nobu 59845bd47a parse.y: yylloc at yyerror
* parse.y (parser_yyerror): utilize the location given by bison.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31 06:53:04 +00:00
nobu 3802fb92ff parse.y: warning for locations
* parse.y (gettable_gen): warn for __FILE__/__LINE__ when eval
  with binding only.  promote use of Binding#source_location
  instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-26 10:10:41 +00:00
mame c2f10299ac parse.y: change NODE_SCOPE's nd_loc to one of the parent NODE
This change (ad-hocly) adjusts the code range of NODE_SCOPE in
class/module definition because the same adjust is already done in
method definition.  I intend to just remove inconsistency between
class/module definition and method definition, but this kind of adjust
is dirty, so it should be fixed later (maybe in 2.6).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21 06:52:15 +00:00
nobu 032e8fdf40 parse.y: end of script at newline
* parse.y (parser_yylex): deal with end of script chars just after
  ignored newline as other places.  [ruby-core:84349] [Bug #14206]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20 00:09:51 +00:00
mame 4abc1a24af node.h: add nd_last_loc and nd_set_last_loc
Just refactoring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 08:22:22 +00:00
mame ad12b5c285 node.[ch], parse.y, compile.c: rename nd_column to nd_first_column
nd_set_column -> nd_first_set_column
nd_lineno -> nd_first_lineno
nd_set_lineno -> nd_first_set_lineno

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 06:02:26 +00:00
mame bf9c947dd8 parse.y: suppress "unused variable" warning of ripper.y
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 05:54:10 +00:00
yui-knk 564dd28616 parse.y: Revert r61196
* parse.y: Because top_stmts is generated from none (not "/* none */"),
  @0 is not set by YYLLOC_DEFAULT. So @0 is a meaningless location.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13 01:10:27 +00:00
yui-knk 47f1d84215 parse.y: Fix the locations of an empty script
* parse.y: Fix the locations of NODE_BEGIN in
  an empty script.

  ```
  ruby --dump=p -e ''
  ```

  * Before

  ```
  NODE_BEGIN (line: 1, code_range: (1,1)-(1,1))
  ```

  * After

  ```
  NODE_BEGIN (line: 1, code_range: (1,0)-(1,0))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 23:48:50 +00:00
yui-knk f6a1ad41db parse.y: Change the last location of none
* parse.y: Change the last location of none to be
  equal to the first location of none.
  Sometimes none has length (`parser->tokp` does not
  match `lex_p` when none is generated).
  This leads to invalid code_ranges.

  e.g. The locations of the NODE_CALL (:sort) is fixed:

  ```
  x.sort.join(" ")
  ```

  * Before

  ```
  NODE_CALL (line: 1, code_range: (1,0)-(1,7))
  ```

  * After

  ```
  NODE_CALL (line: 1, code_range: (1,0)-(1,6))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 14:47:34 +00:00
yui-knk 3d6d615175 parse.y: Set locations of nd_body in NODE_ITER explicitly
* parse.y: Same as r61168, but for brace_block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 14:21:20 +00:00
yui-knk 46e8a8ae37 parse.y: Set locations of nd_body in NODE_ITER explicitly
* parse.y: Currently the location of do_body is set
  by new_do_body. Sometimes the last part of do_body is
  none, because bodystmt ends with opt_ensure.
  Token keyword_end has been looked ahead when a tokenizer
  generates none, so the last location of opt_ensure matches
  the last location of `end`. But this relation will be
  broken when we change the last location of none to be equal to
  the first location of none. So set locations of nd_body in
  NODE_ITER explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 14:10:23 +00:00
yui-knk 79c2e6eccf parse.y: Fix the locations of NODE_ITER (cmd_brace_block)
* parse.y: Update the locations of NODE_ITER
  when nd_iter is determined.

  ```
  a (1) {|i|}
  ```

  * Before

  ```
  NODE_ITER (line: 1, code_range: (1,6)-(1,10))
  ```

  * After

  ```
  NODE_ITER (line: 1, code_range: (1,0)-(1,11))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 08:54:34 +00:00
yui-knk f1c3395099 parse.y: Fix locations of NODE_ARRAY of mlhs_head
* parse.y: Fix to only include a range of mlhs_item
  (exclude ',' form range).

  e.g. The locations of the NODE_ARRAY is fixed:

  ```
  (a,) = 1,2
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,1)-(1,3))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,1)-(1,2))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 01:13:56 +00:00
yui-knk 0b31ce0047 parse.y: Fix locations of NODE_ARRAY in NODE_CALL(:=~)
* parse.y (match_op_gen): Fix to only include a range of node2.

  e.g. The locations of the NODE_ARRAY is fixed:

  ```
  re =~ s1
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,0)-(1,8))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,6)-(1,8))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 00:28:29 +00:00
yui-knk e44f2b7d10 parse.y: Fix locations of NODE_ARRAY of opt_call_args
* parse.y: Fix to only include a range of assocs
  (exclude ',' form range).

  e.g. The locations of the NODE_ARRAY is fixed:

  ```
  m1(str: "bar",)
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,3)-(1,14))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,3)-(1,13))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 00:12:43 +00:00
yui-knk f9d8003c94 parse.y: Fix locations of NODE_ARRAY in NODE_BLOCK_PASS
* parse.y: Fix to only include a range of assocs.

  e.g. The locations of the NODE_ARRAY is fixed:

  ```
  m1(str: "bar", &blk)
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,3)-(1,19))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,3)-(1,13))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 23:38:00 +00:00
yui-knk 2d719aef2b parse.y: Change locations of NODE_DVAR in NODE_MASGN
* parse.y: Change the last location of NODE_DVAR to
  be equal to the first location of NODE_DVAR.
  NODE_DVAR of NODE_MASGN (nd_value) is an internal variable,
  so it has no length.

  e.g. The locations of the NODE_DVAR is changed:

  ```
  a.b {|(c,d)| e}
  ```

  * Before

  ```
  NODE_DVAR (line: 1, code_range: (1,7)-(1,10))
  ```

  * After

  ```
  NODE_DVAR (line: 1, code_range: (1,7)-(1,7))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 23:13:47 +00:00
yui-knk aaf309972e parse.y: Fix locations of NODE_DSTR generated by evstr2dstr_gen
* parse.y (evstr2dstr_gen): Fix to only include a range of node.

  e.g. The locations of the NODE_DSTR is fixed:

  ```
  %W[a #{b} c]
  ```

  * Before

  ```
  NODE_DSTR (line: 1, code_range: (1,3)-(1,9))
  ```

  * After

  ```
  NODE_DSTR (line: 1, code_range: (1,5)-(1,9))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 02:19:43 +00:00
yui-knk ec073534ec parse.y: Remove not used argument
* parse.y (list_append_gen): location is not used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 00:28:27 +00:00
yui-knk 14b6dc4c80 parse.y: Fix locations of NODE_SCOPE in NODE_MODULE
* parse.y: Fix to only include a range of bodystmt.

  e.g. The locations of the NODE_SCOPE is fixed:

  ```
  module M
    def m
    end
  end
  ```

  * Before

  ```
  NODE_SCOPE (line: 4, code_range: (1,0)-(4,3))
  ```

  * After

  ```
  NODE_SCOPE (line: 4, code_range: (1,8)-(4,3))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 00:06:11 +00:00
yui-knk e038b794fe parse.y: Fix the last location of NODE_COLON2
* parse.y: Fix to only include a range from primary_value to tCONSTANT.

  e.g. The locations of the NODE_COLON2 is fixed:

  ```
  A::B ||= 1
  ```

  * Before

  ```
  NODE_COLON2 (line: 1, code_range: (1,0)-(1,10))
  ```

  * After

  ```
  NODE_COLON2 (line: 1, code_range: (1,0)-(1,4))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-10 23:44:22 +00:00
yui-knk ad321cdea5 parse.y: Change the first location of NODE_ARRAY in NODE_DSTR (nd_next->nd_next)
* parse.y (list_append_gen): Change the first location to
  start with the location of item if new list is generated.

  e.g. The locations of the NODE_ARRAY is changed:

  ```
  "#{a}.#{b}"
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,0)-(1,6))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,5)-(1,6))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-10 23:27:58 +00:00
yui-knk 4cfc1aa959 parse.y: Fix locations of NODE_ARRAY in NODE_ATTRASGN (nd_args)
* parse.y (arg_append_gen): Fix to only include a range of
  node2 if new list is generated.

  e.g. The locations of the NODE_ARRAY is fixed:

  ```
  x.default = 5
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,0)-(1,13))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,12)-(1,13))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09 13:13:58 +00:00
yui-knk 51d863e06a parse.y: Change locations of NODE_BLOCK in NODE_RESBODY (nd_body)
* parse.y: Change to only include a range from exc_var to compstmt.

  e.g. The locations of the NODE_BLOCK is changed:

  ```
  begin
    :a
  rescue E => e
    :b
  end
  ```

  * Before

  ```
  NODE_BLOCK (line: 3, code_range: (3,0)-(5,3))
  ```

  * After

  ```
  NODE_BLOCK (line: 3, code_range: (3,9)-(4,4))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09 09:44:03 +00:00
yui-knk 7a79d88161 parse.y: Fix locations of NODE_SCOPE in NODE_SCLASS
* parse.y: Fix to only include a range of bodystmt.

  e.g. The locations of the NODE_SCOPE is fixed:

  ```
  class << []
    def m; end
  end
  ```

  * Before

  ```
  NODE_SCOPE (line: 3, code_range: (1,0)-(3,3))
  ```

  * After

  ```
  NODE_SCOPE (line: 3, code_range: (2,2)-(3,3))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09 03:52:59 +00:00
yui-knk 933fabd1b9 parse.y: Fix locations of NODE_ARRAY in NODE_OPCALL(nd_args)
* parse.y: Fix to only include a range of arg1.

  e.g. The locations of the NODE_ARRAY is fixed:

  ```
  1 + 2
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,0)-(1,5))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,4)-(1,5))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09 03:18:55 +00:00
yui-knk 79aba225b2 parse.y: Fix locations of NODE_SCOPE in NODE_CLASS
* parse.y: Fix to only include a range of bodystmt.

  e.g. The locations of the NODE_SCOPE is fixed:

  ```
  class A
    def a; end
  end
  ```

  * Before

  ```
  NODE_SCOPE (line: 3, code_range: (1,0)-(3,3))
  ```

  * After

  ```
  NODE_SCOPE (line: 3, code_range: (1,7)-(3,3))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09 03:03:34 +00:00
yui-knk f8659dfd94 parse.y Fix compile error
ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08 00:45:23 +00:00
yui-knk c6b31b76ee parse.y: Fix locations of modifier_rescue
* parse.y: Fix to only include a range from modifier_rescue
  to stmt (or arg).

  e.g. The locations of the NODE_RESBODY is fixed:

  ```
  a rescue 1
  ```

  * Before

  ```
  NODE_RESBODY (line: 1, code_range: (1,0)-(1,10))
  ```

  * After

  ```
  NODE_RESBODY (line: 1, code_range: (1,2)-(1,10))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08 00:33:38 +00:00
yui-knk f026add396 parse.y: Fix locations of string
* parse.y: Fix to include locations of tSTRING_BEG and tSTRING_END.

  e.g. The locations of the NODE_STR is fixed:

  ```
  "a"
  ```

  * Before

  ```
  NODE_STR (line: 1, code_range: (1,1)-(1,2))
  ```

  * After

  ```
  NODE_STR (line: 1, code_range: (1,0)-(1,3))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07 23:35:59 +00:00
yui-knk 15c977803d parse.y: Fix locations of array
* parse.y (make_array): Set locations of ary to
  include locations of start token (tLBRACK, tWORDS_BEG, ...)
  and end token (']', tSTRING_END, ...) of array.

  e.g. The locations of the NODE_ARRAY is fixed:

  ```
  [1, 2, 3]
  ```

  * Before

  ```
  NODE_ARRAY (line: 1, code_range: (1,1)-(1,8))
  ```

  * After

  ```
  NODE_ARRAY (line: 1, code_range: (1,0)-(1,9))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07 06:38:49 +00:00
nobu db2d28b08e parse.y: fix for old compilers
* parse.y (arg_value): initialization of aggregation type with
  non-constant values is not allowed in C89.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07 04:12:42 +00:00
yui-knk 803d1753b7 parse.y: Fix locations of dsym
* parse.y: Fix to only include a range from tSTRING_BEG to tLABEL_END.

  e.g. The locations of the NODE_LIT is fixed:

  ```
  { "a": 10 }
  ```

  * Before

  ```
  NODE_LIT (line: 1, code_range: (1,2)-(1,9))
  ```

  * After

  ```
  NODE_LIT (line: 1, code_range: (1,2)-(1,6))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07 03:00:36 +00:00
yui-knk acf7e52d88 parse.y: Fix locations of dsym
* parse.y (dsym_node_gen): Always set locations
  to include locations of tSYMBEG and tSTRING_END.

  e.g. The locations of the NODE_LIT is fixed:

  ```
  :"a"
  ```

  * Before

  ```
  NODE_LIT (line: 1, code_range: (1,2)-(1,3))
  ```

  * After

  ```
  NODE_LIT (line: 1, code_range: (1,0)-(1,4))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07 02:48:38 +00:00
yui-knk 2c018e9646 parse.y: Fix locations of regexp
* parse.y (new_regexp_gen): Always set locations
  to include locations of tREGEXP_BEG and tREGEXP_END.

  e.g. The locations of the NODE_LIT is fixed:

  ```
  /a/
  ```

  * Before

  ```
  NODE_LIT (line: 1, code_range: (1,1)-(1,2))
  ```

  * After

  ```
  NODE_LIT (line: 1, code_range: (1,0)-(1,3))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07 02:36:51 +00:00
yui-knk d2d4839a39 parse.y: Fix locations of xstring
* parse.y (new_xstring_gen): Always set locations
  to include locations of tXSTRING_BEG and tSTRING_END.

  e.g. The locations of the NODE_XSTR is fixed:

  ```
  `a`
  ```

  * Before

  ```
  NODE_XSTR (line: 1, code_range: (1,1)-(1,2))
  ```

  * After

  ```
  NODE_XSTR (line: 1, code_range: (1,0)-(1,3))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07 02:25:37 +00:00
yui-knk c1bd83cef7 parse.y: Fix the first location of heredoc identifier
* parse.y (parser_heredoc_identifier):
  Put length of term at the head of rb_strterm_heredoc_struct.term.

* parse.y (rb_parser_set_location_from_strterm_heredoc):
  Use length of term to calculate first_loc.column.

  e.g. The locations of the NODE_DSTR is fixed:

  ```
  a <<STR
  123
  #{:a}
  STR
  ```

  * Before

  ```
  NODE_DSTR (line: 3, code_range: (1,3)-(1,7))
  ```

  * After

  ```
  NODE_DSTR (line: 3, code_range: (1,2)-(1,7))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 03:09:55 +00:00
mame b7c17ad14d parse.y: remove redefined typedef
Clang told me that this is C11 feature.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 01:41:05 +00:00
yui-knk f7899d3c80 parse.y: Fix locations of HEREDOC
* parse.y (rb_parser_set_location_from_strterm_heredoc):
  Set locations based on rb_strterm_heredoc_t.

* parse.y (yylex): Set yylloc based on rb_strterm_heredoc_t
  when parsing heredoc.

  e.g. The locations of the NODE_DSTR is changed:

  ```
  a <<STR
  123
  #{:a}
  STR
  ```

  * Before

  ```
  NODE_DSTR (line: 3, code_range: (3,0)-(1,7))
  ```

  * After

  ```
  NODE_DSTR (line: 3, code_range: (1,3)-(1,7))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 00:44:18 +00:00
nobu f24efa287f parse.y: nd_line of new node
* parse.y (nd_set_loc): set nd_line of the newly created node to
  the first location.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 13:49:40 +00:00
nobu 4fe720eb36 parse.y: nd_line of call_uni_op
* 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-05 13:46:21 +00:00
nobu 2ed1230429 parse.y: nd_line of logop
* 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-05 13:42:46 +00:00
nobu b9e91bfba4 parse.y: nd_line of match_op
* 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-05 13:38:01 +00:00
nobu 60bca0214b parse.y: nd_line of call_bin_op
* 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-05 13:30:06 +00:00
yui-knk faf43e37ad parse.y: Fix locations of NODE_*ASGN and NODE_ERRINFO
* 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-04 23:59:02 +00:00
yui-knk 4788522fa6 parse.y: Fix a location of NODE_BLOCK_PASS
* 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-04 08:20:07 +00:00
yui-knk 81d8c29a21 parse.y: Fix a location of NODE_ARGSCAT
* 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-04 07:50:42 +00:00
yui-knk 2208c6b442 parse.y: Fix a location of NODE_ARRAY in NODE_ARGSCAT
* 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-04 07:16:31 +00:00
yui-knk 64d1a9e3ac parse.y: Fix a location of NODE_ZARRAY
* 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-03 23:12:01 +00:00
yui-knk c1a9911797 parse.y (new_args_gen): Set the location of NODE_ARGS
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03 12:44:47 +00:00
yui-knk 8a24dc0e0d parse.y: Fix a location of NODE_DVAR in rb_args_info
* 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-03 12:27:01 +00:00
yui-knk 1b055cffbc parse.y: Set a location of NODE_NIL in `not()`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03 06:53:18 +00:00
nobu 61997a2168 parse.y: location of BEGIN
* 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-03 06:14:58 +00:00
yui-knk fef98fdd09 parse.y: Fix locations of NODEs generated by cond0
* 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-03 04:53:05 +00:00
yui-knk 5bf3657b9f parse.y: Fix locations of NODEs related to for statement
* 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-01 13:40:03 +00:00
yui-knk 58d572d6aa parse.y: Fix a location of NODE_HASH
* 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-01 09:48:17 +00:00
yui-knk 0212d5dc74 parse.y: Fix a location of hash keys
* 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-12-01 06:32:59 +00:00
yui-knk 89bfee6fd4 Fix typos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-28 06:19:04 +00:00
yui-knk 2734867c16 parse.y: Fix the last location of NODE_KW_ARG
* 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-26 23:52:47 +00:00
yui-knk 62b5c62f3d parse.y: Fix the last location of NODE_OPT_ARG
* 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-26 23:33:23 +00:00
yui-knk c56ac08636 parse.y: opt_arg_append
* 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-25 11:57:33 +00:00
yui-knk ce64157d97 parse.y: Fix a location of assignable nodes
* 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-25 01:39:45 +00:00
nobu f418f9b4ce parse.y: make_array
* 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-24 04:26:29 +00:00
nobu eb13bcec58 parse.y: refactor list literals
* 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-24 04:26:27 +00:00
yui-knk f8523d35bf parse.y: Fix a location of serial NODE_AND/NODE_OR
* 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-23 14:15:27 +00:00
nobu dee6a91002 ripper.y: fix word list events
* 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-23 04:30:23 +00:00
yui-knk b5ee316862 parse.y: Fix the locations of NODE_BLOCK_PASS
* 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-22 12:32:41 +00:00
yui-knk c0ffccf722 parse.y: Fix the locations of NODE in percent strings
* 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-21 00:47:00 +00:00
yui-knk d911920244 parse.y: Fix the last location of NODE_STR in %w
* 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-20 23:58:42 +00:00
yui-knk 1bf50894ef parse.y: Set the last location of NODE_ARRAY in %w
* 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-20 23:37:01 +00:00
yui-knk 29317b1c38 parse.y: Fix the last location of NODE_LIT in %i
* 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-20 23:12:43 +00:00
yui-knk 45100dbeb2 parse.y: Set the last location of NODE_ARRAY in %i
* 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-20 22:48:05 +00:00
yui-knk 4b279cfdd2 parse.y: Fix the locations of NODE_FCALL
* 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-20 06:00:04 +00:00
yui-knk fa326994ae Update the last location of NODE_BLOCK
* 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-19 23:59:32 +00:00
yui-knk 5fd6558502 parse.y: Fix the locations of NODE_ITER
* 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-18 13:11:36 +00:00
yui-knk db54a07c75 parse.y: Fix the locations of NODE_DVAR and NODE_LVAR
* 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-18 08:21:46 +00:00
yui-knk 15b02bcefc parse.y: Use node_assign
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18 03:32:05 +00:00
yui-knk 28d00c2fb2 Update the last location of NODE_ARRAY
* 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-18 01:40:13 +00:00
nobu 813b8d0a53 parse.y: RUBY_SET_YYLLOC to rb_parser_set_location
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 12:16:31 +00:00
nobu 3465fdd44e parse.y: RUBY_SET_YYLLOC
* 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-17 12:16:30 +00:00
yui-knk f26cce0bba NODE_CALL is not passed to node_assign_gen
* 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-17 08:23:06 +00:00
yui-knk 114fc2201c Fix location of assignable nodes
* 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-17 07:39:15 +00:00
yui-knk 80facdd93a Fix location of assignable nodes
* 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-17 04:25:48 +00:00
yui-knk 82fe13d117 Fix location of NODEs generated by new_op_assign_gen
* 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-16 23:13:24 +00:00
nobu 8c15f40acf parse.y: no return in class
* 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-16 05:36:42 +00:00
yui-knk 575993d743 parse.y: Fix location of asgn node
* 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-16 01:56:54 +00:00
yui-knk b465633fcc parse.y: Preserve previous line and restore it when read '\n'
* 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-16 01:06:10 +00:00
nobu 50702d16ab parse.y: zero codepoints
* 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-14 15:37:48 +00:00
yui-knk 43e15e77b9 Initialize last column with -1 and lineno with 0
* 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-13 01:24:15 +00:00
yui-knk 1ef7b0cd5a Store last location of a node on RNode
* 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
2017-11-13 00:14:33 +00:00
nobu 74597b0b4b parse.y: constified YYLTYPE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-11 04:50:11 +00:00
mame f09ad1dc5d use `rb_ast_dispose` instead of `rb_ast_free`
`rb_ast_dispose` calls `rb_gc_writebarrier_remember`.  Unless we call
it, the marked objects may not be GC'ed until `rb_ast_t` is GC'ed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09 01:32:11 +00:00
nobu cf3329cb8d parse.y: fix r60644
* parse.y (rb_strterm_heredoc_t): should not define sourceline as
  union, to fix wrong read on big-endian platforms.
  as rb_imemo_new stores all members as VALUEs, should read it as
  VALUE too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-08 23:09:25 +00:00
nobu e7d37ebdae parse.y: remove in_single
* parse.y (parser_params): removed in_single, which is referenced
  with in_def always.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-08 10:54:09 +00:00
yui-knk a6f372d129 Omit first argument of NEW_CASE2
* node.h (NEW_CASE2): Omit first argument of NEW_CASE2,
  bacause the first argument of NEW_CASE2 is always 0.
* parse.y: Ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-08 00:03:02 +00:00
nobu 3280f54168 lexer.rb: Ripper::Lexer::State
* ext/ripper/lib/ripper/lexer.rb (Ripper::Lexer::State): wrapper
  of lex_state values.

* parse.y (rb_parser_lex_state_name): return shared strings.  lex
  state combinations are very restricted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-05 21:13:18 +00:00
mame cb7d9fe95f Revert "Introduce rb_code_range_t and replace YYLTYPE with it"
r60655 changed the usage of bison by defining a customized YYLTYPE,
which seemed to cause a random stall at rb_thread_terminate_all.

Kazuki Tsujimoto investigated the issue and pointed out the commit that
caused it.  Thanks!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-05 03:52:22 +00:00
mame a9fd7d9396 Introduce rb_code_range_t and replace YYLTYPE with it
rb_code_range_t has two t_code_location_t, i.e., the first and last
locations.

This is used for YYLTYPE, tracked locations of bison, and will be also
used for representing the "range", the first and the last locations of
each NODE.  Currently, each NODE keeps only the first location, though.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 16:34:00 +00:00
nobu 39a73cac71 parse.y: fix duplicate symbol
* parse.y (rb_strterm_mark): do not define in ripper to get rid of
  duplicate symbol with static-linked-ext.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 15:39:52 +00:00
mame af9b0da125 Avoid usage of the magic number `(NODE*)-1`
This magic number has two meanings depending upon the context:

* "required keyword argument (no name)" on NODE_LASGN (`def foo(x:)`)
* "rest argument (no name)" on NODE_MASGN and NODE_POSTARG
  ('a, b, * = ary` or `a, b, *, z = ary`)

To show this intention explicitly, two macros are introduced:
NODE_SPECIAL_REQUIRED_KEYWORD and NODE_SPECIAL_NO_NAME_REST.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 14:24:16 +00:00
mame fbc8b87e94 parse.y (new_args_tail_gen): returns a NODE instead of imemo
`new_args_tail_gen` returned imemo, but the value was later accessed as
`NODE*`.  This prevented change of NODE structure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 13:31:46 +00:00
nobu e92ca247d2 parse.y: suppress warning in ripper
* parse.y (rb_discard_node_gen): rb_discard_node() is not used in
  ripper right now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 12:07:20 +00:00
nobu 603a7bdc2f parse.y: suppress warnings
* parse.y (parser_set_line): removed no longer used function.

* parse.y (rb_strterm_heredoc_t): adjust type of sourceline to
  ruby_sourceline.

* parse.y (rb_strterm_t): get rid of redefinition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 12:01:42 +00:00
mame 1aa34afd41 Rename imemo_strterm to imemo_parser_strterm
Per ko1's request.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 10:56:50 +00:00
mame 417eca103f Make Ripper use NODE buffer
This is a follow-up of r60488.  Not only the Ruby parser but also Ripper
now use NODE buffer instead of NODE objects managed by GC.

Now we can change the struct of NODEs so that it can keep detailed
location information, perhaps (not tried yet).  Note that, however, the
first word of each NODE must be still compatible with RBasic structure.
This is because Ripper handles NODEs and other objects uniformly;
especially, it still uses `RB_TYPE_P(obj, T_NODE)` for distinguishing
between NODEs and other objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 09:18:08 +00:00
mame ee7dcd1ae1 Fix the alignment bug of r60634 for LLP64
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 07:21:37 +00:00
mame 12697c0867 Revert "Revert "Replace NODE_STRTERM and NODE_HEREDOC with imemo_strterm""
Retry r60634

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 07:21:36 +00:00
mame 96eefc0f44 Revert "Replace NODE_STRTERM and NODE_HEREDOC with imemo_strterm"
Due to build failure on mswin and mingw.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 04:59:19 +00:00
mame c1de9fc5ef Replace NODE_STRTERM and NODE_HEREDOC with imemo_strterm
Just refactoring.

NODE_STRTERM and NODE_HEREDOC are not an internal node of AST, but a
temporary storage for managing termination of string literals and
heredocs.  Instead of NODE abuse, I want to use imemo for the storage
in order to avoid (my) confusion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 03:04:54 +00:00
mame bd46dad47f Remove unneeded complexity
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31 05:24:21 +00:00
yui-knk a09e175068 Use NODE_CASE2 if case expressions don't exist
When NODE_WHEN is compiled by iseq_compile_each0,
the node passed to compile_when is NODE_WHEN (not NODE_CASE).
So we can not handle the location of NODE_CASE of
case statements which don't have case expressions.

e.g. :

```
case; when 1; foo; when 2; bar; else baz; end
```

This commit adds NODE_CASE2, and compiles it by
iseq_compile_each0.

* compile.c (compile_case): Does not call COMPILE_ when
  NODE_CASE does not have case expressions.
* compile.c (compile_case2): Compile NODE_CASE2 by compile_case2.
* compile.c (compile_when): Delete an obsoleted function.
* compile.c (iseq_compile_each0): Compile NODE_CASE2.

* ext/objspace/objspace.c (count_nodes): Add NODE_CASE2 case.

* node.c (dump_node, rb_gc_mark_node): Add NODE_CASE2 case.

* node.h (node_type): Add NODE_CASE2.
* node.h (NEW_CASE2): Add a macro which generates NODE_CASE2.

* parse.y: Generate NODE_CASE2 if case expressions don't exist.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31 00:46:30 +00:00
yui-knk 7a42b03b0c Store lineno on RNode
* node.c (A_NODE_HEADER): Print lineno.

* node.h (nd_column, nd_set_column): Store column
  number with 16-bit.
* node.h (nd_lineno, nd_set_lineno): Define
  getter/setter macros for lineno of RNode.

* parse.y : Set first lineno of tokens.

Thanks to takeshinoda for review.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-30 13:36:20 +00:00
yui-knk d5db205093 Remove duplicated column set
* parse.y : Column of resq is set by new_resbody, so
  this line is needless.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 22:12:08 +00:00
yui-knk ba6a3f5f43 parse.y (new_regexp_gen): Set column for NODE_SCOPE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 21:52:54 +00:00
ko1 85fcaf025d * node.h (ast_t): renamed to `rb_ast_t`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 15:51:23 +00:00
mame c2be819250 parse.y: Need to mark the third element of `NODE_HEREDOC`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 17:06:06 +00:00
mame e35fe8d11b Revert "Revert "Manage AST NODEs out of GC""
This re-introduces r60485.
This reverts commit 5a176b75b1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 16:44:57 +00:00
mame 5a176b75b1 Revert "Manage AST NODEs out of GC"
This reverts commit 620ba74778.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 16:02:34 +00:00
mame 620ba74778 Manage AST NODEs out of GC
NODEs in AST are no longer objects managed by GC.  This change will
remove the restriction imposed by the GC.  For example, a NODE can use
more than five words (this is my primary purpose; we want to store the
position data for each NODE, for coverage library), or even a NODE can
have variable length (some kinds of NODEs have unused fields).
To do this, however, we need more work, since Ripper still uses T_NODE
objects managed by the GC.

The life time of NODEs is more obvious than other kinds of objects; they
are created at parsing, and they become disused immediately after
compilation.  This change releases all NODEs by a few `xfree`s after
compilation, so performance will be improved a bit.  In extreme example,
`eval("x=1;" * 10000000)` runs much faster (40 sec. -> 7.8 sec. on my
machine).

The most important part of this change is `ast_t` struct, which has
three contents: (1) NODE buffer (malloc'ed memory), (2) a reference to
the root NODE, and (3) an array that contains objects that must be
marked during parsing (such as literal objects).  Some functions that
had received `NODE*` arguments, must now receive `ast_t*`.

* node.c, node.h: defines `ast_t` struct and related operations.
* gc.c, internal.h: defines `imemo_ast`.
* parse.y: makes `parser_params` struct have a reference to `ast_t`.
  Instead of `rb_node_newnode`, use `rb_ast_newnode` to create a NODE.
* iseq.c, load.c, ruby.c, template/prelude.c.tmpl: modifies some
  functions to handle `ast_t*` instead of `NODE*`.
* test/ruby/test_gc.rb: ad-hoc fix for a failed test.  The test assumes
  GC eden is increased at startup by NODE object creation.  However,
  this change now create no NODE object, so GC eden is not necessarily
  increased.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 15:59:02 +00:00
mame f902ab6d52 Add explicit markers for literal objects generated in parse.y
This is just a preparation to manage AST NODEs out of GC.
Currently `add_mark_object` does nothing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 15:06:38 +00:00
mame 09ea07e02c Refactoring by adding `rb_imemo_alloc_new` to create imemo_alloc buffer
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 13:38:53 +00:00
mame fdb771d82d Make imemo_alloc writebarrier-unprotected
imemo_alloc provides a memory buffer whose contents are marked by GC.
C code can access imemo_alloc buffer freely, so imemo_alloc must be
considered writebarrier-unprotected.  But T_IMEMO is writebarrier-
protected by default, which caused a GC bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 13:19:45 +00:00
nobu 2c786bf35d Removed NODE_OPT_N
* node.h (NODE_OPT_N): removed.

* parse.y (parser_append_options): expand -n option loop to while
  gets loop.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 08:00:36 +00:00
nobu 30f5c55890 parse.y: rb_parser_set_options
* parse.y (yycompile0): append top-level addenda before appending
  prelude nodes.

* parse.y (rb_parser_set_options): set top-level addendum options
  before parsing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 07:41:48 +00:00
mame e1b6f0f529 Avoid many type casts
The idiom `rb_gc_force_recycle((VALUE)...)` was used heavily.
This change defines `rb_discard_nod(NODE*)` and allows C compiler to
typecheck.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 06:27:58 +00:00
mame f70aa7637b Remove special handling for (NODE*)1
The magic number was used to mark NODE_ATTRASGN when its receiver is
self.  But the hack was refactored at r46366.  So the remaining code
fragments are no longer needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 05:54:30 +00:00
yui-knk ada56ddec7 parse.y (new_scope_gen): adjust indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 06:11:01 +00:00
nobu f644d3ef67 parse.y: workaround for warnings
* parse.y (mark_lvar_used): enable workaround to suppress unused
  local variables.  [ruby-core:82656] [Bug #13872]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 01:37:36 +00:00
nobu 8bd7c8cbc8 fix up r60224
* parse.y (match_op_gen): fix optimization at DREGX_ONCE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 01:13:57 +00:00
yui-knk 92746378ab Remove not used node_type NODE_IASGN2
* compile.c (compile_massign_opt, iseq_compile_each0): This
  node_type has not been used since r11813.
* ext/objspace/objspace.c (count_nodes): ditto
* node.c (dump_node, rb_gc_mark_node): ditto
* node.h (node_type, NEW_IASGN2): ditto
* parse.y (node_assign_gen): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:56:03 +00:00
yui-knk 617c53136d Do not pass a not used argument
* parse.y (new_op_assign_gen): new_op_assign_gen for
  ripper does not need column information.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:51:07 +00:00
yui-knk 1ec8694c9e Define the macro separately for ruby parser and for ripper
* parse.y (new_op_assign): Define the macro separately
  for ruby parser and for ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:32:32 +00:00
nobu 719531dba5 fix up imemo_alloc
* internal.h (rb_imemo_alloc_struct), gc.c (gc_mark_imemo): turned
  next into the pointer to chain.

* parse.y (NEWHEAP): needs a cast.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 09:10:42 +00:00
mame ccfe37884a Replace NODE_ALLOCA with T_IMEMO (imemo_alloc)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 08:40:28 +00:00
yui-knk 1a0ed8cb42 Do not literal_flush if float is read correctly
* parse.y (parse_numeric): Do not literal_flush if
  float is read correctly. This will fix the first
  column of float.

before:
  ```
  1.2i1.1
         ^
  ```

after:
  ```
  1.2i1.1
      ^~~
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 02:50:38 +00:00
nobu 342e9ae38a moved node generation for dregex_once to parse.y
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 01:06:25 +00:00
yui-knk 1d80b1926c Fix build on Windows
* parse.y (new_cdecl_gen): Rename local variable name
  from cdecl to nd_cdecl. We can not use cdecl on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 00:14:32 +00:00
svn a9f5b84010 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20 16:22:24 +00:00
yui-knk 6d4b557811 Store token first column number on RNode
* node.c (A_NODE_HEADER): Print column number.
* node.h (nd_column, nd_set_column): Define getter/setter
  macros for column number of RNode.
* parse.y: Set first column number of tokens.

Notes:

* Use `@n` to get the location of token in parse.y.
* When we use `@n`, arguments of yyerror and yylex are
  changed.
* Initialize column of nodes with -1 to make it easy
  to detect nodes which we forget to set a column number.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20 16:22:22 +00:00
nobu 8b501f6d7f parse.y: indent at '#'
* parse.y (parser_here_document): update indent at '#', which is
  not a space.  [ruby-core:83368] [Bug #14032]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-19 05:10:38 +00:00
nobu 4a375f3ef5 parse.y: serial comparisons
* parse.y (rel_expr): warn sequence of comparisons, which would be
  probably unintentional.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 13:08:53 +00:00
nobu c1c3d07332 parse.y: relop
* parse.y (relop): extract to simplify comparisons.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 13:08:53 +00:00
nobu 72c96011ea parse.y: token info with BOM
* parse.y (parser_prepare): set token_info_enabled flag first,
  before returning at BOM.  [ruby-dev:50288] [Bug #13998]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-11 05:34:24 +00:00
nobu 838a91633c parse.y: fix a typo
* parse.y (f_kw): fix typo.  needs the argument value, not the
  label twice.  [ruby-core:83174] [Bug #13987]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-08 06:00:57 +00:00
nobu 80855409ce parse.y: fix KWD2EID
* parse.y (KWD2EID): should respect the previous callback result
  for keywords.  [ruby-core:83106] [Bug #13971]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-05 01:53:22 +00:00
nobu 2afb729f57 parse.y: fix var_field
* parse.y (mlhs_node): dispatch var_field as well as lhs.

* parse.y (lhs, var_hs): dispatch var_field before assignable
  check so it is inside assign_error at a wrong assignment, as
  well as backref_assign_error.

* parse.y (var_field_gen): wrap var_field value with the variable
  ID.

* parse.y (assignable_gen, const_decl_gen): return the callback
  result on a syntax error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-04 06:47:29 +00:00
nobu 3be412834d parse.y: reserved words as <id>
* parse.y (reswords): declare reserved words as <id> to remove
  extra cast.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-04 05:48:33 +00:00
nobu 8e03b79e06 parse.y: Revert r60102
* parse.y (op): do not set event ID here to dispatch on_op.
  [ruby-core:83089] [Bug #13967]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-04 04:43:00 +00:00
nobu 1ef2ca5a96 parse.y: extract callback results
* parse.y: stripping wrapping NODEs from ripper callback results,
  when storing in Array objects.  NODEs must not appear in Ruby
  level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-03 04:56:23 +00:00
nobu 75318f312d parse.y: set ripper event IDs to keyword variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-03 04:47:13 +00:00
nobu e8e5a45020 parse.y: set ripper event ID symbols to operators
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-03 01:38:52 +00:00
nobu 1852b4a866 ext: check if null byte is contained
[ruby-dev:50267] [Bug #13953]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-30 08:35:23 +00:00
nobu fbb9e6c1eb parse.y: moved duplicate conditions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-26 13:40:14 +00:00
nobu 80aa804a33 parse.y: token type by identifer ID type
* parse.y (parse_ident): leave identifier type decision (local or
  const) to rb_enc_symname_type, and set the token type by ID
  type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-23 06:49:35 +00:00
nobu 5983fd75f2 parse.y: missing semicolon
* parse.y (stmt_or_begin): fix missing semicolon.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-23 06:49:34 +00:00
nobu 5da2f77b93 parse.y: literal term lex_state
* parse.y (parser_string_term, parser_parse_string): move setting
  lex_state operations from parser_yylex per each token types.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20 08:38:52 +00:00
nobu 50f7d64f41 parse.y: lex by lvar
* parse.y (parse_ident): disable tLPAREN_ARG state by local
  variable.  [ruby-list:50578]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19 00:22:56 +00:00
nobu d1e63172c6 parse.y: ripper_lex_state_name
* parse.y (ripper_lex_state_name): represent lex_state as OR-ed
  form.

* ext/ripper/lib/ripper/lexer.rb (Ripper::Lexer::Elem#to_a):
  lex_state for inspection.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18 00:08:19 +00:00
nobu f22345427a parse.y: use SET_LEX_STATE
* parse.y (f_arglist, parser_yylex): set lex_state via
  SET_LEX_STATE macro for yydebug messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-15 08:47:46 +00:00
nobu 7df1e45bb6 ripper: add states of scanner
* parse.y (ripper_state): add states of scanner to tokens from
  Ripper.lex and Ripper::Filter#on_*.  based on the patch by
  aycabta (Code Ahss) at [ruby-core:81789].  [Feature #13686]

* ext/ripper/tools/preproc.rb (prelude, usercode): generate EXPR_*
  constants from enums.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 10:53:47 +00:00
nobu a61ae940c6 parse.y: [DOC] fix call-seq [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 10:49:29 +00:00
mame 3c8c17d30d Introduce NODE_UNLESS for branch coverage
`unless` statement was a syntactic sugar for `if` statement,
which made the result of branch coverage hard to understand.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 05:27:02 +00:00
mame 3155da024c Fix the lineno of case statement that has no expression
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 04:42:23 +00:00
mame cd6df5fb3c Refactor the internal data format for coverage measurement
To prepare new measuring targets: branch and method coverages.
So far, iseq->coverage was an array of counts executed for line coverage.
Now, it is a three-element array for each measuring target,
whose first element is an array for line coverage.
The second element is planned for branch coverage, and the third will be
for method coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-03 14:26:06 +00:00
nobu e7606de949 parse.y: primary should not be 0
* parse.y (primary): should not be 0, since it can be a receiver.
  [ruby-core:82447] [Bug #13836]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-22 13:21:18 +00:00
nobu e169fa9419 parse.y: unexpected tINTEGER message
* parse.y (parser_number_literal_suffix): keep token after numeric
  suffix to show the value in an error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-17 12:33:41 +00:00
nobu aa0f1dcbda parse.y: removed useless check
* parse.y (singleton): literal nodes are always value expressions,
  no check is necessary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-15 13:53:38 +00:00
nobu 29b114a1ea parse.y: set used flag in gettable
* parse.y (dvar_defined_ref, dvar_defined): rename macros.  only
  gettable uses the former.  assignable should not set LVAR_USED
  flag.

* parse.y (gettable_gen): set used flag on local/dynamic variables
  instead of setting in lexer.  [ruby-core:82368] [Bug #13809]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-13 13:34:26 +00:00
nobu 03a2862b98 separate hash literal and keyword arguments
* compile.c (compile_array_keyword_arg): separate keyword splat
  inside hash literal from argument list.

* parse.y (rparen): flag hash literal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-11 01:27:24 +00:00
nobu 4eafec5ea6 parse.y: simplify parse_ident
* parse.y (parse_ident): simplified selecting identifier types by
  the suffix.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-01 08:32:18 +00:00
nobu 7d6965f88d parse.y: brace after array literal arg
* parse.y (parser_yylex): array is another literal.  set state to
  END too not only ENDARG and after a literal, so that a left
  brace after it should be a primary block bound to the literal,
  which causes syntax error.  [ruby-core:81037] [Bug #13547]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-26 00:56:44 +00:00
nobu f29e5013ad parse.y: limit codepoint length
* parse.y (parser_tokadd_codepoint): limit Unicode codepoint
  length.  too long codepoint has been split unexpectedly since
  r57050.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-25 08:30:11 +00:00
rhe c4dfd0ccfb ripper: add kwrest_param parser event
* parse.y (f_kwrest): Dispatch kwrest_param event. This is especially
  useful for unnamed kwrest parameter for which we expose the internal
  ID currently.  [ruby-core:75528] [Feature #12387]

* test/ripper/dummyparser.rb (on_kwrest_param): Add handler for
  kwrest_param parser event.

* test/ripper/test_parser_events.rb (test_params): Adapt to the change
  in DummyParser.
  (test_kwrest_param): Test that kwrest_param event handler is called.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-21 04:29:46 +00:00
nobu 19e687ff03 parse.y: empty hash in defined
* parse.y (command): NODE_ARRAY with NULL is invalid.  traversal
  in defined_expr0 is simplified than iseq_compile_each0.
  [ruby-core:82113] [Bug #13756]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-20 05:48:26 +00:00
nobu 28695a8fff parse.y: refine literal error messages
* parse.y (parser_yyerror): strip newline in error source which
  will not be printed, when lex_p has passed it.

* parse.y (parser_tokadd_utf8): unterminated Unicode escape even
  after invalid Unicode escape.

* parse.y (parser_parse_string): show the error source line when
  unterminated literal at end of file.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-17 00:11:38 +00:00
nobu b17efb6874 parse.y: refine invalid Unicode escape message
* parse.y (literal_flush): rename from numeric_literal_flush, as
  it is not just for numerics now.

* parse.y (parser_tokadd_codepoint): show invalid character
  position, but not the start of Unicode escape.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-16 23:45:48 +00:00
nobu 360f85eb8b parse.y (numeric_literal_flush): fix typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-16 14:32:41 +00:00
nobu 80d502b881 parse.y: utf-8 codepoints
* parse.y (parser_tokadd_utf8): skip spaces in the current line,
  without advancing the line, to get rid of dangling pointer.
  [ruby-core:82029] [Bug #13742]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-16 13:39:18 +00:00
nobu 70af8d3c9c parse.y: refine error messages
* parse.y (parser_read_escape, parser_tok_hex): refine error
  messages.  point from the backslash up to the invalid char.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-15 08:29:03 +00:00
nobu 52e8254b54 parse.y: flush debug output
* parse.y (parser_compile_error): flush debug output before
  compile error message, to keep the order.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-13 07:00:16 +00:00
nobu f2d1848441 parse.y: f_margs parser events
* parse.y (f_margs): implemented parser events for massign
  formal arguments.  [ruby-core:81848] [Bug #13701]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-01 02:01:05 +00:00
nobu 844ca35a92 parse.y: mlhs_add_post
* parse.y (mlhs_add_post): new parser event corresponding to
  POSTARG.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-01 01:51:17 +00:00
nobu f78d92c5ca parse.y: fix token
* parse.y (parser_parse_string): return proper token tREGEXP_END
  at unterminated regexp.  [Bug #13363]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 06:13:00 +00:00
nobu 7c7d74365d parse.y: add ellipsis
* parse.y (parser_yyerror): add ellipsis properly when error line
  is truncated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 05:38:27 +00:00
nobu e42a16190c parse.y: flush numeric token
* parse.y (parser_number_literal_suffix, parse_numeric): flush
  numeric token so following unexpected token part is marked.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 04:08:51 +00:00
nobu ff36c25f47 parse.y: fix parser_yyerror
* parse.y (parser_yyerror): fix buffer overflow at truncation of
  error line.  [ruby-core:81790] [Bug #13687]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 02:02:38 +00:00
nobu c28f8b0394 parse.y: prefer enum yytokentype instead to int
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 01:49:44 +00:00
nobu a0c1006e89 parse.y: line number of bin op
* parse.y (call_bin_op_gen): adjust line number to the receiver,
  instead of the rhs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-26 10:31:34 +00:00
nobu fa480488f4 parse.y: mark error token
* parse.y (parser_yyerror): mark the whole last token which caused
  the error, not only the end.

before:
  ```
  if end
        ^
  ```

after:
  ```
  if end
     ^~~
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-26 09:40:39 +00:00
nobu af4ba5c12a parse.y: should not warn op method call
* parse.y (void_expr_gen): should warn operator expression style
  calls only, but not method style calls.  [Fix GH-1660]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23 11:56:48 +00:00
nobu d391697331 parse.y: check multibyte char
* parse.y (parser_precise_mbclen): check invalid multibyte char at
  skipping strings following `?x` literal string, not to stuck in
  a infinite loop.  [ruby-core:81746] [Bug #13672]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23 11:20:29 +00:00
nobu 99871095e6 parse.y: brace after literal arg
* parse.y (symbol, dsym, parser_set_number_literal, parser_yylex):
  set state to END too not only ENDARG and after a literal, so
  that a left brace after it should be a primary block bound to
  the literal, which causes syntax error.
  [ruby-core:81037] [Bug #13547]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09 17:20:00 +00:00
nobu 046c94380b parse.y: do after cmdarg in paren
* parse.y (parser_yylex): set state to ENDARG after a string
  literal, so that `do` after a literal should be `do_block` and
  bound to the outer method, as well as a numeric/symbol literal.
  [ruby-core:72482] [Bug #11873]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09 17:12:43 +00:00
nobu ac08e59b02 parse.y: export rb_parser_fatal for ripper
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-07 14:03:52 +00:00
nobu 9133f6648d parse.y: make shared string modifiable
* parse.y (dedent_string): ensure that the string is modifiable,
  not to set the length of shared string.
  [ruby-core:80987] [Bug #13540]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-04 06:54:11 +00:00
nobu 191be8057d parse.y: set_line_body is not used in ripper
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-28 09:50:43 +00:00
nobu 7d085cca4b parse.y: fix line in rescue
* parse.y (set_line_body, primary): fix line number of bodystmt as
  the beginning of the block.  [ruby-core:79388] [Bug #13181]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-28 08:06:33 +00:00
nobu 80f5067478 parse.y: args tail at error
* parse.y (new_args_tail_gen): abandon parsing arguments after
  error.  reported by ilsani Martino Sani (ilsani) at
  https://hackerone.com/reports/221201

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-24 06:17:55 +00:00