aboutsummaryrefslogtreecommitdiff
path: root/compiler/main.cup
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-06 21:59:21 -0500
committerMustafa Quraish <[email protected]>2022-02-07 03:18:08 -0500
commit198e4a9983e13f02261b6a34afc536e22e1ce410 (patch)
tree477f0a7537452ec380511b129c1ea7c00e3da281 /compiler/main.cup
parent[C]: Add `here` keyword that evaluates to a string with it's location (diff)
downloadcup-198e4a9983e13f02261b6a34afc536e22e1ce410.tar.xz
cup-198e4a9983e13f02261b6a34afc536e22e1ce410.zip
[cup] Add ability to import files
Diffstat (limited to 'compiler/main.cup')
-rw-r--r--compiler/main.cup11
1 files changed, 1 insertions, 10 deletions
diff --git a/compiler/main.cup b/compiler/main.cup
index 6d7c3d8..fa7db31 100644
--- a/compiler/main.cup
+++ b/compiler/main.cup
@@ -9,16 +9,7 @@ fn main(argc: int, argv: char **): int {
if (argc != 2)
die("Usage: cupcc <input_file>");
- let input_file = fopen(argv[1], 'r');
- defer fclose(input_file);
-
- // using `fmap` here doesn't work on linux, for some reason.
- let file_size = fsize(input_file);
- let src: char* = malloc(file_size+1);
- fread(input_file, src, file_size);
- src[file_size] = '\0';
-
- let lexer = lexer_new(argv[1], src, file_size);
+ let lexer = lexer_new_open_file(argv[1]);
let ast = parse_program(lexer);
dump_ast(ast, 0);