summaryrefslogtreecommitdiff
path: root/parse.y
Commit message (Collapse)AuthorAgeFilesLines
* 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}`.
* Replace RBOOL macroS-H-GAMELINKS2021-09-051-4/+4
|
* Moved exported symbols in internal/util.h to ruby/util.hNobuyoshi Nakada2021-08-241-1/+0
| | | | [Feature #18051]
* ast.c: Rename "save_script_lines" to "keep_script_lines"Yusuke Endoh2021-08-201-4/+4
| | | | | | | ... as per ko1's preference. He is preparing to extend this feature to ISeq for his new debugger. He prefers "keep" to "save" for this wording. This API is internal and not included in any released version, so I change it in advance.
* Allow omission of parentheses in one line pattern matching [Feature #16182]Kazuki Tsujimoto2021-08-191-2/+2
|
* Extract the wrapped value when yydebug [Bug #18075]Nobuyoshi Nakada2021-08-151-1/+1
|
* Fix interpolated heredoceileencodes2021-07-211-1/+4
| | | | | | | | | | | | | | This fixes https://bugs.ruby-lang.org/issues/18038. The provided reproduction showed that this happens in heredocs with double interpolation. In this case `DSTR` was getting returned but needs to be convered to a `EVSTR` which is what is returned by the function. There may be an additional bug here that we weren't able to produce. It seems odd that `STR` returns `DSTR` while everything else should return `EVSTR` since the function is `new_evstr`. [Bug #18038][ruby-core:104597] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* One-line pattern matching is no longer experimentalKazuki Tsujimoto2021-07-171-14/+0
| | | | https://github.com/ruby/dev-meeting-log/blob/master/DevelopersMeeting20210715Japan.md#feature-17724-make-the-pin-operator-support-instanceclassglobal-variables-jeremyevans0
* Add pattern matching pin support for instance/class/global variablesJeremy Evans2021-07-151-1/+13
| | | | | | | | | | | Pin matching for local variables and constants is already supported, and it is fairly simple to add support for these variable types. Note that pin matching for method calls is still not supported without wrapping in parentheses (pin expressions). I think that's for the best as method calls are far more complex (arguments/blocks). Implements [Feature #17724]
* node.h: Reduce struct size to fit with Ruby object size (five VALUEs)Yusuke Endoh2021-06-181-1/+1
| | | | | | | | by merging `rb_ast_body_t#line_count` and `#script_lines`. Fortunately `line_count == RARRAY_LEN(script_lines)` was always satisfied. When script_lines is saved, it has an array of lines, and when not saved, it has a Fixnum that represents the old line_count.
* ast.rb: RubyVM::AST.parse and .of accepts `save_script_lines: true`Yusuke Endoh2021-06-181-0/+17
| | | | | | | This option makes the parser keep the original source as an array of the original code lines. This feature exploits the mechanism of `SCRIPT_LINES__` but records only the specified code that is passed to RubyVM::AST.of or .parse, instead of recording all parsed program texts.
* Adjust styles [ci skip]Nobuyoshi Nakada2021-06-171-1/+1
| | | | | | | | | * --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
* parse.y: Fix the location of a target constant of OP_CDECLYusuke Endoh2021-06-141-1/+2
| | | | | | | | ``` p RubyVM::AbstractSyntaxTree.parse("::Foo += 1").children #=> before: [[], nil, (OP_CDECL@1:0-1:10 (COLON3@1:0-1:10 :Foo) :+ (LIT@1:9-1:10 1))] #=> after: [[], nil, (OP_CDECL@1:0-1:10 (COLON3@1:0-1:5 :Foo) :+ (LIT@1:9-1:10 1))] ```
* Warn more duplicate literal hash keysNobuyoshi Nakada2021-06-031-1/+0
| | | | | Following non-special_const literals: * T_REGEXP
* Warn more duplicate literal hash keysNobuyoshi Nakada2021-06-031-1/+33
| | | | | | | | Following non-special_const literals: * T_BIGNUM * T_FLOAT (non-flonum) * T_RATIONAL * T_COMPLEX
* ripper: wrap endless method in bodystmt [Bug #17869]Nobuyoshi Nakada2021-05-211-4/+12
|
* Also `\U` after control/meta is invalid [Bug #17861]Nobuyoshi Nakada2021-05-131-2/+10
| | | | | As well as `\u`, `\U` should be invalid there too. And highlight including `u`/`U` not only the backslash before it.
* Fix handling of control/meta escapes in literal regexpsJeremy Evans2021-05-121-33/+17
| | | | | | | | | | | | | | | | | | | Ruby uses a recursive algorithm for handling control/meta escapes in strings (read_escape). However, the equivalent code for regexps (tokadd_escape) in did not use a recursive algorithm. Due to this, Handling of control/meta escapes in regexp did not have the same behavior as in strings, leading to behavior such as the following returning nil: ```ruby /\c\xFF/ =~ "\c\xFF" ``` Switch the code for handling \c, \C and \M in literal regexps to use the same code as for strings (read_escape), to keep behavior consistent between the two. Fixes [Bug #14367]
* parse.y: Allow "command" syntax in endless method definitionYusuke Endoh2021-05-131-0/+46
| | | | | | | | | This change allows `def hello = puts "Hello"` without parentheses. Note that `private def hello = puts "Hello"` does not parse for technical reason. [Feature #17398]
* Make imemo_ast WB-protected againYusuke Endoh2021-04-271-1/+5
| | | | | | by firing the write barrier of imemo_ast after nd_lit is modified. This will fix the issue of https://github.com/ruby/ruby/pull/4416 more gracefully.
* Ignore useless separators preceding a file encoding commentNobuyoshi Nakada2021-03-231-0/+1
|
* Pattern matching pin operator against expression [Feature #17411]Kazuki Tsujimoto2021-03-211-4/+14
| | | | This commit is based on the patch by @nobu.
* Add a missing semicolon.Takashi Tamura2021-02-151-1/+1
|
* Removed YYUSE [Bug #17582]Nobuyoshi Nakada2021-01-261-1/+0
| | | | | | | Although it was used just to suppress an "unsed argument" warning in the same manner as other bison-provided functions, it has been dropped since Bision 3.7.5. And we always suppress that warnings.
* Return new NODE_LITNobuyoshi Nakada2021-01-141-5/+2
| | | | | As NODE_ZLIST/NODE_LIST are not markable, cannot be reused as NODE_LIT.
* Ensure symbol list node is either NODE_STR or NODE_DSTRNobuyoshi Nakada2021-01-141-3/+8
|
* Capture to reserved name variables if already defined [Bug #17533]Nobuyoshi Nakada2021-01-131-2/+3
|
* parse.y: handle "duplicated argument name" appropriately on ripper.yNobuhiro IMAI2021-01-091-2/+4
| | | | refs: 733ed1e184
* Fixed error message when % at EOFNobuyoshi Nakada2021-01-041-1/+3
|
* Make args info for RubyVM::AST to available on endless method without parensMasataka Pocke Kuwabara2021-01-011-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem === Arguments information is missing for endless method without parens. For example: ```ruby # ok pp RubyVM::AbstractSyntaxTree.parse(<<~RUBY).children[2] def x() = 42 RUBY # => (DEFN@1:0-1:12 # mid: :x # body: # (SCOPE@1:0-1:12 # tbl: [] # args: # (ARGS@1:5-1:6 # pre_num: 0 # pre_init: nil # opt: nil # first_post: nil # post_num: 0 # post_init: nil # rest: nil # kw: nil # kwrest: nil # block: nil) # body: (LIT@1:10-1:12 42))) # ok pp RubyVM::AbstractSyntaxTree.parse(<<~RUBY).children[2] def x() 42 end RUBY # => (DEFN@1:0-1:14 # mid: :x # body: # (SCOPE@1:0-1:14 # tbl: [] # args: # (ARGS@1:5-1:6 # pre_num: 0 # pre_init: nil # opt: nil # first_post: nil # post_num: 0 # post_init: nil # rest: nil # kw: nil # kwrest: nil # block: nil) # body: (LIT@1:8-1:10 42))) # It has a problem, the `args` is nil pp RubyVM::AbstractSyntaxTree.parse(<<~RUBY).children[2] def x = 42 RUBY # => (DEFN@1:0-1:10 # mid: :x # body: (SCOPE@1:0-1:10 tbl: [] args: nil body: (LIT@1:8-1:10 42))) ``` It causes an error if a program expects `args` node exists. For example: https://github.com/ruby/rbs/issues/551 Solution ==== Call `new_args` on this case.
* shareable_constant_value: experimental_copyKoichi Sasada2020-12-241-7/+18
| | | | | | | "experimental_everything" makes the assigned value, it means the assignment change the state of assigned value. "experimental_copy" tries to make a deep copy and make copyied object sharable.
* Reset paren_nest at tAREF and tASET [Bug #17431]Nobuyoshi Nakada2020-12-241-0/+1
|
* Ensure non-literal expressions shareable if `leteral`Nobuyoshi Nakada2020-12-231-1/+1
|
* `begin ... end` is not a literalNobuyoshi Nakada2020-12-231-1/+1
|
* Changed shareable literal semantics [Feature #17397]Nobuyoshi Nakada2020-12-231-34/+123
| | | | | | When `literal`, check if the literal about to be assigned to a constant is ractor-shareable, otherwise raise `Ractor::Error` at runtime instead of `SyntaxError`.
* ripper: fix bad label parameter handling [Bug #17425]Nobuyoshi Nakada2020-12-231-5/+12
|
* Reduced ID cachesNobuyoshi Nakada2020-12-201-3/+6
| | | | NEW_GASGN and NEW_GVAR evaluate `id` argument twice.
* Use category: :experimental in warnings that are related to experimental ↵Jeremy Evans2020-12-181-2/+4
| | | | | | | | | features This adds rb_category_compile_warn in order to emit compiler warnings with categories. Note that Ripper currently ignores the category for these warnings, but by default it ignores the warnings completely, so this shouldn't matter.
* Fixed not to make non-literal expression shareable [Feature #17273]Nobuyoshi Nakada2020-12-191-8/+10
| | | | | Non-literal expression which is not a part of a literal expression is not a subject of `shareable_literal_value: literal`.
* Drop token info also for endless singleton method definitionNobuyoshi Nakada2020-12-181-8/+7
|
* Ripper: Pass callback result to alias_error as well as other errorsNobuyoshi Nakada2020-12-161-2/+1
| | | | [Bug #17345]
* Ripper: Fixed erred token on wrong alias [Bug #17345]Nobuyoshi Nakada2020-12-161-1/+2
|
* Ripper: Refined error callbacks [Bug #17345]Nobuyoshi Nakada2020-12-151-35/+52
|
* Support shareable_constant_value: literalNobuyoshi Nakada2020-12-141-6/+124
|
* Make shareable_constant_value tri-stateNobuyoshi Nakada2020-12-141-18/+72
|
* shareable_constant_value: is effective only in comment-only lineNobuyoshi Nakada2020-12-141-0/+7
|
* Save and pass lex_context wholelyNobuyoshi Nakada2020-12-141-37/+40
|
* Determine shareable-ness after assignment operatorNobuyoshi Nakada2020-12-141-93/+103
|