[antlr-interest] NQOT: Grammar meta-programming

Harald M. Müller harald_m_mueller at gmx.de
Sat Dec 8 10:35:44 PST 2007


I wrote -

>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#, 
[...]

and Johannes answered

> Actually, this is wrong.

and I say: Huh? - because he cites the C# spec where it says

[...] 
> if x and y are
> identifiers, (x)y, (x)(y), and (x)(-y) are cast_expressions, 
> but (x)-y is not, even if x identifies a type. 

Isn't that exactly what I said?? (in C, if T is declared as a type via
typedef, (T) -a is actually parsed as a cast expression).
But that detail is only important for those C# language lawyers and grammar
writers like you and me ;-) ...

> 
> How would you do unit tests with ANTLR? I'm not sure how I 
> can realize them here.

"unit tests with ANTLR" sounds a little bit wrong, maybe: "unit tests for a
grammar" or "unit tests for a lexer+parser" is the main thing to do ... And
for writing test cases, see e.g. Boris Beizer's "Black Box Testing" - a must
read just to get the "hang of testing" ...

Regards 
Harald



More information about the antlr-interest mailing list