#include <dirent.h>
/* Local */
+#include "apc.h"
#include "parser.tab.h"
#ifndef DE_STACKSIZE
#define DE_STACKSIZE 1024
int scanner_init(void);
extern //scanner.c
int scanner(void);
-static inline
-int dredge_current_depth(void);
extern //bison
YYSTYPE yylval;
static
printing is skipped. In all other cases, 'yylval' is set, and the token's
integer representation is returned.
*/
-int lexer
#define $($)#$
#define SCAN_ERROR -1
#define TK_EMPTY (TK_STACKP == TK_STACKX)
fprintf(stderr,__VA_ARGS__); \
goto done; \
} while (0)
+int lexer
()
{ struct tok token;
start:
while (DE_LEN() > 0)//lex any directory entries in our stack
{
- if (lexer_lexfile(DE_POP()->d_name) == 0)
+ if (lexer_lexfile((uint8_t*)DE_POP()->d_name) == 0)
FAIL("Lexer failed to tokenize [%s]\n",(*DE_STACKB)->d_name);
}
if (TK_EMPTY) //if there are no tokens,
/* Token Receiver
This receiver takes a struct tok and pushes it to the FIFO stack.
*/
-void lexer_pushtok
#define $($)#$ //stringifier
#define ERR_TK "Fatal: Generated over " $(TK_STACKSIZE) " tokens in one pass."
-( int tok, YYSTYPE lval )
+void lexer_pushtok
+( int tok,
+ YYSTYPE lval
+)
{ if (TK_LEN() >= TK_STACKSIZE)
{ fprintf(stderr, ERR_TK);
exit(EXIT_FAILURE);
/* Lexical analysis of a file
Strips a filename to its base name, then sends it to lexer_lex
*/
-int lexer_lexfile
#define HIDDEN_WARNING "%s is hidden and will not be parsed!\n", filename
+int lexer_lexfile
( const uint8_t *filename
)
{ static uint8_t fname[FNAME_MAX];
{ static uint8_t current_path[FPATH_MAX];
static uint8_t const* last_filename;
if ((!last_filename || last_filename != current_filename) &&
- ((uint8_t*) realpath(current_filename, current_path) != (uint8_t*) current_path))
+ ((uint8_t*) realpath((char*)current_filename, (char*)current_path) != (uint8_t*) current_path))
{ perror("realpath: ");
return NULL;
}
/* Scan filename and push the its tokens
onto the stack */
int lexer_lexfilename
-(uint8_t* str)
+( uint8_t* str
+)
{ int ntok, len;
uint8_t *filepath;
/* Determine the filetype of str */
len = u8_strlen(str);
- ntok += lexer_lexstring(str, len);
+ ntok = lexer_lexstring(str, len);
/* Pass back filepath as end of statment operator */
filepath = u8_strdup(lexer_get_current_filepath());