X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=idl%2Fmain.c;h=c4664be36b45d426523d69d9487a0bfb0f0520ea;hp=6732b7dbac8b1a2b46b6e5f0861a35d1243b54cd;hb=c6d07b29eac45a9dc6f121b6a636ff32bc7609a3;hpb=6ed7825ca4ddea88b00968e20cbaeeb1e8eb3de4 diff --git a/idl/main.c b/idl/main.c index 6732b7d..c4664be 100644 --- a/idl/main.c +++ b/idl/main.c @@ -1,10 +1,10 @@ #include #include #include -#include "lexer.h" -#include "parser.h" -static volatile int TRACE; +#include "main.h" + +static int TRACE; static void loop(PSI_Lexer *L, void *P) { @@ -16,12 +16,14 @@ static void loop(PSI_Lexer *L, void *P) } while (-1 != (t = PSI_LexerScan(L))) { - T = PSI_TokenAlloc(L, t); + if (!(T = PSI_TokenAlloc(L, t))) { + break; + } if (TRACE) { printf("# Token: <%s>(%d)\n", T->text, t); } - + PSI_Parser(P, t, T, L); } PSI_Parser(P, 0, T, L); @@ -30,6 +32,7 @@ static void loop(PSI_Lexer *L, void *P) int main(int argc, char *argv[]) { PSI_Lexer L; + PSI_Validator V; void *P = PSI_ParserAlloc(malloc); TRACE = !!getenv("TRACE"); @@ -42,7 +45,18 @@ int main(int argc, char *argv[]) loop(&L, P); PSI_ParserFree(P, free); + + if (!PSI_ValidatorInit(&V, &L)) { + perror("Failed to init validator"); + return 2; + } + PSI_LexerDtor(&L); + if (PSI_ValidatorValidate(&V)) { + printf("Whoa! VALID.\n"); + } + PSI_ValidatorDtor(&V); + return 0; }