Python validator for 3TL (Typed Talking To LLMs) format using the Lark parsing library.
- Full Unicode support
- Validates against the complete 3TL grammar
- Case-insensitive type names
- Detailed error messages with line and column numbers
- Optional parse tree visualization
pip install -r requirements.txtpython validator.py examples/products.3tlpython validator.py --string "#! Test
#@ id:uint, name:str
1, Alice
"python validator.py --show-tree file.3tlpython validator.py --grammar custom-grammar.lark file.3tl0: Valid 3TL format1: Invalid format or error
Valid:
$ python validator.py ../examples/blog.3tl
Valid 3TL formatInvalid:
$ python validator.py --string "#@ id:uint"
Invalid: Unexpected character at line 1, column 1
#@ id:uint
^
Expected: {'LINE_BREAK', '__ANON_0', 'COMMENT_START'}The validator uses the Lark EBNF grammar defined in ../3tl-grammar.lark. The grammar supports:
- Unicode identifiers (café, 名前, etc.)
- Case-insensitive type names (int, INT, Int all valid)
- Flexible array/nullable modifiers (int[]?, int?[])
- Comments anywhere in the file
- Multiple tables per file
- Foreign key references and enums