Starting with the lexer, i'm starting to comprehend better what pratt parsing is and how to apply it. For now just declaring basic structure and functions
This commit is contained in:
27
src/parser.c
27
src/parser.c
@@ -0,0 +1,27 @@
|
||||
#include "parser.h"
|
||||
#include "lexer.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
size_t node_lbp(Operator op) {
|
||||
switch (op) {
|
||||
case OP_ADD:
|
||||
case OP_SUB:
|
||||
return 10;
|
||||
break;
|
||||
case OP_DIV:
|
||||
case OP_MUL:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
size_t node_rbp(Operator op) {
|
||||
switch (op) {
|
||||
case OP_ADD:
|
||||
case OP_SUB:
|
||||
return 10;
|
||||
break;
|
||||
case OP_DIV:
|
||||
case OP_MUL:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user