3 ms·
Its not that hard to implement some form of whitespace sensitive parsing, you need to maintain explicit state, essentially a stack and a number of combinators.
by orbifold 12y ago
Its not that hard to implement some form of whitespace sensitive parsing, you need to maintain explicit state, essentially a stack and a number of combinators. See for example
https://github.com/purescript/purescript/blob/master/src/Language/PureScript/Parser/Common.hs https://github.com/purescript/purescript/blob/master/src/Lan...
The state is defined in
https://github.com/purescript/purescript/blob/master/src/Language/PureScript/Parser/State.hs https://github.com/purescript/purescript/blob/master/src/Lan...
(its just the column number). I believe the whitespace rules for Haskell are somewhat subtle, but shouldn't be much harder.
- purescript 12y agoI tried to change the whitespace rules in the PureScript parser to match Haskell recently (to support explicit braces), and it proved to be very difficult. The "L" function which is defined in the Haskell 98 Report depends heavily on an interaction between the lexer and parser, in which a failed parse causes the indenter to behave differently in the lexer. For this reason, I stayed with the simpler rules that we have now, and I plan to support explicit braces in the parser instead.