Commit graph

302 commits

Author SHA1 Message Date
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
Kevin Newton
d6424453db [ruby/prism] Enable remaining heredoc unescape tests
c7ea4941c5
2023-10-13 15:31:30 -04:00
Kevin Newton
24768d8a57 [ruby/prism] Use current_string for escapes in heredocs
fc49acfc59
2023-10-13 15:31:30 -04:00
Kevin Newton
1a7364b347 [ruby/prism] Use create_unescaped functions for empty heredocs
acec5a13cb
2023-10-13 15:31:30 -04:00
Kevin Newton
da47a71325 [ruby/prism] Use current_string for x string escape sequences
66ce9280bb
2023-10-13 15:31:30 -04:00
Kevin Newton
a7f71e461e [ruby/prism] Use token buffer for string lexing
087cd8f28b
2023-10-13 15:31:30 -04:00
Kevin Newton
973ecf6848 [ruby/prism] Extract out a couple more token buffer functions
341e027d23
2023-10-13 15:31:30 -04:00
Kevin Newton
af8484bc39 [ruby/prism] Capture the token buffer logic into its own struct and functions
4334f0775b
2023-10-13 15:31:30 -04:00
Kevin Newton
ef1e5b65dc [ruby/prism] Use current_string to handle escapes in string literals
d912d48104
2023-10-13 15:31:30 -04:00
Kevin Newton
f64a0434dd [ruby/prism] Use current_string to handle %I
831d5f4b45
2023-10-13 15:31:30 -04:00
Kevin Newton
5fc34f1cde [ruby/prism] Use current_string for handling %W lists
edb1674725
2023-10-13 15:31:30 -04:00
Kevin Newton
41ac8ddca3 [ruby/prism] Extract out string handling for %W lists
dba9bd6b1f
2023-10-13 15:31:30 -04:00
Kevin Newton
3c743445d7 [ruby/prism] Use current_string to handle %i escapes
9c90d0a777
2023-10-13 15:31:30 -04:00
Kevin Newton
4e3013f42d [ruby/prism] Use current_string to handle %w escapes
b8420ea7ae
2023-10-13 15:31:30 -04:00
Kevin Newton
3dba3ab47d [ruby/prism] Strip out old char unescaping
27ca207ab3
2023-10-13 15:31:30 -04:00
Kevin Newton
dd3986876a [ruby/prism] Handle remaining escape sequences for character literals
ba33607034
2023-10-13 15:31:30 -04:00
Kevin Newton
1a941c70e4 [ruby/prism] Track current_string to pass forward for character literals
be1d8ae8bb
2023-10-13 15:31:30 -04:00
Haldun Bayhantopcu
4387af1b4a [ruby/prism] Fix parsing symbols in strings after labels
e16531650d
2023-10-12 16:01:40 +00:00
Matt Valentine-House
5c8764477f [ruby/prism] Increase the depth for the For node index variable
In CRuby's parser locals in for nodes appear deeper in the ast than they
do in Prism, but we can fix that with a transparent scope

460187f41e
2023-10-12 15:26:29 +00:00
Matt Valentine-House
9af5abd23a [ruby/prism] Allow Scope nodes to be created for a For loop
ded8711807
2023-10-11 18:26:00 +00:00
Matt Valentine-House
0fdee133fc [ruby/prism] Attach the ast node to the scope
So when building instruction sequences for a scope we can reference
items from the ast node that requires the scope. This is useful for for
loops, where the local variable tables from the parent scope will need
to be referenced.

426b1ca094
2023-10-09 10:16:01 +00:00
Haldun Bayhantopcu
7eccc13c1f [ruby/prism] Emit error when assigning to a numbered parameter
66248ac2f6
2023-10-06 14:10:28 +00:00
Matt Valentine-House
7db4ce13ed [ruby/prism] Introduce transparent scopes.
A transparent scope is a scope that cannot have local variables added to
it's local table. When a local is added to it's table, it instead gets
added to the first non-transparent parent scope.

This is used in for loops to ensure the correct depth for local
variables inside the body

ddb8e82253

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2023-10-06 12:21:03 +00:00
Haldun Bayhantopcu
8d8fe54355 [ruby/prism] Check for duplicate parameter names in destructured params
c3438aabea
2023-10-05 16:35:45 +00:00
Haldun Bayhantopcu
38cb92a00c [ruby/prism] Check for duplicate names in shadow args
e100c6b8ae
2023-10-05 15:12:05 +00:00
Haldun Bayhantopcu
fb9795cf7a [ruby/prism] Fix parsing shadow args in lambda blocks
53efaf252d
2023-10-05 11:25:32 +00:00
Kevin Newton
d47af93110 [ruby/prism] Provide pm_parser_err_current and pm_parser_err_previous
4828c96939
2023-10-03 18:46:37 +00:00
Kevin Newton
ad0e8ddbdb [ruby/prism] Consolidate diagnostic appendings
4f107d8962
2023-10-03 18:46:36 +00:00
Benoit Daloze
87dad067e0 Sync with prism CallNode#name changes
* https://github.com/ruby/prism/pull/1533
2023-10-02 09:18:56 -04:00
Nathan Froyd
f88f5b59e8 [ruby/prism] remove peek_string to avoid subtle memory issues
f393d30ce1
2023-09-29 20:41:23 +00:00
Kevin Newton
9861ec4fb9 [ruby/prism] Mark ranges as static literal
4c77944dd4
2023-09-29 15:26:06 +00:00
Kevin Newton
223e9fcb27 [ruby/prism] Self should not be marked as static literal
81265ed8a7
2023-09-28 18:51:26 +00:00
Kevin Newton
56cf1633a2 [ruby/prism] Turn on static literal for assoc, hash, and array nodes
80c2c931b5
2023-09-28 18:15:35 +00:00
Haldun Bayhantopcu
834560a923 [ruby/prism] Check whether the predicate is closed for conditionals
bf43006d0a
2023-09-28 13:32:02 +00:00
Haldun Bayhantopcu
7799fe90da [ruby/prism] Check for a semicolon or a newline after the inheritance operator
0326ba6775
2023-09-28 13:31:22 +00:00
Haldun Bayhantopcu
0084bac47a [ruby/prism] Fix assertion failure for fwd params after rest
f86bff6dd7
2023-09-28 13:24:57 +00:00