|
|
@@ -36,6 +36,8 @@
|
|
|
char *psave;
|
|
|
|
|
|
__arch_templ static int new_var(char *p, struct arch *);
|
|
|
+__arch_templ static int set_name(char *p, struct arch *);
|
|
|
+__arch_templ static int math_set_name(char *p, struct arch *);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -65,7 +67,9 @@ __arch_templ int arch_do_keyword(char *p, struct arch *arch_fn) {
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- exit(generic_error("unknown keyword", psave, lno));
|
|
|
+ if (set_name(p, arch_fn))
|
|
|
+ if (math_set_name(p, arch_fn))
|
|
|
+ exit(generic_error("unknow keyword", psave, lno));
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
@@ -133,3 +137,87 @@ __arch_templ static int new_var(char *p, struct arch *arch_fn) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+static int set_name(char *p, struct arch *arch_fn) {
|
|
|
+ char *name;
|
|
|
+ int type, out;
|
|
|
+
|
|
|
+ getword(p, &type, &out);
|
|
|
+
|
|
|
+ if (type != WORDTYPE_NAME)
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ name = strndup(p, out);
|
|
|
+
|
|
|
+ p += out;
|
|
|
+ _skip_spaces(p);
|
|
|
+
|
|
|
+ getword(p, &type, &out);
|
|
|
+
|
|
|
+ if (type != WORDTYPE_KWORD || out != '=')
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ p++;
|
|
|
+ _skip_spaces(p);
|
|
|
+
|
|
|
+ getword(p, &type, &out);
|
|
|
+
|
|
|
+ if (type != WORDTYPE_NR)
|
|
|
+ exit(generic_error("a number required", psave, lno));
|
|
|
+
|
|
|
+
|
|
|
+ arch_fn->arch_set_var(name, out, 0);
|
|
|
+
|
|
|
+ free(name);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/* 9 -> a; */
|
|
|
+
|
|
|
+static int math_set_name(char *p, struct arch *arch_fn) {
|
|
|
+ char *name;
|
|
|
+ int type, out, nr;
|
|
|
+
|
|
|
+ getword(p, &type, &out);
|
|
|
+
|
|
|
+ if (type != WORDTYPE_NR)
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ nr = out;
|
|
|
+
|
|
|
+ /* this requires a space */
|
|
|
+ _skip_word(p);
|
|
|
+ getword(p, &type, &out);
|
|
|
+
|
|
|
+ if (type != WORDTYPE_KWORD || out != '-')
|
|
|
+ exit(generic_error("a '->' required", psave, lno));
|
|
|
+
|
|
|
+ p++;
|
|
|
+ getword(p, &type, &out);
|
|
|
+
|
|
|
+ if (type != WORDTYPE_KWORD || out != '>')
|
|
|
+ exit(generic_error("a '->' required", psave, lno));
|
|
|
+
|
|
|
+ p++;
|
|
|
+ _skip_spaces(p);
|
|
|
+
|
|
|
+ getword(p, &type, &out);
|
|
|
+
|
|
|
+ if (type != WORDTYPE_NAME)
|
|
|
+ exit(generic_error("a name required", psave, lno));
|
|
|
+
|
|
|
+ name = strndup(p, out);
|
|
|
+
|
|
|
+ arch_fn->arch_set_var(name, nr, 0);
|
|
|
+
|
|
|
+ free(name);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|