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
//! `poshtree` turns PowerShell source into a syntax tree and back again.
//!
//! It has three pieces: a lexer that produces tokens, a recursive-descent
//! parser that builds an abstract syntax tree ([`v1::ast::AstNode`]), and an
//! [`unparse`]r that regenerates source from a tree. `regex` is the only
//! dependency.
//!
//! The tree types live under a versioned [`v1`] module. A breaking change to
//! the tree ships as a new `v2` module instead of altering `v1`, so code
//! pinned to `v1` keeps compiling.
//!
//! # Quick start
//! ```
//! use poshtree::v1::{ast::AstNode, parser::parse};
//!
//! let (tree, errors) = parse("$x = 1 + 2");
//! assert!(errors.is_empty());
//!
//! // Walk every node in the tree.
//! let mut nodes = 0;
//! AstNode::ScriptBlock(tree).walk(&mut |_| nodes += 1);
//! assert!(nodes > 0);
//!
//! // Or round-trip source through the parser and back to text.
//! let out = poshtree::unparse_source("$x = 1 + 2");
//! assert!(out.contains("$x"));
//! ```
// Flat re-exports: the most common items
pub use ;
pub use ;
pub use ;
pub use tokenize;
pub use ;
pub use Token;