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

2073 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 1cdaa17a06
parse.y: numbered parameter symbol
* parse.y (parse_atmark): numbered parameter name is not allowed
  as a symbol regardless the context.
2019-05-28 09:00:02 +09:00
Nobuyoshi Nakada b4365e75fd
Do not make an incomplete escape a valid char 2019-05-27 23:08:48 +09:00
Nobuyoshi Nakada c40003da25
Ripper#token
* parse.y (ripper_token): added Ripper#token which returns the
  current token string.  [EXPERIMENTAL]
2019-05-27 23:08:45 +09:00
Nobuyoshi Nakada ea6e284d86
parse.y: removed "parser_" prefix from tokadd_utf8 2019-05-27 13:58:41 +09:00
Nobuyoshi Nakada a43c637660
parse.y: broke the terminator condition down
* parse.y (here_document): broke the terminator condition down
  into each piece, the positional condition, resetting the
  dedented here-document indentation, and matching identifier.
  suppress a false warning by icc.
2019-05-27 00:40:30 +09:00
Nobuyoshi Nakada 2ce6365f9c
parse.y: adjust error indicator
* parse.y (parser_yylex): adjust the error indicator of unexpected
  fraction part.

before:
~~~
1.2.3
^~~
~~~

after:
~~~
1.2.3
   ^~
~~~
2019-05-26 18:47:52 +09:00
Nobuyoshi Nakada 02b39daef8
Fix scanner event at invalid syntax
* parse.y (parser_yyerror, parser_compile_error): revert
  r67224 (e5d10cda07) "Flush erred
  token".
2019-05-26 16:24:33 +09:00
Nobuyoshi Nakada 2893550452
Mixed encoding error can continue to parse 2019-05-24 16:12:17 +09:00
Jeremy Evans c05eaa9325 Fix mixed encoding in heredoc
Heredocs are parsed line-by-line, so we need to keep track of the
temporary encoding of the string.  Previously, a heredoc would
only detect mixed encoding errors if they were on the same line,
this changes things so they will be caught on different lines.

Fixes [Bug #15839]
2019-05-22 21:52:20 -07:00
Nobuyoshi Nakada 7ef548c0ac
Mixed encoding error can continue to parse 2019-05-20 12:43:52 +09:00
Nobuyoshi Nakada 0ed9bdfc13
Pack struct rb_strterm_heredoc_struct on 32-bit platforms 2019-05-16 18:25:16 +09:00
Nobuyoshi Nakada e9bb30d47e
Expect no conflict in the parser 2019-05-12 00:13:52 +09:00
Nobuyoshi Nakada 79931dddba
Propagate parser_params to rb_yytnamerr 2019-05-10 22:02:54 +09:00
Hiroshi SHIBATA aa52464efd
15f45ae4d1 and 56528da3e broke the darwin environment.
Revert "Propagate parser_params to rb_yytnamerr"

This reverts commit 15f45ae4d1.
2019-05-10 21:48:02 +09:00
Nobuyoshi Nakada 15f45ae4d1
Propagate parser_params to rb_yytnamerr 2019-05-10 16:40:34 +09:00
Jeremy Evans bb4ac7a650
Fix use of numbered parameter inside proc that is default value of optarg
This allows cases such as:

```ruby
m ->(a = ->{@1}) {a}
m.call.call(1)

m2 ->(a: ->{@1}) {a}
m2.call.call(2)
```

Previously, this would cause a syntax error.

[Bug#15789]
2019-05-05 16:32:45 +09:00
Jeremy Evans b8f3be295b
Fix a case where numbered parameters should not be allowed
Because `proc{|| @1}` is a syntax error, the following should
also be syntax errors:

```ruby
proc { |
| @1}
```

```ruby
proc { |; a| @1 }
```

This fixes both cases.

[Bug #15825]
2019-05-05 14:46:39 +09:00
Nobuyoshi Nakada ff21e75d32
parse.y: duplicated when clause warning
* parse.y (case_args): moved "duplicated when clause" warning from
  compile phase, so that `ruby -wc` shows them.
2019-05-05 00:29:12 +09:00
Nobuyoshi Nakada 6a3165e19d
Fixed HERETERM_LENGTH_MAX on IL32LLP64 2019-04-29 18:32:21 +09:00
Nobuyoshi Nakada c7f780c155
Refactored rb_strterm_heredoc_t 2019-04-29 17:45:58 +09:00
Nobuyoshi Nakada 1432471a75
Disallow also CR in here-doc identifier
* parse.y (heredoc_identifier): CR in here-document identifier
  might or might not result in a syntax error, by the EOL code.
  make a syntax error regardless of the EOL code.
2019-04-29 13:47:20 +09:00
Nobuyoshi Nakada 330b376133
parse.y: fix here-doc identifier with newline
* parse.y (heredoc_identifier): quoted here-document identifier
  must end within the same line.

  the only corner case that here-document identifier can contain a
  newline is that the closing qoute is placed at the beginning of
  the next line, and has been warned since 2.4.

  ```ruby
  <<"EOS
  " # warning: here document identifier ends with a newline
  EOS
  ```
2019-04-29 12:49:59 +09:00
Nobuyoshi Nakada 54eac83b2a
Hide internal IDs
* parse.y (internal_id): number the ID serial for internal use by
  counting down from the neary maximum value, not to accidentally
  match permanent IDs.

[Bug #15768]
2019-04-26 09:33:48 +09:00
Nobuyoshi Nakada 2272cb00ea
Ripper does not use internal IDs directly 2019-04-25 20:33:18 +09:00
Nobuyoshi Nakada 89271d4a37
Adjusted indents 2019-04-23 20:27:24 +09:00
Seiei Miyagi 6ca9e7cc07
Disallow numbered parameter as the default value of optional argument
[Fix GH-2139] [Bug #15783]
2019-04-23 12:16:15 +09:00
Seiei Miyagi ae07b66aaa
Fix internal error of `->x:@2{}`
[Fix GH-2139] [Bug #15783]
2019-04-23 12:16:14 +09:00
Nobuyoshi Nakada 9cdb736672
Missing semicolon 2019-04-23 10:24:31 +09:00
ktsj 243842f68a Avoid usage of the dummy empty BEGIN node
Use NODE_SPECIAL_NO_NAME_REST instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20 03:37:22 +00:00
nobu c3c4e411eb parse.y: suppress warning
* parse.y (parser_append_options): explicitly pass $; when auto
  splitting, to suppress the warning for non-nil $;.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-18 22:24:03 +00:00
ktsj 9738f96fcf Introduce pattern matching [EXPERIMENTAL]
[ruby-core:87945] [Feature #14912]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17 06:48:03 +00:00
nobu d8442c4306 parse.y: fix fatal messages
* parse.y (rb_parser_fatal): fix "parser" in the message which was
  replaced accidentally.  it is not the argument name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 12:43:32 +00:00
kazu 25c1fd3b90 Reverting all commits from r67479 to r67496 because of CI failures
Because hard to specify commits related to r67479 only.
So please commit again.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 09:15:21 +00:00
nobu cc02df324f parse.y: fix fatal messages
* parse.y (rb_parser_fatal): fix "parser" in the message which was
  replaced accidentally.  it is not the argument name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 05:12:33 +00:00
mame 95f7992b89 Introduce beginless range [Feature#14799]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-03 08:11:41 +00:00
nobu ee5b54822c parse.y: show error line separately
* parse.y: show compile error and the error line separately,
  instead of building the error message by snprintf then yyerror.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-28 10:19:08 +00:00
nobu 740248425c parse.y: make tNUMPARAM id
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-20 00:31:02 +00:00
nobu afa1505ca8 parse.y: removed redundant number_arg parser event
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-19 06:23:36 +00:00
nobu fa66569afa parse.y: fix var_ref of numbered param in ripper
* parse.y (string_dvar, user_variable): register numbered
  parameter in ripper for var_ref.
  [ruby-core:91867] [Bug #15673]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-19 06:01:21 +00:00
nobu e39f7e64b7 parse.y: fix segv with Ripper#yydebug
* parse.y (parser_token_value_print): in ripper, ID values are
  wrapped in NODE_RIPPER at set_yylval_name(), so print the Symbol
  wrapped together.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-19 02:35:50 +00:00
nobu ae5d9a7664 Added Ripper#debug_output
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-19 02:25:15 +00:00
nobu 964bbc1686 parse.y: numbered parameter in lambda
* parse.y (lambda): support numbered parameters, only when no
  argument list including empty parentheses, like empty vertical
  bars.  [ruby-core:91859] [Bug #15672]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-18 12:48:18 +00:00
nobu 17018d4c31 parse.y: continue after invalid name
* parse.y (set_yylval_noname): continue after an invalid global,
  instance, class variable name, without "unexpected end-of-file"
  error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-18 06:42:19 +00:00
nobu d0e25ed277 parse.y: parser_numbered_param
* parse.y (parser_numbered_param): hoisted out the contextual
  check for numbered parameters.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-18 01:18:25 +00:00
nobu 12acc751e3 Numbered parameters [Feature #4475]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-17 05:21:18 +00:00
ktsj 7006fdecf2 dsym should be treated as string [ruby-core:91852] [Bug #15670]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-16 04:00:14 +00:00
nobu 3134b20a01 Show the source line at an invalid class/instance variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-15 00:44:51 +00:00
nobu 9800fc26b0 parse.y: no punctuation instance/class variables
* parse.y (parse_atmark): exclude punctuation follows @ marks,
  whereas it is inclusive after $ mark as some punctuation global
  variables exist.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-14 08:13:46 +00:00
nobu 9c077bbed9 parse.y: show invalid global variable line
* parse.y (parse_gvar): show the source line erred by invalid
  global variable, and indicate the variable including the wrong
  punctuation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-14 05:57:42 +00:00
nobu ccc933d4a6 Hoisted out ruby_show_error_line
* parse.y (ruby_show_error_line): hoisted out from parser_yyerror.

* parse.y (regx_options): revert r67226 and show the error line
  separately.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-14 05:32:30 +00:00
nobu 86c5806c6a More initializations of YYLTYPE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-14 02:18:05 +00:00
nobu 8415df619e Remove unnecessary local variable
newline is always "\n" when it is used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-13 01:44:34 +00:00
nobu b6468b01f7 Show unkwon regexp option line
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-12 04:23:17 +00:00
nobu e5d10cda07 Flush erred token
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-12 04:11:41 +00:00
nobu bda6df356a parse.y: moved excessed_comma
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-11 12:47:02 +00:00
nobu 60023cf452 parse.y: trim newline in erred code
* parse.y (parser_yyerror): trim a newline at the end of the erred
  code which was replaced with an extra space in the succeeding
  cursor line.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-26 13:43:32 +00:00
nobu 6375c68f88 parse.y: function parser_mixed_error & parser_mixed_escape
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-24 12:36:04 +00:00
nobu 7e68efbc95 parse.y: remove an extra error message
* parse.y (parse_string): bail out when word-list meets end of
  input not to show an extra "unexpected" error message after the
  preceding error.

      $ ruby -e "%w["
      -e:1: unterminated string meets end of file
      -e:1: syntax error, unexpected terminator, expecting ' '

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-24 11:43:11 +00:00
nobu c56f61161a parse.y: token name of tSTRING_DEND
* parse.y (rb_yytnamerr): show single-quoted single char as-is, to
  show a quoted closing brace as tSTRING_DEND.  e.g.:

      $ ./ruby -e '"#{true'
      -e:1: syntax error, unexpected end-of-input, expecting '}'

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-23 09:39:45 +00:00
nobu 71342a46ac parse.y: token names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-23 09:08:22 +00:00
nobu bcf85587b1 parse.y: literal add_mark_object
* parse.y (set_yylval_str, set_yylval_literal): always imply
  add_mark_object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-22 23:21:58 +00:00
nobu 4e64c54728 ripper.y: get rid of compile error
yystpcpy is always used by yysyntax_error in bison 2.3, but may
not used by other than yytnamerr in newer bison.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-22 07:25:08 +00:00
nobu 59a6215af6 parse.y: enclose keyword token names by quotes
* parse.y (rb_yytnamerr): strip enclosing double-quotes, same as
  the default yytnamerr except for that single-quotes matching
  back-quotes do not stop stripping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-22 06:24:59 +00:00
nobu 62ec5eb018 parse.y: more token names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-21 10:24:56 +00:00
nobu 9cbb4dde74 parse.y: refactored symbol rules
* parse.y (symbol): turned into a node, as well as `numeric`, for
  a symbol literal, and includes `dsym` now.

* parse.y (ssym): previous `symbol`.  renamed as the counterpart
  of `dsym`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-05 13:15:07 +00:00
nobu 59f59f82d4 parse.y: refine error messages
* parse.y: refine error messages for tSYMBEG and tSTRING_BEG, which
  can appear at invalid places.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-05 11:35:24 +00:00
nobu 67c5747369 Method reference operator
Introduce the new operator for method reference, `.:`.
[Feature #12125] [Feature #13581]
[EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31 15:00:37 +00:00
nobu f89238ec0d parse.y: ignore constant name captures
* parse.y (reg_named_capture_assign_iter): ignore non-local name
  captures, including non-ASCII constant names.
  [ruby-dev:50719] [Bug #15437]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-20 05:43:15 +00:00
yui-knk dd78257919 Fix locations of NODE_UNDEF in undef with multiple args
* parse.y: Fix the beginning position of trailing NODE_UNDEF.

  e.g. The location of the NODE_UNDEF for `b` is fixed:

  ```
  undef a, b
  ```

  * Before

  ```
  NODE_UNDEF (line: 1, location: (1,6)-(1,10))
  ```

  * After

  ```
  NODE_UNDEF (line: 1, location: (1,9)-(1,10))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-25 12:31:35 +00:00
nobu 87b03e8c3c parser: improve error messages
[Fix GH-2011]

From: Akim Demaille <akim.demaille@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-25 08:31:40 +00:00
nobu f800c5fc8e Constified ruby_sourcefile
which usually refers ruby_sourcefile_string and is not freed
directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-10 12:04:18 +00:00
nobu 6e610f5ea7 Parse the source in SCRIPT_LINES__ as array
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-10 11:40:33 +00:00
nobu 4bf84ede20 Get rid of setting SCRIPT_LINES__ by AST.parse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09 13:39:36 +00:00
yui-knk ce798d08de Implement `RubyVM::AST.of` [Feature #14836]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-05 02:13:45 +00:00
nobu 0c6edda08c parse.y: last node of NODE_ARRAY
* parse.y (heredoc_dedent): manage the last node of NODE_ARRAY,
  when concatenating dedented literals.
  [ruby-core:89649] [Bug #15272]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-31 02:57:30 +00:00
nobu a769027f79 parse.y: last location from bison
* parse.y (command): set the last location from the location
  managed by bison, so that other nodes are not needed.
  [ruby-core:89648] [Bug #15271]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 23:43:13 +00:00
mame c9d720b873 parse.y: remove "shadowing outer local variable" warning
You can now write the following without warning.

    user = User.all.find {|user| cond(user) }

Fixes [Feature #12490].
A patch from Soutaro Matsumoto <matsumoto@soutaro.com>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26 03:10:02 +00:00
mame b171d92046 Revert "parse.y: remove "shadowing outer local variable" warning"
I forgot to add the copyright of the patch...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26 03:08:10 +00:00
mame 7f69d4e41f parse.y: remove "shadowing outer local variable" warning
You can now write the following without warning.

  user = User.all.find {|user| cond(user) }

Fixes [Feature #12490].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26 02:54:01 +00:00
yui-knk 2bfbec8745 parse.y: Fix the compile error
* parse.y: Fix "error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 11:06:05 +00:00
yui-knk 4d4b60acea Fix locations of NODE_SCOPE in lambda.
* parse.y: Fix to start with the argument.

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

  ```
  -> x { 1 + 2 }
  ```

  * Before

  ```
  NODE_SCOPE (line: 1, location: (1,2)-(1,14))
  ```

  * After

  ```
  NODE_SCOPE (line: 1, location: (1,3)-(1,14))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 10:53:31 +00:00
yui-knk 46447667f1 Fix locations of NODE_LAMBDA.
* node.h: Add `nd_first_loc` and `nd_set_first_loc`

* parse.y: Fix to start with the beginning of `->` .

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

  ```
  -> x { 1 + 2 }
  ```

  * Before

  ```
  NODE_LAMBDA (line: 1, location: (1,2)-(1,14))
  ```

  * After

  ```
  NODE_LAMBDA (line: 1, location: (1,0)-(1,14))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 10:10:46 +00:00
yui-knk 39fd63428d parse.y (struct ripper_args): Remove not used struct definition
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 05:33:37 +00:00
nobu d325d74174 parse.y: fix block passing with empty kwargs
* parse.y (arg_blk_pass): preceeding arguments node may be NULL when
  an empty keyword argument hash splat is optimized away.
  [ruby-core:88890] [Bug #15087]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-20 01:43:35 +00:00
mame fad01941b3 parse.y (arg_append): support NODE_ARGSCAT case
Because of the lack of this case, `[*ary,1,2,3,4,5,6]` was parsed into
an inefficient AST like `ary + [1,2] + [3,4] + [5,6]`.

A patch from Anmol Chopra <anmolchopra@rocketbox.in>.
Fixes [Bug #15018].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-22 15:04:05 +00:00
mame d65f7458bc parse.y: remove coverage-related code fragments
The code fragments that initializes coverage data were scattered into
both parse.y and compile.c.  parse.y allocated a coverage data, and
compile.c initialize the data.

To remove this cross-cutting concern, this change moves the allocation
from "coverage" function of parse.y to "rb_iseq_new_top" of iseq.c.
For the sake, parse.y just counts the line number of the original source
code, and the number is passed via rb_ast_body_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-22 10:38:56 +00:00
yui-knk e70cad6091 parse.y (heredoc_identifier): Update comment for term_len
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-16 02:07:44 +00:00
yui-knk d21f468dab parse.y: Add comment for `rb_strterm_heredoc_struct.sourceline`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-16 01:26:25 +00:00
mame bae638ad5b parse.y: Deprecate flip-flops
Ref #5400

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-15 08:53:15 +00:00
mame 606d6b3470 Revert "range.c: prohibit `(1..nil)`"
This reverts commit a44c010764a16ae09aaed49d76eec055ca0057c8.
Refs #14845.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13 11:00:28 +00:00
mame 48de2ea5f9 range.c: prohibit `(1..nil)`
Now endless range can be created by either a literal `(1..)` or explicit
range creation `Range.new(1, nil)`.  [Bug #14845]

This change is intended for "early failure"; for example,
`(1..var).to_a` causes out of memory if `var` is inadvertently nil.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13 09:04:32 +00:00
yui-knk 744b0bdb7b parse.y: Fix locations of none and mid-rule actions
When an empty rule or a mid-rule action is reduced,
`YYLLOC_DEFAULT` is called with the third parameter to be zero.
If we use `RUBY_SET_YYLLOC_OF_NONE` to set their locations,
sometimes the end position of NODE indicates a blank.
For example, `a.b ;` generates `NODE_CALL (line: 1, location: (1,0)-(1,4))*`,
whose end position indicates a blank.

This is because of the following reasons:

* `NODE_CALL` is created when `primary_value call_op operation2 opt_paren_args` is
  reduced to `method_call`.
* `opt_paren_args` is `none`.
* `yylex` is called and `lex.pbeg` moves before `none` is reduced, so
  the beginning position of `none` does not match with the end position of `operation2`.

To fix locations, use `YYRHSLOC(Rhs, 0)` in `YYLLOC_DEFAULT`
(0 "refers to the symbol just before the reduction").

By this change, the bottom of the location stack would be referenced,
so initialize the bottom with `RUBY_SET_YYLLOC_OF_NONE` in `%initial-action`.

Ref: https://www.gnu.org/software/bison/manual/html_node/Location-Default-Action.html#Location-Default-Action

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-10 06:22:15 +00:00
yui-knk aee5c4338b parse.y: Fix locations of NODE_RESCUE
* parse.y (new_bodystmt): Fix locations of NODE_RESCUE
  to end with nd_else or nd_resq. Before this commit,
  locations of NODE_RESCUE included locations of nd_ensr
  of NODE_ENSURE which is a parent node of NODE_RESCUE.

  e.g. The location of the end of NODE_RESCUE is fixed:

  ```
  def a
    :b
  rescue
    :c
  ensure
    :d
  end
  ```

  * Before

  ```
  NODE_RESCUE (line: 2, location: (2,2)-(6,4))
  ```

  * After

  ```
  NODE_RESCUE (line: 3, location: (2,2)-(5,0))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-10 05:02:26 +00:00
normal 1c1ff52f43 parse.y: use ruby_sized_xfree and SIZED_REALLOC_N
Another part of the plan to reduce dependencies on malloc_usable_size
which costs us speed: https://bugs.ruby-lang.org/issues/10238

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-22 00:44:22 +00:00
shyouhei 687308cf0d explicit cast to void* required for %p
No automatic type promotion is expected for variadic arguments.
You have to do it by hand.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-21 00:41:57 +00:00
nobu 4dc5b6ff58 parse.y: relax literal in condition warnings
* parse.y (cond0): do not warn literal boolean (true and false) in
  condition expressions, as they are often used as infinite loops,
  deactivated code block, etc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-18 00:36:24 +00:00
nobu 8487c63fa3 rb_parser_printf declaration
* node.h (rb_parser_printf): delcare as PRINTF_ARGS.

* parse.y (parser_token_value_print): cast to adjust to %c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-17 12:36:33 +00:00
nobu b936115ed6 fix potential memory leaks
* parse.y (primary, new_args_tail, local_tbl): keep the order;
  allocate an empty imemo first then xmalloc, to get rid of
  potential memory leak when allocation imemo failed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-11 13:01:36 +00:00
yui-knk 5afa84b028 parse.y: Fix locations of NODE_NIL in endless ranges.
* parse.y: Fix to start with the end of dots.

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

  ```
  1..
  ```

  * Before

  ```
  NODE_NIL (line: 1, location: (1,0)-(1,3))
  ```

  * After

  ```
  NODE_NIL (line: 1, location: (1,3)-(1,3))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-10 06:34:20 +00:00
nobu 6e06d6440b fix potential memory leaks
* gc.c (rb_alloc_tmp_buffer_with_count): keep the order; allocate
  an empty imemo first then xmalloc, to get rid of potential
  memory leak when allocation imemo failed.

* parse.y (rb_parser_malloc, rb_parser_calloc, rb_parser_realloc):
  ditto.

* process.c (rb_execarg_allocate_dup2_tmpbuf): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-09 17:40:04 +00:00
mame e9303e1a00 Rename imemo_alloc with imemo_tmpbuf
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-09 07:11:59 +00:00
mame af0696782d gc.c (rb_imemo_alloc_new): split for each purpose
imemo_alloc is used for three purposes: auto-free pointer (alternative
of alloca), alloc_tmp_buffer, and heap allocation for bison.
To make it clear, this change introduces three functions:
rb_imemo_alloc_auto_free_pointer,
rb_imemo_alloc_auto_free_maybe_mark_buffer, and
rb_imemo_alloc_parser_heap.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-09 07:08:53 +00:00
mame 58823392b4 gc.c (rb_imemo_alloc_new): improve the API interface
rb_imemo_alloc_new returns rb_imemo_alloc_t*, but took VALUEs, which is
inconsistent.  To make the intention clear, it now takes only a pointer
to the buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-09 06:12:17 +00:00
mame 7f95eed19e Introduce endless range [Feature#12912]
Typical usages:
```
p ary[1..]          # drop the first element; identical to ary[1..-1]
(1..).each {|n|...} # iterate forever from 1; identical to 1.step{...}
```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19 15:18:50 +00:00
nobu f168dbd9ef parse.y: fix cmdarg in command_args
* parse.y (call_args): fix invalid CMDARG state after command_args
  followed by tLBRACE_ARG.  [ruby-core:86551] [Bug #14690]

From: Ilya Bylich <ibylich@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-17 01:22:26 +00:00
nobu 3b93a8bcad parse.y: `else` indent
* parse.y (keyword_else): warn less-indented `else` than `case`.
  [ruby-core:86492] [Bug #14674]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-16 08:54:03 +00:00
nobu a3a5f38d09 parse.y: `when` indent
* parse.y (k_when): warn less-indented `when` than `case`.
  [ruby-core:86492] [Bug #14674]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-12 22:13:09 +00:00
nobu bbcab8c6f3 parse.y: [DOC] Ripper.dedent_string is internal
* parse.y (parser_dedent_string): stated that Ripper.dedent_string
  is for internal use only.

[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-09 12:39:59 +00:00
nobu 6a57127222 parse.y: extra error message after no digits
* parse.y (no_digits): return tINTEGER instead of unexpected
  end-of-input, to get rid of extra error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-09 11:09:30 +00:00
stomar d33ddd631b parse.y: fix docs for Ripper.dedent_string
* parse.y: [DOC] fix return type in call-seq of Ripper.dedent_string,
  clarify the method's behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08 19:39:38 +00:00
nobu 9c5d90b516 Use only CMDARG/COND _PUSH/POP for cmdarg/cond management.
From: Ilya Bylich <ibylich@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-29 03:42:32 +00:00
nobu e5a30879f9 parse.y: remove `p->` from bitstack traces
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-29 01:33:25 +00:00
nobu f3fbf1dfad parse.y: k_else in bodystmt
* parse.y (bodystmt): expand opt_else to show the error message at
  the right place.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-23 01:09:57 +00:00
nobu 140512d222 parse.y: else without rescue
* parse.y (bodystmt): [EXPERIMENTAL] make `else` without `rescue`
  a syntax error.  [DevelopersMeeting20180315Japan]

  https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20180315Japan
  https://docs.google.com/document/d/1RT0ijSo8uJ4Awn3CEvuYkjH0TVeXSYgeAFNmVGYC3ak/edit#
  > * do-else-end
  >   https://twitter.com/joker1007/status/974173396006129664
  >   https://twitter.com/joker1007/status/974173641347756032
  >   https://twitter.com/joker1007/status/974176512554369027
  >   Will be SyntaxError in 2.6-preview2
  >   All of begin/do/def (experimental)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-23 00:40:08 +00:00
nobu 721b55d70c parse.y: reorder in the place
* parse.y (new_args_tail): reorder required and optional keyword
  argument variable IDs in the place.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-22 06:47:53 +00:00
nobu 58fbe69a5b parse.y: terminator at continued line
* parse.y (here_document): a continuing line is not the
  terminator.  [ruby-core:86283] [Bug #14621]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-21 12:40:16 +00:00
nobu 491f523ab1 parse.y: unindent continued line
* parse.y (tokadd_string): stop at continued line in dedented here
  documents, to dedent for each lines before removing escaped
  newlines.  [ruby-core:86236] [Bug #14621]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-21 10:32:15 +00:00
nobu b4b3de3e7c node.c: predicates for special NODEs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-20 13:30:57 +00:00
nobu 6916130566 parse.y: NUL-terminate ruby_sourcefile
* parse.y (yycompile): in some cases (warning, error, dtrace,...),
  ruby_sourcefile is expected to be NUL-terminated, so ensure it.

* template/prelude.c.tmpl (prelude_name): NUL-terminate to get rid
  of copying static data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19 14:12:00 +00:00
nobu 7e199e4156 parse.y: push `do` token info
* parse.y (k_rescue, k_ensure): revert r62838.

* parse.y (k_do, k_do_LAMBDA, k_do_block): push token infos of
  `do`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19 12:40:34 +00:00
nobu 5399951b00 parse.y: ignore do indentations
* parse.y (k_rescue, k_ensure): ignore indentations of `do`, it
  is not at the beginning of line usually.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19 08:37:12 +00:00
nobu d34bc779a7 parse.y: mismatched indentations at middle
* parse.y (k_rescue, k_ensure, k_when, k_else, k_elsif): warn
  mismatched indentations at keywords in middle of blocks.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19 08:21:26 +00:00
nobu 62182eb0a4 parse.y: fix duplicate kwrest
* parse.y (f_kwrest): add the variable name as an argument, as
  well as an internal variable.

* parse.y (new_args_tail): now keyword rest argument variable is
  always placed between keyword arguments and block argument, so
  so just reorder required and optional keyword arguments.  no
  longer kwrest duplicates.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19 03:16:40 +00:00
nobu 7773cfa496 ripper: fix escaped space
* parse.y: use tSP same as ripper instead of tSPACE.
  [ruby-core:86080] [Bug #14597]

* ext/ripper/eventids2.c: tSP is defined in ripper.c now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-12 07:55:17 +00:00
nobu f2b094a522 parse.y: fix interpolated string literal dedent
* parse.y (heredoc_dedent): fix interpolated string literal dedent,
  remove indentations from only nodes with the newline flag.
  [ruby-core:85983] [Bug #14584]

* parse.y (here_document): set the newline flag on literal string
  nodes starting at the beginning of line.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-11 12:19:08 +00:00
nobu e1a60b2db9 parse.y: reduce duplicate code
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-11 12:12:08 +00:00
nobu decb59ba83 parse.y: tSPACE for old bison
* parse.y (tSPACE): define a separate token for escaped space, to
  fix `redefining user token number of ' '` error at word list
  separator on bison 2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-06 09:03:24 +00:00
nobu d2a03300d3 parse.y: named whitespaces
* parse.y: named escaped whitespaces to show unexpected character.
  bare whitespaces should not appear outside of word_list.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-05 08:32:46 +00:00
nobu c9ecea33da parse.y: refine assign_in_cond warning
* parse.y (assign_in_cond): refine a warning message for
  assignment of a literal in conditinal expression.
  [ruby-core:85872] [Bug #14562]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-01 04:10:25 +00:00
nobu 96db72ce38 [DOC] missing docs at toplevel
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-23 02:18:52 +00:00
nobu 1727c83584 Fix CMDARG manipulation
* parse.y: Fix CMDARG manipulation. Use CMDARG_P to identify
  keyword_do/keyword_do_block.  [Feature #14506] [Fix GH-1823]

From: Ilya Bylich <ibylich@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-22 12:51:41 +00:00
nobu 7036c4062e parse.y: named backslash
* parse.y: named backslash to show unexpected character.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-03 07:30:39 +00:00
nobu 55e606b36c parse.y: use lex_goto_eol to skip to EOL
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-03 07:21:58 +00:00
nobu c0d22698e3 parse.y (parser_append_options): shorter alias LOC
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-28 14:05:39 +00:00
nobu 813a206d56 parse.y: fix yytokentype function declarations
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-23 14:17:25 +00:00
nobu 502d0bab51 parse.y: added implicit parser_params argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-23 03:53:34 +00:00
nobu 8563942ad9 parse.y: added new_strterm wrapper
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-23 03:37:21 +00:00
nobu 63c047f10a parse.y: concat dedented heredoc
* parse.y (heredoc_dedent): concat literal strings after dedented.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-23 02:31:42 +00:00
nobu 2bf8cac208 parse.y: removed implicit parser_params macros
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-23 02:23:18 +00:00
nobu c91b8a1b3d parse.y: expand tokp macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-21 15:26:20 +00:00
nobu 3cefccb6f9 parse.y: add EXPR_NONE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-21 15:26:19 +00:00
nobu 543ed3652f parse.y: fix state after left brace
* parse.y (parser_yylex): as well as `tLBRACE_ARG` (expr block),
  `tLBRACE` (primary block) also does not accept a label.  only
  hash brace accepts a label.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-21 07:44:25 +00:00
nobu 3a12eb82b2 parse.y: revert trace message to lex_state
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-21 07:44:24 +00:00
nobu bb5772de26 parse.y: use enum yytokentype
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-21 07:44:24 +00:00
nobu 46e2fad66a parse.y: parser_token_value_print for yydebug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-21 07:44:23 +00:00
mame f69bf70881 parse.y: Remove unneeded macro nd_set_line
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 17:52:50 +00:00
mame 5db2894229 parse.y: Remove double meaning of new_qcall/new_command_qcall
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 17:45:25 +00:00
mame 7ba7a2f70e parse.y: rewrite excessed_comma process
Currently, parser.y includes core parser and Ripper parser obscurity.
In addition, *some* Ripper code uses the result of the core parser,
which make it difficult to separate the two parsers.

I want to simplify this, not by separating the two parsers, but by
making *all* Ripper actions follows the core parser actions.
In other words, all the core parser actions run always even in Ripper,
and after that, Ripper-specific actions run.

For tha sake, in principle, I want to put `/*% ripper: ... %*/` in the
end of actions.
Anyway, it is too dirty to put it within expressions, IMO.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 16:21:29 +00:00
mame 43aa218de3 parse.y: Remove macros that are no longer used
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 16:21:28 +00:00
mame 57deb6fe18 parse.y: Remove double meaning of new_op_assign, etc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 16:21:26 +00:00
mame 4d7b8af1cd parse.y: Remove double meaning of new_xstring/new_string1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 16:21:25 +00:00
mame a2688019e5 parse.y: remove double meaning of new_brace_body/new_do_body
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 16:21:23 +00:00
mame c4c135cb7e parse.y: remove double meaning of const_path_field/top_const_field
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 16:21:20 +00:00
mame 9e95513781 parse.y: Remove unneeded var_field_1 trick
I thought this trick was needed because the result of var_field was
passed to different arguments, as follows:

```
$1 = var_field(p, $1);
$$ = backref_assign_error(p, $1, $1, &@$);
```

Currently the DSL supports that one result is passed to one argument.

However, after the refactoring, I found that `backref_assign_error`
uses only one `$1`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 06:11:21 +00:00
nobu a8a4bdb72e parse.y: dot_or_colon as id
* parse.y (dot_or_colon): made type of `dot_or_colon` and EXPR_DOT
  tokens to <id> and set those IDs at tokenization.  type cast at
  primary in ripper is no longer needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 05:58:06 +00:00
nobu 7efe4e0881 parse.y: moved excessed_comma
* parse.y (block_param): embed excessed_comma event result in
  place of rest argument, instead of dispatching with the whole
  parameters.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 05:47:59 +00:00
nobu 0b8594209d dsl.rb: p
* ext/ripper/tools/dsl.rb (DSL#initialize): define `p` for `struct
  parser_params *p`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 05:39:03 +00:00
nobu b5be3e7893 dsl.rb: ID constants
* ext/ripper/tools/dsl.rb (DSL#method_missing): expand ID
  constnats without parentheses.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 05:39:02 +00:00
nobu b54f2addaa dsl.rb: const_missing
* ext/ripper/tools/dsl.rb (DSL.const_missing): define to expand
  Qnil and Qundef as-is.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 05:39:01 +00:00
nobu 76b609c8c3 parse.y (yycompile0): check if accepted
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 01:24:15 +00:00
mame c4380069b7 parse.y (assignable): Remove macro hell
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 17:29:27 +00:00
mame a403faa1b7 parse.y: Split the path of assignable to Ripper/Parser
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 17:06:56 +00:00
mame d0b094b062 parse.y: Remove double meaning of node_assign
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 16:28:23 +00:00
mame 193b158b23 parse.y: Remove double meaning of backref_assign_error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 16:24:07 +00:00
mame a64054cd34 parse.y: Remove unneeded type decls for Ripper
I think that they are not used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 15:43:42 +00:00
mame c141a0f7e7 parse.y: swap `foo!` and `foo` in Ripper DSL
`foo!(...)` means Ripper event, and `foo(...)` means C function/macro
call.  This is for fail-safe; if I forget `!` accidentally, it would
fail to compile, instead of wrongly adding a new Ripper event.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 15:22:36 +00:00
nobu f1b696480a parse.y: assign to $$
* parse.y (command): assign to $$.  should not rely upon
  undocumented behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 13:41:44 +00:00
mame e82059ce6e parse.y: fix up r61957, too
My apologies!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 13:36:03 +00:00
nobu 70321a23d2 parse.y: fix up r61957
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 13:25:49 +00:00
mame bf7621d81d parse.y: Allows Ripper DSL to embed C function calls as `foo!`
Instead of `_foo`.  This makes it useful to do word boundary search of
the editor.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 13:11:11 +00:00
mame f8dd91e6f3 parse.y: Remove new_command
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 11:10:39 +00:00
mame 9b7fe0a250 ext/ripper: Introduce a simple DSL for ripper.y code generation
Currently, parse.y actions are hard to read and write because the code
has double meaning (for core parser and for ripper).  I think that, if
it is easy to write ripper's code shortly and simply, the double meaning
trick is not needed.

For the sake, this change adds a simple DSL for ripper's code.  For
example, in parse.y, we can write:

    /*% ripper: stmts_add(stmts_new, void_stmt) %*/

instead of:

    $$ = dispatch2(stmts_add, dispatch0(stmts_new),
                   dispatch0(void_stmt));

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 10:48:08 +00:00
mame 9eb4344a16 parse.y: Fix excessed_comma event
I believe that the assignment to `$$` was just forgotten.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 10:26:12 +00:00
shyouhei 8fca7e003a rb_parser_lex_state_names marked as static
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 09:44:51 +00:00
nobu b2feea2945 parse.y: no longer undef assignable
* parse.y (assignable): no longer needs to undef since r61899.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 03:37:08 +00:00
nobu e6883ef688 parse.y: fix overflow
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 03:29:12 +00:00
nobu 257fbc2c51 parse.y: REQUIRED_KEYWORD
* parse.y (REQUIRED_KEYWORD): special argument for required
  keyword argument, for core and ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 03:25:20 +00:00
nobu edb8b498f9 parse.y: refine negate_lit_gen error message
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-17 06:05:37 +00:00
mame f8a0c7d629 parse.y: Refactor for-statement generation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 15:12:15 +00:00
mame 0160006b59 parse.y (new_args_tail): Use human-friendly variable names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 15:12:11 +00:00
nobu b343c53db0 parse.y: unified local_push argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 08:21:40 +00:00
nobu 1c0073fa64 parse.y: simplified compstmt
* parse.y (top_compstmt, compstmt): unified void_stmts with
  ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 08:05:57 +00:00
mame 4b6f3bce25 node.c: Stop double meaning of NODE_FOR by introducing NODE_FOR_MASGN
NODE_FOR was used both for "for"-statement itself and for
multi-assignment of for-statement (for x, y, in...end).
This change separates the two purposes, NODE_FOR for the former, and
newly introduced NODE_FOR_MASGN for the latter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 07:24:53 +00:00
mame ce769284a1 parse.y (expr_value_do): factor out COND_PUSH->expr_value->do->COND_POP
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 05:27:20 +00:00
nobu 96dcd21510 parse.y: removed PARSER_ARG macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 03:16:17 +00:00
nobu 28e554a697 parse.y: expand tokadd_mbchar
* parse.y (tokadd_mbchar): renamed and expand callers with p.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 03:16:15 +00:00
mame 840d0dc180 parse.y: set location of nodes that lexer generates
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 02:27:58 +00:00
mame 6fe72f294d parse.y: set location of string/literals in the lexer instead of actions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 02:00:16 +00:00
mame cf924a05e0 parse.y (new_regexp): Fix SEGV of `/#{"\u3042"}#{'い'}/` in non UTF-8
Mixing other encoding string literals in one Regexp caused SEGV.
This bug was found by CoverityScan.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 01:43:25 +00:00
mame fb1172bcf6 parse.y (symbol_append): Added to factor out `%i[]` and `%I[]`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 01:32:58 +00:00
mame e947f26f42 parse.y: Removes unneeded Ripper/Parser guards
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 16:12:34 +00:00
mame ef1b0f36c7 parse.y (new_command_qcall): Receives a block (optional)
There were four cases that uses new_command_qcall and then
method_add_block.  This change factors out the four rules.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 15:04:57 +00:00
mame 4d073d5377 parse.y: Removes unreachable warnings
tIDENTIFIER is now always a local id (except fname).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 08:54:25 +00:00
mame 6bdd198937 parse.y: Removes unneeded NULL checks
Nowadays, there are less rules whose return value is NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 08:54:24 +00:00
mame 84cf66cc6e parse.y: Remove unneeded NULL check
There are many usages assuming that bodystmt always returns non-null.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 07:54:24 +00:00
mame 8ac73660bc parse.y (last_arg_append, rest_arg_append): factor out the code clones
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 07:39:47 +00:00
mame 7c088b9662 parse.y (new_ary_op_assign): Factor out the typical code clone
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 06:25:43 +00:00
mame c2052b027c parse.y: Fix a bug of `obj[42, &blk] ||= foo bar`
Follow up of r28123 (!)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 06:25:42 +00:00
mame 53c6960ddf parse.y (begin_block): Factor out BEGIN {} process.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 06:25:41 +00:00
mame 52a5f76e8b parse.y: Remove unused code comment blocks
The code fragments were commented out in YARV merge era.
I believe that it will be never needed in near future.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 05:17:18 +00:00
mame 5c0748b627 parse.y (parser_heredoc_dedent): Removed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 14:44:46 +00:00
nobu 07d356ee28 parse.y: yydebug
* parse.y (yydebug): define to disable a global variable and get
  rid of linker error when static linked ext.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 14:28:10 +00:00
mame a9f2596336 parse.y: Remove unused a macro "FIXME"
I don't know what it was, but seems that it has been already fixed since
r12117.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 14:17:25 +00:00
nobu 99e52bcd8e parse.y: ripper no longer uses rb_discard_node
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 14:14:51 +00:00
mame 269856a4a1 parse.y: Remove a code for old yacc
The current parse.y won't compile with yacc since it depends on many
bison's extensions.  Also, configure.ac does not have a check for yacc,
so the macro OLD_YACC is no longer used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 14:09:41 +00:00
mame 15352965c2 parse.y: Remove almost all *_gen macros by passing parser_params explicitly
In parse.y many functions were suffixed "_gen" and had companion macros
to pass struct parser_params implicitly, which made parse.c bigger and
more obscure.

This change expands and removes almost all "*_gen" macros.  This
requires explicit passing of struct parser_params, i.e., we need to
write "foo(p, ..)" instead of "foo(..)".  However, it is just extra
three letters.  I believe that this is easier to understand.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 13:51:44 +00:00
mame 97b9899924 parse.y: Expand global-like accessor macros for struct parser_params
For example, `lex_strterm` is expanded to `p->lex.strterm`.
I believe that this expansion make the code straightforward.
They look not so annoying because "parser" was renamed to "p".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 13:51:41 +00:00
mame 14be478d88 parse.y: Use "p" for the variable of struct parser_params consistently
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 13:51:38 +00:00
mame ca6e1620bd parse.y: Avoid "p" as a variable name
Because I want to use the name "p" for struct parser_params through
parse.c.  This change renames "p" to "ptr", "paren", etc. depending upon
the context.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 13:51:35 +00:00
mame 1b102b719d 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@61797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-12 15:59:26 +00:00
mame 21f03063f6 parse.y (token_info_push, token_info_pop): Refactoring
* remove unused argument len
* factor out initialization code of token_info
* make the condition of "mismatched indentations" warning easy to understand

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-12 14:25:31 +00:00
mame ccf3a0d698 parse.y (token_info_push, token_info_pop): Use code_location
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-12 14:25:28 +00:00
mame c4858f341c parse.y: Remove unneeded dependence on pointer representatin
A simple comparison is enough in this case

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-12 13:22:20 +00:00
mame 35b2038ee4 parse.y: Remove LEXPOP hack
cmdarg_stack became inconsistent state due to look-ahead, and LEXPOP
hack smoothed over the inconsistency.

This commit fixes the inconsisitent state itself, and removes LEXPOP
hack.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 15:54:13 +00:00
kazu fda5e85e2b Fix a typo [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 13:56:05 +00:00
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