Open megakilo opened 8 months ago
The Elm equivalent works fine
parens = Parser.succeed (\v -> v) |. Parser.symbol "(" |= expr |. Parser.symbol ")"
term = Parser.oneOf
[ Parser.int
, parens
]
expr = Parser.succeed (\x y -> x + y) |= Parser.lazy (\_ -> term) |. Parser.symbol "+" |= Parser.lazy (\_ -> term)
main =
"1+(2+3)"
|> Parser.run expr
|> Debug.toString
|> text
I think it's related to the compiler bug here https://github.com/roc-lang/roc/issues/4288
I have this mini parser for add expression. But compiler overflows due to the recursive structure. I saw
lazy
seems to be the solution for this but can't figure out why it doesn't work.