Read a pratt parsing article, i think i can do it, got nud and led the right way i think
This commit is contained in:
@@ -4,11 +4,14 @@ typedef struct {
|
||||
ASTNode *head;
|
||||
} AST;
|
||||
|
||||
typedef enum {
|
||||
PARSER_NUD, // Null Denotation
|
||||
PARSER_LED, // Left Denotation
|
||||
} ParserState;
|
||||
typedef struct {
|
||||
ASTNodeArray *arr;
|
||||
size_t pos;
|
||||
} ASTNodeSlice;
|
||||
|
||||
size_t node_lbp(Operator op);
|
||||
size_t node_rbp(Operator op);
|
||||
ASTNode *nud(ASTNodeSlice *slice, size_t pos);
|
||||
ASTNode *led(ASTNodeSlice *slice, size_t pos, size_t right_precedence);
|
||||
|
||||
size_t node_lbp(ASTNode node);
|
||||
size_t node_rbp(ASTNode node);
|
||||
AST parse(ASTNodeArray arr);
|
||||
|
||||
Reference in New Issue
Block a user