summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2019-08-28merge revision(s) 4e038a7e64a9d52eed59b8f05647d4e58d265ec3: [Backport #5400]nagachika
Revert "parse.y: Deprecate flip-flops" This reverts commit bae638ad5b782c44c80efe33834cb9039279af46. [Feature #5400] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-08-07merge revision(s) ↵nagachika
5931857281ce45c1c277aa86d1588119ab00a955,76e2370f132f83c16c9de39a0a9356579f364527: [Backport #16041] Fix dangling path name from fstring * parse.y (yycompile): make sure in advance that the `__FILE__` object shares a fstring, to get rid of dangling path name. Fixed up 53e9908d8afc7f03109b0aafd1698ab35f512b05. [Bug #16041] * vm_eval.c (eval_make_iseq): ditto. Fix dangling path name from fstring * load.c (rb_require_internal): make sure in advance that the path to be loaded shares a fstring, to get rid of dangling path name. Fixed up 5931857281ce45c1c277aa86d1588119ab00a955. [Bug #16041] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-08-07merge revision(s) 53e9908d8afc7f03109b0aafd1698ab35f512b05: [Backport #15916]nagachika
Fix memory leak * string.c (str_replace_shared_without_enc): free previous buffer before replaced. * parse.y (gettable): make sure in advance that the `__FILE__` object shares a fstring, to get rid of replacement with the fstring later. TODO: this hack may be needed in other places. [Bug #15916] Co-Authored-By: luke-gru (Luke Gruber) <luke.gru@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-08-01merge revision(s) ↵nagachika
6375c68f8851e1e0fee8a95afba91c4555097127,c05eaa93258ddc01e685b6cc3a0da82998a2af48: [Backport #15839] 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 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-07-31merge revision(s) ↵nagachika
d0ba4abf1a00339ebbb5d405db3240a8bdb7b68b,54eac83b2ad77ddea84fa6d66c09e0bb014cf61e: [Backport #15786] Add RB_ID_SERIAL_MAX 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-28merge revision(s) 67270: [Backport #15670]naruse
dsym should be treated as string [ruby-core:91852] [Bug #15670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-20parse.y: ignore constant name capturesnobu
* 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-11-25Fix locations of NODE_UNDEF in undef with multiple argsyui-knk
* 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-25parser: improve error messagesnobu
[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-10Constified ruby_sourcefilenobu
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-10Parse the source in SCRIPT_LINES__ as arraynobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09Get rid of setting SCRIPT_LINES__ by AST.parsenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-05Implement `RubyVM::AST.of` [Feature #14836]yui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-31parse.y: last node of NODE_ARRAYnobu
* 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-30parse.y: last location from bisonnobu
* 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-26parse.y: remove "shadowing outer local variable" warningmame
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-26Revert "parse.y: remove "shadowing outer local variable" warning"mame
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-26parse.y: remove "shadowing outer local variable" warningmame
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-20parse.y: Fix the compile erroryui-knk
* 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-20Fix locations of NODE_SCOPE in lambda.yui-knk
* 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-20Fix locations of NODE_LAMBDA.yui-knk
* 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-20parse.y (struct ripper_args): Remove not used struct definitionyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-20parse.y: fix block passing with empty kwargsnobu
* 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-08-22parse.y (arg_append): support NODE_ARGSCAT casemame
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-22parse.y: remove coverage-related code fragmentsmame
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-07-16parse.y (heredoc_identifier): Update comment for term_lenyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-16parse.y: Add comment for `rb_strterm_heredoc_struct.sourceline`yui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-15parse.y: Deprecate flip-flopsmame
Ref #5400 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13Revert "range.c: prohibit `(1..nil)`"mame
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-13range.c: prohibit `(1..nil)`mame
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-10parse.y: Fix locations of none and mid-rule actionsyui-knk
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-10parse.y: Fix locations of NODE_RESCUEyui-knk
* 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-05-22parse.y: use ruby_sized_xfree and SIZED_REALLOC_Nnormal
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-21explicit cast to void* required for %pshyouhei
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-18parse.y: relax literal in condition warningsnobu
* 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-17rb_parser_printf declarationnobu
* 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-11fix potential memory leaksnobu
* 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-10parse.y: Fix locations of NODE_NIL in endless ranges.yui-knk
* 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-09fix potential memory leaksnobu
* 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-09Rename imemo_alloc with imemo_tmpbufmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-09gc.c (rb_imemo_alloc_new): split for each purposemame
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-09gc.c (rb_imemo_alloc_new): improve the API interfacemame
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-04-19Introduce endless range [Feature#12912]mame
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-17parse.y: fix cmdarg in command_argsnobu
* 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-16parse.y: `else` indentnobu
* 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-12parse.y: `when` indentnobu
* 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-09parse.y: [DOC] Ripper.dedent_string is internalnobu
* 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-09parse.y: extra error message after no digitsnobu
* 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-08parse.y: fix docs for Ripper.dedent_stringstomar
* 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-03-29Use only CMDARG/COND _PUSH/POP for cmdarg/cond management.nobu
From: Ilya Bylich <ibylich@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e