"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "xlab-0.8.3/parse.l" of archive xlab-0.8.3.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 /*
    2  * $Id: parse.l,v 1.4 1998/07/24 11:59:14 marc Exp $
    3  *
    4  * xlab command lexical analyzer
    5  *
    6  * (c) Marc Vertes 1997
    7  *
    8  */
    9 
   10 /* option for flex only */
   11 /* new flex version */
   12 %option noyywrap 
   13 /* #define yywrap()	{return 1;} 	 old flex version */
   14 
   15 %{
   16 #include <string.h>
   17 #include "y.tab.h"
   18 
   19 /* 
   20  * flex: redefine YY_INPUT to parse a buffer instead of standard input 
   21  * to do: make it portable for other lex flavors
   22  */
   23 extern char *mystring;
   24 
   25 #undef YY_INPUT
   26 #define YY_INPUT(buf, result, max_size) \
   27   { \
   28     int c = *mystring++; \
   29     result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
   30   }
   31 %}
   32 
   33 ws		[ \t]+
   34 nl		\n
   35 natural		[0-9]+
   36 sysstr		![[:print:]]+\n
   37 qstring		\"[^\"\n]*[\"\n]
   38 filename	[A-Za-z0-9/$:.\-\_]+
   39 
   40 %%
   41 
   42 {ws}		;
   43 record		{ return RECORD; }
   44 replay		{ return REPLAY; }
   45 stop		{ return STOP; }
   46 set		{ return SET; }
   47 debug		{ return DEBUG; }
   48 trace		{ return TRACE; }
   49 speed		{ return SPEED; }
   50 exit		{ return EXIT; }
   51 {sysstr}	{
   52                   yylval.string = (char *)strdup(yytext+1); /* skip exclamation mark (!) */
   53 		  return SYSSTR;
   54 		}
   55 {qstring}	{ 
   56                   yylval.string = (char *)strdup(yytext+1); /* skip open quote */
   57 		  if (yylval.string[yyleng - 2] != '"')
   58 		    printf("Unterminated character string");
   59                   else
   60                     yylval.string[yyleng - 2] = ' '; /* remove close quote */
   61                   return QSTRING;
   62 		}
   63 {natural}	{
   64 		  yylval.intval = atoi(yytext);
   65 		  return NATURAL;
   66                 }
   67 {filename}	{
   68 		  yylval.name = (char *)strdup(yytext);
   69 		  return FILENAME;
   70 		}
   71 .		{ return yytext[0]; }
   72