Skip to main content

TOON (Token-Oriented Object Notation) grammar for tree-sitter

Project description

Tree-Sitter TOON Grammar

A complete tree-sitter grammar implementation for TOON (Token-Oriented Object Notation) v2.0.

Installation

Python

pip install tree-sitter-toon
from tree_sitter import Parser
from tree_sitter_toon import language

parser = Parser(language())
tree = parser.parse(b"name: value")

Development

# Generate parser
tree-sitter generate

# Run tests
tree-sitter test

# Parse a file
tree-sitter parse example.toon

Status

Production Ready

  • 93.8% test pass rate (61/65 tests)
  • All major TOON v2.0 features implemented
  • Comprehensive test coverage

Features

  • ✅ All primitive types (null, boolean, number, string)
  • ✅ Unquoted strings with Unicode/emoji support
  • ✅ Objects with indentation-based nesting
  • ✅ Arrays: inline, tabular, and list formats
  • ✅ All delimiters: comma, pipe, tab
  • ✅ Headers with field lists
  • ✅ Objects as list items
  • ✅ Empty arrays
  • ✅ Nested structures (tested to 5+ levels)

Documentation

  • IMPLEMENTATION_NOTES.md - Complete implementation documentation
  • TASK_COMPLETION.md - Recent work summary
  • example.toon - Working demonstration file

Test Organization

test/corpus/
├── arrays/          - Array tests (inline, tabular, list, root)
├── objects/         - Object structure tests
├── delimiters/      - Delimiter-specific tests
├── primitives.txt   - All primitive value types
└── mixed.txt        - Complex combined scenarios

Example

name: TOON Parser
version: 2.0
unicode: Hello 世界 🎉

arrays:
  inline[3]: a,b,c
  empty[0]:
  
table[2]{id,name}:
  1,Alice
  2,Bob

users[2]:
  - name: Alice
    score: 100
  - name: Bob
    score: 200

nested:
  data[2]: x,y

License

GPL-3.0-or-later

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_toon-0.0.3.tar.gz (35.5 kB view details)

Uploaded Source

File details

Details for the file tree_sitter_toon-0.0.3.tar.gz.

File metadata

  • Download URL: tree_sitter_toon-0.0.3.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for tree_sitter_toon-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a1d4412114131c162341d222543e29c46ef0899df11c0cc27f582e2c0da03fc8
MD5 023ae388ced527471d50096e08677ee0
BLAKE2b-256 16b87457cdaaa1abd12c33663ccf87c13234160016b415cabd0fa9a90d39a3f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page