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