1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (C) 2024-2025 w0wl0lxd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! # toon-lsp
//!
//! A Language Server Protocol (LSP) implementation for TOON (Token-Oriented Object Notation).
//!
//! TOON is a compact, human-readable encoding of the JSON data model designed for LLM prompts.
//! This crate provides:
//!
//! - **AST with source positions** - Full abstract syntax tree with span information
//! - **Parser** - TOON parser that produces positioned AST nodes
//! - **LSP Server** - Complete language server with diagnostics, symbols, and more
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
//! │ Scanner │ ──▶ │ Parser │ ──▶ │ AST │
//! │ (Lexer) │ │ │ │ (with Spans)│
//! └─────────────┘ └─────────────┘ └─────────────┘
//! │
//! ▼
//! ┌─────────────┐
//! │ LSP Server │
//! │ (tower-lsp) │
//! └─────────────┘
//! ```
//!
//! ## Usage
//!
//! ```rust
//! use toon_lsp::{parse, AstNode};
//!
//! let source = "user:\n name: Alice\n age: 30";
//! let ast = parse(source).expect("valid TOON");
//!
//! // Every AST node carries source positions (Span)
//! let AstNode::Document { children, span } = &ast else { return };
//! assert_eq!(span.start.line, 0); // 0-indexed
//!
//! // Walk objects via entries
//! for node in children {
//! if let AstNode::Object { entries, .. } = node {
//! assert_eq!(entries[0].key, "user");
//! }
//! }
//! ```
//!
//! **Error recovery for IDEs**: parse succeeds even with syntax errors:
//!
//! ```rust
//! use toon_lsp::parse_with_errors;
//!
//! let source = "config:\n debug: true\n port: 8080";
//! let (ast, errors) = parse_with_errors(source);
//!
//! // Partial AST available for IDE features even with errors
//! assert!(ast.is_some());
//!
//! // Errors carry spans for diagnostic rendering
//! for err in &errors {
//! let _ = (err.span.start.line, err.kind.clone());
//! }
//! ```
pub use ;
pub use ;
pub use ;