Skip to content

[New] Parse raw, byte and formatted strings #512

@Thirumalai-Shaktivel

Description

@Thirumalai-Shaktivel

Example 1:

print(f"{__file__} executed in {elapsed:0.2f} seconds.")

Error:

$ lpython --show-ast --new-parser examples/expr2.py
syntax error: Token '"{__file__} executed in {elapsed:0.2f} seconds."' (of type 'string') is unexpected here
 --> examples/expr2.py:1:8
  |
1 | print(f"{__file__} executed in {elapsed:0.2f} seconds.")
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 


Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that needs to be fixed).

Example 2:

b"I made it!"

Error:

$ lpython --show-ast --new-parser examples/expr2.py
syntax error: Token '"I made it!"' (of type 'string') is unexpected here
 --> examples/expr2.py:1:2
  |
1 | b"I made it!"
  |  ^^^^^^^^^^^^ 


Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that needs to be fixed).

Example 3:

r"""
Text
"""

Error:

$ lpython --show-ast --new-parser examples/expr2.py
syntax error: Token '"""
Text
"""' (of type 'string') is unexpected here
 --> examples/expr2.py:1:2 - 3:3
  |
1 |    r"""
  |     ^^^...
...
  |
3 |    """
  | ...^^^ 


Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that needs to be fixed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    ParserIssues or improvements related to parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions