<div dir="ltr"><div dir="ltr">On Mon, Apr 1, 2019 at 3:13 PM Terry Reedy <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 4/1/2019 1:14 AM, Guido van Rossum wrote:<br>
> We do have a parser generator in the standard library:<br>
> <a href="https://github.com/python/cpython/tree/master/Lib/lib2to3/pgen2" rel="noreferrer" target="_blank">https://github.com/python/cpython/tree/master/Lib/lib2to3/pgen2</a><br>
<br>
It is effectively undocumented and by inference discouraged from use. <br></blockquote><div><br></div><div>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:</div><div><br></div><div>  genericurl: scheme '://'</div><div>  scheme: ...</div><div> </div><div>The reason is '://' is not a known token type in Python language. That is a real bummer.</div><div><br></div><div>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?</div><div><br></div><div>Cheers,</div><div>Nam</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The entry for lib2to3 in the 2to3 doc:<br>
<a href="https://docs.python.org/3/library/2to3.html#module-lib2to3" rel="noreferrer" target="_blank">https://docs.python.org/3/library/2to3.html#module-lib2to3</a><br>
"<br>
lib2to3 - 2to3’s library<br>
Source code: Lib/lib2to3/<br>
Note: The lib2to3 API should be considered unstable and may change <br>
drastically in the future.<br>
<br>
help(pgen) is not much more helpful.<br>
:<br>
Help on package lib2to3.pgen2 in lib2to3:<br>
<br>
NAME<br>
     lib2to3.pgen2 - The pgen2 package.<br>
<br>
PACKAGE CONTENTS<br>
     conv<br>
     driver<br>
     grammar<br>
     literals<br>
     parse<br>
     pgen<br>
     token<br>
     tokenize<br>
<br>
FILE<br>
     c:\programs\python38\lib\lib2to3\pgen2\__init__.py<br>
<br>
<br>
<br>
-- <br>
Terry Jan Reedy<br>
<br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div>