Class: Language::Atom::Absent

Inherits:
Language::Atom show all
Defined in:
lib/language/atom.rb

Instance Method Summary collapse

Methods inherited from Language::Atom

#<<, #>>, #absent, #aka, #any, #ignore, #inspect, #maybe, #repeat, #str, #then, #|

Constructor Details

#initialize(parent: nil) ⇒ Absent

Returns a new instance of Absent.



102
103
104
# File 'lib/language/atom.rb', line 102

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

Instance Method Details

#parse(parser) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/language/atom.rb', line 106

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_sObject



120
121
122
# File 'lib/language/atom.rb', line 120

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