2684 Commits

Author SHA1 Message Date
ydah
b68172caad Rename f_optarg to f_opt_arg for consistency in parser rules 2025-04-15 00:39:12 +09:00
ydah
1c8154e5c9 Use call_op2 instead of call_op and tCOLON2 2025-04-14 23:13:57 +09:00
ydah
e255964542 Use user defined parameterizing rules range_expr 2025-04-14 03:21:17 +09:00
ydah
088fd968ed Add a new non-terminal symbol ternary to tidy up 2025-04-14 03:01:01 +09:00
ydah
e996699820 Refactor assignment rules to remove unnecessary lhs parameter 2025-04-14 01:15:20 +09:00
ydah
a35a101b4c Change the indent after lhs in generation rules from spaces to tabs
Change the indent to match the characters used in other generation rules. This makes it easier to find lhs.
2025-04-13 01:23:39 +09:00
tomoya ishida
a4a6019550
[Bug #21202] Fix wrong token concat while tokenizing nested unterminated heredoc (#13000) 2025-03-29 20:46:43 +09:00
ydah
549c7fe29d Adjust indentation for user defined parameterized rule
This PR just fixing indentation.
2025-03-29 17:51:19 +09:00
Nobuyoshi Nakada
820c541671 [Bug #21026] no singleton method on pseudo variable literal 2025-03-20 17:32:26 +09:00
Nobuyoshi Nakada
1acfb29015 [Bug #21186] multibyte char literal should be a single letter word 2025-03-17 23:55:11 +09:00
ydah
dd7deef338 Organize block_param_def by defining opt_block_param for non-terminal symbols 2025-03-14 17:10:33 +09:00
ydah
f5f1951808 Refactor parse.y to replace tIDENTIFIER and tCONSTANT with ident_or_const inline rules 2025-03-14 12:32:03 +09:00
ydah
84f51eb02a Use user defined parameterizing rules args_tail_basic 2025-03-14 00:20:35 +09:00
ydah
5965978efb Merge the new_yield method into the rb_node_yield_new method 2025-03-09 11:26:56 +09:00
ydah
caa7eaecc5 Refactor parser rules to remove inline_operation 2025-03-09 02:56:26 +09:00
ydah
24945defa5 Remove redundant semantic action in bvar rule 2025-03-08 22:20:11 +09:00
ydah
eae0fe37c0 Implement CLASS NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e "class A < B; end"
@ ProgramNode (location: (1,0)-(1,16))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,16))
    +-- body: (length: 1)
        +-- @ ClassNode (location: (1,0)-(1,16))
            +-- locals: []
            +-- class_keyword_loc: (1,0)-(1,5) = "class"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- constant_path:
            |   @ ConstantReadNode (location: (1,6)-(1,7))
            |   +-- name: :A
            +-- inheritance_operator_loc: (1,8)-(1,9) = "<"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- superclass:
            |   @ ConstantReadNode (location: (1,10)-(1,11))
            |   +-- name: :B
            +-- body: nil
            +-- end_keyword_loc: (1,13)-(1,16) = "end"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- name: :A
```
2025-03-08 18:26:40 +09:00
ydah
a47e686cb6 Implement POSTEXE NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e "END {  }"
@ ProgramNode (location: (1,0)-(1,8))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,8))
    +-- body: (length: 1)
        +-- @ PostExecutionNode (location: (1,0)-(1,8))
            +-- statements: nil
            +-- keyword_loc: (1,0)-(1,3) = "END"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- opening_loc: (1,4)-(1,5) = "{"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- closing_loc: (1,7)-(1,8) = "}"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2025-03-03 11:17:14 +09:00
ydah
c93f30ab67 Use user defined parameterizing rules mlhs 2025-03-02 23:10:45 +09:00
ydah
6c8cdc9c6b Change superclass rhs to use none 2025-03-02 23:10:17 +09:00
ydah
3198b46a36 s/TERMINTOR/TERMINATOR/ 2025-02-25 10:29:15 +09:00
Nobuyoshi Nakada
21ac0a3a64
[Bug #21153] Add missing op-assign to top const in command_asgn
It was defined in `arg` only; moved that pattern to `op_asgn` rule to
share it with `command_asgn`.
2025-02-24 23:20:12 +09:00
S-H-GAMELINKS
5cf146399f Merge NODE_LINE and NODE_ENCODING cases in cond0 function
NODE_LINE and NODE_ENCODING cases are used SWITCH_BY_COND_TYPE macro that is same to NODE_INTEGER and other cases.
NODE_LINE and NODE_ENCODING cases can be marge to NODE_INTEGER and other node cases.
2025-02-24 18:44:57 +09:00
ydah
2b1db0faec Remove unnecessary assignments to local variables in f_arg_asgn
Local variables are not reassigned and are not needed.
2025-01-21 20:25:38 +09:00
ydah
3260b0b647 Remove unnecessary assignments to local variables in strings
Local variables are not reassigned and are not needed.
2025-01-21 20:25:38 +09:00
Nobuyoshi Nakada
073c4e1cc7
[Feature #6012] Extend source_location for end position and columns 2025-01-09 20:21:41 +09:00
ydah
6069e8fea5 Refactor for loop handling to simplify do keyword location assignment 2025-01-09 18:24:56 +09:00
ydah
7790aa89f9 Use Named Reference 2025-01-09 18:24:56 +09:00
ydah
c721301132 Implement FOR NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e "for a in b do end"
@ ProgramNode (location: (1,0)-(1,17))
+-- locals: [:a]
+-- statements:
    @ StatementsNode (location: (1,0)-(1,17))
    +-- body: (length: 1)
        +-- @ ForNode (location: (1,0)-(1,17))
            +-- index:
            |   @ LocalVariableTargetNode (location: (1,4)-(1,5))
            |   +-- name: :a
            |   +-- depth: 0
            +-- collection:
            |   @ CallNode (location: (1,9)-(1,10))
            |   +-- CallNodeFlags: variable_call, ignore_visibility
            |   +-- receiver: nil
            |   +-- call_operator_loc: nil
            |   +-- name: :b
            |   +-- message_loc: (1,9)-(1,10) = "b"
            |   +-- opening_loc: nil
            |   +-- arguments: nil
            |   +-- closing_loc: nil
            |   +-- block: nil
            +-- statements: nil
            +-- for_keyword_loc: (1,0)-(1,3) = "for"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- in_keyword_loc: (1,6)-(1,8) = "in"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- do_keyword_loc: (1,11)-(1,13) = "do"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- end_keyword_loc: (1,14)-(1,17) = "end"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2025-01-09 18:24:56 +09:00
ydah
36b6625ba9 Refactor parse_isalnum and parse_isxdigit to use macro 2025-01-09 02:33:48 +09:00
ydah
18f756e4af Remove unnecessary semantic actions
If you don’t specify an action for a rule, Lrama supplies a default: `$$ = $1`.
2025-01-08 10:48:07 +09:00
ydah
de8deb5f9c Remove unused token definitions for tRPAREN in Ripper and parser files 2025-01-07 07:17:55 +09:00
Peter Zhu
dfc9e978fb [Bug #21004] Fix memory leak with "it" in parse.y
Parsing `-> do it end` in parse.y leaks memory. We can see this in the
Valgrind output:

    56 bytes in 1 blocks are definitely lost in loss record 1 of 6
        at 0x484E0DC: calloc (vg_replace_malloc.c:1675)
        by 0x188970: calloc1 (default.c:1472)
        by 0x188970: rb_gc_impl_calloc (default.c:8208)
        by 0x188970: ruby_xcalloc_body (gc.c:4598)
        by 0x18B8BC: ruby_xcalloc (gc.c:4592)
        by 0x21DCCA70: new_locations_lambda_body (ripper.y:12844)
        by 0x21DCCA70: ripper_yyparse (ripper.y:5194)
        by 0x21DDA521: rb_ruby_ripper_parse0 (ripper.y:15798)
2025-01-05 09:06:12 +09:00
Peter Zhu
78d7dde21c Remove unused loc in rb_locations_lambda_body_t 2025-01-05 09:06:12 +09:00
ydah
61c4907458 Implement DOT3 NODE locations 2025-01-04 20:27:40 +09:00
ydah
88da6856a3 Implement DOT2 NODE locations 2025-01-04 20:27:40 +09:00
ydah
a1f010b8e4 Use user defined parameterizing rules compstmt(stmts) 2025-01-04 18:59:30 +09:00
ydah
bb66b42a7f Use user defined parameterizing rules op_asgn(rhs) 2025-01-04 18:58:44 +09:00
ydah
2efa78099c Use user defined parameterizing rules def_endless_method(bodystmt) 2025-01-04 18:58:44 +09:00
ydah
4fa68953fb Use user defined parameterizing rules asgn(lhs, rhs) 2025-01-04 18:58:44 +09:00
ydah
1e330dd5ec Use p_primitive_value 2025-01-04 18:07:27 +09:00
ydah
f00c5102c0 Use command_call_value 2025-01-04 18:07:27 +09:00
ydah
0eb63c410e Use user defined parameterizing rules value_expr 2025-01-04 18:07:27 +09:00
ydah
f2454aa2c2 Use user defined parameterizing rules f_kw(value) 2025-01-04 13:55:44 +09:00
ydah
5fcc3ab534 Implement REGX NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e '/foo/'
@ ProgramNode (location: (1,0)-(1,5))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,5))
    +-- body: (length: 1)
        +-- @ RegularExpressionNode (location: (1,0)-(1,5))
            +-- RegularExpressionFlags: forced_us_ascii_encoding
            +-- opening_loc: (1,0)-(1,1) = "/"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- content_loc: (1,1)-(1,4) = "foo"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- closing_loc: (1,4)-(1,5) = "/"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- unescaped: "foo"
```
2025-01-04 13:53:13 +09:00
ydah
fa2517451e Implement LAMBDA NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e "-> (a, b) do foo end"
@ ProgramNode (location: (1,0)-(1,20))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,20))
    +-- body: (length: 1)
        +-- @ LambdaNode (location: (1,0)-(1,20))
            +-- locals: [:a, :b]
            +-- operator_loc: (1,0)-(1,2) = "->"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- opening_loc: (1,10)-(1,12) = "do"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- closing_loc: (1,17)-(1,20) = "end"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: (snip)
```
2025-01-04 13:52:35 +09:00
ydah
607b1b3d76 Implement YIELD NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e 'def foo; yield end'
@ ProgramNode (location: (1,0)-(1,18))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,18))
    +-- body: (length: 1)
        +-- @ DefNode (location: (1,0)-(1,18))
            +-- name: :foo
            +-- name_loc: (1,4)-(1,7) = "foo"
            +-- receiver: nil
            +-- parameters: nil
            +-- body:
            |   @ StatementsNode (location: (1,9)-(1,14))
            |   +-- body: (length: 1)
            |       +-- @ YieldNode (location: (1,9)-(1,14))
            |           +-- keyword_loc: (1,9)-(1,14) = "yield"
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |           +-- lparen_loc: nil
                        ^^^^^^^^^^^^^^^^^^^
            |           +-- arguments: nil
            |           +-- rparen_loc: nil
                        ^^^^^^^^^^^^^^^^^^^
            +-- locals: []
            +-- def_keyword_loc: (1,0)-(1,3) = "def"
            +-- operator_loc: nil
            +-- lparen_loc: nil
            +-- rparen_loc: nil
            +-- equal_loc: nil
            +-- end_keyword_loc: (1,15)-(1,18) = "end"
```
2025-01-04 07:34:49 +09:00
ydah
4c19201142 Implement EVSTR NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e '"#{foo}"'
@ ProgramNode (location: (1,0)-(1,8))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,8))
    +-- body: (length: 1)
        +-- @ InterpolatedStringNode (location: (1,0)-(1,8))
            +-- InterpolatedStringNodeFlags: nil
            +-- opening_loc: (1,0)-(1,1) = "\""
            +-- parts: (length: 1)
            |   +-- @ EmbeddedStatementsNode (location: (1,1)-(1,7))
            |       +-- opening_loc: (1,1)-(1,3) = "\#{"
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |       +-- statements:
            |       |   @ StatementsNode (location: (1,3)-(1,6))
            |       |   +-- body: (length: 1)
            |       |       +-- @ CallNode (location: (1,3)-(1,6))
            |       |           +-- CallNodeFlags: variable_call, ignore_visibility
            |       |           +-- receiver: nil
            |       |           +-- call_operator_loc: nil
            |       |           +-- name: :foo
            |       |           +-- message_loc: (1,3)-(1,6) = "foo"
            |       |           +-- opening_loc: nil
            |       |           +-- arguments: nil
            |       |           +-- closing_loc: nil
            |       |           +-- block: nil
            |       +-- closing_loc: (1,6)-(1,7) = "}"
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- closing_loc: (1,7)-(1,8) = "\""
```
2025-01-04 07:34:25 +09:00
ydah
c22b0598b0 Implement SUPER NODE locations 2025-01-03 23:03:04 +09:00
ydah
5cc4240dda Refactor parse.y to replace tIDENTIFIER and tCONSTANT with ident_or_const inline rules 2025-01-03 22:13:20 +09:00