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 = $1;
148 $$->pt.ass.right = $3;
153 $$ = tree_malloc(ST_LEAF);
154 $$->pt.leaf.type = L_VAR;
155 $$->pt.leaf.value = $1;
158 $$ = tree_malloc(ST_LEAF);
159 $$->pt.leaf.type = L_CONST;
160 $$->pt.leaf.value = $1;
164 arrow: left ARROW right ass_right {
165 $$ = tree_malloc(ST_ARROW);
167 $$->pt.arrow.kw_left = $1;
168 $$->pt.arrow.kw_right = $3;
172 left: /* empty */ {$$=NULL;}
173 | KW_COPY { $$ = "copy"; }
177 right: /* empty */ {$$ = NULL; }
178 | KW_PIPE { $$ = "pipe"; }
179 | KW_MAIL { $$ = "mail"; }
183 | ass_right '.' ass_right {
184 $$ = tree_malloc(ST_OP);
187 $$->pt.op.right = $3;
194 tree_malloc(int type)
197 temp = xmalloc(sizeof (struct tree));
204 yyerror (char const *s)
206 fprintf (stderr, "Line %d: %s\n", line, s);