| 1 | package Pegex::Parser::Indent; | ||
| 2 | |||
| 3 | # The indentation levels of consecutive lines are used to generate INDENT and | ||
| 4 | # DEDENT tokens, using a stack, as follows. Before the first line of the file | ||
| 5 | # is read, a single zero is pushed on the stack; this will never be popped off | ||
| 6 | # again. The numbers pushed on the stack will always be strictly increasing | ||
| 7 | # from bottom to top. At the beginning of each logical line, the line’s | ||
| 8 | # indentation level is compared to the top of the stack. If it is equal, | ||
| 9 | # nothing happens. If it is larger, it is pushed on the stack, and one INDENT | ||
| 10 | # token is generated. If it is smaller, it must be one of the numbers | ||
| 11 | # occurring on the stack; all numbers on the stack that are larger are popped | ||
| 12 | # off, and for each number popped off a DEDENT token is generated. At the end | ||
| 13 | # of the file, a DEDENT token is generated for each number remaining on the | ||
| 14 | # stack that is larger than zero. '' | ||
| 15 | |||
| 16 | 1 | 1; |