aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorc+12023-05-12 11:49:12 -0400
committerc+12023-05-12 11:49:12 -0400
commit17d6e6a265c44569f4533e12cc04442013ab3b3e (patch)
tree25233a2ca455b220a6ecae4d46139a55fd8b100b /src/main.c
parent07077e2974d74efaee109c9da3500ef86aeecd06 (diff)
nothing workds help
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 2d741e4..a463a7e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,10 +6,38 @@
int main(int argc, char* argv[]) {
+ FILE *fsource;
+ long fsource_size;
+ char *source;
+
+ fsource = fopen ("examples/hello.halk", "rb");
+ if (!fsource) { fputs("Source file not found.", stderr); exit(1); };
+
+ fseek(fsource, 0L, SEEK_END);
+ fsource_size = ftell(fsource);
+ rewind(fsource);
+
+ source = calloc(1, fsource_size + 1);
+ if (!source) {
+ fclose(fsource);
+ fputs("Memory allocation faled.", stderr);
+ exit(1);
+ }
+
+ if (1 != fread(source, fsource_size, 1, fsource)) {
+ fclose(fsource);
+ free(source);
+ fputs("Could not read source file.", stderr);
+ exit(1);
+ }
+
lexer_t* lexer = lexer_init(
- "[a simple test script]\nlet it = \"Hello, World!\";\nsay it;"
+ source
);
+ fclose(fsource);
+ free(source);
+
printf("\n=== INPUT =======\n%s\n=== END INPUT ===\n", lexer->content);
token_t* token = NULL;