b4eb459004a3974f731f49704fa30647d17f1e3c
[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 static int TRACE;
9
10 int main(int argc, char *argv[])
11 {
12 PSI_Parser P;
13 PSI_Validator V;
14
15 TRACE = !!getenv("TRACE");
16
17 if (!PSI_ParserInit(&P, argv[1])) {
18 perror("Failer to init parser");
19 return 1;
20 }
21
22 while (-1 != PSI_ParserScan(&P)) {
23 PSI_ParserParse(&P, PSI_TokenAlloc(&P));
24 };
25 PSI_ParserParse(&P, NULL);
26
27 if (!PSI_ValidatorInit(&V, &P)) {
28 perror("Failed to init validator");
29 return 2;
30 }
31
32 PSI_ParserDtor(&P);
33
34 if (PSI_ValidatorValidate(&V)) {
35 printf("Whoa! VALID.\n");
36 }
37 PSI_ValidatorDtor(&V);
38
39 return 0;
40 }