Class: MarshalParser::Parser::SymbolNode

Inherits:
Node
  • Object
show all
Includes:
Annotatable
Defined in:
lib/marshal-parser/parser.rb

Instance Method Summary collapse

Methods inherited from Node

#always_leaf?, #children, #decoded_value, #tokens

Methods included from Assertable

#assert

Constructor Details

#initialize(marker_token, length_token, content_token, link_to_symbol) ⇒ SymbolNode

Returns a new instance of SymbolNode.



391
392
393
394
395
396
397
398
399
400
401
# File 'lib/marshal-parser/parser.rb', line 391

def initialize(marker_token, length_token, content_token, link_to_symbol)
  super()
  assert_token_type marker_token, Lexer::SYMBOL_PREFIX
  assert_token_type length_token, Lexer::INTEGER
  assert_token_type content_token, Lexer::SYMBOL

  @marker_token = marker_token
  @length_token = length_token
  @content_token = content_token
  @link_to_symbol = link_to_symbol # just Integer, index in the Symbols table
end

Instance Method Details

#annotationObject



407
408
409
# File 'lib/marshal-parser/parser.rb', line 407

def annotation
  "symbol ##{@link_to_symbol}"
end

#attributesObject



415
416
417
418
419
420
# File 'lib/marshal-parser/parser.rb', line 415

def attributes
  {
    @length_token => { name: :length, value: @length_token.value },
    @content_token => { name: :content, value: @content_token }
  }
end

#child_entitiesObject



403
404
405
# File 'lib/marshal-parser/parser.rb', line 403

def child_entities
  [@marker_token, @length_token, @content_token]
end

#literal_tokenObject



411
412
413
# File 'lib/marshal-parser/parser.rb', line 411

def literal_token
  @content_token
end