Mercurial > hg > octave-nkf
changeset 16128:210039e91ad6
localize use of yytext with lexical_feedback member function
* lex.h, lex.ll (lexical_feedback::flex_yytext): New function.
* lex.ll (lexical_feedback::xunput, lexical_feedback::process_comment,
lexical_feedback::handle_number, lexical_feedback::handle_identifier,
lexical_feedback::handle_meta_identifier,
lexical_feedback::handle_superclass_identifier):
Use it instead of accessing yytext directly.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2013 15:39:56 -0500 |
parents | f7eb13f14320 |
children | 053b0364b507 |
files | libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll |
diffstat | 2 files changed, 27 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -210,6 +210,8 @@ int octave_read (char *buf, unsigned int max_size); + char *flex_yytext (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 status; } +char * +lexical_feedback::flex_yytext (void) +{ + return yytext; +} + // GAG. // // If we're reading a matrix and the next character is '[', make sure @@ -1563,7 +1569,8 @@ void lexical_feedback::xunput (char c) { - xunput (c, yytext); + char *yytxt = flex_yytext (); + xunput (c, yytxt); } // If we read some newlines, we need figure out what column we're @@ -2084,7 +2091,8 @@ if (! help_buf.empty ()) help_txt = help_buf.top (); - flex_stream_reader flex_reader (this, yytext); + char *yytxt = flex_yytext (); + flex_stream_reader flex_reader (this, yytxt); // process_comment is only supposed to be called when we are not // initially looking at a block comment. @@ -2470,17 +2478,19 @@ double value = 0.0; int nread = 0; - if (looks_like_hex (yytext, strlen (yytext))) + char *yytxt = flex_yytext (); + + if (looks_like_hex (yytxt, strlen (yytxt))) { unsigned long ival; - nread = sscanf (yytext, "%lx", &ival); + nread = sscanf (yytxt, "%lx", &ival); value = static_cast<double> (ival); } else { - char *tmp = strsave (yytext); + char *tmp = strsave (yytxt); char *idx = strpbrk (tmp, "Dd"); @@ -2501,7 +2511,7 @@ looking_for_object_index = false; at_beginning_of_statement = false; - curr_lexer->push_token (new token (value, yytext, input_line_number, + curr_lexer->push_token (new token (value, yytxt, input_line_number, current_input_column)); current_input_column += yyleng; @@ -3208,7 +3218,8 @@ eat_continuation (); std::string pkg; - std::string meth = strip_trailing_whitespace (yytext); + char *yytxt = flex_yytext (); + std::string meth = strip_trailing_whitespace (yytxt); size_t pos = meth.find ("@"); std::string cls = meth.substr (pos).substr (1); meth = meth.substr (0, pos - 1); @@ -3246,7 +3257,8 @@ eat_continuation (); std::string pkg; - std::string cls = strip_trailing_whitespace (yytext).substr (1); + char *yytxt = flex_yytext (); + std::string cls = strip_trailing_whitespace (yytxt).substr (1); size_t pos = cls.find ("."); if (pos != std::string::npos) @@ -3282,9 +3294,11 @@ { bool at_bos = at_beginning_of_statement; - std::string tok = strip_trailing_whitespace (yytext); - - int c = yytext[yyleng-1]; + char *yytxt = flex_yytext (); + + std::string tok = strip_trailing_whitespace (yytxt); + + int c = yytxt[yyleng-1]; bool cont_is_spc = (eat_continuation () != lexical_feedback::NO_WHITESPACE);