Results / elm-parser /
ParserLazyTest
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 msOutput
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 msOutput
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 msOutput
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 msOutput
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"