Class: SyntaxTree::Parser::TokenList

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/syntax_tree/parser.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ TokenList

Returns a new instance of TokenList.



66
67
68
69
# File 'lib/syntax_tree/parser.rb', line 66

def initialize(object)
  super
  @last_deleted = nil
end

Instance Attribute Details

#last_deletedObject (readonly)

Returns the value of attribute last_deleted.



64
65
66
# File 'lib/syntax_tree/parser.rb', line 64

def last_deleted
  @last_deleted
end

Instance Method Details

#delete(value) ⇒ Object



71
72
73
# File 'lib/syntax_tree/parser.rb', line 71

def delete(value)
  @last_deleted = super || @last_deleted
end

#delete_at(index) ⇒ Object



75
76
77
# File 'lib/syntax_tree/parser.rb', line 75

def delete_at(index)
  @last_deleted = super
end