├── .all-contributorsrc ├── .github ├── CONTRIBUTING.md └── FUNDING.yml ├── Asserlang_CSharp └── AssertiveLang.cs ├── Asserlang_Interactive_Python3 ├── README.md └── main.py ├── Asserlang_Python ├── compiler.py ├── examples │ └── gugudan.astv └── exceptions.py ├── Asserlang_nodeJS ├── .gitignore ├── .prettierrc.json ├── package.json ├── src │ └── index.ts ├── tsconfig.json └── yarn.lock ├── LICENSE ├── README.md └── extras └── Asserfuck_Rust ├── .gitignore ├── Cargo.toml ├── README.md └── src └── main.rs /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | "login": "c3nb", 10 | "name": "C#Newbie", 11 | "avatar_url": "https://avatars.githubusercontent.com/u/73321185?v=4", 12 | "profile": "https://github.com/c3nb", 13 | "contributions": [ 14 | "platform" 15 | ] 16 | }, 17 | { 18 | "login": "hwan809", 19 | "name": "hwan809", 20 | "avatar_url": "https://avatars.githubusercontent.com/u/55339366?v=4", 21 | "profile": "https://github.com/hwan809", 22 | "contributions": [ 23 | "platform" 24 | ] 25 | }, 26 | { 27 | "login": "sangchoo1201", 28 | "name": "sangchoo1201", 29 | "avatar_url": "https://avatars.githubusercontent.com/u/75765800?v=4", 30 | "profile": "https://github.com/sangchoo1201", 31 | "contributions": [ 32 | "platform" 33 | ] 34 | }, 35 | { 36 | "login": "wjdqhry", 37 | "name": "Bogus Jung", 38 | "avatar_url": "https://avatars.githubusercontent.com/u/30039641?v=4", 39 | "profile": "https://github.com/wjdqhry", 40 | "contributions": [ 41 | "code" 42 | ] 43 | }, 44 | { 45 | "login": "kdh8219", 46 | "name": "kdh8219", 47 | "avatar_url": "https://avatars.githubusercontent.com/u/65698239?v=4", 48 | "profile": "https://github.com/kdh8219", 49 | "contributions": [ 50 | "code" 51 | ] 52 | } 53 | ], 54 | "contributorsPerLine": 7, 55 | "projectName": "asserlang", 56 | "projectOwner": "assertive-lang", 57 | "repoType": "github", 58 | "repoHost": "https://github.com", 59 | "skipCi": true 60 | } 61 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 기여 가이드라인 2 | 3 | ## 기여하기 전에 4 | 기여하기 전 아래 항목들을 확인하세요: 5 | - 커밋 메시지의 경우 [가이드라인](https://conventionalcommits.org/ko/v1.0.0/)을 꼭 지켜주세요. 6 | - 커밋 메시지 내용은 영어와 소문자(고유명사 제외), 현재형으로 작성해주세요. 7 | - [라이선스](https://github.com/assertive-lang/asserlang/blob/main/LICENSE)에 부합하는 내용인지 확인해주세요. 8 | - [공식 문서](https://github.com/assertive-lang/asserlang/blob/main/README.md)에 부합하는 내용인지 확인해주세요. 9 | - 단순 맞춤법이나 오타, 혹은 문서에 잘못 기재된 내용 등 **문서 오류**의 경우 이슈를 생성해주세요. 10 | 11 | ## 이슈를 생성하기 전에 12 | 이슈를 생성하기 전 아래 항목들을 확인하세요: 13 | - [공식 문서](https://github.com/assertive-lang/asserlang/blob/main/README.md)에 기재된 내용인가요? 14 | - [공식 커뮤니티](https://discord.com/invite/nZEEhDKnvb) 등에 이미 알려진 이슈인가요? 15 | - 이미 등록된 이슈인가요? -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://toss.me/인트0721 2 | -------------------------------------------------------------------------------- /Asserlang_CSharp/AssertiveLang.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Reflection.Emit; 6 | using System.Collections.Generic; 7 | 8 | namespace AssertiveLang 9 | { 10 | public static class Program 11 | { 12 | public static void Main(string[] args) 13 | { 14 | new AsserLangCompiler(File.ReadAllText(args[0])).Compile().AsserFunction(); 15 | } 16 | } 17 | public class AsserLangCompiler 18 | { 19 | public AsserLangCompiler(string source) 20 | { 21 | var arr = source.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); 22 | if (arr.First() != "쿠쿠루삥뽕") throw new AsserLangException($"아무것도 모르죠?"); 23 | if (arr.Last() != "슉슈슉슉") throw new AsserLangException($"아무것도 모르죠?"); 24 | Source = source; 25 | TypeBuilder = AsserLangMethod.AsserLangModule.DefineType($"AsserType{(AsserTypeCount++ == 1 ? "" : AsserTypeCount.ToString())}", TypeAttributes.Public); 26 | Method = (AsserLangMethod)TypeBuilder.DefineMethod("AsserLangMethod", MethodAttributes.Public | MethodAttributes.Static, typeof(object), Type.EmptyTypes); 27 | AsserLangMethod.AsserLangAsm.SetEntryPoint(Method.Method); 28 | } 29 | public string Source { get; } 30 | public TypeBuilder TypeBuilder { get; } 31 | public AsserLangMethod Method { get; private set; } 32 | public ILGenerator IL { get; } 33 | public Dictionary Variables = new Dictionary(); 34 | public Dictionary Methods = new Dictionary(); 35 | public List GotoList = new List(); 36 | public AsserLangResult Result; 37 | public AsserLangResult Compile() 38 | { 39 | int lineNumber = 0; 40 | using (StringReader reader = new StringReader(Source)) 41 | { 42 | string line = ""; 43 | while ((line = reader.ReadLine()) != null) 44 | { 45 | lineNumber++; 46 | if (line.TrimStart().StartsWith("//")) 47 | continue; 48 | if (line.Contains(";;")) 49 | { 50 | line = line.Substring(line.LastIndexOf(";;")).Replace(";;", ""); 51 | if (AsserLangMethod.IsNumber(line, out int label)) 52 | GotoList.Add(label); 53 | } 54 | } 55 | reader.Close(); 56 | } 57 | Method.PrepareLabels(GotoList); 58 | lineNumber = 0; 59 | try 60 | { 61 | using (StringReader reader = new StringReader(Source)) 62 | { 63 | string line = ""; 64 | while ((line = reader.ReadLine()) != null) 65 | { 66 | lineNumber++; 67 | if (line.TrimStart().StartsWith("//")) 68 | continue; 69 | Method.Emit(line, reader, TypeBuilder, ref lineNumber); 70 | } 71 | } 72 | if (!Method.Returned) 73 | Method.Ret(true); 74 | var created = TypeBuilder.CreateType(); 75 | var method = created.GetMethod(Method.Method.Name); 76 | var func = (Func)method.CreateDelegate(typeof(Func)); 77 | return Result = new AsserLangResult(created, method, func); 78 | } 79 | catch (Exception ex) 80 | { 81 | throw new AsserLangException($"컴파일 오류! 줄 {lineNumber}", ex); 82 | } 83 | } 84 | public static void Save() 85 | => AsserLangMethod.AsserLangAsm.Save("AsserLangMethod.dll"); 86 | public static int AsserTypeCount = 1; 87 | } 88 | public class AsserLangException : Exception 89 | { 90 | public AsserLangException(string msg) : base(msg) { } 91 | public AsserLangException(string msg, Exception inner) : base(msg, inner) { } 92 | } 93 | public class AsserLangResult 94 | { 95 | public Type AsserType; 96 | public MethodInfo AsserLangMethod; 97 | public Func AsserFunction; 98 | public AsserLangResult(Type asserType, MethodInfo asserMethod, Func asserFunction) 99 | { 100 | AsserType = asserType; 101 | AsserFunction = asserFunction; 102 | AsserLangMethod = asserMethod; 103 | } 104 | } 105 | public class AsserLangMethod 106 | { 107 | public static explicit operator AsserLangMethod(MethodBuilder methodBuilder) => new AsserLangMethod(methodBuilder); 108 | public static explicit operator MethodBuilder(AsserLangMethod asserMethod) => asserMethod.Method; 109 | public static MethodInfo sEquality = typeof(string).GetMethod("op_Equality"); 110 | public static MethodInfo iParse = typeof(int).GetMethod("Parse", new[] { typeof(string) }); 111 | public static MethodInfo oWrite = typeof(Console).GetMethod("Write", new[] { typeof(object) }); 112 | public static MethodInfo ReadL = typeof(Console).GetMethod("ReadLine"); 113 | public MethodBuilder Method; 114 | public ILGenerator IL; 115 | public Dictionary Parameters; 116 | public Dictionary Variables; 117 | public Dictionary BoxType; 118 | public Dictionary BoxTypeArg; 119 | public AsserLangMethod Outer; 120 | public Type LastBoxedType = typeof(int); 121 | public string[] ParameterNames; 122 | public bool RequireLdnull = true; 123 | public bool Returned = false; 124 | public Stack