changeset 2805:68e6d0c93fc8

[project @ 1997-03-11 04:52:44 by jwe]
author jwe
date Tue, 11 Mar 1997 04:55:34 +0000
parents eedc2f3f61f7
children 187d5321cfa3
files src/parse.y src/pt-exp-base.h src/pt-exp.cc src/pt-exp.h src/pt-mvr.cc
diffstat 5 files changed, 53 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/src/parse.y
+++ b/src/parse.y
@@ -106,10 +106,11 @@
 // the file.
 
 // Generic error messages.
-static void yyerror (char *s);
+static void yyerror (const char *s);
 
 // Error mesages for mismatched end tokens.
-static void end_error (char *type, token::end_tok_type ettype, int l, int c);
+static void end_error
+	(const char *type, token::end_tok_type ettype, int l, int c);
 
 // Check to see that end tokens are properly matched.
 static int check_end (token *tok, token::end_tok_type expected);
@@ -1218,7 +1219,7 @@
 // Generic error messages.
 
 static void
-yyerror (char *s)
+yyerror (const char *s)
 {
   int err_col = current_input_column - 1;
 
@@ -1267,9 +1268,10 @@
 // Error mesages for mismatched end tokens.
 
 static void
-end_error (char *type, token::end_tok_type ettype, int l, int c)
+end_error (const char *type, token::end_tok_type ettype, int l, int c)
 {
-  static char *fmt = "`%s' command matched by `%s' near line %d column %d";
+  static const char *fmt
+    = "`%s' command matched by `%s' near line %d column %d";
 
   switch (ettype)
     {
@@ -1694,11 +1696,11 @@
       break;
 
     case EXPR_AND:
-      t = tree_binary_expression::and;
+      t = tree_binary_expression::el_and;
       break;
 
     case EXPR_OR:
-      t = tree_binary_expression::or;
+      t = tree_binary_expression::el_or;
       break;
 
     default:
@@ -1726,11 +1728,11 @@
   switch (op)
     {
     case EXPR_AND_AND:
-      t = tree_boolean_expression::and;
+      t = tree_boolean_expression::bool_and;
       break;
 
     case EXPR_OR_OR:
-      t = tree_boolean_expression::or;
+      t = tree_boolean_expression::bool_or;
       break;
 
     default:
@@ -1821,7 +1823,7 @@
       break;
 
     case EXPR_NOT:
-      t = tree_unary_expression::not;
+      t = tree_unary_expression::unot;
       break;
 
     case '-':
--- a/src/pt-exp-base.h
+++ b/src/pt-exp-base.h
@@ -47,7 +47,7 @@
       simple_assignment,
       multi_assignment,
       colon,
-      index,
+      index
    };
 
   tree_expression (int l = -1, int c = -1, type et = unknown)
@@ -89,7 +89,7 @@
 
   virtual octave_value eval (bool print) = 0;
 
-  virtual char *oper (void) const { return "<unknown>"; }
+  virtual const char *oper (void) const { return "<unknown>"; }
 
   virtual string original_text (void) const;
 
--- a/src/pt-exp.cc
+++ b/src/pt-exp.cc
@@ -102,10 +102,10 @@
   return retval;
 }
 
-char *
+const char *
 tree_prefix_expression::oper (void) const
 {
-  static char *op;
+  static const char *op;
   switch (etype)
     {
     case increment:
@@ -127,12 +127,8 @@
 tree_prefix_expression::eval_error (void)
 {
   if (error_state > 0)
-    {
-      char *op = oper ();
-
-      ::error ("evaluating prefix operator `%s' near line %d, column %d",
-	       op, line (), column ());
-    }
+    ::error ("evaluating prefix operator `%s' near line %d, column %d",
+	     oper (), line (), column ());
 }
 
 void
@@ -185,10 +181,10 @@
   return retval;
 }
 
-char *
+const char *
 tree_postfix_expression::oper (void) const
 {
-  static char *op;
+  static const char *op;
   switch (etype)
     {
     case increment:
@@ -210,12 +206,8 @@
 tree_postfix_expression::eval_error (void)
 {
   if (error_state > 0)
-    {
-      char *op = oper ();
-
-      ::error ("evaluating postfix operator `%s' near line %d, column %d",
-	       op, line (), column ());
-    }
+    ::error ("evaluating postfix operator `%s' near line %d, column %d",
+	     oper (), line (), column ());
 }
 
 void
@@ -244,7 +236,7 @@
 	{
 	  switch (etype)
 	    {
-	    case not:
+	    case unot:
 	      retval = u.not ();
 	      break;
 
@@ -276,13 +268,13 @@
   return retval;
 }
 
-char *
+const char *
 tree_unary_expression::oper (void) const
 {
-  static char *op;
+  static const char *op;
   switch (etype)
     {
-    case not:
+    case unot:
       op = "!";
       break;
 
@@ -309,12 +301,8 @@
 tree_unary_expression::eval_error (void)
 {
   if (error_state > 0)
-    {
-      char *op = oper ();
-
-      ::error ("evaluating unary operator `%s' near line %d, column %d",
-	       op, line (), column ());
-    }
+    ::error ("evaluating unary operator `%s' near line %d, column %d",
+	     oper (), line (), column ());
 }
 
 void
@@ -415,11 +403,11 @@
 		  op = octave_value::ne;
 		  break;
 
-		case and:
+		case el_and:
 		  op = octave_value::el_and;
 		  break;
 
-		case or:
+		case el_or:
 		  op = octave_value::el_or;
 		  break;
 
@@ -448,10 +436,10 @@
   return retval;
 }
 
-char *
+const char *
 tree_binary_expression::oper (void) const
 {
-  static char *op;
+  static const char *op;
   switch (etype)
     {
     case add:
@@ -518,11 +506,11 @@
       op = "!=";
       break;
 
-    case and:
+    case el_and:
       op = "&";
       break;
 
-    case or:
+    case el_or:
       op = "|";
       break;
 
@@ -537,12 +525,8 @@
 tree_binary_expression::eval_error (void)
 {
   if (error_state > 0)
-    {
-      char *op = oper ();
-
-      ::error ("evaluating binary operator `%s' near line %d, column %d",
-	       op, line (), column ());
-    }
+    ::error ("evaluating binary operator `%s' near line %d, column %d",
+	     oper (), line (), column ());
 }
 
 void
@@ -579,7 +563,7 @@
 	    {
 	      if (a_true)
 		{
-		  if (etype == or)
+		  if (etype == bool_or)
 		    {
 		      result = true;
 		      goto done;
@@ -587,7 +571,7 @@
 		}
 	      else
 		{
-		  if (etype == and)
+		  if (etype == bool_and)
 		    goto done;
 		}
 
@@ -621,17 +605,17 @@
   return retval;
 }
 
-char *
+const char *
 tree_boolean_expression::oper (void) const
 {
-  static char *op;
+  static const char *op;
   switch (etype)
     {
-    case and:
+    case bool_and:
       op = "&&";
       break;
 
-    case or:
+    case bool_or:
       op = "||";
       break;
 
--- a/src/pt-exp.h
+++ b/src/pt-exp.h
@@ -68,7 +68,7 @@
   bool is_prefix_expression (void) const
     { return true; }
 
-  char *oper (void) const;
+  const char *oper (void) const;
 
   tree_identifier *ident (void) { return id; }
 
@@ -110,7 +110,7 @@
 
   void eval_error (void);
 
-  char *oper (void) const;
+  const char *oper (void) const;
 
   tree_identifier *ident (void) { return id; }
 
@@ -135,7 +135,6 @@
   enum type
     {
       unknown,
-      not,
       unot,
       uminus,
       hermitian,
@@ -156,9 +155,9 @@
 
   void eval_error (void);
 
-  char *oper (void) const;
+  const char *oper (void) const;
 
-  bool is_prefix_op (void) { return (etype == not || etype == uminus); }
+  bool is_prefix_op (void) { return (etype == unot || etype == uminus); }
 
   tree_expression *operand (void) { return op; }
 
@@ -199,8 +198,8 @@
       cmp_ge,
       cmp_gt,
       cmp_ne,
-      and,
-      or
+      el_and,
+      el_or
     };
 
   tree_binary_expression (int l = -1, int c = -1, type t = unknown)
@@ -220,7 +219,7 @@
 
   void eval_error (void);
 
-  char *oper (void) const;
+  const char *oper (void) const;
 
   tree_expression *lhs (void) { return op_lhs; }
   tree_expression *rhs (void) { return op_rhs; }
@@ -249,8 +248,8 @@
   enum type
     {
       unknown,
-      and,
-      or
+      bool_and,
+      bool_or
     };
 
   tree_boolean_expression (int l = -1, int c = -1, type t)
@@ -264,7 +263,7 @@
 
   octave_value eval (bool print);
 
-  char *oper (void) const;
+  const char *oper (void) const;
 
 private:
 
--- a/src/pt-mvr.cc
+++ b/src/pt-mvr.cc
@@ -224,7 +224,7 @@
     {
       int l = line ();
       int c = column ();
-      char *fmt;
+      const char *fmt;
       if (l != -1 && c != -1)
 	{
 	  if (list)