summary refs log tree commit diff
path: root/lisc/parse.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-07-30 21:58:52 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:29 -0400
commit390045cae16053d6bd1ff3bd914038ab9df89a62 (patch)
treecd7411b7cd8f3063cfd742cb07c376500cdcb299 /lisc/parse.c
parent92be2fdd177503e315ae433b30bdc1c0c21faf38 (diff)
downloadroux-390045cae16053d6bd1ff3bd914038ab9df89a62.tar.gz
compress parsref code a little
Diffstat (limited to 'lisc/parse.c')
-rw-r--r--lisc/parse.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/lisc/parse.c b/lisc/parse.c
index 9f66382..6c6765d 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -275,36 +275,28 @@ varref(char *v)
 static Ref
 parseref()
 {
-	int64_t val;
-	char *label;
-	int i, ty;
+	int i;
+	Const c;
 
 	switch (next()) {
 	case TVar:
 		return varref(tokval.str);
 	case TNum:
-		ty = CNum;
-		val = tokval.num;
-		label = "";
-		for (i=0; i<ncst; i++)
-			if (cst[i].type == CNum)
-			if (cst[i].val == val)
-				return CONST(i);
-		goto New;
+		c = (Const){.type = CNum, .val = tokval.num};
+		strcpy(c.label, "");
+	if (0) {
 	case TAddr:
-		ty = CAddr;
-		val = 0;
-		label = tokval.str;
+		c = (Const){.type = CAddr, .val = 0};
+		strcpy(c.label, tokval.str);
+	}
 		for (i=0; i<ncst; i++)
-			if (cst[i].type == CAddr)
-			if (strcmp(cst[i].label, label) == 0)
+			if (cst[i].type == c.type
+			&& cst[i].val == c.val
+			&& strcmp(cst[i].label, c.label) == 0)
 				return CONST(i);
-	New:
 		if (i >= NCst)
 			err("too many constants");
-		cst[i].type = ty;
-		cst[i].val = val;
-		strcpy(cst[i].label, label);
+		cst[i] = c;
 		ncst++;
 		return CONST(i);
 	default: