Skip to content

Commit b6a2f91

Browse files
committed
Update docs
1 parent f4810bc commit b6a2f91

3 files changed

Lines changed: 25 additions & 27 deletions

File tree

tivars/tokenizer/decoder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def parse(bytestream: bytes, *, tokens: TITokens = None) -> list[TIToken]:
1616
Parses a byte stream into a list of `TIToken` objects
1717
1818
Each token is represented using one of three different representations formats, dictated by ``mode``:
19-
- ``display``: Represents the tokens with Unicode characters matching the calculator's display
20-
- ``accessible``: Represents the tokens with ASCII-only equivalents, often requiring multi-character glyphs
21-
- ``ti_ascii``: Represents the tokens with their internal font indices (returns a ``bytes`` object)
19+
- ``display``: Represents the tokens with Unicode characters matching the calculator's display
20+
- ``accessible``: Represents the tokens with ASCII-only equivalents, often requiring multi-character glyphs
21+
- ``ti_ascii``: Represents the tokens with their internal font indices (returns a ``bytes`` object)
2222
2323
:param bytestream: The token bytes to parse
2424
:param tokens: The `TITokens` object to use for decoding (defaults to the TI-84+CE tokens)

tivars/tokenizer/encoder.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,34 @@ def normalize(string: str):
3131

3232

3333
def tokenize(string: str, *, trie: TITokenTrie = None, mode: str = None, normalize: bool = True) -> list[TIToken]:
34-
r"""
34+
"""
3535
Tokenizes a string of tokens represented as text into a list of `TIToken` objects
3636
3737
Tokenization is performed using one of three procedures, dictated by ``mode``:
38-
- ``max``: Always munch maximally, i.e. consume the most input possible to produce a token
39-
- ``min``: Always munch minimally, i.e. consume the least input possible, which is often single characters
40-
- ``smart``: Munch maximally or minimally depending on context
38+
- ``max``: Always munch maximally, i.e. consume the most input possible to produce a token
39+
- ``min``: Always munch minimally, i.e. consume the least input possible, which is often single characters
40+
- ``smart``: Munch maximally or minimally depending on context
4141
4242
The ``smart`` tokenization mode uses the following contexts, munching maximally otherwise:
43-
- Strings: munch minimally, except when interpolating using ``Send(`` or storing to an equation
44-
- Program names: munch minimally up to 8 tokens
45-
- List names: munch minimally up to 5 tokens
43+
- Strings: munch minimally, except when interpolating using ``Send(`` or storing to an equation
44+
- Program names: munch minimally up to 8 tokens
45+
- List names: munch minimally up to 5 tokens
4646
4747
In all modes:
48-
- Standard glyphs can be used for substituting Unicode symbols
49-
- `\xXX` and `\uUUUU` output the denoted bytes exactly, regardless of validity
50-
- `\ABCD` maximally munches `ABCD`, regardless of surrounding context
51-
- Certain unprintable characters act as a hard separator for tokens
52-
- U+001F (unit separator): `␟`
53-
- U+200A (hair space): ` `
54-
- U+200C (zero width non-joiner): `‌`
48+
- Standard glyphs can be used for substituting Unicode symbols
49+
- `\\xXX` and `\\uUUUU` output the denoted bytes exactly, regardless of validity
50+
- `\\ABCD` maximally munches `ABCD`, regardless of surrounding context
51+
- Certain unprintable characters act as a hard separator for tokens
52+
- U+001F (unit separator): `␟`
53+
- U+200A (hair space): ` `
54+
- U+200C (zero width non-joiner): `‌`
5555
5656
For reference, here are the tokenization modes utilized by popular IDEs and other software:
57-
- SourceCoder: ``max``
58-
- TokenIDE: ``max``
59-
- TI Connect CE: ¯\_(ツ)_/¯
60-
- TI-Planet Project Builder: ``smart``
61-
- tivars_lib_cpp: ``smart``
57+
- SourceCoder: ``max``
58+
- TokenIDE: ``max``
59+
- TI Connect CE: ¯\\_(ツ)_/¯
60+
- TI-Planet Project Builder: ``smart``
61+
- tivars_lib_cpp: ``smart``
6262
6363
:param string: The text string to encode
6464
:param trie: The `TokenTrie` object to use for tokenization (defaults to the TI-84+CE trie)

tivars/tokenizer/state.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,14 @@ def next(self, token: TIToken, remainder: str) -> list[list['TokenizerState']]:
8686
"""
8787
Determines the next tokenizer timelines given a token
8888
89-
The current state is popped from the stack, and the states returned by this method are pushed.
90-
9189
1. The current state is popped from the stack.
9290
2. All possible timelines are determined, each a list of states.
9391
3. For each separate timeline, those states are added its stack.
9492
9593
If a list of states in a timeline is...
96-
- empty, then the timeline is exiting the current state.
97-
- length one, then the timeline's current state is being replaced by a new state.
98-
- length two, then the timeline is entering a new state, able to exit back to this one.
94+
- empty, then the timeline is exiting the current state.
95+
- length one, then the timeline's current state is being replaced by a new state.
96+
- length two, then the timeline is entering a new state, able to exit back to this one.
9997
10098
:param token: The current token
10199
:param remainder: The remaining string content to tokenize

0 commit comments

Comments
 (0)