- /* check if there is already a copy of the string */
- result = strset_insert(&stringset, string);
- if(result != string) {
- obstack_free(&symbol_obstack, string);
+ lexer_token.kind = T_STRING_LITERAL;
+ lexer_token.string.string = identify_string(string, size);
+}
+
+/**
+ * Parse a wide character constant and set lexer_token.
+ */
+static void parse_wide_character_constant(void)
+{
+ eat('\'');
+
+ while (true) {
+ switch (c) {
+ case '\\': {
+ const utf32 tc = parse_escape_sequence();
+ obstack_grow_symbol(&symbol_obstack, tc);
+ break;
+ }
+
+ MATCH_NEWLINE(
+ parse_error("newline while parsing character constant");
+ break;
+ )
+
+ case '\'':
+ next_char();
+ goto end_of_wide_char_constant;
+
+ case EOF: {
+ errorf(&lexer_token.base.source_position,
+ "EOF while parsing character constant");
+ lexer_token.kind = T_ERROR;
+ return;
+ }
+
+ default:
+ obstack_grow_symbol(&symbol_obstack, c);
+ next_char();
+ break;
+ }
+ }
+
+end_of_wide_char_constant:;
+ obstack_1grow(&symbol_obstack, '\0');
+ size_t size = (size_t) obstack_object_size(&symbol_obstack) - 1;
+ char *string = obstack_finish(&symbol_obstack);
+
+ lexer_token.kind = T_WIDE_CHARACTER_CONSTANT;
+ lexer_token.string.string = identify_string(string, size);
+
+ if (size == 0) {
+ errorf(&lexer_token.base.source_position, "empty character constant");