summaryrefslogtreecommitdiff
path: root/Grammar
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-09-08 20:50:03 -0700
committerYury Selivanov <yury@magic.io>2016-09-08 20:50:03 -0700
commitf8cb8a16a344ab208fd46876c4b63604987347b8 (patch)
treec44caa48291401d1e1e388004d2762513ac88c93 /Grammar
parent09ad17810c38d1aaae02de69084dd2a8ad9f5cdb (diff)
downloadcpython-git-f8cb8a16a344ab208fd46876c4b63604987347b8.tar.gz
Issue #27985: Implement PEP 526 -- Syntax for Variable Annotations.
Patch by Ivan Levkivskyi.
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar5
1 files changed, 3 insertions, 2 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 9e4979e3a1..1478d768b7 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -45,12 +45,13 @@ stmt: simple_stmt | compound_stmt
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |
import_stmt | global_stmt | nonlocal_stmt | assert_stmt)
-expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |
+expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
('=' (yield_expr|testlist_star_expr))*)
+annassign: ':' test ['=' test]
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
'<<=' | '>>=' | '**=' | '//=')
-# For normal assignments, additional restrictions enforced by the interpreter
+# For normal and annotated assignments, additional restrictions enforced by the interpreter
del_stmt: 'del' exprlist
pass_stmt: 'pass'
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt