codebite _

Glocal - an interpreter I am making

Tue 07 of April, 2015

Glocal Logo

Hello, I just decided to share that I am currently developing my own little interpreter. I am coding it in C#, because I am most familiar with it, and feel comfortable in it.

The language itself is pretty limited at the moment. it is called Glocal, because it is a shortened for Glorified Calculator. Because it is basically is at the moment.

I am coding it from scratch, with no prior experience. So everything from Lexer to Evaluation is made with no external library. Reason? Just for fun! :D

Here are the list of features it has right now:

Math Expressions

So I plan to also add:

Here is some code snipped:

{
    ; Has one line comments

    ; variables and basic I/O
    print "Echo: "
    a = scan
    print a

    ; Just added types, so no bool operations yet :(
    ; Has flow control
    if true then
    {
        ; Has power operator
        b = 2 ^ 10
        print b
    }
    else
    {
        ; And other basic math
        c = 213.2 % 3.1 + (16 - 3)
        print c
    }

    print "Enter a number: "
    num = scan

    i = 0

    ; Has a loop
    times num do
    {
        i = i + 1
        print i
    }

    print "What is your name?"
    name = scan
    print "Hello, " + name + "!"

Output:

D:\C#\Interpreter\Interpreter\Debug>glocal test5.gc
Echo:
echo?
echo?
1024
Enter a number:
5
1
2
3
4
5
What is your name?
Red
Hello, Red!

D:\C#\Interpreter\Interpreter\Debug>

Thanks for reading! :D