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, #rule, #str, #then, #|

Constructor Details

#initialize(parent: nil) ⇒ Absent

Returns a new instance of Absent.



116
117
118
# File 'lib/language/atom.rb', line 116

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

Instance Method Details

#parse(parser) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/language/atom.rb', line 120

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

#to_sObject



134
135
136
# File 'lib/language/atom.rb', line 134

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