Mercurial > hg > octave-jordi
changeset 883:ff0bbf26b028
[project @ 1994-11-06 00:22:31 by jwe]
author | jwe |
---|---|
date | Sun, 06 Nov 1994 00:22:31 +0000 |
parents | 714fd17fca28 |
children | d92f1ea6d0cd |
files | src/lex.l src/parse.y src/pt-plot.cc |
diffstat | 3 files changed, 34 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lex.l +++ b/src/lex.l @@ -937,6 +937,11 @@ past_plot_range = 1; return WITH; } + else if (almost_match ("clear", s)) + { + past_plot_range = 1; + return CLEAR; + } else { return 0; @@ -1355,6 +1360,11 @@ static int handle_identifier (char *tok, int next_tok_is_eq) { +// It is almost always an error for an identifier to be followed +// directly by another identifier. Special cases are handled below. + + cant_be_identifier = 1; + // If we are expecting a structure element, we just want to return // TEXT_ID, which is a string that is also a valid identifier. @@ -1365,8 +1375,8 @@ TOK_RETURN (TEXT_ID); } -// If we have a regular keyword, or a plot STYLE, return it. STYLE is -// special only because it can't be followed by an identifier. +// If we have a regular keyword, or a plot STYLE, return it. Keywords +// can be followed by identifiers (TOK_RETURN handles that). int kw_token = is_keyword (tok); if (kw_token) @@ -1375,7 +1385,6 @@ { current_input_column += yyleng; quote_is_transpose = 0; - cant_be_identifier = 1; convert_spaces_to_comma = 1; return kw_token; } @@ -1383,7 +1392,7 @@ TOK_RETURN (kw_token); } -// See if we have a plot keyword (title, using, or with). +// See if we have a plot keyword (title, using, with, or clear). int plot_option_kw = is_plot_keyword (tok); if (plotting && cant_be_identifier && plot_option_kw) @@ -1397,11 +1406,6 @@ if (plotting && ! in_plot_range) past_plot_range = 1; -// It is always an error for an identifier to be followed directly by -// another identifier. - - cant_be_identifier = 1; - // If we are looking at a text style function, set up to gobble its // arguments. These are also reserved words, but only because it // would be very difficult to do anything intelligent with them if
--- a/src/parse.y +++ b/src/parse.y @@ -231,7 +231,7 @@ %token FCN SCREW_TWO %token ELLIPSIS %token END_OF_INPUT -%token USING TITLE WITH COLON OPEN_BRACE CLOSE_BRACE +%token USING TITLE WITH COLON OPEN_BRACE CLOSE_BRACE CLEAR // Nonterminals we construct. %type <tree_type> input @@ -405,6 +405,12 @@ { $$ = new tree_statement ($1); } | ans_expression { $$ = new tree_statement ($1); } + | PLOT CLEAR + { + symbol_record *sr = lookup_by_name ("clearplot", 0); + tree_identifier *id = new tree_identifier (sr); + $$ = new tree_statement (id); + } ; plot_command : PLOT plot_command1
--- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -934,6 +934,7 @@ style->print_code (os); } +int subplot_list::print (int ndim, ostrstream& plot_buf) { int status = 0; @@ -1037,7 +1038,15 @@ plot_line_count = 0; } -DEFUN ("closeplot", Fcloseplot, Scloseplot, 1, 0, +DEFUN ("clearplot", Fclearplot, Sclearplot, 0, 0, + "clearplot (): clear the plot window") +{ + Octave_object retval; + send_to_plot_stream ("clear\n"); + return retval; +} + +DEFUN ("closeplot", Fcloseplot, Scloseplot, 0, 0, "closeplot (): close the stream to plotter") { Octave_object retval; @@ -1045,7 +1054,7 @@ return retval; } -DEFUN_TEXT ("hold", Fhold, Shold, -1, 1, +DEFUN_TEXT ("hold", Fhold, Shold, 1, 0, "hold [on|off]\n\ \n\ determine whether the plot window is cleared before the next line is\n\ @@ -1088,7 +1097,7 @@ return (double) (! clear_before_plotting); } -DEFUN ("purge_tmp_files", Fpurge_tmp_files, Spurge_tmp_files, 5, 1, +DEFUN ("purge_tmp_files", Fpurge_tmp_files, Spurge_tmp_files, 0, 0, "delete temporary data files used for plotting") { Octave_object retval; @@ -1096,7 +1105,7 @@ return retval; } -DEFUN_TEXT ("set", Fset, Sset, -1, 1, +DEFUN_TEXT ("set", Fset, Sset, -1, 0, "set [options]\n\ \n\ set plotting options") @@ -1130,7 +1139,7 @@ return retval; } -DEFUN_TEXT ("show", Fshow, Sshow, -1, 1, +DEFUN_TEXT ("show", Fshow, Sshow, -1, 0, "show [options]\n\ \n\ show plotting options")