Context algorithm
Semi-predictive context algorithm implementation
 All Data Structures Files Functions Variables Typedefs Macros Pages
stack.h
Go to the documentation of this file.
1 /* Copyright 2013 Jorge Merlino
2 
3  This file is part of Context.
4 
5  Context is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Context is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Context. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef STACK_H
20 #define STACK_H
21 
22 #include <assert.h>
23 #include "spacedef.h"
24 #include "debug.h"
25 
30 #define NOTSTACKEMPTY (stacktop > 0)
31 
32 
37 #define PUSHNODE(N)\
38  if(stacktop >= stackalloc)\
39  {\
40  stackalloc += 100;\
41  REALLOC(stack,stack,Uint,stackalloc);\
42  }\
43  assert(stack != NULL);\
44  stack[stacktop++] = N
45 
46 
51 #define POPNODE(N)\
52  N = stack[--stacktop]
53 
54 #endif