Skip to content

Commit 41c7c12

Browse files
committed
Remove unneeded lex_compat token types
These are either fixed in prism or ruby/ripper itself.
1 parent 5ea83ca commit 41c7c12

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
@@ -233,50 +233,6 @@ def ==(other) # :nodoc:
233233
end
234234
end
235235

236-
# Ident tokens for the most part are exactly the same, except sometimes we
237-
# know an ident is a local when ripper doesn't (when they are introduced
238-
# through named captures in regular expressions). In that case we don't
239-
# compare the state.
240-
class IdentToken < Token
241-
def ==(other) # :nodoc:
242-
(self[0...-1] == other[0...-1]) && (
243-
(other[3] == Translation::Ripper::EXPR_LABEL | Translation::Ripper::EXPR_END) ||
244-
(other[3] & (Translation::Ripper::EXPR_ARG | Translation::Ripper::EXPR_CMDARG) != 0)
245-
)
246-
end
247-
end
248-
249-
# Ignored newlines can occasionally have a LABEL state attached to them, so
250-
# we compare the state differently here.
251-
class IgnoredNewlineToken < Token
252-
def ==(other) # :nodoc:
253-
return false unless self[0...-1] == other[0...-1]
254-
255-
if self[3] == Translation::Ripper::EXPR_ARG | Translation::Ripper::EXPR_LABELED
256-
other[3] & Translation::Ripper::EXPR_ARG | Translation::Ripper::EXPR_LABELED != 0
257-
else
258-
self[3] == other[3]
259-
end
260-
end
261-
end
262-
263-
# If we have an identifier that follows a method name like:
264-
#
265-
# def foo bar
266-
#
267-
# then Ripper will mark bar as END|LABEL if there is a local in a parent
268-
# scope named bar because it hasn't pushed the local table yet. We do this
269-
# more accurately, so we need to allow comparing against both END and
270-
# END|LABEL.
271-
class ParamToken < Token
272-
def ==(other) # :nodoc:
273-
(self[0...-1] == other[0...-1]) && (
274-
(other[3] == Translation::Ripper::EXPR_END) ||
275-
(other[3] == Translation::Ripper::EXPR_END | Translation::Ripper::EXPR_LABEL)
276-
)
277-
end
278-
end
279-
280236
# A heredoc in this case is a list of tokens that belong to the body of the
281237
# heredoc that should be appended onto the list of tokens when the heredoc
282238
# closes.
@@ -685,33 +641,8 @@ def result
685641
# want to bother comparing the state on them.
686642
last_heredoc_end = token.location.end_offset
687643
IgnoreStateToken.new([[lineno, column], event, value, lex_state])
688-
when :on_ident
689-
if lex_state == Translation::Ripper::EXPR_END
690-
# If we have an identifier that follows a method name like:
691-
#
692-
# def foo bar
693-
#
694-
# then Ripper will mark bar as END|LABEL if there is a local in a
695-
# parent scope named bar because it hasn't pushed the local table
696-
# yet. We do this more accurately, so we need to allow comparing
697-
# against both END and END|LABEL.
698-
ParamToken.new([[lineno, column], event, value, lex_state])
699-
elsif lex_state == Translation::Ripper::EXPR_END | Translation::Ripper::EXPR_LABEL
700-
# In the event that we're comparing identifiers, we're going to
701-
# allow a little divergence. Ripper doesn't account for local
702-
# variables introduced through named captures in regexes, and we
703-
# do, which accounts for this difference.
704-
IdentToken.new([[lineno, column], event, value, lex_state])
705-
else
706-
Token.new([[lineno, column], event, value, lex_state])
707-
end
708644
when :on_embexpr_end
709645
IgnoreStateToken.new([[lineno, column], event, value, lex_state])
710-
when :on_ignored_nl
711-
# Ignored newlines can occasionally have a LABEL state attached to
712-
# them which doesn't actually impact anything. We don't mirror that
713-
# state so we ignored it.
714-
IgnoredNewlineToken.new([[lineno, column], event, value, lex_state])
715646
when :on_regexp_end
716647
# On regex end, Ripper scans and then sets end state, so the ripper
717648
# lexed output is begin, when it should be end. prism sets lex state

0 commit comments

Comments
 (0)