+/* Lexical analysis of a file
+ Strips a filename to its base name, then sends it to lexer_lexstring before
+ pushing a PATH token with the filename
+ Returns the number of tokens pushed to the parser.
+*/
+int lexer_lexfile
+( uint8_t* filename )
+{ uint8_t* last_period,* iter,* filename_end;
+ int ntok;
+ last_period = NULL;
+ for (iter = filename; *iter; iter++)
+ switch (*iter)
+ { // Keep track of the last 'dot' in the name
+ case '.' : last_period = iter; continue;
+ // replace '_' with '\0' so bison can use strlen on them as tokens.
+ case '_' : *iter = '\0';
+ default: continue;
+ }
+ // Mark the end of the filename
+ filename_end = iter;
+ // Lex from either the last period, if present, or filename end
+ ntok = (last_period) ?
+ lexer_lexstring(filename, (int)(last_period - filename))
+ : lexer_lexstring(filename, (int)(iter - filename));
+ // Replace nulls with their original '_'
+ for (iter = filename; iter < filename_end; iter++)
+ if (*iter == '\0')
+ *iter = '_';
+ PUSHPATH(filename);
+ return ntok + 1;
+ return en_main == 1;
+}
+
+int lexer_lexdir
+( uint8_t* dirname )
+{ uint8_t* de = dirname;
+ int ntok;
+ ntok = 0;
+ de = dirname;
+ if (*de) while (*++de);
+ ntok = lexer_lexstring(dirname, (int)(de - dirname));
+ PUSHOP(CLOPEN);
+ return ntok;
+}
+
+int lexer_closedir
+( void )
+{ int ntok = 0;
+ PUSHOP(CLCLOSE);
+ return ntok;
+}