lex2.matcher
Components of matcher implementations.
Classes
Abstract base class partially implementing IMatcher. |
|
Implementation of IMatcher using Python's builtin re module. |
- class lex2.matcher.BaseMatcher
Bases:
IMatcher
,ABC
Abstract base class partially implementing IMatcher.
- abstract __init__()
- get_uid()
Gets the unique identifier (UID) of the matcher implementation.
- Return type
str
- class lex2.matcher.ReMatcher
Bases:
BaseMatcher
Implementation of IMatcher using Python’s builtin re module.
- __init__()
- compile_pattern(regex)
Compiles regex pattern to implementation-specific regex matcher object.
- Parameters
regex (str) – Regular expression to compile.
- match(ts, token)
Looks for a pattern match and sets it in the provided token object.
- Parameters
ts (ITextstream) – Textstream object managed by the lexer object.
token (Token) – Used to set the match data in the token.
- Returns
True in case of a match.
- Return type
bool