changeset 30320:c41fec3367b0

new lexer utility function, warn_deprecated_syntax * lex.h, lex.ll (base_lexer::warn_deprecated_syntax): New function. (<DQ_STRING_START>(\.\.\.){S}*{NL}): Use it. (<DQ_STRING_START>\\{S}+{NL}): Likewise. (\\{S}*{NL}|\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}): Likewise.
author John W. Eaton <jwe@octave.org>
date Mon, 22 Nov 2021 15:41:42 -0500
parents a12b5a32f94b
children 2ba4758654ca
files libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll
diffstat 2 files changed, 16 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h	Mon Nov 22 16:41:21 2021 +0100
+++ b/libinterp/parse-tree/lex.h	Mon Nov 22 15:41:42 2021 -0500
@@ -691,6 +691,8 @@
 
     void warn_language_extension_operator (const std::string& op);
 
+    void warn_deprecated_syntax (const std::string& msg);
+
     void push_token (token *);
 
     token * current_token (void);
--- a/libinterp/parse-tree/lex.ll	Mon Nov 22 16:41:21 2021 +0100
+++ b/libinterp/parse-tree/lex.ll	Mon Nov 22 15:41:42 2021 -0500
@@ -1072,14 +1072,7 @@
     /* FIXME: Remove support for '...' continuation in Octave 9 */
     static const char *msg = "'...' continuations in double-quoted character strings were deprecated in version 7 and will not be allowed in a future version of Octave; please use '\\' instead";
 
-    std::string nm = curr_lexer->m_fcn_file_full_name;
-
-    if (nm.empty ())
-      warning_with_id ("Octave:deprecated-syntax", "%s", msg);
-    else
-      warning_with_id ("Octave:deprecated-syntax",
-                       "%s; near line %d of file '%s'", msg,
-                       curr_lexer->m_filepos.line (), nm.c_str ());
+    curr_lexer->warn_deprecated_syntax (msg);
 
     HANDLE_STRING_CONTINUATION;
   }
@@ -1090,14 +1083,7 @@
     /* FIXME: Remove support for WS after line continuation in Octave 9 */
     static const char *msg = "whitespace after continuation markers in double-quoted character strings were deprecated in version 7 and will not be allowed in a future version of Octave";
 
-    std::string nm = curr_lexer->m_fcn_file_full_name;
-
-    if (nm.empty ())
-      warning_with_id ("Octave:deprecated-syntax", "%s", msg);
-    else
-      warning_with_id ("Octave:deprecated-syntax",
-                       "%s; near line %d of file '%s'", msg,
-                       curr_lexer->m_filepos.line (), nm.c_str ());
+    curr_lexer->warn_deprecated_syntax (msg);
 
     HANDLE_STRING_CONTINUATION;
   }
@@ -1301,14 +1287,7 @@
     /* FIXME: Remove support for '\\' line continuation in Octave 9 */
     static const char *msg = "using continuation marker \\ outside of double quoted strings was deprecated in version 7 and will be removed from a future version of Octave, use ... instead";
 
-    std::string nm = curr_lexer->m_fcn_file_full_name;
-
-    if (nm.empty ())
-      warning_with_id ("Octave:deprecated-syntax", "%s", msg);
-    else
-      warning_with_id ("Octave:deprecated-syntax",
-                       "%s; near line %d of file '%s'", msg,
-                       curr_lexer->m_filepos.line (), nm.c_str ());
+    curr_lexer->warn_deprecated_syntax (msg);
 
     curr_lexer->handle_continuation ();
   }
@@ -3667,6 +3646,17 @@
   }
 
   void
+  base_lexer::warn_deprecated_syntax (const std::string& msg)
+  {
+    if (m_fcn_file_full_name.empty ())
+      warning_with_id ("Octave:deprecated-syntax", "%s", msg.c_str ());
+    else
+      warning_with_id ("Octave:deprecated-syntax",
+                       "%s; near line %d of file '%s'", msg.c_str (),
+                       m_filepos.line (), m_fcn_file_full_name.c_str ());
+  }
+
+  void
   base_lexer::push_token (token *tok)
   {
     YYSTYPE *lval = yyget_lval (m_scanner);