diff options
author | John Hodge <tpg@mutabah.net> | 2015-03-18 22:13:17 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2015-03-18 22:13:17 +0800 |
commit | ca09043bcadaacd7256a9b5d60b2358434743da6 (patch) | |
tree | e731961dee9ff3a55a700ed9374681ab29c9c4ba /src/parse/lex.cpp | |
parent | 7c774049e8a539ee32923dfbf9ad0c0f36ab4323 (diff) | |
download | mrust-ca09043bcadaacd7256a9b5d60b2358434743da6.tar.gz |
super path in expr, byte literals, while disallow struct, todo struct match
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 |