Character constants now work
git-svn-id: http://picoc.googlecode.com/svn/trunk@102 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
e94767ba98
commit
37c2364eff
11
lex.c
11
lex.c
|
@ -7,7 +7,10 @@
|
|||
|
||||
#include "picoc.h"
|
||||
|
||||
|
||||
#ifndef isalpha
|
||||
#define isalpha(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
|
||||
#define isalnum(c) (isalpha(c) || ((c) >= '0' && (c) <= '9'))
|
||||
#endif
|
||||
#define isCidstart(c) (isalpha(c) || (c)=='_' || (c)=='#')
|
||||
#define isCident(c) (isalnum(c) || (c)=='_')
|
||||
|
||||
|
@ -229,9 +232,8 @@ enum LexToken LexGetStringConstant(struct LexState *Lexer, struct Value *Value)
|
|||
enum LexToken LexGetCharacterConstant(struct LexState *Lexer, struct Value *Value)
|
||||
{
|
||||
Value->Typ = &IntType;
|
||||
Lexer->Pos++;
|
||||
Value->Val->Integer = LexUnEscapeCharacter(&Lexer->Pos, Lexer->End);
|
||||
if (Lexer->Pos != Lexer->End || *Lexer->Pos != '\'')
|
||||
if (Lexer->Pos != Lexer->End && *Lexer->Pos != '\'')
|
||||
LexFail(Lexer, "expected \"'\"");
|
||||
|
||||
Lexer->Pos++;
|
||||
|
@ -443,8 +445,7 @@ enum LexToken LexGetToken(struct ParseState *Parser, struct Value **Value, int I
|
|||
{
|
||||
case TokenStringConstant: LexValue.Typ = CharPtrType; break;
|
||||
case TokenIdentifier: LexValue.Typ = NULL; break;
|
||||
case TokenIntegerConstant: LexValue.Typ = &IntType; break;
|
||||
case TokenCharacterConstant: LexValue.Typ = &CharType; break;
|
||||
case TokenIntegerConstant: case TokenCharacterConstant: LexValue.Typ = &IntType; break;
|
||||
#ifndef NO_FP
|
||||
case TokenFPConstant: LexValue.Typ = &FPType; break;
|
||||
#endif
|
||||
|
|
|
@ -5,4 +5,5 @@ for (Count = -5; Count <= 5; Count++)
|
|||
printf("Count = %d\n", Count);
|
||||
|
||||
printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there");
|
||||
//printf("Character 'a' is '%c'\n", 65);
|
||||
printf("Character 'A' is '%c'\n", 65);
|
||||
printf("Character 'a' is '%c'\n", 'a');
|
||||
|
|
|
@ -11,3 +11,5 @@ Count = 3
|
|||
Count = 4
|
||||
Count = 5
|
||||
String 'hello', 'there' is 'hello', 'there'
|
||||
Character 'A' is 'A'
|
||||
Character 'a' is 'a'
|
||||
|
|
Loading…
Reference in a new issue