From 70d9a1a8b26957ef5772f634346bccfa1dee8811 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 13 Jul 2015 15:26:04 +0300 Subject: [PATCH 15/15] Shellvars: allow && and || constructs after command --- lenses/shellvars.aug | 10 +++++++--- lenses/tests/test_shellvars.aug | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug index 00c6846..0f7c907 100644 --- a/lenses/shellvars.aug +++ b/lenses/shellvars.aug @@ -97,14 +97,17 @@ module Shellvars = . Util.del_str "return" . ( Util.del_ws_spc . store Rx.integer )? - let condition = + let cond_actions= let action (operator:string) (lbl:string) = [ Sep.opt_space . Util.del_str operator . Sep.opt_space . label lbl . sto_to_semicol ] - in let cond (start:string) (end:string) = [ label "type" . store start ] + in ( action "&&" "@and" | action "||" "@or" )* + + let condition = + let cond (start:string) (end:string) = [ label "type" . store start ] . Util.del_ws_spc . sto_to_semicol . Util.del_ws_spc . Util.del_str end - . ( action "&&" "@and" | action "||" "@or" )* + . cond_actions in Util.indent . label "@condition" . (cond "[" "]" | cond "[[" "]]") let command = @@ -114,6 +117,7 @@ module Shellvars = . [ key key_re . eq . store anyquot . Sep.space . del /(\\\\\n[ \t]*)?/ "" ]* . store (word - reserved_key - /zzz/) . [ Sep.space . label "@arg" . sto_to_semicol]? + . cond_actions (************************************************************************ * Group: CONDITIONALS AND LOOPS diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug index 4f52205..00f3aad 100644 --- a/lenses/tests/test_shellvars.aug +++ b/lenses/tests/test_shellvars.aug @@ -628,6 +628,14 @@ bar" } { "@arg" = "arg1 arg2" } } + (* Allow && and || constructs after command *) + test Shellvars.lns get "foo bar && baz || quux\n" = + { "@command" = "foo" + { "@arg" = "bar" } + { "@and" = "baz" } + { "@or" = "quux" } + } + (* Local Variables: *) (* mode: caml *) (* End: *) -- 2.1.0