8 static struct tree* tree_malloc(int type);
22 %token <str> KW_PIPE KW_MAIL KW_COPY
23 %token '(' ')' '{' '}' ';'
27 %left <n> EQ NEQ GE LE '<' '>' RE NRE
50 input: /* empty */ { $$ = input_tree = NULL; }
51 | command input { $$ = tree_malloc(ST_BLOCK);
52 $$->pt.block.head = $1;
53 $$->pt.block.tail = $2;
59 command: ';' { $$ = tree_malloc(ST_EMPTY); }
60 | '{' command next '}' {
61 $$ = tree_malloc(ST_BLOCK);
62 $$->pt.block.head = $2;
63 $$->pt.block.tail = $3;
65 | '{' '}' { $$ = tree_malloc(ST_EMPTY); }
67 | ass ';' { $$ = $1; }
68 | arrow ';' { $$ = $1; }
73 next: /* empty */ {$$ = NULL; }
79 cif: KW_IF cond command KW_ELSE command {
80 $$ = tree_malloc(ST_IF);
85 | KW_IF cond command {
86 $$ = tree_malloc(ST_IF);
94 $$ = tree_malloc(ST_COND);
95 $$->pt.cond.left = $2;
96 $$->pt.cond.right = NULL;
101 $$ = tree_malloc(ST_COND);
102 $$->pt.cond.left = $1;
103 $$->pt.cond.right = $3;
108 $$ = tree_malloc(ST_COND);
109 $$->pt.cond.left = $1;
110 $$->pt.cond.right = $3;
115 $$ = tree_malloc(ST_COND);
116 $$->pt.cond.left = $1;
117 $$->pt.cond.right = $3;
121 | '(' cond ')' { $$ = $2; }
122 | ass_right rop ass_right {
123 $$ = tree_malloc(ST_COND);
124 $$->pt.cond.left = $1;
125 $$->pt.cond.right = $3;
142 $$ = tree_malloc(ST_ASS);
144 $$->pt.ass.left = tree_malloc(ST_LEAF);
145 $$->pt.ass.left->pt.leaf.type = L_VAR;
146 $$->pt.ass.left->pt.leaf.value.s = $1;
148 $$->pt.ass.right = $3;
153 $$ = tree_malloc(ST_LEAF);
154 $$->pt.leaf.type = L_NUM;
155 $$->pt.leaf.value.n = $1;
158 $$ = tree_malloc(ST_LEAF);
159 $$->pt.leaf.type = L_VAR;
160 $$->pt.leaf.value.s = $1;
163 $$ = tree_malloc(ST_LEAF);
164 $$->pt.leaf.type = L_CONST;
165 $$->pt.leaf.value.s = $1;
169 arrow: left ARROW right ass_right {
170 $$ = tree_malloc(ST_ARROW);
172 $$->pt.arrow.kw_left = $1;
173 $$->pt.arrow.kw_right = $3;
177 left: /* empty */ {$$=NULL;}
178 | KW_COPY { $$ = "copy"; }
182 right: /* empty */ {$$ = NULL; }
183 | KW_PIPE { $$ = "pipe"; }
184 | KW_MAIL { $$ = "mail"; }
188 | ass_right '.' ass_right {
189 $$ = tree_malloc(ST_OP);
192 $$->pt.op.right = $3;
199 tree_malloc(int type)
202 temp = xmalloc(sizeof (struct tree));
209 yyerror (char const *s)
211 fprintf (stderr, "Line %d: %s\n", line, s);