Class: MarshalParser::Parser::RegexpNode

Inherits:
Node
  • Object
show all
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(prefix, string_length, string, options) ⇒ RegexpNode

Returns a new instance of RegexpNode.



646
647
648
649
650
651
652
653
654
655
656
657
# File 'lib/marshal-parser/parser.rb', line 646

def initialize(prefix, string_length, string, options)
  super()
  assert_token_type prefix, Lexer::REGEXP_PREFIX
  assert_token_type string_length, Lexer::INTEGER
  assert_token_type string, Lexer::STRING
  assert_token_type options, Lexer::BYTE

  @prefix = prefix
  @string_length = string_length
  @string = string
  @options = options
end

Instance Method Details

#attributesObject



667
668
669
670
671
672
673
# File 'lib/marshal-parser/parser.rb', line 667

def attributes
  {
    @string_length => { name: :length, value: @string_length.value },
    @string => { name: :source_string, value: @string },
    @options => { name: :options, value: @options.value }
  }
end

#child_entitiesObject



659
660
661
# File 'lib/marshal-parser/parser.rb', line 659

def child_entities
  [@prefix, @string_length, @string, @options]
end

#literal_tokenObject



663
664
665
# File 'lib/marshal-parser/parser.rb', line 663

def literal_token
  @string
end