// Process a triple quoted string, the leading """ of which has been seen, but // not consumed static token_t* triple_string(lexer_t* lexer) { consume_chars(lexer, 3); // Leading """ while(true) { if(is_eof(lexer)) return literal_doesnt_terminate(lexer); char c = look(lexer); if((c == '\"') && (lookn(lexer, 2) == '\"') && (lookn(lexer, 3) == '\"')) { consume_chars(lexer, 3); // Triple strings can end with 3 or more "s. If there are more than 3 // the extra ones are part of the string contents while(look(lexer) == '\"') { append_to_token(lexer, '\"'); consume_chars(lexer, 1); } normalise_string(lexer); return make_token_with_text(lexer, TK_STRING); } consume_chars(lexer, 1); append_to_token(lexer, c); } }
// Process a triple quoted string, the leading """ of which has been seen, but // not consumed static token_t* triple_string(lexer_t* lexer) { consume_chars(lexer, 3); // Leading """ while(true) { if(is_eof(lexer)) return literal_doesnt_terminate(lexer); char c = look(lexer); if((c == '\"') && (lookn(lexer, 2) == '\"') && (lookn(lexer, 3) == '\"')) { consume_chars(lexer, 3); normalise_string(lexer); return make_token_with_text(lexer, TK_STRING); } consume_chars(lexer, 1); append_to_token(lexer, c); } }