shithub: scc

Download patch

ref: 68fd23753b7c670097f9dbb0ada76ea59189157a
parent: adc45909f04c3cd3c7ee4e3e1e62ce5d67eaef7d
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Aug 26 16:58:54 EDT 2012

Added tree structure for goto statement

--- a/flow.c
+++ b/flow.c
@@ -10,9 +10,16 @@
 static struct node *
 _goto(void)
 {
+	register struct node *np;
+
 	expect(GOTO);
 	expect(IDEN);
-	return NULL;
+	if (yyval.sym->ns != NS_LABEL)
+		yyval.sym = lookup(yytext, NS_LABEL, CTX_ANY);
+	np = node1(OGOTO, nodesym(yyval.sym));
+	expect(';');
+
+	return np;
 }
 
 static struct node *
--- a/syntax.h
+++ b/syntax.h
@@ -11,7 +11,7 @@
 	OBOR, OAND, OOR, OTERN, OASSIGN, OA_MUL, OA_DIV,
 	OA_MOD, OA_ADD, OA_SUB, OA_SHL, OA_SHR, OA_AND,
 	OA_XOR, OA_OR, OSYM, OCOMP, OSWITCH, OIF, OFOR,
-	OFEXP, ODO, OWHILE, OLABEL
+	OFEXP, ODO, OWHILE, OLABEL, OGOTO
 };
 
 struct node;
--- a/tree.c
+++ b/tree.c
@@ -183,7 +183,8 @@
 		[OFEXP] = {3, "efor"},
 		[ODO] = {2, "do"},
 		[OWHILE] = {2, "while"},
-		[OLABEL] = {2, "label"}
+		[OLABEL] = {2, "label"},
+		[OGOTO] = {1, "goto"}
 	};
 	if (!np) {
 		fputs(" nil", stdout);
--