module stack; static Sp $ Sp = 0$ static Ssize$ Ssize = 100$ static Stack $ Stack = newvect(Ssize)$ localf push $ localf pop $ def push(A) { if (Sp >= Ssize) {print("Warning: Stack overflow\nDiscard the top"); pop();} Stack[Sp] = A; Sp++; } def pop() { local A; if (Sp <= 0) {print("Stack underflow"); return 0;} Sp--; A = Stack[Sp]; return A; } endmodule; def demo() { print("----------------"); stack.push(1); stack.push(2); stack.push("cat"); print(stack.pop()); print(stack.pop()); print(stack.pop()); print("---------------"); } end$