tokens¶
Utilities for working with tokens.
- class macro_polo.tokens.Delimiter(open_type, open_string, close_type, close_string)[source]¶
Represents a delimiter which must be kept balanced.
- close_string: str | None¶
String representation of the closing token.
If
None, onlyclose_typeis checked.
- macro_polo.tokens.desimplify(tokens, *, indent=' ')[source]¶
Revert simplifications made by
lex()and fix indentation.Only reverts simplifications that change semantics.
- macro_polo.tokens.lex(source)[source]¶
Create a simplified token stream from source code.
Some simplifications are applied to make matching easier: