I have a bison grammar:
input: /* empty */
| input command
;
command:
builtin
| external
;
builtin:
CD { printf("Changing to home directory...\n"); }
| CD WORD { printf("Changing to directory %s\n", $2); }
;
I am wondering how I make Bison not accept (YYACCEPT?) Something like commanduntil it reads ALL the input. That way, I can use all of these rules below, which use recursion or something else to create things that either lead to a valid command, or something that won't work.
One simple test that I am doing with the code above just enters "cd mydir mydir". Bison analyzes CDand WORDgoes “hey! This is a team, put it on top!”. Then the next token that he finds is simply WORDthat which has no rule, and then he reports an error.
, , CD WORD WORD , . , - - !
, input command NEWLINE - , - CD WORD , WORD.