Skip to content

High level programming language that compiles into custom bytecodes and brainfuck

Notifications You must be signed in to change notification settings

BBpezsgo/Interpreter

Repository files navigation

My programming language

.Net 9.0 C# preview

About

It's my own programming language that can generate bytecodes (executed by a custom interpreter) and brainfuck (with limitations).

I found a youtuber who made a great tutorial series showing how to make a parser and a compiler. I basically copied the code with minimal changes. When the series ended, I was left on my own, so I improved the code myself.

Command line arguments

BBLang [options...] source

  • --help Prints some information about the program

  • --verbose Prints some information about the compilation process

  • --format format Specifies which generator to use. Supported formats are bytecode, brainfuck and assembly.

Warning

Brainfuck sometimes aint working.

Warning

Assembly 100% not working.

  • --debug Launches the debugger screen (only avaliable on Windows) More info

  • --output file Writes the generated code to the specified file (this option only works for brainfuck)

  • --throw-errors Crashes the program whenever an exception thrown. This useful for me when debugging the compiler.

  • --print-instructions Prints the generated instructions before execution

  • --print-memory Prints the memory after execution

  • --basepath directory Sets the path where source files will be searched for using statements

  • --dont-optimize Disables all optimization

  • --no-debug-info Disables debug information generation (if you compiling into brainfuck, generating debug informations will take a lots of time)

  • --stack-size size Specifies the stack size

  • --heap-size size Specifies the HEAP size

Note

For brainfuck, if you specify zero the HEAP will not be initialized and wherever you try to access it, it will not compile.

Note

Because of how HEAP represented, its size can't be larger than 126.

  • --no-nullcheck Disables null check generation when dereferencing a pointer

Hello World:

using "https://raw.githubusercontent.com/BBpezsgo/Interpreter/master/StandardLibrary/System.Console.bbc";

PrintLine("hello, world");

api-ms-win-crt-string-l1-1-0.dll Missing Error

This can be fixed by install this.

Build From Source

  1. Download this repository
  2. Download the Win32-Stuff repository
  3. Download the Maths repository
  4. Extract the .zip files
  5. Remove all -main suffixes

Now the folder structure should look like this:

./Interpreter/Core.csproj
./Win32-Stuff/Win32.csproj
./Math/Math.csproj
  1. Open ./Interpreter/Core.csproj in a text editor
  2. In the ProjectReference tags, replace all ..\.. with .. (so it will point to the existing projects you downloaded)

Method 1: Building with Visual Studio:

  1. Open ./Interpreter/Core.csproj in Visual Studio
  2. Add the ./Win32-Stuff/Win32.csproj project to the solution
  3. Add the ./Math/Math.csproj project to the solution

Now you can build it with the "Build" button

Method 2: Building with .NET CLI:

  1. Open the ./Interpreter folder

  2. Now you can use the .NET CLI to build (dotnet build) or run (dotnet run) the project