-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
41 lines (38 loc) · 850 Bytes
/
main.c
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
38
39
40
41
/*
* main.c
*
* Created on: 23-Feb-2023
* Author: user
*/
#include <stdio.h>
#include <stdlib.h>
#include "Token/token.h"
#include "Lexer/lexer.h"
#include "Parser/parser.h"
#include "util/ast_helper.h"
int main() {
printf("Hello World\n");
FILE* file = fopen("source.slang","r");
if (file==NULL) {
printf("Error While Opening the file\n");
return -1;
}
Lexer *lexer = CreateLexer();
lexer->LexerInit(lexer,file);
Parser* parser = CreateParser();
parser->ParserInit(parser,lexer);
Ast* ast = parser->parseStatements(parser);
print_ast(ast,0);
// for (int i=0;i<11;i++) {
// Ast* ast1 = parser->parseStatement(parser);
// if (ast1!=NULL) {
// if (ast1->asttype == IFS) {
// printf("If statement\n");
// }
// print_ast(ast1, 0);
//
// }
// }
printf("Symbol Table Size : %d\n",parser->symtab->max);
return 1;
}