@@ -208,18 +208,9 @@ def ==(other)
208
208
end
209
209
end
210
210
211
- # It is extremely non obvious which state the parser is in when comments get
212
- # dispatched. Because of this we don't both comparing state when comparing
213
- # against other comment tokens.
214
- class CommentToken < Token
215
- def ==( other )
216
- self [ 0 ...-1 ] == other [ 0 ...-1 ]
217
- end
218
- end
219
-
220
- # Heredoc end tokens are emitted in an odd order, so we don't compare the
221
- # state on them.
222
- class HeredocEndToken < Token
211
+ # Tokens where state should be ignored
212
+ # used for :on_comment, :on_heredoc_end, :on_embexpr_end
213
+ class IgnoreStateToken < Token
223
214
def ==( other )
224
215
self [ 0 ...-1 ] == other [ 0 ...-1 ]
225
216
end
@@ -619,12 +610,12 @@ def result
619
610
when :on___end__
620
611
EndContentToken . new ( [ [ lineno , column ] , event , value , lex_state ] )
621
612
when :on_comment
622
- CommentToken . new ( [ [ lineno , column ] , event , value , lex_state ] )
613
+ IgnoreStateToken . new ( [ [ lineno , column ] , event , value , lex_state ] )
623
614
when :on_heredoc_end
624
615
# Heredoc end tokens can be emitted in an odd order, so we don't
625
616
# want to bother comparing the state on them.
626
- HeredocEndToken . new ( [ [ lineno , column ] , event , value , lex_state ] )
627
- when :on_embexpr_end , : on_ident
617
+ IgnoreStateToken . new ( [ [ lineno , column ] , event , value , lex_state ] )
618
+ when :on_ident
628
619
if lex_state == Ripper ::EXPR_END
629
620
# If we have an identifier that follows a method name like:
630
621
#
@@ -644,6 +635,8 @@ def result
644
635
else
645
636
Token . new ( [ [ lineno , column ] , event , value , lex_state ] )
646
637
end
638
+ when :on_embexpr_end
639
+ IgnoreStateToken . new ( [ [ lineno , column ] , event , value , lex_state ] )
647
640
when :on_ignored_nl
648
641
# Ignored newlines can occasionally have a LABEL state attached to
649
642
# them which doesn't actually impact anything. We don't mirror that
0 commit comments