mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
[ruby/prism] Fix ripper translator for __END__
https://github.com/ruby/prism/commit/2792ac78ca
This commit is contained in:
1 parent
00a3b71eaf
commit
d1dc4bdb2f
2 files changed
+7
-9
No files matched your search
@@ -225,14 +225,6 @@ module Prism
|
||||
end
|
||||
end
|
||||
|
||||
# Ripper doesn't include the rest of the token in the event, so we need to
|
||||
# trim it down to just the content on the first line when comparing.
|
||||
class EndContentToken < Token
|
||||
def ==(other) # :nodoc:
|
||||
[self[0], self[1], self[2][0..self[2].index("\n")], self[3]] == other
|
||||
end
|
||||
end
|
||||
|
||||
# Tokens where state should be ignored
|
||||
# used for :on_comment, :on_heredoc_end, :on_embexpr_end
|
||||
class IgnoreStateToken < Token
|
||||
@@ -680,7 +672,10 @@ module Prism
|
||||
token =
|
||||
case event
|
||||
when :on___end__
|
||||
EndContentToken.new([[lineno, column], event, value, lex_state])
|
||||
# Ripper doesn't include the rest of the token in the event, so we need to
|
||||
# trim it down to just the content on the first line.
|
||||
value = value[0..value.index("\n")]
|
||||
Token.new([[lineno, column], event, value, lex_state])
|
||||
when :on_comment
|
||||
IgnoreStateToken.new([[lineno, column], event, value, lex_state])
|
||||
when :on_heredoc_end
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
foo
|
||||
__END__
|
||||
Available in DATA constant
|
||||
Reference in new issue
Block a user