[antlr-interest] Re : Re : How to get a list of all valid options for the next token?

Kay Röpke kroepke at classdump.org
Mon Aug 18 07:27:34 PDT 2008


Hi!

On Aug 18, 2008, at 3:39 PM, Niemeijer, R.A. wrote:

> Could anyone enlighten me as to what I'm doing wrong?


mmh. it looks like the follow set being pushed prior to entering a()  
is the set that can follow 'a' in top(), not considering any follow  
set in rule refs.
sounds like a() should either push the set before calling match or the  
follow set should be passed into the exception.
in the normal case pushing it should be inexpensive, it's only when  
the stack space is exhausted that it copies anything.

right now i don't see any way of getting at the necessary information,  
without altering the codegen templates. it should be as simple as  
finding the calls to match(), prior to that incrementing fsp and  
pushing the follow set. the tricky part is decrementing fsp again on  
all possible outbound codepaths, because the surrounding code expects  
the stack to be clean. not sure how much work that is in the  
templates. (it obviously must be done in all targets you care about).

I'd prefer to push it, because that leaves it all in one place, namely  
state.following.

cheers,
-k
-- 
Kay Röpke
http://classdump.org/








More information about the antlr-interest mailing list