Search code examples
cparsingyacclexlexer

Clear buffers before calling YYACCEPT in yacc/lex


Is there any way to clear parser buffers before calling YYACCEPT in yacc.

If i do not clear buffer it causes some problems when i call yyparse for the second time.

Also note that I am using some global variables, so cannot use reentrant parser.

Thanks in advance !!


Solution

  • There sure is. See this section of the flex manual. Specifically, call YY_FLUSH_BUFFER before calling yyparse.