Use stl stack for for carrying scopes
This is rather a cosmetic change. The patch changes the container used for stack of scopes from std::list to std::stack. It suits this particular application a bit better.
This commit is contained in:
parent
21008f2ba9
commit
3764216a88
|
|
@ -34,6 +34,7 @@
|
||||||
# include <cstdarg>
|
# include <cstdarg>
|
||||||
# include <cstring>
|
# include <cstring>
|
||||||
# include <list>
|
# include <list>
|
||||||
|
# include <stack>
|
||||||
# include <map>
|
# include <map>
|
||||||
# include <vector>
|
# include <vector>
|
||||||
# include "parse_types.h"
|
# include "parse_types.h"
|
||||||
|
|
@ -69,7 +70,7 @@ int parse_sorrys = 0;
|
||||||
* manage lexical scopes.
|
* manage lexical scopes.
|
||||||
*/
|
*/
|
||||||
static ActiveScope*active_scope = new ActiveScope;
|
static ActiveScope*active_scope = new ActiveScope;
|
||||||
static list<ActiveScope*> scope_stack;
|
static stack<ActiveScope*> scope_stack;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When a scope boundary starts, call the push_scope function to push
|
* When a scope boundary starts, call the push_scope function to push
|
||||||
|
|
@ -81,7 +82,7 @@ static list<ActiveScope*> scope_stack;
|
||||||
static void push_scope(void)
|
static void push_scope(void)
|
||||||
{
|
{
|
||||||
assert(active_scope);
|
assert(active_scope);
|
||||||
scope_stack.push_front(active_scope);
|
scope_stack.push(active_scope);
|
||||||
active_scope = new ActiveScope (active_scope);
|
active_scope = new ActiveScope (active_scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,8 +90,8 @@ static void pop_scope(void)
|
||||||
{
|
{
|
||||||
delete active_scope;
|
delete active_scope;
|
||||||
assert(scope_stack.size() > 0);
|
assert(scope_stack.size() > 0);
|
||||||
active_scope = scope_stack.front();
|
active_scope = scope_stack.top();
|
||||||
scope_stack.pop_front();
|
scope_stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue