Class: MiniRuby::AST::InvalidNode
- Inherits:
-
ExpressionNode
- Object
- Node
- ExpressionNode
- MiniRuby::AST::InvalidNode
- Defined in:
- lib/miniruby/ast.rb
Overview
Represents an invalid node
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
: Token.
Attributes inherited from Node
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (Object other) -> bool.
-
#initialize(token:, span: Span::ZERO) ⇒ InvalidNode
constructor
: (token: Token, ?span: Span) -> void.
-
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String.
-
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String.
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
#token ⇒ Object (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 |