changeset 16130:421dea028bbf

localize use of yyleng with lexical_feedback member function * lex.h, lex.ll (lexical_feedback::yyleng): New function. (lexical_feedback::handle_number, lexical_feedback::handle_identifier, lexical_feedback::handle_meta_identifier, lexical_feedback::handle_superclass_identifier): Use it.
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2013 16:15:12 -0500
parents 053b0364b507
children e125db98263f
files libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll
diffstat 2 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h
+++ b/libinterp/parse-tree/lex.h
@@ -212,6 +212,8 @@
 
   char *flex_yytext (void);
 
+  int flex_yyleng (void);
+
   void do_comma_insert_check (void);
 
   int text_yyinput (void);
--- a/libinterp/parse-tree/lex.ll
+++ b/libinterp/parse-tree/lex.ll
@@ -1485,6 +1485,12 @@
   return yytext;
 }
 
+int
+lexical_feedback::flex_yyleng (void)
+{
+  return yyleng;
+}
+
 // GAG.
 //
 // If we're reading a matrix and the next character is '[', make sure
@@ -2508,7 +2514,7 @@
   curr_lexer->push_token (new token (value, yytxt, input_line_number,
                                      current_input_column));
 
-  current_input_column += yyleng;
+  current_input_column += flex_yyleng ();
 
   do_comma_insert_check ();
 }
@@ -3240,7 +3246,7 @@
                 input_line_number, current_input_column));
 
   convert_spaces_to_comma = true;
-  current_input_column += yyleng;
+  current_input_column += flex_yyleng ();
 
   return SUPERCLASSREF;
 }
@@ -3274,7 +3280,7 @@
                 input_line_number, current_input_column));
 
   convert_spaces_to_comma = true;
-  current_input_column += yyleng;
+  current_input_column += flex_yyleng ();
 
   return METAQUERY;
 }
@@ -3292,7 +3298,7 @@
 
   std::string tok = strip_trailing_whitespace (yytxt);
 
-  int c = yytxt[yyleng-1];
+  int c = yytxt[flex_yyleng()-1];
 
   bool cont_is_spc = (eat_continuation () != lexical_feedback::NO_WHITESPACE);
 
@@ -3316,7 +3322,7 @@
       convert_spaces_to_comma = true;
       looking_for_object_index = true;
 
-      current_input_column += yyleng;
+      current_input_column += flex_yyleng ();
 
       return STRUCT_ELT;
     }
@@ -3347,7 +3353,7 @@
           curr_lexer->push_token (new token (tok, input_line_number,
                                              current_input_column));
 
-          current_input_column += yyleng;
+          current_input_column += flex_yyleng ();
           quote_is_transpose = false;
           convert_spaces_to_comma = true;
           looking_for_object_index = true;
@@ -3363,7 +3369,7 @@
     {
       if (kw_token >= 0)
         {
-          current_input_column += yyleng;
+          current_input_column += flex_yyleng ();
           quote_is_transpose = false;
           convert_spaces_to_comma = true;
           looking_for_object_index = false;
@@ -3442,7 +3448,7 @@
       maybe_unput_comma (spc_gobbled);
     }
 
-  current_input_column += yyleng;
+  current_input_column += flex_yyleng ();
 
   if (tok != "__end__")
     looking_for_object_index = true;