Browsable Python INDENT/DEDENT Grammar

CC-BY

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

Summary

Syntax

program ::=
	line*
line ::=
	tab_space* linetoken* indent? endofline+ dedent*
endofline ::=
	tab_space* comment? newline
indent ::=
	SP "INDENT"
dedent ::=
	"DEDENT" SP
tab_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

GrammarLabMaintained by Dr. Vadim Zaytsev a.k.a. @grammarware. Last updated in September 2015. []