Procedural macros for generating AST-related code and ensuring memory layout consistency.
This crate provides procedural macros that generate boilerplate code for AST nodes, ensuring consistent memory layout and providing derived traits automatically.
#[ast]attribute: Marks types as AST nodes and generates required traits- Memory layout control: Ensures
#[repr(C)]for predictable memory layout - Trait derivation: Automatically derives common traits like
Debug,Clone, etc. - Code generation: Reduces boilerplate and ensures consistency across AST types
- Adds
#[repr(C)]: Ensures predictable memory layout across platforms - Marker for tooling: Identifies types as AST nodes for code generation tools
- Trait derivation: Automatically implements common traits
- Consistency: Ensures all AST nodes follow the same patterns
This macro system enables:
- Maintainable AST: Reduces boilerplate across hundreds of AST types
- Consistent layout: Critical for performance and correctness
- Tool integration: Allows
oxc_ast_toolsto generate visitor code - Type safety: Ensures all AST nodes have required traits
The macros are designed to be transparent and generate minimal, efficient code.