char* fpos;
} LexFile;
-typedef struct {
+typedef struct Type {
enum {
- FORM_BOOL, FORM_INT, FORM_REAL, FORM_STRING
+ FORM_BOOL, FORM_INT, FORM_REAL, FORM_ARRAY, FORM_STRING
} form;
+ struct Type* base;
int size;
} Type;
void codegen_setint(Item* item, Type* type, long long val);
void codegen_setreal(Item* item, double val);
void codegen_setstr(Item* item, char* val);
-
void codegen_imports(Parser* p);
void codegen_global(Parser* p, char* name, Type* type);
void codegen_main(Parser* p);
(void)item;
if (matches(p, IDENT))
{
- expect(p, IDENT);
+ char* text = expect_text(p, IDENT);
+ Symbol* sym = symbol_get(p, SYM_TYPE, text);
+ item->type = sym->type;
}
else if (accept(p, ARRAY))
{
error(p, "non-constant array size");
}
expect(p, OF);
- type(p, item);
+ Item base = {0};
+ type(p, &base);
+ item->type = calloc(1, sizeof(Type));
+ item->type->form = FORM_ARRAY;
+ item->type->size = item->imm.i;
+ item->type->base = base.type;
}
else if (accept(p, RECORD))
{