mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 06:25:17 +00:00
Fixed parsing wide char constants.
This commit is contained in:
@@ -1234,6 +1234,7 @@ static void Primary (ExprDesc* E)
|
|||||||
|
|
||||||
case TOK_ICONST:
|
case TOK_ICONST:
|
||||||
case TOK_CCONST:
|
case TOK_CCONST:
|
||||||
|
case TOK_WCCONST:
|
||||||
/* Character and integer constants */
|
/* Character and integer constants */
|
||||||
E->IVal = CurTok.IVal;
|
E->IVal = CurTok.IVal;
|
||||||
E->Flags = E_LOC_NONE | E_RTYPE_RVAL;
|
E->Flags = E_LOC_NONE | E_RTYPE_RVAL;
|
||||||
|
@@ -114,6 +114,7 @@ static void PPhiePrimary (PPExpr* Expr)
|
|||||||
switch (CurTok.Tok) {
|
switch (CurTok.Tok) {
|
||||||
case TOK_ICONST:
|
case TOK_ICONST:
|
||||||
case TOK_CCONST:
|
case TOK_CCONST:
|
||||||
|
case TOK_WCCONST:
|
||||||
/* Character and integer constants */
|
/* Character and integer constants */
|
||||||
Expr->IVal = CurTok.IVal;
|
Expr->IVal = CurTok.IVal;
|
||||||
/* According to the C standard, all signed types act as intmax_t
|
/* According to the C standard, all signed types act as intmax_t
|
||||||
|
@@ -412,6 +412,15 @@ static void CharConst (void)
|
|||||||
{
|
{
|
||||||
int C;
|
int C;
|
||||||
|
|
||||||
|
if (CurC == 'L') {
|
||||||
|
/* Wide character constant */
|
||||||
|
NextTok.Tok = TOK_WCCONST;
|
||||||
|
NextChar ();
|
||||||
|
} else {
|
||||||
|
/* Narrow character constant */
|
||||||
|
NextTok.Tok = TOK_CCONST;
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip the quote */
|
/* Skip the quote */
|
||||||
NextChar ();
|
NextChar ();
|
||||||
|
|
||||||
@@ -426,9 +435,6 @@ static void CharConst (void)
|
|||||||
NextChar ();
|
NextChar ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup values and attributes */
|
|
||||||
NextTok.Tok = TOK_CCONST;
|
|
||||||
|
|
||||||
/* Translate into target charset */
|
/* Translate into target charset */
|
||||||
NextTok.IVal = SignExtendChar (TgtTranslateChar (C));
|
NextTok.IVal = SignExtendChar (TgtTranslateChar (C));
|
||||||
|
|
||||||
@@ -804,10 +810,15 @@ void NextToken (void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for wide character literals */
|
/* Check for wide character constants and literals */
|
||||||
if (CurC == 'L' && NextC == '\"') {
|
if (CurC == 'L') {
|
||||||
StringConst ();
|
if (NextC == '\"') {
|
||||||
return;
|
StringConst ();
|
||||||
|
return;
|
||||||
|
} else if (NextC == '\'') {
|
||||||
|
CharConst ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for keywords and identifiers */
|
/* Check for keywords and identifiers */
|
||||||
|
@@ -182,10 +182,11 @@ typedef enum token_t {
|
|||||||
TOK_LAST_PUNC = TOK_DOUBLE_HASH,
|
TOK_LAST_PUNC = TOK_DOUBLE_HASH,
|
||||||
|
|
||||||
/* Primary expressions */
|
/* Primary expressions */
|
||||||
TOK_SCONST,
|
|
||||||
TOK_ICONST,
|
TOK_ICONST,
|
||||||
TOK_CCONST,
|
TOK_CCONST,
|
||||||
|
TOK_WCCONST,
|
||||||
TOK_FCONST,
|
TOK_FCONST,
|
||||||
|
TOK_SCONST,
|
||||||
TOK_WCSCONST,
|
TOK_WCSCONST,
|
||||||
TOK_IDENT,
|
TOK_IDENT,
|
||||||
TOK_A,
|
TOK_A,
|
||||||
|
Reference in New Issue
Block a user