[antlr-interest] Good papers for C#/Java parser stages

Alex Sedow alexsedow at mail.ru
Sun May 16 03:50:35 PDT 2004


> For enclosure (scope, right?), you can keep track of that while parsing -
> just keep track of the 'current scope' as you enter and leave scope
> elements. For the types (inheritance, implemented interfaces, visibility)
> there is forward referencing, so will at least have to do some resolution
at
> the end, or just use a second pass after all the types are defined. I
think
> it is easier to just wait, there isn't much of a speed penalty just
walking
> the types...
>
> I'm not sure why you would need more than a second stage though, perhaps
I'm
> missing which exact step you mean..? I use a third pass for type
> attribution, and resolving overloads etc. Obviously you can't resolve the
> exact map at compile time in some cases (eg you always know which
overload,
> but not which virtual method). That's for C#, though I think Java would be
> similar in most respects.
>
> Cheers,
> Robin

Hello, Robin!

Thanks for answer. I thinking about 3 stages too, but was not confident it.
pass 1- just collecting info about nested types, namespaces and base classes
(names only).
pass 2 - resolve base classes names and members types.
pass 3 - parse function bodies.
Right?

Another question. What better: on first and second pass generate only entity
model and on third pass generate AST with fully resolved entities. Or
generate AST on first pass and then resolve entity refrences on second and
third passes? For C# 1.x second variant is better because it has only two
syntax examples that can be pure syntactly resolved (and may simply fixed
with minor changes in AST tree on third pass). But in C# 2.0 introduce more
syntax ambiguity and AST conversions may not so simple.

Alex.



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list