Mercurial > hg > octave-lyh
diff libinterp/parse-tree/lex.ll @ 16125:96a58f197f93
allow xunput to be called without buffer argument
* lex.h, lex.ll (lexical_feedback::xunput (char)): New function.
Forward to xunput (char, char*) with yytext as default buffer.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2013 14:31:34 -0500 |
parents | 3be725cd195b |
children | 5c885c13bfa3 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -256,7 +256,7 @@ LEXER_DEBUG ("<SCRIPT_FILE_BEGIN>."); BEGIN (INITIAL); - curr_lexer->xunput (yytext[0], yytext); + curr_lexer->xunput (yytext[0]); COUNT_TOK_AND_RETURN (SCRIPT_FILE); } @@ -264,7 +264,7 @@ LEXER_DEBUG ("<FUNCTION_FILE_BEGIN>."); BEGIN (INITIAL); - curr_lexer->xunput (yytext[0], yytext); + curr_lexer->xunput (yytext[0]); COUNT_TOK_AND_RETURN (FUNCTION_FILE); } @@ -354,7 +354,7 @@ int tok_to_return = curr_lexer->handle_close_bracket (spc_gobbled, ']'); if (spc_gobbled) - curr_lexer->xunput (' ', yytext); + curr_lexer->xunput (' '); COUNT_TOK_AND_RETURN (tok_to_return); } @@ -380,7 +380,7 @@ int tok_to_return = curr_lexer->handle_close_bracket (spc_gobbled, '}'); if (spc_gobbled) - curr_lexer->xunput (' ', yytext); + curr_lexer->xunput (' '); COUNT_TOK_AND_RETURN (tok_to_return); } @@ -409,7 +409,7 @@ { curr_lexer->maybe_warn_separator_insert (';'); - curr_lexer->xunput (';', yytext); + curr_lexer->xunput (';'); } } @@ -446,7 +446,7 @@ { curr_lexer->maybe_warn_separator_insert (';'); - curr_lexer->xunput (';', yytext); + curr_lexer->xunput (';'); } curr_lexer->quote_is_transpose = false; @@ -766,7 +766,7 @@ curr_lexer->looking_for_object_index = false; - curr_lexer->xunput (yytext[0], yytext); + curr_lexer->xunput (yytext[0]); bool eof = false; int tok = curr_lexer->process_comment (false, eof); @@ -956,7 +956,7 @@ . { LEXER_DEBUG ("."); - curr_lexer->xunput (yytext[0], yytext); + curr_lexer->xunput (yytext[0]); int c = curr_lexer->text_yyinput (); @@ -1497,10 +1497,10 @@ int c = text_yyinput (); - xunput (c, yytext); + xunput (c); if (spc_gobbled) - xunput (' ', yytext); + xunput (' '); do_comma_insert = (! looking_at_object_index.front () && bracketflag && c == '['); @@ -1533,7 +1533,7 @@ if (c != '\n') { - xunput (c, yytext); + xunput (c); c = '\n'; } } @@ -1560,6 +1560,12 @@ yyunput (c, buf); } +void +lexical_feedback::xunput (char c) +{ + xunput (c, yytext); +} + // If we read some newlines, we need figure out what column we're // really looking at. @@ -2128,7 +2134,7 @@ retval = match_any (c, ",;\n]"); - xunput (c, yytext); + xunput (c); return retval; } @@ -2151,22 +2157,22 @@ { int c1 = text_yyinput (); un_op = (c1 == '\''); - xunput (c1, yytext); + xunput (c1); } else if (c0 == '+') { int c1 = text_yyinput (); un_op = (c1 == '+'); - xunput (c1, yytext); + xunput (c1); } else if (c0 == '-') { int c1 = text_yyinput (); un_op = (c1 == '-'); - xunput (c1, yytext); + xunput (c1); } - xunput (c0, yytext); + xunput (c0); return un_op; } @@ -2215,7 +2221,7 @@ break; } - xunput (c1, yytext); + xunput (c1); } break; @@ -2239,7 +2245,7 @@ // A structure element reference is a binary op. bin_op = true; - xunput (c1, yytext); + xunput (c1); } break; @@ -2269,7 +2275,7 @@ if (c1 == '=') bin_op = true; - xunput (c1, yytext); + xunput (c1); } break; @@ -2277,7 +2283,7 @@ break; } - xunput (c0, yytext); + xunput (c0); return bin_op; } @@ -2447,7 +2453,7 @@ octave_comment_buffer::append (comment_buf); done: - xunput (c, yytext); + xunput (c); current_input_column--; return retval; } @@ -2586,7 +2592,7 @@ } } - xunput (c, yytext); + xunput (c); return false; cleanup: @@ -2595,7 +2601,7 @@ int len = s.length (); while (len--) - xunput (s[len], yytext); + xunput (s[len]); return false; } @@ -2615,12 +2621,12 @@ return true; else { - xunput (c2, yytext); - xunput (c1, yytext); + xunput (c2); + xunput (c1); } } else - xunput (c1, yytext); + xunput (c1); return false; } @@ -2639,7 +2645,7 @@ || (c == '\\' && have_continuation ())) retval = eat_whitespace (); else - xunput (c, yytext); + xunput (c); return retval; } @@ -2702,7 +2708,7 @@ else { std::string s; - xunput (c, yytext); + xunput (c); if (delim == '\'') s = buf.str (); @@ -2750,7 +2756,7 @@ case '=': { int c1 = text_yyinput (); - xunput (c1, yytext); + xunput (c1); if (c1 != '=') retval = true; } @@ -2765,7 +2771,7 @@ case '|': { int c1 = text_yyinput (); - xunput (c1, yytext); + xunput (c1); if (c1 == '=') retval = true; } @@ -2777,11 +2783,11 @@ if (match_any (c1, "+-*/\\")) { int c2 = text_yyinput (); - xunput (c2, yytext); + xunput (c2); if (c2 == '=') retval = true; } - xunput (c1, yytext); + xunput (c1); } break; @@ -2791,11 +2797,11 @@ if (c1 == '>') { int c2 = text_yyinput (); - xunput (c2, yytext); + xunput (c2); if (c2 == '=') retval = true; } - xunput (c1, yytext); + xunput (c1); } break; @@ -2805,11 +2811,11 @@ if (c1 == '<') { int c2 = text_yyinput (); - xunput (c2, yytext); + xunput (c2); if (c2 == '=') retval = true; } - xunput (c1, yytext); + xunput (c1); } break; @@ -2817,7 +2823,7 @@ break; } - xunput (c0, yytext); + xunput (c0); return retval; } @@ -2826,7 +2832,7 @@ lexical_feedback::next_token_is_index_op (void) { int c = text_yyinput (); - xunput (c, yytext); + xunput (c); return c == '(' || c == '{'; } @@ -2884,7 +2890,7 @@ { maybe_warn_separator_insert (','); - xunput (',', yytext); + xunput (','); return retval; } } @@ -2910,8 +2916,8 @@ int c1 = text_yyinput (); int c2 = text_yyinput (); - xunput (c2, yytext); - xunput (c1, yytext); + xunput (c2); + xunput (c1); int sep_op = next_token_is_sep_op (); @@ -2931,7 +2937,7 @@ maybe_warn_separator_insert (','); - xunput (',', yytext); + xunput (','); } } @@ -2956,7 +2962,7 @@ // Restore input. while (! buf.empty ()) { - xunput (buf.top (), yytext); + xunput (buf.top ()); buf.pop (); } @@ -2999,12 +3005,12 @@ && next_token_can_follow_bin_op ()) retval = false; - xunput (c2, yytext); + xunput (c2); } else retval = false; - xunput (c1, yytext); + xunput (c1); } break; @@ -3054,12 +3060,12 @@ && next_token_can_follow_bin_op ()) retval = false; - xunput (c2, yytext); + xunput (c2); } break; } - xunput (c1, yytext); + xunput (c1); } break; @@ -3074,7 +3080,7 @@ && next_token_can_follow_bin_op ()) retval = false; - xunput (c1, yytext); + xunput (c1); } break; @@ -3095,13 +3101,13 @@ && next_token_can_follow_bin_op ()) retval = false; - xunput (c3, yytext); + xunput (c3); } else if (! match_any (c2, ",;\n") && (c2 == ' ' || c2 == '\t') && next_token_can_follow_bin_op ()) retval = false; - xunput (c2, yytext); + xunput (c2); } else if (! match_any (c1, ",;\n") && (! isdigit (c1) && c1 != ' ' && c1 != '\t' @@ -3112,7 +3118,7 @@ retval = false; } - xunput (c1, yytext); + xunput (c1); } break; @@ -3131,13 +3137,13 @@ && next_token_can_follow_bin_op ()) retval = false; - xunput (c2, yytext); + xunput (c2); } else if (! match_any (c1, ",;\n") && (c1 == ' ' || c1 == '\t') && next_token_can_follow_bin_op ()) retval = false; - xunput (c1, yytext); + xunput (c1); } break; @@ -3155,13 +3161,13 @@ && next_token_can_follow_bin_op ()) retval = false; - xunput (c2, yytext); + xunput (c2); } else if (! match_any (c1, ",;\n") && (c1 == ' ' || c1 == '\t') && next_token_can_follow_bin_op ()) retval = false; - xunput (c1, yytext); + xunput (c1); } break; @@ -3180,13 +3186,13 @@ && next_token_can_follow_bin_op ()) retval = false; - xunput (c2, yytext); + xunput (c2); } else if (! match_any (c1, ",;\n") && (c1 == ' ' || c1 == '\t') && next_token_can_follow_bin_op ()) retval = false; - xunput (c1, yytext); + xunput (c1); } break; @@ -3194,7 +3200,7 @@ break; } - xunput (c0, yytext); + xunput (c0); return retval; } @@ -3378,13 +3384,13 @@ if (c1 == '=') { int c2 = text_yyinput (); - xunput (c2, yytext); + xunput (c2); if (c2 != '=') next_tok_is_eq = true; } - xunput (c1, yytext); + xunput (c1); // Kluge alert. //