diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
| commit | 73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch) | |
| tree | e299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/evalexpr/src/evalexpr.h | |
| parent | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff) | |
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/evalexpr/src/evalexpr.h')
| -rw-r--r-- | rushs/evalexpr/src/evalexpr.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/rushs/evalexpr/src/evalexpr.h b/rushs/evalexpr/src/evalexpr.h new file mode 100644 index 0000000..d440ae1 --- /dev/null +++ b/rushs/evalexpr/src/evalexpr.h @@ -0,0 +1,43 @@ +#ifndef EVALEXPR_H +#define EVALEXPR_H + +#include <stddef.h> + +#include "fifo.h" +#include "stack.h" +#include "stack_struct.h" + +enum token_type +{ + NUMBER = 0, + SUB = 1, + ADD = 1, + MOD = 2, + DIV = 2, + MUL = 2, + EXP = 3, + UN_PLUS = 4, + UN_MINUS = 4, + PAR_LEFT = 5, + PAR_RIGHT = 5, + WRONG_TOKEN = -1, +}; + +struct token +{ + enum token_type type; + int value; +}; + +// evalrpn +int parse_number(const char *expr, size_t *offset); +int get_operands(struct stack **s, int *op1, int *op2); +int my_pow(int a, int b); +int evalrpn(const char *expr, int *retval); + +// shunting yard +int opcmp(struct token *op1, struct token *op2); +enum token_type get_type(char op); +int shunting_yard(const char *expr, char **rpn); + +#endif /* ! EVALEXPR_H */ |
