diff src/lex.l @ 3165:e4bbfc196e53

[project @ 1998-04-16 03:01:47 by jwe]
author jwe
date Thu, 16 Apr 1998 03:05:03 +0000
parents 61bb314b2c3d
children 390d5e396682
line wrap: on
line diff
--- a/src/lex.l	Tue Apr 14 20:56:53 1998 +0000
+++ b/src/lex.l	Thu Apr 16 03:05:03 1998 +0000
@@ -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;