[antlr-interest] some (maybe stupid) questions on aquiring expected tokens.

ioffe_nick ioffe_nick at yahoo.com
Tue Oct 19 08:41:18 PDT 2004




Hi!
I've some language with good LL(1) grammar.
1. I need to develop an interactive interface for "stupid" user.
   It means the interface has to incorporate hiding options (tokens)
   which are impossible to enter after some sequence of tokens.
2. Also the interface has to incorporate options to "remove last word"
   i.e. going back and reenter some input.

As for problem 1 - I don't quite understand how should I use FIRST and
FOLLOW in my case since because of 2 reasons:
1. I have to provide lookahead token before production is made, so I
   have no alternatives for the LA (am I correct)
2. assume we have r1 -> X r2 Y and some more rules using the r2.
   after going to r1 and making r2 production my exected is FIRST(Y)
   which is subset of FOLLOW(r2).
   How can I know it before getting back to r1 from r2?

Problem 2:
I understand that backtracking here is bad idea because of actions which
have to be either undone or abandoned.
Is reparsing the whole sequence the only option?
Maybe <wordback> should be special unhandled token which will cause
an expception? But how then can I get back to the correct state?

Thank you in advance,

Nick








 
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