blob: f3147bbf423ad8a8c02ae4e3a2f55f47d3df3b0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <stdio.h>
#include <string.h>
#include "../include/parser.h"
int main() {
const char *code;
Parser parser;
BufferView code_view;
int result;
code =
"const main = () {\n"
" var hello = () {\n"
" \n"
" }\n"
" hello()\n"
"}\n"
"const print = () {\n"
" \n"
"}";
result = parser_init(&parser);
if(result != PARSER_OK) {
fprintf(stderr, "Failed to initialize parser\n");
return 1;
}
code_view = create_buffer_view(code, strlen(code));
result = parser_parse_buffer(&parser, code_view);
if(result != PARSER_OK) {
fprintf(stderr, "Failed to parse\n");
return 1;
}
/* No need to do this here as the program is exiting */
/* parser_deinit(&parser); */
return 0;
}
|