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

Function yy_scan_buffer

src/parser/ds2_lexer.cpp:4150–4177  ·  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

4148 * @return the newly allocated buffer state object.
4149 */
4150YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
4151{
4152 YY_BUFFER_STATE b;
4153
4154 if ( size < 2 ||
4155 base[size-2] != YY_END_OF_BUFFER_CHAR ||
4156 base[size-1] != YY_END_OF_BUFFER_CHAR )
4157 /* They forgot to leave room for the EOB's. */
4158 return NULL;
4159
4160 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
4161 if ( ! b )
4162 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
4163
4164 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
4165 b->yy_buf_pos = b->yy_ch_buf = base;
4166 b->yy_is_our_buffer = 0;
4167 b->yy_input_file = NULL;
4168 b->yy_n_chars = b->yy_buf_size;
4169 b->yy_is_interactive = 0;
4170 b->yy_at_bol = 1;
4171 b->yy_fill_buffer = 0;
4172 b->yy_buffer_status = YY_BUFFER_NEW;
4173
4174 yy_switch_to_buffer( b , yyscanner );
4175
4176 return b;
4177}
4178
4179/** Setup the input buffer state to scan a string. The next call to yylex() will
4180 * 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