diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-05 07:43:24 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:41 +0000 |
| commit | d815d68cbb420243d0f2e3fc866350761154dd82 (patch) | |
| tree | e0603f5606449a4c5d065b4ed2784013c8439eaa | |
| parent | bfa2a08444f073b2a0a5d759f463a04fb8a3c1f2 (diff) | |
[ruby/prism] Implement regular expressions for ripper translation
https://github.com/ruby/prism/commit/788cf7c528
| -rw-r--r-- | lib/prism/translation/ripper.rb | 10 | ||||
| -rw-r--r-- | test/prism/ripper_test.rb | 9 |
2 files changed, 8 insertions, 11 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index c839b90456..fe44fae836 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -1329,7 +1329,7 @@ module Prism # /(?<foo>foo)/ =~ bar # ^^^^^^^^^^^^^^^^^^^^ def visit_match_write_node(node) - raise NoMethodError, __method__ + visit(node.call) end # A node that is missing from the syntax tree. This is only used in the @@ -1568,7 +1568,13 @@ module Prism # /foo/ # ^^^^^ def visit_regular_expression_node(node) - raise NoMethodError, __method__ + bounds(node.content_loc) + content = on_tstring_content(node.unescaped) + + bounds(node.closing_loc) + closing = on_regexp_end(node.closing) + + on_regexp_literal(on_regexp_add(on_regexp_new, content), closing) end # def foo(bar:); end diff --git a/test/prism/ripper_test.rb b/test/prism/ripper_test.rb index 212d2777fd..a1744cd7cb 100644 --- a/test/prism/ripper_test.rb +++ b/test/prism/ripper_test.rb @@ -307,7 +307,6 @@ module Prism methods.txt modules.txt multi_write.txt - newline_terminated.txt non_alphanumeric_methods.txt not.txt patterns.txt @@ -355,9 +354,7 @@ module Prism seattlerb/bug_args_masgn2.txt seattlerb/bug_args_masgn_outer_parens__19.txt seattlerb/bug_call_arglist_parens.txt - seattlerb/bug_case_when_regexp.txt seattlerb/bug_comma.txt - seattlerb/bug_cond_pct.txt seattlerb/bug_hash_args_trailing_comma.txt seattlerb/bug_hash_interp_array.txt seattlerb/bug_masgn_right.txt @@ -575,11 +572,8 @@ module Prism seattlerb/qwords_empty.txt seattlerb/read_escape_unicode_curlies.txt seattlerb/read_escape_unicode_h4.txt - seattlerb/regexp.txt seattlerb/regexp_esc_C_slash.txt - seattlerb/regexp_esc_u.txt seattlerb/regexp_escape_extended.txt - seattlerb/regexp_unicode_curlies.txt seattlerb/required_kwarg_no_value.txt seattlerb/rescue_do_end_ensure_result.txt seattlerb/rescue_do_end_no_raise.txt @@ -715,7 +709,6 @@ module Prism whitequark/bug_heredoc_do.txt whitequark/bug_interp_single.txt whitequark/bug_lambda_leakage.txt - whitequark/bug_regex_verification.txt whitequark/bug_rescue_empty_else.txt whitequark/bug_while_not_parens_do.txt whitequark/case_cond_else.txt @@ -799,7 +792,6 @@ module Prism whitequark/parser_bug_604.txt whitequark/parser_bug_640.txt whitequark/parser_bug_645.txt - whitequark/parser_bug_830.txt whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt whitequark/parser_slash_slash_n_escaping_in_literals.txt whitequark/pattern_matching__FILE__LINE_literals.txt @@ -808,7 +800,6 @@ module Prism whitequark/pattern_matching_single_line_allowed_omission_of_parentheses.txt whitequark/procarg0.txt whitequark/regex_interp.txt - whitequark/regex_plain.txt whitequark/resbody_var.txt whitequark/rescue_else.txt whitequark/rescue_else_ensure.txt |
