Registry / serialization / tatsu
library5.24.0pypypi✓ verified 22d ago

TatSu is a Python library that takes a grammar defined in a variation of EBNF (Extended Backus–Naur Form) and generates a memoizing PEG (Parsing Expression Grammar) / Packrat parser. It is actively maintained with frequent minor releases, providing a powerful tool for creating custom parsers and Abstract Syntax Trees (ASTs). The current version is 5.18.0.

pip install TatSu
INSTALL
IMPORT
SIG · TATSU
T
tatsu
serializationpythonv5.24.0
Install
1.7s avg
Import
596ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.15.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.572s · 18.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.620s · 19MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
from tatsu import compile
from tatsu import compile

This quickstart defines a simple calculator grammar and uses `tatsu.parse` to directly parse an input string, producing an Abstract Syntax Tree (AST). For complex parsing logic or evaluation, a custom 'semantics' class is typically passed to the parse function.

from tatsu import parse grammar = r''' @@grammar::Calc start: expression $ ; expression: term (('+' | '-') term)* ; term: factor (('*' | '/') factor)* ; factor: NUMBER | '(' expression ')' ; NUMBER: /\d+/ ; ''' input_text = '1 + 2 * (3 - 4)' try: # Parse the input using the grammar ast = parse(grammar, input_text) print(f'Input: {input_text}') print(f'AST: {ast}') # Example with a simple calculation (requires a semantics class for evaluation) # For a full calculation example, typically a semantics class is used. # For this quickstart, we just show the parsing to AST. except Exception as e: print(f'Error parsing: {e}')
tatsu --version
Debug
Known issues
breakingPython 3.10 and 3.11 are no longer officially supported as of v5.16.0. TatSu now requires Python >= 3.12. The GitHub README indicates a preference for Python >= 3.13.
fix
Upgrade to Python 3.12 or newer. For older Python versions, consider using the `TatSu-LTS` fork.
affects: >=5.16.0
breakingThe `comments_re` and `eol_comments_re` attributes were removed from `ParserConfig` in v5.13.0. Use `comments` and `eol_comments` instead. Additionally, `re.MULTILINE` is no longer enabled by default for comment regexes; users must explicitly add `(?m)` if multi-line matching is needed.
fix
Update `ParserConfig` (or grammar directives `@@comments` / `@@eol_comments`) to use `comments` and `eol_comments`. If multi-line matching is required, prepend `(?m)` to your regex pattern (e.g., `comments='(?m)/\*.*?\*/'`).
affects: >=5.13.0
breakingThe `FailedCut` exception and its associated logic were removed in v5.15.0. Code that explicitly catches or relies on this exception will break.
fix
Remove any `try...except FailedCut` blocks. Review parsing logic that might have implicitly relied on `FailedCut` for control flow.
affects: >=5.15.0
breakingGenerated parsers from older TatSu versions (prior to v5.16.0, and especially prior to v5.0) may not be compatible with newer TatSu runtime libraries. Significant internal refactoring, particularly around `ParserConfig` and AST generation, occurred in recent major versions (e.g., v5.17.0).
fix
It is strongly recommended to regenerate any existing parsers using the latest TatSu version to benefit from improved speed, layout, features, and ensure compatibility.
affects: >=5.0.0, >=5.16.0
gotchaRules and closures now return `list` objects instead of `tuple` objects in the generated AST. This changes the structural representation of the AST for rules that produce sequences or repetitions.
fix
Adjust code that processes the AST to expect `list` instances where `tuple` was previously returned, for example, when iterating over children or checking types.
affects: >=5.17.0 (implied by major refactoring)
Upgrade
Version history
5.24.0latest on PyPI · released Jul 9, 2026
Audit
Dependencies
PythonrequiredTatSu requires Python 3.12 or newer. For older Python versions, consider 'TatSu-LTS'.
Agent activity
9 hits · last 30 days
node
6
OpenAI (training)
1
Resources
tatsu — pip install tatsu · libregistry