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

Module combine

source code

Matchers that combine sub-matchers (And, Or etc).
Classes [hide private]
  BaseSearch
Common base class (used by smart separators).
  _BaseCombiner
Support for And and Or.
Functions [hide private]
 
search_factory(factory)
Add the arg processing common to all searching.
source code
 
DepthFirst(first, start, stop, rest, generator_manager_queue_len)
(Post order) Depth first repetition (typically used via Repeat).
source code
 
BreadthFirst(first, start, stop, rest, generator_manager_queue_len)
(Level order) Breadth first repetition (typically used via Repeat).
source code
 
OrderByResultCount(matcher, ascending=True)
Modify a matcher to return results in length order.
source code
 
DepthNoTrampoline(first, start, stop, rest, generator_manager_queue_len)
A more efficient search when all matchers are functions (so no need to trampoline).
source code
 
BreadthNoTrampoline(first, start, stop, rest, generator_manager_queue_len)
A more efficient search when all matchers are functions (so no need to trampoline).
source code
 
And(*matchers)
Match one or more matchers in sequence (&).
source code
 
AndNoTrampoline(*matchers)
Used as an optimisation when sub-matchers do not require the trampoline.
source code
 
Or(*matchers)
Match one of the given matchers (|).
source code
 
OrNoTrampoline(*matchers)
Used as an optimisation when sub-matchers do not require the trampoline.
source code
 
First(*matchers)
Match the first successful matcher only (%).
source code
 
Difference(matcher, exclude, count=-1)
Match with matcher, but exclude any matches that would be made by exclude.
source code
 
Limit(match, count=1)
Limit the backtracking for a given matcher.
source code
Variables [hide private]
  _BaseSearch = ABCMeta('_BaseSearch', (object,), {})
ABC used to identify matchers.
Function Details [hide private]

DepthFirst(first, start, stop, rest, generator_manager_queue_len)

source code 
(Post order) Depth first repetition (typically used via Repeat).
Decorators:
  • @trampoline_matcher_factory(first= to(Literal), rest= to(Literal))
  • @search_factory

BreadthFirst(first, start, stop, rest, generator_manager_queue_len)

source code 
(Level order) Breadth first repetition (typically used via Repeat).
Decorators:
  • @trampoline_matcher_factory(first= to(Literal), rest= to(Literal))
  • @search_factory

OrderByResultCount(matcher, ascending=True)

source code 
Modify a matcher to return results in length order.
Decorators:
  • @trampoline_matcher_factory(matcher= to(Literal))

DepthNoTrampoline(first, start, stop, rest, generator_manager_queue_len)

source code 
A more efficient search when all matchers are functions (so no need to trampoline). Depth first (greedy).
Decorators:
  • @sequence_matcher_factory(first= to(Literal), rest= to(Literal))
  • @search_factory

BreadthNoTrampoline(first, start, stop, rest, generator_manager_queue_len)

source code 
A more efficient search when all matchers are functions (so no need to trampoline). Breadth first (non-greedy).
Decorators:
  • @sequence_matcher_factory(first= to(Literal), rest= to(Literal))
  • @search_factory

And(*matchers)

source code 
Match one or more matchers in sequence (&). It can be used indirectly by placing & between matchers.
Decorators:
  • @trampoline_matcher_factory(args_= to(Literal))

AndNoTrampoline(*matchers)

source code 
Used as an optimisation when sub-matchers do not require the trampoline.
Decorators:
  • @sequence_matcher_factory(args_= to(Literal))

Or(*matchers)

source code 

Match one of the given matchers (|). It can be used indirectly by placing | between matchers.

Matchers are tried from left to right until one succeeds; backtracking will try more from the same matcher and, once that is exhausted, continue to the right. String arguments will be coerced to literal matches.

Decorators:
  • @trampoline_matcher_factory(args_= to(Literal))

OrNoTrampoline(*matchers)

source code 
Used as an optimisation when sub-matchers do not require the trampoline.
Decorators:
  • @sequence_matcher_factory(args_= to(Literal))

First(*matchers)

source code 

Match the first successful matcher only (%). It can be used indirectly by placing % between matchers. Note that backtracking for the first-selected matcher will still occur.

Matchers are tried from left to right until one succeeds; backtracking will try more from the same matcher (only). String arguments will be coerced to literal matches.

Decorators:
  • @trampoline_matcher_factory()

Difference(matcher, exclude, count=-1)

source code 
Match with matcher, but exclude any matches that would be made by exclude. This is implemented by comparing the remaining stream after matching, so will not be affected by any transform associated with exclude. The count parameter gives the number of different matches from exclude. By default (-1) all matches are used. A positive value restricts that to the number given.
Decorators:
  • @trampoline_matcher_factory(args_= to(Literal))

Limit(match, count=1)

source code 
Limit the backtracking for a given matcher. A negative count means no limit.
Decorators:
  • @trampoline_matcher_factory(args_= to(Literal))

Variables Details [hide private]

_BaseSearch

ABC used to identify matchers.

Note that graph traversal assumes subclasses are hashable and iterable.

Value:
ABCMeta('_BaseSearch', (object,), {})