Method: Antlr4::Runtime::BufferedTokenStream#filter_for_channel

Defined in:
lib/antlr4/runtime/buffered_token_stream.rb

#filter_for_channel(from, to, channel) ⇒ Object



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/antlr4/runtime/buffered_token_stream.rb', line 269

def filter_for_channel(from, to, channel)
  hidden = []
  i = from
  while i <= to
    t = @tokens[i]
    if channel == -1
      hidden << t if t.channel != Lexer::DEFAULT_TOKEN_CHANNEL
    else
      hidden << t if t.channel == channel
    end
    i += 1
  end
  return nil if hidden.empty?

  hidden
end