Class: Language::Atom::Maybe
Instance Method Summary
collapse
#<<, #>>, #absent, #aka, #any, #ignore, #inspect, #maybe, #repeat, #rule, #str, #then, #|
Constructor Details
#initialize(parent:) ⇒ Maybe
162
163
164
|
# File 'lib/language/atom.rb', line 162
def initialize(parent:)
@parent = parent
end
|
Instance Method Details
#parse(parser) ⇒ Object
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/language/atom.rb', line 166
def parse(parser)
clone =
Parser.new(
root: self,
input: parser.input,
cursor: parser.cursor,
buffer: parser.buffer
)
@parent.parse(clone)
rescue Parser::Interuption
else
parser.cursor = clone.cursor
parser.output = clone.output
end
|
#to_s ⇒ Object
182
183
184
|
# File 'lib/language/atom.rb', line 182
def to_s
@parent ? "#{@parent}.maybe" : "maybe"
end
|