So my objective here is to be able to determine whether an input is acceptable or not. The following are acceptable inputs:
Any combination of "u", "d", "l", "r", "n"
**Example of valid inputs:**
udlrn
uuuuuuuuuuuu
dunrldd
dddddllll
dldnrrrrrrrrrrr
**Example of invalid inputs:**
abc
abcudlr
xudz
dclrxy
Here is my Flex code
%%
"u" return UP;
"d" return DOWN;
"l" return LEFT;
"r" return RIGHT;
"n" return NONE;
\n return END;
%%
And here is my bison code
%token UP
%token DOWN
%token LEFT
%token RIGHT
%token NONE
%token END
%%
start: directions END
{
printf("\nParse complete with acceptable input\n");
}
;
directions: direction
|
directions direction
;
direction: UP | DOWN | LEFT | RIGHT | NONE
;
%%
However when I provide an input such as:
- ldruabc
I am getting the parse complete message even though this input is invalid.