My First Compiler

Community Forums/Showcase/My First Compiler

daaan(Posted 2008) [#1]
I designed a small language and wrote a compiler and interpreter for it. It's really only for drawing graphics turtle style. But you can do some pretty complex drawings with it. Check it out in the gallery!

http://blitzbasic.com/gallery/view_pic.php?id=1845&gallery=&page=1

I still need to implement a debugger and maybe rewrite the scanner. But once it's finished would anyone be interested in trying it out?


puki(Posted 2008) [#2]
Oooh, that looks terribly exciting.

How fast does it draw?


daaan(Posted 2008) [#3]
The shown drawing takes less than a 10th of a second and thats with compiling first. I should run some tests to see exactly how long it takes. I haven't even optimized the interpreter yet.


plash(Posted 2008) [#4]
Amazing.


puki(Posted 2008) [#5]
I've never been really interested in all that tortoise that swims stuff from the 80's (and probably before).

Can you get this thing up to real-time speed?


daaan(Posted 2008) [#6]
If I wrote an assembler and byte code interpreter I bet it would be usable in real-time.

Which is within my realm of understanding. So maybe that will be my next project?


puki(Posted 2008) [#7]
Right you are. How long will this take?


daaan(Posted 2008) [#8]
It could be hacked out in a weekend.


puki(Posted 2008) [#9]
By tomorrow?


M2PLAY(Posted 2008) [#10]
Awesome.
I love the graphics turtle style



daaan(Posted 2008) [#11]
By tomorrow? Sure if I neglected all responsibility.. which I did to get to my current position. My brain has an itch thats telling me to at least take a shower first. I would say don't count on it.


unlikely(Posted 2008) [#12]
Sweet.
That looks like a lot of fun.


puki(Posted 2008) [#13]
Well, make it a quick shower - save the environment and all that.


daaan(Posted 2008) [#14]
I'll start on the assembly and byte code interpreter this weekend. I'm going to write it in C++ to ensure better runtime speed.


daaan(Posted 2008) [#15]
@puki - I started on the byte code interpreter and I've made a lot of progress. I'll keep you updated.


plash(Posted 2008) [#16]
Ah, puki...

This is fantastical, I'm curious, are you going to publish how you did the compiler?


daaan(Posted 2008) [#17]
As soon as I'm done I'll release the source code. Either that or I'll write a tutorial.

Status Update: The Generic Virtual Machine has been finished. Written entirely in C++ it is the backbone for all of my future interpreters. Now all I need to do is write an assembler. Hopefully I'll get to it later this evening.


plash(Posted 2008) [#18]
Wow. This is a contribution of epic proportions!


daaan(Posted 2008) [#19]
Update: The assembler is finished and the interpreter is at about 80% completion. Tomorrow I'm going to rewrite the compiler.

Also, complex drawings are now being rendered at about 1/100th of a second now which should make this language usable in real-time.


deps(Posted 2008) [#20]
Wrote my own asembler an interpreter earlier this week. Would love to see the code for the compiler, since mine is doing nothing more than going through a string and checking for known words and filling an array with the opcode equalient. :)


daaan(Posted 2008) [#21]
...going through a string and checking for known words and filling an array with the opcode equalient.


That sounds more like an assembler.

I'll release the code to the compiler when this project wraps up.


_33(Posted 2008) [#22]
Fantastics stuff!


Panno(Posted 2008) [#23]
cool


Hotshot2005(Posted 2008) [#24]
sound exciting :)


Blitzplotter(Posted 2008) [#25]
I like the graphics... and M2plays paper planet.cool


Foolish(Posted 2008) [#26]
You got mad skilz.


Kev(Posted 2008) [#27]
very nice daniel, take a look at the exe builder i wrote sometime back here

http://www.blitzbasic.com/codearcs/codearcs.php?code=1116

you might be-able to patch your bytecode into it and create your own exe files :)

kev


daaan(Posted 2008) [#28]
Kev - That is fantastic! I'm going to try and use it this weekend. I'll let you know if I get something working.