account for more patterns in IntegerLiteral.getValue

This commit is contained in:
Alex Ford
2021-04-29 17:02:54 +01:00
parent 35d5bae10e
commit 05adfec03d

View File

@@ -51,15 +51,23 @@ class IntegerLiteral extends NumericLiteral, TIntegerLiteral {
exists(string s, string values, string str |
s = this.getValueText() and
(
s.matches("0b%") and values = "01" and str = s.suffix(2)
(s.matches("0b%") or s.matches("0B%")) and
values = "01" and
str = s.suffix(2)
or
s.matches("0x%") and values = "0123456789abcdef" and str = s.suffix(2)
(s.matches("0x%") or s.matches("0X%")) and
values = "0123456789abcdef" and
str = s.suffix(2)
or
s.charAt(0) = "0" and
not s.charAt(1) = ["b", "x"] and
not s.charAt(1) = ["b", "B", "x", "X"] and
values = "01234567" and
str = s.suffix(1)
or
(s.matches("0o%") or s.matches("0O%")) and
values = "01234567" and
str = s.suffix(2)
or
s.charAt(0) != "0" and values = "0123456789" and str = s
)
|