diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-10-20 13:10:54 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-10-20 13:10:54 -0700 |
commit | 888679027c2e9b43d1485d970df8170ac4fda29f (patch) | |
tree | f46c257e6be1f47f4aa69d31a64643c76457a64b /sys/cmd/rc/syntax.y | |
parent | 6d50d5b97d49a74a8faf587ec2bbf234626adf0c (diff) |
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.
Diffstat (limited to 'sys/cmd/rc/syntax.y')
-rw-r--r-- | sys/cmd/rc/syntax.y | 42 |
1 files changed, 24 insertions, 18 deletions
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<tree> line cmds cmdsln body paren block ifbody assign; -%type<tree> cmd basic executable nonkeyword keyword word words wordsnl atom arg args; -%type<tree> Tbang Tsubshell Tindex; -%type<tree> Tword Tif Telse; +%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> 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 |