2 \brief lexical analyzer implementation for APC
3 \details The lexer manages two FIFO stacks. One for maintaining tokens, the
4 other for maintaining a list of files to be scanned. During
5 execution, the lexer will return a token from its token queue if any
6 are present. If not, the lexer will will pop an element from its
7 file queue to 'scanner' to be tokenized. If the file queue is empty,
8 the lexer will instead call 'parsedir' to traverse the directory tree
9 and tokenize the results. If 'parsedir' does not generate any new
11 \author Jordan Lavatai
13 ----------------------------------------------------------------------------*/
30 #include "parser.tab.h"
32 int lexer_lexfile(uint8_t const*);
35 int lexer_lexstring(uint8_t const*, int);
40 #define PUSHTOK(T,L) yypush_parse(apc_pstate, T, L, apc_cstate)
42 /* Lexical analysis of a file
43 Strips a filename to its base name, then sends it to lexer_lexstring before
44 pushing a PATH token with the filename
45 Returns the number of tokens pushed to the parser.
48 ( uint8_t const* filename
)
49 { uint8_t const* last_period
,* iter
;
52 for (iter
= filename
; *iter
; iter
++)
56 { ntok
= lexer_lexstring(filename
, (int)(last_period
- filename
));
57 PUSHTOK(PATH
,filename
);
60 return lexer_lexstring(filename
, (int)(iter
- filename
));