I am developing a bison program and need to have a last option that allow it to recognize anything. Much like a else if…
Thanks
commands: F{
t[top++] = 'F';
}
|PLUS{
t[top++] = '+';
}
|MINUS{
t[topo++] = '-';
}
|ACOL {
t[top++] = '[';
}
|FCOL{
t[top++] = ']';
}
|POINT{
t[top++] = '.';
}
|EQUAL {
t[top++] = '=';
}
| {
/* generic command should be here
if any of the commands above were found it should run whatever is here*/
}
Attach the logic that you want to run after any command token has been recognized in a marker non-terminal, like the following. Notice that the right side of
marker‘s production doesn’t match any tokens.I have formulated my answer to match the comments in the code, which are somewhat at odds with the text of your question. If you want
commandto match anything, not justF,PLUS, etc., then you will have to spell out all of the tokens that your lexer can generate in productions forcommand. This is not necessarily a good idea, for several reasons.