class SyntaxTree::Parser
def on_in(pattern, statements, consequent)
(nil | In | Else) consequent
Statements statements,
untyped pattern,
| (
on_in: (RAssign pattern, nil statements, nil consequent) -> RAssign
:call-seq:
def on_in(pattern, statements, consequent) # Here we have a rightward assignment return pattern unless statements beginning = consume_keyword(:in) ending = consequent || consume_keyword(:end) statements_start = pattern if (token = find_keyword_between(:then, pattern, statements)) tokens.delete(token) statements_start = token end start_char = find_next_statement_start((token || statements_start).location.end_char) # Ripper ignores parentheses on patterns, so we need to do the same in # order to attach comments correctly to the pattern. if source[start_char] == ")" start_char = find_next_statement_start(start_char + 1) end statements.bind( self, start_char, start_char - line_counts[statements_start.location.start_line - 1].start, ending.location.start_char, ending.location.start_column ) node = In.new( pattern: pattern, statements: statements, consequent: consequent, location: beginning.location.to(ending.location) ) PinVisitor.visit(node, tokens) node end