/* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } #ifdef Q_WS_WIN32 b->yy_is_interactive = false; #else b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif errno = oerrno; }
TEST(BisonFlexTest, Test0009) { FileHolder holder("./Resources/Example0009.titan"); GTEST_ASSERT_NE((void*)0, holder.f); BufferStateHolder bp(yy_create_buffer(holder.f, YY_BUF_SIZE)); yy_switch_to_buffer(bp.bp); int ans = yyparse(); yy_flush_buffer(bp.bp); GTEST_ASSERT_EQ(0, ans); }
void CppScanner::Reset() { if(m_data) { free(m_data); m_data = NULL; m_pcurr = NULL; m_curr = 0; } // Notify lex to restart its buffer yy_flush_buffer(yy_current_buffer); m_comment = wxEmptyString; yylineno = 1; }