How do I get bison/flex to restart scanning after something like token substitution?
- by chucknelson
Is there a way to force bison and/or flex to restart scanning after I replace some token with something else?
My particular example would be with replacement for a specific word/string. If I want a word of hello to be replaced by echo hello, how can I get flex or bison to replace hello and then start parsing again (to pick up 2 words instead of just one). So it would be like:
Get token WORD (which is a string type)
If hello, replace token value with echo hello
Restart parsing entire input (which is now echo hello)
Get token WORD (echo)
Get token WORD (hello)
I've seen very tempting functions like yyrestart(), but I don't really understand what that function in particular really accomplishes. Any help is greatly appreciated, thanks!