5 May 2003 Monty   » (Journeyer)

My other claim to fame in the ANTLR world is the AREV to VB translator I wrote. This was not open source, but it was a whole lot of fun! AREV BASIC is a knockoff of PICK BASIC. There were no reserved keywords; IF IF=ELSE THEN ELSE=IF ELSE IF=ELSE is valid code; it used less-than and greater-than in condtions as well as delimiters for array access; a CASE statement really translated to a series of IF/ELSE statements, etc.

In the end I translated 240,000 lines of AREV into VB with an eight-pass translator. Each pass was an ANTLR tree parser which transformed the tree a bit at a time. One of the really cool things about trees and ANTLR's subclassing was having a supergrammar with rules for both AREV and VB in the same tree (using distinct node types) and as I translated I would have a tree with both languages represented. Each pass would inherit from that supergrammar and then specialize certain rules to have translation actions. For instance one pass would change expressions into VB-compatible expressions but leave control structures as AREV. Each intermediate stage was a mixture of AREV and VB nodes in the tree, but the tree parser could handle both simultaneously because each node has a type. Try writing a parser that simultaneously parses two languages -- you can't because you don't know if that IF is from AREV or VB. But in a tree you know because you have the type as well as the text.

Although what I did was essential, the real work was done by nine others who wrote the VB libraries to emulate AREV functionality such as screen handling or string processing. My part of it was definately the most fun, though! Read my article about this project at http://www.codetransform.com/fun_with_antlr.html

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!