class SyntaxTree::Parser::TokenList

This represents all of the tokens coming back from the lexer. It is replacing a simple array because it keeps track of the last deleted token from the list for better error messages.

Attributes

last_deleted[R]
tokens[R]

Public Class Methods

new() click to toggle source
# File lib/syntax_tree/parser.rb, line 66
def initialize
  @tokens = []
  @last_deleted = nil
end

Public Instance Methods

<<(token) click to toggle source
# File lib/syntax_tree/parser.rb, line 71
def <<(token)
  tokens << token
end
[](index) click to toggle source
# File lib/syntax_tree/parser.rb, line 75
def [](index)
  tokens[index]
end
any?(&block) click to toggle source
# File lib/syntax_tree/parser.rb, line 79
def any?(&block)
  tokens.any?(&block)
end
delete(value) click to toggle source
# File lib/syntax_tree/parser.rb, line 91
def delete(value)
  @last_deleted = tokens.delete(value) || @last_deleted
end
delete_at(index) click to toggle source
# File lib/syntax_tree/parser.rb, line 95
def delete_at(index)
  @last_deleted = tokens.delete_at(index)
end
reverse_each(&block) click to toggle source
# File lib/syntax_tree/parser.rb, line 83
def reverse_each(&block)
  tokens.reverse_each(&block)
end
rindex(&block) click to toggle source
# File lib/syntax_tree/parser.rb, line 87
def rindex(&block)
  tokens.rindex(&block)
end