fixes
[henge/apc.git] / src / lexer.c
index 1550db9..362d62b 100644 (file)
@@ -28,6 +28,7 @@
 #include <dirent.h>
 
 /* Local */
+#include "apc.h"
 #include "parser.tab.h"
 #ifndef DE_STACKSIZE
 #define DE_STACKSIZE 1024
@@ -54,8 +55,6 @@ extern //scanner.c
 int         scanner_init(void);
 extern //scanner.c
 int         scanner(void);
-static inline
-int         dredge_current_depth(void);
 extern //bison
 YYSTYPE     yylval;
 static
@@ -114,7 +113,6 @@ int lexer_init
    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)
@@ -123,12 +121,13 @@ int lexer
     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,
@@ -154,10 +153,12 @@ int lexer
 /* 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);
@@ -168,8 +169,8 @@ void lexer_pushtok
 /* 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];
@@ -198,7 +199,7 @@ uint8_t const* lexer_get_current_filepath
 { 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;
     }
@@ -208,7 +209,8 @@ uint8_t const* lexer_get_current_filepath
 /* 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;
   
@@ -221,7 +223,7 @@ int lexer_lexfilename
   /* 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());