Class: Pegarus::Choice
- Defined in:
- lib/pegarus/ast/choice.rb,
lib/pegarus/rubinius/compiler.rb
Instance Attribute Summary
Attributes inherited from BinaryOp
Instance Method Summary collapse
Methods inherited from BinaryOp
Methods inherited from Pattern
#*, #+, #+@, #-, #-@, #/, engine, #graph, #match, select_engine
Constructor Details
This class inherits a constructor from Pegarus::BinaryOp
Instance Method Details
#bytecode(g) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/pegarus/rubinius/compiler.rb', line 151 def bytecode(g) g.push_index # store index, so that we can restart old_fail = g.fail done = g.new_label choice_fail = g.new_label g.fail = choice_fail @first.bytecode(g) g.pop # success, pop index g.fail = old_fail # reset fail g.goto done choice_fail.set! g.fail = old_fail g.set_index # reset index to the stored index, this pops the value @second.bytecode(g) done.set! end |
#visit(visitor) ⇒ Object
3 4 5 |
# File 'lib/pegarus/ast/choice.rb', line 3 def visit(visitor) visitor.choice self end |