diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-10-21 13:28:25 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-10-21 13:28:25 -0700 |
commit | da77d3be2eb0785bc0c0b60c686e163d6243c744 (patch) | |
tree | 75f15d89c1517bf0ba82128753fd0f6c4d3d2447 /sys/cmd/rc/syntax.y | |
parent | 65193a54609c558e473118dba323edc001bdb585 (diff) |
feat(rc): added andand and oror operators
Diffstat (limited to 'sys/cmd/rc/syntax.y')
-rw-r--r-- | sys/cmd/rc/syntax.y | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sys/cmd/rc/syntax.y b/sys/cmd/rc/syntax.y index b486484..2e7e1da 100644 --- a/sys/cmd/rc/syntax.y +++ b/sys/cmd/rc/syntax.y @@ -1,6 +1,6 @@ -%token Tword Twords Tif Telse Tbang Tsubshell -%token Toror Tandand There Tredir Tpipe Tdup -%token Tbasic Tparen Tblock Targs Tindex +%token Tfor Tin Twhile Tif Telse Tswitch Ttwiddle Tbang Tsubshell Tfunc +%token Tredir Tdup Tpipe Tindex +%token Tbasic Targs Tword Twords Tparen Tblock %define parse.error verbose @@ -12,8 +12,8 @@ %} /* operator precendence: lowest first */ -%left Twhile Telse -%left '\n' +%left Tif Tfor Tswitch ')' Twhile Telse +%left Tandand Toror '\n' %left Tbang Tsubshell %left Tpipe; %left '^'; @@ -26,7 +26,7 @@ } %type<tree> line cmds cmdsln body paren block ifbody assign epilog redir; %type<tree> cmd basic executable nonkeyword keyword word words wordsnl atom; -%type<tree> Tbang Tsubshell Tif Telse; +%type<tree> Tfor Tin Twhile Tif Telse Tswitch Ttwiddle Tbang Tsubshell Tfunc; %type<tree> Tword Tredir Tpipe; /* grammar */ @@ -80,11 +80,13 @@ cmd: | basic { $$ = maketree1(Tbasic, $1); } | block epilog { $$ = hangepilog($1, $2); } | cmd Tpipe nl cmd { $$ = hangchild2($2, $1, 0, $4, 1); } +| cmd Tandand nl cmd { $$ = maketree2(Tandand, $1, $4); } +| cmd Toror nl cmd { $$ = maketree2(Toror, $1, $4); } | redir cmd %prec Tbang { $$ = hangchild1($1, $2, 1); } | assign cmd %prec Tbang { $$ = hangchild1($1, $2, 2); } -| Tif paren nl ifbody { $$ = hangchild1($2, $1, 0); } | Tbang cmd { $$ = maketree1(Tbang, $2); } | Tsubshell cmd { $$ = maketree1(Tsubshell, $2); } +| Tif paren nl ifbody { $$ = hangchild1($2, $1, 0); } basic: executable @@ -112,7 +114,7 @@ nonkeyword: //| '`' block { $$ = maketree1('`', $2); } keyword: - Tif|Telse|Tbang|Tsubshell + Tin|Tfor|Twhile|Tif|Telse|Tswitch|Tbang|Tsubshell|Tfunc words: /* empty */ { $$ = nil; } |