Oni Compiler - A brief introduction

Oni Compiler - A brief introduction

Advertisemen

Oni Compiler is my attempt for creating a compiler to compile a terrible language of my own devising. Currently Oni is just a codename, may turn into the real name of the final compiler, may not. It is written in C# due to that being what I'm most familiar with as of late. 

The Oni language incorporates lambda expressions such as in Lambda Calculus or C#'s Lambda Expressions.

Anonymous functions:
mso 9]>
z<-(((INT,INT)(x,y)->(x x * y y * +)),3,5)

In C:
In C: z = 3*3 + 5*5

As you can see from the above example, the Oni language is
A) over-complicated, and
B) uses post-fix arithmetic.

Named functions:

(((INT,INT)(x,y)->(x*x+y*y)), SQUARESUM returns INT) z<-SQUARESUM(3,5)

In C:
int SQUARESUM(int x, int y) { return x*x+y*y; }

Example Programs:

Hello World

PRINT "Hello World

Add User Input


INT X
INT Y
X<-READ
Y<-READ
PRINT (((INT,INT)(a,b)->(a b +)),X,Y)

The above examples of Oni are only a draft, I want to use the creation of the Oni language as a trigger for my to learn a functional language, Haskall or LISP (preferably both).

Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Game Engine Tutorial