refactor: All of parser.c

DAMN, it wasn't that difficult, just bothers me a bit the part that
checks if both lbp and rbp of the infix are valid, like i do validation
twice but is fine i guess, maybe using an else?, i'll see if i change
it, for now i need to change the evaluator
This commit is contained in:
2026-05-13 11:09:22 -06:00
parent 80e05a9acf
commit 542a94ef81
2 changed files with 244 additions and 96 deletions

View File

@@ -11,9 +11,10 @@ typedef enum {
NODE_INT,
NODE_BINARY_OP,
NODE_UNARY_OP,
NODE_PARENTHESIS,
} NodeType;
typedef struct {
typedef struct Node {
NodeType type;
union {
int64_t num;
@@ -26,6 +27,7 @@ typedef struct {
Operator op;
struct Node *to;
}unary;
Operator par;
};
} Node;
@@ -64,6 +66,8 @@ typedef struct {
};
} ParserU8Result;
Node token_to_node(Token token);
ParserU8Result prefix_rbp(Node node);
ParserU8Result postfix_lbp(Node node);
ParserU8Result infix_lbp(Node node);