Class: Language::Atom::Absent

Inherits:
Atom
  • Object
show all
Defined in:
lib/language/atom/absent.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent: nil) ⇒ Absent

Returns a new instance of Absent.



6
7
8
# File 'lib/language/atom/absent.rb', line 6

def initialize(parent: nil)
  @parent = parent
end

Instance Method Details

#parse(parser) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/language/atom/absent.rb', line 10

def parse(parser)
  clone =
    Parser.new(
      root: self,
      input: parser.input,
      cursor: parser.cursor,
      buffer: parser.buffer
    )
  @parent&.parse(clone)
rescue Parser::Interuption
else
  raise Parser::Interuption.new(parser, self)
end

#to_s ⇒ Object



24
25
26
# File 'lib/language/atom/absent.rb', line 24

def to_s
  @parent ? "(#{@parent}).absent" : "absent"
end