Skip to content

Commit

Permalink
Pred: parse add pathspec patterns of the form 'add <PATTERN>'
Browse files Browse the repository at this point in the history
These are equivalent to the non prefixed patterns and are added only for
completeness.
  • Loading branch information
g-raud committed Mar 14, 2018
1 parent 3f543fb commit 05df1cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pred.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ let error_msg s =
Printf.sprintf "bad pattern: %s\n\
A pattern must be introduced by one of the following keywords:\n\
\032 Regex, Name, Path, BelowPath, NameString, String, BelowString\n\
\032 (or del <KEYWORD> or assoc <KEYWORD>)." s
\032 (or add <KEYWORD> or del <KEYWORD> or assoc <KEYWORD>)." s

let addPref = "add "
let delPref = "del "
let assocPref = "assoc "

Expand All @@ -58,6 +59,7 @@ let rec select_pattern str l err =
[] -> err str
| (pref, g)::r ->
if Util.startswith str pref then `Alt (rest pref g)
else if Util.startswith str (addPref^pref) then `Alt (rest (addPref^pref) g)
else if Util.startswith str (delPref^pref) then `Dif (rest (delPref^pref) g)
else if Util.startswith str (assocPref^pref) then `Nul (rest (assocPref^pref) g)
else select_pattern str r err
Expand Down
3 changes: 3 additions & 0 deletions src/pred.mli
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
Seven assoc only patterns "assoc <TYPE>" are also recognized that record the
associated string but do not set the preference for the paths matching the
given pattern.
Seven patterns "add <TYPE>" are also recognized that are equivalent to the
non prefixed patterns.
*)


Expand Down

0 comments on commit 05df1cd

Please sign in to comment.