
Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: python/indentation/cordy/extracted
Source used for this grammar: James R. Cordy, Program to explicate standard Python INDENT/DEDENT symbols, November 2008
program, line, endofline, indent, dedent, tab_space, linetoken, nonblank_token, compound, compoundtoken, compoundtokensquare, compoundtokenround), 1 root (program), 0 top (—), 6 bottom (newline 4, space, comment 4, SP 2, token, tab).program ::=
lineline ::= tab_space linetoken indent endofline dedent
endofline ::= tab_space comment newline
indent ::=
SP "INDENT"dedent ::=
"DEDENT" SPtab_space ::= tab space
linetoken ::= tab_space nonblank_token
nonblank_token ::= compound token
compound ::= "{" compoundtoken "}" "[" compoundtokensquare "]" "(" compoundtokenround ")"
compoundtoken ::= linetoken newline comment
compoundtokensquare ::= linetoken newline comment
compoundtokenround ::= linetoken newline comment