X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=idl%2Fmain.c;h=b4eb459004a3974f731f49704fa30647d17f1e3c;hp=b132bbd3813f6e97029103abe845ace2305138f7;hb=9e0411db099e71409f0ee8a8f464aa34ac65c778;hpb=69008ba2a7733358974c8985caa2e5bcb1182fe1 diff --git a/idl/main.c b/idl/main.c index b132bbd..b4eb459 100644 --- a/idl/main.c +++ b/idl/main.c @@ -2,58 +2,34 @@ #include #include -static int TRACE; - -static void loop(PSI_Lexer *L, void *P) -{ - token_t t; - PSI_Token *T = NULL; - - if (TRACE) { - PSI_ParserTrace(stdout, "> "); - } - - while (-1 != (t = PSI_LexerScan(L))) { - if (!(T = PSI_TokenAlloc(L, t))) { - break; - } - - if (TRACE) { - printf("# Token: <%s>(%d)\n", T->text, t); - } +#include "parser.h" +#include "validator.h" - PSI_Parser(P, t, T, L); - } - PSI_Parser(P, 0, T, L); -} +static int TRACE; int main(int argc, char *argv[]) { - PSI_Lexer L; PSI_Parser P; PSI_Validator V; TRACE = !!getenv("TRACE"); - if (!PSI_LexerInit(&L, argv[1])) { - perror("Failed to init lexer"); - return 1; - } - if (!PSI_ParserInit(&P)) { + if (!PSI_ParserInit(&P, argv[1])) { perror("Failer to init parser"); return 1; } - while (PSI_ParserParse(&p, &L)); - - PSI_ParserFree(P, free); + while (-1 != PSI_ParserScan(&P)) { + PSI_ParserParse(&P, PSI_TokenAlloc(&P)); + }; + PSI_ParserParse(&P, NULL); - if (!PSI_ValidatorInit(&V, &L)) { + if (!PSI_ValidatorInit(&V, &P)) { perror("Failed to init validator"); return 2; } - PSI_LexerDtor(&L); + PSI_ParserDtor(&P); if (PSI_ValidatorValidate(&V)) { printf("Whoa! VALID.\n");