<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 22, 2013 at 3:21 AM, anatoly techtonik <span dir="ltr"><<a href="mailto:techtonik@gmail.com" target="_blank">techtonik@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On Fri, Nov 15, 2013 at 5:43 PM, Benjamin Peterson <<a href="mailto:benjamin@python.org">benjamin@python.org</a>> wrote:<br>


> 2013/11/15 anatoly techtonik <<a href="mailto:techtonik@gmail.com">techtonik@gmail.com</a>>:<br>
>> On Tue, Nov 12, 2013 at 5:08 PM, Benjamin Peterson <<a href="mailto:benjamin@python.org">benjamin@python.org</a>> wrote:<br>
>>> 2013/11/12 anatoly techtonik <<a href="mailto:techtonik@gmail.com">techtonik@gmail.com</a>>:<br>
>>>> On Sun, Nov 10, 2013 at 8:34 AM, Benjamin Peterson <<a href="mailto:benjamin@python.org">benjamin@python.org</a>> wrote:<br>
>>>>> 2013/11/10 anatoly techtonik <<a href="mailto:techtonik@gmail.com">techtonik@gmail.com</a>>:<br>
>>>>>> <a href="http://hg.python.org/cpython/file/1ee45eb6aab9/Parser/Python.asdl" target="_blank">http://hg.python.org/cpython/file/1ee45eb6aab9/Parser/Python.asdl</a><br>
>>>>>><br>
>>>>>> In Assign(expr* targets, expr value), why the first argument is a list?<br>
>>>>><br>
>>>>> x = y = 42<br>
>>>><br>
>>>> Thanks.<br>
>>>><br>
>>>> Speaking of this ASDL. `expr* targets` means that multiple entities of<br>
>>>> `expr` under the name 'targets' can be passed to Assign statement.<br>
>>>> Assign uses them as left value. But `expr` definition contains things<br>
>>>> that can not be used as left side assignment targets:<br>
>>>><br>
>>>>     expr = BoolOp(boolop op, expr* values)<br>
>>>>          | BinOp(expr left, operator op, expr right)<br>
>>>>          ...<br>
>>>>          | Str(string s) -- need to specify raw, unicode, etc?<br>
>>>>          | Bytes(bytes s)<br>
>>>>          | NameConstant(singleton value)<br>
>>>>          | Ellipsis<br>
>>>><br>
>>>>          -- the following expression can appear in assignment context<br>
>>>>          | Attribute(expr value, identifier attr, expr_context ctx)<br>
>>>>          | Subscript(expr value, slice slice, expr_context ctx)<br>
>>>>          | Starred(expr value, expr_context ctx)<br>
>>>>          | Name(identifier id, expr_context ctx)<br>
>>>>          | List(expr* elts, expr_context ctx)<br>
>>>>          | Tuple(expr* elts, expr_context ctx)<br>
>>>><br>
>>>> If I understand correctly, this is compiled into C struct definitions<br>
>>>> (Python-ast.c), and there is a code to traverse the structure, but<br>
>>>> where is code that validates that the structure is correct? Is it done<br>
>>>> on the first level - text file parsing, before ASDL is built? If so,<br>
>>>> then what is the role of this ADSL exactly that the first step is<br>
>>>> unable to solve?<br>
>>><br>
>>> Only valid expression targets are allowed during AST construction. See<br>
>>> set_expr_context in ast.c.<br>
>><br>
>> Oh my. Now there is also CST in addition to AST. This stuff -<br>
>> <a href="http://docs.python.org/devguide/" target="_blank">http://docs.python.org/devguide/</a> - badly needs diagrams about data<br>
>> transformation toolchain from Python source code to machine<br>
>> execution instructions. I'd like some pretty stuff, but raw blogdiag<br>
>> hack will do the job <a href="http://blockdiag.com/en/blockdiag/index.html" target="_blank">http://blockdiag.com/en/blockdiag/index.html</a><br>
>><br>
>> There is no set_expr_context in my copy of CPython code, which<br>
>> seems to be some alpha of Python 3.4<br>
><br>
> It's actually called set_context.<br>
<br>
</div></div>Ok. So what is the process?<br>
<br>
 SOURCE --> TOKEN STREAM --> SENTENCE STREAM --> CST --><br>
--> AST --> BYTECODE<br>
<br>
Is that right?<br>
<div><div class="h5"><br>
>>>> Is it possible to fix ADSL to move `expr` that are allowed in Assign<br>
>>>> into `expr` subset? What effect will it achieve? I mean - will ADSL<br>
>>>> compiler complain about wrong stuff on the left side, or it will still<br>
>>>> be a role of some other component. Which one?<br>
>>><br>
>>> I'm not sure what you mean by an `expr` subset.<br>
>><br>
>> Transform this:<br>
>><br>
>>     expr = BoolOp(boolop op, expr* values)<br>
>>          | BinOp(expr left, operator op, expr right)<br>
>>          ...<br>
>>          | Str(string s) -- need to specify raw, unicode, etc?<br>
>>          | Bytes(bytes s)<br>
>>          | NameConstant(singleton value)<br>
>>          | Ellipsis<br>
>><br>
>>          -- the following expression can appear in assignment context<br>
>>          | Attribute(expr value, identifier attr, expr_context ctx)<br>
>>          | Subscript(expr value, slice slice, expr_context ctx)<br>
>>          | Starred(expr value, expr_context ctx)<br>
>>          | Name(identifier id, expr_context ctx)<br>
>>          | List(expr* elts, expr_context ctx)<br>
>>          | Tuple(expr* elts, expr_context ctx)<br>
>><br>
>> to this:<br>
>><br>
>>     expr = BoolOp(boolop op, expr* values)<br>
>>          | BinOp(expr left, operator op, expr right)<br>
>>          ...<br>
>>          | Str(string s) -- need to specify raw, unicode, etc?<br>
>>          | Bytes(bytes s)<br>
>>          | NameConstant(singleton value)<br>
>>          | Ellipsis<br>
>><br>
>>          -- the following expression can appear in assignment context<br>
>>          | expr_asgn<br>
>><br>
>>      expr_asgn =<br>
>>            Attribute(expr value, identifier attr, expr_context ctx)<br>
>>          | Subscript(expr value, slice slice, expr_context ctx)<br>
>>          | Starred(expr value, expr_context ctx)<br>
>>          | Name(identifier id, expr_context ctx)<br>
>>          | List(expr* elts, expr_context ctx)<br>
>>          | Tuple(expr* elts, expr_context ctx)<br>
><br>
> I doubt ASDL will let you do that.<br>
<br>
</div></div>asdl.py  is plain broken - wrong number of arguments passed to<br>
            output function<br>
asdl_c.py worked ok with fixed ASDL and generated - diff attached.<br>
I don't know what to check further - on Windows without Visual Studio.<br>
--<br></blockquote></div><br></div><div class="gmail_extra">asdl.py is about to be replaced - please see <a href="http://bugs.python.org/issue19655">http://bugs.python.org/issue19655</a> - I'm waiting for after the 3.4 branch to move forward with that.<br>

<br>Let's discuss any needed fixes in that issue.<br><br>Eli<br></div><div class="gmail_extra"><br><br><br></div></div>