Showing content from http://mail.python.org/pipermail/python-dev/attachments/20100331/2d78c295/attachment.html below:
Thank you for the advice everyone. This seed has finally born (rotten) fruit at:<br><br><a href="http://writeonly.wordpress.com/2010/04/01/whython-python-for-people-who-hate-whitespace/">http://writeonly.wordpress.com/2010/04/01/whython-python-for-people-who-hate-whitespace/</a><br>
<a href="http://bitbucket.org/gregglind/python-whython3k/">http://bitbucket.org/gregglind/python-whython3k/</a><br><br><div class="gmail_quote">On Fri, Mar 12, 2010 at 4:13 AM, Georg Brandl <span dir="ltr"><<a href="mailto:g.brandl@gmx.net">g.brandl@gmx.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Am 09.03.2010 14:42, schrieb Jeremy Hylton:<br>
<div><div></div><div class="h5">> On Sat, Mar 6, 2010 at 11:27 AM, Gregg Lind <<a href="mailto:gregg.lind@gmail.com">gregg.lind@gmail.com</a>> wrote:<br>
>> Python-devs,<br>
>><br>
>> I'm writing to you for some help in understanding the Python grammar. As an<br>
>> excuse to deep dive into Python's tokenizer / grammar, I decided (as a<br>
>> hideous, hideous joke) to want to allow braces where colons are allowed (as<br>
>> flow control).<br>
>><br>
>> Starting from PEP 306 (and branch r311), I hacked on Grammar/Grammer<br>
>><br>
>> As a first example:<br>
>><br>
>> funcdef: ('def' NAME parameters ['->' test] ':' suite |<br>
>> 'def' NAME parameters ['->' test] '{' suite '}' )<br>
>><br>
>> I reran Parser/pgen and the dfa changes, but python (3.1) when recompiled,<br>
>> throws errors on things like:<br>
>><br>
>> def a() { None }<br>
>><br>
>> Strangely enough:<br>
>><br>
>> lambdef: ( 'lambda' [varargslist] ':' test |<br>
>> 'lambda' [varargslist] '{' test '}' )<br>
>><br>
>> works fine! I this simplely some difference between "test" and "suite".<br>
>><br>
>> I have tried tackling this with gdb, looking at err_input clearly isn't<br>
>> enough.<br>
>><br>
>> (gdb) break err_input<br>
>> (gdb) break PyParser_ASTFromString<br>
>> import sys<br>
>> b = compile("def a() {pass}","sys.stdout","single")<br>
>> # yet a simple grammar fix is enough for this!<br>
>> c = compile("lambda x {None}","sys.stdout","single")<br>
>><br>
>> I'm in over my head!<br>
><br>
> You don't say what errors occur when you try to compile strings in<br>
> your new language. You may have changed the Grammar, which allows you<br>
> to tokenize the input. That isn't enough to get the input to compile.<br>
> You also need to change the compiler to understand the new tokens.<br>
<br>
</div></div>In particular, many AST creation functions check for specific counts of<br>
children on many nodes. I haven't checked, but in the case of the<br>
"funcdef" rule, it may check for either 7 or 5 children to determine<br>
whether the optional return annotation ['->' test] is present.<br>
<br>
Georg<br>
<br>
<br>
--<br>
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.<br>
Four shall be the number of spaces thou shalt indent, and the number of thy<br>
indenting shall be four. Eight shalt thou not indent, nor either indent thou<br>
two, excepting that thou then proceed to four. Tabs are right out.<br>
<div class="im"><br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
</div>Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/gregg.lind%40gmail.com" target="_blank">http://mail.python.org/mailman/options/python-dev/gregg.lind%40gmail.com</a><br>
</blockquote></div><br>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4