projects
/
henge
/
webcc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
967fb6e
)
FIFO pop for dirent stack
author
ken
<ken@mihrtec.com>
Sat, 22 Oct 2016 19:45:02 +0000
(12:45 -0700)
committer
ken
<ken@mihrtec.com>
Sat, 22 Oct 2016 19:45:02 +0000
(12:45 -0700)
src/apc/lexer.c
patch
|
blob
|
history
diff --git
a/src/apc/lexer.c
b/src/apc/lexer.c
index
096016a
..
53b0c44
100644
(file)
--- 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);
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*);
/* 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
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_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
/* 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)
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_STACK
P
)->d_name);
+ FAIL("Lexer failed to tokenize [%s]\n",(*DE_STACK
B
)->d_name);
if (TK_EMPTY) //if there are no tokens,
{ TK_INIT(); //initialize the token stack back to 0
switch (scanner())
if (TK_EMPTY) //if there are no tokens,
{ TK_INIT(); //initialize the token stack back to 0
switch (scanner())