numsyms.re.c

// print numbers and symbols in stdin

#include <stdio.h>
#include <string.h>
typedef unsigned char uint8;

void
put(const uint8 *s, const uint8 *e)
{
   for (; s < e; s++)
      putchar(*s);
   putchar('\n');
}

void
sub(const uint8 *s)
{
   const uint8 *YYCURSOR = s;
   const uint8 *YYMARKER;
   const uint8 *YYLIMIT;
   for (;;) {
      YYLIMIT = s + strlen(s);
      /*!re2c
         re2c:yyfill:enable  = 0;
         re2c:define:YYCTYPE = uint8;
         re2c:eof = 0;
         re2c:indent:string = "   ";
         re2c:indent:top = 2;
         decc = [0-9];
         binc = [01];
	 b64c = [0-9a-zA-Z+/];
         hexc = [0-9a-fA-F];
         octc = [0-7];
         dec = '0' decc* ('_' decc+)*;
         bin = '2' binc* ('_' binc+)*;
         b64 = '4' b64c* ('_' b64c+)* '='{0,3};
         hex = '6' hexc* ('_' hexc+)*;
         oct = '8' octc* ('_' octc+)*;
         num = dec | bin | b64 | hex | oct;
	 ident = [a-z][0-9]* | ([A-Z][a-z0-9]+)+ | [a-z] '_' [a-z0-9]+;
	 paren = [(){}];
	 op = [-/=+*^.];
	 sym = ident | paren | op;
         num { put(s, YYCURSOR); s = YYCURSOR; continue; }
         sym { put(s, YYCURSOR); s = YYCURSOR; continue; }
         *   {                   s = YYCURSOR; continue; }
         $   { return; }
       */
   }
}

int
main(void)
{
   uint8 buf[256];
   while (fgets(buf, sizeof buf, stdin))
      sub(buf);
   return 0;
}