/************************************************
 * This is a flex file generated by pretzel     *
 *                                              *
 ************************************************/

%{                                                     

 /* some needed headers: */                            
#include<iostream>                                   
#include"attr.h"                                     

 /* we'll define yywrap() which is needed for the scanner
  * here, so we won't have to bother about it if we're 
  * doing the standard case. You can define your own version
  * by #undef'ing PSCAN_YYWRAP and supplying your own definition
  * in the definitions section.                        
  */                                                   
#define PSCAN_YYWRAP                                   

 /* input will come from this istream */               
static istream * yyin_stream;                          

 /* redefine YYINPUT to read from input streams */     
#undef YY_INPUT                                        
#define YY_INPUT(buf, result, max_size) {         \
  if (yyin_stream->eof()) result=YY_NULL;         \
  else {                                          \
    yyin_stream->read(buf, max_size);             \
    result=yyin_stream->gcount();                 \
  }                                               \
}                                                      

%}                                                     


/* this is an example formatted token file for a pascal
 * prettyprinter.
 */



/************************************************
 * some pretzel definitions start here:         *
 ***********************************************/

%{                                                     

 /* the default name of the include file with the token
  * code definitions is stored in PTOKDEFS_NAME and    
  * defaults to `ptokdefs'.                            
  */                                                   
#ifndef PTOKDEFS_NAME                                  
#define PTOKDEFS_NAME "ptokdefs.h"                   
#endif                                                 

 /* now we have to include the token definitions */    
#include PTOKDEFS_NAME                                 

 /* allow user to choose generated scanner class name*/
#ifndef PSCAN_NAME                                     
#define PSCAN_NAME Ppscan                              
#include "Ppscan.h"                                  
#endif                                                 

 /* redefine the interface of the scanner */           
#undef YY_DECL                                         
#define YY_DECL int yylex (Attribute**rvalue)          

 /* here's the standard version of yywrap() */         
#ifdef PSCAN_YYWRAP                                    
extern "C" int yywrap() {                            
    return(1);                                         
}                                                      
#endif                                                 

%}                                                     


%%


"<>"		{ *rvalue=join(
			create("$\\neq$"));
			
		 return(MATH);}


"<="		|
">="		|
":="		{*rvalue=create(yytext);return (MATH);}


'[^'|'']*'		{*rvalue=create(yytext);return (SIMP);}


"("		{*rvalue=create(yytext);return (OPEN);}


")"		{*rvalue=create(yytext);return (CLOSE);}


"["		{*rvalue=create(yytext);return (OPEN);}


"]"		{*rvalue=create(yytext);return (CLOSE);}


"*"		{*rvalue=create(yytext);return (MATH);}


","		{ *rvalue=join(
			join(
				create(yytext),
				create(opt9)
			));
			
		 return(MATH);}


".."		{*rvalue=create(yytext);return (MATH);}


"."		{*rvalue=create(yytext);return (SIMP);}


":"		{*rvalue=create(yytext);return (COLON);}


";"		{*rvalue=create(yytext);return (SEMI);}


"="		{*rvalue=create(yytext);return (MATH);}


"+"		{*rvalue=create(yytext);return (MATH);}


[0-9]+		{*rvalue=create(yytext);return (SIMP);}


[0-9]*"."[0-9]+		{*rvalue=create(yytext);return (SIMP);}


and		{*rvalue=create(yytext);return (MATH);}


array		{*rvalue=create(yytext);return (ALPHA);}


begin		{ *rvalue=join(
			join(
				create(force),
				create(yytext)
			));
			
		 return(BEG);}


case		{ *rvalue=join(
			join(
				create(force),
				create(yytext)
			));
			
		 return(ALPHA);}


const		{ *rvalue=join(
			join(
				join(
				create(force),
				create(backup)
			),
				create(yytext)
			));
			
		 return(INTRO);}


div		{*rvalue=create(yytext);return (MATH);}


do		{*rvalue=create(yytext);return (OMEGA);}


downto		{*rvalue=create(yytext);return (MATH);}


else		{*rvalue=create(yytext);return (ELSE);}


end		{*rvalue=create(yytext);return (END);}


for		{*rvalue=create(yytext);return (ALPHA);}


function		{ *rvalue=join(
			join(
				join(
				create(force),
				create(backup)
			),
				create(yytext)
			));
			
		 return(PROC);}


if		{ *rvalue=join(
			join(
				join(
				create("{\\bf "),
				create(yytext)
			),
				create("}")
			));
			
		 return(ALPHA);}


mod		{*rvalue=create(yytext);return (MATH);}


not		{*rvalue=create(yytext);return (MATH);}


of		{*rvalue=create(yytext);return (OMEGA);}


or		{*rvalue=create(yytext);return (MATH);}


procedure		|
program		{ *rvalue=join(
			join(
				join(
				create(force),
				create(backup)
			),
				create(yytext)
			));
			
		 return(PROC);}


record		{*rvalue=create(yytext);return (BEG);}


repeat		{ *rvalue=join(
			join(
				create(force),
				create(yytext)
			));
			
		 return(BEG);}


then		{*rvalue=create(yytext);return (OMEGA);}


to		{*rvalue=create(yytext);return (MATH);}


type		{ *rvalue=join(
			join(
				join(
				create(force),
				create(backup)
			),
				create(yytext)
			));
			
		 return(INTRO);}


until		{ *rvalue=join(
			join(
				join(
				create(force),
				create(backup)
			),
				create(yytext)
			));
			
		 return(UNTIL);}


var		{ *rvalue=join(
			join(
				join(
				create(force),
				create(backup)
			),
				create(yytext)
			));
			
		 return(INTRO);}


while		{ *rvalue=join(
			join(
				create(force),
				create(yytext)
			));
			
		 return(ALPHA);}


[a-zA-Z][a-zA-Z0-9\_]*		{*rvalue=create(yytext);return (SIMP);}


[\t\ \n]		/* empty */


.		/* empty */

%%
/************************************************
 * additional pretzel C code follows here:      *
 ***********************************************/
PSCAN_NAME::PSCAN_NAME (istream* is ) : Pscan(is)
{                                              
    yyin_stream = is;                          
}                                              
int PSCAN_NAME::scan(Attribute* *rvalue)           
{                                              
    return(yylex(rvalue));                     
}                                              
PSCAN_NAME::~PSCAN_NAME ()                     
{                                              
    yyrestart(NULL);                           
}                                              
/************************************************
 * additional user defined C code follows here: *
 ***********************************************/


/* here's some additional C code */
