diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/parse/lex.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index 260ca319..1e0e0712 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -308,13 +308,23 @@ Token Lexer::getTokenInt() throw ParseError::Generic("Invalid digit in binary literal"); } } - else if( isdigit(ch) ) { + else if( ch == 'o' ) { num_mode = OCT; - throw ParseError::Todo(*this, "Lex octal numbers"); + while( isdigit(ch = this->getc_num()) ) { + val *= 8; + if('0' <= ch && ch <= '7') + val += ch - '0'; + else + throw ParseError::Generic("Invalid digit in octal literal"); + } } else { num_mode = DEC; - val = 0; + while( isdigit(ch) ) { + val *= 10; + val += ch - '0'; + ch = this->getc_num(); + } } } else { |