[antlr-interest] Tips on this compilation process

Natan Vivo nvivo.misc at gmail.com
Fri Dec 11 11:13:31 PST 2009


Hi,

I'm designing a language and would like some tips from more experienced
people on the process of compilation.

I have my language grammar outputting AST with CSharp2 target. I would like
to add some compilation warnings and errors to the process. Previously, I
added a bunch of actions to the lexer/parser grammar to check the parsed
strings. But it seems this tends to get very clumsy as you add more
checks...

So I thought about separating the process into 3 tree pattern matchers with
the following actions:

1st - give errors for invalid operations (things that I can only see after
the tree is constructed)
2nd - warn as much as possible about dangerous situations
3rd - optimize/rewrite whatever possible

So, I generate the AST, pass through the 3 walkers, and finally compile the
code.


My questions are:

1. Is this a good design? Am I separating too much? Am I not separating
enough?
2. Can I still give detailed errors with line numbers/char positions even if
the exception comes from another grammar or the tree was rewritten?


Any other comments regarding the process are welcome.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091211/fb55f5a4/attachment.html 


More information about the antlr-interest mailing list