diff options
Diffstat (limited to 'src/parse/lex.cpp')
-rw-r--r-- | src/parse/lex.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index 17eb4f30..4237b48f 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -240,7 +240,7 @@ Token Lexer::getToken() ch = this->getc(); if( ch == 'x' ) { num_mode = HEX; - while( isxdigit(ch = this->getc()) ) + while( isxdigit(ch = this->getc_num()) ) { val *= 16; if(ch <= '9') @@ -253,7 +253,16 @@ Token Lexer::getToken() } else if( ch == 'b' ) { num_mode = BIN; - throw ParseError::Todo("Lex binary numbers"); + while( isdigit(ch = this->getc_num()) ) + { + val *= 2; + if(ch == '0') + val += 0; + else if( ch == '1' ) + val += 1; + else + throw ParseError::Generic("Invalid digit in binary literal"); + } } else if( isdigit(ch) ) { num_mode = OCT; @@ -487,6 +496,7 @@ uint32_t Lexer::parseEscape(char enclosing) char ch = this->getc(); switch(ch) { + case 'x': case 'u': { // Unicode (up to six hex digits) uint32_t val = 0; |