philomena/lib/philomena_query/parse/bool_parser.ex

22 lines
428 B
Elixir
Raw Normal View History

defmodule PhilomenaQuery.Parse.BoolParser do
@moduledoc false
2019-11-02 19:34:25 +01:00
import NimbleParsec
2019-11-15 19:27:10 +01:00
space =
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
|> ignore()
2019-11-02 19:34:25 +01:00
bool =
choice([
string("true"),
string("false")
])
2019-11-15 19:27:10 +01:00
|> repeat(space)
2019-11-02 19:34:25 +01:00
|> unwrap_and_tag(:bool)
|> eos()
2019-11-02 21:31:55 +01:00
|> label("a boolean, like `true' or `false'")
2019-11-02 19:34:25 +01:00
2020-01-11 05:20:19 +01:00
defparsec(:parse, bool)
end