summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2022-11-09Now bison 3.0 or later is requiredNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6698
2022-11-08Set default %printer for NODE ntermsyui-knk
Before: ``` Reducing stack by rule 639 (line 5062): $1 = token "integer literal" (1.0-1.1: 1) -> $$ = nterm simple_numeric (1.0-1.1: ) ``` After: ``` Reducing stack by rule 641 (line 5078): $1 = token "integer literal" (1.0-1.1: 1) -> $$ = nterm simple_numeric (1.0-1.1: NODE_LIT) ``` `"<*>"` is supported by Bison 2.3b (2008-05-27) or later. https://git.savannah.gnu.org/cgit/bison.git/commit/?id=12e3584054c16ab255672c07af0ffc7bb220e8bc Therefore developers need to install Bison 2.3b+ to build ruby from source codes if their Bison is older. Minimum version requirement for Bison is changed to 3.0. See: https://bugs.ruby-lang.org/issues/19068 [Feature #19068] Notes: Merged: https://github.com/ruby/ruby/pull/6579
2022-10-09Do not set `$!` to `SyntaxError` when error tolerantNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6517
2022-10-08Fix typosyui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/6515
2022-10-08Fix SEGV of dump parsetreeyui-knk
Assign internal_id to semantic value so that dump parsetree option can render the tree for these codes without SEGV. * `def m(&); end` * `def m(*); end` * `def m(**); end` Notes: Merged: https://github.com/ruby/ruby/pull/6514
2022-10-08"expr_value" can be erroryui-knk
So that "IF" node is kept in the case below ``` def m if end ``` [Feature #19013] Notes: Merged: https://github.com/ruby/ruby/pull/6512
2022-10-08Move `error` from top_stmts and top_stmt to stmtyui-knk
By this change, syntax error is recovered smaller units. In the case below, "DEFN :bar" is same level with "CLASS :Foo" now. ``` module Z class Foo foo. end def bar end end ``` [Feature #19013] Notes: Merged: https://github.com/ruby/ruby/pull/6512
2022-10-08Treat "end" as reserved word with consideration of indentyui-knk
"end" after "." or "::" is treated as local variable or method, see `EXPR_DOT_bit` for detail. However this "changes" where `bar` method is defined. In the example below it is not module Z but class Foo. ``` module Z class Foo foo. end def bar end end ``` [Feature #19013] Notes: Merged: https://github.com/ruby/ruby/pull/6512
2022-10-08Generates "end" tokens if parser hits end of inputyui-knk
but "end" tokens are needed for correct language. [Feature #19013] Notes: Merged: https://github.com/ruby/ruby/pull/6512
2022-10-08Add error_tolerant option to RubyVM::ASTyui-knk
If this option is enabled, SyntaxError is not raised and Node is returned even if passed script is broken. [Feature #19013] Notes: Merged: https://github.com/ruby/ruby/pull/6512
2022-09-26Suppress a warning on clangShugo Maeda
The following warning appears without this fix: ``` parse.y:78:1: warning: unknown warning group '-Wpsabi', ignored [-Wunknown-warning-option] RBIMPL_WARNING_IGNORED(-Wpsabi) ^ ./include/ruby/internal/warning_push.h:103:39: note: expanded from macro 'RBIMPL_WARNING_IGNORED' ^ ./include/ruby/internal/warning_push.h:99:39: note: expanded from macro 'RBIMPL_WARNING_PRAGMA2' ^ ./include/ruby/internal/warning_push.h:98:39: note: expanded from macro 'RBIMPL_WARNING_PRAGMA1' ^ ./include/ruby/internal/warning_push.h:97:39: note: expanded from macro 'RBIMPL_WARNING_PRAGMA0' ^ <scratch space>:49:27: note: expanded from here clang diagnostic ignored "-Wpsabi" ^ 1 warning generated. ```
2022-09-14Reuse `opt_arg_append` functionS.H
Notes: Merged: https://github.com/ruby/ruby/pull/6373 Merged-By: nobu <nobu@ruby-lang.org>
2022-09-09Fix unexpected "duplicated key name" error in paren-less one line pattern ↵Kazuki Tsujimoto
matching [Bug #18990]
2022-08-28[Bug #18963] Separate string contents by here document terminatorNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6292
2022-08-22Reuse `nonlocal_var` patternsS.H
Notes: Merged: https://github.com/ruby/ruby/pull/6263 Merged-By: nobu <nobu@ruby-lang.org>
2022-08-19Reuse opt_nl ruleS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5977
2022-08-19Repalce to NIL_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6073
2022-08-12[Bug #18962] Do not read again once reached EOFNobuyoshi Nakada
`Ripper::Lexer#parse` re-parses the source code with syntax errors when `raise_errors: false`. Co-Authored-By: tompng <tomoyapenguin@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/6233
2022-07-12Fix some UBSAN false positives (#6115)Kevin Backhouse
* Fix some UBSAN false positives. * ruby tool/update-deps --fix Notes: Merged-By: jhawthorn <john@hawthorn.email>
2022-07-06[Bug #18890] newline should be insignificant after pattern labelNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6087
2022-06-30[Bug #18877] Let `lex_ctxt` not to eat escaped whitespaceNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6065
2022-06-29[Bug #18884] `class` cannot be just followed by modifiersNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6064 Merged-By: nobu <nobu@ruby-lang.org>
2022-06-23Suppress notes for old gccNobuyoshi Nakada
2022-06-17Using is_ascii_string to check encodingS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5867
2022-06-17Respect the encoding of the source [Bug #18827]Nobuyoshi Nakada
Do not override the input string encoding at the time of preparation, the source encoding is not determined from the input yet. Notes: Merged: https://github.com/ruby/ruby/pull/6015
2022-06-15Remove unnecessary conditionNobuyoshi Nakada
`no_blockarg` is called for non-null `node` only.
2022-06-14ripper: Check if anonymous parameters defined [Bug #18828]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6016
2022-06-06Ignore invalid escapes in regexp commentsJeremy Evans
Invalid escapes are handled at multiple levels. The first level is in parse.y, so skip invalid unicode escape checks for regexps in parse.y. Make rb_reg_preprocess and unescape_nonascii accept the regexp options. In unescape_nonascii, if the regexp is an extended regexp, when "#" is encountered, ignore all characters until the end of line or end of regexp. Unfortunately, in extended regexps, you can use "#" as a non-comment character inside a character class, so also parse "[" and "]" specially for extended regexps, and only skip comments if "#" is not inside a character class. Handle nested character classes as well. This issue doesn't just affect extended regexps, it also affects "(#?" comments inside all regexps. So for those comments, scan until trailing ")" and ignore content inside. I'm not sure if there are other corner cases not handled. A better fix would be to redesign the regexp parser so that it unescaped during parsing instead of before parsing, so you already know the current parsing state. Fixes [Bug #18294] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/5721 Merged-By: jeremyevans <code@jeremyevans.net>
2022-04-21Private local variables should shadow outer variables [Bug #18629]Nobuyoshi Nakada
2022-04-18Fix the wrong index of the previous component [Bug #18739]Nobuyoshi Nakada
2022-04-05Fix using anonymous block in method accepting explicit keywordsJeremy Evans
Record block ID before vtable_pop, so the incorrect one doesn't override it. Fixes [Bug #18673] Notes: Merged: https://github.com/ruby/ruby/pull/5761
2022-02-19Find pattern is no longer experimental [Feature #18585]Kazuki Tsujimoto
2022-02-19Fix location of NODE_LIT in p_kwKazuki Tsujimoto
2022-02-12Reuse operation rule for operation2S-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5545
2022-02-12Reuse p_kwnorest rule for f_no_kwargS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5540
2022-01-11Reduce p_args rules with p_restVladimir Dementyev
2022-01-07Use chomp: option when chomp modeNobuyoshi Nakada
Get rid of depending on using $/ internally in String#chomp!, and chomp the separator at once. Notes: Merged: https://github.com/ruby/ruby/pull/5403
2022-01-07Explicitly pass $/ when loop modeNobuyoshi Nakada
Get rid of depending on using $/ internally in ARGF.gets. Notes: Merged: https://github.com/ruby/ruby/pull/5403
2021-12-30Add support for anonymous rest and keyword rest argument forwardingJeremy Evans
This allows for the following syntax: ```ruby def foo(*) bar(*) end def baz(**) quux(**) end ``` This is a natural addition after the introduction of anonymous block forwarding. Anonymous rest and keyword rest arguments were already supported in method parameters, this just allows them to be used as arguments to other methods. The same advantages of anonymous block forwarding apply to rest and keyword rest argument forwarding. This has some minor changes to #parameters output. Now, instead of `[:rest], [:keyrest]`, you get `[:rest, :*], [:keyrest, :**]`. These were already used for `...` forwarding, so I think it makes it more consistent to include them in other cases. If we want to use `[:rest], [:keyrest]` in both cases, that is also possible. I don't think the previous behavior of `[:rest], [:keyrest]` in the non-... case and `[:rest, :*], [:keyrest, :**]` in the ... case makes sense, but if we did want that behavior, we'll have to make more substantial changes, such as using a different ID in the ... forwarding case. Implements [Feature #18351] Notes: Merged: https://github.com/ruby/ruby/pull/5148
2021-12-16Add `rb_parser_set_pos` functionS.H
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Marivaldo Cavalheiro <marivaldo@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/5089 Merged-By: nobu <nobu@ruby-lang.org>
2021-12-15Fix arg_forward without parentheses [Bug #18267]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5269
2021-12-15Revert "Rename `in_kwarg` as `in_argdef` as unrelated to keywords"Nobuyoshi Nakada
This reverts commit b7f7117bdc78a4a342a57dad1a340b158492ccf3, to separate `in_argdef` from `in_kwarg`. Notes: Merged: https://github.com/ruby/ruby/pull/5269
2021-12-15Turn SET_LEX_STATE macro into an inline function callNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5266
2021-12-15Fix indent [ci skip]Nobuyoshi Nakada
2021-12-13Remove `NODE_DASGN_CURR` [Feature #18406]Nobuyoshi Nakada
This `NODE` type was used in pre-YARV implementation, to improve the performance of assignment to dynamic local variable defined at the innermost scope. It has no longer any actual difference with `NODE_DASGN`, except for the node dump. Notes: Merged: https://github.com/ruby/ruby/pull/5251
2021-12-04Add `nd_type_p` macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/5091 Merged-By: nobu <nobu@ruby-lang.org>
2021-11-23Assign temporary ID to anonymous ID [Bug #18250]Nobuyoshi Nakada
Dumped iseq binary can not have unnamed symbols/IDs, and ID 0 is stored instead. As `struct rb_id_table` disallows ID 0, also for the distinction, re-assign a new temporary ID based on the local variable table index when loading from the binary, as well as the parser. Notes: Merged: https://github.com/ruby/ruby/pull/5157
2021-11-21Refactor hacky ID tables to struct rb_ast_id_table_tYusuke Endoh
The implementation of a local variable tables was represented as `ID*`, but it was very hacky: the first element is not an ID but the size of the table, and, the last element is (sometimes) a link to the next local table only when the id tables are a linked list. This change converts the hacky implementation to a normal struct. Notes: Merged: https://github.com/ruby/ruby/pull/5136
2021-11-18Anonymous block forwarding allows a method to forward a passedJeremy Evans
block to another method without having to provide a name for the block parameter. Implements [Feature #11256] Co-authored-by: Yusuke Endoh mame@ruby-lang.org Co-authored-by: Nobuyoshi Nakada nobu@ruby-lang.org Notes: Merged: https://github.com/ruby/ruby/pull/5051
2021-11-12parse.y: Fix memory leak at parse errorYusuke Endoh
Local variable tables might leak at the parse error. Notes: Merged: https://github.com/ruby/ruby/pull/5111