Package lepl :: Package matchers :: Module memo
[hide private]
[frames] | no frames]

Module memo

source code

Memoisation (both as described by Norvig 1991, giving Packrat parsers for non-left recursive grammars, and the equivalent described by Frost and Hafiz 2006 which allows left-recursive grammars to be used).

Note that neither paper describes the extension to backtracking with generators implemented here.

Classes [hide private]
  MemoException
Exception raised for problems with memoisation.
  _RMemo
A simple memoizer for grammars that do not have left recursion.
  RTable
Wrap a generator so that separate uses all call the same core generator, which is itself tabulated as it unrolls.
  _DummyMatcher
Fake matcher used to provide the appropriate interface to the generator wrapper from within RTable.
  _LMemo
A memoizer for grammars that do have left recursion.
  PerStreamCache
Manage the counter (one for each different stream) that limits the number of (left-)recursive calls.
  PerCallCache
The "final" cache for a matcher at a certain recursive depth and with a certain input stream.
Functions [hide private]
 
RMemo(matcher)
Wrap in the _RMemo cache if required.
source code
 
LMemo(matcher)
Wrap in the _LMemo cache if required.
source code
Variables [hide private]
  NoMemo = ABCMeta('NoMemo', (object,), {})
ABC used to indicate that memoisation should not be applied.