Annotation of parser3/src/include/pa_stack.h, revision 1.5
1.1 paf 1: /*
1.5 ! paf 2: Parser
! 3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 4: Author: Alexander Petrosyan <paf@design.ru>
! 5:
! 6: $Id: pa_string.C,v 1.35 2001/03/10 12:12:51 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_STACK_H
10: #define PA_STACK_H
11:
12: #include "pa_array.h"
13:
14: class Stack : public Array {
15: public:
16:
1.2 paf 17: Stack(Pool& apool) : Array(apool), ftop(0) {
1.1 paf 18: }
19:
20: void push(Item *item) {
1.2 paf 21: if(ftop<size()) // cell is already allocated?
22: put(ftop, item); // use it
1.1 paf 23: else
24: *this+=item; // append it
1.2 paf 25: ftop++;
1.1 paf 26: }
27: Item *pop() {
1.2 paf 28: return get(--ftop);
1.1 paf 29: }
30:
1.4 paf 31: int top_index() { return ftop-1; }
32: Item *top_value() { return get(top_index()); }
1.2 paf 33:
1.1 paf 34: private:
35:
36: // deepest used index
1.2 paf 37: int ftop;
1.1 paf 38:
39: };
40:
41: #endif
E-mail: