Class: GhostWheel::Expression
- Inherits:
-
Object
- Object
- GhostWheel::Expression
- Defined in:
- lib/ghost_wheel/expression.rb,
lib/ghost_wheel/expression/rule.rb,
lib/ghost_wheel/expression/empty.rb,
lib/ghost_wheel/expression/query.rb,
lib/ghost_wheel/expression/literal.rb,
lib/ghost_wheel/expression/optional.rb,
lib/ghost_wheel/expression/sequence.rb,
lib/ghost_wheel/expression/transform.rb,
lib/ghost_wheel/expression/look_ahead.rb,
lib/ghost_wheel/expression/repetition.rb,
lib/ghost_wheel/expression/alternation.rb,
lib/ghost_wheel/expression/end_of_file.rb
Direct Known Subclasses
Alternation, Empty, EndOfFile, Literal, LookAhead, Optional, Query, Repetition, Rule, Sequence, Transform
Defined Under Namespace
Classes: Alternation, Empty, EndOfFile, Literal, LookAhead, Optional, Query, Repetition, Rule, Sequence, Transform
Instance Method Summary collapse
Instance Method Details
#==(other) ⇒ Object
18 19 20 |
# File 'lib/ghost_wheel/expression.rb', line 18 def ==(other) self.class == other.class end |
#parse(scanner, cache = Hash.new) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ghost_wheel/expression.rb', line 5 def parse(scanner, cache = Hash.new) cache_key = "#{object_id}:#{scanner.pos}" cache_hit = cache[cache_key] if cache_hit.nil? result = uncached_parse(scanner, cache) cache[cache_key] = [result, scanner.pos] result else scanner.pos = cache_hit.last cache_hit.first end end |