From 888679027c2e9b43d1485d970df8170ac4fda29f Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 20 Oct 2021 13:10:54 -0700 Subject: Refactored interactivity to track with thread. Hit a bit of a stopping point. Specifically, the way XAsync runs currently is by forking the execution context and having the child run the async code while the parent runs the remainder. The problem with this architecture is it doesn't interact well with job control. When we fork, we create a new process group. Thus the Xasync fork becomes the new leader. In short, our traversal of the parse tree as to be less "preorder" and more "in order", i.e. from the leaves up. The "left" command of the pipeline should be the "leader" of the process group. --- sys/cmd/rc/syntax.y | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'sys/cmd/rc/syntax.y') diff --git a/sys/cmd/rc/syntax.y b/sys/cmd/rc/syntax.y index 6334819..cb4a174 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 Targs Tindex -%token Tbasic Tparen Tblock +%token Toror Tandand There Tredir Tpipe Tdup +%token Tbasic Tparen Tblock Targs Tindex %define parse.error verbose @@ -12,20 +12,21 @@ %} /* operator precendence: lowest first */ -%left Twhile Telse -%left '\n' -%left Tbang Tsubshell +%left Twhile Telse +%left '\n' +%left Tbang Tsubshell +%left Tpipe; %right '$' Tcount Tflat -%right Tindex +%left Tindex /* semantic types */ %union{ struct Tree *tree; } -%type line cmds cmdsln body paren block ifbody assign; -%type cmd basic executable nonkeyword keyword word words wordsnl atom arg args; -%type Tbang Tsubshell Tindex; -%type Tword Tif Telse; +%type line cmds cmdsln body paren block ifbody assign epilog redir; +%type cmd basic executable nonkeyword keyword word words wordsnl atom; +%type Tbang Tsubshell Tif Telse; +%type Tword Tredir Tpipe; /* grammar */ @@ -65,10 +66,20 @@ ifbody: assign: executable '=' word { $$ = maketree2('=', $1, $3); } +redir: + Tdup +| Tredir word { $$ = hangchild1($1, $2, 0); } + +epilog: +/* empty */ { $$ = nil; } +| redir epilog { $$ = hangchild1($1, $2, 1); } + cmd: /* empty */ %prec Twhile { $$ = nil; } | basic { $$ = maketree1(Tbasic, $1); } -| block +| block epilog { $$ = hangepilog($1, $2); } +| cmd Tpipe nl cmd { $$ = hangchild2($2, $1, 0, $4, 1); } +| 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); } @@ -76,13 +87,8 @@ cmd: basic: executable -| basic word { $$ = maketree2(Targs, $1, $2); } - -arg: word - -args: - arg -| args arg { $$ = maketree2(Targs, $1, $2); } +| basic word { $$ = maketree2(Targs, $1, $2); } +| basic redir { $$ = maketree2(Targs, $1, $2); } atom: nonkeyword -- cgit v1.2.1