summaryrefslogtreecommitdiffstats
path: root/example/pushdown.c
blob: ada8d73f9ac225431641030bd42ff1e03b8c748d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
typedef double pushdown_value_t;
#define STACK_IMPLEMENTATION
#define PUSHDOWN_IMPLEMENTATION
#include "../include/pushdown.h"

int main() {
  pushdown_instruction_t instructions[] = {PUSH, COPY, MUL, END};

  stack_t input = {};
  stack_t output = {};

  stack_init(&input);
  stack_init(&output);

  stack_push(&input, 4.0);

  pushdown_run(&output, &input, instructions);

  while (output.size) {
    printf("%lf\n", stack_pop(&output));
  }
}