Reputation: 6560
This is basically second part of my first Question which is about making source code browser. After reading tutorials I found that I need to parse PHP file and Build AST and from there I will have symbols I need. However, searching for days have brought nothing useful on how I can do that. Is there any tutorial or question already answered about building PHP AST? Sorry if it is answered somewhere, my searches found nothing useful!
Upvotes: 2
Views: 917
Reputation: 24280
In 2017 there is stable and powerful tool for that - PHP-Parser.
It allows TOKEN parsing and AST parsing of the PHP source code.
Here is AST code generation example.
If you look for C extension that would allow it, check nikic/ast.
Upvotes: 1
Reputation: 1400
You can look at how PHP does it: https://svn.php.net/repository/php/php-src/trunk/Zend/zend_language_parser.y. Be advised though that PHP uses re2c instead of flex (grammar in ./zend_language_scanner.l).
Upvotes: 1