|
@@ -38,6 +38,7 @@ char *psave;
|
|
|
__arch_templ static int new_var(char *p, struct arch *);
|
|
__arch_templ static int new_var(char *p, struct arch *);
|
|
|
__arch_templ static int set_name(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 *);
|
|
__arch_templ static int math_set_name(char *p, struct arch *);
|
|
|
|
|
+__arch_templ static int check_condition(char *p, struct arch *);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -67,9 +68,8 @@ __arch_templ int arch_do_keyword(char *p, struct arch *arch_fn) {
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
default:
|
|
|
- if (set_name(p, arch_fn))
|
|
|
|
|
- if (math_set_name(p, arch_fn))
|
|
|
|
|
- exit(generic_error("unknow keyword", psave, lno));
|
|
|
|
|
|
|
+ if (set_name(p, arch_fn) + math_set_name(p, arch_fn) + check_condition(p, arch_fn) == 0)
|
|
|
|
|
+ exit(generic_error("unknow keyword", psave, lno));
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -144,7 +144,7 @@ static int set_name(char *p, struct arch *arch_fn) {
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
if (type != WORDTYPE_NAME)
|
|
if (type != WORDTYPE_NAME)
|
|
|
- return 1;
|
|
|
|
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
name = strndup(p, out);
|
|
name = strndup(p, out);
|
|
|
|
|
|
|
@@ -154,7 +154,7 @@ static int set_name(char *p, struct arch *arch_fn) {
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
if (type != WORDTYPE_KWORD || out != '=')
|
|
if (type != WORDTYPE_KWORD || out != '=')
|
|
|
- return 1;
|
|
|
|
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
p++;
|
|
p++;
|
|
|
_skip_spaces(p);
|
|
_skip_spaces(p);
|
|
@@ -169,7 +169,7 @@ static int set_name(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
free(name);
|
|
free(name);
|
|
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
|
+ return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -184,7 +184,7 @@ static int math_set_name(char *p, struct arch *arch_fn) {
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
if (type != WORDTYPE_NR)
|
|
if (type != WORDTYPE_NR)
|
|
|
- return 1;
|
|
|
|
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
nr = out;
|
|
nr = out;
|
|
|
|
|
|
|
@@ -215,9 +215,77 @@ static int math_set_name(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
free(name);
|
|
free(name);
|
|
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
|
+ return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+/* # a - 10
|
|
|
|
|
+ * a : 10 {
|
|
|
|
|
+ * # = 1
|
|
|
|
|
+ * 1: xxx;
|
|
|
|
|
+ * # = 2
|
|
|
|
|
+ * 2: yyy;
|
|
|
|
|
+ * # = 4
|
|
|
|
|
+ * 4: zzz;
|
|
|
|
|
+ * } */
|
|
|
|
|
+
|
|
|
|
|
+static int check_condition(char *p, struct arch *arch_fn) {
|
|
|
|
|
+ struct condition cond;
|
|
|
|
|
+ int type, out;
|
|
|
|
|
+
|
|
|
|
|
+ getword(p, &type, &out);
|
|
|
|
|
+
|
|
|
|
|
+ if (type == WORDTYPE_NR) {
|
|
|
|
|
+ cond.nra = out;
|
|
|
|
|
+
|
|
|
|
|
+ _skip_word(p);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else if (type == WORDTYPE_NAME) {
|
|
|
|
|
+ cond.namea = strndup(p, out);
|
|
|
|
|
+
|
|
|
|
|
+ p += out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else
|
|
|
|
|
+ return 0;
|
|
|
|
|
+
|
|
|
|
|
+ _skip_spaces(p);
|
|
|
|
|
+
|
|
|
|
|
+ getword(p, &type, &out);
|
|
|
|
|
+
|
|
|
|
|
+ getword(p, &type, &out);
|
|
|
|
|
+
|
|
|
|
|
+ if (type != WORDTYPE_KWORD || out != ':')
|
|
|
|
|
+ return 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ p++;
|
|
|
|
|
+ _skip_spaces(p);
|
|
|
|
|
+
|
|
|
|
|
+ getword(p, &type, &out);
|
|
|
|
|
+
|
|
|
|
|
+ if (type == WORDTYPE_NR) {
|
|
|
|
|
+ cond.nrb = out;
|
|
|
|
|
+
|
|
|
|
|
+ _skip_word(p);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else if (type == WORDTYPE_NAME) {
|
|
|
|
|
+ cond.nameb = strndup(p, out);
|
|
|
|
|
+
|
|
|
|
|
+ p += out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else
|
|
|
|
|
+ return 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ printf("condition: %d %d %s %s\n",
|
|
|
|
|
+ cond.nra, cond.nrb,
|
|
|
|
|
+ cond.namea, cond.nameb);
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|