Crate linked_syntax_tree
source ·Expand description
A doubly-linked syntax tree.
Offers functionality similar to std::collections::LinkedList
.
Some code:
x = -10
loop
x = x + 1
if x
break
x = 2
can be represented as:
┌──────────┐
│x = -10 │
└──────────┘
│
┌──────────┐
│loop │
└──────────┘
│ ╲
┌──────────┐ ┌─────────┐
│x = 2 │ │x = x + 1│
└──────────┘ └─────────┘
│
┌─────────┐
│if x │
└─────────┘
╲
┌─────────┐
│break │
└─────────┘
I personally am using this to contain an AST for compile-time evaluate.
Structs
- Roughly matches
std::collections::linked_list::Cursor
. - Roughly matches
std::collections::linked_list::CursorMut
. - An element in a
SyntaxTree
with a known depth. - Iterates through elements depth-first in a
SyntaxTree
returning references. - Iterates through elements depth-first in a
SyntaxTree
returning mutable references. - A doubly-linked syntax tree.