Class: Foxtail::Syntax::Parser::AST::BaseLiteral

Inherits:
SyntaxNode show all
Defined in:
lib/foxtail/syntax/parser/ast/base_literal.rb

Overview

Base class for literal values (strings and numbers) with parsing capability

Direct Known Subclasses

NumberLiteral, StringLiteral

Instance Attribute Summary collapse

Attributes inherited from SyntaxNode

#span

Attributes inherited from BaseNode

#type

Instance Method Summary collapse

Methods inherited from SyntaxNode

#add_span

Methods inherited from BaseNode

#==, #accept, #children, #to_h

Constructor Details

#initialize(value) ⇒ BaseLiteral

Returns a new instance of BaseLiteral.



11
12
13
14
15
16
# File 'lib/foxtail/syntax/parser/ast/base_literal.rb', line 11

def initialize(value)
  super()
  # The "value" field contains the exact contents of the literal,
  # character-for-character.
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/foxtail/syntax/parser/ast/base_literal.rb', line 9

def value
  @value
end

Instance Method Details

#parseObject

Abstract method - subclasses must implement

Raises:

  • (NotImplementedError)


19
# File 'lib/foxtail/syntax/parser/ast/base_literal.rb', line 19

def parse = raise NotImplementedError, "Subclasses must implement parse method"