On 17 November 2015 at 14:30, Nathaniel Smith <n...@pobox.com> wrote: > On Nov 16, 2015 12:46 PM, "Robert Collins" <robe...@robertcollins.net> > wrote: >> > [...] >> marker = wsp* marker_expr ( wsp* ('and' | 'or') wsp* >> marker_expr)* > > I guess technically the spec doesn't say either way what the precedence of > "and" versus "or" should be; it just parses unparenthesised sequences to a > flat ast and in principle the (unspecified) ast evaluator could apply > different precedences. The way the grammar's written though seems to suggest > that they're equal precedence with some unspecified associativity, which is > different from python where "and" is more tightly binding than "or" (and > associativity doesn't matter because each operator is associative in > isolation). Maybe this is implied here too via the language about how this > is intended to be a python subset, but it would be good to clarify what the > evaluation semantics should be.
e.g. "1" < "2" and "3" < "4" or "5" < "6" Right now we haven't used prose to define AND or OR as having differing precedences - and PEP 345 didn't either. I think simple left associative would be fine - right now the grammar we give parses: "name; os_name=='dud' and os_name=='odd' or os_name=='fred'" as ('name', [], [], (('posix', '==', 'dud'), [('and', ('posix', '==', 'odd')), ('or', ('posix', '==', 'fred'))])) which can just be rolled up left to right. > Other comments: > > The whitespace handling looks correct to me now :-) > > I didn't check that the two copies of the grammar are identical (and I only > looked at the top version, not the bottom version). Hopefully someone did? > It'll be a headache if we discover later that there's skew between them, and > no guidance on which is normative. I've been pretty careful; if there's a difference we'll discuss and figure it out :) -Rob -- Robert Collins <rbtcoll...@hp.com> Distinguished Technologist HP Converged Cloud _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org https://mail.python.org/mailman/listinfo/distutils-sig