MCPcopy Create free account
hub / github.com/Gecode/gecode / yy_scan_buffer

Function yy_scan_buffer

gecode/flatzinc/lexer.yy.cpp:2069–2096  ·  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

2067 * @return the newly allocated buffer state object.
2068 */
2069YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
2070{
2071 YY_BUFFER_STATE b;
2072
2073 if ( size < 2 ||
2074 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2075 base[size-1] != YY_END_OF_BUFFER_CHAR )
2076 /* They forgot to leave room for the EOB's. */
2077 return NULL;
2078
2079 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2080 if ( ! b )
2081 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2082
2083 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
2084 b->yy_buf_pos = b->yy_ch_buf = base;
2085 b->yy_is_our_buffer = 0;
2086 b->yy_input_file = NULL;
2087 b->yy_n_chars = b->yy_buf_size;
2088 b->yy_is_interactive = 0;
2089 b->yy_at_bol = 1;
2090 b->yy_fill_buffer = 0;
2091 b->yy_buffer_status = YY_BUFFER_NEW;
2092
2093 yy_switch_to_buffer( b , yyscanner );
2094
2095 return b;
2096}
2097
2098/** Setup the input buffer state to scan a string. The next call to yylex() will
2099 * scan from a @e copy of @a str.

Callers 1

yy_scan_bytesFunction · 0.85

Calls 2

yyallocFunction · 0.85
yy_switch_to_bufferFunction · 0.85

Tested by

no test coverage detected