Ian Kelly wrote: > […] Thomas 'PointedEars' Lahn […] wrote: >> Ian Kelly wrote: >>> What the grammar that you quoted from shows is that STRING+ is an >>> expression. The individual STRINGs of a STRING+ are not expressions, >>> except to the extent that they can be parsed in isolation as a >>> STRING+. >> How did you get that idea? STRING+ means one or more consecutive STRING >> tokens (ignoring whitespace in-between), which means one or more >> consecutive string literals. A (single) string literal definitely is an >> expression as it can be produced with the “expr” goal symbol of the >> Python grammar (given there in a flavor of EBNF). > > Yes, that's what I was referring to in my parenthetical "except..." above.
Your “except” is contradictory to the rest of what you said, at best. > What I mean is that if you construct a parse tree of "foo" "bar" using > that grammar, it looks like this: > > expr > | > STRING+ > / \ > STRING STRING > […] > > There is only one expr node, and it contains both STRING tokens. Prove it. But be warned: Neither would prove that a string literal is not an expression. Because you did not consider the most simple variant of an AST (or subtree) according to this grammar: expr | STRING Again, “STRING+” does _not_ mean “STRING STRING STRING*”; it means “STRING STRING*”. The second and following STRINGs are *optional*. >> […] in the used flavour of EBNF the unquoted “+” following a goal symbol >> clearly means the occurrence of *at least one* of the immediately >> preceding symbol, meaning either one *or more than one*. > > It means one or more *tokens*, not one or more literals. Utter nonsense. Have you ever written a parser? (I have.) A literal *is* a token. Whether two consecutive tokens end up as the same *node* in an AST is a *different* issue (that, again, was _not_ debated). -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. -- https://mail.python.org/mailman/listinfo/python-list