X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fapc%2Flexer.c;h=940ee8163968151c90e9ec508e81ba722265ad3b;hp=096016a12664f76612411bd0fc7ca51e2f1bffff;hb=957d4c384203bdc325c81a594943a5790dcb32aa;hpb=66dd1e5964dfc973afefb8fb7e2b9c5ad156c67c diff --git a/src/apc/lexer.c b/src/apc/lexer.c index 096016a..940ee81 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 @@ -90,6 +91,7 @@ int lexer_init () { TK_INIT(); DE_INIT(); + current_filename = NULL; return scanner_init(); } @@ -114,7 +116,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())