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 = tree_malloc(ST_EMPTY); }
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 */ {$$ = tree_malloc(ST_EMPTY); }
79 cif: KW_IF cond command KW_ELSE command {
80 $$ = tree_malloc(ST_IF);
85 | KW_IF cond command {
86 $$ = tree_malloc(ST_IF);
89 $$->pt.tif.e = tree_malloc(ST_EMPTY);
94 $$ = tree_malloc(ST_COND);
95 $$->pt.cond.left = $2;
96 $$->pt.cond.right = NULL;
98 $$->pt.cond.type = OP_BOOL;
101 $$ = tree_malloc(ST_COND);
102 $$->pt.cond.left = $1;
103 $$->pt.cond.right = $3;
105 $$->pt.cond.type = OP_BOOL;
108 $$ = tree_malloc(ST_COND);
109 $$->pt.cond.left = $1;
110 $$->pt.cond.right = $3;
112 $$->pt.cond.type = OP_BOOL;
115 $$ = tree_malloc(ST_COND);
116 $$->pt.cond.left = $1;
117 $$->pt.cond.right = $3;
119 $$->pt.cond.type = OP_BOOL;
122 | '(' cond ')' { $$ = $2; }
123 | ass_right rop ass_right {
124 $$ = tree_malloc(ST_COND);
125 $$->pt.cond.left = $1;
126 $$->pt.cond.right = $3;
128 $$->pt.cond.type = OP_REL;
144 $$ = tree_malloc(ST_ASS);
146 $$->pt.ass.left = tree_malloc(ST_LEAF);
147 $$->pt.ass.left->pt.leaf.type = L_VAR;
148 $$->pt.ass.left->pt.leaf.value = $1;
150 $$->pt.ass.right = $3;
155 $$ = tree_malloc(ST_LEAF);
156 $$->pt.leaf.type = L_VAR;
157 $$->pt.leaf.value = $1;
160 $$ = tree_malloc(ST_LEAF);
161 $$->pt.leaf.type = L_CONST;
162 $$->pt.leaf.value = $1;
166 arrow: left ARROW right ass_right {
167 $$ = tree_malloc(ST_ARROW);
169 $$->pt.arrow.kw_left = $1;
170 $$->pt.arrow.kw_right = $3;
174 left: /* empty */ { $$ = NULL;}
175 | KW_COPY { $$ = "copy"; }
179 right: /* empty */ { $$ = NULL; }
180 | KW_PIPE { $$ = "pipe"; }
181 | KW_MAIL { $$ = "mail"; }
185 | ass_right '.' ass_right {
186 $$ = tree_malloc(ST_OP);
189 $$->pt.op.right = $3;
196 tree_malloc(int type)
199 temp = xmalloc(sizeof (struct tree));
206 yyerror (char const *s)
208 fprintf (stderr, "Line %d: %s\n", line, s);