[antlr-interest] Re: Type Checker Implementation Question

Bryan Ewbank ewbank at gmail.com
Fri Mar 17 06:24:50 PST 2006

To take this a step further...

(1) Build a separate tree-walking grammer as you describe.
(2) Use it as a separate tree-walking pass, for initial debugging.
(3) Finally, move calls of the semantic rules into the appropriate
parser actions.

This way, you get the isolation in which to build a clean pass; you also get
the benefits of a "single pass" for syntax and semantics.

On 3/16/06, Florian <moon_ari at hotmail.com> wrote:
> Hello,
> Mark Felzer <mark.felzer at ...> writes:
> > Hey group!
> >
> > I am planning to implement a type-checker, for an existing AST, I build
> > with the ANTLR.
> > I am weighting the option of embedding symbol table generation and
> > checking into the the parser / tree walker grammar V.S. creating a
> > separate application that analyzes the AST generating a symbol table.
> >
> > Any advise which way I should go? Which implementation would be easier
> > and more intuitive?
> >
> > Thank you,
> > -Mark
> My choice is to type-check as soon as I've built a complete AST for an
> expression, but without waiting to parse the whole input. This allows to keep
> error messages in order (syntactic ones and typechecking ones) while preserving
> separation of parsing and typechecking code.
> I do symbol generation in the parser -- added code is small: lookup symbol
> table, assign the symbol found, insert symbol in symbol table.
> Florian.

More information about the antlr-interest mailing list