-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (46 loc) · 1.2 KB
/
main.cpp
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
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <string>
#include "ast.h"
#include "converter.h"
// stuff from lex that yacc needs to know about:
using namespace std;
extern int yyparse();
extern FILE *yyin;
extern void init_content_children();
extern void init_list_children();
extern void init_section_children();
extern void init_subsection_children();
extern void init_rows_children();
extern void init_r_content_children();
extern void init_cell_children();
extern void init_figure_children();
extern void init_math_children();
extern void print(ast_node*, int);
ast_node* root;
void yyerror(const char *s) {
cout<<"Parse error! Message:"<<s<<endl;
// might as well halt now:
exit(-1);
}
int main(int argc, char *argv[]) {
if(argc<2){
cout<<"error in entering arguments. Correct Format: /compiler <input.txt>";
}
yyin = fopen(argv[1], "r");
init_content_children();
init_list_children();
init_section_children();
init_subsection_children();
init_rows_children();
init_r_content_children();
init_cell_children();
init_figure_children();
init_math_children();
// parse through the input until there is no more:
do {
yyparse();
} while (!feof(yyin));
converter C;
string s = C.traversal(root);
C.printHTML(s);
}