[antlr-interest] NQOT: Grammar meta-programming

Harald Mueller harald_m_mueller at gmx.de
Sat Dec 8 03:20:00 PST 2007


Steve wrote:
> I have a vague
> dream of one day being able to whip up an interpreter for an esoteric
> language in an hour or less...

All the so-called "simple expressions" in languages I had to parse in the last 15 years were different - not in intent, but because many "language designers" have no idea about what they do and hence introduce subtle or not so subtle "impossibilities" into their languages. Not even C and C# have the same "simple expressions" - e.g.,

   (T) -a

might be a cast expression in C, but never in C#, because they changed the language only a very tiny bit to remove the old "lexical hack." (I hope I did not mess up that example - I did not look intot the reference when I wrote it ...).
I do not know whether Smalltalk is an "esoteric language" in your terminology, but there

   3 + 4 * 5

equals 35 (because method calling is defined like that!).

Last (but not least??), writing the expression part of a language is often a good "entry point" into the first unit tests that have(!!!!!) to be written for any grammar; and I think what you save up front will haunt you later when you get to the intricacies of a language ...

Just be 2 cents (as I said, from some experience with nasty languages ... parsing of which earned me some money, BTW :-) ).

Regards
Harald

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger


More information about the antlr-interest mailing list