]> git.corax.cc Git - ccc/commitdiff
lex: Return wide strings and wide character literals as one token
authorMatthias Kruk <m@m10k.eu>
Sun, 5 Jul 2020 05:38:07 +0000 (14:38 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 5 Jul 2020 05:38:07 +0000 (14:38 +0900)
src/lex.c

index d2bc345a79e6c60621c360400a1708ba05a749fd..83f71b69d0b6f67d0bb797e6fcf8230e75cae2b1 100644 (file)
--- a/src/lex.c
+++ b/src/lex.c
@@ -500,6 +500,16 @@ struct token *_nexttoken(void)
                case STATE_ID:
                        if(identifier_chr(c)) {
                                token_append_char(tok, c);
+                       } else if(c == '\'' && token_cmp(tok, "L") == 0) {
+                               /* token is a wide character literal */
+                               token_append_char(tok, c);
+                               tok->type = TOKEN_CHAR_LITERAL;
+                               state = STATE_CHR;
+                       } else if(c == '"' && token_cmp(tok, "L") == 0) {
+                               /* token is a wide string literal */
+                               token_append_char(tok, c);
+                               tok->type = TOKEN_STRING;
+                               state = STATE_STRING;
                        } else {
                                _putnextchar(c);
                                _identify_token(tok);