diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-10-26 09:44:47 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-10-26 09:44:47 -0700 |
commit | 094d3c76925cf6c05a8bfcc112849627d16279b8 (patch) | |
tree | 2ee67380e480241b8d89427493d794704783387e /sys/cmd/rc/syntax.y | |
parent | 3733507b090311b70ca8a2fed0c739b808f679c6 (diff) |
feat(rc): added index operations
Diffstat (limited to 'sys/cmd/rc/syntax.y')
-rw-r--r-- | sys/cmd/rc/syntax.y | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/cmd/rc/syntax.y b/sys/cmd/rc/syntax.y index 2e7e1da..f3c9f29 100644 --- a/sys/cmd/rc/syntax.y +++ b/sys/cmd/rc/syntax.y @@ -27,7 +27,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> Tfor Tin Twhile Tif Telse Tswitch Ttwiddle Tbang Tsubshell Tfunc; -%type<tree> Tword Tredir Tpipe; +%type<tree> Tword Tredir Tpipe Tdup; /* grammar */ @@ -107,11 +107,14 @@ executable: nonkeyword: Tword -| '$' atom { $$ = maketree1('$', $2); } -| '(' wordsnl ')' { $$ = $2; } -| Tcount atom { $$ = maketree1(Tcount, $2); } -| Tjoin atom { $$ = maketree1(Tjoin, $2); } -//| '`' block { $$ = maketree1('`', $2); } +| '$' atom { $$ = maketree1('$', $2); } +| '$' atom Tindex words ')' { $$ = maketree2(Tindex, $2, $4); } +| '(' wordsnl ')' { $$ = $2; } +| Tcount atom { $$ = maketree1(Tcount, $2); } +| Tjoin atom { $$ = maketree1(Tjoin, $2); } +| '`' block { $$ = maketree1('`', $2); } +//| '(' words ')' { $$ = maketree1(Tparen, $2); } +//| Tredir block { $$ = hangchild1($1, $2, 0); $$->type = Tpipefd; } keyword: Tin|Tfor|Twhile|Tif|Telse|Tswitch|Tbang|Tsubshell|Tfunc |