New PEG parser !

30 views
Skip to first unread message

Pierre Quentel

unread,
Feb 4, 2024, 6:06:42 AMFeb 4
to brython
One month ago, Austin Schick submitted an issue : Exploring performant PEG parsing, where he suggested a new way of implementing a PEG parser in Brython. My first attempt had failed because the parsing time was much slower than the current "hand-made" parser.

The idea was to adapt the scripts used by CPython to generate the C parser (in Tools/peg_generator) to generate a Javascript parser.

After a couple of interactions with Austin, the implementation is now complete and was committed to the current development version.

This new parser is a little slower than the "hand-made" version (around 1,7 times), and the resulting Brython code in brython.js is sligthly bigger (around 20%) but this is acceptable because of the huge benefit if brings: a full compliance with the official Python grammar, including the generation of the AST and of error messages with the "grammar actions" described in PEP 617.

Such a big change is likely to bring errors in cases that have not been tested yet, so all of you who can test their code with the new development version are invited to do so and report bugs in the issue tracker.

J M E

unread,
Feb 4, 2024, 12:59:35 PMFeb 4
to bry...@googlegroups.com
Excellent. Great work.

Sent from my iPhone

On 4 Feb 2024, at 11:06, Pierre Quentel <pierre....@gmail.com> wrote:

One month ago, Austin Schick submitted an issue : Exploring performant PEG parsing, where he suggested a new way of implementing a PEG parser in Brython. My first attempt had failed because the parsing time was much slower than the current "hand-made" parser.
--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/c3816bc5-7043-4b9b-8842-307095648207n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages