From: ken Date: Sat, 22 Oct 2016 19:45:02 +0000 (-0700) Subject: FIFO pop for dirent stack X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=commitdiff_plain;h=b8ef2143830953689f30e3bb4460d0d23bd5dcfd FIFO pop for dirent stack --- diff --git a/src/apc/lexer.c b/src/apc/lexer.c index 096016a..53b0c44 100644 --- a/src/apc/lexer.c +++ b/src/apc/lexer.c @@ -34,7 +34,7 @@ int lexer(void); int lexer_lexfile(const char*); void lexer_pushtok(int, YYSTYPE); char const* lexer_get_current_filepath(void); -struct dirent* lexer_direntpa[DE_STACKSIZE], **lexer_direntpp; +struct dirent* lexer_direntpa[DE_STACKSIZE],** lexer_direntpp,** lexer_direntpb; /* Private */ extern //lexer_lex.rl int lexer_lex(const char*); @@ -58,13 +58,14 @@ struct tok Simple array for keeping track of dirents yet to be processed by the scanner. If this list is empty and there are no tokens, the lexer is done. This array is populated by the scanner as an array, and popped locally by the - lexer as a stack. + lexer as a stack, and is popped as a FIFO stack. */ #define DE_STACK (lexer_direntpa) #define DE_STACKP (lexer_direntpp) -#define DE_LEN() (DE_STACKP - DE_STACK) -#define DE_INIT() (DE_STACKP = DE_STACK) -#define DE_POP() (*--DE_STACKP) +#define DE_STACKB (lexer_direntpb) +#define DE_LEN() (DE_STACKP - DE_STACKB) +#define DE_INIT() (DE_STACKP = DE_STACKB = DE_STACK) +#define DE_POP() (*DE_STACKB++) /* Token Stack This is a FIFO stack whose pointers are a union of either a pointer to an @@ -114,7 +115,7 @@ int lexer start: while (DE_LEN() > 0) //lex any directory entries in our stack if (lexer_lexfile(DE_POP()->d_name) == 0) - FAIL("Lexer failed to tokenize [%s]\n",(*DE_STACKP)->d_name); + FAIL("Lexer failed to tokenize [%s]\n",(*DE_STACKB)->d_name); if (TK_EMPTY) //if there are no tokens, { TK_INIT(); //initialize the token stack back to 0 switch (scanner())