From 198e4a9983e13f02261b6a34afc536e22e1ce410 Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Sun, 6 Feb 2022 21:59:21 -0500 Subject: [cup] Add ability to import files --- compiler/main.cup | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'compiler/main.cup') 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 "); - 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); -- cgit v1.2.3