diff src/parse.y @ 3903:1dbe160ea0d1

[project @ 2002-04-23 03:40:25 by jwe]
author jwe
date Tue, 23 Apr 2002 03:40:25 +0000
parents 69b6bd271277
children e8627dc4bdf2
line wrap: on
line diff
--- a/src/parse.y	Mon Apr 22 16:33:32 2002 +0000
+++ b/src/parse.y	Tue Apr 23 03:40:25 2002 +0000
@@ -127,6 +127,9 @@
 // an eval() statement.
 bool evaluating_function_body = false;
 
+// Keep track of symbol table information when parsing functions.
+static symbol_table *symtab_context = 0;
+
 // Forward declarations for some functions defined at the bottom of
 // the file.
 
@@ -1049,6 +1052,15 @@
 // Some `subroutines' for function definitions
 // ===========================================
 
+save_symtab	: // empty
+		  {
+		    if (symtab_context)
+		      panic_impossible ();
+
+		    symtab_context = curr_sym_tab;
+		  }
+		;
+		   
 global_symtab	: // empty
 		  { curr_sym_tab = global_sym_tab; }
 		;
@@ -1173,8 +1185,8 @@
 // Function definition
 // ===================
 
-function_beg	: FCN stash_comment global_symtab
-		  { $$ = $2; }
+function_beg	: save_symtab FCN stash_comment global_symtab
+		  { $$ = $3; }
 		;
 
 function	: function_beg function2
@@ -2538,7 +2550,11 @@
 static void
 recover_from_parsing_function (void)
 {
-  curr_sym_tab = top_level_sym_tab;
+  if (! symtab_context)
+    panic_impossible ();
+
+  curr_sym_tab = symtab_context;
+  symtab_context = 0;
 
   lexer_flags.defining_func = false;
   lexer_flags.beginning_of_function = false;