jetcrab\ast/
mod.rs

1//! # Abstract Syntax Tree (AST) Module
2//!
3//! Defines the data structures representing JavaScript code as an abstract
4//! syntax tree, enabling programmatic manipulation and analysis of code.
5//!
6//! ## Overview
7//!
8//! The AST module provides comprehensive node types for:
9//!
10//! - **Program Structure**: Scripts, modules, and declarations
11//! - **Statements**: Control flow, loops, and declarations
12//! - **Expressions**: Operations, calls, and assignments
13//! - **Literals**: Values, objects, and functions
14//! - **Common Elements**: Positions, spans, and metadata
15//!
16//! ## Node Types
17//!
18//! Each AST node includes:
19//! - **Position Information**: Line and column numbers
20//! - **Type Safety**: Strongly typed node variants
21//! - **Visitor Pattern**: Traversal and transformation support
22//! - **Serialization**: JSON export capabilities
23//!
24//! ## Usage
25//!
26//! ```rust
27//! use jetcrab::ast::{Node, Program, Visitor};
28//!
29//! let program = Program::new(vec![]);
30//! let node = Node::Program(program);
31//!
32//! // Use visitor pattern for traversal
33//! struct MyVisitor;
34//! impl Visitor for MyVisitor {
35//!     // Implementation details...
36//! }
37//! ```
38
39pub mod common;
40pub mod error;
41pub mod expressions;
42pub mod literals;
43pub mod node;
44pub mod serialization;
45pub mod statements;
46pub mod visitor;
47
48pub use common::{Position, Span};
49pub use error::AstError;
50pub use node::{
51    ExportDeclaration, ExportSpecifier, ImportDeclaration, ImportDefaultSpecifier,
52    ImportNamespaceSpecifier, ImportSpecifier, Node, Program,
53};
54pub use visitor::Visitor;
55
56pub use statements::{
57    BlockStatement, BreakStatement, CatchClause, ClassDeclaration, ContinueStatement,
58    DebuggerStatement, DoWhileStatement, ExpressionStatement, ForStatement, FunctionDeclaration,
59    IfStatement, LabeledStatement, ReturnStatement, SwitchCase, SwitchStatement, ThrowStatement,
60    TryStatement, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement,
61};
62
63pub use expressions::{
64    AssignmentExpression, AwaitExpression, BinaryExpression, CallExpression, ConditionalExpression,
65    LogicalExpression, MemberExpression, MetaProperty, NewExpression, RegExp, Super,
66    UnaryExpression, UpdateExpression, YieldExpression,
67};
68
69pub use literals::{
70    ArrayLiteral, ArrowFunctionExpression, ClassExpression, FunctionExpression, ObjectLiteral,
71    Property, RestElement, SpreadElement, TaggedTemplateExpression, TemplateElement,
72    TemplateLiteral,
73};