Another exciting project

(Now its all starting to fit together - The compiler project I had in my mind for years)

Its a been a dream of mine, for a quite a long time, to write a compiler of my own. Rather than the sheer joy of creating, and getting invovled with such a cool project, my foremost aim was to get to know, more about how one language gets "magically" transformed to another, using a "special software" that we call the compiler. All these thoughts lay in my mind for quite some time.

And whenever i wanted to write a compiler, the first thought that came to my mind was that, I must learn assembly language and parsing and all those complicated stuff.

Now it so happened that, 2 weeks back, one of my friends Nandu had come to my home and we discussed about these things, that is compiler design, operating systems and so on(One of the best things i like about his visit) He asked me if it was possible to write a new programming language, but with an easier, yet powerful syntax, compared to Java. He also told me that the compiler could be written in Java, to compile this new programming language.

The idea really did strike me. After he left my place, I started to think about it, and this is the end result of that thought process.
For identification puprose, the new programming language shall be called Neo(if any of you guys have copyrighted that name, please contact me and I will be glad to change the project name!)

(The compilation process)

As show in the figure ^^ ,the input to the compiler will be the Neo programming language source and the output will be source code in java(yeah, our plain old .java file)Now clearly, 2 challenges lay ahead of me.

  1. Designing a new language - Neo.
  2. Designing a compiler for this new language.

If you seem to feel any of the section highlighted below to be too technical pleae feel free to Google for the same and learn more about it. I bet you wont be sorry for that ;)

1)Designing a new language - Neo

A lot of questions arose in my mind. On the basic level I had to tackle :

  • What syntax must I follow ?(basic structure of the project)
  • Should it be loosely styped and strongly typed
  • What about functions?

Okay, so to keep up with the KISS methodology(KISS - Keep it Simple Stupid) I decided to make a prototype version first, then tackle more complicated issues.

I wanted something, like a mix of Python and Java.(Yeah i know Jython exists, but getting your hands dirty by creating your own compiler is something different)

So first thing i wanted was that in order to print a simple hello world, You must type print. Thats all. No more classes and pubilc static void main (syntax used in java) and all

2) Compiler

The compiler must be in Java, although I have plans to port it to python later on. But anyway currently I will stick on with java. The ouput of the program will be a java file that could be compiled using the normal javac compiler provided by Sun .

Let the coding begin

With a basic idea and some thoughts initiated by Nandu, i decided to start coding. I fired up jcreator and started to code. As the project progressed(in a span of couple of days) I got a lot of great feedback from Nandu and also by looking up in the web; thus the initial prototype version was completed, And i decided to release it, as an open source project.

You can get the complete documentation, along with the full source code for the project here. I want to polish it a bit further by adding more syntax, but still keeping it as simple as possible. If you like to contribute to this project, you can post your modified version as reply to the thread in the group where I posted the source code.

Your precious feedback is welcome, as to how this project should be continued. I have posted my vision here, and if you like to make use of this idea in someother place, do post it here

All the best guys

with regards

Labels: , , ,