mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-25 19:30:50 +00:00
loadtrap.rl -- negative number support (for error numbers)
This commit is contained in:
parent
ff84c1d3f1
commit
4b4122bee2
@ -45,6 +45,9 @@ namespace {
|
|||||||
|
|
|
|
||||||
'$' xdigit+ @addx
|
'$' xdigit+ @addx
|
||||||
|
|
|
|
||||||
|
'-'? @{ negative = true; }
|
||||||
|
digit+ @{value = value * 10 + (fc - '0'); }
|
||||||
|
|
|
||||||
[A-Za-z_] @{ stringValue.push_back(fc); }
|
[A-Za-z_] @{ stringValue.push_back(fc); }
|
||||||
[A-Za-z0-9_]+ @{ stringValue.push_back(fc); }
|
[A-Za-z0-9_]+ @{ stringValue.push_back(fc); }
|
||||||
;
|
;
|
||||||
@ -79,6 +82,7 @@ namespace {
|
|||||||
std::string name;
|
std::string name;
|
||||||
std::string stringValue;
|
std::string stringValue;
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
bool negative = false;
|
||||||
|
|
||||||
value = 0;
|
value = 0;
|
||||||
const char *eof = pe;
|
const char *eof = pe;
|
||||||
@ -91,6 +95,7 @@ namespace {
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (negative) value = (-value) & 0xffff;
|
||||||
|
|
||||||
// name lookup
|
// name lookup
|
||||||
if (!stringValue.empty())
|
if (!stringValue.empty())
|
||||||
@ -104,12 +109,14 @@ namespace {
|
|||||||
value = iter->second;
|
value = iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// if loading globals, wouldn't need to do this...
|
// if loading globals, wouldn't need to do this...
|
||||||
if (value > 0xafff || value < 0xa000)
|
if (value > 0xafff || value < 0xa000)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid trap number: $%04x\n", value);
|
fprintf(stderr, "Invalid trap number: $%04x\n", value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
map.emplace(name, (uint16_t)value);
|
map.emplace(name, (uint16_t)value);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user