semos/main.c
2024-04-05 04:14:35 +02:00

30 lines
710 B
C

#include "parser.h"
#include <stddef.h>
#include <stdio.h>
#include <string.h>
bool lexer_debug = false;
void print_error(const char* message, Pos pos)
{
fprintf(
stderr, "\x1b[31merror\x1b[0m: %s, on line %d\n", message, pos.line);
}
int main(void)
{
char test_program[] = " if a == true { (1) += 2; } ";
Parser parser;
parser_construct(&parser, test_program, strlen(test_program));
ASTNode* expr = parser_parse_statements(&parser);
printf("ast = %s\n", ast_node_type_string[expr->node_type]);
for (size_t i = 0; i < expr->statements.length; ++i) {
printf("ast[%ld] = %s\n", i,
ast_node_type_string[expr->statements.data[i]->node_type]);
}
}