Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88108

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

Path csiph.com!usenet.pasdenom.info!bete-des-vosges.org!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'tree': 0.05; 'string': 0.09; '*is*': 0.09; 'claimed': 0.09; 'literal': 0.09; 'parsed': 0.09; 'parsing': 0.09; 'subject:Why': 0.09; 'variant': 0.09; 'python': 0.11; '"object': 0.16; '*node*': 0.16; 'ast': 0.16; 'did.': 0.16; 'expend': 0.16; 'expression,': 0.16; 'expression.': 0.16; 'expressions.': 0.16; 'literals': 0.16; 'literals.': 0.16; 'node,': 0.16; 'parser?': 0.16; 'subject: \n ': 0.16; 'subject:comment': 0.16; 'subject:quoted': 0.16; 'subject:simple': 0.16; 'subject:triple': 0.16; 'token,': 0.16; 'tuple': 0.16; 'language': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'written': 0.21; '>>>': 0.22; 'example': 0.22; 'otherwise,': 0.22; 'separate': 0.22; 'instead.': 0.24; 'parse': 0.24; 'looks': 0.24; '(or': 0.24; "i've": 0.25; 'this:': 0.26; 'second': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'consisting': 0.31; 'implicit': 0.31; 'so-called': 0.31; 'yes.': 0.31; 'checked': 0.32; 'languages': 0.32; 'quite': 0.32; '(e.g.': 0.33; 'comment': 0.34; 'noticed': 0.34; 'basic': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; "i'll": 0.36; 'subject:?': 0.36; 'effort': 0.37; 'two': 0.37; 'to:addr:python- list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'according': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'ian': 0.60; 'most': 0.60; 'entire': 0.61; 'strictly': 0.61; 'course': 0.61; 'simple': 0.61; 'show': 0.63; 'more': 0.64; 'taking': 0.65; 'skip:\xe2 10': 0.65; 'talking': 0.65; 'thomas': 0.65; 'subject:. ': 0.67; 'believe': 0.68; 'mar': 0.68; '26,': 0.68; 'goal': 0.75; '8bit%:46': 0.78; '2015': 0.84; 'nonsense.': 0.84; 'one*': 0.84; 'browsing': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=EE7apq4vg4twRnwP9HTkjBflSOMdSVSyF3FqDkSA7BY=; b=twZywmmyQTqOXdAtdw25b/1XS12fcGkdLTLV5i9Bd16ETdAQsUAvnMEIq7ayAGBJCu 7aTrHTdPw5uwC6ZP8rPQgATIbP0EOcGt0RnvU/jq5YSTwn82t6zFILjIhF9/KnrIMqeF MCbntyqB+emLZuxvr09In5ZV5EurN1aE2dKpfA+D10QmSk97YjnVc616u6Qd4jpraLID GCsGUHn463Bxdhv0R3pZwg78tFM3gFPOgslfRP+SZLC1s8PtcjtgUrMC417hbe1F32Oc EPWev+eMuAMtVHlhnqiuyZ2FqAPDvJHF4oii0I+bBzlyu+RrCbcmSUQEdPvkWqjVlxMr 8Qzg==
X-Received by 10.66.65.234 with SMTP id a10mr31376313pat.120.1427412461244; Thu, 26 Mar 2015 16:27:41 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <1823599.Pr2V0MPR6q@PointedEars.de>
References <f7b84d9d-c559-4711-ad63-1deea5f12c62@googlegroups.com> <med6mn$ag9$6@dont-email.me> <3533816.ZYnZ2OzjCs@PointedEars.de> <mailman.51.1426995416.10327.python-list@python.org> <3971951.908YQu3oQO@PointedEars.de> <mailman.52.1426997516.10327.python-list@python.org> <1504323.jUKfeKbQsP@PointedEars.de> <mailman.181.1427346636.10327.python-list@python.org> <2362875.FIK8ImHTJA@PointedEars.de> <mailman.211.1427394586.10327.python-list@python.org> <1823599.Pr2V0MPR6q@PointedEars.de>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 26 Mar 2015 17:27:00 -0600
Subject Re: A simple single line, triple-quoted comment is giving syntax error. Why?
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.223.1427412471.10327.python-list@python.org> (permalink)
Lines 74
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427412471 news.xs4all.nl 2960 [2001:888:2000:d::a6]:43128
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88108

Show key headers only | View raw


On Thu, Mar 26, 2015 at 12:54 PM, Thomas 'PointedEars' Lahn
<PointedEars@web.de> 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.
If you believe otherwise, show a parse tree that parses these as
separate expressions.

> 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. 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. 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.

> Again, “STRING+” does _not_ mean “STRING STRING STRING*”; it means “STRING
> STRING*”.  The second and following STRINGs are *optional*.

Please stop speaking down to me. I'm quite familiar with basic concepts of EBNF.

>>> […] 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.)

Yes.

>  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).

I was going to respond with a comment about how literals are a type of
expression, not token, using a literal tuple as an example of a
literal that is not a token. Then I checked the docs and noticed that
the language reference actually shies away from calling this a literal
and uses the phrase "container display" instead. Browsing through the
specifications of a few other languages (e.g. ECMAscript, which has
so-called "object literals"), they all seem to share the pattern of
using "literal" strictly to mean a type of token in their specs,
despite the word taking on a much broader meaning when writing
informally. So I'll have to concede that point as well.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A simple single line, triple-quoted comment is giving syntax error. Why? Aditya Raj Bhatt <adityarajbhatt@gmail.com> - 2015-03-18 10:46 -0700
  Re: A simple single line, triple-quoted comment is giving syntax error. Why? Laurent Pointal <laurent.pointal@laposte.net> - 2015-03-18 19:04 +0100
    Re: A simple single line, triple-quoted comment is giving syntax error. Why? Laurent Pointal <laurent.pointal@laposte.net> - 2015-03-18 19:06 +0100
      Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-18 20:53 +0100
        Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-18 20:56 +0100
        Re: A simple single line, triple-quoted comment is giving syntax error. Why? Terry Reedy <tjreedy@udel.edu> - 2015-03-18 17:47 -0400
        Re: A simple single line, triple-quoted comment is giving syntax error. Why? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-19 09:58 +1100
          Re: A simple single line, triple-quoted comment is giving syntax error. Why? Chris Angelico <rosuav@gmail.com> - 2015-03-19 10:23 +1100
    Re: A simple single line, triple-quoted comment is giving syntax error. Why? Aditya Raj Bhatt <adityarajbhatt@gmail.com> - 2015-03-18 11:23 -0700
      Re: A simple single line, triple-quoted comment is giving syntax error. Why? Igor Korot <ikorot01@gmail.com> - 2015-03-18 14:45 -0400
      Re: A simple single line, triple-quoted comment is giving syntax error. Why? Laurent Pointal <laurent.pointal@laposte.net> - 2015-03-18 20:08 +0100
      Re: A simple single line, triple-quoted comment is giving syntax error. Why? Tim Roberts <timr@probo.com> - 2015-03-28 16:34 -0700
  Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-18 21:21 +0100
  Re: A simple single line, triple-quoted comment is giving syntax error. Why? Tim Chase <python.list@tim.thechases.com> - 2015-03-18 13:15 -0500
  Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ben Finney <ben+python@benfinney.id.au> - 2015-03-19 11:06 +1100
  Re: A simple single line, triple-quoted comment is giving syntax error. Why? Denis McMahon <denismfmcmahon@gmail.com> - 2015-03-19 00:53 +0000
    Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-22 04:14 +0100
      Re: A simple single line, triple-quoted comment is giving syntax error. Why? Chris Angelico <rosuav@gmail.com> - 2015-03-22 14:36 +1100
        Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-22 04:49 +0100
          Re: A simple single line, triple-quoted comment is giving syntax error. Why? Chris Angelico <rosuav@gmail.com> - 2015-03-22 15:11 +1100
            Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-26 05:35 +0100
              Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-25 23:09 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-26 17:45 +0100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-26 12:29 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-26 19:54 +0100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-26 17:27 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-28 19:20 +0100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-29 01:56 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-29 12:41 +0200
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-31 01:23 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? sohcahtoa82@gmail.com - 2015-03-31 16:10 -0700
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Chris Angelico <rosuav@gmail.com> - 2015-04-01 10:36 +1100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-31 17:43 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-02 23:31 +0200
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? sohcahtoa82@gmail.com - 2015-04-02 15:26 -0700
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-02 18:21 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-03 16:40 +1100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Chris Angelico <rosuav@gmail.com> - 2015-04-03 16:57 +1100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Marko Rauhamaa <marko@pacujo.net> - 2015-04-03 10:13 +0300
                r"\"" ??? (was A simple single line, triple-quoted comment) Rustom Mody <rustompmody@gmail.com> - 2015-04-03 05:52 -0700
                Re: r"\"" ??? (was A simple single line, triple-quoted comment) Chris Angelico <rosuav@gmail.com> - 2015-04-04 01:40 +1100
                Re: r"\"" ??? (was A simple single line, triple-quoted comment) Rustom Mody <rustompmody@gmail.com> - 2015-04-03 08:14 -0700
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-03 09:25 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-03 00:40 -0600
                Re: A simple single line, triple-quoted comment is giving syntax   error. Why? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-03-27 11:43 +1300
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-28 19:06 +0100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-26 12:32 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-26 19:56 +0100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-27 10:15 +1100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Tim Chase <python.list@tim.thechases.com> - 2015-03-26 18:47 -0500
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-26 19:38 -0600
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 07:34 +0200
              Re: A simple single line, triple-quoted comment is giving syntax error. Why? Dave Angel <davea@davea.name> - 2015-03-26 01:23 -0400
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-26 18:25 +0100
                Re: A simple single line, triple-quoted comment is giving syntax error. Why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-26 18:30 +0100
          Re: A simple single line, triple-quoted comment is giving syntax error. Why? Marko Rauhamaa <marko@pacujo.net> - 2015-03-22 12:00 +0200

csiph-web