├── .editorconfig ├── .gitattributes ├── .github └── workflows │ ├── release.yml │ └── testing.yml ├── .gitignore ├── CHANGELOG.md ├── Parser ├── include │ └── RigCParser │ │ ├── Grammar.hpp │ │ ├── Grammar │ │ ├── Characters.hpp │ │ ├── Classes.hpp │ │ ├── Conditionals.hpp │ │ ├── Expression.hpp │ │ ├── Functions.hpp │ │ ├── Keywords.hpp │ │ ├── Literals.hpp │ │ ├── Loops.hpp │ │ ├── Operators.hpp │ │ ├── Parts.hpp │ │ ├── Statements.hpp │ │ ├── Templates.hpp │ │ ├── Tokens.hpp │ │ └── Variables.hpp │ │ ├── Parser.hpp │ │ └── RigCParserPCH.hpp └── src │ ├── Main.cpp │ ├── Parser.cpp │ └── RigCParserPCH.cpp ├── ParserApp └── src │ └── Main.cpp ├── README.md ├── VM ├── include │ └── RigCVM │ │ ├── Aliases.hpp │ │ ├── Alloc.hpp │ │ ├── Builtin │ │ └── Functions.hpp │ │ ├── DevServer │ │ ├── Breakpoint.hpp │ │ ├── Instance.hpp │ │ ├── Messaging.hpp │ │ ├── Presets.hpp │ │ └── Utils.hpp │ │ ├── ErrorHandling │ │ ├── Exceptions.hpp │ │ └── Formatting.hpp │ │ ├── Executors │ │ ├── All.hpp │ │ ├── ExpressionExecutor.hpp │ │ └── Templates.hpp │ │ ├── Functions.hpp │ │ ├── Helper │ │ ├── ExtendedVariant.hpp │ │ └── String.hpp │ │ ├── Identifier.hpp │ │ ├── Module.hpp │ │ ├── RigCVMPCH.hpp │ │ ├── Scope.hpp │ │ ├── Settings.hpp │ │ ├── Stack.hpp │ │ ├── StackFrame.hpp │ │ ├── StaticString.hpp │ │ ├── Type.hpp │ │ ├── TypeSystem │ │ ├── ArrayType.hpp │ │ ├── ClassTemplate.hpp │ │ ├── ClassType.hpp │ │ ├── CoreType.hpp │ │ ├── EnumType.hpp │ │ ├── EnumValue.hpp │ │ ├── FuncType.hpp │ │ ├── IType.hpp │ │ ├── RefType.hpp │ │ ├── Shared │ │ │ └── DataMember.hpp │ │ ├── StructuralType.hpp │ │ ├── TemplateParameter.hpp │ │ ├── TemplateType.hpp │ │ ├── TypeConstraint.hpp │ │ ├── TypeRegistry.hpp │ │ └── UnionType.hpp │ │ ├── VM.hpp │ │ └── Value.hpp └── src │ ├── Builtin │ └── Functions.cpp │ ├── DevServer │ ├── Instance.cpp │ ├── Messaging.cpp │ └── Utils.cpp │ ├── ErrorHandling │ └── Exceptions.cpp │ ├── Executors │ ├── All.cpp │ ├── ExpressionExecutor.cpp │ ├── FlowControl.cpp │ ├── Functions.cpp │ ├── Literals.cpp │ ├── Modules.cpp │ └── Templates.cpp │ ├── Functions.cpp │ ├── Helper │ └── String.cpp │ ├── Main.cpp │ ├── RigCVMPCH.cpp │ ├── Scope.cpp │ ├── Settings.cpp │ ├── StackFrame.cpp │ ├── Type.cpp │ ├── TypeSystem │ ├── AddrType.cpp │ ├── ArrayType.cpp │ ├── ClassTemplate.cpp │ ├── ClassType.cpp │ ├── EnumType.cpp │ ├── FuncType.cpp │ ├── IType.cpp │ └── TypeRegistry.cpp │ ├── VM.cpp │ └── Value.cpp ├── VMApp └── src │ └── Main.cpp ├── VMTest ├── include │ └── RigCVMTest │ │ └── Helper.hpp └── src │ ├── Helper.cpp │ └── Main.cpp ├── cpackage.json ├── examples ├── AdvancedFunctionTemplates.rigc ├── AreaCalculator.rigc ├── Classes.rigc ├── Conversions.rigc ├── Enums.rigc ├── ExtensionMethods.rigc ├── FibonacciSequence.rigc ├── FizzBuzz.rigc ├── FunctionTemplates.rigc ├── GuessANumber.rigc ├── HelloWorld.rigc ├── PrimeNumbers.rigc ├── README.md └── helper │ └── Math.rigc ├── res ├── docs │ ├── folder-structure.drawio │ └── overview.drawio ├── example-imgs │ ├── classes-and-funcs.png │ ├── classes-modules.png │ ├── flow-control.png │ ├── hello-world.png │ ├── metaprogramming.png │ └── while-loop.png └── imgs │ └── running-examples.gif ├── tests ├── _helper │ └── Math.rigc ├── empty-main │ └── main.rigc ├── extension-methods-1 │ ├── expected-output.txt │ └── main.rigc ├── hello-world │ ├── expected-output.txt │ └── main.rigc └── variables │ └── create │ └── Int32 │ └── main.rigc └── version.txt /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | # Matches multiple files with brace expansion notation 8 | [*.{cpp,hpp,json,lua,rigc,rigcz}] 9 | charset = utf-8 10 | indent_style = tab 11 | indent_size = 4 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.cpp eol=lf 2 | *.hpp eol=lf 3 | *.json eol=lf 4 | *.lua eol=lf 5 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Release CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the "main" branch 8 | push: 9 | tags: 10 | - "v*" 11 | 12 | # Allows you to run this workflow manually from the Actions tab 13 | workflow_dispatch: 14 | 15 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 16 | jobs: 17 | # This workflow contains a single job called "build" 18 | Build-on-Linux: 19 | # The type of runner that the job will run on 20 | runs-on: ubuntu-latest 21 | 22 | # Steps represent a sequence of tasks that will be executed as part of the job 23 | steps: 24 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 25 | - uses: actions/checkout@v3 26 | with: 27 | path: 'rigc-lang' 28 | 29 | - name: Setup GCC 30 | uses: egor-tensin/setup-gcc@v1 31 | with: 32 | version: 11 33 | platform: x64 34 | 35 | - name: Download pacc 36 | uses: robinraju/release-downloader@v1.4 37 | with: 38 | latest: true 39 | repository: "PoetaKodu/pacc" 40 | fileName: "*-linux-x64.zip" 41 | 42 | - run: unzip '*-linux-x64.zip' 43 | 44 | - name: Install and build 45 | run: | 46 | export LD_PRELOAD=$GITHUB_WORKSPACE/pacc/bin/libstdc++.so.6 47 | ../pacc/bin/pacc install 48 | ../pacc/bin/pacc build --verbose -c=Release --cores=2 49 | chmod +x ./bin/x64/Release/VMApp 50 | chmod +x ./bin/x64/Release/VMTest 51 | working-directory: rigc-lang 52 | 53 | - name: Run tests 54 | working-directory: rigc-lang 55 | run: | 56 | ./bin/x64/Release/VMTest 57 | 58 | - name: Upload VM artifact 59 | uses: actions/upload-artifact@v3 60 | with: 61 | name: ${{ format('rigc-{0}-linux-x64', github.ref_name) }} 62 | path: | 63 | rigc-lang/bin/x64/Release/VM.a 64 | rigc-lang/bin/x64/Release/VMApp 65 | 66 | Build-on-Windows: 67 | # The type of runner that the job will run on 68 | runs-on: windows-latest 69 | 70 | # Steps represent a sequence of tasks that will be executed as part of the job 71 | steps: 72 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 73 | - uses: actions/checkout@v3 74 | with: 75 | path: 'rigc-lang' 76 | 77 | - name: Download pacc 78 | uses: robinraju/release-downloader@v1.4 79 | with: 80 | latest: true 81 | repository: "PoetaKodu/pacc" 82 | fileName: "*-windows-x64.zip" 83 | 84 | - shell: pwsh 85 | run: Get-ChildItem '.' -Filter *-windows-x64.zip | Expand-Archive -DestinationPath '.' -Force 86 | 87 | - name: Install and build 88 | run: | 89 | ..\pacc\bin\pacc install 90 | ..\pacc\bin\pacc build --verbose -c=Release --cores=2 91 | working-directory: rigc-lang 92 | 93 | - name: Run tests 94 | working-directory: rigc-lang 95 | run: | 96 | .\bin\x64\Release\VMTest.exe 97 | 98 | - name: Upload VM artifact 99 | uses: actions/upload-artifact@v3 100 | with: 101 | name: ${{ format('rigc-{0}-windows-x64', github.ref_name) }} 102 | path: | 103 | rigc-lang/bin/x64/Release/VM.lib 104 | rigc-lang/bin/x64/Release/VM.pdb 105 | rigc-lang/bin/x64/Release/VMApp.pdb 106 | rigc-lang/bin/x64/Release/VMApp.exe 107 | 108 | release: 109 | runs-on: ubuntu-latest 110 | needs: [ Build-on-Linux, Build-on-Windows ] 111 | steps: 112 | - uses: google-github-actions/release-please-action@v3 113 | with: 114 | release-type: simple 115 | package-name: rigc 116 | -------------------------------------------------------------------------------- /.github/workflows/testing.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Testing CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the "main" branch 8 | push: 9 | pull_request: 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | # This workflow contains a single job called "build" 17 | Build-on-Linux: 18 | # The type of runner that the job will run on 19 | runs-on: ubuntu-latest 20 | 21 | # Steps represent a sequence of tasks that will be executed as part of the job 22 | steps: 23 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 24 | - uses: actions/checkout@v3 25 | with: 26 | path: 'rigc-lang' 27 | 28 | - name: Setup GCC 29 | uses: egor-tensin/setup-gcc@v1 30 | with: 31 | version: 11 32 | platform: x64 33 | 34 | - name: Download pacc 35 | uses: robinraju/release-downloader@v1.4 36 | with: 37 | latest: true 38 | repository: "PoetaKodu/pacc" 39 | fileName: "*-linux-x64.zip" 40 | 41 | - run: unzip '*-linux-x64.zip' 42 | 43 | - name: Install and build 44 | run: | 45 | export LD_PRELOAD=$GITHUB_WORKSPACE/pacc/bin/libstdc++.so.6 46 | ../pacc/bin/pacc install 47 | ../pacc/bin/pacc build --verbose -c=Release --cores=2 48 | chmod +x ./bin/x64/Release/VMApp 49 | chmod +x ./bin/x64/Release/VMTest 50 | working-directory: rigc-lang 51 | 52 | - name: Run tests 53 | working-directory: rigc-lang 54 | run: | 55 | ./bin/x64/Release/VMTest 56 | 57 | - name: Upload VM artifact 58 | uses: actions/upload-artifact@v3 59 | with: 60 | name: ${{ format('rigc-{0}_{1}_{2}-linux-x64', github.run_id, github.run_number, github.run_attempt) }} 61 | path: | 62 | rigc-lang/bin/x64/Release/VMApp 63 | 64 | Build-on-Windows: 65 | # The type of runner that the job will run on 66 | runs-on: windows-latest 67 | 68 | # Steps represent a sequence of tasks that will be executed as part of the job 69 | steps: 70 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 71 | - uses: actions/checkout@v3 72 | with: 73 | path: 'rigc-lang' 74 | 75 | - name: Download pacc 76 | uses: robinraju/release-downloader@v1.4 77 | with: 78 | latest: true 79 | repository: "PoetaKodu/pacc" 80 | fileName: "*-windows-x64.zip" 81 | 82 | - shell: pwsh 83 | run: Get-ChildItem '.' -Filter *-windows-x64.zip | Expand-Archive -DestinationPath '.' -Force 84 | 85 | - name: Install and build 86 | run: | 87 | ..\pacc\bin\pacc install 88 | ..\pacc\bin\pacc build --verbose -c=Release --cores=2 89 | working-directory: rigc-lang 90 | 91 | - name: Run tests 92 | shell: pwsh 93 | working-directory: rigc-lang 94 | run: | 95 | .\bin\x64\Release\VMTest.exe 96 | 97 | - name: Upload VM artifact 98 | uses: actions/upload-artifact@v3 99 | with: 100 | name: ${{ format('rigc-{0}_{1}_{2}-windows-x64', github.run_id, github.run_number, github.run_attempt) }} 101 | path: | 102 | rigc-lang/bin/x64/Release/VMApp.exe 103 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Custom: 2 | build/ 3 | bin/ 4 | .xmake/ 5 | .vscode/ 6 | .cache/ 7 | res/installer 8 | testbed/ 9 | deps/* 10 | !deps/cpackage.json 11 | !deps/README.md 12 | *.user.* 13 | premake5.lua 14 | pacc_packages 15 | 16 | # Prerequisites 17 | *.d 18 | 19 | # Compiled Object files 20 | *.slo 21 | *.lo 22 | *.o 23 | *.obj 24 | 25 | # Precompiled Headers 26 | *.gch 27 | *.pch 28 | 29 | # Compiled Dynamic libraries 30 | *.so 31 | *.dylib 32 | *.dll 33 | 34 | # Fortran module files 35 | *.mod 36 | *.smod 37 | 38 | # Compiled Static libraries 39 | *.lai 40 | *.la 41 | *.a 42 | *.lib 43 | 44 | # Executables 45 | *.exe 46 | *.out 47 | *.app 48 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.3.0](https://github.com/RigCLang/rigc-lang/compare/v0.2.1...v0.3.0) (2022-10-16) 4 | 5 | 6 | ### Features 7 | 8 | * **vm:** danger conversion operator ([4458a9f](https://github.com/RigCLang/rigc-lang/commit/4458a9fca7c0d5a7d4cafde7e006da269549e16e)) 9 | * **vm:** null keyword and `Null` type. ([a51ba6a](https://github.com/RigCLang/rigc-lang/commit/a51ba6a4e7f5bc780a4ac66e26311286d1258e0a)) 10 | * **vm:** proper `Addr` printing ([c68421d](https://github.com/RigCLang/rigc-lang/commit/c68421d44cb5d1fa464edc72728e8cd035dac2c0)) 11 | 12 | 13 | ### Bug Fixes 14 | 15 | * **vm:** allow non-danger `as` operator to convert `Addr` to `Addr` ([698dfd3](https://github.com/RigCLang/rigc-lang/commit/698dfd33da8ed5123941369b4d9ee7f8b1d1f9dc)) 16 | * **vm:** missing escape of `{}` format braces ([8934a79](https://github.com/RigCLang/rigc-lang/commit/8934a79f344d692acbbbd6103c7125967243dcf0)) 17 | 18 | ## [0.2.1](https://github.com/RigCLang/rigc-lang/compare/v0.2.0-prealpha...v0.2.1) (2022-10-16) 19 | 20 | 21 | ### Features 22 | 23 | * **vm:** `--version` parameter. ([2bcf38f](https://github.com/RigCLang/rigc-lang/commit/2bcf38f7d0ad8639f3702ca4b50073575bc0fd41)) 24 | 25 | 26 | ### Bug Fixes 27 | 28 | * debug-mode devserver thread not stopping after module execution ends ([82cea9f](https://github.com/RigCLang/rigc-lang/commit/82cea9f90b5cc056791922dfe00b211cdba47b16)) 29 | * missing `-lpthread` flag on linux ([575d9d8](https://github.com/RigCLang/rigc-lang/commit/575d9d8c859320b3a8faca656ae8aa287321259b)) 30 | * **vm:** better wording when module name is missing from parameters ([2bcf38f](https://github.com/RigCLang/rigc-lang/commit/2bcf38f7d0ad8639f3702ca4b50073575bc0fd41)) 31 | * **vm:** missing `fmt::runtime` when formatting a runtime string ([fe029cd](https://github.com/RigCLang/rigc-lang/commit/fe029cdf018a312b11f24a5a703c6ca83a10ab9c)) 32 | 33 | ## [0.2.0-prealpha](https://github.com/RigCLang/rigc-lang/compare/v0.1.1-prealpha...v0.2.0-prealpha) (2022-10-16) 34 | 35 | 36 | ### Features 37 | 38 | * add --logfile option ([fc72e80](https://github.com/RigCLang/rigc-lang/commit/fc72e8007d5bdb393a5b3ea24a12442dafd3722a)) 39 | * add --logfile option ([6161a49](https://github.com/RigCLang/rigc-lang/commit/6161a491c2b2c7bdbec9c52e3d674da14cfb4487)) 40 | * **app:** added basic destructor support ([b7ce690](https://github.com/RigCLang/rigc-lang/commit/b7ce690a4b811c64a9fed0a69f7b49631b3e487f)) 41 | * clear logs on opening ([18ab9bc](https://github.com/RigCLang/rigc-lang/commit/18ab9bcd393bc7c76bb69f56e4d49d8f79b239cd)) 42 | * clear logs on opening ([0b56185](https://github.com/RigCLang/rigc-lang/commit/0b5618515d9f320c4fc3e18a63fd9f55a2f36297)) 43 | * don't send frame debug message if the frame is `nullptr`. ([cf011c2](https://github.com/RigCLang/rigc-lang/commit/cf011c24a5de951c369007626bd8da6559776160)) 44 | * format the stack frame' labels in a nicer way ([54aecf2](https://github.com/RigCLang/rigc-lang/commit/54aecf276ce93eaf57b126642746b38c6d2db283)) 45 | * send actual context to the debugger ([1171f0e](https://github.com/RigCLang/rigc-lang/commit/1171f0efdece7b537c3be8b22d96776d5046f3e4)) 46 | * send debug messages about the stack frames and allocations ([54b39d7](https://github.com/RigCLang/rigc-lang/commit/54b39d786a9534405c66db064fdc9acfc7ca26e1)) 47 | * **vm:** `--wait-for-connection` program argument ([358625d](https://github.com/RigCLang/rigc-lang/commit/358625d55dbc67b6ae332a468a8c1db74a7c31f6)) 48 | * **vm:** `Breakpoint` struct for a DevServer ([7005316](https://github.com/RigCLang/rigc-lang/commit/7005316cbec07e7e7ce7b146614c0423672de578)) 49 | * **vm:** `builtin::printCharacters` function. ([3d1355a](https://github.com/RigCLang/rigc-lang/commit/3d1355a5836900c0b870e7006fff536af690f25a)) 50 | * **vm:** `devserverLog` function ([729c165](https://github.com/RigCLang/rigc-lang/commit/729c16554c64a54a09bfaa8c2e4b985a247a85c4)) 51 | * **vm:** added `json` package and some aliases. ([ccb19fe](https://github.com/RigCLang/rigc-lang/commit/ccb19fe944f3a0844a575c0b5f3eaffef59e21b1)) 52 | * **vm:** added `Void` type ([e4d6b7c](https://github.com/RigCLang/rigc-lang/commit/e4d6b7c81bea666d9a712240a9a54020631fa3dc)) 53 | * **vm:** added memory allocation / deallocation functions ([fb8a54e](https://github.com/RigCLang/rigc-lang/commit/fb8a54ef300a96557b46a0fed98db2a01c4b34ca)) 54 | * **VM:** basic conversions example. ([2939389](https://github.com/RigCLang/rigc-lang/commit/2939389f44032771f2db0e0be9cdacd543fa9a22)) 55 | * **VM:** error handling and formatting utilities. ([c443b24](https://github.com/RigCLang/rigc-lang/commit/c443b24aa98f79698bcd62aeecc1402ae2004f5a)) 56 | * **VM:** exception handling for runtime_error. ([322b55e](https://github.com/RigCLang/rigc-lang/commit/322b55e4b569958bcf5dcb3b8fb411b7a7a18de0)) 57 | * **vm:** generate and use copy constructors for each type. ([ea54c96](https://github.com/RigCLang/rigc-lang/commit/ea54c969eea2a66a8a4f3c60a538a36ff0fd112c)) 58 | * **VM:** internal exception class and utils. ([08ddecb](https://github.com/RigCLang/rigc-lang/commit/08ddecbaf7812cc41ca6bfab26150646edea6277)) 59 | * **vm:** support constructor templates ([ff4044b](https://github.com/RigCLang/rigc-lang/commit/ff4044b9cc237c95c41288ae93bccb1785cb2a52)) 60 | * **vm:** working on a dev server ([f7b80fa](https://github.com/RigCLang/rigc-lang/commit/f7b80fac0209a4b1a1ca026cec753fd99e95ab39)) 61 | * **vm:** working on a dev server and destructors. ([16bb61f](https://github.com/RigCLang/rigc-lang/commit/16bb61fc0a0a112afb5698ebb9cc3487222c2543)) 62 | 63 | 64 | ### Bug Fixes 65 | 66 | * **automation:** fixed invalid tag for artifacts ([f8fe4e0](https://github.com/RigCLang/rigc-lang/commit/f8fe4e055c85427e9bb9c67151b80d8c98658c11)) 67 | * **examples:** made examples conforming to the new changes ([61792b3](https://github.com/RigCLang/rigc-lang/commit/61792b3f49c5552e2c60144ec7b950524b3e69e3)) 68 | * proper case for program argument (now): `--skip-root-exception-catching` ([d991b41](https://github.com/RigCLang/rigc-lang/commit/d991b41c571eceab0692fa6f09be749c4fcb0909)) 69 | * proper case for program argument (now): `--skip-root-exception-catching` ([afe08a1](https://github.com/RigCLang/rigc-lang/commit/afe08a11f1888618d1a56fd8633e3c588e5e0851)) 70 | * proper formatting in stack json requests ([5878c27](https://github.com/RigCLang/rigc-lang/commit/5878c276684a1536085f513bf0c3caf2411ed760)) 71 | * removed accidentally added test files. ([0da83b1](https://github.com/RigCLang/rigc-lang/commit/0da83b11d392b0ca7039347f7f42f34005122f26)) 72 | * typo in json debug message alllocation -> allocation ([2970c0d](https://github.com/RigCLang/rigc-lang/commit/2970c0d25d73f527a0c2b7ea28741da48fc5016f)) 73 | * **vm:** added missing return types for `readInt` and `readFloat` ([175a128](https://github.com/RigCLang/rigc-lang/commit/175a128008573e2db0ae164683d6f8332fd329bd)) 74 | * **VM:** allocateOnStack condition in assert. ([332388d](https://github.com/RigCLang/rigc-lang/commit/332388d14ba0586a102addf0266c0848bb9a79f5)) 75 | * **VM:** conversion operator wrong name extraction. ([bad55d9](https://github.com/RigCLang/rigc-lang/commit/bad55d9485eef194e2c85c82c9db71bb43128022)) 76 | * **vm:** do not allow execution if error ocurred during argument parsing ([4154ef9](https://github.com/RigCLang/rigc-lang/commit/4154ef984e6b5e57e3056f438fb15e573c5b6cab)) 77 | * **VM:** evalPostfixOperator's paramString concatenation loop. ([7bf77d3](https://github.com/RigCLang/rigc-lang/commit/7bf77d3cf9fa1e1ba954fe1aef09cb73230e7bf3)) 78 | * **vm:** method templates not being handled properly (problem with `self` param) ([29d1e1e](https://github.com/RigCLang/rigc-lang/commit/29d1e1e5ba27bd95ef8c78562a693e7a00b12362)) 79 | * **vm:** non-debug build used debug-only code. ([83d4eed](https://github.com/RigCLang/rigc-lang/commit/83d4eed8be22c4a8f7541dedca481290e1e41cdd)) 80 | * **vm:** order of core type creation ([7bfb829](https://github.com/RigCLang/rigc-lang/commit/7bfb829a925e0b68bf5273d9d1d509cdbaebe7af)) 81 | * **vm:** path starting with `.\` bug ([337b4c3](https://github.com/RigCLang/rigc-lang/commit/337b4c32e9535350878bccf5fa9f39b5fe7b4925)) 82 | * **VM:** unintended ADL-related error ([53ae9af](https://github.com/RigCLang/rigc-lang/commit/53ae9afa4ae808e04861d8cef284655ffadf306e)) 83 | * **vm:** variable getting invalid address when created ([1c5b34c](https://github.com/RigCLang/rigc-lang/commit/1c5b34cb144656798cf5138c65f8a833bb324115)) 84 | 85 | ## [0.1.1-prealpha](https://github.com/PoetaKodu/rigc-lang/compare/v0.1.0-prealpha...v0.1.1-prealpha) (2022-06-23) 86 | 87 | 88 | ### Bug Fixes 89 | 90 | * **automation:** fixed invalid tag for artifacts ([f8fe4e0](https://github.com/PoetaKodu/rigc-lang/commit/f8fe4e055c85427e9bb9c67151b80d8c98658c11)) 91 | * **automation:** invalid tag being generated ([eaeb64f](https://github.com/PoetaKodu/rigc-lang/commit/eaeb64f795f6a467efa52ae7560e458fbcbc15cf)) 92 | * missing `CHANGELOG.md` ([eaeb64f](https://github.com/PoetaKodu/rigc-lang/commit/eaeb64f795f6a467efa52ae7560e458fbcbc15cf)) 93 | * **VM:** EnumType == operator in postInitialize. ([352e9b2](https://github.com/PoetaKodu/rigc-lang/commit/352e9b2122b10dcec8154f388a50362707b23202)) 94 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace rigc 12 | { 13 | 14 | // Parsing rule that matches a non-empty sequence of 15 | // alphabetic ascii-characters with greedy-matching. 16 | 17 | struct GlobalNS 18 | : 19 | p::star< p::sor > 20 | { 21 | }; 22 | 23 | struct Grammar 24 | : p::must 25 | { 26 | }; 27 | 28 | template< typename Rule > 29 | using Selector = p::parse_tree::selector< Rule, 30 | p::parse_tree::store_content::on< 31 | ImportStatement, 32 | PackageImportFullName, 33 | ClassDefinition, 34 | ClassCodeBlock, 35 | UnionDefinition, 36 | UnionCodeBlock, 37 | EnumDefinition, 38 | EnumCodeBlock, 39 | MethodDef, 40 | MemberOperatorDef, 41 | DataMemberDef, 42 | ExplicitType, 43 | FunctionDefinition, 44 | ExplicitReturnType, 45 | VariableDefinition, 46 | InitializerValue, 47 | IfStatement, 48 | ElseStatement, 49 | WhileStatement, 50 | ForStatement, 51 | ReturnStatement, 52 | BreakStatement, 53 | ContinueStatement, 54 | CodeBlock, 55 | Statements, 56 | SingleBlockStatement, 57 | Condition, 58 | Expression, 59 | ArrayElement, 60 | DeclType, 61 | FunctionParams, 62 | ClosureDefinition, 63 | Parameter, 64 | FunctionArg, 65 | Type, 66 | PossiblyTemplatedSymbol, 67 | PossiblyTemplatedSymbolNoDisamb, 68 | TemplateDefParamList, 69 | TemplateDefParamListElem, 70 | TemplateDefParamKind, 71 | TemplateParams, 72 | TemplateParam, 73 | Name, 74 | OverridableOperatorNames, 75 | IntegerLiteral, 76 | Float32Literal, 77 | Float64Literal, 78 | PrefixOperator, 79 | InfixOperator, 80 | InfixOperatorNoComma, 81 | PostfixOperator, 82 | BoolLiteral, 83 | StringLiteral, 84 | CharLiteral, 85 | ArrayLiteral, 86 | ExportKeyword, 87 | ListOfFunctionArguments 88 | > 89 | >; 90 | 91 | } 92 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Characters.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace rigc 6 | { 7 | 8 | ////////////////////// Whitespace ///////////////////////// 9 | 10 | struct Whitespace 11 | : pegtl::plus< p::space > 12 | { 13 | }; 14 | 15 | struct Comment 16 | : p::seq< p::string<'/','/'>, p::until< p::eolf > > 17 | { 18 | }; 19 | 20 | struct Ws 21 | : p::sor< 22 | Comment, 23 | p::seq< p::plus, p::opt > 24 | > 25 | { 26 | }; 27 | 28 | // using Rs = Whitespace; 29 | 30 | using OptWs = p::star; 31 | 32 | template 33 | using WsWrapped = p::seq< OptWs, GrammarElems..., OptWs >; 34 | 35 | 36 | /////////////////////////////////////////////// 37 | struct char_semicolon 38 | : p::one<';'> 39 | { 40 | }; 41 | 42 | 43 | struct Semicolon 44 | : p::seq< p::opt, p::one<';'> > 45 | { 46 | }; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Classes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace rigc 9 | { 10 | 11 | struct OverridableOperatorNames; 12 | 13 | struct ExplicitType 14 | : p::seq< p::one<':'>, OptWs, Type > 15 | {}; 16 | 17 | struct DataMemberDef 18 | : p::seq< Name, OptWs, p::sor>, p::opt>, OptWs> 19 | {}; 20 | 21 | struct MemberOperatorDef 22 | : p::seq< 23 | p::opt< OverrideKeyword, Ws >, 24 | p::opt, 25 | OperatorKeyword, OptWs, OverridableOperatorNames, 26 | OptWs, p::opt, p::opt, OptWs, CodeBlock > 27 | {}; 28 | 29 | struct MethodDef 30 | : p::seq< p::opt< OverrideKeyword, Ws >, p::opt, Name, OptWs, p::opt, p::opt, OptWs, CodeBlock > 31 | {}; 32 | 33 | struct MemberDef 34 | : p::sor< 35 | MemberOperatorDef, 36 | p::seq>, 37 | MethodDef 38 | > 39 | { 40 | }; 41 | 42 | struct ClassCodeBlock 43 | : p::seq< p::one<'{'>, OptWs, p::star, p::one<'}'> > 44 | { 45 | }; 46 | 47 | struct ClassDefinition 48 | : p::seq< 49 | p::opt, 50 | p::opt, 51 | p::if_must< ClassKeyword, Ws, Name, OptWs, ClassCodeBlock> > 52 | { 53 | }; 54 | 55 | 56 | struct EnumCodeBlock 57 | : p::seq< p::one<'{'>, OptWs, p::opt>, OptWs>>, p::one<'}'> > 58 | { 59 | }; 60 | 61 | using EnumExplicitType = p::if_must; 62 | 63 | struct EnumDefinition 64 | : p::seq< 65 | p::opt, 66 | p::if_must< EnumKeyword, Ws, Name, p::opt, OptWs, EnumCodeBlock > > 67 | { 68 | }; 69 | 70 | struct UnionCodeBlock 71 | : p::seq< p::one<'{'>, OptWs, p::star>, OptWs>, p::one<'}'> > 72 | { 73 | }; 74 | 75 | struct UnionDefinition 76 | : p::seq< 77 | p::opt, 78 | p::opt, 79 | p::if_must< UnionKeyword, Ws, Name, OptWs, UnionCodeBlock > > 80 | { 81 | }; 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Conditionals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace rigc 8 | { 9 | 10 | struct Statement; 11 | struct SingleBlockStatement; 12 | struct CodeBlock; 13 | struct IfStatement; 14 | 15 | struct Condition 16 | : 17 | p::seq< p::one<'('>, OptWs, Expression, OptWs, p::one<')'> > 18 | {}; 19 | 20 | struct OnlyIfStatement 21 | : 22 | p::seq< IfKeyword, OptWs, Condition, OptWs, 23 | p::sor< 24 | SingleBlockStatement, 25 | CodeBlock 26 | > 27 | > 28 | { 29 | }; 30 | 31 | struct ElseStatement 32 | : 33 | p::seq< ElseKeyword, 34 | p::sor< 35 | p::seq, 36 | p::seq 41 | > 42 | > 43 | > 44 | { 45 | }; 46 | 47 | struct IfStatement 48 | : 49 | p::seq< OnlyIfStatement, OptWs, p::opt > 50 | { 51 | }; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Expression.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace rigc 11 | { 12 | 13 | struct Expression; 14 | struct ExprInParen; 15 | 16 | struct SingleExpressionFragment 17 | : 18 | p::seq< 19 | p::star, OptWs, 20 | p::sor, OptWs, 21 | p::star 22 | > 23 | { 24 | }; 25 | 26 | template 27 | struct ExpressionBase 28 | : 29 | p::seq< 30 | SingleExpressionFragment, 31 | p::star< 32 | OptWs, p::if_must 33 | > 34 | > 35 | { 36 | }; 37 | 38 | struct Expression 39 | : ExpressionBase 40 | {}; 41 | 42 | struct ExprWithoutComma 43 | : ExpressionBase 44 | {}; 45 | 46 | struct ExprInParen 47 | : p::if_must< p::one<'('>, OptWs, Expression, OptWs, p::one<')'> > 48 | { 49 | }; 50 | 51 | struct ArrayElement : ExprWithoutComma {}; 52 | struct FunctionArg : ExprWithoutComma {}; 53 | 54 | template 55 | struct ListOfExpressions 56 | : p::opt< 57 | ElementType, OptWs, 58 | p::star< 59 | p::seq< 60 | CommaOp, OptWs, 61 | ElementType 62 | > 63 | >, 64 | OptWs, 65 | p::opt 66 | > 67 | { 68 | }; 69 | 70 | struct ListOfArrayElements : ListOfExpressions {}; 71 | struct ListOfFunctionArguments : ListOfExpressions {}; 72 | 73 | } 74 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Functions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace rigc 9 | { 10 | 11 | struct Statements; 12 | 13 | struct CodeBlock 14 | : p::seq< p::one<'{'>, OptWs, Statements, OptWs, p::one<'}'> > 15 | { 16 | }; 17 | 18 | struct ReturnStatement 19 | : 20 | p::if_must< RetKeyword, OptWs, Expression > 21 | {}; 22 | 23 | struct ExplicitReturnTypeArrow 24 | : p::string<'-','>'> 25 | {}; 26 | 27 | struct ExplicitReturnType 28 | : 29 | p::if_must< ExplicitReturnTypeArrow, OptWs, Type > 30 | {}; 31 | 32 | struct Parameter 33 | : p::seq< 34 | Name, 35 | p::opt< OptWs, p::one<':'>, OptWs, Type >, 36 | p::opt< Assignment > 37 | > 38 | { 39 | }; 40 | 41 | struct Params 42 | : 43 | p::seq< Parameter, OptWs, p::star< p::one<','>, OptWs, Parameter > > 44 | { 45 | }; 46 | 47 | struct FunctionParams 48 | : p::seq< p::one<'('>, OptWs, p::opt, OptWs, p::one<')'> > 49 | { 50 | }; 51 | 52 | 53 | struct FunctionDefinition 54 | : p::seq< 55 | p::opt, 56 | p::opt, 57 | p::if_must< 58 | FuncKeyword, Ws, Name, OptWs, p::opt, p::opt, OptWs, CodeBlock 59 | > 60 | > 61 | { 62 | }; 63 | 64 | struct ClosureDefinition 65 | : p::seq< 66 | p::sor< 67 | Name, 68 | FunctionParams 69 | >, 70 | OptWs, 71 | p::if_must< 72 | p::string<'=','>'>, 73 | OptWs, 74 | p::sor< 75 | Expression, 76 | CodeBlock 77 | > 78 | > 79 | > 80 | {}; 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Keywords.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define DEFINE_KEYWORD(structName, keywordName) \ 6 | struct structName##Keyword \ 7 | : TAO_PEGTL_KEYWORD( keywordName ) \ 8 | { } 9 | 10 | namespace rigc 11 | { 12 | 13 | DEFINE_KEYWORD(From, "from"); 14 | DEFINE_KEYWORD(Import, "import"); 15 | DEFINE_KEYWORD(Export, "export"); 16 | DEFINE_KEYWORD(Func, "func"); 17 | DEFINE_KEYWORD(Var, "var"); 18 | DEFINE_KEYWORD(Const, "const"); 19 | DEFINE_KEYWORD(If, "if"); 20 | DEFINE_KEYWORD(Else, "else"); 21 | DEFINE_KEYWORD(While, "while"); 22 | DEFINE_KEYWORD(Do, "do"); 23 | DEFINE_KEYWORD(For, "for"); 24 | DEFINE_KEYWORD(Ret, "ret"); 25 | DEFINE_KEYWORD(Break, "break"); 26 | DEFINE_KEYWORD(Continue, "continue"); 27 | DEFINE_KEYWORD(True, "true"); 28 | DEFINE_KEYWORD(False, "false"); 29 | DEFINE_KEYWORD(Class, "class"); 30 | DEFINE_KEYWORD(Union, "union"); 31 | DEFINE_KEYWORD(Enum, "enum"); 32 | DEFINE_KEYWORD(Operator, "operator"); 33 | DEFINE_KEYWORD(Override, "override"); 34 | DEFINE_KEYWORD(Template, "template"); 35 | DEFINE_KEYWORD(TemplateTypename, "type_name"); 36 | DEFINE_KEYWORD(Of, "of"); 37 | DEFINE_KEYWORD(As, "as"); 38 | 39 | } 40 | 41 | #undef DEFINE_KEYWORD 42 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Literals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace rigc 10 | { 11 | 12 | 13 | struct Digits 14 | : p::plus 15 | { 16 | }; 17 | 18 | struct IntegerLiteral 19 | : p::seq>, Digits> 20 | { 21 | }; 22 | 23 | struct Float64Literal 24 | : p::seq, p::star, p::not_at > 25 | { 26 | }; 27 | 28 | struct Float32Literal 29 | : p::seq, p::star, p::one<'f'>, p::not_at > 30 | { 31 | }; 32 | 33 | struct ListOfArrayElements; 34 | 35 | struct BoolLiteral 36 | : p::sor 37 | { 38 | }; 39 | 40 | struct ArrayLiteral 41 | : p::seq< p::one<'['>, OptWs, ListOfArrayElements, OptWs, p::one<']'> > 42 | { 43 | }; 44 | 45 | struct EscapeSequence 46 | : p::seq< p::one<'\\'>, p::any > 47 | { 48 | }; 49 | 50 | struct StringLiteralContents 51 | : 52 | p::sor< 53 | EscapeSequence, 54 | p::not_one<'\n', '"'> 55 | > 56 | { 57 | }; 58 | 59 | struct StringLiteral 60 | : 61 | p::if_must< p::one<'"'>, p::star, p::one<'"'> > 62 | { 63 | }; 64 | 65 | struct CharLiteralContents 66 | : 67 | p::sor< 68 | EscapeSequence, 69 | p::not_one<'\n', '\''> 70 | > 71 | { 72 | }; 73 | 74 | struct CharLiteral 75 | : 76 | p::if_must< p::one<'\''>, p::star, p::one<'\''> > 77 | { 78 | }; 79 | 80 | 81 | struct AnyLiteral 82 | : 83 | p::sor< 84 | Float32Literal, 85 | Float64Literal, 86 | IntegerLiteral, 87 | BoolLiteral, 88 | StringLiteral, 89 | CharLiteral, 90 | ArrayLiteral 91 | > 92 | { 93 | }; 94 | 95 | } 96 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Loops.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace rigc 9 | { 10 | 11 | struct Statement; 12 | struct SingleBlockStatement; 13 | struct CodeBlock; 14 | struct Condition; 15 | 16 | struct WhileStatement 17 | : 18 | p::seq< WhileKeyword, OptWs, Condition, OptWs, 19 | p::sor< 20 | SingleBlockStatement, 21 | CodeBlock 22 | > 23 | > 24 | { 25 | }; 26 | 27 | 28 | struct ForStatement 29 | : 30 | p::seq< 31 | ForKeyword, 32 | WsWrapped< 33 | p::one<'('>, 34 | WsWrapped, p::one<';'>, 35 | WsWrapped, p::one<';'>, 36 | WsWrapped, 37 | p::one<')'> 38 | >, 39 | p::sor< 40 | SingleBlockStatement, 41 | CodeBlock 42 | > 43 | > 44 | { 45 | }; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Operators.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace rigc 9 | { 10 | 11 | struct Expression; 12 | struct InfixOperator; 13 | struct PrefixOperator; 14 | struct PostfixOperator; 15 | struct ListOfFunctionArguments; 16 | 17 | #define OP_NAME(...) p::string<__VA_ARGS__> 18 | 19 | struct OverridableOperatorNames : p::sor< 20 | OP_NAME('+','='), 21 | OP_NAME('-','='), 22 | OP_NAME('*','='), 23 | OP_NAME('/','='), 24 | OP_NAME('%','='), 25 | 26 | OP_NAME('<','='), 27 | OP_NAME('>','='), 28 | OP_NAME('<'), 29 | OP_NAME('>'), 30 | OP_NAME('!','='), 31 | OP_NAME('=','='), 32 | 33 | OP_NAME('='), 34 | 35 | OP_NAME('+'), 36 | OP_NAME('-'), 37 | OP_NAME('*'), 38 | OP_NAME('/'), 39 | OP_NAME('%'), 40 | 41 | OP_NAME('p','r','e','+','+'), 42 | OP_NAME('p','r','e','-','-'), 43 | 44 | OP_NAME('p','o','s','t','+','+'), 45 | OP_NAME('p','o','s','t','-','-'), 46 | 47 | OP_NAME('a','s') 48 | > {}; 49 | 50 | #undef OP_NAME 51 | 52 | // Pointer and reference operators 53 | //// Prefix 54 | struct DereferenceOp : p::one <'*'> {}; 55 | struct ReferenceOp : p::one <'&'> {}; 56 | 57 | // Direct assignment operator 58 | //// Infix 59 | struct AssignOp : p::string <'='> {}; 60 | 61 | // Comma operator 62 | //// Infix 63 | struct CommaOp : p::string <','> {}; 64 | 65 | // Dot operator 66 | //// Infix 67 | struct DotOp : p::string <'.'> {}; 68 | 69 | // Subscript operator 70 | //// Postfix 71 | struct SubscriptOp : p::seq < p::one<'['>, OptWs, ListOfFunctionArguments, OptWs, p::one<']'> > {}; 72 | 73 | //// Postfix 74 | struct FunctionCallOp : p::seq < p::one<'('>, OptWs, ListOfFunctionArguments, OptWs, p::one<')'> > {}; 75 | 76 | // Math operators 77 | //// Prefix 78 | struct PreincrementOp : p::string <'+','+'> {}; 79 | struct PredecrementOp : p::string <'-','-'> {}; 80 | struct NumericNegateOp : p::one <'-'> {}; 81 | 82 | //// Postfix 83 | struct PostincrementOp : p::string <'+','+'> {}; 84 | struct PostdecrementOp : p::string <'-','-'> {}; 85 | 86 | //// Infix 87 | struct AddOp : p::string <'+'> {}; 88 | struct SubOp : p::string <'-'> {}; 89 | struct MultOp : p::string <'*'> {}; 90 | struct DivOp : p::string <'/'> {}; 91 | struct ModOp : p::string <'%'> {}; 92 | 93 | struct AddEqOp : p::string <'+','='> {}; 94 | struct SubEqOp : p::string <'-','='> {}; 95 | struct MultEqOp : p::string <'*','='> {}; 96 | struct DivEqOp : p::string <'/','='> {}; 97 | struct ModEqOp : p::string <'%','='> {}; 98 | 99 | // Bitwise operators 100 | //// Prefix 101 | struct BitNegate : p::one <'~'> {}; 102 | 103 | //// Infix 104 | struct BitAndOp : p::string <'&'> {}; 105 | struct BitXorOp : p::string <'^'> {}; 106 | struct BitOrOp : p::string <'|'> {}; 107 | struct BitShLeftOp : p::string <'<','<'> {}; 108 | struct BitShRightOp : p::string <'>','>'> {}; 109 | 110 | struct BitAndEqOp : p::string <'&','='> {}; 111 | struct BitXorEqOp : p::string <'^','='> {}; 112 | struct BitOrEqOp : p::string <'|','='> {}; 113 | struct BitShLeftEqO : p::string <'<','<','='> {}; 114 | struct BitShRightEqOp : p::string <'>','>','='> {}; 115 | 116 | // Logical operators 117 | //// Prefix 118 | struct LogicalNegateOp : p::one <'!'> {}; 119 | 120 | //// Infix 121 | struct LogicalAndOp : p::string<'a','n','d'> {}; 122 | struct LogicalOrOp : p::string<'o','r'> {}; 123 | 124 | // Relational operators 125 | //// Infix 126 | struct EqualOp : p::string <'=','='> {}; 127 | struct InequalOp : p::string <'!','='> {}; 128 | struct GreaterThanOp : p::string <'>'> {}; 129 | struct LowerThanOp : p::string <'<'> {}; 130 | struct GreaterOrEqOp : p::string <'>','='> {}; 131 | struct LowerOrEqOp : p::string <'<','='> {}; 132 | 133 | // Ternary conditional: 134 | //// Infix 135 | struct TernaryFirstOp : p::one <'?'> {}; 136 | struct TernarySecondOp : p::one <':'> {}; 137 | 138 | // Scope operator 139 | //// Infix 140 | struct ScopeOp : p::two<':'>{}; 141 | 142 | // Conversion operator 143 | //// Infix 144 | struct ConversionOp : AsKeyword {}; 145 | 146 | struct DangerConversionOp : p::seq, p::at> {}; 147 | 148 | 149 | ///////////////////// Grammar //////////////////////// 150 | 151 | 152 | struct PrefixOperator 153 | : p::sor< 154 | DereferenceOp, 155 | ReferenceOp, 156 | PreincrementOp, 157 | PredecrementOp, 158 | // NumericNegateOp, 159 | BitNegate, 160 | LogicalNegateOp 161 | > 162 | { 163 | }; 164 | 165 | template 166 | struct InfixOperatorBase 167 | : 168 | p::sor< 169 | AddEqOp, 170 | SubEqOp, 171 | MultEqOp, 172 | DivEqOp, 173 | ModEqOp, 174 | 175 | AddOp, 176 | SubOp, 177 | MultOp, 178 | DivOp, 179 | ModOp, 180 | 181 | BitAndEqOp, 182 | BitXorEqOp, 183 | BitOrEqOp, 184 | BitShLeftEqO, 185 | BitShRightEqOp, 186 | 187 | BitAndOp, 188 | BitXorOp, 189 | BitOrOp, 190 | BitShLeftOp, 191 | BitShRightOp, 192 | 193 | LogicalAndOp, 194 | LogicalOrOp, 195 | 196 | EqualOp, 197 | InequalOp, 198 | GreaterOrEqOp, 199 | LowerOrEqOp, 200 | GreaterThanOp, 201 | LowerThanOp, 202 | 203 | AssignOp, 204 | 205 | ScopeOp, 206 | 207 | DangerConversionOp, 208 | ConversionOp, 209 | 210 | TernaryFirstOp, 211 | TernarySecondOp, 212 | 213 | DotOp, 214 | 215 | Optionals... 216 | > 217 | { 218 | }; 219 | 220 | 221 | struct InfixOperator : InfixOperatorBase {}; 222 | struct InfixOperatorNoComma : InfixOperatorBase<> {}; 223 | 224 | 225 | struct PostfixOperator 226 | : p::sor< 227 | SubscriptOp, 228 | FunctionCallOp, 229 | PostincrementOp, 230 | PostdecrementOp 231 | > 232 | {}; 233 | 234 | 235 | } 236 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Parts.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace rigc 11 | { 12 | 13 | struct AssignmentValue 14 | : Expression 15 | { 16 | }; 17 | 18 | struct InitializerValue 19 | : AssignmentValue 20 | { 21 | }; 22 | 23 | struct Assignment 24 | : p::seq< OptWs, p::one<'='>, OptWs, AssignmentValue > 25 | { 26 | }; 27 | 28 | struct Initialization 29 | : p::seq< OptWs, p::if_must< p::one<'='>, OptWs, InitializerValue > > 30 | { 31 | }; 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Statements.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace rigc 12 | { 13 | 14 | struct BreakStatement 15 | : p::if_must< BreakKeyword, p::sor< p::seq< Ws, IntegerLiteral >, OptWs > > 16 | { 17 | }; 18 | 19 | struct ContinueStatement 20 | : ContinueKeyword 21 | { 22 | }; 23 | 24 | struct NonExpression 25 | : 26 | p::sor< 27 | ReturnStatement, 28 | BreakStatement, 29 | ContinueStatement, 30 | VariableDefinition 31 | > 32 | { 33 | }; 34 | 35 | struct SingleStatement 36 | : 37 | p::seq< p::sor, Semicolon > 38 | { 39 | }; 40 | 41 | struct ComplexStatement 42 | : 43 | p::sor< 44 | IfStatement, 45 | WhileStatement, 46 | ForStatement 47 | > 48 | { 49 | }; 50 | 51 | struct Statement 52 | : 53 | p::sor< 54 | ComplexStatement, 55 | SingleStatement 56 | > 57 | {}; 58 | 59 | 60 | struct SingleBlockStatement 61 | : Statement 62 | { 63 | }; 64 | 65 | struct Statements 66 | : p::star< p::seq > 67 | { 68 | }; 69 | 70 | struct ImportStatement 71 | : p::if_must< ImportKeyword, Ws, PackageImportFullName, OptWs, Semicolon> 72 | { 73 | }; 74 | 75 | } 76 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Templates.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace rigc { 9 | 10 | struct TemplateDefParamKind 11 | : p::sor< TemplateTypenameKeyword, Name > 12 | { 13 | }; 14 | 15 | 16 | struct TemplateDefParamListElem 17 | : 18 | WsWrapped< 19 | Name, // name is a type constraint here, either a type itself or a genuine constraint, C++ concept like 20 | WsWrapped>, 21 | TemplateDefParamKind 22 | > 23 | { 24 | }; 25 | 26 | struct TemplateDefParamList 27 | : 28 | p::list_tail> 29 | { 30 | }; 31 | 32 | struct TemplateDefPreamble 33 | : 34 | p::if_must< 35 | TemplateKeyword, OptWs, 36 | p::one<'<'>, 37 | WsWrapped, 38 | p::one<'>'> 39 | > 40 | { 41 | }; 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Tokens.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace rigc 10 | { 11 | 12 | struct Name; 13 | 14 | struct PackageImportNames 15 | : p::seq< 16 | Name, 17 | p::opt< 18 | p::seq< p::one<'.'>, PackageImportNames> 19 | > 20 | > 21 | { 22 | }; 23 | 24 | struct PackageImportFullName 25 | : 26 | p::sor< 27 | StringLiteral, 28 | PackageImportNames 29 | > 30 | { 31 | }; 32 | 33 | struct Name 34 | : p::identifier 35 | {}; 36 | 37 | struct Type; 38 | 39 | struct TemplateParam 40 | : 41 | p::sor 42 | { 43 | }; 44 | 45 | struct TemplateParamsInner 46 | : 47 | p::seq< 48 | TemplateParam, 49 | p::opt< OptWs, 50 | p::opt< p::seq< p::one<','>, OptWs, TemplateParam> > 51 | > 52 | > 53 | { 54 | }; 55 | 56 | struct TemplateParams 57 | : 58 | p::if_must< p::one<'<'>, OptWs, TemplateParamsInner, OptWs, p::one<'>'> > 59 | { 60 | }; 61 | 62 | struct PossiblyTemplatedSymbolNoDisamb 63 | : 64 | p::seq< Name, p::opt > 65 | {}; 66 | 67 | struct PossiblyTemplatedSymbol 68 | : 69 | p::seq< Name, 70 | p::sor< 71 | p::seq< WsWrapped>, TemplateParams >, 72 | // If ::< Args > not succeded, then make sure the Name (at the start) isn't followed by the TemplateParams 73 | p::not_at 74 | > 75 | > 76 | {}; 77 | 78 | struct Type 79 | : p::sor< PossiblyTemplatedSymbol, PossiblyTemplatedSymbolNoDisamb > 80 | { 81 | }; 82 | 83 | struct DeclType 84 | : 85 | p::sor< 86 | VarKeyword, 87 | ConstKeyword, 88 | Type 89 | > 90 | {}; 91 | 92 | } 93 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Grammar/Variables.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace rigc 8 | { 9 | 10 | struct VariableDefinition 11 | : p::seq< DeclType, Ws, Name, p::opt< Initialization > > 12 | { 13 | }; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/Parser.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace rigc 6 | { 7 | 8 | using ParserNode = p::parse_tree::node; 9 | using ParserNodePtr = std::unique_ptr< ParserNode >; 10 | 11 | auto parse(p::file_input<> &in) -> ParserNodePtr; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Parser/include/RigCParser/RigCParserPCH.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace pegtl = tao::pegtl; 11 | 12 | namespace rigc 13 | { 14 | namespace p = pegtl; 15 | } -------------------------------------------------------------------------------- /Parser/src/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser/include/RigCParser/RigCParserPCH.hpp" 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /Parser/src/Parser.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser/include/RigCParser/RigCParserPCH.hpp" 2 | 3 | #include 4 | #include 5 | 6 | namespace rigc 7 | { 8 | 9 | auto parse(p::file_input<> &in) -> ParserNodePtr 10 | { 11 | namespace pt = pegtl::parse_tree; 12 | return pt::parse< rigc::Grammar, rigc::Selector >( in ); 13 | 14 | // For now leave the error handling to the caller. 15 | 16 | // try 17 | // { 18 | // } 19 | // catch (const pegtl::parse_error &e) 20 | // { 21 | // auto const p = e.positions().front(); 22 | // std::cerr << e.what() << '\n' 23 | // << in.line_at(p) << '\n' 24 | // << std::setw(p.column) << '^' << std::endl; 25 | // } 26 | // catch (const std::exception &e) 27 | // { 28 | // std::cerr << e.what() << std::endl; 29 | // } 30 | 31 | // return nullptr; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Parser/src/RigCParserPCH.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser/include/RigCParser/RigCParserPCH.hpp" 2 | 3 | // Do not edit this file. 4 | -------------------------------------------------------------------------------- /ParserApp/src/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | namespace pt = pegtl::parse_tree; 7 | 8 | if (argc < 2) 9 | return 0; 10 | 11 | try 12 | { 13 | pegtl::file_input in(argv[1]); 14 | 15 | auto root = rigc::parse( in ); 16 | if (root) { 17 | pt::print_dot( std::cout, *root ); 18 | } 19 | } 20 | catch (const std::exception &e) 21 | { 22 | std::cerr << e.what() << std::endl; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RigC programming language 2 | 3 | **⚠ Note: this language is in a very early stage of the development and some features will be missing. This README contains overview of our goals.** 4 | 5 | A prototype of **RigC** programming language - the better and simpler C++ language. 6 | 7 | ## 👋 Hello, World! 8 | 9 | ![Hello World Demo](res/example-imgs/hello-world.png) 10 | 11 | 12 | ## ⏳ Progress 13 | 14 | We're working hard to publish the first usable alpha release. 15 | Consider helping us by contributing. 16 | 17 | - [ ] Basic language constructs 18 | - [x] Variables 19 | - [x] Functions 20 | - [x] Loops 21 | - [x] Classes 22 | - [x] Modules 23 | - [ ] Operator overloading 24 | - [ ] Conversions 25 | - [ ] Implement advanced language constructs 26 | - [x] Basic templates 27 | - [ ] Basic concepts 28 | - [ ] First public alpha release 29 | 30 | ## 🚀 Getting started 31 | 32 | This language is pre-alpha version. You can download the source code and compile it using [pacc](https://github.com/PoetaKodu/pacc) package manager. 33 | 34 | First let it automatically **install** the dependencies: 35 | ```bash 36 | pacc install 37 | ``` 38 | 39 | Then run the **build** command (see [build command flags](https://github.com/PoetaKodu/pacc/blob/main/docs/Actions/Build.md), you might want to run it with multiple cores, or in different configuration) 40 | ```bash 41 | pacc build 42 | ``` 43 | 44 | See pacc documentation [here](https://github.com/PoetaKodu/pacc). 45 | 46 | ## Running RigC code 47 | 48 | Right now the code can only be run using our virtual machine using: 49 | 50 | ```bash 51 | vm