Skip to content

[New] Parse Comments after and inside Multiline statements #509

Closed
@Thirumalai-Shaktivel

Description

@Thirumalai-Shaktivel

Example 1:

def test():
    print()

# Comment

Error:

$ lpython --show-ast --new-parser examples/expr2.py
syntax error: Token '# Comment
' (of type 'comment') is unexpected here
 --> examples/expr2.py:4:1
  |
4 | # Comment
  | ^^^^^^^^^^ 


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:

def main():
    print()
    # Comment

Error:

$ lpython --show-ast --new-parser examples/expr2.py
syntax error: End of file is unexpected here
 --> examples/expr2.py:5:1
  |
5 | 
  | ^ 


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:

def main():
    print()
# Comment
    return
$ lpython --show-ast --new-parser examples/expr2.py
syntax error: Token '# Comment
' (of type 'comment') is unexpected here
 --> examples/expr2.py:3:1
  |
3 | # Comment
  | ^^^^^^^^^^ 


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