summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-02-25 17:15:33 +0800
committerJohn Hodge <tpg@mutabah.net>2016-02-25 17:15:33 +0800
commit34312f9f8e7d281ca13792e79b46b88ac9f46d48 (patch)
tree280a47589fda86eaac7af90a9205d0d6e08876b3 /src
parent181291917323dc8412e4ca28d5ada992d359e15f (diff)
downloadmrust-34312f9f8e7d281ca13792e79b46b88ac9f46d48.tar.gz
Lex - Handle octal literals
Diffstat (limited to 'src')
-rw-r--r--src/parse/lex.cpp16
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 {