/* Public */
int lexer_init(void);
int lexer(void);
+int lexer_lexfile(const char*);
void lexer_pushtok(int, YYSTYPE);
extern //lexer_lex.rl
int lexer_lex(const char*);
()
{start:
while (DE_LEN() > 0) //lex any directory entries in our stack
- if (lexer_lex(DE_POP()->d_name) == 0) //fail if it generates no tokens
+ if (lexer_lexfile(DE_POP()->d_name) == 0)
FAIL("Lexer failed to tokenize [%s]\n",(*DE_STACKP)->d_name);
if (TK_EMPTY) //if there are no tokens,
{ TK_INIT(); //initialize the token stack back to 0
TK_PUSH(tok, lval);
printf("Pushed Token %i | %i\n", TK_STACK[TK_LEN() - 1].tok_t, TK_STACK[TK_LEN() - 1].lval.val);
}
+
+/* Lexical analysis of a file
+ Strips a filename to its base name, then sends it to lexer_lex
+*/
+int lexer_lexfile
+#define MAX_FNAME 2048
+#define HIDDEN_WARNING "%s is hidden and will not be parsed!\n", filename
+( const char *filename
+)
+{ static char fname[MAX_FNAME];
+ char *last_period = NULL, *iter;
+
+ if (*filename == '.')
+ { fprintf (stderr, HIDDEN_WARNING);
+ return 0;
+ }
+ strncpy(fname,filename,MAX_FNAME);
+ last_period = NULL;
+ for (iter = fname; *iter; iter++)
+ if (*iter == '.')
+ last_period = iter;
+ if (last_period)
+ *last_period = '\0';
+ return lexer_lex(fname);
+}