Module

parsing.token_nav

Token navigation utilities for Patitas parser.

Provides mixin for token stream navigation and basic parsing operations.

Classes

TokenNavigationMixin 8
Mixin providing token stream navigation methods. Required Host Attributes: - _tokens: Sequence…

Mixin providing token stream navigation methods.

Required Host Attributes:

  • _tokens: Sequence[Token]
  • _pos: int
  • _current: Token | None

Attributes

Name Type Description
_tokens Sequence[Token]
_pos int
_current Token | None

Methods

Internal Methods 5
_at_end 0 bool
Check if at end of token stream.
def _at_end(self) -> bool
Returns
bool
_advance 0 Token | None
Advance to next token and return it.
def _advance(self) -> Token | None
Returns
Token | None
_peek 1 Token | None
Peek at token at offset from current position.
def _peek(self, offset: int = 1) -> Token | None
Parameters
Name Type Description
offset Default:1
Returns
Token | None
_get_line_at 1 str
Get the full line content containing the given source offset.
def _get_line_at(self, offset: int) -> str
Parameters
Name Type Description
offset
Returns
str
_strip_columns 2 str
Strip up to 'count' columns of whitespace/tabs from start of text.
def _strip_columns(self, text: str, count: int) -> str
Parameters
Name Type Description
text
count
Returns
str