On Mon, Apr 1, 2019 at 3:13 PM Terry Reedy <tjre...@udel.edu> wrote: > On 4/1/2019 1:14 AM, Guido van Rossum wrote: > > We do have a parser generator in the standard library: > > https://github.com/python/cpython/tree/master/Lib/lib2to3/pgen2 > > It is effectively undocumented and by inference discouraged from use. >
I've tried it out over the weekend. The undocumented-ness is kinda annoying but surmountable. What I found was this library is tightly coupled to the Python language, both at the lexer and parser levels. For example, defining a simple grammar like this would not work: genericurl: scheme '://' scheme: ... The reason is '://' is not a known token type in Python language. That is a real bummer. Back to my original goal, I've gathered that there is some interest in having a more general parser library in the stdlib. "Some", but not "much". Should I start out with a straw proposal so that we can hash it out further? Cheers, Nam The entry for lib2to3 in the 2to3 doc: > https://docs.python.org/3/library/2to3.html#module-lib2to3 > " > lib2to3 - 2to3’s library > Source code: Lib/lib2to3/ > Note: The lib2to3 API should be considered unstable and may change > drastically in the future. > > help(pgen) is not much more helpful. > : > Help on package lib2to3.pgen2 in lib2to3: > > NAME > lib2to3.pgen2 - The pgen2 package. > > PACKAGE CONTENTS > conv > driver > grammar > literals > parse > pgen > token > tokenize > > FILE > c:\programs\python38\lib\lib2to3\pgen2\__init__.py > > > > -- > Terry Jan Reedy > > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/