Class: Parslet::Accelerator::Apply Private
- Inherits:
-
Object
- Object
- Parslet::Accelerator::Apply
- Defined in:
- lib/parslet/accelerator/engine.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(engine, expr) ⇒ Apply
constructor
private
A new instance of Apply.
- #match(type_tag) ⇒ Object private
- #visit_alternative(alternatives) ⇒ Object private
- #visit_entity(name, block) ⇒ Object private
- #visit_lookahead(positive, atom) ⇒ Object private
- #visit_named(name, atom) ⇒ Object private
- #visit_parser(root) ⇒ Object private
- #visit_re(regexp) ⇒ Object private
- #visit_repetition(tag, min, max, atom) ⇒ Object private
- #visit_sequence(sequence) ⇒ Object private
- #visit_str(str) ⇒ Object private
Constructor Details
#initialize(engine, expr) ⇒ Apply
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Apply.
7 8 9 10 |
# File 'lib/parslet/accelerator/engine.rb', line 7 def initialize(engine, expr) @engine = engine @expr = expr end |
Instance Method Details
#match(type_tag) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 70 71 72 |
# File 'lib/parslet/accelerator/engine.rb', line 67 def match(type_tag) expr_tag = @expr.type if expr_tag == type_tag yield *@expr.args end end |
#visit_alternative(alternatives) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 35 36 |
# File 'lib/parslet/accelerator/engine.rb', line 28 def visit_alternative(alternatives) match(:alt) do |*expressions| return false if alternatives.size != expressions.size alternatives.zip(expressions).all? do |atom, expr| @engine.match(atom, expr) end end end |
#visit_entity(name, block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/parslet/accelerator/engine.rb', line 15 def visit_entity(name, block) false end |
#visit_lookahead(positive, atom) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 53 |
# File 'lib/parslet/accelerator/engine.rb', line 46 def visit_lookahead(positive, atom) match(:absent) do |expr| return positive == false && @engine.match(atom, expr) end match(:present) do |expr| return positive == true && @engine.match(atom, expr) end end |
#visit_named(name, atom) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 |
# File 'lib/parslet/accelerator/engine.rb', line 18 def visit_named(name, atom) match(:as) do |key| @engine.try_bind(key, name) end end |
#visit_parser(root) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/parslet/accelerator/engine.rb', line 12 def visit_parser(root) false end |
#visit_re(regexp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 |
# File 'lib/parslet/accelerator/engine.rb', line 54 def visit_re(regexp) match(:re) do |*bind_conditions| bind_conditions.all? { |bind_cond| @engine.try_bind(bind_cond, regexp) } end end |
#visit_repetition(tag, min, max, atom) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 |
# File 'lib/parslet/accelerator/engine.rb', line 23 def visit_repetition(tag, min, max, atom) match(:rep) do |e_min, e_max, expr| e_min == min && e_max == max && @engine.match(atom, expr) end end |
#visit_sequence(sequence) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 44 45 |
# File 'lib/parslet/accelerator/engine.rb', line 37 def visit_sequence(sequence) match(:seq) do |*expressions| return false if sequence.size != expressions.size sequence.zip(expressions).all? do |atom, expr| @engine.match(atom, expr) end end end |
#visit_str(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 65 |
# File 'lib/parslet/accelerator/engine.rb', line 60 def visit_str(str) match(:str) do |*bind_conditions| bind_conditions.all? { |bind_cond| @engine.try_bind(bind_cond, str) } end end |