module documentation

Token stream decoder

Function decode Decodes a byte stream into a string of tokens
Function detokenize Stringifies a sequence of TIToken objects given a language and token representation type
Function parse Parses a byte stream into a list of TIToken objects
def decode(data: bytes, *, model: TIModel = TI_84PCE, lang: str = None, mode: str = None) -> str: (source)

Decodes a byte stream into a string of tokens

Parameters
data:bytesThe token bytes to decode
model:TIModelA model for which compatibility is ensured (defaults to the TI-84+CE)
lang:strThe language used in string (defaults to the locale of model, or English, en)
mode:strThe token representation to use for output (defaults to display)
Returns
strA string representing the tokens in data
def detokenize(tokens: Sequence[TIToken], *, model: TIModel = TI_84PCE, lang: str = None, mode: str = None): (source)

Stringifies a sequence of TIToken objects given a language and token representation type

Parameters
tokens:Sequence[TIToken]The TIToken sequence to stringify
model:TIModelThe target model (defaults to the TI-84+CE)
lang:strThe target language (defaults to the locale of model, or English, en)
mode:strThe token representation to use for output (defaults to display)
Returns
A string representing tokens
def parse(bytestream: bytes, *, tokens: TITokens = None) -> list[TIToken]: (source)

Parses a byte stream into a list of TIToken objects

Each token is represented using one of three different representations formats, dictated by mode:
  • display: Represents the tokens with Unicode characters matching the calculator's display
  • accessible: Represents the tokens with ASCII-only equivalents, often requiring multi-character glyphs
  • ti_ascii: Represents the tokens with their internal font indices (returns a bytes object)
Parameters
bytestream:bytesThe token bytes to parse
tokens:TITokensThe TITokens object to use for decoding (defaults to the TI-84+CE tokens)
Returns
list[TIToken]A list of TIToken objects assembled from bytestream