From f6a144987cc403de8ad6bddd055f756120f8d405 Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Wed, 17 Apr 2024 16:00:00 -0700 Subject: archival commit --- example/pushdown.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 example/pushdown.c (limited to 'example/pushdown.c') 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 -- cgit v1.3.1