8000 Accept a commented line at end of document · lezer-parser/python@7606e06 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7606e06

Browse files
committed
Accept a commented line at end of document
FIX: Fix an issue where a commented line at the end of the input would emit an error node. Closes #25
1 parent 2a7e8e3 commit 7606e06

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/python.grammar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ skw<term> { @extend[@name={term}]<identifier, term> }
270270
formatStringSpec { FormatSpec { ":" (formatStringSpecChars | nestedFormatReplacement)* } "}" }
271271

272272
blankLine {
273-
blankLineStart space? Comment? newline
273+
blankLineStart space? Comment? (newline | eof)
274274
}
275275
}
276276

test/statement.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,16 @@ Script(
261261
ExpressionStatement(VariableName))),
262262
ExpressionStatement(VariableName))
263263

264+
# Script ending in a comment
265+
266+
x = 1
267+
268+
# End
269+
270+
==>
271+
272+
Script(AssignStatement(VariableName,AssignOp,Number),Comment)
273+
264274
# Escaped newlines
265275

266276
x = 1 + \

0 commit comments

Comments
 (0)
0