changeset 3165:e4bbfc196e53

[project @ 1998-04-16 03:01:47 by jwe]
author jwe
date Thu, 16 Apr 1998 03:05:03 +0000
parents 45490c020e47
children c3409a0cafa8
files src/ChangeLog src/input.cc src/input.h src/lex.h src/lex.l src/ov-usr-fcn.cc src/ov-usr-fcn.h src/parse.y src/pt-plot.cc src/pt-plot.h src/pt-pr-code.cc src/pt-pr-code.h src/pt-walk.h src/variables.cc
diffstat 14 files changed, 323 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,30 @@
+Wed Apr 15 01:03:05 1998  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* input.cc (Vlast_prompt_time): New global variable.
+	(octave_gets): Set it.
+	* ov-usr-fcn.h (octave_user_function::time_checked): New function.
+	(octave_user_function::mark_fcn_file_up_to_date): Ditto.
+	(octave_user_function::t_checked): New data member.
+	* variables.cc (symbol_out_of_date): Only check file time stamp if
+	a prompt has been printed since the last time check.
+
+	* pt-plot.h, pt-plot.cc (subplot_axes): New class.
+	(subplot): Handle axes.
+	(Vgnuplot_command_axes): New static variable.
+	(gnuplot_command_axes): New function.
+	(symbols_of_pt_plot): DEFVAR gnuplot_command_axes.
+	* pt-walk.h (tree_walker::visit_subplot_axes): New virtual function.
+	* parse.y (plot_options): Handle axes.
+	* lex.l (plot_axes_token): New function.
+	(is_keyword): Use it.
+	(is_plot_keyword): Recognize "axes" and "axis".
+	* lex.h (class lexical_feedback): New field, in_plot_axes.
+	(lexical_feedback::init): Reset it.
+
+Tue Apr 14 23:32:27 1998  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* parse.y (parse_fcn_file): New arg, force_script.  Change callers.
+
 Fri Apr 10 11:01:27 1998  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* help.cc (type): Also print values of variables.
--- a/src/input.cc
+++ b/src/input.cc
@@ -86,6 +86,9 @@
 // more than one state can be active at once.
 int Vecho_executing_commands;
 
+// The time we last printed a prompt.
+time_t Vlast_prompt_time;
+
 // Character to append after successful command-line completion attempts.
 static char Vcompletion_append_char;
 
@@ -192,6 +195,8 @@
 {
   string retval;
 
+  Vlast_prompt_time = time (0);
+
   if ((interactive || forced_interactive)
       && (! (reading_fcn_file || reading_script_file)))
     {
--- a/src/input.h
+++ b/src/input.h
@@ -26,6 +26,7 @@
 #define octave_input_h 1
 
 #include <cstdio>
+#include <ctime>
 
 #include <string>
 
@@ -85,6 +86,8 @@
 
 extern int Vecho_executing_commands;
 
+extern time_t Vlast_prompt_time;
+
 #endif
 
 /*
--- a/src/lex.h
+++ b/src/lex.h
@@ -161,6 +161,9 @@
   // TRUE means we're looking at the style part of a plot command.
   bool in_plot_style;
 
+  // TRUE means we're looking at the axes part of a plot command.
+  bool in_plot_axes;
+
   // TRUE means we're looking at an indirect reference to a
   // structure element.
   bool looking_at_indirect_ref;
--- a/src/lex.l
+++ b/src/lex.l
@@ -835,6 +835,38 @@
   return retval;
 }
 
+// Check to see if a character string matches any of the possible axes
+// tags for plots.
+
+static string
+plot_axes_token (const string& s)
+{
+  string retval;
+
+  static char *plot_axes[] = 
+    {
+      "x1y1",
+      "x1y2",
+      "x2y1",
+      "x2y2",
+      0,
+    };
+
+  char **tmp = plot_axes;
+  while (*tmp)
+    {
+      if (almost_match (*tmp, s.c_str ()))
+	{
+	  retval = *tmp;
+	  break;
+	}
+
+      tmp++;
+    }
+
+  return retval;
+}
+
 // Check to see if a character string matches any one of the plot
 // option keywords.  Don't match abbreviations for clear, since that's
 // not a gnuplot keyword (users will probably only expect to be able
@@ -858,6 +890,11 @@
       lexer_flags.in_plot_style = true;
       return WITH;
     }
+  else if (almost_match ("axes", t) || almost_match ("axis", t))
+    {
+      lexer_flags.in_plot_axes = true;
+      return AXES;
+    }
   else if (strcmp ("clear", t) == 0)
     {
       return CLEAR;
@@ -873,17 +910,32 @@
 static int
 is_keyword (const string& s)
 {
-  if (lexer_flags.plotting && lexer_flags.in_plot_style)
+  if (lexer_flags.plotting)
     {
-      string sty = plot_style_token (s);
-
-      if (! sty.empty ())
+      if (lexer_flags.in_plot_style)
 	{
-	  lexer_flags.in_plot_style = false;
-	  yylval.tok_val = new token (sty);
-	  token_stack.push (yylval.tok_val);
-	  return STYLE;
+	  string sty = plot_style_token (s);
+
+	  if (! sty.empty ())
+	    {
+	      lexer_flags.in_plot_style = false;
+	      yylval.tok_val = new token (sty);
+	      token_stack.push (yylval.tok_val);
+	      return STYLE;
+	    }
 	}
+      else if (lexer_flags.in_plot_axes)
+	{
+	  string axes = plot_axes_token (s);
+
+	  if (! axes.empty ())
+	    {
+	      lexer_flags.in_plot_axes = false;
+	      yylval.tok_val = new token (axes);
+	      token_stack.push (yylval.tok_val);
+	      return AXES_TAG;
+	    }
+	}	
     }
 
   int l = input_line_number;
@@ -1860,6 +1912,7 @@
   doing_set = false;
   in_plot_range = false;
   in_plot_style = false;
+  in_plot_axes = false;
   in_plot_using = false;
   past_plot_range = false;
   plotting = false;
--- a/src/ov-usr-fcn.cc
+++ b/src/ov-usr-fcn.cc
@@ -80,10 +80,10 @@
   : octave_function (string (), string ()),
     param_list (pl), ret_list (rl), cmd_list (cl),
     sym_tab (st), file_name (), fcn_name (), t_parsed (0),
-    system_fcn_file (false), call_depth (0), num_named_args (0),
-    args_passed (), num_args_passed (0), curr_va_arg_number (0),
-    vr_list (0), symtab_entry (0), argn_sr (0), nargin_sr (0),
-    nargout_sr (0)
+    t_checked (0), system_fcn_file (false), call_depth (0),
+    num_named_args (0), args_passed (), num_args_passed (0),
+    curr_va_arg_number (0), vr_list (0), symtab_entry (0),
+    argn_sr (0), nargin_sr (0), nargout_sr (0)
 {
   install_automatic_vars ();
 
--- a/src/ov-usr-fcn.h
+++ b/src/ov-usr-fcn.h
@@ -73,8 +73,14 @@
 
   void stash_fcn_file_name (void);
 
+  void mark_fcn_file_up_to_date (time_t t)
+    { t_checked = t; }
+
   void stash_fcn_file_time (time_t t)
-    { t_parsed = t; }
+    {
+      t_parsed = t;
+      mark_fcn_file_up_to_date (t);
+    }
 
   void stash_symtab_ptr (symbol_record *sr)
     { symtab_entry = sr; }
@@ -85,6 +91,9 @@
   time_t time_parsed (void) const
     { return t_parsed; }
 
+  time_t time_checked (void) const
+    { return t_checked; }
+
   void mark_as_system_fcn_file (void);
 
   bool is_system_fcn_file (void) const
@@ -157,6 +166,10 @@
   // The time the file was parsed.
   time_t t_parsed;
 
+  // The time the file was last checked to see if it needs to be
+  // parsed again.
+  time_t t_checked;
+
   // True if this function came from a file that is considered to be a
   // system function.  This affects whether we check the time stamp
   // on the file to see if it has changed.
--- a/src/parse.y
+++ b/src/parse.y
@@ -324,6 +324,7 @@
   plot_range *plot_range_type;
   subplot_using *subplot_using_type;
   subplot_style *subplot_style_type;
+  subplot_axes *subplot_axes_type;
   octave_user_function *octave_user_function_type;
 }
 
@@ -342,7 +343,7 @@
 %token <tok_val> NAME
 %token <tok_val> END
 %token <tok_val> PLOT
-%token <tok_val> TEXT STYLE
+%token <tok_val> TEXT STYLE AXES_TAG
 %token <tok_val> FOR WHILE
 %token <tok_val> IF ELSEIF ELSE
 %token <tok_val> SWITCH CASE OTHERWISE
@@ -354,7 +355,7 @@
 // Other tokens.
 %token END_OF_INPUT LEXICAL_ERROR
 %token FCN ELLIPSIS ALL_VA_ARGS
-%token USING TITLE WITH COLON OPEN_BRACE CLOSE_BRACE CLEAR
+%token USING TITLE WITH AXES COLON OPEN_BRACE CLOSE_BRACE CLEAR
 
 // Nonterminals we construct.
 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep