philomena/lib/search/bool_parser.ex

19 lines
392 B
Elixir
Raw Normal View History

2019-11-02 19:34:25 +01:00
defmodule Search.BoolParser do
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
defparsec :parse, bool
end