cleanup
[m6w6/ext-psi] / idl / main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "parser.h"
6 #include "validator.h"
7
8 int main(int argc, char *argv[])
9 {
10 PSI_Parser P;
11 PSI_Validator V;
12 unsigned flags = 0;
13
14 if (getenv("TRACE")) {
15 flags |= PSI_PARSER_DEBUG;
16 }
17
18 if (!PSI_ParserInit(&P, argv[1], flags)) {
19 perror("Failer to init parser");
20 return 1;
21 }
22
23 while (-1 != PSI_ParserScan(&P)) {
24 PSI_ParserParse(&P, PSI_TokenAlloc(&P));
25 };
26 PSI_ParserParse(&P, NULL);
27
28 if (!PSI_ValidatorInit(&V, &P)) {
29 perror("Failed to init validator");
30 return 2;
31 }
32
33 PSI_ParserDtor(&P);
34
35 if (PSI_ValidatorValidate(&V)) {
36 printf("Whoa! VALID.\n");
37 }
38 PSI_ValidatorDtor(&V);
39
40 return 0;
41 }