Georg Brandl added the comment:
This grammar specification doesn't contain a full specification of code that won't raise SyntaxError. There are several conditions that aren't checked by the generated parser, but at a later stage in the compilation process.
While probably possible to express in general, this would make the grammar much more complex. For this example, it would require different definitions of `suite`, `stmt`, `simple_stmt`, `compound_stmt` and so on, to track where control-flow statements are allowed. Other definitions need to track `nonlocal` and you'd get a combinatorial explosion of productions.
You could propose a PR to add a note somewhere on that page (but on the master branch, not 3.6 which is unmaintained).
----------
nosy: +georg.brandl
_______________________________________
Python tracker
https://bugs.python.org/issue42284
_______________________________________