diff src/lex.l @ 4214:b9317f3973ec

[project @ 2002-12-04 04:57:01 by jwe]
author jwe
date Wed, 04 Dec 2002 04:57:01 +0000
parents e96f52432059
children ccfdb55c8156
line wrap: on
line diff
--- a/src/lex.l	Wed Dec 04 04:19:15 2002 +0000
+++ b/src/lex.l	Wed Dec 04 04:57:01 2002 +0000
@@ -32,6 +32,7 @@
 #include <cstring>
 
 #include <string>
+#include <stack>
 
 #ifdef HAVE_UNISTD_H
 #ifdef HAVE_SYS_TYPES_H
@@ -40,8 +41,6 @@
 #include <unistd.h>
 #endif
 
-#include "SLStack.h"
-
 #include "cmd-edit.h"
 #include "quit.h"
 #include "lo-sstream.h"
@@ -87,7 +86,7 @@
 //
 // XXX FIXME XXX -- this should really be static, but that causes
 // problems on some systems.
-SLStack <token*> token_stack;
+std::stack <token*> token_stack;
 
 // Did eat_whitespace() eat a space or tab, or a newline, or both?
 
@@ -99,29 +98,36 @@
 
 // Is the closest nesting level a square bracket, squiggly brace or a paren?
 
-class bracket_brace_paren_nesting_level : public SLStack <int>
+class bracket_brace_paren_nesting_level
 {
 public:
 
-  bracket_brace_paren_nesting_level (void) : SLStack<int> () { }
+  bracket_brace_paren_nesting_level (void) : context () { }
 
   ~bracket_brace_paren_nesting_level (void) { }
 
-  void bracket (void) { push (BRACKET); }
-  bool is_bracket (void) { return ! empty () && top () == BRACKET; }
-
-  void brace (void) { push (BRACE); }
-  bool is_brace (void) { return ! empty () && top () == BRACE; }
-
-  void paren (void) { push (PAREN); }
-  bool is_paren (void) { return ! empty () && top () == PAREN; }
-
-  bool none (void) { return empty (); }
-
-  void remove (void) { if (! empty ()) SLStack<int>::pop (); }
+  void bracket (void) { context.push (BRACKET); }
+  bool is_bracket (void)
+    { return ! context.empty () && context.top () == BRACKET; }
+
+  void brace (void) {  context.push (BRACE); }
+  bool is_brace (void)
+    { return ! context.empty () && context.top () == BRACE; }
+
+  void paren (void) {  context.push (PAREN); }
+  bool is_paren (void)
+    { return ! context.empty () && context.top () == PAREN; }
+
+  bool none (void) { return context.empty (); }
+
+  void remove (void) { if (! context.empty ()) context.pop (); }
+
+  void clear (void) { while (! context.empty ()) context.pop (); }
 
 private:
 
+  std::stack<int> context;
+
   enum { BRACKET = 1, BRACE = 2, PAREN = 3 };
 
   bracket_brace_paren_nesting_level (const bracket_brace_paren_nesting_level&);
@@ -819,7 +825,10 @@
   // Clear out the stack of token info used to track line and column
   // numbers.
   while (! token_stack.empty ())
-    delete token_stack.pop ();
+    {
+      delete token_stack.top ();
+      token_stack.pop ();
+    }
 
   // Can be reset by defining a function.
   if (! (reading_script_file || reading_fcn_file))