Sunday, June 5, 2011

ANTLR translator for embedded scripting language

Update 7/16/2011 I have posted code for this.

Last month, I wrote a post detailing the building of a scripting language interpreter inside of ActionScript. The interpreter worked from abstract syntax trees represented in XML, however the idea of programming in this environment is not too appealing. Therefore, I knew I had to build a translator to take a C-like syntax and translate it into my XML abstract syntax tree format. I chose to use ANTLR as my parser generator and used the related StringTemplate template engine to bridge the gap between parsed AST and XML representation. The Definitive ANTLR Reference by Terrence Parr (the creator of ANTLR) was a lot of help when it came to learning about how to use ANTLR and about non-trivial parsing in general.

So far my language consists of functions that may be called by various aspects of the game engine and that may call each other. Various types are supported, type casting is implementing, scoping is implemented, function returns are implemented and while/for/if statements are all supported. I am probably going to implement array support as well. Now that I can write complicated scripting procedures, a lot more opportunities will open for game design when I begin that phase but the code will remain penetrable since it is compiled from a readable C-subset syntax.


  1. Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject!
    Freelance French translator

  2. specialized translations The web site is lovingly serviced and saved as much as date. So it should be, thanks for sharing this with us.

  3. Coincidentally, this program can convert into 7 dialects: English, Spanish, German, Japanese, Korean and French. Youngsters and grown-ups surmise that this program is an important thing for consistently life.notevibes

  4. Translation Studies can very safely be included as an important genre in the domain of Literary Criticism since translation is an art prompting to peep into the diversified lingual..document Translation service

  5. Information about you or your business needs to be translated accurately and flawlessly, since it will determine the image you project. ili translator buy Boca Raton