0b binary numbers in debugger

This commit is contained in:
Kelvin Sherlock 2013-08-02 14:00:57 -04:00
parent e1e3f3f4a2
commit 6b383a0e35
1 changed files with 17 additions and 2 deletions

View File

@ -66,6 +66,14 @@ namespace {
});
}
uint32_t scan2(const char *begin, const char *end)
{
return std::accumulate(begin, end, 0,
[](uint32_t value, char c){
return (value << 1) + (c & 0x01);
});
}
uint32_t scancc(const char *begin, const char *end)
{
return std::accumulate(begin, end, 0,
@ -121,13 +129,20 @@ namespace {
'@' { Parse(parser, tkAT, 0, command); };
'$' xdigit + {
uint32_t value = scan16(ts + 1, te);
Parse(parser, tkINTEGER, value, command);
};
'0x'i xdigit+ {
// hexadecimal
uint32_t value = scan16(ts + 2, te);
Parse(parser, tkINTEGER, value, command);
};
'$' xdigit + {
uint32_t value = scan16(ts + 1, te);
'0b'i [01]+ {
// binary
uint32_t value = scan2(ts + 2, te);
Parse(parser, tkINTEGER, value, command);
};