diff options
| author | Ethan Werner <mail@ethanwerner.com> | 2024-04-17 16:00:00 -0700 |
|---|---|---|
| committer | Ethan Werner <mail@ethanwerner.com> | 2026-06-08 16:01:49 +0400 |
| commit | f6a144987cc403de8ad6bddd055f756120f8d405 (patch) | |
| tree | 3b4cfc8c76db7adba8504dc0e079466e2a0d336c /example/pushdown.c | |
archival commit
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 |