Elm Exactly
Results / elm-parser /

ParserLazyTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks that `Parser.lazy` lets a parser refer to itself, by matching nested parentheses.

`parens` matches `(`, then either another `parens` or nothing, then `)`.
`"((()))"` parses successfully.

Results

elm-0.19.1

passran in 56 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
nested: True

elm-0.19.2

passran in 45 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
nested: True

elm-0.19.3

passran in 42 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
nested: True

lamdera-1.5.0

passran in 61 ms
Output
nested: True

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-parser/ParserLazyTest] in its title.

Source

The -- CHECK: lines give the expected output.

module ParserLazyTest exposing (main)
{-| Checks that `Parser.lazy` lets a parser refer to itself, by matching nested parentheses.
`parens` matches `(`, then either another `parens` or nothing, then `)`.
`"((()))"` parses successfully.
-}
-- CHECK: nested: True
import Html exposing (text)
import Parser exposing ((|.))
parens : Parser.Parser ()
parens =
Parser.succeed ()
|. Parser.symbol "("
|. Parser.oneOf
[ Parser.lazy (\_ -> parens)
, Parser.succeed ()
]
|. Parser.symbol ")"
main =
let
result = Parser.run parens "((()))"
_ = Debug.log "nested"
(case result of
Ok _ -> True
Err _ -> False
)
in
text "done"