[antlr-interest] Using previously matched parser rule in decision making

Jim Idle jimi at temporal-wave.com
Tue Mar 9 23:05:26 PST 2010


Can't rollback as it isn't a database and track state isn't really the right thing to be doing here (nor is tracing what rule you came through to influence parsing really, though scopes are better).

 

{{ action executes even if in synpred/backtrack }}

 

Jim

 

From: Gokulakannan Somasundaram [mailto:gokul007 at gmail.com] 
Sent: Tuesday, March 09, 2010 10:59 PM
To: Jim Idle
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Using previously matched parser rule in decision making

 



java.util.List stack = getRuleInvocationStack(e, getParserName());

But this only works for Java and other targets that copy it (I think C# might do it). I don't do it in C because I prefer to take the view that the C stuff should be as close to the metal as it can be and the programmer will choose to add the overheads they need.


That makes a lot of sense, but can you tell me how can a C-programmer keep track of the rules, he will pass through during the LookAhead. I think this question might be valid for someone using Java Target also. The action, you are asking to execute can be executed during normal parsing, but if that is used in Semantic predicates, then we have to be sure that this will get executed even during the lookahead. Can we create such a facility? 

What i mean is a set of actions, if put inside some special construct, will get executed while executing Syntactic predicates and semantic predicates, possibly with a rollback action. Please let me know, if i am misunderstanding the concept somewhere.

Thanks,
Gokul.





More information about the antlr-interest mailing list