[antlr-interest] NQOT: Grammar meta-programming

Johannes Luber jaluber at gmx.de
Sun Dec 9 16:19:58 PST 2007


Harald M. Müller wrote:
> 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 ;-) ...

The problem is that you overlook e.g. "(int) -1.0", which is valid
nonetheless.
> 
>> 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" ...

Interesting - never heard of that book. Will look into that.

Johannes


More information about the antlr-interest mailing list