Mercurial > hg > octave-terminal
changeset 5504:d0a24bfe4487
[project @ 2005-10-21 12:25:16 by jwe]
author | jwe |
---|---|
date | Fri, 21 Oct 2005 12:25:17 +0000 |
parents | 08448daec293 |
children | 17682e3fba2a |
files | src/ChangeLog src/DLD-FUNCTIONS/gplot.l |
diffstat | 2 files changed, 78 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2005-10-21 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/gplot.l (read_until): Special case STRING. + (handle_string): Restore function. + ("'", "\""): Call handle string when matching these tokens.. + 2005-10-20 John W. Eaton <jwe@octave.org> * pt-mat.cc (tm_row_const::all_real): New data member.
--- a/src/DLD-FUNCTIONS/gplot.l +++ b/src/DLD-FUNCTIONS/gplot.l @@ -121,6 +121,9 @@ static int is_plot_keyword (const std::string& s); +static int handle_string (char delim); +static std::string strbuf; + %} D [0-9] @@ -197,11 +200,14 @@ { gpt_quote_is_transpose = true; gpt_allow_plotkw = true; - warning ("unknown token = \"%s\" in plot command", yytext); - return OTHER; + return handle_string ('\''); } } +"\"" { + return handle_string ('"'); + } + {IDENT} { int itok = 0; if (can_be_plotkw () && (itok = is_plot_keyword (yytext))) @@ -308,6 +314,69 @@ return 0; } +// This is used to handle character strings. Kludge alert. + +static int +handle_string (char delim) +{ + int c; + bool escape_pending = false; + + strbuf = std::string (1, delim); + + while ((c = yyinput ()) != EOF) + { + if (c == '\\') + { + if (escape_pending) + { + strbuf += static_cast<char> (c); + escape_pending = false; + } + else + { + strbuf += static_cast<char> (c); + escape_pending = true; + } + continue; + } + else if (c == '\n') + { + error ("unterminated string constant"); + break; + } + else if (c == delim) + { + if (escape_pending) + strbuf += static_cast<char> (c); + else + { + c = yyinput (); + + if (c == delim) + { + strbuf += static_cast<char> (c); + strbuf += static_cast<char> (c); + } + else + { + yyunput (c, yytext); + strbuf += static_cast<char> (delim); + return STRING; + } + } + } + else + strbuf += static_cast<char> (c); + + escape_pending = false; + } + + throw gpt_parse_error ("unterminated string"); + + return 0; +} + // (Probably not necessesary, but current Matlab style plot functions // break without this (they emit too short gnuplot commands)) @@ -446,7 +515,7 @@ break; } - s += std::string (yytext) + " "; + s += (tok == STRING ? strbuf : std::string (yytext)) + " "; tok = gptlex (); }