Commit graph

302 commits

Author SHA1 Message Date
Kevin Newton
8587d9a8bf
[ruby/prism] Wire up options through the Java parser
13fa262669
2023-11-03 10:13:50 -04:00
Kevin Newton
d7d3243364
[ruby/prism] Properly support the start line option
33cc75a4b7
2023-11-03 10:13:50 -04:00
Kevin Newton
95d3f2eaec
[ruby/prism] Properly support the suppress_warnings option
84229529d7
2023-11-03 10:13:49 -04:00
Kevin Newton
85af40c1d7
[ruby/prism] Properly support the encoding option
4b538af20f
2023-11-03 10:13:49 -04:00
Kevin Newton
6496591194
[ruby/prism] Rename serialization APIs for consistency
5a2252e3ac
2023-11-03 10:13:49 -04:00
Kevin Newton
05f5c545d2
[ruby/prism] Wire up options through the FFI API
f0aa8ad93b
2023-11-03 10:13:49 -04:00
Kevin Newton
2a0f2b7763
[ruby/prism] Create an options struct for passing all of the possible options
99e81619de
2023-11-03 10:13:49 -04:00
Kevin Newton
ee7bf4643d [ruby/prism] Handle invalid constants in the constant pool
It's possible for us to parse a constant that is invalid in the
current encoding. To fix this, we wrap the intern function in an
rb_protect to ensure we always put a valid symbol into the AST.

e78398554d
2023-11-02 22:14:08 +00:00
Kevin Newton
52e127280b [ruby/prism] Disallow assigning to numbered parameters in regexp
ec419422f8
2023-11-01 17:40:16 +00:00
Kevin Newton
690f3bbf5d [ruby/prism] Last remaining missing C comments
e327449db6
2023-11-01 13:10:29 -04:00
Kevin Newton
e745af2f0e [ruby/prism] Comment format for prism.c
83f737ce17
2023-11-01 13:10:29 -04:00
Kevin Newton
17923cc876 [ruby/prism] Even more C file documentation
9c648ce615
2023-11-01 13:10:29 -04:00
Kevin Newton
171788c703 [ruby/prism] Remove unnecessary PM_EMPTY_ARGUMENTS
271f3bf628
2023-11-01 13:10:29 -04:00
Kevin Newton
b12c795bdc [ruby/prism] Remove unnecessary PM_EMPTY_NODE_LIST
857f72e1f4
2023-11-01 13:10:29 -04:00
Kevin Newton
e8a72b516f [ruby/prism] Documentation for more C functions
88336e7d9f
2023-11-01 13:10:29 -04:00
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