aboutsummaryrefslogtreecommitdiffstats
path: root/syntax.y
diff options
context:
space:
mode:
Diffstat (limited to 'syntax.y')
-rw-r--r--syntax.y20
1 files changed, 12 insertions, 8 deletions
diff --git a/syntax.y b/syntax.y
index a53537a..7f6745e 100644
--- a/syntax.y
+++ b/syntax.y
@@ -2,6 +2,7 @@
2#include "cmd.h" 2#include "cmd.h"
3#include "lex.yy.c" 3#include "lex.yy.c"
4#include <stdio.h> 4#include <stdio.h>
5
5%} 6%}
6 7
7%union { 8%union {
@@ -65,16 +66,19 @@ separator:
65part: 66part:
66 part WORD { 67 part WORD {
67 $$ = $1; 68 $$ = $1;
68 $$->argc++; 69 argInsert($$, $2, false);
69 $$->args = realloc($$->args, ($$->argc + 1) * sizeof(char *));
70 $$->args[$$->argc - 1] = $2;
71 $$->args[$$->argc] = NULL;
72 } 70 }
73 | WORD { 71 | WORD {
74 $$ = newCmd(); 72 $$ = newCmd();
75 $$->args = malloc(2 * sizeof(char *)); 73 argInsert($$, $1, false);
76 $$->args[$$->argc++] = $1; 74 }
77 $$->args[$$->argc] = NULL; 75 | part STRING {
76 $$ = $1;
77 argInsert($$, $2, true);
78 }
79 | STRING {
80 $$ = newCmd();
81 argInsert($$, $1, true);
78 } 82 }
79 | part REDIRECT_IN WORD { 83 | part REDIRECT_IN WORD {
80 $$ = $1; 84 $$ = $1;
@@ -99,4 +103,4 @@ part:
99 } 103 }
100 ; 104 ;
101 105
102%% 106%% \ No newline at end of file