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

1654 Коммитов

Автор SHA1 Сообщение Дата
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
nobu 7c23609e60 parse.y: rb_parser_fatal
* parse.y (rb_parser_fatal): abort compilation on internal parser
  error.  rb_bug() is generic use but not useful for debugging the
  parser.  this function dumps internal states, and continues with
  enabling yydebug output to stderr for the parser stack dump.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-24 06:17:54 +00:00
nobu 5b3c9fc962 Get rid of unnecessary GCC extension
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-24 04:20:02 +00:00
nobu 27ed9f1d29 parse.y: fix compile_error format
* parse.y (ripper_compile_error, parser_compile_error): declare as
  PRINTF_ARGS attribute.

* parse.y (id_is_var_gen): fix format specifier for string value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-22 08:32:33 +00:00
nobu 158c742b51 parse.y: fix for empty `__VA_ARGS__`
* parse.y (WARN_CALL, WARNING_CALL): need `##` between a comman
  and `__VA_ARGS__` in the case it is empty, not to end arguments
  with a comma.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-17 01:35:54 +00:00