-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Migrate on own parser #1053
Comments
Any chance we could viably compile the original PHP parser to WebAssembly? |
PHP as a whole has already been compiled to WASM, but I have no insight into that field and can't tell whether compiling parts (i.e. just the parser) would be feasible. |
@loilo i am afraid what original php parsers is not enough for prettier, a lot of information about nodes is missing because php no need this |
Any possibility the plugin could use the https://github.com/nikic/PHP-Parser directly, or would this have the same issue with missing nodes? Obviously that means running php processes as part of prettier PHP (no necessarily simple), but it would have the benefit that it would be easier to stay up to date with future language changes. |
@karptonite same problem not enough node information 😞 I think I can implement parser using bison/yacc (https://github.com/nikic/PHP-Parser using modified version of yacc, but it is not a problem) for two weeks, but i don't have time right now, if somebody want to help me will be great. |
Perhaps the PHP version is extensible enough to allow it to be extended to get the additional node information? I'm looking at this issue as an example of getting information that doesn't normally get stored by the parser: nikic/PHP-Parser#384 |
To be honestly for us interesting only https://github.com/nikic/PHP-Parser/blob/master/grammar/php5.y and https://github.com/nikic/PHP-Parser/blob/master/grammar/php7.y and https://github.com/nikic/PHP-Parser/blob/master/grammar/tokens.y What we should do:
It is not hard, node(s) is very simple |
I can try to find time on PoC |
Hi @evilebottnawi,
|
I think yes, but nobody do this. Also bison/yacc parser better maintenance.
BFN (EBFN) grammar and generate parser based on this rules. You can see https://github.com/nikic/PHP-Parser/tree/master/grammar here how it can be done. |
Alright, thanks for sharing the details - I'll try to take a closer look when I find the time 🙂 |
Hi @evilebottnawi and @czosel, interresting approach. In the past I've used https://www.npmjs.com/package/jison but at that time the LR(1) generated code was not good enough to parse some syntax collisions on PHP, and by resolving them is was too permissive and also too slow compared to now, but agree that the maintenance of the syntax may be easier on grammar files than code. Did you succeed with a POC or prototype ? |
@ichiriac not, is is just idea, it it no high priority, the problem is that we get fixes/features extremely slowly and very few guys have experience with parsers, supporting parser generator based on bfn/ebfn will be easy |
@czosel @loilo i can't continue update php parser due glayzzle/php-parser#359 and glayzzle/php-parser#358, it is big regressions for us, i think we need fork parser and revert this and continue development |
I do not have a lot of time, but in my plan to finish the stable version this month |
@evilebottnawi I think it's fine to continue development on your fork for the moment, most likely @ichiriac will revert the change soon. |
@czosel i think we should:
|
Sounds good! To me, especially better inline support seems critical - unfortunately, that’s probably also the hardest part. |
@czosel - better inline support is related to glayzzle/php-parser#170 I think the actual approach of |
@ichiriac maybe you can allow to me merge without your review (bug fixes), we do great work and our parser not a bad, i just need review when implement new feature |
/cc @czosel I have a lot of PRs with fixes and features https://github.com/glayzzle/php-parser/pulls, I can finish support php 7.3 and php 7.4 and inline nodes by the end of the month if my PR someone will merge (will be great if review also). But the developer is extremely inactive, and I can’t finish it in the right time because of this. |
I'd also be ok with using your fork of the parser until your PRs get merged. Unfortunately, I neither have the time nor the know-how to do reviews of your work on the parser 😞 |
@czosel hm, here there solution:
|
I’d suggest either option 1 or 3. I think keeping the parser separate is important both for separation of concerns and for being able to easily merge your changes back in the upstream parser. |
/cc @ichiriac what about branch for prettier? |
Hi @evilebottnawi , You are registered as collaborator (and also @czosel) from a long time ago, and I already gave you since then the write access level on the repository. In principle you can merge any PR by your own, even if I prefer to check them when it comes to major changes. Lets go with the prettier branch option, here your branch : https://github.com/glayzzle/php-parser/tree/prettier (BTW you can also create as many branches you need)
|
@ichiriac Thanks! |
This may also be of some use: https://github.com/nikic/php-ast Same developer as PHP-Parser. |
Somewhat off topic but this plugin has saved me a long way keeping my code base tidy. Absolutely ♥ it! I understand, however, that PHP plugin is a volunteer project and you can only put so much work. I'd love to help! I don't understand parsers but how about financially wise? Perhaps fellow developers like me would be interested and that would also help you. I use it consistently with PHP 7.3 (f.ex. Laravel) projects. It works flawlessly 99% of time. However, since PHP 7.4 is standing outside and knocking the door - the tense rises. :) |
@flexchar thanks for the desire to help, but we need help in the code and not in the money, we need to implement all the constructs from |
Thanks for the kind words @flexchar, I’m happy to hear the plugin is working well for you! |
@czosel & @evilebottnawi I also want to thank you for your work on this, the project is a huge help. I would really like to try and contribute, but having just spent a few hours attempting to get things working, I ended up stuck on setup, tooling and workflow. I know this is a huge ask, but any additional documentation towards getting a basic development environment working would be really welcome. I've read over the Contributing doc (and Prettier's) but some things don't make sense or seem to point to missing files (the A few places I got stuck
|
Hi @joemaller I'll answer the questions right here - afterwards we can think about what can be added to the documentation.
Update: See #1267 |
@joemaller The docs should be a little better now - let me know if you see further improvements! |
/cc @czosel
Current parser does not improve and does not fix bugs, I propose to go to your own parser, we can use https://github.com/nikic/PHP-Parser/tree/master/grammar as example. I know it is require time, but unfortunately it seems we have no other way.
The text was updated successfully, but these errors were encountered: