Source code for pyregexp.tokens
import string
from typing import Literal
[docs]class ElementToken(Token):
""" Token that are not associated to special meaning."""
def __init__(self, char: str):
super().__init__()
self.char: str = char
[docs]class WildcardToken(Token):
""" Token of a wildcard."""
def __init__(self, char: str):
super().__init__()
self.char: str = char
[docs]class SpaceToken(Token):
""" Token of a space."""
def __init__(self, char: str) -> None:
super().__init__()
self.char: str = string.whitespace
[docs]class Wildcard(WildcardToken):
""" Token using '.' as wildcard."""
def __init__(self):
super().__init__(char='.')
[docs]class StartToken(Token):
""" Token of match start."""
def __init__(self, char: str):
super().__init__()
self.char: str = char
[docs]class Start(StartToken):
""" Token using '^' to match start."""
def __init__(self):
super().__init__(char='^')
[docs]class EndToken(Token):
""" Token of match end."""
def __init__(self, char: str):
super().__init__()
self.char: str = char
[docs]class End(EndToken):
""" Token using '$' to match end."""
def __init__(self):
super().__init__(char='$')
[docs]class Escape(Token):
""" Token of the escape character."""
def __init__(self):
super().__init__()
self.char = '\\'
[docs]class Comma(Token):
""" Token of a comma."""
def __init__(self):
super().__init__()
self.char = ','
[docs]class Parenthesis(Token):
""" Token of a parenthesis."""
def __init__(self):
super().__init__()
[docs]class LeftParenthesis(Parenthesis):
""" Left parenthesis token."""
def __init__(self):
super().__init__()
self.char = '('
[docs]class RightParenthesis(Parenthesis):
""" Right parenthesis token."""
def __init__(self):
super().__init__()
self.char = ')'
[docs]class LeftCurlyBrace(CurlyBrace):
""" Left curly brace token."""
def __init__(self):
super().__init__()
self.char = '{'
[docs]class RightCurlyBrace(CurlyBrace):
""" Right curly brace token."""
def __init__(self):
super().__init__()
self.char = '}'
[docs]class LeftBracket(Bracket):
""" Left bracke token."""
def __init__(self):
super().__init__()
self.char = '['
[docs]class RightBracket(Bracket):
""" Right bracket token."""
def __init__(self):
super().__init__()
self.char = ']'
[docs]class Quantifier(Token):
""" Quantifier token."""
def __init__(self, char: str):
super().__init__()
self.char: str = char
[docs]class ZeroOrMore(Quantifier):
""" Quantifier 'zero or more' token."""
def __init__(self, char: str):
super().__init__(char=char)
[docs]class OneOrMore(Quantifier):
""" Quantifier 'one or more' token."""
def __init__(self, char: str):
super().__init__(char=char)
[docs]class ZeroOrOne(Quantifier):
""" Quantifier 'zero or one' token."""
def __init__(self, char: str):
super().__init__(char=char)
[docs]class Asterisk(ZeroOrMore):
""" Quantifier 'zero or more' token using character '*'."""
def __init__(self):
super().__init__(char='*')
[docs]class Plus(OneOrMore):
""" Quantifier 'one or more' token using character '+'."""
def __init__(self):
super().__init__(char='+')
[docs]class QuestionMark(ZeroOrOne):
""" Quantifier 'zero or one' token using character '?'."""
def __init__(self):
super().__init__(char='?')
[docs]class OrToken(Token):
""" Token of the or."""
def __init__(self, char: str):
super().__init__()
self.char: str = char
[docs]class VerticalBar(OrToken):
""" Token of the or using '|'."""
def __init__(self):
super().__init__(char='|')
[docs]class NotToken(Token):
""" Token of the negation."""
def __init__(self, char: str):
super().__init__()
self.char: str = char
[docs]class Circumflex(NotToken):
""" Token of the negation using '^'."""
def __init__(self):
super().__init__(char='^')
[docs]class Dash(Token):
""" Token of the dash '-'."""
def __init__(self):
super().__init__()
self.char = '-'