changeset 1511:74f9e88a2c12

[project @ 1995-10-03 10:49:31 by jwe]
author jwe
date Tue, 03 Oct 1995 10:50:19 +0000
parents fe9c39fd89c7
children c71ec9e06a84
files src/parse.y src/user-prefs.cc src/variables.cc
diffstat 3 files changed, 50 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/parse.y	Tue Oct 03 10:43:40 1995 +0000
+++ b/src/parse.y	Tue Oct 03 10:50:19 1995 +0000
@@ -157,6 +157,9 @@
 static tree_index_expression *make_index_expression
 	 (tree_indirect_ref *indir, tree_argument_list *args);
 
+// Maybe print a warning.  Duh.
+static void maybe_warn_missing_semi (tree_statement_list *);
+
 #define ABORT_PARSE \
   do \
     { \
@@ -329,14 +332,21 @@
 		| comma_semi
 		  { $$ = 0; }
 		| simple_list1
-		  { $$ = $1; }
+		  {
+		    maybe_warn_missing_semi ($1);
+		    $$ = $1;
+		  }
+		| simple_list1 comma_semi
+		  {
+		    maybe_warn_missing_semi ($1);
+		    $$ = $1;
+		  }
 		| simple_list1 semi_comma
 		  {
 		    tree_statement *tmp = $1->rear ();
 		    tmp->set_print_flag (0);
+		    $$ = $1;
 		  }
-		| simple_list1 comma_semi
-		  { $$ = $1; }
 		;
 
 simple_list1	: statement
@@ -350,9 +360,14 @@
 		    tree_statement *tmp = $1->rear ();
 		    tmp->set_print_flag (0);
 		    $1->append ($3);
+		    $$ = $1;
 		  }
 		| simple_list1 comma_semi statement
-		  { $1->append ($3); }
+		  {
+		    $1->append ($3);
+		    maybe_warn_missing_semi ($1);
+		    $$ = $1;
+		  }
 		;
 
 semi_comma	: ';'
@@ -381,9 +396,14 @@
 		;
 
 list		: list1
-		  { $$ = $1; }
+		  {
+		    maybe_warn_missing_semi ($1);
+		    $$ = $1;
+		  }
 		| list1 comma_nl_sep
-		  { $$ = $1; }
+		  {
+		    $$ = $1;
+		  }
 		| list1 semi_sep
 		  {
 		    tree_statement *tmp = $1->rear ();
@@ -397,12 +417,17 @@
 		    $$ = new tree_statement_list ($1);
 		  }
 		| list1 comma_nl_sep statement
-		  { $1->append ($3); }
+		  {
+		    $1->append ($3);
+		    maybe_warn_missing_semi ($1);
+		    $$ = $1;
+		  }
 		| list1 semi_sep statement
 		  {
 		    tree_statement *tmp = $1->rear ();
 		    tmp->set_print_flag (0);
 		    $1->append ($3);
+		    $$ = $1;
 		  }
 		;
 
@@ -1661,3 +1686,16 @@
 
   return retval;
 }
+
+static void
+maybe_warn_missing_semi (tree_statement_list *t)
+{
+  if (defining_func && user_pref.warn_missing_semicolon)
+    {
+      tree_statement *tmp = t->rear();
+      if (tmp->is_expression ())
+
+	warning ("missing semicolon near line %d, column %d",
+		 tmp->line (), tmp->column ());
+    }
+}
--- a/src/user-prefs.cc	Tue Oct 03 10:43:40 1995 +0000
+++ b/src/user-prefs.cc	Tue Oct 03 10:50:19 1995 +0000
@@ -515,10 +515,9 @@
 }
 
 
-// Generate warning if a statement in a function or script file is not
-// terminated with a semicolon.  Useful for checking scripts and
-// functions that should only produce output using explicit printing
-// statements.
+// Generate warning if a statement in a function is not terminated
+// with a semicolon.  Useful for checking functions that should only
+// produce output using explicit printing statements.
 
 int
 warn_missing_semicolon (void)
--- a/src/variables.cc	Tue Oct 03 10:43:40 1995 +0000
+++ b/src/variables.cc	Tue Oct 03 10:50:19 1995 +0000
@@ -1829,8 +1829,8 @@
 
   DEFVAR ("warn_missing_semicolon", SBV_warn_missing_semicolon,
 	  0.0, 0, warn_missing_semicolon,
-    "produce a warning if a statement in a script or function file is
-not terminated with a semicolon");
+    "produce a warning if a statement in a function file is not
+terminated with a semicolon");
 
   DEFVAR ("whitespace_in_literal_matrix",
 	  SBV_whitespace_in_literal_matrix, "", 0,