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

Module core

source code

Matchers that embody fundamental, common actions.
Classes [hide private]
  Lookahead
Tests to see if the embedded matcher could match, but does not do the matching.
  Delayed
A placeholder that allows forward references (+=).
Functions [hide private]
 
Never(support, stream)
Always fails to match.
source code
 
Any(restrict=None)
Create a matcher for a single character.
source code
 
Literal(text)
Match a series of tokens in the stream ('').
source code
 
Empty(support, stream)
Match any stream, consumes no input, and returns nothing.
source code
 
Regexp(pattern)
Match a regular expression.
source code
 
Eof(support, stream)
Match the end of a stream.
source code
 
Consumer(matcher, consume=True)
Only accept the match if it consumes data from the input
source code
Function Details [hide private]

Never(support, stream)

source code 

Always fails to match.

(in this package rather than lepl.matchers.memo to simplify import dependencies)

Decorators:
  • @sequence_matcher

Any(restrict=None)

source code 
Create a matcher for a single character.
Parameters:
  • restrict, (optional) - A list of tokens (or a string of suitable characters). If omitted any single token is accepted.

    Note: This argument is not a sub-matcher.

Decorators:
  • @function_matcher_factory()

Literal(text)

source code 

Match a series of tokens in the stream ('').

Typically the argument is a string but a list might be appropriate with some streams.

Decorators:
  • @function_matcher_factory()

Empty(support, stream)

source code 
Match any stream, consumes no input, and returns nothing.
Decorators:
  • @function_matcher

Regexp(pattern)

source code 

Match a regular expression. If groups are defined, they are returned as results. Otherwise, the entire expression is returned.

If the pattern contains groups, they are returned as separate results, otherwise the whole match is returned.

Parameters:
  • pattern - The regular expression to match.
Decorators:
  • @function_matcher_factory()

Eof(support, stream)

source code 

Match the end of a stream. Returns nothing.

This is also aliased to Eos in lepl.derived.

Decorators:
  • @function_matcher

Consumer(matcher, consume=True)

source code 
Only accept the match if it consumes data from the input
Decorators:
  • @trampoline_matcher_factory(matcher= to(Literal))