Changeset 17b2b6ad680b…
Parent ab91a87e0efb…
by Hao Lian <hao@fogcreek.com>
Changes to 2 files · Browse files at 17b2b6ad680b Showing diff from parent ab91a87e0efb Diff from another changeset...
@@ -27,8 +27,16 @@
exception ParseError of string
+(* Utilities *)
let pipeline (f, a) = f a
+let findFilter = function
+ | "author" -> Author
+ | "file" -> File
+ | "project" -> Project
+ | "repo" -> Repo
+ | _ -> raise <| Exception "Invalid filter name"
+(* Parsers *)
let word = many1Satisfy <| fun c -> c <> ' '
let phraseEscape = pchar '\\' >>. pchar '"'
let phraseInnard = phraseEscape <|> noneOf "\""
@@ -37,17 +45,10 @@let keyword = (phrase |>> Phrase) <|> (word |>> Word)
let filterName = ["author"; "file"; "project"; "repo"] |> Seq.map pstring |> choice
-let findFilter = function
- | "author" -> Author
- | "file" -> File
- | "project" -> Project
- | "repo" -> Repo
- | _ -> raise <| Exception "Invalid filter name"
-
let filter =
(filterName |>> findFilter)
.>> (pchar ':')
- .>>. (phrase <|> word)
+ .>>. (phrase <|> word <?> "filter argument")
|>> pipeline
let atom = (filter |>> FilterAtom) <|> (keyword |>> KeywordAtom)
|
Loading...