Tuesday, March 01, 2011

Creating your own programming language with ANTLR.

Hi, and welcome to my blog. I am Bart Kiers, a software developer from Rotterdam, the Netherlands. I also do some freelance work now and then (my company: Big O software).

From time to time I answer questions about ANTLR on Stackoverflow, and while doing so, I see many people using ANTLR up to a certain point and then ask themselves: "Okay, how do I proceed from here on? What do I do after creating an AST from my source code?". I hope to answer those questions by creating a small programming language called Tiny Language (TL henceforth) that will be parsed by ANTLR and then interpreted using plain Java code.

Don't worry if certain things are (already) a bit vague: I'll write the coming blogs in such a way that people without prior ANTLR experience and without a Computer Science background can follow them. Or, better said: I hope they will! The only thing you need to know is Java.

This tutorial consists of the following parts:
  1. TL specification
  2. Introduction to ANTLR
  3. Lexical analysis of TL
  4. Syntactic analysis of TL
  5. Building an AST
  6. Creating a tree grammar
  7. Interpreting and evaluating TL I
  8. Interpreting and evaluating TL II
  9. Room for improvement & recommendations

No comments: