mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 11:54:02 +00:00
Branches: main lexer.m tokenises "-INTEGER" as two tokens, a minus sign and a positive integer. This fails when the overall negative value is min_int, i.e. the absolute value is max_int+1 -- too big to store in an int. One less obvious consequence of the bug is that io.read could not parse some plain Mercury terms written out by io.write. library/lexer.m: Add a `token.big_integer' constructor to hold big integer literals in their string representation. Currently this is only done for base 10 literals which cannot fit in an int. library/parser.m: Parse the token sequence, minus sign followed by big_integer max_int+1, as the integer term with value min_int. tests/hard_coded/Mmakefile: tests/hard_coded/lexer_bigint.exp: tests/hard_coded/lexer_bigint.exp2: tests/hard_coded/lexer_bigint.inp: tests/hard_coded/lexer_bigint.m: tests/hard_coded/read_min_int.exp: tests/hard_coded/read_min_int.exp2: tests/hard_coded/read_min_int.inp: tests/hard_coded/read_min_int.m: Add test cases.
32 lines
449 B
Plaintext
32 lines
449 B
Plaintext
% 32-bit
|
|
|
|
2147483646
|
|
2147483647
|
|
2147483648
|
|
|
|
-2147483647
|
|
-2147483648
|
|
-2147483649
|
|
|
|
0b11111111111111111111111111111111
|
|
0o37777777777
|
|
0xffffffff
|
|
|
|
% 64-bit
|
|
|
|
9223372036854775807
|
|
9223372036854775808
|
|
9223372036854775809
|
|
|
|
-9223372036854775807
|
|
-9223372036854775808
|
|
-9223372036854775809
|
|
|
|
0b1111111111111111111111111111111111111111111111111111111111111111
|
|
0o1777777777777777777777
|
|
0xffffffffffffffff
|
|
|
|
% big integer everywhere
|
|
|
|
999999999999999999999999987654321
|