]> git.mdlowis.com Git - proto/obnc.git/commitdiff
commented out broken stuff...really gotta get it working...
authormike lowis <mike@mdlowis.com>
Fri, 14 May 2021 01:50:53 +0000 (21:50 -0400)
committermike lowis <mike@mdlowis.com>
Fri, 14 May 2021 01:50:53 +0000 (21:50 -0400)
cerise/inc/cerise.h
cerise/src/grammar.c

index f1b76e89afe21bda23a54ff235c8b9c7951efc5e..56891e7478a3d502aafa3b756e4aa750947ba1c7 100644 (file)
@@ -77,11 +77,15 @@ typedef struct LexFile {
     char* fpos;
 } LexFile;
 
+struct Symbol;
+
 typedef struct Type {
     enum {
         FORM_BOOL, FORM_INT, FORM_REAL, FORM_ARRAY, FORM_STRING,
+        FORM_RECORD,
         FORM_COUNT
     } form;
+    struct Symbol* fields;
     struct Type* base;
     int size;
 } Type;
index f303994b309f3ea5376ce984a26a0894e8c98732..e009c9a72bb4ca5527c5e3a5a82a47a2948c1ffb 100644 (file)
@@ -346,71 +346,37 @@ RULE(type)
     }
     else if (accept(p, RECORD))
     {
-
-
-//    do
-//    {
-//        int nsyms = 0;
-//        Symbol* first = NULL;
-//        Symbol* sym = NULL;
-////        Symbol* type = NULL;
-//        char* name = NULL;
-//        bool export = false;
-//
-//        do
+        item->type = calloc(1, sizeof(Type));
+        item->type->form = FORM_RECORD;
+//        Symbol **fields = &(item->type->fields);
+//        while (peek(p)->type != END)
 //        {
-//            name = expect_text(p, IDENT);
-//            export = accept(p, '*');
-//            sym = symbol_new(p, name, SYM_VAR, export);
-//            first = (nsyms == 0 ? sym : first);
-//            sym->global = (p->level <= 1 ? 1 : 0);
-//            nsyms++;
-//        }
-//        while (accept(p, ','));
+//            do
+//            {
+//                char* name = expect_text(p, IDENT);
+//                bool export = accept(p, '*');
+//                *prev = symbol_new(p, name, SYM_VAR, export);
+//                nsyms++;
+//            }
+//            while (accept(p, ','));
 //
-//        Item base_type = {0};
-//        expect(p, ':');
-//        type(p, &base_type);
 //
-////        name = expect_text(p, IDENT);
-////        type = symbol_get(p, SYM_TYPE, name);
+////            int nsyms = 0;
+////            Symbol head = {0};
+////            Symbol **prev = &(head.next);
+////
+////            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;
+////            /* 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;
+////            }
 //        }
-//    }
-//    while (matches(p, IDENT));
-
-        while (peek(p)->type != END)
-        {
-            int nsyms = 0;
-            Symbol head = {0};
-            Symbol **prev = &(head.next);
-            do
-            {
-                char* name = expect_text(p, IDENT);
-                bool export = accept(p, '*');
-                *prev = symbol_new(p, name, SYM_VAR, export);
-                nsyms++;
-            }
-            while (accept(p, ','));
-
-            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;
-//            }
-        }
 
         expect(p, END);
     }