summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-03-31 18:49:18 (GMT)
committerGuido van Rossum <guido@python.org>1992-03-31 18:49:18 (GMT)
commitaf82141bb6ca0ac4728df76184634e947a7cc2e4 (patch)
treef372f5994d8c7bd1c4243926ed3c67fb658490b0 /Grammar
parent14f43cf5dc0dffca22e4cbd3989928cc39e43014 (diff)
downloadcpython-af82141bb6ca0ac4728df76184634e947a7cc2e4.zip
cpython-af82141bb6ca0ac4728df76184634e947a7cc2e4.tar.gz
cpython-af82141bb6ca0ac4728df76184634e947a7cc2e4.tar.bz2
Tighten syntax for try statements
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar3
1 files changed, 2 insertions, 1 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 84f2898..24dc70e 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -92,7 +92,8 @@ compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
while_stmt: 'while' test ':' suite ['else' ':' suite]
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
-try_stmt: 'try' ':' suite (except_clause ':' suite)* ['finally' ':' suite]
+try_stmt: 'try' ':' suite (except_clause ':' suite)+ | 'try' ':' suite 'finally' ':' suite
+# NB compile.c makes sure that the default except clause is last
except_clause: 'except' [test [',' test]]
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT