#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include "umpf.h"
static struct tree* tree_malloc(int type);
+static enum var_type get_var_type(char* var);
%}
%error-verbose
$$->pt.ass.left = tree_malloc(ST_LEAF);
$$->pt.ass.left->pt.leaf.type = L_VAR;
$$->pt.ass.left->pt.leaf.value = $1;
- $$->pt.ass.left->pt.leaf.n = find_var($1, var_hash);
+ $$->pt.ass.left->pt.leaf.n = find_var($1, get_var_type($1), var_hash);
$$->pt.ass.right = $3;
}
;
$$ = tree_malloc(ST_LEAF);
$$->pt.leaf.type = L_VAR;
$$->pt.leaf.value = $1;
- $$->pt.leaf.n = find_var($1, var_hash);
+ $$->pt.leaf.n = find_var($1, get_var_type($1), var_hash);
}
| CONST {
$$ = tree_malloc(ST_LEAF);
return temp;
}
+enum var_type
+get_var_type(char* var)
+{
+ int upper = 0;
+ int lower = 0;
+
+ if (islower(*var))
+ return VAR_USER;
+
+ while (*var) {
+ if (isupper(*var))
+ upper++;
+ if (islower(*var))
+ lower++;
+ var++;
+ }
+ if (upper && lower)
+ return VAR_HEADER;
+
+ return VAR_INTERN;
+}
+
void
yyerror (char const *s)
{
- fprintf (stderr, "Line %d: %s\n", line, s);
+ fprintf (stderr, "Line %d: %s\n Saving your e-mail to default mailbox %s\n",
+ line, s, default_mailbox);
+ longjmp(env, 1);
}