]> git.mdlowis.com Git - proto/obnc.git/commitdiff
got rid of next pointer for Symbol type
authormike lowis <mike@mdlowis.com>
Tue, 8 Jun 2021 11:33:19 +0000 (07:33 -0400)
committermike lowis <mike@mdlowis.com>
Tue, 8 Jun 2021 11:33:19 +0000 (07:33 -0400)
cerise/inc/cerise.h
cerise/src/grammar.c
cerise/tests/Module.m

index f159d7efcb4076a1be6606483a3ce7f5478e4c9d..e1abc1c670ea87db79356666cfb1efa65b0c729d 100644 (file)
@@ -105,7 +105,6 @@ typedef union {
 } ImmValue;
 
 typedef struct Symbol {
-    struct Symbol* next;
     enum{
         SYM_SCOPE, SYM_CONST, SYM_VAR, SYM_TYPE, SYM_PROC, SYM_FIELD
     } class;
@@ -246,7 +245,7 @@ typedef struct {
             size_t margs;
             long* args;
         } call;
-    }
+    } u;
 } Operation;
 
 typedef struct {
index 7e891c8c7e42ca59e2d62436886b357c15aeccd4..d90d4b9656c591fa7a0b8b021854c8a5b55df116 100644 (file)
@@ -439,33 +439,13 @@ RULE(var_decl)
     (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));
 }
@@ -806,7 +786,7 @@ TEST_SUITE(Grammar)
         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)
index eeead135df97998be8c651a2b4f29167208bedf2..723c8183769f9071bcb4b2cfba2f441adc0ae733 100644 (file)
@@ -35,28 +35,26 @@ var
   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;
@@ -135,6 +133,8 @@ begin
 #    g[c] = 42;
 #    e[0][9] = 42;
 
-    c = Bar(42);
+#    c = Bar(42);
+
+    c = 42;
 
 end