1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-29 02:55:20 +00:00

Added wide char literals, but treat them identical as normal strings.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4185 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-09-18 14:28:52 +00:00
parent 65ca052303
commit b5db4cd5fa
4 changed files with 47 additions and 22 deletions

View File

@ -1758,8 +1758,9 @@ static unsigned ParseArrayInit (Type* T, int AllowFlexibleMembers)
/* Special handling for a character array initialized by a literal */
if (IsTypeChar (ElementType) &&
(CurTok.Tok == TOK_SCONST ||
(CurTok.Tok == TOK_LCURLY && NextTok.Tok == TOK_SCONST))) {
(CurTok.Tok == TOK_SCONST || CurTok.Tok == TOK_WCSCONST ||
(CurTok.Tok == TOK_LCURLY &&
(NextTok.Tok == TOK_SCONST || NextTok.Tok == TOK_WCSCONST)))) {
/* Char array initialized by string constant */
int NeedParen;

View File

@ -740,6 +740,7 @@ static void Primary (ExprDesc* E)
break;
case TOK_SCONST:
case TOK_WCSCONST:
/* String literal */
E->Type = GetCharArrayType (GetLiteralPoolOffs () - CurTok.IVal);
E->Flags = E_LOC_LITERAL | E_RTYPE_RVAL;

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2008 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* (C) 1998-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -410,21 +410,36 @@ static void StringConst (void)
NextTok.IVal = GetLiteralPoolOffs ();
NextTok.Tok = TOK_SCONST;
/* Be sure to concatenate strings */
while (CurC == '\"') {
/* Concatenate strings. If at least one of the concenated strings is a wide
* character literal, the whole string is a wide char literal, otherwise
* it's a normal string literal.
*/
while (1) {
/* Skip the quote char */
NextChar ();
/* Check if this is a normal or a wide char string */
if (CurC == 'L' && NextC == '\"') {
/* Wide character literal */
NextTok.Tok = TOK_WCSCONST;
NextChar ();
NextChar ();
} else if (CurC == '\"') {
/* Skip the quote char */
NextChar ();
} else {
/* No string */
break;
}
while (CurC != '\"') {
if (CurC == '\0') {
Error ("Unexpected newline");
break;
}
AddLiteralChar (ParseChar ());
}
/* Read until end of string */
while (CurC != '\"') {
if (CurC == '\0') {
Error ("Unexpected newline");
break;
}
AddLiteralChar (ParseChar ());
}
/* Skip closing quote char if there was one */
/* Skip closing quote char if there was one */
NextChar ();
/* Skip white space, read new input */
@ -718,6 +733,13 @@ void NextToken (void)
return;
}
/* Check for wide character literals */
if (CurC == 'L' && NextC == '\"') {
StringConst ();
return;
}
/* Check for keywords and identifiers */
if (IsSym (token)) {
/* Check for a keyword */

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2004 Ullrich von Bassewitz */
/* Römerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* (C) 1998-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -169,6 +169,7 @@ typedef enum token_t {
TOK_ICONST,
TOK_CCONST,
TOK_FCONST,
TOK_WCSCONST,
TOK_ATTRIBUTE,
TOK_FAR,