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 */
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.s);
151 printf("%d\n",t->pt.leaf.value.n);
156 if (t->pt.arrow.kw_left){
157 print_ind(ind+1, ' ');
158 puts(t->pt.arrow.kw_left);
162 if (t->pt.arrow.kw_right){
163 print_ind(ind+1, ' ');
164 puts(t->pt.arrow.kw_right);
166 print_tree(t->pt.arrow.s,ind+1);
169 print_tree(t->pt.op.left, ind+1);
171 putchar(t->pt.op.op);
173 print_tree(t->pt.op.right, ind+1);
183 interp(struct tree* t)
190 interp(t->pt.block.head);
191 interp(t->pt.block.tail);