pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/lezer-parser/python/commit/793b7a016816af6578207cac6c144ea11f187500

rossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> Allow newlines inside argument and parameter lists · lezer-parser/python@793b7a0 · GitHub
Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 793b7a0

Browse files
committed
Allow newlines inside argument and parameter lists
FIX: Fix a bug that caused newlines to be disallowed in argument and parameter lists. Issue codemirror/dev#536
1 parent 8ed0598 commit 793b7a0

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/python.grammar

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ Decorator { At dottedName ArgList? newline }
2222

2323
FunctionDefinition {
2424
kw<"async">? kw<"def"> VariableName
25-
ParamList { "(" commaSep<param>? ")" }
25+
ParamList
2626
TypeDef { "->" test }?
2727
Body
2828
}
2929

30+
ParamList { "(" commaSep<param>? ")" }
31+
3032
ClassDefinition { kw<"class"> VariableName ArgList? Body }
3133

3234
param { VariableName TypeDef? (AssignOp{"="} test)? | "*" VariableName? | "**" VariableName | "/" }

src/tokens.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {ExternalTokenizer, ContextTracker} from "lezer"
22
import {
33
newline as newlineToken, eof, newlineEmpty, newlineBracketed, indent, dedent, printKeyword,
4-
ParenthesizedExpression, TupleExpression, ComprehensionExpression, ArrayExpression, ArrayComprehensionExpression,
4+
ParenthesizedExpression, TupleExpression, ComprehensionExpression,
5+
ArrayExpression, ArrayComprehensionExpression, ArgList, ParamList,
56
DictionaryExpression, DictionaryComprehensionExpression, SetExpression, SetComprehensionExpression
67
} from "./parser.terms.js"
78

89
const newline = 10, carriageReturn = 13, space = 32, tab = 9, hash = 35, parenOpen = 40, dot = 46
910

1011
const bracketed = [
1112
ParenthesizedExpression, TupleExpression, ComprehensionExpression, ArrayExpression, ArrayComprehensionExpression,
12-
DictionaryExpression, DictionaryComprehensionExpression, SetExpression, SetComprehensionExpression
13+
DictionaryExpression, DictionaryComprehensionExpression, SetExpression, SetComprehensionExpression, ArgList, ParamList
1314
]
1415

1516
let cachedIndent = 0, cachedInput = null, cachedPos = 0

test/expression.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ Script(ExpressionStatement(ContinuedString(String, String)),
3333
ExpressionStatement(String),
3434
ExpressionStatement(String))
3535

36+
# Bracketed continued string
37+
38+
print('00300:'
39+
'03630:')
40+
41+
==>
42+
43+
Script(ExpressionStatement(CallExpression(VariableName, ArgList(ContinuedString(String, String)))))
44+
45+
3646
# Format strings
3747

3848
f'hello{22} abc {{ }} {d-1}'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy