The C# based scripting language where you can have your cake and eat it too! (Dies)
This was made for fun (in C# .Net 7.0) but maybe I'll put it in a game one day!. Also yes i've been writing this without git for a good while! Time to put it on git for real and get this finished!
Click here to get a hopefully short and easy to understand overview of the syntax. Subject to modification, will likely break as Cake is fleshed out.
- strings
- math operations
- boolean operations
- variables
- if, elif, and else
- while Loops
- functions (not C# native, yet)
- arrays (regular, arrays in arrays, etc)
- 'structs'
- assert (debug keyword that ends program early if condition fails)
First, clone the project somewhere.
Next, Install the .NET SDK. I'm currently using version `7.0.410`, but 7.0 and above should work fine. Anything lower is probably not going to work at the moment.
Then, if you want to use it as is:
- create a file in the same directory as the cloned project. the filename should end in `.ck`.
- write you first script in the above file (look in SYNTAX.MD for guidance).
- open a terminal in this projects location, and use the command "dotnet run"
- enjoy!
If you want to use this in your own projects, however, then you will be interested in this bit of C# code:
string input = "CODE";
Lexer lexer = new();
Parser parser = new(lexer.Tokenize(input).ToArray());
Main main = parser.Parse();
Evaluator evaluator = new();
evaluator.EvaluateMain(main);
int exitCode = evaluator.exitCode;
the important parts of the above block are the last two lines.
- `evaluator.EvaluateMain(main);`:
This returns something called an "ITokenLiteral". This is just value of some kind, a number or a string. this is the final output of our script!
- `int exitCode = evaluator.exitCode;`:
This is how we get the exit code. if this value is ever not 0, an `assert` statement failed and we exited the program early.
[ ] Global Vars in Cake functions (@var)
[ ] Functions (C#)
[ ] Loops (For i)
[ ] Escape Characters in strings
[ ] Refactor `Prpgram.cs`, it needs some work
[ ] Support C# objects?