55/*
66todo:
77
8- finish types
9- signed unsigned (£ = unsigned)
10-
11- preprocessors {
8+ fixed types
129
13- def preprocessor():
14- a b
15- if a
16- //
17- else
18- //
19- endif
20- }
10+ signed unsigned (£ = unsigned)
2111
2212type child token(type...)
2313
2414struct token
2515
2616typedef token1 token2
2717
28- fixed int a = 0
29- float a = 0.5 // error invalid convertion of float to int
30- int a = 0
31- float a = 0.5 // ok
32-
33- with "stdlang.pclslib"
34- extern printf
35-
36- def mainCRTStartup():
37- start()
38- return(0)
39- end
40-
41- def start():
42- printf("%d", 0.5)
43- return(0)
44- end
18+ preprocessors
4519
4620*/
4721
22+ std::map < string, Basetype > type_dict = {
23+ { " float" , Basetype::_float },
24+ { " int" , Basetype::_int },
25+ { " str" , Basetype::_string },
26+ { " bool" , Basetype::_bool },
27+ { " ptr" , Basetype::_ptr },
28+ { " any" , Basetype::_any }
29+ };
30+
4831std::map < string, Tokentypes > tokens_dict = {
4932 { " def" , Tokentypes::definition },
5033 { " end" , Tokentypes::end },
@@ -55,14 +38,8 @@ std::map < string, Tokentypes > tokens_dict = {
5538 { " )" , Tokentypes::parameter_end },
5639 { " ," , Tokentypes::separator },
5740 { " ." , Tokentypes::float_separator },
58- { " ;" , Tokentypes::line_separator },
41+ { " ;" , Tokentypes::lf },
5942 { " \\ " , Tokentypes::line_concat },
60- { " float" , Tokentypes::type },
61- { " int" , Tokentypes::type },
62- { " str" , Tokentypes::type },
63- { " bool" , Tokentypes::type },
64- { " ptr" , Tokentypes::type },
65- { " any" , Tokentypes::type },
6643 { " global" , Tokentypes::global },
6744 { " local" , Tokentypes::local },
6845 { " \n " , Tokentypes::lf },
@@ -86,13 +63,9 @@ std::map < string, Tokentypes > tokens_dict = {
8663 { " !<" , Tokentypes::jnl },
8764 { " <=" , Tokentypes::jle },
8865 { " !<=" , Tokentypes::jnle },
89- { " !" , Tokentypes::inv },
90- { " \\ n" , Tokentypes::strret },
91- { " \\ 0" , Tokentypes::strterm },
92- { " \\ " , Tokentypes::strback }
66+ { " !" , Tokentypes::inv }
9367 };
9468
95-
9669int ROspaces = 0 ;
9770string section_data = " SECTION .data:\n " ;
9871string section_text = " SECTION .text:\n " ;
@@ -150,7 +123,10 @@ int main(int argc, char** argv)
150123 -cc calling convention[SysVi386, SysV, M64] | default: SysV \n \
151124 -f format[elf32, elf64, elfx32, win32, win64] | default: elf64 \n \
152125 -n no start function \n \
153- -s save asm file\n " ;
126+ -s save asm file \n \
127+ \n \
128+ ----warnings options---- \n \
129+ --w-type disable type convertion warnings \n " ;
154130 }
155131 else {
156132 size_t in1 = in (" -i" , argv, argc);
@@ -194,11 +170,16 @@ int main(int argc, char** argv)
194170 Cconvention = " SysV" ;
195171 }
196172
173+ in1 = in (" --w-type" , argv, argc);
174+ if (in1 != -1 ) {
175+ Error::enabledWarns[Error::typeWarn] = false ;
176+ }
177+
197178 if (Fformat == " elf64" || Fformat == " win64" ) {
198- 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" });
179+ 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 " });
199180 }
200181 elif (Fformat == " elf32" || Fformat == " win32" || Fformat == " elfx32" ) {
201- REG .insert (REG .end (), { " eax" , " ebx" , " ecx" , " edx" , " esi" , " edi" , " ebp" , " esp" , " r8d" , " r9d" , " r10d" , " r11d" , " r12d" , " r13d" , " r14d" , " r15d" });
182+ REG .insert (REG .end (), { " eax" , " ebx" , " ecx" , " edx" , " esi" , " edi" , " ebp" , " esp" , " r8d" , " r9d" , " r10d" , " r11d" , " r12d" , " r13d" , " r14d" , " r15d" , " cr0 " , " cr2 " , " cr3 " , " cr4 " , " cr8 " });
202183 }
203184 else {
204185 cout << " Error: invalid format \" " << Fformat << " \" !" << endl;
@@ -229,6 +210,7 @@ int main(int argc, char** argv)
229210 for (size_t i = 0 ; i < pcllibs.size (); i++) {
230211 tokenlibs.clear ();
231212 tokenlibs = tokenize (pcllibs[i]);
213+ fuse_symbols (&tokenlibs);
232214 identify_tokens (&tokenlibs, true );
233215 clib.precompile_lib (tokenlibs);
234216 }
0 commit comments