Skip to content

Commit 985b58a

Browse files
Earlopainmatzbot
authored andcommitted
[ruby/prism] Remove unneeded lex_compat token types
These are either fixed in prism or ruby/ripper itself. ruby/prism@41c7c126b2
1 parent f7bc28d commit 985b58a

File tree

1 file changed

+0
-69
lines changed

1 file changed

+0
-69
lines changed

lib/prism/lex_compat.rb

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -247,50 +247,6 @@ def ==(other) # :nodoc:
247247
end
248248
end
249249

250-
# Ident tokens for the most part are exactly the same, except sometimes we
251-
# know an ident is a local when ripper doesn't (when they are introduced
252-
# through named captures in regular expressions). In that case we don't
253-
# compare the state.
254-
class IdentToken < Token
255-
def ==(other) # :nodoc:
256-
(self[0...-1] == other[0...-1]) && (
257-
(other[3] == Translation::Ripper::EXPR_LABEL | Translation::Ripper::EXPR_END) ||
258-
(other[3] & (Translation::Ripper::EXPR_ARG | Translation::Ripper::EXPR_CMDARG) != 0)
259-
)
260-
end
261-
end
262-
263-
# Ignored newlines can occasionally have a LABEL state attached to them, so
264-
# we compare the state differently here.
265-
class IgnoredNewlineToken < Token
266-
def ==(other) # :nodoc:
267-
return false unless self[0...-1] == other[0...-1]
268-
269-
if self[3] == Translation::Ripper::EXPR_ARG | Translation::Ripper::EXPR_LABELED
270-
other[3] & Translation::Ripper::EXPR_ARG | Translation::Ripper::EXPR_LABELED != 0
271-
else
272-
self[3] == other[3]
273-
end
274-
end
275-
end
276-
277-
# If we have an identifier that follows a method name like:
278-
#
279-
# def foo bar
280-
#
281-
# then Ripper will mark bar as END|LABEL if there is a local in a parent
282-
# scope named bar because it hasn't pushed the local table yet. We do this
283-
# more accurately, so we need to allow comparing against both END and
284-
# END|LABEL.
285-
class ParamToken < Token
286-
def ==(other) # :nodoc:
287-
(self[0...-1] == other[0...-1]) && (
288-
(other[3] == Translation::Ripper::EXPR_END) ||
289-
(other[3] == Translation::Ripper::EXPR_END | Translation::Ripper::EXPR_LABEL)
290-
)
291-
end
292-
end
293-
294250
# A heredoc in this case is a list of tokens that belong to the body of the
295251
# heredoc that should be appended onto the list of tokens when the heredoc
296252
# closes.
@@ -699,33 +655,8 @@ def result
699655
# want to bother comparing the state on them.
700656
last_heredoc_end = token.location.end_offset
701657
IgnoreStateToken.new([[lineno, column], event, value, lex_state])
702-
when :on_ident
703-
if lex_state == Translation::Ripper::EXPR_END
704-
# If we have an identifier that follows a method name like:
705-
#
706-
# def foo bar
707-
#
708-
# then Ripper will mark bar as END|LABEL if there is a local in a
709-
# parent scope named bar because it hasn't pushed the local table
710-
# yet. We do this more accurately, so we need to allow comparing
711-
# against both END and END|LABEL.
712-
ParamToken.new([[lineno, column], event, value, lex_state])
713-
elsif lex_state == Translation::Ripper::EXPR_END | Translation::Ripper::EXPR_LABEL
714-
# In the event that we're comparing identifiers, we're going to
715-
# allow a little divergence. Ripper doesn't account for local
716-
# variables introduced through named captures in regexes, and we
717-
# do, which accounts for this difference.
718-
IdentToken.new([[lineno, column], event, value, lex_state])
719-
else
720-
Token.new([[lineno, column], event, value, lex_state])
721-
end
722658
when :on_embexpr_end
723659
IgnoreStateToken.new([[lineno, column], event, value, lex_state])
724-
when :on_ignored_nl
725-
# Ignored newlines can occasionally have a LABEL state attached to
726-
# them which doesn't actually impact anything. We don't mirror that
727-
# state so we ignored it.
728-
IgnoredNewlineToken.new([[lineno, column], event, value, lex_state])
729660
when :on_regexp_end
730661
# On regex end, Ripper scans and then sets end state, so the ripper
731662
# lexed output is begin, when it should be end. prism sets lex state

0 commit comments

Comments
 (0)