MCPcopy Create free account
hub / github.com/boostorg/build / balance_parentheses

Function balance_parentheses

src/engine/function.cpp:2384–2416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2382 */
2383
2384void balance_parentheses( char const * * s_, char const * * string,
2385 VAR_PARSE_GROUP * out)
2386{
2387 int32_t depth = 1;
2388 char const * s = *s_;
2389 for ( ; ; )
2390 {
2391 if ( try_parse_variable( &s, string, out ) ) { }
2392 else if ( s[ 0 ] == ':' || s[ 0 ] == '[' )
2393 {
2394 parse_error( "unbalanced parentheses" );
2395 ++s;
2396 }
2397 else if ( s[ 0 ] == '\0' )
2398 {
2399 parse_error( "unbalanced parentheses" );
2400 break;
2401 }
2402 else if ( s[ 0 ] == ')' )
2403 {
2404 ++s;
2405 if ( --depth == 0 ) break;
2406 }
2407 else if ( s[ 0 ] == '(' )
2408 {
2409 ++depth;
2410 ++s;
2411 }
2412 else
2413 ++s;
2414 }
2415 *s_ = s;
2416}
2417
2418
2419/*

Callers 1

parse_variableFunction · 0.85

Calls 2

try_parse_variableFunction · 0.85
parse_errorFunction · 0.85

Tested by

no test coverage detected