rc: add subshell-function syntax
fn foo @{bar} is now equivalent to fn foo {@{bar}}. As a side effect, this disallows creating functions named after keywords without first quoting them.
This commit is contained in:
parent
b542dce430
commit
2f8a59f4b5
1 changed files with 7 additions and 3 deletions
|
@ -17,7 +17,7 @@
|
||||||
struct tree *tree;
|
struct tree *tree;
|
||||||
};
|
};
|
||||||
%type<tree> line paren brace body cmdsa cmdsan assign epilog redir
|
%type<tree> line paren brace body cmdsa cmdsan assign epilog redir
|
||||||
%type<tree> cmd simple first word comword keyword words
|
%type<tree> cmd simple first word comword keyword words comwords
|
||||||
%type<tree> NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN
|
%type<tree> NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN
|
||||||
%type<tree> WORD REDIR DUP PIPE
|
%type<tree> WORD REDIR DUP PIPE
|
||||||
%%
|
%%
|
||||||
|
@ -68,8 +68,10 @@ cmd: {$$=0;}
|
||||||
| assign cmd %prec BANG {$$=mung3($1, $1->child[0], $1->child[1], $2);}
|
| assign cmd %prec BANG {$$=mung3($1, $1->child[0], $1->child[1], $2);}
|
||||||
| BANG cmd {$$=mung1($1, $2);}
|
| BANG cmd {$$=mung1($1, $2);}
|
||||||
| SUBSHELL cmd {$$=mung1($1, $2);}
|
| SUBSHELL cmd {$$=mung1($1, $2);}
|
||||||
| FN words brace {$$=tree2(FN, $2, $3);}
|
| FN comwords brace {$$=tree2(FN, $2, $3);}
|
||||||
| FN words {$$=tree1(FN, $2);}
|
| FN comwords SUBSHELL brace
|
||||||
|
{$$=tree2(FN, $2, mung1($3, $4));}
|
||||||
|
| FN comwords {$$=tree1(FN, $2);}
|
||||||
simple: first
|
simple: first
|
||||||
| simple word {$$=tree2(ARGLIST, $1, $2);}
|
| simple word {$$=tree2(ARGLIST, $1, $2);}
|
||||||
| simple redir {$$=tree2(ARGLIST, $1, $2);}
|
| simple redir {$$=tree2(ARGLIST, $1, $2);}
|
||||||
|
@ -90,3 +92,5 @@ comword: '$' word {$$=tree1('$', $2);}
|
||||||
keyword: FOR|IN|WHILE|IF|NOT|TWIDDLE|BANG|SUBSHELL|SWITCH|FN
|
keyword: FOR|IN|WHILE|IF|NOT|TWIDDLE|BANG|SUBSHELL|SWITCH|FN
|
||||||
words: {$$=(struct tree*)0;}
|
words: {$$=(struct tree*)0;}
|
||||||
| words word {$$=tree2(WORDS, $1, $2);}
|
| words word {$$=tree2(WORDS, $1, $2);}
|
||||||
|
comwords: {$$=(struct tree*)0;}
|
||||||
|
| comwords comword {$$=tree2(WORDS, $1, $2);}
|
||||||
|
|
Loading…
Reference in a new issue