diff test/parser.tst @ 28583:96e7dc4c2214

improve Matlab compatibility for binary and hexadecimal constants * parser.tst: Update tests for new parsing rules for hex and binary integer literals. * lex.h, lex.ll (handle_number): Now a template with three specializations (binary, decimal, hexadecimal). Eliminate IMAG argument. (HANDLE_NUMBER): New macro. Use it to process binary, decimal, and hexadecimal constants with separate lexer patterns. (Im): Delete pattern macro. (EXPON, NUMBIN, NUMHEX, NUMREAL, NUMBER): Replace with DECIMAL_DIGITS, EXPONENT, REAL_DECIMAL, IMAG_DECIMAL, and DECIMAL_NUMBER for matching decimal numbers and SIZE_SUFFIX, BINARY_BITS, BINARY_NUMBER, HEXADECIMAL_BITS, and HEXADECIMAL_NUMBER for matching binary and hexadecimal numbers. ({NUMBER}{Im}): Delete rule. ({BINARY_NUMBER}, {HEXADECIMAL_NUMBER}): New rules. ({DECIMAL_DIGITS}/\.[\*/\\^\']|{DECIMAL_NUMBER}): New rule to replace {D}{D_}*/\.[\*/\\^\']|{NUMBER}. (make_integer_value): New static function. NEWS: Note change.
author John W. Eaton <jwe@octave.org>
date Thu, 16 Jul 2020 18:27:39 -0400
parents bd51beb6205e
children ec591c500fa4
line wrap: on
line diff
--- a/test/parser.tst	Thu Jul 16 16:02:45 2020 -0400
+++ b/test/parser.tst	Thu Jul 16 18:27:39 2020 -0400
@@ -286,19 +286,19 @@
 %!assert (123_456, 123456)
 %!assert (.123_456, .123456)
 %!assert (123_456.123_456, 123456.123456)
-%!assert (0xAB_CD, 43981)
+%!assert (0xAB_CD, uint16 (43981))
 %!assert (2e0_1, 20)
 
 ## Test binary constants
-%!assert (0b101, 5)
+%!assert (0b101, uint8 (5))
 %!assert (0B1100_0001, 0xC1)
-%!assert (class (0b1), "double")
+%!assert (class (0b1), "uint8")
 
 ## Test range of large binary and hexadecimal literals
-%!assert (0x8000_0000_0000_0000, 2^63)
-%!assert (0xFFFF_FFFF_FFFF_FFFF, 2^64)
-%!assert (0b10000000_0000000_000000000_00000000_00000000_00000000_00000000_00000000, 2^63)
-%!assert (0b11111111_1111111_111111111_11111111_11111111_11111111_11111111_11111111, 2^64)
+%!assert (0x8000_0000_0000_0000, uint64 (2^63))
+%!assert (0xFFFF_FFFF_FFFF_FFFF, uint64 (2^64))
+%!assert (0b10000000_0000000_000000000_00000000_00000000_00000000_00000000_00000000, uint64 (2^63))
+%!assert (0b11111111_1111111_111111111_11111111_11111111_11111111_11111111_11111111, uint64 (2^64))
 
 ## Test creation of anonymous functions