A simple single line, triple-quoted comment is giving syntax error. Why?
Thomas 'PointedEars' Lahn
PointedEars at web.de
Thu Mar 26 13:25:47 EDT 2015
Dave Angel wrote:
[Fixed quotation]
> On 03/26/2015 01:09 AM, Ian Kelly wrote:
>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>> <https://docs.python.org/3/reference/lexical_analysis.html#string->>>>>> literal-concatenation>
>>
>> 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+. By the same token, a STRING+ is a single string literal, not
>> an aggregate of several.
>
> That's the way I also read the BNF.
Then I am afraid you need to refresh your knowledge of formal grammars.
> But something I cannot find in that chapter of the reference is the
> definition of STRING+
You *definitely* need to refresh your knowledge of formal grammars.
“STRING+” in this flavor of _E_BNF is – rather obviously – equivalent to
<multiple-string> ::= <STRING> <STRING>*
<STRING> ::= '"' <no-unescaped-doublequote>* '"'
| "'" <no-unescaped-singlequote>* "'"
| '"""' <no-triple-doublequote>* '"""'
| "'''" <no-triple-singlequote>* "'''"
in BNF and
multiple-string = STRING *STRING
STRING = '"' *no-unescaped-doublequote '"'
/ "'" *no-unescaped-singlequote '"'
/ '"""' *no-unescaped-triple-doublequote '"""'
/ "'''" *no-unescaped-triple-singlequote "'''"
in ABNF. I suspect that in this flavor of EBNF the definition of STRING
looks similar to the following:
STRING: ('"' no_unescaped_doublequote* '"'
| "'" no_unescaped_singlequote* "'"
| '"""' no_unescaped_triple_doublequote* '"""'
| "'''" no_unescaped_triple_singlequote* "'''")
Definition of the still undefined goal symbols is left as an exercise to the
reader.
--
PointedEars
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
More information about the Python-list
mailing list