[antlr-interest] parse error because of AST rewrite rules?

Stefan Oestreicher so at deluxe-design.at
Tue Sep 22 04:27:11 PDT 2009


Hi,

> Is this your own language?
Yes, it's a little toy language I'm working on for educational purposes 
and fun of course.
> Note that in C, C++, Java, C#, and other
> languages with C-derived syntax, "int a, b = 3" would not assign anything
> to a; it would leave a uninitialized. It's liable to confuse programmers
> of these languages if your language has C-like syntax but differs on this
> point. [*]
> I also think you may be trying too hard to collapse semantic equivalences
> while generating the AST. A declaration initialiser is a different
> construct from an assignment. It might (in some language) be equivalent
> to an uninitialised declaration followed by an assignment, but an AST is
> still an abstract *syntax* tree -- it should preserve syntactic distinctions
> such as that between "int a; a = 3;" and "int a = 3;". 
> (Whether to distinguish between "int a, b;" and "int a; int b;" is
> slightly less obvious, but my personal preference would be to preserve
> that distinction in the AST as well.
>   
Those a very good points. I will certainly consider them but first I 
have to get some code generated, I have already
defined much more grammar than intended. I guess that's what one gets 
for antlr being such an awesome tool that makes
defining languages so much fun :)

Thank you very much for your feedback, it's much appreciated.

Stefan


More information about the antlr-interest mailing list