From 427b056cda40940834f1bb1460d8fba6003568a6 Mon Sep 17 00:00:00 2001 From: mike lowis Date: Thu, 13 May 2021 21:50:53 -0400 Subject: [PATCH] commented out broken stuff...really gotta get it working... --- cerise/inc/cerise.h | 4 +++ cerise/src/grammar.c | 86 ++++++++++++++------------------------------ 2 files changed, 30 insertions(+), 60 deletions(-) diff --git a/cerise/inc/cerise.h b/cerise/inc/cerise.h index f1b76e8..56891e7 100644 --- a/cerise/inc/cerise.h +++ b/cerise/inc/cerise.h @@ -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; diff --git a/cerise/src/grammar.c b/cerise/src/grammar.c index f303994..e009c9a 100644 --- a/cerise/src/grammar.c +++ b/cerise/src/grammar.c @@ -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); } -- 2.49.0