[antlr-interest] Is this the correct use of ANTLR

Jim Idle jimi at temporal-wave.com
Fri Feb 27 16:26:24 PST 2009


Bob Smiley wrote:
> Thanks for the reply, but I'm actually not trying to create an
> interpreter...my goal is to create a simple scripting language that I can
> just translate into C and compile with GCC.  My question may have been
> confusing because I was asking about a language similar to C, but really any
> grammar with the features I listed below would probably work. 
>   
For what you want to do, if you were familiar with grammars I would say 
it is easiest to type it in from scratch. However, as you are not, then 
why not take the example GNU C parser (download the examples from the 
download page), and take out the stuff you do not need (quite a lot of 
it). Advice: take out the keywords you don't want first, then remove the 
rules that use them, then remove other stuff you don't need.

The best thing to do then would be to use a string template to output 
your C file, then compile that to a .o file. The option output=AST; is 
what you need for that. However, you coudl also provide a few helper 
classes that build the .C file and just call into these with actions.

Jim


More information about the antlr-interest mailing list