# HG changeset patch # User John W. Eaton # Date 1361897441 18000 # Node ID f8e463523229de4389c10ace1423b9cff096602c # Parent 771186909285aa8d216ab1a6b2e6e72bb3c2c026 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. diff -r 771186909285 -r f8e463523229 libinterp/parse-tree/lex.h --- 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; diff -r 771186909285 -r f8e463523229 libinterp/parse-tree/lex.ll --- 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;