44
55#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
66#else
7- #error "compiler must be at c++17 to compile!"
7+ #error "compiler must be at c++17 or above to compile!"
88#endif
99
1010/*
1111todo:
1212
13- !!! condition with functions !!!
13+ make the language safe
1414
15- precompiled {
16- def operator foo()
17- redef token1 token2
18- }
19-
20- datatypes
21- struct token
22- arrays
15+ arrays with basetype
16+ arrays with datatypes
17+ arrays with struct
2318
2419lineconcat \
25- linesplit ;
2620
27- evaluate functions
21+ evaluated functions
2822edef foo():
2923
3024*/
3125
3226map < string, Basetype > type_dict = {
33- { " float" , Basetype::_float },
34- { " int" , Basetype::_int },
35- { " str" , Basetype::_string },
36- { " bool" , Basetype::_bool },
37- { " ptr" , Basetype::_ptr },
38- { " any" , Basetype::_any }
27+ { " float" , Basetype::_float },
28+ { " int" , Basetype::_int },
29+ { " str" , Basetype::_string },
30+ { " bool" , Basetype::_bool },
31+ { " ptr" , Basetype::_ptr },
32+ { " any" , Basetype::_any },
33+ { " bool" , Basetype::_bool },
34+ { " dbool" , Basetype::_2bool },
35+ { " tbool" , Basetype::_3bool },
36+ { " qbool" , Basetype::_4bool },
37+ { " qtbool" , Basetype::_5bool },
38+ { " hbool" , Basetype::_6bool },
39+ { " sbool" , Basetype::_7bool },
40+ { " byte" , Basetype::_byte },
41+ { " word" , Basetype::_word },
42+ { " dword" , Basetype::_dword },
43+ { " qword" , Basetype::_qword }
3944};
4045
4146map < string, Tokentypes > tokens_dict = {
4247 { " def" , Tokentypes::definition },
48+ { " redef" , Tokentypes::redefinition },
4349 { " operator" , Tokentypes::_operator },
4450 { " child" , Tokentypes::child },
4551 { " struct" , Tokentypes::_struct},
@@ -51,6 +57,8 @@ map < string, Tokentypes > tokens_dict = {
5157 { " ]" , Tokentypes::list_end },
5258 { " (" , Tokentypes::parameter_start },
5359 { " )" , Tokentypes::parameter_end },
60+ { " {" , Tokentypes::struct_start },
61+ { " }" , Tokentypes::struct_end },
5462 { " ," , Tokentypes::separator },
5563 { " ." , Tokentypes::float_separator },
5664 { " ;" , Tokentypes::lf },
@@ -84,8 +92,10 @@ int ROspaces = 0;
8492string section_data = " SECTION .data:\n " ;
8593string section_text = " SECTION .text:\n " ;
8694vector<int > argument_order;
95+ vector<int > fargument_order = { 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 };
8796vector<constant> spaces;
8897vector<asoperator> operators;
98+ vector<structure> structs;
8999vector<aschild> childs;
90100vector<constant> externs;
91101vector<string> pcllibs, includes_f, REG ;
@@ -118,7 +128,7 @@ int main(int argc, char** argv)
118128 Options : \n \
119129 ----compilation options---- \n \
120130 -o output file | default: input file.obj \n \
121- -cc calling convention[SysVi386, SysV , M64] \n \
131+ -cc calling convention[SysV, ABI , M64, cdecl] \n \
122132 -f format[elf32, elf64, elfx32, win32, win64] \n \
123133 -n no start function \n \
124134 -s save asm file \n \
@@ -196,7 +206,7 @@ int main(int argc, char** argv)
196206
197207 if (Args[LsccArg::f] == " elf64" || Args[LsccArg::f] == " win64" ) {
198208 architecture = 64 ;
199- REG .insert (REG .end (), { " rax" , " rbx" , " rcx" , " rdx" , " rsi" , " rdi" , " rbp" , " rsp" , " r8" , " r9" , " r10" , " r11" , " r12" , " r13" , " r14" , " r15" , " xmm0" , " xmm1" , " xmm2" , " xmm3" , " eax" , " ebx" , " ecx" , " edx" , " esi" , " edi" , " ebp" , " esp" , " r8d" , " r9d" , " r10d" , " r11d" , " r12d" , " r13d" , " r14d" , " r15d" , " cr0" , " cr2" , " cr3" , " cr4" , " cr8" });
209+ REG .insert (REG .end (), { " rax" , " rbx" , " rcx" , " rdx" , " rsi" , " rdi" , " rbp" , " rsp" , " r8" , " r9" , " r10" , " r11" , " r12" , " r13" , " r14" , " r15" , " xmm0" , " xmm1" , " xmm2" , " xmm3" , " eax" , " ebx" , " ecx" , " edx" , " esi" , " edi" , " ebp" , " esp" , " r8d" , " r9d" , " r10d" , " r11d" , " r12d" , " r13d" , " r14d" , " r15d" , " cr0" , " cr2" , " cr3" , " cr4" , " cr8" , " xmm0 " , " xmm1 " , " xmm2 " , " xmm3 " , " xmm4 " , " xmm5 " , " xmm6 " , " xmm7 " });
200210 }
201211 elif (Args[LsccArg::f] == " elf32" || Args[LsccArg::f] == " win32" || Args[LsccArg::f] == " elfx32" ) {
202212 architecture = 32 ;
@@ -211,17 +221,17 @@ int main(int argc, char** argv)
211221 argument_order.insert (argument_order.end (), { 2 , 3 , 8 , 9 });
212222 convention = CallingConvention::M64 ;
213223 }
214- elif (Args[LsccArg::cc] == " SysV " ) {
224+ elif (Args[LsccArg::cc] == " ABI " ) {
215225 argument_order.insert (argument_order.end (), { 5 , 4 , 3 , 2 , 8 , 9 });
216- convention = CallingConvention::SysV ;
226+ convention = CallingConvention::ABI ;
217227 }
218- elif (Args[LsccArg::cc] == " SysVi386 " ) {
228+ elif (Args[LsccArg::cc] == " SysV " ) {
219229 argument_order.clear ();
220- convention = CallingConvention::SysVi386 ;
230+ convention = CallingConvention::SysV ;
221231 }
222232 elif (Args[LsccArg::cc] == " cdecl" ) {
223233 argument_order.insert (argument_order.end (), { 2 , 3 , 8 , 9 });
224- convention = CallingConvention::cdelc ;
234+ convention = CallingConvention::___cdecl ;
225235 }
226236 else {
227237 cout << " Error: invalid calling convention \" " << Args[LsccArg::cc] << " \" !" << endl;
@@ -254,7 +264,7 @@ int main(int argc, char** argv)
254264 asFile << code;
255265 asFile.close ();
256266
257- system (string (" nasm " + Args[LsccArg::i] + " -f " + Args[LsccArg::f] + " -o " + Args[LsccArg::o]).c_str ());
267+ int nasm_success = system (string (" nasm " + Args[LsccArg::i] + " -f " + Args[LsccArg::f] + " -o " + Args[LsccArg::o]).c_str ());
258268
259269 asFile.open (Args[LsccArg::i]);
260270 asFile << originalContent.str ();
@@ -266,8 +276,12 @@ int main(int argc, char** argv)
266276 asFile.close ();
267277 }
268278
269- cout << Error::errorTypeValid << " Successfully compiled \x1B [33m\" " << Args[LsccArg::i] << " \"\x1B [32m !" << Error::errorTypeNormal << endl;
270-
279+ if (nasm_success == 0 ) {
280+ cout << Error::errorTypeValid << " Successfully compiled \x1B [33m\" " << Args[LsccArg::i] << " \"\x1B [32m !" << Error::errorTypeNormal << endl;
281+ }
282+ else {
283+ cout << Error::errorTypeError << " UnSuccessfully compiled \x1B [33m\" " << Args[LsccArg::i] << " \"\x1B [31m !" << Error::errorTypeNormal << endl;
284+ }
271285 }
272286
273287 return 0 ;
0 commit comments