Layout-sensitive parsing

Combinators for layout-sensitive parsing. They relies on line and colun tracking, and should be used with proper get_col function passed to Parser.parse(), e.g. the one that is passed by reparsec.scannerless.parse() or reparsec.lexer.parse().

reparsec.layout.block(parser)

Applies parser with column mark set to current column.

Parameters:

parser (ParseObj[TypeVar(S), TypeVar(A)]) – Parser

Return type:

TupleParser[TypeVar(S), TypeVar(A)]

reparsec.layout.aligned(parser)

Applies parser if column mark is equal to current column, otherwise fails.

Parameters:

parser (ParseObj[TypeVar(S), TypeVar(A)]) – Parser

Return type:

TupleParser[TypeVar(S), TypeVar(A)]

reparsec.layout.indented(delta, parser)

If current column is greater than column mark by delta, applies parser with column mark set to current column, otherwise fails.

Parameters:
  • delta (int) – Indentation size in columns

  • parser (ParseObj[TypeVar(S), TypeVar(A)]) – Parser

Return type:

TupleParser[TypeVar(S), TypeVar(A)]