summaryrefslogtreecommitdiffstats
path: root/example/pushdown.c
diff options
context:
space:
mode:
Diffstat (limited to 'example/pushdown.c')
-rw-r--r--example/pushdown.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/example/pushdown.c b/example/pushdown.c
index ada8d73..bd34bb8 100644
--- a/example/pushdown.c
+++ b/example/pushdown.c
@@ -1,13 +1,20 @@
-typedef double pushdown_value_t;
+// pushdown.c - Example usage of pushdown.h stack automaton
+
+#include <stdio.h>
+
+typedef double stack_value_t;
#define STACK_IMPLEMENTATION
+#include "../include/stack.h"
+
+typedef double pushdown_value_t;
#define PUSHDOWN_IMPLEMENTATION
#include "../include/pushdown.h"
int main() {
pushdown_instruction_t instructions[] = {PUSH, COPY, MUL, END};
- stack_t input = {};
- stack_t output = {};
+ stack_t input = {0};
+ stack_t output = {0};
stack_init(&input);
stack_init(&output);
@@ -19,4 +26,7 @@ int main() {
while (output.size) {
printf("%lf\n", stack_pop(&output));
}
+
+ stack_free(&input);
+ stack_free(&output);
} \ No newline at end of file