Add octal support

This commit is contained in:
Jonathan Turner
2009-10-06 21:17:23 +00:00
parent 46fd7e9a58
commit ff177b5eaf

View File

@@ -244,9 +244,21 @@ namespace chaiscript
}
else {
std::string match(start, input_pos);
TokenPtr t(new Token(match, Token_Type::Int, filename, prev_line, prev_col, line, col));
match_stack.push_back(t);
return true;
if ((match.size() > 0) && (match[0] == '0')) {
std::stringstream ss(match);
int temp_int;
ss >> std::oct >> temp_int;
std::ostringstream out_int;
out_int << temp_int;
TokenPtr t(new Token(out_int.str(), Token_Type::Int, filename, prev_line, prev_col, line, col));
match_stack.push_back(t);
}
else {
TokenPtr t(new Token(match, Token_Type::Int, filename, prev_line, prev_col, line, col));
match_stack.push_back(t);
return true;
}
}
}
else {