Skip to content

Commit d93db0f

Browse files
committed
Fix integer literals with value zero and explicit base
1 parent 153bff0 commit d93db0f

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

rezparser/parser.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ def p_intlit(self, p):
133133

134134
if p[1].startswith("'"):
135135
value = int.from_bytes(_unescape_string(p[1][1:-1]), "big")
136-
elif p[1].startswith("$") or p[1].startswith("0X") or p[1].startswith("0x"):
137-
value = int(p[1].lstrip("$0Xx"), 16)
136+
elif p[1].startswith("$"):
137+
value = int(p[1][1:], 16)
138+
elif p[1].startswith("0X") or p[1].startswith("0x"):
139+
value = int(p[1][2:], 16)
138140
elif p[1].startswith("0B") or p[1].startswith("0b"):
139-
value = int(p[1].lstrip("0Bb"), 2)
141+
value = int(p[1][2:], 2)
140142
elif p[1].startswith("0"):
141143
value = int(p[1], 8)
142144
else:

test/DGTest.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ resource '_FOO' (2) {
197197
},
198198
"",
199199
8,
200-
0,
200+
0b0 + 0B0 + $0 + 0x0 + 0X0,
201201
$""
202202
};
203203

0 commit comments

Comments
 (0)