|Get allowed-next-tokens in yacc? firstname.lastname@example.org (R Faulds) (1998-03-03)|
|Re: Get allowed-next-tokens in yacc? email@example.com (Maurizio Vitale) (1998-03-06)|
|Re: Get allowed-next-tokens in yacc? firstname.lastname@example.org (Vladimir Alexiev) (1998-03-07)|
|From:||"R Faulds" <email@example.com>|
|Date:||3 Mar 1998 10:38:10 -0500|
|Organization:||The Internet Access Company, Inc.|
I'm using lex&yacc (MKS) to buid a command line parser. It works okay
but there are a few CLI features I can't figure out how to implement.
1) Is there a way (without hacking y.tab.c) to get the list of allowed
tokens for some (any) point in the parse process?
I'm looking to implement a context sensitive help where user may
query (via special key) the next allowed keyword or the list of
such allowed keywords (or fields) if it exists.
e.g. For the commands SHOW INTERFACE <num>
SHOW INTERFACE ALL
If the user presses the help-key...
I want the following output...
<num> - numeric input required
ALL - display all
2) When I'm parsing down a specific rule, how do I use error to localize
the error handling?
e.g. For the command...
SET INTERFACE ADDRESS num ip-addr
The user types...
>set interface address <CR>
I'd like to have an error token (or other means) to trap the error
at the rule's action code so I could issue "numeric required,
choose an interface between [1..7]".
Instead yacc just makes a default call to yyerror() "syntax error" and
exits with an error.
[Honestly, I wouldn't use yacc. Getting the actual list of allowed tokens
at each point is really hard due to the state and table compaction that
yacc does. And the error recovery is no prize-winner. -John]
Return to the
Search the comp.compilers archives again.