class documentation

class Lexer: (source)

Constructor: Lexer(source)

View In Hierarchy

Tokenizer for the field mask grammar.

Parameters
sourceMask string to tokenize.
Method __init__ Undocumented
Method __iter__ Yield tokens until end-of-input.
Method consume Advance the lexer position by the length of prefix.
Method next_token Scan and return the next token.
Method scan_plain_key Scan a plain (unquoted) key token.
Method scan_quoted_key Scan a quoted key token.
Method starts_with Return True if the remaining input starts with prefix.
Instance Variable pos Current cursor position.
Instance Variable source Input string being tokenized.
def __init__(self, source: str): (source)

Undocumented

def __iter__(self) -> Generator[Token, None, None]: (source)

Yield tokens until end-of-input.

def consume(self, prefix: str): (source)

Advance the lexer position by the length of prefix.

Parameters
prefix:strString to consume.
def next_token(self) -> Token: (source)

Scan and return the next token.

Returns
TokenNext Token instance.
Raises
ContextedParseErrorIf an unexpected character is found.
def scan_plain_key(self) -> Token: (source)

Scan a plain (unquoted) key token.

def scan_quoted_key(self) -> Token: (source)

Scan a quoted key token.

def starts_with(self, prefix: str) -> bool: (source)

Return True if the remaining input starts with prefix.

Parameters
prefix:strPrefix to check.
Returns
boolTrue when the remaining input starts with prefix.

Current cursor position.

Input string being tokenized.