9 static struct tree* tree_malloc(int type);
23 %token <str> KW_PIPE KW_MAIL KW_COPY
24 %token '(' ')' '{' '}' ';'
28 %left <n> EQ NEQ GE LE '<' '>' RE NRE
51 input: /* empty */ { $$ = input_tree = NULL; }
52 | command input { $$ = tree_malloc(ST_BLOCK);
53 $$->pt.block.head = $1;
54 $$->pt.block.tail = $2;
60 command: ';' { $$ = tree_malloc(ST_EMPTY); }
61 | '{' command next '}' {
62 $$ = tree_malloc(ST_BLOCK);
63 $$->pt.block.head = $2;
64 $$->pt.block.tail = $3;
66 | '{' '}' { $$ = tree_malloc(ST_EMPTY); }
68 | ass ';' { $$ = $1; }
69 | arrow ';' { $$ = $1; }
74 next: /* empty */ {$$ = NULL; }
80 cif: KW_IF cond command KW_ELSE command {
81 $$ = tree_malloc(ST_IF);
86 | KW_IF cond command {
87 $$ = tree_malloc(ST_IF);
95 $$ = tree_malloc(ST_COND);
96 $$->pt.cond.left = $2;
97 $$->pt.cond.right = NULL;
102 $$ = tree_malloc(ST_COND);
103 $$->pt.cond.left = $1;
104 $$->pt.cond.right = $3;
109 $$ = tree_malloc(ST_COND);
110 $$->pt.cond.left = $1;
111 $$->pt.cond.right = $3;
116 $$ = tree_malloc(ST_COND);
117 $$->pt.cond.left = $1;
118 $$->pt.cond.right = $3;
122 | '(' cond ')' { $$ = $2; }
123 | ass_right rop ass_right {
124 $$ = tree_malloc(ST_COND);
125 $$->pt.cond.left = $1;
126 $$->pt.cond.right = $3;
143 $$ = tree_malloc(ST_ASS);
145 $$->pt.ass.left = tree_malloc(ST_LEAF);
146 $$->pt.ass.left->pt.leaf.type = L_VAR;
147 $$->pt.ass.left->pt.leaf.value.s = $1;
149 $$->pt.ass.right = $3;
154 $$ = tree_malloc(ST_LEAF);
155 $$->pt.leaf.type = L_NUM;
156 $$->pt.leaf.value.n = $1;
159 $$ = tree_malloc(ST_LEAF);
160 $$->pt.leaf.type = L_VAR;
161 $$->pt.leaf.value.s = $1;
164 $$ = tree_malloc(ST_LEAF);
165 $$->pt.leaf.type = L_CONST;
166 $$->pt.leaf.value.s = $1;
170 arrow: left ARROW right ass_right {
171 $$ = tree_malloc(ST_ARROW);
173 $$->pt.arrow.kw_left = $1;
174 $$->pt.arrow.kw_right = $3;
178 left: /* empty */ {$$=NULL;}
179 | KW_COPY { $$ = "copy"; }
183 right: /* empty */ {$$ = NULL; }
184 | KW_PIPE { $$ = "pipe"; }
185 | KW_MAIL { $$ = "mail"; }
189 | ass_right '.' ass_right {
190 $$ = tree_malloc(ST_OP);
193 $$->pt.op.right = $3;
200 tree_malloc(int type)
203 temp = xmalloc(sizeof (struct tree));
210 yyerror (char const *s)
212 fprintf (stderr, "Line %d: %s\n", line, s);