You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
term : Parser Utf8 U64
term = alt digits (lazy (\_ -> expr) |> between (codeunit '(') (codeunit ')'))
expr : Parser Utf8 U64
expr = const (\x -> \y -> x + y) |> apply (lazy \_ -> term) |> skip (codeunit '+') |> apply (lazy \_ -> term)
expect parseStr expr "1+2" == Ok 3u64
expect parseStr expr "1+(1+2)" == Ok 4u64
The text was updated successfully, but these errors were encountered:
megakilo
changed the title
How to use lazy?
lazy not working for recursive parser
Feb 2, 2024
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.The text was updated successfully, but these errors were encountered: