├── .gitignore ├── Examples ├── hello.txt ├── hello_bf_style.txt └── multiplication_table.txt ├── KemonoFriendsLanguage.sln ├── KemonoFriendsLanguage ├── AllTokens.h ├── CallToken.cpp ├── CallToken.h ├── CmdToken.cpp ├── CmdToken.h ├── Compiler.cpp ├── Compiler.h ├── FuncToken.cpp ├── FuncToken.h ├── Interpreter.cpp ├── Interpreter.h ├── KemonoFriendsLanguage.vcxproj ├── KemonoFriendsLanguage.vcxproj.filters ├── MainToken.cpp ├── MainToken.h ├── Program.cpp ├── Program.h ├── RepeatToken.cpp ├── RepeatToken.h ├── Token.cpp ├── Token.h ├── Tokenizer.cpp ├── Tokenizer.h ├── UwaToken.cpp ├── UwaToken.h ├── WaiToken.cpp ├── WaiToken.h └── main.cpp ├── LICENSE.txt ├── README.md └── logo.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Other files 2 | *.mdj 3 | 4 | # Resource files 5 | *.ttf 6 | *.png 7 | !logo.png 8 | *.jpg 9 | *.bmp 10 | *.gif 11 | *.wav 12 | *.ogg 13 | 14 | # Compiled Object files 15 | *.slo 16 | *.lo 17 | *.o 18 | *.obj 19 | 20 | # Precompiled Headers 21 | *.gch 22 | *.pch 23 | 24 | # Compiled Dynamic libraries 25 | *.so 26 | *.dylib 27 | *.dll 28 | 29 | # Fortran module files 30 | *.mod 31 | 32 | # Compiled Static libraries 33 | *.lai 34 | *.la 35 | *.a 36 | *.lib 37 | 38 | # Executables 39 | *.exe 40 | *.out 41 | *.app 42 | 43 | ## Ignore Visual Studio temporary files, build results, and 44 | ## files generated by popular Visual Studio add-ons. 45 | 46 | # User-specific files 47 | *.suo 48 | *.user 49 | *.userosscache 50 | *.sln.docstates 51 | *.VC.opendb 52 | 53 | # User-specific files (MonoDevelop/Xamarin Studio) 54 | *.userprefs 55 | 56 | # Build results 57 | [Dd]ebug/ 58 | [Dd]ebugPublic/ 59 | [Rr]elease/ 60 | [Rr]eleases/ 61 | x64/ 62 | x86/ 63 | build/ 64 | bld/ 65 | [Bb]in/ 66 | [Oo]bj/ 67 | 68 | # Visual Studio 2015 cache/options directory 69 | .vs/ 70 | # Uncomment if you have tasks that create the project's static files in wwwroot 71 | #wwwroot/ 72 | 73 | # MSTest test Results 74 | [Tt]est[Rr]esult*/ 75 | [Bb]uild[Ll]og.* 76 | 77 | # NUNIT 78 | *.VisualState.xml 79 | TestResult.xml 80 | 81 | # Build Results of an ATL Project 82 | [Dd]ebugPS/ 83 | [Rr]eleasePS/ 84 | dlldata.c 85 | 86 | # DNX 87 | project.lock.json 88 | artifacts/ 89 | 90 | *_i.c 91 | *_p.c 92 | *_i.h 93 | *.ilk 94 | *.meta 95 | *.obj 96 | *.pch 97 | *.pdb 98 | *.pgc 99 | *.pgd 100 | *.rsp 101 | *.sbr 102 | *.tlb 103 | *.tli 104 | *.tlh 105 | *.tmp 106 | *.tmp_proj 107 | *.log 108 | *.vspscc 109 | *.vssscc 110 | .builds 111 | *.pidb 112 | *.svclog 113 | *.scc 114 | 115 | # Chutzpah Test files 116 | _Chutzpah* 117 | 118 | # Visual C++ cache files 119 | ipch/ 120 | *.aps 121 | *.ncb 122 | *.opensdf 123 | *.sdf 124 | *.db 125 | *.cachefile 126 | 127 | # Visual Studio profiler 128 | *.psess 129 | *.vsp 130 | *.vspx 131 | *.sap 132 | 133 | # TFS 2012 Local Workspace 134 | $tf/ 135 | 136 | # Guidance Automation Toolkit 137 | *.gpState 138 | 139 | # ReSharper is a .NET coding add-in 140 | _ReSharper*/ 141 | *.[Rr]e[Ss]harper 142 | *.DotSettings.user 143 | 144 | # JustCode is a .NET coding add-in 145 | .JustCode 146 | 147 | # TeamCity is a build add-in 148 | _TeamCity* 149 | 150 | # DotCover is a Code Coverage Tool 151 | *.dotCover 152 | 153 | # NCrunch 154 | _NCrunch_* 155 | .*crunch*.local.xml 156 | nCrunchTemp_* 157 | 158 | # MightyMoose 159 | *.mm.* 160 | AutoTest.Net/ 161 | 162 | # Web workbench (sass) 163 | .sass-cache/ 164 | 165 | # Installshield output folder 166 | [Ee]xpress/ 167 | 168 | # DocProject is a documentation generator add-in 169 | DocProject/buildhelp/ 170 | DocProject/Help/*.HxT 171 | DocProject/Help/*.HxC 172 | DocProject/Help/*.hhc 173 | DocProject/Help/*.hhk 174 | DocProject/Help/*.hhp 175 | DocProject/Help/Html2 176 | DocProject/Help/html 177 | 178 | # Click-Once directory 179 | publish/ 180 | 181 | # Publish Web Output 182 | *.[Pp]ublish.xml 183 | *.azurePubxml 184 | # TODO: Comment the next line if you want to checkin your web deploy settings 185 | # but database connection strings (with potential passwords) will be unencrypted 186 | *.pubxml 187 | *.publishproj 188 | 189 | # NuGet Packages 190 | *.nupkg 191 | # The packages folder can be ignored because of Package Restore 192 | **/packages/* 193 | # except build/, which is used as an MSBuild target. 194 | !**/packages/build/ 195 | # Uncomment if necessary however generally it will be regenerated when needed 196 | #!**/packages/repositories.config 197 | 198 | # Windows Azure Build Output 199 | csx/ 200 | *.build.csdef 201 | 202 | # Windows Azure Emulator 203 | efc/ 204 | rfc/ 205 | 206 | # Windows Store app package directory 207 | AppPackages/ 208 | 209 | # Visual Studio cache files 210 | # files ending in .cache can be ignored 211 | *.[Cc]ache 212 | # but keep track of directories ending in .cache 213 | !*.[Cc]ache/ 214 | 215 | # Others 216 | ClientBin/ 217 | [Ss]tyle[Cc]op.* 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.pfx 223 | *.publishsettings 224 | node_modules/ 225 | orleans.codegen.cs 226 | 227 | # RIA/Silverlight projects 228 | Generated_Code/ 229 | 230 | # Backup & report files from converting an old project file 231 | # to a newer Visual Studio version. Backup files are not needed, 232 | # because we have git ;-) 233 | _UpgradeReport_Files/ 234 | Backup*/ 235 | UpgradeLog*.XML 236 | UpgradeLog*.htm 237 | 238 | # SQL Server files 239 | *.mdf 240 | *.ldf 241 | 242 | # Business Intelligence projects 243 | *.rdl.data 244 | *.bim.layout 245 | *.bim_*.settings 246 | 247 | # Microsoft Fakes 248 | FakesAssemblies/ 249 | 250 | # GhostDoc plugin setting file 251 | *.GhostDoc.xml 252 | 253 | # Node.js Tools for Visual Studio 254 | .ntvs_analysis.dat 255 | 256 | # Visual Studio 6 build log 257 | *.plg 258 | 259 | # Visual Studio 6 workspace options file 260 | *.opt 261 | 262 | # Visual Studio LightSwitch build output 263 | **/*.HTMLClient/GeneratedArtifacts 264 | **/*.DesktopClient/GeneratedArtifacts 265 | **/*.DesktopClient/ModelManifest.xml 266 | **/*.Server/GeneratedArtifacts 267 | **/*.Server/ModelManifest.xml 268 | _Pvt_Extensions 269 | 270 | # Paket dependency manager 271 | .paket/paket.exe 272 | 273 | # FAKE - F# Make 274 | .fake/ -------------------------------------------------------------------------------- /Examples/hello.txt: -------------------------------------------------------------------------------- 1 | # Print Function 2 | friends say_hello 3 | '0' 4 | tanoshi! 5 | "!dlroW ,olleH" 6 | uwa~ 7 | omoshiro! 8 | sugoi! 9 | wai~ 10 | # Main Function 11 | youkoso 12 | sandstar say_hello -------------------------------------------------------------------------------- /Examples/hello_bf_style.txt: -------------------------------------------------------------------------------- 1 | ta-----~noshi 2 | uwa~ 3 | tanoshi! ta-------noshi! 4 | ta----------noshi! 5 | ta---noshi! 6 | ta-noshi 7 | sugoi!!!! 8 | sugo-i 9 | wai~ 10 | tanoshi! 11 | ta--noshi 12 | omoshiro! 13 | tanoshi! 14 | ta-noshi 15 | omoshiro! 16 | ta-------noshi 17 | omoshiro! 18 | omoshiro! 19 | ta---noshi 20 | omoshiro! 21 | tanoshi! 22 | ta--noshi 23 | omoshiro! 24 | sugoi!! 25 | ta---------------noshi 26 | omoshiro! 27 | tanoshi! 28 | omoshiro! 29 | ta---noshi 30 | omoshiro! 31 | sugo------i 32 | omoshiro! 33 | sugo--------i 34 | omoshiro! 35 | tanoshi! 36 | ta-noshi 37 | omoshiro! 38 | tanoshi! 39 | omoshiro! -------------------------------------------------------------------------------- /Examples/multiplication_table.txt: -------------------------------------------------------------------------------- 1 | # [0] += [1] 2 | # [1] = 0 3 | friends can_do_addition 4 | tanoshi! 5 | uwa~ 6 | sugo-i! 7 | ta-noshi! 8 | wai~ 9 | 10 | # [0] *= [1] 11 | friends can_do_multiplication 12 | shaberu 13 | tanoshi! 14 | sugo-i 15 | la 16 | sugoi!! 17 | la 18 | tanoshi! 19 | uwa~ 20 | sugoi!! 21 | sandstar can_do_addition 22 | tanoshi! 23 | shabetta 24 | tanoshi! 25 | sugo-i 26 | wai~ 27 | 28 | # Print [0] to number. 29 | # Only 0~99 30 | friends can_say_number 31 | tanoshi! 32 | '0' 33 | tanoshi! 34 | # This friends not so smart. 35 | " 0 1 2 3 4 5 6 7 8 9 " 36 | "10 11 12 13 14 15 16 17 18 19 " 37 | "20 21 22 23 24 25 26 27 28 29 " 38 | "30 31 32 33 34 35 36 37 38 39 " 39 | "40 41 42 43 44 45 46 47 48 49 " 40 | "50 51 52 53 54 55 56 57 58 59 " 41 | "60 61 62 63 64 65 66 67 68 69 " 42 | "70 71 72 73 74 75 76 77 78 79 " 43 | "80 81 82 83 84 85 86 87 88 89 " 44 | "90 91 92 93 94 95 96 97 98 99 " 45 | uwa~ 46 | sugoi! 47 | wai~ 48 | sugoi! 49 | shaberu 50 | tanoshi! 51 | '1' 52 | uwa~ 53 | tanoshi!!! 54 | shabetta 55 | sugo-i 56 | shaberu 57 | wai~ 58 | tanoshi! 59 | omoshiro!! 60 | 61 | # Welcome to Japari-Math! 62 | youkoso 63 | '0 9 8 7 6 5 4 3 2' 64 | uwa~~ 65 | la la la 66 | sugoi!! 67 | '2' 68 | u----------wa~ 69 | la 70 | sugoi!! 71 | shaberu 72 | tanoshi!!!!!! 73 | shabetta 74 | sandstar can_say_number 75 | "x" 76 | omoshiro! 77 | sugoi!!!! 78 | shaberu 79 | tanoshi!!!!!!! 80 | shabetta 81 | sandstar can_say_number 82 | "=" 83 | omoshiro! 84 | sugoi!!!!!!! 85 | sandstar can_do_multiplication 86 | sandstar can_say_number 87 | '10' # new line 88 | omoshiro! 89 | sugoi!! 90 | shaberu 91 | tanoshi!!! 92 | shabetta 93 | sugoi!! 94 | ta-noshi 95 | wa----------i~ 96 | sugoi!! 97 | wai~~ -------------------------------------------------------------------------------- /KemonoFriendsLanguage.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.4 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KemonoFriendsLanguage", "KemonoFriendsLanguage\KemonoFriendsLanguage.vcxproj", "{7E4EF414-3121-4DFB-9BEE-17872E455BE5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Debug|x64.ActiveCfg = Debug|x64 17 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Debug|x64.Build.0 = Debug|x64 18 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Debug|x86.ActiveCfg = Debug|Win32 19 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Debug|x86.Build.0 = Debug|Win32 20 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Release|x64.ActiveCfg = Release|x64 21 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Release|x64.Build.0 = Release|x64 22 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Release|x86.ActiveCfg = Release|Win32 23 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/AllTokens.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__ALL_TOKENS_H__ 2 | #define __KFL__ALL_TOKENS_H__ 3 | 4 | 5 | #include "Token.h" 6 | #include "CmdToken.h" 7 | #include "CallToken.h" 8 | #include "FuncToken.h" 9 | #include "RepeatToken.h" 10 | #include "MainToken.h" 11 | #include "UwaToken.h" 12 | #include "WaiToken.h" 13 | 14 | 15 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/CallToken.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeuroWhAI/KemonoFriendsLanguage/cc3fa11a8ce80ba16b30da316a85849c3fa93842/KemonoFriendsLanguage/CallToken.cpp -------------------------------------------------------------------------------- /KemonoFriendsLanguage/CallToken.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__CALL_TOKEN_H__ 2 | #define __KFL__CALL_TOKEN_H__ 3 | 4 | 5 | #include 6 | 7 | #include "Token.h" 8 | 9 | 10 | 11 | 12 | class CallToken : public Token 13 | { 14 | public: 15 | CallToken(const std::unordered_map& funcTable, 16 | const std::initializer_list& tokens); 17 | 18 | 19 | private: 20 | const std::unordered_map& m_funcTable; 21 | 22 | 23 | protected: 24 | virtual std::size_t compile(const std::vector& tokens, 25 | std::vector::const_iterator itr, 26 | const std::string& code, Program& proc) const override; 27 | }; 28 | 29 | 30 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/CmdToken.cpp: -------------------------------------------------------------------------------- 1 | #include "CmdToken.h" 2 | 3 | #include "Program.h" 4 | 5 | 6 | 7 | 8 | CmdToken::CmdToken(Program::Types type, const std::initializer_list& tokens) 9 | : Token(tokens) 10 | , m_type(type) 11 | { 12 | 13 | } 14 | 15 | //################################################################################################### 16 | 17 | std::size_t CmdToken::compile(const std::vector& tokens, 18 | std::vector::const_iterator itr, 19 | const std::string& code, Program& proc) const 20 | { 21 | proc.pushCmd(m_type, code); 22 | 23 | 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/CmdToken.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__CMD_TOKEN_H__ 2 | #define __KFL__CMD_TOKEN_H__ 3 | 4 | 5 | #include "Token.h" 6 | 7 | #include "Program.h" 8 | 9 | 10 | 11 | 12 | class CmdToken : public Token 13 | { 14 | public: 15 | CmdToken(Program::Types type, const std::initializer_list& tokens); 16 | 17 | 18 | private: 19 | Program::Types m_type; 20 | 21 | 22 | protected: 23 | virtual std::size_t compile(const std::vector& tokens, 24 | std::vector::const_iterator itr, 25 | const std::string& code, Program& proc) const override; 26 | }; 27 | 28 | 29 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Compiler.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeuroWhAI/KemonoFriendsLanguage/cc3fa11a8ce80ba16b30da316a85849c3fa93842/KemonoFriendsLanguage/Compiler.cpp -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__COMPILER_H__ 2 | #define __KFL__COMPILER_H__ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "AllTokens.h" 10 | #include "Program.h" 11 | 12 | 13 | 14 | 15 | class Compiler 16 | { 17 | public: 18 | Compiler(); 19 | 20 | 21 | private: 22 | const std::vector m_tokenList; 23 | CmdToken m_stringToken; 24 | CmdToken m_numberToken; 25 | FuncToken m_funcToken; 26 | CallToken m_callToken; 27 | MainToken m_mainToken; 28 | CmdToken m_tanoshiToken; 29 | CmdToken m_sugoiToken; 30 | UwaToken m_uwaToken; 31 | WaiToken m_waiToken; 32 | CmdToken m_naniToken; 33 | CmdToken m_omoshiToken; 34 | RepeatToken m_lalaToken; 35 | RepeatToken m_myaToken; 36 | CmdToken m_writeRegToken; 37 | CmdToken m_readRegToken; 38 | 39 | 40 | private: 41 | std::unordered_map m_funcTable; 42 | 43 | 44 | public: 45 | Program compile(const std::vector& tokens); 46 | }; 47 | 48 | 49 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/FuncToken.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeuroWhAI/KemonoFriendsLanguage/cc3fa11a8ce80ba16b30da316a85849c3fa93842/KemonoFriendsLanguage/FuncToken.cpp -------------------------------------------------------------------------------- /KemonoFriendsLanguage/FuncToken.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__FUNC_TOKEN_H__ 2 | #define __KFL__FUNC_TOKEN_H__ 3 | 4 | 5 | #include "Token.h" 6 | 7 | 8 | 9 | 10 | class FuncToken : public Token 11 | { 12 | public: 13 | FuncToken(const std::initializer_list& tokens); 14 | 15 | 16 | protected: 17 | virtual std::size_t compile(const std::vector& tokens, 18 | std::vector::const_iterator itr, 19 | const std::string& code, Program& proc) const override; 20 | }; 21 | 22 | 23 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Interpreter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeuroWhAI/KemonoFriendsLanguage/cc3fa11a8ce80ba16b30da316a85849c3fa93842/KemonoFriendsLanguage/Interpreter.cpp -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Interpreter.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__INTERPRETER_H__ 2 | #define __KFL__INTERPRETER_H__ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "Program.h" 12 | 13 | 14 | 15 | 16 | class Interpreter 17 | { 18 | private: 19 | struct CallStack 20 | { 21 | std::size_t head; 22 | std::size_t ptr; 23 | std::vector ram; 24 | }; 25 | 26 | using CmdFunc = void(Interpreter::*)(std::istringstream&); 27 | 28 | 29 | public: 30 | Interpreter(); 31 | 32 | 33 | private: 34 | Program m_proc; 35 | char m_register; 36 | std::size_t m_head; 37 | std::vector m_ram; 38 | std::size_t m_ptr; 39 | std::stack m_callStack; 40 | std::vector m_cmdList; 41 | 42 | 43 | private: 44 | void registerCmd(Program::Types type, CmdFunc cmd); 45 | 46 | 47 | public: 48 | void setProgram(const Program& proc); 49 | void run(); 50 | 51 | 52 | private: 53 | void incPtr(); 54 | void decPtr(); 55 | 56 | 57 | private: 58 | void cmdNop(std::istringstream& sr); 59 | void cmdString(std::istringstream& sr); 60 | void cmdNumbers(std::istringstream& sr); 61 | void cmdFunc(std::istringstream& sr); 62 | void cmdCall(std::istringstream& sr); 63 | void cmdTanoshi(std::istringstream& sr); 64 | void cmdSugoi(std::istringstream& sr); 65 | void cmdUwa(std::istringstream& sr); 66 | void cmdWai(std::istringstream& sr); 67 | void cmdNanikore(std::istringstream& sr); 68 | void cmdOmoshiro(std::istringstream& sr); 69 | void cmdLala(std::istringstream& sr); 70 | void cmdMya(std::istringstream& sr); 71 | void cmdWriteReg(std::istringstream& sr); 72 | void cmdReadReg(std::istringstream& sr); 73 | }; 74 | 75 | 76 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/KemonoFriendsLanguage.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {7E4EF414-3121-4DFB-9BEE-17872E455BE5} 24 | Win32Proj 25 | KemonoFriendsLanguage 26 | 10.0.14393.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v141 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v141 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v141 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v141 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | 93 | 94 | Console 95 | 96 | 97 | 98 | 99 | 100 | 101 | Level3 102 | Disabled 103 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | 105 | 106 | Console 107 | 108 | 109 | 110 | 111 | Level3 112 | 113 | 114 | MaxSpeed 115 | true 116 | true 117 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | 119 | 120 | Console 121 | true 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | 129 | 130 | MaxSpeed 131 | true 132 | true 133 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 134 | 135 | 136 | Console 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/KemonoFriendsLanguage.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {9a6a309b-a4a7-4142-abf0-70a6533eb57c} 18 | 19 | 20 | {25300ee8-2176-45a5-bcf4-7b6950b3926f} 21 | 22 | 23 | {dd323136-1f5e-40ec-b54f-fc44a1369652} 24 | 25 | 26 | {73de21e3-4f0f-4eea-9372-4dd4a7b6e300} 27 | 28 | 29 | {db74dc46-f858-454b-880c-6cfdbac62dc5} 30 | 31 | 32 | {4db65597-2d66-4589-865e-b27c8765b7db} 33 | 34 | 35 | 36 | 37 | 소스 파일 38 | 39 | 40 | KFL\Compiler 41 | 42 | 43 | KFL\Program 44 | 45 | 46 | KFL\Interpreter 47 | 48 | 49 | KFL\Tokenizer 50 | 51 | 52 | KFL\Token 53 | 54 | 55 | KFL\Token 56 | 57 | 58 | KFL\Token 59 | 60 | 61 | KFL\Token 62 | 63 | 64 | KFL\Token 65 | 66 | 67 | KFL\Token 68 | 69 | 70 | KFL\Token 71 | 72 | 73 | KFL\Token 74 | 75 | 76 | 77 | 78 | KFL\Compiler 79 | 80 | 81 | KFL\Program 82 | 83 | 84 | KFL\Interpreter 85 | 86 | 87 | KFL\Tokenizer 88 | 89 | 90 | KFL\Token 91 | 92 | 93 | KFL\Token 94 | 95 | 96 | KFL\Token 97 | 98 | 99 | KFL\Token 100 | 101 | 102 | KFL\Token 103 | 104 | 105 | KFL\Token 106 | 107 | 108 | KFL\Token 109 | 110 | 111 | KFL\Token 112 | 113 | 114 | KFL\Token 115 | 116 | 117 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/MainToken.cpp: -------------------------------------------------------------------------------- 1 | #include "MainToken.h" 2 | 3 | #include "Program.h" 4 | 5 | 6 | 7 | 8 | MainToken::MainToken(const std::initializer_list& tokens) 9 | : Token(tokens) 10 | { 11 | 12 | } 13 | 14 | //################################################################################################### 15 | 16 | std::size_t MainToken::compile(const std::vector& tokens, 17 | std::vector::const_iterator itr, 18 | const std::string& code, Program& proc) const 19 | { 20 | proc.pushCmd(Program::Types::FUNC); 21 | 22 | 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/MainToken.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__MAIN_TOKEN_H__ 2 | #define __KFL__MAIN_TOKEN_H__ 3 | 4 | 5 | #include "Token.h" 6 | 7 | 8 | 9 | 10 | class MainToken : public Token 11 | { 12 | public: 13 | MainToken(const std::initializer_list& tokens); 14 | 15 | 16 | protected: 17 | virtual std::size_t compile(const std::vector& tokens, 18 | std::vector::const_iterator itr, 19 | const std::string& code, Program& proc) const override; 20 | }; 21 | 22 | 23 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Program.cpp: -------------------------------------------------------------------------------- 1 | #include "Program.h" 2 | 3 | #include 4 | #include 5 | 6 | 7 | 8 | 9 | Program::Program() 10 | : m_beginIndex(0) 11 | { 12 | 13 | } 14 | 15 | //################################################################################################### 16 | 17 | void Program::setMain(std::size_t index) 18 | { 19 | m_beginIndex = index; 20 | } 21 | 22 | 23 | void Program::pushCall(std::size_t destIndex) 24 | { 25 | const char typeChar = static_cast(TYPE_TO_CHAR + static_cast(Types::CALL)); 26 | 27 | m_code.emplace_back(std::string({ typeChar }) + std::to_string(destIndex)); 28 | } 29 | 30 | 31 | void Program::pushCmd(Types type) 32 | { 33 | const char typeChar = static_cast(TYPE_TO_CHAR + static_cast(type)); 34 | 35 | m_code.emplace_back(std::string({ typeChar })); 36 | } 37 | 38 | 39 | void Program::pushCmd(Types type, const std::string& arg) 40 | { 41 | const char typeChar = static_cast(TYPE_TO_CHAR + static_cast(type)); 42 | 43 | m_code.emplace_back(std::string({ typeChar }) + arg); 44 | } 45 | 46 | //################################################################################################### 47 | 48 | void Program::appendUwaiList() 49 | { 50 | m_uwaIDList.emplace_back(0); 51 | m_uwaArgList.emplace_back(0); 52 | m_waiIDList.emplace_back(0); 53 | m_waiArgList.emplace_back(0); 54 | } 55 | 56 | 57 | void Program::increaseUwaID() 58 | { 59 | ++m_uwaIDList.back(); 60 | } 61 | 62 | 63 | void Program::increaseUwaArg() 64 | { 65 | if (m_uwaArgList.back() >= std::numeric_limits::max()) 66 | throw std::exception("Too big uwa-arg."); 67 | 68 | ++m_uwaArgList.back(); 69 | } 70 | 71 | 72 | void Program::increaseWaiID() 73 | { 74 | ++m_waiIDList.back(); 75 | } 76 | 77 | 78 | void Program::increaseWaiArg() 79 | { 80 | if (m_waiArgList.back() >= std::numeric_limits::max()) 81 | throw std::exception("Too big wai-arg."); 82 | 83 | ++m_waiArgList.back(); 84 | } 85 | 86 | 87 | std::size_t Program::getUwaID(std::size_t index) const 88 | { 89 | return m_uwaIDList[index]; 90 | } 91 | 92 | 93 | char Program::getUwaArg(std::size_t index) const 94 | { 95 | return m_uwaArgList[index]; 96 | } 97 | 98 | 99 | std::size_t Program::getWaiID(std::size_t index) const 100 | { 101 | return m_waiIDList[index]; 102 | } 103 | 104 | 105 | char Program::getWaiArg(std::size_t index) const 106 | { 107 | return m_waiArgList[index]; 108 | } 109 | 110 | //################################################################################################### 111 | 112 | std::size_t Program::getStartIndex() const 113 | { 114 | return m_beginIndex; 115 | } 116 | 117 | 118 | const std::vector& Program::getCode() const 119 | { 120 | return m_code; 121 | } 122 | 123 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Program.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__PROGRAM_H__ 2 | #define __KFL__PROGRAM_H__ 3 | 4 | 5 | #include 6 | #include 7 | 8 | 9 | 10 | 11 | class Program 12 | { 13 | public: 14 | static const int TYPE_TO_CHAR = 32; 15 | enum class Types : int 16 | { 17 | NOP = 0, 18 | STR, 19 | NUM, 20 | FUNC, 21 | CALL, 22 | TAN, 23 | SUG, 24 | UWA, 25 | WAI, 26 | NANI, 27 | OMOS, 28 | LAL, 29 | MYA, 30 | SARU, 31 | SABT, 32 | 33 | //---------------------------- 34 | Count 35 | }; 36 | 37 | 38 | public: 39 | Program(); 40 | 41 | 42 | private: 43 | std::size_t m_beginIndex; 44 | std::vector m_code; 45 | std::vector m_uwaIDList; 46 | std::vector m_uwaArgList; 47 | std::vector m_waiIDList; 48 | std::vector m_waiArgList; 49 | 50 | 51 | public: 52 | void setMain(std::size_t index); 53 | void pushCall(std::size_t destIndex); 54 | void pushCmd(Types type); 55 | void pushCmd(Types type, const std::string& arg); 56 | 57 | 58 | public: 59 | void appendUwaiList(); 60 | void increaseUwaID(); 61 | void increaseUwaArg(); 62 | void increaseWaiID(); 63 | void increaseWaiArg(); 64 | std::size_t getUwaID(std::size_t index) const; 65 | char getUwaArg(std::size_t index) const; 66 | std::size_t getWaiID(std::size_t index) const; 67 | char getWaiArg(std::size_t index) const; 68 | 69 | 70 | public: 71 | std::size_t getStartIndex() const; 72 | const std::vector& getCode() const; 73 | }; 74 | 75 | 76 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/RepeatToken.cpp: -------------------------------------------------------------------------------- 1 | #include "RepeatToken.h" 2 | 3 | #include "Program.h" 4 | 5 | 6 | 7 | 8 | RepeatToken::RepeatToken(Program::Types type, const std::initializer_list& tokens) 9 | : Token(tokens) 10 | , m_type(type) 11 | { 12 | 13 | } 14 | 15 | //################################################################################################### 16 | 17 | std::size_t RepeatToken::compile(const std::vector& tokens, 18 | std::vector::const_iterator itr, 19 | const std::string& code, Program& proc) const 20 | { 21 | std::string cmd; 22 | 23 | for (std::size_t laOffset = 0; laOffset < code.size();) 24 | { 25 | bool findTok = false; 26 | 27 | for (auto& tok : tokens) 28 | { 29 | if (code.find(tok, laOffset) == laOffset) 30 | { 31 | laOffset += tok.length(); 32 | 33 | cmd.push_back(ONE_CHAR_ONE_TOKEN); 34 | 35 | findTok = true; 36 | break; 37 | } 38 | } 39 | 40 | if (findTok == false) 41 | { 42 | ++laOffset; 43 | } 44 | } 45 | 46 | proc.pushCmd(m_type, cmd); 47 | 48 | 49 | return 0; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/RepeatToken.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__REPEAT_TOKEN_H__ 2 | #define __KFL__REPEAT_TOKEN_H__ 3 | 4 | 5 | #include "Token.h" 6 | 7 | #include "Program.h" 8 | 9 | 10 | 11 | 12 | class RepeatToken : public Token 13 | { 14 | public: 15 | static const char ONE_CHAR_ONE_TOKEN = '-'; 16 | 17 | 18 | public: 19 | RepeatToken(Program::Types type, const std::initializer_list& tokens); 20 | 21 | 22 | private: 23 | Program::Types m_type; 24 | 25 | 26 | protected: 27 | virtual std::size_t compile(const std::vector& tokens, 28 | std::vector::const_iterator itr, 29 | const std::string& code, Program& proc) const override; 30 | }; 31 | 32 | 33 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Token.cpp: -------------------------------------------------------------------------------- 1 | #include "Token.h" 2 | 3 | #include 4 | 5 | 6 | 7 | 8 | Token::Token(const std::initializer_list& tokens) 9 | : m_tokens(tokens) 10 | { 11 | 12 | } 13 | 14 | //################################################################################################### 15 | 16 | bool Token::check(const std::string& code) const 17 | { 18 | for (auto& tok : m_tokens) 19 | { 20 | if (code.find(tok) == 0) 21 | { 22 | return true; 23 | } 24 | } 25 | 26 | return false; 27 | } 28 | 29 | 30 | std::pair Token::checkAndCompile(std::vector::const_iterator itr, 31 | const std::string& code, Program& proc) const 32 | { 33 | if (check(code)) 34 | { 35 | auto skipCount = compile(m_tokens, itr, code, proc); 36 | 37 | return std::make_pair(true, skipCount); 38 | } 39 | 40 | return std::make_pair(false, 0); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Token.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__TOKEN_H__ 2 | #define __KFL__TOKEN_H__ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | 12 | 13 | class Program; 14 | 15 | 16 | class Token 17 | { 18 | public: 19 | Token(const std::initializer_list& tokens); 20 | virtual ~Token() = default; 21 | 22 | 23 | private: 24 | const std::vector m_tokens; 25 | 26 | 27 | public: 28 | bool check(const std::string& code) const; 29 | std::pair checkAndCompile(std::vector::const_iterator itr, 30 | const std::string& code, Program& proc) const; 31 | 32 | 33 | protected: 34 | virtual std::size_t compile(const std::vector& tokens, 35 | std::vector::const_iterator itr, 36 | const std::string& code, Program& proc) const = 0; 37 | }; 38 | 39 | 40 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Tokenizer.cpp: -------------------------------------------------------------------------------- 1 | #include "Tokenizer.h" 2 | 3 | #include 4 | 5 | 6 | 7 | 8 | Tokenizer::Tokenizer() 9 | { 10 | 11 | } 12 | 13 | //################################################################################################### 14 | 15 | void Tokenizer::parse(std::istream& reader) 16 | { 17 | m_tokens.clear(); 18 | 19 | 20 | while (!reader.eof()) 21 | { 22 | char ch = reader.get(); 23 | 24 | if (ch == '#') 25 | { 26 | eatLineComment(reader); 27 | } 28 | else if (ch == '\"') 29 | { 30 | m_tokens.emplace_back("\""); 31 | readString(reader, m_tokens.back()); 32 | } 33 | else if (ch == '\'') 34 | { 35 | m_tokens.emplace_back("\'"); 36 | readNumbers(reader, m_tokens.back()); 37 | } 38 | else if (isCommandChar(ch)) 39 | { 40 | m_tokens.push_back({ ch }); 41 | readCommand(reader, m_tokens.back()); 42 | } 43 | } 44 | } 45 | 46 | 47 | const std::vector& Tokenizer::getTokens() const 48 | { 49 | return m_tokens; 50 | } 51 | 52 | //################################################################################################### 53 | 54 | void Tokenizer::eatLineComment(std::istream& sr) 55 | { 56 | while (!sr.eof() && sr.good()) 57 | { 58 | if (sr.get() == '\n') 59 | break; 60 | } 61 | } 62 | 63 | 64 | void Tokenizer::readString(std::istream& sr, std::string& out) 65 | { 66 | while (!sr.eof() && sr.good()) 67 | { 68 | char ch = sr.get(); 69 | 70 | out.push_back(ch); 71 | 72 | if (ch == '\"') 73 | { 74 | return; 75 | } 76 | } 77 | 78 | 79 | throw std::exception("Unexpected end of file in string."); 80 | } 81 | 82 | 83 | void Tokenizer::readNumbers(std::istream& sr, std::string& out) 84 | { 85 | while (!sr.eof() && sr.good()) 86 | { 87 | char ch = sr.get(); 88 | 89 | out.push_back(ch); 90 | 91 | if (ch == '\'') 92 | { 93 | return; 94 | } 95 | } 96 | 97 | 98 | throw std::exception("Unexpected end of file in numbers."); 99 | } 100 | 101 | 102 | void Tokenizer::readCommand(std::istream& sr, std::string& out) 103 | { 104 | while (!sr.eof()) 105 | { 106 | char ch = sr.peek(); 107 | 108 | if (isCommandChar(ch) == false) 109 | break; 110 | 111 | if (sr.good()) 112 | out.push_back(sr.get()); 113 | } 114 | } 115 | 116 | //################################################################################################### 117 | 118 | bool Tokenizer::isCommandChar(char ch) 119 | { 120 | return ((ch >= 'a' && ch <= 'z') 121 | || (ch >= 'A' && ch <= 'Z') 122 | || (ch >= '0' && ch <= '9') 123 | || ch == '!' || ch == '?' 124 | || ch == '-' || ch == '~' 125 | || ch == '_' 126 | || (ch & 0x80) != 0); 127 | } 128 | 129 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/Tokenizer.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__TOKENIZER_H__ 2 | #define __KFL__TOKENIZER_H__ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | 12 | class Tokenizer 13 | { 14 | public: 15 | Tokenizer(); 16 | 17 | 18 | public: 19 | std::vector m_tokens; 20 | 21 | 22 | public: 23 | void parse(std::istream& reader); 24 | const std::vector& getTokens() const; 25 | 26 | 27 | private: 28 | void eatLineComment(std::istream& sr); 29 | void readString(std::istream& sr, std::string& out); 30 | void readNumbers(std::istream& sr, std::string& out); 31 | void readCommand(std::istream& sr, std::string& out); 32 | 33 | 34 | private: 35 | bool isCommandChar(char ch); 36 | }; 37 | 38 | 39 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/UwaToken.cpp: -------------------------------------------------------------------------------- 1 | #include "UwaToken.h" 2 | 3 | #include 4 | 5 | #include "Program.h" 6 | 7 | 8 | 9 | 10 | UwaToken::UwaToken(const std::initializer_list& tokens) 11 | : Token(tokens) 12 | { 13 | 14 | } 15 | 16 | //################################################################################################### 17 | 18 | std::size_t UwaToken::compile(const std::vector& tokens, 19 | std::vector::const_iterator itr, 20 | const std::string& code, Program& proc) const 21 | { 22 | proc.pushCmd(Program::Types::UWA, code); 23 | 24 | 25 | std::istringstream sr{ code }; 26 | 27 | proc.increaseUwaID(); 28 | 29 | while (!sr.eof()) 30 | { 31 | auto ch = sr.get(); 32 | 33 | if (ch == '-') 34 | { 35 | proc.increaseUwaArg(); 36 | } 37 | else if (ch == '~') 38 | { 39 | proc.increaseUwaID(); 40 | } 41 | } 42 | 43 | 44 | return 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/UwaToken.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__UWA_TOKEN_H__ 2 | #define __KFL__UWA_TOKEN_H__ 3 | 4 | 5 | #include "Token.h" 6 | 7 | 8 | 9 | 10 | class UwaToken : public Token 11 | { 12 | public: 13 | UwaToken(const std::initializer_list& tokens); 14 | 15 | 16 | protected: 17 | virtual std::size_t compile(const std::vector& tokens, 18 | std::vector::const_iterator itr, 19 | const std::string& code, Program& proc) const override; 20 | }; 21 | 22 | 23 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/WaiToken.cpp: -------------------------------------------------------------------------------- 1 | #include "WaiToken.h" 2 | 3 | #include 4 | 5 | #include "Program.h" 6 | 7 | 8 | 9 | 10 | WaiToken::WaiToken(const std::initializer_list& tokens) 11 | : Token(tokens) 12 | { 13 | 14 | } 15 | 16 | //################################################################################################### 17 | 18 | std::size_t WaiToken::compile(const std::vector& tokens, 19 | std::vector::const_iterator itr, 20 | const std::string& code, Program& proc) const 21 | { 22 | proc.pushCmd(Program::Types::WAI, code); 23 | 24 | 25 | std::istringstream sr{ code }; 26 | 27 | proc.increaseWaiID(); 28 | 29 | while (!sr.eof()) 30 | { 31 | auto ch = sr.get(); 32 | 33 | if (ch == '-') 34 | { 35 | proc.increaseWaiArg(); 36 | } 37 | else if (ch == '~') 38 | { 39 | proc.increaseWaiID(); 40 | } 41 | } 42 | 43 | 44 | return 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /KemonoFriendsLanguage/WaiToken.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFL__WAI_TOKEN_H__ 2 | #define __KFL__WAI_TOKEN_H__ 3 | 4 | 5 | #include "Token.h" 6 | 7 | 8 | 9 | 10 | class WaiToken : public Token 11 | { 12 | public: 13 | WaiToken(const std::initializer_list& tokens); 14 | 15 | 16 | protected: 17 | virtual std::size_t compile(const std::vector& tokens, 18 | std::vector::const_iterator itr, 19 | const std::string& code, Program& proc) const override; 20 | }; 21 | 22 | 23 | #endif -------------------------------------------------------------------------------- /KemonoFriendsLanguage/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "Tokenizer.h" 10 | #include "Compiler.h" 11 | #include "Interpreter.h" 12 | 13 | 14 | 15 | 16 | int main(int argc, char** argv) 17 | { 18 | std::ifstream fr; 19 | 20 | #ifdef _DEBUG 21 | fr.open("../Examples/hello.txt"); 22 | #else 23 | if (argc >= 2) 24 | fr.open(argv[1]); 25 | else 26 | fr.open("code.txt"); 27 | #endif 28 | 29 | if (fr.is_open() == false) 30 | { 31 | std::cout << "Can\'t open file." << std::endl; 32 | return 0; 33 | } 34 | 35 | 36 | try 37 | { 38 | Tokenizer tokenizer; 39 | tokenizer.parse(fr); 40 | auto& tokens = tokenizer.getTokens(); 41 | 42 | 43 | Compiler com; 44 | auto program = com.compile(tokens); 45 | 46 | 47 | Interpreter interpreter; 48 | interpreter.setProgram(program); 49 | interpreter.run(); 50 | } 51 | catch (std::exception& exp) 52 | { 53 | std::cout << "Error!" << std::endl; 54 | std::cout << exp.what() << std::endl; 55 | } 56 | 57 | 58 | #ifdef _DEBUG 59 | std::cout << std::endl << "Press the Enter key to exit." << std::endl; 60 | std::cin.get(); 61 | #endif // _DEBUG 62 | 63 | 64 | return 0; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * ---------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * wrote this file. As long as you retain this notice you 5 | * can do whatever you want with this stuff. If we meet some day, and you think 6 | * this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp 7 | * ---------------------------------------------------------------------------- 8 | */ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kemono Friends Language - 슥語2(SuGGoi2) 2 | 3 | ![Title Logo](./logo.png) 4 | 5 | Fun! Awesome! Programming Language!
6 | 즐겁다! 굉장하다! 프로그래밍 언어!
7 | たのしい! すごい! プログラミング 言語!
8 |
9 | Welcome to ようこそジャパリパーク!
10 | うー!がぉー!
11 | 12 | ## Hello, World! 13 | 14 | - English 15 | ```python 16 | # Print Function 17 | friends English 18 | '0' 19 | tanoshi! 20 | "!dlroW ,olleH" 21 | uwa~ 22 | omoshiro! 23 | sugoi! 24 | wai~ 25 | # Main Function 26 | youkoso 27 | sandstar English 28 | ``` 29 | 30 | - Korean 31 | ```python 32 | # Print Function 33 | 프렌즈 Korean 34 | '0' 35 | 타노시! 36 | "!dlroW ,olleH" 37 | 우와~ 38 | 오모시로! 39 | 스고이! 40 | 와이~ 41 | # Main Function 42 | 요코소 43 | 샌드스타 Korean 44 | ``` 45 | 46 | - Japanese 47 | ```python 48 | # Print Function 49 | フレンズ Japanese 50 | '0' 51 | たのし! 52 | "!dlroW ,olleH" 53 | うわ~ 54 | おもしろ! 55 | すごい! 56 | わい~ 57 | # Main Function 58 | ようこそ 59 | サンドスタ Japanese 60 | ``` 61 | 62 | ## Spec 63 | 64 | ``` 65 | [Syntax] 66 | Token : [a-z, A-Z, 0-9, !, ?, -, ~, _] 67 | Code : {Token}{Not Token}{Token}... 68 | Comment : #...[\n, \0] 69 | Command : {Token} 70 | 71 | [Interpreter] 72 | 'h' = Head : index of 'Command' to execute. 73 | '[p]' = Memory : dynamic array of 1 byte. 74 | 'p' = Pointer : index of byte in 'Memory' 75 | 'r' = Register : store 1 byte. 76 | 77 | [Command] 78 | "..." 79 | "Hi" : [p]='H' → p+=1 → [p]='i' 80 | '...' 81 | '0 42' : [p]=0 → p+=1 → [p]=42 82 | ta(-/~)noshi(!) : increase p or [p] 83 | ta--noshi : [p]+=1 → [p]+=1 84 | ta~-noshi : [p]*=2 → [p]+=1 85 | ta-noshi! : [p]+=1 → p+=1 86 | sugo(-/~)i(!) : decrease p or [p] 87 | sugo--i : [p]-=1 → [p]-=1 88 | sugo~-i : [p]/=2 → [p]-=1 89 | sugo-i! : [p]-=1 → p-=1 90 | u(-)wa(~) : jump 91 | uwa~ : if [p]==0 then move h to wa(-)i~ 92 | u-wa~~ : if [p]==1 then move h to wa(-)i~~ 93 | wa(-)i(~) : jump 94 | wai~ : if [p]!=0 then move h to u(-)wa~ 95 | wa-i~~ : if [p]!=1 then move h to u(-)wa~~ 96 | nanikore(?) : input 97 | nanikore? : [p]=input 98 | nanikore?? : [p]=input → p+=1 → [p]=input 99 | omoshiro(!) : output 100 | omoshiro! : output=[p] 101 | omoshiro!! : output=[p] → p+=1 → output=[p] 102 | la(la) : copy [p] 103 | la : [p+1]=[p] → p+=1 104 | lala : [p+2]=[p] → p+=2 105 | la la : this is two 'Command' that la and la. 106 | mya(mya) : copy [p] 107 | mya : [p-1]=[p] → p-=1 108 | myamya : [p-2]=[p] → p-=2 109 | mya mya : this is two 'Command' that mya and mya. 110 | shaberu : r=[p] 111 | shabetta : [p]=r 112 | youkoso : declare main function 113 | friends {Token} : declare function named {Token} 114 | sandstar {Token} : call function named {Token} 115 | ``` 116 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeuroWhAI/KemonoFriendsLanguage/cc3fa11a8ce80ba16b30da316a85849c3fa93842/logo.png --------------------------------------------------------------------------------