changeset 16118:f8e463523229

move more static lexer helper functions to lexical_feedback class * lex.h, lex.ll (display_token, lexer_debug): Declare as members of lexical_feedback class. Change all callers. (display_state): New argument, STATE. (lexer_debug): Pass YYSTATE to display_state.
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2013 11:50:41 -0500
parents 771186909285
children b31eb56f4d84
files libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll
diffstat 2 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h	Tue Feb 26 11:47:59 2013 -0500
+++ b/libinterp/parse-tree/lex.h	Tue Feb 26 11:50:41 2013 -0500
@@ -276,6 +276,10 @@
 
   void gripe_matlab_incompatible_operator (const std::string& op);
 
+  void display_token (int tok);
+
+  void lexer_debug (const char *pattern, const char *text);
+
   // TRUE means that we should convert spaces to a comma inside a
   // matrix definition.
   bool convert_spaces_to_comma;
--- a/libinterp/parse-tree/lex.ll	Tue Feb 26 11:47:59 2013 -0500
+++ b/libinterp/parse-tree/lex.ll	Tue Feb 26 11:50:41 2013 -0500
@@ -126,11 +126,11 @@
     { \
       int tok_val = tok; \
       if (Vdisplay_tokens) \
-        display_token (tok_val); \
+        curr_lexer->display_token (tok_val); \
       if (lexer_debug_flag) \
         { \
           std::cerr << "R: "; \
-          display_token (tok_val); \
+          curr_lexer->display_token (tok_val); \
           std::cerr << std::endl;  \
         } \
       return tok_val; \
@@ -207,7 +207,7 @@
   do \
     { \
       if (lexer_debug_flag) \
-        lexer_debug (pattern, yytext); \
+        curr_lexer->lexer_debug (pattern, yytext); \
     } \
   while (0)
 
@@ -226,8 +226,6 @@
 
 static std::string strip_trailing_whitespace (char *s);
 static int octave_read (char *buf, unsigned int max_size);
-static void display_token (int tok);
-static void lexer_debug (const char *pattern, const char *text);
 
 %}
 
@@ -1425,8 +1423,8 @@
   return status;
 }
 
-static void
-display_token (int tok)
+void
+lexical_feedback::display_token (int tok)
 {
   switch (tok)
     {
@@ -1552,11 +1550,11 @@
 }
 
 static void
-display_state (void)
+display_state (int state)
 {
   std::cerr << "S: ";
 
-  switch (YY_START)
+  switch (state)
     {
     case INITIAL:
       std::cerr << "INITIAL" << std::endl;
@@ -1584,12 +1582,12 @@
     }
 }
 
-static void
-lexer_debug (const char *pattern, const char *text)
+void
+lexical_feedback::lexer_debug (const char *pattern, const char *text)
 {
   std::cerr << std::endl;
 
-  display_state ();
+  display_state (YY_START);
 
   std::cerr << "P: " << pattern << std::endl;
   std::cerr << "T: " << text << std::endl;