18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/rbs/prototype/rbi.rb', line 18
def parse(string)
= Ripper.lex(string).yield_self do |tokens|
tokens.each.with_object({}) do |token, hash| if token[1] == :on_comment
line = token[0][0]
body = token[2][2..-1] or raise
body = "\n" if body.empty?
= AST::Comment.new(string: body, location: nil)
if ( = hash.delete(line - 1))
hash[line] = AST::Comment.new(
string: .string + .string,
location: nil
)
else
hash[line] =
end
end
end
end
process RubyVM::AbstractSyntaxTree.parse(string), comments:
end
|