On Sat, Mar 28, 2015 at 12:20 PM, Thomas 'PointedEars' Lahn <pointede...@web.de> wrote: > Ian Kelly wrote: > >> […] Thomas 'PointedEars' Lahn […] wrote: >>> Ian Kelly wrote: >>>> 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. >> >> I'm not going to expend the effort that would be required to go >> through the entire Python grammar step-by-step and exhaustively prove >> that "foo" "bar" can unambiguously only be produced as a single expr. > > And why should you? That is not what you claimed.
Of course it is. I claimed that there was only one expr node in the parse tree of "foo" "bar". You asked me to prove it. That would require two things: first, showing that the complete expansion of the parse tree above does not include any further expr nodes (which I contend is obvious enough that it should not need to be explicitly spelled out in this thread), and second, showing that no other parse tree will generate "foo" "bar". >> If you believe otherwise, show a parse tree that parses these as >> separate expressions. > > Fallacies: Straw man, shifting the burden of proof. If there is a straw man here, it is only the result of one or both of us failing to communicate. Are you now saying that you agree that there is only one expr node in the parse of "foo" "bar"? If so, then why did you ask me to prove it? Why should the burden of proof be on me in the first place? I made the request because demonstrating the positive (such a parse tree exists) would, as usual, be much simpler than proving the negative (no such parse tree exists). In any case, it sounds to me like we're probably in agreement at this point. >>> But be warned: Neither would prove that a string literal is not an >>> expression. >> >> I've not claimed that a string literal is not an expression. > > Yes, you did. You debated my statement which says that. Let me refresh > your memory. I said: You are correct. I was reading "string literal" as STRING+ when I wrote that. I was perhaps confused because your statement "Neither would prove that a string literal is not an expression" did not make sense to me at the time. Within a grammar, the question of "is an X a Y" is nonsensical in isolation. It can only be answered in relation to a parse tree. Consider the simple grammar: S -> A | B A -> x B -> x Is x an A? It depends. If the tree that generates the x produces it from an A node, then yes. Otherwise, no. So when I write that the "foo" in "foo" "bar" is not an expression, I am only speaking in relation to the parse tree that generates "foo" "bar". I am not speaking about the parse tree that generates only "foo", because it is irrelevant, even though in that context it would be an expression. > | As I showed, string literals and consecutive tokens of string literals > | (“STRING+”) so as to do implicit concatenation *are* expressions of the > | Python grammar. > > To which you replied: > > | What the grammar that you quoted from shows is that STRING+ is an > | expression. The individual STRINGs of a STRING+ are not expressions, […] > ^^^^^^^ ^^^^^^^^^^^^^^^^^^^ > You continued with > > | except to the extent that they can be parsed in isolation as a STRING+. > > but that is nothing more than a backdoor, contradictory to what you said > before (and, as it has been showed, nonsensical). I don't know what you mean by a "backdoor". The purpose of that parenthetical was to explicitly acknowledge that the single STRING could be viewed as an expression when taken out of context, and to disclaim that I was excluding that case from the preceding statement. I still stand by that statement; The "foo" in "foo" "bar" is not an expression in the same sense that the "42" is not an expression in "hucr,.@#%c|42ptqc$". >> My claim is that a literal consisting of the implicit concatenation of >> more than one string token is can only be parsed as one expression, not >> several. > > Then you must have fundamentally misunderstood my statement and this whole > discussion. Quite possibly. Rereading the thread at the point where I jumped in, it's not clear to me now what it was in your post that I was responding to. >> Parsing "foo" "bar" >> >>> Because you did not consider the most simple variant of an AST >>> (or subtree) according to this grammar: >>> >>> expr >>> | >>> STRING >> >> Of course I did. This is again *exactly* what I was talking about in >> reference to parsing the individual strings in isolation. > > Actually, you were arguing against my statement that string literals are > expressions (that a string literal is an expression). You claimed, rather > explicitly, that they were not. See above. I have no idea what point you're trying to convey here. >> I'm quite familiar with basic concepts of EBNF. > > But apparently not logic. Are you intentionally trying to be inflammatory? I think that I have misunderstood your writing in places and that you have likewise misunderstood mine in others. Can we leave it at that? -- https://mail.python.org/mailman/listinfo/python-list