16 struct variable* next;
22 struct variable** res;
24 res = xmalloc (HASHSIZE * sizeof(struct variable*));
25 memset(res, 0, sizeof(struct variable*)*HASHSIZE);
31 get_bucket_number(char* name)
34 unsigned char* p = name;
44 /* value NULL for finding without modyfiing */
45 static struct variable*
46 find_var(char* name, char* value, struct variable** hash)
51 n = get_bucket_number(name);
54 while(p && strcmp(p->name,name))
62 p = xmalloc(sizeof(struct variable));
63 p->next = hash[n]->next;
65 p->name = xstrdup(name);
68 p->value = xstrdup(value);
74 print_ind(int num, char c)
78 for (i = 0; i < num; i++){
81 //printf("%*s", num, "");
85 regex_cmp(char* s, char* r)
90 int ovector[OVECCOUNT];
92 brum = pcre_compile(r,0,&error,&erroroffset,NULL);
96 int res = pcre_exec(brum,NULL,s,strlen(s),0,0,ovector,OVECCOUNT);
103 print_tree(struct tree* t, int ind)
112 print_tree(t->pt.tif.c,ind+1);
115 print_tree(t->pt.tif.i,ind+1);
118 print_tree(t->pt.tif.e,ind+1);
121 #define UPPER(a) ((a) >> 8)
122 #define LOWER(a) ((a) & 0xFF)
123 print_tree(t->pt.cond.left, ind+1);
126 if (UPPER(t->pt.cond.op) > 0)
127 putchar(UPPER(t->pt.cond.op));
128 putchar(LOWER(t->pt.cond.op));
130 print_tree(t->pt.cond.right, ind+1);
133 print_tree(t->pt.block.head,ind);
134 print_tree(t->pt.block.tail,ind);
137 print_tree(t->pt.ass.left, ind+1);
140 print_tree(t->pt.ass.right, ind+1);
144 switch (t->pt.leaf.type){
148 puts(t->pt.leaf.value);
153 if (t->pt.arrow.kw_left){
154 print_ind(ind+1, ' ');
155 puts(t->pt.arrow.kw_left);
159 if (t->pt.arrow.kw_right){
160 print_ind(ind+1, ' ');
161 puts(t->pt.arrow.kw_right);
163 print_tree(t->pt.arrow.s,ind+1);
166 print_tree(t->pt.op.left, ind+1);
168 putchar(t->pt.op.op);
170 print_tree(t->pt.op.right, ind+1);
180 interp(struct tree* t)
187 interp(t->pt.block.head);
188 interp(t->pt.block.tail);
191 // find_name(t->pt.ass.left->pt.leaf.value.s, interp_ass_right(t->pt.ass.right), var_hash);