Class: MiniRuby::AST::InvalidNode

Inherits:
ExpressionNode show all
Defined in:
lib/miniruby/ast.rb

Overview

Represents an invalid node

Instance Attribute Summary collapse

Attributes inherited from Node

#span

Instance Method Summary collapse

Constructor Details

#initialize(token:, span: Span::ZERO) ⇒ InvalidNode

: (token: Token, ?span: Span) -> void



137
138
139
140
# File 'lib/miniruby/ast.rb', line 137

def initialize(token:, span: Span::ZERO)
  @span = span
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

: Token



134
135
136
# File 'lib/miniruby/ast.rb', line 134

def token
  @token
end

Instance Method Details

#==(other) ⇒ Object

: (Object other) -> bool



143
144
145
146
147
# File 'lib/miniruby/ast.rb', line 143

def ==(other)
  return false unless other.is_a?(InvalidNode)

  @token == other.token
end

#inspect(indent = 0) ⇒ Object

: (?Integer indent) -> String



157
158
159
# File 'lib/miniruby/ast.rb', line 157

def inspect(indent = 0)
  "#{INDENT_UNIT * indent}(invalid #{token.inspect})"
end

#to_s(indent = 0) ⇒ Object

: (?Integer indent) -> String



151
152
153
# File 'lib/miniruby/ast.rb', line 151

def to_s(indent = 0)
  "#{INDENT_UNIT * indent}<invalid: `#{token}`>"
end