Class Citrus::MemoizedInput

  1. lib/citrus.rb
Parent: Citrus::Input

A MemoizedInput is an Input that caches segments of the event stream for particular rules in a parse. This technique (also known as “Packrat” parsing) guarantees parsers will operate in linear time but costs significantly more in terms of time and memory required to perform a parse. For more information, please read the paper on Packrat parsing at pdos.csail.mit.edu/~baford/packrat/icfp02/.

Methods

public class

  1. new

public instance

  1. memoized?

Attributes

cache [R] A nested hash of rules to offsets and their respective matches.
cache_hits [R] The number of times the cache was hit.

Public class methods

new (string)
[show source]
     # File lib/citrus.rb, line 299
299:     def initialize(string)
300:       super(string)
301:       @cache = {}
302:       @cache_hits = 0
303:     end

Public instance methods

memoized? ()

Returns true when using memoization to cache match results.

[show source]
     # File lib/citrus.rb, line 318
318:     def memoized?
319:       true
320:     end