From 139ff4c2e373e47319ae20e268ab17be36b2581a Mon Sep 17 00:00:00 2001 From: Pyro569 Date: Tue, 7 Nov 2023 17:27:46 -0500 Subject: [PATCH 1/7] Beginning of Compiler Rewrite in DawnLang --- New-Compiler/ArgReader.dl | 12 ++++++++++++ New-Compiler/DawnLang | Bin 0 -> 15760 bytes New-Compiler/testfile.dl | 5 +++++ ArgReader.cs => Old-Compiler/ArgReader.cs | 0 Creation.cs => Old-Compiler/Creation.cs | 0 DawnLang.csproj => Old-Compiler/DawnLang.csproj | 0 ErrorCodes.cs => Old-Compiler/ErrorCodes.cs | 0 Tokenization.cs => Old-Compiler/Tokenization.cs | 0 testfile.dl => Old-Compiler/testfile.dl | 0 9 files changed, 17 insertions(+) create mode 100644 New-Compiler/ArgReader.dl create mode 100755 New-Compiler/DawnLang create mode 100644 New-Compiler/testfile.dl rename ArgReader.cs => Old-Compiler/ArgReader.cs (100%) rename Creation.cs => Old-Compiler/Creation.cs (100%) rename DawnLang.csproj => Old-Compiler/DawnLang.csproj (100%) rename ErrorCodes.cs => Old-Compiler/ErrorCodes.cs (100%) rename Tokenization.cs => Old-Compiler/Tokenization.cs (100%) rename testfile.dl => Old-Compiler/testfile.dl (100%) diff --git a/New-Compiler/ArgReader.dl b/New-Compiler/ArgReader.dl new file mode 100644 index 0000000..19acaad --- /dev/null +++ b/New-Compiler/ArgReader.dl @@ -0,0 +1,12 @@ +#import dawnlang.io; +#import dawnlang.io.args; + +function main(args){ + C-Code[ + for(int i = 1; i < argc; i++){ + if(0 == strcmp(argv[i], "-b")){ + printf("Build File!\n"); + } + } + ]-End +} \ No newline at end of file diff --git a/New-Compiler/DawnLang b/New-Compiler/DawnLang new file mode 100755 index 0000000000000000000000000000000000000000..fa5e13f770f82bcbf8ce9daae4376e435ff0ecd3 GIT binary patch literal 15760 zcmeHOYit}>6~4Q+6PMJFl(^X@kW3*#Da8}NVi_Wn^<$kevXc-yB1FJ+ygT*|TJJ8i zv&Al@7?~g}%W42YTT!W?O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;Kv(SlX>1VNy}WX1!tOh;MMR4T#^DE& z-|1aX?Eg!sG>e!};>@^s944#)-yGn72hH2@rczu#y4=O9V9I}JxU{$50{z@28pSZ( zck+K6(7Fxy?a`Q*cgunp`bV1t->1y)k^Qi>fn(G^|Bgfc4+feK%YNV~5IEm`z~i{V z;~fPa;}AUFGm^hY9Efj>i8USj-%Lr%CjVgnk5uu0vD!mg zqC|(=PETn1(8<2hgsu&q6#C!?kM)fX4+#C}$npNZ5&ihk&{$$zAMfiQNk9_3nKB#$ z^4*U^ntIC0>cxVY3gofJIRhQj&Se@q9C{(Ar;Th1bLAo5-TKd5cTWX*>oPqaTp-6@ zPaGS>|AktZ zopy`~K*x45%{4s#c3!C2oMWm}*`k`ab9vKtW_{EI{=>A@N)gr9KiujVQ$o6@jY3+e zso5+H;i6-^Ef1P@!OCSf89KDtX2w7P)$$ofsQ4oUp*rRa?Bz*O?VLQls+ra&ZDZQh z(<#uhaw^LoVs4yVj| zUUxC_ItyH6!9M)uV_@K#hV{ITVdQ5!&!7Dm9|1kCk=W*S65|OPjAP96=Q%7v1!Ky3 zUZ*jZ$dSiqJsGrGP%JxSos;vyhO_AJe~p3S>~qdjL6pkKy0{1^wA({5@!ze0qM*x!8)m zZCo#|wPCX!*L!&F&|||}Z}RUs`FERm{bOMrpU2mM!}zhDe`i%Xh~7dRaKYQNp7A=g z`1SmrwDtz|Q4ss}yzXnJ3zz4~6X0<@8^p-*{FS)dqL4o5k7M~u1C3AaUK8ts_aE#1 z$k(1HhDw||JWq}I9L9G&o)14ikmI>S)hpLJs2b>;$7M%c&R5iTxgK{11OZe08;m;o A0RR91 literal 0 HcmV?d00001 diff --git a/New-Compiler/testfile.dl b/New-Compiler/testfile.dl new file mode 100644 index 0000000..68aed98 --- /dev/null +++ b/New-Compiler/testfile.dl @@ -0,0 +1,5 @@ +#import dawnlang.io; + +function main(){ + print("Hello, World!\n"); +} \ No newline at end of file diff --git a/ArgReader.cs b/Old-Compiler/ArgReader.cs similarity index 100% rename from ArgReader.cs rename to Old-Compiler/ArgReader.cs diff --git a/Creation.cs b/Old-Compiler/Creation.cs similarity index 100% rename from Creation.cs rename to Old-Compiler/Creation.cs diff --git a/DawnLang.csproj b/Old-Compiler/DawnLang.csproj similarity index 100% rename from DawnLang.csproj rename to Old-Compiler/DawnLang.csproj diff --git a/ErrorCodes.cs b/Old-Compiler/ErrorCodes.cs similarity index 100% rename from ErrorCodes.cs rename to Old-Compiler/ErrorCodes.cs diff --git a/Tokenization.cs b/Old-Compiler/Tokenization.cs similarity index 100% rename from Tokenization.cs rename to Old-Compiler/Tokenization.cs diff --git a/testfile.dl b/Old-Compiler/testfile.dl similarity index 100% rename from testfile.dl rename to Old-Compiler/testfile.dl From d3b0a7c6635a0752770ebbf09f396fbd98763047 Mon Sep 17 00:00:00 2001 From: Pyro569 Date: Tue, 7 Nov 2023 17:31:15 -0500 Subject: [PATCH 2/7] Create WHAT_IS_THIS.md --- New-Compiler/WHAT_IS_THIS.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 New-Compiler/WHAT_IS_THIS.md diff --git a/New-Compiler/WHAT_IS_THIS.md b/New-Compiler/WHAT_IS_THIS.md new file mode 100644 index 0000000..d701eed --- /dev/null +++ b/New-Compiler/WHAT_IS_THIS.md @@ -0,0 +1 @@ +This directory you are in, is a rewrite of the DawnLang compiler using the DawnLang language. The goal for this compiler is to be FULLY introduced by DawnLang 1.5.0 or earlier, however it will be introduced in sectional parts. For example, in the 1.1.0 release of DawnLang, the parser might be written in DawnLang while the rest is still written in C#, and then the 1.2.0 update might have the debugger written in DawnLang etc. From a65f698359452b7d4ccc630d2a51eb2f4d66e3cb Mon Sep 17 00:00:00 2001 From: Pyro569 Date: Tue, 7 Nov 2023 17:57:27 -0500 Subject: [PATCH 3/7] New Compiler Stuff (Non-Functional) --- New-Compiler/ArgReader.dl | 23 +++++++++++++++++++++-- New-Compiler/DawnLang | Bin 15760 -> 15696 bytes Old-Compiler/Tokenization.cs | 21 ++++++++++++++------- Old-Compiler/testfile.dl | 11 +++++++++-- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/New-Compiler/ArgReader.dl b/New-Compiler/ArgReader.dl index 19acaad..95b9a24 100644 --- a/New-Compiler/ArgReader.dl +++ b/New-Compiler/ArgReader.dl @@ -3,10 +3,29 @@ function main(args){ C-Code[ - for(int i = 1; i < argc; i++){ + if(argc > 1){ + for(int i = 1; i < argc; i++){ if(0 == strcmp(argv[i], "-b")){ - printf("Build File!\n"); + printf("Build File\n"); } + if(0 == strcmp(argv[i], "-br")){ + printf("Build and Run File\n"); + } + if(0 == strcmp(argv[2], "-d")){ + printf("Development Debug Mode\n"); + } + if(0 == strcmp(argv[i], "--version")){ + printf("DawnLang Version 1.1.0\n"); + } + if(0 == strcmp(argv[i], "--h")){ + printf("-d - Debug Mode (For development use only)\n"); + printf("-b - Build File (input file name as next arg)\n"); + printf("-br - Build and Run File (Compiles and then runs the compiled binary)\n"); + printf("--version - Outputs the DawnLang version you have installed\n"); + printf("--h - Prints out a list of possible arguments for the compiler\n"); + printf("Example Compiler Usage: ./DawnLang \"-b\" \"hello_world.dl\" \"Hello_World\"\n"); + } + } } ]-End } \ No newline at end of file diff --git a/New-Compiler/DawnLang b/New-Compiler/DawnLang index fa5e13f770f82bcbf8ce9daae4376e435ff0ecd3..7aafa2abd861caf935c1229e193b38d894392cd3 100755 GIT binary patch delta 2357 zcmZWrT}%{L6ux&^78V6|5nRC9y}LCQj0`MA{!xKlTw4B$SZmvKIK0};5ltdQYjOjSGn|qk` zRr)TrITB^MEz$Ip#7w8x@V9w)9J;nF=_$jTjv3}W!<` z>e|+wH-FmNbM3+28%g>}+8cD(Xr%eZeB4d<8*R9hTA_Dp{XPvDfqotJx${9#S1X=A`RkZc!Fv{*7DVAL|~ z>iBusOapSOWN0&VA>D>&soAuzC|!rNes-I#s5@_>V&(70vaIrArz*efKy(Dy_F`nHF58H8R?Z z0C`6}3Gb09i+2=x#|pMA^P86WPR1{0VV!H1X?U5I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+ if (Tokens[k] == "]" && Tokens[k + 1] == "-" && Tokens[k + 2] == "End") + break; + else + Tokens.Remove(Tokens[k]); } else if (Tokens[i + 1] == "+" && Tokens[i + 2] == "+" && Tokens[i + 3] == "-" && Tokens[i + 4] == "Code" && Tokens[i + 5] == "[") { @@ -448,12 +453,14 @@ private static void ConvertTokens() RemoveToken(new List { n, n + 1 }); } } + for (int k = i; k < Tokens.Count; k++) + if (Tokens[k] == "]" && Tokens[k + 1] == "-" && Tokens[k + 2] == "End") + break; + else + Tokens.Remove(Tokens[k]); } - for (int k = i; k < Tokens.Count; k++) - if (Tokens[k] == "]" && Tokens[k + 1] == "-" && Tokens[k + 2] == "End") - break; - else - Tokens.Remove(Tokens[k]); + foreach (string token in Tokens) + Console.WriteLine(token); break; case "return": ConvertedTokens.Add("return "); diff --git a/Old-Compiler/testfile.dl b/Old-Compiler/testfile.dl index f07d26d..08598d1 100644 --- a/Old-Compiler/testfile.dl +++ b/Old-Compiler/testfile.dl @@ -1,6 +1,13 @@ #import dawnlang.io; -#import dawnlang.io.args; function main(){ - print("Hello, World!\n"); + int a = 0; + int b = 1; + int c = 1; + for (int i = 1; i < 32; i++){ + print.int(a); + c = a; + a = b; + b += c; + } } \ No newline at end of file From 142f5881c81e7a806b51b389f71a3c91d7c19664 Mon Sep 17 00:00:00 2001 From: Pyro569 Date: Tue, 7 Nov 2023 18:50:56 -0500 Subject: [PATCH 4/7] Update Tokenization.cs --- Old-Compiler/Tokenization.cs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/Old-Compiler/Tokenization.cs b/Old-Compiler/Tokenization.cs index e25a2e0..a016731 100644 --- a/Old-Compiler/Tokenization.cs +++ b/Old-Compiler/Tokenization.cs @@ -29,8 +29,6 @@ public static void BuildFile(string FilePath, string OutputFileName) ReadFile(FilePath); //get the tokens of the file SearchForFunctions(); //search for functions initialized in file and add to FunctionNames list ConvertTokens(); //convert the code to C - foreach (string token in ConvertedTokens) - Console.WriteLine(token); Creation.CreateCFile("Main"); //write the C code into a file Creation.CompileCFile("Main", OutputFileName); //compile the C file hopefully if (!DebugMode) @@ -199,7 +197,7 @@ private static void ConvertTokens() if (Tokens[stopZone + 4] == "+" || Tokens[stopZone + 4] == "-") ConvertedTokens[ConvertedTokens.Count - 1] += Tokens[stopZone + 4]; ConvertedTokens[ConvertedTokens.Count - 1] += " ){"; //create a for loop - for (int z = i; z < stopZone - i; z++) + for (int z = i; z < stopZone; z++) Tokens.Remove(Tokens[z]); break; case "function": @@ -349,6 +347,8 @@ private static void ConvertTokens() } break; } + for (int l = 0; l < TokensToRemove.Count; l++) + Tokens.Remove(Tokens[l]); break; case "print.list.element": if (IntListNames.Contains(Tokens[i + 1])) @@ -409,11 +409,6 @@ private static void ConvertTokens() RemoveToken(new List { n, n + 1 }); } } - for (int k = i; k < Tokens.Count; k++) - if (Tokens[k] == "]" && Tokens[k + 1] == "-" && Tokens[k + 2] == "End") - break; - else - Tokens.Remove(Tokens[k]); } else if (Tokens[i + 1] == "+" && Tokens[i + 2] == "+" && Tokens[i + 3] == "-" && Tokens[i + 4] == "Code" && Tokens[i + 5] == "[") { @@ -453,14 +448,12 @@ private static void ConvertTokens() RemoveToken(new List { n, n + 1 }); } } - for (int k = i; k < Tokens.Count; k++) - if (Tokens[k] == "]" && Tokens[k + 1] == "-" && Tokens[k + 2] == "End") - break; - else - Tokens.Remove(Tokens[k]); } - foreach (string token in Tokens) - Console.WriteLine(token); + for (int k = i; k < Tokens.Count; k++) + if (Tokens[k] == "]" && Tokens[k + 1] == "-" && Tokens[k + 2] == "End") + break; + else + Tokens.Remove(Tokens[k]); break; case "return": ConvertedTokens.Add("return "); From 4dcc6792bde8f6ffdcfd7e62d8383c3b1a612131 Mon Sep 17 00:00:00 2001 From: Pyro569 Date: Sat, 11 Nov 2023 21:31:44 -0500 Subject: [PATCH 5/7] Slightly update the New Compiler --- New-Compiler/ArgReader.dl | 16 +++------------- New-Compiler/DawnLang | Bin 15696 -> 15760 bytes New-Compiler/testfile.dl | 5 ----- Old-Compiler/Tokenization.cs | 2 +- Old-Compiler/testfile.dl | 28 ++++++++++++++++++---------- 5 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 New-Compiler/testfile.dl diff --git a/New-Compiler/ArgReader.dl b/New-Compiler/ArgReader.dl index 95b9a24..fd96ef8 100644 --- a/New-Compiler/ArgReader.dl +++ b/New-Compiler/ArgReader.dl @@ -3,29 +3,19 @@ function main(args){ C-Code[ - if(argc > 1){ - for(int i = 1; i < argc; i++){ + for(int i = 1; i < argc; i++){ if(0 == strcmp(argv[i], "-b")){ printf("Build File\n"); } if(0 == strcmp(argv[i], "-br")){ printf("Build and Run File\n"); } - if(0 == strcmp(argv[2], "-d")){ + if(0 == strcmp(argv[i], "-d")){ printf("Development Debug Mode\n"); } - if(0 == strcmp(argv[i], "--version")){ + if(0 == strcmp(argv[i], "-version")){ printf("DawnLang Version 1.1.0\n"); } - if(0 == strcmp(argv[i], "--h")){ - printf("-d - Debug Mode (For development use only)\n"); - printf("-b - Build File (input file name as next arg)\n"); - printf("-br - Build and Run File (Compiles and then runs the compiled binary)\n"); - printf("--version - Outputs the DawnLang version you have installed\n"); - printf("--h - Prints out a list of possible arguments for the compiler\n"); - printf("Example Compiler Usage: ./DawnLang \"-b\" \"hello_world.dl\" \"Hello_World\"\n"); - } - } } ]-End } \ No newline at end of file diff --git a/New-Compiler/DawnLang b/New-Compiler/DawnLang index 7aafa2abd861caf935c1229e193b38d894392cd3..66b2b0fa03f5c43b3c49114989ce9157756cc50d 100755 GIT binary patch delta 1955 zcmaJ?YfRf!6u-AGD39@P2P-fbf7r4R7%dbm@2mwnN+Jx$j4+LtLc38dh4C+D%tYLr zW)sbTlejO&kt{LdrxAQG{UFIcz&?RroJ%xeMh(Ozl*JF2Y^&$~A8kgWxB1`m`kiwh z=bqE`i_>pUm+A!9Oxfq=4HJ>a#>@kUc|xZM6JVhZPX<*ajS@kTxte<|S19sw^YgS{ zjWPt6s15pQt~sV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hBL@?8m zcAgrO5J3{H9daHJLt#mgNrP}uZV}{O`jSpiugmN55T~;brGz*G)JYq}u4pf9RRSU{ zXjDQpARZ8d%0Ry;M`$!GQbi6PD%9k}*@gPLs1yv)Mk$DTNgjwsXph>Kg?^C=VJeG* zLlG*3desU>b=mPym%H5D7)aQ@0H=Es$SiSn#PQJ6YuEobgcCj698P^V}ho)xvuLds$gor@+9!ZukoeFq7Goc6x zM?&5G15b+i-hM^a{XDPA!wTPrhc_q^zPTM80ZHcZz6cOrl<~!Pg~KdezaYuP%=4YC z^}MgG0e&uCPkFw3P*A%Tg3@8}$*!=T$i&~pdpMXh7$-VP-r%@N7%z2O$Jn|g>;;%d zwwP_wgtdUT%xz6<-GudE1{<6z%P|i!{UBT^D>WxJei_V`P2rIkFL#?0+hz`C%bTpf z;VLYDQlYlOzGB%Yz}||I6{!wglInn~6(#1x7r->kR+O4&*muDU6jqj66FYtJlVf6k elzaA7 { k }); break; case "return": ConvertedTokens.Add("return "); diff --git a/Old-Compiler/testfile.dl b/Old-Compiler/testfile.dl index 08598d1..fd96ef8 100644 --- a/Old-Compiler/testfile.dl +++ b/Old-Compiler/testfile.dl @@ -1,13 +1,21 @@ #import dawnlang.io; +#import dawnlang.io.args; -function main(){ - int a = 0; - int b = 1; - int c = 1; - for (int i = 1; i < 32; i++){ - print.int(a); - c = a; - a = b; - b += c; - } +function main(args){ + C-Code[ + for(int i = 1; i < argc; i++){ + if(0 == strcmp(argv[i], "-b")){ + printf("Build File\n"); + } + if(0 == strcmp(argv[i], "-br")){ + printf("Build and Run File\n"); + } + if(0 == strcmp(argv[i], "-d")){ + printf("Development Debug Mode\n"); + } + if(0 == strcmp(argv[i], "-version")){ + printf("DawnLang Version 1.1.0\n"); + } + } + ]-End } \ No newline at end of file From bb5b34577e6e295391878ee73ff6f43265abf713 Mon Sep 17 00:00:00 2001 From: Pyro569 Date: Sat, 11 Nov 2023 22:01:25 -0500 Subject: [PATCH 6/7] Add Elements to List (int list only) --- New-Compiler/ArgReader.dl | 2 ++ New-Compiler/Tokenization.dl | 5 +++++ Old-Compiler/Tokenization.cs | 26 +++++++++++++++++++++++++- Old-Compiler/testfile.dl | 20 +++----------------- 4 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 New-Compiler/Tokenization.dl diff --git a/New-Compiler/ArgReader.dl b/New-Compiler/ArgReader.dl index fd96ef8..74b50b6 100644 --- a/New-Compiler/ArgReader.dl +++ b/New-Compiler/ArgReader.dl @@ -1,6 +1,8 @@ #import dawnlang.io; #import dawnlang.io.args; +#include Tokenization.dl; + function main(args){ C-Code[ for(int i = 1; i < argc; i++){ diff --git a/New-Compiler/Tokenization.dl b/New-Compiler/Tokenization.dl new file mode 100644 index 0000000..4cfb2ac --- /dev/null +++ b/New-Compiler/Tokenization.dl @@ -0,0 +1,5 @@ +#import dawnlang.io; + +function ReadFile(string FilePath){ + +} \ No newline at end of file diff --git a/Old-Compiler/Tokenization.cs b/Old-Compiler/Tokenization.cs index ea4a5f8..005710f 100644 --- a/Old-Compiler/Tokenization.cs +++ b/Old-Compiler/Tokenization.cs @@ -161,6 +161,8 @@ private static void ConvertTokens() ConvertedTokens.Add("int " + Tokens[i + 1] + Tokens[i + 2]); //int a = 17; if (Tokens[i + 3] == "input.int.last") ConvertedTokens[ConvertedTokens.Count - 1] += "intinput"; + if (Tokens[i + 3] == "list.size") + ConvertedTokens[ConvertedTokens.Count - 1] += "arraySize"; else ConvertedTokens[ConvertedTokens.Count - 1] += Tokens[i + 3]; ConvertedTokens[ConvertedTokens.Count - 1] += ";"; @@ -350,6 +352,19 @@ private static void ConvertTokens() for (int l = 0; l < TokensToRemove.Count; l++) Tokens.Remove(Tokens[l]); break; + case "list.size": + if (!ConvertedTokens.Contains("int arraySize")) + ConvertedTokens.Add("int"); + ConvertedTokens[ConvertedTokens.Count - 1] += " arraySize = sizeof("; + ConvertedTokens[ConvertedTokens.Count - 1] += Tokens[i + 1] + ")/4;"; + break; + case "list.element.add": + if (!ConvertedTokens.Contains("int arraySize")) + ConvertedTokens.Add("int"); + ConvertedTokens[ConvertedTokens.Count - 1] += " arraySize = sizeof("; + ConvertedTokens[ConvertedTokens.Count - 1] += Tokens[i + 1] + ")/4;"; + ConvertedTokens.Add(Tokens[i + 1] + "[arraySize] = " + Tokens[i + 3] + ";"); + break; case "print.list.element": if (IntListNames.Contains(Tokens[i + 1])) ConvertedTokens.Add("printf(\"%d\\n\", " + Tokens[i + 1] + "[" + Tokens[i + 3] + "]);"); @@ -497,7 +512,7 @@ private static void ConvertTokens() //change the value of an int variable if (IntVars.Contains(Tokens[i]) && Tokens[i - 1] != "int" && Tokens[i + 1] == "=") { - if (Tokens[i + 2] != "=" && Tokens[i + 2] != "<" && Tokens[i + 2] != ">") + if (Tokens[i + 2] != "=" && Tokens[i + 2] != "<" && Tokens[i + 2] != ">" && Tokens[i + 2] != "list.size") ConvertedTokens.Add(Tokens[i] + " " + Tokens[i + 1] + " " + Tokens[i + 2] + ";"); } else if (IntVars.Contains(Tokens[i]) && Tokens[i - 1] != "int" && Tokens[i + 1] == "+" && Tokens[i + 2] == "=") @@ -510,6 +525,15 @@ private static void ConvertTokens() ConvertedTokens.Add(Tokens[i] + " = intinput;"); RemoveToken(new List { i, i + 1, i + 2 }); } + else if (IntVars.Contains(Tokens[i]) && Tokens[i + 2] == "list.size") + { + if (!ConvertedTokens.Contains("int arraySize")) + ConvertedTokens.Insert(ConvertedTokens.Count - 1, "int"); + ConvertedTokens[ConvertedTokens.Count - 2] += " arraySize = sizeof("; + ConvertedTokens[ConvertedTokens.Count - 2] += Tokens[i + 3] + ")/4;"; + ConvertedTokens.Add(Tokens[i] + " = arraySize;"); + RemoveToken(new List { i, i + 1, i + 2 }); + } else if (StringVars.Contains(Tokens[i]) && Tokens[i + 2] == "input.str.last") { ConvertedTokens.Add(Tokens[i] + " " + Tokens[i + 1] + " strinput;"); diff --git a/Old-Compiler/testfile.dl b/Old-Compiler/testfile.dl index fd96ef8..35b2998 100644 --- a/Old-Compiler/testfile.dl +++ b/Old-Compiler/testfile.dl @@ -1,21 +1,7 @@ #import dawnlang.io; -#import dawnlang.io.args; function main(args){ - C-Code[ - for(int i = 1; i < argc; i++){ - if(0 == strcmp(argv[i], "-b")){ - printf("Build File\n"); - } - if(0 == strcmp(argv[i], "-br")){ - printf("Build and Run File\n"); - } - if(0 == strcmp(argv[i], "-d")){ - printf("Development Debug Mode\n"); - } - if(0 == strcmp(argv[i], "-version")){ - printf("DawnLang Version 1.1.0\n"); - } - } - ]-End + List intList = [12, 9, 7, 18]; + list.element.add(intList, 47); + print.list.element(intList, 4); } \ No newline at end of file From f08de94204a1666b4ac2f32c40892e79771c8159 Mon Sep 17 00:00:00 2001 From: Pyro569 Date: Sun, 12 Nov 2023 22:31:01 -0500 Subject: [PATCH 7/7] Temporarily Remove C++ abilities --- .gitignore | 3 ++- New-Compiler/ArgReader.dl | 3 +-- New-Compiler/DawnLang | Bin 15760 -> 15520 bytes New-Compiler/Tokenization.dl | 5 ----- Old-Compiler/Creation.cs | 8 ++++---- Old-Compiler/Tokenization.cs | 2 +- Old-Compiler/testfile.dl | 10 +++++----- 7 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 5400d87..d56802f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ project-scripts/ testrun.sh testrundebug.sh build.sh -Main.cpp \ No newline at end of file +Main.cpp +Main.c \ No newline at end of file diff --git a/New-Compiler/ArgReader.dl b/New-Compiler/ArgReader.dl index 74b50b6..b9c39cd 100644 --- a/New-Compiler/ArgReader.dl +++ b/New-Compiler/ArgReader.dl @@ -1,8 +1,7 @@ +#include Tokenization.dl; #import dawnlang.io; #import dawnlang.io.args; -#include Tokenization.dl; - function main(args){ C-Code[ for(int i = 1; i < argc; i++){ diff --git a/New-Compiler/DawnLang b/New-Compiler/DawnLang index 66b2b0fa03f5c43b3c49114989ce9157756cc50d..9b1e748fc7e35130e4dcf245d254604caa40c5c0 100755 GIT binary patch delta 1710 z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@rb>5@I_vMrdgSQG!i&8<7%z27J5qF-|FIp=pC z-|L)n@6hgnR|i}RHcCVvszHcU!5JhfsUlhUoQ%oknRV2ij(%^`|pgdXy?`) z9i$@`?Sc%;8ncO*;3-RP_W(}F4ot?UcKU4$oI*|^&juwXasnwoP;zGQD4v6vjB+ei z&}t=UbCDV25C@ZPh(xs;%q4yl0#EROE|p~K7DC~ITb5P%{8DtywV)A#VQH`-)mbWR zbzC*HX-LcltH0A#Lr5Du?H=h#m8?f3*_SN;!b?c9PzR%A1ZZ~|pnR6|7Zhow@cgA_i%)~|9cj04wvu1p6{&R29 zm?3W5%lPCJV*7CSxbm9%DceDUC&UtwTpn3$Kbmz!PU$XfBDJyBNVB}UH4-MJO`Tk9 zY-^UEjPnbd`Mh9m7AJHl;Ixh~uk+b(ZtZ$^im;m)qs_BK-2xT|e_W7~H5c>|FB zieK>&O7ZAvp}B??DNDD}o5|!Rq?1ThLQ=`~L^9a}9(lnFLkP`B6{$i z$GZ&C7mVI{JOV2>Hk<|_AM%P7cmnPyK{^E0UN=1eo4tok69G7Fnw?*vp9LYSIpzMu z1yl+l?Pc!uT9A=4x;h3-V2|E#8Q~00N?Hok(T7h5CaVHTQ68N{s zNW?{Cu=^ePE+VNyW6&Rv*og!|zjt{ySnzCKn7aoDE$BQTTm~Ne6kSyWw~(1pO@ds5&5Ah-+h2O?}``$=$&eBB9<#9?uGE z(HP=qK+r;w(_An7xJW)g=6-)sJc4FHZ-twVfT!9`w=urpJogZRMQ*mpu%}`^#H&+^ zSwNv4kWs)P=xY$dAm1Q@?eE@4OngblO5v~S`2|0t%66Yxd{8gxYR@02VjC9qE6PCp ziX@>>vOD diff --git a/New-Compiler/Tokenization.dl b/New-Compiler/Tokenization.dl index 4cfb2ac..e69de29 100644 --- a/New-Compiler/Tokenization.dl +++ b/New-Compiler/Tokenization.dl @@ -1,5 +0,0 @@ -#import dawnlang.io; - -function ReadFile(string FilePath){ - -} \ No newline at end of file diff --git a/Old-Compiler/Creation.cs b/Old-Compiler/Creation.cs index 17ba351..f5a381a 100644 --- a/Old-Compiler/Creation.cs +++ b/Old-Compiler/Creation.cs @@ -8,7 +8,7 @@ public static void CreateCFile(string FileName) { Tokenization.ErrorOpCode = "wc100"; //wc for writing c, 100 for first potential error spot - StreamWriter outputFile = new StreamWriter(FileName + ".cpp"); + StreamWriter outputFile = new StreamWriter(FileName + ".c"); //write each converted token to the c file foreach (string codeLines in Tokenization.ConvertedTokens) @@ -25,7 +25,7 @@ public static void CompileCFile(string FileName, string OutputFileName) Tokenization.ErrorOpCode = "cf200"; //cf for compile file, 200 for second potential error spot - Process.Start("gcc", FileName + ".cpp -w -lstdc++"); //-lstdc++ every time in case if c++ code sections are included + Process.Start("gcc", FileName + ".c -w -lstdc++"); //-lstdc++ every time in case if c++ code sections are included Thread.Sleep(1500); //small micro sleep for program to not error moving file since it is so new File.Move("./a.out", "./" + OutputFileName); } @@ -34,8 +34,8 @@ public static void Cleanup(string FileName) { Tokenization.ErrorOpCode = "cl100"; //cl for cleanup, 100 for first potential error spot - if (File.Exists("./" + FileName + ".cpp")) //delete the TempFile.c if it still exists (which it still should, if not, error) - File.Delete("./" + FileName + ".cpp"); + if (File.Exists("./" + FileName + ".c")) //delete the TempFile.c if it still exists (which it still should, if not, error) + File.Delete("./" + FileName + ".c"); else System.Environment.Exit(1); } diff --git a/Old-Compiler/Tokenization.cs b/Old-Compiler/Tokenization.cs index 005710f..fb9ca2b 100644 --- a/Old-Compiler/Tokenization.cs +++ b/Old-Compiler/Tokenization.cs @@ -292,7 +292,7 @@ private static void ConvertTokens() switch (Tokens[i + 1]) { case "dawnlang.io": - ConvertedTokens[ConvertedTokens.Count - 1] += "\n#include "; + ConvertedTokens[ConvertedTokens.Count - 1] += ""; break; case "dawnlang.data.types": ConvertedTokens[ConvertedTokens.Count - 1] += ""; diff --git a/Old-Compiler/testfile.dl b/Old-Compiler/testfile.dl index 35b2998..135d933 100644 --- a/Old-Compiler/testfile.dl +++ b/Old-Compiler/testfile.dl @@ -1,7 +1,7 @@ -#import dawnlang.io; +#include print_number_function.dl; -function main(args){ - List intList = [12, 9, 7, 18]; - list.element.add(intList, 47); - print.list.element(intList, 4); +function main(){ + int twelve = 12; + //call the print_number function from the print_number_function.dl file + print_number(twelve); } \ No newline at end of file