Commit Diff


commit - a3dc2f5de198c4a5c70d7b2be4db9179531c4456
commit + b1c090542f4ecaf993fc81468338839febcb8e37
blob - cc7231514a823861b662e419be141a4492c833fd
blob + 58db764d105aff68e65237083482558bcf17fb47
--- gotd/parse.y
+++ gotd/parse.y
@@ -127,10 +127,29 @@ typedef struct {
 
 grammar		:
 		| grammar '\n'
+		| grammar varset '\n'
 		| grammar main '\n'
 		| grammar repository '\n'
 		;
 
+varset		: STRING '=' STRING	{
+			char *s = $1;
+			while (*s++) {
+				if (isspace((unsigned char)*s)) {
+					yyerror("macro name cannot contain "
+					    "whitespace");
+					free($1);
+					free($3);
+					YYERROR;
+				}
+			}
+			if (symset($1, $3, 0) == -1)
+				fatal("cannot store variable");
+			free($1);
+			free($3);
+		}
+		;
+
 timeout		: NUMBER {
 			if ($1 < 0) {
 				yyerror("invalid timeout: %lld", $1);