3 ms·
The trick used by some parsec parsers is interesting. Instead of trying to keep track of balanced indents and unindents, they just check the intent of the first
by piinbinary 7y ago
The trick used by some parsec parsers is interesting. Instead of trying to keep track of balanced indents and unindents, they just check the intent of the first token of a statement. If it's not the "right" indent, the parse fails. When that happens, it usually ends the current block and tries again with the next indent level. It's not that inefficient because the backtracking happens on the first token of the statement.
https://hackage.haskell.org/package/indents https://hackage.haskell.org/package/indents