# HG changeset patch # User John W. Eaton # Date 1361913312 18000 # Node ID 421dea028bbf8e45cd16974ac53a9b52d8d8baf3 # Parent 053b0364b5070abd6942abd5a36a3b21d26f5988 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. diff -r 053b0364b507 -r 421dea028bbf libinterp/parse-tree/lex.h --- a/libinterp/parse-tree/lex.h Tue Feb 26 16:03:00 2013 -0500 +++ b/libinterp/parse-tree/lex.h Tue Feb 26 16:15:12 2013 -0500 @@ -212,6 +212,8 @@ char *flex_yytext (void); + int flex_yyleng (void); + void do_comma_insert_check (void); int text_yyinput (void); diff -r 053b0364b507 -r 421dea028bbf libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Tue Feb 26 16:03:00 2013 -0500 +++ b/libinterp/parse-tree/lex.ll Tue Feb 26 16:15:12 2013 -0500 @@ -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;