aboutsummaryrefslogtreecommitdiffstats
path: root/syntax.y
diff options
context:
space:
mode:
Diffstat (limited to 'syntax.y')
-rw-r--r--syntax.y23
1 files changed, 17 insertions, 6 deletions
diff --git a/syntax.y b/syntax.y
index 5f33c9a..a53537a 100644
--- a/syntax.y
+++ b/syntax.y
@@ -12,7 +12,7 @@
12} 12}
13 13
14%token <str> WORD STRING error FD_REDIRECT 14%token <str> WORD STRING error FD_REDIRECT
15%token NEWLINE PIPE AND OR REDIRECT_IN REDIRECT_OUT BACKGROUND 15%token NEWLINE PIPE AND OR REDIRECT_IN REDIRECT_OUT BACKGROUND LPAREN RPAREN APPEND
16 16
17%type <cmd> line command part runcommand 17%type <cmd> line command part runcommand
18%type <cmdType> separator 18%type <cmdType> separator
@@ -32,10 +32,13 @@ line:
32runcommand: 32runcommand:
33 command NEWLINE { 33 command NEWLINE {
34 $$ = $1; 34 $$ = $1;
35 runcmd($$); 35 runCmd($$);
36 showPrompt();
37 }
38 | NEWLINE {
39 $$ = NULL;
36 showPrompt(); 40 showPrompt();
37 } 41 }
38 | NEWLINE { $$ = NULL; }
39 ; 42 ;
40 43
41command: 44command:
@@ -43,11 +46,14 @@ command:
43 $$ = $1; 46 $$ = $1;
44 } 47 }
45 | part separator command { 48 | part separator command {
46 $$ = newcmd(); 49 $$ = newCmd();
47 $$->type = $2; 50 $$->type = $2;
48 $$->left = $1; 51 $$->left = $1;
49 $$->right = $3; 52 $$->right = $3;
50 } 53 }
54 | LPAREN command RPAREN {
55 $$ = $2;
56 }
51 ; 57 ;
52 58
53separator: 59separator:
@@ -65,7 +71,7 @@ part:
65 $$->args[$$->argc] = NULL; 71 $$->args[$$->argc] = NULL;
66 } 72 }
67 | WORD { 73 | WORD {
68 $$ = newcmd(); 74 $$ = newCmd();
69 $$->args = malloc(2 * sizeof(char *)); 75 $$->args = malloc(2 * sizeof(char *));
70 $$->args[$$->argc++] = $1; 76 $$->args[$$->argc++] = $1;
71 $$->args[$$->argc] = NULL; 77 $$->args[$$->argc] = NULL;
@@ -78,9 +84,14 @@ part:
78 $$ = $1; 84 $$ = $1;
79 $$->redirectFile[1] = $3; 85 $$->redirectFile[1] = $3;
80 } 86 }
87 | part APPEND WORD {
88 $$ = $1;
89 $$->redirectFile[1] = $3;
90 $$->redirectFD[1] = -1;
91 }
81 | part FD_REDIRECT { 92 | part FD_REDIRECT {
82 $$ = $1; 93 $$ = $1;
83 $$->redirectFD[$2[0]-'0']=$2[3]-'0'; 94 $$->redirectFD[$2[0] - '0'] = $2[3] - '0';
84 } 95 }
85 | part BACKGROUND { 96 | part BACKGROUND {
86 $$ = $1; 97 $$ = $1;