Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Python grammar support for string literal concatenation #536

@microbit-matt-hillsdon

Description

@microbit-matt-hillsdon

At least in this simple case, the Python grammar doesn't seem to support string literal concatenation, where adjacent string literals are valid and are concatenated at compile time to form a single string. The parser appears to be marking an error on the second string.

print('00300:'
      '03630:'
      '36963:'
      '03630:'
      '00300')

Parse tree:

Script(ExpressionStatement(CallExpression(VariableName,ArgList("(",String,⚠))),ExpressionStatement(String),ExpressionStatement(String),ExpressionStatement(String),ExpressionStatement(String,⚠(")")))

A Python session showing the behaviour:

Python 3.9.0 (default, Dec  2 2020, 10:34:08) 
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('00300:'
...       '03630:'
...       '36963:'
...       '03630:'
...       '00300')
00300:03630:36963:03630:00300

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions