waxeye-org / waxeye

Waxeye is a parser generator based on parsing expression grammars (PEGs). It supports C, Java, JavaScript, Python, Racket, and Ruby.
https://waxeye-org.github.io/waxeye/index.html
Other
235 stars 38 forks source link

PHP Support #104

Open michael-becker opened 4 years ago

michael-becker commented 4 years ago

Hey folks,

thanks for the good work with waxeye. Since we need this in a project, I am currently developing support for PHP parser generation (https://github.com/michael-becker/waxeye-php).

As of now, generation of PHP parsers is possible. Still missing is finalising the implementation of the different Transitions. This should be finalised finished next week. Feel free to comment and suggest improvements.

orlandohill commented 4 years ago

Hi Michael,

Sounds great. I'm sure plenty of people will find your PHP work useful.

It looks like you are translating the Java code to PHP. Makes sense.

Long story short, development is stalled for Java. The parser internals have been rewritten, but need to be merged into master. I believe #25 is mostly done, but there are now merge conflicts, and the TypeScript version may have since made further improvements.

Are you able to help us with the Java version too? I believe @glebm has offered to do code review.

glebm commented 4 years ago

The current JavaScript (TypeScript) version would be the best one to base the new PHP or Java parser on, because it's non-recursive. Recursive parsers in these languages can easily run out of stack on inputs only a few KiB in size.

orlandohill commented 4 years ago

The Java code in #25 should already be close to equivalent to the current TypeScript version. Aside from changes to handle Unicode, were there any big changes to Joshua's JavaScript/CoffeScript version?

I think the merge conflicts in #25 are related to the generation code having migrated from PLT Scheme to Racket, and perhaps some stuff with the test harness.

glebm commented 4 years ago

There were no other big changes. I've now skimmed through the code in #25 and it does look equivalent. Unicode support can be implemented in a very similar way (both Java and JavaScript use UTF-16).

michael-becker commented 4 years ago

Thanks for the reply. We are also using the Java and Typescript versions. Since I am more a Java-guy, I will have a look at #25 and hopefully might be able to contribute necessary adaptions.

michael-becker commented 4 years ago

Just to give an update: I have rewritten the PHP implementation according to your remarks. It is now non-recursive. In additiona, I implemented the calc example. Works as a charm from my point of view :)

Currently, there is some code cleaning and minor bugfixing necessary. But I think we should be able to start a code review at the end of this or beginning with next week.

bkil commented 3 years ago

I'd really find support for PHP (either directly or via Haxe #43) useful, as it is a pretty common freely hosted server side language. Can we perhaps somehow give a hand at finishing this up?