concrete-syntax-tree
A small, lossless concrete syntax tree for parser tooling.
The crate provides a generic tree container. Language-specific parsers define
their own node-kind enum and implement [CstKind]. The tree can represent
grammar productions, tokens, whitespace, comments, and other trivia without
discarding the original token text.
Example
use ;
let tree = branch;
assert_eq!;
assert_eq!;
API
CstKind supplies language-specific trivia classification and diagnostic
names. CstNode<K> stores a node kind, byte span, child nodes, and—on leaf
nodes—the exact token text. CstNode::to_source concatenates descendant leaf
text in order, making lossless round-tripping possible when the parser records
all tokens and trivia.
This initial 0.1 API intentionally keeps the tree representation simple.
Future versions may add a document-owned source buffer and span-based text
access without changing the role of the crate as a generic CST foundation.
Scope
This crate does not parse a language, define a grammar, recover from syntax errors, or provide an AST. It is the reusable tree representation for those layers.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.