summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2024-02-13Warn duplication of `__ENCODING__` on the hashyui-knk
``` $ ruby -e 'h = { __ENCODING__ => 1, __ENCODING__ => 2 }' -e:1: warning: key #<Encoding:UTF-8> is duplicated and overwritten on line 1 ```
2024-02-12Use Node for `warn_duplicate_keys` st_table keysyui-knk
2024-02-10Fix the variable to be checkedyui-knk
It should check the result of `rb_parser_search_nonascii`.
2024-02-09Remove ruby object from string nodesyui-knk
String nodes holds ruby string object on `VALUE nd_lit`. This commit changes it to `struct rb_parser_string *string` to reduce dependency on ruby object. Sometimes these strings are concatenated with other string therefore string concatenate functions are needed.
2024-02-07Fix memory leak when parsing invalid pattern matchingPeter Zhu
If the pattern matching is invalid, then the pvtbl would get leaked. For example: 10.times do 100_000.times do eval(<<~RUBY) case {a: 1} in {"a" => 1} end RUBY rescue SyntaxError end puts `ps -o rss= -p #{$$}` end Before: 28096 44768 61472 78512 94992 111504 128096 144528 161008 177472 After: 14096 14112 14112 14176 14208 14240 14240 14240 14240 14240
2024-02-03Use bool to check ascii only in parse_identyui-knk
No need to use ENC_CODERANGE to record ascii only or not.
2024-01-31Introduced `rb_node_const_decl_val` functionS.H
Introduce `rb_node_const_decl_val` function to allow `rb_ary_join` and `rb_ary_reverse` functions to be removed from Universal Parser.
2024-01-28[Bug #20219] `gettable` returns NULL on errorNobuyoshi Nakada
2024-01-28[Bug #20217] `rescue` block is void only if all children are voidNobuyoshi Nakada
2024-01-28[Bug #20217] `return` with `ensure` is a void value expressionNobuyoshi Nakada
2024-01-28Rename `nd_head` in `RNode_RESBODY` as `nd_next`Nobuyoshi Nakada
2024-01-28Remove unused `nd_resq` from `RNode_ENSURE`Nobuyoshi Nakada
2024-01-27Introduce `NODE_ENCODING`S.H
`__ENCODING__ `was managed by `NODE_LIT` with Encoding object. Introduce `NODE_ENCODING` for 1. `__ENCODING__` is detectable from AST Node. 2. Reduce dependency Ruby object for parse.y
2024-01-27bvar is not NODE but IDyui-knk
Before this commit `ruby -y -e 'tap {|;x, y|}'` failed with SEGV. This change fixes it.
2024-01-25Use `token_seen` and simplify `comment_at_top`Nobuyoshi Nakada
Instead of scanning before the current comment.
2024-01-24Do not use ruby2_keywords for ... argument forwardingJeremy Evans
This allows ... argument forwarding to benefit from Allocationless Anonymous Splat Forwarding, allowing the `f` call below to not allocate an array or a hash. ```ruby a = [1] kw = {b: 2} def c(a, b:) end def f(...) c(...) end f(*a, **kw) ``` This temporarily skips prism locals tests until prism is changed to use * and ** for ..., instead of using ruby2_keywords. Ignore failures in rbs bundled gems tests, since they fail due to this change.
2024-01-23Make lastline and nextline to be rb_parser_stringyui-knk
This commit changes `struct parser_params` lastline and nextline from `VALUE` (String object) to `rb_parser_string_t *` so that dependency on Ruby Object is reduced. `parser_string_buffer_t string_buffer` is added to `struct parser_params` to manage `rb_parser_string_t` pointers of each line. All allocated line strings are freed in `rb_ruby_parser_free`.
2024-01-22Use index for referring to symbols in `args` rule instead of named referencesyui-knk
In `args: args ',' arg_splat`, `args` is not unique name. Currently the associated rule is interpreted as `$$ = rest_arg_append(p, $$, $3, &@$);`. The action works as expected because `$$` is initialized with `$1` before each action is executed. However it's misleading then change to use index.
2024-01-14Constify `rb_global_parser_config`Nobuyoshi Nakada
2024-01-13Stop using Array to manage dummy `end` token locationsyui-knk
Before this commit, Array is used to store token locations which expect `end` token, e.g. `class` and `module`. This commit introduces dedicated struct to manage them so that dependency on Ruby Object is reduced.
2024-01-12Suppress warnings in parser_set_encode functionS-H-GAMELINKS
2024-01-12Remove reference counter from rb_parser_configyui-knk
It's allocated outside of parser then no need to track reference count in rb_parser_config.
2024-01-12Statically allocate parser configyui-knk
2024-01-12`set_yylval_literal` is not usedyui-knk
2024-01-11Reject encodings determined at runtime as source code encodingsNobuyoshi Nakada
The encodings determined at runtime are affected by the runtime environment, such as the OS and locale, while the file contents are not.
2024-01-11Remove duplicate function `nd_st_key_val`Nobuyoshi Nakada
2024-01-11Fixed return values for some node types in nd_st_key functionS-H-GAMELINKS
2024-01-10`st_index_t` is not `VALUE`Nobuyoshi Nakada
2024-01-09Fix memory leak in parser for invalid syntaxPeter Zhu
The strterm is leaked when there is invalid syntax. For example: 10.times do 100_000.times do begin RubyVM::InstructionSequence.compile('private def foo = puts "Hello"') rescue SyntaxError end end puts `ps -o rss= -p #{$$}` end Before: 20384 26256 32592 36720 42016 47888 53248 57456 62928 65936 After: 16720 17488 17616 17616 17616 17616 17616 17616 17616 16032 Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-01-09Convert a series of `else if` lines to a `switch`Nobuyoshi Nakada
2024-01-09Introduce NODE_SYM to manage symbol literalyui-knk
`:sym` was managed by `NODE_LIT` with `Symbol` object. This commit introduces `NODE_SYM` so that 1. Symbol literal is detectable from AST Node 2. Reduce dependency on ruby object
2024-01-09Simplify empty hahs with DSTARNobuyoshi Nakada
2024-01-09Extract repeating NODE references as a local variableNobuyoshi Nakada
2024-01-09Use `strcmp` to compare stringsyui-knk
2024-01-08Do not convert NODE_STR to NODE_LIT when the string is hash keyyui-knk
parse.y converted NODE_STR when the string is hash key like ``` h1 = {"str1" => 1} m1("str2" => 2) m2({"str3" => 3}) ``` This commit stop the conversion. `static_literal_node_p` needs to know the node is for hash key or not for the optimization.
2024-01-08Change numeric node value functions argument to `NODE *`yui-knk
Change the argument to align with other node value functions like `rb_node_line_lineno_val`.
2024-01-08Fix numeric node print by `-y` optionyui-knk
These nodes are not NOTE_LIT, so need to treat separately.
2024-01-08Suppress unused-but-set-variable warning in ripperNobuyoshi Nakada
`set_yylval_node` in ripper does not use the argument at all.
2024-01-08Adjust styles and indents [ci skip]Nobuyoshi Nakada
2024-01-07Remove unneeded rb_parser_config_struct struct properties for Universal ParserS-H-GAMELINKS
2024-01-07Do not remove hash duplicated keys in parse.yyui-knk
When hash keys are duplicated, e.g. `h = {k: 1, l: 2, k: 3}`, parser changes node structure for correct compilation. This generates tricky AST. This commit removes AST manipulation from parser to keep AST structure simple.
2024-01-07Check hash key duplication for `__LINE__` and `__FILE__`yui-knk
2024-01-07Introduce Numeric Node'sS-H-GAMELINKS
2024-01-02Introduce NODE_FILEyui-knk
`__FILE__` was managed by `NODE_STR` with `String` object. This commit introduces `NODE_FILE` and `struct rb_parser_string` so that 1. `__FILE__` is detectable from AST Node 2. Reduce dependency ruby object
2024-01-02Warn "literal in condition" for `__LINE__`yui-knk
Print warning for a code like ```ruby if __LINE__ end # => warning: literal in condition ```
2023-12-29Introduce NODE_LINEyui-knk
`__LINE__` was managed by `NODE_LIT` with `Integer` object. This commit introduces `NODE_LINE` so that 1. `__LINE__` is detectable from AST Node 2. Reduce dependency ruby object
2023-12-27[Bug #20094] Distinguish `begin` and parenthesesNobuyoshi Nakada
2023-12-27Initialize rb_node_block_t::nd_end at creationNobuyoshi Nakada
2023-12-27Use NODE_ERROR as placeholder of error instead of NODE_BEGINNobuyoshi Nakada
2023-12-27Include new node types into %printeryui-knk