shithub: mc

Download patch

ref: b8af763052c93ba53fee75cb209e1f673c5caa66
parent: 71bba431594a726d16fe726a71c7c2e7ab6a04d1
author: Ori Bernstein <[email protected]>
date: Fri Nov 27 20:05:04 EST 2015

Allow local type definitions within blocks.

--- a/parse/gram.y
+++ b/parse/gram.y
@@ -930,6 +930,11 @@
 		if ($1)
 			lappend(&$$->block.stmts, &$$->block.nstmts, $1);
 	}
+	| tydef {
+		$$ = mkblock(curloc, mkstab(0));
+		puttype($$->block.scope, mkname($1.loc, $1.name), $1.type);
+		installucons($$->block.scope, $1.type);
+	}
 	| blkbody Tendln stmt {
 		if ($3)
 			lappend(&$1->block.stmts, &$1->block.nstmts, $3);
@@ -941,6 +946,10 @@
 			putdcl($$->block.scope, $3.nl[i]);
 			lappend(&$1->block.stmts, &$1->block.nstmts, $3.nl[i]);
 		}
+	}
+	| blkbody Tendln tydef {
+		puttype($$->block.scope, mkname($3.loc, $3.name), $3.type);
+		installucons($$->block.scope, $3.type);
 	}
 	;