refactor-lexer #11

Merged
laentropia merged 6 commits from refactor-lexer into main 2026-05-12 20:08:39 -06:00
2 changed files with 12 additions and 1 deletions
Showing only changes of commit e30b3d7175 - Show all commits

View File

@@ -32,8 +32,8 @@ typedef struct {
ASTNode *nud(ArraySlice *slice); ASTNode *nud(ArraySlice *slice);
ASTNode *led(ArraySlice *slice, size_t right_precedence); ASTNode *led(ArraySlice *slice, size_t right_precedence);
uint8_t prefix_lbp(ASTNode node);
uint8_t prefix_rbp(ASTNode node); uint8_t prefix_rbp(ASTNode node);
uint8_t postfix_lbp(ASTNode node);
uint8_t infix_lbp(ASTNode node); uint8_t infix_lbp(ASTNode node);
uint8_t infix_rbp(ASTNode node); uint8_t infix_rbp(ASTNode node);

View File

@@ -87,6 +87,17 @@ ASTNode *parse_expr(ArraySlice *slice, Arena *arena, uint8_t min_bp) {
) )
); );
// if is unary then take prefix bp and continue
// to the right, no need to allocate left side
// because we just did and right side
// WILL return a valid allocated pointer.
if (left_side->type == NODE_UNARY_OP) {
uint8_t rbp = prefix_rbp(*left_side);
ASTNode *righ_side = parse_expr(slice, arena, rbp);
left_side->data.unary.val = righ_side;
return left_side;
}
// Should check if is Integer or number // Should check if is Integer or number
arrayslice_next(slice, left_side); arrayslice_next(slice, left_side);