Two types of data structures used in a compiler are:
- Stack
- Heap
Stack
- The stack is a linear data structure.
- It follows LIFO (Last in First Out) rule.
- Each time a procedure is called, space for its local variables is pushed onto a stack, and when the procedure terminates, space is popped off the stack.
Heap
- The heap data structure permits allocation and deallocation of entities in a random order.
- Heap is nonlinear data structure.
- When a program makes an allocation request, the heap manager allocates a memory area and returns its address.
- The program is expected to save this address in a pointer and use it to access the allotted entity.
- When a program makes a deallocation request, the heap manager deallocates a memory area.