diff libinterp/parse-tree/lex.h @ 16111:3ec4f6488569

move token stack to lexical_feedback class * lex.h, lex.ll (token_stack): Move global variable to lexical_feedback class. Change all uses. * lex.ll (lexical_feedback::~lexical_feedback): Move definition here from lex.h. Clean up token_stack.
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2013 01:34:11 -0500
parents 7302f8a4df83
children 7c5e5e97a3bc
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h
+++ b/libinterp/parse-tree/lex.h
@@ -54,6 +54,10 @@
 extern void prep_lexer_for_script_file (void);
 extern void prep_lexer_for_function_file (void);
 
+
+// Forward decl for lexical_feedback::token_stack.
+class token;
+
 // For communication between the lexer and parser.
 
 class
@@ -175,7 +179,7 @@
     init ();
   }
 
-  ~lexical_feedback (void) { }
+  ~lexical_feedback (void);
 
   void init (void)
   {
@@ -280,6 +284,11 @@
   // a paren?
   bbp_nesting_level nesting_level;
 
+  // Stack to hold tokens so that we can delete them when the parser is
+  // reset and avoid growing forever just because we are stashing some
+  // information.
+  std::stack <token*> token_stack;
+
 private:
 
   // No copying!