MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / yy_scan_buffer

Function yy_scan_buffer

src/parser/ds_lexer.cpp:4583–4610  ·  view source on GitHub ↗

Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */

Source from the content-addressed store, hash-verified

4581 * @return the newly allocated buffer state object.
4582 */
4583YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
4584{
4585 YY_BUFFER_STATE b;
4586
4587 if ( size < 2 ||
4588 base[size-2] != YY_END_OF_BUFFER_CHAR ||
4589 base[size-1] != YY_END_OF_BUFFER_CHAR )
4590 /* They forgot to leave room for the EOB's. */
4591 return NULL;
4592
4593 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
4594 if ( ! b )
4595 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
4596
4597 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
4598 b->yy_buf_pos = b->yy_ch_buf = base;
4599 b->yy_is_our_buffer = 0;
4600 b->yy_input_file = NULL;
4601 b->yy_n_chars = b->yy_buf_size;
4602 b->yy_is_interactive = 0;
4603 b->yy_at_bol = 1;
4604 b->yy_fill_buffer = 0;
4605 b->yy_buffer_status = YY_BUFFER_NEW;
4606
4607 yy_switch_to_buffer( b , yyscanner );
4608
4609 return b;
4610}
4611
4612/** Setup the input buffer state to scan a string. The next call to yylex() will
4613 * scan from a @e copy of @a str.

Callers 1

yy_scan_bytesFunction · 0.70

Calls 2

yyallocFunction · 0.70
yy_switch_to_bufferFunction · 0.70

Tested by

no test coverage detected