Package lepl :: Package support :: Module state
[hide private]
[frames] | no frames]

Module state

source code

Encapsulate global (per thread) state.

This is for state that can affect the current parse. It's probably simplest to explain an example of what it can be used for. Memoization records results for a particular state to avoid repeating matches needlessly. The state used to identify when "the same thing is happening" is based on: - the matcher being called - the stream passed to the matcher - this state

So a good shorthand for deciding whether or not this state should be used is to ask whether the state will affect whether or not memoisation will work correctly.

For example, with offside parsing, the current indentation level should be stored here, because a (matcher, stream) combination that has previously failed may work correctly when it changes.

Classes [hide private]
A thread local map from key (typically calling class) to value.