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:
parent
65ca052303
commit
b5db4cd5fa
@ -1758,8 +1758,9 @@ static unsigned ParseArrayInit (Type* T, int AllowFlexibleMembers)
|
|||||||
|
|
||||||
/* Special handling for a character array initialized by a literal */
|
/* Special handling for a character array initialized by a literal */
|
||||||
if (IsTypeChar (ElementType) &&
|
if (IsTypeChar (ElementType) &&
|
||||||
(CurTok.Tok == TOK_SCONST ||
|
(CurTok.Tok == TOK_SCONST || CurTok.Tok == TOK_WCSCONST ||
|
||||||
(CurTok.Tok == TOK_LCURLY && NextTok.Tok == TOK_SCONST))) {
|
(CurTok.Tok == TOK_LCURLY &&
|
||||||
|
(NextTok.Tok == TOK_SCONST || NextTok.Tok == TOK_WCSCONST)))) {
|
||||||
|
|
||||||
/* Char array initialized by string constant */
|
/* Char array initialized by string constant */
|
||||||
int NeedParen;
|
int NeedParen;
|
||||||
|
@ -740,6 +740,7 @@ static void Primary (ExprDesc* E)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_SCONST:
|
case TOK_SCONST:
|
||||||
|
case TOK_WCSCONST:
|
||||||
/* String literal */
|
/* String literal */
|
||||||
E->Type = GetCharArrayType (GetLiteralPoolOffs () - CurTok.IVal);
|
E->Type = GetCharArrayType (GetLiteralPoolOffs () - CurTok.IVal);
|
||||||
E->Flags = E_LOC_LITERAL | E_RTYPE_RVAL;
|
E->Flags = E_LOC_LITERAL | E_RTYPE_RVAL;
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2008 Ullrich von Bassewitz */
|
/* (C) 1998-2009, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -410,21 +410,36 @@ static void StringConst (void)
|
|||||||
NextTok.IVal = GetLiteralPoolOffs ();
|
NextTok.IVal = GetLiteralPoolOffs ();
|
||||||
NextTok.Tok = TOK_SCONST;
|
NextTok.Tok = TOK_SCONST;
|
||||||
|
|
||||||
/* Be sure to concatenate strings */
|
/* Concatenate strings. If at least one of the concenated strings is a wide
|
||||||
while (CurC == '\"') {
|
* character literal, the whole string is a wide char literal, otherwise
|
||||||
|
* it's a normal string literal.
|
||||||
|
*/
|
||||||
|
while (1) {
|
||||||
|
|
||||||
/* Skip the quote char */
|
/* Check if this is a normal or a wide char string */
|
||||||
NextChar ();
|
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 != '\"') {
|
/* Read until end of string */
|
||||||
if (CurC == '\0') {
|
while (CurC != '\"') {
|
||||||
Error ("Unexpected newline");
|
if (CurC == '\0') {
|
||||||
break;
|
Error ("Unexpected newline");
|
||||||
}
|
break;
|
||||||
AddLiteralChar (ParseChar ());
|
}
|
||||||
}
|
AddLiteralChar (ParseChar ());
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip closing quote char if there was one */
|
/* Skip closing quote char if there was one */
|
||||||
NextChar ();
|
NextChar ();
|
||||||
|
|
||||||
/* Skip white space, read new input */
|
/* Skip white space, read new input */
|
||||||
@ -718,6 +733,13 @@ void NextToken (void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for wide character literals */
|
||||||
|
if (CurC == 'L' && NextC == '\"') {
|
||||||
|
StringConst ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for keywords and identifiers */
|
||||||
if (IsSym (token)) {
|
if (IsSym (token)) {
|
||||||
|
|
||||||
/* Check for a keyword */
|
/* Check for a keyword */
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2004 Ullrich von Bassewitz */
|
/* (C) 1998-2009, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -169,6 +169,7 @@ typedef enum token_t {
|
|||||||
TOK_ICONST,
|
TOK_ICONST,
|
||||||
TOK_CCONST,
|
TOK_CCONST,
|
||||||
TOK_FCONST,
|
TOK_FCONST,
|
||||||
|
TOK_WCSCONST,
|
||||||
|
|
||||||
TOK_ATTRIBUTE,
|
TOK_ATTRIBUTE,
|
||||||
TOK_FAR,
|
TOK_FAR,
|
||||||
|
Loading…
Reference in New Issue
Block a user