X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fscanner.c;h=abf472e88998cdf5b974eb0c358ab71b49cd32ef;hp=0baac820d741088c2330c1a9a0dbb57806dd5bf2;hb=78ec1b2aecefbd7f6839f54c52b2dd6e3f80bf1a;hpb=098067796d5d9e7f30451608c054e5dd30c85775 diff --git a/src/scanner.c b/src/scanner.c index 0baac82..abf472e 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -20,6 +20,7 @@ #include //chdir #include //opendir #include //unicode strings +#include //strlen /* Internal */ #include "parser.tab.h" /* Public */ @@ -30,11 +31,12 @@ int scanner_scandir(DIR*); yypstate* apc_pstate; yycstate* apc_cstate; /* Private */ -extern //lexer.c -int lexer_lexfile(uint8_t const*); extern //lexer.rl -int lexer_lexstring(uint8_t const*, int); -#define PUSHTOK(T,L) yypush_parse(apc_pstate, T, L, apc_cstate) +int lexer_lexfile(uint8_t*); +extern //lexer.rl +int lexer_lexdir(uint8_t*); +extern //lexer.rl +void lexer_closedir(void); /* Init Establishes yy states @@ -45,7 +47,7 @@ int scanner_init scanner_quit(); apc_pstate = yypstate_new(); apc_cstate = yycstate_new(); - return (apc_pstate != NULL && apc_cstate != NULL); + return (apc_pstate == NULL || apc_cstate == NULL); } /* Quit @@ -95,23 +97,22 @@ int scanner_scandir switch (direntp->d_type) { case DT_REG: printf("lexfile %s\n",direntp->d_name); - //lexer_lexfile((uint8_t*)direntp->d_name); + lexer_lexfile((uint8_t*)direntp->d_name); goto scan_next_dirent; case DT_DIR: - //lexer_lexstring((uint8_t*)direntp->d_name); //lex the dirname + lexer_lexdir((uint8_t*)direntp->d_name); //lex the dirname printf("lexdir %s\n",direntp->d_name); if (chdir(direntp->d_name)) //change to the specified dir goto libfail; errno = 0; if ((cdirp = opendir(".")) == NULL || errno) //open it goto libfail; - //PUSHTOK(CLOPEN, 0); //push "Open Directory" token printf("Scanner entered [%s]\n",direntp->d_name); if(scanner_scandir(cdirp)) //scan the directory goto libfail; if (chdir("..")) //return to the parent dir goto libfail; - //PUSHTOK(CLCLOSE, 0); //push "Close Directory" token + lexer_closedir(); //push "Close Directory" token printf("Scanner returned\n"); goto scan_next_dirent; //continue scan case DT_UNKNOWN: