diff options
| author | Lorenzo Torres <lorenzotorres@outlook.it> | 2026-06-10 00:16:07 +0200 |
|---|---|---|
| committer | Lorenzo Torres <lorenzotorres@outlook.it> | 2026-06-10 00:16:07 +0200 |
| commit | 6c9d0f7fad1d96796efef43a6db7eef6df8de054 (patch) | |
| tree | 5ef7befd9b853f857caed70570cbd007ca970410 /lc.c | |
| parent | 13d591df4ae3dc07f3be8477f7bcbed296d7bc40 (diff) | |
finished lexer, preliminary work on parser
Diffstat (limited to 'lc.c')
| -rw-r--r-- | lc.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -1,20 +1,26 @@ #include <stdio.h> #include <stdlib.h> #include "lexer.h" +#include "parser.h" int main(void) { - char *src = "12.3"; + FILE *fp = fopen("examples/hello_world.ll", "r"); + fseek(fp, 0, SEEK_END); + size_t length = ftell(fp); + fseek(fp, 0, SEEK_SET); + + char *src = malloc(length + 1); + fread(src, 1, length, fp); + src[length] = '\0'; token *head = lexer_parse(src); if (!head) { printf("Parsing error!\n"); exit(1); } - while (head->next) { - head = head->next; - printf("%d -> %.*s\n", head->type, head->length, head->lexeme); - free(head->prev); - } + + ir_parse(head); + return 0; } |
