X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fapc%2Flexer.c;fp=src%2Fapc%2Flexer.c;h=53b0c44b3044f34d44797d2d3ee2fd981d6b989c;hp=096016a12664f76612411bd0fc7ca51e2f1bffff;hb=b8ef2143830953689f30e3bb4460d0d23bd5dcfd;hpb=967fb6e907a5fc14dac42c3d84faf7b494e1d6a5 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())