diff options
author | Arun Isaac | 2021-02-27 23:52:43 +0530 |
---|---|---|
committer | Arun Isaac | 2021-02-27 23:52:43 +0530 |
commit | e6235229aa0d471b14fcdbf92a60cafb3467f275 (patch) | |
tree | 2ed5b15ae9f3d178b88dbd3b8d1044f93cdf587b | |
parent | c37a8e33f790b385ec1f913b062ad5b5f4bbe96e (diff) | |
download | ccwl-e6235229aa0d471b14fcdbf92a60cafb3467f275.tar.gz ccwl-e6235229aa0d471b14fcdbf92a60cafb3467f275.tar.lz ccwl-e6235229aa0d471b14fcdbf92a60cafb3467f275.zip |
Rewrite parse-command using break-pair.
* ccwl/ccwl.scm (parse-command): Rewrite using break-pair.
-rw-r--r-- | ccwl/ccwl.scm | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 0d261d6..afcb176 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -100,25 +100,16 @@ last element of LST, PRED is passed that element alone." "Parse ARGS, a list of command line arguments and return two lists---the base command and the actual arguments." (let ((base-command arguments - (break (match-lambda - ((arg next) - (and (string? arg) - (string-prefix? "-" arg) - (input? next)))) - (map list args (drop args 1))))) - (values (append (map (match-lambda - ((arg next) arg)) - base-command) - (if (input? (last args)) - (list) - (take-right args 1))) - (parse-arguments - (append (map (match-lambda - ((arg next) arg)) - arguments) - (if (input? (last args)) - (take-right args 1) - (list))))))) + (break-pair (case-lambda + ((arg next) + (and (string? arg) + (string-prefix? "-" arg) + (input? next))) + ((last-arg) + (input? last-arg))) + args))) + (values base-command + (parse-arguments arguments)))) (define (input->tree input) "Convert INPUT, an <input> object, to a tree." |