%C
%e 5000
%p 10000
%n 5000
%k 5000
%a 5000
%o 5000
%{

/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/

static char sccsid_easn_lex[] = "@(#)easn.lex	1.5 11/6/92 07:29:50  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	8/13/90

	ROUTINE:	Lexical Analyzer for ASN.1_Encoder
			Compile with yacc++

PURPOSE:
	This is the lex spec. used to parse a ASN.1 raw-value specification. The
syntax allows the specification of an ASN.1 encoding without benefit of an
encoding specification. 

CALLED ROUTINES:
	
MODIFICATION HISTORY:


*/


#include "asn1.h"
#include <ctype.h>
#include <malloc.h>
#include <string.h>
#include "y.tab.h"

extern FILE	*listfile;
int vlinenumber=0;

extern YYSTYPE yylval;
void asn_error(char *,char *);

#define verror(X)	asn_error("Lexical Error",X)

void vecho();

%}

number		[0-9]+
hexnumber	[0-9a-fA-F][0-9a-fA-F]?


A		[Aa]
B		[Bb]
C		[Cc]
D		[Dd]
E		[Ee]
F		[Ff]
G		[Gg]
H		[Hh]
I		[Ii]
J		[Jj]
K		[Kk]
L		[Ll]
M		[Mm]
N		[Nn]
O		[Oo]
P		[Pp]
Q		[Qq]
R		[Rr]
S		[Ss]
T		[Tt]
U		[Uu]
V		[Vv]
W		[Ww]
X		[Xx]
Y		[Yy]
Z		[Zz]

%%

   extern YYSTYPE yylval;

{U}{N}{I}{V}{E}{R}{S}{A}{L}		{vecho(); return(UNIVERSAL);}
{C}{O}{N}{T}{E}{X}{T}			{vecho(); return(CONTEXT);}
{A}{P}{P}{L}{I}{C}{A}{T}{I}{O}{N}	{vecho(); return(APPLICATION);}
{P}{R}{I}{V}{A}{T}{E}			{vecho(); return(PRIVATE);}
{C}{O}{N}{S}{T}{R}{U}{C}{T}{E}{D}	{vecho(); return(CONSTRUCTED);}
{C}{O}{N}				{vecho(); return(CONSTRUCTED);}
{P}{R}{I}{M}{I}{T}{I}{V}{E}		{vecho(); return(PRIMITIVE);}
{P}{R}{I}{M}				{vecho(); return(PRIMITIVE);}


"("		{vecho(); return(LEFTPAREN);}
")"		{vecho(); return(RIGHTPAREN);}
"["		{vecho(); return(LEFTBRACKET);}
"]"		{vecho(); return(RIGHTBRACKET);}
"{"		{vecho(); return(LEFTBRACE);}
"}"		{vecho(); return(RIGHTBRACE);}
"..."		{vecho(); return(ELLIPSES);}

\t		vecho();
\n		vecho();
" "		vecho();

{number}		{
				vecho();
				yytext[yyleng] = 0;
				yylval.string = yytext;
				return(NUMBER);
			}

{hexnumber}		{
				vecho();
				yytext[yyleng] = 0;
				yylval.string = yytext;
				return(HEXNUMBER);
			}

"/*"			{ vecho();
			  yyleng = 1;
			  do
			  {
			     while ((*yytext=lex_input())!='*')
			        vecho();
			     vecho();
			     *yytext=lex_input();
			     vecho();
			  } while (*yytext != '/');
			}

.			{verror("Illegal character in input stream");}

%%
void vecho ()
   /* echo input on the listing file. */
  { static int BeginALine = 1;
	if (BeginALine) {
	  BeginALine = 0;
	  fprintf( listfile, "%4d ", ++vlinenumber );
	};
	yytext[yyleng] = (char) 0;
	fprintf( listfile, "%s", yytext );
	if ( yytext[ yyleng-1 ]=='\n' )
	  BeginALine = 1;
  }; /* vecho */

