mirror of
https://github.com/ksherlock/mpw.git
synced 2024-09-28 01:54:33 +00:00
0b binary numbers in debugger
This commit is contained in:
parent
e1e3f3f4a2
commit
6b383a0e35
19
bin/lexer.rl
19
bin/lexer.rl
@ -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)
|
uint32_t scancc(const char *begin, const char *end)
|
||||||
{
|
{
|
||||||
return std::accumulate(begin, end, 0,
|
return std::accumulate(begin, end, 0,
|
||||||
@ -121,13 +129,20 @@ namespace {
|
|||||||
'@' { Parse(parser, tkAT, 0, command); };
|
'@' { Parse(parser, tkAT, 0, command); };
|
||||||
|
|
||||||
|
|
||||||
|
'$' xdigit + {
|
||||||
|
uint32_t value = scan16(ts + 1, te);
|
||||||
|
Parse(parser, tkINTEGER, value, command);
|
||||||
|
};
|
||||||
|
|
||||||
'0x'i xdigit+ {
|
'0x'i xdigit+ {
|
||||||
|
// hexadecimal
|
||||||
uint32_t value = scan16(ts + 2, te);
|
uint32_t value = scan16(ts + 2, te);
|
||||||
Parse(parser, tkINTEGER, value, command);
|
Parse(parser, tkINTEGER, value, command);
|
||||||
};
|
};
|
||||||
|
|
||||||
'$' xdigit + {
|
'0b'i [01]+ {
|
||||||
uint32_t value = scan16(ts + 1, te);
|
// binary
|
||||||
|
uint32_t value = scan2(ts + 2, te);
|
||||||
Parse(parser, tkINTEGER, value, command);
|
Parse(parser, tkINTEGER, value, command);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user