-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any plans for an official API to convert from Microsoft\PHPParser\Node to \ast\Node (nikic/php-ast) and/or \PhpParser\Node (nikic/php-parser)? #113
Comments
Good question. No official plans at the moment, but we're currently working with @felixfbecker to port php-language-server to this parser, and after that work is complete, it will be easier for us to understand the tradeoffs of such an approach. |
php-language-server has been ported, it seems. On an unrelated note, I've been working on https://github.com/TysonAndre/php-parser-to-php-ast/ for converting PHP-Parser to php-ast (tests pass, but there's probably some uncommon syntax I've missed), which would help with converting to php-ast if tolerant-php-parser to PHP-Parser conversion existed. |
https://github.com/TysonAndre/php-parser-to-php-ast is 90% (Edit: 98%) done. Test cases aren't comprehensive, there's still bugs in what remains. Two modes of operation are planned (Edit: and implemented):
Still haven't decided how/if features such as autocompletion would work if I proceeded (E.g. should there be an option to return an SplObjectStorageMap mapping an |
https://github.com/TysonAndre/php-parser-to-php-ast is in a usable state. The question asked in the original issue has been answered. Converting to nikic/php-parser's nodes is feasible, but would be very time consuming to implement, and I don't have use cases for PhpParser\Node. |
Related to #47 and #36 , didn't see anything mentioning this when searching issues.
A lot of existing tooling uses one of these two parsers, and there are potential use cases for being able to parse syntactically invalid files.
Examples of potential use cases:
Or, do you recommend creating a separate project depending on tolerant-php-parser?
Aside: if existing tooling needs to know something about any incomplete expressions/statements, adding a property such as $node->tolerantAST to the derived data structures may help
The text was updated successfully, but these errors were encountered: