philomena/lib/search/bool_parser.ex
2019-11-15 13:27:10 -05:00

19 lines
No EOL
392 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