Commit graph

337 commits

Author SHA1 Message Date
Kevin Newton
86bfd6060d [ruby/prism] Documentation for pm_newline_list_t
97b3cc0af8
2023-11-01 13:10:29 -04:00
Kevin Newton
8302f9986c [ruby/prism] Documentation for pm_string_t
ff1d2ec579
2023-11-01 13:10:29 -04:00
Kevin Newton
b67994d6bf [ruby/prism] Even more C documentation
bec5ca37a0
2023-11-01 13:10:29 -04:00
Kevin Newton
7c8d939680 [ruby/prism] Start better documenting C API
2b6e661bbc
2023-11-01 13:10:29 -04:00
Kevin Newton
8c0eb221b7 [ruby/prism] Forward parameters into arrays
2a11bfee76
2023-11-01 17:03:35 +00:00
Jemma Issroff
e80ca70b9b [ruby/prism] Flip incorrect names of OptionalKeywordParameterNode and RequiredKeywordParameterNode
c31f61e898
2023-11-01 14:40:45 +00:00
Jemma Issroff
d0625099e0 [ruby/prism] Split KeywordParameterNode into Optional and Required
Prior to this commit, KeywordParameterNode included both optional
and required keywords. With this commit, it is split in two, with
`OptionalKeywordParameterNode`s no longer having a value field.

89084d9af4
2023-11-01 14:40:44 +00:00
Haldun Bayhantopcu
3801503fe3 [ruby/prism] Fix a possible malloc(0)
fa108b8626
2023-10-31 12:54:13 +00:00
Haldun Bayhantopcu
322755a007 [ruby/prism] Fix a possible null dereference
7dbb8c7e3e
2023-10-31 11:14:07 +00:00
Haldun Bayhantopcu
3a21da9591 [ruby/prism] Faster lex_identifier
e44a9ae742
2023-10-30 16:19:54 +00:00
Kevin Newton
7bf3d9343f [ruby/prism] parse_inline_comments -> parse_comments
bd4d248fd6
2023-10-30 15:53:37 +00:00
Kevin Newton
c201dbc0ad [ruby/prism] Prism.parse_inline_comments
5b72f84480
2023-10-27 18:09:14 +00:00
Kevin Newton
a8af5d3808 [ruby/prism] Use MatchWriteNode on split InterpolatedREN
ee54244800
2023-10-27 13:40:25 +00:00
Kevin Newton
a40e2b8ee9 [ruby/prism] Fix parsing lone assoc splat within hash patterns
1da5e05672
2023-10-27 02:09:33 +00:00
Kevin Newton
6e8ff9d275 [ruby/prism] Allow regexp flags to change
88a61cc30c
2023-10-26 19:43:17 +00:00
Kevin Newton
21dc64534b [ruby/prism] Regenerate snapshots
160df9a687
2023-10-26 15:19:52 -04:00
Kevin Newton
e9aa2398b9 [ruby/prism] Get general prettyprint structure working
7c9cf63d4c
2023-10-26 15:19:35 -04:00
Benoit Daloze
9792be3610 [ruby/prism] Avoid warning for pm_token_buffer_t initialization
* This was causing this error on macOS Mojave:
  src/prism.c:8216:48: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
            pm_token_buffer_t token_buffer = { 0 };
                                               ^

5055fc04fd
2023-10-26 19:12:04 +00:00
Kevin Newton
018f0a9c5f [ruby/prism] Rename to lefts/rights
e6deed05a5
2023-10-26 14:59:13 -04:00
Kevin Newton
922f48f081 [ruby/prism] Remove RequiredDestructuredParameterNode in favor of MultiTargetNode
6d1858192e
2023-10-26 14:59:07 -04:00
Kevin Newton
533bd1d1fa [ruby/prism] Ensure no extra multi-target nodes are created for splats
e60240d54b
2023-10-26 14:59:00 -04:00
Kevin Newton
82acca915a [ruby/prism] Ensure no extra multi-target nodes are created
ec31fd827f
2023-10-26 14:58:55 -04:00
Kevin Newton
234e8fb819 [ruby/prism] Split up multi target/write targets
dda7a0da52
2023-10-26 14:58:48 -04:00
Jemma Issroff
7e4ee92de2 [ruby/prism] Add KeywordSplat flag to ArgumentsNode
Method calls with keyword splat args compile differently than
without since they merge the keyword arg hash with the keyword splat
hash. We know this information at parse time, so can set a flag
which the compiler can use.

e5f8a9a3cd
2023-10-26 18:47:50 +00:00
Jemma Issroff
0abf2d86b9 [PRISM] Move pm_scope_node_init to prism_compile.c
pm_scope_node_init is only used for CRuby, so should not live in the
ruby/prism repo. We will merge the changes here first so they're
not breaking, and will then remove from ruby/prism
2023-10-25 18:18:35 -03:00
Jemma Issroff
10756f3dea [ruby/prism] Add PostExecutionNode to pm_scope_node_init
88fe6213af
2023-10-24 18:34:36 +00:00
Jemma Issroff
a9512e80b0 Revert "Revert "[ruby/prism] Change ScopeNode to point to previous ScopeNode""
This reverts commit fd87372a74.
2023-10-18 17:16:11 -07:00
Kevin Newton
5d0604366e [ruby/prism] Add * and & to methods with ...
e8114a786a
2023-10-18 16:08:31 +00:00
Kevin Newton
f5f032295d [ruby/prism] Provide "constant" constants, embedded in the code
d469a56e7e
2023-10-18 16:08:31 +00:00
Kevin Newton
9c973f9555 [ruby/prism] Use the unescaped regexp to scan for capture groups
555551e8f2
2023-10-18 14:23:46 +00:00
Kevin Newton
2a6f7cd925 [ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:

```ruby
foo.bar += 1
foo[bar] += 1
```

These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.

The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.

Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.

For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.

For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.

I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.

70155db9cd
2023-10-18 14:23:26 +00:00
eileencodes
5a3e8d2f18 [ruby/prism] Ensure last encoding flag wins
You can't encoding a string with more than one encoding so ensure that
the last one wins.

4182c988c9
2023-10-17 17:50:38 +00:00
Kevin Newton
9bd99cc171 [ruby/prism] Fix up super with a blockarg
0ea19ed823
2023-10-17 00:42:31 +00:00
Kevin Newton
1ae8c62483 [ruby/prism] Load magic comments in java
5d189ce33e
2023-10-16 15:40:19 -07:00
Kevin Newton
9f16f07cf1 [ruby/prism] Additionally handle encoding comments in vim mode
bf9bdb9d82
2023-10-16 15:40:19 -07:00
Kevin Newton
5523a23469 [ruby/prism] Attach magic comments to the parse result
c7ef25a79a
2023-10-16 15:40:19 -07:00
Kevin Newton
39dd3343d8 [ruby/prism] Parse all magic comments
2b3d59f424
2023-10-16 15:40:19 -07:00
Jemma Issroff
fd87372a74
Revert "[ruby/prism] Change ScopeNode to point to previous ScopeNode"
This reverts commit 67a987f82b.
2023-10-16 15:20:26 -07:00
Jemma Issroff
67a987f82b [ruby/prism] Change ScopeNode to point to previous ScopeNode
Amend ScopeNode to point to previous ScopeNode, and to have void*
pointers to constants and index_lookup_table

0534324312
2023-10-16 21:53:11 +00:00
Kevin Newton
8e477af1d4 [ruby/prism] Put names on back reference read nodes
10a6403293
2023-10-14 14:15:54 +00:00
Kevin Newton
11e946da2f [ruby/prism] Fix up PR failings
11255f636e
2023-10-13 15:31:30 -04:00
Kevin Newton
d06523bc52 [ruby/prism] Remove now-defunct semantic_field from nodes
c82a9dad64
2023-10-13 15:31:30 -04:00
Kevin Newton
2de0299839 [ruby/prism] Final unescapes cleanup
bfcd8262a4
2023-10-13 15:31:30 -04:00
Kevin Newton
37d958eaf4 Remove old unescaping code 2023-10-13 15:31:30 -04:00
Kevin Newton
fa76cddc5b [ruby/prism] Properly handle unescaping in regexp
abf9fd6863
2023-10-13 15:31:30 -04:00
Kevin Newton
e4f1c06a9b [ruby/prism] Use current_string to handle :" symbols
eedeec8f9a
2023-10-13 15:31:30 -04:00
Kevin Newton
a1de762966 [ruby/prism] Use current_string for :' symbols
fadb5be520
2023-10-13 15:31:30 -04:00
Kevin Newton
8bf0d381dc [ruby/prism] Use current_string for %s symbol literals
52504f8911
2023-10-13 15:31:30 -04:00
Kevin Newton
d0614b5254 [ruby/prism] Split up lines in tilde heredocs
21fad0c2ce
2023-10-13 15:31:30 -04:00
Kevin Newton
ad46fc093b [ruby/prism] Calculate heredoc common whitespace while lexing
c3f43b64a3
2023-10-13 15:31:30 -04:00