├── .gitignore ├── dub.json ├── main.c ├── README.md ├── LICENSE.md ├── LICENSE-human-readable.md └── source ├── preprocessor.d ├── codebuilder.d ├── compiler.d └── app.d /.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | docs/ 5 | uwu.so 6 | uwu.dylib 7 | uwu.dll 8 | uwu.a 9 | uwu.lib 10 | uwu-test-* 11 | *.exe 12 | *.o 13 | *.obj 14 | *.lst 15 | -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uwu", 3 | "authors": [ 4 | "Clipsey" 5 | ], 6 | "description": "The compiler nobody asked for, but you got anyways.", 7 | "copyright": "Copyright © 2018, Clipsey", 8 | "license": "BSL" 9 | } -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | /* 2 | THIS IS A TEST HELLO WORLD PROGRAM, YOU CAN USE uwu transpile main to transpile it! 3 | (Remember to compile this first via GCC or whatever compiler you prefer, lol) 4 | */ 5 | #include 6 | 7 | int main() { 8 | printf("Hello, world!\n"); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uwu 2 | ## The esoteric programming language nobody asked for. 3 | uwu takes code written in machine code, formatted as u and w. 4 | 5 | u is 0 6 | 7 | w is 1 8 | 9 | To compile the compiler, you will need the D language compiler, then run `dub` in this directory. 10 | 11 | ## For lawyers 12 | This project is a joke, for a proper license, see LICENSE-human-readable.md 13 | 14 | (The main license is still the Buwust license, though.) 15 | 16 | Don't rip my head off, ᵖˡᵉᵃˢᵉ. 17 | 18 | # How to use 19 | ``` 20 | Options: 21 | -t/transpile (file(s)) - Transpile binary/executable file(s) 22 | -c/compile (file(s)) - Compile uwu file(s) 23 | -l/license - Shows license text. 24 | -h/help - Shows this help text. 25 | 26 | Extras: 27 | -whatsthis - replace uwu with owo 28 | 29 | Examples: 30 | uwu -t hello.exe 31 | uwu -c hello.uwu 32 | 33 | You can also transpile non-executable files, if you really want to. 34 | uwu -t some_file.png 35 | ``` 36 | 37 | # Credits 38 | Based of an idea by ??#8008 (on discord) 39 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright © 2018, Clipsey 2 | 3 | Pewmission is heweby gwanted, fwee of chawge, to any pewson ow owganyization obtainying a copy of the softwawe and accompanying documentation cuvwed by this wicense (the "Softwawe") to use, wepwoduce, dispway, distwibute, execute, and twansmit the Softwawe, and to pwepawe dewivative wowks of the Softwawe, and to pewmit thiwd-pawties to whom the Softwawe is fuwnyished to do so, aww subject to the fowwowing: 4 | 5 | The copywight nyotices in the Softwawe and this entiwe statement, incwuding the abuv wicense gwant, this westwiction and the fowwowing discwaimew, must be incwuded in aww copies of the Softwawe, in whowe ow in pawt, and aww dewivative wowks of the Softwawe, unwess such copies ow dewivative wowks awe sowewy in the fowm of machinye-executabwe object code genyewated by a souwce wanguage pwocessow. 6 | 7 | THE SOFTWAWE IS PWOVIDED "AS IS", WITHOUT WAWWANTY OF ANY KIND, EXPWESS OW IMPWIED, INCWUDING BUT NyOT WIMITED TO THE WAWWANTIES OF MEWCHANTABIWITY, FITNyESS FOW A PAWTICUWAW PUWPOSE, TITWE AND NyON-INFWINGEMENT. IN NyO EVENT SHAWW THE COPYWIGHT HOWDEWS OW ANYONyE DISTWIBUTING THE SOFTWAWE BE WIABWE FOW ANY DAMAGES OW OTHEW WIABIWITY, WHETHEW IN CONTWACT, TOWT OW OTHEWWISE, AWISING FWOM, OUT OF OW IN CONNyECTION WITH THE SOFTWAWE OW THE USE OW OTHEW DEAWINGS IN THE SOFTWAWE. 8 | -------------------------------------------------------------------------------- /LICENSE-human-readable.md: -------------------------------------------------------------------------------- 1 | (This is the non uwu-ized version of the Buwust license, also known as Boost) 2 | 3 | Copyright © 2018, Clipsey 4 | 5 | Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: 6 | 7 | The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /source/preprocessor.d: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018, Clipsey 3 | 4 | Pewmission is heweby gwanted, fwee of chawge, to any pewson ow owganyization obtainying a copy of the softwawe and accompanying documentation cuvwed by this wicense (the "Softwawe") to use, wepwoduce, dispway, distwibute, execute, and twansmit the Softwawe, and to pwepawe dewivative wowks of the Softwawe, and to pewmit thiwd-pawties to whom the Softwawe is fuwnyished to do so, aww subject to the fowwowing: 5 | 6 | The copywight nyotices in the Softwawe and this entiwe statement, incwuding the abuv wicense gwant, this westwiction and the fowwowing discwaimew, must be incwuded in aww copies of the Softwawe, in whowe ow in pawt, and aww dewivative wowks of the Softwawe, unwess such copies ow dewivative wowks awe sowewy in the fowm of machinye-executabwe object code genyewated by a souwce wanguage pwocessow. 7 | 8 | THE SOFTWAWE IS PWOVIDED "AS IS", WITHOUT WAWWANTY OF ANY KIND, EXPWESS OW IMPWIED, INCWUDING BUT NyOT WIMITED TO THE WAWWANTIES OF MEWCHANTABIWITY, FITNyESS FOW A PAWTICUWAW PUWPOSE, TITWE AND NyON-INFWINGEMENT. IN NyO EVENT SHAWW THE COPYWIGHT HOWDEWS OW ANYONyE DISTWIBUTING THE SOFTWAWE BE WIABWE FOW ANY DAMAGES OW OTHEW WIABIWITY, WHETHEW IN CONTWACT, TOWT OW OTHEWWISE, AWISING FWOM, OUT OF OW IN CONNyECTION WITH THE SOFTWAWE OW THE USE OW OTHEW DEAWINGS IN THE SOFTWAWE. 9 | 10 | */ 11 | string preprocess(string code) { 12 | string output = ""; 13 | foreach(c; code) { 14 | if (c != ' ' && c != '\t' && c != '\n') output ~= c; 15 | } 16 | return output; 17 | } -------------------------------------------------------------------------------- /source/codebuilder.d: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018, Clipsey 3 | 4 | Pewmission is heweby gwanted, fwee of chawge, to any pewson ow owganyization obtainying a copy of the softwawe and accompanying documentation cuvwed by this wicense (the "Softwawe") to use, wepwoduce, dispway, distwibute, execute, and twansmit the Softwawe, and to pwepawe dewivative wowks of the Softwawe, and to pewmit thiwd-pawties to whom the Softwawe is fuwnyished to do so, aww subject to the fowwowing: 5 | 6 | The copywight nyotices in the Softwawe and this entiwe statement, incwuding the abuv wicense gwant, this westwiction and the fowwowing discwaimew, must be incwuded in aww copies of the Softwawe, in whowe ow in pawt, and aww dewivative wowks of the Softwawe, unwess such copies ow dewivative wowks awe sowewy in the fowm of machinye-executabwe object code genyewated by a souwce wanguage pwocessow. 7 | 8 | THE SOFTWAWE IS PWOVIDED "AS IS", WITHOUT WAWWANTY OF ANY KIND, EXPWESS OW IMPWIED, INCWUDING BUT NyOT WIMITED TO THE WAWWANTIES OF MEWCHANTABIWITY, FITNyESS FOW A PAWTICUWAW PUWPOSE, TITWE AND NyON-INFWINGEMENT. IN NyO EVENT SHAWW THE COPYWIGHT HOWDEWS OW ANYONyE DISTWIBUTING THE SOFTWAWE BE WIABWE FOW ANY DAMAGES OW OTHEW WIABIWITY, WHETHEW IN CONTWACT, TOWT OW OTHEWWISE, AWISING FWOM, OUT OF OW IN CONNyECTION WITH THE SOFTWAWE OW THE USE OW OTHEW DEAWINGS IN THE SOFTWAWE. 9 | 10 | */ 11 | import compiler; 12 | 13 | public class CodeBuilder { 14 | public ubyte[] Bytecode; 15 | 16 | public string UWUCode; 17 | private int cntr = 0; 18 | private int cntr2 = 0; 19 | 20 | public void PushByte(ubyte instr) { 21 | Bytecode ~= instr; 22 | } 23 | 24 | public void handle_count() { 25 | if (cntr >= 8) { 26 | cntr = 0; 27 | UWUCode ~= " "; 28 | cntr2++; 29 | } 30 | if (cntr2 >= 4) { 31 | cntr2 = 0; 32 | UWUCode ~= "\n"; 33 | } 34 | } 35 | 36 | public void PushBitU(bool val) { 37 | handle_count(); 38 | cntr++; 39 | if (val) UWUCode ~= "w"; 40 | else { 41 | if (OWO_ENABLED) UWUCode ~= "o"; 42 | else UWUCode ~= "u"; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /source/compiler.d: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018, Clipsey 3 | 4 | Pewmission is heweby gwanted, fwee of chawge, to any pewson ow owganyization obtainying a copy of the softwawe and accompanying documentation cuvwed by this wicense (the "Softwawe") to use, wepwoduce, dispway, distwibute, execute, and twansmit the Softwawe, and to pwepawe dewivative wowks of the Softwawe, and to pewmit thiwd-pawties to whom the Softwawe is fuwnyished to do so, aww subject to the fowwowing: 5 | 6 | The copywight nyotices in the Softwawe and this entiwe statement, incwuding the abuv wicense gwant, this westwiction and the fowwowing discwaimew, must be incwuded in aww copies of the Softwawe, in whowe ow in pawt, and aww dewivative wowks of the Softwawe, unwess such copies ow dewivative wowks awe sowewy in the fowm of machinye-executabwe object code genyewated by a souwce wanguage pwocessow. 7 | 8 | THE SOFTWAWE IS PWOVIDED "AS IS", WITHOUT WAWWANTY OF ANY KIND, EXPWESS OW IMPWIED, INCWUDING BUT NyOT WIMITED TO THE WAWWANTIES OF MEWCHANTABIWITY, FITNyESS FOW A PAWTICUWAW PUWPOSE, TITWE AND NyON-INFWINGEMENT. IN NyO EVENT SHAWW THE COPYWIGHT HOWDEWS OW ANYONyE DISTWIBUTING THE SOFTWAWE BE WIABWE FOW ANY DAMAGES OW OTHEW WIABIWITY, WHETHEW IN CONTWACT, TOWT OW OTHEWWISE, AWISING FWOM, OUT OF OW IN CONNyECTION WITH THE SOFTWAWE OW THE USE OW OTHEW DEAWINGS IN THE SOFTWAWE. 9 | 10 | */ 11 | import std.conv; 12 | import codebuilder; 13 | import std.stdio; 14 | 15 | public static bool OWO_ENABLED = false; 16 | 17 | bool set(byte b, int pos) 18 | { 19 | return (b & (1 << pos)) != 0; 20 | } 21 | 22 | void transpile(ubyte[] mcode, CodeBuilder* builder) { 23 | foreach(b; mcode) { 24 | foreach_reverse(i; 0 .. 8) { 25 | builder.PushBitU(set(b, i)); 26 | } 27 | } 28 | } 29 | 30 | void compile(string code, CodeBuilder* builder) { 31 | if (code.length == 0 || code.length % 8 != 0) { 32 | throw new Exception("No code specified, or code was not bytewords. (len%8 was "~(code.length%8).text~")"); 33 | } 34 | 35 | int acc = 0; 36 | ubyte instr = 0; 37 | foreach(i; 0 .. code.length) { 38 | acc++; 39 | char c = code[i]; 40 | instr <<= 1; 41 | if (OWO_ENABLED) { 42 | if (c == 'o') instr |= (0); 43 | else if (c == 'w') instr |= (1); 44 | else throw new Exception("Unexpected token at index "~i.text~" <"~c.text~">..."); 45 | } else { 46 | if (c == 'u') instr |= (0); 47 | else if (c == 'w') instr |= (1); 48 | else throw new Exception("Unexpected token at index "~i.text~" <"~c.text~">..."); 49 | } 50 | if (acc >= 8) { 51 | builder.PushByte(instr); 52 | acc = 0; 53 | instr = 0; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /source/app.d: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018, Clipsey 3 | 4 | Pewmission is heweby gwanted, fwee of chawge, to any pewson ow owganyization obtainying a copy of the softwawe and accompanying documentation cuvwed by this wicense (the "Softwawe") to use, wepwoduce, dispway, distwibute, execute, and twansmit the Softwawe, and to pwepawe dewivative wowks of the Softwawe, and to pewmit thiwd-pawties to whom the Softwawe is fuwnyished to do so, aww subject to the fowwowing: 5 | 6 | The copywight nyotices in the Softwawe and this entiwe statement, incwuding the abuv wicense gwant, this westwiction and the fowwowing discwaimew, must be incwuded in aww copies of the Softwawe, in whowe ow in pawt, and aww dewivative wowks of the Softwawe, unwess such copies ow dewivative wowks awe sowewy in the fowm of machinye-executabwe object code genyewated by a souwce wanguage pwocessow. 7 | 8 | THE SOFTWAWE IS PWOVIDED "AS IS", WITHOUT WAWWANTY OF ANY KIND, EXPWESS OW IMPWIED, INCWUDING BUT NyOT WIMITED TO THE WAWWANTIES OF MEWCHANTABIWITY, FITNyESS FOW A PAWTICUWAW PUWPOSE, TITWE AND NyON-INFWINGEMENT. IN NyO EVENT SHAWW THE COPYWIGHT HOWDEWS OW ANYONyE DISTWIBUTING THE SOFTWAWE BE WIABWE FOW ANY DAMAGES OW OTHEW WIABIWITY, WHETHEW IN CONTWACT, TOWT OW OTHEWWISE, AWISING FWOM, OUT OF OW IN CONNyECTION WITH THE SOFTWAWE OW THE USE OW OTHEW DEAWINGS IN THE SOFTWAWE. 9 | 10 | */ 11 | import std.stdio; 12 | import std.file; 13 | import std.conv; 14 | import codebuilder; 15 | import compiler; 16 | import preprocessor; 17 | 18 | string helptext = " 19 | Options: 20 | -t/transpile (file(s)) - Transpile binary/executable file(s) 21 | -c/compile (file(s)) - Compile uwu file(s) 22 | -l/license - Shows license text. 23 | -h/help - Shows this help text. 24 | 25 | Extras: 26 | -whatsthis - replace uwu with owo 27 | 28 | Examples: 29 | uwu -t hello.exe 30 | uwu -c hello.uwu 31 | 32 | You can also transpile non-executable files, if you really want to. 33 | uwu -t some_file.png 34 | "; 35 | 36 | string licensetext = " 37 | Copyright © 2018, Clipsey 38 | 39 | Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the \"Software\") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: 40 | 41 | The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. 42 | 43 | THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 44 | "; 45 | 46 | int main(string[] vargs) { 47 | try { 48 | if (vargs.length < 2) { 49 | writeln("Not enough arguments specified!"~helptext); 50 | return 1; 51 | } 52 | string[] args = vargs[1..$]; 53 | if (args[0] == "-whatsthis") { 54 | args = vargs[2..$]; 55 | OWO_ENABLED = true; 56 | } 57 | if (args[0] == "-t" || args[0] == "transpile") { 58 | foreach(f; args[1..$]) { 59 | if (!exists(f)) { 60 | throw new Exception("File \""~f~"\" not found!"); 61 | } 62 | CodeBuilder cb = new CodeBuilder(); 63 | // Input file 64 | File file = File(f); 65 | 66 | // Output file. 67 | string of = f; 68 | if (OWO_ENABLED) { 69 | if (f[$-4] == '.') of = f[0..$-3]~"owo"; 70 | else of = of~".owo"; 71 | } else { 72 | if (f[$-4] == '.') of = f[0..$-3]~"uwu"; 73 | else of = of~".uwu"; 74 | } 75 | File bfile = File(of, "w"); 76 | 77 | ubyte[] buffer = [1]; 78 | while (buffer.length != 0) { 79 | buffer = file.rawRead(new ubyte[4096]); 80 | transpile(buffer, &cb); 81 | } 82 | 83 | bfile.write(cb.UWUCode); 84 | writeln("Transpiled to "~of~" with byte length of "~cb.UWUCode.length.text~"..."); 85 | } 86 | return 0; 87 | } 88 | if (args[0] == "-c" || args[0] == "compile") { 89 | foreach(f; args[1..$]) { 90 | if (!exists(f)) { 91 | throw new Exception("File \""~f~"\" not found!"); 92 | } 93 | CodeBuilder cb = new CodeBuilder(); 94 | // Input file 95 | File file = File(f); 96 | 97 | // Output file. 98 | string of = f; 99 | version(Windows) { 100 | if (f[$-4] == '.') of = f[0..$-3]~"exe"; 101 | else of = of~".exe"; 102 | } else { 103 | if (f[$-4] == '.') of = f[0..$-4]; 104 | else of = of~"-elf"; 105 | } 106 | File bfile = File(of, "w"); 107 | 108 | char[] buffer = [' ']; 109 | long offset = 0; 110 | while (buffer.length != 0) { 111 | buffer = file.rawRead(new char[8]); 112 | offset += buffer.length; 113 | compile(preprocess(cast(string)buffer), &cb); 114 | 115 | // Skip whitespace characters. 116 | char[] peekc = file.rawRead(new char[1]); 117 | while (peekc.length != 0 && (peekc[0] == ' ' || peekc[0] == '\t' || peekc[0] == '\n' || peekc[0] == '\0')) { 118 | offset++; 119 | peekc = file.rawRead(new char[1]); 120 | // wait... 121 | } 122 | if (peekc.length == 0) break; 123 | file.seek(offset); 124 | } 125 | 126 | bfile.rawWrite(cb.Bytecode); 127 | writeln("Compiled to file "~of~" successfully!"); 128 | } 129 | return 0; 130 | } 131 | if (args[0] == "-l" || args[0] == "license") { 132 | writeln(licensetext); 133 | return 0; 134 | } 135 | if (args[0] == "-h" || args[0] == "help") { 136 | writeln(helptext); 137 | return 0; 138 | } 139 | writeln("Invalid option \""~args[0]~"\"!"~helptext); 140 | return 1; 141 | } catch (Exception ex) { 142 | writeln("An error occured while compiling!... <", ex.message, ">"); 143 | return 2; 144 | } 145 | } --------------------------------------------------------------------------------