Game
Robot Unlock
12 years ago

The long journey from character to AST... begins elsewhere


Since we’re in full compiler-compiler season I thought it would be appropriate for me to also provide a more educational example. This example illustrates how a very rudimentary* compiler works. In more detail, it shows what happens to your code after it’s been chopped into nice tokens. Then, it shows how, based on these tokens and the language’s grammar an AST is built and then decorated and, finally, how this tree is fed to an interpreter and results start popping up.

By rudimentary I mean that the language consists of simple arithmetic expressions. Below, you can find the compiler-demo. Just type stuff and be amazed!

If you want to find out more about the inner workings of this nifty thing, check this very nicely written article on CodeProject.

<div> Your input code:
7 + pi * (x - 10)
The environment:
{ “x” : 5, “pi” : 3 }
Output:
</div>



0 comments

Loading...

Next up

Path of Kami: The Evolution of the Lore

Heya there! I really wanted to show you all a little gameplay preview of the first boss fight i'm currently working on i hope you like it ^^

"Our work is never over" they said.

What you all think

So here's the first of the zodiac signs i will make for the next weeks.

The Darkside Detective: A Fumble in the Dark is out TODAY! 🖱️Advanced pointing, clicking action 🖨️Very funny words! Loads of them! 👻6 sarcastic, spectral cases to solve

Terraria

Rockin the Guitar, an Axe like Guitar I made for my Uni project

Call it 'wrong turn'!🚫 The feeling of running into a house with only one exit🚪, and being doomed to die. #pixelart #pixelartist #pixelartwork #art #pixel #indiegame #IndieGameDev #indieartist

Spaaaace~

These are background sprites I've created for a game I'm working on at school ^w^ Click on the post to see how the sprites connect. You won't regret it! (personally, I think it's pretty heheh)

Drawn in Piskel using my mouse. Whaddya think?