diff libinterp/parse-tree/lex.h @ 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 0ecec070c086
children dff830c84726
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h	Thu Jul 16 16:02:45 2020 -0400
+++ b/libinterp/parse-tree/lex.h	Thu Jul 16 18:27:39 2020 -0400
@@ -661,7 +661,9 @@
 
     bool whitespace_is_significant (void);
 
-    int handle_number (bool imag);
+    // We only provide specializations with base equal to 2, 10, or 16.
+    template <int base>
+    int handle_number (void);
 
     void handle_continuation (void);
 
@@ -822,6 +824,10 @@
     bool m_initial_input;
   };
 
+  template <> int base_lexer::handle_number<2> ();
+  template <> int base_lexer::handle_number<10> ();
+  template <> int base_lexer::handle_number<16> ();
+
   class
   push_lexer : public base_lexer
   {