diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /myfind/ast_evaluation/main.c | |
Diffstat (limited to 'myfind/ast_evaluation/main.c')
| -rw-r--r-- | myfind/ast_evaluation/main.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/myfind/ast_evaluation/main.c b/myfind/ast_evaluation/main.c new file mode 100644 index 0000000..2794cd9 --- /dev/null +++ b/myfind/ast_evaluation/main.c @@ -0,0 +1,24 @@ +#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "expression.h"
+#include "parser.h"
+
+int eval_expr(struct my_expr *expr);
+
+int main(int argc, char **argv)
+{
+ static struct my_expr *expr = NULL;
+
+ if (argc < 2)
+ errx(1, "Usage: %s <token> ([token] ...)", argv[0]);
+
+ unsigned args_length = argc - 1;
+ expr = parse_expr(argv + 1, args_length);
+
+ printf("%d\n", eval_expr(expr));
+
+ free_expr(expr);
+ return 0;
+}
|
