Climbing the Abstract Syntax Tree
summary
PHP 7 replaces direct opcode emission with an AST so the parser decouples from the compiler and the parse+compile step runs 10–15% faster at the cost of some memory which PHP 7’s packed zval mostly offsets. The demo builds a basic PHP math compiler in PHP that lexes, converts to reverse polish, constructs an AST and runs a tiny VM — it works as an educational proof of concept but is not production quality. Tools demonstrated include php-ast extension and PHP-Parser plus better-reflection for static analysis and experimental AST rewriting.
AI-written summary · about
chapters (18)
- 0:00Introduction and speaker background
- 1:04How PHP processes code
- 3:08Lexer and token generation
- 6:42Parser and AST generation
- 11:26What is an Abstract Syntax Tree
- 14:59Benefits of AST in PHP 7
- 18:53Polish and reverse Polish notation
- 22:31Building a basic math compiler in PHP
- 27:50Creating AST from reverse Polish notation
- 29:38Executing the AST with a virtual machine
- 31:05Impact of AST on PHP 7 performance
- 32:29AST in other programming languages
- 33:34Using AST in userland with PHP AST extension
- 34:59Modifying AST with err seek extension
- 35:42PHP Parser library for AST in PHP
- 36:26Better Reflection and AST analysis
- 39:55Summary and future of AST in PHP
- 40:37Q&A session
