Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: A simple single line, triple-quoted comment is giving syntax error. Why? Date: Fri, 27 Mar 2015 11:43:29 +1300 Lines: 59 Message-ID: References: <3533816.ZYnZ2OzjCs@PointedEars.de> <3971951.908YQu3oQO@PointedEars.de> <1504323.jUKfeKbQsP@PointedEars.de> <2362875.FIK8ImHTJA@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ksjagpu+cz31cU1+alWCpQnHZdS7m0jfIrsU5s2hWGSzOiYYN8 Cancel-Lock: sha1:Wj87BBmt+dbkjYC8FPpMdYsEYho= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:88105 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 Not quite -- STRING+ is not a symbol in the grammar, it's a shorthand for a combination of symbols. The parse tree is actually just expr / \ STRING STRING > Not like this: > > expr > | > STRING+ > / \ > expr expr > | | > STRING STRING That would be > expr > / \ > expr expr > | | > STRING STRING Thomas 'PointedEars' Lahn wrote: > Prove it. To get a parse tree like the above, there would need to be a production like this in the grammar: expr ::= expr+ There is no such production, so that parse tree is impossible. QED. What you seem to be doing in your mind is taking this production: expr ::= STRING and using it "backwards" to justify expanding any occurrence of STRING into expr. But grammars don't work that way. You're committing a logical fallacy: just because some exprs are STRINGs doesn't mean that all STRINGs are exprs. -- Greg