The life and times of an Abstract Syntax Tree

Author Francesco Bertolaccini explains the importance of Abstract Syntax Trees (ASTs) in compilers and how different programming languages handle memory management of AST nodes. He explores the use of shared pointers in managed languages like C# and Java, contrasting it with C++’s unique pointers. Bertolaccini also delves into AST design considerations, such as immutability and efficient memory allocation. He debates using std::variant over inheritance for AST node representation. The post concludes with a discussion on optimizing AST storage using techniques like std::array and indices rather than raw pointers. Bertolaccini emphasizes the importance of profiling code and avoiding premature optimization.

https://blog.trailofbits.com/2024/05/02/the-life-and-times-of-an-abstract-syntax-tree/

To top