vsig_scan.l 1.6 KB
/* vsig_scan.l - Tokenizer */

%p 6500
%a 4200
%o 4700

digit		[0-9]
hexdigit	[0-9a-fA-F]
alpha		[a-z_A-Z]
dot		[.]
blank		[ ]
underscore	[_]
percent		[%]
colon		[:]
lbrk		[\[]
rbrk		[\]]
number		{digit}+
hex		0x{hexdigit}+
input		[@][Ii]
output		[@][Oo]
bidir 		[@][Bb]
tri   		[@][Tt]
edge  		[@][Ee]
strobe		[@][Ss]
clock		[@][Cc]
valid		[@][Vv]
ident		({alpha}|{dot}|{underscore})*{alpha}({alpha}|{digit}|{dot}|{underscore})*
comment		#[^\n]*\n
quote		[\"]
endofline	[\n]
skip		[ \t]
backslash	[\\]

%%
{number}	{ install_number(yytext, 10); return (tNUMBER);	}
{hex}		{ install_number(yytext, 16); return (tHEX);	}
{input}		{ return (tINPUT);	}
{output}	{ return (tOUTPUT);	}
{bidir}		{ return (tBIDIR);	}
{tri}		{ return (tTRI);	}
{edge}		{ return (tEDGE);	}
{strobe}	{ return (tSTROBE);	}
{clock}		{ return (tCLOCK);	}
{valid}		{ return (tVALID);	}
{quote}		{ return (tQUOTE);	}
{colon}		{ return (tCOLON);	}
{percent}	{ return (tPERCENT);	}
{lbrk}		{ return (tLBRACK);	}
{rbrk}		{ return (tRBRACK);	}
{ident}		{ install(yytext); return (tIDENT);	}

{backslash}	{ int c;  while ( (c = input()) != '\n' &&
		   		c != EOF )
				;  /* eat up input til next line */
		}
{endofline}	{ line_num++; return (tEOL);	}
{comment}	{ fprintf(Vecfp, "%s", yytext); }
{skip}		;
.		{ return (tJUNK);	}
%%

int yywrap()
{
   return(1);
}


void install_number(char *str, int base)
{
   yylval.ival =  strtol(str, NULL, base); 
}


void install(char *str)
{
   (void) strncpy(yylval.name, str, TOKENSIZ-1);
   yylval.name[TOKENSIZ-1] = '\0';
}

void
  yyerror(str)
char *str;
{
  fprintf(stderr,"******* Error line: %d *********\n", line_num);
}