diff options
Diffstat (limited to 'example/pushdown.c')
| -rw-r--r-- | example/pushdown.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/example/pushdown.c b/example/pushdown.c new file mode 100644 index 0000000..ada8d73 --- /dev/null +++ b/example/pushdown.c @@ -0,0 +1,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)); + } +}
\ No newline at end of file |