diff --git a/src/cc65/expr.c b/src/cc65/expr.c index dbcddd4f9..f3003507a 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -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; diff --git a/src/cc65/ppexpr.c b/src/cc65/ppexpr.c index 788fb27d5..dd129ced9 100644 --- a/src/cc65/ppexpr.c +++ b/src/cc65/ppexpr.c @@ -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 diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 11d356281..ebdcdb33e 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -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 */ diff --git a/src/cc65/scanner.h b/src/cc65/scanner.h index c47d660d5..7a67b10ed 100644 --- a/src/cc65/scanner.h +++ b/src/cc65/scanner.h @@ -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,