Skip to content

Commit

Permalink
[ruby/prism] Implement regular expressions for ripper translation
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Mar 6, 2024
1 parent bfa2a08 commit d815d68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 8 additions & 2 deletions lib/prism/translation/ripper.rb
Expand Up @@ -1329,7 +1329,7 @@ def visit_match_required_node(node)
# /(?<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
Expand Down Expand Up @@ -1568,7 +1568,13 @@ def visit_redo_node(node)
# /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
Expand Down
9 changes: 0 additions & 9 deletions test/prism/ripper_test.rb
Expand Up @@ -307,7 +307,6 @@ class RipperFixturesTest < RipperTestCase
methods.txt
modules.txt
multi_write.txt
newline_terminated.txt
non_alphanumeric_methods.txt
not.txt
patterns.txt
Expand Down Expand Up @@ -355,9 +354,7 @@ class RipperFixturesTest < RipperTestCase
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
Expand Down Expand Up @@ -575,11 +572,8 @@ class RipperFixturesTest < RipperTestCase
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
Expand Down Expand Up @@ -715,7 +709,6 @@ class RipperFixturesTest < RipperTestCase
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
Expand Down Expand Up @@ -799,7 +792,6 @@ class RipperFixturesTest < RipperTestCase
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
Expand All @@ -808,7 +800,6 @@ class RipperFixturesTest < RipperTestCase
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
Expand Down

0 comments on commit d815d68

Please sign in to comment.