IndentationSensitiveLanguages

Indentation obviously requires the ability to count and to remember some counters.

Definition

An indentation sensitive grammar is defined by

where

Ct0 := epsilon
Ctn+1 := Ctn t

Example

Let's consider a simplified language that has a statement requiring nesting a (e.g. a while-statement), a simple statement b (e.g. assignment), and a symbol for indentation t (e.g. \t). We may generate a program by the following grammar:

S -> Ct0 E

Ctn E -> Ctn E Ctn E | Ctn N | Ctn b | epsilon

Ctn N -> Ctn a Ctn+1 E