12 void yyerror (char const *);
14 int regex_cmp(char* s, char* r);
15 struct tree* tree_malloc(int type);
75 %token KW_PIPE KW_MAIL KW_COPY
76 %token '(' ')' '{' '}' ';'
80 %left <n> EQ NEQ GE LE '<' '>' RE NRE
98 input: /* empty */ { $$ = NULL }
99 | command input { $$ = tree_malloc(ST_BLOCK);
100 $$->pt.block.head = $1;
101 $$->pt.block.tail = $2;
105 command: ';' { $$ = tree_malloc(ST_EMPTY); }
106 | '{' command next '}' {
107 $$ = tree_malloc(ST_BLOCK);
108 $$->pt.block.head = $2;
109 $$->pt.block.tail = $3;
111 | '{' '}' { $$ = NULL }
118 next: /* empty */ {$$ = NULL}
124 cif: KW_IF cond command KW_ELSE command {
125 $$ = tree_malloc(ST_IF);
130 | KW_IF cond command {
131 $$ = tree_malloc(ST_IF);
139 $$ = tree_malloc(ST_COND);
140 $$->pt.cond.left = $2;
141 $$->pt.cond.right = NULL;
146 $$ = tree_malloc(ST_COND);
147 $$->pt.cond.left = $1;
148 $$->pt.cond.right = $3;
153 $$ = tree_malloc(ST_COND);
154 $$->pt.cond.left = $1;
155 $$->pt.cond.right = $3;
160 $$ = tree_malloc(ST_COND);
161 $$->pt.cond.left = $1;
162 $$->pt.cond.right = $3;
166 | '(' cond ')' { $$ = $2; }
167 | ass_right rop ass_right {
168 $$ = tree_malloc(ST_COND);
169 $$->pt.cond.left = $1;
170 $$->pt.cond.right = $3;
187 $$ = tree_malloc(ST_ASS);
189 $$->pt.ass.left = tree_malloc(ST_LEAF);
190 $$->pt.ass.left->pt.leaf.type = L_VAR;
191 $$->pt.ass.left->pt.leaf.value.s = $1;
193 $$->pt.ass.right = $3;
198 $$ = tree_malloc(ST_LEAF);
199 $$->pt.leaf.type = L_NUM;
200 $$->pt.leaf.value.n = $1;
203 $$ = tree_malloc(ST_LEAF);
204 $$->pt.leaf.type = L_VAR;
205 $$->pt.leaf.value.s = $1;
208 $$ = tree_malloc(ST_LEAF);
209 $$->pt.leaf.type = L_CONST;
210 $$->pt.leaf.value.s = $1;
218 tree_malloc(int type)
221 temp = xmalloc(sizeof (struct tree));
228 regex_cmp(char* s, char* r)
233 int ovector[OVECCOUNT];
235 brum = pcre_compile(r,0,&error,&erroroffset,NULL);
239 int res = pcre_exec(brum,NULL,s,strlen(s),0,0,ovector,OVECCOUNT);
246 yyerror (char const *s)
248 fprintf (stderr, "%s\n", s);