77#include "parser/statement/statement.h"
88#include "parser/type/types.h"
99#include "parser/keywords.h"
10+ #include "compiler/righthand/declaration/identifier.h"
1011
1112#define QUARK_VERSION "0.3.1b"
1213#define QUARK_STABILITY "untested"
@@ -47,23 +48,38 @@ int main(int argc, char** argv) {
4748 CStringVector input_files = { 0 };
4849 char * output_file = "out.c" ;
4950
51+ CStringVector include_paths = { 0 };
52+
5053 int flag ;
51- while ((flag = clflag ()))
54+ while ((flag = clflag ())) {
5255 switch (flag ) {
5356 case 'h' :
5457 printf (help_message , name , name );
5558 return 0 ;
5659 case 'v' :
5760 puts ("Quark Compiler version " QUARK_VERSION " \33[90m" QUARK_STABILITY "\33[0m" );
5861 return 0 ;
59- case -1 : push (& input_files , clarg ());
62+ case -1 :
63+ push (& input_files , clarg ());
64+ break ;
65+ case 'o' :
66+ output_file = clarg ();
6067 break ;
61- case 'o' : output_file = clarg ();
68+ case 'l' :
69+ global_library_path = clarg ();
6270 break ;
63- case 'l' : global_library_path = clarg ();
71+ case 'i' :
72+ push (& include_paths , clarg ());
6473 break ;
6574 default : panicf ("unknown flag '-%c'\n hint: %s -h\n" , flag , name );
6675 }
76+ }
77+
78+ push (& include_paths , "stdint.h" );
79+ push (& include_paths , "stdio.h" );
80+ push (& include_paths , "string.h" );
81+ push (& include_paths , "stdlib.h" );
82+ push (& include_paths , "stdbool.h" );
6783
6884 if (input_files .size == 0 ) {
6985 panicf ("missing input files\n hint: %s -h\n" , name );
@@ -84,18 +100,23 @@ int main(int argc, char** argv) {
84100
85101 push (& compiler .sections , (CompilerSection ) { 0 });
86102 push (& compiler .sections , (CompilerSection ) { 0 });
87- push (& compiler .sections .data [0 ].lines , String ("#include <stdint.h>" ));
88- push (& compiler .sections .data [0 ].lines , String ("#include <stdio.h>" ));
89- push (& compiler .sections .data [0 ].lines , String ("#include <string.h>" ));
90- push (& compiler .sections .data [0 ].lines , String ("#include <stdlib.h>" ));
91- push (& compiler .sections .data [0 ].lines , String ("#include <stdbool.h>" ));
103+
104+ for (size_t i = 0 ; i < include_paths .size ; i ++ ) {
105+ push (& compiler .sections .data [0 ].lines , strf (0 , "#include \"%s\"" , include_paths .data [i ]));
106+ }
107+ // push(&compiler.sections.data[0].lines, String("#include <stdint.h>"));
108+ // push(&compiler.sections.data[0].lines, String("#include <stdio.h>"));
109+ // push(&compiler.sections.data[0].lines, String("#include <string.h>"));
110+ // push(&compiler.sections.data[0].lines, String("#include <stdlib.h>"));
111+ // push(&compiler.sections.data[0].lines, String("#include <stdbool.h>"));
92112
93113 push (& parser .stack , new_scope (NULL ));
94114
95115 FunctionDeclaration * entry = entry_declaration ();
96116 push (& parser .stack , entry -> body );
97117
98118 populate_keyword_table ();
119+ populate_global_c_keywords ();
99120
100121 push (& entry -> body -> children , eval_w ("lib::std" , "import lib::std;" , & parser , & statement ));
101122 const NodeVector body = collect_until (& parser , & statement , 0 , 0 );
0 commit comments