Adventures in Programming

January 31, 2008

In the last year, I have learned a proprietary programming language based on M (MUMPS), learned some M, experimented with ANTLR (a parser generator), studied up on compilers, and built a parser generator.  It has been a lot of fun.

Take a look at A Recipe for Joy in Software Development to see what makes me tick as a developer.  Think you have an adventure I’d really enjoy?  Post a comment.

Advertisements

Building a Parser Generator

January 24, 2008

I wonder how many software developers have ever built a parser generator.  I recently got to do just that.

 

My company has a proprietary language, I’ll call it MO, that compiles to M (MUMPS).  I am part of a project that involves creating a new compiler for MO that will compile not only to M but also to Java.  Pretty cool.  This is not your typical business software application development.  It is more computer-science-ish.

 

The current compiler is hand-written and single phase.  It writes out M code as it reads in MO code.  The new compiler will use a generated parser, which meant we needed a parser generator.  However, a requirement is that the parser be written in MO itself.  Of course, no existing parser generators generate a parser in MO, so we had to write our own.

The parser generator I built closely follows YACC (in terms of grammar specification and error handling).  Like YACC, it generates LALR(1) parsers.  Building it was great fun for me, and I really enjoyed cracking open Compilers: Principles, Techniques, and Tools by Aho et al (“The Dragon Book”).

The parser generator is written in MO itself.  This was done somewhat arbitrarily.  One (minor) advantage is that it lets you do everything in the MO environment.  It also let me explore using new OO features in MO.  I think it could be written just as well in Java.  Maybe I’ll do that for comparison.


%d bloggers like this: