instance method
Prism::Translation::Parser::Compiler#visit_in_node
visit_in_node(node)
lib/prism/translation/parser/compiler.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/parser/compiler.rb, line 968
def visit_in_node(node)
pattern = nil
guard = nil
case node.pattern
when IfNode
pattern = within_pattern { |compiler| node.pattern.statements.accept(compiler) }
guard = builder.if_guard(token(node.pattern.if_keyword_loc), visit(node.pattern.predicate))
when UnlessNode
pattern = within_pattern { |compiler| node.pattern.statements.accept(compiler) }
guard = builder.unless_guard(token(node.pattern.keyword_loc), visit(node.pattern.predicate))
else
pattern = within_pattern { |compiler| node.pattern.accept(compiler) }
end
builder.in_pattern(
token(node.in_loc),
pattern,
guard,
if (then_loc = node.then_loc)
token(then_loc)
else
srange_semicolon(node.pattern.location.end_offset, node.statements&.location&.start_offset)
end,
visit(node.statements)
)
end
case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^