- {
- token->type = SCAN_BAD_UNICODE_CODE_POINT;
- token->number = uc;
- return 0;
- }
-
- dst = CHAR_CAST (uint8_t *, ss_end (token->string));
- token->string.length += u8_uctomb (dst, uc, 4);
-
- return true;
-}
-
-static enum scan_result
-scan_string_segment__ (struct scanner *scanner, enum segment_type type,
- struct substring s, struct token *token)
-{
- bool ok;
-
- switch (type)
- {
- case SEG_QUOTED_STRING:
- ok = scan_quoted_string__ (s, token);
- break;
-
- case SEG_HEX_STRING:
- ok = scan_hex_string__ (s, token);
- break;
-
- case SEG_UNICODE_STRING:
- ok = scan_unicode_string__ (s, token);
- break;
-
- default:
- NOT_REACHED ();
- }
-
- if (ok)
- {
- token->type = T_STRING;
- token->string.string[token->string.length] = '\0';
- scanner->state = S_STRING;
- scanner->substate = 0;
- return SCAN_SAVE;
- }
- else
- {
- /* The function we called above should have filled in token->type and
- token->number properly to describe the error. */
- ss_dealloc (&token->string);
- token->string = ss_empty ();
- return SCAN_DONE;
- }
-
-}
-
-static enum scan_result
-add_bit (struct scanner *scanner, unsigned int bit)
-{
- if (!(scanner->substate & bit))
- {
- scanner->substate |= bit;
- return SCAN_MORE;
- }
- else
- return SCAN_BACK;
-}
-
-static enum scan_result
-scan_string__ (struct scanner *scanner, enum segment_type type,
- struct substring s, struct token *token)
-{
- switch (type)
- {
- case SEG_SPACES:
- case SEG_COMMENT:
- return SCAN_MORE;
-
- case SEG_NEWLINE:
- if (scanner->substate & SS_PLUS)
- return add_bit (scanner, SS_NL_AFTER_PLUS);
- else
- return add_bit (scanner, SS_NL_BEFORE_PLUS);