aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
Commit message (Collapse)AuthorAgeFilesLines
* [Bug #18962] Do not read again once reached EOFNobuyoshi Nakada2022-08-121-0/+1
| | | | | | | `Ripper::Lexer#parse` re-parses the source code with syntax errors when `raise_errors: false`. Co-Authored-By: tompng <tomoyapenguin@gmail.com>
* Fix some UBSAN false positives (#6115)Kevin Backhouse2022-07-121-3/+3
| | | | * Fix some UBSAN false positives. * ruby tool/update-deps --fix
* [Bug #18890] newline should be insignificant after pattern labelNobuyoshi Nakada2022-07-061-1/+1
|
* [Bug #18877] Let `lex_ctxt` not to eat escaped whitespaceNobuyoshi Nakada2022-06-301-5/+1
|
* [Bug #18884] `class` cannot be just followed by modifiersNobuyoshi Nakada2022-06-291-1/+1
|
* Suppress notes for old gccNobuyoshi Nakada2022-06-231-0/+10
|
* Using is_ascii_string to check encodingS-H-GAMELINKS2022-06-171-4/+4
|
* Respect the encoding of the source [Bug #18827]Nobuyoshi Nakada2022-06-171-10/+16
| | | | | Do not override the input string encoding at the time of preparation, the source encoding is not determined from the input yet.
* Remove unnecessary conditionNobuyoshi Nakada2022-06-151-1/+1
| | | | `no_blockarg` is called for non-null `node` only.
* ripper: Check if anonymous parameters defined [Bug #18828]Nobuyoshi Nakada2022-06-141-13/+11
|
* Ignore invalid escapes in regexp commentsJeremy Evans2022-06-061-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Private local variables should shadow outer variables [Bug #18629]Nobuyoshi Nakada2022-04-211-1/+2
|
* Fix the wrong index of the previous component [Bug #18739]Nobuyoshi Nakada2022-04-181-1/+1
|
* Fix using anonymous block in method accepting explicit keywordsJeremy Evans2022-04-051-0/+1
| | | | | | | Record block ID before vtable_pop, so the incorrect one doesn't override it. Fixes [Bug #18673]
* Find pattern is no longer experimental [Feature #18585]Kazuki Tsujimoto2022-02-191-3/+0
|
* Fix location of NODE_LIT in p_kwKazuki Tsujimoto2022-02-191-1/+1
|
* Reuse operation rule for operation2S-H-GAMELINKS2022-02-121-3/+1
|
* Reuse p_kwnorest rule for f_no_kwargS-H-GAMELINKS2022-02-121-1/+1
|
* Reduce p_args rules with p_restVladimir Dementyev2022-01-111-12/+4
|
* Use chomp: option when chomp modeNobuyoshi Nakada2022-01-071-3/+3
| | | | | Get rid of depending on using $/ internally in String#chomp!, and chomp the separator at once.
* Explicitly pass $/ when loop modeNobuyoshi Nakada2022-01-071-1/+3
| | | | Get rid of depending on using $/ internally in ARGF.gets.
* Add support for anonymous rest and keyword rest argument forwardingJeremy Evans2021-12-301-4/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* Add `rb_parser_set_pos` functionS.H2021-12-161-15/+19
| | | | Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Marivaldo Cavalheiro <marivaldo@gmail.com>
* Fix arg_forward without parentheses [Bug #18267]Nobuyoshi Nakada2021-12-151-9/+31
|
* Revert "Rename `in_kwarg` as `in_argdef` as unrelated to keywords"Nobuyoshi Nakada2021-12-151-12/+12
| | | | | This reverts commit b7f7117bdc78a4a342a57dad1a340b158492ccf3, to separate `in_argdef` from `in_kwarg`.
* Turn SET_LEX_STATE macro into an inline function callNobuyoshi Nakada2021-12-151-4/+10
|
* Fix indent [ci skip]Nobuyoshi Nakada2021-12-151-1/+1
|
* Remove `NODE_DASGN_CURR` [Feature #18406]Nobuyoshi Nakada2021-12-131-9/+3
| | | | | | | 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.
* Add `nd_type_p` macroS.H2021-12-041-50/+50
|
* Assign temporary ID to anonymous ID [Bug #18250]Nobuyoshi Nakada2021-11-231-4/+1
| | | | | | | | 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.
* Refactor hacky ID tables to struct rb_ast_id_table_tYusuke Endoh2021-11-211-16/+13
| | | | | | | | | 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.
* Anonymous block forwarding allows a method to forward a passedJeremy Evans2021-11-181-0/+21
| | | | | | | | | | 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
* parse.y: Fix memory leak at parse errorYusuke Endoh2021-11-121-0/+6
| | | | Local variable tables might leak at the parse error.
* [Feature #18290] Remove all usages of rb_gc_force_recyclePeter Zhu2021-11-081-2/+0
| | | | | This commit removes usages of rb_gc_force_recycle since it is a burden to maintain and makes changes to the GC difficult.
* Argument forwarding definition without parentheses [Bug #18267]Nobuyoshi Nakada2021-10-311-29/+20
|
* Rename `in_kwarg` as `in_argdef` as unrelated to keywordsNobuyoshi Nakada2021-10-311-12/+12
|
* Reduce parser stack usage at pattern matchingNobuyoshi Nakada2021-10-311-12/+12
|
* Make new object for negated float as `Float` is always frozen nowNobuyoshi Nakada2021-10-261-1/+1
|
* ast.c: Use kept script_lines data instead of re-opening the source file (#5019)Yusuke Endoh2021-10-261-0/+1
| | | ast.c: Use kept script_lines data instead of re-open the source file
* `RubyVM.keep_script_lines`Koichi Sasada2021-10-211-1/+2
| | | | | | | | | | | | | | `RubyVM.keep_script_lines` enables to keep script lines for each ISeq and AST. This feature is for debugger/REPL support. ```ruby RubyVM.keep_script_lines = true RubyVM::keep_script_lines = true eval("def foo = nil\ndef bar = nil") pp RubyVM::InstructionSequence.of(method(:foo)).script_lines ```
* Fix evaluation order of hash values for duplicate keysJeremy Evans2021-10-181-7/+13
| | | | | | Fixes [Bug #17719] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Ivo Anjo <ivo@ivoanjo.me>
* Remove duplicate value checks on `mrhs` which always has the valueNobuyoshi Nakada2021-10-081-2/+3
|
* Split parser_yyerror0 from parser_yyerrorNobuyoshi Nakada2021-10-051-8/+26
| | | | | The former uses the current location, while the latter takes a non-null location.
* Show the last line at unexpected end-of-input errorNobuyoshi Nakada2021-10-051-3/+1
|
* Replace inaccurate error messagesNobuyoshi Nakada2021-10-051-0/+3
| | | | | | When Bison reports "memory exhausted", it means the parser stack depth reached the limit `YYMAXDEPTH` which is defaulted to 10_000, but not memory allocation failed.
* The same warning for static symbol literalNobuyoshi Nakada2021-10-041-0/+4
|
* Fix the warning message for dynamic symbol literal in conditionNobuyoshi Nakada2021-10-041-1/+1
|
* Use `%printer` directive for Bison 3.8Nobuyoshi Nakada2021-09-141-45/+29
|
* Hash values should be omitted in Ripper resultsShugo Maeda2021-09-111-1/+1
|
* Allow value omission in Hash literalsShugo Maeda2021-09-111-0/+9
| | | | `{x:, y:}` is a syntax sugar of `{x: x, y: y}`.