Skip to content
Snippets Groups Projects
Commit 16d4ef51 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

Merge remote-tracking branch 'odcinek/pep-3104'

parents 3cb30193 d3cfd7c7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -91,6 +91,7 @@ GROUP_SPACE_AFTER = BOTH + (
"RAISE",
"EXEC",
"GLOBAL",
"NONLOCAL",
"PRINT",
"INDENT",
"WHILE",
Loading
Loading
Loading
Loading
@@ -132,6 +132,7 @@ def generate_parse(print_function):
@pg.production("small_stmt : assert_stmt")
@pg.production("small_stmt : raise_stmt")
@pg.production("small_stmt : global_stmt")
@pg.production("small_stmt : nonlocal_stmt")
@pg.production("compound_stmt : if_stmt")
@pg.production("compound_stmt : while_stmt")
@pg.production("compound_stmt : for_stmt")
Loading
Loading
Loading
Loading
@@ -235,6 +235,16 @@ def include_primivites(pg, print_function):
}
 
 
@pg.production("nonlocal_stmt : NONLOCAL names")
def nonlocal_stmt(pack):
(token, names) = pack
return {
"type": "nonlocal",
"formatting": token.hidden_tokens_after,
"value": names,
}
@pg.production("names : NAME")
def names_name(pack):
(name,) = pack
Loading
Loading
Loading
Loading
@@ -504,7 +504,11 @@ nodes_rendering_order = {
("formatting", "second_formatting", "as"),
("key", "as", "as"),
],
"nonlocal": [
("constant", "nonlocal", True),
("formatting", "formatting", True),
("list", "value", True),
],
"del": [
("constant", "del", True),
("formatting", "formatting", True),
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ from .utils import BaronError
class UnknowItem(BaronError):
pass
 
KEYWORDS = ("and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "exec", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "not", "or", "pass", "print", "raise", "return", "try", "while", "with", "yield")
KEYWORDS = ("and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "exec", "finally", "for", "from", "global", "nonlocal", "if", "import", "in", "is", "lambda", "not", "or", "pass", "print", "raise", "return", "try", "while", "with", "yield")
 
TOKENS = (
(r'[a-zA-Z_]\w*', 'NAME'),
Loading
Loading
Loading
Loading
@@ -2548,6 +2548,18 @@ def test_global_two():
])
 
 
def test_nonlocal():
"global a"
group([
('NONLOCAL', 'nonlocal'),
('SPACE', ' '),
('NAME', 'a'),
], [
('NONLOCAL', 'nonlocal', [], [('SPACE', ' ')]),
('NAME', 'a'),
])
def test_print():
"print"
group([
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment