diff options
author | dx <aryadevchavali1@gmail.com> | 2020-05-22 19:13:15 +0100 |
---|---|---|
committer | dx <aryadevchavali1@gmail.com> | 2020-05-22 20:02:18 +0100 |
commit | 99cf6e8eca2e3d29874b8b80e8c4312cd1bc87ba (patch) | |
tree | d19f8f6177b0be1938f4f9c9744eda39f43e2072 /Converter/includes/compiler.h | |
parent | 1a2d0ffdbfb69a2858fb45facfb18468106edd9a (diff) | |
download | mdhtml-99cf6e8eca2e3d29874b8b80e8c4312cd1bc87ba.tar.gz mdhtml-99cf6e8eca2e3d29874b8b80e8c4312cd1bc87ba.tar.bz2 mdhtml-99cf6e8eca2e3d29874b8b80e8c4312cd1bc87ba.zip |
~compile_lines -> compile_file, shuffle
I've redid the compiler to use a FILE object pointer, which means that
we can leave error checking for FILES on the main program.
Furthermore, I've removed the use of the array_t type with a two pass
system. One pass is done for the number of lines (along with potentially
other diagnostics), another is done for the actual compilation. This
means at runtime we have an understanding about the size of the file and
can optimize for it. Also, we have a single memory block to assign to,
where we know the size of the array.
Diffstat (limited to 'Converter/includes/compiler.h')
-rw-r--r-- | Converter/includes/compiler.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Converter/includes/compiler.h b/Converter/includes/compiler.h index 8d84b71..4540164 100644 --- a/Converter/includes/compiler.h +++ b/Converter/includes/compiler.h @@ -2,6 +2,7 @@ #define __COMPILER_H_ #include <stdlib.h> +#include <stdio.h> #include <stdbool.h> typedef char *string; @@ -15,7 +16,9 @@ int find_string(string src, string query, size_t sz_src, size_t sz_query); /* Check if a given character is a text token*/ bool is_token(char c); -/* Given a file, get the lines */ -char **get_lines(char *filename); +/* Given a file, get number of lines */ +int nlines(FILE *fp); +/* Given a file, compile the lines */ +string *compile_file(FILE *fp, string filename, int nlines); #endif // __COMPILER_H_ |