Done with helpers, need some function to actually print the tree and see for myself if it works wit simple symbols
This commit is contained in:
18
src/parser.c
18
src/parser.c
@@ -1,5 +1,6 @@
|
|||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@@ -37,7 +38,24 @@ uint8_t node_rbp(ASTNode node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASTNode ASTNodeSlice_next(ASTNodeSlice *slice) {
|
||||||
|
return slice->arr->data[slice->pos++];
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTNode ASTNodeSlice_peek(ASTNodeSlice *slice) {
|
||||||
|
return slice->arr->data[slice->pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ASTNodeSlice_is_valid(ASTNodeSlice *slice) {
|
||||||
|
if (slice->arr->len < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (slice->pos >= slice->arr->len - 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
AST parse(ASTNodeArray *arr) {
|
AST parse(ASTNodeArray *arr) {
|
||||||
AST tree;
|
AST tree;
|
||||||
|
|||||||
Reference in New Issue
Block a user