void parse_string_as_argument_list(caValue* str, List* output) { // Read the tokens as a space-seperated list of strings. // TODO is to be more smart about word boundaries: spaces inside // quotes or parentheses shouldn't break apart items. TokenStream tokens; tokens.reset(as_cstring(str)); Value itemInProgress; set_string(&itemInProgress, ""); while (!tokens.finished()) { if (tokens.nextIs(tok_Whitespace)) { if (!equals_string(&itemInProgress, "")) { copy(&itemInProgress, list_append(output)); set_string(&itemInProgress, ""); } } else { string_append(&itemInProgress, tokens.nextStr().c_str()); } tokens.consume(); } if (!equals_string(&itemInProgress, "")) { copy(&itemInProgress, list_append(output)); set_string(&itemInProgress, ""); } }
void TPpContext::pushTokenStreamInput(TokenStream& ts, bool prepasting) { pushInput(new tTokenInput(this, &ts, prepasting)); ts.reset(); }