filename terminator is now a .
[henge/apc.git] / src / lexer.rl
index c7600ae..83915ec 100644 (file)
@@ -113,7 +113,7 @@ uint8_t   lval_offs;
   tok = (name | val | ref | dimensions | map | link | SS | direction);
   
 
-  main := (tok tok_delimiter)* tok [\0];
+  main := (tok tok_delimiter)* tok [.];
 
   write data nofinal noerror noprefix;
   
@@ -141,18 +141,11 @@ int lexer_lexstring
 { uint8_t* p, * ts, * pe, * eof;
   int cs, ntok;
   YYSTYPE lval;
-
   ntok = 0;
   p = ts = str;
   pe = eof =  p + size + 1;
-
-  dprintf("\n|---Begin lexstring on p = %U, pe = %p.---|\n",p, pe);
-
   %%write init;
   %%write exec;
-
-  dprintf("\n|---Ending lexstring of file %U, pushed %d tokens.---|\n",str, ntok);
-
   return ntok;
 }
 
@@ -166,6 +159,7 @@ int lexer_lexfile
 { uint8_t* last_period,* iter,* filename_end;
   int      ntok;
   last_period = NULL;
+  printf("size of file = %d\n", u8_strlen(filename));
   for (iter = filename; *iter; iter++)
     switch (*iter)
       { // Keep track of the last 'dot' in the name
@@ -177,14 +171,17 @@ int lexer_lexfile
   // Mark the end of the filename
   filename_end = iter;
   // Lex from either the last period, if present, or filename end
+  dprintf("%U\n\t",filename);
   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);
+  dprintf("\n\t[%i Token%s]\n", ntok, (ntok > 1) ? "s" : "");
   return ntok + 1;
 }
 
@@ -192,14 +189,18 @@ int lexer_lexdir
 ( uint8_t* dirname )
 { int ntok;
   ntok = 0;
+  if (DEBUG) putchar('\t');
   PUSHNAME(dirname);
   PUSHOP(CLOPEN);
+  if (DEBUG) putchar('\n');
   return ntok;
 }
 
 int lexer_closedir
 ( void )
 { int ntok = 0;
+  if (DEBUG) putchar('\t');
   PUSHOP(CLCLOSE);
+  if (DEBUG) putchar('\n');
   return ntok;
 }