Julia .NET Interop Library

An update on the runtime. It is now called the Spinor Programming Language.

I have been working on the Julia Parser (Wow is this a tough Language Lol!)

It works for a good amount of Julia code already but there is a long ways to go (I think it supports ~450 binary operators atm)! You can dynamically add or alter operators such as adding left/right associativity, precedence etc. I may add this ability into the language in the future.

I read a lot of the internals of Julia source and copied over what I could but there is simply a lot I cannot copy since the environment is of .NET.

Here is my first milestone:

static void Main(string[] args) {
            Spinor.Init();
            try {
                var p = new ExprParser();
                var expr = (Expr) p.Parse(@"
                            module MyModule
                                x = 5
                                x *= 2
                                x = (x + 2) * (x - 2) * (x ^ 2) ∈ w

                                struct MyStruct 
                                        field1
                                end
                            end");
                
                expr.WriteCode(Console.Out);
                expr.PrintLn();
            }
            catch (SpinorException e) {
                e.Print();
            }
            Spinor.Exit();
        }

Output:

module MyModule
        #= :3 =#
    x = 5       #= :4 =#
    x * 2       #= :5 =#
    x = ((x + 2) * (x - 2) * (x ^ 2)) ? w       #= :7 =#
    struct MyStruct
                #= :8 =#
        field1  #= :9 =#
    end #= :10 =#
end

Expr(:module, Any[False, MyModule, Expr(:block, Any[#= :3 =#, Expr(:=, Any[x, 5]), #= :4 =#, Expr(:*=, Any[x, 2]), #= :5 =#, Expr(:=, Any[x, Expr(:call, Any[?, Expr(:call, Any[*, Expr(:call, Any[+, x, 2]), Ex
pr(:call, Any[-, x, 2]), Expr(:call, Any[^, x, 2])]), w])]), #= :7 =#, Expr(:struct, Any[False, MyStruct, Expr(:block, Any[#= :8 =#, field1, #= :9 =#])]), #= :10 =#])])

The next milestone will be creating an evaluator that converts Expr objects into CLR code. This will be significantly harder.

2 Likes