From 094d3c76925cf6c05a8bfcc112849627d16279b8 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 26 Oct 2021 09:44:47 -0700 Subject: feat(rc): added index operations --- sys/cmd/rc/syntax.y | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sys/cmd/rc/syntax.y') 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 line cmds cmdsln body paren block ifbody assign epilog redir; %type cmd basic executable nonkeyword keyword word words wordsnl atom; %type Tfor Tin Twhile Tif Telse Tswitch Ttwiddle Tbang Tsubshell Tfunc; -%type Tword Tredir Tpipe; +%type 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 -- cgit v1.2.1