diff options
Diffstat (limited to 'src/parse/lex.cpp')
-rw-r--r-- | src/parse/lex.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index 1e5fb1cf..648792e9 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -393,6 +393,22 @@ Token Lexer::getTokenInt() } else { + if( str == "b" && ch == '\'' ) { + // Byte constant + ch = this->getc(); + if( ch == '\\' ) { + uint32_t val = this->parseEscape('\''); + if( this->getc() != '\'' ) + throw ParseError::Generic(*this, "Multi-byte character literal"); + return Token((uint64_t)val, CORETYPE_U8); + } + else { + if( this->getc() != '\'' ) + throw ParseError::Generic(*this, "Multi-byte character literal"); + return Token((uint64_t)ch, CORETYPE_U8); + } + } + this->ungetc(); for( unsigned int i = 0; i < LEN(RWORDS); i ++ ) { @@ -445,7 +461,7 @@ Token Lexer::getTokenInt() ch = this->getc(); if( ch == '\'' ) { // Character constant - return Token((uint64_t)ch, CORETYPE_CHAR); + return Token((uint64_t)firstchar, CORETYPE_CHAR); } else { // Lifetime name |