[antlr-interest] C++ TokenStreamSelector

John Reid j.reid at mail.cryst.bbk.ac.uk
Fri Feb 16 10:08:52 PST 2007


Jim Idle wrote:
> So:
>  - Split your tokens into the largest character collections that don't
> mean it is too 
>    late by the time the parser gets it (I know that doesn't sound too
> well defined, 
>    if in doubt make new tokens);
>  - Construct parser rules that will accept all the combinations of these
> that COULD be semantically
>    valid. Note that you might end up constructing parser rules that
> accept token strings that are
>    syntactically invalid and have to reject them once you know the
> context;
>  - Either in the first pass if you have all the info as you go, or in a
> subsequent pass if not,
>    rewrite a tree that is now both syntactically and semantically valid.
> Use as many passes as you
>    need to do different things but bear in mind performance when making
> multiple passes.
> 
> Then you will have a tree that you can optimize, walk for code gen, and
> so on.
> 
> Hope that helps,
> 
> Jim
> 
> 

That certainly sounds like good advice and I hope it will help. Thanks 
for the ideas.

John.



More information about the antlr-interest mailing list