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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user