diff libinterp/parse-tree/lex.ll @ 26710:d6dd07dce2d2

use inline functions for matching whitespace in lexer * lex.ll (is_space_or_tab_or_eol): New static function. Use is_space_or_tab and is_space_or_tab_or_eol to match whitespace.
author John W. Eaton <jwe@octave.org>
date Sat, 09 Feb 2019 19:32:31 +0000
parents 17e7d310def8
children 9b0335f4bc74
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Sat Feb 09 16:14:01 2019 +0000
+++ b/libinterp/parse-tree/lex.ll	Sat Feb 09 19:32:31 2019 +0000
@@ -323,6 +323,18 @@
      }                                                                  \
    while (0)
 
+static inline bool
+is_space_or_tab (char c)
+{
+  return c == ' ' || c == '\t';
+}
+
+static inline bool
+is_space_or_tab_or_eol (char c)
+{
+  return c == ' ' || c == '\t' || c == '\n' || c == '\r';
+}
+
 %}
 
 D       [0-9]
@@ -725,7 +737,7 @@
     while (i < len)
       {
         char c = yytext[i];
-        if (c == ' ' || c == '\t')
+        if (is_space_or_tab (c))
           {
             have_space = true;
             i++;
@@ -759,7 +771,7 @@
             while (i < len)
               {
                 char c = yytext[i++];
-                if (! (c == ' ' || c == '\t' || c == '\n' || c == '\r'))
+                if (! is_space_or_tab_or_eol (c))
                   {
                     looks_like_block_comment = false;
                     break;
@@ -1802,12 +1814,6 @@
   std::free (ptr);
 }
 
-static inline bool
-is_space_or_tab (char c)
-{
-  return c == ' ' || c == '\t';
-}
-
 static void
 display_character (char c)
 {
@@ -2463,7 +2469,7 @@
   {
     int c = text_yyinput ();
     xunput (c);
-    return (c == ' ' || c == '\t');
+    return is_space_or_tab (c);
   }
 
   bool
@@ -2868,7 +2874,7 @@
     while (offset < yylng)
       {
         char c = yytxt[offset];
-        if (c == ' ' || c == '\t')
+        if (is_space_or_tab (c))
           {
             have_space = true;
             offset++;
@@ -3547,7 +3553,7 @@
         int c = text_yyinput ();
         xunput (c);
 
-        bool space_after = (c == ' ' || c == '\t');
+        bool space_after = is_space_or_tab (c);
 
         if (! (prev_tok == '[' || prev_tok == '{'
                || previous_token_is_binop ()