Annotation of parser3/src/include/pa_stack.h, revision 1.15
1.7 paf 1: /** @file
1.8 paf 2: Parser: stack class decl.
3:
1.12 paf 4: Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
1.13 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1 paf 6: */
7:
8: #ifndef PA_STACK_H
9: #define PA_STACK_H
1.15 ! paf 10:
! 11: static const char* IDENT_STACK_H="$Id: zzz $";
1.1 paf 12:
1.9 parser 13: #include "pa_config_includes.h"
1.1 paf 14: #include "pa_array.h"
15:
1.7 paf 16: /// simple stack based on Array
1.1 paf 17: class Stack : public Array {
18: public:
19:
1.2 paf 20: Stack(Pool& apool) : Array(apool), ftop(0) {
1.1 paf 21: }
22:
23: void push(Item *item) {
1.2 paf 24: if(ftop<size()) // cell is already allocated?
25: put(ftop, item); // use it
1.1 paf 26: else
27: *this+=item; // append it
1.2 paf 28: ftop++;
1.1 paf 29: }
30: Item *pop() {
1.2 paf 31: return get(--ftop);
1.1 paf 32: }
33:
1.4 paf 34: int top_index() { return ftop-1; }
1.14 paf 35: void top_index(int top_index) { ftop=top_index+1; }
1.4 paf 36: Item *top_value() { return get(top_index()); }
1.2 paf 37:
1.1 paf 38: private:
39:
40: // deepest used index
1.2 paf 41: int ftop;
1.1 paf 42:
43: };
44:
45: #endif
E-mail: