philomena/lib/search/bool_parser.ex
2020-01-10 23:20:19 -05:00

19 lines
394 B
Elixir

defmodule Search.BoolParser do
import NimbleParsec
space =
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
|> ignore()
bool =
choice([
string("true"),
string("false")
])
|> repeat(space)
|> unwrap_and_tag(:bool)
|> eos()
|> label("a boolean, like `true' or `false'")
defparsec(:parse, bool)
end