(void)item;
do
{
- int nsyms = 0;
- Symbol* first = NULL;
- Symbol* sym = NULL;
- char* name = NULL;
- bool export = false;
-
- do
- {
- name = expect_text(p, IDENT);
- export = accept(p, '*');
- sym = symbol_new(p, 0, name, SYM_VAR, export);
- first = (nsyms == 0 ? sym : first);
- nsyms++;
- }
- while (accept(p, ','));
-
+ char* name = expect_text(p, IDENT);
+ bool export = accept(p, '*');
+ Symbol* sym = symbol_new(p, 0, name, SYM_VAR, export);
Item base_type = {0};
expect(p, ':');
type(p, &base_type);
-
- /* apply the type to the newly created symbols */
- for (int i = 0; i < nsyms; i++)
- {
- first->type = base_type.type;
- codegen_var(p, first);
- sym = first->next;
- }
+ sym->type = base_type.type;
}
while (matches(p, IDENT));
}
parse_rule(var_decl, 0, "i : Int");
parse_rule(var_decl, 0, "i : Real");
parse_rule(var_decl, 0, "i : Bool");
- parse_rule(var_decl, 0, "x,y,z : Int");
+// parse_rule(var_decl, 0, "x,y,z : Int");
}
TEST(Should parse module level procedure declarations)
g : array 5 of Int
h : TypeF
-procedure Foo*(e : Int, z : Int, q1 : TypeD, q2 : array 5 of Int) : Int
- const FOO = 2
- type foo = Int
- var
- z1 : Int
- q : array 5 of array 10 of Int
-begin
-# e = q;
- c = 1;
- z1 = 2;
- return z1;
-end
+#procedure Foo*(e : Int, z : Int, q1 : TypeD, q2 : array 5 of Int) : Int
+# const FOO = 2
+# type foo = Int
+# var
+# z1 : Int
+# q : array 5 of array 10 of Int
+#begin
+## e = q;
+# c = 1;
+# z1 = 2;
+# return z1;
+#end
-procedure Bar(a : Int) : Int
-begin
- return a;
-end
+#procedure Bar(a : Int) : Int
+#begin
+# return a;
+#end
begin
-
- h[1].i = 42;
-
+# h[1].i = 42;
# a = true;
# a = A;
# b = 24;
# g[c] = 42;
# e[0][9] = 42;
- c = Bar(42);
+# c = Bar(42);
+
+ c = 42;
end