[Python-ideas] a in x or in y
Boris Borcic
bborcic at gmail.com
Thu Feb 13 14:28:23 CET 2014
More information about the Python-ideas mailing list
Thu Feb 13 14:28:23 CET 2014
- Previous message: [Python-ideas] a in x or in y
- Next message: [Python-ideas] a in x or in y
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nick Coghlan wrote: > On 13 February 2014 20:57, Steven D'Aprano <steve-iDnA/YwAAsAk+I/owrrOrA at public.gmane.org> wrote: >> - given the restrictions on the parser, is this even possible? and > > I haven't worked through an actual candidate grammar (so I could > potentially be wrong) but I'm pretty sure it requires more lookahead > than Guido is willing to allow for the language definition. > > At the point we hit: > > X in Y and > > we're going to want to process "X in Y" as an expression, and then > start looking at compiling the RHS of the "and". > > This proposal would mean that when the "in" shows up after the "and", > we need to backtrack, lift "X" out as its own expression, and then > reinsert it as the LHS of *multiple* containment tests. > > It's worth noting that this deliberate "no more than one token > lookahead" design constraint in the language syntax isn't just for the > benefit of compiler writers: it's there for the benefit of human > readers as well. > > In linguistics, there's a concept called "garden path" sentences - > these are sentences where the first part is a grammatically coherent > sentence, but by *adding more words to the end*, you change the > meaning of words that appeared earlier. Are you trying to say "X in Y and" forms a complete expression?? And couldn't the lexer recognize "and in" and cognates as single tokens anyway, like it apparently does presently for "is not" ? --- Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active. http://www.avast.com
- Previous message: [Python-ideas] a in x or in y
- Next message: [Python-ideas] a in x or in y
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list